CNDP  22.08.0
cnet_chnl.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_CHNL_H
6 #define __CNET_CHNL_H
7 
13 #include <stdio.h> // for snprintf, size_t, NULL
14 #include <sys/socket.h> // for socklen_t, PF_INET, PF_INET6, PF_LOCAL
15 #include <sys/queue.h> // for TAILQ_ENTRY
16 #include <netinet/in.h> // for IPPROTO_ICMP, IPPROTO_ICMPV6, IPPROTO_IGMP
17 #include <bsd/bitstring.h>
18 #include <pktmbuf.h>
19 #include <cnet_const.h> // for _SELREAD, is_set, _SELWRITE
20 #include <cne_vec.h>
21 #include <cnet_protosw.h> // for protosw_entry
22 #include <cne_graph_worker.h>
23 #include <pthread.h> // for pthread_mutex_t, pthread_cond_t
24 #include <stdint.h> // for uint16_t, int32_t, uint32_t, uintptr_t
25 #include <sys/types.h> // for ssize_t
26 
27 #include "cne_log.h" // for CNE_LOG, CNE_LOG_DEBUG, CNE_LOG_ERR
28 #include "cnet_tcp.h" // for TCP_NORMAL_MSS
29 #include "cnet_udp.h" // for _IPPORT_RESERVED
30 
31 struct in_caddr;
32 struct netif;
33 struct stk_s;
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
39 #ifndef __CHNL_PRIV_H
50 typedef int (*chnl_cb_t)(int chnl_type, int cd);
51 #endif
52 
53 #define CHNL_ENABLE_UDP_CHECKSUM (1 << 0)
55 #define SO_CHANNEL 1
56 #define SO_UDP_CHKSUM 1024
57 #define IP_DONTFRAG 1025
58 
59 enum {
60  SHUT_BIT_RD = 0x01,
61  SHUT_BIT_WR = 0x02,
62  SHUT_BIT_RDWR = 0x03,
63 };
64 
66 typedef enum {
74 
83 CNDP_API void chnl_dump(const char *msg, struct chnl *ch);
84 
97 CNDP_API int chnl_connect_common(struct chnl *ch, struct in_caddr *to, int32_t tolen);
98 
113 CNDP_API int chnl_bind_common(struct chnl *ch, struct in_caddr *pAddr, int32_t len,
114  struct pcb_hd *pHd);
115 
130 CNDP_API int channel(int domain, int type, int proto, chnl_cb_t cb);
131 
144 CNDP_API int chnl_bind(int cd, struct sockaddr *addr, int addrlen);
145 
156 CNDP_API int chnl_listen(int cd, int backlog);
157 
170 CNDP_API int chnl_accept(int cd, struct sockaddr *sa, socklen_t *addrlen);
171 
184 CNDP_API int chnl_connect(int cd, struct sockaddr *sa, int addrlen);
185 
201 CNDP_API int chnl_recv(int cd, pktmbuf_t **mbufs, size_t len);
202 
240 CNDP_API int chnl_send(int cd, pktmbuf_t **mbufs, uint16_t nb_mbufs);
241 
256 CNDP_API int chnl_sendto(int cd, struct sockaddr *sa, pktmbuf_t **mbufs, uint16_t nb_mbufs);
257 
278 CNDP_API int chnl_getchnlname(int cd, struct sockaddr *name, socklen_t *namelen);
279 
300 CNDP_API int chnl_getpeername(int cd, struct sockaddr *sa, socklen_t *salen);
301 
310 CNDP_API int chnl_close(int cd);
311 
322 CNDP_API int chnl_shutdown(int cd, int how);
323 
348 CNDP_API int chnl_open(const char *str, int flags, chnl_cb_t fn);
349 
350 #ifdef __cplusplus
351 }
352 #endif
353 
354 #endif /* __CNET_CHNL_H */
CNDP_API int chnl_connect_common(struct chnl *ch, struct in_caddr *to, int32_t tolen)
Common channel connect routine used by protocols.
CNDP_API int chnl_open(const char *str, int flags, chnl_cb_t fn)
chnl_type_t
Definition: cnet_chnl.h:66
@ CHNL_TCP_CLOSE_TYPE
Definition: cnet_chnl.h:71
@ CHNL_UDP_CLOSE_TYPE
Definition: cnet_chnl.h:68
@ CHNL_UDP_RECV_TYPE
Definition: cnet_chnl.h:67
@ CHNL_TCP_RECV_TYPE
Definition: cnet_chnl.h:70
@ CHNL_CALLBACK_TYPES
Definition: cnet_chnl.h:72
@ CHNL_TCP_ACCEPT_TYPE
Definition: cnet_chnl.h:69
CNDP_API int chnl_shutdown(int cd, int how)
Shutdown a channel connection similar to 'shutdown()'.
int(* chnl_cb_t)(int chnl_type, int cd)
Definition: cnet_chnl.h:50
CNDP_API int chnl_getchnlname(int cd, struct sockaddr *name, socklen_t *namelen)
CNDP_API int chnl_recv(int cd, pktmbuf_t **mbufs, size_t len)
CNDP_API int chnl_connect(int cd, struct sockaddr *sa, int addrlen)
Connect to a channel, similar to 'connect()'.
CNDP_API int chnl_bind(int cd, struct sockaddr *addr, int addrlen)
Bind an address to a channel similar to 'bind()'.
CNDP_API int chnl_bind_common(struct chnl *ch, struct in_caddr *pAddr, int32_t len, struct pcb_hd *pHd)
Channel Bind common routine used by protocols.
CNDP_API int channel(int domain, int type, int proto, chnl_cb_t cb)
The routine to create a channel structure similar to 'socket()'.
CNDP_API int chnl_listen(int cd, int backlog)
Listen on a channel similar to 'listen()'.
@ SHUT_BIT_RDWR
Definition: cnet_chnl.h:62
@ SHUT_BIT_RD
Definition: cnet_chnl.h:60
@ SHUT_BIT_WR
Definition: cnet_chnl.h:61
CNDP_API void chnl_dump(const char *msg, struct chnl *ch)
Dump out a channel structure.
CNDP_API int chnl_sendto(int cd, struct sockaddr *sa, pktmbuf_t **mbufs, uint16_t nb_mbufs)
Send data to a channel similar to 'sendto()'.
CNDP_API int chnl_getpeername(int cd, struct sockaddr *sa, socklen_t *salen)
CNDP_API int chnl_accept(int cd, struct sockaddr *sa, socklen_t *addrlen)
Accept on a channel similar to 'accept()'.
CNDP_API int chnl_send(int cd, pktmbuf_t **mbufs, uint16_t nb_mbufs)
CNDP_API int chnl_close(int cd)