net_misc.c File Reference

Helper functions for TCP/IP stack. More...

#include "core/net.h"
#include "core/net_misc.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/auto_ip_misc.h"
#include "igmp/igmp_host.h"
#include "ipv6/ipv6.h"
#include "ipv6/ipv6_routing.h"
#include "ipv6/mld.h"
#include "ipv6/ndp.h"
#include "ipv6/ndp_router_adv_misc.h"
#include "dhcp/dhcp_client_misc.h"
#include "dhcp/dhcp_server_misc.h"
#include "dhcpv6/dhcpv6_client_misc.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_client.h"
#include "llmnr/llmnr_responder.h"
#include "mibs/mib2_module.h"
#include "mibs/if_mib_module.h"
#include "debug.h"

Go to the source code of this file.

Macros

#define TRACE_LEVEL   NIC_TRACE_LEVEL
 

Functions

error_t netAttachLinkChangeCallback (NetInterface *interface, NetLinkChangeCallback callback, void *param)
 Register link change callback. More...
 
error_t netDetachLinkChangeCallback (NetInterface *interface, NetLinkChangeCallback callback, void *param)
 Unregister link change callback. More...
 
void netProcessLinkChange (NetInterface *interface)
 Process link state change event. More...
 
error_t netAttachTimerCallback (systime_t period, NetTimerCallback callback, void *param)
 Register timer callback. More...
 
error_t netDetachTimerCallback (NetTimerCallback callback, void *param)
 Unregister timer callback. More...
 
void netTick (void)
 Manage TCP/IP timers. More...
 
void netStartTimer (NetTimer *timer, systime_t interval)
 Start timer. More...
 
void netStopTimer (NetTimer *timer)
 Stop timer. More...
 
bool_t netTimerRunning (NetTimer *timer)
 Check whether the timer is running. More...
 
bool_t netTimerExpired (NetTimer *timer)
 Check whether the timer has expired. More...
 
void netInitRand (void)
 Initialize random number generator. More...
 
uint32_t netGenerateRand (void)
 Generate a random 32-bit value. More...
 
uint32_t netGenerateRandRange (uint32_t min, uint32_t max)
 Generate a random value in the specified range. More...
 
void netGenerateRandData (uint8_t *data, size_t length)
 Get a string of random data. More...
 
uint32_t netGenerateRandBit (NetRandState *state)
 Generate one random bit. More...
 

Variables

const NetTxAncillary NET_DEFAULT_TX_ANCILLARY
 
const NetRxAncillary NET_DEFAULT_RX_ANCILLARY
 

Detailed Description

Helper functions for TCP/IP stack.

License

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

Copyright (C) 2010-2024 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
2.4.0

Definition in file net_misc.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   NIC_TRACE_LEVEL

Definition at line 32 of file net_misc.c.

Function Documentation

◆ netAttachLinkChangeCallback()

error_t netAttachLinkChangeCallback ( NetInterface interface,
NetLinkChangeCallback  callback,
void *  param 
)

Register link change callback.

Parameters
[in]interfaceUnderlying network interface
[in]callbackCallback function to be called when the link state changed
[in]paramCallback function parameter
Returns
Error code

Definition at line 127 of file net_misc.c.

◆ netAttachTimerCallback()

error_t netAttachTimerCallback ( systime_t  period,
NetTimerCallback  callback,
void *  param 
)

Register timer callback.

Parameters
[in]periodTimer reload value, in milliseconds
[in]callbackCallback function to be called when the timer expires
[in]paramCallback function parameter
Returns
Error code

Definition at line 344 of file net_misc.c.

◆ netDetachLinkChangeCallback()

error_t netDetachLinkChangeCallback ( NetInterface interface,
NetLinkChangeCallback  callback,
void *  param 
)

Unregister link change callback.

Parameters
[in]interfaceUnderlying network interface
[in]callbackCallback function to be unregistered
[in]paramCallback function parameter
Returns
Error code

Definition at line 165 of file net_misc.c.

◆ netDetachTimerCallback()

error_t netDetachTimerCallback ( NetTimerCallback  callback,
void *  param 
)

Unregister timer callback.

Parameters
[in]callbackCallback function to be unregistered
[in]paramCallback function parameter
Returns
Error code

Definition at line 382 of file net_misc.c.

◆ netGenerateRand()

uint32_t netGenerateRand ( void  )

Generate a random 32-bit value.

Returns
Random value

Definition at line 888 of file net_misc.c.

◆ netGenerateRandBit()

uint32_t netGenerateRandBit ( NetRandState state)

Generate one random bit.

Parameters
[in]statePointer to the PRNG state
Returns
Key stream bit

Definition at line 969 of file net_misc.c.

◆ netGenerateRandData()

void netGenerateRandData ( uint8_t *  data,
size_t  length 
)

Get a string of random data.

Parameters
[out]dataBuffer where to store random data
[in]lengthNumber of random bytes to generate

Definition at line 941 of file net_misc.c.

◆ netGenerateRandRange()

uint32_t netGenerateRandRange ( uint32_t  min,
uint32_t  max 
)

Generate a random value in the specified range.

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

Definition at line 914 of file net_misc.c.

◆ netInitRand()

void netInitRand ( void  )

Initialize random number generator.

Definition at line 832 of file net_misc.c.

◆ netProcessLinkChange()

void netProcessLinkChange ( NetInterface interface)

Process link state change event.

Parameters
[in]interfaceUnderlying network interface

Definition at line 198 of file net_misc.c.

◆ netStartTimer()

void netStartTimer ( NetTimer timer,
systime_t  interval 
)

Start timer.

Parameters
[in]timerPointer to the timer structure
[in]intervalTime interval

Definition at line 763 of file net_misc.c.

◆ netStopTimer()

void netStopTimer ( NetTimer timer)

Stop timer.

Parameters
[in]timerPointer to the timer structure

Definition at line 777 of file net_misc.c.

◆ netTick()

void netTick ( void  )

Manage TCP/IP timers.

Definition at line 413 of file net_misc.c.

◆ netTimerExpired()

bool_t netTimerExpired ( NetTimer timer)

Check whether the timer has expired.

Parameters
[in]timerPointer to the timer structure
Returns
TRUE if the timer has expired, else FALSE

Definition at line 803 of file net_misc.c.

◆ netTimerRunning()

bool_t netTimerRunning ( NetTimer timer)

Check whether the timer is running.

Parameters
[in]timerPointer to the timer structure
Returns
TRUE if the timer is running, else FALSE

Definition at line 790 of file net_misc.c.

Variable Documentation

◆ NET_DEFAULT_RX_ANCILLARY

const NetRxAncillary NET_DEFAULT_RX_ANCILLARY
Initial value:
=
{
0,
0,
{{{0}}},
{{{0}}},
0,
0,
{0},
}

Definition at line 101 of file net_misc.c.

◆ NET_DEFAULT_TX_ANCILLARY

const NetTxAncillary NET_DEFAULT_TX_ANCILLARY
Initial value:
=
{
0,
0,
{{{0}}},
{{{0}}},
-1,
-1,
-1,
-1,
0,
0,
-1,
}
#define IP_DEFAULT_DF
Definition: ip.h:40
#define FALSE
Definition: os_port.h:46

Definition at line 71 of file net_misc.c.