net.c File Reference

TCP/IP stack core. More...

#include <stdlib.h>
#include "core/net.h"
#include "core/socket.h"
#include "core/raw_socket.h"
#include "core/tcp_timer.h"
#include "core/tcp_misc.h"
#include "core/ethernet.h"
#include "ipv4/arp.h"
#include "ipv4/ipv4.h"
#include "ipv4/ipv4_routing.h"
#include "ipv4/igmp.h"
#include "ipv6/ipv6.h"
#include "ipv6/ipv6_routing.h"
#include "ipv6/mld.h"
#include "ipv6/ndp.h"
#include "ipv6/ndp_router_adv.h"
#include "dhcp/dhcp_client.h"
#include "dhcp/dhcp_server.h"
#include "dns/dns_cache.h"
#include "dns/dns_client.h"
#include "mdns/mdns_client.h"
#include "mdns/mdns_responder.h"
#include "mdns/mdns_common.h"
#include "dns_sd/dns_sd.h"
#include "netbios/nbns_client.h"
#include "netbios/nbns_responder.h"
#include "netbios/nbns_common.h"
#include "llmnr/llmnr_responder.h"
#include "str.h"
#include "debug.h"
#include "web_socket/web_socket.h"

Go to the source code of this file.

Macros

#define TRACE_LEVEL   NIC_TRACE_LEVEL
 

Functions

error_t netInit (void)
 TCP/IP stack initialization. More...
 
error_t netSetMacAddr (NetInterface *interface, const MacAddr *macAddr)
 Set MAC address. More...
 
error_t netGetMacAddr (NetInterface *interface, MacAddr *macAddr)
 Retrieve MAC address. More...
 
error_t netSetEui64 (NetInterface *interface, const Eui64 *eui64)
 Set EUI-64 interface identifier. More...
 
error_t netGetEui64 (NetInterface *interface, Eui64 *eui64)
 Retrieve EUI-64 interface identifier. More...
 
error_t netSetInterfaceId (NetInterface *interface, uint32_t id)
 Set interface identifier. More...
 
error_t netSetInterfaceName (NetInterface *interface, const char_t *name)
 Set interface name. More...
 
error_t netSetHostname (NetInterface *interface, const char_t *name)
 Set host name. More...
 
error_t netSetVlanId (NetInterface *interface, uint16_t vlanId)
 Specify VLAN identifier (802.1Q) More...
 
error_t netSetVmanId (NetInterface *interface, uint16_t vmanId)
 Specify VMAN identifier (802.1ad) More...
 
error_t netSetParentInterface (NetInterface *interface, NetInterface *physicalInterface)
 Attach a virtual interface to a given physical interface. More...
 
error_t netSetDriver (NetInterface *interface, const NicDriver *driver)
 Set Ethernet MAC driver. More...
 
error_t netSetPhyDriver (NetInterface *interface, const PhyDriver *driver)
 Set Ethernet PHY driver. More...
 
error_t netSetPhyAddr (NetInterface *interface, uint8_t phyAddr)
 Specify Ethernet PHY address. More...
 
error_t netSetSwitchDriver (NetInterface *interface, const SwitchDriver *driver)
 Set Ethernet switch driver. More...
 
error_t netSetSwitchPort (NetInterface *interface, uint8_t port)
 Specify switch port. More...
 
error_t netSetSmiDriver (NetInterface *interface, const SmiDriver *driver)
 Set SMI driver. More...
 
error_t netSetSpiDriver (NetInterface *interface, const SpiDriver *driver)
 Set SPI driver. More...
 
error_t netSetUartDriver (NetInterface *interface, const UartDriver *driver)
 Set UART driver. More...
 
error_t netSetExtIntDriver (NetInterface *interface, const ExtIntDriver *driver)
 Set external interrupt line driver. More...
 
error_t netSetLinkState (NetInterface *interface, NicLinkState linkState)
 Set administrative link state. More...
 
bool_t netGetLinkState (NetInterface *interface)
 Get link state. More...
 
error_t netConfigInterface (NetInterface *interface)
 Configure network interface. More...
 
error_t netStartInterface (NetInterface *interface)
 Start network interface. More...
 
error_t netStopInterface (NetInterface *interface)
 Stop network interface. More...
 
void netTask (void)
 TCP/IP events handling. More...
 
NetInterfacenetGetDefaultInterface (void)
 Get default network interface. More...
 
error_t netInitRand (uint32_t seed)
 Seed pseudo-random number generator. More...
 
