Return to miniupnpc.h CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / miniupnpd / miniupnpc / include |
1.1 ! misho 1: /* $Id: miniupnpc.h,v 1.61 2022/10/21 21:15:02 nanard Exp $ */ ! 2: /* vim: tabstop=4 shiftwidth=4 noexpandtab ! 3: * Project: miniupnp ! 4: * http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/ ! 5: * Author: Thomas Bernard ! 6: * Copyright (c) 2005-2022 Thomas Bernard ! 7: * This software is subjects to the conditions detailed ! 8: * in the LICENCE file provided within this distribution */ ! 9: #ifndef MINIUPNPC_H_INCLUDED ! 10: #define MINIUPNPC_H_INCLUDED ! 11: ! 12: #include "miniupnpc_declspec.h" ! 13: #include "igd_desc_parse.h" ! 14: #include "upnpdev.h" ! 15: ! 16: /* error codes : */ ! 17: #define UPNPDISCOVER_SUCCESS (0) ! 18: #define UPNPDISCOVER_UNKNOWN_ERROR (-1) ! 19: #define UPNPDISCOVER_SOCKET_ERROR (-101) ! 20: #define UPNPDISCOVER_MEMORY_ERROR (-102) ! 21: ! 22: /* versions : */ ! 23: #define MINIUPNPC_VERSION "2.2.4" ! 24: #define MINIUPNPC_API_VERSION 17 ! 25: ! 26: /* Source port: ! 27: Using "1" as an alias for 1900 for backwards compatibility ! 28: (presuming one would have used that for the "sameport" parameter) */ ! 29: #define UPNP_LOCAL_PORT_ANY 0 ! 30: #define UPNP_LOCAL_PORT_SAME 1 ! 31: ! 32: #ifdef __cplusplus ! 33: extern "C" { ! 34: #endif ! 35: ! 36: /* Structures definitions : */ ! 37: struct UPNParg { const char * elt; const char * val; }; ! 38: ! 39: char * ! 40: simpleUPnPcommand(int, const char *, const char *, ! 41: const char *, struct UPNParg *, ! 42: int *); ! 43: ! 44: /* upnpDiscover() ! 45: * discover UPnP devices on the network. ! 46: * The discovered devices are returned as a chained list. ! 47: * It is up to the caller to free the list with freeUPNPDevlist(). ! 48: * delay (in millisecond) is the maximum time for waiting any device ! 49: * response. ! 50: * If available, device list will be obtained from MiniSSDPd. ! 51: * Default path for minissdpd socket will be used if minissdpdsock argument ! 52: * is NULL. ! 53: * If multicastif is not NULL, it will be used instead of the default ! 54: * multicast interface for sending SSDP discover packets. ! 55: * If localport is set to UPNP_LOCAL_PORT_SAME(1) SSDP packets will be sent ! 56: * from the source port 1900 (same as destination port), if set to ! 57: * UPNP_LOCAL_PORT_ANY(0) system assign a source port, any other value will ! 58: * be attempted as the source port. ! 59: * "searchalltypes" parameter is useful when searching several types, ! 60: * if 0, the discovery will stop with the first type returning results. ! 61: * TTL should default to 2. */ ! 62: MINIUPNP_LIBSPEC struct UPNPDev * ! 63: upnpDiscover(int delay, const char * multicastif, ! 64: const char * minissdpdsock, int localport, ! 65: int ipv6, unsigned char ttl, ! 66: int * error); ! 67: ! 68: MINIUPNP_LIBSPEC struct UPNPDev * ! 69: upnpDiscoverAll(int delay, const char * multicastif, ! 70: const char * minissdpdsock, int localport, ! 71: int ipv6, unsigned char ttl, ! 72: int * error); ! 73: ! 74: MINIUPNP_LIBSPEC struct UPNPDev * ! 75: upnpDiscoverDevice(const char * device, int delay, const char * multicastif, ! 76: const char * minissdpdsock, int localport, ! 77: int ipv6, unsigned char ttl, ! 78: int * error); ! 79: ! 80: MINIUPNP_LIBSPEC struct UPNPDev * ! 81: upnpDiscoverDevices(const char * const deviceTypes[], ! 82: int delay, const char * multicastif, ! 83: const char * minissdpdsock, int localport, ! 84: int ipv6, unsigned char ttl, ! 85: int * error, ! 86: int searchalltypes); ! 87: ! 88: /* parserootdesc() : ! 89: * parse root XML description of a UPnP device and fill the IGDdatas ! 90: * structure. */ ! 91: MINIUPNP_LIBSPEC void parserootdesc(const char *, int, struct IGDdatas *); ! 92: ! 93: /* structure used to get fast access to urls ! 94: * controlURL: controlURL of the WANIPConnection ! 95: * ipcondescURL: url of the description of the WANIPConnection ! 96: * controlURL_CIF: controlURL of the WANCommonInterfaceConfig ! 97: * controlURL_6FC: controlURL of the WANIPv6FirewallControl ! 98: */ ! 99: struct UPNPUrls { ! 100: char * controlURL; ! 101: char * ipcondescURL; ! 102: char * controlURL_CIF; ! 103: char * controlURL_6FC; ! 104: char * rootdescURL; ! 105: }; ! 106: ! 107: /* UPNP_GetValidIGD() : ! 108: * return values : ! 109: * 0 = NO IGD found ! 110: * 1 = A valid connected IGD has been found ! 111: * 2 = A valid IGD has been found but it reported as ! 112: * not connected ! 113: * 3 = an UPnP device has been found but was not recognized as an IGD ! 114: * ! 115: * In any non zero return case, the urls and data structures ! 116: * passed as parameters are set. Donc forget to call FreeUPNPUrls(urls) to ! 117: * free allocated memory. ! 118: */ ! 119: MINIUPNP_LIBSPEC int ! 120: UPNP_GetValidIGD(struct UPNPDev * devlist, ! 121: struct UPNPUrls * urls, ! 122: struct IGDdatas * data, ! 123: char * lanaddr, int lanaddrlen); ! 124: ! 125: /* UPNP_GetIGDFromUrl() ! 126: * Used when skipping the discovery process. ! 127: * When succeding, urls, data, and lanaddr arguments are set. ! 128: * return value : ! 129: * 0 - Not ok ! 130: * 1 - OK */ ! 131: MINIUPNP_LIBSPEC int ! 132: UPNP_GetIGDFromUrl(const char * rootdescurl, ! 133: struct UPNPUrls * urls, ! 134: struct IGDdatas * data, ! 135: char * lanaddr, int lanaddrlen); ! 136: ! 137: MINIUPNP_LIBSPEC void ! 138: GetUPNPUrls(struct UPNPUrls *, struct IGDdatas *, ! 139: const char *, unsigned int); ! 140: ! 141: MINIUPNP_LIBSPEC void ! 142: FreeUPNPUrls(struct UPNPUrls *); ! 143: ! 144: /* return 0 or 1 */ ! 145: MINIUPNP_LIBSPEC int UPNPIGD_IsConnected(struct UPNPUrls *, struct IGDdatas *); ! 146: ! 147: ! 148: #ifdef __cplusplus ! 149: } ! 150: #endif ! 151: ! 152: #endif ! 153: