libUPnP
1.8.4
|
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 "upnputil.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 |
Macros | |
#define | APPLICATION_LISTENING_PORT 49152 |
Enumerations | |
enum | MiniServerState { MSERV_IDLE, MSERV_RUNNING, MSERV_STOPPING } |
Functions | |
static UPNP_INLINE void | fdset_if_valid (SOCKET sock, fd_set *set) |
static void | web_server_accept (SOCKET lsock, fd_set *set) |
static void | ssdp_read (SOCKET rsock, fd_set *set) |
static int | receive_from_stopSock (SOCKET ssock, fd_set *set) |
static void | RunMiniServer (MiniServerSockArray *miniSock) |
Run the miniserver. More... | |
static int | get_port (SOCKET sockfd, uint16_t *port) |
Returns port to which socket, sockfd, is bound. More... | |
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. More... | |
static UPNP_INLINE void | InitMiniServerSockArray (MiniServerSockArray *miniSocket) |
int | StartMiniServer (uint16_t *listen_port4, uint16_t *listen_port6) |
Initialize the sockets functionality for the Miniserver. More... | |
int | StopMiniServer () |
Stop and Shutdown the MiniServer and free socket resources. More... | |
Variables | |
uint16_t | miniStopSockPort |
static MiniServerState | gMServState = MSERV_IDLE |
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:
#define APPLICATION_LISTENING_PORT 49152 |
enum MiniServerState |
|
static |
Creates the miniserver STOP socket. This socket is created and listened on to know when it is time to stop the Miniserver.
UPNP_E_OUTOF_SOCKET:
Failed to create a socket. UPNP_E_SOCKET_BIND:
Bind() failed. UPNP_E_INTERNAL_ERROR:
Port returned by the socket layer is < 0. UPNP_E_SUCCESS:
Success. [in] | out | Miniserver Socket Array. |
|
static |
Returns port to which socket, sockfd, is bound.
[in] | sockfd | Socket descriptor. |
[out] | port | The port value if successful, otherwise, untouched. |
References UpnpPrintf().
|
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. |
int StartMiniServer | ( | uint16_t * | listen_port4, |
uint16_t * | 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 gMServState, MSERV_IDLE, UPNP_E_INTERNAL_ERROR, and UPNP_E_OUTOF_MEMORY.
int StopMiniServer | ( | ) |
Stop and Shutdown the MiniServer and free socket resources.
|
static |
module vars
Referenced by StartMiniServer().
uint16_t miniStopSockPort |