Objective Systems, Inc.  

ooSocket.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 1997-2009 by Objective Systems, Inc.
00003  *
00004  * This software is furnished under an open source license and may be
00005  * used and copied only in accordance with the terms of this license.
00006  * The text of the license may generally be found in the root
00007  * directory of this installation in the COPYING file.  It
00008  * can also be viewed online at the following URL:
00009  *
00010  *   http://www.obj-sys.com/open/license.html
00011  *
00012  * Any redistributions of this file including modified versions must
00013  * maintain this copyright notice.
00014  *
00015  *****************************************************************************/
00016 
00022 #ifndef _OOSOCKET_H_
00023 #define _OOSOCKET_H_
00024 
00025 #ifdef _WIN32_WCE
00026 #include <winsock.h>
00027 #elif defined(_WIN32) || defined(_WIN64)
00028 #include <sys/types.h>
00029 #define INCL_WINSOCK_API_TYPEDEFS   1
00030 #define INCL_WINSOCK_API_PROTOTYPES 0
00031 #include <winsock2.h>
00032 #else
00033 #include <sys/types.h>
00034 #include "sys/time.h"
00035 #include <sys/socket.h>
00036 #include <sys/ioctl.h>
00037 #include <netinet/in.h>
00038 #include <netdb.h>
00039 #include <unistd.h>
00040 #include <arpa/inet.h>
00041 #include <net/if.h>
00042 #endif
00043 
00044 #include "ooasn1.h"
00045 
00046 #ifdef __cplusplus
00047 extern "C" {
00048 #endif
00049 
00050 #ifndef EXTERN
00051 #ifdef MAKE_DLL
00052 #define EXTERN __declspec(dllexport)
00053 #elif defined (USEASN1DLL)
00054 #define EXTERN __declspec(dllimport)
00055 #else
00056 #define EXTERN
00057 #endif /* MAKE_DLL */
00058 #endif /* EXTERN */
00059 
00064 #if defined (_WIN64)
00065 typedef unsigned __int64 OOSOCKET; 
00066 #elif defined (_WIN32)
00067 typedef unsigned int OOSOCKET; 
00068 typedef int socklen_t;
00069 #else
00070 typedef int OOSOCKET;          
00071 #endif
00072 
00073 #define OOSOCKET_INVALID ((OOSOCKET)-1)
00074 
00075 
00082 typedef unsigned long OOIPADDR;
00083 
00084 #define OOIPADDR_ANY   ((OOIPADDR)0)
00085 #define OOIPADDR_LOCAL ((OOIPADDR)0x7f000001UL) /* 127.0.0.1 */
00086 
00087 typedef struct OOInterface{
00088    char *name;
00089    char *addr;
00090    char *mask;
00091    struct OOInterface *next;
00092 }OOInterface;
00093 
00094 
00095 
00115 EXTERN int ooSocketAccept (OOSOCKET socket, OOSOCKET *pNewSocket,
00116                              OOIPADDR* destAddr, int* destPort);
00117 
00128 EXTERN int ooSocketAddrToStr (OOIPADDR ipAddr, char* pbuf, int bufsize);
00129 
00143 EXTERN int ooSocketBind (OOSOCKET socket, OOIPADDR addr, int port);
00144 
00153 EXTERN int ooSocketClose (OOSOCKET socket);
00154 
00170 EXTERN int ooSocketConnect (OOSOCKET socket, const char* host, int port);
00171 
00181 EXTERN int ooSocketCreate (OOSOCKET* psocket);
00182 
00191 EXTERN int ooSocketCreateUDP (OOSOCKET* psocket);
00192 
00200 EXTERN int ooSocketsInit (void);
00201 
00209 EXTERN int ooSocketsCleanup (void);
00210 
00226 EXTERN int ooSocketListen (OOSOCKET socket, int maxConnection);
00227 
00228 
00240 EXTERN int ooSocketRecvPeek
00241    (OOSOCKET socket, ASN1OCTET* pbuf, ASN1UINT bufsize);
00242 
00255 EXTERN int ooSocketRecv (OOSOCKET socket, ASN1OCTET* pbuf,
00256                            ASN1UINT bufsize);
00257 
00277 EXTERN int ooSocketRecvFrom (OOSOCKET socket, ASN1OCTET* pbuf,
00278                              ASN1UINT bufsize, char * remotehost,
00279                              ASN1UINT hostBufLen, int * remoteport);
00292 EXTERN int ooSocketSend (OOSOCKET socket, const ASN1OCTET* pdata,
00293                            ASN1UINT size);
00294 
00311 EXTERN int ooSocketSendTo(OOSOCKET socket, const ASN1OCTET* pdata,
00312                             ASN1UINT size, const char* remotehost,
00313                             int remoteport);
00314 
00332 EXTERN int ooSocketSelect(int nfds, fd_set *readfds, fd_set *writefds,
00333                             fd_set *exceptfds, struct timeval * timeout);
00334 
00347 EXTERN int ooSocketStrToAddr (const char* pIPAddrStr, OOIPADDR* pIPAddr);
00348 
00360   EXTERN int ooSocketConvertIpToNwAddr (const char* inetIp, ASN1OCTET* netIp, size_t bufsiz);
00361 
00370 EXTERN int ooGetLocalIPAddress(char * pIPAddrs);
00371 
00372 EXTERN int ooSocketGetSockName
00373 (OOSOCKET socket, struct sockaddr_in *name, socklen_t* size);
00374 
00375 EXTERN long ooSocketHTONL(long val);
00376 
00377 EXTERN short ooSocketHTONS(short val);
00378 
00390 EXTERN int ooSocketGetIpAndPort(OOSOCKET socket, char *ip, int len, int *port);
00391 
00392 
00393 EXTERN int ooSocketGetInterfaceList(OOCTXT *pctxt, OOInterface **ifList);
00397 #ifdef __cplusplus
00398 }
00399 #endif
00400 
00401 #endif /* _OOSOCKET_H_ */
00402 

This file was last modified on 28 May 2010.
Objective Open H.323 Stack, 0.9.1