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"
...
...
_nx_tcp_mss_option_get(UCHAR *, ULONG, ULONG *)
Files
loading...
CodeScopeSTM32 Libraries and Samplesnetxduocommon/src/nx_tcp_mss_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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/**************************************************************************/ /* */ /* 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" ... /**************************************************************************/ /* */ /* FUNCTION RELEASE */ /* */ /* _nx_tcp_mss_option_get PORTABLE C */ /* 6.1 */ /* AUTHOR */ /* */ /* Yuxin Zhou, Microsoft Corporation */ /* */ /* DESCRIPTION */ /* */ /* This function searches for the Maximum Segment Size (MSS) 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 mss value */ /* 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 */ /* mss Max segment 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_mss_option_get(UCHAR *option_ptr, ULONG option_area_size, ULONG *mss) { ULONG option_length; /* Initialize the value. */ *mss = 0; /* Loop through the option area looking for the MSS. */ while (option_area_size >= 4) { /* Is the current character the MSS type? */ if (*option_ptr == NX_TCP_MSS_KIND) { /* Yes, we found it! */ /* Move the pointer forward by one. */ option_ptr++; /* Check the option length, if option length is not equal to 4, return NX_FALSE. */ if (*option_ptr++ != 4) { return(NX_FALSE); }if (*option_ptr++ != 4) { ... } /* Build the mss size. */ *mss = (ULONG)*option_ptr++; /* Get the LSB of the MSS. */ *mss = (*mss << 8) | (ULONG)*option_ptr; /* Finished, get out of the loop! */ break; }if (*option_ptr == NX_TCP_MSS_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! */ option_area_size--; }if (*option_ptr++ == NX_TCP_NOP_KIND) { ... } else { /* Derive the option length. */ option_length = ((ULONG)*option_ptr); /* Return when option length is invalid. */ if (option_length == 0) { return(NX_FALSE); }if (option_length == 0) { ... } /* Move the option pointer forward. */ option_ptr = option_ptr + (option_length - 1); /* 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 >= 4) { ... } /* Return. */ return(NX_TRUE); }{ ... }