You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/API.md
+36-4Lines changed: 36 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,23 +23,32 @@ wolfIP is a minimal TCP/IP stack designed for resource-constrained embedded syst
23
23
24
24
### Device Driver Interface
25
25
```c
26
-
structll {
26
+
structwolfIP_ll_dev {
27
27
uint8_t mac[6]; // Device MAC address
28
28
char ifname[16]; // Interface name
29
-
int (*poll)(struct ll*ll, void *buf, uint32_t len); // Receive function
30
-
int (*send)(struct ll*ll, void *buf, uint32_t len); // Transmit function
29
+
int (*poll)(struct wolfIP_ll_dev*ll, void *buf, uint32_t len); // Receive function
30
+
int (*send)(struct wolfIP_ll_dev*ll, void *buf, uint32_t len); // Transmit function
31
31
};
32
32
```
33
+
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).
33
34
34
35
### IP Configuration
35
36
```c
36
37
struct ipconf {
37
-
struct ll *ll; // Link layer device
38
+
struct wolfIP_ll_dev *ll; // Link layer device
38
39
ip4 ip; // IPv4 address
39
40
ip4 mask; // Subnet mask
40
41
ip4 gw; // Default gateway
41
42
};
42
43
```
44
+
Each `struct wolfIP` instance owns `WOLFIP_MAX_INTERFACES``ipconf` entries—one per link-layer slot. Use the `_ex` helpers to read or update a specific interface; the legacy accessors operate on the first hardware interface (index `0` unless loopback support is compiled in).
45
+
46
+
If `WOLFIP_ENABLE_FORWARDING` is set to `1` at compile time, the stack performs simple IPv4 forwarding between interfaces. Packets received on one interface whose destinations match another configured interface are re-sent with the IP TTL decreased by one (or an ICMP TTL-exceeded response if the TTL would drop to zero).
47
+
48
+
Enabling `WOLFIP_ENABLE_LOOPBACK` (requires `WOLFIP_MAX_INTERFACES > 1`) creates an internal loopback
49
+
device at index `0` with the fixed address `127.0.0.1/8`. Traffic sent to that address is reflected back
50
+
through the stack so local sockets, pings, and other services behave as they would on a standard
51
+
loopback interface; the first hardware interface then shifts to index `1` for legacy helpers.
43
52
44
53
### Socket Address Structures
45
54
```c
@@ -151,6 +160,11 @@ Initializes a static wolfIP instance.
151
160
- Parameters:
152
161
- s: Pointer to wolfIP instance pointer
153
162
163
+
```c
164
+
size_t wolfIP_instance_size(void);
165
+
```
166
+
Returns the size (in bytes) required to store a `struct wolfIP`. Use this when allocating stacks from custom memory managers.
0 commit comments