portlistingparse.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /* $Id: portlistingparse.h,v 1.10 2014/11/01 10:37:32 nanard Exp $ */
  2. /* MiniUPnP project
  3. * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
  4. * (c) 2011-2015 Thomas Bernard
  5. * This software is subject to the conditions detailed
  6. * in the LICENCE file provided within the distribution */
  7. #ifndef PORTLISTINGPARSE_H_INCLUDED
  8. #define PORTLISTINGPARSE_H_INCLUDED
  9. #include "miniupnpc_declspec.h"
  10. /* for the definition of UNSIGNED_INTEGER */
  11. #include "miniupnpctypes.h"
  12. #ifdef __cplusplus
  13. extern "C" {
  14. #endif
  15. /* sample of PortMappingEntry :
  16. <p:PortMappingEntry>
  17. <p:NewRemoteHost>202.233.2.1</p:NewRemoteHost>
  18. <p:NewExternalPort>2345</p:NewExternalPort>
  19. <p:NewProtocol>TCP</p:NewProtocol>
  20. <p:NewInternalPort>2345</p:NewInternalPort>
  21. <p:NewInternalClient>192.168.1.137</p:NewInternalClient>
  22. <p:NewEnabled>1</p:NewEnabled>
  23. <p:NewDescription>dooom</p:NewDescription>
  24. <p:NewLeaseTime>345</p:NewLeaseTime>
  25. </p:PortMappingEntry>
  26. */
  27. typedef enum { PortMappingEltNone,
  28. PortMappingEntry, NewRemoteHost,
  29. NewExternalPort, NewProtocol,
  30. NewInternalPort, NewInternalClient,
  31. NewEnabled, NewDescription,
  32. NewLeaseTime } portMappingElt;
  33. struct PortMapping {
  34. struct PortMapping * l_next; /* list next element */
  35. UNSIGNED_INTEGER leaseTime;
  36. unsigned short externalPort;
  37. unsigned short internalPort;
  38. char remoteHost[64];
  39. char internalClient[64];
  40. char description[64];
  41. char protocol[4];
  42. unsigned char enabled;
  43. };
  44. struct PortMappingParserData {
  45. struct PortMapping * l_head; /* list head */
  46. portMappingElt curelt;
  47. };
  48. MINIUPNP_LIBSPEC void
  49. ParsePortListing(const char * buffer, int bufsize,
  50. struct PortMappingParserData * pdata);
  51. MINIUPNP_LIBSPEC void
  52. FreePortListing(struct PortMappingParserData * pdata);
  53. #ifdef __cplusplus
  54. }
  55. #endif
  56. #endif