libUPnP
1.8.0
|
This file implements the functionality and utility functions used by the Miniserver module. More...
#include "config.h"
#include "miniserver.h"
#include "httpreadwrite.h"
#include "ithread.h"
#include "ssdplib.h"
#include "statcodes.h"
#include "ThreadPool.h"
#include "unixutil.h"
#include "upnpapi.h"
#include "util.h"
#include <assert.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
Data Structures | |
struct | mserv_request_t |
Defines | |
#define | APPLICATION_LISTENING_PORT 49152 |
Enumerations | |
enum | MiniServerState { MSERV_IDLE, MSERV_RUNNING, MSERV_STOPPING } |
Functions | |
void | SetHTTPGetCallback (MiniServerCallback callback) |
Set HTTP Get Callback. | |
void | SetSoapCallback (MiniServerCallback callback) |
Set SOAP Callback. | |
void | SetGenaCallback (MiniServerCallback callback) |
Set GENA Callback. | |
static void | RunMiniServer (MiniServerSockArray *miniSock) |
Run the miniserver. | |
static int | get_port (int sockfd) |
Returns port to which socket, sockfd, is bound. | |
static int | get_miniserver_stopsock (MiniServerSockArray *out) |
Creates the miniserver STOP socket. This socket is created and listened on to know when it is time to stop the Miniserver. | |
int | StartMiniServer (unsigned short *listen_port4, unsigned short *listen_port6) |
Initialize the sockets functionality for the Miniserver. | |
int | StopMiniServer () |
Stop and Shutdown the MiniServer and free socket resources. | |
Variables | |
unsigned short | miniStopSockPort |
static MiniServerCallback | gGetCallback = NULL |
static MiniServerCallback | gSoapCallback = NULL |
static MiniServerCallback | gGenaCallback = NULL |
static MiniServerState | gMServState = MSERV_IDLE |
This file implements the functionality and utility functions used by the Miniserver module.
The miniserver is a central point for processing all network requests. It is made of:
static int get_miniserver_stopsock | ( | MiniServerSockArray * | out | ) | [static] |
Creates the miniserver STOP socket. This socket is created and listened on to know when it is time to stop the Miniserver.
[in] | out | Miniserver Socket Array. |
References get_port(), UPNP_E_INTERNAL_ERROR, UPNP_E_OUTOF_SOCKET, UPNP_E_SOCKET_BIND, UPNP_E_SUCCESS, and UpnpPrintf().
Referenced by StartMiniServer().
static int get_port | ( | int | sockfd | ) | [static] |
Returns port to which socket, sockfd, is bound.
[in] | sockfd | Socket descriptor. |
References UpnpPrintf().
Referenced by get_miniserver_stopsock().
static void RunMiniServer | ( | MiniServerSockArray * | miniSock | ) | [static] |
Run the miniserver.
The MiniServer accepts a new request and schedules a thread to handle the new request. Checks for socket state and invokes appropriate read and shutdown actions for the Miniserver and SSDP sockets.
[in] | miniSock | Socket Array. |
References UpnpPrintf().
Referenced by StartMiniServer().
void SetGenaCallback | ( | MiniServerCallback | callback | ) |
Set GENA Callback.
[in] | callback | GENA Callback to be invoked. |
Referenced by UpnpInitPreamble().
void SetHTTPGetCallback | ( | MiniServerCallback | callback | ) |
Set HTTP Get Callback.
[in] | callback | HTTP Callback to be invoked . |
Referenced by UpnpEnableWebserver().
void SetSoapCallback | ( | MiniServerCallback | callback | ) |
Set SOAP Callback.
[in] | callback | SOAP Callback to be invoked . |
Referenced by UpnpInitPreamble().
int StartMiniServer | ( | unsigned short * | listen_port4, |
unsigned short * | listen_port6 | ||
) |
Initialize the sockets functionality for the Miniserver.
Initialize a thread pool job to run the MiniServer and the job to the thread pool.
If listen port is 0, port is dynamically picked.
Use timer mechanism to start the MiniServer, failure to meet the allowed delay aborts the attempt to launch the MiniServer.
[in,out] | listen_port4 | Port on which the server listens for incoming IPv4 connections. |
[in,out] | listen_port6 | Port on which the server listens for incoming IPv6 connections. |
References get_miniserver_stopsock(), gMiniServerThreadPool, RunMiniServer(), UPNP_E_INTERNAL_ERROR, UPNP_E_OUTOF_MEMORY, and UPNP_E_SUCCESS.
Referenced by UpnpInitStartServers().
int StopMiniServer | ( | ) |
Stop and Shutdown the MiniServer and free socket resources.
References UpnpPrintf().
Referenced by UpnpFinish().