CNDP 22.08.0
Loading...
Searching...
No Matches
cnet_protosw.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_PROTOSW_H
6#define __CNET_PROTOSW_H
7
12
13#include <stdint.h> // for uint16_t, uint8_t
14#include <stdio.h> // for size_t
15#include <sys/types.h> // for ssize_t
16
17#include "cnet_const.h" // for proto_input_t
18#ifdef __cplusplus
19extern "C" {
20#endif
21
22#define CNET_MAX_IPPROTO 256
23#define PROTOSW_WILDCARD 0xFFFF
24
25struct in_caddr;
26struct chnl;
27struct cne_vec;
28struct stk_s;
29
30/*
31 * protoFuncs_t - structure to hold all of the protocol function pointers.
32 *
33 * Each function pointer must have a valid value, which means may have to set
34 * the function pointer to the nullProtocol routine, if not supported.
35 *
36 * The following functions are called as indicated below.
37 */
38typedef int (*close_func_t)(struct chnl *ch);
39typedef int (*send_func_t)(struct chnl *ch, pktmbuf_t **mbufs, uint16_t nb_mbufs);
40typedef int (*recv_func_t)(struct chnl *ch, pktmbuf_t **mbufs, int nb_mbufs);
41typedef int (*bind_func_t)(struct chnl *ch, struct in_caddr *pAddr, int len);
42typedef int (*connect_func_t)(struct chnl *ch, struct in_caddr *to, int slen);
43typedef int (*shutdown_func_t)(struct chnl *ch, int how);
44typedef int (*accept_func_t)(struct chnl *ch, struct in_caddr *addr, int *addrlen);
45typedef int (*listen_func_t)(struct chnl *ch, int backlog);
46
47struct proto_funcs {
48 close_func_t close_func;
49 recv_func_t recv_func;
50 send_func_t send_func;
51 bind_func_t bind_func;
52 connect_func_t connect_func;
53 shutdown_func_t shutdown_func;
54 accept_func_t accept_func;
55 listen_func_t listen_func;
56};
57
58/*
59 * protosw_t - Protocol switch structure to hold all of the different types
60 */
61struct protosw_entry {
62 char name[14];
63 uint16_t domain;
64 uint16_t type;
65 uint16_t proto;
66 pktmbuf_t **vec;
67 struct proto_funcs *funcs;
68};
69
84CNDP_API struct protosw_entry *cnet_protosw_add(const char *name, uint16_t domain, uint16_t type,
85 uint16_t proto);
86
99CNDP_API struct protosw_entry *cnet_protosw_find(uint16_t domain, uint16_t type, uint16_t proto);
100
109CNDP_API void cnet_protosw_dump(struct stk_s *stk);
110
121CNDP_API int cnet_ipproto_set(uint8_t ipproto, struct protosw_entry *psw);
122
131CNDP_API struct protosw_entry *cnet_ipproto_get(uint8_t ipproto);
132
141CNDP_API struct protosw_entry *cnet_protosw_find_by_proto(uint8_t proto);
142
143#ifdef __cplusplus
144}
145#endif
146
147#endif /* __CNET_PROTOSW_H */
CNDP_API int cnet_ipproto_set(uint8_t ipproto, struct protosw_entry *psw)
Set the IP proto value in the given protosw_entry pointer.
CNDP_API struct protosw_entry * cnet_protosw_find_by_proto(uint8_t proto)
Find a protocol switch entry using the IP proto type.
CNDP_API void cnet_protosw_dump(struct stk_s *stk)
Dump out the list of protocol switch values.
CNDP_API struct protosw_entry * cnet_ipproto_get(uint8_t ipproto)
Get the protosw_entry to locate using the IP proto type.
CNDP_API struct protosw_entry * cnet_protosw_find(uint16_t domain, uint16_t type, uint16_t proto)
Find a protocol entry in the protocol switch list.
CNDP_API struct protosw_entry * cnet_protosw_add(const char *name, uint16_t domain, uint16_t type, uint16_t proto)
Add protocol information to the list of protocol switch list.