---
name: "coap_lwip"
section: "3"
platform: "linux"
package: "libcoap3t64"
version: "4.3.4-1.1+deb13u3"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/coap_lwip"
---

# coap\_lwip(3)

Work with CoAP lwip specific API handler

## NAME

coap\_lwip, coap\_lwip\_dump\_memory\_pools, coap\_lwip\_set\_input\_wait\_handler - Work with CoAP lwip specific API handler

## SYNOPSIS

**#include \<coap3/coap.h\>**

**void coap\_lwip\_set\_input\_wait\_handler(coap\_context\_t \****context***, coap\_lwip\_input\_wait\_handler\_t** *handler***, void \****input\_arg***);**

**void coap\_lwip\_dump\_memory\_pools(coap\_log\_t** *log\_level***);**

## DESCRIPTION

This man page describes the additional libcoap functions that are available for working with LwIP implementations.

**NOTE:** If the following line is defined in lwipopts.h, then libcoap will reserve space for one response PDU when allocating coap\_pdu\_t structures.

```
#define MEMP_STATS 1
```

## CALLBACK HANDLER

**Callback Type: coap\_lwip\_input\_wait\_handler\_t**

```
/**
 * LwIP callback handler that can be used to wait / timeout for the
 * next input packet.
 *
 * @param arg The argument passed to the coap_lwip_set_input_wait_handler()
 *            function.
 * @param milli_secs Suggested number of milli secs to wait before returning
 *                   if no input.
 *
 * @return @c 1 if packet received, @c 0 for timeout, else @c -1 on error.
 */
typedef int (*coap_lwip_input_wait_handler_t)(void* arg, uint32_t milli_secs);
```

## FUNCTIONS

**Function: coap\_lwip\_set\_input\_wait\_handler()**

The **coap\_lwip\_set\_input\_wait\_handler**() function is used to define a callback *handler* that is invoked by [**coap\_io\_process**(3)](/coap_io_process/3.md) which passes in the *input\_arg* parameter along with a suggested milli-sec wait time parameter in case there is no input. This callback *handler* is used to wait for (and probably times out) the next input packet. This allows the application to define whatever mechanism it wants use for this process.

**Function: coap\_lwip\_dump\_memory\_pools()**

The **coap\_lwip\_dump\_memory\_pools**() function is used to dump out the current state of the LwIP memory pools at logging level *log\_level*.

This function is always invoked by [**coap\_free\_context**(3)](/coap_free_context/3.md) with a *log\_level* of COAP\_LOG\_DEBUG.

**NOTE:** For information to be printed out, you need the following two lines in lwipopts.h

```
#define MEMP_STATS         1
#define LWIP_STATS_DISPLAY 1
```

## SEE ALSO

[**coap\_context**(3)](/coap_context/3.md) and [**coap\_io**(3)](/coap_io/3.md)

## FURTHER INFORMATION

See

"RFC7252: The Constrained Application Protocol (CoAP)"

for further information.

## BUGS

Please report bugs on the mailing list for libcoap: libcoap-developers@lists.sourceforge.net or raise an issue on GitHub at https://github.com/obgm/libcoap/issues

## AUTHORS

The libcoap project \<libcoap-developers@lists.sourceforge.net\>
