picow-http 0.12.1-4-g9d4fd13
HTTP server for the Raspberry Pi PicoW
server_cfg Struct Reference

HTTP server configuration. More...

#include </builds/korneliuszo/picow_http/include/picow_http/http.h>

Data Fields

struct ntp_cfg ntp_cfg
 
const ip_addr_t * ipaddr
 
unsigned idle_tmo_s
 
unsigned send_tmo_s
 
uint16_t port
 
uint8_t listen_backlog
 
enum lwip_ip_addr_type ip_type
 
bool tls
 

Detailed Description

Configuration of the HTTP server used at startup by http_srv_init().

Struct members ipaddr and ip_type, which configure the IP address at which the server listens, use data types from lwIP for IP address handling. To configure a listen address that differs from the default, use one of the mechanisms defined in lwIP's ip_addr.h, ip4_addr.h and/or ip6_addr.h

For example, to listen only at a specific IPv4 address (perhaps because a static IPv4 address has been configured at the router for the PicoW's MAC address):

#include "lwip/ip4_addr.h"
struct server_cfg cfg;
// Start with the default config, so that we only need to change
// individual fields.
// Listen at 192.0.2.47
IP4_ADDR(cfg.ipaddr, 192, 0, 2, 47);
// Listener is IPv4 only.
cfg.ip_type = IPADDR_TYPE_V4;
if (http_srv_init(&srv, &cfg) != ERR_OK) {
// Error handling
}
static struct server_cfg http_default_cfg(void)
Get the default HTTP server configuration.
Definition: http.h:894
err_t http_srv_init(struct server **server, struct server_cfg *cfg)
Start an HTTP server.
HTTP server configuration.
Definition: http.h:774

A simple and common solution is for the server to listen at any IPv4 or IPv6 address assigned to the PicoW, using IP_ADDR_ANY for the ipaddr member and IPADDR_TYPE_ANY for ip_type. This is the configuration set by http_default_cfg(), so it requires no further modification by application code.

See also
http_srv_init(), http_default_cfg(), http_cfg(), lwIP IP address handling

Field Documentation

◆ idle_tmo_s

unsigned server_cfg::idle_tmo_s

Idle connection timeout in seconds.

◆ ip_type

enum lwip_ip_addr_type server_cfg::ip_type

Listen at an IPv4 or IPv6 address, or both.

◆ ipaddr

const ip_addr_t* server_cfg::ipaddr

IP address at which the server listens.

◆ listen_backlog

uint8_t server_cfg::listen_backlog

Maximum length of the listen queue for incoming connections.

◆ ntp_cfg

struct ntp_cfg server_cfg::ntp_cfg

Configuration of NTP time synchronization

◆ port

uint16_t server_cfg::port

Port at which the server listens.

◆ send_tmo_s

unsigned server_cfg::send_tmo_s

Network send timeout in seconds.

◆ tls

bool server_cfg::tls

true iff this is the configuration of a TLS server.


The documentation for this struct was generated from the following file: