Select one of the symbols to view example projects that use it.
 
Outline
...
...
...
#define NX_SOURCE_CODE
#include "nx_api.h"
#include "nx_tcp.h"
...
Files
loading (3/7)...
SourceVuSTM32 Libraries and Samplesnetxduocommon/src/nx_tcp_window_scaling_option_get.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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/**************************************************************************/ /* */ /* 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_tcp.h" #ifdef NX_ENABLE_TCP_WINDOW_SCALING /**************************************************************************/ /* */ /* FUNCTION RELEASE */ /* */ /* _nx_tcp_window_scaling_option_get PORTABLE C */ /* 6.1 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ /* */ /* DESCRIPTION */ /* */ /* This internal function searches for the Window Scale option. */ /* If found, first check the option length, if option length is not */ /* valid, it returns NX_FALSE to the caller, else it set the window */ /* scale size and returns NX_TRUE to the caller. Otherwise, */ /* NX_TRUE is returned. */ /* */ /* INPUT */ /* */ /* option_ptr Pointer to option area */ /* option_area_size Size of option area */ /* window_scale window scale size */ /* */ /* OUTPUT */ /* */ /* NX_FALSE TCP option is invalid */ /* NX_TRUE TCP option is valid */ /* */ /* CALLS */ /* */ /* None */ /* */ /* CALLED BY */ /* */ /* _nx_tcp_packet_process TCP packet processing */ /* _nx_tcp_server_socket_relisten Socket relisten processing */ /* */ /* 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 */ /* */... /**************************************************************************/ UINT _nx_tcp_window_scaling_option_get(UCHAR *option_ptr, ULONG option_area_size, ULONG *window_scale) { ULONG option_length; /* Set invalid window scaling, in case the SYN message does not contain Window Scaling feature. */ *window_scale = 0xFF; /* Loop through the option area looking for the window scaling option. */ while (option_area_size >= 3) { /* Is the current character the window scaling type? */ if (*option_ptr == NX_TCP_RWIN_KIND) { /* Yes, we found it! */ /* Move the pointer forward by one. */ option_ptr++; /* Check the option length, if option length is not equal to 3, return NX_FALSE. */ if (*option_ptr++ != 3) { return(NX_FALSE); }if (*option_ptr++ != 3) { ... } /* Get the window scale size. */ *window_scale = (ULONG)*option_ptr; if (*window_scale > 14) { /* Make sure window scale is limited to 14, per RFC 1323 pp.11 */ *window_scale = 14; }if (*window_scale > 14) { ... } break; }if (*option_ptr == NX_TCP_RWIN_KIND) { ... } /* Otherwise, process relative to the option type. */ /* Check for end of list. */ if (*option_ptr == NX_TCP_EOL_KIND) { /* Yes, end of list, get out! */ break; }if (*option_ptr == NX_TCP_EOL_KIND) { ... } /* Check for NOP. */ if (*option_ptr == NX_TCP_NOP_KIND) { /* One character option! Skip this option and move to the next entry. */ option_ptr++; option_area_size--; }if (*option_ptr == NX_TCP_NOP_KIND) { ... } else { /* Derive the option length. All options *fields* area 32-bits, but the options themselves may be padded by NOP's. Determine the option size based on alignment of the option ptr *//* ... */ option_length = *(option_ptr + 1); if (option_length == 0) { /* Illegal option length. */ return(NX_FALSE); }if (option_length == 0) { ... } /* Move the option pointer forward. */ option_ptr = option_ptr + option_length; /* Determine if this is greater than the option area size. */ if (option_length > option_area_size) { return(NX_FALSE); }if (option_length > option_area_size) { ... } else { option_area_size = option_area_size - option_length; }else { ... } }else { ... } }while (option_area_size >= 3) { ... } /* Return. */ return(NX_TRUE); }_nx_tcp_window_scaling_option_get (UCHAR *option_ptr, ULONG option_area_size, ULONG *window_scale) { ... } /* ... */#endif /* NX_ENABLE_TCP_WINDOW_SCALING */
Details
Show:
from
Types: Columns:
This file uses the notable symbols shown below. Click anywhere in the file to view more details.