Go to the documentation of this file.
32 #define TRACE_LEVEL NIC_TRACE_LEVEL
69 #if (defined(WEB_SOCKET_SUPPORT) && WEB_SOCKET_SUPPORT == ENABLED)
177 interface->index = i;
181 #if (ETH_SUPPORT == ENABLED)
183 interface->phyAddr = UINT8_MAX;
185 #if (TCP_SUPPORT == ENABLED)
197 #if (defined(WEB_SOCKET_SUPPORT) && WEB_SOCKET_SUPPORT == ENABLED)
202 #if (IPV4_SUPPORT == ENABLED && IPV4_ROUTING_SUPPORT == ENABLED)
210 #if (IPV6_SUPPORT == ENABLED && IPV6_ROUTING_SUPPORT == ENABLED)
218 #if (UDP_SUPPORT == ENABLED)
226 #if (TCP_SUPPORT == ENABLED)
234 #if (DNS_CLIENT_SUPPORT == ENABLED || MDNS_CLIENT_SUPPORT == ENABLED || \
235 NBNS_CLIENT_SUPPORT == ENABLED)
246 #if (PPP_SUPPORT == ENABLED)
249 #if (IPV4_SUPPORT == ENABLED && ETH_SUPPORT == ENABLED)
252 #if (IPV4_SUPPORT == ENABLED && IPV4_FRAG_SUPPORT == ENABLED)
255 #if (IPV4_SUPPORT == ENABLED && (IGMP_HOST_SUPPORT == ENABLED || \
256 IGMP_ROUTER_SUPPORT == ENABLED || IGMP_SNOOPING_SUPPORT == ENABLED))
259 #if (IPV4_SUPPORT == ENABLED && AUTO_IP_SUPPORT == ENABLED)
262 #if (IPV4_SUPPORT == ENABLED && DHCP_CLIENT_SUPPORT == ENABLED)
265 #if (IPV4_SUPPORT == ENABLED && DHCP_SERVER_SUPPORT == ENABLED)
268 #if (IPV6_SUPPORT == ENABLED && IPV6_FRAG_SUPPORT == ENABLED)
271 #if (IPV6_SUPPORT == ENABLED && MLD_NODE_SUPPORT == ENABLED)
274 #if (IPV6_SUPPORT == ENABLED && NDP_SUPPORT == ENABLED)
277 #if (IPV6_SUPPORT == ENABLED && NDP_ROUTER_ADV_SUPPORT == ENABLED)
280 #if (IPV6_SUPPORT == ENABLED && DHCPV6_CLIENT_SUPPORT == ENABLED)
283 #if (TCP_SUPPORT == ENABLED)
286 #if (DNS_CLIENT_SUPPORT == ENABLED || MDNS_CLIENT_SUPPORT == ENABLED || \
287 NBNS_CLIENT_SUPPORT == ENABLED)
290 #if (MDNS_RESPONDER_SUPPORT == ENABLED)
293 #if (DNS_SD_RESPONDER_SUPPORT == ENABLED)
318 #if (NET_RTOS_SUPPORT == DISABLED)
341 if(seed == NULL ||
length == 0)
483 #if (ETH_SUPPORT == ENABLED)
485 if(interface == NULL || macAddr == NULL)
492 interface->macAddr = *macAddr;
518 #if (ETH_SUPPORT == ENABLED)
522 if(interface == NULL || macAddr == NULL)
532 *macAddr = logicalInterface->macAddr;
556 if(interface == NULL || eui64 == NULL)
562 interface->eui64 = *eui64;
583 if(interface == NULL || eui64 == NULL)
593 *eui64 = logicalInterface->eui64;
613 if(interface == NULL)
638 if(interface == NULL ||
name == NULL)
667 if(interface == NULL ||
name == NULL)
695 #if (ETH_VLAN_SUPPORT == ENABLED)
697 if(interface == NULL)
707 interface->vlanId = vlanId;
729 #if (ETH_VMAN_SUPPORT == ENABLED)
731 if(interface == NULL)
741 interface->vmanId = vmanId;
765 #if (ETH_VIRTUAL_IF_SUPPORT == ENABLED || ETH_VLAN_SUPPORT == ENABLED || \
766 ETH_PORT_TAGGING_SUPPORT == ENABLED)
768 if(interface == NULL)
774 interface->parent = physicalInterface;
797 if(interface == NULL || driver == NULL)
803 interface->nicDriver = driver;
821 #if (ETH_SUPPORT == ENABLED)
823 if(interface == NULL || driver == NULL)
829 interface->phyDriver = driver;
851 #if (ETH_SUPPORT == ENABLED)
853 if(interface == NULL)
863 interface->phyAddr = phyAddr;
885 #if (ETH_SUPPORT == ENABLED)
887 if(interface == NULL || driver == NULL)
893 interface->switchDriver = driver;
915 #if (ETH_PORT_TAGGING_SUPPORT == ENABLED)
917 if(interface == NULL)
923 interface->port =
port;
945 #if (ETH_SUPPORT == ENABLED)
947 if(interface == NULL || driver == NULL)
953 interface->smiDriver = driver;
976 if(interface == NULL || driver == NULL)
982 interface->spiDriver = driver;
1001 if(interface == NULL || driver == NULL)
1007 interface->uartDriver = driver;
1026 if(interface == NULL || driver == NULL)
1032 interface->extIntDriver = driver;
1051 if(interface == NULL)
1058 if(linkState != interface->linkState)
1061 interface->linkState = linkState;
1085 if(interface != NULL)
1090 linkState = interface->linkState;
1116 if(interface != NULL)
1121 linkSpeed = interface->linkSpeed;
1147 if(interface != NULL)
1152 duplexMode = interface->duplexMode;
1177 if(interface == NULL)
1180 #if (ETH_SUPPORT == ENABLED)
1184 interface->promiscuous = enable;
1205 if(interface == NULL)
1212 if(interface->nicDriver != NULL)
1213 interface->nicDriver->disableIrq(interface);
1228 if(interface->nicDriver != NULL)
1231 error = interface->nicDriver->init(interface);
1238 #if (ETH_VIRTUAL_IF_SUPPORT == ENABLED || ETH_PORT_TAGGING_SUPPORT == ENABLED)
1245 if(physicalInterface != interface)
1261 #if (ETH_SUPPORT == ENABLED)
1269 #if (IPV4_SUPPORT == ENABLED)
1276 #if (ETH_SUPPORT == ENABLED)
1284 #if (IPV4_SUPPORT == ENABLED && (IGMP_HOST_SUPPORT == ENABLED || \
1285 IGMP_ROUTER_SUPPORT == ENABLED || IGMP_SNOOPING_SUPPORT == ENABLED))
1293 #if (NBNS_CLIENT_SUPPORT == ENABLED || NBNS_RESPONDER_SUPPORT == ENABLED)
1302 #if (IPV6_SUPPORT == ENABLED)
1309 #if (IPV6_SUPPORT == ENABLED && NDP_SUPPORT == ENABLED)
1317 #if (IPV6_SUPPORT == ENABLED && MLD_NODE_SUPPORT == ENABLED)
1326 #if (MDNS_CLIENT_SUPPORT == ENABLED || MDNS_RESPONDER_SUPPORT == ENABLED)
1334 #if (LLMNR_RESPONDER_SUPPORT == ENABLED)
1352 interface->configured =
TRUE;
1358 if(interface->nicDriver != NULL)
1359 interface->nicDriver->enableIrq(interface);
1387 if(interface == NULL)
1396 #if (ETH_SUPPORT == ENABLED)
1398 if(!interface->configured)
1406 if(interface != physicalInterface)
1418 #if (ETH_PORT_TAGGING_SUPPORT == ENABLED)
1420 if(interface->switchDriver != NULL &&
1421 interface->switchDriver->init != NULL)
1424 error = interface->switchDriver->init(interface);
1438 interface->configured =
TRUE;
1444 if(interface->nicDriver != NULL)
1445 interface->nicDriver->enableIrq(interface);
1467 if(interface == NULL)
1477 if(interface->configured)
1480 interface->linkState =
FALSE;
1485 if(interface->nicDriver != NULL)
1486 interface->nicDriver->disableIrq(interface);
1489 interface->configured =
FALSE;
1492 if(interface != physicalInterface)
1494 #if (ETH_SUPPORT == ENABLED)
1537 #if (NET_RTOS_SUPPORT == ENABLED)
1554 if(interface->configured)
1557 if(interface->nicDriver != NULL)
1559 interface->nicDriver->enableIrq(interface);
1601 if(interface->nicEvent)
1604 interface->nicEvent =
FALSE;
1607 if(interface->nicDriver != NULL)
1610 interface->nicDriver->disableIrq(interface);
1612 interface->nicDriver->eventHandler(interface);
1614 interface->nicDriver->enableIrq(interface);
1618 #if (ETH_SUPPORT == ENABLED)
1620 if(interface->phyEvent)
1623 interface->phyEvent =
FALSE;
1626 if(interface->nicDriver != NULL)
1629 interface->nicDriver->disableIrq(interface);
1632 if(interface->phyDriver != NULL)
1635 interface->phyDriver->eventHandler(interface);
1637 else if(interface->switchDriver != NULL)
1640 interface->switchDriver->eventHandler(interface);
1648 interface->nicDriver->enableIrq(interface);
1674 #if (NET_RTOS_SUPPORT == ENABLED)
error_t ethAcceptMacAddr(NetInterface *interface, const MacAddr *macAddr)
Add a unicast/multicast address to the MAC filter table.
IPv6 (Internet Protocol Version 6)
error_t netInit(void)
Initialize TCP/IP stack (deprecated)
OsTaskId osCreateTask(const char_t *name, OsTaskCode taskCode, void *arg, const OsTaskParameters *params)
Create a task.
systime_t ipv4FragTickCounter
String manipulation helper functions.
bool_t osCreateMutex(OsMutex *mutex)
Create a mutex object.
error_t netSetSpiDriver(NetInterface *interface, const SpiDriver *driver)
Set SPI driver.
uint32_t netGetRandRange(uint32_t min, uint32_t max)
Generate a random value in the specified range.
error_t netSetDriver(NetInterface *interface, const NicDriver *driver)
Set Ethernet MAC driver.
error_t ipv4InitRouting(void)
void macAddrToEui64(const MacAddr *macAddr, Eui64 *interfaceId)
Map a MAC address to the IPv6 modified EUI-64 identifier.
error_t netSetUartDriver(NetInterface *interface, const UartDriver *driver)
Set UART driver.
error_t netSeedRand(const uint8_t *seed, size_t length)
Seed the pseudo-random number generator.
WebSocket API (client and server)
void netTaskEx(NetContext *context)
TCP/IP events handling.
#define OS_INVALID_TASK_ID
External interrupt line driver.
systime_t dnsSdResponderTickCounter
#define NET_INTERFACE_COUNT
error_t arpInit(NetInterface *interface)
ARP cache initialization.
error_t netSetSwitchDriver(NetInterface *interface, const SwitchDriver *driver)
Set Ethernet switch driver.
error_t netSetMacAddr(NetInterface *interface, const MacAddr *macAddr)
Set MAC address.
#define NET_TICK_INTERVAL
error_t netSetParentInterface(NetInterface *interface, NetInterface *physicalInterface)
Attach a virtual interface to a given physical interface.
error_t ipv6Init(NetInterface *interface)
IPv6 related initialization.
Helper functions for DHCPv6 client.
#define NET_TASK_STACK_SIZE
#define timeCompare(t1, t2)
Helper functions for DHCP client.
systime_t ipv6FragTickCounter
uint_t netGetLinkSpeed(NetInterface *interface)
Get link speed.
Helper functions for DHCP server.
error_t webSocketInit(void)
WebSocket related initialization.
error_t ethDropMacAddr(NetInterface *interface, const MacAddr *macAddr)
Remove a unicast/multicast address from the MAC filter table.
Router advertisement service.
Definitions common to mDNS client and mDNS responder.
uint32_t netGenerateRand(void)
Generate a random 32-bit value.
systime_t igmpTickCounter
OsTaskParameters taskParams
Task parameters.
systime_t dhcpServerTickCounter
Helper functions for TCP.
@ ERROR_INVALID_PARAMETER
Invalid parameter.
NetInterface * nicGetPhysicalInterface(NetInterface *interface)
Retrieve physical interface.
uint32_t netGenerateRandRange(uint32_t min, uint32_t max)
Generate a random value in the specified range.
#define osSprintf(dest,...)
void(* OsTaskCode)(void *arg)
Task routine.
Definitions common to NBNS client and NBNS responder.
DNS-SD responder (DNS-Based Service Discovery)
error_t netSetPhyAddr(NetInterface *interface, uint8_t phyAddr)
Specify Ethernet PHY address.
error_t mdnsInit(NetInterface *interface)
mDNS related initialization
NBNS client (NetBIOS Name Service)
error_t netSetEui64(NetInterface *interface, const Eui64 *eui64)
Set EUI-64 interface identifier.
error_t netConfigInterface(NetInterface *interface)
Configure network interface.
error_t udpInit(void)
UDP related initialization.
systime_t dhcpv6ClientTickCounter
void osDeleteEvent(OsEvent *event)
Delete an event object.
error_t memPoolInit(void)
Memory pool initialization.
void netGetDefaultSettings(NetSettings *settings)
Initialize settings with default values.
NetInterface * netGetDefaultInterface(void)
Get default network interface.
OsTaskId taskId
Task identifier.
error_t netSetSmiDriver(NetInterface *interface, const SmiDriver *driver)
Set SMI driver.
error_t netGetMacAddr(NetInterface *interface, MacAddr *macAddr)
Retrieve MAC address.
const OsTaskParameters OS_TASK_DEFAULT_PARAMS
error_t netSetPhyDriver(NetInterface *interface, const PhyDriver *driver)
Set Ethernet PHY driver.
void netGenerateRandData(uint8_t *data, size_t length)
Get a string of random data.
mDNS client (Multicast DNS)
error_t netInitEx(NetContext *context, const NetSettings *settings)
Initialize TCP/IP stack.
error_t netSetLinkState(NetInterface *interface, bool_t linkState)
Set administrative link state.
void netProcessLinkChange(NetInterface *interface)
Process link state change event.
error_t igmpInit(NetInterface *interface)
IGMP initialization.
uint32_t netGetRand(void)
Generate a random 32-bit value.
NDP (Neighbor Discovery Protocol)
error_t nicUpdateMacAddrFilter(NetInterface *interface)
Configure MAC address filtering.
error_t netEnablePromiscuousMode(NetInterface *interface, bool_t enable)
Enable promiscuous mode.
DNS client (Domain Name System)
uint32_t systime_t
System time.
MLD node (Multicast Listener Discovery for IPv6)
error_t netSetInterfaceId(NetInterface *interface, uint32_t id)
Set interface identifier.
error_t ndpInit(NetInterface *interface)
Neighbor cache initialization.
error_t tcpInit(void)
TCP related initialization.
void netInitRand(void)
Initialize random number generator.
#define NET_MAX_IF_NAME_LEN
bool_t osWaitForEvent(OsEvent *event, systime_t timeout)
Wait until the specified event is in the signaled state.
void netTick(void)
Manage TCP/IP timers.
void osAcquireMutex(OsMutex *mutex)
Acquire ownership of the specified mutex object.
void osReleaseMutex(OsMutex *mutex)
Release ownership of the specified mutex object.
error_t netSetVmanId(NetInterface *interface, uint16_t vmanId)
Specify VMAN identifier (802.1ad)
NicDuplexMode
Duplex mode.
systime_t autoIpTickCounter
bool_t osCreateEvent(OsEvent *event)
Create an event object.
systime_t dhcpClientTickCounter
#define macCompAddr(macAddr1, macAddr2)
error_t netSetVlanId(NetInterface *interface, uint16_t vlanId)
Specify VLAN identifier (802.1Q)
error_t netStopInterface(NetInterface *interface)
Stop network interface.
error_t netSetHostname(NetInterface *interface, const char_t *name)
Set host name.
@ NIC_UNKNOWN_DUPLEX_MODE
error_t ipv6InitRouting(void)
Initialize IPv6 routing table.
error_t ethInit(NetInterface *interface)
Ethernet related initialization.
error_t nbnsInit(NetInterface *interface)
NBNS related initialization.
Helper functions for Auto-IP.
#define NET_RAND_SEED_SIZE
LLMNR responder (Link-Local Multicast Name Resolution)
error_t netGetEui64(NetInterface *interface, Eui64 *eui64)
Retrieve EUI-64 interface identifier.
NicDuplexMode netGetDuplexMode(NetInterface *interface)
Get duplex mode.
IPv4 (Internet Protocol Version 4)
OsTaskParameters task
Task parameters.
error_t netSetSwitchPort(NetInterface *interface, uint8_t port)
Specify switch port.
error_t mldInit(NetInterface *interface)
MLD initialization.
error_t netStartInterface(NetInterface *interface)
Start network interface.
uint8_t randSeed[NET_RAND_SEED_SIZE]
Random seed.
#define osMemset(p, value, length)
NetInterface * nicGetLogicalInterface(NetInterface *interface)
Retrieve logical interface.
error_t netSetExtIntDriver(NetInterface *interface, const ExtIntDriver *driver)
Set external interrupt line driver.
error_t dnsInit(void)
DNS cache initialization.
void netTask(void)
TCP/IP events handling (deprecated)
bool_t netGetLinkState(NetInterface *interface)
Get link state.
void netGetRandData(uint8_t *data, size_t length)
Get a string of random data.
error_t llmnrResponderInit(NetInterface *interface)
LLMNR responder initialization.
systime_t mdnsResponderTickCounter
ARP (Address Resolution Protocol)
#define NET_TASK_PRIORITY
error_t ipv4Init(NetInterface *interface)
IPv4 related initialization.
error_t socketInit(void)
Socket related initialization.
systime_t ndpRouterAdvTickCounter
const MacAddr MAC_UNSPECIFIED_ADDR
#define NET_MAX_HOSTNAME_LEN
NBNS responder (NetBIOS Name Service)
error_t netStart(NetContext *context)
Start TCP/IP stack.
mDNS responder (Multicast DNS)
systime_t osGetSystemTime(void)
Retrieve system time.
error_t netSetInterfaceName(NetInterface *interface, const char_t *name)
Set interface name.