3939/* FUNCTION RELEASE */
4040/* */
4141/* _nx_ip_packet_checksum_compute PORTABLE C */
42- /* 6.1 */
42+ /* 6.2.1 */
4343/* AUTHOR */
4444/* */
4545/* Yuxin Zhou, Microsoft Corporation */
7575/* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
7676/* 09-30-2020 Yuxin Zhou Modified comment(s), */
7777/* resulting in version 6.1 */
78+ /* 03-08-2023 Tiejun Zhou Modified comment(s), and */
79+ /* fixed compiler warnings, */
80+ /* resulting in version 6.2.1 */
7881/* */
7982/**************************************************************************/
8083VOID _nx_ip_packet_checksum_compute (NX_PACKET * packet_ptr )
@@ -84,30 +87,32 @@ UCHAR *org_prepend_ptr;
8487ULONG checksum ;
8588ULONG val ;
8689UCHAR is_done = NX_FALSE ;
87- ULONG ip_header_length ;
8890ULONG ip_src_addr [4 ];
8991ULONG ip_dst_addr [4 ];
9092ULONG data_length = 0 ;
91- NX_IPV4_HEADER * ip_header_ptr ;
9293NX_TCP_HEADER * tcp_header_ptr ;
9394NX_UDP_HEADER * udp_header_ptr ;
95+ #ifndef NX_DISABLE_IPV4
96+ ULONG ip_header_length ;
97+ NX_IPV4_HEADER * ip_header_ptr ;
9498NX_ICMP_HEADER * icmpv4_header_ptr ;
9599NX_IGMP_HEADER * igmp_header_ptr ;
100+ #endif /* NX_DISABLE_IPV4 */
96101#ifdef FEATURE_NX_IPV6
97102USHORT short_val ;
98103NX_ICMPV6_HEADER * icmpv6_header_ptr ;
99104NX_IPV6_HEADER * ipv6_header_ptr ;
100105#endif
101106
102107 /* Get IP version. */
103- #ifdef FEATURE_NX_IPV6
108+ #ifndef NX_DISABLE_IPV4
104109 if (packet_ptr -> nx_packet_ip_version == NX_IP_VERSION_V4 )
105110 {
106- #endif
107111 next_protocol = NX_PROTOCOL_IPV4 ;
108- #ifdef FEATURE_NX_IPV6
109112 }
110- else
113+ #endif /* NX_DISABLE_IPV4 */
114+ #ifdef FEATURE_NX_IPV6
115+ if (packet_ptr -> nx_packet_ip_version == NX_IP_VERSION_V6 )
111116 {
112117 next_protocol = NX_PROTOCOL_IPV6 ;
113118 }
@@ -121,6 +126,7 @@ NX_IPV6_HEADER *ipv6_header_ptr;
121126 {
122127 switch (next_protocol )
123128 {
129+ #ifndef NX_DISABLE_IPV4
124130 case NX_PROTOCOL_IPV4 :
125131 {
126132
@@ -178,6 +184,7 @@ NX_IPV6_HEADER *ipv6_header_ptr;
178184 data_length = packet_ptr -> nx_packet_length - (ip_header_length << 2 );
179185 break ;
180186 }
187+ #endif /* NX_DISABLE_IPV4 */
181188
182189 case NX_PROTOCOL_TCP :
183190 {
@@ -241,6 +248,7 @@ NX_IPV6_HEADER *ipv6_header_ptr;
241248 break ;
242249 }
243250
251+ #ifndef NX_DISABLE_IPV4
244252 case NX_PROTOCOL_ICMP :
245253 {
246254
@@ -316,6 +324,7 @@ NX_IPV6_HEADER *ipv6_header_ptr;
316324 is_done = NX_TRUE ;
317325 break ;
318326 }
327+ #endif /* NX_DISABLE_IPV4 */
319328
320329#ifdef FEATURE_NX_IPV6
321330 case NX_PROTOCOL_ICMPV6 :
@@ -382,7 +391,7 @@ NX_IPV6_HEADER *ipv6_header_ptr;
382391 }
383392
384393
385- /* Restore origianl prepend_ptr. */
394+ /* Restore original prepend_ptr. */
386395 packet_ptr -> nx_packet_prepend_ptr = org_prepend_ptr ;
387396 return ;
388397}
0 commit comments