mUPnP for C
ssdp.c File Reference

Functions

void mupnp_ssdp_setipv6address (const char *addr)
 Set the IPv6 multicast address for SSDP.
 
const char * mupnp_ssdp_getipv6address (void)
 Get the current IPv6 multicast address for SSDP.
 
void mupnp_ssdp_setannouncecount (int count)
 Set the number of times to send SSDP announcements.
 
int mupnp_ssdp_getannouncecount (void)
 Get the current SSDP announcement repetition count.
 
int mupnp_ssdp_getleasetime (const char *cacheCnt)
 Extract lease time from a Cache-Control header value.
 
const char * mupnp_ssdp_gethostaddress (const char *ifAddr)
 Get the host address for a given network interface.
 

Variables

static char * ssdpIPv6Address = MUPNP_SSDP_IPV6_LINK_LOCAL_ADDRESS
 
static int ssdpAnnounceCount = MUPNP_SSDP_DEFAULT_ANNOUNCE_COUNT
 

Function Documentation

◆ mupnp_ssdp_getannouncecount()

int mupnp_ssdp_getannouncecount ( void )

Get the current SSDP announcement repetition count.

Returns
Number of times each announcement is sent. Default is MUPNP_SSDP_DEFAULT_ANNOUNCE_COUNT (3).
Note
Thread-safe: Can be called from any thread.
See also
mupnp_ssdp_setannouncecount()

◆ mupnp_ssdp_gethostaddress()

const char * mupnp_ssdp_gethostaddress ( const char * ifAddr)

Get the host address for a given network interface.

Retrieves the IP address of the specified network interface, suitable for use in SSDP messages (Location headers, etc.).

Parameters
ifAddrThe network interface address. May be NULL to use default.
Returns
The host address string, or NULL if not available.
Note
Thread-safe: Can be called from any thread.
The returned string is managed internally and should not be freed.

◆ mupnp_ssdp_getipv6address()

const char * mupnp_ssdp_getipv6address ( void )

Get the current IPv6 multicast address for SSDP.

Returns
The currently configured IPv6 multicast address. Default is MUPNP_SSDP_IPV6_LINK_LOCAL_ADDRESS.
Note
Thread-safe: Can be called from any thread.
See also
mupnp_ssdp_setipv6address()

◆ mupnp_ssdp_getleasetime()

int mupnp_ssdp_getleasetime ( const char * cacheCont)

Extract lease time from a Cache-Control header value.

Parses the Cache-Control header (or CACHE-CONTROL) from an SSDP message to extract the max-age directive, which specifies the device's lease time in seconds.

Example: "max-age=1800" returns 1800 (30 minutes).

Parameters
cacheContThe Cache-Control header value. May be NULL.
Returns
The lease time in seconds, or 0 if cacheCont is NULL or max-age directive is not found.
Note
Thread-safe: Can be called from any thread.

◆ mupnp_ssdp_setannouncecount()

void mupnp_ssdp_setannouncecount ( int count)

Set the number of times to send SSDP announcements.

Configures how many times each SSDP advertisement (alive or byebye) is sent. Multiple announcements increase reliability on unreliable networks. Default is MUPNP_SSDP_DEFAULT_ANNOUNCE_COUNT (3).

Parameters
countNumber of announcement repetitions. Must be >= 1. Typical values: 2-4. Higher values increase network traffic.
Note
Thread-safe: Should be called before starting devices.
Side effect: Changes the global announcement count setting.
See also
mupnp_ssdp_getannouncecount()

◆ mupnp_ssdp_setipv6address()

void mupnp_ssdp_setipv6address ( const char * addr)

Set the IPv6 multicast address for SSDP.

Configures the IPv6 multicast address used for SSDP discovery. Default is MUPNP_SSDP_IPV6_LINK_LOCAL_ADDRESS ("FF02::C").

Common IPv6 SSDP addresses:

  • FF01::C - Interface-local scope
  • FF02::C - Link-local scope (default, same subnet)
  • FF05::C - Site-local scope
  • FF0E::C - Global scope
Parameters
addrThe IPv6 multicast address. Must not be NULL. Should be one of the MUPNP_SSDP_IPV6_* constants.
Note
Thread-safe: Should be called before starting devices or control points.
Side effect: Changes the global IPv6 multicast address setting.
See also
mupnp_ssdp_getipv6address()

Variable Documentation

◆ ssdpAnnounceCount

int ssdpAnnounceCount = MUPNP_SSDP_DEFAULT_ANNOUNCE_COUNT
static

◆ ssdpIPv6Address

char* ssdpIPv6Address = MUPNP_SSDP_IPV6_LINK_LOCAL_ADDRESS
static