From aeb5b8fa0adcc4542de8666b90856f524287f931 Mon Sep 17 00:00:00 2001 From: Keith Wiles Date: Mon, 17 Jun 2024 15:51:29 -0500 Subject: [PATCH 1/2] bump version for latest fixes Signed-off-by: Keith Wiles --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 94c0153b..3e82b963 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -23.11.0 +24.06.0 From 75ba0782e63969fb97fca7ca4ea96fb20660e35d Mon Sep 17 00:00:00 2001 From: Jalal Mostafa Date: Wed, 19 Jun 2024 16:40:51 +0200 Subject: [PATCH 2/2] tcp-chnl: add TCP connection established callback for connect and accept The commit adds calls the TCP connection callback for clients when they establish a connection i.e. the connection is ready to send and receive data. To simplify things, `CHNL_TCP_ACCEPT_TYPE` is renamed to `CHNL_TCP_ESTABLISHED_TYPE`. The callback type is used for both server's `accept` and client's `connect`. In case of accept, the listening channel descriptor is passed to the callback. In case of connect, the client channel descriptor is passed. Signed-off-by: Jalal Mostafa --- doc/guides/sample_app_ug/cnet_graph.rst | 14 +++++++------- lib/cnet/chnl/cnet_chnl.h | 12 ++++++------ lib/cnet/tcp/cnet_tcp.c | 4 +++- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/doc/guides/sample_app_ug/cnet_graph.rst b/doc/guides/sample_app_ug/cnet_graph.rst index 3102e097..8e25acef 100644 --- a/doc/guides/sample_app_ug/cnet_graph.rst +++ b/doc/guides/sample_app_ug/cnet_graph.rst @@ -219,13 +219,13 @@ The channel callback types are shown below: .. code-block:: c /** Channel callback types */ - typedef enum { - CHNL_UDP_RECV_TYPE, /**< Callback for receiving UDP packets */ - CHNL_UDP_CLOSE_TYPE, /**< Callback for UDP close */ - CHNL_TCP_ACCEPT_TYPE, /**< Callback type for accepting TCP connection */ - CHNL_TCP_RECV_TYPE, /**< Callback for receiving TCP packets */ - CHNL_TCP_CLOSE_TYPE, /**< Callback for TCP close */ - CHNL_CALLBACK_TYPES /**< Maximum number of callback types */ + typedef enum { + CHNL_UDP_RECV_TYPE, /**< Callback for receiving UDP packets */ + CHNL_UDP_CLOSE_TYPE, /**< Callback for UDP close */ + CHNL_TCP_ESTABLISHED_TYPE, /**< Callback for when TCP is established: `accept` or `connect` */ + CHNL_TCP_RECV_TYPE, /**< Callback for receiving TCP packets */ + CHNL_TCP_CLOSE_TYPE, /**< Callback for TCP close */ + CHNL_CALLBACK_TYPES /**< Maximum number of callback types */ } chnl_type_t; Packet Forwarding using Graph Walk diff --git a/lib/cnet/chnl/cnet_chnl.h b/lib/cnet/chnl/cnet_chnl.h index def19f95..45563caf 100644 --- a/lib/cnet/chnl/cnet_chnl.h +++ b/lib/cnet/chnl/cnet_chnl.h @@ -65,12 +65,12 @@ enum { /** Channel callback types */ typedef enum { - CHNL_UDP_RECV_TYPE, /**< Callback for receiving UDP packets */ - CHNL_UDP_CLOSE_TYPE, /**< Callback for UDP close */ - CHNL_TCP_ACCEPT_TYPE, /**< Callback type for accepting TCP connection */ - CHNL_TCP_RECV_TYPE, /**< Callback for receiving TCP packets */ - CHNL_TCP_CLOSE_TYPE, /**< Callback for TCP close */ - CHNL_CALLBACK_TYPES /**< Maximum number of callback types */ + CHNL_UDP_RECV_TYPE, /**< Callback for receiving UDP packets */ + CHNL_UDP_CLOSE_TYPE, /**< Callback for UDP close */ + CHNL_TCP_ESTABLISHED_TYPE, /**< Callback for when TCP is established: `accept` or `connect` */ + CHNL_TCP_RECV_TYPE, /**< Callback for receiving TCP packets */ + CHNL_TCP_CLOSE_TYPE, /**< Callback for TCP close */ + CHNL_CALLBACK_TYPES /**< Maximum number of callback types */ } chnl_type_t; /** diff --git a/lib/cnet/tcp/cnet_tcp.c b/lib/cnet/tcp/cnet_tcp.c index 350701c4..6ee823b4 100644 --- a/lib/cnet/tcp/cnet_tcp.c +++ b/lib/cnet/tcp/cnet_tcp.c @@ -1389,8 +1389,10 @@ tcp_do_state_change(struct pcb_entry *pcb, int32_t new_state) cnet_tcp_abort(pcb); CNE_ERR("Failed to enqueue PCB to backlog queue\n"); } - pcb->ch->ch_callback(CHNL_TCP_ACCEPT_TYPE, tcb->ppcb->ch->ch_cd); + pcb->ch->ch_callback(CHNL_TCP_ESTABLISHED_TYPE, tcb->ppcb->ch->ch_cd); } + } else { + pcb->ch->ch_callback(CHNL_TCP_ESTABLISHED_TYPE, pcb->ch->ch_cd); } tcb->idle = 0;