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;