|
Odamex
Setting the Standard in Multiplayer Doom
|
00001 /* $Id: portlistingparse.h,v 1.4 2011/02/15 23:03:56 nanard Exp $ */ 00002 /* MiniUPnP project 00003 * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ 00004 * (c) 2011 Thomas Bernard 00005 * This software is subject to the conditions detailed 00006 * in the LICENCE file provided within the distribution */ 00007 #ifndef __PORTLISTINGPARSE_H__ 00008 #define __PORTLISTINGPARSE_H__ 00009 00010 #include "declspec.h" 00011 /* for the definition of UNSIGNED_INTEGER */ 00012 #include "miniupnpctypes.h" 00013 00014 #if defined(NO_SYS_QUEUE_H) || defined(WIN32) || defined(__HAIKU__) 00015 #include "bsdqueue.h" 00016 #else 00017 #include <sys/queue.h> 00018 #endif 00019 00020 #ifdef __cplusplus 00021 extern "C" { 00022 #endif 00023 00024 /* sample of PortMappingEntry : 00025 <p:PortMappingEntry> 00026 <p:NewRemoteHost>202.233.2.1</p:NewRemoteHost> 00027 <p:NewExternalPort>2345</p:NewExternalPort> 00028 <p:NewProtocol>TCP</p:NewProtocol> 00029 <p:NewInternalPort>2345</p:NewInternalPort> 00030 <p:NewInternalClient>192.168.1.137</p:NewInternalClient> 00031 <p:NewEnabled>1</p:NewEnabled> 00032 <p:NewDescription>dooom</p:NewDescription> 00033 <p:NewLeaseTime>345</p:NewLeaseTime> 00034 </p:PortMappingEntry> 00035 */ 00036 typedef enum { PortMappingEltNone, 00037 PortMappingEntry, NewRemoteHost, 00038 NewExternalPort, NewProtocol, 00039 NewInternalPort, NewInternalClient, 00040 NewEnabled, NewDescription, 00041 NewLeaseTime } portMappingElt; 00042 00043 struct PortMapping { 00044 LIST_ENTRY(PortMapping) entries; 00045 UNSIGNED_INTEGER leaseTime; 00046 unsigned short externalPort; 00047 unsigned short internalPort; 00048 char remoteHost[64]; 00049 char internalClient[64]; 00050 char description[64]; 00051 char protocol[4]; 00052 unsigned char enabled; 00053 }; 00054 00055 struct PortMappingParserData { 00056 LIST_HEAD(portmappinglisthead, PortMapping) head; 00057 portMappingElt curelt; 00058 }; 00059 00060 LIBSPEC void 00061 ParsePortListing(const char * buffer, int bufsize, 00062 struct PortMappingParserData * pdata); 00063 00064 LIBSPEC void 00065 FreePortListing(struct PortMappingParserData * pdata); 00066 00067 #ifdef __cplusplus 00068 } 00069 #endif 00070 00071 #endif