1
10
13
14
20
21
22
23
24
25
26
27
28
29
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
78
79
80
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
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
173
174
175
176
177
178
179
180
181
185
186
190
191
195
196
197
202
203
204
205
207
208
209
210
211
212
213
214
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
242
243
244
245
246
255
256
257
258
259
260
261
263
264
265
267
268
270
271
272
273
276
277
278
279
280
281
282
283
284
285
286
295
296
297
298
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
358
359
360
361
362
363
364
365
366
367
368
372
376
380
384
388
389
390
391
392
393
394
395
396
397
398
399
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
426
436
440
441
442
443
444
445
446
447
448
449
450
455
456
458
468
472
473
474
475
476
484
492
500
508
516
524
532
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
558
559
560
561
562
563
564
565
566
567
574
575
576
583
587
588
589
590
591
592
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
689
690
694
695
696
697
698
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
733
734
735
739
740
741
742
743
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
873
874
875
876
877
878
879
880
881
882
883
884
885
886
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
946
947
...
...
...
#include "nx_api.h"
/* ... */
#define NX_LINK_MTU 1514
/* ... */
#define NX_ETHERNET_IP 0x0800
#define NX_ETHERNET_ARP 0x0806
#define NX_ETHERNET_RARP 0x8035
#define NX_ETHERNET_IPV6 0x86DD
#define NX_ETHERNET_SIZE 14
6 defines
/* ... */
ULONG simulated_address_msw = 0x0011;
ULONG simulated_address_lsw = 0x22334456;
VOID _nx_ram_network_driver(NX_IP_DRIVER *driver_req_ptr);
void _nx_ram_network_driver_output(NX_PACKET *packet_ptr, UINT interface_instance_id);
void _nx_ram_network_driver_receive(NX_IP *ip_ptr, NX_PACKET *packet_ptr, UINT interface_instance_id);
#define NX_MAX_RAM_INTERFACES 4
#define NX_RAM_DRIVER_MAX_MCAST_ADDRESSES 3
typedef struct MAC_ADDRESS_STRUCT
{
ULONG nx_mac_address_msw;
ULONG nx_mac_address_lsw;
...} MAC_ADDRESS;
/* ... */
typedef struct _nx_ram_network_driver_instance_type
{
UINT nx_ram_network_driver_in_use;
UINT nx_ram_network_driver_id;
NX_INTERFACE *nx_ram_driver_interface_ptr;
NX_IP *nx_ram_driver_ip_ptr;
MAC_ADDRESS nx_ram_driver_mac_address;
MAC_ADDRESS nx_ram_driver_mcast_address[NX_RAM_DRIVER_MAX_MCAST_ADDRESSES];
...} _nx_ram_network_driver_instance_type;
/* ... */
static _nx_ram_network_driver_instance_type nx_ram_driver[NX_MAX_RAM_INTERFACES];
...
...
VOID _nx_ram_network_driver(NX_IP_DRIVER *driver_req_ptr)
{
UINT i = 0;
NX_IP *ip_ptr;
NX_PACKET *packet_ptr;
ULONG *ethernet_frame_ptr;
NX_INTERFACE *interface_ptr;
UINT interface_index;
ip_ptr = driver_req_ptr -> nx_ip_driver_ptr;
driver_req_ptr -> nx_ip_driver_status = NX_SUCCESS;
interface_ptr = driver_req_ptr -> nx_ip_driver_interface;
interface_index = interface_ptr -> nx_interface_index;
if (driver_req_ptr -> nx_ip_driver_command != NX_LINK_INTERFACE_ATTACH)
{
for (i = 0; i < NX_MAX_RAM_INTERFACES; i++)
{
if (nx_ram_driver[i].nx_ram_network_driver_in_use == 0)
{
continue;
}if (nx_ram_driver[i].nx_ram_network_driver_in_use == 0) { ... }
if (nx_ram_driver[i].nx_ram_driver_ip_ptr != ip_ptr)
{
continue;
}if (nx_ram_driver[i].nx_ram_driver_ip_ptr != ip_ptr) { ... }
if (nx_ram_driver[i].nx_ram_driver_interface_ptr == driver_req_ptr -> nx_ip_driver_interface)
{
break;
}if (nx_ram_driver[i].nx_ram_driver_interface_ptr == driver_req_ptr -> nx_ip_driver_interface) { ... }
}for (i = 0; i < NX_MAX_RAM_INTERFACES; i++) { ... }
if (i == NX_MAX_RAM_INTERFACES)
{
driver_req_ptr -> nx_ip_driver_status = NX_INVALID_INTERFACE;
return;
}if (i == NX_MAX_RAM_INTERFACES) { ... }
}if (driver_req_ptr -> nx_ip_driver_command != NX_LINK_INTERFACE_ATTACH) { ... }
/* ... */
switch (driver_req_ptr -> nx_ip_driver_command)
{
case NX_LINK_INTERFACE_ATTACH:
{
for (i = 0; i < NX_MAX_RAM_INTERFACES; i++)
{
if (nx_ram_driver[i].nx_ram_network_driver_in_use == 0)
{
break;
}if (nx_ram_driver[i].nx_ram_network_driver_in_use == 0) { ... }
}for (i = 0; i < NX_MAX_RAM_INTERFACES; i++) { ... }
if (i < NX_MAX_RAM_INTERFACES)
{
nx_ram_driver[i].nx_ram_network_driver_in_use = 1;
nx_ram_driver[i].nx_ram_network_driver_id = i;
nx_ram_driver[i].nx_ram_driver_interface_ptr = driver_req_ptr -> nx_ip_driver_interface;
nx_ram_driver[i].nx_ram_driver_ip_ptr = ip_ptr;
nx_ram_driver[i].nx_ram_driver_mac_address.nx_mac_address_msw = simulated_address_msw;
nx_ram_driver[i].nx_ram_driver_mac_address.nx_mac_address_lsw = simulated_address_lsw + i;
}if (i < NX_MAX_RAM_INTERFACES) { ... }
else
{
driver_req_ptr -> nx_ip_driver_status = NX_INVALID_INTERFACE;
}else { ... }
break;
...}
case NX_LINK_INTERFACE_ATTACH:
case NX_LINK_INTERFACE_DETACH:
{
memset(&(nx_ram_driver[i]), 0, sizeof(_nx_ram_network_driver_instance_type));
break;
...}
case NX_LINK_INTERFACE_DETACH:
case NX_LINK_INITIALIZE:
{
#ifdef NX_DEBUG
printf("NetX RAM Driver Initialization - %s\n", ip_ptr -> nx_ip_name);
printf(" IP Address =%08X\n", ip_ptr -> nx_ip_address);/* ... */
#endif
/* ... */
/* ... */
nx_ip_interface_mtu_set(ip_ptr, interface_index, (NX_LINK_MTU - NX_ETHERNET_SIZE));
/* ... */
nx_ip_interface_physical_address_set(ip_ptr, interface_index,
nx_ram_driver[i].nx_ram_driver_mac_address.nx_mac_address_msw,
nx_ram_driver[i].nx_ram_driver_mac_address.nx_mac_address_lsw, NX_FALSE);
nx_ip_interface_address_mapping_configure(ip_ptr, interface_index, NX_TRUE);
break;
...}
case NX_LINK_INITIALIZE:
case NX_LINK_UNINITIALIZE:
{
memset(&(nx_ram_driver[i]), 0, sizeof(_nx_ram_network_driver_instance_type));
break;
...}
case NX_LINK_UNINITIALIZE:
case NX_LINK_ENABLE:
{
/* ... */
interface_ptr -> nx_interface_link_up = NX_TRUE;
#ifdef NX_DEBUG
printf("NetX RAM Driver Link Enabled - %s\n", ip_ptr -> nx_ip_name);
#endif
break;
...}
case NX_LINK_ENABLE:
case NX_LINK_DISABLE:
{
/* ... */
interface_ptr -> nx_interface_link_up = NX_FALSE;
#ifdef NX_DEBUG
printf("NetX RAM Driver Link Disabled - %s\n", ip_ptr -> nx_ip_name);
#endif
break;
...}
case NX_LINK_DISABLE:
case NX_LINK_PACKET_SEND:
case NX_LINK_PACKET_BROADCAST:
case NX_LINK_ARP_SEND:
case NX_LINK_ARP_RESPONSE_SEND:
case NX_LINK_RARP_SEND:
{
/* ... */
packet_ptr = driver_req_ptr -> nx_ip_driver_packet;
packet_ptr -> nx_packet_prepend_ptr = packet_ptr -> nx_packet_prepend_ptr - NX_ETHERNET_SIZE;
packet_ptr -> nx_packet_length = packet_ptr -> nx_packet_length + NX_ETHERNET_SIZE;
/* ... */
ethernet_frame_ptr = (ULONG *)(packet_ptr -> nx_packet_prepend_ptr - 2);
*ethernet_frame_ptr = driver_req_ptr -> nx_ip_driver_physical_address_msw;
*(ethernet_frame_ptr + 1) = driver_req_ptr -> nx_ip_driver_physical_address_lsw;
*(ethernet_frame_ptr + 2) = (interface_ptr -> nx_interface_physical_address_msw << 16) |
(interface_ptr -> nx_interface_physical_address_lsw >> 16);
*(ethernet_frame_ptr + 3) = (interface_ptr -> nx_interface_physical_address_lsw << 16);
if (driver_req_ptr -> nx_ip_driver_command == NX_LINK_ARP_SEND)
{
*(ethernet_frame_ptr + 3) |= NX_ETHERNET_ARP;
}if (driver_req_ptr -> nx_ip_driver_command == NX_LINK_ARP_SEND) { ... }
else if (driver_req_ptr -> nx_ip_driver_command == NX_LINK_ARP_RESPONSE_SEND)
{
*(ethernet_frame_ptr + 3) |= NX_ETHERNET_ARP;
}else if (driver_req_ptr -> nx_ip_driver_command == NX_LINK_ARP_RESPONSE_SEND) { ... }
else if (driver_req_ptr -> nx_ip_driver_command == NX_LINK_RARP_SEND)
{
*(ethernet_frame_ptr + 3) |= NX_ETHERNET_RARP;
}else if (driver_req_ptr -> nx_ip_driver_command == NX_LINK_RARP_SEND) { ... }
else if (packet_ptr -> nx_packet_ip_version == 4)
{
*(ethernet_frame_ptr + 3) |= NX_ETHERNET_IP;
}else if (packet_ptr -> nx_packet_ip_version == 4) { ... }
else
{
*(ethernet_frame_ptr + 3) |= NX_ETHERNET_IPV6;
}else { ... }
NX_CHANGE_ULONG_ENDIAN(*(ethernet_frame_ptr));
NX_CHANGE_ULONG_ENDIAN(*(ethernet_frame_ptr + 1));
NX_CHANGE_ULONG_ENDIAN(*(ethernet_frame_ptr + 2));
NX_CHANGE_ULONG_ENDIAN(*(ethernet_frame_ptr + 3));
#ifdef NX_DEBUG_PACKET
printf("NetX RAM Driver Packet Send - %s\n", ip_ptr -> nx_ip_name);
#endif
/* ... */
_nx_ram_network_driver_output(packet_ptr, i);
break;
...}
case NX_LINK_RARP_SEND:
case NX_LINK_MULTICAST_JOIN:
{
UINT mcast_index;
/* ... */
/* ... */
for (mcast_index = 0; mcast_index < NX_RAM_DRIVER_MAX_MCAST_ADDRESSES; mcast_index++)
{
if (nx_ram_driver[i].nx_ram_driver_mcast_address[mcast_index].nx_mac_address_msw == 0 &&
nx_ram_driver[i].nx_ram_driver_mcast_address[mcast_index].nx_mac_address_lsw == 0)
{
nx_ram_driver[i].nx_ram_driver_mcast_address[mcast_index].nx_mac_address_msw = driver_req_ptr -> nx_ip_driver_physical_address_msw;
nx_ram_driver[i].nx_ram_driver_mcast_address[mcast_index].nx_mac_address_lsw = driver_req_ptr -> nx_ip_driver_physical_address_lsw;
break;
}if (nx_ram_driver[i].nx_ram_driver_mcast_address[mcast_index].nx_mac_address_msw == 0 && nx_ram_driver[i].nx_ram_driver_mcast_address[mcast_index].nx_mac_address_lsw == 0) { ... }
}for (mcast_index = 0; mcast_index < NX_RAM_DRIVER_MAX_MCAST_ADDRESSES; mcast_index++) { ... }
if (mcast_index == NX_RAM_DRIVER_MAX_MCAST_ADDRESSES)
{
driver_req_ptr -> nx_ip_driver_status = NX_NO_MORE_ENTRIES;
}if (mcast_index == NX_RAM_DRIVER_MAX_MCAST_ADDRESSES) { ... }
break;
...}
case NX_LINK_MULTICAST_JOIN:
case NX_LINK_MULTICAST_LEAVE:
{
UINT mcast_index;
/* ... */
/* ... */
for (mcast_index = 0; mcast_index < NX_RAM_DRIVER_MAX_MCAST_ADDRESSES; mcast_index++)
{
if (nx_ram_driver[i].nx_ram_driver_mcast_address[mcast_index].nx_mac_address_msw == driver_req_ptr -> nx_ip_driver_physical_address_msw &&
nx_ram_driver[i].nx_ram_driver_mcast_address[mcast_index].nx_mac_address_lsw == driver_req_ptr -> nx_ip_driver_physical_address_lsw)
{
nx_ram_driver[i].nx_ram_driver_mcast_address[mcast_index].nx_mac_address_msw = 0;
nx_ram_driver[i].nx_ram_driver_mcast_address[mcast_index].nx_mac_address_lsw = 0;
break;
}if (nx_ram_driver[i].nx_ram_driver_mcast_address[mcast_index].nx_mac_address_msw == driver_req_ptr -> nx_ip_driver_physical_address_msw && nx_ram_driver[i].nx_ram_driver_mcast_address[mcast_index].nx_mac_address_lsw == driver_req_ptr -> nx_ip_driver_physical_address_lsw) { ... }
}for (mcast_index = 0; mcast_index < NX_RAM_DRIVER_MAX_MCAST_ADDRESSES; mcast_index++) { ... }
if (mcast_index == NX_RAM_DRIVER_MAX_MCAST_ADDRESSES)
{
driver_req_ptr -> nx_ip_driver_status = NX_ENTRY_NOT_FOUND;
}if (mcast_index == NX_RAM_DRIVER_MAX_MCAST_ADDRESSES) { ... }
break;
...}
case NX_LINK_MULTICAST_LEAVE:
case NX_LINK_GET_STATUS:
{
*(driver_req_ptr -> nx_ip_driver_return_ptr) = ip_ptr -> nx_ip_interface[0].nx_interface_link_up;
break;
...}
case NX_LINK_GET_STATUS:
case NX_LINK_GET_SPEED:
{
*(driver_req_ptr -> nx_ip_driver_return_ptr) = 0;
break;
...}
case NX_LINK_GET_SPEED:
case NX_LINK_GET_DUPLEX_TYPE:
{
*(driver_req_ptr -> nx_ip_driver_return_ptr) = 0;
break;
...}
case NX_LINK_GET_DUPLEX_TYPE:
case NX_LINK_GET_ERROR_COUNT:
{
*(driver_req_ptr -> nx_ip_driver_return_ptr) = 0;
break;
...}
case NX_LINK_GET_ERROR_COUNT:
case NX_LINK_GET_RX_COUNT:
{
*(driver_req_ptr -> nx_ip_driver_return_ptr) = 0;
break;
...}
case NX_LINK_GET_RX_COUNT:
case NX_LINK_GET_TX_COUNT:
{
*(driver_req_ptr -> nx_ip_driver_return_ptr) = 0;
break;
...}
case NX_LINK_GET_TX_COUNT:
case NX_LINK_GET_ALLOC_ERRORS:
{
*(driver_req_ptr -> nx_ip_driver_return_ptr) = 0;
break;
...}
case NX_LINK_GET_ALLOC_ERRORS:
case NX_LINK_GET_INTERFACE_TYPE:
{
*(driver_req_ptr -> nx_ip_driver_return_ptr) = NX_INTERFACE_TYPE_UNKNOWN;
break;
...}
case NX_LINK_GET_INTERFACE_TYPE:
case NX_LINK_DEFERRED_PROCESSING:
{
/* ... */
/* ... */
break;
...}
case NX_LINK_DEFERRED_PROCESSING:
case NX_LINK_SET_PHYSICAL_ADDRESS:
{
for (i = 0; i < NX_MAX_RAM_INTERFACES; i++)
{
if (nx_ram_driver[i].nx_ram_driver_interface_ptr == driver_req_ptr -> nx_ip_driver_interface)
{
break;
}if (nx_ram_driver[i].nx_ram_driver_interface_ptr == driver_req_ptr -> nx_ip_driver_interface) { ... }
}for (i = 0; i < NX_MAX_RAM_INTERFACES; i++) { ... }
if (i < NX_MAX_RAM_INTERFACES)
{
nx_ram_driver[i].nx_ram_driver_mac_address.nx_mac_address_msw = driver_req_ptr -> nx_ip_driver_physical_address_msw;
nx_ram_driver[i].nx_ram_driver_mac_address.nx_mac_address_lsw = driver_req_ptr -> nx_ip_driver_physical_address_lsw;
}if (i < NX_MAX_RAM_INTERFACES) { ... }
else
{
driver_req_ptr -> nx_ip_driver_status = NX_INVALID_INTERFACE;
}else { ... }
break;
...}
#ifdef NX_ENABLE_INTERFACE_CAPABILITYcase NX_LINK_SET_PHYSICAL_ADDRESS:
case NX_INTERFACE_CAPABILITY_GET:
{
*(driver_req_ptr -> nx_ip_driver_return_ptr) = 0;
break;
...}
case NX_INTERFACE_CAPABILITY_GET:
case NX_INTERFACE_CAPABILITY_SET:
{
break;
...}/* ... */
#endif
default:
driver_req_ptr -> nx_ip_driver_status = NX_UNHANDLED_COMMAND;
#ifdef NX_DEBUG
printf("NetX RAM Driver Received invalid request - %s\n", ip_ptr -> nx_ip_name);
#endif
break;default
}switch (driver_req_ptr -> nx_ip_driver_command) { ... }
}{ ... }
...
...
void _nx_ram_network_driver_output(NX_PACKET *packet_ptr, UINT interface_instance_id)
{
NX_IP *next_ip;
NX_PACKET *packet_copy;
ULONG destination_address_msw;
ULONG destination_address_lsw;
UINT old_threshold = 0;
UINT i;
UINT mcast_index;
#ifdef NX_DEBUG_PACKET
UCHAR *ptr;
UINT j;
ptr = packet_ptr -> nx_packet_prepend_ptr;
printf("Ethernet Packet: ");
for (j = 0; j < 6; j++)
{
printf("%02X", *ptr++);
}for (j = 0; j < 6; j++) { ... }
printf(" ");
for (j = 0; j < 6; j++)
{
printf("%02X", *ptr++);
}for (j = 0; j < 6; j++) { ... }
printf(" %02X", *ptr++);
printf("%02X ", *ptr++);
i = 0;
for (j = 0; j < (packet_ptr -> nx_packet_length - NX_ETHERNET_SIZE); j++)
{
printf("%02X", *ptr++);
i++;
if (i > 3)
{
i = 0;
printf(" ");
}if (i > 3) { ... }
}for (j = 0; j < (packet_ptr -> nx_packet_length - NX_ETHERNET_SIZE); j++) { ... }
printf("\n");
/* ... */
#endif
destination_address_msw = (ULONG)*(packet_ptr -> nx_packet_prepend_ptr);
destination_address_msw = (destination_address_msw << 8) | (ULONG)*(packet_ptr -> nx_packet_prepend_ptr + 1);
destination_address_lsw = (ULONG)*(packet_ptr -> nx_packet_prepend_ptr + 2);
destination_address_lsw = (destination_address_lsw << 8) | (ULONG)*(packet_ptr -> nx_packet_prepend_ptr + 3);
destination_address_lsw = (destination_address_lsw << 8) | (ULONG)*(packet_ptr -> nx_packet_prepend_ptr + 4);
destination_address_lsw = (destination_address_lsw << 8) | (ULONG)*(packet_ptr -> nx_packet_prepend_ptr + 5);
tx_thread_preemption_change(tx_thread_identify(), 0, &old_threshold);
for (i = 0; i < NX_MAX_RAM_INTERFACES; i++)
{
if (i == interface_instance_id)
{
continue;
}if (i == interface_instance_id) { ... }
if (nx_ram_driver[i].nx_ram_network_driver_in_use == 0)
{
continue;
}if (nx_ram_driver[i].nx_ram_network_driver_in_use == 0) { ... }
next_ip = nx_ram_driver[i].nx_ram_driver_ip_ptr;
/* ... */
if (((destination_address_msw == ((ULONG)0x0000FFFF)) && (destination_address_lsw == ((ULONG)0xFFFFFFFF))) ||
((destination_address_msw == nx_ram_driver[i].nx_ram_driver_mac_address.nx_mac_address_msw) &&
(destination_address_lsw == nx_ram_driver[i].nx_ram_driver_mac_address.nx_mac_address_lsw)) ||
(destination_address_msw == ((ULONG)0x00003333)) ||
((destination_address_msw == 0) && (destination_address_lsw == 0)))
{
if (nx_packet_copy(packet_ptr, &packet_copy, next_ip -> nx_ip_default_packet_pool, NX_NO_WAIT))
{
packet_ptr -> nx_packet_prepend_ptr = packet_ptr -> nx_packet_prepend_ptr + NX_ETHERNET_SIZE;
packet_ptr -> nx_packet_length = packet_ptr -> nx_packet_length - NX_ETHERNET_SIZE;
nx_packet_transmit_release(packet_ptr);
return;
}if (nx_packet_copy(packet_ptr, &packet_copy, next_ip -> nx_ip_default_packet_pool, NX_NO_WAIT)) { ... }
_nx_ram_network_driver_receive(next_ip, packet_copy, i);
}if (((destination_address_msw == ((ULONG)0x0000FFFF)) && (destination_address_lsw == ((ULONG)0xFFFFFFFF))) || /* Broadcast match */ ((destination_address_msw == nx_ram_driver[i].nx_ram_driver_mac_address.nx_mac_address_msw) && (destination_address_lsw == nx_ram_driver[i].nx_ram_driver_mac_address.nx_mac_address_lsw)) || (destination_address_msw == ((ULONG)0x00003333)) || ((destination_address_msw == 0) && (destination_address_lsw == 0))) { ... }
else
{
for (mcast_index = 0; mcast_index < NX_RAM_DRIVER_MAX_MCAST_ADDRESSES; mcast_index++)
{
if (destination_address_msw == nx_ram_driver[i].nx_ram_driver_mcast_address[mcast_index].nx_mac_address_msw &&
destination_address_lsw == nx_ram_driver[i].nx_ram_driver_mcast_address[mcast_index].nx_mac_address_lsw)
{
if (nx_packet_copy(packet_ptr, &packet_copy, next_ip -> nx_ip_default_packet_pool, NX_NO_WAIT))
{
packet_ptr -> nx_packet_prepend_ptr = packet_ptr -> nx_packet_prepend_ptr + NX_ETHERNET_SIZE;
packet_ptr -> nx_packet_length = packet_ptr -> nx_packet_length - NX_ETHERNET_SIZE;
nx_packet_transmit_release(packet_ptr);
return;
}if (nx_packet_copy(packet_ptr, &packet_copy, next_ip -> nx_ip_default_packet_pool, NX_NO_WAIT)) { ... }
_nx_ram_network_driver_receive(next_ip, packet_copy, i);
}if (destination_address_msw == nx_ram_driver[i].nx_ram_driver_mcast_address[mcast_index].nx_mac_address_msw && destination_address_lsw == nx_ram_driver[i].nx_ram_driver_mcast_address[mcast_index].nx_mac_address_lsw) { ... }
}for (mcast_index = 0; mcast_index < NX_RAM_DRIVER_MAX_MCAST_ADDRESSES; mcast_index++) { ... }
}else { ... }
}for (i = 0; i < NX_MAX_RAM_INTERFACES; i++) { ... }
/* ... */
packet_ptr -> nx_packet_prepend_ptr = packet_ptr -> nx_packet_prepend_ptr + NX_ETHERNET_SIZE;
packet_ptr -> nx_packet_length = packet_ptr -> nx_packet_length - NX_ETHERNET_SIZE;
nx_packet_transmit_release(packet_ptr);
tx_thread_preemption_change(tx_thread_identify(), old_threshold, &old_threshold);
}{ ... }
...
...
void _nx_ram_network_driver_receive(NX_IP *ip_ptr, NX_PACKET *packet_ptr, UINT interface_instance_id)
{
UINT packet_type;
/* ... */
packet_type = (((UINT)(*(packet_ptr -> nx_packet_prepend_ptr + 12))) << 8) |
((UINT)(*(packet_ptr -> nx_packet_prepend_ptr + 13)));
packet_ptr -> nx_packet_address.nx_packet_interface_ptr = nx_ram_driver[interface_instance_id].nx_ram_driver_interface_ptr;
if ((packet_type == NX_ETHERNET_IP) || (packet_type == NX_ETHERNET_IPV6))
{
/* ... */
packet_ptr -> nx_packet_prepend_ptr = packet_ptr -> nx_packet_prepend_ptr + NX_ETHERNET_SIZE;
packet_ptr -> nx_packet_length = packet_ptr -> nx_packet_length - NX_ETHERNET_SIZE;
#ifdef NX_DEBUG_PACKET
printf("NetX RAM Driver IP Packet Receive - %s\n", ip_ptr -> nx_ip_name);
#endif
#ifdef NX_DIRECT_ISR_CALL
_nx_ip_packet_receive(ip_ptr, packet_ptr);
#else
_nx_ip_packet_deferred_receive(ip_ptr, packet_ptr);
#endif
}if ((packet_type == NX_ETHERNET_IP) || (packet_type == NX_ETHERNET_IPV6)) { ... }
#ifndef NX_DISABLE_IPV4
else if (packet_type == NX_ETHERNET_ARP)
{
packet_ptr -> nx_packet_prepend_ptr = packet_ptr -> nx_packet_prepend_ptr + NX_ETHERNET_SIZE;
packet_ptr -> nx_packet_length = packet_ptr -> nx_packet_length - NX_ETHERNET_SIZE;
#ifdef NX_DEBUG
printf("NetX RAM Driver ARP Receive - %s\n", ip_ptr -> nx_ip_name);
#endif
_nx_arp_packet_deferred_receive(ip_ptr, packet_ptr);
}else if (packet_type == NX_ETHERNET_ARP) { ... }
else if (packet_type == NX_ETHERNET_RARP)
{
packet_ptr -> nx_packet_prepend_ptr = packet_ptr -> nx_packet_prepend_ptr + NX_ETHERNET_SIZE;
packet_ptr -> nx_packet_length = packet_ptr -> nx_packet_length - NX_ETHERNET_SIZE;
#ifdef NX_DEBUG
printf("NetX RAM Driver RARP Receive - %s\n", ip_ptr -> nx_ip_name);
#endif
_nx_rarp_packet_deferred_receive(ip_ptr, packet_ptr);
}else if (packet_type == NX_ETHERNET_RARP) { ... }
/* ... */#endif
else
{
nx_packet_release(packet_ptr);
}else { ... }
}{ ... }