### Start Default TCP Server Function for lwIP iPerf Source: https://www.nongnu.org/lwip/2_1_x/lwiperf_8h Starts a TCP server for iPerf with default settings. It requires a report callback function and a user-defined argument. This is a convenience function for quick setup. ```c void * lwiperf_start_tcp_server_default (lwiperf_report_fn report_fn, void *report_arg) ``` -------------------------------- ### MQTT Outgoing Publish Example in C Source: https://www.nongnu.org/lwip/2_1_x/group__mqtt Provides an example function to publish messages to an MQTT topic. It demonstrates setting the payload, Quality of Service (QoS) level, and retain flag. This function requires a valid MQTT client connection to be established beforehand. ```c void example_publish(mqtt_client_t *client, void *arg) { const char *pub_payload= "PubSubHubLubJub"; err_t err; u8_t qos = 2; /* 0 1 or 2, see MQTT specification */ u8_t retain = 0; /* No don't retain such crappy payload... */ /* Example of publishing a message */ /* err = mqtt_publish(client, "topic/to/publish", pub_payload, strlen(pub_payload), qos, retain, mqtt_publish_request_cb, arg); */ /* For now just print the result code if something goes wrong */ /* if(err != ERR_OK) { printf("mqtt_publish return: %d\n", err); } */ } ``` -------------------------------- ### Start TCP Server Function for lwIP iPerf Source: https://www.nongnu.org/lwip/2_1_x/lwiperf_8h Starts a TCP server for iPerf performance testing. Requires the local IP address, port, a report callback function, and user-defined argument. Returns a handle to the iPerf session. ```c void * lwiperf_start_tcp_server (const ip_addr_t *local_addr, u16_t local_port, lwiperf_report_fn report_fn, void *report_arg) ``` -------------------------------- ### lwIP iPerf Server Functions Source: https://www.nongnu.org/lwip/2_1_x/lwiperf_8h Functions to start a TCP iPerf server, either with a specified local address and port or using default settings. ```APIDOC ## lwperf_start_tcp_server ### Description Starts a TCP iPerf server on the specified local address and port. ### Method * void * ### Endpoint N/A (Function Call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c void *lwperf_session = lwperf_start_tcp_server(&local_ip, 12345, report_callback, NULL); ``` ### Response #### Success Response - **void***: A pointer to the iperf session structure, or NULL if the server could not be started. #### Response Example ```c (void*)0x12345678 // Example session pointer ``` ## lwperf_start_tcp_server_default ### Description Starts a TCP iPerf server using default settings (e.g., default IP address and port). ### Method * void * ### Endpoint N/A (Function Call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c void *lwperf_session = lwperf_start_tcp_server_default(report_callback, NULL); ``` ### Response #### Success Response - **void***: A pointer to the iperf session structure, or NULL if the server could not be started. #### Response Example ```c (void*)0x12345678 // Example session pointer ``` ``` -------------------------------- ### Start Default TCP Client Function for lwIP iPerf Source: https://www.nongnu.org/lwip/2_1_x/lwiperf_8h Starts an iPerf TCP client with default parameters. It requires the remote server's IP address, a report callback function, and a user-defined argument. This simplifies client initiation. ```c void * lwiperf_start_tcp_client_default (const ip_addr_t *remote_addr, lwiperf_report_fn report_fn, void *report_arg) ``` -------------------------------- ### lwIP iPerf Client Functions Source: https://www.nongnu.org/lwip/2_1_x/lwiperf_8h Functions to start a TCP iPerf client to connect to a remote server, with options for client type and default configurations. ```APIDOC ## lwperf_start_tcp_client ### Description Starts a TCP iPerf client to connect to a remote server. ### Method * void * ### Endpoint N/A (Function Call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c void *lwperf_session = lwperf_start_tcp_client(&remote_ip, 5001, LWIPERF_CLIENT, report_callback, NULL); ``` ### Response #### Success Response - **void***: A pointer to the iperf session structure, or NULL if the client could not be started. #### Response Example ```c (void*)0x87654321 // Example session pointer ``` ## lwperf_start_tcp_client_default ### Description Starts a TCP iPerf client using default settings to connect to a remote server. ### Method * void * ### Endpoint N/A (Function Call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c void *lwperf_session = lwperf_start_tcp_client_default(&remote_ip, report_callback, NULL); ``` ### Response #### Success Response - **void***: A pointer to the iperf session structure, or NULL if the client could not be started. #### Response Example ```c (void*)0x87654321 // Example session pointer ``` ``` -------------------------------- ### lwIP iPerf Server API Source: https://www.nongnu.org/lwip/2_1_x/lwiperf_8c This section details the functions available for starting, managing, and aborting lwIP iPerf TCP server and client sessions. ```APIDOC ## lwIP iPerf Server Functions ### Description Functions for initiating and controlling lwIP iPerf TCP server and client operations. ### Functions #### `lwiperf_start_tcp_server_default` - **Signature**: `void *lwiperf_start_tcp_server_default(lwiperf_report_fn report_fn, void *report_arg)` - **Description**: Starts a TCP iPerf server using default settings. #### `lwiperf_start_tcp_server` - **Signature**: `void *lwiperf_start_tcp_server(const ip_addr_t *local_addr, u16_t local_port, lwiperf_report_fn report_fn, void *report_arg)` - **Description**: Starts a TCP iPerf server listening on a specific local address and port. #### `lwiperf_start_tcp_client_default` - **Signature**: `void *lwiperf_start_tcp_client_default(const ip_addr_t *remote_addr, lwiperf_report_fn report_fn, void *report_arg)` - **Description**: Starts a TCP iPerf client to a default remote server address. #### `lwiperf_start_tcp_client` - **Signature**: `void *lwiperf_start_tcp_client(const ip_addr_t *remote_addr, u16_t remote_port, enum lwiperf_client_type type, lwiperf_report_fn report_fn, void *report_arg)` - **Description**: Starts a TCP iPerf client connecting to a specified remote address and port. #### `lwiperf_abort` - **Signature**: `void lwiperf_abort(void *lwiperf_session)` - **Description**: Aborts an ongoing iPerf session. ### Macros #### `LWIPERF_TCP_MAX_IDLE_SEC` - **Value**: `10U` - **Description**: Specifies the idle timeout in seconds after which the test fails. #### `LWIPERF_SERVER_IP_TYPE` - **Value**: `IPADDR_TYPE_ANY` - **Description**: Configures the IP version the iperf server listens on. `IPADDR_TYPE_ANY` means any IP version. #### `LWIPERF_CHECK_RX_DATA` - **Value**: `0` - **Description**: If set to `1`, checks if the received data has the correct format. Defaults to `0` (disabled). ### Typedefs #### `lwiperf_settings_t` - **Underlying Type**: `struct _lwiperf_settings` - **Description**: Represents the settings structure for an iPerf client. #### `lwiperf_state_tcp_t` - **Underlying Type**: `struct _lwiperf_state_tcp` - **Description**: Connection handle for a TCP iperf session. ``` -------------------------------- ### SNMP Initialization and Configuration (C) Source: https://www.nongnu.org/lwip/2_1_x/apps_2snmp_8h Functions for initializing the SNMP server, setting Management Information Bases (MIBs), and configuring device-specific OIDs. These functions are essential for the basic setup of the SNMP agent. ```C void snmp_init(void); void snmp_set_mibs(const struct snmp_mib **mibs, u8_t num_mibs); void snmp_set_device_enterprise_oid(const struct snmp_obj_id *device_enterprise_oid); const struct snmp_obj_id * snmp_get_device_enterprise_oid(void); ``` -------------------------------- ### MQTT Client Initialization and Connection in C Source: https://www.nongnu.org/lwip/2_1_x/group__mqtt Demonstrates how to initialize an MQTT client using either static or dynamic memory allocation and establish a connection to an MQTT server. It includes setting client information and handling connection callbacks. Dependencies include the lwIP network stack and MQTT protocol definitions. ```c static void example_do_connect(mqtt_client_t *client) { struct mqtt_connect_client_info_t ci; err_t err; /* Setup an empty client info structure */ memset(&ci, 0, sizeof(ci)); /* Minimal amount of information required is client identifier, so set it here */ ci.client_id = "lwip_test"; /* Initiate client and connect to server, if this fails immediately an error code is returned otherwise mqtt_connection_cb will be called with connection result after attempting to establish a connection with the server. For now MQTT version 3.1.1 is always used */ err = mqtt_client_connect(client, ip_addr, MQTT_PORT, mqtt_connection_cb, 0, &ci); /* For now just print the result code if something goes wrong */ if(err != ERR_OK) { printf("mqtt_connect return %d\n", err); } } /* Example usage for static allocation */ mqtt_client_t static_client; example_do_connect(&static_client); /* Example usage for dynamic allocation */ mqtt_client_t *client = mqtt_client_new(); if(client != NULL) { example_do_connect(&client); } /* Connection status can be probed by calling mqtt_client_is_connected(client) */ ``` -------------------------------- ### MIN_REQ_LEN Macro Explanation (C) Source: https://www.nongnu.org/lwip/2_1_x/httpd_8c Defines the minimum length for a valid HTTP/0.9 request. The example 'GET /\r\n' is shown to be exactly 7 bytes, establishing the minimum requirement. ```c #define MIN_REQ_LEN 7 ``` -------------------------------- ### httpd_inits() Source: https://www.nongnu.org/lwip/2_1_x/group__httpd Initializes the HTTPD server, including setting up a listening PCB, binding to a port, and configuring TLS for HTTPS connections. ```APIDOC ## httpd_inits() ### Description Initialize the httpd: set up a listening PCB and bind it to the defined port. Also set up TLS connection handling (HTTPS). ### Method void ### Endpoint N/A (Function Call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c void httpd_inits(struct altcp_tls_config *_conf_); ``` ### Response #### Success Response (N/A) N/A #### Response Example N/A ``` -------------------------------- ### netif_set_up Source: https://www.nongnu.org/lwip/2_1_x/group__netif Enables a network interface, allowing traffic processing. ```APIDOC ## netif_set_up ### Description Brings a network interface up, making it available for processing network traffic. ### Method N/A (Function Signature) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (void) This function does not return a value. #### Response Example N/A ``` -------------------------------- ### altcp_tls_context() - Get Internal TLS Context Source: https://www.nongnu.org/lwip/2_1_x/group__altcp__tls Retrieves a pointer to the internal TLS context associated with an ALTCP connection. This allows the application to modify the TLS context directly, for example, to configure specific cipher suites or settings. ```APIDOC ## altcp_tls_context() ### Description Returns a pointer to the internal TLS context of an ALTCP connection. This allows the application to tweak the TLS context directly. The actual type of the context depends on the specific TLS implementation used (e.g., mbedTLS). ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c void* tls_context = altcp_tls_context(my_altcp_pcb); // Cast tls_context to the appropriate type (e.g., mbedtls_ssl_context*) and modify it. ``` ### Response #### Success Response (200) - **return value** (void *) - Pointer to the internal TLS context. #### Response Example ```c // Returns a pointer to the TLS context structure. ``` ### Error Handling - Returns NULL if the connection is not a TLS connection or if the context cannot be retrieved. ``` -------------------------------- ### Start AUTOIP Client (C) Source: https://www.nongnu.org/lwip/2_1_x/group__autoip Starts the AUTOIP client on a specified network interface. This function is typically called after netif_add() when DHCP is not used or when LWIP_DHCP_AUTOIP_COOP is enabled. ```c err_t autoip_start(struct netif *netif) ``` -------------------------------- ### SNMP Options and Core Initialization (C) Source: https://www.nongnu.org/lwip/2_1_x/apps_2snmp_8h This C code snippet includes necessary headers for SNMP options, error handling, and core SNMP functionality within the lwIP stack. It demonstrates the setup required to utilize SNMP features. ```c #include "lwip/apps/snmp_opts.h" #include "lwip/err.h" #include "lwip/apps/snmp_core.h" ``` -------------------------------- ### Example TXT Record Callback Function Source: https://www.nongnu.org/lwip/2_1_x/group__mdns This is an example implementation of a service_get_txt_fn_t callback. It demonstrates how to add a "path=/" TXT record to a service's response using mdns_resp_add_service_txtitem(). ```c static void srv_txt(struct mdns_service *service, void *txt_userdata) { err_t res; res = mdns_resp_add_service_txtitem(service, "path=/", 6); LWIP_ERROR("mdns add service txt failed\n", (res == ERR_OK), return); } ``` -------------------------------- ### DNS Initialization and Configuration (C) Source: https://www.nongnu.org/lwip/2_1_x/dns_8h This C code snippet demonstrates the initialization and configuration of the DNS client within the lwIP stack. It includes setting up timer intervals, registering callback functions, and configuring DNS servers. ```c #include "lwip/opt.h" #include "lwip/ip_addr.h" #include "lwip/err.h" #define DNS_TMR_INTERVAL 1000 typedef void(* dns_found_callback) (const char *name, const ip_addr_t *ipaddr, void *callback_arg); void dns_init (void); void dns_tmr (void); void dns_setserver (u8_t numdns, const ip_addr_t *dnsserver); const ip_addr_t * dns_getserver (u8_t numdns); err_t dns_gethostbyname (const char *hostname, ip_addr_t *addr, dns_found_callback found, void *callback_arg); err_t dns_gethostbyname_addrtype (const char *hostname, ip_addr_t *addr, dns_found_callback found, void *callback_arg, u8_t dns_addrtype); ``` -------------------------------- ### Start TCP Server with Default Port Source: https://www.nongnu.org/lwip/2_1_x/group__iperf Starts a TCP iperf server on the default TCP port (5001). It listens for incoming connections from iperf clients. A connection handle is returned, which can be used to abort the server. ```APIDOC ## lwiperf_start_tcp_server_default() ### Description Starts a TCP iperf server on the default TCP port (5001) and listen for incoming connections from iperf clients. ### Method N/A (This is a function signature, not a direct HTTP endpoint) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) N/A #### Response Example N/A ### Returns a connection handle that can be used to abort the server by calling lwiperf_abort() ``` -------------------------------- ### Start TCP Server with Specific Address and Port Source: https://www.nongnu.org/lwip/2_1_x/group__iperf Starts a TCP iperf server on a specified IP address and port. It listens for incoming connections from iperf clients. A connection handle is returned, which can be used to abort the server. ```APIDOC ## lwiperf_start_tcp_server() ### Description Starts a TCP iperf server on a specific IP address and port and listens for incoming connections from iperf clients. ### Method N/A (This is a function signature, not a direct HTTP endpoint) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) N/A #### Response Example N/A ### Returns a connection handle that can be used to abort the server by calling lwiperf_abort() ``` -------------------------------- ### httpd_init() Source: https://www.nongnu.org/lwip/2_1_x/group__httpd Initializes the HTTPD server by setting up a listening Transmission Control Block (PCB) and binding it to the default or configured port. ```APIDOC ## httpd_init() ### Description Initialize the httpd: set up a listening PCB and bind it to the defined port. ### Method void ### Endpoint N/A (Function Call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c void httpd_init(void); ``` ### Response #### Success Response (N/A) N/A #### Response Example N/A ``` -------------------------------- ### Network Interface Driver Servicing Example (cs8900) Source: https://www.nongnu.org/lwip/2_1_x/optimization Demonstrates how to frequently service the network interface driver to prevent buffer overflows, using the cs8900 driver as an example. For RTOS environments, an interrupt-driven approach with semaphores or event flags is suggested. ```c cs8900if_service(ethif); // In an RTOS: // ISR triggers a high-priority task to service the driver via semaphore/event flag. ``` -------------------------------- ### TCP Connection Establishment and Configuration Source: https://www.nongnu.org/lwip/2_1_x/tcp_8c Functions for binding, listening, connecting, and configuring TCP connections. ```APIDOC ## POST /tcp/bind ### Description Binds a TCP connection (pcb) to a specific local IP address and port. ### Method POST ### Endpoint /tcp/bind ### Parameters #### Request Body - **pcb** (struct tcp_pcb*) - The TCP connection control block. - **ipaddr** (const ip_addr_t*) - The local IP address to bind to. Use IP_ANY_TYPE for any. - **port** (u16_t) - The local port number to bind to. ### Request Example ```json { "pcb": "0x...", "ipaddr": "0.0.0.0", "port": 80 } ``` ### Response #### Success Response (200) - **err** (err_t) - Error code indicating success or failure. #### Response Example ```json { "err": 0 } ``` ``` ```APIDOC ## POST /tcp/listen ### Description Sets a TCP connection (pcb) to listen for incoming connections, with a specified backlog. ### Method POST ### Endpoint /tcp/listen ### Parameters #### Request Body - **pcb** (struct tcp_pcb*) - The TCP connection control block. - **backlog** (u8_t) - The maximum number of unaccepted connections to queue. ### Request Example ```json { "pcb": "0x...", "backlog": 5 } ``` ### Response #### Success Response (200) - **pcb** (struct tcp_pcb*) - A pointer to the listening pcb, or NULL if listening failed. - **err** (err_t) - Error code indicating success or failure. #### Response Example ```json { "pcb": "0x...", "err": 0 } ``` ``` ```APIDOC ## POST /tcp/connect ### Description Initiates a TCP connection from the given pcb to the specified remote host and port. ### Method POST ### Endpoint /tcp/connect ### Parameters #### Request Body - **pcb** (struct tcp_pcb*) - The TCP connection control block. - **ipaddr** (const ip_addr_t*) - The remote IP address to connect to. - **port** (u16_t) - The remote port number to connect to. - **connected_fn** (tcp_connected_fn) - A callback function to be called when the connection is established. ### Request Example ```json { "pcb": "0x...", "ipaddr": "192.168.1.100", "port": 1234, "connected_fn": "my_connected_callback" } ``` ### Response #### Success Response (200) - **err** (err_t) - Error code indicating success or failure. #### Response Example ```json { "err": 0 } ``` ``` ```APIDOC ## POST /tcp/close ### Description Closes a TCP connection. ### Method POST ### Endpoint /tcp/close ### Parameters #### Request Body - **pcb** (struct tcp_pcb*) - The TCP connection control block to close. ### Request Example ```json { "pcb": "0x..." } ``` ### Response #### Success Response (200) - **err** (err_t) - Error code indicating success or failure. #### Response Example ```json { "err": 0 } ``` ``` ```APIDOC ## POST /tcp/shutdown ### Description Shuts down one or both directions of a TCP connection. ### Method POST ### Endpoint /tcp/shutdown ### Parameters #### Request Body - **pcb** (struct tcp_pcb*) - The TCP connection control block. - **shut_rx** (int) - Flag to shut down the receive direction (1 for shut down, 0 otherwise). - **shut_tx** (int) - Flag to shut down the send direction (1 for shut down, 0 otherwise). ### Request Example ```json { "pcb": "0x...", "shut_rx": 1, "shut_tx": 0 } ``` ### Response #### Success Response (200) - **err** (err_t) - Error code indicating success or failure. #### Response Example ```json { "err": 0 } ``` ``` -------------------------------- ### MQTT Client Functions in C Source: https://www.nongnu.org/lwip/2_1_x/mqtt_8c This snippet includes essential functions for operating an MQTT client using the lwIP stack. It covers client creation, connection management, publishing, subscribing, and setting callbacks for incoming messages. Dependencies include lwIP core and application-specific headers. ```c #include "lwip/apps/mqtt.h" #include "lwip/apps/mqtt_priv.h" #include "lwip/timeouts.h" #include "lwip/ip_addr.h" #include "lwip/mem.h" #include "lwip/err.h" #include "lwip/pbuf.h" #include "lwip/altcp.h" #include "lwip/altcp_tcp.h" #include "lwip/altcp_tls.h" #include err_t mqtt_publish (mqtt_client_t *client, const char *topic, const void *payload, u16_t payload_length, u8_t qos, u8_t retain, mqtt_request_cb_t cb, void *arg); err_t mqtt_sub_unsub (mqtt_client_t *client, const char *topic, u8_t qos, mqtt_request_cb_t cb, void *arg, u8_t sub); void mqtt_set_inpub_callback (mqtt_client_t *client, mqtt_incoming_publish_cb_t pub_cb, mqtt_incoming_data_cb_t data_cb, void *arg); mqtt_client_t * mqtt_client_new (void); void mqtt_client_free (mqtt_client_t *client); err_t mqtt_client_connect (mqtt_client_t *client, const ip_addr_t *ip_addr, u16_t port, mqtt_connection_cb_t cb, void *arg, const struct mqtt_connect_client_info_t *client_info); void mqtt_disconnect (mqtt_client_t *client); u8_t mqtt_client_is_connected (mqtt_client_t *client); ``` -------------------------------- ### SMTP Client Callback Function Example (C) Source: https://www.nongnu.org/lwip/2_1_x/group__smtp An example of a callback function `my_smtp_result_fn` that is invoked upon completion of an SMTP mail sending operation. It demonstrates how to process the results, including server errors and general lwIP errors. ```c void my_smtp_result_fn(void *arg, u8_t smtp_result, u16_t srv_err, err_t err) { printf("mail (%p) sent with results: 0x%02x, 0x%04x, 0x%08x\n", arg, smtp_result, srv_err, err); } ``` -------------------------------- ### MQTT Callback and Data Handling API Source: https://www.nongnu.org/lwip/2_1_x/mqtt_8h Functions for setting up callbacks for incoming messages and data. ```APIDOC ## MQTT Callback and Data Handling API ### Description Defines mechanisms for handling incoming MQTT messages and connection events through callback functions. ### Typedefs #### `mqtt_connection_cb_t` Callback function type for MQTT connection status changes. - **Signature**: `void (*mqtt_connection_cb_t)(mqtt_client_t *client, void *arg, mqtt_connection_status_t status)` #### `mqtt_incoming_data_cb_t` Callback function type for receiving incoming MQTT message data. - **Signature**: `void (*mqtt_incoming_data_cb_t)(void *arg, const u8_t *data, u16_t len, u8_t flags)` #### `mqtt_incoming_publish_cb_t` Callback function type for receiving MQTT publish notifications (topic and total length). - **Signature**: `void (*mqtt_incoming_publish_cb_t)(void *arg, const char *topic, u32_t tot_len)` #### `mqtt_request_cb_t` Callback function type for MQTT operations like subscribe, unsubscribe, and publish. - **Signature**: `void (*mqtt_request_cb_t)(void *arg, err_t err)` ### Functions #### `mqtt_set_inpub_callback` Sets the callback functions for handling incoming published messages. - **Parameters**: - `client` (mqtt_client_t *): The MQTT client instance. - `pub_cb` (mqtt_incoming_publish_cb_t): Callback for receiving publish notifications. - `data_cb` (mqtt_incoming_data_cb_t): Callback for receiving message payload data. - `arg` (void *): User-defined argument passed to both callbacks. ``` -------------------------------- ### netif_set_link_up Source: https://www.nongnu.org/lwip/2_1_x/group__netif Notifies the system that a network interface's link has come up. ```APIDOC ## netif_set_link_up ### Description This function is intended to be called by a network driver when its physical link status transitions to up. ### Method N/A (Function Signature) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (void) This function does not return a value. #### Response Example N/A ``` -------------------------------- ### lwIP Data Structures and Macros Example (C) Source: https://www.nongnu.org/lwip/2_1_x/igmp_8h This C code snippet demonstrates the inclusion of necessary lwIP headers for IP address and network interface manipulation. It also defines an example data structure 'igmp_group' and a macro 'netif_igmp_data' for accessing client data associated with a network interface, commonly used in IGMP implementations. ```c #include "lwip/opt.h" #include "lwip/ip_addr.h" #include "lwip/netif.h" #include "lwip/pbuf.h" ## Data Structures --- struct | igmp_group ## Macros --- #define | netif_igmp_data(netif) ((struct igmp_group *)netif_get_client_data(netif, LWIP_NETIF_CLIENT_DATA_INDEX_IGMP)) ``` -------------------------------- ### pbuf_take_at() Source: https://www.nongnu.org/lwip/2_1_x/group__pbuf Similar to `pbuf_take`, but copies data into the pbuf starting at a specified offset. ```APIDOC ## pbuf_take_at() ### Description This function is analogous to `pbuf_take()`, but it allows copying data from `dataptr` (with length `len`) into the pbuf (`buf`) starting at a specified `offset`. ### Method N/A (This is a function, not an HTTP endpoint) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) - **return_value** (err_t) - ERR_OK if the copy was successful. ERR_MEM if the pbuf is not large enough or the offset is invalid. #### Response Example N/A ``` -------------------------------- ### Initialize SNMP Agent Source: https://www.nongnu.org/lwip/2_1_x/group__snmp Initializes and starts the SNMP agent. This function should be called after all necessary configurations, such as setting trap destinations and system information, have been made. ```c snmp_init(); ``` -------------------------------- ### tcp_init() Source: https://www.nongnu.org/lwip/2_1_x/tcp_8c Initializes the TCP module. ```APIDOC ## tcp_init() ### Description Initializes this module. ### Method (Not applicable, this is a function call) ### Endpoint (Not applicable) ### Parameters None ### Request Example ```c tcp_init(); ``` ### Response None ``` -------------------------------- ### iPerf Client/Server Functions Source: https://www.nongnu.org/lwip/2_1_x/group__iperf Functions to start and abort TCP client and server sessions for performance measurement. ```APIDOC ## lwiperf_start_tcp_server_default() ### Description Starts a default TCP iperf server. ### Method void * ### Endpoint N/A (Library function) ### Parameters #### Arguments - **report_fn** (lwiperf_report_fn) - Callback function to report results. - **report_arg** (void *) - User-defined argument for the report function. ### Response #### Success Response - Returns a handle to the iperf session, or NULL on failure. ### Response Example ``` void* session_handle = lwiperf_start_tcp_server_default(my_report_function, my_report_argument); ``` ## lwiperf_start_tcp_server() ### Description Starts a TCP iperf server on a specified IP address and port. ### Method void * ### Endpoint N/A (Library function) ### Parameters #### Arguments - **local_addr** (const ip_addr_t *) - The local IP address to bind the server to. - **local_port** (u16_t) - The local port to bind the server to. - **report_fn** (lwiperf_report_fn) - Callback function to report results. - **report_arg** (void *) - User-defined argument for the report function. ### Response #### Success Response - Returns a handle to the iperf session, or NULL on failure. ### Response Example ``` void* session_handle = lwiperf_start_tcp_server(&ip_addr_any, 12345, my_report_function, my_report_argument); ``` ## lwiperf_start_tcp_client_default() ### Description Starts a default TCP iperf client to connect to the default port (5001). ### Method void * ### Endpoint N/A (Library function) ### Parameters #### Arguments - **remote_addr** (const ip_addr_t *) - The remote IP address of the iperf server. - **report_fn** (lwiperf_report_fn) - Callback function to report results. - **report_arg** (void *) - User-defined argument for the report function. ### Response #### Success Response - Returns a handle to the iperf session, or NULL on failure. ### Response Example ``` void* session_handle = lwiperf_start_tcp_client_default(&server_ip_address, my_report_function, my_report_argument); ``` ## lwiperf_start_tcp_client() ### Description Starts a TCP iperf client to connect to a specific IP address and port. ### Method void * ### Endpoint N/A (Library function) ### Parameters #### Arguments - **remote_addr** (const ip_addr_t *) - The remote IP address of the iperf server. - **remote_port** (u16_t) - The remote port of the iperf server. - **type** (enum lwiperf_client_type) - The type of client connection (e.g., STREAM, DATAGRAM). - **report_fn** (lwiperf_report_fn) - Callback function to report results. - **report_arg** (void *) - User-defined argument for the report function. ### Response #### Success Response - Returns a handle to the iperf session, or NULL on failure. ### Response Example ``` void* session_handle = lwiperf_start_tcp_client(&server_ip_address, 5001, LWIPERF_CLIENT_TYPE_TCP, my_report_function, my_report_argument); ``` ## lwiperf_abort() ### Description Aborts an ongoing iperf session. ### Method void ### Endpoint N/A (Library function) ### Parameters #### Arguments - **lwiperf_session** (void *) - The handle to the iperf session to abort, obtained from a `lwiperf_start_*` function. ### Response #### Success Response - No return value. ### Response Example ``` lwiperf_abort(session_handle); ``` ``` -------------------------------- ### TCP Connection Setup Functions Source: https://www.nongnu.org/lwip/2_1_x/group__tcp__raw Functions used for creating new TCP connections, binding them to local addresses, listening for incoming connections, accepting connections, and establishing explicit connections to remote hosts. ```APIDOC ## TCP connection setup The functions used for setting up connections is similar to that of the sequential API and of the BSD socket API. A new TCP connection identifier (i.e., a protocol control block - PCB) is created with the `tcp_new()` function. This PCB can then be either set to listen for new incoming connections or be explicitly connected to another host. ### Functions - `tcp_new()`: Creates a new TCP protocol control block (PCB). - `tcp_bind()`: Binds a TCP PCB to a local IP address and port. - `tcp_listen()`: Sets a TCP PCB to listen for incoming connections. - `tcp_listen_with_backlog()`: Sets a TCP PCB to listen for incoming connections with a specified backlog. - `tcp_accept()`: Specifies the callback function to be called when a listening connection is established. - `tcp_connect()`: Explicitly connects a TCP PCB to a remote host and port. ``` -------------------------------- ### AutoIP API Functions Source: https://www.nongnu.org/lwip/2_1_x/autoip_8c Provides functions for starting, stopping, and managing the AutoIP configuration for a network interface. ```APIDOC ## AUTOIP API Functions ### Description This section details the functions available for interacting with the AutoIP module, allowing for automatic IP address configuration on a local network segment. ### Functions - **autoip_set_struct** - **Description:** Sets the AutoIP structure for a given network interface. - **Parameters:** - `netif` (struct netif *) - The network interface to configure. - `autoip` (struct autoip *) - Pointer to the AutoIP state structure. - **Return Value:** None - **autoip_start** - **Description:** Starts the AutoIP process for the specified network interface. - **Parameters:** - `netif` (struct netif *) - The network interface to start AutoIP on. - **Return Value:** `err_t` - Error code indicating success or failure. - **autoip_network_changed** - **Description:** Notifies the AutoIP module that the network has changed, potentially requiring reconfiguration. - **Parameters:** - `netif` (struct netif *) - The network interface that has experienced a network change. - **Return Value:** None - **autoip_stop** - **Description:** Stops the AutoIP process for the specified network interface. - **Parameters:** - `netif` (struct netif *) - The network interface to stop AutoIP on. - **Return Value:** `err_t` - Error code indicating success or failure. - **autoip_tmr** - **Description:** Timer function for AutoIP. Should be called periodically. - **Parameters:** None - **Return Value:** None - **autoip_arp_reply** - **Description:** Handles incoming ARP replies relevant to AutoIP. - **Parameters:** - `netif` (struct netif *) - The network interface receiving the ARP reply. - `hdr` (struct etharp_hdr *) - Pointer to the ARP header. - **Return Value:** None - **autoip_supplied_address** - **Description:** Checks if an IP address has been automatically supplied by AutoIP for the given network interface. - **Parameters:** - `netif` (const struct netif *) - The network interface to check. - **Return Value:** `u8_t` - 1 if an address is supplied, 0 otherwise. ``` -------------------------------- ### PPP Control Block and Netif Initialization (C) Source: https://www.nongnu.org/lwip/2_1_x/group__ppp Demonstrates the initialization of the PPP control block and the PPP network interface structure, essential for setting up PPP connections within the lwIP stack. This code is intended for use in systems with NO_SYS=1 or when called from the lwIP core thread in NO_SYS=0 systems. ```c /* * Globals * ======= */ /* The PPP control block */ ppp_pcb *ppp; /* The PPP IP interface */ struct netif ppp_netif; ``` -------------------------------- ### ip4_addr_netmask_valid Source: https://www.nongnu.org/lwip/2_1_x/ip4__addr_8h Checks if a given IPv4 netmask is valid, meaning it starts with a sequence of ones followed by only zeros. ```APIDOC ## ip4_addr_netmask_valid() ### Description Checks if a netmask is valid (starting with ones, then only zeros). ### Method GET (Conceptual - this is a function, not an HTTP endpoint) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c // Example usage (conceptual) u32_t netmask = ...; // in network byte order if (ip4_addr_netmask_valid(netmask)) { // Netmask is valid } ``` ### Response #### Success Response (Return Value) - **u8_t** - Returns 1 if the netmask is valid, 0 if it is not. #### Response Example ```json // Return value indicates validity 1 // Netmask is valid 0 // Netmask is invalid ``` ``` -------------------------------- ### IGMP Initialization and Group Management (C) Source: https://www.nongnu.org/lwip/2_1_x/igmp_8c Provides functions for initializing the IGMP module, starting and stopping IGMP on a network interface, reporting multicast groups, looking up groups, and joining/leaving multicast groups. It also includes a timer function for IGMP. ```c #include "lwip/opt.h" #include "lwip/igmp.h" #include "lwip/debug.h" #include "lwip/def.h" #include "lwip/mem.h" #include "lwip/ip.h" #include "lwip/inet_chksum.h" #include "lwip/netif.h" #include "lwip/stats.h" #include "lwip/prot/igmp.h" #include // Initialize the IGMP module void igmp_init(void); // Start IGMP on a network interface err_t igmp_start(struct netif *netif); // Stop IGMP on a network interface err_t igmp_stop(struct netif *netif); // Report multicast groups for a network interface void igmp_report_groups(struct netif *netif); // Look for a specific IGMP group on a network interface struct igmp_group *igmp_lookfor_group(struct netif *ifp, const ip4_addr_t *addr); // Join a multicast group err_t igmp_joingroup(const ip4_addr_t *ifaddr, const ip4_addr_t *groupaddr); // Join a multicast group on a specific network interface err_t igmp_joingroup_netif(struct netif *netif, const ip4_addr_t *groupaddr); // Leave a multicast group err_t igmp_leavegroup(const ip4_addr_t *ifaddr, const ip4_addr_t *groupaddr); // Leave a multicast group on a specific network interface err_t igmp_leavegroup_netif(struct netif *netif, const ip4_addr_t *groupaddr); // IGMP timer function void igmp_tmr(void); ``` -------------------------------- ### pbuf_memfind() Source: https://www.nongnu.org/lwip/2_1_x/group__pbuf Finds an occurrence of a memory block within a pbuf, starting from a specified offset. Returns the index of the occurrence or 0xFFFF if not found. ```APIDOC ## pbuf_memfind() ### Description Finds an occurrence of a memory block (`mem`) with a given length (`mem_len`) within a pbuf (`p`), starting the search from `start_offset`. ### Method N/A (This is a function, not an HTTP endpoint) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) - **return_value** (u16_t) - The index where the memory was found, or 0xFFFF if not found. #### Response Example N/A ``` -------------------------------- ### Socket API - Options and Control Source: https://www.nongnu.org/lwip/2_1_x/group__if__api Functions for setting and getting socket options, and controlling socket behavior. ```APIDOC ## POST /setsockopt ### Description Sets socket options. ### Method POST ### Endpoint `/setsockopt` ### Parameters #### Request Body - **socket_descriptor** (int) - Required - The socket descriptor. - **level** (int) - Required - The level at which the option is supported. - **optname** (int) - Required - The name of the option. - **optval** (void *) - Required - A pointer to the buffer containing the option value. - **optlen** (socklen_t) - Required - The length of the option value buffer. ### Response #### Success Response (200) - **status** (int) - 0 on success, -1 on error. #### Response Example ```json { "status": 0 } ``` ## POST /getsockopt ### Description Gets socket options. ### Method POST ### Endpoint `/getsockopt` ### Parameters #### Request Body - **socket_descriptor** (int) - Required - The socket descriptor. - **level** (int) - Required - The level at which the option is supported. - **optname** (int) - Required - The name of the option. - **optlen** (socklen_t) - Required - The length of the buffer for the option value. ### Response #### Success Response (200) - **optval** (void *) - A pointer to the buffer containing the option value. - **optlen** (socklen_t) - The actual length of the option value returned. #### Response Example ```json { "optval": "...", "optlen": 4 } ``` ## POST /fcntl ### Description Manipulates the properties of a file descriptor. ### Method POST ### Endpoint `/fcntl` ### Parameters #### Request Body - **socket_descriptor** (int) - Required - The socket descriptor. - **cmd** (int) - Required - The command to perform. - **arg** (void *) - Optional - Argument for the command. ### Response #### Success Response (200) - **return_value** (int) - The return value of the fcntl operation. #### Response Example ```json { "return_value": 0 } ``` ## POST /ioctl ### Description Performs I/O control operations on a socket. ### Method POST ### Endpoint `/ioctl` ### Parameters #### Request Body - **socket_descriptor** (int) - Required - The socket descriptor. - **cmd** (int) - Required - The I/O control command. - **arg** (void *) - Optional - Argument for the command. ### Response #### Success Response (200) - **return_value** (int) - The return value of the ioctl operation. #### Response Example ```json { "return_value": 0 } ``` ## POST /ioctlsocket ### Description Performs I/O control operations on a socket. This is an alias for ioctl() for POSIX compatibility. ### Method POST ### Endpoint `/ioctlsocket` ### Parameters #### Request Body - **socket_descriptor** (int) - Required - The socket descriptor. - **cmd** (int) - Required - The I/O control command. - **arg** (void *) - Optional - Argument for the command. ### Response #### Success Response (200) - **return_value** (int) - The return value of the ioctlsocket operation. #### Response Example ```json { "return_value": 0 } ``` ## POST /shutdown ### Description Disables further send and/or receive operations on a socket. ### Method POST ### Endpoint `/shutdown` ### Parameters #### Request Body - **socket_descriptor** (int) - Required - The socket descriptor. - **how** (int) - Required - Specifies what to shut down (e.g., SHUT_RD, SHUT_WR, SHUT_RDWR). ### Response #### Success Response (200) - **status** (int) - 0 on success, -1 on error. #### Response Example ```json { "status": 0 } ``` ```