Lines Matching +full:cm +full:- +full:poll +full:- +full:mode

3 /*-
4 * SPDX-License-Identifier: BSD-3-Clause
34 /*-
67 * traceroute host - trace the route ip packets follow going to "host".
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
81 * interval (changed with the -w flag), a "*" is printed for that
87 * value, it can be changed with the -p flag).
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
106 * kernel on the 2nd hop system -- lbl-csam.arpa -- that forwards
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
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)
172 * non-standard (HPUX) software, expect to see this problem
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
215 * routing problem and this code sort-of popped out after 48 hours
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)
258 #include <poll.h>
336 static int tclass = -1;
405 while ((ch = getopt(argc, argv, "aA:dEf:g:Ilm:nNp:q:rs:St:TUvw:")) != -1) in main()
431 /* XXX use after capability mode is entered */ 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()
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()
923 * Here we enter capability mode. Further down access to global in main()
1060 if (poll(pfd, 1, waittime * 1000) > 0 && in wait_for_reply()
1094 return (-1); in setpolicy()
1129 icp->icmp6_type = ICMP6_ECHO_REQUEST; in send_probe()
1130 icp->icmp6_code = 0; in send_probe()
1131 icp->icmp6_cksum = 0; in send_probe()
1132 icp->icmp6_id = ident; in send_probe()
1133 icp->icmp6_seq = htons(seq); in send_probe()
1137 outudp->uh_sport = htons(ident); in send_probe()
1138 outudp->uh_dport = htons(port + seq); in send_probe()
1139 outudp->uh_ulen = htons(datalen); in send_probe()
1140 outudp->uh_sum = 0; in send_probe()
1141 outudp->uh_sum = udp_cksum(&Src, &Dst, outpacket, datalen); in send_probe()
1149 sctp->src_port = htons(ident); in send_probe()
1150 sctp->dest_port = htons(port + seq); in send_probe()
1153 sctp->v_tag = 0; in send_probe()
1155 sctp->v_tag = (sctp->src_port << 16) | sctp->dest_port; in send_probe()
1157 sctp->checksum = htonl(0); in send_probe()
1165 * SHUTDOWN-ACK chunks. in send_probe()
1168 init->ch.chunk_type = SCTP_INITIATION; in send_probe()
1169 init->ch.chunk_flags = 0; in send_probe()
1170 init->ch.chunk_length = htons((u_int16_t)(datalen - in send_probe()
1172 init->init.initiate_tag = (sctp->src_port << 16) | in send_probe()
1173 sctp->dest_port; in send_probe()
1174 init->init.a_rwnd = htonl(1500); in send_probe()
1175 init->init.num_outbound_streams = htons(1); in send_probe()
1176 init->init.num_inbound_streams = htons(1); in send_probe()
1177 init->init.initial_tsn = htonl(0); in send_probe()
1182 param->param_type = htons(SCTP_PAD); in send_probe()
1183 param->param_length = in send_probe()
1184 htons((u_int16_t)(datalen - in send_probe()
1185 sizeof(struct sctphdr) - in send_probe()
1190 * Send a packet containing a SHUTDOWN-ACK chunk, in send_probe()
1196 chk->chunk_type = SCTP_SHUTDOWN_ACK; in send_probe()
1197 chk->chunk_flags = 0; in send_probe()
1198 chk->chunk_length = htons(4); in send_probe()
1203 chk->chunk_type = SCTP_PAD_CHUNK; in send_probe()
1204 chk->chunk_flags = 0; in send_probe()
1205 chk->chunk_length = htons((u_int16_t)(datalen - in send_probe()
1206 sizeof(struct sctphdr) - in send_probe()
1210 sctp->checksum = sctp_crc32c(outpacket, datalen); in send_probe()
1215 tcp->th_sport = htons(ident); in send_probe()
1216 tcp->th_dport = htons(port + seq); in send_probe()
1217 tcp->th_seq = (tcp->th_sport << 16) | tcp->th_dport; in send_probe()
1218 tcp->th_ack = 0; in send_probe()
1219 tcp->th_off = 5; in send_probe()
1221 tcp->th_sum = 0; in send_probe()
1222 tcp->th_sum = tcp_chksum(&Src, &Dst, outpacket, datalen); in send_probe()
1242 struct cmsghdr *cm; in get_hoplim() local
1244 for (cm = (struct cmsghdr *)CMSG_FIRSTHDR(mhdr); cm; in get_hoplim()
1245 cm = (struct cmsghdr *)CMSG_NXTHDR(mhdr, cm)) { in get_hoplim()
1246 if (cm->cmsg_level == IPPROTO_IPV6 && in get_hoplim()
1247 cm->cmsg_type == IPV6_HOPLIMIT && in get_hoplim()
1248 cm->cmsg_len == CMSG_LEN(sizeof(int))) in get_hoplim()
1249 return (*(int *)CMSG_DATA(cm)); in get_hoplim()
1252 return (-1); in get_hoplim()
1260 dt = (double)(t2p->tv_sec - t1p->tv_sec) * 1000.0 + in deltaT()
1261 (double)(t2p->tv_usec - t1p->tv_usec) / 1000.0; in deltaT()
1329 struct sockaddr_in6 *from = (struct sockaddr_in6 *)mhdr->msg_name; in packet_ok()
1330 char *buf = (char *)mhdr->msg_iov[0].iov_base; in packet_ok()
1331 struct cmsghdr *cm; in packet_ok() local
1345 if (cap_getnameinfo(capdns, (struct sockaddr *)from, from->sin6_len, in packet_ok()
1353 cc -= hlen; in packet_ok()
1358 if (cap_getnameinfo(capdns, (struct sockaddr *)from, from->sin6_len, in packet_ok()
1370 for (cm = (struct cmsghdr *)CMSG_FIRSTHDR(mhdr); cm; in packet_ok()
1371 cm = (struct cmsghdr *)CMSG_NXTHDR(mhdr, cm)) { in packet_ok()
1372 if (cm->cmsg_level == IPPROTO_IPV6 && in packet_ok()
1373 cm->cmsg_type == IPV6_PKTINFO && in packet_ok()
1374 cm->cmsg_len == in packet_ok()
1376 rcvpktinfo = (struct in6_pktinfo *)(CMSG_DATA(cm)); in packet_ok()
1378 if (cm->cmsg_level == IPPROTO_IPV6 && in packet_ok()
1379 cm->cmsg_type == IPV6_HOPLIMIT && in packet_ok()
1380 cm->cmsg_len == CMSG_LEN(sizeof(int))) in packet_ok()
1381 hlimp = (int *)CMSG_DATA(cm); in packet_ok()
1393 *type = icp->icmp6_type; in packet_ok()
1394 *code = icp->icmp6_code; in packet_ok()
1409 *ecn = ntohl(hip->ip6_flow & IPV6_ECN_MASK) >> 20; in packet_ok()
1418 if (icmp->icmp6_id == ident && in packet_ok()
1419 icmp->icmp6_seq == htons(seq)) in packet_ok()
1424 if (udp->uh_sport == htons(ident) && in packet_ok()
1425 udp->uh_dport == htons(port + seq)) in packet_ok()
1430 if (sctp->src_port != htons(ident) || in packet_ok()
1431 sctp->dest_port != htons(port + seq)) { in packet_ok()
1436 if (sctp->v_tag != 0) { in packet_ok()
1441 if ((char *)&init->init.a_rwnd > buf + cc) { in packet_ok()
1444 if (init->init.initiate_tag == (u_int32_t) in packet_ok()
1445 ((sctp->src_port << 16) | sctp->dest_port)) { in packet_ok()
1449 if (sctp->v_tag == in packet_ok()
1450 (u_int32_t)((sctp->src_port << 16) | in packet_ok()
1451 sctp->dest_port)) { in packet_ok()
1458 if (tcp->th_sport == htons(ident) && in packet_ok()
1459 tcp->th_dport == htons(port + seq) && in packet_ok()
1460 tcp->th_seq == in packet_ok()
1461 (tcp_seq)((tcp->th_sport << 16) | tcp->th_dport)) in packet_ok()
1471 if (icp->icmp6_id == ident && in packet_ok()
1472 icp->icmp6_seq == htons(seq)) in packet_ok()
1480 if (cap_getnameinfo(capdns, (struct sockaddr *)from, from->sin6_len, in packet_ok()
1484 rcvpktinfo ? inet_ntop(AF_INET6, &rcvpktinfo->ipi6_addr, in packet_ok()
1496 if (i % WIDTH == WIDTH - 1) in packet_ok()
1518 nh = ip6->ip6_nxt; in get_uphdr()
1521 while (lim - cp >= (nh == IPPROTO_NONE ? 0 : 8)) { in get_uphdr()
1535 nh = ((struct ip6_frag *)cp)->ip6f_nxt; in get_uphdr()
1538 hlen = (((struct ip6_ext *)cp)->ip6e_len + 2) << 2; in get_uphdr()
1539 nh = ((struct ip6_ext *)cp)->ip6e_nxt; in get_uphdr()
1542 hlen = (((struct ip6_ext *)cp)->ip6e_len + 1) << 3; in get_uphdr()
1543 nh = ((struct ip6_ext *)cp)->ip6e_nxt; in get_uphdr()
1579 struct sockaddr_in6 *from = (struct sockaddr_in6 *)mhdr->msg_name; in print()
1582 if (cap_getnameinfo(capdns, (struct sockaddr *)from, from->sin6_len, in print()
1595 rcvpktinfo ? inet_ntop(AF_INET6, &rcvpktinfo->ipi6_addr, in print()
1599 rcvpktinfo ? inet_ntop(AF_INET6, &rcvpktinfo->ipi6_addr, in print()
1627 if (cap_getnameinfo(capdns, sa, sa->sa_len, line, sizeof(line), NULL, 0, in inetname()
1638 if (cap_getnameinfo(capdns, sa, sa->sa_len, line, sizeof(line), NULL, 0, in inetname()
1752 nleft -= 2; in in_cksum()
1781 pseudo_hdr.src = src->sin6_addr; in udp_cksum()
1782 pseudo_hdr.dst = dst->sin6_addr; in udp_cksum()
1808 pseudo_hdr.src = src->sin6_addr; in tcp_chksum()
1809 pseudo_hdr.dst = dst->sin6_addr; in tcp_chksum()
1826 "Usage: traceroute6 [-adEIlnNrSTUv] [-A as_server] [-f firsthop] [-g gateway]\n" in usage()
1827 "\t[-m hoplimit] [-p port] [-q probes] [-s src] [-t tclass]\n" in usage()
1828 "\t[-w waittime] target [datalen]\n"); in usage()