1
10
13
14
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
109
110
111
115
116
117
121
122
123
124
125
126
127
128
129
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
154
155
156
157
158
159
160
161
162
163
164
170
171
173
180
181
182
183
184
185
186
187
188
189
190
191
...
...
...
#define NX_SOURCE_CODE
#include "nx_api.h"
#include "nx_ip.h"
#include "nx_packet.h"
NX_CALLER_CHECKING_EXTERNS
...
...
UINT _nxe_ip_create(NX_IP *ip_ptr, CHAR *name, ULONG ip_address, ULONG network_mask,
NX_PACKET_POOL *default_pool, VOID (*ip_link_driver)(struct NX_IP_DRIVER_STRUCT *),
VOID *memory_ptr, ULONG memory_size, UINT priority, UINT ip_control_block_size)
{
UINT status;
UINT old_threshold = 0;
NX_IP *created_ip;
ULONG created_count;
UCHAR *end_stack;
TX_THREAD *current_thread;
if ((ip_ptr == NX_NULL) || (default_pool == NX_NULL) ||
(default_pool -> nx_packet_pool_id != NX_PACKET_POOL_ID) || (ip_link_driver == NX_NULL) ||
(memory_ptr == NX_NULL) || (ip_control_block_size != (UINT)sizeof(NX_IP)))
{
return(NX_PTR_ERROR);
}if ((ip_ptr == NX_NULL) || (default_pool == NX_NULL) || (default_pool -> nx_packet_pool_id != NX_PACKET_POOL_ID) || (ip_link_driver == NX_NULL) || (memory_ptr == NX_NULL) || (ip_control_block_size != (UINT)sizeof(NX_IP))) { ... }
if (memory_size < TX_MINIMUM_STACK)
{
return(NX_SIZE_ERROR);
}if (memory_size < TX_MINIMUM_STACK) { ... }
if (priority >= TX_MAX_PRIORITIES)
{
return(NX_OPTION_ERROR);
}if (priority >= TX_MAX_PRIORITIES) { ... }
end_stack = ((UCHAR *)memory_ptr) + (memory_size - 1);
current_thread = tx_thread_identify();
if (current_thread)
{
tx_thread_preemption_change(current_thread, 0, &old_threshold);
}if (current_thread) { ... }
created_ip = _nx_ip_created_ptr;
created_count = _nx_ip_created_count;
while (created_count--)
{
if ((ip_ptr == created_ip) ||
((memory_ptr >= created_ip -> nx_ip_thread.tx_thread_stack_start) && (memory_ptr < created_ip -> nx_ip_thread.tx_thread_stack_end)) ||
((((VOID *)end_stack) >= created_ip -> nx_ip_thread.tx_thread_stack_start) && (((VOID *)end_stack) < created_ip -> nx_ip_thread.tx_thread_stack_end)))
{
if (current_thread)
{
tx_thread_preemption_change(current_thread, old_threshold, &old_threshold);
}if (current_thread) { ... }
return(NX_PTR_ERROR);
}if ((ip_ptr == created_ip) || ((memory_ptr >= created_ip -> nx_ip_thread.tx_thread_stack_start) && (memory_ptr < created_ip -> nx_ip_thread.tx_thread_stack_end)) || ((((VOID *)end_stack) >= created_ip -> nx_ip_thread.tx_thread_stack_start) && (((VOID *)end_stack) < created_ip -> nx_ip_thread.tx_thread_stack_end))) { ... }
created_ip = created_ip -> nx_ip_created_next;
}while (created_count--) { ... }
if (current_thread)
{
tx_thread_preemption_change(current_thread, old_threshold, &old_threshold);
}if (current_thread) { ... }
/* ... */
if ((ip_address != 0) &&
((ip_address & NX_IP_CLASS_A_MASK) != NX_IP_CLASS_A_TYPE) &&
((ip_address & NX_IP_CLASS_B_MASK) != NX_IP_CLASS_B_TYPE) &&
((ip_address & NX_IP_CLASS_C_MASK) != NX_IP_CLASS_C_TYPE))
{
return(NX_IP_ADDRESS_ERROR);
}if ((ip_address != 0) && ((ip_address & NX_IP_CLASS_A_MASK) != NX_IP_CLASS_A_TYPE) && ((ip_address & NX_IP_CLASS_B_MASK) != NX_IP_CLASS_B_TYPE) && ((ip_address & NX_IP_CLASS_C_MASK) != NX_IP_CLASS_C_TYPE)) { ... }
NX_INIT_AND_THREADS_CALLER_CHECKING
status = _nx_ip_create(ip_ptr, name, ip_address, network_mask, default_pool, ip_link_driver,
memory_ptr, memory_size, priority);
return(status);
}{ ... }