Barracuda Application Server C/C++ Reference
Native APIs, integration guides, and platform interfaces
NetIo.h File Reference
#include <HttpServer.h>
#include <IoIntf.h>
Include dependency graph for NetIo.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  NetIo
 The NetIo is similar to a network file system and makes it possible for the server to access resources on another Barracuda server. More...
 

Macros

#define NetIo_setSSL(o, ssl)   (o)->sharkSslClient=ssl
 Assign TLS configuration for future clients without changing the cached client. More...
 

Typedefs

typedef NetIo NetIo
 The NetIo is similar to a network file system and makes it possible for the server to access resources on another Barracuda server. More...
 

Functions

void NetIo_constructor (NetIo *o, struct SoDisp *disp)
 The NetIo constructor. More...
 
void NetIo_destructor (NetIo *o)
 Close the cached HTTP client and free copied configuration and its mutex. More...
 
int NetIo_setRootDir (NetIo *o, const char *url)
 Initialize/set the URL to the far side Barracuda server. More...
 
int NetIo_setUser (NetIo *o, const char *user, const char *password)
 Set HTTP Basic authentication credentials and discard the cached client. More...
 
int NetIo_setProxy (NetIo *o, const char *proxy, U16 portNo, BaBool useSocksProxy)
 Set proxy. More...
 
int NetIo_setProxyUser (NetIo *o, const char *user, const char *password)
 Set copied proxy authentication credentials; discard the cached client. More...
 
int NetIo_setIntfName (NetIo *o, const char *intfName)
 Select the local interface for future HTTP clients. More...
 
int NetIo_setIPv6 (NetIo *o, BaBool enable)
 Select the family for subsequent connections and discard the cached client. More...
 

Macro Definition Documentation

◆ NetIo_setSSL

#define NetIo_setSSL (   o,
  ssl 
)    (o)->sharkSslClient=ssl

Assign TLS configuration for future clients without changing the cached client.

Parameters
[in,out]oInitialized NetIo.
[in]sslBorrowed initialized SharkSsl_Client or NULL, valid throughout use.
See also
NetIo::setSSL

Typedef Documentation

◆ NetIo

typedef NetIo NetIo

The NetIo is similar to a network file system and makes it possible for the server to access resources on another Barracuda server.

The NetIo is a web file manager client specifically designed to operate a remote HttpResMgr. In other words, the remote HttpResMgr's file system appears as a local file system to code using an instance of the NetIo class.

The NetIo is typically used during development of LSP code in an embedded device without a file system. The device can access resources on for example a remote Windows computer as if the resources are locally on the device.

It is recommended to increase the size of the Web server's default HTTP response buffer if NetIo is configured as the I/O for a HttpResRdr, HttpResMgr, or a WebDAV instance. A size of 8Kbytes can reduce remote read requests compared with a small buffer; the benefit depends on the resources and access pattern. See HttpServerConfig::setResponseData for more information.

The NetIo code, which can be found in xrc/misc/NetIo.c, is delivered as example code. You must therefore include this code in your build if you intend to use NetIo. Serialize configuration changes with file operations; the internal I/O mutex does not protect all setters.

Function Documentation

◆ NetIo_constructor()

void NetIo_constructor ( NetIo o,
struct SoDisp disp 
)

The NetIo constructor.

A NetIo instance cannot be used before it is initialized by calling NetIo::setRootDir.

Parameters
dispBorrowed dispatcher (default NULL), valid throughout use. This optional parameter that makes the integrated NetIo HTTP client release the dispatcher mutex when reading from or writing to the socket. The 'disp' parameter is typically set if the NetIo class is used by a Barracuda Web Server object such as a HttpResRdr instance.
[in,out]oCaller-owned NetIo instance.

◆ NetIo_destructor()

void NetIo_destructor ( NetIo o)

Close the cached HTTP client and free copied configuration and its mutex.

Close open resources/iterators and stop callers first. Does not destroy the borrowed dispatcher or TLS client.

