blob: 6074334a38cf28696cc47ceee5cae8d47cd7eadf (
plain)
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
|
/***************************************************************************
* Copyright (c) 2024 Microsoft Corporation
* Copyright (c) 2025-present Eclipse ThreadX Contributors
*
* This program and the accompanying materials are made available under the
* terms of the MIT License which is available at
* https://opensource.org/licenses/MIT.
*
* SPDX-License-Identifier: MIT
**************************************************************************/
/**************************************************************************/
/**************************************************************************/
/** */
/** NetX Component */
/** */
/** Transmission Control Protocol (TCP) */
/** */
/**************************************************************************/
/**************************************************************************/
#define NX_SOURCE_CODE
/* Include necessary system files. */
#include "nx_api.h"
#include "nx_tcp.h"
#include "nx_ip.h"
/**************************************************************************/
/* */
/* FUNCTION RELEASE */
/* */
/* _nx_tcp_enable PORTABLE C */
/* 6.4.3 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
/* */
/* DESCRIPTION */
/* */
/* This function enables the TCP management component for the */
/* specified IP instance. */
/* */
/* INPUT */
/* */
/* ip_ptr IP instance pointer */
/* */
/* OUTPUT */
/* */
/* status Completion status */
/* */
/* CALLS */
/* */
/* tx_timer_create Create fast TCP timer */
/* */
/* CALLED BY */
/* */
/* Application Code */
/* */
/**************************************************************************/
UINT _nx_tcp_enable(NX_IP *ip_ptr)
{
UINT i;
struct NX_TCP_LISTEN_STRUCT *listen_ptr;
/* If trace is enabled, insert this event into the trace buffer. */
NX_TRACE_IN_LINE_INSERT(NX_TRACE_TCP_ENABLE, ip_ptr, 0, 0, 0, NX_TRACE_TCP_EVENTS, 0, 0);
/* Place all server listen request structures on the available list. */
/* Setup a pointer to the first listen. */
listen_ptr = &(ip_ptr -> nx_ip_tcp_server_listen_reqs[0]);
/* Setup the available listen requests head pointer. */
ip_ptr -> nx_ip_tcp_available_listen_requests = listen_ptr;
/* Loop through the listen requests and link them on the available list. */
for (i = 0; i < NX_MAX_LISTEN_REQUESTS; i++)
{
/* Link listen request to next listen request. */
listen_ptr -> nx_tcp_listen_next = listen_ptr + 1;
/* Determine if we need to move to the next listen request. */
if (i < (NX_MAX_LISTEN_REQUESTS - 1))
{
listen_ptr++;
}
}
/* Make sure the last listen request has a NULL pointer. */
listen_ptr -> nx_tcp_listen_next = NX_NULL;
/* Set the TCP packet queue processing function. */
ip_ptr -> nx_ip_tcp_queue_process = _nx_tcp_queue_process;
/* Set the TCP periodic processing function. */
ip_ptr -> nx_ip_tcp_periodic_processing = _nx_tcp_periodic_processing;
/* Set the TCP fast periodic processing function. */
ip_ptr -> nx_ip_tcp_fast_periodic_processing = _nx_tcp_fast_periodic_processing;
/* Set the TCP deferred cleanup check function. */
ip_ptr -> nx_tcp_deferred_cleanup_check = _nx_tcp_deferred_cleanup_check;
/* Setup base timer variables. */
_nx_tcp_fast_timer_rate = (NX_IP_PERIODIC_RATE + (NX_TCP_FAST_TIMER_RATE - 1)) / NX_TCP_FAST_TIMER_RATE;
_nx_tcp_ack_timer_rate = (NX_IP_PERIODIC_RATE + (NX_TCP_ACK_TIMER_RATE - 1)) / NX_TCP_ACK_TIMER_RATE;
/*lint -e{778} suppress constant expression, since NX_TCP_TRANSMIT_TIMER_RATE can be redefined. */
/*lint -e{835} -e{845} suppress operating on zero. */
_nx_tcp_transmit_timer_rate = (NX_IP_PERIODIC_RATE + (NX_TCP_TRANSMIT_TIMER_RATE - 1)) / NX_TCP_TRANSMIT_TIMER_RATE;
_nx_tcp_2MSL_timer_rate = 2 * NX_IP_PERIODIC_RATE * NX_TCP_MAXIMUM_SEGMENT_LIFETIME;
_nx_ip_fast_periodic_timer_create(ip_ptr);
/* Set the TCP packet receive function in the IP structure to indicate
we are ready to receive TCP packets. */
ip_ptr -> nx_ip_tcp_packet_receive = _nx_tcp_packet_receive;
/* Return successful completion. */
return(NX_SUCCESS);
}
|