Barracuda Application Server C/C++ Reference
Native APIs, integration guides, and platform interfaces
NetIo.h
Go to the documentation of this file.
1/*
2 * ____ _________ __ _
3 * / __ \___ ____ _/ /_ __(_)___ ___ ___ / / ____ ____ _(_)____
4 * / /_/ / _ \/ __ `/ / / / / / __ `__ \/ _ \/ / / __ \/ __ `/ / ___/
5 * / _, _/ __/ /_/ / / / / / / / / / / / __/ /___/ /_/ / /_/ / / /__
6 * /_/ |_|\___/\__,_/_/ /_/ /_/_/ /_/ /_/\___/_____/\____/\__, /_/\___/
7 * /____/
8 *
9 * Barracuda Application Server
10 *
11 ****************************************************************************
12 * HEADER
13 *
14 * $Id: NetIo.h 5978 2026-09-11 16:13:48Z wini $
15 *
16 * COPYRIGHT: Real Time Logic LLC, 2008 - 2020
17 * http://www.realtimelogic.com
18 *
19 * This software is copyrighted by and is the sole property of Real
20 * Time Logic LLC. All rights, title, ownership, or other interests in
21 * the software remain the property of Real Time Logic LLC. This
22 * software may only be used in accordance with the terms and
23 * conditions stipulated in the corresponding license agreement under
24 * which the software has been supplied. Any unauthorized use,
25 * duplication, transmission, distribution, or disclosure of this
26 * software is expressly forbidden.
27 *
28 * This Copyright notice may not be removed or modified without prior
29 * written consent of Real Time Logic LLC.
30 *
31 * Real Time Logic LLC. reserves the right to modify this software
32 * without notice.
33 *
34 * http://www.realtimelogic.com
35 ****************************************************************************
36 */
39#ifndef __NetIo_h
40#define __NetIo_h
41
42#include <HttpServer.h>
43#include <IoIntf.h>
44
45struct SoDisp;
46struct SharkSsl;
47struct HttpClient;
48
49
74typedef struct NetIo
75#ifdef __cplusplus
76: public IoIntf
77{
78 void *operator new(size_t s) { return ::baMalloc(s); }
79 void operator delete(void* d) { if(d) ::baFree(d); }
80 void *operator new(size_t, void *place) { return place; }
81 void operator delete(void*, void *) { }
92 NetIo(struct SoDisp* disp=0);
93
98 ~NetIo();
99
131 int setRootDir(const char* url);
132
140 int setUser(const char* user, const char* password);
141
151 int setProxy(const char* proxy, U16 portNo, BaBool useSocksProxy);
152
160 int setProxyUser(const char* user, const char* password);
161
167 int setIntfName(const char* intfName);
168
172 void setIPv6(bool enable);
173
180 void setSSL(struct SharkSsl* sharkSslClient);
181#if 0
182}
183#endif
184#else
185{
186 IoIntf super; /* Inherits from IoIntf */
187#endif
188 ThreadMutex netMutex;
189 SoDisp* disp;
190
191 struct SharkSsl* sharkSslClient; /* optional SSL client */
192
193 /* Variable proxyPortNo and the 3 following variables are sent
194 * to the HttpClient.
195 */
196 char* proxy; /* Proxy name/IP addr, if any */
197 char* proxyUserPass; /* Format: "user:password" */
198 char* intfName; /* If 0: bind to any intf, or bind to intfName */
199 struct HttpClient* cCon;
200 char* userPass;
201 char* rootPath; /* The base URL */
202 int rootPathLen;
203
204 U16 proxyPortNo; /* host port number */
205
206 U8 httpClientMode; /* HttpClient_SocksProxy | HttpClient_IPv6 */
208
209#ifdef __cplusplus
210extern "C" {
211#endif
212
215void NetIo_constructor(NetIo* o, struct SoDisp* disp);
221int NetIo_setRootDir(NetIo* o, const char* url);
222
223
226int NetIo_setUser(NetIo* o, const char* user, const char* password);
230 NetIo* o, const char* proxy, U16 portNo, BaBool useSocksProxy);
233int NetIo_setProxyUser(NetIo* o, const char* user, const char* password);
236int NetIo_setIntfName(NetIo* o, const char* intfName);
241int NetIo_setIPv6(NetIo* o, BaBool enable);
246#define NetIo_setSSL(o, ssl) (o)->sharkSslClient=ssl
247
248
249#ifdef __cplusplus
250}
251
252inline NetIo::NetIo(struct SoDisp* disp) {
253 NetIo_constructor(this, disp);
254}
256 NetIo_destructor(this);
257}
258inline int NetIo::setRootDir(const char* url) {
259 return NetIo_setRootDir(this, url);
260}
261inline int NetIo::setUser(const char* user, const char* password) {
262 return NetIo_setUser(this, user, password);
263}
264inline int NetIo::setProxy(const char* proxy,U16 portNo,BaBool useSocksProxy) {
265 return NetIo_setProxy(this, proxy, portNo, useSocksProxy);
266}
267inline int NetIo::setProxyUser(const char* user, const char* password) {
268 return NetIo_setProxyUser(this, user, password);
269}
270inline int NetIo::setIntfName(const char* intfName) {
271 return NetIo_setIntfName(this, intfName);
272}
273inline void NetIo::setIPv6(bool enable) {
274 NetIo_setIPv6(this, enable ? TRUE : FALSE);
275}
276inline void NetIo::setSSL(struct SharkSsl* sharkSslClient) {
277 NetIo_setSSL(this, sharkSslClient);
278}
279#endif
280
281
282#endif
void NetIo_destructor(NetIo *o)
Close the cached HTTP client and free copied configuration and its mutex.
int NetIo_setProxyUser(NetIo *o, const char *user, const char *password)
Set copied proxy authentication credentials; discard the cached client.
int NetIo_setProxy(NetIo *o, const char *proxy, U16 portNo, BaBool useSocksProxy)
Set proxy.
int NetIo_setIntfName(NetIo *o, const char *intfName)
Select the local interface for future HTTP clients.
#define NetIo_setSSL(o, ssl)
Assign TLS configuration for future clients without changing the cached client.
Definition: NetIo.h:246
int NetIo_setUser(NetIo *o, const char *user, const char *password)
Set HTTP Basic authentication credentials and discard the cached client.
int NetIo_setIPv6(NetIo *o, BaBool enable)
Select the family for subsequent connections and discard the cached client.
void NetIo_constructor(NetIo *o, struct SoDisp *disp)
The NetIo constructor.
int NetIo_setRootDir(NetIo *o, const char *url)
Initialize/set the URL to the far side Barracuda server.
NetIo NetIo
The NetIo is similar to a network file system and makes it possible for the server to access resource...
void * baMalloc(size_t size)
Allocate uninitialized storage using the target's configured allocator.
void baFree(void *p)
Release storage using the target's configured allocator.
uint16_t U16
Unsigned 16-bit integer.
Definition: GenPrimT.h:91
uint8_t U8
Unsigned 8-bit integer.
Definition: GenPrimT.h:89
U8 BaBool
Boolean stored in an unsigned byte; FALSE is zero and TRUE is one.
Definition: GenPrimT.h:118
Blocking HTTP/1.1 client with optional SharkSSL HTTPS support.
Definition: HttpClient.h:187
U16 proxyPortNo
Proxy TCP port, 1 through 65535 when proxy is configured.
Definition: HttpClient.h:396
const char * intfName
Borrowed local interface name/address, or NULL for the default binding.
Definition: HttpClient.h:386
const char * proxy
Borrowed proxy host string, or NULL for a direct connection.
Definition: HttpClient.h:382
The IoIntf class specifies an abstract file API, implementations include ZipIo, DiskIo,...
Definition: IoIntf.h:482
The NetIo is similar to a network file system and makes it possible for the server to access resource...
Definition: NetIo.h:77
int setIntfName(const char *intfName)
Select the local interface for future HTTP clients.
Definition: NetIo.h:270
int setRootDir(const char *url)
Initialize/set the URL to the far side Barracuda server.
Definition: NetIo.h:258
void setIPv6(bool enable)
Select the address family and discard the cached client.
Definition: NetIo.h:273
int setProxyUser(const char *user, const char *password)
Set copied proxy authentication credentials; discard the cached client.
Definition: NetIo.h:267
int setProxy(const char *proxy, U16 portNo, BaBool useSocksProxy)
Set proxy.
Definition: NetIo.h:264
void setSSL(struct SharkSsl *sharkSslClient)
Configure TLS for future HTTP clients.
Definition: NetIo.h:276
NetIo(struct SoDisp *disp=0)
The NetIo constructor.
Definition: NetIo.h:252
~NetIo()
Close the cached HTTP client and free copied configuration and its mutex.
Definition: NetIo.h:255
int setUser(const char *user, const char *password)
Set HTTP Basic authentication credentials and discard the cached client.
Definition: NetIo.h:261
The SoDisp dispatches any socket connection that contains data by calling the SoDispCon::execute memb...
Definition: SoDisp.h:91
A mutual exclusion class.
Definition: ThreadLib.h:196