Parameters
[in,out]oCaller-owned NetIo instance.

◆ NetIo_setIntfName()

int NetIo_setIntfName ( NetIo o,
const char *  intfName 
)

Select the local interface for future HTTP clients.

Parameters
[in]intfNameCopied NUL-terminated platform interface/address, or NULL to use the default. Does not replace an already cached client.
Returns
Zero success, E_MALLOC allocation failure. Old value is discarded.
Parameters
[in,out]oCaller-owned NetIo instance.

◆ NetIo_setIPv6()

int NetIo_setIPv6 ( NetIo o,
BaBool  enable 
)

Select the family for subsequent connections and discard the cached client.

Parameters
[in,out]oInitialized NetIo.
[in]enableTRUE selects IPv6, FALSE IPv4.
Returns
Always zero. The C++ wrapper returns no value.

◆ NetIo_setProxy()

int NetIo_setProxy ( NetIo o,
const char *  proxy,
U16  portNo,
BaBool  useSocksProxy 
)

Set proxy.

Parameters
proxyCopied NUL-terminated proxy hostname/address, or NULL to disable.
portNoProxy TCP port in host byte order, 1..65535 when enabled.
useSocksProxyFALSE selects the HTTP CONNECT proxy path; TRUE selects SOCKS5. This is a proxy protocol choice, not a promise of encrypted communication with the proxy itself.
Returns
Zero success, E_MALLOC allocation failure. Discards the cached client and changes proxy mode before allocating the new address.
Parameters
[in,out]oCaller-owned NetIo instance.

◆ NetIo_setProxyUser()

int NetIo_setProxyUser ( NetIo o,
const char *  user,
const char *  password 
)

Set copied proxy authentication credentials; discard the cached client.

Parameters
[in]userNUL-terminated username, or NULL to clear credentials.
[in]passwordNUL-terminated password, or NULL when user already contains user:password. Configure before opening remote resources.
Returns
Zero success, E_MALLOC allocation failure; old credentials are discarded before allocation.
Parameters
[in,out]oCaller-owned NetIo instance.

◆ NetIo_setRootDir()

int NetIo_setRootDir ( NetIo o,
const char *  url 
)

Initialize/set the URL to the far side Barracuda server.

The URL must identify the root of a HttpResMgr or a subdirectory within a HttpResMgr instance. As an example, a far side Barracuda server, with a HttpResMgr instance installed in the Virtual File System at URI /drive/ can be initialized as follows:

Base url: http://domainname/drive/
Sub-directory: http://domainname/drive/c/lsp/

In the second example above, the far side HttpResMgr is mapped to the root of the Windows computer. The path /c/lsp/ is to a directory where the files to a LSP application can be found.

The NetIo instance can also access a remote HttpResMgr protected by an authenticator as long as the far side authenticator accepts Basic authentication. In other words, the far side authenticator must be BasicAuthenticator or Authenticator.

Parameters
urlRequired NUL-terminated HTTP(S) URL to the remote HttpResMgr directory, copied and normalized with a trailing slash. Example: http://192.168.1.100/fs/. Configure authentication and TLS first.
Returns
Zero after the remote stat confirms a directory; E_INVALID_URL for an invalid URL, E_MALLOC for allocation failure, IOINTF_ENOENT for a nondirectory, or another I/O/network status. This operation performs network I/O. The previous root is discarded even if the change fails; a failed instance must receive a valid root before normal file operations.
Parameters
[in,out]oCaller-owned NetIo instance.

◆ NetIo_setUser()

int NetIo_setUser ( NetIo o,
const char *  user,
const char *  password 
)

Set HTTP Basic authentication credentials and discard the cached client.

Parameters
[in]userNUL-terminated username, or NULL to clear credentials.
[in]passwordNUL-terminated password; if NULL, user must contain the complete user:password string. Strings are copied.
Returns
Zero success, E_MALLOC allocation failure. Old credentials are discarded before allocation, so failure is not a rollback.
Parameters
[in,out]oCaller-owned NetIo instance.