net.h
Go to the documentation of this file.
1 /**
2  * @file net.h
3  * @brief TCP/IP stack core
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2025 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneTCP Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 2.5.0
29  **/
30 
31 #ifndef _NET_H
32 #define _NET_H
33 
34 //Forward declaration of NetInterface structure
35 struct _NetInterface;
36 #define NetInterface struct _NetInterface
37 
38 //Dependencies
39 #include "os_port.h"
40 #include "net_config.h"
41 #include "core/net_legacy.h"
42 #include "core/net_mem.h"
43 #include "core/net_misc.h"
44 #include "core/nic.h"
45 #include "core/ethernet.h"
46 #include "ipv4/ipv4.h"
47 #include "ipv4/ipv4_frag.h"
48 #include "ipv4/auto_ip.h"
49 #include "ipv6/ipv6.h"
50 #include "ipv4/arp.h"
51 #include "igmp/igmp_host.h"
52 #include "igmp/igmp_router.h"
53 #include "igmp/igmp_snooping.h"
54 #include "dhcp/dhcp_client.h"
55 #include "dhcp/dhcp_server.h"
56 #include "nat/nat.h"
57 #include "ipv6/ndp.h"
58 #include "ipv6/ndp_router_adv.h"
59 #include "ipv6/slaac.h"
60 #include "mld/mld_node.h"
61 #include "dhcpv6/dhcpv6_client.h"
62 #include "dns/dns_client.h"
63 #include "mdns/mdns_responder.h"
64 #include "mdns/mdns_common.h"
66 #include "ppp/ppp.h"
67 #include "cpu_endian.h"
68 #include "error.h"
69 
70 
71 /*
72  * CycloneTCP Open is licensed under GPL version 2. In particular:
73  *
74  * - If you link your program to CycloneTCP Open, the result is a derivative
75  * work that can only be distributed under the same GPL license terms.
76  *
77  * - If additions or changes to CycloneTCP Open are made, the result is a
78  * derivative work that can only be distributed under the same license terms.
79  *
80  * - The GPL license requires that you make the source code available to
81  * whoever you make the binary available to.
82  *
83  * - If you sell or distribute a hardware product that runs CycloneTCP Open,
84  * the GPL license requires you to provide public and full access to all
85  * source code on a nondiscriminatory basis.
86  *
87  * If you fully understand and accept the terms of the GPL license, then edit
88  * the os_port_config.h header and add the following directive:
89  *
90  * #define GPL_LICENSE_TERMS_ACCEPTED
91  */
92 
93 #ifndef GPL_LICENSE_TERMS_ACCEPTED
94  #error Before compiling CycloneTCP Open, you must accept the terms of the GPL license
95 #endif
96 
97 //Version string
98 #define CYCLONE_TCP_VERSION_STRING "2.5.0"
99 //Major version
100 #define CYCLONE_TCP_MAJOR_VERSION 2
101 //Minor version
102 #define CYCLONE_TCP_MINOR_VERSION 5
103 //Revision number
104 #define CYCLONE_TCP_REV_NUMBER 0
105 
106 //RTOS support
107 #ifndef NET_RTOS_SUPPORT
108  #define NET_RTOS_SUPPORT ENABLED
109 #elif (NET_RTOS_SUPPORT != ENABLED && NET_RTOS_SUPPORT != DISABLED)
110  #error NET_RTOS_SUPPORT parameter is not valid
111 #endif
112 
113 //Number of network adapters
114 #ifndef NET_INTERFACE_COUNT
115  #define NET_INTERFACE_COUNT 1
116 #elif (NET_INTERFACE_COUNT < 1)
117  #error NET_INTERFACE_COUNT parameter is not valid
118 #endif
119 
120 //Loopback interface support
121 #ifndef NET_LOOPBACK_IF_SUPPORT
122  #define NET_LOOPBACK_IF_SUPPORT DISABLED
123 #elif (NET_LOOPBACK_IF_SUPPORT != ENABLED && NET_LOOPBACK_IF_SUPPORT != DISABLED)
124  #error NET_LOOPBACK_IF_SUPPORT parameter is not valid
125 #endif
126 
127 //Maximum number of link change callback functions that can be registered
128 #ifndef NET_MAX_LINK_CHANGE_CALLBACKS
129  #define NET_MAX_LINK_CHANGE_CALLBACKS (6 * NET_INTERFACE_COUNT)
130 #elif (NET_MAX_LINK_CHANGE_CALLBACKS < 1)
131  #error NET_MAX_LINK_CHANGE_CALLBACKS parameter is not valid
132 #endif
133 
134 //Maximum number of timer callback functions that can be registered
135 #ifndef NET_MAX_TIMER_CALLBACKS
136  #define NET_MAX_TIMER_CALLBACKS (6 * NET_INTERFACE_COUNT)
137 #elif (NET_MAX_TIMER_CALLBACKS < 1)
138  #error NET_MAX_TIMER_CALLBACKS parameter is not valid
139 #endif
140 
141 //Maximum length of interface name
142 #ifndef NET_MAX_IF_NAME_LEN
143  #define NET_MAX_IF_NAME_LEN 8
144 #elif (NET_MAX_IF_NAME_LEN < 1)
145  #error NET_MAX_IF_NAME_LEN parameter is not valid
146 #endif
147 
148 //Maximum length of host name
149 #ifndef NET_MAX_HOSTNAME_LEN
150  #define NET_MAX_HOSTNAME_LEN 24
151 #elif (NET_MAX_HOSTNAME_LEN < 1)
152  #error NET_MAX_HOSTNAME_LEN parameter is not valid
153 #endif
154 
155 //Size of the seed
156 #ifndef NET_RAND_SEED_SIZE
157  #define NET_RAND_SEED_SIZE 16
158 #elif (NET_RAND_SEED_SIZE < 10)
159  #error NET_RAND_SEED_SIZE parameter is not valid
160 #endif
161 
162 //Stack size required to run the TCP/IP task
163 #ifndef NET_TASK_STACK_SIZE
164  #define NET_TASK_STACK_SIZE 650
165 #elif (NET_TASK_STACK_SIZE < 1)
166  #error NET_TASK_STACK_SIZE parameter is not valid
167 #endif
168 
169 //Priority at which the TCP/IP task should run
170 #ifndef NET_TASK_PRIORITY
171  #define NET_TASK_PRIORITY OS_TASK_PRIORITY_HIGH
172 #endif
173 
174 //TCP/IP stack tick interval
175 #ifndef NET_TICK_INTERVAL
176  #define NET_TICK_INTERVAL 100
177 #elif (NET_TICK_INTERVAL < 10)
178  #error NET_TICK_INTERVAL parameter is not valid
179 #endif
180 
181 //Get system tick count
182 #ifndef netGetSystemTickCount
183  #define netGetSystemTickCount() osGetSystemTime()
184 #endif
185 
186 //C++ guard
187 #ifdef __cplusplus
188 extern "C" {
189 #endif
190 
191 
192 /**
193  * @brief Structure describing a network interface
194  **/
195 
197 {
198  uint_t index; ///<Zero-based index
199  uint32_t id; ///<A unique number identifying the interface
200  Eui64 eui64; ///<EUI-64 interface identifier
201  char_t name[NET_MAX_IF_NAME_LEN + 1]; ///<A unique name identifying the interface
203  const NicDriver *nicDriver; ///<NIC driver
204  const SpiDriver *spiDriver; ///<Underlying SPI driver
205  const UartDriver *uartDriver; ///<Underlying UART driver
206  const ExtIntDriver *extIntDriver; ///<External interrupt line driver
207  uint8_t nicContext[NIC_CONTEXT_SIZE]; ///<Driver specific context
208  OsEvent nicTxEvent; ///<Network controller TX event
209  bool_t nicEvent; ///<A NIC event is pending
210  NicLinkState adminLinkState; ///<Administrative link state
211  bool_t linkState; ///<Link state
212  uint32_t linkSpeed; ///<Link speed
213  NicDuplexMode duplexMode; ///<Duplex mode
214  bool_t configured; ///<Configuration done
215  systime_t initialRto; ///<TCP initial retransmission timeout
216 
217 #if (ETH_SUPPORT == ENABLED)
218  const PhyDriver *phyDriver; ///<Ethernet PHY driver
219  uint8_t phyAddr; ///<PHY address
220  bool_t phyEvent; ///<A PHY event is pending
221  const SwitchDriver *switchDriver; ///<Ethernet switch driver
222  const SmiDriver *smiDriver; ///<SMI driver
223  MacAddr macAddr; ///<Link-layer address
225  bool_t promiscuous; ///<Promiscuous mode
226  bool_t acceptAllMulticast; ///<Accept all frames with a multicast destination address
227 #endif
228 #if (ETH_VLAN_SUPPORT == ENABLED)
229  uint16_t vlanId; ///<VLAN identifier (802.1Q)
230 #endif
231 #if (ETH_VMAN_SUPPORT == ENABLED)
232  uint16_t vmanId; ///<VMAN identifier (802.1ad)
233 #endif
234 #if (ETH_LLC_SUPPORT == ENABLED)
235  LlcRxCallback llcRxCallback; ///<LLC frame received callback (802.2)
236  void *llcRxParam; ///<Callback parameter
237 #endif
238 #if (ETH_PORT_TAGGING_SUPPORT == ENABLED)
239  uint8_t port; ///<Switch port identifier
240 #endif
241 #if (ETH_VIRTUAL_IF_SUPPORT == ENABLED || ETH_VLAN_SUPPORT == ENABLED || \
242  ETH_PORT_TAGGING_SUPPORT == ENABLED)
243  NetInterface *parent; ///<Interface on top of which the virtual interface runs
244 #endif
245 
246 #if (IPV4_SUPPORT == ENABLED)
247  Ipv4Context ipv4Context; ///<IPv4 context
248 #if (ETH_SUPPORT == ENABLED)
249  bool_t enableArp; ///<Enable address resolution using ARP
250  systime_t arpReachableTime; ///<ARP reachable time
251  systime_t arpProbeTimeout; ///<ARP probe timeout
253 #endif
254 #if (IGMP_HOST_SUPPORT == ENABLED)
255  IgmpHostContext igmpHostContext; ///<IGMP host context
256 #endif
257 #if (IGMP_ROUTER_SUPPORT == ENABLED)
258  IgmpRouterContext *igmpRouterContext; ///<IGMP router context
259 #endif
260 #if (IGMP_SNOOPING_SUPPORT == ENABLED)
261  IgmpSnoopingContext *igmpSnoopingContext; ///<IGMP snooping switch context
262 #endif
263 #if (AUTO_IP_SUPPORT == ENABLED)
264  AutoIpContext *autoIpContext; ///<Auto-IP context
265 #endif
266 #if (DHCP_CLIENT_SUPPORT == ENABLED)
267  DhcpClientContext *dhcpClientContext; ///<DHCP client context
268 #endif
269 #if (DHCP_SERVER_SUPPORT == ENABLED)
270  DhcpServerContext *dhcpServerContext; ///<DHCP server context
271 #endif
272 #endif
273 
274 #if (IPV6_SUPPORT == ENABLED)
275  Ipv6Context ipv6Context; ///<IPv6 context
276 #if (NDP_SUPPORT == ENABLED)
277  NdpContext ndpContext; ///<NDP context
278 #endif
279 #if (NDP_ROUTER_ADV_SUPPORT == ENABLED)
280  NdpRouterAdvContext *ndpRouterAdvContext; ///<RA service context
281 #endif
282 #if (MLD_NODE_SUPPORT == ENABLED)
283  MldNodeContext mldNodeContext; ///<MLD node context
284 #endif
285 #if (SLAAC_SUPPORT == ENABLED)
286  SlaacContext *slaacContext; ///<SLAAC context
287 #endif
288 #if (DHCPV6_CLIENT_SUPPORT == ENABLED)
289  Dhcpv6ClientContext *dhcpv6ClientContext; ///<DHCPv6 client context
290 #endif
291 #endif
292 
293 #if (MDNS_RESPONDER_SUPPORT == ENABLED)
294  MdnsResponderContext *mdnsResponderContext; ///<mDNS responder context
295 #endif
296 
297 #if (DNS_SD_RESPONDER_SUPPORT == ENABLED)
298  DnsSdResponderContext *dnsSdResponderContext; ///<DNS-SD responder context
299 #endif
300 
301 #if (PPP_SUPPORT == ENABLED)
302  PppContext *pppContext; ///<PPP context
303 #endif
304 };
305 
306 
307 /**
308  * @brief TCP/IP stack settings
309  **/
310 
311 typedef struct
312 {
313  OsTaskParameters task; ///<Task parameters
314 } NetSettings;
315 
316 
317 /**
318  * @brief TCP/IP stack context
319  **/
320 
321 typedef struct
322 {
323  OsMutex mutex; ///<Mutex preventing simultaneous access to the TCP/IP stack
324  OsEvent event; ///<Event object to receive notifications from drivers
325  bool_t running; ///<The TCP/IP stack is currently running
326  OsTaskParameters taskParams; ///<Task parameters
327  OsTaskId taskId; ///<Task identifier
328  uint32_t entropy;
330  uint8_t randSeed[NET_RAND_SEED_SIZE]; ///<Random seed
331  NetRandState randState; ///<Pseudo-random number generator state
332  NetInterface interfaces[NET_INTERFACE_COUNT]; ///<Network interfaces
335 #if (NAT_SUPPORT == ENABLED)
336  NatContext *natContext; ///<NAT context
337 #endif
338 #if (IPV4_IPSEC_SUPPORT == ENABLED)
339  void *ipsecContext; ///<IPsec context
340  void *ikeContext; ///<IKE context
341 #endif
342 } NetContext;
343 
344 
345 //Global variables
346 extern NetContext netContext;
347 
348 //TCP/IP stack related functions
349 void netGetDefaultSettings(NetSettings *settings);
350 error_t netInit(void);
351 error_t netInitEx(NetContext *context, const NetSettings *settings);
352 
353 error_t netStart(NetContext *context);
354 
355 error_t netSeedRand(const uint8_t *seed, size_t length);
356 uint32_t netGetRand(void);
357 uint32_t netGetRandRange(uint32_t min, uint32_t max);
358 void netGetRandData(uint8_t *data, size_t length);
359 
361 
362 error_t netSetMacAddr(NetInterface *interface, const MacAddr *macAddr);
363 error_t netGetMacAddr(NetInterface *interface, MacAddr *macAddr);
364 
365 error_t netSetEui64(NetInterface *interface, const Eui64 *eui64);
366 error_t netGetEui64(NetInterface *interface, Eui64 *eui64);
367 
368 error_t netSetInterfaceId(NetInterface *interface, uint32_t id);
370 error_t netSetHostname(NetInterface *interface, const char_t *name);
371 
372 error_t netSetVlanId(NetInterface *interface, uint16_t vlanId);
373 error_t netSetVmanId(NetInterface *interface, uint16_t vmanId);
374 
376  NetInterface *physicalInterface);
377 
378 error_t netSetDriver(NetInterface *interface, const NicDriver *driver);
379 
380 error_t netSetPhyDriver(NetInterface *interface, const PhyDriver *driver);
381 error_t netSetPhyAddr(NetInterface *interface, uint8_t phyAddr);
382 
383 error_t netSetSwitchDriver(NetInterface *interface, const SwitchDriver *driver);
384 error_t netSetSwitchPort(NetInterface *interface, uint8_t port);
385 
386 error_t netSetSmiDriver(NetInterface *interface, const SmiDriver *driver);
387 error_t netSetSpiDriver(NetInterface *interface, const SpiDriver *driver);
388 error_t netSetUartDriver(NetInterface *interface, const UartDriver *driver);
389 error_t netSetExtIntDriver(NetInterface *interface, const ExtIntDriver *driver);
390 
391 error_t netSetLinkState(NetInterface *interface, bool_t linkState);
393 
396 
398 
402 
403 void netTask(void);
404 void netTaskEx(NetContext *context);
405 
406 //C++ guard
407 #ifdef __cplusplus
408 }
409 #endif
410 
411 #endif
#define MdnsResponderContext
IPv6 (Internet Protocol Version 6)
const NicDriver * nicDriver
NIC driver.
Definition: net.h:203
error_t netSetEui64(NetInterface *interface, const Eui64 *eui64)
Set EUI-64 interface identifier.
Definition: net.c:557
uint32_t netGetRandRange(uint32_t min, uint32_t max)
Generate a random value in the specified range.
Definition: net.c:417
error_t netStartInterface(NetInterface *interface)
Start network interface.
Definition: net.c:1386
error_t netSetExtIntDriver(NetInterface *interface, const ExtIntDriver *driver)
Set external interrupt line driver.
Definition: net.c:1027
MacAddr macAddr
Link-layer address.
Definition: net.h:223
error_t netSetInterfaceName(NetInterface *interface, const char_t *name)
Set interface name.
Definition: net.c:639
int bool_t
Definition: compiler_port.h:61
error_t netSetUartDriver(NetInterface *interface, const UartDriver *driver)
Set UART driver.
Definition: net.c:1002
DhcpServerContext * dhcpServerContext
DHCP server context.
Definition: net.h:270
uint_t netGetLinkSpeed(NetInterface *interface)
Get link speed.
Definition: net.c:1115
void netGetDefaultSettings(NetSettings *settings)
Initialize settings with default values.
Definition: net.c:83
DHCP client (Dynamic Host Configuration Protocol)
error_t netGetEui64(NetInterface *interface, Eui64 *eui64)
Retrieve EUI-64 interface identifier.
Definition: net.c:582
NdpContext ndpContext
NDP context.
Definition: net.h:277
MldNodeContext mldNodeContext
MLD node context.
Definition: net.h:283
Eui64 eui64
EUI-64 interface identifier.
Definition: net.h:200
bool_t running
The TCP/IP stack is currently running.
Definition: net.h:325
error_t netGetMacAddr(NetInterface *interface, MacAddr *macAddr)
Retrieve MAC address.
Definition: net.c:520
MdnsResponderContext * mdnsResponderContext
mDNS responder context
Definition: net.h:294
Eui64
Definition: ethernet.h:210
systime_t timestamp
Definition: net.h:329
error_t netSetParentInterface(NetInterface *interface, NetInterface *physicalInterface)
Attach a virtual interface to a given physical interface.
Definition: net.c:766
error_t netSetSpiDriver(NetInterface *interface, const SpiDriver *driver)
Set SPI driver.
Definition: net.c:977
systime_t arpProbeTimeout
ARP probe timeout.
Definition: net.h:251
Memory management.
uint16_t vlanId
VLAN identifier (802.1Q)
Definition: net.h:229
const UartDriver * uartDriver
Underlying UART driver.
Definition: net.h:205
uint8_t nicContext[NIC_CONTEXT_SIZE]
Driver specific context.
Definition: net.h:207
#define MAC_ADDR_FILTER_SIZE
Definition: ethernet.h:95
Ethernet PHY driver.
Definition: nic.h:311
UART driver.
Definition: nic.h:385
uint8_t data[]
Definition: ethernet.h:222
void netGetRandData(uint8_t *data, size_t length)
Get a string of random data.
Definition: net.c:447
Event object.
uint32_t entropy
Definition: net.h:328
OsMutex mutex
Mutex preventing simultaneous access to the TCP/IP stack.
Definition: net.h:323
External interrupt line driver.
Definition: nic.h:398
#define AutoIpContext
Definition: auto_ip.h:139
error_t netSetSwitchDriver(NetInterface *interface, const SwitchDriver *driver)
Set Ethernet switch driver.
Definition: net.c:887
char_t name[NET_MAX_IF_NAME_LEN+1]
A unique name identifying the interface.
Definition: net.h:201
SMI driver.
Definition: nic.h:357
error_t netStopInterface(NetInterface *interface)
Stop network interface.
Definition: net.c:1466
#define NET_INTERFACE_COUNT
Definition: net.h:115
Legacy definitions.
MLD node context.
Definition: mld_node.h:114
IGMP snooping switch.
char_t name[]
DhcpClientContext * dhcpClientContext
DHCP client context.
Definition: net.h:267
SPI driver.
Definition: nic.h:369
SlaacContext * slaacContext
SLAAC context.
Definition: net.h:286
error_t netSetInterfaceId(NetInterface *interface, uint32_t id)
Set interface identifier.
Definition: net.c:614
NetContext netContext
Definition: net.c:75
error_t netSetMacAddr(NetInterface *interface, const MacAddr *macAddr)
Set MAC address.
Definition: net.c:485
Pseudo-random number generator state.
Definition: net_misc.h:187
#define PppContext
Definition: ppp.h:38
IPv6 Stateless Address Autoconfiguration.
IPv6 context.
Definition: ipv6.h:496
IPv4 context.
Definition: ipv4.h:427
Ethernet.
#define NET_MAX_LINK_CHANGE_CALLBACKS
Definition: net.h:129
#define DhcpClientContext
Definition: dhcp_client.h:145
Router advertisement service.
Definitions common to mDNS client and mDNS responder.
IGMP router.
bool_t phyEvent
A PHY event is pending.
Definition: net.h:220
ArpCacheEntry arpCache[ARP_CACHE_SIZE]
ARP cache.
Definition: net.h:252
error_t netSetVmanId(NetInterface *interface, uint16_t vmanId)
Specify VMAN identifier (802.1ad)
Definition: net.c:731
IgmpRouterContext * igmpRouterContext
IGMP router context.
Definition: net.h:258
IGMP host context.
Definition: igmp_host.h:114
bool_t netGetLinkState(NetInterface *interface)
Get link state.
Definition: net.c:1084
OsTaskParameters taskParams
Task parameters.
Definition: net.h:326
#define NdpRouterAdvContext
#define ARP_CACHE_SIZE
Definition: arp.h:46
error_t netSetPhyAddr(NetInterface *interface, uint8_t phyAddr)
Specify Ethernet PHY address.
Definition: net.c:853
error_t netSetHostname(NetInterface *interface, const char_t *name)
Set host name.
Definition: net.c:668
void(* LlcRxCallback)(NetInterface *interface, EthHeader *header, const uint8_t *data, size_t length, NetRxAncillary *ancillary, void *param)
LLC frame received callback.
Definition: ethernet.h:274
#define SlaacContext
Definition: slaac.h:50
error_t
Error codes.
Definition: error.h:43
bool_t promiscuous
Promiscuous mode.
Definition: net.h:225
bool_t enableArp
Enable address resolution using ARP.
Definition: net.h:249
error_t netStart(NetContext *context)
Start TCP/IP stack.
Definition: net.c:312
NAT context.
Definition: nat.h:192
DNS-SD responder (DNS-Based Service Discovery)
NDP context.
Definition: ndp.h:580
Timer callback entry.
Definition: net_misc.h:92
DHCPv6 client (Dynamic Host Configuration Protocol for IPv6)
error_t netInit(void)
Initialize TCP/IP stack (deprecated)
Definition: net.c:97
NicLinkState
Link state.
Definition: nic.h:97
NetInterface * netGetDefaultInterface(void)
Get default network interface.
Definition: net.c:471
char_t hostname[NET_MAX_HOSTNAME_LEN+1]
Host name.
Definition: net.h:202
IgmpHostContext igmpHostContext
IGMP host context.
Definition: net.h:255
#define NetInterface
Definition: net.h:36
Ipv6Context ipv6Context
IPv6 context.
Definition: net.h:275
OsTaskId taskId
Task identifier.
Definition: net.h:327
#define DnsSdResponderContext
uint8_t port
Switch port identifier.
Definition: net.h:239
#define Dhcpv6ClientContext
uint16_t vmanId
VMAN identifier (802.1ad)
Definition: net.h:232
TCP/IP stack context.
Definition: net.h:322
LlcRxCallback llcRxCallback
LLC frame received callback (802.2)
Definition: net.h:235
Error codes description.
NAT (IP Network Address Translator)
uint_t index
Zero-based index.
Definition: net.h:198
const SwitchDriver * switchDriver
Ethernet switch driver.
Definition: net.h:221
Task parameters.
IGMP host.
uint8_t length
Definition: tcp.h:375
Byte order conversion.
NicLinkState adminLinkState
Administrative link state.
Definition: net.h:210
void * ipsecContext
IPsec context.
Definition: net.h:339
NatContext * natContext
NAT context.
Definition: net.h:336
MacAddr
Definition: ethernet.h:195
#define NIC_CONTEXT_SIZE
Definition: nic.h:53
NDP (Neighbor Discovery Protocol)
DNS client (Domain Name System)
Mutex object.
error_t netSetSmiDriver(NetInterface *interface, const SmiDriver *driver)
Set SMI driver.
Definition: net.c:947
uint32_t systime_t
System time.
uint16_t port
Definition: dns_common.h:267
NdpRouterAdvContext * ndpRouterAdvContext
RA service context.
Definition: net.h:280
#define NET_MAX_TIMER_CALLBACKS
Definition: net.h:136
error_t netSetVlanId(NetInterface *interface, uint16_t vlanId)
Specify VLAN identifier (802.1Q)
Definition: net.c:697
MLD node (Multicast Listener Discovery for IPv6)
error_t netSetPhyDriver(NetInterface *interface, const PhyDriver *driver)
Set Ethernet PHY driver.
Definition: net.c:823
uint32_t netGetRand(void)
Generate a random 32-bit value.
Definition: net.c:386
char char_t
Definition: compiler_port.h:55
AutoIpContext * autoIpContext
Auto-IP context.
Definition: net.h:264
error_t netSetDriver(NetInterface *interface, const NicDriver *driver)
Set Ethernet MAC driver.
Definition: net.c:798
error_t netInitEx(NetContext *context, const NetSettings *settings)
Initialize TCP/IP stack.
Definition: net.c:127
const ExtIntDriver * extIntDriver
External interrupt line driver.
Definition: net.h:206
systime_t initialRto
TCP initial retransmission timeout.
Definition: net.h:215
bool_t linkState
Link state.
Definition: net.h:211
uint32_t linkSpeed
Link speed.
Definition: net.h:212
IPv4 fragmentation and reassembly.
Ethernet switch driver.
Definition: nic.h:325
#define NET_MAX_IF_NAME_LEN
Definition: net.h:143
MAC filter table entry.
Definition: ethernet.h:262
PppContext * pppContext
PPP context.
Definition: net.h:302
Link change callback entry.
Definition: net_misc.h:73
NicDuplexMode
Duplex mode.
Definition: nic.h:122
void netTaskEx(NetContext *context)
TCP/IP events handling.
Definition: net.c:1533
Network interface controller abstraction layer.
const SpiDriver * spiDriver
Underlying SPI driver.
Definition: net.h:204
uint8_t phyAddr
PHY address.
Definition: net.h:219
OsEvent nicTxEvent
Network controller TX event.
Definition: net.h:208
ARP cache entry.
Definition: arp.h:189
void netTask(void)
TCP/IP events handling (deprecated)
Definition: net.c:1522
PPP (Point-to-Point Protocol)
bool_t acceptAllMulticast
Accept all frames with a multicast destination address.
Definition: net.h:226
#define IgmpRouterContext
Definition: igmp_router.h:47
IgmpSnoopingContext * igmpSnoopingContext
IGMP snooping switch context.
Definition: net.h:261
void * llcRxParam
Callback parameter.
Definition: net.h:236
DnsSdResponderContext * dnsSdResponderContext
DNS-SD responder context.
Definition: net.h:298
NetRandState randState
Pseudo-random number generator state.
Definition: net.h:331
error_t netSetSwitchPort(NetInterface *interface, uint8_t port)
Specify switch port.
Definition: net.c:917
Dhcpv6ClientContext * dhcpv6ClientContext
DHCPv6 client context.
Definition: net.h:289
#define NET_RAND_SEED_SIZE
Definition: net.h:157
Ipv4Context ipv4Context
IPv4 context.
Definition: net.h:247
error_t netEnablePromiscuousMode(NetInterface *interface, bool_t enable)
Enable promiscuous mode.
Definition: net.c:1178
const PhyDriver * phyDriver
Ethernet PHY driver.
Definition: net.h:218
error_t netConfigInterface(NetInterface *interface)
Configure network interface.
Definition: net.c:1204
IPv4 (Internet Protocol Version 4)
OsTaskParameters task
Task parameters.
Definition: net.h:313
thread_t * OsTaskId
Task identifier.
NicDuplexMode duplexMode
Duplex mode.
Definition: net.h:213
const SmiDriver * smiDriver
SMI driver.
Definition: net.h:222
IGMP snooping switch context.
TCP/IP stack settings.
Definition: net.h:312
unsigned int uint_t
Definition: compiler_port.h:57
uint32_t id
A unique number identifying the interface.
Definition: net.h:199
bool_t nicEvent
A NIC event is pending.
Definition: net.h:209
NicDuplexMode netGetDuplexMode(NetInterface *interface)
Get duplex mode.
Definition: net.c:1146
bool_t configured
Configuration done.
Definition: net.h:214
NIC driver.
Definition: nic.h:286
OsEvent event
Event object to receive notifications from drivers.
Definition: net.h:324
void * ikeContext
IKE context.
Definition: net.h:340
RTOS abstraction layer.
DHCP server (Dynamic Host Configuration Protocol)
ARP (Address Resolution Protocol)
systime_t arpReachableTime
ARP reachable time.
Definition: net.h:250
#define DhcpServerContext
Definition: dhcp_server.h:79
error_t netSetLinkState(NetInterface *interface, bool_t linkState)
Set administrative link state.
Definition: net.c:1052
Helper functions for TCP/IP stack.
NetInterface * parent
Interface on top of which the virtual interface runs.
Definition: net.h:243
#define NET_MAX_HOSTNAME_LEN
Definition: net.h:150
Structure describing a network interface.
Definition: net.h:197
mDNS responder (Multicast DNS)
error_t netSeedRand(const uint8_t *seed, size_t length)
Seed the pseudo-random number generator.
Definition: net.c:339
Auto-IP (Dynamic Configuration of IPv4 Link-Local Addresses)
MacFilterEntry macAddrFilter[MAC_ADDR_FILTER_SIZE]
MAC filter table.
Definition: net.h:224