17 #ifndef _OsSocketCrypto_h_ 18 #define _OsSocketCrypto_h_ 32 #define MAX_CRYPTOBUFFER 3000 51 class OsSocketCryptoProxy
61 OsSocketCryptoProxy(
OsSocket* pureSocket,
64 int (
OsSocket::*read3)(
char*,
int,
struct in_addr*,
int*),
65 int (
OsSocket::*read4)(
char*,
int,
long),
66 int (
OsSocket::*write1)(
const char*,
int),
67 int (
OsSocket::*write2)(
const char*,
int,
const char*,
int),
68 int (
OsSocket::*write3)(
const char*,
int,
long),
69 const char* pEncBinData,
71 const char* pDecBinData,
75 virtual ~OsSocketCryptoProxy();
84 int write(
const char* buffer,
int bufferLength);
87 int write(
const char* buffer,
int bufferLength,
88 const char* ipAddress,
int port);
91 int write(
const char* buffer,
int bufferLength,
long waitMilliseconds);
95 int read(
char* buffer,
int bufferLength);
98 int read(
char* buffer,
int bufferLength,
102 int read(
char* buffer,
int bufferLength,
103 struct in_addr* ipAddress,
int* port);
106 int read(
char* buffer,
int bufferLength,
long waitMilliseconds);
133 UtlBoolean setSymKeys(
const char* pEncBinData,
135 const char* pDecBinData,
139 uint8_t mCryptoBuffer[MAX_CRYPTOBUFFER];
140 uint8_t mDecodeBuffer[MAX_CRYPTOBUFFER];
148 UtlBoolean decode(
char* buffer,
int bufferLength,
int originalLength,
int& decodedLen);
151 UtlBoolean encode(
const char* buffer,
int bufferLength,
int& encodedLen);
154 int (
OsSocket::*mRead1)(
char* buffer,
int bufferLength);
157 int (
OsSocket::*mRead2)(
char* buffer,
int bufferLength,
161 int (
OsSocket::*mRead3)(
char* buffer,
int bufferLength,
162 struct in_addr* ipAddress,
int* port);
165 int (
OsSocket::*mRead4)(
char* buffer,
int bufferLength,
long waitMilliseconds);
168 int (
OsSocket::*mWrite1)(
const char* buffer,
int bufferLength);
171 int (
OsSocket::*mWrite2)(
const char* buffer,
int bufferLength,
172 const char* ipAddress,
int port);
175 int (
OsSocket::*mWrite3)(
const char* buffer,
int bufferLength,
176 long waitMilliseconds);
186 OsMulticastSocketCrypto(
int multicastPortNum,
187 const char* multicastHost,
188 int localHostPortNum,
189 const char* localHost,
190 const char* pEncBinData,
192 const char* pDecBinData,
194 :
OsMulticastSocket(multicastPortNum, multicastHost, localHostPortNum, localHost)
196 (int (
OsSocket::*)(char*, int))&OsMulticastSocketCrypto::readProxy1,
197 (int (
OsSocket::*)(char*, int,
UtlString*, int*))&OsMulticastSocketCrypto::readProxy2,
198 (int (
OsSocket::*)(char*, int, struct in_addr*, int*))&OsMulticastSocketCrypto::readProxy3,
199 (int (
OsSocket::*)(char*, int, long))&OsMulticastSocketCrypto::readProxy4,
200 (int (
OsSocket::*)(const char*, int))&OsMulticastSocketCrypto::writeProxy1,
201 (int (
OsSocket::*)(const char*, int, const char*, int))&OsMulticastSocketCrypto::writeProxy2,
203 pEncBinData, encBinLength, pDecBinData, decBinLength)
207 int write(
const char* buffer,
int bufferLength)
209 return mCryptoProxy.write(buffer, bufferLength);
212 int write(
const char* buffer,
int bufferLength,
213 const char* ipAddress,
int port)
215 return mCryptoProxy.write(buffer, bufferLength, ipAddress, port);
218 int read(
char* buffer,
int bufferLength)
220 return mCryptoProxy.read(buffer, bufferLength);
223 int read(
char* buffer,
int bufferLength,
226 return mCryptoProxy.read(buffer, bufferLength, fromAddress, fromPort);
229 int read(
char* buffer,
int bufferLength,
230 struct in_addr* ipAddress,
int* port)
232 return mCryptoProxy.read(buffer, bufferLength, ipAddress, port);
235 int read(
char* buffer,
int bufferLength,
236 long waitMilliseconds)
238 return mCryptoProxy.read(buffer, bufferLength, waitMilliseconds);
242 int writeProxy1(
const char* buffer,
int bufferLength)
247 int writeProxy2(
const char* buffer,
int bufferLength,
248 const char* ipAddress,
int port)
254 int readProxy1(
char* buffer,
int bufferLength)
259 int readProxy2(
char* buffer,
int bufferLength,
262 return OsSocket::read(buffer, bufferLength, fromAddress, fromPort);
265 int readProxy3(
char* buffer,
int bufferLength,
266 struct in_addr* ipAddress,
int* port)
271 int readProxy4(
char* buffer,
int bufferLength,
272 long waitMilliseconds)
278 OsSocketCryptoProxy mCryptoProxy;
286 OsNatDatagramSocketCrypto(
int remoteHostPortNum,
287 const char* remoteHost,
288 int localHostPortNum,
289 const char* localHost,
291 const char* pEncBinData,
293 const char* pDecBinData,
295 :
OsNatDatagramSocket(remoteHostPortNum, remoteHost, localHostPortNum, localHost, pNotification)
297 (int (
OsSocket::*)(char*, int))&OsNatDatagramSocketCrypto::readProxy1,
298 (int (
OsSocket::*)(char*, int,
UtlString*, int*))&OsNatDatagramSocketCrypto::readProxy2,
299 (int (
OsSocket::*)(char*, int, struct in_addr*, int*))&OsNatDatagramSocketCrypto::readProxy3,
300 (int (
OsSocket::*)(char*, int, long))&OsNatDatagramSocketCrypto::readProxy4,
301 (int (
OsSocket::*)(const char*, int))&OsNatDatagramSocketCrypto::writeProxy1,
302 (int (
OsSocket::*)(const char*, int, const char*, int))&OsNatDatagramSocketCrypto::writeProxy2,
303 (int (
OsSocket::*)(const char*, int, long))&OsNatDatagramSocketCrypto::writeProxy3,
304 pEncBinData, encBinLength, pDecBinData, decBinLength)
308 int write(
const char* buffer,
int bufferLength)
310 return mCryptoProxy.write(buffer, bufferLength);
313 int write(
const char* buffer,
int bufferLength,
314 const char* ipAddress,
int port)
316 return mCryptoProxy.write(buffer, bufferLength, ipAddress, port);
319 int write(
const char* buffer,
int bufferLength,
long waitMilliseconds)
321 return mCryptoProxy.write(buffer, bufferLength, waitMilliseconds);
324 int read(
char* buffer,
int bufferLength)
326 return mCryptoProxy.read(buffer, bufferLength);
329 int read(
char* buffer,
int bufferLength,
332 return mCryptoProxy.read(buffer, bufferLength, fromAddress, fromPort);
335 int read(
char* buffer,
int bufferLength,
336 struct in_addr* ipAddress,
int* port)
338 return mCryptoProxy.read(buffer, bufferLength, ipAddress, port);
341 int read(
char* buffer,
int bufferLength,
342 long waitMilliseconds)
344 return mCryptoProxy.read(buffer, bufferLength, waitMilliseconds);
348 int writeProxy1(
const char* buffer,
int bufferLength)
353 int writeProxy2(
const char* buffer,
int bufferLength,
354 const char* ipAddress,
int port)
359 int writeProxy3(
const char* buffer,
int bufferLength,
360 long waitMilliseconds)
366 int readProxy1(
char* buffer,
int bufferLength)
371 int readProxy2(
char* buffer,
int bufferLength,
377 int readProxy3(
char* buffer,
int bufferLength,
378 struct in_addr* ipAddress,
int* port)
383 int readProxy4(
char* buffer,
int bufferLength,
384 long waitMilliseconds)
389 OsSocketCryptoProxy mCryptoProxy;
392 #endif // _OsSocketCrypto_h_
Definition: OsSocket.h:79
A generic cryptography key base class.
Definition: UtlCryptoKey.h:36
int read(int fd, void *buffer, unsigned int count)
unsigned char uint8_t
Definition: stdint.h:78
Definition: OsNotification.h:35
virtual int read(char *buffer, int bufferLength)
Definition: OsNatDatagramSocket.cpp:107
#define NULL
Definition: UtlDefs.h:29
virtual int read(char *buffer, int bufferLength)
param: waitMilliseconds - The maximum number of milliseconds to block. This may be set to zero...
Definition: OsSocket.cpp:235
virtual int write(const char *buffer, int bufferLength)
param: remoteHostName - remote host to send datagram(s) in subsequent calls to write (overloaded vers...
Definition: OsDatagramSocket.cpp:328
Definition: OsNatDatagramSocket.h:100
Definition: UtlString.h:48
int write(int fd, const void *buffer, unsigned int count)
virtual int read(char *buffer, int bufferLength)
param: buffer - the bytes to be written to the socket param: bufferLength - the number of bytes conta...
Definition: OsDatagramSocket.cpp:499
Definition: OsMulticastSocket.h:33
int UtlBoolean
Definition: UtlDefs.h:41
virtual int write(const char *buffer, int bufferLength)
Definition: OsNatDatagramSocket.cpp:239