Manage "Step 0: Addressing" of the UPnP+™ specification. More...
Go to the source code of this file.
Classes | |
struct | MiniServerSockArray |
Provides sockets for all network communications. More... | |
Typedefs | |
typedef void(* | MiniServerCallback) (http_parser_t *parser, http_message_t *request, SOCKINFO *info) |
For a miniserver callback function. | |
Functions | |
void | SetSoapCallback (MiniServerCallback callback) |
Set SOAP Callback. | |
void | SetGenaCallback (MiniServerCallback callback) |
Set GENA Callback. | |
int | StartMiniServer (in_port_t *listen_port4, in_port_t *listen_port6, in_port_t *listen_port6UlaGua) |
Initialize the sockets functionality for the Miniserver. | |
int | StopMiniServer () |
Stop and Shutdown the MiniServer and free socket resources. | |
Variables | |
MiniServerCallback | gGetCallback {nullptr} |
HTTP server callback. | |
Manage "Step 0: Addressing" of the UPnP+™ specification.
The minserver program module is encapsulated in this file and has only some public available structures and functions. All other internals are restricted to file scope using the anonymous namespace. The miniserver is started with StartMiniServer(). It mainly initializes and manages the needed network sockets, starts a new thread and runs the miniserver in it with locking and unlocking mutexes. All constructed resources with StartMiniServer() are freed with StopMiniServer(). The miniserver is stopped through a separate stop socket that sends a regular network stop message to localhost for the running miniserver in its thread. This way the blocking ::select() listing will always be triggered and can shutdown the miniserver.
Definition in file miniserver.hpp.
struct MiniServerSockArray |
Provides sockets for all network communications.
Definition at line 64 of file miniserver.hpp.
typedef void(* MiniServerCallback) (http_parser_t *parser, http_message_t *request, SOCKINFO *info) |
For a miniserver callback function.
Definition at line 111 of file miniserver.hpp.
void SetSoapCallback | ( | MiniServerCallback | callback | ) |
Set SOAP Callback.
[in] | callback | SOAP Callback to be invoked. |
Definition at line 1029 of file miniserver.cpp.
void SetGenaCallback | ( | MiniServerCallback | callback | ) |
Set GENA Callback.
[in] | callback | GENA Callback to be invoked. |
Definition at line 1036 of file miniserver.cpp.
int StartMiniServer | ( | in_port_t * | listen_port4, |
in_port_t * | listen_port6, | ||
in_port_t * | listen_port6UlaGua | ||
) |
Initialize the sockets functionality for the Miniserver.
Initialize a thread pool job to run the MiniServer and the job to the thread pool. If a listening port is specified to 0, then the port number is dynamically picked. Use timer mechanism to start the MiniServer, failure to meet the allowed delay aborts the attempt to launch the MiniServer.
The three parameter are only used if we have also a webserver built in. The miniserver does not need them.
I use a simple random number generator for unspecified port numbers. This is needed because I do not reuse addresses before TIME_WAIT has expired (socket option SO_REUSEADDR = false). I must use different socket addresses to be able to restart a device immediately without TIME_WAIT and that is already given with different port numbers on the same ip address.
[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 LLA connections. |
[in,out] | listen_port6UlaGua | Port on which the server listens for incoming IPv6 ULA or GUA connections. |
Definition at line 1042 of file miniserver.cpp.
int StopMiniServer | ( | ) |
Stop and Shutdown the MiniServer and free socket resources.
Definition at line 1156 of file miniserver.cpp.
|
inline |
HTTP server callback.
Definition at line 115 of file miniserver.hpp.