Classes | |
| struct | active_connection_t |
| struct | mserv_request_t |
| miniserver received request message. More... | |
Enumerations | |
| enum | MiniServerState { MSERV_IDLE , MSERV_RUNNING , MSERV_STOPPING } |
| miniserver state More... | |
Variables | |
| in_port_t | miniStopSockPort |
| Port of the stop socket. | |
| MiniServerState | gMServState {MSERV_IDLE} |
| miniserver state | |
| MiniServerCallback | gSoapCallback {nullptr} |
| SOAP callback. | |
| MiniServerCallback | gGenaCallback {nullptr} |
| GENA callback. | |
Scope restricted to file | |
| static LinkedList | gActiveConnections |
| static pthread_mutex_t | gActiveConnectionsMutex |
| static int | gActiveConnectionsInitialized = 0 |
| static int | active_connection_cmp (void *first, void *second) |
| Compare function for active connections, return true if equal (found) | |
| static void | add_active_connection (SOCKET sock) |
| Add a socket to the active connections list. | |
| static void | remove_active_connection (SOCKET sock) |
| Remove a socket from the active connections list. | |
| void | shutdown_all_active_connections (void) |
| Shutdown all active socket connections. | |
| int | host_header_is_numeric (char *a_host_port, size_t a_host_port_len) |
| Check if a network address is numeric. | |
| int | getNumericHostRedirection (SOCKET a_socket, char *a_host_port, size_t a_hp_size) |
| Returns the ip address with port as text that is bound to a socket. | |
| int | dispatch_request (SOCKINFO *a_info, http_parser_t *a_hparser) |
| Based on the type of message, appropriate callback is issued. | |
| void | free_handle_request_arg (void *args) |
| Free memory assigned for handling request and unitialize socket functionality. | |
| void | handle_request (void *args) |
| Receive the request and dispatch it for handling. | |
| void | schedule_request_job (SOCKET a_sock, UPnPsdk::SSockaddr &clientAddr) |
| Initilize the thread pool to handle an incomming request, sets priority for the job and adds the job to the thread pool. | |
| void | fdset_if_valid (SOCKET a_sock, fd_set *a_set) |
Add a socket file descriptor to an 'fd_set' structure as needed for ::select(). | |
| int | web_server_accept (SOCKET listen_sock, fd_set &set) |
| Accept requested connection from a remote control point and run it in a new thread. | |
| void | ssdp_read (SOCKET *rsock, fd_set *set) |
| Read data from the SSDP socket. | |
| int | receive_from_stopSock (SOCKET ssock, fd_set *set) |
| Check if we have received a packet that shall stop the miniserver. | |
| void | RunMiniServer (MiniServerSockArray *miniSock) |
| Run the miniserver. | |
| void | RunMiniServer_f (MiniServerSockArray *miniSock) |
| int | get_port (SOCKET sockfd, uint16_t *port) |
| Returns port to which socket, sockfd, is bound. | |
| int | get_miniserver_sockets (MiniServerSockArray *out, in_port_t listen_port4, in_port_t listen_port6, in_port_t listen_port6UlaGua) |
| Create STREAM sockets, binds to local network interfaces and listens for incoming connections. | |
| int | get_miniserver_stopsock (MiniServerSockArray *out) |
| Creates the miniserver STOP socket, usable to listen for stopping the miniserver. | |
| void | InitMiniServerSockArray (MiniServerSockArray *miniSocket) |
| Initialize a miniserver Socket Array. | |
| struct anonymous_namespace{miniserver.cpp}::active_connection_t |
Structure to hold active connection info
Definition at line 110 of file miniserver.cpp.
| Class Members | ||
|---|---|---|
| SOCKET | socket | |
| time_t | connect_time | |
| struct anonymous_namespace{miniserver.cpp}::mserv_request_t |
miniserver received request message.
This defines the structure of a UPnP request that has income from a remote control point.
Definition at line 70 of file miniserver.cpp.
| Class Members | ||
|---|---|---|
| SOCKET | sock | Connection socket file descriptor. |
| sockaddr_storage | foreign_sockaddr | Socket address of the remote control point. |
| enum anonymous_namespace{miniserver.cpp}::MiniServerState |
miniserver state
| Enumerator | |
|---|---|
| MSERV_IDLE | miniserver is idle. |
| MSERV_RUNNING | miniserver is running. |
| MSERV_STOPPING | miniserver is running to stop. |
Definition at line 78 of file miniserver.cpp.
|
static |
Compare function for active connections, return true if equal (found)
Definition at line 118 of file miniserver.cpp.
Here is the caller graph for this function:
|
static |
Add a socket to the active connections list.
Definition at line 130 of file miniserver.cpp.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Remove a socket from the active connections list.
Definition at line 158 of file miniserver.cpp.
Here is the call graph for this function:
Here is the caller graph for this function:| void anonymous_namespace{miniserver.cpp}::shutdown_all_active_connections | ( | void | ) |
Shutdown all active socket connections.
Definition at line 183 of file miniserver.cpp.
Here is the call graph for this function:
Here is the caller graph for this function:| int anonymous_namespace{miniserver.cpp}::host_header_is_numeric | ( | char * | a_host_port, |
| size_t | a_host_port_len | ||
| ) |
Check if a network address is numeric.
An empty netaddress or an unspecified one ("[::]", "0.0.0.0") is not valid.
| a_host_port | network address |
| a_host_port_len | length of a_host_port excl. terminating '\0'. |
Definition at line 224 of file miniserver.cpp.
Here is the caller graph for this function:| int anonymous_namespace{miniserver.cpp}::getNumericHostRedirection | ( | SOCKET | a_socket, |
| char * | a_host_port, | ||
| size_t | a_hp_size | ||
| ) |
Returns the ip address with port as text that is bound to a socket.
Example: may return "[2001:db8::ab]:50044" or "192.168.1.2:54321".
| [in] | a_socket | Socket file descriptor. |
| [in,out] | a_host_port | Pointer to buffer that will be filled. |
| [in] | a_hp_size | size of the buffer. |
Definition at line 251 of file miniserver.cpp.
Here is the call graph for this function:
Here is the caller graph for this function:| int anonymous_namespace{miniserver.cpp}::dispatch_request | ( | SOCKINFO * | a_info, |
| http_parser_t * | a_hparser | ||
| ) |
Based on the type of message, appropriate callback is issued.
| [in] | a_info | Socket Information object. |
| [in] | a_hparser | HTTP parser object. |
Definition at line 278 of file miniserver.cpp.
Here is the call graph for this function:
Here is the caller graph for this function:| void anonymous_namespace{miniserver.cpp}::free_handle_request_arg | ( | void * | args | ) |
Free memory assigned for handling request and unitialize socket functionality.
| [in] | args | Request Message to be freed. |
Definition at line 382 of file miniserver.cpp.
Here is the call graph for this function:
Here is the caller graph for this function:| void anonymous_namespace{miniserver.cpp}::handle_request | ( | void * | args | ) |
Receive the request and dispatch it for handling.
| [in] | args | Pointer to Received Request Message to be handled. It's expected to be mserv_request_t* |
Definition at line 398 of file miniserver.cpp.
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
Initilize the thread pool to handle an incomming request, sets priority for the job and adds the job to the thread pool.
| [in] | a_sock | Socket Descriptor on which connection is accepted. |
| [in] | clientAddr | Ctrlpnt address object. |
Definition at line 468 of file miniserver.cpp.
Here is the call graph for this function:
Here is the caller graph for this function:| void anonymous_namespace{miniserver.cpp}::fdset_if_valid | ( | SOCKET | a_sock, |
| fd_set * | a_set | ||
| ) |
Add a socket file descriptor to an 'fd_set' structure as needed for ::select().
a_set may already contain file descriptors. The given a_sock is added to the set. It is ensured that ::select() is not fed with invalid socket file descriptors, in particular with the EBADF error. That could mean: closed socket, or an other network error was detected before adding to the set. It checks that we do not use closed or unbind sockets. It also has a guard that we do not exceed the maximum number FD_SETSIZE (1024) of selectable file descriptors, as noted in "man select".
Returns
| [in] | a_sock | socket file descriptor. |
| [out] | a_set | Pointer to an 'fd_set' structure as needed for ::select(). The structure is modified as documented for ::select(). |
Definition at line 531 of file miniserver.cpp.
Here is the call graph for this function:
Here is the caller graph for this function:| int anonymous_namespace{miniserver.cpp}::web_server_accept | ( | SOCKET | listen_sock, |
| fd_set & | set | ||
| ) |
Accept requested connection from a remote control point and run it in a new thread.
| [in] | listen_sock | File descriptor of socket that is listening on incomming requests. |
| [out] | set | Reference to a file descriptor set as needed for ::select(). |
Definition at line 580 of file miniserver.cpp.
Here is the call graph for this function:
Here is the caller graph for this function:| void anonymous_namespace{miniserver.cpp}::ssdp_read | ( | SOCKET * | rsock, |
| fd_set * | set | ||
| ) |
Read data from the SSDP socket.
| [in] | rsock | Pointer to a Socket file descriptor. |
| [in] | set | Pointer to a file descriptor set as needed for ::select(). |
Definition at line 636 of file miniserver.cpp.
Here is the call graph for this function:
Here is the caller graph for this function:| int anonymous_namespace{miniserver.cpp}::receive_from_stopSock | ( | SOCKET | ssock, |
| fd_set * | set | ||
| ) |
Check if we have received a packet that shall stop the miniserver.
The received datagram must exactly match the shutdown_str from 127.0.0.1. This is a security issue to avoid that the UPnPlib can be terminated from a remote ip address. Receiving 0 bytes on a datagram (there's a datagram here) indicates that a zero-length datagram was successful sent. This will not stop the miniserver.
| [in] | ssock | Socket file descriptor. |
| [in] | set | Pointer to a file descriptor set as needed for ::select(). |
Definition at line 672 of file miniserver.cpp.
Here is the caller graph for this function:| void anonymous_namespace{miniserver.cpp}::RunMiniServer | ( | MiniServerSockArray * | miniSock | ) |
Run the miniserver.
The MiniServer accepts a new request and schedules a thread to handle the new request. It checks for socket state and invokes appropriate read and shutdown actions for the Miniserver and SSDP sockets. This function itself runs in its own thread.
| [in] | miniSock | Pointer to an Array containing valid sockets associated with different tasks like listen on a local interface for requests from control points or handle ssdp communication to a remote UPnP node. |
Definition at line 735 of file miniserver.cpp.
Here is the call graph for this function:| void anonymous_namespace{miniserver.cpp}::RunMiniServer_f | ( | MiniServerSockArray * | miniSock | ) |
Global list to track active socket connections
Definition at line 907 of file miniserver.cpp.
Here is the caller graph for this function:| int anonymous_namespace{miniserver.cpp}::get_port | ( | SOCKET | sockfd, |
| uint16_t * | port | ||
| ) |
Returns port to which socket, sockfd, is bound.
| [in] | sockfd | Socket descriptor. |
| [out] | port | The port value if successful, otherwise, untouched. |
Definition at line 919 of file miniserver.cpp.
Here is the caller graph for this function:| int anonymous_namespace{miniserver.cpp}::get_miniserver_sockets | ( | MiniServerSockArray * | out, |
| in_port_t | listen_port4, | ||
| in_port_t | listen_port6, | ||
| in_port_t | listen_port6UlaGua | ||
| ) |
Create STREAM sockets, binds to local network interfaces and listens for incoming connections.
This is part of starting the miniserver and only available with the webserver compiled in.
| [out] | out | Pointer to a Socket Array that following members will be filled:
|
| [in] | listen_port4 | port on which the UPnP Device shall listen for incoming IPv4 connections. If 0 then an available port number from the operating system is returned in out. |
| [in] | listen_port6 | port on which the UPnP Device shall listen for incoming IPv6 LLA connections. If 0 then an available port number from the operating system is returned in out. |
| [in] | listen_port6UlaGua | port on which the UPnP Device shall listen for incoming IPv6 GUA connections. If 0 then an available port number from the operating system is returned in ***out**. |
Definition at line 963 of file miniserver.cpp.
Here is the call graph for this function:
Here is the caller graph for this function:| int anonymous_namespace{miniserver.cpp}::get_miniserver_stopsock | ( | MiniServerSockArray * | out | ) |
Creates the miniserver STOP socket, usable to listen for stopping the miniserver.
This datagram socket is created and bound to "localhost". It does not listen now but will later be used to listen on to know when it is time to stop the Miniserver.
| [out] | out | Fills the socket file descriptor and the port it is bound to into the structure. |
Definition at line 1076 of file miniserver.cpp.
Here is the call graph for this function:
Here is the caller graph for this function:| void anonymous_namespace{miniserver.cpp}::InitMiniServerSockArray | ( | MiniServerSockArray * | miniSocket | ) |
Initialize a miniserver Socket Array.
| miniSocket | Pointer to a miniserver Socket Array. |
Definition at line 1124 of file miniserver.cpp.
Here is the caller graph for this function:| in_port_t anonymous_namespace{miniserver.cpp}::miniStopSockPort |
Port of the stop socket.
With starting the miniserver there is also this port registered. Its socket is listing for a "ShutDown" message from a local network address (localhost). This is used to stop the miniserver from another thread.
Definition at line 89 of file miniserver.cpp.
| MiniServerState anonymous_namespace{miniserver.cpp}::gMServState {MSERV_IDLE} |
miniserver state
Definition at line 92 of file miniserver.cpp.
| MiniServerCallback anonymous_namespace{miniserver.cpp}::gSoapCallback {nullptr} |
SOAP callback.
Definition at line 97 of file miniserver.cpp.
| MiniServerCallback anonymous_namespace{miniserver.cpp}::gGenaCallback {nullptr} |
GENA callback.
Definition at line 99 of file miniserver.cpp.
|
static |
Global list to track active socket connections
Definition at line 105 of file miniserver.cpp.
|
static |
Global list to track active socket connections
Definition at line 106 of file miniserver.cpp.
|
static |
Global list to track active socket connections
Definition at line 107 of file miniserver.cpp.