3434
3535
3636static const struct tok ip_option_values [] = {
37- { IPOPT_EOL , "EOL" },
38- { IPOPT_NOP , "NOP" },
39- { IPOPT_TS , "timestamp" },
40- { IPOPT_SECURITY , "security" },
41- { IPOPT_RR , "RR" },
42- { IPOPT_SSRR , "SSRR" },
43- { IPOPT_LSRR , "LSRR" },
44- { IPOPT_RA , "RA" },
45- { IPOPT_RFC1393 , "traceroute" },
46- { 0 , NULL }
37+ { IPOPT_EOL , "EOL" },
38+ { IPOPT_NOP , "NOP" },
39+ { IPOPT_TS , "timestamp" },
40+ { IPOPT_SECURITY , "security" },
41+ { IPOPT_RR , "RR" },
42+ { IPOPT_SSRR , "SSRR" },
43+ { IPOPT_LSRR , "LSRR" },
44+ { IPOPT_RA , "RA" },
45+ { IPOPT_RFC1393 , "traceroute" },
46+ { 0 , NULL }
4747};
4848
4949/*
@@ -204,7 +204,7 @@ ip_printts(netdissect_options *ndo,
204204 type = " ^ " ;
205205 ND_TCHECK_LEN (cp + len , hoplen );
206206 ND_PRINT ("%s%u@%s" , type , GET_BE_U_4 (cp + len + hoplen - 4 ),
207- hoplen != 8 ? "" : GET_IPADDR_STRING (cp + len ));
207+ hoplen != 8 ? "" : GET_IPADDR_STRING (cp + len ));
208208 type = " " ;
209209 }
210210
@@ -241,10 +241,10 @@ ip_optprint(netdissect_options *ndo,
241241 option_code = GET_U_1 (cp );
242242
243243 ND_PRINT ("%s" ,
244- tok2str (ip_option_values ,"unknown %u" ,option_code ));
244+ tok2str (ip_option_values ,"unknown %u" ,option_code ));
245245
246246 if (option_code == IPOPT_NOP ||
247- option_code == IPOPT_EOL )
247+ option_code == IPOPT_EOL )
248248 option_len = 1 ;
249249
250250 else {
@@ -303,10 +303,10 @@ ip_optprint(netdissect_options *ndo,
303303#define IP_RES 0x8000
304304
305305static const struct tok ip_frag_values [] = {
306- { IP_MF , "+" },
307- { IP_DF , "DF" },
308- { IP_RES , "rsvd" }, /* The RFC3514 evil ;-) bit */
309- { 0 , NULL }
306+ { IP_MF , "+" },
307+ { IP_DF , "DF" },
308+ { IP_RES , "rsvd" }, /* The RFC3514 evil ;-) bit */
309+ { 0 , NULL }
310310};
311311
312312
@@ -371,84 +371,84 @@ ip_print(netdissect_options *ndo,
371371
372372 off = GET_BE_U_2 (ip -> ip_off );
373373
374- ip_proto = GET_U_1 (ip -> ip_p );
375-
376- if (ndo -> ndo_vflag ) {
377- ip_tos = GET_U_1 (ip -> ip_tos );
378- ND_PRINT ("(tos 0x%x" , ip_tos );
379- /* ECN bits */
380- switch (ip_tos & 0x03 ) {
381-
382- case 0 :
383- break ;
384-
385- case 1 :
386- ND_PRINT (",ECT(1)" );
387- break ;
388-
389- case 2 :
390- ND_PRINT (",ECT(0)" );
391- break ;
392-
393- case 3 :
394- ND_PRINT (",CE" );
395- break ;
396- }
397-
398- ip_ttl = GET_U_1 (ip -> ip_ttl );
399- if (ip_ttl >= 1 )
400- ND_PRINT (", ttl %u" , ip_ttl );
401-
402- /*
403- * for the firewall guys, print id, offset.
404- * On all but the last stick a "+" in the flags portion.
405- * For unfragmented datagrams, note the don't fragment flag.
406- */
407- ND_PRINT (", id %u, offset %u, flags [%s], proto %s (%u)" ,
408- GET_BE_U_2 (ip -> ip_id ),
409- (off & IP_OFFMASK ) * 8 ,
410- bittok2str (ip_frag_values , "none" , off & (IP_RES |IP_DF |IP_MF )),
411- tok2str (ipproto_values , "unknown" , ip_proto ),
412- ip_proto );
413-
414- if (presumed_tso )
415- ND_PRINT (", length %u [was 0, presumed TSO]" , length );
416- else
417- ND_PRINT (", length %u" , GET_BE_U_2 (ip -> ip_len ));
418-
419- if ((hlen > sizeof (struct ip ))) {
420- ND_PRINT (", options (" );
421- if (ip_optprint (ndo , (const u_char * )(ip + 1 ),
422- hlen - sizeof (struct ip )) == -1 ) {
423- ND_PRINT (" [truncated-option]" );
424- truncated = 1 ;
425- }
426- ND_PRINT (")" );
427- }
428-
429- if (!ndo -> ndo_Kflag && ND_TTEST_LEN ((const u_char * )ip , hlen )) {
430- vec [0 ].ptr = (const uint8_t * )(const void * )ip ;
431- vec [0 ].len = hlen ;
432- sum = in_cksum (vec , 1 );
433- if (sum != 0 ) {
434- ip_sum = GET_BE_U_2 (ip -> ip_sum );
435- ND_PRINT (", bad cksum %x (->%x)!" , ip_sum ,
436- in_cksum_shouldbe (ip_sum , sum ));
374+ ip_proto = GET_U_1 (ip -> ip_p );
375+
376+ if (ndo -> ndo_vflag ) {
377+ ip_tos = GET_U_1 (ip -> ip_tos );
378+ ND_PRINT ("(tos 0x%x" , ip_tos );
379+ /* ECN bits */
380+ switch (ip_tos & 0x03 ) {
381+
382+ case 0 :
383+ break ;
384+
385+ case 1 :
386+ ND_PRINT (",ECT(1)" );
387+ break ;
388+
389+ case 2 :
390+ ND_PRINT (",ECT(0)" );
391+ break ;
392+
393+ case 3 :
394+ ND_PRINT (",CE" );
395+ break ;
396+ }
397+
398+ ip_ttl = GET_U_1 (ip -> ip_ttl );
399+ if (ip_ttl >= 1 )
400+ ND_PRINT (", ttl %u" , ip_ttl );
401+
402+ /*
403+ * for the firewall guys, print id, offset.
404+ * On all but the last stick a "+" in the flags portion.
405+ * For unfragmented datagrams, note the don't fragment flag.
406+ */
407+ ND_PRINT (", id %u, offset %u, flags [%s], proto %s (%u)" ,
408+ GET_BE_U_2 (ip -> ip_id ),
409+ (off & IP_OFFMASK ) * 8 ,
410+ bittok2str (ip_frag_values , "none" , off & (IP_RES |IP_DF |IP_MF )),
411+ tok2str (ipproto_values , "unknown" , ip_proto ),
412+ ip_proto );
413+
414+ if (presumed_tso )
415+ ND_PRINT (", length %u [was 0, presumed TSO]" , length );
416+ else
417+ ND_PRINT (", length %u" , GET_BE_U_2 (ip -> ip_len ));
418+
419+ if ((hlen > sizeof (struct ip ))) {
420+ ND_PRINT (", options (" );
421+ if (ip_optprint (ndo , (const u_char * )(ip + 1 ),
422+ hlen - sizeof (struct ip )) == -1 ) {
423+ ND_PRINT (" [truncated-option]" );
424+ truncated = 1 ;
425+ }
426+ ND_PRINT (")" );
427+ }
428+
429+ if (!ndo -> ndo_Kflag && ND_TTEST_LEN ((const u_char * )ip , hlen )) {
430+ vec [0 ].ptr = (const uint8_t * )(const void * )ip ;
431+ vec [0 ].len = hlen ;
432+ sum = in_cksum (vec , 1 );
433+ if (sum != 0 ) {
434+ ip_sum = GET_BE_U_2 (ip -> ip_sum );
435+ ND_PRINT (", bad cksum %x (->%x)!" , ip_sum ,
436+ in_cksum_shouldbe (ip_sum , sum ));
437+ }
438+ }
439+
440+ if (ndo -> ndo_gflag )
441+ ND_PRINT (") " );
442+ else
443+ ND_PRINT (")\n " );
444+ if (truncated ) {
445+ ND_PRINT ("%s > %s: " ,
446+ GET_IPADDR_STRING (ip -> ip_src ),
447+ GET_IPADDR_STRING (ip -> ip_dst ));
448+ nd_print_trunc (ndo );
449+ nd_pop_packet_info (ndo );
450+ return ;
437451 }
438- }
439-
440- if (ndo -> ndo_gflag )
441- ND_PRINT (") " );
442- else
443- ND_PRINT (")\n " );
444- if (truncated ) {
445- ND_PRINT ("%s > %s: " ,
446- GET_IPADDR_STRING (ip -> ip_src ),
447- GET_IPADDR_STRING (ip -> ip_dst ));
448- nd_print_trunc (ndo );
449- nd_pop_packet_info (ndo );
450- return ;
451- }
452452 }
453453
454454 /*
@@ -462,21 +462,21 @@ ip_print(netdissect_options *ndo,
462462 if (nh != IPPROTO_TCP && nh != IPPROTO_UDP &&
463463 nh != IPPROTO_SCTP && nh != IPPROTO_DCCP ) {
464464 ND_PRINT ("%s > %s: " ,
465- GET_IPADDR_STRING (ip -> ip_src ),
466- GET_IPADDR_STRING (ip -> ip_dst ));
465+ GET_IPADDR_STRING (ip -> ip_src ),
466+ GET_IPADDR_STRING (ip -> ip_dst ));
467467 }
468468 /*
469469 * Do a bounds check before calling ip_demux_print().
470470 * At least the header data is required.
471471 */
472472 if (!ND_TTEST_LEN ((const u_char * )ip , hlen )) {
473473 ND_PRINT (" [remaining caplen(%u) < header length(%u)]" ,
474- ND_BYTES_AVAILABLE_AFTER ((const u_char * )ip ),
475- hlen );
474+ ND_BYTES_AVAILABLE_AFTER ((const u_char * )ip ),
475+ hlen );
476476 nd_trunc_longjmp (ndo );
477477 }
478478 ip_demux_print (ndo , (const u_char * )ip + hlen , len , 4 ,
479- off & IP_MF , GET_U_1 (ip -> ip_ttl ), nh , bp );
479+ off & IP_MF , GET_U_1 (ip -> ip_ttl ), nh , bp );
480480 } else {
481481 /*
482482 * Ultra quiet now means that all this stuff should be
@@ -493,7 +493,7 @@ ip_print(netdissect_options *ndo,
493493 * and the protocol.
494494 */
495495 ND_PRINT ("%s > %s:" , GET_IPADDR_STRING (ip -> ip_src ),
496- GET_IPADDR_STRING (ip -> ip_dst ));
496+ GET_IPADDR_STRING (ip -> ip_dst ));
497497 if (!ndo -> ndo_nflag && (p_name = netdb_protoname (ip_proto )) != NULL )
498498 ND_PRINT (" %s" , p_name );
499499 else
0 commit comments