#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-dccp.c,v 1.7 2006-11-02 09:05:23 hannes Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-dccp.c,v 1.8 2007-11-09 00:44:09 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
}
/* checksum calculation */
-#ifdef INET6
- if (ip6) {
- if (ip6->ip6_plen && vflag) {
- u_int16_t sum, dccp_sum;
+ if (vflag && TTEST2(bp[0], len)) {
+ u_int16_t sum = 0, dccp_sum;
+ dccp_sum = EXTRACT_16BITS(&dh->dccph_checksum);
+ (void)printf("cksum 0x%04x ", dccp_sum);
+ if (IP_V(ip) == 4)
+ sum = dccp_cksum(ip, dh, len);
+#ifdef INET6
+ else if (IP_V(ip) == 6)
sum = dccp6_cksum(ip6, dh, len);
- dccp_sum = EXTRACT_16BITS(&dh->dccph_checksum);
- printf("cksum 0x%04x", dccp_sum);
- if (sum != 0) {
- (void)printf(" (incorrect -> 0x%04x), ",in_cksum_shouldbe(dccp_sum, sum));
- } else
- (void)printf(" (correct), ");
- }
- } else
-#endif /* INET6 */
- if (vflag)
- {
- u_int16_t sum, dccp_sum;
-
- sum = dccp_cksum(ip, dh, len);
- dccp_sum = EXTRACT_16BITS(&dh->dccph_checksum);
- printf("cksum 0x%04x", dccp_sum);
- if (sum != 0) {
- (void)printf(" (incorrect (-> 0x%04x), ",in_cksum_shouldbe(dccp_sum, sum));
- } else
- (void)printf(" (correct), ");
+#endif
+ if (sum != 0)
+ (void)printf("(incorrect -> 0x%04x), ",in_cksum_shouldbe(dccp_sum, sum));
+ else
+ (void)printf("(correct), ");
}
switch (DCCPH_TYPE(dh)) {
static int dccp_print_option(const u_char *option)
{
u_int8_t optlen, i;
- u_int32_t *ts;
- u_int16_t *var16;
- u_int32_t *var32;
TCHECK(*option);
for (i = 0; i < optlen -2; i ++) printf("%02x", *(option +2 + i));
break;
case 41:
- ts = (u_int32_t *)(option + 2);
- printf("timestamp %u", (u_int32_t)ntohl(*ts));
+ printf("timestamp %u", EXTRACT_32BITS(option + 2));
break;
case 42:
- ts = (u_int32_t *)(option + 2);
- printf("timestamp_echo %u", (u_int32_t)ntohl(*ts));
+ printf("timestamp_echo %u", EXTRACT_32BITS(option + 2));
break;
case 43:
printf("elapsed_time ");
- if (optlen == 6){
- ts = (u_int32_t *)(option + 2);
- printf("%u", (u_int32_t)ntohl(*ts));
- } else {
- var16 = (u_int16_t *)(option + 2);
- printf("%u", ntohs(*var16));
- }
+ if (optlen == 6)
+ printf("%u", EXTRACT_32BITS(option + 2));
+ else
+ printf("%u", EXTRACT_16BITS(option + 2));
break;
case 44:
printf("data_checksum ");
printf("CCID option %d",*option);
switch (optlen) {
case 4:
- var16 = (u_int16_t *)(option + 2);
- printf(" %u",ntohs(*var16));
+ printf(" %u", EXTRACT_16BITS(option + 2));
break;
case 6:
- var32 = (u_int32_t *)(option + 2);
- printf(" %u",(u_int32_t)ntohl(*var32));
+ printf(" %u", EXTRACT_32BITS(option + 2));
break;
default:
break;