Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tcp-chnl: add TCP connection established callback for connect and accept #372

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions doc/guides/sample_app_ug/cnet_graph.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions lib/cnet/chnl/cnet_chnl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down
4 changes: 3 additions & 1 deletion lib/cnet/tcp/cnet_tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading