net.c File Reference

TCP/IP stack core. More...

#include <stdlib.h>
#include "core/net.h"
#include "core/socket.h"
#include "core/tcp_timer.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 "mibs/mib2_module.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   ETH_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 netSetProxy (NetInterface *interface, const char_t *name, uint16_t port)
 Set proxy server. 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 netSetSwitchPort (NetInterface *interface, uint8_t port)
 Specify switch port. 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)
 Set Ethernet PHY address. 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 link state (for virtual drivers only) More...
 
bool_t netGetLinkState (NetInterface *interface)
 Get link state. More...
 
error_t netConfigInterface (NetInterface *interface)
 Configure network interface. More...
 
void netTask (void)
 TCP/IP events handling. More...
 
void netTick (void)
 Manage TCP/IP timers. 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...
 
error_t netAttachLinkChangeCallback (NetInterface *interface, LinkChangeCallback callback, void *param, uint_t *cookie)
 Register link change callback. More...
 
error_t netDetachLinkChangeCallback (uint_t cookie)
 Unregister link change callback. More...
 
void netInvokeLinkChangeCallback (NetInterface *interface, bool_t linkState)
 Invoke link change callback. More...
 

Variables

OsTasknetTaskHandle
 
OsMutex netMutex
 
OsEvent netEvent
 
NetInterface netInterface [NET_INTERFACE_COUNT]
 

Detailed Description

TCP/IP stack core.

License

Copyright (C) 2010-2018 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.0

Definition in file net.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   ETH_TRACE_LEVEL

Definition at line 30 of file net.c.

Function Documentation

◆ netAttachLinkChangeCallback()

error_t netAttachLinkChangeCallback ( NetInterface interface,
LinkChangeCallback  callback,
void *  param,
uint_t cookie 
)

Register link change callback.

Parameters
[in]interfaceUnderlying network interface
[in]callbackCallback function to be called when the link state changed
[in]paramCallback function parameter (optional)
[out]cookieIdentifier that can be used to unregister the callback function
Returns
Error code

Definition at line 1584 of file net.c.

◆ netConfigInterface()

error_t netConfigInterface ( NetInterface interface)

Configure network interface.

Parameters
[in]interfaceNetwork interface to configure
Returns
Error code

Definition at line 880 of file net.c.

◆ netDetachLinkChangeCallback()

error_t netDetachLinkChangeCallback ( uint_t  cookie)

Unregister link change callback.

Parameters
[in]cookieIdentifier specifying the callback to be unregistered
Returns
Error code

Definition at line 1633 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 1495 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 397 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 854 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 335 of file net.c.

◆ netGetRand()

uint32_t netGetRand ( void  )

Get a random value.

Returns
Random value

Definition at line 1523 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 1554 of file net.c.

◆ netInit()

error_t netInit ( void  )

TCP/IP stack initialization.

Returns
Error code

Definition at line 103 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 1508 of file net.c.

◆ netInvokeLinkChangeCallback()

void netInvokeLinkChangeCallback ( NetInterface interface,
bool_t  linkState 
)

Invoke link change callback.

Parameters
[in]interfaceUnderlying network interface
[in]linkStateLink state

Definition at line 1657 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 668 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 372 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 797 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 481 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 429 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 454 of file net.c.

◆ netSetLinkState()

error_t netSetLinkState ( NetInterface interface,
NicLinkState  linkState 
)

Set link state (for virtual drivers only)

Parameters
[in]interfacePointer to the desired network interface
[in]linkStateLink state
Returns
Error code

Definition at line 822 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 300 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 637 of file net.c.

◆ netSetPhyAddr()

error_t netSetPhyAddr ( NetInterface interface,
uint8_t  phyAddr 
)

Set Ethernet PHY address.

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

Definition at line 718 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 693 of file net.c.

◆ netSetProxy()

error_t netSetProxy ( NetInterface interface,
const char_t name,
uint16_t  port 
)

Set proxy server.

Parameters
[in]interfacePointer to the desired network interface
[in]nameProxy server name
[in]portProxy server port
Returns
Error code

Definition at line 509 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 747 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 606 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 772 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 538 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 572 of file net.c.

◆ netTask()

void netTask ( void  )

TCP/IP events handling.

Definition at line 1056 of file net.c.

◆ netTick()

void netTick ( void  )

Manage TCP/IP timers.

Definition at line 1185 of file net.c.

Variable Documentation

◆ netEvent

OsEvent netEvent

Definition at line 72 of file net.c.

◆ netInterface

Definition at line 74 of file net.c.

◆ netMutex

OsMutex netMutex

Definition at line 70 of file net.c.

◆ netTaskHandle

OsTask* netTaskHandle

Definition at line 68 of file net.c.