uint32_t netGetRand (void)
 Get a random value. More...
 
int32_t netGetRandRange (int32_t min, int32_t max)
 Get a random value in the specified range. More...
 

Variables

NetContext netContext
 

Detailed Description

TCP/IP stack core.

License

SPDX-License-Identifier: GPL-2.0-or-later

Copyright (C) 2010-2020 Oryx Embedded SARL. All rights reserved.

This file is part of CycloneTCP Open.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Author
Oryx Embedded SARL (www.oryx-embedded.com)
Version
1.9.8

Definition in file net.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   NIC_TRACE_LEVEL

Definition at line 32 of file net.c.

Function Documentation

◆ netConfigInterface()

error_t netConfigInterface ( NetInterface interface)

Configure network interface.

Parameters
[in]interfaceNetwork interface to configure
Returns
Error code

Definition at line 895 of file net.c.

◆ netGetDefaultInterface()

NetInterface* netGetDefaultInterface ( void  )

Get default network interface.

Returns
Pointer to the default network interface to be used

Definition at line 1373 of file net.c.

◆ netGetEui64()

error_t netGetEui64 ( NetInterface interface,
Eui64 eui64 
)

Retrieve EUI-64 interface identifier.

Parameters
[in]interfacePointer to the desired network interface
[out]eui64Interface identifier
Returns
Error code

Definition at line 371 of file net.c.

◆ netGetLinkState()

bool_t netGetLinkState ( NetInterface interface)

Get link state.

Parameters
[in]interfacePointer to the desired network interface
Returns
Link state

Definition at line 869 of file net.c.

◆ netGetMacAddr()

error_t netGetMacAddr ( NetInterface interface,
MacAddr macAddr 
)

Retrieve MAC address.

Parameters
[in]interfacePointer to the desired network interface
[out]macAddrMAC address
Returns
Error code

Definition at line 309 of file net.c.

◆ netGetRand()

uint32_t netGetRand ( void  )

Get a random value.

Returns
Random value

Definition at line 1401 of file net.c.

◆ netGetRandRange()

int32_t netGetRandRange ( int32_t  min,
int32_t  max 
)

Get a random value in the specified range.

Parameters
[in]minLower bound
[in]maxUpper bound
Returns
Random value in the specified range

Definition at line 1432 of file net.c.

◆ netInit()

error_t netInit ( void  )

TCP/IP stack initialization.

Returns
Error code

Definition at line 81 of file net.c.

◆ netInitRand()

error_t netInitRand ( uint32_t  seed)

Seed pseudo-random number generator.

Parameters
[in]seedAn integer value to be used as seed by the pseudo-random number generator
Returns
Error code

Definition at line 1386 of file net.c.

◆ netSetDriver()

error_t netSetDriver ( NetInterface interface,
const NicDriver driver 
)

Set Ethernet MAC driver.

Parameters
[in]interfacePointer to the desired network interface
[in]driverEthernet MAC driver
Returns
Error code

Definition at line 583 of file net.c.

◆ netSetEui64()

error_t netSetEui64 ( NetInterface interface,
const Eui64 eui64 
)

Set EUI-64 interface identifier.

Parameters
[in]interfacePointer to the desired network interface
[in]eui64Interface identifier
Returns
Error code

Definition at line 346 of file net.c.

◆ netSetExtIntDriver()

error_t netSetExtIntDriver ( NetInterface interface,
const ExtIntDriver driver 
)

Set external interrupt line driver.

Parameters
[in]interfacePointer to the desired network interface
[in]driverUnderlying SPI driver
Returns
Error code

Definition at line 812 of file net.c.

◆ netSetHostname()

error_t netSetHostname ( NetInterface interface,
const char_t name 
)

Set host name.

Parameters
[in]interfacePointer to the desired network interface
[in]nameNULL-terminated string that contains the host name
Returns
Error code

Definition at line 455 of file net.c.

◆ netSetInterfaceId()

error_t netSetInterfaceId ( NetInterface interface,
uint32_t  id 
)

Set interface identifier.

Parameters
[in]interfacePointer to the desired network interface
[in]idUnique number identifying the interface
Returns
Error code

Definition at line 403 of file net.c.

◆ netSetInterfaceName()

error_t netSetInterfaceName ( NetInterface interface,
const char_t name 
)

Set interface name.

Parameters
[in]interfacePointer to the desired network interface
[in]nameNULL-terminated string that contains the interface name
Returns
Error code

