Lines Matching +full:a +full:- +full:ilm
3 /*-
4 * SPDX-License-Identifier: BSD-3-Clause
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
34 /*-
55 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
67 * traceroute host - trace the route ip packets follow going to "host".
71 * packets with a small ttl (time to live) then listening for an
72 * icmp "time exceeded" reply from a gateway. We start our probes
73 * with a ttl of one and increase by one until we get an icmp "port
74 * unreachable" (which means we got to "host") or hit a max (which
75 * defaults to net.inet.ip.ttl hops & can be changed with the -m flag).
76 * Three probes (change with -q flag) are sent at each ttl setting and
77 * a line is printed showing the ttl, address of the gateway and
80 * be printed. If there is no response within a 5 sec. timeout
81 * interval (changed with the -w flag), a "*" is printed for that
87 * value, it can be changed with the -p flag).
89 * A sample use might be:
94 * 2 lilac-dmc.Berkeley.EDU (128.32.216.1) 39 ms 39 ms 19 ms
95 * 3 lilac-dmc.Berkeley.EDU (128.32.216.1) 39 ms 39 ms 19 ms
96 * 4 ccngw-ner-cc.Berkeley.EDU (128.32.136.23) 39 ms 40 ms 39 ms
97 * 5 ccn-nerif22.Berkeley.EDU (128.32.168.22) 39 ms 39 ms 39 ms
105 * Note that lines 2 & 3 are the same. This is due to a buggy
106 * kernel on the 2nd hop system -- lbl-csam.arpa -- that forwards
107 * packets with a zero ttl.
109 * A more interesting example is:
114 * 2 lilac-dmc.Berkeley.EDU (128.32.216.1) 19 ms 19 ms 19 ms
115 * 3 lilac-dmc.Berkeley.EDU (128.32.216.1) 39 ms 19 ms 19 ms
116 * 4 ccngw-ner-cc.Berkeley.EDU (128.32.136.23) 19 ms 39 ms 39 ms
117 * 5 ccn-nerif22.Berkeley.EDU (128.32.168.22) 20 ms 39 ms 39 ms
135 * with a ttl too small to reach us. 14 - 17 are running the
139 * The silent gateway 12 in the above may be the result of a bug in
148 * 2 lilac-dmc.Berkeley.EDU (128.32.216.1) 39 ms 19 ms 39 ms
149 * 3 lilac-dmc.Berkeley.EDU (128.32.216.1) 19 ms 39 ms 19 ms
150 * 4 ccngw-ner-cc.Berkeley.EDU (128.32.136.23) 39 ms 40 ms 19 ms
151 * 5 ccn-nerif35.Berkeley.EDU (128.32.168.35) 39 ms 39 ms 39 ms
163 * What's really happening is that rip (a Sun-3 running Sun OS3.5)
167 * icmp's) until we probe with a ttl that's at least twice the path
168 * length. I.e., rip is really only 7 hops away. A reply that
169 * returns with a ttl of 1 is a clue this problem exists.
170 * Traceroute prints a "!" after the time if the ttl is <= 1.
171 * Since vendors ship a lot of obsolete (DEC's Ultrix, Sun 3.x) or
172 * non-standard (HPUX) software, expect to see this problem
176 * Other possible annotations after the time are !H, !N, !P (got a host,
178 * route failed or fragmentation needed -- neither of these should
184 * -----
186 * you *don't* make it setuid -- casual use could result in a lot
189 * This program requires a kernel mod that does not appear in any
190 * system available from Berkeley: A raw ip socket using proto
193 * file that came with the source to this program for a description
200 * data from the original datagram. 8 bytes is the size of a udp
205 * it would have taken a lot more kernel hacking to allow this
210 * replied to (so times and/or hop counts don't get confused by a
214 * Don't use this as a coding example. I was trying to find a
215 * routing problem and this code sort-of popped out after 48 hours
223 * glad they didn't keep the idea a secret.
228 * I've hacked up a round-trip-route version of this that works by
229 * sending a loose-source-routed udp datagram through the destination
233 * -- Van Jacobson (van@ee.lbl.gov)
336 static int tclass = -1;
405 while ((ch = getopt(argc, argv, "aA:dEf:g:Ilm:nNp:q:rs:St:TUvw:")) != -1) in main()
407 case 'a': in main()
410 case 'A': in main()
452 (struct in6_addr *)hp->h_addr)) { in main()
517 * probe (e.g., on a multi-homed host). in main()
562 argc -= optind; in main()
591 if (tclass != -1) { in main()
601 if (setresuid(uid, uid, uid) == -1) { in main()
606 if (tclass != -1) { in main()
608 sizeof(int)) == -1) { in main()
636 if (res->ai_addrlen != sizeof(Dst)) { in main()
641 memcpy(&Dst, res->ai_addr, res->ai_addrlen); in main()
642 hostname = res->ai_canonname ? strdup(res->ai_canonname) : *argv; in main()
647 if (res->ai_next) { in main()
648 if (cap_getnameinfo(capdns, res->ai_addr, res->ai_addrlen, hbuf, in main()
697 "traceroute6: packet size must be a multiple of 4.\n"); in main()
777 rth->ip6r_len = rth->ip6r_segleft * 2; in main()
779 (void *)rth, (rth->ip6r_len + 1) << 3)) { in main()
831 if (res->ai_addrlen > sizeof(Src)) { in main()
836 memcpy(&Src, res->ai_addr, res->ai_addrlen); in main()
914 printf("Skipping %lu intermediate hops\n", first_hop - 1); in main()
1004 printf(" !A"); in main()
1090 return (-1); in setpolicy()
1125 icp->icmp6_type = ICMP6_ECHO_REQUEST; in send_probe()
1126 icp->icmp6_code = 0; in send_probe()
1127 icp->icmp6_cksum = 0; in send_probe()
1128 icp->icmp6_id = ident; in send_probe()
1129 icp->icmp6_seq = htons(seq); in send_probe()
1133 outudp->uh_sport = htons(ident); in send_probe()
1134 outudp->uh_dport = htons(port + seq); in send_probe()
1135 outudp->uh_ulen = htons(datalen); in send_probe()
1136 outudp->uh_sum = 0; in send_probe()
1137 outudp->uh_sum = udp_cksum(&Src, &Dst, outpacket, datalen); in send_probe()
1145 sctp->src_port = htons(ident); in send_probe()
1146 sctp->dest_port = htons(port + seq); in send_probe()
1149 sctp->v_tag = 0; in send_probe()
1151 sctp->v_tag = (sctp->src_port << 16) | sctp->dest_port; in send_probe()
1153 sctp->checksum = htonl(0); in send_probe()
1157 * Send a packet containing an INIT chunk. This works in send_probe()
1159 * results in a probe packet containing at least in send_probe()
1161 * SHUTDOWN-ACK chunks. in send_probe()
1164 init->ch.chunk_type = SCTP_INITIATION; in send_probe()
1165 init->ch.chunk_flags = 0; in send_probe()
1166 init->ch.chunk_length = htons((u_int16_t)(datalen - in send_probe()
1168 init->init.initiate_tag = (sctp->src_port << 16) | in send_probe()
1169 sctp->dest_port; in send_probe()
1170 init->init.a_rwnd = htonl(1500); in send_probe()
1171 init->init.num_outbound_streams = htons(1); in send_probe()
1172 init->init.num_inbound_streams = htons(1); in send_probe()
1173 init->init.initial_tsn = htonl(0); in send_probe()
1178 param->param_type = htons(SCTP_PAD); in send_probe()
1179 param->param_length = in send_probe()
1180 htons((u_int16_t)(datalen - in send_probe()
1181 sizeof(struct sctphdr) - in send_probe()
1186 * Send a packet containing a SHUTDOWN-ACK chunk, in send_probe()
1187 * possibly followed by a PAD chunk. in send_probe()
1192 chk->chunk_type = SCTP_SHUTDOWN_ACK; in send_probe()
1193 chk->chunk_flags = 0; in send_probe()
1194 chk->chunk_length = htons(4); in send_probe()
1199 chk->chunk_type = SCTP_PAD_CHUNK; in send_probe()
1200 chk->chunk_flags = 0; in send_probe()
1201 chk->chunk_length = htons((u_int16_t)(datalen - in send_probe()
1202 sizeof(struct sctphdr) - in send_probe()
1206 sctp->checksum = sctp_crc32c(outpacket, datalen); in send_probe()
1211 tcp->th_sport = htons(ident); in send_probe()
1212 tcp->th_dport = htons(port + seq); in send_probe()
1213 tcp->th_seq = (tcp->th_sport << 16) | tcp->th_dport; in send_probe()
1214 tcp->th_ack = 0; in send_probe()
1215 tcp->th_off = 5; in send_probe()
1216 tcp->th_flags = TH_SYN; in send_probe()
1217 tcp->th_sum = 0; in send_probe()
1218 tcp->th_sum = tcp_chksum(&Src, &Dst, outpacket, datalen); in send_probe()
1242 if (cm->cmsg_level == IPPROTO_IPV6 && in get_hoplim()
1243 cm->cmsg_type == IPV6_HOPLIMIT && in get_hoplim()
1244 cm->cmsg_len == CMSG_LEN(sizeof(int))) in get_hoplim()
1248 return (-1); in get_hoplim()
1256 dt = (double)(t2p->tv_sec - t1p->tv_sec) * 1000.0 + in deltaT()
1257 (double)(t2p->tv_usec - t1p->tv_usec) / 1000.0; in deltaT()
1262 * Convert an ICMP "type" field to a printable string.
1325 struct sockaddr_in6 *from = (struct sockaddr_in6 *)mhdr->msg_name; in packet_ok()
1326 char *buf = (char *)mhdr->msg_iov[0].iov_base; in packet_ok()
1341 if (cap_getnameinfo(capdns, (struct sockaddr *)from, from->sin6_len, in packet_ok()
1349 cc -= hlen; in packet_ok()
1354 if (cap_getnameinfo(capdns, (struct sockaddr *)from, from->sin6_len, in packet_ok()
1368 if (cm->cmsg_level == IPPROTO_IPV6 && in packet_ok()
1369 cm->cmsg_type == IPV6_PKTINFO && in packet_ok()
1370 cm->cmsg_len == in packet_ok()
1374 if (cm->cmsg_level == IPPROTO_IPV6 && in packet_ok()
1375 cm->cmsg_type == IPV6_HOPLIMIT && in packet_ok()
1376 cm->cmsg_len == CMSG_LEN(sizeof(int))) in packet_ok()
1389 *type = icp->icmp6_type; in packet_ok()
1390 *code = icp->icmp6_code; in packet_ok()
1405 *ecn = ntohl(hip->ip6_flow & IPV6_ECN_MASK) >> 20; in packet_ok()
1414 if (icmp->icmp6_id == ident && in packet_ok()
1415 icmp->icmp6_seq == htons(seq)) in packet_ok()
1420 if (udp->uh_sport == htons(ident) && in packet_ok()
1421 udp->uh_dport == htons(port + seq)) in packet_ok()
1426 if (sctp->src_port != htons(ident) || in packet_ok()
1427 sctp->dest_port != htons(port + seq)) { in packet_ok()
1432 if (sctp->v_tag != 0) { in packet_ok()
1437 if ((char *)&init->init.a_rwnd > buf + cc) { in packet_ok()
1440 if (init->init.initiate_tag == (u_int32_t) in packet_ok()
1441 ((sctp->src_port << 16) | sctp->dest_port)) { in packet_ok()
1445 if (sctp->v_tag == in packet_ok()
1446 (u_int32_t)((sctp->src_port << 16) | in packet_ok()
1447 sctp->dest_port)) { in packet_ok()
1454 if (tcp->th_sport == htons(ident) && in packet_ok()
1455 tcp->th_dport == htons(port + seq) && in packet_ok()
1456 tcp->th_seq == in packet_ok()
1457 (tcp_seq)((tcp->th_sport << 16) | tcp->th_dport)) in packet_ok()
1467 if (icp->icmp6_id == ident && in packet_ok()
1468 icp->icmp6_seq == htons(seq)) in packet_ok()
1476 if (cap_getnameinfo(capdns, (struct sockaddr *)from, from->sin6_len, in packet_ok()
1480 rcvpktinfo ? inet_ntop(AF_INET6, &rcvpktinfo->ipi6_addr, in packet_ok()
1492 if (i % WIDTH == WIDTH - 1) in packet_ok()
1514 nh = ip6->ip6_nxt; in get_uphdr()
1517 while (lim - cp >= (nh == IPPROTO_NONE ? 0 : 8)) { in get_uphdr()
1531 nh = ((struct ip6_frag *)cp)->ip6f_nxt; in get_uphdr()
1534 hlen = (((struct ip6_ext *)cp)->ip6e_len + 2) << 2; in get_uphdr()
1535 nh = ((struct ip6_ext *)cp)->ip6e_nxt; in get_uphdr()
1538 hlen = (((struct ip6_ext *)cp)->ip6e_len + 1) << 3; in get_uphdr()
1539 nh = ((struct ip6_ext *)cp)->ip6e_nxt; in get_uphdr()
1575 struct sockaddr_in6 *from = (struct sockaddr_in6 *)mhdr->msg_name; in print()
1578 if (cap_getnameinfo(capdns, (struct sockaddr *)from, from->sin6_len, in print()
1591 rcvpktinfo ? inet_ntop(AF_INET6, &rcvpktinfo->ipi6_addr, in print()
1595 rcvpktinfo ? inet_ntop(AF_INET6, &rcvpktinfo->ipi6_addr, in print()
1623 if (cap_getnameinfo(capdns, sa, sa->sa_len, line, sizeof(line), NULL, 0, in inetname()
1634 if (cap_getnameinfo(capdns, sa, sa->sa_len, line, sizeof(line), NULL, 0, in inetname()
1741 * Our algorithm is simple, using a 32 bit accumulator (sum), in in_cksum()
1748 nleft -= 2; in in_cksum()
1777 pseudo_hdr.src = src->sin6_addr; in udp_cksum()
1778 pseudo_hdr.dst = dst->sin6_addr; in udp_cksum()
1804 pseudo_hdr.src = src->sin6_addr; in tcp_chksum()
1805 pseudo_hdr.dst = dst->sin6_addr; in tcp_chksum()
1822 "Usage: traceroute6 [-adEIlnNrSTUv] [-A as_server] [-f firsthop] [-g gateway]\n" in usage()
1823 "\t[-m hoplimit] [-p port] [-q probes] [-s src] [-t tclass]\n" in usage()
1824 "\t[-w waittime] target [datalen]\n"); in usage()