net_misc.h
Go to the documentation of this file.
1 /**
2  * @file net_misc.h
3  * @brief Helper functions for TCP/IP stack
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2020 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneTCP Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 1.9.8
29  **/
30 
31 #ifndef _NET_MISC_H
32 #define _NET_MISC_H
33 
34 //Forward declaration of NetTxAncillary structure
35 struct _NetTxAncillary;
36 #define NetTxAncillary struct _NetTxAncillary
37 
38 //Forward declaration of NetRxAncillary structure
39 struct _NetRxAncillary;
40 #define NetRxAncillary struct _NetRxAncillary
41 
42 //Dependencies
43 #include "core/net.h"
44 #include "core/ethernet.h"
45 #include "core/ip.h"
46 
47 //C++ guard
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
51 
52 
53 /**
54  * @brief Link change callback
55  **/
56 
57 typedef void (*NetLinkChangeCallback)(NetInterface *interface,
58  bool_t linkState, void *param);
59 
60 
61 /**
62  * @brief Link change callback entry
63  **/
64 
65 typedef struct
66 {
69  void *param;
71 
72 
73 /**
74  * @brief Timer callback
75  **/
76 
77 typedef void (*NetTimerCallback)(void *param);
78 
79 
80 /**
81  * @brief Timer callback entry
82  **/
83 
84 typedef struct
85 {
89  void *param;
91 
92 
93 /**
94  * @brief Timestamp
95  **/
96 
97 typedef struct
98 {
99  uint32_t s;
100  uint32_t ns;
101 } NetTimestamp;
102 
103 
104 /**
105  * @brief Additional options passed to the stack (TX path)
106  **/
107 
109 {
110  uint8_t ttl; ///<Time-to-live value
111  bool_t dontRoute; ///<Do not send the packet via a router
112 #if (IP_DIFF_SERV_SUPPORT == ENABLED)
113  uint8_t dscp; ///<Differentiated services codepoint
114 #endif
115 #if (ETH_SUPPORT == ENABLED)
116  MacAddr srcMacAddr; ///<Source MAC address
117  MacAddr destMacAddr; ///<Destination MAC address
118 #endif
119 #if (ETH_VLAN_SUPPORT == ENABLED)
120  int8_t vlanPcp; ///<VLAN priority (802.1Q)
121  int8_t vlanDei; ///<Drop eligible indicator
122 #endif
123 #if (ETH_VMAN_SUPPORT == ENABLED)
124  int8_t vmanPcp; ///<VMAN priority (802.1ad)
125  int8_t vmanDei; ///<Drop eligible indicator
126 #endif
127 #if (ETH_PORT_TAGGING_SUPPORT == ENABLED)
128  uint8_t port; ///<Switch port identifier
129 #endif
130 #if (ETH_TIMESTAMP_SUPPORT == ENABLED)
131  int32_t timestampId; ///<Unique identifier for hardware time stamping
132 #endif
133 };
134 
135 
136 /**
137  * @brief Additional options passed to the stack (RX path)
138  **/
139 
141 {
142  uint8_t ttl; ///<Time-to-live value
143 #if (ETH_SUPPORT == ENABLED)
144  MacAddr srcMacAddr; ///<Source MAC address
145  MacAddr destMacAddr; ///<Destination MAC address
146 #endif
147 #if (ETH_PORT_TAGGING_SUPPORT == ENABLED)
148  uint8_t port; ///<Switch port identifier
149 #endif
150 #if (ETH_TIMESTAMP_SUPPORT == ENABLED)
151  NetTimestamp timestamp; ///<Captured time stamp
152 #endif
153 };
154 
155 
156 //Global constants
159 
160 //TCP/IP stack related functions
162  NetLinkChangeCallback callback, void *param);
163 
165  NetLinkChangeCallback callback, void *param);
166 
167 void netProcessLinkChange(NetInterface *interface);
168 
170  void *param);
171 
172 error_t netDetachTimerCallback(NetTimerCallback callback, void *param);
173 
174 void netTick(void);
175 
176 //C++ guard
177 #ifdef __cplusplus
178 }
179 #endif
180 
181 #endif
NetTimerCallback callback
Definition: net_misc.h:88
error_t netAttachTimerCallback(systime_t period, NetTimerCallback callback, void *param)
Register timer callback.
Definition: net_misc.c:337
int bool_t
Definition: compiler_port.h:49
systime_t timerPeriod
Definition: net_misc.h:87
systime_t timerValue
Definition: net_misc.h:86
__start_packed struct @5 MacAddr
MAC address.
uint8_t dscp
Differentiated services codepoint.
Definition: net_misc.h:113
const NetRxAncillary NET_DEFAULT_RX_ANCILLARY
Definition: net_misc.c:96
void * param
Definition: net_misc.h:89
void * param
Definition: net_misc.h:69
error_t netDetachTimerCallback(NetTimerCallback callback, void *param)
Unregister timer callback.
Definition: net_misc.c:375
Ethernet.
bool_t dontRoute
Do not send the packet via a router.
Definition: net_misc.h:111
void(* NetLinkChangeCallback)(NetInterface *interface, bool_t linkState, void *param)
Link change callback.
Definition: net_misc.h:57
uint8_t ttl
Time-to-live value.
Definition: net_misc.h:142
Timestamp.
Definition: net_misc.h:97
error_t
Error codes.
Definition: error.h:42
MacAddr srcMacAddr
Source MAC address.
Definition: net_misc.h:144
uint8_t ttl
Time-to-live value.
Definition: net_misc.h:110
Timer callback entry.
Definition: net_misc.h:84
MacAddr srcMacAddr
Source MAC address.
Definition: net_misc.h:116
Additional options passed to the stack (TX path)
Definition: net_misc.h:108
#define NetRxAncillary
Definition: net_misc.h:40
#define NetInterface
Definition: net.h:36
int8_t vmanDei
Drop eligible indicator.
Definition: net_misc.h:125
void netTick(void)
Manage TCP/IP timers.
Definition: net_misc.c:406
NetInterface * interface
Definition: net_misc.h:67
#define NetTxAncillary
Definition: net_misc.h:36
Additional options passed to the stack (RX path)
Definition: net_misc.h:140
int8_t vmanPcp
VMAN priority (802.1ad)
Definition: net_misc.h:124
MacAddr destMacAddr
Destination MAC address.
Definition: net_misc.h:117
error_t netDetachLinkChangeCallback(NetInterface *interface, NetLinkChangeCallback callback, void *param)
Unregister link change callback.
Definition: net_misc.c:158
uint8_t port
Switch port identifier.
Definition: net_misc.h:128
int8_t vlanPcp
VLAN priority (802.1Q)
Definition: net_misc.h:120
MacAddr destMacAddr
Destination MAC address.
Definition: net_misc.h:145
uint8_t port
Switch port identifier.
Definition: net_misc.h:148
NetLinkChangeCallback callback
Definition: net_misc.h:68
IPv4 and IPv6 common routines.
Link change callback entry.
Definition: net_misc.h:65
void netProcessLinkChange(NetInterface *interface)
Process link state change event.
Definition: net_misc.c:191
const NetTxAncillary NET_DEFAULT_TX_ANCILLARY
Definition: net_misc.c:68
uint32_t ns
Definition: net_misc.h:100
TCP/IP stack core.
error_t netAttachLinkChangeCallback(NetInterface *interface, NetLinkChangeCallback callback, void *param)
Register link change callback.
Definition: net_misc.c:120
NetTimestamp timestamp
Captured time stamp.
Definition: net_misc.h:151
uint32_t s
Definition: net_misc.h:99
uint32_t systime_t
Definition: compiler_port.h:46
int8_t vlanDei
Drop eligible indicator.
Definition: net_misc.h:121
void(* NetTimerCallback)(void *param)
Timer callback.
Definition: net_misc.h:77
int32_t timestampId
Unique identifier for hardware time stamping.
Definition: net_misc.h:131