Changeset View
Changeset View
Standalone View
Standalone View
head/contrib/tcpdump/print-ip.c
Show First 20 Lines • Show All 432 Lines • ▼ Show 20 Lines | case IPPROTO_IPV4: | ||||
/* DVMRP multicast tunnel (ip-in-ip encapsulation) */ | /* DVMRP multicast tunnel (ip-in-ip encapsulation) */ | ||||
ip_print(ndo, ipds->cp, ipds->len); | ip_print(ndo, ipds->cp, ipds->len); | ||||
if (! ndo->ndo_vflag) { | if (! ndo->ndo_vflag) { | ||||
ND_PRINT((ndo, " (ipip-proto-4)")); | ND_PRINT((ndo, " (ipip-proto-4)")); | ||||
return; | return; | ||||
} | } | ||||
break; | break; | ||||
#ifdef INET6 | |||||
case IPPROTO_IPV6: | case IPPROTO_IPV6: | ||||
/* ip6-in-ip encapsulation */ | /* ip6-in-ip encapsulation */ | ||||
ip6_print(ndo, ipds->cp, ipds->len); | ip6_print(ndo, ipds->cp, ipds->len); | ||||
break; | break; | ||||
#endif /*INET6*/ | |||||
case IPPROTO_RSVP: | case IPPROTO_RSVP: | ||||
rsvp_print(ndo, ipds->cp, ipds->len); | rsvp_print(ndo, ipds->cp, ipds->len); | ||||
break; | break; | ||||
case IPPROTO_GRE: | case IPPROTO_GRE: | ||||
/* do it */ | /* do it */ | ||||
gre_print(ndo, ipds->cp, ipds->len); | gre_print(ndo, ipds->cp, ipds->len); | ||||
▲ Show 20 Lines • Show All 79 Lines • ▼ Show 20 Lines | ip_print(netdissect_options *ndo, | ||||
u_int hlen; | u_int hlen; | ||||
struct cksum_vec vec[1]; | struct cksum_vec vec[1]; | ||||
uint16_t sum, ip_sum; | uint16_t sum, ip_sum; | ||||
struct protoent *proto; | struct protoent *proto; | ||||
ipds->ip = (const struct ip *)bp; | ipds->ip = (const struct ip *)bp; | ||||
ND_TCHECK(ipds->ip->ip_vhl); | ND_TCHECK(ipds->ip->ip_vhl); | ||||
if (IP_V(ipds->ip) != 4) { /* print version if != 4 */ | if (IP_V(ipds->ip) != 4) { /* print version if != 4 */ | ||||
ND_PRINT((ndo, "IP%u ", IP_V(ipds->ip))); | |||||
if (IP_V(ipds->ip) == 6) | if (IP_V(ipds->ip) == 6) | ||||
ND_PRINT((ndo, ", wrong link-layer encapsulation")); | ND_PRINT((ndo, "IP6, wrong link-layer encapsulation ")); | ||||
else | |||||
ND_PRINT((ndo, "IP%u ", IP_V(ipds->ip))); | |||||
} | } | ||||
else if (!ndo->ndo_eflag) | else if (!ndo->ndo_eflag) | ||||
ND_PRINT((ndo, "IP ")); | ND_PRINT((ndo, "IP ")); | ||||
ND_TCHECK(*ipds->ip); | ND_TCHECK(*ipds->ip); | ||||
if (length < sizeof (struct ip)) { | if (length < sizeof (struct ip)) { | ||||
ND_PRINT((ndo, "truncated-ip %u", length)); | ND_PRINT((ndo, "truncated-ip %u", length)); | ||||
return; | return; | ||||
▲ Show 20 Lines • Show All 138 Lines • ▼ Show 20 Lines | if (length < 4) { | ||||
ND_PRINT((ndo, "truncated-ip %d", length)); | ND_PRINT((ndo, "truncated-ip %d", length)); | ||||
return; | return; | ||||
} | } | ||||
memcpy (&hdr, bp, 4); | memcpy (&hdr, bp, 4); | ||||
switch (IP_V(&hdr)) { | switch (IP_V(&hdr)) { | ||||
case 4: | case 4: | ||||
ip_print (ndo, bp, length); | ip_print (ndo, bp, length); | ||||
return; | return; | ||||
#ifdef INET6 | |||||
case 6: | case 6: | ||||
ip6_print (ndo, bp, length); | ip6_print (ndo, bp, length); | ||||
return; | return; | ||||
#endif | |||||
default: | default: | ||||
ND_PRINT((ndo, "unknown ip %d", IP_V(&hdr))); | ND_PRINT((ndo, "unknown ip %d", IP_V(&hdr))); | ||||
return; | return; | ||||
} | } | ||||
} | } | ||||
/* | /* | ||||
* Local Variables: | * Local Variables: | ||||
* c-style: whitesmith | * c-style: whitesmith | ||||
* c-basic-offset: 8 | * c-basic-offset: 8 | ||||
* End: | * End: | ||||
*/ | */ | ||||