Blog
Community
Development
Documentation
CNDP
22.08.0
Toggle main menu visibility
Loading...
Searching...
No Matches
cnet_pcb.h
Go to the documentation of this file.
1
/* SPDX-License-Identifier: BSD-3-Clause
2
* Copyright (c) 2016-2022 Intel Corporation
3
*/
4
5
#ifndef __CNET_PCB_H
6
#define __CNET_PCB_H
7
12
13
#include <
cne_inet.h
>
// for in_caddr
14
#include <stdint.h>
// for uint16_t, uint8_t, int32_t
15
#include <string.h>
// for NULL, memset
16
17
#include "
cne_common.h
"
// for __cne_aligned, __cne_cache_aligned
18
#include "
cne_log.h
"
// for CNE_LOG, CNE_LOG_DEBUG
19
#include "cne_vec.h"
// for cne_vec (ptr only), vec_add_ptr, vec_alloc_ptr, vec...
20
#include "
cnet_const.h
"
// for BEST_MATCH
21
#include "
cnet_stk.h
"
// for per_thread_stk, stk_entry, this_stk
22
#include "
mempool.h
"
// for mempool_put, mempool_get
23
24
#ifdef __cplusplus
25
extern
"C"
{
26
#endif
27
28
struct
pcb_key {
29
struct
in_caddr
faddr
;
30
struct
in_caddr
laddr
;
31
}
__cne_aligned
(
sizeof
(
void
*));
32
33
struct
netif;
34
struct
chnl;
35
struct
tcb_entry;
36
37
struct
pcb_entry {
38
TAILQ_ENTRY(pcb_entry) next;
39
struct
pcb_key key;
40
struct
netif *netif;
41
struct
chnl *ch;
42
struct
tcb_entry *tcb;
43
uint16_t opt_flag;
44
uint8_t ttl;
45
uint8_t tos;
46
uint8_t closed;
47
uint8_t ip_proto;
48
}
__cne_cache_aligned
;
49
50
struct
pcb_hd {
51
struct
pcb_entry **vec;
52
uint16_t local_port;
53
};
54
55
static
inline
void
56
cnet_pcb_free(
struct
pcb_entry *pcb)
57
{
58
if
(pcb) {
59
memset(pcb, 0,
sizeof
(
struct
pcb_entry));
60
pcb->closed = 1;
61
pcb->ip_proto = -1;
62
mempool_put
(this_stk->pcb_objs, (
void
*)pcb);
63
}
64
}
65
66
static
inline
struct
pcb_entry *
67
cnet_pcb_alloc(
struct
pcb_hd *hd, uint16_t proto)
68
{
69
struct
pcb_entry *pcb;
70
71
if
(
mempool_get
(this_stk->pcb_objs, (
void
*)&pcb) < 0)
72
return
NULL;
73
74
pcb->closed = 0;
75
pcb->ip_proto = proto;
76
77
vec_add(hd->vec, pcb);
78
79
return
pcb;
80
}
81
82
static
inline
void
83
cnet_pcb_delete(
struct
pcb_hd *hd,
struct
pcb_entry *pcb)
84
{
85
struct
pcb_entry *p;
86
87
vec_foreach_ptr (p, hd->vec) {
88
if
(p == pcb) {
89
cnet_pcb_free(pcb);
90
break
;
91
}
92
}
93
}
94
130
CNDP_API
struct
pcb_entry *
cnet_pcb_lookup
(
struct
pcb_hd *hd,
struct
pcb_key *key, int32_t flags);
131
140
CNDP_API
void
cnet_pcb_dump
(stk_t *stk);
141
148
CNDP_API
void
cnet_pcb_show
(
struct
pcb_entry *pcb);
149
162
static
inline
struct
pcb_entry *
163
cnet_pcb_locate
(
struct
pcb_hd *hd,
struct
in_caddr *
faddr
,
struct
in_caddr *
laddr
)
164
{
165
struct
pcb_key key;
166
167
*(
struct
in_caddr *)&key.faddr = *
faddr
;
168
*(
struct
in_caddr *)&key.laddr = *
laddr
;
169
170
return
cnet_pcb_lookup
(hd, &key, BEST_MATCH);
171
}
172
173
#ifdef __cplusplus
174
}
175
#endif
176
177
#endif
/* __CNET_PCB_H */
cne_common.h
__cne_aligned
#define __cne_aligned(a)
Definition
cne_common.h:124
__cne_cache_aligned
#define __cne_cache_aligned
Definition
cne_common.h:379
cne_inet.h
cne_log.h
cnet_const.h
cnet_pcb_lookup
CNDP_API struct pcb_entry * cnet_pcb_lookup(struct pcb_hd *hd, struct pcb_key *key, int32_t flags)
faddr
struct in_caddr faddr
Definition
cnet_pcb.h:0
cnet_pcb_show
CNDP_API void cnet_pcb_show(struct pcb_entry *pcb)
cnet_pcb_dump
CNDP_API void cnet_pcb_dump(stk_t *stk)
Dump out the PCB information.
laddr
struct in_caddr laddr
Definition
cnet_pcb.h:1
cnet_pcb_locate
static struct pcb_entry * cnet_pcb_locate(struct pcb_hd *hd, struct in_caddr *faddr, struct in_caddr *laddr)
Return the PCB entry matching the given information.
Definition
cnet_pcb.h:163
cnet_stk.h
mempool.h
mempool_get
CNDP_API int mempool_get(mempool_t *mp, void **obj_p)
mempool_put
CNDP_API void mempool_put(mempool_t *mp, void *obj)
lib
cnet
pcb
cnet_pcb.h
Generated by
1.18.0