traceroute6.c (1f69b3fb55ee0c91b14d428fa114a2c812c723a9) | traceroute6.c (af58a3c6bf09911a4a2092b38ad1b056a83fac50) |
---|---|
1/* $KAME: traceroute6.c,v 1.68 2004/01/25 11:16:12 suz Exp $ */ 2 3/*- 4 * SPDX-License-Identifier: BSD-3-Clause 5 * 6 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 7 * All rights reserved. 8 * --- 317 unchanged lines hidden (view full) --- 326int rcvhlim; 327struct in6_pktinfo *rcvpktinfo; 328 329struct sockaddr_in6 Src, Dst, Rcv; 330u_long datalen = 20; /* How much data */ 331#define ICMP6ECHOLEN 8 332/* XXX: 2064 = 127(max hops in type 0 rthdr) * sizeof(ip6_hdr) + 16(margin) */ 333char rtbuf[2064]; | 1/* $KAME: traceroute6.c,v 1.68 2004/01/25 11:16:12 suz Exp $ */ 2 3/*- 4 * SPDX-License-Identifier: BSD-3-Clause 5 * 6 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 7 * All rights reserved. 8 * --- 317 unchanged lines hidden (view full) --- 326int rcvhlim; 327struct in6_pktinfo *rcvpktinfo; 328 329struct sockaddr_in6 Src, Dst, Rcv; 330u_long datalen = 20; /* How much data */ 331#define ICMP6ECHOLEN 8 332/* XXX: 2064 = 127(max hops in type 0 rthdr) * sizeof(ip6_hdr) + 16(margin) */ 333char rtbuf[2064]; |
334#ifdef USE_RFC2292BIS | |
335struct ip6_rthdr *rth; | 334struct ip6_rthdr *rth; |
336#endif | |
337struct cmsghdr *cmsg; 338 339char *source = NULL; 340char *hostname; 341 342u_long nprobes = 3; 343u_long first_hop = 1; 344u_long max_hops = 30; --- 85 unchanged lines hidden (view full) --- 430 break; 431 case 'g': 432 hp = getipnodebyname(optarg, AF_INET6, 0, &h_errno); 433 if (hp == NULL) { 434 fprintf(stderr, 435 "traceroute6: unknown host %s\n", optarg); 436 exit(1); 437 } | 335struct cmsghdr *cmsg; 336 337char *source = NULL; 338char *hostname; 339 340u_long nprobes = 3; 341u_long first_hop = 1; 342u_long max_hops = 30; --- 85 unchanged lines hidden (view full) --- 428 break; 429 case 'g': 430 hp = getipnodebyname(optarg, AF_INET6, 0, &h_errno); 431 if (hp == NULL) { 432 fprintf(stderr, 433 "traceroute6: unknown host %s\n", optarg); 434 exit(1); 435 } |
438#ifdef USE_RFC2292BIS | |
439 if (rth == NULL) { 440 /* 441 * XXX: We can't detect the number of 442 * intermediate nodes yet. 443 */ 444 if ((rth = inet6_rth_init((void *)rtbuf, 445 sizeof(rtbuf), IPV6_RTHDR_TYPE_0, 446 0)) == NULL) { --- 4 unchanged lines hidden (view full) --- 451 } 452 if (inet6_rth_add((void *)rth, 453 (struct in6_addr *)hp->h_addr)) { 454 fprintf(stderr, 455 "inet6_rth_add failed for %s\n", 456 optarg); 457 exit(1); 458 } | 436 if (rth == NULL) { 437 /* 438 * XXX: We can't detect the number of 439 * intermediate nodes yet. 440 */ 441 if ((rth = inet6_rth_init((void *)rtbuf, 442 sizeof(rtbuf), IPV6_RTHDR_TYPE_0, 443 0)) == NULL) { --- 4 unchanged lines hidden (view full) --- 448 } 449 if (inet6_rth_add((void *)rth, 450 (struct in6_addr *)hp->h_addr)) { 451 fprintf(stderr, 452 "inet6_rth_add failed for %s\n", 453 optarg); 454 exit(1); 455 } |
459#else /* old advanced API */ 460 if (cmsg == NULL) 461 cmsg = inet6_rthdr_init(rtbuf, IPV6_RTHDR_TYPE_0); 462 inet6_rthdr_add(cmsg, (struct in6_addr *)hp->h_addr, 463 IPV6_RTHDR_LOOSE); 464#endif | |
465 freehostent(hp); 466 break; 467 case 'I': 468 useproto = IPPROTO_ICMPV6; 469 break; 470 case 'l': 471 lflag++; 472 break; --- 285 unchanged lines hidden (view full) --- 758 } 759#endif /* SO_SNDBUF */ 760 if (options & SO_DEBUG) 761 (void) setsockopt(sndsock, SOL_SOCKET, SO_DEBUG, 762 (char *)&on, sizeof(on)); 763 if (options & SO_DONTROUTE) 764 (void) setsockopt(sndsock, SOL_SOCKET, SO_DONTROUTE, 765 (char *)&on, sizeof(on)); | 456 freehostent(hp); 457 break; 458 case 'I': 459 useproto = IPPROTO_ICMPV6; 460 break; 461 case 'l': 462 lflag++; 463 break; --- 285 unchanged lines hidden (view full) --- 749 } 750#endif /* SO_SNDBUF */ 751 if (options & SO_DEBUG) 752 (void) setsockopt(sndsock, SOL_SOCKET, SO_DEBUG, 753 (char *)&on, sizeof(on)); 754 if (options & SO_DONTROUTE) 755 (void) setsockopt(sndsock, SOL_SOCKET, SO_DONTROUTE, 756 (char *)&on, sizeof(on)); |
766#ifdef USE_RFC2292BIS | |
767 if (rth) {/* XXX: there is no library to finalize the header... */ 768 rth->ip6r_len = rth->ip6r_segleft * 2; 769 if (setsockopt(sndsock, IPPROTO_IPV6, IPV6_RTHDR, 770 (void *)rth, (rth->ip6r_len + 1) << 3)) { 771 fprintf(stderr, "setsockopt(IPV6_RTHDR): %s\n", 772 strerror(errno)); 773 exit(1); 774 } 775 } | 757 if (rth) {/* XXX: there is no library to finalize the header... */ 758 rth->ip6r_len = rth->ip6r_segleft * 2; 759 if (setsockopt(sndsock, IPPROTO_IPV6, IPV6_RTHDR, 760 (void *)rth, (rth->ip6r_len + 1) << 3)) { 761 fprintf(stderr, "setsockopt(IPV6_RTHDR): %s\n", 762 strerror(errno)); 763 exit(1); 764 } 765 } |
776#else /* old advanced API */ 777 if (cmsg != NULL) { 778 inet6_rthdr_lasthop(cmsg, IPV6_RTHDR_LOOSE); 779 if (setsockopt(sndsock, IPPROTO_IPV6, IPV6_PKTOPTIONS, 780 rtbuf, cmsg->cmsg_len) < 0) { 781 fprintf(stderr, "setsockopt(IPV6_PKTOPTIONS): %s\n", 782 strerror(errno)); 783 exit(1); 784 } 785 } 786#endif /* USE_RFC2292BIS */ | |
787#ifdef IPSEC 788#ifdef IPSEC_POLICY_IPSEC 789 /* 790 * do not raise error even if setsockopt fails, kernel may have ipsec 791 * turned off. 792 */ 793 if (setpolicy(sndsock, "in bypass") < 0) 794 errx(1, "%s", ipsec_strerror()); --- 943 unchanged lines hidden --- | 766#ifdef IPSEC 767#ifdef IPSEC_POLICY_IPSEC 768 /* 769 * do not raise error even if setsockopt fails, kernel may have ipsec 770 * turned off. 771 */ 772 if (setpolicy(sndsock, "in bypass") < 0) 773 errx(1, "%s", ipsec_strerror()); --- 943 unchanged lines hidden --- |