Select one of the symbols to view example projects that use it.
 
Outline
...
...
...
...
#define NX_SOURCE_CODE
#include "nx_api.h"
#include "nx_ip.h"
#include "nx_tcp.h"
...
...
_nx_tcp_socket_state_established(NX_TCP_SOCKET *)
Files
loading...
CodeScopeSTM32 Libraries and Samplesnetxduocommon/src/nx_tcp_socket_state_established.c
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/**************************************************************************/ /* */ /* Copyright (c) Microsoft Corporation. All rights reserved. */ /* */ /* This software is licensed under the Microsoft Software License */ /* Terms for Microsoft Azure RTOS. Full text of the license can be */ /* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */ /* and in the root directory of this software. */ /* */... /**************************************************************************/ ... /**************************************************************************/ /**************************************************************************/ /** */ /** NetX Component */ /** */ /** Transmission Control Protocol (TCP) */ /** */... /**************************************************************************/ /**************************************************************************/ #define NX_SOURCE_CODE /* Include necessary system files. */ #include "nx_api.h" #include "nx_ip.h" #include "nx_tcp.h" ... /**************************************************************************/ /* */ /* FUNCTION RELEASE */ /* */ /* _nx_tcp_socket_state_established PORTABLE C */ /* 6.1 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ /* */ /* DESCRIPTION */ /* */ /* This function processes packets during the ESTABLISHED state, */ /* the state of the socket during typical TCP data sending and */ /* receiving. The expected packet that changes state once in the */ /* established state is the FIN packet. Reception of this will move */ /* the state for this socket to the CLOSE WAIT state. */ /* */ /* INPUT */ /* */ /* socket_ptr Pointer to owning socket */ /* */ /* OUTPUT */ /* */ /* None */ /* */ /* CALLS */ /* */ /* _nx_tcp_packet_send_ack Send ACK message */ /* (nx_tcp_disconnect_callback) Application's callback */ /* function when disconnect */ /* FIN is received */ /* */ /* CALLED BY */ /* */ /* _nx_tcp_socket_packet_process Process TCP packet for socket */ /* */ /* RELEASE HISTORY */ /* */ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ /* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ /* */... /**************************************************************************/ VOID _nx_tcp_socket_state_established(NX_TCP_SOCKET *socket_ptr) { #if !defined(NX_DISABLE_TCP_INFO) || defined(TX_ENABLE_EVENT_TRACE) NX_IP *ip_ptr; /* Setup the IP pointer. */ ip_ptr = socket_ptr -> nx_tcp_socket_ip_ptr;/* ... */ #endif /* Determine if a FIN has been previously detected in the _nx_tcp_socket_state_data_check routine and if the socket's sequence number matches the expected FIN sequence number. *//* ... */ if ((socket_ptr -> nx_tcp_socket_fin_received) && (socket_ptr -> nx_tcp_socket_fin_sequence == socket_ptr -> nx_tcp_socket_rx_sequence)) { #ifndef NX_DISABLE_TCP_INFO /* Increment the TCP disconnections count. */ ip_ptr -> nx_ip_tcp_disconnections++;/* ... */ #endif #ifdef NX_ENABLE_TCP_KEEPALIVE /* Is the keepalive feature enabled on this socket? */ if (socket_ptr -> nx_tcp_socket_keepalive_enabled) { /* Clear the TCP Keepalive timer to disable it for this socket (only needed when the socket is connected. *//* ... */ socket_ptr -> nx_tcp_socket_keepalive_timeout = 0; socket_ptr -> nx_tcp_socket_keepalive_retries = 0; }if (socket_ptr -> nx_tcp_socket_keepalive_enabled) { ... } /* ... */#endif /* If trace is enabled, insert this event into the trace buffer. */ NX_TRACE_IN_LINE_INSERT(NX_TRACE_INTERNAL_TCP_STATE_CHANGE, ip_ptr, socket_ptr, socket_ptr -> nx_tcp_socket_state, NX_TCP_CLOSE_WAIT, NX_TRACE_INTERNAL_EVENTS, 0, 0); /* The FIN bit is set, we need to go into the finished state. */ socket_ptr -> nx_tcp_socket_state = NX_TCP_CLOSE_WAIT; /* Increment the received sequence. */ socket_ptr -> nx_tcp_socket_rx_sequence++; /* Loop to release all threads suspended while trying to receive on the socket. */ while (socket_ptr -> nx_tcp_socket_receive_suspension_list) { /* Release the head of the receive suspension list. */ _nx_tcp_receive_cleanup(socket_ptr -> nx_tcp_socket_receive_suspension_list NX_CLEANUP_ARGUMENT); }while (socket_ptr -> nx_tcp_socket_receive_suspension_list) { ... } /* Send ACK message. */ _nx_tcp_packet_send_ack(socket_ptr, socket_ptr -> nx_tcp_socket_tx_sequence); /* If given, call the application's disconnect callback function for disconnect. *//* ... */ if (socket_ptr -> nx_tcp_disconnect_callback) { /* Call the application's disconnect handling function. It is responsible for calling the socket disconnect function. *//* ... */ (socket_ptr -> nx_tcp_disconnect_callback)(socket_ptr); }if (socket_ptr -> nx_tcp_disconnect_callback) { ... } }if ((socket_ptr -> nx_tcp_socket_fin_received) && (socket_ptr -> nx_tcp_socket_fin_sequence == socket_ptr -> nx_tcp_socket_rx_sequence)) { ... } }{ ... }