mUPnP for C
interface.h File Reference
#include <mupnp/typedef.h>
#include <mupnp/util/list.h>
#include <mupnp/util/string.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <sys/socket.h>

Data Structures

struct  _mUpnpNetworkInterface
 

Macros

#define MUPNP_NET_IPV4_ADDRSTRING_MAXSIZE   ((3 * 4) + (1 * 3) + 1)
 
#define MUPNP_NET_IPV6_ADDRSTRING_MAXSIZE   (1 + (8 * 4) + (1 * 7) + 1 + 1)
 
#define MUPNP_NET_IPV4_LOOPBACK   "127.0.0.1"
 
#define MUPNP_NET_IPV6_LOOPBACK   "fixmelater"
 
#define MUPNP_NET_MACADDR_SIZE   6
 
#define mupnp_net_interface_next(netIf)
 
#define mupnp_net_interface_remove(netIf)
 
#define mupnp_net_interface_setmacaddress(netIf, value)
 
#define mupnp_net_interface_getmacaddress(netIf, buf)
 
#define mupnp_net_interface_setindex(netIf, value)
 
#define mupnp_net_interface_getindex(netIf, buf)
 
#define mupnp_net_interfacelist_clear(netIfList)
 
#define mupnp_net_interfacelist_size(netIfList)
 
#define mupnp_net_interfacelist_gets(netIfList)
 
#define mupnp_net_interfacelist_add(netIfList, netIf)
 

Typedefs

typedef struct _mUpnpNetworkInterface mUpnpNetworkInterface
 
typedef struct _mUpnpNetworkInterface mUpnpNetworkInterfaceList
 

Functions

mUpnpNetworkInterface * mupnp_net_interface_new (void)
 
void mupnp_net_interface_delete (mUpnpNetworkInterface *netIf)
 
mUpnpNetworkInterface * mupnp_net_interface_getany (void)
 
void mupnp_net_interface_setname (mUpnpNetworkInterface *netIf, char *name)
 
char * mupnp_net_interface_getname (mUpnpNetworkInterface *netIf)
 
void mupnp_net_interface_setaddress (mUpnpNetworkInterface *netIf, char *ipaddr)
 
char * mupnp_net_interface_getaddress (mUpnpNetworkInterface *netIf)
 
void mupnp_net_interface_setnetmask (mUpnpNetworkInterface *netIf, char *ipaddr)
 
char * mupnp_net_interface_getnetmask (mUpnpNetworkInterface *netIf)
 
char * mupnp_net_selectaddr (struct sockaddr *remoteaddr)
 
int mupnp_net_interface_cmp (mUpnpNetworkInterface *netIfA, mUpnpNetworkInterface *netIfB)
 
mUpnpNetworkInterfaceList * mupnp_net_interfacelist_new (void)
 
void mupnp_net_interfacelist_delete (mUpnpNetworkInterfaceList *netIfList)
 
mUpnpNetworkInterface * mupnp_net_interfacelist_get (mUpnpNetworkInterfaceList *netIfList, char *name)
 
void mupnp_net_interfacelist_getchanges (mUpnpNetworkInterfaceList *netIfListOld, mUpnpNetworkInterfaceList *netIfListNew, mUpnpNetworkInterfaceList *netIfListAdded, mUpnpNetworkInterfaceList *netIfListRemoved)
 
int mupnp_net_gethostinterfaces (mUpnpNetworkInterfaceList *netIfList)
 
bool mupnp_net_isipv6address (const char *addr)
 
int mupnp_net_getipv6scopeid (const char *addr)
 
void mupnp_net_setipv6enabled (bool enabled)
 
bool mupnp_net_isipv6enabled (void)
 

Macro Definition Documentation

◆ mupnp_net_interface_getindex

#define mupnp_net_interface_getindex ( netIf,
buf )
Value:
(netIf->index)

◆ mupnp_net_interface_getmacaddress

#define mupnp_net_interface_getmacaddress ( netIf,
buf )
Value:
memcpy(buf, netIf->macaddr, MUPNP_NET_MACADDR_SIZE)
#define MUPNP_NET_MACADDR_SIZE
Definition interface.h:38

◆ mupnp_net_interface_next

#define mupnp_net_interface_next ( netIf)
Value:
mUpnpList * mupnp_list_next(mUpnpList *list)
Definition list.c:234
The generic list interface in mUPnP.
Definition list.h:56
Definition interface.h:48

◆ mupnp_net_interface_remove

#define mupnp_net_interface_remove ( netIf)
Value:
void mupnp_list_remove(mUpnpList *list)
Remove a node from its list.
Definition list.c:144

◆ mupnp_net_interface_setindex

#define mupnp_net_interface_setindex ( netIf,
value )
Value:
(netIf->index = value)

◆ mupnp_net_interface_setmacaddress

#define mupnp_net_interface_setmacaddress ( netIf,
value )
Value:
memcpy(netIf->macaddr, value, MUPNP_NET_MACADDR_SIZE)

◆ mupnp_net_interfacelist_add

#define mupnp_net_interfacelist_add ( netIfList,
netIf )
Value:
mupnp_list_add((mUpnpList*)netIfList, (mUpnpList*)netIf)
void mupnp_list_add(mUpnpList *headList, mUpnpList *list)
Add a node to the end of a list.
Definition list.c:123

◆ mupnp_net_interfacelist_clear

#define mupnp_net_interfacelist_clear ( netIfList)
Value:
void mupnp_net_interface_delete(mUpnpNetworkInterface *netIf)
Definition interface.c:50
void mupnp_list_clear(mUpnpList *headList, MUPNP_LIST_DESTRUCTORFUNC destructorFunc)
Definition list.c:257
void(* MUPNP_LIST_DESTRUCTORFUNC)(void *)
Definition list.h:29

◆ mupnp_net_interfacelist_gets

#define mupnp_net_interfacelist_gets ( netIfList)

◆ mupnp_net_interfacelist_size

#define mupnp_net_interfacelist_size ( netIfList)
Value:
int mupnp_list_size(mUpnpList *headList)
Definition list.c:53

◆ MUPNP_NET_IPV4_ADDRSTRING_MAXSIZE

#define MUPNP_NET_IPV4_ADDRSTRING_MAXSIZE   ((3 * 4) + (1 * 3) + 1)

◆ MUPNP_NET_IPV4_LOOPBACK

#define MUPNP_NET_IPV4_LOOPBACK   "127.0.0.1"

◆ MUPNP_NET_IPV6_ADDRSTRING_MAXSIZE

#define MUPNP_NET_IPV6_ADDRSTRING_MAXSIZE   (1 + (8 * 4) + (1 * 7) + 1 + 1)

◆ MUPNP_NET_IPV6_LOOPBACK

#define MUPNP_NET_IPV6_LOOPBACK   "fixmelater"

◆ MUPNP_NET_MACADDR_SIZE

#define MUPNP_NET_MACADDR_SIZE   6

Typedef Documentation

◆ mUpnpNetworkInterface

◆ mUpnpNetworkInterfaceList

Function Documentation

◆ mupnp_net_gethostinterfaces()

int mupnp_net_gethostinterfaces ( mUpnpNetworkInterfaceList * netIfList)

◆ mupnp_net_getipv6scopeid()

int mupnp_net_getipv6scopeid ( const char * addr)

◆ mupnp_net_interface_cmp()

int mupnp_net_interface_cmp ( mUpnpNetworkInterface * netIfA,
mUpnpNetworkInterface * netIfB )

Compares two interfaces based on IP-address.

◆ mupnp_net_interface_delete()

void mupnp_net_interface_delete ( mUpnpNetworkInterface * netIf)

◆ mupnp_net_interface_getaddress()

char * mupnp_net_interface_getaddress ( mUpnpNetworkInterface * netIf)

◆ mupnp_net_interface_getany()

mUpnpNetworkInterface * mupnp_net_interface_getany ( void )

◆ mupnp_net_interface_getname()

char * mupnp_net_interface_getname ( mUpnpNetworkInterface * netIf)

◆ mupnp_net_interface_getnetmask()

char * mupnp_net_interface_getnetmask ( mUpnpNetworkInterface * netIf)

◆ mupnp_net_interface_new()

mUpnpNetworkInterface * mupnp_net_interface_new ( void )

◆ mupnp_net_interface_setaddress()

void mupnp_net_interface_setaddress ( mUpnpNetworkInterface * netIf,
char * ipaddr )

◆ mupnp_net_interface_setname()

void mupnp_net_interface_setname ( mUpnpNetworkInterface * netIf,
char * name )

◆ mupnp_net_interface_setnetmask()

void mupnp_net_interface_setnetmask ( mUpnpNetworkInterface * netIf,
char * ipaddr )

◆ mupnp_net_interfacelist_delete()

void mupnp_net_interfacelist_delete ( mUpnpNetworkInterfaceList * netIfList)

◆ mupnp_net_interfacelist_get()

mUpnpNetworkInterface * mupnp_net_interfacelist_get ( mUpnpNetworkInterfaceList * netIfList,
char * name )

◆ mupnp_net_interfacelist_getchanges()

void mupnp_net_interfacelist_getchanges ( mUpnpNetworkInterfaceList * netIfListOld,
mUpnpNetworkInterfaceList * netIfListNew,
mUpnpNetworkInterfaceList * netIfListAdded,
mUpnpNetworkInterfaceList * netIfListRemoved )

Gets changes in the two given (aka old and new) interface lists. Changes are resolved based on IP-addresses.

Parameters
netIfListOldList of the old interfaces. It is changed!
netIfListNewList of the new interfaces. It is changed!
netIfListAddedList to store interfaces, which were in netIfListNew, but were not in netIfListOld. May be NULL.
netIfListRemovedList to store interfaces, which were in netIfListOld, but were not in netIfListNew.

◆ mupnp_net_interfacelist_new()

mUpnpNetworkInterfaceList * mupnp_net_interfacelist_new ( void )

◆ mupnp_net_isipv6address()

bool mupnp_net_isipv6address ( const char * addr)

◆ mupnp_net_isipv6enabled()

bool mupnp_net_isipv6enabled ( void )

Check whether IPv6 interface addresses are enabled.

Returns
true if enabled by mupnp_net_setipv6enabled().

◆ mupnp_net_selectaddr()

char * mupnp_net_selectaddr ( struct sockaddr * remoteaddr)

◆ mupnp_net_setipv6enabled()

void mupnp_net_setipv6enabled ( bool enabled)

Enable or disable IPv6 interface addresses (issue #17).

Disabled by default. When enabled before a device or control point is started, mupnp_net_gethostinterfaces() on getifaddrs() platforms (Linux, macOS, BSD) also returns the IPv6 link-local address of each interface, formatted with a numeric zone index ("fe80::1%2"), so SSDP also runs on the link-local multicast group (see mupnp_ssdp_setipv6address()) and HTTP is served on that address.

Windows always returned IPv6 addresses and is not affected.

Parameters
enabledtrue to use IPv6 link-local addresses as well as IPv4.