net_misc.h File Reference

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

#include "core/net.h"
#include "core/ethernet.h"
#include "core/ip.h"

Go to the source code of this file.

Data Structures

struct  NetLinkChangeCallbackEntry
 Link change callback entry. More...
 
struct  NetTimerCallbackEntry
 Timer callback entry. More...
 
struct  NetTimestamp
 Timestamp. More...
 
struct  _NetTxAncillary
 Additional options passed to the stack (TX path) More...
 
struct  _NetRxAncillary
 Additional options passed to the stack (RX path) More...
 
struct  NetTimer
 Timer. More...
 
struct  NetRandState
 Pseudo-random number generator state. More...
 

Macros

#define NetTxAncillary   struct _NetTxAncillary
 
#define NetRxAncillary   struct _NetRxAncillary
 
#define NET_RAND_GET_BIT(s, n)   ((s[(n - 1) / 8] >> ((n - 1) % 8)) & 1)
 
#define NET_RAND_STATE_SET_BIT(s, n, v)
 

Typedefs

typedef void(* NetLinkChangeCallback) (NetInterface *interface, bool_t linkState, void *param)
 Link change callback. More...
 
typedef void(* NetTimerCallback) (void *param)
 Timer callback. More...
 

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.h.

Macro Definition Documentation

◆ NET_RAND_GET_BIT

#define NET_RAND_GET_BIT (   s,
  n 
)    ((s[(n - 1) / 8] >> ((n - 1) % 8)) & 1)

Definition at line 48 of file net_misc.h.

◆ NET_RAND_STATE_SET_BIT

#define NET_RAND_STATE_SET_BIT (   s,
  n,
 
)
Value:
s[(n - 1) / 8] = \
(s[(n - 1) / 8] & ~(1 << ((n - 1) % 8))) | (v) << ((n - 1) % 8)
uint8_t n
uint8_t s
Definition: ndp.h:345

Definition at line 51 of file net_misc.h.

◆ NetRxAncillary

#define NetRxAncillary   struct _NetRxAncillary

Definition at line 40 of file net_misc.h.

◆ NetTxAncillary

#define NetTxAncillary   struct _NetTxAncillary

Definition at line 36 of file net_misc.h.

Typedef Documentation

◆ NetLinkChangeCallback

typedef void(* NetLinkChangeCallback) (NetInterface *interface, bool_t linkState, void *param)

Link change callback.

Definition at line 64 of file net_misc.h.

◆ NetTimerCallback

typedef void(* NetTimerCallback) (void *param)

Timer callback.

Definition at line 84 of file net_misc.h.

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
extern

Definition at line 101 of file net_misc.c.

◆ NET_DEFAULT_TX_ANCILLARY

const NetTxAncillary NET_DEFAULT_TX_ANCILLARY
extern

Definition at line 71 of file net_misc.c.