1/* $Id: portlistingparse.h,v 1.6 2012/03/05 19:42:47 nanard Exp $ */ 2/* MiniUPnP project 3 * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ 4 * (c) 2011-2012 Thomas Bernard 5 * This software is subject to the conditions detailed 6 * in the LICENCE file provided within the distribution */ 7#ifndef __PORTLISTINGPARSE_H__ 8#define __PORTLISTINGPARSE_H__ 9 10#include "declspec.h" 11/* for the definition of UNSIGNED_INTEGER */ 12#include "miniupnpctypes.h" 13 14#if defined(NO_SYS_QUEUE_H) || defined(_WIN32) || defined(__HAIKU__) 15#include "bsdqueue.h" 16#else 17#include <sys/queue.h> 18#endif 19 20#ifdef __cplusplus 21extern "C" { 22#endif 23 24/* sample of PortMappingEntry : 25 <p:PortMappingEntry> 26 <p:NewRemoteHost>202.233.2.1</p:NewRemoteHost> 27 <p:NewExternalPort>2345</p:NewExternalPort> 28 <p:NewProtocol>TCP</p:NewProtocol> 29 <p:NewInternalPort>2345</p:NewInternalPort> 30 <p:NewInternalClient>192.168.1.137</p:NewInternalClient> 31 <p:NewEnabled>1</p:NewEnabled> 32 <p:NewDescription>dooom</p:NewDescription> 33 <p:NewLeaseTime>345</p:NewLeaseTime> 34 </p:PortMappingEntry> 35 */ 36typedef enum { PortMappingEltNone, 37 PortMappingEntry, NewRemoteHost, 38 NewExternalPort, NewProtocol, 39 NewInternalPort, NewInternalClient, 40 NewEnabled, NewDescription, 41 NewLeaseTime } portMappingElt; 42 43struct PortMapping { 44 LIST_ENTRY(PortMapping) entries; 45 UNSIGNED_INTEGER leaseTime; 46 unsigned short externalPort; 47 unsigned short internalPort; 48 char remoteHost[64]; 49 char internalClient[64]; 50 char description[64]; 51 char protocol[4]; 52 unsigned char enabled; 53}; 54 55struct PortMappingParserData { 56 LIST_HEAD(portmappinglisthead, PortMapping) head; 57 portMappingElt curelt; 58}; 59 60LIBSPEC void 61ParsePortListing(const char * buffer, int bufsize, 62 struct PortMappingParserData * pdata); 63 64LIBSPEC void 65FreePortListing(struct PortMappingParserData * pdata); 66 67#ifdef __cplusplus 68} 69#endif 70 71#endif 72