Monero
Loading...
Searching...
No Matches
minissdpd.c File Reference
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <signal.h>
#include <errno.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <unistd.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <syslog.h>
#include <ctype.h>
#include <time.h>
#include <sys/queue.h>
#include <sys/stat.h>
#include <sys/un.h>
#include "getifaddr.h"
#include "upnputils.h"
#include "openssdpsocket.h"
#include "daemonize.h"
#include "codelength.h"
#include "ifacewatch.h"
#include "minissdpdtypes.h"
#include "asyncsendto.h"
Include dependency graph for minissdpd.c:

Classes

struct  reqelem
struct  header
struct  device
struct  service

Macros

#define LOG_PERROR   0
#define SET_MAX(max, x)
#define MIN(x, y)
#define HEADER_NT   0
#define HEADER_USN   1
#define HEADER_LOCATION   2
#define NTS_SSDP_ALIVE   1
#define NTS_SSDP_BYEBYE   2
#define NTS_SSDP_UPDATE   3
#define NOTIF_NEW   1
#define NOTIF_UPDATE   2
#define NOTIF_REMOVE   3
#define METHOD_MSEARCH   1
#define METHOD_NOTIFY   2
#define PORT   1900
#define XSTR(s)
#define STR(s)
#define UPNP_MCAST_ADDR   "239.255.255.250"
#define UPNP_MCAST_LL_ADDR   "FF02::C" /* link-local */
#define UPNP_MCAST_SL_ADDR   "FF05::C" /* site-local */

Functions

 LIST_HEAD (servicehead, service)
 LIST_HEAD (reqstructhead, reqelem)
static int write_buffer (struct reqelem *req)
static int add_to_buffer (struct reqelem *req, const unsigned char *data, int len)
static int write_or_buffer (struct reqelem *req, const unsigned char *data, int len)
static const char * nts_to_str (int nts)
static int updateDevice (const struct header *headers, time_t t)
static int removeDevice (const struct header *headers)
static void sendNotifications (int notif_type, const struct device *dev, const struct service *serv)
static void SendSSDPMSEARCHResponse (int s, const struct sockaddr *sockname, const char *st, size_t st_len, const char *usn, const char *server, const char *location)
static void processMSEARCH (int s, const char *st, size_t st_len, const struct sockaddr *addr)
static int containsForbiddenChars (const unsigned char *p, int len)
static int ParseSSDPPacket (int s, const char *p, ssize_t n, const struct sockaddr *addr, const char *searched_device)
static int OpenUnixSocket (const char *path)
static ssize_t processRequestSub (struct reqelem *req, const unsigned char *buf, ssize_t n)
void processRequest (struct reqelem *req)
static void sigterm (int sig)
static void ssdpDiscover (int s, int ipv6, const char *search)
int main (int argc, char **argv)

Variables

struct devicedevlist = 0
unsigned int upnp_bootid = 1
unsigned int upnp_configid = 1337
struct lan_addr_list lan_addrs
static volatile sig_atomic_t quitting = 0

Macro Definition Documentation

◆ HEADER_LOCATION

#define HEADER_LOCATION   2

◆ HEADER_NT

#define HEADER_NT   0

◆ HEADER_USN

#define HEADER_USN   1

◆ LOG_PERROR

#define LOG_PERROR   0

◆ METHOD_MSEARCH

#define METHOD_MSEARCH   1

◆ METHOD_NOTIFY

#define METHOD_NOTIFY   2

◆ MIN

#define MIN ( x,
y )
Value:
(((x)<(y))?(x):(y))

◆ NOTIF_NEW

#define NOTIF_NEW   1

◆ NOTIF_REMOVE

#define NOTIF_REMOVE   3

◆ NOTIF_UPDATE

#define NOTIF_UPDATE   2

◆ NTS_SSDP_ALIVE

#define NTS_SSDP_ALIVE   1

◆ NTS_SSDP_BYEBYE

#define NTS_SSDP_BYEBYE   2

◆ NTS_SSDP_UPDATE

#define NTS_SSDP_UPDATE   3

◆ PORT

#define PORT   1900

◆ SET_MAX

#define SET_MAX ( max,
x )
Value:
if((x) > (max)) (max) = (x)

◆ STR

#define STR ( s)
Value:
#s

◆ UPNP_MCAST_ADDR

#define UPNP_MCAST_ADDR   "239.255.255.250"

◆ UPNP_MCAST_LL_ADDR

#define UPNP_MCAST_LL_ADDR   "FF02::C" /* link-local */

◆ UPNP_MCAST_SL_ADDR

#define UPNP_MCAST_SL_ADDR   "FF05::C" /* site-local */

◆ XSTR

#define XSTR ( s)
Value:
#define s(x, c)
Definition aesb.c:47
#define STR(s)
Definition minissdpd.c:1170

Function Documentation

◆ add_to_buffer()

int add_to_buffer ( struct reqelem * req,
const unsigned char * data,
int len )
static

◆ containsForbiddenChars()

int containsForbiddenChars ( const unsigned char * p,
int len )
static

helper function. reject any non ASCII or non printable character.

◆ LIST_HEAD() [1/2]

LIST_HEAD ( reqstructhead ,
reqelem  )

◆ LIST_HEAD() [2/2]

LIST_HEAD ( servicehead ,
service  )

◆ main()

int main ( int argc,
char ** argv )

◆ nts_to_str()

const char * nts_to_str ( int nts)
static

◆ OpenUnixSocket()

int OpenUnixSocket ( const char * path)
static

◆ ParseSSDPPacket()

int ParseSSDPPacket ( int s,
const char * p,
ssize_t n,
const struct sockaddr * addr,
const char * searched_device )
static

◆ processMSEARCH()

void processMSEARCH ( int s,
const char * st,
size_t st_len,
const struct sockaddr * addr )
static

◆ processRequest()

void processRequest ( struct reqelem * req)

◆ processRequestSub()

ssize_t processRequestSub ( struct reqelem * req,
const unsigned char * buf,
ssize_t n )
static

◆ removeDevice()

int removeDevice ( const struct header * headers)
static

◆ sendNotifications()

void sendNotifications ( int notif_type,
const struct device * dev,
const struct service * serv )
static

◆ SendSSDPMSEARCHResponse()

void SendSSDPMSEARCHResponse ( int s,
const struct sockaddr * sockname,
const char * st,
size_t st_len,
const char * usn,
const char * server,
const char * location )
static

◆ sigterm()

void sigterm ( int sig)
static

◆ ssdpDiscover()

void ssdpDiscover ( int s,
int ipv6,
const char * search )
static

◆ updateDevice()

int updateDevice ( const struct header * headers,
time_t t )
static

◆ write_buffer()

int write_buffer ( struct reqelem * req)
static

◆ write_or_buffer()

int write_or_buffer ( struct reqelem * req,
const unsigned char * data,
int len )
static

Variable Documentation

◆ devlist

struct device* devlist = 0

◆ lan_addrs

struct lan_addr_list lan_addrs

◆ quitting

volatile sig_atomic_t quitting = 0
static

◆ upnp_bootid

unsigned int upnp_bootid = 1

◆ upnp_configid

unsigned int upnp_configid = 1337