Sun Oct 20 02:58:34 2013 UTC ()
remove unused variables


(christos)
diff -r1.3 -r1.4 src/external/bsd/tcpdump/dist/print-esp.c
diff -r1.3 -r1.4 src/external/bsd/tcpdump/dist/print-pgm.c
diff -r1.3 -r1.4 src/external/bsd/tcpdump/dist/print-pim.c
diff -r1.3 -r1.4 src/external/bsd/tcpdump/dist/print-sctp.c
diff -r1.4 -r1.5 src/external/bsd/tcpdump/dist/print-icmp6.c
diff -r1.4 -r1.5 src/external/bsd/tcpdump/dist/print-isakmp.c

cvs diff -r1.3 -r1.4 src/external/bsd/tcpdump/dist/print-esp.c (expand / switch to unified diff)

--- src/external/bsd/tcpdump/dist/print-esp.c 2013/04/06 19:33:08 1.3
+++ src/external/bsd/tcpdump/dist/print-esp.c 2013/10/20 02:58:34 1.4
@@ -17,27 +17,27 @@ @@ -17,27 +17,27 @@
17 * or promote products derived from this software without specific prior 17 * or promote products derived from this software without specific prior
18 * written permission. 18 * written permission.
19 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 19 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
20 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 20 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
21 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
22 */ 22 */
23 23
24#include <sys/cdefs.h> 24#include <sys/cdefs.h>
25#ifndef lint 25#ifndef lint
26#if 0 26#if 0
27static const char rcsid[] _U_ = 27static const char rcsid[] _U_ =
28 "@(#) Header: /tcpdump/master/tcpdump/print-esp.c,v 1.58 2007-12-07 00:03:07 mcr Exp (LBL)"; 28 "@(#) Header: /tcpdump/master/tcpdump/print-esp.c,v 1.58 2007-12-07 00:03:07 mcr Exp (LBL)";
29#else 29#else
30__RCSID("$NetBSD: print-esp.c,v 1.3 2013/04/06 19:33:08 christos Exp $"); 30__RCSID("$NetBSD: print-esp.c,v 1.4 2013/10/20 02:58:34 christos Exp $");
31#endif 31#endif
32#endif 32#endif
33 33
34#ifdef HAVE_CONFIG_H 34#ifdef HAVE_CONFIG_H
35#include "config.h" 35#include "config.h"
36#endif 36#endif
37 37
38#include <string.h> 38#include <string.h>
39 39
40#include <tcpdump-stdinc.h> 40#include <tcpdump-stdinc.h>
41 41
42#include <stdlib.h> 42#include <stdlib.h>
43 43
@@ -211,40 +211,38 @@ int espprint_decode_hex(netdissect_optio @@ -211,40 +211,38 @@ int espprint_decode_hex(netdissect_optio
211 } 211 }
212 212
213 return i; 213 return i;
214} 214}
215 215
216/* 216/*
217 * decode the form: SPINUM@IP <tab> ALGONAME:0xsecret 217 * decode the form: SPINUM@IP <tab> ALGONAME:0xsecret
218 */ 218 */
219 219
220static int 220static int
221espprint_decode_encalgo(netdissect_options *ndo, 221espprint_decode_encalgo(netdissect_options *ndo,
222 char *decode, struct sa_list *sa) 222 char *decode, struct sa_list *sa)
223{ 223{
224 int len; 
225 size_t i; 224 size_t i;
226 const EVP_CIPHER *evp; 225 const EVP_CIPHER *evp;
227 int authlen = 0; 226 int authlen = 0;
228 char *colon, *p; 227 char *colon, *p;
229  228
230 colon = strchr(decode, ':'); 229 colon = strchr(decode, ':');
231 if (colon == NULL) { 230 if (colon == NULL) {
232 (*ndo->ndo_warning)(ndo, "failed to decode espsecret: %s\n", decode); 231 (*ndo->ndo_warning)(ndo, "failed to decode espsecret: %s\n", decode);
233 return 0; 232 return 0;
234 } 233 }
235 *colon = '\0'; 234 *colon = '\0';
236  235
237 len = colon - decode; 
238 if (strlen(decode) > strlen("-hmac96") && 236 if (strlen(decode) > strlen("-hmac96") &&
239 !strcmp(decode + strlen(decode) - strlen("-hmac96"), 237 !strcmp(decode + strlen(decode) - strlen("-hmac96"),
240 "-hmac96")) { 238 "-hmac96")) {
241 p = strstr(decode, "-hmac96"); 239 p = strstr(decode, "-hmac96");
242 *p = '\0'; 240 *p = '\0';
243 authlen = 12; 241 authlen = 12;
244 } 242 }
245 if (strlen(decode) > strlen("-cbc") && 243 if (strlen(decode) > strlen("-cbc") &&
246 !strcmp(decode + strlen(decode) - strlen("-cbc"), "-cbc")) { 244 !strcmp(decode + strlen(decode) - strlen("-cbc"), "-cbc")) {
247 p = strstr(decode, "-cbc"); 245 p = strstr(decode, "-cbc");
248 *p = '\0'; 246 *p = '\0';
249 } 247 }
250 evp = EVP_get_cipherbyname(decode); 248 evp = EVP_get_cipherbyname(decode);
@@ -530,38 +528,36 @@ esp_print(netdissect_options *ndo, @@ -530,38 +528,36 @@ esp_print(netdissect_options *ndo,
530#endif 528#endif
531 , 529 ,
532 int *padlen 530 int *padlen
533#ifndef HAVE_LIBCRYPTO 531#ifndef HAVE_LIBCRYPTO
534 _U_ 532 _U_
535#endif 533#endif
536 ) 534 )
537{ 535{
538 register const struct newesp *esp; 536 register const struct newesp *esp;
539 register const u_char *ep; 537 register const u_char *ep;
540#ifdef HAVE_LIBCRYPTO 538#ifdef HAVE_LIBCRYPTO
541 struct ip *ip; 539 struct ip *ip;
542 struct sa_list *sa = NULL; 540 struct sa_list *sa = NULL;
543 int espsecret_keylen; 
544#ifdef INET6 541#ifdef INET6
545 struct ip6_hdr *ip6 = NULL; 542 struct ip6_hdr *ip6 = NULL;
546#endif 543#endif
547 int advance; 544 int advance;
548 int len; 545 int len;
549 u_char *secret; 546 u_char *secret;
550 int ivlen = 0; 547 int ivlen = 0;
551 u_char *ivoff; 548 u_char *ivoff;
552 u_char *p; 549 u_char *p;
553 EVP_CIPHER_CTX ctx; 550 EVP_CIPHER_CTX ctx;
554 int blocksz; 
555#endif 551#endif
556 552
557 esp = (struct newesp *)bp; 553 esp = (struct newesp *)bp;
558 554
559#ifdef HAVE_LIBCRYPTO 555#ifdef HAVE_LIBCRYPTO
560 secret = NULL; 556 secret = NULL;
561 advance = 0; 557 advance = 0;
562#endif 558#endif
563 559
564#if 0 560#if 0
565 /* keep secret out of a register */ 561 /* keep secret out of a register */
566 p = (u_char *)&secret; 562 p = (u_char *)&secret;
567#endif 563#endif
@@ -645,35 +641,34 @@ esp_print(netdissect_options *ndo, @@ -645,35 +641,34 @@ esp_print(netdissect_options *ndo,
645 goto fail; 641 goto fail;
646 642
647 /* if we can't get nexthdr, we do not need to decrypt it */ 643 /* if we can't get nexthdr, we do not need to decrypt it */
648 if (ep - bp2 < len) 644 if (ep - bp2 < len)
649 goto fail; 645 goto fail;
650 if (ep - bp2 > len) { 646 if (ep - bp2 > len) {
651 /* FCS included at end of frame (NetBSD 1.6 or later) */ 647 /* FCS included at end of frame (NetBSD 1.6 or later) */
652 ep = bp2 + len; 648 ep = bp2 + len;
653 } 649 }
654 650
655 ivoff = (u_char *)(esp + 1) + 0; 651 ivoff = (u_char *)(esp + 1) + 0;
656 ivlen = sa->ivlen; 652 ivlen = sa->ivlen;
657 secret = sa->secret; 653 secret = sa->secret;
658 espsecret_keylen = sa->secretlen; 
659 ep = ep - sa->authlen; 654 ep = ep - sa->authlen;
660 655
661 if (sa->evp) { 656 if (sa->evp) {
662 memset(&ctx, 0, sizeof(ctx)); 657 memset(&ctx, 0, sizeof(ctx));
663 if (EVP_CipherInit(&ctx, sa->evp, secret, NULL, 0) < 0) 658 if (EVP_CipherInit(&ctx, sa->evp, secret, NULL, 0) < 0)
664 (*ndo->ndo_warning)(ndo, "espkey init failed"); 659 (*ndo->ndo_warning)(ndo, "espkey init failed");
665 660
666 blocksz = EVP_CIPHER_CTX_block_size(&ctx); 661 (void)EVP_CIPHER_CTX_block_size(&ctx);
667 662
668 p = ivoff; 663 p = ivoff;
669 EVP_CipherInit(&ctx, NULL, NULL, p, 0); 664 EVP_CipherInit(&ctx, NULL, NULL, p, 0);
670 EVP_Cipher(&ctx, p + ivlen, p + ivlen, ep - (p + ivlen)); 665 EVP_Cipher(&ctx, p + ivlen, p + ivlen, ep - (p + ivlen));
671 EVP_CIPHER_CTX_cleanup(&ctx); 666 EVP_CIPHER_CTX_cleanup(&ctx);
672 advance = ivoff - (u_char *)esp + ivlen; 667 advance = ivoff - (u_char *)esp + ivlen;
673 } else 668 } else
674 advance = sizeof(struct newesp); 669 advance = sizeof(struct newesp);
675 670
676 /* sanity check for pad length */ 671 /* sanity check for pad length */
677 if (ep - bp < *(ep - 2)) 672 if (ep - bp < *(ep - 2))
678 goto fail; 673 goto fail;
679 674

cvs diff -r1.3 -r1.4 src/external/bsd/tcpdump/dist/print-pgm.c (expand / switch to unified diff)

--- src/external/bsd/tcpdump/dist/print-pgm.c 2013/04/06 19:33:08 1.3
+++ src/external/bsd/tcpdump/dist/print-pgm.c 2013/10/20 02:58:34 1.4
@@ -9,27 +9,27 @@ @@ -9,27 +9,27 @@
9 * WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT 9 * WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
10 * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 10 * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
11 * FOR A PARTICULAR PURPOSE. 11 * FOR A PARTICULAR PURPOSE.
12 * 12 *
13 * Original code by Andy Heffernan (ahh@juniper.net) 13 * Original code by Andy Heffernan (ahh@juniper.net)
14 */ 14 */
15 15
16#include <sys/cdefs.h> 16#include <sys/cdefs.h>
17#ifndef lint 17#ifndef lint
18#if 0 18#if 0
19static const char rcsid[] _U_ = 19static const char rcsid[] _U_ =
20 "@(#) Header: /tcpdump/master/tcpdump/print-pgm.c,v 1.5 2005-06-07 22:05:58 guy Exp "; 20 "@(#) Header: /tcpdump/master/tcpdump/print-pgm.c,v 1.5 2005-06-07 22:05:58 guy Exp ";
21#else 21#else
22__RCSID("$NetBSD: print-pgm.c,v 1.3 2013/04/06 19:33:08 christos Exp $"); 22__RCSID("$NetBSD: print-pgm.c,v 1.4 2013/10/20 02:58:34 christos Exp $");
23#endif 23#endif
24#endif 24#endif
25 25
26#ifdef HAVE_CONFIG_H 26#ifdef HAVE_CONFIG_H
27#include "config.h" 27#include "config.h"
28#endif 28#endif
29 29
30#include <tcpdump-stdinc.h> 30#include <tcpdump-stdinc.h>
31 31
32#include <stdio.h> 32#include <stdio.h>
33#include <stdlib.h> 33#include <stdlib.h>
34#include <string.h> 34#include <string.h>
35 35
@@ -166,27 +166,27 @@ pgm_print(register const u_char *bp, reg @@ -166,27 +166,27 @@ pgm_print(register const u_char *bp, reg
166 register const struct pgm_header *pgm; 166 register const struct pgm_header *pgm;
167 register const struct ip *ip; 167 register const struct ip *ip;
168 register char ch; 168 register char ch;
169 u_int16_t sport, dport; 169 u_int16_t sport, dport;
170 int addr_size; 170 int addr_size;
171 const void *nla; 171 const void *nla;
172 int nla_af; 172 int nla_af;
173#ifdef INET6 173#ifdef INET6
174 char nla_buf[INET6_ADDRSTRLEN]; 174 char nla_buf[INET6_ADDRSTRLEN];
175 register const struct ip6_hdr *ip6; 175 register const struct ip6_hdr *ip6;
176#else 176#else
177 char nla_buf[INET_ADDRSTRLEN]; 177 char nla_buf[INET_ADDRSTRLEN];
178#endif 178#endif
179 u_int8_t opt_type, opt_len, flags1, flags2; 179 u_int8_t opt_type, opt_len;
180 u_int32_t seq, opts_len, len, offset; 180 u_int32_t seq, opts_len, len, offset;
181 181
182 pgm = (struct pgm_header *)bp; 182 pgm = (struct pgm_header *)bp;
183 ip = (struct ip *)bp2; 183 ip = (struct ip *)bp2;
184#ifdef INET6 184#ifdef INET6
185 if (IP_V(ip) == 6) 185 if (IP_V(ip) == 6)
186 ip6 = (struct ip6_hdr *)bp2; 186 ip6 = (struct ip6_hdr *)bp2;
187 else 187 else
188 ip6 = NULL; 188 ip6 = NULL;
189#else /* INET6 */ 189#else /* INET6 */
190 if (IP_V(ip) == 6) { 190 if (IP_V(ip) == 6) {
191 (void)printf("Can't handle IPv6"); 191 (void)printf("Can't handle IPv6");
192 return; 192 return;
@@ -540,102 +540,96 @@ pgm_print(register const u_char *bp, reg @@ -540,102 +540,96 @@ pgm_print(register const u_char *bp, reg
540 (void)printf("[Bad OPT_LENGTH option, length %u != 4]", opt_len); 540 (void)printf("[Bad OPT_LENGTH option, length %u != 4]", opt_len);
541 return; 541 return;
542 } 542 }
543 (void)printf(" OPTS LEN (extra?) %d", EXTRACT_16BITS(bp)); 543 (void)printf(" OPTS LEN (extra?) %d", EXTRACT_16BITS(bp));
544 bp += sizeof(u_int16_t); 544 bp += sizeof(u_int16_t);
545 opts_len -= 4; 545 opts_len -= 4;
546 break; 546 break;
547 547
548 case PGM_OPT_FRAGMENT: 548 case PGM_OPT_FRAGMENT:
549 if (opt_len != 16) { 549 if (opt_len != 16) {
550 (void)printf("[Bad OPT_FRAGMENT option, length %u != 16]", opt_len); 550 (void)printf("[Bad OPT_FRAGMENT option, length %u != 16]", opt_len);
551 return; 551 return;
552 } 552 }
553 flags1 = *bp++; 553 bp += 2; /* skip flags */
554 flags2 = *bp++; 
555 seq = EXTRACT_32BITS(bp); 554 seq = EXTRACT_32BITS(bp);
556 bp += sizeof(u_int32_t); 555 bp += sizeof(u_int32_t);
557 offset = EXTRACT_32BITS(bp); 556 offset = EXTRACT_32BITS(bp);
558 bp += sizeof(u_int32_t); 557 bp += sizeof(u_int32_t);
559 len = EXTRACT_32BITS(bp); 558 len = EXTRACT_32BITS(bp);
560 bp += sizeof(u_int32_t); 559 bp += sizeof(u_int32_t);
561 (void)printf(" FRAG seq %u off %u len %u", seq, offset, len); 560 (void)printf(" FRAG seq %u off %u len %u", seq, offset, len);
562 opts_len -= 16; 561 opts_len -= 16;
563 break; 562 break;
564 563
565 case PGM_OPT_NAK_LIST: 564 case PGM_OPT_NAK_LIST:
566 flags1 = *bp++; 565 bp += 2; /* skip flags */
567 flags2 = *bp++; 
568 opt_len -= sizeof(u_int32_t); /* option header */ 566 opt_len -= sizeof(u_int32_t); /* option header */
569 (void)printf(" NAK LIST"); 567 (void)printf(" NAK LIST");
570 while (opt_len) { 568 while (opt_len) {
571 if (opt_len < sizeof(u_int32_t)) { 569 if (opt_len < sizeof(u_int32_t)) {
572 (void)printf("[Option length not a multiple of 4]"); 570 (void)printf("[Option length not a multiple of 4]");
573 return; 571 return;
574 } 572 }
575 TCHECK2(*bp, sizeof(u_int32_t)); 573 TCHECK2(*bp, sizeof(u_int32_t));
576 (void)printf(" %u", EXTRACT_32BITS(bp)); 574 (void)printf(" %u", EXTRACT_32BITS(bp));
577 bp += sizeof(u_int32_t); 575 bp += sizeof(u_int32_t);
578 opt_len -= sizeof(u_int32_t); 576 opt_len -= sizeof(u_int32_t);
579 opts_len -= sizeof(u_int32_t); 577 opts_len -= sizeof(u_int32_t);
580 } 578 }
581 break; 579 break;
582 580
583 case PGM_OPT_JOIN: 581 case PGM_OPT_JOIN:
584 if (opt_len != 8) { 582 if (opt_len != 8) {
585 (void)printf("[Bad OPT_JOIN option, length %u != 8]", opt_len); 583 (void)printf("[Bad OPT_JOIN option, length %u != 8]", opt_len);
586 return; 584 return;
587 } 585 }
588 flags1 = *bp++; 586 bp += 2; /* skip flags */
589 flags2 = *bp++; 
590 seq = EXTRACT_32BITS(bp); 587 seq = EXTRACT_32BITS(bp);
591 bp += sizeof(u_int32_t); 588 bp += sizeof(u_int32_t);
592 (void)printf(" JOIN %u", seq); 589 (void)printf(" JOIN %u", seq);
593 opts_len -= 8; 590 opts_len -= 8;
594 break; 591 break;
595 592
596 case PGM_OPT_NAK_BO_IVL: 593 case PGM_OPT_NAK_BO_IVL:
597 if (opt_len != 12) { 594 if (opt_len != 12) {
598 (void)printf("[Bad OPT_NAK_BO_IVL option, length %u != 12]", opt_len); 595 (void)printf("[Bad OPT_NAK_BO_IVL option, length %u != 12]", opt_len);
599 return; 596 return;
600 } 597 }
601 flags1 = *bp++; 598 bp += 2; /* skip flags */
602 flags2 = *bp++; 
603 offset = EXTRACT_32BITS(bp); 599 offset = EXTRACT_32BITS(bp);
604 bp += sizeof(u_int32_t); 600 bp += sizeof(u_int32_t);
605 seq = EXTRACT_32BITS(bp); 601 seq = EXTRACT_32BITS(bp);
606 bp += sizeof(u_int32_t); 602 bp += sizeof(u_int32_t);
607 (void)printf(" BACKOFF ivl %u ivlseq %u", offset, seq); 603 (void)printf(" BACKOFF ivl %u ivlseq %u", offset, seq);
608 opts_len -= 12; 604 opts_len -= 12;
609 break; 605 break;
610 606
611 case PGM_OPT_NAK_BO_RNG: 607 case PGM_OPT_NAK_BO_RNG:
612 if (opt_len != 12) { 608 if (opt_len != 12) {
613 (void)printf("[Bad OPT_NAK_BO_RNG option, length %u != 12]", opt_len); 609 (void)printf("[Bad OPT_NAK_BO_RNG option, length %u != 12]", opt_len);
614 return; 610 return;
615 } 611 }
616 flags1 = *bp++; 612 bp += 2; /* skip flags */
617 flags2 = *bp++; 
618 offset = EXTRACT_32BITS(bp); 613 offset = EXTRACT_32BITS(bp);
619 bp += sizeof(u_int32_t); 614 bp += sizeof(u_int32_t);
620 seq = EXTRACT_32BITS(bp); 615 seq = EXTRACT_32BITS(bp);
621 bp += sizeof(u_int32_t); 616 bp += sizeof(u_int32_t);
622 (void)printf(" BACKOFF max %u min %u", offset, seq); 617 (void)printf(" BACKOFF max %u min %u", offset, seq);
623 opts_len -= 12; 618 opts_len -= 12;
624 break; 619 break;
625 620
626 case PGM_OPT_REDIRECT: 621 case PGM_OPT_REDIRECT:
627 flags1 = *bp++; 622 bp += 2; /* skip flags */
628 flags2 = *bp++; 
629 switch (EXTRACT_16BITS(bp)) { 623 switch (EXTRACT_16BITS(bp)) {
630 case AFI_IP: 624 case AFI_IP:
631 addr_size = sizeof(struct in_addr); 625 addr_size = sizeof(struct in_addr);
632 nla_af = AF_INET; 626 nla_af = AF_INET;
633 break; 627 break;
634#ifdef INET6 628#ifdef INET6
635 case AFI_IP6: 629 case AFI_IP6:
636 addr_size = sizeof(struct in6_addr); 630 addr_size = sizeof(struct in6_addr);
637 nla_af = AF_INET6; 631 nla_af = AF_INET6;
638 break; 632 break;
639#endif 633#endif
640 default: 634 default:
641 goto trunc; 635 goto trunc;
@@ -650,130 +644,121 @@ pgm_print(register const u_char *bp, reg @@ -650,130 +644,121 @@ pgm_print(register const u_char *bp, reg
650 nla = bp; 644 nla = bp;
651 bp += addr_size; 645 bp += addr_size;
652 646
653 inet_ntop(nla_af, nla, nla_buf, sizeof(nla_buf)); 647 inet_ntop(nla_af, nla, nla_buf, sizeof(nla_buf));
654 (void)printf(" REDIRECT %s", (char *)nla); 648 (void)printf(" REDIRECT %s", (char *)nla);
655 opts_len -= 4 + addr_size; 649 opts_len -= 4 + addr_size;
656 break; 650 break;
657 651
658 case PGM_OPT_PARITY_PRM: 652 case PGM_OPT_PARITY_PRM:
659 if (opt_len != 8) { 653 if (opt_len != 8) {
660 (void)printf("[Bad OPT_PARITY_PRM option, length %u != 8]", opt_len); 654 (void)printf("[Bad OPT_PARITY_PRM option, length %u != 8]", opt_len);
661 return; 655 return;
662 } 656 }
663 flags1 = *bp++; 657 bp += 2; /* skip flags */
664 flags2 = *bp++; 
665 len = EXTRACT_32BITS(bp); 658 len = EXTRACT_32BITS(bp);
666 bp += sizeof(u_int32_t); 659 bp += sizeof(u_int32_t);
667 (void)printf(" PARITY MAXTGS %u", len); 660 (void)printf(" PARITY MAXTGS %u", len);
668 opts_len -= 8; 661 opts_len -= 8;
669 break; 662 break;
670 663
671 case PGM_OPT_PARITY_GRP: 664 case PGM_OPT_PARITY_GRP:
672 if (opt_len != 8) { 665 if (opt_len != 8) {
673 (void)printf("[Bad OPT_PARITY_GRP option, length %u != 8]", opt_len); 666 (void)printf("[Bad OPT_PARITY_GRP option, length %u != 8]", opt_len);
674 return; 667 return;
675 } 668 }
676 flags1 = *bp++; 669 bp += 2; /* skip flags */
677 flags2 = *bp++; 
678 seq = EXTRACT_32BITS(bp); 670 seq = EXTRACT_32BITS(bp);
679 bp += sizeof(u_int32_t); 671 bp += sizeof(u_int32_t);
680 (void)printf(" PARITY GROUP %u", seq); 672 (void)printf(" PARITY GROUP %u", seq);
681 opts_len -= 8; 673 opts_len -= 8;
682 break; 674 break;
683 675
684 case PGM_OPT_CURR_TGSIZE: 676 case PGM_OPT_CURR_TGSIZE:
685 if (opt_len != 8) { 677 if (opt_len != 8) {
686 (void)printf("[Bad OPT_CURR_TGSIZE option, length %u != 8]", opt_len); 678 (void)printf("[Bad OPT_CURR_TGSIZE option, length %u != 8]", opt_len);
687 return; 679 return;
688 } 680 }
689 flags1 = *bp++; 681 bp += 2; /* skip flags */
690 flags2 = *bp++; 
691 len = EXTRACT_32BITS(bp); 682 len = EXTRACT_32BITS(bp);
692 bp += sizeof(u_int32_t); 683 bp += sizeof(u_int32_t);
693 (void)printf(" PARITY ATGS %u", len); 684 (void)printf(" PARITY ATGS %u", len);
694 opts_len -= 8; 685 opts_len -= 8;
695 break; 686 break;
696 687
697 case PGM_OPT_NBR_UNREACH: 688 case PGM_OPT_NBR_UNREACH:
698 if (opt_len != 4) { 689 if (opt_len != 4) {
699 (void)printf("[Bad OPT_NBR_UNREACH option, length %u != 4]", opt_len); 690 (void)printf("[Bad OPT_NBR_UNREACH option, length %u != 4]", opt_len);
700 return; 691 return;
701 } 692 }
702 flags1 = *bp++; 693 bp += 2; /* skip flags */
703 flags2 = *bp++; 
704 (void)printf(" NBR_UNREACH"); 694 (void)printf(" NBR_UNREACH");
705 opts_len -= 4; 695 opts_len -= 4;
706 break; 696 break;
707 697
708 case PGM_OPT_PATH_NLA: 698 case PGM_OPT_PATH_NLA:
709 (void)printf(" PATH_NLA [%d]", opt_len); 699 (void)printf(" PATH_NLA [%d]", opt_len);
710 bp += opt_len; 700 bp += opt_len;
711 opts_len -= opt_len; 701 opts_len -= opt_len;
712 break; 702 break;
713 703
714 case PGM_OPT_SYN: 704 case PGM_OPT_SYN:
715 if (opt_len != 4) { 705 if (opt_len != 4) {
716 (void)printf("[Bad OPT_SYN option, length %u != 4]", opt_len); 706 (void)printf("[Bad OPT_SYN option, length %u != 4]", opt_len);
717 return; 707 return;
718 } 708 }
719 flags1 = *bp++; 709 bp += 2; /* skip flags */
720 flags2 = *bp++; 
721 (void)printf(" SYN"); 710 (void)printf(" SYN");
722 opts_len -= 4; 711 opts_len -= 4;
723 break; 712 break;
724 713
725 case PGM_OPT_FIN: 714 case PGM_OPT_FIN:
726 if (opt_len != 4) { 715 if (opt_len != 4) {
727 (void)printf("[Bad OPT_FIN option, length %u != 4]", opt_len); 716 (void)printf("[Bad OPT_FIN option, length %u != 4]", opt_len);
728 return; 717 return;
729 } 718 }
730 flags1 = *bp++; 719 bp += 2; /* skip flags */
731 flags2 = *bp++; 
732 (void)printf(" FIN"); 720 (void)printf(" FIN");
733 opts_len -= 4; 721 opts_len -= 4;
734 break; 722 break;
735 723
736 case PGM_OPT_RST: 724 case PGM_OPT_RST:
737 if (opt_len != 4) { 725 if (opt_len != 4) {
738 (void)printf("[Bad OPT_RST option, length %u != 4]", opt_len); 726 (void)printf("[Bad OPT_RST option, length %u != 4]", opt_len);
739 return; 727 return;
740 } 728 }
741 flags1 = *bp++; 729 bp += 2; /* skip flags */
742 flags2 = *bp++; 
743 (void)printf(" RST"); 730 (void)printf(" RST");
744 opts_len -= 4; 731 opts_len -= 4;
745 break; 732 break;
746 733
747 case PGM_OPT_CR: 734 case PGM_OPT_CR:
748 (void)printf(" CR"); 735 (void)printf(" CR");
749 bp += opt_len; 736 bp += opt_len;
750 opts_len -= opt_len; 737 opts_len -= opt_len;
751 break; 738 break;
752 739
753 case PGM_OPT_CRQST: 740 case PGM_OPT_CRQST:
754 if (opt_len != 4) { 741 if (opt_len != 4) {
755 (void)printf("[Bad OPT_CRQST option, length %u != 4]", opt_len); 742 (void)printf("[Bad OPT_CRQST option, length %u != 4]", opt_len);
756 return; 743 return;
757 } 744 }
758 flags1 = *bp++; 745 bp += 2; /* skip flags */
759 flags2 = *bp++; 
760 (void)printf(" CRQST"); 746 (void)printf(" CRQST");
761 opts_len -= 4; 747 opts_len -= 4;
762 break; 748 break;
763 749
764 case PGM_OPT_PGMCC_DATA: 750 case PGM_OPT_PGMCC_DATA:
765 flags1 = *bp++; 751 bp += 2; /* skip flags */
766 flags2 = *bp++; 
767 offset = EXTRACT_32BITS(bp); 752 offset = EXTRACT_32BITS(bp);
768 bp += sizeof(u_int32_t); 753 bp += sizeof(u_int32_t);
769 switch (EXTRACT_16BITS(bp)) { 754 switch (EXTRACT_16BITS(bp)) {
770 case AFI_IP: 755 case AFI_IP:
771 addr_size = sizeof(struct in_addr); 756 addr_size = sizeof(struct in_addr);
772 nla_af = AF_INET; 757 nla_af = AF_INET;
773 break; 758 break;
774#ifdef INET6 759#ifdef INET6
775 case AFI_IP6: 760 case AFI_IP6:
776 addr_size = sizeof(struct in6_addr); 761 addr_size = sizeof(struct in6_addr);
777 nla_af = AF_INET6; 762 nla_af = AF_INET6;
778 break; 763 break;
779#endif 764#endif
@@ -786,28 +771,27 @@ pgm_print(register const u_char *bp, reg @@ -786,28 +771,27 @@ pgm_print(register const u_char *bp, reg
786 (void)printf("[Bad OPT_PGMCC_DATA option, length %u != 12 + address size]", opt_len); 771 (void)printf("[Bad OPT_PGMCC_DATA option, length %u != 12 + address size]", opt_len);
787 return; 772 return;
788 } 773 }
789 TCHECK2(*bp, addr_size); 774 TCHECK2(*bp, addr_size);
790 nla = bp; 775 nla = bp;
791 bp += addr_size; 776 bp += addr_size;
792 777
793 inet_ntop(nla_af, nla, nla_buf, sizeof(nla_buf)); 778 inet_ntop(nla_af, nla, nla_buf, sizeof(nla_buf));
794 (void)printf(" PGMCC DATA %u %s", offset, (char*)nla); 779 (void)printf(" PGMCC DATA %u %s", offset, (char*)nla);
795 opts_len -= 16; 780 opts_len -= 16;
796 break; 781 break;
797 782
798 case PGM_OPT_PGMCC_FEEDBACK: 783 case PGM_OPT_PGMCC_FEEDBACK:
799 flags1 = *bp++; 784 bp += 2; /* skip flags */
800 flags2 = *bp++; 
801 offset = EXTRACT_32BITS(bp); 785 offset = EXTRACT_32BITS(bp);
802 bp += sizeof(u_int32_t); 786 bp += sizeof(u_int32_t);
803 switch (EXTRACT_16BITS(bp)) { 787 switch (EXTRACT_16BITS(bp)) {
804 case AFI_IP: 788 case AFI_IP:
805 addr_size = sizeof(struct in_addr); 789 addr_size = sizeof(struct in_addr);
806 nla_af = AF_INET; 790 nla_af = AF_INET;
807 break; 791 break;
808#ifdef INET6 792#ifdef INET6
809 case AFI_IP6: 793 case AFI_IP6:
810 addr_size = sizeof(struct in6_addr); 794 addr_size = sizeof(struct in6_addr);
811 nla_af = AF_INET6; 795 nla_af = AF_INET6;
812 break; 796 break;
813#endif 797#endif

cvs diff -r1.3 -r1.4 src/external/bsd/tcpdump/dist/print-pim.c (expand / switch to unified diff)

--- src/external/bsd/tcpdump/dist/print-pim.c 2013/04/06 19:33:08 1.3
+++ src/external/bsd/tcpdump/dist/print-pim.c 2013/10/20 02:58:34 1.4
@@ -15,27 +15,27 @@ @@ -15,27 +15,27 @@
15 * or promote products derived from this software without specific prior 15 * or promote products derived from this software without specific prior
16 * written permission. 16 * written permission.
17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 18 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 */ 20 */
21 21
22#include <sys/cdefs.h> 22#include <sys/cdefs.h>
23#ifndef lint 23#ifndef lint
24#if 0 24#if 0
25static const char rcsid[] _U_ = 25static const char rcsid[] _U_ =
26 "@(#) Header: /tcpdump/master/tcpdump/print-pim.c,v 1.49 2006-02-13 01:31:35 hannes Exp (LBL)"; 26 "@(#) Header: /tcpdump/master/tcpdump/print-pim.c,v 1.49 2006-02-13 01:31:35 hannes Exp (LBL)";
27#else 27#else
28__RCSID("$NetBSD: print-pim.c,v 1.3 2013/04/06 19:33:08 christos Exp $"); 28__RCSID("$NetBSD: print-pim.c,v 1.4 2013/10/20 02:58:34 christos Exp $");
29#endif 29#endif
30#endif 30#endif
31 31
32#ifdef HAVE_CONFIG_H 32#ifdef HAVE_CONFIG_H
33#include "config.h" 33#include "config.h"
34#endif 34#endif
35 35
36#include <tcpdump-stdinc.h> 36#include <tcpdump-stdinc.h>
37 37
38#include <stdio.h> 38#include <stdio.h>
39#include <stdlib.h> 39#include <stdlib.h>
40 40
41#include "interface.h" 41#include "interface.h"
@@ -116,27 +116,27 @@ struct pim { @@ -116,27 +116,27 @@ struct pim {
116 * Graft-Ack (PIM-DM only), C-RP-Adv 116 * Graft-Ack (PIM-DM only), C-RP-Adv
117 */ 117 */
118#define PIM_VER(x) (((x) & 0xf0) >> 4) 118#define PIM_VER(x) (((x) & 0xf0) >> 4)
119#define PIM_TYPE(x) ((x) & 0x0f) 119#define PIM_TYPE(x) ((x) & 0x0f)
120 u_char pim_rsv; /* Reserved */ 120 u_char pim_rsv; /* Reserved */
121 u_short pim_cksum; /* IP style check sum */ 121 u_short pim_cksum; /* IP style check sum */
122}; 122};
123 123
124static void pimv2_print(register const u_char *bp, register u_int len, u_int cksum); 124static void pimv2_print(register const u_char *bp, register u_int len, u_int cksum);
125 125
126static void 126static void
127pimv1_join_prune_print(register const u_char *bp, register u_int len) 127pimv1_join_prune_print(register const u_char *bp, register u_int len)
128{ 128{
129 int maddrlen, addrlen, ngroups, njoin, nprune; 129 int addrlen, maddrlen, ngroups, njoin, nprune;
130 int njp; 130 int njp;
131 131
132 /* If it's a single group and a single source, use 1-line output. */ 132 /* If it's a single group and a single source, use 1-line output. */
133 if (TTEST2(bp[0], 30) && bp[11] == 1 && 133 if (TTEST2(bp[0], 30) && bp[11] == 1 &&
134 ((njoin = EXTRACT_16BITS(&bp[20])) + EXTRACT_16BITS(&bp[22])) == 1) { 134 ((njoin = EXTRACT_16BITS(&bp[20])) + EXTRACT_16BITS(&bp[22])) == 1) {
135 int hold; 135 int hold;
136 136
137 (void)printf(" RPF %s ", ipaddr_string(bp)); 137 (void)printf(" RPF %s ", ipaddr_string(bp));
138 hold = EXTRACT_16BITS(&bp[6]); 138 hold = EXTRACT_16BITS(&bp[6]);
139 if (hold != 180) { 139 if (hold != 180) {
140 (void)printf("Hold "); 140 (void)printf("Hold ");
141 relts_print(hold); 141 relts_print(hold);
142 } 142 }
@@ -167,26 +167,28 @@ pimv1_join_prune_print(register const u_ @@ -167,26 +167,28 @@ pimv1_join_prune_print(register const u_
167 len -= 8; 167 len -= 8;
168 168
169 TCHECK2(bp[0], 4); 169 TCHECK2(bp[0], 4);
170 maddrlen = bp[1]; 170 maddrlen = bp[1];
171 addrlen = bp[2]; 171 addrlen = bp[2];
172 ngroups = bp[3]; 172 ngroups = bp[3];
173 bp += 4; 173 bp += 4;
174 len -= 4; 174 len -= 4;
175 while (ngroups--) { 175 while (ngroups--) {
176 /* 176 /*
177 * XXX - does the address have length "addrlen" and the 177 * XXX - does the address have length "addrlen" and the
178 * mask length "maddrlen"? 178 * mask length "maddrlen"?
179 */ 179 */
 180 __USE(addrlen);
 181 __USE(maddrlen);
180 TCHECK2(bp[0], sizeof(struct in_addr)); 182 TCHECK2(bp[0], sizeof(struct in_addr));
181 (void)printf("\n\tGroup: %s", ipaddr_string(bp)); 183 (void)printf("\n\tGroup: %s", ipaddr_string(bp));
182 TCHECK2(bp[4], sizeof(struct in_addr)); 184 TCHECK2(bp[4], sizeof(struct in_addr));
183 if (EXTRACT_32BITS(&bp[4]) != 0xffffffff) 185 if (EXTRACT_32BITS(&bp[4]) != 0xffffffff)
184 (void)printf("/%s", ipaddr_string(&bp[4])); 186 (void)printf("/%s", ipaddr_string(&bp[4]));
185 TCHECK2(bp[8], 4); 187 TCHECK2(bp[8], 4);
186 njoin = EXTRACT_16BITS(&bp[8]); 188 njoin = EXTRACT_16BITS(&bp[8]);
187 nprune = EXTRACT_16BITS(&bp[10]); 189 nprune = EXTRACT_16BITS(&bp[10]);
188 (void)printf(" joined: %d pruned: %d", njoin, nprune); 190 (void)printf(" joined: %d pruned: %d", njoin, nprune);
189 bp += 12; 191 bp += 12;
190 len -= 12; 192 len -= 12;
191 for (njp = 0; njp < (njoin + nprune); njp++) { 193 for (njp = 0; njp < (njoin + nprune); njp++) {
192 const char *type; 194 const char *type;

cvs diff -r1.3 -r1.4 src/external/bsd/tcpdump/dist/print-sctp.c (expand / switch to unified diff)

--- src/external/bsd/tcpdump/dist/print-sctp.c 2013/04/06 19:33:08 1.3
+++ src/external/bsd/tcpdump/dist/print-sctp.c 2013/10/20 02:58:34 1.4
@@ -29,27 +29,27 @@ @@ -29,27 +29,27 @@
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE. 33 * SUCH DAMAGE.
34 */ 34 */
35 35
36#include <sys/cdefs.h> 36#include <sys/cdefs.h>
37#ifndef lint 37#ifndef lint
38#if 0 38#if 0
39static const char rcsid[] _U_ = 39static const char rcsid[] _U_ =
40"@(#) Header: /tcpdump/master/tcpdump/print-sctp.c,v 1.21 2007-09-13 18:03:49 guy Exp (NETLAB/PEL)"; 40"@(#) Header: /tcpdump/master/tcpdump/print-sctp.c,v 1.21 2007-09-13 18:03:49 guy Exp (NETLAB/PEL)";
41#else 41#else
42__RCSID("$NetBSD: print-sctp.c,v 1.3 2013/04/06 19:33:08 christos Exp $"); 42__RCSID("$NetBSD: print-sctp.c,v 1.4 2013/10/20 02:58:34 christos Exp $");
43#endif 43#endif
44#endif 44#endif
45 45
46#ifdef HAVE_CONFIG_H 46#ifdef HAVE_CONFIG_H
47#include "config.h" 47#include "config.h"
48#endif 48#endif
49 49
50#include <tcpdump-stdinc.h> 50#include <tcpdump-stdinc.h>
51 51
52#include "sctpHeader.h" 52#include "sctpHeader.h"
53#include "sctpConstants.h" 53#include "sctpConstants.h"
54#include <assert.h> 54#include <assert.h>
55 55
@@ -339,30 +339,26 @@ void sctp_print(const u_char *bp,  @@ -339,30 +339,26 @@ void sctp_print(const u_char *bp,
339 339
340 340
341 /* print duplicate TSNs */ 341 /* print duplicate TSNs */
342 for (dupTSN = (const u_char *)frag, tsnNo=0; 342 for (dupTSN = (const u_char *)frag, tsnNo=0;
343 (const void *) dupTSN < nextChunk && tsnNo<EXTRACT_16BITS(&sack->numDupTsns); 343 (const void *) dupTSN < nextChunk && tsnNo<EXTRACT_16BITS(&sack->numDupTsns);
344 dupTSN += 4, tsnNo++) 344 dupTSN += 4, tsnNo++)
345 printf("\n\t\t[dup TSN #%u: %u] ", tsnNo+1, 345 printf("\n\t\t[dup TSN #%u: %u] ", tsnNo+1,
346 EXTRACT_32BITS(dupTSN)); 346 EXTRACT_32BITS(dupTSN));
347 347
348 break; 348 break;
349 } 349 }
350 case SCTP_HEARTBEAT_REQUEST : 350 case SCTP_HEARTBEAT_REQUEST :
351 { 351 {
352 const struct sctpHBsender *hb; 
353 
354 hb=(const struct sctpHBsender*)chunkDescPtr; 
355 
356 printf("[HB REQ] "); 352 printf("[HB REQ] ");
357 353
358 break; 354 break;
359 } 355 }
360 case SCTP_HEARTBEAT_ACK : 356 case SCTP_HEARTBEAT_ACK :
361 printf("[HB ACK] "); 357 printf("[HB ACK] ");
362 break; 358 break;
363 case SCTP_ABORT_ASSOCIATION : 359 case SCTP_ABORT_ASSOCIATION :
364 printf("[ABORT] "); 360 printf("[ABORT] ");
365 break; 361 break;
366 case SCTP_SHUTDOWN : 362 case SCTP_SHUTDOWN :
367 printf("[SHUTDOWN] "); 363 printf("[SHUTDOWN] ");
368 break; 364 break;

cvs diff -r1.4 -r1.5 src/external/bsd/tcpdump/dist/print-icmp6.c (expand / switch to unified diff)

--- src/external/bsd/tcpdump/dist/print-icmp6.c 2013/04/06 19:33:08 1.4
+++ src/external/bsd/tcpdump/dist/print-icmp6.c 2013/10/20 02:58:34 1.5
@@ -15,27 +15,27 @@ @@ -15,27 +15,27 @@
15 * or promote products derived from this software without specific prior 15 * or promote products derived from this software without specific prior
16 * written permission. 16 * written permission.
17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 18 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 */ 20 */
21 21
22#include <sys/cdefs.h> 22#include <sys/cdefs.h>
23#ifndef lint 23#ifndef lint
24#if 0 24#if 0
25static const char rcsid[] _U_ = 25static const char rcsid[] _U_ =
26 "@(#) Header: /tcpdump/master/tcpdump/print-icmp6.c,v 1.86 2008-02-05 19:36:13 guy Exp "; 26 "@(#) Header: /tcpdump/master/tcpdump/print-icmp6.c,v 1.86 2008-02-05 19:36:13 guy Exp ";
27#else 27#else
28__RCSID("$NetBSD: print-icmp6.c,v 1.4 2013/04/06 19:33:08 christos Exp $"); 28__RCSID("$NetBSD: print-icmp6.c,v 1.5 2013/10/20 02:58:34 christos Exp $");
29#endif 29#endif
30#endif 30#endif
31 31
32#ifdef HAVE_CONFIG_H 32#ifdef HAVE_CONFIG_H
33#include "config.h" 33#include "config.h"
34#endif 34#endif
35 35
36#ifdef INET6 36#ifdef INET6
37 37
38#include <tcpdump-stdinc.h> 38#include <tcpdump-stdinc.h>
39 39
40#include <stdio.h> 40#include <stdio.h>
41#include <string.h> 41#include <string.h>
@@ -669,29 +669,27 @@ get_upperlayer(u_char *bp, u_int *prot) @@ -669,29 +669,27 @@ get_upperlayer(u_char *bp, u_int *prot)
669 default: /* unknown or undecodable header */ 669 default: /* unknown or undecodable header */
670 *prot = nh; /* meaningless, but set here anyway */ 670 *prot = nh; /* meaningless, but set here anyway */
671 return(NULL); 671 return(NULL);
672 } 672 }
673 } 673 }
674 674
675 return(NULL); /* should be notreached, though */ 675 return(NULL); /* should be notreached, though */
676} 676}
677 677
678static void 678static void
679icmp6_opt_print(const u_char *bp, int resid) 679icmp6_opt_print(const u_char *bp, int resid)
680{ 680{
681 const struct nd_opt_hdr *op; 681 const struct nd_opt_hdr *op;
682 const struct nd_opt_hdr *opl; /* why there's no struct? */ 
683 const struct nd_opt_prefix_info *opp; 682 const struct nd_opt_prefix_info *opp;
684 const struct icmp6_opts_redirect *opr; 
685 const struct nd_opt_mtu *opm; 683 const struct nd_opt_mtu *opm;
686 const struct nd_opt_rdnss *oprd; 684 const struct nd_opt_rdnss *oprd;
687 const struct nd_opt_advinterval *opa; 685 const struct nd_opt_advinterval *opa;
688 const struct nd_opt_homeagent_info *oph; 686 const struct nd_opt_homeagent_info *oph;
689 const struct nd_opt_route_info *opri; 687 const struct nd_opt_route_info *opri;
690 const u_char *cp, *ep; 688 const u_char *cp, *ep;
691 struct in6_addr in6, *in6p; 689 struct in6_addr in6, *in6p;
692 size_t l; 690 size_t l;
693 u_int i; 691 u_int i;
694 692
695#define ECHECK(var) if ((u_char *)&(var) > ep - sizeof(var)) return 693#define ECHECK(var) if ((u_char *)&(var) > ep - sizeof(var)) return
696 694
697 cp = bp; 695 cp = bp;
@@ -707,48 +705,45 @@ icmp6_opt_print(const u_char *bp, int re @@ -707,48 +705,45 @@ icmp6_opt_print(const u_char *bp, int re
707 if (op->nd_opt_len == 0) 705 if (op->nd_opt_len == 0)
708 goto trunc; 706 goto trunc;
709 if (cp + (op->nd_opt_len << 3) > ep) 707 if (cp + (op->nd_opt_len << 3) > ep)
710 goto trunc; 708 goto trunc;
711 709
712 printf("\n\t %s option (%u), length %u (%u): ", 710 printf("\n\t %s option (%u), length %u (%u): ",
713 tok2str(icmp6_opt_values, "unknown", op->nd_opt_type), 711 tok2str(icmp6_opt_values, "unknown", op->nd_opt_type),
714 op->nd_opt_type, 712 op->nd_opt_type,
715 op->nd_opt_len << 3, 713 op->nd_opt_len << 3,
716 op->nd_opt_len); 714 op->nd_opt_len);
717 715
718 switch (op->nd_opt_type) { 716 switch (op->nd_opt_type) {
719 case ND_OPT_SOURCE_LINKADDR: 717 case ND_OPT_SOURCE_LINKADDR:
720 opl = (struct nd_opt_hdr *)op; 
721 l = (op->nd_opt_len << 3) - 2; 718 l = (op->nd_opt_len << 3) - 2;
722 print_lladdr(cp + 2, l); 719 print_lladdr(cp + 2, l);
723 break; 720 break;
724 case ND_OPT_TARGET_LINKADDR: 721 case ND_OPT_TARGET_LINKADDR:
725 opl = (struct nd_opt_hdr *)op; 
726 l = (op->nd_opt_len << 3) - 2; 722 l = (op->nd_opt_len << 3) - 2;
727 print_lladdr(cp + 2, l); 723 print_lladdr(cp + 2, l);
728 break; 724 break;
729 case ND_OPT_PREFIX_INFORMATION: 725 case ND_OPT_PREFIX_INFORMATION:
730 opp = (struct nd_opt_prefix_info *)op; 726 opp = (struct nd_opt_prefix_info *)op;
731 TCHECK(opp->nd_opt_pi_prefix); 727 TCHECK(opp->nd_opt_pi_prefix);
732 printf("%s/%u%s, Flags [%s], valid time %ss", 728 printf("%s/%u%s, Flags [%s], valid time %ss",
733 ip6addr_string(&opp->nd_opt_pi_prefix), 729 ip6addr_string(&opp->nd_opt_pi_prefix),
734 opp->nd_opt_pi_prefix_len, 730 opp->nd_opt_pi_prefix_len,
735 (op->nd_opt_len != 4) ? "badlen" : "", 731 (op->nd_opt_len != 4) ? "badlen" : "",
736 bittok2str(icmp6_opt_pi_flag_values, "none", opp->nd_opt_pi_flags_reserved), 732 bittok2str(icmp6_opt_pi_flag_values, "none", opp->nd_opt_pi_flags_reserved),
737 get_lifetime(EXTRACT_32BITS(&opp->nd_opt_pi_valid_time))); 733 get_lifetime(EXTRACT_32BITS(&opp->nd_opt_pi_valid_time)));
738 printf(", pref. time %ss", get_lifetime(EXTRACT_32BITS(&opp->nd_opt_pi_preferred_time))); 734 printf(", pref. time %ss", get_lifetime(EXTRACT_32BITS(&opp->nd_opt_pi_preferred_time)));
739 break; 735 break;
740 case ND_OPT_REDIRECTED_HEADER: 736 case ND_OPT_REDIRECTED_HEADER:
741 opr = (struct icmp6_opts_redirect *)op; 
742 print_unknown_data(bp,"\n\t ",op->nd_opt_len<<3); 737 print_unknown_data(bp,"\n\t ",op->nd_opt_len<<3);
743 /* xxx */ 738 /* xxx */
744 break; 739 break;
745 case ND_OPT_MTU: 740 case ND_OPT_MTU:
746 opm = (struct nd_opt_mtu *)op; 741 opm = (struct nd_opt_mtu *)op;
747 TCHECK(opm->nd_opt_mtu_mtu); 742 TCHECK(opm->nd_opt_mtu_mtu);
748 printf(" %u%s", 743 printf(" %u%s",
749 EXTRACT_32BITS(&opm->nd_opt_mtu_mtu), 744 EXTRACT_32BITS(&opm->nd_opt_mtu_mtu),
750 (op->nd_opt_len != 1) ? "bad option length" : "" ); 745 (op->nd_opt_len != 1) ? "bad option length" : "" );
751 break; 746 break;
752 case ND_OPT_RDNSS: 747 case ND_OPT_RDNSS:
753 oprd = (struct nd_opt_rdnss *)op; 748 oprd = (struct nd_opt_rdnss *)op;
754 l = (op->nd_opt_len - 1) / 2; 749 l = (op->nd_opt_len - 1) / 2;

cvs diff -r1.4 -r1.5 src/external/bsd/tcpdump/dist/print-isakmp.c (expand / switch to unified diff)

--- src/external/bsd/tcpdump/dist/print-isakmp.c 2013/04/06 19:33:08 1.4
+++ src/external/bsd/tcpdump/dist/print-isakmp.c 2013/10/20 02:58:34 1.5
@@ -24,27 +24,27 @@ @@ -24,27 +24,27 @@
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE. 27 * SUCH DAMAGE.
28 * 28 *
29 */ 29 */
30 30
31#include <sys/cdefs.h> 31#include <sys/cdefs.h>
32#ifndef lint 32#ifndef lint
33#if 0 33#if 0
34static const char rcsid[] _U_ = 34static const char rcsid[] _U_ =
35 "@(#) Header: /tcpdump/master/tcpdump/print-isakmp.c,v 1.61 2008-02-05 19:34:25 guy Exp (LBL)"; 35 "@(#) Header: /tcpdump/master/tcpdump/print-isakmp.c,v 1.61 2008-02-05 19:34:25 guy Exp (LBL)";
36#else 36#else
37__RCSID("$NetBSD: print-isakmp.c,v 1.4 2013/04/06 19:33:08 christos Exp $"); 37__RCSID("$NetBSD: print-isakmp.c,v 1.5 2013/10/20 02:58:34 christos Exp $");
38#endif 38#endif
39#endif 39#endif
40 40
41#define NETDISSECT_REWORKED 41#define NETDISSECT_REWORKED
42#ifdef HAVE_CONFIG_H 42#ifdef HAVE_CONFIG_H
43#include "config.h" 43#include "config.h"
44#endif 44#endif
45 45
46#include <tcpdump-stdinc.h> 46#include <tcpdump-stdinc.h>
47 47
48#include <string.h> 48#include <string.h>
49 49
50#include <stdio.h> 50#include <stdio.h>
@@ -540,46 +540,44 @@ ikev1_attr_print(netdissect_options *ndo @@ -540,46 +540,44 @@ ikev1_attr_print(netdissect_options *ndo
540 ND_PRINT((ndo,")")); 540 ND_PRINT((ndo,")"));
541 return p + totlen; 541 return p + totlen;
542} 542}
543 543
544static const u_char * 544static const u_char *
545ikev1_sa_print(netdissect_options *ndo, u_char tpay _U_, 545ikev1_sa_print(netdissect_options *ndo, u_char tpay _U_,
546 const struct isakmp_gen *ext, 546 const struct isakmp_gen *ext,
547 u_int item_len _U_, 547 u_int item_len _U_,
548 const u_char *ep, u_int32_t phase, u_int32_t doi0 _U_, 548 const u_char *ep, u_int32_t phase, u_int32_t doi0 _U_,
549 u_int32_t proto0, int depth) 549 u_int32_t proto0, int depth)
550{ 550{
551 const struct ikev1_pl_sa *p; 551 const struct ikev1_pl_sa *p;
552 struct ikev1_pl_sa sa; 552 struct ikev1_pl_sa sa;
553 const u_int32_t *q; 
554 u_int32_t doi, sit, ident; 553 u_int32_t doi, sit, ident;
555 const u_char *cp, *np; 554 const u_char *cp, *np;
556 int t; 555 int t;
557 556
558 ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_SA))); 557 ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_SA)));
559 558
560 p = (struct ikev1_pl_sa *)ext; 559 p = (struct ikev1_pl_sa *)ext;
561 ND_TCHECK(*p); 560 ND_TCHECK(*p);
562 safememcpy(&sa, ext, sizeof(sa)); 561 safememcpy(&sa, ext, sizeof(sa));
563 doi = ntohl(sa.doi); 562 doi = ntohl(sa.doi);
564 sit = ntohl(sa.sit); 563 sit = ntohl(sa.sit);
565 if (doi != 1) { 564 if (doi != 1) {
566 ND_PRINT((ndo," doi=%d", doi)); 565 ND_PRINT((ndo," doi=%d", doi));
567 ND_PRINT((ndo," situation=%u", (u_int32_t)ntohl(sa.sit))); 566 ND_PRINT((ndo," situation=%u", (u_int32_t)ntohl(sa.sit)));
568 return (u_char *)(p + 1); 567 return (u_char *)(p + 1);
569 } 568 }
570 569
571 ND_PRINT((ndo," doi=ipsec")); 570 ND_PRINT((ndo," doi=ipsec"));
572 q = (u_int32_t *)&sa.sit; 
573 ND_PRINT((ndo," situation=")); 571 ND_PRINT((ndo," situation="));
574 t = 0; 572 t = 0;
575 if (sit & 0x01) { 573 if (sit & 0x01) {
576 ND_PRINT((ndo,"identity")); 574 ND_PRINT((ndo,"identity"));
577 t++; 575 t++;
578 } 576 }
579 if (sit & 0x02) { 577 if (sit & 0x02) {
580 ND_PRINT((ndo,"%ssecrecy", t ? "+" : "")); 578 ND_PRINT((ndo,"%ssecrecy", t ? "+" : ""));
581 t++; 579 t++;
582 } 580 }
583 if (sit & 0x04) 581 if (sit & 0x04)
584 ND_PRINT((ndo,"%sintegrity", t ? "+" : "")); 582 ND_PRINT((ndo,"%sintegrity", t ? "+" : ""));
585 583
@@ -1763,27 +1761,26 @@ trunc: @@ -1763,27 +1761,26 @@ trunc:
1763 return NULL; 1761 return NULL;
1764} 1762}
1765 1763
1766/* notify payloads */ 1764/* notify payloads */
1767static const u_char * 1765static const u_char *
1768ikev2_n_print(netdissect_options *ndo, u_char tpay _U_,  1766ikev2_n_print(netdissect_options *ndo, u_char tpay _U_,
1769 const struct isakmp_gen *ext, 1767 const struct isakmp_gen *ext,
1770 u_int item_len _U_, const u_char *ep _U_, 1768 u_int item_len _U_, const u_char *ep _U_,
1771 u_int32_t phase _U_, u_int32_t doi _U_, 1769 u_int32_t phase _U_, u_int32_t doi _U_,
1772 u_int32_t proto _U_, int depth _U_) 1770 u_int32_t proto _U_, int depth _U_)
1773{ 1771{
1774 struct ikev2_n *p, n; 1772 struct ikev2_n *p, n;
1775 const u_char *cp; 1773 const u_char *cp;
1776 u_char *ep2; 
1777 u_char showspi, showdata, showsomedata; 1774 u_char showspi, showdata, showsomedata;
1778 const char *notify_name; 1775 const char *notify_name;
1779 u_int32_t type; 1776 u_int32_t type;
1780 1777
1781 p = (struct ikev2_n *)ext; 1778 p = (struct ikev2_n *)ext;
1782 ND_TCHECK(*p); 1779 ND_TCHECK(*p);
1783 safememcpy(&n, ext, sizeof(n)); 1780 safememcpy(&n, ext, sizeof(n));
1784 ikev2_pay_print(ndo, NPSTR(ISAKMP_NPTYPE_N), n.h.critical); 1781 ikev2_pay_print(ndo, NPSTR(ISAKMP_NPTYPE_N), n.h.critical);
1785 1782
1786 showspi = 1; 1783 showspi = 1;
1787 showdata = 0; 1784 showdata = 0;
1788 showsomedata=0; 1785 showsomedata=0;
1789 notify_name=NULL; 1786 notify_name=NULL;
@@ -1940,27 +1937,26 @@ ikev2_n_print(netdissect_options *ndo, u @@ -1940,27 +1937,26 @@ ikev2_n_print(netdissect_options *ndo, u
1940 1937
1941 if(notify_name) { 1938 if(notify_name) {
1942 ND_PRINT((ndo," type=%u(%s)", type, notify_name)); 1939 ND_PRINT((ndo," type=%u(%s)", type, notify_name));
1943 } 1940 }
1944  1941
1945 1942
1946 if (showspi && n.spi_size) { 1943 if (showspi && n.spi_size) {
1947 ND_PRINT((ndo," spi=")); 1944 ND_PRINT((ndo," spi="));
1948 if (!rawprint(ndo, (caddr_t)(p + 1), n.spi_size)) 1945 if (!rawprint(ndo, (caddr_t)(p + 1), n.spi_size))
1949 goto trunc; 1946 goto trunc;
1950 } 1947 }
1951 1948
1952 cp = (u_char *)(p + 1) + n.spi_size; 1949 cp = (u_char *)(p + 1) + n.spi_size;
1953 ep2 = (u_char *)p + item_len; 
1954 1950
1955 if(3 < ndo->ndo_vflag) { 1951 if(3 < ndo->ndo_vflag) {
1956 showdata = 1; 1952 showdata = 1;
1957 } 1953 }
1958 1954
1959 if ((showdata || (showsomedata && ep-cp < 30)) && cp < ep) { 1955 if ((showdata || (showsomedata && ep-cp < 30)) && cp < ep) {
1960 ND_PRINT((ndo," data=(")); 1956 ND_PRINT((ndo," data=("));
1961 if (!rawprint(ndo, (caddr_t)(cp), ep - cp)) 1957 if (!rawprint(ndo, (caddr_t)(cp), ep - cp))
1962 goto trunc; 1958 goto trunc;
1963 1959
1964 ND_PRINT((ndo,")")); 1960 ND_PRINT((ndo,")"));
1965 1961
1966 } else if(showsomedata && cp < ep) { 1962 } else if(showsomedata && cp < ep) {
@@ -2257,41 +2253,39 @@ ikev1_print(netdissect_options *ndo, @@ -2257,41 +2253,39 @@ ikev1_print(netdissect_options *ndo,
2257 ND_PRINT((ndo," R")); 2253 ND_PRINT((ndo," R"));
2258 else 2254 else
2259 ND_PRINT((ndo," ?")); 2255 ND_PRINT((ndo," ?"));
2260 } 2256 }
2261  2257
2262 ND_PRINT((ndo," %s", ETYPESTR(base->etype))); 2258 ND_PRINT((ndo," %s", ETYPESTR(base->etype)));
2263 if (base->flags) { 2259 if (base->flags) {
2264 ND_PRINT((ndo,"[%s%s]", base->flags & ISAKMP_FLAG_E ? "E" : "", 2260 ND_PRINT((ndo,"[%s%s]", base->flags & ISAKMP_FLAG_E ? "E" : "",
2265 base->flags & ISAKMP_FLAG_C ? "C" : "")); 2261 base->flags & ISAKMP_FLAG_C ? "C" : ""));
2266 } 2262 }
2267  2263
2268 if (ndo->ndo_vflag) { 2264 if (ndo->ndo_vflag) {
2269 const struct isakmp_gen *ext; 2265 const struct isakmp_gen *ext;
2270 int nparen; 
2271  2266
2272 ND_PRINT((ndo,":")); 2267 ND_PRINT((ndo,":"));
2273  2268
2274 /* regardless of phase... */ 2269 /* regardless of phase... */
2275 if (base->flags & ISAKMP_FLAG_E) { 2270 if (base->flags & ISAKMP_FLAG_E) {
2276 /* 2271 /*
2277 * encrypted, nothing we can do right now. 2272 * encrypted, nothing we can do right now.
2278 * we hope to decrypt the packet in the future... 2273 * we hope to decrypt the packet in the future...
2279 */ 2274 */
2280 ND_PRINT((ndo," [encrypted %s]", NPSTR(base->np))); 2275 ND_PRINT((ndo," [encrypted %s]", NPSTR(base->np)));
2281 goto done; 2276 goto done;
2282 } 2277 }
2283  2278
2284 nparen = 0; 
2285 CHECKLEN(p + 1, base->np); 2279 CHECKLEN(p + 1, base->np);
2286 np = base->np; 2280 np = base->np;
2287 ext = (struct isakmp_gen *)(p + 1); 2281 ext = (struct isakmp_gen *)(p + 1);
2288 ikev1_sub_print(ndo, np, ext, ep, phase, 0, 0, 0); 2282 ikev1_sub_print(ndo, np, ext, ep, phase, 0, 0, 0);
2289 } 2283 }
2290  2284
2291done: 2285done:
2292 if (ndo->ndo_vflag) { 2286 if (ndo->ndo_vflag) {
2293 if (ntohl(base->len) != length) { 2287 if (ntohl(base->len) != length) {
2294 ND_PRINT((ndo," (len mismatch: isakmp %u/ip %u)", 2288 ND_PRINT((ndo," (len mismatch: isakmp %u/ip %u)",
2295 (u_int32_t)ntohl(base->len), length)); 2289 (u_int32_t)ntohl(base->len), length));
2296 } 2290 }
2297 } 2291 }
@@ -2414,41 +2408,39 @@ ikev2_print(netdissect_options *ndo, @@ -2414,41 +2408,39 @@ ikev2_print(netdissect_options *ndo,
2414 else 2408 else
2415 ND_PRINT((ndo, " child_sa ")); 2409 ND_PRINT((ndo, " child_sa "));
2416 2410
2417 ND_PRINT((ndo, " %s", ETYPESTR(base->etype))); 2411 ND_PRINT((ndo, " %s", ETYPESTR(base->etype)));
2418 if (base->flags) { 2412 if (base->flags) {
2419 ND_PRINT((ndo, "[%s%s%s]", 2413 ND_PRINT((ndo, "[%s%s%s]",
2420 base->flags & ISAKMP_FLAG_I ? "I" : "", 2414 base->flags & ISAKMP_FLAG_I ? "I" : "",
2421 base->flags & ISAKMP_FLAG_V ? "V" : "", 2415 base->flags & ISAKMP_FLAG_V ? "V" : "",
2422 base->flags & ISAKMP_FLAG_R ? "R" : "")); 2416 base->flags & ISAKMP_FLAG_R ? "R" : ""));
2423 } 2417 }
2424 2418
2425 if (ndo->ndo_vflag) { 2419 if (ndo->ndo_vflag) {
2426 const struct isakmp_gen *ext; 2420 const struct isakmp_gen *ext;
2427 int nparen; 
2428 2421
2429 ND_PRINT((ndo, ":")); 2422 ND_PRINT((ndo, ":"));
2430 2423
2431 /* regardless of phase... */ 2424 /* regardless of phase... */
2432 if (base->flags & ISAKMP_FLAG_E) { 2425 if (base->flags & ISAKMP_FLAG_E) {
2433 /* 2426 /*
2434 * encrypted, nothing we can do right now. 2427 * encrypted, nothing we can do right now.
2435 * we hope to decrypt the packet in the future... 2428 * we hope to decrypt the packet in the future...
2436 */ 2429 */
2437 ND_PRINT((ndo, " [encrypted %s]", NPSTR(base->np))); 2430 ND_PRINT((ndo, " [encrypted %s]", NPSTR(base->np)));
2438 goto done; 2431 goto done;
2439 } 2432 }
2440 2433
2441 nparen = 0; 
2442 CHECKLEN(p + 1, base->np) 2434 CHECKLEN(p + 1, base->np)
2443 2435
2444 np = base->np; 2436 np = base->np;
2445 ext = (struct isakmp_gen *)(p + 1); 2437 ext = (struct isakmp_gen *)(p + 1);
2446 ikev2_sub_print(ndo, base, np, ext, ep, phase, 0, 0, 0); 2438 ikev2_sub_print(ndo, base, np, ext, ep, phase, 0, 0, 0);
2447 } 2439 }
2448 2440
2449done: 2441done:
2450 if (ndo->ndo_vflag) { 2442 if (ndo->ndo_vflag) {
2451 if (ntohl(base->len) != length) { 2443 if (ntohl(base->len) != length) {
2452 ND_PRINT((ndo, " (len mismatch: isakmp %u/ip %u)", 2444 ND_PRINT((ndo, " (len mismatch: isakmp %u/ip %u)",
2453 (u_int32_t)ntohl(base->len), length)); 2445 (u_int32_t)ntohl(base->len), length));
2454 } 2446 }
@@ -2512,29 +2504,26 @@ isakmp_print(netdissect_options *ndo, @@ -2512,29 +2504,26 @@ isakmp_print(netdissect_options *ndo,
2512 break; 2504 break;
2513 2505
2514 case IKEv2_MAJOR_VERSION: 2506 case IKEv2_MAJOR_VERSION:
2515 ikev2_print(ndo, bp, length, bp2, &base); 2507 ikev2_print(ndo, bp, length, bp2, &base);
2516 break; 2508 break;
2517 } 2509 }
2518} 2510}
2519 2511
2520void 2512void
2521isakmp_rfc3948_print(netdissect_options *ndo, 2513isakmp_rfc3948_print(netdissect_options *ndo,
2522 const u_char *bp, u_int length, 2514 const u_char *bp, u_int length,
2523 const u_char *bp2) 2515 const u_char *bp2)
2524{ 2516{
2525 const u_char *ep; 
2526 ep = ndo->ndo_snapend; 
2527 
2528 if(length == 1 && bp[0]==0xff) { 2517 if(length == 1 && bp[0]==0xff) {
2529 ND_PRINT((ndo, "isakmp-nat-keep-alive")); 2518 ND_PRINT((ndo, "isakmp-nat-keep-alive"));
2530 return; 2519 return;
2531 } 2520 }
2532 2521
2533 if(length < 4) { 2522 if(length < 4) {
2534 goto trunc; 2523 goto trunc;
2535 } 2524 }
2536  2525
2537 /* 2526 /*
2538 * see if this is an IKE packet 2527 * see if this is an IKE packet
2539 */ 2528 */
2540 if(bp[0]==0 && bp[1]==0 && bp[2]==0 && bp[3]==0) { 2529 if(bp[0]==0 && bp[1]==0 && bp[2]==0 && bp[3]==0) {