003 File Manager
Current Path:
/usr/src/contrib/tcpdump
usr
/
src
/
contrib
/
tcpdump
/
π
..
π
CHANGES
(57.87 KB)
π
CONTRIBUTING
(5.93 KB)
π
CREDITS
(14.57 KB)
π
INSTALL.txt
(5.25 KB)
π
LICENSE
(873 B)
π
Makefile-devel-adds
(614 B)
π
Makefile.in
(9.96 KB)
π
PLATFORMS
(567 B)
π
README
(9.04 KB)
π
README.md
(9.04 KB)
π
VERSION
(6 B)
π
addrtoname.c
(33.19 KB)
π
addrtoname.h
(2.78 KB)
π
addrtostr.c
(5.64 KB)
π
addrtostr.h
(2.03 KB)
π
af.c
(1.96 KB)
π
af.h
(1.81 KB)
π
ah.h
(2.34 KB)
π
appletalk.h
(4.06 KB)
π
ascii_strcasecmp.c
(3.5 KB)
π
ascii_strcasecmp.h
(1.49 KB)
π
atime.awk
(529 B)
π
atm.h
(1.14 KB)
π
bpf_dump.c
(1.9 KB)
π
chdlc.h
(1.31 KB)
π
checksum.c
(5.25 KB)
π
config.guess
(43.17 KB)
π
config.h.in
(11.19 KB)
π
config.sub
(34.93 KB)
π
configure
(255.88 KB)
π
configure.ac
(25.05 KB)
π
configure.in
(25.66 KB)
π
cpack.c
(3.92 KB)
π
cpack.h
(2.37 KB)
π
ether.h
(2.34 KB)
π
ethertype.h
(5.58 KB)
π
extract.h
(11.48 KB)
π
funcattrs.h
(4.42 KB)
π
getopt_long.h
(2.52 KB)
π
gmpls.c
(5.82 KB)
π
gmpls.h
(1.38 KB)
π
gmt2local.c
(2.01 KB)
π
gmt2local.h
(1.21 KB)
π
in_cksum.c
(6.44 KB)
π
install-sh
(5.45 KB)
π
interface.h
(2.29 KB)
π
ip.h
(5.75 KB)
π
ip6.h
(7.6 KB)
π
ipproto.c
(16.49 KB)
π
ipproto.h
(4.72 KB)
π
l2vpn.c
(3.36 KB)
π
l2vpn.h
(781 B)
π
lbl
π
llc.h
(3.72 KB)
π
machdep.c
(2.58 KB)
π
machdep.h
(1.24 KB)
π
makemib
(6.41 KB)
π
mib.h
(26.33 KB)
π
missing
π
mkdep
(2.43 KB)
π
mpls.h
(1.93 KB)
π
nameser.h
(10.8 KB)
π
netdissect-stdinc.h
(9.93 KB)
π
netdissect.c
(3.38 KB)
π
netdissect.h
(30.13 KB)
π
nfs.h
(13.37 KB)
π
nfsfh.h
(2.57 KB)
π
nlpid.c
(1.27 KB)
π
nlpid.h
(1.3 KB)
π
openflow.h
(2.14 KB)
π
ospf.h
(10.21 KB)
π
oui.c
(3.83 KB)
π
oui.h
(4.06 KB)
π
packetdat.awk
(1.39 KB)
π
parsenfsfh.c
(12.87 KB)
π
pcap-missing.h
(1.8 KB)
π
pcap_dump_ftell.c
(1.29 KB)
π
ppp.h
(3.07 KB)
π
print-802_11.c
(91.47 KB)
π
print-802_15_4.c
(5.5 KB)
π
print-ah.c
(2.02 KB)
π
print-ahcp.c
(10.73 KB)
π
print-aodv.c
(15.98 KB)
π
print-aoe.c
(11.13 KB)
π
print-ap1394.c
(4 KB)
π
print-arcnet.c
(8.83 KB)
π
print-arp.c
(14.57 KB)
π
print-ascii.c
(6.23 KB)
π
print-atalk.c
(16.76 KB)
π
print-atm.c
(16.81 KB)
π
print-babel.c
(23.79 KB)
π
print-beep.c
(1.71 KB)
π
print-bfd.c
(16.5 KB)
π
print-bgp.c
(99.77 KB)
π
print-bootp.c
(30.07 KB)
π
print-bt.c
(2.21 KB)
π
print-calm-fast.c
(1.81 KB)
π
print-carp.c
(2.43 KB)
π
print-cdp.c
(11.16 KB)
π
print-cfm.c
(24.19 KB)
π
print-chdlc.c
(5.88 KB)
π
print-cip.c
(2.5 KB)
π
print-cnfp.c
(13.69 KB)
π
print-dccp.c
(17.75 KB)
π
print-decnet.c
(37.63 KB)
π
print-dhcp6.c
(23.22 KB)
π
print-domain.c
(18.44 KB)
π
print-dtp.c
(3.03 KB)
π
print-dvmrp.c
(8.98 KB)
π
print-eap.c
(9.26 KB)
π
print-egp.c
(8.69 KB)
π
print-eigrp.c
(19.49 KB)
π
print-enc.c
(4.2 KB)
π
print-esp.c
(21.46 KB)
π
print-ether.c
(12.91 KB)
π
print-fddi.c
(10.51 KB)
π
print-forces.c
(45.01 KB)
π
print-fr.c
(31.99 KB)
π
print-frag6.c
(2.36 KB)
π
print-ftp.c
(973 B)
π
print-geneve.c
(6.13 KB)
π
print-geonet.c
(6.72 KB)
π
print-gre.c
(9.72 KB)
π
print-hncp.c
(26.39 KB)
π
print-hsrp.c
(4.57 KB)
π
print-http.c
(1.51 KB)
π
print-icmp.c
(22.7 KB)
π
print-icmp6.c
(59.81 KB)
π
print-igmp.c
(10.05 KB)
π
print-igrp.c
(4.64 KB)
π
print-ip.c
(17.04 KB)
π
print-ip6.c
(10.57 KB)
π
print-ip6opts.c
(5.53 KB)
π
print-ipcomp.c
(2.32 KB)
π
print-ipfc.c
(4.41 KB)
π
print-ipnet.c
(2.78 KB)
π
print-ipx.c
(6.42 KB)
π
print-isakmp.c
(81.72 KB)
π
print-isoclns.c
(107.61 KB)
π
print-juniper.c
(48.42 KB)
π
print-krb.c
(6.26 KB)
π
print-l2tp.c
(23.94 KB)
π
print-lane.c
(3.04 KB)
π
print-ldp.c
(24.35 KB)
π
print-lisp.c
(15.23 KB)
π
print-llc.c
(16.68 KB)
π
print-lldp.c
(57.26 KB)
π
print-lmp.c
(38.11 KB)
π
print-loopback.c
(3.63 KB)
π
print-lspping.c
(51.64 KB)
π
print-lwapp.c
(13.01 KB)
π
print-lwres.c
(14.08 KB)
π
print-m3ua.c
(10.92 KB)
π
print-medsa.c
(5.57 KB)
π
print-mobile.c
(3.28 KB)
π
print-mobility.c
(9.74 KB)
π
print-mpcp.c
(7.87 KB)
π
print-mpls.c
(5.31 KB)
π
print-mptcp.c
(13.68 KB)
π
print-msdp.c
(2.69 KB)
π
print-msnlb.c
(2.39 KB)
π
print-nflog.c
(4.4 KB)
π
print-nfs.c
(42.84 KB)
π
print-nsh.c
(5.39 KB)
π
print-ntp.c
(13.34 KB)
π
print-null.c
(4.01 KB)
π
print-olsr.c
(23.42 KB)
π
print-openflow-1.0.c
(76.63 KB)
π
print-openflow.c
(4.77 KB)
π
print-ospf.c
(39.49 KB)
π
print-ospf6.c
(29.86 KB)
π
print-otv.c
(2.1 KB)
π
print-pflog.c
(4.86 KB)
π
print-pfsync.c
(12.53 KB)
π
print-pgm.c
(22.17 KB)
π
print-pim.c
(32.59 KB)
π
print-pktap.c
(5.18 KB)
π
print-ppi.c
(2.68 KB)
π
print-ppp.c
(46.16 KB)
π
print-pppoe.c
(5.65 KB)
π
print-pptp.c
(25.9 KB)
π
print-radius.c
(35.1 KB)
π
print-raw.c
(1.52 KB)
π
print-resp.c
(16.5 KB)
π
print-rip.c
(9.19 KB)
π
print-ripng.c
(6 KB)
π
print-rpki-rtr.c
(10.83 KB)
π
print-rrcp.c
(4.56 KB)
π
print-rsvp.c
(78.61 KB)
π
print-rt6.c
(2.66 KB)
π
print-rtsp.c
(1.16 KB)
π
print-rx.c
(66.92 KB)
π
print-sctp.c
(23.13 KB)
π
print-sflow.c
(31.91 KB)
π
print-sip.c
(1.29 KB)
π
print-sl.c
(6.95 KB)
π
print-sll.c
(9.2 KB)
π
print-slow.c
(25.17 KB)
π
print-smb.c
(43.19 KB)
π
print-smtp.c
(983 B)
π
print-snmp.c
(43.17 KB)
π
print-stp.c
(17.18 KB)
π
print-sunatm.c
(3.27 KB)
π
print-sunrpc.c
(7.85 KB)
π
print-symantec.c
(3.78 KB)
π
print-syslog.c
(3.96 KB)
π
print-tcp.c
(35.84 KB)
π
print-telnet.c
(15.02 KB)
π
print-tftp.c
(5.2 KB)
π
print-timed.c
(4.74 KB)
π
print-tipc.c
(11.53 KB)
π
print-token.c
(7.96 KB)
π
print-udld.c
(5.47 KB)
π
print-udp.c
(21.28 KB)
π
print-usb.c
(4.18 KB)
π
print-vjc.c
(4.45 KB)
π
print-vqp.c
(6.8 KB)
π
print-vrrp.c
(6.37 KB)
π
print-vtp.c
(13.56 KB)
π
print-vxlan-gpe.c
(3.46 KB)
π
print-vxlan.c
(2.21 KB)
π
print-wb.c
(10.93 KB)
π
print-zephyr.c
(8.03 KB)
π
print-zeromq.c
(7.5 KB)
π
print.c
(11.54 KB)
π
print.h
(1.78 KB)
π
rpc_auth.h
(2.77 KB)
π
rpc_msg.h
(3.19 KB)
π
rpl.h
(4.88 KB)
π
send-ack.awk
(1.56 KB)
π
setsignal.c
(3.27 KB)
π
setsignal.h
(1.24 KB)
π
signature.c
(5.58 KB)
π
signature.h
(1.12 KB)
π
slcompress.h
(3.55 KB)
π
smb.h
(5.38 KB)
π
smbutil.c
(63.88 KB)
π
stime.awk
(567 B)
π
strtoaddr.c
(5.34 KB)
π
strtoaddr.h
(992 B)
π
tcp.h
(5.02 KB)
π
tcpdump.1.in
(60.82 KB)
π
tcpdump.c
(69.76 KB)
π
timeval-operations.h
(3.19 KB)
π
udp.h
(8.25 KB)
π
util-print.c
(23.75 KB)
π
vfprintf.c
(1.62 KB)
Editing: print-hncp.c
/* * Copyright (c) 2016 Antonin DΓ©cimo, Jean-RaphaΓ«l Gaglione * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the project nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ /* \summary: Home Networking Control Protocol (HNCP) printer */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include <netdissect-stdinc.h> #include <stdlib.h> #include <string.h> #include "netdissect.h" #include "addrtoname.h" #include "extract.h" static void hncp_print_rec(netdissect_options *ndo, const u_char *cp, u_int length, int indent); void hncp_print(netdissect_options *ndo, const u_char *cp, u_int length) { ND_PRINT((ndo, "hncp (%d)", length)); hncp_print_rec(ndo, cp, length, 1); } /* RFC7787 */ #define DNCP_REQUEST_NETWORK_STATE 1 #define DNCP_REQUEST_NODE_STATE 2 #define DNCP_NODE_ENDPOINT 3 #define DNCP_NETWORK_STATE 4 #define DNCP_NODE_STATE 5 #define DNCP_PEER 8 #define DNCP_KEEP_ALIVE_INTERVAL 9 #define DNCP_TRUST_VERDICT 10 /* RFC7788 */ #define HNCP_HNCP_VERSION 32 #define HNCP_EXTERNAL_CONNECTION 33 #define HNCP_DELEGATED_PREFIX 34 #define HNCP_PREFIX_POLICY 43 #define HNCP_DHCPV4_DATA 37 /* This is correct, see RFC 7788 Errata ID 5113. */ #define HNCP_DHCPV6_DATA 38 /* idem */ #define HNCP_ASSIGNED_PREFIX 35 #define HNCP_NODE_ADDRESS 36 #define HNCP_DNS_DELEGATED_ZONE 39 #define HNCP_DOMAIN_NAME 40 #define HNCP_NODE_NAME 41 #define HNCP_MANAGED_PSK 42 /* See type_mask in hncp_print_rec below */ #define RANGE_DNCP_RESERVED 0x10000 #define RANGE_HNCP_UNASSIGNED 0x10001 #define RANGE_DNCP_PRIVATE_USE 0x10002 #define RANGE_DNCP_FUTURE_USE 0x10003 static const struct tok type_values[] = { { DNCP_REQUEST_NETWORK_STATE, "Request network state" }, { DNCP_REQUEST_NODE_STATE, "Request node state" }, { DNCP_NODE_ENDPOINT, "Node endpoint" }, { DNCP_NETWORK_STATE, "Network state" }, { DNCP_NODE_STATE, "Node state" }, { DNCP_PEER, "Peer" }, { DNCP_KEEP_ALIVE_INTERVAL, "Keep-alive interval" }, { DNCP_TRUST_VERDICT, "Trust-Verdict" }, { HNCP_HNCP_VERSION, "HNCP-Version" }, { HNCP_EXTERNAL_CONNECTION, "External-Connection" }, { HNCP_DELEGATED_PREFIX, "Delegated-Prefix" }, { HNCP_PREFIX_POLICY, "Prefix-Policy" }, { HNCP_DHCPV4_DATA, "DHCPv4-Data" }, { HNCP_DHCPV6_DATA, "DHCPv6-Data" }, { HNCP_ASSIGNED_PREFIX, "Assigned-Prefix" }, { HNCP_NODE_ADDRESS, "Node-Address" }, { HNCP_DNS_DELEGATED_ZONE, "DNS-Delegated-Zone" }, { HNCP_DOMAIN_NAME, "Domain-Name" }, { HNCP_NODE_NAME, "Node-Name" }, { HNCP_MANAGED_PSK, "Managed-PSK" }, { RANGE_DNCP_RESERVED, "Reserved" }, { RANGE_HNCP_UNASSIGNED, "Unassigned" }, { RANGE_DNCP_PRIVATE_USE, "Private use" }, { RANGE_DNCP_FUTURE_USE, "Future use" }, { 0, NULL} }; #define DH4OPT_DNS_SERVERS 6 /* RFC2132 */ #define DH4OPT_NTP_SERVERS 42 /* RFC2132 */ #define DH4OPT_DOMAIN_SEARCH 119 /* RFC3397 */ static const struct tok dh4opt_str[] = { { DH4OPT_DNS_SERVERS, "DNS-server" }, { DH4OPT_NTP_SERVERS, "NTP-server"}, { DH4OPT_DOMAIN_SEARCH, "DNS-search" }, { 0, NULL } }; #define DH6OPT_DNS_SERVERS 23 /* RFC3646 */ #define DH6OPT_DOMAIN_LIST 24 /* RFC3646 */ #define DH6OPT_SNTP_SERVERS 31 /* RFC4075 */ static const struct tok dh6opt_str[] = { { DH6OPT_DNS_SERVERS, "DNS-server" }, { DH6OPT_DOMAIN_LIST, "DNS-search-list" }, { DH6OPT_SNTP_SERVERS, "SNTP-servers" }, { 0, NULL } }; /* * For IPv4-mapped IPv6 addresses, length of the prefix that precedes * the 4 bytes of IPv4 address at the end of the IPv6 address. */ #define IPV4_MAPPED_HEADING_LEN 12 /* * Is an IPv6 address an IPv4-mapped address? */ static inline int is_ipv4_mapped_address(const u_char *addr) { /* The value of the prefix */ static const u_char ipv4_mapped_heading[IPV4_MAPPED_HEADING_LEN] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF }; return memcmp(addr, ipv4_mapped_heading, IPV4_MAPPED_HEADING_LEN) == 0; } static const char * format_nid(const u_char *data) { static char buf[4][sizeof("01:01:01:01")]; static int i = 0; i = (i + 1) % 4; snprintf(buf[i], sizeof(buf[i]), "%02x:%02x:%02x:%02x", data[0], data[1], data[2], data[3]); return buf[i]; } static const char * format_256(const u_char *data) { static char buf[4][sizeof("0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef")]; static int i = 0; i = (i + 1) % 4; snprintf(buf[i], sizeof(buf[i]), "%016" PRIx64 "%016" PRIx64 "%016" PRIx64 "%016" PRIx64, EXTRACT_64BITS(data), EXTRACT_64BITS(data + 8), EXTRACT_64BITS(data + 16), EXTRACT_64BITS(data + 24) ); return buf[i]; } static const char * format_interval(const uint32_t n) { static char buf[4][sizeof("0000000.000s")]; static int i = 0; i = (i + 1) % 4; snprintf(buf[i], sizeof(buf[i]), "%u.%03us", n / 1000, n % 1000); return buf[i]; } static const char * format_ip6addr(netdissect_options *ndo, const u_char *cp) { if (is_ipv4_mapped_address(cp)) return ipaddr_string(ndo, cp + IPV4_MAPPED_HEADING_LEN); else return ip6addr_string(ndo, cp); } static int print_prefix(netdissect_options *ndo, const u_char *prefix, u_int max_length) { int plenbytes; char buf[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx::/128")]; if (prefix[0] >= 96 && max_length >= IPV4_MAPPED_HEADING_LEN + 1 && is_ipv4_mapped_address(&prefix[1])) { struct in_addr addr; u_int plen; plen = prefix[0]-96; if (32 < plen) return -1; max_length -= 1; memset(&addr, 0, sizeof(addr)); plenbytes = (plen + 7) / 8; if (max_length < (u_int)plenbytes + IPV4_MAPPED_HEADING_LEN) return -3; memcpy(&addr, &prefix[1 + IPV4_MAPPED_HEADING_LEN], plenbytes); if (plen % 8) { ((u_char *)&addr)[plenbytes - 1] &= ((0xff00 >> (plen % 8)) & 0xff); } snprintf(buf, sizeof(buf), "%s/%d", ipaddr_string(ndo, &addr), plen); plenbytes += 1 + IPV4_MAPPED_HEADING_LEN; } else { plenbytes = decode_prefix6(ndo, prefix, max_length, buf, sizeof(buf)); if (plenbytes < 0) return plenbytes; } ND_PRINT((ndo, "%s", buf)); return plenbytes; } static int print_dns_label(netdissect_options *ndo, const u_char *cp, u_int max_length, int print) { u_int length = 0; while (length < max_length) { u_int lab_length = cp[length++]; if (lab_length == 0) return (int)length; if (length > 1 && print) safeputchar(ndo, '.'); if (length+lab_length > max_length) { if (print) safeputs(ndo, cp+length, max_length-length); break; } if (print) safeputs(ndo, cp+length, lab_length); length += lab_length; } if (print) ND_PRINT((ndo, "[|DNS]")); return -1; } static int dhcpv4_print(netdissect_options *ndo, const u_char *cp, u_int length, int indent) { u_int i, t; const u_char *tlv, *value; uint8_t type, optlen; i = 0; while (i < length) { if (i + 2 > length) return -1; tlv = cp + i; type = (uint8_t)tlv[0]; optlen = (uint8_t)tlv[1]; value = tlv + 2; ND_PRINT((ndo, "\n")); for (t = indent; t > 0; t--) ND_PRINT((ndo, "\t")); ND_PRINT((ndo, "%s", tok2str(dh4opt_str, "Unknown", type))); ND_PRINT((ndo," (%u)", optlen + 2 )); if (i + 2 + optlen > length) return -1; switch (type) { case DH4OPT_DNS_SERVERS: case DH4OPT_NTP_SERVERS: { if (optlen < 4 || optlen % 4 != 0) { return -1; } for (t = 0; t < optlen; t += 4) ND_PRINT((ndo, " %s", ipaddr_string(ndo, value + t))); } break; case DH4OPT_DOMAIN_SEARCH: { const u_char *tp = value; while (tp < value + optlen) { ND_PRINT((ndo, " ")); if ((tp = ns_nprint(ndo, tp, value + optlen)) == NULL) return -1; } } break; } i += 2 + optlen; } return 0; } static int dhcpv6_print(netdissect_options *ndo, const u_char *cp, u_int length, int indent) { u_int i, t; const u_char *tlv, *value; uint16_t type, optlen; i = 0; while (i < length) { if (i + 4 > length) return -1; tlv = cp + i; type = EXTRACT_16BITS(tlv); optlen = EXTRACT_16BITS(tlv + 2); value = tlv + 4; ND_PRINT((ndo, "\n")); for (t = indent; t > 0; t--) ND_PRINT((ndo, "\t")); ND_PRINT((ndo, "%s", tok2str(dh6opt_str, "Unknown", type))); ND_PRINT((ndo," (%u)", optlen + 4 )); if (i + 4 + optlen > length) return -1; switch (type) { case DH6OPT_DNS_SERVERS: case DH6OPT_SNTP_SERVERS: { if (optlen % 16 != 0) { ND_PRINT((ndo, " %s", istr)); return -1; } for (t = 0; t < optlen; t += 16) ND_PRINT((ndo, " %s", ip6addr_string(ndo, value + t))); } break; case DH6OPT_DOMAIN_LIST: { const u_char *tp = value; while (tp < value + optlen) { ND_PRINT((ndo, " ")); if ((tp = ns_nprint(ndo, tp, value + optlen)) == NULL) return -1; } } break; } i += 4 + optlen; } return 0; } /* Determine in-line mode */ static int is_in_line(netdissect_options *ndo, int indent) { return indent - 1 >= ndo->ndo_vflag && ndo->ndo_vflag < 3; } static void print_type_in_line(netdissect_options *ndo, uint32_t type, int count, int indent, int *first_one) { if (count > 0) { if (*first_one) { *first_one = 0; if (indent > 1) { u_int t; ND_PRINT((ndo, "\n")); for (t = indent; t > 0; t--) ND_PRINT((ndo, "\t")); } else { ND_PRINT((ndo, " ")); } } else { ND_PRINT((ndo, ", ")); } ND_PRINT((ndo, "%s", tok2str(type_values, "Easter Egg", type))); if (count > 1) ND_PRINT((ndo, " (x%d)", count)); } } void hncp_print_rec(netdissect_options *ndo, const u_char *cp, u_int length, int indent) { const int in_line = is_in_line(ndo, indent); int first_one = 1; u_int i, t; uint32_t last_type_mask = 0xffffffffU; int last_type_count = -1; const u_char *tlv, *value; uint16_t type, bodylen; uint32_t type_mask; i = 0; while (i < length) { tlv = cp + i; if (!in_line) { ND_PRINT((ndo, "\n")); for (t = indent; t > 0; t--) ND_PRINT((ndo, "\t")); } ND_TCHECK2(*tlv, 4); if (i + 4 > length) goto invalid; type = EXTRACT_16BITS(tlv); bodylen = EXTRACT_16BITS(tlv + 2); value = tlv + 4; ND_TCHECK2(*value, bodylen); if (i + bodylen + 4 > length) goto invalid; type_mask = (type == 0) ? RANGE_DNCP_RESERVED: (44 <= type && type <= 511) ? RANGE_HNCP_UNASSIGNED: (768 <= type && type <= 1023) ? RANGE_DNCP_PRIVATE_USE: RANGE_DNCP_FUTURE_USE; if (type == 6 || type == 7) type_mask = RANGE_DNCP_FUTURE_USE; /* defined types */ { t = 0; while (1) { u_int key = type_values[t++].v; if (key > 0xffff) break; if (key == type) { type_mask = type; break; } } } if (in_line) { if (last_type_mask == type_mask) { last_type_count++; } else { print_type_in_line(ndo, last_type_mask, last_type_count, indent, &first_one); last_type_mask = type_mask; last_type_count = 1; } goto skip_multiline; } ND_PRINT((ndo,"%s", tok2str(type_values, "Easter Egg (42)", type_mask) )); if (type_mask > 0xffff) ND_PRINT((ndo,": type=%u", type )); ND_PRINT((ndo," (%u)", bodylen + 4 )); switch (type_mask) { case DNCP_REQUEST_NETWORK_STATE: { if (bodylen != 0) ND_PRINT((ndo, " %s", istr)); } break; case DNCP_REQUEST_NODE_STATE: { const char *node_identifier; if (bodylen != 4) { ND_PRINT((ndo, " %s", istr)); break; } node_identifier = format_nid(value); ND_PRINT((ndo, " NID: %s", node_identifier)); } break; case DNCP_NODE_ENDPOINT: { const char *node_identifier; uint32_t endpoint_identifier; if (bodylen != 8) { ND_PRINT((ndo, " %s", istr)); break; } node_identifier = format_nid(value); endpoint_identifier = EXTRACT_32BITS(value + 4); ND_PRINT((ndo, " NID: %s EPID: %08x", node_identifier, endpoint_identifier )); } break; case DNCP_NETWORK_STATE: { uint64_t hash; if (bodylen != 8) { ND_PRINT((ndo, " %s", istr)); break; } hash = EXTRACT_64BITS(value); ND_PRINT((ndo, " hash: %016" PRIx64, hash)); } break; case DNCP_NODE_STATE: { const char *node_identifier, *interval; uint32_t sequence_number; uint64_t hash; if (bodylen < 20) { ND_PRINT((ndo, " %s", istr)); break; } node_identifier = format_nid(value); sequence_number = EXTRACT_32BITS(value + 4); interval = format_interval(EXTRACT_32BITS(value + 8)); hash = EXTRACT_64BITS(value + 12); ND_PRINT((ndo, " NID: %s seqno: %u %s hash: %016" PRIx64, node_identifier, sequence_number, interval, hash )); hncp_print_rec(ndo, value+20, bodylen-20, indent+1); } break; case DNCP_PEER: { const char *peer_node_identifier; uint32_t peer_endpoint_identifier, endpoint_identifier; if (bodylen != 12) { ND_PRINT((ndo, " %s", istr)); break; } peer_node_identifier = format_nid(value); peer_endpoint_identifier = EXTRACT_32BITS(value + 4); endpoint_identifier = EXTRACT_32BITS(value + 8); ND_PRINT((ndo, " Peer-NID: %s Peer-EPID: %08x Local-EPID: %08x", peer_node_identifier, peer_endpoint_identifier, endpoint_identifier )); } break; case DNCP_KEEP_ALIVE_INTERVAL: { uint32_t endpoint_identifier; const char *interval; if (bodylen < 8) { ND_PRINT((ndo, " %s", istr)); break; } endpoint_identifier = EXTRACT_32BITS(value); interval = format_interval(EXTRACT_32BITS(value + 4)); ND_PRINT((ndo, " EPID: %08x Interval: %s", endpoint_identifier, interval )); } break; case DNCP_TRUST_VERDICT: { if (bodylen <= 36) { ND_PRINT((ndo, " %s", istr)); break; } ND_PRINT((ndo, " Verdict: %u Fingerprint: %s Common Name: ", *value, format_256(value + 4))); safeputs(ndo, value + 36, bodylen - 36); } break; case HNCP_HNCP_VERSION: { uint16_t capabilities; uint8_t M, P, H, L; if (bodylen < 5) { ND_PRINT((ndo, " %s", istr)); break; } capabilities = EXTRACT_16BITS(value + 2); M = (uint8_t)((capabilities >> 12) & 0xf); P = (uint8_t)((capabilities >> 8) & 0xf); H = (uint8_t)((capabilities >> 4) & 0xf); L = (uint8_t)(capabilities & 0xf); ND_PRINT((ndo, " M: %u P: %u H: %u L: %u User-agent: ", M, P, H, L )); safeputs(ndo, value + 4, bodylen - 4); } break; case HNCP_EXTERNAL_CONNECTION: { /* Container TLV */ hncp_print_rec(ndo, value, bodylen, indent+1); } break; case HNCP_DELEGATED_PREFIX: { int l; if (bodylen < 9 || bodylen < 9 + (value[8] + 7) / 8) { ND_PRINT((ndo, " %s", istr)); break; } ND_PRINT((ndo, " VLSO: %s PLSO: %s Prefix: ", format_interval(EXTRACT_32BITS(value)), format_interval(EXTRACT_32BITS(value + 4)) )); l = print_prefix(ndo, value + 8, bodylen - 8); if (l == -1) { ND_PRINT((ndo, "(length is invalid)")); break; } if (l < 0) { /* * We've already checked that we've captured the * entire TLV, based on its length, so this will * either be -1, meaning "the prefix length is * greater than the longest possible address of * that type" (i.e., > 32 for IPv4 or > 128 for * IPv6", or -3, meaning "the prefix runs past * the end of the TLV". */ ND_PRINT((ndo, " %s", istr)); break; } l += 8 + (-l & 3); if (bodylen >= l) hncp_print_rec(ndo, value + l, bodylen - l, indent+1); } break; case HNCP_PREFIX_POLICY: { uint8_t policy; int l; if (bodylen < 1) { ND_PRINT((ndo, " %s", istr)); break; } policy = value[0]; ND_PRINT((ndo, " type: ")); if (policy == 0) { if (bodylen != 1) { ND_PRINT((ndo, " %s", istr)); break; } ND_PRINT((ndo, "Internet connectivity")); } else if (policy >= 1 && policy <= 128) { ND_PRINT((ndo, "Dest-Prefix: ")); l = print_prefix(ndo, value, bodylen); if (l == -1) { ND_PRINT((ndo, "(length is invalid)")); break; } if (l < 0) { /* * We've already checked that we've captured the * entire TLV, based on its length, so this will * either be -1, meaning "the prefix length is * greater than the longest possible address of * that type" (i.e., > 32 for IPv4 or > 128 for * IPv6", or -3, meaning "the prefix runs past * the end of the TLV". */ ND_PRINT((ndo, " %s", istr)); break; } } else if (policy == 129) { ND_PRINT((ndo, "DNS domain: ")); print_dns_label(ndo, value+1, bodylen-1, 1); } else if (policy == 130) { ND_PRINT((ndo, "Opaque UTF-8: ")); safeputs(ndo, value + 1, bodylen - 1); } else if (policy == 131) { if (bodylen != 1) { ND_PRINT((ndo, " %s", istr)); break; } ND_PRINT((ndo, "Restrictive assignment")); } else if (policy >= 132) { ND_PRINT((ndo, "Unknown (%u)", policy)); /* Reserved for future additions */ } } break; case HNCP_DHCPV4_DATA: { if (bodylen == 0) { ND_PRINT((ndo, " %s", istr)); break; } if (dhcpv4_print(ndo, value, bodylen, indent+1) != 0) goto invalid; } break; case HNCP_DHCPV6_DATA: { if (bodylen == 0) { ND_PRINT((ndo, " %s", istr)); break; } if (dhcpv6_print(ndo, value, bodylen, indent+1) != 0) { ND_PRINT((ndo, " %s", istr)); break; } } break; case HNCP_ASSIGNED_PREFIX: { uint8_t prty; int l; if (bodylen < 6 || bodylen < 6 + (value[5] + 7) / 8) { ND_PRINT((ndo, " %s", istr)); break; } prty = (uint8_t)(value[4] & 0xf); ND_PRINT((ndo, " EPID: %08x Prty: %u", EXTRACT_32BITS(value), prty )); ND_PRINT((ndo, " Prefix: ")); if ((l = print_prefix(ndo, value + 5, bodylen - 5)) < 0) { ND_PRINT((ndo, " %s", istr)); break; } l += 5; l += -l & 3; if (bodylen >= l) hncp_print_rec(ndo, value + l, bodylen - l, indent+1); } break; case HNCP_NODE_ADDRESS: { uint32_t endpoint_identifier; const char *ip_address; if (bodylen < 20) { ND_PRINT((ndo, " %s", istr)); break; } endpoint_identifier = EXTRACT_32BITS(value); ip_address = format_ip6addr(ndo, value + 4); ND_PRINT((ndo, " EPID: %08x IP Address: %s", endpoint_identifier, ip_address )); hncp_print_rec(ndo, value + 20, bodylen - 20, indent+1); } break; case HNCP_DNS_DELEGATED_ZONE: { const char *ip_address; int len; if (bodylen < 17) { ND_PRINT((ndo, " %s", istr)); break; } ip_address = format_ip6addr(ndo, value); ND_PRINT((ndo, " IP-Address: %s %c%c%c ", ip_address, (value[16] & 4) ? 'l' : '-', (value[16] & 2) ? 'b' : '-', (value[16] & 1) ? 's' : '-' )); len = print_dns_label(ndo, value+17, bodylen-17, 1); if (len < 0) { ND_PRINT((ndo, " %s", istr)); break; } len += 17; len += -len & 3; if (bodylen >= len) hncp_print_rec(ndo, value+len, bodylen-len, indent+1); } break; case HNCP_DOMAIN_NAME: { if (bodylen == 0) { ND_PRINT((ndo, " %s", istr)); break; } ND_PRINT((ndo, " Domain: ")); print_dns_label(ndo, value, bodylen, 1); } break; case HNCP_NODE_NAME: { u_int l; if (bodylen < 17) { ND_PRINT((ndo, " %s", istr)); break; } l = value[16]; if (bodylen < 17 + l) { ND_PRINT((ndo, " %s", istr)); break; } ND_PRINT((ndo, " IP-Address: %s Name: ", format_ip6addr(ndo, value) )); if (l < 64) { safeputchar(ndo, '"'); safeputs(ndo, value + 17, l); safeputchar(ndo, '"'); } else { ND_PRINT((ndo, "%s", istr)); } l += 17; l += -l & 3; if (bodylen >= l) hncp_print_rec(ndo, value + l, bodylen - l, indent+1); } break; case HNCP_MANAGED_PSK: { if (bodylen < 32) { ND_PRINT((ndo, " %s", istr)); break; } ND_PRINT((ndo, " PSK: %s", format_256(value))); hncp_print_rec(ndo, value + 32, bodylen - 32, indent+1); } break; case RANGE_DNCP_RESERVED: case RANGE_HNCP_UNASSIGNED: case RANGE_DNCP_PRIVATE_USE: case RANGE_DNCP_FUTURE_USE: break; } skip_multiline: i += 4 + bodylen + (-bodylen & 3); } print_type_in_line(ndo, last_type_mask, last_type_count, indent, &first_one); return; trunc: ND_PRINT((ndo, "%s", "[|hncp]")); return; invalid: ND_PRINT((ndo, "%s", istr)); return; }
Upload File
Create Folder