#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <sys/types.h>
#if defined (__NetBSD__)
#include <net/if.h>
#endif
#if defined(_WIN32) || defined(__amigaos__) || defined(__amigaos4__)
#ifdef _WIN32
#include <winsock2.h>
#include <ws2tcpip.h>
#include <io.h>
#include <iphlpapi.h>
#include "win32_snprintf.h"
#if !defined(_MSC_VER)
#include <stdint.h>
#else
typedef unsigned short uint16_t;
#endif
#ifndef strncasecmp
#if defined(_MSC_VER) && (_MSC_VER >= 1400)
#define strncasecmp …
#else
#define strncasecmp …
#endif
#endif
#if defined(WINAPI_FAMILY) && defined(WINAPI_FAMILY_PARTITION)
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && WINAPI_FAMILY != WINAPI_FAMILY_DESKTOP_APP
#define in6addr_any …
static const IN6_ADDR in6addr_any_init = {0};
#endif
#endif
#endif
#if defined(__amigaos__) || defined(__amigaos4__)
#include <sys/socket.h>
#endif
#if defined(__amigaos__)
#define uint16_t …
#endif
#define UNIX_PATH_LEN …
struct sockaddr_un {
uint16_t sun_family;
char sun_path[UNIX_PATH_LEN];
};
#else
#include <strings.h>
#include <unistd.h>
#include <sys/socket.h>
#include <sys/param.h>
#include <sys/time.h>
#include <sys/un.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <net/if.h>
#define closesocket …
#endif
#include "miniupnpc_socketdef.h"
#if !defined(__DragonFly__) && !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(__APPLE__) && !defined(_WIN32) && !defined(__CYGWIN__) && !defined(__sun) && !defined(__GNU__) && !defined(__FreeBSD_kernel__) && !defined(__HAIKU__)
#define HAS_IP_MREQN
#endif
#ifndef _WIN32
#include <sys/ioctl.h>
#if defined(__sun) || defined(__HAIKU__)
#include <sys/sockio.h>
#endif
#endif
#if defined(HAS_IP_MREQN) && defined(NEED_STRUCT_IP_MREQN)
struct ip_mreqn
{
struct in_addr imr_multiaddr;
struct in_addr imr_address;
int imr_ifindex;
};
#endif
#if defined(__amigaos__) || defined(__amigaos4__)
#define TIMEVAL …
#endif
#include "minissdpc.h"
#include "miniupnpc.h"
#include "receivedata.h"
#if !(defined(_WIN32) || defined(__amigaos__) || defined(__amigaos4__))
#include "codelength.h"
struct UPNPDev *
getDevicesFromMiniSSDPD(const char * devtype, const char * socketpath, int * error)
{ … }
#define READ_BYTE_BUFFER(c) …
#ifndef MIN
#define MIN …
#endif
#define READ_COPY_BUFFER(dst, len) …
#define READ_DISCARD_BUFFER(len) …
int
connectToMiniSSDPD(const char * socketpath)
{ … }
int
disconnectFromMiniSSDPD(int s)
{ … }
int
requestDevicesFromMiniSSDPD(int s, const char * devtype)
{ … }
struct UPNPDev *
receiveDevicesFromMiniSSDPD(int s, int * error)
{ … }
#endif
static void
parseMSEARCHReply(const char * reply, int size,
const char * * location, int * locationsize,
const char * * st, int * stsize,
const char * * usn, int * usnsize)
{ … }
#if defined(CLOCK_MONOTONIC_FAST)
#define UPNP_CLOCKID …
#elif defined(CLOCK_MONOTONIC)
#define UPNP_CLOCKID …
#endif
static int upnp_gettimeofday(struct timeval * tv)
{ … }
#define SSDP_PORT …
#define XSTR(s) …
#define STR(s) …
#define UPNP_MCAST_ADDR …
#define UPNP_MCAST_LL_ADDR …
#define UPNP_MCAST_SL_ADDR …
struct UPNPDev *
ssdpDiscoverDevices(const char * const deviceTypes[],
int delay, const char * multicastif,
int localport,
int ipv6, unsigned char ttl,
int * error,
int searchalltypes)
{ … }