13 #include <sys/types.h>
27 #define MS_PER_TICK 10
30 #define is_set(x, y) (((x) & (y)) != 0)
31 #define is_clr(x, y) (((x) & (y)) == 0)
33 #define PROTO_DEFAULT_MBUF_COUNT 1024
34 #define _IPPORT_RESERVED 49152
39 #define __cnet_no_return __attribute__((__no_return__))
44 #define __cnet_attribute(...) __attribute__((__VA_ARGS__))
46 #ifdef CNET_ASSERT_ENABLED
47 #define cnet_assert(x) assert(x)
49 #define cnet_assert(x) \
56 PROTOSW_MAX_SIZE = 64,
60 CNET_PRIORITY_0 = 0x0000,
61 CNET_PRIORITY_1 = 0x0100,
62 CNET_PRIORITY_2 = 0x0200,
63 CNET_PRIORITY_3 = 0x0300,
64 CNET_PRIORITY_4 = 0x0400,
65 CNET_PRIORITY_5 = 0x0500,
66 CNET_PRIORITY_6 = 0x0600,
67 CNET_PRIORITY_7 = 0x0700,
68 CNET_PRIORITY_8 = 0x0800,
69 CNET_PRIORITY_9 = 0x0900,
70 CNET_PRIORITY_10 = 0x0a00
75 CNET_STK_PRIO = (CNET_PRIORITY_1 + 1),
76 CNET_PROTOSW_PRIO = (CNET_PRIORITY_1 + 2),
78 CNET_IPV4_PRIO = (CNET_PRIORITY_2 + 0),
79 CNET_IPV6_PRIO = (CNET_PRIORITY_2 + 1),
80 CNET_ND_PRIO = (CNET_PRIORITY_2 + 2),
82 CNET_ICMP_PRIO = (CNET_PRIORITY_3 + 0),
83 CNET_ICMP6_PRIO = (CNET_PRIORITY_3 + 1),
84 CNET_RARP_PRIO = (CNET_PRIORITY_3 + 2),
86 CNET_PCB_PRIO = (CNET_PRIORITY_4 + 0),
87 CNET_UDP_PRIO = (CNET_PRIORITY_4 + 1),
88 CNET_TCP_PRIO = (CNET_PRIORITY_4 + 2),
89 CNET_RAW_PRIO = (CNET_PRIORITY_4 + 3),
91 CNET_CHNL_PRIO = (CNET_PRIORITY_5 + 0),
92 CNET_RAW_CHNL_PRIO = (CNET_PRIORITY_5 + 1),
93 CNET_UDP_CHNL_PRIO = (CNET_PRIORITY_5 + 2),
94 CNET_TCP_CHNL_PRIO = (CNET_PRIORITY_5 + 3),
95 CNET_ICMP_CHNL_PRIO = (CNET_PRIORITY_5 + 4),
96 CNET_ICMP6_CHNL_PRIO = (CNET_PRIORITY_5 + 5),
98 CNET_UTILS_PRIO = (CNET_PRIORITY_9 + 0),
99 CNET_CFG_PRIO = (CNET_PRIORITY_10),
104 TCP_VEC_PCB_COUNT = 32,
105 UDP_VEC_PCB_COUNT = 32,
106 RAW_VEC_PCB_COUNT = 32,
107 ICMP_VEC_PCB_COUNT = 32,
108 ICMP6_VEC_PCB_COUNT = 32,
109 CHNL_OPT_VEC_COUNT = 8,
113 typedef enum { EXACT_MATCH = 1, BEST_MATCH = 2, IPV6_TYPE = 0x80 } match_t;
115 typedef enum { CNET_INIT = 1, CNET_STOP, CNET_ALL } init_types_e;
128 typedef int (*cfunc_t)(
void *arg);
129 typedef int (*vfunc_t)(void);
131 typedef union iofunc_s {
132 void (*
generic)(void);
134 int (*netif)(
struct netif *netif);
135 int (*ifunc)(
struct netif *netif,
struct pktmbuf_s **vec);
136 void (*vfunc)(
struct netif *netif,
struct pktmbuf_s **vec);
137 int (*ioctl)(
struct netif *netif,
int cmd,
void *data);
139 int (*chfunc)(
struct chnl *ch,
struct pktmbuf_s **vec);
140 int (*tcbfunc)(
struct tcb_entry *tcb);
183 return errno = errorValue, (errorValue ? -1 : 0);
196 return errno = errorValue, NULL;
static void * __errno_set_null(int errorValue)
int(* proto_input_t)(struct netif *netif, struct pktmbuf_s **vec)
static int __errno_set(int errorValue)