Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions config.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@

#define ETHERNET
#define LINK_MTU 1536
#ifndef LINK_MTU_MIN
#define LINK_MTU_MIN 64U
#endif
#if LINK_MTU < LINK_MTU_MIN
#error "LINK_MTU must be greater than or equal to LINK_MTU_MIN"
#endif

#define MAX_TCPSOCKETS 4
#define MAX_UDPSOCKETS 2
Expand Down
7 changes: 7 additions & 0 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ struct wolfIP_ll_dev {
uint8_t mac[6]; // Device MAC address
char ifname[16]; // Interface name
uint8_t non_ethernet; // L3-only link (no Ethernet header/ARP when set)
uint32_t mtu; // Optional internal frame budget, defaults to LINK_MTU
int (*poll)(struct wolfIP_ll_dev *ll, void *buf, uint32_t len); // Receive function
int (*send)(struct wolfIP_ll_dev *ll, void *buf, uint32_t len); // Transmit function
};
```
wolfIP maintains an array of these descriptors sized by `WOLFIP_MAX_INTERFACES` (default `1`). Call `wolfIP_getdev_ex()` to access a specific slot; the legacy `wolfIP_getdev()` helper targets the first hardware slot (index `0` normally, or `1` when the optional loopback interface is enabled).

When `non_ethernet` is set, the interface is treated as L3-only point-to-point: the stack skips ARP/neighbor resolution, omits Ethernet headers on transmit, and expects receive buffers to begin at the IP header.
The `mtu` field still describes wolfIP's internal frame budget including Ethernet headroom, so on non-Ethernet links the payload passed to `ll->send()` is effectively capped at `mtu - ETH_HEADER_LEN` on Ethernet-enabled builds.

### IP Configuration
```c
Expand Down Expand Up @@ -203,8 +205,13 @@ Per-interface versions of the IP configuration helpers. The legacy functions tar
```c
struct wolfIP_ll_dev *wolfIP_getdev(struct wolfIP *s);
struct wolfIP_ll_dev *wolfIP_getdev_ex(struct wolfIP *s, unsigned int if_idx);
int wolfIP_mtu_set(struct wolfIP *s, unsigned int if_idx, uint32_t mtu);
int wolfIP_mtu_get(struct wolfIP *s, unsigned int if_idx, uint32_t *mtu);
```
Access the link-layer descriptor(s) that should be wired to hardware drivers. `_ex` returns `NULL` if `if_idx` exceeds `WOLFIP_MAX_INTERFACES`.
`wolfIP_mtu_set()` updates the effective per-interface MTU, treating `0` as the default `LINK_MTU` and clamping to `[LINK_MTU_MIN, LINK_MTU]`. `wolfIP_mtu_get()` returns the effective MTU currently used by the stack.
For `non_ethernet` devices this value remains the internal frame budget; the maximum IP bytes handed to the driver are reduced by `ETH_HEADER_LEN` when Ethernet support is compiled in.
- Returns: `wolfIP_getdev()`/`wolfIP_getdev_ex()` return a pointer to the link-layer descriptor or `NULL` on invalid interface index; `wolfIP_mtu_set()` returns `0` on success or a negative error code on failure; `wolfIP_mtu_get()` returns `0` on success or a negative error code on failure and stores the effective MTU in `*mtu`.

## DHCP Client Functions

Expand Down
Loading
Loading