LIBSSDP
 All Classes Files Functions Variables Typedefs Macros
Functions
ssdp_cache.c File Reference
#include <arpa/inet.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "common_definitions.h"
#include "configuration.h"
#include "log.h"
#include "net_utils.h"
#include "socket_helpers.h"
#include "ssdp_message.h"
#include "ssdp_cache.h"
#include "ssdp_cache_output_format.h"
Include dependency graph for ssdp_cache.c:

Go to the source code of this file.

Functions

static BOOL create_plain_text_message (char *results, int buffer_size, ssdp_message_s *ssdp_message)
 
static int send_stuff (const char *url, const char *data, const struct sockaddr_storage *da, int port, int timeout, configuration_s *conf)
 
static void free_ssdp_cache (ssdp_cache_s **ssdp_cache_pointer)
 
BOOL add_ssdp_message_to_cache (ssdp_cache_s **ssdp_cache_pointer, ssdp_message_s **ssdp_message_pointer)
 
BOOL flush_ssdp_cache (configuration_s *conf, ssdp_cache_s **ssdp_cache_pointer, const char *url, struct sockaddr_storage *sockaddr_recipient, int port, int timeout)
 

Detailed Description

Functions for managing the SSDP cachein the program/lib.

Definition in file ssdp_cache.c.

Function Documentation

BOOL add_ssdp_message_to_cache ( ssdp_cache_s **  ssdp_cache_pointer,
ssdp_message_s **  ssdp_message_pointer 
)

Adds a ssdp message to a ssdp messages list. If the list hasn't been initialized then it is initialized first.

Parameters
ssdp_cache_pointerThe address of a pointer to a ssdp cache list.
ssdp_message_pointerThe ssdp message to be appended to the cache list.
Returns
TRUE on success, exits on failure.

Definition at line 290 of file ssdp_cache.c.

static BOOL create_plain_text_message ( char *  results,
int  buffer_size,
ssdp_message_s ssdp_message 
)
static

Create a plain-text message.

Parameters
resultsThe buffer to store the results in.
buffer_sizeThe size of the buffer 'results'.
messageThe message to convert.

Definition at line 30 of file ssdp_cache.c.

BOOL flush_ssdp_cache ( configuration_s conf,
ssdp_cache_s **  ssdp_cache_pointer,
const char *  url,
struct sockaddr_storage *  sockaddr_recipient,
int  port,
int  timeout 
)

Send and free the passed SSDP cache.

Parameters
confThe configuration to use.
ssdp_cache_pointerThe SSDP cache to send and delete (flush).
urlThe URL (without the protocol and IP) to send the data to.
sockaddr_recipientThe socket address to send to.
portThe port to send to.
timeoutThe send-timeout to set.
Returns
TRUE on success, FALSE otherwise.

Definition at line 392 of file ssdp_cache.c.

static void free_ssdp_cache ( ssdp_cache_s **  ssdp_cache_pointer)
static

Frees all the elements in the ssdp messages list.

Parameters
ssdp_cache_pointerThe ssdp cache list to be cleared.

Definition at line 241 of file ssdp_cache.c.

static int send_stuff ( const char *  url,
const char *  data,
const struct sockaddr_storage *  da,
int  port,
int  timeout,
configuration_s conf 
)
static

Send the SSDP cache to the given address (aka. forwarder).

Parameters
urlThe URL (without the protocol and IP) to send the data to.
dataThe data to send.
daThe socket address to send to.
portThe port to send to.
timeoutThe send-timeout to set.
confThe configuration to use.
Returns
0 on success, errno otherwise.

Definition at line 98 of file ssdp_cache.c.