Barracuda Application Server C/C++ Reference
NO
NetIo.h
1/*
2 * ____ _________ __ _
3 * / __ \___ ____ _/ /_ __(_)___ ___ ___ / / ____ ____ _(_)____
4 * / /_/ / _ \/ __ `/ / / / / / __ `__ \/ _ \/ / / __ \/ __ `/ / ___/
5 * / _, _/ __/ /_/ / / / / / / / / / / / __/ /___/ /_/ / /_/ / / /__
6 * /_/ |_|\___/\__,_/_/ /_/ /_/_/ /_/ /_/\___/_____/\____/\__, /_/\___/
7 * /____/
8 *
9 * Barracuda Application Server
10 *
11 ****************************************************************************
12 * HEADER
13 *
14 * $Id: NetIo.h 5392 2023-02-21 15:56:50Z 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 */
37#ifndef __NetIo_h
38#define __NetIo_h
39
40#include <HttpServer.h>
41#include <IoIntf.h>
42
43struct SoDisp;
44struct SharkSsl;
45struct HttpClient;
46
47
71typedef struct NetIo
72#ifdef __cplusplus
73: public IoIntf
74{
75 void *operator new(size_t s) { return ::baMalloc(s); }
76 void operator delete(void* d) { if(d) ::baFree(d); }
77 void *operator new(size_t, void *place) { return place; }
78 void operator delete(void*, void *) { }
88 NetIo(struct SoDisp* disp=0);
89
92 ~NetIo();
93
119 int setRootDir(const char* url);
120
123 int setUser(const char* user, const char* password);
124
130 int setProxy(const char* proxy, U16 portNo, BaBool useSocksProxy);
131
134 int setProxyUser(const char* user, const char* password);
135
138 int setIntfName(const char* intfName);
139
142 void setIPv6(bool enable);
143
144 /* Enable secure connections. The SharkSsl instance must have
145 been initialized as a SharkSsl_Client.
146 */
147 void setSSL(struct SharkSsl* sharkSslClient);
148#if 0
149}
150#endif
151#else
152{
153 IoIntf super; /* Inherits from IoIntf */
154#endif
155 ThreadMutex netMutex;
156 SoDisp* disp;
157
158 struct SharkSsl* sharkSslClient; /* optional SSL client */
159
160 /* Variable proxyPortNo and the 3 following variables are sent
161 * to the HttpClient.
162 */
163 char* proxy; /* Proxy name/IP addr, if any */
164 char* proxyUserPass; /* Format: "user:password" */
165 char* intfName; /* If 0: bind to any intf, or bind to intfName */
166 struct HttpClient* cCon;
167 char* userPass;
168 char* rootPath; /* The base URL */
169 int rootPathLen;
170
171 U16 proxyPortNo; /* host port number */
172
173 U8 httpClientMode; /* HttpClient_SocksProxy | HttpClient_IPv6 */
174} NetIo;
175
176#ifdef __cplusplus
177extern "C" {
178#endif
179
180void NetIo_constructor(NetIo* o, struct SoDisp* disp);
181void NetIo_destructor(NetIo* o);
182int NetIo_setRootDir(NetIo* o, const char* url);
183
184
185int NetIo_setUser(NetIo* o, const char* user, const char* password);
186int NetIo_setProxy(
187 NetIo* o, const char* proxy, U16 portNo, BaBool useSocksProxy);
188int NetIo_setProxyUser(NetIo* o, const char* user, const char* password);
189int NetIo_setIntfName(NetIo* o, const char* intfName);
190int NetIo_setIPv6(NetIo* o, BaBool enable);
191#define NetIo_setSSL(o, ssl) (o)->sharkSslClient=ssl
192
193
194#ifdef __cplusplus
195}
196
197inline NetIo::NetIo(struct SoDisp* disp) {
198 NetIo_constructor(this, disp);
199}
201 NetIo_destructor(this);
202}
203inline int NetIo::setRootDir(const char* url) {
204 return NetIo_setRootDir(this, url);
205}
206inline int NetIo::setUser(const char* user, const char* password) {
207 return NetIo_setUser(this, user, password);
208}
209inline int NetIo::setProxy(const char* proxy,U16 portNo,BaBool useSocksProxy) {
210 return NetIo_setProxy(this, proxy, portNo, useSocksProxy);
211}
212inline int NetIo::setProxyUser(const char* user, const char* password) {
213 return NetIo_setProxyUser(this, user, password);
214}
215inline int NetIo::setIntfName(const char* intfName) {
216 return NetIo_setIntfName(this, intfName);
217}
218inline void NetIo::setIPv6(bool enable) {
219 NetIo_setIPv6(this, enable ? TRUE : FALSE);
220}
221inline void NetIo::setSSL(struct SharkSsl* sharkSslClient) {
222 NetIo_setSSL(this, sharkSslClient);
223}
224#endif
225
226
227#endif
void * baMalloc(size_t size)
Returns pointer to uninitialized newly-allocated space for an object of size "size",...
void baFree(void *p)
Deallocates space to which it points.
The HTTP(S) "C" client library implementation conforms to the HTTP/1.1 standard, RFC 2616.
Definition: HttpClient.h:190
The IoIntf class specifies an abstract file API, implementations include ZipIo, DiskIo,...
Definition: IoIntf.h:377
The NetIo is similar to a network file system and makes it possible for the server to access resource...
Definition: NetIo.h:74
int setIntfName(const char *intfName)
When connection, bind to intfName.
Definition: NetIo.h:215
int setRootDir(const char *url)
Initialize/set the URL to the far side Barracuda server.
Definition: NetIo.h:203
void setIPv6(bool enable)
Use IPv6, default is IPv4.
Definition: NetIo.h:218
int setProxyUser(const char *user, const char *password)
Set proxy username.
Definition: NetIo.h:212
int setProxy(const char *proxy, U16 portNo, BaBool useSocksProxy)
Set proxy.
Definition: NetIo.h:209
NetIo(struct SoDisp *disp=0)
The NetIo constructor.
Definition: NetIo.h:197
~NetIo()
The NetIo destructor.
Definition: NetIo.h:200
int setUser(const char *user, const char *password)
Set HTTP basic authentication username and password.
Definition: NetIo.h:206
The SoDisp dispatches any socket connection that contains data by calling the SoDispCon::execute memb...
Definition: SoDisp.h:86
A mutual exclusion class.
Definition: ThreadLib.h:186