Definition at line 428 of file net.c.

◆ netSetLinkState()

error_t netSetLinkState ( NetInterface interface,
NicLinkState  linkState 
)

Set administrative link state.

Parameters
[in]interfacePointer to the desired network interface
[in]linkStateAdministrative link state (up, down or auto)
Returns
Error code

Definition at line 837 of file net.c.

◆ netSetMacAddr()

error_t netSetMacAddr ( NetInterface interface,
const MacAddr macAddr 
)

Set MAC address.

Parameters
[in]interfacePointer to the desired network interface
[in]macAddrMAC address
Returns
Error code

Definition at line 274 of file net.c.

◆ netSetParentInterface()

error_t netSetParentInterface ( NetInterface interface,
NetInterface physicalInterface 
)

Attach a virtual interface to a given physical interface.

Parameters
[in]interfacePointer to the virtual interface
[in]physicalInterfacephysical interface on top of which the virtual interface will run
Returns
Error code

Definition at line 551 of file net.c.

◆ netSetPhyAddr()

error_t netSetPhyAddr ( NetInterface interface,
uint8_t  phyAddr 
)

Specify Ethernet PHY address.

Parameters
[in]interfacePointer to the desired network interface
[in]phyAddrPHY address
Returns
Error code

Definition at line 638 of file net.c.

◆ netSetPhyDriver()

error_t netSetPhyDriver ( NetInterface interface,
const PhyDriver driver 
)

Set Ethernet PHY driver.

Parameters
[in]interfacePointer to the desired network interface
[in]driverEthernet PHY driver (can be NULL for MAC + PHY controller)
Returns
Error code

Definition at line 608 of file net.c.

◆ netSetSmiDriver()

error_t netSetSmiDriver ( NetInterface interface,
const SmiDriver driver 
)

Set SMI driver.

Parameters
[in]interfacePointer to the desired network interface
[in]driverUnderlying SMI driver
Returns
Error code

Definition at line 732 of file net.c.

◆ netSetSpiDriver()

error_t netSetSpiDriver ( NetInterface interface,
const SpiDriver driver 
)

Set SPI driver.

Parameters
[in]interfacePointer to the desired network interface
[in]driverUnderlying SPI driver
Returns
Error code

Definition at line 762 of file net.c.

◆ netSetSwitchDriver()

error_t netSetSwitchDriver ( NetInterface interface,
const SwitchDriver driver 
)

Set Ethernet switch driver.

Parameters
[in]interfacePointer to the desired network interface
[in]driverEthernet switch driver
Returns
Error code

Definition at line 672 of file net.c.

◆ netSetSwitchPort()

error_t netSetSwitchPort ( NetInterface interface,
uint8_t  port 
)

Specify switch port.

Parameters
[in]interfacePointer to the desired network interface
[in]portSwitch port identifier
Returns
Error code

Definition at line 702 of file net.c.

◆ netSetUartDriver()

error_t netSetUartDriver ( NetInterface interface,
const UartDriver driver 
)

Set UART driver.

Parameters
[in]interfacePointer to the desired network interface
[in]driverUnderlying UART driver
Returns
Error code

Definition at line 787 of file net.c.

◆ netSetVlanId()

error_t netSetVlanId ( NetInterface interface,
uint16_t  vlanId 
)

Specify VLAN identifier (802.1Q)

Parameters
[in]interfacePointer to the desired network interface
[in]vlanIdVLAN identifier
Returns
Error code

Definition at line 482 of file net.c.

◆ netSetVmanId()

error_t netSetVmanId ( NetInterface interface,
uint16_t  vmanId 
)

Specify VMAN identifier (802.1ad)

Parameters
[in]interfacePointer to the desired network interface
[in]vmanIdVMAN identifier
Returns
Error code

Definition at line 516 of file net.c.

◆ netStartInterface()

error_t netStartInterface ( NetInterface interface)

Start network interface.

Parameters
[in]interfaceNetwork interface to start
Returns
Error code

Definition at line 1085 of file net.c.

◆ netStopInterface()

error_t netStopInterface ( NetInterface interface)

Stop network interface.

Parameters
[in]interfaceNetwork interface to stop
Returns
Error code

Definition at line 1165 of file net.c.

◆ netTask()

void netTask ( void  )

TCP/IP events handling.

Definition at line 1221 of file net.c.

Variable Documentation

◆ netContext

NetContext netContext

Definition at line 71 of file net.c.