summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2017-10-10 12:55:06 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2017-10-11 09:29:33 +0200
commit104304864887f0e3765bb28333dc7b9bd991aa4f (patch)
treec1472d363822507fba1cebca8fb18f611accd51b
parentUpdate CONTRIBUTING.md (diff)
downloadrtems-libbsd-104304864887f0e3765bb28333dc7b9bd991aa4f.tar.bz2
tcpdump: Update to FreeBSD head 2017-04-04
Update tcpdump from Git mirror commit 99a648a912e81e29d9c4c159cbbe263462f2d719 to 642b174daddbd0efd9bb5f242c43f4ab4db6869f.
-rw-r--r--freebsd/contrib/tcpdump/addrtoname.c364
-rw-r--r--freebsd/contrib/tcpdump/addrtoname.h49
-rw-r--r--freebsd/contrib/tcpdump/addrtostr.c222
-rw-r--r--freebsd/contrib/tcpdump/addrtostr.h (renamed from freebsd/contrib/tcpdump/decode_prefix.h)31
-rw-r--r--freebsd/contrib/tcpdump/af.c17
-rw-r--r--freebsd/contrib/tcpdump/af.h8
-rw-r--r--freebsd/contrib/tcpdump/ah.h18
-rw-r--r--freebsd/contrib/tcpdump/aodv.h190
-rw-r--r--freebsd/contrib/tcpdump/appletalk.h62
-rw-r--r--freebsd/contrib/tcpdump/arcnet.h101
-rw-r--r--freebsd/contrib/tcpdump/ascii_strcasecmp.c113
-rw-r--r--freebsd/contrib/tcpdump/ascii_strcasecmp.h (renamed from freebsd/contrib/tcpdump/ipfc.h)20
-rw-r--r--freebsd/contrib/tcpdump/atm.h2
-rw-r--r--freebsd/contrib/tcpdump/bootp.h231
-rw-r--r--freebsd/contrib/tcpdump/bpf_dump.c17
-rw-r--r--freebsd/contrib/tcpdump/chdlc.h1
-rw-r--r--freebsd/contrib/tcpdump/checksum.c57
-rw-r--r--freebsd/contrib/tcpdump/cpack.c53
-rw-r--r--freebsd/contrib/tcpdump/cpack.h28
-rw-r--r--freebsd/contrib/tcpdump/dccp.h139
-rw-r--r--freebsd/contrib/tcpdump/decnet.h461
-rw-r--r--freebsd/contrib/tcpdump/enc.h47
-rw-r--r--freebsd/contrib/tcpdump/esp.h68
-rw-r--r--freebsd/contrib/tcpdump/ether.h16
-rw-r--r--freebsd/contrib/tcpdump/ethertype.h23
-rw-r--r--freebsd/contrib/tcpdump/extract.h221
-rw-r--r--freebsd/contrib/tcpdump/fddi.h76
-rw-r--r--freebsd/contrib/tcpdump/forces.h679
-rw-r--r--freebsd/contrib/tcpdump/gmpls.c37
-rw-r--r--freebsd/contrib/tcpdump/gmpls.h3
-rw-r--r--freebsd/contrib/tcpdump/gmt2local.c15
-rw-r--r--freebsd/contrib/tcpdump/gmt2local.h2
-rw-r--r--freebsd/contrib/tcpdump/icmp6.h473
-rw-r--r--freebsd/contrib/tcpdump/ieee802_11.h347
-rw-r--r--freebsd/contrib/tcpdump/ieee802_11_radio.h291
-rw-r--r--freebsd/contrib/tcpdump/igrp.h33
-rw-r--r--freebsd/contrib/tcpdump/in_cksum.c46
-rw-r--r--freebsd/contrib/tcpdump/interface.h341
-rw-r--r--freebsd/contrib/tcpdump/ip.h44
-rw-r--r--freebsd/contrib/tcpdump/ip6.h78
-rw-r--r--freebsd/contrib/tcpdump/ipnet.h13
-rw-r--r--freebsd/contrib/tcpdump/ipproto.c19
-rw-r--r--freebsd/contrib/tcpdump/ipproto.h5
-rw-r--r--freebsd/contrib/tcpdump/ipsec_doi.h151
-rw-r--r--freebsd/contrib/tcpdump/ipx.h31
-rw-r--r--freebsd/contrib/tcpdump/isakmp.h501
-rw-r--r--freebsd/contrib/tcpdump/l2tp.h62
-rw-r--r--freebsd/contrib/tcpdump/l2vpn.c115
-rw-r--r--freebsd/contrib/tcpdump/l2vpn.h4
-rw-r--r--freebsd/contrib/tcpdump/lane.h41
-rw-r--r--freebsd/contrib/tcpdump/llc.h3
-rw-r--r--freebsd/contrib/tcpdump/machdep.c29
-rw-r--r--freebsd/contrib/tcpdump/machdep.h6
-rw-r--r--freebsd/contrib/tcpdump/mib.h2
-rw-r--r--freebsd/contrib/tcpdump/mpls.h2
-rw-r--r--freebsd/contrib/tcpdump/nameser.h49
-rw-r--r--freebsd/contrib/tcpdump/netbios.h16
-rw-r--r--freebsd/contrib/tcpdump/netdissect-stdinc.h (renamed from freebsd/contrib/tcpdump/tcpdump-stdinc.h)262
-rw-r--r--freebsd/contrib/tcpdump/netdissect.c154
-rw-r--r--freebsd/contrib/tcpdump/netdissect.h759
-rw-r--r--freebsd/contrib/tcpdump/nfs.h112
-rw-r--r--freebsd/contrib/tcpdump/nfsfh.h12
-rw-r--r--freebsd/contrib/tcpdump/nlpid.c19
-rw-r--r--freebsd/contrib/tcpdump/nlpid.h3
-rw-r--r--freebsd/contrib/tcpdump/ntp.h127
-rw-r--r--freebsd/contrib/tcpdump/oakley.h126
-rw-r--r--freebsd/contrib/tcpdump/openflow.h51
-rw-r--r--freebsd/contrib/tcpdump/ospf.h105
-rw-r--r--freebsd/contrib/tcpdump/ospf6.h265
-rw-r--r--freebsd/contrib/tcpdump/oui.c29
-rw-r--r--freebsd/contrib/tcpdump/oui.h41
-rw-r--r--freebsd/contrib/tcpdump/parsenfsfh.c302
-rw-r--r--freebsd/contrib/tcpdump/pcap-missing.h17
-rw-r--r--freebsd/contrib/tcpdump/pmap_prot.h90
-rw-r--r--freebsd/contrib/tcpdump/ppi.h9
-rw-r--r--freebsd/contrib/tcpdump/ppp.h5
-rw-r--r--freebsd/contrib/tcpdump/print-802_11.c2413
-rw-r--r--freebsd/contrib/tcpdump/print-802_15_4.c44
-rw-r--r--freebsd/contrib/tcpdump/print-ah.c47
-rw-r--r--freebsd/contrib/tcpdump/print-ahcp.c419
-rw-r--r--freebsd/contrib/tcpdump/print-aodv.c687
-rw-r--r--freebsd/contrib/tcpdump/print-aoe.c438
-rw-r--r--freebsd/contrib/tcpdump/print-ap1394.c76
-rw-r--r--freebsd/contrib/tcpdump/print-arcnet.c182
-rw-r--r--freebsd/contrib/tcpdump/print-arp.c106
-rw-r--r--freebsd/contrib/tcpdump/print-ascii.c100
-rw-r--r--freebsd/contrib/tcpdump/print-atalk.c370
-rw-r--r--freebsd/contrib/tcpdump/print-atm.c332
-rw-r--r--freebsd/contrib/tcpdump/print-babel.c530
-rw-r--r--freebsd/contrib/tcpdump/print-beep.c45
-rw-r--r--freebsd/contrib/tcpdump/print-bfd.c307
-rw-r--r--freebsd/contrib/tcpdump/print-bgp.c1567
-rw-r--r--freebsd/contrib/tcpdump/print-bootp.c750
-rw-r--r--freebsd/contrib/tcpdump/print-bt.c38
-rw-r--r--freebsd/contrib/tcpdump/print-calm-fast.c83
-rw-r--r--freebsd/contrib/tcpdump/print-carp.c51
-rw-r--r--freebsd/contrib/tcpdump/print-cdp.c321
-rw-r--r--freebsd/contrib/tcpdump/print-cfm.c492
-rw-r--r--freebsd/contrib/tcpdump/print-chdlc.c109
-rw-r--r--freebsd/contrib/tcpdump/print-cip.c76
-rw-r--r--freebsd/contrib/tcpdump/print-cnfp.c475
-rw-r--r--freebsd/contrib/tcpdump/print-dccp.c725
-rw-r--r--freebsd/contrib/tcpdump/print-decnet.c946
-rw-r--r--freebsd/contrib/tcpdump/print-dhcp6.c737
-rw-r--r--freebsd/contrib/tcpdump/print-domain.c399
-rw-r--r--freebsd/contrib/tcpdump/print-dtp.c81
-rw-r--r--freebsd/contrib/tcpdump/print-dvmrp.c210
-rw-r--r--freebsd/contrib/tcpdump/print-eap.c103
-rw-r--r--freebsd/contrib/tcpdump/print-egp.c206
-rw-r--r--freebsd/contrib/tcpdump/print-eigrp.c303
-rw-r--r--freebsd/contrib/tcpdump/print-enc.c92
-rw-r--r--freebsd/contrib/tcpdump/print-esp.c336
-rw-r--r--freebsd/contrib/tcpdump/print-ether.c272
-rw-r--r--freebsd/contrib/tcpdump/print-fddi.c196
-rw-r--r--freebsd/contrib/tcpdump/print-forces.c1459
-rw-r--r--freebsd/contrib/tcpdump/print-fr.c797
-rw-r--r--freebsd/contrib/tcpdump/print-frag6.c45
-rw-r--r--freebsd/contrib/tcpdump/print-ftp.c (renamed from freebsd/contrib/tcpdump/bgp.h)33
-rw-r--r--freebsd/contrib/tcpdump/print-geneve.c245
-rw-r--r--freebsd/contrib/tcpdump/print-geonet.c294
-rw-r--r--freebsd/contrib/tcpdump/print-gre.c275
-rw-r--r--freebsd/contrib/tcpdump/print-hncp.c863
-rw-r--r--freebsd/contrib/tcpdump/print-hsrp.c97
-rw-r--r--freebsd/contrib/tcpdump/print-http.c85
-rw-r--r--freebsd/contrib/tcpdump/print-icmp.c265
-rw-r--r--freebsd/contrib/tcpdump/print-icmp6.c1619
-rw-r--r--freebsd/contrib/tcpdump/print-igmp.c243
-rw-r--r--freebsd/contrib/tcpdump/print-igrp.c111
-rw-r--r--freebsd/contrib/tcpdump/print-ip.c397
-rw-r--r--freebsd/contrib/tcpdump/print-ip6.c265
-rw-r--r--freebsd/contrib/tcpdump/print-ip6opts.c221
-rw-r--r--freebsd/contrib/tcpdump/print-ipcomp.c84
-rw-r--r--freebsd/contrib/tcpdump/print-ipfc.c98
-rw-r--r--freebsd/contrib/tcpdump/print-ipnet.c48
-rw-r--r--freebsd/contrib/tcpdump/print-ipx.c171
-rw-r--r--freebsd/contrib/tcpdump/print-isakmp.c1572
-rw-r--r--freebsd/contrib/tcpdump/print-isoclns.c1885
-rw-r--r--freebsd/contrib/tcpdump/print-juniper.c535
-rw-r--r--freebsd/contrib/tcpdump/print-krb.c133
-rw-r--r--freebsd/contrib/tcpdump/print-l2tp.c356
-rw-r--r--freebsd/contrib/tcpdump/print-lane.c56
-rw-r--r--freebsd/contrib/tcpdump/print-ldp.c310
-rw-r--r--freebsd/contrib/tcpdump/print-lisp.c457
-rw-r--r--freebsd/contrib/tcpdump/print-llc.c369
-rw-r--r--freebsd/contrib/tcpdump/print-lldp.c714
-rw-r--r--freebsd/contrib/tcpdump/print-lmp.c454
-rw-r--r--freebsd/contrib/tcpdump/print-loopback.c144
-rw-r--r--freebsd/contrib/tcpdump/print-lspping.c880
-rw-r--r--freebsd/contrib/tcpdump/print-lwapp.c126
-rw-r--r--freebsd/contrib/tcpdump/print-lwres.c266
-rw-r--r--freebsd/contrib/tcpdump/print-m3ua.c347
-rw-r--r--freebsd/contrib/tcpdump/print-medsa.c204
-rw-r--r--freebsd/contrib/tcpdump/print-mobile.c61
-rw-r--r--freebsd/contrib/tcpdump/print-mobility.c228
-rw-r--r--freebsd/contrib/tcpdump/print-mpcp.c153
-rw-r--r--freebsd/contrib/tcpdump/print-mpls.c83
-rw-r--r--freebsd/contrib/tcpdump/print-mptcp.c438
-rw-r--r--freebsd/contrib/tcpdump/print-msdp.c65
-rw-r--r--freebsd/contrib/tcpdump/print-msnlb.c33
-rw-r--r--freebsd/contrib/tcpdump/print-netbios.c93
-rw-r--r--freebsd/contrib/tcpdump/print-nfs.c1309
-rw-r--r--freebsd/contrib/tcpdump/print-nsh.c193
-rw-r--r--freebsd/contrib/tcpdump/print-ntp.c339
-rw-r--r--freebsd/contrib/tcpdump/print-null.c71
-rw-r--r--freebsd/contrib/tcpdump/print-olsr.c448
-rw-r--r--freebsd/contrib/tcpdump/print-openflow-1.0.c2568
-rw-r--r--freebsd/contrib/tcpdump/print-openflow.c150
-rw-r--r--freebsd/contrib/tcpdump/print-ospf.c808
-rw-r--r--freebsd/contrib/tcpdump/print-ospf6.c842
-rw-r--r--freebsd/contrib/tcpdump/print-otv.c67
-rw-r--r--freebsd/contrib/tcpdump/print-pflog.c93
-rw-r--r--freebsd/contrib/tcpdump/print-pfsync.c245
-rw-r--r--freebsd/contrib/tcpdump/print-pgm.c715
-rw-r--r--freebsd/contrib/tcpdump/print-pim.c764
-rw-r--r--freebsd/contrib/tcpdump/print-pktap.c177
-rw-r--r--freebsd/contrib/tcpdump/print-ppi.c105
-rw-r--r--freebsd/contrib/tcpdump/print-ppp.c1030
-rw-r--r--freebsd/contrib/tcpdump/print-pppoe.c92
-rw-r--r--freebsd/contrib/tcpdump/print-pptp.c1192
-rw-r--r--freebsd/contrib/tcpdump/print-radius.c550
-rw-r--r--freebsd/contrib/tcpdump/print-raw.c30
-rw-r--r--freebsd/contrib/tcpdump/print-resp.c546
-rw-r--r--freebsd/contrib/tcpdump/print-rip.c161
-rw-r--r--freebsd/contrib/tcpdump/print-ripng.c124
-rw-r--r--freebsd/contrib/tcpdump/print-rpki-rtr.c123
-rw-r--r--freebsd/contrib/tcpdump/print-rrcp.c94
-rw-r--r--freebsd/contrib/tcpdump/print-rsvp.c796
-rw-r--r--freebsd/contrib/tcpdump/print-rt6.c60
-rw-r--r--freebsd/contrib/tcpdump/print-rtsp.c55
-rw-r--r--freebsd/contrib/tcpdump/print-rx.c1201
-rw-r--r--freebsd/contrib/tcpdump/print-sctp.c868
-rw-r--r--freebsd/contrib/tcpdump/print-sflow.c585
-rw-r--r--freebsd/contrib/tcpdump/print-sip.c72
-rw-r--r--freebsd/contrib/tcpdump/print-sl.c152
-rw-r--r--freebsd/contrib/tcpdump/print-sll.c207
-rw-r--r--freebsd/contrib/tcpdump/print-slow.c523
-rw-r--r--freebsd/contrib/tcpdump/print-smb.c594
-rw-r--r--freebsd/contrib/tcpdump/print-smtp.c40
-rw-r--r--freebsd/contrib/tcpdump/print-snmp.c939
-rw-r--r--freebsd/contrib/tcpdump/print-stp.c322
-rw-r--r--freebsd/contrib/tcpdump/print-sunatm.c39
-rw-r--r--freebsd/contrib/tcpdump/print-sunrpc.c8
-rw-r--r--freebsd/contrib/tcpdump/print-symantec.c82
-rw-r--r--freebsd/contrib/tcpdump/print-syslog.c89
-rw-r--r--freebsd/contrib/tcpdump/print-tcp.c769
-rw-r--r--freebsd/contrib/tcpdump/print-telnet.c373
-rw-r--r--freebsd/contrib/tcpdump/print-tftp.c185
-rw-r--r--freebsd/contrib/tcpdump/print-timed.c157
-rw-r--r--freebsd/contrib/tcpdump/print-tipc.c123
-rw-r--r--freebsd/contrib/tcpdump/print-token.c173
-rw-r--r--freebsd/contrib/tcpdump/print-udld.c135
-rw-r--r--freebsd/contrib/tcpdump/print-udp.c701
-rw-r--r--freebsd/contrib/tcpdump/print-usb.c60
-rw-r--r--freebsd/contrib/tcpdump/print-vjc.c63
-rw-r--r--freebsd/contrib/tcpdump/print-vqp.c82
-rw-r--r--freebsd/contrib/tcpdump/print-vrrp.c120
-rw-r--r--freebsd/contrib/tcpdump/print-vtp.c171
-rw-r--r--freebsd/contrib/tcpdump/print-vxlan-gpe.c121
-rw-r--r--freebsd/contrib/tcpdump/print-vxlan.c64
-rw-r--r--freebsd/contrib/tcpdump/print-wb.c255
-rw-r--r--freebsd/contrib/tcpdump/print-zephyr.c140
-rw-r--r--freebsd/contrib/tcpdump/print-zeromq.c164
-rw-r--r--freebsd/contrib/tcpdump/print.c492
-rw-r--r--freebsd/contrib/tcpdump/print.h44
-rw-r--r--freebsd/contrib/tcpdump/route6d.h77
-rw-r--r--freebsd/contrib/tcpdump/rpc_auth.h8
-rw-r--r--freebsd/contrib/tcpdump/rpc_msg.h28
-rw-r--r--freebsd/contrib/tcpdump/rpl.h174
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-addrtoname-data.h17
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-addrtostr-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-af-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-ascii_strcasecmp-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-bpf_dump-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-checksum-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-cpack-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-data.h173
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-gmpls-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-gmt2local-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-in_cksum-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-ipproto-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-l2vpn-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-machdep-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-namespace.h462
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-netdissect-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-nlpid-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-oui-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-parsenfsfh-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-802_11-data.h7
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-802_15_4-data.h5
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ah-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ahcp-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-aodv-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-aoe-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ap1394-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-arcnet-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-arp-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ascii-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-atalk-data.h5
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-atm-data.h5
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-babel-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-beep-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-bfd-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-bgp-data.h5
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-bootp-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-bt-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-calm-fast-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-carp-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-cdp-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-cfm-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-chdlc-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-cip-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-cnfp-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-dccp-data.h6
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-decnet-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-dhcp6-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-domain-data.h6
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-dtp-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-dvmrp-data.h5
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-eap-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-egp-data.h9
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-eigrp-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-enc-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-esp-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ether-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-fddi-data.h5
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-forces-data.h5
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-fr-data.h5
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-frag6-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ftp-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-geneve-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-geonet-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-gre-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-hncp-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-hsrp-data.h5
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-http-data.h5
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-icmp-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-icmp6-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-igmp-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-igrp-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ip-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ip6-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ip6opts-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ipcomp-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ipfc-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ipnet-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ipx-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-isakmp-data.h19
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-isoclns-data.h5
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-juniper-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-krb-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-l2tp-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-lane-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ldp-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-lisp-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-llc-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-lldp-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-lmp-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-loopback-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-lspping-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-lwapp-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-lwres-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-m3ua-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-medsa-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-mobile-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-mobility-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-mpcp-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-mpls-data.h5
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-mptcp-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-msdp-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-msnlb-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-nfs-data.h9
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-nsh-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ntp-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-null-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-olsr-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-openflow-1.0-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-openflow-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ospf-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ospf6-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-otv-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-pflog-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-pfsync-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-pgm-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-pim-data.h5
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-pktap-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ppi-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ppp-data.h5
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-pppoe-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-pptp-data.h5
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-radius-data.h20
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-raw-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-resp-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-rip-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ripng-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-rpki-rtr-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-rrcp-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-rsvp-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-rt6-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-rtsp-data.h5
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-rx-data.h8
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-sctp-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-sflow-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-sip-data.h5
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-sl-data.h6
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-sll-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-slow-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-smb-data.h7
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-smtp-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-snmp-data.h377
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-stp-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-sunatm-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-symantec-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-syslog-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-tcp-data.h6
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-telnet-data.h11
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-tftp-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-timed-data.h5
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-tipc-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-token-data.h7
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-udld-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-udp-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-usb-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-vjc-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-vqp-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-vrrp-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-vtp-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-vxlan-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-vxlan-gpe-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-wb-data.h5
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-zephyr-data.h5
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-zeromq-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-setsignal-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-signature-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-smbutil-data.h5
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-tcpdump-data.h28
-rw-r--r--freebsd/contrib/tcpdump/rtems-bsd-tcpdump-util-print-data.h4
-rw-r--r--freebsd/contrib/tcpdump/rx.h113
-rw-r--r--freebsd/contrib/tcpdump/sctpConstants.h571
-rw-r--r--freebsd/contrib/tcpdump/sctpHeader.h323
-rw-r--r--freebsd/contrib/tcpdump/setsignal.c19
-rw-r--r--freebsd/contrib/tcpdump/setsignal.h2
-rw-r--r--freebsd/contrib/tcpdump/signature.c115
-rw-r--r--freebsd/contrib/tcpdump/signature.h11
-rw-r--r--freebsd/contrib/tcpdump/slcompress.h2
-rw-r--r--freebsd/contrib/tcpdump/slip.h34
-rw-r--r--freebsd/contrib/tcpdump/sll.h127
-rw-r--r--freebsd/contrib/tcpdump/smb.h8
-rw-r--r--freebsd/contrib/tcpdump/smbutil.c287
-rw-r--r--freebsd/contrib/tcpdump/strtoaddr.h23
-rw-r--r--freebsd/contrib/tcpdump/tcp.h94
-rw-r--r--freebsd/contrib/tcpdump/tcpdump.c2622
-rw-r--r--freebsd/contrib/tcpdump/telnet.h348
-rw-r--r--freebsd/contrib/tcpdump/tftp.h82
-rw-r--r--freebsd/contrib/tcpdump/timed.h97
-rw-r--r--freebsd/contrib/tcpdump/timeval-operations.h78
-rw-r--r--freebsd/contrib/tcpdump/token.h53
-rw-r--r--freebsd/contrib/tcpdump/udp.h326
-rw-r--r--freebsd/contrib/tcpdump/util-print.c946
-rw-r--r--freebsd/contrib/tcpdump/util.c610
-rw-r--r--freebsd/usr.sbin/tcpdump/tcpdump/config.h275
-rw-r--r--libbsd.py88
-rw-r--r--libbsd_waf.py28
423 files changed, 44407 insertions, 29727 deletions
diff --git a/freebsd/contrib/tcpdump/addrtoname.c b/freebsd/contrib/tcpdump/addrtoname.c
index cd5963d5..82e61a0b 100644
--- a/freebsd/contrib/tcpdump/addrtoname.c
+++ b/freebsd/contrib/tcpdump/addrtoname.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
@@ -22,19 +25,18 @@
*
* Internet, ethernet, port, and protocol string to address
* and address to string conversion routines
- *
- * $FreeBSD$
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/addrtoname.c,v 1.119 2007-08-08 14:06:34 hannes Exp $ (LBL)";
-#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#ifdef HAVE_CASPER
+#include <libcasper.h>
+#include <casper/cap_dns.h>
+#endif /* HAVE_CASPER */
+
+#include <netdissect-stdinc.h>
#ifdef USE_ETHER_NTOHOST
#ifdef HAVE_NETINET_IF_ETHER_H
@@ -65,8 +67,10 @@ extern int ether_ntohost(char *, const struct ether_addr *);
#include <string.h>
#include <stdlib.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
+#include "addrtostr.h"
+#include "ethertype.h"
#include "llc.h"
#include "setsignal.h"
#include "extract.h"
@@ -79,13 +83,13 @@ extern int ether_ntohost(char *, const struct ether_addr *);
/*
* hash tables for whatever-to-name translations
*
- * XXX there has to be error checks against strdup(3) failure
+ * ndo_error() called on strdup(3) failure
*/
#define HASHNAMESIZE 4096
struct hnamemem {
- u_int32_t addr;
+ uint32_t addr;
const char *name;
struct hnamemem *nxt;
};
@@ -97,7 +101,7 @@ static struct hnamemem eprototable[HASHNAMESIZE];
static struct hnamemem dnaddrtable[HASHNAMESIZE];
static struct hnamemem ipxsaptable[HASHNAMESIZE];
-#if defined(INET6) && defined(WIN32)
+#ifdef _WIN32
/*
* fake gethostbyaddr for Win2k/XP
* gethostbyaddr() returns incorrect value when AF_INET6 is passed
@@ -135,9 +139,8 @@ win32_gethostbyaddr(const char *addr, int len, int type)
}
}
#define gethostbyaddr win32_gethostbyaddr
-#endif /* INET6 & WIN32 */
+#endif /* _WIN32 */
-#ifdef INET6
struct h6namemem {
struct in6_addr addr;
char *name;
@@ -145,7 +148,6 @@ struct h6namemem {
};
static struct h6namemem h6nametable[HASHNAMESIZE];
-#endif /* INET6 */
struct enamemem {
u_short e_addr0;
@@ -162,7 +164,7 @@ static struct enamemem nsaptable[HASHNAMESIZE];
static struct enamemem bytestringtable[HASHNAMESIZE];
struct protoidmem {
- u_int32_t p_oui;
+ uint32_t p_oui;
u_short p_proto;
const char *p_name;
struct protoidmem *p_nxt;
@@ -174,7 +176,7 @@ static struct protoidmem protoidtable[HASHNAMESIZE];
* A faster replacement for inet_ntoa().
*/
const char *
-intoa(u_int32_t addr)
+intoa(uint32_t addr)
{
register char *cp;
register u_int byte;
@@ -203,8 +205,11 @@ intoa(u_int32_t addr)
return cp + 1;
}
-static u_int32_t f_netmask;
-static u_int32_t f_localnet;
+static uint32_t f_netmask;
+static uint32_t f_localnet;
+#ifdef HAVE_CASPER
+extern cap_channel_t *capdns;
+#endif
/*
* Return a name for the IP address pointed to by ap. This address
@@ -212,7 +217,7 @@ static u_int32_t f_localnet;
*
* NOTE: ap is *NOT* necessarily part of the packet data (not even if
* this is being called with the "ipaddr_string()" macro), so you
- * *CANNOT* use the TCHECK{2}/TTEST{2} macros on it. Furthermore,
+ * *CANNOT* use the ND_TCHECK{2}/ND_TTEST{2} macros on it. Furthermore,
* even in cases where it *is* part of the packet data, the caller
* would still have to check for a null return value, even if it's
* just printing the return value with "%s" - not all versions of
@@ -226,11 +231,11 @@ static u_int32_t f_localnet;
* also needs to check whether they're present in the packet buffer.
*/
const char *
-getname(const u_char *ap)
+getname(netdissect_options *ndo, const u_char *ap)
{
register struct hostent *hp;
- u_int32_t addr;
- static struct hnamemem *p; /* static for longjmp() */
+ uint32_t addr;
+ struct hnamemem *p;
memcpy(&addr, ap, sizeof(addr));
p = &hnametable[addr & (HASHNAMESIZE-1)];
@@ -239,7 +244,7 @@ getname(const u_char *ap)
return (p->name);
}
p->addr = addr;
- p->nxt = newhnamemem();
+ p->nxt = newhnamemem(ndo);
/*
* Print names unless:
@@ -248,14 +253,23 @@ getname(const u_char *ap)
* given, f_netmask and f_localnet are 0 and the test
* evaluates to true)
*/
- if (!nflag &&
+ if (!ndo->ndo_nflag &&
(addr & f_netmask) == f_localnet) {
- hp = gethostbyaddr((char *)&addr, 4, AF_INET);
+#ifdef HAVE_CASPER
+ if (capdns != NULL) {
+ hp = cap_gethostbyaddr(capdns, (char *)&addr, 4,
+ AF_INET);
+ } else
+#endif
+ hp = gethostbyaddr((char *)&addr, 4, AF_INET);
if (hp) {
char *dotp;
p->name = strdup(hp->h_name);
- if (Nflag) {
+ if (p->name == NULL)
+ (*ndo->ndo_error)(ndo,
+ "getname: strdup(hp->h_name)");
+ if (ndo->ndo_Nflag) {
/* Remove domain qualifications */
dotp = strchr(p->name, '.');
if (dotp)
@@ -265,42 +279,59 @@ getname(const u_char *ap)
}
}
p->name = strdup(intoa(addr));
+ if (p->name == NULL)
+ (*ndo->ndo_error)(ndo, "getname: strdup(intoa(addr))");
return (p->name);
}
-#ifdef INET6
/*
* Return a name for the IP6 address pointed to by ap. This address
* is assumed to be in network byte order.
*/
const char *
-getname6(const u_char *ap)
+getname6(netdissect_options *ndo, const u_char *ap)
{
register struct hostent *hp;
- struct in6_addr addr;
- static struct h6namemem *p; /* static for longjmp() */
+ union {
+ struct in6_addr addr;
+ struct for_hash_addr {
+ char fill[14];
+ uint16_t d;
+ } addra;
+ } addr;
+ struct h6namemem *p;
register const char *cp;
char ntop_buf[INET6_ADDRSTRLEN];
memcpy(&addr, ap, sizeof(addr));
- p = &h6nametable[*(u_int16_t *)&addr.s6_addr[14] & (HASHNAMESIZE-1)];
+ p = &h6nametable[addr.addra.d & (HASHNAMESIZE-1)];
for (; p->nxt; p = p->nxt) {
if (memcmp(&p->addr, &addr, sizeof(addr)) == 0)
return (p->name);
}
- p->addr = addr;
- p->nxt = newh6namemem();
+ p->addr = addr.addr;
+ p->nxt = newh6namemem(ndo);
/*
* Do not print names if -n was given.
*/
- if (!nflag) {
- hp = gethostbyaddr((char *)&addr, sizeof(addr), AF_INET6);
+ if (!ndo->ndo_nflag) {
+#ifdef HAVE_CASPER
+ if (capdns != NULL) {
+ hp = cap_gethostbyaddr(capdns, (char *)&addr,
+ sizeof(addr), AF_INET6);
+ } else
+#endif
+ hp = gethostbyaddr((char *)&addr, sizeof(addr),
+ AF_INET6);
if (hp) {
char *dotp;
p->name = strdup(hp->h_name);
- if (Nflag) {
+ if (p->name == NULL)
+ (*ndo->ndo_error)(ndo,
+ "getname6: strdup(hp->h_name)");
+ if (ndo->ndo_Nflag) {
/* Remove domain qualifications */
dotp = strchr(p->name, '.');
if (dotp)
@@ -309,11 +340,12 @@ getname6(const u_char *ap)
return (p->name);
}
}
- cp = inet_ntop(AF_INET6, &addr, ntop_buf, sizeof(ntop_buf));
+ cp = addrtostr6(ap, ntop_buf, sizeof(ntop_buf));
p->name = strdup(cp);
+ if (p->name == NULL)
+ (*ndo->ndo_error)(ndo, "getname6: strdup(cp)");
return (p->name);
}
-#endif /* INET6 */
static const char hex[] = "0123456789abcdef";
@@ -321,7 +353,7 @@ static const char hex[] = "0123456789abcdef";
/* Find the hash node that corresponds the ether address 'ep' */
static inline struct enamemem *
-lookup_emem(const u_char *ep)
+lookup_emem(netdissect_options *ndo, const u_char *ep)
{
register u_int i, j, k;
struct enamemem *tp;
@@ -343,7 +375,7 @@ lookup_emem(const u_char *ep)
tp->e_addr2 = k;
tp->e_nxt = (struct enamemem *)calloc(1, sizeof(*tp));
if (tp->e_nxt == NULL)
- error("lookup_emem: calloc");
+ (*ndo->ndo_error)(ndo, "lookup_emem: calloc");
return tp;
}
@@ -354,7 +386,8 @@ lookup_emem(const u_char *ep)
*/
static inline struct enamemem *
-lookup_bytestring(register const u_char *bs, const unsigned int nlen)
+lookup_bytestring(netdissect_options *ndo, register const u_char *bs,
+ const unsigned int nlen)
{
struct enamemem *tp;
register u_int i, j, k;
@@ -386,12 +419,12 @@ lookup_bytestring(register const u_char *bs, const unsigned int nlen)
tp->e_bs = (u_char *) calloc(1, nlen + 1);
if (tp->e_bs == NULL)
- error("lookup_bytestring: calloc");
+ (*ndo->ndo_error)(ndo, "lookup_bytestring: calloc");
memcpy(tp->e_bs, bs, nlen);
tp->e_nxt = (struct enamemem *)calloc(1, sizeof(*tp));
if (tp->e_nxt == NULL)
- error("lookup_bytestring: calloc");
+ (*ndo->ndo_error)(ndo, "lookup_bytestring: calloc");
return tp;
}
@@ -399,14 +432,15 @@ lookup_bytestring(register const u_char *bs, const unsigned int nlen)
/* Find the hash node that corresponds the NSAP 'nsap' */
static inline struct enamemem *
-lookup_nsap(register const u_char *nsap)
+lookup_nsap(netdissect_options *ndo, register const u_char *nsap,
+ register u_int nsap_length)
{
register u_int i, j, k;
- unsigned int nlen = *nsap;
struct enamemem *tp;
- const u_char *ensap = nsap + nlen - 6;
+ const u_char *ensap;
- if (nlen > 6) {
+ if (nsap_length > 6) {
+ ensap = nsap + nsap_length - 6;
k = (ensap[0] << 8) | ensap[1];
j = (ensap[2] << 8) | ensap[3];
i = (ensap[4] << 8) | ensap[5];
@@ -419,22 +453,23 @@ lookup_nsap(register const u_char *nsap)
if (tp->e_addr0 == i &&
tp->e_addr1 == j &&
tp->e_addr2 == k &&
- tp->e_nsap[0] == nlen &&
+ tp->e_nsap[0] == nsap_length &&
memcmp((const char *)&(nsap[1]),
- (char *)&(tp->e_nsap[1]), nlen) == 0)
+ (char *)&(tp->e_nsap[1]), nsap_length) == 0)
return tp;
else
tp = tp->e_nxt;
tp->e_addr0 = i;
tp->e_addr1 = j;
tp->e_addr2 = k;
- tp->e_nsap = (u_char *)malloc(nlen + 1);
+ tp->e_nsap = (u_char *)malloc(nsap_length + 1);
if (tp->e_nsap == NULL)
- error("lookup_nsap: malloc");
- memcpy((char *)tp->e_nsap, (const char *)nsap, nlen + 1);
+ (*ndo->ndo_error)(ndo, "lookup_nsap: malloc");
+ tp->e_nsap[0] = (u_char)nsap_length; /* guaranteed < ISONSAP_MAX_LENGTH */
+ memcpy((char *)&tp->e_nsap[1], (const char *)nsap, nsap_length);
tp->e_nxt = (struct enamemem *)calloc(1, sizeof(*tp));
if (tp->e_nxt == NULL)
- error("lookup_nsap: calloc");
+ (*ndo->ndo_error)(ndo, "lookup_nsap: calloc");
return tp;
}
@@ -442,7 +477,7 @@ lookup_nsap(register const u_char *nsap)
/* Find the hash node that corresponds the protoid 'pi'. */
static inline struct protoidmem *
-lookup_protoid(const u_char *pi)
+lookup_protoid(netdissect_options *ndo, const u_char *pi)
{
register u_int i, j;
struct protoidmem *tp;
@@ -462,13 +497,13 @@ lookup_protoid(const u_char *pi)
tp->p_proto = j;
tp->p_nxt = (struct protoidmem *)calloc(1, sizeof(*tp));
if (tp->p_nxt == NULL)
- error("lookup_protoid: calloc");
+ (*ndo->ndo_error)(ndo, "lookup_protoid: calloc");
return tp;
}
const char *
-etheraddr_string(register const u_char *ep)
+etheraddr_string(netdissect_options *ndo, register const u_char *ep)
{
register int i;
register char *cp;
@@ -476,21 +511,18 @@ etheraddr_string(register const u_char *ep)
int oui;
char buf[BUFSIZE];
- tp = lookup_emem(ep);
+ tp = lookup_emem(ndo, ep);
if (tp->e_name)
return (tp->e_name);
#ifdef USE_ETHER_NTOHOST
- if (!nflag) {
+ if (!ndo->ndo_nflag) {
char buf2[BUFSIZE];
- /*
- * We don't cast it to "const struct ether_addr *"
- * because some systems fail to declare the second
- * argument as a "const" pointer, even though they
- * don't modify what it points to.
- */
- if (ether_ntohost(buf2, (struct ether_addr *)ep) == 0) {
+ if (ether_ntohost(buf2, (const struct ether_addr *)ep) == 0) {
tp->e_name = strdup(buf2);
+ if (tp->e_name == NULL)
+ (*ndo->ndo_error)(ndo,
+ "etheraddr_string: strdup(buf2)");
return (tp->e_name);
}
}
@@ -505,17 +537,19 @@ etheraddr_string(register const u_char *ep)
*cp++ = hex[*ep++ & 0xf];
}
- if (!nflag) {
+ if (!ndo->ndo_nflag) {
snprintf(cp, BUFSIZE - (2 + 5*3), " (oui %s)",
tok2str(oui_values, "Unknown", oui));
} else
*cp = '\0';
tp->e_name = strdup(buf);
+ if (tp->e_name == NULL)
+ (*ndo->ndo_error)(ndo, "etheraddr_string: strdup(buf)");
return (tp->e_name);
}
const char *
-le64addr_string(const u_char *ep)
+le64addr_string(netdissect_options *ndo, const u_char *ep)
{
const unsigned int len = 8;
register u_int i;
@@ -523,7 +557,7 @@ le64addr_string(const u_char *ep)
register struct enamemem *tp;
char buf[BUFSIZE];
- tp = lookup_bytestring(ep, len);
+ tp = lookup_bytestring(ndo, ep, len);
if (tp->e_name)
return (tp->e_name);
@@ -538,12 +572,15 @@ le64addr_string(const u_char *ep)
*cp = '\0';
tp->e_name = strdup(buf);
+ if (tp->e_name == NULL)
+ (*ndo->ndo_error)(ndo, "le64addr_string: strdup(buf)");
return (tp->e_name);
}
const char *
-linkaddr_string(const u_char *ep, const unsigned int type, const unsigned int len)
+linkaddr_string(netdissect_options *ndo, const u_char *ep,
+ const unsigned int type, const unsigned int len)
{
register u_int i;
register char *cp;
@@ -553,18 +590,18 @@ linkaddr_string(const u_char *ep, const unsigned int type, const unsigned int le
return ("<empty>");
if (type == LINKADDR_ETHER && len == ETHER_ADDR_LEN)
- return (etheraddr_string(ep));
+ return (etheraddr_string(ndo, ep));
if (type == LINKADDR_FRELAY)
- return (q922_string(ep));
+ return (q922_string(ndo, ep, len));
- tp = lookup_bytestring(ep, len);
+ tp = lookup_bytestring(ndo, ep, len);
if (tp->e_name)
return (tp->e_name);
tp->e_name = cp = (char *)malloc(len*3);
if (tp->e_name == NULL)
- error("linkaddr_string: malloc");
+ (*ndo->ndo_error)(ndo, "linkaddr_string: malloc");
*cp++ = hex[*ep >> 4];
*cp++ = hex[*ep++ & 0xf];
for (i = len-1; i > 0 ; --i) {
@@ -577,11 +614,11 @@ linkaddr_string(const u_char *ep, const unsigned int type, const unsigned int le
}
const char *
-etherproto_string(u_short port)
+etherproto_string(netdissect_options *ndo, u_short port)
{
register char *cp;
register struct hnamemem *tp;
- register u_int32_t i = port;
+ register uint32_t i = port;
char buf[sizeof("0000")];
for (tp = &eprototable[i & (HASHNAMESIZE-1)]; tp->nxt; tp = tp->nxt)
@@ -589,7 +626,7 @@ etherproto_string(u_short port)
return (tp->name);
tp->addr = i;
- tp->nxt = newhnamemem();
+ tp->nxt = newhnamemem(ndo);
cp = buf;
NTOHS(port);
@@ -599,18 +636,20 @@ etherproto_string(u_short port)
*cp++ = hex[port & 0xf];
*cp++ = '\0';
tp->name = strdup(buf);
+ if (tp->name == NULL)
+ (*ndo->ndo_error)(ndo, "etherproto_string: strdup(buf)");
return (tp->name);
}
const char *
-protoid_string(register const u_char *pi)
+protoid_string(netdissect_options *ndo, register const u_char *pi)
{
register u_int i, j;
register char *cp;
register struct protoidmem *tp;
char buf[sizeof("00:00:00:00:00")];
- tp = lookup_protoid(pi);
+ tp = lookup_protoid(ndo, pi);
if (tp->p_name)
return tp->p_name;
@@ -626,12 +665,15 @@ protoid_string(register const u_char *pi)
}
*cp = '\0';
tp->p_name = strdup(buf);
+ if (tp->p_name == NULL)
+ (*ndo->ndo_error)(ndo, "protoid_string: strdup(buf)");
return (tp->p_name);
}
#define ISONSAP_MAX_LENGTH 20
const char *
-isonsap_string(const u_char *nsap, register u_int nsap_length)
+isonsap_string(netdissect_options *ndo, const u_char *nsap,
+ register u_int nsap_length)
{
register u_int nsap_idx;
register char *cp;
@@ -640,13 +682,13 @@ isonsap_string(const u_char *nsap, register u_int nsap_length)
if (nsap_length < 1 || nsap_length > ISONSAP_MAX_LENGTH)
return ("isonsap_string: illegal length");
- tp = lookup_nsap(nsap);
+ tp = lookup_nsap(ndo, nsap, nsap_length);
if (tp->e_name)
return tp->e_name;
tp->e_name = cp = (char *)malloc(sizeof("xx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xxxx.xx"));
if (cp == NULL)
- error("isonsap_string: malloc");
+ (*ndo->ndo_error)(ndo, "isonsap_string: malloc");
for (nsap_idx = 0; nsap_idx < nsap_length; nsap_idx++) {
*cp++ = hex[*nsap >> 4];
@@ -661,10 +703,10 @@ isonsap_string(const u_char *nsap, register u_int nsap_length)
}
const char *
-tcpport_string(u_short port)
+tcpport_string(netdissect_options *ndo, u_short port)
{
register struct hnamemem *tp;
- register u_int32_t i = port;
+ register uint32_t i = port;
char buf[sizeof("00000")];
for (tp = &tporttable[i & (HASHNAMESIZE-1)]; tp->nxt; tp = tp->nxt)
@@ -672,18 +714,20 @@ tcpport_string(u_short port)
return (tp->name);
tp->addr = i;
- tp->nxt = newhnamemem();
+ tp->nxt = newhnamemem(ndo);
(void)snprintf(buf, sizeof(buf), "%u", i);
tp->name = strdup(buf);
+ if (tp->name == NULL)
+ (*ndo->ndo_error)(ndo, "tcpport_string: strdup(buf)");
return (tp->name);
}
const char *
-udpport_string(register u_short port)
+udpport_string(netdissect_options *ndo, register u_short port)
{
register struct hnamemem *tp;
- register u_int32_t i = port;
+ register uint32_t i = port;
char buf[sizeof("00000")];
for (tp = &uporttable[i & (HASHNAMESIZE-1)]; tp->nxt; tp = tp->nxt)
@@ -691,19 +735,21 @@ udpport_string(register u_short port)
return (tp->name);
tp->addr = i;
- tp->nxt = newhnamemem();
+ tp->nxt = newhnamemem(ndo);
(void)snprintf(buf, sizeof(buf), "%u", i);
tp->name = strdup(buf);
+ if (tp->name == NULL)
+ (*ndo->ndo_error)(ndo, "udpport_string: strdup(buf)");
return (tp->name);
}
const char *
-ipxsap_string(u_short port)
+ipxsap_string(netdissect_options *ndo, u_short port)
{
register char *cp;
register struct hnamemem *tp;
- register u_int32_t i = port;
+ register uint32_t i = port;
char buf[sizeof("0000")];
for (tp = &ipxsaptable[i & (HASHNAMESIZE-1)]; tp->nxt; tp = tp->nxt)
@@ -711,7 +757,7 @@ ipxsap_string(u_short port)
return (tp->name);
tp->addr = i;
- tp->nxt = newhnamemem();
+ tp->nxt = newhnamemem(ndo);
cp = buf;
NTOHS(port);
@@ -721,11 +767,13 @@ ipxsap_string(u_short port)
*cp++ = hex[port & 0xf];
*cp++ = '\0';
tp->name = strdup(buf);
+ if (tp->name == NULL)
+ (*ndo->ndo_error)(ndo, "ipxsap_string: strdup(buf)");
return (tp->name);
}
static void
-init_servarray(void)
+init_servarray(netdissect_options *ndo)
{
struct servent *sv;
register struct hnamemem *table;
@@ -744,30 +792,49 @@ init_servarray(void)
while (table->name)
table = table->nxt;
- if (nflag) {
+ if (ndo->ndo_nflag) {
(void)snprintf(buf, sizeof(buf), "%d", port);
table->name = strdup(buf);
} else
table->name = strdup(sv->s_name);
+ if (table->name == NULL)
+ (*ndo->ndo_error)(ndo, "init_servarray: strdup");
+
table->addr = port;
- table->nxt = newhnamemem();
+ table->nxt = newhnamemem(ndo);
}
endservent();
}
-/* in libpcap.a (nametoaddr.c) */
-#if defined(WIN32) && !defined(USE_STATIC_LIBPCAP)
-__declspec(dllimport)
-#else
-extern
-#endif
-const struct eproto {
+static const struct eproto {
const char *s;
u_short p;
-} eproto_db[];
+} eproto_db[] = {
+ { "pup", ETHERTYPE_PUP },
+ { "xns", ETHERTYPE_NS },
+ { "ip", ETHERTYPE_IP },
+ { "ip6", ETHERTYPE_IPV6 },
+ { "arp", ETHERTYPE_ARP },
+ { "rarp", ETHERTYPE_REVARP },
+ { "sprite", ETHERTYPE_SPRITE },
+ { "mopdl", ETHERTYPE_MOPDL },
+ { "moprc", ETHERTYPE_MOPRC },
+ { "decnet", ETHERTYPE_DN },
+ { "lat", ETHERTYPE_LAT },
+ { "sca", ETHERTYPE_SCA },
+ { "lanbridge", ETHERTYPE_LANBRIDGE },
+ { "vexp", ETHERTYPE_VEXP },
+ { "vprod", ETHERTYPE_VPROD },
+ { "atalk", ETHERTYPE_ATALK },
+ { "atalkarp", ETHERTYPE_AARP },
+ { "loopback", ETHERTYPE_LOOPBACK },
+ { "decdts", ETHERTYPE_DECDTS },
+ { "decdns", ETHERTYPE_DECDNS },
+ { (char *)0, 0 }
+};
static void
-init_eprotoarray(void)
+init_eprotoarray(netdissect_options *ndo)
{
register int i;
register struct hnamemem *table;
@@ -779,7 +846,7 @@ init_eprotoarray(void)
table = table->nxt;
table->name = eproto_db[i].s;
table->addr = htons(eproto_db[i].p);
- table->nxt = newhnamemem();
+ table->nxt = newhnamemem(ndo);
}
}
@@ -800,7 +867,7 @@ static const struct protoidlist {
* types.
*/
static void
-init_protoidarray(void)
+init_protoidarray(netdissect_options *ndo)
{
register int i;
register struct protoidmem *tp;
@@ -814,12 +881,15 @@ init_protoidarray(void)
u_short etype = htons(eproto_db[i].p);
memcpy((char *)&protoid[3], (char *)&etype, 2);
- tp = lookup_protoid(protoid);
+ tp = lookup_protoid(ndo, protoid);
tp->p_name = strdup(eproto_db[i].s);
+ if (tp->p_name == NULL)
+ (*ndo->ndo_error)(ndo,
+ "init_protoidarray: strdup(eproto_db[i].s)");
}
/* Hardwire some SNAP proto ID names */
for (pl = protoidlist; pl->name != NULL; ++pl) {
- tp = lookup_protoid(pl->protoid);
+ tp = lookup_protoid(ndo, pl->protoid);
/* Don't override existing name */
if (tp->p_name != NULL)
continue;
@@ -851,7 +921,7 @@ static const struct etherlist {
* translation, so we just pcap_next_etherent as a convenience.
*/
static void
-init_etherarray(void)
+init_etherarray(netdissect_options *ndo)
{
register const struct etherlist *el;
register struct enamemem *tp;
@@ -865,8 +935,11 @@ init_etherarray(void)
fp = fopen(PCAP_ETHERS_FILE, "r");
if (fp != NULL) {
while ((ep = pcap_next_etherent(fp)) != NULL) {
- tp = lookup_emem(ep->addr);
+ tp = lookup_emem(ndo, ep->addr);
tp->e_name = strdup(ep->name);
+ if (tp->e_name == NULL)
+ (*ndo->ndo_error)(ndo,
+ "init_etherarray: strdup(ep->addr)");
}
(void)fclose(fp);
}
@@ -874,7 +947,7 @@ init_etherarray(void)
/* Hardwire some ethernet names */
for (el = etherlist; el->name != NULL; ++el) {
- tp = lookup_emem(el->addr);
+ tp = lookup_emem(ndo, el->addr);
/* Don't override existing name */
if (tp->e_name != NULL)
continue;
@@ -882,14 +955,12 @@ init_etherarray(void)
#ifdef USE_ETHER_NTOHOST
/*
* Use YP/NIS version of name if available.
- *
- * We don't cast it to "const struct ether_addr *"
- * because some systems don't modify the Ethernet
- * address but fail to declare the second argument
- * as a "const" pointer.
*/
- if (ether_ntohost(name, (struct ether_addr *)el->addr) == 0) {
+ if (ether_ntohost(name, (const struct ether_addr *)el->addr) == 0) {
tp->e_name = strdup(name);
+ if (tp->e_name == NULL)
+ (*ndo->ndo_error)(ndo,
+ "init_etherarray: strdup(name)");
continue;
}
#endif
@@ -1115,7 +1186,7 @@ static const struct tok ipxsap_db[] = {
};
static void
-init_ipxsaparray(void)
+init_ipxsaparray(netdissect_options *ndo)
{
register int i;
register struct hnamemem *table;
@@ -1127,59 +1198,59 @@ init_ipxsaparray(void)
table = table->nxt;
table->name = ipxsap_db[i].s;
table->addr = htons(ipxsap_db[i].v);
- table->nxt = newhnamemem();
+ table->nxt = newhnamemem(ndo);
}
}
/*
* Initialize the address to name translation machinery. We map all
- * non-local IP addresses to numeric addresses if fflag is true (i.e.,
- * to prevent blocking on the nameserver). localnet is the IP address
+ * non-local IP addresses to numeric addresses if ndo->ndo_fflag is true
+ * (i.e., to prevent blocking on the nameserver). localnet is the IP address
* of the local network. mask is its subnet mask.
*/
void
-init_addrtoname(u_int32_t localnet, u_int32_t mask)
+init_addrtoname(netdissect_options *ndo, uint32_t localnet, uint32_t mask)
{
- if (fflag) {
+ if (ndo->ndo_fflag) {
f_localnet = localnet;
f_netmask = mask;
}
- if (nflag)
+ if (ndo->ndo_nflag)
/*
* Simplest way to suppress names.
*/
return;
- init_etherarray();
- init_servarray();
- init_eprotoarray();
- init_protoidarray();
- init_ipxsaparray();
+ init_etherarray(ndo);
+ init_servarray(ndo);
+ init_eprotoarray(ndo);
+ init_protoidarray(ndo);
+ init_ipxsaparray(ndo);
}
const char *
-dnaddr_string(u_short dnaddr)
+dnaddr_string(netdissect_options *ndo, u_short dnaddr)
{
register struct hnamemem *tp;
- for (tp = &dnaddrtable[dnaddr & (HASHNAMESIZE-1)]; tp->nxt != 0;
+ for (tp = &dnaddrtable[dnaddr & (HASHNAMESIZE-1)]; tp->nxt != NULL;
tp = tp->nxt)
if (tp->addr == dnaddr)
return (tp->name);
tp->addr = dnaddr;
- tp->nxt = newhnamemem();
- if (nflag)
- tp->name = dnnum_string(dnaddr);
+ tp->nxt = newhnamemem(ndo);
+ if (ndo->ndo_nflag)
+ tp->name = dnnum_string(ndo, dnaddr);
else
- tp->name = dnname_string(dnaddr);
+ tp->name = dnname_string(ndo, dnaddr);
return(tp->name);
}
/* Return a zero'ed hnamemem struct and cuts down on calloc() overhead */
struct hnamemem *
-newhnamemem(void)
+newhnamemem(netdissect_options *ndo)
{
register struct hnamemem *p;
static struct hnamemem *ptr = NULL;
@@ -1189,17 +1260,16 @@ newhnamemem(void)
num = 64;
ptr = (struct hnamemem *)calloc(num, sizeof (*ptr));
if (ptr == NULL)
- error("newhnamemem: calloc");
+ (*ndo->ndo_error)(ndo, "newhnamemem: calloc");
}
--num;
p = ptr++;
return (p);
}
-#ifdef INET6
/* Return a zero'ed h6namemem struct and cuts down on calloc() overhead */
struct h6namemem *
-newh6namemem(void)
+newh6namemem(netdissect_options *ndo)
{
register struct h6namemem *p;
static struct h6namemem *ptr = NULL;
@@ -1209,10 +1279,24 @@ newh6namemem(void)
num = 64;
ptr = (struct h6namemem *)calloc(num, sizeof (*ptr));
if (ptr == NULL)
- error("newh6namemem: calloc");
+ (*ndo->ndo_error)(ndo, "newh6namemem: calloc");
}
--num;
p = ptr++;
return (p);
}
-#endif /* INET6 */
+
+/* Represent TCI part of the 802.1Q 4-octet tag as text. */
+const char *
+ieee8021q_tci_string(const uint16_t tci)
+{
+ static char buf[128];
+ snprintf(buf, sizeof(buf), "vlan %u, p %u%s",
+ tci & 0xfff,
+ tci >> 13,
+ (tci & 0x1000) ? ", DEI" : "");
+ return buf;
+}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-addrtoname-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/addrtoname.h b/freebsd/contrib/tcpdump/addrtoname.h
index cd5c41f4..72e5ef19 100644
--- a/freebsd/contrib/tcpdump/addrtoname.h
+++ b/freebsd/contrib/tcpdump/addrtoname.h
@@ -17,10 +17,16 @@
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * @(#) $Header: /tcpdump/master/tcpdump/addrtoname.h,v 1.20 2007-08-08 14:06:34 hannes Exp $ (LBL)
*/
+/*
+ * Definitions to let us compile most of the IPv6 code even on systems
+ * without IPv6 support.
+ */
+#ifndef INET6_ADDRSTRLEN
+#define INET6_ADDRSTRLEN 46
+#endif
+
/* Name to address translation routines. */
enum {
@@ -32,25 +38,24 @@ enum {
#define BUFSIZE 128
-extern const char *linkaddr_string(const u_char *, const unsigned int, const unsigned int);
-extern const char *etheraddr_string(const u_char *);
-extern const char *le64addr_string(const u_char *);
-extern const char *etherproto_string(u_short);
-extern const char *tcpport_string(u_short);
-extern const char *udpport_string(u_short);
-extern const char *getname(const u_char *);
-#ifdef INET6
-extern const char *getname6(const u_char *);
-#endif
-extern const char *intoa(u_int32_t);
+extern const char *linkaddr_string(netdissect_options *, const u_char *, const unsigned int, const unsigned int);
+extern const char *etheraddr_string(netdissect_options *, const u_char *);
+extern const char *le64addr_string(netdissect_options *, const u_char *);
+extern const char *etherproto_string(netdissect_options *, u_short);
+extern const char *tcpport_string(netdissect_options *, u_short);
+extern const char *udpport_string(netdissect_options *, u_short);
+extern const char *isonsap_string(netdissect_options *, const u_char *, register u_int);
+extern const char *dnaddr_string(netdissect_options *, u_short);
+extern const char *protoid_string(netdissect_options *, const u_char *);
+extern const char *ipxsap_string(netdissect_options *, u_short);
+extern const char *getname(netdissect_options *, const u_char *);
+extern const char *getname6(netdissect_options *, const u_char *);
+extern const char *intoa(uint32_t);
-extern void init_addrtoname(u_int32_t, u_int32_t);
-extern struct hnamemem *newhnamemem(void);
-#ifdef INET6
-extern struct h6namemem *newh6namemem(void);
-#endif
+extern void init_addrtoname(netdissect_options *, uint32_t, uint32_t);
+extern struct hnamemem *newhnamemem(netdissect_options *);
+extern struct h6namemem *newh6namemem(netdissect_options *);
+extern const char * ieee8021q_tci_string(const uint16_t);
-#define ipaddr_string(p) getname((const u_char *)(p))
-#ifdef INET6
-#define ip6addr_string(p) getname6((const u_char *)(p))
-#endif
+#define ipaddr_string(ndo, p) getname(ndo, (const u_char *)(p))
+#define ip6addr_string(ndo, p) getname6(ndo, (const u_char *)(p))
diff --git a/freebsd/contrib/tcpdump/addrtostr.c b/freebsd/contrib/tcpdump/addrtostr.c
new file mode 100644
index 00000000..b29fe415
--- /dev/null
+++ b/freebsd/contrib/tcpdump/addrtostr.c
@@ -0,0 +1,222 @@
+#include <machine/rtems-bsd-user-space.h>
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
+/*
+ * Copyright (c) 1999 Kungliga Tekniska Högskolan
+ * (Royal Institute of Technology, Stockholm, Sweden).
+ * All rights reserved.
+ *
+ * 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the Kungliga Tekniska
+ * Högskolan and its contributors.
+ *
+ * 4. Neither the name of the Institute 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 INSTITUTE 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 INSTITUTE 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <netdissect-stdinc.h>
+#include "addrtostr.h"
+
+#include <stdio.h>
+#include <string.h>
+
+/*
+ *
+ */
+
+#ifndef IN6ADDRSZ
+#define IN6ADDRSZ 16 /* IPv6 T_AAAA */
+#endif
+
+#ifndef INT16SZ
+#define INT16SZ 2 /* word size */
+#endif
+
+const char *
+addrtostr (const void *src, char *dst, size_t size)
+{
+ const u_char *srcaddr = (const u_char *)src;
+ const char digits[] = "0123456789";
+ int i;
+ const char *orig_dst = dst;
+
+ if (size < INET_ADDRSTRLEN) {
+ errno = ENOSPC;
+ return NULL;
+ }
+ for (i = 0; i < 4; ++i) {
+ int n = *srcaddr++;
+ int non_zerop = 0;
+
+ if (non_zerop || n / 100 > 0) {
+ *dst++ = digits[n / 100];
+ n %= 100;
+ non_zerop = 1;
+ }
+ if (non_zerop || n / 10 > 0) {
+ *dst++ = digits[n / 10];
+ n %= 10;
+ non_zerop = 1;
+ }
+ *dst++ = digits[n];
+ if (i != 3)
+ *dst++ = '.';
+ }
+ *dst++ = '\0';
+ return orig_dst;
+}
+
+/*
+ * Convert IPv6 binary address into presentation (printable) format.
+ */
+const char *
+addrtostr6 (const void *src, char *dst, size_t size)
+{
+ /*
+ * Note that int32_t and int16_t need only be "at least" large enough
+ * to contain a value of the specified size. On some systems, like
+ * Crays, there is no such thing as an integer variable with 16 bits.
+ * Keep this in mind if you think this function should have been coded
+ * to use pointer overlays. All the world's not a VAX.
+ */
+ const u_char *srcaddr = (const u_char *)src;
+ char *dp;
+ size_t space_left, added_space;
+ int snprintfed;
+ struct {
+ long base;
+ long len;
+ } best, cur;
+ u_long words [IN6ADDRSZ / INT16SZ];
+ int i;
+
+ /* Preprocess:
+ * Copy the input (bytewise) array into a wordwise array.
+ * Find the longest run of 0x00's in src[] for :: shorthanding.
+ */
+ memset (words, 0, sizeof(words));
+ for (i = 0; i < IN6ADDRSZ; i++)
+ words[i/2] |= (srcaddr[i] << ((1 - (i % 2)) << 3));
+
+ best.len = 0;
+ best.base = -1;
+ cur.len = 0;
+ cur.base = -1;
+ for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++)
+ {
+ if (words[i] == 0)
+ {
+ if (cur.base == -1)
+ cur.base = i, cur.len = 1;
+ else cur.len++;
+ }
+ else if (cur.base != -1)
+ {
+ if (best.base == -1 || cur.len > best.len)
+ best = cur;
+ cur.base = -1;
+ }
+ }
+ if ((cur.base != -1) && (best.base == -1 || cur.len > best.len))
+ best = cur;
+ if (best.base != -1 && best.len < 2)
+ best.base = -1;
+
+ /* Format the result.
+ */
+ dp = dst;
+ space_left = size;
+#define APPEND_CHAR(c) \
+ { \
+ if (space_left == 0) { \
+ errno = ENOSPC; \
+ return (NULL); \
+ } \
+ *dp++ = c; \
+ space_left--; \
+ }
+ for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++)
+ {
+ /* Are we inside the best run of 0x00's?
+ */
+ if (best.base != -1 && i >= best.base && i < (best.base + best.len))
+ {
+ if (i == best.base)
+ APPEND_CHAR(':');
+ continue;
+ }
+
+ /* Are we following an initial run of 0x00s or any real hex?
+ */
+ if (i != 0)
+ APPEND_CHAR(':');
+
+ /* Is this address an encapsulated IPv4?
+ */
+ if (i == 6 && best.base == 0 &&
+ (best.len == 6 || (best.len == 5 && words[5] == 0xffff)))
+ {
+ if (!addrtostr(srcaddr+12, dp, space_left))
+ {
+ errno = ENOSPC;
+ return (NULL);
+ }
+ added_space = strlen(dp);
+ dp += added_space;
+ space_left -= added_space;
+ break;
+ }
+ snprintfed = snprintf (dp, space_left, "%lx", words[i]);
+ if (snprintfed < 0)
+ return (NULL);
+ if ((size_t) snprintfed >= space_left)
+ {
+ errno = ENOSPC;
+ return (NULL);
+ }
+ dp += snprintfed;
+ space_left -= snprintfed;
+ }
+
+ /* Was it a trailing run of 0x00's?
+ */
+ if (best.base != -1 && (best.base + best.len) == (IN6ADDRSZ / INT16SZ))
+ APPEND_CHAR(':');
+ APPEND_CHAR('\0');
+
+ return (dst);
+}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-addrtostr-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/decode_prefix.h b/freebsd/contrib/tcpdump/addrtostr.h
index 8bb4a767..2b95a162 100644
--- a/freebsd/contrib/tcpdump/decode_prefix.h
+++ b/freebsd/contrib/tcpdump/addrtostr.h
@@ -1,23 +1,32 @@
/*
- * Copyright (C) 1999 WIDE Project.
+ * Copyright (c) 1999 Kungliga Tekniska Högskolan
+ * (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
* 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
+ *
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the Kungliga Tekniska
+ * Högskolan and its contributors.
+ *
+ * 4. Neither the name of the Institute 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
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE 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
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE 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)
@@ -25,17 +34,9 @@
* 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.
- *
- * Extensively modified by Hannes Gredler (hannes@juniper.net) for more
- * complete BGP support.
*/
-#ifndef tcpdump_decode_prefix_h
-#define tcpdump_decode_prefix_h
-
-extern int decode_prefix4(const u_char *pptr, u_int itemlen, char *buf, u_int buflen);
-#ifdef INET6
-extern int decode_prefix6(const u_char *pd, u_int itemlen, char *buf, u_int buflen);
-#endif
+/* Address to printable string translation routines. */
-#endif
+extern const char *addrtostr(const void *src, char *dst, size_t size);
+extern const char *addrtostr6(const void *src, char *dst, size_t size);
diff --git a/freebsd/contrib/tcpdump/af.c b/freebsd/contrib/tcpdump/af.c
index 4e307a02..18ea6da9 100644
--- a/freebsd/contrib/tcpdump/af.c
+++ b/freebsd/contrib/tcpdump/af.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1998-2006 The TCPDUMP project
*
@@ -17,17 +20,12 @@
* Original code by Hannes Gredler (hannes@juniper.net)
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/af.c,v 1.3 2006-03-23 14:58:44 hannes Exp $ (LBL)";
-#endif
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
-#include "interface.h"
+#include <netdissect-stdinc.h>
+#include "netdissect.h"
#include "af.h"
const struct tok af_values[] = {
@@ -63,3 +61,6 @@ const struct tok bsd_af_values[] = {
{ BSD_AFNUM_INET6_DARWIN, "IPv6" },
{ 0, NULL}
};
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-af-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/af.h b/freebsd/contrib/tcpdump/af.h
index 679cc8e5..1bde577e 100644
--- a/freebsd/contrib/tcpdump/af.h
+++ b/freebsd/contrib/tcpdump/af.h
@@ -1,5 +1,3 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/af.h,v 1.3 2006-03-23 14:58:44 hannes Exp $ (LBL) */
-
/*
* Copyright (c) 1998-2006 The TCPDUMP project
*
@@ -52,6 +50,6 @@ extern const struct tok bsd_af_values[];
#define BSD_AFNUM_ISO 7
#define BSD_AFNUM_APPLETALK 16
#define BSD_AFNUM_IPX 23
-#define BSD_AFNUM_INET6_BSD 24 /* OpenBSD (and probably NetBSD), BSD/OS */
-#define BSD_AFNUM_INET6_FREEBSD 28
-#define BSD_AFNUM_INET6_DARWIN 30
+#define BSD_AFNUM_INET6_BSD 24 /* NetBSD, OpenBSD, BSD/OS, Npcap */
+#define BSD_AFNUM_INET6_FREEBSD 28 /* FreeBSD */
+#define BSD_AFNUM_INET6_DARWIN 30 /* OS X, iOS, other Darwin-based OSes */
diff --git a/freebsd/contrib/tcpdump/ah.h b/freebsd/contrib/tcpdump/ah.h
index c22806af..d87a087e 100644
--- a/freebsd/contrib/tcpdump/ah.h
+++ b/freebsd/contrib/tcpdump/ah.h
@@ -38,19 +38,19 @@
#define _NETINET6_AH_H_
struct ah {
- u_int8_t ah_nxt; /* Next Header */
- u_int8_t ah_len; /* Length of data, in 32bit */
- u_int16_t ah_reserve; /* Reserved for future use */
- u_int32_t ah_spi; /* Security parameter index */
+ uint8_t ah_nxt; /* Next Header */
+ uint8_t ah_len; /* Length of data, in 32bit */
+ uint16_t ah_reserve; /* Reserved for future use */
+ uint32_t ah_spi; /* Security parameter index */
/* variable size, 32bit bound*/ /* Authentication data */
};
struct newah {
- u_int8_t ah_nxt; /* Next Header */
- u_int8_t ah_len; /* Length of data + 1, in 32bit */
- u_int16_t ah_reserve; /* Reserved for future use */
- u_int32_t ah_spi; /* Security parameter index */
- u_int32_t ah_seq; /* Sequence number field */
+ uint8_t ah_nxt; /* Next Header */
+ uint8_t ah_len; /* Length of data + 1, in 32bit */
+ uint16_t ah_reserve; /* Reserved for future use */
+ uint32_t ah_spi; /* Security parameter index */
+ uint32_t ah_seq; /* Sequence number field */
/* variable size, 32bit bound*/ /* Authentication data */
};
diff --git a/freebsd/contrib/tcpdump/aodv.h b/freebsd/contrib/tcpdump/aodv.h
deleted file mode 100644
index 456ec8b3..00000000
--- a/freebsd/contrib/tcpdump/aodv.h
+++ /dev/null
@@ -1,190 +0,0 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/aodv.h,v 1.3 2003-09-13 01:34:42 guy Exp $ (LBL) */
-/*
- * Copyright (c) 2003 Bruce M. Simpson <bms@spc.org>
- * All rights reserved.
- *
- * 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. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by Bruce M. Simpson.
- * 4. Neither the name of Bruce M. Simpson nor the names of co-
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY Bruce M. Simpson 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 Bruce M. Simpson 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.
- */
-#ifndef _AODV_H_
-#define _AODV_H_
-
-struct aodv_rreq {
- u_int8_t rreq_type; /* AODV message type (1) */
- u_int8_t rreq_flags; /* various flags */
- u_int8_t rreq_zero0; /* reserved, set to zero */
- u_int8_t rreq_hops; /* number of hops from originator */
- u_int32_t rreq_id; /* request ID */
- u_int32_t rreq_da; /* destination IPv4 address */
- u_int32_t rreq_ds; /* destination sequence number */
- u_int32_t rreq_oa; /* originator IPv4 address */
- u_int32_t rreq_os; /* originator sequence number */
-};
-#ifdef INET6
-struct aodv_rreq6 {
- u_int8_t rreq_type; /* AODV message type (1) */
- u_int8_t rreq_flags; /* various flags */
- u_int8_t rreq_zero0; /* reserved, set to zero */
- u_int8_t rreq_hops; /* number of hops from originator */
- u_int32_t rreq_id; /* request ID */
- struct in6_addr rreq_da; /* destination IPv6 address */
- u_int32_t rreq_ds; /* destination sequence number */
- struct in6_addr rreq_oa; /* originator IPv6 address */
- u_int32_t rreq_os; /* originator sequence number */
-};
-struct aodv_rreq6_draft_01 {
- u_int8_t rreq_type; /* AODV message type (16) */
- u_int8_t rreq_flags; /* various flags */
- u_int8_t rreq_zero0; /* reserved, set to zero */
- u_int8_t rreq_hops; /* number of hops from originator */
- u_int32_t rreq_id; /* request ID */
- u_int32_t rreq_ds; /* destination sequence number */
- u_int32_t rreq_os; /* originator sequence number */
- struct in6_addr rreq_da; /* destination IPv6 address */
- struct in6_addr rreq_oa; /* originator IPv6 address */
-};
-#endif
-
-#define RREQ_JOIN 0x80 /* join (reserved for multicast */
-#define RREQ_REPAIR 0x40 /* repair (reserved for multicast */
-#define RREQ_GRAT 0x20 /* gratuitous RREP */
-#define RREQ_DEST 0x10 /* destination only */
-#define RREQ_UNKNOWN 0x08 /* unknown destination sequence num */
-#define RREQ_FLAGS_MASK 0xF8 /* mask for rreq_flags */
-
-struct aodv_rrep {
- u_int8_t rrep_type; /* AODV message type (2) */
- u_int8_t rrep_flags; /* various flags */
- u_int8_t rrep_ps; /* prefix size */
- u_int8_t rrep_hops; /* number of hops from o to d */
- u_int32_t rrep_da; /* destination IPv4 address */
- u_int32_t rrep_ds; /* destination sequence number */
- u_int32_t rrep_oa; /* originator IPv4 address */
- u_int32_t rrep_life; /* lifetime of this route */
-};
-#ifdef INET6
-struct aodv_rrep6 {
- u_int8_t rrep_type; /* AODV message type (2) */
- u_int8_t rrep_flags; /* various flags */
- u_int8_t rrep_ps; /* prefix size */
- u_int8_t rrep_hops; /* number of hops from o to d */
- struct in6_addr rrep_da; /* destination IPv6 address */
- u_int32_t rrep_ds; /* destination sequence number */
- struct in6_addr rrep_oa; /* originator IPv6 address */
- u_int32_t rrep_life; /* lifetime of this route */
-};
-struct aodv_rrep6_draft_01 {
- u_int8_t rrep_type; /* AODV message type (17) */
- u_int8_t rrep_flags; /* various flags */
- u_int8_t rrep_ps; /* prefix size */
- u_int8_t rrep_hops; /* number of hops from o to d */
- u_int32_t rrep_ds; /* destination sequence number */
- struct in6_addr rrep_da; /* destination IPv6 address */
- struct in6_addr rrep_oa; /* originator IPv6 address */
- u_int32_t rrep_life; /* lifetime of this route */
-};
-#endif
-
-#define RREP_REPAIR 0x80 /* repair (reserved for multicast */
-#define RREP_ACK 0x40 /* acknowledgement required */
-#define RREP_FLAGS_MASK 0xC0 /* mask for rrep_flags */
-#define RREP_PREFIX_MASK 0x1F /* mask for prefix size */
-
-struct rerr_unreach {
- u_int32_t u_da; /* IPv4 address */
- u_int32_t u_ds; /* sequence number */
-};
-#ifdef INET6
-struct rerr_unreach6 {
- struct in6_addr u_da; /* IPv6 address */
- u_int32_t u_ds; /* sequence number */
-};
-struct rerr_unreach6_draft_01 {
- struct in6_addr u_da; /* IPv6 address */
- u_int32_t u_ds; /* sequence number */
-};
-#endif
-
-struct aodv_rerr {
- u_int8_t rerr_type; /* AODV message type (3 or 18) */
- u_int8_t rerr_flags; /* various flags */
- u_int8_t rerr_zero0; /* reserved, set to zero */
- u_int8_t rerr_dc; /* destination count */
- union {
- struct rerr_unreach dest[1];
-#ifdef INET6
- struct rerr_unreach6 dest6[1];
- struct rerr_unreach6_draft_01 dest6_draft_01[1];
-#endif
- } r;
-};
-
-#define RERR_NODELETE 0x80 /* don't delete the link */
-#define RERR_FLAGS_MASK 0x80 /* mask for rerr_flags */
-
-struct aodv_rrep_ack {
- u_int8_t ra_type;
- u_int8_t ra_zero0;
-};
-
-union aodv {
- struct aodv_rreq rreq;
- struct aodv_rrep rrep;
- struct aodv_rerr rerr;
- struct aodv_rrep_ack rrep_ack;
-#ifdef INET6
- struct aodv_rreq6 rreq6;
- struct aodv_rreq6_draft_01 rreq6_draft_01;
- struct aodv_rrep6 rrep6;
- struct aodv_rrep6_draft_01 rrep6_draft_01;
-#endif
-};
-
-#define AODV_RREQ 1 /* route request */
-#define AODV_RREP 2 /* route response */
-#define AODV_RERR 3 /* error report */
-#define AODV_RREP_ACK 4 /* route response acknowledgement */
-
-#define AODV_V6_DRAFT_01_RREQ 16 /* IPv6 route request */
-#define AODV_V6_DRAFT_01_RREP 17 /* IPv6 route response */
-#define AODV_V6_DRAFT_01_RERR 18 /* IPv6 error report */
-#define AODV_V6_DRAFT_01_RREP_ACK 19 /* IPV6 route response acknowledgment */
-
-struct aodv_ext {
- u_int8_t type; /* extension type */
- u_int8_t length; /* extension length */
-};
-
-struct aodv_hello {
- struct aodv_ext eh; /* extension header */
- u_int32_t interval; /* expect my next hello in
- * (n) ms */
-};
-
-#define AODV_EXT_HELLO 1
-
-#endif /* _AODV_H_ */
diff --git a/freebsd/contrib/tcpdump/appletalk.h b/freebsd/contrib/tcpdump/appletalk.h
index ff972f65..3fbcbce0 100644
--- a/freebsd/contrib/tcpdump/appletalk.h
+++ b/freebsd/contrib/tcpdump/appletalk.h
@@ -19,14 +19,12 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* AppleTalk protocol formats (courtesy Bill Croft of Stanford/SUMEX).
- *
- * @(#) $Header: /tcpdump/master/tcpdump/appletalk.h,v 1.16 2004-05-01 09:41:50 hannes Exp $ (LBL)
*/
struct LAP {
- u_int8_t dst;
- u_int8_t src;
- u_int8_t type;
+ uint8_t dst;
+ uint8_t src;
+ uint8_t type;
};
#define lapShortDDP 1 /* short DDP type */
#define lapDDP 2 /* DDP type */
@@ -35,22 +33,22 @@ struct LAP {
/* Datagram Delivery Protocol */
struct atDDP {
- u_int16_t length;
- u_int16_t checksum;
- u_int16_t dstNet;
- u_int16_t srcNet;
- u_int8_t dstNode;
- u_int8_t srcNode;
- u_int8_t dstSkt;
- u_int8_t srcSkt;
- u_int8_t type;
+ uint16_t length;
+ uint16_t checksum;
+ uint16_t dstNet;
+ uint16_t srcNet;
+ uint8_t dstNode;
+ uint8_t srcNode;
+ uint8_t dstSkt;
+ uint8_t srcSkt;
+ uint8_t type;
};
struct atShortDDP {
- u_int16_t length;
- u_int8_t dstSkt;
- u_int8_t srcSkt;
- u_int8_t type;
+ uint16_t length;
+ uint8_t dstSkt;
+ uint8_t srcSkt;
+ uint8_t type;
};
#define ddpMaxWKS 0x7F
@@ -74,10 +72,10 @@ struct atShortDDP {
/* AppleTalk Transaction Protocol */
struct atATP {
- u_int8_t control;
- u_int8_t bitmap;
- u_int16_t transID;
- int32_t userData;
+ uint8_t control;
+ uint8_t bitmap;
+ uint16_t transID;
+ int32_t userData;
};
#define atpReqCode 0x40
@@ -95,8 +93,8 @@ struct atATP {
/* AppleTalk Echo Protocol */
struct atEcho {
- u_int8_t echoFunction;
- u_int8_t *echoData;
+ uint8_t echoFunction;
+ uint8_t *echoData;
};
#define echoSkt 4 /* the echoer socket */
@@ -108,15 +106,15 @@ struct atEcho {
/* Name Binding Protocol */
struct atNBP {
- u_int8_t control;
- u_int8_t id;
+ uint8_t control;
+ uint8_t id;
};
struct atNBPtuple {
- u_int16_t net;
- u_int8_t node;
- u_int8_t skt;
- u_int8_t enumerator;
+ uint16_t net;
+ uint8_t node;
+ uint8_t skt;
+ uint8_t enumerator;
};
#define nbpBrRq 0x10
@@ -142,8 +140,8 @@ struct atNBPtuple {
/* Zone Information Protocol */
struct zipHeader {
- u_int8_t command;
- u_int8_t netcount;
+ uint8_t command;
+ uint8_t netcount;
};
#define zipHeaderSize 2
diff --git a/freebsd/contrib/tcpdump/arcnet.h b/freebsd/contrib/tcpdump/arcnet.h
deleted file mode 100644
index 3b609566..00000000
--- a/freebsd/contrib/tcpdump/arcnet.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (c) 1982, 1986, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * 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. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
- *
- * @(#) $Id: arcnet.h,v 1.3 2003-01-23 09:05:37 guy Exp $ (LBL)
- *
- * from: NetBSD: if_arc.h,v 1.13 1999/11/19 20:41:19 thorpej Exp
- */
-
-/*
- * Structure of a 2.5MB/s Arcnet header on the BSDs,
- * as given to interface code.
- */
-struct arc_header {
- u_int8_t arc_shost;
- u_int8_t arc_dhost;
- u_int8_t arc_type;
- /*
- * only present for newstyle encoding with LL fragmentation.
- * Don't use sizeof(anything), use ARC_HDR{,NEW}LEN instead.
- */
- u_int8_t arc_flag;
- u_int16_t arc_seqid;
-
- /*
- * only present in exception packets (arc_flag == 0xff)
- */
- u_int8_t arc_type2; /* same as arc_type */
- u_int8_t arc_flag2; /* real flag value */
- u_int16_t arc_seqid2; /* real seqid value */
-};
-
-#define ARC_HDRLEN 3
-#define ARC_HDRNEWLEN 6
-#define ARC_HDRNEWLEN_EXC 10
-
-/* RFC 1051 */
-#define ARCTYPE_IP_OLD 240 /* IP protocol */
-#define ARCTYPE_ARP_OLD 241 /* address resolution protocol */
-
-/* RFC 1201 */
-#define ARCTYPE_IP 212 /* IP protocol */
-#define ARCTYPE_ARP 213 /* address resolution protocol */
-#define ARCTYPE_REVARP 214 /* reverse addr resolution protocol */
-
-#define ARCTYPE_ATALK 221 /* Appletalk */
-#define ARCTYPE_BANIAN 247 /* Banyan Vines */
-#define ARCTYPE_IPX 250 /* Novell IPX */
-
-#define ARCTYPE_INET6 0xc4 /* IPng */
-#define ARCTYPE_DIAGNOSE 0x80 /* as per ANSI/ATA 878.1 */
-
-/*
- * Structure of a 2.5MB/s Arcnet header on Linux. Linux has
- * an extra "offset" field when given to interface code, and
- * never presents packets that look like exception frames.
- */
-struct arc_linux_header {
- u_int8_t arc_shost;
- u_int8_t arc_dhost;
- u_int16_t arc_offset;
- u_int8_t arc_type;
- /*
- * only present for newstyle encoding with LL fragmentation.
- * Don't use sizeof(anything), use ARC_LINUX_HDR{,NEW}LEN
- * instead.
- */
- u_int8_t arc_flag;
- u_int16_t arc_seqid;
-};
-
-#define ARC_LINUX_HDRLEN 5
-#define ARC_LINUX_HDRNEWLEN 8
diff --git a/freebsd/contrib/tcpdump/ascii_strcasecmp.c b/freebsd/contrib/tcpdump/ascii_strcasecmp.c
new file mode 100644
index 00000000..22134709
--- /dev/null
+++ b/freebsd/contrib/tcpdump/ascii_strcasecmp.c
@@ -0,0 +1,113 @@
+#include <machine/rtems-bsd-user-space.h>
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
+/*
+ * Copyright (c) 1987 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that this notice is preserved and that due credit is given
+ * to the University of California at Berkeley. The name of the University
+ * may not be used to endorse or promote products derived from this
+ * software without specific written prior permission. This software
+ * is provided ``as is'' without express or implied warranty.
+ */
+
+#include "ascii_strcasecmp.h"
+
+/*
+ * This array maps upper-case ASCII letters to their lower-case
+ * equivalents; all other byte values are mapped to themselves,
+ * so this is locale-independent and intended to be locale-independent,
+ * to avoid issues with, for example, "i" and "I" not being lower-case
+ * and upper-case versions of the same letter in Turkish, where
+ * there are separate "i with dot" and "i without dot" letters.
+ */
+static const unsigned char charmap[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+ 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
+ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
+ 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
+ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
+ 0x40, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
+ 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
+ 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
+ 0x78, 0x79, 0x7a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
+ 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
+ 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
+ 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
+ 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
+ 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
+ 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
+ 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
+ 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
+ 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
+ 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
+ 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
+ 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
+ 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
+ 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
+ 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
+ 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
+ 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
+ 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
+ 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
+ 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,
+};
+
+int
+ascii_strcasecmp(const char *s1, const char *s2)
+{
+ register const unsigned char *cm = charmap,
+ *us1 = (const unsigned char *)s1,
+ *us2 = (const unsigned char *)s2;
+
+ while (cm[*us1] == cm[*us2++])
+ if (*us1++ == '\0')
+ return(0);
+ return(cm[*us1] - cm[*--us2]);
+}
+
+int
+ascii_strncasecmp(const char *s1, const char *s2, register size_t n)
+{
+ register const unsigned char *cm = charmap,
+ *us1 = (const unsigned char *)s1,
+ *us2 = (const unsigned char *)s2;
+
+ for (;;) {
+ if (n == 0) {
+ /*
+ * We've run out of characters that we should
+ * compare, and they've all been equal; return
+ * 0, to indicate that the prefixes are the
+ * same.
+ */
+ return(0);
+ }
+ if (cm[*us1] != cm[*us2++]) {
+ /*
+ * We've found a mismatch.
+ */
+ break;
+ }
+ if (*us1++ == '\0') {
+ /*
+ * We've run out of characters *to* compare,
+ * and they've all been equal; return 0, to
+ * indicate that the strings are the same.
+ */
+ return(0);
+ }
+ n--;
+ }
+ return(cm[*us1] - cm[*--us2]);
+}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-ascii_strcasecmp-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/ipfc.h b/freebsd/contrib/tcpdump/ascii_strcasecmp.h
index 438d1156..7f8ddb9a 100644
--- a/freebsd/contrib/tcpdump/ipfc.h
+++ b/freebsd/contrib/tcpdump/ascii_strcasecmp.h
@@ -1,7 +1,10 @@
/*
- * Copyright (c) 1992, 1993, 1994, 1995, 1996
+ * Copyright (c) 1988-1997
* The Regents of the University of California. All rights reserved.
*
+ * Copyright (c) 1998-2012 Michael Richardson <mcr@tcpdump.org>
+ * The TCPDUMP project
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code distributions
* retain the above copyright notice and this paragraph in its entirety, (2)
@@ -17,13 +20,14 @@
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * @(#) $Header: /tcpdump/master/tcpdump/ipfc.h,v 1.4 2002-12-11 07:13:53 guy Exp $ (LBL)
*/
-struct ipfc_header {
- u_char ipfc_dhost[8];
- u_char ipfc_shost[8];
-};
+#ifndef netdissect_ascii_strcasecmp_h
+#define netdissect_ascii_strcasecmp_h
+
+#include <stddef.h>
+
+extern int ascii_strcasecmp(const char *, const char *);
+extern int ascii_strncasecmp(const char *, const char *, size_t);
-#define IPFC_HDRLEN 16
+#endif /* netdissect_ascii_strcasecmp_h */
diff --git a/freebsd/contrib/tcpdump/atm.h b/freebsd/contrib/tcpdump/atm.h
index 65ac5c17..8d1737ed 100644
--- a/freebsd/contrib/tcpdump/atm.h
+++ b/freebsd/contrib/tcpdump/atm.h
@@ -13,8 +13,6 @@
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * @(#) $Header: /tcpdump/master/tcpdump/atm.h,v 1.3 2006-02-08 01:43:00 hannes Exp $
*/
/*
diff --git a/freebsd/contrib/tcpdump/bootp.h b/freebsd/contrib/tcpdump/bootp.h
deleted file mode 100644
index b1b81dce..00000000
--- a/freebsd/contrib/tcpdump/bootp.h
+++ /dev/null
@@ -1,231 +0,0 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/bootp.h,v 1.19 2008-04-22 09:46:03 hannes Exp $ (LBL) */
-/*
- * Bootstrap Protocol (BOOTP). RFC951 and RFC1048.
- *
- * This file specifies the "implementation-independent" BOOTP protocol
- * information which is common to both client and server.
- *
- * Copyright 1988 by Carnegie Mellon.
- *
- * Permission to use, copy, modify, and distribute this program for any
- * purpose and without fee is hereby granted, provided that this copyright
- * and permission notice appear on all copies and supporting documentation,
- * the name of Carnegie Mellon not be used in advertising or publicity
- * pertaining to distribution of the program without specific prior
- * permission, and notice be given in supporting documentation that copying
- * and distribution is by permission of Carnegie Mellon and Stanford
- * University. Carnegie Mellon makes no representations about the
- * suitability of this software for any purpose. It is provided "as is"
- * without express or implied warranty.
- */
-
-
-struct bootp {
- u_int8_t bp_op; /* packet opcode type */
- u_int8_t bp_htype; /* hardware addr type */
- u_int8_t bp_hlen; /* hardware addr length */
- u_int8_t bp_hops; /* gateway hops */
- u_int32_t bp_xid; /* transaction ID */
- u_int16_t bp_secs; /* seconds since boot began */
- u_int16_t bp_flags; /* flags - see bootp_flag_values[]
- in print-bootp.c */
- struct in_addr bp_ciaddr; /* client IP address */
- struct in_addr bp_yiaddr; /* 'your' IP address */
- struct in_addr bp_siaddr; /* server IP address */
- struct in_addr bp_giaddr; /* gateway IP address */
- u_int8_t bp_chaddr[16]; /* client hardware address */
- u_int8_t bp_sname[64]; /* server host name */
- u_int8_t bp_file[128]; /* boot file name */
- u_int8_t bp_vend[64]; /* vendor-specific area */
-} UNALIGNED;
-
-/*
- * UDP port numbers, server and client.
- */
-#define IPPORT_BOOTPS 67
-#define IPPORT_BOOTPC 68
-
-#define BOOTPREPLY 2
-#define BOOTPREQUEST 1
-
-/*
- * Vendor magic cookie (v_magic) for CMU
- */
-#define VM_CMU "CMU"
-
-/*
- * Vendor magic cookie (v_magic) for RFC1048
- */
-#define VM_RFC1048 { 99, 130, 83, 99 }
-
-
-
-/*
- * RFC1048 tag values used to specify what information is being supplied in
- * the vendor field of the packet.
- */
-
-#define TAG_PAD ((u_int8_t) 0)
-#define TAG_SUBNET_MASK ((u_int8_t) 1)
-#define TAG_TIME_OFFSET ((u_int8_t) 2)
-#define TAG_GATEWAY ((u_int8_t) 3)
-#define TAG_TIME_SERVER ((u_int8_t) 4)
-#define TAG_NAME_SERVER ((u_int8_t) 5)
-#define TAG_DOMAIN_SERVER ((u_int8_t) 6)
-#define TAG_LOG_SERVER ((u_int8_t) 7)
-#define TAG_COOKIE_SERVER ((u_int8_t) 8)
-#define TAG_LPR_SERVER ((u_int8_t) 9)
-#define TAG_IMPRESS_SERVER ((u_int8_t) 10)
-#define TAG_RLP_SERVER ((u_int8_t) 11)
-#define TAG_HOSTNAME ((u_int8_t) 12)
-#define TAG_BOOTSIZE ((u_int8_t) 13)
-#define TAG_END ((u_int8_t) 255)
-/* RFC1497 tags */
-#define TAG_DUMPPATH ((u_int8_t) 14)
-#define TAG_DOMAINNAME ((u_int8_t) 15)
-#define TAG_SWAP_SERVER ((u_int8_t) 16)
-#define TAG_ROOTPATH ((u_int8_t) 17)
-#define TAG_EXTPATH ((u_int8_t) 18)
-/* RFC2132 */
-#define TAG_IP_FORWARD ((u_int8_t) 19)
-#define TAG_NL_SRCRT ((u_int8_t) 20)
-#define TAG_PFILTERS ((u_int8_t) 21)
-#define TAG_REASS_SIZE ((u_int8_t) 22)
-#define TAG_DEF_TTL ((u_int8_t) 23)
-#define TAG_MTU_TIMEOUT ((u_int8_t) 24)
-#define TAG_MTU_TABLE ((u_int8_t) 25)
-#define TAG_INT_MTU ((u_int8_t) 26)
-#define TAG_LOCAL_SUBNETS ((u_int8_t) 27)
-#define TAG_BROAD_ADDR ((u_int8_t) 28)
-#define TAG_DO_MASK_DISC ((u_int8_t) 29)
-#define TAG_SUPPLY_MASK ((u_int8_t) 30)
-#define TAG_DO_RDISC ((u_int8_t) 31)
-#define TAG_RTR_SOL_ADDR ((u_int8_t) 32)
-#define TAG_STATIC_ROUTE ((u_int8_t) 33)
-#define TAG_USE_TRAILERS ((u_int8_t) 34)
-#define TAG_ARP_TIMEOUT ((u_int8_t) 35)
-#define TAG_ETH_ENCAP ((u_int8_t) 36)
-#define TAG_TCP_TTL ((u_int8_t) 37)
-#define TAG_TCP_KEEPALIVE ((u_int8_t) 38)
-#define TAG_KEEPALIVE_GO ((u_int8_t) 39)
-#define TAG_NIS_DOMAIN ((u_int8_t) 40)
-#define TAG_NIS_SERVERS ((u_int8_t) 41)
-#define TAG_NTP_SERVERS ((u_int8_t) 42)
-#define TAG_VENDOR_OPTS ((u_int8_t) 43)
-#define TAG_NETBIOS_NS ((u_int8_t) 44)
-#define TAG_NETBIOS_DDS ((u_int8_t) 45)
-#define TAG_NETBIOS_NODE ((u_int8_t) 46)
-#define TAG_NETBIOS_SCOPE ((u_int8_t) 47)
-#define TAG_XWIN_FS ((u_int8_t) 48)
-#define TAG_XWIN_DM ((u_int8_t) 49)
-#define TAG_NIS_P_DOMAIN ((u_int8_t) 64)
-#define TAG_NIS_P_SERVERS ((u_int8_t) 65)
-#define TAG_MOBILE_HOME ((u_int8_t) 68)
-#define TAG_SMPT_SERVER ((u_int8_t) 69)
-#define TAG_POP3_SERVER ((u_int8_t) 70)
-#define TAG_NNTP_SERVER ((u_int8_t) 71)
-#define TAG_WWW_SERVER ((u_int8_t) 72)
-#define TAG_FINGER_SERVER ((u_int8_t) 73)
-#define TAG_IRC_SERVER ((u_int8_t) 74)
-#define TAG_STREETTALK_SRVR ((u_int8_t) 75)
-#define TAG_STREETTALK_STDA ((u_int8_t) 76)
-/* DHCP options */
-#define TAG_REQUESTED_IP ((u_int8_t) 50)
-#define TAG_IP_LEASE ((u_int8_t) 51)
-#define TAG_OPT_OVERLOAD ((u_int8_t) 52)
-#define TAG_TFTP_SERVER ((u_int8_t) 66)
-#define TAG_BOOTFILENAME ((u_int8_t) 67)
-#define TAG_DHCP_MESSAGE ((u_int8_t) 53)
-#define TAG_SERVER_ID ((u_int8_t) 54)
-#define TAG_PARM_REQUEST ((u_int8_t) 55)
-#define TAG_MESSAGE ((u_int8_t) 56)
-#define TAG_MAX_MSG_SIZE ((u_int8_t) 57)
-#define TAG_RENEWAL_TIME ((u_int8_t) 58)
-#define TAG_REBIND_TIME ((u_int8_t) 59)
-#define TAG_VENDOR_CLASS ((u_int8_t) 60)
-#define TAG_CLIENT_ID ((u_int8_t) 61)
-/* RFC 2241 */
-#define TAG_NDS_SERVERS ((u_int8_t) 85)
-#define TAG_NDS_TREE_NAME ((u_int8_t) 86)
-#define TAG_NDS_CONTEXT ((u_int8_t) 87)
-/* RFC 2242 */
-#define TAG_NDS_IPDOMAIN ((u_int8_t) 62)
-#define TAG_NDS_IPINFO ((u_int8_t) 63)
-/* RFC 2485 */
-#define TAG_OPEN_GROUP_UAP ((u_int8_t) 98)
-/* RFC 2563 */
-#define TAG_DISABLE_AUTOCONF ((u_int8_t) 116)
-/* RFC 2610 */
-#define TAG_SLP_DA ((u_int8_t) 78)
-#define TAG_SLP_SCOPE ((u_int8_t) 79)
-/* RFC 2937 */
-#define TAG_NS_SEARCH ((u_int8_t) 117)
-/* RFC 3011 */
-#define TAG_IP4_SUBNET_SELECT ((u_int8_t) 118)
-/* RFC 3442 */
-#define TAG_CLASSLESS_STATIC_RT ((u_int8_t) 121)
-#define TAG_CLASSLESS_STA_RT_MS ((u_int8_t) 249)
-/* ftp://ftp.isi.edu/.../assignments/bootp-dhcp-extensions */
-#define TAG_USER_CLASS ((u_int8_t) 77)
-#define TAG_SLP_NAMING_AUTH ((u_int8_t) 80)
-#define TAG_CLIENT_FQDN ((u_int8_t) 81)
-#define TAG_AGENT_CIRCUIT ((u_int8_t) 82)
-#define TAG_AGENT_REMOTE ((u_int8_t) 83)
-#define TAG_AGENT_MASK ((u_int8_t) 84)
-#define TAG_TZ_STRING ((u_int8_t) 88)
-#define TAG_FQDN_OPTION ((u_int8_t) 89)
-#define TAG_AUTH ((u_int8_t) 90)
-#define TAG_VINES_SERVERS ((u_int8_t) 91)
-#define TAG_SERVER_RANK ((u_int8_t) 92)
-#define TAG_CLIENT_ARCH ((u_int8_t) 93)
-#define TAG_CLIENT_NDI ((u_int8_t) 94)
-#define TAG_CLIENT_GUID ((u_int8_t) 97)
-#define TAG_LDAP_URL ((u_int8_t) 95)
-#define TAG_6OVER4 ((u_int8_t) 96)
-#define TAG_PRINTER_NAME ((u_int8_t) 100)
-#define TAG_MDHCP_SERVER ((u_int8_t) 101)
-#define TAG_IPX_COMPAT ((u_int8_t) 110)
-#define TAG_NETINFO_PARENT ((u_int8_t) 112)
-#define TAG_NETINFO_PARENT_TAG ((u_int8_t) 113)
-#define TAG_URL ((u_int8_t) 114)
-#define TAG_FAILOVER ((u_int8_t) 115)
-#define TAG_EXTENDED_REQUEST ((u_int8_t) 126)
-#define TAG_EXTENDED_OPTION ((u_int8_t) 127)
-
-
-/* DHCP Message types (values for TAG_DHCP_MESSAGE option) */
-#define DHCPDISCOVER 1
-#define DHCPOFFER 2
-#define DHCPREQUEST 3
-#define DHCPDECLINE 4
-#define DHCPACK 5
-#define DHCPNAK 6
-#define DHCPRELEASE 7
-#define DHCPINFORM 8
-
-
-/*
- * "vendor" data permitted for CMU bootp clients.
- */
-
-struct cmu_vend {
- u_int8_t v_magic[4]; /* magic number */
- u_int32_t v_flags; /* flags/opcodes, etc. */
- struct in_addr v_smask; /* Subnet mask */
- struct in_addr v_dgate; /* Default gateway */
- struct in_addr v_dns1, v_dns2; /* Domain name servers */
- struct in_addr v_ins1, v_ins2; /* IEN-116 name servers */
- struct in_addr v_ts1, v_ts2; /* Time servers */
- u_int8_t v_unused[24]; /* currently unused */
-} UNALIGNED;
-
-
-/* v_flags values */
-#define VF_SMASK 1 /* Subnet mask field contains valid data */
-
-/* RFC 4702 DHCP Client FQDN Option */
-
-#define CLIENT_FQDN_FLAGS_S 0x01
-#define CLIENT_FQDN_FLAGS_O 0x02
-#define CLIENT_FQDN_FLAGS_E 0x04
-#define CLIENT_FQDN_FLAGS_N 0x08
diff --git a/freebsd/contrib/tcpdump/bpf_dump.c b/freebsd/contrib/tcpdump/bpf_dump.c
index 841f8d77..57fca1f2 100644
--- a/freebsd/contrib/tcpdump/bpf_dump.c
+++ b/freebsd/contrib/tcpdump/bpf_dump.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1992, 1993, 1994, 1995, 1996
* The Regents of the University of California. All rights reserved.
@@ -20,21 +23,16 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/bpf_dump.c,v 1.17 2008-02-14 20:53:49 guy Exp $ (LBL)";
-#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include <pcap.h>
#include <stdio.h>
-#include "interface.h"
+#include "netdissect.h"
void
bpf_dump(const struct bpf_program *p, int option)
@@ -66,3 +64,6 @@ bpf_dump(const struct bpf_program *p, int option)
puts(bpf_image(insn, i));
}
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-bpf_dump-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/chdlc.h b/freebsd/contrib/tcpdump/chdlc.h
index d1172633..d5a2d915 100644
--- a/freebsd/contrib/tcpdump/chdlc.h
+++ b/freebsd/contrib/tcpdump/chdlc.h
@@ -1,4 +1,3 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/chdlc.h,v 1.1 2000-09-18 05:11:43 guy Exp $ (LBL) */
/*
* Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
diff --git a/freebsd/contrib/tcpdump/checksum.c b/freebsd/contrib/tcpdump/checksum.c
index a9077303..9a3889c1 100644
--- a/freebsd/contrib/tcpdump/checksum.c
+++ b/freebsd/contrib/tcpdump/checksum.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1998-2006 The TCPDUMP project
*
@@ -19,23 +22,18 @@
* Original code by Hannes Gredler (hannes@juniper.net)
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/checksum.c,v 1.4 2006-09-25 09:23:32 hannes Exp $";
-#endif
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
-#include "interface.h"
+#include "netdissect.h"
/*
* CRC-10 table generated using the following Python snippet:
@@ -57,7 +55,7 @@ for i in range(len(crc_table)/8):
sys.stdout.write("\n")
*/
-static const u_int16_t crc10_table[256] =
+static const uint16_t crc10_table[256] =
{
0x0000, 0x0233, 0x0255, 0x0066, 0x0299, 0x00aa, 0x00cc, 0x02ff,
0x0301, 0x0132, 0x0154, 0x0367, 0x0198, 0x03ab, 0x03cd, 0x01fe,
@@ -95,12 +93,12 @@ static const u_int16_t crc10_table[256] =
static void
init_crc10_table(void)
-{
+{
#define CRC10_POLYNOMIAL 0x633
register int i, j;
- register u_int16_t accum;
- u_int16_t verify_crc10_table[256];
-
+ register uint16_t accum;
+ uint16_t verify_crc10_table[256];
+
for ( i = 0; i < 256; i++ )
{
accum = ((unsigned short) i << 2);
@@ -116,8 +114,8 @@ init_crc10_table(void)
#undef CRC10_POLYNOMIAL
}
-u_int16_t
-verify_crc10_cksum(u_int16_t accum, const u_char *p, int length)
+uint16_t
+verify_crc10_cksum(uint16_t accum, const u_char *p, int length)
{
register int i;
@@ -142,40 +140,40 @@ init_checksum(void) {
* Creates the OSI Fletcher checksum. See 8473-1, Appendix C, section C.3.
* The checksum field of the passed PDU does not need to be reset to zero.
*/
-u_int16_t
-create_osi_cksum (const u_int8_t *pptr, int checksum_offset, int length)
+uint16_t
+create_osi_cksum (const uint8_t *pptr, int checksum_offset, int length)
{
int x;
int y;
- u_int32_t mul;
- u_int32_t c0;
- u_int32_t c1;
- u_int16_t checksum;
- int index;
+ uint32_t mul;
+ uint32_t c0;
+ uint32_t c1;
+ uint16_t checksum;
+ int idx;
c0 = 0;
c1 = 0;
- for (index = 0; index < length; index++) {
+ for (idx = 0; idx < length; idx++) {
/*
* Ignore the contents of the checksum field.
*/
- if (index == checksum_offset ||
- index == checksum_offset+1) {
+ if (idx == checksum_offset ||
+ idx == checksum_offset+1) {
c1 += c0;
pptr++;
} else {
c0 = c0 + *(pptr++);
c1 += c0;
- }
+ }
}
c0 = c0 % 255;
c1 = c1 % 255;
mul = (length - checksum_offset)*(c0);
-
+
x = mul - c0 - c1;
y = c1 - mul - 1;
@@ -191,6 +189,9 @@ create_osi_cksum (const u_int8_t *pptr, int checksum_offset, int length)
y &= 0x00FF;
checksum = ((x << 8) | y);
-
+
return checksum;
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-checksum-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/cpack.c b/freebsd/contrib/tcpdump/cpack.c
index e34fc1dc..fecbd1c3 100644
--- a/freebsd/contrib/tcpdump/cpack.c
+++ b/freebsd/contrib/tcpdump/cpack.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*-
* Copyright (c) 2003, 2004 David Young. All rights reserved.
*
@@ -35,13 +38,13 @@
#include <stdlib.h>
#include <string.h>
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include "cpack.h"
#include "extract.h"
-u_int8_t *
-cpack_next_boundary(u_int8_t *buf, u_int8_t *p, size_t alignment)
+const uint8_t *
+cpack_next_boundary(const uint8_t *buf, const uint8_t *p, size_t alignment)
{
size_t misalignment = (size_t)(p - buf) % alignment;
@@ -55,10 +58,10 @@ cpack_next_boundary(u_int8_t *buf, u_int8_t *p, size_t alignment)
* wordsize bytes remain in the buffer after the boundary. Otherwise,
* return a pointer to the boundary.
*/
-u_int8_t *
+const uint8_t *
cpack_align_and_reserve(struct cpack_state *cs, size_t wordsize)
{
- u_int8_t *next;
+ const uint8_t *next;
/* Ensure alignment. */
next = cpack_next_boundary(cs->c_buf, cs->c_next, wordsize);
@@ -70,8 +73,19 @@ cpack_align_and_reserve(struct cpack_state *cs, size_t wordsize)
return next;
}
+/* Advance by N bytes without returning them. */
+int
+cpack_advance(struct cpack_state *cs, const size_t toskip)
+{
+ /* No space left? */
+ if (cs->c_next - cs->c_buf + toskip > cs->c_len)
+ return -1;
+ cs->c_next += toskip;
+ return 0;
+}
+
int
-cpack_init(struct cpack_state *cs, u_int8_t *buf, size_t buflen)
+cpack_init(struct cpack_state *cs, const uint8_t *buf, size_t buflen)
{
memset(cs, 0, sizeof(*cs));
@@ -84,55 +98,55 @@ cpack_init(struct cpack_state *cs, u_int8_t *buf, size_t buflen)
/* Unpack a 64-bit unsigned integer. */
int
-cpack_uint64(struct cpack_state *cs, u_int64_t *u)
+cpack_uint64(struct cpack_state *cs, uint64_t *u)
{
- u_int8_t *next;
+ const uint8_t *next;
if ((next = cpack_align_and_reserve(cs, sizeof(*u))) == NULL)
return -1;
*u = EXTRACT_LE_64BITS(next);
- /* Move pointer past the u_int64_t. */
+ /* Move pointer past the uint64_t. */
cs->c_next = next + sizeof(*u);
return 0;
}
/* Unpack a 32-bit unsigned integer. */
int
-cpack_uint32(struct cpack_state *cs, u_int32_t *u)
+cpack_uint32(struct cpack_state *cs, uint32_t *u)
{
- u_int8_t *next;
+ const uint8_t *next;
if ((next = cpack_align_and_reserve(cs, sizeof(*u))) == NULL)
return -1;
*u = EXTRACT_LE_32BITS(next);
- /* Move pointer past the u_int32_t. */
+ /* Move pointer past the uint32_t. */
cs->c_next = next + sizeof(*u);
return 0;
}
/* Unpack a 16-bit unsigned integer. */
int
-cpack_uint16(struct cpack_state *cs, u_int16_t *u)
+cpack_uint16(struct cpack_state *cs, uint16_t *u)
{
- u_int8_t *next;
+ const uint8_t *next;
if ((next = cpack_align_and_reserve(cs, sizeof(*u))) == NULL)
return -1;
*u = EXTRACT_LE_16BITS(next);
- /* Move pointer past the u_int16_t. */
+ /* Move pointer past the uint16_t. */
cs->c_next = next + sizeof(*u);
return 0;
}
/* Unpack an 8-bit unsigned integer. */
int
-cpack_uint8(struct cpack_state *cs, u_int8_t *u)
+cpack_uint8(struct cpack_state *cs, uint8_t *u)
{
/* No space left? */
if ((size_t)(cs->c_next - cs->c_buf) >= cs->c_len)
@@ -140,7 +154,10 @@ cpack_uint8(struct cpack_state *cs, u_int8_t *u)
*u = *cs->c_next;
- /* Move pointer past the u_int8_t. */
+ /* Move pointer past the uint8_t. */
cs->c_next++;
return 0;
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-cpack-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/cpack.h b/freebsd/contrib/tcpdump/cpack.h
index 74f97960..3072e0c3 100644
--- a/freebsd/contrib/tcpdump/cpack.h
+++ b/freebsd/contrib/tcpdump/cpack.h
@@ -31,24 +31,26 @@
#define _CPACK_H
struct cpack_state {
- u_int8_t *c_buf;
- u_int8_t *c_next;
+ const uint8_t *c_buf;
+ const uint8_t *c_next;
size_t c_len;
};
-int cpack_init(struct cpack_state *, u_int8_t *, size_t);
+int cpack_init(struct cpack_state *, const uint8_t *, size_t);
-int cpack_uint8(struct cpack_state *, u_int8_t *);
-int cpack_uint16(struct cpack_state *, u_int16_t *);
-int cpack_uint32(struct cpack_state *, u_int32_t *);
-int cpack_uint64(struct cpack_state *, u_int64_t *);
+int cpack_uint8(struct cpack_state *, uint8_t *);
+int cpack_uint16(struct cpack_state *, uint16_t *);
+int cpack_uint32(struct cpack_state *, uint32_t *);
+int cpack_uint64(struct cpack_state *, uint64_t *);
-u_int8_t *cpack_next_boundary(u_int8_t *buf, u_int8_t *p, size_t alignment);
-u_int8_t *cpack_align_and_reserve(struct cpack_state *cs, size_t wordsize);
+const uint8_t *cpack_next_boundary(const uint8_t *buf, const uint8_t *p, size_t alignment);
+const uint8_t *cpack_align_and_reserve(struct cpack_state *cs, size_t wordsize);
-#define cpack_int8(__s, __p) cpack_uint8((__s), (u_int8_t*)(__p))
-#define cpack_int16(__s, __p) cpack_uint16((__s), (u_int16_t*)(__p))
-#define cpack_int32(__s, __p) cpack_uint32((__s), (u_int32_t*)(__p))
-#define cpack_int64(__s, __p) cpack_uint64((__s), (u_int64_t*)(__p))
+#define cpack_int8(__s, __p) cpack_uint8((__s), (uint8_t*)(__p))
+#define cpack_int16(__s, __p) cpack_uint16((__s), (uint16_t*)(__p))
+#define cpack_int32(__s, __p) cpack_uint32((__s), (uint32_t*)(__p))
+#define cpack_int64(__s, __p) cpack_uint64((__s), (uint64_t*)(__p))
+
+extern int cpack_advance(struct cpack_state *, const size_t);
#endif /* _CPACK_H */
diff --git a/freebsd/contrib/tcpdump/dccp.h b/freebsd/contrib/tcpdump/dccp.h
deleted file mode 100644
index 5c66e23c..00000000
--- a/freebsd/contrib/tcpdump/dccp.h
+++ /dev/null
@@ -1,139 +0,0 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/dccp.h,v 1.5 2006-11-02 09:05:23 hannes Exp $ (LBL) */
-/*
- * Copyright (C) Arnaldo Carvalho de Melo 2004
- * Copyright (C) Ian McDonald 2005 <iam4@cs.waikato.ac.nz>
- * Copyright (C) Yoshifumi Nishida 2005
- *
- * This software may be distributed either under the terms of the
- * BSD-style license that accompanies tcpdump or the GNU GPL version 2
- */
-
-#ifndef __DCCP_HDR__
-#define __DCCP_HDR__
-
-/**
- * struct dccp_hdr - generic part of DCCP packet header
- *
- * @dccph_sport - Relevant port on the endpoint that sent this packet
- * @dccph_dport - Relevant port on the other endpoint
- * @dccph_doff - Data Offset from the start of the DCCP header, in 32-bit words
- * @dccph_ccval - Used by the HC-Sender CCID
- * @dccph_cscov - Parts of the packet that are covered by the Checksum field
- * @dccph_checksum - Internet checksum, depends on dccph_cscov
- * @dccph_x - 0 = 24 bit sequence number, 1 = 48
- * @dccph_type - packet type, see DCCP_PKT_ prefixed macros
- * @dccph_seq - sequence number high or low order 24 bits, depends on dccph_x
- */
-struct dccp_hdr {
- u_int16_t dccph_sport,
- dccph_dport;
- u_int8_t dccph_doff;
- u_int8_t dccph_ccval_cscov;
- u_int16_t dccph_checksum;
- union {
- u_int8_t dccph_xtr;
- u_int32_t dccph_seq;
- } dccph_xtrs;
-};
-
-#define DCCPH_CCVAL(dh) (((dh)->dccph_ccval_cscov >> 4) & 0xF)
-#define DCCPH_CSCOV(dh) (((dh)->dccph_ccval_cscov) & 0xF)
-
-#define DCCPH_X(dh) ((dh)->dccph_xtrs.dccph_xtr & 1)
-#define DCCPH_TYPE(dh) (((dh)->dccph_xtrs.dccph_xtr >> 1) & 0xF)
-#define DCCPH_SEQ(dh) (((dh)->dccph_xtrs.dccph_seq) >> 8)
-
-/**
- * struct dccp_hdr_ext - the low bits of a 48 bit seq packet
- *
- * @dccph_seq_low - low 24 bits of a 48 bit seq packet
- */
-struct dccp_hdr_ext {
- u_int32_t dccph_seq_low;
-};
-
-/**
- * struct dccp_hdr_request - Conection initiation request header
- *
- * @dccph_req_service - Service to which the client app wants to connect
- */
-struct dccp_hdr_request {
- u_int32_t dccph_req_service;
-};
-
-/**
- * struct dccp_hdr_ack_bits - acknowledgment bits common to most packets
- *
- * @dccph_resp_ack_nr_high - 48 bit ack number high order bits, contains GSR
- * @dccph_resp_ack_nr_low - 48 bit ack number low order bits, contains GSR
- */
-struct dccp_hdr_ack_bits {
- u_int32_t dccph_ra;
- u_int32_t dccph_ack_nr_low;
-};
-
-#define DCCPH_ACK(dh_ack) ((dh_ack)->dccph_ra >> 8)
-
-/**
- * struct dccp_hdr_response - Conection initiation response header
- *
- * @dccph_resp_ack_nr_high - 48 bit ack number high order bits, contains GSR
- * @dccph_resp_ack_nr_low - 48 bit ack number low order bits, contains GSR
- * @dccph_resp_service - Echoes the Service Code on a received DCCP-Request
- */
-struct dccp_hdr_response {
- struct dccp_hdr_ack_bits dccph_resp_ack;
- u_int32_t dccph_resp_service;
-};
-
-#if 0
-static inline struct dccp_hdr_data *dccp_hdr_data(struct dccp_hdr *hdrg)
-{
- const int ext = DCCPH_X(hdrg) ? sizeof(struct dccp_hdr_ext) : 0;
-
- return (struct dccp_hdr_data *)(((u_char *)hdrg) + sizeof(hdrg) + ext);
-}
-#endif
-
-/**
- * struct dccp_hdr_reset - Unconditionally shut down a connection
- *
- * @dccph_reset_service - Echoes the Service Code on a received DCCP-Request
- */
-struct dccp_hdr_reset {
- struct dccp_hdr_ack_bits dccph_reset_ack;
- u_int8_t dccph_reset_code,
- dccph_reset_data[3];
-};
-
-enum dccp_pkt_type {
- DCCP_PKT_REQUEST = 0,
- DCCP_PKT_RESPONSE,
- DCCP_PKT_DATA,
- DCCP_PKT_ACK,
- DCCP_PKT_DATAACK,
- DCCP_PKT_CLOSEREQ,
- DCCP_PKT_CLOSE,
- DCCP_PKT_RESET,
- DCCP_PKT_SYNC,
- DCCP_PKT_SYNCACK,
- DCCP_PKT_INVALID
-};
-
-enum dccp_reset_codes {
- DCCP_RESET_CODE_UNSPECIFIED = 0,
- DCCP_RESET_CODE_CLOSED,
- DCCP_RESET_CODE_ABORTED,
- DCCP_RESET_CODE_NO_CONNECTION,
- DCCP_RESET_CODE_PACKET_ERROR,
- DCCP_RESET_CODE_OPTION_ERROR,
- DCCP_RESET_CODE_MANDATORY_ERROR,
- DCCP_RESET_CODE_CONNECTION_REFUSED,
- DCCP_RESET_CODE_BAD_SERVICE_CODE,
- DCCP_RESET_CODE_TOO_BUSY,
- DCCP_RESET_CODE_BAD_INIT_COOKIE,
- DCCP_RESET_CODE_AGGRESSION_PENALTY,
- __DCCP_RESET_CODE_LAST
-};
-
-#endif /* __DCCP_HDR__ */
diff --git a/freebsd/contrib/tcpdump/decnet.h b/freebsd/contrib/tcpdump/decnet.h
deleted file mode 100644
index d25d157d..00000000
--- a/freebsd/contrib/tcpdump/decnet.h
+++ /dev/null
@@ -1,461 +0,0 @@
-/*
- * Copyright (c) 1992, 1994, 1996
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that: (1) source code distributions
- * retain the above copyright notice and this paragraph in its entirety, (2)
- * distributions including binary code include the above copyright notice and
- * this paragraph in its entirety in the documentation or other materials
- * provided with the distribution, and (3) all advertising materials mentioning
- * features or use of this software display the following acknowledgement:
- * ``This product includes software developed by the University of California,
- * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
- * the University 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 ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * @(#) $Header: /tcpdump/master/tcpdump/decnet.h,v 1.11 2002-12-11 07:13:50 guy Exp $ (LBL)
- */
-
-#ifndef WIN32
-typedef u_int8_t byte[1]; /* single byte field */
-#else
-/*
- * the keyword 'byte' generates conflicts in Windows
- */
-typedef unsigned char Byte[1]; /* single byte field */
-#define byte Byte
-#endif /* WIN32 */
-typedef u_int8_t word[2]; /* 2 byte field */
-typedef u_int8_t longword[4]; /* 4 bytes field */
-
-/*
- * Definitions for DECNET Phase IV protocol headers
- */
-union etheraddress {
- u_int8_t dne_addr[6]; /* full ethernet address */
- struct {
- u_int8_t dne_hiord[4]; /* DECnet HIORD prefix */
- u_int8_t dne_nodeaddr[2]; /* DECnet node address */
- } dne_remote;
-};
-
-typedef union etheraddress etheraddr; /* Ethernet address */
-
-#define HIORD 0x000400aa /* high 32-bits of address (swapped) */
-
-#define AREAMASK 0176000 /* mask for area field */
-#define AREASHIFT 10 /* bit-offset for area field */
-#define NODEMASK 01777 /* mask for node address field */
-
-#define DN_MAXADDL 20 /* max size of DECnet address */
-struct dn_naddr {
- u_int16_t a_len; /* length of address */
- u_int8_t a_addr[DN_MAXADDL]; /* address as bytes */
-};
-
-/*
- * Define long and short header formats.
- */
-struct shorthdr
- {
- byte sh_flags; /* route flags */
- word sh_dst; /* destination node address */
- word sh_src; /* source node address */
- byte sh_visits; /* visit count */
- };
-
-struct longhdr
- {
- byte lg_flags; /* route flags */
- byte lg_darea; /* destination area (reserved) */
- byte lg_dsarea; /* destination subarea (reserved) */
- etheraddr lg_dst; /* destination id */
- byte lg_sarea; /* source area (reserved) */
- byte lg_ssarea; /* source subarea (reserved) */
- etheraddr lg_src; /* source id */
- byte lg_nextl2; /* next level 2 router (reserved) */
- byte lg_visits; /* visit count */
- byte lg_service; /* service class (reserved) */
- byte lg_pt; /* protocol type (reserved) */
- };
-
-union routehdr
- {
- struct shorthdr rh_short; /* short route header */
- struct longhdr rh_long; /* long route header */
- };
-
-/*
- * Define the values of various fields in the protocol messages.
- *
- * 1. Data packet formats.
- */
-#define RMF_MASK 7 /* mask for message type */
-#define RMF_SHORT 2 /* short message format */
-#define RMF_LONG 6 /* long message format */
-#ifndef RMF_RQR
-#define RMF_RQR 010 /* request return to sender */
-#define RMF_RTS 020 /* returning to sender */
-#define RMF_IE 040 /* intra-ethernet packet */
-#endif /* RMR_RQR */
-#define RMF_FVER 0100 /* future version flag */
-#define RMF_PAD 0200 /* pad field */
-#define RMF_PADMASK 0177 /* pad field mask */
-
-#define VIS_MASK 077 /* visit field mask */
-
-/*
- * 2. Control packet formats.
- */
-#define RMF_CTLMASK 017 /* mask for message type */
-#define RMF_CTLMSG 01 /* control message indicator */
-#define RMF_INIT 01 /* initialization message */
-#define RMF_VER 03 /* verification message */
-#define RMF_TEST 05 /* hello and test message */
-#define RMF_L1ROUT 07 /* level 1 routing message */
-#define RMF_L2ROUT 011 /* level 2 routing message */
-#define RMF_RHELLO 013 /* router hello message */
-#define RMF_EHELLO 015 /* endnode hello message */
-
-#define TI_L2ROUT 01 /* level 2 router */
-#define TI_L1ROUT 02 /* level 1 router */
-#define TI_ENDNODE 03 /* endnode */
-#define TI_VERIF 04 /* verification required */
-#define TI_BLOCK 010 /* blocking requested */
-
-#define VE_VERS 2 /* version number (2) */
-#define VE_ECO 0 /* ECO number */
-#define VE_UECO 0 /* user ECO number (0) */
-
-#define P3_VERS 1 /* phase III version number (1) */
-#define P3_ECO 3 /* ECO number (3) */
-#define P3_UECO 0 /* user ECO number (0) */
-
-#define II_L2ROUT 01 /* level 2 router */
-#define II_L1ROUT 02 /* level 1 router */
-#define II_ENDNODE 03 /* endnode */
-#define II_VERIF 04 /* verification required */
-#define II_NOMCAST 040 /* no multicast traffic accepted */
-#define II_BLOCK 0100 /* blocking requested */
-#define II_TYPEMASK 03 /* mask for node type */
-
-#define TESTDATA 0252 /* test data bytes */
-#define TESTLEN 1 /* length of transmitted test data */
-
-/*
- * Define control message formats.
- */
-struct initmsgIII /* phase III initialization message */
- {
- byte inIII_flags; /* route flags */
- word inIII_src; /* source node address */
- byte inIII_info; /* routing layer information */
- word inIII_blksize; /* maximum data link block size */
- byte inIII_vers; /* version number */
- byte inIII_eco; /* ECO number */
- byte inIII_ueco; /* user ECO number */
- byte inIII_rsvd; /* reserved image field */
- };
-
-struct initmsg /* initialization message */
- {
- byte in_flags; /* route flags */
- word in_src; /* source node address */
- byte in_info; /* routing layer information */
- word in_blksize; /* maximum data link block size */
- byte in_vers; /* version number */
- byte in_eco; /* ECO number */
- byte in_ueco; /* user ECO number */
- word in_hello; /* hello timer */
- byte in_rsvd; /* reserved image field */
- };
-
-struct verifmsg /* verification message */
- {
- byte ve_flags; /* route flags */
- word ve_src; /* source node address */
- byte ve_fcnval; /* function value image field */
- };
-
-struct testmsg /* hello and test message */
- {
- byte te_flags; /* route flags */
- word te_src; /* source node address */
- byte te_data; /* test data image field */
- };
-
-struct l1rout /* level 1 routing message */
- {
- byte r1_flags; /* route flags */
- word r1_src; /* source node address */
- byte r1_rsvd; /* reserved field */
- };
-
-struct l2rout /* level 2 routing message */
- {
- byte r2_flags; /* route flags */
- word r2_src; /* source node address */
- byte r2_rsvd; /* reserved field */
- };
-
-struct rhellomsg /* router hello message */
- {
- byte rh_flags; /* route flags */
- byte rh_vers; /* version number */
- byte rh_eco; /* ECO number */
- byte rh_ueco; /* user ECO number */
- etheraddr rh_src; /* source id */
- byte rh_info; /* routing layer information */
- word rh_blksize; /* maximum data link block size */
- byte rh_priority; /* router's priority */
- byte rh_area; /* reserved */
- word rh_hello; /* hello timer */
- byte rh_mpd; /* reserved */
- };
-
-struct ehellomsg /* endnode hello message */
- {
- byte eh_flags; /* route flags */
- byte eh_vers; /* version number */
- byte eh_eco; /* ECO number */
- byte eh_ueco; /* user ECO number */
- etheraddr eh_src; /* source id */
- byte eh_info; /* routing layer information */
- word eh_blksize; /* maximum data link block size */
- byte eh_area; /* area (reserved) */
- byte eh_seed[8]; /* verification seed */
- etheraddr eh_router; /* designated router */
- word eh_hello; /* hello timer */
- byte eh_mpd; /* (reserved) */
- byte eh_data; /* test data image field */
- };
-
-union controlmsg
- {
- struct initmsg cm_init; /* initialization message */
- struct verifmsg cm_ver; /* verification message */
- struct testmsg cm_test; /* hello and test message */
- struct l1rout cm_l1rou; /* level 1 routing message */
- struct l2rout cm_l2rout; /* level 2 routing message */
- struct rhellomsg cm_rhello; /* router hello message */
- struct ehellomsg cm_ehello; /* endnode hello message */
- };
-
-/* Macros for decoding routing-info fields */
-#define RI_COST(x) ((x)&0777)
-#define RI_HOPS(x) (((x)>>10)&037)
-
-/*
- * NSP protocol fields and values.
- */
-
-#define NSP_TYPEMASK 014 /* mask to isolate type code */
-#define NSP_SUBMASK 0160 /* mask to isolate subtype code */
-#define NSP_SUBSHFT 4 /* shift to move subtype code */
-
-#define MFT_DATA 0 /* data message */
-#define MFT_ACK 04 /* acknowledgement message */
-#define MFT_CTL 010 /* control message */
-
-#define MFS_ILS 020 /* data or I/LS indicator */
-#define MFS_BOM 040 /* beginning of message (data) */
-#define MFS_MOM 0 /* middle of message (data) */
-#define MFS_EOM 0100 /* end of message (data) */
-#define MFS_INT 040 /* interrupt message */
-
-#define MFS_DACK 0 /* data acknowledgement */
-#define MFS_IACK 020 /* I/LS acknowledgement */
-#define MFS_CACK 040 /* connect acknowledgement */
-
-#define MFS_NOP 0 /* no operation */
-#define MFS_CI 020 /* connect initiate */
-#define MFS_CC 040 /* connect confirm */
-#define MFS_DI 060 /* disconnect initiate */
-#define MFS_DC 0100 /* disconnect confirm */
-#define MFS_RCI 0140 /* retransmitted connect initiate */
-
-#define SGQ_ACK 0100000 /* ack */
-#define SGQ_NAK 0110000 /* negative ack */
-#define SGQ_OACK 0120000 /* other channel ack */
-#define SGQ_ONAK 0130000 /* other channel negative ack */
-#define SGQ_MASK 07777 /* mask to isolate seq # */
-#define SGQ_OTHER 020000 /* other channel qualifier */
-#define SGQ_DELAY 010000 /* ack delay flag */
-
-#define SGQ_EOM 0100000 /* pseudo flag for end-of-message */
-
-#define LSM_MASK 03 /* mask for modifier field */
-#define LSM_NOCHANGE 0 /* no change */
-#define LSM_DONOTSEND 1 /* do not send data */
-#define LSM_SEND 2 /* send data */
-
-#define LSI_MASK 014 /* mask for interpretation field */
-#define LSI_DATA 0 /* data segment or message count */
-#define LSI_INTR 4 /* interrupt request count */
-#define LSI_INTM 0377 /* funny marker for int. message */
-
-#define COS_MASK 014 /* mask for flow control field */
-#define COS_NONE 0 /* no flow control */
-#define COS_SEGMENT 04 /* segment flow control */
-#define COS_MESSAGE 010 /* message flow control */
-#define COS_CRYPTSER 020 /* cryptographic services requested */
-#define COS_DEFAULT 1 /* default value for field */
-
-#define COI_MASK 3 /* mask for version field */
-#define COI_32 0 /* version 3.2 */
-#define COI_31 1 /* version 3.1 */
-#define COI_40 2 /* version 4.0 */
-#define COI_41 3 /* version 4.1 */
-
-#define MNU_MASK 140 /* mask for session control version */
-#define MNU_10 000 /* session V1.0 */
-#define MNU_20 040 /* session V2.0 */
-#define MNU_ACCESS 1 /* access control present */
-#define MNU_USRDATA 2 /* user data field present */
-#define MNU_INVKPROXY 4 /* invoke proxy field present */
-#define MNU_UICPROXY 8 /* use uic-based proxy */
-
-#define DC_NORESOURCES 1 /* no resource reason code */
-#define DC_NOLINK 41 /* no link terminate reason code */
-#define DC_COMPLETE 42 /* disconnect complete reason code */
-
-#define DI_NOERROR 0 /* user disconnect */
-#define DI_SHUT 3 /* node is shutting down */
-#define DI_NOUSER 4 /* destination end user does not exist */
-#define DI_INVDEST 5 /* invalid end user destination */
-#define DI_REMRESRC 6 /* insufficient remote resources */
-#define DI_TPA 8 /* third party abort */
-#define DI_PROTOCOL 7 /* protocol error discovered */
-#define DI_ABORT 9 /* user abort */
-#define DI_LOCALRESRC 32 /* insufficient local resources */
-#define DI_REMUSERRESRC 33 /* insufficient remote user resources */
-#define DI_BADACCESS 34 /* bad access control information */
-#define DI_BADACCNT 36 /* bad ACCOUNT information */
-#define DI_CONNECTABORT 38 /* connect request cancelled */
-#define DI_TIMEDOUT 38 /* remote node or user crashed */
-#define DI_UNREACHABLE 39 /* local timers expired due to ... */
-#define DI_BADIMAGE 43 /* bad image data in connect */
-#define DI_SERVMISMATCH 54 /* cryptographic service mismatch */
-
-#define UC_OBJREJECT 0 /* object rejected connect */
-#define UC_USERDISCONNECT 0 /* user disconnect */
-#define UC_RESOURCES 1 /* insufficient resources (local or remote) */
-#define UC_NOSUCHNODE 2 /* unrecognized node name */
-#define UC_REMOTESHUT 3 /* remote node shutting down */
-#define UC_NOSUCHOBJ 4 /* unrecognized object */
-#define UC_INVOBJFORMAT 5 /* invalid object name format */
-#define UC_OBJTOOBUSY 6 /* object too busy */
-#define UC_NETWORKABORT 8 /* network abort */
-#define UC_USERABORT 9 /* user abort */
-#define UC_INVNODEFORMAT 10 /* invalid node name format */
-#define UC_LOCALSHUT 11 /* local node shutting down */
-#define UC_ACCESSREJECT 34 /* invalid access control information */
-#define UC_NORESPONSE 38 /* no response from object */
-#define UC_UNREACHABLE 39 /* node unreachable */
-
-/*
- * NSP message formats.
- */
-struct nsphdr /* general nsp header */
- {
- byte nh_flags; /* message flags */
- word nh_dst; /* destination link address */
- word nh_src; /* source link address */
- };
-
-struct seghdr /* data segment header */
- {
- byte sh_flags; /* message flags */
- word sh_dst; /* destination link address */
- word sh_src; /* source link address */
- word sh_seq[3]; /* sequence numbers */
- };
-
-struct minseghdr /* minimum data segment header */
- {
- byte ms_flags; /* message flags */
- word ms_dst; /* destination link address */
- word ms_src; /* source link address */
- word ms_seq; /* sequence number */
- };
-
-struct lsmsg /* link service message (after hdr) */
- {
- byte ls_lsflags; /* link service flags */
- byte ls_fcval; /* flow control value */
- };
-
-struct ackmsg /* acknowledgement message */
- {
- byte ak_flags; /* message flags */
- word ak_dst; /* destination link address */
- word ak_src; /* source link address */
- word ak_acknum[2]; /* acknowledgement numbers */
- };
-
-struct minackmsg /* minimum acknowledgement message */
- {
- byte mk_flags; /* message flags */
- word mk_dst; /* destination link address */
- word mk_src; /* source link address */
- word mk_acknum; /* acknowledgement number */
- };
-
-struct ciackmsg /* connect acknowledgement message */
- {
- byte ck_flags; /* message flags */
- word ck_dst; /* destination link address */
- };
-
-struct cimsg /* connect initiate message */
- {
- byte ci_flags; /* message flags */
- word ci_dst; /* destination link address (0) */
- word ci_src; /* source link address */
- byte ci_services; /* requested services */
- byte ci_info; /* information */
- word ci_segsize; /* maximum segment size */
- };
-
-struct ccmsg /* connect confirm message */
- {
- byte cc_flags; /* message flags */
- word cc_dst; /* destination link address */
- word cc_src; /* source link address */
- byte cc_services; /* requested services */
- byte cc_info; /* information */
- word cc_segsize; /* maximum segment size */
- byte cc_optlen; /* optional data length */
- };
-
-struct cnmsg /* generic connect message */
- {
- byte cn_flags; /* message flags */
- word cn_dst; /* destination link address */
- word cn_src; /* source link address */
- byte cn_services; /* requested services */
- byte cn_info; /* information */
- word cn_segsize; /* maximum segment size */
- };
-
-struct dimsg /* disconnect initiate message */
- {
- byte di_flags; /* message flags */
- word di_dst; /* destination link address */
- word di_src; /* source link address */
- word di_reason; /* reason code */
- byte di_optlen; /* optional data length */
- };
-
-struct dcmsg /* disconnect confirm message */
- {
- byte dc_flags; /* message flags */
- word dc_dst; /* destination link address */
- word dc_src; /* source link address */
- word dc_reason; /* reason code */
- };
diff --git a/freebsd/contrib/tcpdump/enc.h b/freebsd/contrib/tcpdump/enc.h
deleted file mode 100644
index 2d57e2b8..00000000
--- a/freebsd/contrib/tcpdump/enc.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/enc.h,v 1.1 2003-03-08 08:55:33 guy Exp $ (LBL) */
-/* From $OpenBSD: if_enc.h,v 1.8 2001/06/25 05:14:00 angelos Exp $ */
-/*
- * The authors of this code are John Ioannidis (ji@tla.org),
- * Angelos D. Keromytis (kermit@csd.uch.gr) and
- * Niels Provos (provos@physnet.uni-hamburg.de).
- *
- * This code was written by John Ioannidis for BSD/OS in Athens, Greece,
- * in November 1995.
- *
- * Ported to OpenBSD and NetBSD, with additional transforms, in December 1996,
- * by Angelos D. Keromytis.
- *
- * Additional transforms and features in 1997 and 1998 by Angelos D. Keromytis
- * and Niels Provos.
- *
- * Copyright (C) 1995, 1996, 1997, 1998 by John Ioannidis, Angelos D. Keromytis
- * and Niels Provos.
- * Copyright (c) 2001, Angelos D. Keromytis.
- *
- * Permission to use, copy, and modify this software with or without fee
- * is hereby granted, provided that this entire notice is included in
- * all copies of any software which is or includes a copy or
- * modification of this software.
- * You may use this code under the GNU public license if you so wish. Please
- * contribute changes back to the authors under this freer than GPL license
- * so that we may further the use of strong encryption without limitations to
- * all.
- *
- * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTY. IN PARTICULAR, NONE OF THE AUTHORS MAKES ANY
- * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE
- * MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR
- * PURPOSE.
- */
-
-#define ENC_HDRLEN 12
-
-/* From $OpenBSD: mbuf.h,v 1.56 2002/01/25 15:50:23 art Exp $ */
-#define M_CONF 0x0400 /* packet was encrypted (ESP-transport) */
-#define M_AUTH 0x0800 /* packet was authenticated (AH) */
-
-struct enchdr {
- u_int32_t af;
- u_int32_t spi;
- u_int32_t flags;
-};
diff --git a/freebsd/contrib/tcpdump/esp.h b/freebsd/contrib/tcpdump/esp.h
deleted file mode 100644
index 56cdada0..00000000
--- a/freebsd/contrib/tcpdump/esp.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/* $NetBSD: esp.h,v 1.13 2000/09/26 08:37:38 itojun Exp $ */
-/* $KAME: esp.h,v 1.15 2000/09/20 18:15:22 itojun Exp $ */
-
-/*
- * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
- * All rights reserved.
- *
- * 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.
- */
-
-/*
- * RFC1827/2406 Encapsulated Security Payload.
- */
-
-#ifndef _NETINET6_ESP_H_
-#define _NETINET6_ESP_H_
-
-struct esp {
- u_int32_t esp_spi; /* ESP */
- /*variable size, 32bit bound*/ /* Initialization Vector */
- /*variable size*/ /* Payload data */
- /*variable size*/ /* padding */
- /*8bit*/ /* pad size */
- /*8bit*/ /* next header */
- /*8bit*/ /* next header */
- /*variable size, 32bit bound*/ /* Authentication data (new IPsec) */
-};
-
-struct newesp {
- u_int32_t esp_spi; /* ESP */
- u_int32_t esp_seq; /* Sequence number */
- /*variable size*/ /* (IV and) Payload data */
- /*variable size*/ /* padding */
- /*8bit*/ /* pad size */
- /*8bit*/ /* next header */
- /*8bit*/ /* next header */
- /*variable size, 32bit bound*/ /* Authentication data */
-};
-
-struct esptail {
- u_int8_t esp_padlen; /* pad length */
- u_int8_t esp_nxt; /* Next header */
- /*variable size, 32bit bound*/ /* Authentication data (new IPsec)*/
-};
-
-#endif /*_NETINET6_ESP_H_*/
diff --git a/freebsd/contrib/tcpdump/ether.h b/freebsd/contrib/tcpdump/ether.h
index e8b3a713..64916789 100644
--- a/freebsd/contrib/tcpdump/ether.h
+++ b/freebsd/contrib/tcpdump/ether.h
@@ -1,4 +1,3 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/ether.h,v 1.8 2002-12-11 07:13:51 guy Exp $ (LBL) */
/*
* Copyright (c) 1982, 1986, 1993
* The Regents of the University of California. All rights reserved.
@@ -42,18 +41,17 @@
#define ETHER_ADDR_LEN 6
/*
- * Structure of a DEC/Intel/Xerox or 802.3 Ethernet header.
+ * Structure of an Ethernet header.
*/
struct ether_header {
- u_int8_t ether_dhost[ETHER_ADDR_LEN];
- u_int8_t ether_shost[ETHER_ADDR_LEN];
- u_int16_t ether_type;
+ uint8_t ether_dhost[ETHER_ADDR_LEN];
+ uint8_t ether_shost[ETHER_ADDR_LEN];
+ uint16_t ether_length_type;
};
/*
- * Length of a DEC/Intel/Xerox or 802.3 Ethernet header; note that some
- * compilers may pad "struct ether_header" to a multiple of 4 bytes,
- * for example, so "sizeof (struct ether_header)" may not give the right
- * answer.
+ * Length of an Ethernet header; note that some compilers may pad
+ * "struct ether_header" to a multiple of 4 bytes, for example, so
+ * "sizeof (struct ether_header)" may not give the right answer.
*/
#define ETHER_HDRLEN 14
diff --git a/freebsd/contrib/tcpdump/ethertype.h b/freebsd/contrib/tcpdump/ethertype.h
index 2c79ba28..2aa53a08 100644
--- a/freebsd/contrib/tcpdump/ethertype.h
+++ b/freebsd/contrib/tcpdump/ethertype.h
@@ -17,9 +17,6 @@
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * @(#) $Header: /tcpdump/master/tcpdump/ethertype.h,v 1.30 2008-02-06 10:47:53 guy Exp $ (LBL)
- * $FreeBSD$
*/
/*
@@ -169,11 +166,14 @@
#ifndef ETHERTYPE_RRCP
#define ETHERTYPE_RRCP 0x8899
#endif
+#ifndef ETHERTYPE_AOE
+#define ETHERTYPE_AOE 0x88a2
+#endif
#ifndef ETHERTYPE_LOOPBACK
#define ETHERTYPE_LOOPBACK 0x9000
#endif
#ifndef ETHERTYPE_VMAN
-#define ETHERTYPE_VMAN 0x9100 /* Extreme VMAN Protocol */
+#define ETHERTYPE_VMAN 0x9100 /* Extreme VMAN Protocol */
#endif
#ifndef ETHERTYPE_CFM_OLD
#define ETHERTYPE_CFM_OLD 0xabcd /* 802.1ag depreciated */
@@ -181,8 +181,23 @@
#ifndef ETHERTYPE_CFM
#define ETHERTYPE_CFM 0x8902 /* 802.1ag */
#endif
+#ifndef ETHERTYPE_IEEE1905_1
+#define ETHERTYPE_IEEE1905_1 0x893a /* IEEE 1905.1 */
+#endif
#ifndef ETHERTYPE_ISO
#define ETHERTYPE_ISO 0xfefe /* nonstandard - used in Cisco HDLC encapsulation */
#endif
+#ifndef ETHERTYPE_CALM_FAST
+#define ETHERTYPE_CALM_FAST 0x1111 /* ISO CALM FAST */
+#endif
+#ifndef ETHERTYPE_GEONET_OLD
+#define ETHERTYPE_GEONET_OLD 0x0707 /* ETSI GeoNetworking (before Jan 2013) */
+#endif
+#ifndef ETHERTYPE_GEONET
+#define ETHERTYPE_GEONET 0x8947 /* ETSI GeoNetworking (Official IEEE registration from Jan 2013) */
+#endif
+#ifndef ETHERTYPE_MEDSA
+#define ETHERTYPE_MEDSA 0xdada /* Marvel Distributed Switch Architecture */
+#endif
extern const struct tok ethertype_values[];
diff --git a/freebsd/contrib/tcpdump/extract.h b/freebsd/contrib/tcpdump/extract.h
index 60ecd680..23623c28 100644
--- a/freebsd/contrib/tcpdump/extract.h
+++ b/freebsd/contrib/tcpdump/extract.h
@@ -17,8 +17,6 @@
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * @(#) $Header: /tcpdump/master/tcpdump/extract.h,v 1.25 2006-01-30 16:20:07 hannes Exp $ (LBL)
*/
/*
@@ -28,104 +26,168 @@
/*
* The processor doesn't natively handle unaligned loads.
*/
-#ifdef HAVE___ATTRIBUTE__
+#if defined(__GNUC__) && defined(HAVE___ATTRIBUTE__) && \
+ (defined(__alpha) || defined(__alpha__) || \
+ defined(__mips) || defined(__mips__))
+
/*
- * We have __attribute__; we assume that means we have __attribute__((packed)).
- * Declare packed structures containing a u_int16_t and a u_int32_t,
+ * This is a GCC-compatible compiler and we have __attribute__, which
+ * we assume that mean we have __attribute__((packed)), and this is
+ * MIPS or Alpha, which has instructions that can help when doing
+ * unaligned loads.
+ *
+ * Declare packed structures containing a uint16_t and a uint32_t,
* cast the pointer to point to one of those, and fetch through it;
* the GCC manual doesn't appear to explicitly say that
* __attribute__((packed)) causes the compiler to generate unaligned-safe
* code, but it apppears to do so.
*
- * We do this in case the compiler can generate, for this instruction set,
- * better code to do an unaligned load and pass stuff to "ntohs()" or
- * "ntohl()" than the code to fetch the bytes one at a time and
- * assemble them. (That might not be the case on a little-endian platform,
- * where "ntohs()" and "ntohl()" might not be done inline.)
+ * We do this in case the compiler can generate code using those
+ * instructions to do an unaligned load and pass stuff to "ntohs()" or
+ * "ntohl()", which might be better than than the code to fetch the
+ * bytes one at a time and assemble them. (That might not be the
+ * case on a little-endian platform, such as DEC's MIPS machines and
+ * Alpha machines, where "ntohs()" and "ntohl()" might not be done
+ * inline.)
+ *
+ * We do this only for specific architectures because, for example,
+ * at least some versions of GCC, when compiling for 64-bit SPARC,
+ * generate code that assumes alignment if we do this.
+ *
+ * XXX - add other architectures and compilers as possible and
+ * appropriate.
+ *
+ * HP's C compiler, indicated by __HP_cc being defined, supports
+ * "#pragma unaligned N" in version A.05.50 and later, where "N"
+ * specifies a number of bytes at which the typedef on the next
+ * line is aligned, e.g.
+ *
+ * #pragma unalign 1
+ * typedef uint16_t unaligned_uint16_t;
+ *
+ * to define unaligned_uint16_t as a 16-bit unaligned data type.
+ * This could be presumably used, in sufficiently recent versions of
+ * the compiler, with macros similar to those below. This would be
+ * useful only if that compiler could generate better code for PA-RISC
+ * or Itanium than would be generated by a bunch of shifts-and-ORs.
+ *
+ * DEC C, indicated by __DECC being defined, has, at least on Alpha,
+ * an __unaligned qualifier that can be applied to pointers to get the
+ * compiler to generate code that does unaligned loads and stores when
+ * dereferencing the pointer in question.
+ *
+ * XXX - what if the native C compiler doesn't support
+ * __attribute__((packed))? How can we get it to generate unaligned
+ * accesses for *specific* items?
*/
typedef struct {
- u_int16_t val;
-} __attribute__((packed)) unaligned_u_int16_t;
+ uint16_t val;
+} __attribute__((packed)) unaligned_uint16_t;
typedef struct {
- u_int32_t val;
-} __attribute__((packed)) unaligned_u_int32_t;
+ uint32_t val;
+} __attribute__((packed)) unaligned_uint32_t;
-static inline u_int16_t
+static inline uint16_t
EXTRACT_16BITS(const void *p)
{
- return ((u_int16_t)ntohs(((const unaligned_u_int16_t *)(p))->val));
+ return ((uint16_t)ntohs(((const unaligned_uint16_t *)(p))->val));
}
-static inline u_int32_t
+static inline uint32_t
EXTRACT_32BITS(const void *p)
{
- return ((u_int32_t)ntohl(((const unaligned_u_int32_t *)(p))->val));
+ return ((uint32_t)ntohl(((const unaligned_uint32_t *)(p))->val));
}
-static inline u_int64_t
+static inline uint64_t
EXTRACT_64BITS(const void *p)
{
- return ((u_int64_t)(((u_int64_t)ntohl(((const unaligned_u_int32_t *)(p) + 0)->val)) << 32 | \
- ((u_int64_t)ntohl(((const unaligned_u_int32_t *)(p) + 1)->val)) << 0));
-
+ return ((uint64_t)(((uint64_t)ntohl(((const unaligned_uint32_t *)(p) + 0)->val)) << 32 |
+ ((uint64_t)ntohl(((const unaligned_uint32_t *)(p) + 1)->val)) << 0));
}
-#else /* HAVE___ATTRIBUTE__ */
+#else /* have to do it a byte at a time */
/*
- * We don't have __attribute__, so do unaligned loads of big-endian
+ * This isn't a GCC-compatible compiler, we don't have __attribute__,
+ * or we do but we don't know of any better way with this instruction
+ * set to do unaligned loads, so do unaligned loads of big-endian
* quantities the hard way - fetch the bytes one at a time and
* assemble them.
*/
#define EXTRACT_16BITS(p) \
- ((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 0) << 8 | \
- (u_int16_t)*((const u_int8_t *)(p) + 1)))
+ ((uint16_t)(((uint16_t)(*((const uint8_t *)(p) + 0)) << 8) | \
+ ((uint16_t)(*((const uint8_t *)(p) + 1)) << 0)))
#define EXTRACT_32BITS(p) \
- ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 24 | \
- (u_int32_t)*((const u_int8_t *)(p) + 1) << 16 | \
- (u_int32_t)*((const u_int8_t *)(p) + 2) << 8 | \
- (u_int32_t)*((const u_int8_t *)(p) + 3)))
+ ((uint32_t)(((uint32_t)(*((const uint8_t *)(p) + 0)) << 24) | \
+ ((uint32_t)(*((const uint8_t *)(p) + 1)) << 16) | \
+ ((uint32_t)(*((const uint8_t *)(p) + 2)) << 8) | \
+ ((uint32_t)(*((const uint8_t *)(p) + 3)) << 0)))
#define EXTRACT_64BITS(p) \
- ((u_int64_t)((u_int64_t)*((const u_int8_t *)(p) + 0) << 56 | \
- (u_int64_t)*((const u_int8_t *)(p) + 1) << 48 | \
- (u_int64_t)*((const u_int8_t *)(p) + 2) << 40 | \
- (u_int64_t)*((const u_int8_t *)(p) + 3) << 32 | \
- (u_int64_t)*((const u_int8_t *)(p) + 4) << 24 | \
- (u_int64_t)*((const u_int8_t *)(p) + 5) << 16 | \
- (u_int64_t)*((const u_int8_t *)(p) + 6) << 8 | \
- (u_int64_t)*((const u_int8_t *)(p) + 7)))
-#endif /* HAVE___ATTRIBUTE__ */
+ ((uint64_t)(((uint64_t)(*((const uint8_t *)(p) + 0)) << 56) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 1)) << 48) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 2)) << 40) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 3)) << 32) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 4)) << 24) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 5)) << 16) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 6)) << 8) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 7)) << 0)))
+#endif /* must special-case unaligned accesses */
#else /* LBL_ALIGN */
/*
* The processor natively handles unaligned loads, so we can just
* cast the pointer and fetch through it.
*/
-static inline u_int16_t
+static inline uint16_t
EXTRACT_16BITS(const void *p)
{
- return ((u_int16_t)ntohs(*(const u_int16_t *)(p)));
+ return ((uint16_t)ntohs(*(const uint16_t *)(p)));
}
-static inline u_int32_t
+static inline uint32_t
EXTRACT_32BITS(const void *p)
{
- return ((u_int32_t)ntohl(*(const u_int32_t *)(p)));
+ return ((uint32_t)ntohl(*(const uint32_t *)(p)));
}
-static inline u_int64_t
+static inline uint64_t
EXTRACT_64BITS(const void *p)
{
- return ((u_int64_t)(((u_int64_t)ntohl(*((const u_int32_t *)(p) + 0))) << 32 | \
- ((u_int64_t)ntohl(*((const u_int32_t *)(p) + 1))) << 0));
+ return ((uint64_t)(((uint64_t)ntohl(*((const uint32_t *)(p) + 0))) << 32 |
+ ((uint64_t)ntohl(*((const uint32_t *)(p) + 1))) << 0));
}
#endif /* LBL_ALIGN */
#define EXTRACT_24BITS(p) \
- ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 16 | \
- (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \
- (u_int32_t)*((const u_int8_t *)(p) + 2)))
+ ((uint32_t)(((uint32_t)(*((const uint8_t *)(p) + 0)) << 16) | \
+ ((uint32_t)(*((const uint8_t *)(p) + 1)) << 8) | \
+ ((uint32_t)(*((const uint8_t *)(p) + 2)) << 0)))
+
+#define EXTRACT_40BITS(p) \
+ ((uint64_t)(((uint64_t)(*((const uint8_t *)(p) + 0)) << 32) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 1)) << 24) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 2)) << 16) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 3)) << 8) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 4)) << 0)))
+
+#define EXTRACT_48BITS(p) \
+ ((uint64_t)(((uint64_t)(*((const uint8_t *)(p) + 0)) << 40) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 1)) << 32) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 2)) << 24) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 3)) << 16) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 4)) << 8) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 5)) << 0)))
+
+#define EXTRACT_56BITS(p) \
+ ((uint64_t)(((uint64_t)(*((const uint8_t *)(p) + 0)) << 48) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 1)) << 40) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 2)) << 32) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 3)) << 24) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 4)) << 16) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 5)) << 8) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 6)) << 0)))
/*
* Macros to extract possibly-unaligned little-endian integral values.
@@ -133,23 +195,50 @@ EXTRACT_64BITS(const void *p)
*/
#define EXTRACT_LE_8BITS(p) (*(p))
#define EXTRACT_LE_16BITS(p) \
- ((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 1) << 8 | \
- (u_int16_t)*((const u_int8_t *)(p) + 0)))
+ ((uint16_t)(((uint16_t)(*((const uint8_t *)(p) + 1)) << 8) | \
+ ((uint16_t)(*((const uint8_t *)(p) + 0)) << 0)))
#define EXTRACT_LE_32BITS(p) \
- ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 3) << 24 | \
- (u_int32_t)*((const u_int8_t *)(p) + 2) << 16 | \
- (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \
- (u_int32_t)*((const u_int8_t *)(p) + 0)))
+ ((uint32_t)(((uint32_t)(*((const uint8_t *)(p) + 3)) << 24) | \
+ ((uint32_t)(*((const uint8_t *)(p) + 2)) << 16) | \
+ ((uint32_t)(*((const uint8_t *)(p) + 1)) << 8) | \
+ ((uint32_t)(*((const uint8_t *)(p) + 0)) << 0)))
#define EXTRACT_LE_24BITS(p) \
- ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 2) << 16 | \
- (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \
- (u_int32_t)*((const u_int8_t *)(p) + 0)))
+ ((uint32_t)(((uint32_t)(*((const uint8_t *)(p) + 2)) << 16) | \
+ ((uint32_t)(*((const uint8_t *)(p) + 1)) << 8) | \
+ ((uint32_t)(*((const uint8_t *)(p) + 0)) << 0)))
#define EXTRACT_LE_64BITS(p) \
- ((u_int64_t)((u_int64_t)*((const u_int8_t *)(p) + 7) << 56 | \
- (u_int64_t)*((const u_int8_t *)(p) + 6) << 48 | \
- (u_int64_t)*((const u_int8_t *)(p) + 5) << 40 | \
- (u_int64_t)*((const u_int8_t *)(p) + 4) << 32 | \
- (u_int64_t)*((const u_int8_t *)(p) + 3) << 24 | \
- (u_int64_t)*((const u_int8_t *)(p) + 2) << 16 | \
- (u_int64_t)*((const u_int8_t *)(p) + 1) << 8 | \
- (u_int64_t)*((const u_int8_t *)(p) + 0)))
+ ((uint64_t)(((uint64_t)(*((const uint8_t *)(p) + 7)) << 56) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 6)) << 48) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 5)) << 40) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 4)) << 32) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 3)) << 24) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 2)) << 16) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 1)) << 8) | \
+ ((uint64_t)(*((const uint8_t *)(p) + 0)) << 0)))
+
+/*
+ * Macros to check the presence of the values in question.
+ */
+#define ND_TTEST_8BITS(p) ND_TTEST2(*(p), 1)
+#define ND_TCHECK_8BITS(p) ND_TCHECK2(*(p), 1)
+
+#define ND_TTEST_16BITS(p) ND_TTEST2(*(p), 2)
+#define ND_TCHECK_16BITS(p) ND_TCHECK2(*(p), 2)
+
+#define ND_TTEST_24BITS(p) ND_TTEST2(*(p), 3)
+#define ND_TCHECK_24BITS(p) ND_TCHECK2(*(p), 3)
+
+#define ND_TTEST_32BITS(p) ND_TTEST2(*(p), 4)
+#define ND_TCHECK_32BITS(p) ND_TCHECK2(*(p), 4)
+
+#define ND_TTEST_40BITS(p) ND_TTEST2(*(p), 5)
+#define ND_TCHECK_40BITS(p) ND_TCHECK2(*(p), 5)
+
+#define ND_TTEST_48BITS(p) ND_TTEST2(*(p), 6)
+#define ND_TCHECK_48BITS(p) ND_TCHECK2(*(p), 6)
+
+#define ND_TTEST_56BITS(p) ND_TTEST2(*(p), 7)
+#define ND_TCHECK_56BITS(p) ND_TCHECK2(*(p), 7)
+
+#define ND_TTEST_64BITS(p) ND_TTEST2(*(p), 8)
+#define ND_TCHECK_64BITS(p) ND_TCHECK2(*(p), 8)
diff --git a/freebsd/contrib/tcpdump/fddi.h b/freebsd/contrib/tcpdump/fddi.h
deleted file mode 100644
index df38c8e9..00000000
--- a/freebsd/contrib/tcpdump/fddi.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (c) 1992, 1993, 1994, 1995, 1996
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that: (1) source code distributions
- * retain the above copyright notice and this paragraph in its entirety, (2)
- * distributions including binary code include the above copyright notice and
- * this paragraph in its entirety in the documentation or other materials
- * provided with the distribution, and (3) all advertising materials mentioning
- * features or use of this software display the following acknowledgement:
- * ``This product includes software developed by the University of California,
- * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
- * the University 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 ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * @(#) $Header: /tcpdump/master/tcpdump/fddi.h,v 1.11 2002-12-11 07:13:51 guy Exp $ (LBL)
- */
-
-/*
- * Based on Ultrix if_fddi.h
- */
-
-/*
- * This stuff should come from a system header file, but there's no
- * obviously portable way to do that and it's not really going
- * to change from system to system (except for the padding business).
- */
-
-struct fddi_header {
- u_char fddi_fc; /* frame control */
- u_char fddi_dhost[6];
- u_char fddi_shost[6];
-};
-
-/*
- * Length of an FDDI header; note that some compilers may pad
- * "struct fddi_header" to a multiple of 4 bytes, for example, so
- * "sizeof (struct fddi_header)" may not give the right
- * answer.
- */
-#define FDDI_HDRLEN 13
-
-/* Useful values for fddi_fc (frame control) field */
-
-/*
- * FDDI Frame Control bits
- */
-#define FDDIFC_C 0x80 /* Class bit */
-#define FDDIFC_L 0x40 /* Address length bit */
-#define FDDIFC_F 0x30 /* Frame format bits */
-#define FDDIFC_Z 0x0f /* Control bits */
-
-/*
- * FDDI Frame Control values. (48-bit addressing only).
- */
-#define FDDIFC_VOID 0x40 /* Void frame */
-#define FDDIFC_NRT 0x80 /* Nonrestricted token */
-#define FDDIFC_RT 0xc0 /* Restricted token */
-#define FDDIFC_SMT_INFO 0x41 /* SMT Info */
-#define FDDIFC_SMT_NSA 0x4F /* SMT Next station adrs */
-#define FDDIFC_MAC_BEACON 0xc2 /* MAC Beacon frame */
-#define FDDIFC_MAC_CLAIM 0xc3 /* MAC Claim frame */
-#define FDDIFC_LLC_ASYNC 0x50 /* Async. LLC frame */
-#define FDDIFC_LLC_SYNC 0xd0 /* Sync. LLC frame */
-#define FDDIFC_IMP_ASYNC 0x60 /* Implementor Async. */
-#define FDDIFC_IMP_SYNC 0xe0 /* Implementor Synch. */
-#define FDDIFC_SMT 0x40 /* SMT frame */
-#define FDDIFC_MAC 0xc0 /* MAC frame */
-
-#define FDDIFC_CLFF 0xF0 /* Class/Length/Format bits */
-#define FDDIFC_ZZZZ 0x0F /* Control bits */
diff --git a/freebsd/contrib/tcpdump/forces.h b/freebsd/contrib/tcpdump/forces.h
deleted file mode 100644
index d41475f9..00000000
--- a/freebsd/contrib/tcpdump/forces.h
+++ /dev/null
@@ -1,679 +0,0 @@
-/*
- * Copyright (c) 1982, 1986, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * 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. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
- *
- * Copyright (c) 2009 Mojatatu Networks, Inc
- *
- */
-
-/*
- * Per draft-ietf-forces-protocol-22
-*/
-#define ForCES_VERS 1
-#define ForCES_HDRL 24
-#define ForCES_ALNL 4U
-#define TLV_HDRL 4
-#define ILV_HDRL 8
-
-#define TOM_RSVD 0x0
-#define TOM_ASSNSETUP 0x1
-#define TOM_ASSNTEARD 0x2
-#define TOM_CONFIG 0x3
-#define TOM_QUERY 0x4
-#define TOM_EVENTNOT 0x5
-#define TOM_PKTREDIR 0x6
-#define TOM_HEARTBT 0x0F
-#define TOM_ASSNSETREP 0x11
-#define TOM_CONFIGREP 0x13
-#define TOM_QUERYREP 0x14
-
-/*
- * tom_h Flags: resv1(8b):maxtlvs(4b):resv2(2b):mintlv(2b)
-*/
-#define ZERO_TTLV 0x01
-#define ZERO_MORE_TTLV 0x02
-#define ONE_MORE_TTLV 0x04
-#define ZERO_TLV 0x00
-#define ONE_TLV 0x10
-#define TWO_TLV 0x20
-#define MAX_TLV 0xF0
-
-#define TTLV_T1 (ONE_MORE_TTLV|ONE_TLV)
-#define TTLV_T2 (ONE_MORE_TTLV|MAX_TLV)
-
-struct tom_h {
- u_int32_t v;
- u_int16_t flags;
- u_int16_t op_msk;
- const char *s;
- int (*print) (register const u_char * pptr, register u_int len,
- u_int16_t op_msk, int indent);
-};
-
-enum {
- TOM_RSV_I,
- TOM_ASS_I,
- TOM_AST_I,
- TOM_CFG_I,
- TOM_QRY_I,
- TOM_EVN_I,
- TOM_RED_I,
- TOM_HBT_I,
- TOM_ASR_I,
- TOM_CNR_I,
- TOM_QRR_I,
- _TOM_RSV_MAX
-};
-#define TOM_MAX_IND (_TOM_RSV_MAX - 1)
-
-int lfbselect_print(register const u_char * pptr, register u_int len,
- u_int16_t op_msk, int indent);
-int redirect_print(register const u_char * pptr, register u_int len,
- u_int16_t op_msk, int indent);
-int asrtlv_print(register const u_char * pptr, register u_int len,
- u_int16_t op_msk, int indent);
-int asttlv_print(register const u_char * pptr, register u_int len,
- u_int16_t op_msk, int indent);
-int gentltlv_print(register const u_char * pptr, register u_int len,
- u_int16_t op_msk, int indent);
-int print_metailv(register const u_char * pptr, register u_int len,
- u_int16_t op_msk, int indent);
-int print_metatlv(register const u_char * pptr, register u_int len,
- u_int16_t op_msk, int indent);
-int print_reddata(register const u_char * pptr, register u_int len,
- u_int16_t op_msk, int indent);
-
-static inline int tom_valid(u_int8_t tom)
-{
- if (tom > 0) {
- if (tom >= 0x7 && tom <= 0xe)
- return 0;
- if (tom == 0x10)
- return 0;
- if (tom > 0x14)
- return 0;
- return 1;
- } else
- return 0;
-}
-
-static inline const char *ForCES_node(u_int32_t node)
-{
- if (node <= 0x3FFFFFFF)
- return "FE";
- if (node >= 0x40000000 && node <= 0x7FFFFFFF)
- return "CE";
- if (node >= 0xC0000000 && node <= 0xFFFFFFEF)
- return "AllMulticast";
- if (node == 0xFFFFFFFD)
- return "AllCEsBroadcast";
- if (node == 0xFFFFFFFE)
- return "AllFEsBroadcast";
- if (node == 0xFFFFFFFF)
- return "AllBroadcast";
-
- return "ForCESreserved";
-
-}
-
-static inline const char *ForCES_ACKp(u_int32_t flg)
-{
- if (flg == 0x0)
- return "NoACK";
- if (flg == 0x1)
- return "SuccessACK";
- if (flg == 0x2)
- return "FailureACK";
- if (flg == 0x3)
- return "AlwaysACK";
- return "ACKUnknown";
-}
-
-static inline const char *ForCES_EMp(u_int32_t flg)
-{
- if (flg == 0x0)
- return "EMReserved";
- if (flg == 0x1)
- return "execute-all-or-none";
- if (flg == 0x2)
- return "execute-until-failure";
- if (flg == 0x3)
- return "continue-execute-on-failure";
- return "EMUnknown";
-}
-
-static inline const char *ForCES_ATp(u_int32_t flg)
-{
- if (flg == 0x0)
- return "Standalone";
- if (flg == 0x1)
- return "2PCtransaction";
- return "ATUnknown";
-}
-
-static inline const char *ForCES_TPp(u_int32_t flg)
-{
- if (flg == 0x0)
- return "StartofTransaction";
- if (flg == 0x1)
- return "MiddleofTransaction";
- if (flg == 0x2)
- return "EndofTransaction";
- if (flg == 0x3)
- return "abort";
- return "TPUnknown";
-}
-
-/*
- * Structure of forces header, naked of TLVs.
- */
-struct forcesh {
- u_int8_t fm_vrsvd; /* version and reserved */
-#define ForCES_V(forcesh) ((forcesh)->fm_vrsvd >> 4)
- u_int8_t fm_tom; /* type of message */
- u_int16_t fm_len; /* total length * 4 bytes */
-#define ForCES_BLN(forcesh) ((u_int32_t)(EXTRACT_16BITS(&(forcesh)->fm_len) << 2))
- u_int32_t fm_sid; /* Source ID */
-#define ForCES_SID(forcesh) EXTRACT_32BITS(&(forcesh)->fm_sid)
- u_int32_t fm_did; /* Destination ID */
-#define ForCES_DID(forcesh) EXTRACT_32BITS(&(forcesh)->fm_did)
- u_int8_t fm_cor[8]; /* correlator */
- u_int32_t fm_flags; /* flags */
-#define ForCES_ACK(forcesh) ((EXTRACT_32BITS(&(forcesh)->fm_flags)&0xC0000000) >> 30)
-#define ForCES_PRI(forcesh) ((EXTRACT_32BITS(&(forcesh)->fm_flags)&0x38000000) >> 27)
-#define ForCES_RS1(forcesh) ((EXTRACT_32BITS(&(forcesh)->fm_flags)&0x07000000) >> 24)
-#define ForCES_EM(forcesh) ((EXTRACT_32BITS(&(forcesh)->fm_flags)&0x00C00000) >> 22)
-#define ForCES_AT(forcesh) ((EXTRACT_32BITS(&(forcesh)->fm_flags)&0x00200000) >> 21)
-#define ForCES_TP(forcesh) ((EXTRACT_32BITS(&(forcesh)->fm_flags)&0x00180000) >> 19)
-#define ForCES_RS2(forcesh) ((EXTRACT_32BITS(&(forcesh)->fm_flags)&0x0007FFFF) >> 0)
-};
-
-#define ForCES_HLN_VALID(fhl,tlen) ((tlen) >= ForCES_HDRL && \
- (fhl) >= ForCES_HDRL && \
- (fhl) == (tlen))
-
-#define F_LFB_RSVD 0x0
-#define F_LFB_FEO 0x1
-#define F_LFB_FEPO 0x2
-const struct tok ForCES_LFBs[] = {
- {F_LFB_RSVD, "Invalid TLV"},
- {F_LFB_FEO, "FEObj LFB"},
- {F_LFB_FEPO, "FEProtoObj LFB"},
- {0, NULL}
-};
-
-int forces_type_print(register const u_char * pptr, const struct forcesh *fhdr,
- register u_int mlen, const struct tom_h *tops);
-
-enum {
- F_OP_RSV,
- F_OP_SET,
- F_OP_SETPROP,
- F_OP_SETRESP,
- F_OP_SETPRESP,
- F_OP_DEL,
- F_OP_DELRESP,
- F_OP_GET,
- F_OP_GETPROP,
- F_OP_GETRESP,
- F_OP_GETPRESP,
- F_OP_REPORT,
- F_OP_COMMIT,
- F_OP_RCOMMIT,
- F_OP_RTRCOMP,
- _F_OP_MAX
-};
-
-#define F_OP_MAX (_F_OP_MAX - 1)
-enum {
- B_OP_SET = 1 << (F_OP_SET - 1),
- B_OP_SETPROP = 1 << (F_OP_SETPROP - 1),
- B_OP_SETRESP = 1 << (F_OP_SETRESP - 1),
- B_OP_SETPRESP = 1 << (F_OP_SETPRESP - 1),
- B_OP_DEL = 1 << (F_OP_DEL - 1),
- B_OP_DELRESP = 1 << (F_OP_DELRESP - 1),
- B_OP_GET = 1 << (F_OP_GET - 1),
- B_OP_GETPROP = 1 << (F_OP_GETPROP - 1),
- B_OP_GETRESP = 1 << (F_OP_GETRESP - 1),
- B_OP_GETPRESP = 1 << (F_OP_GETPRESP - 1),
- B_OP_REPORT = 1 << (F_OP_REPORT - 1),
- B_OP_COMMIT = 1 << (F_OP_COMMIT - 1),
- B_OP_RCOMMIT = 1 << (F_OP_RCOMMIT - 1),
- B_OP_RTRCOMP = 1 << (F_OP_RTRCOMP - 1),
-};
-
-struct optlv_h {
- u_int16_t flags;
- u_int16_t op_msk;
- const char *s;
- int (*print) (register const u_char * pptr, register u_int len,
- u_int16_t op_msk, int indent);
-};
-
-int genoptlv_print(register const u_char * pptr, register u_int len,
- u_int16_t op_msk, int indent);
-int recpdoptlv_print(register const u_char * pptr, register u_int len,
- u_int16_t op_msk, int indent);
-int invoptlv_print(register const u_char * pptr, register u_int len,
- u_int16_t op_msk, int indent);
-
-#define OP_MIN_SIZ 8
-struct pathdata_h {
- u_int16_t pflags;
- u_int16_t pIDcnt;
-};
-
-#define B_FULLD 0x1
-#define B_SPARD 0x2
-#define B_RESTV 0x4
-#define B_KEYIN 0x8
-
-static const struct optlv_h OPTLV_msg[F_OP_MAX + 1] = {
- /* F_OP_RSV */ {ZERO_TTLV, 0, "Invalid OPTLV", invoptlv_print},
- /* F_OP_SET */ {TTLV_T2, B_FULLD | B_SPARD, " Set", recpdoptlv_print},
- /* F_OP_SETPROP */
- {TTLV_T2, B_FULLD | B_SPARD, " SetProp", recpdoptlv_print},
- /* F_OP_SETRESP */ {TTLV_T2, B_RESTV, " SetResp", recpdoptlv_print},
- /* F_OP_SETPRESP */ {TTLV_T2, B_RESTV, " SetPropResp", recpdoptlv_print},
- /* F_OP_DEL */ {ZERO_TTLV, 0, " Del", recpdoptlv_print},
- /* F_OP_DELRESP */ {TTLV_T2, B_RESTV, " DelResp", recpdoptlv_print},
- /* F_OP_GET */ {ZERO_TTLV, 0, " Get", recpdoptlv_print},
- /* F_OP_GETPROP */ {ZERO_TTLV, 0, " GetProp", recpdoptlv_print},
- /* F_OP_GETRESP */
- {TTLV_T2, B_FULLD | B_SPARD | B_RESTV, " GetResp", recpdoptlv_print},
- /* F_OP_GETPRESP */
- {TTLV_T2, B_FULLD | B_RESTV, " GetPropResp", recpdoptlv_print},
- /* F_OP_REPORT */
- {TTLV_T2, B_FULLD | B_SPARD, " Report", recpdoptlv_print},
- /* F_OP_COMMIT */ {ZERO_TTLV, 0, " Commit", NULL},
- /* F_OP_RCOMMIT */ {TTLV_T1, B_RESTV, " RCommit", genoptlv_print},
- /* F_OP_RTRCOMP */ {ZERO_TTLV, 0, " RTRCOMP", NULL},
-};
-
-static inline const struct optlv_h *get_forces_optlv_h(u_int16_t opt)
-{
- if (opt > F_OP_MAX || opt <= F_OP_RSV)
- return &OPTLV_msg[F_OP_RSV];
-
- return &OPTLV_msg[opt];
-}
-
-#define IND_SIZE 256
-#define IND_CHR ' '
-#define IND_PREF '\n'
-#define IND_SUF 0x0
-char ind_buf[IND_SIZE];
-
-static inline char *indent_pr(int indent, int nlpref)
-{
- int i = 0;
- char *r = ind_buf;
-
- if (indent > (IND_SIZE - 1))
- indent = IND_SIZE - 1;
-
- if (nlpref) {
- r[i] = IND_PREF;
- i++;
- indent--;
- }
-
- while (--indent >= 0)
- r[i++] = IND_CHR;
-
- r[i] = IND_SUF;
- return r;
-}
-
-static inline int op_valid(u_int16_t op, u_int16_t mask)
-{
- int opb = 1 << (op - 1);
-
- if (op == 0)
- return 0;
- if (opb & mask)
- return 1;
- /* I guess we should allow vendor operations? */
- if (op >= 0x8000)
- return 1;
- return 0;
-}
-
-#define F_TLV_RSVD 0x0000
-#define F_TLV_REDR 0x0001
-#define F_TLV_ASRS 0x0010
-#define F_TLV_ASRT 0x0011
-#define F_TLV_LFBS 0x1000
-#define F_TLV_PDAT 0x0110
-#define F_TLV_KEYI 0x0111
-#define F_TLV_FULD 0x0112
-#define F_TLV_SPAD 0x0113
-#define F_TLV_REST 0x0114
-#define F_TLV_METD 0x0115
-#define F_TLV_REDD 0x0116
-#define F_TLV_VNST 0x8000
-
-static const struct tok ForCES_TLV[] = {
- {F_TLV_RSVD, "Invalid TLV"},
- {F_TLV_REDR, "REDIRECT TLV"},
- {F_TLV_ASRS, "ASResult TLV"},
- {F_TLV_ASRT, "ASTreason TLV"},
- {F_TLV_LFBS, "LFBselect TLV"},
- {F_TLV_PDAT, "PATH-DATA TLV"},
- {F_TLV_KEYI, "KEYINFO TLV"},
- {F_TLV_FULD, "FULLDATA TLV"},
- {F_TLV_SPAD, "SPARSEDATA TLV"},
- {F_TLV_REST, "RESULT TLV"},
- {F_TLV_METD, "METADATA TLV"},
- {F_TLV_REDD, "REDIRECTDATA TLV"},
- {0, NULL}
-};
-
-#define TLV_HLN 4
-static inline int ttlv_valid(u_int16_t ttlv)
-{
- if (ttlv > 0) {
- if (ttlv == 1 || ttlv == 0x1000)
- return 1;
- if (ttlv >= 0x10 && ttlv <= 0x11)
- return 1;
- if (ttlv >= 0x110 && ttlv <= 0x116)
- return 1;
- if (ttlv >= 0x8000)
- return 0; /* XXX: */
- }
-
- return 0;
-}
-
-struct forces_ilv {
- u_int32_t type;
- u_int32_t length;
-};
-
-struct forces_tlv {
- u_int16_t type;
- u_int16_t length;
-};
-
-int otlv_print(const struct forces_tlv *otlv, u_int16_t op_msk, int indent);
-
-#define F_ALN_LEN(len) ( ((len)+ForCES_ALNL-1) & ~(ForCES_ALNL-1) )
-#define GET_TOP_TLV(fhdr) ((struct forces_tlv *)((fhdr) + sizeof (struct forcesh)))
-#define TLV_SET_LEN(len) (F_ALN_LEN(TLV_HDRL) + (len))
-#define TLV_ALN_LEN(len) F_ALN_LEN(TLV_SET_LEN(len))
-#define TLV_RDAT_LEN(tlv) ((int)(EXTRACT_16BITS(&(tlv)->length) - TLV_SET_LEN(0))
-#define TLV_DATA(tlvp) ((void*)(((char*)(tlvp)) + TLV_SET_LEN(0)))
-#define GO_NXT_TLV(tlv,rlen) ((rlen) -= F_ALN_LEN(EXTRACT_16BITS(&(tlv)->length)), \
- (struct forces_tlv*)(((char*)(tlv)) \
- + F_ALN_LEN(EXTRACT_16BITS(&(tlv)->length))))
-#define ILV_SET_LEN(len) (F_ALN_LEN(ILV_HDRL) + (len))
-#define ILV_ALN_LEN(len) F_ALN_LEN(ILV_SET_LEN(len))
-#define ILV_RDAT_LEN(ilv) ((int)(EXTRACT_32BITS(&(ilv)->length)) - ILV_SET_LEN(0))
-#define ILV_DATA(ilvp) ((void*)(((char*)(ilvp)) + ILV_SET_LEN(0)))
-#define GO_NXT_ILV(ilv,rlen) ((rlen) -= F_ALN_LEN(EXTRACT_32BITS(&(ilv)->length)), \
- (struct forces_ilv *)(((char*)(ilv)) \
- + F_ALN_LEN(EXTRACT_32BITS(&(ilv)->length))))
-#define INVALID_RLEN -1
-#define INVALID_STLN -2
-#define INVALID_LTLN -3
-#define INVALID_ALEN -4
-
-static const struct tok ForCES_TLV_err[] = {
- {INVALID_RLEN, "Invalid total length"},
- {INVALID_STLN, "xLV too short"},
- {INVALID_LTLN, "xLV too long"},
- {INVALID_ALEN, "data padding missing"},
- {0, NULL}
-};
-
-static inline int tlv_valid(const struct forces_tlv *tlv, u_int rlen)
-{
- if (rlen < TLV_HDRL)
- return INVALID_RLEN;
- if (EXTRACT_16BITS(&tlv->length) < TLV_HDRL)
- return INVALID_STLN;
- if (EXTRACT_16BITS(&tlv->length) > rlen)
- return INVALID_LTLN;
- if (rlen < F_ALN_LEN(EXTRACT_16BITS(&tlv->length)))
- return INVALID_ALEN;
-
- return 0;
-}
-
-static inline int ilv_valid(const struct forces_ilv *ilv, u_int rlen)
-{
- if (rlen < ILV_HDRL)
- return INVALID_RLEN;
- if (EXTRACT_32BITS(&ilv->length) < ILV_HDRL)
- return INVALID_STLN;
- if (EXTRACT_32BITS(&ilv->length) > rlen)
- return INVALID_LTLN;
- if (rlen < F_ALN_LEN(EXTRACT_32BITS(&ilv->length)))
- return INVALID_ALEN;
-
- return 0;
-}
-
-struct forces_lfbsh {
- u_int32_t class;
- u_int32_t instance;
-};
-
-#define ASSNS_OPS (B_OP_REPORT)
-#define CFG_OPS (B_OP_SET|B_OP_SETPROP|B_OP_DEL|B_OP_COMMIT|B_OP_RTRCOMP)
-#define CFG_ROPS (B_OP_SETRESP|B_OP_SETPRESP|B_OP_DELRESP|B_OP_RCOMMIT)
-#define CFG_QY (B_OP_GET|B_OP_GETPROP)
-#define CFG_QYR (B_OP_GETRESP|B_OP_GETPRESP)
-#define CFG_EVN (B_OP_REPORT)
-
-static const struct tom_h ForCES_msg[TOM_MAX_IND + 1] = {
- /* TOM_RSV_I */ {TOM_RSVD, ZERO_TTLV, 0, "Invalid message", NULL},
- /* TOM_ASS_I */ {TOM_ASSNSETUP, ZERO_MORE_TTLV | TWO_TLV, ASSNS_OPS,
- "Association Setup", lfbselect_print},
- /* TOM_AST_I */
- {TOM_ASSNTEARD, TTLV_T1, 0, "Association TearDown", asttlv_print},
- /* TOM_CFG_I */ {TOM_CONFIG, TTLV_T2, CFG_OPS, "Config", lfbselect_print},
- /* TOM_QRY_I */ {TOM_QUERY, TTLV_T2, CFG_QY, "Query", lfbselect_print},
- /* TOM_EVN_I */ {TOM_EVENTNOT, TTLV_T1, CFG_EVN, "Event Notification",
- lfbselect_print},
- /* TOM_RED_I */
- {TOM_PKTREDIR, TTLV_T2, 0, "Packet Redirect", redirect_print},
- /* TOM_HBT_I */ {TOM_HEARTBT, ZERO_TTLV, 0, "HeartBeat", NULL},
- /* TOM_ASR_I */
- {TOM_ASSNSETREP, TTLV_T1, 0, "Association Response", asrtlv_print},
- /* TOM_CNR_I */ {TOM_CONFIGREP, TTLV_T2, CFG_ROPS, "Config Response",
- lfbselect_print},
- /* TOM_QRR_I */
- {TOM_QUERYREP, TTLV_T2, CFG_QYR, "Query Response", lfbselect_print},
-};
-
-static inline const struct tom_h *get_forces_tom(u_int8_t tom)
-{
- int i;
- for (i = TOM_RSV_I; i <= TOM_MAX_IND; i++) {
- const struct tom_h *th = &ForCES_msg[i];
- if (th->v == tom)
- return th;
- }
- return &ForCES_msg[TOM_RSV_I];
-}
-
-struct pdata_ops {
- u_int32_t v;
- u_int16_t flags;
- u_int16_t op_msk;
- const char *s;
- int (*print) (register const u_char * pptr, register u_int len,
- u_int16_t op_msk, int indent);
-};
-
-enum {
- PD_RSV_I,
- PD_SEL_I,
- PD_FDT_I,
- PD_SDT_I,
- PD_RES_I,
- PD_PDT_I,
- _PD_RSV_MAX
-};
-#define PD_MAX_IND (_TOM_RSV_MAX - 1)
-
-static inline int pd_valid(u_int16_t pd)
-{
- if (pd >= F_TLV_PDAT && pd <= F_TLV_REST)
- return 1;
- return 0;
-}
-
-static inline void chk_op_type(u_int16_t type, u_int16_t msk, u_int16_t omsk)
-{
- if (type != F_TLV_PDAT) {
- if (msk & B_KEYIN) {
- if (type != F_TLV_KEYI) {
- printf
- ("Based on flags expected KEYINFO TLV!\n");
- }
- } else {
- if (!(msk & omsk)) {
- printf
- ("Illegal DATA encoding for type 0x%x programmed %x got %x \n",
- type, omsk, msk);
- }
- }
- }
-
-}
-
-int fdatatlv_print(register const u_char * pptr, register u_int len,
- u_int16_t op_msk, int indent);
-int sdatailv_print(register const u_char * pptr, register u_int len,
- u_int16_t op_msk, int indent);
-int sdatatlv_print(register const u_char * pptr, register u_int len,
- u_int16_t op_msk, int indent);
-int pdatatlv_print(register const u_char * pptr, register u_int len,
- u_int16_t op_msk, int indent);
-int pkeyitlv_print(register const u_char * pptr, register u_int len,
- u_int16_t op_msk, int indent);
-
-int pdatacnt_print(register const u_char * pptr, register u_int len,
- u_int16_t IDcnt, u_int16_t op_msk, int indent);
-int pdata_print(register const u_char * pptr, register u_int len,
- u_int16_t op_msk, int indent);
-
-int prestlv_print(register const u_char * pptr, register u_int len,
- u_int16_t op_msk, int indent);
-#define F_SELKEY 1
-
-struct res_val {
- u_int8_t result;
- u_int8_t resv1;
- u_int16_t resv2;
-};
-
-static const struct pdata_ops ForCES_pdata[PD_MAX_IND + 1] = {
- /* PD_RSV_I */ {0, 0, 0, "Invalid message", NULL},
- /* PD_SEL_I */ {F_TLV_KEYI, 0, 0, "KEYINFO TLV", pkeyitlv_print},
- /* PD_FDT_I */ {F_TLV_FULD, 0, B_FULLD, "FULLDATA TLV", fdatatlv_print},
- /* PD_SDT_I */ {F_TLV_SPAD, 0, B_SPARD, "SPARSEDATA TLV", sdatatlv_print},
- /* PD_RES_I */ {F_TLV_REST, 0, B_RESTV, "RESULT TLV", prestlv_print},
- /* PD_PDT_I */
- {F_TLV_PDAT, 0, 0, "Inner PATH-DATA TLV", recpdoptlv_print},
-};
-
-static inline const struct pdata_ops *get_forces_pd(u_int16_t pd)
-{
- int i;
- for (i = PD_RSV_I + 1; i <= PD_MAX_IND; i++) {
- const struct pdata_ops *pdo = &ForCES_pdata[i];
- if (pdo->v == pd)
- return pdo;
- }
- return &ForCES_pdata[TOM_RSV_I];
-}
-
-enum {
- E_SUCCESS,
- E_INVALID_HEADER,
- E_LENGTH_MISMATCH,
- E_VERSION_MISMATCH,
- E_INVALID_DESTINATION_PID,
- E_LFB_UNKNOWN,
- E_LFB_NOT_FOUND,
- E_LFB_INSTANCE_ID_NOT_FOUND,
- E_INVALID_PATH,
- E_COMPONENT_DOES_NOT_EXIST,
- E_EXISTS,
- E_NOT_FOUND,
- E_READ_ONLY,
- E_INVALID_ARRAY_CREATION,
- E_VALUE_OUT_OF_RANGE,
- E_CONTENTS_TOO_LONG,
- E_INVALID_PARAMETERS,
- E_INVALID_MESSAGE_TYPE,
- E_INVALID_FLAGS,
- E_INVALID_TLV,
- E_EVENT_ERROR,
- E_NOT_SUPPORTED,
- E_MEMORY_ERROR,
- E_INTERNAL_ERROR,
- /* 0x18-0xFE are reserved .. */
- E_UNSPECIFIED_ERROR = 0XFF
-};
-
-const struct tok ForCES_errs[] = {
- {E_SUCCESS, "SUCCESS"},
- {E_INVALID_HEADER, "INVALID HEADER"},
- {E_LENGTH_MISMATCH, "LENGTH MISMATCH"},
- {E_VERSION_MISMATCH, "VERSION MISMATCH"},
- {E_INVALID_DESTINATION_PID, "INVALID DESTINATION PID"},
- {E_LFB_UNKNOWN, "LFB UNKNOWN"},
- {E_LFB_NOT_FOUND, "LFB NOT FOUND"},
- {E_LFB_INSTANCE_ID_NOT_FOUND, "LFB INSTANCE ID NOT FOUND"},
- {E_INVALID_PATH, "INVALID PATH"},
- {E_COMPONENT_DOES_NOT_EXIST, "COMPONENT DOES NOT EXIST"},
- {E_EXISTS, "EXISTS ALREADY"},
- {E_NOT_FOUND, "NOT FOUND"},
- {E_READ_ONLY, "READ ONLY"},
- {E_INVALID_ARRAY_CREATION, "INVALID ARRAY CREATION"},
- {E_VALUE_OUT_OF_RANGE, "VALUE OUT OF RANGE"},
- {E_CONTENTS_TOO_LONG, "CONTENTS TOO LONG"},
- {E_INVALID_PARAMETERS, "INVALID PARAMETERS"},
- {E_INVALID_MESSAGE_TYPE, "INVALID MESSAGE TYPE"},
- {E_INVALID_FLAGS, "INVALID FLAGS"},
- {E_INVALID_TLV, "INVALID TLV"},
- {E_EVENT_ERROR, "EVENT ERROR"},
- {E_NOT_SUPPORTED, "NOT SUPPORTED"},
- {E_MEMORY_ERROR, "MEMORY ERROR"},
- {E_INTERNAL_ERROR, "INTERNAL ERROR"},
- {E_UNSPECIFIED_ERROR, "UNSPECIFIED ERROR"},
- {0, NULL}
-};
diff --git a/freebsd/contrib/tcpdump/gmpls.c b/freebsd/contrib/tcpdump/gmpls.c
index 8216d658..1427ae31 100644
--- a/freebsd/contrib/tcpdump/gmpls.c
+++ b/freebsd/contrib/tcpdump/gmpls.c
@@ -1,6 +1,9 @@
#include <machine/rtems-bsd-user-space.h>
-
-/*
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
+/*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code
* distributions retain the above copyright notice and this paragraph
@@ -15,18 +18,13 @@
* Original code by Hannes Gredler (hannes@juniper.net)
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/gmpls.c,v 1.7 2006-04-14 07:11:59 hannes Exp $ (LBL)";
-#endif
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "gmpls.h"
/* rfc3471 */
@@ -143,8 +141,8 @@ const struct tok gmpls_payload_values[] = {
{ 0, NULL }
};
-/*
- * Link Type values used by LMP Service Discovery (specifically, the Client
+/*
+ * Link Type values used by LMP Service Discovery (specifically, the Client
* Port Service Attributes Object). See UNI 1.0 section 9.4.2 for details.
*/
const struct tok lmp_sd_service_config_cpsa_link_type_values[] = {
@@ -153,9 +151,9 @@ const struct tok lmp_sd_service_config_cpsa_link_type_values[] = {
{ 0, NULL}
};
-/*
- * Signal Type values for SDH links used by LMP Service Discovery (specifically,
- * the Client Port Service Attributes Object). See UNI 1.0 section 9.4.2 for
+/*
+ * Signal Type values for SDH links used by LMP Service Discovery (specifically,
+ * the Client Port Service Attributes Object). See UNI 1.0 section 9.4.2 for
* details.
*/
const struct tok lmp_sd_service_config_cpsa_signal_type_sdh_values[] = {
@@ -170,9 +168,9 @@ const struct tok lmp_sd_service_config_cpsa_signal_type_sdh_values[] = {
{ 0, NULL}
};
-/*
- * Signal Type values for SONET links used by LMP Service Discovery (specifically,
- * the Client Port Service Attributes Object). See UNI 1.0 section 9.4.2 for
+/*
+ * Signal Type values for SONET links used by LMP Service Discovery (specifically,
+ * the Client Port Service Attributes Object). See UNI 1.0 section 9.4.2 for
* details.
*/
const struct tok lmp_sd_service_config_cpsa_signal_type_sonet_values[] = {
@@ -188,7 +186,7 @@ const struct tok lmp_sd_service_config_cpsa_signal_type_sonet_values[] = {
};
#define DIFFSERV_BC_MODEL_RDM 0 /* draft-ietf-tewg-diff-te-proto-07 */
-#define DIFFSERV_BC_MODEL_MAM 1 /* draft-ietf-tewg-diff-te-proto-07 */
+#define DIFFSERV_BC_MODEL_MAM 1 /* draft-ietf-tewg-diff-te-proto-07 */
#define DIFFSERV_BC_MODEL_EXTD_MAM 254 /* experimental */
const struct tok diffserv_te_bc_values[] = {
@@ -197,3 +195,6 @@ const struct tok diffserv_te_bc_values[] = {
{ DIFFSERV_BC_MODEL_EXTD_MAM, "Maximum allocation with E-LSP support"},
{ 0, NULL }
};
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-gmpls-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/gmpls.h b/freebsd/contrib/tcpdump/gmpls.h
index 8db99dea..8b44f949 100644
--- a/freebsd/contrib/tcpdump/gmpls.h
+++ b/freebsd/contrib/tcpdump/gmpls.h
@@ -1,5 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/gmpls.h,v 1.5 2006-04-14 07:11:59 hannes Exp $ (LBL) */
-/*
+/*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code
* distributions retain the above copyright notice and this paragraph
diff --git a/freebsd/contrib/tcpdump/gmt2local.c b/freebsd/contrib/tcpdump/gmt2local.c
index 6e220919..51c80ab8 100644
--- a/freebsd/contrib/tcpdump/gmt2local.c
+++ b/freebsd/contrib/tcpdump/gmt2local.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1997
* The Regents of the University of California. All rights reserved.
@@ -21,16 +24,11 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/gmt2local.c,v 1.9 2003-11-16 09:36:09 guy Exp $ (LBL)";
-#endif
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <stdio.h>
@@ -71,3 +69,6 @@ gmt2local(time_t t)
return (dt);
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-gmt2local-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/gmt2local.h b/freebsd/contrib/tcpdump/gmt2local.h
index f7b3841e..89254df9 100644
--- a/freebsd/contrib/tcpdump/gmt2local.h
+++ b/freebsd/contrib/tcpdump/gmt2local.h
@@ -17,8 +17,6 @@
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * @(#) $Header: /tcpdump/master/tcpdump/gmt2local.h,v 1.2 1999-10-07 23:47:10 mcr Exp $ (LBL)
*/
#ifndef gmt2local_h
#define gmt2local_h
diff --git a/freebsd/contrib/tcpdump/icmp6.h b/freebsd/contrib/tcpdump/icmp6.h
deleted file mode 100644
index c4d292e5..00000000
--- a/freebsd/contrib/tcpdump/icmp6.h
+++ /dev/null
@@ -1,473 +0,0 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/icmp6.h,v 1.18 2007-08-29 02:31:44 mcr Exp $ (LBL) */
-/* NetBSD: icmp6.h,v 1.13 2000/08/03 16:30:37 itojun Exp */
-/* $KAME: icmp6.h,v 1.22 2000/08/03 15:25:16 jinmei Exp $ */
-
-/*
- * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
- * All rights reserved.
- *
- * 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.
- */
-
-/*
- * Copyright (c) 1982, 1986, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * 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. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
- *
- * @(#)ip_icmp.h 8.1 (Berkeley) 6/10/93
- */
-
-#ifndef _NETINET_ICMP6_H_
-#define _NETINET_ICMP6_H_
-
-struct icmp6_hdr {
- u_int8_t icmp6_type; /* type field */
- u_int8_t icmp6_code; /* code field */
- u_int16_t icmp6_cksum; /* checksum field */
- union {
- u_int32_t icmp6_un_data32[1]; /* type-specific field */
- u_int16_t icmp6_un_data16[2]; /* type-specific field */
- u_int8_t icmp6_un_data8[4]; /* type-specific field */
- } icmp6_dataun;
-};
-
-#define icmp6_data32 icmp6_dataun.icmp6_un_data32
-#define icmp6_data16 icmp6_dataun.icmp6_un_data16
-#define icmp6_data8 icmp6_dataun.icmp6_un_data8
-#define icmp6_pptr icmp6_data32[0] /* parameter prob */
-#define icmp6_mtu icmp6_data32[0] /* packet too big */
-#define icmp6_id icmp6_data16[0] /* echo request/reply */
-#define icmp6_seq icmp6_data16[1] /* echo request/reply */
-#define icmp6_maxdelay icmp6_data16[0] /* mcast group membership */
-
-#define ICMP6_DST_UNREACH 1 /* dest unreachable, codes: */
-#define ICMP6_PACKET_TOO_BIG 2 /* packet too big */
-#define ICMP6_TIME_EXCEEDED 3 /* time exceeded, code: */
-#define ICMP6_PARAM_PROB 4 /* ip6 header bad */
-
-#define ICMP6_ECHO_REQUEST 128 /* echo service */
-#define ICMP6_ECHO_REPLY 129 /* echo reply */
-#define ICMP6_MEMBERSHIP_QUERY 130 /* group membership query */
-#define MLD6_LISTENER_QUERY 130 /* multicast listener query */
-#define ICMP6_MEMBERSHIP_REPORT 131 /* group membership report */
-#define MLD6_LISTENER_REPORT 131 /* multicast listener report */
-#define ICMP6_MEMBERSHIP_REDUCTION 132 /* group membership termination */
-#define MLD6_LISTENER_DONE 132 /* multicast listener done */
-
-#define ND_ROUTER_SOLICIT 133 /* router solicitation */
-#define ND_ROUTER_ADVERT 134 /* router advertisement */
-#define ND_NEIGHBOR_SOLICIT 135 /* neighbor solicitation */
-#define ND_NEIGHBOR_ADVERT 136 /* neighbor advertisement */
-#define ND_REDIRECT 137 /* redirect */
-
-#define ICMP6_ROUTER_RENUMBERING 138 /* router renumbering */
-
-#define ICMP6_WRUREQUEST 139 /* who are you request */
-#define ICMP6_WRUREPLY 140 /* who are you reply */
-#define ICMP6_FQDN_QUERY 139 /* FQDN query */
-#define ICMP6_FQDN_REPLY 140 /* FQDN reply */
-#define ICMP6_NI_QUERY 139 /* node information request */
-#define ICMP6_NI_REPLY 140 /* node information reply */
-#define IND_SOLICIT 141 /* inverse neighbor solicitation */
-#define IND_ADVERT 142 /* inverse neighbor advertisement */
-
-#define ICMP6_V2_MEMBERSHIP_REPORT 143 /* v2 membership report */
-#define MLDV2_LISTENER_REPORT 143 /* v2 multicast listener report */
-#define ICMP6_HADISCOV_REQUEST 144
-#define ICMP6_HADISCOV_REPLY 145
-#define ICMP6_MOBILEPREFIX_SOLICIT 146
-#define ICMP6_MOBILEPREFIX_ADVERT 147
-
-#define MLD6_MTRACE_RESP 200 /* mtrace response(to sender) */
-#define MLD6_MTRACE 201 /* mtrace messages */
-
-#define ICMP6_MAXTYPE 201
-
-#define ICMP6_DST_UNREACH_NOROUTE 0 /* no route to destination */
-#define ICMP6_DST_UNREACH_ADMIN 1 /* administratively prohibited */
-#define ICMP6_DST_UNREACH_NOTNEIGHBOR 2 /* not a neighbor(obsolete) */
-#define ICMP6_DST_UNREACH_BEYONDSCOPE 2 /* beyond scope of source address */
-#define ICMP6_DST_UNREACH_ADDR 3 /* address unreachable */
-#define ICMP6_DST_UNREACH_NOPORT 4 /* port unreachable */
-
-#define ICMP6_TIME_EXCEED_TRANSIT 0 /* ttl==0 in transit */
-#define ICMP6_TIME_EXCEED_REASSEMBLY 1 /* ttl==0 in reass */
-
-#define ICMP6_PARAMPROB_HEADER 0 /* erroneous header field */
-#define ICMP6_PARAMPROB_NEXTHEADER 1 /* unrecognized next header */
-#define ICMP6_PARAMPROB_OPTION 2 /* unrecognized option */
-
-#define ICMP6_INFOMSG_MASK 0x80 /* all informational messages */
-
-#define ICMP6_NI_SUBJ_IPV6 0 /* Query Subject is an IPv6 address */
-#define ICMP6_NI_SUBJ_FQDN 1 /* Query Subject is a Domain name */
-#define ICMP6_NI_SUBJ_IPV4 2 /* Query Subject is an IPv4 address */
-
-#define ICMP6_NI_SUCCESS 0 /* node information successful reply */
-#define ICMP6_NI_REFUSED 1 /* node information request is refused */
-#define ICMP6_NI_UNKNOWN 2 /* unknown Qtype */
-
-#define ICMP6_ROUTER_RENUMBERING_COMMAND 0 /* rr command */
-#define ICMP6_ROUTER_RENUMBERING_RESULT 1 /* rr result */
-#define ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET 255 /* rr seq num reset */
-
-/* Used in kernel only */
-#define ND_REDIRECT_ONLINK 0 /* redirect to an on-link node */
-#define ND_REDIRECT_ROUTER 1 /* redirect to a better router */
-
-/*
- * Multicast Listener Discovery
- */
-struct mld6_hdr {
- struct icmp6_hdr mld6_hdr;
- struct in6_addr mld6_addr; /* multicast address */
-};
-
-#define mld6_type mld6_hdr.icmp6_type
-#define mld6_code mld6_hdr.icmp6_code
-#define mld6_cksum mld6_hdr.icmp6_cksum
-#define mld6_maxdelay mld6_hdr.icmp6_data16[0]
-#define mld6_reserved mld6_hdr.icmp6_data16[1]
-
-#define MLD_MINLEN 24
-#define MLDV2_MINLEN 28
-
-/*
- * Neighbor Discovery
- */
-
-struct nd_router_solicit { /* router solicitation */
- struct icmp6_hdr nd_rs_hdr;
- /* could be followed by options */
-};
-
-#define nd_rs_type nd_rs_hdr.icmp6_type
-#define nd_rs_code nd_rs_hdr.icmp6_code
-#define nd_rs_cksum nd_rs_hdr.icmp6_cksum
-#define nd_rs_reserved nd_rs_hdr.icmp6_data32[0]
-
-struct nd_router_advert { /* router advertisement */
- struct icmp6_hdr nd_ra_hdr;
- u_int32_t nd_ra_reachable; /* reachable time */
- u_int32_t nd_ra_retransmit; /* retransmit timer */
- /* could be followed by options */
-};
-
-#define nd_ra_type nd_ra_hdr.icmp6_type
-#define nd_ra_code nd_ra_hdr.icmp6_code
-#define nd_ra_cksum nd_ra_hdr.icmp6_cksum
-#define nd_ra_curhoplimit nd_ra_hdr.icmp6_data8[0]
-#define nd_ra_flags_reserved nd_ra_hdr.icmp6_data8[1]
-#define ND_RA_FLAG_MANAGED 0x80
-#define ND_RA_FLAG_OTHER 0x40
-#define ND_RA_FLAG_HOME_AGENT 0x20
-
-/*
- * Router preference values based on draft-draves-ipngwg-router-selection-01.
- * These are non-standard definitions.
- */
-#define ND_RA_FLAG_RTPREF_MASK 0x18 /* 00011000 */
-
-#define ND_RA_FLAG_RTPREF_HIGH 0x08 /* 00001000 */
-#define ND_RA_FLAG_RTPREF_MEDIUM 0x00 /* 00000000 */
-#define ND_RA_FLAG_RTPREF_LOW 0x18 /* 00011000 */
-#define ND_RA_FLAG_RTPREF_RSV 0x10 /* 00010000 */
-
-#define nd_ra_router_lifetime nd_ra_hdr.icmp6_data16[1]
-
-struct nd_neighbor_solicit { /* neighbor solicitation */
- struct icmp6_hdr nd_ns_hdr;
- struct in6_addr nd_ns_target; /*target address */
- /* could be followed by options */
-};
-
-#define nd_ns_type nd_ns_hdr.icmp6_type
-#define nd_ns_code nd_ns_hdr.icmp6_code
-#define nd_ns_cksum nd_ns_hdr.icmp6_cksum
-#define nd_ns_reserved nd_ns_hdr.icmp6_data32[0]
-
-struct nd_neighbor_advert { /* neighbor advertisement */
- struct icmp6_hdr nd_na_hdr;
- struct in6_addr nd_na_target; /* target address */
- /* could be followed by options */
-};
-
-#define nd_na_type nd_na_hdr.icmp6_type
-#define nd_na_code nd_na_hdr.icmp6_code
-#define nd_na_cksum nd_na_hdr.icmp6_cksum
-#define nd_na_flags_reserved nd_na_hdr.icmp6_data32[0]
-
-#define ND_NA_FLAG_ROUTER 0x80000000
-#define ND_NA_FLAG_SOLICITED 0x40000000
-#define ND_NA_FLAG_OVERRIDE 0x20000000
-
-struct nd_redirect { /* redirect */
- struct icmp6_hdr nd_rd_hdr;
- struct in6_addr nd_rd_target; /* target address */
- struct in6_addr nd_rd_dst; /* destination address */
- /* could be followed by options */
-};
-
-#define nd_rd_type nd_rd_hdr.icmp6_type
-#define nd_rd_code nd_rd_hdr.icmp6_code
-#define nd_rd_cksum nd_rd_hdr.icmp6_cksum
-#define nd_rd_reserved nd_rd_hdr.icmp6_data32[0]
-
-struct nd_opt_hdr { /* Neighbor discovery option header */
- u_int8_t nd_opt_type;
- u_int8_t nd_opt_len;
- /* followed by option specific data*/
-};
-
-#define ND_OPT_SOURCE_LINKADDR 1
-#define ND_OPT_TARGET_LINKADDR 2
-#define ND_OPT_PREFIX_INFORMATION 3
-#define ND_OPT_REDIRECTED_HEADER 4
-#define ND_OPT_MTU 5
-#define ND_OPT_ADVINTERVAL 7
-#define ND_OPT_HOMEAGENT_INFO 8
-#define ND_OPT_ROUTE_INFO 9 /* draft-ietf-ipngwg-router-preference, not officially assigned yet */
-#define ND_OPT_RDNSS 25
-#define ND_OPT_DNSSL 31
-
-struct nd_opt_prefix_info { /* prefix information */
- u_int8_t nd_opt_pi_type;
- u_int8_t nd_opt_pi_len;
- u_int8_t nd_opt_pi_prefix_len;
- u_int8_t nd_opt_pi_flags_reserved;
- u_int8_t nd_opt_pi_valid_time[4];
- u_int8_t nd_opt_pi_preferred_time[4];
- u_int8_t nd_opt_pi_reserved2[4];
- struct in6_addr nd_opt_pi_prefix;
-};
-
-#define ND_OPT_PI_FLAG_ONLINK 0x80
-#define ND_OPT_PI_FLAG_AUTO 0x40
-#define ND_OPT_PI_FLAG_ROUTER 0x20 /*2292bis*/
-
-struct nd_opt_rd_hdr { /* redirected header */
- u_int8_t nd_opt_rh_type;
- u_int8_t nd_opt_rh_len;
- u_int16_t nd_opt_rh_reserved1;
- u_int32_t nd_opt_rh_reserved2;
- /* followed by IP header and data */
-};
-
-struct nd_opt_mtu { /* MTU option */
- u_int8_t nd_opt_mtu_type;
- u_int8_t nd_opt_mtu_len;
- u_int16_t nd_opt_mtu_reserved;
- u_int32_t nd_opt_mtu_mtu;
-};
-
-struct nd_opt_rdnss { /* RDNSS RFC 6106 5.1 */
- u_int8_t nd_opt_rdnss_type;
- u_int8_t nd_opt_rdnss_len;
- u_int16_t nd_opt_rdnss_reserved;
- u_int32_t nd_opt_rdnss_lifetime;
- struct in6_addr nd_opt_rdnss_addr[1]; /* variable-length */
-};
-
-struct nd_opt_dnssl { /* DNSSL RFC 6106 5.2 */
- u_int8_t nd_opt_dnssl_type;
- u_int8_t nd_opt_dnssl_len;
- u_int16_t nd_opt_dnssl_reserved;
- u_int32_t nd_opt_dnssl_lifetime;
- /* followed by list of DNS search domains, variable-length */
-};
-
-struct nd_opt_advinterval { /* Advertisement interval option */
- u_int8_t nd_opt_adv_type;
- u_int8_t nd_opt_adv_len;
- u_int16_t nd_opt_adv_reserved;
- u_int32_t nd_opt_adv_interval;
-};
-
-struct nd_opt_homeagent_info { /* Home Agent info */
- u_int8_t nd_opt_hai_type;
- u_int8_t nd_opt_hai_len;
- u_int16_t nd_opt_hai_reserved;
- int16_t nd_opt_hai_preference;
- u_int16_t nd_opt_hai_lifetime;
-};
-
-struct nd_opt_route_info { /* route info */
- u_int8_t nd_opt_rti_type;
- u_int8_t nd_opt_rti_len;
- u_int8_t nd_opt_rti_prefixlen;
- u_int8_t nd_opt_rti_flags;
- u_int32_t nd_opt_rti_lifetime;
- /* prefix follows */
-};
-
-/*
- * icmp6 namelookup
- */
-
-struct icmp6_namelookup {
- struct icmp6_hdr icmp6_nl_hdr;
- u_int8_t icmp6_nl_nonce[8];
- int32_t icmp6_nl_ttl;
-#if 0
- u_int8_t icmp6_nl_len;
- u_int8_t icmp6_nl_name[3];
-#endif
- /* could be followed by options */
-};
-
-/*
- * icmp6 node information
- */
-struct icmp6_nodeinfo {
- struct icmp6_hdr icmp6_ni_hdr;
- u_int8_t icmp6_ni_nonce[8];
- /* could be followed by reply data */
-};
-
-#define ni_type icmp6_ni_hdr.icmp6_type
-#define ni_code icmp6_ni_hdr.icmp6_code
-#define ni_cksum icmp6_ni_hdr.icmp6_cksum
-#define ni_qtype icmp6_ni_hdr.icmp6_data16[0]
-#define ni_flags icmp6_ni_hdr.icmp6_data16[1]
-
-#define NI_QTYPE_NOOP 0 /* NOOP */
-#define NI_QTYPE_SUPTYPES 1 /* Supported Qtypes */
-#define NI_QTYPE_FQDN 2 /* FQDN (draft 04) */
-#define NI_QTYPE_DNSNAME 2 /* DNS Name */
-#define NI_QTYPE_NODEADDR 3 /* Node Addresses */
-#define NI_QTYPE_IPV4ADDR 4 /* IPv4 Addresses */
-
-/* network endian */
-#define NI_SUPTYPE_FLAG_COMPRESS ((u_int16_t)htons(0x1))
-#define NI_FQDN_FLAG_VALIDTTL ((u_int16_t)htons(0x1))
-
-/* network endian */
-#define NI_NODEADDR_FLAG_TRUNCATE ((u_int16_t)htons(0x1))
-#define NI_NODEADDR_FLAG_ALL ((u_int16_t)htons(0x2))
-#define NI_NODEADDR_FLAG_COMPAT ((u_int16_t)htons(0x4))
-#define NI_NODEADDR_FLAG_LINKLOCAL ((u_int16_t)htons(0x8))
-#define NI_NODEADDR_FLAG_SITELOCAL ((u_int16_t)htons(0x10))
-#define NI_NODEADDR_FLAG_GLOBAL ((u_int16_t)htons(0x20))
-#define NI_NODEADDR_FLAG_ANYCAST ((u_int16_t)htons(0x40)) /* just experimental. not in spec */
-
-struct ni_reply_fqdn {
- u_int32_t ni_fqdn_ttl; /* TTL */
- u_int8_t ni_fqdn_namelen; /* length in octets of the FQDN */
- u_int8_t ni_fqdn_name[3]; /* XXX: alignment */
-};
-
-/*
- * Router Renumbering. as router-renum-08.txt
- */
-struct icmp6_router_renum { /* router renumbering header */
- struct icmp6_hdr rr_hdr;
- u_int8_t rr_segnum;
- u_int8_t rr_flags;
- u_int16_t rr_maxdelay;
- u_int32_t rr_reserved;
-};
-#define ICMP6_RR_FLAGS_TEST 0x80
-#define ICMP6_RR_FLAGS_REQRESULT 0x40
-#define ICMP6_RR_FLAGS_FORCEAPPLY 0x20
-#define ICMP6_RR_FLAGS_SPECSITE 0x10
-#define ICMP6_RR_FLAGS_PREVDONE 0x08
-
-#define rr_type rr_hdr.icmp6_type
-#define rr_code rr_hdr.icmp6_code
-#define rr_cksum rr_hdr.icmp6_cksum
-#define rr_seqnum rr_hdr.icmp6_data32[0]
-
-struct rr_pco_match { /* match prefix part */
- u_int8_t rpm_code;
- u_int8_t rpm_len;
- u_int8_t rpm_ordinal;
- u_int8_t rpm_matchlen;
- u_int8_t rpm_minlen;
- u_int8_t rpm_maxlen;
- u_int16_t rpm_reserved;
- struct in6_addr rpm_prefix;
-};
-
-#define RPM_PCO_ADD 1
-#define RPM_PCO_CHANGE 2
-#define RPM_PCO_SETGLOBAL 3
-#define RPM_PCO_MAX 4
-
-struct rr_pco_use { /* use prefix part */
- u_int8_t rpu_uselen;
- u_int8_t rpu_keeplen;
- u_int8_t rpu_ramask;
- u_int8_t rpu_raflags;
- u_int32_t rpu_vltime;
- u_int32_t rpu_pltime;
- u_int32_t rpu_flags;
- struct in6_addr rpu_prefix;
-};
-#define ICMP6_RR_PCOUSE_RAFLAGS_ONLINK 0x80
-#define ICMP6_RR_PCOUSE_RAFLAGS_AUTO 0x40
-
-/* network endian */
-#define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME ((u_int32_t)htonl(0x80000000))
-#define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME ((u_int32_t)htonl(0x40000000))
-
-struct rr_result { /* router renumbering result message */
- u_int16_t rrr_flags;
- u_int8_t rrr_ordinal;
- u_int8_t rrr_matchedlen;
- u_int32_t rrr_ifid;
- struct in6_addr rrr_prefix;
-};
-/* network endian */
-#define ICMP6_RR_RESULT_FLAGS_OOB ((u_int16_t)htons(0x0002))
-#define ICMP6_RR_RESULT_FLAGS_FORBIDDEN ((u_int16_t)htons(0x0001))
-
-#endif /* not _NETINET_ICMP6_H_ */
diff --git a/freebsd/contrib/tcpdump/ieee802_11.h b/freebsd/contrib/tcpdump/ieee802_11.h
deleted file mode 100644
index 2aa13450..00000000
--- a/freebsd/contrib/tcpdump/ieee802_11.h
+++ /dev/null
@@ -1,347 +0,0 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/ieee802_11.h,v 1.12 2007-07-22 19:59:06 guy Exp $ (LBL) */
-/*
- * Copyright (c) 2001
- * Fortress Technologies
- * Charlie Lenahan ( clenahan@fortresstech.com )
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that: (1) source code distributions
- * retain the above copyright notice and this paragraph in its entirety, (2)
- * distributions including binary code include the above copyright notice and
- * this paragraph in its entirety in the documentation or other materials
- * provided with the distribution, and (3) all advertising materials mentioning
- * features or use of this software display the following acknowledgement:
- * ``This product includes software developed by the University of California,
- * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
- * the University 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 ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-/* Lengths of 802.11 header components. */
-#define IEEE802_11_FC_LEN 2
-#define IEEE802_11_DUR_LEN 2
-#define IEEE802_11_DA_LEN 6
-#define IEEE802_11_SA_LEN 6
-#define IEEE802_11_BSSID_LEN 6
-#define IEEE802_11_RA_LEN 6
-#define IEEE802_11_TA_LEN 6
-#define IEEE802_11_SEQ_LEN 2
-#define IEEE802_11_CTL_LEN 2
-#define IEEE802_11_IV_LEN 3
-#define IEEE802_11_KID_LEN 1
-
-/* Frame check sequence length. */
-#define IEEE802_11_FCS_LEN 4
-
-/* Lengths of beacon components. */
-#define IEEE802_11_TSTAMP_LEN 8
-#define IEEE802_11_BCNINT_LEN 2
-#define IEEE802_11_CAPINFO_LEN 2
-#define IEEE802_11_LISTENINT_LEN 2
-
-#define IEEE802_11_AID_LEN 2
-#define IEEE802_11_STATUS_LEN 2
-#define IEEE802_11_REASON_LEN 2
-
-/* Length of previous AP in reassocation frame */
-#define IEEE802_11_AP_LEN 6
-
-#define T_MGMT 0x0 /* management */
-#define T_CTRL 0x1 /* control */
-#define T_DATA 0x2 /* data */
-#define T_RESV 0x3 /* reserved */
-
-#define ST_ASSOC_REQUEST 0x0
-#define ST_ASSOC_RESPONSE 0x1
-#define ST_REASSOC_REQUEST 0x2
-#define ST_REASSOC_RESPONSE 0x3
-#define ST_PROBE_REQUEST 0x4
-#define ST_PROBE_RESPONSE 0x5
-/* RESERVED 0x6 */
-/* RESERVED 0x7 */
-#define ST_BEACON 0x8
-#define ST_ATIM 0x9
-#define ST_DISASSOC 0xA
-#define ST_AUTH 0xB
-#define ST_DEAUTH 0xC
-#define ST_ACTION 0xD
-/* RESERVED 0xE */
-/* RESERVED 0xF */
-
-
-#define CTRL_CONTROL_WRAPPER 0x7
-#define CTRL_BAR 0x8
-#define CTRL_BA 0x9
-#define CTRL_PS_POLL 0xA
-#define CTRL_RTS 0xB
-#define CTRL_CTS 0xC
-#define CTRL_ACK 0xD
-#define CTRL_CF_END 0xE
-#define CTRL_END_ACK 0xF
-
-#define DATA_DATA 0x0
-#define DATA_DATA_CF_ACK 0x1
-#define DATA_DATA_CF_POLL 0x2
-#define DATA_DATA_CF_ACK_POLL 0x3
-#define DATA_NODATA 0x4
-#define DATA_NODATA_CF_ACK 0x5
-#define DATA_NODATA_CF_POLL 0x6
-#define DATA_NODATA_CF_ACK_POLL 0x7
-
-#define DATA_QOS_DATA 0x8
-#define DATA_QOS_DATA_CF_ACK 0x9
-#define DATA_QOS_DATA_CF_POLL 0xA
-#define DATA_QOS_DATA_CF_ACK_POLL 0xB
-#define DATA_QOS_NODATA 0xC
-#define DATA_QOS_CF_POLL_NODATA 0xE
-#define DATA_QOS_CF_ACK_POLL_NODATA 0xF
-
-/*
- * The subtype field of a data frame is, in effect, composed of 4 flag
- * bits - CF-Ack, CF-Poll, Null (means the frame doesn't actually have
- * any data), and QoS.
- */
-#define DATA_FRAME_IS_CF_ACK(x) ((x) & 0x01)
-#define DATA_FRAME_IS_CF_POLL(x) ((x) & 0x02)
-#define DATA_FRAME_IS_NULL(x) ((x) & 0x04)
-#define DATA_FRAME_IS_QOS(x) ((x) & 0x08)
-
-/*
- * Bits in the frame control field.
- */
-#define FC_VERSION(fc) ((fc) & 0x3)
-#define FC_TYPE(fc) (((fc) >> 2) & 0x3)
-#define FC_SUBTYPE(fc) (((fc) >> 4) & 0xF)
-#define FC_TO_DS(fc) ((fc) & 0x0100)
-#define FC_FROM_DS(fc) ((fc) & 0x0200)
-#define FC_MORE_FLAG(fc) ((fc) & 0x0400)
-#define FC_RETRY(fc) ((fc) & 0x0800)
-#define FC_POWER_MGMT(fc) ((fc) & 0x1000)
-#define FC_MORE_DATA(fc) ((fc) & 0x2000)
-#define FC_WEP(fc) ((fc) & 0x4000)
-#define FC_ORDER(fc) ((fc) & 0x8000)
-
-struct mgmt_header_t {
- u_int16_t fc;
- u_int16_t duration;
- u_int8_t da[6];
- u_int8_t sa[6];
- u_int8_t bssid[6];
- u_int16_t seq_ctrl;
-};
-
-#define MGMT_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
- IEEE802_11_DA_LEN+IEEE802_11_SA_LEN+\
- IEEE802_11_BSSID_LEN+IEEE802_11_SEQ_LEN)
-
-#define CAPABILITY_ESS(cap) ((cap) & 0x0001)
-#define CAPABILITY_IBSS(cap) ((cap) & 0x0002)
-#define CAPABILITY_CFP(cap) ((cap) & 0x0004)
-#define CAPABILITY_CFP_REQ(cap) ((cap) & 0x0008)
-#define CAPABILITY_PRIVACY(cap) ((cap) & 0x0010)
-
-struct ssid_t {
- u_int8_t element_id;
- u_int8_t length;
- u_char ssid[33]; /* 32 + 1 for null */
-};
-
-struct rates_t {
- u_int8_t element_id;
- u_int8_t length;
- u_int8_t rate[16];
-};
-
-struct challenge_t {
- u_int8_t element_id;
- u_int8_t length;
- u_int8_t text[254]; /* 1-253 + 1 for null */
-};
-
-struct fh_t {
- u_int8_t element_id;
- u_int8_t length;
- u_int16_t dwell_time;
- u_int8_t hop_set;
- u_int8_t hop_pattern;
- u_int8_t hop_index;
-};
-
-struct ds_t {
- u_int8_t element_id;
- u_int8_t length;
- u_int8_t channel;
-};
-
-struct cf_t {
- u_int8_t element_id;
- u_int8_t length;
- u_int8_t count;
- u_int8_t period;
- u_int16_t max_duration;
- u_int16_t dur_remaing;
-};
-
-struct tim_t {
- u_int8_t element_id;
- u_int8_t length;
- u_int8_t count;
- u_int8_t period;
- u_int8_t bitmap_control;
- u_int8_t bitmap[251];
-};
-
-#define E_SSID 0
-#define E_RATES 1
-#define E_FH 2
-#define E_DS 3
-#define E_CF 4
-#define E_TIM 5
-#define E_IBSS 6
-/* reserved 7 */
-/* reserved 8 */
-/* reserved 9 */
-/* reserved 10 */
-/* reserved 11 */
-/* reserved 12 */
-/* reserved 13 */
-/* reserved 14 */
-/* reserved 15 */
-/* reserved 16 */
-
-#define E_CHALLENGE 16
-/* reserved 17 */
-/* reserved 18 */
-/* reserved 19 */
-/* reserved 16 */
-/* reserved 16 */
-
-
-struct mgmt_body_t {
- u_int8_t timestamp[IEEE802_11_TSTAMP_LEN];
- u_int16_t beacon_interval;
- u_int16_t listen_interval;
- u_int16_t status_code;
- u_int16_t aid;
- u_char ap[IEEE802_11_AP_LEN];
- u_int16_t reason_code;
- u_int16_t auth_alg;
- u_int16_t auth_trans_seq_num;
- int challenge_present;
- struct challenge_t challenge;
- u_int16_t capability_info;
- int ssid_present;
- struct ssid_t ssid;
- int rates_present;
- struct rates_t rates;
- int ds_present;
- struct ds_t ds;
- int cf_present;
- struct cf_t cf;
- int fh_present;
- struct fh_t fh;
- int tim_present;
- struct tim_t tim;
-};
-
-struct ctrl_rts_t {
- u_int16_t fc;
- u_int16_t duration;
- u_int8_t ra[6];
- u_int8_t ta[6];
- u_int8_t fcs[4];
-};
-
-#define CTRL_RTS_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
- IEEE802_11_RA_LEN+IEEE802_11_TA_LEN)
-
-struct ctrl_cts_t {
- u_int16_t fc;
- u_int16_t duration;
- u_int8_t ra[6];
- u_int8_t fcs[4];
-};
-
-#define CTRL_CTS_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+IEEE802_11_RA_LEN)
-
-struct ctrl_ack_t {
- u_int16_t fc;
- u_int16_t duration;
- u_int8_t ra[6];
- u_int8_t fcs[4];
-};
-
-#define CTRL_ACK_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+IEEE802_11_RA_LEN)
-
-struct ctrl_ps_poll_t {
- u_int16_t fc;
- u_int16_t aid;
- u_int8_t bssid[6];
- u_int8_t ta[6];
- u_int8_t fcs[4];
-};
-
-#define CTRL_PS_POLL_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_AID_LEN+\
- IEEE802_11_BSSID_LEN+IEEE802_11_TA_LEN)
-
-struct ctrl_end_t {
- u_int16_t fc;
- u_int16_t duration;
- u_int8_t ra[6];
- u_int8_t bssid[6];
- u_int8_t fcs[4];
-};
-
-#define CTRL_END_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
- IEEE802_11_RA_LEN+IEEE802_11_BSSID_LEN)
-
-struct ctrl_end_ack_t {
- u_int16_t fc;
- u_int16_t duration;
- u_int8_t ra[6];
- u_int8_t bssid[6];
- u_int8_t fcs[4];
-};
-
-#define CTRL_END_ACK_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
- IEEE802_11_RA_LEN+IEEE802_11_BSSID_LEN)
-
-struct ctrl_ba_t {
- u_int16_t fc;
- u_int16_t duration;
- u_int8_t ra[6];
- u_int8_t fcs[4];
-};
-
-#define CTRL_BA_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+IEEE802_11_RA_LEN)
-
-struct ctrl_bar_t {
- u_int16_t fc;
- u_int16_t dur;
- u_int8_t ra[6];
- u_int8_t ta[6];
- u_int16_t ctl;
- u_int16_t seq;
- u_int8_t fcs[4];
-};
-
-#define CTRL_BAR_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
- IEEE802_11_RA_LEN+IEEE802_11_TA_LEN+\
- IEEE802_11_CTL_LEN+IEEE802_11_SEQ_LEN)
-
-struct meshcntl_t {
- u_int8_t flags;
- u_int8_t ttl;
- u_int8_t seq[4];
- u_int8_t addr4[6];
- u_int8_t addr5[6];
- u_int8_t addr6[6];
-};
-
-#define IV_IV(iv) ((iv) & 0xFFFFFF)
-#define IV_PAD(iv) (((iv) >> 24) & 0x3F)
-#define IV_KEYID(iv) (((iv) >> 30) & 0x03)
diff --git a/freebsd/contrib/tcpdump/ieee802_11_radio.h b/freebsd/contrib/tcpdump/ieee802_11_radio.h
deleted file mode 100644
index 812b5ac3..00000000
--- a/freebsd/contrib/tcpdump/ieee802_11_radio.h
+++ /dev/null
@@ -1,291 +0,0 @@
-/* $FreeBSD$ */
-/* NetBSD: ieee802_11_radio.h,v 1.2 2006/02/26 03:04:03 dyoung Exp */
-/* $Header: /tcpdump/master/tcpdump/ieee802_11_radio.h,v 1.3 2007-08-29 02:31:44 mcr Exp $ */
-
-/*-
- * Copyright (c) 2003, 2004 David Young. All rights reserved.
- *
- * 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. The name of David Young may not be used to endorse or promote
- * products derived from this software without specific prior
- * written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY DAVID YOUNG ``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 DAVID
- * YOUNG 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.
- */
-#ifndef _NET_IF_IEEE80211RADIOTAP_H_
-#define _NET_IF_IEEE80211RADIOTAP_H_
-
-/* A generic radio capture format is desirable. It must be
- * rigidly defined (e.g., units for fields should be given),
- * and easily extensible.
- *
- * The following is an extensible radio capture format. It is
- * based on a bitmap indicating which fields are present.
- *
- * I am trying to describe precisely what the application programmer
- * should expect in the following, and for that reason I tell the
- * units and origin of each measurement (where it applies), or else I
- * use sufficiently weaselly language ("is a monotonically nondecreasing
- * function of...") that I cannot set false expectations for lawyerly
- * readers.
- */
-
-/*
- * The radio capture header precedes the 802.11 header.
- *
- * Note well: all radiotap fields are little-endian.
- */
-struct ieee80211_radiotap_header {
- u_int8_t it_version; /* Version 0. Only increases
- * for drastic changes,
- * introduction of compatible
- * new fields does not count.
- */
- u_int8_t it_pad;
- u_int16_t it_len; /* length of the whole
- * header in bytes, including
- * it_version, it_pad,
- * it_len, and data fields.
- */
- u_int32_t it_present; /* A bitmap telling which
- * fields are present. Set bit 31
- * (0x80000000) to extend the
- * bitmap by another 32 bits.
- * Additional extensions are made
- * by setting bit 31.
- */
-};
-
-/* Name Data type Units
- * ---- --------- -----
- *
- * IEEE80211_RADIOTAP_TSFT u_int64_t microseconds
- *
- * Value in microseconds of the MAC's 64-bit 802.11 Time
- * Synchronization Function timer when the first bit of the
- * MPDU arrived at the MAC. For received frames, only.
- *
- * IEEE80211_RADIOTAP_CHANNEL 2 x u_int16_t MHz, bitmap
- *
- * Tx/Rx frequency in MHz, followed by flags (see below).
- * Note that IEEE80211_RADIOTAP_XCHANNEL must be used to
- * represent an HT channel as there is not enough room in
- * the flags word.
- *
- * IEEE80211_RADIOTAP_FHSS u_int16_t see below
- *
- * For frequency-hopping radios, the hop set (first byte)
- * and pattern (second byte).
- *
- * IEEE80211_RADIOTAP_RATE u_int8_t 500kb/s or index
- *
- * Tx/Rx data rate. If bit 0x80 is set then it represents an
- * an MCS index and not an IEEE rate.
- *
- * IEEE80211_RADIOTAP_DBM_ANTSIGNAL int8_t decibels from
- * one milliwatt (dBm)
- *
- * RF signal power at the antenna, decibel difference from
- * one milliwatt.
- *
- * IEEE80211_RADIOTAP_DBM_ANTNOISE int8_t decibels from
- * one milliwatt (dBm)
- *
- * RF noise power at the antenna, decibel difference from one
- * milliwatt.
- *
- * IEEE80211_RADIOTAP_DB_ANTSIGNAL u_int8_t decibel (dB)
- *
- * RF signal power at the antenna, decibel difference from an
- * arbitrary, fixed reference.
- *
- * IEEE80211_RADIOTAP_DB_ANTNOISE u_int8_t decibel (dB)
- *
- * RF noise power at the antenna, decibel difference from an
- * arbitrary, fixed reference point.
- *
- * IEEE80211_RADIOTAP_LOCK_QUALITY u_int16_t unitless
- *
- * Quality of Barker code lock. Unitless. Monotonically
- * nondecreasing with "better" lock strength. Called "Signal
- * Quality" in datasheets. (Is there a standard way to measure
- * this?)
- *
- * IEEE80211_RADIOTAP_TX_ATTENUATION u_int16_t unitless
- *
- * Transmit power expressed as unitless distance from max
- * power set at factory calibration. 0 is max power.
- * Monotonically nondecreasing with lower power levels.
- *
- * IEEE80211_RADIOTAP_DB_TX_ATTENUATION u_int16_t decibels (dB)
- *
- * Transmit power expressed as decibel distance from max power
- * set at factory calibration. 0 is max power. Monotonically
- * nondecreasing with lower power levels.
- *
- * IEEE80211_RADIOTAP_DBM_TX_POWER int8_t decibels from
- * one milliwatt (dBm)
- *
- * Transmit power expressed as dBm (decibels from a 1 milliwatt
- * reference). This is the absolute power level measured at
- * the antenna port.
- *
- * IEEE80211_RADIOTAP_FLAGS u_int8_t bitmap
- *
- * Properties of transmitted and received frames. See flags
- * defined below.
- *
- * IEEE80211_RADIOTAP_ANTENNA u_int8_t antenna index
- *
- * Unitless indication of the Rx/Tx antenna for this packet.
- * The first antenna is antenna 0.
- *
- * IEEE80211_RADIOTAP_RX_FLAGS u_int16_t bitmap
- *
- * Properties of received frames. See flags defined below.
- *
- * IEEE80211_RADIOTAP_XCHANNEL u_int32_t bitmap
- * u_int16_t MHz
- * u_int8_t channel number
- * u_int8_t .5 dBm
- *
- * Extended channel specification: flags (see below) followed by
- * frequency in MHz, the corresponding IEEE channel number, and
- * finally the maximum regulatory transmit power cap in .5 dBm
- * units. This property supersedes IEEE80211_RADIOTAP_CHANNEL
- * and only one of the two should be present.
- *
- * IEEE80211_RADIOTAP_MCS u_int8_t known
- * u_int8_t flags
- * u_int8_t mcs
- *
- * Bitset indicating which fields have known values, followed
- * by bitset of flag values, followed by the MCS rate index as
- * in IEEE 802.11n.
- *
- * IEEE80211_RADIOTAP_VENDOR_NAMESPACE
- * u_int8_t OUI[3]
- * u_int8_t subspace
- * u_int16_t length
- *
- * The Vendor Namespace Field contains three sub-fields. The first
- * sub-field is 3 bytes long. It contains the vendor's IEEE 802
- * Organizationally Unique Identifier (OUI). The fourth byte is a
- * vendor-specific "namespace selector."
- *
- */
-enum ieee80211_radiotap_type {
- IEEE80211_RADIOTAP_TSFT = 0,
- IEEE80211_RADIOTAP_FLAGS = 1,
- IEEE80211_RADIOTAP_RATE = 2,
- IEEE80211_RADIOTAP_CHANNEL = 3,
- IEEE80211_RADIOTAP_FHSS = 4,
- IEEE80211_RADIOTAP_DBM_ANTSIGNAL = 5,
- IEEE80211_RADIOTAP_DBM_ANTNOISE = 6,
- IEEE80211_RADIOTAP_LOCK_QUALITY = 7,
- IEEE80211_RADIOTAP_TX_ATTENUATION = 8,
- IEEE80211_RADIOTAP_DB_TX_ATTENUATION = 9,
- IEEE80211_RADIOTAP_DBM_TX_POWER = 10,
- IEEE80211_RADIOTAP_ANTENNA = 11,
- IEEE80211_RADIOTAP_DB_ANTSIGNAL = 12,
- IEEE80211_RADIOTAP_DB_ANTNOISE = 13,
- IEEE80211_RADIOTAP_RX_FLAGS = 14,
- /* NB: gap for netbsd definitions */
- IEEE80211_RADIOTAP_XCHANNEL = 18,
- IEEE80211_RADIOTAP_MCS = 19,
- IEEE80211_RADIOTAP_NAMESPACE = 29,
- IEEE80211_RADIOTAP_VENDOR_NAMESPACE = 30,
- IEEE80211_RADIOTAP_EXT = 31
-};
-
-/* channel attributes */
-#define IEEE80211_CHAN_TURBO 0x00010 /* Turbo channel */
-#define IEEE80211_CHAN_CCK 0x00020 /* CCK channel */
-#define IEEE80211_CHAN_OFDM 0x00040 /* OFDM channel */
-#define IEEE80211_CHAN_2GHZ 0x00080 /* 2 GHz spectrum channel. */
-#define IEEE80211_CHAN_5GHZ 0x00100 /* 5 GHz spectrum channel */
-#define IEEE80211_CHAN_PASSIVE 0x00200 /* Only passive scan allowed */
-#define IEEE80211_CHAN_DYN 0x00400 /* Dynamic CCK-OFDM channel */
-#define IEEE80211_CHAN_GFSK 0x00800 /* GFSK channel (FHSS PHY) */
-#define IEEE80211_CHAN_GSM 0x01000 /* 900 MHz spectrum channel */
-#define IEEE80211_CHAN_STURBO 0x02000 /* 11a static turbo channel only */
-#define IEEE80211_CHAN_HALF 0x04000 /* Half rate channel */
-#define IEEE80211_CHAN_QUARTER 0x08000 /* Quarter rate channel */
-#define IEEE80211_CHAN_HT20 0x10000 /* HT 20 channel */
-#define IEEE80211_CHAN_HT40U 0x20000 /* HT 40 channel w/ ext above */
-#define IEEE80211_CHAN_HT40D 0x40000 /* HT 40 channel w/ ext below */
-
-/* Useful combinations of channel characteristics, borrowed from Ethereal */
-#define IEEE80211_CHAN_A \
- (IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_OFDM)
-#define IEEE80211_CHAN_B \
- (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_CCK)
-#define IEEE80211_CHAN_G \
- (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_DYN)
-#define IEEE80211_CHAN_TA \
- (IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_OFDM | IEEE80211_CHAN_TURBO)
-#define IEEE80211_CHAN_TG \
- (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_DYN | IEEE80211_CHAN_TURBO)
-
-
-/* For IEEE80211_RADIOTAP_FLAGS */
-#define IEEE80211_RADIOTAP_F_CFP 0x01 /* sent/received
- * during CFP
- */
-#define IEEE80211_RADIOTAP_F_SHORTPRE 0x02 /* sent/received
- * with short
- * preamble
- */
-#define IEEE80211_RADIOTAP_F_WEP 0x04 /* sent/received
- * with WEP encryption
- */
-#define IEEE80211_RADIOTAP_F_FRAG 0x08 /* sent/received
- * with fragmentation
- */
-#define IEEE80211_RADIOTAP_F_FCS 0x10 /* frame includes FCS */
-#define IEEE80211_RADIOTAP_F_DATAPAD 0x20 /* frame has padding between
- * 802.11 header and payload
- * (to 32-bit boundary)
- */
-#define IEEE80211_RADIOTAP_F_BADFCS 0x40 /* does not pass FCS check */
-
-/* For IEEE80211_RADIOTAP_RX_FLAGS */
-#define IEEE80211_RADIOTAP_F_RX_BADFCS 0x0001 /* frame failed crc check */
-#define IEEE80211_RADIOTAP_F_RX_PLCP_CRC 0x0002 /* frame failed PLCP CRC check */
-
-/* For IEEE80211_RADIOTAP_MCS known */
-#define IEEE80211_RADIOTAP_MCS_BANDWIDTH_KNOWN 0x01
-#define IEEE80211_RADIOTAP_MCS_MCS_INDEX_KNOWN 0x02 /* MCS index field */
-#define IEEE80211_RADIOTAP_MCS_GUARD_INTERVAL_KNOWN 0x04
-#define IEEE80211_RADIOTAP_MCS_HT_FORMAT_KNOWN 0x08
-#define IEEE80211_RADIOTAP_MCS_FEC_TYPE_KNOWN 0x10
-
-/* For IEEE80211_RADIOTAP_MCS flags */
-#define IEEE80211_RADIOTAP_MCS_BANDWIDTH_MASK 0x03
-#define IEEE80211_RADIOTAP_MCS_BANDWIDTH_20 0
-#define IEEE80211_RADIOTAP_MCS_BANDWIDTH_40 1
-#define IEEE80211_RADIOTAP_MCS_BANDWIDTH_20L 2
-#define IEEE80211_RADIOTAP_MCS_BANDWIDTH_20U 3
-#define IEEE80211_RADIOTAP_MCS_SHORT_GI 0x04 /* short guard interval */
-#define IEEE80211_RADIOTAP_MCS_HT_GREENFIELD 0x08
-#define IEEE80211_RADIOTAP_MCS_FEC_LDPC 0x10
-
-#endif /* _NET_IF_IEEE80211RADIOTAP_H_ */
diff --git a/freebsd/contrib/tcpdump/igrp.h b/freebsd/contrib/tcpdump/igrp.h
deleted file mode 100644
index b5f133bc..00000000
--- a/freebsd/contrib/tcpdump/igrp.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/igrp.h,v 1.6 2002-12-11 07:13:52 guy Exp $ (LBL) */
-/* Cisco IGRP definitions */
-
-/* IGRP Header */
-
-struct igrphdr {
- u_int8_t ig_vop; /* protocol version number / opcode */
-#define IGRP_V(x) (((x) & 0xf0) >> 4)
-#define IGRP_OP(x) ((x) & 0x0f)
- u_int8_t ig_ed; /* edition number */
- u_int16_t ig_as; /* autonomous system number */
- u_int16_t ig_ni; /* number of subnet in local net */
- u_int16_t ig_ns; /* number of networks in AS */
- u_int16_t ig_nx; /* number of networks ouside AS */
- u_int16_t ig_sum; /* checksum of IGRP header & data */
-};
-
-#define IGRP_UPDATE 1
-#define IGRP_REQUEST 2
-
-/* IGRP routing entry */
-
-struct igrprte {
- u_int8_t igr_net[3]; /* 3 significant octets of IP address */
- u_int8_t igr_dly[3]; /* delay in tens of microseconds */
- u_int8_t igr_bw[3]; /* bandwidth in units of 1 kb/s */
- u_int8_t igr_mtu[2]; /* MTU in octets */
- u_int8_t igr_rel; /* percent packets successfully tx/rx */
- u_int8_t igr_ld; /* percent of channel occupied */
- u_int8_t igr_hct; /* hop count */
-};
-
-#define IGRP_RTE_SIZE 14 /* don't believe sizeof ! */
diff --git a/freebsd/contrib/tcpdump/in_cksum.c b/freebsd/contrib/tcpdump/in_cksum.c
index bfd6be98..36d7afe2 100644
--- a/freebsd/contrib/tcpdump/in_cksum.c
+++ b/freebsd/contrib/tcpdump/in_cksum.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/* in_cksum.c
* 4.4-Lite-2 Internet checksum routine, modified to take a vector of
* pointers/lengths giving the pieces to be checksummed. Also using
@@ -41,9 +44,9 @@
# include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
/*
* Checksum routine for Internet Protocol family headers (Portable Version).
@@ -55,27 +58,27 @@
#define ADDCARRY(x) {if ((x) > 65535) (x) -= 65535;}
#define REDUCE {l_util.l = sum; sum = l_util.s[0] + l_util.s[1]; ADDCARRY(sum);}
-u_int16_t
+uint16_t
in_cksum(const struct cksum_vec *vec, int veclen)
{
- register const u_int16_t *w;
+ register const uint16_t *w;
register int sum = 0;
register int mlen = 0;
int byte_swapped = 0;
union {
- u_int8_t c[2];
- u_int16_t s;
+ uint8_t c[2];
+ uint16_t s;
} s_util;
union {
- u_int16_t s[2];
- u_int32_t l;
+ uint16_t s[2];
+ uint32_t l;
} l_util;
for (; veclen != 0; vec++, veclen--) {
if (vec->len == 0)
continue;
- w = (const u_int16_t *)(void *)vec->ptr;
+ w = (const uint16_t *)(const void *)vec->ptr;
if (mlen == -1) {
/*
* The first byte of this chunk is the continuation
@@ -85,20 +88,20 @@ in_cksum(const struct cksum_vec *vec, int veclen)
* s_util.c[0] is already saved when scanning previous
* chunk.
*/
- s_util.c[1] = *(const u_int8_t *)w;
+ s_util.c[1] = *(const uint8_t *)w;
sum += s_util.s;
- w = (const u_int16_t *)(void *)((const u_int8_t *)w + 1);
+ w = (const uint16_t *)(const void *)((const uint8_t *)w + 1);
mlen = vec->len - 1;
} else
mlen = vec->len;
/*
* Force to even boundary.
*/
- if ((1 & (unsigned long) w) && (mlen > 0)) {
+ if ((1 & (uintptr_t) w) && (mlen > 0)) {
REDUCE;
sum <<= 8;
- s_util.c[0] = *(const u_int8_t *)w;
- w = (const u_int16_t *)(void *)((const u_int8_t *)w + 1);
+ s_util.c[0] = *(const uint8_t *)w;
+ w = (const uint16_t *)(const void *)((const uint8_t *)w + 1);
mlen--;
byte_swapped = 1;
}
@@ -130,13 +133,13 @@ in_cksum(const struct cksum_vec *vec, int veclen)
sum <<= 8;
byte_swapped = 0;
if (mlen == -1) {
- s_util.c[1] = *(const u_int8_t *)w;
+ s_util.c[1] = *(const uint8_t *)w;
sum += s_util.s;
mlen = 0;
} else
mlen = -1;
} else if (mlen == -1)
- s_util.c[0] = *(const u_int8_t *)w;
+ s_util.c[0] = *(const uint8_t *)w;
}
if (mlen == -1) {
/* The last mbuf has odd # of bytes. Follow the
@@ -155,10 +158,10 @@ in_cksum(const struct cksum_vec *vec, int veclen)
* that the checksum covers (including the checksum itself), compute
* what the checksum field *should* have been.
*/
-u_int16_t
-in_cksum_shouldbe(u_int16_t sum, u_int16_t computed_sum)
+uint16_t
+in_cksum_shouldbe(uint16_t sum, uint16_t computed_sum)
{
- u_int32_t shouldbe;
+ uint32_t shouldbe;
/*
* The value that should have gone into the checksum field
@@ -200,3 +203,6 @@ in_cksum_shouldbe(u_int16_t sum, u_int16_t computed_sum)
shouldbe = (shouldbe & 0xFFFF) + (shouldbe >> 16);
return shouldbe;
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-in_cksum-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/interface.h b/freebsd/contrib/tcpdump/interface.h
index 175c33e2..46d338b4 100644
--- a/freebsd/contrib/tcpdump/interface.h
+++ b/freebsd/contrib/tcpdump/interface.h
@@ -17,8 +17,6 @@
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.285 2008-08-16 11:36:20 hannes Exp $ (LBL)
*/
#ifndef tcpdump_interface_h
@@ -38,13 +36,19 @@
#if !defined(HAVE_SNPRINTF)
int snprintf(char *, size_t, const char *, ...)
- __attribute__((format(printf, 3, 4)));
-#endif
+#ifdef __ATTRIBUTE___FORMAT_OK
+ __attribute__((format(printf, 3, 4)))
+#endif /* __ATTRIBUTE___FORMAT_OK */
+ ;
+#endif /* !defined(HAVE_SNPRINTF) */
#if !defined(HAVE_VSNPRINTF)
int vsnprintf(char *, size_t, const char *, va_list)
- __attribute__((format(printf, 3, 0)));
-#endif
+#ifdef __ATTRIBUTE___FORMAT_OK
+ __attribute__((format(printf, 3, 0)))
+#endif /* __ATTRIBUTE___FORMAT_OK */
+ ;
+#endif /* !defined(HAVE_VSNPRINTF) */
#ifndef HAVE_STRLCAT
extern size_t strlcat(char *, const char *, size_t);
@@ -61,340 +65,15 @@ extern char *strdup(const char *);
extern char *strsep(char **, const char *);
#endif
-#define PT_VAT 1 /* Visual Audio Tool */
-#define PT_WB 2 /* distributed White Board */
-#define PT_RPC 3 /* Remote Procedure Call */
-#define PT_RTP 4 /* Real-Time Applications protocol */
-#define PT_RTCP 5 /* Real-Time Applications control protocol */
-#define PT_SNMP 6 /* Simple Network Management Protocol */
-#define PT_CNFP 7 /* Cisco NetFlow protocol */
-#define PT_TFTP 8 /* trivial file transfer protocol */
-#define PT_AODV 9 /* Ad-hoc On-demand Distance Vector Protocol */
-#define PT_CARP 10 /* Common Address Redundancy Protocol */
-#define PT_RADIUS 11 /* RADIUS authentication Protocol */
-#define PT_ZMTP1 12 /* ZeroMQ Message Transport Protocol 1.0 */
-#define PT_VXLAN 13 /* Virtual eXtensible Local Area Network */
-
-#ifndef min
-#define min(a,b) ((a)>(b)?(b):(a))
-#endif
-#ifndef max
-#define max(a,b) ((b)>(a)?(b):(a))
-#endif
-
-#define ESRC(ep) ((ep)->ether_shost)
-#define EDST(ep) ((ep)->ether_dhost)
-
-#ifndef NTOHL
-#define NTOHL(x) (x) = ntohl(x)
-#define NTOHS(x) (x) = ntohs(x)
-#define HTONL(x) (x) = htonl(x)
-#define HTONS(x) (x) = htons(x)
-#endif
-#endif
-
-#ifndef MIN
-#define MIN(a,b) ((a)<(b)?(a):(b))
#endif
extern char *program_name; /* used to generate self-identifying messages */
-extern int32_t thiszone; /* seconds offset from gmt to local time */
-
-/*
- * True if "l" bytes of "var" were captured.
- *
- * The "snapend - (l) <= snapend" checks to make sure "l" isn't so large
- * that "snapend - (l)" underflows.
- *
- * The check is for <= rather than < because "l" might be 0.
- */
-#define TTEST2(var, l) (snapend - (l) <= snapend && \
- (const u_char *)&(var) <= snapend - (l))
-
-/* True if "var" was captured */
-#define TTEST(var) TTEST2(var, sizeof(var))
-
-/* Bail if "l" bytes of "var" were not captured */
-#define TCHECK2(var, l) if (!TTEST2(var, l)) goto trunc
-
-/* Bail if "var" was not captured */
-#define TCHECK(var) TCHECK2(var, sizeof(var))
-
-extern void ts_print(const struct timeval *);
-extern void relts_print(int);
-
-extern int fn_print(const u_char *, const u_char *);
-extern int fn_printn(const u_char *, u_int, const u_char *);
-extern int fn_printzp(const u_char *, u_int, const u_char *);
-extern int mask2plen(u_int32_t);
-extern const char *tok2strary_internal(const char **, int, const char *, int);
-#define tok2strary(a,f,i) tok2strary_internal(a, sizeof(a)/sizeof(a[0]),f,i)
-
-extern const char *dnaddr_string(u_short);
-
-extern void error(const char *, ...)
- __attribute__((noreturn, format (printf, 1, 2)));
-extern void warning(const char *, ...) __attribute__ ((format (printf, 1, 2)));
-
-extern char *read_infile(char *);
-extern char *copy_argv(char **);
-
-extern void safeputchar(int);
-extern void safeputs(const char *, int);
-
-extern const char *isonsap_string(const u_char *, register u_int);
-extern const char *protoid_string(const u_char *);
-extern const char *ipxsap_string(u_short);
-extern const char *dnname_string(u_short);
-extern const char *dnnum_string(u_short);
-
-/* checksum routines */
-extern void init_checksum(void);
-extern u_int16_t verify_crc10_cksum(u_int16_t, const u_char *, int);
-extern u_int16_t create_osi_cksum(const u_int8_t *, int, int);
-
-/* The printer routines. */
-
#include <pcap.h>
-extern int print_unknown_data(const u_char *, const char *,int);
-extern void ascii_print(const u_char *, u_int);
-extern void hex_and_ascii_print_with_offset(const char *, const u_char *,
- u_int, u_int);
-extern void hex_and_ascii_print(const char *, const u_char *, u_int);
-extern void hex_print_with_offset(const char *, const u_char *, u_int, u_int);
-extern void hex_print(const char *, const u_char *, u_int);
-extern void telnet_print(const u_char *, u_int);
-extern int llc_print(const u_char *, u_int, u_int, const u_char *,
- const u_char *, u_short *);
-extern int snap_print(const u_char *, u_int, u_int, u_int);
-extern void aarp_print(const u_char *, u_int);
-extern void aodv_print(const u_char *, u_int, int);
-extern void atalk_print(const u_char *, u_int);
-extern void atm_print(u_int, u_int, u_int, const u_char *, u_int, u_int);
-extern u_int atm_if_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int sunatm_if_print(const struct pcap_pkthdr *, const u_char *);
-extern int oam_print(const u_char *, u_int, u_int);
-extern void bootp_print(const u_char *, u_int);
-extern void bgp_print(const u_char *, int);
-extern void beep_print(const u_char *, u_int);
-extern void cnfp_print(const u_char *, const u_char *);
-extern void decnet_print(const u_char *, u_int, u_int);
-extern void default_print(const u_char *, u_int);
-extern void dvmrp_print(const u_char *, u_int);
-extern void egp_print(const u_char *, u_int);
-extern u_int enc_if_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int pflog_if_print(const struct pcap_pkthdr *, const u_char *);
-extern void pfsync_ip_print(const u_char *, u_int);
-extern u_int arcnet_if_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int arcnet_linux_if_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int token_print(const u_char *, u_int, u_int);
-extern u_int token_if_print(const struct pcap_pkthdr *, const u_char *);
-extern void fddi_print(const u_char *, u_int, u_int);
-extern u_int fddi_if_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int fr_if_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int mfr_if_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int fr_print(register const u_char *, u_int);
-extern u_int mfr_print(register const u_char *, u_int);
-extern char *q922_string(const u_char *);
-extern u_int ieee802_11_if_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int ieee802_11_radio_if_print(const struct pcap_pkthdr *,
- const u_char *);
-extern u_int ap1394_if_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int ieee802_11_radio_avs_if_print(const struct pcap_pkthdr *,
- const u_char *);
-extern void gre_print(const u_char *, u_int);
-extern void icmp_print(const u_char *, u_int, const u_char *, int);
-extern void igmp_print(const u_char *, u_int);
-extern void igrp_print(const u_char *, u_int, const u_char *);
-extern void ipN_print(const u_char *, u_int);
-extern u_int ipfc_if_print(const struct pcap_pkthdr *, const u_char *);
-extern void ipx_print(const u_char *, u_int);
-extern void isoclns_print(const u_char *, u_int, u_int);
-extern void krb_print(const u_char *);
-extern u_int llap_print(const u_char *, u_int);
-extern u_int ltalk_if_print(const struct pcap_pkthdr *, const u_char *);
-extern void msdp_print(const unsigned char *, u_int);
-extern void nfsreply_print(const u_char *, u_int, const u_char *);
-extern void nfsreq_print(const u_char *, u_int, const u_char *);
-extern void ns_print(const u_char *, u_int, int);
-extern const u_char * ns_nprint (register const u_char *, register const u_char *);
-extern void ntp_print(const u_char *, u_int);
-extern u_int null_if_print(const struct pcap_pkthdr *, const u_char *);
-extern void ospf_print(const u_char *, u_int, const u_char *);
-extern void olsr_print (const u_char *, u_int, int);
-extern void pimv1_print(const u_char *, u_int);
-extern void cisco_autorp_print(const u_char *, u_int);
-extern void rsvp_print(const u_char *, u_int);
-extern void ldp_print(const u_char *, u_int);
-extern void lldp_print(const u_char *, u_int);
-extern void rpki_rtr_print(const u_char *, u_int);
-extern void lmp_print(const u_char *, u_int);
-extern void lspping_print(const u_char *, u_int);
-extern void lwapp_control_print(const u_char *, u_int, int);
-extern void lwapp_data_print(const u_char *, u_int);
-extern void eigrp_print(const u_char *, u_int);
-extern void mobile_print(const u_char *, u_int);
-extern void pim_print(const u_char *, u_int, u_int);
-extern u_int pppoe_print(const u_char *, u_int);
-extern u_int ppp_print(register const u_char *, u_int);
-extern u_int ppp_if_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int ppp_hdlc_if_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int ppp_bsdos_if_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int pppoe_if_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int prism_if_print(const struct pcap_pkthdr *, const u_char *);
-extern void q933_print(const u_char *, u_int);
-extern int vjc_print(register const char *, u_short);
-extern void vqp_print(register const u_char *, register u_int);
-extern u_int raw_if_print(const struct pcap_pkthdr *, const u_char *);
-extern void rip_print(const u_char *, u_int);
-extern u_int sl_if_print(const struct pcap_pkthdr *, const u_char *);
-extern void lane_print(const u_char *, u_int, u_int);
-extern u_int lane_if_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int cip_if_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int sl_bsdos_if_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int chdlc_if_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int chdlc_print(register const u_char *, u_int);
-extern u_int juniper_atm1_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int juniper_atm2_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int juniper_mfr_print(const struct pcap_pkthdr *, register const u_char *);
-extern u_int juniper_mlfr_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int juniper_mlppp_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int juniper_pppoe_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int juniper_pppoe_atm_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int juniper_ggsn_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int juniper_es_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int juniper_monitor_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int juniper_services_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int juniper_ether_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int juniper_ppp_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int juniper_frelay_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int juniper_chdlc_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int sll_if_print(const struct pcap_pkthdr *, const u_char *);
-extern void snmp_print(const u_char *, u_int);
-extern void sunrpcrequest_print(const u_char *, u_int, const u_char *);
-extern u_int symantec_if_print(const struct pcap_pkthdr *, const u_char *);
-extern void tcp_print(const u_char *, u_int, const u_char *, int);
-extern void tftp_print(const u_char *, u_int);
-extern void timed_print(const u_char *);
-extern void udld_print(const u_char *, u_int);
-extern void udp_print(const u_char *, u_int, const u_char *, int);
-extern void vtp_print(const u_char *, u_int);
-extern void wb_print(const void *, u_int);
-extern int ah_print(register const u_char *);
-extern int ipcomp_print(register const u_char *, int *);
-extern void rx_print(register const u_char *, int, int, int, u_char *);
-extern void netbeui_print(u_short, const u_char *, int);
-extern void ipx_netbios_print(const u_char *, u_int);
-extern void nbt_tcp_print(const u_char *, int);
-extern void nbt_udp137_print(const u_char *, int);
-extern void nbt_udp138_print(const u_char *, int);
-extern void smb_tcp_print(const u_char *, int);
-extern char *smb_errstr(int, int);
-extern const char *nt_errstr(u_int32_t);
-extern void print_data(const unsigned char *, int);
-extern void l2tp_print(const u_char *, u_int);
-extern void vrrp_print(const u_char *, u_int, int);
-extern void carp_print(const u_char *, u_int, int);
-extern void slow_print(const u_char *, u_int);
-extern void sflow_print(const u_char *, u_int);
-extern void mpcp_print(const u_char *, u_int);
-extern void cfm_print(const u_char *, u_int);
-extern void pgm_print(const u_char *, u_int, const u_char *);
-extern void cdp_print(const u_char *, u_int, u_int);
-extern void dtp_print(const u_char *, u_int);
-extern void stp_print(const u_char *, u_int);
-extern void radius_print(const u_char *, u_int);
-extern void lwres_print(const u_char *, u_int);
-extern void pptp_print(const u_char *);
-extern void dccp_print(const u_char *, const u_char *, u_int);
-extern void sctp_print(const u_char *, const u_char *, u_int);
-extern void forces_print(const u_char *, u_int);
-extern void mpls_print(const u_char *, u_int);
-extern void mpls_lsp_ping_print(const u_char *, u_int);
-extern void zephyr_print(const u_char *, int);
-extern void zmtp1_print(const u_char *, u_int);
-extern void hsrp_print(const u_char *, u_int);
-extern void bfd_print(const u_char *, u_int, u_int);
-extern void sip_print(const u_char *, u_int);
-extern void syslog_print(const u_char *, u_int);
-extern u_int bt_if_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int usb_linux_48_byte_print(const struct pcap_pkthdr *, const u_char *);
-extern u_int usb_linux_64_byte_print(const struct pcap_pkthdr *, const u_char *);
-extern void vxlan_print(const u_char *, u_int);
-extern void otv_print(const u_char *, u_int);
-
-
-#ifdef INET6
-extern void ip6_opt_print(const u_char *, int);
-extern int hbhopt_print(const u_char *);
-extern int dstopt_print(const u_char *);
-extern int frag6_print(const u_char *, const u_char *);
-extern int mobility_print(const u_char *, const u_char *);
-extern void ripng_print(const u_char *, unsigned int);
-extern int rt6_print(const u_char *, const u_char *);
-extern void ospf6_print(const u_char *, u_int);
-extern void dhcp6_print(const u_char *, u_int);
-extern void babel_print(const u_char *, u_int);
-extern int mask62plen(const u_char *);
-#endif /*INET6*/
-
-struct cksum_vec {
- const u_int8_t *ptr;
- int len;
-};
-extern u_int16_t in_cksum(const struct cksum_vec *, int);
-extern u_int16_t in_cksum_shouldbe(u_int16_t, u_int16_t);
-
#ifndef HAVE_BPF_DUMP
struct bpf_program;
extern void bpf_dump(const struct bpf_program *, int);
#endif
-
-#include "netdissect.h"
-
-/* forward compatibility */
-
-#ifndef NETDISSECT_REWORKED
-extern netdissect_options *gndo;
-
-#define bflag gndo->ndo_bflag
-#define eflag gndo->ndo_eflag
-#define fflag gndo->ndo_fflag
-#define jflag gndo->ndo_jflag
-#define Kflag gndo->ndo_Kflag
-#define nflag gndo->ndo_nflag
-#define Nflag gndo->ndo_Nflag
-#define Oflag gndo->ndo_Oflag
-#define pflag gndo->ndo_pflag
-#define qflag gndo->ndo_qflag
-#define Rflag gndo->ndo_Rflag
-#define sflag gndo->ndo_sflag
-#define Sflag gndo->ndo_Sflag
-#define tflag gndo->ndo_tflag
-#define Uflag gndo->ndo_Uflag
-#define uflag gndo->ndo_uflag
-#define vflag gndo->ndo_vflag
-#define xflag gndo->ndo_xflag
-#define Xflag gndo->ndo_Xflag
-#define Cflag gndo->ndo_Cflag
-#define Gflag gndo->ndo_Gflag
-#define Aflag gndo->ndo_Aflag
-#define Bflag gndo->ndo_Bflag
-#define Iflag gndo->ndo_Iflag
-#define suppress_default_print gndo->ndo_suppress_default_print
-#define packettype gndo->ndo_packettype
-#define sigsecret gndo->ndo_sigsecret
-#define Wflag gndo->ndo_Wflag
-#define WflagChars gndo->ndo_WflagChars
-#define Cflag_count gndo->ndo_Cflag_count
-#define Gflag_count gndo->ndo_Gflag_count
-#define Gflag_time gndo->ndo_Gflag_time
-#define Hflag gndo->ndo_Hflag
-#define snaplen gndo->ndo_snaplen
-#define snapend gndo->ndo_snapend
-
-#endif
diff --git a/freebsd/contrib/tcpdump/ip.h b/freebsd/contrib/tcpdump/ip.h
index 8a97632e..8179061e 100644
--- a/freebsd/contrib/tcpdump/ip.h
+++ b/freebsd/contrib/tcpdump/ip.h
@@ -1,4 +1,3 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/ip.h,v 1.12 2007-09-14 01:29:28 guy Exp $ (LBL) */
/*
* Copyright (c) 1982, 1986, 1993
* The Regents of the University of California. All rights reserved.
@@ -34,6 +33,9 @@
* @(#)ip.h 8.2 (Berkeley) 6/1/94
*/
+#ifndef netdissect_ip_h
+#define netdissect_ip_h
+
/*
* Definitions for internet protocol version 4.
* Per RFC 791, September 1981.
@@ -48,21 +50,21 @@
* against negative integers quite easily, and fail in subtle ways.
*/
struct ip {
- u_int8_t ip_vhl; /* header length, version */
+ nd_uint8_t ip_vhl; /* header length, version */
#define IP_V(ip) (((ip)->ip_vhl & 0xf0) >> 4)
#define IP_HL(ip) ((ip)->ip_vhl & 0x0f)
- u_int8_t ip_tos; /* type of service */
- u_int16_t ip_len; /* total length */
- u_int16_t ip_id; /* identification */
- u_int16_t ip_off; /* fragment offset field */
+ nd_uint8_t ip_tos; /* type of service */
+ nd_uint16_t ip_len; /* total length */
+ nd_uint16_t ip_id; /* identification */
+ nd_uint16_t ip_off; /* fragment offset field */
#define IP_DF 0x4000 /* dont fragment flag */
#define IP_MF 0x2000 /* more fragments flag */
#define IP_OFFMASK 0x1fff /* mask for fragmenting bits */
- u_int8_t ip_ttl; /* time to live */
- u_int8_t ip_p; /* protocol */
- u_int16_t ip_sum; /* checksum */
- struct in_addr ip_src,ip_dst; /* source and dest address */
-} UNALIGNED;
+ nd_uint8_t ip_ttl; /* time to live */
+ nd_uint8_t ip_p; /* protocol */
+ nd_uint16_t ip_sum; /* checksum */
+ nd_ipv4 ip_src,ip_dst; /* source and dest address */
+};
#define IP_MAXPACKET 65535 /* maximum packet size */
@@ -121,20 +123,20 @@ struct ip {
* Time stamp option structure.
*/
struct ip_timestamp {
- u_int8_t ipt_code; /* IPOPT_TS */
- u_int8_t ipt_len; /* size of structure (variable) */
- u_int8_t ipt_ptr; /* index of current entry */
- u_int8_t ipt_oflwflg; /* flags, overflow counter */
+ nd_uint8_t ipt_code; /* IPOPT_TS */
+ nd_uint8_t ipt_len; /* size of structure (variable) */
+ nd_uint8_t ipt_ptr; /* index of current entry */
+ nd_uint8_t ipt_oflwflg; /* flags, overflow counter */
#define IPTS_OFLW(ip) (((ipt)->ipt_oflwflg & 0xf0) >> 4)
#define IPTS_FLG(ip) ((ipt)->ipt_oflwflg & 0x0f)
union ipt_timestamp {
- u_int32_t ipt_time[1];
+ nd_uint32_t ipt_time[1];
struct ipt_ta {
- struct in_addr ipt_addr;
- u_int32_t ipt_time;
+ nd_ipv4 ipt_addr;
+ nd_uint32_t ipt_time;
} ipt_ta[1];
} ipt_timestamp;
-} UNALIGNED;
+};
/* flag bits for ipt_flg */
#define IPOPT_TS_TSONLY 0 /* timestamps only */
@@ -159,6 +161,4 @@ struct ip_timestamp {
#define IPTTLDEC 1 /* subtracted when forwarding */
#define IP_MSS 576 /* default maximum segment size */
-
-/* in print-ip.c */
-extern int nextproto4_cksum(const struct ip *, const u_int8_t *, u_int, u_int);
+#endif /* netdissect_ip_h */
diff --git a/freebsd/contrib/tcpdump/ip6.h b/freebsd/contrib/tcpdump/ip6.h
index 12c87ad2..2ea1d0ab 100644
--- a/freebsd/contrib/tcpdump/ip6.h
+++ b/freebsd/contrib/tcpdump/ip6.h
@@ -1,4 +1,3 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/ip6.h,v 1.8 2007-08-29 02:31:44 mcr Exp $ (LBL) */
/* NetBSD: ip6.h,v 1.9 2000/07/13 05:34:21 itojun Exp */
/* $KAME: ip6.h,v 1.9 2000/07/02 21:01:32 itojun Exp $ */
@@ -77,18 +76,19 @@
struct ip6_hdr {
union {
struct ip6_hdrctl {
- u_int32_t ip6_un1_flow; /* 20 bits of flow-ID */
- u_int16_t ip6_un1_plen; /* payload length */
- u_int8_t ip6_un1_nxt; /* next header */
- u_int8_t ip6_un1_hlim; /* hop limit */
+ uint32_t ip6_un1_flow; /* 20 bits of flow-ID */
+ uint16_t ip6_un1_plen; /* payload length */
+ uint8_t ip6_un1_nxt; /* next header */
+ uint8_t ip6_un1_hlim; /* hop limit */
} ip6_un1;
- u_int8_t ip6_un2_vfc; /* 4 bits version, top 4 bits class */
+ uint8_t ip6_un2_vfc; /* 4 bits version, top 4 bits class */
} ip6_ctlun;
struct in6_addr ip6_src; /* source address */
struct in6_addr ip6_dst; /* destination address */
} UNALIGNED;
#define ip6_vfc ip6_ctlun.ip6_un2_vfc
+#define IP6_VERSION(ip6_hdr) (((ip6_hdr)->ip6_vfc & 0xf0) >> 4)
#define ip6_flow ip6_ctlun.ip6_un1.ip6_un1_flow
#define ip6_plen ip6_ctlun.ip6_un1.ip6_un1_plen
#define ip6_nxt ip6_ctlun.ip6_un1.ip6_un1_nxt
@@ -96,8 +96,8 @@ struct ip6_hdr {
#define ip6_hops ip6_ctlun.ip6_un1.ip6_un1_hlim
/* in network endian */
-#define IPV6_FLOWINFO_MASK ((u_int32_t)htonl(0x0fffffff)) /* flow info (28 bits) */
-#define IPV6_FLOWLABEL_MASK ((u_int32_t)htonl(0x000fffff)) /* flow label (20 bits) */
+#define IPV6_FLOWINFO_MASK ((uint32_t)htonl(0x0fffffff)) /* flow info (28 bits) */
+#define IPV6_FLOWLABEL_MASK ((uint32_t)htonl(0x000fffff)) /* flow label (20 bits) */
#if 1
/* ECN bits proposed by Sally Floyd */
#define IP6TOS_CE 0x01 /* congestion experienced */
@@ -109,29 +109,33 @@ struct ip6_hdr {
*/
struct ip6_ext {
- u_int8_t ip6e_nxt;
- u_int8_t ip6e_len;
+ uint8_t ip6e_nxt;
+ uint8_t ip6e_len;
} UNALIGNED;
/* Hop-by-Hop options header */
struct ip6_hbh {
- u_int8_t ip6h_nxt; /* next header */
- u_int8_t ip6h_len; /* length in units of 8 octets */
+ uint8_t ip6h_nxt; /* next header */
+ uint8_t ip6h_len; /* length in units of 8 octets */
/* followed by options */
} UNALIGNED;
/* Destination options header */
struct ip6_dest {
- u_int8_t ip6d_nxt; /* next header */
- u_int8_t ip6d_len; /* length in units of 8 octets */
+ uint8_t ip6d_nxt; /* next header */
+ uint8_t ip6d_len; /* length in units of 8 octets */
/* followed by options */
} UNALIGNED;
+/* http://www.iana.org/assignments/ipv6-parameters/ipv6-parameters.xhtml */
+
/* Option types and related macros */
#define IP6OPT_PAD1 0x00 /* 00 0 00000 */
#define IP6OPT_PADN 0x01 /* 00 0 00001 */
#define IP6OPT_JUMBO 0xC2 /* 11 0 00010 = 194 */
#define IP6OPT_JUMBO_LEN 6
+#define IP6OPT_RPL 0x63 /* 01 1 00011 */
+#define IP6OPT_TUN_ENC_LIMIT 0x04 /* 00 0 00100 */
#define IP6OPT_ROUTER_ALERT 0x05 /* 00 0 00101 */
#define IP6OPT_RTALERT_LEN 4
@@ -140,11 +144,16 @@ struct ip6_dest {
#define IP6OPT_RTALERT_ACTNET 2 /* contains an Active Networks msg */
#define IP6OPT_MINLEN 2
-#define IP6OPT_BINDING_UPDATE 0xc6 /* 11 0 00110 */
-#define IP6OPT_BINDING_ACK 0x07 /* 00 0 00111 */
-#define IP6OPT_BINDING_REQ 0x08 /* 00 0 01000 */
+#define IP6OPT_QUICK_START 0x26 /* 00 1 00110 */
+#define IP6OPT_CALIPSO 0x07 /* 00 0 00111 */
+#define IP6OPT_SMF_DPD 0x08 /* 00 0 01000 */
#define IP6OPT_HOME_ADDRESS 0xc9 /* 11 0 01001 */
+#define IP6OPT_HOMEADDR_MINLEN 18
#define IP6OPT_EID 0x8a /* 10 0 01010 */
+#define IP6OPT_ILNP_NOTICE 0x8b /* 10 0 01011 */
+#define IP6OPT_LINE_ID 0x8c /* 10 0 01100 */
+#define IP6OPT_MPL 0x6d /* 01 1 01101 */
+#define IP6OPT_IP_DFF 0xee /* 11 1 01110 */
#define IP6OPT_TYPE(o) ((o) & 0xC0)
#define IP6OPT_TYPE_SKIP 0x00
@@ -156,37 +165,38 @@ struct ip6_dest {
/* Routing header */
struct ip6_rthdr {
- u_int8_t ip6r_nxt; /* next header */
- u_int8_t ip6r_len; /* length in units of 8 octets */
- u_int8_t ip6r_type; /* routing type */
- u_int8_t ip6r_segleft; /* segments left */
+ uint8_t ip6r_nxt; /* next header */
+ uint8_t ip6r_len; /* length in units of 8 octets */
+ uint8_t ip6r_type; /* routing type */
+ uint8_t ip6r_segleft; /* segments left */
/* followed by routing type specific data */
} UNALIGNED;
+#define IPV6_RTHDR_TYPE_0 0
+#define IPV6_RTHDR_TYPE_2 2
+
/* Type 0 Routing header */
+/* Also used for Type 2 */
struct ip6_rthdr0 {
- u_int8_t ip6r0_nxt; /* next header */
- u_int8_t ip6r0_len; /* length in units of 8 octets */
- u_int8_t ip6r0_type; /* always zero */
- u_int8_t ip6r0_segleft; /* segments left */
- u_int8_t ip6r0_reserved; /* reserved field */
- u_int8_t ip6r0_slmap[3]; /* strict/loose bit map */
+ uint8_t ip6r0_nxt; /* next header */
+ uint8_t ip6r0_len; /* length in units of 8 octets */
+ uint8_t ip6r0_type; /* always zero */
+ uint8_t ip6r0_segleft; /* segments left */
+ uint8_t ip6r0_reserved; /* reserved field */
+ uint8_t ip6r0_slmap[3]; /* strict/loose bit map */
struct in6_addr ip6r0_addr[1]; /* up to 23 addresses */
} UNALIGNED;
/* Fragment header */
struct ip6_frag {
- u_int8_t ip6f_nxt; /* next header */
- u_int8_t ip6f_reserved; /* reserved field */
- u_int16_t ip6f_offlg; /* offset, reserved, and flag */
- u_int32_t ip6f_ident; /* identification */
+ uint8_t ip6f_nxt; /* next header */
+ uint8_t ip6f_reserved; /* reserved field */
+ uint16_t ip6f_offlg; /* offset, reserved, and flag */
+ uint32_t ip6f_ident; /* identification */
} UNALIGNED;
#define IP6F_OFF_MASK 0xfff8 /* mask out offset from ip6f_offlg */
#define IP6F_RESERVED_MASK 0x0006 /* reserved bits in ip6f_offlg */
#define IP6F_MORE_FRAG 0x0001 /* more-fragments flag */
-/* in print-ip6.c */
-extern int nextproto6_cksum(const struct ip6_hdr *, const u_int8_t *, u_int, u_int);
-
#endif /* not _NETINET_IP6_H_ */
diff --git a/freebsd/contrib/tcpdump/ipnet.h b/freebsd/contrib/tcpdump/ipnet.h
deleted file mode 100644
index ae692842..00000000
--- a/freebsd/contrib/tcpdump/ipnet.h
+++ /dev/null
@@ -1,13 +0,0 @@
-typedef struct ipnet_hdr {
- uint8_t iph_version;
- uint8_t iph_family;
- uint16_t iph_htype;
- uint32_t iph_pktlen;
- uint32_t iph_ifindex;
- uint32_t iph_grifindex;
- uint32_t iph_zsrc;
- uint32_t iph_zdst;
-} ipnet_hdr_t;
-
-#define IPH_AF_INET 2 /* Matches Solaris's AF_INET */
-#define IPH_AF_INET6 26 /* Matches Solaris's AF_INET6 */
diff --git a/freebsd/contrib/tcpdump/ipproto.c b/freebsd/contrib/tcpdump/ipproto.c
index a0ddf867..59f3f361 100644
--- a/freebsd/contrib/tcpdump/ipproto.c
+++ b/freebsd/contrib/tcpdump/ipproto.c
@@ -1,6 +1,9 @@
#include <machine/rtems-bsd-user-space.h>
-
-/*
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
+/*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code
* distributions retain the above copyright notice and this paragraph
@@ -15,18 +18,13 @@
* Original code by Hannes Gredler (hannes@juniper.net)
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/ipproto.c,v 1.6 2005-09-20 06:01:22 guy Exp $ (LBL)";
-#endif
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "ipproto.h"
const struct tok ipproto_values[] = {
@@ -62,3 +60,6 @@ const struct tok ipproto_values[] = {
{ 0, NULL }
};
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-ipproto-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/ipproto.h b/freebsd/contrib/tcpdump/ipproto.h
index 4b6bf51c..4719d4d3 100644
--- a/freebsd/contrib/tcpdump/ipproto.h
+++ b/freebsd/contrib/tcpdump/ipproto.h
@@ -30,12 +30,9 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * @(#) $Header: /tcpdump/master/tcpdump/ipproto.h,v 1.6 2005-09-20 06:01:22 guy Exp $ (LBL)
- *
* From:
* @(#)in.h 8.3 (Berkeley) 1/3/94
- * $FreeBSD$
- * FreeBSD: src/sys/netinet/in.h,v 1.38.2.3 1999/08/29 16:29:34 peter Exp
+ * $FreeBSD: projects/clang400-import/contrib/tcpdump/ipproto.h 276788 2015-01-07 19:55:18Z delphij $
*/
extern const struct tok ipproto_values[];
diff --git a/freebsd/contrib/tcpdump/ipsec_doi.h b/freebsd/contrib/tcpdump/ipsec_doi.h
deleted file mode 100644
index 554a2586..00000000
--- a/freebsd/contrib/tcpdump/ipsec_doi.h
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
- * All rights reserved.
- *
- * 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.
- */
-/* YIPS @(#)$Id: ipsec_doi.h,v 1.7 2002-12-11 07:13:53 guy Exp $ */
-
-/* refer to RFC 2407 */
-
-#if !defined(_IPSEC_DOI_H_)
-#define _IPSEC_DOI_H_
-
-#define IPSEC_DOI 1
-
-/* 4.2 IPSEC Situation Definition */
-#define IPSECDOI_SIT_IDENTITY_ONLY 0x00000001
-#define IPSECDOI_SIT_SECRECY 0x00000002
-#define IPSECDOI_SIT_INTEGRITY 0x00000004
-
-/* 4.4.1 IPSEC Security Protocol Identifiers */
- /* 4.4.2 IPSEC ISAKMP Transform Values */
-#define IPSECDOI_PROTO_ISAKMP 1
-#define IPSECDOI_KEY_IKE 1
-
-/* 4.4.1 IPSEC Security Protocol Identifiers */
-#define IPSECDOI_PROTO_IPSEC_AH 2
- /* 4.4.3 IPSEC AH Transform Values */
-#define IPSECDOI_AH_MD5 2
-#define IPSECDOI_AH_SHA 3
-#define IPSECDOI_AH_DES 4
-#define IPSECDOI_AH_SHA2_256 5
-#define IPSECDOI_AH_SHA2_384 6
-#define IPSECDOI_AH_SHA2_512 7
-
-/* 4.4.1 IPSEC Security Protocol Identifiers */
-#define IPSECDOI_PROTO_IPSEC_ESP 3
- /* 4.4.4 IPSEC ESP Transform Identifiers */
-#define IPSECDOI_ESP_DES_IV64 1
-#define IPSECDOI_ESP_DES 2
-#define IPSECDOI_ESP_3DES 3
-#define IPSECDOI_ESP_RC5 4
-#define IPSECDOI_ESP_IDEA 5
-#define IPSECDOI_ESP_CAST 6
-#define IPSECDOI_ESP_BLOWFISH 7
-#define IPSECDOI_ESP_3IDEA 8
-#define IPSECDOI_ESP_DES_IV32 9
-#define IPSECDOI_ESP_RC4 10
-#define IPSECDOI_ESP_NULL 11
-#define IPSECDOI_ESP_RIJNDAEL 12
-#define IPSECDOI_ESP_AES 12
-
-/* 4.4.1 IPSEC Security Protocol Identifiers */
-#define IPSECDOI_PROTO_IPCOMP 4
- /* 4.4.5 IPSEC IPCOMP Transform Identifiers */
-#define IPSECDOI_IPCOMP_OUI 1
-#define IPSECDOI_IPCOMP_DEFLATE 2
-#define IPSECDOI_IPCOMP_LZS 3
-
-/* 4.5 IPSEC Security Association Attributes */
-#define IPSECDOI_ATTR_SA_LTYPE 1 /* B */
-#define IPSECDOI_ATTR_SA_LTYPE_DEFAULT 1
-#define IPSECDOI_ATTR_SA_LTYPE_SEC 1
-#define IPSECDOI_ATTR_SA_LTYPE_KB 2
-#define IPSECDOI_ATTR_SA_LDUR 2 /* V */
-#define IPSECDOI_ATTR_SA_LDUR_DEFAULT 28800 /* 8 hours */
-#define IPSECDOI_ATTR_GRP_DESC 3 /* B */
-#define IPSECDOI_ATTR_ENC_MODE 4 /* B */
- /* default value: host dependent */
-#define IPSECDOI_ATTR_ENC_MODE_TUNNEL 1
-#define IPSECDOI_ATTR_ENC_MODE_TRNS 2
-#define IPSECDOI_ATTR_AUTH 5 /* B */
- /* 0 means not to use authentication. */
-#define IPSECDOI_ATTR_AUTH_HMAC_MD5 1
-#define IPSECDOI_ATTR_AUTH_HMAC_SHA1 2
-#define IPSECDOI_ATTR_AUTH_DES_MAC 3
-#define IPSECDOI_ATTR_AUTH_KPDK 4 /*RFC-1826(Key/Pad/Data/Key)*/
- /*
- * When negotiating ESP without authentication, the Auth
- * Algorithm attribute MUST NOT be included in the proposal.
- * When negotiating ESP without confidentiality, the Auth
- * Algorithm attribute MUST be included in the proposal and
- * the ESP transform ID must be ESP_NULL.
- */
-#define IPSECDOI_ATTR_KEY_LENGTH 6 /* B */
-#define IPSECDOI_ATTR_KEY_ROUNDS 7 /* B */
-#define IPSECDOI_ATTR_COMP_DICT_SIZE 8 /* B */
-#define IPSECDOI_ATTR_COMP_PRIVALG 9 /* V */
-
-/* 4.6.1 Security Association Payload */
-struct ipsecdoi_sa {
- struct isakmp_gen h;
- u_int32_t doi; /* Domain of Interpretation */
- u_int32_t sit; /* Situation */
-};
-
-struct ipsecdoi_secrecy_h {
- u_int16_t len;
- u_int16_t reserved;
-};
-
-/* 4.6.2.1 Identification Type Values */
-struct ipsecdoi_id {
- struct isakmp_gen h;
- u_int8_t type; /* ID Type */
- u_int8_t proto_id; /* Protocol ID */
- u_int16_t port; /* Port */
- /* Identification Data */
-};
-
-#define IPSECDOI_ID_IPV4_ADDR 1
-#define IPSECDOI_ID_FQDN 2
-#define IPSECDOI_ID_USER_FQDN 3
-#define IPSECDOI_ID_IPV4_ADDR_SUBNET 4
-#define IPSECDOI_ID_IPV6_ADDR 5
-#define IPSECDOI_ID_IPV6_ADDR_SUBNET 6
-#define IPSECDOI_ID_IPV4_ADDR_RANGE 7
-#define IPSECDOI_ID_IPV6_ADDR_RANGE 8
-#define IPSECDOI_ID_DER_ASN1_DN 9
-#define IPSECDOI_ID_DER_ASN1_GN 10
-#define IPSECDOI_ID_KEY_ID 11
-
-/* 4.6.3 IPSEC DOI Notify Message Types */
-/* Notify Messages - Status Types */
-#define IPSECDOI_NTYPE_RESPONDER_LIFETIME 24576
-#define IPSECDOI_NTYPE_REPLAY_STATUS 24577
-#define IPSECDOI_NTYPE_INITIAL_CONTACT 24578
-
-#endif /* !defined(_IPSEC_DOI_H_) */
diff --git a/freebsd/contrib/tcpdump/ipx.h b/freebsd/contrib/tcpdump/ipx.h
deleted file mode 100644
index bfc30198..00000000
--- a/freebsd/contrib/tcpdump/ipx.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * IPX protocol formats
- *
- * @(#) $Header: /tcpdump/master/tcpdump/ipx.h,v 1.8 2002-12-11 07:13:54 guy Exp $
- */
-
-/* well-known sockets */
-#define IPX_SKT_NCP 0x0451
-#define IPX_SKT_SAP 0x0452
-#define IPX_SKT_RIP 0x0453
-#define IPX_SKT_NETBIOS 0x0455
-#define IPX_SKT_DIAGNOSTICS 0x0456
-#define IPX_SKT_NWLINK_DGM 0x0553 /* NWLink datagram, may contain SMB */
-#define IPX_SKT_EIGRP 0x85be /* Cisco EIGRP over IPX */
-
-/* IPX transport header */
-struct ipxHdr {
- u_int16_t cksum; /* Checksum */
- u_int16_t length; /* Length, in bytes, including header */
- u_int8_t tCtl; /* Transport Control (i.e. hop count) */
- u_int8_t pType; /* Packet Type (i.e. level 2 protocol) */
- u_int16_t dstNet[2]; /* destination net */
- u_int8_t dstNode[6]; /* destination node */
- u_int16_t dstSkt; /* destination socket */
- u_int16_t srcNet[2]; /* source net */
- u_int8_t srcNode[6]; /* source node */
- u_int16_t srcSkt; /* source socket */
-};
-
-#define ipxSize 30
-
diff --git a/freebsd/contrib/tcpdump/isakmp.h b/freebsd/contrib/tcpdump/isakmp.h
deleted file mode 100644
index d628f7ae..00000000
--- a/freebsd/contrib/tcpdump/isakmp.h
+++ /dev/null
@@ -1,501 +0,0 @@
-/*
- * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
- * All rights reserved.
- *
- * 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.
- */
-/* YIPS @(#)$Id: isakmp.h,v 1.12 2007-11-24 18:13:33 mcr Exp $ */
-
-/* refer to RFC 2408 */
-
-/* must include <netinet/in.h> */
-
-#if !defined(_ISAKMP_H_)
-#define _ISAKMP_H_
-
-typedef u_char cookie_t[8];
-typedef u_char msgid_t[4];
-
-typedef struct { /* i_cookie + r_cookie */
- cookie_t i_ck;
- cookie_t r_ck;
-} isakmp_index;
-
-#define INITIATOR 1
-#define RESPONDER 2
-
-#define PORT_ISAKMP 500
-
-#define GENERATE 1
-#define VALIDATE 0
-
-/* Phase of oakley definition */
-/*
- 0000 0000 0000 0000
- | |||| ||||
- | |||| ++++--> negosiation number in phase
- | ++++-------> phase number
- +---------------> expire ?
- */
-#define ISAKMP_PH1 0x0010
-#define ISAKMP_PH2 0x0020
-#define ISAKMP_EXPIRED 0x0100
-
-#define ISAKMP_NGP_0 0x0000
-#define ISAKMP_NGP_1 0x0001
-#define ISAKMP_NGP_2 0x0002
-#define ISAKMP_NGP_3 0x0003
-#define ISAKMP_NGP_4 0x0004
-
-#define ISAKMP_PH1_N (ISAKMP_PH1 | ISAKMP_NGP_0) /* i.e. spawn */
-#define ISAKMP_PH1_1 (ISAKMP_PH1 | ISAKMP_NGP_1)
-#define ISAKMP_PH1_2 (ISAKMP_PH1 | ISAKMP_NGP_2)
-#define ISAKMP_PH1_3 (ISAKMP_PH1 | ISAKMP_NGP_3)
-#define ISAKMP_PH2_N (ISAKMP_PH2 | ISAKMP_NGP_0)
-#define ISAKMP_PH2_1 (ISAKMP_PH2 | ISAKMP_NGP_1)
-#define ISAKMP_PH2_2 (ISAKMP_PH2 | ISAKMP_NGP_2)
-#define ISAKMP_PH2_3 (ISAKMP_PH2 | ISAKMP_NGP_3)
-
-#define ISAKMP_TIMER_DEFAULT 10 /* seconds */
-#define ISAKMP_TRY_DEFAULT 3 /* times */
-
-/* 3.1 ISAKMP Header Format (IKEv1 and IKEv2)
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- ! Initiator !
- ! Cookie !
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- ! Responder !
- ! Cookie !
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- ! Next Payload ! MjVer ! MnVer ! Exchange Type ! Flags !
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- ! Message ID !
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- ! Length !
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-*/
-struct isakmp {
- cookie_t i_ck; /* Initiator Cookie */
- cookie_t r_ck; /* Responder Cookie */
- u_int8_t np; /* Next Payload Type */
- u_int8_t vers;
-#define ISAKMP_VERS_MAJOR 0xf0
-#define ISAKMP_VERS_MAJOR_SHIFT 4
-#define ISAKMP_VERS_MINOR 0x0f
-#define ISAKMP_VERS_MINOR_SHIFT 0
- u_int8_t etype; /* Exchange Type */
- u_int8_t flags; /* Flags */
- msgid_t msgid;
- u_int32_t len; /* Length */
-};
-
-/* Next Payload Type */
-#define ISAKMP_NPTYPE_NONE 0 /* NONE*/
-#define ISAKMP_NPTYPE_SA 1 /* Security Association */
-#define ISAKMP_NPTYPE_P 2 /* Proposal */
-#define ISAKMP_NPTYPE_T 3 /* Transform */
-#define ISAKMP_NPTYPE_KE 4 /* Key Exchange */
-#define ISAKMP_NPTYPE_ID 5 /* Identification */
-#define ISAKMP_NPTYPE_CERT 6 /* Certificate */
-#define ISAKMP_NPTYPE_CR 7 /* Certificate Request */
-#define ISAKMP_NPTYPE_HASH 8 /* Hash */
-#define ISAKMP_NPTYPE_SIG 9 /* Signature */
-#define ISAKMP_NPTYPE_NONCE 10 /* Nonce */
-#define ISAKMP_NPTYPE_N 11 /* Notification */
-#define ISAKMP_NPTYPE_D 12 /* Delete */
-#define ISAKMP_NPTYPE_VID 13 /* Vendor ID */
-#define ISAKMP_NPTYPE_v2E 46 /* v2 Encrypted payload */
-
-#define IKEv1_MAJOR_VERSION 1
-#define IKEv1_MINOR_VERSION 0
-
-#define IKEv2_MAJOR_VERSION 2
-#define IKEv2_MINOR_VERSION 0
-
-/* Exchange Type */
-#define ISAKMP_ETYPE_NONE 0 /* NONE */
-#define ISAKMP_ETYPE_BASE 1 /* Base */
-#define ISAKMP_ETYPE_IDENT 2 /* Identity Proteciton */
-#define ISAKMP_ETYPE_AUTH 3 /* Authentication Only */
-#define ISAKMP_ETYPE_AGG 4 /* Aggressive */
-#define ISAKMP_ETYPE_INF 5 /* Informational */
-
-/* Flags */
-#define ISAKMP_FLAG_E 0x01 /* Encryption Bit */
-#define ISAKMP_FLAG_C 0x02 /* Commit Bit */
-#define ISAKMP_FLAG_extra 0x04
-
-/* IKEv2 */
-#define ISAKMP_FLAG_I (1 << 3) /* (I)nitiator */
-#define ISAKMP_FLAG_V (1 << 4) /* (V)ersion */
-#define ISAKMP_FLAG_R (1 << 5) /* (R)esponse */
-
-
-/* 3.2 Payload Generic Header
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- ! Next Payload ! RESERVED ! Payload Length !
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-*/
-struct isakmp_gen {
- u_int8_t np; /* Next Payload */
- u_int8_t critical; /* bit 7 - critical, rest is RESERVED */
- u_int16_t len; /* Payload Length */
-};
-
-/* 3.3 Data Attributes
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- !A! Attribute Type ! AF=0 Attribute Length !
- !F! ! AF=1 Attribute Value !
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- . AF=0 Attribute Value .
- . AF=1 Not Transmitted .
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-*/
-struct isakmp_data {
- u_int16_t type; /* defined by DOI-spec, and Attribute Format */
- u_int16_t lorv; /* if f equal 1, Attribute Length */
- /* if f equal 0, Attribute Value */
- /* if f equal 1, Attribute Value */
-};
-#define ISAKMP_GEN_TLV 0x0000
-#define ISAKMP_GEN_TV 0x8000
- /* mask for type of attribute format */
-#define ISAKMP_GEN_MASK 0x8000
-
-/* 3.4 Security Association Payload */
- /* MAY NOT be used, because of being defined in ipsec-doi. */
- /*
- If the current payload is the last in the message,
- then the value of the next payload field will be 0.
- This field MUST NOT contain the
- values for the Proposal or Transform payloads as they are considered
- part of the security association negotiation. For example, this
- field would contain the value "10" (Nonce payload) in the first
- message of a Base Exchange (see Section 4.4) and the value "0" in the
- first message of an Identity Protect Exchange (see Section 4.5).
- */
-struct ikev1_pl_sa {
- struct isakmp_gen h;
- u_int32_t doi; /* Domain of Interpretation */
- u_int32_t sit; /* Situation */
-};
-
-/* 3.5 Proposal Payload */
- /*
- The value of the next payload field MUST only contain the value "2"
- or "0". If there are additional Proposal payloads in the message,
- then this field will be 2. If the current Proposal payload is the
- last within the security association proposal, then this field will
- be 0.
- */
-struct ikev1_pl_p {
- struct isakmp_gen h;
- u_int8_t p_no; /* Proposal # */
- u_int8_t prot_id; /* Protocol */
- u_int8_t spi_size; /* SPI Size */
- u_int8_t num_t; /* Number of Transforms */
- /* SPI */
-};
-
-/* 3.6 Transform Payload */
- /*
- The value of the next payload field MUST only contain the value "3"
- or "0". If there are additional Transform payloads in the proposal,
- then this field will be 3. If the current Transform payload is the
- last within the proposal, then this field will be 0.
- */
-struct ikev1_pl_t {
- struct isakmp_gen h;
- u_int8_t t_no; /* Transform # */
- u_int8_t t_id; /* Transform-Id */
- u_int16_t reserved; /* RESERVED2 */
- /* SA Attributes */
-};
-
-/* 3.7 Key Exchange Payload */
-struct ikev1_pl_ke {
- struct isakmp_gen h;
- /* Key Exchange Data */
-};
-
-/* 3.8 Identification Payload */
- /* MUST NOT to be used, because of being defined in ipsec-doi. */
-struct ikev1_pl_id {
- struct isakmp_gen h;
- union {
- u_int8_t id_type; /* ID Type */
- u_int32_t doi_data; /* DOI Specific ID Data */
- } d;
- /* Identification Data */
-};
-
-/* 3.9 Certificate Payload */
-struct ikev1_pl_cert {
- struct isakmp_gen h;
- u_int8_t encode; /* Cert Encoding */
- char cert; /* Certificate Data */
- /*
- This field indicates the type of
- certificate or certificate-related information contained in the
- Certificate Data field.
- */
-};
-
-/* Certificate Type */
-#define ISAKMP_CERT_NONE 0
-#define ISAKMP_CERT_PKCS 1
-#define ISAKMP_CERT_PGP 2
-#define ISAKMP_CERT_DNS 3
-#define ISAKMP_CERT_SIGN 4
-#define ISAKMP_CERT_KE 5
-#define ISAKMP_CERT_KT 6
-#define ISAKMP_CERT_CRL 7
-#define ISAKMP_CERT_ARL 8
-#define ISAKMP_CERT_SPKI 9
-
-/* 3.10 Certificate Request Payload */
-struct ikev1_pl_cr {
- struct isakmp_gen h;
- u_int8_t num_cert; /* # Cert. Types */
- /*
- Certificate Types (variable length)
- -- Contains a list of the types of certificates requested,
- sorted in order of preference. Each individual certificate
- type is 1 octet. This field is NOT requiredo
- */
- /* # Certificate Authorities (1 octet) */
- /* Certificate Authorities (variable length) */
-};
-
-/* 3.11 Hash Payload */
- /* may not be used, because of having only data. */
-struct ikev1_pl_hash {
- struct isakmp_gen h;
- /* Hash Data */
-};
-
-/* 3.12 Signature Payload */
- /* may not be used, because of having only data. */
-struct ikev1_pl_sig {
- struct isakmp_gen h;
- /* Signature Data */
-};
-
-/* 3.13 Nonce Payload */
- /* may not be used, because of having only data. */
-struct ikev1_pl_nonce {
- struct isakmp_gen h;
- /* Nonce Data */
-};
-
-/* 3.14 Notification Payload */
-struct ikev1_pl_n {
- struct isakmp_gen h;
- u_int32_t doi; /* Domain of Interpretation */
- u_int8_t prot_id; /* Protocol-ID */
- u_int8_t spi_size; /* SPI Size */
- u_int16_t type; /* Notify Message Type */
- /* SPI */
- /* Notification Data */
-};
-
-/* 3.14.1 Notify Message Types */
-/* NOTIFY MESSAGES - ERROR TYPES */
-#define ISAKMP_NTYPE_INVALID_PAYLOAD_TYPE 1
-#define ISAKMP_NTYPE_DOI_NOT_SUPPORTED 2
-#define ISAKMP_NTYPE_SITUATION_NOT_SUPPORTED 3
-#define ISAKMP_NTYPE_INVALID_COOKIE 4
-#define ISAKMP_NTYPE_INVALID_MAJOR_VERSION 5
-#define ISAKMP_NTYPE_INVALID_MINOR_VERSION 6
-#define ISAKMP_NTYPE_INVALID_EXCHANGE_TYPE 7
-#define ISAKMP_NTYPE_INVALID_FLAGS 8
-#define ISAKMP_NTYPE_INVALID_MESSAGE_ID 9
-#define ISAKMP_NTYPE_INVALID_PROTOCOL_ID 10
-#define ISAKMP_NTYPE_INVALID_SPI 11
-#define ISAKMP_NTYPE_INVALID_TRANSFORM_ID 12
-#define ISAKMP_NTYPE_ATTRIBUTES_NOT_SUPPORTED 13
-#define ISAKMP_NTYPE_NO_PROPOSAL_CHOSEN 14
-#define ISAKMP_NTYPE_BAD_PROPOSAL_SYNTAX 15
-#define ISAKMP_NTYPE_PAYLOAD_MALFORMED 16
-#define ISAKMP_NTYPE_INVALID_KEY_INFORMATION 17
-#define ISAKMP_NTYPE_INVALID_ID_INFORMATION 18
-#define ISAKMP_NTYPE_INVALID_CERT_ENCODING 19
-#define ISAKMP_NTYPE_INVALID_CERTIFICATE 20
-#define ISAKMP_NTYPE_BAD_CERT_REQUEST_SYNTAX 21
-#define ISAKMP_NTYPE_INVALID_CERT_AUTHORITY 22
-#define ISAKMP_NTYPE_INVALID_HASH_INFORMATION 23
-#define ISAKMP_NTYPE_AUTHENTICATION_FAILED 24
-#define ISAKMP_NTYPE_INVALID_SIGNATURE 25
-#define ISAKMP_NTYPE_ADDRESS_NOTIFICATION 26
-/* NOTIFY MESSAGES - STATUS TYPES */
-#define ISAKMP_NTYPE_CONNECTED 16384
-/* using only to log */
-#define ISAKMP_LOG_RETRY_LIMIT_REACHED 65530
-
-/* 3.15 Delete Payload */
-struct ikev1_pl_d {
- struct isakmp_gen h;
- u_int32_t doi; /* Domain of Interpretation */
- u_int8_t prot_id; /* Protocol-Id */
- u_int8_t spi_size; /* SPI Size */
- u_int16_t num_spi; /* # of SPIs */
- /* SPI(es) */
-};
-
-
-struct ikev1_ph1tab {
- struct ikev1_ph1 *head;
- struct ikev1_ph1 *tail;
- int len;
-};
-
-struct isakmp_ph2tab {
- struct ikev1_ph2 *head;
- struct ikev1_ph2 *tail;
- int len;
-};
-
-#define EXCHANGE_PROXY 1
-#define EXCHANGE_MYSELF 0
-
-#define PFS_NEED 1
-#define PFS_NONEED 0
-
-/* IKEv2 (RFC4306) */
-
-/* 3.3 Security Association Payload -- generic header */
-/* 3.3.1. Proposal Substructure */
-struct ikev2_p {
- struct isakmp_gen h;
- u_int8_t p_no; /* Proposal # */
- u_int8_t prot_id; /* Protocol */
- u_int8_t spi_size; /* SPI Size */
- u_int8_t num_t; /* Number of Transforms */
-};
-
-/* 3.3.2. Transform Substructure */
-struct ikev2_t {
- struct isakmp_gen h;
- u_int8_t t_type; /* Transform Type (ENCR,PRF,INTEG,etc.*/
- u_int8_t res2; /* reserved byte */
- u_int16_t t_id; /* Transform ID */
-};
-
-enum ikev2_t_type {
- IV2_T_ENCR = 1,
- IV2_T_PRF = 2,
- IV2_T_INTEG= 3,
- IV2_T_DH = 4,
- IV2_T_ESN = 5,
-};
-
-/* 3.4. Key Exchange Payload */
-struct ikev2_ke {
- struct isakmp_gen h;
- u_int16_t ke_group;
- u_int16_t ke_res1;
- /* KE data */
-};
-
-
-/* 3.5. Identification Payloads */
-enum ikev2_id_type {
- ID_IPV4_ADDR=1,
- ID_FQDN=2,
- ID_RFC822_ADDR=3,
- ID_IPV6_ADDR=5,
- ID_DER_ASN1_DN=9,
- ID_DER_ASN1_GN=10,
- ID_KEY_ID=11,
-};
-struct ikev2_id {
- struct isakmp_gen h;
- u_int8_t type; /* ID type */
- u_int8_t res1;
- u_int16_t res2;
- /* SPI */
- /* Notification Data */
-};
-
-/* 3.10 Notification Payload */
-struct ikev2_n {
- struct isakmp_gen h;
- u_int8_t prot_id; /* Protocol-ID */
- u_int8_t spi_size; /* SPI Size */
- u_int16_t type; /* Notify Message Type */
-};
-
-enum ikev2_n_type {
- IV2_NOTIFY_UNSUPPORTED_CRITICAL_PAYLOAD = 1,
- IV2_NOTIFY_INVALID_IKE_SPI = 4,
- IV2_NOTIFY_INVALID_MAJOR_VERSION = 5,
- IV2_NOTIFY_INVALID_SYNTAX = 7,
- IV2_NOTIFY_INVALID_MESSAGE_ID = 9,
- IV2_NOTIFY_INVALID_SPI =11,
- IV2_NOTIFY_NO_PROPOSAL_CHOSEN =14,
- IV2_NOTIFY_INVALID_KE_PAYLOAD =17,
- IV2_NOTIFY_AUTHENTICATION_FAILED =24,
- IV2_NOTIFY_SINGLE_PAIR_REQUIRED =34,
- IV2_NOTIFY_NO_ADDITIONAL_SAS =35,
- IV2_NOTIFY_INTERNAL_ADDRESS_FAILURE =36,
- IV2_NOTIFY_FAILED_CP_REQUIRED =37,
- IV2_NOTIFY_INVALID_SELECTORS =39,
- IV2_NOTIFY_INITIAL_CONTACT =16384,
- IV2_NOTIFY_SET_WINDOW_SIZE =16385,
- IV2_NOTIFY_ADDITIONAL_TS_POSSIBLE =16386,
- IV2_NOTIFY_IPCOMP_SUPPORTED =16387,
- IV2_NOTIFY_NAT_DETECTION_SOURCE_IP =16388,
- IV2_NOTIFY_NAT_DETECTION_DESTINATION_IP =16389,
- IV2_NOTIFY_COOKIE =16390,
- IV2_NOTIFY_USE_TRANSPORT_MODE =16391,
- IV2_NOTIFY_HTTP_CERT_LOOKUP_SUPPORTED =16392,
- IV2_NOTIFY_REKEY_SA =16393,
- IV2_NOTIFY_ESP_TFC_PADDING_NOT_SUPPORTED =16394,
- IV2_NOTIFY_NON_FIRST_FRAGMENTS_ALSO =16395
-};
-
-struct notify_messages {
- u_int16_t type;
- char *msg;
-};
-
-/* 3.8 Notification Payload */
-struct ikev2_auth {
- struct isakmp_gen h;
- u_int8_t auth_method; /* Protocol-ID */
- u_int8_t reserved[3];
- /* authentication data */
-};
-
-enum ikev2_auth_type {
- IV2_RSA_SIG = 1,
- IV2_SHARED = 2,
- IV2_DSS_SIG = 3,
-};
-
-#endif /* !defined(_ISAKMP_H_) */
diff --git a/freebsd/contrib/tcpdump/l2tp.h b/freebsd/contrib/tcpdump/l2tp.h
deleted file mode 100644
index 5be24b9f..00000000
--- a/freebsd/contrib/tcpdump/l2tp.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/l2tp.h,v 1.5 2001-11-05 10:03:27 guy Exp $ (LBL) */
-/*
- * Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that: (1) source code distributions
- * retain the above copyright notice and this paragraph in its entirety, (2)
- * distributions including binary code include the above copyright notice and
- * this paragraph in its entirety in the documentation or other materials
- * provided with the distribution, and (3) all advertising materials mentioning
- * features or use of this software display the following acknowledgement:
- * ``This product includes software developed by the University of California,
- * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
- * the University 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 ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * L2TP support contributed by Motonori Shindo (mshindo@mshindo.net)
- */
-
-
-#define L2TP_FLAG_TYPE 0x8000 /* Type (0=Data, 1=Control) */
-#define L2TP_FLAG_LENGTH 0x4000 /* Length */
-#define L2TP_FLAG_SEQUENCE 0x0800 /* Sequence */
-#define L2TP_FLAG_OFFSET 0x0200 /* Offset */
-#define L2TP_FLAG_PRIORITY 0x0100 /* Priority */
-
-#define L2TP_VERSION_MASK 0x000f /* Version Mask */
-#define L2TP_VERSION_L2F 0x0001 /* L2F */
-#define L2TP_VERSION_L2TP 0x0002 /* L2TP */
-
-#define L2TP_AVP_HDR_FLAG_MANDATORY 0x8000 /* Mandatory Flag */
-#define L2TP_AVP_HDR_FLAG_HIDDEN 0x4000 /* Hidden Flag */
-#define L2TP_AVP_HDR_LEN_MASK 0x03ff /* Length Mask */
-
-#define L2TP_FRAMING_CAP_SYNC_MASK 0x00000001 /* Synchronous */
-#define L2TP_FRAMING_CAP_ASYNC_MASK 0x00000002 /* Asynchronous */
-
-#define L2TP_FRAMING_TYPE_SYNC_MASK 0x00000001 /* Synchronous */
-#define L2TP_FRAMING_TYPE_ASYNC_MASK 0x00000002 /* Asynchronous */
-
-#define L2TP_BEARER_CAP_DIGITAL_MASK 0x00000001 /* Digital */
-#define L2TP_BEARER_CAP_ANALOG_MASK 0x00000002 /* Analog */
-
-#define L2TP_BEARER_TYPE_DIGITAL_MASK 0x00000001 /* Digital */
-#define L2TP_BEARER_TYPE_ANALOG_MASK 0x00000002 /* Analog */
-
-/* Authen Type */
-#define L2TP_AUTHEN_TYPE_RESERVED 0x0000 /* Reserved */
-#define L2TP_AUTHEN_TYPE_TEXTUAL 0x0001 /* Textual username/password exchange */
-#define L2TP_AUTHEN_TYPE_CHAP 0x0002 /* PPP CHAP */
-#define L2TP_AUTHEN_TYPE_PAP 0x0003 /* PPP PAP */
-#define L2TP_AUTHEN_TYPE_NO_AUTH 0x0004 /* No Authentication */
-#define L2TP_AUTHEN_TYPE_MSCHAPv1 0x0005 /* MSCHAPv1 */
-
-#define L2TP_PROXY_AUTH_ID_MASK 0x00ff
-
-
diff --git a/freebsd/contrib/tcpdump/l2vpn.c b/freebsd/contrib/tcpdump/l2vpn.c
index f869242b..c5743c1f 100644
--- a/freebsd/contrib/tcpdump/l2vpn.c
+++ b/freebsd/contrib/tcpdump/l2vpn.c
@@ -1,6 +1,9 @@
#include <machine/rtems-bsd-user-space.h>
-
-/*
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
+/*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code
* distributions retain the above copyright notice and this paragraph
@@ -15,46 +18,86 @@
* Original code by Hannes Gredler (hannes@juniper.net)
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/l2vpn.c,v 1.1 2004-06-15 09:42:40 hannes Exp $ (LBL)";
-#endif
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
-#include "interface.h"
+#include <netdissect-stdinc.h>
+#include "netdissect.h"
#include "l2vpn.h"
-/* draft-ietf-pwe3-iana-allocation-04 */
+/*
+ * BGP Layer 2 Encapsulation Types
+ *
+ * RFC 6624
+ *
+ * http://www.iana.org/assignments/bgp-parameters/bgp-parameters.xhtml#bgp-l2-encapsulation-types-registry
+ */
const struct tok l2vpn_encaps_values[] = {
- { 0x00, "Reserved"},
- { 0x01, "Frame Relay"},
- { 0x02, "ATM AAL5 VCC transport"},
- { 0x03, "ATM transparent cell transport"},
- { 0x04, "Ethernet VLAN"},
- { 0x05, "Ethernet"},
- { 0x06, "Cisco-HDLC"},
- { 0x07, "PPP"},
- { 0x08, "SONET/SDH Circuit Emulation Service over MPLS"},
- { 0x09, "ATM n-to-one VCC cell transport"},
- { 0x0a, "ATM n-to-one VPC cell transport"},
- { 0x0b, "IP Layer2 Transport"},
- { 0x0c, "ATM one-to-one VCC Cell Mode"},
- { 0x0d, "ATM one-to-one VPC Cell Mode"},
- { 0x0e, "ATM AAL5 PDU VCC transport"},
- { 0x0f, "Frame-Relay Port mode"},
- { 0x10, "SONET/SDH Circuit Emulation over Packet"},
- { 0x11, "Structure-agnostic E1 over Packet"},
- { 0x12, "Structure-agnostic T1 (DS1) over Packet"},
- { 0x13, "Structure-agnostic E3 over Packet"},
- { 0x14, "Structure-agnostic T3 (DS3) over Packet"},
- { 0x15, "CESoPSN basic mode"},
- { 0x16, "TDMoIP basic mode"},
- { 0x17, "CESoPSN TDM with CAS"},
- { 0x18, "TDMoIP TDM with CAS"},
- { 0x40, "IP-interworking"},
+ { 0, "Reserved"},
+ { 1, "Frame Relay"},
+ { 2, "ATM AAL5 SDU VCC transport"},
+ { 3, "ATM transparent cell transport"},
+ { 4, "Ethernet (VLAN) Tagged Mode"},
+ { 5, "Ethernet Raw Mode"},
+ { 6, "Cisco HDLC"},
+ { 7, "PPP"},
+ { 8, "SONET/SDH Circuit Emulation Service over MPLS"},
+ { 9, "ATM n-to-one VCC cell transport"},
+ { 10, "ATM n-to-one VPC cell transport"},
+ { 11, "IP layer 2 transport"},
+ { 15, "Frame Relay Port mode"},
+ { 17, "Structure-agnostic E1 over packet"},
+ { 18, "Structure-agnostic T1 (DS1) over packet"},
+ { 19, "VPLS"},
+ { 20, "Structure-agnostic T3 (DS3) over packet"},
+ { 21, "Nx64kbit/s Basic Service using Structure-aware"},
+ { 25, "Frame Relay DLCI"},
+ { 40, "Structure-agnostic E3 over packet"},
+ { 41, "Octet-aligned playload for Structure-agnostic DS1 circuits"},
+ { 42, "E1 Nx64kbit/s with CAS using Structure-aware"},
+ { 43, "DS1 (ESF) Nx64kbit/s with CAS using Structure-aware"},
+ { 44, "DS1 (SF) Nx64kbit/s with CAS using Structure-aware"},
+ { 0, NULL}
+};
+
+/*
+ * MPLS Pseudowire Types
+ *
+ * RFC 4446
+ *
+ * http://www.iana.org/assignments/pwe3-parameters/pwe3-parameters.xhtml#pwe3-parameters-2
+ */
+const struct tok mpls_pw_types_values[] = {
+ { 0x0000, "Reserved"},
+ { 0x0001, "Frame Relay DLCI (Martini Mode)"},
+ { 0x0002, "ATM AAL5 SDU VCC transport"},
+ { 0x0003, "ATM transparent cell transport"},
+ { 0x0004, "Ethernet VLAN"},
+ { 0x0005, "Ethernet"},
+ { 0x0006, "Cisco-HDLC"},
+ { 0x0007, "PPP"},
+ { 0x0008, "SONET/SDH Circuit Emulation Service over MPLS"},
+ { 0x0009, "ATM n-to-one VCC cell transport"},
+ { 0x000a, "ATM n-to-one VPC cell transport"},
+ { 0x000b, "IP Layer2 Transport"},
+ { 0x000c, "ATM one-to-one VCC Cell Mode"},
+ { 0x000d, "ATM one-to-one VPC Cell Mode"},
+ { 0x000e, "ATM AAL5 PDU VCC transport"},
+ { 0x000f, "Frame-Relay Port mode"},
+ { 0x0010, "SONET/SDH Circuit Emulation over Packet"},
+ { 0x0011, "Structure-agnostic E1 over Packet"},
+ { 0x0012, "Structure-agnostic T1 (DS1) over Packet"},
+ { 0x0013, "Structure-agnostic E3 over Packet"},
+ { 0x0014, "Structure-agnostic T3 (DS3) over Packet"},
+ { 0x0015, "CESoPSN basic mode"},
+ { 0x0016, "TDMoIP basic mode"},
+ { 0x0017, "CESoPSN TDM with CAS"},
+ { 0x0018, "TDMoIP TDM with CAS"},
+ { 0x0019, "Frame Relay DLCI"},
+ { 0x0040, "IP-interworking"},
{ 0, NULL}
};
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-l2vpn-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/l2vpn.h b/freebsd/contrib/tcpdump/l2vpn.h
index 871eca0e..d93abf15 100644
--- a/freebsd/contrib/tcpdump/l2vpn.h
+++ b/freebsd/contrib/tcpdump/l2vpn.h
@@ -1,5 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/l2vpn.h,v 1.1 2004-06-15 09:42:41 hannes Exp $ (LBL) */
-/*
+/*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code
* distributions retain the above copyright notice and this paragraph
@@ -15,3 +14,4 @@
*/
extern const struct tok l2vpn_encaps_values[];
+extern const struct tok mpls_pw_types_values[];
diff --git a/freebsd/contrib/tcpdump/lane.h b/freebsd/contrib/tcpdump/lane.h
deleted file mode 100644
index 76cc020e..00000000
--- a/freebsd/contrib/tcpdump/lane.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Marko Kiiskila carnil@cs.tut.fi
- *
- * Tampere University of Technology - Telecommunications Laboratory
- *
- * Permission to use, copy, modify and distribute this
- * software and its documentation is hereby granted,
- * provided that both the copyright notice and this
- * permission notice appear in all copies of the software,
- * derivative works or modified versions, and any portions
- * thereof, that both notices appear in supporting
- * documentation, and that the use of this software is
- * acknowledged in any publications resulting from using
- * the software.
- *
- * TUT ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION AND DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS
- * SOFTWARE.
- *
- */
-
-/* $Id: lane.h,v 1.7 2002-12-11 07:13:54 guy Exp $ */
-
-#ifndef ETHER_ADDR_LEN
-#define ETHER_ADDR_LEN 6
-#endif
-
-struct lecdatahdr_8023 {
- u_int16_t le_header;
- u_int8_t h_dest[ETHER_ADDR_LEN];
- u_int8_t h_source[ETHER_ADDR_LEN];
- u_int16_t h_type;
-};
-
-struct lane_controlhdr {
- u_int16_t lec_header;
- u_int8_t lec_proto;
- u_int8_t lec_vers;
- u_int16_t lec_opcode;
-};
diff --git a/freebsd/contrib/tcpdump/llc.h b/freebsd/contrib/tcpdump/llc.h
index faa72561..ec8d069e 100644
--- a/freebsd/contrib/tcpdump/llc.h
+++ b/freebsd/contrib/tcpdump/llc.h
@@ -17,8 +17,6 @@
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * @(#) $Header: /tcpdump/master/tcpdump/llc.h,v 1.23 2007-04-13 09:43:11 hannes Exp $ (LBL)
*/
/*
@@ -106,6 +104,7 @@
#define PID_CISCO_DTP 0x2004 /* Cisco Dynamic Trunk Protocol */
#define PID_CISCO_UDLD 0x0111 /* Unidirectional Link Detection */
#define PID_CISCO_PVST 0x010b /* Per VLAN Spanning Tree+ and RPVST+ */
+#define PID_CISCO_VLANBRIDGE 0x010c /* "VLAN Bridge", according to Wireshark */
/*
* PIDs for use with OUI_RFC2684.
diff --git a/freebsd/contrib/tcpdump/machdep.c b/freebsd/contrib/tcpdump/machdep.c
index 4d5e6b06..946f2e51 100644
--- a/freebsd/contrib/tcpdump/machdep.c
+++ b/freebsd/contrib/tcpdump/machdep.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1996, 1997
* The Regents of the University of California. All rights reserved.
@@ -21,11 +24,6 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/machdep.c,v 1.13 2003-12-15 03:53:21 guy Exp $ (LBL)";
-#endif
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -36,7 +34,7 @@ static const char rcsid[] _U_ =
* need to do to get it defined? This is clearly wrong, as we shouldn't
* have to include UNIX or Windows system header files to get it.
*/
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#ifndef HAVE___ATTRIBUTE__
#define __attribute__(x)
@@ -48,12 +46,24 @@ static const char rcsid[] _U_ =
#if !defined(HAVE_SNPRINTF)
int snprintf(char *, size_t, const char *, ...)
- __attribute__((format(printf, 3, 4)));
+#ifdef __ATTRIBUTE___FORMAT_OK
+ __attribute__((format(printf, 3, 4)))
+#endif /* __ATTRIBUTE___FORMAT_OK */
+ ;
#endif /* !defined(HAVE_SNPRINTF) */
#endif /* __osf__ */
#include "machdep.h"
+/*
+ * On platforms where the CPU doesn't support unaligned loads, force
+ * unaligned accesses to abort with SIGBUS, rather than being fixed
+ * up (slowly) by the OS kernel; on those platforms, misaligned accesses
+ * are bugs, and we want tcpdump to crash so that the bugs are reported.
+ *
+ * The only OS on which this is necessary is DEC OSF/1^W^WDigital
+ * UNIX^W^WTru64 UNIX.
+ */
int
abort_on_misalignment(char *ebuf _U_, size_t ebufsiz _U_)
{
@@ -67,3 +77,6 @@ abort_on_misalignment(char *ebuf _U_, size_t ebufsiz _U_)
#endif
return (0);
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-machdep-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/machdep.h b/freebsd/contrib/tcpdump/machdep.h
index 6328c826..ba8ed389 100644
--- a/freebsd/contrib/tcpdump/machdep.h
+++ b/freebsd/contrib/tcpdump/machdep.h
@@ -17,11 +17,9 @@
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * @(#) $Header: /tcpdump/master/tcpdump/machdep.h,v 1.2 2000-01-17 06:24:24 itojun Exp $ (LBL)
*/
-#ifndef tcpdump_machdep_h
-#define tcpdump_machdep_h
+#ifndef netdissect_machdep_h
+#define netdissect_machdep_h
int abort_on_misalignment(char *, size_t);
#endif
diff --git a/freebsd/contrib/tcpdump/mib.h b/freebsd/contrib/tcpdump/mib.h
index 92c6c2c5..6c8e63c9 100644
--- a/freebsd/contrib/tcpdump/mib.h
+++ b/freebsd/contrib/tcpdump/mib.h
@@ -8,7 +8,7 @@
/* parse problem: new name "mib" for mgmt.mib(1) ignored */
/* parse problem: no parent for 0.nullSpecific(0) */
-struct obj
+static struct obj
_proteon_obj = {
"proteon", 1, 0,
NULL, NULL
diff --git a/freebsd/contrib/tcpdump/mpls.h b/freebsd/contrib/tcpdump/mpls.h
index ae1c97e6..03cb4bf5 100644
--- a/freebsd/contrib/tcpdump/mpls.h
+++ b/freebsd/contrib/tcpdump/mpls.h
@@ -1,4 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/mpls.h,v 1.1 2004-06-14 14:47:58 hannes Exp $ (LBL)
+/*
* Copyright (C) 2001 WIDE Project. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/freebsd/contrib/tcpdump/nameser.h b/freebsd/contrib/tcpdump/nameser.h
index f441f3ea..e075f092 100644
--- a/freebsd/contrib/tcpdump/nameser.h
+++ b/freebsd/contrib/tcpdump/nameser.h
@@ -1,4 +1,3 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/nameser.h,v 1.16 2006-11-10 03:18:21 guy Exp $ (LBL) */
/*
* Copyright (c) 1983, 1989, 1993
* The Regents of the University of California. All rights reserved.
@@ -72,20 +71,6 @@
#define RRFIXEDSZ 10
/*
- * Internet nameserver port number
- */
-#define NAMESERVER_PORT 53
-
-/*
- * Port for multicast DNS; see
- *
- * http://files.multicastdns.org/draft-cheshire-dnsext-multicastdns.txt
- *
- * for the current mDNS spec.
- */
-#define MULTICASTDNS_PORT 5353
-
-/*
* Currently defined opcodes
*/
#define QUERY 0x0 /* standard query */
@@ -225,13 +210,13 @@
* Structure for query header.
*/
typedef struct {
- u_int16_t id; /* query identification number */
- u_int8_t flags1; /* first byte of flags */
- u_int8_t flags2; /* second byte of flags */
- u_int16_t qdcount; /* number of question entries */
- u_int16_t ancount; /* number of answer entries */
- u_int16_t nscount; /* number of authority entries */
- u_int16_t arcount; /* number of resource entries */
+ uint16_t id; /* query identification number */
+ uint8_t flags1; /* first byte of flags */
+ uint8_t flags2; /* second byte of flags */
+ uint16_t qdcount; /* number of question entries */
+ uint16_t ancount; /* number of answer entries */
+ uint16_t nscount; /* number of authority entries */
+ uint16_t arcount; /* number of resource entries */
} HEADER;
/*
@@ -262,36 +247,36 @@ struct rrec {
int16_t r_zone; /* zone number */
int16_t r_class; /* class number */
int16_t r_type; /* type number */
- u_int32_t r_ttl; /* time to live */
+ uint32_t r_ttl; /* time to live */
int r_size; /* size of data area */
char *r_data; /* pointer to data */
};
/*
* Inline versions of get/put short/long. Pointer is advanced.
- * We also assume that a "u_int16_t" holds 2 "chars"
- * and that a "u_int32_t" holds 4 "chars".
+ * We also assume that a "uint16_t" holds 2 "chars"
+ * and that a "uint32_t" holds 4 "chars".
*
* These macros demonstrate the property of C whereby it can be
* portable or it can be elegant but never both.
*/
#define GETSHORT(s, cp) { \
register u_char *t_cp = (u_char *)(cp); \
- (s) = ((u_int16_t)t_cp[0] << 8) | (u_int16_t)t_cp[1]; \
+ (s) = ((uint16_t)t_cp[0] << 8) | (uint16_t)t_cp[1]; \
(cp) += 2; \
}
#define GETLONG(l, cp) { \
register u_char *t_cp = (u_char *)(cp); \
- (l) = (((u_int32_t)t_cp[0]) << 24) \
- | (((u_int32_t)t_cp[1]) << 16) \
- | (((u_int32_t)t_cp[2]) << 8) \
- | (((u_int32_t)t_cp[3])); \
+ (l) = (((uint32_t)t_cp[0]) << 24) \
+ | (((uint32_t)t_cp[1]) << 16) \
+ | (((uint32_t)t_cp[2]) << 8) \
+ | (((uint32_t)t_cp[3])); \
(cp) += 4; \
}
#define PUTSHORT(s, cp) { \
- register u_int16_t t_s = (u_int16_t)(s); \
+ register uint16_t t_s = (uint16_t)(s); \
register u_char *t_cp = (u_char *)(cp); \
*t_cp++ = t_s >> 8; \
*t_cp = t_s; \
@@ -303,7 +288,7 @@ struct rrec {
* were depending on this "feature", you will lose.
*/
#define PUTLONG(l, cp) { \
- register u_int32_t t_l = (u_int32_t)(l); \
+ register uint32_t t_l = (uint32_t)(l); \
register u_char *t_cp = (u_char *)(cp); \
*t_cp++ = t_l >> 24; \
*t_cp++ = t_l >> 16; \
diff --git a/freebsd/contrib/tcpdump/netbios.h b/freebsd/contrib/tcpdump/netbios.h
deleted file mode 100644
index d3e2725f..00000000
--- a/freebsd/contrib/tcpdump/netbios.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * NETBIOS protocol formats
- *
- * @(#) $Header: /tcpdump/master/tcpdump/netbios.h,v 1.3 2002-12-11 07:13:55 guy Exp $
- */
-
-struct p8022Hdr {
- u_char dsap;
- u_char ssap;
- u_char flags;
-};
-
-#define p8022Size 3 /* min 802.2 header size */
-
-#define UI 0x03 /* 802.2 flags */
-
diff --git a/freebsd/contrib/tcpdump/tcpdump-stdinc.h b/freebsd/contrib/tcpdump/netdissect-stdinc.h
index d350d1be..c7070f0a 100644
--- a/freebsd/contrib/tcpdump/tcpdump-stdinc.h
+++ b/freebsd/contrib/tcpdump/netdissect-stdinc.h
@@ -27,69 +27,153 @@
* 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.
- *
- *
- * @(#) $Header: /tcpdump/master/tcpdump/tcpdump-stdinc.h,v 1.18 2007-11-24 18:13:33 mcr Exp $ (LBL)
*/
/*
* Include the appropriate OS header files on Windows and various flavors
- * of UNIX, and also define some additional items and include various
- * non-OS header files on Windows, and; this isolates most of the platform
+ * of UNIX, include various non-OS header files on Windows, and define
+ * various items as needed, to isolate most of netdissect's platform
* differences to this one file.
*/
-#ifndef tcpdump_stdinc_h
-#define tcpdump_stdinc_h
+#ifndef netdissect_stdinc_h
+#define netdissect_stdinc_h
-#ifdef WIN32
+#include <errno.h>
+#ifdef _WIN32
+
+/*
+ * Includes and definitions for Windows.
+ */
+
+#include <stdint.h>
#include <stdio.h>
#include <winsock2.h>
-#include <Ws2tcpip.h>
-#include "bittypes.h"
+#include <ws2tcpip.h>
#include <ctype.h>
#include <time.h>
#include <io.h>
#include <fcntl.h>
#include <sys/types.h>
-#include <net/netdb.h> /* in wpcap's Win32/include */
-#ifndef NBBY
-#define NBBY 8
+#ifndef uint8_t
+#define uint8_t unsigned char
+#endif
+
+#ifndef int8_t
+#define int8_t signed char
+#endif
+
+#ifndef uint16_t
+#define uint16_t unsigned short
+#endif
+
+#ifndef int16_t
+#define int16_t signed short
+#endif
+
+#ifndef uint32_t
+#define uint32_t unsigned int
+#endif
+
+#ifndef int32_t
+#define int32_t signed int
+#endif
+
+#ifdef _MSC_EXTENSIONS
+
+#ifndef uint64_t
+#define uint64_t unsigned _int64
+#endif
+
+#ifndef int64_t
+#define int64_t _int64
+#endif
+
+#ifndef PRId64
+#define PRId64 "I64d"
+#endif
+
+#ifndef PRIo64
+#define PRIo64 "I64o"
+#endif
+
+#ifndef PRIu64
+#define PRIu64 "I64u"
#endif
-#if !defined(__MINGW32__) && !defined(__WATCOMC__)
-#undef toascii
-#define isascii __isascii
-#define toascii __toascii
+#ifndef PRIx64
+#define PRIx64 "I64x"
+#endif
+
+#else /* _MSC_EXTENSIONS */
+
+#ifndef uint64_t
+#define uint64_t unsigned long long
+#endif
+
+#ifndef int64_t
+#define int64_t long long
+#endif
+
+#ifndef PRId64
+#define PRId64 "lld"
+#endif
+
+#ifndef PRIo64
+#define PRIo64 "llo"
+#endif
+
+#ifndef PRIu64
+#define PRIu64 "llu"
+#endif
+
+#ifndef PRIx64
+#define PRIx64 "llx"
+#endif
+
+#endif /* _MSC_EXTENSIONS */
+
+/*
+ * Suppress definition of intN_t in bittypes.h, as included by <pcap/pcap.h>
+ * on Windows.
+ * (Yes, HAVE_U_INTn_T, as the definition guards are UN*X-oriented, and
+ * we check for u_intN_t in the UN*X configure script.)
+ */
+#define HAVE_U_INT8_T
+#define HAVE_U_INT16_T
+#define HAVE_U_INT32_T
+#define HAVE_U_INT64_T
+
+#ifdef _MSC_VER
#define stat _stat
#define open _open
#define fstat _fstat
#define read _read
#define close _close
#define O_RDONLY _O_RDONLY
+#endif /* _MSC_VER */
-typedef short ino_t;
-#endif /* __MINGW32__ */
-
-#ifdef __MINGW32__
-#include <stdint.h>
+/*
+ * With MSVC, for C, __inline is used to make a function an inline.
+ */
+#ifdef _MSC_VER
+#define inline __inline
#endif
-/* Protos for missing/x.c functions (ideally <missing/addrinfo.h>
- * should be used, but it clashes with <ws2tcpip.h>).
- */
-extern const char *inet_ntop (int, const void *, char *, size_t);
-extern int inet_pton (int, const char *, void *);
-extern int inet_aton (const char *cp, struct in_addr *addr);
+#ifdef AF_INET6
+#define HAVE_OS_IPV6_SUPPORT
+#endif
#ifndef INET6_ADDRSTRLEN
#define INET6_ADDRSTRLEN 46
#endif
-#ifndef toascii
-#define toascii(c) ((c) & 0x7f)
+/* It is in MSVC's <errno.h>, but not defined in MingW+Watcom.
+ */
+#ifndef EAFNOSUPPORT
+#define EAFNOSUPPORT WSAEAFNOSUPPORT
#endif
#ifndef caddr_t
@@ -97,26 +181,24 @@ typedef char* caddr_t;
#endif /* caddr_t */
#define MAXHOSTNAMELEN 64
-#define NI_MAXHOST 1025
#define snprintf _snprintf
#define vsnprintf _vsnprintf
#define RETSIGTYPE void
-#else /* WIN32 */
+#else /* _WIN32 */
+
+/*
+ * Includes and definitions for various flavors of UN*X.
+ */
#include <ctype.h>
#include <unistd.h>
#include <netdb.h>
#if HAVE_INTTYPES_H
#include <inttypes.h>
-#else
-#if HAVE_STDINT_H
+#elif HAVE_STDINT_H
#include <stdint.h>
#endif
-#endif
-#ifdef HAVE_SYS_BITYPES_H
-#include <sys/bitypes.h>
-#endif
#include <sys/param.h>
#include <sys/types.h> /* concession to AIX */
#include <sys/time.h>
@@ -129,7 +211,7 @@ typedef char* caddr_t;
#include <arpa/inet.h>
-#endif /* WIN32 */
+#endif /* _WIN32 */
#ifndef HAVE___ATTRIBUTE__
#define __attribute__(x)
@@ -166,9 +248,16 @@ typedef char* caddr_t;
* Note: this also requires that padding be put into the structure,
* at least for compilers where it's implemented as __attribute__((packed)).
*/
+#if !(defined(_MSC_VER) && defined(UNALIGNED))
+/* MSVC may have its own macro defined with the same name and purpose. */
+#undef UNALIGNED
#define UNALIGNED __attribute__((packed))
+#endif
-#if defined(WIN32) || defined(MSDOS)
+/*
+ * fopen() read and write modes for text files and binary files.
+ */
+#if defined(_WIN32) || defined(MSDOS)
#define FOPEN_READ_TXT "rt"
#define FOPEN_READ_BIN "rb"
#define FOPEN_WRITE_TXT "wt"
@@ -180,7 +269,17 @@ typedef char* caddr_t;
#define FOPEN_WRITE_BIN FOPEN_WRITE_TXT
#endif
-#if defined(__GNUC__) && defined(__i386__) && !defined(__APPLE__) && !defined(__ntohl)
+/*
+ * Inline x86 assembler-language versions of ntoh[ls]() and hton[ls](),
+ * defined if the OS doesn't provide them. These assume no more than
+ * an 80386, so, for example, it avoids the bswap instruction added in
+ * the 80486.
+ *
+ * (We don't use them on OS X; Apple provides their own, which *doesn't*
+ * avoid the bswap instruction, as OS X only supports machines that
+ * have it.)
+ */
+#if defined(__GNUC__) && defined(__i386__) && !defined(__APPLE__) && !defined(__ntohl)
#undef ntohl
#undef ntohs
#undef htonl
@@ -211,6 +310,32 @@ typedef char* caddr_t;
}
#endif
+/*
+ * If the OS doesn't define AF_INET6 and struct in6_addr:
+ *
+ * define AF_INET6, so we can use it internally as a "this is an
+ * IPv6 address" indication;
+ *
+ * define struct in6_addr so that we can use it for IPv6 addresses.
+ */
+#ifndef HAVE_OS_IPV6_SUPPORT
+#ifndef AF_INET6
+#define AF_INET6 24
+
+struct in6_addr {
+ union {
+ __uint8_t __u6_addr8[16];
+ __uint16_t __u6_addr16[8];
+ __uint32_t __u6_addr32[4];
+ } __u6_addr; /* 128-bit IP6 address */
+};
+#endif
+#endif
+
+#ifndef NI_MAXHOST
+#define NI_MAXHOST 1025
+#endif
+
#ifndef INET_ADDRSTRLEN
#define INET_ADDRSTRLEN 16
#endif
@@ -223,4 +348,57 @@ typedef char* caddr_t;
#define FALSE 0
#endif
-#endif /* tcpdump_stdinc_h */
+/*
+ * The Apple deprecation workaround macros below were adopted from the
+ * FreeRADIUS server code under permission of Alan DeKok and Arran Cudbard-Bell.
+ */
+
+#define XSTRINGIFY(x) #x
+
+/*
+ * Macros for controlling warnings in GCC >= 4.2 and clang >= 2.8
+ */
+#define DIAG_JOINSTR(x,y) XSTRINGIFY(x ## y)
+#define DIAG_DO_PRAGMA(x) _Pragma (#x)
+
+#if defined(__GNUC__) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 402
+# define DIAG_PRAGMA(x) DIAG_DO_PRAGMA(GCC diagnostic x)
+# if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406
+# define DIAG_OFF(x) DIAG_PRAGMA(push) DIAG_PRAGMA(ignored DIAG_JOINSTR(-W,x))
+# define DIAG_ON(x) DIAG_PRAGMA(pop)
+# else
+# define DIAG_OFF(x) DIAG_PRAGMA(ignored DIAG_JOINSTR(-W,x))
+# define DIAG_ON(x) DIAG_PRAGMA(warning DIAG_JOINSTR(-W,x))
+# endif
+#elif defined(__clang__) && ((__clang_major__ * 100) + __clang_minor__ >= 208)
+# define DIAG_PRAGMA(x) DIAG_DO_PRAGMA(clang diagnostic x)
+# define DIAG_OFF(x) DIAG_PRAGMA(push) DIAG_PRAGMA(ignored DIAG_JOINSTR(-W,x))
+# define DIAG_ON(x) DIAG_PRAGMA(pop)
+#else
+# define DIAG_OFF(x)
+# define DIAG_ON(x)
+#endif
+
+/*
+ * For dealing with APIs which are only deprecated in OSX (like the OpenSSL API)
+ */
+#ifdef __APPLE__
+# define USES_APPLE_DEPRECATED_API DIAG_OFF(deprecated-declarations)
+# define USES_APPLE_RST DIAG_ON(deprecated-declarations)
+#else
+# define USES_APPLE_DEPRECATED_API
+# define USES_APPLE_RST
+#endif
+
+/*
+ * end of Apple deprecation workaround macros
+ */
+
+#ifndef min
+#define min(a,b) ((a)>(b)?(b):(a))
+#endif
+#ifndef max
+#define max(a,b) ((b)>(a)?(b):(a))
+#endif
+
+#endif /* netdissect_stdinc_h */
diff --git a/freebsd/contrib/tcpdump/netdissect.c b/freebsd/contrib/tcpdump/netdissect.c
new file mode 100644
index 00000000..6aa4a204
--- /dev/null
+++ b/freebsd/contrib/tcpdump/netdissect.c
@@ -0,0 +1,154 @@
+#include <machine/rtems-bsd-user-space.h>
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
+/*
+ * Copyright (c) 1988-1997
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Copyright (c) 1998-2012 Michael Richardson <mcr@tcpdump.org>
+ * The TCPDUMP project
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code distributions
+ * retain the above copyright notice and this paragraph in its entirety, (2)
+ * distributions including binary code include the above copyright notice and
+ * this paragraph in its entirety in the documentation or other materials
+ * provided with the distribution, and (3) all advertising materials mentioning
+ * features or use of this software display the following acknowledgement:
+ * ``This product includes software developed by the University of California,
+ * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
+ * the University 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 ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <netdissect-stdinc.h>
+#include "netdissect.h"
+#include <string.h>
+#include <stdio.h>
+
+#ifdef USE_LIBSMI
+#include <smi.h>
+#endif
+
+/*
+ * Initialize anything that must be initialized before dissecting
+ * packets.
+ *
+ * This should be called at the beginning of the program; it does
+ * not need to be called, and should not be called, for every
+ * netdissect_options structure.
+ */
+int
+nd_init(char *errbuf, size_t errbuf_size)
+{
+#ifdef _WIN32
+ WORD wVersionRequested;
+ WSADATA wsaData;
+ int err;
+
+ /*
+ * Request Winsock 2.2; we expect Winsock 2.
+ */
+ wVersionRequested = MAKEWORD(2, 2);
+ err = WSAStartup(wVersionRequested, &wsaData);
+ if (err != 0) {
+ strlcpy(errbuf, "Attempting to initialize Winsock failed",
+ errbuf_size);
+ return (-1);
+ }
+#endif /* _WIN32 */
+
+#ifdef USE_LIBSMI
+ /*
+ * XXX - should we just fail if this fails? Some of the
+ * libsmi calls may fail.
+ */
+ smiInit("tcpdump");
+#endif
+
+ /*
+ * Clears the error buffer, and uses it so we don't get
+ * "unused argument" warnings at compile time.
+ */
+ strlcpy(errbuf, "", errbuf_size);
+ return (0);
+}
+
+/*
+ * Clean up anything that ndo_init() did.
+ */
+void
+nd_cleanup(void)
+{
+#ifdef USE_LIBSMI
+ /*
+ * This appears, in libsmi 0.4.8, to do nothing if smiInit()
+ * wasn't done or failed, so we call it unconditionally.
+ */
+ smiExit();
+#endif
+
+#ifdef _WIN32
+ /*
+ * Undo the WSAStartup() call above.
+ */
+ WSACleanup();
+#endif
+}
+
+int
+nd_have_smi_support(void)
+{
+#ifdef USE_LIBSMI
+ return (1);
+#else
+ return (0);
+#endif
+}
+
+/*
+ * Indicates whether an SMI module has been loaded, so that we can use
+ * libsmi to translate OIDs.
+ */
+int nd_smi_module_loaded;
+
+int
+nd_load_smi_module(const char *module, char *errbuf, size_t errbuf_size)
+{
+#ifdef USE_LIBSMI
+ if (smiLoadModule(module) == 0) {
+ snprintf(errbuf, errbuf_size, "could not load MIB module %s",
+ module);
+ return (-1);
+ }
+ nd_smi_module_loaded = 1;
+ return (0);
+#else
+ snprintf(errbuf, errbuf_size, "MIB module %s not loaded: no libsmi support",
+ module);
+ return (-1);
+#endif
+}
+
+const char *
+nd_smi_version_string(void)
+{
+#ifdef USE_LIBSMI
+ return (smi_version_string);
+#else
+ return (NULL);
+#endif
+}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-netdissect-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/netdissect.h b/freebsd/contrib/tcpdump/netdissect.h
index be6fb119..1d28c0b7 100644
--- a/freebsd/contrib/tcpdump/netdissect.h
+++ b/freebsd/contrib/tcpdump/netdissect.h
@@ -20,8 +20,6 @@
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * @(#) $Header: /tcpdump/master/tcpdump/netdissect.h,v 1.27 2008-08-16 11:36:20 hannes Exp $ (LBL)
*/
#ifndef netdissect_h
@@ -36,19 +34,68 @@
#define __attribute__(x)
#endif
+/*
+ * Data types corresponding to multi-byte integral values within data
+ * structures. These are defined as arrays of octets, so that they're
+ * not aligned on their "natural" boundaries, and so that you *must*
+ * use the EXTRACT_ macros to extract them (which you should be doing
+ * *anyway*, so as not to assume a particular byte order or alignment
+ * in your code).
+ */
+typedef unsigned char nd_uint16_t[2];
+typedef unsigned char nd_uint24_t[3];
+typedef unsigned char nd_uint32_t[4];
+typedef unsigned char nd_uint40_t[5];
+typedef unsigned char nd_uint48_t[6];
+typedef unsigned char nd_uint56_t[7];
+typedef unsigned char nd_uint64_t[8];
+
+/*
+ * Use this for IPv4 addresses. It's defined as an array of octets, so
+ * that it's not aligned on its "natural" boundary, and it's defined as
+ * a structure in the hopes that this makes it harder to naively use
+ * EXTRACT_32BITS() to extract the value - in many cases you just want
+ * to use UNALIGNED_MEMCPY() to copy its value, so that it remains in
+ * network byte order.
+ */
+typedef struct {
+ unsigned char bytes[4];
+} nd_ipv4;
+
+/*
+ * Data types corresponding to single-byte integral values, for
+ * completeness.
+ */
+typedef unsigned char nd_uint8_t;
+typedef signed char nd_int8_t;
+
/* snprintf et al */
#include <stdarg.h>
+#include <pcap.h>
+
+#include "ip.h" /* struct ip for nextproto4_cksum() */
+#include "ip6.h" /* struct ip6 for nextproto6_cksum() */
+
+extern int32_t thiszone; /* seconds offset from gmt to local time */
+/* invalid string to print '(invalid)' for malformed or corrupted packets */
+extern const char istr[];
#if !defined(HAVE_SNPRINTF)
int snprintf (char *str, size_t sz, const char *format, ...)
- __attribute__ ((format (printf, 3, 4)));
-#endif
+#ifdef __ATTRIBUTE___FORMAT_OK
+ __attribute__((format (printf, 3, 4)))
+#endif /* __ATTRIBUTE___FORMAT_OK */
+ ;
+#endif /* !defined(HAVE_SNPRINTF) */
#if !defined(HAVE_VSNPRINTF)
int vsnprintf (char *str, size_t sz, const char *format, va_list ap)
- __attribute__((format (printf, 3, 0)));
-#endif
+#ifdef __ATTRIBUTE___FORMAT_OK
+ __attribute__((format (printf, 3, 0)))
+#endif /* __ATTRIBUTE___FORMAT_OK */
+ ;
+#endif /* !defined(HAVE_VSNPRINTF) */
#ifndef HAVE_STRLCAT
extern size_t strlcat (char *, const char *, size_t);
@@ -66,24 +113,39 @@ extern char *strsep(char **, const char *);
#endif
struct tok {
- int v; /* value */
+ u_int v; /* value */
const char *s; /* string */
};
-#define TOKBUFSIZE 128
-extern const char *tok2strbuf(const struct tok *, const char *, int,
+extern const char *tok2strbuf(const struct tok *, const char *, u_int,
char *buf, size_t bufsize);
/* tok2str is deprecated */
-extern const char *tok2str(const struct tok *, const char *, int);
-extern char *bittok2str(const struct tok *, const char *, int);
-extern char *bittok2str_nosep(const struct tok *, const char *, int);
-
+extern const char *tok2str(const struct tok *, const char *, u_int);
+extern char *bittok2str(const struct tok *, const char *, u_int);
+extern char *bittok2str_nosep(const struct tok *, const char *, u_int);
+
+/* Initialize netdissect. */
+extern int nd_init(char *, size_t);
+/* Clean up netdissect. */
+extern void nd_cleanup(void);
+
+/* Do we have libsmi support? */
+extern int nd_have_smi_support(void);
+/* Load an SMI module. */
+extern int nd_load_smi_module(const char *, char *, size_t);
+/* Flag indicating whether an SMI module has been loaded. */
+extern int nd_smi_module_loaded;
+/* Version number of the SMI library, or NULL if we don't have libsmi support. */
+extern const char *nd_smi_version_string(void);
typedef struct netdissect_options netdissect_options;
+#define IF_PRINTER_ARGS (netdissect_options *, const struct pcap_pkthdr *, const u_char *)
+
+typedef u_int (*if_printer) IF_PRINTER_ARGS;
+
struct netdissect_options {
- int ndo_aflag; /* translate network and broadcast addresses */
int ndo_bflag; /* print 4 byte ASes in ASDOT notation */
int ndo_eflag; /* print ethernet header */
int ndo_fflag; /* don't translate "foreign" IP address */
@@ -91,77 +153,60 @@ struct netdissect_options {
int ndo_nflag; /* leave addresses as numbers */
int ndo_Nflag; /* remove domains from printed host names */
int ndo_qflag; /* quick (shorter) output */
- int ndo_Rflag; /* print sequence # field in AH/ESP*/
- int ndo_sflag; /* use the libsmi to translate OIDs */
int ndo_Sflag; /* print raw TCP sequence numbers */
int ndo_tflag; /* print packet arrival time */
- int ndo_Uflag; /* "unbuffered" output of dump files */
int ndo_uflag; /* Print undecoded NFS handles */
- int ndo_vflag; /* verbose */
+ int ndo_vflag; /* verbosity level */
int ndo_xflag; /* print packet in hex */
int ndo_Xflag; /* print packet in hex/ascii */
int ndo_Aflag; /* print packet only in ascii observing TAB,
* LF, CR and SPACE as graphical chars
*/
- int ndo_Bflag; /* buffer size */
- int ndo_Iflag; /* rfmon (monitor) mode */
- int ndo_Oflag; /* run filter code optimizer */
- int ndo_dlt; /* if != -1, ask libpcap for the DLT it names*/
- int ndo_jflag; /* packet time stamp source */
- int ndo_pflag; /* don't go promiscuous */
-
- int ndo_Cflag; /* rotate dump files after this many bytes */
- int ndo_Cflag_count; /* Keep track of which file number we're writing */
- int ndo_Gflag; /* rotate dump files after this many seconds */
- int ndo_Gflag_count; /* number of files created with Gflag rotation */
- time_t ndo_Gflag_time; /* The last time_t the dump file was rotated. */
- int ndo_Wflag; /* recycle output files after this number of files */
- int ndo_WflagChars;
int ndo_Hflag; /* dissect 802.11s draft mesh standard */
+ int ndo_packet_number; /* print a packet number in the beginning of line */
int ndo_suppress_default_print; /* don't use default_print() for unknown packet types */
- const char *ndo_dltname;
+ int ndo_tstamp_precision; /* requested time stamp precision */
+ const char *program_name; /* Name of the program using the library */
char *ndo_espsecret;
struct sa_list *ndo_sa_list_head; /* used by print-esp.c */
struct sa_list *ndo_sa_default;
- char *ndo_sigsecret; /* Signature verification secret key */
-
- struct esp_algorithm *ndo_espsecret_xform; /* cache of decoded */
- char *ndo_espsecret_key;
+ char *ndo_sigsecret; /* Signature verification secret key */
int ndo_packettype; /* as specified by -T */
- char *ndo_program_name; /*used to generate self-identifying messages */
-
- int32_t ndo_thiszone; /* seconds offset from gmt to local time */
-
int ndo_snaplen;
/*global pointers to beginning and end of current packet (during printing) */
const u_char *ndo_packetp;
const u_char *ndo_snapend;
- /* bookkeeping for ^T output */
- int ndo_infodelay;
+ /* pointer to the if_printer function */
+ if_printer ndo_if_printer;
/* pointer to void function to output stuff */
void (*ndo_default_print)(netdissect_options *,
- register const u_char *bp, register u_int length);
- void (*ndo_info)(netdissect_options *, int verbose);
+ register const u_char *bp, register u_int length);
+ /* pointer to function to do regular output */
int (*ndo_printf)(netdissect_options *,
const char *fmt, ...)
#ifdef __ATTRIBUTE___FORMAT_OK_FOR_FUNCTION_POINTERS
__attribute__ ((format (printf, 2, 3)))
#endif
;
+ /* pointer to function to output errors */
void (*ndo_error)(netdissect_options *,
const char *fmt, ...)
+#ifdef __ATTRIBUTE___NORETURN_OK_FOR_FUNCTION_POINTERS
+ __attribute__ ((noreturn))
+#endif /* __ATTRIBUTE___NORETURN_OK_FOR_FUNCTION_POINTERS */
#ifdef __ATTRIBUTE___FORMAT_OK_FOR_FUNCTION_POINTERS
- __attribute__ ((noreturn, format (printf, 2, 3)))
-#endif
+ __attribute__ ((format (printf, 2, 3)))
+#endif /* __ATTRIBUTE___FORMAT_OK_FOR_FUNCTION_POINTERS */
;
+ /* pointer to function to output warnings */
void (*ndo_warning)(netdissect_options *,
const char *fmt, ...)
#ifdef __ATTRIBUTE___FORMAT_OK_FOR_FUNCTION_POINTERS
@@ -183,6 +228,10 @@ struct netdissect_options {
#define PT_RADIUS 11 /* RADIUS authentication Protocol */
#define PT_ZMTP1 12 /* ZeroMQ Message Transport Protocol 1.0 */
#define PT_VXLAN 13 /* Virtual eXtensible Local Area Network */
+#define PT_PGM 14 /* [UDP-encapsulated] Pragmatic General Multicast */
+#define PT_PGM_ZMTP1 15 /* ZMTP/1.0 inside PGM (native or UDP-encapsulated) */
+#define PT_LMP 16 /* Link Management Protocol */
+#define PT_RESP 17 /* RESP */
#ifndef min
#define min(a,b) ((a)>(b)?(b):(a))
@@ -191,16 +240,33 @@ struct netdissect_options {
#define max(a,b) ((b)>(a)?(b):(a))
#endif
+/* For source or destination ports tests (UDP, TCP, ...) */
+#define IS_SRC_OR_DST_PORT(p) (sport == (p) || dport == (p))
+
/*
* Maximum snapshot length. This should be enough to capture the full
* packet on most network interfaces.
*
- * XXX - could it be larger? If so, should it? Some applications might
- * use the snapshot length in a savefile header to control the size of
- * the buffer they allocate, so a size of, say, 2^31-1 might not work
- * well.
+ *
+ * Somewhat arbitrary, but chosen to be:
+ *
+ * 1) big enough for maximum-size Linux loopback packets (65549)
+ * and some USB packets captured with USBPcap:
+ *
+ * http://desowin.org/usbpcap/
+ *
+ * (> 131072, < 262144)
+ *
+ * and
+ *
+ * 2) small enough not to cause attempts to allocate huge amounts of
+ * memory; some applications might use the snapshot length in a
+ * savefile header to control the size of the buffer they allocate,
+ * so a size of, say, 2^31-1 might not work well.
+ *
+ * XXX - does it need to be bigger still?
*/
-#define MAXIMUM_SNAPLEN 65535
+#define MAXIMUM_SNAPLEN 262144
/*
* The default snapshot length is the maximum.
@@ -224,9 +290,30 @@ struct netdissect_options {
* "l" isn't so large that "ndo->ndo_snapend - (l)" underflows.
*
* The check is for <= rather than < because "l" might be 0.
+ *
+ * We cast the pointers to uintptr_t to make sure that the compiler
+ * doesn't optimize away any of these tests (which it is allowed to
+ * do, as adding an integer to, or subtracting an integer from, a
+ * pointer assumes that the pointer is a pointer to an element of an
+ * array and that the result of the addition or subtraction yields a
+ * pointer to another member of the array, so that, for example, if
+ * you subtract a positive integer from a pointer, the result is
+ * guaranteed to be less than the original pointer value). See
+ *
+ * http://www.kb.cert.org/vuls/id/162289
*/
-#define ND_TTEST2(var, l) (ndo->ndo_snapend - (l) <= ndo->ndo_snapend && \
- (const u_char *)&(var) <= ndo->ndo_snapend - (l))
+
+/*
+ * Test in two parts to avoid these warnings:
+ * comparison of unsigned expression >= 0 is always true [-Wtype-limits],
+ * comparison is always true due to limited range of data type [-Wtype-limits].
+ */
+#define IS_NOT_NEGATIVE(x) (((x) > 0) || ((x) == 0))
+
+#define ND_TTEST2(var, l) \
+ (IS_NOT_NEGATIVE(l) && \
+ ((uintptr_t)ndo->ndo_snapend - (l) <= (uintptr_t)ndo->ndo_snapend && \
+ (uintptr_t)&(var) <= (uintptr_t)ndo->ndo_snapend - (l)))
/* True if "var" was captured */
#define ND_TTEST(var) ND_TTEST2(var, sizeof(var))
@@ -240,276 +327,338 @@ struct netdissect_options {
#define ND_PRINT(STUFF) (*ndo->ndo_printf)STUFF
#define ND_DEFAULTPRINT(ap, length) (*ndo->ndo_default_print)(ndo, ap, length)
-#if 0
-extern void ts_print(netdissect_options *ipdo,
- const struct timeval *);
-extern void relts_print(int);
-#endif
+extern void ts_print(netdissect_options *, const struct timeval *);
+extern void signed_relts_print(netdissect_options *, int32_t);
+extern void unsigned_relts_print(netdissect_options *, uint32_t);
-extern int fn_print(const u_char *, const u_char *);
-extern int fn_printn(const u_char *, u_int, const u_char *);
-extern const char *tok2str(const struct tok *, const char *, int);
+extern void fn_print_char(netdissect_options *, u_char);
+extern int fn_print(netdissect_options *, const u_char *, const u_char *);
+extern u_int fn_printztn(netdissect_options *ndo, const u_char *, u_int, const u_char *);
+extern int fn_printn(netdissect_options *, const u_char *, u_int, const u_char *);
+extern int fn_printzp(netdissect_options *, const u_char *, u_int, const u_char *);
-extern void wrapup(int);
+/*
+ * Flags for txtproto_print().
+ */
+#define RESP_CODE_SECOND_TOKEN 0x00000001 /* response code is second token in response line */
-#if 0
-extern char *read_infile(netdissect_options *, char *);
-extern char *copy_argv(netdissect_options *, char **);
-#endif
+extern void txtproto_print(netdissect_options *, const u_char *, u_int,
+ const char *, const char **, u_int);
+
+/*
+ * Locale-independent macros for testing character properties and
+ * stripping the 8th bit from characters. Assumed to be handed
+ * a value between 0 and 255, i.e. don't hand them a char, as
+ * those might be in the range -128 to 127.
+ */
+#define ND_ISASCII(c) (!((c) & 0x80)) /* value is an ASCII code point */
+#define ND_ISPRINT(c) ((c) >= 0x20 && (c) <= 0x7E)
+#define ND_ISGRAPH(c) ((c) > 0x20 && (c) <= 0x7E)
+#define ND_TOASCII(c) ((c) & 0x7F)
-extern void safeputchar(int);
-extern void safeputs(const char *, int);
+extern void safeputchar(netdissect_options *, const u_char);
+extern void safeputs(netdissect_options *, const u_char *, const u_int);
+
+#ifdef LBL_ALIGN
+/*
+ * The processor doesn't natively handle unaligned loads,
+ * and the compiler might "helpfully" optimize memcpy()
+ * and memcmp(), when handed pointers that would normally
+ * be properly aligned, into sequences that assume proper
+ * alignment.
+ *
+ * Do copies and compares of possibly-unaligned data by
+ * calling routines that wrap memcpy() and memcmp(), to
+ * prevent that optimization.
+ */
+extern void unaligned_memcpy(void *, const void *, size_t);
+extern int unaligned_memcmp(const void *, const void *, size_t);
+#define UNALIGNED_MEMCPY(p, q, l) unaligned_memcpy((p), (q), (l))
+#define UNALIGNED_MEMCMP(p, q, l) unaligned_memcmp((p), (q), (l))
+#else
+/*
+ * The procesor natively handles unaligned loads, so just use memcpy()
+ * and memcmp(), to enable those optimizations.
+ */
+#define UNALIGNED_MEMCPY(p, q, l) memcpy((p), (q), (l))
+#define UNALIGNED_MEMCMP(p, q, l) memcmp((p), (q), (l))
+#endif
#define PLURAL_SUFFIX(n) \
(((n) != 1) ? "s" : "")
-#if 0
-extern const char *isonsap_string(netdissect_options *, const u_char *);
-extern const char *protoid_string(netdissect_options *, const u_char *);
-extern const char *dnname_string(netdissect_options *, u_short);
-extern const char *dnnum_string(netdissect_options *, u_short);
-#endif
+extern const char *tok2strary_internal(const char **, int, const char *, int);
+#define tok2strary(a,f,i) tok2strary_internal(a, sizeof(a)/sizeof(a[0]),f,i)
-/* The printer routines. */
+extern if_printer lookup_printer(int);
-#include <pcap.h>
+/* The DLT printer routines */
+
+extern u_int ap1394_if_print IF_PRINTER_ARGS;
+extern u_int arcnet_if_print IF_PRINTER_ARGS;
+extern u_int arcnet_linux_if_print IF_PRINTER_ARGS;
+extern u_int atm_if_print IF_PRINTER_ARGS;
+extern u_int bt_if_print IF_PRINTER_ARGS;
+extern u_int chdlc_if_print IF_PRINTER_ARGS;
+extern u_int cip_if_print IF_PRINTER_ARGS;
+extern u_int enc_if_print IF_PRINTER_ARGS;
+extern u_int ether_if_print IF_PRINTER_ARGS;
+extern u_int fddi_if_print IF_PRINTER_ARGS;
+extern u_int fr_if_print IF_PRINTER_ARGS;
+extern u_int ieee802_11_if_print IF_PRINTER_ARGS;
+extern u_int ieee802_11_radio_avs_if_print IF_PRINTER_ARGS;
+extern u_int ieee802_11_radio_if_print IF_PRINTER_ARGS;
+extern u_int ieee802_15_4_if_print IF_PRINTER_ARGS;
+extern u_int ipfc_if_print IF_PRINTER_ARGS;
+extern u_int ipnet_if_print IF_PRINTER_ARGS;
+extern u_int juniper_atm1_print IF_PRINTER_ARGS;
+extern u_int juniper_atm2_print IF_PRINTER_ARGS;
+extern u_int juniper_chdlc_print IF_PRINTER_ARGS;
+extern u_int juniper_es_print IF_PRINTER_ARGS;
+extern u_int juniper_ether_print IF_PRINTER_ARGS;
+extern u_int juniper_frelay_print IF_PRINTER_ARGS;
+extern u_int juniper_ggsn_print IF_PRINTER_ARGS;
+extern u_int juniper_mfr_print IF_PRINTER_ARGS;
+extern u_int juniper_mlfr_print IF_PRINTER_ARGS;
+extern u_int juniper_mlppp_print IF_PRINTER_ARGS;
+extern u_int juniper_monitor_print IF_PRINTER_ARGS;
+extern u_int juniper_ppp_print IF_PRINTER_ARGS;
+extern u_int juniper_pppoe_atm_print IF_PRINTER_ARGS;
+extern u_int juniper_pppoe_print IF_PRINTER_ARGS;
+extern u_int juniper_services_print IF_PRINTER_ARGS;
+extern u_int lane_if_print IF_PRINTER_ARGS;
+extern u_int ltalk_if_print IF_PRINTER_ARGS;
+extern u_int mfr_if_print IF_PRINTER_ARGS;
+extern u_int netanalyzer_if_print IF_PRINTER_ARGS;
+extern u_int netanalyzer_transparent_if_print IF_PRINTER_ARGS;
+extern u_int nflog_if_print IF_PRINTER_ARGS;
+extern u_int null_if_print IF_PRINTER_ARGS;
+extern u_int pflog_if_print IF_PRINTER_ARGS;
+extern u_int pktap_if_print IF_PRINTER_ARGS;
+extern u_int ppi_if_print IF_PRINTER_ARGS;
+extern u_int ppp_bsdos_if_print IF_PRINTER_ARGS;
+extern u_int ppp_hdlc_if_print IF_PRINTER_ARGS;
+extern u_int ppp_if_print IF_PRINTER_ARGS;
+extern u_int pppoe_if_print IF_PRINTER_ARGS;
+extern u_int prism_if_print IF_PRINTER_ARGS;
+extern u_int raw_if_print IF_PRINTER_ARGS;
+extern u_int sl_bsdos_if_print IF_PRINTER_ARGS;
+extern u_int sl_if_print IF_PRINTER_ARGS;
+extern u_int sll_if_print IF_PRINTER_ARGS;
+extern u_int sunatm_if_print IF_PRINTER_ARGS;
+extern u_int symantec_if_print IF_PRINTER_ARGS;
+extern u_int token_if_print IF_PRINTER_ARGS;
+extern u_int usb_linux_48_byte_print IF_PRINTER_ARGS;
+extern u_int usb_linux_64_byte_print IF_PRINTER_ARGS;
-typedef u_int (*if_ndo_printer)(struct netdissect_options *ndo,
- const struct pcap_pkthdr *, const u_char *);
-typedef u_int (*if_printer)(const struct pcap_pkthdr *, const u_char *);
+/*
+ * Structure passed to some printers to allow them to print
+ * link-layer address information if ndo_eflag isn't set
+ * (because they are for protocols that don't have their
+ * own addresses, so that we'd want to report link-layer
+ * address information).
+ *
+ * This contains a pointer to an address and a pointer to a routine
+ * to which we pass that pointer in order to get a string.
+ */
+struct lladdr_info {
+ const char *(*addr_string)(netdissect_options *, const u_char *);
+ const u_char *addr;
+};
-extern if_ndo_printer lookup_ndo_printer(int);
-extern if_printer lookup_printer(int);
+/* The printer routines. */
-extern void eap_print(netdissect_options *,const u_char *, u_int);
-extern int esp_print(netdissect_options *,
- register const u_char *bp, int len, register const u_char *bp2,
- int *nhdr, int *padlen);
-extern void arp_print(netdissect_options *,const u_char *, u_int, u_int);
+extern void aarp_print(netdissect_options *, const u_char *, u_int);
+extern int ah_print(netdissect_options *, register const u_char *);
+extern void ahcp_print(netdissect_options *, const u_char *, const u_int);
+extern void aodv_print(netdissect_options *, const u_char *, u_int, int);
+extern void aoe_print(netdissect_options *, const u_char *, const u_int);
+extern void arp_print(netdissect_options *, const u_char *, u_int, u_int);
+extern void ascii_print(netdissect_options *, const u_char *, u_int);
+extern void atalk_print(netdissect_options *, const u_char *, u_int);
+extern void atm_print(netdissect_options *, u_int, u_int, u_int, const u_char *, u_int, u_int);
+extern void babel_print(netdissect_options *, const u_char *, u_int);
+extern void beep_print(netdissect_options *, const u_char *, u_int);
+extern void bfd_print(netdissect_options *, const u_char *, u_int, u_int);
+extern void bgp_print(netdissect_options *, const u_char *, int);
+extern char *bgp_vpn_rd_print (netdissect_options *, const u_char *);
+extern void bootp_print(netdissect_options *, const u_char *, u_int);
+extern void calm_fast_print(netdissect_options *, const u_char *, u_int, const struct lladdr_info *);
+extern void carp_print(netdissect_options *, const u_char *, u_int, int);
+extern void cdp_print(netdissect_options *, const u_char *, u_int, u_int);
+extern void cfm_print(netdissect_options *, const u_char *, u_int);
+extern u_int chdlc_print(netdissect_options *, register const u_char *, u_int);
+extern void cisco_autorp_print(netdissect_options *, const u_char *, u_int);
+extern void cnfp_print(netdissect_options *, const u_char *);
+extern void dccp_print(netdissect_options *, const u_char *, const u_char *, u_int);
+extern void decnet_print(netdissect_options *, const u_char *, u_int, u_int);
+extern void dhcp6_print(netdissect_options *, const u_char *, u_int);
+extern int dstopt_print(netdissect_options *, const u_char *);
+extern void dtp_print(netdissect_options *, const u_char *, u_int);
+extern void dvmrp_print(netdissect_options *, const u_char *, u_int);
+extern void eap_print(netdissect_options *, const u_char *, u_int);
+extern void egp_print(netdissect_options *, const u_char *, u_int);
+extern void eigrp_print(netdissect_options *, const u_char *, u_int);
+extern int esp_print(netdissect_options *, const u_char *, const int, const u_char *, int *, int *);
+extern u_int ether_print(netdissect_options *, const u_char *, u_int, u_int, void (*)(netdissect_options *, const u_char *), const u_char *);
+extern int ethertype_print(netdissect_options *, u_short, const u_char *, u_int, u_int, const struct lladdr_info *, const struct lladdr_info *);
+extern u_int fddi_print(netdissect_options *, const u_char *, u_int, u_int);
+extern void forces_print(netdissect_options *, const u_char *, u_int);
+extern u_int fr_print(netdissect_options *, register const u_char *, u_int);
+extern int frag6_print(netdissect_options *, const u_char *, const u_char *);
+extern void ftp_print(netdissect_options *, const u_char *, u_int);
+extern void geneve_print(netdissect_options *, const u_char *, u_int);
+extern void geonet_print(netdissect_options *, const u_char *, u_int, const struct lladdr_info *);
+extern void gre_print(netdissect_options *, const u_char *, u_int);
+extern int hbhopt_print(netdissect_options *, const u_char *);
+extern void hex_and_ascii_print(netdissect_options *, const char *, const u_char *, u_int);
+extern void hex_and_ascii_print_with_offset(netdissect_options *, const char *, const u_char *, u_int, u_int);
+extern void hex_print(netdissect_options *, const char *ident, const u_char *cp, u_int);
+extern void hex_print_with_offset(netdissect_options *, const char *ident, const u_char *cp, u_int, u_int);
+extern void hncp_print(netdissect_options *, const u_char *, u_int);
+extern void hsrp_print(netdissect_options *, const u_char *, u_int);
+extern void http_print(netdissect_options *, const u_char *, u_int);
+extern void icmp6_print(netdissect_options *, const u_char *, u_int, const u_char *, int);
+extern void icmp_print(netdissect_options *, const u_char *, u_int, const u_char *, int);
+extern void igmp_print(netdissect_options *, const u_char *, u_int);
+extern void igrp_print(netdissect_options *, const u_char *, u_int);
+extern void ip6_print(netdissect_options *, const u_char *, u_int);
+extern void ipN_print(netdissect_options *, const u_char *, u_int);
+extern void ip_print(netdissect_options *, const u_char *, u_int);
+extern void ip_print_inner(netdissect_options *, const u_char *, u_int, u_int nh, const u_char *);
+extern void ipcomp_print(netdissect_options *, register const u_char *);
+extern void ipx_netbios_print(netdissect_options *, const u_char *, u_int);
+extern void ipx_print(netdissect_options *, const u_char *, u_int);
+extern void isakmp_print(netdissect_options *, const u_char *, u_int, const u_char *);
+extern void isakmp_rfc3948_print(netdissect_options *, const u_char *, u_int, const u_char *);
+extern void isoclns_print(netdissect_options *, const u_char *, u_int, u_int);
+extern void krb_print(netdissect_options *, const u_char *);
+extern void l2tp_print(netdissect_options *, const u_char *, u_int);
+extern void lane_print(netdissect_options *, const u_char *, u_int, u_int);
+extern void ldp_print(netdissect_options *, const u_char *, u_int);
+extern void lisp_print(netdissect_options *, const u_char *, u_int);
+extern u_int llap_print(netdissect_options *, const u_char *, u_int);
+extern int llc_print(netdissect_options *, const u_char *, u_int, u_int, const struct lladdr_info *, const struct lladdr_info *);
+extern void lldp_print(netdissect_options *, const u_char *, u_int);
+extern void lmp_print(netdissect_options *, const u_char *, u_int);
+extern void loopback_print(netdissect_options *, const u_char *, const u_int);
+extern void lspping_print(netdissect_options *, const u_char *, u_int);
+extern void lwapp_control_print(netdissect_options *, const u_char *, u_int, int);
+extern void lwapp_data_print(netdissect_options *, const u_char *, u_int);
+extern void lwres_print(netdissect_options *, const u_char *, u_int);
+extern void m3ua_print(netdissect_options *, const u_char *, const u_int);
+extern void medsa_print(netdissect_options *, const u_char *, u_int, u_int, const struct lladdr_info *, const struct lladdr_info *);
+extern u_int mfr_print(netdissect_options *, register const u_char *, u_int);
+extern void mobile_print(netdissect_options *, const u_char *, u_int);
+extern int mobility_print(netdissect_options *, const u_char *, const u_char *);
+extern void mpcp_print(netdissect_options *, const u_char *, u_int);
+extern void mpls_print(netdissect_options *, const u_char *, u_int);
+extern int mptcp_print(netdissect_options *, const u_char *, u_int, u_char);
+extern void msdp_print(netdissect_options *, const u_char *, u_int);
+extern void msnlb_print(netdissect_options *, const u_char *);
+extern void nbt_tcp_print(netdissect_options *, const u_char *, int);
+extern void nbt_udp137_print(netdissect_options *, const u_char *, int);
+extern void nbt_udp138_print(netdissect_options *, const u_char *, int);
+extern void netbeui_print(netdissect_options *, u_short, const u_char *, int);
+extern void nfsreply_print(netdissect_options *, const u_char *, u_int, const u_char *);
+extern void nfsreply_print_noaddr(netdissect_options *, const u_char *, u_int, const u_char *);
+extern void nfsreq_print_noaddr(netdissect_options *, const u_char *, u_int, const u_char *);
+extern const u_char * ns_nprint (netdissect_options *, register const u_char *, register const u_char *);
+extern void ns_print(netdissect_options *, const u_char *, u_int, int);
+extern void nsh_print(netdissect_options *ndo, const u_char *bp, u_int len);
+extern void ntp_print(netdissect_options *, const u_char *, u_int);
+extern void oam_print(netdissect_options *, const u_char *, u_int, u_int);
+extern void olsr_print(netdissect_options *, const u_char *, u_int, int);
+extern void openflow_print(netdissect_options *, const u_char *, const u_int);
+extern void ospf6_print(netdissect_options *, const u_char *, u_int);
+extern void ospf_print(netdissect_options *, const u_char *, u_int, const u_char *);
+extern int ospf_print_grace_lsa(netdissect_options *, const uint8_t *, u_int);
+extern int ospf_print_te_lsa(netdissect_options *, const uint8_t *, u_int);
+extern void otv_print(netdissect_options *, const u_char *, u_int);
+extern void pfsync_ip_print(netdissect_options *, const u_char *, u_int);
+extern void pgm_print(netdissect_options *, const u_char *, u_int, const u_char *);
+extern void pim_print(netdissect_options *, const u_char *, u_int, const u_char *);
+extern void pimv1_print(netdissect_options *, const u_char *, u_int);
+extern u_int ppp_print(netdissect_options *, register const u_char *, u_int);
+extern u_int pppoe_print(netdissect_options *, const u_char *, u_int);
+extern void pptp_print(netdissect_options *, const u_char *);
+extern int print_unknown_data(netdissect_options *, const u_char *, const char *, int);
+extern char *q922_string(netdissect_options *, const u_char *, u_int);
+extern void q933_print(netdissect_options *, const u_char *, u_int);
+extern void radius_print(netdissect_options *, const u_char *, u_int);
+extern void resp_print(netdissect_options *, const u_char *, u_int);
+extern void rip_print(netdissect_options *, const u_char *, u_int);
+extern void ripng_print(netdissect_options *, const u_char *, unsigned int);
+extern void rpki_rtr_print(netdissect_options *, const u_char *, u_int);
+extern void rrcp_print(netdissect_options *, const u_char *, u_int, const struct lladdr_info *, const struct lladdr_info *);
+extern void rsvp_print(netdissect_options *, const u_char *, u_int);
+extern int rt6_print(netdissect_options *, const u_char *, const u_char *);
+extern void rtsp_print(netdissect_options *, const u_char *, u_int);
+extern void rx_print(netdissect_options *, register const u_char *, int, int, int, const u_char *);
+extern void sctp_print(netdissect_options *, const u_char *, const u_char *, u_int);
+extern void sflow_print(netdissect_options *, const u_char *, u_int);
+extern void sip_print(netdissect_options *, const u_char *, u_int);
+extern void slow_print(netdissect_options *, const u_char *, u_int);
+extern void smb_print_data(netdissect_options *, const unsigned char *, int);
+extern void smb_tcp_print(netdissect_options *, const u_char *, int);
+extern void smtp_print(netdissect_options *, const u_char *, u_int);
+extern int snap_print(netdissect_options *, const u_char *, u_int, u_int, const struct lladdr_info *, const struct lladdr_info *, u_int);
+extern void snmp_print(netdissect_options *, const u_char *, u_int);
+extern void stp_print(netdissect_options *, const u_char *, u_int);
+extern void sunrpcrequest_print(netdissect_options *, const u_char *, u_int, const u_char *);
+extern void syslog_print(netdissect_options *, const u_char *, u_int);
+extern void tcp_print(netdissect_options *, const u_char *, u_int, const u_char *, int);
+extern void telnet_print(netdissect_options *, const u_char *, u_int);
+extern void tftp_print(netdissect_options *, const u_char *, u_int);
+extern void timed_print(netdissect_options *, const u_char *);
extern void tipc_print(netdissect_options *, const u_char *, u_int, u_int);
-extern void msnlb_print(netdissect_options *, const u_char *, u_int);
-extern void icmp6_print(netdissect_options *ndo, const u_char *,
- u_int, const u_char *, int);
-extern void isakmp_print(netdissect_options *,const u_char *,
- u_int, const u_char *);
-extern void isakmp_rfc3948_print(netdissect_options *,const u_char *,
- u_int, const u_char *);
-extern void ip_print(netdissect_options *,const u_char *, u_int);
-extern void ip_print_inner(netdissect_options *ndo,
- const u_char *bp, u_int length, u_int nh,
- const u_char *bp2);
-extern void rrcp_print(netdissect_options *,const u_char *, u_int);
-
-extern void ether_print(netdissect_options *,
- const u_char *, u_int, u_int,
- void (*)(netdissect_options *, const u_char *),
- const u_char *);
-
-extern u_int ether_if_print(netdissect_options *,
- const struct pcap_pkthdr *,const u_char *);
-extern u_int netanalyzer_if_print(netdissect_options *,
- const struct pcap_pkthdr *,const u_char *);
-extern u_int netanalyzer_transparent_if_print(netdissect_options *,
- const struct pcap_pkthdr *,
- const u_char *);
-
-extern int ethertype_print(netdissect_options *,u_short, const u_char *,
- u_int, u_int);
-
-/* stuff that has not yet been rototiled */
-#if 0
-extern void ascii_print(netdissect_options *,u_int);
-extern void hex_and_ascii_print_with_offset(netdissect_options *,const char *,
- u_int, u_int);
-extern void hex_and_ascii_print(netdissect_options *,const char *, u_int);
-extern void hex_print_with_offset(netdissect_options *,const char *,
- u_int, u_int);
-extern void hex_print(netdissect_options *,const char *, u_int);
-extern void telnet_print(netdissect_options *,const u_char *, u_int);
-extern int llc_print(netdissect_options *,
- const u_char *, u_int, u_int, const u_char *,
- const u_char *, u_short *);
-extern void aarp_print(netdissect_options *,const u_char *, u_int);
-extern void atalk_print(netdissect_options *,const u_char *, u_int);
-extern void atm_if_print(u_char *,const struct pcap_pkthdr *, const u_char *);
-extern void bootp_print(netdissect_options *,const u_char *,
- u_int, u_short, u_short);
-extern void bgp_print(netdissect_options *,const u_char *, int);
-extern void bxxp_print(netdissect_options *,const u_char *, u_int);
-extern void chdlc_if_print(u_char *user, const struct pcap_pkthdr *h,
- register const u_char *p);
-extern void chdlc_print(netdissect_options *ndo,
- register const u_char *p, u_int length, u_int caplen);
-extern void cisco_autorp_print(netdissect_options *,
- const u_char *, u_int);
-extern void cnfp_print(netdissect_options *,const u_char *cp,
- u_int len, const u_char *bp);
-extern void decnet_print(netdissect_options *,const u_char *,
- u_int, u_int);
-extern void default_print(netdissect_options *,const u_char *, u_int);
-extern void dvmrp_print(netdissect_options *,const u_char *, u_int);
-extern void egp_print(netdissect_options *,const u_char *, u_int,
- const u_char *);
-
-extern void arcnet_if_print(u_char*,const struct pcap_pkthdr *,const u_char *);
-extern void token_if_print(u_char *,const struct pcap_pkthdr *,const u_char *);
-extern void fddi_if_print(u_char *,const struct pcap_pkthdr *, const u_char *);
-
-extern void gre_print(netdissect_options *,const u_char *, u_int);
-extern void icmp_print(netdissect_options *,const u_char *, u_int,
- const u_char *);
-extern void hsrp_print(netdissect_options *ndo,
- register const u_char *bp, register u_int len);
-extern void ieee802_11_if_print(u_char *,const struct pcap_pkthdr *, const u_char *);
-extern void igmp_print(netdissect_options *,
- register const u_char *, u_int);
-extern void igrp_print(netdissect_options *,const u_char *, u_int,
- const u_char *);
-extern int nextproto4_cksum(const struct ip *, const u_int8_t *, u_int, u_int);
-extern void ipN_print(netdissect_options *,const u_char *, u_int);
-extern void ipx_print(netdissect_options *,const u_char *, u_int);
-extern void isoclns_print(netdissect_options *,const u_char *,
- u_int, u_int, const u_char *, const u_char *);
-extern void krb_print(netdissect_options *,const u_char *, u_int);
-extern void llap_print(netdissect_options *,const u_char *, u_int);
-extern const char *linkaddr_string(netdissect_options *ndo,
- const u_char *ep, const unsigned int len);
-extern void ltalk_if_print(netdissect_options *ndo,
- u_char *user, const struct pcap_pkthdr *h,
- const u_char *p);
-extern void mpls_print(netdissect_options *ndo,
- const u_char *bp, u_int length);
-extern void msdp_print(netdissect_options *ndo,
- const unsigned char *sp, u_int length);
-extern void nfsreply_print(netdissect_options *,const u_char *,
- u_int, const u_char *);
-extern void nfsreq_print(netdissect_options *,const u_char *,
- u_int, const u_char *);
-extern void ns_print(netdissect_options *,const u_char *, u_int);
-extern void ntp_print(netdissect_options *,const u_char *, u_int);
-extern void null_if_print(u_char *,const struct pcap_pkthdr *, const u_char *);
-extern void ospf_print(netdissect_options *,const u_char *,
- u_int, const u_char *);
-extern void pimv1_print(netdissect_options *,const u_char *, u_int);
-extern void mobile_print(netdissect_options *,const u_char *, u_int);
-extern void pim_print(netdissect_options *,const u_char *, u_int, u_int);
-extern void pppoe_if_print(u_char *,const struct pcap_pkthdr *, const u_char *);
-extern void pppoe_print(netdissect_options *,const u_char *, u_int);
-extern void ppp_print(netdissect_options *,
- register const u_char *, u_int);
-
-extern void ppp_if_print(u_char *,const struct pcap_pkthdr *, const u_char *);
-extern void ppp_hdlc_if_print(u_char *,
- const struct pcap_pkthdr *, const u_char *);
-extern void ppp_bsdos_if_print(u_char *,
- const struct pcap_pkthdr *, const u_char *);
-
-extern int vjc_print(netdissect_options *,register const char *,
- register u_int, u_short);
-
-extern void raw_if_print(u_char *,
- const struct pcap_pkthdr *, const u_char *);
-
-extern void rip_print(netdissect_options *,const u_char *, u_int);
-extern void rpki_rtr_print(netdissect_options *,const u_char *, u_int);
-
-extern void sctp_print(netdissect_options *ndo,
- const u_char *bp, const u_char *bp2,
- u_int sctpPacketLength);
-
-extern void sl_if_print(u_char *,const struct pcap_pkthdr *, const u_char *);
-
-extern void lane_if_print(u_char *,const struct pcap_pkthdr *,const u_char *);
-extern void cip_if_print(u_char *,const struct pcap_pkthdr *,const u_char *);
-extern void sl_bsdos_if_print(u_char *,
- const struct pcap_pkthdr *, const u_char *);
-extern void sll_if_print(u_char *,
- const struct pcap_pkthdr *, const u_char *);
-
-extern void snmp_print(netdissect_options *,const u_char *, u_int);
-extern void sunrpcrequest_print(netdissect_options *,const u_char *,
- u_int, const u_char *);
-extern void tcp_print(netdissect_options *,const u_char *, u_int,
- const u_char *, int);
-extern void tftp_print(netdissect_options *,const u_char *, u_int);
-extern void timed_print(netdissect_options *,const u_char *, u_int);
-extern void udp_print(netdissect_options *,const u_char *, u_int,
- const u_char *, int);
-extern void wb_print(netdissect_options *,const void *, u_int);
-extern int ah_print(netdissect_options *,register const u_char *,
- register const u_char *);
-extern void esp_print_decodesecret(netdissect_options *ndo);
-extern int ipcomp_print(netdissect_options *,register const u_char *,
- register const u_char *, int *);
-extern void rx_print(netdissect_options *,register const u_char *,
- int, int, int, u_char *);
-extern void netbeui_print(netdissect_options *,u_short,
- const u_char *, int);
-extern void ipx_netbios_print(netdissect_options *,const u_char *, u_int);
-extern void nbt_tcp_print(netdissect_options *,const u_char *, int);
-extern void nbt_udp137_print(netdissect_options *,
- const u_char *data, int);
-extern void nbt_udp138_print(netdissect_options *,
- const u_char *data, int);
-extern char *smb_errstr(netdissect_options *,int, int);
-extern const char *nt_errstr(netdissect_options *, u_int32_t);
-extern void print_data(netdissect_options *,const unsigned char *, int);
-extern void l2tp_print(netdissect_options *,const u_char *, u_int);
-extern void lcp_print(netdissect_options *,const u_char *, u_int);
-extern void vrrp_print(netdissect_options *,const u_char *bp,
- u_int len, int ttl);
-extern void carp_print(netdissect_options *,const u_char *bp,
- u_int len, int ttl);
-extern void cdp_print(netdissect_options *,const u_char *,
- u_int, u_int, const u_char *, const u_char *);
-extern void stp_print(netdissect_options *,const u_char *p, u_int length);
-extern void radius_print(netdissect_options *,const u_char *, u_int);
-extern void lwres_print(netdissect_options *,const u_char *, u_int);
-extern void pptp_print(netdissect_options *,const u_char *, u_int);
-#endif
+extern u_int token_print(netdissect_options *, const u_char *, u_int, u_int);
+extern void udld_print(netdissect_options *, const u_char *, u_int);
+extern void udp_print(netdissect_options *, const u_char *, u_int, const u_char *, int);
+extern int vjc_print(netdissect_options *, register const char *, u_short);
+extern void vqp_print(netdissect_options *, register const u_char *, register u_int);
+extern void vrrp_print(netdissect_options *, const u_char *, u_int, const u_char *, int);
+extern void vtp_print(netdissect_options *, const u_char *, u_int);
+extern void vxlan_gpe_print(netdissect_options *ndo, const u_char *bp, u_int len);
+extern void vxlan_print(netdissect_options *, const u_char *, u_int);
+extern void wb_print(netdissect_options *, const void *, u_int);
+extern void zephyr_print(netdissect_options *, const u_char *, int);
+extern void zmtp1_print(netdissect_options *, const u_char *, u_int);
+extern void zmtp1_print_datagram(netdissect_options *, const u_char *, const u_int);
+
+/* checksum routines */
+extern void init_checksum(void);
+extern uint16_t verify_crc10_cksum(uint16_t, const u_char *, int);
+extern uint16_t create_osi_cksum(const uint8_t *, int, int);
-extern u_int ipnet_if_print(netdissect_options *,const struct pcap_pkthdr *, const u_char *);
-extern u_int ppi_if_print(netdissect_options *,const struct pcap_pkthdr *, const u_char *);
-
-extern u_int ieee802_15_4_if_print(netdissect_options *,const struct pcap_pkthdr *, const u_char *);
-
-#ifdef INET6
-extern void ip6_print(netdissect_options *,const u_char *, u_int);
-#if 0
-extern void ip6_opt_print(netdissect_options *,const u_char *, int);
-extern int nextproto6_cksum(const struct ip6_hdr *, const u_int8_t *, u_int, u_int);
-extern int hbhopt_print(netdissect_options *,const u_char *);
-extern int dstopt_print(netdissect_options *,const u_char *);
-extern int frag6_print(netdissect_options *,const u_char *,
- const u_char *);
-extern void icmp6_print(netdissect_options *,const u_char *,
- const u_char *);
-extern void ripng_print(netdissect_options *,const u_char *, int);
-extern int rt6_print(netdissect_options *,const u_char *, const u_char *);
-extern void ospf6_print(netdissect_options *,const u_char *, u_int);
-extern void dhcp6_print(netdissect_options *,const u_char *,
- u_int, u_int16_t, u_int16_t);
-
-extern void zephyr_print(netdissect_options * ndo,
- const u_char *cp, int length);
-#endif /* 0 */
-
-#endif /*INET6*/
-
-#if 0
struct cksum_vec {
- const u_int8_t *ptr;
+ const uint8_t *ptr;
int len;
};
-extern u_int16_t in_cksum(const struct cksum_vec *, int);
-extern u_int16_t in_cksum_shouldbe(u_int16_t, u_int16_t);
-#endif
+extern uint16_t in_cksum(const struct cksum_vec *, int);
+extern uint16_t in_cksum_shouldbe(uint16_t, uint16_t);
-extern void esp_print_decodesecret(netdissect_options *ndo);
-extern int esp_print_decrypt_buffer_by_ikev2(netdissect_options *ndo,
- int initiator,
- u_char spii[8], u_char spir[8],
- u_char *buf, u_char *end);
+extern int nextproto4_cksum(netdissect_options *, const struct ip *, const uint8_t *, u_int, u_int, u_int);
+
+/* in print-ip6.c */
+extern int nextproto6_cksum(netdissect_options *, const struct ip6_hdr *, const uint8_t *, u_int, u_int, u_int);
+
+/* Utilities */
+extern int mask2plen(uint32_t);
+extern int mask62plen(const u_char *);
+extern const char *dnname_string(netdissect_options *, u_short);
+extern const char *dnnum_string(netdissect_options *, u_short);
+
+extern char *smb_errstr(int, int);
+extern const char *nt_errstr(uint32_t);
+
+extern int decode_prefix4(netdissect_options *, const u_char *, u_int, char *, u_int);
+extern int decode_prefix6(netdissect_options *, const u_char *, u_int, char *, u_int);
+
+extern void esp_print_decodesecret(netdissect_options *);
+extern int esp_print_decrypt_buffer_by_ikev2(netdissect_options *, int,
+ u_char spii[8], u_char spir[8],
+ const u_char *, const u_char *);
#endif /* netdissect_h */
diff --git a/freebsd/contrib/tcpdump/nfs.h b/freebsd/contrib/tcpdump/nfs.h
index b35e2cd5..da7bc508 100644
--- a/freebsd/contrib/tcpdump/nfs.h
+++ b/freebsd/contrib/tcpdump/nfs.h
@@ -1,4 +1,3 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/nfs.h,v 1.9 2007-11-18 03:24:38 guy Exp $ (LBL) */
/* NetBSD: nfs.h,v 1.1 1996/05/23 22:49:53 fvdl Exp */
/*
@@ -36,7 +35,6 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD$
* @(#)nfsproto.h 8.2 (Berkeley) 3/30/95
*/
@@ -240,11 +238,11 @@
txdr_unsigned(((t) == VFIFO) ? MAKEIMODE(VCHR, (m)) : \
MAKEIMODE((t), (m)))
#define vtonfsv3_mode(m) txdr_unsigned((m) & 07777)
-#define nfstov_mode(a) (fxdr_unsigned(u_int16_t, (a))&07777)
+#define nfstov_mode(a) (fxdr_unsigned(uint16_t, (a))&07777)
#define vtonfsv2_type(a) txdr_unsigned(nfsv2_type[((int32_t)(a))])
#define vtonfsv3_type(a) txdr_unsigned(nfsv3_type[((int32_t)(a))])
-#define nfsv2tov_type(a) nv2tov_type[fxdr_unsigned(u_int32_t,(a))&0x7]
-#define nfsv3tov_type(a) nv3tov_type[fxdr_unsigned(u_int32_t,(a))&0x7]
+#define nfsv2tov_type(a) nv2tov_type[fxdr_unsigned(uint32_t,(a))&0x7]
+#define nfsv3tov_type(a) nv3tov_type[fxdr_unsigned(uint32_t,(a))&0x7]
/* File types */
typedef enum { NFNON=0, NFREG=1, NFDIR=2, NFBLK=3, NFCHR=4, NFLNK=5,
@@ -268,14 +266,14 @@ union nfsfh {
typedef union nfsfh nfsfh_t;
struct nfsv2_time {
- u_int32_t nfsv2_sec;
- u_int32_t nfsv2_usec;
+ uint32_t nfsv2_sec;
+ uint32_t nfsv2_usec;
};
typedef struct nfsv2_time nfstime2;
struct nfsv3_time {
- u_int32_t nfsv3_sec;
- u_int32_t nfsv3_nsec;
+ uint32_t nfsv3_sec;
+ uint32_t nfsv3_nsec;
};
typedef struct nfsv3_time nfstime3;
@@ -284,7 +282,7 @@ typedef struct nfsv3_time nfstime3;
* protocol and to facilitate xdr conversion.
*/
struct nfs_uquad {
- u_int32_t nfsuquad[2];
+ uint32_t nfsuquad[2];
};
typedef struct nfs_uquad nfsuint64;
@@ -292,8 +290,8 @@ typedef struct nfs_uquad nfsuint64;
* NFS Version 3 special file number.
*/
struct nfsv3_spec {
- u_int32_t specdata1;
- u_int32_t specdata2;
+ uint32_t specdata1;
+ uint32_t specdata2;
};
typedef struct nfsv3_spec nfsv3spec;
@@ -307,19 +305,19 @@ typedef struct nfsv3_spec nfsv3spec;
* NFSX_FATTR(v3) macro.
*/
struct nfs_fattr {
- u_int32_t fa_type;
- u_int32_t fa_mode;
- u_int32_t fa_nlink;
- u_int32_t fa_uid;
- u_int32_t fa_gid;
+ uint32_t fa_type;
+ uint32_t fa_mode;
+ uint32_t fa_nlink;
+ uint32_t fa_uid;
+ uint32_t fa_gid;
union {
struct {
- u_int32_t nfsv2fa_size;
- u_int32_t nfsv2fa_blocksize;
- u_int32_t nfsv2fa_rdev;
- u_int32_t nfsv2fa_blocks;
- u_int32_t nfsv2fa_fsid;
- u_int32_t nfsv2fa_fileid;
+ uint32_t nfsv2fa_size;
+ uint32_t nfsv2fa_blocksize;
+ uint32_t nfsv2fa_rdev;
+ uint32_t nfsv2fa_blocks;
+ uint32_t nfsv2fa_fsid;
+ uint32_t nfsv2fa_fileid;
nfstime2 nfsv2fa_atime;
nfstime2 nfsv2fa_mtime;
nfstime2 nfsv2fa_ctime;
@@ -357,10 +355,10 @@ struct nfs_fattr {
#define fa3_ctime fa_un.fa_nfsv3.nfsv3fa_ctime
struct nfsv2_sattr {
- u_int32_t sa_mode;
- u_int32_t sa_uid;
- u_int32_t sa_gid;
- u_int32_t sa_size;
+ uint32_t sa_mode;
+ uint32_t sa_uid;
+ uint32_t sa_gid;
+ uint32_t sa_size;
nfstime2 sa_atime;
nfstime2 sa_mtime;
};
@@ -369,28 +367,28 @@ struct nfsv2_sattr {
* NFS Version 3 sattr structure for the new node creation case.
*/
struct nfsv3_sattr {
- u_int32_t sa_modeset;
- u_int32_t sa_mode;
- u_int32_t sa_uidset;
- u_int32_t sa_uid;
- u_int32_t sa_gidset;
- u_int32_t sa_gid;
- u_int32_t sa_sizeset;
- u_int32_t sa_size;
- u_int32_t sa_atimetype;
+ uint32_t sa_modeset;
+ uint32_t sa_mode;
+ uint32_t sa_uidset;
+ uint32_t sa_uid;
+ uint32_t sa_gidset;
+ uint32_t sa_gid;
+ uint32_t sa_sizeset;
+ uint32_t sa_size;
+ uint32_t sa_atimetype;
nfstime3 sa_atime;
- u_int32_t sa_mtimetype;
+ uint32_t sa_mtimetype;
nfstime3 sa_mtime;
};
struct nfs_statfs {
union {
struct {
- u_int32_t nfsv2sf_tsize;
- u_int32_t nfsv2sf_bsize;
- u_int32_t nfsv2sf_blocks;
- u_int32_t nfsv2sf_bfree;
- u_int32_t nfsv2sf_bavail;
+ uint32_t nfsv2sf_tsize;
+ uint32_t nfsv2sf_bsize;
+ uint32_t nfsv2sf_blocks;
+ uint32_t nfsv2sf_bfree;
+ uint32_t nfsv2sf_bavail;
} sf_nfsv2;
struct {
nfsuint64 nfsv3sf_tbytes;
@@ -399,7 +397,7 @@ struct nfs_statfs {
nfsuint64 nfsv3sf_tfiles;
nfsuint64 nfsv3sf_ffiles;
nfsuint64 nfsv3sf_afiles;
- u_int32_t nfsv3sf_invarsec;
+ uint32_t nfsv3sf_invarsec;
} sf_nfsv3;
} sf_un;
};
@@ -418,23 +416,23 @@ struct nfs_statfs {
#define sf_invarsec sf_un.sf_nfsv3.nfsv3sf_invarsec
struct nfsv3_fsinfo {
- u_int32_t fs_rtmax;
- u_int32_t fs_rtpref;
- u_int32_t fs_rtmult;
- u_int32_t fs_wtmax;
- u_int32_t fs_wtpref;
- u_int32_t fs_wtmult;
- u_int32_t fs_dtpref;
+ uint32_t fs_rtmax;
+ uint32_t fs_rtpref;
+ uint32_t fs_rtmult;
+ uint32_t fs_wtmax;
+ uint32_t fs_wtpref;
+ uint32_t fs_wtmult;
+ uint32_t fs_dtpref;
nfsuint64 fs_maxfilesize;
nfstime3 fs_timedelta;
- u_int32_t fs_properties;
+ uint32_t fs_properties;
};
struct nfsv3_pathconf {
- u_int32_t pc_linkmax;
- u_int32_t pc_namemax;
- u_int32_t pc_notrunc;
- u_int32_t pc_chownrestricted;
- u_int32_t pc_caseinsensitive;
- u_int32_t pc_casepreserving;
+ uint32_t pc_linkmax;
+ uint32_t pc_namemax;
+ uint32_t pc_notrunc;
+ uint32_t pc_chownrestricted;
+ uint32_t pc_caseinsensitive;
+ uint32_t pc_casepreserving;
};
diff --git a/freebsd/contrib/tcpdump/nfsfh.h b/freebsd/contrib/tcpdump/nfsfh.h
index 82367132..5cf8fc44 100644
--- a/freebsd/contrib/tcpdump/nfsfh.h
+++ b/freebsd/contrib/tcpdump/nfsfh.h
@@ -1,5 +1,3 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/nfsfh.h,v 1.13 2002-04-24 06:27:05 guy Exp $ (LBL) */
-
/*
* Copyright (c) 1993, 1994 Jeffrey C. Mogul, Digital Equipment Corporation,
* Western Research Laboratory. All rights reserved.
@@ -39,8 +37,6 @@
* Jeffrey C. Mogul
* Digital Equipment Corporation
* Western Research Laboratory
- * $FreeBSD$
- * $NetBSD: nfsfh.h,v 1.1.1.2 1997/10/03 17:25:13 christos Exp $
*/
/*
@@ -48,8 +44,8 @@
* that we might be spying upon use different external representations.
*/
typedef struct {
- u_int32_t Minor; /* upper case to avoid clashing with macro names */
- u_int32_t Major;
+ uint32_t Minor; /* upper case to avoid clashing with macro names */
+ uint32_t Major;
} my_devt;
#define dev_eq(a,b) ((a.Minor == b.Minor) && (a.Major == b.Major))
@@ -61,10 +57,10 @@ typedef struct {
typedef struct {
my_devt Fsid_dev; /* XXX avoid name conflict with AIX */
char Opaque_Handle[2 * 32 + 1];
- u_int32_t fsid_code;
+ uint32_t fsid_code;
} my_fsid;
#define fsid_eq(a,b) ((a.fsid_code == b.fsid_code) &&\
dev_eq(a.Fsid_dev, b.Fsid_dev))
-extern void Parse_fh(const unsigned char *, int, my_fsid *, ino_t *, const char **, const char **, int);
+extern void Parse_fh(const unsigned char *, u_int, my_fsid *, uint32_t *, const char **, const char **, int);
diff --git a/freebsd/contrib/tcpdump/nlpid.c b/freebsd/contrib/tcpdump/nlpid.c
index 83bfedf0..bd443eb4 100644
--- a/freebsd/contrib/tcpdump/nlpid.c
+++ b/freebsd/contrib/tcpdump/nlpid.c
@@ -1,6 +1,9 @@
#include <machine/rtems-bsd-user-space.h>
-
-/*
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
+/*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code
* distributions retain the above copyright notice and this paragraph
@@ -15,17 +18,12 @@
* Original code by Hannes Gredler (hannes@juniper.net)
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/nlpid.c,v 1.4 2004-10-19 15:27:55 hannes Exp $ (LBL)";
-#endif
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
-#include "interface.h"
+#include <netdissect-stdinc.h>
+#include "netdissect.h"
#include "nlpid.h"
const struct tok nlpid_values[] = {
@@ -46,3 +44,6 @@ const struct tok nlpid_values[] = {
{ NLPID_IP6, "IPv6" },
{ 0, NULL }
};
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-nlpid-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/nlpid.h b/freebsd/contrib/tcpdump/nlpid.h
index 1546fc6e..63a2e709 100644
--- a/freebsd/contrib/tcpdump/nlpid.h
+++ b/freebsd/contrib/tcpdump/nlpid.h
@@ -1,5 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/nlpid.h,v 1.4 2004-10-19 15:27:55 hannes Exp $ (LBL) */
-/*
+/*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code
* distributions retain the above copyright notice and this paragraph
diff --git a/freebsd/contrib/tcpdump/ntp.h b/freebsd/contrib/tcpdump/ntp.h
deleted file mode 100644
index 0614f73b..00000000
--- a/freebsd/contrib/tcpdump/ntp.h
+++ /dev/null
@@ -1,127 +0,0 @@
-/* $Header: /tcpdump/master/tcpdump/ntp.h,v 1.8 2004-01-28 14:34:50 hannes Exp $ */
-
-/*
- * Based on ntp.h from the U of MD implementation
- * This file is based on Version 2 of the NTP spec (RFC1119).
- */
-
-/*
- * Definitions for the masses
- */
-#define JAN_1970 2208988800U /* 1970 - 1900 in seconds */
-
-/*
- * Structure definitions for NTP fixed point values
- *
- * 0 1 2 3
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Integer Part |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Fraction Part |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- *
- * 0 1 2 3
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Integer Part | Fraction Part |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-*/
-struct l_fixedpt {
- u_int32_t int_part;
- u_int32_t fraction;
-};
-
-struct s_fixedpt {
- u_int16_t int_part;
- u_int16_t fraction;
-};
-
-/* rfc2030
- * 1 2 3
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * |LI | VN |Mode | Stratum | Poll | Precision |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Root Delay |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Root Dispersion |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Reference Identifier |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | |
- * | Reference Timestamp (64) |
- * | |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | |
- * | Originate Timestamp (64) |
- * | |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | |
- * | Receive Timestamp (64) |
- * | |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | |
- * | Transmit Timestamp (64) |
- * | |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Key Identifier (optional) (32) |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | |
- * | |
- * | Message Digest (optional) (128) |
- * | |
- * | |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-
-struct ntpdata {
- u_char status; /* status of local clock and leap info */
- u_char stratum; /* Stratum level */
- u_char ppoll; /* poll value */
- int precision:8;
- struct s_fixedpt root_delay;
- struct s_fixedpt root_dispersion;
- u_int32_t refid;
- struct l_fixedpt ref_timestamp;
- struct l_fixedpt org_timestamp;
- struct l_fixedpt rec_timestamp;
- struct l_fixedpt xmt_timestamp;
- u_int32_t key_id;
- u_int8_t message_digest[16];
-};
-/*
- * Leap Second Codes (high order two bits)
- */
-#define NO_WARNING 0x00 /* no warning */
-#define PLUS_SEC 0x40 /* add a second (61 seconds) */
-#define MINUS_SEC 0x80 /* minus a second (59 seconds) */
-#define ALARM 0xc0 /* alarm condition (clock unsynchronized) */
-
-/*
- * Clock Status Bits that Encode Version
- */
-#define NTPVERSION_1 0x08
-#define VERSIONMASK 0x38
-#define LEAPMASK 0xc0
-#define MODEMASK 0x07
-
-/*
- * Code values
- */
-#define MODE_UNSPEC 0 /* unspecified */
-#define MODE_SYM_ACT 1 /* symmetric active */
-#define MODE_SYM_PAS 2 /* symmetric passive */
-#define MODE_CLIENT 3 /* client */
-#define MODE_SERVER 4 /* server */
-#define MODE_BROADCAST 5 /* broadcast */
-#define MODE_RES1 6 /* reserved */
-#define MODE_RES2 7 /* reserved */
-
-/*
- * Stratum Definitions
- */
-#define UNSPECIFIED 0
-#define PRIM_REF 1 /* radio clock */
-#define INFO_QUERY 62 /* **** THIS implementation dependent **** */
-#define INFO_REPLY 63 /* **** THIS implementation dependent **** */
diff --git a/freebsd/contrib/tcpdump/oakley.h b/freebsd/contrib/tcpdump/oakley.h
deleted file mode 100644
index ad328171..00000000
--- a/freebsd/contrib/tcpdump/oakley.h
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
- * All rights reserved.
- *
- * 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.
- */
-/* YIPS @(#)$Id: oakley.h,v 1.4 2002-12-11 07:13:56 guy Exp $ */
-
-/* refer to RFC 2409 */
-
-#if !defined(_ISAKMP_OAKLEY_H_)
-#define _ISAKMP_OAKLEY_H_
-
-/* Attribute Classes */
-#define OAKLEY_ATTR_ENC_ALG 1 /* B */
-#define OAKLEY_ATTR_ENC_ALG_DES 1
-#define OAKLEY_ATTR_ENC_ALG_IDEA 2
-#define OAKLEY_ATTR_ENC_ALG_BL 3
-#define OAKLEY_ATTR_ENC_ALG_RC5 4
-#define OAKLEY_ATTR_ENC_ALG_3DES 5
-#define OAKLEY_ATTR_ENC_ALG_CAST 6
-#define OAKLEY_ATTR_HASH_ALG 2 /* B */
-#define OAKLEY_ATTR_HASH_ALG_MD5 1
-#define OAKLEY_ATTR_HASH_ALG_SHA 2
-#define OAKLEY_ATTR_HASH_ALG_TIGER 3
-#define OAKLEY_ATTR_AUTH_METHOD 3 /* B */
-#define OAKLEY_ATTR_AUTH_METHOD_PSKEY 1
-#define OAKLEY_ATTR_AUTH_METHOD_DSS 2
-#define OAKLEY_ATTR_AUTH_METHOD_RSA 3
-#define OAKLEY_ATTR_AUTH_METHOD_RSAENC 4
-#define OAKLEY_ATTR_AUTH_METHOD_RSAREV 5
-#define OAKLEY_ATTR_GRP_DESC 4 /* B */
-#define OAKLEY_ATTR_GRP_DESC_MODP768 1
-#define OAKLEY_ATTR_GRP_DESC_MODP1024 2
-#define OAKLEY_ATTR_GRP_DESC_EC2N155 3
-#define OAKLEY_ATTR_GRP_DESC_EC2N185 4
-#define OAKLEY_ATTR_GRP_TYPE 5 /* B */
-#define OAKLEY_ATTR_GRP_TYPE_MODP 1
-#define OAKLEY_ATTR_GRP_TYPE_ECP 2
-#define OAKLEY_ATTR_GRP_TYPE_EC2N 3
-#define OAKLEY_ATTR_GRP_PI 6 /* V */
-#define OAKLEY_ATTR_GRP_GEN_ONE 7 /* V */
-#define OAKLEY_ATTR_GRP_GEN_TWO 8 /* V */
-#define OAKLEY_ATTR_GRP_CURVE_A 9 /* V */
-#define OAKLEY_ATTR_GRP_CURVE_B 10 /* V */
-#define OAKLEY_ATTR_SA_LTYPE 11 /* B */
-#define OAKLEY_ATTR_SA_LTYPE_DEFAULT 1
-#define OAKLEY_ATTR_SA_LTYPE_SEC 1
-#define OAKLEY_ATTR_SA_LTYPE_KB 2
-#define OAKLEY_ATTR_SA_LDUR 12 /* V */
-#define OAKLEY_ATTR_SA_LDUR_DEFAULT 28800 /* 8 hours */
-#define OAKLEY_ATTR_PRF 13 /* B */
-#define OAKLEY_ATTR_KEY_LEN 14 /* B */
-#define OAKLEY_ATTR_FIELD_SIZE 15 /* B */
-#define OAKLEY_ATTR_GRP_ORDER 16 /* V */
-
-#define OAKLEY_ID_IPV4_ADDR 0
-#define OAKLEY_ID_IPV4_ADDR_SUBNET 1
-#define OAKLEY_ID_IPV6_ADDR 2
-#define OAKLEY_ID_IPV6_ADDR_SUBNET 3
-
-/* Additional Exchange Type */
-#define ISAKMP_ETYPE_QUICK 32
-#define ISAKMP_ETYPE_NEWGRP 33
-
-/* The use for checking proposal payload. This is not exchange type. */
-#define OAKLEY_MAIN_MODE 0
-#define OAKLEY_QUICK_MODE 1
-
-#define OAKLEY_PRIME_MODP768 "\
- FFFFFFFF FFFFFFFF C90FDAA2 2168C234 C4C6628B 80DC1CD1 \
- 29024E08 8A67CC74 020BBEA6 3B139B22 514A0879 8E3404DD \
- EF9519B3 CD3A431B 302B0A6D F25F1437 4FE1356D 6D51C245 \
- E485B576 625E7EC6 F44C42E9 A63A3620 FFFFFFFF FFFFFFFF"
-
-#define OAKLEY_PRIME_MODP1024 "\
- FFFFFFFF FFFFFFFF C90FDAA2 2168C234 C4C6628B 80DC1CD1 \
- 29024E08 8A67CC74 020BBEA6 3B139B22 514A0879 8E3404DD \
- EF9519B3 CD3A431B 302B0A6D F25F1437 4FE1356D 6D51C245 \
- E485B576 625E7EC6 F44C42E9 A637ED6B 0BFF5CB6 F406B7ED \
- EE386BFB 5A899FA5 AE9F2411 7C4B1FE6 49286651 ECE65381 \
- FFFFFFFF FFFFFFFF"
-
-#define DEFAULTSECRETSIZE ( 128 / 8 ) /* 128 bits */
-#define DEFAULTNONCESIZE ( 128 / 8 ) /* 128 bits */
-
-#define MAXPADLWORD 20
-
-#if 0
-/* isakmp sa structure */
-struct oakley_sa {
- u_int8_t proto_id; /* OAKLEY */
- vchar_t *spi; /* spi */
- u_int8_t dhgrp; /* DH; group */
- u_int8_t auth_t; /* method of authentication */
- u_int8_t prf_t; /* type of prf */
- u_int8_t hash_t; /* type of hash */
- u_int8_t enc_t; /* type of cipher */
- u_int8_t life_t; /* type of duration of lifetime */
- u_int32_t ldur; /* life duration */
-};
-#endif
-
-#endif /* !defined(_ISAKMP_OAKLEY_H_) */
diff --git a/freebsd/contrib/tcpdump/openflow.h b/freebsd/contrib/tcpdump/openflow.h
new file mode 100644
index 00000000..31ef03c4
--- /dev/null
+++ b/freebsd/contrib/tcpdump/openflow.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2013 The TCPDUMP project
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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
+ * COPYRIGHT HOLDER 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.
+ */
+
+/* OpenFlow: protocol between controller and datapath. */
+
+/* for netdissect_options */
+#include "netdissect.h"
+
+#define OF_HEADER_LEN 8
+
+#define ONF_EXP_ONF 0x4f4e4600
+#define ONF_EXP_BUTE 0xff000001
+#define ONF_EXP_NOVIFLOW 0xff000002
+#define ONF_EXP_L3 0xff000003
+#define ONF_EXP_L4L7 0xff000004
+#define ONF_EXP_WMOB 0xff000005
+#define ONF_EXP_FABS 0xff000006
+#define ONF_EXP_OTRANS 0xff000007
+extern const struct tok onf_exp_str[];
+
+/*
+ * Routines to print packets for various versions of OpenFlow.
+ */
+extern const u_char *of10_header_body_print(netdissect_options *ndo,
+ const u_char *, const u_char *,
+ const uint8_t, const uint16_t, const uint32_t);
+extern const char * of_vendor_name(const uint32_t);
diff --git a/freebsd/contrib/tcpdump/ospf.h b/freebsd/contrib/tcpdump/ospf.h
index b86458ba..b47aaf69 100644
--- a/freebsd/contrib/tcpdump/ospf.h
+++ b/freebsd/contrib/tcpdump/ospf.h
@@ -1,4 +1,3 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/ospf.h,v 1.23 2007-10-08 07:53:21 hannes Exp $ (LBL) */
/*
* Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
@@ -35,7 +34,7 @@
* +------------------------------------+
*
*/
-
+
#define OSPF_OPTION_T 0x01 /* T bit: TOS support */
#define OSPF_OPTION_E 0x02 /* E bit: External routes advertised */
#define OSPF_OPTION_MC 0x04 /* MC bit: Multicast capable */
@@ -137,6 +136,8 @@
#define MCLA_VERTEX_NETWORK 2
/* Link-Local-Signaling */
+#define OSPF_LLS_HDRLEN 4U /* RFC5613 Section 2.2 */
+
#define OSPF_LLS_EO 1 /* RFC4811, RFC4812 */
#define OSPF_LLS_MD5 2 /* RFC4813 */
@@ -147,14 +148,14 @@
* TOS metric struct (will be 0 or more in router links update)
*/
struct tos_metric {
- u_int8_t tos_type;
- u_int8_t reserved;
- u_int8_t tos_metric[2];
+ uint8_t tos_type;
+ uint8_t reserved;
+ uint8_t tos_metric[2];
};
struct tos_link {
- u_int8_t link_type;
- u_int8_t link_tos_count;
- u_int8_t tos_metric[2];
+ uint8_t link_type;
+ uint8_t link_tos_count;
+ uint8_t tos_metric[2];
};
union un_tos {
struct tos_link link;
@@ -163,20 +164,20 @@ union un_tos {
/* link state advertisement header */
struct lsa_hdr {
- u_int16_t ls_age;
- u_int8_t ls_options;
- u_int8_t ls_type;
+ uint16_t ls_age;
+ uint8_t ls_options;
+ uint8_t ls_type;
union {
struct in_addr lsa_id;
struct { /* opaque LSAs change the LSA-ID field */
- u_int8_t opaque_type;
- u_int8_t opaque_id[3];
+ uint8_t opaque_type;
+ uint8_t opaque_id[3];
} opaque_field;
} un_lsa_id;
struct in_addr ls_router;
- u_int32_t ls_seq;
- u_int16_t ls_chksum;
- u_int16_t ls_length;
+ uint32_t ls_seq;
+ uint16_t ls_chksum;
+ uint16_t ls_length;
};
/* link state advertisement */
@@ -187,9 +188,9 @@ struct lsa {
union {
/* Router links advertisements */
struct {
- u_int8_t rla_flags;
- u_int8_t rla_zero[1];
- u_int16_t rla_count;
+ uint8_t rla_flags;
+ uint8_t rla_zero[1];
+ uint16_t rla_count;
struct rlalink {
struct in_addr link_id;
struct in_addr link_data;
@@ -206,14 +207,14 @@ struct lsa {
/* Summary links advertisements */
struct {
struct in_addr sla_mask;
- u_int32_t sla_tosmetric[1]; /* may repeat */
+ uint32_t sla_tosmetric[1]; /* may repeat */
} un_sla;
/* AS external links advertisements */
struct {
struct in_addr asla_mask;
struct aslametric {
- u_int32_t asla_tosmetric;
+ uint32_t asla_tosmetric;
struct in_addr asla_forward;
struct in_addr asla_tag;
} asla_metric[1]; /* may repeat */
@@ -221,34 +222,34 @@ struct lsa {
/* Multicast group membership */
struct mcla {
- u_int32_t mcla_vtype;
+ uint32_t mcla_vtype;
struct in_addr mcla_vid;
} un_mcla[1];
/* Opaque TE LSA */
struct {
- u_int16_t type;
- u_int16_t length;
- u_int8_t data[1]; /* may repeat */
+ uint16_t type;
+ uint16_t length;
+ uint8_t data[1]; /* may repeat */
} un_te_lsa_tlv;
/* Opaque Grace LSA */
struct {
- u_int16_t type;
- u_int16_t length;
- u_int8_t data[1]; /* may repeat */
+ uint16_t type;
+ uint16_t length;
+ uint8_t data[1]; /* may repeat */
} un_grace_tlv;
/* Opaque Router information LSA */
struct {
- u_int16_t type;
- u_int16_t length;
- u_int8_t data[1]; /* may repeat */
+ uint16_t type;
+ uint16_t length;
+ uint8_t data[1]; /* may repeat */
} un_ri_tlv;
/* Unknown LSA */
struct unknown {
- u_int8_t data[1]; /* may repeat */
+ uint8_t data[1]; /* may repeat */
} un_unknown[1];
} lsa_un;
@@ -260,23 +261,23 @@ struct lsa {
* the main header
*/
struct ospfhdr {
- u_int8_t ospf_version;
- u_int8_t ospf_type;
- u_int16_t ospf_len;
+ uint8_t ospf_version;
+ uint8_t ospf_type;
+ uint16_t ospf_len;
struct in_addr ospf_routerid;
struct in_addr ospf_areaid;
- u_int16_t ospf_chksum;
- u_int16_t ospf_authtype;
- u_int8_t ospf_authdata[OSPF_AUTH_SIZE];
+ uint16_t ospf_chksum;
+ uint16_t ospf_authtype;
+ uint8_t ospf_authdata[OSPF_AUTH_SIZE];
union {
/* Hello packet */
struct {
struct in_addr hello_mask;
- u_int16_t hello_helloint;
- u_int8_t hello_options;
- u_int8_t hello_priority;
- u_int32_t hello_deadint;
+ uint16_t hello_helloint;
+ uint8_t hello_options;
+ uint8_t hello_priority;
+ uint32_t hello_deadint;
struct in_addr hello_dr;
struct in_addr hello_bdr;
struct in_addr hello_neighbor[1]; /* may repeat */
@@ -284,21 +285,21 @@ struct ospfhdr {
/* Database Description packet */
struct {
- u_int16_t db_ifmtu;
- u_int8_t db_options;
- u_int8_t db_flags;
- u_int32_t db_seq;
+ uint16_t db_ifmtu;
+ uint8_t db_options;
+ uint8_t db_flags;
+ uint32_t db_seq;
struct lsa_hdr db_lshdr[1]; /* may repeat */
} un_db;
/* Link State Request */
struct lsr {
- u_int8_t ls_type[4];
+ uint8_t ls_type[4];
union {
struct in_addr ls_stateid;
struct { /* opaque LSAs change the LSA-ID field */
- u_int8_t opaque_type;
- u_int8_t opaque_id[3];
+ uint8_t opaque_type;
+ uint8_t opaque_id[3];
} opaque_field;
} un_ls_stateid;
struct in_addr ls_router;
@@ -306,7 +307,7 @@ struct ospfhdr {
/* Link State Update */
struct {
- u_int32_t lsu_count;
+ uint32_t lsu_count;
struct lsa lsu_lsa[1]; /* may repeat */
} un_lsu;
@@ -322,7 +323,3 @@ struct ospfhdr {
#define ospf_lsr ospf_un.un_lsr
#define ospf_lsu ospf_un.un_lsu
#define ospf_lsa ospf_un.un_lsa
-
-/* Functions shared by ospf and ospf6 */
-extern int ospf_print_te_lsa(const u_int8_t *, u_int);
-extern int ospf_print_grace_lsa(const u_int8_t *, u_int);
diff --git a/freebsd/contrib/tcpdump/ospf6.h b/freebsd/contrib/tcpdump/ospf6.h
deleted file mode 100644
index e2eabee1..00000000
--- a/freebsd/contrib/tcpdump/ospf6.h
+++ /dev/null
@@ -1,265 +0,0 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/ospf6.h,v 1.7 2006-09-05 15:50:26 hannes Exp $ (LBL) */
-/*
- * Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that: (1) source code distributions
- * retain the above copyright notice and this paragraph in its entirety, (2)
- * distributions including binary code include the above copyright notice and
- * this paragraph in its entirety in the documentation or other materials
- * provided with the distribution, and (3) all advertising materials mentioning
- * features or use of this software display the following acknowledgement:
- * ``This product includes software developed by the University of California,
- * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
- * the University 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 ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * OSPF support contributed by Jeffrey Honig (jch@mitchell.cit.cornell.edu)
- */
-#define OSPF_TYPE_HELLO 1 /* Hello */
-#define OSPF_TYPE_DD 2 /* Database Description */
-#define OSPF_TYPE_LS_REQ 3 /* Link State Request */
-#define OSPF_TYPE_LS_UPDATE 4 /* Link State Update */
-#define OSPF_TYPE_LS_ACK 5 /* Link State Ack */
-
-/* Options *_options */
-#define OSPF6_OPTION_V6 0x01 /* V6 bit: A bit for peeping tom */
-#define OSPF6_OPTION_E 0x02 /* E bit: External routes advertised */
-#define OSPF6_OPTION_MC 0x04 /* MC bit: Multicast capable */
-#define OSPF6_OPTION_N 0x08 /* N bit: For type-7 LSA */
-#define OSPF6_OPTION_R 0x10 /* R bit: Router bit */
-#define OSPF6_OPTION_DC 0x20 /* DC bit: Demand circuits */
-
-
-/* db_flags */
-#define OSPF6_DB_INIT 0x04 /* */
-#define OSPF6_DB_MORE 0x02
-#define OSPF6_DB_MASTER 0x01
-
-/* ls_type */
-#define LS_TYPE_ROUTER 1 /* router link */
-#define LS_TYPE_NETWORK 2 /* network link */
-#define LS_TYPE_INTER_AP 3 /* Inter-Area-Prefix */
-#define LS_TYPE_INTER_AR 4 /* Inter-Area-Router */
-#define LS_TYPE_ASE 5 /* ASE */
-#define LS_TYPE_GROUP 6 /* Group membership */
-#define LS_TYPE_NSSA 7 /* NSSA */
-#define LS_TYPE_LINK 8 /* Link LSA */
-#define LS_TYPE_INTRA_AP 9 /* Intra-Area-Prefix */
-#define LS_TYPE_INTRA_ATE 10 /* Intra-Area-TE */
-#define LS_TYPE_GRACE 11 /* Grace LSA */
-#define LS_TYPE_MASK 0x1fff
-
-#define LS_SCOPE_LINKLOCAL 0x0000
-#define LS_SCOPE_AREA 0x2000
-#define LS_SCOPE_AS 0x4000
-#define LS_SCOPE_MASK 0x6000
-#define LS_SCOPE_U 0x8000
-
-/* rla_link.link_type */
-#define RLA_TYPE_ROUTER 1 /* point-to-point to another router */
-#define RLA_TYPE_TRANSIT 2 /* connection to transit network */
-#define RLA_TYPE_VIRTUAL 4 /* virtual link */
-
-/* rla_flags */
-#define RLA_FLAG_B 0x01
-#define RLA_FLAG_E 0x02
-#define RLA_FLAG_V 0x04
-#define RLA_FLAG_W 0x08
-#define RLA_FLAG_N 0x10
-
-/* lsa_prefix options */
-#define LSA_PREFIX_OPT_NU 0x01
-#define LSA_PREFIX_OPT_LA 0x02
-#define LSA_PREFIX_OPT_MC 0x04
-#define LSA_PREFIX_OPT_P 0x08
-#define LSA_PREFIX_OPT_DN 0x10
-
-/* sla_tosmetric breakdown */
-#define SLA_MASK_TOS 0x7f000000
-#define SLA_MASK_METRIC 0x00ffffff
-#define SLA_SHIFT_TOS 24
-
-/* asla_metric */
-#define ASLA_FLAG_FWDADDR 0x02000000
-#define ASLA_FLAG_ROUTETAG 0x01000000
-#define ASLA_MASK_METRIC 0x00ffffff
-
-typedef u_int32_t rtrid_t;
-
-/* link state advertisement header */
-struct lsa6_hdr {
- u_int16_t ls_age;
- u_int16_t ls_type;
- rtrid_t ls_stateid;
- rtrid_t ls_router;
- u_int32_t ls_seq;
- u_int16_t ls_chksum;
- u_int16_t ls_length;
-};
-
-struct lsa6_prefix {
- u_int8_t lsa_p_len;
- u_int8_t lsa_p_opt;
- u_int16_t lsa_p_metric;
- u_int8_t lsa_p_prefix[4];
-};
-
-/* link state advertisement */
-struct lsa6 {
- struct lsa6_hdr ls_hdr;
-
- /* Link state types */
- union {
- /* Router links advertisements */
- struct {
- union {
- u_int8_t flg;
- u_int32_t opt;
- } rla_flgandopt;
-#define rla_flags rla_flgandopt.flg
-#define rla_options rla_flgandopt.opt
- struct rlalink6 {
- u_int8_t link_type;
- u_int8_t link_zero[1];
- u_int16_t link_metric;
- u_int32_t link_ifid;
- u_int32_t link_nifid;
- rtrid_t link_nrtid;
- } rla_link[1]; /* may repeat */
- } un_rla;
-
- /* Network links advertisements */
- struct {
- u_int32_t nla_options;
- rtrid_t nla_router[1]; /* may repeat */
- } un_nla;
-
- /* Inter Area Prefix LSA */
- struct {
- u_int32_t inter_ap_metric;
- struct lsa6_prefix inter_ap_prefix[1];
- } un_inter_ap;
-
- /* AS external links advertisements */
- struct {
- u_int32_t asla_metric;
- struct lsa6_prefix asla_prefix[1];
- /* some optional fields follow */
- } un_asla;
-
-#if 0
- /* Summary links advertisements */
- struct {
- struct in_addr sla_mask;
- u_int32_t sla_tosmetric[1]; /* may repeat */
- } un_sla;
-
- /* Multicast group membership */
- struct mcla {
- u_int32_t mcla_vtype;
- struct in_addr mcla_vid;
- } un_mcla[1];
-#endif
-
- /* Type 7 LSA */
-
- /* Link LSA */
- struct llsa {
- union {
- u_int8_t pri;
- u_int32_t opt;
- } llsa_priandopt;
-#define llsa_priority llsa_priandopt.pri
-#define llsa_options llsa_priandopt.opt
- struct in6_addr llsa_lladdr;
- u_int32_t llsa_nprefix;
- struct lsa6_prefix llsa_prefix[1];
- } un_llsa;
-
- /* Intra-Area-Prefix */
- struct {
- u_int16_t intra_ap_nprefix;
- u_int16_t intra_ap_lstype;
- rtrid_t intra_ap_lsid;
- rtrid_t intra_ap_rtid;
- struct lsa6_prefix intra_ap_prefix[1];
- } un_intra_ap;
- } lsa_un;
-};
-
-
-#define OSPF_AUTH_SIZE 8
-
-/*
- * the main header
- */
-struct ospf6hdr {
- u_int8_t ospf6_version;
- u_int8_t ospf6_type;
- u_int16_t ospf6_len;
- rtrid_t ospf6_routerid;
- rtrid_t ospf6_areaid;
- u_int16_t ospf6_chksum;
- u_int8_t ospf6_instanceid;
- u_int8_t ospf6_rsvd;
- union {
-
- /* Hello packet */
- struct {
- u_int32_t hello_ifid;
- union {
- u_int8_t pri;
- u_int32_t opt;
- } hello_priandopt;
-#define hello_priority hello_priandopt.pri
-#define hello_options hello_priandopt.opt
- u_int16_t hello_helloint;
- u_int16_t hello_deadint;
- rtrid_t hello_dr;
- rtrid_t hello_bdr;
- rtrid_t hello_neighbor[1]; /* may repeat */
- } un_hello;
-
- /* Database Description packet */
- struct {
- u_int32_t db_options;
- u_int16_t db_mtu;
- u_int8_t db_mbz;
- u_int8_t db_flags;
- u_int32_t db_seq;
- struct lsa6_hdr db_lshdr[1]; /* may repeat */
- } un_db;
-
- /* Link State Request */
- struct lsr6 {
- u_int16_t ls_mbz;
- u_int16_t ls_type;
- rtrid_t ls_stateid;
- rtrid_t ls_router;
- } un_lsr[1]; /* may repeat */
-
- /* Link State Update */
- struct {
- u_int32_t lsu_count;
- struct lsa6 lsu_lsa[1]; /* may repeat */
- } un_lsu;
-
- /* Link State Acknowledgement */
- struct {
- struct lsa6_hdr lsa_lshdr[1]; /* may repeat */
- } un_lsa ;
- } ospf6_un ;
-};
-
-#define ospf6_hello ospf6_un.un_hello
-#define ospf6_db ospf6_un.un_db
-#define ospf6_lsr ospf6_un.un_lsr
-#define ospf6_lsu ospf6_un.un_lsu
-#define ospf6_lsa ospf6_un.un_lsa
-
diff --git a/freebsd/contrib/tcpdump/oui.c b/freebsd/contrib/tcpdump/oui.c
index 07ba0943..44688aae 100644
--- a/freebsd/contrib/tcpdump/oui.c
+++ b/freebsd/contrib/tcpdump/oui.c
@@ -1,6 +1,9 @@
#include <machine/rtems-bsd-user-space.h>
-
-/*
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
+/*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code
* distributions retain the above copyright notice and this paragraph
@@ -15,17 +18,12 @@
* Original code by Hannes Gredler (hannes@juniper.net)
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/oui.c,v 1.9 2008-01-09 09:40:47 hannes Exp $ (LBL)";
-#endif
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
-#include "interface.h"
+#include <netdissect-stdinc.h>
+#include "netdissect.h"
#include "oui.h"
/* FIXME complete OUI list using a script */
@@ -33,6 +31,7 @@ static const char rcsid[] _U_ =
const struct tok oui_values[] = {
{ OUI_ENCAP_ETHER, "Ethernet" },
{ OUI_CISCO, "Cisco" },
+ { OUI_IANA, "IANA" },
{ OUI_NORTEL, "Nortel Networks SONMP" },
{ OUI_CISCO_90, "Cisco bridged" },
{ OUI_RFC2684, "Ethernet bridged" },
@@ -45,6 +44,15 @@ const struct tok oui_values[] = {
{ OUI_IEEE_8023_PRIVATE, "IEEE 802.3 Private"},
{ OUI_TIA, "ANSI/TIA"},
{ OUI_DCBX, "DCBX"},
+ { OUI_NICIRA, "Nicira Networks" },
+ { OUI_BSN, "Big Switch Networks" },
+ { OUI_VELLO, "Vello Systems" },
+ { OUI_HP2, "HP" },
+ { OUI_HPLABS, "HP-Labs" },
+ { OUI_INFOBLOX, "Infoblox Inc" },
+ { OUI_ONLAB, "Open Networking Lab" },
+ { OUI_FREESCALE, "Freescale" },
+ { OUI_NETRONOME, "Netronome" },
{ 0, NULL }
};
@@ -99,3 +107,6 @@ const struct tok smi_values[] = {
{ SMI_WIFI_ALLIANCE, "Wi-Fi Alliance"},
{ 0, NULL}
};
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-oui-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/oui.h b/freebsd/contrib/tcpdump/oui.h
index d39cb6ca..a85f883d 100644
--- a/freebsd/contrib/tcpdump/oui.h
+++ b/freebsd/contrib/tcpdump/oui.h
@@ -1,5 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/oui.h,v 1.8 2008-01-09 09:40:47 hannes Exp $ (LBL) */
-/*
+/*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code
* distributions retain the above copyright notice and this paragraph
@@ -17,20 +16,30 @@
extern const struct tok oui_values[];
extern const struct tok smi_values[];
-#define OUI_ENCAP_ETHER 0x000000 /* encapsulated Ethernet */
-#define OUI_CISCO 0x00000c /* Cisco protocols */
-#define OUI_NORTEL 0x000081 /* Nortel SONMP */
-#define OUI_CISCO_90 0x0000f8 /* Cisco bridging */
-#define OUI_RFC2684 0x0080c2 /* RFC 2427/2684 bridged Ethernet */
-#define OUI_ATM_FORUM 0x00A03E /* ATM Forum */
-#define OUI_CABLE_BPDU 0x00E02F /* DOCSIS spanning tree BPDU */
-#define OUI_APPLETALK 0x080007 /* Appletalk */
-#define OUI_JUNIPER 0x009069 /* Juniper */
-#define OUI_HP 0x080009 /* Hewlett-Packard */
-#define OUI_IEEE_8021_PRIVATE 0x0080c2 /* IEEE 802.1 Organisation Specific - Annex F */
-#define OUI_IEEE_8023_PRIVATE 0x00120f /* IEEE 802.3 Organisation Specific - Annex G */
-#define OUI_TIA 0x0012bb /* TIA - Telecommunications Industry Association - ANSI/TIA-1057- 2006 */
-#define OUI_DCBX 0x001B21 /* DCBX */
+#define OUI_ENCAP_ETHER 0x000000 /* encapsulated Ethernet */
+#define OUI_CISCO 0x00000c /* Cisco protocols */
+#define OUI_IANA 0x00005E /* IANA */
+#define OUI_NORTEL 0x000081 /* Nortel SONMP */
+#define OUI_CISCO_90 0x0000f8 /* Cisco bridging */
+#define OUI_RFC2684 0x0080c2 /* RFC 2427/2684 bridged Ethernet */
+#define OUI_ATM_FORUM 0x00A03E /* ATM Forum */
+#define OUI_CABLE_BPDU 0x00E02F /* DOCSIS spanning tree BPDU */
+#define OUI_APPLETALK 0x080007 /* Appletalk */
+#define OUI_JUNIPER 0x009069 /* Juniper */
+#define OUI_HP 0x080009 /* Hewlett-Packard */
+#define OUI_IEEE_8021_PRIVATE 0x0080c2 /* IEEE 802.1 Organisation Specific - Annex F */
+#define OUI_IEEE_8023_PRIVATE 0x00120f /* IEEE 802.3 Organisation Specific - Annex G */
+#define OUI_TIA 0x0012bb /* TIA - Telecommunications Industry Association - ANSI/TIA-1057- 2006 */
+#define OUI_DCBX 0x001B21 /* DCBX */
+#define OUI_NICIRA 0x002320 /* Nicira Networks */
+#define OUI_BSN 0x5c16c7 /* Big Switch Networks */
+#define OUI_VELLO 0xb0d2f5 /* Vello Systems */
+#define OUI_HP2 0x002481 /* HP too */
+#define OUI_HPLABS 0x0004ea /* HP-Labs */
+#define OUI_INFOBLOX 0x748771 /* Infoblox Inc */
+#define OUI_ONLAB 0xa42305 /* Open Networking Lab */
+#define OUI_FREESCALE 0x00049f /* Freescale */
+#define OUI_NETRONOME 0x0015ad /* Netronome */
/*
* These are SMI Network Management Private Enterprise Codes for
diff --git a/freebsd/contrib/tcpdump/parsenfsfh.c b/freebsd/contrib/tcpdump/parsenfsfh.c
index a6025e6b..bb391379 100644
--- a/freebsd/contrib/tcpdump/parsenfsfh.c
+++ b/freebsd/contrib/tcpdump/parsenfsfh.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1993, 1994 Jeffrey C. Mogul, Digital Equipment Corporation,
* Western Research Laboratory. All rights reserved.
@@ -40,25 +43,18 @@
* Jeffrey C. Mogul
* Digital Equipment Corporation
* Western Research Laboratory
- *
- * $FreeBSD$
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/parsenfsfh.c,v 1.29 2006-06-13 22:21:38 guy Exp $ (LBL)";
-#endif
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <stdio.h>
#include <string.h>
-#include "interface.h"
+#include "netdissect.h"
#include "nfsfh.h"
/*
@@ -87,7 +83,7 @@ static const char rcsid[] _U_ =
#ifdef ultrix
/* Nasty hack to keep the Ultrix C compiler from emitting bogus warnings */
-#define XFF(x) ((u_int32_t)(x))
+#define XFF(x) ((uint32_t)(x))
#else
#define XFF(x) (x)
#endif
@@ -111,153 +107,158 @@ static const char rcsid[] _U_ =
((lsb) + ((e)<<8) + ((d)<<16) + ((c)<<24))
#endif
-static int is_UCX(const unsigned char *);
+static int is_UCX(const unsigned char *, u_int);
void
-Parse_fh(fh, len, fsidp, inop, osnamep, fsnamep, ourself)
-register const unsigned char *fh;
-int len _U_;
-my_fsid *fsidp;
-ino_t *inop;
-const char **osnamep; /* if non-NULL, return OS name here */
-const char **fsnamep; /* if non-NULL, return server fs name here (for VMS) */
-int ourself; /* true if file handle was generated on this host */
+Parse_fh(register const unsigned char *fh, u_int len, my_fsid *fsidp,
+ uint32_t *inop,
+ const char **osnamep, /* if non-NULL, return OS name here */
+ const char **fsnamep, /* if non-NULL, return server fs name here (for VMS) */
+ int ourself) /* true if file handle was generated on this host */
{
register const unsigned char *fhp = fh;
- u_int32_t temp;
+ uint32_t temp;
int fhtype = FHT_UNKNOWN;
- int i;
+ u_int i;
- if (ourself) {
- /* File handle generated on this host, no need for guessing */
+ /*
+ * Require at least 16 bytes of file handle; it's variable-length
+ * in NFSv3. "len" is in units of 32-bit words, not bytes.
+ */
+ if (len < 16/4)
+ fhtype = FHT_UNKNOWN;
+ else {
+ if (ourself) {
+ /* File handle generated on this host, no need for guessing */
#if defined(IRIX40)
- fhtype = FHT_IRIX4;
+ fhtype = FHT_IRIX4;
#endif
#if defined(IRIX50)
- fhtype = FHT_IRIX5;
+ fhtype = FHT_IRIX5;
#endif
#if defined(IRIX51)
- fhtype = FHT_IRIX5;
+ fhtype = FHT_IRIX5;
#endif
#if defined(SUNOS4)
- fhtype = FHT_SUNOS4;
+ fhtype = FHT_SUNOS4;
#endif
#if defined(SUNOS5)
- fhtype = FHT_SUNOS5;
+ fhtype = FHT_SUNOS5;
#endif
#if defined(ultrix)
- fhtype = FHT_ULTRIX;
+ fhtype = FHT_ULTRIX;
#endif
#if defined(__osf__)
- fhtype = FHT_DECOSF;
+ fhtype = FHT_DECOSF;
#endif
#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) \
|| defined(__OpenBSD__)
- fhtype = FHT_BSD44;
-#endif
- }
- /*
- * This is basically a big decision tree
- */
- else if ((fhp[0] == 0) && (fhp[1] == 0)) {
- /* bytes[0,1] == (0,0); rules out Ultrix, IRIX5, SUNOS5 */
- /* probably rules out HP-UX, AIX unless they allow major=0 */
- if ((fhp[2] == 0) && (fhp[3] == 0)) {
- /* bytes[2,3] == (0,0); must be Auspex */
- /* XXX or could be Ultrix+MASSBUS "hp" disk? */
- fhtype = FHT_AUSPEX;
- }
- else {
- /*
- * bytes[2,3] != (0,0); rules out Auspex, could be
- * DECOSF, SUNOS4, or IRIX4
- */
- if ((fhp[4] != 0) && (fhp[5] == 0) &&
- (fhp[8] == 12) && (fhp[9] == 0)) {
- /* seems to be DECOSF, with minor == 0 */
- fhtype = FHT_DECOSF;
- }
- else {
- /* could be SUNOS4 or IRIX4 */
- /* XXX the test of fhp[5] == 8 could be wrong */
- if ((fhp[4] == 0) && (fhp[5] == 8) && (fhp[6] == 0) &&
- (fhp[7] == 0)) {
- /* looks like a length, not a file system typecode */
- fhtype = FHT_IRIX4;
- }
- else {
- /* by elimination */
- fhtype = FHT_SUNOS4;
- }
- }
- }
- }
- else {
- /*
- * bytes[0,1] != (0,0); rules out Auspex, IRIX4, SUNOS4
- * could be IRIX5, DECOSF, UCX, Ultrix, SUNOS5
- * could be AIX, HP-UX
- */
- if ((fhp[2] == 0) && (fhp[3] == 0)) {
- /*
- * bytes[2,3] == (0,0); rules out OSF, probably not UCX
- * (unless the exported device name is just one letter!),
- * could be Ultrix, IRIX5, AIX, or SUNOS5
- * might be HP-UX (depends on their values for minor devs)
- */
- if ((fhp[6] == 0) && (fhp[7] == 0)) {
fhtype = FHT_BSD44;
+#endif
}
- /*XXX we probably only need to test of these two bytes */
- else if ((fhp[21] == 0) && (fhp[23] == 0)) {
- fhtype = FHT_ULTRIX;
- }
- else {
- /* Could be SUNOS5/IRIX5, maybe AIX */
- /* XXX no obvious difference between SUNOS5 and IRIX5 */
- if (fhp[9] == 10)
- fhtype = FHT_SUNOS5;
- /* XXX what about AIX? */
- }
- }
- else {
/*
- * bytes[2,3] != (0,0); rules out Ultrix, could be
- * DECOSF, SUNOS5, IRIX5, AIX, HP-UX, or UCX
+ * This is basically a big decision tree
*/
- if ((fhp[8] == 12) && (fhp[9] == 0)) {
- fhtype = FHT_DECOSF;
- }
- else if ((fhp[8] == 0) && (fhp[9] == 10)) {
- /* could be SUNOS5/IRIX5, AIX, HP-UX */
- if ((fhp[7] == 0) && (fhp[6] == 0) &&
- (fhp[5] == 0) && (fhp[4] == 0)) {
- /* XXX is this always true of HP-UX? */
- fhtype = FHT_HPUX9;
- }
- else if (fhp[7] == 2) {
- /* This would be MNT_NFS on AIX, which is impossible */
- fhtype = FHT_SUNOS5; /* or maybe IRIX5 */
+ else if ((fhp[0] == 0) && (fhp[1] == 0)) {
+ /* bytes[0,1] == (0,0); rules out Ultrix, IRIX5, SUNOS5 */
+ /* probably rules out HP-UX, AIX unless they allow major=0 */
+ if ((fhp[2] == 0) && (fhp[3] == 0)) {
+ /* bytes[2,3] == (0,0); must be Auspex */
+ /* XXX or could be Ultrix+MASSBUS "hp" disk? */
+ fhtype = FHT_AUSPEX;
}
else {
/*
- * XXX Could be SUNOS5/IRIX5 or AIX. I don't
- * XXX see any way to disambiguate these, so
- * XXX I'm going with the more likely guess.
- * XXX Sorry, Big Blue.
+ * bytes[2,3] != (0,0); rules out Auspex, could be
+ * DECOSF, SUNOS4, or IRIX4
*/
- fhtype = FHT_SUNOS5; /* or maybe IRIX5 */
+ if ((fhp[4] != 0) && (fhp[5] == 0) &&
+ (fhp[8] == 12) && (fhp[9] == 0)) {
+ /* seems to be DECOSF, with minor == 0 */
+ fhtype = FHT_DECOSF;
+ }
+ else {
+ /* could be SUNOS4 or IRIX4 */
+ /* XXX the test of fhp[5] == 8 could be wrong */
+ if ((fhp[4] == 0) && (fhp[5] == 8) && (fhp[6] == 0) &&
+ (fhp[7] == 0)) {
+ /* looks like a length, not a file system typecode */
+ fhtype = FHT_IRIX4;
+ }
+ else {
+ /* by elimination */
+ fhtype = FHT_SUNOS4;
+ }
+ }
}
- }
+ }
else {
- if (is_UCX(fhp)) {
- fhtype = FHT_VMSUCX;
+ /*
+ * bytes[0,1] != (0,0); rules out Auspex, IRIX4, SUNOS4
+ * could be IRIX5, DECOSF, UCX, Ultrix, SUNOS5
+ * could be AIX, HP-UX
+ */
+ if ((fhp[2] == 0) && (fhp[3] == 0)) {
+ /*
+ * bytes[2,3] == (0,0); rules out OSF, probably not UCX
+ * (unless the exported device name is just one letter!),
+ * could be Ultrix, IRIX5, AIX, or SUNOS5
+ * might be HP-UX (depends on their values for minor devs)
+ */
+ if ((fhp[6] == 0) && (fhp[7] == 0)) {
+ fhtype = FHT_BSD44;
+ }
+ /*XXX we probably only need to test of these two bytes */
+ else if ((len >= 24/4) && (fhp[21] == 0) && (fhp[23] == 0)) {
+ fhtype = FHT_ULTRIX;
+ }
+ else {
+ /* Could be SUNOS5/IRIX5, maybe AIX */
+ /* XXX no obvious difference between SUNOS5 and IRIX5 */
+ if (fhp[9] == 10)
+ fhtype = FHT_SUNOS5;
+ /* XXX what about AIX? */
+ }
}
else {
- fhtype = FHT_UNKNOWN;
+ /*
+ * bytes[2,3] != (0,0); rules out Ultrix, could be
+ * DECOSF, SUNOS5, IRIX5, AIX, HP-UX, or UCX
+ */
+ if ((fhp[8] == 12) && (fhp[9] == 0)) {
+ fhtype = FHT_DECOSF;
+ }
+ else if ((fhp[8] == 0) && (fhp[9] == 10)) {
+ /* could be SUNOS5/IRIX5, AIX, HP-UX */
+ if ((fhp[7] == 0) && (fhp[6] == 0) &&
+ (fhp[5] == 0) && (fhp[4] == 0)) {
+ /* XXX is this always true of HP-UX? */
+ fhtype = FHT_HPUX9;
+ }
+ else if (fhp[7] == 2) {
+ /* This would be MNT_NFS on AIX, which is impossible */
+ fhtype = FHT_SUNOS5; /* or maybe IRIX5 */
+ }
+ else {
+ /*
+ * XXX Could be SUNOS5/IRIX5 or AIX. I don't
+ * XXX see any way to disambiguate these, so
+ * XXX I'm going with the more likely guess.
+ * XXX Sorry, Big Blue.
+ */
+ fhtype = FHT_SUNOS5; /* or maybe IRIX5 */
+ }
+ }
+ else {
+ if (is_UCX(fhp, len)) {
+ fhtype = FHT_VMSUCX;
+ }
+ else {
+ fhtype = FHT_UNKNOWN;
+ }
+ }
}
}
- }
}
/* XXX still needs to handle SUNOS3 */
@@ -268,8 +269,7 @@ int ourself; /* true if file handle was generated on this host */
fsidp->Fsid_dev.Major = fhp[6];
fsidp->fsid_code = 0;
- temp = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]);
- *inop = temp;
+ *inop = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]);
if (osnamep)
*osnamep = "Auspex";
@@ -280,8 +280,7 @@ int ourself; /* true if file handle was generated on this host */
fsidp->Fsid_dev.Major = fhp[1];
fsidp->fsid_code = 0;
- temp = make_uint32(fhp[15], fhp[14], fhp[13], fhp[12]);
- *inop = temp;
+ *inop = make_uint32(fhp[15], fhp[14], fhp[13], fhp[12]);
if (osnamep)
*osnamep = "BSD 4.4";
@@ -295,8 +294,7 @@ int ourself; /* true if file handle was generated on this host */
fsidp->Fsid_dev.Minor = temp & 0xFFFFF;
fsidp->Fsid_dev.Major = (temp>>20) & 0xFFF;
- temp = make_uint32(fhp[15], fhp[14], fhp[13], fhp[12]);
- *inop = temp;
+ *inop = make_uint32(fhp[15], fhp[14], fhp[13], fhp[12]);
if (osnamep)
*osnamep = "OSF";
break;
@@ -306,8 +304,7 @@ int ourself; /* true if file handle was generated on this host */
fsidp->Fsid_dev.Major = fhp[2];
fsidp->fsid_code = 0;
- temp = make_uint32(fhp[8], fhp[9], fhp[10], fhp[11]);
- *inop = temp;
+ *inop = make_uint32(fhp[8], fhp[9], fhp[10], fhp[11]);
if (osnamep)
*osnamep = "IRIX4";
@@ -318,8 +315,7 @@ int ourself; /* true if file handle was generated on this host */
fsidp->Fsid_dev.Major = make_uint16(fhp[0], fhp[1]);
fsidp->fsid_code = make_uint32(fhp[4], fhp[5], fhp[6], fhp[7]);
- temp = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]);
- *inop = temp;
+ *inop = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]);
if (osnamep)
*osnamep = "IRIX5";
@@ -341,8 +337,7 @@ int ourself; /* true if file handle was generated on this host */
fsidp->Fsid_dev.Major = fhp[2];
fsidp->fsid_code = make_uint32(fhp[4], fhp[5], fhp[6], fhp[7]);
- temp = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]);
- *inop = temp;
+ *inop = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]);
if (osnamep)
*osnamep = "SUNOS4";
@@ -355,8 +350,7 @@ int ourself; /* true if file handle was generated on this host */
fsidp->Fsid_dev.Minor = temp & 0x3FFFF;
fsidp->fsid_code = make_uint32(fhp[4], fhp[5], fhp[6], fhp[7]);
- temp = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]);
- *inop = temp;
+ *inop = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]);
if (osnamep)
*osnamep = "SUNOS5";
@@ -379,13 +373,13 @@ int ourself; /* true if file handle was generated on this host */
if (sizeof(*fsidp) > 14)
memset((char *)fsidp, 0, sizeof(*fsidp));
/* just use the whole thing */
- memcpy((char *)fsidp, (char *)fh, 14);
+ memcpy((char *)fsidp, (const char *)fh, 14);
}
else {
- u_int32_t tempa[4]; /* at least 16 bytes, maybe more */
+ uint32_t tempa[4]; /* at least 16 bytes, maybe more */
memset((char *)tempa, 0, sizeof(tempa));
- memcpy((char *)tempa, (char *)fh, 14); /* ensure alignment */
+ memcpy((char *)tempa, (const char *)fh, 14); /* ensure alignment */
fsidp->Fsid_dev.Minor = tempa[0] + (tempa[1]<<1);
fsidp->Fsid_dev.Major = tempa[2] + (tempa[3]<<1);
fsidp->fsid_code = 0;
@@ -396,7 +390,7 @@ int ourself; /* true if file handle was generated on this host */
/* Caller must save (and null-terminate?) this value */
if (fsnamep)
- *fsnamep = (char *)&(fhp[1]);
+ *fsnamep = (const char *)&(fhp[1]);
if (osnamep)
*osnamep = "VMS";
@@ -407,8 +401,7 @@ int ourself; /* true if file handle was generated on this host */
fsidp->Fsid_dev.Major = make_uint16(fhp[0], fhp[1]);
fsidp->fsid_code = make_uint32(fhp[4], fhp[5], fhp[6], fhp[7]);
- temp = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]);
- *inop = temp;
+ *inop = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]);
if (osnamep)
*osnamep = "AIX32";
@@ -420,8 +413,7 @@ int ourself; /* true if file handle was generated on this host */
fsidp->Fsid_dev.Minor = temp;
fsidp->fsid_code = make_uint32(fhp[4], fhp[5], fhp[6], fhp[7]);
- temp = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]);
- *inop = temp;
+ *inop = make_uint32(fhp[12], fhp[13], fhp[14], fhp[15]);
if (osnamep)
*osnamep = "HPUX9";
@@ -430,13 +422,14 @@ int ourself; /* true if file handle was generated on this host */
case FHT_UNKNOWN:
#ifdef DEBUG
/* XXX debugging */
- for (i = 0; i < 32; i++)
+ for (i = 0; i < len*4; i++)
(void)fprintf(stderr, "%x.", fhp[i]);
(void)fprintf(stderr, "\n");
#endif
/* Save the actual handle, so it can be display with -u */
- for (i = 0; i < 32; i++)
+ for (i = 0; i < len*4 && i*2 < sizeof(fsidp->Opaque_Handle) - 1; i++)
(void)snprintf(&(fsidp->Opaque_Handle[i*2]), 3, "%.2X", fhp[i]);
+ fsidp->Opaque_Handle[i*2] = '\0';
/* XXX for now, give "bogus" values to aid debugging */
fsidp->fsid_code = 0;
@@ -463,14 +456,20 @@ int ourself; /* true if file handle was generated on this host */
* (3) followed by string of nulls
*/
static int
-is_UCX(fhp)
-const unsigned char *fhp;
+is_UCX(const unsigned char *fhp, u_int len)
{
- register int i;
+ register u_int i;
int seen_null = 0;
+ /*
+ * Require at least 28 bytes of file handle; it's variable-length
+ * in NFSv3. "len" is in units of 32-bit words, not bytes.
+ */
+ if (len < 28/4)
+ return(0);
+
for (i = 1; i < 14; i++) {
- if (isprint(fhp[i])) {
+ if (ND_ISPRINT(fhp[i])) {
if (seen_null)
return(0);
else
@@ -486,3 +485,6 @@ const unsigned char *fhp;
return(1);
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-parsenfsfh-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/pcap-missing.h b/freebsd/contrib/tcpdump/pcap-missing.h
index 5c0ece25..92706b14 100644
--- a/freebsd/contrib/tcpdump/pcap-missing.h
+++ b/freebsd/contrib/tcpdump/pcap-missing.h
@@ -17,12 +17,10 @@
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * @(#) $Header: /tcpdump/master/tcpdump/pcap-missing.h,v 1.3 2005-06-03 22:08:52 guy Exp $ (LBL)
*/
-#ifndef tcpdump_pcap_missing_h
-#define tcpdump_pcap_missing_h
+#ifndef netdissect_pcap_missing_h
+#define netdissect_pcap_missing_h
/*
* Declarations of functions that might be missing from libpcap.
@@ -48,13 +46,4 @@ extern const char *pcap_datalink_val_to_description(int);
extern long pcap_dump_ftell(pcap_dumper_t *);
#endif
-#endif
-
-
-
-
-
-
-
-
-
+#endif /* netdissect_pcap_missing_h */
diff --git a/freebsd/contrib/tcpdump/pmap_prot.h b/freebsd/contrib/tcpdump/pmap_prot.h
deleted file mode 100644
index 949c3994..00000000
--- a/freebsd/contrib/tcpdump/pmap_prot.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/pmap_prot.h,v 1.3 2005-04-27 21:43:48 guy Exp $ (LBL) */
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part. Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- *
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California 94043
- *
- * from: @(#)pmap_prot.h 1.14 88/02/08 SMI
- * from: @(#)pmap_prot.h 2.1 88/07/29 4.0 RPCSRC
- * $FreeBSD$
- * FreeBSD: src/include/rpc/pmap_prot.h,v 1.9.2.1 1999/08/29 14:39:05 peter Exp
- */
-
-/*
- * pmap_prot.h
- * Protocol for the local binder service, or pmap.
- *
- * Copyright (C) 1984, Sun Microsystems, Inc.
- *
- * The following procedures are supported by the protocol:
- *
- * PMAPPROC_NULL() returns ()
- * takes nothing, returns nothing
- *
- * PMAPPROC_SET(struct pmap) returns (bool_t)
- * TRUE is success, FALSE is failure. Registers the tuple
- * [prog, vers, prot, port].
- *
- * PMAPPROC_UNSET(struct pmap) returns (bool_t)
- * TRUE is success, FALSE is failure. Un-registers pair
- * [prog, vers]. prot and port are ignored.
- *
- * PMAPPROC_GETPORT(struct pmap) returns (long unsigned).
- * 0 is failure. Otherwise returns the port number where the pair
- * [prog, vers] is registered. It may lie!
- *
- * PMAPPROC_DUMP() RETURNS (struct pmaplist *)
- *
- * PMAPPROC_CALLIT(unsigned, unsigned, unsigned, string<>)
- * RETURNS (port, string<>);
- * usage: encapsulatedresults = PMAPPROC_CALLIT(prog, vers, proc, encapsulatedargs);
- * Calls the procedure on the local machine. If it is not registered,
- * this procedure is quite; ie it does not return error information!!!
- * This procedure only is supported on rpc/udp and calls via
- * rpc/udp. This routine only passes null authentication parameters.
- * This file has no interface to xdr routines for PMAPPROC_CALLIT.
- *
- * The service supports remote procedure calls on udp/ip or tcp/ip socket 111.
- */
-
-#define SUNRPC_PMAPPORT ((u_int16_t)111)
-#define SUNRPC_PMAPPROG ((u_int32_t)100000)
-#define SUNRPC_PMAPVERS ((u_int32_t)2)
-#define SUNRPC_PMAPVERS_PROTO ((u_int32_t)2)
-#define SUNRPC_PMAPVERS_ORIG ((u_int32_t)1)
-#define SUNRPC_PMAPPROC_NULL ((u_int32_t)0)
-#define SUNRPC_PMAPPROC_SET ((u_int32_t)1)
-#define SUNRPC_PMAPPROC_UNSET ((u_int32_t)2)
-#define SUNRPC_PMAPPROC_GETPORT ((u_int32_t)3)
-#define SUNRPC_PMAPPROC_DUMP ((u_int32_t)4)
-#define SUNRPC_PMAPPROC_CALLIT ((u_int32_t)5)
-
-struct sunrpc_pmap {
- u_int32_t pm_prog;
- u_int32_t pm_vers;
- u_int32_t pm_prot;
- u_int32_t pm_port;
-};
diff --git a/freebsd/contrib/tcpdump/ppi.h b/freebsd/contrib/tcpdump/ppi.h
deleted file mode 100644
index 733eb950..00000000
--- a/freebsd/contrib/tcpdump/ppi.h
+++ /dev/null
@@ -1,9 +0,0 @@
-typedef struct ppi_header {
- uint8_t ppi_ver;
- uint8_t ppi_flags;
- uint16_t ppi_len;
- uint32_t ppi_dlt;
-} ppi_header_t;
-
-#define PPI_HDRLEN 8
-
diff --git a/freebsd/contrib/tcpdump/ppp.h b/freebsd/contrib/tcpdump/ppp.h
index 3ae519b6..9d53423f 100644
--- a/freebsd/contrib/tcpdump/ppp.h
+++ b/freebsd/contrib/tcpdump/ppp.h
@@ -1,4 +1,3 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/ppp.h,v 1.16 2004-10-20 16:14:16 hannes Exp $ (LBL) */
/*
* Point to Point Protocol (PPP) RFC1331
*
@@ -14,8 +13,6 @@
* University. Carnegie Mellon makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
- *
- * $FreeBSD$
*/
#define PPP_HDRLEN 4 /* length of PPP header */
@@ -69,5 +66,3 @@
#define PPP_MPCP 0xc03d /* Multi-Link */
#define PPP_SPAP_OLD 0xc123
#define PPP_EAP 0xc227
-
-extern struct tok ppptype2str[];
diff --git a/freebsd/contrib/tcpdump/print-802_11.c b/freebsd/contrib/tcpdump/print-802_11.c
index d0dee658..00f88f9f 100644
--- a/freebsd/contrib/tcpdump/print-802_11.c
+++ b/freebsd/contrib/tcpdump/print-802_11.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 2001
* Fortress Technologies, Inc. All rights reserved.
@@ -22,50 +25,394 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-802_11.c,v 1.49 2007-12-29 23:25:02 guy Exp $ (LBL)";
-#endif
+/* \summary: IEEE 802.11 printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include <stdio.h>
-#include <pcap.h>
#include <string.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
-#include "ethertype.h"
#include "extract.h"
#include "cpack.h"
-#include "ieee802_11.h"
-#include "ieee802_11_radio.h"
-/* Radiotap state */
-/* This is used to save state when parsing/processing parameters */
-struct radiotap_state
-{
- u_int32_t present;
+/* Lengths of 802.11 header components. */
+#define IEEE802_11_FC_LEN 2
+#define IEEE802_11_DUR_LEN 2
+#define IEEE802_11_DA_LEN 6
+#define IEEE802_11_SA_LEN 6
+#define IEEE802_11_BSSID_LEN 6
+#define IEEE802_11_RA_LEN 6
+#define IEEE802_11_TA_LEN 6
+#define IEEE802_11_ADDR1_LEN 6
+#define IEEE802_11_SEQ_LEN 2
+#define IEEE802_11_CTL_LEN 2
+#define IEEE802_11_CARRIED_FC_LEN 2
+#define IEEE802_11_HT_CONTROL_LEN 4
+#define IEEE802_11_IV_LEN 3
+#define IEEE802_11_KID_LEN 1
+
+/* Frame check sequence length. */
+#define IEEE802_11_FCS_LEN 4
+
+/* Lengths of beacon components. */
+#define IEEE802_11_TSTAMP_LEN 8
+#define IEEE802_11_BCNINT_LEN 2
+#define IEEE802_11_CAPINFO_LEN 2
+#define IEEE802_11_LISTENINT_LEN 2
+
+#define IEEE802_11_AID_LEN 2
+#define IEEE802_11_STATUS_LEN 2
+#define IEEE802_11_REASON_LEN 2
+
+/* Length of previous AP in reassocation frame */
+#define IEEE802_11_AP_LEN 6
+
+#define T_MGMT 0x0 /* management */
+#define T_CTRL 0x1 /* control */
+#define T_DATA 0x2 /* data */
+#define T_RESV 0x3 /* reserved */
+
+#define ST_ASSOC_REQUEST 0x0
+#define ST_ASSOC_RESPONSE 0x1
+#define ST_REASSOC_REQUEST 0x2
+#define ST_REASSOC_RESPONSE 0x3
+#define ST_PROBE_REQUEST 0x4
+#define ST_PROBE_RESPONSE 0x5
+/* RESERVED 0x6 */
+/* RESERVED 0x7 */
+#define ST_BEACON 0x8
+#define ST_ATIM 0x9
+#define ST_DISASSOC 0xA
+#define ST_AUTH 0xB
+#define ST_DEAUTH 0xC
+#define ST_ACTION 0xD
+/* RESERVED 0xE */
+/* RESERVED 0xF */
+
+static const struct tok st_str[] = {
+ { ST_ASSOC_REQUEST, "Assoc Request" },
+ { ST_ASSOC_RESPONSE, "Assoc Response" },
+ { ST_REASSOC_REQUEST, "ReAssoc Request" },
+ { ST_REASSOC_RESPONSE, "ReAssoc Response" },
+ { ST_PROBE_REQUEST, "Probe Request" },
+ { ST_PROBE_RESPONSE, "Probe Response" },
+ { ST_BEACON, "Beacon" },
+ { ST_ATIM, "ATIM" },
+ { ST_DISASSOC, "Disassociation" },
+ { ST_AUTH, "Authentication" },
+ { ST_DEAUTH, "DeAuthentication" },
+ { ST_ACTION, "Action" },
+ { 0, NULL }
+};
+
+#define CTRL_CONTROL_WRAPPER 0x7
+#define CTRL_BAR 0x8
+#define CTRL_BA 0x9
+#define CTRL_PS_POLL 0xA
+#define CTRL_RTS 0xB
+#define CTRL_CTS 0xC
+#define CTRL_ACK 0xD
+#define CTRL_CF_END 0xE
+#define CTRL_END_ACK 0xF
+
+static const struct tok ctrl_str[] = {
+ { CTRL_CONTROL_WRAPPER, "Control Wrapper" },
+ { CTRL_BAR, "BAR" },
+ { CTRL_BA, "BA" },
+ { CTRL_PS_POLL, "Power Save-Poll" },
+ { CTRL_RTS, "Request-To-Send" },
+ { CTRL_CTS, "Clear-To-Send" },
+ { CTRL_ACK, "Acknowledgment" },
+ { CTRL_CF_END, "CF-End" },
+ { CTRL_END_ACK, "CF-End+CF-Ack" },
+ { 0, NULL }
+};
+
+#define DATA_DATA 0x0
+#define DATA_DATA_CF_ACK 0x1
+#define DATA_DATA_CF_POLL 0x2
+#define DATA_DATA_CF_ACK_POLL 0x3
+#define DATA_NODATA 0x4
+#define DATA_NODATA_CF_ACK 0x5
+#define DATA_NODATA_CF_POLL 0x6
+#define DATA_NODATA_CF_ACK_POLL 0x7
+
+#define DATA_QOS_DATA 0x8
+#define DATA_QOS_DATA_CF_ACK 0x9
+#define DATA_QOS_DATA_CF_POLL 0xA
+#define DATA_QOS_DATA_CF_ACK_POLL 0xB
+#define DATA_QOS_NODATA 0xC
+#define DATA_QOS_CF_POLL_NODATA 0xE
+#define DATA_QOS_CF_ACK_POLL_NODATA 0xF
+
+/*
+ * The subtype field of a data frame is, in effect, composed of 4 flag
+ * bits - CF-Ack, CF-Poll, Null (means the frame doesn't actually have
+ * any data), and QoS.
+ */
+#define DATA_FRAME_IS_CF_ACK(x) ((x) & 0x01)
+#define DATA_FRAME_IS_CF_POLL(x) ((x) & 0x02)
+#define DATA_FRAME_IS_NULL(x) ((x) & 0x04)
+#define DATA_FRAME_IS_QOS(x) ((x) & 0x08)
+
+/*
+ * Bits in the frame control field.
+ */
+#define FC_VERSION(fc) ((fc) & 0x3)
+#define FC_TYPE(fc) (((fc) >> 2) & 0x3)
+#define FC_SUBTYPE(fc) (((fc) >> 4) & 0xF)
+#define FC_TO_DS(fc) ((fc) & 0x0100)
+#define FC_FROM_DS(fc) ((fc) & 0x0200)
+#define FC_MORE_FLAG(fc) ((fc) & 0x0400)
+#define FC_RETRY(fc) ((fc) & 0x0800)
+#define FC_POWER_MGMT(fc) ((fc) & 0x1000)
+#define FC_MORE_DATA(fc) ((fc) & 0x2000)
+#define FC_PROTECTED(fc) ((fc) & 0x4000)
+#define FC_ORDER(fc) ((fc) & 0x8000)
+
+struct mgmt_header_t {
+ uint16_t fc;
+ uint16_t duration;
+ uint8_t da[IEEE802_11_DA_LEN];
+ uint8_t sa[IEEE802_11_SA_LEN];
+ uint8_t bssid[IEEE802_11_BSSID_LEN];
+ uint16_t seq_ctrl;
+};
+
+#define MGMT_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
+ IEEE802_11_DA_LEN+IEEE802_11_SA_LEN+\
+ IEEE802_11_BSSID_LEN+IEEE802_11_SEQ_LEN)
+
+#define CAPABILITY_ESS(cap) ((cap) & 0x0001)
+#define CAPABILITY_IBSS(cap) ((cap) & 0x0002)
+#define CAPABILITY_CFP(cap) ((cap) & 0x0004)
+#define CAPABILITY_CFP_REQ(cap) ((cap) & 0x0008)
+#define CAPABILITY_PRIVACY(cap) ((cap) & 0x0010)
+
+struct ssid_t {
+ uint8_t element_id;
+ uint8_t length;
+ u_char ssid[33]; /* 32 + 1 for null */
+};
+
+struct rates_t {
+ uint8_t element_id;
+ uint8_t length;
+ uint8_t rate[16];
+};
+
+struct challenge_t {
+ uint8_t element_id;
+ uint8_t length;
+ uint8_t text[254]; /* 1-253 + 1 for null */
+};
+
+struct fh_t {
+ uint8_t element_id;
+ uint8_t length;
+ uint16_t dwell_time;
+ uint8_t hop_set;
+ uint8_t hop_pattern;
+ uint8_t hop_index;
+};
+
+struct ds_t {
+ uint8_t element_id;
+ uint8_t length;
+ uint8_t channel;
+};
+
+struct cf_t {
+ uint8_t element_id;
+ uint8_t length;
+ uint8_t count;
+ uint8_t period;
+ uint16_t max_duration;
+ uint16_t dur_remaing;
+};
+
+struct tim_t {
+ uint8_t element_id;
+ uint8_t length;
+ uint8_t count;
+ uint8_t period;
+ uint8_t bitmap_control;
+ uint8_t bitmap[251];
+};
+
+#define E_SSID 0
+#define E_RATES 1
+#define E_FH 2
+#define E_DS 3
+#define E_CF 4
+#define E_TIM 5
+#define E_IBSS 6
+/* reserved 7 */
+/* reserved 8 */
+/* reserved 9 */
+/* reserved 10 */
+/* reserved 11 */
+/* reserved 12 */
+/* reserved 13 */
+/* reserved 14 */
+/* reserved 15 */
+/* reserved 16 */
+
+#define E_CHALLENGE 16
+/* reserved 17 */
+/* reserved 18 */
+/* reserved 19 */
+/* reserved 16 */
+/* reserved 16 */
+
+
+struct mgmt_body_t {
+ uint8_t timestamp[IEEE802_11_TSTAMP_LEN];
+ uint16_t beacon_interval;
+ uint16_t listen_interval;
+ uint16_t status_code;
+ uint16_t aid;
+ u_char ap[IEEE802_11_AP_LEN];
+ uint16_t reason_code;
+ uint16_t auth_alg;
+ uint16_t auth_trans_seq_num;
+ int challenge_present;
+ struct challenge_t challenge;
+ uint16_t capability_info;
+ int ssid_present;
+ struct ssid_t ssid;
+ int rates_present;
+ struct rates_t rates;
+ int ds_present;
+ struct ds_t ds;
+ int cf_present;
+ struct cf_t cf;
+ int fh_present;
+ struct fh_t fh;
+ int tim_present;
+ struct tim_t tim;
+};
- u_int8_t rate;
+struct ctrl_control_wrapper_hdr_t {
+ uint16_t fc;
+ uint16_t duration;
+ uint8_t addr1[IEEE802_11_ADDR1_LEN];
+ uint16_t carried_fc[IEEE802_11_CARRIED_FC_LEN];
+ uint16_t ht_control[IEEE802_11_HT_CONTROL_LEN];
};
+#define CTRL_CONTROL_WRAPPER_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
+ IEEE802_11_ADDR1_LEN+\
+ IEEE802_11_CARRIED_FC_LEN+\
+ IEEE802_11_HT_CONTROL_LEN)
+
+struct ctrl_rts_hdr_t {
+ uint16_t fc;
+ uint16_t duration;
+ uint8_t ra[IEEE802_11_RA_LEN];
+ uint8_t ta[IEEE802_11_TA_LEN];
+};
+
+#define CTRL_RTS_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
+ IEEE802_11_RA_LEN+IEEE802_11_TA_LEN)
+
+struct ctrl_cts_hdr_t {
+ uint16_t fc;
+ uint16_t duration;
+ uint8_t ra[IEEE802_11_RA_LEN];
+};
+
+#define CTRL_CTS_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+IEEE802_11_RA_LEN)
+
+struct ctrl_ack_hdr_t {
+ uint16_t fc;
+ uint16_t duration;
+ uint8_t ra[IEEE802_11_RA_LEN];
+};
+
+#define CTRL_ACK_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+IEEE802_11_RA_LEN)
+
+struct ctrl_ps_poll_hdr_t {
+ uint16_t fc;
+ uint16_t aid;
+ uint8_t bssid[IEEE802_11_BSSID_LEN];
+ uint8_t ta[IEEE802_11_TA_LEN];
+};
+
+#define CTRL_PS_POLL_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_AID_LEN+\
+ IEEE802_11_BSSID_LEN+IEEE802_11_TA_LEN)
+
+struct ctrl_end_hdr_t {
+ uint16_t fc;
+ uint16_t duration;
+ uint8_t ra[IEEE802_11_RA_LEN];
+ uint8_t bssid[IEEE802_11_BSSID_LEN];
+};
+
+#define CTRL_END_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
+ IEEE802_11_RA_LEN+IEEE802_11_BSSID_LEN)
+
+struct ctrl_end_ack_hdr_t {
+ uint16_t fc;
+ uint16_t duration;
+ uint8_t ra[IEEE802_11_RA_LEN];
+ uint8_t bssid[IEEE802_11_BSSID_LEN];
+};
+
+#define CTRL_END_ACK_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
+ IEEE802_11_RA_LEN+IEEE802_11_BSSID_LEN)
+
+struct ctrl_ba_hdr_t {
+ uint16_t fc;
+ uint16_t duration;
+ uint8_t ra[IEEE802_11_RA_LEN];
+};
+
+#define CTRL_BA_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+IEEE802_11_RA_LEN)
+
+struct ctrl_bar_hdr_t {
+ uint16_t fc;
+ uint16_t dur;
+ uint8_t ra[IEEE802_11_RA_LEN];
+ uint8_t ta[IEEE802_11_TA_LEN];
+ uint16_t ctl;
+ uint16_t seq;
+};
+
+#define CTRL_BAR_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
+ IEEE802_11_RA_LEN+IEEE802_11_TA_LEN+\
+ IEEE802_11_CTL_LEN+IEEE802_11_SEQ_LEN)
+
+struct meshcntl_t {
+ uint8_t flags;
+ uint8_t ttl;
+ uint8_t seq[4];
+ uint8_t addr4[6];
+ uint8_t addr5[6];
+ uint8_t addr6[6];
+};
+
+#define IV_IV(iv) ((iv) & 0xFFFFFF)
+#define IV_PAD(iv) (((iv) >> 24) & 0x3F)
+#define IV_KEYID(iv) (((iv) >> 30) & 0x03)
+
#define PRINT_SSID(p) \
if (p.ssid_present) { \
- printf(" ("); \
- fn_print(p.ssid.ssid, NULL); \
- printf(")"); \
+ ND_PRINT((ndo, " (")); \
+ fn_print(ndo, p.ssid.ssid, NULL); \
+ ND_PRINT((ndo, ")")); \
}
#define PRINT_RATE(_sep, _r, _suf) \
- printf("%s%2.1f%s", _sep, (.5 * ((_r) & 0x7f)), _suf)
+ ND_PRINT((ndo, "%s%2.1f%s", _sep, (.5 * ((_r) & 0x7f)), _suf))
#define PRINT_RATES(p) \
if (p.rates_present) { \
int z; \
@@ -76,14 +423,14 @@ struct radiotap_state
sep = " "; \
} \
if (p.rates.length != 0) \
- printf(" Mbit]"); \
+ ND_PRINT((ndo, " Mbit]")); \
}
#define PRINT_DS_CHANNEL(p) \
if (p.ds_present) \
- printf(" CH: %u", p.ds.channel); \
- printf("%s", \
- CAPABILITY_PRIVACY(p.capability_info) ? ", PRIVACY" : "" );
+ ND_PRINT((ndo, " CH: %u", p.ds.channel)); \
+ ND_PRINT((ndo, "%s", \
+ CAPABILITY_PRIVACY(p.capability_info) ? ", PRIVACY" : ""));
#define MAX_MCS_INDEX 76
@@ -550,9 +897,7 @@ static const char *status_text[] = {
"The request has not been successful as one or more parameters "
"have invalid values", /* 38 */
"The TS has not been created because the request cannot be honored. "
- "However, a suggested TSPEC is provided so that the initiating QSTA"
- "may attempt to set another TS with the suggested changes to the "
- "TSPEC", /* 39 */
+ "Try again with the suggested changes to the TSPEC", /* 39 */
"Invalid Information Element", /* 40 */
"Group Cipher is not valid", /* 41 */
"Pairwise Cipher is not valid", /* 42 */
@@ -639,23 +984,25 @@ static const char *reason_text[] = {
#define NUM_REASONS (sizeof reason_text / sizeof reason_text[0])
static int
-wep_print(const u_char *p)
+wep_print(netdissect_options *ndo,
+ const u_char *p)
{
- u_int32_t iv;
+ uint32_t iv;
- if (!TTEST2(*p, IEEE802_11_IV_LEN + IEEE802_11_KID_LEN))
+ if (!ND_TTEST2(*p, IEEE802_11_IV_LEN + IEEE802_11_KID_LEN))
return 0;
iv = EXTRACT_LE_32BITS(p);
- printf("Data IV:%3x Pad %x KeyID %x", IV_IV(iv), IV_PAD(iv),
- IV_KEYID(iv));
+ ND_PRINT((ndo, " IV:%3x Pad %x KeyID %x", IV_IV(iv), IV_PAD(iv),
+ IV_KEYID(iv)));
return 1;
}
static int
-parse_elements(struct mgmt_body_t *pbody, const u_char *p, int offset,
- u_int length)
+parse_elements(netdissect_options *ndo,
+ struct mgmt_body_t *pbody, const u_char *p, int offset,
+ u_int length)
{
u_int elementlen;
struct ssid_t ssid;
@@ -676,23 +1023,28 @@ parse_elements(struct mgmt_body_t *pbody, const u_char *p, int offset,
pbody->tim_present = 0;
while (length != 0) {
- if (!TTEST2(*(p + offset), 1))
+ /* Make sure we at least have the element ID and length. */
+ if (!ND_TTEST2(*(p + offset), 2))
return 0;
- if (length < 1)
+ if (length < 2)
return 0;
+ elementlen = *(p + offset + 1);
+
+ /* Make sure we have the entire element. */
+ if (!ND_TTEST2(*(p + offset + 2), elementlen))
+ return 0;
+ if (length < elementlen + 2)
+ return 0;
+
switch (*(p + offset)) {
case E_SSID:
- if (!TTEST2(*(p + offset), 2))
- return 0;
- if (length < 2)
- return 0;
memcpy(&ssid, p + offset, 2);
offset += 2;
length -= 2;
if (ssid.length != 0) {
if (ssid.length > sizeof(ssid.ssid) - 1)
return 0;
- if (!TTEST2(*(p + offset), ssid.length))
+ if (!ND_TTEST2(*(p + offset), ssid.length))
return 0;
if (length < ssid.length)
return 0;
@@ -714,10 +1066,6 @@ parse_elements(struct mgmt_body_t *pbody, const u_char *p, int offset,
}
break;
case E_CHALLENGE:
- if (!TTEST2(*(p + offset), 2))
- return 0;
- if (length < 2)
- return 0;
memcpy(&challenge, p + offset, 2);
offset += 2;
length -= 2;
@@ -725,7 +1073,7 @@ parse_elements(struct mgmt_body_t *pbody, const u_char *p, int offset,
if (challenge.length >
sizeof(challenge.text) - 1)
return 0;
- if (!TTEST2(*(p + offset), challenge.length))
+ if (!ND_TTEST2(*(p + offset), challenge.length))
return 0;
if (length < challenge.length)
return 0;
@@ -748,17 +1096,13 @@ parse_elements(struct mgmt_body_t *pbody, const u_char *p, int offset,
}
break;
case E_RATES:
- if (!TTEST2(*(p + offset), 2))
- return 0;
- if (length < 2)
- return 0;
memcpy(&rates, p + offset, 2);
offset += 2;
length -= 2;
if (rates.length != 0) {
if (rates.length > sizeof rates.rate)
return 0;
- if (!TTEST2(*(p + offset), rates.length))
+ if (!ND_TTEST2(*(p + offset), rates.length))
return 0;
if (length < rates.length)
return 0;
@@ -788,13 +1132,17 @@ parse_elements(struct mgmt_body_t *pbody, const u_char *p, int offset,
}
break;
case E_DS:
- if (!TTEST2(*(p + offset), 3))
- return 0;
- if (length < 3)
- return 0;
- memcpy(&ds, p + offset, 3);
- offset += 3;
- length -= 3;
+ memcpy(&ds, p + offset, 2);
+ offset += 2;
+ length -= 2;
+ if (ds.length != 1) {
+ offset += ds.length;
+ length -= ds.length;
+ break;
+ }
+ ds.channel = *(p + offset);
+ offset += 1;
+ length -= 1;
/*
* Present and not truncated.
*
@@ -808,13 +1156,17 @@ parse_elements(struct mgmt_body_t *pbody, const u_char *p, int offset,
}
break;
case E_CF:
- if (!TTEST2(*(p + offset), 8))
- return 0;
- if (length < 8)
- return 0;
- memcpy(&cf, p + offset, 8);
- offset += 8;
- length -= 8;
+ memcpy(&cf, p + offset, 2);
+ offset += 2;
+ length -= 2;
+ if (cf.length != 6) {
+ offset += cf.length;
+ length -= cf.length;
+ break;
+ }
+ memcpy(&cf.count, p + offset, 6);
+ offset += 6;
+ length -= 6;
/*
* Present and not truncated.
*
@@ -828,29 +1180,20 @@ parse_elements(struct mgmt_body_t *pbody, const u_char *p, int offset,
}
break;
case E_TIM:
- if (!TTEST2(*(p + offset), 2))
- return 0;
- if (length < 2)
- return 0;
memcpy(&tim, p + offset, 2);
offset += 2;
length -= 2;
- if (!TTEST2(*(p + offset), 3))
- return 0;
- if (length < 3)
+ if (tim.length <= 3) {
+ offset += tim.length;
+ length -= tim.length;
+ break;
+ }
+ if (tim.length - 3 > (int)sizeof tim.bitmap)
return 0;
memcpy(&tim.count, p + offset, 3);
offset += 3;
length -= 3;
- if (tim.length <= 3)
- break;
- if (tim.length - 3 > (int)sizeof tim.bitmap)
- return 0;
- if (!TTEST2(*(p + offset), tim.length - 3))
- return 0;
- if (length < (u_int)(tim.length - 3))
- return 0;
memcpy(tim.bitmap, p + (tim.length - 3),
(tim.length - 3));
offset += tim.length - 3;
@@ -869,20 +1212,11 @@ parse_elements(struct mgmt_body_t *pbody, const u_char *p, int offset,
break;
default:
#if 0
- printf("(1) unhandled element_id (%d) ",
- *(p + offset));
+ ND_PRINT((ndo, "(1) unhandled element_id (%d) ",
+ *(p + offset)));
#endif
- if (!TTEST2(*(p + offset), 2))
- return 0;
- if (length < 2)
- return 0;
- elementlen = *(p + offset + 1);
- if (!TTEST2(*(p + offset + 2), elementlen))
- return 0;
- if (length < elementlen + 2)
- return 0;
- offset += elementlen + 2;
- length -= elementlen + 2;
+ offset += 2 + elementlen;
+ length -= 2 + elementlen;
break;
}
}
@@ -896,7 +1230,8 @@ parse_elements(struct mgmt_body_t *pbody, const u_char *p, int offset,
*********************************************************************************/
static int
-handle_beacon(const u_char *p, u_int length)
+handle_beacon(netdissect_options *ndo,
+ const u_char *p, u_int length)
{
struct mgmt_body_t pbody;
int offset = 0;
@@ -904,7 +1239,7 @@ handle_beacon(const u_char *p, u_int length)
memset(&pbody, 0, sizeof(pbody));
- if (!TTEST2(*p, IEEE802_11_TSTAMP_LEN + IEEE802_11_BCNINT_LEN +
+ if (!ND_TTEST2(*p, IEEE802_11_TSTAMP_LEN + IEEE802_11_BCNINT_LEN +
IEEE802_11_CAPINFO_LEN))
return 0;
if (length < IEEE802_11_TSTAMP_LEN + IEEE802_11_BCNINT_LEN +
@@ -920,19 +1255,20 @@ handle_beacon(const u_char *p, u_int length)
offset += IEEE802_11_CAPINFO_LEN;
length -= IEEE802_11_CAPINFO_LEN;
- ret = parse_elements(&pbody, p, offset, length);
+ ret = parse_elements(ndo, &pbody, p, offset, length);
PRINT_SSID(pbody);
PRINT_RATES(pbody);
- printf(" %s",
- CAPABILITY_ESS(pbody.capability_info) ? "ESS" : "IBSS");
+ ND_PRINT((ndo, " %s",
+ CAPABILITY_ESS(pbody.capability_info) ? "ESS" : "IBSS"));
PRINT_DS_CHANNEL(pbody);
return ret;
}
static int
-handle_assoc_request(const u_char *p, u_int length)
+handle_assoc_request(netdissect_options *ndo,
+ const u_char *p, u_int length)
{
struct mgmt_body_t pbody;
int offset = 0;
@@ -940,7 +1276,7 @@ handle_assoc_request(const u_char *p, u_int length)
memset(&pbody, 0, sizeof(pbody));
- if (!TTEST2(*p, IEEE802_11_CAPINFO_LEN + IEEE802_11_LISTENINT_LEN))
+ if (!ND_TTEST2(*p, IEEE802_11_CAPINFO_LEN + IEEE802_11_LISTENINT_LEN))
return 0;
if (length < IEEE802_11_CAPINFO_LEN + IEEE802_11_LISTENINT_LEN)
return 0;
@@ -951,7 +1287,7 @@ handle_assoc_request(const u_char *p, u_int length)
offset += IEEE802_11_LISTENINT_LEN;
length -= IEEE802_11_LISTENINT_LEN;
- ret = parse_elements(&pbody, p, offset, length);
+ ret = parse_elements(ndo, &pbody, p, offset, length);
PRINT_SSID(pbody);
PRINT_RATES(pbody);
@@ -959,7 +1295,8 @@ handle_assoc_request(const u_char *p, u_int length)
}
static int
-handle_assoc_response(const u_char *p, u_int length)
+handle_assoc_response(netdissect_options *ndo,
+ const u_char *p, u_int length)
{
struct mgmt_body_t pbody;
int offset = 0;
@@ -967,7 +1304,7 @@ handle_assoc_response(const u_char *p, u_int length)
memset(&pbody, 0, sizeof(pbody));
- if (!TTEST2(*p, IEEE802_11_CAPINFO_LEN + IEEE802_11_STATUS_LEN +
+ if (!ND_TTEST2(*p, IEEE802_11_CAPINFO_LEN + IEEE802_11_STATUS_LEN +
IEEE802_11_AID_LEN))
return 0;
if (length < IEEE802_11_CAPINFO_LEN + IEEE802_11_STATUS_LEN +
@@ -983,19 +1320,20 @@ handle_assoc_response(const u_char *p, u_int length)
offset += IEEE802_11_AID_LEN;
length -= IEEE802_11_AID_LEN;
- ret = parse_elements(&pbody, p, offset, length);
+ ret = parse_elements(ndo, &pbody, p, offset, length);
- printf(" AID(%x) :%s: %s", ((u_int16_t)(pbody.aid << 2 )) >> 2 ,
+ ND_PRINT((ndo, " AID(%x) :%s: %s", ((uint16_t)(pbody.aid << 2 )) >> 2 ,
CAPABILITY_PRIVACY(pbody.capability_info) ? " PRIVACY " : "",
(pbody.status_code < NUM_STATUSES
? status_text[pbody.status_code]
- : "n/a"));
+ : "n/a")));
return ret;
}
static int
-handle_reassoc_request(const u_char *p, u_int length)
+handle_reassoc_request(netdissect_options *ndo,
+ const u_char *p, u_int length)
{
struct mgmt_body_t pbody;
int offset = 0;
@@ -1003,7 +1341,7 @@ handle_reassoc_request(const u_char *p, u_int length)
memset(&pbody, 0, sizeof(pbody));
- if (!TTEST2(*p, IEEE802_11_CAPINFO_LEN + IEEE802_11_LISTENINT_LEN +
+ if (!ND_TTEST2(*p, IEEE802_11_CAPINFO_LEN + IEEE802_11_LISTENINT_LEN +
IEEE802_11_AP_LEN))
return 0;
if (length < IEEE802_11_CAPINFO_LEN + IEEE802_11_LISTENINT_LEN +
@@ -1019,23 +1357,25 @@ handle_reassoc_request(const u_char *p, u_int length)
offset += IEEE802_11_AP_LEN;
length -= IEEE802_11_AP_LEN;
- ret = parse_elements(&pbody, p, offset, length);
+ ret = parse_elements(ndo, &pbody, p, offset, length);
PRINT_SSID(pbody);
- printf(" AP : %s", etheraddr_string( pbody.ap ));
+ ND_PRINT((ndo, " AP : %s", etheraddr_string(ndo, pbody.ap )));
return ret;
}
static int
-handle_reassoc_response(const u_char *p, u_int length)
+handle_reassoc_response(netdissect_options *ndo,
+ const u_char *p, u_int length)
{
/* Same as a Association Reponse */
- return handle_assoc_response(p, length);
+ return handle_assoc_response(ndo, p, length);
}
static int
-handle_probe_request(const u_char *p, u_int length)
+handle_probe_request(netdissect_options *ndo,
+ const u_char *p, u_int length)
{
struct mgmt_body_t pbody;
int offset = 0;
@@ -1043,7 +1383,7 @@ handle_probe_request(const u_char *p, u_int length)
memset(&pbody, 0, sizeof(pbody));
- ret = parse_elements(&pbody, p, offset, length);
+ ret = parse_elements(ndo, &pbody, p, offset, length);
PRINT_SSID(pbody);
PRINT_RATES(pbody);
@@ -1052,7 +1392,8 @@ handle_probe_request(const u_char *p, u_int length)
}
static int
-handle_probe_response(const u_char *p, u_int length)
+handle_probe_response(netdissect_options *ndo,
+ const u_char *p, u_int length)
{
struct mgmt_body_t pbody;
int offset = 0;
@@ -1060,7 +1401,7 @@ handle_probe_response(const u_char *p, u_int length)
memset(&pbody, 0, sizeof(pbody));
- if (!TTEST2(*p, IEEE802_11_TSTAMP_LEN + IEEE802_11_BCNINT_LEN +
+ if (!ND_TTEST2(*p, IEEE802_11_TSTAMP_LEN + IEEE802_11_BCNINT_LEN +
IEEE802_11_CAPINFO_LEN))
return 0;
if (length < IEEE802_11_TSTAMP_LEN + IEEE802_11_BCNINT_LEN +
@@ -1076,7 +1417,7 @@ handle_probe_response(const u_char *p, u_int length)
offset += IEEE802_11_CAPINFO_LEN;
length -= IEEE802_11_CAPINFO_LEN;
- ret = parse_elements(&pbody, p, offset, length);
+ ret = parse_elements(ndo, &pbody, p, offset, length);
PRINT_SSID(pbody);
PRINT_RATES(pbody);
@@ -1093,28 +1434,30 @@ handle_atim(void)
}
static int
-handle_disassoc(const u_char *p, u_int length)
+handle_disassoc(netdissect_options *ndo,
+ const u_char *p, u_int length)
{
struct mgmt_body_t pbody;
memset(&pbody, 0, sizeof(pbody));
- if (!TTEST2(*p, IEEE802_11_REASON_LEN))
+ if (!ND_TTEST2(*p, IEEE802_11_REASON_LEN))
return 0;
if (length < IEEE802_11_REASON_LEN)
return 0;
pbody.reason_code = EXTRACT_LE_16BITS(p);
- printf(": %s",
+ ND_PRINT((ndo, ": %s",
(pbody.reason_code < NUM_REASONS)
? reason_text[pbody.reason_code]
- : "Reserved" );
+ : "Reserved"));
return 1;
}
static int
-handle_auth(const u_char *p, u_int length)
+handle_auth(netdissect_options *ndo,
+ const u_char *p, u_int length)
{
struct mgmt_body_t pbody;
int offset = 0;
@@ -1122,7 +1465,7 @@ handle_auth(const u_char *p, u_int length)
memset(&pbody, 0, sizeof(pbody));
- if (!TTEST2(*p, 6))
+ if (!ND_TTEST2(*p, 6))
return 0;
if (length < 6)
return 0;
@@ -1136,12 +1479,12 @@ handle_auth(const u_char *p, u_int length)
offset += 2;
length -= 2;
- ret = parse_elements(&pbody, p, offset, length);
+ ret = parse_elements(ndo, &pbody, p, offset, length);
if ((pbody.auth_alg == 1) &&
((pbody.auth_trans_seq_num == 2) ||
(pbody.auth_trans_seq_num == 3))) {
- printf(" (%s)-%x [Challenge Text] %s",
+ ND_PRINT((ndo, " (%s)-%x [Challenge Text] %s",
(pbody.auth_alg < NUM_AUTH_ALGS)
? auth_alg_text[pbody.auth_alg]
: "Reserved",
@@ -1149,10 +1492,10 @@ handle_auth(const u_char *p, u_int length)
((pbody.auth_trans_seq_num % 2)
? ((pbody.status_code < NUM_STATUSES)
? status_text[pbody.status_code]
- : "n/a") : ""));
+ : "n/a") : "")));
return ret;
}
- printf(" (%s)-%x: %s",
+ ND_PRINT((ndo, " (%s)-%x: %s",
(pbody.auth_alg < NUM_AUTH_ALGS)
? auth_alg_text[pbody.auth_alg]
: "Reserved",
@@ -1161,126 +1504,125 @@ handle_auth(const u_char *p, u_int length)
? ((pbody.status_code < NUM_STATUSES)
? status_text[pbody.status_code]
: "n/a")
- : "");
+ : ""));
return ret;
}
static int
-handle_deauth(const struct mgmt_header_t *pmh, const u_char *p, u_int length)
+handle_deauth(netdissect_options *ndo,
+ const uint8_t *src, const u_char *p, u_int length)
{
struct mgmt_body_t pbody;
- int offset = 0;
const char *reason = NULL;
memset(&pbody, 0, sizeof(pbody));
- if (!TTEST2(*p, IEEE802_11_REASON_LEN))
+ if (!ND_TTEST2(*p, IEEE802_11_REASON_LEN))
return 0;
if (length < IEEE802_11_REASON_LEN)
return 0;
pbody.reason_code = EXTRACT_LE_16BITS(p);
- offset += IEEE802_11_REASON_LEN;
- length -= IEEE802_11_REASON_LEN;
reason = (pbody.reason_code < NUM_REASONS)
? reason_text[pbody.reason_code]
: "Reserved";
- if (eflag) {
- printf(": %s", reason);
+ if (ndo->ndo_eflag) {
+ ND_PRINT((ndo, ": %s", reason));
} else {
- printf(" (%s): %s", etheraddr_string(pmh->sa), reason);
+ ND_PRINT((ndo, " (%s): %s", etheraddr_string(ndo, src), reason));
}
return 1;
}
#define PRINT_HT_ACTION(v) (\
- (v) == 0 ? printf("TxChWidth") : \
- (v) == 1 ? printf("MIMOPwrSave") : \
- printf("Act#%d", (v)) \
+ (v) == 0 ? ND_PRINT((ndo, "TxChWidth")) : \
+ (v) == 1 ? ND_PRINT((ndo, "MIMOPwrSave")) : \
+ ND_PRINT((ndo, "Act#%d", (v))) \
)
#define PRINT_BA_ACTION(v) (\
- (v) == 0 ? printf("ADDBA Request") : \
- (v) == 1 ? printf("ADDBA Response") : \
- (v) == 2 ? printf("DELBA") : \
- printf("Act#%d", (v)) \
+ (v) == 0 ? ND_PRINT((ndo, "ADDBA Request")) : \
+ (v) == 1 ? ND_PRINT((ndo, "ADDBA Response")) : \
+ (v) == 2 ? ND_PRINT((ndo, "DELBA")) : \
+ ND_PRINT((ndo, "Act#%d", (v))) \
)
#define PRINT_MESHLINK_ACTION(v) (\
- (v) == 0 ? printf("Request") : \
- (v) == 1 ? printf("Report") : \
- printf("Act#%d", (v)) \
+ (v) == 0 ? ND_PRINT((ndo, "Request")) : \
+ (v) == 1 ? ND_PRINT((ndo, "Report")) : \
+ ND_PRINT((ndo, "Act#%d", (v))) \
)
#define PRINT_MESHPEERING_ACTION(v) (\
- (v) == 0 ? printf("Open") : \
- (v) == 1 ? printf("Confirm") : \
- (v) == 2 ? printf("Close") : \
- printf("Act#%d", (v)) \
+ (v) == 0 ? ND_PRINT((ndo, "Open")) : \
+ (v) == 1 ? ND_PRINT((ndo, "Confirm")) : \
+ (v) == 2 ? ND_PRINT((ndo, "Close")) : \
+ ND_PRINT((ndo, "Act#%d", (v))) \
)
#define PRINT_MESHPATH_ACTION(v) (\
- (v) == 0 ? printf("Request") : \
- (v) == 1 ? printf("Report") : \
- (v) == 2 ? printf("Error") : \
- (v) == 3 ? printf("RootAnnouncement") : \
- printf("Act#%d", (v)) \
+ (v) == 0 ? ND_PRINT((ndo, "Request")) : \
+ (v) == 1 ? ND_PRINT((ndo, "Report")) : \
+ (v) == 2 ? ND_PRINT((ndo, "Error")) : \
+ (v) == 3 ? ND_PRINT((ndo, "RootAnnouncement")) : \
+ ND_PRINT((ndo, "Act#%d", (v))) \
)
#define PRINT_MESH_ACTION(v) (\
- (v) == 0 ? printf("MeshLink") : \
- (v) == 1 ? printf("HWMP") : \
- (v) == 2 ? printf("Gate Announcement") : \
- (v) == 3 ? printf("Congestion Control") : \
- (v) == 4 ? printf("MCCA Setup Request") : \
- (v) == 5 ? printf("MCCA Setup Reply") : \
- (v) == 6 ? printf("MCCA Advertisement Request") : \
- (v) == 7 ? printf("MCCA Advertisement") : \
- (v) == 8 ? printf("MCCA Teardown") : \
- (v) == 9 ? printf("TBTT Adjustment Request") : \
- (v) == 10 ? printf("TBTT Adjustment Response") : \
- printf("Act#%d", (v)) \
+ (v) == 0 ? ND_PRINT((ndo, "MeshLink")) : \
+ (v) == 1 ? ND_PRINT((ndo, "HWMP")) : \
+ (v) == 2 ? ND_PRINT((ndo, "Gate Announcement")) : \
+ (v) == 3 ? ND_PRINT((ndo, "Congestion Control")) : \
+ (v) == 4 ? ND_PRINT((ndo, "MCCA Setup Request")) : \
+ (v) == 5 ? ND_PRINT((ndo, "MCCA Setup Reply")) : \
+ (v) == 6 ? ND_PRINT((ndo, "MCCA Advertisement Request")) : \
+ (v) == 7 ? ND_PRINT((ndo, "MCCA Advertisement")) : \
+ (v) == 8 ? ND_PRINT((ndo, "MCCA Teardown")) : \
+ (v) == 9 ? ND_PRINT((ndo, "TBTT Adjustment Request")) : \
+ (v) == 10 ? ND_PRINT((ndo, "TBTT Adjustment Response")) : \
+ ND_PRINT((ndo, "Act#%d", (v))) \
)
#define PRINT_MULTIHOP_ACTION(v) (\
- (v) == 0 ? printf("Proxy Update") : \
- (v) == 1 ? printf("Proxy Update Confirmation") : \
- printf("Act#%d", (v)) \
+ (v) == 0 ? ND_PRINT((ndo, "Proxy Update")) : \
+ (v) == 1 ? ND_PRINT((ndo, "Proxy Update Confirmation")) : \
+ ND_PRINT((ndo, "Act#%d", (v))) \
)
#define PRINT_SELFPROT_ACTION(v) (\
- (v) == 1 ? printf("Peering Open") : \
- (v) == 2 ? printf("Peering Confirm") : \
- (v) == 3 ? printf("Peering Close") : \
- (v) == 4 ? printf("Group Key Inform") : \
- (v) == 5 ? printf("Group Key Acknowledge") : \
- printf("Act#%d", (v)) \
+ (v) == 1 ? ND_PRINT((ndo, "Peering Open")) : \
+ (v) == 2 ? ND_PRINT((ndo, "Peering Confirm")) : \
+ (v) == 3 ? ND_PRINT((ndo, "Peering Close")) : \
+ (v) == 4 ? ND_PRINT((ndo, "Group Key Inform")) : \
+ (v) == 5 ? ND_PRINT((ndo, "Group Key Acknowledge")) : \
+ ND_PRINT((ndo, "Act#%d", (v))) \
)
static int
-handle_action(const struct mgmt_header_t *pmh, const u_char *p, u_int length)
+handle_action(netdissect_options *ndo,
+ const uint8_t *src, const u_char *p, u_int length)
{
- if (!TTEST2(*p, 2))
+ if (!ND_TTEST2(*p, 2))
return 0;
if (length < 2)
return 0;
- if (eflag) {
- printf(": ");
+ if (ndo->ndo_eflag) {
+ ND_PRINT((ndo, ": "));
} else {
- printf(" (%s): ", etheraddr_string(pmh->sa));
+ ND_PRINT((ndo, " (%s): ", etheraddr_string(ndo, src)));
}
switch (p[0]) {
- case 0: printf("Spectrum Management Act#%d", p[1]); break;
- case 1: printf("QoS Act#%d", p[1]); break;
- case 2: printf("DLS Act#%d", p[1]); break;
- case 3: printf("BA "); PRINT_BA_ACTION(p[1]); break;
- case 7: printf("HT "); PRINT_HT_ACTION(p[1]); break;
- case 13: printf("MeshAction "); PRINT_MESH_ACTION(p[1]); break;
+ case 0: ND_PRINT((ndo, "Spectrum Management Act#%d", p[1])); break;
+ case 1: ND_PRINT((ndo, "QoS Act#%d", p[1])); break;
+ case 2: ND_PRINT((ndo, "DLS Act#%d", p[1])); break;
+ case 3: ND_PRINT((ndo, "BA ")); PRINT_BA_ACTION(p[1]); break;
+ case 7: ND_PRINT((ndo, "HT ")); PRINT_HT_ACTION(p[1]); break;
+ case 13: ND_PRINT((ndo, "MeshAction ")); PRINT_MESH_ACTION(p[1]); break;
case 14:
- printf("MultiohopAction ");
+ ND_PRINT((ndo, "MultiohopAction "));
PRINT_MULTIHOP_ACTION(p[1]); break;
case 15:
- printf("SelfprotectAction ");
+ ND_PRINT((ndo, "SelfprotectAction "));
PRINT_SELFPROT_ACTION(p[1]); break;
- case 127: printf("Vendor Act#%d", p[1]); break;
+ case 127: ND_PRINT((ndo, "Vendor Act#%d", p[1])); break;
default:
- printf("Reserved(%d) Act#%d", p[0], p[1]);
+ ND_PRINT((ndo, "Reserved(%d) Act#%d", p[0], p[1]));
break;
}
return 1;
@@ -1293,57 +1635,40 @@ handle_action(const struct mgmt_header_t *pmh, const u_char *p, u_int length)
static int
-mgmt_body_print(u_int16_t fc, const struct mgmt_header_t *pmh,
- const u_char *p, u_int length)
+mgmt_body_print(netdissect_options *ndo,
+ uint16_t fc, const uint8_t *src, const u_char *p, u_int length)
{
+ ND_PRINT((ndo, "%s", tok2str(st_str, "Unhandled Management subtype(%x)", FC_SUBTYPE(fc))));
+
+ /* There may be a problem w/ AP not having this bit set */
+ if (FC_PROTECTED(fc))
+ return wep_print(ndo, p);
switch (FC_SUBTYPE(fc)) {
case ST_ASSOC_REQUEST:
- printf("Assoc Request");
- return handle_assoc_request(p, length);
+ return handle_assoc_request(ndo, p, length);
case ST_ASSOC_RESPONSE:
- printf("Assoc Response");
- return handle_assoc_response(p, length);
+ return handle_assoc_response(ndo, p, length);
case ST_REASSOC_REQUEST:
- printf("ReAssoc Request");
- return handle_reassoc_request(p, length);
+ return handle_reassoc_request(ndo, p, length);
case ST_REASSOC_RESPONSE:
- printf("ReAssoc Response");
- return handle_reassoc_response(p, length);
+ return handle_reassoc_response(ndo, p, length);
case ST_PROBE_REQUEST:
- printf("Probe Request");
- return handle_probe_request(p, length);
+ return handle_probe_request(ndo, p, length);
case ST_PROBE_RESPONSE:
- printf("Probe Response");
- return handle_probe_response(p, length);
+ return handle_probe_response(ndo, p, length);
case ST_BEACON:
- printf("Beacon");
- return handle_beacon(p, length);
+ return handle_beacon(ndo, p, length);
case ST_ATIM:
- printf("ATIM");
return handle_atim();
case ST_DISASSOC:
- printf("Disassociation");
- return handle_disassoc(p, length);
+ return handle_disassoc(ndo, p, length);
case ST_AUTH:
- printf("Authentication");
- if (!TTEST2(*p, 3))
- return 0;
- if ((p[0] == 0 ) && (p[1] == 0) && (p[2] == 0)) {
- printf("Authentication (Shared-Key)-3 ");
- return wep_print(p);
- }
- return handle_auth(p, length);
+ return handle_auth(ndo, p, length);
case ST_DEAUTH:
- printf("DeAuthentication");
- return handle_deauth(pmh, p, length);
- break;
+ return handle_deauth(ndo, src, p, length);
case ST_ACTION:
- printf("Action");
- return handle_action(pmh, p, length);
- break;
+ return handle_action(ndo, src, p, length);
default:
- printf("Unhandled Management subtype(%x)",
- FC_SUBTYPE(fc));
return 1;
}
}
@@ -1354,90 +1679,77 @@ mgmt_body_print(u_int16_t fc, const struct mgmt_header_t *pmh,
*********************************************************************************/
static int
-ctrl_body_print(u_int16_t fc, const u_char *p)
+ctrl_body_print(netdissect_options *ndo,
+ uint16_t fc, const u_char *p)
{
+ ND_PRINT((ndo, "%s", tok2str(ctrl_str, "Unknown Ctrl Subtype", FC_SUBTYPE(fc))));
switch (FC_SUBTYPE(fc)) {
case CTRL_CONTROL_WRAPPER:
- printf("Control Wrapper");
/* XXX - requires special handling */
break;
case CTRL_BAR:
- printf("BAR");
- if (!TTEST2(*p, CTRL_BAR_HDRLEN))
+ if (!ND_TTEST2(*p, CTRL_BAR_HDRLEN))
return 0;
- if (!eflag)
- printf(" RA:%s TA:%s CTL(%x) SEQ(%u) ",
- etheraddr_string(((const struct ctrl_bar_t *)p)->ra),
- etheraddr_string(((const struct ctrl_bar_t *)p)->ta),
- EXTRACT_LE_16BITS(&(((const struct ctrl_bar_t *)p)->ctl)),
- EXTRACT_LE_16BITS(&(((const struct ctrl_bar_t *)p)->seq)));
+ if (!ndo->ndo_eflag)
+ ND_PRINT((ndo, " RA:%s TA:%s CTL(%x) SEQ(%u) ",
+ etheraddr_string(ndo, ((const struct ctrl_bar_hdr_t *)p)->ra),
+ etheraddr_string(ndo, ((const struct ctrl_bar_hdr_t *)p)->ta),
+ EXTRACT_LE_16BITS(&(((const struct ctrl_bar_hdr_t *)p)->ctl)),
+ EXTRACT_LE_16BITS(&(((const struct ctrl_bar_hdr_t *)p)->seq))));
break;
case CTRL_BA:
- printf("BA");
- if (!TTEST2(*p, CTRL_BA_HDRLEN))
+ if (!ND_TTEST2(*p, CTRL_BA_HDRLEN))
return 0;
- if (!eflag)
- printf(" RA:%s ",
- etheraddr_string(((const struct ctrl_ba_t *)p)->ra));
+ if (!ndo->ndo_eflag)
+ ND_PRINT((ndo, " RA:%s ",
+ etheraddr_string(ndo, ((const struct ctrl_ba_hdr_t *)p)->ra)));
break;
case CTRL_PS_POLL:
- printf("Power Save-Poll");
- if (!TTEST2(*p, CTRL_PS_POLL_HDRLEN))
+ if (!ND_TTEST2(*p, CTRL_PS_POLL_HDRLEN))
return 0;
- printf(" AID(%x)",
- EXTRACT_LE_16BITS(&(((const struct ctrl_ps_poll_t *)p)->aid)));
+ ND_PRINT((ndo, " AID(%x)",
+ EXTRACT_LE_16BITS(&(((const struct ctrl_ps_poll_hdr_t *)p)->aid))));
break;
case CTRL_RTS:
- printf("Request-To-Send");
- if (!TTEST2(*p, CTRL_RTS_HDRLEN))
+ if (!ND_TTEST2(*p, CTRL_RTS_HDRLEN))
return 0;
- if (!eflag)
- printf(" TA:%s ",
- etheraddr_string(((const struct ctrl_rts_t *)p)->ta));
+ if (!ndo->ndo_eflag)
+ ND_PRINT((ndo, " TA:%s ",
+ etheraddr_string(ndo, ((const struct ctrl_rts_hdr_t *)p)->ta)));
break;
case CTRL_CTS:
- printf("Clear-To-Send");
- if (!TTEST2(*p, CTRL_CTS_HDRLEN))
+ if (!ND_TTEST2(*p, CTRL_CTS_HDRLEN))
return 0;
- if (!eflag)
- printf(" RA:%s ",
- etheraddr_string(((const struct ctrl_cts_t *)p)->ra));
+ if (!ndo->ndo_eflag)
+ ND_PRINT((ndo, " RA:%s ",
+ etheraddr_string(ndo, ((const struct ctrl_cts_hdr_t *)p)->ra)));
break;
case CTRL_ACK:
- printf("Acknowledgment");
- if (!TTEST2(*p, CTRL_ACK_HDRLEN))
+ if (!ND_TTEST2(*p, CTRL_ACK_HDRLEN))
return 0;
- if (!eflag)
- printf(" RA:%s ",
- etheraddr_string(((const struct ctrl_ack_t *)p)->ra));
+ if (!ndo->ndo_eflag)
+ ND_PRINT((ndo, " RA:%s ",
+ etheraddr_string(ndo, ((const struct ctrl_ack_hdr_t *)p)->ra)));
break;
case CTRL_CF_END:
- printf("CF-End");
- if (!TTEST2(*p, CTRL_END_HDRLEN))
+ if (!ND_TTEST2(*p, CTRL_END_HDRLEN))
return 0;
- if (!eflag)
- printf(" RA:%s ",
- etheraddr_string(((const struct ctrl_end_t *)p)->ra));
+ if (!ndo->ndo_eflag)
+ ND_PRINT((ndo, " RA:%s ",
+ etheraddr_string(ndo, ((const struct ctrl_end_hdr_t *)p)->ra)));
break;
case CTRL_END_ACK:
- printf("CF-End+CF-Ack");
- if (!TTEST2(*p, CTRL_END_ACK_HDRLEN))
+ if (!ND_TTEST2(*p, CTRL_END_ACK_HDRLEN))
return 0;
- if (!eflag)
- printf(" RA:%s ",
- etheraddr_string(((const struct ctrl_end_ack_t *)p)->ra));
+ if (!ndo->ndo_eflag)
+ ND_PRINT((ndo, " RA:%s ",
+ etheraddr_string(ndo, ((const struct ctrl_end_ack_hdr_t *)p)->ra)));
break;
- default:
- printf("Unknown Ctrl Subtype");
}
return 1;
}
/*
- * Print Header funcs
- */
-
-/*
* Data Frame - Address field contents
*
* To Ds | From DS | Addr 1 | Addr 2 | Addr 3 | Addr 4
@@ -1447,27 +1759,81 @@ ctrl_body_print(u_int16_t fc, const u_char *p)
* 1 | 1 | RA | TA | DA | SA
*/
+/*
+ * Function to get source and destination MAC addresses for a data frame.
+ */
static void
-data_header_print(u_int16_t fc, const u_char *p, const u_int8_t **srcp,
- const u_int8_t **dstp)
+get_data_src_dst_mac(uint16_t fc, const u_char *p, const uint8_t **srcp,
+ const uint8_t **dstp)
+{
+#define ADDR1 (p + 4)
+#define ADDR2 (p + 10)
+#define ADDR3 (p + 16)
+#define ADDR4 (p + 24)
+
+ if (!FC_TO_DS(fc)) {
+ if (!FC_FROM_DS(fc)) {
+ /* not To DS and not From DS */
+ *srcp = ADDR2;
+ *dstp = ADDR1;
+ } else {
+ /* not To DS and From DS */
+ *srcp = ADDR3;
+ *dstp = ADDR1;
+ }
+ } else {
+ if (!FC_FROM_DS(fc)) {
+ /* From DS and not To DS */
+ *srcp = ADDR2;
+ *dstp = ADDR3;
+ } else {
+ /* To DS and From DS */
+ *srcp = ADDR4;
+ *dstp = ADDR3;
+ }
+ }
+
+#undef ADDR1
+#undef ADDR2
+#undef ADDR3
+#undef ADDR4
+}
+
+static void
+get_mgmt_src_dst_mac(const u_char *p, const uint8_t **srcp, const uint8_t **dstp)
+{
+ const struct mgmt_header_t *hp = (const struct mgmt_header_t *) p;
+
+ if (srcp != NULL)
+ *srcp = hp->sa;
+ if (dstp != NULL)
+ *dstp = hp->da;
+}
+
+/*
+ * Print Header funcs
+ */
+
+static void
+data_header_print(netdissect_options *ndo, uint16_t fc, const u_char *p)
{
u_int subtype = FC_SUBTYPE(fc);
if (DATA_FRAME_IS_CF_ACK(subtype) || DATA_FRAME_IS_CF_POLL(subtype) ||
DATA_FRAME_IS_QOS(subtype)) {
- printf("CF ");
+ ND_PRINT((ndo, "CF "));
if (DATA_FRAME_IS_CF_ACK(subtype)) {
if (DATA_FRAME_IS_CF_POLL(subtype))
- printf("Ack/Poll");
+ ND_PRINT((ndo, "Ack/Poll"));
else
- printf("Ack");
+ ND_PRINT((ndo, "Ack"));
} else {
if (DATA_FRAME_IS_CF_POLL(subtype))
- printf("Poll");
+ ND_PRINT((ndo, "Poll"));
}
if (DATA_FRAME_IS_QOS(subtype))
- printf("+QoS");
- printf(" ");
+ ND_PRINT((ndo, "+QoS"));
+ ND_PRINT((ndo, " "));
}
#define ADDR1 (p + 4)
@@ -1476,45 +1842,21 @@ data_header_print(u_int16_t fc, const u_char *p, const u_int8_t **srcp,
#define ADDR4 (p + 24)
if (!FC_TO_DS(fc) && !FC_FROM_DS(fc)) {
- if (srcp != NULL)
- *srcp = ADDR2;
- if (dstp != NULL)
- *dstp = ADDR1;
- if (!eflag)
- return;
- printf("DA:%s SA:%s BSSID:%s ",
- etheraddr_string(ADDR1), etheraddr_string(ADDR2),
- etheraddr_string(ADDR3));
+ ND_PRINT((ndo, "DA:%s SA:%s BSSID:%s ",
+ etheraddr_string(ndo, ADDR1), etheraddr_string(ndo, ADDR2),
+ etheraddr_string(ndo, ADDR3)));
} else if (!FC_TO_DS(fc) && FC_FROM_DS(fc)) {
- if (srcp != NULL)
- *srcp = ADDR3;
- if (dstp != NULL)
- *dstp = ADDR1;
- if (!eflag)
- return;
- printf("DA:%s BSSID:%s SA:%s ",
- etheraddr_string(ADDR1), etheraddr_string(ADDR2),
- etheraddr_string(ADDR3));
+ ND_PRINT((ndo, "DA:%s BSSID:%s SA:%s ",
+ etheraddr_string(ndo, ADDR1), etheraddr_string(ndo, ADDR2),
+ etheraddr_string(ndo, ADDR3)));
} else if (FC_TO_DS(fc) && !FC_FROM_DS(fc)) {
- if (srcp != NULL)
- *srcp = ADDR2;
- if (dstp != NULL)
- *dstp = ADDR3;
- if (!eflag)
- return;
- printf("BSSID:%s SA:%s DA:%s ",
- etheraddr_string(ADDR1), etheraddr_string(ADDR2),
- etheraddr_string(ADDR3));
+ ND_PRINT((ndo, "BSSID:%s SA:%s DA:%s ",
+ etheraddr_string(ndo, ADDR1), etheraddr_string(ndo, ADDR2),
+ etheraddr_string(ndo, ADDR3)));
} else if (FC_TO_DS(fc) && FC_FROM_DS(fc)) {
- if (srcp != NULL)
- *srcp = ADDR4;
- if (dstp != NULL)
- *dstp = ADDR3;
- if (!eflag)
- return;
- printf("RA:%s TA:%s DA:%s SA:%s ",
- etheraddr_string(ADDR1), etheraddr_string(ADDR2),
- etheraddr_string(ADDR3), etheraddr_string(ADDR4));
+ ND_PRINT((ndo, "RA:%s TA:%s DA:%s SA:%s ",
+ etheraddr_string(ndo, ADDR1), etheraddr_string(ndo, ADDR2),
+ etheraddr_string(ndo, ADDR3), etheraddr_string(ndo, ADDR4)));
}
#undef ADDR1
@@ -1524,82 +1866,67 @@ data_header_print(u_int16_t fc, const u_char *p, const u_int8_t **srcp,
}
static void
-mgmt_header_print(const u_char *p, const u_int8_t **srcp,
- const u_int8_t **dstp)
+mgmt_header_print(netdissect_options *ndo, const u_char *p)
{
const struct mgmt_header_t *hp = (const struct mgmt_header_t *) p;
- if (srcp != NULL)
- *srcp = hp->sa;
- if (dstp != NULL)
- *dstp = hp->da;
- if (!eflag)
- return;
-
- printf("BSSID:%s DA:%s SA:%s ",
- etheraddr_string((hp)->bssid), etheraddr_string((hp)->da),
- etheraddr_string((hp)->sa));
+ ND_PRINT((ndo, "BSSID:%s DA:%s SA:%s ",
+ etheraddr_string(ndo, (hp)->bssid), etheraddr_string(ndo, (hp)->da),
+ etheraddr_string(ndo, (hp)->sa)));
}
static void
-ctrl_header_print(u_int16_t fc, const u_char *p, const u_int8_t **srcp,
- const u_int8_t **dstp)
+ctrl_header_print(netdissect_options *ndo, uint16_t fc, const u_char *p)
{
- if (srcp != NULL)
- *srcp = NULL;
- if (dstp != NULL)
- *dstp = NULL;
- if (!eflag)
- return;
-
switch (FC_SUBTYPE(fc)) {
case CTRL_BAR:
- printf(" RA:%s TA:%s CTL(%x) SEQ(%u) ",
- etheraddr_string(((const struct ctrl_bar_t *)p)->ra),
- etheraddr_string(((const struct ctrl_bar_t *)p)->ta),
- EXTRACT_LE_16BITS(&(((const struct ctrl_bar_t *)p)->ctl)),
- EXTRACT_LE_16BITS(&(((const struct ctrl_bar_t *)p)->seq)));
+ ND_PRINT((ndo, " RA:%s TA:%s CTL(%x) SEQ(%u) ",
+ etheraddr_string(ndo, ((const struct ctrl_bar_hdr_t *)p)->ra),
+ etheraddr_string(ndo, ((const struct ctrl_bar_hdr_t *)p)->ta),
+ EXTRACT_LE_16BITS(&(((const struct ctrl_bar_hdr_t *)p)->ctl)),
+ EXTRACT_LE_16BITS(&(((const struct ctrl_bar_hdr_t *)p)->seq))));
break;
case CTRL_BA:
- printf("RA:%s ",
- etheraddr_string(((const struct ctrl_ba_t *)p)->ra));
+ ND_PRINT((ndo, "RA:%s ",
+ etheraddr_string(ndo, ((const struct ctrl_ba_hdr_t *)p)->ra)));
break;
case CTRL_PS_POLL:
- printf("BSSID:%s TA:%s ",
- etheraddr_string(((const struct ctrl_ps_poll_t *)p)->bssid),
- etheraddr_string(((const struct ctrl_ps_poll_t *)p)->ta));
+ ND_PRINT((ndo, "BSSID:%s TA:%s ",
+ etheraddr_string(ndo, ((const struct ctrl_ps_poll_hdr_t *)p)->bssid),
+ etheraddr_string(ndo, ((const struct ctrl_ps_poll_hdr_t *)p)->ta)));
break;
case CTRL_RTS:
- printf("RA:%s TA:%s ",
- etheraddr_string(((const struct ctrl_rts_t *)p)->ra),
- etheraddr_string(((const struct ctrl_rts_t *)p)->ta));
+ ND_PRINT((ndo, "RA:%s TA:%s ",
+ etheraddr_string(ndo, ((const struct ctrl_rts_hdr_t *)p)->ra),
+ etheraddr_string(ndo, ((const struct ctrl_rts_hdr_t *)p)->ta)));
break;
case CTRL_CTS:
- printf("RA:%s ",
- etheraddr_string(((const struct ctrl_cts_t *)p)->ra));
+ ND_PRINT((ndo, "RA:%s ",
+ etheraddr_string(ndo, ((const struct ctrl_cts_hdr_t *)p)->ra)));
break;
case CTRL_ACK:
- printf("RA:%s ",
- etheraddr_string(((const struct ctrl_ack_t *)p)->ra));
+ ND_PRINT((ndo, "RA:%s ",
+ etheraddr_string(ndo, ((const struct ctrl_ack_hdr_t *)p)->ra)));
break;
case CTRL_CF_END:
- printf("RA:%s BSSID:%s ",
- etheraddr_string(((const struct ctrl_end_t *)p)->ra),
- etheraddr_string(((const struct ctrl_end_t *)p)->bssid));
+ ND_PRINT((ndo, "RA:%s BSSID:%s ",
+ etheraddr_string(ndo, ((const struct ctrl_end_hdr_t *)p)->ra),
+ etheraddr_string(ndo, ((const struct ctrl_end_hdr_t *)p)->bssid)));
break;
case CTRL_END_ACK:
- printf("RA:%s BSSID:%s ",
- etheraddr_string(((const struct ctrl_end_ack_t *)p)->ra),
- etheraddr_string(((const struct ctrl_end_ack_t *)p)->bssid));
+ ND_PRINT((ndo, "RA:%s BSSID:%s ",
+ etheraddr_string(ndo, ((const struct ctrl_end_ack_hdr_t *)p)->ra),
+ etheraddr_string(ndo, ((const struct ctrl_end_ack_hdr_t *)p)->bssid)));
break;
default:
- printf("(H) Unknown Ctrl Subtype");
+ /* We shouldn't get here - we should already have quit */
break;
}
}
static int
-extract_header_length(u_int16_t fc)
+extract_header_length(netdissect_options *ndo,
+ uint16_t fc)
{
int len;
@@ -1608,8 +1935,12 @@ extract_header_length(u_int16_t fc)
return MGMT_HDRLEN;
case T_CTRL:
switch (FC_SUBTYPE(fc)) {
+ case CTRL_CONTROL_WRAPPER:
+ return CTRL_CONTROL_WRAPPER_HDRLEN;
case CTRL_BAR:
return CTRL_BAR_HDRLEN;
+ case CTRL_BA:
+ return CTRL_BA_HDRLEN;
case CTRL_PS_POLL:
return CTRL_PS_POLL_HDRLEN;
case CTRL_RTS:
@@ -1623,6 +1954,7 @@ extract_header_length(u_int16_t fc)
case CTRL_END_ACK:
return CTRL_END_ACK_HDRLEN;
default:
+ ND_PRINT((ndo, "unknown 802.11 ctrl frame subtype (%d)", FC_SUBTYPE(fc)));
return 0;
}
case T_DATA:
@@ -1631,7 +1963,7 @@ extract_header_length(u_int16_t fc)
len += 2;
return len;
default:
- printf("unknown IEEE802.11 frame type (%d)", FC_TYPE(fc));
+ ND_PRINT((ndo, "unknown 802.11 frame type (%d)", FC_TYPE(fc)));
return 0;
}
}
@@ -1643,63 +1975,58 @@ extract_mesh_header_length(const u_char *p)
}
/*
- * Print the 802.11 MAC header if eflag is set, and set "*srcp" and "*dstp"
- * to point to the source and destination MAC addresses in any case if
- * "srcp" and "dstp" aren't null.
+ * Print the 802.11 MAC header.
*/
static void
-ieee_802_11_hdr_print(u_int16_t fc, const u_char *p, u_int hdrlen,
- u_int meshdrlen, const u_int8_t **srcp, const u_int8_t **dstp)
+ieee_802_11_hdr_print(netdissect_options *ndo,
+ uint16_t fc, const u_char *p, u_int hdrlen,
+ u_int meshdrlen)
{
- if (vflag) {
+ if (ndo->ndo_vflag) {
if (FC_MORE_DATA(fc))
- printf("More Data ");
+ ND_PRINT((ndo, "More Data "));
if (FC_MORE_FLAG(fc))
- printf("More Fragments ");
+ ND_PRINT((ndo, "More Fragments "));
if (FC_POWER_MGMT(fc))
- printf("Pwr Mgmt ");
+ ND_PRINT((ndo, "Pwr Mgmt "));
if (FC_RETRY(fc))
- printf("Retry ");
+ ND_PRINT((ndo, "Retry "));
if (FC_ORDER(fc))
- printf("Strictly Ordered ");
- if (FC_WEP(fc))
- printf("WEP Encrypted ");
+ ND_PRINT((ndo, "Strictly Ordered "));
+ if (FC_PROTECTED(fc))
+ ND_PRINT((ndo, "Protected "));
if (FC_TYPE(fc) != T_CTRL || FC_SUBTYPE(fc) != CTRL_PS_POLL)
- printf("%dus ",
+ ND_PRINT((ndo, "%dus ",
EXTRACT_LE_16BITS(
- &((const struct mgmt_header_t *)p)->duration));
+ &((const struct mgmt_header_t *)p)->duration)));
}
if (meshdrlen != 0) {
const struct meshcntl_t *mc =
(const struct meshcntl_t *)&p[hdrlen - meshdrlen];
int ae = mc->flags & 3;
- printf("MeshData (AE %d TTL %u seq %u", ae, mc->ttl,
- EXTRACT_LE_32BITS(mc->seq));
+ ND_PRINT((ndo, "MeshData (AE %d TTL %u seq %u", ae, mc->ttl,
+ EXTRACT_LE_32BITS(mc->seq)));
if (ae > 0)
- printf(" A4:%s", etheraddr_string(mc->addr4));
+ ND_PRINT((ndo, " A4:%s", etheraddr_string(ndo, mc->addr4)));
if (ae > 1)
- printf(" A5:%s", etheraddr_string(mc->addr5));
+ ND_PRINT((ndo, " A5:%s", etheraddr_string(ndo, mc->addr5)));
if (ae > 2)
- printf(" A6:%s", etheraddr_string(mc->addr6));
- printf(") ");
+ ND_PRINT((ndo, " A6:%s", etheraddr_string(ndo, mc->addr6)));
+ ND_PRINT((ndo, ") "));
}
switch (FC_TYPE(fc)) {
case T_MGMT:
- mgmt_header_print(p, srcp, dstp);
+ mgmt_header_print(ndo, p);
break;
case T_CTRL:
- ctrl_header_print(fc, p, srcp, dstp);
+ ctrl_header_print(ndo, fc, p);
break;
case T_DATA:
- data_header_print(fc, p, srcp, dstp);
+ data_header_print(ndo, fc, p);
break;
default:
- printf("(header) unknown IEEE802.11 frame type (%d)",
- FC_TYPE(fc));
- *srcp = NULL;
- *dstp = NULL;
break;
}
}
@@ -1708,19 +2035,22 @@ ieee_802_11_hdr_print(u_int16_t fc, const u_char *p, u_int hdrlen,
#define roundup2(x, y) (((x)+((y)-1))&(~((y)-1))) /* if y is powers of two */
#endif
+static const char tstr[] = "[|802.11]";
+
static u_int
-ieee802_11_print(const u_char *p, u_int length, u_int orig_caplen, int pad,
- u_int fcslen)
+ieee802_11_print(netdissect_options *ndo,
+ const u_char *p, u_int length, u_int orig_caplen, int pad,
+ u_int fcslen)
{
- u_int16_t fc;
+ uint16_t fc;
u_int caplen, hdrlen, meshdrlen;
- const u_int8_t *src, *dst;
- u_short extracted_ethertype;
+ struct lladdr_info src, dst;
+ int llc_hdrlen;
caplen = orig_caplen;
/* Remove FCS, if present */
if (length < fcslen) {
- printf("[|802.11]");
+ ND_PRINT((ndo, "%s", tstr));
return caplen;
}
length -= fcslen;
@@ -1728,32 +2058,36 @@ ieee802_11_print(const u_char *p, u_int length, u_int orig_caplen, int pad,
/* Amount of FCS in actual packet data, if any */
fcslen = caplen - length;
caplen -= fcslen;
- snapend -= fcslen;
+ ndo->ndo_snapend -= fcslen;
}
if (caplen < IEEE802_11_FC_LEN) {
- printf("[|802.11]");
+ ND_PRINT((ndo, "%s", tstr));
return orig_caplen;
}
fc = EXTRACT_LE_16BITS(p);
- hdrlen = extract_header_length(fc);
+ hdrlen = extract_header_length(ndo, fc);
+ if (hdrlen == 0) {
+ /* Unknown frame type or control frame subtype; quit. */
+ return (0);
+ }
if (pad)
hdrlen = roundup2(hdrlen, 4);
- if (Hflag && FC_TYPE(fc) == T_DATA &&
+ if (ndo->ndo_Hflag && FC_TYPE(fc) == T_DATA &&
DATA_FRAME_IS_QOS(FC_SUBTYPE(fc))) {
meshdrlen = extract_mesh_header_length(p+hdrlen);
hdrlen += meshdrlen;
} else
meshdrlen = 0;
-
if (caplen < hdrlen) {
- printf("[|802.11]");
+ ND_PRINT((ndo, "%s", tstr));
return hdrlen;
}
- ieee_802_11_hdr_print(fc, p, hdrlen, meshdrlen, &src, &dst);
+ if (ndo->ndo_eflag)
+ ieee_802_11_hdr_print(ndo, fc, p, hdrlen, meshdrlen);
/*
* Go past the 802.11 header.
@@ -1762,17 +2096,19 @@ ieee802_11_print(const u_char *p, u_int length, u_int orig_caplen, int pad,
caplen -= hdrlen;
p += hdrlen;
+ src.addr_string = etheraddr_string;
+ dst.addr_string = etheraddr_string;
switch (FC_TYPE(fc)) {
case T_MGMT:
- if (!mgmt_body_print(fc,
- (const struct mgmt_header_t *)(p - hdrlen), p, length)) {
- printf("[|802.11]");
+ get_mgmt_src_dst_mac(p - hdrlen, &src.addr, &dst.addr);
+ if (!mgmt_body_print(ndo, fc, src.addr, p, length)) {
+ ND_PRINT((ndo, "%s", tstr));
return hdrlen;
}
break;
case T_CTRL:
- if (!ctrl_body_print(fc, p - hdrlen)) {
- printf("[|802.11]");
+ if (!ctrl_body_print(ndo, fc, p - hdrlen)) {
+ ND_PRINT((ndo, "%s", tstr));
return hdrlen;
}
break;
@@ -1780,30 +2116,29 @@ ieee802_11_print(const u_char *p, u_int length, u_int orig_caplen, int pad,
if (DATA_FRAME_IS_NULL(FC_SUBTYPE(fc)))
return hdrlen; /* no-data frame */
/* There may be a problem w/ AP not having this bit set */
- if (FC_WEP(fc)) {
- if (!wep_print(p)) {
- printf("[|802.11]");
+ if (FC_PROTECTED(fc)) {
+ ND_PRINT((ndo, "Data"));
+ if (!wep_print(ndo, p)) {
+ ND_PRINT((ndo, "%s", tstr));
return hdrlen;
}
- } else if (llc_print(p, length, caplen, dst, src,
- &extracted_ethertype) == 0) {
- /*
- * Some kinds of LLC packet we cannot
- * handle intelligently
- */
- if (!eflag)
- ieee_802_11_hdr_print(fc, p - hdrlen, hdrlen,
- meshdrlen, NULL, NULL);
- if (extracted_ethertype)
- printf("(LLC %s) ",
- etherproto_string(
- htons(extracted_ethertype)));
- if (!suppress_default_print)
- default_print(p, caplen);
+ } else {
+ get_data_src_dst_mac(fc, p - hdrlen, &src.addr, &dst.addr);
+ llc_hdrlen = llc_print(ndo, p, length, caplen, &src, &dst);
+ if (llc_hdrlen < 0) {
+ /*
+ * Some kinds of LLC packet we cannot
+ * handle intelligently
+ */
+ if (!ndo->ndo_suppress_default_print)
+ ND_DEFAULTPRINT(p, caplen);
+ llc_hdrlen = -llc_hdrlen;
+ }
+ hdrlen += llc_hdrlen;
}
break;
default:
- printf("unknown 802.11 frame type (%d)", FC_TYPE(fc));
+ /* We shouldn't get here - we should already have quit */
break;
}
@@ -1817,11 +2152,355 @@ ieee802_11_print(const u_char *p, u_int length, u_int orig_caplen, int pad,
* is the number of bytes actually captured.
*/
u_int
-ieee802_11_if_print(const struct pcap_pkthdr *h, const u_char *p)
+ieee802_11_if_print(netdissect_options *ndo,
+ const struct pcap_pkthdr *h, const u_char *p)
{
- return ieee802_11_print(p, h->len, h->caplen, 0, 0);
+ return ieee802_11_print(ndo, p, h->len, h->caplen, 0, 0);
}
+
+/* $FreeBSD: projects/clang400-import/contrib/tcpdump/print-802_11.c 276788 2015-01-07 19:55:18Z delphij $ */
+/* NetBSD: ieee802_11_radio.h,v 1.2 2006/02/26 03:04:03 dyoung Exp */
+
+/*-
+ * Copyright (c) 2003, 2004 David Young. All rights reserved.
+ *
+ * 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. The name of David Young may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY DAVID YOUNG ``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 DAVID
+ * YOUNG 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.
+ */
+
+/* A generic radio capture format is desirable. It must be
+ * rigidly defined (e.g., units for fields should be given),
+ * and easily extensible.
+ *
+ * The following is an extensible radio capture format. It is
+ * based on a bitmap indicating which fields are present.
+ *
+ * I am trying to describe precisely what the application programmer
+ * should expect in the following, and for that reason I tell the
+ * units and origin of each measurement (where it applies), or else I
+ * use sufficiently weaselly language ("is a monotonically nondecreasing
+ * function of...") that I cannot set false expectations for lawyerly
+ * readers.
+ */
+
+/*
+ * The radio capture header precedes the 802.11 header.
+ *
+ * Note well: all radiotap fields are little-endian.
+ */
+struct ieee80211_radiotap_header {
+ uint8_t it_version; /* Version 0. Only increases
+ * for drastic changes,
+ * introduction of compatible
+ * new fields does not count.
+ */
+ uint8_t it_pad;
+ uint16_t it_len; /* length of the whole
+ * header in bytes, including
+ * it_version, it_pad,
+ * it_len, and data fields.
+ */
+ uint32_t it_present; /* A bitmap telling which
+ * fields are present. Set bit 31
+ * (0x80000000) to extend the
+ * bitmap by another 32 bits.
+ * Additional extensions are made
+ * by setting bit 31.
+ */
+};
+
+/* Name Data type Units
+ * ---- --------- -----
+ *
+ * IEEE80211_RADIOTAP_TSFT uint64_t microseconds
+ *
+ * Value in microseconds of the MAC's 64-bit 802.11 Time
+ * Synchronization Function timer when the first bit of the
+ * MPDU arrived at the MAC. For received frames, only.
+ *
+ * IEEE80211_RADIOTAP_CHANNEL 2 x uint16_t MHz, bitmap
+ *
+ * Tx/Rx frequency in MHz, followed by flags (see below).
+ * Note that IEEE80211_RADIOTAP_XCHANNEL must be used to
+ * represent an HT channel as there is not enough room in
+ * the flags word.
+ *
+ * IEEE80211_RADIOTAP_FHSS uint16_t see below
+ *
+ * For frequency-hopping radios, the hop set (first byte)
+ * and pattern (second byte).
+ *
+ * IEEE80211_RADIOTAP_RATE uint8_t 500kb/s or index
+ *
+ * Tx/Rx data rate. If bit 0x80 is set then it represents an
+ * an MCS index and not an IEEE rate.
+ *
+ * IEEE80211_RADIOTAP_DBM_ANTSIGNAL int8_t decibels from
+ * one milliwatt (dBm)
+ *
+ * RF signal power at the antenna, decibel difference from
+ * one milliwatt.
+ *
+ * IEEE80211_RADIOTAP_DBM_ANTNOISE int8_t decibels from
+ * one milliwatt (dBm)
+ *
+ * RF noise power at the antenna, decibel difference from one
+ * milliwatt.
+ *
+ * IEEE80211_RADIOTAP_DB_ANTSIGNAL uint8_t decibel (dB)
+ *
+ * RF signal power at the antenna, decibel difference from an
+ * arbitrary, fixed reference.
+ *
+ * IEEE80211_RADIOTAP_DB_ANTNOISE uint8_t decibel (dB)
+ *
+ * RF noise power at the antenna, decibel difference from an
+ * arbitrary, fixed reference point.
+ *
+ * IEEE80211_RADIOTAP_LOCK_QUALITY uint16_t unitless
+ *
+ * Quality of Barker code lock. Unitless. Monotonically
+ * nondecreasing with "better" lock strength. Called "Signal
+ * Quality" in datasheets. (Is there a standard way to measure
+ * this?)
+ *
+ * IEEE80211_RADIOTAP_TX_ATTENUATION uint16_t unitless
+ *
+ * Transmit power expressed as unitless distance from max
+ * power set at factory calibration. 0 is max power.
+ * Monotonically nondecreasing with lower power levels.
+ *
+ * IEEE80211_RADIOTAP_DB_TX_ATTENUATION uint16_t decibels (dB)
+ *
+ * Transmit power expressed as decibel distance from max power
+ * set at factory calibration. 0 is max power. Monotonically
+ * nondecreasing with lower power levels.
+ *
+ * IEEE80211_RADIOTAP_DBM_TX_POWER int8_t decibels from
+ * one milliwatt (dBm)
+ *
+ * Transmit power expressed as dBm (decibels from a 1 milliwatt
+ * reference). This is the absolute power level measured at
+ * the antenna port.
+ *
+ * IEEE80211_RADIOTAP_FLAGS uint8_t bitmap
+ *
+ * Properties of transmitted and received frames. See flags
+ * defined below.
+ *
+ * IEEE80211_RADIOTAP_ANTENNA uint8_t antenna index
+ *
+ * Unitless indication of the Rx/Tx antenna for this packet.
+ * The first antenna is antenna 0.
+ *
+ * IEEE80211_RADIOTAP_RX_FLAGS uint16_t bitmap
+ *
+ * Properties of received frames. See flags defined below.
+ *
+ * IEEE80211_RADIOTAP_XCHANNEL uint32_t bitmap
+ * uint16_t MHz
+ * uint8_t channel number
+ * uint8_t .5 dBm
+ *
+ * Extended channel specification: flags (see below) followed by
+ * frequency in MHz, the corresponding IEEE channel number, and
+ * finally the maximum regulatory transmit power cap in .5 dBm
+ * units. This property supersedes IEEE80211_RADIOTAP_CHANNEL
+ * and only one of the two should be present.
+ *
+ * IEEE80211_RADIOTAP_MCS uint8_t known
+ * uint8_t flags
+ * uint8_t mcs
+ *
+ * Bitset indicating which fields have known values, followed
+ * by bitset of flag values, followed by the MCS rate index as
+ * in IEEE 802.11n.
+ *
+ *
+ * IEEE80211_RADIOTAP_AMPDU_STATUS u32, u16, u8, u8 unitless
+ *
+ * Contains the AMPDU information for the subframe.
+ *
+ * IEEE80211_RADIOTAP_VHT u16, u8, u8, u8[4], u8, u8, u16
+ *
+ * Contains VHT information about this frame.
+ *
+ * IEEE80211_RADIOTAP_VENDOR_NAMESPACE
+ * uint8_t OUI[3]
+ * uint8_t subspace
+ * uint16_t length
+ *
+ * The Vendor Namespace Field contains three sub-fields. The first
+ * sub-field is 3 bytes long. It contains the vendor's IEEE 802
+ * Organizationally Unique Identifier (OUI). The fourth byte is a
+ * vendor-specific "namespace selector."
+ *
+ */
+enum ieee80211_radiotap_type {
+ IEEE80211_RADIOTAP_TSFT = 0,
+ IEEE80211_RADIOTAP_FLAGS = 1,
+ IEEE80211_RADIOTAP_RATE = 2,
+ IEEE80211_RADIOTAP_CHANNEL = 3,
+ IEEE80211_RADIOTAP_FHSS = 4,
+ IEEE80211_RADIOTAP_DBM_ANTSIGNAL = 5,
+ IEEE80211_RADIOTAP_DBM_ANTNOISE = 6,
+ IEEE80211_RADIOTAP_LOCK_QUALITY = 7,
+ IEEE80211_RADIOTAP_TX_ATTENUATION = 8,
+ IEEE80211_RADIOTAP_DB_TX_ATTENUATION = 9,
+ IEEE80211_RADIOTAP_DBM_TX_POWER = 10,
+ IEEE80211_RADIOTAP_ANTENNA = 11,
+ IEEE80211_RADIOTAP_DB_ANTSIGNAL = 12,
+ IEEE80211_RADIOTAP_DB_ANTNOISE = 13,
+ IEEE80211_RADIOTAP_RX_FLAGS = 14,
+ /* NB: gap for netbsd definitions */
+ IEEE80211_RADIOTAP_XCHANNEL = 18,
+ IEEE80211_RADIOTAP_MCS = 19,
+ IEEE80211_RADIOTAP_AMPDU_STATUS = 20,
+ IEEE80211_RADIOTAP_VHT = 21,
+ IEEE80211_RADIOTAP_NAMESPACE = 29,
+ IEEE80211_RADIOTAP_VENDOR_NAMESPACE = 30,
+ IEEE80211_RADIOTAP_EXT = 31
+};
+
+/* channel attributes */
+#define IEEE80211_CHAN_TURBO 0x00010 /* Turbo channel */
+#define IEEE80211_CHAN_CCK 0x00020 /* CCK channel */
+#define IEEE80211_CHAN_OFDM 0x00040 /* OFDM channel */
+#define IEEE80211_CHAN_2GHZ 0x00080 /* 2 GHz spectrum channel. */
+#define IEEE80211_CHAN_5GHZ 0x00100 /* 5 GHz spectrum channel */
+#define IEEE80211_CHAN_PASSIVE 0x00200 /* Only passive scan allowed */
+#define IEEE80211_CHAN_DYN 0x00400 /* Dynamic CCK-OFDM channel */
+#define IEEE80211_CHAN_GFSK 0x00800 /* GFSK channel (FHSS PHY) */
+#define IEEE80211_CHAN_GSM 0x01000 /* 900 MHz spectrum channel */
+#define IEEE80211_CHAN_STURBO 0x02000 /* 11a static turbo channel only */
+#define IEEE80211_CHAN_HALF 0x04000 /* Half rate channel */
+#define IEEE80211_CHAN_QUARTER 0x08000 /* Quarter rate channel */
+#define IEEE80211_CHAN_HT20 0x10000 /* HT 20 channel */
+#define IEEE80211_CHAN_HT40U 0x20000 /* HT 40 channel w/ ext above */
+#define IEEE80211_CHAN_HT40D 0x40000 /* HT 40 channel w/ ext below */
+
+/* Useful combinations of channel characteristics, borrowed from Ethereal */
+#define IEEE80211_CHAN_A \
+ (IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_OFDM)
+#define IEEE80211_CHAN_B \
+ (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_CCK)
+#define IEEE80211_CHAN_G \
+ (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_DYN)
+#define IEEE80211_CHAN_TA \
+ (IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_OFDM | IEEE80211_CHAN_TURBO)
+#define IEEE80211_CHAN_TG \
+ (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_DYN | IEEE80211_CHAN_TURBO)
+
+
+/* For IEEE80211_RADIOTAP_FLAGS */
+#define IEEE80211_RADIOTAP_F_CFP 0x01 /* sent/received
+ * during CFP
+ */
+#define IEEE80211_RADIOTAP_F_SHORTPRE 0x02 /* sent/received
+ * with short
+ * preamble
+ */
+#define IEEE80211_RADIOTAP_F_WEP 0x04 /* sent/received
+ * with WEP encryption
+ */
+#define IEEE80211_RADIOTAP_F_FRAG 0x08 /* sent/received
+ * with fragmentation
+ */
+#define IEEE80211_RADIOTAP_F_FCS 0x10 /* frame includes FCS */
+#define IEEE80211_RADIOTAP_F_DATAPAD 0x20 /* frame has padding between
+ * 802.11 header and payload
+ * (to 32-bit boundary)
+ */
+#define IEEE80211_RADIOTAP_F_BADFCS 0x40 /* does not pass FCS check */
+
+/* For IEEE80211_RADIOTAP_RX_FLAGS */
+#define IEEE80211_RADIOTAP_F_RX_BADFCS 0x0001 /* frame failed crc check */
+#define IEEE80211_RADIOTAP_F_RX_PLCP_CRC 0x0002 /* frame failed PLCP CRC check */
+
+/* For IEEE80211_RADIOTAP_MCS known */
+#define IEEE80211_RADIOTAP_MCS_BANDWIDTH_KNOWN 0x01
+#define IEEE80211_RADIOTAP_MCS_MCS_INDEX_KNOWN 0x02 /* MCS index field */
+#define IEEE80211_RADIOTAP_MCS_GUARD_INTERVAL_KNOWN 0x04
+#define IEEE80211_RADIOTAP_MCS_HT_FORMAT_KNOWN 0x08
+#define IEEE80211_RADIOTAP_MCS_FEC_TYPE_KNOWN 0x10
+#define IEEE80211_RADIOTAP_MCS_STBC_KNOWN 0x20
+#define IEEE80211_RADIOTAP_MCS_NESS_KNOWN 0x40
+#define IEEE80211_RADIOTAP_MCS_NESS_BIT_1 0x80
+
+/* For IEEE80211_RADIOTAP_MCS flags */
+#define IEEE80211_RADIOTAP_MCS_BANDWIDTH_MASK 0x03
+#define IEEE80211_RADIOTAP_MCS_BANDWIDTH_20 0
+#define IEEE80211_RADIOTAP_MCS_BANDWIDTH_40 1
+#define IEEE80211_RADIOTAP_MCS_BANDWIDTH_20L 2
+#define IEEE80211_RADIOTAP_MCS_BANDWIDTH_20U 3
+#define IEEE80211_RADIOTAP_MCS_SHORT_GI 0x04 /* short guard interval */
+#define IEEE80211_RADIOTAP_MCS_HT_GREENFIELD 0x08
+#define IEEE80211_RADIOTAP_MCS_FEC_LDPC 0x10
+#define IEEE80211_RADIOTAP_MCS_STBC_MASK 0x60
+#define IEEE80211_RADIOTAP_MCS_STBC_1 1
+#define IEEE80211_RADIOTAP_MCS_STBC_2 2
+#define IEEE80211_RADIOTAP_MCS_STBC_3 3
+#define IEEE80211_RADIOTAP_MCS_STBC_SHIFT 5
+#define IEEE80211_RADIOTAP_MCS_NESS_BIT_0 0x80
+
+/* For IEEE80211_RADIOTAP_AMPDU_STATUS */
+#define IEEE80211_RADIOTAP_AMPDU_REPORT_ZEROLEN 0x0001
+#define IEEE80211_RADIOTAP_AMPDU_IS_ZEROLEN 0x0002
+#define IEEE80211_RADIOTAP_AMPDU_LAST_KNOWN 0x0004
+#define IEEE80211_RADIOTAP_AMPDU_IS_LAST 0x0008
+#define IEEE80211_RADIOTAP_AMPDU_DELIM_CRC_ERR 0x0010
+#define IEEE80211_RADIOTAP_AMPDU_DELIM_CRC_KNOWN 0x0020
+
+/* For IEEE80211_RADIOTAP_VHT known */
+#define IEEE80211_RADIOTAP_VHT_STBC_KNOWN 0x0001
+#define IEEE80211_RADIOTAP_VHT_TXOP_PS_NA_KNOWN 0x0002
+#define IEEE80211_RADIOTAP_VHT_GUARD_INTERVAL_KNOWN 0x0004
+#define IEEE80211_RADIOTAP_VHT_SGI_NSYM_DIS_KNOWN 0x0008
+#define IEEE80211_RADIOTAP_VHT_LDPC_EXTRA_OFDM_SYM_KNOWN 0x0010
+#define IEEE80211_RADIOTAP_VHT_BEAMFORMED_KNOWN 0x0020
+#define IEEE80211_RADIOTAP_VHT_BANDWIDTH_KNOWN 0x0040
+#define IEEE80211_RADIOTAP_VHT_GROUP_ID_KNOWN 0x0080
+#define IEEE80211_RADIOTAP_VHT_PARTIAL_AID_KNOWN 0x0100
+
+/* For IEEE80211_RADIOTAP_VHT flags */
+#define IEEE80211_RADIOTAP_VHT_STBC 0x01
+#define IEEE80211_RADIOTAP_VHT_TXOP_PS_NA 0x02
+#define IEEE80211_RADIOTAP_VHT_SHORT_GI 0x04
+#define IEEE80211_RADIOTAP_VHT_SGI_NSYM_M10_9 0x08
+#define IEEE80211_RADIOTAP_VHT_LDPC_EXTRA_OFDM_SYM 0x10
+#define IEEE80211_RADIOTAP_VHT_BEAMFORMED 0x20
+
+#define IEEE80211_RADIOTAP_VHT_BANDWIDTH_MASK 0x1f
+
+#define IEEE80211_RADIOTAP_VHT_NSS_MASK 0x0f
+#define IEEE80211_RADIOTAP_VHT_MCS_MASK 0xf0
+#define IEEE80211_RADIOTAP_VHT_MCS_SHIFT 4
+
+#define IEEE80211_RADIOTAP_CODING_LDPC_USERn 0x01
+
#define IEEE80211_CHAN_FHSS \
(IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_GFSK)
#define IEEE80211_CHAN_A \
@@ -1847,180 +2526,97 @@ ieee802_11_if_print(const struct pcap_pkthdr *h, const u_char *p)
(IS_CHAN_PUREG(flags) || IS_CHAN_G(flags))
static void
-print_chaninfo(int freq, int flags)
+print_chaninfo(netdissect_options *ndo,
+ uint16_t freq, int flags, int presentflags)
{
- printf("%u MHz", freq);
- if (IS_CHAN_FHSS(flags))
- printf(" FHSS");
- if (IS_CHAN_A(flags)) {
- if (flags & IEEE80211_CHAN_HALF)
- printf(" 11a/10Mhz");
- else if (flags & IEEE80211_CHAN_QUARTER)
- printf(" 11a/5Mhz");
- else
- printf(" 11a");
+ ND_PRINT((ndo, "%u MHz", freq));
+ if (presentflags & (1 << IEEE80211_RADIOTAP_MCS)) {
+ /*
+ * We have the MCS field, so this is 11n, regardless
+ * of what the channel flags say.
+ */
+ ND_PRINT((ndo, " 11n"));
+ } else {
+ if (IS_CHAN_FHSS(flags))
+ ND_PRINT((ndo, " FHSS"));
+ if (IS_CHAN_A(flags)) {
+ if (flags & IEEE80211_CHAN_HALF)
+ ND_PRINT((ndo, " 11a/10Mhz"));
+ else if (flags & IEEE80211_CHAN_QUARTER)
+ ND_PRINT((ndo, " 11a/5Mhz"));
+ else
+ ND_PRINT((ndo, " 11a"));
+ }
+ if (IS_CHAN_ANYG(flags)) {
+ if (flags & IEEE80211_CHAN_HALF)
+ ND_PRINT((ndo, " 11g/10Mhz"));
+ else if (flags & IEEE80211_CHAN_QUARTER)
+ ND_PRINT((ndo, " 11g/5Mhz"));
+ else
+ ND_PRINT((ndo, " 11g"));
+ } else if (IS_CHAN_B(flags))
+ ND_PRINT((ndo, " 11b"));
+ if (flags & IEEE80211_CHAN_TURBO)
+ ND_PRINT((ndo, " Turbo"));
}
- if (IS_CHAN_ANYG(flags)) {
- if (flags & IEEE80211_CHAN_HALF)
- printf(" 11g/10Mhz");
- else if (flags & IEEE80211_CHAN_QUARTER)
- printf(" 11g/5Mhz");
- else
- printf(" 11g");
- } else if (IS_CHAN_B(flags))
- printf(" 11b");
- if (flags & IEEE80211_CHAN_TURBO)
- printf(" Turbo");
+ /*
+ * These apply to 11n.
+ */
if (flags & IEEE80211_CHAN_HT20)
- printf(" ht/20");
+ ND_PRINT((ndo, " ht/20"));
else if (flags & IEEE80211_CHAN_HT40D)
- printf(" ht/40-");
+ ND_PRINT((ndo, " ht/40-"));
else if (flags & IEEE80211_CHAN_HT40U)
- printf(" ht/40+");
- printf(" ");
+ ND_PRINT((ndo, " ht/40+"));
+ ND_PRINT((ndo, " "));
}
static int
-print_radiotap_field(struct cpack_state *s, u_int32_t bit, u_int8_t *flags,
- struct radiotap_state *state, u_int32_t presentflags)
+print_radiotap_field(netdissect_options *ndo,
+ struct cpack_state *s, uint32_t bit, uint8_t *flagsp,
+ uint32_t presentflags)
{
- union {
- int8_t i8;
- u_int8_t u8;
- int16_t i16;
- u_int16_t u16;
- u_int32_t u32;
- u_int64_t u64;
- } u, u2, u3, u4;
+ u_int i;
int rc;
switch (bit) {
- case IEEE80211_RADIOTAP_FLAGS:
- rc = cpack_uint8(s, &u.u8);
- if (rc != 0)
- break;
- *flags = u.u8;
- break;
- case IEEE80211_RADIOTAP_RATE:
- rc = cpack_uint8(s, &u.u8);
- if (rc != 0)
- break;
- /* Save state rate */
- state->rate = u.u8;
- break;
- case IEEE80211_RADIOTAP_DB_ANTSIGNAL:
- case IEEE80211_RADIOTAP_DB_ANTNOISE:
- case IEEE80211_RADIOTAP_ANTENNA:
- rc = cpack_uint8(s, &u.u8);
- break;
- case IEEE80211_RADIOTAP_DBM_ANTSIGNAL:
- case IEEE80211_RADIOTAP_DBM_ANTNOISE:
- rc = cpack_int8(s, &u.i8);
- break;
- case IEEE80211_RADIOTAP_CHANNEL:
- rc = cpack_uint16(s, &u.u16);
- if (rc != 0)
- break;
- rc = cpack_uint16(s, &u2.u16);
- break;
- case IEEE80211_RADIOTAP_FHSS:
- case IEEE80211_RADIOTAP_LOCK_QUALITY:
- case IEEE80211_RADIOTAP_TX_ATTENUATION:
- case IEEE80211_RADIOTAP_RX_FLAGS:
- rc = cpack_uint16(s, &u.u16);
- break;
- case IEEE80211_RADIOTAP_DB_TX_ATTENUATION:
- rc = cpack_uint8(s, &u.u8);
- break;
- case IEEE80211_RADIOTAP_DBM_TX_POWER:
- rc = cpack_int8(s, &u.i8);
- break;
- case IEEE80211_RADIOTAP_TSFT:
- rc = cpack_uint64(s, &u.u64);
- break;
- case IEEE80211_RADIOTAP_XCHANNEL:
- rc = cpack_uint32(s, &u.u32);
- if (rc != 0)
- break;
- rc = cpack_uint16(s, &u2.u16);
- if (rc != 0)
- break;
- rc = cpack_uint8(s, &u3.u8);
- if (rc != 0)
- break;
- rc = cpack_uint8(s, &u4.u8);
- break;
- case IEEE80211_RADIOTAP_MCS:
- rc = cpack_uint8(s, &u.u8);
- if (rc != 0)
- break;
- rc = cpack_uint8(s, &u2.u8);
+ case IEEE80211_RADIOTAP_TSFT: {
+ uint64_t tsft;
+
+ rc = cpack_uint64(s, &tsft);
if (rc != 0)
- break;
- rc = cpack_uint8(s, &u3.u8);
+ goto trunc;
+ ND_PRINT((ndo, "%" PRIu64 "us tsft ", tsft));
break;
- case IEEE80211_RADIOTAP_VENDOR_NAMESPACE: {
- u_int8_t vns[3];
- u_int16_t length;
- u_int8_t subspace;
-
- if ((cpack_align_and_reserve(s, 2)) == NULL) {
- rc = -1;
- break;
}
- rc = cpack_uint8(s, &vns[0]);
- if (rc != 0)
- break;
- rc = cpack_uint8(s, &vns[1]);
- if (rc != 0)
- break;
- rc = cpack_uint8(s, &vns[2]);
- if (rc != 0)
- break;
- rc = cpack_uint8(s, &subspace);
- if (rc != 0)
- break;
- rc = cpack_uint16(s, &length);
- if (rc != 0)
- break;
+ case IEEE80211_RADIOTAP_FLAGS: {
+ uint8_t flagsval;
- /* Skip up to length */
- s->c_next += length;
+ rc = cpack_uint8(s, &flagsval);
+ if (rc != 0)
+ goto trunc;
+ *flagsp = flagsval;
+ if (flagsval & IEEE80211_RADIOTAP_F_CFP)
+ ND_PRINT((ndo, "cfp "));
+ if (flagsval & IEEE80211_RADIOTAP_F_SHORTPRE)
+ ND_PRINT((ndo, "short preamble "));
+ if (flagsval & IEEE80211_RADIOTAP_F_WEP)
+ ND_PRINT((ndo, "wep "));
+ if (flagsval & IEEE80211_RADIOTAP_F_FRAG)
+ ND_PRINT((ndo, "fragmented "));
+ if (flagsval & IEEE80211_RADIOTAP_F_BADFCS)
+ ND_PRINT((ndo, "bad-fcs "));
break;
- }
- default:
- /* this bit indicates a field whose
- * size we do not know, so we cannot
- * proceed. Just print the bit number.
- */
- printf("[bit %u] ", bit);
- return -1;
- }
-
- if (rc != 0) {
- printf("[|802.11]");
- return rc;
- }
+ }
- /* Preserve the state present flags */
- state->present = presentflags;
+ case IEEE80211_RADIOTAP_RATE: {
+ uint8_t rate;
- switch (bit) {
- case IEEE80211_RADIOTAP_CHANNEL:
- /*
- * If CHANNEL and XCHANNEL are both present, skip
- * CHANNEL.
- */
- if (presentflags & (1 << IEEE80211_RADIOTAP_XCHANNEL))
- break;
- print_chaninfo(u.u16, u2.u16);
- break;
- case IEEE80211_RADIOTAP_FHSS:
- printf("fhset %d fhpat %d ", u.u16 & 0xff, (u.u16 >> 8) & 0xff);
- break;
- case IEEE80211_RADIOTAP_RATE:
+ rc = cpack_uint8(s, &rate);
+ if (rc != 0)
+ goto trunc;
/*
* XXX On FreeBSD rate & 0x80 means we have an MCS. On
* Linux and AirPcap it does not. (What about
@@ -2042,7 +2638,7 @@ print_radiotap_field(struct cpack_state *s, u_int32_t bit, u_int8_t *flags,
* setting. Such rates do exist, e.g. 11n
* MCS 7 at 20 MHz with a long guard interval.
*/
- if (u.u8 >= 0x80 && u.u8 <= 0x8f) {
+ if (rate >= 0x80 && rate <= 0x8f) {
/*
* XXX - we don't know the channel width
* or guard interval length, so we can't
@@ -2059,60 +2655,173 @@ print_radiotap_field(struct cpack_state *s, u_int32_t bit, u_int8_t *flags,
* information from Flags, at least on
* FreeBSD?
*/
- printf("MCS %u ", u.u8 & 0x7f);
+ ND_PRINT((ndo, "MCS %u ", rate & 0x7f));
} else
- printf("%2.1f Mb/s ", .5*u.u8);
+ ND_PRINT((ndo, "%2.1f Mb/s ", .5 * rate));
break;
- case IEEE80211_RADIOTAP_DBM_ANTSIGNAL:
- printf("%ddB signal ", u.i8);
+ }
+
+ case IEEE80211_RADIOTAP_CHANNEL: {
+ uint16_t frequency;
+ uint16_t flags;
+
+ rc = cpack_uint16(s, &frequency);
+ if (rc != 0)
+ goto trunc;
+ rc = cpack_uint16(s, &flags);
+ if (rc != 0)
+ goto trunc;
+ /*
+ * If CHANNEL and XCHANNEL are both present, skip
+ * CHANNEL.
+ */
+ if (presentflags & (1 << IEEE80211_RADIOTAP_XCHANNEL))
+ break;
+ print_chaninfo(ndo, frequency, flags, presentflags);
break;
- case IEEE80211_RADIOTAP_DBM_ANTNOISE:
- printf("%ddB noise ", u.i8);
+ }
+
+ case IEEE80211_RADIOTAP_FHSS: {
+ uint8_t hopset;
+ uint8_t hoppat;
+
+ rc = cpack_uint8(s, &hopset);
+ if (rc != 0)
+ goto trunc;
+ rc = cpack_uint8(s, &hoppat);
+ if (rc != 0)
+ goto trunc;
+ ND_PRINT((ndo, "fhset %d fhpat %d ", hopset, hoppat));
break;
- case IEEE80211_RADIOTAP_DB_ANTSIGNAL:
- printf("%ddB signal ", u.u8);
+ }
+
+ case IEEE80211_RADIOTAP_DBM_ANTSIGNAL: {
+ int8_t dbm_antsignal;
+
+ rc = cpack_int8(s, &dbm_antsignal);
+ if (rc != 0)
+ goto trunc;
+ ND_PRINT((ndo, "%ddBm signal ", dbm_antsignal));
break;
- case IEEE80211_RADIOTAP_DB_ANTNOISE:
- printf("%ddB noise ", u.u8);
+ }
+
+ case IEEE80211_RADIOTAP_DBM_ANTNOISE: {
+ int8_t dbm_antnoise;
+
+ rc = cpack_int8(s, &dbm_antnoise);
+ if (rc != 0)
+ goto trunc;
+ ND_PRINT((ndo, "%ddBm noise ", dbm_antnoise));
break;
- case IEEE80211_RADIOTAP_LOCK_QUALITY:
- printf("%u sq ", u.u16);
+ }
+
+ case IEEE80211_RADIOTAP_LOCK_QUALITY: {
+ uint16_t lock_quality;
+
+ rc = cpack_uint16(s, &lock_quality);
+ if (rc != 0)
+ goto trunc;
+ ND_PRINT((ndo, "%u sq ", lock_quality));
break;
- case IEEE80211_RADIOTAP_TX_ATTENUATION:
- printf("%d tx power ", -(int)u.u16);
+ }
+
+ case IEEE80211_RADIOTAP_TX_ATTENUATION: {
+ uint16_t tx_attenuation;
+
+ rc = cpack_uint16(s, &tx_attenuation);
+ if (rc != 0)
+ goto trunc;
+ ND_PRINT((ndo, "%d tx power ", -(int)tx_attenuation));
break;
- case IEEE80211_RADIOTAP_DB_TX_ATTENUATION:
- printf("%ddB tx power ", -(int)u.u8);
+ }
+
+ case IEEE80211_RADIOTAP_DB_TX_ATTENUATION: {
+ uint8_t db_tx_attenuation;
+
+ rc = cpack_uint8(s, &db_tx_attenuation);
+ if (rc != 0)
+ goto trunc;
+ ND_PRINT((ndo, "%ddB tx attenuation ", -(int)db_tx_attenuation));
break;
- case IEEE80211_RADIOTAP_DBM_TX_POWER:
- printf("%ddBm tx power ", u.i8);
+ }
+
+ case IEEE80211_RADIOTAP_DBM_TX_POWER: {
+ int8_t dbm_tx_power;
+
+ rc = cpack_int8(s, &dbm_tx_power);
+ if (rc != 0)
+ goto trunc;
+ ND_PRINT((ndo, "%ddBm tx power ", dbm_tx_power));
break;
- case IEEE80211_RADIOTAP_FLAGS:
- if (u.u8 & IEEE80211_RADIOTAP_F_CFP)
- printf("cfp ");
- if (u.u8 & IEEE80211_RADIOTAP_F_SHORTPRE)
- printf("short preamble ");
- if (u.u8 & IEEE80211_RADIOTAP_F_WEP)
- printf("wep ");
- if (u.u8 & IEEE80211_RADIOTAP_F_FRAG)
- printf("fragmented ");
- if (u.u8 & IEEE80211_RADIOTAP_F_BADFCS)
- printf("bad-fcs ");
+ }
+
+ case IEEE80211_RADIOTAP_ANTENNA: {
+ uint8_t antenna;
+
+ rc = cpack_uint8(s, &antenna);
+ if (rc != 0)
+ goto trunc;
+ ND_PRINT((ndo, "antenna %u ", antenna));
break;
- case IEEE80211_RADIOTAP_ANTENNA:
- printf("antenna %d ", u.u8);
+ }
+
+ case IEEE80211_RADIOTAP_DB_ANTSIGNAL: {
+ uint8_t db_antsignal;
+
+ rc = cpack_uint8(s, &db_antsignal);
+ if (rc != 0)
+ goto trunc;
+ ND_PRINT((ndo, "%ddB signal ", db_antsignal));
break;
- case IEEE80211_RADIOTAP_TSFT:
- printf("%" PRIu64 "us tsft ", u.u64);
+ }
+
+ case IEEE80211_RADIOTAP_DB_ANTNOISE: {
+ uint8_t db_antnoise;
+
+ rc = cpack_uint8(s, &db_antnoise);
+ if (rc != 0)
+ goto trunc;
+ ND_PRINT((ndo, "%ddB noise ", db_antnoise));
break;
- case IEEE80211_RADIOTAP_RX_FLAGS:
+ }
+
+ case IEEE80211_RADIOTAP_RX_FLAGS: {
+ uint16_t rx_flags;
+
+ rc = cpack_uint16(s, &rx_flags);
+ if (rc != 0)
+ goto trunc;
/* Do nothing for now */
break;
- case IEEE80211_RADIOTAP_XCHANNEL:
- print_chaninfo(u2.u16, u.u32);
+ }
+
+ case IEEE80211_RADIOTAP_XCHANNEL: {
+ uint32_t flags;
+ uint16_t frequency;
+ uint8_t channel;
+ uint8_t maxpower;
+
+ rc = cpack_uint32(s, &flags);
+ if (rc != 0)
+ goto trunc;
+ rc = cpack_uint16(s, &frequency);
+ if (rc != 0)
+ goto trunc;
+ rc = cpack_uint8(s, &channel);
+ if (rc != 0)
+ goto trunc;
+ rc = cpack_uint8(s, &maxpower);
+ if (rc != 0)
+ goto trunc;
+ print_chaninfo(ndo, frequency, flags, presentflags);
break;
+ }
+
case IEEE80211_RADIOTAP_MCS: {
- static const char *bandwidth[4] = {
+ uint8_t known;
+ uint8_t flags;
+ uint8_t mcs_index;
+ static const char *ht_bandwidth[4] = {
"20 MHz",
"40 MHz",
"20 MHz (L)",
@@ -2120,25 +2829,34 @@ print_radiotap_field(struct cpack_state *s, u_int32_t bit, u_int8_t *flags,
};
float htrate;
- if (u.u8 & IEEE80211_RADIOTAP_MCS_MCS_INDEX_KNOWN) {
+ rc = cpack_uint8(s, &known);
+ if (rc != 0)
+ goto trunc;
+ rc = cpack_uint8(s, &flags);
+ if (rc != 0)
+ goto trunc;
+ rc = cpack_uint8(s, &mcs_index);
+ if (rc != 0)
+ goto trunc;
+ if (known & IEEE80211_RADIOTAP_MCS_MCS_INDEX_KNOWN) {
/*
* We know the MCS index.
*/
- if (u3.u8 <= MAX_MCS_INDEX) {
+ if (mcs_index <= MAX_MCS_INDEX) {
/*
* And it's in-range.
*/
- if (u.u8 & (IEEE80211_RADIOTAP_MCS_BANDWIDTH_KNOWN|IEEE80211_RADIOTAP_MCS_GUARD_INTERVAL_KNOWN)) {
+ if (known & (IEEE80211_RADIOTAP_MCS_BANDWIDTH_KNOWN|IEEE80211_RADIOTAP_MCS_GUARD_INTERVAL_KNOWN)) {
/*
* And we know both the bandwidth and
* the guard interval, so we can look
* up the rate.
*/
- htrate =
+ htrate =
ieee80211_float_htrates \
- [u3.u8] \
- [((u2.u8 & IEEE80211_RADIOTAP_MCS_BANDWIDTH_MASK) == IEEE80211_RADIOTAP_MCS_BANDWIDTH_40 ? 1 : 0)] \
- [((u2.u8 & IEEE80211_RADIOTAP_MCS_SHORT_GI) ? 1 : 0)];
+ [mcs_index] \
+ [((flags & IEEE80211_RADIOTAP_MCS_BANDWIDTH_MASK) == IEEE80211_RADIOTAP_MCS_BANDWIDTH_40 ? 1 : 0)] \
+ [((flags & IEEE80211_RADIOTAP_MCS_SHORT_GI) ? 1 : 0)];
} else {
/*
* We don't know both the bandwidth
@@ -2158,131 +2876,403 @@ print_radiotap_field(struct cpack_state *s, u_int32_t bit, u_int8_t *flags,
* We have the rate.
* Print it.
*/
- printf("%.1f Mb/s MCS %u ", htrate, u3.u8);
+ ND_PRINT((ndo, "%.1f Mb/s MCS %u ", htrate, mcs_index));
} else {
/*
* We at least have the MCS index.
* Print it.
*/
- printf("MCS %u ", u3.u8);
+ ND_PRINT((ndo, "MCS %u ", mcs_index));
}
}
- if (u.u8 & IEEE80211_RADIOTAP_MCS_BANDWIDTH_KNOWN) {
- printf("%s ",
- bandwidth[u2.u8 & IEEE80211_RADIOTAP_MCS_BANDWIDTH_MASK]);
+ if (known & IEEE80211_RADIOTAP_MCS_BANDWIDTH_KNOWN) {
+ ND_PRINT((ndo, "%s ",
+ ht_bandwidth[flags & IEEE80211_RADIOTAP_MCS_BANDWIDTH_MASK]));
+ }
+ if (known & IEEE80211_RADIOTAP_MCS_GUARD_INTERVAL_KNOWN) {
+ ND_PRINT((ndo, "%s GI ",
+ (flags & IEEE80211_RADIOTAP_MCS_SHORT_GI) ?
+ "short" : "long"));
+ }
+ if (known & IEEE80211_RADIOTAP_MCS_HT_FORMAT_KNOWN) {
+ ND_PRINT((ndo, "%s ",
+ (flags & IEEE80211_RADIOTAP_MCS_HT_GREENFIELD) ?
+ "greenfield" : "mixed"));
+ }
+ if (known & IEEE80211_RADIOTAP_MCS_FEC_TYPE_KNOWN) {
+ ND_PRINT((ndo, "%s FEC ",
+ (flags & IEEE80211_RADIOTAP_MCS_FEC_LDPC) ?
+ "LDPC" : "BCC"));
}
- if (u.u8 & IEEE80211_RADIOTAP_MCS_GUARD_INTERVAL_KNOWN) {
- printf("%s GI ",
- (u2.u8 & IEEE80211_RADIOTAP_MCS_SHORT_GI) ?
- "short" : "lon");
+ if (known & IEEE80211_RADIOTAP_MCS_STBC_KNOWN) {
+ ND_PRINT((ndo, "RX-STBC%u ",
+ (flags & IEEE80211_RADIOTAP_MCS_STBC_MASK) >> IEEE80211_RADIOTAP_MCS_STBC_SHIFT));
+ }
+ break;
+ }
+
+ case IEEE80211_RADIOTAP_AMPDU_STATUS: {
+ uint32_t reference_num;
+ uint16_t flags;
+ uint8_t delim_crc;
+ uint8_t reserved;
+
+ rc = cpack_uint32(s, &reference_num);
+ if (rc != 0)
+ goto trunc;
+ rc = cpack_uint16(s, &flags);
+ if (rc != 0)
+ goto trunc;
+ rc = cpack_uint8(s, &delim_crc);
+ if (rc != 0)
+ goto trunc;
+ rc = cpack_uint8(s, &reserved);
+ if (rc != 0)
+ goto trunc;
+ /* Do nothing for now */
+ break;
+ }
+
+ case IEEE80211_RADIOTAP_VHT: {
+ uint16_t known;
+ uint8_t flags;
+ uint8_t bandwidth;
+ uint8_t mcs_nss[4];
+ uint8_t coding;
+ uint8_t group_id;
+ uint16_t partial_aid;
+ static const char *vht_bandwidth[32] = {
+ "20 MHz",
+ "40 MHz",
+ "20 MHz (L)",
+ "20 MHz (U)",
+ "80 MHz",
+ "80 MHz (L)",
+ "80 MHz (U)",
+ "80 MHz (LL)",
+ "80 MHz (LU)",
+ "80 MHz (UL)",
+ "80 MHz (UU)",
+ "160 MHz",
+ "160 MHz (L)",
+ "160 MHz (U)",
+ "160 MHz (LL)",
+ "160 MHz (LU)",
+ "160 MHz (UL)",
+ "160 MHz (UU)",
+ "160 MHz (LLL)",
+ "160 MHz (LLU)",
+ "160 MHz (LUL)",
+ "160 MHz (UUU)",
+ "160 MHz (ULL)",
+ "160 MHz (ULU)",
+ "160 MHz (UUL)",
+ "160 MHz (UUU)",
+ "unknown (26)",
+ "unknown (27)",
+ "unknown (28)",
+ "unknown (29)",
+ "unknown (30)",
+ "unknown (31)"
+ };
+
+ rc = cpack_uint16(s, &known);
+ if (rc != 0)
+ goto trunc;
+ rc = cpack_uint8(s, &flags);
+ if (rc != 0)
+ goto trunc;
+ rc = cpack_uint8(s, &bandwidth);
+ if (rc != 0)
+ goto trunc;
+ for (i = 0; i < 4; i++) {
+ rc = cpack_uint8(s, &mcs_nss[i]);
+ if (rc != 0)
+ goto trunc;
+ }
+ rc = cpack_uint8(s, &coding);
+ if (rc != 0)
+ goto trunc;
+ rc = cpack_uint8(s, &group_id);
+ if (rc != 0)
+ goto trunc;
+ rc = cpack_uint16(s, &partial_aid);
+ if (rc != 0)
+ goto trunc;
+ for (i = 0; i < 4; i++) {
+ u_int nss, mcs;
+ nss = mcs_nss[i] & IEEE80211_RADIOTAP_VHT_NSS_MASK;
+ mcs = (mcs_nss[i] & IEEE80211_RADIOTAP_VHT_MCS_MASK) >> IEEE80211_RADIOTAP_VHT_MCS_SHIFT;
+
+ if (nss == 0)
+ continue;
+
+ ND_PRINT((ndo, "User %u MCS %u ", i, mcs));
+ ND_PRINT((ndo, "%s FEC ",
+ (coding & (IEEE80211_RADIOTAP_CODING_LDPC_USERn << i)) ?
+ "LDPC" : "BCC"));
}
- if (u.u8 & IEEE80211_RADIOTAP_MCS_HT_FORMAT_KNOWN) {
- printf("%s ",
- (u2.u8 & IEEE80211_RADIOTAP_MCS_HT_GREENFIELD) ?
- "greenfield" : "mixed");
+ if (known & IEEE80211_RADIOTAP_VHT_BANDWIDTH_KNOWN) {
+ ND_PRINT((ndo, "%s ",
+ vht_bandwidth[bandwidth & IEEE80211_RADIOTAP_VHT_BANDWIDTH_MASK]));
}
- if (u.u8 & IEEE80211_RADIOTAP_MCS_FEC_TYPE_KNOWN) {
- printf("%s FEC ",
- (u2.u8 & IEEE80211_RADIOTAP_MCS_FEC_LDPC) ?
- "LDPC" : "BCC");
+ if (known & IEEE80211_RADIOTAP_VHT_GUARD_INTERVAL_KNOWN) {
+ ND_PRINT((ndo, "%s GI ",
+ (flags & IEEE80211_RADIOTAP_VHT_SHORT_GI) ?
+ "short" : "long"));
}
break;
}
+
+ default:
+ /* this bit indicates a field whose
+ * size we do not know, so we cannot
+ * proceed. Just print the bit number.
+ */
+ ND_PRINT((ndo, "[bit %u] ", bit));
+ return -1;
}
+
return 0;
+
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return rc;
}
-static u_int
-ieee802_11_radio_print(const u_char *p, u_int length, u_int caplen)
+
+static int
+print_in_radiotap_namespace(netdissect_options *ndo,
+ struct cpack_state *s, uint8_t *flags,
+ uint32_t presentflags, int bit0)
{
#define BITNO_32(x) (((x) >> 16) ? 16 + BITNO_16((x) >> 16) : BITNO_16((x)))
#define BITNO_16(x) (((x) >> 8) ? 8 + BITNO_8((x) >> 8) : BITNO_8((x)))
#define BITNO_8(x) (((x) >> 4) ? 4 + BITNO_4((x) >> 4) : BITNO_4((x)))
#define BITNO_4(x) (((x) >> 2) ? 2 + BITNO_2((x) >> 2) : BITNO_2((x)))
#define BITNO_2(x) (((x) & 2) ? 1 : 0)
+ uint32_t present, next_present;
+ int bitno;
+ enum ieee80211_radiotap_type bit;
+ int rc;
+
+ for (present = presentflags; present; present = next_present) {
+ /*
+ * Clear the least significant bit that is set.
+ */
+ next_present = present & (present - 1);
+
+ /*
+ * Get the bit number, within this presence word,
+ * of the remaining least significant bit that
+ * is set.
+ */
+ bitno = BITNO_32(present ^ next_present);
+
+ /*
+ * Stop if this is one of the "same meaning
+ * in all presence flags" bits.
+ */
+ if (bitno >= IEEE80211_RADIOTAP_NAMESPACE)
+ break;
+
+ /*
+ * Get the radiotap bit number of that bit.
+ */
+ bit = (enum ieee80211_radiotap_type)(bit0 + bitno);
+
+ rc = print_radiotap_field(ndo, s, bit, flags, presentflags);
+ if (rc != 0)
+ return rc;
+ }
+
+ return 0;
+}
+
+static u_int
+ieee802_11_radio_print(netdissect_options *ndo,
+ const u_char *p, u_int length, u_int caplen)
+{
#define BIT(n) (1U << n)
#define IS_EXTENDED(__p) \
(EXTRACT_LE_32BITS(__p) & BIT(IEEE80211_RADIOTAP_EXT)) != 0
struct cpack_state cpacker;
- struct ieee80211_radiotap_header *hdr;
- u_int32_t present, next_present;
- u_int32_t presentflags = 0;
- u_int32_t *presentp, *last_presentp;
- enum ieee80211_radiotap_type bit;
+ const struct ieee80211_radiotap_header *hdr;
+ uint32_t presentflags;
+ const uint32_t *presentp, *last_presentp;
+ int vendor_namespace;
+ uint8_t vendor_oui[3];
+ uint8_t vendor_subnamespace;
+ uint16_t skip_length;
int bit0;
- const u_char *iter;
u_int len;
- u_int8_t flags;
+ uint8_t flags;
int pad;
u_int fcslen;
- struct radiotap_state state;
if (caplen < sizeof(*hdr)) {
- printf("[|802.11]");
+ ND_PRINT((ndo, "%s", tstr));
return caplen;
}
- hdr = (struct ieee80211_radiotap_header *)p;
+ hdr = (const struct ieee80211_radiotap_header *)p;
len = EXTRACT_LE_16BITS(&hdr->it_len);
+ /*
+ * If we don't have the entire radiotap header, just give up.
+ */
if (caplen < len) {
- printf("[|802.11]");
+ ND_PRINT((ndo, "%s", tstr));
return caplen;
}
+ cpack_init(&cpacker, (const uint8_t *)hdr, len); /* align against header start */
+ cpack_advance(&cpacker, sizeof(*hdr)); /* includes the 1st bitmap */
for (last_presentp = &hdr->it_present;
- IS_EXTENDED(last_presentp) &&
- (u_char*)(last_presentp + 1) <= p + len;
- last_presentp++);
+ (const u_char*)(last_presentp + 1) <= p + len &&
+ IS_EXTENDED(last_presentp);
+ last_presentp++)
+ cpack_advance(&cpacker, sizeof(hdr->it_present)); /* more bitmaps */
/* are there more bitmap extensions than bytes in header? */
- if (IS_EXTENDED(last_presentp)) {
- printf("[|802.11]");
- return caplen;
- }
-
- iter = (u_char*)(last_presentp + 1);
-
- if (cpack_init(&cpacker, (u_int8_t*)iter, len - (iter - p)) != 0) {
- /* XXX */
- printf("[|802.11]");
+ if ((const u_char*)(last_presentp + 1) > p + len) {
+ ND_PRINT((ndo, "%s", tstr));
return caplen;
}
+ /*
+ * Start out at the beginning of the default radiotap namespace.
+ */
+ bit0 = 0;
+ vendor_namespace = 0;
+ memset(vendor_oui, 0, 3);
+ vendor_subnamespace = 0;
+ skip_length = 0;
/* Assume no flags */
flags = 0;
/* Assume no Atheros padding between 802.11 header and body */
pad = 0;
/* Assume no FCS at end of frame */
fcslen = 0;
- for (bit0 = 0, presentp = &hdr->it_present; presentp <= last_presentp;
- presentp++, bit0 += 32) {
+ for (presentp = &hdr->it_present; presentp <= last_presentp;
+ presentp++) {
presentflags = EXTRACT_LE_32BITS(presentp);
- /* Clear state. */
- memset(&state, 0, sizeof(state));
+ /*
+ * If this is a vendor namespace, we don't handle it.
+ */
+ if (vendor_namespace) {
+ /*
+ * Skip past the stuff we don't understand.
+ * If we add support for any vendor namespaces,
+ * it'd be added here; use vendor_oui and
+ * vendor_subnamespace to interpret the fields.
+ */
+ if (cpack_advance(&cpacker, skip_length) != 0) {
+ /*
+ * Ran out of space in the packet.
+ */
+ break;
+ }
+
+ /*
+ * We've skipped it all; nothing more to
+ * skip.
+ */
+ skip_length = 0;
+ } else {
+ if (print_in_radiotap_namespace(ndo, &cpacker,
+ &flags, presentflags, bit0) != 0) {
+ /*
+ * Fatal error - can't process anything
+ * more in the radiotap header.
+ */
+ break;
+ }
+ }
+
+ /*
+ * Handle the namespace switch bits; we've already handled
+ * the extension bit in all but the last word above.
+ */
+ switch (presentflags &
+ (BIT(IEEE80211_RADIOTAP_NAMESPACE)|BIT(IEEE80211_RADIOTAP_VENDOR_NAMESPACE))) {
- for (present = EXTRACT_LE_32BITS(presentp); present;
- present = next_present) {
- /* clear the least significant bit that is set */
- next_present = present & (present - 1);
+ case 0:
+ /*
+ * We're not changing namespaces.
+ * advance to the next 32 bits in the current
+ * namespace.
+ */
+ bit0 += 32;
+ break;
- /* extract the least significant bit that is set */
- bit = (enum ieee80211_radiotap_type)
- (bit0 + BITNO_32(present ^ next_present));
+ case BIT(IEEE80211_RADIOTAP_NAMESPACE):
+ /*
+ * We're switching to the radiotap namespace.
+ * Reset the presence-bitmap index to 0, and
+ * reset the namespace to the default radiotap
+ * namespace.
+ */
+ bit0 = 0;
+ vendor_namespace = 0;
+ memset(vendor_oui, 0, 3);
+ vendor_subnamespace = 0;
+ skip_length = 0;
+ break;
- if (print_radiotap_field(&cpacker, bit, &flags, &state, presentflags) != 0)
- goto out;
+ case BIT(IEEE80211_RADIOTAP_VENDOR_NAMESPACE):
+ /*
+ * We're switching to a vendor namespace.
+ * Reset the presence-bitmap index to 0,
+ * note that we're in a vendor namespace,
+ * and fetch the fields of the Vendor Namespace
+ * item.
+ */
+ bit0 = 0;
+ vendor_namespace = 1;
+ if ((cpack_align_and_reserve(&cpacker, 2)) == NULL) {
+ ND_PRINT((ndo, "%s", tstr));
+ break;
+ }
+ if (cpack_uint8(&cpacker, &vendor_oui[0]) != 0) {
+ ND_PRINT((ndo, "%s", tstr));
+ break;
+ }
+ if (cpack_uint8(&cpacker, &vendor_oui[1]) != 0) {
+ ND_PRINT((ndo, "%s", tstr));
+ break;
+ }
+ if (cpack_uint8(&cpacker, &vendor_oui[2]) != 0) {
+ ND_PRINT((ndo, "%s", tstr));
+ break;
+ }
+ if (cpack_uint8(&cpacker, &vendor_subnamespace) != 0) {
+ ND_PRINT((ndo, "%s", tstr));
+ break;
+ }
+ if (cpack_uint16(&cpacker, &skip_length) != 0) {
+ ND_PRINT((ndo, "%s", tstr));
+ break;
+ }
+ break;
+
+ default:
+ /*
+ * Illegal combination. The behavior in this
+ * case is undefined by the radiotap spec; we
+ * just ignore both bits.
+ */
+ break;
}
}
-out:
if (flags & IEEE80211_RADIOTAP_F_DATAPAD)
pad = 1; /* Atheros padding */
if (flags & IEEE80211_RADIOTAP_F_FCS)
fcslen = 4; /* FCS at end of packet */
- return len + ieee802_11_print(p + len, length - len, caplen - len, pad,
+ return len + ieee802_11_print(ndo, p + len, length - len, caplen - len, pad,
fcslen);
#undef BITNO_32
#undef BITNO_16
@@ -2293,12 +3283,13 @@ out:
}
static u_int
-ieee802_11_avs_radio_print(const u_char *p, u_int length, u_int caplen)
+ieee802_11_avs_radio_print(netdissect_options *ndo,
+ const u_char *p, u_int length, u_int caplen)
{
- u_int32_t caphdr_len;
+ uint32_t caphdr_len;
if (caplen < 8) {
- printf("[|802.11]");
+ ND_PRINT((ndo, "%s", tstr));
return caplen;
}
@@ -2309,16 +3300,16 @@ ieee802_11_avs_radio_print(const u_char *p, u_int length, u_int caplen)
* to be large enough to include even the version
* cookie or capture header length!
*/
- printf("[|802.11]");
+ ND_PRINT((ndo, "%s", tstr));
return caplen;
}
if (caplen < caphdr_len) {
- printf("[|802.11]");
+ ND_PRINT((ndo, "%s", tstr));
return caplen;
}
- return caphdr_len + ieee802_11_print(p + caphdr_len,
+ return caphdr_len + ieee802_11_print(ndo, p + caphdr_len,
length - caphdr_len, caplen - caphdr_len, 0, 0);
}
@@ -2342,28 +3333,29 @@ ieee802_11_avs_radio_print(const u_char *p, u_int length, u_int caplen)
* indicate whether it's a Prism header or an AVS header).
*/
u_int
-prism_if_print(const struct pcap_pkthdr *h, const u_char *p)
+prism_if_print(netdissect_options *ndo,
+ const struct pcap_pkthdr *h, const u_char *p)
{
u_int caplen = h->caplen;
u_int length = h->len;
- u_int32_t msgcode;
+ uint32_t msgcode;
if (caplen < 4) {
- printf("[|802.11]");
+ ND_PRINT((ndo, "%s", tstr));
return caplen;
}
msgcode = EXTRACT_32BITS(p);
if (msgcode == WLANCAP_MAGIC_COOKIE_V1 ||
msgcode == WLANCAP_MAGIC_COOKIE_V2)
- return ieee802_11_avs_radio_print(p, length, caplen);
+ return ieee802_11_avs_radio_print(ndo, p, length, caplen);
if (caplen < PRISM_HDR_LEN) {
- printf("[|802.11]");
+ ND_PRINT((ndo, "%s", tstr));
return caplen;
}
- return PRISM_HDR_LEN + ieee802_11_print(p + PRISM_HDR_LEN,
+ return PRISM_HDR_LEN + ieee802_11_print(ndo, p + PRISM_HDR_LEN,
length - PRISM_HDR_LEN, caplen - PRISM_HDR_LEN, 0, 0);
}
@@ -2372,9 +3364,10 @@ prism_if_print(const struct pcap_pkthdr *h, const u_char *p)
* header, containing information such as radio information.
*/
u_int
-ieee802_11_radio_if_print(const struct pcap_pkthdr *h, const u_char *p)
+ieee802_11_radio_if_print(netdissect_options *ndo,
+ const struct pcap_pkthdr *h, const u_char *p)
{
- return ieee802_11_radio_print(p, h->len, h->caplen);
+ return ieee802_11_radio_print(ndo, p, h->len, h->caplen);
}
/*
@@ -2383,7 +3376,11 @@ ieee802_11_radio_if_print(const struct pcap_pkthdr *h, const u_char *p)
* which we currently ignore.
*/
u_int
-ieee802_11_radio_avs_if_print(const struct pcap_pkthdr *h, const u_char *p)
+ieee802_11_radio_avs_if_print(netdissect_options *ndo,
+ const struct pcap_pkthdr *h, const u_char *p)
{
- return ieee802_11_avs_radio_print(p, h->len, h->caplen);
+ return ieee802_11_avs_radio_print(ndo, p, h->len, h->caplen);
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-802_11-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-802_15_4.c b/freebsd/contrib/tcpdump/print-802_15_4.c
index cd8ff8e6..9238e10c 100644
--- a/freebsd/contrib/tcpdump/print-802_15_4.c
+++ b/freebsd/contrib/tcpdump/print-802_15_4.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 2009
* Siemens AG, All rights reserved.
@@ -22,17 +25,15 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
+/* \summary: IEEE 802.15.4 printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
-
-#include <stdio.h>
-#include <pcap.h>
-#include <string.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "extract.h"
@@ -49,7 +50,7 @@ static const char *ftypes[] = {
};
static int
-extract_header_length(u_int16_t fc)
+extract_header_length(uint16_t fc)
{
int len = 0;
@@ -92,13 +93,13 @@ extract_header_length(u_int16_t fc)
u_int
-ieee802_15_4_if_print(struct netdissect_options *ndo,
+ieee802_15_4_if_print(netdissect_options *ndo,
const struct pcap_pkthdr *h, const u_char *p)
{
u_int caplen = h->caplen;
int hdrlen;
- u_int16_t fc;
- u_int8_t seq;
+ uint16_t fc;
+ uint8_t seq;
if (caplen < 3) {
ND_PRINT((ndo, "[|802.15.4] %x", caplen));
@@ -114,19 +115,19 @@ ieee802_15_4_if_print(struct netdissect_options *ndo,
caplen -= 3;
ND_PRINT((ndo,"IEEE 802.15.4 %s packet ", ftypes[fc & 0x7]));
- if (vflag)
+ if (ndo->ndo_vflag)
ND_PRINT((ndo,"seq %02x ", seq));
if (hdrlen == -1) {
- ND_PRINT((ndo,"malformed! "));
+ ND_PRINT((ndo,"invalid! "));
return caplen;
}
- if (!vflag) {
+ if (!ndo->ndo_vflag) {
p+= hdrlen;
caplen -= hdrlen;
} else {
- u_int16_t panid = 0;
+ uint16_t panid = 0;
switch ((fc >> 10) & 0x3) {
case 0x00:
@@ -144,11 +145,11 @@ ieee802_15_4_if_print(struct netdissect_options *ndo,
case 0x03:
panid = EXTRACT_LE_16BITS(p);
p += 2;
- ND_PRINT((ndo,"%04x:%s ", panid, le64addr_string(p)));
+ ND_PRINT((ndo,"%04x:%s ", panid, le64addr_string(ndo, p)));
p += 8;
break;
}
- ND_PRINT((ndo,"< ");
+ ND_PRINT((ndo,"< "));
switch ((fc >> 14) & 0x3) {
case 0x00:
@@ -170,7 +171,7 @@ ieee802_15_4_if_print(struct netdissect_options *ndo,
panid = EXTRACT_LE_16BITS(p);
p += 2;
}
- ND_PRINT((ndo,"%04x:%s ", panid, le64addr_string(p))));
+ ND_PRINT((ndo,"%04x:%s ", panid, le64addr_string(ndo, p)));
p += 8;
break;
}
@@ -178,8 +179,11 @@ ieee802_15_4_if_print(struct netdissect_options *ndo,
caplen -= hdrlen;
}
- if (!suppress_default_print)
- (ndo->ndo_default_print)(ndo, p, caplen);
+ if (!ndo->ndo_suppress_default_print)
+ ND_DEFAULTPRINT(p, caplen);
return 0;
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-802_15_4-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-ah.c b/freebsd/contrib/tcpdump/print-ah.c
index 0bc6b389..2d5f9e4c 100644
--- a/freebsd/contrib/tcpdump/print-ah.c
+++ b/freebsd/contrib/tcpdump/print-ah.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/* $NetBSD: print-ah.c,v 1.4 1996/05/20 00:41:16 fvdl Exp $ */
/*
@@ -23,51 +26,47 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ah.c,v 1.22 2003-11-19 00:36:06 guy Exp $ (LBL)";
-#endif
+/* \summary: IPSEC Authentication Header printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
-
-#include <stdio.h>
+#include <netdissect-stdinc.h>
#include "ah.h"
-#include "interface.h"
-#include "addrtoname.h"
+#include "netdissect.h"
#include "extract.h"
int
-ah_print(register const u_char *bp)
+ah_print(netdissect_options *ndo, register const u_char *bp)
{
register const struct ah *ah;
- register const u_char *ep;
int sumlen;
- u_int32_t spi;
ah = (const struct ah *)bp;
- ep = snapend; /* 'ep' points to the end of available data. */
- TCHECK(*ah);
+ ND_TCHECK(*ah);
sumlen = ah->ah_len << 2;
- spi = EXTRACT_32BITS(&ah->ah_spi);
- printf("AH(spi=0x%08x", spi);
- if (vflag)
- printf(",sumlen=%d", sumlen);
- printf(",seq=0x%x", EXTRACT_32BITS(ah + 1));
- if (bp + sizeof(struct ah) + sumlen > ep)
- fputs("[truncated]", stdout);
- fputs("): ", stdout);
+ ND_PRINT((ndo, "AH(spi=0x%08x", EXTRACT_32BITS(&ah->ah_spi)));
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo, ",sumlen=%d", sumlen));
+ ND_TCHECK_32BITS(ah + 1);
+ ND_PRINT((ndo, ",seq=0x%x", EXTRACT_32BITS(ah + 1)));
+ if (!ND_TTEST2(*bp, sizeof(struct ah) + sumlen)) {
+ ND_PRINT((ndo, "[truncated]):"));
+ return -1;
+ }
+ ND_PRINT((ndo, "): "));
return sizeof(struct ah) + sumlen;
trunc:
- fputs("[|AH]", stdout);
+ ND_PRINT((ndo, "[|AH]"));
return -1;
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-ah-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-ahcp.c b/freebsd/contrib/tcpdump/print-ahcp.c
new file mode 100644
index 00000000..80baba89
--- /dev/null
+++ b/freebsd/contrib/tcpdump/print-ahcp.c
@@ -0,0 +1,419 @@
+#include <machine/rtems-bsd-user-space.h>
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
+/*
+ * Copyright (c) 2013 The TCPDUMP project
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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
+ * COPYRIGHT HOLDER 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: Ad Hoc Configuration Protocol (AHCP) printer */
+
+/* Based on draft-chroboczek-ahcp-00 and source code of ahcpd-0.53 */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <netdissect-stdinc.h>
+
+#include "netdissect.h"
+#include "extract.h"
+#include "addrtoname.h"
+
+static const char tstr[] = " [|ahcp]";
+
+#define AHCP_MAGIC_NUMBER 43
+#define AHCP_VERSION_1 1
+#define AHCP1_HEADER_FIX_LEN 24
+#define AHCP1_BODY_MIN_LEN 4
+
+#define AHCP1_MSG_DISCOVER 0
+#define AHCP1_MSG_OFFER 1
+#define AHCP1_MSG_REQUEST 2
+#define AHCP1_MSG_ACK 3
+#define AHCP1_MSG_NACK 4
+#define AHCP1_MSG_RELEASE 5
+
+static const struct tok ahcp1_msg_str[] = {
+ { AHCP1_MSG_DISCOVER, "Discover" },
+ { AHCP1_MSG_OFFER, "Offer" },
+ { AHCP1_MSG_REQUEST, "Request" },
+ { AHCP1_MSG_ACK, "Ack" },
+ { AHCP1_MSG_NACK, "Nack" },
+ { AHCP1_MSG_RELEASE, "Release" },
+ { 0, NULL }
+};
+
+#define AHCP1_OPT_PAD 0
+#define AHCP1_OPT_MANDATORY 1
+#define AHCP1_OPT_ORIGIN_TIME 2
+#define AHCP1_OPT_EXPIRES 3
+#define AHCP1_OPT_MY_IPV6_ADDRESS 4
+#define AHCP1_OPT_MY_IPV4_ADDRESS 5
+#define AHCP1_OPT_IPV6_PREFIX 6
+#define AHCP1_OPT_IPV4_PREFIX 7
+#define AHCP1_OPT_IPV6_ADDRESS 8
+#define AHCP1_OPT_IPV4_ADDRESS 9
+#define AHCP1_OPT_IPV6_PREFIX_DELEGATION 10
+#define AHCP1_OPT_IPV4_PREFIX_DELEGATION 11
+#define AHCP1_OPT_NAME_SERVER 12
+#define AHCP1_OPT_NTP_SERVER 13
+#define AHCP1_OPT_MAX 13
+
+static const struct tok ahcp1_opt_str[] = {
+ { AHCP1_OPT_PAD, "Pad" },
+ { AHCP1_OPT_MANDATORY, "Mandatory" },
+ { AHCP1_OPT_ORIGIN_TIME, "Origin Time" },
+ { AHCP1_OPT_EXPIRES, "Expires" },
+ { AHCP1_OPT_MY_IPV6_ADDRESS, "My-IPv6-Address" },
+ { AHCP1_OPT_MY_IPV4_ADDRESS, "My-IPv4-Address" },
+ { AHCP1_OPT_IPV6_PREFIX, "IPv6 Prefix" },
+ { AHCP1_OPT_IPV4_PREFIX, "IPv4 Prefix" },
+ { AHCP1_OPT_IPV6_ADDRESS, "IPv6 Address" },
+ { AHCP1_OPT_IPV4_ADDRESS, "IPv4 Address" },
+ { AHCP1_OPT_IPV6_PREFIX_DELEGATION, "IPv6 Prefix Delegation" },
+ { AHCP1_OPT_IPV4_PREFIX_DELEGATION, "IPv4 Prefix Delegation" },
+ { AHCP1_OPT_NAME_SERVER, "Name Server" },
+ { AHCP1_OPT_NTP_SERVER, "NTP Server" },
+ { 0, NULL }
+};
+
+static int
+ahcp_time_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
+{
+ time_t t;
+ struct tm *tm;
+ char buf[BUFSIZE];
+
+ if (cp + 4 != ep)
+ goto invalid;
+ ND_TCHECK2(*cp, 4);
+ t = EXTRACT_32BITS(cp);
+ if (NULL == (tm = gmtime(&t)))
+ ND_PRINT((ndo, ": gmtime() error"));
+ else if (0 == strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", tm))
+ ND_PRINT((ndo, ": strftime() error"));
+ else
+ ND_PRINT((ndo, ": %s UTC", buf));
+ return 0;
+
+invalid:
+ ND_PRINT((ndo, "%s", istr));
+ ND_TCHECK2(*cp, ep - cp);
+ return 0;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return -1;
+}
+
+static int
+ahcp_seconds_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
+{
+ if (cp + 4 != ep)
+ goto invalid;
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, ": %us", EXTRACT_32BITS(cp)));
+ return 0;
+
+invalid:
+ ND_PRINT((ndo, "%s", istr));
+ ND_TCHECK2(*cp, ep - cp);
+ return 0;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return -1;
+}
+
+static int
+ahcp_ipv6_addresses_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
+{
+ const char *sep = ": ";
+
+ while (cp < ep) {
+ if (cp + 16 > ep)
+ goto invalid;
+ ND_TCHECK2(*cp, 16);
+ ND_PRINT((ndo, "%s%s", sep, ip6addr_string(ndo, cp)));
+ cp += 16;
+ sep = ", ";
+ }
+ return 0;
+
+invalid:
+ ND_PRINT((ndo, "%s", istr));
+ ND_TCHECK2(*cp, ep - cp);
+ return 0;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return -1;
+}
+
+static int
+ahcp_ipv4_addresses_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
+{
+ const char *sep = ": ";
+
+ while (cp < ep) {
+ if (cp + 4 > ep)
+ goto invalid;
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, "%s%s", sep, ipaddr_string(ndo, cp)));
+ cp += 4;
+ sep = ", ";
+ }
+ return 0;
+
+invalid:
+ ND_PRINT((ndo, "%s", istr));
+ ND_TCHECK2(*cp, ep - cp);
+ return 0;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return -1;
+}
+
+static int
+ahcp_ipv6_prefixes_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
+{
+ const char *sep = ": ";
+
+ while (cp < ep) {
+ if (cp + 17 > ep)
+ goto invalid;
+ ND_TCHECK2(*cp, 17);
+ ND_PRINT((ndo, "%s%s/%u", sep, ip6addr_string(ndo, cp), *(cp + 16)));
+ cp += 17;
+ sep = ", ";
+ }
+ return 0;
+
+invalid:
+ ND_PRINT((ndo, "%s", istr));
+ ND_TCHECK2(*cp, ep - cp);
+ return 0;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return -1;
+}
+
+static int
+ahcp_ipv4_prefixes_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
+{
+ const char *sep = ": ";
+
+ while (cp < ep) {
+ if (cp + 5 > ep)
+ goto invalid;
+ ND_TCHECK2(*cp, 5);
+ ND_PRINT((ndo, "%s%s/%u", sep, ipaddr_string(ndo, cp), *(cp + 4)));
+ cp += 5;
+ sep = ", ";
+ }
+ return 0;
+
+invalid:
+ ND_PRINT((ndo, "%s", istr));
+ ND_TCHECK2(*cp, ep - cp);
+ return 0;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return -1;
+}
+
+/* Data decoders signal truncated data with -1. */
+static int
+(* const data_decoders[AHCP1_OPT_MAX + 1])(netdissect_options *, const u_char *, const u_char *) = {
+ /* [AHCP1_OPT_PAD] = */ NULL,
+ /* [AHCP1_OPT_MANDATORY] = */ NULL,
+ /* [AHCP1_OPT_ORIGIN_TIME] = */ ahcp_time_print,
+ /* [AHCP1_OPT_EXPIRES] = */ ahcp_seconds_print,
+ /* [AHCP1_OPT_MY_IPV6_ADDRESS] = */ ahcp_ipv6_addresses_print,
+ /* [AHCP1_OPT_MY_IPV4_ADDRESS] = */ ahcp_ipv4_addresses_print,
+ /* [AHCP1_OPT_IPV6_PREFIX] = */ ahcp_ipv6_prefixes_print,
+ /* [AHCP1_OPT_IPV4_PREFIX] = */ NULL,
+ /* [AHCP1_OPT_IPV6_ADDRESS] = */ ahcp_ipv6_addresses_print,
+ /* [AHCP1_OPT_IPV4_ADDRESS] = */ ahcp_ipv4_addresses_print,
+ /* [AHCP1_OPT_IPV6_PREFIX_DELEGATION] = */ ahcp_ipv6_prefixes_print,
+ /* [AHCP1_OPT_IPV4_PREFIX_DELEGATION] = */ ahcp_ipv4_prefixes_print,
+ /* [AHCP1_OPT_NAME_SERVER] = */ ahcp_ipv6_addresses_print,
+ /* [AHCP1_OPT_NTP_SERVER] = */ ahcp_ipv6_addresses_print,
+};
+
+static void
+ahcp1_options_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
+{
+ uint8_t option_no, option_len;
+
+ while (cp < ep) {
+ /* Option no */
+ ND_TCHECK2(*cp, 1);
+ option_no = *cp;
+ cp += 1;
+ ND_PRINT((ndo, "\n\t %s", tok2str(ahcp1_opt_str, "Unknown-%u", option_no)));
+ if (option_no == AHCP1_OPT_PAD || option_no == AHCP1_OPT_MANDATORY)
+ continue;
+ /* Length */
+ if (cp + 1 > ep)
+ goto invalid;
+ ND_TCHECK2(*cp, 1);
+ option_len = *cp;
+ cp += 1;
+ if (cp + option_len > ep)
+ goto invalid;
+ /* Value */
+ if (option_no <= AHCP1_OPT_MAX && data_decoders[option_no] != NULL) {
+ if (data_decoders[option_no](ndo, cp, cp + option_len) < 0)
+ break; /* truncated and already marked up */
+ } else {
+ ND_PRINT((ndo, " (Length %u)", option_len));
+ ND_TCHECK2(*cp, option_len);
+ }
+ cp += option_len;
+ }
+ return;
+
+invalid:
+ ND_PRINT((ndo, "%s", istr));
+ ND_TCHECK2(*cp, ep - cp);
+ return;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+}
+
+static void
+ahcp1_body_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
+{
+ uint8_t type, mbz;
+ uint16_t body_len;
+
+ if (cp + AHCP1_BODY_MIN_LEN > ep)
+ goto invalid;
+ /* Type */
+ ND_TCHECK2(*cp, 1);
+ type = *cp;
+ cp += 1;
+ /* MBZ */
+ ND_TCHECK2(*cp, 1);
+ mbz = *cp;
+ cp += 1;
+ /* Length */
+ ND_TCHECK2(*cp, 2);
+ body_len = EXTRACT_16BITS(cp);
+ cp += 2;
+
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo, "\n\t%s", tok2str(ahcp1_msg_str, "Unknown-%u", type)));
+ if (mbz != 0)
+ ND_PRINT((ndo, ", MBZ %u", mbz));
+ ND_PRINT((ndo, ", Length %u", body_len));
+ }
+ if (cp + body_len > ep)
+ goto invalid;
+
+ /* Options */
+ if (ndo->ndo_vflag >= 2)
+ ahcp1_options_print(ndo, cp, cp + body_len); /* not ep (ignore extra data) */
+ else
+ ND_TCHECK2(*cp, body_len);
+ return;
+
+invalid:
+ ND_PRINT((ndo, "%s", istr));
+ ND_TCHECK2(*cp, ep - cp);
+ return;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+}
+
+void
+ahcp_print(netdissect_options *ndo, const u_char *cp, const u_int len)
+{
+ const u_char *ep = cp + len;
+ uint8_t version;
+
+ ND_PRINT((ndo, "AHCP"));
+ if (len < 2)
+ goto invalid;
+ /* Magic */
+ ND_TCHECK2(*cp, 1);
+ if (*cp != AHCP_MAGIC_NUMBER)
+ goto invalid;
+ cp += 1;
+ /* Version */
+ ND_TCHECK2(*cp, 1);
+ version = *cp;
+ cp += 1;
+ switch (version) {
+ case AHCP_VERSION_1: {
+ ND_PRINT((ndo, " Version 1"));
+ if (len < AHCP1_HEADER_FIX_LEN)
+ goto invalid;
+ if (!ndo->ndo_vflag) {
+ ND_TCHECK2(*cp, AHCP1_HEADER_FIX_LEN - 2);
+ cp += AHCP1_HEADER_FIX_LEN - 2;
+ } else {
+ /* Hopcount */
+ ND_TCHECK2(*cp, 1);
+ ND_PRINT((ndo, "\n\tHopcount %u", *cp));
+ cp += 1;
+ /* Original Hopcount */
+ ND_TCHECK2(*cp, 1);
+ ND_PRINT((ndo, ", Original Hopcount %u", *cp));
+ cp += 1;
+ /* Nonce */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, ", Nonce 0x%08x", EXTRACT_32BITS(cp)));
+ cp += 4;
+ /* Source Id */
+ ND_TCHECK2(*cp, 8);
+ ND_PRINT((ndo, ", Source Id %s", linkaddr_string(ndo, cp, 0, 8)));
+ cp += 8;
+ /* Destination Id */
+ ND_TCHECK2(*cp, 8);
+ ND_PRINT((ndo, ", Destination Id %s", linkaddr_string(ndo, cp, 0, 8)));
+ cp += 8;
+ }
+ /* Body */
+ ahcp1_body_print(ndo, cp, ep);
+ break;
+ }
+ default:
+ ND_PRINT((ndo, " Version %u (unknown)", version));
+ break;
+ }
+ return;
+
+invalid:
+ ND_PRINT((ndo, "%s", istr));
+ ND_TCHECK2(*cp, ep - cp);
+ return;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-ahcp-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-aodv.c b/freebsd/contrib/tcpdump/print-aodv.c
index a585a95a..665e6c7d 100644
--- a/freebsd/contrib/tcpdump/print-aodv.c
+++ b/freebsd/contrib/tcpdump/print-aodv.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 2003 Bruce M. Simpson <bms@spc.org>
* All rights reserved.
@@ -32,426 +35,506 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-aodv.c,v 1.11 2004-03-24 00:30:19 guy Exp $ (LBL)";
-#endif
+/* \summary: Ad hoc On-Demand Distance Vector (AODV) Routing printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
-
-#include <stddef.h>
-#include <stdio.h>
-#include <ctype.h>
-#include <string.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
-#include "extract.h" /* must come after interface.h */
-
-#include "aodv.h"
+#include "extract.h"
+
+
+struct aodv_rreq {
+ uint8_t rreq_type; /* AODV message type (1) */
+ uint8_t rreq_flags; /* various flags */
+ uint8_t rreq_zero0; /* reserved, set to zero */
+ uint8_t rreq_hops; /* number of hops from originator */
+ uint32_t rreq_id; /* request ID */
+ uint32_t rreq_da; /* destination IPv4 address */
+ uint32_t rreq_ds; /* destination sequence number */
+ uint32_t rreq_oa; /* originator IPv4 address */
+ uint32_t rreq_os; /* originator sequence number */
+};
+struct aodv_rreq6 {
+ uint8_t rreq_type; /* AODV message type (1) */
+ uint8_t rreq_flags; /* various flags */
+ uint8_t rreq_zero0; /* reserved, set to zero */
+ uint8_t rreq_hops; /* number of hops from originator */
+ uint32_t rreq_id; /* request ID */
+ struct in6_addr rreq_da; /* destination IPv6 address */
+ uint32_t rreq_ds; /* destination sequence number */
+ struct in6_addr rreq_oa; /* originator IPv6 address */
+ uint32_t rreq_os; /* originator sequence number */
+};
+struct aodv_rreq6_draft_01 {
+ uint8_t rreq_type; /* AODV message type (16) */
+ uint8_t rreq_flags; /* various flags */
+ uint8_t rreq_zero0; /* reserved, set to zero */
+ uint8_t rreq_hops; /* number of hops from originator */
+ uint32_t rreq_id; /* request ID */
+ uint32_t rreq_ds; /* destination sequence number */
+ uint32_t rreq_os; /* originator sequence number */
+ struct in6_addr rreq_da; /* destination IPv6 address */
+ struct in6_addr rreq_oa; /* originator IPv6 address */
+};
+
+#define RREQ_JOIN 0x80 /* join (reserved for multicast */
+#define RREQ_REPAIR 0x40 /* repair (reserved for multicast */
+#define RREQ_GRAT 0x20 /* gratuitous RREP */
+#define RREQ_DEST 0x10 /* destination only */
+#define RREQ_UNKNOWN 0x08 /* unknown destination sequence num */
+#define RREQ_FLAGS_MASK 0xF8 /* mask for rreq_flags */
+
+struct aodv_rrep {
+ uint8_t rrep_type; /* AODV message type (2) */
+ uint8_t rrep_flags; /* various flags */
+ uint8_t rrep_ps; /* prefix size */
+ uint8_t rrep_hops; /* number of hops from o to d */
+ uint32_t rrep_da; /* destination IPv4 address */
+ uint32_t rrep_ds; /* destination sequence number */
+ uint32_t rrep_oa; /* originator IPv4 address */
+ uint32_t rrep_life; /* lifetime of this route */
+};
+struct aodv_rrep6 {
+ uint8_t rrep_type; /* AODV message type (2) */
+ uint8_t rrep_flags; /* various flags */
+ uint8_t rrep_ps; /* prefix size */
+ uint8_t rrep_hops; /* number of hops from o to d */
+ struct in6_addr rrep_da; /* destination IPv6 address */
+ uint32_t rrep_ds; /* destination sequence number */
+ struct in6_addr rrep_oa; /* originator IPv6 address */
+ uint32_t rrep_life; /* lifetime of this route */
+};
+struct aodv_rrep6_draft_01 {
+ uint8_t rrep_type; /* AODV message type (17) */
+ uint8_t rrep_flags; /* various flags */
+ uint8_t rrep_ps; /* prefix size */
+ uint8_t rrep_hops; /* number of hops from o to d */
+ uint32_t rrep_ds; /* destination sequence number */
+ struct in6_addr rrep_da; /* destination IPv6 address */
+ struct in6_addr rrep_oa; /* originator IPv6 address */
+ uint32_t rrep_life; /* lifetime of this route */
+};
+
+#define RREP_REPAIR 0x80 /* repair (reserved for multicast */
+#define RREP_ACK 0x40 /* acknowledgement required */
+#define RREP_FLAGS_MASK 0xC0 /* mask for rrep_flags */
+#define RREP_PREFIX_MASK 0x1F /* mask for prefix size */
+
+struct rerr_unreach {
+ uint32_t u_da; /* IPv4 address */
+ uint32_t u_ds; /* sequence number */
+};
+struct rerr_unreach6 {
+ struct in6_addr u_da; /* IPv6 address */
+ uint32_t u_ds; /* sequence number */
+};
+struct rerr_unreach6_draft_01 {
+ struct in6_addr u_da; /* IPv6 address */
+ uint32_t u_ds; /* sequence number */
+};
+
+struct aodv_rerr {
+ uint8_t rerr_type; /* AODV message type (3 or 18) */
+ uint8_t rerr_flags; /* various flags */
+ uint8_t rerr_zero0; /* reserved, set to zero */
+ uint8_t rerr_dc; /* destination count */
+};
+
+#define RERR_NODELETE 0x80 /* don't delete the link */
+#define RERR_FLAGS_MASK 0x80 /* mask for rerr_flags */
+
+struct aodv_rrep_ack {
+ uint8_t ra_type;
+ uint8_t ra_zero0;
+};
+
+#define AODV_RREQ 1 /* route request */
+#define AODV_RREP 2 /* route response */
+#define AODV_RERR 3 /* error report */
+#define AODV_RREP_ACK 4 /* route response acknowledgement */
+
+#define AODV_V6_DRAFT_01_RREQ 16 /* IPv6 route request */
+#define AODV_V6_DRAFT_01_RREP 17 /* IPv6 route response */
+#define AODV_V6_DRAFT_01_RERR 18 /* IPv6 error report */
+#define AODV_V6_DRAFT_01_RREP_ACK 19 /* IPV6 route response acknowledgment */
+
+struct aodv_ext {
+ uint8_t type; /* extension type */
+ uint8_t length; /* extension length */
+};
+
+struct aodv_hello {
+ struct aodv_ext eh; /* extension header */
+ uint8_t interval[4]; /* expect my next hello in
+ * (n) ms
+ * NOTE: this is not aligned */
+};
+
+#define AODV_EXT_HELLO 1
static void
-aodv_extension(const struct aodv_ext *ep, u_int length)
+aodv_extension(netdissect_options *ndo,
+ const struct aodv_ext *ep, u_int length)
{
- u_int i;
const struct aodv_hello *ah;
switch (ep->type) {
case AODV_EXT_HELLO:
- if (snapend < (u_char *) ep) {
- printf(" [|hello]");
- return;
- }
- i = min(length, (u_int)(snapend - (u_char *)ep));
- if (i < sizeof(struct aodv_hello)) {
- printf(" [|hello]");
- return;
- }
- i -= sizeof(struct aodv_hello);
- ah = (void *)ep;
- printf("\n\text HELLO %ld ms",
- (unsigned long)EXTRACT_32BITS(&ah->interval));
+ ah = (const struct aodv_hello *)(const void *)ep;
+ ND_TCHECK(*ah);
+ if (length < sizeof(struct aodv_hello))
+ goto trunc;
+ ND_PRINT((ndo, "\n\text HELLO %ld ms",
+ (unsigned long)EXTRACT_32BITS(&ah->interval)));
break;
default:
- printf("\n\text %u %u", ep->type, ep->length);
+ ND_PRINT((ndo, "\n\text %u %u", ep->type, ep->length));
break;
}
+ return;
+
+trunc:
+ ND_PRINT((ndo, " [|hello]"));
}
static void
-aodv_rreq(const union aodv *ap, const u_char *dat, u_int length)
+aodv_rreq(netdissect_options *ndo, const u_char *dat, u_int length)
{
u_int i;
+ const struct aodv_rreq *ap = (const struct aodv_rreq *)dat;
- if (snapend < dat) {
- printf(" [|aodv]");
- return;
- }
- i = min(length, (u_int)(snapend - dat));
- if (i < sizeof(ap->rreq)) {
- printf(" [|rreq]");
- return;
- }
- i -= sizeof(ap->rreq);
- printf(" rreq %u %s%s%s%s%shops %u id 0x%08lx\n"
+ ND_TCHECK(*ap);
+ if (length < sizeof(*ap))
+ goto trunc;
+ ND_PRINT((ndo, " rreq %u %s%s%s%s%shops %u id 0x%08lx\n"
"\tdst %s seq %lu src %s seq %lu", length,
- ap->rreq.rreq_type & RREQ_JOIN ? "[J]" : "",
- ap->rreq.rreq_type & RREQ_REPAIR ? "[R]" : "",
- ap->rreq.rreq_type & RREQ_GRAT ? "[G]" : "",
- ap->rreq.rreq_type & RREQ_DEST ? "[D]" : "",
- ap->rreq.rreq_type & RREQ_UNKNOWN ? "[U] " : " ",
- ap->rreq.rreq_hops,
- (unsigned long)EXTRACT_32BITS(&ap->rreq.rreq_id),
- ipaddr_string(&ap->rreq.rreq_da),
- (unsigned long)EXTRACT_32BITS(&ap->rreq.rreq_ds),
- ipaddr_string(&ap->rreq.rreq_oa),
- (unsigned long)EXTRACT_32BITS(&ap->rreq.rreq_os));
+ ap->rreq_type & RREQ_JOIN ? "[J]" : "",
+ ap->rreq_type & RREQ_REPAIR ? "[R]" : "",
+ ap->rreq_type & RREQ_GRAT ? "[G]" : "",
+ ap->rreq_type & RREQ_DEST ? "[D]" : "",
+ ap->rreq_type & RREQ_UNKNOWN ? "[U] " : " ",
+ ap->rreq_hops,
+ (unsigned long)EXTRACT_32BITS(&ap->rreq_id),
+ ipaddr_string(ndo, &ap->rreq_da),
+ (unsigned long)EXTRACT_32BITS(&ap->rreq_ds),
+ ipaddr_string(ndo, &ap->rreq_oa),
+ (unsigned long)EXTRACT_32BITS(&ap->rreq_os)));
+ i = length - sizeof(*ap);
if (i >= sizeof(struct aodv_ext))
- aodv_extension((void *)(&ap->rreq + 1), i);
+ aodv_extension(ndo, (const struct aodv_ext *)(dat + sizeof(*ap)), i);
+ return;
+
+trunc:
+ ND_PRINT((ndo, " [|rreq"));
}
static void
-aodv_rrep(const union aodv *ap, const u_char *dat, u_int length)
+aodv_rrep(netdissect_options *ndo, const u_char *dat, u_int length)
{
u_int i;
+ const struct aodv_rrep *ap = (const struct aodv_rrep *)dat;
- if (snapend < dat) {
- printf(" [|aodv]");
- return;
- }
- i = min(length, (u_int)(snapend - dat));
- if (i < sizeof(ap->rrep)) {
- printf(" [|rrep]");
- return;
- }
- i -= sizeof(ap->rrep);
- printf(" rrep %u %s%sprefix %u hops %u\n"
+ ND_TCHECK(*ap);
+ if (length < sizeof(*ap))
+ goto trunc;
+ ND_PRINT((ndo, " rrep %u %s%sprefix %u hops %u\n"
"\tdst %s dseq %lu src %s %lu ms", length,
- ap->rrep.rrep_type & RREP_REPAIR ? "[R]" : "",
- ap->rrep.rrep_type & RREP_ACK ? "[A] " : " ",
- ap->rrep.rrep_ps & RREP_PREFIX_MASK,
- ap->rrep.rrep_hops,
- ipaddr_string(&ap->rrep.rrep_da),
- (unsigned long)EXTRACT_32BITS(&ap->rrep.rrep_ds),
- ipaddr_string(&ap->rrep.rrep_oa),
- (unsigned long)EXTRACT_32BITS(&ap->rrep.rrep_life));
+ ap->rrep_type & RREP_REPAIR ? "[R]" : "",
+ ap->rrep_type & RREP_ACK ? "[A] " : " ",
+ ap->rrep_ps & RREP_PREFIX_MASK,
+ ap->rrep_hops,
+ ipaddr_string(ndo, &ap->rrep_da),
+ (unsigned long)EXTRACT_32BITS(&ap->rrep_ds),
+ ipaddr_string(ndo, &ap->rrep_oa),
+ (unsigned long)EXTRACT_32BITS(&ap->rrep_life)));
+ i = length - sizeof(*ap);
if (i >= sizeof(struct aodv_ext))
- aodv_extension((void *)(&ap->rrep + 1), i);
+ aodv_extension(ndo, (const struct aodv_ext *)(dat + sizeof(*ap)), i);
+ return;
+
+trunc:
+ ND_PRINT((ndo, " [|rreq"));
}
static void
-aodv_rerr(const union aodv *ap, const u_char *dat, u_int length)
+aodv_rerr(netdissect_options *ndo, const u_char *dat, u_int length)
{
- u_int i;
- const struct rerr_unreach *dp = NULL;
- int n, trunc;
-
- if (snapend < dat) {
- printf(" [|aodv]");
- return;
- }
- i = min(length, (u_int)(snapend - dat));
- if (i < offsetof(struct aodv_rerr, r)) {
- printf(" [|rerr]");
- return;
+ u_int i, dc;
+ const struct aodv_rerr *ap = (const struct aodv_rerr *)dat;
+ const struct rerr_unreach *dp;
+
+ ND_TCHECK(*ap);
+ if (length < sizeof(*ap))
+ goto trunc;
+ ND_PRINT((ndo, " rerr %s [items %u] [%u]:",
+ ap->rerr_flags & RERR_NODELETE ? "[D]" : "",
+ ap->rerr_dc, length));
+ dp = (const struct rerr_unreach *)(dat + sizeof(*ap));
+ i = length - sizeof(*ap);
+ for (dc = ap->rerr_dc; dc != 0; dc--) {
+ ND_TCHECK(*dp);
+ if (i < sizeof(*dp))
+ goto trunc;
+ ND_PRINT((ndo, " {%s}(%ld)", ipaddr_string(ndo, &dp->u_da),
+ (unsigned long)EXTRACT_32BITS(&dp->u_ds)));
+ dp++;
+ i -= sizeof(*dp);
}
- i -= offsetof(struct aodv_rerr, r);
- dp = &ap->rerr.r.dest[0];
- n = ap->rerr.rerr_dc * sizeof(ap->rerr.r.dest[0]);
- printf(" rerr %s [items %u] [%u]:",
- ap->rerr.rerr_flags & RERR_NODELETE ? "[D]" : "",
- ap->rerr.rerr_dc, length);
- trunc = n - (i/sizeof(ap->rerr.r.dest[0]));
- for (; i >= sizeof(ap->rerr.r.dest[0]);
- ++dp, i -= sizeof(ap->rerr.r.dest[0])) {
- printf(" {%s}(%ld)", ipaddr_string(&dp->u_da),
- (unsigned long)EXTRACT_32BITS(&dp->u_ds));
- }
- if (trunc)
- printf("[|rerr]");
+ return;
+
+trunc:
+ ND_PRINT((ndo, "[|rerr]"));
}
static void
-#ifdef INET6
-aodv_v6_rreq(const union aodv *ap, const u_char *dat, u_int length)
-#else
-aodv_v6_rreq(const union aodv *ap _U_, const u_char *dat _U_, u_int length)
-#endif
+aodv_v6_rreq(netdissect_options *ndo, const u_char *dat, u_int length)
{
-#ifdef INET6
u_int i;
+ const struct aodv_rreq6 *ap = (const struct aodv_rreq6 *)dat;
- if (snapend < dat) {
- printf(" [|aodv]");
- return;
- }
- i = min(length, (u_int)(snapend - dat));
- if (i < sizeof(ap->rreq6)) {
- printf(" [|rreq6]");
- return;
- }
- i -= sizeof(ap->rreq6);
- printf(" v6 rreq %u %s%s%s%s%shops %u id 0x%08lx\n"
+ ND_TCHECK(*ap);
+ if (length < sizeof(*ap))
+ goto trunc;
+ ND_PRINT((ndo, " v6 rreq %u %s%s%s%s%shops %u id 0x%08lx\n"
"\tdst %s seq %lu src %s seq %lu", length,
- ap->rreq6.rreq_type & RREQ_JOIN ? "[J]" : "",
- ap->rreq6.rreq_type & RREQ_REPAIR ? "[R]" : "",
- ap->rreq6.rreq_type & RREQ_GRAT ? "[G]" : "",
- ap->rreq6.rreq_type & RREQ_DEST ? "[D]" : "",
- ap->rreq6.rreq_type & RREQ_UNKNOWN ? "[U] " : " ",
- ap->rreq6.rreq_hops,
- (unsigned long)EXTRACT_32BITS(&ap->rreq6.rreq_id),
- ip6addr_string(&ap->rreq6.rreq_da),
- (unsigned long)EXTRACT_32BITS(&ap->rreq6.rreq_ds),
- ip6addr_string(&ap->rreq6.rreq_oa),
- (unsigned long)EXTRACT_32BITS(&ap->rreq6.rreq_os));
+ ap->rreq_type & RREQ_JOIN ? "[J]" : "",
+ ap->rreq_type & RREQ_REPAIR ? "[R]" : "",
+ ap->rreq_type & RREQ_GRAT ? "[G]" : "",
+ ap->rreq_type & RREQ_DEST ? "[D]" : "",
+ ap->rreq_type & RREQ_UNKNOWN ? "[U] " : " ",
+ ap->rreq_hops,
+ (unsigned long)EXTRACT_32BITS(&ap->rreq_id),
+ ip6addr_string(ndo, &ap->rreq_da),
+ (unsigned long)EXTRACT_32BITS(&ap->rreq_ds),
+ ip6addr_string(ndo, &ap->rreq_oa),
+ (unsigned long)EXTRACT_32BITS(&ap->rreq_os)));
+ i = length - sizeof(*ap);
if (i >= sizeof(struct aodv_ext))
- aodv_extension((void *)(&ap->rreq6 + 1), i);
-#else
- printf(" v6 rreq %u", length);
-#endif
+ aodv_extension(ndo, (const struct aodv_ext *)(dat + sizeof(*ap)), i);
+ return;
+
+trunc:
+ ND_PRINT((ndo, " [|rreq"));
}
static void
-#ifdef INET6
-aodv_v6_rrep(const union aodv *ap, const u_char *dat, u_int length)
-#else
-aodv_v6_rrep(const union aodv *ap _U_, const u_char *dat _U_, u_int length)
-#endif
+aodv_v6_rrep(netdissect_options *ndo, const u_char *dat, u_int length)
{
-#ifdef INET6
u_int i;
+ const struct aodv_rrep6 *ap = (const struct aodv_rrep6 *)dat;
- if (snapend < dat) {
- printf(" [|aodv]");
- return;
- }
- i = min(length, (u_int)(snapend - dat));
- if (i < sizeof(ap->rrep6)) {
- printf(" [|rrep6]");
- return;
- }
- i -= sizeof(ap->rrep6);
- printf(" rrep %u %s%sprefix %u hops %u\n"
+ ND_TCHECK(*ap);
+ if (length < sizeof(*ap))
+ goto trunc;
+ ND_PRINT((ndo, " rrep %u %s%sprefix %u hops %u\n"
"\tdst %s dseq %lu src %s %lu ms", length,
- ap->rrep6.rrep_type & RREP_REPAIR ? "[R]" : "",
- ap->rrep6.rrep_type & RREP_ACK ? "[A] " : " ",
- ap->rrep6.rrep_ps & RREP_PREFIX_MASK,
- ap->rrep6.rrep_hops,
- ip6addr_string(&ap->rrep6.rrep_da),
- (unsigned long)EXTRACT_32BITS(&ap->rrep6.rrep_ds),
- ip6addr_string(&ap->rrep6.rrep_oa),
- (unsigned long)EXTRACT_32BITS(&ap->rrep6.rrep_life));
+ ap->rrep_type & RREP_REPAIR ? "[R]" : "",
+ ap->rrep_type & RREP_ACK ? "[A] " : " ",
+ ap->rrep_ps & RREP_PREFIX_MASK,
+ ap->rrep_hops,
+ ip6addr_string(ndo, &ap->rrep_da),
+ (unsigned long)EXTRACT_32BITS(&ap->rrep_ds),
+ ip6addr_string(ndo, &ap->rrep_oa),
+ (unsigned long)EXTRACT_32BITS(&ap->rrep_life)));
+ i = length - sizeof(*ap);
if (i >= sizeof(struct aodv_ext))
- aodv_extension((void *)(&ap->rrep6 + 1), i);
-#else
- printf(" rrep %u", length);
-#endif
+ aodv_extension(ndo, (const struct aodv_ext *)(dat + sizeof(*ap)), i);
+ return;
+
+trunc:
+ ND_PRINT((ndo, " [|rreq"));
}
static void
-#ifdef INET6
-aodv_v6_rerr(const union aodv *ap, u_int length)
-#else
-aodv_v6_rerr(const union aodv *ap _U_, u_int length)
-#endif
+aodv_v6_rerr(netdissect_options *ndo, const u_char *dat, u_int length)
{
-#ifdef INET6
- const struct rerr_unreach6 *dp6 = NULL;
- int i, j, n, trunc;
-
- i = length - offsetof(struct aodv_rerr, r);
- j = sizeof(ap->rerr.r.dest6[0]);
- dp6 = &ap->rerr.r.dest6[0];
- n = ap->rerr.rerr_dc * j;
- printf(" rerr %s [items %u] [%u]:",
- ap->rerr.rerr_flags & RERR_NODELETE ? "[D]" : "",
- ap->rerr.rerr_dc, length);
- trunc = n - (i/j);
- for (; i -= j >= 0; ++dp6) {
- printf(" {%s}(%ld)", ip6addr_string(&dp6->u_da),
- (unsigned long)EXTRACT_32BITS(&dp6->u_ds));
+ u_int i, dc;
+ const struct aodv_rerr *ap = (const struct aodv_rerr *)dat;
+ const struct rerr_unreach6 *dp6;
+
+ ND_TCHECK(*ap);
+ if (length < sizeof(*ap))
+ goto trunc;
+ ND_PRINT((ndo, " rerr %s [items %u] [%u]:",
+ ap->rerr_flags & RERR_NODELETE ? "[D]" : "",
+ ap->rerr_dc, length));
+ dp6 = (const struct rerr_unreach6 *)(const void *)(ap + 1);
+ i = length - sizeof(*ap);
+ for (dc = ap->rerr_dc; dc != 0; dc--) {
+ ND_TCHECK(*dp6);
+ if (i < sizeof(*dp6))
+ goto trunc;
+ ND_PRINT((ndo, " {%s}(%ld)", ip6addr_string(ndo, &dp6->u_da),
+ (unsigned long)EXTRACT_32BITS(&dp6->u_ds)));
+ dp6++;
+ i -= sizeof(*dp6);
}
- if (trunc)
- printf("[|rerr]");
-#else
- printf(" rerr %u", length);
-#endif
+ return;
+
+trunc:
+ ND_PRINT((ndo, "[|rerr]"));
}
static void
-#ifdef INET6
-aodv_v6_draft_01_rreq(const union aodv *ap, const u_char *dat, u_int length)
-#else
-aodv_v6_draft_01_rreq(const union aodv *ap _U_, const u_char *dat _U_,
- u_int length)
-#endif
+aodv_v6_draft_01_rreq(netdissect_options *ndo, const u_char *dat, u_int length)
{
-#ifdef INET6
u_int i;
+ const struct aodv_rreq6_draft_01 *ap = (const struct aodv_rreq6_draft_01 *)dat;
- if (snapend < dat) {
- printf(" [|aodv]");
- return;
- }
- i = min(length, (u_int)(snapend - dat));
- if (i < sizeof(ap->rreq6_draft_01)) {
- printf(" [|rreq6]");
- return;
- }
- i -= sizeof(ap->rreq6_draft_01);
- printf(" rreq %u %s%s%s%s%shops %u id 0x%08lx\n"
+ ND_TCHECK(*ap);
+ if (length < sizeof(*ap))
+ goto trunc;
+ ND_PRINT((ndo, " rreq %u %s%s%s%s%shops %u id 0x%08lx\n"
"\tdst %s seq %lu src %s seq %lu", length,
- ap->rreq6_draft_01.rreq_type & RREQ_JOIN ? "[J]" : "",
- ap->rreq6_draft_01.rreq_type & RREQ_REPAIR ? "[R]" : "",
- ap->rreq6_draft_01.rreq_type & RREQ_GRAT ? "[G]" : "",
- ap->rreq6_draft_01.rreq_type & RREQ_DEST ? "[D]" : "",
- ap->rreq6_draft_01.rreq_type & RREQ_UNKNOWN ? "[U] " : " ",
- ap->rreq6_draft_01.rreq_hops,
- (unsigned long)EXTRACT_32BITS(&ap->rreq6_draft_01.rreq_id),
- ip6addr_string(&ap->rreq6_draft_01.rreq_da),
- (unsigned long)EXTRACT_32BITS(&ap->rreq6_draft_01.rreq_ds),
- ip6addr_string(&ap->rreq6_draft_01.rreq_oa),
- (unsigned long)EXTRACT_32BITS(&ap->rreq6_draft_01.rreq_os));
+ ap->rreq_type & RREQ_JOIN ? "[J]" : "",
+ ap->rreq_type & RREQ_REPAIR ? "[R]" : "",
+ ap->rreq_type & RREQ_GRAT ? "[G]" : "",
+ ap->rreq_type & RREQ_DEST ? "[D]" : "",
+ ap->rreq_type & RREQ_UNKNOWN ? "[U] " : " ",
+ ap->rreq_hops,
+ (unsigned long)EXTRACT_32BITS(&ap->rreq_id),
+ ip6addr_string(ndo, &ap->rreq_da),
+ (unsigned long)EXTRACT_32BITS(&ap->rreq_ds),
+ ip6addr_string(ndo, &ap->rreq_oa),
+ (unsigned long)EXTRACT_32BITS(&ap->rreq_os)));
+ i = length - sizeof(*ap);
if (i >= sizeof(struct aodv_ext))
- aodv_extension((void *)(&ap->rreq6_draft_01 + 1), i);
-#else
- printf(" rreq %u", length);
-#endif
+ aodv_extension(ndo, (const struct aodv_ext *)(dat + sizeof(*ap)), i);
+ return;
+
+trunc:
+ ND_PRINT((ndo, " [|rreq"));
}
static void
-#ifdef INET6
-aodv_v6_draft_01_rrep(const union aodv *ap, const u_char *dat, u_int length)
-#else
-aodv_v6_draft_01_rrep(const union aodv *ap _U_, const u_char *dat _U_,
- u_int length)
-#endif
+aodv_v6_draft_01_rrep(netdissect_options *ndo, const u_char *dat, u_int length)
{
-#ifdef INET6
u_int i;
+ const struct aodv_rrep6_draft_01 *ap = (const struct aodv_rrep6_draft_01 *)dat;
- if (snapend < dat) {
- printf(" [|aodv]");
- return;
- }
- i = min(length, (u_int)(snapend - dat));
- if (i < sizeof(ap->rrep6_draft_01)) {
- printf(" [|rrep6]");
- return;
- }
- i -= sizeof(ap->rrep6_draft_01);
- printf(" rrep %u %s%sprefix %u hops %u\n"
+ ND_TCHECK(*ap);
+ if (length < sizeof(*ap))
+ goto trunc;
+ ND_PRINT((ndo, " rrep %u %s%sprefix %u hops %u\n"
"\tdst %s dseq %lu src %s %lu ms", length,
- ap->rrep6_draft_01.rrep_type & RREP_REPAIR ? "[R]" : "",
- ap->rrep6_draft_01.rrep_type & RREP_ACK ? "[A] " : " ",
- ap->rrep6_draft_01.rrep_ps & RREP_PREFIX_MASK,
- ap->rrep6_draft_01.rrep_hops,
- ip6addr_string(&ap->rrep6_draft_01.rrep_da),
- (unsigned long)EXTRACT_32BITS(&ap->rrep6_draft_01.rrep_ds),
- ip6addr_string(&ap->rrep6_draft_01.rrep_oa),
- (unsigned long)EXTRACT_32BITS(&ap->rrep6_draft_01.rrep_life));
+ ap->rrep_type & RREP_REPAIR ? "[R]" : "",
+ ap->rrep_type & RREP_ACK ? "[A] " : " ",
+ ap->rrep_ps & RREP_PREFIX_MASK,
+ ap->rrep_hops,
+ ip6addr_string(ndo, &ap->rrep_da),
+ (unsigned long)EXTRACT_32BITS(&ap->rrep_ds),
+ ip6addr_string(ndo, &ap->rrep_oa),
+ (unsigned long)EXTRACT_32BITS(&ap->rrep_life)));
+ i = length - sizeof(*ap);
if (i >= sizeof(struct aodv_ext))
- aodv_extension((void *)(&ap->rrep6_draft_01 + 1), i);
-#else
- printf(" rrep %u", length);
-#endif
+ aodv_extension(ndo, (const struct aodv_ext *)(dat + sizeof(*ap)), i);
+ return;
+
+trunc:
+ ND_PRINT((ndo, " [|rreq"));
}
static void
-#ifdef INET6
-aodv_v6_draft_01_rerr(const union aodv *ap, u_int length)
-#else
-aodv_v6_draft_01_rerr(const union aodv *ap _U_, u_int length)
-#endif
+aodv_v6_draft_01_rerr(netdissect_options *ndo, const u_char *dat, u_int length)
{
-#ifdef INET6
- const struct rerr_unreach6_draft_01 *dp6 = NULL;
- int i, j, n, trunc;
-
- i = length - offsetof(struct aodv_rerr, r);
- j = sizeof(ap->rerr.r.dest6_draft_01[0]);
- dp6 = &ap->rerr.r.dest6_draft_01[0];
- n = ap->rerr.rerr_dc * j;
- printf(" rerr %s [items %u] [%u]:",
- ap->rerr.rerr_flags & RERR_NODELETE ? "[D]" : "",
- ap->rerr.rerr_dc, length);
- trunc = n - (i/j);
- for (; i -= j >= 0; ++dp6) {
- printf(" {%s}(%ld)", ip6addr_string(&dp6->u_da),
- (unsigned long)EXTRACT_32BITS(&dp6->u_ds));
+ u_int i, dc;
+ const struct aodv_rerr *ap = (const struct aodv_rerr *)dat;
+ const struct rerr_unreach6_draft_01 *dp6;
+
+ ND_TCHECK(*ap);
+ if (length < sizeof(*ap))
+ goto trunc;
+ ND_PRINT((ndo, " rerr %s [items %u] [%u]:",
+ ap->rerr_flags & RERR_NODELETE ? "[D]" : "",
+ ap->rerr_dc, length));
+ dp6 = (const struct rerr_unreach6_draft_01 *)(const void *)(ap + 1);
+ i = length - sizeof(*ap);
+ for (dc = ap->rerr_dc; dc != 0; dc--) {
+ ND_TCHECK(*dp6);
+ if (i < sizeof(*dp6))
+ goto trunc;
+ ND_PRINT((ndo, " {%s}(%ld)", ip6addr_string(ndo, &dp6->u_da),
+ (unsigned long)EXTRACT_32BITS(&dp6->u_ds)));
+ dp6++;
+ i -= sizeof(*dp6);
}
- if (trunc)
- printf("[|rerr]");
-#else
- printf(" rerr %u", length);
-#endif
+ return;
+
+trunc:
+ ND_PRINT((ndo, "[|rerr]"));
}
void
-aodv_print(const u_char *dat, u_int length, int is_ip6)
+aodv_print(netdissect_options *ndo,
+ const u_char *dat, u_int length, int is_ip6)
{
- const union aodv *ap;
+ uint8_t msg_type;
- ap = (union aodv *)dat;
- if (snapend < dat) {
- printf(" [|aodv]");
- return;
- }
- if (min(length, (u_int)(snapend - dat)) < sizeof(ap->rrep_ack)) {
- printf(" [|aodv]");
- return;
- }
- printf(" aodv");
+ /*
+ * The message type is the first byte; make sure we have it
+ * and then fetch it.
+ */
+ ND_TCHECK(*dat);
+ msg_type = *dat;
+ ND_PRINT((ndo, " aodv"));
- switch (ap->rerr.rerr_type) {
+ switch (msg_type) {
case AODV_RREQ:
if (is_ip6)
- aodv_v6_rreq(ap, dat, length);
+ aodv_v6_rreq(ndo, dat, length);
else
- aodv_rreq(ap, dat, length);
+ aodv_rreq(ndo, dat, length);
break;
case AODV_RREP:
if (is_ip6)
- aodv_v6_rrep(ap, dat, length);
+ aodv_v6_rrep(ndo, dat, length);
else
- aodv_rrep(ap, dat, length);
+ aodv_rrep(ndo, dat, length);
break;
case AODV_RERR:
if (is_ip6)
- aodv_v6_rerr(ap, length);
+ aodv_v6_rerr(ndo, dat, length);
else
- aodv_rerr(ap, dat, length);
+ aodv_rerr(ndo, dat, length);
break;
case AODV_RREP_ACK:
- printf(" rrep-ack %u", length);
+ ND_PRINT((ndo, " rrep-ack %u", length));
break;
case AODV_V6_DRAFT_01_RREQ:
- aodv_v6_draft_01_rreq(ap, dat, length);
+ aodv_v6_draft_01_rreq(ndo, dat, length);
break;
case AODV_V6_DRAFT_01_RREP:
- aodv_v6_draft_01_rrep(ap, dat, length);
+ aodv_v6_draft_01_rrep(ndo, dat, length);
break;
case AODV_V6_DRAFT_01_RERR:
- aodv_v6_draft_01_rerr(ap, length);
+ aodv_v6_draft_01_rerr(ndo, dat, length);
break;
case AODV_V6_DRAFT_01_RREP_ACK:
- printf(" rrep-ack %u", length);
+ ND_PRINT((ndo, " rrep-ack %u", length));
break;
default:
- printf(" %u %u", ap->rreq.rreq_type, length);
+ ND_PRINT((ndo, " type %u %u", msg_type, length));
}
+ return;
+
+trunc:
+ ND_PRINT((ndo, " [|aodv]"));
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-aodv-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-aoe.c b/freebsd/contrib/tcpdump/print-aoe.c
new file mode 100644
index 00000000..1cd835a1
--- /dev/null
+++ b/freebsd/contrib/tcpdump/print-aoe.c
@@ -0,0 +1,438 @@
+#include <machine/rtems-bsd-user-space.h>
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
+/*
+ * Copyright (c) 2014 The TCPDUMP project
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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
+ * COPYRIGHT HOLDER 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: ATA over Ethernet (AoE) protocol printer */
+
+/* specification: http://brantleycoilecompany.com/AoEr11.pdf */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <netdissect-stdinc.h>
+
+#include "netdissect.h"
+#include "extract.h"
+#include "addrtoname.h"
+#include "ether.h"
+
+static const char tstr[] = " [|aoe]";
+
+#define AOE_V1 1
+#define ATA_SECTOR_SIZE 512
+
+#define AOEV1_CMD_ISSUE_ATA_COMMAND 0
+#define AOEV1_CMD_QUERY_CONFIG_INFORMATION 1
+#define AOEV1_CMD_MAC_MASK_LIST 2
+#define AOEV1_CMD_RESERVE_RELEASE 3
+
+static const struct tok cmdcode_str[] = {
+ { AOEV1_CMD_ISSUE_ATA_COMMAND, "Issue ATA Command" },
+ { AOEV1_CMD_QUERY_CONFIG_INFORMATION, "Query Config Information" },
+ { AOEV1_CMD_MAC_MASK_LIST, "MAC Mask List" },
+ { AOEV1_CMD_RESERVE_RELEASE, "Reserve/Release" },
+ { 0, NULL }
+};
+
+#define AOEV1_COMMON_HDR_LEN 10U /* up to but w/o Arg */
+#define AOEV1_ISSUE_ARG_LEN 12U /* up to but w/o Data */
+#define AOEV1_QUERY_ARG_LEN 8U /* up to but w/o Config String */
+#define AOEV1_MAC_ARG_LEN 4U /* up to but w/o Directive 0 */
+#define AOEV1_RESERVE_ARG_LEN 2U /* up to but w/o Ethernet address 0 */
+#define AOEV1_MAX_CONFSTR_LEN 1024U
+
+#define AOEV1_FLAG_R 0x08
+#define AOEV1_FLAG_E 0x04
+
+static const struct tok aoev1_flag_str[] = {
+ { AOEV1_FLAG_R, "Response" },
+ { AOEV1_FLAG_E, "Error" },
+ { 0x02, "MBZ-0x02" },
+ { 0x01, "MBZ-0x01" },
+ { 0, NULL }
+};
+
+static const struct tok aoev1_errcode_str[] = {
+ { 1, "Unrecognized command code" },
+ { 2, "Bad argument parameter" },
+ { 3, "Device unavailable" },
+ { 4, "Config string present" },
+ { 5, "Unsupported version" },
+ { 6, "Target is reserved" },
+ { 0, NULL }
+};
+
+#define AOEV1_AFLAG_E 0x40
+#define AOEV1_AFLAG_D 0x10
+#define AOEV1_AFLAG_A 0x02
+#define AOEV1_AFLAG_W 0x01
+
+static const struct tok aoev1_aflag_str[] = {
+ { 0x08, "MBZ-0x08" },
+ { AOEV1_AFLAG_E, "Ext48" },
+ { 0x06, "MBZ-0x06" },
+ { AOEV1_AFLAG_D, "Device" },
+ { 0x04, "MBZ-0x04" },
+ { 0x03, "MBZ-0x03" },
+ { AOEV1_AFLAG_A, "Async" },
+ { AOEV1_AFLAG_W, "Write" },
+ { 0, NULL }
+};
+
+static const struct tok aoev1_ccmd_str[] = {
+ { 0, "read config string" },
+ { 1, "test config string" },
+ { 2, "test config string prefix" },
+ { 3, "set config string" },
+ { 4, "force set config string" },
+ { 0, NULL }
+};
+
+static const struct tok aoev1_mcmd_str[] = {
+ { 0, "Read Mac Mask List" },
+ { 1, "Edit Mac Mask List" },
+ { 0, NULL }
+};
+
+static const struct tok aoev1_merror_str[] = {
+ { 1, "Unspecified Error" },
+ { 2, "Bad DCmd directive" },
+ { 3, "Mask list full" },
+ { 0, NULL }
+};
+
+static const struct tok aoev1_dcmd_str[] = {
+ { 0, "No Directive" },
+ { 1, "Add mac address to mask list" },
+ { 2, "Delete mac address from mask list" },
+ { 0, NULL }
+};
+
+static const struct tok aoev1_rcmd_str[] = {
+ { 0, "Read reserve list" },
+ { 1, "Set reserve list" },
+ { 2, "Force set reserve list" },
+ { 0, NULL }
+};
+
+static void
+aoev1_issue_print(netdissect_options *ndo,
+ const u_char *cp, const u_int len)
+{
+ const u_char *ep = cp + len;
+
+ if (len < AOEV1_ISSUE_ARG_LEN)
+ goto invalid;
+ /* AFlags */
+ ND_TCHECK2(*cp, 1);
+ ND_PRINT((ndo, "\n\tAFlags: [%s]", bittok2str(aoev1_aflag_str, "none", *cp)));
+ cp += 1;
+ /* Err/Feature */
+ ND_TCHECK2(*cp, 1);
+ ND_PRINT((ndo, ", Err/Feature: %u", *cp));
+ cp += 1;
+ /* Sector Count (not correlated with the length) */
+ ND_TCHECK2(*cp, 1);
+ ND_PRINT((ndo, ", Sector Count: %u", *cp));
+ cp += 1;
+ /* Cmd/Status */
+ ND_TCHECK2(*cp, 1);
+ ND_PRINT((ndo, ", Cmd/Status: %u", *cp));
+ cp += 1;
+ /* lba0 */
+ ND_TCHECK2(*cp, 1);
+ ND_PRINT((ndo, "\n\tlba0: %u", *cp));
+ cp += 1;
+ /* lba1 */
+ ND_TCHECK2(*cp, 1);
+ ND_PRINT((ndo, ", lba1: %u", *cp));
+ cp += 1;
+ /* lba2 */
+ ND_TCHECK2(*cp, 1);
+ ND_PRINT((ndo, ", lba2: %u", *cp));
+ cp += 1;
+ /* lba3 */
+ ND_TCHECK2(*cp, 1);
+ ND_PRINT((ndo, ", lba3: %u", *cp));
+ cp += 1;
+ /* lba4 */
+ ND_TCHECK2(*cp, 1);
+ ND_PRINT((ndo, ", lba4: %u", *cp));
+ cp += 1;
+ /* lba5 */
+ ND_TCHECK2(*cp, 1);
+ ND_PRINT((ndo, ", lba5: %u", *cp));
+ cp += 1;
+ /* Reserved */
+ ND_TCHECK2(*cp, 2);
+ cp += 2;
+ /* Data */
+ if (len > AOEV1_ISSUE_ARG_LEN)
+ ND_PRINT((ndo, "\n\tData: %u bytes", len - AOEV1_ISSUE_ARG_LEN));
+ return;
+
+invalid:
+ ND_PRINT((ndo, "%s", istr));
+ ND_TCHECK2(*cp, ep - cp);
+ return;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+}
+
+static void
+aoev1_query_print(netdissect_options *ndo,
+ const u_char *cp, const u_int len)
+{
+ const u_char *ep = cp + len;
+ uint16_t cslen;
+
+ if (len < AOEV1_QUERY_ARG_LEN)
+ goto invalid;
+ /* Buffer Count */
+ ND_TCHECK2(*cp, 2);
+ ND_PRINT((ndo, "\n\tBuffer Count: %u", EXTRACT_16BITS(cp)));
+ cp += 2;
+ /* Firmware Version */
+ ND_TCHECK2(*cp, 2);
+ ND_PRINT((ndo, ", Firmware Version: %u", EXTRACT_16BITS(cp)));
+ cp += 2;
+ /* Sector Count */
+ ND_TCHECK2(*cp, 1);
+ ND_PRINT((ndo, ", Sector Count: %u", *cp));
+ cp += 1;
+ /* AoE/CCmd */
+ ND_TCHECK2(*cp, 1);
+ ND_PRINT((ndo, ", AoE: %u, CCmd: %s", (*cp & 0xF0) >> 4,
+ tok2str(aoev1_ccmd_str, "Unknown (0x02x)", *cp & 0x0F)));
+ cp += 1;
+ /* Config String Length */
+ ND_TCHECK2(*cp, 2);
+ cslen = EXTRACT_16BITS(cp);
+ cp += 2;
+ if (cslen > AOEV1_MAX_CONFSTR_LEN || AOEV1_QUERY_ARG_LEN + cslen > len)
+ goto invalid;
+ /* Config String */
+ ND_TCHECK2(*cp, cslen);
+ if (cslen) {
+ ND_PRINT((ndo, "\n\tConfig String (length %u): ", cslen));
+ if (fn_printn(ndo, cp, cslen, ndo->ndo_snapend))
+ goto trunc;
+ }
+ return;
+
+invalid:
+ ND_PRINT((ndo, "%s", istr));
+ ND_TCHECK2(*cp, ep - cp);
+ return;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+}
+
+static void
+aoev1_mac_print(netdissect_options *ndo,
+ const u_char *cp, const u_int len)
+{
+ const u_char *ep = cp + len;
+ uint8_t dircount, i;
+
+ if (len < AOEV1_MAC_ARG_LEN)
+ goto invalid;
+ /* Reserved */
+ ND_TCHECK2(*cp, 1);
+ cp += 1;
+ /* MCmd */
+ ND_TCHECK2(*cp, 1);
+ ND_PRINT((ndo, "\n\tMCmd: %s", tok2str(aoev1_mcmd_str, "Unknown (0x%02x)", *cp)));
+ cp += 1;
+ /* MError */
+ ND_TCHECK2(*cp, 1);
+ ND_PRINT((ndo, ", MError: %s", tok2str(aoev1_merror_str, "Unknown (0x%02x)", *cp)));
+ cp += 1;
+ /* Dir Count */
+ ND_TCHECK2(*cp, 1);
+ dircount = *cp;
+ cp += 1;
+ ND_PRINT((ndo, ", Dir Count: %u", dircount));
+ if (AOEV1_MAC_ARG_LEN + dircount * 8 > len)
+ goto invalid;
+ /* directives */
+ for (i = 0; i < dircount; i++) {
+ /* Reserved */
+ ND_TCHECK2(*cp, 1);
+ cp += 1;
+ /* DCmd */
+ ND_TCHECK2(*cp, 1);
+ ND_PRINT((ndo, "\n\t DCmd: %s", tok2str(aoev1_dcmd_str, "Unknown (0x%02x)", *cp)));
+ cp += 1;
+ /* Ethernet Address */
+ ND_TCHECK2(*cp, ETHER_ADDR_LEN);
+ ND_PRINT((ndo, ", Ethernet Address: %s", etheraddr_string(ndo, cp)));
+ cp += ETHER_ADDR_LEN;
+ }
+ return;
+
+invalid:
+ ND_PRINT((ndo, "%s", istr));
+ ND_TCHECK2(*cp, ep - cp);
+ return;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+}
+
+static void
+aoev1_reserve_print(netdissect_options *ndo,
+ const u_char *cp, const u_int len)
+{
+ const u_char *ep = cp + len;
+ uint8_t nmacs, i;
+
+ if (len < AOEV1_RESERVE_ARG_LEN || (len - AOEV1_RESERVE_ARG_LEN) % ETHER_ADDR_LEN)
+ goto invalid;
+ /* RCmd */
+ ND_TCHECK2(*cp, 1);
+ ND_PRINT((ndo, "\n\tRCmd: %s", tok2str(aoev1_rcmd_str, "Unknown (0x%02x)", *cp)));
+ cp += 1;
+ /* NMacs (correlated with the length) */
+ ND_TCHECK2(*cp, 1);
+ nmacs = *cp;
+ cp += 1;
+ ND_PRINT((ndo, ", NMacs: %u", nmacs));
+ if (AOEV1_RESERVE_ARG_LEN + nmacs * ETHER_ADDR_LEN != len)
+ goto invalid;
+ /* addresses */
+ for (i = 0; i < nmacs; i++) {
+ ND_PRINT((ndo, "\n\tEthernet Address %u: %s", i, etheraddr_string(ndo, cp)));
+ cp += ETHER_ADDR_LEN;
+ }
+ return;
+
+invalid:
+ ND_PRINT((ndo, "%s", istr));
+ ND_TCHECK2(*cp, ep - cp);
+ return;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+}
+
+/* cp points to the Ver/Flags octet */
+static void
+aoev1_print(netdissect_options *ndo,
+ const u_char *cp, const u_int len)
+{
+ const u_char *ep = cp + len;
+ uint8_t flags, command;
+ void (*cmd_decoder)(netdissect_options *, const u_char *, const u_int);
+
+ if (len < AOEV1_COMMON_HDR_LEN)
+ goto invalid;
+ /* Flags */
+ flags = *cp & 0x0F;
+ ND_PRINT((ndo, ", Flags: [%s]", bittok2str(aoev1_flag_str, "none", flags)));
+ cp += 1;
+ if (! ndo->ndo_vflag)
+ return;
+ /* Error */
+ ND_TCHECK2(*cp, 1);
+ if (flags & AOEV1_FLAG_E)
+ ND_PRINT((ndo, "\n\tError: %s", tok2str(aoev1_errcode_str, "Invalid (%u)", *cp)));
+ cp += 1;
+ /* Major */
+ ND_TCHECK2(*cp, 2);
+ ND_PRINT((ndo, "\n\tMajor: 0x%04x", EXTRACT_16BITS(cp)));
+ cp += 2;
+ /* Minor */
+ ND_TCHECK2(*cp, 1);
+ ND_PRINT((ndo, ", Minor: 0x%02x", *cp));
+ cp += 1;
+ /* Command */
+ ND_TCHECK2(*cp, 1);
+ command = *cp;
+ cp += 1;
+ ND_PRINT((ndo, ", Command: %s", tok2str(cmdcode_str, "Unknown (0x%02x)", command)));
+ /* Tag */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, ", Tag: 0x%08x", EXTRACT_32BITS(cp)));
+ cp += 4;
+ /* Arg */
+ cmd_decoder =
+ command == AOEV1_CMD_ISSUE_ATA_COMMAND ? aoev1_issue_print :
+ command == AOEV1_CMD_QUERY_CONFIG_INFORMATION ? aoev1_query_print :
+ command == AOEV1_CMD_MAC_MASK_LIST ? aoev1_mac_print :
+ command == AOEV1_CMD_RESERVE_RELEASE ? aoev1_reserve_print :
+ NULL;
+ if (cmd_decoder != NULL)
+ cmd_decoder(ndo, cp, len - AOEV1_COMMON_HDR_LEN);
+ return;
+
+invalid:
+ ND_PRINT((ndo, "%s", istr));
+ ND_TCHECK2(*cp, ep - cp);
+ return;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+}
+
+void
+aoe_print(netdissect_options *ndo,
+ const u_char *cp, const u_int len)
+{
+ const u_char *ep = cp + len;
+ uint8_t ver;
+
+ ND_PRINT((ndo, "AoE length %u", len));
+
+ if (len < 1)
+ goto invalid;
+ /* Ver/Flags */
+ ND_TCHECK2(*cp, 1);
+ ver = (*cp & 0xF0) >> 4;
+ /* Don't advance cp yet: low order 4 bits are version-specific. */
+ ND_PRINT((ndo, ", Ver %u", ver));
+
+ switch (ver) {
+ case AOE_V1:
+ aoev1_print(ndo, cp, len);
+ break;
+ }
+ return;
+
+invalid:
+ ND_PRINT((ndo, "%s", istr));
+ ND_TCHECK2(*cp, ep - cp);
+ return;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+}
+
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-aoe-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-ap1394.c b/freebsd/contrib/tcpdump/print-ap1394.c
index 698b2123..f1438283 100644
--- a/freebsd/contrib/tcpdump/print-ap1394.c
+++ b/freebsd/contrib/tcpdump/print-ap1394.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2000
* The Regents of the University of California. All rights reserved.
@@ -20,21 +23,16 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ap1394.c,v 1.5 2006-02-11 22:12:06 hannes Exp $ (LBL)";
-#endif
+
+/* \summary: Apple IP-over-IEEE 1394 printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
-
-#include <stdio.h>
-#include <pcap.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
#include "addrtoname.h"
#include "ethertype.h"
@@ -56,28 +54,34 @@ struct firewire_header {
*/
#define FIREWIRE_HDRLEN 18
+static const char *
+fwaddr_string(netdissect_options *ndo, const u_char *addr)
+{
+ return (linkaddr_string(ndo, addr, LINKADDR_IEEE1394, FIREWIRE_EUI64_LEN));
+}
+
static inline void
-ap1394_hdr_print(register const u_char *bp, u_int length)
+ap1394_hdr_print(netdissect_options *ndo, register const u_char *bp, u_int length)
{
register const struct firewire_header *fp;
- u_int16_t firewire_type;
+ uint16_t firewire_type;
fp = (const struct firewire_header *)bp;
- (void)printf("%s > %s",
- linkaddr_string(fp->firewire_dhost, LINKADDR_IEEE1394, FIREWIRE_EUI64_LEN),
- linkaddr_string(fp->firewire_shost, LINKADDR_IEEE1394, FIREWIRE_EUI64_LEN));
+ ND_PRINT((ndo, "%s > %s",
+ fwaddr_string(ndo, fp->firewire_shost),
+ fwaddr_string(ndo, fp->firewire_dhost)));
firewire_type = EXTRACT_16BITS(&fp->firewire_type);
- if (!qflag) {
- (void)printf(", ethertype %s (0x%04x)",
+ if (!ndo->ndo_qflag) {
+ ND_PRINT((ndo, ", ethertype %s (0x%04x)",
tok2str(ethertype_values,"Unknown", firewire_type),
- firewire_type);
+ firewire_type));
} else {
- (void)printf(", %s", tok2str(ethertype_values,"Unknown Ethertype (0x%04x)", firewire_type));
+ ND_PRINT((ndo, ", %s", tok2str(ethertype_values,"Unknown Ethertype (0x%04x)", firewire_type)));
}
- (void)printf(", length %u: ", length);
+ ND_PRINT((ndo, ", length %u: ", length));
}
/*
@@ -87,35 +91,43 @@ ap1394_hdr_print(register const u_char *bp, u_int length)
* is the number of bytes actually captured.
*/
u_int
-ap1394_if_print(const struct pcap_pkthdr *h, const u_char *p)
+ap1394_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
{
u_int length = h->len;
u_int caplen = h->caplen;
- struct firewire_header *fp;
+ const struct firewire_header *fp;
u_short ether_type;
+ struct lladdr_info src, dst;
if (caplen < FIREWIRE_HDRLEN) {
- printf("[|ap1394]");
+ ND_PRINT((ndo, "[|ap1394]"));
return FIREWIRE_HDRLEN;
}
- if (eflag)
- ap1394_hdr_print(p, length);
+ if (ndo->ndo_eflag)
+ ap1394_hdr_print(ndo, p, length);
length -= FIREWIRE_HDRLEN;
caplen -= FIREWIRE_HDRLEN;
- fp = (struct firewire_header *)p;
+ fp = (const struct firewire_header *)p;
p += FIREWIRE_HDRLEN;
ether_type = EXTRACT_16BITS(&fp->firewire_type);
- if (ethertype_print(gndo, ether_type, p, length, caplen) == 0) {
+ src.addr = fp->firewire_shost;
+ src.addr_string = fwaddr_string;
+ dst.addr = fp->firewire_dhost;
+ dst.addr_string = fwaddr_string;
+ if (ethertype_print(ndo, ether_type, p, length, caplen, &src, &dst) == 0) {
/* ether_type not known, print raw packet */
- if (!eflag)
- ap1394_hdr_print((u_char *)fp, length + FIREWIRE_HDRLEN);
+ if (!ndo->ndo_eflag)
+ ap1394_hdr_print(ndo, (const u_char *)fp, length + FIREWIRE_HDRLEN);
- if (!suppress_default_print)
- default_print(p, caplen);
- }
+ if (!ndo->ndo_suppress_default_print)
+ ND_DEFAULTPRINT(p, caplen);
+ }
return FIREWIRE_HDRLEN;
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-ap1394-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-arcnet.c b/freebsd/contrib/tcpdump/print-arcnet.c
index 83bb8fb6..384f1444 100644
--- a/freebsd/contrib/tcpdump/print-arcnet.c
+++ b/freebsd/contrib/tcpdump/print-arcnet.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
@@ -22,28 +25,91 @@
*
* From: NetBSD: print-arcnet.c,v 1.2 2000/04/24 13:02:28 itojun Exp
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-arcnet.c,v 1.20 2005-04-06 21:32:38 mcr Exp $ (LBL)";
-#endif
+
+/* \summary: Attached Resource Computer NETwork (ARCNET) printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
-
-#include <stdio.h>
-#include <pcap.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
-#include "arcnet.h"
-static int arcnet_encap_print(u_char arctype, const u_char *p,
+/*
+ * from: NetBSD: if_arc.h,v 1.13 1999/11/19 20:41:19 thorpej Exp
+ */
+
+/*
+ * Structure of a 2.5MB/s Arcnet header on the BSDs,
+ * as given to interface code.
+ */
+struct arc_header {
+ uint8_t arc_shost;
+ uint8_t arc_dhost;
+ uint8_t arc_type;
+ /*
+ * only present for newstyle encoding with LL fragmentation.
+ * Don't use sizeof(anything), use ARC_HDR{,NEW}LEN instead.
+ */
+ uint8_t arc_flag;
+ uint16_t arc_seqid;
+
+ /*
+ * only present in exception packets (arc_flag == 0xff)
+ */
+ uint8_t arc_type2; /* same as arc_type */
+ uint8_t arc_flag2; /* real flag value */
+ uint16_t arc_seqid2; /* real seqid value */
+};
+
+#define ARC_HDRLEN 3
+#define ARC_HDRNEWLEN 6
+#define ARC_HDRNEWLEN_EXC 10
+
+/* RFC 1051 */
+#define ARCTYPE_IP_OLD 240 /* IP protocol */
+#define ARCTYPE_ARP_OLD 241 /* address resolution protocol */
+
+/* RFC 1201 */
+#define ARCTYPE_IP 212 /* IP protocol */
+#define ARCTYPE_ARP 213 /* address resolution protocol */
+#define ARCTYPE_REVARP 214 /* reverse addr resolution protocol */
+
+#define ARCTYPE_ATALK 221 /* Appletalk */
+#define ARCTYPE_BANIAN 247 /* Banyan Vines */
+#define ARCTYPE_IPX 250 /* Novell IPX */
+
+#define ARCTYPE_INET6 0xc4 /* IPng */
+#define ARCTYPE_DIAGNOSE 0x80 /* as per ANSI/ATA 878.1 */
+
+/*
+ * Structure of a 2.5MB/s Arcnet header on Linux. Linux has
+ * an extra "offset" field when given to interface code, and
+ * never presents packets that look like exception frames.
+ */
+struct arc_linux_header {
+ uint8_t arc_shost;
+ uint8_t arc_dhost;
+ uint16_t arc_offset;
+ uint8_t arc_type;
+ /*
+ * only present for newstyle encoding with LL fragmentation.
+ * Don't use sizeof(anything), use ARC_LINUX_HDR{,NEW}LEN
+ * instead.
+ */
+ uint8_t arc_flag;
+ uint16_t arc_seqid;
+};
+
+#define ARC_LINUX_HDRLEN 5
+#define ARC_LINUX_HDRNEWLEN 8
+
+static int arcnet_encap_print(netdissect_options *, u_char arctype, const u_char *p,
u_int length, u_int caplen);
-struct tok arctypemap[] = {
+static const struct tok arctypemap[] = {
{ ARCTYPE_IP_OLD, "oldip" },
{ ARCTYPE_ARP_OLD, "oldarp" },
{ ARCTYPE_IP, "ip" },
@@ -58,7 +124,8 @@ struct tok arctypemap[] = {
};
static inline void
-arcnet_print(const u_char *bp, u_int length, int phds, int flag, u_int seqid)
+arcnet_print(netdissect_options *ndo, const u_char *bp, u_int length, int phds,
+ int flag, u_int seqid)
{
const struct arc_header *ap;
const char *arctypename;
@@ -67,40 +134,40 @@ arcnet_print(const u_char *bp, u_int length, int phds, int flag, u_int seqid)
ap = (const struct arc_header *)bp;
- if (qflag) {
- (void)printf("%02x %02x %d: ",
+ if (ndo->ndo_qflag) {
+ ND_PRINT((ndo, "%02x %02x %d: ",
ap->arc_shost,
ap->arc_dhost,
- length);
+ length));
return;
}
arctypename = tok2str(arctypemap, "%02x", ap->arc_type);
if (!phds) {
- (void)printf("%02x %02x %s %d: ",
+ ND_PRINT((ndo, "%02x %02x %s %d: ",
ap->arc_shost, ap->arc_dhost, arctypename,
- length);
+ length));
return;
}
if (flag == 0) {
- (void)printf("%02x %02x %s seqid %04x %d: ",
+ ND_PRINT((ndo, "%02x %02x %s seqid %04x %d: ",
ap->arc_shost, ap->arc_dhost, arctypename, seqid,
- length);
+ length));
return;
}
if (flag & 1)
- (void)printf("%02x %02x %s seqid %04x "
+ ND_PRINT((ndo, "%02x %02x %s seqid %04x "
"(first of %d fragments) %d: ",
ap->arc_shost, ap->arc_dhost, arctypename, seqid,
- (flag + 3) / 2, length);
+ (flag + 3) / 2, length));
else
- (void)printf("%02x %02x %s seqid %04x "
+ ND_PRINT((ndo, "%02x %02x %s seqid %04x "
"(fragment %d) %d: ",
ap->arc_shost, ap->arc_dhost, arctypename, seqid,
- flag/2 + 1, length);
+ flag/2 + 1, length));
}
/*
@@ -110,7 +177,7 @@ arcnet_print(const u_char *bp, u_int length, int phds, int flag, u_int seqid)
* is the number of bytes actually captured.
*/
u_int
-arcnet_if_print(const struct pcap_pkthdr *h, const u_char *p)
+arcnet_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
{
u_int caplen = h->caplen;
u_int length = h->len;
@@ -120,8 +187,8 @@ arcnet_if_print(const struct pcap_pkthdr *h, const u_char *p)
u_int seqid = 0;
u_char arc_type;
- if (caplen < ARC_HDRLEN) {
- printf("[|arcnet]");
+ if (caplen < ARC_HDRLEN || length < ARC_HDRLEN) {
+ ND_PRINT((ndo, "[|arcnet]"));
return (caplen);
}
@@ -141,16 +208,16 @@ arcnet_if_print(const struct pcap_pkthdr *h, const u_char *p)
}
if (phds) {
- if (caplen < ARC_HDRNEWLEN) {
- arcnet_print(p, length, 0, 0, 0);
- printf("[|phds]");
+ if (caplen < ARC_HDRNEWLEN || length < ARC_HDRNEWLEN) {
+ arcnet_print(ndo, p, length, 0, 0, 0);
+ ND_PRINT((ndo, "[|phds]"));
return (caplen);
}
if (ap->arc_flag == 0xff) {
- if (caplen < ARC_HDRNEWLEN_EXC) {
- arcnet_print(p, length, 0, 0, 0);
- printf("[|phds extended]");
+ if (caplen < ARC_HDRNEWLEN_EXC || length < ARC_HDRNEWLEN_EXC) {
+ arcnet_print(ndo, p, length, 0, 0, 0);
+ ND_PRINT((ndo, "[|phds extended]"));
return (caplen);
}
flag = ap->arc_flag2;
@@ -164,8 +231,8 @@ arcnet_if_print(const struct pcap_pkthdr *h, const u_char *p)
}
- if (eflag)
- arcnet_print(p, length, phds, flag, seqid);
+ if (ndo->ndo_eflag)
+ arcnet_print(ndo, p, length, phds, flag, seqid);
/*
* Go past the ARCNET header.
@@ -181,8 +248,8 @@ arcnet_if_print(const struct pcap_pkthdr *h, const u_char *p)
return (archdrlen);
}
- if (!arcnet_encap_print(arc_type, p, length, caplen))
- default_print(p, caplen);
+ if (!arcnet_encap_print(ndo, arc_type, p, length, caplen))
+ ND_DEFAULTPRINT(p, caplen);
return (archdrlen);
}
@@ -198,7 +265,7 @@ arcnet_if_print(const struct pcap_pkthdr *h, const u_char *p)
* extra "offset" field between the src/dest and packet type.
*/
u_int
-arcnet_linux_if_print(const struct pcap_pkthdr *h, const u_char *p)
+arcnet_linux_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
{
u_int caplen = h->caplen;
u_int length = h->len;
@@ -207,8 +274,8 @@ arcnet_linux_if_print(const struct pcap_pkthdr *h, const u_char *p)
int archdrlen = 0;
u_char arc_type;
- if (caplen < ARC_LINUX_HDRLEN) {
- printf("[|arcnet]");
+ if (caplen < ARC_LINUX_HDRLEN || length < ARC_LINUX_HDRLEN) {
+ ND_PRINT((ndo, "[|arcnet]"));
return (caplen);
}
@@ -218,8 +285,8 @@ arcnet_linux_if_print(const struct pcap_pkthdr *h, const u_char *p)
switch (arc_type) {
default:
archdrlen = ARC_LINUX_HDRNEWLEN;
- if (caplen < ARC_LINUX_HDRNEWLEN) {
- printf("[|arcnet]");
+ if (caplen < ARC_LINUX_HDRNEWLEN || length < ARC_LINUX_HDRNEWLEN) {
+ ND_PRINT((ndo, "[|arcnet]"));
return (caplen);
}
break;
@@ -230,8 +297,8 @@ arcnet_linux_if_print(const struct pcap_pkthdr *h, const u_char *p)
break;
}
- if (eflag)
- arcnet_print(p, length, 0, 0, 0);
+ if (ndo->ndo_eflag)
+ arcnet_print(ndo, p, length, 0, 0, 0);
/*
* Go past the ARCNET header.
@@ -240,8 +307,8 @@ arcnet_linux_if_print(const struct pcap_pkthdr *h, const u_char *p)
caplen -= archdrlen;
p += archdrlen;
- if (!arcnet_encap_print(arc_type, p, length, caplen))
- default_print(p, caplen);
+ if (!arcnet_encap_print(ndo, arc_type, p, length, caplen))
+ ND_DEFAULTPRINT(p, caplen);
return (archdrlen);
}
@@ -255,36 +322,34 @@ arcnet_linux_if_print(const struct pcap_pkthdr *h, const u_char *p)
static int
-arcnet_encap_print(u_char arctype, const u_char *p,
+arcnet_encap_print(netdissect_options *ndo, u_char arctype, const u_char *p,
u_int length, u_int caplen)
{
switch (arctype) {
case ARCTYPE_IP_OLD:
case ARCTYPE_IP:
- ip_print(gndo, p, length);
+ ip_print(ndo, p, length);
return (1);
-#ifdef INET6
case ARCTYPE_INET6:
- ip6_print(gndo, p, length);
+ ip6_print(ndo, p, length);
return (1);
-#endif /*INET6*/
case ARCTYPE_ARP_OLD:
case ARCTYPE_ARP:
case ARCTYPE_REVARP:
- arp_print(gndo, p, length, caplen);
+ arp_print(ndo, p, length, caplen);
return (1);
case ARCTYPE_ATALK: /* XXX was this ever used? */
- if (vflag)
- fputs("et1 ", stdout);
- atalk_print(p, length);
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo, "et1 "));
+ atalk_print(ndo, p, length);
return (1);
case ARCTYPE_IPX:
- ipx_print(p, length);
+ ipx_print(ndo, p, length);
return (1);
default:
@@ -298,3 +363,6 @@ arcnet_encap_print(u_char arctype, const u_char *p,
* End:
*/
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-arcnet-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-arp.c b/freebsd/contrib/tcpdump/print-arp.c
index ac85cf96..487fa300 100644
--- a/freebsd/contrib/tcpdump/print-arp.c
+++ b/freebsd/contrib/tcpdump/print-arp.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
@@ -19,29 +22,25 @@
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * $FreeBSD$
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-arp.c,v 1.66 2006-03-03 22:53:21 hannes Exp $ (LBL)";
-#endif
+/* \summary: Address Resolution Protocol (ARP) printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include <stdio.h>
#include <string.h>
#include "netdissect.h"
#include "addrtoname.h"
#include "ether.h"
#include "ethertype.h"
-#include "extract.h" /* must come after interface.h */
+#include "extract.h"
+
+static const char tstr[] = "[|ARP]";
/*
* Address Resolution Protocol.
@@ -103,7 +102,7 @@ struct arp_pkthdr {
#define TPA(ap) (ar_tpa(ap))
-struct tok arpop_values[] = {
+static const struct tok arpop_values[] = {
{ ARPOP_REQUEST, "Request" },
{ ARPOP_REPLY, "Reply" },
{ ARPOP_REVREQUEST, "Reverse Request" },
@@ -114,7 +113,7 @@ struct tok arpop_values[] = {
{ 0, NULL }
};
-struct tok arphrd_values[] = {
+static const struct tok arphrd_values[] = {
{ ARPHRD_ETHER, "Ethernet" },
{ ARPHRD_IEEE802, "TokenRing" },
{ ARPHRD_ARCNET, "ArcNet" },
@@ -183,7 +182,17 @@ struct atmarp_pkthdr {
#define ATMTSA(ap) (aar_tsa(ap))
#define ATMTPA(ap) (aar_tpa(ap))
-static u_char ezero[6];
+static int
+isnonzero(const u_char *a, size_t len)
+{
+ while (len > 0) {
+ if (*a != 0)
+ return (1);
+ a++;
+ len--;
+ }
+ return (0);
+}
static void
atmarp_addr_print(netdissect_options *ndo,
@@ -193,10 +202,10 @@ atmarp_addr_print(netdissect_options *ndo,
if (ha_len == 0)
ND_PRINT((ndo, "<No address>"));
else {
- ND_PRINT((ndo, "%s", linkaddr_string(ha, LINKADDR_ATM, ha_len)));
- if (srca_len != 0)
+ ND_PRINT((ndo, "%s", linkaddr_string(ndo, ha, LINKADDR_ATM, ha_len)));
+ if (srca_len != 0)
ND_PRINT((ndo, ",%s",
- linkaddr_string(srca, LINKADDR_ATM, srca_len)));
+ linkaddr_string(ndo, srca, LINKADDR_ATM, srca_len)));
}
}
@@ -215,7 +224,7 @@ atmarp_print(netdissect_options *ndo,
op = ATMOP(ap);
if (!ND_TTEST2(*aar_tpa(ap), ATMTPROTO_LEN(ap))) {
- ND_PRINT((ndo, "[|ARP]"));
+ ND_PRINT((ndo, "%s", tstr));
ND_DEFAULTPRINT((const u_char *)ap, length);
return;
}
@@ -241,25 +250,25 @@ atmarp_print(netdissect_options *ndo,
}
/* print operation */
- printf("%s%s ",
- ndo->ndo_vflag ? ", " : "",
- tok2str(arpop_values, "Unknown (%u)", op));
+ ND_PRINT((ndo, "%s%s ",
+ ndo->ndo_vflag ? ", " : "",
+ tok2str(arpop_values, "Unknown (%u)", op)));
switch (op) {
case ARPOP_REQUEST:
- ND_PRINT((ndo, "who-has %s", ipaddr_string(ATMTPA(ap))));
+ ND_PRINT((ndo, "who-has %s", ipaddr_string(ndo, ATMTPA(ap))));
if (ATMTHRD_LEN(ap) != 0) {
ND_PRINT((ndo, " ("));
atmarp_addr_print(ndo, ATMTHA(ap), ATMTHRD_LEN(ap),
ATMTSA(ap), ATMTSLN(ap));
ND_PRINT((ndo, ")"));
}
- ND_PRINT((ndo, "tell %s", ipaddr_string(ATMSPA(ap))));
+ ND_PRINT((ndo, "tell %s", ipaddr_string(ndo, ATMSPA(ap))));
break;
case ARPOP_REPLY:
- ND_PRINT((ndo, "%s is-at ", ipaddr_string(ATMSPA(ap))));
+ ND_PRINT((ndo, "%s is-at ", ipaddr_string(ndo, ATMSPA(ap))));
atmarp_addr_print(ndo, ATMSHA(ap), ATMSHRD_LEN(ap), ATMSSA(ap),
ATMSSLN(ap));
break;
@@ -276,11 +285,11 @@ atmarp_print(netdissect_options *ndo,
case ARPOP_INVREPLY:
atmarp_addr_print(ndo, ATMSHA(ap), ATMSHRD_LEN(ap), ATMSSA(ap),
ATMSSLN(ap));
- ND_PRINT((ndo, "at %s", ipaddr_string(ATMSPA(ap))));
+ ND_PRINT((ndo, "at %s", ipaddr_string(ndo, ATMSPA(ap))));
break;
case ARPOP_NAK:
- ND_PRINT((ndo, "for %s", ipaddr_string(ATMSPA(ap))));
+ ND_PRINT((ndo, "for %s", ipaddr_string(ndo, ATMSPA(ap))));
break;
default:
@@ -293,7 +302,7 @@ atmarp_print(netdissect_options *ndo,
return;
trunc:
- ND_PRINT((ndo, "[|ARP]"));
+ ND_PRINT((ndo, "%s", tstr));
}
void
@@ -310,11 +319,11 @@ arp_print(netdissect_options *ndo,
pro = PRO(ap);
op = OP(ap);
-
+
/* if its ATM then call the ATM ARP printer
for Frame-relay ARP most of the fields
are similar to Ethernet so overload the Ethernet Printer
- and set the linkaddr type for linkaddr_string() accordingly */
+ and set the linkaddr type for linkaddr_string(ndo, ) accordingly */
switch(hrd) {
case ARPHRD_ATM2225:
@@ -329,7 +338,7 @@ arp_print(netdissect_options *ndo,
}
if (!ND_TTEST2(*ar_tpa(ap), PROTO_LEN(ap))) {
- ND_PRINT((ndo, "[|ARP]"));
+ ND_PRINT((ndo, "%s", tstr));
ND_DEFAULTPRINT((const u_char *)ap, length);
return;
}
@@ -356,48 +365,48 @@ arp_print(netdissect_options *ndo,
}
/* print operation */
- printf("%s%s ",
- ndo->ndo_vflag ? ", " : "",
- tok2str(arpop_values, "Unknown (%u)", op));
+ ND_PRINT((ndo, "%s%s ",
+ ndo->ndo_vflag ? ", " : "",
+ tok2str(arpop_values, "Unknown (%u)", op)));
switch (op) {
case ARPOP_REQUEST:
- ND_PRINT((ndo, "who-has %s", ipaddr_string(TPA(ap))));
- if (memcmp((const char *)ezero, (const char *)THA(ap), HRD_LEN(ap)) != 0)
+ ND_PRINT((ndo, "who-has %s", ipaddr_string(ndo, TPA(ap))));
+ if (isnonzero((const u_char *)THA(ap), HRD_LEN(ap)))
ND_PRINT((ndo, " (%s)",
- linkaddr_string(THA(ap), linkaddr, HRD_LEN(ap))));
- ND_PRINT((ndo, " tell %s", ipaddr_string(SPA(ap))));
+ linkaddr_string(ndo, THA(ap), linkaddr, HRD_LEN(ap))));
+ ND_PRINT((ndo, " tell %s", ipaddr_string(ndo, SPA(ap))));
break;
case ARPOP_REPLY:
ND_PRINT((ndo, "%s is-at %s",
- ipaddr_string(SPA(ap)),
- linkaddr_string(SHA(ap), linkaddr, HRD_LEN(ap))));
+ ipaddr_string(ndo, SPA(ap)),
+ linkaddr_string(ndo, SHA(ap), linkaddr, HRD_LEN(ap))));
break;
case ARPOP_REVREQUEST:
ND_PRINT((ndo, "who-is %s tell %s",
- linkaddr_string(THA(ap), linkaddr, HRD_LEN(ap)),
- linkaddr_string(SHA(ap), linkaddr, HRD_LEN(ap))));
+ linkaddr_string(ndo, THA(ap), linkaddr, HRD_LEN(ap)),
+ linkaddr_string(ndo, SHA(ap), linkaddr, HRD_LEN(ap))));
break;
case ARPOP_REVREPLY:
ND_PRINT((ndo, "%s at %s",
- linkaddr_string(THA(ap), linkaddr, HRD_LEN(ap)),
- ipaddr_string(TPA(ap))));
+ linkaddr_string(ndo, THA(ap), linkaddr, HRD_LEN(ap)),
+ ipaddr_string(ndo, TPA(ap))));
break;
case ARPOP_INVREQUEST:
ND_PRINT((ndo, "who-is %s tell %s",
- linkaddr_string(THA(ap), linkaddr, HRD_LEN(ap)),
- linkaddr_string(SHA(ap), linkaddr, HRD_LEN(ap))));
+ linkaddr_string(ndo, THA(ap), linkaddr, HRD_LEN(ap)),
+ linkaddr_string(ndo, SHA(ap), linkaddr, HRD_LEN(ap))));
break;
case ARPOP_INVREPLY:
ND_PRINT((ndo,"%s at %s",
- linkaddr_string(THA(ap), linkaddr, HRD_LEN(ap)),
- ipaddr_string(TPA(ap))));
+ linkaddr_string(ndo, SHA(ap), linkaddr, HRD_LEN(ap)),
+ ipaddr_string(ndo, SPA(ap))));
break;
default:
@@ -410,7 +419,7 @@ arp_print(netdissect_options *ndo,
return;
trunc:
- ND_PRINT((ndo, "[|ARP]"));
+ ND_PRINT((ndo, "%s", tstr));
}
/*
@@ -419,3 +428,6 @@ trunc:
* End:
*/
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-arp-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-ascii.c b/freebsd/contrib/tcpdump/print-ascii.c
index 70199afd..b7078148 100644
--- a/freebsd/contrib/tcpdump/print-ascii.c
+++ b/freebsd/contrib/tcpdump/print-ascii.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/* $NetBSD: print-ascii.c,v 1.1 1999/09/30 14:49:12 sjg Exp $ */
/*-
@@ -38,18 +41,16 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
+/* \summary: ASCII packet dump printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ascii.c,v 1.17 2005-07-06 20:53:32 guy Exp $";
-#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <stdio.h>
-#include "interface.h"
+#include "netdissect.h"
#define ASCII_LINELENGTH 300
#define HEXDUMP_BYTES_PER_LINE 16
@@ -59,32 +60,55 @@ static const char rcsid[] _U_ =
(HEXDUMP_HEXSTUFF_PER_SHORT * HEXDUMP_SHORTS_PER_LINE)
void
-ascii_print(register const u_char *cp, register u_int length)
+ascii_print(netdissect_options *ndo,
+ const u_char *cp, u_int length)
{
- register int s;
+ u_int caplength;
+ register u_char s;
- putchar('\n');
+ caplength = (ndo->ndo_snapend >= cp) ? ndo->ndo_snapend - cp : 0;
+ if (length > caplength)
+ length = caplength;
+ ND_PRINT((ndo, "\n"));
while (length > 0) {
s = *cp++;
length--;
- if (!isgraph(s) &&
- (s != '\t' && s != ' ' && s != '\n' && s != '\r'))
- putchar('.');
- else
- putchar(s);
+ if (s == '\r') {
+ /*
+ * Don't print CRs at the end of the line; they
+ * don't belong at the ends of lines on UN*X,
+ * and the standard I/O library will give us one
+ * on Windows so we don't need to print one
+ * ourselves.
+ *
+ * In the middle of a line, just print a '.'.
+ */
+ if (length > 1 && *cp != '\n')
+ ND_PRINT((ndo, "."));
+ } else {
+ if (!ND_ISGRAPH(s) &&
+ (s != '\t' && s != ' ' && s != '\n'))
+ ND_PRINT((ndo, "."));
+ else
+ ND_PRINT((ndo, "%c", s));
+ }
}
}
void
-hex_and_ascii_print_with_offset(register const char *ident,
+hex_and_ascii_print_with_offset(netdissect_options *ndo, register const char *ident,
register const u_char *cp, register u_int length, register u_int oset)
{
+ u_int caplength;
register u_int i;
register int s1, s2;
register int nshorts;
char hexstuff[HEXDUMP_SHORTS_PER_LINE*HEXDUMP_HEXSTUFF_PER_SHORT+1], *hsp;
char asciistuff[ASCII_LINELENGTH+1], *asp;
+ caplength = (ndo->ndo_snapend >= cp) ? ndo->ndo_snapend - cp : 0;
+ if (length > caplength)
+ length = caplength;
nshorts = length / sizeof(u_short);
i = 0;
hsp = hexstuff; asp = asciistuff;
@@ -94,14 +118,14 @@ hex_and_ascii_print_with_offset(register const char *ident,
(void)snprintf(hsp, sizeof(hexstuff) - (hsp - hexstuff),
" %02x%02x", s1, s2);
hsp += HEXDUMP_HEXSTUFF_PER_SHORT;
- *(asp++) = (isgraph(s1) ? s1 : '.');
- *(asp++) = (isgraph(s2) ? s2 : '.');
+ *(asp++) = (ND_ISGRAPH(s1) ? s1 : '.');
+ *(asp++) = (ND_ISGRAPH(s2) ? s2 : '.');
i++;
if (i >= HEXDUMP_SHORTS_PER_LINE) {
*hsp = *asp = '\0';
- (void)printf("%s0x%04x: %-*s %s",
+ ND_PRINT((ndo, "%s0x%04x: %-*s %s",
ident, oset, HEXDUMP_HEXSTUFF_PER_LINE,
- hexstuff, asciistuff);
+ hexstuff, asciistuff));
i = 0; hsp = hexstuff; asp = asciistuff;
oset += HEXDUMP_BYTES_PER_LINE;
}
@@ -111,48 +135,53 @@ hex_and_ascii_print_with_offset(register const char *ident,
(void)snprintf(hsp, sizeof(hexstuff) - (hsp - hexstuff),
" %02x", s1);
hsp += 3;
- *(asp++) = (isgraph(s1) ? s1 : '.');
+ *(asp++) = (ND_ISGRAPH(s1) ? s1 : '.');
++i;
}
if (i > 0) {
*hsp = *asp = '\0';
- (void)printf("%s0x%04x: %-*s %s",
+ ND_PRINT((ndo, "%s0x%04x: %-*s %s",
ident, oset, HEXDUMP_HEXSTUFF_PER_LINE,
- hexstuff, asciistuff);
+ hexstuff, asciistuff));
}
}
void
-hex_and_ascii_print(register const char *ident, register const u_char *cp,
- register u_int length)
+hex_and_ascii_print(netdissect_options *ndo, register const char *ident,
+ register const u_char *cp, register u_int length)
{
- hex_and_ascii_print_with_offset(ident, cp, length, 0);
+ hex_and_ascii_print_with_offset(ndo, ident, cp, length, 0);
}
/*
* telnet_print() wants this. It is essentially default_print_unaligned()
*/
void
-hex_print_with_offset(register const char *ident, register const u_char *cp, register u_int length,
- register u_int oset)
+hex_print_with_offset(netdissect_options *ndo,
+ const char *ident, const u_char *cp, u_int length,
+ u_int oset)
{
+ u_int caplength;
register u_int i, s;
register int nshorts;
+ caplength = (ndo->ndo_snapend >= cp) ? ndo->ndo_snapend - cp : 0;
+ if (length > caplength)
+ length = caplength;
nshorts = (u_int) length / sizeof(u_short);
i = 0;
while (--nshorts >= 0) {
if ((i++ % 8) == 0) {
- (void)printf("%s0x%04x: ", ident, oset);
+ ND_PRINT((ndo,"%s0x%04x: ", ident, oset));
oset += HEXDUMP_BYTES_PER_LINE;
}
s = *cp++;
- (void)printf(" %02x%02x", s, *cp++);
+ ND_PRINT((ndo," %02x%02x", s, *cp++));
}
if (length & 1) {
if ((i % 8) == 0)
- (void)printf("%s0x%04x: ", ident, oset);
- (void)printf(" %02x", *cp);
+ ND_PRINT((ndo,"%s0x%04x: ", ident, oset));
+ ND_PRINT((ndo," %02x", *cp));
}
}
@@ -160,9 +189,9 @@ hex_print_with_offset(register const char *ident, register const u_char *cp, reg
* just for completeness
*/
void
-hex_print(register const char *ident, register const u_char *cp, register u_int length)
+hex_print(netdissect_options *ndo,const char *ident, const u_char *cp, u_int length)
{
- hex_print_with_offset(ident, cp, length, 0);
+ hex_print_with_offset(ndo, ident, cp, length, 0);
}
#ifdef MAIN
@@ -183,3 +212,6 @@ main(int argc, char *argv[])
exit(0);
}
#endif /* MAIN */
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-ascii-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-atalk.c b/freebsd/contrib/tcpdump/print-atalk.c
index f6a0dcc0..44f45d82 100644
--- a/freebsd/contrib/tcpdump/print-atalk.c
+++ b/freebsd/contrib/tcpdump/print-atalk.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
@@ -19,35 +22,28 @@
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Format and print AppleTalk packets.
- *
- * $FreeBSD$
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-atalk.c,v 1.81 2004-05-01 09:41:50 hannes Exp $ (LBL)";
-#endif
+/* \summary: AppleTalk printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <stdio.h>
-#include <stdlib.h>
#include <string.h>
-#include <pcap.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "ethertype.h"
-#include "extract.h" /* must come after interface.h */
+#include "extract.h"
#include "appletalk.h"
-static struct tok type2str[] = {
+static const char tstr[] = "[|atalk]";
+
+static const struct tok type2str[] = {
{ ddpRTMP, "rtmp" },
{ ddpRTMPrequest, "rtmpReq" },
{ ddpECHO, "echo" },
@@ -58,44 +54,50 @@ static struct tok type2str[] = {
};
struct aarp {
- u_int16_t htype, ptype;
- u_int8_t halen, palen;
- u_int16_t op;
- u_int8_t hsaddr[6];
- u_int8_t psaddr[4];
- u_int8_t hdaddr[6];
- u_int8_t pdaddr[4];
+ uint16_t htype, ptype;
+ uint8_t halen, palen;
+ uint16_t op;
+ uint8_t hsaddr[6];
+ uint8_t psaddr[4];
+ uint8_t hdaddr[6];
+ uint8_t pdaddr[4];
};
-static char tstr[] = "[|atalk]";
-
-static void atp_print(const struct atATP *, u_int);
-static void atp_bitmap_print(u_char);
-static void nbp_print(const struct atNBP *, u_int, u_short, u_char, u_char);
-static const char *print_cstring(const char *, const u_char *);
-static const struct atNBPtuple *nbp_tuple_print(const struct atNBPtuple *,
+static void atp_print(netdissect_options *, const struct atATP *, u_int);
+static void atp_bitmap_print(netdissect_options *, u_char);
+static void nbp_print(netdissect_options *, const struct atNBP *, u_int, u_short, u_char, u_char);
+static const struct atNBPtuple *nbp_tuple_print(netdissect_options *ndo, const struct atNBPtuple *,
const u_char *,
u_short, u_char, u_char);
-static const struct atNBPtuple *nbp_name_print(const struct atNBPtuple *,
+static const struct atNBPtuple *nbp_name_print(netdissect_options *, const struct atNBPtuple *,
const u_char *);
-static const char *ataddr_string(u_short, u_char);
-static void ddp_print(const u_char *, u_int, int, u_short, u_char, u_char);
-static const char *ddpskt_string(int);
+static const char *ataddr_string(netdissect_options *, u_short, u_char);
+static void ddp_print(netdissect_options *, const u_char *, u_int, int, u_short, u_char, u_char);
+static const char *ddpskt_string(netdissect_options *, int);
/*
* Print LLAP packets received on a physical LocalTalk interface.
*/
u_int
-ltalk_if_print(const struct pcap_pkthdr *h, const u_char *p)
+ltalk_if_print(netdissect_options *ndo,
+ const struct pcap_pkthdr *h, const u_char *p)
{
- return (llap_print(p, h->caplen));
+ u_int hdrlen;
+
+ hdrlen = llap_print(ndo, p, h->len);
+ if (hdrlen == 0) {
+ /* Cut short by the snapshot length. */
+ return (h->caplen);
+ }
+ return (hdrlen);
}
/*
* Print AppleTalk LLAP packets.
*/
u_int
-llap_print(register const u_char *bp, u_int length)
+llap_print(netdissect_options *ndo,
+ register const u_char *bp, u_int length)
{
register const struct LAP *lp;
register const struct atDDP *dp;
@@ -104,9 +106,13 @@ llap_print(register const u_char *bp, u_int length)
u_int hdrlen;
if (length < sizeof(*lp)) {
- (void)printf(" [|llap %u]", length);
+ ND_PRINT((ndo, " [|llap %u]", length));
return (length);
}
+ if (!ND_TTEST2(*bp, sizeof(*lp))) {
+ ND_PRINT((ndo, " [|llap]"));
+ return (0); /* cut short by the snapshot length */
+ }
lp = (const struct LAP *)bp;
bp += sizeof(*lp);
length -= sizeof(*lp);
@@ -115,36 +121,44 @@ llap_print(register const u_char *bp, u_int length)
case lapShortDDP:
if (length < ddpSSize) {
- (void)printf(" [|sddp %u]", length);
+ ND_PRINT((ndo, " [|sddp %u]", length));
return (length);
}
+ if (!ND_TTEST2(*bp, ddpSSize)) {
+ ND_PRINT((ndo, " [|sddp]"));
+ return (0); /* cut short by the snapshot length */
+ }
sdp = (const struct atShortDDP *)bp;
- printf("%s.%s",
- ataddr_string(0, lp->src), ddpskt_string(sdp->srcSkt));
- printf(" > %s.%s:",
- ataddr_string(0, lp->dst), ddpskt_string(sdp->dstSkt));
+ ND_PRINT((ndo, "%s.%s",
+ ataddr_string(ndo, 0, lp->src), ddpskt_string(ndo, sdp->srcSkt)));
+ ND_PRINT((ndo, " > %s.%s:",
+ ataddr_string(ndo, 0, lp->dst), ddpskt_string(ndo, sdp->dstSkt)));
bp += ddpSSize;
length -= ddpSSize;
hdrlen += ddpSSize;
- ddp_print(bp, length, sdp->type, 0, lp->src, sdp->srcSkt);
+ ddp_print(ndo, bp, length, sdp->type, 0, lp->src, sdp->srcSkt);
break;
case lapDDP:
if (length < ddpSize) {
- (void)printf(" [|ddp %u]", length);
+ ND_PRINT((ndo, " [|ddp %u]", length));
return (length);
}
+ if (!ND_TTEST2(*bp, ddpSize)) {
+ ND_PRINT((ndo, " [|ddp]"));
+ return (0); /* cut short by the snapshot length */
+ }
dp = (const struct atDDP *)bp;
snet = EXTRACT_16BITS(&dp->srcNet);
- printf("%s.%s", ataddr_string(snet, dp->srcNode),
- ddpskt_string(dp->srcSkt));
- printf(" > %s.%s:",
- ataddr_string(EXTRACT_16BITS(&dp->dstNet), dp->dstNode),
- ddpskt_string(dp->dstSkt));
+ ND_PRINT((ndo, "%s.%s", ataddr_string(ndo, snet, dp->srcNode),
+ ddpskt_string(ndo, dp->srcSkt)));
+ ND_PRINT((ndo, " > %s.%s:",
+ ataddr_string(ndo, EXTRACT_16BITS(&dp->dstNet), dp->dstNode),
+ ddpskt_string(ndo, dp->dstSkt)));
bp += ddpSize;
length -= ddpSize;
hdrlen += ddpSize;
- ddp_print(bp, length, dp->type, snet, dp->srcNode, dp->srcSkt);
+ ddp_print(ndo, bp, length, dp->type, snet, dp->srcNode, dp->srcSkt);
break;
#ifdef notdef
@@ -154,8 +168,8 @@ llap_print(register const u_char *bp, u_int length)
#endif
default:
- printf("%d > %d at-lap#%d %u",
- lp->src, lp->dst, lp->type, length);
+ ND_PRINT((ndo, "%d > %d at-lap#%d %u",
+ lp->src, lp->dst, lp->type, length));
break;
}
return (hdrlen);
@@ -167,191 +181,206 @@ llap_print(register const u_char *bp, u_int length)
* packets in them).
*/
void
-atalk_print(register const u_char *bp, u_int length)
+atalk_print(netdissect_options *ndo,
+ register const u_char *bp, u_int length)
{
register const struct atDDP *dp;
u_short snet;
- if(!eflag)
- printf("AT ");
+ if(!ndo->ndo_eflag)
+ ND_PRINT((ndo, "AT "));
if (length < ddpSize) {
- (void)printf(" [|ddp %u]", length);
+ ND_PRINT((ndo, " [|ddp %u]", length));
+ return;
+ }
+ if (!ND_TTEST2(*bp, ddpSize)) {
+ ND_PRINT((ndo, " [|ddp]"));
return;
}
dp = (const struct atDDP *)bp;
snet = EXTRACT_16BITS(&dp->srcNet);
- printf("%s.%s", ataddr_string(snet, dp->srcNode),
- ddpskt_string(dp->srcSkt));
- printf(" > %s.%s: ",
- ataddr_string(EXTRACT_16BITS(&dp->dstNet), dp->dstNode),
- ddpskt_string(dp->dstSkt));
+ ND_PRINT((ndo, "%s.%s", ataddr_string(ndo, snet, dp->srcNode),
+ ddpskt_string(ndo, dp->srcSkt)));
+ ND_PRINT((ndo, " > %s.%s: ",
+ ataddr_string(ndo, EXTRACT_16BITS(&dp->dstNet), dp->dstNode),
+ ddpskt_string(ndo, dp->dstSkt)));
bp += ddpSize;
length -= ddpSize;
- ddp_print(bp, length, dp->type, snet, dp->srcNode, dp->srcSkt);
+ ddp_print(ndo, bp, length, dp->type, snet, dp->srcNode, dp->srcSkt);
}
/* XXX should probably pass in the snap header and do checks like arp_print() */
void
-aarp_print(register const u_char *bp, u_int length)
+aarp_print(netdissect_options *ndo,
+ register const u_char *bp, u_int length)
{
register const struct aarp *ap;
-#define AT(member) ataddr_string((ap->member[1]<<8)|ap->member[2],ap->member[3])
+#define AT(member) ataddr_string(ndo, (ap->member[1]<<8)|ap->member[2],ap->member[3])
- printf("aarp ");
+ ND_PRINT((ndo, "aarp "));
ap = (const struct aarp *)bp;
+ if (!ND_TTEST(*ap)) {
+ /* Just bail if we don't have the whole chunk. */
+ ND_PRINT((ndo, " [|aarp]"));
+ return;
+ }
+ if (length < sizeof(*ap)) {
+ ND_PRINT((ndo, " [|aarp %u]", length));
+ return;
+ }
if (EXTRACT_16BITS(&ap->htype) == 1 &&
EXTRACT_16BITS(&ap->ptype) == ETHERTYPE_ATALK &&
ap->halen == 6 && ap->palen == 4 )
switch (EXTRACT_16BITS(&ap->op)) {
case 1: /* request */
- (void)printf("who-has %s tell %s",
- AT(pdaddr), AT(psaddr));
+ ND_PRINT((ndo, "who-has %s tell %s", AT(pdaddr), AT(psaddr)));
return;
case 2: /* response */
- (void)printf("reply %s is-at %s",
- AT(psaddr), etheraddr_string(ap->hsaddr));
+ ND_PRINT((ndo, "reply %s is-at %s", AT(psaddr), etheraddr_string(ndo, ap->hsaddr)));
return;
case 3: /* probe (oy!) */
- (void)printf("probe %s tell %s",
- AT(pdaddr), AT(psaddr));
+ ND_PRINT((ndo, "probe %s tell %s", AT(pdaddr), AT(psaddr)));
return;
}
- (void)printf("len %u op %u htype %u ptype %#x halen %u palen %u",
+ ND_PRINT((ndo, "len %u op %u htype %u ptype %#x halen %u palen %u",
length, EXTRACT_16BITS(&ap->op), EXTRACT_16BITS(&ap->htype),
- EXTRACT_16BITS(&ap->ptype), ap->halen, ap->palen);
+ EXTRACT_16BITS(&ap->ptype), ap->halen, ap->palen));
}
/*
* Print AppleTalk Datagram Delivery Protocol packets.
*/
static void
-ddp_print(register const u_char *bp, register u_int length, register int t,
- register u_short snet, register u_char snode, u_char skt)
+ddp_print(netdissect_options *ndo,
+ register const u_char *bp, register u_int length, register int t,
+ register u_short snet, register u_char snode, u_char skt)
{
switch (t) {
case ddpNBP:
- nbp_print((const struct atNBP *)bp, length, snet, snode, skt);
+ nbp_print(ndo, (const struct atNBP *)bp, length, snet, snode, skt);
break;
case ddpATP:
- atp_print((const struct atATP *)bp, length);
+ atp_print(ndo, (const struct atATP *)bp, length);
break;
case ddpEIGRP:
- eigrp_print(bp, length);
+ eigrp_print(ndo, bp, length);
break;
default:
- (void)printf(" at-%s %d", tok2str(type2str, NULL, t), length);
+ ND_PRINT((ndo, " at-%s %d", tok2str(type2str, NULL, t), length));
break;
}
}
static void
-atp_print(register const struct atATP *ap, u_int length)
+atp_print(netdissect_options *ndo,
+ register const struct atATP *ap, u_int length)
{
char c;
- u_int32_t data;
+ uint32_t data;
- if ((const u_char *)(ap + 1) > snapend) {
+ if ((const u_char *)(ap + 1) > ndo->ndo_snapend) {
/* Just bail if we don't have the whole chunk. */
- fputs(tstr, stdout);
+ ND_PRINT((ndo, "%s", tstr));
return;
}
if (length < sizeof(*ap)) {
- (void)printf(" [|atp %u]", length);
+ ND_PRINT((ndo, " [|atp %u]", length));
return;
}
length -= sizeof(*ap);
switch (ap->control & 0xc0) {
case atpReqCode:
- (void)printf(" atp-req%s %d",
+ ND_PRINT((ndo, " atp-req%s %d",
ap->control & atpXO? " " : "*",
- EXTRACT_16BITS(&ap->transID));
+ EXTRACT_16BITS(&ap->transID)));
- atp_bitmap_print(ap->bitmap);
+ atp_bitmap_print(ndo, ap->bitmap);
if (length != 0)
- (void)printf(" [len=%u]", length);
+ ND_PRINT((ndo, " [len=%u]", length));
switch (ap->control & (atpEOM|atpSTS)) {
case atpEOM:
- (void)printf(" [EOM]");
+ ND_PRINT((ndo, " [EOM]"));
break;
case atpSTS:
- (void)printf(" [STS]");
+ ND_PRINT((ndo, " [STS]"));
break;
case atpEOM|atpSTS:
- (void)printf(" [EOM,STS]");
+ ND_PRINT((ndo, " [EOM,STS]"));
break;
}
break;
case atpRspCode:
- (void)printf(" atp-resp%s%d:%d (%u)",
+ ND_PRINT((ndo, " atp-resp%s%d:%d (%u)",
ap->control & atpEOM? "*" : " ",
- EXTRACT_16BITS(&ap->transID), ap->bitmap, length);
+ EXTRACT_16BITS(&ap->transID), ap->bitmap, length));
switch (ap->control & (atpXO|atpSTS)) {
case atpXO:
- (void)printf(" [XO]");
+ ND_PRINT((ndo, " [XO]"));
break;
case atpSTS:
- (void)printf(" [STS]");
+ ND_PRINT((ndo, " [STS]"));
break;
case atpXO|atpSTS:
- (void)printf(" [XO,STS]");
+ ND_PRINT((ndo, " [XO,STS]"));
break;
}
break;
case atpRelCode:
- (void)printf(" atp-rel %d", EXTRACT_16BITS(&ap->transID));
+ ND_PRINT((ndo, " atp-rel %d", EXTRACT_16BITS(&ap->transID)));
- atp_bitmap_print(ap->bitmap);
+ atp_bitmap_print(ndo, ap->bitmap);
/* length should be zero */
if (length)
- (void)printf(" [len=%u]", length);
+ ND_PRINT((ndo, " [len=%u]", length));
/* there shouldn't be any control flags */
if (ap->control & (atpXO|atpEOM|atpSTS)) {
c = '[';
if (ap->control & atpXO) {
- (void)printf("%cXO", c);
+ ND_PRINT((ndo, "%cXO", c));
c = ',';
}
if (ap->control & atpEOM) {
- (void)printf("%cEOM", c);
+ ND_PRINT((ndo, "%cEOM", c));
c = ',';
}
if (ap->control & atpSTS) {
- (void)printf("%cSTS", c);
+ ND_PRINT((ndo, "%cSTS", c));
c = ',';
}
- (void)printf("]");
+ ND_PRINT((ndo, "]"));
}
break;
default:
- (void)printf(" atp-0x%x %d (%u)", ap->control,
- EXTRACT_16BITS(&ap->transID), length);
+ ND_PRINT((ndo, " atp-0x%x %d (%u)", ap->control,
+ EXTRACT_16BITS(&ap->transID), length));
break;
}
data = EXTRACT_32BITS(&ap->userData);
if (data != 0)
- (void)printf(" 0x%x", data);
+ ND_PRINT((ndo, " 0x%x", data));
}
static void
-atp_bitmap_print(register u_char bm)
+atp_bitmap_print(netdissect_options *ndo,
+ register u_char bm)
{
register char c;
register int i;
@@ -365,164 +394,164 @@ atp_bitmap_print(register u_char bm)
c = '<';
for (i = 0; bm; ++i) {
if (bm & 1) {
- (void)printf("%c%d", c, i);
+ ND_PRINT((ndo, "%c%d", c, i));
c = ',';
}
bm >>= 1;
}
- (void)printf(">");
+ ND_PRINT((ndo, ">"));
} else {
for (i = 0; bm; ++i)
bm >>= 1;
if (i > 1)
- (void)printf("<0-%d>", i - 1);
+ ND_PRINT((ndo, "<0-%d>", i - 1));
else
- (void)printf("<0>");
+ ND_PRINT((ndo, "<0>"));
}
}
static void
-nbp_print(register const struct atNBP *np, u_int length, register u_short snet,
- register u_char snode, register u_char skt)
+nbp_print(netdissect_options *ndo,
+ register const struct atNBP *np, u_int length, register u_short snet,
+ register u_char snode, register u_char skt)
{
register const struct atNBPtuple *tp =
- (const struct atNBPtuple *)((u_char *)np + nbpHeaderSize);
+ (const struct atNBPtuple *)((const u_char *)np + nbpHeaderSize);
int i;
const u_char *ep;
if (length < nbpHeaderSize) {
- (void)printf(" truncated-nbp %u", length);
+ ND_PRINT((ndo, " truncated-nbp %u", length));
return;
}
length -= nbpHeaderSize;
if (length < 8) {
/* must be room for at least one tuple */
- (void)printf(" truncated-nbp %u", length + nbpHeaderSize);
+ ND_PRINT((ndo, " truncated-nbp %u", length + nbpHeaderSize));
return;
}
/* ep points to end of available data */
- ep = snapend;
+ ep = ndo->ndo_snapend;
if ((const u_char *)tp > ep) {
- fputs(tstr, stdout);
+ ND_PRINT((ndo, "%s", tstr));
return;
}
switch (i = np->control & 0xf0) {
case nbpBrRq:
case nbpLkUp:
- (void)printf(i == nbpLkUp? " nbp-lkup %d:":" nbp-brRq %d:",
- np->id);
+ ND_PRINT((ndo, i == nbpLkUp? " nbp-lkup %d:":" nbp-brRq %d:", np->id));
if ((const u_char *)(tp + 1) > ep) {
- fputs(tstr, stdout);
+ ND_PRINT((ndo, "%s", tstr));
return;
}
- (void)nbp_name_print(tp, ep);
+ (void)nbp_name_print(ndo, tp, ep);
/*
* look for anomalies: the spec says there can only
* be one tuple, the address must match the source
* address and the enumerator should be zero.
*/
if ((np->control & 0xf) != 1)
- (void)printf(" [ntup=%d]", np->control & 0xf);
+ ND_PRINT((ndo, " [ntup=%d]", np->control & 0xf));
if (tp->enumerator)
- (void)printf(" [enum=%d]", tp->enumerator);
+ ND_PRINT((ndo, " [enum=%d]", tp->enumerator));
if (EXTRACT_16BITS(&tp->net) != snet ||
tp->node != snode || tp->skt != skt)
- (void)printf(" [addr=%s.%d]",
- ataddr_string(EXTRACT_16BITS(&tp->net),
- tp->node), tp->skt);
+ ND_PRINT((ndo, " [addr=%s.%d]",
+ ataddr_string(ndo, EXTRACT_16BITS(&tp->net),
+ tp->node), tp->skt));
break;
case nbpLkUpReply:
- (void)printf(" nbp-reply %d:", np->id);
+ ND_PRINT((ndo, " nbp-reply %d:", np->id));
/* print each of the tuples in the reply */
for (i = np->control & 0xf; --i >= 0 && tp; )
- tp = nbp_tuple_print(tp, ep, snet, snode, skt);
+ tp = nbp_tuple_print(ndo, tp, ep, snet, snode, skt);
break;
default:
- (void)printf(" nbp-0x%x %d (%u)", np->control, np->id,
- length);
+ ND_PRINT((ndo, " nbp-0x%x %d (%u)", np->control, np->id, length));
break;
}
}
/* print a counted string */
static const char *
-print_cstring(register const char *cp, register const u_char *ep)
+print_cstring(netdissect_options *ndo,
+ register const char *cp, register const u_char *ep)
{
register u_int length;
if (cp >= (const char *)ep) {
- fputs(tstr, stdout);
+ ND_PRINT((ndo, "%s", tstr));
return (0);
}
length = *cp++;
/* Spec says string can be at most 32 bytes long */
if (length > 32) {
- (void)printf("[len=%u]", length);
+ ND_PRINT((ndo, "[len=%u]", length));
return (0);
}
while ((int)--length >= 0) {
if (cp >= (const char *)ep) {
- fputs(tstr, stdout);
+ ND_PRINT((ndo, "%s", tstr));
return (0);
}
- putchar(*cp++);
+ ND_PRINT((ndo, "%c", *cp++));
}
return (cp);
}
static const struct atNBPtuple *
-nbp_tuple_print(register const struct atNBPtuple *tp,
- register const u_char *ep,
- register u_short snet, register u_char snode,
- register u_char skt)
+nbp_tuple_print(netdissect_options *ndo,
+ register const struct atNBPtuple *tp, register const u_char *ep,
+ register u_short snet, register u_char snode, register u_char skt)
{
register const struct atNBPtuple *tpn;
if ((const u_char *)(tp + 1) > ep) {
- fputs(tstr, stdout);
+ ND_PRINT((ndo, "%s", tstr));
return 0;
}
- tpn = nbp_name_print(tp, ep);
+ tpn = nbp_name_print(ndo, tp, ep);
/* if the enumerator isn't 1, print it */
if (tp->enumerator != 1)
- (void)printf("(%d)", tp->enumerator);
+ ND_PRINT((ndo, "(%d)", tp->enumerator));
/* if the socket doesn't match the src socket, print it */
if (tp->skt != skt)
- (void)printf(" %d", tp->skt);
+ ND_PRINT((ndo, " %d", tp->skt));
/* if the address doesn't match the src address, it's an anomaly */
if (EXTRACT_16BITS(&tp->net) != snet || tp->node != snode)
- (void)printf(" [addr=%s]",
- ataddr_string(EXTRACT_16BITS(&tp->net), tp->node));
+ ND_PRINT((ndo, " [addr=%s]",
+ ataddr_string(ndo, EXTRACT_16BITS(&tp->net), tp->node)));
return (tpn);
}
static const struct atNBPtuple *
-nbp_name_print(const struct atNBPtuple *tp, register const u_char *ep)
+nbp_name_print(netdissect_options *ndo,
+ const struct atNBPtuple *tp, register const u_char *ep)
{
register const char *cp = (const char *)tp + nbpTupleSize;
- putchar(' ');
+ ND_PRINT((ndo, " "));
/* Object */
- putchar('"');
- if ((cp = print_cstring(cp, ep)) != NULL) {
+ ND_PRINT((ndo, "\""));
+ if ((cp = print_cstring(ndo, cp, ep)) != NULL) {
/* Type */
- putchar(':');
- if ((cp = print_cstring(cp, ep)) != NULL) {
+ ND_PRINT((ndo, ":"));
+ if ((cp = print_cstring(ndo, cp, ep)) != NULL) {
/* Zone */
- putchar('@');
- if ((cp = print_cstring(cp, ep)) != NULL)
- putchar('"');
+ ND_PRINT((ndo, "@"));
+ if ((cp = print_cstring(ndo, cp, ep)) != NULL)
+ ND_PRINT((ndo, "\""));
}
}
return ((const struct atNBPtuple *)cp);
@@ -540,11 +569,12 @@ struct hnamemem {
static struct hnamemem hnametable[HASHNAMESIZE];
static const char *
-ataddr_string(u_short atnet, u_char athost)
+ataddr_string(netdissect_options *ndo,
+ u_short atnet, u_char athost)
{
register struct hnamemem *tp, *tp2;
register int i = (atnet << 8) | athost;
- char nambuf[MAXHOSTNAMELEN + 20];
+ char nambuf[256+1];
static int first = 1;
FILE *fp;
@@ -552,7 +582,7 @@ ataddr_string(u_short atnet, u_char athost)
* if this is the first call, see if there's an AppleTalk
* number to name map file.
*/
- if (first && (first = 0, !nflag)
+ if (first && (first = 0, !ndo->ndo_nflag)
&& (fp = fopen("/etc/atalk.names", "r"))) {
char line[256];
int i1, i2;
@@ -573,8 +603,11 @@ ataddr_string(u_short atnet, u_char athost)
tp->nxt; tp = tp->nxt)
;
tp->addr = i2;
- tp->nxt = newhnamemem();
+ tp->nxt = newhnamemem(ndo);
tp->name = strdup(nambuf);
+ if (tp->name == NULL)
+ (*ndo->ndo_error)(ndo,
+ "ataddr_string: strdup(nambuf)");
}
fclose(fp);
}
@@ -588,25 +621,30 @@ ataddr_string(u_short atnet, u_char athost)
for (tp2 = &hnametable[i & (HASHNAMESIZE-1)]; tp2->nxt; tp2 = tp2->nxt)
if (tp2->addr == i) {
tp->addr = (atnet << 8) | athost;
- tp->nxt = newhnamemem();
+ tp->nxt = newhnamemem(ndo);
(void)snprintf(nambuf, sizeof(nambuf), "%s.%d",
tp2->name, athost);
tp->name = strdup(nambuf);
+ if (tp->name == NULL)
+ (*ndo->ndo_error)(ndo,
+ "ataddr_string: strdup(nambuf)");
return (tp->name);
}
tp->addr = (atnet << 8) | athost;
- tp->nxt = newhnamemem();
+ tp->nxt = newhnamemem(ndo);
if (athost != 255)
(void)snprintf(nambuf, sizeof(nambuf), "%d.%d", atnet, athost);
else
(void)snprintf(nambuf, sizeof(nambuf), "%d", atnet);
tp->name = strdup(nambuf);
+ if (tp->name == NULL)
+ (*ndo->ndo_error)(ndo, "ataddr_string: strdup(nambuf)");
return (tp->name);
}
-static struct tok skt2str[] = {
+static const struct tok skt2str[] = {
{ rtmpSkt, "rtmp" }, /* routing table maintenance */
{ nbpSkt, "nis" }, /* name info socket */
{ echoSkt, "echo" }, /* AppleTalk echo protocol */
@@ -615,13 +653,17 @@ static struct tok skt2str[] = {
};
static const char *
-ddpskt_string(register int skt)
+ddpskt_string(netdissect_options *ndo,
+ register int skt)
{
static char buf[8];
- if (nflag) {
+ if (ndo->ndo_nflag) {
(void)snprintf(buf, sizeof(buf), "%d", skt);
return (buf);
}
return (tok2str(skt2str, "%d", skt));
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-atalk-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-atm.c b/freebsd/contrib/tcpdump/print-atm.c
index ecf03a86..c03b0f0e 100644
--- a/freebsd/contrib/tcpdump/print-atm.c
+++ b/freebsd/contrib/tcpdump/print-atm.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1994, 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
@@ -19,46 +22,126 @@
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * $FreeBSD$
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-atm.c,v 1.49 2007-10-22 19:37:51 guy Exp $ (LBL)";
-#endif
+
+/* \summary: Asynchronous Transfer Mode (ATM) printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include <stdio.h>
-#include <pcap.h>
-#include <string.h>
-
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
#include "addrtoname.h"
-#include "ethertype.h"
#include "atm.h"
-#include "atmuni31.h"
#include "llc.h"
-#include "ether.h"
+/* start of the original atmuni31.h */
+
+/*
+ * Copyright (c) 1997 Yen Yen Lim and North Dakota State University
+ * All rights reserved.
+ *
+ * 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Yen Yen Lim and
+ North Dakota State University
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+ */
+
+/* Based on UNI3.1 standard by ATM Forum */
+
+/* ATM traffic types based on VPI=0 and (the following VCI */
+#define VCI_PPC 0x05 /* Point-to-point signal msg */
+#define VCI_BCC 0x02 /* Broadcast signal msg */
+#define VCI_OAMF4SC 0x03 /* Segment OAM F4 flow cell */
+#define VCI_OAMF4EC 0x04 /* End-to-end OAM F4 flow cell */
+#define VCI_METAC 0x01 /* Meta signal msg */
+#define VCI_ILMIC 0x10 /* ILMI msg */
+
+/* Q.2931 signalling messages */
+#define CALL_PROCEED 0x02 /* call proceeding */
+#define CONNECT 0x07 /* connect */
+#define CONNECT_ACK 0x0f /* connect_ack */
+#define SETUP 0x05 /* setup */
+#define RELEASE 0x4d /* release */
+#define RELEASE_DONE 0x5a /* release_done */
+#define RESTART 0x46 /* restart */
+#define RESTART_ACK 0x4e /* restart ack */
+#define STATUS 0x7d /* status */
+#define STATUS_ENQ 0x75 /* status ack */
+#define ADD_PARTY 0x80 /* add party */
+#define ADD_PARTY_ACK 0x81 /* add party ack */
+#define ADD_PARTY_REJ 0x82 /* add party rej */
+#define DROP_PARTY 0x83 /* drop party */
+#define DROP_PARTY_ACK 0x84 /* drop party ack */
+
+/* Information Element Parameters in the signalling messages */
+#define CAUSE 0x08 /* cause */
+#define ENDPT_REF 0x54 /* endpoint reference */
+#define AAL_PARA 0x58 /* ATM adaptation layer parameters */
+#define TRAFF_DESCRIP 0x59 /* atm traffic descriptors */
+#define CONNECT_ID 0x5a /* connection identifier */
+#define QOS_PARA 0x5c /* quality of service parameters */
+#define B_HIGHER 0x5d /* broadband higher layer information */
+#define B_BEARER 0x5e /* broadband bearer capability */
+#define B_LOWER 0x5f /* broadband lower information */
+#define CALLING_PARTY 0x6c /* calling party number */
+#define CALLED_PARTY 0x70 /* called party nmber */
+
+#define Q2931 0x09
+
+/* Q.2931 signalling general messages format */
+#define PROTO_POS 0 /* offset of protocol discriminator */
+#define CALL_REF_POS 2 /* offset of call reference value */
+#define MSG_TYPE_POS 5 /* offset of message type */
+#define MSG_LEN_POS 7 /* offset of mesage length */
+#define IE_BEGIN_POS 9 /* offset of first information element */
+
+/* format of signalling messages */
+#define TYPE_POS 0
+#define LEN_POS 2
+#define FIELD_BEGIN_POS 4
+
+/* end of the original atmuni31.h */
+
+static const char tstr[] = "[|atm]";
#define OAM_CRC10_MASK 0x3ff
#define OAM_PAYLOAD_LEN 48
#define OAM_FUNCTION_SPECIFIC_LEN 45 /* this excludes crc10 and cell-type/function-type */
#define OAM_CELLTYPE_FUNCTYPE_LEN 1
-struct tok oam_f_values[] = {
+static const struct tok oam_f_values[] = {
{ VCI_OAMF4SC, "OAM F4 (segment)" },
{ VCI_OAMF4EC, "OAM F4 (end)" },
{ 0, NULL }
};
-struct tok atm_pty_values[] = {
+static const struct tok atm_pty_values[] = {
{ 0x0, "user data, uncongested, SDU 0" },
{ 0x1, "user data, uncongested, SDU 1" },
{ 0x2, "user data, congested, SDU 0" },
@@ -74,7 +157,7 @@ struct tok atm_pty_values[] = {
#define OAM_CELLTYPE_AD 0x8
#define OAM_CELLTYPE_SM 0xf
-struct tok oam_celltype_values[] = {
+static const struct tok oam_celltype_values[] = {
{ OAM_CELLTYPE_FM, "Fault Management" },
{ OAM_CELLTYPE_PM, "Performance Management" },
{ OAM_CELLTYPE_AD, "activate/deactivate" },
@@ -87,7 +170,7 @@ struct tok oam_celltype_values[] = {
#define OAM_FM_FUNCTYPE_CONTCHECK 0x4
#define OAM_FM_FUNCTYPE_LOOPBACK 0x8
-struct tok oam_fm_functype_values[] = {
+static const struct tok oam_fm_functype_values[] = {
{ OAM_FM_FUNCTYPE_AIS, "AIS" },
{ OAM_FM_FUNCTYPE_RDI, "RDI" },
{ OAM_FM_FUNCTYPE_CONTCHECK, "Continuity Check" },
@@ -95,14 +178,14 @@ struct tok oam_fm_functype_values[] = {
{ 0, NULL }
};
-struct tok oam_pm_functype_values[] = {
+static const struct tok oam_pm_functype_values[] = {
{ 0x0, "Forward Monitoring" },
{ 0x1, "Backward Reporting" },
{ 0x2, "Monitoring and Reporting" },
{ 0, NULL }
};
-struct tok oam_ad_functype_values[] = {
+static const struct tok oam_ad_functype_values[] = {
{ 0x0, "Performance Monitoring" },
{ 0x1, "Continuity Check" },
{ 0, NULL }
@@ -110,7 +193,7 @@ struct tok oam_ad_functype_values[] = {
#define OAM_FM_LOOPBACK_INDICATOR_MASK 0x1
-struct tok oam_fm_loopback_indicator_values[] = {
+static const struct tok oam_fm_loopback_indicator_values[] = {
{ 0x0, "Reply" },
{ 0x1, "Request" },
{ 0, NULL }
@@ -138,21 +221,20 @@ static const struct tok *oam_functype_values[16] = {
/*
* Print an RFC 1483 LLC-encapsulated ATM frame.
*/
-static void
-atm_llc_print(const u_char *p, int length, int caplen)
+static u_int
+atm_llc_print(netdissect_options *ndo,
+ const u_char *p, int length, int caplen)
{
- u_short extracted_ethertype;
-
- if (!llc_print(p, length, caplen, NULL, NULL,
- &extracted_ethertype)) {
- /* ether_type not known, print raw packet */
- if (extracted_ethertype) {
- printf("(LLC %s) ",
- etherproto_string(htons(extracted_ethertype)));
- }
- if (!suppress_default_print)
- default_print(p, caplen);
+ int llc_hdrlen;
+
+ llc_hdrlen = llc_print(ndo, p, length, caplen, NULL, NULL);
+ if (llc_hdrlen < 0) {
+ /* packet not known, print raw packet */
+ if (!ndo->ndo_suppress_default_print)
+ ND_DEFAULTPRINT(p, caplen);
+ llc_hdrlen = -llc_hdrlen;
}
+ return (llc_hdrlen);
}
/*
@@ -168,27 +250,37 @@ atm_llc_print(const u_char *p, int length, int caplen)
* is the number of bytes actually captured.
*/
u_int
-atm_if_print(const struct pcap_pkthdr *h, const u_char *p)
+atm_if_print(netdissect_options *ndo,
+ const struct pcap_pkthdr *h, const u_char *p)
{
u_int caplen = h->caplen;
u_int length = h->len;
- u_int32_t llchdr;
+ uint32_t llchdr;
u_int hdrlen = 0;
- if (caplen < 8) {
- printf("[|atm]");
+ if (caplen < 1 || length < 1) {
+ ND_PRINT((ndo, "%s", tstr));
return (caplen);
}
/* Cisco Style NLPID ? */
if (*p == LLC_UI) {
- if (eflag)
- printf("CNLPID ");
- isoclns_print(p+1, length-1, caplen-1);
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, "CNLPID "));
+ isoclns_print(ndo, p + 1, length - 1, caplen - 1);
return hdrlen;
}
/*
+ * Must have at least a DSAP, an SSAP, and the first byte of the
+ * control field.
+ */
+ if (caplen < 3 || length < 3) {
+ ND_PRINT((ndo, "%s", tstr));
+ return (caplen);
+ }
+
+ /*
* Extract the presumed LLC header into a variable, for quick
* testing.
* Then check for a header that's neither a header for a SNAP
@@ -215,25 +307,29 @@ atm_if_print(const struct pcap_pkthdr *h, const u_char *p)
* packets? If so, could it be changed to use a
* new DLT_IEEE802_6 value if we added it?
*/
- if (eflag)
- printf("%08x%08x %08x%08x ",
+ if (caplen < 20 || length < 20) {
+ ND_PRINT((ndo, "%s", tstr));
+ return (caplen);
+ }
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, "%08x%08x %08x%08x ",
EXTRACT_32BITS(p),
EXTRACT_32BITS(p+4),
EXTRACT_32BITS(p+8),
- EXTRACT_32BITS(p+12));
+ EXTRACT_32BITS(p+12)));
p += 20;
length -= 20;
caplen -= 20;
hdrlen += 20;
}
- atm_llc_print(p, length, caplen);
+ hdrlen += atm_llc_print(ndo, p, length, caplen);
return (hdrlen);
}
/*
* ATM signalling.
*/
-static struct tok msgtype2str[] = {
+static const struct tok msgtype2str[] = {
{ CALL_PROCEED, "Call_proceeding" },
{ CONNECT, "Connect" },
{ CONNECT_ACK, "Connect_ack" },
@@ -253,26 +349,21 @@ static struct tok msgtype2str[] = {
};
static void
-sig_print(const u_char *p, int caplen)
+sig_print(netdissect_options *ndo,
+ const u_char *p)
{
- bpf_u_int32 call_ref;
+ uint32_t call_ref;
- if (caplen < PROTO_POS) {
- printf("[|atm]");
- return;
- }
+ ND_TCHECK(p[PROTO_POS]);
if (p[PROTO_POS] == Q2931) {
/*
- * protocol:Q.2931 for User to Network Interface
+ * protocol:Q.2931 for User to Network Interface
* (UNI 3.1) signalling
*/
- printf("Q.2931");
- if (caplen < MSG_TYPE_POS) {
- printf(" [|atm]");
- return;
- }
- printf(":%s ",
- tok2str(msgtype2str, "msgtype#%d", p[MSG_TYPE_POS]));
+ ND_PRINT((ndo, "Q.2931"));
+ ND_TCHECK(p[MSG_TYPE_POS]);
+ ND_PRINT((ndo, ":%s ",
+ tok2str(msgtype2str, "msgtype#%d", p[MSG_TYPE_POS])));
/*
* The call reference comes before the message type,
@@ -281,46 +372,51 @@ sig_print(const u_char *p, int caplen)
* the call reference.
*/
call_ref = EXTRACT_24BITS(&p[CALL_REF_POS]);
- printf("CALL_REF:0x%06x", call_ref);
+ ND_PRINT((ndo, "CALL_REF:0x%06x", call_ref));
} else {
/* SCCOP with some unknown protocol atop it */
- printf("SSCOP, proto %d ", p[PROTO_POS]);
+ ND_PRINT((ndo, "SSCOP, proto %d ", p[PROTO_POS]));
}
+ return;
+
+trunc:
+ ND_PRINT((ndo, " %s", tstr));
}
/*
* Print an ATM PDU (such as an AAL5 PDU).
*/
void
-atm_print(u_int vpi, u_int vci, u_int traftype, const u_char *p, u_int length,
- u_int caplen)
+atm_print(netdissect_options *ndo,
+ u_int vpi, u_int vci, u_int traftype, const u_char *p, u_int length,
+ u_int caplen)
{
- if (eflag)
- printf("VPI:%u VCI:%u ", vpi, vci);
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, "VPI:%u VCI:%u ", vpi, vci));
if (vpi == 0) {
switch (vci) {
case VCI_PPC:
- sig_print(p, caplen);
+ sig_print(ndo, p);
return;
case VCI_BCC:
- printf("broadcast sig: ");
+ ND_PRINT((ndo, "broadcast sig: "));
return;
case VCI_OAMF4SC: /* fall through */
case VCI_OAMF4EC:
- oam_print(p, length, ATM_OAM_HEC);
+ oam_print(ndo, p, length, ATM_OAM_HEC);
return;
case VCI_METAC:
- printf("meta: ");
+ ND_PRINT((ndo, "meta: "));
return;
case VCI_ILMIC:
- printf("ilmi: ");
- snmp_print(p, length);
+ ND_PRINT((ndo, "ilmi: "));
+ snmp_print(ndo, p, length);
return;
}
}
@@ -332,35 +428,36 @@ atm_print(u_int vpi, u_int vci, u_int traftype, const u_char *p, u_int length,
/*
* Assumes traffic is LLC if unknown.
*/
- atm_llc_print(p, length, caplen);
+ atm_llc_print(ndo, p, length, caplen);
break;
case ATM_LANE:
- lane_print(p, length, caplen);
+ lane_print(ndo, p, length, caplen);
break;
}
}
struct oam_fm_loopback_t {
- u_int8_t loopback_indicator;
- u_int8_t correlation_tag[4];
- u_int8_t loopback_id[12];
- u_int8_t source_id[12];
- u_int8_t unused[16];
+ uint8_t loopback_indicator;
+ uint8_t correlation_tag[4];
+ uint8_t loopback_id[12];
+ uint8_t source_id[12];
+ uint8_t unused[16];
};
struct oam_fm_ais_rdi_t {
- u_int8_t failure_type;
- u_int8_t failure_location[16];
- u_int8_t unused[28];
+ uint8_t failure_type;
+ uint8_t failure_location[16];
+ uint8_t unused[28];
};
-int
-oam_print (const u_char *p, u_int length, u_int hec) {
-
- u_int32_t cell_header;
- u_int16_t vpi, vci, cksum, cksum_shouldbe, idx;
- u_int8_t cell_type, func_type, payload, clp;
+void
+oam_print (netdissect_options *ndo,
+ const u_char *p, u_int length, u_int hec)
+{
+ uint32_t cell_header;
+ uint16_t vpi, vci, cksum, cksum_shouldbe, idx;
+ uint8_t cell_type, func_type, payload, clp;
union {
const struct oam_fm_loopback_t *oam_fm_loopback;
@@ -368,6 +465,7 @@ oam_print (const u_char *p, u_int length, u_int hec) {
} oam_ptr;
+ ND_TCHECK(*(p+ATM_HDR_LEN_NOHEC+hec));
cell_header = EXTRACT_32BITS(p+hec);
cell_type = ((*(p+ATM_HDR_LEN_NOHEC+hec))>>4) & 0x0f;
func_type = (*(p+ATM_HDR_LEN_NOHEC+hec)) & 0x0f;
@@ -377,47 +475,48 @@ oam_print (const u_char *p, u_int length, u_int hec) {
payload = (cell_header>>1)&0x7;
clp = cell_header&0x1;
- printf("%s, vpi %u, vci %u, payload [ %s ], clp %u, length %u",
+ ND_PRINT((ndo, "%s, vpi %u, vci %u, payload [ %s ], clp %u, length %u",
tok2str(oam_f_values, "OAM F5", vci),
vpi, vci,
tok2str(atm_pty_values, "Unknown", payload),
- clp, length);
+ clp, length));
- if (!vflag) {
- return 1;
+ if (!ndo->ndo_vflag) {
+ return;
}
- printf("\n\tcell-type %s (%u)",
+ ND_PRINT((ndo, "\n\tcell-type %s (%u)",
tok2str(oam_celltype_values, "unknown", cell_type),
- cell_type);
+ cell_type));
if (oam_functype_values[cell_type] == NULL)
- printf(", func-type unknown (%u)", func_type);
+ ND_PRINT((ndo, ", func-type unknown (%u)", func_type));
else
- printf(", func-type %s (%u)",
+ ND_PRINT((ndo, ", func-type %s (%u)",
tok2str(oam_functype_values[cell_type],"none",func_type),
- func_type);
+ func_type));
p += ATM_HDR_LEN_NOHEC + hec;
switch (cell_type << 4 | func_type) {
case (OAM_CELLTYPE_FM << 4 | OAM_FM_FUNCTYPE_LOOPBACK):
oam_ptr.oam_fm_loopback = (const struct oam_fm_loopback_t *)(p + OAM_CELLTYPE_FUNCTYPE_LEN);
- printf("\n\tLoopback-Indicator %s, Correlation-Tag 0x%08x",
+ ND_TCHECK(*oam_ptr.oam_fm_loopback);
+ ND_PRINT((ndo, "\n\tLoopback-Indicator %s, Correlation-Tag 0x%08x",
tok2str(oam_fm_loopback_indicator_values,
"Unknown",
oam_ptr.oam_fm_loopback->loopback_indicator & OAM_FM_LOOPBACK_INDICATOR_MASK),
- EXTRACT_32BITS(&oam_ptr.oam_fm_loopback->correlation_tag));
- printf("\n\tLocation-ID ");
+ EXTRACT_32BITS(&oam_ptr.oam_fm_loopback->correlation_tag)));
+ ND_PRINT((ndo, "\n\tLocation-ID "));
for (idx = 0; idx < sizeof(oam_ptr.oam_fm_loopback->loopback_id); idx++) {
if (idx % 2) {
- printf("%04x ", EXTRACT_16BITS(&oam_ptr.oam_fm_loopback->loopback_id[idx]));
+ ND_PRINT((ndo, "%04x ", EXTRACT_16BITS(&oam_ptr.oam_fm_loopback->loopback_id[idx])));
}
}
- printf("\n\tSource-ID ");
+ ND_PRINT((ndo, "\n\tSource-ID "));
for (idx = 0; idx < sizeof(oam_ptr.oam_fm_loopback->source_id); idx++) {
if (idx % 2) {
- printf("%04x ", EXTRACT_16BITS(&oam_ptr.oam_fm_loopback->source_id[idx]));
+ ND_PRINT((ndo, "%04x ", EXTRACT_16BITS(&oam_ptr.oam_fm_loopback->source_id[idx])));
}
}
break;
@@ -425,11 +524,12 @@ oam_print (const u_char *p, u_int length, u_int hec) {
case (OAM_CELLTYPE_FM << 4 | OAM_FM_FUNCTYPE_AIS):
case (OAM_CELLTYPE_FM << 4 | OAM_FM_FUNCTYPE_RDI):
oam_ptr.oam_fm_ais_rdi = (const struct oam_fm_ais_rdi_t *)(p + OAM_CELLTYPE_FUNCTYPE_LEN);
- printf("\n\tFailure-type 0x%02x", oam_ptr.oam_fm_ais_rdi->failure_type);
- printf("\n\tLocation-ID ");
+ ND_TCHECK(*oam_ptr.oam_fm_ais_rdi);
+ ND_PRINT((ndo, "\n\tFailure-type 0x%02x", oam_ptr.oam_fm_ais_rdi->failure_type));
+ ND_PRINT((ndo, "\n\tLocation-ID "));
for (idx = 0; idx < sizeof(oam_ptr.oam_fm_ais_rdi->failure_location); idx++) {
if (idx % 2) {
- printf("%04x ", EXTRACT_16BITS(&oam_ptr.oam_fm_ais_rdi->failure_location[idx]));
+ ND_PRINT((ndo, "%04x ", EXTRACT_16BITS(&oam_ptr.oam_fm_ais_rdi->failure_location[idx])));
}
}
break;
@@ -443,13 +543,21 @@ oam_print (const u_char *p, u_int length, u_int hec) {
}
/* crc10 checksum verification */
+ ND_TCHECK2(*(p + OAM_CELLTYPE_FUNCTYPE_LEN + OAM_FUNCTION_SPECIFIC_LEN), 2);
cksum = EXTRACT_16BITS(p + OAM_CELLTYPE_FUNCTYPE_LEN + OAM_FUNCTION_SPECIFIC_LEN)
& OAM_CRC10_MASK;
cksum_shouldbe = verify_crc10_cksum(0, p, OAM_PAYLOAD_LEN);
-
- printf("\n\tcksum 0x%03x (%scorrect)",
+
+ ND_PRINT((ndo, "\n\tcksum 0x%03x (%scorrect)",
cksum,
- cksum_shouldbe == 0 ? "" : "in");
+ cksum_shouldbe == 0 ? "" : "in"));
+
+ return;
- return 1;
+trunc:
+ ND_PRINT((ndo, "[|oam]"));
+ return;
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-atm-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-babel.c b/freebsd/contrib/tcpdump/print-babel.c
index 629c57e9..af835a50 100644
--- a/freebsd/contrib/tcpdump/print-babel.c
+++ b/freebsd/contrib/tcpdump/print-babel.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 2007-2011 Grégoire Henry, Juliusz Chroboczek
*
@@ -28,50 +31,57 @@
* SUCH DAMAGE.
*/
+/* \summary: Babel Routing Protocol printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <stdio.h>
#include <string.h>
+#include "netdissect.h"
#include "addrtoname.h"
-#include "interface.h"
#include "extract.h"
-static void babel_print_v2(const u_char *cp, u_int length);
+static const char tstr[] = "[|babel]";
+
+static void babel_print_v2(netdissect_options *, const u_char *cp, u_int length);
void
-babel_print(const u_char *cp, u_int length) {
- printf("babel");
+babel_print(netdissect_options *ndo,
+ const u_char *cp, u_int length)
+{
+ ND_PRINT((ndo, "babel"));
- TCHECK2(*cp, 4);
+ ND_TCHECK2(*cp, 4);
if(cp[0] != 42) {
- printf(" malformed header");
+ ND_PRINT((ndo, " invalid header"));
return;
} else {
- printf(" %d", cp[1]);
+ ND_PRINT((ndo, " %d", cp[1]));
}
switch(cp[1]) {
case 2:
- babel_print_v2(cp,length);
+ babel_print_v2(ndo, cp, length);
break;
default:
- printf(" unknown version");
+ ND_PRINT((ndo, " unknown version"));
break;
}
return;
trunc:
- printf(" [|babel]");
+ ND_PRINT((ndo, " %s", tstr));
return;
}
+/* TLVs */
#define MESSAGE_PAD1 0
#define MESSAGE_PADN 1
#define MESSAGE_ACK_REQ 2
@@ -85,6 +95,22 @@ babel_print(const u_char *cp, u_int length) {
#define MESSAGE_MH_REQUEST 10
#define MESSAGE_TSPC 11
#define MESSAGE_HMAC 12
+#define MESSAGE_UPDATE_SRC_SPECIFIC 13
+#define MESSAGE_REQUEST_SRC_SPECIFIC 14
+#define MESSAGE_MH_REQUEST_SRC_SPECIFIC 15
+
+/* sub-TLVs */
+#define MESSAGE_SUB_PAD1 0
+#define MESSAGE_SUB_PADN 1
+#define MESSAGE_SUB_DIVERSITY 2
+#define MESSAGE_SUB_TIMESTAMP 3
+
+/* Diversity sub-TLV channel codes */
+static const struct tok diversity_str[] = {
+ { 0, "reserved" },
+ { 255, "all" },
+ { 0, NULL }
+};
static const char *
format_id(const u_char *id)
@@ -100,34 +126,53 @@ static const unsigned char v4prefix[16] =
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF, 0, 0, 0, 0 };
static const char *
-format_prefix(const u_char *prefix, unsigned char plen)
+format_prefix(netdissect_options *ndo, const u_char *prefix, unsigned char plen)
{
static char buf[50];
if(plen >= 96 && memcmp(prefix, v4prefix, 12) == 0)
- snprintf(buf, 50, "%s/%u", ipaddr_string(prefix + 12), plen - 96);
+ snprintf(buf, 50, "%s/%u", ipaddr_string(ndo, prefix + 12), plen - 96);
else
-#ifdef INET6
- snprintf(buf, 50, "%s/%u", ip6addr_string(prefix), plen);
-#else
- snprintf(buf, 50, "IPv6 addresses not supported");
-#endif
+ snprintf(buf, 50, "%s/%u", ip6addr_string(ndo, prefix), plen);
buf[49] = '\0';
return buf;
}
static const char *
-format_address(const u_char *prefix)
+format_address(netdissect_options *ndo, const u_char *prefix)
{
if(memcmp(prefix, v4prefix, 12) == 0)
- return ipaddr_string(prefix + 12);
+ return ipaddr_string(ndo, prefix + 12);
else
-#ifdef INET6
- return ip6addr_string(prefix);
-#else
- return "IPv6 addresses not supported";
-#endif
+ return ip6addr_string(ndo, prefix);
}
+static const char *
+format_interval(const uint16_t i)
+{
+ static char buf[sizeof("000.00s")];
+
+ if (i == 0)
+ return "0.0s (bogus)";
+ snprintf(buf, sizeof(buf), "%u.%02us", i / 100, i % 100);
+ return buf;
+}
+
+static const char *
+format_interval_update(const uint16_t i)
+{
+ return i == 0xFFFF ? "infinity" : format_interval(i);
+}
+
+static const char *
+format_timestamp(const uint32_t i)
+{
+ static char buf[sizeof("0000.000000s")];
+ snprintf(buf, sizeof(buf), "%u.%06us", i / 1000000, i % 1000000);
+ return buf;
+}
+
+/* Return number of octets consumed from the input buffer (not the prefix length
+ * in bytes), or -1 for encoding error. */
static int
network_prefix(int ae, int plen, unsigned int omitted,
const unsigned char *p, const unsigned char *dp,
@@ -135,6 +180,7 @@ network_prefix(int ae, int plen, unsigned int omitted,
{
unsigned pb;
unsigned char prefix[16];
+ int consumed = 0;
if(plen >= 0)
pb = (plen + 7) / 8;
@@ -158,7 +204,10 @@ network_prefix(int ae, int plen, unsigned int omitted,
if (dp == NULL) return -1;
memcpy(prefix, dp, 12 + omitted);
}
- if(pb > omitted) memcpy(prefix + 12 + omitted, p, pb - omitted);
+ if(pb > omitted) {
+ memcpy(prefix + 12 + omitted, p, pb - omitted);
+ consumed = pb - omitted;
+ }
break;
case 2:
if(omitted > 16 || (pb > omitted && len < pb - omitted))
@@ -167,20 +216,26 @@ network_prefix(int ae, int plen, unsigned int omitted,
if (dp == NULL) return -1;
memcpy(prefix, dp, omitted);
}
- if(pb > omitted) memcpy(prefix + omitted, p, pb - omitted);
+ if(pb > omitted) {
+ memcpy(prefix + omitted, p, pb - omitted);
+ consumed = pb - omitted;
+ }
break;
case 3:
if(pb > 8 && len < pb - 8) return -1;
prefix[0] = 0xfe;
prefix[1] = 0x80;
- if(pb > 8) memcpy(prefix + 8, p, pb - 8);
+ if(pb > 8) {
+ memcpy(prefix + 8, p, pb - 8);
+ consumed = pb - 8;
+ }
break;
default:
return -1;
}
memcpy(p_r, prefix, 16);
- return 1;
+ return consumed;
}
static int
@@ -190,22 +245,118 @@ network_address(int ae, const unsigned char *a, unsigned int len,
return network_prefix(ae, -1, 0, a, NULL, len, a_r);
}
+/*
+ * Sub-TLVs consume the "extra data" of Babel TLVs (see Section 4.3 of RFC6126),
+ * their encoding is similar to the encoding of TLVs, but the type namespace is
+ * different:
+ *
+ * o Type 0 stands for Pad1 sub-TLV with the same encoding as the Pad1 TLV.
+ * o Type 1 stands for PadN sub-TLV with the same encoding as the PadN TLV.
+ * o Type 2 stands for Diversity sub-TLV, which propagates diversity routing
+ * data. Its body is a variable-length sequence of 8-bit unsigned integers,
+ * each representing per-hop number of interferring radio channel for the
+ * prefix. Channel 0 is invalid and must not be used in the sub-TLV, channel
+ * 255 interferes with any other channel.
+ * o Type 3 stands for Timestamp sub-TLV, used to compute RTT between
+ * neighbours. In the case of a Hello TLV, the body stores a 32-bits
+ * timestamp, while in the case of a IHU TLV, two 32-bits timestamps are
+ * stored.
+ *
+ * Sub-TLV types 0 and 1 are valid for any TLV type, whether sub-TLV type 2 is
+ * only valid for TLV type 8 (Update). Note that within an Update TLV a missing
+ * Diversity sub-TLV is not the same as a Diversity sub-TLV with an empty body.
+ * The former would mean a lack of any claims about the interference, and the
+ * latter would state that interference is definitely absent.
+ * A type 3 sub-TLV is valid both for Hello and IHU TLVs, though the exact
+ * semantic of the sub-TLV is different in each case.
+ */
+static void
+subtlvs_print(netdissect_options *ndo,
+ const u_char *cp, const u_char *ep, const uint8_t tlv_type)
+{
+ uint8_t subtype, sublen;
+ const char *sep;
+ uint32_t t1, t2;
+
+ while (cp < ep) {
+ subtype = *cp++;
+ if(subtype == MESSAGE_SUB_PAD1) {
+ ND_PRINT((ndo, " sub-pad1"));
+ continue;
+ }
+ if(cp == ep)
+ goto invalid;
+ sublen = *cp++;
+ if(cp + sublen > ep)
+ goto invalid;
+
+ switch(subtype) {
+ case MESSAGE_SUB_PADN:
+ ND_PRINT((ndo, " sub-padn"));
+ cp += sublen;
+ break;
+ case MESSAGE_SUB_DIVERSITY:
+ ND_PRINT((ndo, " sub-diversity"));
+ if (sublen == 0) {
+ ND_PRINT((ndo, " empty"));
+ break;
+ }
+ sep = " ";
+ while(sublen--) {
+ ND_PRINT((ndo, "%s%s", sep, tok2str(diversity_str, "%u", *cp++)));
+ sep = "-";
+ }
+ if(tlv_type != MESSAGE_UPDATE &&
+ tlv_type != MESSAGE_UPDATE_SRC_SPECIFIC)
+ ND_PRINT((ndo, " (bogus)"));
+ break;
+ case MESSAGE_SUB_TIMESTAMP:
+ ND_PRINT((ndo, " sub-timestamp"));
+ if(tlv_type == MESSAGE_HELLO) {
+ if(sublen < 4)
+ goto invalid;
+ t1 = EXTRACT_32BITS(cp);
+ ND_PRINT((ndo, " %s", format_timestamp(t1)));
+ } else if(tlv_type == MESSAGE_IHU) {
+ if(sublen < 8)
+ goto invalid;
+ t1 = EXTRACT_32BITS(cp);
+ ND_PRINT((ndo, " %s", format_timestamp(t1)));
+ t2 = EXTRACT_32BITS(cp + 4);
+ ND_PRINT((ndo, "|%s", format_timestamp(t2)));
+ } else
+ ND_PRINT((ndo, " (bogus)"));
+ cp += sublen;
+ break;
+ default:
+ ND_PRINT((ndo, " sub-unknown-0x%02x", subtype));
+ cp += sublen;
+ } /* switch */
+ } /* while */
+ return;
+
+ invalid:
+ ND_PRINT((ndo, "%s", istr));
+}
+
#define ICHECK(i, l) \
- if ((i) + (l) > bodylen || (i) + (l) > length) goto corrupt;
+ if ((i) + (l) > bodylen || (i) + (l) > length) goto invalid;
static void
-babel_print_v2(const u_char *cp, u_int length) {
+babel_print_v2(netdissect_options *ndo,
+ const u_char *cp, u_int length)
+{
u_int i;
u_short bodylen;
u_char v4_prefix[16] =
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF, 0, 0, 0, 0 };
u_char v6_prefix[16] = {0};
- TCHECK2(*cp, 4);
+ ND_TCHECK2(*cp, 4);
if (length < 4)
- goto corrupt;
+ goto invalid;
bodylen = EXTRACT_16BITS(cp + 2);
- printf(" (%u)", bodylen);
+ ND_PRINT((ndo, " (%u)", bodylen));
/* Process the TLVs in the body */
i = 0;
@@ -214,236 +365,361 @@ babel_print_v2(const u_char *cp, u_int length) {
u_int type, len;
message = cp + 4 + i;
- TCHECK2(*message, 2);
+
+ ND_TCHECK2(*message, 1);
+ if((type = message[0]) == MESSAGE_PAD1) {
+ ND_PRINT((ndo, ndo->ndo_vflag ? "\n\tPad 1" : " pad1"));
+ i += 1;
+ continue;
+ }
+
+ ND_TCHECK2(*message, 2);
ICHECK(i, 2);
- type = message[0];
len = message[1];
- TCHECK2(*message, 2 + len);
+ ND_TCHECK2(*message, 2 + len);
ICHECK(i, 2 + len);
switch(type) {
- case MESSAGE_PAD1: {
- if(!vflag)
- printf(" pad1");
- else
- printf("\n\tPad 1");
- }
- break;
-
case MESSAGE_PADN: {
- if(!vflag)
- printf(" padN");
+ if (!ndo->ndo_vflag)
+ ND_PRINT((ndo, " padN"));
else
- printf("\n\tPad %d", len + 2);
+ ND_PRINT((ndo, "\n\tPad %d", len + 2));
}
break;
case MESSAGE_ACK_REQ: {
u_short nonce, interval;
- if(!vflag)
- printf(" ack-req");
+ if (!ndo->ndo_vflag)
+ ND_PRINT((ndo, " ack-req"));
else {
- printf("\n\tAcknowledgment Request ");
- if(len < 6) goto corrupt;
+ ND_PRINT((ndo, "\n\tAcknowledgment Request "));
+ if(len < 6) goto invalid;
nonce = EXTRACT_16BITS(message + 4);
interval = EXTRACT_16BITS(message + 6);
- printf("%04x %d", nonce, interval);
+ ND_PRINT((ndo, "%04x %s", nonce, format_interval(interval)));
}
}
break;
case MESSAGE_ACK: {
u_short nonce;
- if(!vflag)
- printf(" ack");
+ if (!ndo->ndo_vflag)
+ ND_PRINT((ndo, " ack"));
else {
- printf("\n\tAcknowledgment ");
- if(len < 2) goto corrupt;
+ ND_PRINT((ndo, "\n\tAcknowledgment "));
+ if(len < 2) goto invalid;
nonce = EXTRACT_16BITS(message + 2);
- printf("%04x", nonce);
+ ND_PRINT((ndo, "%04x", nonce));
}
}
break;
case MESSAGE_HELLO: {
u_short seqno, interval;
- if(!vflag)
- printf(" hello");
+ if (!ndo->ndo_vflag)
+ ND_PRINT((ndo, " hello"));
else {
- printf("\n\tHello ");
- if(len < 6) goto corrupt;
+ ND_PRINT((ndo, "\n\tHello "));
+ if(len < 6) goto invalid;
seqno = EXTRACT_16BITS(message + 4);
interval = EXTRACT_16BITS(message + 6);
- printf("seqno %u interval %u", seqno, interval);
+ ND_PRINT((ndo, "seqno %u interval %s", seqno, format_interval(interval)));
+ /* Extra data. */
+ if(len > 6)
+ subtlvs_print(ndo, message + 8, message + 2 + len, type);
}
}
break;
case MESSAGE_IHU: {
unsigned short txcost, interval;
- if(!vflag)
- printf(" ihu");
+ if (!ndo->ndo_vflag)
+ ND_PRINT((ndo, " ihu"));
else {
u_char address[16];
int rc;
- printf("\n\tIHU ");
- if(len < 6) goto corrupt;
+ ND_PRINT((ndo, "\n\tIHU "));
+ if(len < 6) goto invalid;
txcost = EXTRACT_16BITS(message + 4);
interval = EXTRACT_16BITS(message + 6);
rc = network_address(message[2], message + 8, len - 6, address);
- if(rc < 0) { printf("[|babel]"); break; }
- printf("%s txcost %u interval %d",
- format_address(address), txcost, interval);
+ if(rc < 0) { ND_PRINT((ndo, "%s", tstr)); break; }
+ ND_PRINT((ndo, "%s txcost %u interval %s",
+ format_address(ndo, address), txcost, format_interval(interval)));
+ /* Extra data. */
+ if((u_int)rc < len - 6)
+ subtlvs_print(ndo, message + 8 + rc, message + 2 + len,
+ type);
}
}
break;
case MESSAGE_ROUTER_ID: {
- if(!vflag)
- printf(" router-id");
+ if (!ndo->ndo_vflag)
+ ND_PRINT((ndo, " router-id"));
else {
- printf("\n\tRouter Id");
- if(len < 10) goto corrupt;
- printf(" %s", format_id(message + 4));
+ ND_PRINT((ndo, "\n\tRouter Id"));
+ if(len < 10) goto invalid;
+ ND_PRINT((ndo, " %s", format_id(message + 4)));
}
}
break;
case MESSAGE_NH: {
- if(!vflag)
- printf(" nh");
+ if (!ndo->ndo_vflag)
+ ND_PRINT((ndo, " nh"));
else {
int rc;
u_char nh[16];
- printf("\n\tNext Hop");
- if(len < 2) goto corrupt;
+ ND_PRINT((ndo, "\n\tNext Hop"));
+ if(len < 2) goto invalid;
rc = network_address(message[2], message + 4, len - 2, nh);
- if(rc < 0) goto corrupt;
- printf(" %s", format_address(nh));
+ if(rc < 0) goto invalid;
+ ND_PRINT((ndo, " %s", format_address(ndo, nh)));
}
}
break;
case MESSAGE_UPDATE: {
- if(!vflag) {
- printf(" update");
+ if (!ndo->ndo_vflag) {
+ ND_PRINT((ndo, " update"));
if(len < 1)
- printf("/truncated");
+ ND_PRINT((ndo, "/truncated"));
else
- printf("%s%s%s",
+ ND_PRINT((ndo, "%s%s%s",
(message[3] & 0x80) ? "/prefix": "",
(message[3] & 0x40) ? "/id" : "",
- (message[3] & 0x3f) ? "/unknown" : "");
+ (message[3] & 0x3f) ? "/unknown" : ""));
} else {
u_short interval, seqno, metric;
u_char plen;
int rc;
u_char prefix[16];
- printf("\n\tUpdate");
- if(len < 10) goto corrupt;
+ ND_PRINT((ndo, "\n\tUpdate"));
+ if(len < 10) goto invalid;
plen = message[4] + (message[2] == 1 ? 96 : 0);
rc = network_prefix(message[2], message[4], message[5],
message + 12,
message[2] == 1 ? v4_prefix : v6_prefix,
len - 10, prefix);
- if(rc < 0) goto corrupt;
+ if(rc < 0) goto invalid;
interval = EXTRACT_16BITS(message + 6);
seqno = EXTRACT_16BITS(message + 8);
metric = EXTRACT_16BITS(message + 10);
- printf("%s%s%s %s metric %u seqno %u interval %u",
+ ND_PRINT((ndo, "%s%s%s %s metric %u seqno %u interval %s",
(message[3] & 0x80) ? "/prefix": "",
(message[3] & 0x40) ? "/id" : "",
(message[3] & 0x3f) ? "/unknown" : "",
- format_prefix(prefix, plen),
- metric, seqno, interval);
+ format_prefix(ndo, prefix, plen),
+ metric, seqno, format_interval_update(interval)));
if(message[3] & 0x80) {
if(message[2] == 1)
memcpy(v4_prefix, prefix, 16);
else
memcpy(v6_prefix, prefix, 16);
}
+ /* extra data? */
+ if((u_int)rc < len - 10)
+ subtlvs_print(ndo, message + 12 + rc, message + 2 + len, type);
}
}
break;
case MESSAGE_REQUEST: {
- if(!vflag)
- printf(" request");
+ if (!ndo->ndo_vflag)
+ ND_PRINT((ndo, " request"));
else {
int rc;
u_char prefix[16], plen;
- printf("\n\tRequest ");
- if(len < 2) goto corrupt;
+ ND_PRINT((ndo, "\n\tRequest "));
+ if(len < 2) goto invalid;
plen = message[3] + (message[2] == 1 ? 96 : 0);
rc = network_prefix(message[2], message[3], 0,
message + 4, NULL, len - 2, prefix);
- if(rc < 0) goto corrupt;
- plen = message[3] + (message[2] == 1 ? 96 : 0);
- printf("for %s",
- message[2] == 0 ? "any" : format_prefix(prefix, plen));
+ if(rc < 0) goto invalid;
+ ND_PRINT((ndo, "for %s",
+ message[2] == 0 ? "any" : format_prefix(ndo, prefix, plen)));
}
}
break;
case MESSAGE_MH_REQUEST : {
- if(!vflag)
- printf(" mh-request");
+ if (!ndo->ndo_vflag)
+ ND_PRINT((ndo, " mh-request"));
else {
int rc;
u_short seqno;
u_char prefix[16], plen;
- printf("\n\tMH-Request ");
- if(len < 14) goto corrupt;
+ ND_PRINT((ndo, "\n\tMH-Request "));
+ if(len < 14) goto invalid;
seqno = EXTRACT_16BITS(message + 4);
rc = network_prefix(message[2], message[3], 0,
message + 16, NULL, len - 14, prefix);
- if(rc < 0) goto corrupt;
+ if(rc < 0) goto invalid;
plen = message[3] + (message[2] == 1 ? 96 : 0);
- printf("(%u hops) for %s seqno %u id %s",
- message[6], format_prefix(prefix, plen),
- seqno, format_id(message + 8));
+ ND_PRINT((ndo, "(%u hops) for %s seqno %u id %s",
+ message[6], format_prefix(ndo, prefix, plen),
+ seqno, format_id(message + 8)));
}
}
break;
case MESSAGE_TSPC :
- if(!vflag)
- printf(" tspc");
+ if (!ndo->ndo_vflag)
+ ND_PRINT((ndo, " tspc"));
else {
- printf("\n\tTS/PC ");
- if(len < 6) goto corrupt;
- printf("timestamp %u packetcounter %u", EXTRACT_32BITS (message + 4),
- EXTRACT_16BITS(message + 2));
+ ND_PRINT((ndo, "\n\tTS/PC "));
+ if(len < 6) goto invalid;
+ ND_PRINT((ndo, "timestamp %u packetcounter %u", EXTRACT_32BITS (message + 4),
+ EXTRACT_16BITS(message + 2)));
}
break;
case MESSAGE_HMAC : {
- if(!vflag)
- printf(" hmac");
+ if (!ndo->ndo_vflag)
+ ND_PRINT((ndo, " hmac"));
else {
unsigned j;
- printf("\n\tHMAC ");
- if(len < 18) goto corrupt;
- printf("key-id %u digest-%u ", EXTRACT_16BITS(message + 2), len - 2);
+ ND_PRINT((ndo, "\n\tHMAC "));
+ if(len < 18) goto invalid;
+ ND_PRINT((ndo, "key-id %u digest-%u ", EXTRACT_16BITS(message + 2), len - 2));
for (j = 0; j < len - 2; j++)
- printf ("%02X", message[4 + j]);
+ ND_PRINT((ndo, "%02X", message[4 + j]));
}
}
break;
+
+ case MESSAGE_UPDATE_SRC_SPECIFIC : {
+ if(!ndo->ndo_vflag) {
+ ND_PRINT((ndo, " ss-update"));
+ } else {
+ u_char prefix[16], src_prefix[16];
+ u_short interval, seqno, metric;
+ u_char ae, plen, src_plen, omitted;
+ int rc;
+ int parsed_len = 10;
+ ND_PRINT((ndo, "\n\tSS-Update"));
+ if(len < 10) goto invalid;
+ ae = message[2];
+ src_plen = message[3];
+ plen = message[4];
+ omitted = message[5];
+ interval = EXTRACT_16BITS(message + 6);
+ seqno = EXTRACT_16BITS(message + 8);
+ metric = EXTRACT_16BITS(message + 10);
+ rc = network_prefix(ae, plen, omitted, message + 2 + parsed_len,
+ ae == 1 ? v4_prefix : v6_prefix,
+ len - parsed_len, prefix);
+ if(rc < 0) goto invalid;
+ if(ae == 1)
+ plen += 96;
+ parsed_len += rc;
+ rc = network_prefix(ae, src_plen, 0, message + 2 + parsed_len,
+ NULL, len - parsed_len, src_prefix);
+ if(rc < 0) goto invalid;
+ if(ae == 1)
+ src_plen += 96;
+ parsed_len += rc;
+
+ ND_PRINT((ndo, " %s from", format_prefix(ndo, prefix, plen)));
+ ND_PRINT((ndo, " %s metric %u seqno %u interval %s",
+ format_prefix(ndo, src_prefix, src_plen),
+ metric, seqno, format_interval_update(interval)));
+ /* extra data? */
+ if((u_int)parsed_len < len)
+ subtlvs_print(ndo, message + 2 + parsed_len,
+ message + 2 + len, type);
+ }
+ }
+ break;
+
+ case MESSAGE_REQUEST_SRC_SPECIFIC : {
+ if(!ndo->ndo_vflag)
+ ND_PRINT((ndo, " ss-request"));
+ else {
+ int rc, parsed_len = 3;
+ u_char ae, plen, src_plen, prefix[16], src_prefix[16];
+ ND_PRINT((ndo, "\n\tSS-Request "));
+ if(len < 3) goto invalid;
+ ae = message[2];
+ plen = message[3];
+ src_plen = message[4];
+ rc = network_prefix(ae, plen, 0, message + 2 + parsed_len,
+ NULL, len - parsed_len, prefix);
+ if(rc < 0) goto invalid;
+ if(ae == 1)
+ plen += 96;
+ parsed_len += rc;
+ rc = network_prefix(ae, src_plen, 0, message + 2 + parsed_len,
+ NULL, len - parsed_len, src_prefix);
+ if(rc < 0) goto invalid;
+ if(ae == 1)
+ src_plen += 96;
+ parsed_len += rc;
+ if(ae == 0) {
+ ND_PRINT((ndo, "for any"));
+ } else {
+ ND_PRINT((ndo, "for (%s, ", format_prefix(ndo, prefix, plen)));
+ ND_PRINT((ndo, "%s)", format_prefix(ndo, src_prefix, src_plen)));
+ }
+ }
+ }
+ break;
+
+ case MESSAGE_MH_REQUEST_SRC_SPECIFIC : {
+ if(!ndo->ndo_vflag)
+ ND_PRINT((ndo, " ss-mh-request"));
+ else {
+ int rc, parsed_len = 14;
+ u_short seqno;
+ u_char ae, plen, src_plen, prefix[16], src_prefix[16], hopc;
+ const u_char *router_id = NULL;
+ ND_PRINT((ndo, "\n\tSS-MH-Request "));
+ if(len < 14) goto invalid;
+ ae = message[2];
+ plen = message[3];
+ seqno = EXTRACT_16BITS(message + 4);
+ hopc = message[6];
+ src_plen = message[7];
+ router_id = message + 8;
+ rc = network_prefix(ae, plen, 0, message + 2 + parsed_len,
+ NULL, len - parsed_len, prefix);
+ if(rc < 0) goto invalid;
+ if(ae == 1)
+ plen += 96;
+ parsed_len += rc;
+ rc = network_prefix(ae, src_plen, 0, message + 2 + parsed_len,
+ NULL, len - parsed_len, src_prefix);
+ if(rc < 0) goto invalid;
+ if(ae == 1)
+ src_plen += 96;
+ ND_PRINT((ndo, "(%u hops) for (%s, ",
+ hopc, format_prefix(ndo, prefix, plen)));
+ ND_PRINT((ndo, "%s) seqno %u id %s",
+ format_prefix(ndo, src_prefix, src_plen),
+ seqno, format_id(router_id)));
+ }
+ }
+ break;
+
default:
- if(!vflag)
- printf(" unknown");
+ if (!ndo->ndo_vflag)
+ ND_PRINT((ndo, " unknown"));
else
- printf("\n\tUnknown message type %d", type);
+ ND_PRINT((ndo, "\n\tUnknown message type %d", type));
}
i += len + 2;
}
return;
trunc:
- printf(" [|babel]");
+ ND_PRINT((ndo, " %s", tstr));
return;
- corrupt:
- printf(" (corrupt)");
+ invalid:
+ ND_PRINT((ndo, "%s", istr));
return;
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-babel-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-beep.c b/freebsd/contrib/tcpdump/print-beep.c
index 30b5cb0c..884c6382 100644
--- a/freebsd/contrib/tcpdump/print-beep.c
+++ b/freebsd/contrib/tcpdump/print-beep.c
@@ -1,36 +1,30 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (C) 2000, Richard Sharpe
*
* This software may be distributed either under the terms of the
- * BSD-style licence that accompanies tcpdump or under the GNU GPL
+ * BSD-style license that accompanies tcpdump or under the GNU GPL
* version 2 or later.
*
* print-beep.c
*
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-beep.c,v 1.6 2003-11-16 09:36:13 guy Exp $";
-#endif
+/* \summary: Blocks Extensible Exchange Protocol (BEEP) printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#ifdef HAVE_MEMORY_H
-#include <memory.h>
-#endif
-#include <stdio.h>
-#include <stdlib.h>
#include <string.h>
-#include "interface.h"
-#include "extract.h"
+#include "netdissect.h"
/* Check for a string but not go beyond length
* Return TRUE on match, FALSE otherwise
@@ -38,8 +32,6 @@ static const char rcsid[] _U_ =
* Looks at the first few chars up to tl1 ...
*/
-static int l_strnstart(const char *, u_int, const char *, u_int);
-
static int
l_strnstart(const char *tstr1, u_int tl1, const char *str2, u_int l2)
{
@@ -51,23 +43,26 @@ l_strnstart(const char *tstr1, u_int tl1, const char *str2, u_int l2)
}
void
-beep_print(const u_char *bp, u_int length)
+beep_print(netdissect_options *ndo, const u_char *bp, u_int length)
{
if (l_strnstart("MSG", 4, (const char *)bp, length)) /* A REQuest */
- printf(" BEEP MSG");
+ ND_PRINT((ndo, " BEEP MSG"));
else if (l_strnstart("RPY ", 4, (const char *)bp, length))
- printf(" BEEP RPY");
+ ND_PRINT((ndo, " BEEP RPY"));
else if (l_strnstart("ERR ", 4, (const char *)bp, length))
- printf(" BEEP ERR");
+ ND_PRINT((ndo, " BEEP ERR"));
else if (l_strnstart("ANS ", 4, (const char *)bp, length))
- printf(" BEEP ANS");
+ ND_PRINT((ndo, " BEEP ANS"));
else if (l_strnstart("NUL ", 4, (const char *)bp, length))
- printf(" BEEP NUL");
+ ND_PRINT((ndo, " BEEP NUL"));
else if (l_strnstart("SEQ ", 4, (const char *)bp, length))
- printf(" BEEP SEQ");
+ ND_PRINT((ndo, " BEEP SEQ"));
else if (l_strnstart("END", 4, (const char *)bp, length))
- printf(" BEEP END");
+ ND_PRINT((ndo, " BEEP END"));
else
- printf(" BEEP (payload or undecoded)");
+ ND_PRINT((ndo, " BEEP (payload or undecoded)"));
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-beep-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-bfd.c b/freebsd/contrib/tcpdump/print-bfd.c
index e6f79e60..e956857d 100644
--- a/freebsd/contrib/tcpdump/print-bfd.c
+++ b/freebsd/contrib/tcpdump/print-bfd.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code
@@ -15,23 +18,18 @@
* Original code by Hannes Gredler (hannes@juniper.net)
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-bfd.c,v 1.10 2006-02-02 06:35:52 hannes Exp $";
-#endif
+/* \summary: Bidirectional Forwarding Detection (BFD) printer */
+
+/* specification: RFC 5880 (for version 1) and RFC 5881 */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
-
-#include <stdio.h>
-#include <stdlib.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
-#include "addrtoname.h"
#include "udp.h"
@@ -55,13 +53,13 @@ static const char rcsid[] _U_ =
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
-/*
- * Control packet, BFDv1, draft-ietf-bfd-base-02.txt
+/*
+ * Control packet, BFDv1, RFC 5880
*
* 0 1 2 3
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * |Vers | Diag |Sta|P|F|C|A|D|R| Detect Mult | Length |
+ * |Vers | Diag |Sta|P|F|C|A|D|M| Detect Mult | Length |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | My Discriminator |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
@@ -76,15 +74,15 @@ static const char rcsid[] _U_ =
*/
struct bfd_header_t {
- u_int8_t version_diag;
- u_int8_t flags;
- u_int8_t detect_time_multiplier;
- u_int8_t length;
- u_int8_t my_discriminator[4];
- u_int8_t your_discriminator[4];
- u_int8_t desired_min_tx_interval[4];
- u_int8_t required_min_rx_interval[4];
- u_int8_t required_min_echo_interval[4];
+ uint8_t version_diag;
+ uint8_t flags;
+ uint8_t detect_time_multiplier;
+ uint8_t length;
+ uint8_t my_discriminator[4];
+ uint8_t your_discriminator[4];
+ uint8_t desired_min_tx_interval[4];
+ uint8_t required_min_rx_interval[4];
+ uint8_t required_min_echo_interval[4];
};
/*
@@ -98,23 +96,40 @@ struct bfd_header_t {
*/
struct bfd_auth_header_t {
- u_int8_t auth_type;
- u_int8_t auth_len;
- u_int8_t auth_data;
+ uint8_t auth_type;
+ uint8_t auth_len;
+ uint8_t auth_data;
+ uint8_t dummy; /* minimun 4 bytes */
+};
+
+enum auth_type {
+ AUTH_PASSWORD = 1,
+ AUTH_MD5 = 2,
+ AUTH_MET_MD5 = 3,
+ AUTH_SHA1 = 4,
+ AUTH_MET_SHA1 = 5
};
static const struct tok bfd_v1_authentication_values[] = {
- { 0, "Reserved" },
- { 1, "Simple Password" },
- { 2, "Keyed MD5" },
- { 3, "Meticulous Keyed MD5" },
- { 4, "Keyed SHA1" },
- { 5, "Meticulous Keyed SHA1" },
+ { AUTH_PASSWORD, "Simple Password" },
+ { AUTH_MD5, "Keyed MD5" },
+ { AUTH_MET_MD5, "Meticulous Keyed MD5" },
+ { AUTH_SHA1, "Keyed SHA1" },
+ { AUTH_MET_SHA1, "Meticulous Keyed SHA1" },
{ 0, NULL }
};
-#define BFD_EXTRACT_VERSION(x) (((x)&0xe0)>>5)
-#define BFD_EXTRACT_DIAG(x) ((x)&0x1f)
+enum auth_length {
+ AUTH_PASSWORD_FIELD_MIN_LEN = 4, /* header + password min: 3 + 1 */
+ AUTH_PASSWORD_FIELD_MAX_LEN = 19, /* header + password max: 3 + 16 */
+ AUTH_MD5_FIELD_LEN = 24,
+ AUTH_MD5_HASH_LEN = 16,
+ AUTH_SHA1_FIELD_LEN = 28,
+ AUTH_SHA1_HASH_LEN = 20
+};
+
+#define BFD_EXTRACT_VERSION(x) (((x)&0xe0)>>5)
+#define BFD_EXTRACT_DIAG(x) ((x)&0x1f)
static const struct tok bfd_port_values[] = {
{ BFD_CONTROL_PORT, "Control" },
@@ -122,7 +137,6 @@ static const struct tok bfd_port_values[] = {
{ 0, NULL }
};
-
static const struct tok bfd_diag_values[] = {
{ 0, "No Diagnostic" },
{ 1, "Control Detection Time Expired" },
@@ -137,14 +151,14 @@ static const struct tok bfd_diag_values[] = {
};
static const struct tok bfd_v0_flag_values[] = {
- { 0x80, "I Hear You" },
- { 0x40, "Demand" },
- { 0x20, "Poll" },
- { 0x10, "Final" },
- { 0x08, "Reserved" },
- { 0x04, "Reserved" },
- { 0x02, "Reserved" },
- { 0x01, "Reserved" },
+ { 0x80, "I Hear You" },
+ { 0x40, "Demand" },
+ { 0x20, "Poll" },
+ { 0x10, "Final" },
+ { 0x08, "Reserved" },
+ { 0x04, "Reserved" },
+ { 0x02, "Reserved" },
+ { 0x01, "Reserved" },
{ 0, NULL }
};
@@ -156,7 +170,7 @@ static const struct tok bfd_v1_flag_values[] = {
{ 0x08, "Control Plane Independent" },
{ BFD_FLAG_AUTH, "Authentication Present" },
{ 0x02, "Demand" },
- { 0x01, "Reserved" },
+ { 0x01, "Multipoint" },
{ 0, NULL }
};
@@ -168,16 +182,127 @@ static const struct tok bfd_v1_state_values[] = {
{ 0, NULL }
};
+static int
+auth_print(netdissect_options *ndo, register const u_char *pptr)
+{
+ const struct bfd_auth_header_t *bfd_auth_header;
+ int i;
+
+ pptr += sizeof (const struct bfd_header_t);
+ bfd_auth_header = (const struct bfd_auth_header_t *)pptr;
+ ND_TCHECK(*bfd_auth_header);
+ ND_PRINT((ndo, "\n\tAuthentication: %s (%u), length: %u",
+ tok2str(bfd_v1_authentication_values,"Unknown",bfd_auth_header->auth_type),
+ bfd_auth_header->auth_type,
+ bfd_auth_header->auth_len));
+ pptr += 2;
+ ND_PRINT((ndo, "\n\t Auth Key ID: %d", *pptr));
+
+ switch(bfd_auth_header->auth_type) {
+ case AUTH_PASSWORD:
+/*
+ * Simple Password Authentication Section Format
+ *
+ * 0 1 2 3
+ * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Auth Type | Auth Len | Auth Key ID | Password... |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | ... |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+ if (bfd_auth_header->auth_len < AUTH_PASSWORD_FIELD_MIN_LEN ||
+ bfd_auth_header->auth_len > AUTH_PASSWORD_FIELD_MAX_LEN) {
+ ND_PRINT((ndo, "[invalid length %d]",
+ bfd_auth_header->auth_len));
+ break;
+ }
+ pptr++;
+ ND_PRINT((ndo, ", Password: "));
+ /* the length is equal to the password length plus three */
+ if (fn_printn(ndo, pptr, bfd_auth_header->auth_len - 3,
+ ndo->ndo_snapend))
+ goto trunc;
+ break;
+ case AUTH_MD5:
+ case AUTH_MET_MD5:
+/*
+ * Keyed MD5 and Meticulous Keyed MD5 Authentication Section Format
+ *
+ * 0 1 2 3
+ * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Auth Type | Auth Len | Auth Key ID | Reserved |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Sequence Number |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Auth Key/Digest... |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | ... |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+ if (bfd_auth_header->auth_len != AUTH_MD5_FIELD_LEN) {
+ ND_PRINT((ndo, "[invalid length %d]",
+ bfd_auth_header->auth_len));
+ break;
+ }
+ pptr += 2;
+ ND_TCHECK2(*pptr, 4);
+ ND_PRINT((ndo, ", Sequence Number: 0x%08x", EXTRACT_32BITS(pptr)));
+ pptr += 4;
+ ND_TCHECK2(*pptr, AUTH_MD5_HASH_LEN);
+ ND_PRINT((ndo, "\n\t Digest: "));
+ for(i = 0; i < AUTH_MD5_HASH_LEN; i++)
+ ND_PRINT((ndo, "%02x", pptr[i]));
+ break;
+ case AUTH_SHA1:
+ case AUTH_MET_SHA1:
+/*
+ * Keyed SHA1 and Meticulous Keyed SHA1 Authentication Section Format
+ *
+ * 0 1 2 3
+ * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Auth Type | Auth Len | Auth Key ID | Reserved |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Sequence Number |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Auth Key/Hash... |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | ... |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+ if (bfd_auth_header->auth_len != AUTH_SHA1_FIELD_LEN) {
+ ND_PRINT((ndo, "[invalid length %d]",
+ bfd_auth_header->auth_len));
+ break;
+ }
+ pptr += 2;
+ ND_TCHECK2(*pptr, 4);
+ ND_PRINT((ndo, ", Sequence Number: 0x%08x", EXTRACT_32BITS(pptr)));
+ pptr += 4;
+ ND_TCHECK2(*pptr, AUTH_SHA1_HASH_LEN);
+ ND_PRINT((ndo, "\n\t Hash: "));
+ for(i = 0; i < AUTH_SHA1_HASH_LEN; i++)
+ ND_PRINT((ndo, "%02x", pptr[i]));
+ break;
+ }
+ return 0;
+
+trunc:
+ return 1;
+}
+
void
-bfd_print(register const u_char *pptr, register u_int len, register u_int port)
+bfd_print(netdissect_options *ndo, register const u_char *pptr,
+ register u_int len, register u_int port)
{
const struct bfd_header_t *bfd_header;
- const struct bfd_auth_header_t *bfd_auth_header;
- u_int8_t version = 0;
+ uint8_t version = 0;
bfd_header = (const struct bfd_header_t *)pptr;
if (port == BFD_CONTROL_PORT) {
- TCHECK(*bfd_header);
+ ND_TCHECK(*bfd_header);
version = BFD_EXTRACT_VERSION(bfd_header->version_diag);
} else if (port == BFD_ECHO_PORT) {
/* Echo is BFD v1 only */
@@ -187,79 +312,74 @@ bfd_print(register const u_char *pptr, register u_int len, register u_int port)
/* BFDv0 */
case (BFD_CONTROL_PORT << 8):
- if (vflag < 1 )
+ if (ndo->ndo_vflag < 1)
{
- printf("BFDv%u, %s, Flags: [%s], length: %u",
+ ND_PRINT((ndo, "BFDv%u, %s, Flags: [%s], length: %u",
version,
tok2str(bfd_port_values, "unknown (%u)", port),
bittok2str(bfd_v0_flag_values, "none", bfd_header->flags),
- len);
+ len));
return;
}
-
- printf("BFDv%u, length: %u\n\t%s, Flags: [%s], Diagnostic: %s (0x%02x)",
+
+ ND_PRINT((ndo, "BFDv%u, length: %u\n\t%s, Flags: [%s], Diagnostic: %s (0x%02x)",
version,
len,
tok2str(bfd_port_values, "unknown (%u)", port),
bittok2str(bfd_v0_flag_values, "none", bfd_header->flags),
tok2str(bfd_diag_values,"unknown",BFD_EXTRACT_DIAG(bfd_header->version_diag)),
- BFD_EXTRACT_DIAG(bfd_header->version_diag));
-
- printf("\n\tDetection Timer Multiplier: %u (%u ms Detection time), BFD Length: %u",
+ BFD_EXTRACT_DIAG(bfd_header->version_diag)));
+
+ ND_PRINT((ndo, "\n\tDetection Timer Multiplier: %u (%u ms Detection time), BFD Length: %u",
bfd_header->detect_time_multiplier,
bfd_header->detect_time_multiplier * EXTRACT_32BITS(bfd_header->desired_min_tx_interval)/1000,
- bfd_header->length);
+ bfd_header->length));
- printf("\n\tMy Discriminator: 0x%08x", EXTRACT_32BITS(bfd_header->my_discriminator));
- printf(", Your Discriminator: 0x%08x", EXTRACT_32BITS(bfd_header->your_discriminator));
- printf("\n\t Desired min Tx Interval: %4u ms", EXTRACT_32BITS(bfd_header->desired_min_tx_interval)/1000);
- printf("\n\t Required min Rx Interval: %4u ms", EXTRACT_32BITS(bfd_header->required_min_rx_interval)/1000);
- printf("\n\t Required min Echo Interval: %4u ms", EXTRACT_32BITS(bfd_header->required_min_echo_interval)/1000);
+ ND_PRINT((ndo, "\n\tMy Discriminator: 0x%08x", EXTRACT_32BITS(bfd_header->my_discriminator)));
+ ND_PRINT((ndo, ", Your Discriminator: 0x%08x", EXTRACT_32BITS(bfd_header->your_discriminator)));
+ ND_PRINT((ndo, "\n\t Desired min Tx Interval: %4u ms", EXTRACT_32BITS(bfd_header->desired_min_tx_interval)/1000));
+ ND_PRINT((ndo, "\n\t Required min Rx Interval: %4u ms", EXTRACT_32BITS(bfd_header->required_min_rx_interval)/1000));
+ ND_PRINT((ndo, "\n\t Required min Echo Interval: %4u ms", EXTRACT_32BITS(bfd_header->required_min_echo_interval)/1000));
break;
/* BFDv1 */
case (BFD_CONTROL_PORT << 8 | 1):
- if (vflag < 1 )
+ if (ndo->ndo_vflag < 1)
{
- printf("BFDv%u, %s, State %s, Flags: [%s], length: %u",
+ ND_PRINT((ndo, "BFDv%u, %s, State %s, Flags: [%s], length: %u",
version,
tok2str(bfd_port_values, "unknown (%u)", port),
tok2str(bfd_v1_state_values, "unknown (%u)", (bfd_header->flags & 0xc0) >> 6),
bittok2str(bfd_v1_flag_values, "none", bfd_header->flags & 0x3f),
- len);
+ len));
return;
}
-
- printf("BFDv%u, length: %u\n\t%s, State %s, Flags: [%s], Diagnostic: %s (0x%02x)",
+
+ ND_PRINT((ndo, "BFDv%u, length: %u\n\t%s, State %s, Flags: [%s], Diagnostic: %s (0x%02x)",
version,
len,
tok2str(bfd_port_values, "unknown (%u)", port),
tok2str(bfd_v1_state_values, "unknown (%u)", (bfd_header->flags & 0xc0) >> 6),
bittok2str(bfd_v1_flag_values, "none", bfd_header->flags & 0x3f),
tok2str(bfd_diag_values,"unknown",BFD_EXTRACT_DIAG(bfd_header->version_diag)),
- BFD_EXTRACT_DIAG(bfd_header->version_diag));
-
- printf("\n\tDetection Timer Multiplier: %u (%u ms Detection time), BFD Length: %u",
+ BFD_EXTRACT_DIAG(bfd_header->version_diag)));
+
+ ND_PRINT((ndo, "\n\tDetection Timer Multiplier: %u (%u ms Detection time), BFD Length: %u",
bfd_header->detect_time_multiplier,
bfd_header->detect_time_multiplier * EXTRACT_32BITS(bfd_header->desired_min_tx_interval)/1000,
- bfd_header->length);
+ bfd_header->length));
- printf("\n\tMy Discriminator: 0x%08x", EXTRACT_32BITS(bfd_header->my_discriminator));
- printf(", Your Discriminator: 0x%08x", EXTRACT_32BITS(bfd_header->your_discriminator));
- printf("\n\t Desired min Tx Interval: %4u ms", EXTRACT_32BITS(bfd_header->desired_min_tx_interval)/1000);
- printf("\n\t Required min Rx Interval: %4u ms", EXTRACT_32BITS(bfd_header->required_min_rx_interval)/1000);
- printf("\n\t Required min Echo Interval: %4u ms", EXTRACT_32BITS(bfd_header->required_min_echo_interval)/1000);
+ ND_PRINT((ndo, "\n\tMy Discriminator: 0x%08x", EXTRACT_32BITS(bfd_header->my_discriminator)));
+ ND_PRINT((ndo, ", Your Discriminator: 0x%08x", EXTRACT_32BITS(bfd_header->your_discriminator)));
+ ND_PRINT((ndo, "\n\t Desired min Tx Interval: %4u ms", EXTRACT_32BITS(bfd_header->desired_min_tx_interval)/1000));
+ ND_PRINT((ndo, "\n\t Required min Rx Interval: %4u ms", EXTRACT_32BITS(bfd_header->required_min_rx_interval)/1000));
+ ND_PRINT((ndo, "\n\t Required min Echo Interval: %4u ms", EXTRACT_32BITS(bfd_header->required_min_echo_interval)/1000));
if (bfd_header->flags & BFD_FLAG_AUTH) {
- pptr += sizeof (const struct bfd_header_t);
- bfd_auth_header = (const struct bfd_auth_header_t *)pptr;
- TCHECK2(*bfd_auth_header, sizeof(const struct bfd_auth_header_t));
- printf("\n\t%s (%u) Authentication, length %u present",
- tok2str(bfd_v1_authentication_values,"Unknown",bfd_auth_header->auth_type),
- bfd_auth_header->auth_type,
- bfd_auth_header->auth_len);
+ if (auth_print(ndo, pptr))
+ goto trunc;
}
break;
@@ -269,17 +389,26 @@ bfd_print(register const u_char *pptr, register u_int len, register u_int port)
case (BFD_ECHO_PORT << 8 | 1):
default:
- printf("BFD, %s, length: %u",
+ ND_PRINT((ndo, "BFD, %s, length: %u",
tok2str(bfd_port_values, "unknown (%u)", port),
- len);
- if (vflag >= 1) {
- if(!print_unknown_data(pptr,"\n\t",len))
- return;
+ len));
+ if (ndo->ndo_vflag >= 1) {
+ if(!print_unknown_data(ndo, pptr,"\n\t",len))
+ return;
}
break;
}
return;
trunc:
- printf("[|BFD]");
+ ND_PRINT((ndo, "[|BFD]"));
}
+/*
+ * Local Variables:
+ * c-style: whitesmith
+ * c-basic-offset: 8
+ * End:
+ */
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-bfd-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-bgp.c b/freebsd/contrib/tcpdump/print-bgp.c
index f58bc316..a2ebdaf2 100644
--- a/freebsd/contrib/tcpdump/print-bgp.c
+++ b/freebsd/contrib/tcpdump/print-bgp.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (C) 1999 WIDE Project.
* All rights reserved.
@@ -32,32 +35,27 @@
* complete BGP support.
*/
+/* \summary: Border Gateway Protocol (BGP) printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-bgp.c,v 1.118 2007-12-07 15:54:52 hannes Exp $";
-#endif
-
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <stdio.h>
#include <string.h>
-#include "interface.h"
-#include "decode_prefix.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "extract.h"
-#include "bgp.h"
#include "af.h"
#include "l2vpn.h"
struct bgp {
- u_int8_t bgp_marker[16];
- u_int16_t bgp_len;
- u_int8_t bgp_type;
+ uint8_t bgp_marker[16];
+ uint16_t bgp_len;
+ uint8_t bgp_type;
};
#define BGP_SIZE 19 /* unaligned */
@@ -67,7 +65,7 @@ struct bgp {
#define BGP_KEEPALIVE 4
#define BGP_ROUTE_REFRESH 5
-static struct tok bgp_msg_values[] = {
+static const struct tok bgp_msg_values[] = {
{ BGP_OPEN, "Open"},
{ BGP_UPDATE, "Update"},
{ BGP_NOTIFICATION, "Notification"},
@@ -77,43 +75,43 @@ static struct tok bgp_msg_values[] = {
};
struct bgp_open {
- u_int8_t bgpo_marker[16];
- u_int16_t bgpo_len;
- u_int8_t bgpo_type;
- u_int8_t bgpo_version;
- u_int16_t bgpo_myas;
- u_int16_t bgpo_holdtime;
- u_int32_t bgpo_id;
- u_int8_t bgpo_optlen;
+ uint8_t bgpo_marker[16];
+ uint16_t bgpo_len;
+ uint8_t bgpo_type;
+ uint8_t bgpo_version;
+ uint16_t bgpo_myas;
+ uint16_t bgpo_holdtime;
+ uint32_t bgpo_id;
+ uint8_t bgpo_optlen;
/* options should follow */
};
#define BGP_OPEN_SIZE 29 /* unaligned */
struct bgp_opt {
- u_int8_t bgpopt_type;
- u_int8_t bgpopt_len;
+ uint8_t bgpopt_type;
+ uint8_t bgpopt_len;
/* variable length */
};
#define BGP_OPT_SIZE 2 /* some compilers may pad to 4 bytes */
#define BGP_CAP_HEADER_SIZE 2 /* some compilers may pad to 4 bytes */
struct bgp_notification {
- u_int8_t bgpn_marker[16];
- u_int16_t bgpn_len;
- u_int8_t bgpn_type;
- u_int8_t bgpn_major;
- u_int8_t bgpn_minor;
+ uint8_t bgpn_marker[16];
+ uint16_t bgpn_len;
+ uint8_t bgpn_type;
+ uint8_t bgpn_major;
+ uint8_t bgpn_minor;
};
#define BGP_NOTIFICATION_SIZE 21 /* unaligned */
struct bgp_route_refresh {
- u_int8_t bgp_marker[16];
- u_int16_t len;
- u_int8_t type;
- u_int8_t afi[2]; /* the compiler messes this structure up */
- u_int8_t res; /* when doing misaligned sequences of int8 and int16 */
- u_int8_t safi; /* afi should be int16 - so we have to access it using */
-}; /* EXTRACT_16BITS(&bgp_route_refresh->afi) (sigh) */
+ uint8_t bgp_marker[16];
+ uint16_t len;
+ uint8_t type;
+ uint8_t afi[2]; /* the compiler messes this structure up */
+ uint8_t res; /* when doing misaligned sequences of int8 and int16 */
+ uint8_t safi; /* afi should be int16 - so we have to access it using */
+}; /* EXTRACT_16BITS(&bgp_route_refresh->afi) (sigh) */
#define BGP_ROUTE_REFRESH_SIZE 23
#define bgp_attr_lenlen(flags, p) \
@@ -129,22 +127,29 @@ struct bgp_route_refresh {
#define BGPTYPE_ATOMIC_AGGREGATE 6
#define BGPTYPE_AGGREGATOR 7
#define BGPTYPE_COMMUNITIES 8 /* RFC1997 */
-#define BGPTYPE_ORIGINATOR_ID 9 /* RFC1998 */
-#define BGPTYPE_CLUSTER_LIST 10 /* RFC1998 */
-#define BGPTYPE_DPA 11 /* draft-ietf-idr-bgp-dpa */
-#define BGPTYPE_ADVERTISERS 12 /* RFC1863 */
-#define BGPTYPE_RCID_PATH 13 /* RFC1863 */
-#define BGPTYPE_MP_REACH_NLRI 14 /* RFC2283 */
-#define BGPTYPE_MP_UNREACH_NLRI 15 /* RFC2283 */
-#define BGPTYPE_EXTD_COMMUNITIES 16 /* draft-ietf-idr-bgp-ext-communities */
-#define BGPTYPE_AS4_PATH 17 /* RFC4893 */
-#define BGPTYPE_AGGREGATOR4 18 /* RFC4893 */
-#define BGPTYPE_PMSI_TUNNEL 22 /* draft-ietf-l3vpn-2547bis-mcast-bgp-02.txt */
-#define BGPTYPE_ATTR_SET 128 /* draft-marques-ppvpn-ibgp */
+#define BGPTYPE_ORIGINATOR_ID 9 /* RFC4456 */
+#define BGPTYPE_CLUSTER_LIST 10 /* RFC4456 */
+#define BGPTYPE_DPA 11 /* deprecated, draft-ietf-idr-bgp-dpa */
+#define BGPTYPE_ADVERTISERS 12 /* deprecated RFC1863 */
+#define BGPTYPE_RCID_PATH 13 /* deprecated RFC1863 */
+#define BGPTYPE_MP_REACH_NLRI 14 /* RFC4760 */
+#define BGPTYPE_MP_UNREACH_NLRI 15 /* RFC4760 */
+#define BGPTYPE_EXTD_COMMUNITIES 16 /* RFC4360 */
+#define BGPTYPE_AS4_PATH 17 /* RFC6793 */
+#define BGPTYPE_AGGREGATOR4 18 /* RFC6793 */
+#define BGPTYPE_PMSI_TUNNEL 22 /* RFC6514 */
+#define BGPTYPE_TUNNEL_ENCAP 23 /* RFC5512 */
+#define BGPTYPE_TRAFFIC_ENG 24 /* RFC5543 */
+#define BGPTYPE_IPV6_EXTD_COMMUNITIES 25 /* RFC5701 */
+#define BGPTYPE_AIGP 26 /* RFC7311 */
+#define BGPTYPE_PE_DISTINGUISHER_LABEL 27 /* RFC6514 */
+#define BGPTYPE_ENTROPY_LABEL 28 /* RFC6790 */
+#define BGPTYPE_LARGE_COMMUNITY 32 /* draft-ietf-idr-large-community-05 */
+#define BGPTYPE_ATTR_SET 128 /* RFC6368 */
#define BGP_MP_NLRI_MINSIZE 3 /* End of RIB Marker detection */
-static struct tok bgp_attr_values[] = {
+static const struct tok bgp_attr_values[] = {
{ BGPTYPE_ORIGIN, "Origin"},
{ BGPTYPE_AS_PATH, "AS Path"},
{ BGPTYPE_AS4_PATH, "AS4 Path"},
@@ -164,6 +169,13 @@ static struct tok bgp_attr_values[] = {
{ BGPTYPE_MP_UNREACH_NLRI, "Multi-Protocol Unreach NLRI"},
{ BGPTYPE_EXTD_COMMUNITIES, "Extended Community"},
{ BGPTYPE_PMSI_TUNNEL, "PMSI Tunnel"},
+ { BGPTYPE_TUNNEL_ENCAP, "Tunnel Encapsulation"},
+ { BGPTYPE_TRAFFIC_ENG, "Traffic Engineering"},
+ { BGPTYPE_IPV6_EXTD_COMMUNITIES, "IPv6 Extended Community"},
+ { BGPTYPE_AIGP, "Accumulated IGP Metric"},
+ { BGPTYPE_PE_DISTINGUISHER_LABEL, "PE Distinguisher Label"},
+ { BGPTYPE_ENTROPY_LABEL, "Entropy Label"},
+ { BGPTYPE_LARGE_COMMUNITY, "Large Community"},
{ BGPTYPE_ATTR_SET, "Attribute Set"},
{ 255, "Reserved for development"},
{ 0, NULL}
@@ -177,7 +189,7 @@ static struct tok bgp_attr_values[] = {
#define BGP_AS_SEG_TYPE_MIN BGP_AS_SET
#define BGP_AS_SEG_TYPE_MAX BGP_CONFED_AS_SET
-static struct tok bgp_as_path_segment_open_values[] = {
+static const struct tok bgp_as_path_segment_open_values[] = {
{ BGP_AS_SEQUENCE, ""},
{ BGP_AS_SET, "{ "},
{ BGP_CONFED_AS_SEQUENCE, "( "},
@@ -185,7 +197,7 @@ static struct tok bgp_as_path_segment_open_values[] = {
{ 0, NULL}
};
-static struct tok bgp_as_path_segment_close_values[] = {
+static const struct tok bgp_as_path_segment_close_values[] = {
{ BGP_AS_SEQUENCE, ""},
{ BGP_AS_SET, "}"},
{ BGP_CONFED_AS_SEQUENCE, ")"},
@@ -196,28 +208,37 @@ static struct tok bgp_as_path_segment_close_values[] = {
#define BGP_OPT_AUTH 1
#define BGP_OPT_CAP 2
-
-static struct tok bgp_opt_values[] = {
+static const struct tok bgp_opt_values[] = {
{ BGP_OPT_AUTH, "Authentication Information"},
{ BGP_OPT_CAP, "Capabilities Advertisement"},
{ 0, NULL}
};
-#define BGP_CAPCODE_MP 1
-#define BGP_CAPCODE_RR 2
-#define BGP_CAPCODE_ORF 3 /* XXX */
-#define BGP_CAPCODE_RESTART 64 /* draft-ietf-idr-restart-05 */
-#define BGP_CAPCODE_AS_NEW 65 /* XXX */
-#define BGP_CAPCODE_DYN_CAP 67 /* XXX */
+#define BGP_CAPCODE_MP 1 /* RFC2858 */
+#define BGP_CAPCODE_RR 2 /* RFC2918 */
+#define BGP_CAPCODE_ORF 3 /* RFC5291 */
+#define BGP_CAPCODE_MR 4 /* RFC3107 */
+#define BGP_CAPCODE_EXT_NH 5 /* RFC5549 */
+#define BGP_CAPCODE_RESTART 64 /* RFC4724 */
+#define BGP_CAPCODE_AS_NEW 65 /* RFC6793 */
+#define BGP_CAPCODE_DYN_CAP 67 /* draft-ietf-idr-dynamic-cap */
+#define BGP_CAPCODE_MULTISESS 68 /* draft-ietf-idr-bgp-multisession */
+#define BGP_CAPCODE_ADD_PATH 69 /* RFC7911 */
+#define BGP_CAPCODE_ENH_RR 70 /* draft-keyur-bgp-enhanced-route-refresh */
#define BGP_CAPCODE_RR_CISCO 128
-static struct tok bgp_capcode_values[] = {
+static const struct tok bgp_capcode_values[] = {
{ BGP_CAPCODE_MP, "Multiprotocol Extensions"},
{ BGP_CAPCODE_RR, "Route Refresh"},
{ BGP_CAPCODE_ORF, "Cooperative Route Filtering"},
+ { BGP_CAPCODE_MR, "Multiple Routes to a Destination"},
+ { BGP_CAPCODE_EXT_NH, "Extended Next Hop Encoding"},
{ BGP_CAPCODE_RESTART, "Graceful Restart"},
{ BGP_CAPCODE_AS_NEW, "32-Bit AS Number"},
{ BGP_CAPCODE_DYN_CAP, "Dynamic Capability"},
+ { BGP_CAPCODE_MULTISESS, "Multisession BGP"},
+ { BGP_CAPCODE_ADD_PATH, "Multiple Paths"},
+ { BGP_CAPCODE_ENH_RR, "Enhanced Route Refresh"},
{ BGP_CAPCODE_RR_CISCO, "Route Refresh (Cisco)"},
{ 0, NULL}
};
@@ -230,7 +251,7 @@ static struct tok bgp_capcode_values[] = {
#define BGP_NOTIFY_MAJOR_CEASE 6
#define BGP_NOTIFY_MAJOR_CAP 7
-static struct tok bgp_notify_major_values[] = {
+static const struct tok bgp_notify_major_values[] = {
{ BGP_NOTIFY_MAJOR_MSG, "Message Header Error"},
{ BGP_NOTIFY_MAJOR_OPEN, "OPEN Message Error"},
{ BGP_NOTIFY_MAJOR_UPDATE, "UPDATE Message Error"},
@@ -243,7 +264,7 @@ static struct tok bgp_notify_major_values[] = {
/* draft-ietf-idr-cease-subcode-02 */
#define BGP_NOTIFY_MINOR_CEASE_MAXPRFX 1
-static struct tok bgp_notify_minor_cease_values[] = {
+static const struct tok bgp_notify_minor_cease_values[] = {
{ BGP_NOTIFY_MINOR_CEASE_MAXPRFX, "Maximum Number of Prefixes Reached"},
{ 2, "Administratively Shutdown"},
{ 3, "Peer Unconfigured"},
@@ -254,14 +275,14 @@ static struct tok bgp_notify_minor_cease_values[] = {
{ 0, NULL}
};
-static struct tok bgp_notify_minor_msg_values[] = {
+static const struct tok bgp_notify_minor_msg_values[] = {
{ 1, "Connection Not Synchronized"},
{ 2, "Bad Message Length"},
{ 3, "Bad Message Type"},
{ 0, NULL}
};
-static struct tok bgp_notify_minor_open_values[] = {
+static const struct tok bgp_notify_minor_open_values[] = {
{ 1, "Unsupported Version Number"},
{ 2, "Bad Peer AS"},
{ 3, "Bad BGP Identifier"},
@@ -272,7 +293,7 @@ static struct tok bgp_notify_minor_open_values[] = {
{ 0, NULL}
};
-static struct tok bgp_notify_minor_update_values[] = {
+static const struct tok bgp_notify_minor_update_values[] = {
{ 1, "Malformed Attribute List"},
{ 2, "Unrecognized Well-known Attribute"},
{ 3, "Missing Well-known Attribute"},
@@ -287,7 +308,14 @@ static struct tok bgp_notify_minor_update_values[] = {
{ 0, NULL}
};
-static struct tok bgp_notify_minor_cap_values[] = {
+static const struct tok bgp_notify_minor_fsm_values[] = {
+ { 1, "In OpenSent State"},
+ { 2, "In OpenConfirm State"},
+ { 3, "In Established State"},
+ { 0, NULL }
+};
+
+static const struct tok bgp_notify_minor_cap_values[] = {
{ 1, "Invalid Action Value" },
{ 2, "Invalid Capability Length" },
{ 3, "Malformed Capability Value" },
@@ -295,7 +323,7 @@ static struct tok bgp_notify_minor_cap_values[] = {
{ 0, NULL }
};
-static struct tok bgp_origin_values[] = {
+static const struct tok bgp_origin_values[] = {
{ 0, "IGP"},
{ 1, "EGP"},
{ 2, "Incomplete"},
@@ -310,7 +338,7 @@ static struct tok bgp_origin_values[] = {
#define BGP_PMSI_TUNNEL_INGRESS 6
#define BGP_PMSI_TUNNEL_LDP_MP2MP 7
-static struct tok bgp_pmsi_tunnel_values[] = {
+static const struct tok bgp_pmsi_tunnel_values[] = {
{ BGP_PMSI_TUNNEL_RSVP_P2MP, "RSVP-TE P2MP LSP"},
{ BGP_PMSI_TUNNEL_LDP_P2MP, "LDP P2MP LSP"},
{ BGP_PMSI_TUNNEL_PIM_SSM, "PIM-SSM Tree"},
@@ -321,35 +349,44 @@ static struct tok bgp_pmsi_tunnel_values[] = {
{ 0, NULL}
};
-static struct tok bgp_pmsi_flag_values[] = {
+static const struct tok bgp_pmsi_flag_values[] = {
{ 0x01, "Leaf Information required"},
{ 0, NULL}
};
+#define BGP_AIGP_TLV 1
+
+static const struct tok bgp_aigp_values[] = {
+ { BGP_AIGP_TLV, "AIGP"},
+ { 0, NULL}
+};
/* Subsequent address family identifier, RFC2283 section 7 */
#define SAFNUM_RES 0
#define SAFNUM_UNICAST 1
#define SAFNUM_MULTICAST 2
-#define SAFNUM_UNIMULTICAST 3
+#define SAFNUM_UNIMULTICAST 3 /* deprecated now */
/* labeled BGP RFC3107 */
#define SAFNUM_LABUNICAST 4
-/* draft-ietf-l3vpn-2547bis-mcast-bgp-02.txt */
+/* RFC6514 */
#define SAFNUM_MULTICAST_VPN 5
-#define SAFNUM_TUNNEL 64 /* XXX */
-#define SAFNUM_VPLS 65 /* XXX */
-/* draft-nalawade-idr-mdt-safi-03 */
+/* draft-nalawade-kapoor-tunnel-safi */
+#define SAFNUM_TUNNEL 64
+/* RFC4761 */
+#define SAFNUM_VPLS 65
+/* RFC6037 */
#define SAFNUM_MDT 66
-/* Section 4.3.4 of draft-rosen-rfc2547bis-03.txt */
+/* RFC4364 */
#define SAFNUM_VPNUNICAST 128
+/* RFC6513 */
#define SAFNUM_VPNMULTICAST 129
-#define SAFNUM_VPNUNIMULTICAST 130
-/* draft-marques-ppvpn-rt-constrain-01.txt */
+#define SAFNUM_VPNUNIMULTICAST 130 /* deprecated now */
+/* RFC4684 */
#define SAFNUM_RT_ROUTING_INFO 132
#define BGP_VPN_RD_LEN 8
-static struct tok bgp_safi_values[] = {
+static const struct tok bgp_safi_values[] = {
{ SAFNUM_RES, "Reserved"},
{ SAFNUM_UNICAST, "Unicast"},
{ SAFNUM_MULTICAST, "Multicast"},
@@ -389,7 +426,7 @@ static struct tok bgp_safi_values[] = {
#define BGP_EXT_COM_OSPF_RTYPE2 0x8000 /* duplicate - keep for backwards compatability */
#define BGP_EXT_COM_OSPF_RID 0x0107 /* OSPF Router ID,Format RouterID(4B):Unused(2B) */
-#define BGP_EXT_COM_OSPF_RID2 0x8001 /* duplicate - keep for backwards compatability */
+#define BGP_EXT_COM_OSPF_RID2 0x8001 /* duplicate - keep for backwards compatability */
#define BGP_EXT_COM_L2INFO 0x800a /* draft-kompella-ppvpn-l2vpn */
@@ -398,7 +435,6 @@ static struct tok bgp_safi_values[] = {
#define BGP_EXT_COM_L2VPN_RT_0 0x000a /* L2VPN Identifier,Format AS(2bytes):AN(4bytes) */
#define BGP_EXT_COM_L2VPN_RT_1 0xF10a /* L2VPN Identifier,Format IP address:AN(2bytes) */
-
/* http://www.cisco.com/en/US/tech/tk436/tk428/technologies_tech_note09186a00801eb09a.shtml */
#define BGP_EXT_COM_EIGRP_GEN 0x8800
#define BGP_EXT_COM_EIGRP_METRIC_AS_DELAY 0x8801
@@ -407,13 +443,13 @@ static struct tok bgp_safi_values[] = {
#define BGP_EXT_COM_EIGRP_EXT_REMAS_REMID 0x8804
#define BGP_EXT_COM_EIGRP_EXT_REMPROTO_REMMETRIC 0x8805
-static struct tok bgp_extd_comm_flag_values[] = {
+static const struct tok bgp_extd_comm_flag_values[] = {
{ 0x8000, "vendor-specific"},
{ 0x4000, "non-transitive"},
{ 0, NULL},
};
-static struct tok bgp_extd_comm_subtype_values[] = {
+static const struct tok bgp_extd_comm_subtype_values[] = {
{ BGP_EXT_COM_RT_0, "target"},
{ BGP_EXT_COM_RT_1, "target"},
{ BGP_EXT_COM_RT_2, "target"},
@@ -429,7 +465,7 @@ static struct tok bgp_extd_comm_subtype_values[] = {
{ BGP_EXT_COM_OSPF_RTYPE2, "ospf-route-type"},
{ BGP_EXT_COM_OSPF_RID, "ospf-router-id"},
{ BGP_EXT_COM_OSPF_RID2, "ospf-router-id"},
- { BGP_EXT_COM_L2INFO, "layer2-info"},
+ { BGP_EXT_COM_L2INFO, "layer2-info"},
{ BGP_EXT_COM_EIGRP_GEN , "eigrp-general-route (flag, tag)" },
{ BGP_EXT_COM_EIGRP_METRIC_AS_DELAY , "eigrp-route-metric (AS, delay)" },
{ BGP_EXT_COM_EIGRP_METRIC_REL_NH_BW , "eigrp-route-metric (reliability, nexthop, bandwidth)" },
@@ -452,17 +488,24 @@ static struct tok bgp_extd_comm_subtype_values[] = {
#define BGP_OSPF_RTYPE_SHAM 129 /* OSPF-MPLS-VPN Sham link */
#define BGP_OSPF_RTYPE_METRIC_TYPE 0x1 /* LSB of RTYPE Options Field */
-static struct tok bgp_extd_comm_ospf_rtype_values[] = {
- { BGP_OSPF_RTYPE_RTR, "Router" },
- { BGP_OSPF_RTYPE_NET, "Network" },
- { BGP_OSPF_RTYPE_SUM, "Summary" },
- { BGP_OSPF_RTYPE_EXT, "External" },
+static const struct tok bgp_extd_comm_ospf_rtype_values[] = {
+ { BGP_OSPF_RTYPE_RTR, "Router" },
+ { BGP_OSPF_RTYPE_NET, "Network" },
+ { BGP_OSPF_RTYPE_SUM, "Summary" },
+ { BGP_OSPF_RTYPE_EXT, "External" },
{ BGP_OSPF_RTYPE_NSSA,"NSSA External" },
- { BGP_OSPF_RTYPE_SHAM,"MPLS-VPN Sham" },
+ { BGP_OSPF_RTYPE_SHAM,"MPLS-VPN Sham" },
+ { 0, NULL },
+};
+
+/* ADD-PATH Send/Receive field values */
+static const struct tok bgp_add_path_recvsend[] = {
+ { 1, "Receive" },
+ { 2, "Send" },
+ { 3, "Both" },
{ 0, NULL },
};
-#define TOKBUFSIZE 128
static char astostr[20];
/*
@@ -470,14 +513,15 @@ static char astostr[20];
*
* Convert an AS number into a string and return string pointer.
*
- * Bepending on bflag is set or not, AS number is converted into ASDOT notation
+ * Depending on bflag is set or not, AS number is converted into ASDOT notation
* or plain number notation.
*
*/
static char *
-as_printf (char *str, int size, u_int asnum)
+as_printf(netdissect_options *ndo,
+ char *str, int size, u_int asnum)
{
- if (!bflag || asnum <= 0xFFFF) {
+ if (!ndo->ndo_bflag || asnum <= 0xFFFF) {
snprintf(str, size, "%u", asnum);
} else {
snprintf(str, size, "%u.%u", asnum >> 16, asnum & 0xFFFF);
@@ -488,12 +532,13 @@ as_printf (char *str, int size, u_int asnum)
#define ITEMCHECK(minlen) if (itemlen < minlen) goto badtlv;
int
-decode_prefix4(const u_char *pptr, u_int itemlen, char *buf, u_int buflen)
+decode_prefix4(netdissect_options *ndo,
+ const u_char *pptr, u_int itemlen, char *buf, u_int buflen)
{
struct in_addr addr;
u_int plen, plenbytes;
- TCHECK(pptr[0]);
+ ND_TCHECK(pptr[0]);
ITEMCHECK(1);
plen = pptr[0];
if (32 < plen)
@@ -502,14 +547,14 @@ decode_prefix4(const u_char *pptr, u_int itemlen, char *buf, u_int buflen)
memset(&addr, 0, sizeof(addr));
plenbytes = (plen + 7) / 8;
- TCHECK2(pptr[1], plenbytes);
+ ND_TCHECK2(pptr[1], plenbytes);
ITEMCHECK(plenbytes);
memcpy(&addr, &pptr[1], plenbytes);
if (plen % 8) {
((u_char *)&addr)[plenbytes - 1] &=
((0xff00 >> (plen % 8)) & 0xff);
}
- snprintf(buf, buflen, "%s/%d", getname((u_char *)&addr), plen);
+ snprintf(buf, buflen, "%s/%d", ipaddr_string(ndo, &addr), plen);
return 1 + plenbytes;
trunc:
@@ -520,13 +565,14 @@ badtlv:
}
static int
-decode_labeled_prefix4(const u_char *pptr, u_int itemlen, char *buf, u_int buflen)
+decode_labeled_prefix4(netdissect_options *ndo,
+ const u_char *pptr, u_int itemlen, char *buf, u_int buflen)
{
struct in_addr addr;
u_int plen, plenbytes;
/* prefix length and label = 4 bytes */
- TCHECK2(pptr[0], 4);
+ ND_TCHECK2(pptr[0], 4);
ITEMCHECK(4);
plen = pptr[0]; /* get prefix length */
@@ -535,7 +581,7 @@ decode_labeled_prefix4(const u_char *pptr, u_int itemlen, char *buf, u_int bufle
is added to the prefix length;
we also do only read out just one label -
there is no real application for advertisement of
- stacked labels in a a single BGP message
+ stacked labels in a single BGP message
*/
if (24 > plen)
@@ -549,7 +595,7 @@ decode_labeled_prefix4(const u_char *pptr, u_int itemlen, char *buf, u_int bufle
memset(&addr, 0, sizeof(addr));
plenbytes = (plen + 7) / 8;
- TCHECK2(pptr[4], plenbytes);
+ ND_TCHECK2(pptr[4], plenbytes);
ITEMCHECK(plenbytes);
memcpy(&addr, &pptr[4], plenbytes);
if (plen % 8) {
@@ -558,7 +604,7 @@ decode_labeled_prefix4(const u_char *pptr, u_int itemlen, char *buf, u_int bufle
}
/* the label may get offsetted by 4 bits so lets shift it right */
snprintf(buf, buflen, "%s/%d, label:%u %s",
- getname((u_char *)&addr),
+ ipaddr_string(ndo, &addr),
plen,
EXTRACT_24BITS(pptr+1)>>4,
((pptr[3]&1)==0) ? "(BOGUS: Bottom of Stack NOT set!)" : "(bottom)" );
@@ -578,7 +624,9 @@ badtlv:
* print an ipv4 or ipv6 address into a buffer dependend on address length.
*/
static char *
-bgp_vpn_ip_print (const u_char *pptr, u_int addr_length) {
+bgp_vpn_ip_print(netdissect_options *ndo,
+ const u_char *pptr, u_int addr_length)
+{
/* worst case string is s fully formatted v6 address */
static char addr[sizeof("1234:5678:89ab:cdef:1234:5678:89ab:cdef")];
@@ -586,15 +634,13 @@ bgp_vpn_ip_print (const u_char *pptr, u_int addr_length) {
switch(addr_length) {
case (sizeof(struct in_addr) << 3): /* 32 */
- TCHECK2(pptr[0], sizeof(struct in_addr));
- snprintf(pos, sizeof(addr), "%s", ipaddr_string(pptr));
+ ND_TCHECK2(pptr[0], sizeof(struct in_addr));
+ snprintf(pos, sizeof(addr), "%s", ipaddr_string(ndo, pptr));
break;
-#ifdef INET6
case (sizeof(struct in6_addr) << 3): /* 128 */
- TCHECK2(pptr[0], sizeof(struct in6_addr));
- snprintf(pos, sizeof(addr), "%s", ip6addr_string(pptr));
+ ND_TCHECK2(pptr[0], sizeof(struct in6_addr));
+ snprintf(pos, sizeof(addr), "%s", ip6addr_string(ndo, pptr));
break;
-#endif
default:
snprintf(pos, sizeof(addr), "bogus address length %u", addr_length);
break;
@@ -625,38 +671,39 @@ trunc:
* return the number of bytes read from the wire.
*/
static int
-bgp_vpn_sg_print (const u_char *pptr, char *buf, u_int buflen) {
-
- u_int8_t addr_length;
+bgp_vpn_sg_print(netdissect_options *ndo,
+ const u_char *pptr, char *buf, u_int buflen)
+{
+ uint8_t addr_length;
u_int total_length, offset;
total_length = 0;
/* Source address length, encoded in bits */
- TCHECK2(pptr[0], 1);
+ ND_TCHECK2(pptr[0], 1);
addr_length = *pptr++;
/* Source address */
- TCHECK2(pptr[0], (addr_length >> 3));
+ ND_TCHECK2(pptr[0], (addr_length >> 3));
total_length += (addr_length >> 3) + 1;
offset = strlen(buf);
if (addr_length) {
snprintf(buf + offset, buflen - offset, ", Source %s",
- bgp_vpn_ip_print(pptr, addr_length));
+ bgp_vpn_ip_print(ndo, pptr, addr_length));
pptr += (addr_length >> 3);
}
-
+
/* Group address length, encoded in bits */
- TCHECK2(pptr[0], 1);
+ ND_TCHECK2(pptr[0], 1);
addr_length = *pptr++;
/* Group address */
- TCHECK2(pptr[0], (addr_length >> 3));
+ ND_TCHECK2(pptr[0], (addr_length >> 3));
total_length += (addr_length >> 3) + 1;
offset = strlen(buf);
if (addr_length) {
snprintf(buf + offset, buflen - offset, ", Group %s",
- bgp_vpn_ip_print(pptr, addr_length));
+ bgp_vpn_ip_print(ndo, pptr, addr_length));
pptr += (addr_length >> 3);
}
@@ -664,13 +711,13 @@ trunc:
return (total_length);
}
-
/* RDs and RTs share the same semantics
* we use bgp_vpn_rd_print for
* printing route targets inside a NLRI */
char *
-bgp_vpn_rd_print (const u_char *pptr) {
-
+bgp_vpn_rd_print(netdissect_options *ndo,
+ const u_char *pptr)
+{
/* allocate space for the largest possible string */
static char rd[sizeof("xxxxxxxxxx:xxxxx (xxx.xxx.xxx.xxx:xxxxx)")];
char *pos = rd;
@@ -695,7 +742,7 @@ bgp_vpn_rd_print (const u_char *pptr) {
/* 4-byte-AS:number fmt*/
case 2:
snprintf(pos, sizeof(rd) - (pos - rd), "%s:%u (%u.%u.%u.%u:%u)",
- as_printf(astostr, sizeof(astostr), EXTRACT_32BITS(pptr+2)),
+ as_printf(ndo, astostr, sizeof(astostr), EXTRACT_32BITS(pptr+2)),
EXTRACT_16BITS(pptr+6), *(pptr+2), *(pptr+3), *(pptr+4),
*(pptr+5), EXTRACT_16BITS(pptr+6));
break;
@@ -709,16 +756,19 @@ bgp_vpn_rd_print (const u_char *pptr) {
}
static int
-decode_rt_routing_info(const u_char *pptr, char *buf, u_int buflen)
+decode_rt_routing_info(netdissect_options *ndo,
+ const u_char *pptr, char *buf, u_int buflen)
{
- u_int8_t route_target[8];
+ uint8_t route_target[8];
u_int plen;
- TCHECK(pptr[0]);
+ ND_TCHECK(pptr[0]);
plen = pptr[0]; /* get prefix length */
- if (0 == plen)
- return 1; /* default route target */
+ if (0 == plen) {
+ snprintf(buf, buflen, "default route target");
+ return 1;
+ }
if (32 > plen)
return -1;
@@ -729,15 +779,15 @@ decode_rt_routing_info(const u_char *pptr, char *buf, u_int buflen)
return -1;
memset(&route_target, 0, sizeof(route_target));
- TCHECK2(pptr[1], (plen + 7) / 8);
+ ND_TCHECK2(pptr[1], (plen + 7) / 8);
memcpy(&route_target, &pptr[1], (plen + 7) / 8);
if (plen % 8) {
((u_char *)&route_target)[(plen + 7) / 8 - 1] &=
((0xff00 >> (plen % 8)) & 0xff);
}
snprintf(buf, buflen, "origin AS: %s, route target %s",
- as_printf(astostr, sizeof(astostr), EXTRACT_32BITS(pptr+1)),
- bgp_vpn_rd_print((u_char *)&route_target));
+ as_printf(ndo, astostr, sizeof(astostr), EXTRACT_32BITS(pptr+1)),
+ bgp_vpn_rd_print(ndo, (u_char *)&route_target));
return 5 + (plen + 7) / 8;
@@ -746,12 +796,13 @@ trunc:
}
static int
-decode_labeled_vpn_prefix4(const u_char *pptr, char *buf, u_int buflen)
+decode_labeled_vpn_prefix4(netdissect_options *ndo,
+ const u_char *pptr, char *buf, u_int buflen)
{
struct in_addr addr;
u_int plen;
- TCHECK(pptr[0]);
+ ND_TCHECK(pptr[0]);
plen = pptr[0]; /* get prefix length */
if ((24+64) > plen)
@@ -763,7 +814,7 @@ decode_labeled_vpn_prefix4(const u_char *pptr, char *buf, u_int buflen)
return -1;
memset(&addr, 0, sizeof(addr));
- TCHECK2(pptr[12], (plen + 7) / 8);
+ ND_TCHECK2(pptr[12], (plen + 7) / 8);
memcpy(&addr, &pptr[12], (plen + 7) / 8);
if (plen % 8) {
((u_char *)&addr)[(plen + 7) / 8 - 1] &=
@@ -771,8 +822,8 @@ decode_labeled_vpn_prefix4(const u_char *pptr, char *buf, u_int buflen)
}
/* the label may get offsetted by 4 bits so lets shift it right */
snprintf(buf, buflen, "RD: %s, %s/%d, label:%u %s",
- bgp_vpn_rd_print(pptr+4),
- getname((u_char *)&addr),
+ bgp_vpn_rd_print(ndo, pptr+4),
+ ipaddr_string(ndo, &addr),
plen,
EXTRACT_24BITS(pptr+1)>>4,
((pptr[3]&1)==0) ? "(BOGUS: Bottom of Stack NOT set!)" : "(bottom)" );
@@ -796,35 +847,36 @@ trunc:
#define MDT_VPN_NLRI_LEN 16
static int
-decode_mdt_vpn_nlri(const u_char *pptr, char *buf, u_int buflen)
+decode_mdt_vpn_nlri(netdissect_options *ndo,
+ const u_char *pptr, char *buf, u_int buflen)
{
const u_char *rd;
const u_char *vpn_ip;
-
- TCHECK(pptr[0]);
+
+ ND_TCHECK(pptr[0]);
/* if the NLRI is not predefined length, quit.*/
- if (*pptr != MDT_VPN_NLRI_LEN * NBBY)
+ if (*pptr != MDT_VPN_NLRI_LEN * 8)
return -1;
pptr++;
/* RD */
- TCHECK2(pptr[0], 8);
+ ND_TCHECK2(pptr[0], 8);
rd = pptr;
pptr+=8;
/* IPv4 address */
- TCHECK2(pptr[0], sizeof(struct in_addr));
+ ND_TCHECK2(pptr[0], sizeof(struct in_addr));
vpn_ip = pptr;
pptr+=sizeof(struct in_addr);
/* MDT Group Address */
- TCHECK2(pptr[0], sizeof(struct in_addr));
+ ND_TCHECK2(pptr[0], sizeof(struct in_addr));
snprintf(buf, buflen, "RD: %s, VPN IP Address: %s, MC Group Address: %s",
- bgp_vpn_rd_print(rd), ipaddr_string(vpn_ip), ipaddr_string(pptr));
-
+ bgp_vpn_rd_print(ndo, rd), ipaddr_string(ndo, vpn_ip), ipaddr_string(ndo, pptr));
+
return MDT_VPN_NLRI_LEN + 1;
trunc:
@@ -840,7 +892,7 @@ return -2;
#define BGP_MULTICAST_VPN_ROUTE_TYPE_SHARED_TREE_JOIN 6
#define BGP_MULTICAST_VPN_ROUTE_TYPE_SOURCE_TREE_JOIN 7
-static struct tok bgp_multicast_vpn_route_type_values[] = {
+static const struct tok bgp_multicast_vpn_route_type_values[] = {
{ BGP_MULTICAST_VPN_ROUTE_TYPE_INTRA_AS_I_PMSI, "Intra-AS I-PMSI"},
{ BGP_MULTICAST_VPN_ROUTE_TYPE_INTER_AS_I_PMSI, "Inter-AS I-PMSI"},
{ BGP_MULTICAST_VPN_ROUTE_TYPE_S_PMSI, "S-PMSI"},
@@ -851,12 +903,13 @@ static struct tok bgp_multicast_vpn_route_type_values[] = {
};
static int
-decode_multicast_vpn(const u_char *pptr, char *buf, u_int buflen)
+decode_multicast_vpn(netdissect_options *ndo,
+ const u_char *pptr, char *buf, u_int buflen)
{
- u_int8_t route_type, route_length, addr_length, sg_length;
+ uint8_t route_type, route_length, addr_length, sg_length;
u_int offset;
- TCHECK2(pptr[0], 2);
+ ND_TCHECK2(pptr[0], 2);
route_type = *pptr++;
route_length = *pptr++;
@@ -867,59 +920,59 @@ decode_multicast_vpn(const u_char *pptr, char *buf, u_int buflen)
switch(route_type) {
case BGP_MULTICAST_VPN_ROUTE_TYPE_INTRA_AS_I_PMSI:
- TCHECK2(pptr[0], BGP_VPN_RD_LEN);
+ ND_TCHECK2(pptr[0], BGP_VPN_RD_LEN);
offset = strlen(buf);
snprintf(buf + offset, buflen - offset, ", RD: %s, Originator %s",
- bgp_vpn_rd_print(pptr),
- bgp_vpn_ip_print(pptr + BGP_VPN_RD_LEN,
+ bgp_vpn_rd_print(ndo, pptr),
+ bgp_vpn_ip_print(ndo, pptr + BGP_VPN_RD_LEN,
(route_length - BGP_VPN_RD_LEN) << 3));
break;
case BGP_MULTICAST_VPN_ROUTE_TYPE_INTER_AS_I_PMSI:
- TCHECK2(pptr[0], BGP_VPN_RD_LEN + 4);
+ ND_TCHECK2(pptr[0], BGP_VPN_RD_LEN + 4);
offset = strlen(buf);
snprintf(buf + offset, buflen - offset, ", RD: %s, Source-AS %s",
- bgp_vpn_rd_print(pptr),
- as_printf(astostr, sizeof(astostr),
+ bgp_vpn_rd_print(ndo, pptr),
+ as_printf(ndo, astostr, sizeof(astostr),
EXTRACT_32BITS(pptr + BGP_VPN_RD_LEN)));
break;
case BGP_MULTICAST_VPN_ROUTE_TYPE_S_PMSI:
- TCHECK2(pptr[0], BGP_VPN_RD_LEN);
+ ND_TCHECK2(pptr[0], BGP_VPN_RD_LEN);
offset = strlen(buf);
snprintf(buf + offset, buflen - offset, ", RD: %s",
- bgp_vpn_rd_print(pptr));
+ bgp_vpn_rd_print(ndo, pptr));
pptr += BGP_VPN_RD_LEN;
- sg_length = bgp_vpn_sg_print(pptr, buf, buflen);
+ sg_length = bgp_vpn_sg_print(ndo, pptr, buf, buflen);
addr_length = route_length - sg_length;
- TCHECK2(pptr[0], addr_length);
+ ND_TCHECK2(pptr[0], addr_length);
offset = strlen(buf);
snprintf(buf + offset, buflen - offset, ", Originator %s",
- bgp_vpn_ip_print(pptr, addr_length << 3));
+ bgp_vpn_ip_print(ndo, pptr, addr_length << 3));
break;
case BGP_MULTICAST_VPN_ROUTE_TYPE_SOURCE_ACTIVE:
- TCHECK2(pptr[0], BGP_VPN_RD_LEN);
+ ND_TCHECK2(pptr[0], BGP_VPN_RD_LEN);
offset = strlen(buf);
snprintf(buf + offset, buflen - offset, ", RD: %s",
- bgp_vpn_rd_print(pptr));
+ bgp_vpn_rd_print(ndo, pptr));
pptr += BGP_VPN_RD_LEN;
- bgp_vpn_sg_print(pptr, buf, buflen);
+ bgp_vpn_sg_print(ndo, pptr, buf, buflen);
break;
case BGP_MULTICAST_VPN_ROUTE_TYPE_SHARED_TREE_JOIN: /* fall through */
case BGP_MULTICAST_VPN_ROUTE_TYPE_SOURCE_TREE_JOIN:
- TCHECK2(pptr[0], BGP_VPN_RD_LEN);
+ ND_TCHECK2(pptr[0], BGP_VPN_RD_LEN);
offset = strlen(buf);
snprintf(buf + offset, buflen - offset, ", RD: %s, Source-AS %s",
- bgp_vpn_rd_print(pptr),
- as_printf(astostr, sizeof(astostr),
+ bgp_vpn_rd_print(ndo, pptr),
+ as_printf(ndo, astostr, sizeof(astostr),
EXTRACT_32BITS(pptr + BGP_VPN_RD_LEN)));
pptr += BGP_VPN_RD_LEN;
- bgp_vpn_sg_print(pptr, buf, buflen);
+ bgp_vpn_sg_print(ndo, pptr, buf, buflen);
break;
/*
@@ -946,22 +999,23 @@ trunc:
* the buffer would have overflowed; again, set buflen to 0 in
* that case.
*/
-#define UPDATE_BUF_BUFLEN(buf, buflen, strlen) \
- if (strlen<0) \
+#define UPDATE_BUF_BUFLEN(buf, buflen, stringlen) \
+ if (stringlen<0) \
buflen=0; \
- else if ((u_int)strlen>buflen) \
+ else if ((u_int)stringlen>buflen) \
buflen=0; \
else { \
- buflen-=strlen; \
- buf+=strlen; \
+ buflen-=stringlen; \
+ buf+=stringlen; \
}
static int
-decode_labeled_vpn_l2(const u_char *pptr, char *buf, u_int buflen)
+decode_labeled_vpn_l2(netdissect_options *ndo,
+ const u_char *pptr, char *buf, u_int buflen)
{
- int plen,tlen,strlen,tlv_type,tlv_len,ttlv_len;
+ int plen,tlen,stringlen,tlv_type,tlv_len,ttlv_len;
- TCHECK2(pptr[0], 2);
+ ND_TCHECK2(pptr[0], 2);
plen=EXTRACT_16BITS(pptr);
tlen=plen;
pptr+=2;
@@ -969,31 +1023,30 @@ decode_labeled_vpn_l2(const u_char *pptr, char *buf, u_int buflen)
* -> Assume a 12 Byte-length NLRI is auto-discovery-only
* and > 17 as old format. Complain for the middle case
*/
- if (plen==12) {
+ if (plen==12) {
/* assume AD-only with RD, BGPNH */
- TCHECK2(pptr[0],12);
+ ND_TCHECK2(pptr[0],12);
buf[0]='\0';
- strlen=snprintf(buf, buflen, "RD: %s, BGPNH: %s",
- bgp_vpn_rd_print(pptr),
- /* need something like getname() here */
- getname(pptr+8)
- );
- UPDATE_BUF_BUFLEN(buf, buflen, strlen);
+ stringlen=snprintf(buf, buflen, "RD: %s, BGPNH: %s",
+ bgp_vpn_rd_print(ndo, pptr),
+ ipaddr_string(ndo, pptr+8)
+ );
+ UPDATE_BUF_BUFLEN(buf, buflen, stringlen);
pptr+=12;
tlen-=12;
return plen;
- } else if (plen>17) {
+ } else if (plen>17) {
/* assume old format */
/* RD, ID, LBLKOFF, LBLBASE */
- TCHECK2(pptr[0],15);
+ ND_TCHECK2(pptr[0],15);
buf[0]='\0';
- strlen=snprintf(buf, buflen, "RD: %s, CE-ID: %u, Label-Block Offset: %u, Label Base %u",
- bgp_vpn_rd_print(pptr),
- EXTRACT_16BITS(pptr+8),
- EXTRACT_16BITS(pptr+10),
- EXTRACT_24BITS(pptr+12)>>4); /* the label is offsetted by 4 bits so lets shift it right */
- UPDATE_BUF_BUFLEN(buf, buflen, strlen);
+ stringlen=snprintf(buf, buflen, "RD: %s, CE-ID: %u, Label-Block Offset: %u, Label Base %u",
+ bgp_vpn_rd_print(ndo, pptr),
+ EXTRACT_16BITS(pptr+8),
+ EXTRACT_16BITS(pptr+10),
+ EXTRACT_24BITS(pptr+12)>>4); /* the label is offsetted by 4 bits so lets shift it right */
+ UPDATE_BUF_BUFLEN(buf, buflen, stringlen);
pptr+=15;
tlen-=15;
@@ -1001,7 +1054,7 @@ decode_labeled_vpn_l2(const u_char *pptr, char *buf, u_int buflen)
while (tlen>0) {
if (tlen < 3)
return -1;
- TCHECK2(pptr[0], 3);
+ ND_TCHECK2(pptr[0], 3);
tlv_type=*pptr++;
tlv_len=EXTRACT_16BITS(pptr);
ttlv_len=tlv_len;
@@ -1010,34 +1063,34 @@ decode_labeled_vpn_l2(const u_char *pptr, char *buf, u_int buflen)
switch(tlv_type) {
case 1:
if (buflen!=0) {
- strlen=snprintf(buf,buflen, "\n\t\tcircuit status vector (%u) length: %u: 0x",
- tlv_type,
- tlv_len);
- UPDATE_BUF_BUFLEN(buf, buflen, strlen);
+ stringlen=snprintf(buf,buflen, "\n\t\tcircuit status vector (%u) length: %u: 0x",
+ tlv_type,
+ tlv_len);
+ UPDATE_BUF_BUFLEN(buf, buflen, stringlen);
}
ttlv_len=ttlv_len/8+1; /* how many bytes do we need to read ? */
while (ttlv_len>0) {
- TCHECK(pptr[0]);
+ ND_TCHECK(pptr[0]);
if (buflen!=0) {
- strlen=snprintf(buf,buflen, "%02x",*pptr++);
- UPDATE_BUF_BUFLEN(buf, buflen, strlen);
+ stringlen=snprintf(buf,buflen, "%02x",*pptr++);
+ UPDATE_BUF_BUFLEN(buf, buflen, stringlen);
}
ttlv_len--;
}
break;
default:
if (buflen!=0) {
- strlen=snprintf(buf,buflen, "\n\t\tunknown TLV #%u, length: %u",
- tlv_type,
- tlv_len);
- UPDATE_BUF_BUFLEN(buf, buflen, strlen);
+ stringlen=snprintf(buf,buflen, "\n\t\tunknown TLV #%u, length: %u",
+ tlv_type,
+ tlv_len);
+ UPDATE_BUF_BUFLEN(buf, buflen, stringlen);
}
break;
}
tlen-=(tlv_len<<3); /* the tlv-length is expressed in bits so lets shift it right */
}
return plen+2;
-
+
} else {
/* complain bitterly ? */
/* fall through */
@@ -1048,14 +1101,14 @@ trunc:
return -2;
}
-#ifdef INET6
int
-decode_prefix6(const u_char *pd, u_int itemlen, char *buf, u_int buflen)
+decode_prefix6(netdissect_options *ndo,
+ const u_char *pd, u_int itemlen, char *buf, u_int buflen)
{
struct in6_addr addr;
u_int plen, plenbytes;
- TCHECK(pd[0]);
+ ND_TCHECK(pd[0]);
ITEMCHECK(1);
plen = pd[0];
if (128 < plen)
@@ -1064,14 +1117,14 @@ decode_prefix6(const u_char *pd, u_int itemlen, char *buf, u_int buflen)
memset(&addr, 0, sizeof(addr));
plenbytes = (plen + 7) / 8;
- TCHECK2(pd[1], plenbytes);
+ ND_TCHECK2(pd[1], plenbytes);
ITEMCHECK(plenbytes);
memcpy(&addr, &pd[1], plenbytes);
if (plen % 8) {
addr.s6_addr[plenbytes - 1] &=
((0xff00 >> (plen % 8)) & 0xff);
}
- snprintf(buf, buflen, "%s/%d", getname6((u_char *)&addr), plen);
+ snprintf(buf, buflen, "%s/%d", ip6addr_string(ndo, &addr), plen);
return 1 + plenbytes;
trunc:
@@ -1082,13 +1135,14 @@ badtlv:
}
static int
-decode_labeled_prefix6(const u_char *pptr, u_int itemlen, char *buf, u_int buflen)
+decode_labeled_prefix6(netdissect_options *ndo,
+ const u_char *pptr, u_int itemlen, char *buf, u_int buflen)
{
struct in6_addr addr;
u_int plen, plenbytes;
/* prefix length and label = 4 bytes */
- TCHECK2(pptr[0], 4);
+ ND_TCHECK2(pptr[0], 4);
ITEMCHECK(4);
plen = pptr[0]; /* get prefix length */
@@ -1103,7 +1157,7 @@ decode_labeled_prefix6(const u_char *pptr, u_int itemlen, char *buf, u_int bufle
memset(&addr, 0, sizeof(addr));
plenbytes = (plen + 7) / 8;
- TCHECK2(pptr[4], plenbytes);
+ ND_TCHECK2(pptr[4], plenbytes);
memcpy(&addr, &pptr[4], plenbytes);
if (plen % 8) {
addr.s6_addr[plenbytes - 1] &=
@@ -1111,7 +1165,7 @@ decode_labeled_prefix6(const u_char *pptr, u_int itemlen, char *buf, u_int bufle
}
/* the label may get offsetted by 4 bits so lets shift it right */
snprintf(buf, buflen, "%s/%d, label:%u %s",
- getname6((u_char *)&addr),
+ ip6addr_string(ndo, &addr),
plen,
EXTRACT_24BITS(pptr+1)>>4,
((pptr[3]&1)==0) ? "(BOGUS: Bottom of Stack NOT set!)" : "(bottom)" );
@@ -1126,12 +1180,13 @@ badtlv:
}
static int
-decode_labeled_vpn_prefix6(const u_char *pptr, char *buf, u_int buflen)
+decode_labeled_vpn_prefix6(netdissect_options *ndo,
+ const u_char *pptr, char *buf, u_int buflen)
{
struct in6_addr addr;
u_int plen;
- TCHECK(pptr[0]);
+ ND_TCHECK(pptr[0]);
plen = pptr[0]; /* get prefix length */
if ((24+64) > plen)
@@ -1143,7 +1198,7 @@ decode_labeled_vpn_prefix6(const u_char *pptr, char *buf, u_int buflen)
return -1;
memset(&addr, 0, sizeof(addr));
- TCHECK2(pptr[12], (plen + 7) / 8);
+ ND_TCHECK2(pptr[12], (plen + 7) / 8);
memcpy(&addr, &pptr[12], (plen + 7) / 8);
if (plen % 8) {
addr.s6_addr[(plen + 7) / 8 - 1] &=
@@ -1151,8 +1206,8 @@ decode_labeled_vpn_prefix6(const u_char *pptr, char *buf, u_int buflen)
}
/* the label may get offsetted by 4 bits so lets shift it right */
snprintf(buf, buflen, "RD: %s, %s/%d, label:%u %s",
- bgp_vpn_rd_print(pptr+4),
- getname6((u_char *)&addr),
+ bgp_vpn_rd_print(ndo, pptr+4),
+ ip6addr_string(ndo, &addr),
plen,
EXTRACT_24BITS(pptr+1)>>4,
((pptr[3]&1)==0) ? "(BOGUS: Bottom of Stack NOT set!)" : "(bottom)" );
@@ -1162,29 +1217,29 @@ decode_labeled_vpn_prefix6(const u_char *pptr, char *buf, u_int buflen)
trunc:
return -2;
}
-#endif
static int
-decode_clnp_prefix(const u_char *pptr, char *buf, u_int buflen)
+decode_clnp_prefix(netdissect_options *ndo,
+ const u_char *pptr, char *buf, u_int buflen)
{
- u_int8_t addr[19];
+ uint8_t addr[19];
u_int plen;
- TCHECK(pptr[0]);
+ ND_TCHECK(pptr[0]);
plen = pptr[0]; /* get prefix length */
if (152 < plen)
return -1;
memset(&addr, 0, sizeof(addr));
- TCHECK2(pptr[4], (plen + 7) / 8);
+ ND_TCHECK2(pptr[4], (plen + 7) / 8);
memcpy(&addr, &pptr[4], (plen + 7) / 8);
if (plen % 8) {
addr[(plen + 7) / 8 - 1] &=
((0xff00 >> (plen % 8)) & 0xff);
}
snprintf(buf, buflen, "%s/%d",
- isonsap_string(addr,(plen + 7) / 8),
+ isonsap_string(ndo, addr,(plen + 7) / 8),
plen);
return 1 + (plen + 7) / 8;
@@ -1194,12 +1249,13 @@ trunc:
}
static int
-decode_labeled_vpn_clnp_prefix(const u_char *pptr, char *buf, u_int buflen)
+decode_labeled_vpn_clnp_prefix(netdissect_options *ndo,
+ const u_char *pptr, char *buf, u_int buflen)
{
- u_int8_t addr[19];
+ uint8_t addr[19];
u_int plen;
- TCHECK(pptr[0]);
+ ND_TCHECK(pptr[0]);
plen = pptr[0]; /* get prefix length */
if ((24+64) > plen)
@@ -1211,7 +1267,7 @@ decode_labeled_vpn_clnp_prefix(const u_char *pptr, char *buf, u_int buflen)
return -1;
memset(&addr, 0, sizeof(addr));
- TCHECK2(pptr[12], (plen + 7) / 8);
+ ND_TCHECK2(pptr[12], (plen + 7) / 8);
memcpy(&addr, &pptr[12], (plen + 7) / 8);
if (plen % 8) {
addr[(plen + 7) / 8 - 1] &=
@@ -1219,8 +1275,8 @@ decode_labeled_vpn_clnp_prefix(const u_char *pptr, char *buf, u_int buflen)
}
/* the label may get offsetted by 4 bits so lets shift it right */
snprintf(buf, buflen, "RD: %s, %s/%d, label:%u %s",
- bgp_vpn_rd_print(pptr+4),
- isonsap_string(addr,(plen + 7) / 8),
+ bgp_vpn_rd_print(ndo, pptr+4),
+ isonsap_string(ndo, addr,(plen + 7) / 8),
plen,
EXTRACT_24BITS(pptr+1)>>4,
((pptr[3]&1)==0) ? "(BOGUS: Bottom of Stack NOT set!)" : "(bottom)" );
@@ -1239,7 +1295,8 @@ trunc:
* support, exchange AS-Path with the same path-attribute type value 0x02.
*/
static int
-bgp_attr_get_as_size (u_int8_t bgpa_type, const u_char *pptr, int len)
+bgp_attr_get_as_size(netdissect_options *ndo,
+ uint8_t bgpa_type, const u_char *pptr, int len)
{
const u_char *tptr = pptr;
@@ -1257,7 +1314,7 @@ bgp_attr_get_as_size (u_int8_t bgpa_type, const u_char *pptr, int len)
* each.
*/
while (tptr < pptr + len) {
- TCHECK(tptr[0]);
+ ND_TCHECK(tptr[0]);
/*
* If we do not find a valid segment type, our guess might be wrong.
@@ -1265,7 +1322,7 @@ bgp_attr_get_as_size (u_int8_t bgpa_type, const u_char *pptr, int len)
if (tptr[0] < BGP_AS_SEG_TYPE_MIN || tptr[0] > BGP_AS_SEG_TYPE_MAX) {
goto trunc;
}
- TCHECK(tptr[1]);
+ ND_TCHECK(tptr[1]);
tptr += 2 + tptr[1] * 2;
}
@@ -1289,20 +1346,20 @@ trunc:
}
static int
-bgp_attr_print(u_int atype, const u_char *pptr, u_int len)
+bgp_attr_print(netdissect_options *ndo,
+ u_int atype, const u_char *pptr, u_int len)
{
int i;
- u_int16_t af;
- u_int8_t safi, snpa, nhlen;
+ uint16_t af;
+ uint8_t safi, snpa, nhlen;
union { /* copy buffer for bandwidth values */
- float f;
- u_int32_t i;
+ float f;
+ uint32_t i;
} bw;
int advance;
u_int tlen;
const u_char *tptr;
char buf[MAXHOSTNAMELEN + 100];
- char tokbuf[TOKBUFSIZE];
int as_size;
tptr = pptr;
@@ -1311,28 +1368,26 @@ bgp_attr_print(u_int atype, const u_char *pptr, u_int len)
switch (atype) {
case BGPTYPE_ORIGIN:
if (len != 1)
- printf("invalid len");
+ ND_PRINT((ndo, "invalid len"));
else {
- TCHECK(*tptr);
- printf("%s", tok2strbuf(bgp_origin_values,
+ ND_TCHECK(*tptr);
+ ND_PRINT((ndo, "%s", tok2str(bgp_origin_values,
"Unknown Origin Typecode",
- tptr[0],
- tokbuf, sizeof(tokbuf)));
+ tptr[0])));
}
break;
-
/*
* Process AS4 byte path and AS2 byte path attributes here.
*/
case BGPTYPE_AS4_PATH:
case BGPTYPE_AS_PATH:
if (len % 2) {
- printf("invalid len");
+ ND_PRINT((ndo, "invalid len"));
break;
}
if (!len) {
- printf("empty");
+ ND_PRINT((ndo, "empty"));
break;
}
@@ -1344,49 +1399,47 @@ bgp_attr_print(u_int atype, const u_char *pptr, u_int len)
* 2 bytes first, and it does not pass, assume that ASs are
* encoded in 4 bytes format and move on.
*/
- as_size = bgp_attr_get_as_size(atype, pptr, len);
+ as_size = bgp_attr_get_as_size(ndo, atype, pptr, len);
while (tptr < pptr + len) {
- TCHECK(tptr[0]);
- printf("%s", tok2strbuf(bgp_as_path_segment_open_values,
- "?", tptr[0],
- tokbuf, sizeof(tokbuf)));
+ ND_TCHECK(tptr[0]);
+ ND_PRINT((ndo, "%s", tok2str(bgp_as_path_segment_open_values,
+ "?", tptr[0])));
for (i = 0; i < tptr[1] * as_size; i += as_size) {
- TCHECK2(tptr[2 + i], as_size);
- printf("%s ",
- as_printf(astostr, sizeof(astostr),
- as_size == 2 ?
+ ND_TCHECK2(tptr[2 + i], as_size);
+ ND_PRINT((ndo, "%s ",
+ as_printf(ndo, astostr, sizeof(astostr),
+ as_size == 2 ?
EXTRACT_16BITS(&tptr[2 + i]) :
- EXTRACT_32BITS(&tptr[2 + i])));
+ EXTRACT_32BITS(&tptr[2 + i]))));
}
- TCHECK(tptr[0]);
- printf("%s", tok2strbuf(bgp_as_path_segment_close_values,
- "?", tptr[0],
- tokbuf, sizeof(tokbuf)));
- TCHECK(tptr[1]);
+ ND_TCHECK(tptr[0]);
+ ND_PRINT((ndo, "%s", tok2str(bgp_as_path_segment_close_values,
+ "?", tptr[0])));
+ ND_TCHECK(tptr[1]);
tptr += 2 + tptr[1] * as_size;
}
break;
case BGPTYPE_NEXT_HOP:
if (len != 4)
- printf("invalid len");
+ ND_PRINT((ndo, "invalid len"));
else {
- TCHECK2(tptr[0], 4);
- printf("%s", getname(tptr));
+ ND_TCHECK2(tptr[0], 4);
+ ND_PRINT((ndo, "%s", ipaddr_string(ndo, tptr)));
}
break;
case BGPTYPE_MULTI_EXIT_DISC:
case BGPTYPE_LOCAL_PREF:
if (len != 4)
- printf("invalid len");
+ ND_PRINT((ndo, "invalid len"));
else {
- TCHECK2(tptr[0], 4);
- printf("%u", EXTRACT_32BITS(tptr));
+ ND_TCHECK2(tptr[0], 4);
+ ND_PRINT((ndo, "%u", EXTRACT_32BITS(tptr)));
}
break;
case BGPTYPE_ATOMIC_AGGREGATE:
if (len != 0)
- printf("invalid len");
+ ND_PRINT((ndo, "invalid len"));
break;
case BGPTYPE_AGGREGATOR:
@@ -1395,54 +1448,54 @@ bgp_attr_print(u_int atype, const u_char *pptr, u_int len)
* the length of this PA can be either 6 bytes or 8 bytes.
*/
if (len != 6 && len != 8) {
- printf("invalid len");
+ ND_PRINT((ndo, "invalid len"));
break;
}
- TCHECK2(tptr[0], len);
+ ND_TCHECK2(tptr[0], len);
if (len == 6) {
- printf(" AS #%s, origin %s",
- as_printf(astostr, sizeof(astostr), EXTRACT_16BITS(tptr)),
- getname(tptr + 2));
+ ND_PRINT((ndo, " AS #%s, origin %s",
+ as_printf(ndo, astostr, sizeof(astostr), EXTRACT_16BITS(tptr)),
+ ipaddr_string(ndo, tptr + 2)));
} else {
- printf(" AS #%s, origin %s",
- as_printf(astostr, sizeof(astostr),
- EXTRACT_32BITS(tptr)), getname(tptr + 4));
+ ND_PRINT((ndo, " AS #%s, origin %s",
+ as_printf(ndo, astostr, sizeof(astostr),
+ EXTRACT_32BITS(tptr)), ipaddr_string(ndo, tptr + 4)));
}
break;
case BGPTYPE_AGGREGATOR4:
if (len != 8) {
- printf("invalid len");
+ ND_PRINT((ndo, "invalid len"));
break;
}
- TCHECK2(tptr[0], 8);
- printf(" AS #%s, origin %s",
- as_printf(astostr, sizeof(astostr), EXTRACT_32BITS(tptr)),
- getname(tptr + 4));
+ ND_TCHECK2(tptr[0], 8);
+ ND_PRINT((ndo, " AS #%s, origin %s",
+ as_printf(ndo, astostr, sizeof(astostr), EXTRACT_32BITS(tptr)),
+ ipaddr_string(ndo, tptr + 4)));
break;
case BGPTYPE_COMMUNITIES:
if (len % 4) {
- printf("invalid len");
+ ND_PRINT((ndo, "invalid len"));
break;
}
while (tlen>0) {
- u_int32_t comm;
- TCHECK2(tptr[0], 4);
+ uint32_t comm;
+ ND_TCHECK2(tptr[0], 4);
comm = EXTRACT_32BITS(tptr);
switch (comm) {
case BGP_COMMUNITY_NO_EXPORT:
- printf(" NO_EXPORT");
+ ND_PRINT((ndo, " NO_EXPORT"));
break;
case BGP_COMMUNITY_NO_ADVERT:
- printf(" NO_ADVERTISE");
+ ND_PRINT((ndo, " NO_ADVERTISE"));
break;
case BGP_COMMUNITY_NO_EXPORT_SUBCONFED:
- printf(" NO_EXPORT_SUBCONFED");
+ ND_PRINT((ndo, " NO_EXPORT_SUBCONFED"));
break;
default:
- printf("%u:%u%s",
+ ND_PRINT((ndo, "%u:%u%s",
(comm >> 16) & 0xffff,
comm & 0xffff,
- (tlen>4) ? ", " : "");
+ (tlen>4) ? ", " : ""));
break;
}
tlen -=4;
@@ -1451,39 +1504,37 @@ bgp_attr_print(u_int atype, const u_char *pptr, u_int len)
break;
case BGPTYPE_ORIGINATOR_ID:
if (len != 4) {
- printf("invalid len");
+ ND_PRINT((ndo, "invalid len"));
break;
}
- TCHECK2(tptr[0], 4);
- printf("%s",getname(tptr));
+ ND_TCHECK2(tptr[0], 4);
+ ND_PRINT((ndo, "%s",ipaddr_string(ndo, tptr)));
break;
case BGPTYPE_CLUSTER_LIST:
if (len % 4) {
- printf("invalid len");
+ ND_PRINT((ndo, "invalid len"));
break;
}
while (tlen>0) {
- TCHECK2(tptr[0], 4);
- printf("%s%s",
- getname(tptr),
- (tlen>4) ? ", " : "");
+ ND_TCHECK2(tptr[0], 4);
+ ND_PRINT((ndo, "%s%s",
+ ipaddr_string(ndo, tptr),
+ (tlen>4) ? ", " : ""));
tlen -=4;
tptr +=4;
}
break;
case BGPTYPE_MP_REACH_NLRI:
- TCHECK2(tptr[0], 3);
+ ND_TCHECK2(tptr[0], 3);
af = EXTRACT_16BITS(tptr);
safi = tptr[2];
-
- printf("\n\t AFI: %s (%u), %sSAFI: %s (%u)",
- tok2strbuf(af_values, "Unknown AFI", af,
- tokbuf, sizeof(tokbuf)),
+
+ ND_PRINT((ndo, "\n\t AFI: %s (%u), %sSAFI: %s (%u)",
+ tok2str(af_values, "Unknown AFI", af),
af,
(safi>128) ? "vendor specific " : "", /* 128 is meanwhile wellknown */
- tok2strbuf(bgp_safi_values, "Unknown SAFI", safi,
- tokbuf, sizeof(tokbuf)),
- safi);
+ tok2str(bgp_safi_values, "Unknown SAFI", safi),
+ safi));
switch(af<<8 | safi) {
case (AFNUM_INET<<8 | SAFNUM_UNICAST):
@@ -1495,8 +1546,7 @@ bgp_attr_print(u_int atype, const u_char *pptr, u_int len)
case (AFNUM_INET<<8 | SAFNUM_VPNMULTICAST):
case (AFNUM_INET<<8 | SAFNUM_VPNUNIMULTICAST):
case (AFNUM_INET<<8 | SAFNUM_MULTICAST_VPN):
- case (AFNUM_INET<<8 | SAFNUM_MDT):
-#ifdef INET6
+ case (AFNUM_INET<<8 | SAFNUM_MDT):
case (AFNUM_INET6<<8 | SAFNUM_UNICAST):
case (AFNUM_INET6<<8 | SAFNUM_MULTICAST):
case (AFNUM_INET6<<8 | SAFNUM_UNIMULTICAST):
@@ -1504,7 +1554,6 @@ bgp_attr_print(u_int atype, const u_char *pptr, u_int len)
case (AFNUM_INET6<<8 | SAFNUM_VPNUNICAST):
case (AFNUM_INET6<<8 | SAFNUM_VPNMULTICAST):
case (AFNUM_INET6<<8 | SAFNUM_VPNUNIMULTICAST):
-#endif
case (AFNUM_NSAP<<8 | SAFNUM_UNICAST):
case (AFNUM_NSAP<<8 | SAFNUM_MULTICAST):
case (AFNUM_NSAP<<8 | SAFNUM_UNIMULTICAST):
@@ -1517,27 +1566,27 @@ bgp_attr_print(u_int atype, const u_char *pptr, u_int len)
case (AFNUM_VPLS<<8 | SAFNUM_VPLS):
break;
default:
- TCHECK2(tptr[0], tlen);
- printf("\n\t no AFI %u / SAFI %u decoder",af,safi);
- if (vflag <= 1)
- print_unknown_data(tptr,"\n\t ",tlen);
+ ND_TCHECK2(tptr[0], tlen);
+ ND_PRINT((ndo, "\n\t no AFI %u / SAFI %u decoder", af, safi));
+ if (ndo->ndo_vflag <= 1)
+ print_unknown_data(ndo, tptr, "\n\t ", tlen);
goto done;
break;
}
tptr +=3;
- TCHECK(tptr[0]);
+ ND_TCHECK(tptr[0]);
nhlen = tptr[0];
tlen = nhlen;
tptr++;
if (tlen) {
int nnh = 0;
- printf("\n\t nexthop: ");
+ ND_PRINT((ndo, "\n\t nexthop: "));
while (tlen > 0) {
if ( nnh++ > 0 ) {
- printf( ", " );
+ ND_PRINT((ndo, ", " ));
}
switch(af<<8 | safi) {
case (AFNUM_INET<<8 | SAFNUM_UNICAST):
@@ -1546,13 +1595,13 @@ bgp_attr_print(u_int atype, const u_char *pptr, u_int len)
case (AFNUM_INET<<8 | SAFNUM_LABUNICAST):
case (AFNUM_INET<<8 | SAFNUM_RT_ROUTING_INFO):
case (AFNUM_INET<<8 | SAFNUM_MULTICAST_VPN):
- case (AFNUM_INET<<8 | SAFNUM_MDT):
+ case (AFNUM_INET<<8 | SAFNUM_MDT):
if (tlen < (int)sizeof(struct in_addr)) {
- printf("invalid len");
+ ND_PRINT((ndo, "invalid len"));
tlen = 0;
} else {
- TCHECK2(tptr[0], sizeof(struct in_addr));
- printf("%s",getname(tptr));
+ ND_TCHECK2(tptr[0], sizeof(struct in_addr));
+ ND_PRINT((ndo, "%s",ipaddr_string(ndo, tptr)));
tlen -= sizeof(struct in_addr);
tptr += sizeof(struct in_addr);
}
@@ -1561,28 +1610,27 @@ bgp_attr_print(u_int atype, const u_char *pptr, u_int len)
case (AFNUM_INET<<8 | SAFNUM_VPNMULTICAST):
case (AFNUM_INET<<8 | SAFNUM_VPNUNIMULTICAST):
if (tlen < (int)(sizeof(struct in_addr)+BGP_VPN_RD_LEN)) {
- printf("invalid len");
+ ND_PRINT((ndo, "invalid len"));
tlen = 0;
} else {
- TCHECK2(tptr[0], sizeof(struct in_addr)+BGP_VPN_RD_LEN);
- printf("RD: %s, %s",
- bgp_vpn_rd_print(tptr),
- getname(tptr+BGP_VPN_RD_LEN));
+ ND_TCHECK2(tptr[0], sizeof(struct in_addr)+BGP_VPN_RD_LEN);
+ ND_PRINT((ndo, "RD: %s, %s",
+ bgp_vpn_rd_print(ndo, tptr),
+ ipaddr_string(ndo, tptr+BGP_VPN_RD_LEN)));
tlen -= (sizeof(struct in_addr)+BGP_VPN_RD_LEN);
tptr += (sizeof(struct in_addr)+BGP_VPN_RD_LEN);
}
break;
-#ifdef INET6
case (AFNUM_INET6<<8 | SAFNUM_UNICAST):
case (AFNUM_INET6<<8 | SAFNUM_MULTICAST):
case (AFNUM_INET6<<8 | SAFNUM_UNIMULTICAST):
case (AFNUM_INET6<<8 | SAFNUM_LABUNICAST):
if (tlen < (int)sizeof(struct in6_addr)) {
- printf("invalid len");
+ ND_PRINT((ndo, "invalid len"));
tlen = 0;
} else {
- TCHECK2(tptr[0], sizeof(struct in6_addr));
- printf("%s", getname6(tptr));
+ ND_TCHECK2(tptr[0], sizeof(struct in6_addr));
+ ND_PRINT((ndo, "%s", ip6addr_string(ndo, tptr)));
tlen -= sizeof(struct in6_addr);
tptr += sizeof(struct in6_addr);
}
@@ -1591,28 +1639,27 @@ bgp_attr_print(u_int atype, const u_char *pptr, u_int len)
case (AFNUM_INET6<<8 | SAFNUM_VPNMULTICAST):
case (AFNUM_INET6<<8 | SAFNUM_VPNUNIMULTICAST):
if (tlen < (int)(sizeof(struct in6_addr)+BGP_VPN_RD_LEN)) {
- printf("invalid len");
+ ND_PRINT((ndo, "invalid len"));
tlen = 0;
} else {
- TCHECK2(tptr[0], sizeof(struct in6_addr)+BGP_VPN_RD_LEN);
- printf("RD: %s, %s",
- bgp_vpn_rd_print(tptr),
- getname6(tptr+BGP_VPN_RD_LEN));
+ ND_TCHECK2(tptr[0], sizeof(struct in6_addr)+BGP_VPN_RD_LEN);
+ ND_PRINT((ndo, "RD: %s, %s",
+ bgp_vpn_rd_print(ndo, tptr),
+ ip6addr_string(ndo, tptr+BGP_VPN_RD_LEN)));
tlen -= (sizeof(struct in6_addr)+BGP_VPN_RD_LEN);
tptr += (sizeof(struct in6_addr)+BGP_VPN_RD_LEN);
}
break;
-#endif
case (AFNUM_VPLS<<8 | SAFNUM_VPLS):
case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNICAST):
case (AFNUM_L2VPN<<8 | SAFNUM_VPNMULTICAST):
case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNIMULTICAST):
if (tlen < (int)sizeof(struct in_addr)) {
- printf("invalid len");
+ ND_PRINT((ndo, "invalid len"));
tlen = 0;
} else {
- TCHECK2(tptr[0], sizeof(struct in_addr));
- printf("%s", getname(tptr));
+ ND_TCHECK2(tptr[0], sizeof(struct in_addr));
+ ND_PRINT((ndo, "%s", ipaddr_string(ndo, tptr)));
tlen -= (sizeof(struct in_addr));
tptr += (sizeof(struct in_addr));
}
@@ -1620,8 +1667,8 @@ bgp_attr_print(u_int atype, const u_char *pptr, u_int len)
case (AFNUM_NSAP<<8 | SAFNUM_UNICAST):
case (AFNUM_NSAP<<8 | SAFNUM_MULTICAST):
case (AFNUM_NSAP<<8 | SAFNUM_UNIMULTICAST):
- TCHECK2(tptr[0], tlen);
- printf("%s",isonsap_string(tptr,tlen));
+ ND_TCHECK2(tptr[0], tlen);
+ ND_PRINT((ndo, "%s", isonsap_string(ndo, tptr, tlen)));
tptr += tlen;
tlen = 0;
break;
@@ -1630,30 +1677,28 @@ bgp_attr_print(u_int atype, const u_char *pptr, u_int len)
case (AFNUM_NSAP<<8 | SAFNUM_VPNMULTICAST):
case (AFNUM_NSAP<<8 | SAFNUM_VPNUNIMULTICAST):
if (tlen < BGP_VPN_RD_LEN+1) {
- printf("invalid len");
+ ND_PRINT((ndo, "invalid len"));
tlen = 0;
} else {
- TCHECK2(tptr[0], tlen);
- printf("RD: %s, %s",
- bgp_vpn_rd_print(tptr),
- isonsap_string(tptr+BGP_VPN_RD_LEN,tlen-BGP_VPN_RD_LEN));
+ ND_TCHECK2(tptr[0], tlen);
+ ND_PRINT((ndo, "RD: %s, %s",
+ bgp_vpn_rd_print(ndo, tptr),
+ isonsap_string(ndo, tptr+BGP_VPN_RD_LEN,tlen-BGP_VPN_RD_LEN)));
/* rfc986 mapped IPv4 address ? */
if (EXTRACT_32BITS(tptr+BGP_VPN_RD_LEN) == 0x47000601)
- printf(" = %s", getname(tptr+BGP_VPN_RD_LEN+4));
-#ifdef INET6
+ ND_PRINT((ndo, " = %s", ipaddr_string(ndo, tptr+BGP_VPN_RD_LEN+4)));
/* rfc1888 mapped IPv6 address ? */
else if (EXTRACT_24BITS(tptr+BGP_VPN_RD_LEN) == 0x350000)
- printf(" = %s", getname6(tptr+BGP_VPN_RD_LEN+3));
-#endif
+ ND_PRINT((ndo, " = %s", ip6addr_string(ndo, tptr+BGP_VPN_RD_LEN+3)));
tptr += tlen;
tlen = 0;
}
break;
default:
- TCHECK2(tptr[0], tlen);
- printf("no AFI %u/SAFI %u decoder",af,safi);
- if (vflag <= 1)
- print_unknown_data(tptr,"\n\t ",tlen);
+ ND_TCHECK2(tptr[0], tlen);
+ ND_PRINT((ndo, "no AFI %u/SAFI %u decoder", af, safi));
+ if (ndo->ndo_vflag <= 1)
+ print_unknown_data(ndo, tptr, "\n\t ", tlen);
tptr += tlen;
tlen = 0;
goto done;
@@ -1661,22 +1706,22 @@ bgp_attr_print(u_int atype, const u_char *pptr, u_int len)
}
}
}
- printf(", nh-length: %u", nhlen);
+ ND_PRINT((ndo, ", nh-length: %u", nhlen));
tptr += tlen;
- TCHECK(tptr[0]);
+ ND_TCHECK(tptr[0]);
snpa = tptr[0];
tptr++;
if (snpa) {
- printf("\n\t %u SNPA", snpa);
+ ND_PRINT((ndo, "\n\t %u SNPA", snpa));
for (/*nothing*/; snpa > 0; snpa--) {
- TCHECK(tptr[0]);
- printf("\n\t %d bytes", tptr[0]);
+ ND_TCHECK(tptr[0]);
+ ND_PRINT((ndo, "\n\t %d bytes", tptr[0]));
tptr += tptr[0] + 1;
}
} else {
- printf(", no SNPA");
+ ND_PRINT((ndo, ", no SNPA"));
}
while (len - (tptr - pptr) > 0) {
@@ -1684,143 +1729,141 @@ bgp_attr_print(u_int atype, const u_char *pptr, u_int len)
case (AFNUM_INET<<8 | SAFNUM_UNICAST):
case (AFNUM_INET<<8 | SAFNUM_MULTICAST):
case (AFNUM_INET<<8 | SAFNUM_UNIMULTICAST):
- advance = decode_prefix4(tptr, len, buf, sizeof(buf));
+ advance = decode_prefix4(ndo, tptr, len, buf, sizeof(buf));
if (advance == -1)
- printf("\n\t (illegal prefix length)");
+ ND_PRINT((ndo, "\n\t (illegal prefix length)"));
else if (advance == -2)
goto trunc;
else if (advance == -3)
break; /* bytes left, but not enough */
else
- printf("\n\t %s", buf);
+ ND_PRINT((ndo, "\n\t %s", buf));
break;
case (AFNUM_INET<<8 | SAFNUM_LABUNICAST):
- advance = decode_labeled_prefix4(tptr, len, buf, sizeof(buf));
+ advance = decode_labeled_prefix4(ndo, tptr, len, buf, sizeof(buf));
if (advance == -1)
- printf("\n\t (illegal prefix length)");
+ ND_PRINT((ndo, "\n\t (illegal prefix length)"));
else if (advance == -2)
goto trunc;
else if (advance == -3)
break; /* bytes left, but not enough */
else
- printf("\n\t %s", buf);
+ ND_PRINT((ndo, "\n\t %s", buf));
break;
case (AFNUM_INET<<8 | SAFNUM_VPNUNICAST):
case (AFNUM_INET<<8 | SAFNUM_VPNMULTICAST):
case (AFNUM_INET<<8 | SAFNUM_VPNUNIMULTICAST):
- advance = decode_labeled_vpn_prefix4(tptr, buf, sizeof(buf));
+ advance = decode_labeled_vpn_prefix4(ndo, tptr, buf, sizeof(buf));
if (advance == -1)
- printf("\n\t (illegal prefix length)");
+ ND_PRINT((ndo, "\n\t (illegal prefix length)"));
else if (advance == -2)
goto trunc;
else
- printf("\n\t %s", buf);
+ ND_PRINT((ndo, "\n\t %s", buf));
break;
case (AFNUM_INET<<8 | SAFNUM_RT_ROUTING_INFO):
- advance = decode_rt_routing_info(tptr, buf, sizeof(buf));
+ advance = decode_rt_routing_info(ndo, tptr, buf, sizeof(buf));
if (advance == -1)
- printf("\n\t (illegal prefix length)");
+ ND_PRINT((ndo, "\n\t (illegal prefix length)"));
else if (advance == -2)
goto trunc;
else
- printf("\n\t %s", buf);
+ ND_PRINT((ndo, "\n\t %s", buf));
break;
case (AFNUM_INET<<8 | SAFNUM_MULTICAST_VPN): /* fall through */
case (AFNUM_INET6<<8 | SAFNUM_MULTICAST_VPN):
- advance = decode_multicast_vpn(tptr, buf, sizeof(buf));
+ advance = decode_multicast_vpn(ndo, tptr, buf, sizeof(buf));
if (advance == -1)
- printf("\n\t (illegal prefix length)");
+ ND_PRINT((ndo, "\n\t (illegal prefix length)"));
else if (advance == -2)
goto trunc;
else
- printf("\n\t %s", buf);
+ ND_PRINT((ndo, "\n\t %s", buf));
break;
case (AFNUM_INET<<8 | SAFNUM_MDT):
- advance = decode_mdt_vpn_nlri(tptr, buf, sizeof(buf));
+ advance = decode_mdt_vpn_nlri(ndo, tptr, buf, sizeof(buf));
if (advance == -1)
- printf("\n\t (illegal prefix length)");
+ ND_PRINT((ndo, "\n\t (illegal prefix length)"));
else if (advance == -2)
goto trunc;
else
- printf("\n\t %s", buf);
+ ND_PRINT((ndo, "\n\t %s", buf));
break;
-#ifdef INET6
case (AFNUM_INET6<<8 | SAFNUM_UNICAST):
case (AFNUM_INET6<<8 | SAFNUM_MULTICAST):
case (AFNUM_INET6<<8 | SAFNUM_UNIMULTICAST):
- advance = decode_prefix6(tptr, len, buf, sizeof(buf));
+ advance = decode_prefix6(ndo, tptr, len, buf, sizeof(buf));
if (advance == -1)
- printf("\n\t (illegal prefix length)");
+ ND_PRINT((ndo, "\n\t (illegal prefix length)"));
else if (advance == -2)
goto trunc;
else if (advance == -3)
break; /* bytes left, but not enough */
else
- printf("\n\t %s", buf);
+ ND_PRINT((ndo, "\n\t %s", buf));
break;
case (AFNUM_INET6<<8 | SAFNUM_LABUNICAST):
- advance = decode_labeled_prefix6(tptr, len, buf, sizeof(buf));
+ advance = decode_labeled_prefix6(ndo, tptr, len, buf, sizeof(buf));
if (advance == -1)
- printf("\n\t (illegal prefix length)");
+ ND_PRINT((ndo, "\n\t (illegal prefix length)"));
else if (advance == -2)
goto trunc;
else if (advance == -3)
break; /* bytes left, but not enough */
else
- printf("\n\t %s", buf);
+ ND_PRINT((ndo, "\n\t %s", buf));
break;
case (AFNUM_INET6<<8 | SAFNUM_VPNUNICAST):
case (AFNUM_INET6<<8 | SAFNUM_VPNMULTICAST):
case (AFNUM_INET6<<8 | SAFNUM_VPNUNIMULTICAST):
- advance = decode_labeled_vpn_prefix6(tptr, buf, sizeof(buf));
+ advance = decode_labeled_vpn_prefix6(ndo, tptr, buf, sizeof(buf));
if (advance == -1)
- printf("\n\t (illegal prefix length)");
+ ND_PRINT((ndo, "\n\t (illegal prefix length)"));
else if (advance == -2)
goto trunc;
else
- printf("\n\t %s", buf);
+ ND_PRINT((ndo, "\n\t %s", buf));
break;
-#endif
case (AFNUM_VPLS<<8 | SAFNUM_VPLS):
case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNICAST):
case (AFNUM_L2VPN<<8 | SAFNUM_VPNMULTICAST):
case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNIMULTICAST):
- advance = decode_labeled_vpn_l2(tptr, buf, sizeof(buf));
+ advance = decode_labeled_vpn_l2(ndo, tptr, buf, sizeof(buf));
if (advance == -1)
- printf("\n\t (illegal length)");
+ ND_PRINT((ndo, "\n\t (illegal length)"));
else if (advance == -2)
goto trunc;
else
- printf("\n\t %s", buf);
+ ND_PRINT((ndo, "\n\t %s", buf));
break;
case (AFNUM_NSAP<<8 | SAFNUM_UNICAST):
case (AFNUM_NSAP<<8 | SAFNUM_MULTICAST):
case (AFNUM_NSAP<<8 | SAFNUM_UNIMULTICAST):
- advance = decode_clnp_prefix(tptr, buf, sizeof(buf));
+ advance = decode_clnp_prefix(ndo, tptr, buf, sizeof(buf));
if (advance == -1)
- printf("\n\t (illegal prefix length)");
+ ND_PRINT((ndo, "\n\t (illegal prefix length)"));
else if (advance == -2)
goto trunc;
else
- printf("\n\t %s", buf);
+ ND_PRINT((ndo, "\n\t %s", buf));
break;
case (AFNUM_NSAP<<8 | SAFNUM_VPNUNICAST):
case (AFNUM_NSAP<<8 | SAFNUM_VPNMULTICAST):
case (AFNUM_NSAP<<8 | SAFNUM_VPNUNIMULTICAST):
- advance = decode_labeled_vpn_clnp_prefix(tptr, buf, sizeof(buf));
+ advance = decode_labeled_vpn_clnp_prefix(ndo, tptr, buf, sizeof(buf));
if (advance == -1)
- printf("\n\t (illegal prefix length)");
+ ND_PRINT((ndo, "\n\t (illegal prefix length)"));
else if (advance == -2)
goto trunc;
else
- printf("\n\t %s", buf);
- break;
+ ND_PRINT((ndo, "\n\t %s", buf));
+ break;
default:
- TCHECK2(*tptr,tlen);
- printf("\n\t no AFI %u / SAFI %u decoder",af,safi);
- if (vflag <= 1)
- print_unknown_data(tptr,"\n\t ",tlen);
+ ND_TCHECK2(*tptr,tlen);
+ ND_PRINT((ndo, "\n\t no AFI %u / SAFI %u decoder", af, safi));
+ if (ndo->ndo_vflag <= 1)
+ print_unknown_data(ndo, tptr, "\n\t ", tlen);
advance = 0;
tptr = pptr + len;
break;
@@ -1833,156 +1876,152 @@ bgp_attr_print(u_int atype, const u_char *pptr, u_int len)
break;
case BGPTYPE_MP_UNREACH_NLRI:
- TCHECK2(tptr[0], BGP_MP_NLRI_MINSIZE);
+ ND_TCHECK2(tptr[0], BGP_MP_NLRI_MINSIZE);
af = EXTRACT_16BITS(tptr);
safi = tptr[2];
- printf("\n\t AFI: %s (%u), %sSAFI: %s (%u)",
- tok2strbuf(af_values, "Unknown AFI", af,
- tokbuf, sizeof(tokbuf)),
+ ND_PRINT((ndo, "\n\t AFI: %s (%u), %sSAFI: %s (%u)",
+ tok2str(af_values, "Unknown AFI", af),
af,
(safi>128) ? "vendor specific " : "", /* 128 is meanwhile wellknown */
- tok2strbuf(bgp_safi_values, "Unknown SAFI", safi,
- tokbuf, sizeof(tokbuf)),
- safi);
+ tok2str(bgp_safi_values, "Unknown SAFI", safi),
+ safi));
if (len == BGP_MP_NLRI_MINSIZE)
- printf("\n\t End-of-Rib Marker (empty NLRI)");
+ ND_PRINT((ndo, "\n\t End-of-Rib Marker (empty NLRI)"));
tptr += 3;
-
+
while (len - (tptr - pptr) > 0) {
switch (af<<8 | safi) {
case (AFNUM_INET<<8 | SAFNUM_UNICAST):
case (AFNUM_INET<<8 | SAFNUM_MULTICAST):
case (AFNUM_INET<<8 | SAFNUM_UNIMULTICAST):
- advance = decode_prefix4(tptr, len, buf, sizeof(buf));
+ advance = decode_prefix4(ndo, tptr, len, buf, sizeof(buf));
if (advance == -1)
- printf("\n\t (illegal prefix length)");
+ ND_PRINT((ndo, "\n\t (illegal prefix length)"));
else if (advance == -2)
goto trunc;
else if (advance == -3)
break; /* bytes left, but not enough */
else
- printf("\n\t %s", buf);
+ ND_PRINT((ndo, "\n\t %s", buf));
break;
case (AFNUM_INET<<8 | SAFNUM_LABUNICAST):
- advance = decode_labeled_prefix4(tptr, len, buf, sizeof(buf));
+ advance = decode_labeled_prefix4(ndo, tptr, len, buf, sizeof(buf));
if (advance == -1)
- printf("\n\t (illegal prefix length)");
+ ND_PRINT((ndo, "\n\t (illegal prefix length)"));
else if (advance == -2)
goto trunc;
else if (advance == -3)
break; /* bytes left, but not enough */
else
- printf("\n\t %s", buf);
+ ND_PRINT((ndo, "\n\t %s", buf));
break;
case (AFNUM_INET<<8 | SAFNUM_VPNUNICAST):
case (AFNUM_INET<<8 | SAFNUM_VPNMULTICAST):
case (AFNUM_INET<<8 | SAFNUM_VPNUNIMULTICAST):
- advance = decode_labeled_vpn_prefix4(tptr, buf, sizeof(buf));
+ advance = decode_labeled_vpn_prefix4(ndo, tptr, buf, sizeof(buf));
if (advance == -1)
- printf("\n\t (illegal prefix length)");
+ ND_PRINT((ndo, "\n\t (illegal prefix length)"));
else if (advance == -2)
goto trunc;
else
- printf("\n\t %s", buf);
+ ND_PRINT((ndo, "\n\t %s", buf));
break;
-#ifdef INET6
case (AFNUM_INET6<<8 | SAFNUM_UNICAST):
case (AFNUM_INET6<<8 | SAFNUM_MULTICAST):
case (AFNUM_INET6<<8 | SAFNUM_UNIMULTICAST):
- advance = decode_prefix6(tptr, len, buf, sizeof(buf));
+ advance = decode_prefix6(ndo, tptr, len, buf, sizeof(buf));
if (advance == -1)
- printf("\n\t (illegal prefix length)");
+ ND_PRINT((ndo, "\n\t (illegal prefix length)"));
else if (advance == -2)
goto trunc;
else if (advance == -3)
break; /* bytes left, but not enough */
else
- printf("\n\t %s", buf);
+ ND_PRINT((ndo, "\n\t %s", buf));
break;
case (AFNUM_INET6<<8 | SAFNUM_LABUNICAST):
- advance = decode_labeled_prefix6(tptr, len, buf, sizeof(buf));
+ advance = decode_labeled_prefix6(ndo, tptr, len, buf, sizeof(buf));
if (advance == -1)
- printf("\n\t (illegal prefix length)");
+ ND_PRINT((ndo, "\n\t (illegal prefix length)"));
else if (advance == -2)
goto trunc;
else if (advance == -3)
break; /* bytes left, but not enough */
else
- printf("\n\t %s", buf);
+ ND_PRINT((ndo, "\n\t %s", buf));
break;
case (AFNUM_INET6<<8 | SAFNUM_VPNUNICAST):
case (AFNUM_INET6<<8 | SAFNUM_VPNMULTICAST):
case (AFNUM_INET6<<8 | SAFNUM_VPNUNIMULTICAST):
- advance = decode_labeled_vpn_prefix6(tptr, buf, sizeof(buf));
+ advance = decode_labeled_vpn_prefix6(ndo, tptr, buf, sizeof(buf));
if (advance == -1)
- printf("\n\t (illegal prefix length)");
+ ND_PRINT((ndo, "\n\t (illegal prefix length)"));
else if (advance == -2)
goto trunc;
else
- printf("\n\t %s", buf);
+ ND_PRINT((ndo, "\n\t %s", buf));
break;
-#endif
case (AFNUM_VPLS<<8 | SAFNUM_VPLS):
case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNICAST):
case (AFNUM_L2VPN<<8 | SAFNUM_VPNMULTICAST):
case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNIMULTICAST):
- advance = decode_labeled_vpn_l2(tptr, buf, sizeof(buf));
+ advance = decode_labeled_vpn_l2(ndo, tptr, buf, sizeof(buf));
if (advance == -1)
- printf("\n\t (illegal length)");
+ ND_PRINT((ndo, "\n\t (illegal length)"));
else if (advance == -2)
goto trunc;
else
- printf("\n\t %s", buf);
+ ND_PRINT((ndo, "\n\t %s", buf));
break;
case (AFNUM_NSAP<<8 | SAFNUM_UNICAST):
case (AFNUM_NSAP<<8 | SAFNUM_MULTICAST):
case (AFNUM_NSAP<<8 | SAFNUM_UNIMULTICAST):
- advance = decode_clnp_prefix(tptr, buf, sizeof(buf));
+ advance = decode_clnp_prefix(ndo, tptr, buf, sizeof(buf));
if (advance == -1)
- printf("\n\t (illegal prefix length)");
+ ND_PRINT((ndo, "\n\t (illegal prefix length)"));
else if (advance == -2)
goto trunc;
else
- printf("\n\t %s", buf);
+ ND_PRINT((ndo, "\n\t %s", buf));
break;
case (AFNUM_NSAP<<8 | SAFNUM_VPNUNICAST):
case (AFNUM_NSAP<<8 | SAFNUM_VPNMULTICAST):
case (AFNUM_NSAP<<8 | SAFNUM_VPNUNIMULTICAST):
- advance = decode_labeled_vpn_clnp_prefix(tptr, buf, sizeof(buf));
+ advance = decode_labeled_vpn_clnp_prefix(ndo, tptr, buf, sizeof(buf));
if (advance == -1)
- printf("\n\t (illegal prefix length)");
+ ND_PRINT((ndo, "\n\t (illegal prefix length)"));
else if (advance == -2)
goto trunc;
else
- printf("\n\t %s", buf);
- break;
+ ND_PRINT((ndo, "\n\t %s", buf));
+ break;
case (AFNUM_INET<<8 | SAFNUM_MDT):
- advance = decode_mdt_vpn_nlri(tptr, buf, sizeof(buf));
+ advance = decode_mdt_vpn_nlri(ndo, tptr, buf, sizeof(buf));
if (advance == -1)
- printf("\n\t (illegal prefix length)");
+ ND_PRINT((ndo, "\n\t (illegal prefix length)"));
else if (advance == -2)
goto trunc;
else
- printf("\n\t %s", buf);
+ ND_PRINT((ndo, "\n\t %s", buf));
break;
case (AFNUM_INET<<8 | SAFNUM_MULTICAST_VPN): /* fall through */
case (AFNUM_INET6<<8 | SAFNUM_MULTICAST_VPN):
- advance = decode_multicast_vpn(tptr, buf, sizeof(buf));
+ advance = decode_multicast_vpn(ndo, tptr, buf, sizeof(buf));
if (advance == -1)
- printf("\n\t (illegal prefix length)");
+ ND_PRINT((ndo, "\n\t (illegal prefix length)"));
else if (advance == -2)
goto trunc;
else
- printf("\n\t %s", buf);
+ ND_PRINT((ndo, "\n\t %s", buf));
break;
default:
- TCHECK2(*(tptr-3),tlen);
- printf("no AFI %u / SAFI %u decoder",af,safi);
- if (vflag <= 1)
- print_unknown_data(tptr-3,"\n\t ",tlen);
+ ND_TCHECK2(*(tptr-3),tlen);
+ ND_PRINT((ndo, "no AFI %u / SAFI %u decoder", af, safi));
+ if (ndo->ndo_vflag <= 1)
+ print_unknown_data(ndo, tptr-3, "\n\t ", tlen);
advance = 0;
tptr = pptr + len;
break;
@@ -1994,50 +2033,50 @@ bgp_attr_print(u_int atype, const u_char *pptr, u_int len)
break;
case BGPTYPE_EXTD_COMMUNITIES:
if (len % 8) {
- printf("invalid len");
+ ND_PRINT((ndo, "invalid len"));
break;
}
while (tlen>0) {
- u_int16_t extd_comm;
+ uint16_t extd_comm;
- TCHECK2(tptr[0], 2);
+ ND_TCHECK2(tptr[0], 2);
extd_comm=EXTRACT_16BITS(tptr);
- printf("\n\t %s (0x%04x), Flags [%s]",
- tok2strbuf(bgp_extd_comm_subtype_values,
+ ND_PRINT((ndo, "\n\t %s (0x%04x), Flags [%s]",
+ tok2str(bgp_extd_comm_subtype_values,
"unknown extd community typecode",
- extd_comm, tokbuf, sizeof(tokbuf)),
+ extd_comm),
extd_comm,
- bittok2str(bgp_extd_comm_flag_values, "none", extd_comm));
+ bittok2str(bgp_extd_comm_flag_values, "none", extd_comm)));
- TCHECK2(*(tptr+2), 6);
+ ND_TCHECK2(*(tptr+2), 6);
switch(extd_comm) {
case BGP_EXT_COM_RT_0:
case BGP_EXT_COM_RO_0:
case BGP_EXT_COM_L2VPN_RT_0:
- printf(": %u:%u (= %s)",
+ ND_PRINT((ndo, ": %u:%u (= %s)",
EXTRACT_16BITS(tptr+2),
EXTRACT_32BITS(tptr+4),
- getname(tptr+4));
+ ipaddr_string(ndo, tptr+4)));
break;
case BGP_EXT_COM_RT_1:
case BGP_EXT_COM_RO_1:
case BGP_EXT_COM_L2VPN_RT_1:
case BGP_EXT_COM_VRF_RT_IMP:
- printf(": %s:%u",
- getname(tptr+2),
- EXTRACT_16BITS(tptr+6));
+ ND_PRINT((ndo, ": %s:%u",
+ ipaddr_string(ndo, tptr+2),
+ EXTRACT_16BITS(tptr+6)));
break;
case BGP_EXT_COM_RT_2:
case BGP_EXT_COM_RO_2:
- printf(": %s:%u",
- as_printf(astostr, sizeof(astostr),
- EXTRACT_32BITS(tptr+2)), EXTRACT_16BITS(tptr+6));
+ ND_PRINT((ndo, ": %s:%u",
+ as_printf(ndo, astostr, sizeof(astostr),
+ EXTRACT_32BITS(tptr+2)), EXTRACT_16BITS(tptr+6)));
break;
case BGP_EXT_COM_LINKBAND:
bw.i = EXTRACT_32BITS(tptr+2);
- printf(": bandwidth: %.3f Mbps",
- bw.f*8/1000000);
+ ND_PRINT((ndo, ": bandwidth: %.3f Mbps",
+ bw.f*8/1000000));
break;
case BGP_EXT_COM_VPN_ORIGIN:
case BGP_EXT_COM_VPN_ORIGIN2:
@@ -2045,34 +2084,32 @@ bgp_attr_print(u_int atype, const u_char *pptr, u_int len)
case BGP_EXT_COM_VPN_ORIGIN4:
case BGP_EXT_COM_OSPF_RID:
case BGP_EXT_COM_OSPF_RID2:
- printf("%s", getname(tptr+2));
+ ND_PRINT((ndo, "%s", ipaddr_string(ndo, tptr+2)));
break;
case BGP_EXT_COM_OSPF_RTYPE:
- case BGP_EXT_COM_OSPF_RTYPE2:
- printf(": area:%s, router-type:%s, metric-type:%s%s",
- getname(tptr+2),
- tok2strbuf(bgp_extd_comm_ospf_rtype_values,
+ case BGP_EXT_COM_OSPF_RTYPE2:
+ ND_PRINT((ndo, ": area:%s, router-type:%s, metric-type:%s%s",
+ ipaddr_string(ndo, tptr+2),
+ tok2str(bgp_extd_comm_ospf_rtype_values,
"unknown (0x%02x)",
- *(tptr+6),
- tokbuf, sizeof(tokbuf)),
+ *(tptr+6)),
(*(tptr+7) & BGP_OSPF_RTYPE_METRIC_TYPE) ? "E2" : "",
- ((*(tptr+6) == BGP_OSPF_RTYPE_EXT) || (*(tptr+6) == BGP_OSPF_RTYPE_NSSA)) ? "E1" : "");
+ ((*(tptr+6) == BGP_OSPF_RTYPE_EXT) || (*(tptr+6) == BGP_OSPF_RTYPE_NSSA)) ? "E1" : ""));
break;
case BGP_EXT_COM_L2INFO:
- printf(": %s Control Flags [0x%02x]:MTU %u",
- tok2strbuf(l2vpn_encaps_values,
+ ND_PRINT((ndo, ": %s Control Flags [0x%02x]:MTU %u",
+ tok2str(l2vpn_encaps_values,
"unknown encaps",
- *(tptr+2),
- tokbuf, sizeof(tokbuf)),
+ *(tptr+2)),
*(tptr+3),
- EXTRACT_16BITS(tptr+4));
+ EXTRACT_16BITS(tptr+4)));
break;
case BGP_EXT_COM_SOURCE_AS:
- printf(": AS %u", EXTRACT_16BITS(tptr+2));
+ ND_PRINT((ndo, ": AS %u", EXTRACT_16BITS(tptr+2)));
break;
default:
- TCHECK2(*tptr,8);
- print_unknown_data(tptr,"\n\t ",8);
+ ND_TCHECK2(*tptr,8);
+ print_unknown_data(ndo, tptr, "\n\t ", 8);
break;
}
tlen -=8;
@@ -2082,18 +2119,18 @@ bgp_attr_print(u_int atype, const u_char *pptr, u_int len)
case BGPTYPE_PMSI_TUNNEL:
{
- u_int8_t tunnel_type, flags;
-
+ uint8_t tunnel_type, flags;
+
tunnel_type = *(tptr+1);
flags = *tptr;
tlen = len;
- TCHECK2(tptr[0], 5);
- printf("\n\t Tunnel-type %s (%u), Flags [%s], MPLS Label %u",
+ ND_TCHECK2(tptr[0], 5);
+ ND_PRINT((ndo, "\n\t Tunnel-type %s (%u), Flags [%s], MPLS Label %u",
tok2str(bgp_pmsi_tunnel_values, "Unknown", tunnel_type),
tunnel_type,
bittok2str(bgp_pmsi_flag_values, "none", flags),
- EXTRACT_24BITS(tptr+2)>>4);
+ EXTRACT_24BITS(tptr+2)>>4));
tptr +=5;
tlen -= 5;
@@ -2101,56 +2138,98 @@ bgp_attr_print(u_int atype, const u_char *pptr, u_int len)
switch (tunnel_type) {
case BGP_PMSI_TUNNEL_PIM_SM: /* fall through */
case BGP_PMSI_TUNNEL_PIM_BIDIR:
- TCHECK2(tptr[0], 8);
- printf("\n\t Sender %s, P-Group %s",
- ipaddr_string(tptr),
- ipaddr_string(tptr+4));
+ ND_TCHECK2(tptr[0], 8);
+ ND_PRINT((ndo, "\n\t Sender %s, P-Group %s",
+ ipaddr_string(ndo, tptr),
+ ipaddr_string(ndo, tptr+4)));
break;
case BGP_PMSI_TUNNEL_PIM_SSM:
- TCHECK2(tptr[0], 8);
- printf("\n\t Root-Node %s, P-Group %s",
- ipaddr_string(tptr),
- ipaddr_string(tptr+4));
+ ND_TCHECK2(tptr[0], 8);
+ ND_PRINT((ndo, "\n\t Root-Node %s, P-Group %s",
+ ipaddr_string(ndo, tptr),
+ ipaddr_string(ndo, tptr+4)));
break;
case BGP_PMSI_TUNNEL_INGRESS:
- TCHECK2(tptr[0], 4);
- printf("\n\t Tunnel-Endpoint %s",
- ipaddr_string(tptr));
+ ND_TCHECK2(tptr[0], 4);
+ ND_PRINT((ndo, "\n\t Tunnel-Endpoint %s",
+ ipaddr_string(ndo, tptr)));
break;
case BGP_PMSI_TUNNEL_LDP_P2MP: /* fall through */
case BGP_PMSI_TUNNEL_LDP_MP2MP:
- TCHECK2(tptr[0], 8);
- printf("\n\t Root-Node %s, LSP-ID 0x%08x",
- ipaddr_string(tptr),
- EXTRACT_32BITS(tptr+4));
+ ND_TCHECK2(tptr[0], 8);
+ ND_PRINT((ndo, "\n\t Root-Node %s, LSP-ID 0x%08x",
+ ipaddr_string(ndo, tptr),
+ EXTRACT_32BITS(tptr+4)));
break;
case BGP_PMSI_TUNNEL_RSVP_P2MP:
- TCHECK2(tptr[0], 8);
- printf("\n\t Extended-Tunnel-ID %s, P2MP-ID 0x%08x",
- ipaddr_string(tptr),
- EXTRACT_32BITS(tptr+4));
+ ND_TCHECK2(tptr[0], 8);
+ ND_PRINT((ndo, "\n\t Extended-Tunnel-ID %s, P2MP-ID 0x%08x",
+ ipaddr_string(ndo, tptr),
+ EXTRACT_32BITS(tptr+4)));
break;
default:
- if (vflag <= 1) {
- print_unknown_data(tptr,"\n\t ",tlen);
+ if (ndo->ndo_vflag <= 1) {
+ print_unknown_data(ndo, tptr, "\n\t ", tlen);
}
}
break;
}
+ case BGPTYPE_AIGP:
+ {
+ uint8_t type;
+ uint16_t length;
+
+ ND_TCHECK2(tptr[0], 3);
+
+ tlen = len;
+
+ while (tlen >= 3) {
+
+ type = *tptr;
+ length = EXTRACT_16BITS(tptr+1);
+
+ ND_PRINT((ndo, "\n\t %s TLV (%u), length %u",
+ tok2str(bgp_aigp_values, "Unknown", type),
+ type, length));
+
+ /*
+ * Check if we can read the TLV data.
+ */
+ ND_TCHECK2(tptr[3], length - 3);
+
+ switch (type) {
+
+ case BGP_AIGP_TLV:
+ ND_TCHECK2(tptr[3], 8);
+ ND_PRINT((ndo, ", metric %" PRIu64,
+ EXTRACT_64BITS(tptr+3)));
+ break;
+
+ default:
+ if (ndo->ndo_vflag <= 1) {
+ print_unknown_data(ndo, tptr+3,"\n\t ", length-3);
+ }
+ }
+
+ tptr += length;
+ tlen -= length;
+ }
+ break;
+ }
case BGPTYPE_ATTR_SET:
- TCHECK2(tptr[0], 4);
+ ND_TCHECK2(tptr[0], 4);
if (len < 4)
goto trunc;
- printf("\n\t Origin AS: %s",
- as_printf(astostr, sizeof(astostr), EXTRACT_32BITS(tptr)));
+ ND_PRINT((ndo, "\n\t Origin AS: %s",
+ as_printf(ndo, astostr, sizeof(astostr), EXTRACT_32BITS(tptr))));
tptr+=4;
len -=4;
while (len) {
- u_int aflags, atype, alenlen, alen;
-
- TCHECK2(tptr[0], 2);
+ u_int aflags, alenlen, alen;
+
+ ND_TCHECK2(tptr[0], 2);
if (len < 2)
goto trunc;
aflags = *tptr;
@@ -2158,49 +2237,64 @@ bgp_attr_print(u_int atype, const u_char *pptr, u_int len)
tptr += 2;
len -= 2;
alenlen = bgp_attr_lenlen(aflags, tptr);
- TCHECK2(tptr[0], alenlen);
+ ND_TCHECK2(tptr[0], alenlen);
if (len < alenlen)
goto trunc;
alen = bgp_attr_len(aflags, tptr);
tptr += alenlen;
len -= alenlen;
-
- printf("\n\t %s (%u), length: %u",
- tok2strbuf(bgp_attr_values,
- "Unknown Attribute", atype,
- tokbuf, sizeof(tokbuf)),
+
+ ND_PRINT((ndo, "\n\t %s (%u), length: %u",
+ tok2str(bgp_attr_values,
+ "Unknown Attribute", atype),
atype,
- alen);
-
+ alen));
+
if (aflags) {
- printf(", Flags [%s%s%s%s",
+ ND_PRINT((ndo, ", Flags [%s%s%s%s",
aflags & 0x80 ? "O" : "",
aflags & 0x40 ? "T" : "",
aflags & 0x20 ? "P" : "",
- aflags & 0x10 ? "E" : "");
+ aflags & 0x10 ? "E" : ""));
if (aflags & 0xf)
- printf("+%x", aflags & 0xf);
- printf("]: ");
+ ND_PRINT((ndo, "+%x", aflags & 0xf));
+ ND_PRINT((ndo, "]: "));
}
/* FIXME check for recursion */
- if (!bgp_attr_print(atype, tptr, alen))
+ if (!bgp_attr_print(ndo, atype, tptr, alen))
return 0;
tptr += alen;
len -= alen;
}
break;
-
+ case BGPTYPE_LARGE_COMMUNITY:
+ if (len == 0 || len % 12) {
+ ND_PRINT((ndo, "invalid len"));
+ break;
+ }
+ ND_PRINT((ndo, "\n\t "));
+ while (len > 0) {
+ ND_TCHECK2(*tptr, 12);
+ ND_PRINT((ndo, "%u:%u:%u%s",
+ EXTRACT_32BITS(tptr),
+ EXTRACT_32BITS(tptr + 4),
+ EXTRACT_32BITS(tptr + 8),
+ (len > 12) ? ", " : ""));
+ tptr += 12;
+ len -= 12;
+ }
+ break;
default:
- TCHECK2(*pptr,len);
- printf("\n\t no Attribute %u decoder",atype); /* we have no decoder for the attribute */
- if (vflag <= 1)
- print_unknown_data(pptr,"\n\t ",len);
+ ND_TCHECK2(*pptr,len);
+ ND_PRINT((ndo, "\n\t no Attribute %u decoder", atype)); /* we have no decoder for the attribute */
+ if (ndo->ndo_vflag <= 1)
+ print_unknown_data(ndo, pptr, "\n\t ", len);
break;
}
- if (vflag > 1 && len) { /* omit zero length attributes*/
- TCHECK2(*pptr,len);
- print_unknown_data(pptr,"\n\t ",len);
+ if (ndo->ndo_vflag > 1 && len) { /* omit zero length attributes*/
+ ND_TCHECK2(*pptr,len);
+ print_unknown_data(ndo, pptr, "\n\t ", len);
}
return 1;
@@ -2209,53 +2303,48 @@ trunc:
}
static void
-bgp_capabilities_print(const u_char *opt, int caps_len)
+bgp_capabilities_print(netdissect_options *ndo,
+ const u_char *opt, int caps_len)
{
- char tokbuf[TOKBUFSIZE];
- char tokbuf2[TOKBUFSIZE];
int cap_type, cap_len, tcap_len, cap_offset;
int i = 0;
while (i < caps_len) {
- TCHECK2(opt[i], BGP_CAP_HEADER_SIZE);
+ ND_TCHECK2(opt[i], BGP_CAP_HEADER_SIZE);
cap_type=opt[i];
cap_len=opt[i+1];
tcap_len=cap_len;
- printf("\n\t %s (%u), length: %u",
- tok2strbuf(bgp_capcode_values, "Unknown",
- cap_type, tokbuf, sizeof(tokbuf)),
+ ND_PRINT((ndo, "\n\t %s (%u), length: %u",
+ tok2str(bgp_capcode_values, "Unknown",
+ cap_type),
cap_type,
- cap_len);
- TCHECK2(opt[i+2], cap_len);
+ cap_len));
+ ND_TCHECK2(opt[i+2], cap_len);
switch (cap_type) {
case BGP_CAPCODE_MP:
- printf("\n\t\tAFI %s (%u), SAFI %s (%u)",
- tok2strbuf(af_values, "Unknown",
- EXTRACT_16BITS(opt+i+2),
- tokbuf, sizeof(tokbuf)),
+ ND_PRINT((ndo, "\n\t\tAFI %s (%u), SAFI %s (%u)",
+ tok2str(af_values, "Unknown",
+ EXTRACT_16BITS(opt+i+2)),
EXTRACT_16BITS(opt+i+2),
- tok2strbuf(bgp_safi_values, "Unknown",
- opt[i+5],
- tokbuf, sizeof(tokbuf)),
- opt[i+5]);
+ tok2str(bgp_safi_values, "Unknown",
+ opt[i+5]),
+ opt[i+5]));
break;
case BGP_CAPCODE_RESTART:
- printf("\n\t\tRestart Flags: [%s], Restart Time %us",
+ ND_PRINT((ndo, "\n\t\tRestart Flags: [%s], Restart Time %us",
((opt[i+2])&0x80) ? "R" : "none",
- EXTRACT_16BITS(opt+i+2)&0xfff);
+ EXTRACT_16BITS(opt+i+2)&0xfff));
tcap_len-=2;
cap_offset=4;
while(tcap_len>=4) {
- printf("\n\t\t AFI %s (%u), SAFI %s (%u), Forwarding state preserved: %s",
- tok2strbuf(af_values,"Unknown",
- EXTRACT_16BITS(opt+i+cap_offset),
- tokbuf, sizeof(tokbuf)),
+ ND_PRINT((ndo, "\n\t\t AFI %s (%u), SAFI %s (%u), Forwarding state preserved: %s",
+ tok2str(af_values,"Unknown",
+ EXTRACT_16BITS(opt+i+cap_offset)),
EXTRACT_16BITS(opt+i+cap_offset),
- tok2strbuf(bgp_safi_values,"Unknown",
- opt[i+cap_offset+2],
- tokbuf2, sizeof(tokbuf2)),
+ tok2str(bgp_safi_values,"Unknown",
+ opt[i+cap_offset+2]),
opt[i+cap_offset+2],
- ((opt[i+cap_offset+3])&0x80) ? "yes" : "no" );
+ ((opt[i+cap_offset+3])&0x80) ? "yes" : "no" ));
tcap_len-=4;
cap_offset+=4;
}
@@ -2269,50 +2358,72 @@ bgp_capabilities_print(const u_char *opt, int caps_len)
* Extract the 4 byte AS number encoded.
*/
if (cap_len == 4) {
- printf("\n\t\t 4 Byte AS %s",
- as_printf(astostr, sizeof(astostr),
- EXTRACT_32BITS(opt + i + 2)));
+ ND_PRINT((ndo, "\n\t\t 4 Byte AS %s",
+ as_printf(ndo, astostr, sizeof(astostr),
+ EXTRACT_32BITS(opt + i + 2))));
+ }
+ break;
+ case BGP_CAPCODE_ADD_PATH:
+ cap_offset=2;
+ if (tcap_len == 0) {
+ ND_PRINT((ndo, " (bogus)")); /* length */
+ break;
+ }
+ while (tcap_len > 0) {
+ if (tcap_len < 4) {
+ ND_PRINT((ndo, "\n\t\t(invalid)"));
+ break;
+ }
+ ND_PRINT((ndo, "\n\t\tAFI %s (%u), SAFI %s (%u), Send/Receive: %s",
+ tok2str(af_values,"Unknown",EXTRACT_16BITS(opt+i+cap_offset)),
+ EXTRACT_16BITS(opt+i+cap_offset),
+ tok2str(bgp_safi_values,"Unknown",opt[i+cap_offset+2]),
+ opt[i+cap_offset+2],
+ tok2str(bgp_add_path_recvsend,"Bogus (0x%02x)",opt[i+cap_offset+3])
+ ));
+ tcap_len-=4;
+ cap_offset+=4;
}
break;
default:
- printf("\n\t\tno decoder for Capability %u",
- cap_type);
- if (vflag <= 1)
- print_unknown_data(&opt[i+2],"\n\t\t",cap_len);
+ ND_PRINT((ndo, "\n\t\tno decoder for Capability %u",
+ cap_type));
+ if (ndo->ndo_vflag <= 1)
+ print_unknown_data(ndo, &opt[i+2], "\n\t\t", cap_len);
break;
}
- if (vflag > 1 && cap_len > 0) {
- print_unknown_data(&opt[i+2],"\n\t\t",cap_len);
+ if (ndo->ndo_vflag > 1 && cap_len > 0) {
+ print_unknown_data(ndo, &opt[i+2], "\n\t\t", cap_len);
}
i += BGP_CAP_HEADER_SIZE + cap_len;
}
return;
trunc:
- printf("[|BGP]");
+ ND_PRINT((ndo, "[|BGP]"));
}
static void
-bgp_open_print(const u_char *dat, int length)
+bgp_open_print(netdissect_options *ndo,
+ const u_char *dat, int length)
{
struct bgp_open bgpo;
struct bgp_opt bgpopt;
const u_char *opt;
int i;
- char tokbuf[TOKBUFSIZE];
- TCHECK2(dat[0], BGP_OPEN_SIZE);
+ ND_TCHECK2(dat[0], BGP_OPEN_SIZE);
memcpy(&bgpo, dat, BGP_OPEN_SIZE);
- printf("\n\t Version %d, ", bgpo.bgpo_version);
- printf("my AS %s, ",
- as_printf(astostr, sizeof(astostr), ntohs(bgpo.bgpo_myas)));
- printf("Holdtime %us, ", ntohs(bgpo.bgpo_holdtime));
- printf("ID %s", getname((u_char *)&bgpo.bgpo_id));
- printf("\n\t Optional parameters, length: %u", bgpo.bgpo_optlen);
+ ND_PRINT((ndo, "\n\t Version %d, ", bgpo.bgpo_version));
+ ND_PRINT((ndo, "my AS %s, ",
+ as_printf(ndo, astostr, sizeof(astostr), ntohs(bgpo.bgpo_myas))));
+ ND_PRINT((ndo, "Holdtime %us, ", ntohs(bgpo.bgpo_holdtime)));
+ ND_PRINT((ndo, "ID %s", ipaddr_string(ndo, &bgpo.bgpo_id)));
+ ND_PRINT((ndo, "\n\t Optional parameters, length: %u", bgpo.bgpo_optlen));
/* some little sanity checking */
- if (length < bgpo.bgpo_optlen+BGP_OPEN_SIZE)
+ if (length < bgpo.bgpo_optlen+BGP_OPEN_SIZE)
return;
/* ugly! */
@@ -2321,56 +2432,51 @@ bgp_open_print(const u_char *dat, int length)
i = 0;
while (i < bgpo.bgpo_optlen) {
- TCHECK2(opt[i], BGP_OPT_SIZE);
+ ND_TCHECK2(opt[i], BGP_OPT_SIZE);
memcpy(&bgpopt, &opt[i], BGP_OPT_SIZE);
if (i + 2 + bgpopt.bgpopt_len > bgpo.bgpo_optlen) {
- printf("\n\t Option %d, length: %u", bgpopt.bgpopt_type, bgpopt.bgpopt_len);
+ ND_PRINT((ndo, "\n\t Option %d, length: %u", bgpopt.bgpopt_type, bgpopt.bgpopt_len));
break;
}
- printf("\n\t Option %s (%u), length: %u",
- tok2strbuf(bgp_opt_values,"Unknown",
- bgpopt.bgpopt_type,
- tokbuf, sizeof(tokbuf)),
+ ND_PRINT((ndo, "\n\t Option %s (%u), length: %u",
+ tok2str(bgp_opt_values,"Unknown",
+ bgpopt.bgpopt_type),
bgpopt.bgpopt_type,
- bgpopt.bgpopt_len);
+ bgpopt.bgpopt_len));
/* now let's decode the options we know*/
switch(bgpopt.bgpopt_type) {
case BGP_OPT_CAP:
- bgp_capabilities_print(&opt[i+BGP_OPT_SIZE],
+ bgp_capabilities_print(ndo, &opt[i+BGP_OPT_SIZE],
bgpopt.bgpopt_len);
break;
case BGP_OPT_AUTH:
default:
- printf("\n\t no decoder for option %u",
- bgpopt.bgpopt_type);
+ ND_PRINT((ndo, "\n\t no decoder for option %u",
+ bgpopt.bgpopt_type));
break;
}
i += BGP_OPT_SIZE + bgpopt.bgpopt_len;
}
return;
trunc:
- printf("[|BGP]");
+ ND_PRINT((ndo, "[|BGP]"));
}
static void
-bgp_update_print(const u_char *dat, int length)
+bgp_update_print(netdissect_options *ndo,
+ const u_char *dat, int length)
{
struct bgp bgp;
const u_char *p;
int withdrawn_routes_len;
int len;
int i;
- char tokbuf[TOKBUFSIZE];
-#ifndef INET6
- char buf[MAXHOSTNAMELEN + 100];
- int wpfx;
-#endif
- TCHECK2(dat[0], BGP_SIZE);
+ ND_TCHECK2(dat[0], BGP_SIZE);
if (length < BGP_SIZE)
goto trunc;
memcpy(&bgp, dat, BGP_SIZE);
@@ -2378,7 +2484,7 @@ bgp_update_print(const u_char *dat, int length)
length -= BGP_SIZE;
/* Unfeasible routes */
- TCHECK2(p[0], 2);
+ ND_TCHECK2(p[0], 2);
if (length < 2)
goto trunc;
withdrawn_routes_len = EXTRACT_16BITS(p);
@@ -2390,42 +2496,15 @@ bgp_update_print(const u_char *dat, int length)
* it's not possible to tell if this a v4 or v6 route,
* so only try to decode it if we're not v6 enabled.
*/
- TCHECK2(p[0], withdrawn_routes_len);
+ ND_TCHECK2(p[0], withdrawn_routes_len);
if (length < withdrawn_routes_len)
goto trunc;
-#ifdef INET6
- printf("\n\t Withdrawn routes: %d bytes", withdrawn_routes_len);
+ ND_PRINT((ndo, "\n\t Withdrawn routes: %d bytes", withdrawn_routes_len));
p += withdrawn_routes_len;
length -= withdrawn_routes_len;
-#else
- if (withdrawn_routes_len < 2)
- goto trunc;
- length -= 2;
- withdrawn_routes_len -= 2;
-
-
- printf("\n\t Withdrawn routes:");
-
- while(withdrawn_routes_len > 0) {
- wpfx = decode_prefix4(p, withdrawn_routes_len, buf, sizeof(buf));
- if (wpfx == -1) {
- printf("\n\t (illegal prefix length)");
- break;
- } else if (wpfx == -2)
- goto trunc;
- else if (wpfx == -3)
- goto trunc; /* bytes left, but not enough */
- else {
- printf("\n\t %s", buf);
- p += wpfx;
- length -= wpfx;
- withdrawn_routes_len -= wpfx;
- }
- }
-#endif
}
- TCHECK2(p[0], 2);
+ ND_TCHECK2(p[0], 2);
if (length < 2)
goto trunc;
len = EXTRACT_16BITS(p);
@@ -2434,7 +2513,7 @@ bgp_update_print(const u_char *dat, int length)
if (withdrawn_routes_len == 0 && len == 0 && length == 0) {
/* No withdrawn routes, no path attributes, no NLRI */
- printf("\n\t End-of-Rib Marker (empty NLRI)");
+ ND_PRINT((ndo, "\n\t End-of-Rib Marker (empty NLRI)"));
return;
}
@@ -2443,7 +2522,7 @@ bgp_update_print(const u_char *dat, int length)
while (len) {
int aflags, atype, alenlen, alen;
- TCHECK2(p[0], 2);
+ ND_TCHECK2(p[0], 2);
if (len < 2)
goto trunc;
if (length < 2)
@@ -2454,7 +2533,7 @@ bgp_update_print(const u_char *dat, int length)
len -= 2;
length -= 2;
alenlen = bgp_attr_lenlen(aflags, p);
- TCHECK2(p[0], alenlen);
+ ND_TCHECK2(p[0], alenlen);
if (len < alenlen)
goto trunc;
if (length < alenlen)
@@ -2464,34 +2543,33 @@ bgp_update_print(const u_char *dat, int length)
len -= alenlen;
length -= alenlen;
- printf("\n\t %s (%u), length: %u",
- tok2strbuf(bgp_attr_values, "Unknown Attribute",
- atype,
- tokbuf, sizeof(tokbuf)),
+ ND_PRINT((ndo, "\n\t %s (%u), length: %u",
+ tok2str(bgp_attr_values, "Unknown Attribute",
+ atype),
atype,
- alen);
+ alen));
if (aflags) {
- printf(", Flags [%s%s%s%s",
+ ND_PRINT((ndo, ", Flags [%s%s%s%s",
aflags & 0x80 ? "O" : "",
aflags & 0x40 ? "T" : "",
aflags & 0x20 ? "P" : "",
- aflags & 0x10 ? "E" : "");
+ aflags & 0x10 ? "E" : ""));
if (aflags & 0xf)
- printf("+%x", aflags & 0xf);
- printf("]: ");
+ ND_PRINT((ndo, "+%x", aflags & 0xf));
+ ND_PRINT((ndo, "]: "));
}
if (len < alen)
goto trunc;
if (length < alen)
goto trunc;
- if (!bgp_attr_print(atype, p, alen))
+ if (!bgp_attr_print(ndo, atype, p, alen))
goto trunc;
p += alen;
len -= alen;
length -= alen;
}
- }
+ }
if (length) {
/*
@@ -2502,19 +2580,19 @@ bgp_update_print(const u_char *dat, int length)
*
* http://tools.ietf.org/html/draft-ietf-idr-add-paths-06
*/
- printf("\n\t Updated routes:");
+ ND_PRINT((ndo, "\n\t Updated routes:"));
while (length) {
char buf[MAXHOSTNAMELEN + 100];
- i = decode_prefix4(p, length, buf, sizeof(buf));
+ i = decode_prefix4(ndo, p, length, buf, sizeof(buf));
if (i == -1) {
- printf("\n\t (illegal prefix length)");
+ ND_PRINT((ndo, "\n\t (illegal prefix length)"));
break;
} else if (i == -2)
goto trunc;
else if (i == -3)
goto trunc; /* bytes left, but not enough */
else {
- printf("\n\t %s", buf);
+ ND_PRINT((ndo, "\n\t %s", buf));
p += i;
length -= i;
}
@@ -2522,74 +2600,79 @@ bgp_update_print(const u_char *dat, int length)
}
return;
trunc:
- printf("[|BGP]");
+ ND_PRINT((ndo, "[|BGP]"));
}
static void
-bgp_notification_print(const u_char *dat, int length)
+bgp_notification_print(netdissect_options *ndo,
+ const u_char *dat, int length)
{
struct bgp_notification bgpn;
const u_char *tptr;
- char tokbuf[TOKBUFSIZE];
- char tokbuf2[TOKBUFSIZE];
- TCHECK2(dat[0], BGP_NOTIFICATION_SIZE);
+ ND_TCHECK2(dat[0], BGP_NOTIFICATION_SIZE);
memcpy(&bgpn, dat, BGP_NOTIFICATION_SIZE);
/* some little sanity checking */
if (length<BGP_NOTIFICATION_SIZE)
return;
- printf(", %s (%u)",
- tok2strbuf(bgp_notify_major_values, "Unknown Error",
- bgpn.bgpn_major, tokbuf, sizeof(tokbuf)),
- bgpn.bgpn_major);
+ ND_PRINT((ndo, ", %s (%u)",
+ tok2str(bgp_notify_major_values, "Unknown Error",
+ bgpn.bgpn_major),
+ bgpn.bgpn_major));
switch (bgpn.bgpn_major) {
case BGP_NOTIFY_MAJOR_MSG:
- printf(", subcode %s (%u)",
- tok2strbuf(bgp_notify_minor_msg_values, "Unknown",
- bgpn.bgpn_minor, tokbuf, sizeof(tokbuf)),
- bgpn.bgpn_minor);
+ ND_PRINT((ndo, ", subcode %s (%u)",
+ tok2str(bgp_notify_minor_msg_values, "Unknown",
+ bgpn.bgpn_minor),
+ bgpn.bgpn_minor));
break;
case BGP_NOTIFY_MAJOR_OPEN:
- printf(", subcode %s (%u)",
- tok2strbuf(bgp_notify_minor_open_values, "Unknown",
- bgpn.bgpn_minor, tokbuf, sizeof(tokbuf)),
- bgpn.bgpn_minor);
+ ND_PRINT((ndo, ", subcode %s (%u)",
+ tok2str(bgp_notify_minor_open_values, "Unknown",
+ bgpn.bgpn_minor),
+ bgpn.bgpn_minor));
break;
case BGP_NOTIFY_MAJOR_UPDATE:
- printf(", subcode %s (%u)",
- tok2strbuf(bgp_notify_minor_update_values, "Unknown",
- bgpn.bgpn_minor, tokbuf, sizeof(tokbuf)),
- bgpn.bgpn_minor);
+ ND_PRINT((ndo, ", subcode %s (%u)",
+ tok2str(bgp_notify_minor_update_values, "Unknown",
+ bgpn.bgpn_minor),
+ bgpn.bgpn_minor));
+ break;
+ case BGP_NOTIFY_MAJOR_FSM:
+ ND_PRINT((ndo, " subcode %s (%u)",
+ tok2str(bgp_notify_minor_fsm_values, "Unknown",
+ bgpn.bgpn_minor),
+ bgpn.bgpn_minor));
break;
case BGP_NOTIFY_MAJOR_CAP:
- printf(" subcode %s (%u)",
- tok2strbuf(bgp_notify_minor_cap_values, "Unknown",
- bgpn.bgpn_minor, tokbuf, sizeof(tokbuf)),
- bgpn.bgpn_minor);
+ ND_PRINT((ndo, " subcode %s (%u)",
+ tok2str(bgp_notify_minor_cap_values, "Unknown",
+ bgpn.bgpn_minor),
+ bgpn.bgpn_minor));
+ break;
case BGP_NOTIFY_MAJOR_CEASE:
- printf(", subcode %s (%u)",
- tok2strbuf(bgp_notify_minor_cease_values, "Unknown",
- bgpn.bgpn_minor, tokbuf, sizeof(tokbuf)),
- bgpn.bgpn_minor);
+ ND_PRINT((ndo, ", subcode %s (%u)",
+ tok2str(bgp_notify_minor_cease_values, "Unknown",
+ bgpn.bgpn_minor),
+ bgpn.bgpn_minor));
/* draft-ietf-idr-cease-subcode-02 mentions optionally 7 bytes
* for the maxprefix subtype, which may contain AFI, SAFI and MAXPREFIXES
*/
if(bgpn.bgpn_minor == BGP_NOTIFY_MINOR_CEASE_MAXPRFX && length >= BGP_NOTIFICATION_SIZE + 7) {
tptr = dat + BGP_NOTIFICATION_SIZE;
- TCHECK2(*tptr, 7);
- printf(", AFI %s (%u), SAFI %s (%u), Max Prefixes: %u",
- tok2strbuf(af_values, "Unknown",
- EXTRACT_16BITS(tptr), tokbuf, sizeof(tokbuf)),
+ ND_TCHECK2(*tptr, 7);
+ ND_PRINT((ndo, ", AFI %s (%u), SAFI %s (%u), Max Prefixes: %u",
+ tok2str(af_values, "Unknown",
+ EXTRACT_16BITS(tptr)),
EXTRACT_16BITS(tptr),
- tok2strbuf(bgp_safi_values, "Unknown", *(tptr+2),
- tokbuf2, sizeof(tokbuf)),
+ tok2str(bgp_safi_values, "Unknown", *(tptr+2)),
*(tptr+2),
- EXTRACT_32BITS(tptr+3));
+ EXTRACT_32BITS(tptr+3)));
}
break;
default:
@@ -2598,17 +2681,16 @@ bgp_notification_print(const u_char *dat, int length)
return;
trunc:
- printf("[|BGP]");
+ ND_PRINT((ndo, "[|BGP]"));
}
static void
-bgp_route_refresh_print(const u_char *pptr, int len) {
-
+bgp_route_refresh_print(netdissect_options *ndo,
+ const u_char *pptr, int len)
+{
const struct bgp_route_refresh *bgp_route_refresh_header;
- char tokbuf[TOKBUFSIZE];
- char tokbuf2[TOKBUFSIZE];
- TCHECK2(pptr[0], BGP_ROUTE_REFRESH_SIZE);
+ ND_TCHECK2(pptr[0], BGP_ROUTE_REFRESH_SIZE);
/* some little sanity checking */
if (len<BGP_ROUTE_REFRESH_SIZE)
@@ -2616,72 +2698,70 @@ bgp_route_refresh_print(const u_char *pptr, int len) {
bgp_route_refresh_header = (const struct bgp_route_refresh *)pptr;
- printf("\n\t AFI %s (%u), SAFI %s (%u)",
- tok2strbuf(af_values,"Unknown",
+ ND_PRINT((ndo, "\n\t AFI %s (%u), SAFI %s (%u)",
+ tok2str(af_values,"Unknown",
/* this stinks but the compiler pads the structure
* weird */
- EXTRACT_16BITS(&bgp_route_refresh_header->afi),
- tokbuf, sizeof(tokbuf)),
+ EXTRACT_16BITS(&bgp_route_refresh_header->afi)),
EXTRACT_16BITS(&bgp_route_refresh_header->afi),
- tok2strbuf(bgp_safi_values,"Unknown",
- bgp_route_refresh_header->safi,
- tokbuf2, sizeof(tokbuf2)),
- bgp_route_refresh_header->safi);
-
- if (vflag > 1) {
- TCHECK2(*pptr, len);
- print_unknown_data(pptr,"\n\t ", len);
+ tok2str(bgp_safi_values,"Unknown",
+ bgp_route_refresh_header->safi),
+ bgp_route_refresh_header->safi));
+
+ if (ndo->ndo_vflag > 1) {
+ ND_TCHECK2(*pptr, len);
+ print_unknown_data(ndo, pptr, "\n\t ", len);
}
-
+
return;
trunc:
- printf("[|BGP]");
+ ND_PRINT((ndo, "[|BGP]"));
}
static int
-bgp_header_print(const u_char *dat, int length)
+bgp_header_print(netdissect_options *ndo,
+ const u_char *dat, int length)
{
struct bgp bgp;
- char tokbuf[TOKBUFSIZE];
- TCHECK2(dat[0], BGP_SIZE);
+ ND_TCHECK2(dat[0], BGP_SIZE);
memcpy(&bgp, dat, BGP_SIZE);
- printf("\n\t%s Message (%u), length: %u",
- tok2strbuf(bgp_msg_values, "Unknown", bgp.bgp_type,
- tokbuf, sizeof(tokbuf)),
+ ND_PRINT((ndo, "\n\t%s Message (%u), length: %u",
+ tok2str(bgp_msg_values, "Unknown", bgp.bgp_type),
bgp.bgp_type,
- length);
+ length));
switch (bgp.bgp_type) {
case BGP_OPEN:
- bgp_open_print(dat, length);
+ bgp_open_print(ndo, dat, length);
break;
case BGP_UPDATE:
- bgp_update_print(dat, length);
+ bgp_update_print(ndo, dat, length);
break;
case BGP_NOTIFICATION:
- bgp_notification_print(dat, length);
+ bgp_notification_print(ndo, dat, length);
break;
case BGP_KEEPALIVE:
break;
case BGP_ROUTE_REFRESH:
- bgp_route_refresh_print(dat, length);
+ bgp_route_refresh_print(ndo, dat, length);
break;
default:
/* we have no decoder for the BGP message */
- TCHECK2(*dat, length);
- printf("\n\t no Message %u decoder",bgp.bgp_type);
- print_unknown_data(dat,"\n\t ",length);
+ ND_TCHECK2(*dat, length);
+ ND_PRINT((ndo, "\n\t no Message %u decoder", bgp.bgp_type));
+ print_unknown_data(ndo, dat, "\n\t ", length);
break;
}
return 1;
trunc:
- printf("[|BGP]");
+ ND_PRINT((ndo, "[|BGP]"));
return 0;
}
void
-bgp_print(const u_char *dat, int length)
+bgp_print(netdissect_options *ndo,
+ const u_char *dat, int length)
{
const u_char *p;
const u_char *ep;
@@ -2691,29 +2771,28 @@ bgp_print(const u_char *dat, int length)
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
};
struct bgp bgp;
- u_int16_t hlen;
- char tokbuf[TOKBUFSIZE];
+ uint16_t hlen;
ep = dat + length;
- if (snapend < dat + length)
- ep = snapend;
+ if (ndo->ndo_snapend < dat + length)
+ ep = ndo->ndo_snapend;
- printf(": BGP, length: %u",length);
+ ND_PRINT((ndo, ": BGP"));
- if (vflag < 1) /* lets be less chatty */
+ if (ndo->ndo_vflag < 1) /* lets be less chatty */
return;
p = dat;
start = p;
while (p < ep) {
- if (!TTEST2(p[0], 1))
+ if (!ND_TTEST2(p[0], 1))
break;
if (p[0] != 0xff) {
p++;
continue;
}
- if (!TTEST2(p[0], sizeof(marker)))
+ if (!ND_TTEST2(p[0], sizeof(marker)))
break;
if (memcmp(p, marker, sizeof(marker)) != 0) {
p++;
@@ -2721,30 +2800,29 @@ bgp_print(const u_char *dat, int length)
}
/* found BGP header */
- TCHECK2(p[0], BGP_SIZE); /*XXX*/
+ ND_TCHECK2(p[0], BGP_SIZE); /*XXX*/
memcpy(&bgp, p, BGP_SIZE);
if (start != p)
- printf(" [|BGP]");
+ ND_PRINT((ndo, " [|BGP]"));
hlen = ntohs(bgp.bgp_len);
if (hlen < BGP_SIZE) {
- printf("\n[|BGP Bogus header length %u < %u]", hlen,
- BGP_SIZE);
+ ND_PRINT((ndo, "\n[|BGP Bogus header length %u < %u]", hlen,
+ BGP_SIZE));
break;
}
- if (TTEST2(p[0], hlen)) {
- if (!bgp_header_print(p, hlen))
+ if (ND_TTEST2(p[0], hlen)) {
+ if (!bgp_header_print(ndo, p, hlen))
return;
p += hlen;
start = p;
} else {
- printf("\n[|BGP %s]",
- tok2strbuf(bgp_msg_values,
+ ND_PRINT((ndo, "\n[|BGP %s]",
+ tok2str(bgp_msg_values,
"Unknown Message Type",
- bgp.bgp_type,
- tokbuf, sizeof(tokbuf)));
+ bgp.bgp_type)));
break;
}
}
@@ -2752,7 +2830,7 @@ bgp_print(const u_char *dat, int length)
return;
trunc:
- printf(" [|BGP]");
+ ND_PRINT((ndo, " [|BGP]"));
}
/*
@@ -2761,3 +2839,6 @@ trunc:
* c-basic-offset: 4
* End:
*/
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-bgp-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-bootp.c b/freebsd/contrib/tcpdump/print-bootp.c
index abf8efc0..f1f5b609 100644
--- a/freebsd/contrib/tcpdump/print-bootp.c
+++ b/freebsd/contrib/tcpdump/print-bootp.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
@@ -19,163 +22,384 @@
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Format and print bootp packets.
- *
- * $FreeBSD$
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-bootp.c,v 1.89 2008-04-22 09:45:08 hannes Exp $ (LBL)";
-#endif
+
+/* \summary: BOOTP and IPv4 DHCP printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include <stdio.h>
#include <string.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "extract.h"
-#include "ether.h"
-#include "bootp.h"
-static void rfc1048_print(const u_char *);
-static void cmu_print(const u_char *);
-static char *client_fqdn_flags(u_int flags);
+static const char tstr[] = " [|bootp]";
+
+/*
+ * Bootstrap Protocol (BOOTP). RFC951 and RFC1048.
+ *
+ * This file specifies the "implementation-independent" BOOTP protocol
+ * information which is common to both client and server.
+ *
+ * Copyright 1988 by Carnegie Mellon.
+ *
+ * Permission to use, copy, modify, and distribute this program for any
+ * purpose and without fee is hereby granted, provided that this copyright
+ * and permission notice appear on all copies and supporting documentation,
+ * the name of Carnegie Mellon not be used in advertising or publicity
+ * pertaining to distribution of the program without specific prior
+ * permission, and notice be given in supporting documentation that copying
+ * and distribution is by permission of Carnegie Mellon and Stanford
+ * University. Carnegie Mellon makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ */
+
+struct bootp {
+ uint8_t bp_op; /* packet opcode type */
+ uint8_t bp_htype; /* hardware addr type */
+ uint8_t bp_hlen; /* hardware addr length */
+ uint8_t bp_hops; /* gateway hops */
+ uint32_t bp_xid; /* transaction ID */
+ uint16_t bp_secs; /* seconds since boot began */
+ uint16_t bp_flags; /* flags - see bootp_flag_values[]
+ in print-bootp.c */
+ struct in_addr bp_ciaddr; /* client IP address */
+ struct in_addr bp_yiaddr; /* 'your' IP address */
+ struct in_addr bp_siaddr; /* server IP address */
+ struct in_addr bp_giaddr; /* gateway IP address */
+ uint8_t bp_chaddr[16]; /* client hardware address */
+ uint8_t bp_sname[64]; /* server host name */
+ uint8_t bp_file[128]; /* boot file name */
+ uint8_t bp_vend[64]; /* vendor-specific area */
+} UNALIGNED;
+
+#define BOOTPREPLY 2
+#define BOOTPREQUEST 1
+
+/*
+ * Vendor magic cookie (v_magic) for CMU
+ */
+#define VM_CMU "CMU"
+
+/*
+ * Vendor magic cookie (v_magic) for RFC1048
+ */
+#define VM_RFC1048 { 99, 130, 83, 99 }
+
+/*
+ * RFC1048 tag values used to specify what information is being supplied in
+ * the vendor field of the packet.
+ */
+
+#define TAG_PAD ((uint8_t) 0)
+#define TAG_SUBNET_MASK ((uint8_t) 1)
+#define TAG_TIME_OFFSET ((uint8_t) 2)
+#define TAG_GATEWAY ((uint8_t) 3)
+#define TAG_TIME_SERVER ((uint8_t) 4)
+#define TAG_NAME_SERVER ((uint8_t) 5)
+#define TAG_DOMAIN_SERVER ((uint8_t) 6)
+#define TAG_LOG_SERVER ((uint8_t) 7)
+#define TAG_COOKIE_SERVER ((uint8_t) 8)
+#define TAG_LPR_SERVER ((uint8_t) 9)
+#define TAG_IMPRESS_SERVER ((uint8_t) 10)
+#define TAG_RLP_SERVER ((uint8_t) 11)
+#define TAG_HOSTNAME ((uint8_t) 12)
+#define TAG_BOOTSIZE ((uint8_t) 13)
+#define TAG_END ((uint8_t) 255)
+/* RFC1497 tags */
+#define TAG_DUMPPATH ((uint8_t) 14)
+#define TAG_DOMAINNAME ((uint8_t) 15)
+#define TAG_SWAP_SERVER ((uint8_t) 16)
+#define TAG_ROOTPATH ((uint8_t) 17)
+#define TAG_EXTPATH ((uint8_t) 18)
+/* RFC2132 */
+#define TAG_IP_FORWARD ((uint8_t) 19)
+#define TAG_NL_SRCRT ((uint8_t) 20)
+#define TAG_PFILTERS ((uint8_t) 21)
+#define TAG_REASS_SIZE ((uint8_t) 22)
+#define TAG_DEF_TTL ((uint8_t) 23)
+#define TAG_MTU_TIMEOUT ((uint8_t) 24)
+#define TAG_MTU_TABLE ((uint8_t) 25)
+#define TAG_INT_MTU ((uint8_t) 26)
+#define TAG_LOCAL_SUBNETS ((uint8_t) 27)
+#define TAG_BROAD_ADDR ((uint8_t) 28)
+#define TAG_DO_MASK_DISC ((uint8_t) 29)
+#define TAG_SUPPLY_MASK ((uint8_t) 30)
+#define TAG_DO_RDISC ((uint8_t) 31)
+#define TAG_RTR_SOL_ADDR ((uint8_t) 32)
+#define TAG_STATIC_ROUTE ((uint8_t) 33)
+#define TAG_USE_TRAILERS ((uint8_t) 34)
+#define TAG_ARP_TIMEOUT ((uint8_t) 35)
+#define TAG_ETH_ENCAP ((uint8_t) 36)
+#define TAG_TCP_TTL ((uint8_t) 37)
+#define TAG_TCP_KEEPALIVE ((uint8_t) 38)
+#define TAG_KEEPALIVE_GO ((uint8_t) 39)
+#define TAG_NIS_DOMAIN ((uint8_t) 40)
+#define TAG_NIS_SERVERS ((uint8_t) 41)
+#define TAG_NTP_SERVERS ((uint8_t) 42)
+#define TAG_VENDOR_OPTS ((uint8_t) 43)
+#define TAG_NETBIOS_NS ((uint8_t) 44)
+#define TAG_NETBIOS_DDS ((uint8_t) 45)
+#define TAG_NETBIOS_NODE ((uint8_t) 46)
+#define TAG_NETBIOS_SCOPE ((uint8_t) 47)
+#define TAG_XWIN_FS ((uint8_t) 48)
+#define TAG_XWIN_DM ((uint8_t) 49)
+#define TAG_NIS_P_DOMAIN ((uint8_t) 64)
+#define TAG_NIS_P_SERVERS ((uint8_t) 65)
+#define TAG_MOBILE_HOME ((uint8_t) 68)
+#define TAG_SMPT_SERVER ((uint8_t) 69)
+#define TAG_POP3_SERVER ((uint8_t) 70)
+#define TAG_NNTP_SERVER ((uint8_t) 71)
+#define TAG_WWW_SERVER ((uint8_t) 72)
+#define TAG_FINGER_SERVER ((uint8_t) 73)
+#define TAG_IRC_SERVER ((uint8_t) 74)
+#define TAG_STREETTALK_SRVR ((uint8_t) 75)
+#define TAG_STREETTALK_STDA ((uint8_t) 76)
+/* DHCP options */
+#define TAG_REQUESTED_IP ((uint8_t) 50)
+#define TAG_IP_LEASE ((uint8_t) 51)
+#define TAG_OPT_OVERLOAD ((uint8_t) 52)
+#define TAG_TFTP_SERVER ((uint8_t) 66)
+#define TAG_BOOTFILENAME ((uint8_t) 67)
+#define TAG_DHCP_MESSAGE ((uint8_t) 53)
+#define TAG_SERVER_ID ((uint8_t) 54)
+#define TAG_PARM_REQUEST ((uint8_t) 55)
+#define TAG_MESSAGE ((uint8_t) 56)
+#define TAG_MAX_MSG_SIZE ((uint8_t) 57)
+#define TAG_RENEWAL_TIME ((uint8_t) 58)
+#define TAG_REBIND_TIME ((uint8_t) 59)
+#define TAG_VENDOR_CLASS ((uint8_t) 60)
+#define TAG_CLIENT_ID ((uint8_t) 61)
+/* RFC 2241 */
+#define TAG_NDS_SERVERS ((uint8_t) 85)
+#define TAG_NDS_TREE_NAME ((uint8_t) 86)
+#define TAG_NDS_CONTEXT ((uint8_t) 87)
+/* RFC 2242 */
+#define TAG_NDS_IPDOMAIN ((uint8_t) 62)
+#define TAG_NDS_IPINFO ((uint8_t) 63)
+/* RFC 2485 */
+#define TAG_OPEN_GROUP_UAP ((uint8_t) 98)
+/* RFC 2563 */
+#define TAG_DISABLE_AUTOCONF ((uint8_t) 116)
+/* RFC 2610 */
+#define TAG_SLP_DA ((uint8_t) 78)
+#define TAG_SLP_SCOPE ((uint8_t) 79)
+/* RFC 2937 */
+#define TAG_NS_SEARCH ((uint8_t) 117)
+/* RFC 3004 - The User Class Option for DHCP */
+#define TAG_USER_CLASS ((uint8_t) 77)
+/* RFC 3011 */
+#define TAG_IP4_SUBNET_SELECT ((uint8_t) 118)
+/* RFC 3442 */
+#define TAG_CLASSLESS_STATIC_RT ((uint8_t) 121)
+#define TAG_CLASSLESS_STA_RT_MS ((uint8_t) 249)
+/* RFC 5859 - TFTP Server Address Option for DHCPv4 */
+#define TAG_TFTP_SERVER_ADDRESS ((uint8_t) 150)
+/* ftp://ftp.isi.edu/.../assignments/bootp-dhcp-extensions */
+#define TAG_SLP_NAMING_AUTH ((uint8_t) 80)
+#define TAG_CLIENT_FQDN ((uint8_t) 81)
+#define TAG_AGENT_CIRCUIT ((uint8_t) 82)
+#define TAG_AGENT_REMOTE ((uint8_t) 83)
+#define TAG_AGENT_MASK ((uint8_t) 84)
+#define TAG_TZ_STRING ((uint8_t) 88)
+#define TAG_FQDN_OPTION ((uint8_t) 89)
+#define TAG_AUTH ((uint8_t) 90)
+#define TAG_VINES_SERVERS ((uint8_t) 91)
+#define TAG_SERVER_RANK ((uint8_t) 92)
+#define TAG_CLIENT_ARCH ((uint8_t) 93)
+#define TAG_CLIENT_NDI ((uint8_t) 94)
+#define TAG_CLIENT_GUID ((uint8_t) 97)
+#define TAG_LDAP_URL ((uint8_t) 95)
+#define TAG_6OVER4 ((uint8_t) 96)
+/* RFC 4833, TZ codes */
+#define TAG_TZ_PCODE ((uint8_t) 100)
+#define TAG_TZ_TCODE ((uint8_t) 101)
+#define TAG_IPX_COMPAT ((uint8_t) 110)
+#define TAG_NETINFO_PARENT ((uint8_t) 112)
+#define TAG_NETINFO_PARENT_TAG ((uint8_t) 113)
+#define TAG_URL ((uint8_t) 114)
+#define TAG_FAILOVER ((uint8_t) 115)
+#define TAG_EXTENDED_REQUEST ((uint8_t) 126)
+#define TAG_EXTENDED_OPTION ((uint8_t) 127)
+#define TAG_MUDURL ((uint8_t) 161)
+
+/* DHCP Message types (values for TAG_DHCP_MESSAGE option) */
+#define DHCPDISCOVER 1
+#define DHCPOFFER 2
+#define DHCPREQUEST 3
+#define DHCPDECLINE 4
+#define DHCPACK 5
+#define DHCPNAK 6
+#define DHCPRELEASE 7
+#define DHCPINFORM 8
+
+/*
+ * "vendor" data permitted for CMU bootp clients.
+ */
+
+struct cmu_vend {
+ uint8_t v_magic[4]; /* magic number */
+ uint32_t v_flags; /* flags/opcodes, etc. */
+ struct in_addr v_smask; /* Subnet mask */
+ struct in_addr v_dgate; /* Default gateway */
+ struct in_addr v_dns1, v_dns2; /* Domain name servers */
+ struct in_addr v_ins1, v_ins2; /* IEN-116 name servers */
+ struct in_addr v_ts1, v_ts2; /* Time servers */
+ uint8_t v_unused[24]; /* currently unused */
+} UNALIGNED;
+
+
+/* v_flags values */
+#define VF_SMASK 1 /* Subnet mask field contains valid data */
-static char tstr[] = " [|bootp]";
+/* RFC 4702 DHCP Client FQDN Option */
+
+#define CLIENT_FQDN_FLAGS_S 0x01
+#define CLIENT_FQDN_FLAGS_O 0x02
+#define CLIENT_FQDN_FLAGS_E 0x04
+#define CLIENT_FQDN_FLAGS_N 0x08
+/* end of original bootp.h */
+
+static void rfc1048_print(netdissect_options *, const u_char *);
+static void cmu_print(netdissect_options *, const u_char *);
+static char *client_fqdn_flags(u_int flags);
static const struct tok bootp_flag_values[] = {
- { 0x8000, "Broadcast" },
- { 0, NULL}
+ { 0x8000, "Broadcast" },
+ { 0, NULL}
};
static const struct tok bootp_op_values[] = {
- { BOOTPREQUEST, "Request" },
- { BOOTPREPLY, "Reply" },
- { 0, NULL}
+ { BOOTPREQUEST, "Request" },
+ { BOOTPREPLY, "Reply" },
+ { 0, NULL}
};
/*
* Print bootp requests
*/
void
-bootp_print(register const u_char *cp, u_int length)
+bootp_print(netdissect_options *ndo,
+ register const u_char *cp, u_int length)
{
register const struct bootp *bp;
static const u_char vm_cmu[4] = VM_CMU;
static const u_char vm_rfc1048[4] = VM_RFC1048;
bp = (const struct bootp *)cp;
- TCHECK(bp->bp_op);
+ ND_TCHECK(bp->bp_op);
- printf("BOOTP/DHCP, %s",
- tok2str(bootp_op_values, "unknown (0x%02x)", bp->bp_op));
+ ND_PRINT((ndo, "BOOTP/DHCP, %s",
+ tok2str(bootp_op_values, "unknown (0x%02x)", bp->bp_op)));
+ ND_TCHECK(bp->bp_hlen);
if (bp->bp_htype == 1 && bp->bp_hlen == 6 && bp->bp_op == BOOTPREQUEST) {
- TCHECK2(bp->bp_chaddr[0], 6);
- printf(" from %s", etheraddr_string(bp->bp_chaddr));
+ ND_TCHECK2(bp->bp_chaddr[0], 6);
+ ND_PRINT((ndo, " from %s", etheraddr_string(ndo, bp->bp_chaddr)));
}
- printf(", length %u", length);
+ ND_PRINT((ndo, ", length %u", length));
- if (!vflag)
- return;
+ if (!ndo->ndo_vflag)
+ return;
- TCHECK(bp->bp_secs);
+ ND_TCHECK(bp->bp_secs);
/* The usual hardware address type is 1 (10Mb Ethernet) */
if (bp->bp_htype != 1)
- printf(", htype %d", bp->bp_htype);
+ ND_PRINT((ndo, ", htype %d", bp->bp_htype));
/* The usual length for 10Mb Ethernet address is 6 bytes */
if (bp->bp_htype != 1 || bp->bp_hlen != 6)
- printf(", hlen %d", bp->bp_hlen);
+ ND_PRINT((ndo, ", hlen %d", bp->bp_hlen));
/* Only print interesting fields */
if (bp->bp_hops)
- printf(", hops %d", bp->bp_hops);
- if (bp->bp_xid)
- printf(", xid 0x%x", EXTRACT_32BITS(&bp->bp_xid));
- if (bp->bp_secs)
- printf(", secs %d", EXTRACT_16BITS(&bp->bp_secs));
+ ND_PRINT((ndo, ", hops %d", bp->bp_hops));
+ if (EXTRACT_32BITS(&bp->bp_xid))
+ ND_PRINT((ndo, ", xid 0x%x", EXTRACT_32BITS(&bp->bp_xid)));
+ if (EXTRACT_16BITS(&bp->bp_secs))
+ ND_PRINT((ndo, ", secs %d", EXTRACT_16BITS(&bp->bp_secs)));
- printf(", Flags [%s]",
- bittok2str(bootp_flag_values, "none", EXTRACT_16BITS(&bp->bp_flags)));
- if (vflag > 1)
- printf(" (0x%04x)", EXTRACT_16BITS(&bp->bp_flags));
+ ND_PRINT((ndo, ", Flags [%s]",
+ bittok2str(bootp_flag_values, "none", EXTRACT_16BITS(&bp->bp_flags))));
+ if (ndo->ndo_vflag > 1)
+ ND_PRINT((ndo, " (0x%04x)", EXTRACT_16BITS(&bp->bp_flags)));
/* Client's ip address */
- TCHECK(bp->bp_ciaddr);
- if (bp->bp_ciaddr.s_addr)
- printf("\n\t Client-IP %s", ipaddr_string(&bp->bp_ciaddr));
+ ND_TCHECK(bp->bp_ciaddr);
+ if (EXTRACT_32BITS(&bp->bp_ciaddr.s_addr))
+ ND_PRINT((ndo, "\n\t Client-IP %s", ipaddr_string(ndo, &bp->bp_ciaddr)));
/* 'your' ip address (bootp client) */
- TCHECK(bp->bp_yiaddr);
- if (bp->bp_yiaddr.s_addr)
- printf("\n\t Your-IP %s", ipaddr_string(&bp->bp_yiaddr));
+ ND_TCHECK(bp->bp_yiaddr);
+ if (EXTRACT_32BITS(&bp->bp_yiaddr.s_addr))
+ ND_PRINT((ndo, "\n\t Your-IP %s", ipaddr_string(ndo, &bp->bp_yiaddr)));
/* Server's ip address */
- TCHECK(bp->bp_siaddr);
- if (bp->bp_siaddr.s_addr)
- printf("\n\t Server-IP %s", ipaddr_string(&bp->bp_siaddr));
+ ND_TCHECK(bp->bp_siaddr);
+ if (EXTRACT_32BITS(&bp->bp_siaddr.s_addr))
+ ND_PRINT((ndo, "\n\t Server-IP %s", ipaddr_string(ndo, &bp->bp_siaddr)));
/* Gateway's ip address */
- TCHECK(bp->bp_giaddr);
- if (bp->bp_giaddr.s_addr)
- printf("\n\t Gateway-IP %s", ipaddr_string(&bp->bp_giaddr));
+ ND_TCHECK(bp->bp_giaddr);
+ if (EXTRACT_32BITS(&bp->bp_giaddr.s_addr))
+ ND_PRINT((ndo, "\n\t Gateway-IP %s", ipaddr_string(ndo, &bp->bp_giaddr)));
/* Client's Ethernet address */
if (bp->bp_htype == 1 && bp->bp_hlen == 6) {
- TCHECK2(bp->bp_chaddr[0], 6);
- printf("\n\t Client-Ethernet-Address %s", etheraddr_string(bp->bp_chaddr));
+ ND_TCHECK2(bp->bp_chaddr[0], 6);
+ ND_PRINT((ndo, "\n\t Client-Ethernet-Address %s", etheraddr_string(ndo, bp->bp_chaddr)));
}
- TCHECK2(bp->bp_sname[0], 1); /* check first char only */
+ ND_TCHECK2(bp->bp_sname[0], 1); /* check first char only */
if (*bp->bp_sname) {
- printf("\n\t sname \"");
- if (fn_print(bp->bp_sname, snapend)) {
- putchar('"');
- fputs(tstr + 1, stdout);
+ ND_PRINT((ndo, "\n\t sname \""));
+ if (fn_printztn(ndo, bp->bp_sname, (u_int)sizeof bp->bp_sname,
+ ndo->ndo_snapend)) {
+ ND_PRINT((ndo, "\""));
+ ND_PRINT((ndo, "%s", tstr + 1));
return;
}
- putchar('"');
+ ND_PRINT((ndo, "\""));
}
- TCHECK2(bp->bp_file[0], 1); /* check first char only */
+ ND_TCHECK2(bp->bp_file[0], 1); /* check first char only */
if (*bp->bp_file) {
- printf("\n\t file \"");
- if (fn_print(bp->bp_file, snapend)) {
- putchar('"');
- fputs(tstr + 1, stdout);
+ ND_PRINT((ndo, "\n\t file \""));
+ if (fn_printztn(ndo, bp->bp_file, (u_int)sizeof bp->bp_file,
+ ndo->ndo_snapend)) {
+ ND_PRINT((ndo, "\""));
+ ND_PRINT((ndo, "%s", tstr + 1));
return;
}
- putchar('"');
+ ND_PRINT((ndo, "\""));
}
/* Decode the vendor buffer */
- TCHECK(bp->bp_vend[0]);
+ ND_TCHECK(bp->bp_vend[0]);
if (memcmp((const char *)bp->bp_vend, vm_rfc1048,
- sizeof(u_int32_t)) == 0)
- rfc1048_print(bp->bp_vend);
+ sizeof(uint32_t)) == 0)
+ rfc1048_print(ndo, bp->bp_vend);
else if (memcmp((const char *)bp->bp_vend, vm_cmu,
- sizeof(u_int32_t)) == 0)
- cmu_print(bp->bp_vend);
+ sizeof(uint32_t)) == 0)
+ cmu_print(ndo, bp->bp_vend);
else {
- u_int32_t ul;
+ uint32_t ul;
ul = EXTRACT_32BITS(&bp->bp_vend);
if (ul != 0)
- printf("\n\t Vendor-#0x%x", ul);
+ ND_PRINT((ndo, "\n\t Vendor-#0x%x", ul));
}
return;
trunc:
- fputs(tstr, stdout);
+ ND_PRINT((ndo, "%s", tstr));
}
/*
@@ -191,7 +415,7 @@ trunc:
* B - on/off (8 bits)
* $ - special (explicit code to handle)
*/
-static struct tok tag2str[] = {
+static const struct tok tag2str[] = {
/* RFC1048 tags */
{ TAG_PAD, " PAD" },
{ TAG_SUBNET_MASK, "iSubnet-Mask" }, /* subnet mask (RFC950) */
@@ -280,13 +504,16 @@ static struct tok tag2str[] = {
{ TAG_SLP_SCOPE, "bSLP-SCOPE" }, /*"b" is a little wrong */
/* RFC 2937 */
{ TAG_NS_SEARCH, "sNSSEARCH" }, /* XXX 's' */
+/* RFC 3004 - The User Class Option for DHCP */
+ { TAG_USER_CLASS, "$User-Class" },
/* RFC 3011 */
{ TAG_IP4_SUBNET_SELECT, "iSUBNET" },
/* RFC 3442 */
{ TAG_CLASSLESS_STATIC_RT, "$Classless-Static-Route" },
{ TAG_CLASSLESS_STA_RT_MS, "$Classless-Static-Route-Microsoft" },
+/* RFC 5859 - TFTP Server Address Option for DHCPv4 */
+ { TAG_TFTP_SERVER_ADDRESS, "iTFTP-Server-Address" },
/* http://www.iana.org/assignments/bootp-dhcp-extensions/index.htm */
- { TAG_USER_CLASS, "aCLASS" },
{ TAG_SLP_NAMING_AUTH, "aSLP-NA" },
{ TAG_CLIENT_FQDN, "$FQDN" },
{ TAG_AGENT_CIRCUIT, "$Agent-Information" },
@@ -302,98 +529,100 @@ static struct tok tag2str[] = {
{ TAG_CLIENT_GUID, "bGUID" }, /* XXX 'b' */
{ TAG_LDAP_URL, "aLDAP" },
{ TAG_6OVER4, "i6o4" },
- { TAG_PRINTER_NAME, "aPRTR" },
- { TAG_MDHCP_SERVER, "bMDHCP" }, /* XXX 'b' */
+ { TAG_TZ_PCODE, "aPOSIX-TZ" },
+ { TAG_TZ_TCODE, "aTZ-Name" },
{ TAG_IPX_COMPAT, "bIPX" }, /* XXX 'b' */
{ TAG_NETINFO_PARENT, "iNI" },
{ TAG_NETINFO_PARENT_TAG, "aNITAG" },
{ TAG_URL, "aURL" },
{ TAG_FAILOVER, "bFAIL" }, /* XXX 'b' */
- { 0, NULL }
+ { TAG_MUDURL, "aMUD-URL" },
+ { 0, NULL }
};
/* 2-byte extended tags */
-static struct tok xtag2str[] = {
- { 0, NULL }
+static const struct tok xtag2str[] = {
+ { 0, NULL }
};
/* DHCP "options overload" types */
-static struct tok oo2str[] = {
- { 1, "file" },
- { 2, "sname" },
- { 3, "file+sname" },
- { 0, NULL }
+static const struct tok oo2str[] = {
+ { 1, "file" },
+ { 2, "sname" },
+ { 3, "file+sname" },
+ { 0, NULL }
};
/* NETBIOS over TCP/IP node type options */
-static struct tok nbo2str[] = {
- { 0x1, "b-node" },
- { 0x2, "p-node" },
- { 0x4, "m-node" },
- { 0x8, "h-node" },
- { 0, NULL }
+static const struct tok nbo2str[] = {
+ { 0x1, "b-node" },
+ { 0x2, "p-node" },
+ { 0x4, "m-node" },
+ { 0x8, "h-node" },
+ { 0, NULL }
};
/* ARP Hardware types, for Client-ID option */
-static struct tok arp2str[] = {
- { 0x1, "ether" },
- { 0x6, "ieee802" },
- { 0x7, "arcnet" },
- { 0xf, "frelay" },
- { 0x17, "strip" },
- { 0x18, "ieee1394" },
- { 0, NULL }
+static const struct tok arp2str[] = {
+ { 0x1, "ether" },
+ { 0x6, "ieee802" },
+ { 0x7, "arcnet" },
+ { 0xf, "frelay" },
+ { 0x17, "strip" },
+ { 0x18, "ieee1394" },
+ { 0, NULL }
};
-static struct tok dhcp_msg_values[] = {
- { DHCPDISCOVER, "Discover" },
- { DHCPOFFER, "Offer" },
- { DHCPREQUEST, "Request" },
- { DHCPDECLINE, "Decline" },
- { DHCPACK, "ACK" },
- { DHCPNAK, "NACK" },
- { DHCPRELEASE, "Release" },
- { DHCPINFORM, "Inform" },
- { 0, NULL }
+static const struct tok dhcp_msg_values[] = {
+ { DHCPDISCOVER, "Discover" },
+ { DHCPOFFER, "Offer" },
+ { DHCPREQUEST, "Request" },
+ { DHCPDECLINE, "Decline" },
+ { DHCPACK, "ACK" },
+ { DHCPNAK, "NACK" },
+ { DHCPRELEASE, "Release" },
+ { DHCPINFORM, "Inform" },
+ { 0, NULL }
};
-#define AGENT_SUBOPTION_CIRCUIT_ID 1 /* RFC 3046 */
-#define AGENT_SUBOPTION_REMOTE_ID 2 /* RFC 3046 */
-#define AGENT_SUBOPTION_SUBSCRIBER_ID 6 /* RFC 3993 */
-static struct tok agent_suboption_values[] = {
- { AGENT_SUBOPTION_CIRCUIT_ID, "Circuit-ID" },
- { AGENT_SUBOPTION_REMOTE_ID, "Remote-ID" },
- { AGENT_SUBOPTION_SUBSCRIBER_ID, "Subscriber-ID" },
- { 0, NULL }
+#define AGENT_SUBOPTION_CIRCUIT_ID 1 /* RFC 3046 */
+#define AGENT_SUBOPTION_REMOTE_ID 2 /* RFC 3046 */
+#define AGENT_SUBOPTION_SUBSCRIBER_ID 6 /* RFC 3993 */
+static const struct tok agent_suboption_values[] = {
+ { AGENT_SUBOPTION_CIRCUIT_ID, "Circuit-ID" },
+ { AGENT_SUBOPTION_REMOTE_ID, "Remote-ID" },
+ { AGENT_SUBOPTION_SUBSCRIBER_ID, "Subscriber-ID" },
+ { 0, NULL }
};
static void
-rfc1048_print(register const u_char *bp)
+rfc1048_print(netdissect_options *ndo,
+ register const u_char *bp)
{
- register u_int16_t tag;
+ register uint16_t tag;
register u_int len;
register const char *cp;
register char c;
int first, idx;
- u_int32_t ul;
- u_int16_t us;
- u_int8_t uc, subopt, suboptlen;
+ uint32_t ul;
+ uint16_t us;
+ uint8_t uc, subopt, suboptlen;
- printf("\n\t Vendor-rfc1048 Extensions");
+ ND_PRINT((ndo, "\n\t Vendor-rfc1048 Extensions"));
/* Step over magic cookie */
- printf("\n\t Magic Cookie 0x%08x", EXTRACT_32BITS(bp));
+ ND_PRINT((ndo, "\n\t Magic Cookie 0x%08x", EXTRACT_32BITS(bp)));
bp += sizeof(int32_t);
/* Loop while we there is a tag left in the buffer */
- while (TTEST2(*bp, 1)) {
+ while (ND_TTEST2(*bp, 1)) {
tag = *bp++;
- if (tag == TAG_PAD && vflag < 3)
+ if (tag == TAG_PAD && ndo->ndo_vflag < 3)
continue;
- if (tag == TAG_END && vflag < 3)
+ if (tag == TAG_END && ndo->ndo_vflag < 3)
return;
if (tag == TAG_EXTENDED_OPTION) {
- TCHECK2(*(bp + 1), 2);
+ ND_TCHECK2(*(bp + 1), 2);
tag = EXTRACT_16BITS(bp + 1);
/* XXX we don't know yet if the IANA will
* preclude overlap of 1-byte and 2-byte spaces.
@@ -408,32 +637,32 @@ rfc1048_print(register const u_char *bp)
len = 0;
else {
/* Get the length; check for truncation */
- TCHECK2(*bp, 1);
+ ND_TCHECK2(*bp, 1);
len = *bp++;
}
- printf("\n\t %s Option %u, length %u%s", cp, tag, len,
- len > 0 ? ": " : "");
+ ND_PRINT((ndo, "\n\t %s Option %u, length %u%s", cp, tag, len,
+ len > 0 ? ": " : ""));
- if (tag == TAG_PAD && vflag > 2) {
+ if (tag == TAG_PAD && ndo->ndo_vflag > 2) {
u_int ntag = 1;
- while (TTEST2(*bp, 1) && *bp == TAG_PAD) {
+ while (ND_TTEST2(*bp, 1) && *bp == TAG_PAD) {
bp++;
ntag++;
}
if (ntag > 1)
- printf(", occurs %u", ntag);
+ ND_PRINT((ndo, ", occurs %u", ntag));
}
- if (!TTEST2(*bp, len)) {
- printf("[|rfc1048 %u]", len);
+ if (!ND_TTEST2(*bp, len)) {
+ ND_PRINT((ndo, "[|rfc1048 %u]", len));
return;
}
if (tag == TAG_DHCP_MESSAGE && len == 1) {
uc = *bp++;
- printf("%s", tok2str(dhcp_msg_values, "Unknown (%u)", uc));
- continue;
+ ND_PRINT((ndo, "%s", tok2str(dhcp_msg_values, "Unknown (%u)", uc)));
+ continue;
}
if (tag == TAG_PARM_REQUEST) {
@@ -442,10 +671,10 @@ rfc1048_print(register const u_char *bp)
uc = *bp++;
cp = tok2str(tag2str, "?Option %u", uc);
if (idx % 4 == 0)
- printf("\n\t ");
+ ND_PRINT((ndo, "\n\t "));
else
- printf(", ");
- printf("%s", cp + 1);
+ ND_PRINT((ndo, ", "));
+ ND_PRINT((ndo, "%s", cp + 1));
idx++;
}
continue;
@@ -459,8 +688,8 @@ rfc1048_print(register const u_char *bp)
bp += 2;
cp = tok2str(xtag2str, "?xT%u", us);
if (!first)
- putchar('+');
- printf("%s", cp + 1);
+ ND_PRINT((ndo, "+"));
+ ND_PRINT((ndo, "%s", cp + 1));
first = 0;
}
continue;
@@ -481,12 +710,12 @@ rfc1048_print(register const u_char *bp)
case 'a':
/* ascii strings */
- putchar('"');
- if (fn_printn(bp, len, snapend)) {
- putchar('"');
+ ND_PRINT((ndo, "\""));
+ if (fn_printn(ndo, bp, len, ndo->ndo_snapend)) {
+ ND_PRINT((ndo, "\""));
goto trunc;
}
- putchar('"');
+ ND_PRINT((ndo, "\""));
bp += len;
len = 0;
break;
@@ -497,15 +726,15 @@ rfc1048_print(register const u_char *bp)
/* ip addresses/32-bit words */
while (len >= sizeof(ul)) {
if (!first)
- putchar(',');
+ ND_PRINT((ndo, ","));
ul = EXTRACT_32BITS(bp);
if (c == 'i') {
ul = htonl(ul);
- printf("%s", ipaddr_string(&ul));
+ ND_PRINT((ndo, "%s", ipaddr_string(ndo, &ul)));
} else if (c == 'L')
- printf("%d", ul);
+ ND_PRINT((ndo, "%d", ul));
else
- printf("%u", ul);
+ ND_PRINT((ndo, "%u", ul));
bp += sizeof(ul);
len -= sizeof(ul);
first = 0;
@@ -516,12 +745,12 @@ rfc1048_print(register const u_char *bp)
/* IP address pairs */
while (len >= 2*sizeof(ul)) {
if (!first)
- putchar(',');
+ ND_PRINT((ndo, ","));
memcpy((char *)&ul, (const char *)bp, sizeof(ul));
- printf("(%s:", ipaddr_string(&ul));
+ ND_PRINT((ndo, "(%s:", ipaddr_string(ndo, &ul)));
bp += sizeof(ul);
memcpy((char *)&ul, (const char *)bp, sizeof(ul));
- printf("%s)", ipaddr_string(&ul));
+ ND_PRINT((ndo, "%s)", ipaddr_string(ndo, &ul)));
bp += sizeof(ul);
len -= 2*sizeof(ul);
first = 0;
@@ -532,9 +761,9 @@ rfc1048_print(register const u_char *bp)
/* shorts */
while (len >= sizeof(us)) {
if (!first)
- putchar(',');
+ ND_PRINT((ndo, ","));
us = EXTRACT_16BITS(bp);
- printf("%u", us);
+ ND_PRINT((ndo, "%u", us));
bp += sizeof(us);
len -= sizeof(us);
first = 0;
@@ -545,16 +774,16 @@ rfc1048_print(register const u_char *bp)
/* boolean */
while (len > 0) {
if (!first)
- putchar(',');
+ ND_PRINT((ndo, ","));
switch (*bp) {
case 0:
- putchar('N');
+ ND_PRINT((ndo, "N"));
break;
case 1:
- putchar('Y');
+ ND_PRINT((ndo, "Y"));
break;
default:
- printf("%u?", *bp);
+ ND_PRINT((ndo, "%u?", *bp));
break;
}
++bp;
@@ -569,11 +798,11 @@ rfc1048_print(register const u_char *bp)
/* Bytes */
while (len > 0) {
if (!first)
- putchar(c == 'x' ? ':' : '.');
+ ND_PRINT((ndo, c == 'x' ? ":" : "."));
if (c == 'x')
- printf("%02x", *bp);
+ ND_PRINT((ndo, "%02x", *bp));
else
- printf("%u", *bp);
+ ND_PRINT((ndo, "%u", *bp));
++bp;
--len;
first = 0;
@@ -586,80 +815,77 @@ rfc1048_print(register const u_char *bp)
case TAG_NETBIOS_NODE:
/* this option should be at least 1 byte long */
- if (len < 1) {
- printf("ERROR: option %u len %u < 1 bytes",
- TAG_NETBIOS_NODE, len);
+ if (len < 1) {
+ ND_PRINT((ndo, "ERROR: length < 1 bytes"));
break;
}
tag = *bp++;
--len;
- fputs(tok2str(nbo2str, NULL, tag), stdout);
+ ND_PRINT((ndo, "%s", tok2str(nbo2str, NULL, tag)));
break;
case TAG_OPT_OVERLOAD:
/* this option should be at least 1 byte long */
- if (len < 1) {
- printf("ERROR: option %u len %u < 1 bytes",
- TAG_OPT_OVERLOAD, len);
+ if (len < 1) {
+ ND_PRINT((ndo, "ERROR: length < 1 bytes"));
break;
}
tag = *bp++;
--len;
- fputs(tok2str(oo2str, NULL, tag), stdout);
+ ND_PRINT((ndo, "%s", tok2str(oo2str, NULL, tag)));
break;
case TAG_CLIENT_FQDN:
/* this option should be at least 3 bytes long */
- if (len < 3) {
- printf("ERROR: option %u len %u < 3 bytes",
- TAG_CLIENT_FQDN, len);
+ if (len < 3) {
+ ND_PRINT((ndo, "ERROR: length < 3 bytes"));
bp += len;
len = 0;
break;
}
if (*bp)
- printf("[%s] ", client_fqdn_flags(*bp));
+ ND_PRINT((ndo, "[%s] ", client_fqdn_flags(*bp)));
bp++;
if (*bp || *(bp+1))
- printf("%u/%u ", *bp, *(bp+1));
+ ND_PRINT((ndo, "%u/%u ", *bp, *(bp+1)));
bp += 2;
- putchar('"');
- if (fn_printn(bp, len - 3, snapend)) {
- putchar('"');
+ ND_PRINT((ndo, "\""));
+ if (fn_printn(ndo, bp, len - 3, ndo->ndo_snapend)) {
+ ND_PRINT((ndo, "\""));
goto trunc;
}
- putchar('"');
+ ND_PRINT((ndo, "\""));
bp += len - 3;
len = 0;
break;
case TAG_CLIENT_ID:
- { int type;
+ {
+ int type;
/* this option should be at least 1 byte long */
- if (len < 1) {
- printf("ERROR: option %u len %u < 1 bytes",
- TAG_CLIENT_ID, len);
+ if (len < 1) {
+ ND_PRINT((ndo, "ERROR: length < 1 bytes"));
break;
}
type = *bp++;
len--;
if (type == 0) {
- putchar('"');
- if (fn_printn(bp, len, snapend)) {
- putchar('"');
+ ND_PRINT((ndo, "\""));
+ if (fn_printn(ndo, bp, len, ndo->ndo_snapend)) {
+ ND_PRINT((ndo, "\""));
goto trunc;
}
- putchar('"');
+ ND_PRINT((ndo, "\""));
bp += len;
len = 0;
break;
} else {
- printf("%s ", tok2str(arp2str, "hardware-type %u,", type));
+ ND_PRINT((ndo, "%s ", tok2str(arp2str, "hardware-type %u,", type)));
while (len > 0) {
if (!first)
- putchar(':');
- printf("%02x", *bp);
+ ND_PRINT((ndo, ":"));
+ ND_PRINT((ndo, "%02x", *bp));
++bp;
--len;
first = 0;
@@ -674,56 +900,56 @@ rfc1048_print(register const u_char *bp)
suboptlen = *bp++;
len -= 2;
if (suboptlen > len) {
- printf("\n\t %s SubOption %u, length %u: length goes past end of option",
- tok2str(agent_suboption_values, "Unknown", subopt),
- subopt,
- suboptlen);
+ ND_PRINT((ndo, "\n\t %s SubOption %u, length %u: length goes past end of option",
+ tok2str(agent_suboption_values, "Unknown", subopt),
+ subopt,
+ suboptlen));
bp += len;
len = 0;
break;
}
- printf("\n\t %s SubOption %u, length %u: ",
- tok2str(agent_suboption_values, "Unknown", subopt),
- subopt,
- suboptlen);
+ ND_PRINT((ndo, "\n\t %s SubOption %u, length %u: ",
+ tok2str(agent_suboption_values, "Unknown", subopt),
+ subopt,
+ suboptlen));
switch (subopt) {
- case AGENT_SUBOPTION_CIRCUIT_ID: /* fall through */
- case AGENT_SUBOPTION_REMOTE_ID:
- case AGENT_SUBOPTION_SUBSCRIBER_ID:
- fn_printn(bp, suboptlen, NULL);
- break;
+ case AGENT_SUBOPTION_CIRCUIT_ID: /* fall through */
+ case AGENT_SUBOPTION_REMOTE_ID:
+ case AGENT_SUBOPTION_SUBSCRIBER_ID:
+ if (fn_printn(ndo, bp, suboptlen, ndo->ndo_snapend))
+ goto trunc;
+ break;
default:
- print_unknown_data(bp, "\n\t\t", suboptlen);
+ print_unknown_data(ndo, bp, "\n\t\t", suboptlen);
}
len -= suboptlen;
bp += suboptlen;
- }
- break;
+ }
+ break;
case TAG_CLASSLESS_STATIC_RT:
case TAG_CLASSLESS_STA_RT_MS:
- {
+ {
u_int mask_width, significant_octets, i;
/* this option should be at least 5 bytes long */
- if (len < 5) {
- printf("ERROR: option %u len %u < 5 bytes",
- TAG_CLASSLESS_STATIC_RT, len);
+ if (len < 5) {
+ ND_PRINT((ndo, "ERROR: length < 5 bytes"));
bp += len;
len = 0;
break;
}
while (len > 0) {
if (!first)
- putchar(',');
+ ND_PRINT((ndo, ","));
mask_width = *bp++;
len--;
/* mask_width <= 32 */
if (mask_width > 32) {
- printf("[ERROR: Mask width (%d) > 32]", mask_width);
+ ND_PRINT((ndo, "[ERROR: Mask width (%d) > 32]", mask_width));
bp += len;
len = 0;
break;
@@ -731,36 +957,78 @@ rfc1048_print(register const u_char *bp)
significant_octets = (mask_width + 7) / 8;
/* significant octets + router(4) */
if (len < significant_octets + 4) {
- printf("[ERROR: Remaining length (%u) < %u bytes]", len, significant_octets + 4);
+ ND_PRINT((ndo, "[ERROR: Remaining length (%u) < %u bytes]", len, significant_octets + 4));
bp += len;
len = 0;
break;
}
- putchar('(');
+ ND_PRINT((ndo, "("));
if (mask_width == 0)
- printf("default");
+ ND_PRINT((ndo, "default"));
else {
for (i = 0; i < significant_octets ; i++) {
if (i > 0)
- putchar('.');
- printf("%d", *bp++);
+ ND_PRINT((ndo, "."));
+ ND_PRINT((ndo, "%d", *bp++));
}
for (i = significant_octets ; i < 4 ; i++)
- printf(".0");
- printf("/%d", mask_width);
+ ND_PRINT((ndo, ".0"));
+ ND_PRINT((ndo, "/%d", mask_width));
}
memcpy((char *)&ul, (const char *)bp, sizeof(ul));
- printf(":%s)", ipaddr_string(&ul));
+ ND_PRINT((ndo, ":%s)", ipaddr_string(ndo, &ul)));
bp += sizeof(ul);
len -= (significant_octets + 4);
first = 0;
}
- }
- break;
+ break;
+ }
+
+ case TAG_USER_CLASS:
+ {
+ u_int suboptnumber = 1;
+
+ first = 1;
+ if (len < 2) {
+ ND_PRINT((ndo, "ERROR: length < 2 bytes"));
+ bp += len;
+ len = 0;
+ break;
+ }
+ while (len > 0) {
+ suboptlen = *bp++;
+ len--;
+ ND_PRINT((ndo, "\n\t "));
+ ND_PRINT((ndo, "instance#%u: ", suboptnumber));
+ if (suboptlen == 0) {
+ ND_PRINT((ndo, "ERROR: suboption length must be non-zero"));
+ bp += len;
+ len = 0;
+ break;
+ }
+ if (len < suboptlen) {
+ ND_PRINT((ndo, "ERROR: invalid option"));
+ bp += len;
+ len = 0;
+ break;
+ }
+ ND_PRINT((ndo, "\""));
+ if (fn_printn(ndo, bp, suboptlen, ndo->ndo_snapend)) {
+ ND_PRINT((ndo, "\""));
+ goto trunc;
+ }
+ ND_PRINT((ndo, "\""));
+ ND_PRINT((ndo, ", length %d", suboptlen));
+ suboptnumber++;
+ len -= suboptlen;
+ bp += suboptlen;
+ }
+ break;
+ }
default:
- printf("[unknown special tag %u, size %u]",
- tag, len);
+ ND_PRINT((ndo, "[unknown special tag %u, size %u]",
+ tag, len));
bp += len;
len = 0;
break;
@@ -769,31 +1037,32 @@ rfc1048_print(register const u_char *bp)
}
/* Data left over? */
if (len) {
- printf("\n\t trailing data length %u", len);
+ ND_PRINT((ndo, "\n\t trailing data length %u", len));
bp += len;
}
}
return;
trunc:
- printf("|[rfc1048]");
+ ND_PRINT((ndo, "|[rfc1048]"));
}
static void
-cmu_print(register const u_char *bp)
+cmu_print(netdissect_options *ndo,
+ register const u_char *bp)
{
register const struct cmu_vend *cmu;
-#define PRINTCMUADDR(m, s) { TCHECK(cmu->m); \
+#define PRINTCMUADDR(m, s) { ND_TCHECK(cmu->m); \
if (cmu->m.s_addr != 0) \
- printf(" %s:%s", s, ipaddr_string(&cmu->m.s_addr)); }
+ ND_PRINT((ndo, " %s:%s", s, ipaddr_string(ndo, &cmu->m.s_addr))); }
- printf(" vend-cmu");
+ ND_PRINT((ndo, " vend-cmu"));
cmu = (const struct cmu_vend *)bp;
/* Only print if there are unknown bits */
- TCHECK(cmu->v_flags);
+ ND_TCHECK(cmu->v_flags);
if ((cmu->v_flags & ~(VF_SMASK)) != 0)
- printf(" F:0x%x", cmu->v_flags);
+ ND_PRINT((ndo, " F:0x%x", cmu->v_flags));
PRINTCMUADDR(v_dgate, "DG");
PRINTCMUADDR(v_smask, cmu->v_flags & VF_SMASK ? "SM" : "SM*");
PRINTCMUADDR(v_dns1, "NS1");
@@ -805,7 +1074,7 @@ cmu_print(register const u_char *bp)
return;
trunc:
- fputs(tstr, stdout);
+ ND_PRINT((ndo, "%s", tstr));
#undef PRINTCMUADDR
}
@@ -827,3 +1096,6 @@ client_fqdn_flags(u_int flags)
return buf;
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-bootp-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-bt.c b/freebsd/contrib/tcpdump/print-bt.c
index 3fdee7aa..b3c76699 100644
--- a/freebsd/contrib/tcpdump/print-bt.c
+++ b/freebsd/contrib/tcpdump/print-bt.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 2007
* paolo.abeni@email.it All rights reserved.
@@ -11,32 +14,24 @@
* this paragraph in its entirety in the documentation or other materials
* provided with the distribution, and (3) all advertising materials mentioning
* features or use of this software display the following acknowledgement:
- * ``This product includes software developed by Paolo Abeni.''
- * The name of author may not be used to endorse or promote products derived
+ * ``This product includes software developed by Paolo Abeni.''
+ * The name of author may not be used to endorse or promote products derived
* from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-bt.c,v 1.2 2008-09-25 21:45:50 guy Exp $";
-#endif
+/* \summary: Bluetooth printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
-
-#include <pcap.h>
-#include <stdio.h>
-#include <string.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
-#include "addrtoname.h"
#if defined(DLT_BLUETOOTH_HCI_H4_WITH_PHDR) && defined(HAVE_PCAP_BLUETOOTH_H)
#include <pcap/bluetooth.h>
@@ -49,24 +44,24 @@ static const char rcsid[] _U_ =
* is the number of bytes actually captured.
*/
u_int
-bt_if_print(const struct pcap_pkthdr *h, const u_char *p)
+bt_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
{
u_int length = h->len;
u_int caplen = h->caplen;
const pcap_bluetooth_h4_header* hdr = (const pcap_bluetooth_h4_header*)p;
if (caplen < BT_HDRLEN) {
- printf("[|bt]");
+ ND_PRINT((ndo, "[|bt]"));
return (BT_HDRLEN);
}
caplen -= BT_HDRLEN;
length -= BT_HDRLEN;
p += BT_HDRLEN;
- if (eflag)
- (void)printf("hci length %d, direction %s, ", length, (EXTRACT_32BITS(&hdr->direction)&0x1)?"in":"out");
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, "hci length %d, direction %s, ", length, (EXTRACT_32BITS(&hdr->direction)&0x1)?"in":"out"));
- if (!suppress_default_print)
- default_print(p, caplen);
+ if (!ndo->ndo_suppress_default_print)
+ ND_DEFAULTPRINT(p, caplen);
return (BT_HDRLEN);
}
@@ -79,3 +74,6 @@ bt_if_print(const struct pcap_pkthdr *h, const u_char *p)
* c-basic-offset: 8
* End:
*/
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-bt-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-calm-fast.c b/freebsd/contrib/tcpdump/print-calm-fast.c
new file mode 100644
index 00000000..cbd38d94
--- /dev/null
+++ b/freebsd/contrib/tcpdump/print-calm-fast.c
@@ -0,0 +1,83 @@
+#include <machine/rtems-bsd-user-space.h>
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
+/*
+ * Copyright (c) 2013 The TCPDUMP project
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code
+ * distributions retain the above copyright notice and this paragraph
+ * in its entirety, and (2) distributions including binary code include
+ * the above copyright notice and this paragraph in its entirety in
+ * the documentation or other materials provided with the distribution.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND
+ * WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
+ * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE.
+ *
+ * Original code by Ola Martin Lykkja (ola.lykkja@q-free.com)
+ */
+
+/* \summary: Communication access for land mobiles (CALM) printer */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <netdissect-stdinc.h>
+
+#include "netdissect.h"
+#include "addrtoname.h"
+
+/*
+ ISO 29281:2009
+ Intelligent Transport Systems . Communications access for land mobiles (CALM)
+ CALM non-IP networking
+*/
+
+/*
+ * This is the top level routine of the printer. 'bp' points
+ * to the calm header of the packet.
+ */
+void
+calm_fast_print(netdissect_options *ndo, const u_char *bp, u_int length, const struct lladdr_info *src)
+{
+ int srcNwref;
+ int dstNwref;
+
+ ND_TCHECK2(*bp, 2);
+ if (length < 2)
+ goto trunc;
+ srcNwref = bp[0];
+ dstNwref = bp[1];
+ length -= 2;
+ bp += 2;
+
+ ND_PRINT((ndo, "CALM FAST"));
+ if (src != NULL)
+ ND_PRINT((ndo, " src:%s", (src->addr_string)(ndo, src->addr)));
+ ND_PRINT((ndo, "; "));
+ ND_PRINT((ndo, "SrcNwref:%d; ", srcNwref));
+ ND_PRINT((ndo, "DstNwref:%d; ", dstNwref));
+
+ if (ndo->ndo_vflag)
+ ND_DEFAULTPRINT(bp, length);
+ return;
+
+trunc:
+ ND_PRINT((ndo, "[|calm fast]"));
+ return;
+}
+
+
+/*
+ * Local Variables:
+ * c-style: whitesmith
+ * c-basic-offset: 8
+ * End:
+ */
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-calm-fast-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-carp.c b/freebsd/contrib/tcpdump/print-carp.c
index e58c4c85..215e2319 100644
--- a/freebsd/contrib/tcpdump/print-carp.c
+++ b/freebsd/contrib/tcpdump/print-carp.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/* $OpenBSD: print-carp.c,v 1.6 2009/10/27 23:59:55 deraadt Exp $ */
/*
@@ -36,55 +39,53 @@
*
*/
+/* \summary: Common Address Redundancy Protocol (CARP) printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-#include <netinet/in.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h" /* for checksum structure and functions */
#include "extract.h"
-#include "addrtoname.h"
void
-carp_print(register const u_char *bp, register u_int len, int ttl)
+carp_print(netdissect_options *ndo, register const u_char *bp, register u_int len, int ttl)
{
int version, type;
const char *type_s;
- TCHECK(bp[0]);
+ ND_TCHECK(bp[0]);
version = (bp[0] & 0xf0) >> 4;
type = bp[0] & 0x0f;
if (type == 1)
type_s = "advertise";
else
type_s = "unknown";
- printf("CARPv%d-%s %d: ", version, type_s, len);
+ ND_PRINT((ndo, "CARPv%d-%s %d: ", version, type_s, len));
if (ttl != 255)
- printf("[ttl=%d!] ", ttl);
+ ND_PRINT((ndo, "[ttl=%d!] ", ttl));
if (version != 2 || type != 1)
return;
- TCHECK(bp[2]);
- TCHECK(bp[5]);
- printf("vhid=%d advbase=%d advskew=%d authlen=%d ",
- bp[1], bp[5], bp[2], bp[3]);
- if (vflag) {
+ ND_TCHECK(bp[2]);
+ ND_TCHECK(bp[5]);
+ ND_PRINT((ndo, "vhid=%d advbase=%d advskew=%d authlen=%d ",
+ bp[1], bp[5], bp[2], bp[3]));
+ if (ndo->ndo_vflag) {
struct cksum_vec vec[1];
- vec[0].ptr = (const u_int8_t *)bp;
+ vec[0].ptr = (const uint8_t *)bp;
vec[0].len = len;
- if (TTEST2(bp[0], len) && in_cksum(vec, 1))
- printf(" (bad carp cksum %x!)",
- EXTRACT_16BITS(&bp[6]));
+ if (ND_TTEST2(bp[0], len) && in_cksum(vec, 1))
+ ND_PRINT((ndo, " (bad carp cksum %x!)",
+ EXTRACT_16BITS(&bp[6])));
}
- printf("counter=%" PRIu64, EXTRACT_64BITS(&bp[8]));
+ ND_PRINT((ndo, "counter=%" PRIu64, EXTRACT_64BITS(&bp[8])));
return;
trunc:
- printf("[|carp]");
+ ND_PRINT((ndo, "[|carp]"));
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-carp-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-cdp.c b/freebsd/contrib/tcpdump/print-cdp.c
index 3370cdb5..8372e9d0 100644
--- a/freebsd/contrib/tcpdump/print-cdp.c
+++ b/freebsd/contrib/tcpdump/print-cdp.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1992, 1993, 1994, 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
@@ -26,28 +29,33 @@
* http://www.cisco.com/univercd/cc/td/doc/product/lan/trsrb/frames.htm
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-cdp.c,v 1.25 2004-10-07 14:53:11 hannes Exp $";
-#endif
+/* \summary: Cisco Discovery Protocol (CDP) printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include <stdio.h>
#include <string.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
-#include "extract.h" /* must come after interface.h */
+#include "extract.h"
#include "nlpid.h"
-#define CDP_HEADER_LEN 4
+static const char tstr[] = "[|cdp]";
+
+#define CDP_HEADER_LEN 4
+#define CDP_HEADER_VERSION_OFFSET 0
+#define CDP_HEADER_TTL_OFFSET 1
+#define CDP_HEADER_CHECKSUM_OFFSET 2
-static struct tok cdp_tlv_values[] = {
+#define CDP_TLV_HEADER_LEN 4
+#define CDP_TLV_TYPE_OFFSET 0
+#define CDP_TLV_LEN_OFFSET 2
+
+static const struct tok cdp_tlv_values[] = {
{ 0x01, "Device-ID"},
{ 0x02, "Address"},
{ 0x03, "Port-ID"},
@@ -72,7 +80,7 @@ static struct tok cdp_tlv_values[] = {
{ 0, NULL}
};
-static struct tok cdp_capability_values[] = {
+static const struct tok cdp_capability_values[] = {
{ 0x01, "Router" },
{ 0x02, "Transparent Bridge" },
{ 0x04, "Source Route Bridge" },
@@ -83,158 +91,182 @@ static struct tok cdp_capability_values[] = {
{ 0, NULL }
};
-static int cdp_print_addr(const u_char *, int);
-static int cdp_print_prefixes(const u_char *, int);
+static int cdp_print_addr(netdissect_options *, const u_char *, int);
+static int cdp_print_prefixes(netdissect_options *, const u_char *, int);
static unsigned long cdp_get_number(const u_char *, int);
void
-cdp_print(const u_char *pptr, u_int length, u_int caplen)
+cdp_print(netdissect_options *ndo,
+ const u_char *pptr, u_int length, u_int caplen)
{
int type, len, i, j;
- const u_char *tptr;
+ const u_char *tptr;
if (caplen < CDP_HEADER_LEN) {
- (void)printf("[|cdp]");
+ ND_PRINT((ndo, "%s", tstr));
return;
}
- tptr = pptr; /* temporary pointer */
+ tptr = pptr; /* temporary pointer */
- if (!TTEST2(*tptr, CDP_HEADER_LEN))
- goto trunc;
- printf("CDPv%u, ttl: %us", *tptr, *(tptr+1));
- if (vflag)
- printf(", checksum: %u (unverified), length %u", EXTRACT_16BITS(tptr), length);
+ ND_TCHECK2(*tptr, CDP_HEADER_LEN);
+ ND_PRINT((ndo, "CDPv%u, ttl: %us", *(tptr + CDP_HEADER_VERSION_OFFSET),
+ *(tptr + CDP_HEADER_TTL_OFFSET)));
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo, ", checksum: 0x%04x (unverified), length %u", EXTRACT_16BITS(tptr+CDP_HEADER_CHECKSUM_OFFSET), length));
tptr += CDP_HEADER_LEN;
while (tptr < (pptr+length)) {
+ ND_TCHECK2(*tptr, CDP_TLV_HEADER_LEN); /* read out Type and Length */
+ type = EXTRACT_16BITS(tptr+CDP_TLV_TYPE_OFFSET);
+ len = EXTRACT_16BITS(tptr+CDP_TLV_LEN_OFFSET); /* object length includes the 4 bytes header length */
+ if (len < CDP_TLV_HEADER_LEN) {
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo, "\n\t%s (0x%02x), TLV length: %u byte%s (too short)",
+ tok2str(cdp_tlv_values,"unknown field type", type),
+ type,
+ len,
+ PLURAL_SUFFIX(len))); /* plural */
+ else
+ ND_PRINT((ndo, ", %s TLV length %u too short",
+ tok2str(cdp_tlv_values,"unknown field type", type),
+ len));
+ break;
+ }
+ tptr += CDP_TLV_HEADER_LEN;
+ len -= CDP_TLV_HEADER_LEN;
- if (!TTEST2(*tptr, 4)) /* read out Type and Length */
- goto trunc;
- type = EXTRACT_16BITS(tptr);
- len = EXTRACT_16BITS(tptr+2); /* object length includes the 4 bytes header length */
- tptr += 4;
- len -= 4;
-
- if (!TTEST2(*tptr, len))
- goto trunc;
+ ND_TCHECK2(*tptr, len);
- if (vflag || type == 1) { /* in non-verbose mode just print Device-ID */
+ if (ndo->ndo_vflag || type == 1) { /* in non-verbose mode just print Device-ID */
- if (vflag)
- printf("\n\t%s (0x%02x), length: %u byte%s: ",
- tok2str(cdp_tlv_values,"unknown field type", type),
- type,
- len,
- PLURAL_SUFFIX(len)); /* plural */
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo, "\n\t%s (0x%02x), value length: %u byte%s: ",
+ tok2str(cdp_tlv_values,"unknown field type", type),
+ type,
+ len,
+ PLURAL_SUFFIX(len))); /* plural */
- switch (type) {
+ switch (type) {
- case 0x01: /* Device-ID */
- if (!vflag)
- printf(", Device-ID ");
- printf("'");
- fn_printn(tptr, len, NULL);
- printf("'");
+ case 0x01: /* Device-ID */
+ if (!ndo->ndo_vflag)
+ ND_PRINT((ndo, ", Device-ID "));
+ ND_PRINT((ndo, "'"));
+ (void)fn_printn(ndo, tptr, len, NULL);
+ ND_PRINT((ndo, "'"));
break;
- case 0x02: /* Address */
- if (cdp_print_addr(tptr, len) < 0)
- goto trunc;
+ case 0x02: /* Address */
+ if (cdp_print_addr(ndo, tptr, len) < 0)
+ goto trunc;
break;
- case 0x03: /* Port-ID */
- printf("'");
- fn_printn(tptr, len, NULL);
- printf("'");
+ case 0x03: /* Port-ID */
+ ND_PRINT((ndo, "'"));
+ (void)fn_printn(ndo, tptr, len, NULL);
+ ND_PRINT((ndo, "'"));
break;
- case 0x04: /* Capabilities */
- printf("(0x%08x): %s",
- EXTRACT_32BITS(tptr),
- bittok2str(cdp_capability_values, "none",EXTRACT_32BITS(tptr)));
+ case 0x04: /* Capabilities */
+ if (len < 4)
+ goto trunc;
+ ND_PRINT((ndo, "(0x%08x): %s",
+ EXTRACT_32BITS(tptr),
+ bittok2str(cdp_capability_values, "none", EXTRACT_32BITS(tptr))));
break;
- case 0x05: /* Version */
- printf("\n\t ");
- for (i=0;i<len;i++) {
- j = *(tptr+i);
- putchar(j);
- if (j == 0x0a) /* lets rework the version string to get a nice identation */
- printf("\t ");
- }
+ case 0x05: /* Version */
+ ND_PRINT((ndo, "\n\t "));
+ for (i=0;i<len;i++) {
+ j = *(tptr+i);
+ if (j == '\n') /* lets rework the version string to
+ get a nice indentation */
+ ND_PRINT((ndo, "\n\t "));
+ else
+ fn_print_char(ndo, j);
+ }
break;
- case 0x06: /* Platform */
- printf("'");
- fn_printn(tptr, len, NULL);
- printf("'");
+ case 0x06: /* Platform */
+ ND_PRINT((ndo, "'"));
+ (void)fn_printn(ndo, tptr, len, NULL);
+ ND_PRINT((ndo, "'"));
break;
- case 0x07: /* Prefixes */
- if (cdp_print_prefixes(tptr, len) < 0)
- goto trunc;
+ case 0x07: /* Prefixes */
+ if (cdp_print_prefixes(ndo, tptr, len) < 0)
+ goto trunc;
break;
- case 0x08: /* Protocol Hello Option - not documented */
+ case 0x08: /* Protocol Hello Option - not documented */
break;
- case 0x09: /* VTP Mgmt Domain - not documented */
- printf("'");
- fn_printn(tptr, len, NULL);
- printf("'");
+ case 0x09: /* VTP Mgmt Domain - CDPv2 */
+ ND_PRINT((ndo, "'"));
+ (void)fn_printn(ndo, tptr, len, NULL);
+ ND_PRINT((ndo, "'"));
break;
- case 0x0a: /* Native VLAN ID - not documented */
- printf("%d",EXTRACT_16BITS(tptr));
+ case 0x0a: /* Native VLAN ID - CDPv2 */
+ if (len < 2)
+ goto trunc;
+ ND_PRINT((ndo, "%d", EXTRACT_16BITS(tptr)));
break;
- case 0x0b: /* Duplex - not documented */
- printf("%s", *(tptr) ? "full": "half");
+ case 0x0b: /* Duplex - CDPv2 */
+ if (len < 1)
+ goto trunc;
+ ND_PRINT((ndo, "%s", *(tptr) ? "full": "half"));
break;
- /* http://www.cisco.com/univercd/cc/td/doc/product/voice/ata/atarn/186rn21m.htm
- * plus more details from other sources
- */
- case 0x0e: /* ATA-186 VoIP VLAN request - incomplete doc. */
- printf("app %d, vlan %d",
- *(tptr), EXTRACT_16BITS(tptr+1));
+ /* http://www.cisco.com/c/en/us/td/docs/voice_ip_comm/cata/186/2_12_m/english/release/notes/186rn21m.html
+ * plus more details from other sources
+ */
+ case 0x0e: /* ATA-186 VoIP VLAN request - incomplete doc. */
+ if (len < 3)
+ goto trunc;
+ ND_PRINT((ndo, "app %d, vlan %d", *(tptr), EXTRACT_16BITS(tptr + 1)));
break;
- case 0x10: /* ATA-186 VoIP VLAN assignment - incomplete doc. */
- printf("%1.2fW",
- cdp_get_number(tptr, len)/1000.0 );
+ case 0x10: /* ATA-186 VoIP VLAN assignment - incomplete doc. */
+ ND_PRINT((ndo, "%1.2fW", cdp_get_number(tptr, len) / 1000.0));
break;
- case 0x11: /* MTU - not documented */
- printf("%u bytes", EXTRACT_32BITS(tptr));
+ case 0x11: /* MTU - not documented */
+ if (len < 4)
+ goto trunc;
+ ND_PRINT((ndo, "%u bytes", EXTRACT_32BITS(tptr)));
break;
- case 0x12: /* AVVID trust bitmap - not documented */
- printf("0x%02x", *(tptr) );
+ case 0x12: /* AVVID trust bitmap - not documented */
+ if (len < 1)
+ goto trunc;
+ ND_PRINT((ndo, "0x%02x", *(tptr)));
break;
- case 0x13: /* AVVID untrusted port CoS - not documented */
- printf("0x%02x", *(tptr));
+ case 0x13: /* AVVID untrusted port CoS - not documented */
+ if (len < 1)
+ goto trunc;
+ ND_PRINT((ndo, "0x%02x", *(tptr)));
break;
- case 0x14: /* System Name - not documented */
- printf("'");
- fn_printn(tptr, len, NULL);
- printf("'");
+ case 0x14: /* System Name - not documented */
+ ND_PRINT((ndo, "'"));
+ (void)fn_printn(ndo, tptr, len, NULL);
+ ND_PRINT((ndo, "'"));
break;
- case 0x16: /* System Object ID - not documented */
- if (cdp_print_addr(tptr, len) < 0)
+ case 0x16: /* System Object ID - not documented */
+ if (cdp_print_addr(ndo, tptr, len) < 0)
goto trunc;
break;
- case 0x17: /* Physical Location - not documented */
- printf("0x%02x", *(tptr));
+ case 0x17: /* Physical Location - not documented */
+ if (len < 1)
+ goto trunc;
+ ND_PRINT((ndo, "0x%02x", *(tptr)));
if (len > 1) {
- printf("/");
- fn_printn(tptr + 1, len - 1, NULL);
- }
- break;
- default:
- print_unknown_data(tptr,"\n\t ",len);
+ ND_PRINT((ndo, "/"));
+ (void)fn_printn(ndo, tptr + 1, len - 1, NULL);
+ }
break;
- }
- }
- /* avoid infinite loop */
- if (len == 0)
+ default:
+ print_unknown_data(ndo, tptr, "\n\t ", len);
break;
+ }
+ }
tptr = tptr+len;
}
- if (vflag < 1)
- printf(", length %u",caplen);
+ if (ndo->ndo_vflag < 1)
+ ND_PRINT((ndo, ", length %u", caplen));
return;
trunc:
- printf("[|cdp]");
+ ND_PRINT((ndo, "%s", tstr));
}
/*
@@ -249,29 +281,30 @@ trunc:
#define PT_IEEE_802_2 2 /* IEEE 802.2 LLC header */
static int
-cdp_print_addr(const u_char * p, int l)
+cdp_print_addr(netdissect_options *ndo,
+ const u_char * p, int l)
{
int pt, pl, al, num;
const u_char *endp = p + l;
-#ifdef INET6
- static u_char prot_ipv6[] = {
+ static const u_char prot_ipv6[] = {
0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00, 0x86, 0xdd
};
-#endif
- TCHECK2(*p, 2);
+ ND_TCHECK2(*p, 4);
+ if (p + 4 > endp)
+ goto trunc;
num = EXTRACT_32BITS(p);
p += 4;
while (p < endp && num >= 0) {
- TCHECK2(*p, 2);
+ ND_TCHECK2(*p, 2);
if (p + 2 > endp)
goto trunc;
pt = p[0]; /* type of "protocol" field */
pl = p[1]; /* length of "protocol" field */
p += 2;
- TCHECK2(p[pl], 2);
+ ND_TCHECK2(p[pl], 2);
if (p + pl + 2 > endp)
goto trunc;
al = EXTRACT_16BITS(&p[pl]); /* address length */
@@ -284,15 +317,12 @@ cdp_print_addr(const u_char * p, int l)
*/
p += 3;
- TCHECK2(*p, 4);
+ ND_TCHECK2(*p, 4);
if (p + 4 > endp)
goto trunc;
- printf("IPv4 (%u) %s",
- num,
- ipaddr_string(p));
+ ND_PRINT((ndo, "IPv4 (%u) %s", num, ipaddr_string(ndo, p)));
p += 4;
}
-#ifdef INET6
else if (pt == PT_IEEE_802_2 && pl == 8 &&
memcmp(p, prot_ipv6, 8) == 0 && al == 16) {
/*
@@ -302,41 +332,38 @@ cdp_print_addr(const u_char * p, int l)
* Ethertype, address length = 16
*/
p += 10;
- TCHECK2(*p, al);
+ ND_TCHECK2(*p, al);
if (p + al > endp)
goto trunc;
- printf("IPv6 (%u) %s",
- num,
- ip6addr_string(p));
+ ND_PRINT((ndo, "IPv6 (%u) %s", num, ip6addr_string(ndo, p)));
p += al;
}
-#endif
else {
/*
* Generic case: just print raw data
*/
- TCHECK2(*p, pl);
+ ND_TCHECK2(*p, pl);
if (p + pl > endp)
goto trunc;
- printf("pt=0x%02x, pl=%d, pb=", *(p - 2), pl);
+ ND_PRINT((ndo, "pt=0x%02x, pl=%d, pb=", *(p - 2), pl));
while (pl-- > 0)
- printf(" %02x", *p++);
- TCHECK2(*p, 2);
+ ND_PRINT((ndo, " %02x", *p++));
+ ND_TCHECK2(*p, 2);
if (p + 2 > endp)
goto trunc;
al = (*p << 8) + *(p + 1);
- printf(", al=%d, a=", al);
+ ND_PRINT((ndo, ", al=%d, a=", al));
p += 2;
- TCHECK2(*p, al);
+ ND_TCHECK2(*p, al);
if (p + al > endp)
goto trunc;
while (al-- > 0)
- printf(" %02x", *p++);
+ ND_PRINT((ndo, " %02x", *p++));
}
num--;
if (num)
- printf(" ");
+ ND_PRINT((ndo, " "));
}
return 0;
@@ -347,15 +374,16 @@ trunc:
static int
-cdp_print_prefixes(const u_char * p, int l)
+cdp_print_prefixes(netdissect_options *ndo,
+ const u_char * p, int l)
{
if (l % 5)
goto trunc;
- printf(" IPv4 Prefixes (%d):", l / 5);
+ ND_PRINT((ndo, " IPv4 Prefixes (%d):", l / 5));
while (l > 0) {
- printf(" %u.%u.%u.%u/%u", p[0], p[1], p[2], p[3], p[4]);
+ ND_PRINT((ndo, " %u.%u.%u.%u/%u", p[0], p[1], p[2], p[3], p[4]));
l -= 5;
p += 5;
}
@@ -379,3 +407,6 @@ static unsigned long cdp_get_number(const u_char * p, int l)
}
return res;
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-cdp-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-cfm.c b/freebsd/contrib/tcpdump/print-cfm.c
index 4db453a4..2b10786d 100644
--- a/freebsd/contrib/tcpdump/print-cfm.c
+++ b/freebsd/contrib/tcpdump/print-cfm.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1998-2006 The TCPDUMP project
*
@@ -14,44 +17,31 @@
* LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE.
*
- * Support for the IEEE Connectivity Fault Management Protocols as per 802.1ag.
- *
* Original code by Hannes Gredler (hannes@juniper.net)
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-cfm.c,v 1.5 2007-07-24 16:01:42 hannes Exp $";
-#endif
+/* \summary: IEEE 802.1ag Connectivity Fault Management (CFM) protocols printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
#include "ether.h"
#include "addrtoname.h"
#include "oui.h"
#include "af.h"
-/*
- * Prototypes
- */
-const char * cfm_egress_id_string(register const u_char *);
-int cfm_mgmt_addr_print(register const u_char *);
-
struct cfm_common_header_t {
- u_int8_t mdlevel_version;
- u_int8_t opcode;
- u_int8_t flags;
- u_int8_t first_tlv_offset;
+ uint8_t mdlevel_version;
+ uint8_t opcode;
+ uint8_t flags;
+ uint8_t first_tlv_offset;
};
#define CFM_VERSION 0
@@ -77,20 +67,17 @@ static const struct tok cfm_opcode_values[] = {
* Message Formats.
*/
struct cfm_ccm_t {
- u_int8_t sequence[4];
- u_int8_t ma_epi[2];
- u_int8_t md_nameformat;
- u_int8_t md_namelength;
- u_int8_t md_name[46]; /* md name and short ma name */
- u_int8_t reserved_itu[16];
- u_int8_t reserved[6];
+ uint8_t sequence[4];
+ uint8_t ma_epi[2];
+ uint8_t names[48];
+ uint8_t itu_t_y_1731[16];
};
/*
* Timer Bases for the CCM Interval field.
* Expressed in units of seconds.
*/
-const float ccm_interval_base[8] = {0, 0.003333, 0.01, 0.1, 1, 10, 60, 600};
+static const float ccm_interval_base[8] = {0, 0.003333, 0.01, 0.1, 1, 10, 60, 600};
#define CCM_INTERVAL_MIN_MULTIPLIER 3.25
#define CCM_INTERVAL_MAX_MULTIPLIER 3.5
@@ -128,17 +115,14 @@ static const struct tok cfm_ma_nameformat_values[] = {
};
struct cfm_lbm_t {
- u_int8_t transaction_id[4];
- u_int8_t reserved[4];
+ uint8_t transaction_id[4];
};
struct cfm_ltm_t {
- u_int8_t transaction_id[4];
- u_int8_t egress_id[8];
- u_int8_t ttl;
- u_int8_t original_mac[ETHER_ADDR_LEN];
- u_int8_t target_mac[ETHER_ADDR_LEN];
- u_int8_t reserved[3];
+ uint8_t transaction_id[4];
+ uint8_t ttl;
+ uint8_t original_mac[ETHER_ADDR_LEN];
+ uint8_t target_mac[ETHER_ADDR_LEN];
};
static const struct tok cfm_ltm_flag_values[] = {
@@ -147,17 +131,15 @@ static const struct tok cfm_ltm_flag_values[] = {
};
struct cfm_ltr_t {
- u_int8_t transaction_id[4];
- u_int8_t last_egress_id[8];
- u_int8_t next_egress_id[8];
- u_int8_t ttl;
- u_int8_t replay_action;
- u_int8_t reserved[6];
+ uint8_t transaction_id[4];
+ uint8_t ttl;
+ uint8_t replay_action;
};
static const struct tok cfm_ltr_flag_values[] = {
- { 0x80, "Forwarded"},
- { 0x40, "Terminal MEP"},
+ { 0x80, "UseFDB Only"},
+ { 0x40, "FwdYes"},
+ { 0x20, "Terminal MEP"},
{ 0, NULL}
};
@@ -195,8 +177,8 @@ static const struct tok cfm_tlv_values[] = {
*/
struct cfm_tlv_header_t {
- u_int8_t type;
- u_int8_t length[2];
+ uint8_t type;
+ uint8_t length[2];
};
/* FIXME define TLV formats */
@@ -238,10 +220,11 @@ static const struct tok cfm_tlv_senderid_chassisid_values[] = {
};
-int
-cfm_mgmt_addr_print(register const u_char *tptr) {
-
- u_int mgmt_addr_type;
+static int
+cfm_network_addr_print(netdissect_options *ndo,
+ register const u_char *tptr)
+{
+ u_int network_addr_type;
u_int hexdump = FALSE;
/*
@@ -249,24 +232,22 @@ cfm_mgmt_addr_print(register const u_char *tptr) {
* 802.1ab specifies that this field width
* is only once octet
*/
- mgmt_addr_type = *tptr;
- printf("\n\t Management Address Type %s (%u)",
- tok2str(af_values, "Unknown", mgmt_addr_type),
- mgmt_addr_type);
+ network_addr_type = *tptr;
+ ND_PRINT((ndo, "\n\t Network Address Type %s (%u)",
+ tok2str(af_values, "Unknown", network_addr_type),
+ network_addr_type));
/*
* Resolve the passed in Address.
*/
- switch(mgmt_addr_type) {
+ switch(network_addr_type) {
case AFNUM_INET:
- printf(", %s", ipaddr_string(tptr + 1));
+ ND_PRINT((ndo, ", %s", ipaddr_string(ndo, tptr + 1)));
break;
-#ifdef INET6
case AFNUM_INET6:
- printf(", %s", ip6addr_string(tptr + 1));
+ ND_PRINT((ndo, ", %s", ip6addr_string(ndo, tptr + 1)));
break;
-#endif
default:
hexdump = TRUE;
@@ -276,27 +257,19 @@ cfm_mgmt_addr_print(register const u_char *tptr) {
return hexdump;
}
-/*
- * The egress-ID string is a 16-Bit string plus a MAC address.
- */
-const char *
-cfm_egress_id_string(register const u_char *tptr) {
- static char egress_id_buffer[80];
-
- snprintf(egress_id_buffer, sizeof(egress_id_buffer),
- "MAC %0x4x-%s",
- EXTRACT_16BITS(tptr),
- etheraddr_string(tptr+2));
-
- return egress_id_buffer;
-}
-
void
-cfm_print(register const u_char *pptr, register u_int length) {
-
+cfm_print(netdissect_options *ndo,
+ register const u_char *pptr, register u_int length)
+{
const struct cfm_common_header_t *cfm_common_header;
const struct cfm_tlv_header_t *cfm_tlv_header;
- const u_int8_t *tptr, *tlv_ptr, *ma_name, *ma_nameformat, *ma_namelength;
+ const uint8_t *tptr, *tlv_ptr;
+ const uint8_t *namesp;
+ u_int names_data_remaining;
+ uint8_t md_nameformat, md_namelength;
+ const uint8_t *md_name;
+ uint8_t ma_nameformat, ma_namelength;
+ const uint8_t *ma_name;
u_int hexdump, tlen, cfm_tlv_len, cfm_tlv_type, ccm_interval;
@@ -309,109 +282,161 @@ cfm_print(register const u_char *pptr, register u_int length) {
tptr=pptr;
cfm_common_header = (const struct cfm_common_header_t *)pptr;
- TCHECK(*cfm_common_header);
+ if (length < sizeof(*cfm_common_header))
+ goto tooshort;
+ ND_TCHECK(*cfm_common_header);
/*
* Sanity checking of the header.
*/
if (CFM_EXTRACT_VERSION(cfm_common_header->mdlevel_version) != CFM_VERSION) {
- printf("CFMv%u not supported, length %u",
- CFM_EXTRACT_VERSION(cfm_common_header->mdlevel_version), length);
+ ND_PRINT((ndo, "CFMv%u not supported, length %u",
+ CFM_EXTRACT_VERSION(cfm_common_header->mdlevel_version), length));
return;
}
- printf("CFMv%u %s, MD Level %u, length %u",
+ ND_PRINT((ndo, "CFMv%u %s, MD Level %u, length %u",
CFM_EXTRACT_VERSION(cfm_common_header->mdlevel_version),
tok2str(cfm_opcode_values, "unknown (%u)", cfm_common_header->opcode),
CFM_EXTRACT_MD_LEVEL(cfm_common_header->mdlevel_version),
- length);
+ length));
/*
* In non-verbose mode just print the opcode and md-level.
*/
- if (vflag < 1) {
+ if (ndo->ndo_vflag < 1) {
return;
}
- printf("\n\tFirst TLV offset %u", cfm_common_header->first_tlv_offset);
+ ND_PRINT((ndo, "\n\tFirst TLV offset %u", cfm_common_header->first_tlv_offset));
tptr += sizeof(const struct cfm_common_header_t);
tlen = length - sizeof(struct cfm_common_header_t);
+ /*
+ * Sanity check the first TLV offset.
+ */
+ if (cfm_common_header->first_tlv_offset > tlen) {
+ ND_PRINT((ndo, " (too large, must be <= %u)", tlen));
+ return;
+ }
+
switch (cfm_common_header->opcode) {
case CFM_OPCODE_CCM:
msg_ptr.cfm_ccm = (const struct cfm_ccm_t *)tptr;
+ if (cfm_common_header->first_tlv_offset < sizeof(*msg_ptr.cfm_ccm)) {
+ ND_PRINT((ndo, " (too small 1, must be >= %lu)",
+ (unsigned long) sizeof(*msg_ptr.cfm_ccm)));
+ return;
+ }
+ if (tlen < sizeof(*msg_ptr.cfm_ccm))
+ goto tooshort;
+ ND_TCHECK(*msg_ptr.cfm_ccm);
ccm_interval = CFM_EXTRACT_CCM_INTERVAL(cfm_common_header->flags);
- printf(", Flags [CCM Interval %u%s]",
+ ND_PRINT((ndo, ", Flags [CCM Interval %u%s]",
ccm_interval,
cfm_common_header->flags & CFM_CCM_RDI_FLAG ?
- ", RDI" : "");
+ ", RDI" : ""));
/*
* Resolve the CCM interval field.
*/
if (ccm_interval) {
- printf("\n\t CCM Interval %.3fs"
+ ND_PRINT((ndo, "\n\t CCM Interval %.3fs"
", min CCM Lifetime %.3fs, max CCM Lifetime %.3fs",
ccm_interval_base[ccm_interval],
ccm_interval_base[ccm_interval] * CCM_INTERVAL_MIN_MULTIPLIER,
- ccm_interval_base[ccm_interval] * CCM_INTERVAL_MAX_MULTIPLIER);
+ ccm_interval_base[ccm_interval] * CCM_INTERVAL_MAX_MULTIPLIER));
}
- printf("\n\t Sequence Number 0x%08x, MA-End-Point-ID 0x%04x",
+ ND_PRINT((ndo, "\n\t Sequence Number 0x%08x, MA-End-Point-ID 0x%04x",
EXTRACT_32BITS(msg_ptr.cfm_ccm->sequence),
- EXTRACT_16BITS(msg_ptr.cfm_ccm->ma_epi));
+ EXTRACT_16BITS(msg_ptr.cfm_ccm->ma_epi)));
+ namesp = msg_ptr.cfm_ccm->names;
+ names_data_remaining = sizeof(msg_ptr.cfm_ccm->names);
/*
* Resolve the MD fields.
*/
- printf("\n\t MD Name Format %s (%u), MD Name length %u",
- tok2str(cfm_md_nameformat_values, "Unknown",
- msg_ptr.cfm_ccm->md_nameformat),
- msg_ptr.cfm_ccm->md_nameformat,
- msg_ptr.cfm_ccm->md_namelength);
-
- if (msg_ptr.cfm_ccm->md_nameformat != CFM_CCM_MD_FORMAT_NONE) {
- printf("\n\t MD Name: ");
- switch (msg_ptr.cfm_ccm->md_nameformat) {
+ md_nameformat = *namesp;
+ namesp++;
+ names_data_remaining--; /* We know this is != 0 */
+ if (md_nameformat != CFM_CCM_MD_FORMAT_NONE) {
+ md_namelength = *namesp;
+ namesp++;
+ names_data_remaining--; /* We know this is !=0 */
+ ND_PRINT((ndo, "\n\t MD Name Format %s (%u), MD Name length %u",
+ tok2str(cfm_md_nameformat_values, "Unknown",
+ md_nameformat),
+ md_nameformat,
+ md_namelength));
+
+ /* -2 for the MA short name format and length */
+ if (md_namelength > names_data_remaining - 2) {
+ ND_PRINT((ndo, " (too large, must be <= %u)", names_data_remaining - 2));
+ return;
+ }
+
+ md_name = namesp;
+ ND_PRINT((ndo, "\n\t MD Name: "));
+ switch (md_nameformat) {
case CFM_CCM_MD_FORMAT_DNS:
case CFM_CCM_MD_FORMAT_CHAR:
- safeputs((const char *)msg_ptr.cfm_ccm->md_name, msg_ptr.cfm_ccm->md_namelength);
+ safeputs(ndo, md_name, md_namelength);
break;
case CFM_CCM_MD_FORMAT_MAC:
- printf("\n\t MAC %s", etheraddr_string(
- msg_ptr.cfm_ccm->md_name));
+ if (md_namelength == 6) {
+ ND_PRINT((ndo, "\n\t MAC %s", etheraddr_string(ndo,
+ md_name)));
+ } else {
+ ND_PRINT((ndo, "\n\t MAC (length invalid)"));
+ }
break;
/* FIXME add printers for those MD formats - hexdump for now */
case CFM_CCM_MA_FORMAT_8021:
default:
- print_unknown_data(msg_ptr.cfm_ccm->md_name, "\n\t ",
- msg_ptr.cfm_ccm->md_namelength);
+ print_unknown_data(ndo, md_name, "\n\t ",
+ md_namelength);
}
+ namesp += md_namelength;
+ names_data_remaining -= md_namelength;
+ } else {
+ ND_PRINT((ndo, "\n\t MD Name Format %s (%u)",
+ tok2str(cfm_md_nameformat_values, "Unknown",
+ md_nameformat),
+ md_nameformat));
}
/*
* Resolve the MA fields.
*/
- ma_nameformat = msg_ptr.cfm_ccm->md_name + msg_ptr.cfm_ccm->md_namelength;
- ma_namelength = msg_ptr.cfm_ccm->md_name + msg_ptr.cfm_ccm->md_namelength + 1;
- ma_name = msg_ptr.cfm_ccm->md_name + msg_ptr.cfm_ccm->md_namelength + 2;
-
- printf("\n\t MA Name-Format %s (%u), MA name length %u",
+ ma_nameformat = *namesp;
+ namesp++;
+ names_data_remaining--; /* We know this is != 0 */
+ ma_namelength = *namesp;
+ namesp++;
+ names_data_remaining--; /* We know this is != 0 */
+ ND_PRINT((ndo, "\n\t MA Name-Format %s (%u), MA name length %u",
tok2str(cfm_ma_nameformat_values, "Unknown",
- *ma_nameformat),
- *ma_nameformat,
- *ma_namelength);
+ ma_nameformat),
+ ma_nameformat,
+ ma_namelength));
- printf("\n\t MA Name: ");
- switch (*ma_nameformat) {
+ if (ma_namelength > names_data_remaining) {
+ ND_PRINT((ndo, " (too large, must be <= %u)", names_data_remaining));
+ return;
+ }
+
+ ma_name = namesp;
+ ND_PRINT((ndo, "\n\t MA Name: "));
+ switch (ma_nameformat) {
case CFM_CCM_MA_FORMAT_CHAR:
- safeputs((const char *)ma_name, *ma_namelength);
+ safeputs(ndo, ma_name, ma_namelength);
break;
/* FIXME add printers for those MA formats - hexdump for now */
@@ -420,45 +445,56 @@ cfm_print(register const u_char *pptr, register u_int length) {
case CFM_CCM_MA_FORMAT_INT:
case CFM_CCM_MA_FORMAT_VPN:
default:
- print_unknown_data(ma_name, "\n\t ", *ma_namelength);
+ print_unknown_data(ndo, ma_name, "\n\t ", ma_namelength);
}
break;
case CFM_OPCODE_LTM:
msg_ptr.cfm_ltm = (const struct cfm_ltm_t *)tptr;
+ if (cfm_common_header->first_tlv_offset < sizeof(*msg_ptr.cfm_ltm)) {
+ ND_PRINT((ndo, " (too small 4, must be >= %lu)",
+ (unsigned long) sizeof(*msg_ptr.cfm_ltm)));
+ return;
+ }
+ if (tlen < sizeof(*msg_ptr.cfm_ltm))
+ goto tooshort;
+ ND_TCHECK(*msg_ptr.cfm_ltm);
- printf(", Flags [%s]",
- bittok2str(cfm_ltm_flag_values, "none", cfm_common_header->flags));
+ ND_PRINT((ndo, ", Flags [%s]",
+ bittok2str(cfm_ltm_flag_values, "none", cfm_common_header->flags)));
- printf("\n\t Transaction-ID 0x%08x, Egress-ID %s, ttl %u",
+ ND_PRINT((ndo, "\n\t Transaction-ID 0x%08x, ttl %u",
EXTRACT_32BITS(msg_ptr.cfm_ltm->transaction_id),
- cfm_egress_id_string(msg_ptr.cfm_ltm->egress_id),
- msg_ptr.cfm_ltm->ttl);
+ msg_ptr.cfm_ltm->ttl));
- printf("\n\t Original-MAC %s, Target-MAC %s",
- etheraddr_string(msg_ptr.cfm_ltm->original_mac),
- etheraddr_string(msg_ptr.cfm_ltm->target_mac));
+ ND_PRINT((ndo, "\n\t Original-MAC %s, Target-MAC %s",
+ etheraddr_string(ndo, msg_ptr.cfm_ltm->original_mac),
+ etheraddr_string(ndo, msg_ptr.cfm_ltm->target_mac)));
break;
case CFM_OPCODE_LTR:
msg_ptr.cfm_ltr = (const struct cfm_ltr_t *)tptr;
+ if (cfm_common_header->first_tlv_offset < sizeof(*msg_ptr.cfm_ltr)) {
+ ND_PRINT((ndo, " (too small 5, must be >= %lu)",
+ (unsigned long) sizeof(*msg_ptr.cfm_ltr)));
+ return;
+ }
+ if (tlen < sizeof(*msg_ptr.cfm_ltr))
+ goto tooshort;
+ ND_TCHECK(*msg_ptr.cfm_ltr);
- printf(", Flags [%s]",
- bittok2str(cfm_ltr_flag_values, "none", cfm_common_header->flags));
+ ND_PRINT((ndo, ", Flags [%s]",
+ bittok2str(cfm_ltr_flag_values, "none", cfm_common_header->flags)));
- printf("\n\t Transaction-ID 0x%08x, Last-Egress-ID %s",
+ ND_PRINT((ndo, "\n\t Transaction-ID 0x%08x, ttl %u",
EXTRACT_32BITS(msg_ptr.cfm_ltr->transaction_id),
- cfm_egress_id_string(msg_ptr.cfm_ltr->last_egress_id));
+ msg_ptr.cfm_ltr->ttl));
- printf("\n\t Next-Egress-ID %s, ttl %u",
- cfm_egress_id_string(msg_ptr.cfm_ltr->next_egress_id),
- msg_ptr.cfm_ltr->ttl);
-
- printf("\n\t Replay-Action %s (%u)",
+ ND_PRINT((ndo, "\n\t Replay-Action %s (%u)",
tok2str(cfm_ltr_replay_action_values,
"Unknown",
msg_ptr.cfm_ltr->replay_action),
- msg_ptr.cfm_ltr->replay_action);
+ msg_ptr.cfm_ltr->replay_action));
break;
/*
@@ -468,83 +504,78 @@ cfm_print(register const u_char *pptr, register u_int length) {
case CFM_OPCODE_LBR:
case CFM_OPCODE_LBM:
default:
- if (tlen > cfm_common_header->first_tlv_offset) {
- print_unknown_data(tptr, "\n\t ",
- tlen - cfm_common_header->first_tlv_offset);
- }
+ print_unknown_data(ndo, tptr, "\n\t ",
+ tlen - cfm_common_header->first_tlv_offset);
break;
}
- /*
- * Sanity check for not walking off.
- */
- if (tlen <= cfm_common_header->first_tlv_offset) {
- return;
- }
-
tptr += cfm_common_header->first_tlv_offset;
tlen -= cfm_common_header->first_tlv_offset;
-
+
while (tlen > 0) {
cfm_tlv_header = (const struct cfm_tlv_header_t *)tptr;
/* Enough to read the tlv type ? */
- TCHECK2(*tptr, 1);
+ ND_TCHECK2(*tptr, 1);
cfm_tlv_type=cfm_tlv_header->type;
- if (cfm_tlv_type != CFM_TLV_END) {
- /* did we capture enough for fully decoding the object header ? */
- TCHECK2(*tptr, sizeof(struct cfm_tlv_header_t));
- cfm_tlv_len=EXTRACT_16BITS(&cfm_tlv_header->length);
- } else {
- cfm_tlv_len = 0;
- }
-
- printf("\n\t%s TLV (0x%02x), length %u",
+ ND_PRINT((ndo, "\n\t%s TLV (0x%02x)",
tok2str(cfm_tlv_values, "Unknown", cfm_tlv_type),
- cfm_tlv_type,
- cfm_tlv_len);
-
- /* sanity check for not walking off and infinite loop check. */
- if ((cfm_tlv_type != CFM_TLV_END) &&
- ((cfm_tlv_len + sizeof(struct cfm_tlv_header_t) > tlen) ||
- (!cfm_tlv_len))) {
- print_unknown_data(tptr,"\n\t ",tlen);
+ cfm_tlv_type));
+
+ if (cfm_tlv_type == CFM_TLV_END) {
+ /* Length is "Not present if the Type field is 0." */
return;
}
+ /* do we have the full tlv header ? */
+ if (tlen < sizeof(struct cfm_tlv_header_t))
+ goto tooshort;
+ ND_TCHECK2(*tptr, sizeof(struct cfm_tlv_header_t));
+ cfm_tlv_len=EXTRACT_16BITS(&cfm_tlv_header->length);
+
+ ND_PRINT((ndo, ", length %u", cfm_tlv_len));
+
tptr += sizeof(struct cfm_tlv_header_t);
tlen -= sizeof(struct cfm_tlv_header_t);
tlv_ptr = tptr;
- /* did we capture enough for fully decoding the object ? */
- if (cfm_tlv_type != CFM_TLV_END) {
- TCHECK2(*tptr, cfm_tlv_len);
- }
+ /* do we have the full tlv ? */
+ if (tlen < cfm_tlv_len)
+ goto tooshort;
+ ND_TCHECK2(*tptr, cfm_tlv_len);
hexdump = FALSE;
switch(cfm_tlv_type) {
- case CFM_TLV_END:
- /* we are done - bail out */
- return;
-
case CFM_TLV_PORT_STATUS:
- printf(", Status: %s (%u)",
+ if (cfm_tlv_len < 1) {
+ ND_PRINT((ndo, " (too short, must be >= 1)"));
+ return;
+ }
+ ND_PRINT((ndo, ", Status: %s (%u)",
tok2str(cfm_tlv_port_status_values, "Unknown", *tptr),
- *tptr);
+ *tptr));
break;
case CFM_TLV_INTERFACE_STATUS:
- printf(", Status: %s (%u)",
+ if (cfm_tlv_len < 1) {
+ ND_PRINT((ndo, " (too short, must be >= 1)"));
+ return;
+ }
+ ND_PRINT((ndo, ", Status: %s (%u)",
tok2str(cfm_tlv_interface_status_values, "Unknown", *tptr),
- *tptr);
+ *tptr));
break;
case CFM_TLV_PRIVATE:
- printf(", Vendor: %s (%u), Sub-Type %u",
+ if (cfm_tlv_len < 4) {
+ ND_PRINT((ndo, " (too short, must be >= 4)"));
+ return;
+ }
+ ND_PRINT((ndo, ", Vendor: %s (%u), Sub-Type %u",
tok2str(oui_values,"Unknown", EXTRACT_24BITS(tptr)),
EXTRACT_24BITS(tptr),
- *(tptr+3));
+ *(tptr + 3)));
hexdump = TRUE;
break;
@@ -553,34 +584,45 @@ cfm_print(register const u_char *pptr, register u_int length) {
u_int chassis_id_type, chassis_id_length;
u_int mgmt_addr_length;
+ if (cfm_tlv_len < 1) {
+ ND_PRINT((ndo, " (too short, must be >= 1)"));
+ return;
+ }
+
/*
- * Check if there is a Chassis-ID.
+ * Get the Chassis ID length and check it.
*/
chassis_id_length = *tptr;
- if (chassis_id_length > tlen) {
- hexdump = TRUE;
- break;
- }
-
tptr++;
tlen--;
+ cfm_tlv_len--;
if (chassis_id_length) {
+ if (cfm_tlv_len < 1) {
+ ND_PRINT((ndo, "\n\t (TLV too short)"));
+ return;
+ }
chassis_id_type = *tptr;
- printf("\n\t Chassis-ID Type %s (%u), Chassis-ID length %u",
+ cfm_tlv_len--;
+ ND_PRINT((ndo, "\n\t Chassis-ID Type %s (%u), Chassis-ID length %u",
tok2str(cfm_tlv_senderid_chassisid_values,
"Unknown",
chassis_id_type),
chassis_id_type,
- chassis_id_length);
+ chassis_id_length));
+
+ if (cfm_tlv_len < chassis_id_length) {
+ ND_PRINT((ndo, "\n\t (TLV too short)"));
+ return;
+ }
switch (chassis_id_type) {
case CFM_CHASSIS_ID_MAC_ADDRESS:
- printf("\n\t MAC %s", etheraddr_string(tptr+1));
+ ND_PRINT((ndo, "\n\t MAC %s", etheraddr_string(ndo, tptr + 1)));
break;
case CFM_CHASSIS_ID_NETWORK_ADDRESS:
- hexdump |= cfm_mgmt_addr_print(tptr);
+ hexdump |= cfm_network_addr_print(ndo, tptr);
break;
case CFM_CHASSIS_ID_INTERFACE_NAME: /* fall through */
@@ -588,39 +630,67 @@ cfm_print(register const u_char *pptr, register u_int length) {
case CFM_CHASSIS_ID_LOCAL:
case CFM_CHASSIS_ID_CHASSIS_COMPONENT:
case CFM_CHASSIS_ID_PORT_COMPONENT:
- safeputs((const char *)tptr+1, chassis_id_length);
+ safeputs(ndo, tptr + 1, chassis_id_length);
break;
default:
hexdump = TRUE;
break;
}
- }
+ cfm_tlv_len -= chassis_id_length;
- tptr += chassis_id_length;
- tlen -= chassis_id_length;
+ tptr += 1 + chassis_id_length;
+ tlen -= 1 + chassis_id_length;
+ }
/*
* Check if there is a Management Address.
*/
- mgmt_addr_length = *tptr;
- if (mgmt_addr_length > tlen) {
- hexdump = TRUE;
- break;
+ if (cfm_tlv_len == 0) {
+ /* No, there isn't; we're done. */
+ return;
}
+ mgmt_addr_length = *tptr;
tptr++;
tlen--;
-
+ cfm_tlv_len--;
if (mgmt_addr_length) {
- hexdump |= cfm_mgmt_addr_print(tptr);
+ if (cfm_tlv_len < mgmt_addr_length) {
+ ND_PRINT((ndo, "\n\t (TLV too short)"));
+ return;
+ }
+ cfm_tlv_len -= mgmt_addr_length;
+ /*
+ * XXX - this is an OID; print it as such.
+ */
+ tptr += mgmt_addr_length;
+ tlen -= mgmt_addr_length;
+
+ if (cfm_tlv_len < 1) {
+ ND_PRINT((ndo, "\n\t (TLV too short)"));
+ return;
+ }
+
+ mgmt_addr_length = *tptr;
+ tptr++;
+ tlen--;
+ cfm_tlv_len--;
+ if (mgmt_addr_length) {
+ if (cfm_tlv_len < mgmt_addr_length) {
+ ND_PRINT((ndo, "\n\t (TLV too short)"));
+ return;
+ }
+ cfm_tlv_len -= mgmt_addr_length;
+ /*
+ * XXX - this is a TransportDomain; print it as such.
+ */
+ tptr += mgmt_addr_length;
+ tlen -= mgmt_addr_length;
+ }
}
-
- tptr += mgmt_addr_length;
- tlen -= mgmt_addr_length;
-
+ break;
}
- break;
/*
* FIXME those are the defined TLVs that lack a decoder
@@ -635,13 +705,21 @@ cfm_print(register const u_char *pptr, register u_int length) {
break;
}
/* do we want to see an additional hexdump ? */
- if (hexdump || vflag > 1)
- print_unknown_data(tlv_ptr, "\n\t ", cfm_tlv_len);
+ if (hexdump || ndo->ndo_vflag > 1)
+ print_unknown_data(ndo, tlv_ptr, "\n\t ", cfm_tlv_len);
tptr+=cfm_tlv_len;
tlen-=cfm_tlv_len;
}
return;
+
+tooshort:
+ ND_PRINT((ndo, "\n\t\t packet is too short"));
+ return;
+
trunc:
- printf("\n\t\t packet exceeded snapshot");
+ ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-cfm-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-chdlc.c b/freebsd/contrib/tcpdump/print-chdlc.c
index 37414cb3..b67ba5fd 100644
--- a/freebsd/contrib/tcpdump/print-chdlc.c
+++ b/freebsd/contrib/tcpdump/print-chdlc.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
@@ -21,30 +24,23 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-chdlc.c,v 1.43 2005-11-29 08:56:19 hannes Exp $ (LBL)";
-#endif
+/* \summary: Cisco HDLC printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
-
-#include <pcap.h>
-#include <stdio.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "ethertype.h"
#include "extract.h"
-#include "ppp.h"
#include "chdlc.h"
-static void chdlc_slarp_print(const u_char *, u_int);
+static void chdlc_slarp_print(netdissect_options *, const u_char *, u_int);
-const struct tok chdlc_cast_values[] = {
+static const struct tok chdlc_cast_values[] = {
{ CHDLC_UNICAST, "unicast" },
{ CHDLC_BCAST, "bcast" },
{ 0, NULL}
@@ -53,29 +49,30 @@ const struct tok chdlc_cast_values[] = {
/* Standard CHDLC printer */
u_int
-chdlc_if_print(const struct pcap_pkthdr *h, register const u_char *p)
+chdlc_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, register const u_char *p)
{
register u_int length = h->len;
register u_int caplen = h->caplen;
if (caplen < CHDLC_HDRLEN) {
- printf("[|chdlc]");
+ ND_PRINT((ndo, "[|chdlc]"));
return (caplen);
}
- return (chdlc_print(p,length));
+ return (chdlc_print(ndo, p,length));
}
u_int
-chdlc_print(register const u_char *p, u_int length) {
+chdlc_print(netdissect_options *ndo, register const u_char *p, u_int length)
+{
u_int proto;
proto = EXTRACT_16BITS(&p[2]);
- if (eflag) {
- printf("%s, ethertype %s (0x%04x), length %u: ",
+ if (ndo->ndo_eflag) {
+ ND_PRINT((ndo, "%s, ethertype %s (0x%04x), length %u: ",
tok2str(chdlc_cast_values, "0x%02x", p[0]),
tok2str(ethertype_values, "Unknown", proto),
proto,
- length);
+ length));
}
length -= CHDLC_HDRLEN;
@@ -83,15 +80,13 @@ chdlc_print(register const u_char *p, u_int length) {
switch (proto) {
case ETHERTYPE_IP:
- ip_print(gndo, p, length);
+ ip_print(ndo, p, length);
break;
-#ifdef INET6
case ETHERTYPE_IPV6:
- ip6_print(gndo, p, length);
+ ip6_print(ndo, p, length);
break;
-#endif
case CHDLC_TYPE_SLARP:
- chdlc_slarp_print(p, length);
+ chdlc_slarp_print(ndo, p, length);
break;
#if 0
case CHDLC_TYPE_CDP:
@@ -100,20 +95,20 @@ chdlc_print(register const u_char *p, u_int length) {
#endif
case ETHERTYPE_MPLS:
case ETHERTYPE_MPLS_MULTI:
- mpls_print(p, length);
+ mpls_print(ndo, p, length);
break;
case ETHERTYPE_ISO:
/* is the fudge byte set ? lets verify by spotting ISO headers */
if (*(p+1) == 0x81 ||
*(p+1) == 0x82 ||
*(p+1) == 0x83)
- isoclns_print(p+1, length-1, length-1);
+ isoclns_print(ndo, p + 1, length - 1, ndo->ndo_snapend - p - 1);
else
- isoclns_print(p, length, length);
+ isoclns_print(ndo, p, length, ndo->ndo_snapend - p);
break;
default:
- if (!eflag)
- printf("unknown CHDLC protocol (0x%04x)", proto);
+ if (!ndo->ndo_eflag)
+ ND_PRINT((ndo, "unknown CHDLC protocol (0x%04x)", proto));
break;
}
@@ -124,19 +119,19 @@ chdlc_print(register const u_char *p, u_int length) {
* The fixed-length portion of a SLARP packet.
*/
struct cisco_slarp {
- u_int8_t code[4];
+ uint8_t code[4];
#define SLARP_REQUEST 0
#define SLARP_REPLY 1
#define SLARP_KEEPALIVE 2
union {
struct {
- u_int8_t addr[4];
- u_int8_t mask[4];
+ uint8_t addr[4];
+ uint8_t mask[4];
} addr;
struct {
- u_int8_t myseq[4];
- u_int8_t yourseq[4];
- u_int8_t rel[2];
+ uint8_t myseq[4];
+ uint8_t yourseq[4];
+ uint8_t rel[2];
} keep;
} un;
};
@@ -145,20 +140,20 @@ struct cisco_slarp {
#define SLARP_MAX_LEN 18
static void
-chdlc_slarp_print(const u_char *cp, u_int length)
+chdlc_slarp_print(netdissect_options *ndo, const u_char *cp, u_int length)
{
const struct cisco_slarp *slarp;
u_int sec,min,hrs,days;
- printf("SLARP (length: %u), ",length);
+ ND_PRINT((ndo, "SLARP (length: %u), ",length));
if (length < SLARP_MIN_LEN)
goto trunc;
slarp = (const struct cisco_slarp *)cp;
- TCHECK2(*slarp, SLARP_MIN_LEN);
+ ND_TCHECK2(*slarp, SLARP_MIN_LEN);
switch (EXTRACT_32BITS(&slarp->code)) {
case SLARP_REQUEST:
- printf("request");
+ ND_PRINT((ndo, "request"));
/*
* At least according to William "Chops" Westfield's
* message in
@@ -170,42 +165,41 @@ chdlc_slarp_print(const u_char *cp, u_int length)
*/
break;
case SLARP_REPLY:
- printf("reply %s/%s",
- ipaddr_string(&slarp->un.addr.addr),
- ipaddr_string(&slarp->un.addr.mask));
+ ND_PRINT((ndo, "reply %s/%s",
+ ipaddr_string(ndo, &slarp->un.addr.addr),
+ ipaddr_string(ndo, &slarp->un.addr.mask)));
break;
case SLARP_KEEPALIVE:
- printf("keepalive: mineseen=0x%08x, yourseen=0x%08x, reliability=0x%04x",
+ ND_PRINT((ndo, "keepalive: mineseen=0x%08x, yourseen=0x%08x, reliability=0x%04x",
EXTRACT_32BITS(&slarp->un.keep.myseq),
EXTRACT_32BITS(&slarp->un.keep.yourseq),
- EXTRACT_16BITS(&slarp->un.keep.rel));
+ EXTRACT_16BITS(&slarp->un.keep.rel)));
if (length >= SLARP_MAX_LEN) { /* uptime-stamp is optional */
cp += SLARP_MIN_LEN;
- if (!TTEST2(*cp, 4))
- goto trunc;
+ ND_TCHECK2(*cp, 4);
sec = EXTRACT_32BITS(cp) / 1000;
min = sec / 60; sec -= min * 60;
hrs = min / 60; min -= hrs * 60;
days = hrs / 24; hrs -= days * 24;
- printf(", link uptime=%ud%uh%um%us",days,hrs,min,sec);
+ ND_PRINT((ndo, ", link uptime=%ud%uh%um%us",days,hrs,min,sec));
}
break;
default:
- printf("0x%02x unknown", EXTRACT_32BITS(&slarp->code));
- if (vflag <= 1)
- print_unknown_data(cp+4,"\n\t",length-4);
+ ND_PRINT((ndo, "0x%02x unknown", EXTRACT_32BITS(&slarp->code)));
+ if (ndo->ndo_vflag <= 1)
+ print_unknown_data(ndo,cp+4,"\n\t",length-4);
break;
}
- if (SLARP_MAX_LEN < length && vflag)
- printf(", (trailing junk: %d bytes)", length - SLARP_MAX_LEN);
- if (vflag > 1)
- print_unknown_data(cp+4,"\n\t",length-4);
+ if (SLARP_MAX_LEN < length && ndo->ndo_vflag)
+ ND_PRINT((ndo, ", (trailing junk: %d bytes)", length - SLARP_MAX_LEN));
+ if (ndo->ndo_vflag > 1)
+ print_unknown_data(ndo,cp+4,"\n\t",length-4);
return;
trunc:
- printf("[|slarp]");
+ ND_PRINT((ndo, "[|slarp]"));
}
@@ -215,3 +209,6 @@ trunc:
* c-basic-offset: 8
* End:
*/
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-chdlc-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-cip.c b/freebsd/contrib/tcpdump/print-cip.c
index 3b9075af..82842ec0 100644
--- a/freebsd/contrib/tcpdump/print-cip.c
+++ b/freebsd/contrib/tcpdump/print-cip.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Marko Kiiskila carnil@cs.tut.fi
*
@@ -22,10 +25,7 @@
*
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-cip.c,v 1.26 2005-07-07 01:22:17 guy Exp $ (LBL)";
-#endif
+/* \summary: Classical-IP over ATM printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -33,19 +33,12 @@ static const char rcsid[] _U_ =
#include <string.h>
-#include <tcpdump-stdinc.h>
-
-#include <stdio.h>
-#include <pcap.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
-#include "ethertype.h"
-#include "ether.h"
-#define RFC1483LLC_LEN 8
-
-static unsigned char rfcllc[] = {
+static const unsigned char rfcllc[] = {
0xaa, /* DSAP: non-ISO */
0xaa, /* SSAP: non-ISO */
0x03, /* Ctrl: Unnumbered Information Command PDU */
@@ -54,12 +47,12 @@ static unsigned char rfcllc[] = {
0x00 };
static inline void
-cip_print(int length)
+cip_print(netdissect_options *ndo, u_int length)
{
/*
* There is no MAC-layer header, so just print the length.
*/
- printf("%d: ", length);
+ ND_PRINT((ndo, "%u: ", length));
}
/*
@@ -69,44 +62,46 @@ cip_print(int length)
* is the number of bytes actually captured.
*/
u_int
-cip_if_print(const struct pcap_pkthdr *h, const u_char *p)
+cip_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
{
u_int caplen = h->caplen;
u_int length = h->len;
- u_short extracted_ethertype;
+ size_t cmplen;
+ int llc_hdrlen;
- if (memcmp(rfcllc, p, sizeof(rfcllc))==0 && caplen < RFC1483LLC_LEN) {
- printf("[|cip]");
- return (0);
- }
+ cmplen = sizeof(rfcllc);
+ if (cmplen > caplen)
+ cmplen = caplen;
+ if (cmplen > length)
+ cmplen = length;
- if (eflag)
- cip_print(length);
+ if (ndo->ndo_eflag)
+ cip_print(ndo, length);
- if (memcmp(rfcllc, p, sizeof(rfcllc)) == 0) {
+ if (cmplen == 0) {
+ ND_PRINT((ndo, "[|cip]"));
+ return 0;
+ }
+ if (memcmp(rfcllc, p, cmplen) == 0) {
/*
* LLC header is present. Try to print it & higher layers.
*/
- if (llc_print(p, length, caplen, NULL, NULL,
- &extracted_ethertype) == 0) {
- /* ether_type not known, print raw packet */
- if (!eflag)
- cip_print(length);
- if (extracted_ethertype) {
- printf("(LLC %s) ",
- etherproto_string(htons(extracted_ethertype)));
- }
- if (!suppress_default_print)
- default_print(p, caplen);
+ llc_hdrlen = llc_print(ndo, p, length, caplen, NULL, NULL);
+ if (llc_hdrlen < 0) {
+ /* packet type not known, print raw packet */
+ if (!ndo->ndo_suppress_default_print)
+ ND_DEFAULTPRINT(p, caplen);
+ llc_hdrlen = -llc_hdrlen;
}
} else {
/*
* LLC header is absent; treat it as just IP.
*/
- ip_print(gndo, p, length);
+ llc_hdrlen = 0;
+ ip_print(ndo, p, length);
}
- return (0);
+ return (llc_hdrlen);
}
@@ -116,3 +111,6 @@ cip_if_print(const struct pcap_pkthdr *h, const u_char *p)
* c-basic-offset: 8
* End:
*/
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-cip-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-cnfp.c b/freebsd/contrib/tcpdump/print-cnfp.c
index ae4a3426..92d17cb2 100644
--- a/freebsd/contrib/tcpdump/print-cnfp.c
+++ b/freebsd/contrib/tcpdump/print-cnfp.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/* $OpenBSD: print-cnfp.c,v 1.2 1998/06/25 20:26:59 mickey Exp $ */
/*
@@ -32,72 +35,146 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-/* Cisco NetFlow protocol */
+/* \summary: Cisco NetFlow protocol printer */
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-cnfp.c,v 1.17 2005-04-20 20:53:18 guy Exp $";
-#endif
+/*
+ * Cisco NetFlow protocol
+ *
+ * See
+ *
+ * http://www.cisco.com/c/en/us/td/docs/net_mgmt/netflow_collection_engine/3-6/user/guide/format.html#wp1005892
+ */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <stdio.h>
#include <string.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "extract.h"
#include "tcp.h"
#include "ipproto.h"
-struct nfhdr {
- u_int32_t ver_cnt; /* version [15], and # of records */
- u_int32_t msys_uptime;
- u_int32_t utc_sec;
- u_int32_t utc_nsec;
- u_int32_t sequence; /* v5 flow sequence number */
- u_int32_t reserved; /* v5 only */
+struct nfhdr_v1 {
+ uint16_t version; /* version number */
+ uint16_t count; /* # of records */
+ uint32_t msys_uptime;
+ uint32_t utc_sec;
+ uint32_t utc_nsec;
};
-struct nfrec {
+struct nfrec_v1 {
struct in_addr src_ina;
struct in_addr dst_ina;
struct in_addr nhop_ina;
- u_int32_t ifaces; /* src,dst ifaces */
- u_int32_t packets;
- u_int32_t octets;
- u_int32_t start_time; /* sys_uptime value */
- u_int32_t last_time; /* sys_uptime value */
- u_int32_t ports; /* src,dst ports */
- u_int32_t proto_tos; /* proto, tos, pad, flags(v5) */
- u_int32_t asses; /* v1: flags; v5: src,dst AS */
- u_int32_t masks; /* src,dst addr prefix; v6: encaps */
+ uint16_t input; /* SNMP index of input interface */
+ uint16_t output; /* SNMP index of output interface */
+ uint32_t packets; /* packets in the flow */
+ uint32_t octets; /* layer 3 octets in the packets of the flow */
+ uint32_t start_time; /* sys_uptime value at start of flow */
+ uint32_t last_time; /* sys_uptime value when last packet of flow was received */
+ uint16_t srcport; /* TCP/UDP source port or equivalent */
+ uint16_t dstport; /* TCP/UDP source port or equivalent */
+ uint16_t pad1; /* pad */
+ uint8_t proto; /* IP protocol type */
+ uint8_t tos; /* IP type of service */
+ uint8_t tcp_flags; /* cumulative OR of TCP flags */
+ uint8_t pad[3]; /* padding */
+ uint32_t reserved; /* unused */
+};
+
+struct nfhdr_v5 {
+ uint16_t version; /* version number */
+ uint16_t count; /* # of records */
+ uint32_t msys_uptime;
+ uint32_t utc_sec;
+ uint32_t utc_nsec;
+ uint32_t sequence; /* flow sequence number */
+ uint8_t engine_type; /* type of flow-switching engine */
+ uint8_t engine_id; /* slot number of the flow-switching engine */
+ uint16_t sampling_interval; /* sampling mode and interval */
+};
+
+struct nfrec_v5 {
+ struct in_addr src_ina;
+ struct in_addr dst_ina;
+ struct in_addr nhop_ina;
+ uint16_t input; /* SNMP index of input interface */
+ uint16_t output; /* SNMP index of output interface */
+ uint32_t packets; /* packets in the flow */
+ uint32_t octets; /* layer 3 octets in the packets of the flow */
+ uint32_t start_time; /* sys_uptime value at start of flow */
+ uint32_t last_time; /* sys_uptime value when last packet of flow was received */
+ uint16_t srcport; /* TCP/UDP source port or equivalent */
+ uint16_t dstport; /* TCP/UDP source port or equivalent */
+ uint8_t pad1; /* pad */
+ uint8_t tcp_flags; /* cumulative OR of TCP flags */
+ uint8_t proto; /* IP protocol type */
+ uint8_t tos; /* IP type of service */
+ uint16_t src_as; /* AS number of the source */
+ uint16_t dst_as; /* AS number of the destination */
+ uint8_t src_mask; /* source address mask bits */
+ uint8_t dst_mask; /* destination address prefix mask bits */
+ uint16_t pad2;
struct in_addr peer_nexthop; /* v6: IP address of the nexthop within the peer (FIB)*/
};
-void
-cnfp_print(const u_char *cp, const u_char *bp _U_)
+struct nfhdr_v6 {
+ uint16_t version; /* version number */
+ uint16_t count; /* # of records */
+ uint32_t msys_uptime;
+ uint32_t utc_sec;
+ uint32_t utc_nsec;
+ uint32_t sequence; /* v5 flow sequence number */
+ uint32_t reserved; /* v5 only */
+};
+
+struct nfrec_v6 {
+ struct in_addr src_ina;
+ struct in_addr dst_ina;
+ struct in_addr nhop_ina;
+ uint16_t input; /* SNMP index of input interface */
+ uint16_t output; /* SNMP index of output interface */
+ uint32_t packets; /* packets in the flow */
+ uint32_t octets; /* layer 3 octets in the packets of the flow */
+ uint32_t start_time; /* sys_uptime value at start of flow */
+ uint32_t last_time; /* sys_uptime value when last packet of flow was received */
+ uint16_t srcport; /* TCP/UDP source port or equivalent */
+ uint16_t dstport; /* TCP/UDP source port or equivalent */
+ uint8_t pad1; /* pad */
+ uint8_t tcp_flags; /* cumulative OR of TCP flags */
+ uint8_t proto; /* IP protocol type */
+ uint8_t tos; /* IP type of service */
+ uint16_t src_as; /* AS number of the source */
+ uint16_t dst_as; /* AS number of the destination */
+ uint8_t src_mask; /* source address mask bits */
+ uint8_t dst_mask; /* destination address prefix mask bits */
+ uint16_t flags;
+ struct in_addr peer_nexthop; /* v6: IP address of the nexthop within the peer (FIB)*/
+};
+
+static void
+cnfp_v1_print(netdissect_options *ndo, const u_char *cp)
{
- register const struct nfhdr *nh;
- register const struct nfrec *nr;
+ register const struct nfhdr_v1 *nh;
+ register const struct nfrec_v1 *nr;
struct protoent *pent;
int nrecs, ver;
#if 0
time_t t;
#endif
- nh = (const struct nfhdr *)cp;
-
- if ((const u_char *)(nh + 1) > snapend)
- return;
+ nh = (const struct nfhdr_v1 *)cp;
+ ND_TCHECK(*nh);
- nrecs = EXTRACT_32BITS(&nh->ver_cnt) & 0xffff;
- ver = (EXTRACT_32BITS(&nh->ver_cnt) & 0xffff0000) >> 16;
+ ver = EXTRACT_16BITS(&nh->version);
+ nrecs = EXTRACT_32BITS(&nh->count);
#if 0
/*
* This is seconds since the UN*X epoch, and is followed by
@@ -107,86 +184,302 @@ cnfp_print(const u_char *cp, const u_char *bp _U_)
t = EXTRACT_32BITS(&nh->utc_sec);
#endif
- printf("NetFlow v%x, %u.%03u uptime, %u.%09u, ", ver,
+ ND_PRINT((ndo, "NetFlow v%x, %u.%03u uptime, %u.%09u, ", ver,
EXTRACT_32BITS(&nh->msys_uptime)/1000,
EXTRACT_32BITS(&nh->msys_uptime)%1000,
- EXTRACT_32BITS(&nh->utc_sec), EXTRACT_32BITS(&nh->utc_nsec));
-
- if (ver == 5 || ver == 6) {
- printf("#%u, ", EXTRACT_32BITS(&nh->sequence));
- nr = (const struct nfrec *)&nh[1];
- snaplen -= 24;
- } else {
- nr = (const struct nfrec *)&nh->sequence;
- snaplen -= 16;
- }
+ EXTRACT_32BITS(&nh->utc_sec), EXTRACT_32BITS(&nh->utc_nsec)));
+
+ nr = (const struct nfrec_v1 *)&nh[1];
- printf("%2u recs", nrecs);
+ ND_PRINT((ndo, "%2u recs", nrecs));
- for (; nrecs-- && (const u_char *)(nr + 1) <= snapend; nr++) {
+ for (; nrecs != 0; nr++, nrecs--) {
char buf[20];
char asbuf[20];
- printf("\n started %u.%03u, last %u.%03u",
+ /*
+ * Make sure we have the entire record.
+ */
+ ND_TCHECK(*nr);
+ ND_PRINT((ndo, "\n started %u.%03u, last %u.%03u",
EXTRACT_32BITS(&nr->start_time)/1000,
EXTRACT_32BITS(&nr->start_time)%1000,
EXTRACT_32BITS(&nr->last_time)/1000,
- EXTRACT_32BITS(&nr->last_time)%1000);
+ EXTRACT_32BITS(&nr->last_time)%1000));
asbuf[0] = buf[0] = '\0';
- if (ver == 5 || ver == 6) {
- snprintf(buf, sizeof(buf), "/%u",
- (EXTRACT_32BITS(&nr->masks) >> 24) & 0xff);
- snprintf(asbuf, sizeof(asbuf), ":%u",
- (EXTRACT_32BITS(&nr->asses) >> 16) & 0xffff);
- }
- printf("\n %s%s%s:%u ", intoa(nr->src_ina.s_addr), buf, asbuf,
- EXTRACT_32BITS(&nr->ports) >> 16);
-
- if (ver == 5 || ver ==6) {
- snprintf(buf, sizeof(buf), "/%d",
- (EXTRACT_32BITS(&nr->masks) >> 16) & 0xff);
- snprintf(asbuf, sizeof(asbuf), ":%u",
- EXTRACT_32BITS(&nr->asses) & 0xffff);
+ ND_PRINT((ndo, "\n %s%s%s:%u ", intoa(nr->src_ina.s_addr), buf, asbuf,
+ EXTRACT_16BITS(&nr->srcport)));
+
+ ND_PRINT((ndo, "> %s%s%s:%u ", intoa(nr->dst_ina.s_addr), buf, asbuf,
+ EXTRACT_16BITS(&nr->dstport)));
+
+ ND_PRINT((ndo, ">> %s\n ", intoa(nr->nhop_ina.s_addr)));
+
+ pent = getprotobynumber(nr->proto);
+ if (!pent || ndo->ndo_nflag)
+ ND_PRINT((ndo, "%u ", nr->proto));
+ else
+ ND_PRINT((ndo, "%s ", pent->p_name));
+
+ /* tcp flags for tcp only */
+ if (pent && pent->p_proto == IPPROTO_TCP) {
+ int flags;
+ flags = nr->tcp_flags;
+ ND_PRINT((ndo, "%s%s%s%s%s%s%s",
+ flags & TH_FIN ? "F" : "",
+ flags & TH_SYN ? "S" : "",
+ flags & TH_RST ? "R" : "",
+ flags & TH_PUSH ? "P" : "",
+ flags & TH_ACK ? "A" : "",
+ flags & TH_URG ? "U" : "",
+ flags ? " " : ""));
}
- printf("> %s%s%s:%u ", intoa(nr->dst_ina.s_addr), buf, asbuf,
- EXTRACT_32BITS(&nr->ports) & 0xffff);
- printf(">> %s\n ", intoa(nr->nhop_ina.s_addr));
+ buf[0]='\0';
+ ND_PRINT((ndo, "tos %u, %u (%u octets) %s",
+ nr->tos,
+ EXTRACT_32BITS(&nr->packets),
+ EXTRACT_32BITS(&nr->octets), buf));
+ }
+ return;
- pent = getprotobynumber((EXTRACT_32BITS(&nr->proto_tos) >> 8) & 0xff);
- if (!pent || nflag)
- printf("%u ",
- (EXTRACT_32BITS(&nr->proto_tos) >> 8) & 0xff);
+trunc:
+ ND_PRINT((ndo, "[|cnfp]"));
+ return;
+}
+
+static void
+cnfp_v5_print(netdissect_options *ndo, const u_char *cp)
+{
+ register const struct nfhdr_v5 *nh;
+ register const struct nfrec_v5 *nr;
+ struct protoent *pent;
+ int nrecs, ver;
+#if 0
+ time_t t;
+#endif
+
+ nh = (const struct nfhdr_v5 *)cp;
+ ND_TCHECK(*nh);
+
+ ver = EXTRACT_16BITS(&nh->version);
+ nrecs = EXTRACT_32BITS(&nh->count);
+#if 0
+ /*
+ * This is seconds since the UN*X epoch, and is followed by
+ * nanoseconds. XXX - format it, rather than just dumping the
+ * raw seconds-since-the-Epoch.
+ */
+ t = EXTRACT_32BITS(&nh->utc_sec);
+#endif
+
+ ND_PRINT((ndo, "NetFlow v%x, %u.%03u uptime, %u.%09u, ", ver,
+ EXTRACT_32BITS(&nh->msys_uptime)/1000,
+ EXTRACT_32BITS(&nh->msys_uptime)%1000,
+ EXTRACT_32BITS(&nh->utc_sec), EXTRACT_32BITS(&nh->utc_nsec)));
+
+ ND_PRINT((ndo, "#%u, ", EXTRACT_32BITS(&nh->sequence)));
+ nr = (const struct nfrec_v5 *)&nh[1];
+
+ ND_PRINT((ndo, "%2u recs", nrecs));
+
+ for (; nrecs != 0; nr++, nrecs--) {
+ char buf[20];
+ char asbuf[20];
+
+ /*
+ * Make sure we have the entire record.
+ */
+ ND_TCHECK(*nr);
+ ND_PRINT((ndo, "\n started %u.%03u, last %u.%03u",
+ EXTRACT_32BITS(&nr->start_time)/1000,
+ EXTRACT_32BITS(&nr->start_time)%1000,
+ EXTRACT_32BITS(&nr->last_time)/1000,
+ EXTRACT_32BITS(&nr->last_time)%1000));
+
+ asbuf[0] = buf[0] = '\0';
+ snprintf(buf, sizeof(buf), "/%u", nr->src_mask);
+ snprintf(asbuf, sizeof(asbuf), ":%u",
+ EXTRACT_16BITS(&nr->src_as));
+ ND_PRINT((ndo, "\n %s%s%s:%u ", intoa(nr->src_ina.s_addr), buf, asbuf,
+ EXTRACT_16BITS(&nr->srcport)));
+
+ snprintf(buf, sizeof(buf), "/%d", nr->dst_mask);
+ snprintf(asbuf, sizeof(asbuf), ":%u",
+ EXTRACT_16BITS(&nr->dst_as));
+ ND_PRINT((ndo, "> %s%s%s:%u ", intoa(nr->dst_ina.s_addr), buf, asbuf,
+ EXTRACT_16BITS(&nr->dstport)));
+
+ ND_PRINT((ndo, ">> %s\n ", intoa(nr->nhop_ina.s_addr)));
+
+ pent = getprotobynumber(nr->proto);
+ if (!pent || ndo->ndo_nflag)
+ ND_PRINT((ndo, "%u ", nr->proto));
else
- printf("%s ", pent->p_name);
+ ND_PRINT((ndo, "%s ", pent->p_name));
/* tcp flags for tcp only */
if (pent && pent->p_proto == IPPROTO_TCP) {
int flags;
- if (ver == 1)
- flags = (EXTRACT_32BITS(&nr->asses) >> 24) & 0xff;
- else
- flags = (EXTRACT_32BITS(&nr->proto_tos) >> 16) & 0xff;
- if (flags & TH_FIN) putchar('F');
- if (flags & TH_SYN) putchar('S');
- if (flags & TH_RST) putchar('R');
- if (flags & TH_PUSH) putchar('P');
- if (flags & TH_ACK) putchar('A');
- if (flags & TH_URG) putchar('U');
- if (flags)
- putchar(' ');
+ flags = nr->tcp_flags;
+ ND_PRINT((ndo, "%s%s%s%s%s%s%s",
+ flags & TH_FIN ? "F" : "",
+ flags & TH_SYN ? "S" : "",
+ flags & TH_RST ? "R" : "",
+ flags & TH_PUSH ? "P" : "",
+ flags & TH_ACK ? "A" : "",
+ flags & TH_URG ? "U" : "",
+ flags ? " " : ""));
}
buf[0]='\0';
- if (ver == 6) {
- snprintf(buf, sizeof(buf), "(%u<>%u encaps)",
- (EXTRACT_32BITS(&nr->masks) >> 8) & 0xff,
- (EXTRACT_32BITS(&nr->masks)) & 0xff);
+ ND_PRINT((ndo, "tos %u, %u (%u octets) %s",
+ nr->tos,
+ EXTRACT_32BITS(&nr->packets),
+ EXTRACT_32BITS(&nr->octets), buf));
+ }
+ return;
+
+trunc:
+ ND_PRINT((ndo, "[|cnfp]"));
+ return;
+}
+
+static void
+cnfp_v6_print(netdissect_options *ndo, const u_char *cp)
+{
+ register const struct nfhdr_v6 *nh;
+ register const struct nfrec_v6 *nr;
+ struct protoent *pent;
+ int nrecs, ver;
+#if 0
+ time_t t;
+#endif
+
+ nh = (const struct nfhdr_v6 *)cp;
+ ND_TCHECK(*nh);
+
+ ver = EXTRACT_16BITS(&nh->version);
+ nrecs = EXTRACT_32BITS(&nh->count);
+#if 0
+ /*
+ * This is seconds since the UN*X epoch, and is followed by
+ * nanoseconds. XXX - format it, rather than just dumping the
+ * raw seconds-since-the-Epoch.
+ */
+ t = EXTRACT_32BITS(&nh->utc_sec);
+#endif
+
+ ND_PRINT((ndo, "NetFlow v%x, %u.%03u uptime, %u.%09u, ", ver,
+ EXTRACT_32BITS(&nh->msys_uptime)/1000,
+ EXTRACT_32BITS(&nh->msys_uptime)%1000,
+ EXTRACT_32BITS(&nh->utc_sec), EXTRACT_32BITS(&nh->utc_nsec)));
+
+ ND_PRINT((ndo, "#%u, ", EXTRACT_32BITS(&nh->sequence)));
+ nr = (const struct nfrec_v6 *)&nh[1];
+
+ ND_PRINT((ndo, "%2u recs", nrecs));
+
+ for (; nrecs != 0; nr++, nrecs--) {
+ char buf[20];
+ char asbuf[20];
+
+ /*
+ * Make sure we have the entire record.
+ */
+ ND_TCHECK(*nr);
+ ND_PRINT((ndo, "\n started %u.%03u, last %u.%03u",
+ EXTRACT_32BITS(&nr->start_time)/1000,
+ EXTRACT_32BITS(&nr->start_time)%1000,
+ EXTRACT_32BITS(&nr->last_time)/1000,
+ EXTRACT_32BITS(&nr->last_time)%1000));
+
+ asbuf[0] = buf[0] = '\0';
+ snprintf(buf, sizeof(buf), "/%u", nr->src_mask);
+ snprintf(asbuf, sizeof(asbuf), ":%u",
+ EXTRACT_16BITS(&nr->src_as));
+ ND_PRINT((ndo, "\n %s%s%s:%u ", intoa(nr->src_ina.s_addr), buf, asbuf,
+ EXTRACT_16BITS(&nr->srcport)));
+
+ snprintf(buf, sizeof(buf), "/%d", nr->dst_mask);
+ snprintf(asbuf, sizeof(asbuf), ":%u",
+ EXTRACT_16BITS(&nr->dst_as));
+ ND_PRINT((ndo, "> %s%s%s:%u ", intoa(nr->dst_ina.s_addr), buf, asbuf,
+ EXTRACT_16BITS(&nr->dstport)));
+
+ ND_PRINT((ndo, ">> %s\n ", intoa(nr->nhop_ina.s_addr)));
+
+ pent = getprotobynumber(nr->proto);
+ if (!pent || ndo->ndo_nflag)
+ ND_PRINT((ndo, "%u ", nr->proto));
+ else
+ ND_PRINT((ndo, "%s ", pent->p_name));
+
+ /* tcp flags for tcp only */
+ if (pent && pent->p_proto == IPPROTO_TCP) {
+ int flags;
+ flags = nr->tcp_flags;
+ ND_PRINT((ndo, "%s%s%s%s%s%s%s",
+ flags & TH_FIN ? "F" : "",
+ flags & TH_SYN ? "S" : "",
+ flags & TH_RST ? "R" : "",
+ flags & TH_PUSH ? "P" : "",
+ flags & TH_ACK ? "A" : "",
+ flags & TH_URG ? "U" : "",
+ flags ? " " : ""));
}
- printf("tos %u, %u (%u octets) %s",
- EXTRACT_32BITS(&nr->proto_tos) & 0xff,
+
+ buf[0]='\0';
+ snprintf(buf, sizeof(buf), "(%u<>%u encaps)",
+ (EXTRACT_16BITS(&nr->flags) >> 8) & 0xff,
+ (EXTRACT_16BITS(&nr->flags)) & 0xff);
+ ND_PRINT((ndo, "tos %u, %u (%u octets) %s",
+ nr->tos,
EXTRACT_32BITS(&nr->packets),
- EXTRACT_32BITS(&nr->octets), buf);
+ EXTRACT_32BITS(&nr->octets), buf));
+ }
+ return;
+
+trunc:
+ ND_PRINT((ndo, "[|cnfp]"));
+ return;
+}
+
+void
+cnfp_print(netdissect_options *ndo, const u_char *cp)
+{
+ int ver;
+
+ /*
+ * First 2 bytes are the version number.
+ */
+ ND_TCHECK2(*cp, 2);
+ ver = EXTRACT_16BITS(cp);
+ switch (ver) {
+
+ case 1:
+ cnfp_v1_print(ndo, cp);
+ break;
+
+ case 5:
+ cnfp_v5_print(ndo, cp);
+ break;
+
+ case 6:
+ cnfp_v6_print(ndo, cp);
+ break;
+
+ default:
+ ND_PRINT((ndo, "NetFlow v%x", ver));
+ break;
}
+ return;
+
+trunc:
+ ND_PRINT((ndo, "[|cnfp]"));
+ return;
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-cnfp-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-dccp.c b/freebsd/contrib/tcpdump/print-dccp.c
index 59417c58..a8748123 100644
--- a/freebsd/contrib/tcpdump/print-dccp.c
+++ b/freebsd/contrib/tcpdump/print-dccp.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (C) Arnaldo Carvalho de Melo 2004
* Copyright (C) Ian McDonald 2005
@@ -9,31 +12,158 @@
* BSD-style license that accompanies tcpdump or the GNU GPL version 2
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-dccp.c,v 1.8 2007-11-09 00:44:09 guy Exp $ (LBL)";
-#endif
+/* \summary: Datagram Congestion Control Protocol (DCCP) printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
-
-#include "dccp.h"
+#include <netdissect-stdinc.h>
#include <stdio.h>
#include <string.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
-#include "extract.h" /* must come after interface.h */
+#include "extract.h"
#include "ip.h"
-#ifdef INET6
#include "ip6.h"
-#endif
#include "ipproto.h"
+/* RFC4340: Datagram Congestion Control Protocol (DCCP) */
+
+/**
+ * struct dccp_hdr - generic part of DCCP packet header, with a 24-bit
+ * sequence number
+ *
+ * @dccph_sport - Relevant port on the endpoint that sent this packet
+ * @dccph_dport - Relevant port on the other endpoint
+ * @dccph_doff - Data Offset from the start of the DCCP header, in 32-bit words
+ * @dccph_ccval - Used by the HC-Sender CCID
+ * @dccph_cscov - Parts of the packet that are covered by the Checksum field
+ * @dccph_checksum - Internet checksum, depends on dccph_cscov
+ * @dccph_x - 0 = 24 bit sequence number, 1 = 48
+ * @dccph_type - packet type, see DCCP_PKT_ prefixed macros
+ * @dccph_seq - 24-bit sequence number
+ */
+struct dccp_hdr {
+ uint16_t dccph_sport,
+ dccph_dport;
+ uint8_t dccph_doff;
+ uint8_t dccph_ccval_cscov;
+ uint16_t dccph_checksum;
+ uint8_t dccph_xtr;
+ uint8_t dccph_seq[3];
+} UNALIGNED;
+
+/**
+ * struct dccp_hdr_ext - generic part of DCCP packet header, with a 48-bit
+ * sequence number
+ *
+ * @dccph_sport - Relevant port on the endpoint that sent this packet
+ * @dccph_dport - Relevant port on the other endpoint
+ * @dccph_doff - Data Offset from the start of the DCCP header, in 32-bit words
+ * @dccph_ccval - Used by the HC-Sender CCID
+ * @dccph_cscov - Parts of the packet that are covered by the Checksum field
+ * @dccph_checksum - Internet checksum, depends on dccph_cscov
+ * @dccph_x - 0 = 24 bit sequence number, 1 = 48
+ * @dccph_type - packet type, see DCCP_PKT_ prefixed macros
+ * @dccph_seq - 48-bit sequence number
+ */
+struct dccp_hdr_ext {
+ uint16_t dccph_sport,
+ dccph_dport;
+ uint8_t dccph_doff;
+ uint8_t dccph_ccval_cscov;
+ uint16_t dccph_checksum;
+ uint8_t dccph_xtr;
+ uint8_t reserved;
+ uint8_t dccph_seq[6];
+} UNALIGNED;
+
+#define DCCPH_CCVAL(dh) (((dh)->dccph_ccval_cscov >> 4) & 0xF)
+#define DCCPH_CSCOV(dh) (((dh)->dccph_ccval_cscov) & 0xF)
+
+#define DCCPH_X(dh) ((dh)->dccph_xtr & 1)
+#define DCCPH_TYPE(dh) (((dh)->dccph_xtr >> 1) & 0xF)
+
+/**
+ * struct dccp_hdr_request - Conection initiation request header
+ *
+ * @dccph_req_service - Service to which the client app wants to connect
+ */
+struct dccp_hdr_request {
+ uint32_t dccph_req_service;
+} UNALIGNED;
+
+/**
+ * struct dccp_hdr_response - Conection initiation response header
+ *
+ * @dccph_resp_ack - 48 bit ack number, contains GSR
+ * @dccph_resp_service - Echoes the Service Code on a received DCCP-Request
+ */
+struct dccp_hdr_response {
+ uint8_t dccph_resp_ack[8]; /* always 8 bytes */
+ uint32_t dccph_resp_service;
+} UNALIGNED;
+
+/**
+ * struct dccp_hdr_reset - Unconditionally shut down a connection
+ *
+ * @dccph_resp_ack - 48 bit ack number
+ * @dccph_reset_service - Echoes the Service Code on a received DCCP-Request
+ */
+struct dccp_hdr_reset {
+ uint8_t dccph_reset_ack[8]; /* always 8 bytes */
+ uint8_t dccph_reset_code,
+ dccph_reset_data[3];
+} UNALIGNED;
+
+enum dccp_pkt_type {
+ DCCP_PKT_REQUEST = 0,
+ DCCP_PKT_RESPONSE,
+ DCCP_PKT_DATA,
+ DCCP_PKT_ACK,
+ DCCP_PKT_DATAACK,
+ DCCP_PKT_CLOSEREQ,
+ DCCP_PKT_CLOSE,
+ DCCP_PKT_RESET,
+ DCCP_PKT_SYNC,
+ DCCP_PKT_SYNCACK
+};
+
+static const struct tok dccp_pkt_type_str[] = {
+ { DCCP_PKT_REQUEST, "DCCP-Request" },
+ { DCCP_PKT_RESPONSE, "DCCP-Response" },
+ { DCCP_PKT_DATA, "DCCP-Data" },
+ { DCCP_PKT_ACK, "DCCP-Ack" },
+ { DCCP_PKT_DATAACK, "DCCP-DataAck" },
+ { DCCP_PKT_CLOSEREQ, "DCCP-CloseReq" },
+ { DCCP_PKT_CLOSE, "DCCP-Close" },
+ { DCCP_PKT_RESET, "DCCP-Reset" },
+ { DCCP_PKT_SYNC, "DCCP-Sync" },
+ { DCCP_PKT_SYNCACK, "DCCP-SyncAck" },
+ { 0, NULL}
+};
+
+enum dccp_reset_codes {
+ DCCP_RESET_CODE_UNSPECIFIED = 0,
+ DCCP_RESET_CODE_CLOSED,
+ DCCP_RESET_CODE_ABORTED,
+ DCCP_RESET_CODE_NO_CONNECTION,
+ DCCP_RESET_CODE_PACKET_ERROR,
+ DCCP_RESET_CODE_OPTION_ERROR,
+ DCCP_RESET_CODE_MANDATORY_ERROR,
+ DCCP_RESET_CODE_CONNECTION_REFUSED,
+ DCCP_RESET_CODE_BAD_SERVICE_CODE,
+ DCCP_RESET_CODE_TOO_BUSY,
+ DCCP_RESET_CODE_BAD_INIT_COOKIE,
+ DCCP_RESET_CODE_AGGRESSION_PENALTY,
+ __DCCP_RESET_CODE_LAST
+};
+
+static const char tstr[] = "[|dccp]";
+
static const char *dccp_reset_codes[] = {
"unspecified",
"closed",
@@ -50,60 +180,59 @@ static const char *dccp_reset_codes[] = {
};
static const char *dccp_feature_nums[] = {
- "reserved",
+ "reserved",
"ccid",
"allow_short_seqno",
"sequence_window",
- "ecn_incapable",
- "ack_ratio",
+ "ecn_incapable",
+ "ack_ratio",
"send_ack_vector",
- "send_ndp_count",
- "minimum checksum coverage",
+ "send_ndp_count",
+ "minimum checksum coverage",
"check data checksum",
};
static inline u_int dccp_csum_coverage(const struct dccp_hdr* dh, u_int len)
{
u_int cov;
-
+
if (DCCPH_CSCOV(dh) == 0)
return len;
- cov = (dh->dccph_doff + DCCPH_CSCOV(dh) - 1) * sizeof(u_int32_t);
+ cov = (dh->dccph_doff + DCCPH_CSCOV(dh) - 1) * sizeof(uint32_t);
return (cov > len)? len : cov;
}
-static int dccp_cksum(const struct ip *ip,
+static int dccp_cksum(netdissect_options *ndo, const struct ip *ip,
const struct dccp_hdr *dh, u_int len)
{
- return nextproto4_cksum(ip, (const u_int8_t *)(void *)dh,
- dccp_csum_coverage(dh, len), IPPROTO_DCCP);
+ return nextproto4_cksum(ndo, ip, (const uint8_t *)(const void *)dh, len,
+ dccp_csum_coverage(dh, len), IPPROTO_DCCP);
}
-#ifdef INET6
-static int dccp6_cksum(const struct ip6_hdr *ip6, const struct dccp_hdr *dh, u_int len)
+static int dccp6_cksum(netdissect_options *ndo, const struct ip6_hdr *ip6,
+ const struct dccp_hdr *dh, u_int len)
{
- return nextproto6_cksum(ip6, (const u_int8_t *)(void *)dh,
- dccp_csum_coverage(dh, len), IPPROTO_DCCP);
+ return nextproto6_cksum(ndo, ip6, (const uint8_t *)(const void *)dh, len,
+ dccp_csum_coverage(dh, len), IPPROTO_DCCP);
}
-#endif
-static const char *dccp_reset_code(u_int8_t code)
+static const char *dccp_reset_code(uint8_t code)
{
if (code >= __DCCP_RESET_CODE_LAST)
return "invalid";
return dccp_reset_codes[code];
}
-static u_int64_t dccp_seqno(const struct dccp_hdr *dh)
+static uint64_t dccp_seqno(const u_char *bp)
{
- u_int32_t seq_high = DCCPH_SEQ(dh);
- u_int64_t seqno = EXTRACT_24BITS(&seq_high) & 0xFFFFFF;
+ const struct dccp_hdr *dh = (const struct dccp_hdr *)bp;
+ uint64_t seqno;
if (DCCPH_X(dh) != 0) {
- const struct dccp_hdr_ext *dhx = (void *)(dh + 1);
- u_int32_t seq_low = dhx->dccph_seq_low;
- seqno &= 0x00FFFF; /* clear reserved field */
- seqno = (seqno << 32) + EXTRACT_32BITS(&seq_low);
+ const struct dccp_hdr_ext *dhx = (const struct dccp_hdr_ext *)bp;
+ seqno = EXTRACT_48BITS(dhx->dccph_seq);
+ } else {
+ seqno = EXTRACT_24BITS(dh->dccph_seq);
}
return seqno;
@@ -111,356 +240,428 @@ static u_int64_t dccp_seqno(const struct dccp_hdr *dh)
static inline unsigned int dccp_basic_hdr_len(const struct dccp_hdr *dh)
{
- return sizeof(*dh) + (DCCPH_X(dh) ? sizeof(struct dccp_hdr_ext) : 0);
+ return DCCPH_X(dh) ? sizeof(struct dccp_hdr_ext) : sizeof(struct dccp_hdr);
}
-static void dccp_print_ack_no(const u_char *bp)
+static void dccp_print_ack_no(netdissect_options *ndo, const u_char *bp)
{
const struct dccp_hdr *dh = (const struct dccp_hdr *)bp;
- const struct dccp_hdr_ack_bits *dh_ack =
- (struct dccp_hdr_ack_bits *)(bp + dccp_basic_hdr_len(dh));
- u_int32_t ack_high;
- u_int64_t ackno;
-
- TCHECK2(*dh_ack,4);
- ack_high = DCCPH_ACK(dh_ack);
- ackno = EXTRACT_24BITS(&ack_high) & 0xFFFFFF;
+ const u_char *ackp = bp + dccp_basic_hdr_len(dh);
+ uint64_t ackno;
if (DCCPH_X(dh) != 0) {
- u_int32_t ack_low;
-
- TCHECK2(*dh_ack,8);
- ack_low = dh_ack->dccph_ack_nr_low;
-
- ackno &= 0x00FFFF; /* clear reserved field */
- ackno = (ackno << 32) + EXTRACT_32BITS(&ack_low);
+ ND_TCHECK2(*ackp, 8);
+ ackno = EXTRACT_48BITS(ackp + 2);
+ } else {
+ ND_TCHECK2(*ackp, 4);
+ ackno = EXTRACT_24BITS(ackp + 1);
}
- (void)printf("(ack=%" PRIu64 ") ", ackno);
+ ND_PRINT((ndo, "(ack=%" PRIu64 ") ", ackno));
trunc:
return;
}
-static inline unsigned int dccp_packet_hdr_len(const u_int8_t type)
-{
- if (type == DCCP_PKT_DATA)
- return 0;
- if (type == DCCP_PKT_DATAACK ||
- type == DCCP_PKT_ACK ||
- type == DCCP_PKT_SYNC ||
- type == DCCP_PKT_SYNCACK ||
- type == DCCP_PKT_CLOSE ||
- type == DCCP_PKT_CLOSEREQ)
- return sizeof(struct dccp_hdr_ack_bits);
- if (type == DCCP_PKT_REQUEST)
- return sizeof(struct dccp_hdr_request);
- if (type == DCCP_PKT_RESPONSE)
- return sizeof(struct dccp_hdr_response);
- return sizeof(struct dccp_hdr_reset);
-}
-
-static int dccp_print_option(const u_char *option);
+static int dccp_print_option(netdissect_options *, const u_char *, u_int);
/**
* dccp_print - show dccp packet
* @bp - beginning of dccp packet
- * @data2 - beginning of enclosing
+ * @data2 - beginning of enclosing
* @len - lenght of ip packet
*/
-void dccp_print(const u_char *bp, const u_char *data2, u_int len)
+void dccp_print(netdissect_options *ndo, const u_char *bp, const u_char *data2,
+ u_int len)
{
const struct dccp_hdr *dh;
const struct ip *ip;
-#ifdef INET6
const struct ip6_hdr *ip6;
-#endif
const u_char *cp;
u_short sport, dport;
u_int hlen;
- u_int extlen = 0;
+ u_int fixed_hdrlen;
+ uint8_t dccph_type;
dh = (const struct dccp_hdr *)bp;
- ip = (struct ip *)data2;
-#ifdef INET6
+ ip = (const struct ip *)data2;
if (IP_V(ip) == 6)
ip6 = (const struct ip6_hdr *)data2;
else
ip6 = NULL;
-#endif /*INET6*/
+
+ /* make sure we have enough data to look at the X bit */
cp = (const u_char *)(dh + 1);
- if (cp > snapend) {
- printf("[Invalid packet|dccp]");
+ if (cp > ndo->ndo_snapend) {
+ ND_PRINT((ndo, "[Invalid packet|dccp]"));
return;
}
-
if (len < sizeof(struct dccp_hdr)) {
- printf("truncated-dccp - %ld bytes missing!",
- (long)len - sizeof(struct dccp_hdr));
+ ND_PRINT((ndo, "truncated-dccp - %u bytes missing!",
+ len - (u_int)sizeof(struct dccp_hdr)));
return;
}
+ /* get the length of the generic header */
+ fixed_hdrlen = dccp_basic_hdr_len(dh);
+ if (len < fixed_hdrlen) {
+ ND_PRINT((ndo, "truncated-dccp - %u bytes missing!",
+ len - fixed_hdrlen));
+ return;
+ }
+ ND_TCHECK2(*dh, fixed_hdrlen);
+
sport = EXTRACT_16BITS(&dh->dccph_sport);
dport = EXTRACT_16BITS(&dh->dccph_dport);
hlen = dh->dccph_doff * 4;
-#ifdef INET6
if (ip6) {
- (void)printf("%s.%d > %s.%d: ",
- ip6addr_string(&ip6->ip6_src), sport,
- ip6addr_string(&ip6->ip6_dst), dport);
- } else
-#endif /*INET6*/
- {
- (void)printf("%s.%d > %s.%d: ",
- ipaddr_string(&ip->ip_src), sport,
- ipaddr_string(&ip->ip_dst), dport);
+ ND_PRINT((ndo, "%s.%d > %s.%d: ",
+ ip6addr_string(ndo, &ip6->ip6_src), sport,
+ ip6addr_string(ndo, &ip6->ip6_dst), dport));
+ } else {
+ ND_PRINT((ndo, "%s.%d > %s.%d: ",
+ ipaddr_string(ndo, &ip->ip_src), sport,
+ ipaddr_string(ndo, &ip->ip_dst), dport));
}
- fflush(stdout);
- if (qflag) {
- (void)printf(" %d", len - hlen);
+ ND_PRINT((ndo, "DCCP"));
+
+ if (ndo->ndo_qflag) {
+ ND_PRINT((ndo, " %d", len - hlen));
if (hlen > len) {
- (void)printf("dccp [bad hdr length %u - too long, > %u]",
- hlen, len);
+ ND_PRINT((ndo, " [bad hdr length %u - too long, > %u]",
+ hlen, len));
}
return;
}
/* other variables in generic header */
- if (vflag) {
- (void)printf("CCVal %d, CsCov %d, ", DCCPH_CCVAL(dh), DCCPH_CSCOV(dh));
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo, " (CCVal %d, CsCov %d, ", DCCPH_CCVAL(dh), DCCPH_CSCOV(dh)));
}
/* checksum calculation */
- if (vflag && TTEST2(bp[0], len)) {
- u_int16_t sum = 0, dccp_sum;
+ if (ndo->ndo_vflag && ND_TTEST2(bp[0], len)) {
+ uint16_t sum = 0, dccp_sum;
dccp_sum = EXTRACT_16BITS(&dh->dccph_checksum);
- (void)printf("cksum 0x%04x ", dccp_sum);
+ ND_PRINT((ndo, "cksum 0x%04x ", dccp_sum));
if (IP_V(ip) == 4)
- sum = dccp_cksum(ip, dh, len);
-#ifdef INET6
+ sum = dccp_cksum(ndo, ip, dh, len);
else if (IP_V(ip) == 6)
- sum = dccp6_cksum(ip6, dh, len);
-#endif
+ sum = dccp6_cksum(ndo, ip6, dh, len);
if (sum != 0)
- (void)printf("(incorrect -> 0x%04x), ",in_cksum_shouldbe(dccp_sum, sum));
+ ND_PRINT((ndo, "(incorrect -> 0x%04x)",in_cksum_shouldbe(dccp_sum, sum)));
else
- (void)printf("(correct), ");
+ ND_PRINT((ndo, "(correct)"));
}
- switch (DCCPH_TYPE(dh)) {
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo, ")"));
+ ND_PRINT((ndo, " "));
+
+ dccph_type = DCCPH_TYPE(dh);
+ switch (dccph_type) {
case DCCP_PKT_REQUEST: {
- struct dccp_hdr_request *dhr =
- (struct dccp_hdr_request *)(bp + dccp_basic_hdr_len(dh));
- TCHECK(*dhr);
- (void)printf("request (service=%d) ",
- EXTRACT_32BITS(&dhr->dccph_req_service));
- extlen += 4;
+ const struct dccp_hdr_request *dhr =
+ (const struct dccp_hdr_request *)(bp + fixed_hdrlen);
+ fixed_hdrlen += 4;
+ if (len < fixed_hdrlen) {
+ ND_PRINT((ndo, "truncated-%s - %u bytes missing!",
+ tok2str(dccp_pkt_type_str, "", dccph_type),
+ len - fixed_hdrlen));
+ return;
+ }
+ ND_TCHECK(*dhr);
+ ND_PRINT((ndo, "%s (service=%d) ",
+ tok2str(dccp_pkt_type_str, "", dccph_type),
+ EXTRACT_32BITS(&dhr->dccph_req_service)));
break;
}
case DCCP_PKT_RESPONSE: {
- struct dccp_hdr_response *dhr =
- (struct dccp_hdr_response *)(bp + dccp_basic_hdr_len(dh));
- TCHECK(*dhr);
- (void)printf("response (service=%d) ",
- EXTRACT_32BITS(&dhr->dccph_resp_service));
- extlen += 12;
+ const struct dccp_hdr_response *dhr =
+ (const struct dccp_hdr_response *)(bp + fixed_hdrlen);
+ fixed_hdrlen += 12;
+ if (len < fixed_hdrlen) {
+ ND_PRINT((ndo, "truncated-%s - %u bytes missing!",
+ tok2str(dccp_pkt_type_str, "", dccph_type),
+ len - fixed_hdrlen));
+ return;
+ }
+ ND_TCHECK(*dhr);
+ ND_PRINT((ndo, "%s (service=%d) ",
+ tok2str(dccp_pkt_type_str, "", dccph_type),
+ EXTRACT_32BITS(&dhr->dccph_resp_service)));
break;
}
case DCCP_PKT_DATA:
- (void)printf("data ");
+ ND_PRINT((ndo, "%s ", tok2str(dccp_pkt_type_str, "", dccph_type)));
break;
case DCCP_PKT_ACK: {
- (void)printf("ack ");
- extlen += 8;
+ fixed_hdrlen += 8;
+ if (len < fixed_hdrlen) {
+ ND_PRINT((ndo, "truncated-%s - %u bytes missing!",
+ tok2str(dccp_pkt_type_str, "", dccph_type),
+ len - fixed_hdrlen));
+ return;
+ }
+ ND_PRINT((ndo, "%s ", tok2str(dccp_pkt_type_str, "", dccph_type)));
break;
}
case DCCP_PKT_DATAACK: {
- (void)printf("dataack ");
- extlen += 8;
+ fixed_hdrlen += 8;
+ if (len < fixed_hdrlen) {
+ ND_PRINT((ndo, "truncated-%s - %u bytes missing!",
+ tok2str(dccp_pkt_type_str, "", dccph_type),
+ len - fixed_hdrlen));
+ return;
+ }
+ ND_PRINT((ndo, "%s ", tok2str(dccp_pkt_type_str, "", dccph_type)));
break;
}
case DCCP_PKT_CLOSEREQ:
- (void)printf("closereq ");
- extlen += 8;
+ fixed_hdrlen += 8;
+ if (len < fixed_hdrlen) {
+ ND_PRINT((ndo, "truncated-%s - %u bytes missing!",
+ tok2str(dccp_pkt_type_str, "", dccph_type),
+ len - fixed_hdrlen));
+ return;
+ }
+ ND_PRINT((ndo, "%s ", tok2str(dccp_pkt_type_str, "", dccph_type)));
break;
case DCCP_PKT_CLOSE:
- (void)printf("close ");
- extlen += 8;
+ fixed_hdrlen += 8;
+ if (len < fixed_hdrlen) {
+ ND_PRINT((ndo, "truncated-%s - %u bytes missing!",
+ tok2str(dccp_pkt_type_str, "", dccph_type),
+ len - fixed_hdrlen));
+ return;
+ }
+ ND_PRINT((ndo, "%s ", tok2str(dccp_pkt_type_str, "", dccph_type)));
break;
case DCCP_PKT_RESET: {
- struct dccp_hdr_reset *dhr =
- (struct dccp_hdr_reset *)(bp + dccp_basic_hdr_len(dh));
- TCHECK(*dhr);
- (void)printf("reset (code=%s) ",
- dccp_reset_code(dhr->dccph_reset_code));
- extlen += 12;
+ const struct dccp_hdr_reset *dhr =
+ (const struct dccp_hdr_reset *)(bp + fixed_hdrlen);
+ fixed_hdrlen += 12;
+ if (len < fixed_hdrlen) {
+ ND_PRINT((ndo, "truncated-%s - %u bytes missing!",
+ tok2str(dccp_pkt_type_str, "", dccph_type),
+ len - fixed_hdrlen));
+ return;
+ }
+ ND_TCHECK(*dhr);
+ ND_PRINT((ndo, "%s (code=%s) ",
+ tok2str(dccp_pkt_type_str, "", dccph_type),
+ dccp_reset_code(dhr->dccph_reset_code)));
break;
}
case DCCP_PKT_SYNC:
- (void)printf("sync ");
- extlen += 8;
+ fixed_hdrlen += 8;
+ if (len < fixed_hdrlen) {
+ ND_PRINT((ndo, "truncated-%s - %u bytes missing!",
+ tok2str(dccp_pkt_type_str, "", dccph_type),
+ len - fixed_hdrlen));
+ return;
+ }
+ ND_PRINT((ndo, "%s ", tok2str(dccp_pkt_type_str, "", dccph_type)));
break;
case DCCP_PKT_SYNCACK:
- (void)printf("syncack ");
- extlen += 8;
+ fixed_hdrlen += 8;
+ if (len < fixed_hdrlen) {
+ ND_PRINT((ndo, "truncated-%s - %u bytes missing!",
+ tok2str(dccp_pkt_type_str, "", dccph_type),
+ len - fixed_hdrlen));
+ return;
+ }
+ ND_PRINT((ndo, "%s ", tok2str(dccp_pkt_type_str, "", dccph_type)));
break;
default:
- (void)printf("invalid ");
+ ND_PRINT((ndo, "%s ", tok2str(dccp_pkt_type_str, "unknown-type-%u", dccph_type)));
break;
}
- if ((DCCPH_TYPE(dh) != DCCP_PKT_DATA) &&
+ if ((DCCPH_TYPE(dh) != DCCP_PKT_DATA) &&
(DCCPH_TYPE(dh) != DCCP_PKT_REQUEST))
- dccp_print_ack_no(bp);
+ dccp_print_ack_no(ndo, bp);
- if (vflag < 2)
+ if (ndo->ndo_vflag < 2)
return;
- (void)printf("seq %" PRIu64, dccp_seqno(dh));
+ ND_PRINT((ndo, "seq %" PRIu64, dccp_seqno(bp)));
/* process options */
- if (hlen > dccp_basic_hdr_len(dh) + extlen){
- const u_char *cp;
+ if (hlen > fixed_hdrlen){
u_int optlen;
- cp = bp + dccp_basic_hdr_len(dh) + extlen;
- printf(" <");
+ cp = bp + fixed_hdrlen;
+ ND_PRINT((ndo, " <"));
- hlen -= dccp_basic_hdr_len(dh) + extlen;
+ hlen -= fixed_hdrlen;
while(1){
- TCHECK(*cp);
- optlen = dccp_print_option(cp);
- if (!optlen) goto trunc2;
- if (hlen <= optlen) break;
+ optlen = dccp_print_option(ndo, cp, hlen);
+ if (!optlen)
+ break;
+ if (hlen <= optlen)
+ break;
hlen -= optlen;
cp += optlen;
- printf(", ");
+ ND_PRINT((ndo, ", "));
}
- printf(">");
+ ND_PRINT((ndo, ">"));
}
return;
trunc:
- printf("[|dccp]");
-trunc2:
+ ND_PRINT((ndo, "%s", tstr));
return;
}
-static int dccp_print_option(const u_char *option)
-{
- u_int8_t optlen, i;
+static const struct tok dccp_option_values[] = {
+ { 0, "nop" },
+ { 1, "mandatory" },
+ { 2, "slowreceiver" },
+ { 32, "change_l" },
+ { 33, "confirm_l" },
+ { 34, "change_r" },
+ { 35, "confirm_r" },
+ { 36, "initcookie" },
+ { 37, "ndp_count" },
+ { 38, "ack_vector0" },
+ { 39, "ack_vector1" },
+ { 40, "data_dropped" },
+ { 41, "timestamp" },
+ { 42, "timestamp_echo" },
+ { 43, "elapsed_time" },
+ { 44, "data_checksum" },
+ { 0, NULL }
+};
+
+static int dccp_print_option(netdissect_options *ndo, const u_char *option, u_int hlen)
+{
+ uint8_t optlen, i;
- TCHECK(*option);
+ ND_TCHECK(*option);
if (*option >= 32) {
- TCHECK(*(option+1));
+ ND_TCHECK(*(option+1));
optlen = *(option +1);
if (optlen < 2) {
- printf("Option %d optlen too short",*option);
- return 1;
+ if (*option >= 128)
+ ND_PRINT((ndo, "CCID option %u optlen too short", *option));
+ else
+ ND_PRINT((ndo, "%s optlen too short",
+ tok2str(dccp_option_values, "Option %u", *option)));
+ return 0;
}
- } else optlen = 1;
-
- TCHECK2(*option,optlen);
-
- switch (*option){
- case 0:
- printf("nop");
- break;
- case 1:
- printf("mandatory");
- break;
- case 2:
- printf("slowreceiver");
- break;
- case 32:
- printf("change_l");
- if (*(option +2) < 10){
- printf(" %s", dccp_feature_nums[*(option +2)]);
- for (i = 0; i < optlen -3; i ++) printf(" %d", *(option +3 + i));
- }
- break;
- case 33:
- printf("confirm_l");
- if (*(option +2) < 10){
- printf(" %s", dccp_feature_nums[*(option +2)]);
- for (i = 0; i < optlen -3; i ++) printf(" %d", *(option +3 + i));
- }
- break;
- case 34:
- printf("change_r");
- if (*(option +2) < 10){
- printf(" %s", dccp_feature_nums[*(option +2)]);
- for (i = 0; i < optlen -3; i ++) printf(" %d", *(option +3 + i));
- }
- break;
- case 35:
- printf("confirm_r");
- if (*(option +2) < 10){
- printf(" %s", dccp_feature_nums[*(option +2)]);
- for (i = 0; i < optlen -3; i ++) printf(" %d", *(option +3 + i));
- }
- break;
- case 36:
- printf("initcookie 0x");
- for (i = 0; i < optlen -2; i ++) printf("%02x", *(option +2 + i));
- break;
- case 37:
- printf("ndp_count");
- for (i = 0; i < optlen -2; i ++) printf(" %d", *(option +2 + i));
- break;
- case 38:
- printf("ack_vector0 0x");
- for (i = 0; i < optlen -2; i ++) printf("%02x", *(option +2 + i));
- break;
- case 39:
- printf("ack_vector1 0x");
- for (i = 0; i < optlen -2; i ++) printf("%02x", *(option +2 + i));
- break;
- case 40:
- printf("data_dropped 0x");
- for (i = 0; i < optlen -2; i ++) printf("%02x", *(option +2 + i));
- break;
- case 41:
- printf("timestamp %u", EXTRACT_32BITS(option + 2));
- break;
- case 42:
- printf("timestamp_echo %u", EXTRACT_32BITS(option + 2));
- break;
- case 43:
- printf("elapsed_time ");
- if (optlen == 6)
- printf("%u", EXTRACT_32BITS(option + 2));
+ } else
+ optlen = 1;
+
+ if (hlen < optlen) {
+ if (*option >= 128)
+ ND_PRINT((ndo, "CCID option %u optlen goes past header length",
+ *option));
else
- printf("%u", EXTRACT_16BITS(option + 2));
- break;
- case 44:
- printf("data_checksum ");
- for (i = 0; i < optlen -2; i ++) printf("%02x", *(option +2 + i));
- break;
- default :
- if (*option >= 128) {
- printf("CCID option %d",*option);
- switch (optlen) {
- case 4:
- printf(" %u", EXTRACT_16BITS(option + 2));
- break;
- case 6:
- printf(" %u", EXTRACT_32BITS(option + 2));
- break;
- default:
- break;
+ ND_PRINT((ndo, "%s optlen goes past header length",
+ tok2str(dccp_option_values, "Option %u", *option)));
+ return 0;
+ }
+ ND_TCHECK2(*option, optlen);
+
+ if (*option >= 128) {
+ ND_PRINT((ndo, "CCID option %d", *option));
+ switch (optlen) {
+ case 4:
+ ND_PRINT((ndo, " %u", EXTRACT_16BITS(option + 2)));
+ break;
+ case 6:
+ ND_PRINT((ndo, " %u", EXTRACT_32BITS(option + 2)));
+ break;
+ default:
+ break;
+ }
+ } else {
+ ND_PRINT((ndo, "%s", tok2str(dccp_option_values, "Option %u", *option)));
+ switch (*option) {
+ case 32:
+ case 33:
+ case 34:
+ case 35:
+ if (optlen < 3) {
+ ND_PRINT((ndo, " optlen too short"));
+ return optlen;
+ }
+ if (*(option + 2) < 10){
+ ND_PRINT((ndo, " %s", dccp_feature_nums[*(option + 2)]));
+ for (i = 0; i < optlen - 3; i++)
+ ND_PRINT((ndo, " %d", *(option + 3 + i)));
+ }
+ break;
+ case 36:
+ if (optlen > 2) {
+ ND_PRINT((ndo, " 0x"));
+ for (i = 0; i < optlen - 2; i++)
+ ND_PRINT((ndo, "%02x", *(option + 2 + i)));
+ }
+ break;
+ case 37:
+ for (i = 0; i < optlen - 2; i++)
+ ND_PRINT((ndo, " %d", *(option + 2 + i)));
+ break;
+ case 38:
+ if (optlen > 2) {
+ ND_PRINT((ndo, " 0x"));
+ for (i = 0; i < optlen - 2; i++)
+ ND_PRINT((ndo, "%02x", *(option + 2 + i)));
+ }
+ break;
+ case 39:
+ if (optlen > 2) {
+ ND_PRINT((ndo, " 0x"));
+ for (i = 0; i < optlen - 2; i++)
+ ND_PRINT((ndo, "%02x", *(option + 2 + i)));
+ }
+ break;
+ case 40:
+ if (optlen > 2) {
+ ND_PRINT((ndo, " 0x"));
+ for (i = 0; i < optlen - 2; i++)
+ ND_PRINT((ndo, "%02x", *(option + 2 + i)));
+ }
+ break;
+ case 41:
+ if (optlen == 4)
+ ND_PRINT((ndo, " %u", EXTRACT_32BITS(option + 2)));
+ else
+ ND_PRINT((ndo, " optlen != 4"));
+ break;
+ case 42:
+ if (optlen == 4)
+ ND_PRINT((ndo, " %u", EXTRACT_32BITS(option + 2)));
+ else
+ ND_PRINT((ndo, " optlen != 4"));
+ break;
+ case 43:
+ if (optlen == 6)
+ ND_PRINT((ndo, " %u", EXTRACT_32BITS(option + 2)));
+ else if (optlen == 4)
+ ND_PRINT((ndo, " %u", EXTRACT_16BITS(option + 2)));
+ else
+ ND_PRINT((ndo, " optlen != 4 or 6"));
+ break;
+ case 44:
+ if (optlen > 2) {
+ ND_PRINT((ndo, " "));
+ for (i = 0; i < optlen - 2; i++)
+ ND_PRINT((ndo, "%02x", *(option + 2 + i)));
}
break;
}
-
- printf("unknown_opt %d", *option);
- break;
}
return optlen;
trunc:
- printf("[|dccp]");
+ ND_PRINT((ndo, "%s", tstr));
return 0;
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-dccp-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-decnet.c b/freebsd/contrib/tcpdump/print-decnet.c
index f453381c..cdfca50d 100644
--- a/freebsd/contrib/tcpdump/print-decnet.c
+++ b/freebsd/contrib/tcpdump/print-decnet.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1992, 1993, 1994, 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
@@ -21,16 +24,13 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-decnet.c,v 1.39 2005-05-06 02:16:26 guy Exp $ (LBL)";
-#endif
+/* \summary: DECnet printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
struct mbuf;
struct rtentry;
@@ -43,31 +43,468 @@ struct rtentry;
#include <stdlib.h>
#include <string.h>
-#include "decnet.h"
#include "extract.h"
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
+static const char tstr[] = "[|decnet]";
+
+#ifndef _WIN32
+typedef uint8_t byte[1]; /* single byte field */
+#else
+/*
+ * the keyword 'byte' generates conflicts in Windows
+ */
+typedef unsigned char Byte[1]; /* single byte field */
+#define byte Byte
+#endif /* _WIN32 */
+typedef uint8_t word[2]; /* 2 byte field */
+typedef uint8_t longword[4]; /* 4 bytes field */
+
+/*
+ * Definitions for DECNET Phase IV protocol headers
+ */
+union etheraddress {
+ uint8_t dne_addr[6]; /* full ethernet address */
+ struct {
+ uint8_t dne_hiord[4]; /* DECnet HIORD prefix */
+ uint8_t dne_nodeaddr[2]; /* DECnet node address */
+ } dne_remote;
+};
+
+typedef union etheraddress etheraddr; /* Ethernet address */
+
+#define HIORD 0x000400aa /* high 32-bits of address (swapped) */
+
+#define AREAMASK 0176000 /* mask for area field */
+#define AREASHIFT 10 /* bit-offset for area field */
+#define NODEMASK 01777 /* mask for node address field */
+
+#define DN_MAXADDL 20 /* max size of DECnet address */
+struct dn_naddr {
+ uint16_t a_len; /* length of address */
+ uint8_t a_addr[DN_MAXADDL]; /* address as bytes */
+};
+
+/*
+ * Define long and short header formats.
+ */
+struct shorthdr
+ {
+ byte sh_flags; /* route flags */
+ word sh_dst; /* destination node address */
+ word sh_src; /* source node address */
+ byte sh_visits; /* visit count */
+ };
+
+struct longhdr
+ {
+ byte lg_flags; /* route flags */
+ byte lg_darea; /* destination area (reserved) */
+ byte lg_dsarea; /* destination subarea (reserved) */
+ etheraddr lg_dst; /* destination id */
+ byte lg_sarea; /* source area (reserved) */
+ byte lg_ssarea; /* source subarea (reserved) */
+ etheraddr lg_src; /* source id */
+ byte lg_nextl2; /* next level 2 router (reserved) */
+ byte lg_visits; /* visit count */
+ byte lg_service; /* service class (reserved) */
+ byte lg_pt; /* protocol type (reserved) */
+ };
+
+union routehdr
+ {
+ struct shorthdr rh_short; /* short route header */
+ struct longhdr rh_long; /* long route header */
+ };
+
+/*
+ * Define the values of various fields in the protocol messages.
+ *
+ * 1. Data packet formats.
+ */
+#define RMF_MASK 7 /* mask for message type */
+#define RMF_SHORT 2 /* short message format */
+#define RMF_LONG 6 /* long message format */
+#ifndef RMF_RQR
+#define RMF_RQR 010 /* request return to sender */
+#define RMF_RTS 020 /* returning to sender */
+#define RMF_IE 040 /* intra-ethernet packet */
+#endif /* RMR_RQR */
+#define RMF_FVER 0100 /* future version flag */
+#define RMF_PAD 0200 /* pad field */
+#define RMF_PADMASK 0177 /* pad field mask */
+
+#define VIS_MASK 077 /* visit field mask */
+
+/*
+ * 2. Control packet formats.
+ */
+#define RMF_CTLMASK 017 /* mask for message type */
+#define RMF_CTLMSG 01 /* control message indicator */
+#define RMF_INIT 01 /* initialization message */
+#define RMF_VER 03 /* verification message */
+#define RMF_TEST 05 /* hello and test message */
+#define RMF_L1ROUT 07 /* level 1 routing message */
+#define RMF_L2ROUT 011 /* level 2 routing message */
+#define RMF_RHELLO 013 /* router hello message */
+#define RMF_EHELLO 015 /* endnode hello message */
+
+#define TI_L2ROUT 01 /* level 2 router */
+#define TI_L1ROUT 02 /* level 1 router */
+#define TI_ENDNODE 03 /* endnode */
+#define TI_VERIF 04 /* verification required */
+#define TI_BLOCK 010 /* blocking requested */
+
+#define VE_VERS 2 /* version number (2) */
+#define VE_ECO 0 /* ECO number */
+#define VE_UECO 0 /* user ECO number (0) */
+
+#define P3_VERS 1 /* phase III version number (1) */
+#define P3_ECO 3 /* ECO number (3) */
+#define P3_UECO 0 /* user ECO number (0) */
+
+#define II_L2ROUT 01 /* level 2 router */
+#define II_L1ROUT 02 /* level 1 router */
+#define II_ENDNODE 03 /* endnode */
+#define II_VERIF 04 /* verification required */
+#define II_NOMCAST 040 /* no multicast traffic accepted */
+#define II_BLOCK 0100 /* blocking requested */
+#define II_TYPEMASK 03 /* mask for node type */
+
+#define TESTDATA 0252 /* test data bytes */
+#define TESTLEN 1 /* length of transmitted test data */
+
+/*
+ * Define control message formats.
+ */
+struct initmsgIII /* phase III initialization message */
+ {
+ byte inIII_flags; /* route flags */
+ word inIII_src; /* source node address */
+ byte inIII_info; /* routing layer information */
+ word inIII_blksize; /* maximum data link block size */
+ byte inIII_vers; /* version number */
+ byte inIII_eco; /* ECO number */
+ byte inIII_ueco; /* user ECO number */
+ byte inIII_rsvd; /* reserved image field */
+ };
+
+struct initmsg /* initialization message */
+ {
+ byte in_flags; /* route flags */
+ word in_src; /* source node address */
+ byte in_info; /* routing layer information */
+ word in_blksize; /* maximum data link block size */
+ byte in_vers; /* version number */
+ byte in_eco; /* ECO number */
+ byte in_ueco; /* user ECO number */
+ word in_hello; /* hello timer */
+ byte in_rsvd; /* reserved image field */
+ };
+
+struct verifmsg /* verification message */
+ {
+ byte ve_flags; /* route flags */
+ word ve_src; /* source node address */
+ byte ve_fcnval; /* function value image field */
+ };
+
+struct testmsg /* hello and test message */
+ {
+ byte te_flags; /* route flags */
+ word te_src; /* source node address */
+ byte te_data; /* test data image field */
+ };
+
+struct l1rout /* level 1 routing message */
+ {
+ byte r1_flags; /* route flags */
+ word r1_src; /* source node address */
+ byte r1_rsvd; /* reserved field */
+ };
+
+struct l2rout /* level 2 routing message */
+ {
+ byte r2_flags; /* route flags */
+ word r2_src; /* source node address */
+ byte r2_rsvd; /* reserved field */
+ };
+
+struct rhellomsg /* router hello message */
+ {
+ byte rh_flags; /* route flags */
+ byte rh_vers; /* version number */
+ byte rh_eco; /* ECO number */
+ byte rh_ueco; /* user ECO number */
+ etheraddr rh_src; /* source id */
+ byte rh_info; /* routing layer information */
+ word rh_blksize; /* maximum data link block size */
+ byte rh_priority; /* router's priority */
+ byte rh_area; /* reserved */
+ word rh_hello; /* hello timer */
+ byte rh_mpd; /* reserved */
+ };
+
+struct ehellomsg /* endnode hello message */
+ {
+ byte eh_flags; /* route flags */
+ byte eh_vers; /* version number */
+ byte eh_eco; /* ECO number */
+ byte eh_ueco; /* user ECO number */
+ etheraddr eh_src; /* source id */
+ byte eh_info; /* routing layer information */
+ word eh_blksize; /* maximum data link block size */
+ byte eh_area; /* area (reserved) */
+ byte eh_seed[8]; /* verification seed */
+ etheraddr eh_router; /* designated router */
+ word eh_hello; /* hello timer */
+ byte eh_mpd; /* (reserved) */
+ byte eh_data; /* test data image field */
+ };
+
+union controlmsg
+ {
+ struct initmsg cm_init; /* initialization message */
+ struct verifmsg cm_ver; /* verification message */
+ struct testmsg cm_test; /* hello and test message */
+ struct l1rout cm_l1rou; /* level 1 routing message */
+ struct l2rout cm_l2rout; /* level 2 routing message */
+ struct rhellomsg cm_rhello; /* router hello message */
+ struct ehellomsg cm_ehello; /* endnode hello message */
+ };
+
+/* Macros for decoding routing-info fields */
+#define RI_COST(x) ((x)&0777)
+#define RI_HOPS(x) (((x)>>10)&037)
+
+/*
+ * NSP protocol fields and values.
+ */
+
+#define NSP_TYPEMASK 014 /* mask to isolate type code */
+#define NSP_SUBMASK 0160 /* mask to isolate subtype code */
+#define NSP_SUBSHFT 4 /* shift to move subtype code */
+
+#define MFT_DATA 0 /* data message */
+#define MFT_ACK 04 /* acknowledgement message */
+#define MFT_CTL 010 /* control message */
+
+#define MFS_ILS 020 /* data or I/LS indicator */
+#define MFS_BOM 040 /* beginning of message (data) */
+#define MFS_MOM 0 /* middle of message (data) */
+#define MFS_EOM 0100 /* end of message (data) */
+#define MFS_INT 040 /* interrupt message */
+
+#define MFS_DACK 0 /* data acknowledgement */
+#define MFS_IACK 020 /* I/LS acknowledgement */
+#define MFS_CACK 040 /* connect acknowledgement */
+
+#define MFS_NOP 0 /* no operation */
+#define MFS_CI 020 /* connect initiate */
+#define MFS_CC 040 /* connect confirm */
+#define MFS_DI 060 /* disconnect initiate */
+#define MFS_DC 0100 /* disconnect confirm */
+#define MFS_RCI 0140 /* retransmitted connect initiate */
+
+#define SGQ_ACK 0100000 /* ack */
+#define SGQ_NAK 0110000 /* negative ack */
+#define SGQ_OACK 0120000 /* other channel ack */
+#define SGQ_ONAK 0130000 /* other channel negative ack */
+#define SGQ_MASK 07777 /* mask to isolate seq # */
+#define SGQ_OTHER 020000 /* other channel qualifier */
+#define SGQ_DELAY 010000 /* ack delay flag */
+
+#define SGQ_EOM 0100000 /* pseudo flag for end-of-message */
+
+#define LSM_MASK 03 /* mask for modifier field */
+#define LSM_NOCHANGE 0 /* no change */
+#define LSM_DONOTSEND 1 /* do not send data */
+#define LSM_SEND 2 /* send data */
+
+#define LSI_MASK 014 /* mask for interpretation field */
+#define LSI_DATA 0 /* data segment or message count */
+#define LSI_INTR 4 /* interrupt request count */
+#define LSI_INTM 0377 /* funny marker for int. message */
+
+#define COS_MASK 014 /* mask for flow control field */
+#define COS_NONE 0 /* no flow control */
+#define COS_SEGMENT 04 /* segment flow control */
+#define COS_MESSAGE 010 /* message flow control */
+#define COS_DEFAULT 1 /* default value for field */
+
+#define COI_MASK 3 /* mask for version field */
+#define COI_32 0 /* version 3.2 */
+#define COI_31 1 /* version 3.1 */
+#define COI_40 2 /* version 4.0 */
+#define COI_41 3 /* version 4.1 */
+
+#define MNU_MASK 140 /* mask for session control version */
+#define MNU_10 000 /* session V1.0 */
+#define MNU_20 040 /* session V2.0 */
+#define MNU_ACCESS 1 /* access control present */
+#define MNU_USRDATA 2 /* user data field present */
+#define MNU_INVKPROXY 4 /* invoke proxy field present */
+#define MNU_UICPROXY 8 /* use uic-based proxy */
+
+#define DC_NORESOURCES 1 /* no resource reason code */
+#define DC_NOLINK 41 /* no link terminate reason code */
+#define DC_COMPLETE 42 /* disconnect complete reason code */
+
+#define DI_NOERROR 0 /* user disconnect */
+#define DI_SHUT 3 /* node is shutting down */
+#define DI_NOUSER 4 /* destination end user does not exist */
+#define DI_INVDEST 5 /* invalid end user destination */
+#define DI_REMRESRC 6 /* insufficient remote resources */
+#define DI_TPA 8 /* third party abort */
+#define DI_PROTOCOL 7 /* protocol error discovered */
+#define DI_ABORT 9 /* user abort */
+#define DI_LOCALRESRC 32 /* insufficient local resources */
+#define DI_REMUSERRESRC 33 /* insufficient remote user resources */
+#define DI_BADACCESS 34 /* bad access control information */
+#define DI_BADACCNT 36 /* bad ACCOUNT information */
+#define DI_CONNECTABORT 38 /* connect request cancelled */
+#define DI_TIMEDOUT 38 /* remote node or user crashed */
+#define DI_UNREACHABLE 39 /* local timers expired due to ... */
+#define DI_BADIMAGE 43 /* bad image data in connect */
+#define DI_SERVMISMATCH 54 /* cryptographic service mismatch */
+
+#define UC_OBJREJECT 0 /* object rejected connect */
+#define UC_USERDISCONNECT 0 /* user disconnect */
+#define UC_RESOURCES 1 /* insufficient resources (local or remote) */
+#define UC_NOSUCHNODE 2 /* unrecognized node name */
+#define UC_REMOTESHUT 3 /* remote node shutting down */
+#define UC_NOSUCHOBJ 4 /* unrecognized object */
+#define UC_INVOBJFORMAT 5 /* invalid object name format */
+#define UC_OBJTOOBUSY 6 /* object too busy */
+#define UC_NETWORKABORT 8 /* network abort */
+#define UC_USERABORT 9 /* user abort */
+#define UC_INVNODEFORMAT 10 /* invalid node name format */
+#define UC_LOCALSHUT 11 /* local node shutting down */
+#define UC_ACCESSREJECT 34 /* invalid access control information */
+#define UC_NORESPONSE 38 /* no response from object */
+#define UC_UNREACHABLE 39 /* node unreachable */
+
+/*
+ * NSP message formats.
+ */
+struct nsphdr /* general nsp header */
+ {
+ byte nh_flags; /* message flags */
+ word nh_dst; /* destination link address */
+ word nh_src; /* source link address */
+ };
+
+struct seghdr /* data segment header */
+ {
+ byte sh_flags; /* message flags */
+ word sh_dst; /* destination link address */
+ word sh_src; /* source link address */
+ word sh_seq[3]; /* sequence numbers */
+ };
+
+struct minseghdr /* minimum data segment header */
+ {
+ byte ms_flags; /* message flags */
+ word ms_dst; /* destination link address */
+ word ms_src; /* source link address */
+ word ms_seq; /* sequence number */
+ };
+
+struct lsmsg /* link service message (after hdr) */
+ {
+ byte ls_lsflags; /* link service flags */
+ byte ls_fcval; /* flow control value */
+ };
+
+struct ackmsg /* acknowledgement message */
+ {
+ byte ak_flags; /* message flags */
+ word ak_dst; /* destination link address */
+ word ak_src; /* source link address */
+ word ak_acknum[2]; /* acknowledgement numbers */
+ };
+
+struct minackmsg /* minimum acknowledgement message */
+ {
+ byte mk_flags; /* message flags */
+ word mk_dst; /* destination link address */
+ word mk_src; /* source link address */
+ word mk_acknum; /* acknowledgement number */
+ };
+
+struct ciackmsg /* connect acknowledgement message */
+ {
+ byte ck_flags; /* message flags */
+ word ck_dst; /* destination link address */
+ };
+
+struct cimsg /* connect initiate message */
+ {
+ byte ci_flags; /* message flags */
+ word ci_dst; /* destination link address (0) */
+ word ci_src; /* source link address */
+ byte ci_services; /* requested services */
+ byte ci_info; /* information */
+ word ci_segsize; /* maximum segment size */
+ };
+
+struct ccmsg /* connect confirm message */
+ {
+ byte cc_flags; /* message flags */
+ word cc_dst; /* destination link address */
+ word cc_src; /* source link address */
+ byte cc_services; /* requested services */
+ byte cc_info; /* information */
+ word cc_segsize; /* maximum segment size */
+ byte cc_optlen; /* optional data length */
+ };
+
+struct cnmsg /* generic connect message */
+ {
+ byte cn_flags; /* message flags */
+ word cn_dst; /* destination link address */
+ word cn_src; /* source link address */
+ byte cn_services; /* requested services */
+ byte cn_info; /* information */
+ word cn_segsize; /* maximum segment size */
+ };
+
+struct dimsg /* disconnect initiate message */
+ {
+ byte di_flags; /* message flags */
+ word di_dst; /* destination link address */
+ word di_src; /* source link address */
+ word di_reason; /* reason code */
+ byte di_optlen; /* optional data length */
+ };
+
+struct dcmsg /* disconnect confirm message */
+ {
+ byte dc_flags; /* message flags */
+ word dc_dst; /* destination link address */
+ word dc_src; /* source link address */
+ word dc_reason; /* reason code */
+ };
+
/* Forwards */
-static int print_decnet_ctlmsg(const union routehdr *, u_int, u_int);
-static void print_t_info(int);
-static int print_l1_routes(const char *, u_int);
-static int print_l2_routes(const char *, u_int);
-static void print_i_info(int);
+static int print_decnet_ctlmsg(netdissect_options *, const union routehdr *, u_int, u_int);
+static void print_t_info(netdissect_options *, int);
+static int print_l1_routes(netdissect_options *, const char *, u_int);
+static int print_l2_routes(netdissect_options *, const char *, u_int);
+static void print_i_info(netdissect_options *, int);
static int print_elist(const char *, u_int);
-static int print_nsp(const u_char *, u_int);
-static void print_reason(int);
-#ifdef PRINT_NSPDATA
-static void pdata(u_char *, int);
-#endif
+static int print_nsp(netdissect_options *, const u_char *, u_int);
+static void print_reason(netdissect_options *, int);
#ifndef HAVE_NETDNET_DNETDB_H_DNET_HTOA
extern char *dnet_htoa(struct dn_naddr *);
#endif
void
-decnet_print(register const u_char *ap, register u_int length,
- register u_int caplen)
+decnet_print(netdissect_options *ndo,
+ register const u_char *ap, register u_int length,
+ register u_int caplen)
{
register const union routehdr *rhp;
register int mflags;
@@ -76,36 +513,36 @@ decnet_print(register const u_char *ap, register u_int length,
const u_char *nspp;
if (length < sizeof(struct shorthdr)) {
- (void)printf("[|decnet]");
+ ND_PRINT((ndo, "%s", tstr));
return;
}
- TCHECK2(*ap, sizeof(short));
+ ND_TCHECK2(*ap, sizeof(short));
pktlen = EXTRACT_LE_16BITS(ap);
if (pktlen < sizeof(struct shorthdr)) {
- (void)printf("[|decnet]");
+ ND_PRINT((ndo, "%s", tstr));
return;
}
if (pktlen > length) {
- (void)printf("[|decnet]");
+ ND_PRINT((ndo, "%s", tstr));
return;
}
length = pktlen;
rhp = (const union routehdr *)&(ap[sizeof(short)]);
- TCHECK(rhp->rh_short.sh_flags);
+ ND_TCHECK(rhp->rh_short.sh_flags);
mflags = EXTRACT_LE_8BITS(rhp->rh_short.sh_flags);
if (mflags & RMF_PAD) {
/* pad bytes of some sort in front of message */
u_int padlen = mflags & RMF_PADMASK;
- if (vflag)
- (void) printf("[pad:%d] ", padlen);
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo, "[pad:%d] ", padlen));
if (length < padlen + 2) {
- (void)printf("[|decnet]");
+ ND_PRINT((ndo, "%s", tstr));
return;
}
- TCHECK2(ap[sizeof(short)], padlen);
+ ND_TCHECK2(ap[sizeof(short)], padlen);
ap += padlen;
length -= padlen;
caplen -= padlen;
@@ -114,14 +551,14 @@ decnet_print(register const u_char *ap, register u_int length,
}
if (mflags & RMF_FVER) {
- (void) printf("future-version-decnet");
- default_print(ap, min(length, caplen));
+ ND_PRINT((ndo, "future-version-decnet"));
+ ND_DEFAULTPRINT(ap, min(length, caplen));
return;
}
/* is it a control message? */
if (mflags & RMF_CTLMSG) {
- if (!print_decnet_ctlmsg(rhp, length, caplen))
+ if (!print_decnet_ctlmsg(ndo, rhp, length, caplen))
goto trunc;
return;
}
@@ -129,10 +566,10 @@ decnet_print(register const u_char *ap, register u_int length,
switch (mflags & RMF_MASK) {
case RMF_LONG:
if (length < sizeof(struct longhdr)) {
- (void)printf("[|decnet]");
+ ND_PRINT((ndo, "%s", tstr));
return;
}
- TCHECK(rhp->rh_long);
+ ND_TCHECK(rhp->rh_long);
dst =
EXTRACT_LE_16BITS(rhp->rh_long.lg_dst.dne_remote.dne_nodeaddr);
src =
@@ -142,7 +579,7 @@ decnet_print(register const u_char *ap, register u_int length,
nsplen = length - sizeof(struct longhdr);
break;
case RMF_SHORT:
- TCHECK(rhp->rh_short);
+ ND_TCHECK(rhp->rh_short);
dst = EXTRACT_LE_16BITS(rhp->rh_short.sh_dst);
src = EXTRACT_LE_16BITS(rhp->rh_short.sh_src);
hops = (EXTRACT_LE_8BITS(rhp->rh_short.sh_visits) & VIS_MASK)+1;
@@ -150,50 +587,51 @@ decnet_print(register const u_char *ap, register u_int length,
nsplen = length - sizeof(struct shorthdr);
break;
default:
- (void) printf("unknown message flags under mask");
- default_print((u_char *)ap, min(length, caplen));
+ ND_PRINT((ndo, "unknown message flags under mask"));
+ ND_DEFAULTPRINT((const u_char *)ap, min(length, caplen));
return;
}
- (void)printf("%s > %s %d ",
- dnaddr_string(src), dnaddr_string(dst), pktlen);
- if (vflag) {
+ ND_PRINT((ndo, "%s > %s %d ",
+ dnaddr_string(ndo, src), dnaddr_string(ndo, dst), pktlen));
+ if (ndo->ndo_vflag) {
if (mflags & RMF_RQR)
- (void)printf("RQR ");
+ ND_PRINT((ndo, "RQR "));
if (mflags & RMF_RTS)
- (void)printf("RTS ");
+ ND_PRINT((ndo, "RTS "));
if (mflags & RMF_IE)
- (void)printf("IE ");
- (void)printf("%d hops ", hops);
+ ND_PRINT((ndo, "IE "));
+ ND_PRINT((ndo, "%d hops ", hops));
}
- if (!print_nsp(nspp, nsplen))
+ if (!print_nsp(ndo, nspp, nsplen))
goto trunc;
return;
trunc:
- (void)printf("[|decnet]");
+ ND_PRINT((ndo, "%s", tstr));
return;
}
static int
-print_decnet_ctlmsg(register const union routehdr *rhp, u_int length,
- u_int caplen)
+print_decnet_ctlmsg(netdissect_options *ndo,
+ register const union routehdr *rhp, u_int length,
+ u_int caplen)
{
int mflags = EXTRACT_LE_8BITS(rhp->rh_short.sh_flags);
- register union controlmsg *cmp = (union controlmsg *)rhp;
+ register const union controlmsg *cmp = (const union controlmsg *)rhp;
int src, dst, info, blksize, eco, ueco, hello, other, vers;
etheraddr srcea, rtea;
int priority;
- char *rhpx = (char *)rhp;
+ const char *rhpx = (const char *)rhp;
int ret;
switch (mflags & RMF_CTLMASK) {
case RMF_INIT:
- (void)printf("init ");
+ ND_PRINT((ndo, "init "));
if (length < sizeof(struct initmsg))
goto trunc;
- TCHECK(cmp->cm_init);
+ ND_TCHECK(cmp->cm_init);
src = EXTRACT_LE_16BITS(cmp->cm_init.in_src);
info = EXTRACT_LE_8BITS(cmp->cm_init.in_info);
blksize = EXTRACT_LE_16BITS(cmp->cm_init.in_blksize);
@@ -201,106 +639,106 @@ print_decnet_ctlmsg(register const union routehdr *rhp, u_int length,
eco = EXTRACT_LE_8BITS(cmp->cm_init.in_eco);
ueco = EXTRACT_LE_8BITS(cmp->cm_init.in_ueco);
hello = EXTRACT_LE_16BITS(cmp->cm_init.in_hello);
- print_t_info(info);
- (void)printf(
+ print_t_info(ndo, info);
+ ND_PRINT((ndo,
"src %sblksize %d vers %d eco %d ueco %d hello %d",
- dnaddr_string(src), blksize, vers, eco, ueco,
- hello);
+ dnaddr_string(ndo, src), blksize, vers, eco, ueco,
+ hello));
ret = 1;
break;
case RMF_VER:
- (void)printf("verification ");
+ ND_PRINT((ndo, "verification "));
if (length < sizeof(struct verifmsg))
goto trunc;
- TCHECK(cmp->cm_ver);
+ ND_TCHECK(cmp->cm_ver);
src = EXTRACT_LE_16BITS(cmp->cm_ver.ve_src);
other = EXTRACT_LE_8BITS(cmp->cm_ver.ve_fcnval);
- (void)printf("src %s fcnval %o", dnaddr_string(src), other);
+ ND_PRINT((ndo, "src %s fcnval %o", dnaddr_string(ndo, src), other));
ret = 1;
break;
case RMF_TEST:
- (void)printf("test ");
+ ND_PRINT((ndo, "test "));
if (length < sizeof(struct testmsg))
goto trunc;
- TCHECK(cmp->cm_test);
+ ND_TCHECK(cmp->cm_test);
src = EXTRACT_LE_16BITS(cmp->cm_test.te_src);
other = EXTRACT_LE_8BITS(cmp->cm_test.te_data);
- (void)printf("src %s data %o", dnaddr_string(src), other);
+ ND_PRINT((ndo, "src %s data %o", dnaddr_string(ndo, src), other));
ret = 1;
break;
case RMF_L1ROUT:
- (void)printf("lev-1-routing ");
+ ND_PRINT((ndo, "lev-1-routing "));
if (length < sizeof(struct l1rout))
goto trunc;
- TCHECK(cmp->cm_l1rou);
+ ND_TCHECK(cmp->cm_l1rou);
src = EXTRACT_LE_16BITS(cmp->cm_l1rou.r1_src);
- (void)printf("src %s ", dnaddr_string(src));
- ret = print_l1_routes(&(rhpx[sizeof(struct l1rout)]),
+ ND_PRINT((ndo, "src %s ", dnaddr_string(ndo, src)));
+ ret = print_l1_routes(ndo, &(rhpx[sizeof(struct l1rout)]),
length - sizeof(struct l1rout));
break;
case RMF_L2ROUT:
- (void)printf("lev-2-routing ");
+ ND_PRINT((ndo, "lev-2-routing "));
if (length < sizeof(struct l2rout))
goto trunc;
- TCHECK(cmp->cm_l2rout);
+ ND_TCHECK(cmp->cm_l2rout);
src = EXTRACT_LE_16BITS(cmp->cm_l2rout.r2_src);
- (void)printf("src %s ", dnaddr_string(src));
- ret = print_l2_routes(&(rhpx[sizeof(struct l2rout)]),
+ ND_PRINT((ndo, "src %s ", dnaddr_string(ndo, src)));
+ ret = print_l2_routes(ndo, &(rhpx[sizeof(struct l2rout)]),
length - sizeof(struct l2rout));
break;
case RMF_RHELLO:
- (void)printf("router-hello ");
+ ND_PRINT((ndo, "router-hello "));
if (length < sizeof(struct rhellomsg))
goto trunc;
- TCHECK(cmp->cm_rhello);
+ ND_TCHECK(cmp->cm_rhello);
vers = EXTRACT_LE_8BITS(cmp->cm_rhello.rh_vers);
eco = EXTRACT_LE_8BITS(cmp->cm_rhello.rh_eco);
ueco = EXTRACT_LE_8BITS(cmp->cm_rhello.rh_ueco);
- memcpy((char *)&srcea, (char *)&(cmp->cm_rhello.rh_src),
+ memcpy((char *)&srcea, (const char *)&(cmp->cm_rhello.rh_src),
sizeof(srcea));
src = EXTRACT_LE_16BITS(srcea.dne_remote.dne_nodeaddr);
info = EXTRACT_LE_8BITS(cmp->cm_rhello.rh_info);
blksize = EXTRACT_LE_16BITS(cmp->cm_rhello.rh_blksize);
priority = EXTRACT_LE_8BITS(cmp->cm_rhello.rh_priority);
hello = EXTRACT_LE_16BITS(cmp->cm_rhello.rh_hello);
- print_i_info(info);
- (void)printf(
+ print_i_info(ndo, info);
+ ND_PRINT((ndo,
"vers %d eco %d ueco %d src %s blksize %d pri %d hello %d",
- vers, eco, ueco, dnaddr_string(src),
- blksize, priority, hello);
+ vers, eco, ueco, dnaddr_string(ndo, src),
+ blksize, priority, hello));
ret = print_elist(&(rhpx[sizeof(struct rhellomsg)]),
length - sizeof(struct rhellomsg));
break;
case RMF_EHELLO:
- (void)printf("endnode-hello ");
+ ND_PRINT((ndo, "endnode-hello "));
if (length < sizeof(struct ehellomsg))
goto trunc;
- TCHECK(cmp->cm_ehello);
+ ND_TCHECK(cmp->cm_ehello);
vers = EXTRACT_LE_8BITS(cmp->cm_ehello.eh_vers);
eco = EXTRACT_LE_8BITS(cmp->cm_ehello.eh_eco);
ueco = EXTRACT_LE_8BITS(cmp->cm_ehello.eh_ueco);
- memcpy((char *)&srcea, (char *)&(cmp->cm_ehello.eh_src),
+ memcpy((char *)&srcea, (const char *)&(cmp->cm_ehello.eh_src),
sizeof(srcea));
src = EXTRACT_LE_16BITS(srcea.dne_remote.dne_nodeaddr);
info = EXTRACT_LE_8BITS(cmp->cm_ehello.eh_info);
blksize = EXTRACT_LE_16BITS(cmp->cm_ehello.eh_blksize);
/*seed*/
- memcpy((char *)&rtea, (char *)&(cmp->cm_ehello.eh_router),
+ memcpy((char *)&rtea, (const char *)&(cmp->cm_ehello.eh_router),
sizeof(rtea));
dst = EXTRACT_LE_16BITS(rtea.dne_remote.dne_nodeaddr);
hello = EXTRACT_LE_16BITS(cmp->cm_ehello.eh_hello);
other = EXTRACT_LE_8BITS(cmp->cm_ehello.eh_data);
- print_i_info(info);
- (void)printf(
+ print_i_info(ndo, info);
+ ND_PRINT((ndo,
"vers %d eco %d ueco %d src %s blksize %d rtr %s hello %d data %o",
- vers, eco, ueco, dnaddr_string(src),
- blksize, dnaddr_string(dst), hello, other);
+ vers, eco, ueco, dnaddr_string(ndo, src),
+ blksize, dnaddr_string(ndo, dst), hello, other));
ret = 1;
break;
default:
- (void)printf("unknown control message");
- default_print((u_char *)rhp, min(length, caplen));
+ ND_PRINT((ndo, "unknown control message"));
+ ND_DEFAULTPRINT((const u_char *)rhp, min(length, caplen));
ret = 1;
break;
}
@@ -311,23 +749,25 @@ trunc:
}
static void
-print_t_info(int info)
+print_t_info(netdissect_options *ndo,
+ int info)
{
int ntype = info & 3;
switch (ntype) {
- case 0: (void)printf("reserved-ntype? "); break;
- case TI_L2ROUT: (void)printf("l2rout "); break;
- case TI_L1ROUT: (void)printf("l1rout "); break;
- case TI_ENDNODE: (void)printf("endnode "); break;
+ case 0: ND_PRINT((ndo, "reserved-ntype? ")); break;
+ case TI_L2ROUT: ND_PRINT((ndo, "l2rout ")); break;
+ case TI_L1ROUT: ND_PRINT((ndo, "l1rout ")); break;
+ case TI_ENDNODE: ND_PRINT((ndo, "endnode ")); break;
}
if (info & TI_VERIF)
- (void)printf("verif ");
+ ND_PRINT((ndo, "verif "));
if (info & TI_BLOCK)
- (void)printf("blo ");
+ ND_PRINT((ndo, "blo "));
}
static int
-print_l1_routes(const char *rp, u_int len)
+print_l1_routes(netdissect_options *ndo,
+ const char *rp, u_int len)
{
int count;
int id;
@@ -335,7 +775,7 @@ print_l1_routes(const char *rp, u_int len)
/* The last short is a checksum */
while (len > (3 * sizeof(short))) {
- TCHECK2(*rp, 3 * sizeof(short));
+ ND_TCHECK2(*rp, 3 * sizeof(short));
count = EXTRACT_LE_16BITS(rp);
if (count > 1024)
return (1); /* seems to be bogus from here on */
@@ -347,8 +787,8 @@ print_l1_routes(const char *rp, u_int len)
info = EXTRACT_LE_16BITS(rp);
rp += sizeof(short);
len -= sizeof(short);
- (void)printf("{ids %d-%d cost %d hops %d} ", id, id + count,
- RI_COST(info), RI_HOPS(info));
+ ND_PRINT((ndo, "{ids %d-%d cost %d hops %d} ", id, id + count,
+ RI_COST(info), RI_HOPS(info)));
}
return (1);
@@ -357,7 +797,8 @@ trunc:
}
static int
-print_l2_routes(const char *rp, u_int len)
+print_l2_routes(netdissect_options *ndo,
+ const char *rp, u_int len)
{
int count;
int area;
@@ -365,7 +806,7 @@ print_l2_routes(const char *rp, u_int len)
/* The last short is a checksum */
while (len > (3 * sizeof(short))) {
- TCHECK2(*rp, 3 * sizeof(short));
+ ND_TCHECK2(*rp, 3 * sizeof(short));
count = EXTRACT_LE_16BITS(rp);
if (count > 1024)
return (1); /* seems to be bogus from here on */
@@ -377,8 +818,8 @@ print_l2_routes(const char *rp, u_int len)
info = EXTRACT_LE_16BITS(rp);
rp += sizeof(short);
len -= sizeof(short);
- (void)printf("{areas %d-%d cost %d hops %d} ", area, area + count,
- RI_COST(info), RI_HOPS(info));
+ ND_PRINT((ndo, "{areas %d-%d cost %d hops %d} ", area, area + count,
+ RI_COST(info), RI_HOPS(info)));
}
return (1);
@@ -387,21 +828,22 @@ trunc:
}
static void
-print_i_info(int info)
+print_i_info(netdissect_options *ndo,
+ int info)
{
int ntype = info & II_TYPEMASK;
switch (ntype) {
- case 0: (void)printf("reserved-ntype? "); break;
- case II_L2ROUT: (void)printf("l2rout "); break;
- case II_L1ROUT: (void)printf("l1rout "); break;
- case II_ENDNODE: (void)printf("endnode "); break;
+ case 0: ND_PRINT((ndo, "reserved-ntype? ")); break;
+ case II_L2ROUT: ND_PRINT((ndo, "l2rout ")); break;
+ case II_L1ROUT: ND_PRINT((ndo, "l1rout ")); break;
+ case II_ENDNODE: ND_PRINT((ndo, "endnode ")); break;
}
if (info & II_VERIF)
- (void)printf("verif ");
+ ND_PRINT((ndo, "verif "));
if (info & II_NOMCAST)
- (void)printf("nomcast ");
+ ND_PRINT((ndo, "nomcast "));
if (info & II_BLOCK)
- (void)printf("blo ");
+ ND_PRINT((ndo, "blo "));
}
static int
@@ -412,14 +854,15 @@ print_elist(const char *elp _U_, u_int len _U_)
}
static int
-print_nsp(const u_char *nspp, u_int nsplen)
+print_nsp(netdissect_options *ndo,
+ const u_char *nspp, u_int nsplen)
{
- const struct nsphdr *nsphp = (struct nsphdr *)nspp;
+ const struct nsphdr *nsphp = (const struct nsphdr *)nspp;
int dst, src, flags;
if (nsplen < sizeof(struct nsphdr))
goto trunc;
- TCHECK(*nsphp);
+ ND_TCHECK(*nsphp);
flags = EXTRACT_LE_8BITS(nsphp->nh_flags);
dst = EXTRACT_LE_16BITS(nsphp->nh_dst);
src = EXTRACT_LE_16BITS(nsphp->nh_src);
@@ -431,219 +874,199 @@ print_nsp(const u_char *nspp, u_int nsplen)
case MFS_MOM:
case MFS_EOM:
case MFS_BOM+MFS_EOM:
- printf("data %d>%d ", src, dst);
+ ND_PRINT((ndo, "data %d>%d ", src, dst));
{
- struct seghdr *shp = (struct seghdr *)nspp;
+ const struct seghdr *shp = (const struct seghdr *)nspp;
int ack;
-#ifdef PRINT_NSPDATA
- u_char *dp;
-#endif
u_int data_off = sizeof(struct minseghdr);
if (nsplen < data_off)
goto trunc;
- TCHECK(shp->sh_seq[0]);
+ ND_TCHECK(shp->sh_seq[0]);
ack = EXTRACT_LE_16BITS(shp->sh_seq[0]);
if (ack & SGQ_ACK) { /* acknum field */
if ((ack & SGQ_NAK) == SGQ_NAK)
- (void)printf("nak %d ", ack & SGQ_MASK);
+ ND_PRINT((ndo, "nak %d ", ack & SGQ_MASK));
else
- (void)printf("ack %d ", ack & SGQ_MASK);
+ ND_PRINT((ndo, "ack %d ", ack & SGQ_MASK));
data_off += sizeof(short);
if (nsplen < data_off)
goto trunc;
- TCHECK(shp->sh_seq[1]);
+ ND_TCHECK(shp->sh_seq[1]);
ack = EXTRACT_LE_16BITS(shp->sh_seq[1]);
if (ack & SGQ_OACK) { /* ackoth field */
if ((ack & SGQ_ONAK) == SGQ_ONAK)
- (void)printf("onak %d ", ack & SGQ_MASK);
+ ND_PRINT((ndo, "onak %d ", ack & SGQ_MASK));
else
- (void)printf("oack %d ", ack & SGQ_MASK);
+ ND_PRINT((ndo, "oack %d ", ack & SGQ_MASK));
data_off += sizeof(short);
if (nsplen < data_off)
goto trunc;
- TCHECK(shp->sh_seq[2]);
+ ND_TCHECK(shp->sh_seq[2]);
ack = EXTRACT_LE_16BITS(shp->sh_seq[2]);
}
}
- (void)printf("seg %d ", ack & SGQ_MASK);
-#ifdef PRINT_NSPDATA
- if (nsplen > data_off) {
- dp = &(nspp[data_off]);
- TCHECK2(*dp, nsplen - data_off);
- pdata(dp, nsplen - data_off);
- }
-#endif
+ ND_PRINT((ndo, "seg %d ", ack & SGQ_MASK));
}
break;
case MFS_ILS+MFS_INT:
- printf("intr ");
+ ND_PRINT((ndo, "intr "));
{
- struct seghdr *shp = (struct seghdr *)nspp;
+ const struct seghdr *shp = (const struct seghdr *)nspp;
int ack;
-#ifdef PRINT_NSPDATA
- u_char *dp;
-#endif
u_int data_off = sizeof(struct minseghdr);
if (nsplen < data_off)
goto trunc;
- TCHECK(shp->sh_seq[0]);
+ ND_TCHECK(shp->sh_seq[0]);
ack = EXTRACT_LE_16BITS(shp->sh_seq[0]);
if (ack & SGQ_ACK) { /* acknum field */
if ((ack & SGQ_NAK) == SGQ_NAK)
- (void)printf("nak %d ", ack & SGQ_MASK);
+ ND_PRINT((ndo, "nak %d ", ack & SGQ_MASK));
else
- (void)printf("ack %d ", ack & SGQ_MASK);
+ ND_PRINT((ndo, "ack %d ", ack & SGQ_MASK));
data_off += sizeof(short);
if (nsplen < data_off)
goto trunc;
- TCHECK(shp->sh_seq[1]);
+ ND_TCHECK(shp->sh_seq[1]);
ack = EXTRACT_LE_16BITS(shp->sh_seq[1]);
if (ack & SGQ_OACK) { /* ackdat field */
if ((ack & SGQ_ONAK) == SGQ_ONAK)
- (void)printf("nakdat %d ", ack & SGQ_MASK);
+ ND_PRINT((ndo, "nakdat %d ", ack & SGQ_MASK));
else
- (void)printf("ackdat %d ", ack & SGQ_MASK);
+ ND_PRINT((ndo, "ackdat %d ", ack & SGQ_MASK));
data_off += sizeof(short);
if (nsplen < data_off)
goto trunc;
- TCHECK(shp->sh_seq[2]);
+ ND_TCHECK(shp->sh_seq[2]);
ack = EXTRACT_LE_16BITS(shp->sh_seq[2]);
}
}
- (void)printf("seg %d ", ack & SGQ_MASK);
-#ifdef PRINT_NSPDATA
- if (nsplen > data_off) {
- dp = &(nspp[data_off]);
- TCHECK2(*dp, nsplen - data_off);
- pdata(dp, nsplen - data_off);
- }
-#endif
+ ND_PRINT((ndo, "seg %d ", ack & SGQ_MASK));
}
break;
case MFS_ILS:
- (void)printf("link-service %d>%d ", src, dst);
+ ND_PRINT((ndo, "link-service %d>%d ", src, dst));
{
- struct seghdr *shp = (struct seghdr *)nspp;
- struct lsmsg *lsmp =
- (struct lsmsg *)&(nspp[sizeof(struct seghdr)]);
+ const struct seghdr *shp = (const struct seghdr *)nspp;
+ const struct lsmsg *lsmp =
+ (const struct lsmsg *)&(nspp[sizeof(struct seghdr)]);
int ack;
int lsflags, fcval;
if (nsplen < sizeof(struct seghdr) + sizeof(struct lsmsg))
goto trunc;
- TCHECK(shp->sh_seq[0]);
+ ND_TCHECK(shp->sh_seq[0]);
ack = EXTRACT_LE_16BITS(shp->sh_seq[0]);
if (ack & SGQ_ACK) { /* acknum field */
if ((ack & SGQ_NAK) == SGQ_NAK)
- (void)printf("nak %d ", ack & SGQ_MASK);
+ ND_PRINT((ndo, "nak %d ", ack & SGQ_MASK));
else
- (void)printf("ack %d ", ack & SGQ_MASK);
- TCHECK(shp->sh_seq[1]);
+ ND_PRINT((ndo, "ack %d ", ack & SGQ_MASK));
+ ND_TCHECK(shp->sh_seq[1]);
ack = EXTRACT_LE_16BITS(shp->sh_seq[1]);
if (ack & SGQ_OACK) { /* ackdat field */
if ((ack & SGQ_ONAK) == SGQ_ONAK)
- (void)printf("nakdat %d ", ack & SGQ_MASK);
+ ND_PRINT((ndo, "nakdat %d ", ack & SGQ_MASK));
else
- (void)printf("ackdat %d ", ack & SGQ_MASK);
- TCHECK(shp->sh_seq[2]);
+ ND_PRINT((ndo, "ackdat %d ", ack & SGQ_MASK));
+ ND_TCHECK(shp->sh_seq[2]);
ack = EXTRACT_LE_16BITS(shp->sh_seq[2]);
}
}
- (void)printf("seg %d ", ack & SGQ_MASK);
- TCHECK(*lsmp);
+ ND_PRINT((ndo, "seg %d ", ack & SGQ_MASK));
+ ND_TCHECK(*lsmp);
lsflags = EXTRACT_LE_8BITS(lsmp->ls_lsflags);
fcval = EXTRACT_LE_8BITS(lsmp->ls_fcval);
switch (lsflags & LSI_MASK) {
case LSI_DATA:
- (void)printf("dat seg count %d ", fcval);
+ ND_PRINT((ndo, "dat seg count %d ", fcval));
switch (lsflags & LSM_MASK) {
case LSM_NOCHANGE:
break;
case LSM_DONOTSEND:
- (void)printf("donotsend-data ");
+ ND_PRINT((ndo, "donotsend-data "));
break;
case LSM_SEND:
- (void)printf("send-data ");
+ ND_PRINT((ndo, "send-data "));
break;
default:
- (void)printf("reserved-fcmod? %x", lsflags);
+ ND_PRINT((ndo, "reserved-fcmod? %x", lsflags));
break;
}
break;
case LSI_INTR:
- (void)printf("intr req count %d ", fcval);
+ ND_PRINT((ndo, "intr req count %d ", fcval));
break;
default:
- (void)printf("reserved-fcval-int? %x", lsflags);
+ ND_PRINT((ndo, "reserved-fcval-int? %x", lsflags));
break;
}
}
break;
default:
- (void)printf("reserved-subtype? %x %d > %d", flags, src, dst);
+ ND_PRINT((ndo, "reserved-subtype? %x %d > %d", flags, src, dst));
break;
}
break;
case MFT_ACK:
switch (flags & NSP_SUBMASK) {
case MFS_DACK:
- (void)printf("data-ack %d>%d ", src, dst);
+ ND_PRINT((ndo, "data-ack %d>%d ", src, dst));
{
- struct ackmsg *amp = (struct ackmsg *)nspp;
+ const struct ackmsg *amp = (const struct ackmsg *)nspp;
int ack;
if (nsplen < sizeof(struct ackmsg))
goto trunc;
- TCHECK(*amp);
+ ND_TCHECK(*amp);
ack = EXTRACT_LE_16BITS(amp->ak_acknum[0]);
if (ack & SGQ_ACK) { /* acknum field */
if ((ack & SGQ_NAK) == SGQ_NAK)
- (void)printf("nak %d ", ack & SGQ_MASK);
+ ND_PRINT((ndo, "nak %d ", ack & SGQ_MASK));
else
- (void)printf("ack %d ", ack & SGQ_MASK);
+ ND_PRINT((ndo, "ack %d ", ack & SGQ_MASK));
ack = EXTRACT_LE_16BITS(amp->ak_acknum[1]);
if (ack & SGQ_OACK) { /* ackoth field */
if ((ack & SGQ_ONAK) == SGQ_ONAK)
- (void)printf("onak %d ", ack & SGQ_MASK);
+ ND_PRINT((ndo, "onak %d ", ack & SGQ_MASK));
else
- (void)printf("oack %d ", ack & SGQ_MASK);
+ ND_PRINT((ndo, "oack %d ", ack & SGQ_MASK));
}
}
}
break;
case MFS_IACK:
- (void)printf("ils-ack %d>%d ", src, dst);
+ ND_PRINT((ndo, "ils-ack %d>%d ", src, dst));
{
- struct ackmsg *amp = (struct ackmsg *)nspp;
+ const struct ackmsg *amp = (const struct ackmsg *)nspp;
int ack;
if (nsplen < sizeof(struct ackmsg))
goto trunc;
- TCHECK(*amp);
+ ND_TCHECK(*amp);
ack = EXTRACT_LE_16BITS(amp->ak_acknum[0]);
if (ack & SGQ_ACK) { /* acknum field */
if ((ack & SGQ_NAK) == SGQ_NAK)
- (void)printf("nak %d ", ack & SGQ_MASK);
+ ND_PRINT((ndo, "nak %d ", ack & SGQ_MASK));
else
- (void)printf("ack %d ", ack & SGQ_MASK);
- TCHECK(amp->ak_acknum[1]);
+ ND_PRINT((ndo, "ack %d ", ack & SGQ_MASK));
+ ND_TCHECK(amp->ak_acknum[1]);
ack = EXTRACT_LE_16BITS(amp->ak_acknum[1]);
if (ack & SGQ_OACK) { /* ackdat field */
if ((ack & SGQ_ONAK) == SGQ_ONAK)
- (void)printf("nakdat %d ", ack & SGQ_MASK);
+ ND_PRINT((ndo, "nakdat %d ", ack & SGQ_MASK));
else
- (void)printf("ackdat %d ", ack & SGQ_MASK);
+ ND_PRINT((ndo, "ackdat %d ", ack & SGQ_MASK));
}
}
}
break;
case MFS_CACK:
- (void)printf("conn-ack %d", dst);
+ ND_PRINT((ndo, "conn-ack %d", dst));
break;
default:
- (void)printf("reserved-acktype? %x %d > %d", flags, src, dst);
+ ND_PRINT((ndo, "reserved-acktype? %x %d > %d", flags, src, dst));
break;
}
break;
@@ -652,20 +1075,17 @@ print_nsp(const u_char *nspp, u_int nsplen)
case MFS_CI:
case MFS_RCI:
if ((flags & NSP_SUBMASK) == MFS_CI)
- (void)printf("conn-initiate ");
+ ND_PRINT((ndo, "conn-initiate "));
else
- (void)printf("retrans-conn-initiate ");
- (void)printf("%d>%d ", src, dst);
+ ND_PRINT((ndo, "retrans-conn-initiate "));
+ ND_PRINT((ndo, "%d>%d ", src, dst));
{
- struct cimsg *cimp = (struct cimsg *)nspp;
+ const struct cimsg *cimp = (const struct cimsg *)nspp;
int services, info, segsize;
-#ifdef PRINT_NSPDATA
- u_char *dp;
-#endif
if (nsplen < sizeof(struct cimsg))
goto trunc;
- TCHECK(*cimp);
+ ND_TCHECK(*cimp);
services = EXTRACT_LE_8BITS(cimp->ci_services);
info = EXTRACT_LE_8BITS(cimp->ci_info);
segsize = EXTRACT_LE_16BITS(cimp->ci_segsize);
@@ -674,52 +1094,39 @@ print_nsp(const u_char *nspp, u_int nsplen)
case COS_NONE:
break;
case COS_SEGMENT:
- (void)printf("seg ");
+ ND_PRINT((ndo, "seg "));
break;
case COS_MESSAGE:
- (void)printf("msg ");
- break;
- case COS_CRYPTSER:
- (void)printf("crypt ");
+ ND_PRINT((ndo, "msg "));
break;
}
switch (info & COI_MASK) {
case COI_32:
- (void)printf("ver 3.2 ");
+ ND_PRINT((ndo, "ver 3.2 "));
break;
case COI_31:
- (void)printf("ver 3.1 ");
+ ND_PRINT((ndo, "ver 3.1 "));
break;
case COI_40:
- (void)printf("ver 4.0 ");
+ ND_PRINT((ndo, "ver 4.0 "));
break;
case COI_41:
- (void)printf("ver 4.1 ");
+ ND_PRINT((ndo, "ver 4.1 "));
break;
}
- (void)printf("segsize %d ", segsize);
-#ifdef PRINT_NSPDATA
- if (nsplen > sizeof(struct cimsg)) {
- dp = &(nspp[sizeof(struct cimsg)]);
- TCHECK2(*dp, nsplen - sizeof(struct cimsg));
- pdata(dp, nsplen - sizeof(struct cimsg));
- }
-#endif
+ ND_PRINT((ndo, "segsize %d ", segsize));
}
break;
case MFS_CC:
- (void)printf("conn-confirm %d>%d ", src, dst);
+ ND_PRINT((ndo, "conn-confirm %d>%d ", src, dst));
{
- struct ccmsg *ccmp = (struct ccmsg *)nspp;
+ const struct ccmsg *ccmp = (const struct ccmsg *)nspp;
int services, info;
u_int segsize, optlen;
-#ifdef PRINT_NSPDATA
- u_char *dp;
-#endif
if (nsplen < sizeof(struct ccmsg))
goto trunc;
- TCHECK(*ccmp);
+ ND_TCHECK(*ccmp);
services = EXTRACT_LE_8BITS(ccmp->cc_services);
info = EXTRACT_LE_8BITS(ccmp->cc_info);
segsize = EXTRACT_LE_16BITS(ccmp->cc_segsize);
@@ -729,90 +1136,70 @@ print_nsp(const u_char *nspp, u_int nsplen)
case COS_NONE:
break;
case COS_SEGMENT:
- (void)printf("seg ");
+ ND_PRINT((ndo, "seg "));
break;
case COS_MESSAGE:
- (void)printf("msg ");
- break;
- case COS_CRYPTSER:
- (void)printf("crypt ");
+ ND_PRINT((ndo, "msg "));
break;
}
switch (info & COI_MASK) {
case COI_32:
- (void)printf("ver 3.2 ");
+ ND_PRINT((ndo, "ver 3.2 "));
break;
case COI_31:
- (void)printf("ver 3.1 ");
+ ND_PRINT((ndo, "ver 3.1 "));
break;
case COI_40:
- (void)printf("ver 4.0 ");
+ ND_PRINT((ndo, "ver 4.0 "));
break;
case COI_41:
- (void)printf("ver 4.1 ");
+ ND_PRINT((ndo, "ver 4.1 "));
break;
}
- (void)printf("segsize %d ", segsize);
+ ND_PRINT((ndo, "segsize %d ", segsize));
if (optlen) {
- (void)printf("optlen %d ", optlen);
-#ifdef PRINT_NSPDATA
- if (optlen > nsplen - sizeof(struct ccmsg))
- goto trunc;
- dp = &(nspp[sizeof(struct ccmsg)]);
- TCHECK2(*dp, optlen);
- pdata(dp, optlen);
-#endif
+ ND_PRINT((ndo, "optlen %d ", optlen));
}
}
break;
case MFS_DI:
- (void)printf("disconn-initiate %d>%d ", src, dst);
+ ND_PRINT((ndo, "disconn-initiate %d>%d ", src, dst));
{
- struct dimsg *dimp = (struct dimsg *)nspp;
+ const struct dimsg *dimp = (const struct dimsg *)nspp;
int reason;
u_int optlen;
-#ifdef PRINT_NSPDATA
- u_char *dp;
-#endif
if (nsplen < sizeof(struct dimsg))
goto trunc;
- TCHECK(*dimp);
+ ND_TCHECK(*dimp);
reason = EXTRACT_LE_16BITS(dimp->di_reason);
optlen = EXTRACT_LE_8BITS(dimp->di_optlen);
- print_reason(reason);
+ print_reason(ndo, reason);
if (optlen) {
- (void)printf("optlen %d ", optlen);
-#ifdef PRINT_NSPDATA
- if (optlen > nsplen - sizeof(struct dimsg))
- goto trunc;
- dp = &(nspp[sizeof(struct dimsg)]);
- TCHECK2(*dp, optlen);
- pdata(dp, optlen);
-#endif
+ ND_PRINT((ndo, "optlen %d ", optlen));
}
}
break;
case MFS_DC:
- (void)printf("disconn-confirm %d>%d ", src, dst);
+ ND_PRINT((ndo, "disconn-confirm %d>%d ", src, dst));
{
- struct dcmsg *dcmp = (struct dcmsg *)nspp;
+ const struct dcmsg *dcmp = (const struct dcmsg *)nspp;
int reason;
- TCHECK(*dcmp);
+ ND_TCHECK(*dcmp);
reason = EXTRACT_LE_16BITS(dcmp->dc_reason);
- print_reason(reason);
+ print_reason(ndo, reason);
}
break;
default:
- (void)printf("reserved-ctltype? %x %d > %d", flags, src, dst);
+ ND_PRINT((ndo, "reserved-ctltype? %x %d > %d", flags, src, dst));
break;
}
break;
default:
- (void)printf("reserved-type? %x %d > %d", flags, src, dst);
+ ND_PRINT((ndo, "reserved-type? %x %d > %d", flags, src, dst));
break;
}
return (1);
@@ -821,7 +1208,7 @@ trunc:
return (0);
}
-static struct tok reason2str[] = {
+static const struct tok reason2str[] = {
{ UC_OBJREJECT, "object rejected connect" },
{ UC_RESOURCES, "insufficient resources" },
{ UC_NOSUCHNODE, "unrecognized node name" },
@@ -848,13 +1235,14 @@ static struct tok reason2str[] = {
};
static void
-print_reason(register int reason)
+print_reason(netdissect_options *ndo,
+ register int reason)
{
- printf("%s ", tok2str(reason2str, "reason-%d", reason));
+ ND_PRINT((ndo, "%s ", tok2str(reason2str, "reason-%d", reason)));
}
const char *
-dnnum_string(u_short dnaddr)
+dnnum_string(netdissect_options *ndo, u_short dnaddr)
{
char *str;
size_t siz;
@@ -863,35 +1251,29 @@ dnnum_string(u_short dnaddr)
str = (char *)malloc(siz = sizeof("00.0000"));
if (str == NULL)
- error("dnnum_string: malloc");
+ (*ndo->ndo_error)(ndo, "dnnum_string: malloc");
snprintf(str, siz, "%d.%d", area, node);
return(str);
}
const char *
-dnname_string(u_short dnaddr)
+dnname_string(netdissect_options *ndo, u_short dnaddr)
{
#ifdef HAVE_DNET_HTOA
struct dn_naddr dna;
+ char *dnname;
dna.a_len = sizeof(short);
memcpy((char *)dna.a_addr, (char *)&dnaddr, sizeof(short));
- return (strdup(dnet_htoa(&dna)));
+ dnname = dnet_htoa(&dna);
+ if(dnname != NULL)
+ return (strdup(dnname));
+ else
+ return(dnnum_string(ndo, dnaddr));
#else
- return(dnnum_string(dnaddr)); /* punt */
+ return(dnnum_string(ndo, dnaddr)); /* punt */
#endif
}
-
-#ifdef PRINT_NSPDATA
-static void
-pdata(u_char *dp, u_int maxlen)
-{
- char c;
- u_int x = maxlen;
-
- while (x-- > 0) {
- c = *dp++;
- safeputchar(c);
- }
-}
-#endif
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-decnet-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-dhcp6.c b/freebsd/contrib/tcpdump/print-dhcp6.c
index fbb31261..a3554665 100644
--- a/freebsd/contrib/tcpdump/print-dhcp6.c
+++ b/freebsd/contrib/tcpdump/print-dhcp6.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (C) 1998 and 1999 WIDE Project.
* All rights reserved.
@@ -28,9 +31,12 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
+
+/* \summary: IPv6 DHCP printer */
+
/*
* RFC3315: DHCPv6
- * supported DHCPv6 options:
+ * supported DHCPv6 options:
* RFC3319: Session Initiation Protocol (SIP) Servers options,
* RFC3633: IPv6 Prefix options,
* RFC3646: DNS Configuration options,
@@ -38,29 +44,25 @@
* RFC4075: Simple Network Time Protocol (SNTP) Configuration option,
* RFC4242: Information Refresh Time option,
* RFC4280: Broadcast and Multicast Control Servers options,
+ * RFC5908: Network Time Protocol (NTP) Server Option for DHCPv6
* RFC6334: Dual-Stack Lite option,
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-dhcp6.c,v 1.37 2008-02-06 10:26:09 guy Exp $";
-#endif
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <stdio.h>
#include <string.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "extract.h"
/* lease duration */
-#define DHCP6_DURATITION_INFINITE 0xffffffff
+#define DHCP6_DURATION_INFINITE 0xffffffff
/* Error Values */
#define DH6ERR_FAILURE 16
@@ -86,11 +88,30 @@ static const char rcsid[] _U_ =
#define DH6_LEASEQUERY 14
#define DH6_LQ_REPLY 15
+static const struct tok dh6_msgtype_str[] = {
+ { DH6_SOLICIT, "solicit" },
+ { DH6_ADVERTISE, "advertise" },
+ { DH6_REQUEST, "request" },
+ { DH6_CONFIRM, "confirm" },
+ { DH6_RENEW, "renew" },
+ { DH6_REBIND, "rebind" },
+ { DH6_REPLY, "reply" },
+ { DH6_RELEASE, "release" },
+ { DH6_DECLINE, "decline" },
+ { DH6_RECONFIGURE, "reconfigure" },
+ { DH6_INFORM_REQ, "inf-req" },
+ { DH6_RELAY_FORW, "relay-fwd" },
+ { DH6_RELAY_REPLY, "relay-reply" },
+ { DH6_LEASEQUERY, "leasequery" },
+ { DH6_LQ_REPLY, "leasequery-reply" },
+ { 0, NULL }
+};
+
/* DHCP6 base packet format */
struct dhcp6 {
union {
- u_int8_t m;
- u_int32_t x;
+ nd_uint8_t m;
+ nd_uint32_t x;
} dh6_msgtypexid;
/* options follow */
};
@@ -100,10 +121,10 @@ struct dhcp6 {
/* DHCPv6 relay messages */
struct dhcp6_relay {
- u_int8_t dh6relay_msgtype;
- u_int8_t dh6relay_hcnt;
- u_int8_t dh6relay_linkaddr[16]; /* XXX: badly aligned */
- u_int8_t dh6relay_peeraddr[16];
+ nd_uint8_t dh6relay_msgtype;
+ nd_uint8_t dh6relay_hcnt;
+ nd_uint8_t dh6relay_linkaddr[16]; /* XXX: badly aligned */
+ nd_uint8_t dh6relay_peeraddr[16];
/* options follow */
};
@@ -148,15 +169,15 @@ struct dhcp6_relay {
#define DH6OPT_RECONF_ACCEPT 20
#define DH6OPT_SIP_SERVER_D 21
#define DH6OPT_SIP_SERVER_A 22
-#define DH6OPT_DNS 23
-#define DH6OPT_DNSNAME 24
+#define DH6OPT_DNS_SERVERS 23
+#define DH6OPT_DOMAIN_LIST 24
#define DH6OPT_IA_PD 25
#define DH6OPT_IA_PD_PREFIX 26
#define DH6OPT_NIS_SERVERS 27
#define DH6OPT_NISP_SERVERS 28
#define DH6OPT_NIS_NAME 29
#define DH6OPT_NISP_NAME 30
-#define DH6OPT_NTP_SERVERS 31
+#define DH6OPT_SNTP_SERVERS 31
#define DH6OPT_LIFETIME 32
#define DH6OPT_BCMCS_SERVER_D 33
#define DH6OPT_BCMCS_SERVER_A 34
@@ -173,330 +194,269 @@ struct dhcp6_relay {
#define DH6OPT_CLT_TIME 46
#define DH6OPT_LQ_RELAY_DATA 47
#define DH6OPT_LQ_CLIENT_LINK 48
+#define DH6OPT_NTP_SERVER 56
+# define DH6OPT_NTP_SUBOPTION_SRV_ADDR 1
+# define DH6OPT_NTP_SUBOPTION_MC_ADDR 2
+# define DH6OPT_NTP_SUBOPTION_SRV_FQDN 3
#define DH6OPT_AFTR_NAME 64
+#define DH6OPT_MUDURL 112
+
+static const struct tok dh6opt_str[] = {
+ { DH6OPT_CLIENTID, "client-ID" },
+ { DH6OPT_SERVERID, "server-ID" },
+ { DH6OPT_IA_NA, "IA_NA" },
+ { DH6OPT_IA_TA, "IA_TA" },
+ { DH6OPT_IA_ADDR, "IA_ADDR" },
+ { DH6OPT_ORO, "option-request" },
+ { DH6OPT_PREFERENCE, "preference" },
+ { DH6OPT_ELAPSED_TIME, "elapsed-time" },
+ { DH6OPT_RELAY_MSG, "relay-message" },
+ { DH6OPT_AUTH, "authentication" },
+ { DH6OPT_UNICAST, "server-unicast" },
+ { DH6OPT_STATUS_CODE, "status-code" },
+ { DH6OPT_RAPID_COMMIT, "rapid-commit" },
+ { DH6OPT_USER_CLASS, "user-class" },
+ { DH6OPT_VENDOR_CLASS, "vendor-class" },
+ { DH6OPT_VENDOR_OPTS, "vendor-specific-info" },
+ { DH6OPT_INTERFACE_ID, "interface-ID" },
+ { DH6OPT_RECONF_MSG, "reconfigure-message" },
+ { DH6OPT_RECONF_ACCEPT, "reconfigure-accept" },
+ { DH6OPT_SIP_SERVER_D, "SIP-servers-domain" },
+ { DH6OPT_SIP_SERVER_A, "SIP-servers-address" },
+ { DH6OPT_DNS_SERVERS, "DNS-server" },
+ { DH6OPT_DOMAIN_LIST, "DNS-search-list" },
+ { DH6OPT_IA_PD, "IA_PD" },
+ { DH6OPT_IA_PD_PREFIX, "IA_PD-prefix" },
+ { DH6OPT_SNTP_SERVERS, "SNTP-servers" },
+ { DH6OPT_LIFETIME, "lifetime" },
+ { DH6OPT_NIS_SERVERS, "NIS-server" },
+ { DH6OPT_NISP_SERVERS, "NIS+-server" },
+ { DH6OPT_NIS_NAME, "NIS-domain-name" },
+ { DH6OPT_NISP_NAME, "NIS+-domain-name" },
+ { DH6OPT_BCMCS_SERVER_D, "BCMCS-domain-name" },
+ { DH6OPT_BCMCS_SERVER_A, "BCMCS-server" },
+ { DH6OPT_GEOCONF_CIVIC, "Geoconf-Civic" },
+ { DH6OPT_REMOTE_ID, "Remote-ID" },
+ { DH6OPT_SUBSCRIBER_ID, "Subscriber-ID" },
+ { DH6OPT_CLIENT_FQDN, "Client-FQDN" },
+ { DH6OPT_PANA_AGENT, "PANA-agent" },
+ { DH6OPT_NEW_POSIX_TIMEZONE, "POSIX-timezone" },
+ { DH6OPT_NEW_TZDB_TIMEZONE, "POSIX-tz-database" },
+ { DH6OPT_ERO, "Echo-request-option" },
+ { DH6OPT_LQ_QUERY, "Lease-query" },
+ { DH6OPT_CLIENT_DATA, "LQ-client-data" },
+ { DH6OPT_CLT_TIME, "Clt-time" },
+ { DH6OPT_LQ_RELAY_DATA, "LQ-relay-data" },
+ { DH6OPT_LQ_CLIENT_LINK, "LQ-client-link" },
+ { DH6OPT_NTP_SERVER, "NTP-server" },
+ { DH6OPT_AFTR_NAME, "AFTR-Name" },
+ { DH6OPT_MUDURL, "MUD-URL" },
+ { 0, NULL }
+};
+
+static const struct tok dh6opt_stcode_str[] = {
+ { DH6OPT_STCODE_SUCCESS, "Success" }, /* RFC3315 */
+ { DH6OPT_STCODE_UNSPECFAIL, "UnspecFail" }, /* RFC3315 */
+ { DH6OPT_STCODE_NOADDRAVAIL, "NoAddrsAvail" }, /* RFC3315 */
+ { DH6OPT_STCODE_NOBINDING, "NoBinding" }, /* RFC3315 */
+ { DH6OPT_STCODE_NOTONLINK, "NotOnLink" }, /* RFC3315 */
+ { DH6OPT_STCODE_USEMULTICAST, "UseMulticast" }, /* RFC3315 */
+ { DH6OPT_STCODE_NOPREFIXAVAIL, "NoPrefixAvail" }, /* RFC3633 */
+ { DH6OPT_STCODE_UNKNOWNQUERYTYPE, "UnknownQueryType" }, /* RFC5007 */
+ { DH6OPT_STCODE_MALFORMEDQUERY, "MalformedQuery" }, /* RFC5007 */
+ { DH6OPT_STCODE_NOTCONFIGURED, "NotConfigured" }, /* RFC5007 */
+ { DH6OPT_STCODE_NOTALLOWED, "NotAllowed" }, /* RFC5007 */
+ { 0, NULL }
+};
struct dhcp6opt {
- u_int16_t dh6opt_type;
- u_int16_t dh6opt_len;
+ nd_uint16_t dh6opt_type;
+ nd_uint16_t dh6opt_len;
/* type-dependent data follows */
};
static const char *
-dhcp6opt_name(int type)
-{
- static char genstr[sizeof("opt_65535") + 1]; /* XXX thread unsafe */
-
- if (type > 65535)
- return "INVALID-option";
-
- switch(type) {
- case DH6OPT_CLIENTID:
- return "client-ID";
- case DH6OPT_SERVERID:
- return "server-ID";
- case DH6OPT_IA_NA:
- return "IA_NA";
- case DH6OPT_IA_TA:
- return "IA_TA";
- case DH6OPT_IA_ADDR:
- return "IA_ADDR";
- case DH6OPT_ORO:
- return "option-request";
- case DH6OPT_PREFERENCE:
- return "preference";
- case DH6OPT_ELAPSED_TIME:
- return "elapsed-time";
- case DH6OPT_RELAY_MSG:
- return "relay-message";
- case DH6OPT_AUTH:
- return "authentication";
- case DH6OPT_UNICAST:
- return "server-unicast";
- case DH6OPT_STATUS_CODE:
- return "status-code";
- case DH6OPT_RAPID_COMMIT:
- return "rapid-commit";
- case DH6OPT_USER_CLASS:
- return "user-class";
- case DH6OPT_VENDOR_CLASS:
- return "vendor-class";
- case DH6OPT_VENDOR_OPTS:
- return "vendor-specific-info";
- case DH6OPT_INTERFACE_ID:
- return "interface-ID";
- case DH6OPT_RECONF_MSG:
- return "reconfigure-message";
- case DH6OPT_RECONF_ACCEPT:
- return "reconfigure-accept";
- case DH6OPT_SIP_SERVER_D:
- return "SIP-servers-domain";
- case DH6OPT_SIP_SERVER_A:
- return "SIP-servers-address";
- case DH6OPT_DNS:
- return "DNS-server";
- case DH6OPT_DNSNAME:
- return "DNS-search-list";
- case DH6OPT_IA_PD:
- return "IA_PD";
- case DH6OPT_IA_PD_PREFIX:
- return "IA_PD-prefix";
- case DH6OPT_NTP_SERVERS:
- return "NTP-server";
- case DH6OPT_LIFETIME:
- return "lifetime";
- case DH6OPT_NIS_SERVERS:
- return "NIS-server";
- case DH6OPT_NISP_SERVERS:
- return "NIS+-server";
- case DH6OPT_NIS_NAME:
- return "NIS-domain-name";
- case DH6OPT_NISP_NAME:
- return "NIS+-domain-name";
- case DH6OPT_BCMCS_SERVER_D:
- return "BCMCS-domain-name";
- case DH6OPT_BCMCS_SERVER_A:
- return "BCMCS-server";
- case DH6OPT_GEOCONF_CIVIC:
- return "Geoconf-Civic";
- case DH6OPT_REMOTE_ID:
- return "Remote-ID";
- case DH6OPT_SUBSCRIBER_ID:
- return "Subscriber-ID";
- case DH6OPT_CLIENT_FQDN:
- return "Client-FQDN";
- case DH6OPT_PANA_AGENT:
- return "PANA-agent";
- case DH6OPT_NEW_POSIX_TIMEZONE:
- return "POSIX-timezone";
- case DH6OPT_NEW_TZDB_TIMEZONE:
- return "POSIX-tz-database";
- case DH6OPT_ERO:
- return "Echo-request-option";
- case DH6OPT_LQ_QUERY:
- return "Lease-query";
- case DH6OPT_CLIENT_DATA:
- return "LQ-client-data";
- case DH6OPT_CLT_TIME:
- return "Clt-time";
- case DH6OPT_LQ_RELAY_DATA:
- return "LQ-relay-data";
- case DH6OPT_LQ_CLIENT_LINK:
- return "LQ-client-link";
- case DH6OPT_AFTR_NAME:
- return "AFTR-Name";
- default:
- snprintf(genstr, sizeof(genstr), "opt_%d", type);
- return(genstr);
- }
-}
-
-static const char *
-dhcp6stcode(int code)
+dhcp6stcode(const uint16_t code)
{
- static char genstr[sizeof("code255") + 1]; /* XXX thread unsafe */
-
- if (code > 255)
- return "INVALID code";
-
- switch(code) {
- case DH6OPT_STCODE_SUCCESS:
- return "success";
- case DH6OPT_STCODE_UNSPECFAIL:
- return "unspec failure";
- case DH6OPT_STCODE_NOADDRAVAIL:
- return "no addresses";
- case DH6OPT_STCODE_NOBINDING:
- return "no binding";
- case DH6OPT_STCODE_NOTONLINK:
- return "not on-link";
- case DH6OPT_STCODE_USEMULTICAST:
- return "use multicast";
- case DH6OPT_STCODE_NOPREFIXAVAIL:
- return "no prefixes";
- case DH6OPT_STCODE_UNKNOWNQUERYTYPE:
- return "unknown query type";
- case DH6OPT_STCODE_MALFORMEDQUERY:
- return "malformed query";
- case DH6OPT_STCODE_NOTCONFIGURED:
- return "not configured";
- case DH6OPT_STCODE_NOTALLOWED:
- return "not allowed";
- default:
- snprintf(genstr, sizeof(genstr), "code%d", code);
- return(genstr);
- }
+ return code > 255 ? "INVALID code" : tok2str(dh6opt_stcode_str, "code%u", code);
}
static void
-dhcp6opt_print(const u_char *cp, const u_char *ep)
+dhcp6opt_print(netdissect_options *ndo,
+ const u_char *cp, const u_char *ep)
{
- struct dhcp6opt *dh6o;
- u_char *tp;
+ const struct dhcp6opt *dh6o;
+ const u_char *tp;
size_t i;
- u_int16_t opttype;
+ uint16_t opttype;
size_t optlen;
- u_int8_t auth_proto;
+ uint8_t auth_proto;
u_int authinfolen, authrealmlen;
+ int remain_len; /* Length of remaining options */
+ int label_len; /* Label length */
+ uint16_t subopt_code;
+ uint16_t subopt_len;
if (cp == ep)
return;
while (cp < ep) {
if (ep < cp + sizeof(*dh6o))
goto trunc;
- dh6o = (struct dhcp6opt *)cp;
- TCHECK(*dh6o);
+ dh6o = (const struct dhcp6opt *)cp;
+ ND_TCHECK(*dh6o);
optlen = EXTRACT_16BITS(&dh6o->dh6opt_len);
if (ep < cp + sizeof(*dh6o) + optlen)
goto trunc;
opttype = EXTRACT_16BITS(&dh6o->dh6opt_type);
- printf(" (%s", dhcp6opt_name(opttype));
+ ND_PRINT((ndo, " (%s", tok2str(dh6opt_str, "opt_%u", opttype)));
+ ND_TCHECK2(*(cp + sizeof(*dh6o)), optlen);
switch (opttype) {
case DH6OPT_CLIENTID:
case DH6OPT_SERVERID:
if (optlen < 2) {
/*(*/
- printf(" ?)");
+ ND_PRINT((ndo, " ?)"));
break;
}
- tp = (u_char *)(dh6o + 1);
+ tp = (const u_char *)(dh6o + 1);
switch (EXTRACT_16BITS(tp)) {
case 1:
if (optlen >= 2 + 6) {
- printf(" hwaddr/time type %u time %u ",
+ ND_PRINT((ndo, " hwaddr/time type %u time %u ",
EXTRACT_16BITS(&tp[2]),
- EXTRACT_32BITS(&tp[4]));
+ EXTRACT_32BITS(&tp[4])));
for (i = 8; i < optlen; i++)
- printf("%02x", tp[i]);
+ ND_PRINT((ndo, "%02x", tp[i]));
/*(*/
- printf(")");
+ ND_PRINT((ndo, ")"));
} else {
/*(*/
- printf(" ?)");
+ ND_PRINT((ndo, " ?)"));
}
break;
case 2:
if (optlen >= 2 + 8) {
- printf(" vid ");
+ ND_PRINT((ndo, " vid "));
for (i = 2; i < 2 + 8; i++)
- printf("%02x", tp[i]);
+ ND_PRINT((ndo, "%02x", tp[i]));
/*(*/
- printf(")");
+ ND_PRINT((ndo, ")"));
} else {
/*(*/
- printf(" ?)");
+ ND_PRINT((ndo, " ?)"));
}
break;
case 3:
if (optlen >= 2 + 2) {
- printf(" hwaddr type %u ",
- EXTRACT_16BITS(&tp[2]));
+ ND_PRINT((ndo, " hwaddr type %u ",
+ EXTRACT_16BITS(&tp[2])));
for (i = 4; i < optlen; i++)
- printf("%02x", tp[i]);
+ ND_PRINT((ndo, "%02x", tp[i]));
/*(*/
- printf(")");
+ ND_PRINT((ndo, ")"));
} else {
/*(*/
- printf(" ?)");
+ ND_PRINT((ndo, " ?)"));
}
break;
default:
- printf(" type %d)", EXTRACT_16BITS(tp));
+ ND_PRINT((ndo, " type %d)", EXTRACT_16BITS(tp)));
break;
}
break;
case DH6OPT_IA_ADDR:
if (optlen < 24) {
/*(*/
- printf(" ?)");
+ ND_PRINT((ndo, " ?)"));
break;
}
- tp = (u_char *)(dh6o + 1);
- printf(" %s", ip6addr_string(&tp[0]));
- printf(" pltime:%u vltime:%u",
+ tp = (const u_char *)(dh6o + 1);
+ ND_PRINT((ndo, " %s", ip6addr_string(ndo, &tp[0])));
+ ND_PRINT((ndo, " pltime:%u vltime:%u",
EXTRACT_32BITS(&tp[16]),
- EXTRACT_32BITS(&tp[20]));
+ EXTRACT_32BITS(&tp[20])));
if (optlen > 24) {
/* there are sub-options */
- dhcp6opt_print(tp + 24, tp + optlen);
+ dhcp6opt_print(ndo, tp + 24, tp + optlen);
}
- printf(")");
+ ND_PRINT((ndo, ")"));
break;
case DH6OPT_ORO:
case DH6OPT_ERO:
if (optlen % 2) {
- printf(" ?)");
+ ND_PRINT((ndo, " ?)"));
break;
}
- tp = (u_char *)(dh6o + 1);
+ tp = (const u_char *)(dh6o + 1);
for (i = 0; i < optlen; i += 2) {
- printf(" %s",
- dhcp6opt_name(EXTRACT_16BITS(&tp[i])));
+ ND_PRINT((ndo, " %s",
+ tok2str(dh6opt_str, "opt_%u", EXTRACT_16BITS(&tp[i]))));
}
- printf(")");
+ ND_PRINT((ndo, ")"));
break;
case DH6OPT_PREFERENCE:
if (optlen != 1) {
- printf(" ?)");
+ ND_PRINT((ndo, " ?)"));
break;
}
- tp = (u_char *)(dh6o + 1);
- printf(" %d)", *tp);
+ tp = (const u_char *)(dh6o + 1);
+ ND_PRINT((ndo, " %d)", *tp));
break;
case DH6OPT_ELAPSED_TIME:
if (optlen != 2) {
- printf(" ?)");
+ ND_PRINT((ndo, " ?)"));
break;
}
- tp = (u_char *)(dh6o + 1);
- printf(" %d)", EXTRACT_16BITS(tp));
+ tp = (const u_char *)(dh6o + 1);
+ ND_PRINT((ndo, " %d)", EXTRACT_16BITS(tp)));
break;
case DH6OPT_RELAY_MSG:
- printf(" (");
- tp = (u_char *)(dh6o + 1);
- dhcp6_print(tp, optlen);
- printf(")");
+ ND_PRINT((ndo, " ("));
+ tp = (const u_char *)(dh6o + 1);
+ dhcp6_print(ndo, tp, optlen);
+ ND_PRINT((ndo, ")"));
break;
case DH6OPT_AUTH:
if (optlen < 11) {
- printf(" ?)");
+ ND_PRINT((ndo, " ?)"));
break;
}
- tp = (u_char *)(dh6o + 1);
+ tp = (const u_char *)(dh6o + 1);
auth_proto = *tp;
switch (auth_proto) {
case DH6OPT_AUTHPROTO_DELAYED:
- printf(" proto: delayed");
+ ND_PRINT((ndo, " proto: delayed"));
break;
case DH6OPT_AUTHPROTO_RECONFIG:
- printf(" proto: reconfigure");
+ ND_PRINT((ndo, " proto: reconfigure"));
break;
default:
- printf(" proto: %d", auth_proto);
+ ND_PRINT((ndo, " proto: %d", auth_proto));
break;
}
tp++;
switch (*tp) {
case DH6OPT_AUTHALG_HMACMD5:
/* XXX: may depend on the protocol */
- printf(", alg: HMAC-MD5");
+ ND_PRINT((ndo, ", alg: HMAC-MD5"));
break;
default:
- printf(", alg: %d", *tp);
+ ND_PRINT((ndo, ", alg: %d", *tp));
break;
}
tp++;
switch (*tp) {
case DH6OPT_AUTHRDM_MONOCOUNTER:
- printf(", RDM: mono");
+ ND_PRINT((ndo, ", RDM: mono"));
break;
default:
- printf(", RDM: %d", *tp);
+ ND_PRINT((ndo, ", RDM: %d", *tp));
break;
}
tp++;
- printf(", RD:");
+ ND_PRINT((ndo, ", RD:"));
for (i = 0; i < 4; i++, tp += 2)
- printf(" %04x", EXTRACT_16BITS(tp));
+ ND_PRINT((ndo, " %04x", EXTRACT_16BITS(tp)));
/* protocol dependent part */
authinfolen = optlen - 11;
@@ -505,50 +465,50 @@ dhcp6opt_print(const u_char *cp, const u_char *ep)
if (authinfolen == 0)
break;
if (authinfolen < 20) {
- printf(" ??");
+ ND_PRINT((ndo, " ??"));
break;
}
authrealmlen = authinfolen - 20;
if (authrealmlen > 0) {
- printf(", realm: ");
+ ND_PRINT((ndo, ", realm: "));
}
for (i = 0; i < authrealmlen; i++, tp++)
- printf("%02x", *tp);
- printf(", key ID: %08x", EXTRACT_32BITS(tp));
+ ND_PRINT((ndo, "%02x", *tp));
+ ND_PRINT((ndo, ", key ID: %08x", EXTRACT_32BITS(tp)));
tp += 4;
- printf(", HMAC-MD5:");
+ ND_PRINT((ndo, ", HMAC-MD5:"));
for (i = 0; i < 4; i++, tp+= 4)
- printf(" %08x", EXTRACT_32BITS(tp));
+ ND_PRINT((ndo, " %08x", EXTRACT_32BITS(tp)));
break;
case DH6OPT_AUTHPROTO_RECONFIG:
if (authinfolen != 17) {
- printf(" ??");
+ ND_PRINT((ndo, " ??"));
break;
}
switch (*tp++) {
case DH6OPT_AUTHRECONFIG_KEY:
- printf(" reconfig-key");
+ ND_PRINT((ndo, " reconfig-key"));
break;
case DH6OPT_AUTHRECONFIG_HMACMD5:
- printf(" type: HMAC-MD5");
+ ND_PRINT((ndo, " type: HMAC-MD5"));
break;
default:
- printf(" type: ??");
+ ND_PRINT((ndo, " type: ??"));
break;
}
- printf(" value:");
+ ND_PRINT((ndo, " value:"));
for (i = 0; i < 4; i++, tp+= 4)
- printf(" %08x", EXTRACT_32BITS(tp));
+ ND_PRINT((ndo, " %08x", EXTRACT_32BITS(tp)));
break;
default:
- printf(" ??");
+ ND_PRINT((ndo, " ??"));
break;
}
- printf(")");
+ ND_PRINT((ndo, ")"));
break;
case DH6OPT_RAPID_COMMIT: /* nothing todo */
- printf(")");
+ ND_PRINT((ndo, ")"));
break;
case DH6OPT_INTERFACE_ID:
case DH6OPT_SUBSCRIBER_ID:
@@ -556,195 +516,253 @@ dhcp6opt_print(const u_char *cp, const u_char *ep)
* Since we cannot predict the encoding, print hex dump
* at most 10 characters.
*/
- tp = (u_char *)(dh6o + 1);
- printf(" ");
+ tp = (const u_char *)(dh6o + 1);
+ ND_PRINT((ndo, " "));
for (i = 0; i < optlen && i < 10; i++)
- printf("%02x", tp[i]);
- printf("...)");
+ ND_PRINT((ndo, "%02x", tp[i]));
+ ND_PRINT((ndo, "...)"));
break;
case DH6OPT_RECONF_MSG:
- tp = (u_char *)(dh6o + 1);
+ tp = (const u_char *)(dh6o + 1);
switch (*tp) {
case DH6_RENEW:
- printf(" for renew)");
+ ND_PRINT((ndo, " for renew)"));
break;
case DH6_INFORM_REQ:
- printf(" for inf-req)");
+ ND_PRINT((ndo, " for inf-req)"));
break;
default:
- printf(" for ?\?\?(%02x))", *tp);
+ ND_PRINT((ndo, " for ?\?\?(%02x))", *tp));
break;
}
break;
case DH6OPT_RECONF_ACCEPT: /* nothing todo */
- printf(")");
+ ND_PRINT((ndo, ")"));
break;
case DH6OPT_SIP_SERVER_A:
- case DH6OPT_DNS:
- case DH6OPT_NTP_SERVERS:
+ case DH6OPT_DNS_SERVERS:
+ case DH6OPT_SNTP_SERVERS:
case DH6OPT_NIS_SERVERS:
case DH6OPT_NISP_SERVERS:
case DH6OPT_BCMCS_SERVER_A:
case DH6OPT_PANA_AGENT:
case DH6OPT_LQ_CLIENT_LINK:
if (optlen % 16) {
- printf(" ?)");
+ ND_PRINT((ndo, " ?)"));
break;
}
- tp = (u_char *)(dh6o + 1);
+ tp = (const u_char *)(dh6o + 1);
for (i = 0; i < optlen; i += 16)
- printf(" %s", ip6addr_string(&tp[i]));
- printf(")");
+ ND_PRINT((ndo, " %s", ip6addr_string(ndo, &tp[i])));
+ ND_PRINT((ndo, ")"));
+ break;
+ case DH6OPT_SIP_SERVER_D:
+ case DH6OPT_DOMAIN_LIST:
+ tp = (const u_char *)(dh6o + 1);
+ while (tp < cp + sizeof(*dh6o) + optlen) {
+ ND_PRINT((ndo, " "));
+ if ((tp = ns_nprint(ndo, tp, cp + sizeof(*dh6o) + optlen)) == NULL)
+ goto trunc;
+ }
+ ND_PRINT((ndo, ")"));
break;
case DH6OPT_STATUS_CODE:
if (optlen < 2) {
- printf(" ?)");
+ ND_PRINT((ndo, " ?)"));
break;
}
- tp = (u_char *)(dh6o + 1);
- printf(" %s)", dhcp6stcode(EXTRACT_16BITS(&tp[0])));
+ tp = (const u_char *)(dh6o + 1);
+ ND_PRINT((ndo, " %s)", dhcp6stcode(EXTRACT_16BITS(&tp[0]))));
break;
case DH6OPT_IA_NA:
case DH6OPT_IA_PD:
if (optlen < 12) {
- printf(" ?)");
+ ND_PRINT((ndo, " ?)"));
break;
}
- tp = (u_char *)(dh6o + 1);
- printf(" IAID:%u T1:%u T2:%u",
+ tp = (const u_char *)(dh6o + 1);
+ ND_PRINT((ndo, " IAID:%u T1:%u T2:%u",
EXTRACT_32BITS(&tp[0]),
EXTRACT_32BITS(&tp[4]),
- EXTRACT_32BITS(&tp[8]));
+ EXTRACT_32BITS(&tp[8])));
if (optlen > 12) {
/* there are sub-options */
- dhcp6opt_print(tp + 12, tp + optlen);
+ dhcp6opt_print(ndo, tp + 12, tp + optlen);
}
- printf(")");
+ ND_PRINT((ndo, ")"));
break;
case DH6OPT_IA_TA:
if (optlen < 4) {
- printf(" ?)");
+ ND_PRINT((ndo, " ?)"));
break;
}
- tp = (u_char *)(dh6o + 1);
- printf(" IAID:%u", EXTRACT_32BITS(tp));
+ tp = (const u_char *)(dh6o + 1);
+ ND_PRINT((ndo, " IAID:%u", EXTRACT_32BITS(tp)));
if (optlen > 4) {
/* there are sub-options */
- dhcp6opt_print(tp + 4, tp + optlen);
+ dhcp6opt_print(ndo, tp + 4, tp + optlen);
}
- printf(")");
+ ND_PRINT((ndo, ")"));
break;
case DH6OPT_IA_PD_PREFIX:
if (optlen < 25) {
- printf(" ?)");
+ ND_PRINT((ndo, " ?)"));
break;
}
- tp = (u_char *)(dh6o + 1);
- printf(" %s/%d", ip6addr_string(&tp[9]), tp[8]);
- printf(" pltime:%u vltime:%u",
+ tp = (const u_char *)(dh6o + 1);
+ ND_PRINT((ndo, " %s/%d", ip6addr_string(ndo, &tp[9]), tp[8]));
+ ND_PRINT((ndo, " pltime:%u vltime:%u",
EXTRACT_32BITS(&tp[0]),
- EXTRACT_32BITS(&tp[4]));
+ EXTRACT_32BITS(&tp[4])));
if (optlen > 25) {
/* there are sub-options */
- dhcp6opt_print(tp + 25, tp + optlen);
+ dhcp6opt_print(ndo, tp + 25, tp + optlen);
}
- printf(")");
+ ND_PRINT((ndo, ")"));
break;
case DH6OPT_LIFETIME:
case DH6OPT_CLT_TIME:
if (optlen != 4) {
- printf(" ?)");
+ ND_PRINT((ndo, " ?)"));
break;
}
- tp = (u_char *)(dh6o + 1);
- printf(" %d)", EXTRACT_32BITS(tp));
+ tp = (const u_char *)(dh6o + 1);
+ ND_PRINT((ndo, " %d)", EXTRACT_32BITS(tp)));
break;
case DH6OPT_REMOTE_ID:
if (optlen < 4) {
- printf(" ?)");
+ ND_PRINT((ndo, " ?)"));
break;
}
- tp = (u_char *)(dh6o + 1);
- printf(" %d ", EXTRACT_32BITS(tp));
+ tp = (const u_char *)(dh6o + 1);
+ ND_PRINT((ndo, " %d ", EXTRACT_32BITS(tp)));
/*
* Print hex dump first 10 characters.
*/
for (i = 4; i < optlen && i < 14; i++)
- printf("%02x", tp[i]);
- printf("...)");
+ ND_PRINT((ndo, "%02x", tp[i]));
+ ND_PRINT((ndo, "...)"));
break;
case DH6OPT_LQ_QUERY:
if (optlen < 17) {
- printf(" ?)");
+ ND_PRINT((ndo, " ?)"));
break;
}
- tp = (u_char *)(dh6o + 1);
+ tp = (const u_char *)(dh6o + 1);
switch (*tp) {
case 1:
- printf(" by-address");
+ ND_PRINT((ndo, " by-address"));
break;
case 2:
- printf(" by-clientID");
+ ND_PRINT((ndo, " by-clientID"));
break;
default:
- printf(" type_%d", (int)*tp);
+ ND_PRINT((ndo, " type_%d", (int)*tp));
break;
}
- printf(" %s", ip6addr_string(&tp[1]));
+ ND_PRINT((ndo, " %s", ip6addr_string(ndo, &tp[1])));
if (optlen > 17) {
/* there are query-options */
- dhcp6opt_print(tp + 17, tp + optlen);
+ dhcp6opt_print(ndo, tp + 17, tp + optlen);
}
- printf(")");
+ ND_PRINT((ndo, ")"));
break;
case DH6OPT_CLIENT_DATA:
- tp = (u_char *)(dh6o + 1);
+ tp = (const u_char *)(dh6o + 1);
if (optlen > 0) {
/* there are encapsulated options */
- dhcp6opt_print(tp, tp + optlen);
+ dhcp6opt_print(ndo, tp, tp + optlen);
}
- printf(")");
+ ND_PRINT((ndo, ")"));
break;
case DH6OPT_LQ_RELAY_DATA:
if (optlen < 16) {
- printf(" ?)");
+ ND_PRINT((ndo, " ?)"));
break;
}
- tp = (u_char *)(dh6o + 1);
- printf(" %s ", ip6addr_string(&tp[0]));
+ tp = (const u_char *)(dh6o + 1);
+ ND_PRINT((ndo, " %s ", ip6addr_string(ndo, &tp[0])));
/*
* Print hex dump first 10 characters.
*/
for (i = 16; i < optlen && i < 26; i++)
- printf("%02x", tp[i]);
- printf("...)");
+ ND_PRINT((ndo, "%02x", tp[i]));
+ ND_PRINT((ndo, "...)"));
+ break;
+ case DH6OPT_NTP_SERVER:
+ if (optlen < 4) {
+ ND_PRINT((ndo, " ?)"));
+ break;
+ }
+ tp = (const u_char *)(dh6o + 1);
+ while (tp < cp + sizeof(*dh6o) + optlen - 4) {
+ subopt_code = EXTRACT_16BITS(tp);
+ tp += 2;
+ subopt_len = EXTRACT_16BITS(tp);
+ tp += 2;
+ if (tp + subopt_len > cp + sizeof(*dh6o) + optlen)
+ goto trunc;
+ ND_PRINT((ndo, " subopt:%d", subopt_code));
+ switch (subopt_code) {
+ case DH6OPT_NTP_SUBOPTION_SRV_ADDR:
+ case DH6OPT_NTP_SUBOPTION_MC_ADDR:
+ if (subopt_len != 16) {
+ ND_PRINT((ndo, " ?"));
+ break;
+ }
+ ND_PRINT((ndo, " %s", ip6addr_string(ndo, &tp[0])));
+ break;
+ case DH6OPT_NTP_SUBOPTION_SRV_FQDN:
+ ND_PRINT((ndo, " "));
+ if (ns_nprint(ndo, tp, tp + subopt_len) == NULL)
+ goto trunc;
+ break;
+ default:
+ ND_PRINT((ndo, " ?"));
+ break;
+ }
+ tp += subopt_len;
+ }
+ ND_PRINT((ndo, ")"));
break;
case DH6OPT_AFTR_NAME:
if (optlen < 3) {
- printf(" ?)");
+ ND_PRINT((ndo, " ?)"));
break;
}
- tp = (u_char *)(dh6o + 1);
- int remain_len = optlen;
- printf(" ");
+ tp = (const u_char *)(dh6o + 1);
+ remain_len = optlen;
+ ND_PRINT((ndo, " "));
/* Encoding is described in section 3.1 of RFC 1035 */
- int label_len; /* Label length */
while (remain_len && *tp) {
label_len = *tp++;
if (label_len < remain_len - 1) {
- printf("%.*s", label_len, tp);
+ (void)fn_printn(ndo, tp, label_len, NULL);
tp += label_len;
remain_len -= (label_len + 1);
- if(*tp) printf(".");
+ if(*tp) ND_PRINT((ndo, "."));
} else {
- printf(" ?");
+ ND_PRINT((ndo, " ?"));
break;
}
}
- printf(")");
+ ND_PRINT((ndo, ")"));
+ break;
+ case DH6OPT_NEW_POSIX_TIMEZONE: /* all three of these options */
+ case DH6OPT_NEW_TZDB_TIMEZONE: /* are encoded similarly */
+ case DH6OPT_MUDURL: /* although GMT might not work */
+ if (optlen < 5) {
+ ND_PRINT((ndo, " ?)"));
+ break;
+ }
+ tp = (const u_char *)(dh6o + 1);
+ ND_PRINT((ndo, "="));
+ (void)fn_printn(ndo, tp, (u_int)optlen, NULL);
+ ND_PRINT((ndo, ")"));
break;
+
default:
- printf(")");
+ ND_PRINT((ndo, ")"));
break;
}
@@ -753,119 +771,66 @@ dhcp6opt_print(const u_char *cp, const u_char *ep)
return;
trunc:
- printf("[|dhcp6ext]");
+ ND_PRINT((ndo, "[|dhcp6ext]"));
}
/*
* Print dhcp6 packets
*/
void
-dhcp6_print(const u_char *cp, u_int length)
+dhcp6_print(netdissect_options *ndo,
+ const u_char *cp, u_int length)
{
- struct dhcp6 *dh6;
- struct dhcp6_relay *dh6relay;
+ const struct dhcp6 *dh6;
+ const struct dhcp6_relay *dh6relay;
const u_char *ep;
- u_char *extp;
+ const u_char *extp;
const char *name;
- printf("dhcp6");
+ ND_PRINT((ndo, "dhcp6"));
- ep = (u_char *)snapend;
+ ep = (const u_char *)ndo->ndo_snapend;
if (cp + length < ep)
ep = cp + length;
- dh6 = (struct dhcp6 *)cp;
- dh6relay = (struct dhcp6_relay *)cp;
- TCHECK(dh6->dh6_xid);
- switch (dh6->dh6_msgtype) {
- case DH6_SOLICIT:
- name = "solicit";
- break;
- case DH6_ADVERTISE:
- name = "advertise";
- break;
- case DH6_REQUEST:
- name = "request";
- break;
- case DH6_CONFIRM:
- name = "confirm";
- break;
- case DH6_RENEW:
- name = "renew";
- break;
- case DH6_REBIND:
- name = "rebind";
- break;
- case DH6_REPLY:
- name = "reply";
- break;
- case DH6_RELEASE:
- name = "release";
- break;
- case DH6_DECLINE:
- name = "decline";
- break;
- case DH6_RECONFIGURE:
- name = "reconfigure";
- break;
- case DH6_INFORM_REQ:
- name= "inf-req";
- break;
- case DH6_RELAY_FORW:
- name= "relay-fwd";
- break;
- case DH6_RELAY_REPLY:
- name= "relay-reply";
- break;
- case DH6_LEASEQUERY:
- name= "leasequery";
- break;
- case DH6_LQ_REPLY:
- name= "leasequery-reply";
- break;
- default:
- name = NULL;
- break;
- }
+ dh6 = (const struct dhcp6 *)cp;
+ dh6relay = (const struct dhcp6_relay *)cp;
+ ND_TCHECK(dh6->dh6_xid);
+ name = tok2str(dh6_msgtype_str, "msgtype-%u", dh6->dh6_msgtype);
- if (!vflag) {
- if (name)
- printf(" %s", name);
- else if (dh6->dh6_msgtype != DH6_RELAY_FORW &&
- dh6->dh6_msgtype != DH6_RELAY_REPLY) {
- printf(" msgtype-%u", dh6->dh6_msgtype);
- }
+ if (!ndo->ndo_vflag) {
+ ND_PRINT((ndo, " %s", name));
return;
}
/* XXX relay agent messages have to be handled differently */
- if (name)
- printf(" %s (", name); /*)*/
- else
- printf(" msgtype-%u (", dh6->dh6_msgtype); /*)*/
+ ND_PRINT((ndo, " %s (", name)); /*)*/
if (dh6->dh6_msgtype != DH6_RELAY_FORW &&
dh6->dh6_msgtype != DH6_RELAY_REPLY) {
- printf("xid=%x", EXTRACT_32BITS(&dh6->dh6_xid) & DH6_XIDMASK);
- extp = (u_char *)(dh6 + 1);
- dhcp6opt_print(extp, ep);
+ ND_PRINT((ndo, "xid=%x", EXTRACT_32BITS(&dh6->dh6_xid) & DH6_XIDMASK));
+ extp = (const u_char *)(dh6 + 1);
+ dhcp6opt_print(ndo, extp, ep);
} else { /* relay messages */
struct in6_addr addr6;
- TCHECK(dh6relay->dh6relay_peeraddr);
+ ND_TCHECK(dh6relay->dh6relay_peeraddr);
memcpy(&addr6, dh6relay->dh6relay_linkaddr, sizeof (addr6));
- printf("linkaddr=%s", ip6addr_string(&addr6));
+ ND_PRINT((ndo, "linkaddr=%s", ip6addr_string(ndo, &addr6)));
memcpy(&addr6, dh6relay->dh6relay_peeraddr, sizeof (addr6));
- printf(" peeraddr=%s", ip6addr_string(&addr6));
+ ND_PRINT((ndo, " peeraddr=%s", ip6addr_string(ndo, &addr6)));
- dhcp6opt_print((u_char *)(dh6relay + 1), ep);
+ dhcp6opt_print(ndo, (const u_char *)(dh6relay + 1), ep);
}
/*(*/
- printf(")");
+ ND_PRINT((ndo, ")"));
return;
trunc:
- printf("[|dhcp6]");
+ ND_PRINT((ndo, "[|dhcp6]"));
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-dhcp6-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-domain.c b/freebsd/contrib/tcpdump/print-domain.c
index 412e1308..ad6e0760 100644
--- a/freebsd/contrib/tcpdump/print-domain.c
+++ b/freebsd/contrib/tcpdump/print-domain.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
@@ -19,33 +22,28 @@
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * $FreeBSD$
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-domain.c,v 1.98 2007-12-09 01:40:32 guy Exp $ (LBL)";
-#endif
+/* \summary: Domain Name System (DNS) printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include "nameser.h"
-#include <stdio.h>
#include <string.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
-#include "extract.h" /* must come after interface.h */
+#include "addrtostr.h"
+#include "extract.h"
static const char *ns_ops[] = {
"", " inv_q", " stat", " op3", " notify", " update", " op6", " op7",
- " op8", " updataA", " updateD", " updateDA",
+ " op8", " updateA", " updateD", " updateDA",
" updateM", " updateMA", " zoneInit", " zoneRef",
};
@@ -58,11 +56,12 @@ static const char *ns_resp[] = {
/* skip over a domain name */
static const u_char *
-ns_nskip(register const u_char *cp)
+ns_nskip(netdissect_options *ndo,
+ register const u_char *cp)
{
register u_char i;
- if (!TTEST2(*cp, 1))
+ if (!ND_TTEST2(*cp, 1))
return (NULL);
i = *cp++;
while (i) {
@@ -73,7 +72,7 @@ ns_nskip(register const u_char *cp)
if ((i & ~INDIR_MASK) != EDNS0_ELT_BITLABEL)
return(NULL); /* unknown ELT */
- if (!TTEST2(*cp, 1))
+ if (!ND_TTEST2(*cp, 1))
return (NULL);
if ((bitlen = *cp++) == 0)
bitlen = 256;
@@ -81,7 +80,7 @@ ns_nskip(register const u_char *cp)
cp += bytelen;
} else
cp += i;
- if (!TTEST2(*cp, 1))
+ if (!ND_TTEST2(*cp, 1))
return (NULL);
i = *cp++;
}
@@ -90,13 +89,14 @@ ns_nskip(register const u_char *cp)
/* print a <domain-name> */
static const u_char *
-blabel_print(const u_char *cp)
+blabel_print(netdissect_options *ndo,
+ const u_char *cp)
{
int bitlen, slen, b;
const u_char *bitp, *lim;
char tc;
- if (!TTEST2(*cp, 1))
+ if (!ND_TTEST2(*cp, 1))
return(NULL);
if ((bitlen = *cp) == 0)
bitlen = 256;
@@ -104,42 +104,43 @@ blabel_print(const u_char *cp)
lim = cp + 1 + slen;
/* print the bit string as a hex string */
- printf("\\[x");
+ ND_PRINT((ndo, "\\[x"));
for (bitp = cp + 1, b = bitlen; bitp < lim && b > 7; b -= 8, bitp++) {
- TCHECK(*bitp);
- printf("%02x", *bitp);
+ ND_TCHECK(*bitp);
+ ND_PRINT((ndo, "%02x", *bitp));
}
if (b > 4) {
- TCHECK(*bitp);
+ ND_TCHECK(*bitp);
tc = *bitp++;
- printf("%02x", tc & (0xff << (8 - b)));
+ ND_PRINT((ndo, "%02x", tc & (0xff << (8 - b))));
} else if (b > 0) {
- TCHECK(*bitp);
+ ND_TCHECK(*bitp);
tc = *bitp++;
- printf("%1x", ((tc >> 4) & 0x0f) & (0x0f << (4 - b)));
+ ND_PRINT((ndo, "%1x", ((tc >> 4) & 0x0f) & (0x0f << (4 - b))));
}
- printf("/%d]", bitlen);
+ ND_PRINT((ndo, "/%d]", bitlen));
return lim;
trunc:
- printf(".../%d]", bitlen);
+ ND_PRINT((ndo, ".../%d]", bitlen));
return NULL;
}
static int
-labellen(const u_char *cp)
+labellen(netdissect_options *ndo,
+ const u_char *cp)
{
register u_int i;
- if (!TTEST2(*cp, 1))
+ if (!ND_TTEST2(*cp, 1))
return(-1);
i = *cp;
if ((i & INDIR_MASK) == EDNS0_MASK) {
int bitlen, elt;
if ((elt = (i & ~INDIR_MASK)) != EDNS0_ELT_BITLABEL) {
- printf("<ELT %d>", elt);
+ ND_PRINT((ndo, "<ELT %d>", elt));
return(-1);
}
- if (!TTEST2(*(cp + 1), 1))
+ if (!ND_TTEST2(*(cp + 1), 1))
return(-1);
if ((bitlen = *(cp + 1)) == 0)
bitlen = 256;
@@ -149,18 +150,19 @@ labellen(const u_char *cp)
}
const u_char *
-ns_nprint(register const u_char *cp, register const u_char *bp)
+ns_nprint(netdissect_options *ndo,
+ register const u_char *cp, register const u_char *bp)
{
register u_int i, l;
register const u_char *rp = NULL;
register int compress = 0;
int chars_processed;
int elt;
- int data_size = snapend - bp;
+ int data_size = ndo->ndo_snapend - bp;
- if ((l = labellen(cp)) == (u_int)-1)
+ if ((l = labellen(ndo, cp)) == (u_int)-1)
return(NULL);
- if (!TTEST2(*cp, 1))
+ if (!ND_TTEST2(*cp, 1))
return(NULL);
chars_processed = 1;
if (((i = *cp++) & INDIR_MASK) != INDIR_MASK) {
@@ -169,18 +171,18 @@ ns_nprint(register const u_char *cp, register const u_char *bp)
}
if (i != 0)
- while (i && cp < snapend) {
+ while (i && cp < ndo->ndo_snapend) {
if ((i & INDIR_MASK) == INDIR_MASK) {
if (!compress) {
rp = cp + 1;
compress = 1;
}
- if (!TTEST2(*cp, 1))
+ if (!ND_TTEST2(*cp, 1))
return(NULL);
cp = bp + (((i << 8) | *cp) & 0x3fff);
- if ((l = labellen(cp)) == (u_int)-1)
+ if ((l = labellen(ndo, cp)) == (u_int)-1)
return(NULL);
- if (!TTEST2(*cp, 1))
+ if (!ND_TTEST2(*cp, 1))
return(NULL);
i = *cp++;
chars_processed++;
@@ -192,7 +194,7 @@ ns_nprint(register const u_char *cp, register const u_char *bp)
* which means we're looping.
*/
if (chars_processed >= data_size) {
- printf("<LOOP>");
+ ND_PRINT((ndo, "<LOOP>"));
return (NULL);
}
continue;
@@ -201,25 +203,25 @@ ns_nprint(register const u_char *cp, register const u_char *bp)
elt = (i & ~INDIR_MASK);
switch(elt) {
case EDNS0_ELT_BITLABEL:
- if (blabel_print(cp) == NULL)
+ if (blabel_print(ndo, cp) == NULL)
return (NULL);
break;
default:
/* unknown ELT */
- printf("<ELT %d>", elt);
+ ND_PRINT((ndo, "<ELT %d>", elt));
return(NULL);
}
} else {
- if (fn_printn(cp, l, snapend))
+ if (fn_printn(ndo, cp, l, ndo->ndo_snapend))
return(NULL);
}
cp += l;
chars_processed += l;
- putchar('.');
- if ((l = labellen(cp)) == (u_int)-1)
+ ND_PRINT((ndo, "."));
+ if ((l = labellen(ndo, cp)) == (u_int)-1)
return(NULL);
- if (!TTEST2(*cp, 1))
+ if (!ND_TTEST2(*cp, 1))
return(NULL);
i = *cp++;
chars_processed++;
@@ -227,26 +229,27 @@ ns_nprint(register const u_char *cp, register const u_char *bp)
rp += l + 1;
}
else
- putchar('.');
+ ND_PRINT((ndo, "."));
return (rp);
}
/* print a <character-string> */
static const u_char *
-ns_cprint(register const u_char *cp)
+ns_cprint(netdissect_options *ndo,
+ register const u_char *cp)
{
register u_int i;
- if (!TTEST2(*cp, 1))
+ if (!ND_TTEST2(*cp, 1))
return (NULL);
i = *cp++;
- if (fn_printn(cp, i, snapend))
+ if (fn_printn(ndo, cp, i, ndo->ndo_snapend))
return (NULL);
return (cp + i);
}
/* http://www.iana.org/assignments/dns-parameters */
-struct tok ns_type2str[] = {
+const struct tok ns_type2str[] = {
{ T_A, "A" }, /* RFC 1035 */
{ T_NS, "NS" }, /* RFC 1035 */
{ T_MD, "MD" }, /* RFC 1035 */
@@ -311,7 +314,7 @@ struct tok ns_type2str[] = {
{ 0, NULL }
};
-struct tok ns_class2str[] = {
+const struct tok ns_class2str[] = {
{ C_IN, "IN" }, /* Not used */
{ C_CHAOS, "CHAOS" },
{ C_HS, "HS" },
@@ -321,20 +324,21 @@ struct tok ns_class2str[] = {
/* print a query */
static const u_char *
-ns_qprint(register const u_char *cp, register const u_char *bp, int is_mdns)
+ns_qprint(netdissect_options *ndo,
+ register const u_char *cp, register const u_char *bp, int is_mdns)
{
register const u_char *np = cp;
register u_int i, class;
- cp = ns_nskip(cp);
+ cp = ns_nskip(ndo, cp);
- if (cp == NULL || !TTEST2(*cp, 4))
+ if (cp == NULL || !ND_TTEST2(*cp, 4))
return(NULL);
/* print the qtype */
i = EXTRACT_16BITS(cp);
cp += 2;
- printf(" %s", tok2str(ns_type2str, "Type%d", i));
+ ND_PRINT((ndo, " %s", tok2str(ns_type2str, "Type%d", i)));
/* print the qclass (if it's not IN) */
i = EXTRACT_16BITS(cp);
cp += 2;
@@ -343,36 +347,34 @@ ns_qprint(register const u_char *cp, register const u_char *bp, int is_mdns)
else
class = i;
if (class != C_IN)
- printf(" %s", tok2str(ns_class2str, "(Class %d)", class));
+ ND_PRINT((ndo, " %s", tok2str(ns_class2str, "(Class %d)", class)));
if (is_mdns) {
- if (i & C_QU)
- printf(" (QU)");
- else
- printf(" (QM)");
+ ND_PRINT((ndo, i & C_QU ? " (QU)" : " (QM)"));
}
- fputs("? ", stdout);
- cp = ns_nprint(np, bp);
+ ND_PRINT((ndo, "? "));
+ cp = ns_nprint(ndo, np, bp);
return(cp ? cp + 4 : NULL);
}
/* print a reply */
static const u_char *
-ns_rprint(register const u_char *cp, register const u_char *bp, int is_mdns)
+ns_rprint(netdissect_options *ndo,
+ register const u_char *cp, register const u_char *bp, int is_mdns)
{
register u_int i, class, opt_flags = 0;
register u_short typ, len;
register const u_char *rp;
- if (vflag) {
- putchar(' ');
- if ((cp = ns_nprint(cp, bp)) == NULL)
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo, " "));
+ if ((cp = ns_nprint(ndo, cp, bp)) == NULL)
return NULL;
} else
- cp = ns_nskip(cp);
+ cp = ns_nskip(ndo, cp);
- if (cp == NULL || !TTEST2(*cp, 10))
- return (snapend);
+ if (cp == NULL || !ND_TTEST2(*cp, 10))
+ return (ndo->ndo_snapend);
/* print the type/qtype */
typ = EXTRACT_16BITS(cp);
@@ -385,10 +387,10 @@ ns_rprint(register const u_char *cp, register const u_char *bp, int is_mdns)
else
class = i;
if (class != C_IN && typ != T_OPT)
- printf(" %s", tok2str(ns_class2str, "(Class %d)", class));
+ ND_PRINT((ndo, " %s", tok2str(ns_class2str, "(Class %d)", class)));
if (is_mdns) {
if (i & C_CACHE_FLUSH)
- printf(" (Cache flush)");
+ ND_PRINT((ndo, " (Cache flush)"));
}
if (typ == T_OPT) {
@@ -397,11 +399,11 @@ ns_rprint(register const u_char *cp, register const u_char *bp, int is_mdns)
opt_flags = EXTRACT_16BITS(cp);
/* ignore rest of ttl field */
cp += 2;
- } else if (vflag > 2) {
+ } else if (ndo->ndo_vflag > 2) {
/* print ttl */
- printf(" [");
- relts_print(EXTRACT_32BITS(cp));
- printf("]");
+ ND_PRINT((ndo, " ["));
+ unsigned_relts_print(ndo, EXTRACT_32BITS(cp));
+ ND_PRINT((ndo, "]"));
cp += 4;
} else {
/* ignore ttl */
@@ -413,15 +415,15 @@ ns_rprint(register const u_char *cp, register const u_char *bp, int is_mdns)
rp = cp + len;
- printf(" %s", tok2str(ns_type2str, "Type%d", typ));
- if (rp > snapend)
+ ND_PRINT((ndo, " %s", tok2str(ns_type2str, "Type%d", typ)));
+ if (rp > ndo->ndo_snapend)
return(NULL);
switch (typ) {
case T_A:
- if (!TTEST2(*cp, sizeof(struct in_addr)))
+ if (!ND_TTEST2(*cp, sizeof(struct in_addr)))
return(NULL);
- printf(" %s", intoa(htonl(EXTRACT_32BITS(cp))));
+ ND_PRINT((ndo, " %s", intoa(htonl(EXTRACT_32BITS(cp)))));
break;
case T_NS:
@@ -430,73 +432,70 @@ ns_rprint(register const u_char *cp, register const u_char *bp, int is_mdns)
#ifdef T_DNAME
case T_DNAME:
#endif
- putchar(' ');
- if (ns_nprint(cp, bp) == NULL)
+ ND_PRINT((ndo, " "));
+ if (ns_nprint(ndo, cp, bp) == NULL)
return(NULL);
break;
case T_SOA:
- if (!vflag)
+ if (!ndo->ndo_vflag)
break;
- putchar(' ');
- if ((cp = ns_nprint(cp, bp)) == NULL)
+ ND_PRINT((ndo, " "));
+ if ((cp = ns_nprint(ndo, cp, bp)) == NULL)
return(NULL);
- putchar(' ');
- if ((cp = ns_nprint(cp, bp)) == NULL)
+ ND_PRINT((ndo, " "));
+ if ((cp = ns_nprint(ndo, cp, bp)) == NULL)
return(NULL);
- if (!TTEST2(*cp, 5 * 4))
+ if (!ND_TTEST2(*cp, 5 * 4))
return(NULL);
- printf(" %u", EXTRACT_32BITS(cp));
+ ND_PRINT((ndo, " %u", EXTRACT_32BITS(cp)));
cp += 4;
- printf(" %u", EXTRACT_32BITS(cp));
+ ND_PRINT((ndo, " %u", EXTRACT_32BITS(cp)));
cp += 4;
- printf(" %u", EXTRACT_32BITS(cp));
+ ND_PRINT((ndo, " %u", EXTRACT_32BITS(cp)));
cp += 4;
- printf(" %u", EXTRACT_32BITS(cp));
+ ND_PRINT((ndo, " %u", EXTRACT_32BITS(cp)));
cp += 4;
- printf(" %u", EXTRACT_32BITS(cp));
+ ND_PRINT((ndo, " %u", EXTRACT_32BITS(cp)));
cp += 4;
break;
case T_MX:
- putchar(' ');
- if (!TTEST2(*cp, 2))
+ ND_PRINT((ndo, " "));
+ if (!ND_TTEST2(*cp, 2))
return(NULL);
- if (ns_nprint(cp + 2, bp) == NULL)
+ if (ns_nprint(ndo, cp + 2, bp) == NULL)
return(NULL);
- printf(" %d", EXTRACT_16BITS(cp));
+ ND_PRINT((ndo, " %d", EXTRACT_16BITS(cp)));
break;
case T_TXT:
while (cp < rp) {
- printf(" \"");
- cp = ns_cprint(cp);
+ ND_PRINT((ndo, " \""));
+ cp = ns_cprint(ndo, cp);
if (cp == NULL)
return(NULL);
- putchar('"');
+ ND_PRINT((ndo, "\""));
}
break;
case T_SRV:
- putchar(' ');
- if (!TTEST2(*cp, 6))
+ ND_PRINT((ndo, " "));
+ if (!ND_TTEST2(*cp, 6))
return(NULL);
- if (ns_nprint(cp + 6, bp) == NULL)
+ if (ns_nprint(ndo, cp + 6, bp) == NULL)
return(NULL);
- printf(":%d %d %d", EXTRACT_16BITS(cp + 4),
- EXTRACT_16BITS(cp), EXTRACT_16BITS(cp + 2));
+ ND_PRINT((ndo, ":%d %d %d", EXTRACT_16BITS(cp + 4),
+ EXTRACT_16BITS(cp), EXTRACT_16BITS(cp + 2)));
break;
-#ifdef INET6
case T_AAAA:
{
- struct in6_addr addr;
char ntop_buf[INET6_ADDRSTRLEN];
- if (!TTEST2(*cp, sizeof(struct in6_addr)))
+ if (!ND_TTEST2(*cp, sizeof(struct in6_addr)))
return(NULL);
- memcpy(&addr, cp, sizeof(struct in6_addr));
- printf(" %s",
- inet_ntop(AF_INET6, &addr, ntop_buf, sizeof(ntop_buf)));
+ ND_PRINT((ndo, " %s",
+ addrtostr6(cp, ntop_buf, sizeof(ntop_buf))));
break;
}
@@ -507,72 +506,71 @@ ns_rprint(register const u_char *cp, register const u_char *bp, int is_mdns)
int pbit, pbyte;
char ntop_buf[INET6_ADDRSTRLEN];
- if (!TTEST2(*cp, 1))
+ if (!ND_TTEST2(*cp, 1))
return(NULL);
pbit = *cp;
pbyte = (pbit & ~7) / 8;
if (pbit > 128) {
- printf(" %u(bad plen)", pbit);
+ ND_PRINT((ndo, " %u(bad plen)", pbit));
break;
} else if (pbit < 128) {
- if (!TTEST2(*(cp + 1), sizeof(a) - pbyte))
+ if (!ND_TTEST2(*(cp + 1), sizeof(a) - pbyte))
return(NULL);
memset(&a, 0, sizeof(a));
memcpy(&a.s6_addr[pbyte], cp + 1, sizeof(a) - pbyte);
- printf(" %u %s", pbit,
- inet_ntop(AF_INET6, &a, ntop_buf, sizeof(ntop_buf)));
+ ND_PRINT((ndo, " %u %s", pbit,
+ addrtostr6(&a, ntop_buf, sizeof(ntop_buf))));
}
if (pbit > 0) {
- putchar(' ');
- if (ns_nprint(cp + 1 + sizeof(a) - pbyte, bp) == NULL)
+ ND_PRINT((ndo, " "));
+ if (ns_nprint(ndo, cp + 1 + sizeof(a) - pbyte, bp) == NULL)
return(NULL);
}
break;
}
-#endif /*INET6*/
case T_OPT:
- printf(" UDPsize=%u", class);
+ ND_PRINT((ndo, " UDPsize=%u", class));
if (opt_flags & 0x8000)
- printf(" OK");
+ ND_PRINT((ndo, " DO"));
break;
case T_UNSPECA: /* One long string */
- if (!TTEST2(*cp, len))
+ if (!ND_TTEST2(*cp, len))
return(NULL);
- if (fn_printn(cp, len, snapend))
+ if (fn_printn(ndo, cp, len, ndo->ndo_snapend))
return(NULL);
break;
case T_TSIG:
{
- if (cp + len > snapend)
+ if (cp + len > ndo->ndo_snapend)
return(NULL);
- if (!vflag)
+ if (!ndo->ndo_vflag)
break;
- putchar(' ');
- if ((cp = ns_nprint(cp, bp)) == NULL)
+ ND_PRINT((ndo, " "));
+ if ((cp = ns_nprint(ndo, cp, bp)) == NULL)
return(NULL);
cp += 6;
- if (!TTEST2(*cp, 2))
+ if (!ND_TTEST2(*cp, 2))
return(NULL);
- printf(" fudge=%u", EXTRACT_16BITS(cp));
+ ND_PRINT((ndo, " fudge=%u", EXTRACT_16BITS(cp)));
cp += 2;
- if (!TTEST2(*cp, 2))
+ if (!ND_TTEST2(*cp, 2))
return(NULL);
- printf(" maclen=%u", EXTRACT_16BITS(cp));
+ ND_PRINT((ndo, " maclen=%u", EXTRACT_16BITS(cp)));
cp += 2 + EXTRACT_16BITS(cp);
- if (!TTEST2(*cp, 2))
+ if (!ND_TTEST2(*cp, 2))
return(NULL);
- printf(" origid=%u", EXTRACT_16BITS(cp));
+ ND_PRINT((ndo, " origid=%u", EXTRACT_16BITS(cp)));
cp += 2;
- if (!TTEST2(*cp, 2))
+ if (!ND_TTEST2(*cp, 2))
return(NULL);
- printf(" error=%u", EXTRACT_16BITS(cp));
+ ND_PRINT((ndo, " error=%u", EXTRACT_16BITS(cp)));
cp += 2;
- if (!TTEST2(*cp, 2))
+ if (!ND_TTEST2(*cp, 2))
return(NULL);
- printf(" otherlen=%u", EXTRACT_16BITS(cp));
+ ND_PRINT((ndo, " otherlen=%u", EXTRACT_16BITS(cp)));
cp += 2;
}
}
@@ -580,15 +578,16 @@ ns_rprint(register const u_char *cp, register const u_char *bp, int is_mdns)
}
void
-ns_print(register const u_char *bp, u_int length, int is_mdns)
+ns_print(netdissect_options *ndo,
+ register const u_char *bp, u_int length, int is_mdns)
{
register const HEADER *np;
register int qdcount, ancount, nscount, arcount;
register const u_char *cp;
- u_int16_t b2;
+ uint16_t b2;
np = (const HEADER *)bp;
- TCHECK(*np);
+ ND_TCHECK(*np);
/* get the byte-order right */
qdcount = EXTRACT_16BITS(&np->qdcount);
ancount = EXTRACT_16BITS(&np->ancount);
@@ -597,65 +596,65 @@ ns_print(register const u_char *bp, u_int length, int is_mdns)
if (DNS_QR(np)) {
/* this is a response */
- printf("%d%s%s%s%s%s%s",
+ ND_PRINT((ndo, "%d%s%s%s%s%s%s",
EXTRACT_16BITS(&np->id),
ns_ops[DNS_OPCODE(np)],
ns_resp[DNS_RCODE(np)],
DNS_AA(np)? "*" : "",
DNS_RA(np)? "" : "-",
DNS_TC(np)? "|" : "",
- DNS_AD(np)? "$" : "");
+ DNS_AD(np)? "$" : ""));
if (qdcount != 1)
- printf(" [%dq]", qdcount);
+ ND_PRINT((ndo, " [%dq]", qdcount));
/* Print QUESTION section on -vv */
cp = (const u_char *)(np + 1);
while (qdcount--) {
if (qdcount < EXTRACT_16BITS(&np->qdcount) - 1)
- putchar(',');
- if (vflag > 1) {
- fputs(" q:", stdout);
- if ((cp = ns_qprint(cp, bp, is_mdns)) == NULL)
+ ND_PRINT((ndo, ","));
+ if (ndo->ndo_vflag > 1) {
+ ND_PRINT((ndo, " q:"));
+ if ((cp = ns_qprint(ndo, cp, bp, is_mdns)) == NULL)
goto trunc;
} else {
- if ((cp = ns_nskip(cp)) == NULL)
+ if ((cp = ns_nskip(ndo, cp)) == NULL)
goto trunc;
cp += 4; /* skip QTYPE and QCLASS */
}
}
- printf(" %d/%d/%d", ancount, nscount, arcount);
+ ND_PRINT((ndo, " %d/%d/%d", ancount, nscount, arcount));
if (ancount--) {
- if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL)
+ if ((cp = ns_rprint(ndo, cp, bp, is_mdns)) == NULL)
goto trunc;
- while (cp < snapend && ancount--) {
- putchar(',');
- if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL)
+ while (cp < ndo->ndo_snapend && ancount--) {
+ ND_PRINT((ndo, ","));
+ if ((cp = ns_rprint(ndo, cp, bp, is_mdns)) == NULL)
goto trunc;
}
}
if (ancount > 0)
goto trunc;
/* Print NS and AR sections on -vv */
- if (vflag > 1) {
- if (cp < snapend && nscount--) {
- fputs(" ns:", stdout);
- if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL)
+ if (ndo->ndo_vflag > 1) {
+ if (cp < ndo->ndo_snapend && nscount--) {
+ ND_PRINT((ndo, " ns:"));
+ if ((cp = ns_rprint(ndo, cp, bp, is_mdns)) == NULL)
goto trunc;
- while (cp < snapend && nscount--) {
- putchar(',');
- if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL)
+ while (cp < ndo->ndo_snapend && nscount--) {
+ ND_PRINT((ndo, ","));
+ if ((cp = ns_rprint(ndo, cp, bp, is_mdns)) == NULL)
goto trunc;
}
}
if (nscount > 0)
goto trunc;
- if (cp < snapend && arcount--) {
- fputs(" ar:", stdout);
- if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL)
+ if (cp < ndo->ndo_snapend && arcount--) {
+ ND_PRINT((ndo, " ar:"));
+ if ((cp = ns_rprint(ndo, cp, bp, is_mdns)) == NULL)
goto trunc;
- while (cp < snapend && arcount--) {
- putchar(',');
- if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL)
+ while (cp < ndo->ndo_snapend && arcount--) {
+ ND_PRINT((ndo, ","));
+ if ((cp = ns_rprint(ndo, cp, bp, is_mdns)) == NULL)
goto trunc;
}
}
@@ -665,39 +664,39 @@ ns_print(register const u_char *bp, u_int length, int is_mdns)
}
else {
/* this is a request */
- printf("%d%s%s%s", EXTRACT_16BITS(&np->id), ns_ops[DNS_OPCODE(np)],
+ ND_PRINT((ndo, "%d%s%s%s", EXTRACT_16BITS(&np->id), ns_ops[DNS_OPCODE(np)],
DNS_RD(np) ? "+" : "",
- DNS_CD(np) ? "%" : "");
+ DNS_CD(np) ? "%" : ""));
/* any weirdness? */
- b2 = EXTRACT_16BITS(((u_short *)np)+1);
+ b2 = EXTRACT_16BITS(((const u_short *)np)+1);
if (b2 & 0x6cf)
- printf(" [b2&3=0x%x]", b2);
+ ND_PRINT((ndo, " [b2&3=0x%x]", b2));
if (DNS_OPCODE(np) == IQUERY) {
if (qdcount)
- printf(" [%dq]", qdcount);
+ ND_PRINT((ndo, " [%dq]", qdcount));
if (ancount != 1)
- printf(" [%da]", ancount);
+ ND_PRINT((ndo, " [%da]", ancount));
}
else {
if (ancount)
- printf(" [%da]", ancount);
+ ND_PRINT((ndo, " [%da]", ancount));
if (qdcount != 1)
- printf(" [%dq]", qdcount);
+ ND_PRINT((ndo, " [%dq]", qdcount));
}
if (nscount)
- printf(" [%dn]", nscount);
+ ND_PRINT((ndo, " [%dn]", nscount));
if (arcount)
- printf(" [%dau]", arcount);
+ ND_PRINT((ndo, " [%dau]", arcount));
cp = (const u_char *)(np + 1);
if (qdcount--) {
- cp = ns_qprint(cp, (const u_char *)np, is_mdns);
+ cp = ns_qprint(ndo, cp, (const u_char *)np, is_mdns);
if (!cp)
goto trunc;
- while (cp < snapend && qdcount--) {
- cp = ns_qprint((const u_char *)cp,
+ while (cp < ndo->ndo_snapend && qdcount--) {
+ cp = ns_qprint(ndo, (const u_char *)cp,
(const u_char *)np,
is_mdns);
if (!cp)
@@ -708,37 +707,37 @@ ns_print(register const u_char *bp, u_int length, int is_mdns)
goto trunc;
/* Print remaining sections on -vv */
- if (vflag > 1) {
+ if (ndo->ndo_vflag > 1) {
if (ancount--) {
- if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL)
+ if ((cp = ns_rprint(ndo, cp, bp, is_mdns)) == NULL)
goto trunc;
- while (cp < snapend && ancount--) {
- putchar(',');
- if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL)
+ while (cp < ndo->ndo_snapend && ancount--) {
+ ND_PRINT((ndo, ","));
+ if ((cp = ns_rprint(ndo, cp, bp, is_mdns)) == NULL)
goto trunc;
}
}
if (ancount > 0)
goto trunc;
- if (cp < snapend && nscount--) {
- fputs(" ns:", stdout);
- if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL)
+ if (cp < ndo->ndo_snapend && nscount--) {
+ ND_PRINT((ndo, " ns:"));
+ if ((cp = ns_rprint(ndo, cp, bp, is_mdns)) == NULL)
goto trunc;
- while (nscount-- && cp < snapend) {
- putchar(',');
- if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL)
+ while (nscount-- && cp < ndo->ndo_snapend) {
+ ND_PRINT((ndo, ","));
+ if ((cp = ns_rprint(ndo, cp, bp, is_mdns)) == NULL)
goto trunc;
}
}
if (nscount > 0)
goto trunc;
- if (cp < snapend && arcount--) {
- fputs(" ar:", stdout);
- if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL)
+ if (cp < ndo->ndo_snapend && arcount--) {
+ ND_PRINT((ndo, " ar:"));
+ if ((cp = ns_rprint(ndo, cp, bp, is_mdns)) == NULL)
goto trunc;
- while (cp < snapend && arcount--) {
- putchar(',');
- if ((cp = ns_rprint(cp, bp, is_mdns)) == NULL)
+ while (cp < ndo->ndo_snapend && arcount--) {
+ ND_PRINT((ndo, ","));
+ if ((cp = ns_rprint(ndo, cp, bp, is_mdns)) == NULL)
goto trunc;
}
}
@@ -746,10 +745,12 @@ ns_print(register const u_char *bp, u_int length, int is_mdns)
goto trunc;
}
}
- printf(" (%d)", length);
+ ND_PRINT((ndo, " (%d)", length));
return;
trunc:
- printf("[|domain]");
- return;
+ ND_PRINT((ndo, "[|domain]"));
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-domain-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-dtp.c b/freebsd/contrib/tcpdump/print-dtp.c
index f1471e86..aa29dab2 100644
--- a/freebsd/contrib/tcpdump/print-dtp.c
+++ b/freebsd/contrib/tcpdump/print-dtp.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1998-2007 The TCPDUMP project
*
@@ -14,24 +17,22 @@
* LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE.
*
- * Dynamic Trunk Protocol (DTP)
- *
* Original code by Carles Kishimoto <carles.kishimoto@gmail.com>
*/
+/* \summary: Dynamic Trunking Protocol (DTP) printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
-
-#include <stdio.h>
-#include <string.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
-#include "extract.h"
-#include "nlpid.h"
+#include "extract.h"
+
+static const char tstr[] = " [|dtp]";
#define DTP_HEADER_LEN 1
#define DTP_DOMAIN_TLV 0x0001
@@ -39,7 +40,7 @@
#define DTP_DTP_TYPE_TLV 0x0003
#define DTP_NEIGHBOR_TLV 0x0004
-static struct tok dtp_tlv_values[] = {
+static const struct tok dtp_tlv_values[] = {
{ DTP_DOMAIN_TLV, "Domain TLV"},
{ DTP_STATUS_TLV, "Status TLV"},
{ DTP_DTP_TYPE_TLV, "DTP type TLV"},
@@ -48,7 +49,7 @@ static struct tok dtp_tlv_values[] = {
};
void
-dtp_print (const u_char *pptr, u_int length)
+dtp_print (netdissect_options *ndo, const u_char *pptr, u_int length)
{
int type, len;
const u_char *tptr;
@@ -56,19 +57,18 @@ dtp_print (const u_char *pptr, u_int length)
if (length < DTP_HEADER_LEN)
goto trunc;
- tptr = pptr;
+ tptr = pptr;
- if (!TTEST2(*tptr, DTP_HEADER_LEN))
- goto trunc;
+ ND_TCHECK2(*tptr, DTP_HEADER_LEN);
- printf("DTPv%u, length %u",
+ ND_PRINT((ndo, "DTPv%u, length %u",
(*tptr),
- length);
+ length));
/*
* In non-verbose mode, just print version.
*/
- if (vflag < 1) {
+ if (ndo->ndo_vflag < 1) {
return;
}
@@ -76,45 +76,53 @@ dtp_print (const u_char *pptr, u_int length)
while (tptr < (pptr+length)) {
- if (!TTEST2(*tptr, 4))
- goto trunc;
-
+ ND_TCHECK2(*tptr, 4);
type = EXTRACT_16BITS(tptr);
- len = EXTRACT_16BITS(tptr+2);
-
- /* infinite loop check */
- if (type == 0 || len == 0) {
+ len = EXTRACT_16BITS(tptr+2);
+ /* XXX: should not be but sometimes it is, see the test captures */
+ if (type == 0)
return;
- }
-
- printf("\n\t%s (0x%04x) TLV, length %u",
+ ND_PRINT((ndo, "\n\t%s (0x%04x) TLV, length %u",
tok2str(dtp_tlv_values, "Unknown", type),
- type, len);
+ type, len));
+
+ /* infinite loop check */
+ if (len < 4)
+ goto invalid;
+ ND_TCHECK2(*tptr, len);
switch (type) {
case DTP_DOMAIN_TLV:
- printf(", %s", tptr+4);
+ ND_PRINT((ndo, ", "));
+ fn_printzp(ndo, tptr+4, len-4, pptr+length);
break;
- case DTP_STATUS_TLV:
+ case DTP_STATUS_TLV:
case DTP_DTP_TYPE_TLV:
- printf(", 0x%x", *(tptr+4));
+ if (len < 5)
+ goto invalid;
+ ND_PRINT((ndo, ", 0x%x", *(tptr+4)));
break;
case DTP_NEIGHBOR_TLV:
- printf(", %s", etheraddr_string(tptr+4));
+ if (len < 10)
+ goto invalid;
+ ND_PRINT((ndo, ", %s", etheraddr_string(ndo, tptr+4)));
break;
default:
break;
- }
+ }
tptr += len;
}
return;
+ invalid:
+ ND_PRINT((ndo, "%s", istr));
+ return;
trunc:
- printf("[|dtp]");
+ ND_PRINT((ndo, "%s", tstr));
}
/*
@@ -123,3 +131,6 @@ dtp_print (const u_char *pptr, u_int length)
* c-basic-offset: 4
* End:
*/
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-dtp-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-dvmrp.c b/freebsd/contrib/tcpdump/print-dvmrp.c
index 4f553b7d..894f08db 100644
--- a/freebsd/contrib/tcpdump/print-dvmrp.c
+++ b/freebsd/contrib/tcpdump/print-dvmrp.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1995, 1996
* The Regents of the University of California. All rights reserved.
@@ -21,22 +24,15 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-dvmrp.c,v 1.27 2003-11-19 09:42:04 guy Exp $ (LBL)";
-#endif
+/* \summary: Distance Vector Multicast Routing Protocol printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
#include "addrtoname.h"
@@ -64,27 +60,28 @@ static const char rcsid[] _U_ =
#define DVMRP_NF_DISABLED 0x20 /* administratively disabled */
#define DVMRP_NF_QUERIER 0x40 /* I am the subnet's querier */
-static int print_probe(const u_char *, const u_char *, u_int);
-static int print_report(const u_char *, const u_char *, u_int);
-static int print_neighbors(const u_char *, const u_char *, u_int);
-static int print_neighbors2(const u_char *, const u_char *, u_int);
-static int print_prune(const u_char *);
-static int print_graft(const u_char *);
-static int print_graft_ack(const u_char *);
+static int print_probe(netdissect_options *, const u_char *, const u_char *, u_int);
+static int print_report(netdissect_options *, const u_char *, const u_char *, u_int);
+static int print_neighbors(netdissect_options *, const u_char *, const u_char *, u_int);
+static int print_neighbors2(netdissect_options *, const u_char *, const u_char *, u_int);
+static int print_prune(netdissect_options *, const u_char *);
+static int print_graft(netdissect_options *, const u_char *);
+static int print_graft_ack(netdissect_options *, const u_char *);
-static u_int32_t target_level;
+static uint32_t target_level;
void
-dvmrp_print(register const u_char *bp, register u_int len)
+dvmrp_print(netdissect_options *ndo,
+ register const u_char *bp, register u_int len)
{
register const u_char *ep;
register u_char type;
- ep = (const u_char *)snapend;
+ ep = (const u_char *)ndo->ndo_snapend;
if (bp >= ep)
return;
- TCHECK(bp[1]);
+ ND_TCHECK(bp[1]);
type = bp[1];
/* Skip IGMP header */
@@ -94,94 +91,95 @@ dvmrp_print(register const u_char *bp, register u_int len)
switch (type) {
case DVMRP_PROBE:
- printf(" Probe");
- if (vflag) {
- if (print_probe(bp, ep, len) < 0)
+ ND_PRINT((ndo, " Probe"));
+ if (ndo->ndo_vflag) {
+ if (print_probe(ndo, bp, ep, len) < 0)
goto trunc;
}
break;
case DVMRP_REPORT:
- printf(" Report");
- if (vflag > 1) {
- if (print_report(bp, ep, len) < 0)
+ ND_PRINT((ndo, " Report"));
+ if (ndo->ndo_vflag > 1) {
+ if (print_report(ndo, bp, ep, len) < 0)
goto trunc;
}
break;
case DVMRP_ASK_NEIGHBORS:
- printf(" Ask-neighbors(old)");
+ ND_PRINT((ndo, " Ask-neighbors(old)"));
break;
case DVMRP_NEIGHBORS:
- printf(" Neighbors(old)");
- if (print_neighbors(bp, ep, len) < 0)
+ ND_PRINT((ndo, " Neighbors(old)"));
+ if (print_neighbors(ndo, bp, ep, len) < 0)
goto trunc;
break;
case DVMRP_ASK_NEIGHBORS2:
- printf(" Ask-neighbors2");
+ ND_PRINT((ndo, " Ask-neighbors2"));
break;
case DVMRP_NEIGHBORS2:
- printf(" Neighbors2");
+ ND_PRINT((ndo, " Neighbors2"));
/*
* extract version and capabilities from IGMP group
* address field
*/
bp -= 4;
- TCHECK2(bp[0], 4);
+ ND_TCHECK2(bp[0], 4);
target_level = (bp[0] << 24) | (bp[1] << 16) |
(bp[2] << 8) | bp[3];
bp += 4;
- if (print_neighbors2(bp, ep, len) < 0)
+ if (print_neighbors2(ndo, bp, ep, len) < 0)
goto trunc;
break;
case DVMRP_PRUNE:
- printf(" Prune");
- if (print_prune(bp) < 0)
+ ND_PRINT((ndo, " Prune"));
+ if (print_prune(ndo, bp) < 0)
goto trunc;
break;
case DVMRP_GRAFT:
- printf(" Graft");
- if (print_graft(bp) < 0)
+ ND_PRINT((ndo, " Graft"));
+ if (print_graft(ndo, bp) < 0)
goto trunc;
break;
case DVMRP_GRAFT_ACK:
- printf(" Graft-ACK");
- if (print_graft_ack(bp) < 0)
+ ND_PRINT((ndo, " Graft-ACK"));
+ if (print_graft_ack(ndo, bp) < 0)
goto trunc;
break;
default:
- printf(" [type %d]", type);
+ ND_PRINT((ndo, " [type %d]", type));
break;
}
return;
trunc:
- printf("[|dvmrp]");
+ ND_PRINT((ndo, "[|dvmrp]"));
return;
}
-static int
-print_report(register const u_char *bp, register const u_char *ep,
- register u_int len)
+static int
+print_report(netdissect_options *ndo,
+ register const u_char *bp, register const u_char *ep,
+ register u_int len)
{
- register u_int32_t mask, origin;
+ register uint32_t mask, origin;
register int metric, done;
register u_int i, width;
while (len > 0) {
if (len < 3) {
- printf(" [|]");
+ ND_PRINT((ndo, " [|]"));
return (0);
}
- TCHECK2(bp[0], 3);
- mask = (u_int32_t)0xff << 24 | bp[0] << 16 | bp[1] << 8 | bp[2];
+ ND_TCHECK2(bp[0], 3);
+ mask = (uint32_t)0xff << 24 | bp[0] << 16 | bp[1] << 8 | bp[2];
width = 1;
if (bp[0])
width = 2;
@@ -190,32 +188,32 @@ print_report(register const u_char *bp, register const u_char *ep,
if (bp[2])
width = 4;
- printf("\n\tMask %s", intoa(htonl(mask)));
+ ND_PRINT((ndo, "\n\tMask %s", intoa(htonl(mask))));
bp += 3;
len -= 3;
do {
if (bp + width + 1 > ep) {
- printf(" [|]");
+ ND_PRINT((ndo, " [|]"));
return (0);
}
if (len < width + 1) {
- printf("\n\t [Truncated Report]");
+ ND_PRINT((ndo, "\n\t [Truncated Report]"));
return (0);
}
origin = 0;
for (i = 0; i < width; ++i) {
- TCHECK(*bp);
+ ND_TCHECK(*bp);
origin = origin << 8 | *bp++;
}
for ( ; i < 4; ++i)
origin <<= 8;
- TCHECK(*bp);
+ ND_TCHECK(*bp);
metric = *bp++;
done = metric & 0x80;
metric &= 0x7f;
- printf("\n\t %s metric %d", intoa(htonl(origin)),
- metric);
+ ND_PRINT((ndo, "\n\t %s metric %d", intoa(htonl(origin)),
+ metric));
len -= width + 1;
} while (!done);
}
@@ -225,31 +223,29 @@ trunc:
}
static int
-print_probe(register const u_char *bp, register const u_char *ep,
- register u_int len)
+print_probe(netdissect_options *ndo,
+ register const u_char *bp, register const u_char *ep,
+ register u_int len)
{
- register u_int32_t genid;
+ register uint32_t genid;
- TCHECK2(bp[0], 4);
+ ND_TCHECK2(bp[0], 4);
if ((len < 4) || ((bp + 4) > ep)) {
/* { (ctags) */
- printf(" [|}");
+ ND_PRINT((ndo, " [|}"));
return (0);
}
genid = (bp[0] << 24) | (bp[1] << 16) | (bp[2] << 8) | bp[3];
bp += 4;
len -= 4;
- if (vflag > 1)
- printf("\n\t");
- else
- printf(" ");
- printf("genid %u", genid);
- if (vflag < 2)
+ ND_PRINT((ndo, ndo->ndo_vflag > 1 ? "\n\t" : " "));
+ ND_PRINT((ndo, "genid %u", genid));
+ if (ndo->ndo_vflag < 2)
return (0);
while ((len > 0) && (bp < ep)) {
- TCHECK2(bp[0], 4);
- printf("\n\tneighbor %s", ipaddr_string(bp));
+ ND_TCHECK2(bp[0], 4);
+ ND_PRINT((ndo, "\n\tneighbor %s", ipaddr_string(ndo, bp)));
bp += 4; len -= 4;
}
return (0);
@@ -258,8 +254,9 @@ trunc:
}
static int
-print_neighbors(register const u_char *bp, register const u_char *ep,
- register u_int len)
+print_neighbors(netdissect_options *ndo,
+ register const u_char *bp, register const u_char *ep,
+ register u_int len)
{
const u_char *laddr;
register u_char metric;
@@ -267,7 +264,7 @@ print_neighbors(register const u_char *bp, register const u_char *ep,
register int ncount;
while (len > 0 && bp < ep) {
- TCHECK2(bp[0], 7);
+ ND_TCHECK2(bp[0], 7);
laddr = bp;
bp += 4;
metric = *bp++;
@@ -275,10 +272,10 @@ print_neighbors(register const u_char *bp, register const u_char *ep,
ncount = *bp++;
len -= 7;
while (--ncount >= 0) {
- TCHECK2(bp[0], 4);
- printf(" [%s ->", ipaddr_string(laddr));
- printf(" %s, (%d/%d)]",
- ipaddr_string(bp), metric, thresh);
+ ND_TCHECK2(bp[0], 4);
+ ND_PRINT((ndo, " [%s ->", ipaddr_string(ndo, laddr)));
+ ND_PRINT((ndo, " %s, (%d/%d)]",
+ ipaddr_string(ndo, bp), metric, thresh));
bp += 4;
len -= 4;
}
@@ -289,19 +286,20 @@ trunc:
}
static int
-print_neighbors2(register const u_char *bp, register const u_char *ep,
- register u_int len)
+print_neighbors2(netdissect_options *ndo,
+ register const u_char *bp, register const u_char *ep,
+ register u_int len)
{
const u_char *laddr;
register u_char metric, thresh, flags;
register int ncount;
- printf(" (v %d.%d):",
+ ND_PRINT((ndo, " (v %d.%d):",
(int)target_level & 0xff,
- (int)(target_level >> 8) & 0xff);
+ (int)(target_level >> 8) & 0xff));
while (len > 0 && bp < ep) {
- TCHECK2(bp[0], 8);
+ ND_TCHECK2(bp[0], 8);
laddr = bp;
bp += 4;
metric = *bp++;
@@ -310,25 +308,25 @@ print_neighbors2(register const u_char *bp, register const u_char *ep,
ncount = *bp++;
len -= 8;
while (--ncount >= 0 && (len >= 4) && (bp + 4) <= ep) {
- printf(" [%s -> ", ipaddr_string(laddr));
- printf("%s (%d/%d", ipaddr_string(bp),
- metric, thresh);
+ ND_PRINT((ndo, " [%s -> ", ipaddr_string(ndo, laddr)));
+ ND_PRINT((ndo, "%s (%d/%d", ipaddr_string(ndo, bp),
+ metric, thresh));
if (flags & DVMRP_NF_TUNNEL)
- printf("/tunnel");
+ ND_PRINT((ndo, "/tunnel"));
if (flags & DVMRP_NF_SRCRT)
- printf("/srcrt");
+ ND_PRINT((ndo, "/srcrt"));
if (flags & DVMRP_NF_QUERIER)
- printf("/querier");
+ ND_PRINT((ndo, "/querier"));
if (flags & DVMRP_NF_DISABLED)
- printf("/disabled");
+ ND_PRINT((ndo, "/disabled"));
if (flags & DVMRP_NF_DOWN)
- printf("/down");
- printf(")]");
+ ND_PRINT((ndo, "/down"));
+ ND_PRINT((ndo, ")]"));
bp += 4;
len -= 4;
}
if (ncount != -1) {
- printf(" [|]");
+ ND_PRINT((ndo, " [|]"));
return (0);
}
}
@@ -338,34 +336,40 @@ trunc:
}
static int
-print_prune(register const u_char *bp)
+print_prune(netdissect_options *ndo,
+ register const u_char *bp)
{
- TCHECK2(bp[0], 12);
- printf(" src %s grp %s", ipaddr_string(bp), ipaddr_string(bp + 4));
+ ND_TCHECK2(bp[0], 12);
+ ND_PRINT((ndo, " src %s grp %s", ipaddr_string(ndo, bp), ipaddr_string(ndo, bp + 4)));
bp += 8;
- (void)printf(" timer ");
- relts_print(EXTRACT_32BITS(bp));
+ ND_PRINT((ndo, " timer "));
+ unsigned_relts_print(ndo, EXTRACT_32BITS(bp));
return (0);
trunc:
return (-1);
}
static int
-print_graft(register const u_char *bp)
+print_graft(netdissect_options *ndo,
+ register const u_char *bp)
{
- TCHECK2(bp[0], 8);
- printf(" src %s grp %s", ipaddr_string(bp), ipaddr_string(bp + 4));
+ ND_TCHECK2(bp[0], 8);
+ ND_PRINT((ndo, " src %s grp %s", ipaddr_string(ndo, bp), ipaddr_string(ndo, bp + 4)));
return (0);
trunc:
return (-1);
}
static int
-print_graft_ack(register const u_char *bp)
+print_graft_ack(netdissect_options *ndo,
+ register const u_char *bp)
{
- TCHECK2(bp[0], 8);
- printf(" src %s grp %s", ipaddr_string(bp), ipaddr_string(bp + 4));
+ ND_TCHECK2(bp[0], 8);
+ ND_PRINT((ndo, " src %s grp %s", ipaddr_string(ndo, bp), ipaddr_string(ndo, bp + 4)));
return (0);
trunc:
return (-1);
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-dvmrp-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-eap.c b/freebsd/contrib/tcpdump/print-eap.c
index 5730dbb7..9a1f3263 100644
--- a/freebsd/contrib/tcpdump/print-eap.c
+++ b/freebsd/contrib/tcpdump/print-eap.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 2004 - Michael Richardson <mcr@xelerance.com>
*
@@ -18,30 +21,18 @@
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Format and print EAP packets.
- *
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-eap.c,v 1.5 2007-10-04 16:41:33 hannes Exp $";
-#endif
+/* \summary: Extensible Authentication Protocol (EAP) printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
-
-#include <stdio.h>
-#include <string.h>
+#include <netdissect-stdinc.h>
#include "netdissect.h"
-#include "interface.h"
-#include "addrtoname.h"
#include "extract.h"
-#include "ether.h"
#define EAP_FRAME_TYPE_PACKET 0
#define EAP_FRAME_TYPE_START 1
@@ -115,7 +106,7 @@ static const struct tok eap_type_values[] = {
{ EAP_TYPE_EXPANDED_TYPES, "Expanded types" },
{ EAP_TYPE_EXPERIMENTAL, "Experimental" },
{ 0, NULL}
-};
+};
#define EAP_TLS_EXTRACT_BIT_L(x) (((x)&0x80)>>7)
@@ -161,35 +152,35 @@ static const struct tok eap_aka_subtype_values[] = {
* Print EAP requests / responses
*/
void
-eap_print(netdissect_options *ndo _U_,
+eap_print(netdissect_options *ndo,
register const u_char *cp,
- u_int length _U_)
+ u_int length)
{
const struct eap_frame_t *eap;
const u_char *tptr;
u_int tlen, type, subtype;
int count=0, len;
-
+
tptr = cp;
tlen = length;
eap = (const struct eap_frame_t *)cp;
- TCHECK(*eap);
+ ND_TCHECK(*eap);
/* in non-verbose mode just lets print the basic info */
- if (vflag < 1) {
- printf("%s (%u) v%u, len %u",
+ if (ndo->ndo_vflag < 1) {
+ ND_PRINT((ndo, "%s (%u) v%u, len %u",
tok2str(eap_frame_type_values, "unknown", eap->type),
eap->type,
eap->version,
- EXTRACT_16BITS(eap->length));
+ EXTRACT_16BITS(eap->length)));
return;
}
-
- printf("%s (%u) v%u, len %u",
+
+ ND_PRINT((ndo, "%s (%u) v%u, len %u",
tok2str(eap_frame_type_values, "unknown", eap->type),
eap->type,
eap->version,
- EXTRACT_16BITS(eap->length));
+ EXTRACT_16BITS(eap->length)));
tptr += sizeof(const struct eap_frame_t);
tlen -= sizeof(const struct eap_frame_t);
@@ -198,33 +189,32 @@ eap_print(netdissect_options *ndo _U_,
case EAP_FRAME_TYPE_PACKET:
type = *(tptr);
len = EXTRACT_16BITS(tptr+2);
- printf(", %s (%u), id %u, len %u",
+ ND_PRINT((ndo, ", %s (%u), id %u, len %u",
tok2str(eap_code_values, "unknown", type),
type,
*(tptr+1),
- len);
+ len));
- if (!TTEST2(*tptr, len))
- goto trunc;
+ ND_TCHECK2(*tptr, len);
if (type <= 2) { /* For EAP_REQUEST and EAP_RESPONSE only */
subtype = *(tptr+4);
- printf("\n\t\t Type %s (%u)",
+ ND_PRINT((ndo, "\n\t\t Type %s (%u)",
tok2str(eap_type_values, "unknown", *(tptr+4)),
- *(tptr+4));
+ *(tptr + 4)));
- switch (subtype) {
+ switch (subtype) {
case EAP_TYPE_IDENTITY:
if (len - 5 > 0) {
- printf(", Identity: ");
- safeputs((const char *)tptr+5, len-5);
+ ND_PRINT((ndo, ", Identity: "));
+ safeputs(ndo, tptr + 5, len - 5);
}
break;
case EAP_TYPE_NOTIFICATION:
if (len - 5 > 0) {
- printf(", Notification: ");
- safeputs((const char *)tptr+5, len-5);
+ ND_PRINT((ndo, ", Notification: "));
+ safeputs(ndo, tptr + 5, len - 5);
}
break;
@@ -236,36 +226,36 @@ eap_print(netdissect_options *ndo _U_,
* the desired authentication
* type one octet per type
*/
- while (count < len) {
- printf(" %s (%u),",
+ while (count < len) {
+ ND_PRINT((ndo, " %s (%u),",
tok2str(eap_type_values, "unknown", *(tptr+count)),
- *(tptr+count));
+ *(tptr + count)));
count++;
}
break;
case EAP_TYPE_TTLS:
- printf(" TTLSv%u",
- EAP_TTLS_VERSION(*(tptr+5))); /* fall through */
+ ND_PRINT((ndo, " TTLSv%u",
+ EAP_TTLS_VERSION(*(tptr + 5)))); /* fall through */
case EAP_TYPE_TLS:
- printf(" flags [%s] 0x%02x,",
+ ND_PRINT((ndo, " flags [%s] 0x%02x,",
bittok2str(eap_tls_flags_values, "none", *(tptr+5)),
- *(tptr+5));
+ *(tptr + 5)));
if (EAP_TLS_EXTRACT_BIT_L(*(tptr+5))) {
- printf(" len %u", EXTRACT_32BITS(tptr+6));
+ ND_PRINT((ndo, " len %u", EXTRACT_32BITS(tptr + 6)));
}
break;
case EAP_TYPE_FAST:
- printf(" FASTv%u",
- EAP_TTLS_VERSION(*(tptr+5)));
- printf(" flags [%s] 0x%02x,",
+ ND_PRINT((ndo, " FASTv%u",
+ EAP_TTLS_VERSION(*(tptr + 5))));
+ ND_PRINT((ndo, " flags [%s] 0x%02x,",
bittok2str(eap_tls_flags_values, "none", *(tptr+5)),
- *(tptr+5));
+ *(tptr + 5)));
if (EAP_TLS_EXTRACT_BIT_L(*(tptr+5))) {
- printf(" len %u", EXTRACT_32BITS(tptr+6));
+ ND_PRINT((ndo, " len %u", EXTRACT_32BITS(tptr + 6)));
}
/* FIXME - TLV attributes follow */
@@ -273,14 +263,14 @@ eap_print(netdissect_options *ndo _U_,
case EAP_TYPE_AKA:
case EAP_TYPE_SIM:
- printf(" subtype [%s] 0x%02x,",
+ ND_PRINT((ndo, " subtype [%s] 0x%02x,",
tok2str(eap_aka_subtype_values, "unknown", *(tptr+5)),
- *(tptr+5));
+ *(tptr + 5)));
/* FIXME - TLV attributes follow */
break;
- case EAP_TYPE_MD5_CHALLENGE:
+ case EAP_TYPE_MD5_CHALLENGE:
case EAP_TYPE_OTP:
case EAP_TYPE_GTC:
case EAP_TYPE_EXPANDED_TYPES:
@@ -289,7 +279,7 @@ eap_print(netdissect_options *ndo _U_,
break;
}
}
- break;
+ break;
case EAP_FRAME_TYPE_LOGOFF:
case EAP_FRAME_TYPE_ENCAP_ASF_ALERT:
@@ -299,7 +289,7 @@ eap_print(netdissect_options *ndo _U_,
return;
trunc:
- printf("\n\t[|EAP]");
+ ND_PRINT((ndo, "\n\t[|EAP]"));
}
/*
@@ -307,3 +297,6 @@ eap_print(netdissect_options *ndo _U_,
* c-basic-offset: 4
* End:
*/
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-eap-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-egp.c b/freebsd/contrib/tcpdump/print-egp.c
index 1c90bd86..69e8a030 100644
--- a/freebsd/contrib/tcpdump/print-egp.c
+++ b/freebsd/contrib/tcpdump/print-egp.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1991, 1992, 1993, 1994, 1995, 1996
* The Regents of the University of California. All rights reserved.
@@ -20,35 +23,28 @@
* Initial contribution from Jeff Honig (jch@MITCHELL.CIT.CORNELL.EDU).
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-egp.c,v 1.38 2006-02-11 22:13:24 hannes Exp $ (LBL)";
-#endif
+/* \summary: Exterior Gateway Protocol (EGP) printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include <stdio.h>
-
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "extract.h"
-#include "ip.h"
-
struct egp_packet {
- u_int8_t egp_version;
+ uint8_t egp_version;
#define EGP_VERSION 2
- u_int8_t egp_type;
+ uint8_t egp_type;
#define EGPT_ACQUIRE 3
#define EGPT_REACH 5
#define EGPT_POLL 2
#define EGPT_UPDATE 1
#define EGPT_ERROR 8
- u_int8_t egp_code;
+ uint8_t egp_code;
#define EGPC_REQUEST 0
#define EGPC_CONFIRM 1
#define EGPC_REFUSE 2
@@ -56,7 +52,7 @@ struct egp_packet {
#define EGPC_CEASEACK 4
#define EGPC_HELLO 0
#define EGPC_HEARDU 1
- u_int8_t egp_status;
+ uint8_t egp_status;
#define EGPS_UNSPEC 0
#define EGPS_ACTIVE 1
#define EGPS_PASSIVE 2
@@ -69,13 +65,13 @@ struct egp_packet {
#define EGPS_UP 1
#define EGPS_DOWN 2
#define EGPS_UNSOL 0x80
- u_int16_t egp_checksum;
- u_int16_t egp_as;
- u_int16_t egp_sequence;
+ uint16_t egp_checksum;
+ uint16_t egp_as;
+ uint16_t egp_sequence;
union {
- u_int16_t egpu_hello;
- u_int8_t egpu_gws[2];
- u_int16_t egpu_reason;
+ uint16_t egpu_hello;
+ uint8_t egpu_gws[2];
+ uint16_t egpu_reason;
#define EGPR_UNSPEC 0
#define EGPR_BADHEAD 1
#define EGPR_BADDATA 2
@@ -89,14 +85,14 @@ struct egp_packet {
#define egp_extgw egp_handg.egpu_gws[1]
#define egp_reason egp_handg.egpu_reason
union {
- u_int16_t egpu_poll;
- u_int32_t egpu_sourcenet;
+ uint16_t egpu_poll;
+ uint32_t egpu_sourcenet;
} egp_pands;
#define egp_poll egp_pands.egpu_poll
#define egp_sourcenet egp_pands.egpu_sourcenet
};
-const char *egp_acquire_codes[] = {
+static const char *egp_acquire_codes[] = {
"request",
"confirm",
"refuse",
@@ -104,7 +100,7 @@ const char *egp_acquire_codes[] = {
"cease_ack"
};
-const char *egp_acquire_status[] = {
+static const char *egp_acquire_status[] = {
"unspecified",
"active_mode",
"passive_mode",
@@ -115,18 +111,18 @@ const char *egp_acquire_status[] = {
"protocol_violation"
};
-const char *egp_reach_codes[] = {
+static const char *egp_reach_codes[] = {
"hello",
"i-h-u"
};
-const char *egp_status_updown[] = {
+static const char *egp_status_updown[] = {
"indeterminate",
"up",
"down"
};
-const char *egp_reasons[] = {
+static const char *egp_reasons[] = {
"unspecified",
"bad_EGP_header_format",
"bad_EGP_data_field_format",
@@ -137,11 +133,12 @@ const char *egp_reasons[] = {
};
static void
-egpnrprint(register const struct egp_packet *egp)
+egpnrprint(netdissect_options *ndo,
+ register const struct egp_packet *egp, u_int length)
{
- register const u_int8_t *cp;
- u_int32_t addr;
- register u_int32_t net;
+ register const uint8_t *cp;
+ uint32_t addr;
+ register uint32_t net;
register u_int netlen;
int gateways, distances, networks;
int t_gateways;
@@ -161,13 +158,16 @@ egpnrprint(register const struct egp_packet *egp)
net = 0;
netlen = 0;
}
- cp = (u_int8_t *)(egp + 1);
+ cp = (const uint8_t *)(egp + 1);
+ length -= sizeof(*egp);
t_gateways = egp->egp_intgw + egp->egp_extgw;
for (gateways = 0; gateways < t_gateways; ++gateways) {
/* Pickup host part of gateway address */
addr = 0;
- TCHECK2(cp[0], 4 - netlen);
+ if (length < 4 - netlen)
+ goto trunc;
+ ND_TCHECK2(cp[0], 4 - netlen);
switch (netlen) {
case 1:
@@ -180,69 +180,86 @@ egpnrprint(register const struct egp_packet *egp)
addr = (addr << 8) | *cp++;
}
addr |= net;
- TCHECK2(cp[0], 1);
+ length -= 4 - netlen;
+ if (length < 1)
+ goto trunc;
+ ND_TCHECK2(cp[0], 1);
distances = *cp++;
- printf(" %s %s ",
+ length--;
+ ND_PRINT((ndo, " %s %s ",
gateways < (int)egp->egp_intgw ? "int" : "ext",
- ipaddr_string(&addr));
+ ipaddr_string(ndo, &addr)));
comma = "";
- putchar('(');
+ ND_PRINT((ndo, "("));
while (--distances >= 0) {
- TCHECK2(cp[0], 2);
- printf("%sd%d:", comma, (int)*cp++);
+ if (length < 2)
+ goto trunc;
+ ND_TCHECK2(cp[0], 2);
+ ND_PRINT((ndo, "%sd%d:", comma, (int)*cp++));
comma = ", ";
networks = *cp++;
+ length -= 2;
while (--networks >= 0) {
/* Pickup network number */
- TCHECK2(cp[0], 1);
- addr = (u_int32_t)*cp++ << 24;
+ if (length < 1)
+ goto trunc;
+ ND_TCHECK2(cp[0], 1);
+ addr = (uint32_t)*cp++ << 24;
+ length--;
if (IN_CLASSB(addr)) {
- TCHECK2(cp[0], 1);
- addr |= (u_int32_t)*cp++ << 16;
+ if (length < 1)
+ goto trunc;
+ ND_TCHECK2(cp[0], 1);
+ addr |= (uint32_t)*cp++ << 16;
+ length--;
} else if (!IN_CLASSA(addr)) {
- TCHECK2(cp[0], 2);
- addr |= (u_int32_t)*cp++ << 16;
- addr |= (u_int32_t)*cp++ << 8;
+ if (length < 2)
+ goto trunc;
+ ND_TCHECK2(cp[0], 2);
+ addr |= (uint32_t)*cp++ << 16;
+ addr |= (uint32_t)*cp++ << 8;
+ length -= 2;
}
- printf(" %s", ipaddr_string(&addr));
+ ND_PRINT((ndo, " %s", ipaddr_string(ndo, &addr)));
}
}
- putchar(')');
+ ND_PRINT((ndo, ")"));
}
return;
trunc:
- fputs("[|]", stdout);
+ ND_PRINT((ndo, "[|]"));
}
void
-egp_print(register const u_int8_t *bp, register u_int length)
+egp_print(netdissect_options *ndo,
+ register const uint8_t *bp, register u_int length)
{
register const struct egp_packet *egp;
register int status;
register int code;
register int type;
- egp = (struct egp_packet *)bp;
- if (!TTEST2(*egp, length)) {
- printf("[|egp]");
+ egp = (const struct egp_packet *)bp;
+ if (length < sizeof(*egp) || !ND_TTEST(*egp)) {
+ ND_PRINT((ndo, "[|egp]"));
return;
}
- if (!vflag) {
- printf("EGPv%u, AS %u, seq %u, length %u",
+ if (!ndo->ndo_vflag) {
+ ND_PRINT((ndo, "EGPv%u, AS %u, seq %u, length %u",
egp->egp_version,
EXTRACT_16BITS(&egp->egp_as),
EXTRACT_16BITS(&egp->egp_sequence),
- length);
+ length));
return;
} else
- printf("EGPv%u, length %u",
+ ND_PRINT((ndo, "EGPv%u, length %u",
egp->egp_version,
- length);
+ length));
if (egp->egp_version != EGP_VERSION) {
- printf("[version %d]", egp->egp_version);
+ ND_PRINT((ndo, "[version %d]", egp->egp_version));
return;
}
@@ -252,31 +269,31 @@ egp_print(register const u_int8_t *bp, register u_int length)
switch (type) {
case EGPT_ACQUIRE:
- printf(" acquire");
+ ND_PRINT((ndo, " acquire"));
switch (code) {
case EGPC_REQUEST:
case EGPC_CONFIRM:
- printf(" %s", egp_acquire_codes[code]);
+ ND_PRINT((ndo, " %s", egp_acquire_codes[code]));
switch (status) {
case EGPS_UNSPEC:
case EGPS_ACTIVE:
case EGPS_PASSIVE:
- printf(" %s", egp_acquire_status[status]);
+ ND_PRINT((ndo, " %s", egp_acquire_status[status]));
break;
default:
- printf(" [status %d]", status);
+ ND_PRINT((ndo, " [status %d]", status));
break;
}
- printf(" hello:%d poll:%d",
+ ND_PRINT((ndo, " hello:%d poll:%d",
EXTRACT_16BITS(&egp->egp_hello),
- EXTRACT_16BITS(&egp->egp_poll));
+ EXTRACT_16BITS(&egp->egp_poll)));
break;
case EGPC_REFUSE:
case EGPC_CEASE:
case EGPC_CEASEACK:
- printf(" %s", egp_acquire_codes[code]);
+ ND_PRINT((ndo, " %s", egp_acquire_codes[code]));
switch (status ) {
case EGPS_UNSPEC:
case EGPS_NORES:
@@ -284,17 +301,17 @@ egp_print(register const u_int8_t *bp, register u_int length)
case EGPS_GODOWN:
case EGPS_PARAM:
case EGPS_PROTO:
- printf(" %s", egp_acquire_status[status]);
+ ND_PRINT((ndo, " %s", egp_acquire_status[status]));
break;
default:
- printf("[status %d]", status);
+ ND_PRINT((ndo, "[status %d]", status));
break;
}
break;
default:
- printf("[code %d]", code);
+ ND_PRINT((ndo, "[code %d]", code));
break;
}
break;
@@ -304,61 +321,64 @@ egp_print(register const u_int8_t *bp, register u_int length)
case EGPC_HELLO:
case EGPC_HEARDU:
- printf(" %s", egp_reach_codes[code]);
+ ND_PRINT((ndo, " %s", egp_reach_codes[code]));
if (status <= EGPS_DOWN)
- printf(" state:%s", egp_status_updown[status]);
+ ND_PRINT((ndo, " state:%s", egp_status_updown[status]));
else
- printf(" [status %d]", status);
+ ND_PRINT((ndo, " [status %d]", status));
break;
default:
- printf("[reach code %d]", code);
+ ND_PRINT((ndo, "[reach code %d]", code));
break;
}
break;
case EGPT_POLL:
- printf(" poll");
+ ND_PRINT((ndo, " poll"));
if (egp->egp_status <= EGPS_DOWN)
- printf(" state:%s", egp_status_updown[status]);
+ ND_PRINT((ndo, " state:%s", egp_status_updown[status]));
else
- printf(" [status %d]", status);
- printf(" net:%s", ipaddr_string(&egp->egp_sourcenet));
+ ND_PRINT((ndo, " [status %d]", status));
+ ND_PRINT((ndo, " net:%s", ipaddr_string(ndo, &egp->egp_sourcenet)));
break;
case EGPT_UPDATE:
- printf(" update");
+ ND_PRINT((ndo, " update"));
if (status & EGPS_UNSOL) {
status &= ~EGPS_UNSOL;
- printf(" unsolicited");
+ ND_PRINT((ndo, " unsolicited"));
}
if (status <= EGPS_DOWN)
- printf(" state:%s", egp_status_updown[status]);
+ ND_PRINT((ndo, " state:%s", egp_status_updown[status]));
else
- printf(" [status %d]", status);
- printf(" %s int %d ext %d",
- ipaddr_string(&egp->egp_sourcenet),
+ ND_PRINT((ndo, " [status %d]", status));
+ ND_PRINT((ndo, " %s int %d ext %d",
+ ipaddr_string(ndo, &egp->egp_sourcenet),
egp->egp_intgw,
- egp->egp_extgw);
- if (vflag)
- egpnrprint(egp);
+ egp->egp_extgw));
+ if (ndo->ndo_vflag)
+ egpnrprint(ndo, egp, length);
break;
case EGPT_ERROR:
- printf(" error");
+ ND_PRINT((ndo, " error"));
if (status <= EGPS_DOWN)
- printf(" state:%s", egp_status_updown[status]);
+ ND_PRINT((ndo, " state:%s", egp_status_updown[status]));
else
- printf(" [status %d]", status);
+ ND_PRINT((ndo, " [status %d]", status));
if (EXTRACT_16BITS(&egp->egp_reason) <= EGPR_UVERSION)
- printf(" %s", egp_reasons[EXTRACT_16BITS(&egp->egp_reason)]);
+ ND_PRINT((ndo, " %s", egp_reasons[EXTRACT_16BITS(&egp->egp_reason)]));
else
- printf(" [reason %d]", EXTRACT_16BITS(&egp->egp_reason));
+ ND_PRINT((ndo, " [reason %d]", EXTRACT_16BITS(&egp->egp_reason)));
break;
default:
- printf("[type %d]", type);
+ ND_PRINT((ndo, "[type %d]", type));
break;
}
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-egp-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-eigrp.c b/freebsd/contrib/tcpdump/print-eigrp.c
index 599fe89a..0fdf88c4 100644
--- a/freebsd/contrib/tcpdump/print-eigrp.c
+++ b/freebsd/contrib/tcpdump/print-eigrp.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1998-2004 Hannes Gredler <hannes@tcpdump.org>
* The TCPDUMP project
@@ -16,22 +19,17 @@
* FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-eigrp.c,v 1.7 2005-05-06 02:53:26 guy Exp $";
-#endif
+/* \summary: Enhanced Interior Gateway Routing Protocol (EIGRP) printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include <stdio.h>
-#include <stdlib.h>
#include <string.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
#include "addrtoname.h"
@@ -41,13 +39,13 @@ static const char rcsid[] _U_ =
*/
struct eigrp_common_header {
- u_int8_t version;
- u_int8_t opcode;
- u_int8_t checksum[2];
- u_int8_t flags[4];
- u_int8_t seq[4];
- u_int8_t ack[4];
- u_int8_t asn[4];
+ uint8_t version;
+ uint8_t opcode;
+ uint8_t checksum[2];
+ uint8_t flags[4];
+ uint8_t seq[4];
+ uint8_t ack[4];
+ uint8_t asn[4];
};
#define EIGRP_VERSION 2
@@ -76,8 +74,8 @@ static const struct tok eigrp_common_header_flag_values[] = {
};
struct eigrp_tlv_header {
- u_int8_t type[2];
- u_int8_t length[2];
+ uint8_t type[2];
+ uint8_t length[2];
};
#define EIGRP_TLV_GENERAL_PARM 0x0001
@@ -110,91 +108,91 @@ static const struct tok eigrp_tlv_values[] = {
};
struct eigrp_tlv_general_parm_t {
- u_int8_t k1;
- u_int8_t k2;
- u_int8_t k3;
- u_int8_t k4;
- u_int8_t k5;
- u_int8_t res;
- u_int8_t holdtime[2];
-};
+ uint8_t k1;
+ uint8_t k2;
+ uint8_t k3;
+ uint8_t k4;
+ uint8_t k5;
+ uint8_t res;
+ uint8_t holdtime[2];
+};
struct eigrp_tlv_sw_version_t {
- u_int8_t ios_major;
- u_int8_t ios_minor;
- u_int8_t eigrp_major;
- u_int8_t eigrp_minor;
-};
+ uint8_t ios_major;
+ uint8_t ios_minor;
+ uint8_t eigrp_major;
+ uint8_t eigrp_minor;
+};
struct eigrp_tlv_ip_int_t {
- u_int8_t nexthop[4];
- u_int8_t delay[4];
- u_int8_t bandwidth[4];
- u_int8_t mtu[3];
- u_int8_t hopcount;
- u_int8_t reliability;
- u_int8_t load;
- u_int8_t reserved[2];
- u_int8_t plen;
- u_int8_t destination; /* variable length [1-4] bytes encoding */
-};
+ uint8_t nexthop[4];
+ uint8_t delay[4];
+ uint8_t bandwidth[4];
+ uint8_t mtu[3];
+ uint8_t hopcount;
+ uint8_t reliability;
+ uint8_t load;
+ uint8_t reserved[2];
+ uint8_t plen;
+ uint8_t destination; /* variable length [1-4] bytes encoding */
+};
struct eigrp_tlv_ip_ext_t {
- u_int8_t nexthop[4];
- u_int8_t origin_router[4];
- u_int8_t origin_as[4];
- u_int8_t tag[4];
- u_int8_t metric[4];
- u_int8_t reserved[2];
- u_int8_t proto_id;
- u_int8_t flags;
- u_int8_t delay[4];
- u_int8_t bandwidth[4];
- u_int8_t mtu[3];
- u_int8_t hopcount;
- u_int8_t reliability;
- u_int8_t load;
- u_int8_t reserved2[2];
- u_int8_t plen;
- u_int8_t destination; /* variable length [1-4] bytes encoding */
-};
+ uint8_t nexthop[4];
+ uint8_t origin_router[4];
+ uint8_t origin_as[4];
+ uint8_t tag[4];
+ uint8_t metric[4];
+ uint8_t reserved[2];
+ uint8_t proto_id;
+ uint8_t flags;
+ uint8_t delay[4];
+ uint8_t bandwidth[4];
+ uint8_t mtu[3];
+ uint8_t hopcount;
+ uint8_t reliability;
+ uint8_t load;
+ uint8_t reserved2[2];
+ uint8_t plen;
+ uint8_t destination; /* variable length [1-4] bytes encoding */
+};
struct eigrp_tlv_at_cable_setup_t {
- u_int8_t cable_start[2];
- u_int8_t cable_end[2];
- u_int8_t router_id[4];
+ uint8_t cable_start[2];
+ uint8_t cable_end[2];
+ uint8_t router_id[4];
};
struct eigrp_tlv_at_int_t {
- u_int8_t nexthop[4];
- u_int8_t delay[4];
- u_int8_t bandwidth[4];
- u_int8_t mtu[3];
- u_int8_t hopcount;
- u_int8_t reliability;
- u_int8_t load;
- u_int8_t reserved[2];
- u_int8_t cable_start[2];
- u_int8_t cable_end[2];
-};
+ uint8_t nexthop[4];
+ uint8_t delay[4];
+ uint8_t bandwidth[4];
+ uint8_t mtu[3];
+ uint8_t hopcount;
+ uint8_t reliability;
+ uint8_t load;
+ uint8_t reserved[2];
+ uint8_t cable_start[2];
+ uint8_t cable_end[2];
+};
struct eigrp_tlv_at_ext_t {
- u_int8_t nexthop[4];
- u_int8_t origin_router[4];
- u_int8_t origin_as[4];
- u_int8_t tag[4];
- u_int8_t proto_id;
- u_int8_t flags;
- u_int8_t metric[2];
- u_int8_t delay[4];
- u_int8_t bandwidth[4];
- u_int8_t mtu[3];
- u_int8_t hopcount;
- u_int8_t reliability;
- u_int8_t load;
- u_int8_t reserved2[2];
- u_int8_t cable_start[2];
- u_int8_t cable_end[2];
+ uint8_t nexthop[4];
+ uint8_t origin_router[4];
+ uint8_t origin_as[4];
+ uint8_t tag[4];
+ uint8_t proto_id;
+ uint8_t flags;
+ uint8_t metric[2];
+ uint8_t delay[4];
+ uint8_t bandwidth[4];
+ uint8_t mtu[3];
+ uint8_t hopcount;
+ uint8_t reliability;
+ uint8_t load;
+ uint8_t reserved2[2];
+ uint8_t cable_start[2];
+ uint8_t cable_end[2];
};
static const struct tok eigrp_ext_proto_id_values[] = {
@@ -213,13 +211,13 @@ static const struct tok eigrp_ext_proto_id_values[] = {
};
void
-eigrp_print(register const u_char *pptr, register u_int len) {
-
+eigrp_print(netdissect_options *ndo, register const u_char *pptr, register u_int len)
+{
const struct eigrp_common_header *eigrp_com_header;
const struct eigrp_tlv_header *eigrp_tlv_header;
const u_char *tptr,*tlv_tptr;
u_int tlen,eigrp_tlv_len,eigrp_tlv_type,tlv_tlen, byte_length, bit_length;
- u_int8_t prefix[4];
+ uint8_t prefix[4];
union {
const struct eigrp_tlv_general_parm_t *eigrp_tlv_general_parm;
@@ -233,21 +231,21 @@ eigrp_print(register const u_char *pptr, register u_int len) {
tptr=pptr;
eigrp_com_header = (const struct eigrp_common_header *)pptr;
- TCHECK(*eigrp_com_header);
+ ND_TCHECK(*eigrp_com_header);
/*
* Sanity checking of the header.
*/
if (eigrp_com_header->version != EIGRP_VERSION) {
- printf("EIGRP version %u packet not supported",eigrp_com_header->version);
+ ND_PRINT((ndo, "EIGRP version %u packet not supported",eigrp_com_header->version));
return;
}
/* in non-verbose mode just lets print the basic Message Type*/
- if (vflag < 1) {
- printf("EIGRP %s, length: %u",
+ if (ndo->ndo_vflag < 1) {
+ ND_PRINT((ndo, "EIGRP %s, length: %u",
tok2str(eigrp_opcode_values, "unknown (%u)",eigrp_com_header->opcode),
- len);
+ len));
return;
}
@@ -256,7 +254,7 @@ eigrp_print(register const u_char *pptr, register u_int len) {
tlen=len-sizeof(struct eigrp_common_header);
/* FIXME print other header info */
- printf("\n\tEIGRP v%u, opcode: %s (%u), chksum: 0x%04x, Flags: [%s]\n\tseq: 0x%08x, ack: 0x%08x, AS: %u, length: %u",
+ ND_PRINT((ndo, "\n\tEIGRP v%u, opcode: %s (%u), chksum: 0x%04x, Flags: [%s]\n\tseq: 0x%08x, ack: 0x%08x, AS: %u, length: %u",
eigrp_com_header->version,
tok2str(eigrp_opcode_values, "unknown, type: %u",eigrp_com_header->opcode),
eigrp_com_header->opcode,
@@ -267,13 +265,13 @@ eigrp_print(register const u_char *pptr, register u_int len) {
EXTRACT_32BITS(&eigrp_com_header->seq),
EXTRACT_32BITS(&eigrp_com_header->ack),
EXTRACT_32BITS(&eigrp_com_header->asn),
- tlen);
+ tlen));
tptr+=sizeof(const struct eigrp_common_header);
while(tlen>0) {
/* did we capture enough for fully decoding the object header ? */
- TCHECK2(*tptr, sizeof(struct eigrp_tlv_header));
+ ND_TCHECK2(*tptr, sizeof(struct eigrp_tlv_header));
eigrp_tlv_header = (const struct eigrp_tlv_header *)tptr;
eigrp_tlv_len=EXTRACT_16BITS(&eigrp_tlv_header->length);
@@ -282,45 +280,45 @@ eigrp_print(register const u_char *pptr, register u_int len) {
if (eigrp_tlv_len < sizeof(struct eigrp_tlv_header) ||
eigrp_tlv_len > tlen) {
- print_unknown_data(tptr+sizeof(struct eigrp_tlv_header),"\n\t ",tlen);
+ print_unknown_data(ndo,tptr+sizeof(struct eigrp_tlv_header),"\n\t ",tlen);
return;
}
- printf("\n\t %s TLV (0x%04x), length: %u",
+ ND_PRINT((ndo, "\n\t %s TLV (0x%04x), length: %u",
tok2str(eigrp_tlv_values,
"Unknown",
eigrp_tlv_type),
eigrp_tlv_type,
- eigrp_tlv_len);
+ eigrp_tlv_len));
tlv_tptr=tptr+sizeof(struct eigrp_tlv_header);
tlv_tlen=eigrp_tlv_len-sizeof(struct eigrp_tlv_header);
/* did we capture enough for fully decoding the object ? */
- TCHECK2(*tptr, eigrp_tlv_len);
+ ND_TCHECK2(*tptr, eigrp_tlv_len);
switch(eigrp_tlv_type) {
case EIGRP_TLV_GENERAL_PARM:
tlv_ptr.eigrp_tlv_general_parm = (const struct eigrp_tlv_general_parm_t *)tlv_tptr;
- printf("\n\t holdtime: %us, k1 %u, k2 %u, k3 %u, k4 %u, k5 %u",
+ ND_PRINT((ndo, "\n\t holdtime: %us, k1 %u, k2 %u, k3 %u, k4 %u, k5 %u",
EXTRACT_16BITS(tlv_ptr.eigrp_tlv_general_parm->holdtime),
tlv_ptr.eigrp_tlv_general_parm->k1,
tlv_ptr.eigrp_tlv_general_parm->k2,
tlv_ptr.eigrp_tlv_general_parm->k3,
tlv_ptr.eigrp_tlv_general_parm->k4,
- tlv_ptr.eigrp_tlv_general_parm->k5);
+ tlv_ptr.eigrp_tlv_general_parm->k5));
break;
case EIGRP_TLV_SW_VERSION:
tlv_ptr.eigrp_tlv_sw_version = (const struct eigrp_tlv_sw_version_t *)tlv_tptr;
- printf("\n\t IOS version: %u.%u, EIGRP version %u.%u",
+ ND_PRINT((ndo, "\n\t IOS version: %u.%u, EIGRP version %u.%u",
tlv_ptr.eigrp_tlv_sw_version->ios_major,
tlv_ptr.eigrp_tlv_sw_version->ios_minor,
tlv_ptr.eigrp_tlv_sw_version->eigrp_major,
- tlv_ptr.eigrp_tlv_sw_version->eigrp_minor);
+ tlv_ptr.eigrp_tlv_sw_version->eigrp_minor));
break;
case EIGRP_TLV_IP_INT:
@@ -328,28 +326,28 @@ eigrp_print(register const u_char *pptr, register u_int len) {
bit_length = tlv_ptr.eigrp_tlv_ip_int->plen;
if (bit_length > 32) {
- printf("\n\t illegal prefix length %u",bit_length);
+ ND_PRINT((ndo, "\n\t illegal prefix length %u",bit_length));
break;
}
byte_length = (bit_length + 7) / 8; /* variable length encoding */
memset(prefix, 0, 4);
memcpy(prefix,&tlv_ptr.eigrp_tlv_ip_int->destination,byte_length);
- printf("\n\t IPv4 prefix: %15s/%u, nexthop: ",
- ipaddr_string(prefix),
- bit_length);
+ ND_PRINT((ndo, "\n\t IPv4 prefix: %15s/%u, nexthop: ",
+ ipaddr_string(ndo, prefix),
+ bit_length));
if (EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_ip_int->nexthop) == 0)
- printf("self");
+ ND_PRINT((ndo, "self"));
else
- printf("%s",ipaddr_string(&tlv_ptr.eigrp_tlv_ip_int->nexthop));
+ ND_PRINT((ndo, "%s",ipaddr_string(ndo, &tlv_ptr.eigrp_tlv_ip_int->nexthop)));
- printf("\n\t delay %u ms, bandwidth %u Kbps, mtu %u, hop %u, reliability %u, load %u",
+ ND_PRINT((ndo, "\n\t delay %u ms, bandwidth %u Kbps, mtu %u, hop %u, reliability %u, load %u",
(EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_ip_int->delay)/100),
EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_ip_int->bandwidth),
EXTRACT_24BITS(&tlv_ptr.eigrp_tlv_ip_int->mtu),
tlv_ptr.eigrp_tlv_ip_int->hopcount,
tlv_ptr.eigrp_tlv_ip_int->reliability,
- tlv_ptr.eigrp_tlv_ip_int->load);
+ tlv_ptr.eigrp_tlv_ip_int->load));
break;
case EIGRP_TLV_IP_EXT:
@@ -357,99 +355,99 @@ eigrp_print(register const u_char *pptr, register u_int len) {
bit_length = tlv_ptr.eigrp_tlv_ip_ext->plen;
if (bit_length > 32) {
- printf("\n\t illegal prefix length %u",bit_length);
+ ND_PRINT((ndo, "\n\t illegal prefix length %u",bit_length));
break;
}
byte_length = (bit_length + 7) / 8; /* variable length encoding */
memset(prefix, 0, 4);
memcpy(prefix,&tlv_ptr.eigrp_tlv_ip_ext->destination,byte_length);
- printf("\n\t IPv4 prefix: %15s/%u, nexthop: ",
- ipaddr_string(prefix),
- bit_length);
+ ND_PRINT((ndo, "\n\t IPv4 prefix: %15s/%u, nexthop: ",
+ ipaddr_string(ndo, prefix),
+ bit_length));
if (EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_ip_ext->nexthop) == 0)
- printf("self");
+ ND_PRINT((ndo, "self"));
else
- printf("%s",ipaddr_string(&tlv_ptr.eigrp_tlv_ip_ext->nexthop));
+ ND_PRINT((ndo, "%s",ipaddr_string(ndo, &tlv_ptr.eigrp_tlv_ip_ext->nexthop)));
- printf("\n\t origin-router %s, origin-as %u, origin-proto %s, flags [0x%02x], tag 0x%08x, metric %u",
- ipaddr_string(tlv_ptr.eigrp_tlv_ip_ext->origin_router),
+ ND_PRINT((ndo, "\n\t origin-router %s, origin-as %u, origin-proto %s, flags [0x%02x], tag 0x%08x, metric %u",
+ ipaddr_string(ndo, tlv_ptr.eigrp_tlv_ip_ext->origin_router),
EXTRACT_32BITS(tlv_ptr.eigrp_tlv_ip_ext->origin_as),
tok2str(eigrp_ext_proto_id_values,"unknown",tlv_ptr.eigrp_tlv_ip_ext->proto_id),
tlv_ptr.eigrp_tlv_ip_ext->flags,
EXTRACT_32BITS(tlv_ptr.eigrp_tlv_ip_ext->tag),
- EXTRACT_32BITS(tlv_ptr.eigrp_tlv_ip_ext->metric));
+ EXTRACT_32BITS(tlv_ptr.eigrp_tlv_ip_ext->metric)));
- printf("\n\t delay %u ms, bandwidth %u Kbps, mtu %u, hop %u, reliability %u, load %u",
+ ND_PRINT((ndo, "\n\t delay %u ms, bandwidth %u Kbps, mtu %u, hop %u, reliability %u, load %u",
(EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_ip_ext->delay)/100),
EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_ip_ext->bandwidth),
EXTRACT_24BITS(&tlv_ptr.eigrp_tlv_ip_ext->mtu),
tlv_ptr.eigrp_tlv_ip_ext->hopcount,
tlv_ptr.eigrp_tlv_ip_ext->reliability,
- tlv_ptr.eigrp_tlv_ip_ext->load);
+ tlv_ptr.eigrp_tlv_ip_ext->load));
break;
case EIGRP_TLV_AT_CABLE_SETUP:
tlv_ptr.eigrp_tlv_at_cable_setup = (const struct eigrp_tlv_at_cable_setup_t *)tlv_tptr;
- printf("\n\t Cable-range: %u-%u, Router-ID %u",
+ ND_PRINT((ndo, "\n\t Cable-range: %u-%u, Router-ID %u",
EXTRACT_16BITS(&tlv_ptr.eigrp_tlv_at_cable_setup->cable_start),
EXTRACT_16BITS(&tlv_ptr.eigrp_tlv_at_cable_setup->cable_end),
- EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_at_cable_setup->router_id));
+ EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_at_cable_setup->router_id)));
break;
case EIGRP_TLV_AT_INT:
tlv_ptr.eigrp_tlv_at_int = (const struct eigrp_tlv_at_int_t *)tlv_tptr;
- printf("\n\t Cable-Range: %u-%u, nexthop: ",
+ ND_PRINT((ndo, "\n\t Cable-Range: %u-%u, nexthop: ",
EXTRACT_16BITS(&tlv_ptr.eigrp_tlv_at_int->cable_start),
- EXTRACT_16BITS(&tlv_ptr.eigrp_tlv_at_int->cable_end));
+ EXTRACT_16BITS(&tlv_ptr.eigrp_tlv_at_int->cable_end)));
if (EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_at_int->nexthop) == 0)
- printf("self");
+ ND_PRINT((ndo, "self"));
else
- printf("%u.%u",
+ ND_PRINT((ndo, "%u.%u",
EXTRACT_16BITS(&tlv_ptr.eigrp_tlv_at_int->nexthop),
- EXTRACT_16BITS(&tlv_ptr.eigrp_tlv_at_int->nexthop[2]));
+ EXTRACT_16BITS(&tlv_ptr.eigrp_tlv_at_int->nexthop[2])));
- printf("\n\t delay %u ms, bandwidth %u Kbps, mtu %u, hop %u, reliability %u, load %u",
+ ND_PRINT((ndo, "\n\t delay %u ms, bandwidth %u Kbps, mtu %u, hop %u, reliability %u, load %u",
(EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_at_int->delay)/100),
EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_at_int->bandwidth),
EXTRACT_24BITS(&tlv_ptr.eigrp_tlv_at_int->mtu),
tlv_ptr.eigrp_tlv_at_int->hopcount,
tlv_ptr.eigrp_tlv_at_int->reliability,
- tlv_ptr.eigrp_tlv_at_int->load);
+ tlv_ptr.eigrp_tlv_at_int->load));
break;
case EIGRP_TLV_AT_EXT:
tlv_ptr.eigrp_tlv_at_ext = (const struct eigrp_tlv_at_ext_t *)tlv_tptr;
- printf("\n\t Cable-Range: %u-%u, nexthop: ",
+ ND_PRINT((ndo, "\n\t Cable-Range: %u-%u, nexthop: ",
EXTRACT_16BITS(&tlv_ptr.eigrp_tlv_at_ext->cable_start),
- EXTRACT_16BITS(&tlv_ptr.eigrp_tlv_at_ext->cable_end));
+ EXTRACT_16BITS(&tlv_ptr.eigrp_tlv_at_ext->cable_end)));
if (EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_at_ext->nexthop) == 0)
- printf("self");
+ ND_PRINT((ndo, "self"));
else
- printf("%u.%u",
+ ND_PRINT((ndo, "%u.%u",
EXTRACT_16BITS(&tlv_ptr.eigrp_tlv_at_ext->nexthop),
- EXTRACT_16BITS(&tlv_ptr.eigrp_tlv_at_ext->nexthop[2]));
+ EXTRACT_16BITS(&tlv_ptr.eigrp_tlv_at_ext->nexthop[2])));
- printf("\n\t origin-router %u, origin-as %u, origin-proto %s, flags [0x%02x], tag 0x%08x, metric %u",
+ ND_PRINT((ndo, "\n\t origin-router %u, origin-as %u, origin-proto %s, flags [0x%02x], tag 0x%08x, metric %u",
EXTRACT_32BITS(tlv_ptr.eigrp_tlv_at_ext->origin_router),
EXTRACT_32BITS(tlv_ptr.eigrp_tlv_at_ext->origin_as),
tok2str(eigrp_ext_proto_id_values,"unknown",tlv_ptr.eigrp_tlv_at_ext->proto_id),
tlv_ptr.eigrp_tlv_at_ext->flags,
EXTRACT_32BITS(tlv_ptr.eigrp_tlv_at_ext->tag),
- EXTRACT_16BITS(tlv_ptr.eigrp_tlv_at_ext->metric));
+ EXTRACT_16BITS(tlv_ptr.eigrp_tlv_at_ext->metric)));
- printf("\n\t delay %u ms, bandwidth %u Kbps, mtu %u, hop %u, reliability %u, load %u",
+ ND_PRINT((ndo, "\n\t delay %u ms, bandwidth %u Kbps, mtu %u, hop %u, reliability %u, load %u",
(EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_at_ext->delay)/100),
EXTRACT_32BITS(&tlv_ptr.eigrp_tlv_at_ext->bandwidth),
EXTRACT_24BITS(&tlv_ptr.eigrp_tlv_at_ext->mtu),
tlv_ptr.eigrp_tlv_at_ext->hopcount,
tlv_ptr.eigrp_tlv_at_ext->reliability,
- tlv_ptr.eigrp_tlv_at_ext->load);
+ tlv_ptr.eigrp_tlv_at_ext->load));
break;
/*
@@ -464,13 +462,13 @@ eigrp_print(register const u_char *pptr, register u_int len) {
case EIGRP_TLV_IPX_EXT:
default:
- if (vflag <= 1)
- print_unknown_data(tlv_tptr,"\n\t ",tlv_tlen);
+ if (ndo->ndo_vflag <= 1)
+ print_unknown_data(ndo,tlv_tptr,"\n\t ",tlv_tlen);
break;
}
/* do we want to see an additionally hexdump ? */
- if (vflag > 1)
- print_unknown_data(tptr+sizeof(struct eigrp_tlv_header),"\n\t ",
+ if (ndo->ndo_vflag > 1)
+ print_unknown_data(ndo,tptr+sizeof(struct eigrp_tlv_header),"\n\t ",
eigrp_tlv_len-sizeof(struct eigrp_tlv_header));
tptr+=eigrp_tlv_len;
@@ -478,5 +476,8 @@ eigrp_print(register const u_char *pptr, register u_int len) {
}
return;
trunc:
- printf("\n\t\t packet exceeded snapshot");
+ ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-eigrp-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-enc.c b/freebsd/contrib/tcpdump/print-enc.c
index db16f933..0a9d80e2 100644
--- a/freebsd/contrib/tcpdump/print-enc.c
+++ b/freebsd/contrib/tcpdump/print-enc.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/* $OpenBSD: print-enc.c,v 1.7 2002/02/19 19:39:40 millert Exp $ */
/*
@@ -23,33 +26,73 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-enc.c,v 1.6 2008-11-18 07:35:32 guy Exp $ (LBL)";
-#endif
+/* \summary: OpenBSD IPsec encapsulation BPF layer printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include <pcap.h>
-
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
-#include "addrtoname.h"
-#include "enc.h"
+/* From $OpenBSD: if_enc.h,v 1.8 2001/06/25 05:14:00 angelos Exp $ */
+/*
+ * The authors of this code are John Ioannidis (ji@tla.org),
+ * Angelos D. Keromytis (kermit@csd.uch.gr) and
+ * Niels Provos (provos@physnet.uni-hamburg.de).
+ *
+ * This code was written by John Ioannidis for BSD/OS in Athens, Greece,
+ * in November 1995.
+ *
+ * Ported to OpenBSD and NetBSD, with additional transforms, in December 1996,
+ * by Angelos D. Keromytis.
+ *
+ * Additional transforms and features in 1997 and 1998 by Angelos D. Keromytis
+ * and Niels Provos.
+ *
+ * Copyright (C) 1995, 1996, 1997, 1998 by John Ioannidis, Angelos D. Keromytis
+ * and Niels Provos.
+ * Copyright (c) 2001, Angelos D. Keromytis.
+ *
+ * Permission to use, copy, and modify this software with or without fee
+ * is hereby granted, provided that this entire notice is included in
+ * all copies of any software which is or includes a copy or
+ * modification of this software.
+ * You may use this code under the GNU public license if you so wish. Please
+ * contribute changes back to the authors under this freer than GPL license
+ * so that we may further the use of strong encryption without limitations to
+ * all.
+ *
+ * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTY. IN PARTICULAR, NONE OF THE AUTHORS MAKES ANY
+ * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE
+ * MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR
+ * PURPOSE.
+ */
+
+#define ENC_HDRLEN 12
+
+/* From $OpenBSD: mbuf.h,v 1.56 2002/01/25 15:50:23 art Exp $ */
+#define M_CONF 0x0400 /* packet was encrypted (ESP-transport) */
+#define M_AUTH 0x0800 /* packet was authenticated (AH) */
+
+struct enchdr {
+ uint32_t af;
+ uint32_t spi;
+ uint32_t flags;
+};
#define ENC_PRINT_TYPE(wh, xf, nam) \
if ((wh) & (xf)) { \
- printf("%s%s", nam, (wh) == (xf) ? "): " : ","); \
+ ND_PRINT((ndo, "%s%s", nam, (wh) == (xf) ? "): " : ",")); \
(wh) &= ~(xf); \
}
u_int
-enc_if_print(const struct pcap_pkthdr *h, register const u_char *p)
+enc_if_print(netdissect_options *ndo,
+ const struct pcap_pkthdr *h, register const u_char *p)
{
register u_int length = h->len;
register u_int caplen = h->caplen;
@@ -57,34 +100,34 @@ enc_if_print(const struct pcap_pkthdr *h, register const u_char *p)
const struct enchdr *hdr;
if (caplen < ENC_HDRLEN) {
- printf("[|enc]");
+ ND_PRINT((ndo, "[|enc]"));
goto out;
}
- hdr = (struct enchdr *)p;
+ hdr = (const struct enchdr *)p;
flags = hdr->flags;
if (flags == 0)
- printf("(unprotected): ");
+ ND_PRINT((ndo, "(unprotected): "));
else
- printf("(");
+ ND_PRINT((ndo, "("));
ENC_PRINT_TYPE(flags, M_AUTH, "authentic");
ENC_PRINT_TYPE(flags, M_CONF, "confidential");
/* ENC_PRINT_TYPE(flags, M_TUNNEL, "tunnel"); */
- printf("SPI 0x%08x: ", EXTRACT_32BITS(&hdr->spi));
+ ND_PRINT((ndo, "SPI 0x%08x: ", EXTRACT_32BITS(&hdr->spi)));
length -= ENC_HDRLEN;
caplen -= ENC_HDRLEN;
p += ENC_HDRLEN;
-
+
switch (hdr->af) {
case AF_INET:
- ip_print(gndo, p, length);
+ ip_print(ndo, p, length);
break;
-#ifdef INET6
+#ifdef AF_INET6
case AF_INET6:
- ip6_print(gndo, p, length);
+ ip6_print(ndo, p, length);
break;
-#endif /*INET6*/
+#endif
}
out:
@@ -98,3 +141,6 @@ out:
* c-basic-offset: 8
* End:
*/
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-enc-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-esp.c b/freebsd/contrib/tcpdump/print-esp.c
index 6bf04dd0..81a87575 100644
--- a/freebsd/contrib/tcpdump/print-esp.c
+++ b/freebsd/contrib/tcpdump/print-esp.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/* $NetBSD: print-ah.c,v 1.4 1996/05/20 00:41:16 fvdl Exp $ */
/*
@@ -23,57 +26,92 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-esp.c,v 1.58 2007-12-07 00:03:07 mcr Exp $ (LBL)";
-#endif
+/* \summary: IPSEC Encapsulating Security Payload (ESP) printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <string.h>
-
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
+#include <string.h>
#include <stdlib.h>
+/* Any code in this file that depends on HAVE_LIBCRYPTO depends on
+ * HAVE_OPENSSL_EVP_H too. Undefining the former when the latter isn't defined
+ * is the simplest way of handling the dependency.
+ */
#ifdef HAVE_LIBCRYPTO
#ifdef HAVE_OPENSSL_EVP_H
#include <openssl/evp.h>
+#else
+#undef HAVE_LIBCRYPTO
#endif
#endif
-#include <stdio.h>
+#include "netdissect.h"
+#include "strtoaddr.h"
+#include "extract.h"
+
+#include "ascii_strcasecmp.h"
#include "ip.h"
-#include "esp.h"
-#ifdef INET6
#include "ip6.h"
-#endif
-#include "netdissect.h"
-#include "addrtoname.h"
-#include "extract.h"
+/*
+ * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
+ * All rights reserved.
+ *
+ * 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.
+ */
+
+/*
+ * RFC1827/2406 Encapsulated Security Payload.
+ */
-#ifndef HAVE_SOCKADDR_STORAGE
-#ifdef INET6
-struct sockaddr_storage {
- union {
- struct sockaddr_in sin;
- struct sockaddr_in6 sin6;
- } un;
+struct newesp {
+ uint32_t esp_spi; /* ESP */
+ uint32_t esp_seq; /* Sequence number */
+ /*variable size*/ /* (IV and) Payload data */
+ /*variable size*/ /* padding */
+ /*8bit*/ /* pad size */
+ /*8bit*/ /* next header */
+ /*8bit*/ /* next header */
+ /*variable size, 32bit bound*/ /* Authentication data */
};
-#else
-#define sockaddr_storage sockaddr
-#endif
-#endif /* HAVE_SOCKADDR_STORAGE */
#ifdef HAVE_LIBCRYPTO
+union inaddr_u {
+ struct in_addr in4;
+ struct in6_addr in6;
+};
struct sa_list {
struct sa_list *next;
- struct sockaddr_storage daddr;
- u_int32_t spi; /* if == 0, then IKEv2 */
+ u_int daddr_version;
+ union inaddr_u daddr;
+ uint32_t spi; /* if == 0, then IKEv2 */
int initiator;
u_char spii[8]; /* for IKEv2 */
u_char spir[8];
@@ -86,22 +124,49 @@ struct sa_list {
int secretlen;
};
+#ifndef HAVE_EVP_CIPHER_CTX_NEW
+/*
+ * Allocate an EVP_CIPHER_CTX.
+ * Used if we have an older version of OpenSSL that doesn't provide
+ * routines to allocate and free them.
+ */
+static EVP_CIPHER_CTX *
+EVP_CIPHER_CTX_new(void)
+{
+ EVP_CIPHER_CTX *ctx;
+
+ ctx = malloc(sizeof(*ctx));
+ if (ctx == NULL)
+ return (NULL);
+ memset(ctx, 0, sizeof(*ctx));
+ return (ctx);
+}
+
+static void
+EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *ctx)
+{
+ EVP_CIPHER_CTX_cleanup(ctx);
+ free(ctx);
+}
+#endif
+
/*
* this will adjust ndo_packetp and ndo_snapend to new buffer!
*/
+USES_APPLE_DEPRECATED_API
int esp_print_decrypt_buffer_by_ikev2(netdissect_options *ndo,
int initiator,
u_char spii[8], u_char spir[8],
- u_char *buf, u_char *end)
+ const u_char *buf, const u_char *end)
{
struct sa_list *sa;
- u_char *iv;
+ const u_char *iv;
int len;
- EVP_CIPHER_CTX ctx;
+ EVP_CIPHER_CTX *ctx;
/* initiator arg is any non-zero value */
if(initiator) initiator=1;
-
+
/* see if we can find the SA, and if so, decode it */
for (sa = ndo->ndo_sa_list_head; sa != NULL; sa = sa->next) {
if (sa->spi == 0
@@ -125,19 +190,22 @@ int esp_print_decrypt_buffer_by_ikev2(netdissect_options *ndo,
if(end <= buf) return 0;
- memset(&ctx, 0, sizeof(ctx));
- if (EVP_CipherInit(&ctx, sa->evp, sa->secret, NULL, 0) < 0)
+ ctx = EVP_CIPHER_CTX_new();
+ if (ctx == NULL)
+ return 0;
+ if (EVP_CipherInit(ctx, sa->evp, sa->secret, NULL, 0) < 0)
(*ndo->ndo_warning)(ndo, "espkey init failed");
- EVP_CipherInit(&ctx, NULL, NULL, iv, 0);
- EVP_Cipher(&ctx, buf, buf, len);
- EVP_CIPHER_CTX_cleanup(&ctx);
+ EVP_CipherInit(ctx, NULL, NULL, iv, 0);
+ EVP_Cipher(ctx, __DECONST(u_char *, buf), buf, len);
+ EVP_CIPHER_CTX_free(ctx);
ndo->ndo_packetp = buf;
ndo->ndo_snapend = end;
return 1;
-
+
}
+USES_APPLE_RST
static void esp_print_addsa(netdissect_options *ndo,
struct sa_list *sa, int sa_def)
@@ -194,12 +262,12 @@ int espprint_decode_hex(netdissect_options *ndo,
int i;
len = strlen(hex) / 2;
-
+
if (len > binbuf_len) {
(*ndo->ndo_warning)(ndo, "secret is too big: %d\n", len);
return 0;
}
-
+
i = 0;
while (hex[0] != '\0' && hex[1]!='\0') {
binbuf[i] = hex2byte(ndo, hex);
@@ -214,24 +282,23 @@ int espprint_decode_hex(netdissect_options *ndo,
* decode the form: SPINUM@IP <tab> ALGONAME:0xsecret
*/
+USES_APPLE_DEPRECATED_API
static int
espprint_decode_encalgo(netdissect_options *ndo,
char *decode, struct sa_list *sa)
{
- int len;
size_t i;
const EVP_CIPHER *evp;
int authlen = 0;
char *colon, *p;
-
+
colon = strchr(decode, ':');
if (colon == NULL) {
(*ndo->ndo_warning)(ndo, "failed to decode espsecret: %s\n", decode);
return 0;
}
*colon = '\0';
-
- len = colon - decode;
+
if (strlen(decode) > strlen("-hmac96") &&
!strcmp(decode + strlen(decode) - strlen("-hmac96"),
"-hmac96")) {
@@ -253,11 +320,11 @@ espprint_decode_encalgo(netdissect_options *ndo,
sa->ivlen = 0;
return 0;
}
-
+
sa->evp = evp;
sa->authlen = authlen;
sa->ivlen = EVP_CIPHER_iv_length(evp);
-
+
colon++;
if (colon[0] == '0' && colon[1] == 'x') {
/* decode some hex! */
@@ -267,7 +334,7 @@ espprint_decode_encalgo(netdissect_options *ndo,
if(sa->secretlen == 0) return 0;
} else {
i = strlen(colon);
-
+
if (i < sizeof(sa->secret)) {
memcpy(sa->secret, colon, i);
sa->secretlen = i;
@@ -279,6 +346,7 @@ espprint_decode_encalgo(netdissect_options *ndo,
return 1;
}
+USES_APPLE_RST
/*
* for the moment, ignore the auth algorith, just hard code the authenticator
@@ -296,9 +364,9 @@ espprint_decode_authalgo(netdissect_options *ndo,
return 0;
}
*colon = '\0';
-
- if(strcasecmp(colon,"sha1") == 0 ||
- strcasecmp(colon,"md5") == 0) {
+
+ if(ascii_strcasecmp(colon,"sha1") == 0 ||
+ ascii_strcasecmp(colon,"md5") == 0) {
sa->authlen = 12;
}
return 1;
@@ -315,21 +383,21 @@ static void esp_print_decode_ikeline(netdissect_options *ndo, char *line,
int ilen, rlen;
char *authkey;
char *enckey;
-
+
init = strsep(&line, " \t");
icookie = strsep(&line, " \t");
rcookie = strsep(&line, " \t");
authkey = strsep(&line, " \t");
enckey = strsep(&line, " \t");
-
+
/* if any fields are missing */
if(!init || !icookie || !rcookie || !authkey || !enckey) {
(*ndo->ndo_warning)(ndo, "print_esp: failed to find all fields for ikev2 at %s:%u",
file, lineno);
-
+
return;
}
-
+
ilen = strlen(icookie);
rlen = strlen(rcookie);
@@ -343,7 +411,7 @@ static void esp_print_decode_ikeline(netdissect_options *ndo, char *line,
(*ndo->ndo_warning)(ndo, "init=%s icookie=%s(%u) rcookie=%s(%u)",
init, icookie, ilen, rcookie, rlen);
-
+
return;
}
@@ -358,7 +426,7 @@ static void esp_print_decode_ikeline(netdissect_options *ndo, char *line,
if(!espprint_decode_encalgo(ndo, enckey, &sa1)) return;
if(!espprint_decode_authalgo(ndo, authkey, &sa1)) return;
-
+
esp_print_addsa(ndo, &sa1, FALSE);
}
@@ -385,28 +453,30 @@ static void esp_print_decode_onesecret(netdissect_options *ndo, char *line,
if (line == NULL) {
decode = spikey;
spikey = NULL;
+ /* sa1.daddr.version = 0; */
/* memset(&sa1.daddr, 0, sizeof(sa1.daddr)); */
/* sa1.spi = 0; */
sa_def = 1;
} else
decode = line;
- if (spikey && strcasecmp(spikey, "file") == 0) {
+ if (spikey && ascii_strcasecmp(spikey, "file") == 0) {
/* open file and read it */
FILE *secretfile;
char fileline[1024];
- int lineno=0;
+ int subfile_lineno=0;
char *nl;
char *filename = line;
secretfile = fopen(filename, FOPEN_READ_TXT);
if (secretfile == NULL) {
- perror(filename);
- exit(3);
+ (*ndo->ndo_error)(ndo, "print_esp: can't open %s: %s\n",
+ filename, strerror(errno));
+ return;
}
while (fgets(fileline, sizeof(fileline)-1, secretfile) != NULL) {
- lineno++;
+ subfile_lineno++;
/* remove newline from the line */
nl = strchr(fileline, '\n');
if (nl)
@@ -414,63 +484,48 @@ static void esp_print_decode_onesecret(netdissect_options *ndo, char *line,
if (fileline[0] == '#') continue;
if (fileline[0] == '\0') continue;
- esp_print_decode_onesecret(ndo, fileline, filename, lineno);
+ esp_print_decode_onesecret(ndo, fileline, filename, subfile_lineno);
}
fclose(secretfile);
return;
}
- if (spikey && strcasecmp(spikey, "ikev2") == 0) {
+ if (spikey && ascii_strcasecmp(spikey, "ikev2") == 0) {
esp_print_decode_ikeline(ndo, line, file, lineno);
return;
- }
+ }
if (spikey) {
-
+
char *spistr, *foo;
- u_int32_t spino;
- struct sockaddr_in *sin;
-#ifdef INET6
- struct sockaddr_in6 *sin6;
-#endif
-
+ uint32_t spino;
+
spistr = strsep(&spikey, "@");
-
+
spino = strtoul(spistr, &foo, 0);
if (spistr == foo || !spikey) {
(*ndo->ndo_warning)(ndo, "print_esp: failed to decode spi# %s\n", foo);
return;
}
-
+
sa1.spi = spino;
-
- sin = (struct sockaddr_in *)&sa1.daddr;
-#ifdef INET6
- sin6 = (struct sockaddr_in6 *)&sa1.daddr;
- if (inet_pton(AF_INET6, spikey, &sin6->sin6_addr) == 1) {
-#ifdef HAVE_SOCKADDR_SA_LEN
- sin6->sin6_len = sizeof(struct sockaddr_in6);
-#endif
- sin6->sin6_family = AF_INET6;
- } else
-#endif
- if (inet_pton(AF_INET, spikey, &sin->sin_addr) == 1) {
-#ifdef HAVE_SOCKADDR_SA_LEN
- sin->sin_len = sizeof(struct sockaddr_in);
-#endif
- sin->sin_family = AF_INET;
- } else {
- (*ndo->ndo_warning)(ndo, "print_esp: can not decode IP# %s\n", spikey);
- return;
- }
+
+ if (strtoaddr6(spikey, &sa1.daddr.in6) == 1) {
+ sa1.daddr_version = 6;
+ } else if (strtoaddr(spikey, &sa1.daddr.in4) == 1) {
+ sa1.daddr_version = 4;
+ } else {
+ (*ndo->ndo_warning)(ndo, "print_esp: can not decode IP# %s\n", spikey);
+ return;
+ }
}
if (decode) {
/* skip any blank spaces */
while (isspace((unsigned char)*decode))
decode++;
-
+
if(!espprint_decode_encalgo(ndo, decode, &sa1)) {
return;
}
@@ -479,12 +534,20 @@ static void esp_print_decode_onesecret(netdissect_options *ndo, char *line,
esp_print_addsa(ndo, &sa1, sa_def);
}
+USES_APPLE_DEPRECATED_API
static void esp_init(netdissect_options *ndo _U_)
{
-
+ /*
+ * 0.9.6 doesn't appear to define OPENSSL_API_COMPAT, so
+ * we check whether it's undefined or it's less than the
+ * value for 1.1.0.
+ */
+#if !defined(OPENSSL_API_COMPAT) || OPENSSL_API_COMPAT < 0x10100000L
OpenSSL_add_all_algorithms();
+#endif
EVP_add_cipher_alias(SN_des_ede3_cbc, "3des");
}
+USES_APPLE_RST
void esp_print_decodesecret(netdissect_options *ndo)
{
@@ -514,6 +577,9 @@ void esp_print_decodesecret(netdissect_options *ndo)
#endif
+#ifdef HAVE_LIBCRYPTO
+USES_APPLE_DEPRECATED_API
+#endif
int
esp_print(netdissect_options *ndo,
const u_char *bp, const int length, const u_char *bp2
@@ -535,23 +601,19 @@ esp_print(netdissect_options *ndo,
register const struct newesp *esp;
register const u_char *ep;
#ifdef HAVE_LIBCRYPTO
- struct ip *ip;
+ const struct ip *ip;
struct sa_list *sa = NULL;
- int espsecret_keylen;
-#ifdef INET6
- struct ip6_hdr *ip6 = NULL;
-#endif
+ const struct ip6_hdr *ip6 = NULL;
int advance;
int len;
u_char *secret;
int ivlen = 0;
- u_char *ivoff;
- u_char *p;
- EVP_CIPHER_CTX ctx;
- int blocksz;
+ const u_char *ivoff;
+ const u_char *p;
+ EVP_CIPHER_CTX *ctx;
#endif
- esp = (struct newesp *)bp;
+ esp = (const struct newesp *)bp;
#ifdef HAVE_LIBCRYPTO
secret = NULL;
@@ -566,13 +628,13 @@ esp_print(netdissect_options *ndo,
/* 'ep' points to the end of available data. */
ep = ndo->ndo_snapend;
- if ((u_char *)(esp + 1) >= ep) {
- fputs("[|ESP]", stdout);
+ if ((const u_char *)(esp + 1) >= ep) {
+ ND_PRINT((ndo, "[|ESP]"));
goto fail;
}
- (*ndo->ndo_printf)(ndo, "ESP(spi=0x%08x", EXTRACT_32BITS(&esp->esp_spi));
- (*ndo->ndo_printf)(ndo, ",seq=0x%x)", EXTRACT_32BITS(&esp->esp_seq));
- (*ndo->ndo_printf)(ndo, ", length %u", length);
+ ND_PRINT((ndo, "ESP(spi=0x%08x", EXTRACT_32BITS(&esp->esp_spi)));
+ ND_PRINT((ndo, ",seq=0x%x)", EXTRACT_32BITS(&esp->esp_seq)));
+ ND_PRINT((ndo, ", length %u", length));
#ifndef HAVE_LIBCRYPTO
goto fail;
@@ -588,11 +650,10 @@ esp_print(netdissect_options *ndo,
if (ndo->ndo_sa_list_head == NULL)
goto fail;
- ip = (struct ip *)bp2;
+ ip = (const struct ip *)bp2;
switch (IP_V(ip)) {
-#ifdef INET6
case 6:
- ip6 = (struct ip6_hdr *)bp2;
+ ip6 = (const struct ip6_hdr *)bp2;
/* we do not attempt to decrypt jumbograms */
if (!EXTRACT_16BITS(&ip6->ip6_plen))
goto fail;
@@ -601,16 +662,14 @@ esp_print(netdissect_options *ndo,
/* see if we can find the SA, and if so, decode it */
for (sa = ndo->ndo_sa_list_head; sa != NULL; sa = sa->next) {
- struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)&sa->daddr;
if (sa->spi == EXTRACT_32BITS(&esp->esp_spi) &&
- sin6->sin6_family == AF_INET6 &&
- memcmp(&sin6->sin6_addr, &ip6->ip6_dst,
+ sa->daddr_version == 6 &&
+ UNALIGNED_MEMCMP(&sa->daddr.in6, &ip6->ip6_dst,
sizeof(struct in6_addr)) == 0) {
break;
}
}
break;
-#endif /*INET6*/
case 4:
/* nexthdr & padding are in the last fragment */
if (EXTRACT_16BITS(&ip->ip_off) & IP_MF)
@@ -619,10 +678,10 @@ esp_print(netdissect_options *ndo,
/* see if we can find the SA, and if so, decode it */
for (sa = ndo->ndo_sa_list_head; sa != NULL; sa = sa->next) {
- struct sockaddr_in *sin = (struct sockaddr_in *)&sa->daddr;
if (sa->spi == EXTRACT_32BITS(&esp->esp_spi) &&
- sin->sin_family == AF_INET &&
- sin->sin_addr.s_addr == ip->ip_dst.s_addr) {
+ sa->daddr_version == 4 &&
+ UNALIGNED_MEMCMP(&sa->daddr.in4, &ip->ip_dst,
+ sizeof(struct in_addr)) == 0) {
break;
}
}
@@ -636,7 +695,7 @@ esp_print(netdissect_options *ndo,
*/
if (sa == NULL)
sa = ndo->ndo_sa_default;
-
+
/* if not found fail */
if (sa == NULL)
goto fail;
@@ -649,24 +708,25 @@ esp_print(netdissect_options *ndo,
ep = bp2 + len;
}
- ivoff = (u_char *)(esp + 1) + 0;
+ ivoff = (const u_char *)(esp + 1) + 0;
ivlen = sa->ivlen;
secret = sa->secret;
- espsecret_keylen = sa->secretlen;
ep = ep - sa->authlen;
if (sa->evp) {
- memset(&ctx, 0, sizeof(ctx));
- if (EVP_CipherInit(&ctx, sa->evp, secret, NULL, 0) < 0)
- (*ndo->ndo_warning)(ndo, "espkey init failed");
-
- blocksz = EVP_CIPHER_CTX_block_size(&ctx);
-
- p = ivoff;
- EVP_CipherInit(&ctx, NULL, NULL, p, 0);
- EVP_Cipher(&ctx, p + ivlen, p + ivlen, ep - (p + ivlen));
- EVP_CIPHER_CTX_cleanup(&ctx);
- advance = ivoff - (u_char *)esp + ivlen;
+ ctx = EVP_CIPHER_CTX_new();
+ if (ctx != NULL) {
+ if (EVP_CipherInit(ctx, sa->evp, secret, NULL, 0) < 0)
+ (*ndo->ndo_warning)(ndo, "espkey init failed");
+
+ p = ivoff;
+ EVP_CipherInit(ctx, NULL, NULL, p, 0);
+ EVP_Cipher(ctx, __DECONST(u_char *, p + ivlen),
+ p + ivlen, ep - (p + ivlen));
+ EVP_CIPHER_CTX_free(ctx);
+ advance = ivoff - (const u_char *)esp + ivlen;
+ } else
+ advance = sizeof(struct newesp);
} else
advance = sizeof(struct newesp);
@@ -680,13 +740,16 @@ esp_print(netdissect_options *ndo,
if (nhdr)
*nhdr = *(ep - 1);
- (ndo->ndo_printf)(ndo, ": ");
+ ND_PRINT((ndo, ": "));
return advance;
#endif
fail:
return -1;
}
+#ifdef HAVE_LIBCRYPTO
+USES_APPLE_RST
+#endif
/*
* Local Variables:
@@ -694,3 +757,6 @@ fail:
* c-basic-offset: 8
* End:
*/
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-esp-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-ether.c b/freebsd/contrib/tcpdump/print-ether.c
index aaf067b1..d6f78804 100644
--- a/freebsd/contrib/tcpdump/print-ether.c
+++ b/freebsd/contrib/tcpdump/print-ether.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2000
* The Regents of the University of California. All rights reserved.
@@ -19,31 +22,23 @@
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * $FreeBSD$
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.106 2008-02-06 10:47:53 guy Exp $ (LBL)";
-#endif
-#define NETDISSECT_REWORKED
+/* \summary: Ethernet printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
-
-#include <stdio.h>
-#include <pcap.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
#include "addrtoname.h"
#include "ethertype.h"
#include "ether.h"
-const struct tok ethertype_values[] = {
+const struct tok ethertype_values[] = {
{ ETHERTYPE_IP, "IPv4" },
{ ETHERTYPE_MPLS, "MPLS unicast" },
{ ETHERTYPE_MPLS_MULTI, "MPLS multicast" },
@@ -87,8 +82,14 @@ const struct tok ethertype_values[] = {
{ ETHERTYPE_GRE_ISO, "GRE-OSI" },
{ ETHERTYPE_CFM_OLD, "CFM (old)" },
{ ETHERTYPE_CFM, "CFM" },
+ { ETHERTYPE_IEEE1905_1, "IEEE1905.1" },
{ ETHERTYPE_LLDP, "LLDP" },
- { ETHERTYPE_TIPC, "TIPC"},
+ { ETHERTYPE_TIPC, "TIPC"},
+ { ETHERTYPE_GEONET_OLD, "GeoNet (old)"},
+ { ETHERTYPE_GEONET, "GeoNet"},
+ { ETHERTYPE_CALM_FAST, "CALM FAST"},
+ { ETHERTYPE_AOE, "AoE" },
+ { ETHERTYPE_MEDSA, "MEDSA" },
{ 0, NULL}
};
@@ -97,30 +98,32 @@ ether_hdr_print(netdissect_options *ndo,
const u_char *bp, u_int length)
{
register const struct ether_header *ep;
- u_int16_t ether_type;
+ uint16_t length_type;
ep = (const struct ether_header *)bp;
- (void)ND_PRINT((ndo, "%s > %s",
- etheraddr_string(ESRC(ep)),
- etheraddr_string(EDST(ep))));
+ ND_PRINT((ndo, "%s > %s",
+ etheraddr_string(ndo, ESRC(ep)),
+ etheraddr_string(ndo, EDST(ep))));
- ether_type = EXTRACT_16BITS(&ep->ether_type);
+ length_type = EXTRACT_16BITS(&ep->ether_length_type);
if (!ndo->ndo_qflag) {
- if (ether_type <= ETHERMTU)
- (void)ND_PRINT((ndo, ", 802.3"));
- else
- (void)ND_PRINT((ndo, ", ethertype %s (0x%04x)",
- tok2str(ethertype_values,"Unknown", ether_type),
- ether_type));
+ if (length_type <= ETHERMTU) {
+ ND_PRINT((ndo, ", 802.3"));
+ length = length_type;
+ } else
+ ND_PRINT((ndo, ", ethertype %s (0x%04x)",
+ tok2str(ethertype_values,"Unknown", length_type),
+ length_type));
} else {
- if (ether_type <= ETHERMTU)
- (void)ND_PRINT((ndo, ", 802.3"));
- else
- (void)ND_PRINT((ndo, ", %s", tok2str(ethertype_values,"Unknown Ethertype (0x%04x)", ether_type)));
+ if (length_type <= ETHERMTU) {
+ ND_PRINT((ndo, ", 802.3"));
+ length = length_type;
+ } else
+ ND_PRINT((ndo, ", %s", tok2str(ethertype_values,"Unknown Ethertype (0x%04x)", length_type)));
}
- (void)ND_PRINT((ndo, ", length %u: ", length));
+ ND_PRINT((ndo, ", length %u: ", length));
}
/*
@@ -128,20 +131,28 @@ ether_hdr_print(netdissect_options *ndo,
* This might be encapsulated within another frame; we might be passed
* a pointer to a function that can print header information for that
* frame's protocol, and an argument to pass to that function.
+ *
+ * FIXME: caplen can and should be derived from ndo->ndo_snapend and p.
*/
-void
+u_int
ether_print(netdissect_options *ndo,
const u_char *p, u_int length, u_int caplen,
void (*print_encap_header)(netdissect_options *ndo, const u_char *), const u_char *encap_header_arg)
{
- struct ether_header *ep;
+ const struct ether_header *ep;
u_int orig_length;
- u_short ether_type;
- u_short extracted_ether_type;
+ u_short length_type;
+ u_int hdrlen;
+ int llc_hdrlen;
+ struct lladdr_info src, dst;
- if (caplen < ETHER_HDRLEN || length < ETHER_HDRLEN) {
+ if (caplen < ETHER_HDRLEN) {
+ ND_PRINT((ndo, "[|ether]"));
+ return (caplen);
+ }
+ if (length < ETHER_HDRLEN) {
ND_PRINT((ndo, "[|ether]"));
- return;
+ return (length);
}
if (ndo->ndo_eflag) {
@@ -153,58 +164,61 @@ ether_print(netdissect_options *ndo,
length -= ETHER_HDRLEN;
caplen -= ETHER_HDRLEN;
- ep = (struct ether_header *)p;
+ ep = (const struct ether_header *)p;
p += ETHER_HDRLEN;
+ hdrlen = ETHER_HDRLEN;
- ether_type = EXTRACT_16BITS(&ep->ether_type);
+ src.addr = ESRC(ep);
+ src.addr_string = etheraddr_string;
+ dst.addr = EDST(ep);
+ dst.addr_string = etheraddr_string;
+ length_type = EXTRACT_16BITS(&ep->ether_length_type);
recurse:
/*
* Is it (gag) an 802.3 encapsulation?
*/
- if (ether_type <= ETHERMTU) {
+ if (length_type <= ETHERMTU) {
/* Try to print the LLC-layer header & higher layers */
- if (llc_print(p, length, caplen, ESRC(ep), EDST(ep),
- &extracted_ether_type) == 0) {
- /* ether_type not known, print raw packet */
- if (!ndo->ndo_eflag) {
- if (print_encap_header != NULL)
- (*print_encap_header)(ndo, encap_header_arg);
- ether_hdr_print(ndo, (u_char *)ep, orig_length);
- }
-
+ llc_hdrlen = llc_print(ndo, p, length, caplen, &src, &dst);
+ if (llc_hdrlen < 0) {
+ /* packet type not known, print raw packet */
if (!ndo->ndo_suppress_default_print)
- ndo->ndo_default_print(ndo, p, caplen);
+ ND_DEFAULTPRINT(p, caplen);
+ llc_hdrlen = -llc_hdrlen;
}
- } else if (ether_type == ETHERTYPE_8021Q ||
- ether_type == ETHERTYPE_8021Q9100 ||
- ether_type == ETHERTYPE_8021Q9200 ||
- ether_type == ETHERTYPE_8021QinQ) {
+ hdrlen += llc_hdrlen;
+ } else if (length_type == ETHERTYPE_8021Q ||
+ length_type == ETHERTYPE_8021Q9100 ||
+ length_type == ETHERTYPE_8021Q9200 ||
+ length_type == ETHERTYPE_8021QinQ) {
/*
* Print VLAN information, and then go back and process
* the enclosed type field.
*/
- if (caplen < 4 || length < 4) {
+ if (caplen < 4) {
+ ND_PRINT((ndo, "[|vlan]"));
+ return (hdrlen + caplen);
+ }
+ if (length < 4) {
ND_PRINT((ndo, "[|vlan]"));
- return;
+ return (hdrlen + length);
}
if (ndo->ndo_eflag) {
- u_int16_t tag = EXTRACT_16BITS(p);
+ uint16_t tag = EXTRACT_16BITS(p);
- ND_PRINT((ndo, "vlan %u, p %u%s, ",
- tag & 0xfff,
- tag >> 13,
- (tag & 0x1000) ? ", CFI" : ""));
+ ND_PRINT((ndo, "%s, ", ieee8021q_tci_string(tag)));
}
- ether_type = EXTRACT_16BITS(p + 2);
- if (ndo->ndo_eflag && ether_type > ETHERMTU)
- ND_PRINT((ndo, "ethertype %s, ", tok2str(ethertype_values,"0x%04x", ether_type)));
+ length_type = EXTRACT_16BITS(p + 2);
+ if (ndo->ndo_eflag && length_type > ETHERMTU)
+ ND_PRINT((ndo, "ethertype %s, ", tok2str(ethertype_values,"0x%04x", length_type)));
p += 4;
length -= 4;
caplen -= 4;
+ hdrlen += 4;
goto recurse;
- } else if (ether_type == ETHERTYPE_JUMBO) {
+ } else if (length_type == ETHERTYPE_JUMBO) {
/*
* Alteon jumbo frames.
* See
@@ -215,53 +229,48 @@ recurse:
* there's an LLC header and payload.
*/
/* Try to print the LLC-layer header & higher layers */
- if (llc_print(p, length, caplen, ESRC(ep), EDST(ep),
- &extracted_ether_type) == 0) {
- /* ether_type not known, print raw packet */
- if (!ndo->ndo_eflag) {
- if (print_encap_header != NULL)
- (*print_encap_header)(ndo, encap_header_arg);
- ether_hdr_print(ndo, (u_char *)ep, orig_length);
- }
-
+ llc_hdrlen = llc_print(ndo, p, length, caplen, &src, &dst);
+ if (llc_hdrlen < 0) {
+ /* packet type not known, print raw packet */
if (!ndo->ndo_suppress_default_print)
- ndo->ndo_default_print(ndo, p, caplen);
+ ND_DEFAULTPRINT(p, caplen);
+ llc_hdrlen = -llc_hdrlen;
}
+ hdrlen += llc_hdrlen;
} else {
- if (ethertype_print(ndo, ether_type, p, length, caplen) == 0) {
- /* ether_type not known, print raw packet */
+ if (ethertype_print(ndo, length_type, p, length, caplen, &src, &dst) == 0) {
+ /* type not known, print raw packet */
if (!ndo->ndo_eflag) {
if (print_encap_header != NULL)
(*print_encap_header)(ndo, encap_header_arg);
- ether_hdr_print(ndo, (u_char *)ep, orig_length);
+ ether_hdr_print(ndo, (const u_char *)ep, orig_length);
}
if (!ndo->ndo_suppress_default_print)
- ndo->ndo_default_print(ndo, p, caplen);
+ ND_DEFAULTPRINT(p, caplen);
}
}
+ return (hdrlen);
}
/*
* This is the top level routine of the printer. 'p' points
- * to the ether header of the packet, 'h->ts' is the timestamp,
- * 'h->len' is the length of the packet off the wire, and 'h->caplen'
- * is the number of bytes actually captured.
+ * to the ether header of the packet, 'h->len' is the length
+ * of the packet off the wire, and 'h->caplen' is the number
+ * of bytes actually captured.
*/
u_int
ether_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h,
const u_char *p)
{
- ether_print(ndo, p, h->len, h->caplen, NULL, NULL);
-
- return (ETHER_HDRLEN);
+ return (ether_print(ndo, p, h->len, h->caplen, NULL, NULL));
}
/*
* This is the top level routine of the printer. 'p' points
- * to the ether header of the packet, 'h->ts' is the timestamp,
- * 'h->len' is the length of the packet off the wire, and 'h->caplen'
- * is the number of bytes actually captured.
+ * to the ether header of the packet, 'h->len' is the length
+ * of the packet off the wire, and 'h->caplen' is the number
+ * of bytes actually captured.
*
* This is for DLT_NETANALYZER, which has a 4-byte pseudo-header
* before the Ethernet header.
@@ -274,21 +283,19 @@ netanalyzer_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h,
* Fail if we don't have enough data for the Hilscher pseudo-header.
*/
if (h->len < 4 || h->caplen < 4) {
- printf("[|netanalyzer]");
+ ND_PRINT((ndo, "[|netanalyzer]"));
return (h->caplen);
}
/* Skip the pseudo-header. */
- ether_print(ndo, p + 4, h->len - 4, h->caplen - 4, NULL, NULL);
-
- return (4 + ETHER_HDRLEN);
+ return (4 + ether_print(ndo, p + 4, h->len - 4, h->caplen - 4, NULL, NULL));
}
/*
* This is the top level routine of the printer. 'p' points
- * to the ether header of the packet, 'h->ts' is the timestamp,
- * 'h->len' is the length of the packet off the wire, and 'h->caplen'
- * is the number of bytes actually captured.
+ * to the ether header of the packet, 'h->len' is the length
+ * of the packet off the wire, and 'h->caplen' is the number
+ * of bytes actually captured.
*
* This is for DLT_NETANALYZER_TRANSPARENT, which has a 4-byte
* pseudo-header, a 7-byte Ethernet preamble, and a 1-byte Ethernet SOF
@@ -304,14 +311,12 @@ netanalyzer_transparent_if_print(netdissect_options *ndo,
* preamble, and SOF.
*/
if (h->len < 12 || h->caplen < 12) {
- printf("[|netanalyzer-transparent]");
+ ND_PRINT((ndo, "[|netanalyzer-transparent]"));
return (h->caplen);
}
/* Skip the pseudo-header, preamble, and SOF. */
- ether_print(ndo, p + 12, h->len - 12, h->caplen - 12, NULL, NULL);
-
- return (12 + ETHER_HDRLEN);
+ return (12 + ether_print(ndo, p + 12, h->len - 12, h->caplen - 12, NULL, NULL));
}
/*
@@ -324,7 +329,8 @@ netanalyzer_transparent_if_print(netdissect_options *ndo,
int
ethertype_print(netdissect_options *ndo,
u_short ether_type, const u_char *p,
- u_int length, u_int caplen)
+ u_int length, u_int caplen,
+ const struct lladdr_info *src, const struct lladdr_info *dst)
{
switch (ether_type) {
@@ -332,45 +338,47 @@ ethertype_print(netdissect_options *ndo,
ip_print(ndo, p, length);
return (1);
-#ifdef INET6
case ETHERTYPE_IPV6:
ip6_print(ndo, p, length);
return (1);
-#endif /*INET6*/
case ETHERTYPE_ARP:
case ETHERTYPE_REVARP:
- arp_print(ndo, p, length, caplen);
+ arp_print(ndo, p, length, caplen);
return (1);
case ETHERTYPE_DN:
- decnet_print(/*ndo,*/p, length, caplen);
+ decnet_print(ndo, p, length, caplen);
return (1);
case ETHERTYPE_ATALK:
if (ndo->ndo_vflag)
- fputs("et1 ", stdout);
- atalk_print(/*ndo,*/p, length);
+ ND_PRINT((ndo, "et1 "));
+ atalk_print(ndo, p, length);
return (1);
case ETHERTYPE_AARP:
- aarp_print(/*ndo,*/p, length);
+ aarp_print(ndo, p, length);
return (1);
case ETHERTYPE_IPX:
ND_PRINT((ndo, "(NOV-ETHII) "));
- ipx_print(/*ndo,*/p, length);
+ ipx_print(ndo, p, length);
return (1);
- case ETHERTYPE_ISO:
- isoclns_print(/*ndo,*/p+1, length-1, length-1);
- return(1);
+ case ETHERTYPE_ISO:
+ if (length == 0 || caplen == 0) {
+ ND_PRINT((ndo, " [|osi]"));
+ return (1);
+ }
+ isoclns_print(ndo, p + 1, length - 1, caplen - 1);
+ return(1);
case ETHERTYPE_PPPOED:
case ETHERTYPE_PPPOES:
case ETHERTYPE_PPPOED2:
case ETHERTYPE_PPPOES2:
- pppoe_print(/*ndo,*/p, length);
+ pppoe_print(ndo, p, length);
return (1);
case ETHERTYPE_EAPOL:
@@ -378,39 +386,40 @@ ethertype_print(netdissect_options *ndo,
return (1);
case ETHERTYPE_RRCP:
- rrcp_print(ndo, p - 14 , length + 14);
+ rrcp_print(ndo, p, length, src, dst);
return (1);
case ETHERTYPE_PPP:
if (length) {
- printf(": ");
- ppp_print(/*ndo,*/p, length);
+ ND_PRINT((ndo, ": "));
+ ppp_print(ndo, p, length);
}
return (1);
case ETHERTYPE_MPCP:
- mpcp_print(/*ndo,*/p, length);
+ mpcp_print(ndo, p, length);
return (1);
case ETHERTYPE_SLOW:
- slow_print(/*ndo,*/p, length);
+ slow_print(ndo, p, length);
return (1);
case ETHERTYPE_CFM:
case ETHERTYPE_CFM_OLD:
- cfm_print(/*ndo,*/p, length);
+ cfm_print(ndo, p, length);
return (1);
case ETHERTYPE_LLDP:
- lldp_print(/*ndo,*/p, length);
+ lldp_print(ndo, p, length);
return (1);
case ETHERTYPE_LOOPBACK:
+ loopback_print(ndo, p, length);
return (1);
case ETHERTYPE_MPLS:
case ETHERTYPE_MPLS_MULTI:
- mpls_print(/*ndo,*/p, length);
+ mpls_print(ndo, p, length);
return (1);
case ETHERTYPE_TIPC:
@@ -418,13 +427,31 @@ ethertype_print(netdissect_options *ndo,
return (1);
case ETHERTYPE_MS_NLB_HB:
- msnlb_print(ndo, p, length);
+ msnlb_print(ndo, p);
+ return (1);
+
+ case ETHERTYPE_GEONET_OLD:
+ case ETHERTYPE_GEONET:
+ geonet_print(ndo, p, length, src);
+ return (1);
+
+ case ETHERTYPE_CALM_FAST:
+ calm_fast_print(ndo, p, length, src);
+ return (1);
+
+ case ETHERTYPE_AOE:
+ aoe_print(ndo, p, length);
+ return (1);
+
+ case ETHERTYPE_MEDSA:
+ medsa_print(ndo, p, length, caplen, src, dst);
return (1);
case ETHERTYPE_LAT:
case ETHERTYPE_SCA:
case ETHERTYPE_MOPRC:
case ETHERTYPE_MOPDL:
+ case ETHERTYPE_IEEE1905_1:
/* default_print for now */
default:
return (0);
@@ -439,3 +466,6 @@ ethertype_print(netdissect_options *ndo,
* End:
*/
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-ether-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-fddi.c b/freebsd/contrib/tcpdump/print-fddi.c
index 9bca7077..68a4effa 100644
--- a/freebsd/contrib/tcpdump/print-fddi.c
+++ b/freebsd/contrib/tcpdump/print-fddi.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1991, 1992, 1993, 1994, 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
@@ -19,39 +22,77 @@
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * $FreeBSD$
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-fddi.c,v 1.66 2005-11-13 12:12:41 guy Exp $ (LBL)";
-#endif
+/* \summary: Fiber Distributed Data Interface (FDDI) printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include <pcap.h>
-#include <stdio.h>
#include <string.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
-#include "ethertype.h"
-
#include "ether.h"
-#include "fddi.h"
+
+/*
+ * Based on Ultrix if_fddi.h
+ */
+
+struct fddi_header {
+ u_char fddi_fc; /* frame control */
+ u_char fddi_dhost[6];
+ u_char fddi_shost[6];
+};
+
+/*
+ * Length of an FDDI header; note that some compilers may pad
+ * "struct fddi_header" to a multiple of 4 bytes, for example, so
+ * "sizeof (struct fddi_header)" may not give the right
+ * answer.
+ */
+#define FDDI_HDRLEN 13
+
+/* Useful values for fddi_fc (frame control) field */
+
+/*
+ * FDDI Frame Control bits
+ */
+#define FDDIFC_C 0x80 /* Class bit */
+#define FDDIFC_L 0x40 /* Address length bit */
+#define FDDIFC_F 0x30 /* Frame format bits */
+#define FDDIFC_Z 0x0f /* Control bits */
+
+/*
+ * FDDI Frame Control values. (48-bit addressing only).
+ */
+#define FDDIFC_VOID 0x40 /* Void frame */
+#define FDDIFC_NRT 0x80 /* Nonrestricted token */
+#define FDDIFC_RT 0xc0 /* Restricted token */
+#define FDDIFC_SMT_INFO 0x41 /* SMT Info */
+#define FDDIFC_SMT_NSA 0x4F /* SMT Next station adrs */
+#define FDDIFC_MAC_BEACON 0xc2 /* MAC Beacon frame */
+#define FDDIFC_MAC_CLAIM 0xc3 /* MAC Claim frame */
+#define FDDIFC_LLC_ASYNC 0x50 /* Async. LLC frame */
+#define FDDIFC_LLC_SYNC 0xd0 /* Sync. LLC frame */
+#define FDDIFC_IMP_ASYNC 0x60 /* Implementor Async. */
+#define FDDIFC_IMP_SYNC 0xe0 /* Implementor Synch. */
+#define FDDIFC_SMT 0x40 /* SMT frame */
+#define FDDIFC_MAC 0xc0 /* MAC frame */
+
+#define FDDIFC_CLFF 0xF0 /* Class/Length/Format bits */
+#define FDDIFC_ZZZZ 0x0F /* Control bits */
/*
* Some FDDI interfaces use bit-swapped addresses.
*/
#if defined(ultrix) || defined(__alpha) || defined(__bsdi) || defined(__NetBSD__) || defined(__linux__)
-int fddi_bitswap = 0;
+static int fddi_bitswap = 0;
#else
-int fddi_bitswap = 1;
+static int fddi_bitswap = 1;
#endif
/*
@@ -84,7 +125,7 @@ int fddi_bitswap = 1;
* - vj
*/
-static u_char fddi_bit_swap[] = {
+static const u_char fddi_bit_swap[] = {
0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
@@ -123,67 +164,67 @@ static u_char fddi_bit_swap[] = {
* Print FDDI frame-control bits
*/
static inline void
-print_fddi_fc(u_char fc)
+print_fddi_fc(netdissect_options *ndo, u_char fc)
{
switch (fc) {
case FDDIFC_VOID: /* Void frame */
- printf("void ");
+ ND_PRINT((ndo, "void "));
break;
case FDDIFC_NRT: /* Nonrestricted token */
- printf("nrt ");
+ ND_PRINT((ndo, "nrt "));
break;
case FDDIFC_RT: /* Restricted token */
- printf("rt ");
+ ND_PRINT((ndo, "rt "));
break;
case FDDIFC_SMT_INFO: /* SMT Info */
- printf("info ");
+ ND_PRINT((ndo, "info "));
break;
case FDDIFC_SMT_NSA: /* SMT Next station adrs */
- printf("nsa ");
+ ND_PRINT((ndo, "nsa "));
break;
case FDDIFC_MAC_BEACON: /* MAC Beacon frame */
- printf("beacon ");
+ ND_PRINT((ndo, "beacon "));
break;
case FDDIFC_MAC_CLAIM: /* MAC Claim frame */
- printf("claim ");
+ ND_PRINT((ndo, "claim "));
break;
default:
switch (fc & FDDIFC_CLFF) {
case FDDIFC_MAC:
- printf("mac%1x ", fc & FDDIFC_ZZZZ);
+ ND_PRINT((ndo, "mac%1x ", fc & FDDIFC_ZZZZ));
break;
case FDDIFC_SMT:
- printf("smt%1x ", fc & FDDIFC_ZZZZ);
+ ND_PRINT((ndo, "smt%1x ", fc & FDDIFC_ZZZZ));
break;
case FDDIFC_LLC_ASYNC:
- printf("async%1x ", fc & FDDIFC_ZZZZ);
+ ND_PRINT((ndo, "async%1x ", fc & FDDIFC_ZZZZ));
break;
case FDDIFC_LLC_SYNC:
- printf("sync%1x ", fc & FDDIFC_ZZZZ);
+ ND_PRINT((ndo, "sync%1x ", fc & FDDIFC_ZZZZ));
break;
case FDDIFC_IMP_ASYNC:
- printf("imp_async%1x ", fc & FDDIFC_ZZZZ);
+ ND_PRINT((ndo, "imp_async%1x ", fc & FDDIFC_ZZZZ));
break;
case FDDIFC_IMP_SYNC:
- printf("imp_sync%1x ", fc & FDDIFC_ZZZZ);
+ ND_PRINT((ndo, "imp_sync%1x ", fc & FDDIFC_ZZZZ));
break;
default:
- printf("%02x ", fc);
+ ND_PRINT((ndo, "%02x ", fc));
break;
}
}
@@ -215,43 +256,39 @@ extract_fddi_addrs(const struct fddi_header *fddip, char *fsrc, char *fdst)
* Print the FDDI MAC header
*/
static inline void
-fddi_hdr_print(register const struct fddi_header *fddip, register u_int length,
- register const u_char *fsrc, register const u_char *fdst)
+fddi_hdr_print(netdissect_options *ndo,
+ register const struct fddi_header *fddip, register u_int length,
+ register const u_char *fsrc, register const u_char *fdst)
{
const char *srcname, *dstname;
- srcname = etheraddr_string(fsrc);
- dstname = etheraddr_string(fdst);
+ srcname = etheraddr_string(ndo, fsrc);
+ dstname = etheraddr_string(ndo, fdst);
- if (vflag)
- (void) printf("%02x %s %s %d: ",
- fddip->fddi_fc,
- srcname, dstname,
- length);
- else if (qflag)
- printf("%s %s %d: ", srcname, dstname, length);
- else {
- (void) print_fddi_fc(fddip->fddi_fc);
- (void) printf("%s %s %d: ", srcname, dstname, length);
- }
+ if (!ndo->ndo_qflag)
+ print_fddi_fc(ndo, fddip->fddi_fc);
+ ND_PRINT((ndo, "%s > %s, length %u: ",
+ srcname, dstname,
+ length));
}
static inline void
-fddi_smt_print(const u_char *p _U_, u_int length _U_)
+fddi_smt_print(netdissect_options *ndo, const u_char *p _U_, u_int length _U_)
{
- printf("<SMT printer not yet implemented>");
+ ND_PRINT((ndo, "<SMT printer not yet implemented>"));
}
-void
-fddi_print(const u_char *p, u_int length, u_int caplen)
+u_int
+fddi_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen)
{
const struct fddi_header *fddip = (const struct fddi_header *)p;
struct ether_header ehdr;
- u_short extracted_ethertype;
+ struct lladdr_info src, dst;
+ int llc_hdrlen;
if (caplen < FDDI_HDRLEN) {
- printf("[|fddi]");
- return;
+ ND_PRINT((ndo, "[|fddi]"));
+ return (caplen);
}
/*
@@ -259,8 +296,13 @@ fddi_print(const u_char *p, u_int length, u_int caplen)
*/
extract_fddi_addrs(fddip, (char *)ESRC(&ehdr), (char *)EDST(&ehdr));
- if (eflag)
- fddi_hdr_print(fddip, length, ESRC(&ehdr), EDST(&ehdr));
+ if (ndo->ndo_eflag)
+ fddi_hdr_print(ndo, fddip, length, ESRC(&ehdr), EDST(&ehdr));
+
+ src.addr = ESRC(&ehdr);
+ src.addr_string = etheraddr_string;
+ dst.addr = EDST(&ehdr);
+ dst.addr_string = etheraddr_string;
/* Skip over FDDI MAC header */
length -= FDDI_HDRLEN;
@@ -270,32 +312,29 @@ fddi_print(const u_char *p, u_int length, u_int caplen)
/* Frame Control field determines interpretation of packet */
if ((fddip->fddi_fc & FDDIFC_CLFF) == FDDIFC_LLC_ASYNC) {
/* Try to print the LLC-layer header & higher layers */
- if (llc_print(p, length, caplen, ESRC(&ehdr), EDST(&ehdr),
- &extracted_ethertype) == 0) {
+ llc_hdrlen = llc_print(ndo, p, length, caplen, &src, &dst);
+ if (llc_hdrlen < 0) {
/*
* Some kinds of LLC packet we cannot
* handle intelligently
*/
- if (!eflag)
- fddi_hdr_print(fddip, length + FDDI_HDRLEN,
- ESRC(&ehdr), EDST(&ehdr));
- if (extracted_ethertype) {
- printf("(LLC %s) ",
- etherproto_string(htons(extracted_ethertype)));
- }
- if (!suppress_default_print)
- default_print(p, caplen);
+ if (!ndo->ndo_suppress_default_print)
+ ND_DEFAULTPRINT(p, caplen);
+ llc_hdrlen = -llc_hdrlen;
}
- } else if ((fddip->fddi_fc & FDDIFC_CLFF) == FDDIFC_SMT)
- fddi_smt_print(p, caplen);
- else {
+ } else if ((fddip->fddi_fc & FDDIFC_CLFF) == FDDIFC_SMT) {
+ fddi_smt_print(ndo, p, caplen);
+ llc_hdrlen = 0;
+ } else {
/* Some kinds of FDDI packet we cannot handle intelligently */
- if (!eflag)
- fddi_hdr_print(fddip, length + FDDI_HDRLEN, ESRC(&ehdr),
+ if (!ndo->ndo_eflag)
+ fddi_hdr_print(ndo, fddip, length + FDDI_HDRLEN, ESRC(&ehdr),
EDST(&ehdr));
- if (!suppress_default_print)
- default_print(p, caplen);
+ if (!ndo->ndo_suppress_default_print)
+ ND_DEFAULTPRINT(p, caplen);
+ llc_hdrlen = 0;
}
+ return (FDDI_HDRLEN + llc_hdrlen);
}
/*
@@ -305,9 +344,10 @@ fddi_print(const u_char *p, u_int length, u_int caplen)
* is the number of bytes actually captured.
*/
u_int
-fddi_if_print(const struct pcap_pkthdr *h, register const u_char *p)
+fddi_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, register const u_char *p)
{
- fddi_print(p, h->len, h->caplen);
-
- return (FDDI_HDRLEN);
+ return (fddi_print(ndo, p, h->len, h->caplen));
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-fddi-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-forces.c b/freebsd/contrib/tcpdump/print-forces.c
index 4b9f52dd..033b0f30 100644
--- a/freebsd/contrib/tcpdump/print-forces.c
+++ b/freebsd/contrib/tcpdump/print-forces.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code
@@ -16,29 +19,641 @@
*
*/
+/* \summary: Forwarding and Control Element Separation (ForCES) Protocol printer */
+
+/* specification: RFC 5810 */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
-#include "forces.h"
+static const char tstr[] = "[|forces]";
+
+#define ForCES_VERS 1
+#define ForCES_HDRL 24
+#define ForCES_ALNL 4U
+#define TLV_HDRL 4
+#define ILV_HDRL 8
+
+#define TOM_RSVD 0x0
+#define TOM_ASSNSETUP 0x1
+#define TOM_ASSNTEARD 0x2
+#define TOM_CONFIG 0x3
+#define TOM_QUERY 0x4
+#define TOM_EVENTNOT 0x5
+#define TOM_PKTREDIR 0x6
+#define TOM_HEARTBT 0x0F
+#define TOM_ASSNSETREP 0x11
+#define TOM_CONFIGREP 0x13
+#define TOM_QUERYREP 0x14
+
+/*
+ * tom_h Flags: resv1(8b):maxtlvs(4b):resv2(2b):mintlv(2b)
+*/
+#define ZERO_TTLV 0x01
+#define ZERO_MORE_TTLV 0x02
+#define ONE_MORE_TTLV 0x04
+#define ZERO_TLV 0x00
+#define ONE_TLV 0x10
+#define TWO_TLV 0x20
+#define MAX_TLV 0xF0
+
+#define TTLV_T1 (ONE_MORE_TTLV|ONE_TLV)
+#define TTLV_T2 (ONE_MORE_TTLV|MAX_TLV)
+
+struct tom_h {
+ uint32_t v;
+ uint16_t flags;
+ uint16_t op_msk;
+ const char *s;
+ int (*print) (netdissect_options *ndo, register const u_char * pptr, register u_int len,
+ uint16_t op_msk, int indent);
+};
+
+enum {
+ TOM_RSV_I,
+ TOM_ASS_I,
+ TOM_AST_I,
+ TOM_CFG_I,
+ TOM_QRY_I,
+ TOM_EVN_I,
+ TOM_RED_I,
+ TOM_HBT_I,
+ TOM_ASR_I,
+ TOM_CNR_I,
+ TOM_QRR_I,
+ _TOM_RSV_MAX
+};
+#define TOM_MAX_IND (_TOM_RSV_MAX - 1)
+
+static inline int tom_valid(uint8_t tom)
+{
+ if (tom > 0) {
+ if (tom >= 0x7 && tom <= 0xe)
+ return 0;
+ if (tom == 0x10)
+ return 0;
+ if (tom > 0x14)
+ return 0;
+ return 1;
+ } else
+ return 0;
+}
+
+static inline const char *ForCES_node(uint32_t node)
+{
+ if (node <= 0x3FFFFFFF)
+ return "FE";
+ if (node >= 0x40000000 && node <= 0x7FFFFFFF)
+ return "CE";
+ if (node >= 0xC0000000 && node <= 0xFFFFFFEF)
+ return "AllMulticast";
+ if (node == 0xFFFFFFFD)
+ return "AllCEsBroadcast";
+ if (node == 0xFFFFFFFE)
+ return "AllFEsBroadcast";
+ if (node == 0xFFFFFFFF)
+ return "AllBroadcast";
+
+ return "ForCESreserved";
+
+}
+
+static const struct tok ForCES_ACKs[] = {
+ {0x0, "NoACK"},
+ {0x1, "SuccessACK"},
+ {0x2, "FailureACK"},
+ {0x3, "AlwaysACK"},
+ {0, NULL}
+};
+
+static const struct tok ForCES_EMs[] = {
+ {0x0, "EMReserved"},
+ {0x1, "execute-all-or-none"},
+ {0x2, "execute-until-failure"},
+ {0x3, "continue-execute-on-failure"},
+ {0, NULL}
+};
+
+static const struct tok ForCES_ATs[] = {
+ {0x0, "Standalone"},
+ {0x1, "2PCtransaction"},
+ {0, NULL}
+};
+
+static const struct tok ForCES_TPs[] = {
+ {0x0, "StartofTransaction"},
+ {0x1, "MiddleofTransaction"},
+ {0x2, "EndofTransaction"},
+ {0x3, "abort"},
+ {0, NULL}
+};
+
+/*
+ * Structure of forces header, naked of TLVs.
+ */
+struct forcesh {
+ nd_uint8_t fm_vrsvd; /* version and reserved */
+#define ForCES_V(forcesh) ((forcesh)->fm_vrsvd >> 4)
+ nd_uint8_t fm_tom; /* type of message */
+ nd_uint16_t fm_len; /* total length * 4 bytes */
+#define ForCES_BLN(forcesh) ((uint32_t)(EXTRACT_16BITS(&(forcesh)->fm_len) << 2))
+ nd_uint32_t fm_sid; /* Source ID */
+#define ForCES_SID(forcesh) EXTRACT_32BITS(&(forcesh)->fm_sid)
+ nd_uint32_t fm_did; /* Destination ID */
+#define ForCES_DID(forcesh) EXTRACT_32BITS(&(forcesh)->fm_did)
+ nd_uint8_t fm_cor[8]; /* correlator */
+ nd_uint32_t fm_flags; /* flags */
+#define ForCES_ACK(forcesh) ((EXTRACT_32BITS(&(forcesh)->fm_flags)&0xC0000000) >> 30)
+#define ForCES_PRI(forcesh) ((EXTRACT_32BITS(&(forcesh)->fm_flags)&0x38000000) >> 27)
+#define ForCES_RS1(forcesh) ((EXTRACT_32BITS(&(forcesh)->fm_flags)&0x07000000) >> 24)
+#define ForCES_EM(forcesh) ((EXTRACT_32BITS(&(forcesh)->fm_flags)&0x00C00000) >> 22)
+#define ForCES_AT(forcesh) ((EXTRACT_32BITS(&(forcesh)->fm_flags)&0x00200000) >> 21)
+#define ForCES_TP(forcesh) ((EXTRACT_32BITS(&(forcesh)->fm_flags)&0x00180000) >> 19)
+#define ForCES_RS2(forcesh) ((EXTRACT_32BITS(&(forcesh)->fm_flags)&0x0007FFFF) >> 0)
+};
+
+#define ForCES_HLN_VALID(fhl,tlen) ((tlen) >= ForCES_HDRL && \
+ (fhl) >= ForCES_HDRL && \
+ (fhl) == (tlen))
+
+#define F_LFB_RSVD 0x0
+#define F_LFB_FEO 0x1
+#define F_LFB_FEPO 0x2
+static const struct tok ForCES_LFBs[] = {
+ {F_LFB_RSVD, "Invalid TLV"},
+ {F_LFB_FEO, "FEObj LFB"},
+ {F_LFB_FEPO, "FEProtoObj LFB"},
+ {0, NULL}
+};
+
+/* this is defined in RFC5810 section A.2 */
+/* http://www.iana.org/assignments/forces/forces.xhtml#oper-tlv-types */
+enum {
+ F_OP_RSV = 0,
+ F_OP_SET = 1,
+ F_OP_SETPROP = 2,
+ F_OP_SETRESP = 3,
+ F_OP_SETPRESP = 4,
+ F_OP_DEL = 5,
+ F_OP_DELRESP = 6,
+ F_OP_GET = 7,
+ F_OP_GETPROP = 8,
+ F_OP_GETRESP = 9,
+ F_OP_GETPRESP = 10,
+ F_OP_REPORT = 11,
+ F_OP_COMMIT = 12,
+ F_OP_RCOMMIT = 13,
+ F_OP_RTRCOMP = 14,
+ _F_OP_MAX
+};
+#define F_OP_MAX (_F_OP_MAX - 1)
+
+enum {
+ B_OP_SET = 1 << (F_OP_SET - 1),
+ B_OP_SETPROP = 1 << (F_OP_SETPROP - 1),
+ B_OP_SETRESP = 1 << (F_OP_SETRESP - 1),
+ B_OP_SETPRESP = 1 << (F_OP_SETPRESP - 1),
+ B_OP_DEL = 1 << (F_OP_DEL - 1),
+ B_OP_DELRESP = 1 << (F_OP_DELRESP - 1),
+ B_OP_GET = 1 << (F_OP_GET - 1),
+ B_OP_GETPROP = 1 << (F_OP_GETPROP - 1),
+ B_OP_GETRESP = 1 << (F_OP_GETRESP - 1),
+ B_OP_GETPRESP = 1 << (F_OP_GETPRESP - 1),
+ B_OP_REPORT = 1 << (F_OP_REPORT - 1),
+ B_OP_COMMIT = 1 << (F_OP_COMMIT - 1),
+ B_OP_RCOMMIT = 1 << (F_OP_RCOMMIT - 1),
+ B_OP_RTRCOMP = 1 << (F_OP_RTRCOMP - 1)
+};
+
+struct optlv_h {
+ uint16_t flags;
+ uint16_t op_msk;
+ const char *s;
+ int (*print) (netdissect_options *ndo, register const u_char * pptr, register u_int len,
+ uint16_t op_msk, int indent);
+};
+
+static int genoptlv_print(netdissect_options *, register const u_char * pptr, register u_int len,
+ uint16_t op_msk, int indent);
+static int recpdoptlv_print(netdissect_options *, register const u_char * pptr, register u_int len,
+ uint16_t op_msk, int indent);
+static int invoptlv_print(netdissect_options *, register const u_char * pptr, register u_int len,
+ uint16_t op_msk, int indent);
+
+#define OP_MIN_SIZ 8
+struct pathdata_h {
+ nd_uint16_t pflags;
+ nd_uint16_t pIDcnt;
+};
+
+#define B_FULLD 0x1
+#define B_SPARD 0x2
+#define B_RESTV 0x4
+#define B_KEYIN 0x8
+#define B_APPND 0x10
+#define B_TRNG 0x20
+
+static const struct optlv_h OPTLV_msg[F_OP_MAX + 1] = {
+ /* F_OP_RSV */ {ZERO_TTLV, 0, "Invalid OPTLV", invoptlv_print},
+ /* F_OP_SET */ {TTLV_T2, B_FULLD | B_SPARD, " Set", recpdoptlv_print},
+ /* F_OP_SETPROP */
+ {TTLV_T2, B_FULLD | B_SPARD, " SetProp", recpdoptlv_print},
+ /* F_OP_SETRESP */ {TTLV_T2, B_RESTV, " SetResp", recpdoptlv_print},
+ /* F_OP_SETPRESP */ {TTLV_T2, B_RESTV, " SetPropResp", recpdoptlv_print},
+ /* F_OP_DEL */ {ZERO_TTLV, 0, " Del", recpdoptlv_print},
+ /* F_OP_DELRESP */ {TTLV_T2, B_RESTV, " DelResp", recpdoptlv_print},
+ /* F_OP_GET */ {ZERO_TTLV, 0, " Get", recpdoptlv_print},
+ /* F_OP_GETPROP */ {ZERO_TTLV, 0, " GetProp", recpdoptlv_print},
+ /* F_OP_GETRESP */
+ {TTLV_T2, B_FULLD | B_SPARD | B_RESTV, " GetResp", recpdoptlv_print},
+ /* F_OP_GETPRESP */
+ {TTLV_T2, B_FULLD | B_RESTV, " GetPropResp", recpdoptlv_print},
+ /* F_OP_REPORT */
+ {TTLV_T2, B_FULLD | B_SPARD, " Report", recpdoptlv_print},
+ /* F_OP_COMMIT */ {ZERO_TTLV, 0, " Commit", NULL},
+ /* F_OP_RCOMMIT */ {TTLV_T1, B_RESTV, " RCommit", genoptlv_print},
+ /* F_OP_RTRCOMP */ {ZERO_TTLV, 0, " RTRCOMP", NULL},
+};
+
+static inline const struct optlv_h *get_forces_optlv_h(uint16_t opt)
+{
+ if (opt > F_OP_MAX || opt <= F_OP_RSV)
+ return &OPTLV_msg[F_OP_RSV];
+
+ return &OPTLV_msg[opt];
+}
+
+#define IND_SIZE 256
+#define IND_CHR ' '
+#define IND_PREF '\n'
+#define IND_SUF 0x0
+static char ind_buf[IND_SIZE];
+
+static inline char *indent_pr(int indent, int nlpref)
+{
+ int i = 0;
+ char *r = ind_buf;
+
+ if (indent > (IND_SIZE - 1))
+ indent = IND_SIZE - 1;
+
+ if (nlpref) {
+ r[i] = IND_PREF;
+ i++;
+ indent--;
+ }
+
+ while (--indent >= 0)
+ r[i++] = IND_CHR;
+
+ r[i] = IND_SUF;
+ return r;
+}
+
+static inline int op_valid(uint16_t op, uint16_t mask)
+{
+ int opb = 1 << (op - 1);
+
+ if (op == 0)
+ return 0;
+ if (opb & mask)
+ return 1;
+ /* I guess we should allow vendor operations? */
+ if (op >= 0x8000)
+ return 1;
+ return 0;
+}
+
+#define F_TLV_RSVD 0x0000
+#define F_TLV_REDR 0x0001
+#define F_TLV_ASRS 0x0010
+#define F_TLV_ASRT 0x0011
+#define F_TLV_LFBS 0x1000
+#define F_TLV_PDAT 0x0110
+#define F_TLV_KEYI 0x0111
+#define F_TLV_FULD 0x0112
+#define F_TLV_SPAD 0x0113
+#define F_TLV_REST 0x0114
+#define F_TLV_METD 0x0115
+#define F_TLV_REDD 0x0116
+#define F_TLV_TRNG 0x0117
+
+
+#define F_TLV_VNST 0x8000
+
+static const struct tok ForCES_TLV[] = {
+ {F_TLV_RSVD, "Invalid TLV"},
+ {F_TLV_REDR, "REDIRECT TLV"},
+ {F_TLV_ASRS, "ASResult TLV"},
+ {F_TLV_ASRT, "ASTreason TLV"},
+ {F_TLV_LFBS, "LFBselect TLV"},
+ {F_TLV_PDAT, "PATH-DATA TLV"},
+ {F_TLV_KEYI, "KEYINFO TLV"},
+ {F_TLV_FULD, "FULLDATA TLV"},
+ {F_TLV_SPAD, "SPARSEDATA TLV"},
+ {F_TLV_REST, "RESULT TLV"},
+ {F_TLV_METD, "METADATA TLV"},
+ {F_TLV_REDD, "REDIRECTDATA TLV"},
+ {0, NULL}
+};
+
+#define TLV_HLN 4
+static inline int ttlv_valid(uint16_t ttlv)
+{
+ if (ttlv > 0) {
+ if (ttlv == 1 || ttlv == 0x1000)
+ return 1;
+ if (ttlv >= 0x10 && ttlv <= 0x11)
+ return 1;
+ if (ttlv >= 0x110 && ttlv <= 0x116)
+ return 1;
+ if (ttlv >= 0x8000)
+ return 0; /* XXX: */
+ }
+
+ return 0;
+}
+
+struct forces_ilv {
+ nd_uint32_t type;
+ nd_uint32_t length;
+};
+
+struct forces_tlv {
+ nd_uint16_t type;
+ nd_uint16_t length;
+};
+
+#define F_ALN_LEN(len) ( ((len)+ForCES_ALNL-1) & ~(ForCES_ALNL-1) )
+#define GET_TOP_TLV(fhdr) ((const struct forces_tlv *)((fhdr) + sizeof (struct forcesh)))
+#define TLV_SET_LEN(len) (F_ALN_LEN(TLV_HDRL) + (len))
+#define TLV_ALN_LEN(len) F_ALN_LEN(TLV_SET_LEN(len))
+#define TLV_RDAT_LEN(tlv) ((int)(EXTRACT_16BITS(&(tlv)->length) - TLV_SET_LEN(0))
+#define TLV_DATA(tlvp) ((const void*)(((const char*)(tlvp)) + TLV_SET_LEN(0)))
+#define GO_NXT_TLV(tlv,rlen) ((rlen) -= F_ALN_LEN(EXTRACT_16BITS(&(tlv)->length)), \
+ (const struct forces_tlv*)(((const char*)(tlv)) \
+ + F_ALN_LEN(EXTRACT_16BITS(&(tlv)->length))))
+#define ILV_SET_LEN(len) (F_ALN_LEN(ILV_HDRL) + (len))
+#define ILV_ALN_LEN(len) F_ALN_LEN(ILV_SET_LEN(len))
+#define ILV_RDAT_LEN(ilv) ((int)(EXTRACT_32BITS(&(ilv)->length)) - ILV_SET_LEN(0))
+#define ILV_DATA(ilvp) ((const void*)(((const char*)(ilvp)) + ILV_SET_LEN(0)))
+#define GO_NXT_ILV(ilv,rlen) ((rlen) -= F_ALN_LEN(EXTRACT_32BITS(&(ilv)->length)), \
+ (const struct forces_ilv *)(((const char*)(ilv)) \
+ + F_ALN_LEN(EXTRACT_32BITS(&(ilv)->length))))
+#define INVALID_RLEN 1
+#define INVALID_STLN 2
+#define INVALID_LTLN 3
+#define INVALID_ALEN 4
+
+static const struct tok ForCES_TLV_err[] = {
+ {INVALID_RLEN, "Invalid total length"},
+ {INVALID_STLN, "xLV too short"},
+ {INVALID_LTLN, "xLV too long"},
+ {INVALID_ALEN, "data padding missing"},
+ {0, NULL}
+};
+
+static inline u_int tlv_valid(const struct forces_tlv *tlv, u_int rlen)
+{
+ if (rlen < TLV_HDRL)
+ return INVALID_RLEN;
+ if (EXTRACT_16BITS(&tlv->length) < TLV_HDRL)
+ return INVALID_STLN;
+ if (EXTRACT_16BITS(&tlv->length) > rlen)
+ return INVALID_LTLN;
+ if (rlen < F_ALN_LEN(EXTRACT_16BITS(&tlv->length)))
+ return INVALID_ALEN;
+
+ return 0;
+}
+
+static inline int ilv_valid(const struct forces_ilv *ilv, u_int rlen)
+{
+ if (rlen < ILV_HDRL)
+ return INVALID_RLEN;
+ if (EXTRACT_32BITS(&ilv->length) < ILV_HDRL)
+ return INVALID_STLN;
+ if (EXTRACT_32BITS(&ilv->length) > rlen)
+ return INVALID_LTLN;
+ if (rlen < F_ALN_LEN(EXTRACT_32BITS(&ilv->length)))
+ return INVALID_ALEN;
+
+ return 0;
+}
+
+static int lfbselect_print(netdissect_options *, register const u_char * pptr, register u_int len,
+ uint16_t op_msk, int indent);
+static int redirect_print(netdissect_options *, register const u_char * pptr, register u_int len,
+ uint16_t op_msk, int indent);
+static int asrtlv_print(netdissect_options *, register const u_char * pptr, register u_int len,
+ uint16_t op_msk, int indent);
+static int asttlv_print(netdissect_options *, register const u_char * pptr, register u_int len,
+ uint16_t op_msk, int indent);
+
+struct forces_lfbsh {
+ nd_uint32_t class;
+ nd_uint32_t instance;
+};
+
+#define ASSNS_OPS (B_OP_REPORT)
+#define CFG_OPS (B_OP_SET|B_OP_SETPROP|B_OP_DEL|B_OP_COMMIT|B_OP_RTRCOMP)
+#define CFG_ROPS (B_OP_SETRESP|B_OP_SETPRESP|B_OP_DELRESP|B_OP_RCOMMIT)
+#define CFG_QY (B_OP_GET|B_OP_GETPROP)
+#define CFG_QYR (B_OP_GETRESP|B_OP_GETPRESP)
+#define CFG_EVN (B_OP_REPORT)
+
+static const struct tom_h ForCES_msg[TOM_MAX_IND + 1] = {
+ /* TOM_RSV_I */ {TOM_RSVD, ZERO_TTLV, 0, "Invalid message", NULL},
+ /* TOM_ASS_I */ {TOM_ASSNSETUP, ZERO_MORE_TTLV | TWO_TLV, ASSNS_OPS,
+ "Association Setup", lfbselect_print},
+ /* TOM_AST_I */
+ {TOM_ASSNTEARD, TTLV_T1, 0, "Association TearDown", asttlv_print},
+ /* TOM_CFG_I */ {TOM_CONFIG, TTLV_T2, CFG_OPS, "Config", lfbselect_print},
+ /* TOM_QRY_I */ {TOM_QUERY, TTLV_T2, CFG_QY, "Query", lfbselect_print},
+ /* TOM_EVN_I */ {TOM_EVENTNOT, TTLV_T1, CFG_EVN, "Event Notification",
+ lfbselect_print},
+ /* TOM_RED_I */
+ {TOM_PKTREDIR, TTLV_T2, 0, "Packet Redirect", redirect_print},
+ /* TOM_HBT_I */ {TOM_HEARTBT, ZERO_TTLV, 0, "HeartBeat", NULL},
+ /* TOM_ASR_I */
+ {TOM_ASSNSETREP, TTLV_T1, 0, "Association Response", asrtlv_print},
+ /* TOM_CNR_I */ {TOM_CONFIGREP, TTLV_T2, CFG_ROPS, "Config Response",
+ lfbselect_print},
+ /* TOM_QRR_I */
+ {TOM_QUERYREP, TTLV_T2, CFG_QYR, "Query Response", lfbselect_print},
+};
+
+static inline const struct tom_h *get_forces_tom(uint8_t tom)
+{
+ int i;
+ for (i = TOM_RSV_I; i <= TOM_MAX_IND; i++) {
+ const struct tom_h *th = &ForCES_msg[i];
+ if (th->v == tom)
+ return th;
+ }
+ return &ForCES_msg[TOM_RSV_I];
+}
+
+struct pdata_ops {
+ uint32_t v;
+ uint16_t flags;
+ uint16_t op_msk;
+ const char *s;
+ int (*print) (netdissect_options *, register const u_char * pptr, register u_int len,
+ uint16_t op_msk, int indent);
+};
+
+enum {
+ PD_RSV_I,
+ PD_SEL_I,
+ PD_FDT_I,
+ PD_SDT_I,
+ PD_RES_I,
+ PD_PDT_I,
+ _PD_RSV_MAX
+};
+#define PD_MAX_IND (_TOM_RSV_MAX - 1)
+
+static inline int pd_valid(uint16_t pd)
+{
+ if (pd >= F_TLV_PDAT && pd <= F_TLV_REST)
+ return 1;
+ return 0;
+}
+
+static inline void
+chk_op_type(netdissect_options *ndo,
+ uint16_t type, uint16_t msk, uint16_t omsk)
+{
+ if (type != F_TLV_PDAT) {
+ if (msk & B_KEYIN) {
+ if (type != F_TLV_KEYI) {
+ ND_PRINT((ndo, "Based on flags expected KEYINFO TLV!\n"));
+ }
+ } else {
+ if (!(msk & omsk)) {
+ ND_PRINT((ndo, "Illegal DATA encoding for type 0x%x programmed %x got %x \n",
+ type, omsk, msk));
+ }
+ }
+ }
+
+}
+
+#define F_SELKEY 1
+#define F_SELTABRANGE 2
+#define F_TABAPPEND 4
+
+struct res_val {
+ nd_uint8_t result;
+ nd_uint8_t resv1;
+ nd_uint16_t resv2;
+};
+
+static int prestlv_print(netdissect_options *, register const u_char * pptr, register u_int len,
+ uint16_t op_msk, int indent);
+static int pkeyitlv_print(netdissect_options *, register const u_char * pptr, register u_int len,
+ uint16_t op_msk, int indent);
+static int fdatatlv_print(netdissect_options *, register const u_char * pptr, register u_int len,
+ uint16_t op_msk, int indent);
+static int sdatatlv_print(netdissect_options *, register const u_char * pptr, register u_int len,
+ uint16_t op_msk, int indent);
+
+static const struct pdata_ops ForCES_pdata[PD_MAX_IND + 1] = {
+ /* PD_RSV_I */ {0, 0, 0, "Invalid message", NULL},
+ /* PD_SEL_I */ {F_TLV_KEYI, 0, 0, "KEYINFO TLV", pkeyitlv_print},
+ /* PD_FDT_I */ {F_TLV_FULD, 0, B_FULLD, "FULLDATA TLV", fdatatlv_print},
+ /* PD_SDT_I */ {F_TLV_SPAD, 0, B_SPARD, "SPARSEDATA TLV", sdatatlv_print},
+ /* PD_RES_I */ {F_TLV_REST, 0, B_RESTV, "RESULT TLV", prestlv_print},
+ /* PD_PDT_I */
+ {F_TLV_PDAT, 0, 0, "Inner PATH-DATA TLV", recpdoptlv_print},
+};
+
+static inline const struct pdata_ops *get_forces_pd(uint16_t pd)
+{
+ int i;
+ for (i = PD_RSV_I + 1; i <= PD_MAX_IND; i++) {
+ const struct pdata_ops *pdo = &ForCES_pdata[i];
+ if (pdo->v == pd)
+ return pdo;
+ }
+ return &ForCES_pdata[TOM_RSV_I];
+}
+
+enum {
+ E_SUCCESS,
+ E_INVALID_HEADER,
+ E_LENGTH_MISMATCH,
+ E_VERSION_MISMATCH,
+ E_INVALID_DESTINATION_PID,
+ E_LFB_UNKNOWN,
+ E_LFB_NOT_FOUND,
+ E_LFB_INSTANCE_ID_NOT_FOUND,
+ E_INVALID_PATH,
+ E_COMPONENT_DOES_NOT_EXIST,
+ E_EXISTS,
+ E_NOT_FOUND,
+ E_READ_ONLY,
+ E_INVALID_ARRAY_CREATION,
+ E_VALUE_OUT_OF_RANGE,
+ E_CONTENTS_TOO_LONG,
+ E_INVALID_PARAMETERS,
+ E_INVALID_MESSAGE_TYPE,
+ E_INVALID_FLAGS,
+ E_INVALID_TLV,
+ E_EVENT_ERROR,
+ E_NOT_SUPPORTED,
+ E_MEMORY_ERROR,
+ E_INTERNAL_ERROR,
+ /* 0x18-0xFE are reserved .. */
+ E_UNSPECIFIED_ERROR = 0XFF
+};
+
+static const struct tok ForCES_errs[] = {
+ {E_SUCCESS, "SUCCESS"},
+ {E_INVALID_HEADER, "INVALID HEADER"},
+ {E_LENGTH_MISMATCH, "LENGTH MISMATCH"},
+ {E_VERSION_MISMATCH, "VERSION MISMATCH"},
+ {E_INVALID_DESTINATION_PID, "INVALID DESTINATION PID"},
+ {E_LFB_UNKNOWN, "LFB UNKNOWN"},
+ {E_LFB_NOT_FOUND, "LFB NOT FOUND"},
+ {E_LFB_INSTANCE_ID_NOT_FOUND, "LFB INSTANCE ID NOT FOUND"},
+ {E_INVALID_PATH, "INVALID PATH"},
+ {E_COMPONENT_DOES_NOT_EXIST, "COMPONENT DOES NOT EXIST"},
+ {E_EXISTS, "EXISTS ALREADY"},
+ {E_NOT_FOUND, "NOT FOUND"},
+ {E_READ_ONLY, "READ ONLY"},
+ {E_INVALID_ARRAY_CREATION, "INVALID ARRAY CREATION"},
+ {E_VALUE_OUT_OF_RANGE, "VALUE OUT OF RANGE"},
+ {E_CONTENTS_TOO_LONG, "CONTENTS TOO LONG"},
+ {E_INVALID_PARAMETERS, "INVALID PARAMETERS"},
+ {E_INVALID_MESSAGE_TYPE, "INVALID MESSAGE TYPE"},
+ {E_INVALID_FLAGS, "INVALID FLAGS"},
+ {E_INVALID_TLV, "INVALID TLV"},
+ {E_EVENT_ERROR, "EVENT ERROR"},
+ {E_NOT_SUPPORTED, "NOT SUPPORTED"},
+ {E_MEMORY_ERROR, "MEMORY ERROR"},
+ {E_INTERNAL_ERROR, "INTERNAL ERROR"},
+ {E_UNSPECIFIED_ERROR, "UNSPECIFIED ERROR"},
+ {0, NULL}
+};
#define RESLEN 4
-int
-prestlv_print(register const u_char * pptr, register u_int len,
- u_int16_t op_msk _U_, int indent)
+static int
+prestlv_print(netdissect_options *ndo,
+ register const u_char * pptr, register u_int len,
+ uint16_t op_msk _U_, int indent)
{
- const struct forces_tlv *tlv = (struct forces_tlv *)pptr;
- register const u_char *tdp = (u_char *) TLV_DATA(tlv);
- struct res_val *r = (struct res_val *)tdp;
+ const struct forces_tlv *tlv = (const struct forces_tlv *)pptr;
+ register const u_char *tdp = (const u_char *) TLV_DATA(tlv);
+ const struct res_val *r = (const struct res_val *)tdp;
u_int dlen;
/*
@@ -47,92 +662,97 @@ prestlv_print(register const u_char * pptr, register u_int len,
*/
dlen = len - TLV_HDRL;
if (dlen != RESLEN) {
- printf("illegal RESULT-TLV: %d bytes!\n", dlen);
+ ND_PRINT((ndo, "illegal RESULT-TLV: %d bytes!\n", dlen));
return -1;
}
- TCHECK(*r);
+ ND_TCHECK(*r);
if (r->result >= 0x18 && r->result <= 0xFE) {
- printf("illegal reserved result code: 0x%x!\n", r->result);
+ ND_PRINT((ndo, "illegal reserved result code: 0x%x!\n", r->result));
return -1;
}
- if (vflag >= 3) {
+ if (ndo->ndo_vflag >= 3) {
char *ib = indent_pr(indent, 0);
- printf("%s Result: %s (code 0x%x)\n", ib,
- tok2str(ForCES_errs, NULL, r->result), r->result);
+ ND_PRINT((ndo, "%s Result: %s (code 0x%x)\n", ib,
+ tok2str(ForCES_errs, NULL, r->result), r->result));
}
return 0;
trunc:
- fputs("[|forces]", stdout);
+ ND_PRINT((ndo, "%s", tstr));
return -1;
}
-int
-fdatatlv_print(register const u_char * pptr, register u_int len,
- u_int16_t op_msk _U_, int indent)
+static int
+fdatatlv_print(netdissect_options *ndo,
+ register const u_char * pptr, register u_int len,
+ uint16_t op_msk _U_, int indent)
{
- const struct forces_tlv *tlv = (struct forces_tlv *)pptr;
+ const struct forces_tlv *tlv = (const struct forces_tlv *)pptr;
u_int rlen;
- register const u_char *tdp = (u_char *) TLV_DATA(tlv);
- u_int16_t type;
+ register const u_char *tdp = (const u_char *) TLV_DATA(tlv);
+ uint16_t type;
/*
* pdatacnt_print() or pkeyitlv_print() has ensured that len
* (the TLV length) >= TLV_HDRL.
*/
rlen = len - TLV_HDRL;
- TCHECK(*tlv);
+ ND_TCHECK(*tlv);
type = EXTRACT_16BITS(&tlv->type);
if (type != F_TLV_FULD) {
- printf("Error: expecting FULLDATA!\n");
+ ND_PRINT((ndo, "Error: expecting FULLDATA!\n"));
return -1;
}
- if (vflag >= 3) {
+ if (ndo->ndo_vflag >= 3) {
char *ib = indent_pr(indent + 2, 1);
- printf("%s[", &ib[1]);
- hex_print_with_offset(ib, tdp, rlen, 0);
- printf("\n%s]\n", &ib[1]);
+ ND_PRINT((ndo, "%s[", &ib[1]));
+ hex_print_with_offset(ndo, ib, tdp, rlen, 0);
+ ND_PRINT((ndo, "\n%s]\n", &ib[1]));
}
return 0;
trunc:
- fputs("[|forces]", stdout);
+ ND_PRINT((ndo, "%s", tstr));
return -1;
}
-int
-sdatailv_print(register const u_char * pptr, register u_int len,
- u_int16_t op_msk _U_, int indent)
+static int
+sdatailv_print(netdissect_options *ndo,
+ register const u_char * pptr, register u_int len,
+ uint16_t op_msk _U_, int indent)
{
u_int rlen;
- const struct forces_ilv *ilv = (struct forces_ilv *)pptr;
+ const struct forces_ilv *ilv = (const struct forces_ilv *)pptr;
int invilv;
if (len < ILV_HDRL) {
- printf("Error: BAD SPARSEDATA-TLV!\n");
+ ND_PRINT((ndo, "Error: BAD SPARSEDATA-TLV!\n"));
return -1;
}
rlen = len;
indent += 1;
while (rlen != 0) {
+#if 0
+ ND_PRINT((ndo, "Jamal - outstanding length <%d>\n", rlen));
+#endif
char *ib = indent_pr(indent, 1);
- register const u_char *tdp = (u_char *) ILV_DATA(ilv);
- TCHECK(*ilv);
+ register const u_char *tdp = (const u_char *) ILV_DATA(ilv);
+ ND_TCHECK(*ilv);
invilv = ilv_valid(ilv, rlen);
if (invilv) {
- printf("%s[", &ib[1]);
- hex_print_with_offset(ib, tdp, rlen, 0);
- printf("\n%s]\n", &ib[1]);
+ ND_PRINT((ndo, "%s[", &ib[1]));
+ hex_print_with_offset(ndo, ib, tdp, rlen, 0);
+ ND_PRINT((ndo, "\n%s]\n", &ib[1]));
return -1;
}
- if (vflag >= 3) {
+ if (ndo->ndo_vflag >= 3) {
int ilvl = EXTRACT_32BITS(&ilv->length);
- printf("\n%s ILV: type %x length %d\n", &ib[1],
- EXTRACT_32BITS(&ilv->type), ilvl);
- hex_print_with_offset("\t\t[", tdp, ilvl-ILV_HDRL, 0);
+ ND_PRINT((ndo, "\n%s ILV: type %x length %d\n", &ib[1],
+ EXTRACT_32BITS(&ilv->type), ilvl));
+ hex_print_with_offset(ndo, "\t\t[", tdp, ilvl-ILV_HDRL, 0);
}
ilv = GO_NXT_ILV(ilv, rlen);
@@ -141,62 +761,64 @@ sdatailv_print(register const u_char * pptr, register u_int len,
return 0;
trunc:
- fputs("[|forces]", stdout);
+ ND_PRINT((ndo, "%s", tstr));
return -1;
}
-int
-sdatatlv_print(register const u_char * pptr, register u_int len,
- u_int16_t op_msk, int indent)
+static int
+sdatatlv_print(netdissect_options *ndo,
+ register const u_char * pptr, register u_int len,
+ uint16_t op_msk, int indent)
{
- const struct forces_tlv *tlv = (struct forces_tlv *)pptr;
+ const struct forces_tlv *tlv = (const struct forces_tlv *)pptr;
u_int rlen;
- register const u_char *tdp = (u_char *) TLV_DATA(tlv);
- u_int16_t type;
+ register const u_char *tdp = (const u_char *) TLV_DATA(tlv);
+ uint16_t type;
/*
* pdatacnt_print() has ensured that len (the TLV length)
* >= TLV_HDRL.
*/
rlen = len - TLV_HDRL;
- TCHECK(*tlv);
+ ND_TCHECK(*tlv);
type = EXTRACT_16BITS(&tlv->type);
if (type != F_TLV_SPAD) {
- printf("Error: expecting SPARSEDATA!\n");
+ ND_PRINT((ndo, "Error: expecting SPARSEDATA!\n"));
return -1;
}
- return sdatailv_print(tdp, rlen, op_msk, indent);
+ return sdatailv_print(ndo, tdp, rlen, op_msk, indent);
trunc:
- fputs("[|forces]", stdout);
+ ND_PRINT((ndo, "%s", tstr));
return -1;
}
-int
-pkeyitlv_print(register const u_char * pptr, register u_int len,
- u_int16_t op_msk, int indent)
+static int
+pkeyitlv_print(netdissect_options *ndo,
+ register const u_char * pptr, register u_int len,
+ uint16_t op_msk, int indent)
{
- const struct forces_tlv *tlv = (struct forces_tlv *)pptr;
- register const u_char *tdp = (u_char *) TLV_DATA(tlv);
+ const struct forces_tlv *tlv = (const struct forces_tlv *)pptr;
+ register const u_char *tdp = (const u_char *) TLV_DATA(tlv);
register const u_char *dp = tdp + 4;
- const struct forces_tlv *kdtlv = (struct forces_tlv *)dp;
- u_int32_t id;
+ const struct forces_tlv *kdtlv = (const struct forces_tlv *)dp;
+ uint32_t id;
char *ib = indent_pr(indent, 0);
- u_int16_t type, tll;
- int invtlv;
+ uint16_t type, tll;
+ u_int invtlv;
- TCHECK(*tdp);
+ ND_TCHECK(*tdp);
id = EXTRACT_32BITS(tdp);
- printf("%sKeyinfo: Key 0x%x\n", ib, id);
- TCHECK(*kdtlv);
+ ND_PRINT((ndo, "%sKeyinfo: Key 0x%x\n", ib, id));
+ ND_TCHECK(*kdtlv);
type = EXTRACT_16BITS(&kdtlv->type);
invtlv = tlv_valid(kdtlv, len);
if (invtlv) {
- printf("%s TLV type 0x%x len %d\n",
+ ND_PRINT((ndo, "%s TLV type 0x%x len %d\n",
tok2str(ForCES_TLV_err, NULL, invtlv), type,
- EXTRACT_16BITS(&kdtlv->length));
+ EXTRACT_16BITS(&kdtlv->length)));
return -1;
}
/*
@@ -205,48 +827,114 @@ pkeyitlv_print(register const u_char * pptr, register u_int len,
* go past the end of the containing TLV).
*/
tll = EXTRACT_16BITS(&kdtlv->length);
- dp = (u_char *) TLV_DATA(kdtlv);
- return fdatatlv_print(dp, tll, op_msk, indent);
+ dp = (const u_char *) TLV_DATA(kdtlv);
+ return fdatatlv_print(ndo, dp, tll, op_msk, indent);
trunc:
- fputs("[|forces]", stdout);
+ ND_PRINT((ndo, "%s", tstr));
return -1;
}
-int
-pdatacnt_print(register const u_char * pptr, register u_int len,
- u_int16_t IDcnt, u_int16_t op_msk, int indent)
+#define PTH_DESC_SIZE 12
+
+static int
+pdatacnt_print(netdissect_options *ndo,
+ register const u_char * pptr, register u_int len,
+ uint16_t IDcnt, uint16_t op_msk, int indent)
{
u_int i;
- u_int32_t id;
+ uint32_t id;
char *ib = indent_pr(indent, 0);
+ if ((op_msk & B_APPND) && ndo->ndo_vflag >= 3) {
+ ND_PRINT((ndo, "%sTABLE APPEND\n", ib));
+ }
for (i = 0; i < IDcnt; i++) {
- TCHECK2(*pptr, 4);
+ ND_TCHECK2(*pptr, 4);
if (len < 4)
goto trunc;
id = EXTRACT_32BITS(pptr);
- if (vflag >= 3)
- printf("%s ID#%02u: %d\n", ib, i + 1, id);
+ if (ndo->ndo_vflag >= 3)
+ ND_PRINT((ndo, "%sID#%02u: %d\n", ib, i + 1, id));
len -= 4;
pptr += 4;
}
+
+ if ((op_msk & B_TRNG) || (op_msk & B_KEYIN)) {
+ if (op_msk & B_TRNG) {
+ uint32_t starti, endi;
+
+ if (len < PTH_DESC_SIZE) {
+ ND_PRINT((ndo, "pathlength %d with key/range too short %d\n",
+ len, PTH_DESC_SIZE));
+ return -1;
+ }
+
+ pptr += sizeof(struct forces_tlv);
+ len -= sizeof(struct forces_tlv);
+
+ starti = EXTRACT_32BITS(pptr);
+ pptr += 4;
+ len -= 4;
+
+ endi = EXTRACT_32BITS(pptr);
+ pptr += 4;
+ len -= 4;
+
+ if (ndo->ndo_vflag >= 3)
+ ND_PRINT((ndo, "%sTable range: [%d,%d]\n", ib, starti, endi));
+ }
+
+ if (op_msk & B_KEYIN) {
+ const struct forces_tlv *keytlv;
+ uint16_t tll;
+
+ if (len < PTH_DESC_SIZE) {
+ ND_PRINT((ndo, "pathlength %d with key/range too short %d\n",
+ len, PTH_DESC_SIZE));
+ return -1;
+ }
+
+ /* skip keyid */
+ pptr += 4;
+ len -= 4;
+ keytlv = (const struct forces_tlv *)pptr;
+ /* skip header */
+ pptr += sizeof(struct forces_tlv);
+ len -= sizeof(struct forces_tlv);
+ /* skip key content */
+ tll = EXTRACT_16BITS(&keytlv->length);
+ if (tll < TLV_HDRL) {
+ ND_PRINT((ndo, "key content length %u < %u\n",
+ tll, TLV_HDRL));
+ return -1;
+ }
+ tll -= TLV_HDRL;
+ if (len < tll) {
+ ND_PRINT((ndo, "key content too short\n"));
+ return -1;
+ }
+ pptr += tll;
+ len -= tll;
+ }
+
+ }
+
if (len) {
- const struct forces_tlv *pdtlv = (struct forces_tlv *)pptr;
- u_int16_t type;
- u_int16_t tll;
+ const struct forces_tlv *pdtlv = (const struct forces_tlv *)pptr;
+ uint16_t type;
+ uint16_t tll;
int pad = 0;
u_int aln;
- int invtlv;
+ u_int invtlv;
- TCHECK(*pdtlv);
+ ND_TCHECK(*pdtlv);
type = EXTRACT_16BITS(&pdtlv->type);
invtlv = tlv_valid(pdtlv, len);
if (invtlv) {
- printf
- ("%s Outstanding bytes %d for TLV type 0x%x TLV len %d\n",
- tok2str(ForCES_TLV_err, NULL, invtlv), len, type,
- EXTRACT_16BITS(&pdtlv->length));
+ ND_PRINT((ndo, "%s Outstanding bytes %d for TLV type 0x%x TLV len %d\n",
+ tok2str(ForCES_TLV_err, NULL, invtlv), len, type,
+ EXTRACT_16BITS(&pdtlv->length)));
goto pd_err;
}
/*
@@ -258,9 +946,9 @@ pdatacnt_print(register const u_char * pptr, register u_int len,
aln = F_ALN_LEN(EXTRACT_16BITS(&pdtlv->length));
if (aln > EXTRACT_16BITS(&pdtlv->length)) {
if (aln > len) {
- printf
- ("Invalid padded pathdata TLV type 0x%x len %d missing %d pad bytes\n",
- type, EXTRACT_16BITS(&pdtlv->length), aln - len);
+ ND_PRINT((ndo,
+ "Invalid padded pathdata TLV type 0x%x len %d missing %d pad bytes\n",
+ type, EXTRACT_16BITS(&pdtlv->length), aln - len));
} else {
pad = aln - EXTRACT_16BITS(&pdtlv->length);
}
@@ -268,34 +956,30 @@ pdatacnt_print(register const u_char * pptr, register u_int len,
if (pd_valid(type)) {
const struct pdata_ops *ops = get_forces_pd(type);
- if (vflag >= 3 && ops->v != F_TLV_PDAT) {
+ if (ndo->ndo_vflag >= 3 && ops->v != F_TLV_PDAT) {
if (pad)
- printf
- ("%s %s (Length %d DataLen %d pad %d Bytes)\n",
- ib, ops->s, EXTRACT_16BITS(&pdtlv->length),
- tll, pad);
+ ND_PRINT((ndo, "%s %s (Length %d DataLen %d pad %d Bytes)\n",
+ ib, ops->s, EXTRACT_16BITS(&pdtlv->length), tll, pad));
else
- printf
- ("%s %s (Length %d DataLen %d Bytes)\n",
- ib, ops->s, EXTRACT_16BITS(&pdtlv->length),
- tll);
+ ND_PRINT((ndo, "%s %s (Length %d DataLen %d Bytes)\n",
+ ib, ops->s, EXTRACT_16BITS(&pdtlv->length), tll));
}
- chk_op_type(type, op_msk, ops->op_msk);
+ chk_op_type(ndo, type, op_msk, ops->op_msk);
- if (ops->print((const u_char *)pdtlv,
+ if (ops->print(ndo, (const u_char *)pdtlv,
tll + pad + TLV_HDRL, op_msk,
indent + 2) == -1)
return -1;
len -= (TLV_HDRL + pad + tll);
} else {
- printf("Invalid path data content type 0x%x len %d\n",
- type, EXTRACT_16BITS(&pdtlv->length));
+ ND_PRINT((ndo, "Invalid path data content type 0x%x len %d\n",
+ type, EXTRACT_16BITS(&pdtlv->length)));
pd_err:
if (EXTRACT_16BITS(&pdtlv->length)) {
- hex_print_with_offset("Bad Data val\n\t [",
+ hex_print_with_offset(ndo, "Bad Data val\n\t [",
pptr, len, 0);
- printf("]\n");
+ ND_PRINT((ndo, "]\n"));
return -1;
}
@@ -304,115 +988,134 @@ pd_err:
return len;
trunc:
- fputs("[|forces]", stdout);
+ ND_PRINT((ndo, "%s", tstr));
return -1;
}
-int
-pdata_print(register const u_char * pptr, register u_int len,
- u_int16_t op_msk, int indent)
+static int
+pdata_print(netdissect_options *ndo,
+ register const u_char * pptr, register u_int len,
+ uint16_t op_msk, int indent)
{
- const struct pathdata_h *pdh = (struct pathdata_h *)pptr;
+ const struct pathdata_h *pdh = (const struct pathdata_h *)pptr;
char *ib = indent_pr(indent, 0);
u_int minsize = 0;
int more_pd = 0;
- u_int16_t idcnt = 0;
+ uint16_t idcnt = 0;
- TCHECK(*pdh);
+ ND_TCHECK(*pdh);
if (len < sizeof(struct pathdata_h))
goto trunc;
- if (vflag >= 3) {
- printf("\n%sPathdata: Flags 0x%x ID count %d\n",
- ib, EXTRACT_16BITS(&pdh->pflags), EXTRACT_16BITS(&pdh->pIDcnt));
+ if (ndo->ndo_vflag >= 3) {
+ ND_PRINT((ndo, "\n%sPathdata: Flags 0x%x ID count %d\n",
+ ib, EXTRACT_16BITS(&pdh->pflags), EXTRACT_16BITS(&pdh->pIDcnt)));
}
if (EXTRACT_16BITS(&pdh->pflags) & F_SELKEY) {
op_msk |= B_KEYIN;
}
+
+ /* Table GET Range operation */
+ if (EXTRACT_16BITS(&pdh->pflags) & F_SELTABRANGE) {
+ op_msk |= B_TRNG;
+ }
+ /* Table SET append operation */
+ if (EXTRACT_16BITS(&pdh->pflags) & F_TABAPPEND) {
+ op_msk |= B_APPND;
+ }
+
pptr += sizeof(struct pathdata_h);
len -= sizeof(struct pathdata_h);
idcnt = EXTRACT_16BITS(&pdh->pIDcnt);
minsize = idcnt * 4;
if (len < minsize) {
- printf("\t\t\ttruncated IDs expected %uB got %uB\n", minsize,
- len);
- hex_print_with_offset("\t\t\tID Data[", pptr, len, 0);
- printf("]\n");
+ ND_PRINT((ndo, "\t\t\ttruncated IDs expected %uB got %uB\n", minsize,
+ len));
+ hex_print_with_offset(ndo, "\t\t\tID Data[", pptr, len, 0);
+ ND_PRINT((ndo, "]\n"));
return -1;
}
- more_pd = pdatacnt_print(pptr, len, idcnt, op_msk, indent);
+
+ if ((op_msk & B_TRNG) && (op_msk & B_KEYIN)) {
+ ND_PRINT((ndo, "\t\t\tIllegal to have both Table ranges and keys\n"));
+ return -1;
+ }
+
+ more_pd = pdatacnt_print(ndo, pptr, len, idcnt, op_msk, indent);
if (more_pd > 0) {
int consumed = len - more_pd;
pptr += consumed;
- len = more_pd;
+ len = more_pd;
/* XXX: Argh, recurse some more */
- return recpdoptlv_print(pptr, len, op_msk, indent+1);
+ return recpdoptlv_print(ndo, pptr, len, op_msk, indent+1);
} else
return 0;
trunc:
- fputs("[|forces]", stdout);
+ ND_PRINT((ndo, "%s", tstr));
return -1;
}
-int
-genoptlv_print(register const u_char * pptr, register u_int len,
- u_int16_t op_msk, int indent)
+static int
+genoptlv_print(netdissect_options *ndo,
+ register const u_char * pptr, register u_int len,
+ uint16_t op_msk, int indent)
{
- const struct forces_tlv *pdtlv = (struct forces_tlv *)pptr;
- u_int16_t type;
+ const struct forces_tlv *pdtlv = (const struct forces_tlv *)pptr;
+ uint16_t type;
int tll;
- int invtlv;
+ u_int invtlv;
char *ib = indent_pr(indent, 0);
- TCHECK(*pdtlv);
+ ND_TCHECK(*pdtlv);
type = EXTRACT_16BITS(&pdtlv->type);
tll = EXTRACT_16BITS(&pdtlv->length) - TLV_HDRL;
invtlv = tlv_valid(pdtlv, len);
- printf("genoptlvprint - %s TLV type 0x%x len %d\n",
- tok2str(ForCES_TLV, NULL, type), type, EXTRACT_16BITS(&pdtlv->length));
+ ND_PRINT((ndo, "genoptlvprint - %s TLV type 0x%x len %d\n",
+ tok2str(ForCES_TLV, NULL, type), type, EXTRACT_16BITS(&pdtlv->length)));
if (!invtlv) {
/*
* At this point, tlv_valid() has ensured that the TLV
* length is large enough but not too large (it doesn't
* go past the end of the containing TLV).
*/
- register const u_char *dp = (u_char *) TLV_DATA(pdtlv);
+ register const u_char *dp = (const u_char *) TLV_DATA(pdtlv);
if (!ttlv_valid(type)) {
- printf("%s TLV type 0x%x len %d\n",
+ ND_PRINT((ndo, "%s TLV type 0x%x len %d\n",
tok2str(ForCES_TLV_err, NULL, invtlv), type,
- EXTRACT_16BITS(&pdtlv->length));
+ EXTRACT_16BITS(&pdtlv->length)));
return -1;
}
- if (vflag >= 3)
- printf("%s%s, length %d (data length %d Bytes)",
+ if (ndo->ndo_vflag >= 3)
+ ND_PRINT((ndo, "%s%s, length %d (data length %d Bytes)",
ib, tok2str(ForCES_TLV, NULL, type),
- EXTRACT_16BITS(&pdtlv->length), tll);
+ EXTRACT_16BITS(&pdtlv->length), tll));
- return pdata_print(dp, tll, op_msk, indent + 1);
+ return pdata_print(ndo, dp, tll, op_msk, indent + 1);
} else {
- printf("\t\t\tInvalid ForCES TLV type=%x", type);
+ ND_PRINT((ndo, "\t\t\tInvalid ForCES TLV type=%x", type));
return -1;
}
trunc:
- fputs("[|forces]", stdout);
+ ND_PRINT((ndo, "%s", tstr));
return -1;
}
-int
-recpdoptlv_print(register const u_char * pptr, register u_int len,
- u_int16_t op_msk, int indent)
+static int
+recpdoptlv_print(netdissect_options *ndo,
+ register const u_char * pptr, register u_int len,
+ uint16_t op_msk, int indent)
{
- const struct forces_tlv *pdtlv = (struct forces_tlv *)pptr;
+ const struct forces_tlv *pdtlv = (const struct forces_tlv *)pptr;
int tll;
- int invtlv;
- u_int16_t type;
+ u_int invtlv;
+ uint16_t type;
register const u_char *dp;
char *ib;
while (len != 0) {
- TCHECK(*pdtlv);
+ ND_TCHECK(*pdtlv);
invtlv = tlv_valid(pdtlv, len);
if (invtlv) {
break;
@@ -425,54 +1128,56 @@ recpdoptlv_print(register const u_char * pptr, register u_int len,
*/
ib = indent_pr(indent, 0);
type = EXTRACT_16BITS(&pdtlv->type);
- dp = (u_char *) TLV_DATA(pdtlv);
+ dp = (const u_char *) TLV_DATA(pdtlv);
tll = EXTRACT_16BITS(&pdtlv->length) - TLV_HDRL;
- if (vflag >= 3)
- printf
- ("%s%s, length %d (data encapsulated %d Bytes)",
- ib, tok2str(ForCES_TLV, NULL, type),
- EXTRACT_16BITS(&pdtlv->length),
- EXTRACT_16BITS(&pdtlv->length) - TLV_HDRL);
+ if (ndo->ndo_vflag >= 3)
+ ND_PRINT((ndo, "%s%s, length %d (data encapsulated %d Bytes)",
+ ib, tok2str(ForCES_TLV, NULL, type),
+ EXTRACT_16BITS(&pdtlv->length),
+ EXTRACT_16BITS(&pdtlv->length) - TLV_HDRL));
- if (pdata_print(dp, tll, op_msk, indent + 1) == -1)
+ if (pdata_print(ndo, dp, tll, op_msk, indent + 1) == -1)
return -1;
pdtlv = GO_NXT_TLV(pdtlv, len);
}
if (len) {
- printf
- ("\n\t\tMessy PATHDATA TLV header, type (0x%x)\n\t\texcess of %d Bytes ",
- EXTRACT_16BITS(&pdtlv->type), len - EXTRACT_16BITS(&pdtlv->length));
+ ND_PRINT((ndo,
+ "\n\t\tMessy PATHDATA TLV header, type (0x%x)\n\t\texcess of %d Bytes ",
+ EXTRACT_16BITS(&pdtlv->type), len - EXTRACT_16BITS(&pdtlv->length)));
return -1;
}
return 0;
trunc:
- fputs("[|forces]", stdout);
+ ND_PRINT((ndo, "%s", tstr));
return -1;
}
-int
-invoptlv_print(register const u_char * pptr, register u_int len,
- u_int16_t op_msk _U_, int indent)
+static int
+invoptlv_print(netdissect_options *ndo,
+ register const u_char * pptr, register u_int len,
+ uint16_t op_msk _U_, int indent)
{
char *ib = indent_pr(indent, 1);
- if (vflag >= 3) {
- printf("%sData[", &ib[1]);
- hex_print_with_offset(ib, pptr, len, 0);
- printf("%s]\n", ib);
+ if (ndo->ndo_vflag >= 3) {
+ ND_PRINT((ndo, "%sData[", &ib[1]));
+ hex_print_with_offset(ndo, ib, pptr, len, 0);
+ ND_PRINT((ndo, "%s]\n", ib));
}
return -1;
}
-int otlv_print(const struct forces_tlv *otlv, u_int16_t op_msk _U_, int indent)
+static int
+otlv_print(netdissect_options *ndo,
+ const struct forces_tlv *otlv, uint16_t op_msk _U_, int indent)
{
int rc = 0;
- register const u_char *dp = (u_char *) TLV_DATA(otlv);
- u_int16_t type;
+ register const u_char *dp = (const u_char *) TLV_DATA(otlv);
+ uint16_t type;
int tll;
char *ib = indent_pr(indent, 0);
const struct optlv_h *ops;
@@ -481,45 +1186,43 @@ int otlv_print(const struct forces_tlv *otlv, u_int16_t op_msk _U_, int indent)
* lfbselect_print() has ensured that EXTRACT_16BITS(&otlv->length)
* >= TLV_HDRL.
*/
- TCHECK(*otlv);
+ ND_TCHECK(*otlv);
type = EXTRACT_16BITS(&otlv->type);
tll = EXTRACT_16BITS(&otlv->length) - TLV_HDRL;
ops = get_forces_optlv_h(type);
- if (vflag >= 3) {
- printf("%sOper TLV %s(0x%x) length %d\n", ib, ops->s, type,
- EXTRACT_16BITS(&otlv->length));
- }
- /* empty TLVs like COMMIT and TRCOMMIT are empty, we stop here .. */
- if (!ops->flags & ZERO_TTLV) {
- if (tll != 0) /* instead of "if (tll)" - for readability .. */
- printf("%s: Illegal - MUST be empty\n", ops->s);
- return rc;
+ if (ndo->ndo_vflag >= 3) {
+ ND_PRINT((ndo, "%sOper TLV %s(0x%x) length %d\n", ib, ops->s, type,
+ EXTRACT_16BITS(&otlv->length)));
}
/* rest of ops must at least have 12B {pathinfo} */
if (tll < OP_MIN_SIZ) {
- printf("\t\tOper TLV %s(0x%x) length %d\n", ops->s, type,
- EXTRACT_16BITS(&otlv->length));
- printf("\t\tTruncated data size %d minimum required %d\n", tll,
- OP_MIN_SIZ);
- return invoptlv_print(dp, tll, ops->op_msk, indent);
+ ND_PRINT((ndo, "\t\tOper TLV %s(0x%x) length %d\n", ops->s, type,
+ EXTRACT_16BITS(&otlv->length)));
+ ND_PRINT((ndo, "\t\tTruncated data size %d minimum required %d\n", tll,
+ OP_MIN_SIZ));
+ return invoptlv_print(ndo, dp, tll, ops->op_msk, indent);
}
- rc = ops->print(dp, tll, ops->op_msk, indent + 1);
+ /* XXX - do anything with ops->flags? */
+ if(ops->print) {
+ rc = ops->print(ndo, dp, tll, ops->op_msk, indent + 1);
+ }
return rc;
trunc:
- fputs("[|forces]", stdout);
+ ND_PRINT((ndo, "%s", tstr));
return -1;
}
#define ASTDLN 4
#define ASTMCD 255
-int
-asttlv_print(register const u_char * pptr, register u_int len,
- u_int16_t op_msk _U_, int indent)
+static int
+asttlv_print(netdissect_options *ndo,
+ register const u_char * pptr, register u_int len,
+ uint16_t op_msk _U_, int indent)
{
- u_int32_t rescode;
+ uint32_t rescode;
u_int dlen;
char *ib = indent_pr(indent, 0);
@@ -529,54 +1232,55 @@ asttlv_print(register const u_char * pptr, register u_int len,
*/
dlen = len - TLV_HDRL;
if (dlen != ASTDLN) {
- printf("illegal ASTresult-TLV: %d bytes!\n", dlen);
+ ND_PRINT((ndo, "illegal ASTresult-TLV: %d bytes!\n", dlen));
return -1;
}
- TCHECK2(*pptr, 4);
+ ND_TCHECK2(*pptr, 4);
rescode = EXTRACT_32BITS(pptr);
if (rescode > ASTMCD) {
- printf("illegal ASTresult result code: %d!\n", rescode);
+ ND_PRINT((ndo, "illegal ASTresult result code: %d!\n", rescode));
return -1;
}
- if (vflag >= 3) {
- printf("Teardown reason:\n%s", ib);
+ if (ndo->ndo_vflag >= 3) {
+ ND_PRINT((ndo, "Teardown reason:\n%s", ib));
switch (rescode) {
case 0:
- printf("Normal Teardown");
+ ND_PRINT((ndo, "Normal Teardown"));
break;
case 1:
- printf("Loss of Heartbeats");
+ ND_PRINT((ndo, "Loss of Heartbeats"));
break;
case 2:
- printf("Out of bandwidth");
+ ND_PRINT((ndo, "Out of bandwidth"));
break;
case 3:
- printf("Out of Memory");
+ ND_PRINT((ndo, "Out of Memory"));
break;
case 4:
- printf("Application Crash");
+ ND_PRINT((ndo, "Application Crash"));
break;
default:
- printf("Unknown Teardown reason");
+ ND_PRINT((ndo, "Unknown Teardown reason"));
break;
}
- printf("(%x)\n%s", rescode, ib);
+ ND_PRINT((ndo, "(%x)\n%s", rescode, ib));
}
return 0;
trunc:
- fputs("[|forces]", stdout);
+ ND_PRINT((ndo, "%s", tstr));
return -1;
}
#define ASRDLN 4
#define ASRMCD 3
-int
-asrtlv_print(register const u_char * pptr, register u_int len,
- u_int16_t op_msk _U_, int indent)
+static int
+asrtlv_print(netdissect_options *ndo,
+ register const u_char * pptr, register u_int len,
+ uint16_t op_msk _U_, int indent)
{
- u_int32_t rescode;
+ uint32_t rescode;
u_int dlen;
char *ib = indent_pr(indent, 0);
@@ -586,94 +1290,100 @@ asrtlv_print(register const u_char * pptr, register u_int len,
*/
dlen = len - TLV_HDRL;
if (dlen != ASRDLN) { /* id, instance, oper tlv */
- printf("illegal ASRresult-TLV: %d bytes!\n", dlen);
+ ND_PRINT((ndo, "illegal ASRresult-TLV: %d bytes!\n", dlen));
return -1;
}
- TCHECK2(*pptr, 4);
+ ND_TCHECK2(*pptr, 4);
rescode = EXTRACT_32BITS(pptr);
if (rescode > ASRMCD) {
- printf("illegal ASRresult result code: %d!\n", rescode);
+ ND_PRINT((ndo, "illegal ASRresult result code: %d!\n", rescode));
return -1;
}
- if (vflag >= 3) {
- printf("\n%s", ib);
+ if (ndo->ndo_vflag >= 3) {
+ ND_PRINT((ndo, "\n%s", ib));
switch (rescode) {
case 0:
- printf("Success ");
+ ND_PRINT((ndo, "Success "));
break;
case 1:
- printf("FE ID invalid ");
+ ND_PRINT((ndo, "FE ID invalid "));
break;
case 2:
- printf("permission denied ");
+ ND_PRINT((ndo, "permission denied "));
break;
default:
- printf("Unknown ");
+ ND_PRINT((ndo, "Unknown "));
break;
}
- printf("(%x)\n%s", rescode, ib);
+ ND_PRINT((ndo, "(%x)\n%s", rescode, ib));
}
return 0;
trunc:
- fputs("[|forces]", stdout);
+ ND_PRINT((ndo, "%s", tstr));
return -1;
}
+#if 0
/*
* XXX - not used.
*/
-int
-gentltlv_print(register const u_char * pptr _U_, register u_int len,
- u_int16_t op_msk _U_, int indent _U_)
+static int
+gentltlv_print(netdissect_options *ndo,
+ register const u_char * pptr _U_, register u_int len,
+ uint16_t op_msk _U_, int indent _U_)
{
u_int dlen = len - TLV_HDRL;
if (dlen < 4) { /* at least 32 bits must exist */
- printf("truncated TLV: %d bytes missing! ", 4 - dlen);
+ ND_PRINT((ndo, "truncated TLV: %d bytes missing! ", 4 - dlen));
return -1;
}
return 0;
}
+#endif
#define RD_MIN 8
-int
-print_metailv(register const u_char * pptr, register u_int len,
- u_int16_t op_msk _U_, int indent)
+
+static int
+print_metailv(netdissect_options *ndo,
+ register const u_char * pptr, uint16_t op_msk _U_, int indent)
{
- u_int dlen;
u_int rlen;
char *ib = indent_pr(indent, 0);
/* XXX: check header length */
- const struct forces_ilv *ilv = (struct forces_ilv *)pptr;
+ const struct forces_ilv *ilv = (const struct forces_ilv *)pptr;
/*
* print_metatlv() has ensured that len (what remains in the
* ILV) >= ILV_HDRL.
*/
- dlen = len - ILV_HDRL;
- rlen = dlen;
- TCHECK(*ilv);
- printf("\n%sMetaID 0x%x length %d\n", ib, EXTRACT_32BITS(&ilv->type),
- EXTRACT_32BITS(&ilv->length));
- hex_print_with_offset("\n\t\t\t\t[", ILV_DATA(ilv), rlen, 0);
+ rlen = EXTRACT_32BITS(&ilv->length) - ILV_HDRL;
+ ND_TCHECK(*ilv);
+ ND_PRINT((ndo, "%sMetaID 0x%x length %d\n", ib, EXTRACT_32BITS(&ilv->type),
+ EXTRACT_32BITS(&ilv->length)));
+ if (ndo->ndo_vflag >= 3) {
+ hex_print_with_offset(ndo, "\t\t[", ILV_DATA(ilv), rlen, 0);
+ ND_PRINT((ndo, " ]\n"));
+ }
return 0;
trunc:
- fputs("[|forces]", stdout);
+ ND_PRINT((ndo, "%s", tstr));
return -1;
}
-int
-print_metatlv(register const u_char * pptr, register u_int len,
- u_int16_t op_msk _U_, int indent)
+static int
+print_metatlv(netdissect_options *ndo,
+ register const u_char * pptr, register u_int len,
+ uint16_t op_msk _U_, int indent)
{
u_int dlen;
char *ib = indent_pr(indent, 0);
u_int rlen;
- const struct forces_ilv *ilv = (struct forces_ilv *)pptr;
+ const struct forces_ilv *ilv = (const struct forces_ilv *)pptr;
int invilv;
/*
@@ -682,85 +1392,62 @@ print_metatlv(register const u_char * pptr, register u_int len,
*/
dlen = len - TLV_HDRL;
rlen = dlen;
- printf("\n%s METADATA\n", ib);
+ ND_PRINT((ndo, "\n%s METADATA length %d \n", ib, rlen));
while (rlen != 0) {
- TCHECK(*ilv);
+ ND_TCHECK(*ilv);
invilv = ilv_valid(ilv, rlen);
- if (invilv)
+ if (invilv) {
break;
+ }
/*
* At this point, ilv_valid() has ensured that the ILV
* length is large enough but not too large (it doesn't
* go past the end of the containing TLV).
*/
- print_metailv((u_char *) ilv, rlen, 0, indent + 1);
-
+ print_metailv(ndo, (const u_char *) ilv, 0, indent + 1);
ilv = GO_NXT_ILV(ilv, rlen);
}
return 0;
trunc:
- fputs("[|forces]", stdout);
+ ND_PRINT((ndo, "%s", tstr));
return -1;
}
-/*
-*/
-int
-print_reddata(register const u_char * pptr, register u_int len,
- u_int16_t op_msk _U_, int indent _U_)
+
+static int
+print_reddata(netdissect_options *ndo,
+ register const u_char * pptr, register u_int len,
+ uint16_t op_msk _U_, int indent)
{
u_int dlen;
+ char *ib = indent_pr(indent, 0);
u_int rlen;
- int invtlv;
- const struct forces_tlv *tlv = (struct forces_tlv *)pptr;
- /*
- * redirect_print() has ensured that len (what remains in the
- * TLV) >= TLV_HDRL.
- */
dlen = len - TLV_HDRL;
- printf("\n\t\t Redirect DATA\n");
- if (dlen <= RD_MIN) {
- printf("\n\t\ttruncated Redirect data: %d bytes missing! ",
- RD_MIN - dlen);
- return -1;
- }
-
rlen = dlen;
- TCHECK(*tlv);
- invtlv = tlv_valid(tlv, rlen);
+ ND_PRINT((ndo, "\n%s Redirect Data length %d \n", ib, rlen));
- if (invtlv) {
- printf("Redir data type 0x%x len %d\n", EXTRACT_16BITS(&tlv->type),
- EXTRACT_16BITS(&tlv->length));
- return -1;
+ if (ndo->ndo_vflag >= 3) {
+ ND_PRINT((ndo, "\t\t["));
+ hex_print_with_offset(ndo, "\n\t\t", pptr, rlen, 0);
+ ND_PRINT((ndo, "\n\t\t]"));
}
- /*
- * At this point, tlv_valid() has ensured that the TLV
- * length is large enough but not too large (it doesn't
- * go past the end of the containing TLV).
- */
- rlen -= TLV_HDRL;
- hex_print_with_offset("\n\t\t\t[", TLV_DATA(tlv), rlen, 0);
return 0;
-
-trunc:
- fputs("[|forces]", stdout);
- return -1;
}
-int
-redirect_print(register const u_char * pptr, register u_int len,
- u_int16_t op_msk _U_, int indent)
+static int
+redirect_print(netdissect_options *ndo,
+ register const u_char * pptr, register u_int len,
+ uint16_t op_msk _U_, int indent)
{
- const struct forces_tlv *tlv = (struct forces_tlv *)pptr;
+ const struct forces_tlv *tlv = (const struct forces_tlv *)pptr;
u_int dlen;
u_int rlen;
- int invtlv;
+ u_int invtlv;
/*
* forces_type_print() has ensured that len (the TLV length)
@@ -768,18 +1455,20 @@ redirect_print(register const u_char * pptr, register u_int len,
*/
dlen = len - TLV_HDRL;
if (dlen <= RD_MIN) {
- printf("\n\t\ttruncated Redirect TLV: %d bytes missing! ",
- RD_MIN - dlen);
+ ND_PRINT((ndo, "\n\t\ttruncated Redirect TLV: %d bytes missing! ",
+ RD_MIN - dlen));
return -1;
}
rlen = dlen;
indent += 1;
while (rlen != 0) {
- TCHECK(*tlv);
+ ND_TCHECK(*tlv);
invtlv = tlv_valid(tlv, rlen);
- if (invtlv)
+ if (invtlv) {
+ ND_PRINT((ndo, "Bad Redirect data\n"));
break;
+ }
/*
* At this point, tlv_valid() has ensured that the TLV
@@ -787,44 +1476,49 @@ redirect_print(register const u_char * pptr, register u_int len,
* go past the end of the containing TLV).
*/
if (EXTRACT_16BITS(&tlv->type) == F_TLV_METD) {
- print_metatlv((u_char *) TLV_DATA(tlv), rlen, 0, indent);
+ print_metatlv(ndo, (const u_char *) TLV_DATA(tlv),
+ EXTRACT_16BITS(&tlv->length), 0, indent);
} else if ((EXTRACT_16BITS(&tlv->type) == F_TLV_REDD)) {
- print_reddata((u_char *) TLV_DATA(tlv), rlen, 0, indent);
+ print_reddata(ndo, (const u_char *) TLV_DATA(tlv),
+ EXTRACT_16BITS(&tlv->length), 0, indent);
} else {
- printf("Unknown REDIRECT TLV 0x%x len %d\n",
- EXTRACT_16BITS(&tlv->type), EXTRACT_16BITS(&tlv->length));
+ ND_PRINT((ndo, "Unknown REDIRECT TLV 0x%x len %d\n",
+ EXTRACT_16BITS(&tlv->type),
+ EXTRACT_16BITS(&tlv->length)));
}
tlv = GO_NXT_TLV(tlv, rlen);
}
if (rlen) {
- printf
- ("\n\t\tMessy Redirect TLV header, type (0x%x)\n\t\texcess of %d Bytes ",
- EXTRACT_16BITS(&tlv->type), rlen - EXTRACT_16BITS(&tlv->length));
+ ND_PRINT((ndo,
+ "\n\t\tMessy Redirect TLV header, type (0x%x)\n\t\texcess of %d Bytes ",
+ EXTRACT_16BITS(&tlv->type),
+ rlen - EXTRACT_16BITS(&tlv->length)));
return -1;
}
return 0;
trunc:
- fputs("[|forces]", stdout);
+ ND_PRINT((ndo, "%s", tstr));
return -1;
}
#define OP_OFF 8
#define OP_MIN 12
-int
-lfbselect_print(register const u_char * pptr, register u_int len,
- u_int16_t op_msk, int indent)
+static int
+lfbselect_print(netdissect_options *ndo,
+ register const u_char * pptr, register u_int len,
+ uint16_t op_msk, int indent)
{
const struct forces_lfbsh *lfbs;
const struct forces_tlv *otlv;
char *ib = indent_pr(indent, 0);
u_int dlen;
u_int rlen;
- int invtlv;
+ u_int invtlv;
/*
* forces_type_print() has ensured that len (the TLV length)
@@ -832,8 +1526,8 @@ lfbselect_print(register const u_char * pptr, register u_int len,
*/
dlen = len - TLV_HDRL;
if (dlen <= OP_MIN) { /* id, instance, oper tlv header .. */
- printf("\n\t\ttruncated lfb selector: %d bytes missing! ",
- OP_MIN - dlen);
+ ND_PRINT((ndo, "\n\t\ttruncated lfb selector: %d bytes missing! ",
+ OP_MIN - dlen));
return -1;
}
@@ -844,19 +1538,19 @@ lfbselect_print(register const u_char * pptr, register u_int len,
rlen = dlen - OP_OFF;
lfbs = (const struct forces_lfbsh *)pptr;
- TCHECK(*lfbs);
- if (vflag >= 3) {
- printf("\n%s%s(Classid %x) instance %x\n",
+ ND_TCHECK(*lfbs);
+ if (ndo->ndo_vflag >= 3) {
+ ND_PRINT((ndo, "\n%s%s(Classid %x) instance %x\n",
ib, tok2str(ForCES_LFBs, NULL, EXTRACT_32BITS(&lfbs->class)),
EXTRACT_32BITS(&lfbs->class),
- EXTRACT_32BITS(&lfbs->instance));
+ EXTRACT_32BITS(&lfbs->instance)));
}
- otlv = (struct forces_tlv *)(lfbs + 1);
+ otlv = (const struct forces_tlv *)(lfbs + 1);
indent += 1;
while (rlen != 0) {
- TCHECK(*otlv);
+ ND_TCHECK(*otlv);
invtlv = tlv_valid(otlv, rlen);
if (invtlv)
break;
@@ -867,39 +1561,40 @@ lfbselect_print(register const u_char * pptr, register u_int len,
* go past the end of the containing TLV).
*/
if (op_valid(EXTRACT_16BITS(&otlv->type), op_msk)) {
- otlv_print(otlv, 0, indent);
+ otlv_print(ndo, otlv, 0, indent);
} else {
- if (vflag < 3)
- printf("\n");
- printf
- ("\t\tINValid oper-TLV type 0x%x length %d for this ForCES message\n",
- EXTRACT_16BITS(&otlv->type), EXTRACT_16BITS(&otlv->length));
- invoptlv_print((u_char *)otlv, rlen, 0, indent);
+ if (ndo->ndo_vflag < 3)
+ ND_PRINT((ndo, "\n"));
+ ND_PRINT((ndo,
+ "\t\tINValid oper-TLV type 0x%x length %d for this ForCES message\n",
+ EXTRACT_16BITS(&otlv->type), EXTRACT_16BITS(&otlv->length)));
+ invoptlv_print(ndo, (const u_char *)otlv, rlen, 0, indent);
}
otlv = GO_NXT_TLV(otlv, rlen);
}
if (rlen) {
- printf
- ("\n\t\tMessy oper TLV header, type (0x%x)\n\t\texcess of %d Bytes ",
- EXTRACT_16BITS(&otlv->type), rlen - EXTRACT_16BITS(&otlv->length));
+ ND_PRINT((ndo,
+ "\n\t\tMessy oper TLV header, type (0x%x)\n\t\texcess of %d Bytes ",
+ EXTRACT_16BITS(&otlv->type), rlen - EXTRACT_16BITS(&otlv->length)));
return -1;
}
return 0;
trunc:
- fputs("[|forces]", stdout);
+ ND_PRINT((ndo, "%s", tstr));
return -1;
}
-int
-forces_type_print(register const u_char * pptr, const struct forcesh *fhdr _U_,
- register u_int mlen, const struct tom_h *tops)
+static int
+forces_type_print(netdissect_options *ndo,
+ register const u_char * pptr, const struct forcesh *fhdr _U_,
+ register u_int mlen, const struct tom_h *tops)
{
const struct forces_tlv *tltlv;
u_int rlen;
- int invtlv;
+ u_int invtlv;
int rc = 0;
int ttlv = 0;
@@ -911,14 +1606,14 @@ forces_type_print(register const u_char * pptr, const struct forcesh *fhdr _U_,
if (rlen > TLV_HLN) {
if (tops->flags & ZERO_TTLV) {
- printf("<0x%x>Illegal Top level TLV!\n", tops->flags);
+ ND_PRINT((ndo, "<0x%x>Illegal Top level TLV!\n", tops->flags));
return -1;
}
} else {
if (tops->flags & ZERO_MORE_TTLV)
return 0;
if (tops->flags & ONE_MORE_TTLV) {
- printf("\tTop level TLV Data missing!\n");
+ ND_PRINT((ndo, "\tTop level TLV Data missing!\n"));
return -1;
}
}
@@ -933,7 +1628,7 @@ forces_type_print(register const u_char * pptr, const struct forcesh *fhdr _U_,
/*XXX: 15 top level tlvs will probably be fine
You are nuts if you send more ;-> */
while (rlen != 0) {
- TCHECK(*tltlv);
+ ND_TCHECK(*tltlv);
invtlv = tlv_valid(tltlv, rlen);
if (invtlv)
break;
@@ -944,18 +1639,18 @@ forces_type_print(register const u_char * pptr, const struct forcesh *fhdr _U_,
* go past the end of the packet).
*/
if (!ttlv_valid(EXTRACT_16BITS(&tltlv->type))) {
- printf("\n\tInvalid ForCES Top TLV type=0x%x",
- EXTRACT_16BITS(&tltlv->type));
+ ND_PRINT((ndo, "\n\tInvalid ForCES Top TLV type=0x%x",
+ EXTRACT_16BITS(&tltlv->type)));
return -1;
}
- if (vflag >= 3)
- printf("\t%s, length %d (data length %d Bytes)",
+ if (ndo->ndo_vflag >= 3)
+ ND_PRINT((ndo, "\t%s, length %d (data length %d Bytes)",
tok2str(ForCES_TLV, NULL, EXTRACT_16BITS(&tltlv->type)),
EXTRACT_16BITS(&tltlv->length),
- EXTRACT_16BITS(&tltlv->length) - TLV_HDRL);
+ EXTRACT_16BITS(&tltlv->length) - TLV_HDRL));
- rc = tops->print((u_char *) TLV_DATA(tltlv),
+ rc = tops->print(ndo, (const u_char *) TLV_DATA(tltlv),
EXTRACT_16BITS(&tltlv->length), tops->op_msk, 9);
if (rc < 0) {
return -1;
@@ -970,30 +1665,32 @@ forces_type_print(register const u_char * pptr, const struct forcesh *fhdr _U_,
* short, and didn't have *enough* TLVs in it?
*/
if (rlen) {
- printf("\tMess TopTLV header: min %u, total %d advertised %d ",
- TLV_HDRL, rlen, EXTRACT_16BITS(&tltlv->length));
+ ND_PRINT((ndo, "\tMess TopTLV header: min %u, total %d advertised %d ",
+ TLV_HDRL, rlen, EXTRACT_16BITS(&tltlv->length)));
return -1;
}
return 0;
trunc:
- fputs("[|forces]", stdout);
+ ND_PRINT((ndo, "%s", tstr));
return -1;
}
-void forces_print(register const u_char * pptr, register u_int len)
+void
+forces_print(netdissect_options *ndo,
+ register const u_char * pptr, register u_int len)
{
const struct forcesh *fhdr;
u_int mlen;
- u_int32_t flg_raw;
+ uint32_t flg_raw;
const struct tom_h *tops;
int rc = 0;
fhdr = (const struct forcesh *)pptr;
- TCHECK(*fhdr);
+ ND_TCHECK(*fhdr);
if (!tom_valid(fhdr->fm_tom)) {
- printf("Invalid ForCES message type %d\n", fhdr->fm_tom);
+ ND_PRINT((ndo, "Invalid ForCES message type %d\n", fhdr->fm_tom));
goto error;
}
@@ -1001,57 +1698,71 @@ void forces_print(register const u_char * pptr, register u_int len)
tops = get_forces_tom(fhdr->fm_tom);
if (tops->v == TOM_RSVD) {
- printf("\n\tUnknown ForCES message type=0x%x", fhdr->fm_tom);
+ ND_PRINT((ndo, "\n\tUnknown ForCES message type=0x%x", fhdr->fm_tom));
goto error;
}
- printf("\n\tForCES %s ", tops->s);
+ ND_PRINT((ndo, "\n\tForCES %s ", tops->s));
if (!ForCES_HLN_VALID(mlen, len)) {
- printf
- ("Illegal ForCES pkt len - min %u, total recvd %d, advertised %d ",
- ForCES_HDRL, len, ForCES_BLN(fhdr));
+ ND_PRINT((ndo,
+ "Illegal ForCES pkt len - min %u, total recvd %d, advertised %d ",
+ ForCES_HDRL, len, ForCES_BLN(fhdr)));
goto error;
}
- TCHECK2(*(pptr + 20), 4);
+ ND_TCHECK2(*(pptr + 20), 4);
flg_raw = EXTRACT_32BITS(pptr + 20);
- if (vflag >= 1) {
- printf("\n\tForCES Version %d len %uB flags 0x%08x ",
- ForCES_V(fhdr), mlen, flg_raw);
- printf("\n\tSrcID 0x%x(%s) DstID 0x%x(%s) Correlator 0x%" PRIx64,
+ if (ndo->ndo_vflag >= 1) {
+ ND_PRINT((ndo, "\n\tForCES Version %d len %uB flags 0x%08x ",
+ ForCES_V(fhdr), mlen, flg_raw));
+ ND_PRINT((ndo,
+ "\n\tSrcID 0x%x(%s) DstID 0x%x(%s) Correlator 0x%" PRIx64,
ForCES_SID(fhdr), ForCES_node(ForCES_SID(fhdr)),
ForCES_DID(fhdr), ForCES_node(ForCES_DID(fhdr)),
- EXTRACT_64BITS(fhdr->fm_cor));
+ EXTRACT_64BITS(fhdr->fm_cor)));
}
- if (vflag >= 2) {
- printf
- ("\n\tForCES flags:\n\t %s(0x%x), prio=%d, %s(0x%x),\n\t %s(0x%x), %s(0x%x)\n",
- ForCES_ACKp(ForCES_ACK(fhdr)), ForCES_ACK(fhdr),
+ if (ndo->ndo_vflag >= 2) {
+ ND_PRINT((ndo,
+ "\n\tForCES flags:\n\t %s(0x%x), prio=%d, %s(0x%x),\n\t %s(0x%x), %s(0x%x)\n",
+ tok2str(ForCES_ACKs, "ACKUnknown", ForCES_ACK(fhdr)),
+ ForCES_ACK(fhdr),
ForCES_PRI(fhdr),
- ForCES_EMp(ForCES_EM(fhdr)), ForCES_EM(fhdr),
- ForCES_ATp(ForCES_AT(fhdr)), ForCES_AT(fhdr),
- ForCES_TPp(ForCES_TP(fhdr)), ForCES_TP(fhdr));
- printf
- ("\t Extra flags: rsv(b5-7) 0x%x rsv(b13-31) 0x%x\n",
- ForCES_RS1(fhdr), ForCES_RS2(fhdr));
+ tok2str(ForCES_EMs, "EMUnknown", ForCES_EM(fhdr)),
+ ForCES_EM(fhdr),
+ tok2str(ForCES_ATs, "ATUnknown", ForCES_AT(fhdr)),
+ ForCES_AT(fhdr),
+ tok2str(ForCES_TPs, "TPUnknown", ForCES_TP(fhdr)),
+ ForCES_TP(fhdr)));
+ ND_PRINT((ndo,
+ "\t Extra flags: rsv(b5-7) 0x%x rsv(b13-31) 0x%x\n",
+ ForCES_RS1(fhdr), ForCES_RS2(fhdr)));
}
- rc = forces_type_print(pptr, fhdr, mlen, tops);
+ rc = forces_type_print(ndo, pptr, fhdr, mlen, tops);
if (rc < 0) {
error:
- hex_print_with_offset("\n\t[", pptr, len, 0);
- printf("\n\t]");
+ hex_print_with_offset(ndo, "\n\t[", pptr, len, 0);
+ ND_PRINT((ndo, "\n\t]"));
return;
}
- if (vflag >= 4) {
- printf("\n\t Raw ForCES message\n\t [");
- hex_print_with_offset("\n\t ", pptr, len, 0);
- printf("\n\t ]");
+ if (ndo->ndo_vflag >= 4) {
+ ND_PRINT((ndo, "\n\t Raw ForCES message\n\t ["));
+ hex_print_with_offset(ndo, "\n\t ", pptr, len, 0);
+ ND_PRINT((ndo, "\n\t ]"));
}
- printf("\n");
+ ND_PRINT((ndo, "\n"));
return;
trunc:
- fputs("[|forces]", stdout);
+ ND_PRINT((ndo, "%s", tstr));
}
+/*
+ * Local Variables:
+ * c-style: whitesmith
+ * c-basic-offset: 8
+ * End:
+ */
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-forces-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-fr.c b/freebsd/contrib/tcpdump/print-fr.c
index 73e056d4..7abdd9ee 100644
--- a/freebsd/contrib/tcpdump/print-fr.c
+++ b/freebsd/contrib/tcpdump/print-fr.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996
* The Regents of the University of California. All rights reserved.
@@ -19,33 +22,28 @@
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * $FreeBSD$
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#)$Header: /tcpdump/master/tcpdump/print-fr.c,v 1.51 2006-06-23 22:20:32 hannes Exp $ (LBL)";
-#endif
+/* \summary: Frame Relay printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <stdio.h>
#include <string.h>
-#include <pcap.h>
+#include "netdissect.h"
#include "addrtoname.h"
-#include "interface.h"
#include "ethertype.h"
+#include "llc.h"
#include "nlpid.h"
#include "extract.h"
#include "oui.h"
-static void frf15_print(const u_char *, u_int);
+static void frf15_print(netdissect_options *ndo, const u_char *, u_int);
/*
* the frame relay header has a variable length
@@ -77,7 +75,7 @@ static void frf15_print(const u_char *, u_int);
#define FR_SDLC_BIT 0x00000002
-struct tok fr_header_flag_values[] = {
+static const struct tok fr_header_flag_values[] = {
{ FR_CR_BIT, "C!" },
{ FR_DE_BIT, "DE" },
{ FR_BECN_BIT, "BECN" },
@@ -94,22 +92,28 @@ struct tok fr_header_flag_values[] = {
#define MFR_CTRL_FRAME (MFR_B_BIT | MFR_E_BIT | MFR_C_BIT)
#define MFR_FRAG_FRAME (MFR_B_BIT | MFR_E_BIT )
-struct tok frf_flag_values[] = {
+static const struct tok frf_flag_values[] = {
{ MFR_B_BIT, "Begin" },
{ MFR_E_BIT, "End" },
{ MFR_C_BIT, "Control" },
{ 0, NULL }
};
-/* Finds out Q.922 address length, DLCI and flags. Returns 0 on success
+/* Finds out Q.922 address length, DLCI and flags. Returns 1 on success,
+ * 0 on invalid address, -1 on truncated packet
* save the flags dep. on address length
*/
-static int parse_q922_addr(const u_char *p, u_int *dlci,
- u_int *addr_len, u_int8_t *flags)
+static int parse_q922_addr(netdissect_options *ndo,
+ const u_char *p, u_int *dlci,
+ u_int *addr_len, uint8_t *flags, u_int length)
{
- if ((p[0] & FR_EA_BIT))
+ if (!ND_TTEST(p[0]) || length < 1)
return -1;
+ if ((p[0] & FR_EA_BIT))
+ return 0;
+ if (!ND_TTEST(p[1]) || length < 2)
+ return -1;
*addr_len = 2;
*dlci = ((p[0] & 0xFC) << 2) | ((p[1] & 0xF0) >> 4);
@@ -119,34 +123,42 @@ static int parse_q922_addr(const u_char *p, u_int *dlci,
flags[3] = 0;
if (p[1] & FR_EA_BIT)
- return 0; /* 2-byte Q.922 address */
+ return 1; /* 2-byte Q.922 address */
p += 2;
+ length -= 2;
+ if (!ND_TTEST(p[0]) || length < 1)
+ return -1;
(*addr_len)++; /* 3- or 4-byte Q.922 address */
if ((p[0] & FR_EA_BIT) == 0) {
*dlci = (*dlci << 7) | (p[0] >> 1);
(*addr_len)++; /* 4-byte Q.922 address */
p++;
+ length--;
}
+ if (!ND_TTEST(p[0]) || length < 1)
+ return -1;
if ((p[0] & FR_EA_BIT) == 0)
- return -1; /* more than 4 bytes of Q.922 address? */
+ return 0; /* more than 4 bytes of Q.922 address? */
flags[3] = p[0] & 0x02;
*dlci = (*dlci << 6) | (p[0] >> 2);
- return 0;
+ return 1;
}
-char *q922_string(const u_char *p) {
+char *
+q922_string(netdissect_options *ndo, const u_char *p, u_int length)
+{
static u_int dlci, addr_len;
- static u_int8_t flags[4];
+ static uint8_t flags[4];
static char buffer[sizeof("DLCI xxxxxxxxxx")];
memset(buffer, 0, sizeof(buffer));
- if (parse_q922_addr(p, &dlci, &addr_len, flags) == 0){
+ if (parse_q922_addr(ndo, p, &dlci, &addr_len, flags, length) == 1){
snprintf(buffer, sizeof(buffer), "DLCI %u", dlci);
}
@@ -180,178 +192,205 @@ char *q922_string(const u_char *p) {
may optionally be increased to three or four octets.
*/
-static u_int
-fr_hdrlen(const u_char *p, u_int addr_len)
-{
- if (!p[addr_len + 1] /* pad exist */)
- return addr_len + 1 /* UI */ + 1 /* pad */ + 1 /* NLPID */;
- else
- return addr_len + 1 /* UI */ + 1 /* NLPID */;
-}
-
static void
-fr_hdr_print(int length, u_int addr_len, u_int dlci, u_int8_t *flags, u_int16_t nlpid)
+fr_hdr_print(netdissect_options *ndo,
+ int length, u_int addr_len, u_int dlci, uint8_t *flags, uint16_t nlpid)
{
- if (qflag) {
- (void)printf("Q.922, DLCI %u, length %u: ",
+ if (ndo->ndo_qflag) {
+ ND_PRINT((ndo, "Q.922, DLCI %u, length %u: ",
dlci,
- length);
+ length));
} else {
if (nlpid <= 0xff) /* if its smaller than 256 then its a NLPID */
- (void)printf("Q.922, hdr-len %u, DLCI %u, Flags [%s], NLPID %s (0x%02x), length %u: ",
+ ND_PRINT((ndo, "Q.922, hdr-len %u, DLCI %u, Flags [%s], NLPID %s (0x%02x), length %u: ",
addr_len,
dlci,
bittok2str(fr_header_flag_values, "none", EXTRACT_32BITS(flags)),
tok2str(nlpid_values,"unknown", nlpid),
nlpid,
- length);
+ length));
else /* must be an ethertype */
- (void)printf("Q.922, hdr-len %u, DLCI %u, Flags [%s], cisco-ethertype %s (0x%04x), length %u: ",
+ ND_PRINT((ndo, "Q.922, hdr-len %u, DLCI %u, Flags [%s], cisco-ethertype %s (0x%04x), length %u: ",
addr_len,
dlci,
bittok2str(fr_header_flag_values, "none", EXTRACT_32BITS(flags)),
tok2str(ethertype_values, "unknown", nlpid),
nlpid,
- length);
+ length));
}
}
u_int
-fr_if_print(const struct pcap_pkthdr *h, register const u_char *p)
+fr_if_print(netdissect_options *ndo,
+ const struct pcap_pkthdr *h, register const u_char *p)
{
register u_int length = h->len;
register u_int caplen = h->caplen;
- TCHECK2(*p, 4); /* minimum frame header length */
+ ND_TCHECK2(*p, 4); /* minimum frame header length */
- if ((length = fr_print(p, length)) == 0)
+ if ((length = fr_print(ndo, p, length)) == 0)
return (0);
else
return length;
trunc:
- printf("[|fr]");
+ ND_PRINT((ndo, "[|fr]"));
return caplen;
}
u_int
-fr_print(register const u_char *p, u_int length)
+fr_print(netdissect_options *ndo,
+ register const u_char *p, u_int length)
{
- u_int16_t extracted_ethertype;
+ int ret;
+ uint16_t extracted_ethertype;
u_int dlci;
u_int addr_len;
- u_int16_t nlpid;
+ uint16_t nlpid;
u_int hdr_len;
- u_int8_t flags[4];
+ uint8_t flags[4];
- if (parse_q922_addr(p, &dlci, &addr_len, flags)) {
- printf("Q.922, invalid address");
+ ret = parse_q922_addr(ndo, p, &dlci, &addr_len, flags, length);
+ if (ret == -1)
+ goto trunc;
+ if (ret == 0) {
+ ND_PRINT((ndo, "Q.922, invalid address"));
return 0;
}
- TCHECK2(*p,addr_len+1+1);
- hdr_len = fr_hdrlen(p, addr_len);
- TCHECK2(*p,hdr_len);
-
- if (p[addr_len] != 0x03 && dlci != 0) {
-
- /* lets figure out if we have cisco style encapsulation: */
- extracted_ethertype = EXTRACT_16BITS(p+addr_len);
+ ND_TCHECK(p[addr_len]);
+ if (length < addr_len + 1)
+ goto trunc;
- if (eflag)
- fr_hdr_print(length, addr_len, dlci, flags, extracted_ethertype);
-
- if (ethertype_print(gndo, extracted_ethertype,
- p+addr_len+ETHERTYPE_LEN,
- length-addr_len-ETHERTYPE_LEN,
- length-addr_len-ETHERTYPE_LEN) == 0)
- /* ether_type not known, probably it wasn't one */
- printf("UI %02x! ", p[addr_len]);
- else
- return hdr_len;
+ if (p[addr_len] != LLC_UI && dlci != 0) {
+ /*
+ * Let's figure out if we have Cisco-style encapsulation,
+ * with an Ethernet type (Cisco HDLC type?) following the
+ * address.
+ */
+ if (!ND_TTEST2(p[addr_len], 2) || length < addr_len + 2) {
+ /* no Ethertype */
+ ND_PRINT((ndo, "UI %02x! ", p[addr_len]));
+ } else {
+ extracted_ethertype = EXTRACT_16BITS(p+addr_len);
+
+ if (ndo->ndo_eflag)
+ fr_hdr_print(ndo, length, addr_len, dlci,
+ flags, extracted_ethertype);
+
+ if (ethertype_print(ndo, extracted_ethertype,
+ p+addr_len+ETHERTYPE_LEN,
+ length-addr_len-ETHERTYPE_LEN,
+ ndo->ndo_snapend-p-addr_len-ETHERTYPE_LEN,
+ NULL, NULL) == 0)
+ /* ether_type not known, probably it wasn't one */
+ ND_PRINT((ndo, "UI %02x! ", p[addr_len]));
+ else
+ return addr_len + 2;
+ }
}
- if (!p[addr_len + 1]) { /* pad byte should be used with 3-byte Q.922 */
+ ND_TCHECK(p[addr_len+1]);
+ if (length < addr_len + 2)
+ goto trunc;
+
+ if (p[addr_len + 1] == 0) {
+ /*
+ * Assume a pad byte after the control (UI) byte.
+ * A pad byte should only be used with 3-byte Q.922.
+ */
if (addr_len != 3)
- printf("Pad! ");
- } else if (addr_len == 3)
- printf("No pad! ");
+ ND_PRINT((ndo, "Pad! "));
+ hdr_len = addr_len + 1 /* UI */ + 1 /* pad */ + 1 /* NLPID */;
+ } else {
+ /*
+ * Not a pad byte.
+ * A pad byte should be used with 3-byte Q.922.
+ */
+ if (addr_len == 3)
+ ND_PRINT((ndo, "No pad! "));
+ hdr_len = addr_len + 1 /* UI */ + 1 /* NLPID */;
+ }
+ ND_TCHECK(p[hdr_len - 1]);
+ if (length < hdr_len)
+ goto trunc;
nlpid = p[hdr_len - 1];
- if (eflag)
- fr_hdr_print(length, addr_len, dlci, flags, nlpid);
+ if (ndo->ndo_eflag)
+ fr_hdr_print(ndo, length, addr_len, dlci, flags, nlpid);
p += hdr_len;
length -= hdr_len;
switch (nlpid) {
case NLPID_IP:
- ip_print(gndo, p, length);
+ ip_print(ndo, p, length);
break;
-#ifdef INET6
case NLPID_IP6:
- ip6_print(gndo, p, length);
+ ip6_print(ndo, p, length);
break;
-#endif
+
case NLPID_CLNP:
case NLPID_ESIS:
case NLPID_ISIS:
- isoclns_print(p-1, length+1, length+1); /* OSI printers need the NLPID field */
+ isoclns_print(ndo, p - 1, length + 1, ndo->ndo_snapend - p + 1); /* OSI printers need the NLPID field */
break;
case NLPID_SNAP:
- if (snap_print(p, length, length, 0) == 0) {
+ if (snap_print(ndo, p, length, ndo->ndo_snapend - p, NULL, NULL, 0) == 0) {
/* ether_type not known, print raw packet */
- if (!eflag)
- fr_hdr_print(length + hdr_len, hdr_len,
+ if (!ndo->ndo_eflag)
+ fr_hdr_print(ndo, length + hdr_len, hdr_len,
dlci, flags, nlpid);
- if (!suppress_default_print)
- default_print(p - hdr_len, length + hdr_len);
+ if (!ndo->ndo_suppress_default_print)
+ ND_DEFAULTPRINT(p - hdr_len, length + hdr_len);
}
break;
case NLPID_Q933:
- q933_print(p, length);
+ q933_print(ndo, p, length);
break;
case NLPID_MFR:
- frf15_print(p, length);
+ frf15_print(ndo, p, length);
break;
case NLPID_PPP:
- ppp_print(p, length);
+ ppp_print(ndo, p, length);
break;
default:
- if (!eflag)
- fr_hdr_print(length + hdr_len, addr_len,
+ if (!ndo->ndo_eflag)
+ fr_hdr_print(ndo, length + hdr_len, addr_len,
dlci, flags, nlpid);
- if (!xflag)
- default_print(p, length);
+ if (!ndo->ndo_xflag)
+ ND_DEFAULTPRINT(p, length);
}
return hdr_len;
trunc:
- printf("[|fr]");
+ ND_PRINT((ndo, "[|fr]"));
return 0;
}
u_int
-mfr_if_print(const struct pcap_pkthdr *h, register const u_char *p)
+mfr_if_print(netdissect_options *ndo,
+ const struct pcap_pkthdr *h, register const u_char *p)
{
register u_int length = h->len;
register u_int caplen = h->caplen;
- TCHECK2(*p, 2); /* minimum frame header length */
+ ND_TCHECK2(*p, 2); /* minimum frame header length */
- if ((length = mfr_print(p, length)) == 0)
+ if ((length = mfr_print(ndo, p, length)) == 0)
return (0);
else
return length;
trunc:
- printf("[|mfr]");
+ ND_PRINT((ndo, "[|mfr]"));
return caplen;
}
@@ -364,7 +403,7 @@ mfr_if_print(const struct pcap_pkthdr *h, register const u_char *p)
#define MFR_CTRL_MSG_REMOVE_LINK 6
#define MFR_CTRL_MSG_REMOVE_LINK_ACK 7
-struct tok mfr_ctrl_msg_values[] = {
+static const struct tok mfr_ctrl_msg_values[] = {
{ MFR_CTRL_MSG_ADD_LINK, "Add Link" },
{ MFR_CTRL_MSG_ADD_LINK_ACK, "Add Link ACK" },
{ MFR_CTRL_MSG_ADD_LINK_REJ, "Add Link Reject" },
@@ -382,7 +421,7 @@ struct tok mfr_ctrl_msg_values[] = {
#define MFR_CTRL_IE_VENDOR_EXT 6
#define MFR_CTRL_IE_CAUSE 7
-struct tok mfr_ctrl_ie_values[] = {
+static const struct tok mfr_ctrl_ie_values[] = {
{ MFR_CTRL_IE_BUNDLE_ID, "Bundle ID"},
{ MFR_CTRL_IE_LINK_ID, "Link ID"},
{ MFR_CTRL_IE_MAGIC_NUM, "Magic Number"},
@@ -395,22 +434,23 @@ struct tok mfr_ctrl_ie_values[] = {
#define MFR_ID_STRING_MAXLEN 50
struct ie_tlv_header_t {
- u_int8_t ie_type;
- u_int8_t ie_len;
+ uint8_t ie_type;
+ uint8_t ie_len;
};
u_int
-mfr_print(register const u_char *p, u_int length)
+mfr_print(netdissect_options *ndo,
+ register const u_char *p, u_int length)
{
u_int tlen,idx,hdr_len = 0;
- u_int16_t sequence_num;
- u_int8_t ie_type,ie_len;
- const u_int8_t *tptr;
+ uint16_t sequence_num;
+ uint8_t ie_type,ie_len;
+ const uint8_t *tptr;
/*
* FRF.16 Link Integrity Control Frame
- *
+ *
* 7 6 5 4 3 2 1 0
* +----+----+----+----+----+----+----+----+
* | B | E | C=1| 0 0 0 0 | EA |
@@ -421,35 +461,35 @@ mfr_print(register const u_char *p, u_int length)
* +----+----+----+----+----+----+----+----+
*/
- TCHECK2(*p, 4); /* minimum frame header length */
+ ND_TCHECK2(*p, 4); /* minimum frame header length */
if ((p[0] & MFR_BEC_MASK) == MFR_CTRL_FRAME && p[1] == 0) {
- printf("FRF.16 Control, Flags [%s], %s, length %u",
+ ND_PRINT((ndo, "FRF.16 Control, Flags [%s], %s, length %u",
bittok2str(frf_flag_values,"none",(p[0] & MFR_BEC_MASK)),
tok2str(mfr_ctrl_msg_values,"Unknown Message (0x%02x)",p[2]),
- length);
+ length));
tptr = p + 3;
tlen = length -3;
hdr_len = 3;
- if (!vflag)
+ if (!ndo->ndo_vflag)
return hdr_len;
while (tlen>sizeof(struct ie_tlv_header_t)) {
- TCHECK2(*tptr, sizeof(struct ie_tlv_header_t));
+ ND_TCHECK2(*tptr, sizeof(struct ie_tlv_header_t));
ie_type=tptr[0];
ie_len=tptr[1];
- printf("\n\tIE %s (%u), length %u: ",
+ ND_PRINT((ndo, "\n\tIE %s (%u), length %u: ",
tok2str(mfr_ctrl_ie_values,"Unknown",ie_type),
ie_type,
- ie_len);
+ ie_len));
/* infinite loop check */
if (ie_type == 0 || ie_len <= sizeof(struct ie_tlv_header_t))
return hdr_len;
- TCHECK2(*tptr,ie_len);
+ ND_TCHECK2(*tptr, ie_len);
tptr+=sizeof(struct ie_tlv_header_t);
/* tlv len includes header */
ie_len-=sizeof(struct ie_tlv_header_t);
@@ -458,14 +498,14 @@ mfr_print(register const u_char *p, u_int length)
switch (ie_type) {
case MFR_CTRL_IE_MAGIC_NUM:
- printf("0x%08x",EXTRACT_32BITS(tptr));
+ ND_PRINT((ndo, "0x%08x", EXTRACT_32BITS(tptr)));
break;
case MFR_CTRL_IE_BUNDLE_ID: /* same message format */
case MFR_CTRL_IE_LINK_ID:
for (idx = 0; idx < ie_len && idx < MFR_ID_STRING_MAXLEN; idx++) {
if (*(tptr+idx) != 0) /* don't print null termination */
- safeputchar(*(tptr+idx));
+ safeputchar(ndo, *(tptr + idx));
else
break;
}
@@ -473,7 +513,7 @@ mfr_print(register const u_char *p, u_int length)
case MFR_CTRL_IE_TIMESTAMP:
if (ie_len == sizeof(struct timeval)) {
- ts_print((const struct timeval *)tptr);
+ ts_print(ndo, (const struct timeval *)tptr);
break;
}
/* fall through and hexdump if no unix timestamp */
@@ -487,15 +527,15 @@ mfr_print(register const u_char *p, u_int length)
case MFR_CTRL_IE_CAUSE:
default:
- if (vflag <= 1)
- print_unknown_data(tptr,"\n\t ",ie_len);
+ if (ndo->ndo_vflag <= 1)
+ print_unknown_data(ndo, tptr, "\n\t ", ie_len);
break;
}
/* do we want to see a hexdump of the IE ? */
- if (vflag > 1 )
- print_unknown_data(tptr,"\n\t ",ie_len);
-
+ if (ndo->ndo_vflag > 1 )
+ print_unknown_data(ndo, tptr, "\n\t ", ie_len);
+
tlen-=ie_len;
tptr+=ie_len;
}
@@ -503,7 +543,7 @@ mfr_print(register const u_char *p, u_int length)
}
/*
* FRF.16 Fragmentation Frame
- *
+ *
* 7 6 5 4 3 2 1 0
* +----+----+----+----+----+----+----+----+
* | B | E | C=0|seq. (high 4 bits) | EA |
@@ -520,30 +560,30 @@ mfr_print(register const u_char *p, u_int length)
/* whole packet or first fragment ? */
if ((p[0] & MFR_BEC_MASK) == MFR_FRAG_FRAME ||
(p[0] & MFR_BEC_MASK) == MFR_B_BIT) {
- printf("FRF.16 Frag, seq %u, Flags [%s], ",
+ ND_PRINT((ndo, "FRF.16 Frag, seq %u, Flags [%s], ",
sequence_num,
- bittok2str(frf_flag_values,"none",(p[0] & MFR_BEC_MASK)));
+ bittok2str(frf_flag_values,"none",(p[0] & MFR_BEC_MASK))));
hdr_len = 2;
- fr_print(p+hdr_len,length-hdr_len);
+ fr_print(ndo, p+hdr_len,length-hdr_len);
return hdr_len;
}
/* must be a middle or the last fragment */
- printf("FRF.16 Frag, seq %u, Flags [%s]",
+ ND_PRINT((ndo, "FRF.16 Frag, seq %u, Flags [%s]",
sequence_num,
- bittok2str(frf_flag_values,"none",(p[0] & MFR_BEC_MASK)));
- print_unknown_data(p,"\n\t",length);
+ bittok2str(frf_flag_values,"none",(p[0] & MFR_BEC_MASK))));
+ print_unknown_data(ndo, p, "\n\t", length);
return hdr_len;
trunc:
- printf("[|mfr]");
+ ND_PRINT((ndo, "[|mfr]"));
return length;
}
/* an NLPID of 0xb1 indicates a 2-byte
* FRF.15 header
- *
+ *
* 7 6 5 4 3 2 1 0
* +----+----+----+----+----+----+----+----+
* ~ Q.922 header ~
@@ -559,18 +599,23 @@ mfr_print(register const u_char *p, u_int length)
#define FR_FRF15_FRAGTYPE 0x01
static void
-frf15_print (const u_char *p, u_int length) {
-
- u_int16_t sequence_num, flags;
+frf15_print(netdissect_options *ndo,
+ const u_char *p, u_int length)
+{
+ uint16_t sequence_num, flags;
+
+ if (length < 2)
+ goto trunc;
+ ND_TCHECK2(*p, 2);
flags = p[0]&MFR_BEC_MASK;
sequence_num = (p[0]&0x1e)<<7 | p[1];
- printf("FRF.15, seq 0x%03x, Flags [%s],%s Fragmentation, length %u",
+ ND_PRINT((ndo, "FRF.15, seq 0x%03x, Flags [%s],%s Fragmentation, length %u",
sequence_num,
bittok2str(frf_flag_values,"none",flags),
p[0]&FR_FRF15_FRAGTYPE ? "Interface" : "End-to-End",
- length);
+ length));
/* TODO:
* depending on all permutations of the B, E and C bit
@@ -580,7 +625,10 @@ frf15_print (const u_char *p, u_int length) {
* model is end-to-end or interface based wether we want to print
* another Q.922 header
*/
+ return;
+trunc:
+ ND_PRINT((ndo, "[|frf.15]"));
}
/*
@@ -588,13 +636,13 @@ frf15_print (const u_char *p, u_int length) {
*/
/* Q.933 packet format
- Format of Other Protocols
+ Format of Other Protocols
using Q.933 NLPID
- +-------------------------------+
- | Q.922 Address |
+ +-------------------------------+
+ | Q.922 Address |
+ +---------------+---------------+
+ |Control 0x03 | NLPID 0x08 |
+---------------+---------------+
- |Control 0x03 | NLPID 0x08 |
- +---------------+---------------+
| L2 Protocol ID |
| octet 1 | octet 2 |
+-------------------------------+
@@ -630,7 +678,7 @@ frf15_print (const u_char *p, u_int length) {
#define MSG_TYPE_STATUS 0x7D
#define MSG_TYPE_STATUS_ENQ 0x75
-struct tok fr_q933_msg_values[] = {
+static const struct tok fr_q933_msg_values[] = {
{ MSG_TYPE_ESC_TO_NATIONAL, "ESC to National" },
{ MSG_TYPE_ALERT, "Alert" },
{ MSG_TYPE_CALL_PROCEEDING, "Call proceeding" },
@@ -648,7 +696,11 @@ struct tok fr_q933_msg_values[] = {
{ 0, NULL }
};
-#define MSG_ANSI_LOCKING_SHIFT 0x95
+#define IE_IS_SINGLE_OCTET(iecode) ((iecode) & 0x80)
+#define IE_IS_SHIFT(iecode) (((iecode) & 0xF0) == 0x90)
+#define IE_SHIFT_IS_NON_LOCKING(iecode) ((iecode) & 0x08)
+#define IE_SHIFT_IS_LOCKING(iecode) (!(IE_SHIFT_IS_NON_LOCKING(iecode)))
+#define IE_SHIFT_CODESET(iecode) ((iecode) & 0x07)
#define FR_LMI_ANSI_REPORT_TYPE_IE 0x01
#define FR_LMI_ANSI_LINK_VERIFY_IE_91 0x19 /* details? */
@@ -659,7 +711,7 @@ struct tok fr_q933_msg_values[] = {
#define FR_LMI_CCITT_LINK_VERIFY_IE 0x53
#define FR_LMI_CCITT_PVC_STATUS_IE 0x57
-struct tok fr_q933_ie_values_codeset5[] = {
+static const struct tok fr_q933_ie_values_codeset_0_5[] = {
{ FR_LMI_ANSI_REPORT_TYPE_IE, "ANSI Report Type" },
{ FR_LMI_ANSI_LINK_VERIFY_IE_91, "ANSI Link Verify" },
{ FR_LMI_ANSI_LINK_VERIFY_IE, "ANSI Link Verify" },
@@ -674,21 +726,21 @@ struct tok fr_q933_ie_values_codeset5[] = {
#define FR_LMI_REPORT_TYPE_IE_LINK_VERIFY 1
#define FR_LMI_REPORT_TYPE_IE_ASYNC_PVC 2
-struct tok fr_lmi_report_type_ie_values[] = {
+static const struct tok fr_lmi_report_type_ie_values[] = {
{ FR_LMI_REPORT_TYPE_IE_FULL_STATUS, "Full Status" },
{ FR_LMI_REPORT_TYPE_IE_LINK_VERIFY, "Link verify" },
{ FR_LMI_REPORT_TYPE_IE_ASYNC_PVC, "Async PVC Status" },
{ 0, NULL }
};
-/* array of 16 codepages - currently we only support codepage 1,5 */
-static struct tok *fr_q933_ie_codesets[] = {
+/* array of 16 codesets - currently we only support codepage 0 and 5 */
+static const struct tok *fr_q933_ie_codesets[] = {
+ fr_q933_ie_values_codeset_0_5,
NULL,
- fr_q933_ie_values_codeset5,
NULL,
NULL,
NULL,
- fr_q933_ie_values_codeset5,
+ fr_q933_ie_values_codeset_0_5,
NULL,
NULL,
NULL,
@@ -701,20 +753,20 @@ static struct tok *fr_q933_ie_codesets[] = {
NULL
};
-static int fr_q933_print_ie_codeset5(const struct ie_tlv_header_t *ie_p,
- const u_char *p);
+static int fr_q933_print_ie_codeset_0_5(netdissect_options *ndo, u_int iecode,
+ u_int ielength, const u_char *p);
-typedef int (*codeset_pr_func_t)(const struct ie_tlv_header_t *ie_p,
- const u_char *p);
+typedef int (*codeset_pr_func_t)(netdissect_options *, u_int iecode,
+ u_int ielength, const u_char *p);
-/* array of 16 codepages - currently we only support codepage 1,5 */
-static codeset_pr_func_t fr_q933_print_ie_codeset[] = {
+/* array of 16 codesets - currently we only support codepage 0 and 5 */
+static const codeset_pr_func_t fr_q933_print_ie_codeset[] = {
+ fr_q933_print_ie_codeset_0_5,
NULL,
- fr_q933_print_ie_codeset5,
NULL,
NULL,
NULL,
- fr_q933_print_ie_codeset5,
+ fr_q933_print_ie_codeset_0_5,
NULL,
NULL,
NULL,
@@ -727,161 +779,372 @@ static codeset_pr_func_t fr_q933_print_ie_codeset[] = {
NULL
};
+/*
+ * ITU-T Q.933.
+ *
+ * p points to octet 2, the octet containing the length of the
+ * call reference value, so p[n] is octet n+2 ("octet X" is as
+ * used in Q.931/Q.933).
+ *
+ * XXX - actually used both for Q.931 and Q.933.
+ */
void
-q933_print(const u_char *p, u_int length)
+q933_print(netdissect_options *ndo,
+ const u_char *p, u_int length)
{
- const u_char *ptemp = p;
- struct ie_tlv_header_t *ie_p;
- int olen;
- int is_ansi = 0;
- u_int codeset;
- u_int ie_is_known = 0;
-
- if (length < 9) { /* shortest: Q.933a LINK VERIFY */
- printf("[|q.933]");
- return;
+ u_int olen;
+ u_int call_ref_length, i;
+ uint8_t call_ref[15]; /* maximum length - length field is 4 bits */
+ u_int msgtype;
+ u_int iecode;
+ u_int ielength;
+ u_int codeset = 0;
+ u_int is_ansi = 0;
+ u_int ie_is_known;
+ u_int non_locking_shift;
+ u_int unshift_codeset;
+
+ ND_PRINT((ndo, "%s", ndo->ndo_eflag ? "" : "Q.933"));
+
+ if (length == 0 || !ND_TTEST(*p)) {
+ if (!ndo->ndo_eflag)
+ ND_PRINT((ndo, ", "));
+ ND_PRINT((ndo, "length %u", length));
+ goto trunc;
}
- codeset = p[2]&0x0f; /* extract the codeset */
+ /*
+ * Get the length of the call reference value.
+ */
+ olen = length; /* preserve the original length for display */
+ call_ref_length = (*p) & 0x0f;
+ p++;
+ length--;
+
+ /*
+ * Get the call reference value.
+ */
+ for (i = 0; i < call_ref_length; i++) {
+ if (length == 0 || !ND_TTEST(*p)) {
+ if (!ndo->ndo_eflag)
+ ND_PRINT((ndo, ", "));
+ ND_PRINT((ndo, "length %u", olen));
+ goto trunc;
+ }
+ call_ref[i] = *p;
+ p++;
+ length--;
+ }
- if (p[2] == MSG_ANSI_LOCKING_SHIFT) {
- is_ansi = 1;
+ /*
+ * Get the message type.
+ */
+ if (length == 0 || !ND_TTEST(*p)) {
+ if (!ndo->ndo_eflag)
+ ND_PRINT((ndo, ", "));
+ ND_PRINT((ndo, "length %u", olen));
+ goto trunc;
+ }
+ msgtype = *p;
+ p++;
+ length--;
+
+ /*
+ * Peek ahead to see if we start with a shift.
+ */
+ non_locking_shift = 0;
+ unshift_codeset = codeset;
+ if (length != 0) {
+ if (!ND_TTEST(*p)) {
+ if (!ndo->ndo_eflag)
+ ND_PRINT((ndo, ", "));
+ ND_PRINT((ndo, "length %u", olen));
+ goto trunc;
+ }
+ iecode = *p;
+ if (IE_IS_SHIFT(iecode)) {
+ /*
+ * It's a shift. Skip over it.
+ */
+ p++;
+ length--;
+
+ /*
+ * Get the codeset.
+ */
+ codeset = IE_SHIFT_CODESET(iecode);
+
+ /*
+ * If it's a locking shift to codeset 5,
+ * mark this as ANSI. (XXX - 5 is actually
+ * for national variants in general, not
+ * the US variant in particular, but maybe
+ * this is more American exceptionalism. :-))
+ */
+ if (IE_SHIFT_IS_LOCKING(iecode)) {
+ /*
+ * It's a locking shift.
+ */
+ if (codeset == 5) {
+ /*
+ * It's a locking shift to
+ * codeset 5, so this is
+ * T1.617 Annex D.
+ */
+ is_ansi = 1;
+ }
+ } else {
+ /*
+ * It's a non-locking shift.
+ * Remember the current codeset, so we
+ * can revert to it after the next IE.
+ */
+ non_locking_shift = 1;
+ unshift_codeset = 0;
+ }
+ }
}
-
- printf("%s", eflag ? "" : "Q.933, ");
/* printing out header part */
- printf("%s, codeset %u", is_ansi ? "ANSI" : "CCITT", codeset);
-
- if (p[0]) {
- printf(", Call Ref: 0x%02x", p[0]);
+ if (!ndo->ndo_eflag)
+ ND_PRINT((ndo, ", "));
+ ND_PRINT((ndo, "%s, codeset %u", is_ansi ? "ANSI" : "CCITT", codeset));
+
+ if (call_ref_length != 0) {
+ ND_TCHECK(p[0]);
+ if (call_ref_length > 1 || p[0] != 0) {
+ /*
+ * Not a dummy call reference.
+ */
+ ND_PRINT((ndo, ", Call Ref: 0x"));
+ for (i = 0; i < call_ref_length; i++)
+ ND_PRINT((ndo, "%02x", call_ref[i]));
+ }
}
- if (vflag) {
- printf(", %s (0x%02x), length %u",
- tok2str(fr_q933_msg_values,
- "unknown message", p[1]),
- p[1],
- length);
- } else {
- printf(", %s",
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo, ", %s (0x%02x), length %u",
+ tok2str(fr_q933_msg_values,
+ "unknown message", msgtype),
+ msgtype,
+ olen));
+ } else {
+ ND_PRINT((ndo, ", %s",
tok2str(fr_q933_msg_values,
- "unknown message 0x%02x", p[1]));
- }
-
- olen = length; /* preserve the original length for non verbose mode */
-
- if (length < (u_int)(2 - is_ansi)) {
- printf("[|q.933]");
- return;
+ "unknown message 0x%02x", msgtype)));
}
- length -= 2 + is_ansi;
- ptemp += 2 + is_ansi;
-
- /* Loop through the rest of IE */
- while (length > sizeof(struct ie_tlv_header_t)) {
- ie_p = (struct ie_tlv_header_t *)ptemp;
- if (length < sizeof(struct ie_tlv_header_t) ||
- length < sizeof(struct ie_tlv_header_t) + ie_p->ie_len) {
- if (vflag) { /* not bark if there is just a trailer */
- printf("\n[|q.933]");
- } else {
- printf(", length %u",olen);
- }
- return;
- }
-
- /* lets do the full IE parsing only in verbose mode
- * however some IEs (DLCI Status, Link Verify)
- * are also interestting in non-verbose mode */
- if (vflag) {
- printf("\n\t%s IE (0x%02x), length %u: ",
- tok2str(fr_q933_ie_codesets[codeset],
- "unknown", ie_p->ie_type),
- ie_p->ie_type,
- ie_p->ie_len);
- }
- /* sanity check */
- if (ie_p->ie_type == 0 || ie_p->ie_len == 0) {
- return;
+ /* Loop through the rest of the IEs */
+ while (length != 0) {
+ /*
+ * What's the state of any non-locking shifts?
+ */
+ if (non_locking_shift == 1) {
+ /*
+ * There's a non-locking shift in effect for
+ * this IE. Count it, so we reset the codeset
+ * before the next IE.
+ */
+ non_locking_shift = 2;
+ } else if (non_locking_shift == 2) {
+ /*
+ * Unshift.
+ */
+ codeset = unshift_codeset;
+ non_locking_shift = 0;
}
- if (fr_q933_print_ie_codeset[codeset] != NULL) {
- ie_is_known = fr_q933_print_ie_codeset[codeset](ie_p, ptemp);
- }
-
- if (vflag >= 1 && !ie_is_known) {
- print_unknown_data(ptemp+2,"\n\t",ie_p->ie_len);
+ /*
+ * Get the first octet of the IE.
+ */
+ if (!ND_TTEST(*p)) {
+ if (!ndo->ndo_vflag) {
+ ND_PRINT((ndo, ", length %u", olen));
+ }
+ goto trunc;
}
-
- /* do we want to see a hexdump of the IE ? */
- if (vflag> 1 && ie_is_known) {
- print_unknown_data(ptemp+2,"\n\t ",ie_p->ie_len);
+ iecode = *p;
+ p++;
+ length--;
+
+ /* Single-octet IE? */
+ if (IE_IS_SINGLE_OCTET(iecode)) {
+ /*
+ * Yes. Is it a shift?
+ */
+ if (IE_IS_SHIFT(iecode)) {
+ /*
+ * Yes. Is it locking?
+ */
+ if (IE_SHIFT_IS_LOCKING(iecode)) {
+ /*
+ * Yes.
+ */
+ non_locking_shift = 0;
+ } else {
+ /*
+ * No. Remember the current
+ * codeset, so we can revert
+ * to it after the next IE.
+ */
+ non_locking_shift = 1;
+ unshift_codeset = codeset;
+ }
+
+ /*
+ * Get the codeset.
+ */
+ codeset = IE_SHIFT_CODESET(iecode);
+ }
+ } else {
+ /*
+ * No. Get the IE length.
+ */
+ if (length == 0 || !ND_TTEST(*p)) {
+ if (!ndo->ndo_vflag) {
+ ND_PRINT((ndo, ", length %u", olen));
+ }
+ goto trunc;
+ }
+ ielength = *p;
+ p++;
+ length--;
+
+ /* lets do the full IE parsing only in verbose mode
+ * however some IEs (DLCI Status, Link Verify)
+ * are also interesting in non-verbose mode */
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo, "\n\t%s IE (0x%02x), length %u: ",
+ tok2str(fr_q933_ie_codesets[codeset],
+ "unknown", iecode),
+ iecode,
+ ielength));
+ }
+
+ /* sanity checks */
+ if (iecode == 0 || ielength == 0) {
+ return;
+ }
+ if (length < ielength || !ND_TTEST2(*p, ielength)) {
+ if (!ndo->ndo_vflag) {
+ ND_PRINT((ndo, ", length %u", olen));
+ }
+ goto trunc;
+ }
+
+ ie_is_known = 0;
+ if (fr_q933_print_ie_codeset[codeset] != NULL) {
+ ie_is_known = fr_q933_print_ie_codeset[codeset](ndo, iecode, ielength, p);
+ }
+
+ if (ie_is_known) {
+ /*
+ * Known IE; do we want to see a hexdump
+ * of it?
+ */
+ if (ndo->ndo_vflag > 1) {
+ /* Yes. */
+ print_unknown_data(ndo, p, "\n\t ", ielength);
+ }
+ } else {
+ /*
+ * Unknown IE; if we're printing verbosely,
+ * print its content in hex.
+ */
+ if (ndo->ndo_vflag >= 1) {
+ print_unknown_data(ndo, p, "\n\t", ielength);
+ }
+ }
+
+ length -= ielength;
+ p += ielength;
}
-
- length = length - ie_p->ie_len - 2;
- ptemp = ptemp + ie_p->ie_len + 2;
}
- if (!vflag) {
- printf(", length %u",olen);
+ if (!ndo->ndo_vflag) {
+ ND_PRINT((ndo, ", length %u", olen));
}
+ return;
+
+trunc:
+ ND_PRINT((ndo, "[|q.933]"));
}
static int
-fr_q933_print_ie_codeset5(const struct ie_tlv_header_t *ie_p, const u_char *p)
+fr_q933_print_ie_codeset_0_5(netdissect_options *ndo, u_int iecode,
+ u_int ielength, const u_char *p)
{
u_int dlci;
- switch (ie_p->ie_type) {
+ switch (iecode) {
case FR_LMI_ANSI_REPORT_TYPE_IE: /* fall through */
case FR_LMI_CCITT_REPORT_TYPE_IE:
- if (vflag) {
- printf("%s (%u)",
- tok2str(fr_lmi_report_type_ie_values,"unknown",p[2]),
- p[2]);
+ if (ielength < 1) {
+ if (!ndo->ndo_vflag) {
+ ND_PRINT((ndo, ", "));
+ }
+ ND_PRINT((ndo, "Invalid REPORT TYPE IE"));
+ return 1;
+ }
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo, "%s (%u)",
+ tok2str(fr_lmi_report_type_ie_values,"unknown",p[0]),
+ p[0]));
}
return 1;
case FR_LMI_ANSI_LINK_VERIFY_IE: /* fall through */
case FR_LMI_CCITT_LINK_VERIFY_IE:
case FR_LMI_ANSI_LINK_VERIFY_IE_91:
- if (!vflag) {
- printf(", ");
+ if (!ndo->ndo_vflag) {
+ ND_PRINT((ndo, ", "));
}
- printf("TX Seq: %3d, RX Seq: %3d", p[2], p[3]);
+ if (ielength < 2) {
+ ND_PRINT((ndo, "Invalid LINK VERIFY IE"));
+ return 1;
+ }
+ ND_PRINT((ndo, "TX Seq: %3d, RX Seq: %3d", p[0], p[1]));
return 1;
case FR_LMI_ANSI_PVC_STATUS_IE: /* fall through */
case FR_LMI_CCITT_PVC_STATUS_IE:
- if (!vflag) {
- printf(", ");
+ if (!ndo->ndo_vflag) {
+ ND_PRINT((ndo, ", "));
}
- /* now parse the DLCI information element. */
- if ((ie_p->ie_len < 3) ||
- (p[2] & 0x80) ||
- ((ie_p->ie_len == 3) && !(p[3] & 0x80)) ||
- ((ie_p->ie_len == 4) && ((p[3] & 0x80) || !(p[4] & 0x80))) ||
- ((ie_p->ie_len == 5) && ((p[3] & 0x80) || (p[4] & 0x80) ||
- !(p[5] & 0x80))) ||
- (ie_p->ie_len > 5) ||
- !(p[ie_p->ie_len + 1] & 0x80)) {
- printf("Invalid DLCI IE");
+ /* now parse the DLCI information element. */
+ if ((ielength < 3) ||
+ (p[0] & 0x80) ||
+ ((ielength == 3) && !(p[1] & 0x80)) ||
+ ((ielength == 4) && ((p[1] & 0x80) || !(p[2] & 0x80))) ||
+ ((ielength == 5) && ((p[1] & 0x80) || (p[2] & 0x80) ||
+ !(p[3] & 0x80))) ||
+ (ielength > 5) ||
+ !(p[ielength - 1] & 0x80)) {
+ ND_PRINT((ndo, "Invalid DLCI in PVC STATUS IE"));
+ return 1;
}
-
- dlci = ((p[2] & 0x3F) << 4) | ((p[3] & 0x78) >> 3);
- if (ie_p->ie_len == 4) {
- dlci = (dlci << 6) | ((p[4] & 0x7E) >> 1);
+
+ dlci = ((p[0] & 0x3F) << 4) | ((p[1] & 0x78) >> 3);
+ if (ielength == 4) {
+ dlci = (dlci << 6) | ((p[2] & 0x7E) >> 1);
}
- else if (ie_p->ie_len == 5) {
- dlci = (dlci << 13) | (p[4] & 0x7F) | ((p[5] & 0x7E) >> 1);
+ else if (ielength == 5) {
+ dlci = (dlci << 13) | (p[2] & 0x7F) | ((p[3] & 0x7E) >> 1);
}
- printf("DLCI %u: status %s%s", dlci,
- p[ie_p->ie_len + 1] & 0x8 ? "New, " : "",
- p[ie_p->ie_len + 1] & 0x2 ? "Active" : "Inactive");
+ ND_PRINT((ndo, "DLCI %u: status %s%s", dlci,
+ p[ielength - 1] & 0x8 ? "New, " : "",
+ p[ielength - 1] & 0x2 ? "Active" : "Inactive"));
return 1;
}
return 0;
}
+/*
+ * Local Variables:
+ * c-style: whitesmith
+ * c-basic-offset: 8
+ * End:
+ */
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-fr-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-frag6.c b/freebsd/contrib/tcpdump/print-frag6.c
index 5401de13..7e24e9c4 100644
--- a/freebsd/contrib/tcpdump/print-frag6.c
+++ b/freebsd/contrib/tcpdump/print-frag6.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1988, 1989, 1990, 1991, 1993, 1994
* The Regents of the University of California. All rights reserved.
@@ -21,29 +24,20 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-frag6.c,v 1.20 2005-04-20 22:33:06 guy Exp $";
-#endif
+/* \summary: IPv6 fragmentation header printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#ifdef INET6
-
-#include <tcpdump-stdinc.h>
-
-#include <stdio.h>
+#include <netdissect-stdinc.h>
#include "ip6.h"
-
-#include "interface.h"
-#include "addrtoname.h"
+#include "netdissect.h"
#include "extract.h"
int
-frag6_print(register const u_char *bp, register const u_char *bp2)
+frag6_print(netdissect_options *ndo, register const u_char *bp, register const u_char *bp2)
{
register const struct ip6_frag *dp;
register const struct ip6_hdr *ip6;
@@ -51,34 +45,33 @@ frag6_print(register const u_char *bp, register const u_char *bp2)
dp = (const struct ip6_frag *)bp;
ip6 = (const struct ip6_hdr *)bp2;
- TCHECK(dp->ip6f_offlg);
+ ND_TCHECK(dp->ip6f_offlg);
- if (vflag) {
- printf("frag (0x%08x:%d|%ld)",
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo, "frag (0x%08x:%d|%ld)",
EXTRACT_32BITS(&dp->ip6f_ident),
EXTRACT_16BITS(&dp->ip6f_offlg) & IP6F_OFF_MASK,
sizeof(struct ip6_hdr) + EXTRACT_16BITS(&ip6->ip6_plen) -
- (long)(bp - bp2) - sizeof(struct ip6_frag));
+ (long)(bp - bp2) - sizeof(struct ip6_frag)));
} else {
- printf("frag (%d|%ld)",
+ ND_PRINT((ndo, "frag (%d|%ld)",
EXTRACT_16BITS(&dp->ip6f_offlg) & IP6F_OFF_MASK,
sizeof(struct ip6_hdr) + EXTRACT_16BITS(&ip6->ip6_plen) -
- (long)(bp - bp2) - sizeof(struct ip6_frag));
+ (long)(bp - bp2) - sizeof(struct ip6_frag)));
}
-#if 1
/* it is meaningless to decode non-first fragment */
if ((EXTRACT_16BITS(&dp->ip6f_offlg) & IP6F_OFF_MASK) != 0)
return -1;
else
-#endif
{
- fputs(" ", stdout);
+ ND_PRINT((ndo, " "));
return sizeof(struct ip6_frag);
}
trunc:
- fputs("[|frag]", stdout);
+ ND_PRINT((ndo, "[|frag]"));
return -1;
-#undef TCHECK
}
-#endif /* INET6 */
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-frag6-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/bgp.h b/freebsd/contrib/tcpdump/print-ftp.c
index 50815960..31c22206 100644
--- a/freebsd/contrib/tcpdump/bgp.h
+++ b/freebsd/contrib/tcpdump/print-ftp.c
@@ -1,5 +1,9 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/bgp.h,v 1.3 2004-06-16 08:45:15 hannes Exp $ (LBL) */
-/*
+#include <machine/rtems-bsd-user-space.h>
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
+/*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code
* distributions retain the above copyright notice and this paragraph
@@ -10,8 +14,27 @@
* WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
* LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE.
- *
- * Original code by Hannes Gredler (hannes@juniper.net)
*/
-extern char *bgp_vpn_rd_print (const u_char *);
+/* \summary: File Transfer Protocol (FTP) printer */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <netdissect-stdinc.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "netdissect.h"
+#include "extract.h"
+
+void
+ftp_print(netdissect_options *ndo, const u_char *pptr, u_int len)
+{
+ txtproto_print(ndo, pptr, len, "ftp", NULL, 0);
+}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-ftp-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-geneve.c b/freebsd/contrib/tcpdump/print-geneve.c
new file mode 100644
index 00000000..16a27727
--- /dev/null
+++ b/freebsd/contrib/tcpdump/print-geneve.c
@@ -0,0 +1,245 @@
+#include <machine/rtems-bsd-user-space.h>
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
+/*
+ * Copyright (c) 2014 VMware, Inc. All Rights Reserved.
+ *
+ * Jesse Gross <jesse@nicira.com>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code
+ * distributions retain the above copyright notice and this paragraph
+ * in its entirety, and (2) distributions including binary code include
+ * the above copyright notice and this paragraph in its entirety in
+ * the documentation or other materials provided with the distribution.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND
+ * WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
+ * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE.
+ */
+
+/* \summary: Generic Network Virtualization Encapsulation (Geneve) printer */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <netdissect-stdinc.h>
+
+#include "netdissect.h"
+#include "extract.h"
+#include "ethertype.h"
+
+/*
+ * Geneve header, draft-ietf-nvo3-geneve
+ *
+ * 0 1 2 3
+ * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * |Ver| Opt Len |O|C| Rsvd. | Protocol Type |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Virtual Network Identifier (VNI) | Reserved |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Variable Length Options |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *
+ * Options:
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Option Class | Type |R|R|R| Length |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Variable Option Data |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+
+#define VER_SHIFT 6
+#define HDR_OPTS_LEN_MASK 0x3F
+
+#define FLAG_OAM (1 << 7)
+#define FLAG_CRITICAL (1 << 6)
+#define FLAG_R1 (1 << 5)
+#define FLAG_R2 (1 << 4)
+#define FLAG_R3 (1 << 3)
+#define FLAG_R4 (1 << 2)
+#define FLAG_R5 (1 << 1)
+#define FLAG_R6 (1 << 0)
+
+#define OPT_TYPE_CRITICAL (1 << 7)
+#define OPT_LEN_MASK 0x1F
+
+static const struct tok geneve_flag_values[] = {
+ { FLAG_OAM, "O" },
+ { FLAG_CRITICAL, "C" },
+ { FLAG_R1, "R1" },
+ { FLAG_R2, "R2" },
+ { FLAG_R3, "R3" },
+ { FLAG_R4, "R4" },
+ { FLAG_R5, "R5" },
+ { FLAG_R6, "R6" },
+ { 0, NULL }
+};
+
+static const char *
+format_opt_class(uint16_t opt_class)
+{
+ switch (opt_class) {
+ case 0x0100:
+ return "Linux";
+ case 0x0101:
+ return "Open vSwitch";
+ case 0x0102:
+ return "Open Virtual Networking (OVN)";
+ case 0x0103:
+ return "In-band Network Telemetry (INT)";
+ case 0x0104:
+ return "VMware";
+ default:
+ if (opt_class <= 0x00ff)
+ return "Standard";
+ else if (opt_class >= 0xfff0)
+ return "Experimental";
+ }
+
+ return "Unknown";
+}
+
+static void
+geneve_opts_print(netdissect_options *ndo, const u_char *bp, u_int len)
+{
+ const char *sep = "";
+
+ while (len > 0) {
+ uint16_t opt_class;
+ uint8_t opt_type;
+ uint8_t opt_len;
+
+ ND_PRINT((ndo, "%s", sep));
+ sep = ", ";
+
+ opt_class = EXTRACT_16BITS(bp);
+ opt_type = *(bp + 2);
+ opt_len = 4 + ((*(bp + 3) & OPT_LEN_MASK) * 4);
+
+ ND_PRINT((ndo, "class %s (0x%x) type 0x%x%s len %u",
+ format_opt_class(opt_class), opt_class, opt_type,
+ opt_type & OPT_TYPE_CRITICAL ? "(C)" : "", opt_len));
+
+ if (opt_len > len) {
+ ND_PRINT((ndo, " [bad length]"));
+ return;
+ }
+
+ if (ndo->ndo_vflag > 1 && opt_len > 4) {
+ const uint32_t *data = (const uint32_t *)(bp + 4);
+ int i;
+
+ ND_PRINT((ndo, " data"));
+
+ for (i = 4; i < opt_len; i += 4) {
+ ND_PRINT((ndo, " %08x", EXTRACT_32BITS(data)));
+ data++;
+ }
+ }
+
+ bp += opt_len;
+ len -= opt_len;
+ }
+}
+
+void
+geneve_print(netdissect_options *ndo, const u_char *bp, u_int len)
+{
+ uint8_t ver_opt;
+ u_int version;
+ uint8_t flags;
+ uint16_t prot;
+ uint32_t vni;
+ uint8_t reserved;
+ u_int opts_len;
+
+ ND_PRINT((ndo, "Geneve"));
+
+ ND_TCHECK2(*bp, 8);
+
+ ver_opt = *bp;
+ bp += 1;
+ len -= 1;
+
+ version = ver_opt >> VER_SHIFT;
+ if (version != 0) {
+ ND_PRINT((ndo, " ERROR: unknown-version %u", version));
+ return;
+ }
+
+ flags = *bp;
+ bp += 1;
+ len -= 1;
+
+ prot = EXTRACT_16BITS(bp);
+ bp += 2;
+ len -= 2;
+
+ vni = EXTRACT_24BITS(bp);
+ bp += 3;
+ len -= 3;
+
+ reserved = *bp;
+ bp += 1;
+ len -= 1;
+
+ ND_PRINT((ndo, ", Flags [%s]",
+ bittok2str_nosep(geneve_flag_values, "none", flags)));
+ ND_PRINT((ndo, ", vni 0x%x", vni));
+
+ if (reserved)
+ ND_PRINT((ndo, ", rsvd 0x%x", reserved));
+
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, ", proto %s (0x%04x)",
+ tok2str(ethertype_values, "unknown", prot), prot));
+
+ opts_len = (ver_opt & HDR_OPTS_LEN_MASK) * 4;
+
+ if (len < opts_len) {
+ ND_PRINT((ndo, " truncated-geneve - %u bytes missing",
+ opts_len - len));
+ return;
+ }
+
+ ND_TCHECK2(*bp, opts_len);
+
+ if (opts_len > 0) {
+ ND_PRINT((ndo, ", options ["));
+
+ if (ndo->ndo_vflag)
+ geneve_opts_print(ndo, bp, opts_len);
+ else
+ ND_PRINT((ndo, "%u bytes", opts_len));
+
+ ND_PRINT((ndo, "]"));
+ }
+
+ bp += opts_len;
+ len -= opts_len;
+
+ if (ndo->ndo_vflag < 1)
+ ND_PRINT((ndo, ": "));
+ else
+ ND_PRINT((ndo, "\n\t"));
+
+ if (ethertype_print(ndo, prot, bp, len, ndo->ndo_snapend - bp, NULL, NULL) == 0) {
+ if (prot == ETHERTYPE_TEB)
+ ether_print(ndo, bp, len, ndo->ndo_snapend - bp, NULL, NULL);
+ else
+ ND_PRINT((ndo, "geneve-proto-0x%x", prot));
+ }
+
+ return;
+
+trunc:
+ ND_PRINT((ndo, " [|geneve]"));
+}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-geneve-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-geonet.c b/freebsd/contrib/tcpdump/print-geonet.c
new file mode 100644
index 00000000..626d3e10
--- /dev/null
+++ b/freebsd/contrib/tcpdump/print-geonet.c
@@ -0,0 +1,294 @@
+#include <machine/rtems-bsd-user-space.h>
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
+/*
+ * Copyright (c) 2013 The TCPDUMP project
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code
+ * distributions retain the above copyright notice and this paragraph
+ * in its entirety, and (2) distributions including binary code include
+ * the above copyright notice and this paragraph in its entirety in
+ * the documentation or other materials provided with the distribution.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND
+ * WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
+ * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE.
+ *
+ * Original code by Ola Martin Lykkja (ola.lykkja@q-free.com)
+ */
+
+/* \summary: ISO CALM FAST and ETSI GeoNetworking printer */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <netdissect-stdinc.h>
+
+#include "netdissect.h"
+#include "extract.h"
+#include "addrtoname.h"
+
+
+/*
+ ETSI TS 102 636-5-1 V1.1.1 (2011-02)
+ Intelligent Transport Systems (ITS); Vehicular Communications; GeoNetworking;
+ Part 5: Transport Protocols; Sub-part 1: Basic Transport Protocol
+
+ ETSI TS 102 636-4-1 V1.1.1 (2011-06)
+ Intelligent Transport Systems (ITS); Vehicular communications; GeoNetworking;
+ Part 4: Geographical addressing and forwarding for point-to-point and point-to-multipoint communications;
+ Sub-part 1: Media-Independent Functionality
+*/
+
+#define GEONET_ADDR_LEN 8
+
+static const struct tok msg_type_values[] = {
+ { 0, "CAM" },
+ { 1, "DENM" },
+ { 101, "TPEGM" },
+ { 102, "TSPDM" },
+ { 103, "VPM" },
+ { 104, "SRM" },
+ { 105, "SLAM" },
+ { 106, "ecoCAM" },
+ { 107, "ITM" },
+ { 150, "SA" },
+ { 0, NULL }
+};
+
+static void
+print_btp_body(netdissect_options *ndo,
+ const u_char *bp)
+{
+ int version;
+ int msg_type;
+ const char *msg_type_str;
+
+ /* Assuming ItsDpuHeader */
+ version = bp[0];
+ msg_type = bp[1];
+ msg_type_str = tok2str(msg_type_values, "unknown (%u)", msg_type);
+
+ ND_PRINT((ndo, "; ItsPduHeader v:%d t:%d-%s", version, msg_type, msg_type_str));
+}
+
+static void
+print_btp(netdissect_options *ndo,
+ const u_char *bp)
+{
+ uint16_t dest = EXTRACT_16BITS(bp+0);
+ uint16_t src = EXTRACT_16BITS(bp+2);
+ ND_PRINT((ndo, "; BTP Dst:%u Src:%u", dest, src));
+}
+
+static int
+print_long_pos_vector(netdissect_options *ndo,
+ const u_char *bp)
+{
+ uint32_t lat, lon;
+
+ if (!ND_TTEST2(*bp, GEONET_ADDR_LEN))
+ return (-1);
+ ND_PRINT((ndo, "GN_ADDR:%s ", linkaddr_string (ndo, bp, 0, GEONET_ADDR_LEN)));
+
+ if (!ND_TTEST2(*(bp+12), 8))
+ return (-1);
+ lat = EXTRACT_32BITS(bp+12);
+ ND_PRINT((ndo, "lat:%d ", lat));
+ lon = EXTRACT_32BITS(bp+16);
+ ND_PRINT((ndo, "lon:%d", lon));
+ return (0);
+}
+
+
+/*
+ * This is the top level routine of the printer. 'p' points
+ * to the geonet header of the packet.
+ */
+void
+geonet_print(netdissect_options *ndo, const u_char *bp, u_int length,
+ const struct lladdr_info *src)
+{
+ int version;
+ int next_hdr;
+ int hdr_type;
+ int hdr_subtype;
+ uint16_t payload_length;
+ int hop_limit;
+ const char *next_hdr_txt = "Unknown";
+ const char *hdr_type_txt = "Unknown";
+ int hdr_size = -1;
+
+ ND_PRINT((ndo, "GeoNet "));
+ if (src != NULL)
+ ND_PRINT((ndo, "src:%s", (src->addr_string)(ndo, src->addr)));
+ ND_PRINT((ndo, "; "));
+
+ /* Process Common Header */
+ if (length < 36)
+ goto invalid;
+
+ ND_TCHECK2(*bp, 8);
+ version = bp[0] >> 4;
+ next_hdr = bp[0] & 0x0f;
+ hdr_type = bp[1] >> 4;
+ hdr_subtype = bp[1] & 0x0f;
+ payload_length = EXTRACT_16BITS(bp+4);
+ hop_limit = bp[7];
+
+ switch (next_hdr) {
+ case 0: next_hdr_txt = "Any"; break;
+ case 1: next_hdr_txt = "BTP-A"; break;
+ case 2: next_hdr_txt = "BTP-B"; break;
+ case 3: next_hdr_txt = "IPv6"; break;
+ }
+
+ switch (hdr_type) {
+ case 0: hdr_type_txt = "Any"; break;
+ case 1: hdr_type_txt = "Beacon"; break;
+ case 2: hdr_type_txt = "GeoUnicast"; break;
+ case 3: switch (hdr_subtype) {
+ case 0: hdr_type_txt = "GeoAnycastCircle"; break;
+ case 1: hdr_type_txt = "GeoAnycastRect"; break;
+ case 2: hdr_type_txt = "GeoAnycastElipse"; break;
+ }
+ break;
+ case 4: switch (hdr_subtype) {
+ case 0: hdr_type_txt = "GeoBroadcastCircle"; break;
+ case 1: hdr_type_txt = "GeoBroadcastRect"; break;
+ case 2: hdr_type_txt = "GeoBroadcastElipse"; break;
+ }
+ break;
+ case 5: switch (hdr_subtype) {
+ case 0: hdr_type_txt = "TopoScopeBcast-SH"; break;
+ case 1: hdr_type_txt = "TopoScopeBcast-MH"; break;
+ }
+ break;
+ case 6: switch (hdr_subtype) {
+ case 0: hdr_type_txt = "LocService-Request"; break;
+ case 1: hdr_type_txt = "LocService-Reply"; break;
+ }
+ break;
+ }
+
+ ND_PRINT((ndo, "v:%d ", version));
+ ND_PRINT((ndo, "NH:%d-%s ", next_hdr, next_hdr_txt));
+ ND_PRINT((ndo, "HT:%d-%d-%s ", hdr_type, hdr_subtype, hdr_type_txt));
+ ND_PRINT((ndo, "HopLim:%d ", hop_limit));
+ ND_PRINT((ndo, "Payload:%d ", payload_length));
+ if (print_long_pos_vector(ndo, bp + 8) == -1)
+ goto trunc;
+
+ /* Skip Common Header */
+ length -= 36;
+ bp += 36;
+
+ /* Process Extended Headers */
+ switch (hdr_type) {
+ case 0: /* Any */
+ hdr_size = 0;
+ break;
+ case 1: /* Beacon */
+ hdr_size = 0;
+ break;
+ case 2: /* GeoUnicast */
+ break;
+ case 3: switch (hdr_subtype) {
+ case 0: /* GeoAnycastCircle */
+ break;
+ case 1: /* GeoAnycastRect */
+ break;
+ case 2: /* GeoAnycastElipse */
+ break;
+ }
+ break;
+ case 4: switch (hdr_subtype) {
+ case 0: /* GeoBroadcastCircle */
+ break;
+ case 1: /* GeoBroadcastRect */
+ break;
+ case 2: /* GeoBroadcastElipse */
+ break;
+ }
+ break;
+ case 5: switch (hdr_subtype) {
+ case 0: /* TopoScopeBcast-SH */
+ hdr_size = 0;
+ break;
+ case 1: /* TopoScopeBcast-MH */
+ hdr_size = 68 - 36;
+ break;
+ }
+ break;
+ case 6: switch (hdr_subtype) {
+ case 0: /* LocService-Request */
+ break;
+ case 1: /* LocService-Reply */
+ break;
+ }
+ break;
+ }
+
+ /* Skip Extended headers */
+ if (hdr_size >= 0) {
+ if (length < (u_int)hdr_size)
+ goto invalid;
+ ND_TCHECK2(*bp, hdr_size);
+ length -= hdr_size;
+ bp += hdr_size;
+ switch (next_hdr) {
+ case 0: /* Any */
+ break;
+ case 1:
+ case 2: /* BTP A/B */
+ if (length < 4)
+ goto invalid;
+ ND_TCHECK2(*bp, 4);
+ print_btp(ndo, bp);
+ length -= 4;
+ bp += 4;
+ if (length >= 2) {
+ /*
+ * XXX - did print_btp_body()
+ * return if length < 2
+ * because this is optional,
+ * or was that just not
+ * reporting genuine errors?
+ */
+ ND_TCHECK2(*bp, 2);
+ print_btp_body(ndo, bp);
+ }
+ break;
+ case 3: /* IPv6 */
+ break;
+ }
+ }
+
+ /* Print user data part */
+ if (ndo->ndo_vflag)
+ ND_DEFAULTPRINT(bp, length);
+ return;
+
+invalid:
+ ND_PRINT((ndo, " Malformed (small) "));
+ /* XXX - print the remaining data as hex? */
+ return;
+
+trunc:
+ ND_PRINT((ndo, "[|geonet]"));
+}
+
+
+/*
+ * Local Variables:
+ * c-style: whitesmith
+ * c-basic-offset: 8
+ * End:
+ */
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-geonet-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-gre.c b/freebsd/contrib/tcpdump/print-gre.c
index a3e6c315..007de454 100644
--- a/freebsd/contrib/tcpdump/print-gre.c
+++ b/freebsd/contrib/tcpdump/print-gre.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/* $OpenBSD: print-gre.c,v 1.6 2002/10/30 03:04:04 fgsch Exp $ */
/*
@@ -33,32 +36,28 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
+/* \summary: Generic Routing Encapsulation (GRE) printer */
+
/*
- * tcpdump filter for GRE - Generic Routing Encapsulation
+ * netdissect printer for GRE - Generic Routing Encapsulation
* RFC1701 (GRE), RFC1702 (GRE IPv4), and RFC2637 (Enhanced GRE)
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-gre.c,v 1.28 2005-04-06 21:32:39 mcr Exp $ (LBL)";
-#endif
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include <stdio.h>
#include <string.h>
-#include "interface.h"
-#include "addrtoname.h"
+#include "netdissect.h"
+#include "addrtostr.h"
#include "extract.h"
-
-#include "ip.h"
#include "ethertype.h"
+static const char tstr[] = "[|gre]";
+
#define GRE_CP 0x8000 /* checksum present */
#define GRE_RP 0x4000 /* routing present */
#define GRE_KP 0x2000 /* key present */
@@ -67,11 +66,11 @@ static const char rcsid[] _U_ =
#define GRE_RECRS 0x0700 /* recursion count */
#define GRE_AP 0x0080 /* acknowledgment# present */
-struct tok gre_flag_values[] = {
+static const struct tok gre_flag_values[] = {
{ GRE_CP, "checksum present"},
- { GRE_RP, "routing present"},
- { GRE_KP, "key present"},
- { GRE_SP, "sequence# present"},
+ { GRE_RP, "routing present"},
+ { GRE_KP, "key present"},
+ { GRE_SP, "sequence# present"},
{ GRE_sP, "source routing present"},
{ GRE_RECRS, "recursion count"},
{ GRE_AP, "ack present"},
@@ -84,53 +83,56 @@ struct tok gre_flag_values[] = {
#define GRESRE_IP 0x0800 /* IP */
#define GRESRE_ASN 0xfffe /* ASN */
-void gre_print_0(const u_char *, u_int);
-void gre_print_1(const u_char *, u_int);
-void gre_sre_print(u_int16_t, u_int8_t, u_int8_t, const u_char *, u_int);
-void gre_sre_ip_print(u_int8_t, u_int8_t, const u_char *, u_int);
-void gre_sre_asn_print(u_int8_t, u_int8_t, const u_char *, u_int);
+static void gre_print_0(netdissect_options *, const u_char *, u_int);
+static void gre_print_1(netdissect_options *, const u_char *, u_int);
+static int gre_sre_print(netdissect_options *, uint16_t, uint8_t, uint8_t, const u_char *, u_int);
+static int gre_sre_ip_print(netdissect_options *, uint8_t, uint8_t, const u_char *, u_int);
+static int gre_sre_asn_print(netdissect_options *, uint8_t, uint8_t, const u_char *, u_int);
void
-gre_print(const u_char *bp, u_int length)
+gre_print(netdissect_options *ndo, const u_char *bp, u_int length)
{
u_int len = length, vers;
- if (len < 2) {
- printf("[|gre]");
- return;
- }
+ ND_TCHECK2(*bp, 2);
+ if (len < 2)
+ goto trunc;
vers = EXTRACT_16BITS(bp) & GRE_VERS_MASK;
- printf("GREv%u",vers);
+ ND_PRINT((ndo, "GREv%u",vers));
switch(vers) {
case 0:
- gre_print_0(bp, len);
+ gre_print_0(ndo, bp, len);
break;
case 1:
- gre_print_1(bp, len);
+ gre_print_1(ndo, bp, len);
break;
default:
- printf(" ERROR: unknown-version");
+ ND_PRINT((ndo, " ERROR: unknown-version"));
break;
}
- return;
+ return;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return;
}
-void
-gre_print_0(const u_char *bp, u_int length)
+static void
+gre_print_0(netdissect_options *ndo, const u_char *bp, u_int length)
{
u_int len = length;
- u_int16_t flags, prot;
+ uint16_t flags, prot;
flags = EXTRACT_16BITS(bp);
- if (vflag)
- printf(", Flags [%s]",
- bittok2str(gre_flag_values,"none",flags));
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo, ", Flags [%s]",
+ bittok2str(gre_flag_values,"none",flags)));
len -= 2;
bp += 2;
+ ND_TCHECK2(*bp, 2);
if (len < 2)
goto trunc;
prot = EXTRACT_16BITS(bp);
@@ -138,42 +140,47 @@ gre_print_0(const u_char *bp, u_int length)
bp += 2;
if ((flags & GRE_CP) | (flags & GRE_RP)) {
+ ND_TCHECK2(*bp, 2);
if (len < 2)
goto trunc;
- if (vflag)
- printf(", sum 0x%x", EXTRACT_16BITS(bp));
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo, ", sum 0x%x", EXTRACT_16BITS(bp)));
bp += 2;
len -= 2;
+ ND_TCHECK2(*bp, 2);
if (len < 2)
goto trunc;
- printf(", off 0x%x", EXTRACT_16BITS(bp));
+ ND_PRINT((ndo, ", off 0x%x", EXTRACT_16BITS(bp)));
bp += 2;
len -= 2;
}
if (flags & GRE_KP) {
+ ND_TCHECK2(*bp, 4);
if (len < 4)
goto trunc;
- printf(", key=0x%x", EXTRACT_32BITS(bp));
+ ND_PRINT((ndo, ", key=0x%x", EXTRACT_32BITS(bp)));
bp += 4;
len -= 4;
}
if (flags & GRE_SP) {
+ ND_TCHECK2(*bp, 4);
if (len < 4)
goto trunc;
- printf(", seq %u", EXTRACT_32BITS(bp));
+ ND_PRINT((ndo, ", seq %u", EXTRACT_32BITS(bp)));
bp += 4;
len -= 4;
}
if (flags & GRE_RP) {
for (;;) {
- u_int16_t af;
- u_int8_t sreoff;
- u_int8_t srelen;
+ uint16_t af;
+ uint8_t sreoff;
+ uint8_t srelen;
+ ND_TCHECK2(*bp, 4);
if (len < 4)
goto trunc;
af = EXTRACT_16BITS(bp);
@@ -185,7 +192,8 @@ gre_print_0(const u_char *bp, u_int length)
if (af == 0 && srelen == 0)
break;
- gre_sre_print(af, sreoff, srelen, bp, len);
+ if (!gre_sre_print(ndo, af, sreoff, srelen, bp, len))
+ goto trunc;
if (len < srelen)
goto trunc;
@@ -194,65 +202,64 @@ gre_print_0(const u_char *bp, u_int length)
}
}
- if (eflag)
- printf(", proto %s (0x%04x)",
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, ", proto %s (0x%04x)",
tok2str(ethertype_values,"unknown",prot),
- prot);
+ prot));
- printf(", length %u",length);
+ ND_PRINT((ndo, ", length %u",length));
- if (vflag < 1)
- printf(": "); /* put in a colon as protocol demarc */
+ if (ndo->ndo_vflag < 1)
+ ND_PRINT((ndo, ": ")); /* put in a colon as protocol demarc */
else
- printf("\n\t"); /* if verbose go multiline */
+ ND_PRINT((ndo, "\n\t")); /* if verbose go multiline */
switch (prot) {
case ETHERTYPE_IP:
- ip_print(gndo, bp, len);
+ ip_print(ndo, bp, len);
break;
-#ifdef INET6
case ETHERTYPE_IPV6:
- ip6_print(gndo, bp, len);
+ ip6_print(ndo, bp, len);
break;
-#endif
case ETHERTYPE_MPLS:
- mpls_print(bp, len);
+ mpls_print(ndo, bp, len);
break;
case ETHERTYPE_IPX:
- ipx_print(bp, len);
+ ipx_print(ndo, bp, len);
break;
case ETHERTYPE_ATALK:
- atalk_print(bp, len);
+ atalk_print(ndo, bp, len);
break;
case ETHERTYPE_GRE_ISO:
- isoclns_print(bp, len, len);
+ isoclns_print(ndo, bp, len, ndo->ndo_snapend - bp);
break;
case ETHERTYPE_TEB:
- ether_print(gndo, bp, len, len, NULL, NULL);
+ ether_print(ndo, bp, len, ndo->ndo_snapend - bp, NULL, NULL);
break;
default:
- printf("gre-proto-0x%x", prot);
+ ND_PRINT((ndo, "gre-proto-0x%x", prot));
}
return;
trunc:
- printf("[|gre]");
+ ND_PRINT((ndo, "%s", tstr));
}
-void
-gre_print_1(const u_char *bp, u_int length)
+static void
+gre_print_1(netdissect_options *ndo, const u_char *bp, u_int length)
{
u_int len = length;
- u_int16_t flags, prot;
+ uint16_t flags, prot;
flags = EXTRACT_16BITS(bp);
len -= 2;
bp += 2;
- if (vflag)
- printf(", Flags [%s]",
- bittok2str(gre_flag_values,"none",flags));
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo, ", Flags [%s]",
+ bittok2str(gre_flag_values,"none",flags)));
+ ND_TCHECK2(*bp, 2);
if (len < 2)
goto trunc;
prot = EXTRACT_16BITS(bp);
@@ -261,145 +268,163 @@ gre_print_1(const u_char *bp, u_int length)
if (flags & GRE_KP) {
- u_int32_t k;
+ uint32_t k;
+ ND_TCHECK2(*bp, 4);
if (len < 4)
goto trunc;
k = EXTRACT_32BITS(bp);
- printf(", call %d", k & 0xffff);
+ ND_PRINT((ndo, ", call %d", k & 0xffff));
len -= 4;
bp += 4;
}
if (flags & GRE_SP) {
+ ND_TCHECK2(*bp, 4);
if (len < 4)
goto trunc;
- printf(", seq %u", EXTRACT_32BITS(bp));
+ ND_PRINT((ndo, ", seq %u", EXTRACT_32BITS(bp)));
bp += 4;
len -= 4;
}
if (flags & GRE_AP) {
+ ND_TCHECK2(*bp, 4);
if (len < 4)
goto trunc;
- printf(", ack %u", EXTRACT_32BITS(bp));
+ ND_PRINT((ndo, ", ack %u", EXTRACT_32BITS(bp)));
bp += 4;
len -= 4;
}
if ((flags & GRE_SP) == 0)
- printf(", no-payload");
+ ND_PRINT((ndo, ", no-payload"));
- if (eflag)
- printf(", proto %s (0x%04x)",
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, ", proto %s (0x%04x)",
tok2str(ethertype_values,"unknown",prot),
- prot);
+ prot));
- printf(", length %u",length);
+ ND_PRINT((ndo, ", length %u",length));
if ((flags & GRE_SP) == 0)
return;
- if (vflag < 1)
- printf(": "); /* put in a colon as protocol demarc */
+ if (ndo->ndo_vflag < 1)
+ ND_PRINT((ndo, ": ")); /* put in a colon as protocol demarc */
else
- printf("\n\t"); /* if verbose go multiline */
+ ND_PRINT((ndo, "\n\t")); /* if verbose go multiline */
switch (prot) {
case ETHERTYPE_PPP:
- ppp_print(bp, len);
+ ppp_print(ndo, bp, len);
break;
default:
- printf("gre-proto-0x%x", prot);
+ ND_PRINT((ndo, "gre-proto-0x%x", prot));
break;
}
return;
trunc:
- printf("[|gre]");
+ ND_PRINT((ndo, "%s", tstr));
}
-void
-gre_sre_print(u_int16_t af, u_int8_t sreoff, u_int8_t srelen,
- const u_char *bp, u_int len)
+static int
+gre_sre_print(netdissect_options *ndo, uint16_t af, uint8_t sreoff,
+ uint8_t srelen, const u_char *bp, u_int len)
{
+ int ret;
+
switch (af) {
case GRESRE_IP:
- printf(", (rtaf=ip");
- gre_sre_ip_print(sreoff, srelen, bp, len);
- printf(") ");
+ ND_PRINT((ndo, ", (rtaf=ip"));
+ ret = gre_sre_ip_print(ndo, sreoff, srelen, bp, len);
+ ND_PRINT((ndo, ")"));
break;
case GRESRE_ASN:
- printf(", (rtaf=asn");
- gre_sre_asn_print(sreoff, srelen, bp, len);
- printf(") ");
+ ND_PRINT((ndo, ", (rtaf=asn"));
+ ret = gre_sre_asn_print(ndo, sreoff, srelen, bp, len);
+ ND_PRINT((ndo, ")"));
break;
default:
- printf(", (rtaf=0x%x) ", af);
+ ND_PRINT((ndo, ", (rtaf=0x%x)", af));
+ ret = 1;
}
+ return (ret);
}
-void
-gre_sre_ip_print(u_int8_t sreoff, u_int8_t srelen, const u_char *bp, u_int len)
+
+static int
+gre_sre_ip_print(netdissect_options *ndo, uint8_t sreoff, uint8_t srelen,
+ const u_char *bp, u_int len)
{
- struct in_addr a;
const u_char *up = bp;
+ char buf[INET_ADDRSTRLEN];
if (sreoff & 3) {
- printf(", badoffset=%u", sreoff);
- return;
+ ND_PRINT((ndo, ", badoffset=%u", sreoff));
+ return (1);
}
if (srelen & 3) {
- printf(", badlength=%u", srelen);
- return;
+ ND_PRINT((ndo, ", badlength=%u", srelen));
+ return (1);
}
if (sreoff >= srelen) {
- printf(", badoff/len=%u/%u", sreoff, srelen);
- return;
+ ND_PRINT((ndo, ", badoff/len=%u/%u", sreoff, srelen));
+ return (1);
}
- for (;;) {
- if (len < 4 || srelen == 0)
- return;
+ while (srelen != 0) {
+ if (!ND_TTEST2(*bp, 4))
+ return (0);
+ if (len < 4)
+ return (0);
- memcpy(&a, bp, sizeof(a));
- printf(" %s%s",
- ((bp - up) == sreoff) ? "*" : "",
- inet_ntoa(a));
+ addrtostr(bp, buf, sizeof(buf));
+ ND_PRINT((ndo, " %s%s",
+ ((bp - up) == sreoff) ? "*" : "", buf));
bp += 4;
len -= 4;
srelen -= 4;
}
+ return (1);
}
-void
-gre_sre_asn_print(u_int8_t sreoff, u_int8_t srelen, const u_char *bp, u_int len)
+static int
+gre_sre_asn_print(netdissect_options *ndo, uint8_t sreoff, uint8_t srelen,
+ const u_char *bp, u_int len)
{
const u_char *up = bp;
if (sreoff & 1) {
- printf(", badoffset=%u", sreoff);
- return;
+ ND_PRINT((ndo, ", badoffset=%u", sreoff));
+ return (1);
}
if (srelen & 1) {
- printf(", badlength=%u", srelen);
- return;
+ ND_PRINT((ndo, ", badlength=%u", srelen));
+ return (1);
}
if (sreoff >= srelen) {
- printf(", badoff/len=%u/%u", sreoff, srelen);
- return;
+ ND_PRINT((ndo, ", badoff/len=%u/%u", sreoff, srelen));
+ return (1);
}
- for (;;) {
- if (len < 2 || srelen == 0)
- return;
+ while (srelen != 0) {
+ if (!ND_TTEST2(*bp, 2))
+ return (0);
+ if (len < 2)
+ return (0);
- printf(" %s%x",
+ ND_PRINT((ndo, " %s%x",
((bp - up) == sreoff) ? "*" : "",
- EXTRACT_16BITS(bp));
+ EXTRACT_16BITS(bp)));
bp += 2;
len -= 2;
srelen -= 2;
}
+ return (1);
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-gre-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-hncp.c b/freebsd/contrib/tcpdump/print-hncp.c
new file mode 100644
index 00000000..cc1e0c36
--- /dev/null
+++ b/freebsd/contrib/tcpdump/print-hncp.c
@@ -0,0 +1,863 @@
+#include <machine/rtems-bsd-user-space.h>
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
+/*
+ * 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
+#define HNCP_DHCPV6_DATA 38
+#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][11+5];
+ static int i = 0;
+ i = (i + 1) % 4;
+ snprintf(buf[i], 16, "%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][64+5];
+ static int i = 0;
+ i = (i + 1) % 4;
+ snprintf(buf[i], 28, "%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));
+ }
+
+ 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) {
+ 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 ));
+
+ 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) {
+ 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 ));
+
+ 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;
+}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-hncp-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-hsrp.c b/freebsd/contrib/tcpdump/print-hsrp.c
index 51d4b107..f20d2973 100644
--- a/freebsd/contrib/tcpdump/print-hsrp.c
+++ b/freebsd/contrib/tcpdump/print-hsrp.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (C) 2001 Julian Cowley
* All rights reserved.
@@ -29,22 +32,17 @@
* SUCH DAMAGE.
*/
-/* Cisco Hot Standby Router Protocol (HSRP). */
+/* \summary: Cisco Hot Standby Router Protocol (HSRP) printer */
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-hsrp.c,v 1.10 2005-05-06 07:56:52 guy Exp $";
-#endif
+/* Cisco Hot Standby Router Protocol (HSRP). */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
-
-#include <stdio.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
/* HSRP op code types. */
@@ -55,7 +53,7 @@ static const char *op_code_str[] = {
};
/* HSRP states and associated names. */
-static struct tok states[] = {
+static const struct tok states[] = {
{ 0, "initial" },
{ 1, "learn" },
{ 2, "listen" },
@@ -87,56 +85,59 @@ static struct tok states[] = {
/* HSRP protocol header. */
struct hsrp {
- u_int8_t hsrp_version;
- u_int8_t hsrp_op_code;
- u_int8_t hsrp_state;
- u_int8_t hsrp_hellotime;
- u_int8_t hsrp_holdtime;
- u_int8_t hsrp_priority;
- u_int8_t hsrp_group;
- u_int8_t hsrp_reserved;
- u_int8_t hsrp_authdata[HSRP_AUTH_SIZE];
+ uint8_t hsrp_version;
+ uint8_t hsrp_op_code;
+ uint8_t hsrp_state;
+ uint8_t hsrp_hellotime;
+ uint8_t hsrp_holdtime;
+ uint8_t hsrp_priority;
+ uint8_t hsrp_group;
+ uint8_t hsrp_reserved;
+ uint8_t hsrp_authdata[HSRP_AUTH_SIZE];
struct in_addr hsrp_virtaddr;
};
void
-hsrp_print(register const u_int8_t *bp, register u_int len)
+hsrp_print(netdissect_options *ndo, register const uint8_t *bp, register u_int len)
{
- struct hsrp *hp = (struct hsrp *) bp;
+ const struct hsrp *hp = (const struct hsrp *) bp;
- TCHECK(hp->hsrp_version);
- printf("HSRPv%d", hp->hsrp_version);
+ ND_TCHECK(hp->hsrp_version);
+ ND_PRINT((ndo, "HSRPv%d", hp->hsrp_version));
if (hp->hsrp_version != 0)
return;
- TCHECK(hp->hsrp_op_code);
- printf("-");
- printf("%s ", tok2strary(op_code_str, "unknown (%d)", hp->hsrp_op_code));
- printf("%d: ", len);
- TCHECK(hp->hsrp_state);
- printf("state=%s ", tok2str(states, "Unknown (%d)", hp->hsrp_state));
- TCHECK(hp->hsrp_group);
- printf("group=%d ", hp->hsrp_group);
- TCHECK(hp->hsrp_reserved);
+ ND_TCHECK(hp->hsrp_op_code);
+ ND_PRINT((ndo, "-"));
+ ND_PRINT((ndo, "%s ", tok2strary(op_code_str, "unknown (%d)", hp->hsrp_op_code)));
+ ND_PRINT((ndo, "%d: ", len));
+ ND_TCHECK(hp->hsrp_state);
+ ND_PRINT((ndo, "state=%s ", tok2str(states, "Unknown (%d)", hp->hsrp_state)));
+ ND_TCHECK(hp->hsrp_group);
+ ND_PRINT((ndo, "group=%d ", hp->hsrp_group));
+ ND_TCHECK(hp->hsrp_reserved);
if (hp->hsrp_reserved != 0) {
- printf("[reserved=%d!] ", hp->hsrp_reserved);
+ ND_PRINT((ndo, "[reserved=%d!] ", hp->hsrp_reserved));
}
- TCHECK(hp->hsrp_virtaddr);
- printf("addr=%s", ipaddr_string(&hp->hsrp_virtaddr));
- if (vflag) {
- printf(" hellotime=");
- relts_print(hp->hsrp_hellotime);
- printf(" holdtime=");
- relts_print(hp->hsrp_holdtime);
- printf(" priority=%d", hp->hsrp_priority);
- printf(" auth=\"");
- if (fn_printn(hp->hsrp_authdata, sizeof(hp->hsrp_authdata),
- snapend)) {
- printf("\"");
+ ND_TCHECK(hp->hsrp_virtaddr);
+ ND_PRINT((ndo, "addr=%s", ipaddr_string(ndo, &hp->hsrp_virtaddr)));
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo, " hellotime="));
+ unsigned_relts_print(ndo, hp->hsrp_hellotime);
+ ND_PRINT((ndo, " holdtime="));
+ unsigned_relts_print(ndo, hp->hsrp_holdtime);
+ ND_PRINT((ndo, " priority=%d", hp->hsrp_priority));
+ ND_PRINT((ndo, " auth=\""));
+ if (fn_printn(ndo, hp->hsrp_authdata, sizeof(hp->hsrp_authdata),
+ ndo->ndo_snapend)) {
+ ND_PRINT((ndo, "\""));
goto trunc;
}
- printf("\"");
+ ND_PRINT((ndo, "\""));
}
return;
trunc:
- printf("[|hsrp]");
+ ND_PRINT((ndo, "[|hsrp]"));
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-hsrp-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-http.c b/freebsd/contrib/tcpdump/print-http.c
new file mode 100644
index 00000000..ecf442ec
--- /dev/null
+++ b/freebsd/contrib/tcpdump/print-http.c
@@ -0,0 +1,85 @@
+#include <machine/rtems-bsd-user-space.h>
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
+/*
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code
+ * distributions retain the above copyright notice and this paragraph
+ * in its entirety, and (2) distributions including binary code include
+ * the above copyright notice and this paragraph in its entirety in
+ * the documentation or other materials provided with the distribution.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND
+ * WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
+ * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE.
+ */
+
+/* \summary: Hypertext Transfer Protocol (HTTP) printer */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <netdissect-stdinc.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "netdissect.h"
+#include "extract.h"
+
+/*
+ * Includes WebDAV requests.
+ */
+static const char *httpcmds[] = {
+ "GET",
+ "PUT",
+ "COPY",
+ "HEAD",
+ "LOCK",
+ "MOVE",
+ "POLL",
+ "POST",
+ "BCOPY",
+ "BMOVE",
+ "MKCOL",
+ "TRACE",
+ "LABEL",
+ "MERGE",
+ "DELETE",
+ "SEARCH",
+ "UNLOCK",
+ "REPORT",
+ "UPDATE",
+ "NOTIFY",
+ "BDELETE",
+ "CONNECT",
+ "OPTIONS",
+ "CHECKIN",
+ "PROPFIND",
+ "CHECKOUT",
+ "CCM_POST",
+ "SUBSCRIBE",
+ "PROPPATCH",
+ "BPROPFIND",
+ "BPROPPATCH",
+ "UNCHECKOUT",
+ "MKACTIVITY",
+ "MKWORKSPACE",
+ "UNSUBSCRIBE",
+ "RPC_CONNECT",
+ "VERSION-CONTROL",
+ "BASELINE-CONTROL",
+ NULL
+};
+
+void
+http_print(netdissect_options *ndo, const u_char *pptr, u_int len)
+{
+ txtproto_print(ndo, pptr, len, "http", httpcmds, RESP_CODE_SECOND_TOKEN);
+}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-http-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-icmp.c b/freebsd/contrib/tcpdump/print-icmp.c
index 8cdc3651..4b6b56cb 100644
--- a/freebsd/contrib/tcpdump/print-icmp.c
+++ b/freebsd/contrib/tcpdump/print-icmp.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1988, 1989, 1990, 1991, 1993, 1994, 1995, 1996
* The Regents of the University of California. All rights reserved.
@@ -19,27 +22,22 @@
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * $FreeBSD$
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-icmp.c,v 1.87 2007-09-13 17:42:31 guy Exp $ (LBL)";
-#endif
+/* \summary: Internet Control Message Protocol (ICMP) printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <stdio.h>
#include <string.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
-#include "extract.h" /* must come after interface.h */
+#include "extract.h"
#include "ip.h"
#include "udp.h"
@@ -55,17 +53,17 @@ static const char rcsid[] _U_ =
* Structure of an icmp header.
*/
struct icmp {
- u_int8_t icmp_type; /* type of message, see below */
- u_int8_t icmp_code; /* type sub code */
- u_int16_t icmp_cksum; /* ones complement cksum of struct */
+ uint8_t icmp_type; /* type of message, see below */
+ uint8_t icmp_code; /* type sub code */
+ uint16_t icmp_cksum; /* ones complement cksum of struct */
union {
- u_int8_t ih_pptr; /* ICMP_PARAMPROB */
+ uint8_t ih_pptr; /* ICMP_PARAMPROB */
struct in_addr ih_gwaddr; /* ICMP_REDIRECT */
struct ih_idseq {
- u_int16_t icd_id;
- u_int16_t icd_seq;
+ uint16_t icd_id;
+ uint16_t icd_seq;
} ih_idseq;
- u_int32_t ih_void;
+ uint32_t ih_void;
} icmp_hun;
#define icmp_pptr icmp_hun.ih_pptr
#define icmp_gwaddr icmp_hun.ih_gwaddr
@@ -74,16 +72,16 @@ struct icmp {
#define icmp_void icmp_hun.ih_void
union {
struct id_ts {
- u_int32_t its_otime;
- u_int32_t its_rtime;
- u_int32_t its_ttime;
+ uint32_t its_otime;
+ uint32_t its_rtime;
+ uint32_t its_ttime;
} id_ts;
struct id_ip {
struct ip idi_ip;
/* options and then 64 bits of data */
} id_ip;
- u_int32_t id_mask;
- u_int8_t id_data[1];
+ uint32_t id_mask;
+ uint8_t id_data[1];
} icmp_dun;
#define icmp_otime icmp_dun.id_ts.its_otime
#define icmp_rtime icmp_dun.id_ts.its_rtime
@@ -93,7 +91,7 @@ struct icmp {
#define icmp_data icmp_dun.id_data
};
-#define ICMP_MPLS_EXT_EXTRACT_VERSION(x) (((x)&0xf0)>>4)
+#define ICMP_MPLS_EXT_EXTRACT_VERSION(x) (((x)&0xf0)>>4)
#define ICMP_MPLS_EXT_VERSION 2
/*
@@ -106,7 +104,7 @@ struct icmp {
*/
#define ICMP_MINLEN 8 /* abs minimum */
#define ICMP_EXTD_MINLEN (156 - sizeof (struct ip)) /* draft-bonica-internet-icmp-08 */
-#define ICMP_TSLEN (8 + 3 * sizeof (u_int32_t)) /* timestamp */
+#define ICMP_TSLEN (8 + 3 * sizeof (uint32_t)) /* timestamp */
#define ICMP_MASKLEN 12 /* address mask */
#define ICMP_ADVLENMIN (8 + sizeof (struct ip) + 8) /* min */
#define ICMP_ADVLEN(p) (8 + (IP_HL(&(p)->icmp_ip) << 2) + 8)
@@ -153,12 +151,10 @@ struct icmp {
#define ICMP_MAXTYPE 18
-#define ICMP_INFOTYPE(type) \
- ((type) == ICMP_ECHOREPLY || (type) == ICMP_ECHO || \
- (type) == ICMP_ROUTERADVERT || (type) == ICMP_ROUTERSOLICIT || \
- (type) == ICMP_TSTAMP || (type) == ICMP_TSTAMPREPLY || \
- (type) == ICMP_IREQ || (type) == ICMP_IREQREPLY || \
- (type) == ICMP_MASKREQ || (type) == ICMP_MASKREPLY)
+#define ICMP_ERRTYPE(type) \
+ ((type) == ICMP_UNREACH || (type) == ICMP_SOURCEQUENCH || \
+ (type) == ICMP_REDIRECT || (type) == ICMP_TIMXCEED || \
+ (type) == ICMP_PARAMPROB)
#define ICMP_MPLS_EXT_TYPE(type) \
((type) == ICMP_UNREACH || \
(type) == ICMP_TIMXCEED || \
@@ -198,7 +194,7 @@ struct icmp {
#endif
/* Most of the icmp types */
-static struct tok icmp2str[] = {
+static const struct tok icmp2str[] = {
{ ICMP_ECHOREPLY, "echo reply" },
{ ICMP_SOURCEQUENCH, "source quench" },
{ ICMP_ECHO, "echo request" },
@@ -212,7 +208,7 @@ static struct tok icmp2str[] = {
};
/* Formats for most of the ICMP_UNREACH codes */
-static struct tok unreach2str[] = {
+static const struct tok unreach2str[] = {
{ ICMP_UNREACH_NET, "net %s unreachable" },
{ ICMP_UNREACH_HOST, "host %s unreachable" },
{ ICMP_UNREACH_SRCFAIL,
@@ -239,7 +235,7 @@ static struct tok unreach2str[] = {
};
/* Formats for the ICMP_REDIRECT codes */
-static struct tok type2str[] = {
+static const struct tok type2str[] = {
{ ICMP_REDIRECT_NET, "redirect %s to net %s" },
{ ICMP_REDIRECT_HOST, "redirect %s to host %s" },
{ ICMP_REDIRECT_TOSNET, "redirect-tos %s to net %s" },
@@ -249,20 +245,20 @@ static struct tok type2str[] = {
/* rfc1191 */
struct mtu_discovery {
- u_int16_t unused;
- u_int16_t nexthopmtu;
+ uint16_t unused;
+ uint16_t nexthopmtu;
};
/* rfc1256 */
struct ih_rdiscovery {
- u_int8_t ird_addrnum;
- u_int8_t ird_addrsiz;
- u_int16_t ird_lifetime;
+ uint8_t ird_addrnum;
+ uint8_t ird_addrsiz;
+ uint16_t ird_lifetime;
};
struct id_rdiscovery {
- u_int32_t ird_addr;
- u_int32_t ird_pref;
+ uint32_t ird_addr;
+ uint32_t ird_pref;
};
/*
@@ -292,22 +288,22 @@ struct id_rdiscovery {
*/
struct icmp_ext_t {
- u_int8_t icmp_type;
- u_int8_t icmp_code;
- u_int8_t icmp_checksum[2];
- u_int8_t icmp_reserved;
- u_int8_t icmp_length;
- u_int8_t icmp_reserved2[2];
- u_int8_t icmp_ext_legacy_header[128]; /* extension header starts 128 bytes after ICMP header */
- u_int8_t icmp_ext_version_res[2];
- u_int8_t icmp_ext_checksum[2];
- u_int8_t icmp_ext_data[1];
+ uint8_t icmp_type;
+ uint8_t icmp_code;
+ uint8_t icmp_checksum[2];
+ uint8_t icmp_reserved;
+ uint8_t icmp_length;
+ uint8_t icmp_reserved2[2];
+ uint8_t icmp_ext_legacy_header[128]; /* extension header starts 128 bytes after ICMP header */
+ uint8_t icmp_ext_version_res[2];
+ uint8_t icmp_ext_checksum[2];
+ uint8_t icmp_ext_data[1];
};
struct icmp_mpls_ext_object_header_t {
- u_int8_t length[2];
- u_int8_t class_num;
- u_int8_t ctype;
+ uint8_t length[2];
+ uint8_t class_num;
+ uint8_t ctype;
};
static const struct tok icmp_mpls_ext_obj_values[] = {
@@ -321,7 +317,8 @@ const char *icmp_tstamp_print(u_int);
/* print the milliseconds since midnight UTC */
const char *
-icmp_tstamp_print(u_int tstamp) {
+icmp_tstamp_print(u_int tstamp)
+{
u_int msec,sec,min,hrs;
static char buf[64];
@@ -333,9 +330,10 @@ icmp_tstamp_print(u_int tstamp) {
snprintf(buf, sizeof(buf), "%02u:%02u:%02u.%03u",hrs,min,sec,msec);
return buf;
}
-
+
void
-icmp_print(const u_char *bp, u_int plen, const u_char *bp2, int fragmented)
+icmp_print(netdissect_options *ndo, const u_char *bp, u_int plen, const u_char *bp2,
+ int fragmented)
{
char *cp;
const struct icmp *dp;
@@ -344,25 +342,25 @@ icmp_print(const u_char *bp, u_int plen, const u_char *bp2, int fragmented)
const char *str, *fmt;
const struct ip *oip;
const struct udphdr *ouh;
- const u_int8_t *obj_tptr;
- u_int32_t raw_label;
+ const uint8_t *obj_tptr;
+ uint32_t raw_label;
const u_char *snapend_save;
const struct icmp_mpls_ext_object_header_t *icmp_mpls_ext_object_header;
u_int hlen, dport, mtu, obj_tlen, obj_class_num, obj_ctype;
char buf[MAXHOSTNAMELEN + 100];
struct cksum_vec vec[1];
- dp = (struct icmp *)bp;
- ext_dp = (struct icmp_ext_t *)bp;
- ip = (struct ip *)bp2;
+ dp = (const struct icmp *)bp;
+ ext_dp = (const struct icmp_ext_t *)bp;
+ ip = (const struct ip *)bp2;
str = buf;
- TCHECK(dp->icmp_code);
+ ND_TCHECK(dp->icmp_code);
switch (dp->icmp_type) {
case ICMP_ECHO:
case ICMP_ECHOREPLY:
- TCHECK(dp->icmp_seq);
+ ND_TCHECK(dp->icmp_seq);
(void)snprintf(buf, sizeof(buf), "echo %s, id %u, seq %u",
dp->icmp_type == ICMP_ECHO ?
"request" : "reply",
@@ -371,44 +369,44 @@ icmp_print(const u_char *bp, u_int plen, const u_char *bp2, int fragmented)
break;
case ICMP_UNREACH:
- TCHECK(dp->icmp_ip.ip_dst);
+ ND_TCHECK(dp->icmp_ip.ip_dst);
switch (dp->icmp_code) {
case ICMP_UNREACH_PROTOCOL:
- TCHECK(dp->icmp_ip.ip_p);
+ ND_TCHECK(dp->icmp_ip.ip_p);
(void)snprintf(buf, sizeof(buf),
"%s protocol %d unreachable",
- ipaddr_string(&dp->icmp_ip.ip_dst),
+ ipaddr_string(ndo, &dp->icmp_ip.ip_dst),
dp->icmp_ip.ip_p);
break;
case ICMP_UNREACH_PORT:
- TCHECK(dp->icmp_ip.ip_p);
+ ND_TCHECK(dp->icmp_ip.ip_p);
oip = &dp->icmp_ip;
hlen = IP_HL(oip) * 4;
- ouh = (struct udphdr *)(((u_char *)oip) + hlen);
- TCHECK(ouh->uh_dport);
+ ouh = (const struct udphdr *)(((const u_char *)oip) + hlen);
+ ND_TCHECK(ouh->uh_dport);
dport = EXTRACT_16BITS(&ouh->uh_dport);
switch (oip->ip_p) {
case IPPROTO_TCP:
(void)snprintf(buf, sizeof(buf),
"%s tcp port %s unreachable",
- ipaddr_string(&oip->ip_dst),
- tcpport_string(dport));
+ ipaddr_string(ndo, &oip->ip_dst),
+ tcpport_string(ndo, dport));
break;
case IPPROTO_UDP:
(void)snprintf(buf, sizeof(buf),
"%s udp port %s unreachable",
- ipaddr_string(&oip->ip_dst),
- udpport_string(dport));
+ ipaddr_string(ndo, &oip->ip_dst),
+ udpport_string(ndo, dport));
break;
default:
(void)snprintf(buf, sizeof(buf),
"%s protocol %d port %d unreachable",
- ipaddr_string(&oip->ip_dst),
+ ipaddr_string(ndo, &oip->ip_dst),
oip->ip_p, dport);
break;
}
@@ -417,16 +415,16 @@ icmp_print(const u_char *bp, u_int plen, const u_char *bp2, int fragmented)
case ICMP_UNREACH_NEEDFRAG:
{
register const struct mtu_discovery *mp;
- mp = (struct mtu_discovery *)(u_char *)&dp->icmp_void;
+ mp = (const struct mtu_discovery *)(const u_char *)&dp->icmp_void;
mtu = EXTRACT_16BITS(&mp->nexthopmtu);
if (mtu) {
(void)snprintf(buf, sizeof(buf),
"%s unreachable - need to frag (mtu %d)",
- ipaddr_string(&dp->icmp_ip.ip_dst), mtu);
+ ipaddr_string(ndo, &dp->icmp_ip.ip_dst), mtu);
} else {
(void)snprintf(buf, sizeof(buf),
"%s unreachable - need to frag",
- ipaddr_string(&dp->icmp_ip.ip_dst));
+ ipaddr_string(ndo, &dp->icmp_ip.ip_dst));
}
}
break;
@@ -435,18 +433,18 @@ icmp_print(const u_char *bp, u_int plen, const u_char *bp2, int fragmented)
fmt = tok2str(unreach2str, "#%d %%s unreachable",
dp->icmp_code);
(void)snprintf(buf, sizeof(buf), fmt,
- ipaddr_string(&dp->icmp_ip.ip_dst));
+ ipaddr_string(ndo, &dp->icmp_ip.ip_dst));
break;
}
break;
case ICMP_REDIRECT:
- TCHECK(dp->icmp_ip.ip_dst);
+ ND_TCHECK(dp->icmp_ip.ip_dst);
fmt = tok2str(type2str, "redirect-#%d %%s to net %%s",
dp->icmp_code);
(void)snprintf(buf, sizeof(buf), fmt,
- ipaddr_string(&dp->icmp_ip.ip_dst),
- ipaddr_string(&dp->icmp_gwaddr));
+ ipaddr_string(ndo, &dp->icmp_ip.ip_dst),
+ ipaddr_string(ndo, &dp->icmp_gwaddr));
break;
case ICMP_ROUTERADVERT:
@@ -458,8 +456,8 @@ icmp_print(const u_char *bp, u_int plen, const u_char *bp2, int fragmented)
(void)snprintf(buf, sizeof(buf), "router advertisement");
cp = buf + strlen(buf);
- ihp = (struct ih_rdiscovery *)&dp->icmp_void;
- TCHECK(*ihp);
+ ihp = (const struct ih_rdiscovery *)&dp->icmp_void;
+ ND_TCHECK(*ihp);
(void)strncpy(cp, " lifetime ", sizeof(buf) - (cp - buf));
cp = buf + strlen(buf);
lifetime = EXTRACT_16BITS(&ihp->ird_lifetime);
@@ -488,11 +486,11 @@ icmp_print(const u_char *bp, u_int plen, const u_char *bp2, int fragmented)
" [size %d]", size);
break;
}
- idp = (struct id_rdiscovery *)&dp->icmp_data;
+ idp = (const struct id_rdiscovery *)&dp->icmp_data;
while (num-- > 0) {
- TCHECK(*idp);
+ ND_TCHECK(*idp);
(void)snprintf(cp, sizeof(buf) - (cp - buf), " {%s %u}",
- ipaddr_string(&idp->ird_addr),
+ ipaddr_string(ndo, &idp->ird_addr),
EXTRACT_32BITS(&idp->ird_pref));
cp = buf + strlen(buf);
++idp;
@@ -501,7 +499,7 @@ icmp_print(const u_char *bp, u_int plen, const u_char *bp2, int fragmented)
break;
case ICMP_TIMXCEED:
- TCHECK(dp->icmp_ip.ip_dst);
+ ND_TCHECK(dp->icmp_ip.ip_dst);
switch (dp->icmp_code) {
case ICMP_TIMXCEED_INTRANS:
@@ -524,20 +522,20 @@ icmp_print(const u_char *bp, u_int plen, const u_char *bp2, int fragmented)
(void)snprintf(buf, sizeof(buf),
"parameter problem - code %d", dp->icmp_code);
else {
- TCHECK(dp->icmp_pptr);
+ ND_TCHECK(dp->icmp_pptr);
(void)snprintf(buf, sizeof(buf),
"parameter problem - octet %d", dp->icmp_pptr);
}
break;
case ICMP_MASKREPLY:
- TCHECK(dp->icmp_mask);
+ ND_TCHECK(dp->icmp_mask);
(void)snprintf(buf, sizeof(buf), "address mask is 0x%08x",
EXTRACT_32BITS(&dp->icmp_mask));
break;
case ICMP_TSTAMP:
- TCHECK(dp->icmp_seq);
+ ND_TCHECK(dp->icmp_seq);
(void)snprintf(buf, sizeof(buf),
"time stamp query id %u seq %u",
EXTRACT_16BITS(&dp->icmp_id),
@@ -545,7 +543,7 @@ icmp_print(const u_char *bp, u_int plen, const u_char *bp2, int fragmented)
break;
case ICMP_TSTAMPREPLY:
- TCHECK(dp->icmp_ttime);
+ ND_TCHECK(dp->icmp_ttime);
(void)snprintf(buf, sizeof(buf),
"time stamp reply id %u seq %u: org %s",
EXTRACT_16BITS(&dp->icmp_id),
@@ -562,19 +560,19 @@ icmp_print(const u_char *bp, u_int plen, const u_char *bp2, int fragmented)
str = tok2str(icmp2str, "type-#%d", dp->icmp_type);
break;
}
- (void)printf("ICMP %s, length %u", str, plen);
- if (vflag && !fragmented) { /* don't attempt checksumming if this is a frag */
- u_int16_t sum, icmp_sum;
- struct cksum_vec vec[1];
- if (TTEST2(*bp, plen)) {
- vec[0].ptr = (const u_int8_t *)(void *)dp;
+ ND_PRINT((ndo, "ICMP %s, length %u", str, plen));
+ if (ndo->ndo_vflag && !fragmented) { /* don't attempt checksumming if this is a frag */
+ uint16_t sum, icmp_sum;
+
+ if (ND_TTEST2(*bp, plen)) {
+ vec[0].ptr = (const uint8_t *)(const void *)dp;
vec[0].len = plen;
sum = in_cksum(vec, 1);
if (sum != 0) {
icmp_sum = EXTRACT_16BITS(&dp->icmp_cksum);
- (void)printf(" (wrong icmp cksum %x (->%x)!)",
+ ND_PRINT((ndo, " (wrong icmp cksum %x (->%x)!)",
icmp_sum,
- in_cksum_shouldbe(icmp_sum, sum));
+ in_cksum_shouldbe(icmp_sum, sum)));
}
}
}
@@ -583,22 +581,22 @@ icmp_print(const u_char *bp, u_int plen, const u_char *bp2, int fragmented)
* print the remnants of the IP packet.
* save the snaplength as this may get overidden in the IP printer.
*/
- if (vflag >= 1 && !ICMP_INFOTYPE(dp->icmp_type)) {
+ if (ndo->ndo_vflag >= 1 && ICMP_ERRTYPE(dp->icmp_type)) {
bp += 8;
- (void)printf("\n\t");
- ip = (struct ip *)bp;
- snaplen = snapend - bp;
- snapend_save = snapend;
- ip_print(gndo, bp, EXTRACT_16BITS(&ip->ip_len));
- snapend = snapend_save;
+ ND_PRINT((ndo, "\n\t"));
+ ip = (const struct ip *)bp;
+ ndo->ndo_snaplen = ndo->ndo_snapend - bp;
+ snapend_save = ndo->ndo_snapend;
+ ip_print(ndo, bp, EXTRACT_16BITS(&ip->ip_len));
+ ndo->ndo_snapend = snapend_save;
}
/*
* Attempt to decode the MPLS extensions only for some ICMP types.
*/
- if (vflag >= 1 && plen > ICMP_EXTD_MINLEN && ICMP_MPLS_EXT_TYPE(dp->icmp_type)) {
+ if (ndo->ndo_vflag >= 1 && plen > ICMP_EXTD_MINLEN && ICMP_MPLS_EXT_TYPE(dp->icmp_type)) {
- TCHECK(*ext_dp);
+ ND_TCHECK(*ext_dp);
/*
* Check first if the mpls extension header shows a non-zero length.
@@ -607,54 +605,54 @@ icmp_print(const u_char *bp, u_int plen, const u_char *bp2, int fragmented)
* however not all implementations set the length field proper.
*/
if (!ext_dp->icmp_length) {
- vec[0].ptr = (const u_int8_t *)(void *)&ext_dp->icmp_ext_version_res;
+ vec[0].ptr = (const uint8_t *)(const void *)&ext_dp->icmp_ext_version_res;
vec[0].len = plen - ICMP_EXTD_MINLEN;
if (in_cksum(vec, 1)) {
return;
}
}
- printf("\n\tMPLS extension v%u",
- ICMP_MPLS_EXT_EXTRACT_VERSION(*(ext_dp->icmp_ext_version_res)));
-
+ ND_PRINT((ndo, "\n\tMPLS extension v%u",
+ ICMP_MPLS_EXT_EXTRACT_VERSION(*(ext_dp->icmp_ext_version_res))));
+
/*
* Sanity checking of the header.
*/
if (ICMP_MPLS_EXT_EXTRACT_VERSION(*(ext_dp->icmp_ext_version_res)) !=
ICMP_MPLS_EXT_VERSION) {
- printf(" packet not supported");
+ ND_PRINT((ndo, " packet not supported"));
return;
}
hlen = plen - ICMP_EXTD_MINLEN;
- vec[0].ptr = (const u_int8_t *)(void *)&ext_dp->icmp_ext_version_res;
+ vec[0].ptr = (const uint8_t *)(const void *)&ext_dp->icmp_ext_version_res;
vec[0].len = hlen;
- printf(", checksum 0x%04x (%scorrect), length %u",
+ ND_PRINT((ndo, ", checksum 0x%04x (%scorrect), length %u",
EXTRACT_16BITS(ext_dp->icmp_ext_checksum),
in_cksum(vec, 1) ? "in" : "",
- hlen);
+ hlen));
hlen -= 4; /* subtract common header size */
- obj_tptr = (u_int8_t *)ext_dp->icmp_ext_data;
+ obj_tptr = (const uint8_t *)ext_dp->icmp_ext_data;
while (hlen > sizeof(struct icmp_mpls_ext_object_header_t)) {
- icmp_mpls_ext_object_header = (struct icmp_mpls_ext_object_header_t *)obj_tptr;
- TCHECK(*icmp_mpls_ext_object_header);
+ icmp_mpls_ext_object_header = (const struct icmp_mpls_ext_object_header_t *)obj_tptr;
+ ND_TCHECK(*icmp_mpls_ext_object_header);
obj_tlen = EXTRACT_16BITS(icmp_mpls_ext_object_header->length);
obj_class_num = icmp_mpls_ext_object_header->class_num;
obj_ctype = icmp_mpls_ext_object_header->ctype;
obj_tptr += sizeof(struct icmp_mpls_ext_object_header_t);
- printf("\n\t %s Object (%u), Class-Type: %u, length %u",
+ ND_PRINT((ndo, "\n\t %s Object (%u), Class-Type: %u, length %u",
tok2str(icmp_mpls_ext_obj_values,"unknown",obj_class_num),
obj_class_num,
obj_ctype,
- obj_tlen);
+ obj_tlen));
hlen-=sizeof(struct icmp_mpls_ext_object_header_t); /* length field includes tlv header */
- /* infinite loop protection */
+ /* infinite loop protection */
if ((obj_class_num == 0) ||
(obj_tlen < sizeof(struct icmp_mpls_ext_object_header_t))) {
return;
@@ -665,15 +663,15 @@ icmp_print(const u_char *bp, u_int plen, const u_char *bp2, int fragmented)
case 1:
switch(obj_ctype) {
case 1:
- TCHECK2(*obj_tptr, 4);
+ ND_TCHECK2(*obj_tptr, 4);
raw_label = EXTRACT_32BITS(obj_tptr);
- printf("\n\t label %u, exp %u", MPLS_LABEL(raw_label), MPLS_EXP(raw_label));
+ ND_PRINT((ndo, "\n\t label %u, exp %u", MPLS_LABEL(raw_label), MPLS_EXP(raw_label)));
if (MPLS_STACK(raw_label))
- printf(", [S]");
- printf(", ttl %u", MPLS_TTL(raw_label));
+ ND_PRINT((ndo, ", [S]"));
+ ND_PRINT((ndo, ", ttl %u", MPLS_TTL(raw_label)));
break;
default:
- print_unknown_data(obj_tptr, "\n\t ", obj_tlen);
+ print_unknown_data(ndo, obj_tptr, "\n\t ", obj_tlen);
}
break;
@@ -683,7 +681,7 @@ icmp_print(const u_char *bp, u_int plen, const u_char *bp2, int fragmented)
*/
case 2:
default:
- print_unknown_data(obj_tptr, "\n\t ", obj_tlen);
+ print_unknown_data(ndo, obj_tptr, "\n\t ", obj_tlen);
break;
}
if (hlen < obj_tlen)
@@ -695,5 +693,14 @@ icmp_print(const u_char *bp, u_int plen, const u_char *bp2, int fragmented)
return;
trunc:
- fputs("[|icmp]", stdout);
+ ND_PRINT((ndo, "[|icmp]"));
}
+/*
+ * Local Variables:
+ * c-style: whitesmith
+ * c-basic-offset: 8
+ * End:
+ */
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-icmp-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-icmp6.c b/freebsd/contrib/tcpdump/print-icmp6.c
index 69a4016c..abc74815 100644
--- a/freebsd/contrib/tcpdump/print-icmp6.c
+++ b/freebsd/contrib/tcpdump/print-icmp6.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1988, 1989, 1990, 1991, 1993, 1994
* The Regents of the University of California. All rights reserved.
@@ -21,53 +24,480 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-icmp6.c,v 1.86 2008-02-05 19:36:13 guy Exp $";
-#endif
+/* \summary: IPv6 Internet Control Message Protocol (ICMPv6) printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#ifdef INET6
-
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <stdio.h>
#include <string.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
+#include "addrtostr.h"
#include "extract.h"
#include "ip6.h"
-#include "icmp6.h"
#include "ipproto.h"
#include "udp.h"
#include "ah.h"
+/* NetBSD: icmp6.h,v 1.13 2000/08/03 16:30:37 itojun Exp */
+/* $KAME: icmp6.h,v 1.22 2000/08/03 15:25:16 jinmei Exp $ */
+
+/*
+ * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
+ * All rights reserved.
+ *
+ * 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.
+ */
+
+struct icmp6_hdr {
+ uint8_t icmp6_type; /* type field */
+ uint8_t icmp6_code; /* code field */
+ uint16_t icmp6_cksum; /* checksum field */
+ union {
+ uint32_t icmp6_un_data32[1]; /* type-specific field */
+ uint16_t icmp6_un_data16[2]; /* type-specific field */
+ uint8_t icmp6_un_data8[4]; /* type-specific field */
+ } icmp6_dataun;
+};
+
+#define icmp6_data32 icmp6_dataun.icmp6_un_data32
+#define icmp6_data16 icmp6_dataun.icmp6_un_data16
+#define icmp6_data8 icmp6_dataun.icmp6_un_data8
+#define icmp6_pptr icmp6_data32[0] /* parameter prob */
+#define icmp6_mtu icmp6_data32[0] /* packet too big */
+#define icmp6_id icmp6_data16[0] /* echo request/reply */
+#define icmp6_seq icmp6_data16[1] /* echo request/reply */
+#define icmp6_maxdelay icmp6_data16[0] /* mcast group membership */
+
+#define ICMP6_DST_UNREACH 1 /* dest unreachable, codes: */
+#define ICMP6_PACKET_TOO_BIG 2 /* packet too big */
+#define ICMP6_TIME_EXCEEDED 3 /* time exceeded, code: */
+#define ICMP6_PARAM_PROB 4 /* ip6 header bad */
+
+#define ICMP6_ECHO_REQUEST 128 /* echo service */
+#define ICMP6_ECHO_REPLY 129 /* echo reply */
+#define ICMP6_MEMBERSHIP_QUERY 130 /* group membership query */
+#define MLD6_LISTENER_QUERY 130 /* multicast listener query */
+#define ICMP6_MEMBERSHIP_REPORT 131 /* group membership report */
+#define MLD6_LISTENER_REPORT 131 /* multicast listener report */
+#define ICMP6_MEMBERSHIP_REDUCTION 132 /* group membership termination */
+#define MLD6_LISTENER_DONE 132 /* multicast listener done */
+
+#define ND_ROUTER_SOLICIT 133 /* router solicitation */
+#define ND_ROUTER_ADVERT 134 /* router advertisement */
+#define ND_NEIGHBOR_SOLICIT 135 /* neighbor solicitation */
+#define ND_NEIGHBOR_ADVERT 136 /* neighbor advertisement */
+#define ND_REDIRECT 137 /* redirect */
+
+#define ICMP6_ROUTER_RENUMBERING 138 /* router renumbering */
+
+#define ICMP6_WRUREQUEST 139 /* who are you request */
+#define ICMP6_WRUREPLY 140 /* who are you reply */
+#define ICMP6_FQDN_QUERY 139 /* FQDN query */
+#define ICMP6_FQDN_REPLY 140 /* FQDN reply */
+#define ICMP6_NI_QUERY 139 /* node information request */
+#define ICMP6_NI_REPLY 140 /* node information reply */
+#define IND_SOLICIT 141 /* inverse neighbor solicitation */
+#define IND_ADVERT 142 /* inverse neighbor advertisement */
+
+#define ICMP6_V2_MEMBERSHIP_REPORT 143 /* v2 membership report */
+#define MLDV2_LISTENER_REPORT 143 /* v2 multicast listener report */
+#define ICMP6_HADISCOV_REQUEST 144
+#define ICMP6_HADISCOV_REPLY 145
+#define ICMP6_MOBILEPREFIX_SOLICIT 146
+#define ICMP6_MOBILEPREFIX_ADVERT 147
+
+#define MLD6_MTRACE_RESP 200 /* mtrace response(to sender) */
+#define MLD6_MTRACE 201 /* mtrace messages */
+
+#define ICMP6_MAXTYPE 201
+
+#define ICMP6_DST_UNREACH_NOROUTE 0 /* no route to destination */
+#define ICMP6_DST_UNREACH_ADMIN 1 /* administratively prohibited */
+#define ICMP6_DST_UNREACH_NOTNEIGHBOR 2 /* not a neighbor(obsolete) */
+#define ICMP6_DST_UNREACH_BEYONDSCOPE 2 /* beyond scope of source address */
+#define ICMP6_DST_UNREACH_ADDR 3 /* address unreachable */
+#define ICMP6_DST_UNREACH_NOPORT 4 /* port unreachable */
+
+#define ICMP6_TIME_EXCEED_TRANSIT 0 /* ttl==0 in transit */
+#define ICMP6_TIME_EXCEED_REASSEMBLY 1 /* ttl==0 in reass */
+
+#define ICMP6_PARAMPROB_HEADER 0 /* erroneous header field */
+#define ICMP6_PARAMPROB_NEXTHEADER 1 /* unrecognized next header */
+#define ICMP6_PARAMPROB_OPTION 2 /* unrecognized option */
+
+#define ICMP6_INFOMSG_MASK 0x80 /* all informational messages */
+
+#define ICMP6_NI_SUBJ_IPV6 0 /* Query Subject is an IPv6 address */
+#define ICMP6_NI_SUBJ_FQDN 1 /* Query Subject is a Domain name */
+#define ICMP6_NI_SUBJ_IPV4 2 /* Query Subject is an IPv4 address */
+
+#define ICMP6_NI_SUCCESS 0 /* node information successful reply */
+#define ICMP6_NI_REFUSED 1 /* node information request is refused */
+#define ICMP6_NI_UNKNOWN 2 /* unknown Qtype */
+
+#define ICMP6_ROUTER_RENUMBERING_COMMAND 0 /* rr command */
+#define ICMP6_ROUTER_RENUMBERING_RESULT 1 /* rr result */
+#define ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET 255 /* rr seq num reset */
+
+/* Used in kernel only */
+#define ND_REDIRECT_ONLINK 0 /* redirect to an on-link node */
+#define ND_REDIRECT_ROUTER 1 /* redirect to a better router */
+
+/*
+ * Multicast Listener Discovery
+ */
+struct mld6_hdr {
+ struct icmp6_hdr mld6_hdr;
+ struct in6_addr mld6_addr; /* multicast address */
+};
+
+#define mld6_type mld6_hdr.icmp6_type
+#define mld6_code mld6_hdr.icmp6_code
+#define mld6_cksum mld6_hdr.icmp6_cksum
+#define mld6_maxdelay mld6_hdr.icmp6_data16[0]
+#define mld6_reserved mld6_hdr.icmp6_data16[1]
+
+#define MLD_MINLEN 24
+#define MLDV2_MINLEN 28
+
+/*
+ * Neighbor Discovery
+ */
+
+struct nd_router_solicit { /* router solicitation */
+ struct icmp6_hdr nd_rs_hdr;
+ /* could be followed by options */
+};
+
+#define nd_rs_type nd_rs_hdr.icmp6_type
+#define nd_rs_code nd_rs_hdr.icmp6_code
+#define nd_rs_cksum nd_rs_hdr.icmp6_cksum
+#define nd_rs_reserved nd_rs_hdr.icmp6_data32[0]
+
+struct nd_router_advert { /* router advertisement */
+ struct icmp6_hdr nd_ra_hdr;
+ uint32_t nd_ra_reachable; /* reachable time */
+ uint32_t nd_ra_retransmit; /* retransmit timer */
+ /* could be followed by options */
+};
+
+#define nd_ra_type nd_ra_hdr.icmp6_type
+#define nd_ra_code nd_ra_hdr.icmp6_code
+#define nd_ra_cksum nd_ra_hdr.icmp6_cksum
+#define nd_ra_curhoplimit nd_ra_hdr.icmp6_data8[0]
+#define nd_ra_flags_reserved nd_ra_hdr.icmp6_data8[1]
+#define ND_RA_FLAG_MANAGED 0x80
+#define ND_RA_FLAG_OTHER 0x40
+#define ND_RA_FLAG_HOME_AGENT 0x20
+
+/*
+ * Router preference values based on draft-draves-ipngwg-router-selection-01.
+ * These are non-standard definitions.
+ */
+#define ND_RA_FLAG_RTPREF_MASK 0x18 /* 00011000 */
+
+#define ND_RA_FLAG_RTPREF_HIGH 0x08 /* 00001000 */
+#define ND_RA_FLAG_RTPREF_MEDIUM 0x00 /* 00000000 */
+#define ND_RA_FLAG_RTPREF_LOW 0x18 /* 00011000 */
+#define ND_RA_FLAG_RTPREF_RSV 0x10 /* 00010000 */
+
+#define nd_ra_router_lifetime nd_ra_hdr.icmp6_data16[1]
+
+struct nd_neighbor_solicit { /* neighbor solicitation */
+ struct icmp6_hdr nd_ns_hdr;
+ struct in6_addr nd_ns_target; /*target address */
+ /* could be followed by options */
+};
+
+#define nd_ns_type nd_ns_hdr.icmp6_type
+#define nd_ns_code nd_ns_hdr.icmp6_code
+#define nd_ns_cksum nd_ns_hdr.icmp6_cksum
+#define nd_ns_reserved nd_ns_hdr.icmp6_data32[0]
+
+struct nd_neighbor_advert { /* neighbor advertisement */
+ struct icmp6_hdr nd_na_hdr;
+ struct in6_addr nd_na_target; /* target address */
+ /* could be followed by options */
+};
+
+#define nd_na_type nd_na_hdr.icmp6_type
+#define nd_na_code nd_na_hdr.icmp6_code
+#define nd_na_cksum nd_na_hdr.icmp6_cksum
+#define nd_na_flags_reserved nd_na_hdr.icmp6_data32[0]
+
+#define ND_NA_FLAG_ROUTER 0x80000000
+#define ND_NA_FLAG_SOLICITED 0x40000000
+#define ND_NA_FLAG_OVERRIDE 0x20000000
+
+struct nd_redirect { /* redirect */
+ struct icmp6_hdr nd_rd_hdr;
+ struct in6_addr nd_rd_target; /* target address */
+ struct in6_addr nd_rd_dst; /* destination address */
+ /* could be followed by options */
+};
+
+#define nd_rd_type nd_rd_hdr.icmp6_type
+#define nd_rd_code nd_rd_hdr.icmp6_code
+#define nd_rd_cksum nd_rd_hdr.icmp6_cksum
+#define nd_rd_reserved nd_rd_hdr.icmp6_data32[0]
+
+struct nd_opt_hdr { /* Neighbor discovery option header */
+ uint8_t nd_opt_type;
+ uint8_t nd_opt_len;
+ /* followed by option specific data*/
+};
+
+#define ND_OPT_SOURCE_LINKADDR 1
+#define ND_OPT_TARGET_LINKADDR 2
+#define ND_OPT_PREFIX_INFORMATION 3
+#define ND_OPT_REDIRECTED_HEADER 4
+#define ND_OPT_MTU 5
+#define ND_OPT_ADVINTERVAL 7
+#define ND_OPT_HOMEAGENT_INFO 8
+#define ND_OPT_ROUTE_INFO 24 /* RFC4191 */
+#define ND_OPT_RDNSS 25
+#define ND_OPT_DNSSL 31
+
+struct nd_opt_prefix_info { /* prefix information */
+ nd_uint8_t nd_opt_pi_type;
+ nd_uint8_t nd_opt_pi_len;
+ nd_uint8_t nd_opt_pi_prefix_len;
+ nd_uint8_t nd_opt_pi_flags_reserved;
+ nd_uint32_t nd_opt_pi_valid_time;
+ nd_uint32_t nd_opt_pi_preferred_time;
+ nd_uint32_t nd_opt_pi_reserved2;
+ struct in6_addr nd_opt_pi_prefix;
+};
+
+#define ND_OPT_PI_FLAG_ONLINK 0x80
+#define ND_OPT_PI_FLAG_AUTO 0x40
+#define ND_OPT_PI_FLAG_ROUTER 0x20 /*2292bis*/
+
+struct nd_opt_rd_hdr { /* redirected header */
+ uint8_t nd_opt_rh_type;
+ uint8_t nd_opt_rh_len;
+ uint16_t nd_opt_rh_reserved1;
+ uint32_t nd_opt_rh_reserved2;
+ /* followed by IP header and data */
+};
+
+struct nd_opt_mtu { /* MTU option */
+ uint8_t nd_opt_mtu_type;
+ uint8_t nd_opt_mtu_len;
+ uint16_t nd_opt_mtu_reserved;
+ uint32_t nd_opt_mtu_mtu;
+};
+
+struct nd_opt_rdnss { /* RDNSS RFC 6106 5.1 */
+ uint8_t nd_opt_rdnss_type;
+ uint8_t nd_opt_rdnss_len;
+ uint16_t nd_opt_rdnss_reserved;
+ uint32_t nd_opt_rdnss_lifetime;
+ struct in6_addr nd_opt_rdnss_addr[1]; /* variable-length */
+};
+
+struct nd_opt_dnssl { /* DNSSL RFC 6106 5.2 */
+ uint8_t nd_opt_dnssl_type;
+ uint8_t nd_opt_dnssl_len;
+ uint16_t nd_opt_dnssl_reserved;
+ uint32_t nd_opt_dnssl_lifetime;
+ /* followed by list of DNS search domains, variable-length */
+};
+
+struct nd_opt_advinterval { /* Advertisement interval option */
+ uint8_t nd_opt_adv_type;
+ uint8_t nd_opt_adv_len;
+ uint16_t nd_opt_adv_reserved;
+ uint32_t nd_opt_adv_interval;
+};
+
+struct nd_opt_homeagent_info { /* Home Agent info */
+ uint8_t nd_opt_hai_type;
+ uint8_t nd_opt_hai_len;
+ uint16_t nd_opt_hai_reserved;
+ int16_t nd_opt_hai_preference;
+ uint16_t nd_opt_hai_lifetime;
+};
+
+struct nd_opt_route_info { /* route info */
+ uint8_t nd_opt_rti_type;
+ uint8_t nd_opt_rti_len;
+ uint8_t nd_opt_rti_prefixlen;
+ uint8_t nd_opt_rti_flags;
+ uint32_t nd_opt_rti_lifetime;
+ /* prefix follows */
+};
+
+/*
+ * icmp6 namelookup
+ */
+
+struct icmp6_namelookup {
+ struct icmp6_hdr icmp6_nl_hdr;
+ uint8_t icmp6_nl_nonce[8];
+ int32_t icmp6_nl_ttl;
+#if 0
+ uint8_t icmp6_nl_len;
+ uint8_t icmp6_nl_name[3];
+#endif
+ /* could be followed by options */
+};
+
+/*
+ * icmp6 node information
+ */
+struct icmp6_nodeinfo {
+ struct icmp6_hdr icmp6_ni_hdr;
+ uint8_t icmp6_ni_nonce[8];
+ /* could be followed by reply data */
+};
+
+#define ni_type icmp6_ni_hdr.icmp6_type
+#define ni_code icmp6_ni_hdr.icmp6_code
+#define ni_cksum icmp6_ni_hdr.icmp6_cksum
+#define ni_qtype icmp6_ni_hdr.icmp6_data16[0]
+#define ni_flags icmp6_ni_hdr.icmp6_data16[1]
+
+#define NI_QTYPE_NOOP 0 /* NOOP */
+#define NI_QTYPE_SUPTYPES 1 /* Supported Qtypes */
+#define NI_QTYPE_FQDN 2 /* FQDN (draft 04) */
+#define NI_QTYPE_DNSNAME 2 /* DNS Name */
+#define NI_QTYPE_NODEADDR 3 /* Node Addresses */
+#define NI_QTYPE_IPV4ADDR 4 /* IPv4 Addresses */
+
+/* network endian */
+#define NI_SUPTYPE_FLAG_COMPRESS ((uint16_t)htons(0x1))
+#define NI_FQDN_FLAG_VALIDTTL ((uint16_t)htons(0x1))
+
+/* network endian */
+#define NI_NODEADDR_FLAG_TRUNCATE ((uint16_t)htons(0x1))
+#define NI_NODEADDR_FLAG_ALL ((uint16_t)htons(0x2))
+#define NI_NODEADDR_FLAG_COMPAT ((uint16_t)htons(0x4))
+#define NI_NODEADDR_FLAG_LINKLOCAL ((uint16_t)htons(0x8))
+#define NI_NODEADDR_FLAG_SITELOCAL ((uint16_t)htons(0x10))
+#define NI_NODEADDR_FLAG_GLOBAL ((uint16_t)htons(0x20))
+#define NI_NODEADDR_FLAG_ANYCAST ((uint16_t)htons(0x40)) /* just experimental. not in spec */
+
+struct ni_reply_fqdn {
+ uint32_t ni_fqdn_ttl; /* TTL */
+ uint8_t ni_fqdn_namelen; /* length in octets of the FQDN */
+ uint8_t ni_fqdn_name[3]; /* XXX: alignment */
+};
+
+/*
+ * Router Renumbering. as router-renum-08.txt
+ */
+struct icmp6_router_renum { /* router renumbering header */
+ struct icmp6_hdr rr_hdr;
+ uint8_t rr_segnum;
+ uint8_t rr_flags;
+ uint16_t rr_maxdelay;
+ uint32_t rr_reserved;
+};
+#define ICMP6_RR_FLAGS_TEST 0x80
+#define ICMP6_RR_FLAGS_REQRESULT 0x40
+#define ICMP6_RR_FLAGS_FORCEAPPLY 0x20
+#define ICMP6_RR_FLAGS_SPECSITE 0x10
+#define ICMP6_RR_FLAGS_PREVDONE 0x08
+
+#define rr_type rr_hdr.icmp6_type
+#define rr_code rr_hdr.icmp6_code
+#define rr_cksum rr_hdr.icmp6_cksum
+#define rr_seqnum rr_hdr.icmp6_data32[0]
+
+struct rr_pco_match { /* match prefix part */
+ uint8_t rpm_code;
+ uint8_t rpm_len;
+ uint8_t rpm_ordinal;
+ uint8_t rpm_matchlen;
+ uint8_t rpm_minlen;
+ uint8_t rpm_maxlen;
+ uint16_t rpm_reserved;
+ struct in6_addr rpm_prefix;
+};
+
+#define RPM_PCO_ADD 1
+#define RPM_PCO_CHANGE 2
+#define RPM_PCO_SETGLOBAL 3
+#define RPM_PCO_MAX 4
+
+struct rr_pco_use { /* use prefix part */
+ uint8_t rpu_uselen;
+ uint8_t rpu_keeplen;
+ uint8_t rpu_ramask;
+ uint8_t rpu_raflags;
+ uint32_t rpu_vltime;
+ uint32_t rpu_pltime;
+ uint32_t rpu_flags;
+ struct in6_addr rpu_prefix;
+};
+#define ICMP6_RR_PCOUSE_RAFLAGS_ONLINK 0x80
+#define ICMP6_RR_PCOUSE_RAFLAGS_AUTO 0x40
+
+/* network endian */
+#define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME ((uint32_t)htonl(0x80000000))
+#define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME ((uint32_t)htonl(0x40000000))
+
+struct rr_result { /* router renumbering result message */
+ uint16_t rrr_flags;
+ uint8_t rrr_ordinal;
+ uint8_t rrr_matchedlen;
+ uint32_t rrr_ifid;
+ struct in6_addr rrr_prefix;
+};
+/* network endian */
+#define ICMP6_RR_RESULT_FLAGS_OOB ((uint16_t)htons(0x0002))
+#define ICMP6_RR_RESULT_FLAGS_FORBIDDEN ((uint16_t)htons(0x0001))
+
static const char *get_rtpref(u_int);
-static const char *get_lifetime(u_int32_t);
-static void print_lladdr(const u_char *, size_t);
-static void icmp6_opt_print(const u_char *, int);
-static void mld6_print(const u_char *);
-static void mldv2_report_print(const u_char *, u_int);
-static void mldv2_query_print(const u_char *, u_int);
-static struct udphdr *get_upperlayer(u_char *, u_int *);
-static void dnsname_print(const u_char *, const u_char *);
-static void icmp6_nodeinfo_print(u_int, const u_char *, const u_char *);
-static void icmp6_rrenum_print(const u_char *, const u_char *);
+static const char *get_lifetime(uint32_t);
+static void print_lladdr(netdissect_options *ndo, const u_char *, size_t);
+static void icmp6_opt_print(netdissect_options *ndo, const u_char *, int);
+static void mld6_print(netdissect_options *ndo, const u_char *);
+static void mldv2_report_print(netdissect_options *ndo, const u_char *, u_int);
+static void mldv2_query_print(netdissect_options *ndo, const u_char *, u_int);
+static const struct udphdr *get_upperlayer(netdissect_options *ndo, const u_char *, u_int *);
+static void dnsname_print(netdissect_options *ndo, const u_char *, const u_char *);
+static void icmp6_nodeinfo_print(netdissect_options *ndo, u_int, const u_char *, const u_char *);
+static void icmp6_rrenum_print(netdissect_options *ndo, const u_char *, const u_char *);
#ifndef abs
#define abs(a) ((0 < (a)) ? (a) : -(a))
#endif
-/* inline the various RPL definitions */
-#define ND_RPL_MESSAGE 0x9B
+#include "rpl.h"
-static struct tok icmp6_type_values[] = {
+static const struct tok icmp6_type_values[] = {
{ ICMP6_DST_UNREACH, "destination unreachable"},
{ ICMP6_PACKET_TOO_BIG, "packet too big"},
{ ICMP6_TIME_EXCEEDED, "time exceeded in-transit"},
@@ -100,7 +530,7 @@ static struct tok icmp6_type_values[] = {
{ 0, NULL }
};
-static struct tok icmp6_dst_unreach_code_values[] = {
+static const struct tok icmp6_dst_unreach_code_values[] = {
{ ICMP6_DST_UNREACH_NOROUTE, "unreachable route" },
{ ICMP6_DST_UNREACH_ADMIN, " unreachable prohibited"},
{ ICMP6_DST_UNREACH_BEYONDSCOPE, "beyond scope"},
@@ -109,21 +539,21 @@ static struct tok icmp6_dst_unreach_code_values[] = {
{ 0, NULL }
};
-static struct tok icmp6_opt_pi_flag_values[] = {
+static const struct tok icmp6_opt_pi_flag_values[] = {
{ ND_OPT_PI_FLAG_ONLINK, "onlink" },
{ ND_OPT_PI_FLAG_AUTO, "auto" },
{ ND_OPT_PI_FLAG_ROUTER, "router" },
{ 0, NULL }
};
-static struct tok icmp6_opt_ra_flag_values[] = {
+static const struct tok icmp6_opt_ra_flag_values[] = {
{ ND_RA_FLAG_MANAGED, "managed" },
{ ND_RA_FLAG_OTHER, "other stateful"},
{ ND_RA_FLAG_HOME_AGENT, "home agent"},
{ 0, NULL }
};
-static struct tok icmp6_nd_na_flag_values[] = {
+static const struct tok icmp6_nd_na_flag_values[] = {
{ ND_NA_FLAG_ROUTER, "router" },
{ ND_NA_FLAG_SOLICITED, "solicited" },
{ ND_NA_FLAG_OVERRIDE, "override" },
@@ -131,7 +561,7 @@ static struct tok icmp6_nd_na_flag_values[] = {
};
-static struct tok icmp6_opt_values[] = {
+static const struct tok icmp6_opt_values[] = {
{ ND_OPT_SOURCE_LINKADDR, "source link-address"},
{ ND_OPT_TARGET_LINKADDR, "destination link-address"},
{ ND_OPT_PREFIX_INFORMATION, "prefix info"},
@@ -146,7 +576,7 @@ static struct tok icmp6_opt_values[] = {
};
/* mldv2 report types */
-static struct tok mldv2report2str[] = {
+static const struct tok mldv2report2str[] = {
{ 1, "is_in" },
{ 2, "is_ex" },
{ 3, "to_in" },
@@ -170,11 +600,11 @@ get_rtpref(u_int v)
}
static const char *
-get_lifetime(u_int32_t v)
+get_lifetime(uint32_t v)
{
static char buf[20];
- if (v == (u_int32_t)~0UL)
+ if (v == (uint32_t)~0UL)
return "infinity";
else {
snprintf(buf, sizeof(buf), "%us", v);
@@ -183,110 +613,247 @@ get_lifetime(u_int32_t v)
}
static void
-print_lladdr(const u_int8_t *p, size_t l)
+print_lladdr(netdissect_options *ndo, const uint8_t *p, size_t l)
{
- const u_int8_t *ep, *q;
+ const uint8_t *ep, *q;
q = p;
ep = p + l;
while (l > 0 && q < ep) {
if (q > p)
- printf(":");
- printf("%02x", *q++);
+ ND_PRINT((ndo,":"));
+ ND_PRINT((ndo,"%02x", *q++));
l--;
}
}
-static int icmp6_cksum(const struct ip6_hdr *ip6, const struct icmp6_hdr *icp,
- u_int len)
+static int icmp6_cksum(netdissect_options *ndo, const struct ip6_hdr *ip6,
+ const struct icmp6_hdr *icp, u_int len)
{
- return (nextproto6_cksum(ip6, (const u_int8_t *)(void *)icp, len,
- IPPROTO_ICMPV6));
+ return nextproto6_cksum(ndo, ip6, (const uint8_t *)(const void *)icp, len, len,
+ IPPROTO_ICMPV6);
}
-enum ND_RPL_CODE {
- ND_RPL_DIS =0x00,
- ND_RPL_DIO =0x01,
- ND_RPL_DAO =0x02,
- ND_RPL_DAO_ACK=0x03,
- ND_RPL_SDIS =0x80,
- ND_RPL_SDIO =0x81,
- ND_RPL_SDAO =0x82,
- ND_RPL_SDAO_ACK=0x83,
- ND_RPL_SCC =0x8A,
+static const struct tok rpl_mop_values[] = {
+ { RPL_DIO_NONSTORING, "nonstoring"},
+ { RPL_DIO_STORING, "storing"},
+ { RPL_DIO_NONSTORING_MULTICAST, "nonstoring-multicast"},
+ { RPL_DIO_STORING_MULTICAST, "storing-multicast"},
+ { 0, NULL},
};
-enum ND_RPL_DIO_FLAGS {
- ND_RPL_DIO_GROUNDED = 0x80,
- ND_RPL_DIO_DATRIG = 0x40,
- ND_RPL_DIO_DASUPPORT= 0x20,
- ND_RPL_DIO_RES4 = 0x10,
- ND_RPL_DIO_RES3 = 0x08,
- ND_RPL_DIO_PRF_MASK = 0x07, /* 3-bit preference */
+static const struct tok rpl_subopt_values[] = {
+ { RPL_OPT_PAD0, "pad0"},
+ { RPL_OPT_PADN, "padN"},
+ { RPL_DIO_METRICS, "metrics"},
+ { RPL_DIO_ROUTINGINFO, "routinginfo"},
+ { RPL_DIO_CONFIG, "config"},
+ { RPL_DAO_RPLTARGET, "rpltarget"},
+ { RPL_DAO_TRANSITINFO, "transitinfo"},
+ { RPL_DIO_DESTPREFIX, "destprefix"},
+ { RPL_DAO_RPLTARGET_DESC, "rpltargetdesc"},
+ { 0, NULL},
};
-struct nd_rpl_dio {
- u_int8_t rpl_flags;
- u_int8_t rpl_seq;
- u_int8_t rpl_instanceid;
- u_int8_t rpl_dagrank;
- u_int8_t rpl_dagid[16];
-};
+static void
+rpl_dio_printopt(netdissect_options *ndo,
+ const struct rpl_dio_genoption *opt,
+ u_int length)
+{
+ if(length < RPL_DIO_GENOPTION_LEN) return;
+ length -= RPL_DIO_GENOPTION_LEN;
+
+ ND_TCHECK(opt->rpl_dio_len);
+
+ while((opt->rpl_dio_type == RPL_OPT_PAD0 &&
+ (const u_char *)opt < ndo->ndo_snapend) ||
+ ND_TTEST2(*opt,(opt->rpl_dio_len+2))) {
+
+ unsigned int optlen = opt->rpl_dio_len+2;
+ if(opt->rpl_dio_type == RPL_OPT_PAD0) {
+ optlen = 1;
+ ND_PRINT((ndo, " opt:pad0"));
+ } else {
+ ND_PRINT((ndo, " opt:%s len:%u ",
+ tok2str(rpl_subopt_values, "subopt:%u", opt->rpl_dio_type),
+ optlen));
+ if(ndo->ndo_vflag > 2) {
+ unsigned int paylen = opt->rpl_dio_len;
+ if(paylen > length) paylen = length;
+ hex_print(ndo,
+ " ",
+ ((const uint8_t *)opt) + RPL_DIO_GENOPTION_LEN, /* content of DIO option */
+ paylen);
+ }
+ }
+ opt = (const struct rpl_dio_genoption *)(((const char *)opt) + optlen);
+ length -= optlen;
+ }
+ return;
+trunc:
+ ND_PRINT((ndo," [|truncated]"));
+ return;
+}
+
+static void
+rpl_dio_print(netdissect_options *ndo,
+ const u_char *bp, u_int length)
+{
+ const struct nd_rpl_dio *dio = (const struct nd_rpl_dio *)bp;
+ const char *dagid_str;
+
+ ND_TCHECK(*dio);
+ dagid_str = ip6addr_string (ndo, dio->rpl_dagid);
+
+ ND_PRINT((ndo, " [dagid:%s,seq:%u,instance:%u,rank:%u,%smop:%s,prf:%u]",
+ dagid_str,
+ dio->rpl_dtsn,
+ dio->rpl_instanceid,
+ EXTRACT_16BITS(&dio->rpl_dagrank),
+ RPL_DIO_GROUNDED(dio->rpl_mopprf) ? "grounded,":"",
+ tok2str(rpl_mop_values, "mop%u", RPL_DIO_MOP(dio->rpl_mopprf)),
+ RPL_DIO_PRF(dio->rpl_mopprf)));
+
+ if(ndo->ndo_vflag > 1) {
+ const struct rpl_dio_genoption *opt = (const struct rpl_dio_genoption *)&dio[1];
+ rpl_dio_printopt(ndo, opt, length);
+ }
+ return;
+trunc:
+ ND_PRINT((ndo," [|truncated]"));
+ return;
+}
+
+static void
+rpl_dao_print(netdissect_options *ndo,
+ const u_char *bp, u_int length)
+{
+ const struct nd_rpl_dao *dao = (const struct nd_rpl_dao *)bp;
+ const char *dagid_str = "<elided>";
+
+ ND_TCHECK(*dao);
+ if (length < ND_RPL_DAO_MIN_LEN)
+ goto tooshort;
+
+ bp += ND_RPL_DAO_MIN_LEN;
+ length -= ND_RPL_DAO_MIN_LEN;
+ if(RPL_DAO_D(dao->rpl_flags)) {
+ ND_TCHECK2(dao->rpl_dagid, DAGID_LEN);
+ if (length < DAGID_LEN)
+ goto tooshort;
+ dagid_str = ip6addr_string (ndo, dao->rpl_dagid);
+ bp += DAGID_LEN;
+ length -= DAGID_LEN;
+ }
+
+ ND_PRINT((ndo, " [dagid:%s,seq:%u,instance:%u%s%s,%02x]",
+ dagid_str,
+ dao->rpl_daoseq,
+ dao->rpl_instanceid,
+ RPL_DAO_K(dao->rpl_flags) ? ",acK":"",
+ RPL_DAO_D(dao->rpl_flags) ? ",Dagid":"",
+ dao->rpl_flags));
+
+ if(ndo->ndo_vflag > 1) {
+ const struct rpl_dio_genoption *opt = (const struct rpl_dio_genoption *)bp;
+ rpl_dio_printopt(ndo, opt, length);
+ }
+ return;
+
+trunc:
+ ND_PRINT((ndo," [|truncated]"));
+ return;
+
+tooshort:
+ ND_PRINT((ndo," [|length too short]"));
+ return;
+}
+
+static void
+rpl_daoack_print(netdissect_options *ndo,
+ const u_char *bp, u_int length)
+{
+ const struct nd_rpl_daoack *daoack = (const struct nd_rpl_daoack *)bp;
+ const char *dagid_str = "<elided>";
+
+ ND_TCHECK2(*daoack, ND_RPL_DAOACK_MIN_LEN);
+ if (length < ND_RPL_DAOACK_MIN_LEN)
+ goto tooshort;
+
+ bp += ND_RPL_DAOACK_MIN_LEN;
+ length -= ND_RPL_DAOACK_MIN_LEN;
+ if(RPL_DAOACK_D(daoack->rpl_flags)) {
+ ND_TCHECK2(daoack->rpl_dagid, DAGID_LEN);
+ if (length < DAGID_LEN)
+ goto tooshort;
+ dagid_str = ip6addr_string (ndo, daoack->rpl_dagid);
+ bp += DAGID_LEN;
+ length -= DAGID_LEN;
+ }
+
+ ND_PRINT((ndo, " [dagid:%s,seq:%u,instance:%u,status:%u]",
+ dagid_str,
+ daoack->rpl_daoseq,
+ daoack->rpl_instanceid,
+ daoack->rpl_status));
+
+ /* no officially defined options for DAOACK, but print any we find */
+ if(ndo->ndo_vflag > 1) {
+ const struct rpl_dio_genoption *opt = (const struct rpl_dio_genoption *)bp;
+ rpl_dio_printopt(ndo, opt, length);
+ }
+ return;
+
+trunc:
+ ND_PRINT((ndo," [|dao-truncated]"));
+ return;
+
+tooshort:
+ ND_PRINT((ndo," [|dao-length too short]"));
+ return;
+}
static void
rpl_print(netdissect_options *ndo,
const struct icmp6_hdr *hdr,
- const u_char *bp, u_int length _U_)
+ const u_char *bp, u_int length)
{
- struct nd_rpl_dio *dio = (struct nd_rpl_dio *)bp;
int secured = hdr->icmp6_code & 0x80;
int basecode= hdr->icmp6_code & 0x7f;
- ND_TCHECK(dio->rpl_dagid);
-
if(secured) {
- ND_PRINT((ndo, ", (SEC)"));
+ ND_PRINT((ndo, ", (SEC) [worktodo]"));
+ /* XXX
+ * the next header pointer needs to move forward to
+ * skip the secure part.
+ */
+ return;
} else {
ND_PRINT((ndo, ", (CLR)"));
}
-
+
switch(basecode) {
- case ND_RPL_DIS:
+ case ND_RPL_DAG_IS:
ND_PRINT((ndo, "DODAG Information Solicitation"));
if(ndo->ndo_vflag) {
}
break;
- case ND_RPL_DIO:
+ case ND_RPL_DAG_IO:
ND_PRINT((ndo, "DODAG Information Object"));
if(ndo->ndo_vflag) {
- char dagid[65];
- char *d = dagid;
- int i;
- for(i=0;i<16;i++) {
- if(isprint(dio->rpl_dagid[i])) {
- *d++ = dio->rpl_dagid[i];
- } else {
- int cnt=snprintf(d,4,"0x%02x",
- dio->rpl_dagid[i]);
- d += cnt;
- }
- }
- *d++ = '\0';
- ND_PRINT((ndo, " [seq:%u,instance:%u,rank:%u,dagid:%s]",
- dio->rpl_seq,
- dio->rpl_instanceid,
- dio->rpl_dagrank,
- dagid));
+ rpl_dio_print(ndo, bp, length);
}
break;
case ND_RPL_DAO:
ND_PRINT((ndo, "Destination Advertisement Object"));
if(ndo->ndo_vflag) {
+ rpl_dao_print(ndo, bp, length);
}
break;
case ND_RPL_DAO_ACK:
ND_PRINT((ndo, "Destination Advertisement Object Ack"));
if(ndo->ndo_vflag) {
+ rpl_daoack_print(ndo, bp, length);
}
break;
default:
@@ -294,10 +861,13 @@ rpl_print(netdissect_options *ndo,
break;
}
return;
+
+#if 0
trunc:
ND_PRINT((ndo," [|truncated]"));
return;
-
+#endif
+
}
@@ -313,302 +883,303 @@ icmp6_print(netdissect_options *ndo,
const u_char *ep;
u_int prot;
- dp = (struct icmp6_hdr *)bp;
- ip = (struct ip6_hdr *)bp2;
- oip = (struct ip6_hdr *)(dp + 1);
+ dp = (const struct icmp6_hdr *)bp;
+ ip = (const struct ip6_hdr *)bp2;
+ oip = (const struct ip6_hdr *)(dp + 1);
/* 'ep' points to the end of available data. */
- ep = snapend;
+ ep = ndo->ndo_snapend;
- TCHECK(dp->icmp6_cksum);
+ ND_TCHECK(dp->icmp6_cksum);
- if (vflag && !fragmented) {
- u_int16_t sum, udp_sum;
+ if (ndo->ndo_vflag && !fragmented) {
+ uint16_t sum, udp_sum;
- if (TTEST2(bp[0], length)) {
+ if (ND_TTEST2(bp[0], length)) {
udp_sum = EXTRACT_16BITS(&dp->icmp6_cksum);
- sum = icmp6_cksum(ip, dp, length);
+ sum = icmp6_cksum(ndo, ip, dp, length);
if (sum != 0)
- (void)printf("[bad icmp6 cksum 0x%04x -> 0x%04x!] ",
- udp_sum,
- in_cksum_shouldbe(udp_sum, sum));
+ ND_PRINT((ndo,"[bad icmp6 cksum 0x%04x -> 0x%04x!] ",
+ udp_sum,
+ in_cksum_shouldbe(udp_sum, sum)));
else
- (void)printf("[icmp6 sum ok] ");
+ ND_PRINT((ndo,"[icmp6 sum ok] "));
}
}
- printf("ICMP6, %s", tok2str(icmp6_type_values,"unknown icmp6 type (%u)",dp->icmp6_type));
+ ND_PRINT((ndo,"ICMP6, %s", tok2str(icmp6_type_values,"unknown icmp6 type (%u)",dp->icmp6_type)));
/* display cosmetics: print the packet length for printer that use the vflag now */
- if (vflag && (dp->icmp6_type == ND_ROUTER_SOLICIT ||
+ if (ndo->ndo_vflag && (dp->icmp6_type == ND_ROUTER_SOLICIT ||
dp->icmp6_type == ND_ROUTER_ADVERT ||
dp->icmp6_type == ND_NEIGHBOR_ADVERT ||
dp->icmp6_type == ND_NEIGHBOR_SOLICIT ||
dp->icmp6_type == ND_REDIRECT ||
dp->icmp6_type == ICMP6_HADISCOV_REPLY ||
dp->icmp6_type == ICMP6_MOBILEPREFIX_ADVERT ))
- printf(", length %u", length);
-
+ ND_PRINT((ndo,", length %u", length));
+
switch (dp->icmp6_type) {
case ICMP6_DST_UNREACH:
- TCHECK(oip->ip6_dst);
- printf(", %s", tok2str(icmp6_dst_unreach_code_values,"unknown unreach code (%u)",dp->icmp6_code));
+ ND_TCHECK(oip->ip6_dst);
+ ND_PRINT((ndo,", %s", tok2str(icmp6_dst_unreach_code_values,"unknown unreach code (%u)",dp->icmp6_code)));
switch (dp->icmp6_code) {
case ICMP6_DST_UNREACH_NOROUTE: /* fall through */
case ICMP6_DST_UNREACH_ADMIN:
case ICMP6_DST_UNREACH_ADDR:
- printf(" %s",ip6addr_string(&oip->ip6_dst));
+ ND_PRINT((ndo," %s",ip6addr_string(ndo, &oip->ip6_dst)));
break;
case ICMP6_DST_UNREACH_BEYONDSCOPE:
- printf(" %s, source address %s",
- ip6addr_string(&oip->ip6_dst),
- ip6addr_string(&oip->ip6_src));
+ ND_PRINT((ndo," %s, source address %s",
+ ip6addr_string(ndo, &oip->ip6_dst),
+ ip6addr_string(ndo, &oip->ip6_src)));
break;
case ICMP6_DST_UNREACH_NOPORT:
- if ((ouh = get_upperlayer((u_char *)oip, &prot))
+ if ((ouh = get_upperlayer(ndo, (const u_char *)oip, &prot))
== NULL)
goto trunc;
dport = EXTRACT_16BITS(&ouh->uh_dport);
switch (prot) {
case IPPROTO_TCP:
- printf(", %s tcp port %s",
- ip6addr_string(&oip->ip6_dst),
- tcpport_string(dport));
+ ND_PRINT((ndo,", %s tcp port %s",
+ ip6addr_string(ndo, &oip->ip6_dst),
+ tcpport_string(ndo, dport)));
break;
case IPPROTO_UDP:
- printf(", %s udp port %s",
- ip6addr_string(&oip->ip6_dst),
- udpport_string(dport));
+ ND_PRINT((ndo,", %s udp port %s",
+ ip6addr_string(ndo, &oip->ip6_dst),
+ udpport_string(ndo, dport)));
break;
default:
- printf(", %s protocol %d port %d unreachable",
- ip6addr_string(&oip->ip6_dst),
- oip->ip6_nxt, dport);
+ ND_PRINT((ndo,", %s protocol %d port %d unreachable",
+ ip6addr_string(ndo, &oip->ip6_dst),
+ oip->ip6_nxt, dport));
break;
}
break;
default:
- if (vflag <= 1) {
- print_unknown_data(bp,"\n\t",length);
- return;
- }
+ if (ndo->ndo_vflag <= 1) {
+ print_unknown_data(ndo, bp,"\n\t",length);
+ return;
+ }
break;
}
break;
case ICMP6_PACKET_TOO_BIG:
- TCHECK(dp->icmp6_mtu);
- printf(", mtu %u", EXTRACT_32BITS(&dp->icmp6_mtu));
+ ND_TCHECK(dp->icmp6_mtu);
+ ND_PRINT((ndo,", mtu %u", EXTRACT_32BITS(&dp->icmp6_mtu)));
break;
case ICMP6_TIME_EXCEEDED:
- TCHECK(oip->ip6_dst);
+ ND_TCHECK(oip->ip6_dst);
switch (dp->icmp6_code) {
case ICMP6_TIME_EXCEED_TRANSIT:
- printf(" for %s",
- ip6addr_string(&oip->ip6_dst));
+ ND_PRINT((ndo," for %s",
+ ip6addr_string(ndo, &oip->ip6_dst)));
break;
case ICMP6_TIME_EXCEED_REASSEMBLY:
- printf(" (reassembly)");
+ ND_PRINT((ndo," (reassembly)"));
break;
default:
- printf(", unknown code (%u)", dp->icmp6_code);
+ ND_PRINT((ndo,", unknown code (%u)", dp->icmp6_code));
break;
}
break;
case ICMP6_PARAM_PROB:
- TCHECK(oip->ip6_dst);
+ ND_TCHECK(oip->ip6_dst);
switch (dp->icmp6_code) {
case ICMP6_PARAMPROB_HEADER:
- printf(", errorneous - octet %u", EXTRACT_32BITS(&dp->icmp6_pptr));
- break;
+ ND_PRINT((ndo,", erroneous - octet %u", EXTRACT_32BITS(&dp->icmp6_pptr)));
+ break;
case ICMP6_PARAMPROB_NEXTHEADER:
- printf(", next header - octet %u", EXTRACT_32BITS(&dp->icmp6_pptr));
- break;
+ ND_PRINT((ndo,", next header - octet %u", EXTRACT_32BITS(&dp->icmp6_pptr)));
+ break;
case ICMP6_PARAMPROB_OPTION:
- printf(", option - octet %u", EXTRACT_32BITS(&dp->icmp6_pptr));
- break;
+ ND_PRINT((ndo,", option - octet %u", EXTRACT_32BITS(&dp->icmp6_pptr)));
+ break;
default:
- printf(", code-#%d",
- dp->icmp6_code);
- break;
+ ND_PRINT((ndo,", code-#%d",
+ dp->icmp6_code));
+ break;
}
break;
case ICMP6_ECHO_REQUEST:
case ICMP6_ECHO_REPLY:
- TCHECK(dp->icmp6_seq);
- printf(", seq %u", EXTRACT_16BITS(&dp->icmp6_seq));
+ ND_TCHECK(dp->icmp6_seq);
+ ND_PRINT((ndo,", seq %u", EXTRACT_16BITS(&dp->icmp6_seq)));
break;
case ICMP6_MEMBERSHIP_QUERY:
if (length == MLD_MINLEN) {
- mld6_print((const u_char *)dp);
+ mld6_print(ndo, (const u_char *)dp);
} else if (length >= MLDV2_MINLEN) {
- printf(" v2");
- mldv2_query_print((const u_char *)dp, length);
+ ND_PRINT((ndo," v2"));
+ mldv2_query_print(ndo, (const u_char *)dp, length);
} else {
- printf(" unknown-version (len %u) ", length);
+ ND_PRINT((ndo," unknown-version (len %u) ", length));
}
break;
case ICMP6_MEMBERSHIP_REPORT:
- mld6_print((const u_char *)dp);
+ mld6_print(ndo, (const u_char *)dp);
break;
case ICMP6_MEMBERSHIP_REDUCTION:
- mld6_print((const u_char *)dp);
+ mld6_print(ndo, (const u_char *)dp);
break;
case ND_ROUTER_SOLICIT:
#define RTSOLLEN 8
- if (vflag) {
- icmp6_opt_print((const u_char *)dp + RTSOLLEN,
+ if (ndo->ndo_vflag) {
+ icmp6_opt_print(ndo, (const u_char *)dp + RTSOLLEN,
length - RTSOLLEN);
}
break;
case ND_ROUTER_ADVERT:
#define RTADVLEN 16
- if (vflag) {
- struct nd_router_advert *p;
-
- p = (struct nd_router_advert *)dp;
- TCHECK(p->nd_ra_retransmit);
- printf("\n\thop limit %u, Flags [%s]" \
- ", pref %s, router lifetime %us, reachable time %us, retrans time %us",
- (u_int)p->nd_ra_curhoplimit,
- bittok2str(icmp6_opt_ra_flag_values,"none",(p->nd_ra_flags_reserved)),
- get_rtpref(p->nd_ra_flags_reserved),
- EXTRACT_16BITS(&p->nd_ra_router_lifetime),
- EXTRACT_32BITS(&p->nd_ra_reachable),
- EXTRACT_32BITS(&p->nd_ra_retransmit));
-
- icmp6_opt_print((const u_char *)dp + RTADVLEN,
+ if (ndo->ndo_vflag) {
+ const struct nd_router_advert *p;
+
+ p = (const struct nd_router_advert *)dp;
+ ND_TCHECK(p->nd_ra_retransmit);
+ ND_PRINT((ndo,"\n\thop limit %u, Flags [%s]" \
+ ", pref %s, router lifetime %us, reachable time %us, retrans time %us",
+ (u_int)p->nd_ra_curhoplimit,
+ bittok2str(icmp6_opt_ra_flag_values,"none",(p->nd_ra_flags_reserved)),
+ get_rtpref(p->nd_ra_flags_reserved),
+ EXTRACT_16BITS(&p->nd_ra_router_lifetime),
+ EXTRACT_32BITS(&p->nd_ra_reachable),
+ EXTRACT_32BITS(&p->nd_ra_retransmit)));
+
+ icmp6_opt_print(ndo, (const u_char *)dp + RTADVLEN,
length - RTADVLEN);
}
break;
case ND_NEIGHBOR_SOLICIT:
{
- struct nd_neighbor_solicit *p;
- p = (struct nd_neighbor_solicit *)dp;
- TCHECK(p->nd_ns_target);
- printf(", who has %s", ip6addr_string(&p->nd_ns_target));
- if (vflag) {
+ const struct nd_neighbor_solicit *p;
+ p = (const struct nd_neighbor_solicit *)dp;
+ ND_TCHECK(p->nd_ns_target);
+ ND_PRINT((ndo,", who has %s", ip6addr_string(ndo, &p->nd_ns_target)));
+ if (ndo->ndo_vflag) {
#define NDSOLLEN 24
- icmp6_opt_print((const u_char *)dp + NDSOLLEN,
+ icmp6_opt_print(ndo, (const u_char *)dp + NDSOLLEN,
length - NDSOLLEN);
}
}
break;
case ND_NEIGHBOR_ADVERT:
{
- struct nd_neighbor_advert *p;
-
- p = (struct nd_neighbor_advert *)dp;
- TCHECK(p->nd_na_target);
- printf(", tgt is %s",
- ip6addr_string(&p->nd_na_target));
- if (vflag) {
- printf(", Flags [%s]",
- bittok2str(icmp6_nd_na_flag_values,
- "none",
- EXTRACT_32BITS(&p->nd_na_flags_reserved)));
+ const struct nd_neighbor_advert *p;
+
+ p = (const struct nd_neighbor_advert *)dp;
+ ND_TCHECK(p->nd_na_target);
+ ND_PRINT((ndo,", tgt is %s",
+ ip6addr_string(ndo, &p->nd_na_target)));
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo,", Flags [%s]",
+ bittok2str(icmp6_nd_na_flag_values,
+ "none",
+ EXTRACT_32BITS(&p->nd_na_flags_reserved))));
#define NDADVLEN 24
- icmp6_opt_print((const u_char *)dp + NDADVLEN,
+ icmp6_opt_print(ndo, (const u_char *)dp + NDADVLEN,
length - NDADVLEN);
#undef NDADVLEN
}
}
break;
case ND_REDIRECT:
-#define RDR(i) ((struct nd_redirect *)(i))
- TCHECK(RDR(dp)->nd_rd_dst);
- printf(", %s", getname6((const u_char *)&RDR(dp)->nd_rd_dst));
- TCHECK(RDR(dp)->nd_rd_target);
- printf(" to %s",
- getname6((const u_char*)&RDR(dp)->nd_rd_target));
+#define RDR(i) ((const struct nd_redirect *)(i))
+ ND_TCHECK(RDR(dp)->nd_rd_dst);
+ ND_PRINT((ndo,", %s", ip6addr_string(ndo, &RDR(dp)->nd_rd_dst)));
+ ND_TCHECK(RDR(dp)->nd_rd_target);
+ ND_PRINT((ndo," to %s",
+ ip6addr_string(ndo, &RDR(dp)->nd_rd_target)));
#define REDIRECTLEN 40
- if (vflag) {
- icmp6_opt_print((const u_char *)dp + REDIRECTLEN,
+ if (ndo->ndo_vflag) {
+ icmp6_opt_print(ndo, (const u_char *)dp + REDIRECTLEN,
length - REDIRECTLEN);
}
break;
#undef REDIRECTLEN
#undef RDR
case ICMP6_ROUTER_RENUMBERING:
- icmp6_rrenum_print(bp, ep);
+ icmp6_rrenum_print(ndo, bp, ep);
break;
case ICMP6_NI_QUERY:
case ICMP6_NI_REPLY:
- icmp6_nodeinfo_print(length, bp, ep);
+ icmp6_nodeinfo_print(ndo, length, bp, ep);
break;
case IND_SOLICIT:
case IND_ADVERT:
break;
case ICMP6_V2_MEMBERSHIP_REPORT:
- mldv2_report_print((const u_char *) dp, length);
+ mldv2_report_print(ndo, (const u_char *) dp, length);
break;
case ICMP6_MOBILEPREFIX_SOLICIT: /* fall through */
case ICMP6_HADISCOV_REQUEST:
- TCHECK(dp->icmp6_data16[0]);
- printf(", id 0x%04x", EXTRACT_16BITS(&dp->icmp6_data16[0]));
+ ND_TCHECK(dp->icmp6_data16[0]);
+ ND_PRINT((ndo,", id 0x%04x", EXTRACT_16BITS(&dp->icmp6_data16[0])));
break;
case ICMP6_HADISCOV_REPLY:
- if (vflag) {
- struct in6_addr *in6;
- u_char *cp;
-
- TCHECK(dp->icmp6_data16[0]);
- printf(", id 0x%04x", EXTRACT_16BITS(&dp->icmp6_data16[0]));
- cp = (u_char *)dp + length;
- in6 = (struct in6_addr *)(dp + 1);
- for (; (u_char *)in6 < cp; in6++) {
- TCHECK(*in6);
- printf(", %s", ip6addr_string(in6));
+ if (ndo->ndo_vflag) {
+ const struct in6_addr *in6;
+ const u_char *cp;
+
+ ND_TCHECK(dp->icmp6_data16[0]);
+ ND_PRINT((ndo,", id 0x%04x", EXTRACT_16BITS(&dp->icmp6_data16[0])));
+ cp = (const u_char *)dp + length;
+ in6 = (const struct in6_addr *)(dp + 1);
+ for (; (const u_char *)in6 < cp; in6++) {
+ ND_TCHECK(*in6);
+ ND_PRINT((ndo,", %s", ip6addr_string(ndo, in6)));
}
}
break;
case ICMP6_MOBILEPREFIX_ADVERT:
- if (vflag) {
- TCHECK(dp->icmp6_data16[0]);
- printf(", id 0x%04x", EXTRACT_16BITS(&dp->icmp6_data16[0]));
+ if (ndo->ndo_vflag) {
+ ND_TCHECK(dp->icmp6_data16[0]);
+ ND_PRINT((ndo,", id 0x%04x", EXTRACT_16BITS(&dp->icmp6_data16[0])));
if (dp->icmp6_data16[1] & 0xc0)
- printf(" ");
+ ND_PRINT((ndo," "));
if (dp->icmp6_data16[1] & 0x80)
- printf("M");
+ ND_PRINT((ndo,"M"));
if (dp->icmp6_data16[1] & 0x40)
- printf("O");
+ ND_PRINT((ndo,"O"));
#define MPADVLEN 8
- icmp6_opt_print((const u_char *)dp + MPADVLEN,
+ icmp6_opt_print(ndo, (const u_char *)dp + MPADVLEN,
length - MPADVLEN);
}
break;
case ND_RPL_MESSAGE:
- rpl_print(ndo, dp, &dp->icmp6_data8[0], length);
+ /* plus 4, because struct icmp6_hdr contains 4 bytes of icmp payload */
+ rpl_print(ndo, dp, &dp->icmp6_data8[0], length-sizeof(struct icmp6_hdr)+4);
break;
default:
- printf(", length %u", length);
- if (vflag <= 1)
- print_unknown_data(bp,"\n\t", length);
+ ND_PRINT((ndo,", length %u", length));
+ if (ndo->ndo_vflag <= 1)
+ print_unknown_data(ndo, bp,"\n\t", length);
return;
}
- if (!vflag)
- printf(", length %u", length);
+ if (!ndo->ndo_vflag)
+ ND_PRINT((ndo,", length %u", length));
return;
trunc:
- fputs("[|icmp6]", stdout);
+ ND_PRINT((ndo, "[|icmp6]"));
}
-static struct udphdr *
-get_upperlayer(u_char *bp, u_int *prot)
+static const struct udphdr *
+get_upperlayer(netdissect_options *ndo, const u_char *bp, u_int *prot)
{
const u_char *ep;
- struct ip6_hdr *ip6 = (struct ip6_hdr *)bp;
- struct udphdr *uh;
- struct ip6_hbh *hbh;
- struct ip6_frag *fragh;
- struct ah *ah;
+ const struct ip6_hdr *ip6 = (const struct ip6_hdr *)bp;
+ const struct udphdr *uh;
+ const struct ip6_hbh *hbh;
+ const struct ip6_frag *fragh;
+ const struct ah *ah;
u_int nh;
int hlen;
/* 'ep' points to the end of available data. */
- ep = snapend;
+ ep = ndo->ndo_snapend;
- if (!TTEST(ip6->ip6_nxt))
+ if (!ND_TTEST(ip6->ip6_nxt))
return NULL;
nh = ip6->ip6_nxt;
@@ -620,8 +1191,8 @@ get_upperlayer(u_char *bp, u_int *prot)
switch(nh) {
case IPPROTO_UDP:
case IPPROTO_TCP:
- uh = (struct udphdr *)bp;
- if (TTEST(uh->uh_dport)) {
+ uh = (const struct udphdr *)bp;
+ if (ND_TTEST(uh->uh_dport)) {
*prot = nh;
return(uh);
}
@@ -632,16 +1203,16 @@ get_upperlayer(u_char *bp, u_int *prot)
case IPPROTO_HOPOPTS:
case IPPROTO_DSTOPTS:
case IPPROTO_ROUTING:
- hbh = (struct ip6_hbh *)bp;
- if (!TTEST(hbh->ip6h_len))
+ hbh = (const struct ip6_hbh *)bp;
+ if (!ND_TTEST(hbh->ip6h_len))
return(NULL);
nh = hbh->ip6h_nxt;
hlen = (hbh->ip6h_len + 1) << 3;
break;
case IPPROTO_FRAGMENT: /* this should be odd, but try anyway */
- fragh = (struct ip6_frag *)bp;
- if (!TTEST(fragh->ip6f_offlg))
+ fragh = (const struct ip6_frag *)bp;
+ if (!ND_TTEST(fragh->ip6f_offlg))
return(NULL);
/* fragments with non-zero offset are meaningless */
if ((EXTRACT_16BITS(&fragh->ip6f_offlg) & IP6F_OFF_MASK) != 0)
@@ -651,8 +1222,8 @@ get_upperlayer(u_char *bp, u_int *prot)
break;
case IPPROTO_AH:
- ah = (struct ah *)bp;
- if (!TTEST(ah->ah_len))
+ ah = (const struct ah *)bp;
+ if (!ND_TTEST(ah->ah_len))
return(NULL);
nh = ah->ah_nxt;
hlen = (ah->ah_len + 2) << 2;
@@ -668,12 +1239,10 @@ get_upperlayer(u_char *bp, u_int *prot)
}
static void
-icmp6_opt_print(const u_char *bp, int resid)
+icmp6_opt_print(netdissect_options *ndo, const u_char *bp, int resid)
{
const struct nd_opt_hdr *op;
- const struct nd_opt_hdr *opl; /* why there's no struct? */
const struct nd_opt_prefix_info *opp;
- const struct icmp6_opts_redirect *opr;
const struct nd_opt_mtu *opm;
const struct nd_opt_rdnss *oprd;
const struct nd_opt_dnssl *opds;
@@ -681,18 +1250,19 @@ icmp6_opt_print(const u_char *bp, int resid)
const struct nd_opt_homeagent_info *oph;
const struct nd_opt_route_info *opri;
const u_char *cp, *ep, *domp;
- struct in6_addr in6, *in6p;
+ struct in6_addr in6;
+ const struct in6_addr *in6p;
size_t l;
u_int i;
-#define ECHECK(var) if ((u_char *)&(var) > ep - sizeof(var)) return
+#define ECHECK(var) if ((const u_char *)&(var) > ep - sizeof(var)) return
cp = bp;
/* 'ep' points to the end of available data. */
- ep = snapend;
+ ep = ndo->ndo_snapend;
while (cp < ep) {
- op = (struct nd_opt_hdr *)cp;
+ op = (const struct nd_opt_hdr *)cp;
ECHECK(op->nd_opt_len);
if (resid <= 0)
@@ -702,116 +1272,113 @@ icmp6_opt_print(const u_char *bp, int resid)
if (cp + (op->nd_opt_len << 3) > ep)
goto trunc;
- printf("\n\t %s option (%u), length %u (%u): ",
- tok2str(icmp6_opt_values, "unknown", op->nd_opt_type),
- op->nd_opt_type,
- op->nd_opt_len << 3,
- op->nd_opt_len);
+ ND_PRINT((ndo,"\n\t %s option (%u), length %u (%u): ",
+ tok2str(icmp6_opt_values, "unknown", op->nd_opt_type),
+ op->nd_opt_type,
+ op->nd_opt_len << 3,
+ op->nd_opt_len));
switch (op->nd_opt_type) {
case ND_OPT_SOURCE_LINKADDR:
- opl = (struct nd_opt_hdr *)op;
l = (op->nd_opt_len << 3) - 2;
- print_lladdr(cp + 2, l);
+ print_lladdr(ndo, cp + 2, l);
break;
case ND_OPT_TARGET_LINKADDR:
- opl = (struct nd_opt_hdr *)op;
l = (op->nd_opt_len << 3) - 2;
- print_lladdr(cp + 2, l);
+ print_lladdr(ndo, cp + 2, l);
break;
case ND_OPT_PREFIX_INFORMATION:
- opp = (struct nd_opt_prefix_info *)op;
- TCHECK(opp->nd_opt_pi_prefix);
- printf("%s/%u%s, Flags [%s], valid time %s",
- ip6addr_string(&opp->nd_opt_pi_prefix),
- opp->nd_opt_pi_prefix_len,
- (op->nd_opt_len != 4) ? "badlen" : "",
- bittok2str(icmp6_opt_pi_flag_values, "none", opp->nd_opt_pi_flags_reserved),
- get_lifetime(EXTRACT_32BITS(&opp->nd_opt_pi_valid_time)));
- printf(", pref. time %s", get_lifetime(EXTRACT_32BITS(&opp->nd_opt_pi_preferred_time)));
+ opp = (const struct nd_opt_prefix_info *)op;
+ ND_TCHECK(opp->nd_opt_pi_prefix);
+ ND_PRINT((ndo,"%s/%u%s, Flags [%s], valid time %s",
+ ip6addr_string(ndo, &opp->nd_opt_pi_prefix),
+ opp->nd_opt_pi_prefix_len,
+ (op->nd_opt_len != 4) ? "badlen" : "",
+ bittok2str(icmp6_opt_pi_flag_values, "none", opp->nd_opt_pi_flags_reserved),
+ get_lifetime(EXTRACT_32BITS(&opp->nd_opt_pi_valid_time))));
+ ND_PRINT((ndo,", pref. time %s", get_lifetime(EXTRACT_32BITS(&opp->nd_opt_pi_preferred_time))));
break;
case ND_OPT_REDIRECTED_HEADER:
- opr = (struct icmp6_opts_redirect *)op;
- print_unknown_data(bp,"\n\t ",op->nd_opt_len<<3);
+ print_unknown_data(ndo, bp,"\n\t ",op->nd_opt_len<<3);
/* xxx */
break;
case ND_OPT_MTU:
- opm = (struct nd_opt_mtu *)op;
- TCHECK(opm->nd_opt_mtu_mtu);
- printf(" %u%s",
+ opm = (const struct nd_opt_mtu *)op;
+ ND_TCHECK(opm->nd_opt_mtu_mtu);
+ ND_PRINT((ndo," %u%s",
EXTRACT_32BITS(&opm->nd_opt_mtu_mtu),
- (op->nd_opt_len != 1) ? "bad option length" : "" );
+ (op->nd_opt_len != 1) ? "bad option length" : "" ));
break;
case ND_OPT_RDNSS:
- oprd = (struct nd_opt_rdnss *)op;
+ oprd = (const struct nd_opt_rdnss *)op;
l = (op->nd_opt_len - 1) / 2;
- printf(" lifetime %us,",
- EXTRACT_32BITS(&oprd->nd_opt_rdnss_lifetime));
+ ND_PRINT((ndo," lifetime %us,",
+ EXTRACT_32BITS(&oprd->nd_opt_rdnss_lifetime)));
for (i = 0; i < l; i++) {
- TCHECK(oprd->nd_opt_rdnss_addr[i]);
- printf(" addr: %s",
- ip6addr_string(&oprd->nd_opt_rdnss_addr[i]));
+ ND_TCHECK(oprd->nd_opt_rdnss_addr[i]);
+ ND_PRINT((ndo," addr: %s",
+ ip6addr_string(ndo, &oprd->nd_opt_rdnss_addr[i])));
}
break;
case ND_OPT_DNSSL:
- opds = (struct nd_opt_dnssl *)op;
- printf(" lifetime %us, domain(s):",
- EXTRACT_32BITS(&opds->nd_opt_dnssl_lifetime));
+ opds = (const struct nd_opt_dnssl *)op;
+ ND_PRINT((ndo," lifetime %us, domain(s):",
+ EXTRACT_32BITS(&opds->nd_opt_dnssl_lifetime)));
domp = cp + 8; /* domain names, variable-sized, RFC1035-encoded */
while (domp < cp + (op->nd_opt_len << 3) && *domp != '\0')
{
- printf (" ");
- if ((domp = ns_nprint (domp, bp)) == NULL)
+ ND_PRINT((ndo, " "));
+ if ((domp = ns_nprint (ndo, domp, bp)) == NULL)
goto trunc;
}
break;
case ND_OPT_ADVINTERVAL:
- opa = (struct nd_opt_advinterval *)op;
- TCHECK(opa->nd_opt_adv_interval);
- printf(" %ums", EXTRACT_32BITS(&opa->nd_opt_adv_interval));
+ opa = (const struct nd_opt_advinterval *)op;
+ ND_TCHECK(opa->nd_opt_adv_interval);
+ ND_PRINT((ndo," %ums", EXTRACT_32BITS(&opa->nd_opt_adv_interval)));
break;
- case ND_OPT_HOMEAGENT_INFO:
- oph = (struct nd_opt_homeagent_info *)op;
- TCHECK(oph->nd_opt_hai_lifetime);
- printf(" preference %u, lifetime %u",
- EXTRACT_16BITS(&oph->nd_opt_hai_preference),
- EXTRACT_16BITS(&oph->nd_opt_hai_lifetime));
+ case ND_OPT_HOMEAGENT_INFO:
+ oph = (const struct nd_opt_homeagent_info *)op;
+ ND_TCHECK(oph->nd_opt_hai_lifetime);
+ ND_PRINT((ndo," preference %u, lifetime %u",
+ EXTRACT_16BITS(&oph->nd_opt_hai_preference),
+ EXTRACT_16BITS(&oph->nd_opt_hai_lifetime)));
break;
case ND_OPT_ROUTE_INFO:
- opri = (struct nd_opt_route_info *)op;
- TCHECK(opri->nd_opt_rti_lifetime);
+ opri = (const struct nd_opt_route_info *)op;
+ ND_TCHECK(opri->nd_opt_rti_lifetime);
memset(&in6, 0, sizeof(in6));
- in6p = (struct in6_addr *)(opri + 1);
+ in6p = (const struct in6_addr *)(opri + 1);
switch (op->nd_opt_len) {
case 1:
break;
case 2:
- TCHECK2(*in6p, 8);
+ ND_TCHECK2(*in6p, 8);
memcpy(&in6, opri + 1, 8);
break;
case 3:
- TCHECK(*in6p);
+ ND_TCHECK(*in6p);
memcpy(&in6, opri + 1, sizeof(in6));
break;
default:
goto trunc;
}
- printf(" %s/%u", ip6addr_string(&in6),
- opri->nd_opt_rti_prefixlen);
- printf(", pref=%s", get_rtpref(opri->nd_opt_rti_flags));
- printf(", lifetime=%s",
- get_lifetime(EXTRACT_32BITS(&opri->nd_opt_rti_lifetime)));
+ ND_PRINT((ndo," %s/%u", ip6addr_string(ndo, &in6),
+ opri->nd_opt_rti_prefixlen));
+ ND_PRINT((ndo,", pref=%s", get_rtpref(opri->nd_opt_rti_flags)));
+ ND_PRINT((ndo,", lifetime=%s",
+ get_lifetime(EXTRACT_32BITS(&opri->nd_opt_rti_lifetime))));
break;
default:
- if (vflag <= 1) {
- print_unknown_data(cp+2,"\n\t ", (op->nd_opt_len << 3) - 2); /* skip option header */
+ if (ndo->ndo_vflag <= 1) {
+ print_unknown_data(ndo,cp+2,"\n\t ", (op->nd_opt_len << 3) - 2); /* skip option header */
return;
}
break;
}
/* do we want to see an additional hexdump ? */
- if (vflag> 1)
- print_unknown_data(cp+2,"\n\t ", (op->nd_opt_len << 3) - 2); /* skip option header */
+ if (ndo->ndo_vflag> 1)
+ print_unknown_data(ndo, cp+2,"\n\t ", (op->nd_opt_len << 3) - 2); /* skip option header */
cp += op->nd_opt_len << 3;
resid -= op->nd_opt_len << 3;
@@ -819,89 +1386,89 @@ icmp6_opt_print(const u_char *bp, int resid)
return;
trunc:
- fputs("[ndp opt]", stdout);
+ ND_PRINT((ndo, "[ndp opt]"));
return;
#undef ECHECK
}
static void
-mld6_print(const u_char *bp)
+mld6_print(netdissect_options *ndo, const u_char *bp)
{
- struct mld6_hdr *mp = (struct mld6_hdr *)bp;
+ const struct mld6_hdr *mp = (const struct mld6_hdr *)bp;
const u_char *ep;
/* 'ep' points to the end of available data. */
- ep = snapend;
+ ep = ndo->ndo_snapend;
- if ((u_char *)mp + sizeof(*mp) > ep)
+ if ((const u_char *)mp + sizeof(*mp) > ep)
return;
- printf("max resp delay: %d ", EXTRACT_16BITS(&mp->mld6_maxdelay));
- printf("addr: %s", ip6addr_string(&mp->mld6_addr));
+ ND_PRINT((ndo,"max resp delay: %d ", EXTRACT_16BITS(&mp->mld6_maxdelay)));
+ ND_PRINT((ndo,"addr: %s", ip6addr_string(ndo, &mp->mld6_addr)));
}
static void
-mldv2_report_print(const u_char *bp, u_int len)
+mldv2_report_print(netdissect_options *ndo, const u_char *bp, u_int len)
{
- struct icmp6_hdr *icp = (struct icmp6_hdr *) bp;
+ const struct icmp6_hdr *icp = (const struct icmp6_hdr *) bp;
u_int group, nsrcs, ngroups;
u_int i, j;
/* Minimum len is 8 */
if (len < 8) {
- printf(" [invalid len %d]", len);
- return;
+ ND_PRINT((ndo," [invalid len %d]", len));
+ return;
}
- TCHECK(icp->icmp6_data16[1]);
+ ND_TCHECK(icp->icmp6_data16[1]);
ngroups = EXTRACT_16BITS(&icp->icmp6_data16[1]);
- printf(", %d group record(s)", ngroups);
- if (vflag > 0) {
+ ND_PRINT((ndo,", %d group record(s)", ngroups));
+ if (ndo->ndo_vflag > 0) {
/* Print the group records */
group = 8;
for (i = 0; i < ngroups; i++) {
/* type(1) + auxlen(1) + numsrc(2) + grp(16) */
if (len < group + 20) {
- printf(" [invalid number of groups]");
- return;
+ ND_PRINT((ndo," [invalid number of groups]"));
+ return;
}
- TCHECK2(bp[group + 4], sizeof(struct in6_addr));
- printf(" [gaddr %s", ip6addr_string(&bp[group + 4]));
- printf(" %s", tok2str(mldv2report2str, " [v2-report-#%d]",
- bp[group]));
+ ND_TCHECK2(bp[group + 4], sizeof(struct in6_addr));
+ ND_PRINT((ndo," [gaddr %s", ip6addr_string(ndo, &bp[group + 4])));
+ ND_PRINT((ndo," %s", tok2str(mldv2report2str, " [v2-report-#%d]",
+ bp[group])));
nsrcs = (bp[group + 2] << 8) + bp[group + 3];
/* Check the number of sources and print them */
if (len < group + 20 + (nsrcs * sizeof(struct in6_addr))) {
- printf(" [invalid number of sources %d]", nsrcs);
- return;
+ ND_PRINT((ndo," [invalid number of sources %d]", nsrcs));
+ return;
}
- if (vflag == 1)
- printf(", %d source(s)", nsrcs);
+ if (ndo->ndo_vflag == 1)
+ ND_PRINT((ndo,", %d source(s)", nsrcs));
else {
/* Print the sources */
- (void)printf(" {");
+ ND_PRINT((ndo," {"));
for (j = 0; j < nsrcs; j++) {
- TCHECK2(bp[group + 20 + j * sizeof(struct in6_addr)],
+ ND_TCHECK2(bp[group + 20 + j * sizeof(struct in6_addr)],
sizeof(struct in6_addr));
- printf(" %s", ip6addr_string(&bp[group + 20 + j * sizeof(struct in6_addr)]));
+ ND_PRINT((ndo," %s", ip6addr_string(ndo, &bp[group + 20 + j * sizeof(struct in6_addr)])));
}
- (void)printf(" }");
+ ND_PRINT((ndo," }"));
}
/* Next group record */
group += 20 + nsrcs * sizeof(struct in6_addr);
- printf("]");
+ ND_PRINT((ndo,"]"));
}
}
return;
trunc:
- (void)printf("[|icmp6]");
+ ND_PRINT((ndo,"[|icmp6]"));
return;
}
static void
-mldv2_query_print(const u_char *bp, u_int len)
+mldv2_query_print(netdissect_options *ndo, const u_char *bp, u_int len)
{
- struct icmp6_hdr *icp = (struct icmp6_hdr *) bp;
+ const struct icmp6_hdr *icp = (const struct icmp6_hdr *) bp;
u_int mrc;
int mrt, qqi;
u_int nsrcs;
@@ -909,480 +1476,486 @@ mldv2_query_print(const u_char *bp, u_int len)
/* Minimum len is 28 */
if (len < 28) {
- printf(" [invalid len %d]", len);
+ ND_PRINT((ndo," [invalid len %d]", len));
return;
}
- TCHECK(icp->icmp6_data16[0]);
+ ND_TCHECK(icp->icmp6_data16[0]);
mrc = EXTRACT_16BITS(&icp->icmp6_data16[0]);
if (mrc < 32768) {
mrt = mrc;
} else {
mrt = ((mrc & 0x0fff) | 0x1000) << (((mrc & 0x7000) >> 12) + 3);
}
- if (vflag) {
- (void)printf(" [max resp delay=%d]", mrt);
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo," [max resp delay=%d]", mrt));
}
- TCHECK2(bp[8], sizeof(struct in6_addr));
- printf(" [gaddr %s", ip6addr_string(&bp[8]));
+ ND_TCHECK2(bp[8], sizeof(struct in6_addr));
+ ND_PRINT((ndo," [gaddr %s", ip6addr_string(ndo, &bp[8])));
- if (vflag) {
- TCHECK(bp[25]);
+ if (ndo->ndo_vflag) {
+ ND_TCHECK(bp[25]);
if (bp[24] & 0x08) {
- printf(" sflag");
+ ND_PRINT((ndo," sflag"));
}
if (bp[24] & 0x07) {
- printf(" robustness=%d", bp[24] & 0x07);
+ ND_PRINT((ndo," robustness=%d", bp[24] & 0x07));
}
if (bp[25] < 128) {
qqi = bp[25];
} else {
qqi = ((bp[25] & 0x0f) | 0x10) << (((bp[25] & 0x70) >> 4) + 3);
}
- printf(" qqi=%d", qqi);
+ ND_PRINT((ndo," qqi=%d", qqi));
}
- TCHECK2(bp[26], 2);
+ ND_TCHECK2(bp[26], 2);
nsrcs = EXTRACT_16BITS(&bp[26]);
if (nsrcs > 0) {
if (len < 28 + nsrcs * sizeof(struct in6_addr))
- printf(" [invalid number of sources]");
- else if (vflag > 1) {
- printf(" {");
+ ND_PRINT((ndo," [invalid number of sources]"));
+ else if (ndo->ndo_vflag > 1) {
+ ND_PRINT((ndo," {"));
for (i = 0; i < nsrcs; i++) {
- TCHECK2(bp[28 + i * sizeof(struct in6_addr)],
+ ND_TCHECK2(bp[28 + i * sizeof(struct in6_addr)],
sizeof(struct in6_addr));
- printf(" %s", ip6addr_string(&bp[28 + i * sizeof(struct in6_addr)]));
+ ND_PRINT((ndo," %s", ip6addr_string(ndo, &bp[28 + i * sizeof(struct in6_addr)])));
}
- printf(" }");
+ ND_PRINT((ndo," }"));
} else
- printf(", %d source(s)", nsrcs);
+ ND_PRINT((ndo,", %d source(s)", nsrcs));
}
- printf("]");
+ ND_PRINT((ndo,"]"));
return;
trunc:
- (void)printf("[|icmp6]");
+ ND_PRINT((ndo,"[|icmp6]"));
return;
}
static void
-dnsname_print(const u_char *cp, const u_char *ep)
+dnsname_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
{
int i;
/* DNS name decoding - no decompression */
- printf(", \"");
+ ND_PRINT((ndo,", \""));
while (cp < ep) {
i = *cp++;
if (i) {
if (i > ep - cp) {
- printf("???");
+ ND_PRINT((ndo,"???"));
break;
}
while (i-- && cp < ep) {
- safeputchar(*cp);
+ safeputchar(ndo, *cp);
cp++;
}
if (cp + 1 < ep && *cp)
- printf(".");
+ ND_PRINT((ndo,"."));
} else {
if (cp == ep) {
/* FQDN */
- printf(".");
+ ND_PRINT((ndo,"."));
} else if (cp + 1 == ep && *cp == '\0') {
/* truncated */
} else {
/* invalid */
- printf("???");
+ ND_PRINT((ndo,"???"));
}
break;
}
}
- printf("\"");
+ ND_PRINT((ndo,"\""));
}
static void
-icmp6_nodeinfo_print(u_int icmp6len, const u_char *bp, const u_char *ep)
+icmp6_nodeinfo_print(netdissect_options *ndo, u_int icmp6len, const u_char *bp, const u_char *ep)
{
- struct icmp6_nodeinfo *ni6;
- struct icmp6_hdr *dp;
+ const struct icmp6_nodeinfo *ni6;
+ const struct icmp6_hdr *dp;
const u_char *cp;
size_t siz, i;
int needcomma;
if (ep < bp)
return;
- dp = (struct icmp6_hdr *)bp;
- ni6 = (struct icmp6_nodeinfo *)bp;
+ dp = (const struct icmp6_hdr *)bp;
+ ni6 = (const struct icmp6_nodeinfo *)bp;
siz = ep - bp;
switch (ni6->ni_type) {
case ICMP6_NI_QUERY:
if (siz == sizeof(*dp) + 4) {
/* KAME who-are-you */
- printf(" who-are-you request");
+ ND_PRINT((ndo," who-are-you request"));
break;
}
- printf(" node information query");
+ ND_PRINT((ndo," node information query"));
- TCHECK2(*dp, sizeof(*ni6));
- ni6 = (struct icmp6_nodeinfo *)dp;
- printf(" ("); /*)*/
+ ND_TCHECK2(*dp, sizeof(*ni6));
+ ni6 = (const struct icmp6_nodeinfo *)dp;
+ ND_PRINT((ndo," (")); /*)*/
switch (EXTRACT_16BITS(&ni6->ni_qtype)) {
case NI_QTYPE_NOOP:
- printf("noop");
+ ND_PRINT((ndo,"noop"));
break;
case NI_QTYPE_SUPTYPES:
- printf("supported qtypes");
+ ND_PRINT((ndo,"supported qtypes"));
i = EXTRACT_16BITS(&ni6->ni_flags);
if (i)
- printf(" [%s]", (i & 0x01) ? "C" : "");
- break;
+ ND_PRINT((ndo," [%s]", (i & 0x01) ? "C" : ""));
break;
case NI_QTYPE_FQDN:
- printf("DNS name");
+ ND_PRINT((ndo,"DNS name"));
break;
case NI_QTYPE_NODEADDR:
- printf("node addresses");
+ ND_PRINT((ndo,"node addresses"));
i = ni6->ni_flags;
if (!i)
break;
/* NI_NODEADDR_FLAG_TRUNCATE undefined for query */
- printf(" [%s%s%s%s%s%s]",
+ ND_PRINT((ndo," [%s%s%s%s%s%s]",
(i & NI_NODEADDR_FLAG_ANYCAST) ? "a" : "",
(i & NI_NODEADDR_FLAG_GLOBAL) ? "G" : "",
(i & NI_NODEADDR_FLAG_SITELOCAL) ? "S" : "",
(i & NI_NODEADDR_FLAG_LINKLOCAL) ? "L" : "",
(i & NI_NODEADDR_FLAG_COMPAT) ? "C" : "",
- (i & NI_NODEADDR_FLAG_ALL) ? "A" : "");
+ (i & NI_NODEADDR_FLAG_ALL) ? "A" : ""));
break;
default:
- printf("unknown");
+ ND_PRINT((ndo,"unknown"));
break;
}
if (ni6->ni_qtype == NI_QTYPE_NOOP ||
ni6->ni_qtype == NI_QTYPE_SUPTYPES) {
if (siz != sizeof(*ni6))
- if (vflag)
- printf(", invalid len");
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo,", invalid len"));
/*(*/
- printf(")");
+ ND_PRINT((ndo,")"));
break;
}
/* XXX backward compat, icmp-name-lookup-03 */
if (siz == sizeof(*ni6)) {
- printf(", 03 draft");
+ ND_PRINT((ndo,", 03 draft"));
/*(*/
- printf(")");
+ ND_PRINT((ndo,")"));
break;
}
switch (ni6->ni_code) {
case ICMP6_NI_SUBJ_IPV6:
- if (!TTEST2(*dp,
+ if (!ND_TTEST2(*dp,
sizeof(*ni6) + sizeof(struct in6_addr)))
break;
if (siz != sizeof(*ni6) + sizeof(struct in6_addr)) {
- if (vflag)
- printf(", invalid subject len");
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo,", invalid subject len"));
break;
}
- printf(", subject=%s",
- getname6((const u_char *)(ni6 + 1)));
+ ND_PRINT((ndo,", subject=%s",
+ ip6addr_string(ndo, ni6 + 1)));
break;
case ICMP6_NI_SUBJ_FQDN:
- printf(", subject=DNS name");
+ ND_PRINT((ndo,", subject=DNS name"));
cp = (const u_char *)(ni6 + 1);
if (cp[0] == ep - cp - 1) {
/* icmp-name-lookup-03, pascal string */
- if (vflag)
- printf(", 03 draft");
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo,", 03 draft"));
cp++;
- printf(", \"");
+ ND_PRINT((ndo,", \""));
while (cp < ep) {
- safeputchar(*cp);
+ safeputchar(ndo, *cp);
cp++;
}
- printf("\"");
+ ND_PRINT((ndo,"\""));
} else
- dnsname_print(cp, ep);
+ dnsname_print(ndo, cp, ep);
break;
case ICMP6_NI_SUBJ_IPV4:
- if (!TTEST2(*dp, sizeof(*ni6) + sizeof(struct in_addr)))
+ if (!ND_TTEST2(*dp, sizeof(*ni6) + sizeof(struct in_addr)))
break;
if (siz != sizeof(*ni6) + sizeof(struct in_addr)) {
- if (vflag)
- printf(", invalid subject len");
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo,", invalid subject len"));
break;
}
- printf(", subject=%s",
- getname((const u_char *)(ni6 + 1)));
+ ND_PRINT((ndo,", subject=%s",
+ ipaddr_string(ndo, ni6 + 1)));
break;
default:
- printf(", unknown subject");
+ ND_PRINT((ndo,", unknown subject"));
break;
}
/*(*/
- printf(")");
+ ND_PRINT((ndo,")"));
break;
case ICMP6_NI_REPLY:
if (icmp6len > siz) {
- printf("[|icmp6: node information reply]");
+ ND_PRINT((ndo,"[|icmp6: node information reply]"));
break;
}
needcomma = 0;
- ni6 = (struct icmp6_nodeinfo *)dp;
- printf(" node information reply");
- printf(" ("); /*)*/
+ ni6 = (const struct icmp6_nodeinfo *)dp;
+ ND_PRINT((ndo," node information reply"));
+ ND_PRINT((ndo," (")); /*)*/
switch (ni6->ni_code) {
case ICMP6_NI_SUCCESS:
- if (vflag) {
- printf("success");
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo,"success"));
needcomma++;
}
break;
case ICMP6_NI_REFUSED:
- printf("refused");
+ ND_PRINT((ndo,"refused"));
needcomma++;
if (siz != sizeof(*ni6))
- if (vflag)
- printf(", invalid length");
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo,", invalid length"));
break;
case ICMP6_NI_UNKNOWN:
- printf("unknown");
+ ND_PRINT((ndo,"unknown"));
needcomma++;
if (siz != sizeof(*ni6))
- if (vflag)
- printf(", invalid length");
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo,", invalid length"));
break;
}
if (ni6->ni_code != ICMP6_NI_SUCCESS) {
/*(*/
- printf(")");
+ ND_PRINT((ndo,")"));
break;
}
switch (EXTRACT_16BITS(&ni6->ni_qtype)) {
case NI_QTYPE_NOOP:
if (needcomma)
- printf(", ");
- printf("noop");
+ ND_PRINT((ndo,", "));
+ ND_PRINT((ndo,"noop"));
if (siz != sizeof(*ni6))
- if (vflag)
- printf(", invalid length");
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo,", invalid length"));
break;
case NI_QTYPE_SUPTYPES:
if (needcomma)
- printf(", ");
- printf("supported qtypes");
+ ND_PRINT((ndo,", "));
+ ND_PRINT((ndo,"supported qtypes"));
i = EXTRACT_16BITS(&ni6->ni_flags);
if (i)
- printf(" [%s]", (i & 0x01) ? "C" : "");
+ ND_PRINT((ndo," [%s]", (i & 0x01) ? "C" : ""));
break;
case NI_QTYPE_FQDN:
if (needcomma)
- printf(", ");
- printf("DNS name");
+ ND_PRINT((ndo,", "));
+ ND_PRINT((ndo,"DNS name"));
cp = (const u_char *)(ni6 + 1) + 4;
if (cp[0] == ep - cp - 1) {
/* icmp-name-lookup-03, pascal string */
- if (vflag)
- printf(", 03 draft");
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo,", 03 draft"));
cp++;
- printf(", \"");
+ ND_PRINT((ndo,", \""));
while (cp < ep) {
- safeputchar(*cp);
+ safeputchar(ndo, *cp);
cp++;
}
- printf("\"");
+ ND_PRINT((ndo,"\""));
} else
- dnsname_print(cp, ep);
+ dnsname_print(ndo, cp, ep);
if ((EXTRACT_16BITS(&ni6->ni_flags) & 0x01) != 0)
- printf(" [TTL=%u]", *(u_int32_t *)(ni6 + 1));
+ ND_PRINT((ndo," [TTL=%u]", EXTRACT_32BITS(ni6 + 1)));
break;
case NI_QTYPE_NODEADDR:
if (needcomma)
- printf(", ");
- printf("node addresses");
+ ND_PRINT((ndo,", "));
+ ND_PRINT((ndo,"node addresses"));
i = sizeof(*ni6);
while (i < siz) {
if (i + sizeof(struct in6_addr) + sizeof(int32_t) > siz)
break;
- printf(" %s", getname6(bp + i));
+ ND_PRINT((ndo," %s", ip6addr_string(ndo, bp + i)));
i += sizeof(struct in6_addr);
- printf("(%d)", (int32_t)EXTRACT_32BITS(bp + i));
+ ND_PRINT((ndo,"(%d)", (int32_t)EXTRACT_32BITS(bp + i)));
i += sizeof(int32_t);
}
i = ni6->ni_flags;
if (!i)
break;
- printf(" [%s%s%s%s%s%s%s]",
- (i & NI_NODEADDR_FLAG_ANYCAST) ? "a" : "",
- (i & NI_NODEADDR_FLAG_GLOBAL) ? "G" : "",
- (i & NI_NODEADDR_FLAG_SITELOCAL) ? "S" : "",
- (i & NI_NODEADDR_FLAG_LINKLOCAL) ? "L" : "",
- (i & NI_NODEADDR_FLAG_COMPAT) ? "C" : "",
- (i & NI_NODEADDR_FLAG_ALL) ? "A" : "",
- (i & NI_NODEADDR_FLAG_TRUNCATE) ? "T" : "");
+ ND_PRINT((ndo," [%s%s%s%s%s%s%s]",
+ (i & NI_NODEADDR_FLAG_ANYCAST) ? "a" : "",
+ (i & NI_NODEADDR_FLAG_GLOBAL) ? "G" : "",
+ (i & NI_NODEADDR_FLAG_SITELOCAL) ? "S" : "",
+ (i & NI_NODEADDR_FLAG_LINKLOCAL) ? "L" : "",
+ (i & NI_NODEADDR_FLAG_COMPAT) ? "C" : "",
+ (i & NI_NODEADDR_FLAG_ALL) ? "A" : "",
+ (i & NI_NODEADDR_FLAG_TRUNCATE) ? "T" : ""));
break;
default:
if (needcomma)
- printf(", ");
- printf("unknown");
+ ND_PRINT((ndo,", "));
+ ND_PRINT((ndo,"unknown"));
break;
}
/*(*/
- printf(")");
+ ND_PRINT((ndo,")"));
break;
}
return;
trunc:
- fputs("[|icmp6]", stdout);
+ ND_PRINT((ndo, "[|icmp6]"));
}
static void
-icmp6_rrenum_print(const u_char *bp, const u_char *ep)
+icmp6_rrenum_print(netdissect_options *ndo, const u_char *bp, const u_char *ep)
{
- struct icmp6_router_renum *rr6;
+ const struct icmp6_router_renum *rr6;
const char *cp;
- struct rr_pco_match *match;
- struct rr_pco_use *use;
+ const struct rr_pco_match *match;
+ const struct rr_pco_use *use;
char hbuf[NI_MAXHOST];
int n;
if (ep < bp)
return;
- rr6 = (struct icmp6_router_renum *)bp;
+ rr6 = (const struct icmp6_router_renum *)bp;
cp = (const char *)(rr6 + 1);
- TCHECK(rr6->rr_reserved);
+ ND_TCHECK(rr6->rr_reserved);
switch (rr6->rr_code) {
case ICMP6_ROUTER_RENUMBERING_COMMAND:
- printf("router renum: command");
+ ND_PRINT((ndo,"router renum: command"));
break;
case ICMP6_ROUTER_RENUMBERING_RESULT:
- printf("router renum: result");
+ ND_PRINT((ndo,"router renum: result"));
break;
case ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET:
- printf("router renum: sequence number reset");
+ ND_PRINT((ndo,"router renum: sequence number reset"));
break;
default:
- printf("router renum: code-#%d", rr6->rr_code);
+ ND_PRINT((ndo,"router renum: code-#%d", rr6->rr_code));
break;
}
- printf(", seq=%u", EXTRACT_32BITS(&rr6->rr_seqnum));
+ ND_PRINT((ndo,", seq=%u", EXTRACT_32BITS(&rr6->rr_seqnum)));
- if (vflag) {
+ if (ndo->ndo_vflag) {
#define F(x, y) ((rr6->rr_flags) & (x) ? (y) : "")
- printf("["); /*]*/
+ ND_PRINT((ndo,"[")); /*]*/
if (rr6->rr_flags) {
- printf("%s%s%s%s%s,", F(ICMP6_RR_FLAGS_TEST, "T"),
- F(ICMP6_RR_FLAGS_REQRESULT, "R"),
- F(ICMP6_RR_FLAGS_FORCEAPPLY, "A"),
- F(ICMP6_RR_FLAGS_SPECSITE, "S"),
- F(ICMP6_RR_FLAGS_PREVDONE, "P"));
+ ND_PRINT((ndo,"%s%s%s%s%s,", F(ICMP6_RR_FLAGS_TEST, "T"),
+ F(ICMP6_RR_FLAGS_REQRESULT, "R"),
+ F(ICMP6_RR_FLAGS_FORCEAPPLY, "A"),
+ F(ICMP6_RR_FLAGS_SPECSITE, "S"),
+ F(ICMP6_RR_FLAGS_PREVDONE, "P")));
}
- printf("seg=%u,", rr6->rr_segnum);
- printf("maxdelay=%u", EXTRACT_16BITS(&rr6->rr_maxdelay));
+ ND_PRINT((ndo,"seg=%u,", rr6->rr_segnum));
+ ND_PRINT((ndo,"maxdelay=%u", EXTRACT_16BITS(&rr6->rr_maxdelay)));
if (rr6->rr_reserved)
- printf("rsvd=0x%x", EXTRACT_32BITS(&rr6->rr_reserved));
+ ND_PRINT((ndo,"rsvd=0x%x", EXTRACT_32BITS(&rr6->rr_reserved)));
/*[*/
- printf("]");
+ ND_PRINT((ndo,"]"));
#undef F
}
if (rr6->rr_code == ICMP6_ROUTER_RENUMBERING_COMMAND) {
- match = (struct rr_pco_match *)cp;
+ match = (const struct rr_pco_match *)cp;
cp = (const char *)(match + 1);
- TCHECK(match->rpm_prefix);
+ ND_TCHECK(match->rpm_prefix);
- if (vflag > 1)
- printf("\n\t");
+ if (ndo->ndo_vflag > 1)
+ ND_PRINT((ndo,"\n\t"));
else
- printf(" ");
- printf("match("); /*)*/
+ ND_PRINT((ndo," "));
+ ND_PRINT((ndo,"match(")); /*)*/
switch (match->rpm_code) {
- case RPM_PCO_ADD: printf("add"); break;
- case RPM_PCO_CHANGE: printf("change"); break;
- case RPM_PCO_SETGLOBAL: printf("setglobal"); break;
- default: printf("#%u", match->rpm_code); break;
+ case RPM_PCO_ADD: ND_PRINT((ndo,"add")); break;
+ case RPM_PCO_CHANGE: ND_PRINT((ndo,"change")); break;
+ case RPM_PCO_SETGLOBAL: ND_PRINT((ndo,"setglobal")); break;
+ default: ND_PRINT((ndo,"#%u", match->rpm_code)); break;
}
- if (vflag) {
- printf(",ord=%u", match->rpm_ordinal);
- printf(",min=%u", match->rpm_minlen);
- printf(",max=%u", match->rpm_maxlen);
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo,",ord=%u", match->rpm_ordinal));
+ ND_PRINT((ndo,",min=%u", match->rpm_minlen));
+ ND_PRINT((ndo,",max=%u", match->rpm_maxlen));
}
- if (inet_ntop(AF_INET6, &match->rpm_prefix, hbuf, sizeof(hbuf)))
- printf(",%s/%u", hbuf, match->rpm_matchlen);
+ if (addrtostr6(&match->rpm_prefix, hbuf, sizeof(hbuf)))
+ ND_PRINT((ndo,",%s/%u", hbuf, match->rpm_matchlen));
else
- printf(",?/%u", match->rpm_matchlen);
+ ND_PRINT((ndo,",?/%u", match->rpm_matchlen));
/*(*/
- printf(")");
+ ND_PRINT((ndo,")"));
n = match->rpm_len - 3;
if (n % 4)
goto trunc;
n /= 4;
while (n-- > 0) {
- use = (struct rr_pco_use *)cp;
+ use = (const struct rr_pco_use *)cp;
cp = (const char *)(use + 1);
- TCHECK(use->rpu_prefix);
+ ND_TCHECK(use->rpu_prefix);
- if (vflag > 1)
- printf("\n\t");
+ if (ndo->ndo_vflag > 1)
+ ND_PRINT((ndo,"\n\t"));
else
- printf(" ");
- printf("use("); /*)*/
+ ND_PRINT((ndo," "));
+ ND_PRINT((ndo,"use(")); /*)*/
if (use->rpu_flags) {
#define F(x, y) ((use->rpu_flags) & (x) ? (y) : "")
- printf("%s%s,",
- F(ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME, "V"),
- F(ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME, "P"));
+ ND_PRINT((ndo,"%s%s,",
+ F(ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME, "V"),
+ F(ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME, "P")));
#undef F
}
- if (vflag) {
- printf("mask=0x%x,", use->rpu_ramask);
- printf("raflags=0x%x,", use->rpu_raflags);
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo,"mask=0x%x,", use->rpu_ramask));
+ ND_PRINT((ndo,"raflags=0x%x,", use->rpu_raflags));
if (~use->rpu_vltime == 0)
- printf("vltime=infty,");
+ ND_PRINT((ndo,"vltime=infty,"));
else
- printf("vltime=%u,",
- EXTRACT_32BITS(&use->rpu_vltime));
+ ND_PRINT((ndo,"vltime=%u,",
+ EXTRACT_32BITS(&use->rpu_vltime)));
if (~use->rpu_pltime == 0)
- printf("pltime=infty,");
+ ND_PRINT((ndo,"pltime=infty,"));
else
- printf("pltime=%u,",
- EXTRACT_32BITS(&use->rpu_pltime));
+ ND_PRINT((ndo,"pltime=%u,",
+ EXTRACT_32BITS(&use->rpu_pltime)));
}
- if (inet_ntop(AF_INET6, &use->rpu_prefix, hbuf,
- sizeof(hbuf)))
- printf("%s/%u/%u", hbuf, use->rpu_uselen,
- use->rpu_keeplen);
+ if (addrtostr6(&use->rpu_prefix, hbuf, sizeof(hbuf)))
+ ND_PRINT((ndo,"%s/%u/%u", hbuf, use->rpu_uselen,
+ use->rpu_keeplen));
else
- printf("?/%u/%u", use->rpu_uselen,
- use->rpu_keeplen);
+ ND_PRINT((ndo,"?/%u/%u", use->rpu_uselen,
+ use->rpu_keeplen));
/*(*/
- printf(")");
+ ND_PRINT((ndo,")"));
}
}
return;
trunc:
- fputs("[|icmp6]", stdout);
+ ND_PRINT((ndo,"[|icmp6]"));
}
-#endif /* INET6 */
+/*
+ * Local Variables:
+ * c-style: whitesmith
+ * c-basic-offset: 8
+ * End:
+ */
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-icmp6-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-igmp.c b/freebsd/contrib/tcpdump/print-igmp.c
index e2bc597e..5dd2351e 100644
--- a/freebsd/contrib/tcpdump/print-igmp.c
+++ b/freebsd/contrib/tcpdump/print-igmp.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1988, 1989, 1990, 1991, 1993, 1994, 1995, 1996
* The Regents of the University of California. All rights reserved.
@@ -21,38 +24,34 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-igmp.c,v 1.15 2004-03-24 00:59:16 guy Exp $ (LBL)";
-#endif
+/* \summary: Internet Group Management Protocol (IGMP) printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include <stdio.h>
-#include <string.h>
-
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
-#include "extract.h" /* must come after interface.h */
+#include "extract.h"
#ifndef IN_CLASSD
#define IN_CLASSD(i) (((int32_t)(i) & 0xf0000000) == 0xe0000000)
#endif
+static const char tstr[] = "[|igmp]";
+
/* (following from ipmulti/mrouted/prune.h) */
/*
* The packet format for a traceroute request.
*/
struct tr_query {
- u_int32_t tr_src; /* traceroute source */
- u_int32_t tr_dst; /* traceroute destination */
- u_int32_t tr_raddr; /* traceroute response address */
- u_int32_t tr_rttlqid; /* response ttl and qid */
+ uint32_t tr_src; /* traceroute source */
+ uint32_t tr_dst; /* traceroute destination */
+ uint32_t tr_raddr; /* traceroute response address */
+ uint32_t tr_rttlqid; /* response ttl and qid */
};
#define TR_GETTTL(x) (int)(((x) >> 24) & 0xff)
@@ -63,17 +62,17 @@ struct tr_query {
* beginning, followed by one tr_resp for each hop taken.
*/
struct tr_resp {
- u_int32_t tr_qarr; /* query arrival time */
- u_int32_t tr_inaddr; /* incoming interface address */
- u_int32_t tr_outaddr; /* outgoing interface address */
- u_int32_t tr_rmtaddr; /* parent address in source tree */
- u_int32_t tr_vifin; /* input packet count on interface */
- u_int32_t tr_vifout; /* output packet count on interface */
- u_int32_t tr_pktcnt; /* total incoming packets for src-grp */
- u_int8_t tr_rproto; /* routing proto deployed on router */
- u_int8_t tr_fttl; /* ttl required to forward on outvif */
- u_int8_t tr_smask; /* subnet mask for src addr */
- u_int8_t tr_rflags; /* forwarding error codes */
+ uint32_t tr_qarr; /* query arrival time */
+ uint32_t tr_inaddr; /* incoming interface address */
+ uint32_t tr_outaddr; /* outgoing interface address */
+ uint32_t tr_rmtaddr; /* parent address in source tree */
+ uint32_t tr_vifin; /* input packet count on interface */
+ uint32_t tr_vifout; /* output packet count on interface */
+ uint32_t tr_pktcnt; /* total incoming packets for src-grp */
+ uint8_t tr_rproto; /* routing proto deployed on router */
+ uint8_t tr_fttl; /* ttl required to forward on outvif */
+ uint8_t tr_smask; /* subnet mask for src addr */
+ uint8_t tr_rflags; /* forwarding error codes */
};
/* defs within mtrace */
@@ -98,7 +97,7 @@ struct tr_resp {
#define TR_PROTO_CBT 4
/* igmpv3 report types */
-static struct tok igmpv3report2str[] = {
+static const struct tok igmpv3report2str[] = {
{ 1, "is_in" },
{ 2, "is_ex" },
{ 3, "to_in" },
@@ -109,118 +108,119 @@ static struct tok igmpv3report2str[] = {
};
static void
-print_mtrace(register const u_char *bp, register u_int len)
+print_mtrace(netdissect_options *ndo,
+ register const u_char *bp, register u_int len)
{
register const struct tr_query *tr = (const struct tr_query *)(bp + 8);
- TCHECK(*tr);
+ ND_TCHECK(*tr);
if (len < 8 + sizeof (struct tr_query)) {
- (void)printf(" [invalid len %d]", len);
+ ND_PRINT((ndo, " [invalid len %d]", len));
return;
}
- printf("mtrace %u: %s to %s reply-to %s",
+ ND_PRINT((ndo, "mtrace %u: %s to %s reply-to %s",
TR_GETQID(EXTRACT_32BITS(&tr->tr_rttlqid)),
- ipaddr_string(&tr->tr_src), ipaddr_string(&tr->tr_dst),
- ipaddr_string(&tr->tr_raddr));
+ ipaddr_string(ndo, &tr->tr_src), ipaddr_string(ndo, &tr->tr_dst),
+ ipaddr_string(ndo, &tr->tr_raddr)));
if (IN_CLASSD(EXTRACT_32BITS(&tr->tr_raddr)))
- printf(" with-ttl %d", TR_GETTTL(EXTRACT_32BITS(&tr->tr_rttlqid)));
+ ND_PRINT((ndo, " with-ttl %d", TR_GETTTL(EXTRACT_32BITS(&tr->tr_rttlqid))));
return;
trunc:
- (void)printf("[|igmp]");
- return;
+ ND_PRINT((ndo, "%s", tstr));
}
static void
-print_mresp(register const u_char *bp, register u_int len)
+print_mresp(netdissect_options *ndo,
+ register const u_char *bp, register u_int len)
{
register const struct tr_query *tr = (const struct tr_query *)(bp + 8);
- TCHECK(*tr);
+ ND_TCHECK(*tr);
if (len < 8 + sizeof (struct tr_query)) {
- (void)printf(" [invalid len %d]", len);
+ ND_PRINT((ndo, " [invalid len %d]", len));
return;
}
- printf("mresp %lu: %s to %s reply-to %s",
+ ND_PRINT((ndo, "mresp %lu: %s to %s reply-to %s",
(u_long)TR_GETQID(EXTRACT_32BITS(&tr->tr_rttlqid)),
- ipaddr_string(&tr->tr_src), ipaddr_string(&tr->tr_dst),
- ipaddr_string(&tr->tr_raddr));
+ ipaddr_string(ndo, &tr->tr_src), ipaddr_string(ndo, &tr->tr_dst),
+ ipaddr_string(ndo, &tr->tr_raddr)));
if (IN_CLASSD(EXTRACT_32BITS(&tr->tr_raddr)))
- printf(" with-ttl %d", TR_GETTTL(EXTRACT_32BITS(&tr->tr_rttlqid)));
+ ND_PRINT((ndo, " with-ttl %d", TR_GETTTL(EXTRACT_32BITS(&tr->tr_rttlqid))));
return;
trunc:
- (void)printf("[|igmp]");
- return;
+ ND_PRINT((ndo, "%s", tstr));
}
static void
-print_igmpv3_report(register const u_char *bp, register u_int len)
+print_igmpv3_report(netdissect_options *ndo,
+ register const u_char *bp, register u_int len)
{
u_int group, nsrcs, ngroups;
register u_int i, j;
/* Minimum len is 16, and should be a multiple of 4 */
if (len < 16 || len & 0x03) {
- (void)printf(" [invalid len %d]", len);
+ ND_PRINT((ndo, " [invalid len %d]", len));
return;
}
- TCHECK2(bp[6], 2);
+ ND_TCHECK2(bp[6], 2);
ngroups = EXTRACT_16BITS(&bp[6]);
- (void)printf(", %d group record(s)", ngroups);
- if (vflag > 0) {
+ ND_PRINT((ndo, ", %d group record(s)", ngroups));
+ if (ndo->ndo_vflag > 0) {
/* Print the group records */
group = 8;
for (i=0; i<ngroups; i++) {
if (len < group+8) {
- (void)printf(" [invalid number of groups]");
+ ND_PRINT((ndo, " [invalid number of groups]"));
return;
}
- TCHECK2(bp[group+4], 4);
- (void)printf(" [gaddr %s", ipaddr_string(&bp[group+4]));
- (void)printf(" %s", tok2str(igmpv3report2str, " [v3-report-#%d]",
- bp[group]));
+ ND_TCHECK2(bp[group+4], 4);
+ ND_PRINT((ndo, " [gaddr %s", ipaddr_string(ndo, &bp[group+4])));
+ ND_PRINT((ndo, " %s", tok2str(igmpv3report2str, " [v3-report-#%d]",
+ bp[group])));
nsrcs = EXTRACT_16BITS(&bp[group+2]);
/* Check the number of sources and print them */
if (len < group+8+(nsrcs<<2)) {
- (void)printf(" [invalid number of sources %d]", nsrcs);
+ ND_PRINT((ndo, " [invalid number of sources %d]", nsrcs));
return;
}
- if (vflag == 1)
- (void)printf(", %d source(s)", nsrcs);
+ if (ndo->ndo_vflag == 1)
+ ND_PRINT((ndo, ", %d source(s)", nsrcs));
else {
/* Print the sources */
- (void)printf(" {");
+ ND_PRINT((ndo, " {"));
for (j=0; j<nsrcs; j++) {
- TCHECK2(bp[group+8+(j<<2)], 4);
- (void)printf(" %s", ipaddr_string(&bp[group+8+(j<<2)]));
+ ND_TCHECK2(bp[group+8+(j<<2)], 4);
+ ND_PRINT((ndo, " %s", ipaddr_string(ndo, &bp[group+8+(j<<2)])));
}
- (void)printf(" }");
+ ND_PRINT((ndo, " }"));
}
/* Next group record */
group += 8 + (nsrcs << 2);
- (void)printf("]");
+ ND_PRINT((ndo, "]"));
}
}
return;
trunc:
- (void)printf("[|igmp]");
- return;
+ ND_PRINT((ndo, "%s", tstr));
}
static void
-print_igmpv3_query(register const u_char *bp, register u_int len)
+print_igmpv3_query(netdissect_options *ndo,
+ register const u_char *bp, register u_int len)
{
u_int mrc;
- int mrt;
+ u_int mrt;
u_int nsrcs;
register u_int i;
- (void)printf(" v3");
+ ND_PRINT((ndo, " v3"));
/* Minimum len is 12, and should be a multiple of 4 */
if (len < 12 || len & 0x03) {
- (void)printf(" [invalid len %d]", len);
+ ND_PRINT((ndo, " [invalid len %d]", len));
return;
}
- TCHECK(bp[1]);
+ ND_TCHECK(bp[1]);
mrc = bp[1];
if (mrc < 128) {
mrt = mrc;
@@ -228,119 +228,122 @@ print_igmpv3_query(register const u_char *bp, register u_int len)
mrt = ((mrc & 0x0f) | 0x10) << (((mrc & 0x70) >> 4) + 3);
}
if (mrc != 100) {
- (void)printf(" [max resp time ");
+ ND_PRINT((ndo, " [max resp time "));
if (mrt < 600) {
- (void)printf("%.1fs", mrt * 0.1);
+ ND_PRINT((ndo, "%.1fs", mrt * 0.1));
} else {
- relts_print(mrt / 10);
+ unsigned_relts_print(ndo, mrt / 10);
}
- (void)printf("]");
+ ND_PRINT((ndo, "]"));
}
- TCHECK2(bp[4], 4);
+ ND_TCHECK2(bp[4], 4);
if (EXTRACT_32BITS(&bp[4]) == 0)
return;
- (void)printf(" [gaddr %s", ipaddr_string(&bp[4]));
- TCHECK2(bp[10], 2);
+ ND_PRINT((ndo, " [gaddr %s", ipaddr_string(ndo, &bp[4])));
+ ND_TCHECK2(bp[10], 2);
nsrcs = EXTRACT_16BITS(&bp[10]);
if (nsrcs > 0) {
if (len < 12 + (nsrcs << 2))
- (void)printf(" [invalid number of sources]");
- else if (vflag > 1) {
- (void)printf(" {");
+ ND_PRINT((ndo, " [invalid number of sources]"));
+ else if (ndo->ndo_vflag > 1) {
+ ND_PRINT((ndo, " {"));
for (i=0; i<nsrcs; i++) {
- TCHECK2(bp[12+(i<<2)], 4);
- (void)printf(" %s", ipaddr_string(&bp[12+(i<<2)]));
+ ND_TCHECK2(bp[12+(i<<2)], 4);
+ ND_PRINT((ndo, " %s", ipaddr_string(ndo, &bp[12+(i<<2)])));
}
- (void)printf(" }");
+ ND_PRINT((ndo, " }"));
} else
- (void)printf(", %d source(s)", nsrcs);
+ ND_PRINT((ndo, ", %d source(s)", nsrcs));
}
- (void)printf("]");
+ ND_PRINT((ndo, "]"));
return;
trunc:
- (void)printf("[|igmp]");
- return;
+ ND_PRINT((ndo, "%s", tstr));
}
void
-igmp_print(register const u_char *bp, register u_int len)
+igmp_print(netdissect_options *ndo,
+ register const u_char *bp, register u_int len)
{
struct cksum_vec vec[1];
- if (qflag) {
- (void)printf("igmp");
+ if (ndo->ndo_qflag) {
+ ND_PRINT((ndo, "igmp"));
return;
}
- TCHECK(bp[0]);
+ ND_TCHECK(bp[0]);
switch (bp[0]) {
case 0x11:
- (void)printf("igmp query");
+ ND_PRINT((ndo, "igmp query"));
if (len >= 12)
- print_igmpv3_query(bp, len);
+ print_igmpv3_query(ndo, bp, len);
else {
- TCHECK(bp[1]);
+ ND_TCHECK(bp[1]);
if (bp[1]) {
- (void)printf(" v2");
+ ND_PRINT((ndo, " v2"));
if (bp[1] != 100)
- (void)printf(" [max resp time %d]", bp[1]);
+ ND_PRINT((ndo, " [max resp time %d]", bp[1]));
} else
- (void)printf(" v1");
- TCHECK2(bp[4], 4);
+ ND_PRINT((ndo, " v1"));
+ ND_TCHECK2(bp[4], 4);
if (EXTRACT_32BITS(&bp[4]))
- (void)printf(" [gaddr %s]", ipaddr_string(&bp[4]));
+ ND_PRINT((ndo, " [gaddr %s]", ipaddr_string(ndo, &bp[4])));
if (len != 8)
- (void)printf(" [len %d]", len);
+ ND_PRINT((ndo, " [len %d]", len));
}
break;
case 0x12:
- TCHECK2(bp[4], 4);
- (void)printf("igmp v1 report %s", ipaddr_string(&bp[4]));
+ ND_TCHECK2(bp[4], 4);
+ ND_PRINT((ndo, "igmp v1 report %s", ipaddr_string(ndo, &bp[4])));
if (len != 8)
- (void)printf(" [len %d]", len);
+ ND_PRINT((ndo, " [len %d]", len));
break;
case 0x16:
- TCHECK2(bp[4], 4);
- (void)printf("igmp v2 report %s", ipaddr_string(&bp[4]));
+ ND_TCHECK2(bp[4], 4);
+ ND_PRINT((ndo, "igmp v2 report %s", ipaddr_string(ndo, &bp[4])));
break;
case 0x22:
- (void)printf("igmp v3 report");
- print_igmpv3_report(bp, len);
+ ND_PRINT((ndo, "igmp v3 report"));
+ print_igmpv3_report(ndo, bp, len);
break;
case 0x17:
- TCHECK2(bp[4], 4);
- (void)printf("igmp leave %s", ipaddr_string(&bp[4]));
+ ND_TCHECK2(bp[4], 4);
+ ND_PRINT((ndo, "igmp leave %s", ipaddr_string(ndo, &bp[4])));
break;
case 0x13:
- (void)printf("igmp dvmrp");
+ ND_PRINT((ndo, "igmp dvmrp"));
if (len < 8)
- (void)printf(" [len %d]", len);
+ ND_PRINT((ndo, " [len %d]", len));
else
- dvmrp_print(bp, len);
+ dvmrp_print(ndo, bp, len);
break;
case 0x14:
- (void)printf("igmp pimv1");
- pimv1_print(bp, len);
+ ND_PRINT((ndo, "igmp pimv1"));
+ pimv1_print(ndo, bp, len);
break;
case 0x1e:
- print_mresp(bp, len);
+ print_mresp(ndo, bp, len);
break;
case 0x1f:
- print_mtrace(bp, len);
+ print_mtrace(ndo, bp, len);
break;
default:
- (void)printf("igmp-%d", bp[0]);
+ ND_PRINT((ndo, "igmp-%d", bp[0]));
break;
}
- if (vflag && TTEST2(bp[0], len)) {
+ if (ndo->ndo_vflag && len >= 4 && ND_TTEST2(bp[0], len)) {
/* Check the IGMP checksum */
vec[0].ptr = bp;
vec[0].len = len;
if (in_cksum(vec, 1))
- printf(" bad igmp cksum %x!", EXTRACT_16BITS(&bp[2]));
+ ND_PRINT((ndo, " bad igmp cksum %x!", EXTRACT_16BITS(&bp[2])));
}
return;
trunc:
- fputs("[|igmp]", stdout);
+ ND_PRINT((ndo, "%s", tstr));
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-igmp-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-igrp.c b/freebsd/contrib/tcpdump/print-igrp.c
index 77c63283..7e248238 100644
--- a/freebsd/contrib/tcpdump/print-igrp.c
+++ b/freebsd/contrib/tcpdump/print-igrp.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1996, 1997
* The Regents of the University of California. All rights reserved.
@@ -23,41 +26,66 @@
* Initial contribution from Francis Dupont (francis.dupont@inria.fr)
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-igrp.c,v 1.21 2005-04-20 21:01:56 guy Exp $ (LBL)";
-#endif
+/* \summary: Interior Gateway Routing Protocol (IGRP) printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
+
+#include "netdissect.h"
+#include "extract.h"
+
+/* Cisco IGRP definitions */
+
+/* IGRP Header */
-#include <stdio.h>
+struct igrphdr {
+ uint8_t ig_vop; /* protocol version number / opcode */
+#define IGRP_V(x) (((x) & 0xf0) >> 4)
+#define IGRP_OP(x) ((x) & 0x0f)
+ uint8_t ig_ed; /* edition number */
+ uint16_t ig_as; /* autonomous system number */
+ uint16_t ig_ni; /* number of subnet in local net */
+ uint16_t ig_ns; /* number of networks in AS */
+ uint16_t ig_nx; /* number of networks ouside AS */
+ uint16_t ig_sum; /* checksum of IGRP header & data */
+};
+
+#define IGRP_UPDATE 1
+#define IGRP_REQUEST 2
+
+/* IGRP routing entry */
+
+struct igrprte {
+ uint8_t igr_net[3]; /* 3 significant octets of IP address */
+ uint8_t igr_dly[3]; /* delay in tens of microseconds */
+ uint8_t igr_bw[3]; /* bandwidth in units of 1 kb/s */
+ uint8_t igr_mtu[2]; /* MTU in octets */
+ uint8_t igr_rel; /* percent packets successfully tx/rx */
+ uint8_t igr_ld; /* percent of channel occupied */
+ uint8_t igr_hct; /* hop count */
+};
-#include "interface.h"
-#include "addrtoname.h"
-#include "igrp.h"
-#include "ip.h"
-#include "extract.h" /* must come after interface.h */
+#define IGRP_RTE_SIZE 14 /* don't believe sizeof ! */
static void
-igrp_entry_print(register struct igrprte *igr, register int is_interior,
- register int is_exterior)
+igrp_entry_print(netdissect_options *ndo, register const struct igrprte *igr,
+ register int is_interior, register int is_exterior)
{
register u_int delay, bandwidth;
u_int metric, mtu;
if (is_interior)
- printf(" *.%d.%d.%d", igr->igr_net[0],
- igr->igr_net[1], igr->igr_net[2]);
+ ND_PRINT((ndo, " *.%d.%d.%d", igr->igr_net[0],
+ igr->igr_net[1], igr->igr_net[2]));
else if (is_exterior)
- printf(" X%d.%d.%d.0", igr->igr_net[0],
- igr->igr_net[1], igr->igr_net[2]);
+ ND_PRINT((ndo, " X%d.%d.%d.0", igr->igr_net[0],
+ igr->igr_net[1], igr->igr_net[2]));
else
- printf(" %d.%d.%d.0", igr->igr_net[0],
- igr->igr_net[1], igr->igr_net[2]);
+ ND_PRINT((ndo, " %d.%d.%d.0", igr->igr_net[0],
+ igr->igr_net[1], igr->igr_net[2]));
delay = EXTRACT_24BITS(igr->igr_dly);
bandwidth = EXTRACT_24BITS(igr->igr_bw);
@@ -66,60 +94,60 @@ igrp_entry_print(register struct igrprte *igr, register int is_interior,
metric = 0xffffff;
mtu = EXTRACT_16BITS(igr->igr_mtu);
- printf(" d=%d b=%d r=%d l=%d M=%d mtu=%d in %d hops",
+ ND_PRINT((ndo, " d=%d b=%d r=%d l=%d M=%d mtu=%d in %d hops",
10 * delay, bandwidth == 0 ? 0 : 10000000 / bandwidth,
igr->igr_rel, igr->igr_ld, metric,
- mtu, igr->igr_hct);
+ mtu, igr->igr_hct));
}
-static struct tok op2str[] = {
+static const struct tok op2str[] = {
{ IGRP_UPDATE, "update" },
{ IGRP_REQUEST, "request" },
{ 0, NULL }
};
void
-igrp_print(register const u_char *bp, u_int length, const u_char *bp2 _U_)
+igrp_print(netdissect_options *ndo, register const u_char *bp, u_int length)
{
- register struct igrphdr *hdr;
- register u_char *cp;
+ register const struct igrphdr *hdr;
+ register const u_char *cp;
u_int nint, nsys, next;
- hdr = (struct igrphdr *)bp;
- cp = (u_char *)(hdr + 1);
- (void)printf("igrp:");
+ hdr = (const struct igrphdr *)bp;
+ cp = (const u_char *)(hdr + 1);
+ ND_PRINT((ndo, "igrp:"));
/* Header */
- TCHECK(*hdr);
+ ND_TCHECK(*hdr);
nint = EXTRACT_16BITS(&hdr->ig_ni);
nsys = EXTRACT_16BITS(&hdr->ig_ns);
next = EXTRACT_16BITS(&hdr->ig_nx);
- (void)printf(" %s V%d edit=%d AS=%d (%d/%d/%d)",
+ ND_PRINT((ndo, " %s V%d edit=%d AS=%d (%d/%d/%d)",
tok2str(op2str, "op-#%d", IGRP_OP(hdr->ig_vop)),
IGRP_V(hdr->ig_vop),
hdr->ig_ed,
EXTRACT_16BITS(&hdr->ig_as),
nint,
nsys,
- next);
+ next));
length -= sizeof(*hdr);
while (length >= IGRP_RTE_SIZE) {
if (nint > 0) {
- TCHECK2(*cp, IGRP_RTE_SIZE);
- igrp_entry_print((struct igrprte *)cp, 1, 0);
+ ND_TCHECK2(*cp, IGRP_RTE_SIZE);
+ igrp_entry_print(ndo, (const struct igrprte *)cp, 1, 0);
--nint;
} else if (nsys > 0) {
- TCHECK2(*cp, IGRP_RTE_SIZE);
- igrp_entry_print((struct igrprte *)cp, 0, 0);
+ ND_TCHECK2(*cp, IGRP_RTE_SIZE);
+ igrp_entry_print(ndo, (const struct igrprte *)cp, 0, 0);
--nsys;
} else if (next > 0) {
- TCHECK2(*cp, IGRP_RTE_SIZE);
- igrp_entry_print((struct igrprte *)cp, 0, 1);
+ ND_TCHECK2(*cp, IGRP_RTE_SIZE);
+ igrp_entry_print(ndo, (const struct igrprte *)cp, 0, 1);
--next;
} else {
- (void)printf(" [extra bytes %d]", length);
+ ND_PRINT((ndo, " [extra bytes %d]", length));
break;
}
cp += IGRP_RTE_SIZE;
@@ -128,5 +156,8 @@ igrp_print(register const u_char *bp, u_int length, const u_char *bp2 _U_)
if (nint == 0 && nsys == 0 && next == 0)
return;
trunc:
- fputs(" [|igrp]", stdout);
+ ND_PRINT((ndo, " [|igrp]"));
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-igrp-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-ip.c b/freebsd/contrib/tcpdump/print-ip.c
index 947964cb..ec005c1e 100644
--- a/freebsd/contrib/tcpdump/print-ip.c
+++ b/freebsd/contrib/tcpdump/print-ip.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
@@ -19,33 +22,28 @@
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * $FreeBSD$
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ip.c,v 1.159 2007-09-14 01:29:28 guy Exp $ (LBL)";
-#endif
+/* \summary: IP printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include <stdio.h>
-#include <stdlib.h>
#include <string.h>
+#include "netdissect.h"
#include "addrtoname.h"
-#include "interface.h"
-#include "extract.h" /* must come after interface.h */
+#include "extract.h"
#include "ip.h"
#include "ipproto.h"
-struct tok ip_option_values[] = {
+static const char tstr[] = "[|ip]";
+
+static const struct tok ip_option_values[] = {
{ IPOPT_EOL, "EOL" },
{ IPOPT_NOP, "NOP" },
{ IPOPT_TS, "timestamp" },
@@ -62,25 +60,26 @@ struct tok ip_option_values[] = {
* print the recorded route in an IP RR, LSRR or SSRR option.
*/
static void
-ip_printroute(register const u_char *cp, u_int length)
+ip_printroute(netdissect_options *ndo,
+ register const u_char *cp, u_int length)
{
register u_int ptr;
register u_int len;
if (length < 3) {
- printf(" [bad length %u]", length);
+ ND_PRINT((ndo, " [bad length %u]", length));
return;
}
if ((length + 1) & 3)
- printf(" [bad length %u]", length);
+ ND_PRINT((ndo, " [bad length %u]", length));
ptr = cp[2] - 1;
if (ptr < 3 || ((ptr + 1) & 3) || ptr > length + 1)
- printf(" [bad ptr %u]", cp[2]);
+ ND_PRINT((ndo, " [bad ptr %u]", cp[2]));
for (len = 3; len < length; len += 4) {
- printf(" %s", ipaddr_string(&cp[len]));
- if (ptr > len)
- printf(",");
+ ND_PRINT((ndo, " %s", ipaddr_string(ndo, &cp[len])));
+ if (ptr > len)
+ ND_PRINT((ndo, ","));
}
}
@@ -91,13 +90,14 @@ ip_printroute(register const u_char *cp, u_int length)
* This is used for UDP and TCP pseudo-header in the checksum
* calculation.
*/
-static u_int32_t
-ip_finddst(const struct ip *ip)
+static uint32_t
+ip_finddst(netdissect_options *ndo,
+ const struct ip *ip)
{
int length;
int len;
const u_char *cp;
- u_int32_t retval;
+ uint32_t retval;
cp = (const u_char *)(ip + 1);
length = (IP_HL(ip) << 2) - sizeof(struct ip);
@@ -105,31 +105,31 @@ ip_finddst(const struct ip *ip)
for (; length > 0; cp += len, length -= len) {
int tt;
- TCHECK(*cp);
+ ND_TCHECK(*cp);
tt = *cp;
if (tt == IPOPT_EOL)
break;
else if (tt == IPOPT_NOP)
len = 1;
else {
- TCHECK(cp[1]);
+ ND_TCHECK(cp[1]);
len = cp[1];
if (len < 2)
break;
}
- TCHECK2(*cp, len);
+ ND_TCHECK2(*cp, len);
switch (tt) {
case IPOPT_SSRR:
case IPOPT_LSRR:
if (len < 7)
break;
- memcpy(&retval, cp + len - 4, 4);
+ UNALIGNED_MEMCPY(&retval, cp + len - 4, 4);
return retval;
}
}
trunc:
- memcpy(&retval, &ip->ip_dst.s_addr, sizeof(u_int32_t));
+ UNALIGNED_MEMCPY(&retval, &ip->ip_dst, sizeof(uint32_t));
return retval;
}
@@ -137,37 +137,39 @@ trunc:
* Compute a V4-style checksum by building a pseudoheader.
*/
int
-nextproto4_cksum(const struct ip *ip, const u_int8_t *data,
- u_int len, u_int next_proto)
+nextproto4_cksum(netdissect_options *ndo,
+ const struct ip *ip, const uint8_t *data,
+ u_int len, u_int covlen, u_int next_proto)
{
struct phdr {
- u_int32_t src;
- u_int32_t dst;
+ uint32_t src;
+ uint32_t dst;
u_char mbz;
u_char proto;
- u_int16_t len;
+ uint16_t len;
} ph;
struct cksum_vec vec[2];
/* pseudo-header.. */
- ph.len = htons((u_int16_t)len);
+ ph.len = htons((uint16_t)len);
ph.mbz = 0;
ph.proto = next_proto;
- memcpy(&ph.src, &ip->ip_src.s_addr, sizeof(u_int32_t));
+ UNALIGNED_MEMCPY(&ph.src, &ip->ip_src, sizeof(uint32_t));
if (IP_HL(ip) == 5)
- memcpy(&ph.dst, &ip->ip_dst.s_addr, sizeof(u_int32_t));
+ UNALIGNED_MEMCPY(&ph.dst, &ip->ip_dst, sizeof(uint32_t));
else
- ph.dst = ip_finddst(ip);
+ ph.dst = ip_finddst(ndo, ip);
- vec[0].ptr = (const u_int8_t *)(void *)&ph;
+ vec[0].ptr = (const uint8_t *)(void *)&ph;
vec[0].len = sizeof(ph);
vec[1].ptr = data;
- vec[1].len = len;
+ vec[1].len = covlen;
return (in_cksum(vec, 2));
}
static void
-ip_printts(register const u_char *cp, u_int length)
+ip_printts(netdissect_options *ndo,
+ register const u_char *cp, u_int length)
{
register u_int ptr;
register u_int len;
@@ -175,23 +177,23 @@ ip_printts(register const u_char *cp, u_int length)
const char *type;
if (length < 4) {
- printf("[bad length %u]", length);
+ ND_PRINT((ndo, "[bad length %u]", length));
return;
}
- printf(" TS{");
+ ND_PRINT((ndo, " TS{"));
hoplen = ((cp[3]&0xF) != IPOPT_TS_TSONLY) ? 8 : 4;
if ((length - 4) & (hoplen-1))
- printf("[bad length %u]", length);
+ ND_PRINT((ndo, "[bad length %u]", length));
ptr = cp[2] - 1;
len = 0;
if (ptr < 4 || ((ptr - 4) & (hoplen-1)) || ptr > length + 1)
- printf("[bad ptr %u]", cp[2]);
+ ND_PRINT((ndo, "[bad ptr %u]", cp[2]));
switch (cp[3]&0xF) {
case IPOPT_TS_TSONLY:
- printf("TSONLY");
+ ND_PRINT((ndo, "TSONLY"));
break;
case IPOPT_TS_TSANDADDR:
- printf("TS+ADDR");
+ ND_PRINT((ndo, "TS+ADDR"));
break;
/*
* prespecified should really be 3, but some ones might send 2
@@ -200,13 +202,13 @@ ip_printts(register const u_char *cp, u_int length)
*/
case 2:
- printf("PRESPEC2.0");
+ ND_PRINT((ndo, "PRESPEC2.0"));
break;
case 3: /* IPOPT_TS_PRESPEC */
- printf("PRESPEC");
+ ND_PRINT((ndo, "PRESPEC"));
break;
default:
- printf("[bad ts type %d]", cp[3]&0xF);
+ ND_PRINT((ndo, "[bad ts type %d]", cp[3]&0xF));
goto done;
}
@@ -214,25 +216,26 @@ ip_printts(register const u_char *cp, u_int length)
for (len = 4; len < length; len += hoplen) {
if (ptr == len)
type = " ^ ";
- printf("%s%d@%s", type, EXTRACT_32BITS(&cp[len+hoplen-4]),
- hoplen!=8 ? "" : ipaddr_string(&cp[len]));
+ ND_PRINT((ndo, "%s%d@%s", type, EXTRACT_32BITS(&cp[len+hoplen-4]),
+ hoplen!=8 ? "" : ipaddr_string(ndo, &cp[len])));
type = " ";
}
done:
- printf("%s", ptr == len ? " ^ " : "");
+ ND_PRINT((ndo, "%s", ptr == len ? " ^ " : ""));
if (cp[3]>>4)
- printf(" [%d hops not recorded]} ", cp[3]>>4);
+ ND_PRINT((ndo, " [%d hops not recorded]} ", cp[3]>>4));
else
- printf("}");
+ ND_PRINT((ndo, "}"));
}
/*
* print IP options.
*/
static void
-ip_optprint(register const u_char *cp, u_int length)
+ip_optprint(netdissect_options *ndo,
+ register const u_char *cp, u_int length)
{
register u_int option_len;
const char *sep = "";
@@ -240,57 +243,57 @@ ip_optprint(register const u_char *cp, u_int length)
for (; length > 0; cp += option_len, length -= option_len) {
u_int option_code;
- printf("%s", sep);
+ ND_PRINT((ndo, "%s", sep));
sep = ",";
- TCHECK(*cp);
+ ND_TCHECK(*cp);
option_code = *cp;
- printf("%s",
- tok2str(ip_option_values,"unknown %u",option_code));
+ ND_PRINT((ndo, "%s",
+ tok2str(ip_option_values,"unknown %u",option_code)));
if (option_code == IPOPT_NOP ||
option_code == IPOPT_EOL)
option_len = 1;
else {
- TCHECK(cp[1]);
+ ND_TCHECK(cp[1]);
option_len = cp[1];
if (option_len < 2) {
- printf(" [bad length %u]", option_len);
+ ND_PRINT((ndo, " [bad length %u]", option_len));
return;
}
}
if (option_len > length) {
- printf(" [bad length %u]", option_len);
+ ND_PRINT((ndo, " [bad length %u]", option_len));
return;
}
- TCHECK2(*cp, option_len);
+ ND_TCHECK2(*cp, option_len);
switch (option_code) {
case IPOPT_EOL:
return;
case IPOPT_TS:
- ip_printts(cp, option_len);
+ ip_printts(ndo, cp, option_len);
break;
case IPOPT_RR: /* fall through */
case IPOPT_SSRR:
case IPOPT_LSRR:
- ip_printroute(cp, option_len);
+ ip_printroute(ndo, cp, option_len);
break;
case IPOPT_RA:
if (option_len < 4) {
- printf(" [bad length %u]", option_len);
+ ND_PRINT((ndo, " [bad length %u]", option_len));
break;
}
- TCHECK(cp[3]);
- if (EXTRACT_16BITS(&cp[2]) != 0)
- printf(" value %u", EXTRACT_16BITS(&cp[2]));
+ ND_TCHECK(cp[3]);
+ if (EXTRACT_16BITS(&cp[2]) != 0)
+ ND_PRINT((ndo, " value %u", EXTRACT_16BITS(&cp[2])));
break;
case IPOPT_NOP: /* nothing to print - fall through */
@@ -302,12 +305,12 @@ ip_optprint(register const u_char *cp, u_int length)
return;
trunc:
- printf("[|ip]");
+ ND_PRINT((ndo, "%s", tstr));
}
#define IP_RES 0x8000
-static struct tok ip_frag_values[] = {
+static const struct tok ip_frag_values[] = {
{ IP_MF, "+" },
{ IP_DF, "DF" },
{ IP_RES, "rsvd" }, /* The RFC3514 evil ;-) bit */
@@ -327,14 +330,17 @@ ip_print_demux(netdissect_options *ndo,
struct ip_print_demux_state *ipds)
{
struct protoent *proto;
- struct cksum_vec vec[1];
again:
switch (ipds->nh) {
case IPPROTO_AH:
+ if (!ND_TTEST(*ipds->cp)) {
+ ND_PRINT((ndo, "[|AH]"));
+ break;
+ }
ipds->nh = *ipds->cp;
- ipds->advance = ah_print(ipds->cp);
+ ipds->advance = ah_print(ndo, ipds->cp);
if (ipds->advance <= 0)
break;
ipds->cp += ipds->advance;
@@ -357,39 +363,39 @@ again:
case IPPROTO_IPCOMP:
{
- int enh;
- ipds->advance = ipcomp_print(ipds->cp, &enh);
- if (ipds->advance <= 0)
- break;
- ipds->cp += ipds->advance;
- ipds->len -= ipds->advance;
- ipds->nh = enh & 0xff;
- goto again;
+ ipcomp_print(ndo, ipds->cp);
+ /*
+ * Either this has decompressed the payload and
+ * printed it, in which case there's nothing more
+ * to do, or it hasn't, in which case there's
+ * nothing more to do.
+ */
+ break;
}
case IPPROTO_SCTP:
- sctp_print(ipds->cp, (const u_char *)ipds->ip, ipds->len);
+ sctp_print(ndo, ipds->cp, (const u_char *)ipds->ip, ipds->len);
break;
case IPPROTO_DCCP:
- dccp_print(ipds->cp, (const u_char *)ipds->ip, ipds->len);
+ dccp_print(ndo, ipds->cp, (const u_char *)ipds->ip, ipds->len);
break;
case IPPROTO_TCP:
/* pass on the MF bit plus the offset to detect fragments */
- tcp_print(ipds->cp, ipds->len, (const u_char *)ipds->ip,
+ tcp_print(ndo, ipds->cp, ipds->len, (const u_char *)ipds->ip,
ipds->off & (IP_MF|IP_OFFMASK));
break;
case IPPROTO_UDP:
/* pass on the MF bit plus the offset to detect fragments */
- udp_print(ipds->cp, ipds->len, (const u_char *)ipds->ip,
+ udp_print(ndo, ipds->cp, ipds->len, (const u_char *)ipds->ip,
ipds->off & (IP_MF|IP_OFFMASK));
break;
case IPPROTO_ICMP:
/* pass on the MF bit plus the offset to detect fragments */
- icmp_print(ipds->cp, ipds->len, (const u_char *)ipds->ip,
+ icmp_print(ndo, ipds->cp, ipds->len, (const u_char *)ipds->ip,
ipds->off & (IP_MF|IP_OFFMASK));
break;
@@ -407,11 +413,11 @@ again:
* match was the current protocol number
* assignments say.
*/
- igrp_print(ipds->cp, ipds->len, (const u_char *)ipds->ip);
+ igrp_print(ndo, ipds->cp, ipds->len);
break;
case IPPROTO_EIGRP:
- eigrp_print(ipds->cp, ipds->len);
+ eigrp_print(ndo, ipds->cp, ipds->len);
break;
case IPPROTO_ND:
@@ -419,75 +425,74 @@ again:
break;
case IPPROTO_EGP:
- egp_print(ipds->cp, ipds->len);
+ egp_print(ndo, ipds->cp, ipds->len);
break;
case IPPROTO_OSPF:
- ospf_print(ipds->cp, ipds->len, (const u_char *)ipds->ip);
+ ospf_print(ndo, ipds->cp, ipds->len, (const u_char *)ipds->ip);
break;
case IPPROTO_IGMP:
- igmp_print(ipds->cp, ipds->len);
+ igmp_print(ndo, ipds->cp, ipds->len);
break;
case IPPROTO_IPV4:
/* DVMRP multicast tunnel (ip-in-ip encapsulation) */
ip_print(ndo, ipds->cp, ipds->len);
- if (! vflag) {
+ if (! ndo->ndo_vflag) {
ND_PRINT((ndo, " (ipip-proto-4)"));
return;
}
break;
-#ifdef INET6
case IPPROTO_IPV6:
/* ip6-in-ip encapsulation */
ip6_print(ndo, ipds->cp, ipds->len);
break;
-#endif /*INET6*/
case IPPROTO_RSVP:
- rsvp_print(ipds->cp, ipds->len);
+ rsvp_print(ndo, ipds->cp, ipds->len);
break;
case IPPROTO_GRE:
/* do it */
- gre_print(ipds->cp, ipds->len);
+ gre_print(ndo, ipds->cp, ipds->len);
break;
case IPPROTO_MOBILE:
- mobile_print(ipds->cp, ipds->len);
+ mobile_print(ndo, ipds->cp, ipds->len);
break;
case IPPROTO_PIM:
- vec[0].ptr = ipds->cp;
- vec[0].len = ipds->len;
- pim_print(ipds->cp, ipds->len, in_cksum(vec, 1));
+ pim_print(ndo, ipds->cp, ipds->len, (const u_char *)ipds->ip);
break;
case IPPROTO_VRRP:
- if (packettype == PT_CARP) {
- if (vflag)
- (void)printf("carp %s > %s: ",
- ipaddr_string(&ipds->ip->ip_src),
- ipaddr_string(&ipds->ip->ip_dst));
- carp_print(ipds->cp, ipds->len, ipds->ip->ip_ttl);
+ if (ndo->ndo_packettype == PT_CARP) {
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo, "carp %s > %s: ",
+ ipaddr_string(ndo, &ipds->ip->ip_src),
+ ipaddr_string(ndo, &ipds->ip->ip_dst)));
+ carp_print(ndo, ipds->cp, ipds->len, ipds->ip->ip_ttl);
} else {
- if (vflag)
- (void)printf("vrrp %s > %s: ",
- ipaddr_string(&ipds->ip->ip_src),
- ipaddr_string(&ipds->ip->ip_dst));
- vrrp_print(ipds->cp, ipds->len, ipds->ip->ip_ttl);
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo, "vrrp %s > %s: ",
+ ipaddr_string(ndo, &ipds->ip->ip_src),
+ ipaddr_string(ndo, &ipds->ip->ip_dst)));
+ vrrp_print(ndo, ipds->cp, ipds->len,
+ (const u_char *)ipds->ip, ipds->ip->ip_ttl);
}
break;
case IPPROTO_PGM:
- pgm_print(ipds->cp, ipds->len, (const u_char *)ipds->ip);
+ pgm_print(ndo, ipds->cp, ipds->len, (const u_char *)ipds->ip);
break;
+#if defined(HAVE_NET_PFVAR_H)
case IPPROTO_PFSYNC:
- pfsync_ip_print(ipds->cp, ipds->len);
+ pfsync_ip_print(ndo, ipds->cp, ipds->len);
break;
+#endif
default:
if (ndo->ndo_nflag==0 && (proto = getprotobynumber(ipds->nh)) != NULL)
@@ -531,40 +536,40 @@ ip_print(netdissect_options *ndo,
const u_char *ipend;
u_int hlen;
struct cksum_vec vec[1];
- u_int16_t sum, ip_sum;
+ uint16_t sum, ip_sum;
struct protoent *proto;
ipds->ip = (const struct ip *)bp;
- if (IP_V(ipds->ip) != 4) { /* print version if != 4 */
- printf("IP%u ", IP_V(ipds->ip));
+ ND_TCHECK(ipds->ip->ip_vhl);
+ if (IP_V(ipds->ip) != 4) { /* print version and fail if != 4 */
if (IP_V(ipds->ip) == 6)
- printf(", wrong link-layer encapsulation");
+ ND_PRINT((ndo, "IP6, wrong link-layer encapsulation "));
+ else
+ ND_PRINT((ndo, "IP%u ", IP_V(ipds->ip)));
+ return;
}
- else if (!eflag)
- printf("IP ");
+ if (!ndo->ndo_eflag)
+ ND_PRINT((ndo, "IP "));
- if ((u_char *)(ipds->ip + 1) > ndo->ndo_snapend) {
- printf("[|ip]");
- return;
- }
+ ND_TCHECK(*ipds->ip);
if (length < sizeof (struct ip)) {
- (void)printf("truncated-ip %u", length);
+ ND_PRINT((ndo, "truncated-ip %u", length));
return;
}
hlen = IP_HL(ipds->ip) * 4;
if (hlen < sizeof (struct ip)) {
- (void)printf("bad-hlen %u", hlen);
+ ND_PRINT((ndo, "bad-hlen %u", hlen));
return;
}
ipds->len = EXTRACT_16BITS(&ipds->ip->ip_len);
if (length < ipds->len)
- (void)printf("truncated-ip - %u bytes missing! ",
- ipds->len - length);
+ ND_PRINT((ndo, "truncated-ip - %u bytes missing! ",
+ ipds->len - length));
if (ipds->len < hlen) {
#ifdef GUESS_TSO
if (ipds->len) {
- (void)printf("bad-len %u", ipds->len);
+ ND_PRINT((ndo, "bad-len %u", ipds->len));
return;
}
else {
@@ -572,7 +577,7 @@ ip_print(netdissect_options *ndo,
ipds->len = length;
}
#else
- (void)printf("bad-len %u", ipds->len);
+ ND_PRINT((ndo, "bad-len %u", ipds->len));
return;
#endif /* GUESS_TSO */
}
@@ -588,24 +593,29 @@ ip_print(netdissect_options *ndo,
ipds->off = EXTRACT_16BITS(&ipds->ip->ip_off);
- if (vflag) {
- (void)printf("(tos 0x%x", (int)ipds->ip->ip_tos);
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo, "(tos 0x%x", (int)ipds->ip->ip_tos));
/* ECN bits */
- if (ipds->ip->ip_tos & 0x03) {
- switch (ipds->ip->ip_tos & 0x03) {
- case 1:
- (void)printf(",ECT(1)");
- break;
- case 2:
- (void)printf(",ECT(0)");
- break;
- case 3:
- (void)printf(",CE");
- }
+ switch (ipds->ip->ip_tos & 0x03) {
+
+ case 0:
+ break;
+
+ case 1:
+ ND_PRINT((ndo, ",ECT(1)"));
+ break;
+
+ case 2:
+ ND_PRINT((ndo, ",ECT(0)"));
+ break;
+
+ case 3:
+ ND_PRINT((ndo, ",CE"));
+ break;
}
if (ipds->ip->ip_ttl >= 1)
- (void)printf(", ttl %u", ipds->ip->ip_ttl);
+ ND_PRINT((ndo, ", ttl %u", ipds->ip->ip_ttl));
/*
* for the firewall guys, print id, offset.
@@ -613,33 +623,33 @@ ip_print(netdissect_options *ndo,
* For unfragmented datagrams, note the don't fragment flag.
*/
- (void)printf(", id %u, offset %u, flags [%s], proto %s (%u)",
+ ND_PRINT((ndo, ", id %u, offset %u, flags [%s], proto %s (%u)",
EXTRACT_16BITS(&ipds->ip->ip_id),
(ipds->off & 0x1fff) * 8,
bittok2str(ip_frag_values, "none", ipds->off&0xe000),
tok2str(ipproto_values,"unknown",ipds->ip->ip_p),
- ipds->ip->ip_p);
+ ipds->ip->ip_p));
- (void)printf(", length %u", EXTRACT_16BITS(&ipds->ip->ip_len));
+ ND_PRINT((ndo, ", length %u", EXTRACT_16BITS(&ipds->ip->ip_len)));
if ((hlen - sizeof(struct ip)) > 0) {
- printf(", options (");
- ip_optprint((u_char *)(ipds->ip + 1), hlen - sizeof(struct ip));
- printf(")");
+ ND_PRINT((ndo, ", options ("));
+ ip_optprint(ndo, (const u_char *)(ipds->ip + 1), hlen - sizeof(struct ip));
+ ND_PRINT((ndo, ")"));
}
- if (!Kflag && (u_char *)ipds->ip + hlen <= ndo->ndo_snapend) {
- vec[0].ptr = (const u_int8_t *)(void *)ipds->ip;
+ if (!ndo->ndo_Kflag && (const u_char *)ipds->ip + hlen <= ndo->ndo_snapend) {
+ vec[0].ptr = (const uint8_t *)(const void *)ipds->ip;
vec[0].len = hlen;
sum = in_cksum(vec, 1);
if (sum != 0) {
ip_sum = EXTRACT_16BITS(&ipds->ip->ip_sum);
- (void)printf(", bad cksum %x (->%x)!", ip_sum,
- in_cksum_shouldbe(ip_sum, sum));
+ ND_PRINT((ndo, ", bad cksum %x (->%x)!", ip_sum,
+ in_cksum_shouldbe(ip_sum, sum)));
}
}
- printf(")\n ");
+ ND_PRINT((ndo, ")\n "));
}
/*
@@ -652,55 +662,63 @@ ip_print(netdissect_options *ndo,
if (ipds->nh != IPPROTO_TCP && ipds->nh != IPPROTO_UDP &&
ipds->nh != IPPROTO_SCTP && ipds->nh != IPPROTO_DCCP) {
- (void)printf("%s > %s: ",
- ipaddr_string(&ipds->ip->ip_src),
- ipaddr_string(&ipds->ip->ip_dst));
+ ND_PRINT((ndo, "%s > %s: ",
+ ipaddr_string(ndo, &ipds->ip->ip_src),
+ ipaddr_string(ndo, &ipds->ip->ip_dst)));
}
ip_print_demux(ndo, ipds);
} else {
- /* Ultra quiet now means that all this stuff should be suppressed */
- if (qflag > 1) return;
+ /*
+ * Ultra quiet now means that all this stuff should be
+ * suppressed.
+ */
+ if (ndo->ndo_qflag > 1)
+ return;
- /*
- * if this isn't the first frag, we're missing the
- * next level protocol header. print the ip addr
- * and the protocol.
- */
- if (ipds->off & 0x1fff) {
- (void)printf("%s > %s:", ipaddr_string(&ipds->ip->ip_src),
- ipaddr_string(&ipds->ip->ip_dst));
+ /*
+ * This isn't the first frag, so we're missing the
+ * next level protocol header. print the ip addr
+ * and the protocol.
+ */
+ ND_PRINT((ndo, "%s > %s:", ipaddr_string(ndo, &ipds->ip->ip_src),
+ ipaddr_string(ndo, &ipds->ip->ip_dst)));
if (!ndo->ndo_nflag && (proto = getprotobynumber(ipds->ip->ip_p)) != NULL)
- (void)printf(" %s", proto->p_name);
+ ND_PRINT((ndo, " %s", proto->p_name));
else
- (void)printf(" ip-proto-%d", ipds->ip->ip_p);
- }
+ ND_PRINT((ndo, " ip-proto-%d", ipds->ip->ip_p));
}
+ return;
+
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return;
}
void
-ipN_print(register const u_char *bp, register u_int length)
+ipN_print(netdissect_options *ndo, register const u_char *bp, register u_int length)
{
- struct ip *ip, hdr;
-
- ip = (struct ip *)bp;
- if (length < 4) {
- (void)printf("truncated-ip %d", length);
+ if (length < 1) {
+ ND_PRINT((ndo, "truncated-ip %d", length));
return;
}
- memcpy (&hdr, (char *)ip, 4);
- switch (IP_V(&hdr)) {
- case 4:
- ip_print (gndo, bp, length);
- return;
-#ifdef INET6
- case 6:
- ip6_print (gndo, bp, length);
- return;
-#endif
+
+ ND_TCHECK(*bp);
+ switch (*bp & 0xF0) {
+ case 0x40:
+ ip_print (ndo, bp, length);
+ break;
+ case 0x60:
+ ip6_print (ndo, bp, length);
+ break;
default:
- (void)printf("unknown ip %d", IP_V(&hdr));
- return;
+ ND_PRINT((ndo, "unknown ip %d", (*bp & 0xF0) >> 4));
+ break;
}
+ return;
+
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return;
}
/*
@@ -711,3 +729,6 @@ ipN_print(register const u_char *bp, register u_int length)
*/
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-ip-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-ip6.c b/freebsd/contrib/tcpdump/print-ip6.c
index 387067b7..8fb408b2 100644
--- a/freebsd/contrib/tcpdump/print-ip6.c
+++ b/freebsd/contrib/tcpdump/print-ip6.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994
* The Regents of the University of California. All rights reserved.
@@ -19,29 +22,19 @@
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * $FreeBSD$
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ip6.c,v 1.52 2007-09-21 07:05:33 hannes Exp $";
-#endif
+/* \summary: IPv6 printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#ifdef INET6
-
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include <stdio.h>
-#include <stdlib.h>
#include <string.h>
#include "netdissect.h"
-#include "interface.h"
#include "addrtoname.h"
#include "extract.h"
@@ -49,32 +42,172 @@ static const char rcsid[] _U_ =
#include "ipproto.h"
/*
+ * If routing headers are presend and valid, set dst to the final destination.
+ * Otherwise, set it to the IPv6 destination.
+ *
+ * This is used for UDP and TCP pseudo-header in the checksum
+ * calculation.
+ */
+static void
+ip6_finddst(netdissect_options *ndo, struct in6_addr *dst,
+ const struct ip6_hdr *ip6)
+{
+ const u_char *cp;
+ int advance;
+ u_int nh;
+ const struct in6_addr *dst_addr;
+ const struct ip6_rthdr *dp;
+ const struct ip6_rthdr0 *dp0;
+ const struct in6_addr *addr;
+ int i, len;
+
+ cp = (const u_char *)ip6;
+ advance = sizeof(struct ip6_hdr);
+ nh = ip6->ip6_nxt;
+ dst_addr = &ip6->ip6_dst;
+
+ while (cp < ndo->ndo_snapend) {
+ cp += advance;
+
+ switch (nh) {
+
+ case IPPROTO_HOPOPTS:
+ case IPPROTO_DSTOPTS:
+ case IPPROTO_MOBILITY_OLD:
+ case IPPROTO_MOBILITY:
+ /*
+ * These have a header length byte, following
+ * the next header byte, giving the length of
+ * the header, in units of 8 octets, excluding
+ * the first 8 octets.
+ */
+ ND_TCHECK2(*cp, 2);
+ advance = (int)((*(cp + 1) + 1) << 3);
+ nh = *cp;
+ break;
+
+ case IPPROTO_FRAGMENT:
+ /*
+ * The byte following the next header byte is
+ * marked as reserved, and the header is always
+ * the same size.
+ */
+ ND_TCHECK2(*cp, 1);
+ advance = sizeof(struct ip6_frag);
+ nh = *cp;
+ break;
+
+ case IPPROTO_ROUTING:
+ /*
+ * OK, we found it.
+ */
+ dp = (const struct ip6_rthdr *)cp;
+ ND_TCHECK(*dp);
+ len = dp->ip6r_len;
+ switch (dp->ip6r_type) {
+
+ case IPV6_RTHDR_TYPE_0:
+ case IPV6_RTHDR_TYPE_2: /* Mobile IPv6 ID-20 */
+ dp0 = (const struct ip6_rthdr0 *)dp;
+ if (len % 2 == 1)
+ goto trunc;
+ len >>= 1;
+ addr = &dp0->ip6r0_addr[0];
+ for (i = 0; i < len; i++) {
+ if ((const u_char *)(addr + 1) > ndo->ndo_snapend)
+ goto trunc;
+
+ dst_addr = addr;
+ addr++;
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ /*
+ * Only one routing header to a customer.
+ */
+ goto done;
+
+ case IPPROTO_AH:
+ case IPPROTO_ESP:
+ case IPPROTO_IPCOMP:
+ default:
+ /*
+ * AH and ESP are, in the RFCs that describe them,
+ * described as being "viewed as an end-to-end
+ * payload" "in the IPv6 context, so that they
+ * "should appear after hop-by-hop, routing, and
+ * fragmentation extension headers". We assume
+ * that's the case, and stop as soon as we see
+ * one. (We can't handle an ESP header in
+ * the general case anyway, as its length depends
+ * on the encryption algorithm.)
+ *
+ * IPComp is also "viewed as an end-to-end
+ * payload" "in the IPv6 context".
+ *
+ * All other protocols are assumed to be the final
+ * protocol.
+ */
+ goto done;
+ }
+ }
+
+done:
+trunc:
+ UNALIGNED_MEMCPY(dst, dst_addr, sizeof(struct in6_addr));
+}
+
+/*
* Compute a V6-style checksum by building a pseudoheader.
*/
int
-nextproto6_cksum(const struct ip6_hdr *ip6, const u_int8_t *data,
- u_int len, u_int next_proto)
+nextproto6_cksum(netdissect_options *ndo,
+ const struct ip6_hdr *ip6, const uint8_t *data,
+ u_int len, u_int covlen, u_int next_proto)
{
struct {
struct in6_addr ph_src;
struct in6_addr ph_dst;
- u_int32_t ph_len;
- u_int8_t ph_zero[3];
- u_int8_t ph_nxt;
+ uint32_t ph_len;
+ uint8_t ph_zero[3];
+ uint8_t ph_nxt;
} ph;
struct cksum_vec vec[2];
/* pseudo-header */
memset(&ph, 0, sizeof(ph));
- ph.ph_src = ip6->ip6_src;
- ph.ph_dst = ip6->ip6_dst;
+ UNALIGNED_MEMCPY(&ph.ph_src, &ip6->ip6_src, sizeof (struct in6_addr));
+ switch (ip6->ip6_nxt) {
+
+ case IPPROTO_HOPOPTS:
+ case IPPROTO_DSTOPTS:
+ case IPPROTO_MOBILITY_OLD:
+ case IPPROTO_MOBILITY:
+ case IPPROTO_FRAGMENT:
+ case IPPROTO_ROUTING:
+ /*
+ * The next header is either a routing header or a header
+ * after which there might be a routing header, so scan
+ * for a routing header.
+ */
+ ip6_finddst(ndo, &ph.ph_dst, ip6);
+ break;
+
+ default:
+ UNALIGNED_MEMCPY(&ph.ph_dst, &ip6->ip6_dst, sizeof (struct in6_addr));
+ break;
+ }
ph.ph_len = htonl(len);
ph.ph_nxt = next_proto;
- vec[0].ptr = (const u_int8_t *)(void *)&ph;
+ vec[0].ptr = (const uint8_t *)(void *)&ph;
vec[0].len = sizeof(ph);
vec[1].ptr = data;
- vec[1].len = len;
+ vec[1].len = covlen;
return in_cksum(vec, 2);
}
@@ -97,19 +230,24 @@ ip6_print(netdissect_options *ndo, const u_char *bp, u_int length)
ip6 = (const struct ip6_hdr *)bp;
- TCHECK(*ip6);
+ ND_TCHECK(*ip6);
if (length < sizeof (struct ip6_hdr)) {
- (void)ND_PRINT((ndo, "truncated-ip6 %u", length));
+ ND_PRINT((ndo, "truncated-ip6 %u", length));
return;
}
if (!ndo->ndo_eflag)
ND_PRINT((ndo, "IP6 "));
+ if (IP6_VERSION(ip6) != 6) {
+ ND_PRINT((ndo,"version error: %u != 6", IP6_VERSION(ip6)));
+ return;
+ }
+
payload_len = EXTRACT_16BITS(&ip6->ip6_plen);
len = payload_len + sizeof(struct ip6_hdr);
if (length < len)
- (void)ND_PRINT((ndo, "truncated-ip6 - %u bytes missing!",
+ ND_PRINT((ndo, "truncated-ip6 - %u bytes missing!",
len - length));
if (ndo->ndo_vflag) {
@@ -118,18 +256,18 @@ ip6_print(netdissect_options *ndo, const u_char *bp, u_int length)
#if 0
/* rfc1883 */
if (flow & 0x0f000000)
- (void)ND_PRINT((ndo, "pri 0x%02x, ", (flow & 0x0f000000) >> 24));
+ ND_PRINT((ndo, "pri 0x%02x, ", (flow & 0x0f000000) >> 24));
if (flow & 0x00ffffff)
- (void)ND_PRINT((ndo, "flowlabel 0x%06x, ", flow & 0x00ffffff));
+ ND_PRINT((ndo, "flowlabel 0x%06x, ", flow & 0x00ffffff));
#else
/* RFC 2460 */
if (flow & 0x0ff00000)
- (void)ND_PRINT((ndo, "class 0x%02x, ", (flow & 0x0ff00000) >> 20));
+ ND_PRINT((ndo, "class 0x%02x, ", (flow & 0x0ff00000) >> 20));
if (flow & 0x000fffff)
- (void)ND_PRINT((ndo, "flowlabel 0x%05x, ", flow & 0x000fffff));
+ ND_PRINT((ndo, "flowlabel 0x%05x, ", flow & 0x000fffff));
#endif
- (void)ND_PRINT((ndo, "hlim %u, next-header %s (%u) payload length: %u) ",
+ ND_PRINT((ndo, "hlim %u, next-header %s (%u) payload length: %u) ",
ip6->ip6_hlim,
tok2str(ipproto_values,"unknown",ip6->ip6_nxt),
ip6->ip6_nxt,
@@ -153,22 +291,26 @@ ip6_print(netdissect_options *ndo, const u_char *bp, u_int length)
if (cp == (const u_char *)(ip6 + 1) &&
nh != IPPROTO_TCP && nh != IPPROTO_UDP &&
nh != IPPROTO_DCCP && nh != IPPROTO_SCTP) {
- (void)ND_PRINT((ndo, "%s > %s: ", ip6addr_string(&ip6->ip6_src),
- ip6addr_string(&ip6->ip6_dst)));
+ ND_PRINT((ndo, "%s > %s: ", ip6addr_string(ndo, &ip6->ip6_src),
+ ip6addr_string(ndo, &ip6->ip6_dst)));
}
switch (nh) {
case IPPROTO_HOPOPTS:
- advance = hbhopt_print(cp);
+ advance = hbhopt_print(ndo, cp);
+ if (advance < 0)
+ return;
nh = *cp;
break;
case IPPROTO_DSTOPTS:
- advance = dstopt_print(cp);
+ advance = dstopt_print(ndo, cp);
+ if (advance < 0)
+ return;
nh = *cp;
break;
case IPPROTO_FRAGMENT:
- advance = frag6_print(cp, (const u_char *)ip6);
- if (ndo->ndo_snapend <= cp + advance)
+ advance = frag6_print(ndo, cp, (const u_char *)ip6);
+ if (advance < 0 || ndo->ndo_snapend <= cp + advance)
return;
nh = *cp;
fragmented = 1;
@@ -177,39 +319,37 @@ ip6_print(netdissect_options *ndo, const u_char *bp, u_int length)
case IPPROTO_MOBILITY_OLD:
case IPPROTO_MOBILITY:
/*
- * XXX - we don't use "advance"; the current
- * "Mobility Support in IPv6" draft
- * (draft-ietf-mobileip-ipv6-24) says that
+ * XXX - we don't use "advance"; RFC 3775 says that
* the next header field in a mobility header
* should be IPPROTO_NONE, but speaks of
* the possiblity of a future extension in
* which payload can be piggybacked atop a
* mobility header.
*/
- advance = mobility_print(cp, (const u_char *)ip6);
+ advance = mobility_print(ndo, cp, (const u_char *)ip6);
nh = *cp;
return;
case IPPROTO_ROUTING:
- advance = rt6_print(cp, (const u_char *)ip6);
+ advance = rt6_print(ndo, cp, (const u_char *)ip6);
nh = *cp;
break;
case IPPROTO_SCTP:
- sctp_print(cp, (const u_char *)ip6, len);
+ sctp_print(ndo, cp, (const u_char *)ip6, len);
return;
case IPPROTO_DCCP:
- dccp_print(cp, (const u_char *)ip6, len);
+ dccp_print(ndo, cp, (const u_char *)ip6, len);
return;
case IPPROTO_TCP:
- tcp_print(cp, len, (const u_char *)ip6, fragmented);
+ tcp_print(ndo, cp, len, (const u_char *)ip6, fragmented);
return;
case IPPROTO_UDP:
- udp_print(cp, len, (const u_char *)ip6, fragmented);
+ udp_print(ndo, cp, len, (const u_char *)ip6, fragmented);
return;
case IPPROTO_ICMPV6:
icmp6_print(ndo, cp, len, (const u_char *)ip6, fragmented);
return;
case IPPROTO_AH:
- advance = ah_print(cp);
+ advance = ah_print(ndo, cp);
nh = *cp;
break;
case IPPROTO_ESP:
@@ -222,19 +362,23 @@ ip6_print(netdissect_options *ndo, const u_char *bp, u_int length)
}
case IPPROTO_IPCOMP:
{
- int enh;
- advance = ipcomp_print(cp, &enh);
- nh = enh & 0xff;
+ ipcomp_print(ndo, cp);
+ /*
+ * Either this has decompressed the payload and
+ * printed it, in which case there's nothing more
+ * to do, or it hasn't, in which case there's
+ * nothing more to do.
+ */
+ advance = -1;
break;
}
case IPPROTO_PIM:
- pim_print(cp, len, nextproto6_cksum(ip6, cp, len,
- IPPROTO_PIM));
+ pim_print(ndo, cp, len, (const u_char *)ip6);
return;
case IPPROTO_OSPF:
- ospf6_print(cp, len);
+ ospf6_print(ndo, cp, len);
return;
case IPPROTO_IPV6:
@@ -246,30 +390,31 @@ ip6_print(netdissect_options *ndo, const u_char *bp, u_int length)
return;
case IPPROTO_PGM:
- pgm_print(cp, len, (const u_char *)ip6);
+ pgm_print(ndo, cp, len, (const u_char *)ip6);
return;
case IPPROTO_GRE:
- gre_print(cp, len);
+ gre_print(ndo, cp, len);
return;
case IPPROTO_RSVP:
- rsvp_print(cp, len);
+ rsvp_print(ndo, cp, len);
return;
case IPPROTO_NONE:
- (void)ND_PRINT((ndo, "no next header"));
+ ND_PRINT((ndo, "no next header"));
return;
default:
- (void)ND_PRINT((ndo, "ip-proto-%d %d", nh, len));
+ ND_PRINT((ndo, "ip-proto-%d %d", nh, len));
return;
}
}
return;
trunc:
- (void)ND_PRINT((ndo, "[|ip6]"));
+ ND_PRINT((ndo, "[|ip6]"));
}
-
-#endif /* INET6 */
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-ip6-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-ip6opts.c b/freebsd/contrib/tcpdump/print-ip6opts.c
index a01a86bc..396e8a86 100644
--- a/freebsd/contrib/tcpdump/print-ip6opts.c
+++ b/freebsd/contrib/tcpdump/print-ip6opts.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (C) 1998 WIDE Project.
* All rights reserved.
@@ -29,51 +32,22 @@
* SUCH DAMAGE.
*/
+/* \summary: IPv6 header option printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ip6opts.c,v 1.18 2005-04-20 22:18:50 guy Exp $";
-#endif
-
-#ifdef INET6
-#include <tcpdump-stdinc.h>
-
-#include <stdio.h>
+#include <netdissect-stdinc.h>
#include "ip6.h"
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "extract.h"
-/* items outside of rfc2292bis */
-#ifndef IP6OPT_MINLEN
-#define IP6OPT_MINLEN 2
-#endif
-#ifndef IP6OPT_RTALERT_LEN
-#define IP6OPT_RTALERT_LEN 4
-#endif
-#ifndef IP6OPT_JUMBO_LEN
-#define IP6OPT_JUMBO_LEN 6
-#endif
-#define IP6OPT_HOMEADDR_MINLEN 18
-#define IP6OPT_BU_MINLEN 10
-#define IP6OPT_BA_MINLEN 13
-#define IP6OPT_BR_MINLEN 2
-#define IP6SOPT_UI 0x2
-#define IP6SOPT_UI_MINLEN 4
-#define IP6SOPT_ALTCOA 0x3
-#define IP6SOPT_ALTCOA_MINLEN 18
-#define IP6SOPT_AUTH 0x4
-#define IP6SOPT_AUTH_MINLEN 6
-
-static void ip6_sopt_print(const u_char *, int);
-
static void
-ip6_sopt_print(const u_char *bp, int len)
+ip6_sopt_print(netdissect_options *ndo, const u_char *bp, int len)
{
int i;
int optlen;
@@ -92,53 +66,32 @@ ip6_sopt_print(const u_char *bp, int len)
switch (bp[i]) {
case IP6OPT_PAD1:
- printf(", pad1");
+ ND_PRINT((ndo, ", pad1"));
break;
case IP6OPT_PADN:
if (len - i < IP6OPT_MINLEN) {
- printf(", padn: trunc");
+ ND_PRINT((ndo, ", padn: trunc"));
goto trunc;
}
- printf(", padn");
- break;
- case IP6SOPT_UI:
- if (len - i < IP6SOPT_UI_MINLEN) {
- printf(", ui: trunc");
- goto trunc;
- }
- printf(", ui: 0x%04x ", EXTRACT_16BITS(&bp[i + 2]));
- break;
- case IP6SOPT_ALTCOA:
- if (len - i < IP6SOPT_ALTCOA_MINLEN) {
- printf(", altcoa: trunc");
- goto trunc;
- }
- printf(", alt-CoA: %s", ip6addr_string(&bp[i+2]));
- break;
- case IP6SOPT_AUTH:
- if (len - i < IP6SOPT_AUTH_MINLEN) {
- printf(", auth: trunc");
- goto trunc;
- }
- printf(", auth spi: 0x%08x", EXTRACT_32BITS(&bp[i + 2]));
+ ND_PRINT((ndo, ", padn"));
break;
default:
if (len - i < IP6OPT_MINLEN) {
- printf(", sopt_type %d: trunc)", bp[i]);
+ ND_PRINT((ndo, ", sopt_type %d: trunc)", bp[i]));
goto trunc;
}
- printf(", sopt_type 0x%02x: len=%d", bp[i], bp[i + 1]);
+ ND_PRINT((ndo, ", sopt_type 0x%02x: len=%d", bp[i], bp[i + 1]));
break;
}
}
return;
trunc:
- printf("[trunc] ");
+ ND_PRINT((ndo, "[trunc] "));
}
-void
-ip6_opt_print(const u_char *bp, int len)
+static void
+ip6_opt_print(netdissect_options *ndo, const u_char *bp, int len)
{
int i;
int optlen = 0;
@@ -159,176 +112,110 @@ ip6_opt_print(const u_char *bp, int len)
switch (bp[i]) {
case IP6OPT_PAD1:
- printf("(pad1)");
+ ND_PRINT((ndo, "(pad1)"));
break;
case IP6OPT_PADN:
if (len - i < IP6OPT_MINLEN) {
- printf("(padn: trunc)");
+ ND_PRINT((ndo, "(padn: trunc)"));
goto trunc;
}
- printf("(padn)");
+ ND_PRINT((ndo, "(padn)"));
break;
case IP6OPT_ROUTER_ALERT:
if (len - i < IP6OPT_RTALERT_LEN) {
- printf("(rtalert: trunc)");
+ ND_PRINT((ndo, "(rtalert: trunc)"));
goto trunc;
}
if (bp[i + 1] != IP6OPT_RTALERT_LEN - 2) {
- printf("(rtalert: invalid len %d)", bp[i + 1]);
+ ND_PRINT((ndo, "(rtalert: invalid len %d)", bp[i + 1]));
goto trunc;
}
- printf("(rtalert: 0x%04x) ", EXTRACT_16BITS(&bp[i + 2]));
+ ND_PRINT((ndo, "(rtalert: 0x%04x) ", EXTRACT_16BITS(&bp[i + 2])));
break;
case IP6OPT_JUMBO:
if (len - i < IP6OPT_JUMBO_LEN) {
- printf("(jumbo: trunc)");
+ ND_PRINT((ndo, "(jumbo: trunc)"));
goto trunc;
}
if (bp[i + 1] != IP6OPT_JUMBO_LEN - 2) {
- printf("(jumbo: invalid len %d)", bp[i + 1]);
+ ND_PRINT((ndo, "(jumbo: invalid len %d)", bp[i + 1]));
goto trunc;
}
- printf("(jumbo: %u) ", EXTRACT_32BITS(&bp[i + 2]));
+ ND_PRINT((ndo, "(jumbo: %u) ", EXTRACT_32BITS(&bp[i + 2])));
break;
case IP6OPT_HOME_ADDRESS:
if (len - i < IP6OPT_HOMEADDR_MINLEN) {
- printf("(homeaddr: trunc)");
+ ND_PRINT((ndo, "(homeaddr: trunc)"));
goto trunc;
}
if (bp[i + 1] < IP6OPT_HOMEADDR_MINLEN - 2) {
- printf("(homeaddr: invalid len %d)", bp[i + 1]);
+ ND_PRINT((ndo, "(homeaddr: invalid len %d)", bp[i + 1]));
goto trunc;
}
- printf("(homeaddr: %s", ip6addr_string(&bp[i + 2]));
+ ND_PRINT((ndo, "(homeaddr: %s", ip6addr_string(ndo, &bp[i + 2])));
if (bp[i + 1] > IP6OPT_HOMEADDR_MINLEN - 2) {
- ip6_sopt_print(&bp[i + IP6OPT_HOMEADDR_MINLEN],
+ ip6_sopt_print(ndo, &bp[i + IP6OPT_HOMEADDR_MINLEN],
(optlen - IP6OPT_HOMEADDR_MINLEN));
}
- printf(")");
- break;
- case IP6OPT_BINDING_UPDATE:
- if (len - i < IP6OPT_BU_MINLEN) {
- printf("(bu: trunc)");
- goto trunc;
- }
- if (bp[i + 1] < IP6OPT_BU_MINLEN - 2) {
- printf("(bu: invalid len %d)", bp[i + 1]);
- goto trunc;
- }
- printf("(bu: ");
- if (bp[i + 2] & 0x80)
- printf("A");
- if (bp[i + 2] & 0x40)
- printf("H");
- if (bp[i + 2] & 0x20)
- printf("S");
- if (bp[i + 2] & 0x10)
- printf("D");
- if ((bp[i + 2] & 0x0f) || bp[i + 3] || bp[i + 4])
- printf("res");
- printf(", sequence: %u", bp[i + 5]);
- printf(", lifetime: %u", EXTRACT_32BITS(&bp[i + 6]));
-
- if (bp[i + 1] > IP6OPT_BU_MINLEN - 2) {
- ip6_sopt_print(&bp[i + IP6OPT_BU_MINLEN],
- (optlen - IP6OPT_BU_MINLEN));
- }
- printf(")");
- break;
- case IP6OPT_BINDING_ACK:
- if (len - i < IP6OPT_BA_MINLEN) {
- printf("(ba: trunc)");
- goto trunc;
- }
- if (bp[i + 1] < IP6OPT_BA_MINLEN - 2) {
- printf("(ba: invalid len %d)", bp[i + 1]);
- goto trunc;
- }
- printf("(ba: ");
- printf("status: %u", bp[i + 2]);
- if (bp[i + 3])
- printf("res");
- printf(", sequence: %u", bp[i + 4]);
- printf(", lifetime: %u", EXTRACT_32BITS(&bp[i + 5]));
- printf(", refresh: %u", EXTRACT_32BITS(&bp[i + 9]));
-
- if (bp[i + 1] > IP6OPT_BA_MINLEN - 2) {
- ip6_sopt_print(&bp[i + IP6OPT_BA_MINLEN],
- (optlen - IP6OPT_BA_MINLEN));
- }
- printf(")");
- break;
- case IP6OPT_BINDING_REQ:
- if (len - i < IP6OPT_BR_MINLEN) {
- printf("(br: trunc)");
- goto trunc;
- }
- printf("(br");
- if (bp[i + 1] > IP6OPT_BR_MINLEN - 2) {
- ip6_sopt_print(&bp[i + IP6OPT_BR_MINLEN],
- (optlen - IP6OPT_BR_MINLEN));
- }
- printf(")");
+ ND_PRINT((ndo, ")"));
break;
default:
if (len - i < IP6OPT_MINLEN) {
- printf("(type %d: trunc)", bp[i]);
+ ND_PRINT((ndo, "(type %d: trunc)", bp[i]));
goto trunc;
}
- printf("(opt_type 0x%02x: len=%d)", bp[i], bp[i + 1]);
+ ND_PRINT((ndo, "(opt_type 0x%02x: len=%d)", bp[i], bp[i + 1]));
break;
}
}
- printf(" ");
-
-#if 0
-end:
-#endif
+ ND_PRINT((ndo, " "));
return;
trunc:
- printf("[trunc] ");
+ ND_PRINT((ndo, "[trunc] "));
}
int
-hbhopt_print(register const u_char *bp)
+hbhopt_print(netdissect_options *ndo, register const u_char *bp)
{
- const struct ip6_hbh *dp = (struct ip6_hbh *)bp;
+ const struct ip6_hbh *dp = (const struct ip6_hbh *)bp;
int hbhlen = 0;
- TCHECK(dp->ip6h_len);
+ ND_TCHECK(dp->ip6h_len);
hbhlen = (int)((dp->ip6h_len + 1) << 3);
- TCHECK2(*dp, hbhlen);
- printf("HBH ");
- if (vflag)
- ip6_opt_print((const u_char *)dp + sizeof(*dp), hbhlen - sizeof(*dp));
+ ND_TCHECK2(*dp, hbhlen);
+ ND_PRINT((ndo, "HBH "));
+ if (ndo->ndo_vflag)
+ ip6_opt_print(ndo, (const u_char *)dp + sizeof(*dp), hbhlen - sizeof(*dp));
return(hbhlen);
trunc:
- fputs("[|HBH]", stdout);
+ ND_PRINT((ndo, "[|HBH]"));
return(-1);
}
int
-dstopt_print(register const u_char *bp)
+dstopt_print(netdissect_options *ndo, register const u_char *bp)
{
- const struct ip6_dest *dp = (struct ip6_dest *)bp;
+ const struct ip6_dest *dp = (const struct ip6_dest *)bp;
int dstoptlen = 0;
- TCHECK(dp->ip6d_len);
+ ND_TCHECK(dp->ip6d_len);
dstoptlen = (int)((dp->ip6d_len + 1) << 3);
- TCHECK2(*dp, dstoptlen);
- printf("DSTOPT ");
- if (vflag) {
- ip6_opt_print((const u_char *)dp + sizeof(*dp),
+ ND_TCHECK2(*dp, dstoptlen);
+ ND_PRINT((ndo, "DSTOPT "));
+ if (ndo->ndo_vflag) {
+ ip6_opt_print(ndo, (const u_char *)dp + sizeof(*dp),
dstoptlen - sizeof(*dp));
}
return(dstoptlen);
trunc:
- fputs("[|DSTOPT]", stdout);
+ ND_PRINT((ndo, "[|DSTOPT]"));
return(-1);
}
-#endif /* INET6 */
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-ip6opts-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-ipcomp.c b/freebsd/contrib/tcpdump/print-ipcomp.c
index 04f16b38..4716fdae 100644
--- a/freebsd/contrib/tcpdump/print-ipcomp.c
+++ b/freebsd/contrib/tcpdump/print-ipcomp.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1988, 1989, 1990, 1991, 1993, 1994
* The Regents of the University of California. All rights reserved.
@@ -21,73 +24,54 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ipcomp.c,v 1.20 2003-11-19 00:36:08 guy Exp $";
-#endif
+/* \summary: IP Payload Compression Protocol (IPComp) printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <string.h>
-#include <tcpdump-stdinc.h>
-
-#include <stdio.h>
+#include <netdissect-stdinc.h>
struct ipcomp {
- u_int8_t comp_nxt; /* Next Header */
- u_int8_t comp_flags; /* Length of data, in 32bit */
- u_int16_t comp_cpi; /* Compression parameter index */
+ uint8_t comp_nxt; /* Next Header */
+ uint8_t comp_flags; /* Length of data, in 32bit */
+ uint16_t comp_cpi; /* Compression parameter index */
};
-#if defined(HAVE_LIBZ) && defined(HAVE_ZLIB_H)
-#include <zlib.h>
-#endif
-
-#include "interface.h"
-#include "addrtoname.h"
+#include "netdissect.h"
#include "extract.h"
-int
-ipcomp_print(register const u_char *bp, int *nhdr _U_)
+void
+ipcomp_print(netdissect_options *ndo, register const u_char *bp)
{
register const struct ipcomp *ipcomp;
- register const u_char *ep;
- u_int16_t cpi;
-#if defined(HAVE_LIBZ) && defined(HAVE_ZLIB_H)
- int advance;
-#endif
+ uint16_t cpi;
- ipcomp = (struct ipcomp *)bp;
+ ipcomp = (const struct ipcomp *)bp;
+ ND_TCHECK(*ipcomp);
cpi = EXTRACT_16BITS(&ipcomp->comp_cpi);
- /* 'ep' points to the end of available data. */
- ep = snapend;
-
- if ((u_char *)(ipcomp + 1) >= ep - sizeof(struct ipcomp)) {
- fputs("[|IPCOMP]", stdout);
- goto fail;
- }
- printf("IPComp(cpi=0x%04x)", cpi);
-
-#if defined(HAVE_LIBZ) && defined(HAVE_ZLIB_H)
- if (1)
- goto fail;
+ ND_PRINT((ndo, "IPComp(cpi=0x%04x)", cpi));
/*
- * We may want to decompress the packet here. Packet buffer
- * management is a headache (if we decompress, packet will become
- * larger).
+ * XXX - based on the CPI, we could decompress the packet here.
+ * Packet buffer management is a headache (if we decompress,
+ * packet will become larger).
+ *
+ * We would decompress the packet and then call a routine that,
+ * based on ipcomp->comp_nxt, dissects the decompressed data.
+ *
+ * Until we do that, however, we just return -1, so that
+ * the loop that processes "protocol"/"next header" types
+ * stops - there's nothing more it can do with a compressed
+ * payload.
*/
- if (nhdr)
- *nhdr = ipcomp->comp_nxt;
- advance = sizeof(struct ipcomp);
+ return;
- printf(": ");
- return advance;
-
-#endif
-fail:
- return -1;
+trunc:
+ ND_PRINT((ndo, "[|IPCOMP]"));
+ return;
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-ipcomp-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-ipfc.c b/freebsd/contrib/tcpdump/print-ipfc.c
index 4e431d32..c7177439 100644
--- a/freebsd/contrib/tcpdump/print-ipfc.c
+++ b/freebsd/contrib/tcpdump/print-ipfc.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1991, 1992, 1993, 1994, 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
@@ -21,31 +24,29 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ipfc.c,v 1.9 2005-11-13 12:12:42 guy Exp $ (LBL)";
-#endif
+/* \summary: IP over Fibre Channel printer */
+
+/* specification: RFC 2625 */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include <pcap.h>
-#include <stdio.h>
#include <string.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
-#include "ethertype.h"
#include "ether.h"
-#include "ipfc.h"
-/*
- * RFC 2625 IP-over-Fibre Channel.
- */
+struct ipfc_header {
+ u_char ipfc_dhost[8];
+ u_char ipfc_shost[8];
+};
+
+#define IPFC_HDRLEN 16
/* Extract src, dst addresses */
static inline void
@@ -64,39 +65,58 @@ extract_ipfc_addrs(const struct ipfc_header *ipfcp, char *ipfcsrc,
* Print the Network_Header
*/
static inline void
-ipfc_hdr_print(register const struct ipfc_header *ipfcp _U_,
+ipfc_hdr_print(netdissect_options *ndo,
+ register const struct ipfc_header *ipfcp _U_,
register u_int length, register const u_char *ipfcsrc,
register const u_char *ipfcdst)
{
const char *srcname, *dstname;
- srcname = etheraddr_string(ipfcsrc);
- dstname = etheraddr_string(ipfcdst);
+ srcname = etheraddr_string(ndo, ipfcsrc);
+ dstname = etheraddr_string(ndo, ipfcdst);
/*
- * XXX - show the upper 16 bits? Do so only if "vflag" is set?
+ * XXX - should we show the upper 16 bits of the addresses?
+ * Do so only if "vflag" is set?
+ * Section 3.3 "FC Port and Node Network Addresses" says that
+ *
+ * In this specification, both the Source and Destination
+ * 4-bit NAA identifiers SHALL be set to binary '0001'
+ * indicating that an IEEE 48-bit MAC address is contained
+ * in the lower 48 bits of the network address fields. The
+ * high order 12 bits in the network address fields SHALL
+ * be set to 0x0000.
+ *
+ * so, for captures following this specification, the upper 16
+ * bits should be 0x1000, followed by a MAC address.
*/
- (void) printf("%s %s %d: ", srcname, dstname, length);
+ ND_PRINT((ndo, "%s > %s, length %u: ", srcname, dstname, length));
}
-static void
-ipfc_print(const u_char *p, u_int length, u_int caplen)
+static u_int
+ipfc_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen)
{
const struct ipfc_header *ipfcp = (const struct ipfc_header *)p;
struct ether_header ehdr;
- u_short extracted_ethertype;
+ struct lladdr_info src, dst;
+ int llc_hdrlen;
if (caplen < IPFC_HDRLEN) {
- printf("[|ipfc]");
- return;
+ ND_PRINT((ndo, "[|ipfc]"));
+ return (caplen);
}
/*
* Get the network addresses into a canonical form
*/
extract_ipfc_addrs(ipfcp, (char *)ESRC(&ehdr), (char *)EDST(&ehdr));
- if (eflag)
- ipfc_hdr_print(ipfcp, length, ESRC(&ehdr), EDST(&ehdr));
+ if (ndo->ndo_eflag)
+ ipfc_hdr_print(ndo, ipfcp, length, ESRC(&ehdr), EDST(&ehdr));
+
+ src.addr = ESRC(&ehdr);
+ src.addr_string = etheraddr_string;
+ dst.addr = EDST(&ehdr);
+ dst.addr_string = etheraddr_string;
/* Skip over Network_Header */
length -= IPFC_HDRLEN;
@@ -104,22 +124,17 @@ ipfc_print(const u_char *p, u_int length, u_int caplen)
caplen -= IPFC_HDRLEN;
/* Try to print the LLC-layer header & higher layers */
- if (llc_print(p, length, caplen, ESRC(&ehdr), EDST(&ehdr),
- &extracted_ethertype) == 0) {
+ llc_hdrlen = llc_print(ndo, p, length, caplen, &src, &dst);
+ if (llc_hdrlen < 0) {
/*
* Some kinds of LLC packet we cannot
* handle intelligently
*/
- if (!eflag)
- ipfc_hdr_print(ipfcp, length + IPFC_HDRLEN,
- ESRC(&ehdr), EDST(&ehdr));
- if (extracted_ethertype) {
- printf("(LLC %s) ",
- etherproto_string(htons(extracted_ethertype)));
- }
- if (!suppress_default_print)
- default_print(p, caplen);
+ if (!ndo->ndo_suppress_default_print)
+ ND_DEFAULTPRINT(p, caplen);
+ llc_hdrlen = -llc_hdrlen;
}
+ return (IPFC_HDRLEN + llc_hdrlen);
}
/*
@@ -129,9 +144,10 @@ ipfc_print(const u_char *p, u_int length, u_int caplen)
* is the number of bytes actually captured.
*/
u_int
-ipfc_if_print(const struct pcap_pkthdr *h, register const u_char *p)
+ipfc_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, register const u_char *p)
{
- ipfc_print(p, h->len, h->caplen);
-
- return (IPFC_HDRLEN);
+ return (ipfc_print(ndo, p, h->len, h->caplen));
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-ipfc-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-ipnet.c b/freebsd/contrib/tcpdump/print-ipnet.c
index 75863458..fe59a5db 100644
--- a/freebsd/contrib/tcpdump/print-ipnet.c
+++ b/freebsd/contrib/tcpdump/print-ipnet.c
@@ -1,29 +1,42 @@
#include <machine/rtems-bsd-user-space.h>
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
+/* \summary: Solaris DLT_IPNET printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
-
-#include <stdio.h>
-#include <pcap.h>
+#include <netdissect-stdinc.h>
#include "netdissect.h"
-#include "interface.h"
-#include "addrtoname.h"
-#include "ipnet.h"
+
+typedef struct ipnet_hdr {
+ uint8_t iph_version;
+ uint8_t iph_family;
+ uint16_t iph_htype;
+ uint32_t iph_pktlen;
+ uint32_t iph_ifindex;
+ uint32_t iph_grifindex;
+ uint32_t iph_zsrc;
+ uint32_t iph_zdst;
+} ipnet_hdr_t;
+
+#define IPH_AF_INET 2 /* Matches Solaris's AF_INET */
+#define IPH_AF_INET6 26 /* Matches Solaris's AF_INET6 */
#ifdef DLT_IPNET
-const struct tok ipnet_values[] = {
+static const struct tok ipnet_values[] = {
{ IPH_AF_INET, "IPv4" },
{ IPH_AF_INET6, "IPv6" },
{ 0, NULL }
};
static inline void
-ipnet_hdr_print(struct netdissect_options *ndo, const u_char *bp, u_int length)
+ipnet_hdr_print(netdissect_options *ndo, const u_char *bp, u_int length)
{
const ipnet_hdr_t *hdr;
hdr = (const ipnet_hdr_t *)bp;
@@ -46,9 +59,9 @@ ipnet_hdr_print(struct netdissect_options *ndo, const u_char *bp, u_int length)
}
static void
-ipnet_print(struct netdissect_options *ndo, const u_char *p, u_int length, u_int caplen)
+ipnet_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen)
{
- ipnet_hdr_t *hdr;
+ const ipnet_hdr_t *hdr;
if (caplen < sizeof(ipnet_hdr_t)) {
ND_PRINT((ndo, "[|ipnet]"));
@@ -60,7 +73,7 @@ ipnet_print(struct netdissect_options *ndo, const u_char *p, u_int length, u_int
length -= sizeof(ipnet_hdr_t);
caplen -= sizeof(ipnet_hdr_t);
- hdr = (ipnet_hdr_t *)p;
+ hdr = (const ipnet_hdr_t *)p;
p += sizeof(ipnet_hdr_t);
switch (hdr->iph_family) {
@@ -69,19 +82,17 @@ ipnet_print(struct netdissect_options *ndo, const u_char *p, u_int length, u_int
ip_print(ndo, p, length);
break;
-#ifdef INET6
case IPH_AF_INET6:
ip6_print(ndo, p, length);
break;
-#endif /*INET6*/
default:
if (!ndo->ndo_eflag)
- ipnet_hdr_print(ndo, (u_char *)hdr,
+ ipnet_hdr_print(ndo, (const u_char *)hdr,
length + sizeof(ipnet_hdr_t));
if (!ndo->ndo_suppress_default_print)
- ndo->ndo_default_print(ndo, p, caplen);
+ ND_DEFAULTPRINT(p, caplen);
break;
}
}
@@ -93,7 +104,7 @@ ipnet_print(struct netdissect_options *ndo, const u_char *p, u_int length, u_int
* is the number of bytes actually captured.
*/
u_int
-ipnet_if_print(struct netdissect_options *ndo,
+ipnet_if_print(netdissect_options *ndo,
const struct pcap_pkthdr *h, const u_char *p)
{
ipnet_print(ndo, p, h->len, h->caplen);
@@ -109,3 +120,6 @@ ipnet_if_print(struct netdissect_options *ndo,
*/
#endif /* DLT_IPNET */
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-ipnet-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-ipx.c b/freebsd/contrib/tcpdump/print-ipx.c
index ae136429..517d5881 100644
--- a/freebsd/contrib/tcpdump/print-ipx.c
+++ b/freebsd/contrib/tcpdump/print-ipx.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1994, 1995, 1996
* The Regents of the University of California. All rights reserved.
@@ -20,70 +23,85 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * Format and print Novell IPX packets.
* Contributed by Brad Parker (brad@fcr.com).
- *
- * $FreeBSD$
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ipx.c,v 1.42 2005-05-06 08:26:44 guy Exp $";
-#endif
+/* \summary: Novell IPX printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include <stdlib.h>
#include <stdio.h>
-#include <string.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
-#include "ipx.h"
#include "extract.h"
-
-static const char *ipxaddr_string(u_int32_t, const u_char *);
-void ipx_decode(const struct ipxHdr *, const u_char *, u_int);
-void ipx_sap_print(const u_short *, u_int);
-void ipx_rip_print(const u_short *, u_int);
+/* well-known sockets */
+#define IPX_SKT_NCP 0x0451
+#define IPX_SKT_SAP 0x0452
+#define IPX_SKT_RIP 0x0453
+#define IPX_SKT_NETBIOS 0x0455
+#define IPX_SKT_DIAGNOSTICS 0x0456
+#define IPX_SKT_NWLINK_DGM 0x0553 /* NWLink datagram, may contain SMB */
+#define IPX_SKT_EIGRP 0x85be /* Cisco EIGRP over IPX */
+
+/* IPX transport header */
+struct ipxHdr {
+ uint16_t cksum; /* Checksum */
+ uint16_t length; /* Length, in bytes, including header */
+ uint8_t tCtl; /* Transport Control (i.e. hop count) */
+ uint8_t pType; /* Packet Type (i.e. level 2 protocol) */
+ uint16_t dstNet[2]; /* destination net */
+ uint8_t dstNode[6]; /* destination node */
+ uint16_t dstSkt; /* destination socket */
+ uint16_t srcNet[2]; /* source net */
+ uint8_t srcNode[6]; /* source node */
+ uint16_t srcSkt; /* source socket */
+};
+
+#define ipxSize 30
+
+static const char *ipxaddr_string(uint32_t, const u_char *);
+static void ipx_decode(netdissect_options *, const struct ipxHdr *, const u_char *, u_int);
+static void ipx_sap_print(netdissect_options *, const u_short *, u_int);
+static void ipx_rip_print(netdissect_options *, const u_short *, u_int);
/*
* Print IPX datagram packets.
*/
void
-ipx_print(const u_char *p, u_int length)
+ipx_print(netdissect_options *ndo, const u_char *p, u_int length)
{
const struct ipxHdr *ipx = (const struct ipxHdr *)p;
- if (!eflag)
- printf("IPX ");
+ if (!ndo->ndo_eflag)
+ ND_PRINT((ndo, "IPX "));
- TCHECK(ipx->srcSkt);
- (void)printf("%s.%04x > ",
+ ND_TCHECK(ipx->srcSkt);
+ ND_PRINT((ndo, "%s.%04x > ",
ipxaddr_string(EXTRACT_32BITS(ipx->srcNet), ipx->srcNode),
- EXTRACT_16BITS(&ipx->srcSkt));
+ EXTRACT_16BITS(&ipx->srcSkt)));
- (void)printf("%s.%04x: ",
+ ND_PRINT((ndo, "%s.%04x: ",
ipxaddr_string(EXTRACT_32BITS(ipx->dstNet), ipx->dstNode),
- EXTRACT_16BITS(&ipx->dstSkt));
+ EXTRACT_16BITS(&ipx->dstSkt)));
/* take length from ipx header */
- TCHECK(ipx->length);
+ ND_TCHECK(ipx->length);
length = EXTRACT_16BITS(&ipx->length);
- ipx_decode(ipx, (u_char *)ipx + ipxSize, length - ipxSize);
+ ipx_decode(ndo, ipx, p + ipxSize, length - ipxSize);
return;
trunc:
- printf("[|ipx %d]", length);
+ ND_PRINT((ndo, "[|ipx %d]", length));
}
static const char *
-ipxaddr_string(u_int32_t net, const u_char *node)
+ipxaddr_string(uint32_t net, const u_char *node)
{
static char line[256];
@@ -93,52 +111,52 @@ ipxaddr_string(u_int32_t net, const u_char *node)
return line;
}
-void
-ipx_decode(const struct ipxHdr *ipx, const u_char *datap, u_int length)
+static void
+ipx_decode(netdissect_options *ndo, const struct ipxHdr *ipx, const u_char *datap, u_int length)
{
register u_short dstSkt;
dstSkt = EXTRACT_16BITS(&ipx->dstSkt);
switch (dstSkt) {
case IPX_SKT_NCP:
- (void)printf("ipx-ncp %d", length);
+ ND_PRINT((ndo, "ipx-ncp %d", length));
break;
case IPX_SKT_SAP:
- ipx_sap_print((u_short *)datap, length);
+ ipx_sap_print(ndo, (const u_short *)datap, length);
break;
case IPX_SKT_RIP:
- ipx_rip_print((u_short *)datap, length);
+ ipx_rip_print(ndo, (const u_short *)datap, length);
break;
case IPX_SKT_NETBIOS:
- (void)printf("ipx-netbios %d", length);
-#ifdef TCPDUMP_DO_SMB
- ipx_netbios_print(datap, length);
+ ND_PRINT((ndo, "ipx-netbios %d", length));
+#ifdef ENABLE_SMB
+ ipx_netbios_print(ndo, datap, length);
#endif
break;
case IPX_SKT_DIAGNOSTICS:
- (void)printf("ipx-diags %d", length);
+ ND_PRINT((ndo, "ipx-diags %d", length));
break;
case IPX_SKT_NWLINK_DGM:
- (void)printf("ipx-nwlink-dgm %d", length);
-#ifdef TCPDUMP_DO_SMB
- ipx_netbios_print(datap, length);
+ ND_PRINT((ndo, "ipx-nwlink-dgm %d", length));
+#ifdef ENABLE_SMB
+ ipx_netbios_print(ndo, datap, length);
#endif
break;
case IPX_SKT_EIGRP:
- eigrp_print(datap, length);
+ eigrp_print(ndo, datap, length);
break;
default:
- (void)printf("ipx-#%x %d", dstSkt, length);
+ ND_PRINT((ndo, "ipx-#%x %d", dstSkt, length));
break;
}
}
-void
-ipx_sap_print(const u_short *ipx, u_int length)
+static void
+ipx_sap_print(netdissect_options *ndo, const u_short *ipx, u_int length)
{
int command, i;
- TCHECK(ipx[0]);
+ ND_TCHECK(ipx[0]);
command = EXTRACT_16BITS(ipx);
ipx++;
length -= 2;
@@ -147,79 +165,82 @@ ipx_sap_print(const u_short *ipx, u_int length)
case 1:
case 3:
if (command == 1)
- (void)printf("ipx-sap-req");
+ ND_PRINT((ndo, "ipx-sap-req"));
else
- (void)printf("ipx-sap-nearest-req");
+ ND_PRINT((ndo, "ipx-sap-nearest-req"));
- TCHECK(ipx[0]);
- (void)printf(" %s", ipxsap_string(htons(EXTRACT_16BITS(&ipx[0]))));
+ ND_TCHECK(ipx[0]);
+ ND_PRINT((ndo, " %s", ipxsap_string(ndo, htons(EXTRACT_16BITS(&ipx[0])))));
break;
case 2:
case 4:
if (command == 2)
- (void)printf("ipx-sap-resp");
+ ND_PRINT((ndo, "ipx-sap-resp"));
else
- (void)printf("ipx-sap-nearest-resp");
+ ND_PRINT((ndo, "ipx-sap-nearest-resp"));
for (i = 0; i < 8 && length > 0; i++) {
- TCHECK(ipx[0]);
- (void)printf(" %s '", ipxsap_string(htons(EXTRACT_16BITS(&ipx[0]))));
- if (fn_printzp((u_char *)&ipx[1], 48, snapend)) {
- printf("'");
+ ND_TCHECK(ipx[0]);
+ ND_PRINT((ndo, " %s '", ipxsap_string(ndo, htons(EXTRACT_16BITS(&ipx[0])))));
+ if (fn_printzp(ndo, (const u_char *)&ipx[1], 48, ndo->ndo_snapend)) {
+ ND_PRINT((ndo, "'"));
goto trunc;
}
- TCHECK2(ipx[25], 10);
- printf("' addr %s",
- ipxaddr_string(EXTRACT_32BITS(&ipx[25]), (u_char *)&ipx[27]));
+ ND_TCHECK2(ipx[25], 10);
+ ND_PRINT((ndo, "' addr %s",
+ ipxaddr_string(EXTRACT_32BITS(&ipx[25]), (const u_char *)&ipx[27])));
ipx += 32;
length -= 64;
}
break;
default:
- (void)printf("ipx-sap-?%x", command);
+ ND_PRINT((ndo, "ipx-sap-?%x", command));
break;
}
return;
trunc:
- printf("[|ipx %d]", length);
+ ND_PRINT((ndo, "[|ipx %d]", length));
}
-void
-ipx_rip_print(const u_short *ipx, u_int length)
+static void
+ipx_rip_print(netdissect_options *ndo, const u_short *ipx, u_int length)
{
int command, i;
- TCHECK(ipx[0]);
+ ND_TCHECK(ipx[0]);
command = EXTRACT_16BITS(ipx);
ipx++;
length -= 2;
switch (command) {
case 1:
- (void)printf("ipx-rip-req");
+ ND_PRINT((ndo, "ipx-rip-req"));
if (length > 0) {
- TCHECK(ipx[3]);
- (void)printf(" %08x/%d.%d", EXTRACT_32BITS(&ipx[0]),
- EXTRACT_16BITS(&ipx[2]), EXTRACT_16BITS(&ipx[3]));
+ ND_TCHECK(ipx[3]);
+ ND_PRINT((ndo, " %08x/%d.%d", EXTRACT_32BITS(&ipx[0]),
+ EXTRACT_16BITS(&ipx[2]), EXTRACT_16BITS(&ipx[3])));
}
break;
case 2:
- (void)printf("ipx-rip-resp");
+ ND_PRINT((ndo, "ipx-rip-resp"));
for (i = 0; i < 50 && length > 0; i++) {
- TCHECK(ipx[3]);
- (void)printf(" %08x/%d.%d", EXTRACT_32BITS(&ipx[0]),
- EXTRACT_16BITS(&ipx[2]), EXTRACT_16BITS(&ipx[3]));
+ ND_TCHECK(ipx[3]);
+ ND_PRINT((ndo, " %08x/%d.%d", EXTRACT_32BITS(&ipx[0]),
+ EXTRACT_16BITS(&ipx[2]), EXTRACT_16BITS(&ipx[3])));
ipx += 4;
length -= 8;
}
break;
default:
- (void)printf("ipx-rip-?%x", command);
+ ND_PRINT((ndo, "ipx-rip-?%x", command));
break;
}
return;
trunc:
- printf("[|ipx %d]", length);
+ ND_PRINT((ndo, "[|ipx %d]", length));
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-ipx-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-isakmp.c b/freebsd/contrib/tcpdump/print-isakmp.c
index 8b9e3508..015f3141 100644
--- a/freebsd/contrib/tcpdump/print-isakmp.c
+++ b/freebsd/contrib/tcpdump/print-isakmp.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
* All rights reserved.
@@ -30,46 +33,561 @@
*
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-isakmp.c,v 1.61 2008-02-05 19:34:25 guy Exp $ (LBL)";
-#endif
+/* \summary: Internet Security Association and Key Management Protocol (ISAKMP) printer */
-#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+/* The functions from print-esp.c used in this file are only defined when both
+ * OpenSSL and evp.h are detected. Employ the same preprocessor device here.
+ */
+#ifndef HAVE_OPENSSL_EVP_H
+#undef HAVE_LIBCRYPTO
+#endif
+
+#include <netdissect-stdinc.h>
#include <string.h>
-#include <stdio.h>
-
-#include "isakmp.h"
-#include "ipsec_doi.h"
-#include "oakley.h"
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
-#include "extract.h" /* must come after interface.h */
+#include "extract.h"
#include "ip.h"
-#ifdef INET6
#include "ip6.h"
-#endif
-#ifndef HAVE_SOCKADDR_STORAGE
-#define sockaddr_storage sockaddr
+/* refer to RFC 2408 */
+
+typedef u_char cookie_t[8];
+typedef u_char msgid_t[4];
+
+#define PORT_ISAKMP 500
+
+/* 3.1 ISAKMP Header Format (IKEv1 and IKEv2)
+ 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ ! Initiator !
+ ! Cookie !
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ ! Responder !
+ ! Cookie !
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ ! Next Payload ! MjVer ! MnVer ! Exchange Type ! Flags !
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ ! Message ID !
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ ! Length !
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+*/
+struct isakmp {
+ cookie_t i_ck; /* Initiator Cookie */
+ cookie_t r_ck; /* Responder Cookie */
+ uint8_t np; /* Next Payload Type */
+ uint8_t vers;
+#define ISAKMP_VERS_MAJOR 0xf0
+#define ISAKMP_VERS_MAJOR_SHIFT 4
+#define ISAKMP_VERS_MINOR 0x0f
+#define ISAKMP_VERS_MINOR_SHIFT 0
+ uint8_t etype; /* Exchange Type */
+ uint8_t flags; /* Flags */
+ msgid_t msgid;
+ uint32_t len; /* Length */
+};
+
+/* Next Payload Type */
+#define ISAKMP_NPTYPE_NONE 0 /* NONE*/
+#define ISAKMP_NPTYPE_SA 1 /* Security Association */
+#define ISAKMP_NPTYPE_P 2 /* Proposal */
+#define ISAKMP_NPTYPE_T 3 /* Transform */
+#define ISAKMP_NPTYPE_KE 4 /* Key Exchange */
+#define ISAKMP_NPTYPE_ID 5 /* Identification */
+#define ISAKMP_NPTYPE_CERT 6 /* Certificate */
+#define ISAKMP_NPTYPE_CR 7 /* Certificate Request */
+#define ISAKMP_NPTYPE_HASH 8 /* Hash */
+#define ISAKMP_NPTYPE_SIG 9 /* Signature */
+#define ISAKMP_NPTYPE_NONCE 10 /* Nonce */
+#define ISAKMP_NPTYPE_N 11 /* Notification */
+#define ISAKMP_NPTYPE_D 12 /* Delete */
+#define ISAKMP_NPTYPE_VID 13 /* Vendor ID */
+#define ISAKMP_NPTYPE_v2E 46 /* v2 Encrypted payload */
+
+#define IKEv1_MAJOR_VERSION 1
+#define IKEv1_MINOR_VERSION 0
+
+#define IKEv2_MAJOR_VERSION 2
+#define IKEv2_MINOR_VERSION 0
+
+/* Flags */
+#define ISAKMP_FLAG_E 0x01 /* Encryption Bit */
+#define ISAKMP_FLAG_C 0x02 /* Commit Bit */
+#define ISAKMP_FLAG_extra 0x04
+
+/* IKEv2 */
+#define ISAKMP_FLAG_I (1 << 3) /* (I)nitiator */
+#define ISAKMP_FLAG_V (1 << 4) /* (V)ersion */
+#define ISAKMP_FLAG_R (1 << 5) /* (R)esponse */
+
+
+/* 3.2 Payload Generic Header
+ 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ ! Next Payload ! RESERVED ! Payload Length !
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+*/
+struct isakmp_gen {
+ uint8_t np; /* Next Payload */
+ uint8_t critical; /* bit 7 - critical, rest is RESERVED */
+ uint16_t len; /* Payload Length */
+};
+
+/* 3.3 Data Attributes
+ 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ !A! Attribute Type ! AF=0 Attribute Length !
+ !F! ! AF=1 Attribute Value !
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ . AF=0 Attribute Value .
+ . AF=1 Not Transmitted .
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+*/
+struct isakmp_data {
+ uint16_t type; /* defined by DOI-spec, and Attribute Format */
+ uint16_t lorv; /* if f equal 1, Attribute Length */
+ /* if f equal 0, Attribute Value */
+ /* if f equal 1, Attribute Value */
+};
+
+/* 3.4 Security Association Payload */
+ /* MAY NOT be used, because of being defined in ipsec-doi. */
+ /*
+ If the current payload is the last in the message,
+ then the value of the next payload field will be 0.
+ This field MUST NOT contain the
+ values for the Proposal or Transform payloads as they are considered
+ part of the security association negotiation. For example, this
+ field would contain the value "10" (Nonce payload) in the first
+ message of a Base Exchange (see Section 4.4) and the value "0" in the
+ first message of an Identity Protect Exchange (see Section 4.5).
+ */
+struct ikev1_pl_sa {
+ struct isakmp_gen h;
+ uint32_t doi; /* Domain of Interpretation */
+ uint32_t sit; /* Situation */
+};
+
+/* 3.5 Proposal Payload */
+ /*
+ The value of the next payload field MUST only contain the value "2"
+ or "0". If there are additional Proposal payloads in the message,
+ then this field will be 2. If the current Proposal payload is the
+ last within the security association proposal, then this field will
+ be 0.
+ */
+struct ikev1_pl_p {
+ struct isakmp_gen h;
+ uint8_t p_no; /* Proposal # */
+ uint8_t prot_id; /* Protocol */
+ uint8_t spi_size; /* SPI Size */
+ uint8_t num_t; /* Number of Transforms */
+ /* SPI */
+};
+
+/* 3.6 Transform Payload */
+ /*
+ The value of the next payload field MUST only contain the value "3"
+ or "0". If there are additional Transform payloads in the proposal,
+ then this field will be 3. If the current Transform payload is the
+ last within the proposal, then this field will be 0.
+ */
+struct ikev1_pl_t {
+ struct isakmp_gen h;
+ uint8_t t_no; /* Transform # */
+ uint8_t t_id; /* Transform-Id */
+ uint16_t reserved; /* RESERVED2 */
+ /* SA Attributes */
+};
+
+/* 3.7 Key Exchange Payload */
+struct ikev1_pl_ke {
+ struct isakmp_gen h;
+ /* Key Exchange Data */
+};
+
+/* 3.8 Identification Payload */
+ /* MUST NOT to be used, because of being defined in ipsec-doi. */
+struct ikev1_pl_id {
+ struct isakmp_gen h;
+ union {
+ uint8_t id_type; /* ID Type */
+ uint32_t doi_data; /* DOI Specific ID Data */
+ } d;
+ /* Identification Data */
+};
+
+/* 3.9 Certificate Payload */
+struct ikev1_pl_cert {
+ struct isakmp_gen h;
+ uint8_t encode; /* Cert Encoding */
+ char cert; /* Certificate Data */
+ /*
+ This field indicates the type of
+ certificate or certificate-related information contained in the
+ Certificate Data field.
+ */
+};
+
+/* 3.10 Certificate Request Payload */
+struct ikev1_pl_cr {
+ struct isakmp_gen h;
+ uint8_t num_cert; /* # Cert. Types */
+ /*
+ Certificate Types (variable length)
+ -- Contains a list of the types of certificates requested,
+ sorted in order of preference. Each individual certificate
+ type is 1 octet. This field is NOT requiredo
+ */
+ /* # Certificate Authorities (1 octet) */
+ /* Certificate Authorities (variable length) */
+};
+
+/* 3.11 Hash Payload */
+ /* may not be used, because of having only data. */
+struct ikev1_pl_hash {
+ struct isakmp_gen h;
+ /* Hash Data */
+};
+
+/* 3.12 Signature Payload */
+ /* may not be used, because of having only data. */
+struct ikev1_pl_sig {
+ struct isakmp_gen h;
+ /* Signature Data */
+};
+
+/* 3.13 Nonce Payload */
+ /* may not be used, because of having only data. */
+struct ikev1_pl_nonce {
+ struct isakmp_gen h;
+ /* Nonce Data */
+};
+
+/* 3.14 Notification Payload */
+struct ikev1_pl_n {
+ struct isakmp_gen h;
+ uint32_t doi; /* Domain of Interpretation */
+ uint8_t prot_id; /* Protocol-ID */
+ uint8_t spi_size; /* SPI Size */
+ uint16_t type; /* Notify Message Type */
+ /* SPI */
+ /* Notification Data */
+};
+
+/* 3.14.1 Notify Message Types */
+/* NOTIFY MESSAGES - ERROR TYPES */
+#define ISAKMP_NTYPE_INVALID_PAYLOAD_TYPE 1
+#define ISAKMP_NTYPE_DOI_NOT_SUPPORTED 2
+#define ISAKMP_NTYPE_SITUATION_NOT_SUPPORTED 3
+#define ISAKMP_NTYPE_INVALID_COOKIE 4
+#define ISAKMP_NTYPE_INVALID_MAJOR_VERSION 5
+#define ISAKMP_NTYPE_INVALID_MINOR_VERSION 6
+#define ISAKMP_NTYPE_INVALID_EXCHANGE_TYPE 7
+#define ISAKMP_NTYPE_INVALID_FLAGS 8
+#define ISAKMP_NTYPE_INVALID_MESSAGE_ID 9
+#define ISAKMP_NTYPE_INVALID_PROTOCOL_ID 10
+#define ISAKMP_NTYPE_INVALID_SPI 11
+#define ISAKMP_NTYPE_INVALID_TRANSFORM_ID 12
+#define ISAKMP_NTYPE_ATTRIBUTES_NOT_SUPPORTED 13
+#define ISAKMP_NTYPE_NO_PROPOSAL_CHOSEN 14
+#define ISAKMP_NTYPE_BAD_PROPOSAL_SYNTAX 15
+#define ISAKMP_NTYPE_PAYLOAD_MALFORMED 16
+#define ISAKMP_NTYPE_INVALID_KEY_INFORMATION 17
+#define ISAKMP_NTYPE_INVALID_ID_INFORMATION 18
+#define ISAKMP_NTYPE_INVALID_CERT_ENCODING 19
+#define ISAKMP_NTYPE_INVALID_CERTIFICATE 20
+#define ISAKMP_NTYPE_BAD_CERT_REQUEST_SYNTAX 21
+#define ISAKMP_NTYPE_INVALID_CERT_AUTHORITY 22
+#define ISAKMP_NTYPE_INVALID_HASH_INFORMATION 23
+#define ISAKMP_NTYPE_AUTHENTICATION_FAILED 24
+#define ISAKMP_NTYPE_INVALID_SIGNATURE 25
+#define ISAKMP_NTYPE_ADDRESS_NOTIFICATION 26
+
+/* 3.15 Delete Payload */
+struct ikev1_pl_d {
+ struct isakmp_gen h;
+ uint32_t doi; /* Domain of Interpretation */
+ uint8_t prot_id; /* Protocol-Id */
+ uint8_t spi_size; /* SPI Size */
+ uint16_t num_spi; /* # of SPIs */
+ /* SPI(es) */
+};
+
+struct ikev1_ph1tab {
+ struct ikev1_ph1 *head;
+ struct ikev1_ph1 *tail;
+ int len;
+};
+
+struct isakmp_ph2tab {
+ struct ikev1_ph2 *head;
+ struct ikev1_ph2 *tail;
+ int len;
+};
+
+/* IKEv2 (RFC4306) */
+
+/* 3.3 Security Association Payload -- generic header */
+/* 3.3.1. Proposal Substructure */
+struct ikev2_p {
+ struct isakmp_gen h;
+ uint8_t p_no; /* Proposal # */
+ uint8_t prot_id; /* Protocol */
+ uint8_t spi_size; /* SPI Size */
+ uint8_t num_t; /* Number of Transforms */
+};
+
+/* 3.3.2. Transform Substructure */
+struct ikev2_t {
+ struct isakmp_gen h;
+ uint8_t t_type; /* Transform Type (ENCR,PRF,INTEG,etc.*/
+ uint8_t res2; /* reserved byte */
+ uint16_t t_id; /* Transform ID */
+};
+
+enum ikev2_t_type {
+ IV2_T_ENCR = 1,
+ IV2_T_PRF = 2,
+ IV2_T_INTEG= 3,
+ IV2_T_DH = 4,
+ IV2_T_ESN = 5
+};
+
+/* 3.4. Key Exchange Payload */
+struct ikev2_ke {
+ struct isakmp_gen h;
+ uint16_t ke_group;
+ uint16_t ke_res1;
+ /* KE data */
+};
+
+
+/* 3.5. Identification Payloads */
+enum ikev2_id_type {
+ ID_IPV4_ADDR=1,
+ ID_FQDN=2,
+ ID_RFC822_ADDR=3,
+ ID_IPV6_ADDR=5,
+ ID_DER_ASN1_DN=9,
+ ID_DER_ASN1_GN=10,
+ ID_KEY_ID=11
+};
+struct ikev2_id {
+ struct isakmp_gen h;
+ uint8_t type; /* ID type */
+ uint8_t res1;
+ uint16_t res2;
+ /* SPI */
+ /* Notification Data */
+};
+
+/* 3.10 Notification Payload */
+struct ikev2_n {
+ struct isakmp_gen h;
+ uint8_t prot_id; /* Protocol-ID */
+ uint8_t spi_size; /* SPI Size */
+ uint16_t type; /* Notify Message Type */
+};
+
+enum ikev2_n_type {
+ IV2_NOTIFY_UNSUPPORTED_CRITICAL_PAYLOAD = 1,
+ IV2_NOTIFY_INVALID_IKE_SPI = 4,
+ IV2_NOTIFY_INVALID_MAJOR_VERSION = 5,
+ IV2_NOTIFY_INVALID_SYNTAX = 7,
+ IV2_NOTIFY_INVALID_MESSAGE_ID = 9,
+ IV2_NOTIFY_INVALID_SPI =11,
+ IV2_NOTIFY_NO_PROPOSAL_CHOSEN =14,
+ IV2_NOTIFY_INVALID_KE_PAYLOAD =17,
+ IV2_NOTIFY_AUTHENTICATION_FAILED =24,
+ IV2_NOTIFY_SINGLE_PAIR_REQUIRED =34,
+ IV2_NOTIFY_NO_ADDITIONAL_SAS =35,
+ IV2_NOTIFY_INTERNAL_ADDRESS_FAILURE =36,
+ IV2_NOTIFY_FAILED_CP_REQUIRED =37,
+ IV2_NOTIFY_INVALID_SELECTORS =39,
+ IV2_NOTIFY_INITIAL_CONTACT =16384,
+ IV2_NOTIFY_SET_WINDOW_SIZE =16385,
+ IV2_NOTIFY_ADDITIONAL_TS_POSSIBLE =16386,
+ IV2_NOTIFY_IPCOMP_SUPPORTED =16387,
+ IV2_NOTIFY_NAT_DETECTION_SOURCE_IP =16388,
+ IV2_NOTIFY_NAT_DETECTION_DESTINATION_IP =16389,
+ IV2_NOTIFY_COOKIE =16390,
+ IV2_NOTIFY_USE_TRANSPORT_MODE =16391,
+ IV2_NOTIFY_HTTP_CERT_LOOKUP_SUPPORTED =16392,
+ IV2_NOTIFY_REKEY_SA =16393,
+ IV2_NOTIFY_ESP_TFC_PADDING_NOT_SUPPORTED =16394,
+ IV2_NOTIFY_NON_FIRST_FRAGMENTS_ALSO =16395
+};
+
+struct notify_messages {
+ uint16_t type;
+ char *msg;
+};
+
+/* 3.8 Notification Payload */
+struct ikev2_auth {
+ struct isakmp_gen h;
+ uint8_t auth_method; /* Protocol-ID */
+ uint8_t reserved[3];
+ /* authentication data */
+};
+
+enum ikev2_auth_type {
+ IV2_RSA_SIG = 1,
+ IV2_SHARED = 2,
+ IV2_DSS_SIG = 3
+};
+
+/* refer to RFC 2409 */
+
+#if 0
+/* isakmp sa structure */
+struct oakley_sa {
+ uint8_t proto_id; /* OAKLEY */
+ vchar_t *spi; /* spi */
+ uint8_t dhgrp; /* DH; group */
+ uint8_t auth_t; /* method of authentication */
+ uint8_t prf_t; /* type of prf */
+ uint8_t hash_t; /* type of hash */
+ uint8_t enc_t; /* type of cipher */
+ uint8_t life_t; /* type of duration of lifetime */
+ uint32_t ldur; /* life duration */
+};
#endif
+/* refer to RFC 2407 */
+
+#define IPSEC_DOI 1
+
+/* 4.2 IPSEC Situation Definition */
+#define IPSECDOI_SIT_IDENTITY_ONLY 0x00000001
+#define IPSECDOI_SIT_SECRECY 0x00000002
+#define IPSECDOI_SIT_INTEGRITY 0x00000004
+
+/* 4.4.1 IPSEC Security Protocol Identifiers */
+ /* 4.4.2 IPSEC ISAKMP Transform Values */
+#define IPSECDOI_PROTO_ISAKMP 1
+#define IPSECDOI_KEY_IKE 1
+
+/* 4.4.1 IPSEC Security Protocol Identifiers */
+#define IPSECDOI_PROTO_IPSEC_AH 2
+ /* 4.4.3 IPSEC AH Transform Values */
+#define IPSECDOI_AH_MD5 2
+#define IPSECDOI_AH_SHA 3
+#define IPSECDOI_AH_DES 4
+#define IPSECDOI_AH_SHA2_256 5
+#define IPSECDOI_AH_SHA2_384 6
+#define IPSECDOI_AH_SHA2_512 7
+
+/* 4.4.1 IPSEC Security Protocol Identifiers */
+#define IPSECDOI_PROTO_IPSEC_ESP 3
+ /* 4.4.4 IPSEC ESP Transform Identifiers */
+#define IPSECDOI_ESP_DES_IV64 1
+#define IPSECDOI_ESP_DES 2
+#define IPSECDOI_ESP_3DES 3
+#define IPSECDOI_ESP_RC5 4
+#define IPSECDOI_ESP_IDEA 5
+#define IPSECDOI_ESP_CAST 6
+#define IPSECDOI_ESP_BLOWFISH 7
+#define IPSECDOI_ESP_3IDEA 8
+#define IPSECDOI_ESP_DES_IV32 9
+#define IPSECDOI_ESP_RC4 10
+#define IPSECDOI_ESP_NULL 11
+#define IPSECDOI_ESP_RIJNDAEL 12
+#define IPSECDOI_ESP_AES 12
+
+/* 4.4.1 IPSEC Security Protocol Identifiers */
+#define IPSECDOI_PROTO_IPCOMP 4
+ /* 4.4.5 IPSEC IPCOMP Transform Identifiers */
+#define IPSECDOI_IPCOMP_OUI 1
+#define IPSECDOI_IPCOMP_DEFLATE 2
+#define IPSECDOI_IPCOMP_LZS 3
+
+/* 4.5 IPSEC Security Association Attributes */
+#define IPSECDOI_ATTR_SA_LTYPE 1 /* B */
+#define IPSECDOI_ATTR_SA_LTYPE_DEFAULT 1
+#define IPSECDOI_ATTR_SA_LTYPE_SEC 1
+#define IPSECDOI_ATTR_SA_LTYPE_KB 2
+#define IPSECDOI_ATTR_SA_LDUR 2 /* V */
+#define IPSECDOI_ATTR_SA_LDUR_DEFAULT 28800 /* 8 hours */
+#define IPSECDOI_ATTR_GRP_DESC 3 /* B */
+#define IPSECDOI_ATTR_ENC_MODE 4 /* B */
+ /* default value: host dependent */
+#define IPSECDOI_ATTR_ENC_MODE_TUNNEL 1
+#define IPSECDOI_ATTR_ENC_MODE_TRNS 2
+#define IPSECDOI_ATTR_AUTH 5 /* B */
+ /* 0 means not to use authentication. */
+#define IPSECDOI_ATTR_AUTH_HMAC_MD5 1
+#define IPSECDOI_ATTR_AUTH_HMAC_SHA1 2
+#define IPSECDOI_ATTR_AUTH_DES_MAC 3
+#define IPSECDOI_ATTR_AUTH_KPDK 4 /*RFC-1826(Key/Pad/Data/Key)*/
+ /*
+ * When negotiating ESP without authentication, the Auth
+ * Algorithm attribute MUST NOT be included in the proposal.
+ * When negotiating ESP without confidentiality, the Auth
+ * Algorithm attribute MUST be included in the proposal and
+ * the ESP transform ID must be ESP_NULL.
+ */
+#define IPSECDOI_ATTR_KEY_LENGTH 6 /* B */
+#define IPSECDOI_ATTR_KEY_ROUNDS 7 /* B */
+#define IPSECDOI_ATTR_COMP_DICT_SIZE 8 /* B */
+#define IPSECDOI_ATTR_COMP_PRIVALG 9 /* V */
+
+/* 4.6.1 Security Association Payload */
+struct ipsecdoi_sa {
+ struct isakmp_gen h;
+ uint32_t doi; /* Domain of Interpretation */
+ uint32_t sit; /* Situation */
+};
+
+struct ipsecdoi_secrecy_h {
+ uint16_t len;
+ uint16_t reserved;
+};
+
+/* 4.6.2.1 Identification Type Values */
+struct ipsecdoi_id {
+ struct isakmp_gen h;
+ uint8_t type; /* ID Type */
+ uint8_t proto_id; /* Protocol ID */
+ uint16_t port; /* Port */
+ /* Identification Data */
+};
+
+#define IPSECDOI_ID_IPV4_ADDR 1
+#define IPSECDOI_ID_FQDN 2
+#define IPSECDOI_ID_USER_FQDN 3
+#define IPSECDOI_ID_IPV4_ADDR_SUBNET 4
+#define IPSECDOI_ID_IPV6_ADDR 5
+#define IPSECDOI_ID_IPV6_ADDR_SUBNET 6
+#define IPSECDOI_ID_IPV4_ADDR_RANGE 7
+#define IPSECDOI_ID_IPV6_ADDR_RANGE 8
+#define IPSECDOI_ID_DER_ASN1_DN 9
+#define IPSECDOI_ID_DER_ASN1_GN 10
+#define IPSECDOI_ID_KEY_ID 11
+
+/* 4.6.3 IPSEC DOI Notify Message Types */
+/* Notify Messages - Status Types */
+#define IPSECDOI_NTYPE_RESPONDER_LIFETIME 24576
+#define IPSECDOI_NTYPE_REPLAY_STATUS 24577
+#define IPSECDOI_NTYPE_INITIAL_CONTACT 24578
+
#define DECLARE_PRINTER(func) static const u_char *ike##func##_print( \
netdissect_options *ndo, u_char tpay, \
const struct isakmp_gen *ext, \
u_int item_len, \
const u_char *end_pointer, \
- u_int32_t phase,\
- u_int32_t doi0, \
- u_int32_t proto0, int depth)
+ uint32_t phase,\
+ uint32_t doi0, \
+ uint32_t proto0, int depth)
DECLARE_PRINTER(v1_sa);
DECLARE_PRINTER(v1_p);
@@ -103,28 +621,27 @@ static const u_char *ikev2_e_print(netdissect_options *ndo,
struct isakmp *base,
u_char tpay,
const struct isakmp_gen *ext,
- u_int item_len,
- const u_char *end_pointer,
- u_int32_t phase,
- u_int32_t doi0,
- u_int32_t proto0, int depth);
+ u_int item_len,
+ const u_char *end_pointer,
+ uint32_t phase,
+ uint32_t doi0,
+ uint32_t proto0, int depth);
static const u_char *ike_sub0_print(netdissect_options *ndo,u_char, const struct isakmp_gen *,
- const u_char *, u_int32_t, u_int32_t, u_int32_t, int);
+ const u_char *, uint32_t, uint32_t, uint32_t, int);
static const u_char *ikev1_sub_print(netdissect_options *ndo,u_char, const struct isakmp_gen *,
- const u_char *, u_int32_t, u_int32_t, u_int32_t, int);
+ const u_char *, uint32_t, uint32_t, uint32_t, int);
static const u_char *ikev2_sub_print(netdissect_options *ndo,
struct isakmp *base,
u_char np, const struct isakmp_gen *ext,
- const u_char *ep, u_int32_t phase,
- u_int32_t doi, u_int32_t proto,
+ const u_char *ep, uint32_t phase,
+ uint32_t doi, uint32_t proto,
int depth);
static char *numstr(int);
-static void safememcpy(void *, const void *, size_t);
static void
ikev1_print(netdissect_options *ndo,
@@ -132,11 +649,20 @@ ikev1_print(netdissect_options *ndo,
const u_char *bp2, struct isakmp *base);
#define MAXINITIATORS 20
-int ninitiator = 0;
-struct {
+static int ninitiator = 0;
+union inaddr_u {
+ struct in_addr in4;
+ struct in6_addr in6;
+};
+#ifndef __rtems__
+static struct {
+#else /* __rtems__ */
+static struct cookiecache {
+#endif /* __rtems__ */
cookie_t initiator;
- struct sockaddr_storage iaddr;
- struct sockaddr_storage raddr;
+ u_int version;
+ union inaddr_u iaddr;
+ union inaddr_u raddr;
} cookiecache[MAXINITIATORS];
/* protocol id */
@@ -156,17 +682,17 @@ static const char *npstr[] = {
"v2cr", "v2auth","v2nonce", "v2n", "v2d", /* 38- 42 */
"v2vid", "v2TSi", "v2TSr", "v2e", "v2cp", /* 43- 47 */
"v2eap", /* 48 */
-
+
};
/* isakmp->np */
-static const u_char *(*npfunc[])(netdissect_options *ndo, u_char tpay,
+static const u_char *(*npfunc[])(netdissect_options *ndo, u_char tpay,
const struct isakmp_gen *ext,
u_int item_len,
const u_char *end_pointer,
- u_int32_t phase,
- u_int32_t doi0,
- u_int32_t proto0, int depth) = {
+ uint32_t phase,
+ uint32_t doi0,
+ uint32_t proto0, int depth) = {
NULL,
ikev1_sa_print,
ikev1_p_print,
@@ -222,18 +748,18 @@ static const char *etypestr[] = {
#define ETYPESTR(x) STR_OR_ID(x, etypestr)
#define CHECKLEN(p, np) \
- if (ep < (u_char *)(p)) { \
+ if (ep < (const u_char *)(p)) { \
ND_PRINT((ndo," [|%s]", NPSTR(np))); \
goto done; \
}
-
+
#define NPFUNC(x) \
(((x) < sizeof(npfunc)/sizeof(npfunc[0]) && npfunc[(x)]) \
? npfunc[(x)] : NULL)
static int
-iszero(u_char *p, size_t l)
+iszero(const u_char *p, size_t l)
{
while (l--) {
if (*p++)
@@ -261,12 +787,8 @@ static void
cookie_record(cookie_t *in, const u_char *bp2)
{
int i;
- struct ip *ip;
- struct sockaddr_in *sin;
-#ifdef INET6
- struct ip6_hdr *ip6;
- struct sockaddr_in6 *sin6;
-#endif
+ const struct ip *ip;
+ const struct ip6_hdr *ip6;
i = cookie_find(in);
if (0 <= i) {
@@ -274,53 +796,23 @@ cookie_record(cookie_t *in, const u_char *bp2)
return;
}
- ip = (struct ip *)bp2;
+ ip = (const struct ip *)bp2;
switch (IP_V(ip)) {
case 4:
- memset(&cookiecache[ninitiator].iaddr, 0,
- sizeof(cookiecache[ninitiator].iaddr));
- memset(&cookiecache[ninitiator].raddr, 0,
- sizeof(cookiecache[ninitiator].raddr));
-
- sin = (struct sockaddr_in *)&cookiecache[ninitiator].iaddr;
-#ifdef HAVE_SOCKADDR_SA_LEN
- sin->sin_len = sizeof(struct sockaddr_in);
-#endif
- sin->sin_family = AF_INET;
- memcpy(&sin->sin_addr, &ip->ip_src, sizeof(ip->ip_src));
- sin = (struct sockaddr_in *)&cookiecache[ninitiator].raddr;
-#ifdef HAVE_SOCKADDR_SA_LEN
- sin->sin_len = sizeof(struct sockaddr_in);
-#endif
- sin->sin_family = AF_INET;
- memcpy(&sin->sin_addr, &ip->ip_dst, sizeof(ip->ip_dst));
+ cookiecache[ninitiator].version = 4;
+ UNALIGNED_MEMCPY(&cookiecache[ninitiator].iaddr.in4, &ip->ip_src, sizeof(struct in_addr));
+ UNALIGNED_MEMCPY(&cookiecache[ninitiator].raddr.in4, &ip->ip_dst, sizeof(struct in_addr));
break;
-#ifdef INET6
case 6:
- memset(&cookiecache[ninitiator].iaddr, 0,
- sizeof(cookiecache[ninitiator].iaddr));
- memset(&cookiecache[ninitiator].raddr, 0,
- sizeof(cookiecache[ninitiator].raddr));
-
- ip6 = (struct ip6_hdr *)bp2;
- sin6 = (struct sockaddr_in6 *)&cookiecache[ninitiator].iaddr;
-#ifdef HAVE_SOCKADDR_SA_LEN
- sin6->sin6_len = sizeof(struct sockaddr_in6);
-#endif
- sin6->sin6_family = AF_INET6;
- memcpy(&sin6->sin6_addr, &ip6->ip6_src, sizeof(ip6->ip6_src));
- sin6 = (struct sockaddr_in6 *)&cookiecache[ninitiator].raddr;
-#ifdef HAVE_SOCKADDR_SA_LEN
- sin6->sin6_len = sizeof(struct sockaddr_in6);
-#endif
- sin6->sin6_family = AF_INET6;
- memcpy(&sin6->sin6_addr, &ip6->ip6_dst, sizeof(ip6->ip6_dst));
+ ip6 = (const struct ip6_hdr *)bp2;
+ cookiecache[ninitiator].version = 6;
+ UNALIGNED_MEMCPY(&cookiecache[ninitiator].iaddr.in6, &ip6->ip6_src, sizeof(struct in6_addr));
+ UNALIGNED_MEMCPY(&cookiecache[ninitiator].raddr.in6, &ip6->ip6_dst, sizeof(struct in6_addr));
break;
-#endif
default:
return;
}
- memcpy(&cookiecache[ninitiator].initiator, in, sizeof(*in));
+ UNALIGNED_MEMCPY(&cookiecache[ninitiator].initiator, in, sizeof(*in));
ninitiator = (ninitiator + 1) % MAXINITIATORS;
}
@@ -329,94 +821,54 @@ cookie_record(cookie_t *in, const u_char *bp2)
static int
cookie_sidecheck(int i, const u_char *bp2, int initiator)
{
- struct sockaddr_storage ss;
- struct sockaddr *sa;
- struct ip *ip;
- struct sockaddr_in *sin;
-#ifdef INET6
- struct ip6_hdr *ip6;
- struct sockaddr_in6 *sin6;
-#endif
- int salen;
+ const struct ip *ip;
+ const struct ip6_hdr *ip6;
- memset(&ss, 0, sizeof(ss));
- ip = (struct ip *)bp2;
+ ip = (const struct ip *)bp2;
switch (IP_V(ip)) {
case 4:
- sin = (struct sockaddr_in *)&ss;
-#ifdef HAVE_SOCKADDR_SA_LEN
- sin->sin_len = sizeof(struct sockaddr_in);
-#endif
- sin->sin_family = AF_INET;
- memcpy(&sin->sin_addr, &ip->ip_src, sizeof(ip->ip_src));
+ if (cookiecache[i].version != 4)
+ return 0;
+ if (initiator) {
+ if (UNALIGNED_MEMCMP(&ip->ip_src, &cookiecache[i].iaddr.in4, sizeof(struct in_addr)) == 0)
+ return 1;
+ } else {
+ if (UNALIGNED_MEMCMP(&ip->ip_src, &cookiecache[i].raddr.in4, sizeof(struct in_addr)) == 0)
+ return 1;
+ }
break;
-#ifdef INET6
case 6:
- ip6 = (struct ip6_hdr *)bp2;
- sin6 = (struct sockaddr_in6 *)&ss;
-#ifdef HAVE_SOCKADDR_SA_LEN
- sin6->sin6_len = sizeof(struct sockaddr_in6);
-#endif
- sin6->sin6_family = AF_INET6;
- memcpy(&sin6->sin6_addr, &ip6->ip6_src, sizeof(ip6->ip6_src));
+ if (cookiecache[i].version != 6)
+ return 0;
+ ip6 = (const struct ip6_hdr *)bp2;
+ if (initiator) {
+ if (UNALIGNED_MEMCMP(&ip6->ip6_src, &cookiecache[i].iaddr.in6, sizeof(struct in6_addr)) == 0)
+ return 1;
+ } else {
+ if (UNALIGNED_MEMCMP(&ip6->ip6_src, &cookiecache[i].raddr.in6, sizeof(struct in6_addr)) == 0)
+ return 1;
+ }
break;
-#endif
default:
- return 0;
+ break;
}
- sa = (struct sockaddr *)&ss;
- if (initiator) {
- if (sa->sa_family != ((struct sockaddr *)&cookiecache[i].iaddr)->sa_family)
- return 0;
-#ifdef HAVE_SOCKADDR_SA_LEN
- salen = sa->sa_len;
-#else
-#ifdef INET6
- if (sa->sa_family == AF_INET6)
- salen = sizeof(struct sockaddr_in6);
- else
- salen = sizeof(struct sockaddr);
-#else
- salen = sizeof(struct sockaddr);
-#endif
-#endif
- if (memcmp(&ss, &cookiecache[i].iaddr, salen) == 0)
- return 1;
- } else {
- if (sa->sa_family != ((struct sockaddr *)&cookiecache[i].raddr)->sa_family)
- return 0;
-#ifdef HAVE_SOCKADDR_SA_LEN
- salen = sa->sa_len;
-#else
-#ifdef INET6
- if (sa->sa_family == AF_INET6)
- salen = sizeof(struct sockaddr_in6);
- else
- salen = sizeof(struct sockaddr);
-#else
- salen = sizeof(struct sockaddr);
-#endif
-#endif
- if (memcmp(&ss, &cookiecache[i].raddr, salen) == 0)
- return 1;
- }
return 0;
}
static void
-hexprint(netdissect_options *ndo, caddr_t loc, size_t len)
+hexprint(netdissect_options *ndo, const uint8_t *loc, size_t len)
{
- u_char *p;
+ const uint8_t *p;
size_t i;
- p = (u_char *)loc;
+ p = loc;
for (i = 0; i < len; i++)
ND_PRINT((ndo,"%02x", p[i] & 0xff));
}
static int
-rawprint(netdissect_options *ndo, caddr_t loc, size_t len)
+rawprint(netdissect_options *ndo, const uint8_t *loc, size_t len)
{
ND_TCHECK2(*loc, len);
@@ -430,7 +882,7 @@ trunc:
/*
* returns false if we run out of data buffer
*/
-static int ike_show_somedata(struct netdissect_options *ndo,
+static int ike_show_somedata(netdissect_options *ndo,
const u_char *cp, const u_char *ep)
{
/* there is too much data, just show some of it */
@@ -440,18 +892,18 @@ static int ike_show_somedata(struct netdissect_options *ndo,
if(len > 10) {
len = 10;
}
-
+
/* really shouldn't happen because of above */
if(end < cp + len) {
end = cp+len;
elen = ep - end;
}
-
+
ND_PRINT((ndo," data=("));
- if(!rawprint(ndo, (caddr_t)(cp), len)) goto trunc;
+ if(!rawprint(ndo, (const uint8_t *)(cp), len)) goto trunc;
ND_PRINT((ndo, "..."));
if(elen) {
- if(!rawprint(ndo, (caddr_t)(end), elen)) goto trunc;
+ if(!rawprint(ndo, (const uint8_t *)(end), elen)) goto trunc;
}
ND_PRINT((ndo,")"));
return 1;
@@ -471,36 +923,34 @@ ikev1_attrmap_print(netdissect_options *ndo,
const u_char *p, const u_char *ep,
const struct attrmap *map, size_t nmap)
{
- u_int16_t *q;
int totlen;
- u_int32_t t, v;
+ uint32_t t, v;
- q = (u_int16_t *)p;
if (p[0] & 0x80)
totlen = 4;
else
- totlen = 4 + EXTRACT_16BITS(&q[1]);
+ totlen = 4 + EXTRACT_16BITS(&p[2]);
if (ep < p + totlen) {
ND_PRINT((ndo,"[|attr]"));
return ep + 1;
}
ND_PRINT((ndo,"("));
- t = EXTRACT_16BITS(&q[0]) & 0x7fff;
+ t = EXTRACT_16BITS(&p[0]) & 0x7fff;
if (map && t < nmap && map[t].type)
ND_PRINT((ndo,"type=%s ", map[t].type));
else
ND_PRINT((ndo,"type=#%d ", t));
if (p[0] & 0x80) {
ND_PRINT((ndo,"value="));
- v = EXTRACT_16BITS(&q[1]);
+ v = EXTRACT_16BITS(&p[2]);
if (map && t < nmap && v < map[t].nvalue && map[t].value[v])
ND_PRINT((ndo,"%s", map[t].value[v]));
else
- rawprint(ndo, (caddr_t)&q[1], 2);
+ rawprint(ndo, (const uint8_t *)&p[2], 2);
} else {
- ND_PRINT((ndo,"len=%d value=", EXTRACT_16BITS(&q[1])));
- rawprint(ndo, (caddr_t)&p[4], EXTRACT_16BITS(&q[1]));
+ ND_PRINT((ndo,"len=%d value=", EXTRACT_16BITS(&p[2])));
+ rawprint(ndo, (const uint8_t *)&p[4], EXTRACT_16BITS(&p[2]));
}
ND_PRINT((ndo,")"));
return p + totlen;
@@ -509,30 +959,28 @@ ikev1_attrmap_print(netdissect_options *ndo,
static const u_char *
ikev1_attr_print(netdissect_options *ndo, const u_char *p, const u_char *ep)
{
- u_int16_t *q;
int totlen;
- u_int32_t t;
+ uint32_t t;
- q = (u_int16_t *)p;
if (p[0] & 0x80)
totlen = 4;
else
- totlen = 4 + EXTRACT_16BITS(&q[1]);
+ totlen = 4 + EXTRACT_16BITS(&p[2]);
if (ep < p + totlen) {
ND_PRINT((ndo,"[|attr]"));
return ep + 1;
}
ND_PRINT((ndo,"("));
- t = EXTRACT_16BITS(&q[0]) & 0x7fff;
+ t = EXTRACT_16BITS(&p[0]) & 0x7fff;
ND_PRINT((ndo,"type=#%d ", t));
if (p[0] & 0x80) {
ND_PRINT((ndo,"value="));
- t = q[1];
- rawprint(ndo, (caddr_t)&q[1], 2);
+ t = p[2];
+ rawprint(ndo, (const uint8_t *)&p[2], 2);
} else {
- ND_PRINT((ndo,"len=%d value=", EXTRACT_16BITS(&q[1])));
- rawprint(ndo, (caddr_t)&p[2], EXTRACT_16BITS(&q[1]));
+ ND_PRINT((ndo,"len=%d value=", EXTRACT_16BITS(&p[2])));
+ rawprint(ndo, (const uint8_t *)&p[4], EXTRACT_16BITS(&p[2]));
}
ND_PRINT((ndo,")"));
return p + totlen;
@@ -542,31 +990,29 @@ static const u_char *
ikev1_sa_print(netdissect_options *ndo, u_char tpay _U_,
const struct isakmp_gen *ext,
u_int item_len _U_,
- const u_char *ep, u_int32_t phase, u_int32_t doi0 _U_,
- u_int32_t proto0, int depth)
+ const u_char *ep, uint32_t phase, uint32_t doi0 _U_,
+ uint32_t proto0, int depth)
{
const struct ikev1_pl_sa *p;
struct ikev1_pl_sa sa;
- const u_int32_t *q;
- u_int32_t doi, sit, ident;
+ uint32_t doi, sit, ident;
const u_char *cp, *np;
int t;
ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_SA)));
- p = (struct ikev1_pl_sa *)ext;
+ p = (const struct ikev1_pl_sa *)ext;
ND_TCHECK(*p);
- safememcpy(&sa, ext, sizeof(sa));
+ UNALIGNED_MEMCPY(&sa, ext, sizeof(sa));
doi = ntohl(sa.doi);
sit = ntohl(sa.sit);
if (doi != 1) {
ND_PRINT((ndo," doi=%d", doi));
- ND_PRINT((ndo," situation=%u", (u_int32_t)ntohl(sa.sit)));
- return (u_char *)(p + 1);
+ ND_PRINT((ndo," situation=%u", (uint32_t)ntohl(sa.sit)));
+ return (const u_char *)(p + 1);
}
ND_PRINT((ndo," doi=ipsec"));
- q = (u_int32_t *)&sa.sit;
ND_PRINT((ndo," situation="));
t = 0;
if (sit & 0x01) {
@@ -580,15 +1026,15 @@ ikev1_sa_print(netdissect_options *ndo, u_char tpay _U_,
if (sit & 0x04)
ND_PRINT((ndo,"%sintegrity", t ? "+" : ""));
- np = (u_char *)ext + sizeof(sa);
+ np = (const u_char *)ext + sizeof(sa);
if (sit != 0x01) {
ND_TCHECK2(*(ext + 1), sizeof(ident));
- safememcpy(&ident, ext + 1, sizeof(ident));
- ND_PRINT((ndo," ident=%u", (u_int32_t)ntohl(ident)));
+ UNALIGNED_MEMCPY(&ident, ext + 1, sizeof(ident));
+ ND_PRINT((ndo," ident=%u", (uint32_t)ntohl(ident)));
np += sizeof(ident);
}
- ext = (struct isakmp_gen *)np;
+ ext = (const struct isakmp_gen *)np;
ND_TCHECK(*ext);
cp = ikev1_sub_print(ndo, ISAKMP_NPTYPE_P, ext, ep, phase, doi, proto0,
@@ -603,8 +1049,8 @@ trunc:
static const u_char *
ikev1_p_print(netdissect_options *ndo, u_char tpay _U_,
const struct isakmp_gen *ext, u_int item_len _U_,
- const u_char *ep, u_int32_t phase, u_int32_t doi0,
- u_int32_t proto0 _U_, int depth)
+ const u_char *ep, uint32_t phase, uint32_t doi0,
+ uint32_t proto0 _U_, int depth)
{
const struct ikev1_pl_p *p;
struct ikev1_pl_p prop;
@@ -612,23 +1058,23 @@ ikev1_p_print(netdissect_options *ndo, u_char tpay _U_,
ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_P)));
- p = (struct ikev1_pl_p *)ext;
+ p = (const struct ikev1_pl_p *)ext;
ND_TCHECK(*p);
- safememcpy(&prop, ext, sizeof(prop));
+ UNALIGNED_MEMCPY(&prop, ext, sizeof(prop));
ND_PRINT((ndo," #%d protoid=%s transform=%d",
prop.p_no, PROTOIDSTR(prop.prot_id), prop.num_t));
if (prop.spi_size) {
ND_PRINT((ndo," spi="));
- if (!rawprint(ndo, (caddr_t)(p + 1), prop.spi_size))
+ if (!rawprint(ndo, (const uint8_t *)(p + 1), prop.spi_size))
goto trunc;
}
- ext = (struct isakmp_gen *)((u_char *)(p + 1) + prop.spi_size);
+ ext = (const struct isakmp_gen *)((const u_char *)(p + 1) + prop.spi_size);
ND_TCHECK(*ext);
-
+
cp = ikev1_sub_print(ndo, ISAKMP_NPTYPE_T, ext, ep, phase, doi0,
prop.prot_id, depth);
-
+
return cp;
trunc:
ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_P)));
@@ -688,7 +1134,7 @@ static const char *ipcomp_p_map[] = {
NULL, "oui", "deflate", "lzs",
};
-const struct attrmap ipsec_t_map[] = {
+static const struct attrmap ipsec_t_map[] = {
{ NULL, 0, { NULL } },
{ "lifetype", 3, { NULL, "sec", "kb", }, },
{ "life", 0, { NULL } },
@@ -715,7 +1161,7 @@ const struct attrmap ipsec_t_map[] = {
{ "privalg", 0, { NULL } },
};
-const struct attrmap encr_t_map[] = {
+static const struct attrmap encr_t_map[] = {
{ NULL, 0, { NULL } }, { NULL, 0, { NULL } }, /* 0, 1 */
{ NULL, 0, { NULL } }, { NULL, 0, { NULL } }, /* 2, 3 */
{ NULL, 0, { NULL } }, { NULL, 0, { NULL } }, /* 4, 5 */
@@ -726,7 +1172,7 @@ const struct attrmap encr_t_map[] = {
{ "keylen", 14, { NULL }},
};
-const struct attrmap oakley_t_map[] = {
+static const struct attrmap oakley_t_map[] = {
{ NULL, 0, { NULL } },
{ "enc", 8, { NULL, "1des", "idea", "blowfish", "rc5",
"3des", "cast", "aes", }, },
@@ -766,8 +1212,8 @@ const struct attrmap oakley_t_map[] = {
static const u_char *
ikev1_t_print(netdissect_options *ndo, u_char tpay _U_,
const struct isakmp_gen *ext, u_int item_len,
- const u_char *ep, u_int32_t phase _U_, u_int32_t doi _U_,
- u_int32_t proto, int depth _U_)
+ const u_char *ep, uint32_t phase _U_, uint32_t doi _U_,
+ uint32_t proto, int depth _U_)
{
const struct ikev1_pl_t *p;
struct ikev1_pl_t t;
@@ -779,9 +1225,9 @@ ikev1_t_print(netdissect_options *ndo, u_char tpay _U_,
ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_T)));
- p = (struct ikev1_pl_t *)ext;
+ p = (const struct ikev1_pl_t *)ext;
ND_TCHECK(*p);
- safememcpy(&t, ext, sizeof(t));
+ UNALIGNED_MEMCPY(&t, ext, sizeof(t));
switch (proto) {
case 1:
@@ -815,8 +1261,8 @@ ikev1_t_print(netdissect_options *ndo, u_char tpay _U_,
ND_PRINT((ndo," #%d id=%s ", t.t_no, idstr));
else
ND_PRINT((ndo," #%d id=%d ", t.t_no, t.t_id));
- cp = (u_char *)(p + 1);
- ep2 = (u_char *)p + item_len;
+ cp = (const u_char *)(p + 1);
+ ep2 = (const u_char *)p + item_len;
while (cp < ep && cp < ep2) {
if (map && nmap) {
cp = ikev1_attrmap_print(ndo, cp, (ep < ep2) ? ep : ep2,
@@ -835,22 +1281,22 @@ trunc:
static const u_char *
ikev1_ke_print(netdissect_options *ndo, u_char tpay _U_,
const struct isakmp_gen *ext, u_int item_len _U_,
- const u_char *ep _U_, u_int32_t phase _U_, u_int32_t doi _U_,
- u_int32_t proto _U_, int depth _U_)
+ const u_char *ep _U_, uint32_t phase _U_, uint32_t doi _U_,
+ uint32_t proto _U_, int depth _U_)
{
struct isakmp_gen e;
ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_KE)));
ND_TCHECK(*ext);
- safememcpy(&e, ext, sizeof(e));
+ UNALIGNED_MEMCPY(&e, ext, sizeof(e));
ND_PRINT((ndo," key len=%d", ntohs(e.len) - 4));
if (2 < ndo->ndo_vflag && 4 < ntohs(e.len)) {
ND_PRINT((ndo," "));
- if (!rawprint(ndo, (caddr_t)(ext + 1), ntohs(e.len) - 4))
+ if (!rawprint(ndo, (const uint8_t *)(ext + 1), ntohs(e.len) - 4))
goto trunc;
}
- return (u_char *)ext + ntohs(e.len);
+ return (const u_char *)ext + ntohs(e.len);
trunc:
ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_KE)));
return NULL;
@@ -858,9 +1304,9 @@ trunc:
static const u_char *
ikev1_id_print(netdissect_options *ndo, u_char tpay _U_,
- const struct isakmp_gen *ext, u_int item_len _U_,
- const u_char *ep _U_, u_int32_t phase, u_int32_t doi _U_,
- u_int32_t proto _U_, int depth _U_)
+ const struct isakmp_gen *ext, u_int item_len,
+ const u_char *ep _U_, uint32_t phase, uint32_t doi _U_,
+ uint32_t proto _U_, int depth _U_)
{
#define USE_IPSECDOI_IN_PHASE1 1
const struct ikev1_pl_id *p;
@@ -878,11 +1324,11 @@ ikev1_id_print(netdissect_options *ndo, u_char tpay _U_,
ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_ID)));
- p = (struct ikev1_pl_id *)ext;
+ p = (const struct ikev1_pl_id *)ext;
ND_TCHECK(*p);
- safememcpy(&id, ext, sizeof(id));
+ UNALIGNED_MEMCPY(&id, ext, sizeof(id));
if (sizeof(*p) < item_len) {
- data = (u_char *)(p + 1);
+ data = (const u_char *)(p + 1);
len = item_len - sizeof(*p);
} else {
data = NULL;
@@ -899,7 +1345,7 @@ ikev1_id_print(netdissect_options *ndo, u_char tpay _U_,
default:
ND_PRINT((ndo," idtype=%s", STR_OR_ID(id.d.id_type, idtypestr)));
ND_PRINT((ndo," doi_data=%u",
- (u_int32_t)(ntohl(id.d.doi_data) & 0xffffff)));
+ (uint32_t)(ntohl(id.d.doi_data) & 0xffffff)));
break;
#ifdef USE_IPSECDOI_IN_PHASE1
@@ -907,40 +1353,32 @@ ikev1_id_print(netdissect_options *ndo, u_char tpay _U_,
#endif
case 2:
{
- const struct ipsecdoi_id *p;
- struct ipsecdoi_id id;
+ const struct ipsecdoi_id *doi_p;
+ struct ipsecdoi_id doi_id;
struct protoent *pe;
- p = (struct ipsecdoi_id *)ext;
- ND_TCHECK(*p);
- safememcpy(&id, ext, sizeof(id));
- ND_PRINT((ndo," idtype=%s", STR_OR_ID(id.type, ipsecidtypestr)));
- if (id.proto_id) {
-#ifndef WIN32
- setprotoent(1);
-#endif /* WIN32 */
- pe = getprotobynumber(id.proto_id);
- if (pe)
- ND_PRINT((ndo," protoid=%s", pe->p_name));
-#ifndef WIN32
- endprotoent();
-#endif /* WIN32 */
- } else {
- /* it DOES NOT mean IPPROTO_IP! */
- ND_PRINT((ndo," protoid=%s", "0"));
- }
- ND_PRINT((ndo," port=%d", ntohs(id.port)));
+ doi_p = (const struct ipsecdoi_id *)ext;
+ ND_TCHECK(*doi_p);
+ UNALIGNED_MEMCPY(&doi_id, ext, sizeof(doi_id));
+ ND_PRINT((ndo," idtype=%s", STR_OR_ID(doi_id.type, ipsecidtypestr)));
+ /* A protocol ID of 0 DOES NOT mean IPPROTO_IP! */
+ pe = doi_id.proto_id ? getprotobynumber(doi_id.proto_id) : NULL;
+ if (pe)
+ ND_PRINT((ndo," protoid=%s", pe->p_name));
+ else
+ ND_PRINT((ndo," protoid=%u", doi_id.proto_id));
+ ND_PRINT((ndo," port=%d", ntohs(doi_id.port)));
if (!len)
break;
if (data == NULL)
goto trunc;
ND_TCHECK2(*data, len);
- switch (id.type) {
+ switch (doi_id.type) {
case IPSECDOI_ID_IPV4_ADDR:
if (len < 4)
ND_PRINT((ndo," len=%d [bad: < 4]", len));
else
- ND_PRINT((ndo," len=%d %s", len, ipaddr_string(data)));
+ ND_PRINT((ndo," len=%d %s", len, ipaddr_string(ndo, data)));
len = 0;
break;
case IPSECDOI_ID_FQDN:
@@ -949,7 +1387,7 @@ ikev1_id_print(netdissect_options *ndo, u_char tpay _U_,
int i;
ND_PRINT((ndo," len=%d ", len));
for (i = 0; i < len; i++)
- safeputchar(data[i]);
+ safeputchar(ndo, data[i]);
len = 0;
break;
}
@@ -961,58 +1399,57 @@ ikev1_id_print(netdissect_options *ndo, u_char tpay _U_,
else {
mask = data + sizeof(struct in_addr);
ND_PRINT((ndo," len=%d %s/%u.%u.%u.%u", len,
- ipaddr_string(data),
+ ipaddr_string(ndo, data),
mask[0], mask[1], mask[2], mask[3]));
}
len = 0;
break;
}
-#ifdef INET6
case IPSECDOI_ID_IPV6_ADDR:
if (len < 16)
ND_PRINT((ndo," len=%d [bad: < 16]", len));
else
- ND_PRINT((ndo," len=%d %s", len, ip6addr_string(data)));
+ ND_PRINT((ndo," len=%d %s", len, ip6addr_string(ndo, data)));
len = 0;
break;
case IPSECDOI_ID_IPV6_ADDR_SUBNET:
{
- const u_int32_t *mask;
+ const u_char *mask;
if (len < 20)
ND_PRINT((ndo," len=%d [bad: < 20]", len));
else {
- mask = (u_int32_t *)(data + sizeof(struct in6_addr));
+ mask = (const u_char *)(data + sizeof(struct in6_addr));
/*XXX*/
- ND_PRINT((ndo," len=%d %s/0x%08x%08x%08x%08x", len,
- ip6addr_string(data),
- mask[0], mask[1], mask[2], mask[3]));
+ ND_PRINT((ndo," len=%d %s/0x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", len,
+ ip6addr_string(ndo, data),
+ mask[0], mask[1], mask[2], mask[3],
+ mask[4], mask[5], mask[6], mask[7],
+ mask[8], mask[9], mask[10], mask[11],
+ mask[12], mask[13], mask[14], mask[15]));
}
len = 0;
break;
}
-#endif /*INET6*/
case IPSECDOI_ID_IPV4_ADDR_RANGE:
if (len < 8)
ND_PRINT((ndo," len=%d [bad: < 8]", len));
else {
ND_PRINT((ndo," len=%d %s-%s", len,
- ipaddr_string(data),
- ipaddr_string(data + sizeof(struct in_addr))));
+ ipaddr_string(ndo, data),
+ ipaddr_string(ndo, data + sizeof(struct in_addr))));
}
len = 0;
break;
-#ifdef INET6
case IPSECDOI_ID_IPV6_ADDR_RANGE:
if (len < 32)
ND_PRINT((ndo," len=%d [bad: < 32]", len));
else {
ND_PRINT((ndo," len=%d %s-%s", len,
- ip6addr_string(data),
- ip6addr_string(data + sizeof(struct in6_addr))));
+ ip6addr_string(ndo, data),
+ ip6addr_string(ndo, data + sizeof(struct in6_addr))));
}
len = 0;
break;
-#endif /*INET6*/
case IPSECDOI_ID_DER_ASN1_DN:
case IPSECDOI_ID_DER_ASN1_GN:
case IPSECDOI_ID_KEY_ID:
@@ -1025,11 +1462,11 @@ ikev1_id_print(netdissect_options *ndo, u_char tpay _U_,
ND_PRINT((ndo," len=%d", len));
if (2 < ndo->ndo_vflag) {
ND_PRINT((ndo," "));
- if (!rawprint(ndo, (caddr_t)data, len))
+ if (!rawprint(ndo, (const uint8_t *)data, len))
goto trunc;
}
}
- return (u_char *)ext + item_len;
+ return (const u_char *)ext + item_len;
trunc:
ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_ID)));
return NULL;
@@ -1037,10 +1474,10 @@ trunc:
static const u_char *
ikev1_cert_print(netdissect_options *ndo, u_char tpay _U_,
- const struct isakmp_gen *ext, u_int item_len _U_,
- const u_char *ep _U_, u_int32_t phase _U_,
- u_int32_t doi0 _U_,
- u_int32_t proto0 _U_, int depth _U_)
+ const struct isakmp_gen *ext, u_int item_len,
+ const u_char *ep _U_, uint32_t phase _U_,
+ uint32_t doi0 _U_,
+ uint32_t proto0 _U_, int depth _U_)
{
const struct ikev1_pl_cert *p;
struct ikev1_pl_cert cert;
@@ -1052,17 +1489,17 @@ ikev1_cert_print(netdissect_options *ndo, u_char tpay _U_,
ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_CERT)));
- p = (struct ikev1_pl_cert *)ext;
+ p = (const struct ikev1_pl_cert *)ext;
ND_TCHECK(*p);
- safememcpy(&cert, ext, sizeof(cert));
+ UNALIGNED_MEMCPY(&cert, ext, sizeof(cert));
ND_PRINT((ndo," len=%d", item_len - 4));
ND_PRINT((ndo," type=%s", STR_OR_ID((cert.encode), certstr)));
if (2 < ndo->ndo_vflag && 4 < item_len) {
ND_PRINT((ndo," "));
- if (!rawprint(ndo, (caddr_t)(ext + 1), item_len - 4))
+ if (!rawprint(ndo, (const uint8_t *)(ext + 1), item_len - 4))
goto trunc;
}
- return (u_char *)ext + item_len;
+ return (const u_char *)ext + item_len;
trunc:
ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_CERT)));
return NULL;
@@ -1070,9 +1507,9 @@ trunc:
static const u_char *
ikev1_cr_print(netdissect_options *ndo, u_char tpay _U_,
- const struct isakmp_gen *ext, u_int item_len _U_,
- const u_char *ep _U_, u_int32_t phase _U_, u_int32_t doi0 _U_,
- u_int32_t proto0 _U_, int depth _U_)
+ const struct isakmp_gen *ext, u_int item_len,
+ const u_char *ep _U_, uint32_t phase _U_, uint32_t doi0 _U_,
+ uint32_t proto0 _U_, int depth _U_)
{
const struct ikev1_pl_cert *p;
struct ikev1_pl_cert cert;
@@ -1084,17 +1521,17 @@ ikev1_cr_print(netdissect_options *ndo, u_char tpay _U_,
ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_CR)));
- p = (struct ikev1_pl_cert *)ext;
+ p = (const struct ikev1_pl_cert *)ext;
ND_TCHECK(*p);
- safememcpy(&cert, ext, sizeof(cert));
+ UNALIGNED_MEMCPY(&cert, ext, sizeof(cert));
ND_PRINT((ndo," len=%d", item_len - 4));
ND_PRINT((ndo," type=%s", STR_OR_ID((cert.encode), certstr)));
if (2 < ndo->ndo_vflag && 4 < item_len) {
ND_PRINT((ndo," "));
- if (!rawprint(ndo, (caddr_t)(ext + 1), item_len - 4))
+ if (!rawprint(ndo, (const uint8_t *)(ext + 1), item_len - 4))
goto trunc;
}
- return (u_char *)ext + item_len;
+ return (const u_char *)ext + item_len;
trunc:
ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_CR)));
return NULL;
@@ -1103,22 +1540,22 @@ trunc:
static const u_char *
ikev1_hash_print(netdissect_options *ndo, u_char tpay _U_,
const struct isakmp_gen *ext, u_int item_len _U_,
- const u_char *ep _U_, u_int32_t phase _U_, u_int32_t doi _U_,
- u_int32_t proto _U_, int depth _U_)
+ const u_char *ep _U_, uint32_t phase _U_, uint32_t doi _U_,
+ uint32_t proto _U_, int depth _U_)
{
struct isakmp_gen e;
ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_HASH)));
ND_TCHECK(*ext);
- safememcpy(&e, ext, sizeof(e));
+ UNALIGNED_MEMCPY(&e, ext, sizeof(e));
ND_PRINT((ndo," len=%d", ntohs(e.len) - 4));
if (2 < ndo->ndo_vflag && 4 < ntohs(e.len)) {
ND_PRINT((ndo," "));
- if (!rawprint(ndo, (caddr_t)(ext + 1), ntohs(e.len) - 4))
+ if (!rawprint(ndo, (const uint8_t *)(ext + 1), ntohs(e.len) - 4))
goto trunc;
}
- return (u_char *)ext + ntohs(e.len);
+ return (const u_char *)ext + ntohs(e.len);
trunc:
ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_HASH)));
return NULL;
@@ -1127,22 +1564,22 @@ trunc:
static const u_char *
ikev1_sig_print(netdissect_options *ndo, u_char tpay _U_,
const struct isakmp_gen *ext, u_int item_len _U_,
- const u_char *ep _U_, u_int32_t phase _U_, u_int32_t doi _U_,
- u_int32_t proto _U_, int depth _U_)
+ const u_char *ep _U_, uint32_t phase _U_, uint32_t doi _U_,
+ uint32_t proto _U_, int depth _U_)
{
struct isakmp_gen e;
ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_SIG)));
ND_TCHECK(*ext);
- safememcpy(&e, ext, sizeof(e));
+ UNALIGNED_MEMCPY(&e, ext, sizeof(e));
ND_PRINT((ndo," len=%d", ntohs(e.len) - 4));
if (2 < ndo->ndo_vflag && 4 < ntohs(e.len)) {
ND_PRINT((ndo," "));
- if (!rawprint(ndo, (caddr_t)(ext + 1), ntohs(e.len) - 4))
+ if (!rawprint(ndo, (const uint8_t *)(ext + 1), ntohs(e.len) - 4))
goto trunc;
}
- return (u_char *)ext + ntohs(e.len);
+ return (const u_char *)ext + ntohs(e.len);
trunc:
ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_SIG)));
return NULL;
@@ -1152,27 +1589,27 @@ static const u_char *
ikev1_nonce_print(netdissect_options *ndo, u_char tpay _U_,
const struct isakmp_gen *ext,
u_int item_len _U_,
- const u_char *ep _U_,
- u_int32_t phase _U_, u_int32_t doi _U_,
- u_int32_t proto _U_, int depth _U_)
+ const u_char *ep,
+ uint32_t phase _U_, uint32_t doi _U_,
+ uint32_t proto _U_, int depth _U_)
{
struct isakmp_gen e;
ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_NONCE)));
ND_TCHECK(*ext);
- safememcpy(&e, ext, sizeof(e));
+ UNALIGNED_MEMCPY(&e, ext, sizeof(e));
ND_PRINT((ndo," n len=%d", ntohs(e.len) - 4));
if (2 < ndo->ndo_vflag && 4 < ntohs(e.len)) {
ND_PRINT((ndo," "));
- if (!rawprint(ndo, (caddr_t)(ext + 1), ntohs(e.len) - 4))
+ if (!rawprint(ndo, (const uint8_t *)(ext + 1), ntohs(e.len) - 4))
goto trunc;
} else if (1 < ndo->ndo_vflag && 4 < ntohs(e.len)) {
ND_PRINT((ndo," "));
- if (!ike_show_somedata(ndo, (u_char *)(caddr_t)(ext + 1), ep))
+ if (!ike_show_somedata(ndo, (const u_char *)(const uint8_t *)(ext + 1), ep))
goto trunc;
}
- return (u_char *)ext + ntohs(e.len);
+ return (const u_char *)ext + ntohs(e.len);
trunc:
ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_NONCE)));
return NULL;
@@ -1181,14 +1618,15 @@ trunc:
static const u_char *
ikev1_n_print(netdissect_options *ndo, u_char tpay _U_,
const struct isakmp_gen *ext, u_int item_len,
- const u_char *ep, u_int32_t phase, u_int32_t doi0 _U_,
- u_int32_t proto0 _U_, int depth)
+ const u_char *ep, uint32_t phase, uint32_t doi0 _U_,
+ uint32_t proto0 _U_, int depth)
{
- struct ikev1_pl_n *p, n;
+ const struct ikev1_pl_n *p;
+ struct ikev1_pl_n n;
const u_char *cp;
- u_char *ep2;
- u_int32_t doi;
- u_int32_t proto;
+ const u_char *ep2;
+ uint32_t doi;
+ uint32_t proto;
static const char *notify_error_str[] = {
NULL, "INVALID-PAYLOAD-TYPE",
"DOI-NOT-SUPPORTED", "SITUATION-NOT-SUPPORTED",
@@ -1237,9 +1675,9 @@ ikev1_n_print(netdissect_options *ndo, u_char tpay _U_,
ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_N)));
- p = (struct ikev1_pl_n *)ext;
+ p = (const struct ikev1_pl_n *)ext;
ND_TCHECK(*p);
- safememcpy(&n, ext, sizeof(n));
+ UNALIGNED_MEMCPY(&n, ext, sizeof(n));
doi = ntohl(n.doi);
proto = n.prot_id;
if (doi != 1) {
@@ -1255,10 +1693,10 @@ ikev1_n_print(netdissect_options *ndo, u_char tpay _U_,
ND_PRINT((ndo," type=%s", numstr(ntohs(n.type))));
if (n.spi_size) {
ND_PRINT((ndo," spi="));
- if (!rawprint(ndo, (caddr_t)(p + 1), n.spi_size))
+ if (!rawprint(ndo, (const uint8_t *)(p + 1), n.spi_size))
goto trunc;
}
- return (u_char *)(p + 1) + n.spi_size;
+ return (const u_char *)(p + 1) + n.spi_size;
}
ND_PRINT((ndo," doi=ipsec"));
@@ -1275,12 +1713,12 @@ ikev1_n_print(netdissect_options *ndo, u_char tpay _U_,
ND_PRINT((ndo," type=%s", numstr(ntohs(n.type))));
if (n.spi_size) {
ND_PRINT((ndo," spi="));
- if (!rawprint(ndo, (caddr_t)(p + 1), n.spi_size))
+ if (!rawprint(ndo, (const uint8_t *)(p + 1), n.spi_size))
goto trunc;
}
- cp = (u_char *)(p + 1) + n.spi_size;
- ep2 = (u_char *)p + item_len;
+ cp = (const u_char *)(p + 1) + n.spi_size;
+ ep2 = (const u_char *)p + item_len;
if (cp < ep) {
ND_PRINT((ndo," orig=("));
@@ -1297,11 +1735,11 @@ ikev1_n_print(netdissect_options *ndo, u_char tpay _U_,
}
case IPSECDOI_NTYPE_REPLAY_STATUS:
ND_PRINT((ndo,"replay detection %sabled",
- (*(u_int32_t *)cp) ? "en" : "dis"));
+ EXTRACT_32BITS(cp) ? "en" : "dis"));
break;
case ISAKMP_NTYPE_NO_PROPOSAL_CHOSEN:
if (ikev1_sub_print(ndo, ISAKMP_NPTYPE_SA,
- (struct isakmp_gen *)cp, ep, phase, doi, proto,
+ (const struct isakmp_gen *)cp, ep, phase, doi, proto,
depth) == NULL)
return NULL;
break;
@@ -1313,7 +1751,7 @@ ikev1_n_print(netdissect_options *ndo, u_char tpay _U_,
}
ND_PRINT((ndo,")"));
}
- return (u_char *)ext + item_len;
+ return (const u_char *)ext + item_len;
trunc:
ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_N)));
return NULL;
@@ -1322,21 +1760,21 @@ trunc:
static const u_char *
ikev1_d_print(netdissect_options *ndo, u_char tpay _U_,
const struct isakmp_gen *ext, u_int item_len _U_,
- const u_char *ep _U_, u_int32_t phase _U_, u_int32_t doi0 _U_,
- u_int32_t proto0 _U_, int depth _U_)
+ const u_char *ep _U_, uint32_t phase _U_, uint32_t doi0 _U_,
+ uint32_t proto0 _U_, int depth _U_)
{
const struct ikev1_pl_d *p;
struct ikev1_pl_d d;
- const u_int8_t *q;
- u_int32_t doi;
- u_int32_t proto;
+ const uint8_t *q;
+ uint32_t doi;
+ uint32_t proto;
int i;
ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_D)));
- p = (struct ikev1_pl_d *)ext;
+ p = (const struct ikev1_pl_d *)ext;
ND_TCHECK(*p);
- safememcpy(&d, ext, sizeof(d));
+ UNALIGNED_MEMCPY(&d, ext, sizeof(d));
doi = ntohl(d.doi);
proto = d.prot_id;
if (doi != 1) {
@@ -1349,11 +1787,11 @@ ikev1_d_print(netdissect_options *ndo, u_char tpay _U_,
ND_PRINT((ndo," spilen=%u", d.spi_size));
ND_PRINT((ndo," nspi=%u", ntohs(d.num_spi)));
ND_PRINT((ndo," spi="));
- q = (u_int8_t *)(p + 1);
+ q = (const uint8_t *)(p + 1);
for (i = 0; i < ntohs(d.num_spi); i++) {
if (i != 0)
ND_PRINT((ndo,","));
- if (!rawprint(ndo, (caddr_t)q, d.spi_size))
+ if (!rawprint(ndo, (const uint8_t *)q, d.spi_size))
goto trunc;
q += d.spi_size;
}
@@ -1367,22 +1805,22 @@ static const u_char *
ikev1_vid_print(netdissect_options *ndo, u_char tpay _U_,
const struct isakmp_gen *ext,
u_int item_len _U_, const u_char *ep _U_,
- u_int32_t phase _U_, u_int32_t doi _U_,
- u_int32_t proto _U_, int depth _U_)
+ uint32_t phase _U_, uint32_t doi _U_,
+ uint32_t proto _U_, int depth _U_)
{
struct isakmp_gen e;
ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_VID)));
ND_TCHECK(*ext);
- safememcpy(&e, ext, sizeof(e));
+ UNALIGNED_MEMCPY(&e, ext, sizeof(e));
ND_PRINT((ndo," len=%d", ntohs(e.len) - 4));
if (2 < ndo->ndo_vflag && 4 < ntohs(e.len)) {
ND_PRINT((ndo," "));
- if (!rawprint(ndo, (caddr_t)(ext + 1), ntohs(e.len) - 4))
+ if (!rawprint(ndo, (const uint8_t *)(ext + 1), ntohs(e.len) - 4))
goto trunc;
}
- return (u_char *)ext + ntohs(e.len);
+ return (const u_char *)ext + ntohs(e.len);
trunc:
ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_VID)));
return NULL;
@@ -1407,43 +1845,42 @@ ikev2_gen_print(netdissect_options *ndo, u_char tpay,
struct isakmp_gen e;
ND_TCHECK(*ext);
- safememcpy(&e, ext, sizeof(e));
+ UNALIGNED_MEMCPY(&e, ext, sizeof(e));
ikev2_pay_print(ndo, NPSTR(tpay), e.critical);
ND_PRINT((ndo," len=%d", ntohs(e.len) - 4));
if (2 < ndo->ndo_vflag && 4 < ntohs(e.len)) {
ND_PRINT((ndo," "));
- if (!rawprint(ndo, (caddr_t)(ext + 1), ntohs(e.len) - 4))
+ if (!rawprint(ndo, (const uint8_t *)(ext + 1), ntohs(e.len) - 4))
goto trunc;
}
- return (u_char *)ext + ntohs(e.len);
+ return (const u_char *)ext + ntohs(e.len);
trunc:
ND_PRINT((ndo," [|%s]", NPSTR(tpay)));
return NULL;
}
static const u_char *
-ikev2_t_print(netdissect_options *ndo, u_char tpay _U_, int pcount,
+ikev2_t_print(netdissect_options *ndo, int tcount,
const struct isakmp_gen *ext, u_int item_len,
- const u_char *ep, u_int32_t phase _U_, u_int32_t doi _U_,
- u_int32_t proto _U_, int depth _U_)
+ const u_char *ep)
{
const struct ikev2_t *p;
struct ikev2_t t;
- u_int16_t t_id;
+ uint16_t t_id;
const u_char *cp;
const char *idstr;
const struct attrmap *map;
size_t nmap;
const u_char *ep2;
- p = (struct ikev2_t *)ext;
+ p = (const struct ikev2_t *)ext;
ND_TCHECK(*p);
- safememcpy(&t, ext, sizeof(t));
+ UNALIGNED_MEMCPY(&t, ext, sizeof(t));
ikev2_pay_print(ndo, NPSTR(ISAKMP_NPTYPE_T), t.h.critical);
t_id = ntohs(t.t_id);
-
+
map = NULL;
nmap = 0;
@@ -1476,15 +1913,15 @@ ikev2_t_print(netdissect_options *ndo, u_char tpay _U_, int pcount,
}
if (idstr)
- ND_PRINT((ndo," #%u type=%s id=%s ", pcount,
+ ND_PRINT((ndo," #%u type=%s id=%s ", tcount,
STR_OR_ID(t.t_type, ikev2_t_type_map),
idstr));
else
- ND_PRINT((ndo," #%u type=%s id=%u ", pcount,
+ ND_PRINT((ndo," #%u type=%s id=%u ", tcount,
STR_OR_ID(t.t_type, ikev2_t_type_map),
t.t_id));
- cp = (u_char *)(p + 1);
- ep2 = (u_char *)p + item_len;
+ cp = (const u_char *)(p + 1);
+ ep2 = (const u_char *)p + item_len;
while (cp < ep && cp < ep2) {
if (map && nmap) {
cp = ikev1_attrmap_print(ndo, cp, (ep < ep2) ? ep : ep2,
@@ -1502,34 +1939,97 @@ trunc:
static const u_char *
ikev2_p_print(netdissect_options *ndo, u_char tpay _U_, int pcount _U_,
- const struct isakmp_gen *ext, u_int item_len _U_,
- const u_char *ep, u_int32_t phase, u_int32_t doi0,
- u_int32_t proto0 _U_, int depth)
+ const struct isakmp_gen *ext, u_int oprop_length,
+ const u_char *ep, int depth)
{
const struct ikev2_p *p;
struct ikev2_p prop;
+ u_int prop_length;
const u_char *cp;
+ int i;
+ int tcount;
+ u_char np;
+ struct isakmp_gen e;
+ u_int item_len;
- p = (struct ikev2_p *)ext;
+ p = (const struct ikev2_p *)ext;
ND_TCHECK(*p);
- safememcpy(&prop, ext, sizeof(prop));
+ UNALIGNED_MEMCPY(&prop, ext, sizeof(prop));
+
ikev2_pay_print(ndo, NPSTR(ISAKMP_NPTYPE_P), prop.h.critical);
+ /*
+ * ikev2_sa_print() guarantees that this is >= 4.
+ */
+ prop_length = oprop_length - 4;
ND_PRINT((ndo," #%u protoid=%s transform=%d len=%u",
prop.p_no, PROTOIDSTR(prop.prot_id),
- prop.num_t, ntohs(prop.h.len)));
+ prop.num_t, oprop_length));
+ cp = (const u_char *)(p + 1);
+
if (prop.spi_size) {
+ if (prop_length < prop.spi_size)
+ goto toolong;
ND_PRINT((ndo," spi="));
- if (!rawprint(ndo, (caddr_t)(p + 1), prop.spi_size))
+ if (!rawprint(ndo, (const uint8_t *)cp, prop.spi_size))
goto trunc;
+ cp += prop.spi_size;
+ prop_length -= prop.spi_size;
}
- ext = (struct isakmp_gen *)((u_char *)(p + 1) + prop.spi_size);
- ND_TCHECK(*ext);
+ /*
+ * Print the transforms.
+ */
+ tcount = 0;
+ for (np = ISAKMP_NPTYPE_T; np != 0; np = e.np) {
+ tcount++;
+ ext = (const struct isakmp_gen *)cp;
+ if (prop_length < sizeof(*ext))
+ goto toolong;
+ ND_TCHECK(*ext);
- cp = ikev2_sub_print(ndo, NULL, ISAKMP_NPTYPE_T, ext, ep, phase, doi0,
- prop.prot_id, depth);
-
+ UNALIGNED_MEMCPY(&e, ext, sizeof(e));
+
+ /*
+ * Since we can't have a payload length of less than 4 bytes,
+ * we need to bail out here if the generic header is nonsensical
+ * or truncated, otherwise we could loop forever processing
+ * zero-length items or otherwise misdissect the packet.
+ */
+ item_len = ntohs(e.len);
+ if (item_len <= 4)
+ goto trunc;
+
+ if (prop_length < item_len)
+ goto toolong;
+ ND_TCHECK2(*cp, item_len);
+
+ depth++;
+ ND_PRINT((ndo,"\n"));
+ for (i = 0; i < depth; i++)
+ ND_PRINT((ndo," "));
+ ND_PRINT((ndo,"("));
+ if (np == ISAKMP_NPTYPE_T) {
+ cp = ikev2_t_print(ndo, tcount, ext, item_len, ep);
+ if (cp == NULL) {
+ /* error, already reported */
+ return NULL;
+ }
+ } else {
+ ND_PRINT((ndo, "%s", NPSTR(np)));
+ cp += item_len;
+ }
+ ND_PRINT((ndo,")"));
+ depth--;
+ prop_length -= item_len;
+ }
+ return cp;
+toolong:
+ /*
+ * Skip the rest of the proposal.
+ */
+ cp += prop_length;
+ ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_P)));
return cp;
trunc:
ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_P)));
@@ -1537,76 +2037,136 @@ trunc:
}
static const u_char *
-ikev2_sa_print(netdissect_options *ndo, u_char tpay,
+ikev2_sa_print(netdissect_options *ndo, u_char tpay,
const struct isakmp_gen *ext1,
- u_int item_len _U_, const u_char *ep _U_,
- u_int32_t phase _U_, u_int32_t doi _U_,
- u_int32_t proto _U_, int depth _U_)
+ u_int osa_length, const u_char *ep,
+ uint32_t phase _U_, uint32_t doi _U_,
+ uint32_t proto _U_, int depth)
{
+ const struct isakmp_gen *ext;
struct isakmp_gen e;
- int osa_length, sa_length;
+ u_int sa_length;
+ const u_char *cp;
+ int i;
+ int pcount;
+ u_char np;
+ u_int item_len;
ND_TCHECK(*ext1);
- safememcpy(&e, ext1, sizeof(e));
+ UNALIGNED_MEMCPY(&e, ext1, sizeof(e));
ikev2_pay_print(ndo, "sa", e.critical);
+ /*
+ * ikev2_sub0_print() guarantees that this is >= 4.
+ */
osa_length= ntohs(e.len);
sa_length = osa_length - 4;
ND_PRINT((ndo," len=%d", sa_length));
- ikev2_sub_print(ndo, NULL, ISAKMP_NPTYPE_P,
- ext1+1, ep,
- 0, 0, 0, depth);
+ /*
+ * Print the payloads.
+ */
+ cp = (const u_char *)(ext1 + 1);
+ pcount = 0;
+ for (np = ISAKMP_NPTYPE_P; np != 0; np = e.np) {
+ pcount++;
+ ext = (const struct isakmp_gen *)cp;
+ if (sa_length < sizeof(*ext))
+ goto toolong;
+ ND_TCHECK(*ext);
+
+ UNALIGNED_MEMCPY(&e, ext, sizeof(e));
+
+ /*
+ * Since we can't have a payload length of less than 4 bytes,
+ * we need to bail out here if the generic header is nonsensical
+ * or truncated, otherwise we could loop forever processing
+ * zero-length items or otherwise misdissect the packet.
+ */
+ item_len = ntohs(e.len);
+ if (item_len <= 4)
+ goto trunc;
+
+ if (sa_length < item_len)
+ goto toolong;
+ ND_TCHECK2(*cp, item_len);
- return (u_char *)ext1 + osa_length;
+ depth++;
+ ND_PRINT((ndo,"\n"));
+ for (i = 0; i < depth; i++)
+ ND_PRINT((ndo," "));
+ ND_PRINT((ndo,"("));
+ if (np == ISAKMP_NPTYPE_P) {
+ cp = ikev2_p_print(ndo, np, pcount, ext, item_len,
+ ep, depth);
+ if (cp == NULL) {
+ /* error, already reported */
+ return NULL;
+ }
+ } else {
+ ND_PRINT((ndo, "%s", NPSTR(np)));
+ cp += item_len;
+ }
+ ND_PRINT((ndo,")"));
+ depth--;
+ sa_length -= item_len;
+ }
+ return cp;
+toolong:
+ /*
+ * Skip the rest of the SA.
+ */
+ cp += sa_length;
+ ND_PRINT((ndo," [|%s]", NPSTR(tpay)));
+ return cp;
trunc:
ND_PRINT((ndo," [|%s]", NPSTR(tpay)));
return NULL;
}
static const u_char *
-ikev2_ke_print(netdissect_options *ndo, u_char tpay,
+ikev2_ke_print(netdissect_options *ndo, u_char tpay,
const struct isakmp_gen *ext,
u_int item_len _U_, const u_char *ep _U_,
- u_int32_t phase _U_, u_int32_t doi _U_,
- u_int32_t proto _U_, int depth _U_)
+ uint32_t phase _U_, uint32_t doi _U_,
+ uint32_t proto _U_, int depth _U_)
{
struct ikev2_ke ke;
- struct ikev2_ke *k;
+ const struct ikev2_ke *k;
- k = (struct ikev2_ke *)ext;
+ k = (const struct ikev2_ke *)ext;
ND_TCHECK(*ext);
- safememcpy(&ke, ext, sizeof(ke));
+ UNALIGNED_MEMCPY(&ke, ext, sizeof(ke));
ikev2_pay_print(ndo, NPSTR(tpay), ke.h.critical);
ND_PRINT((ndo," len=%u group=%s", ntohs(ke.h.len) - 8,
STR_OR_ID(ntohs(ke.ke_group), dh_p_map)));
-
+
if (2 < ndo->ndo_vflag && 8 < ntohs(ke.h.len)) {
ND_PRINT((ndo," "));
- if (!rawprint(ndo, (caddr_t)(k + 1), ntohs(ke.h.len) - 8))
+ if (!rawprint(ndo, (const uint8_t *)(k + 1), ntohs(ke.h.len) - 8))
goto trunc;
}
- return (u_char *)ext + ntohs(ke.h.len);
+ return (const u_char *)ext + ntohs(ke.h.len);
trunc:
ND_PRINT((ndo," [|%s]", NPSTR(tpay)));
return NULL;
}
static const u_char *
-ikev2_ID_print(netdissect_options *ndo, u_char tpay,
+ikev2_ID_print(netdissect_options *ndo, u_char tpay,
const struct isakmp_gen *ext,
u_int item_len _U_, const u_char *ep _U_,
- u_int32_t phase _U_, u_int32_t doi _U_,
- u_int32_t proto _U_, int depth _U_)
+ uint32_t phase _U_, uint32_t doi _U_,
+ uint32_t proto _U_, int depth _U_)
{
struct ikev2_id id;
int id_len, idtype_len, i;
unsigned int dumpascii, dumphex;
- unsigned char *typedata;
+ const unsigned char *typedata;
ND_TCHECK(*ext);
- safememcpy(&id, ext, sizeof(id));
+ UNALIGNED_MEMCPY(&id, ext, sizeof(id));
ikev2_pay_print(ndo, NPSTR(tpay), id.h.critical);
id_len = ntohs(id.h.len);
@@ -1614,14 +2174,14 @@ ikev2_ID_print(netdissect_options *ndo, u_char tpay,
ND_PRINT((ndo," len=%d", id_len - 4));
if (2 < ndo->ndo_vflag && 4 < id_len) {
ND_PRINT((ndo," "));
- if (!rawprint(ndo, (caddr_t)(ext + 1), id_len - 4))
+ if (!rawprint(ndo, (const uint8_t *)(ext + 1), id_len - 4))
goto trunc;
}
idtype_len =id_len - sizeof(struct ikev2_id);
dumpascii = 0;
dumphex = 0;
- typedata = (unsigned char *)(ext)+sizeof(struct ikev2_id);
+ typedata = (const unsigned char *)(ext)+sizeof(struct ikev2_id);
switch(id.type) {
case ID_IPV4_ADDR:
@@ -1657,7 +2217,7 @@ ikev2_ID_print(netdissect_options *ndo, u_char tpay,
if(dumpascii) {
ND_TCHECK2(*typedata, idtype_len);
for(i=0; i<idtype_len; i++) {
- if(isprint(typedata[i])) {
+ if(ND_ISPRINT(typedata[i])) {
ND_PRINT((ndo, "%c", typedata[i]));
} else {
ND_PRINT((ndo, "."));
@@ -1665,96 +2225,96 @@ ikev2_ID_print(netdissect_options *ndo, u_char tpay,
}
}
if(dumphex) {
- if (!rawprint(ndo, (caddr_t)typedata, idtype_len))
+ if (!rawprint(ndo, (const uint8_t *)typedata, idtype_len))
goto trunc;
}
- return (u_char *)ext + id_len;
+ return (const u_char *)ext + id_len;
trunc:
ND_PRINT((ndo," [|%s]", NPSTR(tpay)));
return NULL;
}
static const u_char *
-ikev2_cert_print(netdissect_options *ndo, u_char tpay,
+ikev2_cert_print(netdissect_options *ndo, u_char tpay,
const struct isakmp_gen *ext,
u_int item_len _U_, const u_char *ep _U_,
- u_int32_t phase _U_, u_int32_t doi _U_,
- u_int32_t proto _U_, int depth _U_)
+ uint32_t phase _U_, uint32_t doi _U_,
+ uint32_t proto _U_, int depth _U_)
{
return ikev2_gen_print(ndo, tpay, ext);
}
static const u_char *
-ikev2_cr_print(netdissect_options *ndo, u_char tpay,
+ikev2_cr_print(netdissect_options *ndo, u_char tpay,
const struct isakmp_gen *ext,
u_int item_len _U_, const u_char *ep _U_,
- u_int32_t phase _U_, u_int32_t doi _U_,
- u_int32_t proto _U_, int depth _U_)
+ uint32_t phase _U_, uint32_t doi _U_,
+ uint32_t proto _U_, int depth _U_)
{
return ikev2_gen_print(ndo, tpay, ext);
}
static const u_char *
-ikev2_auth_print(netdissect_options *ndo, u_char tpay,
+ikev2_auth_print(netdissect_options *ndo, u_char tpay,
const struct isakmp_gen *ext,
- u_int item_len _U_, const u_char *ep _U_,
- u_int32_t phase _U_, u_int32_t doi _U_,
- u_int32_t proto _U_, int depth _U_)
+ u_int item_len _U_, const u_char *ep,
+ uint32_t phase _U_, uint32_t doi _U_,
+ uint32_t proto _U_, int depth _U_)
{
struct ikev2_auth a;
const char *v2_auth[]={ "invalid", "rsasig",
"shared-secret", "dsssig" };
- u_char *authdata = (u_char*)ext + sizeof(a);
+ const u_char *authdata = (const u_char*)ext + sizeof(a);
unsigned int len;
ND_TCHECK(*ext);
- safememcpy(&a, ext, sizeof(a));
+ UNALIGNED_MEMCPY(&a, ext, sizeof(a));
ikev2_pay_print(ndo, NPSTR(tpay), a.h.critical);
len = ntohs(a.h.len);
- ND_PRINT((ndo," len=%d method=%s", len-4,
+ ND_PRINT((ndo," len=%d method=%s", len-4,
STR_OR_ID(a.auth_method, v2_auth)));
if (1 < ndo->ndo_vflag && 4 < len) {
ND_PRINT((ndo," authdata=("));
- if (!rawprint(ndo, (caddr_t)authdata, len - sizeof(a)))
+ if (!rawprint(ndo, (const uint8_t *)authdata, len - sizeof(a)))
goto trunc;
ND_PRINT((ndo,") "));
} else if(ndo->ndo_vflag && 4 < len) {
if(!ike_show_somedata(ndo, authdata, ep)) goto trunc;
}
- return (u_char *)ext + len;
+ return (const u_char *)ext + len;
trunc:
ND_PRINT((ndo," [|%s]", NPSTR(tpay)));
return NULL;
}
static const u_char *
-ikev2_nonce_print(netdissect_options *ndo, u_char tpay,
+ikev2_nonce_print(netdissect_options *ndo, u_char tpay,
const struct isakmp_gen *ext,
- u_int item_len _U_, const u_char *ep _U_,
- u_int32_t phase _U_, u_int32_t doi _U_,
- u_int32_t proto _U_, int depth _U_)
+ u_int item_len _U_, const u_char *ep,
+ uint32_t phase _U_, uint32_t doi _U_,
+ uint32_t proto _U_, int depth _U_)
{
struct isakmp_gen e;
ND_TCHECK(*ext);
- safememcpy(&e, ext, sizeof(e));
+ UNALIGNED_MEMCPY(&e, ext, sizeof(e));
ikev2_pay_print(ndo, "nonce", e.critical);
ND_PRINT((ndo," len=%d", ntohs(e.len) - 4));
if (1 < ndo->ndo_vflag && 4 < ntohs(e.len)) {
ND_PRINT((ndo," nonce=("));
- if (!rawprint(ndo, (caddr_t)(ext + 1), ntohs(e.len) - 4))
+ if (!rawprint(ndo, (const uint8_t *)(ext + 1), ntohs(e.len) - 4))
goto trunc;
ND_PRINT((ndo,") "));
} else if(ndo->ndo_vflag && 4 < ntohs(e.len)) {
if(!ike_show_somedata(ndo, (const u_char *)(ext+1), ep)) goto trunc;
}
- return (u_char *)ext + ntohs(e.len);
+ return (const u_char *)ext + ntohs(e.len);
trunc:
ND_PRINT((ndo," [|%s]", NPSTR(tpay)));
return NULL;
@@ -1762,22 +2322,22 @@ trunc:
/* notify payloads */
static const u_char *
-ikev2_n_print(netdissect_options *ndo, u_char tpay _U_,
+ikev2_n_print(netdissect_options *ndo, u_char tpay _U_,
const struct isakmp_gen *ext,
- u_int item_len _U_, const u_char *ep _U_,
- u_int32_t phase _U_, u_int32_t doi _U_,
- u_int32_t proto _U_, int depth _U_)
+ u_int item_len, const u_char *ep,
+ uint32_t phase _U_, uint32_t doi _U_,
+ uint32_t proto _U_, int depth _U_)
{
- struct ikev2_n *p, n;
+ const struct ikev2_n *p;
+ struct ikev2_n n;
const u_char *cp;
- u_char *ep2;
u_char showspi, showdata, showsomedata;
const char *notify_name;
- u_int32_t type;
+ uint32_t type;
- p = (struct ikev2_n *)ext;
+ p = (const struct ikev2_n *)ext;
ND_TCHECK(*p);
- safememcpy(&n, ext, sizeof(n));
+ UNALIGNED_MEMCPY(&n, ext, sizeof(n));
ikev2_pay_print(ndo, NPSTR(ISAKMP_NPTYPE_N), n.h.critical);
showspi = 1;
@@ -1851,7 +2411,7 @@ ikev2_n_print(netdissect_options *ndo, u_char tpay _U_,
showspi = 0;
break;
- case IV2_NOTIFY_FAILED_CP_REQUIRED:
+ case IV2_NOTIFY_FAILED_CP_REQUIRED:
notify_name = "failed:cp_required";
showspi = 0;
break;
@@ -1866,7 +2426,7 @@ ikev2_n_print(netdissect_options *ndo, u_char tpay _U_,
showspi = 0;
break;
- case IV2_NOTIFY_SET_WINDOW_SIZE:
+ case IV2_NOTIFY_SET_WINDOW_SIZE:
notify_name = "set_window_size";
showspi = 0;
break;
@@ -1876,7 +2436,7 @@ ikev2_n_print(netdissect_options *ndo, u_char tpay _U_,
showspi = 0;
break;
- case IV2_NOTIFY_IPCOMP_SUPPORTED:
+ case IV2_NOTIFY_IPCOMP_SUPPORTED:
notify_name = "ipcomp_supported";
showspi = 0;
break;
@@ -1938,16 +2498,15 @@ ikev2_n_print(netdissect_options *ndo, u_char tpay _U_,
if(notify_name) {
ND_PRINT((ndo," type=%u(%s)", type, notify_name));
}
-
+
if (showspi && n.spi_size) {
ND_PRINT((ndo," spi="));
- if (!rawprint(ndo, (caddr_t)(p + 1), n.spi_size))
+ if (!rawprint(ndo, (const uint8_t *)(p + 1), n.spi_size))
goto trunc;
}
- cp = (u_char *)(p + 1) + n.spi_size;
- ep2 = (u_char *)p + item_len;
+ cp = (const u_char *)(p + 1) + n.spi_size;
if(3 < ndo->ndo_vflag) {
showdata = 1;
@@ -1955,7 +2514,7 @@ ikev2_n_print(netdissect_options *ndo, u_char tpay _U_,
if ((showdata || (showsomedata && ep-cp < 30)) && cp < ep) {
ND_PRINT((ndo," data=("));
- if (!rawprint(ndo, (caddr_t)(cp), ep - cp))
+ if (!rawprint(ndo, (const uint8_t *)(cp), ep - cp))
goto trunc;
ND_PRINT((ndo,")"));
@@ -1963,63 +2522,63 @@ ikev2_n_print(netdissect_options *ndo, u_char tpay _U_,
} else if(showsomedata && cp < ep) {
if(!ike_show_somedata(ndo, cp, ep)) goto trunc;
}
-
- return (u_char *)ext + item_len;
+
+ return (const u_char *)ext + item_len;
trunc:
ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_N)));
return NULL;
}
static const u_char *
-ikev2_d_print(netdissect_options *ndo, u_char tpay,
+ikev2_d_print(netdissect_options *ndo, u_char tpay,
const struct isakmp_gen *ext,
u_int item_len _U_, const u_char *ep _U_,
- u_int32_t phase _U_, u_int32_t doi _U_,
- u_int32_t proto _U_, int depth _U_)
+ uint32_t phase _U_, uint32_t doi _U_,
+ uint32_t proto _U_, int depth _U_)
{
return ikev2_gen_print(ndo, tpay, ext);
}
static const u_char *
-ikev2_vid_print(netdissect_options *ndo, u_char tpay,
+ikev2_vid_print(netdissect_options *ndo, u_char tpay,
const struct isakmp_gen *ext,
u_int item_len _U_, const u_char *ep _U_,
- u_int32_t phase _U_, u_int32_t doi _U_,
- u_int32_t proto _U_, int depth _U_)
+ uint32_t phase _U_, uint32_t doi _U_,
+ uint32_t proto _U_, int depth _U_)
{
struct isakmp_gen e;
const u_char *vid;
int i, len;
ND_TCHECK(*ext);
- safememcpy(&e, ext, sizeof(e));
+ UNALIGNED_MEMCPY(&e, ext, sizeof(e));
ikev2_pay_print(ndo, NPSTR(tpay), e.critical);
ND_PRINT((ndo," len=%d vid=", ntohs(e.len) - 4));
-
+
vid = (const u_char *)(ext+1);
len = ntohs(e.len) - 4;
ND_TCHECK2(*vid, len);
for(i=0; i<len; i++) {
- if(isprint(vid[i])) ND_PRINT((ndo, "%c", vid[i]));
+ if(ND_ISPRINT(vid[i])) ND_PRINT((ndo, "%c", vid[i]));
else ND_PRINT((ndo, "."));
}
if (2 < ndo->ndo_vflag && 4 < len) {
ND_PRINT((ndo," "));
- if (!rawprint(ndo, (caddr_t)(ext + 1), ntohs(e.len) - 4))
+ if (!rawprint(ndo, (const uint8_t *)(ext + 1), ntohs(e.len) - 4))
goto trunc;
}
- return (u_char *)ext + ntohs(e.len);
+ return (const u_char *)ext + ntohs(e.len);
trunc:
ND_PRINT((ndo," [|%s]", NPSTR(tpay)));
return NULL;
}
static const u_char *
-ikev2_TS_print(netdissect_options *ndo, u_char tpay,
+ikev2_TS_print(netdissect_options *ndo, u_char tpay,
const struct isakmp_gen *ext,
u_int item_len _U_, const u_char *ep _U_,
- u_int32_t phase _U_, u_int32_t doi _U_,
- u_int32_t proto _U_, int depth _U_)
+ uint32_t phase _U_, uint32_t doi _U_,
+ uint32_t proto _U_, int depth _U_)
{
return ikev2_gen_print(ndo, tpay, ext);
}
@@ -2030,32 +2589,32 @@ ikev2_e_print(netdissect_options *ndo,
_U_
#endif
struct isakmp *base,
- u_char tpay,
+ u_char tpay,
const struct isakmp_gen *ext,
u_int item_len _U_, const u_char *ep _U_,
#ifndef HAVE_LIBCRYPTO
_U_
#endif
- u_int32_t phase,
+ uint32_t phase,
#ifndef HAVE_LIBCRYPTO
_U_
#endif
- u_int32_t doi,
+ uint32_t doi,
#ifndef HAVE_LIBCRYPTO
_U_
#endif
- u_int32_t proto,
+ uint32_t proto,
#ifndef HAVE_LIBCRYPTO
_U_
#endif
int depth)
{
struct isakmp_gen e;
- u_char *dat;
+ const u_char *dat;
volatile int dlen;
ND_TCHECK(*ext);
- safememcpy(&e, ext, sizeof(e));
+ UNALIGNED_MEMCPY(&e, ext, sizeof(e));
ikev2_pay_print(ndo, NPSTR(tpay), e.critical);
dlen = ntohs(e.len)-4;
@@ -2063,20 +2622,20 @@ ikev2_e_print(netdissect_options *ndo,
ND_PRINT((ndo," len=%d", dlen));
if (2 < ndo->ndo_vflag && 4 < dlen) {
ND_PRINT((ndo," "));
- if (!rawprint(ndo, (caddr_t)(ext + 1), dlen))
+ if (!rawprint(ndo, (const uint8_t *)(ext + 1), dlen))
goto trunc;
}
- dat = (u_char *)(ext+1);
+ dat = (const u_char *)(ext+1);
ND_TCHECK2(*dat, dlen);
-
+
#ifdef HAVE_LIBCRYPTO
/* try to decypt it! */
if(esp_print_decrypt_buffer_by_ikev2(ndo,
base->flags & ISAKMP_FLAG_I,
base->i_ck, base->r_ck,
dat, dat+dlen)) {
-
+
ext = (const struct isakmp_gen *)ndo->ndo_packetp;
/* got it decrypted, print stuff inside. */
@@ -2084,7 +2643,7 @@ ikev2_e_print(netdissect_options *ndo,
phase, doi, proto, depth+1);
}
#endif
-
+
/* always return NULL, because E must be at end, and NP refers
* to what was inside.
@@ -2096,21 +2655,21 @@ trunc:
}
static const u_char *
-ikev2_cp_print(netdissect_options *ndo, u_char tpay,
+ikev2_cp_print(netdissect_options *ndo, u_char tpay,
const struct isakmp_gen *ext,
u_int item_len _U_, const u_char *ep _U_,
- u_int32_t phase _U_, u_int32_t doi _U_,
- u_int32_t proto _U_, int depth _U_)
+ uint32_t phase _U_, uint32_t doi _U_,
+ uint32_t proto _U_, int depth _U_)
{
return ikev2_gen_print(ndo, tpay, ext);
}
static const u_char *
-ikev2_eap_print(netdissect_options *ndo, u_char tpay,
+ikev2_eap_print(netdissect_options *ndo, u_char tpay,
const struct isakmp_gen *ext,
u_int item_len _U_, const u_char *ep _U_,
- u_int32_t phase _U_, u_int32_t doi _U_,
- u_int32_t proto _U_, int depth _U_)
+ uint32_t phase _U_, uint32_t doi _U_,
+ uint32_t proto _U_, int depth _U_)
{
return ikev2_gen_print(ndo, tpay, ext);
}
@@ -2119,15 +2678,15 @@ static const u_char *
ike_sub0_print(netdissect_options *ndo,
u_char np, const struct isakmp_gen *ext, const u_char *ep,
- u_int32_t phase, u_int32_t doi, u_int32_t proto, int depth)
+ uint32_t phase, uint32_t doi, uint32_t proto, int depth)
{
const u_char *cp;
struct isakmp_gen e;
u_int item_len;
- cp = (u_char *)ext;
+ cp = (const u_char *)ext;
ND_TCHECK(*ext);
- safememcpy(&e, ext, sizeof(e));
+ UNALIGNED_MEMCPY(&e, ext, sizeof(e));
/*
* Since we can't have a payload length of less than 4 bytes,
@@ -2159,7 +2718,7 @@ trunc:
static const u_char *
ikev1_sub_print(netdissect_options *ndo,
u_char np, const struct isakmp_gen *ext, const u_char *ep,
- u_int32_t phase, u_int32_t doi, u_int32_t proto, int depth)
+ uint32_t phase, uint32_t doi, uint32_t proto, int depth)
{
const u_char *cp;
int i;
@@ -2169,8 +2728,8 @@ ikev1_sub_print(netdissect_options *ndo,
while (np) {
ND_TCHECK(*ext);
-
- safememcpy(&e, ext, sizeof(e));
+
+ UNALIGNED_MEMCPY(&e, ext, sizeof(e));
ND_TCHECK2(*ext, ntohs(e.len));
@@ -2189,7 +2748,7 @@ ikev1_sub_print(netdissect_options *ndo,
}
np = e.np;
- ext = (struct isakmp_gen *)cp;
+ ext = (const struct isakmp_gen *)cp;
}
return cp;
trunc:
@@ -2205,17 +2764,6 @@ numstr(int x)
return buf;
}
-/*
- * some compiler tries to optimize memcpy(), using the alignment constraint
- * on the argument pointer type. by using this function, we try to avoid the
- * optimization.
- */
-static void
-safememcpy(void *p, const void *q, size_t l)
-{
- memcpy(p, q, l);
-}
-
static void
ikev1_print(netdissect_options *ndo,
const u_char *bp, u_int length,
@@ -2226,19 +2774,19 @@ ikev1_print(netdissect_options *ndo,
u_char np;
int i;
int phase;
-
+
p = (const struct isakmp *)bp;
ep = ndo->ndo_snapend;
-
- phase = (*(u_int32_t *)base->msgid == 0) ? 1 : 2;
+
+ phase = (EXTRACT_32BITS(base->msgid) == 0) ? 1 : 2;
if (phase == 1)
ND_PRINT((ndo," phase %d", phase));
else
ND_PRINT((ndo," phase %d/others", phase));
-
+
i = cookie_find(&base->i_ck);
if (i < 0) {
- if (iszero((u_char *)&base->r_ck, sizeof(base->r_ck))) {
+ if (iszero((const u_char *)&base->r_ck, sizeof(base->r_ck))) {
/* the first packet */
ND_PRINT((ndo," I"));
if (bp2)
@@ -2253,19 +2801,18 @@ ikev1_print(netdissect_options *ndo,
else
ND_PRINT((ndo," ?"));
}
-
+
ND_PRINT((ndo," %s", ETYPESTR(base->etype)));
if (base->flags) {
ND_PRINT((ndo,"[%s%s]", base->flags & ISAKMP_FLAG_E ? "E" : "",
base->flags & ISAKMP_FLAG_C ? "C" : ""));
}
-
+
if (ndo->ndo_vflag) {
const struct isakmp_gen *ext;
- int nparen;
-
+
ND_PRINT((ndo,":"));
-
+
/* regardless of phase... */
if (base->flags & ISAKMP_FLAG_E) {
/*
@@ -2275,36 +2822,35 @@ ikev1_print(netdissect_options *ndo,
ND_PRINT((ndo," [encrypted %s]", NPSTR(base->np)));
goto done;
}
-
- nparen = 0;
+
CHECKLEN(p + 1, base->np);
np = base->np;
- ext = (struct isakmp_gen *)(p + 1);
+ ext = (const struct isakmp_gen *)(p + 1);
ikev1_sub_print(ndo, np, ext, ep, phase, 0, 0, 0);
}
-
+
done:
if (ndo->ndo_vflag) {
if (ntohl(base->len) != length) {
ND_PRINT((ndo," (len mismatch: isakmp %u/ip %u)",
- (u_int32_t)ntohl(base->len), length));
+ (uint32_t)ntohl(base->len), length));
}
}
}
static const u_char *
ikev2_sub0_print(netdissect_options *ndo, struct isakmp *base,
- u_char np, int pcount,
+ u_char np,
const struct isakmp_gen *ext, const u_char *ep,
- u_int32_t phase, u_int32_t doi, u_int32_t proto, int depth)
+ uint32_t phase, uint32_t doi, uint32_t proto, int depth)
{
const u_char *cp;
struct isakmp_gen e;
u_int item_len;
- cp = (u_char *)ext;
+ cp = (const u_char *)ext;
ND_TCHECK(*ext);
- safememcpy(&e, ext, sizeof(e));
+ UNALIGNED_MEMCPY(&e, ext, sizeof(e));
/*
* Since we can't have a payload length of less than 4 bytes,
@@ -2316,13 +2862,7 @@ ikev2_sub0_print(netdissect_options *ndo, struct isakmp *base,
if (item_len <= 4)
return NULL;
- if(np == ISAKMP_NPTYPE_P) {
- cp = ikev2_p_print(ndo, np, pcount, ext, item_len,
- ep, phase, doi, proto, depth);
- } else if(np == ISAKMP_NPTYPE_T) {
- cp = ikev2_t_print(ndo, np, pcount, ext, item_len,
- ep, phase, doi, proto, depth);
- } else if(np == ISAKMP_NPTYPE_v2E) {
+ if (np == ISAKMP_NPTYPE_v2E) {
cp = ikev2_e_print(ndo, base, np, ext, item_len,
ep, phase, doi, proto, depth);
} else if (NPFUNC(np)) {
@@ -2330,7 +2870,7 @@ ikev2_sub0_print(netdissect_options *ndo, struct isakmp *base,
* XXX - what if item_len is too short, or too long,
* for this payload type?
*/
- cp = (*npfunc[np])(ndo, np, /*pcount,*/ ext, item_len,
+ cp = (*npfunc[np])(ndo, np, ext, item_len,
ep, phase, doi, proto, depth);
} else {
ND_PRINT((ndo,"%s", NPSTR(np)));
@@ -2347,20 +2887,17 @@ static const u_char *
ikev2_sub_print(netdissect_options *ndo,
struct isakmp *base,
u_char np, const struct isakmp_gen *ext, const u_char *ep,
- u_int32_t phase, u_int32_t doi, u_int32_t proto, int depth)
+ uint32_t phase, uint32_t doi, uint32_t proto, int depth)
{
const u_char *cp;
int i;
- int pcount;
struct isakmp_gen e;
cp = (const u_char *)ext;
- pcount = 0;
while (np) {
- pcount++;
ND_TCHECK(*ext);
-
- safememcpy(&e, ext, sizeof(e));
+
+ UNALIGNED_MEMCPY(&e, ext, sizeof(e));
ND_TCHECK2(*ext, ntohs(e.len));
@@ -2369,7 +2906,7 @@ ikev2_sub_print(netdissect_options *ndo,
for (i = 0; i < depth; i++)
ND_PRINT((ndo," "));
ND_PRINT((ndo,"("));
- cp = ikev2_sub0_print(ndo, base, np, pcount,
+ cp = ikev2_sub0_print(ndo, base, np,
ext, ep, phase, doi, proto, depth);
ND_PRINT((ndo,")"));
depth--;
@@ -2380,7 +2917,7 @@ ikev2_sub_print(netdissect_options *ndo,
}
np = e.np;
- ext = (struct isakmp_gen *)cp;
+ ext = (const struct isakmp_gen *)cp;
}
return cp;
trunc:
@@ -2401,7 +2938,7 @@ ikev2_print(netdissect_options *ndo,
p = (const struct isakmp *)bp;
ep = ndo->ndo_snapend;
- phase = (*(u_int32_t *)base->msgid == 0) ? 1 : 2;
+ phase = (EXTRACT_32BITS(base->msgid) == 0) ? 1 : 2;
if (phase == 1)
ND_PRINT((ndo, " parent_sa"));
else
@@ -2417,7 +2954,6 @@ ikev2_print(netdissect_options *ndo,
if (ndo->ndo_vflag) {
const struct isakmp_gen *ext;
- int nparen;
ND_PRINT((ndo, ":"));
@@ -2431,11 +2967,10 @@ ikev2_print(netdissect_options *ndo,
goto done;
}
- nparen = 0;
CHECKLEN(p + 1, base->np)
np = base->np;
- ext = (struct isakmp_gen *)(p + 1);
+ ext = (const struct isakmp_gen *)(p + 1);
ikev2_sub_print(ndo, base, np, ext, ep, phase, 0, 0, 0);
}
@@ -2443,7 +2978,7 @@ done:
if (ndo->ndo_vflag) {
if (ntohl(base->len) != length) {
ND_PRINT((ndo, " (len mismatch: isakmp %u/ip %u)",
- (u_int32_t)ntohl(base->len), length));
+ (uint32_t)ntohl(base->len), length));
}
}
}
@@ -2469,12 +3004,12 @@ isakmp_print(netdissect_options *ndo,
p = (const struct isakmp *)bp;
ep = ndo->ndo_snapend;
- if ((struct isakmp *)ep < p + 1) {
+ if ((const struct isakmp *)ep < p + 1) {
ND_PRINT((ndo,"[|isakmp]"));
return;
}
- safememcpy(&base, p, sizeof(base));
+ UNALIGNED_MEMCPY(&base, p, sizeof(base));
ND_PRINT((ndo,"isakmp"));
major = (base.vers & ISAKMP_VERS_MAJOR)
@@ -2488,14 +3023,14 @@ isakmp_print(netdissect_options *ndo,
if (ndo->ndo_vflag) {
ND_PRINT((ndo," msgid "));
- hexprint(ndo, (caddr_t)&base.msgid, sizeof(base.msgid));
+ hexprint(ndo, (const uint8_t *)&base.msgid, sizeof(base.msgid));
}
if (1 < ndo->ndo_vflag) {
ND_PRINT((ndo," cookie "));
- hexprint(ndo, (caddr_t)&base.i_ck, sizeof(base.i_ck));
+ hexprint(ndo, (const uint8_t *)&base.i_ck, sizeof(base.i_ck));
ND_PRINT((ndo,"->"));
- hexprint(ndo, (caddr_t)&base.r_ck, sizeof(base.r_ck));
+ hexprint(ndo, (const uint8_t *)&base.r_ck, sizeof(base.r_ck));
}
ND_PRINT((ndo,":"));
@@ -2515,8 +3050,6 @@ isakmp_rfc3948_print(netdissect_options *ndo,
const u_char *bp, u_int length,
const u_char *bp2)
{
- const u_char *ep;
- ep = ndo->ndo_snapend;
if(length == 1 && bp[0]==0xff) {
ND_PRINT((ndo, "isakmp-nat-keep-alive"));
@@ -2526,7 +3059,7 @@ isakmp_rfc3948_print(netdissect_options *ndo,
if(length < 4) {
goto trunc;
}
-
+
/*
* see if this is an IKE packet
*/
@@ -2550,7 +3083,7 @@ isakmp_rfc3948_print(netdissect_options *ndo,
bp += advance;
length -= advance + padlen;
nh = enh & 0xff;
-
+
ip_print_inner(ndo, bp, length, nh, bp2);
return;
}
@@ -2568,5 +3101,8 @@ trunc:
*/
-
+
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-isakmp-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-isoclns.c b/freebsd/contrib/tcpdump/print-isoclns.c
index a4b9fb95..a199e7c6 100644
--- a/freebsd/contrib/tcpdump/print-isoclns.c
+++ b/freebsd/contrib/tcpdump/print-isoclns.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1992, 1993, 1994, 1995, 1996
* The Regents of the University of California. All rights reserved.
@@ -24,27 +27,20 @@
*
* Extensively modified by Hannes Gredler (hannes@juniper.net) for more
* complete IS-IS & CLNP support.
- *
- * $FreeBSD$
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-isoclns.c,v 1.165 2008-08-16 13:38:15 hannes Exp $ (LBL)";
-#endif
+/* \summary: ISO CLNS, ESIS, and ISIS printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include <stdio.h>
#include <string.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
-#include "ethertype.h"
#include "ether.h"
#include "nlpid.h"
#include "extract.h"
@@ -52,6 +48,8 @@ static const char rcsid[] _U_ =
#include "oui.h"
#include "signature.h"
+static const char tstr[] = " [|isis]";
+
/*
* IS-IS is defined in ISO 10589. Look there for protocol definitions.
*/
@@ -80,7 +78,7 @@ static const char rcsid[] _U_ =
#define ISIS_PDU_L1_PSNP 26
#define ISIS_PDU_L2_PSNP 27
-static struct tok isis_pdu_values[] = {
+static const struct tok isis_pdu_values[] = {
{ ISIS_PDU_L1_LAN_IIH, "L1 Lan IIH"},
{ ISIS_PDU_L2_LAN_IIH, "L2 Lan IIH"},
{ ISIS_PDU_PTP_IIH, "p2p IIH"},
@@ -113,6 +111,7 @@ static struct tok isis_pdu_values[] = {
#define ISIS_TLV_AUTH 10 /* iso10589, rfc3567 */
#define ISIS_TLV_CHECKSUM 12 /* rfc3358 */
#define ISIS_TLV_CHECKSUM_MINLEN 2
+#define ISIS_TLV_POI 13 /* rfc6232 */
#define ISIS_TLV_LSP_BUFFERSIZE 14 /* iso10589 rev2 */
#define ISIS_TLV_LSP_BUFFERSIZE_MINLEN 2
#define ISIS_TLV_EXT_IS_REACH 22 /* draft-ietf-isis-traffic-05 */
@@ -150,7 +149,7 @@ static struct tok isis_pdu_values[] = {
#define ISIS_TLV_VENDOR_PRIVATE 250 /* draft-ietf-isis-experimental-tlv-01 */
#define ISIS_TLV_VENDOR_PRIVATE_MINLEN 3
-static struct tok isis_tlv_values[] = {
+static const struct tok isis_tlv_values[] = {
{ ISIS_TLV_AREA_ADDR, "Area address(es)"},
{ ISIS_TLV_IS_REACH, "IS Reachability"},
{ ISIS_TLV_ESNEIGH, "ES Neighbor(s)"},
@@ -162,6 +161,7 @@ static struct tok isis_tlv_values[] = {
{ ISIS_TLV_LSP, "LSP entries"},
{ ISIS_TLV_AUTH, "Authentication"},
{ ISIS_TLV_CHECKSUM, "Checksum"},
+ { ISIS_TLV_POI, "Purge Originator Identifier"},
{ ISIS_TLV_LSP_BUFFERSIZE, "LSP Buffersize"},
{ ISIS_TLV_EXT_IS_REACH, "Extended IS Reachability"},
{ ISIS_TLV_IS_ALIAS_ID, "IS Alias ID"},
@@ -202,7 +202,7 @@ static struct tok isis_tlv_values[] = {
#define ESIS_OPTION_ADDRESS_MASK 225 /* iso9542 */
#define ESIS_OPTION_SNPA_MASK 226 /* iso9542 */
-static struct tok esis_option_values[] = {
+static const struct tok esis_option_values[] = {
{ ESIS_OPTION_PROTOCOLS, "Protocols supported"},
{ ESIS_OPTION_QOS_MAINTENANCE, "QoS Maintenance" },
{ ESIS_OPTION_SECURITY, "Security" },
@@ -221,7 +221,7 @@ static struct tok esis_option_values[] = {
#define CLNP_OPTION_PADDING 204 /* iso8473 */
#define CLNP_OPTION_PRIORITY 205 /* iso8473 */
-static struct tok clnp_option_values[] = {
+static const struct tok clnp_option_values[] = {
{ CLNP_OPTION_DISCARD_REASON, "Discard Reason"},
{ CLNP_OPTION_PRIORITY, "Priority"},
{ CLNP_OPTION_QOS_MAINTENANCE, "QoS Maintenance"},
@@ -232,7 +232,7 @@ static struct tok clnp_option_values[] = {
{ 0, NULL }
};
-static struct tok clnp_option_rfd_class_values[] = {
+static const struct tok clnp_option_rfd_class_values[] = {
{ 0x0, "General"},
{ 0x8, "Address"},
{ 0x9, "Source Routeing"},
@@ -242,7 +242,7 @@ static struct tok clnp_option_rfd_class_values[] = {
{ 0, NULL }
};
-static struct tok clnp_option_rfd_general_values[] = {
+static const struct tok clnp_option_rfd_general_values[] = {
{ 0x0, "Reason not specified"},
{ 0x1, "Protocol procedure error"},
{ 0x2, "Incorrect checksum"},
@@ -254,13 +254,13 @@ static struct tok clnp_option_rfd_general_values[] = {
{ 0, NULL }
};
-static struct tok clnp_option_rfd_address_values[] = {
+static const struct tok clnp_option_rfd_address_values[] = {
{ 0x0, "Destination address unreachable"},
{ 0x1, "Destination address unknown"},
{ 0, NULL }
};
-static struct tok clnp_option_rfd_source_routeing_values[] = {
+static const struct tok clnp_option_rfd_source_routeing_values[] = {
{ 0x0, "Unspecified source routeing error"},
{ 0x1, "Syntax error in source routeing field"},
{ 0x2, "Unknown address in source routeing field"},
@@ -268,13 +268,13 @@ static struct tok clnp_option_rfd_source_routeing_values[] = {
{ 0, NULL }
};
-static struct tok clnp_option_rfd_lifetime_values[] = {
+static const struct tok clnp_option_rfd_lifetime_values[] = {
{ 0x0, "Lifetime expired while data unit in transit"},
{ 0x1, "Lifetime expired during reassembly"},
{ 0, NULL }
};
-static struct tok clnp_option_rfd_pdu_discard_values[] = {
+static const struct tok clnp_option_rfd_pdu_discard_values[] = {
{ 0x0, "Unsupported option not specified"},
{ 0x1, "Unsupported protocol version"},
{ 0x2, "Unsupported security option"},
@@ -283,13 +283,13 @@ static struct tok clnp_option_rfd_pdu_discard_values[] = {
{ 0, NULL }
};
-static struct tok clnp_option_rfd_reassembly_values[] = {
+static const struct tok clnp_option_rfd_reassembly_values[] = {
{ 0x0, "Reassembly interference"},
{ 0, NULL }
};
/* array of 16 error-classes */
-static struct tok *clnp_option_rfd_error_class[] = {
+static const struct tok *clnp_option_rfd_error_class[] = {
clnp_option_rfd_general_values,
NULL,
NULL,
@@ -314,26 +314,26 @@ static struct tok *clnp_option_rfd_error_class[] = {
#define CLNP_OPTION_SCOPE_DA_SPEC 0x80
#define CLNP_OPTION_SCOPE_GLOBAL 0xc0
-static struct tok clnp_option_scope_values[] = {
+static const struct tok clnp_option_scope_values[] = {
{ CLNP_OPTION_SCOPE_SA_SPEC, "Source Address Specific"},
{ CLNP_OPTION_SCOPE_DA_SPEC, "Destination Address Specific"},
{ CLNP_OPTION_SCOPE_GLOBAL, "Globally unique"},
{ 0, NULL }
};
-static struct tok clnp_option_sr_rr_values[] = {
+static const struct tok clnp_option_sr_rr_values[] = {
{ 0x0, "partial"},
{ 0x1, "complete"},
{ 0, NULL }
};
-static struct tok clnp_option_sr_rr_string_values[] = {
+static const struct tok clnp_option_sr_rr_string_values[] = {
{ CLNP_OPTION_SOURCE_ROUTING, "source routing"},
{ CLNP_OPTION_ROUTE_RECORDING, "recording of route in progress"},
{ 0, NULL }
};
-static struct tok clnp_option_qos_global_values[] = {
+static const struct tok clnp_option_qos_global_values[] = {
{ 0x20, "reserved"},
{ 0x10, "sequencing vs. delay"},
{ 0x08, "congested"},
@@ -360,7 +360,7 @@ static struct tok clnp_option_qos_global_values[] = {
#define ISIS_SUBTLV_SPB_METRIC 29 /* rfc6329 */
-static struct tok isis_ext_is_reach_subtlv_values[] = {
+static const struct tok isis_ext_is_reach_subtlv_values[] = {
{ ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP, "Administrative groups" },
{ ISIS_SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID, "Link Local/Remote Identifier" },
{ ISIS_SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID, "Link Remote Identifier" },
@@ -389,14 +389,14 @@ static struct tok isis_ext_is_reach_subtlv_values[] = {
#define ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG64 2 /* draft-ietf-isis-admin-tags-01 */
#define ISIS_SUBTLV_EXTD_IP_REACH_MGMT_PREFIX_COLOR 117 /* draft-ietf-isis-wg-multi-topology-05 */
-static struct tok isis_ext_ip_reach_subtlv_values[] = {
+static const struct tok isis_ext_ip_reach_subtlv_values[] = {
{ ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG32, "32-Bit Administrative tag" },
{ ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG64, "64-Bit Administrative tag" },
{ ISIS_SUBTLV_EXTD_IP_REACH_MGMT_PREFIX_COLOR, "Management Prefix Color" },
{ 0, NULL }
};
-static struct tok isis_subtlv_link_attribute_values[] = {
+static const struct tok isis_subtlv_link_attribute_values[] = {
{ 0x01, "Local Protection Available" },
{ 0x02, "Link excluded from local protection path" },
{ 0x04, "Local maintenance required"},
@@ -409,7 +409,7 @@ static struct tok isis_subtlv_link_attribute_values[] = {
#define ISIS_SUBTLV_AUTH_MD5_LEN 16
#define ISIS_SUBTLV_AUTH_PRIVATE 255
-static struct tok isis_subtlv_auth_values[] = {
+static const struct tok isis_subtlv_auth_values[] = {
{ ISIS_SUBTLV_AUTH_SIMPLE, "simple text password"},
{ ISIS_SUBTLV_AUTH_GENERIC, "Generic Crypto key-id"},
{ ISIS_SUBTLV_AUTH_MD5, "HMAC-MD5 password"},
@@ -421,7 +421,7 @@ static struct tok isis_subtlv_auth_values[] = {
#define ISIS_SUBTLV_IDRP_LOCAL 1
#define ISIS_SUBTLV_IDRP_ASN 2
-static struct tok isis_subtlv_idrp_values[] = {
+static const struct tok isis_subtlv_idrp_values[] = {
{ ISIS_SUBTLV_IDRP_RES, "Reserved"},
{ ISIS_SUBTLV_IDRP_LOCAL, "Routing-Domain Specific"},
{ ISIS_SUBTLV_IDRP_ASN, "AS Number Tag"},
@@ -442,24 +442,24 @@ static struct tok isis_subtlv_idrp_values[] = {
#define ISIS_SUBTLV_SPB_INSTANCE_MIN_LEN 19
#define ISIS_SUBTLV_SPB_INSTANCE_VLAN_TUPLE_LEN 8
-static struct tok isis_mt_port_cap_subtlv_values[] = {
+static const struct tok isis_mt_port_cap_subtlv_values[] = {
{ ISIS_SUBTLV_SPB_MCID, "SPB MCID" },
{ ISIS_SUBTLV_SPB_DIGEST, "SPB Digest" },
{ ISIS_SUBTLV_SPB_BVID, "SPB BVID" },
{ 0, NULL }
};
-static struct tok isis_mt_capability_subtlv_values[] = {
+static const struct tok isis_mt_capability_subtlv_values[] = {
{ ISIS_SUBTLV_SPB_INSTANCE, "SPB Instance" },
{ ISIS_SUBTLV_SPBM_SI, "SPBM Service Identifier and Unicast Address" },
{ 0, NULL }
};
struct isis_spb_mcid {
- u_int8_t format_id;
- u_int8_t name[32];
- u_int8_t revision_lvl[2];
- u_int8_t digest[16];
+ uint8_t format_id;
+ uint8_t name[32];
+ uint8_t revision_lvl[2];
+ uint8_t digest[16];
};
struct isis_subtlv_spb_mcid {
@@ -468,18 +468,18 @@ struct isis_subtlv_spb_mcid {
};
struct isis_subtlv_spb_instance {
- u_int8_t cist_root_id[8];
- u_int8_t cist_external_root_path_cost[4];
- u_int8_t bridge_priority[2];
- u_int8_t spsourceid[4];
- u_int8_t no_of_trees;
+ uint8_t cist_root_id[8];
+ uint8_t cist_external_root_path_cost[4];
+ uint8_t bridge_priority[2];
+ uint8_t spsourceid[4];
+ uint8_t no_of_trees;
};
#define CLNP_SEGMENT_PART 0x80
#define CLNP_MORE_SEGMENTS 0x40
#define CLNP_REQUEST_ER 0x20
-static struct tok clnp_flag_values[] = {
+static const struct tok clnp_flag_values[] = {
{ CLNP_SEGMENT_PART, "Segmentation permitted"},
{ CLNP_MORE_SEGMENTS, "more Segments"},
{ CLNP_REQUEST_ER, "request Error Report"},
@@ -498,7 +498,7 @@ static struct tok clnp_flag_values[] = {
#define ISIS_MASK_MTID(x) ((x)&0x0fff)
#define ISIS_MASK_MTFLAGS(x) ((x)&0xf000)
-static struct tok isis_mt_flag_values[] = {
+static const struct tok isis_mt_flag_values[] = {
{ 0x4000, "ATT bit set"},
{ 0x8000, "Overload bit set"},
{ 0, NULL}
@@ -517,7 +517,7 @@ static struct tok isis_mt_flag_values[] = {
#define ISIS_MASK_TLV_SHARED_RISK_GROUP(x) ((x)&0x1)
-static struct tok isis_mt_values[] = {
+static const struct tok isis_mt_values[] = {
{ 0, "IPv4 unicast"},
{ 1, "In-Band Management"},
{ 2, "IPv6 unicast"},
@@ -526,7 +526,7 @@ static struct tok isis_mt_values[] = {
{ 0, NULL }
};
-static struct tok isis_iih_circuit_type_values[] = {
+static const struct tok isis_iih_circuit_type_values[] = {
{ 1, "Level 1 only"},
{ 2, "Level 2 only"},
{ 3, "Level 1, Level 2"},
@@ -538,7 +538,7 @@ static struct tok isis_iih_circuit_type_values[] = {
#define ISIS_LSP_TYPE_UNUSED2 2
#define ISIS_LSP_TYPE_LEVEL_2 3
-static struct tok isis_lsp_istype_values[] = {
+static const struct tok isis_lsp_istype_values[] = {
{ ISIS_LSP_TYPE_UNUSED0, "Unused 0x0 (invalid)"},
{ ISIS_LSP_TYPE_LEVEL_1, "L1 IS"},
{ ISIS_LSP_TYPE_UNUSED2, "Unused 0x2 (invalid)"},
@@ -555,7 +555,7 @@ static struct tok isis_lsp_istype_values[] = {
#define ISIS_PTP_ADJ_INIT 1
#define ISIS_PTP_ADJ_DOWN 2
-static struct tok isis_ptp_adjancey_values[] = {
+static const struct tok isis_ptp_adjancey_values[] = {
{ ISIS_PTP_ADJ_UP, "Up" },
{ ISIS_PTP_ADJ_INIT, "Initializing" },
{ ISIS_PTP_ADJ_DOWN, "Down" },
@@ -563,48 +563,48 @@ static struct tok isis_ptp_adjancey_values[] = {
};
struct isis_tlv_ptp_adj {
- u_int8_t adjacency_state;
- u_int8_t extd_local_circuit_id[4];
- u_int8_t neighbor_sysid[SYSTEM_ID_LEN];
- u_int8_t neighbor_extd_local_circuit_id[4];
+ uint8_t adjacency_state;
+ uint8_t extd_local_circuit_id[4];
+ uint8_t neighbor_sysid[SYSTEM_ID_LEN];
+ uint8_t neighbor_extd_local_circuit_id[4];
};
-static void osi_print_cksum(const u_int8_t *pptr, u_int16_t checksum,
- u_int checksum_offset, u_int length);
-static int clnp_print(const u_int8_t *, u_int);
-static void esis_print(const u_int8_t *, u_int);
-static int isis_print(const u_int8_t *, u_int);
+static int osi_print_cksum(netdissect_options *, const uint8_t *pptr,
+ uint16_t checksum, int checksum_offset, int length);
+static int clnp_print(netdissect_options *, const uint8_t *, u_int);
+static void esis_print(netdissect_options *, const uint8_t *, u_int);
+static int isis_print(netdissect_options *, const uint8_t *, u_int);
struct isis_metric_block {
- u_int8_t metric_default;
- u_int8_t metric_delay;
- u_int8_t metric_expense;
- u_int8_t metric_error;
+ uint8_t metric_default;
+ uint8_t metric_delay;
+ uint8_t metric_expense;
+ uint8_t metric_error;
};
struct isis_tlv_is_reach {
struct isis_metric_block isis_metric_block;
- u_int8_t neighbor_nodeid[NODE_ID_LEN];
+ uint8_t neighbor_nodeid[NODE_ID_LEN];
};
struct isis_tlv_es_reach {
struct isis_metric_block isis_metric_block;
- u_int8_t neighbor_sysid[SYSTEM_ID_LEN];
+ uint8_t neighbor_sysid[SYSTEM_ID_LEN];
};
struct isis_tlv_ip_reach {
struct isis_metric_block isis_metric_block;
- u_int8_t prefix[4];
- u_int8_t mask[4];
+ uint8_t prefix[4];
+ uint8_t mask[4];
};
-static struct tok isis_is_reach_virtual_values[] = {
+static const struct tok isis_is_reach_virtual_values[] = {
{ 0, "IsNotVirtual"},
{ 1, "IsVirtual"},
{ 0, NULL }
};
-static struct tok isis_restart_flag_values[] = {
+static const struct tok isis_restart_flag_values[] = {
{ 0x1, "Restart Request"},
{ 0x2, "Restart Acknowledgement"},
{ 0x4, "Suppress adjacency advertisement"},
@@ -612,59 +612,59 @@ static struct tok isis_restart_flag_values[] = {
};
struct isis_common_header {
- u_int8_t nlpid;
- u_int8_t fixed_len;
- u_int8_t version; /* Protocol version */
- u_int8_t id_length;
- u_int8_t pdu_type; /* 3 MSbits are reserved */
- u_int8_t pdu_version; /* Packet format version */
- u_int8_t reserved;
- u_int8_t max_area;
+ uint8_t nlpid;
+ uint8_t fixed_len;
+ uint8_t version; /* Protocol version */
+ uint8_t id_length;
+ uint8_t pdu_type; /* 3 MSbits are reserved */
+ uint8_t pdu_version; /* Packet format version */
+ uint8_t reserved;
+ uint8_t max_area;
};
struct isis_iih_lan_header {
- u_int8_t circuit_type;
- u_int8_t source_id[SYSTEM_ID_LEN];
- u_int8_t holding_time[2];
- u_int8_t pdu_len[2];
- u_int8_t priority;
- u_int8_t lan_id[NODE_ID_LEN];
+ uint8_t circuit_type;
+ uint8_t source_id[SYSTEM_ID_LEN];
+ uint8_t holding_time[2];
+ uint8_t pdu_len[2];
+ uint8_t priority;
+ uint8_t lan_id[NODE_ID_LEN];
};
struct isis_iih_ptp_header {
- u_int8_t circuit_type;
- u_int8_t source_id[SYSTEM_ID_LEN];
- u_int8_t holding_time[2];
- u_int8_t pdu_len[2];
- u_int8_t circuit_id;
+ uint8_t circuit_type;
+ uint8_t source_id[SYSTEM_ID_LEN];
+ uint8_t holding_time[2];
+ uint8_t pdu_len[2];
+ uint8_t circuit_id;
};
struct isis_lsp_header {
- u_int8_t pdu_len[2];
- u_int8_t remaining_lifetime[2];
- u_int8_t lsp_id[LSP_ID_LEN];
- u_int8_t sequence_number[4];
- u_int8_t checksum[2];
- u_int8_t typeblock;
+ uint8_t pdu_len[2];
+ uint8_t remaining_lifetime[2];
+ uint8_t lsp_id[LSP_ID_LEN];
+ uint8_t sequence_number[4];
+ uint8_t checksum[2];
+ uint8_t typeblock;
};
struct isis_csnp_header {
- u_int8_t pdu_len[2];
- u_int8_t source_id[NODE_ID_LEN];
- u_int8_t start_lsp_id[LSP_ID_LEN];
- u_int8_t end_lsp_id[LSP_ID_LEN];
+ uint8_t pdu_len[2];
+ uint8_t source_id[NODE_ID_LEN];
+ uint8_t start_lsp_id[LSP_ID_LEN];
+ uint8_t end_lsp_id[LSP_ID_LEN];
};
struct isis_psnp_header {
- u_int8_t pdu_len[2];
- u_int8_t source_id[NODE_ID_LEN];
+ uint8_t pdu_len[2];
+ uint8_t source_id[NODE_ID_LEN];
};
struct isis_tlv_lsp {
- u_int8_t remaining_lifetime[2];
- u_int8_t lsp_id[LSP_ID_LEN];
- u_int8_t sequence_number[4];
- u_int8_t checksum[2];
+ uint8_t remaining_lifetime[2];
+ uint8_t lsp_id[LSP_ID_LEN];
+ uint8_t sequence_number[4];
+ uint8_t checksum[2];
};
#define ISIS_COMMON_HEADER_SIZE (sizeof(struct isis_common_header))
@@ -674,66 +674,60 @@ struct isis_tlv_lsp {
#define ISIS_CSNP_HEADER_SIZE (sizeof(struct isis_csnp_header))
#define ISIS_PSNP_HEADER_SIZE (sizeof(struct isis_psnp_header))
-void isoclns_print(const u_int8_t *p, u_int length, u_int caplen)
+void
+isoclns_print(netdissect_options *ndo,
+ const uint8_t *p, u_int length, u_int caplen)
{
- if (caplen <= 1) { /* enough bytes on the wire ? */
- printf("|OSI");
- return;
- }
+ if (caplen <= 1) { /* enough bytes on the wire ? */
+ ND_PRINT((ndo, "|OSI"));
+ return;
+ }
+
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, "OSI NLPID %s (0x%02x): ", tok2str(nlpid_values, "Unknown", *p), *p));
- if (eflag)
- printf("OSI NLPID %s (0x%02x): ",
- tok2str(nlpid_values,"Unknown",*p),
- *p);
-
switch (*p) {
case NLPID_CLNP:
- if (!clnp_print(p, length))
- print_unknown_data(p,"\n\t",caplen);
+ if (!clnp_print(ndo, p, length))
+ print_unknown_data(ndo, p, "\n\t", caplen);
break;
case NLPID_ESIS:
- esis_print(p, length);
+ esis_print(ndo, p, length);
return;
case NLPID_ISIS:
- if (!isis_print(p, length))
- print_unknown_data(p,"\n\t",caplen);
+ if (!isis_print(ndo, p, length))
+ print_unknown_data(ndo, p, "\n\t", caplen);
break;
case NLPID_NULLNS:
- (void)printf("%slength: %u",
- eflag ? "" : ", ",
- length);
+ ND_PRINT((ndo, "%slength: %u", ndo->ndo_eflag ? "" : ", ", length));
break;
- case NLPID_Q933:
- q933_print(p+1, length-1);
- break;
+ case NLPID_Q933:
+ q933_print(ndo, p + 1, length - 1);
+ break;
- case NLPID_IP:
- ip_print(gndo, p+1, length-1);
- break;
+ case NLPID_IP:
+ ip_print(ndo, p + 1, length - 1);
+ break;
-#ifdef INET6
- case NLPID_IP6:
- ip6_print(gndo, p+1, length-1);
- break;
-#endif
+ case NLPID_IP6:
+ ip6_print(ndo, p + 1, length - 1);
+ break;
- case NLPID_PPP:
- ppp_print(p+1, length-1);
- break;
+ case NLPID_PPP:
+ ppp_print(ndo, p + 1, length - 1);
+ break;
default:
- if (!eflag)
- printf("OSI NLPID 0x%02x unknown",*p);
- (void)printf("%slength: %u",
- eflag ? "" : ", ",
- length);
+ if (!ndo->ndo_eflag)
+ ND_PRINT((ndo, "OSI NLPID 0x%02x unknown", *p));
+ ND_PRINT((ndo, "%slength: %u", ndo->ndo_eflag ? "" : ", ", length));
if (caplen > 1)
- print_unknown_data(p,"\n\t",caplen);
+ print_unknown_data(ndo, p, "\n\t", caplen);
break;
}
}
@@ -744,7 +738,7 @@ void isoclns_print(const u_int8_t *p, u_int length, u_int caplen)
#define CLNP_PDU_ERQ 30
#define CLNP_PDU_ERP 31
-static struct tok clnp_pdu_values[] = {
+static const struct tok clnp_pdu_values[] = {
{ CLNP_PDU_ER, "Error Report"},
{ CLNP_PDU_MD, "MD"},
{ CLNP_PDU_DT, "Data"},
@@ -754,19 +748,19 @@ static struct tok clnp_pdu_values[] = {
};
struct clnp_header_t {
- u_int8_t nlpid;
- u_int8_t length_indicator;
- u_int8_t version;
- u_int8_t lifetime; /* units of 500ms */
- u_int8_t type;
- u_int8_t segment_length[2];
- u_int8_t cksum[2];
+ uint8_t nlpid;
+ uint8_t length_indicator;
+ uint8_t version;
+ uint8_t lifetime; /* units of 500ms */
+ uint8_t type;
+ uint8_t segment_length[2];
+ uint8_t cksum[2];
};
struct clnp_segment_header_t {
- u_int8_t data_unit_id[2];
- u_int8_t segment_offset[2];
- u_int8_t total_length[2];
+ uint8_t data_unit_id[2];
+ uint8_t segment_offset[2];
+ uint8_t total_length[2];
};
/*
@@ -774,29 +768,43 @@ struct clnp_segment_header_t {
* Decode CLNP packets. Return 0 on error.
*/
-static int clnp_print (const u_int8_t *pptr, u_int length)
+static int
+clnp_print(netdissect_options *ndo,
+ const uint8_t *pptr, u_int length)
{
- const u_int8_t *optr,*source_address,*dest_address;
+ const uint8_t *optr,*source_address,*dest_address;
u_int li,tlen,nsap_offset,source_address_length,dest_address_length, clnp_pdu_type, clnp_flags;
const struct clnp_header_t *clnp_header;
const struct clnp_segment_header_t *clnp_segment_header;
- u_int8_t rfd_error_major,rfd_error_minor;
+ uint8_t rfd_error_major,rfd_error_minor;
clnp_header = (const struct clnp_header_t *) pptr;
- TCHECK(*clnp_header);
+ ND_TCHECK(*clnp_header);
li = clnp_header->length_indicator;
optr = pptr;
- if (!eflag)
- printf("CLNP");
+ if (!ndo->ndo_eflag)
+ ND_PRINT((ndo, "CLNP"));
/*
* Sanity checking of the header.
*/
if (clnp_header->version != CLNP_VERSION) {
- printf("version %d packet not supported", clnp_header->version);
+ ND_PRINT((ndo, "version %d packet not supported", clnp_header->version));
+ return (0);
+ }
+
+ if (li > length) {
+ ND_PRINT((ndo, " length indicator(%u) > PDU size (%u)!", li, length));
+ return (0);
+ }
+
+ if (li < sizeof(struct clnp_header_t)) {
+ ND_PRINT((ndo, " length indicator %u < min PDU size:", li));
+ while (pptr < ndo->ndo_snapend)
+ ND_PRINT((ndo, "%02X", *pptr++));
return (0);
}
@@ -807,56 +815,85 @@ static int clnp_print (const u_int8_t *pptr, u_int length)
pptr += sizeof(struct clnp_header_t);
li -= sizeof(struct clnp_header_t);
+
+ if (li < 1) {
+ ND_PRINT((ndo, "li < size of fixed part of CLNP header and addresses"));
+ return (0);
+ }
+ ND_TCHECK(*pptr);
dest_address_length = *pptr;
- dest_address = pptr + 1;
+ pptr += 1;
+ li -= 1;
+ if (li < dest_address_length) {
+ ND_PRINT((ndo, "li < size of fixed part of CLNP header and addresses"));
+ return (0);
+ }
+ ND_TCHECK2(*pptr, dest_address_length);
+ dest_address = pptr;
+ pptr += dest_address_length;
+ li -= dest_address_length;
- pptr += (1 + dest_address_length);
- li -= (1 + dest_address_length);
+ if (li < 1) {
+ ND_PRINT((ndo, "li < size of fixed part of CLNP header and addresses"));
+ return (0);
+ }
+ ND_TCHECK(*pptr);
source_address_length = *pptr;
- source_address = pptr +1;
-
- pptr += (1 + source_address_length);
- li -= (1 + source_address_length);
-
- if (vflag < 1) {
- printf("%s%s > %s, %s, length %u",
- eflag ? "" : ", ",
- isonsap_string(source_address, source_address_length),
- isonsap_string(dest_address, dest_address_length),
+ pptr += 1;
+ li -= 1;
+ if (li < source_address_length) {
+ ND_PRINT((ndo, "li < size of fixed part of CLNP header and addresses"));
+ return (0);
+ }
+ ND_TCHECK2(*pptr, source_address_length);
+ source_address = pptr;
+ pptr += source_address_length;
+ li -= source_address_length;
+
+ if (ndo->ndo_vflag < 1) {
+ ND_PRINT((ndo, "%s%s > %s, %s, length %u",
+ ndo->ndo_eflag ? "" : ", ",
+ isonsap_string(ndo, source_address, source_address_length),
+ isonsap_string(ndo, dest_address, dest_address_length),
tok2str(clnp_pdu_values,"unknown (%u)",clnp_pdu_type),
- length);
+ length));
return (1);
}
- printf("%slength %u",eflag ? "" : ", ",length);
+ ND_PRINT((ndo, "%slength %u", ndo->ndo_eflag ? "" : ", ", length));
- printf("\n\t%s PDU, hlen: %u, v: %u, lifetime: %u.%us, Segment PDU length: %u, checksum: 0x%04x",
+ ND_PRINT((ndo, "\n\t%s PDU, hlen: %u, v: %u, lifetime: %u.%us, Segment PDU length: %u, checksum: 0x%04x",
tok2str(clnp_pdu_values, "unknown (%u)",clnp_pdu_type),
clnp_header->length_indicator,
clnp_header->version,
clnp_header->lifetime/2,
(clnp_header->lifetime%2)*5,
EXTRACT_16BITS(clnp_header->segment_length),
- EXTRACT_16BITS(clnp_header->cksum));
+ EXTRACT_16BITS(clnp_header->cksum)));
- osi_print_cksum(optr, EXTRACT_16BITS(clnp_header->cksum), 7,
- clnp_header->length_indicator);
+ if (osi_print_cksum(ndo, optr, EXTRACT_16BITS(clnp_header->cksum), 7,
+ clnp_header->length_indicator) == 0)
+ goto trunc;
- printf("\n\tFlags [%s]",
- bittok2str(clnp_flag_values,"none",clnp_flags));
+ ND_PRINT((ndo, "\n\tFlags [%s]",
+ bittok2str(clnp_flag_values, "none", clnp_flags)));
- printf("\n\tsource address (length %u): %s\n\tdest address (length %u): %s",
+ ND_PRINT((ndo, "\n\tsource address (length %u): %s\n\tdest address (length %u): %s",
source_address_length,
- isonsap_string(source_address, source_address_length),
+ isonsap_string(ndo, source_address, source_address_length),
dest_address_length,
- isonsap_string(dest_address,dest_address_length));
+ isonsap_string(ndo, dest_address, dest_address_length)));
if (clnp_flags & CLNP_SEGMENT_PART) {
+ if (li < sizeof(const struct clnp_segment_header_t)) {
+ ND_PRINT((ndo, "li < size of fixed part of CLNP header, addresses, and segment part"));
+ return (0);
+ }
clnp_segment_header = (const struct clnp_segment_header_t *) pptr;
- TCHECK(*clnp_segment_header);
- printf("\n\tData Unit ID: 0x%04x, Segment Offset: %u, Total PDU Length: %u",
+ ND_TCHECK(*clnp_segment_header);
+ ND_PRINT((ndo, "\n\tData Unit ID: 0x%04x, Segment Offset: %u, Total PDU Length: %u",
EXTRACT_16BITS(clnp_segment_header->data_unit_id),
EXTRACT_16BITS(clnp_segment_header->segment_offset),
- EXTRACT_16BITS(clnp_segment_header->total_length));
+ EXTRACT_16BITS(clnp_segment_header->total_length)));
pptr+=sizeof(const struct clnp_segment_header_t);
li-=sizeof(const struct clnp_segment_header_t);
}
@@ -864,46 +901,58 @@ static int clnp_print (const u_int8_t *pptr, u_int length)
/* now walk the options */
while (li >= 2) {
u_int op, opli;
- const u_int8_t *tptr;
-
- TCHECK2(*pptr, 2);
+ const uint8_t *tptr;
+
if (li < 2) {
- printf(", bad opts/li");
+ ND_PRINT((ndo, ", bad opts/li"));
return (0);
}
+ ND_TCHECK2(*pptr, 2);
op = *pptr++;
opli = *pptr++;
li -= 2;
- TCHECK2(*pptr, opli);
if (opli > li) {
- printf(", opt (%d) too long", op);
+ ND_PRINT((ndo, ", opt (%d) too long", op));
return (0);
}
+ ND_TCHECK2(*pptr, opli);
li -= opli;
tptr = pptr;
tlen = opli;
-
- printf("\n\t %s Option #%u, length %u, value: ",
+
+ ND_PRINT((ndo, "\n\t %s Option #%u, length %u, value: ",
tok2str(clnp_option_values,"Unknown",op),
op,
- opli);
+ opli));
+ /*
+ * We've already checked that the entire option is present
+ * in the captured packet with the ND_TCHECK2() call.
+ * Therefore, we don't need to do ND_TCHECK()/ND_TCHECK2()
+ * checks.
+ * We do, however, need to check tlen, to make sure we
+ * don't run past the end of the option.
+ */
switch (op) {
case CLNP_OPTION_ROUTE_RECORDING: /* those two options share the format */
- case CLNP_OPTION_SOURCE_ROUTING:
- printf("%s %s",
+ case CLNP_OPTION_SOURCE_ROUTING:
+ if (tlen < 2) {
+ ND_PRINT((ndo, ", bad opt len"));
+ return (0);
+ }
+ ND_PRINT((ndo, "%s %s",
tok2str(clnp_option_sr_rr_values,"Unknown",*tptr),
- tok2str(clnp_option_sr_rr_string_values,"Unknown Option %u",op));
+ tok2str(clnp_option_sr_rr_string_values, "Unknown Option %u", op)));
nsap_offset=*(tptr+1);
if (nsap_offset == 0) {
- printf(" Bad NSAP offset (0)");
+ ND_PRINT((ndo, " Bad NSAP offset (0)"));
break;
}
nsap_offset-=1; /* offset to nsap list */
if (nsap_offset > tlen) {
- printf(" Bad NSAP offset (past end of option)");
+ ND_PRINT((ndo, " Bad NSAP offset (past end of option)"));
break;
}
tptr+=nsap_offset;
@@ -911,53 +960,69 @@ static int clnp_print (const u_int8_t *pptr, u_int length)
while (tlen > 0) {
source_address_length=*tptr;
if (tlen < source_address_length+1) {
- printf("\n\t NSAP address goes past end of option");
+ ND_PRINT((ndo, "\n\t NSAP address goes past end of option"));
break;
}
if (source_address_length > 0) {
source_address=(tptr+1);
- TCHECK2(*source_address, source_address_length);
- printf("\n\t NSAP address (length %u): %s",
+ ND_TCHECK2(*source_address, source_address_length);
+ ND_PRINT((ndo, "\n\t NSAP address (length %u): %s",
source_address_length,
- isonsap_string(source_address, source_address_length));
+ isonsap_string(ndo, source_address, source_address_length)));
}
tlen-=source_address_length+1;
}
break;
case CLNP_OPTION_PRIORITY:
- printf("0x%1x", *tptr&0x0f);
+ if (tlen < 1) {
+ ND_PRINT((ndo, ", bad opt len"));
+ return (0);
+ }
+ ND_PRINT((ndo, "0x%1x", *tptr&0x0f));
break;
case CLNP_OPTION_QOS_MAINTENANCE:
- printf("\n\t Format Code: %s",
- tok2str(clnp_option_scope_values,"Reserved",*tptr&CLNP_OPTION_SCOPE_MASK));
+ if (tlen < 1) {
+ ND_PRINT((ndo, ", bad opt len"));
+ return (0);
+ }
+ ND_PRINT((ndo, "\n\t Format Code: %s",
+ tok2str(clnp_option_scope_values, "Reserved", *tptr&CLNP_OPTION_SCOPE_MASK)));
if ((*tptr&CLNP_OPTION_SCOPE_MASK) == CLNP_OPTION_SCOPE_GLOBAL)
- printf("\n\t QoS Flags [%s]",
+ ND_PRINT((ndo, "\n\t QoS Flags [%s]",
bittok2str(clnp_option_qos_global_values,
"none",
- *tptr&CLNP_OPTION_OPTION_QOS_MASK));
+ *tptr&CLNP_OPTION_OPTION_QOS_MASK)));
break;
case CLNP_OPTION_SECURITY:
- printf("\n\t Format Code: %s, Security-Level %u",
+ if (tlen < 2) {
+ ND_PRINT((ndo, ", bad opt len"));
+ return (0);
+ }
+ ND_PRINT((ndo, "\n\t Format Code: %s, Security-Level %u",
tok2str(clnp_option_scope_values,"Reserved",*tptr&CLNP_OPTION_SCOPE_MASK),
- *(tptr+1));
+ *(tptr+1)));
break;
case CLNP_OPTION_DISCARD_REASON:
+ if (tlen < 1) {
+ ND_PRINT((ndo, ", bad opt len"));
+ return (0);
+ }
rfd_error_major = (*tptr&0xf0) >> 4;
rfd_error_minor = *tptr&0x0f;
- printf("\n\t Class: %s Error (0x%01x), %s (0x%01x)",
+ ND_PRINT((ndo, "\n\t Class: %s Error (0x%01x), %s (0x%01x)",
tok2str(clnp_option_rfd_class_values,"Unknown",rfd_error_major),
rfd_error_major,
tok2str(clnp_option_rfd_error_class[rfd_error_major],"Unknown",rfd_error_minor),
- rfd_error_minor);
+ rfd_error_minor));
break;
case CLNP_OPTION_PADDING:
- printf("padding data");
+ ND_PRINT((ndo, "padding data"));
break;
/*
@@ -966,11 +1031,11 @@ static int clnp_print (const u_int8_t *pptr, u_int length)
*/
default:
- print_unknown_data(tptr,"\n\t ",opli);
+ print_unknown_data(ndo, tptr, "\n\t ", opli);
break;
}
- if (vflag > 1)
- print_unknown_data(pptr,"\n\t ",opli);
+ if (ndo->ndo_vflag > 1)
+ print_unknown_data(ndo, pptr, "\n\t ", opli);
pptr += opli;
}
@@ -978,30 +1043,30 @@ static int clnp_print (const u_int8_t *pptr, u_int length)
case CLNP_PDU_ER: /* fall through */
case CLNP_PDU_ERP:
- TCHECK(*pptr);
+ ND_TCHECK(*pptr);
if (*(pptr) == NLPID_CLNP) {
- printf("\n\t-----original packet-----\n\t");
+ ND_PRINT((ndo, "\n\t-----original packet-----\n\t"));
/* FIXME recursion protection */
- clnp_print(pptr, length-clnp_header->length_indicator);
+ clnp_print(ndo, pptr, length - clnp_header->length_indicator);
break;
- }
+ }
case CLNP_PDU_DT:
case CLNP_PDU_MD:
case CLNP_PDU_ERQ:
-
+
default:
/* dump the PDU specific data */
if (length-(pptr-optr) > 0) {
- printf("\n\t undecoded non-header data, length %u",length-clnp_header->length_indicator);
- print_unknown_data(pptr,"\n\t ",length-(pptr-optr));
+ ND_PRINT((ndo, "\n\t undecoded non-header data, length %u", length-clnp_header->length_indicator));
+ print_unknown_data(ndo, pptr, "\n\t ", length - (pptr - optr));
}
}
return (1);
trunc:
- fputs("[|clnp]", stdout);
+ ND_PRINT((ndo, "[|clnp]"));
return (1);
}
@@ -1011,7 +1076,7 @@ static int clnp_print (const u_int8_t *pptr, u_int length)
#define ESIS_PDU_ESH 2
#define ESIS_PDU_ISH 4
-static struct tok esis_pdu_values[] = {
+static const struct tok esis_pdu_values[] = {
{ ESIS_PDU_REDIRECT, "redirect"},
{ ESIS_PDU_ESH, "ESH"},
{ ESIS_PDU_ISH, "ISH"},
@@ -1019,35 +1084,33 @@ static struct tok esis_pdu_values[] = {
};
struct esis_header_t {
- u_int8_t nlpid;
- u_int8_t length_indicator;
- u_int8_t version;
- u_int8_t reserved;
- u_int8_t type;
- u_int8_t holdtime[2];
- u_int8_t cksum[2];
+ uint8_t nlpid;
+ uint8_t length_indicator;
+ uint8_t version;
+ uint8_t reserved;
+ uint8_t type;
+ uint8_t holdtime[2];
+ uint8_t cksum[2];
};
static void
-esis_print(const u_int8_t *pptr, u_int length)
+esis_print(netdissect_options *ndo,
+ const uint8_t *pptr, u_int length)
{
- const u_int8_t *optr;
+ const uint8_t *optr;
u_int li,esis_pdu_type,source_address_length, source_address_number;
const struct esis_header_t *esis_header;
- if (!eflag)
- printf("ES-IS");
+ if (!ndo->ndo_eflag)
+ ND_PRINT((ndo, "ES-IS"));
if (length <= 2) {
- if (qflag)
- printf("bad pkt!");
- else
- printf("no header at all!");
+ ND_PRINT((ndo, ndo->ndo_qflag ? "bad pkt!" : "no header at all!"));
return;
}
esis_header = (const struct esis_header_t *) pptr;
- TCHECK(*esis_header);
+ ND_TCHECK(*esis_header);
li = esis_header->length_indicator;
optr = pptr;
@@ -1056,104 +1119,106 @@ esis_print(const u_int8_t *pptr, u_int length)
*/
if (esis_header->nlpid != NLPID_ESIS) {
- printf(" nlpid 0x%02x packet not supported", esis_header->nlpid);
+ ND_PRINT((ndo, " nlpid 0x%02x packet not supported", esis_header->nlpid));
return;
}
if (esis_header->version != ESIS_VERSION) {
- printf(" version %d packet not supported", esis_header->version);
+ ND_PRINT((ndo, " version %d packet not supported", esis_header->version));
return;
}
-
+
if (li > length) {
- printf(" length indicator(%d) > PDU size (%d)!", li, length);
+ ND_PRINT((ndo, " length indicator(%u) > PDU size (%u)!", li, length));
return;
}
if (li < sizeof(struct esis_header_t) + 2) {
- printf(" length indicator < min PDU size %d:", li);
- while (--length != 0)
- printf("%02X", *pptr++);
+ ND_PRINT((ndo, " length indicator %u < min PDU size:", li));
+ while (pptr < ndo->ndo_snapend)
+ ND_PRINT((ndo, "%02X", *pptr++));
return;
}
esis_pdu_type = esis_header->type & ESIS_PDU_TYPE_MASK;
- if (vflag < 1) {
- printf("%s%s, length %u",
- eflag ? "" : ", ",
+ if (ndo->ndo_vflag < 1) {
+ ND_PRINT((ndo, "%s%s, length %u",
+ ndo->ndo_eflag ? "" : ", ",
tok2str(esis_pdu_values,"unknown type (%u)",esis_pdu_type),
- length);
+ length));
return;
} else
- printf("%slength %u\n\t%s (%u)",
- eflag ? "" : ", ",
+ ND_PRINT((ndo, "%slength %u\n\t%s (%u)",
+ ndo->ndo_eflag ? "" : ", ",
length,
tok2str(esis_pdu_values,"unknown type: %u", esis_pdu_type),
- esis_pdu_type);
+ esis_pdu_type));
- printf(", v: %u%s", esis_header->version, esis_header->version == ESIS_VERSION ? "" : "unsupported" );
- printf(", checksum: 0x%04x", EXTRACT_16BITS(esis_header->cksum));
+ ND_PRINT((ndo, ", v: %u%s", esis_header->version, esis_header->version == ESIS_VERSION ? "" : "unsupported" ));
+ ND_PRINT((ndo, ", checksum: 0x%04x", EXTRACT_16BITS(esis_header->cksum)));
- osi_print_cksum(pptr, EXTRACT_16BITS(esis_header->cksum), 7, li);
+ if (osi_print_cksum(ndo, pptr, EXTRACT_16BITS(esis_header->cksum), 7, li) == 0)
+ goto trunc;
- printf(", holding time: %us, length indicator: %u",EXTRACT_16BITS(esis_header->holdtime),li);
+ ND_PRINT((ndo, ", holding time: %us, length indicator: %u",
+ EXTRACT_16BITS(esis_header->holdtime), li));
- if (vflag > 1)
- print_unknown_data(optr,"\n\t",sizeof(struct esis_header_t));
+ if (ndo->ndo_vflag > 1)
+ print_unknown_data(ndo, optr, "\n\t", sizeof(struct esis_header_t));
pptr += sizeof(struct esis_header_t);
li -= sizeof(struct esis_header_t);
switch (esis_pdu_type) {
case ESIS_PDU_REDIRECT: {
- const u_int8_t *dst, *snpa, *neta;
+ const uint8_t *dst, *snpa, *neta;
u_int dstl, snpal, netal;
- TCHECK(*pptr);
+ ND_TCHECK(*pptr);
if (li < 1) {
- printf(", bad redirect/li");
+ ND_PRINT((ndo, ", bad redirect/li"));
return;
}
dstl = *pptr;
pptr++;
li--;
- TCHECK2(*pptr, dstl);
+ ND_TCHECK2(*pptr, dstl);
if (li < dstl) {
- printf(", bad redirect/li");
+ ND_PRINT((ndo, ", bad redirect/li"));
return;
}
dst = pptr;
pptr += dstl;
li -= dstl;
- printf("\n\t %s", isonsap_string(dst,dstl));
+ ND_PRINT((ndo, "\n\t %s", isonsap_string(ndo, dst, dstl)));
- TCHECK(*pptr);
+ ND_TCHECK(*pptr);
if (li < 1) {
- printf(", bad redirect/li");
+ ND_PRINT((ndo, ", bad redirect/li"));
return;
}
snpal = *pptr;
pptr++;
li--;
- TCHECK2(*pptr, snpal);
+ ND_TCHECK2(*pptr, snpal);
if (li < snpal) {
- printf(", bad redirect/li");
+ ND_PRINT((ndo, ", bad redirect/li"));
return;
}
snpa = pptr;
pptr += snpal;
li -= snpal;
- TCHECK(*pptr);
+ ND_TCHECK(*pptr);
if (li < 1) {
- printf(", bad redirect/li");
+ ND_PRINT((ndo, ", bad redirect/li"));
return;
}
netal = *pptr;
pptr++;
- TCHECK2(*pptr, netal);
+ ND_TCHECK2(*pptr, netal);
if (li < netal) {
- printf(", bad redirect/li");
+ ND_PRINT((ndo, ", bad redirect/li"));
return;
}
neta = pptr;
@@ -1161,42 +1226,42 @@ esis_print(const u_int8_t *pptr, u_int length)
li -= netal;
if (netal == 0)
- printf("\n\t %s", etheraddr_string(snpa));
+ ND_PRINT((ndo, "\n\t %s", etheraddr_string(ndo, snpa)));
else
- printf("\n\t %s", isonsap_string(neta,netal));
+ ND_PRINT((ndo, "\n\t %s", isonsap_string(ndo, neta, netal)));
break;
}
case ESIS_PDU_ESH:
- TCHECK(*pptr);
+ ND_TCHECK(*pptr);
if (li < 1) {
- printf(", bad esh/li");
+ ND_PRINT((ndo, ", bad esh/li"));
return;
}
source_address_number = *pptr;
pptr++;
li--;
- printf("\n\t Number of Source Addresses: %u", source_address_number);
-
+ ND_PRINT((ndo, "\n\t Number of Source Addresses: %u", source_address_number));
+
while (source_address_number > 0) {
- TCHECK(*pptr);
+ ND_TCHECK(*pptr);
if (li < 1) {
- printf(", bad esh/li");
+ ND_PRINT((ndo, ", bad esh/li"));
return;
}
source_address_length = *pptr;
pptr++;
li--;
- TCHECK2(*pptr, source_address_length);
+ ND_TCHECK2(*pptr, source_address_length);
if (li < source_address_length) {
- printf(", bad esh/li");
+ ND_PRINT((ndo, ", bad esh/li"));
return;
}
- printf("\n\t NET (length: %u): %s",
+ ND_PRINT((ndo, "\n\t NET (length: %u): %s",
source_address_length,
- isonsap_string(pptr,source_address_length));
+ isonsap_string(ndo, pptr, source_address_length)));
pptr += source_address_length;
li -= source_address_length;
source_address_number--;
@@ -1205,78 +1270,78 @@ esis_print(const u_int8_t *pptr, u_int length)
break;
case ESIS_PDU_ISH: {
- TCHECK(*pptr);
+ ND_TCHECK(*pptr);
if (li < 1) {
- printf(", bad ish/li");
+ ND_PRINT((ndo, ", bad ish/li"));
return;
}
source_address_length = *pptr;
pptr++;
li--;
- TCHECK2(*pptr, source_address_length);
+ ND_TCHECK2(*pptr, source_address_length);
if (li < source_address_length) {
- printf(", bad ish/li");
+ ND_PRINT((ndo, ", bad ish/li"));
return;
}
- printf("\n\t NET (length: %u): %s", source_address_length, isonsap_string(pptr, source_address_length));
+ ND_PRINT((ndo, "\n\t NET (length: %u): %s", source_address_length, isonsap_string(ndo, pptr, source_address_length)));
pptr += source_address_length;
li -= source_address_length;
break;
}
default:
- if (vflag <= 1) {
- if (pptr < snapend)
- print_unknown_data(pptr,"\n\t ",snapend-pptr);
- }
- return;
+ if (ndo->ndo_vflag <= 1) {
+ if (pptr < ndo->ndo_snapend)
+ print_unknown_data(ndo, pptr, "\n\t ", ndo->ndo_snapend - pptr);
+ }
+ return;
}
/* now walk the options */
while (li != 0) {
u_int op, opli;
- const u_int8_t *tptr;
-
+ const uint8_t *tptr;
+
if (li < 2) {
- printf(", bad opts/li");
+ ND_PRINT((ndo, ", bad opts/li"));
return;
}
- TCHECK2(*pptr, 2);
+ ND_TCHECK2(*pptr, 2);
op = *pptr++;
opli = *pptr++;
li -= 2;
if (opli > li) {
- printf(", opt (%d) too long", op);
+ ND_PRINT((ndo, ", opt (%d) too long", op));
return;
}
li -= opli;
tptr = pptr;
-
- printf("\n\t %s Option #%u, length %u, value: ",
+
+ ND_PRINT((ndo, "\n\t %s Option #%u, length %u, value: ",
tok2str(esis_option_values,"Unknown",op),
op,
- opli);
+ opli));
switch (op) {
case ESIS_OPTION_ES_CONF_TIME:
if (opli == 2) {
- TCHECK2(*pptr, 2);
- printf("%us", EXTRACT_16BITS(tptr));
+ ND_TCHECK2(*pptr, 2);
+ ND_PRINT((ndo, "%us", EXTRACT_16BITS(tptr)));
} else
- printf("(bad length)");
+ ND_PRINT((ndo, "(bad length)"));
break;
case ESIS_OPTION_PROTOCOLS:
while (opli>0) {
- TCHECK(*pptr);
- printf("%s (0x%02x)",
+ ND_TCHECK(*pptr);
+ ND_PRINT((ndo, "%s (0x%02x)",
tok2str(nlpid_values,
"unknown",
*tptr),
- *tptr);
+ *tptr));
if (opli>1) /* further NPLIDs ? - put comma */
- printf(", ");
+ ND_PRINT((ndo, ", "));
tptr++;
opli--;
}
@@ -1294,58 +1359,58 @@ esis_print(const u_int8_t *pptr, u_int length)
case ESIS_OPTION_SNPA_MASK:
default:
- print_unknown_data(tptr,"\n\t ",opli);
+ print_unknown_data(ndo, tptr, "\n\t ", opli);
break;
}
- if (vflag > 1)
- print_unknown_data(pptr,"\n\t ",opli);
+ if (ndo->ndo_vflag > 1)
+ print_unknown_data(ndo, pptr, "\n\t ", opli);
pptr += opli;
}
trunc:
return;
-}
-
+}
static void
-isis_print_mcid (const struct isis_spb_mcid *mcid)
+isis_print_mcid(netdissect_options *ndo,
+ const struct isis_spb_mcid *mcid)
{
int i;
- printf( "ID: %d, Name: ", mcid->format_id);
+ ND_TCHECK(*mcid);
+ ND_PRINT((ndo, "ID: %d, Name: ", mcid->format_id));
- for(i=0; i<32; i++)
- {
- printf("%c", mcid->name[i]);
- if(mcid->name[i] == '\0')
- break;
- }
+ if (fn_printzp(ndo, mcid->name, 32, ndo->ndo_snapend))
+ goto trunc;
- printf("\n\t Lvl: %d",
- EXTRACT_16BITS(mcid->revision_lvl));
+ ND_PRINT((ndo, "\n\t Lvl: %d", EXTRACT_16BITS(mcid->revision_lvl)));
- printf( ", Digest: ");
+ ND_PRINT((ndo, ", Digest: "));
- for(i=0;i<16;i++)
- printf("%.2x ",mcid->digest[i]);
+ for(i=0;i<16;i++)
+ ND_PRINT((ndo, "%.2x ", mcid->digest[i]));
+
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
}
static int
-isis_print_mt_port_cap_subtlv (const u_int8_t *tptr, int len)
+isis_print_mt_port_cap_subtlv(netdissect_options *ndo,
+ const uint8_t *tptr, int len)
{
int stlv_type, stlv_len;
const struct isis_subtlv_spb_mcid *subtlv_spb_mcid;
int i;
- while (len > 0)
+ while (len > 2)
{
stlv_type = *(tptr++);
stlv_len = *(tptr++);
/* first lets see if we know the subTLVs name*/
- printf("\n\t %s subTLV #%u, length: %u",
+ ND_PRINT((ndo, "\n\t %s subTLV #%u, length: %u",
tok2str(isis_mt_port_cap_subtlv_values, "unknown", stlv_type),
stlv_type,
- stlv_len);
+ stlv_len));
/*len -= TLV_TYPE_LEN_OFFSET;*/
len = len -2;
@@ -1354,19 +1419,18 @@ isis_print_mt_port_cap_subtlv (const u_int8_t *tptr, int len)
{
case ISIS_SUBTLV_SPB_MCID:
{
- if (!TTEST2(*(tptr), ISIS_SUBTLV_SPB_MCID_MIN_LEN))
- goto trunctlv;
+ ND_TCHECK2(*(tptr), ISIS_SUBTLV_SPB_MCID_MIN_LEN);
- subtlv_spb_mcid = (struct isis_subtlv_spb_mcid *)tptr;
+ subtlv_spb_mcid = (const struct isis_subtlv_spb_mcid *)tptr;
- printf( "\n\t MCID: ");
- isis_print_mcid (&(subtlv_spb_mcid->mcid));
+ ND_PRINT((ndo, "\n\t MCID: "));
+ isis_print_mcid(ndo, &(subtlv_spb_mcid->mcid));
/*tptr += SPB_MCID_MIN_LEN;
len -= SPB_MCID_MIN_LEN; */
- printf( "\n\t AUX-MCID: ");
- isis_print_mcid (&(subtlv_spb_mcid->aux_mcid));
+ ND_PRINT((ndo, "\n\t AUX-MCID: "));
+ isis_print_mcid(ndo, &(subtlv_spb_mcid->aux_mcid));
/*tptr += SPB_MCID_MIN_LEN;
len -= SPB_MCID_MIN_LEN; */
@@ -1378,22 +1442,21 @@ isis_print_mt_port_cap_subtlv (const u_int8_t *tptr, int len)
case ISIS_SUBTLV_SPB_DIGEST:
{
- if (!TTEST2(*(tptr), ISIS_SUBTLV_SPB_DIGEST_MIN_LEN))
- goto trunctlv;
+ ND_TCHECK2(*(tptr), ISIS_SUBTLV_SPB_DIGEST_MIN_LEN);
- printf ("\n\t RES: %d V: %d A: %d D: %d",
+ ND_PRINT((ndo, "\n\t RES: %d V: %d A: %d D: %d",
(*(tptr) >> 5), (((*tptr)>> 4) & 0x01),
- ((*(tptr) >> 2) & 0x03), ((*tptr) & 0x03));
+ ((*(tptr) >> 2) & 0x03), ((*tptr) & 0x03)));
tptr++;
- printf( "\n\t Digest: ");
-
+ ND_PRINT((ndo, "\n\t Digest: "));
+
for(i=1;i<=8; i++)
{
- printf("%08x ", EXTRACT_32BITS(tptr));
+ ND_PRINT((ndo, "%08x ", EXTRACT_32BITS(tptr)));
if (i%4 == 0 && i != 8)
- printf("\n\t ");
+ ND_PRINT((ndo, "\n\t "));
tptr = tptr + 4;
}
@@ -1404,23 +1467,21 @@ isis_print_mt_port_cap_subtlv (const u_int8_t *tptr, int len)
case ISIS_SUBTLV_SPB_BVID:
{
- if (!TTEST2(*(tptr), stlv_len))
- goto trunctlv;
+ ND_TCHECK2(*(tptr), stlv_len);
- while (len)
+ while (len >= ISIS_SUBTLV_SPB_BVID_MIN_LEN)
{
- if (!TTEST2(*(tptr), ISIS_SUBTLV_SPB_BVID_MIN_LEN))
- goto trunctlv;
+ ND_TCHECK2(*(tptr), ISIS_SUBTLV_SPB_BVID_MIN_LEN);
- printf("\n\t ECT: %08x",
- EXTRACT_32BITS(tptr));
+ ND_PRINT((ndo, "\n\t ECT: %08x",
+ EXTRACT_32BITS(tptr)));
tptr = tptr+4;
- printf(" BVID: %d, U:%01x M:%01x ",
+ ND_PRINT((ndo, " BVID: %d, U:%01x M:%01x ",
(EXTRACT_16BITS (tptr) >> 4) ,
(EXTRACT_16BITS (tptr) >> 3) & 0x01,
- (EXTRACT_16BITS (tptr) >> 2) & 0x01);
+ (EXTRACT_16BITS (tptr) >> 2) & 0x01));
tptr = tptr + 2;
len = len - ISIS_SUBTLV_SPB_BVID_MIN_LEN;
@@ -1428,7 +1489,7 @@ isis_print_mt_port_cap_subtlv (const u_int8_t *tptr, int len)
break;
}
-
+
default:
break;
}
@@ -1436,52 +1497,53 @@ isis_print_mt_port_cap_subtlv (const u_int8_t *tptr, int len)
return 0;
- trunctlv:
- printf("\n\t\t packet exceeded snapshot");
- return(1);
+ trunc:
+ ND_PRINT((ndo, "\n\t\t"));
+ ND_PRINT((ndo, "%s", tstr));
+ return(1);
}
static int
-isis_print_mt_capability_subtlv (const u_int8_t *tptr, int len)
+isis_print_mt_capability_subtlv(netdissect_options *ndo,
+ const uint8_t *tptr, int len)
{
int stlv_type, stlv_len, tmp;
- while (len > 0)
- {
+ while (len > 2)
+ {
stlv_type = *(tptr++);
stlv_len = *(tptr++);
/* first lets see if we know the subTLVs name*/
- printf("\n\t %s subTLV #%u, length: %u",
+ ND_PRINT((ndo, "\n\t %s subTLV #%u, length: %u",
tok2str(isis_mt_capability_subtlv_values, "unknown", stlv_type),
stlv_type,
- stlv_len);
-
+ stlv_len));
+
len = len - 2;
switch (stlv_type)
- {
+ {
case ISIS_SUBTLV_SPB_INSTANCE:
- if (!TTEST2(*(tptr), ISIS_SUBTLV_SPB_INSTANCE_MIN_LEN))
- goto trunctlv;
+ ND_TCHECK2(*tptr, ISIS_SUBTLV_SPB_INSTANCE_MIN_LEN);
- printf("\n\t CIST Root-ID: %08x", EXTRACT_32BITS(tptr));
+ ND_PRINT((ndo, "\n\t CIST Root-ID: %08x", EXTRACT_32BITS(tptr)));
tptr = tptr+4;
- printf(" %08x", EXTRACT_32BITS(tptr));
+ ND_PRINT((ndo, " %08x", EXTRACT_32BITS(tptr)));
tptr = tptr+4;
- printf(", Path Cost: %08x", EXTRACT_32BITS(tptr));
+ ND_PRINT((ndo, ", Path Cost: %08x", EXTRACT_32BITS(tptr)));
tptr = tptr+4;
- printf(", Prio: %d", EXTRACT_16BITS(tptr));
- tptr = tptr + 2;
- printf("\n\t RES: %d",
- EXTRACT_16BITS(tptr) >> 5);
- printf(", V: %d",
- (EXTRACT_16BITS(tptr) >> 4) & 0x0001);
- printf(", SPSource-ID: %d",
- (EXTRACT_32BITS(tptr) & 0x000fffff));
+ ND_PRINT((ndo, ", Prio: %d", EXTRACT_16BITS(tptr)));
+ tptr = tptr + 2;
+ ND_PRINT((ndo, "\n\t RES: %d",
+ EXTRACT_16BITS(tptr) >> 5));
+ ND_PRINT((ndo, ", V: %d",
+ (EXTRACT_16BITS(tptr) >> 4) & 0x0001));
+ ND_PRINT((ndo, ", SPSource-ID: %d",
+ (EXTRACT_32BITS(tptr) & 0x000fffff)));
tptr = tptr+4;
- printf(", No of Trees: %x", *(tptr));
+ ND_PRINT((ndo, ", No of Trees: %x", *(tptr)));
tmp = *(tptr++);
@@ -1489,54 +1551,52 @@ isis_print_mt_capability_subtlv (const u_int8_t *tptr, int len)
while (tmp)
{
- if (!TTEST2(*(tptr), ISIS_SUBTLV_SPB_INSTANCE_VLAN_TUPLE_LEN))
- goto trunctlv;
+ ND_TCHECK2(*tptr, ISIS_SUBTLV_SPB_INSTANCE_VLAN_TUPLE_LEN);
- printf ("\n\t U:%d, M:%d, A:%d, RES:%d",
+ ND_PRINT((ndo, "\n\t U:%d, M:%d, A:%d, RES:%d",
*(tptr) >> 7, (*(tptr) >> 6) & 0x01,
- (*(tptr) >> 5) & 0x01, (*(tptr) & 0x1f));
-
+ (*(tptr) >> 5) & 0x01, (*(tptr) & 0x1f)));
+
tptr++;
-
- printf (", ECT: %08x", EXTRACT_32BITS(tptr));
+
+ ND_PRINT((ndo, ", ECT: %08x", EXTRACT_32BITS(tptr)));
tptr = tptr + 4;
- printf (", BVID: %d, SPVID: %d",
+ ND_PRINT((ndo, ", BVID: %d, SPVID: %d",
(EXTRACT_24BITS(tptr) >> 12) & 0x000fff,
- EXTRACT_24BITS(tptr) & 0x000fff);
+ EXTRACT_24BITS(tptr) & 0x000fff));
tptr = tptr + 3;
len = len - ISIS_SUBTLV_SPB_INSTANCE_VLAN_TUPLE_LEN;
- tmp--;
+ tmp--;
}
break;
case ISIS_SUBTLV_SPBM_SI:
- if (!TTEST2(*(tptr), 6))
- goto trunctlv;
+ ND_TCHECK2(*tptr, 8);
- printf("\n\t BMAC: %08x", EXTRACT_32BITS(tptr));
+ ND_PRINT((ndo, "\n\t BMAC: %08x", EXTRACT_32BITS(tptr)));
tptr = tptr+4;
- printf("%04x", EXTRACT_16BITS(tptr));
+ ND_PRINT((ndo, "%04x", EXTRACT_16BITS(tptr)));
tptr = tptr+2;
- printf (", RES: %d, VID: %d", EXTRACT_16BITS(tptr) >> 12,
- (EXTRACT_16BITS(tptr)) & 0x0fff);
+ ND_PRINT((ndo, ", RES: %d, VID: %d", EXTRACT_16BITS(tptr) >> 12,
+ (EXTRACT_16BITS(tptr)) & 0x0fff));
tptr = tptr+2;
len = len - 8;
stlv_len = stlv_len - 8;
- while (stlv_len)
- {
- printf("\n\t T: %d, R: %d, RES: %d, ISID: %d",
+ while (stlv_len >= 4) {
+ ND_TCHECK2(*tptr, 4);
+ ND_PRINT((ndo, "\n\t T: %d, R: %d, RES: %d, ISID: %d",
(EXTRACT_32BITS(tptr) >> 31),
(EXTRACT_32BITS(tptr) >> 30) & 0x01,
(EXTRACT_32BITS(tptr) >> 24) & 0x03f,
- (EXTRACT_32BITS(tptr)) & 0x0ffffff);
+ (EXTRACT_32BITS(tptr)) & 0x0ffffff));
tptr = tptr + 4;
len = len - 4;
@@ -1551,15 +1611,15 @@ isis_print_mt_capability_subtlv (const u_int8_t *tptr, int len)
}
return 0;
- trunctlv:
- printf("\n\t\t packet exceeded snapshot");
+ trunc:
+ ND_PRINT((ndo, "\n\t\t"));
+ ND_PRINT((ndo, "%s", tstr));
return(1);
}
-
/* shared routine for printing system, node and lsp-ids */
static char *
-isis_print_id(const u_int8_t *cp, int id_len)
+isis_print_id(const uint8_t *cp, int id_len)
{
int i;
static char id[sizeof("xxxx.xxxx.xxxx.yy-zz")];
@@ -1582,29 +1642,31 @@ isis_print_id(const u_int8_t *cp, int id_len)
/* print the 4-byte metric block which is common found in the old-style TLVs */
static int
-isis_print_metric_block (const struct isis_metric_block *isis_metric_block)
+isis_print_metric_block(netdissect_options *ndo,
+ const struct isis_metric_block *isis_metric_block)
{
- printf(", Default Metric: %d, %s",
+ ND_PRINT((ndo, ", Default Metric: %d, %s",
ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block->metric_default),
- ISIS_LSP_TLV_METRIC_IE(isis_metric_block->metric_default) ? "External" : "Internal");
+ ISIS_LSP_TLV_METRIC_IE(isis_metric_block->metric_default) ? "External" : "Internal"));
if (!ISIS_LSP_TLV_METRIC_SUPPORTED(isis_metric_block->metric_delay))
- printf("\n\t\t Delay Metric: %d, %s",
+ ND_PRINT((ndo, "\n\t\t Delay Metric: %d, %s",
ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block->metric_delay),
- ISIS_LSP_TLV_METRIC_IE(isis_metric_block->metric_delay) ? "External" : "Internal");
+ ISIS_LSP_TLV_METRIC_IE(isis_metric_block->metric_delay) ? "External" : "Internal"));
if (!ISIS_LSP_TLV_METRIC_SUPPORTED(isis_metric_block->metric_expense))
- printf("\n\t\t Expense Metric: %d, %s",
+ ND_PRINT((ndo, "\n\t\t Expense Metric: %d, %s",
ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block->metric_expense),
- ISIS_LSP_TLV_METRIC_IE(isis_metric_block->metric_expense) ? "External" : "Internal");
+ ISIS_LSP_TLV_METRIC_IE(isis_metric_block->metric_expense) ? "External" : "Internal"));
if (!ISIS_LSP_TLV_METRIC_SUPPORTED(isis_metric_block->metric_error))
- printf("\n\t\t Error Metric: %d, %s",
+ ND_PRINT((ndo, "\n\t\t Error Metric: %d, %s",
ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block->metric_error),
- ISIS_LSP_TLV_METRIC_IE(isis_metric_block->metric_error) ? "External" : "Internal");
+ ISIS_LSP_TLV_METRIC_IE(isis_metric_block->metric_error) ? "External" : "Internal"));
return(1); /* everything is ok */
}
static int
-isis_print_tlv_ip_reach (const u_int8_t *cp, const char *ident, int length)
+isis_print_tlv_ip_reach(netdissect_options *ndo,
+ const uint8_t *cp, const char *ident, int length)
{
int prefix_len;
const struct isis_tlv_ip_reach *tlv_ip_reach;
@@ -1613,50 +1675,50 @@ isis_print_tlv_ip_reach (const u_int8_t *cp, const char *ident, int length)
while (length > 0) {
if ((size_t)length < sizeof(*tlv_ip_reach)) {
- printf("short IPv4 Reachability (%d vs %lu)",
+ ND_PRINT((ndo, "short IPv4 Reachability (%d vs %lu)",
length,
- (unsigned long)sizeof(*tlv_ip_reach));
+ (unsigned long)sizeof(*tlv_ip_reach)));
return (0);
}
- if (!TTEST(*tlv_ip_reach))
+ if (!ND_TTEST(*tlv_ip_reach))
return (0);
prefix_len = mask2plen(EXTRACT_32BITS(tlv_ip_reach->mask));
if (prefix_len == -1)
- printf("%sIPv4 prefix: %s mask %s",
+ ND_PRINT((ndo, "%sIPv4 prefix: %s mask %s",
ident,
- ipaddr_string((tlv_ip_reach->prefix)),
- ipaddr_string((tlv_ip_reach->mask)));
+ ipaddr_string(ndo, (tlv_ip_reach->prefix)),
+ ipaddr_string(ndo, (tlv_ip_reach->mask))));
else
- printf("%sIPv4 prefix: %15s/%u",
+ ND_PRINT((ndo, "%sIPv4 prefix: %15s/%u",
ident,
- ipaddr_string((tlv_ip_reach->prefix)),
- prefix_len);
+ ipaddr_string(ndo, (tlv_ip_reach->prefix)),
+ prefix_len));
- printf(", Distribution: %s, Metric: %u, %s",
+ ND_PRINT((ndo, ", Distribution: %s, Metric: %u, %s",
ISIS_LSP_TLV_METRIC_UPDOWN(tlv_ip_reach->isis_metric_block.metric_default) ? "down" : "up",
ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach->isis_metric_block.metric_default),
- ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach->isis_metric_block.metric_default) ? "External" : "Internal");
+ ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach->isis_metric_block.metric_default) ? "External" : "Internal"));
if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach->isis_metric_block.metric_delay))
- printf("%s Delay Metric: %u, %s",
+ ND_PRINT((ndo, "%s Delay Metric: %u, %s",
ident,
ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach->isis_metric_block.metric_delay),
- ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach->isis_metric_block.metric_delay) ? "External" : "Internal");
-
+ ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach->isis_metric_block.metric_delay) ? "External" : "Internal"));
+
if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach->isis_metric_block.metric_expense))
- printf("%s Expense Metric: %u, %s",
+ ND_PRINT((ndo, "%s Expense Metric: %u, %s",
ident,
ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach->isis_metric_block.metric_expense),
- ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach->isis_metric_block.metric_expense) ? "External" : "Internal");
-
+ ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach->isis_metric_block.metric_expense) ? "External" : "Internal"));
+
if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach->isis_metric_block.metric_error))
- printf("%s Error Metric: %u, %s",
+ ND_PRINT((ndo, "%s Error Metric: %u, %s",
ident,
ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach->isis_metric_block.metric_error),
- ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach->isis_metric_block.metric_error) ? "External" : "Internal");
+ ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach->isis_metric_block.metric_error) ? "External" : "Internal"));
length -= sizeof(struct isis_tlv_ip_reach);
tlv_ip_reach++;
@@ -1670,50 +1732,47 @@ isis_print_tlv_ip_reach (const u_int8_t *cp, const char *ident, int length)
*/
static int
-isis_print_ip_reach_subtlv (const u_int8_t *tptr,int subt,int subl,const char *ident) {
-
- /* first lets see if we know the subTLVs name*/
- printf("%s%s subTLV #%u, length: %u",
- ident,
- tok2str(isis_ext_ip_reach_subtlv_values,
- "unknown",
- subt),
- subt,
- subl);
+isis_print_ip_reach_subtlv(netdissect_options *ndo,
+ const uint8_t *tptr, int subt, int subl,
+ const char *ident)
+{
+ /* first lets see if we know the subTLVs name*/
+ ND_PRINT((ndo, "%s%s subTLV #%u, length: %u",
+ ident, tok2str(isis_ext_ip_reach_subtlv_values, "unknown", subt),
+ subt, subl));
- if (!TTEST2(*tptr,subl))
- goto trunctlv;
+ ND_TCHECK2(*tptr,subl);
switch(subt) {
case ISIS_SUBTLV_EXTD_IP_REACH_MGMT_PREFIX_COLOR: /* fall through */
case ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG32:
while (subl >= 4) {
- printf(", 0x%08x (=%u)",
+ ND_PRINT((ndo, ", 0x%08x (=%u)",
EXTRACT_32BITS(tptr),
- EXTRACT_32BITS(tptr));
+ EXTRACT_32BITS(tptr)));
tptr+=4;
subl-=4;
}
break;
case ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG64:
while (subl >= 8) {
- printf(", 0x%08x%08x",
+ ND_PRINT((ndo, ", 0x%08x%08x",
EXTRACT_32BITS(tptr),
- EXTRACT_32BITS(tptr+4));
+ EXTRACT_32BITS(tptr+4)));
tptr+=8;
subl-=8;
}
break;
default:
- if(!print_unknown_data(tptr,"\n\t\t ",
- subl))
+ if (!print_unknown_data(ndo, tptr, "\n\t\t ", subl))
return(0);
break;
}
return(1);
-
-trunctlv:
- printf("%spacket exceeded snapshot",ident);
+
+trunc:
+ ND_PRINT((ndo, "%s", ident));
+ ND_PRINT((ndo, "%s", tstr));
return(0);
}
@@ -1723,121 +1782,120 @@ trunctlv:
*/
static int
-isis_print_is_reach_subtlv (const u_int8_t *tptr,u_int subt,u_int subl,const char *ident) {
-
+isis_print_is_reach_subtlv(netdissect_options *ndo,
+ const uint8_t *tptr, u_int subt, u_int subl,
+ const char *ident)
+{
u_int te_class,priority_level,gmpls_switch_cap;
union { /* int to float conversion buffer for several subTLVs */
- float f;
- u_int32_t i;
+ float f;
+ uint32_t i;
} bw;
/* first lets see if we know the subTLVs name*/
- printf("%s%s subTLV #%u, length: %u",
- ident,
- tok2str(isis_ext_is_reach_subtlv_values,
- "unknown",
- subt),
- subt,
- subl);
+ ND_PRINT((ndo, "%s%s subTLV #%u, length: %u",
+ ident, tok2str(isis_ext_is_reach_subtlv_values, "unknown", subt),
+ subt, subl));
- if (!TTEST2(*tptr,subl))
- goto trunctlv;
+ ND_TCHECK2(*tptr, subl);
switch(subt) {
- case ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP:
+ case ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP:
case ISIS_SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID:
case ISIS_SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID:
if (subl >= 4) {
- printf(", 0x%08x", EXTRACT_32BITS(tptr));
+ ND_PRINT((ndo, ", 0x%08x", EXTRACT_32BITS(tptr)));
if (subl == 8) /* rfc4205 */
- printf(", 0x%08x", EXTRACT_32BITS(tptr+4));
+ ND_PRINT((ndo, ", 0x%08x", EXTRACT_32BITS(tptr+4)));
}
break;
case ISIS_SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR:
case ISIS_SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR:
if (subl >= sizeof(struct in_addr))
- printf(", %s", ipaddr_string(tptr));
+ ND_PRINT((ndo, ", %s", ipaddr_string(ndo, tptr)));
break;
case ISIS_SUBTLV_EXT_IS_REACH_MAX_LINK_BW :
- case ISIS_SUBTLV_EXT_IS_REACH_RESERVABLE_BW:
+ case ISIS_SUBTLV_EXT_IS_REACH_RESERVABLE_BW:
if (subl >= 4) {
bw.i = EXTRACT_32BITS(tptr);
- printf(", %.3f Mbps", bw.f*8/1000000 );
+ ND_PRINT((ndo, ", %.3f Mbps", bw.f * 8 / 1000000));
}
break;
case ISIS_SUBTLV_EXT_IS_REACH_UNRESERVED_BW :
if (subl >= 32) {
for (te_class = 0; te_class < 8; te_class++) {
bw.i = EXTRACT_32BITS(tptr);
- printf("%s TE-Class %u: %.3f Mbps",
+ ND_PRINT((ndo, "%s TE-Class %u: %.3f Mbps",
ident,
te_class,
- bw.f*8/1000000 );
+ bw.f * 8 / 1000000));
tptr+=4;
}
}
break;
case ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS: /* fall through */
case ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS_OLD:
- printf("%sBandwidth Constraints Model ID: %s (%u)",
+ ND_PRINT((ndo, "%sBandwidth Constraints Model ID: %s (%u)",
ident,
tok2str(diffserv_te_bc_values, "unknown", *tptr),
- *tptr);
+ *tptr));
tptr++;
/* decode BCs until the subTLV ends */
for (te_class = 0; te_class < (subl-1)/4; te_class++) {
+ ND_TCHECK2(*tptr, 4);
bw.i = EXTRACT_32BITS(tptr);
- printf("%s Bandwidth constraint CT%u: %.3f Mbps",
+ ND_PRINT((ndo, "%s Bandwidth constraint CT%u: %.3f Mbps",
ident,
te_class,
- bw.f*8/1000000 );
+ bw.f * 8 / 1000000));
tptr+=4;
}
break;
case ISIS_SUBTLV_EXT_IS_REACH_TE_METRIC:
if (subl >= 3)
- printf(", %u", EXTRACT_24BITS(tptr));
+ ND_PRINT((ndo, ", %u", EXTRACT_24BITS(tptr)));
break;
case ISIS_SUBTLV_EXT_IS_REACH_LINK_ATTRIBUTE:
if (subl == 2) {
- printf(", [ %s ] (0x%04x)",
+ ND_PRINT((ndo, ", [ %s ] (0x%04x)",
bittok2str(isis_subtlv_link_attribute_values,
"Unknown",
EXTRACT_16BITS(tptr)),
- EXTRACT_16BITS(tptr));
+ EXTRACT_16BITS(tptr)));
}
break;
case ISIS_SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE:
if (subl >= 2) {
- printf(", %s, Priority %u",
+ ND_PRINT((ndo, ", %s, Priority %u",
bittok2str(gmpls_link_prot_values, "none", *tptr),
- *(tptr+1));
+ *(tptr+1)));
}
break;
case ISIS_SUBTLV_SPB_METRIC:
if (subl >= 6) {
- printf (", LM: %u", EXTRACT_24BITS(tptr));
+ ND_PRINT((ndo, ", LM: %u", EXTRACT_24BITS(tptr)));
tptr=tptr+3;
- printf (", P: %u", *(tptr));
- printf (", P-ID: %u", EXTRACT_16BITS(++tptr));
+ ND_PRINT((ndo, ", P: %u", *(tptr)));
+ tptr++;
+ ND_PRINT((ndo, ", P-ID: %u", EXTRACT_16BITS(tptr)));
}
break;
case ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR:
if (subl >= 36) {
gmpls_switch_cap = *tptr;
- printf("%s Interface Switching Capability:%s",
+ ND_PRINT((ndo, "%s Interface Switching Capability:%s",
ident,
- tok2str(gmpls_switch_cap_values, "Unknown", gmpls_switch_cap));
- printf(", LSP Encoding: %s",
- tok2str(gmpls_encoding_values, "Unknown", *(tptr+1)));
+ tok2str(gmpls_switch_cap_values, "Unknown", gmpls_switch_cap)));
+ ND_PRINT((ndo, ", LSP Encoding: %s",
+ tok2str(gmpls_encoding_values, "Unknown", *(tptr + 1))));
tptr+=4;
- printf("%s Max LSP Bandwidth:",ident);
+ ND_PRINT((ndo, "%s Max LSP Bandwidth:", ident));
for (priority_level = 0; priority_level < 8; priority_level++) {
bw.i = EXTRACT_32BITS(tptr);
- printf("%s priority level %d: %.3f Mbps",
+ ND_PRINT((ndo, "%s priority level %d: %.3f Mbps",
ident,
priority_level,
- bw.f*8/1000000 );
+ bw.f * 8 / 1000000));
tptr+=4;
}
subl-=36;
@@ -1846,81 +1904,80 @@ isis_print_is_reach_subtlv (const u_int8_t *tptr,u_int subt,u_int subl,const cha
case GMPLS_PSC2:
case GMPLS_PSC3:
case GMPLS_PSC4:
+ ND_TCHECK2(*tptr, 6);
bw.i = EXTRACT_32BITS(tptr);
- printf("%s Min LSP Bandwidth: %.3f Mbps", ident, bw.f*8/1000000);
- printf("%s Interface MTU: %u", ident, EXTRACT_16BITS(tptr+4));
+ ND_PRINT((ndo, "%s Min LSP Bandwidth: %.3f Mbps", ident, bw.f * 8 / 1000000));
+ ND_PRINT((ndo, "%s Interface MTU: %u", ident, EXTRACT_16BITS(tptr + 4)));
break;
case GMPLS_TSC:
+ ND_TCHECK2(*tptr, 8);
bw.i = EXTRACT_32BITS(tptr);
- printf("%s Min LSP Bandwidth: %.3f Mbps", ident, bw.f*8/1000000);
- printf("%s Indication %s", ident,
- tok2str(gmpls_switch_cap_tsc_indication_values, "Unknown (%u)", *(tptr+4)));
+ ND_PRINT((ndo, "%s Min LSP Bandwidth: %.3f Mbps", ident, bw.f * 8 / 1000000));
+ ND_PRINT((ndo, "%s Indication %s", ident,
+ tok2str(gmpls_switch_cap_tsc_indication_values, "Unknown (%u)", *(tptr + 4))));
break;
default:
/* there is some optional stuff left to decode but this is as of yet
not specified so just lets hexdump what is left */
if(subl>0){
- if(!print_unknown_data(tptr,"\n\t\t ",
- subl))
+ if (!print_unknown_data(ndo, tptr, "\n\t\t ", subl))
return(0);
}
}
}
break;
default:
- if(!print_unknown_data(tptr,"\n\t\t ",
- subl))
+ if (!print_unknown_data(ndo, tptr, "\n\t\t ", subl))
return(0);
break;
}
return(1);
-trunctlv:
- printf("%spacket exceeded snapshot",ident);
+trunc:
return(0);
}
-
/*
* this is the common IS-REACH decoder it is called
* from various EXTD-IS REACH style TLVs (22,24,222)
*/
static int
-isis_print_ext_is_reach (const u_int8_t *tptr,const char *ident, int tlv_type) {
-
+isis_print_ext_is_reach(netdissect_options *ndo,
+ const uint8_t *tptr, const char *ident, int tlv_type)
+{
char ident_buffer[20];
int subtlv_type,subtlv_len,subtlv_sum_len;
int proc_bytes = 0; /* how many bytes did we process ? */
-
- if (!TTEST2(*tptr, NODE_ID_LEN))
+
+ if (!ND_TTEST2(*tptr, NODE_ID_LEN))
return(0);
- printf("%sIS Neighbor: %s", ident, isis_print_id(tptr, NODE_ID_LEN));
+ ND_PRINT((ndo, "%sIS Neighbor: %s", ident, isis_print_id(tptr, NODE_ID_LEN)));
tptr+=(NODE_ID_LEN);
if (tlv_type != ISIS_TLV_IS_ALIAS_ID) { /* the Alias TLV Metric field is implicit 0 */
- if (!TTEST2(*tptr, 3)) /* and is therefore skipped */
+ if (!ND_TTEST2(*tptr, 3)) /* and is therefore skipped */
return(0);
- printf(", Metric: %d",EXTRACT_24BITS(tptr));
+ ND_PRINT((ndo, ", Metric: %d", EXTRACT_24BITS(tptr)));
tptr+=3;
}
-
- if (!TTEST2(*tptr, 1))
+
+ if (!ND_TTEST2(*tptr, 1))
return(0);
subtlv_sum_len=*(tptr++); /* read out subTLV length */
proc_bytes=NODE_ID_LEN+3+1;
- printf(", %ssub-TLVs present",subtlv_sum_len ? "" : "no ");
+ ND_PRINT((ndo, ", %ssub-TLVs present",subtlv_sum_len ? "" : "no "));
if (subtlv_sum_len) {
- printf(" (%u)",subtlv_sum_len);
+ ND_PRINT((ndo, " (%u)", subtlv_sum_len));
while (subtlv_sum_len>0) {
- if (!TTEST2(*tptr,2))
+ if (!ND_TTEST2(*tptr,2))
return(0);
subtlv_type=*(tptr++);
subtlv_len=*(tptr++);
- /* prepend the ident string */
+ /* prepend the indent string */
snprintf(ident_buffer, sizeof(ident_buffer), "%s ",ident);
- if(!isis_print_is_reach_subtlv(tptr,subtlv_type,subtlv_len,ident_buffer))
+ if (!isis_print_is_reach_subtlv(ndo, tptr, subtlv_type, subtlv_len, ident_buffer))
return(0);
tptr+=subtlv_len;
subtlv_sum_len-=(subtlv_len+2);
@@ -1936,20 +1993,21 @@ isis_print_ext_is_reach (const u_int8_t *tptr,const char *ident, int tlv_type) {
*/
static int
-isis_print_mtid (const u_int8_t *tptr,const char *ident) {
-
- if (!TTEST2(*tptr, 2))
+isis_print_mtid(netdissect_options *ndo,
+ const uint8_t *tptr, const char *ident)
+{
+ if (!ND_TTEST2(*tptr, 2))
return(0);
- printf("%s%s",
+ ND_PRINT((ndo, "%s%s",
ident,
tok2str(isis_mt_values,
"Reserved for IETF Consensus",
- ISIS_MASK_MTID(EXTRACT_16BITS(tptr))));
+ ISIS_MASK_MTID(EXTRACT_16BITS(tptr)))));
- printf(" Topology (0x%03x), Flags: [%s]",
+ ND_PRINT((ndo, " Topology (0x%03x), Flags: [%s]",
ISIS_MASK_MTID(EXTRACT_16BITS(tptr)),
- bittok2str(isis_mt_flag_values, "none",ISIS_MASK_MTFLAGS(EXTRACT_16BITS(tptr))));
+ bittok2str(isis_mt_flag_values, "none",ISIS_MASK_MTFLAGS(EXTRACT_16BITS(tptr)))));
return(2);
}
@@ -1962,54 +2020,49 @@ isis_print_mtid (const u_int8_t *tptr,const char *ident) {
*/
static int
-isis_print_extd_ip_reach (const u_int8_t *tptr, const char *ident, u_int16_t afi) {
-
+isis_print_extd_ip_reach(netdissect_options *ndo,
+ const uint8_t *tptr, const char *ident, uint16_t afi)
+{
char ident_buffer[20];
-#ifdef INET6
- u_int8_t prefix[sizeof(struct in6_addr)]; /* shared copy buffer for IPv4 and IPv6 prefixes */
-#else
- u_int8_t prefix[sizeof(struct in_addr)]; /* shared copy buffer for IPv4 prefixes */
-#endif
+ uint8_t prefix[sizeof(struct in6_addr)]; /* shared copy buffer for IPv4 and IPv6 prefixes */
u_int metric, status_byte, bit_length, byte_length, sublen, processed, subtlvtype, subtlvlen;
- if (!TTEST2(*tptr, 4))
+ if (!ND_TTEST2(*tptr, 4))
return (0);
metric = EXTRACT_32BITS(tptr);
processed=4;
tptr+=4;
-
+
if (afi == AF_INET) {
- if (!TTEST2(*tptr, 1)) /* fetch status byte */
+ if (!ND_TTEST2(*tptr, 1)) /* fetch status byte */
return (0);
status_byte=*(tptr++);
bit_length = status_byte&0x3f;
if (bit_length > 32) {
- printf("%sIPv4 prefix: bad bit length %u",
+ ND_PRINT((ndo, "%sIPv4 prefix: bad bit length %u",
ident,
- bit_length);
+ bit_length));
return (0);
}
processed++;
-#ifdef INET6
} else if (afi == AF_INET6) {
- if (!TTEST2(*tptr, 1)) /* fetch status & prefix_len byte */
+ if (!ND_TTEST2(*tptr, 1)) /* fetch status & prefix_len byte */
return (0);
status_byte=*(tptr++);
bit_length=*(tptr++);
if (bit_length > 128) {
- printf("%sIPv6 prefix: bad bit length %u",
+ ND_PRINT((ndo, "%sIPv6 prefix: bad bit length %u",
ident,
- bit_length);
+ bit_length));
return (0);
}
processed+=2;
-#endif
} else
return (0); /* somebody is fooling us */
byte_length = (bit_length + 7) / 8; /* prefix has variable length encoding */
-
- if (!TTEST2(*tptr, byte_length))
+
+ if (!ND_TTEST2(*tptr, byte_length))
return (0);
memset(prefix, 0, sizeof prefix); /* clear the copy buffer */
memcpy(prefix,tptr,byte_length); /* copy as much as is stored in the TLV */
@@ -2017,54 +2070,48 @@ isis_print_extd_ip_reach (const u_int8_t *tptr, const char *ident, u_int16_t afi
processed+=byte_length;
if (afi == AF_INET)
- printf("%sIPv4 prefix: %15s/%u",
+ ND_PRINT((ndo, "%sIPv4 prefix: %15s/%u",
ident,
- ipaddr_string(prefix),
- bit_length);
-#ifdef INET6
- if (afi == AF_INET6)
- printf("%sIPv6 prefix: %s/%u",
+ ipaddr_string(ndo, prefix),
+ bit_length));
+ else if (afi == AF_INET6)
+ ND_PRINT((ndo, "%sIPv6 prefix: %s/%u",
ident,
- ip6addr_string(prefix),
- bit_length);
-#endif
-
- printf(", Distribution: %s, Metric: %u",
+ ip6addr_string(ndo, prefix),
+ bit_length));
+
+ ND_PRINT((ndo, ", Distribution: %s, Metric: %u",
ISIS_MASK_TLV_EXTD_IP_UPDOWN(status_byte) ? "down" : "up",
- metric);
+ metric));
if (afi == AF_INET && ISIS_MASK_TLV_EXTD_IP_SUBTLV(status_byte))
- printf(", sub-TLVs present");
-#ifdef INET6
- if (afi == AF_INET6)
- printf(", %s%s",
+ ND_PRINT((ndo, ", sub-TLVs present"));
+ else if (afi == AF_INET6)
+ ND_PRINT((ndo, ", %s%s",
ISIS_MASK_TLV_EXTD_IP6_IE(status_byte) ? "External" : "Internal",
- ISIS_MASK_TLV_EXTD_IP6_SUBTLV(status_byte) ? ", sub-TLVs present" : "");
-#endif
-
+ ISIS_MASK_TLV_EXTD_IP6_SUBTLV(status_byte) ? ", sub-TLVs present" : ""));
+
if ((afi == AF_INET && ISIS_MASK_TLV_EXTD_IP_SUBTLV(status_byte))
-#ifdef INET6
|| (afi == AF_INET6 && ISIS_MASK_TLV_EXTD_IP6_SUBTLV(status_byte))
-#endif
) {
/* assume that one prefix can hold more
than one subTLV - therefore the first byte must reflect
the aggregate bytecount of the subTLVs for this prefix
*/
- if (!TTEST2(*tptr, 1))
+ if (!ND_TTEST2(*tptr, 1))
return (0);
sublen=*(tptr++);
processed+=sublen+1;
- printf(" (%u)",sublen); /* print out subTLV length */
-
+ ND_PRINT((ndo, " (%u)", sublen)); /* print out subTLV length */
+
while (sublen>0) {
- if (!TTEST2(*tptr,2))
+ if (!ND_TTEST2(*tptr,2))
return (0);
subtlvtype=*(tptr++);
subtlvlen=*(tptr++);
- /* prepend the ident string */
+ /* prepend the indent string */
snprintf(ident_buffer, sizeof(ident_buffer), "%s ",ident);
- if(!isis_print_ip_reach_subtlv(tptr,subtlvtype,subtlvlen,ident_buffer))
+ if (!isis_print_ip_reach_subtlv(ndo, tptr, subtlvtype, subtlvlen, ident_buffer))
return(0);
tptr+=subtlvlen;
sublen-=(subtlvlen+2);
@@ -2074,17 +2121,33 @@ isis_print_extd_ip_reach (const u_int8_t *tptr, const char *ident, u_int16_t afi
}
/*
+ * Clear checksum and lifetime prior to signature verification.
+ */
+static void
+isis_clear_checksum_lifetime(void *header)
+{
+ struct isis_lsp_header *header_lsp = (struct isis_lsp_header *) header;
+
+ header_lsp->checksum[0] = 0;
+ header_lsp->checksum[1] = 0;
+ header_lsp->remaining_lifetime[0] = 0;
+ header_lsp->remaining_lifetime[1] = 0;
+}
+
+/*
* isis_print
* Decode IS-IS packets. Return 0 on error.
*/
-static int isis_print (const u_int8_t *p, u_int length)
+static int
+isis_print(netdissect_options *ndo,
+ const uint8_t *p, u_int length)
{
const struct isis_common_header *isis_header;
const struct isis_iih_lan_header *header_iih_lan;
const struct isis_iih_ptp_header *header_iih_ptp;
- struct isis_lsp_header *header_lsp;
+ const struct isis_lsp_header *header_lsp;
const struct isis_csnp_header *header_csnp;
const struct isis_psnp_header *header_psnp;
@@ -2093,9 +2156,9 @@ static int isis_print (const u_int8_t *p, u_int length)
const struct isis_tlv_is_reach *tlv_is_reach;
const struct isis_tlv_es_reach *tlv_es_reach;
- u_int8_t pdu_type, max_area, id_length, tlv_type, tlv_len, tmp, alen, lan_alen, prefix_len;
- u_int8_t ext_is_len, ext_ip_len, mt_len;
- const u_int8_t *optr, *pptr, *tptr;
+ uint8_t pdu_type, max_area, id_length, tlv_type, tlv_len, tmp, alen, lan_alen, prefix_len;
+ uint8_t ext_is_len, ext_ip_len, mt_len;
+ const uint8_t *optr, *pptr, *tptr;
u_short packet_len,pdu_len, key_id;
u_int i,vendor_id;
int sigcheck;
@@ -2105,34 +2168,34 @@ static int isis_print (const u_int8_t *p, u_int length)
need it for parsing the checksum TLV and authentication
TLV verification */
isis_header = (const struct isis_common_header *)p;
- TCHECK(*isis_header);
+ ND_TCHECK(*isis_header);
pptr = p+(ISIS_COMMON_HEADER_SIZE);
header_iih_lan = (const struct isis_iih_lan_header *)pptr;
header_iih_ptp = (const struct isis_iih_ptp_header *)pptr;
- header_lsp = (struct isis_lsp_header *)pptr;
+ header_lsp = (const struct isis_lsp_header *)pptr;
header_csnp = (const struct isis_csnp_header *)pptr;
header_psnp = (const struct isis_psnp_header *)pptr;
- if (!eflag)
- printf("IS-IS");
+ if (!ndo->ndo_eflag)
+ ND_PRINT((ndo, "IS-IS"));
/*
* Sanity checking of the header.
*/
if (isis_header->version != ISIS_VERSION) {
- printf("version %d packet not supported", isis_header->version);
+ ND_PRINT((ndo, "version %d packet not supported", isis_header->version));
return (0);
}
if ((isis_header->id_length != SYSTEM_ID_LEN) && (isis_header->id_length != 0)) {
- printf("system ID length of %d is not supported",
- isis_header->id_length);
+ ND_PRINT((ndo, "system ID length of %d is not supported",
+ isis_header->id_length));
return (0);
}
if (isis_header->pdu_version != ISIS_VERSION) {
- printf("version %d packet not supported", isis_header->pdu_version);
+ ND_PRINT((ndo, "version %d packet not supported", isis_header->pdu_version));
return (0);
}
@@ -2142,7 +2205,7 @@ static int isis_print (const u_int8_t *p, u_int length)
max_area = 3; /* silly shit */
break;
case 255:
- printf("bad packet -- 255 areas");
+ ND_PRINT((ndo, "bad packet -- 255 areas"));
return (0);
default:
break;
@@ -2170,58 +2233,63 @@ static int isis_print (const u_int8_t *p, u_int length)
}
/* toss any non 6-byte sys-ID len PDUs */
- if (id_length != 6 ) {
- printf("bad packet -- illegal sys-ID length (%u)", id_length);
+ if (id_length != 6 ) {
+ ND_PRINT((ndo, "bad packet -- illegal sys-ID length (%u)", id_length));
return (0);
}
pdu_type=isis_header->pdu_type;
/* in non-verbose mode print the basic PDU Type plus PDU specific brief information*/
- if (vflag < 1) {
- printf("%s%s",
- eflag ? "" : ", ",
- tok2str(isis_pdu_values,"unknown PDU-Type %u",pdu_type));
+ if (ndo->ndo_vflag < 1) {
+ ND_PRINT((ndo, "%s%s",
+ ndo->ndo_eflag ? "" : ", ",
+ tok2str(isis_pdu_values, "unknown PDU-Type %u", pdu_type)));
switch (pdu_type) {
case ISIS_PDU_L1_LAN_IIH:
case ISIS_PDU_L2_LAN_IIH:
- printf(", src-id %s",
- isis_print_id(header_iih_lan->source_id,SYSTEM_ID_LEN));
- printf(", lan-id %s, prio %u",
+ ND_TCHECK(*header_iih_lan);
+ ND_PRINT((ndo, ", src-id %s",
+ isis_print_id(header_iih_lan->source_id, SYSTEM_ID_LEN)));
+ ND_PRINT((ndo, ", lan-id %s, prio %u",
isis_print_id(header_iih_lan->lan_id,NODE_ID_LEN),
- header_iih_lan->priority);
+ header_iih_lan->priority));
break;
case ISIS_PDU_PTP_IIH:
- printf(", src-id %s", isis_print_id(header_iih_ptp->source_id,SYSTEM_ID_LEN));
+ ND_TCHECK(*header_iih_ptp);
+ ND_PRINT((ndo, ", src-id %s", isis_print_id(header_iih_ptp->source_id, SYSTEM_ID_LEN)));
break;
case ISIS_PDU_L1_LSP:
case ISIS_PDU_L2_LSP:
- printf(", lsp-id %s, seq 0x%08x, lifetime %5us",
+ ND_TCHECK(*header_lsp);
+ ND_PRINT((ndo, ", lsp-id %s, seq 0x%08x, lifetime %5us",
isis_print_id(header_lsp->lsp_id, LSP_ID_LEN),
EXTRACT_32BITS(header_lsp->sequence_number),
- EXTRACT_16BITS(header_lsp->remaining_lifetime));
+ EXTRACT_16BITS(header_lsp->remaining_lifetime)));
break;
case ISIS_PDU_L1_CSNP:
case ISIS_PDU_L2_CSNP:
- printf(", src-id %s", isis_print_id(header_csnp->source_id,NODE_ID_LEN));
+ ND_TCHECK(*header_csnp);
+ ND_PRINT((ndo, ", src-id %s", isis_print_id(header_csnp->source_id, NODE_ID_LEN)));
break;
case ISIS_PDU_L1_PSNP:
case ISIS_PDU_L2_PSNP:
- printf(", src-id %s", isis_print_id(header_psnp->source_id,NODE_ID_LEN));
+ ND_TCHECK(*header_psnp);
+ ND_PRINT((ndo, ", src-id %s", isis_print_id(header_psnp->source_id, NODE_ID_LEN)));
break;
}
- printf(", length %u", length);
+ ND_PRINT((ndo, ", length %u", length));
return(1);
}
/* ok they seem to want to know everything - lets fully decode it */
- printf("%slength %u", eflag ? "" : ", ",length);
+ ND_PRINT((ndo, "%slength %u", ndo->ndo_eflag ? "" : ", ", length));
- printf("\n\t%s, hlen: %u, v: %u, pdu-v: %u, sys-id-len: %u (%u), max-area: %u (%u)",
+ ND_PRINT((ndo, "\n\t%s, hlen: %u, v: %u, pdu-v: %u, sys-id-len: %u (%u), max-area: %u (%u)",
tok2str(isis_pdu_values,
"unknown, type %u",
pdu_type),
@@ -2231,10 +2299,10 @@ static int isis_print (const u_int8_t *p, u_int length)
id_length,
isis_header->id_length,
max_area,
- isis_header->max_area);
+ isis_header->max_area));
- if (vflag > 1) {
- if(!print_unknown_data(optr,"\n\t",8)) /* provide the _o_riginal pointer */
+ if (ndo->ndo_vflag > 1) {
+ if (!print_unknown_data(ndo, optr, "\n\t", 8)) /* provide the _o_riginal pointer */
return(0); /* for optionally debugging the common header */
}
@@ -2243,34 +2311,34 @@ static int isis_print (const u_int8_t *p, u_int length)
case ISIS_PDU_L1_LAN_IIH:
case ISIS_PDU_L2_LAN_IIH:
if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_LAN_HEADER_SIZE)) {
- printf(", bogus fixed header length %u should be %lu",
- isis_header->fixed_len, (unsigned long)ISIS_IIH_LAN_HEADER_SIZE);
+ ND_PRINT((ndo, ", bogus fixed header length %u should be %lu",
+ isis_header->fixed_len, (unsigned long)ISIS_IIH_LAN_HEADER_SIZE));
return (0);
}
+ ND_TCHECK(*header_iih_lan);
pdu_len=EXTRACT_16BITS(header_iih_lan->pdu_len);
if (packet_len>pdu_len) {
packet_len=pdu_len; /* do TLV decoding as long as it makes sense */
length=pdu_len;
}
- TCHECK(*header_iih_lan);
- printf("\n\t source-id: %s, holding time: %us, Flags: [%s]",
+ ND_PRINT((ndo, "\n\t source-id: %s, holding time: %us, Flags: [%s]",
isis_print_id(header_iih_lan->source_id,SYSTEM_ID_LEN),
EXTRACT_16BITS(header_iih_lan->holding_time),
tok2str(isis_iih_circuit_type_values,
"unknown circuit type 0x%02x",
- header_iih_lan->circuit_type));
+ header_iih_lan->circuit_type)));
- printf("\n\t lan-id: %s, Priority: %u, PDU length: %u",
+ ND_PRINT((ndo, "\n\t lan-id: %s, Priority: %u, PDU length: %u",
isis_print_id(header_iih_lan->lan_id, NODE_ID_LEN),
(header_iih_lan->priority) & ISIS_LAN_PRIORITY_MASK,
- pdu_len);
+ pdu_len));
- if (vflag > 1) {
- if(!print_unknown_data(pptr,"\n\t ",ISIS_IIH_LAN_HEADER_SIZE))
- return(0);
- }
+ if (ndo->ndo_vflag > 1) {
+ if (!print_unknown_data(ndo, pptr, "\n\t ", ISIS_IIH_LAN_HEADER_SIZE))
+ return(0);
+ }
packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_LAN_HEADER_SIZE);
pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_LAN_HEADER_SIZE);
@@ -2278,33 +2346,33 @@ static int isis_print (const u_int8_t *p, u_int length)
case ISIS_PDU_PTP_IIH:
if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_PTP_HEADER_SIZE)) {
- printf(", bogus fixed header length %u should be %lu",
- isis_header->fixed_len, (unsigned long)ISIS_IIH_PTP_HEADER_SIZE);
+ ND_PRINT((ndo, ", bogus fixed header length %u should be %lu",
+ isis_header->fixed_len, (unsigned long)ISIS_IIH_PTP_HEADER_SIZE));
return (0);
}
+ ND_TCHECK(*header_iih_ptp);
pdu_len=EXTRACT_16BITS(header_iih_ptp->pdu_len);
if (packet_len>pdu_len) {
packet_len=pdu_len; /* do TLV decoding as long as it makes sense */
length=pdu_len;
}
- TCHECK(*header_iih_ptp);
- printf("\n\t source-id: %s, holding time: %us, Flags: [%s]",
+ ND_PRINT((ndo, "\n\t source-id: %s, holding time: %us, Flags: [%s]",
isis_print_id(header_iih_ptp->source_id,SYSTEM_ID_LEN),
EXTRACT_16BITS(header_iih_ptp->holding_time),
tok2str(isis_iih_circuit_type_values,
"unknown circuit type 0x%02x",
- header_iih_ptp->circuit_type));
+ header_iih_ptp->circuit_type)));
- printf("\n\t circuit-id: 0x%02x, PDU length: %u",
+ ND_PRINT((ndo, "\n\t circuit-id: 0x%02x, PDU length: %u",
header_iih_ptp->circuit_id,
- pdu_len);
+ pdu_len));
- if (vflag > 1) {
- if(!print_unknown_data(pptr,"\n\t ",ISIS_IIH_PTP_HEADER_SIZE))
- return(0);
- }
+ if (ndo->ndo_vflag > 1) {
+ if (!print_unknown_data(ndo, pptr, "\n\t ", ISIS_IIH_PTP_HEADER_SIZE))
+ return(0);
+ }
packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_PTP_HEADER_SIZE);
pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_PTP_HEADER_SIZE);
@@ -2313,55 +2381,48 @@ static int isis_print (const u_int8_t *p, u_int length)
case ISIS_PDU_L1_LSP:
case ISIS_PDU_L2_LSP:
if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_LSP_HEADER_SIZE)) {
- printf(", bogus fixed header length %u should be %lu",
- isis_header->fixed_len, (unsigned long)ISIS_LSP_HEADER_SIZE);
+ ND_PRINT((ndo, ", bogus fixed header length %u should be %lu",
+ isis_header->fixed_len, (unsigned long)ISIS_LSP_HEADER_SIZE));
return (0);
}
+ ND_TCHECK(*header_lsp);
pdu_len=EXTRACT_16BITS(header_lsp->pdu_len);
if (packet_len>pdu_len) {
packet_len=pdu_len; /* do TLV decoding as long as it makes sense */
length=pdu_len;
}
- TCHECK(*header_lsp);
- printf("\n\t lsp-id: %s, seq: 0x%08x, lifetime: %5us\n\t chksum: 0x%04x",
+ ND_PRINT((ndo, "\n\t lsp-id: %s, seq: 0x%08x, lifetime: %5us\n\t chksum: 0x%04x",
isis_print_id(header_lsp->lsp_id, LSP_ID_LEN),
EXTRACT_32BITS(header_lsp->sequence_number),
EXTRACT_16BITS(header_lsp->remaining_lifetime),
- EXTRACT_16BITS(header_lsp->checksum));
+ EXTRACT_16BITS(header_lsp->checksum)));
+ if (osi_print_cksum(ndo, (const uint8_t *)header_lsp->lsp_id,
+ EXTRACT_16BITS(header_lsp->checksum),
+ 12, length-12) == 0)
+ goto trunc;
- osi_print_cksum((u_int8_t *)header_lsp->lsp_id,
- EXTRACT_16BITS(header_lsp->checksum), 12, length-12);
-
- /*
- * Clear checksum and lifetime prior to signature verification.
- */
- header_lsp->checksum[0] = 0;
- header_lsp->checksum[1] = 0;
- header_lsp->remaining_lifetime[0] = 0;
- header_lsp->remaining_lifetime[1] = 0;
-
-
- printf(", PDU length: %u, Flags: [ %s",
+ ND_PRINT((ndo, ", PDU length: %u, Flags: [ %s",
pdu_len,
- ISIS_MASK_LSP_OL_BIT(header_lsp->typeblock) ? "Overload bit set, " : "");
+ ISIS_MASK_LSP_OL_BIT(header_lsp->typeblock) ? "Overload bit set, " : ""));
if (ISIS_MASK_LSP_ATT_BITS(header_lsp->typeblock)) {
- printf("%s", ISIS_MASK_LSP_ATT_DEFAULT_BIT(header_lsp->typeblock) ? "default " : "");
- printf("%s", ISIS_MASK_LSP_ATT_DELAY_BIT(header_lsp->typeblock) ? "delay " : "");
- printf("%s", ISIS_MASK_LSP_ATT_EXPENSE_BIT(header_lsp->typeblock) ? "expense " : "");
- printf("%s", ISIS_MASK_LSP_ATT_ERROR_BIT(header_lsp->typeblock) ? "error " : "");
- printf("ATT bit set, ");
+ ND_PRINT((ndo, "%s", ISIS_MASK_LSP_ATT_DEFAULT_BIT(header_lsp->typeblock) ? "default " : ""));
+ ND_PRINT((ndo, "%s", ISIS_MASK_LSP_ATT_DELAY_BIT(header_lsp->typeblock) ? "delay " : ""));
+ ND_PRINT((ndo, "%s", ISIS_MASK_LSP_ATT_EXPENSE_BIT(header_lsp->typeblock) ? "expense " : ""));
+ ND_PRINT((ndo, "%s", ISIS_MASK_LSP_ATT_ERROR_BIT(header_lsp->typeblock) ? "error " : ""));
+ ND_PRINT((ndo, "ATT bit set, "));
}
- printf("%s", ISIS_MASK_LSP_PARTITION_BIT(header_lsp->typeblock) ? "P bit set, " : "");
- printf("%s ]", tok2str(isis_lsp_istype_values,"Unknown(0x%x)",ISIS_MASK_LSP_ISTYPE_BITS(header_lsp->typeblock)));
+ ND_PRINT((ndo, "%s", ISIS_MASK_LSP_PARTITION_BIT(header_lsp->typeblock) ? "P bit set, " : ""));
+ ND_PRINT((ndo, "%s ]", tok2str(isis_lsp_istype_values, "Unknown(0x%x)",
+ ISIS_MASK_LSP_ISTYPE_BITS(header_lsp->typeblock))));
- if (vflag > 1) {
- if(!print_unknown_data(pptr,"\n\t ",ISIS_LSP_HEADER_SIZE))
- return(0);
- }
+ if (ndo->ndo_vflag > 1) {
+ if (!print_unknown_data(ndo, pptr, "\n\t ", ISIS_LSP_HEADER_SIZE))
+ return(0);
+ }
packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_LSP_HEADER_SIZE);
pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_LSP_HEADER_SIZE);
@@ -2370,30 +2431,30 @@ static int isis_print (const u_int8_t *p, u_int length)
case ISIS_PDU_L1_CSNP:
case ISIS_PDU_L2_CSNP:
if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_CSNP_HEADER_SIZE)) {
- printf(", bogus fixed header length %u should be %lu",
- isis_header->fixed_len, (unsigned long)ISIS_CSNP_HEADER_SIZE);
+ ND_PRINT((ndo, ", bogus fixed header length %u should be %lu",
+ isis_header->fixed_len, (unsigned long)ISIS_CSNP_HEADER_SIZE));
return (0);
}
+ ND_TCHECK(*header_csnp);
pdu_len=EXTRACT_16BITS(header_csnp->pdu_len);
if (packet_len>pdu_len) {
packet_len=pdu_len; /* do TLV decoding as long as it makes sense */
length=pdu_len;
}
- TCHECK(*header_csnp);
- printf("\n\t source-id: %s, PDU length: %u",
+ ND_PRINT((ndo, "\n\t source-id: %s, PDU length: %u",
isis_print_id(header_csnp->source_id, NODE_ID_LEN),
- pdu_len);
- printf("\n\t start lsp-id: %s",
- isis_print_id(header_csnp->start_lsp_id, LSP_ID_LEN));
- printf("\n\t end lsp-id: %s",
- isis_print_id(header_csnp->end_lsp_id, LSP_ID_LEN));
-
- if (vflag > 1) {
- if(!print_unknown_data(pptr,"\n\t ",ISIS_CSNP_HEADER_SIZE))
- return(0);
- }
+ pdu_len));
+ ND_PRINT((ndo, "\n\t start lsp-id: %s",
+ isis_print_id(header_csnp->start_lsp_id, LSP_ID_LEN)));
+ ND_PRINT((ndo, "\n\t end lsp-id: %s",
+ isis_print_id(header_csnp->end_lsp_id, LSP_ID_LEN)));
+
+ if (ndo->ndo_vflag > 1) {
+ if (!print_unknown_data(ndo, pptr, "\n\t ", ISIS_CSNP_HEADER_SIZE))
+ return(0);
+ }
packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_CSNP_HEADER_SIZE);
pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_CSNP_HEADER_SIZE);
@@ -2402,34 +2463,33 @@ static int isis_print (const u_int8_t *p, u_int length)
case ISIS_PDU_L1_PSNP:
case ISIS_PDU_L2_PSNP:
if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_PSNP_HEADER_SIZE)) {
- printf("- bogus fixed header length %u should be %lu",
- isis_header->fixed_len, (unsigned long)ISIS_PSNP_HEADER_SIZE);
+ ND_PRINT((ndo, "- bogus fixed header length %u should be %lu",
+ isis_header->fixed_len, (unsigned long)ISIS_PSNP_HEADER_SIZE));
return (0);
}
+ ND_TCHECK(*header_psnp);
pdu_len=EXTRACT_16BITS(header_psnp->pdu_len);
if (packet_len>pdu_len) {
packet_len=pdu_len; /* do TLV decoding as long as it makes sense */
length=pdu_len;
}
- TCHECK(*header_psnp);
- printf("\n\t source-id: %s, PDU length: %u",
+ ND_PRINT((ndo, "\n\t source-id: %s, PDU length: %u",
isis_print_id(header_psnp->source_id, NODE_ID_LEN),
- pdu_len);
+ pdu_len));
- if (vflag > 1) {
- if(!print_unknown_data(pptr,"\n\t ",ISIS_PSNP_HEADER_SIZE))
- return(0);
- }
+ if (ndo->ndo_vflag > 1) {
+ if (!print_unknown_data(ndo, pptr, "\n\t ", ISIS_PSNP_HEADER_SIZE))
+ return(0);
+ }
packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_PSNP_HEADER_SIZE);
pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_PSNP_HEADER_SIZE);
break;
default:
- if(!print_unknown_data(pptr,"\n\t ",length))
- return(0);
+ (void)print_unknown_data(ndo, pptr, "\n\t ", length);
return (0);
}
@@ -2438,15 +2498,11 @@ static int isis_print (const u_int8_t *p, u_int length)
*/
while (packet_len >= 2) {
- if (pptr == snapend) {
- return (1);
+ if (pptr == ndo->ndo_snapend) {
+ return (1);
}
- if (!TTEST2(*pptr, 2)) {
- printf("\n\t\t packet exceeded snapshot (%ld) bytes",
- (long)(pptr-snapend));
- return (1);
- }
+ ND_TCHECK2(*pptr, 2);
tlv_type = *pptr++;
tlv_len = *pptr++;
tmp =tlv_len; /* copy temporary len & pointer to packet data */
@@ -2457,59 +2513,55 @@ static int isis_print (const u_int8_t *p, u_int length)
}
/* first lets see if we know the TLVs name*/
- printf("\n\t %s TLV #%u, length: %u",
+ ND_PRINT((ndo, "\n\t %s TLV #%u, length: %u",
tok2str(isis_tlv_values,
"unknown",
tlv_type),
tlv_type,
- tlv_len);
+ tlv_len));
- if (tlv_len == 0) /* something is malformed */
+ if (tlv_len == 0) /* something is invalid */
continue;
/* now check if we have a decoder otherwise do a hexdump at the end*/
switch (tlv_type) {
case ISIS_TLV_AREA_ADDR:
- if (!TTEST2(*tptr, 1))
- goto trunctlv;
+ ND_TCHECK2(*tptr, 1);
alen = *tptr++;
while (tmp && alen < tmp) {
- printf("\n\t Area address (length: %u): %s",
+ ND_PRINT((ndo, "\n\t Area address (length: %u): %s",
alen,
- isonsap_string(tptr,alen));
+ isonsap_string(ndo, tptr, alen)));
tptr += alen;
tmp -= alen + 1;
if (tmp==0) /* if this is the last area address do not attemt a boundary check */
break;
- if (!TTEST2(*tptr, 1))
- goto trunctlv;
+ ND_TCHECK2(*tptr, 1);
alen = *tptr++;
}
break;
case ISIS_TLV_ISNEIGH:
while (tmp >= ETHER_ADDR_LEN) {
- if (!TTEST2(*tptr, ETHER_ADDR_LEN))
- goto trunctlv;
- printf("\n\t SNPA: %s",isis_print_id(tptr,ETHER_ADDR_LEN));
+ ND_TCHECK2(*tptr, ETHER_ADDR_LEN);
+ ND_PRINT((ndo, "\n\t SNPA: %s", isis_print_id(tptr, ETHER_ADDR_LEN)));
tmp -= ETHER_ADDR_LEN;
tptr += ETHER_ADDR_LEN;
}
break;
case ISIS_TLV_ISNEIGH_VARLEN:
- if (!TTEST2(*tptr, 1) || tmp < 3) /* min. TLV length */
+ if (!ND_TTEST2(*tptr, 1) || tmp < 3) /* min. TLV length */
goto trunctlv;
lan_alen = *tptr++; /* LAN address length */
if (lan_alen == 0) {
- printf("\n\t LAN address length 0 bytes (invalid)");
+ ND_PRINT((ndo, "\n\t LAN address length 0 bytes (invalid)"));
break;
}
tmp --;
- printf("\n\t LAN address length %u bytes ",lan_alen);
+ ND_PRINT((ndo, "\n\t LAN address length %u bytes ", lan_alen));
while (tmp >= lan_alen) {
- if (!TTEST2(*tptr, lan_alen))
- goto trunctlv;
- printf("\n\t\tIS Neighbor: %s",isis_print_id(tptr,lan_alen));
+ ND_TCHECK2(*tptr, lan_alen);
+ ND_PRINT((ndo, "\n\t\tIS Neighbor: %s", isis_print_id(tptr, lan_alen)));
tmp -= lan_alen;
tptr +=lan_alen;
}
@@ -2519,16 +2571,16 @@ static int isis_print (const u_int8_t *p, u_int length)
break;
case ISIS_TLV_MT_IS_REACH:
- mt_len = isis_print_mtid(tptr, "\n\t ");
+ mt_len = isis_print_mtid(ndo, tptr, "\n\t ");
if (mt_len == 0) /* did something go wrong ? */
goto trunctlv;
tptr+=mt_len;
tmp-=mt_len;
while (tmp >= 2+NODE_ID_LEN+3+1) {
- ext_is_len = isis_print_ext_is_reach(tptr,"\n\t ",tlv_type);
+ ext_is_len = isis_print_ext_is_reach(ndo, tptr, "\n\t ", tlv_type);
if (ext_is_len == 0) /* did something go wrong ? */
goto trunctlv;
-
+
tmp-=ext_is_len;
tptr+=ext_is_len;
}
@@ -2536,7 +2588,7 @@ static int isis_print (const u_int8_t *p, u_int length)
case ISIS_TLV_IS_ALIAS_ID:
while (tmp >= NODE_ID_LEN+1) { /* is it worth attempting a decode ? */
- ext_is_len = isis_print_ext_is_reach(tptr,"\n\t ",tlv_type);
+ ext_is_len = isis_print_ext_is_reach(ndo, tptr, "\n\t ", tlv_type);
if (ext_is_len == 0) /* did something go wrong ? */
goto trunctlv;
tmp-=ext_is_len;
@@ -2546,27 +2598,25 @@ static int isis_print (const u_int8_t *p, u_int length)
case ISIS_TLV_EXT_IS_REACH:
while (tmp >= NODE_ID_LEN+3+1) { /* is it worth attempting a decode ? */
- ext_is_len = isis_print_ext_is_reach(tptr,"\n\t ",tlv_type);
+ ext_is_len = isis_print_ext_is_reach(ndo, tptr, "\n\t ", tlv_type);
if (ext_is_len == 0) /* did something go wrong ? */
- goto trunctlv;
+ goto trunctlv;
tmp-=ext_is_len;
tptr+=ext_is_len;
}
break;
case ISIS_TLV_IS_REACH:
- if (!TTEST2(*tptr,1)) /* check if there is one byte left to read out the virtual flag */
- goto trunctlv;
- printf("\n\t %s",
+ ND_TCHECK2(*tptr,1); /* check if there is one byte left to read out the virtual flag */
+ ND_PRINT((ndo, "\n\t %s",
tok2str(isis_is_reach_virtual_values,
"bogus virtual flag 0x%02x",
- *tptr++));
+ *tptr++)));
tlv_is_reach = (const struct isis_tlv_is_reach *)tptr;
while (tmp >= sizeof(struct isis_tlv_is_reach)) {
- if (!TTEST(*tlv_is_reach))
- goto trunctlv;
- printf("\n\t IS Neighbor: %s",
- isis_print_id(tlv_is_reach->neighbor_nodeid, NODE_ID_LEN));
- isis_print_metric_block(&tlv_is_reach->isis_metric_block);
+ ND_TCHECK(*tlv_is_reach);
+ ND_PRINT((ndo, "\n\t IS Neighbor: %s",
+ isis_print_id(tlv_is_reach->neighbor_nodeid, NODE_ID_LEN)));
+ isis_print_metric_block(ndo, &tlv_is_reach->isis_metric_block);
tmp -= sizeof(struct isis_tlv_is_reach);
tlv_is_reach++;
}
@@ -2575,11 +2625,10 @@ static int isis_print (const u_int8_t *p, u_int length)
case ISIS_TLV_ESNEIGH:
tlv_es_reach = (const struct isis_tlv_es_reach *)tptr;
while (tmp >= sizeof(struct isis_tlv_es_reach)) {
- if (!TTEST(*tlv_es_reach))
- goto trunctlv;
- printf("\n\t ES Neighbor: %s",
- isis_print_id(tlv_es_reach->neighbor_sysid,SYSTEM_ID_LEN));
- isis_print_metric_block(&tlv_es_reach->isis_metric_block);
+ ND_TCHECK(*tlv_es_reach);
+ ND_PRINT((ndo, "\n\t ES Neighbor: %s",
+ isis_print_id(tlv_es_reach->neighbor_sysid, SYSTEM_ID_LEN)));
+ isis_print_metric_block(ndo, &tlv_es_reach->isis_metric_block);
tmp -= sizeof(struct isis_tlv_es_reach);
tlv_es_reach++;
}
@@ -2588,13 +2637,13 @@ static int isis_print (const u_int8_t *p, u_int length)
/* those two TLVs share the same format */
case ISIS_TLV_INT_IP_REACH:
case ISIS_TLV_EXT_IP_REACH:
- if (!isis_print_tlv_ip_reach(pptr, "\n\t ", tlv_len))
- return (1);
- break;
+ if (!isis_print_tlv_ip_reach(ndo, pptr, "\n\t ", tlv_len))
+ return (1);
+ break;
case ISIS_TLV_EXTD_IP_REACH:
while (tmp>0) {
- ext_ip_len = isis_print_extd_ip_reach(tptr, "\n\t ", AF_INET);
+ ext_ip_len = isis_print_extd_ip_reach(ndo, tptr, "\n\t ", AF_INET);
if (ext_ip_len == 0) /* did something go wrong ? */
goto trunctlv;
tptr+=ext_ip_len;
@@ -2603,7 +2652,7 @@ static int isis_print (const u_int8_t *p, u_int length)
break;
case ISIS_TLV_MT_IP_REACH:
- mt_len = isis_print_mtid(tptr, "\n\t ");
+ mt_len = isis_print_mtid(ndo, tptr, "\n\t ");
if (mt_len == 0) { /* did something go wrong ? */
goto trunctlv;
}
@@ -2611,7 +2660,7 @@ static int isis_print (const u_int8_t *p, u_int length)
tmp-=mt_len;
while (tmp>0) {
- ext_ip_len = isis_print_extd_ip_reach(tptr, "\n\t ", AF_INET);
+ ext_ip_len = isis_print_extd_ip_reach(ndo, tptr, "\n\t ", AF_INET);
if (ext_ip_len == 0) /* did something go wrong ? */
goto trunctlv;
tptr+=ext_ip_len;
@@ -2619,10 +2668,9 @@ static int isis_print (const u_int8_t *p, u_int length)
}
break;
-#ifdef INET6
case ISIS_TLV_IP6_REACH:
while (tmp>0) {
- ext_ip_len = isis_print_extd_ip_reach(tptr, "\n\t ", AF_INET6);
+ ext_ip_len = isis_print_extd_ip_reach(ndo, tptr, "\n\t ", AF_INET6);
if (ext_ip_len == 0) /* did something go wrong ? */
goto trunctlv;
tptr+=ext_ip_len;
@@ -2631,7 +2679,7 @@ static int isis_print (const u_int8_t *p, u_int length)
break;
case ISIS_TLV_MT_IP6_REACH:
- mt_len = isis_print_mtid(tptr, "\n\t ");
+ mt_len = isis_print_mtid(ndo, tptr, "\n\t ");
if (mt_len == 0) { /* did something go wrong ? */
goto trunctlv;
}
@@ -2639,7 +2687,7 @@ static int isis_print (const u_int8_t *p, u_int length)
tmp-=mt_len;
while (tmp>0) {
- ext_ip_len = isis_print_extd_ip_reach(tptr, "\n\t ", AF_INET6);
+ ext_ip_len = isis_print_extd_ip_reach(ndo, tptr, "\n\t ", AF_INET6);
if (ext_ip_len == 0) /* did something go wrong ? */
goto trunctlv;
tptr+=ext_ip_len;
@@ -2649,64 +2697,54 @@ static int isis_print (const u_int8_t *p, u_int length)
case ISIS_TLV_IP6ADDR:
while (tmp>=sizeof(struct in6_addr)) {
- if (!TTEST2(*tptr, sizeof(struct in6_addr)))
- goto trunctlv;
+ ND_TCHECK2(*tptr, sizeof(struct in6_addr));
- printf("\n\t IPv6 interface address: %s",
- ip6addr_string(tptr));
+ ND_PRINT((ndo, "\n\t IPv6 interface address: %s",
+ ip6addr_string(ndo, tptr)));
tptr += sizeof(struct in6_addr);
tmp -= sizeof(struct in6_addr);
}
break;
-#endif
case ISIS_TLV_AUTH:
- if (!TTEST2(*tptr, 1))
- goto trunctlv;
+ ND_TCHECK2(*tptr, 1);
- printf("\n\t %s: ",
+ ND_PRINT((ndo, "\n\t %s: ",
tok2str(isis_subtlv_auth_values,
"unknown Authentication type 0x%02x",
- *tptr));
+ *tptr)));
switch (*tptr) {
case ISIS_SUBTLV_AUTH_SIMPLE:
- for(i=1;i<tlv_len;i++) {
- if (!TTEST2(*(tptr+i), 1))
- goto trunctlv;
- printf("%c",*(tptr+i));
- }
+ if (fn_printzp(ndo, tptr + 1, tlv_len - 1, ndo->ndo_snapend))
+ goto trunctlv;
break;
case ISIS_SUBTLV_AUTH_MD5:
for(i=1;i<tlv_len;i++) {
- if (!TTEST2(*(tptr+i), 1))
- goto trunctlv;
- printf("%02x",*(tptr+i));
+ ND_TCHECK2(*(tptr + i), 1);
+ ND_PRINT((ndo, "%02x", *(tptr + i)));
}
if (tlv_len != ISIS_SUBTLV_AUTH_MD5_LEN+1)
- printf(", (malformed subTLV) ");
+ ND_PRINT((ndo, ", (invalid subTLV) "));
-#ifdef HAVE_LIBCRYPTO
- sigcheck = signature_verify(optr, length,
- (unsigned char *)tptr + 1);
-#else
- sigcheck = CANT_CHECK_SIGNATURE;
-#endif
- printf(" (%s)", tok2str(signature_check_values, "Unknown", sigcheck));
+ sigcheck = signature_verify(ndo, optr, length, tptr + 1,
+ isis_clear_checksum_lifetime,
+ header_lsp);
+ ND_PRINT((ndo, " (%s)", tok2str(signature_check_values, "Unknown", sigcheck)));
break;
case ISIS_SUBTLV_AUTH_GENERIC:
+ ND_TCHECK2(*(tptr + 1), 2);
key_id = EXTRACT_16BITS((tptr+1));
- printf("%u, password: ", key_id);
- for(i=1 + sizeof(u_int16_t);i<tlv_len;i++) {
- if (!TTEST2(*(tptr+i), 1))
- goto trunctlv;
- printf("%02x",*(tptr+i));
+ ND_PRINT((ndo, "%u, password: ", key_id));
+ for(i=1 + sizeof(uint16_t);i<tlv_len;i++) {
+ ND_TCHECK2(*(tptr + i), 1);
+ ND_PRINT((ndo, "%02x", *(tptr + i)));
}
break;
case ISIS_SUBTLV_AUTH_PRIVATE:
default:
- if(!print_unknown_data(tptr+1,"\n\t\t ",tlv_len-1))
+ if (!print_unknown_data(ndo, tptr + 1, "\n\t\t ", tlv_len - 1))
return(0);
break;
}
@@ -2715,49 +2753,42 @@ static int isis_print (const u_int8_t *p, u_int length)
case ISIS_TLV_PTP_ADJ:
tlv_ptp_adj = (const struct isis_tlv_ptp_adj *)tptr;
if(tmp>=1) {
- if (!TTEST2(*tptr, 1))
- goto trunctlv;
- printf("\n\t Adjacency State: %s (%u)",
+ ND_TCHECK2(*tptr, 1);
+ ND_PRINT((ndo, "\n\t Adjacency State: %s (%u)",
tok2str(isis_ptp_adjancey_values, "unknown", *tptr),
- *tptr);
+ *tptr));
tmp--;
}
if(tmp>sizeof(tlv_ptp_adj->extd_local_circuit_id)) {
- if (!TTEST2(tlv_ptp_adj->extd_local_circuit_id,
- sizeof(tlv_ptp_adj->extd_local_circuit_id)))
- goto trunctlv;
- printf("\n\t Extended Local circuit-ID: 0x%08x",
- EXTRACT_32BITS(tlv_ptp_adj->extd_local_circuit_id));
+ ND_TCHECK(tlv_ptp_adj->extd_local_circuit_id);
+ ND_PRINT((ndo, "\n\t Extended Local circuit-ID: 0x%08x",
+ EXTRACT_32BITS(tlv_ptp_adj->extd_local_circuit_id)));
tmp-=sizeof(tlv_ptp_adj->extd_local_circuit_id);
}
if(tmp>=SYSTEM_ID_LEN) {
- if (!TTEST2(tlv_ptp_adj->neighbor_sysid, SYSTEM_ID_LEN))
- goto trunctlv;
- printf("\n\t Neighbor System-ID: %s",
- isis_print_id(tlv_ptp_adj->neighbor_sysid,SYSTEM_ID_LEN));
+ ND_TCHECK2(tlv_ptp_adj->neighbor_sysid, SYSTEM_ID_LEN);
+ ND_PRINT((ndo, "\n\t Neighbor System-ID: %s",
+ isis_print_id(tlv_ptp_adj->neighbor_sysid, SYSTEM_ID_LEN)));
tmp-=SYSTEM_ID_LEN;
}
if(tmp>=sizeof(tlv_ptp_adj->neighbor_extd_local_circuit_id)) {
- if (!TTEST2(tlv_ptp_adj->neighbor_extd_local_circuit_id,
- sizeof(tlv_ptp_adj->neighbor_extd_local_circuit_id)))
- goto trunctlv;
- printf("\n\t Neighbor Extended Local circuit-ID: 0x%08x",
- EXTRACT_32BITS(tlv_ptp_adj->neighbor_extd_local_circuit_id));
+ ND_TCHECK(tlv_ptp_adj->neighbor_extd_local_circuit_id);
+ ND_PRINT((ndo, "\n\t Neighbor Extended Local circuit-ID: 0x%08x",
+ EXTRACT_32BITS(tlv_ptp_adj->neighbor_extd_local_circuit_id)));
}
break;
case ISIS_TLV_PROTOCOLS:
- printf("\n\t NLPID(s): ");
+ ND_PRINT((ndo, "\n\t NLPID(s): "));
while (tmp>0) {
- if (!TTEST2(*(tptr), 1))
- goto trunctlv;
- printf("%s (0x%02x)",
+ ND_TCHECK2(*(tptr), 1);
+ ND_PRINT((ndo, "%s (0x%02x)",
tok2str(nlpid_values,
"unknown",
*tptr),
- *tptr);
+ *tptr));
if (tmp>1) /* further NPLIDs ? - put comma */
- printf(", ");
+ ND_PRINT((ndo, ", "));
tptr++;
tmp--;
}
@@ -2765,102 +2796,89 @@ static int isis_print (const u_int8_t *p, u_int length)
case ISIS_TLV_MT_PORT_CAP:
{
- if (!TTEST2(*(tptr), 2))
- goto trunctlv;
+ ND_TCHECK2(*(tptr), 2);
- printf("\n\t RES: %d, MTID(s): %d",
- (EXTRACT_16BITS (tptr) >> 12),
- (EXTRACT_16BITS (tptr) & 0x0fff));
+ ND_PRINT((ndo, "\n\t RES: %d, MTID(s): %d",
+ (EXTRACT_16BITS (tptr) >> 12),
+ (EXTRACT_16BITS (tptr) & 0x0fff)));
tmp = tmp-2;
tptr = tptr+2;
if (tmp)
- isis_print_mt_port_cap_subtlv (tptr, tmp);
+ isis_print_mt_port_cap_subtlv(ndo, tptr, tmp);
break;
}
case ISIS_TLV_MT_CAPABILITY:
- if (!TTEST2(*(tptr), 2))
- goto trunctlv;
+ ND_TCHECK2(*(tptr), 2);
- printf("\n\t O: %d, RES: %d, MTID(s): %d",
+ ND_PRINT((ndo, "\n\t O: %d, RES: %d, MTID(s): %d",
(EXTRACT_16BITS(tptr) >> 15) & 0x01,
(EXTRACT_16BITS(tptr) >> 12) & 0x07,
- EXTRACT_16BITS(tptr) & 0x0fff);
+ EXTRACT_16BITS(tptr) & 0x0fff));
tmp = tmp-2;
tptr = tptr+2;
if (tmp)
- isis_print_mt_capability_subtlv (tptr, tmp);
+ isis_print_mt_capability_subtlv(ndo, tptr, tmp);
break;
case ISIS_TLV_TE_ROUTER_ID:
- if (!TTEST2(*pptr, sizeof(struct in_addr)))
- goto trunctlv;
- printf("\n\t Traffic Engineering Router ID: %s", ipaddr_string(pptr));
+ ND_TCHECK2(*pptr, sizeof(struct in_addr));
+ ND_PRINT((ndo, "\n\t Traffic Engineering Router ID: %s", ipaddr_string(ndo, pptr)));
break;
case ISIS_TLV_IPADDR:
while (tmp>=sizeof(struct in_addr)) {
- if (!TTEST2(*tptr, sizeof(struct in_addr)))
- goto trunctlv;
- printf("\n\t IPv4 interface address: %s", ipaddr_string(tptr));
+ ND_TCHECK2(*tptr, sizeof(struct in_addr));
+ ND_PRINT((ndo, "\n\t IPv4 interface address: %s", ipaddr_string(ndo, tptr)));
tptr += sizeof(struct in_addr);
tmp -= sizeof(struct in_addr);
}
break;
case ISIS_TLV_HOSTNAME:
- printf("\n\t Hostname: ");
- while (tmp>0) {
- if (!TTEST2(*tptr, 1))
- goto trunctlv;
- printf("%c",*tptr++);
- tmp--;
- }
+ ND_PRINT((ndo, "\n\t Hostname: "));
+ if (fn_printzp(ndo, tptr, tmp, ndo->ndo_snapend))
+ goto trunctlv;
break;
case ISIS_TLV_SHARED_RISK_GROUP:
if (tmp < NODE_ID_LEN)
break;
- if (!TTEST2(*tptr, NODE_ID_LEN))
- goto trunctlv;
- printf("\n\t IS Neighbor: %s", isis_print_id(tptr, NODE_ID_LEN));
+ ND_TCHECK2(*tptr, NODE_ID_LEN);
+ ND_PRINT((ndo, "\n\t IS Neighbor: %s", isis_print_id(tptr, NODE_ID_LEN)));
tptr+=(NODE_ID_LEN);
tmp-=(NODE_ID_LEN);
if (tmp < 1)
break;
- if (!TTEST2(*tptr, 1))
- goto trunctlv;
- printf(", Flags: [%s]", ISIS_MASK_TLV_SHARED_RISK_GROUP(*tptr++) ? "numbered" : "unnumbered");
+ ND_TCHECK2(*tptr, 1);
+ ND_PRINT((ndo, ", Flags: [%s]", ISIS_MASK_TLV_SHARED_RISK_GROUP(*tptr++) ? "numbered" : "unnumbered"));
tmp--;
if (tmp < sizeof(struct in_addr))
break;
- if (!TTEST2(*tptr,sizeof(struct in_addr)))
- goto trunctlv;
- printf("\n\t IPv4 interface address: %s", ipaddr_string(tptr));
+ ND_TCHECK2(*tptr, sizeof(struct in_addr));
+ ND_PRINT((ndo, "\n\t IPv4 interface address: %s", ipaddr_string(ndo, tptr)));
tptr+=sizeof(struct in_addr);
tmp-=sizeof(struct in_addr);
if (tmp < sizeof(struct in_addr))
break;
- if (!TTEST2(*tptr,sizeof(struct in_addr)))
- goto trunctlv;
- printf("\n\t IPv4 neighbor address: %s", ipaddr_string(tptr));
+ ND_TCHECK2(*tptr, sizeof(struct in_addr));
+ ND_PRINT((ndo, "\n\t IPv4 neighbor address: %s", ipaddr_string(ndo, tptr)));
tptr+=sizeof(struct in_addr);
tmp-=sizeof(struct in_addr);
while (tmp>=4) {
- if (!TTEST2(*tptr, 4))
- goto trunctlv;
- printf("\n\t Link-ID: 0x%08x", EXTRACT_32BITS(tptr));
+ ND_TCHECK2(*tptr, 4);
+ ND_PRINT((ndo, "\n\t Link-ID: 0x%08x", EXTRACT_32BITS(tptr)));
tptr+=4;
tmp-=4;
}
@@ -2869,19 +2887,15 @@ static int isis_print (const u_int8_t *p, u_int length)
case ISIS_TLV_LSP:
tlv_lsp = (const struct isis_tlv_lsp *)tptr;
while(tmp>=sizeof(struct isis_tlv_lsp)) {
- if (!TTEST((tlv_lsp->lsp_id)[LSP_ID_LEN-1]))
- goto trunctlv;
- printf("\n\t lsp-id: %s",
- isis_print_id(tlv_lsp->lsp_id, LSP_ID_LEN));
- if (!TTEST2(tlv_lsp->sequence_number, 4))
- goto trunctlv;
- printf(", seq: 0x%08x",EXTRACT_32BITS(tlv_lsp->sequence_number));
- if (!TTEST2(tlv_lsp->remaining_lifetime, 2))
- goto trunctlv;
- printf(", lifetime: %5ds",EXTRACT_16BITS(tlv_lsp->remaining_lifetime));
- if (!TTEST2(tlv_lsp->checksum, 2))
- goto trunctlv;
- printf(", chksum: 0x%04x",EXTRACT_16BITS(tlv_lsp->checksum));
+ ND_TCHECK((tlv_lsp->lsp_id)[LSP_ID_LEN-1]);
+ ND_PRINT((ndo, "\n\t lsp-id: %s",
+ isis_print_id(tlv_lsp->lsp_id, LSP_ID_LEN)));
+ ND_TCHECK2(tlv_lsp->sequence_number, 4);
+ ND_PRINT((ndo, ", seq: 0x%08x", EXTRACT_32BITS(tlv_lsp->sequence_number)));
+ ND_TCHECK2(tlv_lsp->remaining_lifetime, 2);
+ ND_PRINT((ndo, ", lifetime: %5ds", EXTRACT_16BITS(tlv_lsp->remaining_lifetime)));
+ ND_TCHECK2(tlv_lsp->checksum, 2);
+ ND_PRINT((ndo, ", chksum: 0x%04x", EXTRACT_16BITS(tlv_lsp->checksum)));
tmp-=sizeof(struct isis_tlv_lsp);
tlv_lsp++;
}
@@ -2890,15 +2904,30 @@ static int isis_print (const u_int8_t *p, u_int length)
case ISIS_TLV_CHECKSUM:
if (tmp < ISIS_TLV_CHECKSUM_MINLEN)
break;
- if (!TTEST2(*tptr, ISIS_TLV_CHECKSUM_MINLEN))
- goto trunctlv;
- printf("\n\t checksum: 0x%04x ", EXTRACT_16BITS(tptr));
+ ND_TCHECK2(*tptr, ISIS_TLV_CHECKSUM_MINLEN);
+ ND_PRINT((ndo, "\n\t checksum: 0x%04x ", EXTRACT_16BITS(tptr)));
/* do not attempt to verify the checksum if it is zero
* most likely a HMAC-MD5 TLV is also present and
* to avoid conflicts the checksum TLV is zeroed.
* see rfc3358 for details
*/
- osi_print_cksum(optr, EXTRACT_16BITS(tptr), tptr-optr, length);
+ if (osi_print_cksum(ndo, optr, EXTRACT_16BITS(tptr), tptr-optr,
+ length) == 0)
+ goto trunc;
+ break;
+
+ case ISIS_TLV_POI:
+ if (tlv_len >= SYSTEM_ID_LEN + 1) {
+ ND_TCHECK2(*tptr, SYSTEM_ID_LEN + 1);
+ ND_PRINT((ndo, "\n\t Purge Originator System-ID: %s",
+ isis_print_id(tptr + 1, SYSTEM_ID_LEN)));
+ }
+
+ if (tlv_len == 2 * SYSTEM_ID_LEN + 1) {
+ ND_TCHECK2(*tptr, 2 * SYSTEM_ID_LEN + 1);
+ ND_PRINT((ndo, "\n\t Received from System-ID: %s",
+ isis_print_id(tptr + SYSTEM_ID_LEN + 1, SYSTEM_ID_LEN)));
+ }
break;
case ISIS_TLV_MT_SUPPORTED:
@@ -2908,13 +2937,13 @@ static int isis_print (const u_int8_t *p, u_int length)
/* length can only be a multiple of 2, otherwise there is
something broken -> so decode down until length is 1 */
if (tmp!=1) {
- mt_len = isis_print_mtid(tptr, "\n\t ");
+ mt_len = isis_print_mtid(ndo, tptr, "\n\t ");
if (mt_len == 0) /* did something go wrong ? */
goto trunctlv;
tptr+=mt_len;
tmp-=mt_len;
} else {
- printf("\n\t malformed MT-ID");
+ ND_PRINT((ndo, "\n\t invalid MT-ID"));
break;
}
}
@@ -2924,10 +2953,9 @@ static int isis_print (const u_int8_t *p, u_int length)
/* first attempt to decode the flags */
if (tmp < ISIS_TLV_RESTART_SIGNALING_FLAGLEN)
break;
- if (!TTEST2(*tptr, ISIS_TLV_RESTART_SIGNALING_FLAGLEN))
- goto trunctlv;
- printf("\n\t Flags [%s]",
- bittok2str(isis_restart_flag_values, "none", *tptr));
+ ND_TCHECK2(*tptr, ISIS_TLV_RESTART_SIGNALING_FLAGLEN);
+ ND_PRINT((ndo, "\n\t Flags [%s]",
+ bittok2str(isis_restart_flag_values, "none", *tptr)));
tptr+=ISIS_TLV_RESTART_SIGNALING_FLAGLEN;
tmp-=ISIS_TLV_RESTART_SIGNALING_FLAGLEN;
@@ -2937,40 +2965,36 @@ static int isis_print (const u_int8_t *p, u_int length)
if (tmp < ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN)
break;
- if (!TTEST2(*tptr, ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN))
- goto trunctlv;
+ ND_TCHECK2(*tptr, ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN);
- printf(", Remaining holding time %us", EXTRACT_16BITS(tptr));
+ ND_PRINT((ndo, ", Remaining holding time %us", EXTRACT_16BITS(tptr)));
tptr+=ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN;
tmp-=ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN;
/* is there an additional sysid field present ?*/
if (tmp == SYSTEM_ID_LEN) {
- if (!TTEST2(*tptr, SYSTEM_ID_LEN))
- goto trunctlv;
- printf(", for %s",isis_print_id(tptr,SYSTEM_ID_LEN));
- }
+ ND_TCHECK2(*tptr, SYSTEM_ID_LEN);
+ ND_PRINT((ndo, ", for %s", isis_print_id(tptr,SYSTEM_ID_LEN)));
+ }
break;
case ISIS_TLV_IDRP_INFO:
if (tmp < ISIS_TLV_IDRP_INFO_MINLEN)
break;
- if (!TTEST2(*tptr, ISIS_TLV_IDRP_INFO_MINLEN))
- goto trunctlv;
- printf("\n\t Inter-Domain Information Type: %s",
+ ND_TCHECK2(*tptr, ISIS_TLV_IDRP_INFO_MINLEN);
+ ND_PRINT((ndo, "\n\t Inter-Domain Information Type: %s",
tok2str(isis_subtlv_idrp_values,
"Unknown (0x%02x)",
- *tptr));
+ *tptr)));
switch (*tptr++) {
case ISIS_SUBTLV_IDRP_ASN:
- if (!TTEST2(*tptr, 2)) /* fetch AS number */
- goto trunctlv;
- printf("AS Number: %u",EXTRACT_16BITS(tptr));
+ ND_TCHECK2(*tptr, 2); /* fetch AS number */
+ ND_PRINT((ndo, "AS Number: %u", EXTRACT_16BITS(tptr)));
break;
case ISIS_SUBTLV_IDRP_LOCAL:
case ISIS_SUBTLV_IDRP_RES:
default:
- if(!print_unknown_data(tptr,"\n\t ",tlv_len-1))
+ if (!print_unknown_data(ndo, tptr, "\n\t ", tlv_len - 1))
return(0);
break;
}
@@ -2979,16 +3003,14 @@ static int isis_print (const u_int8_t *p, u_int length)
case ISIS_TLV_LSP_BUFFERSIZE:
if (tmp < ISIS_TLV_LSP_BUFFERSIZE_MINLEN)
break;
- if (!TTEST2(*tptr, ISIS_TLV_LSP_BUFFERSIZE_MINLEN))
- goto trunctlv;
- printf("\n\t LSP Buffersize: %u",EXTRACT_16BITS(tptr));
+ ND_TCHECK2(*tptr, ISIS_TLV_LSP_BUFFERSIZE_MINLEN);
+ ND_PRINT((ndo, "\n\t LSP Buffersize: %u", EXTRACT_16BITS(tptr)));
break;
case ISIS_TLV_PART_DIS:
while (tmp >= SYSTEM_ID_LEN) {
- if (!TTEST2(*tptr, SYSTEM_ID_LEN))
- goto trunctlv;
- printf("\n\t %s",isis_print_id(tptr,SYSTEM_ID_LEN));
+ ND_TCHECK2(*tptr, SYSTEM_ID_LEN);
+ ND_PRINT((ndo, "\n\t %s", isis_print_id(tptr, SYSTEM_ID_LEN)));
tptr+=SYSTEM_ID_LEN;
tmp-=SYSTEM_ID_LEN;
}
@@ -2997,29 +3019,25 @@ static int isis_print (const u_int8_t *p, u_int length)
case ISIS_TLV_PREFIX_NEIGH:
if (tmp < sizeof(struct isis_metric_block))
break;
- if (!TTEST2(*tptr, sizeof(struct isis_metric_block)))
- goto trunctlv;
- printf("\n\t Metric Block");
- isis_print_metric_block((const struct isis_metric_block *)tptr);
+ ND_TCHECK2(*tptr, sizeof(struct isis_metric_block));
+ ND_PRINT((ndo, "\n\t Metric Block"));
+ isis_print_metric_block(ndo, (const struct isis_metric_block *)tptr);
tptr+=sizeof(struct isis_metric_block);
tmp-=sizeof(struct isis_metric_block);
while(tmp>0) {
- if (!TTEST2(*tptr, 1))
- goto trunctlv;
+ ND_TCHECK2(*tptr, 1);
prefix_len=*tptr++; /* read out prefix length in semioctets*/
if (prefix_len < 2) {
- printf("\n\t\tAddress: prefix length %u < 2", prefix_len);
+ ND_PRINT((ndo, "\n\t\tAddress: prefix length %u < 2", prefix_len));
break;
}
tmp--;
if (tmp < prefix_len/2)
break;
- if (!TTEST2(*tptr, prefix_len/2))
- goto trunctlv;
- printf("\n\t\tAddress: %s/%u",
- isonsap_string(tptr,prefix_len/2),
- prefix_len*4);
+ ND_TCHECK2(*tptr, prefix_len / 2);
+ ND_PRINT((ndo, "\n\t\tAddress: %s/%u",
+ isonsap_string(ndo, tptr, prefix_len / 2), prefix_len * 4));
tptr+=prefix_len/2;
tmp-=prefix_len/2;
}
@@ -3028,24 +3046,22 @@ static int isis_print (const u_int8_t *p, u_int length)
case ISIS_TLV_IIH_SEQNR:
if (tmp < ISIS_TLV_IIH_SEQNR_MINLEN)
break;
- if (!TTEST2(*tptr, ISIS_TLV_IIH_SEQNR_MINLEN)) /* check if four bytes are on the wire */
- goto trunctlv;
- printf("\n\t Sequence number: %u", EXTRACT_32BITS(tptr) );
+ ND_TCHECK2(*tptr, ISIS_TLV_IIH_SEQNR_MINLEN); /* check if four bytes are on the wire */
+ ND_PRINT((ndo, "\n\t Sequence number: %u", EXTRACT_32BITS(tptr)));
break;
case ISIS_TLV_VENDOR_PRIVATE:
if (tmp < ISIS_TLV_VENDOR_PRIVATE_MINLEN)
break;
- if (!TTEST2(*tptr, ISIS_TLV_VENDOR_PRIVATE_MINLEN)) /* check if enough byte for a full oui */
- goto trunctlv;
+ ND_TCHECK2(*tptr, ISIS_TLV_VENDOR_PRIVATE_MINLEN); /* check if enough byte for a full oui */
vendor_id = EXTRACT_24BITS(tptr);
- printf("\n\t Vendor: %s (%u)",
- tok2str(oui_values,"Unknown",vendor_id),
- vendor_id);
+ ND_PRINT((ndo, "\n\t Vendor: %s (%u)",
+ tok2str(oui_values, "Unknown", vendor_id),
+ vendor_id));
tptr+=3;
tmp-=3;
if (tmp > 0) /* hexdump the rest */
- if(!print_unknown_data(tptr,"\n\t\t",tmp))
+ if (!print_unknown_data(ndo, tptr, "\n\t\t", tmp))
return(0);
break;
/*
@@ -3060,53 +3076,71 @@ static int isis_print (const u_int8_t *p, u_int length)
case ISIS_TLV_NORTEL_PRIVATE2:
default:
- if (vflag <= 1) {
- if(!print_unknown_data(pptr,"\n\t\t",tlv_len))
- return(0);
- }
- break;
+ if (ndo->ndo_vflag <= 1) {
+ if (!print_unknown_data(ndo, pptr, "\n\t\t", tlv_len))
+ return(0);
+ }
+ break;
}
/* do we want to see an additionally hexdump ? */
- if (vflag> 1) {
- if(!print_unknown_data(pptr,"\n\t ",tlv_len))
- return(0);
- }
+ if (ndo->ndo_vflag> 1) {
+ if (!print_unknown_data(ndo, pptr, "\n\t ", tlv_len))
+ return(0);
+ }
pptr += tlv_len;
packet_len -= tlv_len;
}
if (packet_len != 0) {
- printf("\n\t %u straggler bytes", packet_len);
+ ND_PRINT((ndo, "\n\t %u straggler bytes", packet_len));
}
return (1);
trunc:
- fputs("[|isis]", stdout);
+ ND_PRINT((ndo, "%s", tstr));
return (1);
trunctlv:
- printf("\n\t\t packet exceeded snapshot");
+ ND_PRINT((ndo, "\n\t\t"));
+ ND_PRINT((ndo, "%s", tstr));
return(1);
}
-static void
-osi_print_cksum (const u_int8_t *pptr, u_int16_t checksum,
- u_int checksum_offset, u_int length)
+static int
+osi_print_cksum(netdissect_options *ndo, const uint8_t *pptr,
+ uint16_t checksum, int checksum_offset, int length)
{
- u_int16_t calculated_checksum;
+ uint16_t calculated_checksum;
- /* do not attempt to verify the checksum if it is zero */
- if (!checksum) {
- printf("(unverified)");
+ /* do not attempt to verify the checksum if it is zero,
+ * if the total length is nonsense,
+ * if the offset is nonsense,
+ * or the base pointer is not sane
+ */
+ if (!checksum
+ || length < 0
+ || checksum_offset < 0
+ || length > ndo->ndo_snaplen
+ || checksum_offset > ndo->ndo_snaplen
+ || checksum_offset > length) {
+ ND_PRINT((ndo, " (unverified)"));
+ return 1;
} else {
+#if 0
+ printf("\nosi_print_cksum: %p %u %u %u\n", pptr, checksum_offset, length, ndo->ndo_snaplen);
+#endif
+ ND_TCHECK2(*pptr, length);
calculated_checksum = create_osi_cksum(pptr, checksum_offset, length);
if (checksum == calculated_checksum) {
- printf(" (correct)");
+ ND_PRINT((ndo, " (correct)"));
} else {
- printf(" (incorrect should be 0x%04x)", calculated_checksum);
+ ND_PRINT((ndo, " (incorrect should be 0x%04x)", calculated_checksum));
}
+ return 1;
}
+trunc:
+ return 0;
}
/*
@@ -3115,3 +3149,6 @@ osi_print_cksum (const u_int8_t *pptr, u_int16_t checksum,
* c-basic-offset: 8
* End:
*/
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-isoclns-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-juniper.c b/freebsd/contrib/tcpdump/print-juniper.c
index e221835f..4130ed6f 100644
--- a/freebsd/contrib/tcpdump/print-juniper.c
+++ b/freebsd/contrib/tcpdump/print-juniper.c
@@ -1,8 +1,11 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/* NetBSD: print-juniper.c,v 1.2 2007/07/24 11:53:45 drochner Exp */
-/*
+/*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code
* distributions retain the above copyright notice and this paragraph
@@ -17,9 +20,9 @@
* Original code by Hannes Gredler (hannes@juniper.net)
*/
+/* \summary: DLT_JUNIPER_* printers */
+
#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-juniper.c,v 1.34 2007-08-29 02:31:44 mcr Exp $ (LBL)";
#else
__RCSID("NetBSD: print-juniper.c,v 1.3 2007/07/25 06:31:32 dogcow Exp ");
#endif
@@ -28,12 +31,11 @@ __RCSID("NetBSD: print-juniper.c,v 1.3 2007/07/25 06:31:32 dogcow Exp ");
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include <pcap.h>
-#include <stdio.h>
+#include <string.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "extract.h"
#include "ppp.h"
@@ -67,7 +69,7 @@ __RCSID("NetBSD: print-juniper.c,v 1.3 2007/07/25 06:31:32 dogcow Exp ");
#define JUNIPER_IPSEC_O_AH_AUTHENTICATION_TYPE 4
#define JUNIPER_IPSEC_O_ESP_ENCRYPTION_TYPE 5
-static struct tok juniper_ipsec_type_values[] = {
+static const struct tok juniper_ipsec_type_values[] = {
{ JUNIPER_IPSEC_O_ESP_ENCRYPT_ESP_AUTHEN_TYPE, "ESP ENCR-AUTH" },
{ JUNIPER_IPSEC_O_ESP_ENCRYPT_AH_AUTHEN_TYPE, "ESP ENCR-AH AUTH" },
{ JUNIPER_IPSEC_O_ESP_AUTHENTICATION_TYPE, "ESP AUTH" },
@@ -76,7 +78,7 @@ static struct tok juniper_ipsec_type_values[] = {
{ 0, NULL}
};
-static struct tok juniper_direction_values[] = {
+static const struct tok juniper_direction_values[] = {
{ JUNIPER_BPF_IN, "In"},
{ JUNIPER_BPF_OUT, "Out"},
{ 0, NULL}
@@ -89,15 +91,15 @@ enum {
JUNIPER_EXT_TLV_IFD_MEDIATYPE = 3,
JUNIPER_EXT_TLV_IFL_IDX = 4,
JUNIPER_EXT_TLV_IFL_UNIT = 5,
- JUNIPER_EXT_TLV_IFL_ENCAPS = 6,
- JUNIPER_EXT_TLV_TTP_IFD_MEDIATYPE = 7,
+ JUNIPER_EXT_TLV_IFL_ENCAPS = 6,
+ JUNIPER_EXT_TLV_TTP_IFD_MEDIATYPE = 7,
JUNIPER_EXT_TLV_TTP_IFL_ENCAPS = 8
};
/* 1 byte type and 1-byte length */
-#define JUNIPER_EXT_TLV_OVERHEAD 2
+#define JUNIPER_EXT_TLV_OVERHEAD 2U
-struct tok jnx_ext_tlv_values[] = {
+static const struct tok jnx_ext_tlv_values[] = {
{ JUNIPER_EXT_TLV_IFD_IDX, "Device Interface Index" },
{ JUNIPER_EXT_TLV_IFD_NAME,"Device Interface Name" },
{ JUNIPER_EXT_TLV_IFD_MEDIATYPE, "Device Media Type" },
@@ -109,7 +111,7 @@ struct tok jnx_ext_tlv_values[] = {
{ 0, NULL }
};
-struct tok jnx_flag_values[] = {
+static const struct tok jnx_flag_values[] = {
{ JUNIPER_BPF_EXT, "Ext" },
{ JUNIPER_BPF_FILTER, "Filter" },
{ JUNIPER_BPF_IIF, "IIF" },
@@ -179,7 +181,7 @@ struct tok jnx_flag_values[] = {
#define JUNIPER_IFML_DFC 59
#define JUNIPER_IFML_PICPEER 60
-struct tok juniper_ifmt_values[] = {
+static const struct tok juniper_ifmt_values[] = {
{ JUNIPER_IFML_ETHER, "Ethernet" },
{ JUNIPER_IFML_FDDI, "FDDI" },
{ JUNIPER_IFML_TOKENRING, "Token-Ring" },
@@ -302,7 +304,7 @@ struct tok juniper_ifmt_values[] = {
#define JUNIPER_IFLE_DFC 66
#define JUNIPER_IFLE_PICPEER 67
-struct tok juniper_ifle_values[] = {
+static const struct tok juniper_ifle_values[] = {
{ JUNIPER_IFLE_AGGREGATOR, "Aggregator" },
{ JUNIPER_IFLE_ATM_CCC, "CCC over ATM" },
{ JUNIPER_IFLE_ATM_CELLRELAY_CCC, "ATM CCC Cell Relay" },
@@ -368,12 +370,12 @@ struct tok juniper_ifle_values[] = {
};
struct juniper_cookie_table_t {
- u_int32_t pictype; /* pic type */
- u_int8_t cookie_len; /* cookie len */
+ uint32_t pictype; /* pic type */
+ uint8_t cookie_len; /* cookie len */
const char *s; /* pic name */
};
-static struct juniper_cookie_table_t juniper_cookie_table[] = {
+static const struct juniper_cookie_table_t juniper_cookie_table[] = {
#ifdef DLT_JUNIPER_ATM1
{ DLT_JUNIPER_ATM1, 4, "ATM1"},
#endif
@@ -411,17 +413,17 @@ static struct juniper_cookie_table_t juniper_cookie_table[] = {
};
struct juniper_l2info_t {
- u_int32_t length;
- u_int32_t caplen;
- u_int32_t pictype;
- u_int8_t direction;
- u_int8_t header_len;
- u_int8_t cookie_len;
- u_int8_t cookie_type;
- u_int8_t cookie[8];
- u_int8_t bundle;
- u_int16_t proto;
- u_int8_t flags;
+ uint32_t length;
+ uint32_t caplen;
+ uint32_t pictype;
+ uint8_t direction;
+ uint8_t header_len;
+ uint8_t cookie_len;
+ uint8_t cookie_type;
+ uint8_t cookie[8];
+ uint8_t bundle;
+ uint16_t proto;
+ uint8_t flags;
};
#define LS_COOKIE_ID 0x54
@@ -441,59 +443,57 @@ struct juniper_l2info_t {
#define MFR_BE_MASK 0xc0
-static struct tok juniper_protocol_values[] = {
+static const struct tok juniper_protocol_values[] = {
{ JUNIPER_PROTO_NULL, "Null" },
{ JUNIPER_PROTO_IPV4, "IPv4" },
{ JUNIPER_PROTO_IPV6, "IPv6" },
{ 0, NULL}
};
-int ip_heuristic_guess(register const u_char *, u_int);
-int juniper_ppp_heuristic_guess(register const u_char *, u_int);
-int juniper_read_tlv_value(const u_char *, u_int, u_int);
-static int juniper_parse_header (const u_char *, const struct pcap_pkthdr *, struct juniper_l2info_t *);
+static int ip_heuristic_guess(netdissect_options *, register const u_char *, u_int);
+static int juniper_ppp_heuristic_guess(netdissect_options *, register const u_char *, u_int);
+static int juniper_parse_header(netdissect_options *, const u_char *, const struct pcap_pkthdr *, struct juniper_l2info_t *);
#ifdef DLT_JUNIPER_GGSN
u_int
-juniper_ggsn_print(const struct pcap_pkthdr *h, register const u_char *p)
+juniper_ggsn_print(netdissect_options *ndo,
+ const struct pcap_pkthdr *h, register const u_char *p)
{
struct juniper_l2info_t l2info;
struct juniper_ggsn_header {
- u_int8_t svc_id;
- u_int8_t flags_len;
- u_int8_t proto;
- u_int8_t flags;
- u_int8_t vlan_id[2];
- u_int8_t res[2];
+ uint8_t svc_id;
+ uint8_t flags_len;
+ uint8_t proto;
+ uint8_t flags;
+ uint8_t vlan_id[2];
+ uint8_t res[2];
};
const struct juniper_ggsn_header *gh;
l2info.pictype = DLT_JUNIPER_GGSN;
- if(juniper_parse_header(p, h, &l2info) == 0)
+ if (juniper_parse_header(ndo, p, h, &l2info) == 0)
return l2info.header_len;
p+=l2info.header_len;
gh = (struct juniper_ggsn_header *)&l2info.cookie;
- if (eflag) {
- printf("proto %s (%u), vlan %u: ",
+ if (ndo->ndo_eflag) {
+ ND_PRINT((ndo, "proto %s (%u), vlan %u: ",
tok2str(juniper_protocol_values,"Unknown",gh->proto),
gh->proto,
- EXTRACT_16BITS(&gh->vlan_id[0]));
+ EXTRACT_16BITS(&gh->vlan_id[0])));
}
switch (gh->proto) {
case JUNIPER_PROTO_IPV4:
- ip_print(gndo, p, l2info.length);
+ ip_print(ndo, p, l2info.length);
break;
-#ifdef INET6
case JUNIPER_PROTO_IPV6:
- ip6_print(gndo, p, l2info.length);
+ ip6_print(ndo, p, l2info.length);
break;
-#endif /* INET6 */
default:
- if (!eflag)
- printf("unknown GGSN proto (%u)", gh->proto);
+ if (!ndo->ndo_eflag)
+ ND_PRINT((ndo, "unknown GGSN proto (%u)", gh->proto));
}
return l2info.header_len;
@@ -502,26 +502,27 @@ juniper_ggsn_print(const struct pcap_pkthdr *h, register const u_char *p)
#ifdef DLT_JUNIPER_ES
u_int
-juniper_es_print(const struct pcap_pkthdr *h, register const u_char *p)
+juniper_es_print(netdissect_options *ndo,
+ const struct pcap_pkthdr *h, register const u_char *p)
{
struct juniper_l2info_t l2info;
struct juniper_ipsec_header {
- u_int8_t sa_index[2];
- u_int8_t ttl;
- u_int8_t type;
- u_int8_t spi[4];
- u_int8_t src_ip[4];
- u_int8_t dst_ip[4];
+ uint8_t sa_index[2];
+ uint8_t ttl;
+ uint8_t type;
+ uint8_t spi[4];
+ uint8_t src_ip[4];
+ uint8_t dst_ip[4];
};
u_int rewrite_len,es_type_bundle;
const struct juniper_ipsec_header *ih;
l2info.pictype = DLT_JUNIPER_ES;
- if(juniper_parse_header(p, h, &l2info) == 0)
+ if (juniper_parse_header(ndo, p, h, &l2info) == 0)
return l2info.header_len;
p+=l2info.header_len;
- ih = (struct juniper_ipsec_header *)p;
+ ih = (const struct juniper_ipsec_header *)p;
switch (ih->type) {
case JUNIPER_IPSEC_O_ESP_ENCRYPT_ESP_AUTHEN_TYPE:
@@ -534,70 +535,72 @@ juniper_es_print(const struct pcap_pkthdr *h, register const u_char *p)
case JUNIPER_IPSEC_O_ESP_ENCRYPTION_TYPE:
rewrite_len = 16;
es_type_bundle = 0;
+ break;
default:
- printf("ES Invalid type %u, length %u",
+ ND_PRINT((ndo, "ES Invalid type %u, length %u",
ih->type,
- l2info.length);
+ l2info.length));
return l2info.header_len;
}
l2info.length-=rewrite_len;
p+=rewrite_len;
- if (eflag) {
+ if (ndo->ndo_eflag) {
if (!es_type_bundle) {
- printf("ES SA, index %u, ttl %u type %s (%u), spi %u, Tunnel %s > %s, length %u\n",
+ ND_PRINT((ndo, "ES SA, index %u, ttl %u type %s (%u), spi %u, Tunnel %s > %s, length %u\n",
EXTRACT_16BITS(&ih->sa_index),
- ih->ttl,
+ ih->ttl,
tok2str(juniper_ipsec_type_values,"Unknown",ih->type),
ih->type,
EXTRACT_32BITS(&ih->spi),
- ipaddr_string(&ih->src_ip),
- ipaddr_string(&ih->dst_ip),
- l2info.length);
+ ipaddr_string(ndo, &ih->src_ip),
+ ipaddr_string(ndo, &ih->dst_ip),
+ l2info.length));
} else {
- printf("ES SA, index %u, ttl %u type %s (%u), length %u\n",
+ ND_PRINT((ndo, "ES SA, index %u, ttl %u type %s (%u), length %u\n",
EXTRACT_16BITS(&ih->sa_index),
- ih->ttl,
+ ih->ttl,
tok2str(juniper_ipsec_type_values,"Unknown",ih->type),
ih->type,
- l2info.length);
+ l2info.length));
}
}
- ip_print(gndo, p, l2info.length);
+ ip_print(ndo, p, l2info.length);
return l2info.header_len;
}
#endif
#ifdef DLT_JUNIPER_MONITOR
u_int
-juniper_monitor_print(const struct pcap_pkthdr *h, register const u_char *p)
+juniper_monitor_print(netdissect_options *ndo,
+ const struct pcap_pkthdr *h, register const u_char *p)
{
struct juniper_l2info_t l2info;
struct juniper_monitor_header {
- u_int8_t pkt_type;
- u_int8_t padding;
- u_int8_t iif[2];
- u_int8_t service_id[4];
+ uint8_t pkt_type;
+ uint8_t padding;
+ uint8_t iif[2];
+ uint8_t service_id[4];
};
const struct juniper_monitor_header *mh;
l2info.pictype = DLT_JUNIPER_MONITOR;
- if(juniper_parse_header(p, h, &l2info) == 0)
+ if (juniper_parse_header(ndo, p, h, &l2info) == 0)
return l2info.header_len;
p+=l2info.header_len;
- mh = (struct juniper_monitor_header *)p;
+ mh = (const struct juniper_monitor_header *)p;
- if (eflag)
- printf("service-id %u, iif %u, pkt-type %u: ",
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, "service-id %u, iif %u, pkt-type %u: ",
EXTRACT_32BITS(&mh->service_id),
EXTRACT_16BITS(&mh->iif),
- mh->pkt_type);
+ mh->pkt_type));
/* no proto field - lets guess by first byte of IP header*/
- ip_heuristic_guess(p, l2info.length);
+ ip_heuristic_guess (ndo, p, l2info.length);
return l2info.header_len;
}
@@ -605,33 +608,34 @@ juniper_monitor_print(const struct pcap_pkthdr *h, register const u_char *p)
#ifdef DLT_JUNIPER_SERVICES
u_int
-juniper_services_print(const struct pcap_pkthdr *h, register const u_char *p)
+juniper_services_print(netdissect_options *ndo,
+ const struct pcap_pkthdr *h, register const u_char *p)
{
struct juniper_l2info_t l2info;
struct juniper_services_header {
- u_int8_t svc_id;
- u_int8_t flags_len;
- u_int8_t svc_set_id[2];
- u_int8_t dir_iif[4];
+ uint8_t svc_id;
+ uint8_t flags_len;
+ uint8_t svc_set_id[2];
+ uint8_t dir_iif[4];
};
const struct juniper_services_header *sh;
l2info.pictype = DLT_JUNIPER_SERVICES;
- if(juniper_parse_header(p, h, &l2info) == 0)
+ if (juniper_parse_header(ndo, p, h, &l2info) == 0)
return l2info.header_len;
p+=l2info.header_len;
- sh = (struct juniper_services_header *)p;
+ sh = (const struct juniper_services_header *)p;
- if (eflag)
- printf("service-id %u flags 0x%02x service-set-id 0x%04x iif %u: ",
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, "service-id %u flags 0x%02x service-set-id 0x%04x iif %u: ",
sh->svc_id,
sh->flags_len,
EXTRACT_16BITS(&sh->svc_set_id),
- EXTRACT_24BITS(&sh->dir_iif[1]));
+ EXTRACT_24BITS(&sh->dir_iif[1])));
/* no proto field - lets guess by first byte of IP header*/
- ip_heuristic_guess(p, l2info.length);
+ ip_heuristic_guess (ndo, p, l2info.length);
return l2info.header_len;
}
@@ -639,98 +643,104 @@ juniper_services_print(const struct pcap_pkthdr *h, register const u_char *p)
#ifdef DLT_JUNIPER_PPPOE
u_int
-juniper_pppoe_print(const struct pcap_pkthdr *h, register const u_char *p)
+juniper_pppoe_print(netdissect_options *ndo,
+ const struct pcap_pkthdr *h, register const u_char *p)
{
struct juniper_l2info_t l2info;
l2info.pictype = DLT_JUNIPER_PPPOE;
- if(juniper_parse_header(p, h, &l2info) == 0)
+ if (juniper_parse_header(ndo, p, h, &l2info) == 0)
return l2info.header_len;
p+=l2info.header_len;
/* this DLT contains nothing but raw ethernet frames */
- ether_print(gndo, p, l2info.length, l2info.caplen, NULL, NULL);
+ ether_print(ndo, p, l2info.length, l2info.caplen, NULL, NULL);
return l2info.header_len;
}
#endif
#ifdef DLT_JUNIPER_ETHER
u_int
-juniper_ether_print(const struct pcap_pkthdr *h, register const u_char *p)
+juniper_ether_print(netdissect_options *ndo,
+ const struct pcap_pkthdr *h, register const u_char *p)
{
struct juniper_l2info_t l2info;
l2info.pictype = DLT_JUNIPER_ETHER;
- if(juniper_parse_header(p, h, &l2info) == 0)
+ if (juniper_parse_header(ndo, p, h, &l2info) == 0)
return l2info.header_len;
p+=l2info.header_len;
/* this DLT contains nothing but raw Ethernet frames */
- ether_print(gndo, p, l2info.length, l2info.caplen, NULL, NULL);
+ ether_print(ndo, p, l2info.length, l2info.caplen, NULL, NULL);
return l2info.header_len;
}
#endif
#ifdef DLT_JUNIPER_PPP
u_int
-juniper_ppp_print(const struct pcap_pkthdr *h, register const u_char *p)
+juniper_ppp_print(netdissect_options *ndo,
+ const struct pcap_pkthdr *h, register const u_char *p)
{
struct juniper_l2info_t l2info;
l2info.pictype = DLT_JUNIPER_PPP;
- if(juniper_parse_header(p, h, &l2info) == 0)
+ if (juniper_parse_header(ndo, p, h, &l2info) == 0)
return l2info.header_len;
p+=l2info.header_len;
/* this DLT contains nothing but raw ppp frames */
- ppp_print(p, l2info.length);
+ ppp_print(ndo, p, l2info.length);
return l2info.header_len;
}
#endif
#ifdef DLT_JUNIPER_FRELAY
u_int
-juniper_frelay_print(const struct pcap_pkthdr *h, register const u_char *p)
+juniper_frelay_print(netdissect_options *ndo,
+ const struct pcap_pkthdr *h, register const u_char *p)
{
struct juniper_l2info_t l2info;
l2info.pictype = DLT_JUNIPER_FRELAY;
- if(juniper_parse_header(p, h, &l2info) == 0)
+ if (juniper_parse_header(ndo, p, h, &l2info) == 0)
return l2info.header_len;
p+=l2info.header_len;
/* this DLT contains nothing but raw frame-relay frames */
- fr_print(p, l2info.length);
+ fr_print(ndo, p, l2info.length);
return l2info.header_len;
}
#endif
#ifdef DLT_JUNIPER_CHDLC
u_int
-juniper_chdlc_print(const struct pcap_pkthdr *h, register const u_char *p)
+juniper_chdlc_print(netdissect_options *ndo,
+ const struct pcap_pkthdr *h, register const u_char *p)
{
struct juniper_l2info_t l2info;
l2info.pictype = DLT_JUNIPER_CHDLC;
- if(juniper_parse_header(p, h, &l2info) == 0)
+ if (juniper_parse_header(ndo, p, h, &l2info) == 0)
return l2info.header_len;
p+=l2info.header_len;
/* this DLT contains nothing but raw c-hdlc frames */
- chdlc_print(p, l2info.length);
+ chdlc_print(ndo, p, l2info.length);
return l2info.header_len;
}
#endif
#ifdef DLT_JUNIPER_PPPOE_ATM
u_int
-juniper_pppoe_atm_print(const struct pcap_pkthdr *h, register const u_char *p)
+juniper_pppoe_atm_print(netdissect_options *ndo,
+ const struct pcap_pkthdr *h, register const u_char *p)
{
struct juniper_l2info_t l2info;
- u_int16_t extracted_ethertype;
+ uint16_t extracted_ethertype;
l2info.pictype = DLT_JUNIPER_PPPOE_ATM;
- if(juniper_parse_header(p, h, &l2info) == 0)
+ if (juniper_parse_header(ndo, p, h, &l2info) == 0)
return l2info.header_len;
p+=l2info.header_len;
@@ -738,33 +748,35 @@ juniper_pppoe_atm_print(const struct pcap_pkthdr *h, register const u_char *p)
extracted_ethertype = EXTRACT_16BITS(p);
/* this DLT contains nothing but raw PPPoE frames,
* prepended with a type field*/
- if (ethertype_print(gndo, extracted_ethertype,
+ if (ethertype_print(ndo, extracted_ethertype,
p+ETHERTYPE_LEN,
l2info.length-ETHERTYPE_LEN,
- l2info.caplen-ETHERTYPE_LEN) == 0)
+ l2info.caplen-ETHERTYPE_LEN,
+ NULL, NULL) == 0)
/* ether_type not known, probably it wasn't one */
- printf("unknown ethertype 0x%04x", extracted_ethertype);
-
+ ND_PRINT((ndo, "unknown ethertype 0x%04x", extracted_ethertype));
+
return l2info.header_len;
}
#endif
#ifdef DLT_JUNIPER_MLPPP
u_int
-juniper_mlppp_print(const struct pcap_pkthdr *h, register const u_char *p)
+juniper_mlppp_print(netdissect_options *ndo,
+ const struct pcap_pkthdr *h, register const u_char *p)
{
struct juniper_l2info_t l2info;
l2info.pictype = DLT_JUNIPER_MLPPP;
- if(juniper_parse_header(p, h, &l2info) == 0)
+ if (juniper_parse_header(ndo, p, h, &l2info) == 0)
return l2info.header_len;
/* suppress Bundle-ID if frame was captured on a child-link
* best indicator if the cookie looks like a proto */
- if (eflag &&
+ if (ndo->ndo_eflag &&
EXTRACT_16BITS(&l2info.cookie) != PPP_OSI &&
EXTRACT_16BITS(&l2info.cookie) != (PPP_ADDRESS << 8 | PPP_CONTROL))
- printf("Bundle-ID %u: ",l2info.bundle);
+ ND_PRINT((ndo, "Bundle-ID %u: ", l2info.bundle));
p+=l2info.header_len;
@@ -775,20 +787,18 @@ juniper_mlppp_print(const struct pcap_pkthdr *h, register const u_char *p)
* -> this must be incoming IS-IS over PPP
*/
if (l2info.cookie[4] == (JUNIPER_LSQ_COOKIE_RE|JUNIPER_LSQ_COOKIE_DIR))
- ppp_print(p, l2info.length);
+ ppp_print(ndo, p, l2info.length);
else
- ip_print(gndo, p, l2info.length);
+ ip_print(ndo, p, l2info.length);
return l2info.header_len;
-#ifdef INET6
case JUNIPER_LSQ_L3_PROTO_IPV6:
- ip6_print(gndo, p,l2info.length);
+ ip6_print(ndo, p,l2info.length);
return l2info.header_len;
-#endif
case JUNIPER_LSQ_L3_PROTO_MPLS:
- mpls_print(p,l2info.length);
+ mpls_print(ndo, p, l2info.length);
return l2info.header_len;
case JUNIPER_LSQ_L3_PROTO_ISO:
- isoclns_print(p,l2info.length,l2info.caplen);
+ isoclns_print(ndo, p, l2info.length, l2info.caplen);
return l2info.header_len;
default:
break;
@@ -797,11 +807,11 @@ juniper_mlppp_print(const struct pcap_pkthdr *h, register const u_char *p)
/* zero length cookie ? */
switch (EXTRACT_16BITS(&l2info.cookie)) {
case PPP_OSI:
- ppp_print(p-2,l2info.length+2);
+ ppp_print(ndo, p - 2, l2info.length + 2);
break;
case (PPP_ADDRESS << 8 | PPP_CONTROL): /* fall through */
default:
- ppp_print(p,l2info.length);
+ ppp_print(ndo, p, l2info.length);
break;
}
@@ -812,19 +822,21 @@ juniper_mlppp_print(const struct pcap_pkthdr *h, register const u_char *p)
#ifdef DLT_JUNIPER_MFR
u_int
-juniper_mfr_print(const struct pcap_pkthdr *h, register const u_char *p)
+juniper_mfr_print(netdissect_options *ndo,
+ const struct pcap_pkthdr *h, register const u_char *p)
{
struct juniper_l2info_t l2info;
+ memset(&l2info, 0, sizeof(l2info));
l2info.pictype = DLT_JUNIPER_MFR;
- if(juniper_parse_header(p, h, &l2info) == 0)
+ if (juniper_parse_header(ndo, p, h, &l2info) == 0)
return l2info.header_len;
-
+
p+=l2info.header_len;
/* child-link ? */
if (l2info.cookie_len == 0) {
- mfr_print(p,l2info.length);
+ mfr_print(ndo, p, l2info.length);
return l2info.header_len;
}
@@ -832,18 +844,16 @@ juniper_mfr_print(const struct pcap_pkthdr *h, register const u_char *p)
if (l2info.cookie_len == AS_PIC_COOKIE_LEN) {
switch(l2info.proto) {
case JUNIPER_LSQ_L3_PROTO_IPV4:
- ip_print(gndo, p, l2info.length);
+ ip_print(ndo, p, l2info.length);
return l2info.header_len;
-#ifdef INET6
case JUNIPER_LSQ_L3_PROTO_IPV6:
- ip6_print(gndo, p,l2info.length);
+ ip6_print(ndo, p,l2info.length);
return l2info.header_len;
-#endif
case JUNIPER_LSQ_L3_PROTO_MPLS:
- mpls_print(p,l2info.length);
+ mpls_print(ndo, p, l2info.length);
return l2info.header_len;
case JUNIPER_LSQ_L3_PROTO_ISO:
- isoclns_print(p,l2info.length,l2info.caplen);
+ isoclns_print(ndo, p, l2info.length, l2info.caplen);
return l2info.header_len;
default:
break;
@@ -852,19 +862,20 @@ juniper_mfr_print(const struct pcap_pkthdr *h, register const u_char *p)
}
/* suppress Bundle-ID if frame was captured on a child-link */
- if (eflag && EXTRACT_32BITS(l2info.cookie) != 1) printf("Bundle-ID %u, ",l2info.bundle);
+ if (ndo->ndo_eflag && EXTRACT_32BITS(l2info.cookie) != 1)
+ ND_PRINT((ndo, "Bundle-ID %u, ", l2info.bundle));
switch (l2info.proto) {
case (LLCSAP_ISONS<<8 | LLCSAP_ISONS):
- isoclns_print(p+1, l2info.length-1, l2info.caplen-1);
+ isoclns_print(ndo, p + 1, l2info.length - 1, l2info.caplen - 1);
break;
case (LLC_UI<<8 | NLPID_Q933):
case (LLC_UI<<8 | NLPID_IP):
case (LLC_UI<<8 | NLPID_IP6):
/* pass IP{4,6} to the OSI layer for proper link-layer printing */
- isoclns_print(p-1, l2info.length+1, l2info.caplen+1);
+ isoclns_print(ndo, p - 1, l2info.length + 1, l2info.caplen + 1);
break;
default:
- printf("unknown protocol 0x%04x, length %u",l2info.proto, l2info.length);
+ ND_PRINT((ndo, "unknown protocol 0x%04x, length %u", l2info.proto, l2info.length));
}
return l2info.header_len;
@@ -873,31 +884,33 @@ juniper_mfr_print(const struct pcap_pkthdr *h, register const u_char *p)
#ifdef DLT_JUNIPER_MLFR
u_int
-juniper_mlfr_print(const struct pcap_pkthdr *h, register const u_char *p)
+juniper_mlfr_print(netdissect_options *ndo,
+ const struct pcap_pkthdr *h, register const u_char *p)
{
struct juniper_l2info_t l2info;
l2info.pictype = DLT_JUNIPER_MLFR;
- if(juniper_parse_header(p, h, &l2info) == 0)
+ if (juniper_parse_header(ndo, p, h, &l2info) == 0)
return l2info.header_len;
p+=l2info.header_len;
/* suppress Bundle-ID if frame was captured on a child-link */
- if (eflag && EXTRACT_32BITS(l2info.cookie) != 1) printf("Bundle-ID %u, ",l2info.bundle);
+ if (ndo->ndo_eflag && EXTRACT_32BITS(l2info.cookie) != 1)
+ ND_PRINT((ndo, "Bundle-ID %u, ", l2info.bundle));
switch (l2info.proto) {
case (LLC_UI):
case (LLC_UI<<8):
- isoclns_print(p, l2info.length, l2info.caplen);
+ isoclns_print(ndo, p, l2info.length, l2info.caplen);
break;
case (LLC_UI<<8 | NLPID_Q933):
case (LLC_UI<<8 | NLPID_IP):
case (LLC_UI<<8 | NLPID_IP6):
/* pass IP{4,6} to the OSI layer for proper link-layer printing */
- isoclns_print(p-1, l2info.length+1, l2info.caplen+1);
+ isoclns_print(ndo, p - 1, l2info.length + 1, l2info.caplen + 1);
break;
default:
- printf("unknown protocol 0x%04x, length %u",l2info.proto, l2info.length);
+ ND_PRINT((ndo, "unknown protocol 0x%04x, length %u", l2info.proto, l2info.length));
}
return l2info.header_len;
@@ -914,38 +927,39 @@ juniper_mlfr_print(const struct pcap_pkthdr *h, register const u_char *p)
#ifdef DLT_JUNIPER_ATM1
u_int
-juniper_atm1_print(const struct pcap_pkthdr *h, register const u_char *p)
+juniper_atm1_print(netdissect_options *ndo,
+ const struct pcap_pkthdr *h, register const u_char *p)
{
- u_int16_t extracted_ethertype;
+ int llc_hdrlen;
struct juniper_l2info_t l2info;
l2info.pictype = DLT_JUNIPER_ATM1;
- if(juniper_parse_header(p, h, &l2info) == 0)
+ if (juniper_parse_header(ndo, p, h, &l2info) == 0)
return l2info.header_len;
p+=l2info.header_len;
if (l2info.cookie[0] == 0x80) { /* OAM cell ? */
- oam_print(p,l2info.length,ATM_OAM_NOHEC);
+ oam_print(ndo, p, l2info.length, ATM_OAM_NOHEC);
return l2info.header_len;
}
if (EXTRACT_24BITS(p) == 0xfefe03 || /* NLPID encaps ? */
EXTRACT_24BITS(p) == 0xaaaa03) { /* SNAP encaps ? */
- if (llc_print(p, l2info.length, l2info.caplen, NULL, NULL,
- &extracted_ethertype) != 0)
+ llc_hdrlen = llc_print(ndo, p, l2info.length, l2info.caplen, NULL, NULL);
+ if (llc_hdrlen > 0)
return l2info.header_len;
}
if (p[0] == 0x03) { /* Cisco style NLPID encaps ? */
- isoclns_print(p + 1, l2info.length - 1, l2info.caplen - 1);
+ isoclns_print(ndo, p + 1, l2info.length - 1, l2info.caplen - 1);
/* FIXME check if frame was recognized */
return l2info.header_len;
}
- if(ip_heuristic_guess(p, l2info.length) != 0) /* last try - vcmux encaps ? */
+ if (ip_heuristic_guess(ndo, p, l2info.length) != 0) /* last try - vcmux encaps ? */
return l2info.header_len;
return l2info.header_len;
@@ -962,47 +976,48 @@ juniper_atm1_print(const struct pcap_pkthdr *h, register const u_char *p)
#ifdef DLT_JUNIPER_ATM2
u_int
-juniper_atm2_print(const struct pcap_pkthdr *h, register const u_char *p)
+juniper_atm2_print(netdissect_options *ndo,
+ const struct pcap_pkthdr *h, register const u_char *p)
{
- u_int16_t extracted_ethertype;
+ int llc_hdrlen;
struct juniper_l2info_t l2info;
l2info.pictype = DLT_JUNIPER_ATM2;
- if(juniper_parse_header(p, h, &l2info) == 0)
+ if (juniper_parse_header(ndo, p, h, &l2info) == 0)
return l2info.header_len;
p+=l2info.header_len;
if (l2info.cookie[7] & ATM2_PKT_TYPE_MASK) { /* OAM cell ? */
- oam_print(p,l2info.length,ATM_OAM_NOHEC);
+ oam_print(ndo, p, l2info.length, ATM_OAM_NOHEC);
return l2info.header_len;
}
if (EXTRACT_24BITS(p) == 0xfefe03 || /* NLPID encaps ? */
EXTRACT_24BITS(p) == 0xaaaa03) { /* SNAP encaps ? */
- if (llc_print(p, l2info.length, l2info.caplen, NULL, NULL,
- &extracted_ethertype) != 0)
+ llc_hdrlen = llc_print(ndo, p, l2info.length, l2info.caplen, NULL, NULL);
+ if (llc_hdrlen > 0)
return l2info.header_len;
}
if (l2info.direction != JUNIPER_BPF_PKT_IN && /* ether-over-1483 encaps ? */
(EXTRACT_32BITS(l2info.cookie) & ATM2_GAP_COUNT_MASK)) {
- ether_print(gndo, p, l2info.length, l2info.caplen, NULL, NULL);
+ ether_print(ndo, p, l2info.length, l2info.caplen, NULL, NULL);
return l2info.header_len;
}
if (p[0] == 0x03) { /* Cisco style NLPID encaps ? */
- isoclns_print(p + 1, l2info.length - 1, l2info.caplen - 1);
+ isoclns_print(ndo, p + 1, l2info.length - 1, l2info.caplen - 1);
/* FIXME check if frame was recognized */
return l2info.header_len;
}
- if(juniper_ppp_heuristic_guess(p, l2info.length) != 0) /* PPPoA vcmux encaps ? */
+ if(juniper_ppp_heuristic_guess(ndo, p, l2info.length) != 0) /* PPPoA vcmux encaps ? */
return l2info.header_len;
- if(ip_heuristic_guess(p, l2info.length) != 0) /* last try - vcmux encaps ? */
+ if (ip_heuristic_guess(ndo, p, l2info.length) != 0) /* last try - vcmux encaps ? */
return l2info.header_len;
return l2info.header_len;
@@ -1012,9 +1027,10 @@ juniper_atm2_print(const struct pcap_pkthdr *h, register const u_char *p)
/* try to guess, based on all PPP protos that are supported in
* a juniper router if the payload data is encapsulated using PPP */
-int
-juniper_ppp_heuristic_guess(register const u_char *p, u_int length) {
-
+static int
+juniper_ppp_heuristic_guess(netdissect_options *ndo,
+ register const u_char *p, u_int length)
+{
switch(EXTRACT_16BITS(p)) {
case PPP_IP :
case PPP_OSI :
@@ -1027,11 +1043,9 @@ juniper_ppp_heuristic_guess(register const u_char *p, u_int length) {
case PPP_PAP :
case PPP_CHAP :
case PPP_ML :
-#ifdef INET6
case PPP_IPV6 :
case PPP_IPV6CP :
-#endif
- ppp_print(p, length);
+ ppp_print(ndo, p, length);
break;
default:
@@ -1041,9 +1055,10 @@ juniper_ppp_heuristic_guess(register const u_char *p, u_int length) {
return 1; /* we printed a ppp packet */
}
-int
-ip_heuristic_guess(register const u_char *p, u_int length) {
-
+static int
+ip_heuristic_guess(netdissect_options *ndo,
+ register const u_char *p, u_int length)
+{
switch(p[0]) {
case 0x45:
case 0x46:
@@ -1056,9 +1071,8 @@ ip_heuristic_guess(register const u_char *p, u_int length) {
case 0x4d:
case 0x4e:
case 0x4f:
- ip_print(gndo, p, length);
+ ip_print(ndo, p, length);
break;
-#ifdef INET6
case 0x60:
case 0x61:
case 0x62:
@@ -1075,9 +1089,8 @@ ip_heuristic_guess(register const u_char *p, u_int length) {
case 0x6d:
case 0x6e:
case 0x6f:
- ip6_print(gndo, p, length);
+ ip6_print(ndo, p, length);
break;
-#endif
default:
return 0; /* did not find a ip header */
break;
@@ -1085,9 +1098,9 @@ ip_heuristic_guess(register const u_char *p, u_int length) {
return 1; /* we printed an v4/v6 packet */
}
-int
-juniper_read_tlv_value(const u_char *p, u_int tlv_type, u_int tlv_len) {
-
+static int
+juniper_read_tlv_value(const u_char *p, u_int tlv_type, u_int tlv_len)
+{
int tlv_value;
/* TLVs < 128 are little endian encoded */
@@ -1133,12 +1146,13 @@ juniper_read_tlv_value(const u_char *p, u_int tlv_type, u_int tlv_len) {
}
static int
-juniper_parse_header (const u_char *p, const struct pcap_pkthdr *h, struct juniper_l2info_t *l2info) {
-
- struct juniper_cookie_table_t *lp = juniper_cookie_table;
+juniper_parse_header(netdissect_options *ndo,
+ const u_char *p, const struct pcap_pkthdr *h, struct juniper_l2info_t *l2info)
+{
+ const struct juniper_cookie_table_t *lp = juniper_cookie_table;
u_int idx, jnx_ext_len, jnx_header_len = 0;
- u_int8_t tlv_type,tlv_len;
- u_int32_t control_word;
+ uint8_t tlv_type,tlv_len;
+ uint32_t control_word;
int tlv_value;
const u_char *tptr;
@@ -1150,24 +1164,24 @@ juniper_parse_header (const u_char *p, const struct pcap_pkthdr *h, struct junip
l2info->length = h->len;
l2info->caplen = h->caplen;
- TCHECK2(p[0],4);
+ ND_TCHECK2(p[0], 4);
l2info->flags = p[3];
l2info->direction = p[3]&JUNIPER_BPF_PKT_IN;
-
+
if (EXTRACT_24BITS(p) != JUNIPER_MGC_NUMBER) { /* magic number found ? */
- printf("no magic-number found!");
+ ND_PRINT((ndo, "no magic-number found!"));
return 0;
- }
+ }
- if (eflag) /* print direction */
- printf("%3s ",tok2str(juniper_direction_values,"---",l2info->direction));
+ if (ndo->ndo_eflag) /* print direction */
+ ND_PRINT((ndo, "%3s ", tok2str(juniper_direction_values, "---", l2info->direction)));
/* magic number + flags */
jnx_header_len = 4;
- if (vflag>1)
- printf("\n\tJuniper PCAP Flags [%s]",
- bittok2str(jnx_flag_values, "none", l2info->flags));
+ if (ndo->ndo_vflag > 1)
+ ND_PRINT((ndo, "\n\tJuniper PCAP Flags [%s]",
+ bittok2str(jnx_flag_values, "none", l2info->flags)));
/* extensions present ? - calculate how much bytes to skip */
if ((l2info->flags & JUNIPER_BPF_EXT ) == JUNIPER_BPF_EXT ) {
@@ -1175,36 +1189,37 @@ juniper_parse_header (const u_char *p, const struct pcap_pkthdr *h, struct junip
tptr = p+jnx_header_len;
/* ok to read extension length ? */
- TCHECK2(tptr[0], 2);
+ ND_TCHECK2(tptr[0], 2);
jnx_ext_len = EXTRACT_16BITS(tptr);
jnx_header_len += 2;
tptr +=2;
-
+
/* nail up the total length -
* just in case something goes wrong
* with TLV parsing */
jnx_header_len += jnx_ext_len;
-
- if (vflag>1)
- printf(", PCAP Extension(s) total length %u",
- jnx_ext_len);
-
- TCHECK2(tptr[0], jnx_ext_len);
+
+ if (ndo->ndo_vflag > 1)
+ ND_PRINT((ndo, ", PCAP Extension(s) total length %u", jnx_ext_len));
+
+ ND_TCHECK2(tptr[0], jnx_ext_len);
while (jnx_ext_len > JUNIPER_EXT_TLV_OVERHEAD) {
tlv_type = *(tptr++);
tlv_len = *(tptr++);
tlv_value = 0;
-
- /* sanity check */
+
+ /* sanity checks */
if (tlv_type == 0 || tlv_len == 0)
break;
-
- if (vflag>1)
- printf("\n\t %s Extension TLV #%u, length %u, value ",
+ if (tlv_len+JUNIPER_EXT_TLV_OVERHEAD > jnx_ext_len)
+ goto trunc;
+
+ if (ndo->ndo_vflag > 1)
+ ND_PRINT((ndo, "\n\t %s Extension TLV #%u, length %u, value ",
tok2str(jnx_ext_tlv_values,"Unknown",tlv_type),
tlv_type,
- tlv_len);
-
+ tlv_len));
+
tlv_value = juniper_read_tlv_value(tptr, tlv_type, tlv_len);
switch (tlv_type) {
case JUNIPER_EXT_TLV_IFD_NAME:
@@ -1213,19 +1228,19 @@ juniper_parse_header (const u_char *p, const struct pcap_pkthdr *h, struct junip
case JUNIPER_EXT_TLV_IFD_MEDIATYPE:
case JUNIPER_EXT_TLV_TTP_IFD_MEDIATYPE:
if (tlv_value != -1) {
- if (vflag>1)
- printf("%s (%u)",
+ if (ndo->ndo_vflag > 1)
+ ND_PRINT((ndo, "%s (%u)",
tok2str(juniper_ifmt_values, "Unknown", tlv_value),
- tlv_value);
+ tlv_value));
}
break;
case JUNIPER_EXT_TLV_IFL_ENCAPS:
case JUNIPER_EXT_TLV_TTP_IFL_ENCAPS:
if (tlv_value != -1) {
- if (vflag>1)
- printf("%s (%u)",
+ if (ndo->ndo_vflag > 1)
+ ND_PRINT((ndo, "%s (%u)",
tok2str(juniper_ifle_values, "Unknown", tlv_value),
- tlv_value);
+ tlv_value));
}
break;
case JUNIPER_EXT_TLV_IFL_IDX: /* fall through */
@@ -1233,35 +1248,36 @@ juniper_parse_header (const u_char *p, const struct pcap_pkthdr *h, struct junip
case JUNIPER_EXT_TLV_IFD_IDX:
default:
if (tlv_value != -1) {
- if (vflag>1)
- printf("%u",tlv_value);
+ if (ndo->ndo_vflag > 1)
+ ND_PRINT((ndo, "%u", tlv_value));
}
break;
}
-
+
tptr+=tlv_len;
jnx_ext_len -= tlv_len+JUNIPER_EXT_TLV_OVERHEAD;
}
-
- if (vflag>1)
- printf("\n\t-----original packet-----\n\t");
- }
-
- if ((l2info->flags & JUNIPER_BPF_NO_L2 ) == JUNIPER_BPF_NO_L2 ) {
- if (eflag)
- printf("no-L2-hdr, ");
+
+ if (ndo->ndo_vflag > 1)
+ ND_PRINT((ndo, "\n\t-----original packet-----\n\t"));
+ }
+
+ if ((l2info->flags & JUNIPER_BPF_NO_L2 ) == JUNIPER_BPF_NO_L2 ) {
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, "no-L2-hdr, "));
/* there is no link-layer present -
* perform the v4/v6 heuristics
* to figure out what it is
*/
- TCHECK2(p[jnx_header_len+4],1);
- if(ip_heuristic_guess(p+jnx_header_len+4,l2info->length-(jnx_header_len+4)) == 0)
- printf("no IP-hdr found!");
+ ND_TCHECK2(p[jnx_header_len + 4], 1);
+ if (ip_heuristic_guess(ndo, p + jnx_header_len + 4,
+ l2info->length - (jnx_header_len + 4)) == 0)
+ ND_PRINT((ndo, "no IP-hdr found!"));
l2info->header_len=jnx_header_len+4;
return 0; /* stop parsing the output further */
-
+
}
l2info->header_len = jnx_header_len;
p+=l2info->header_len;
@@ -1283,7 +1299,7 @@ juniper_parse_header (const u_char *p, const struct pcap_pkthdr *h, struct junip
l2info->cookie_type = AS_COOKIE_ID;
l2info->cookie_len = 8;
break;
-
+
default:
l2info->bundle = l2info->cookie[0];
break;
@@ -1302,25 +1318,25 @@ juniper_parse_header (const u_char *p, const struct pcap_pkthdr *h, struct junip
l2info->length -= l2info->cookie_len;
l2info->caplen -= l2info->cookie_len;
- if (eflag)
- printf("%s-PIC, cookie-len %u",
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, "%s-PIC, cookie-len %u",
lp->s,
- l2info->cookie_len);
+ l2info->cookie_len));
if (l2info->cookie_len > 0) {
- TCHECK2(p[0],l2info->cookie_len);
- if (eflag)
- printf(", cookie 0x");
+ ND_TCHECK2(p[0], l2info->cookie_len);
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, ", cookie 0x"));
for (idx = 0; idx < l2info->cookie_len; idx++) {
l2info->cookie[idx] = p[idx]; /* copy cookie data */
- if (eflag) printf("%02x",p[idx]);
+ if (ndo->ndo_eflag) ND_PRINT((ndo, "%02x", p[idx]));
}
}
- if (eflag) printf(": "); /* print demarc b/w L2/L3*/
-
+ if (ndo->ndo_eflag) ND_PRINT((ndo, ": ")); /* print demarc b/w L2/L3*/
- l2info->proto = EXTRACT_16BITS(p+l2info->cookie_len);
+
+ l2info->proto = EXTRACT_16BITS(p+l2info->cookie_len);
break;
}
++lp;
@@ -1337,7 +1353,7 @@ juniper_parse_header (const u_char *p, const struct pcap_pkthdr *h, struct junip
break;
case AS_COOKIE_ID:
l2info->bundle = (EXTRACT_16BITS(&l2info->cookie[6])>>3)&0xfff;
- l2info->proto = (l2info->cookie[5])&JUNIPER_LSQ_L3_PROTO_MASK;
+ l2info->proto = (l2info->cookie[5])&JUNIPER_LSQ_L3_PROTO_MASK;
break;
default:
l2info->bundle = l2info->cookie[0];
@@ -1350,7 +1366,7 @@ juniper_parse_header (const u_char *p, const struct pcap_pkthdr *h, struct junip
switch (l2info->cookie_type) {
case LS_COOKIE_ID:
l2info->bundle = l2info->cookie[1];
- l2info->proto = EXTRACT_16BITS(p);
+ l2info->proto = EXTRACT_16BITS(p);
l2info->header_len += 2;
l2info->length -= 2;
l2info->caplen -= 2;
@@ -1373,7 +1389,7 @@ juniper_parse_header (const u_char *p, const struct pcap_pkthdr *h, struct junip
switch (l2info->cookie_type) {
case LS_COOKIE_ID:
l2info->bundle = l2info->cookie[1];
- l2info->proto = EXTRACT_16BITS(p);
+ l2info->proto = EXTRACT_16BITS(p);
l2info->header_len += 2;
l2info->length -= 2;
l2info->caplen -= 2;
@@ -1390,7 +1406,7 @@ juniper_parse_header (const u_char *p, const struct pcap_pkthdr *h, struct junip
#endif
#ifdef DLT_JUNIPER_ATM2
case DLT_JUNIPER_ATM2:
- TCHECK2(p[0],4);
+ ND_TCHECK2(p[0], 4);
/* ATM cell relay control word present ? */
if (l2info->cookie[7] & ATM2_PKT_TYPE_MASK) {
control_word = EXTRACT_32BITS(p);
@@ -1404,9 +1420,9 @@ juniper_parse_header (const u_char *p, const struct pcap_pkthdr *h, struct junip
default:
break;
}
-
- if (eflag)
- printf("control-word 0x%08x ", control_word);
+
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, "control-word 0x%08x ", control_word));
}
break;
#endif
@@ -1436,16 +1452,16 @@ juniper_parse_header (const u_char *p, const struct pcap_pkthdr *h, struct junip
#endif
default:
- printf("Unknown Juniper DLT_ type %u: ", l2info->pictype);
+ ND_PRINT((ndo, "Unknown Juniper DLT_ type %u: ", l2info->pictype));
break;
}
-
- if (eflag > 1)
- printf("hlen %u, proto 0x%04x, ",l2info->header_len,l2info->proto);
+
+ if (ndo->ndo_eflag > 1)
+ ND_PRINT((ndo, "hlen %u, proto 0x%04x, ", l2info->header_len, l2info->proto));
return 1; /* everything went ok so far. continue parsing */
trunc:
- printf("[|juniper_hdr], length %u",h->len);
+ ND_PRINT((ndo, "[|juniper_hdr], length %u", h->len));
return 0;
}
@@ -1456,3 +1472,6 @@ juniper_parse_header (const u_char *p, const struct pcap_pkthdr *h, struct junip
* c-basic-offset: 4
* End:
*/
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-juniper-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-krb.c b/freebsd/contrib/tcpdump/print-krb.c
index b18203b1..421347b9 100644
--- a/freebsd/contrib/tcpdump/print-krb.c
+++ b/freebsd/contrib/tcpdump/print-krb.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
@@ -23,26 +26,22 @@
* Initial contribution from John Hawkinson (jhawk@mit.edu).
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-krb.c,v 1.23 2003-11-16 09:36:26 guy Exp $";
-#endif
+/* \summary: Kerberos printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
-
-#include <stdio.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
-#include "addrtoname.h"
+#include "netdissect.h"
#include "extract.h"
-static const u_char *c_print(register const u_char *, register const u_char *);
-static const u_char *krb4_print_hdr(const u_char *);
-static void krb4_print(const u_char *);
+static const char tstr[] = " [|kerberos]";
+
+static const u_char *c_print(netdissect_options *, register const u_char *, register const u_char *);
+static const u_char *krb4_print_hdr(netdissect_options *, const u_char *);
+static void krb4_print(netdissect_options *, const u_char *);
#define AUTH_MSG_KDC_REQUEST 1<<1
#define AUTH_MSG_KDC_REPLY 2<<1
@@ -67,13 +66,11 @@ static void krb4_print(const u_char *);
#define KERB_ERR_NULL_KEY 10
struct krb {
- u_int8_t pvno; /* Protocol Version */
- u_int8_t type; /* Type+B */
+ uint8_t pvno; /* Protocol Version */
+ uint8_t type; /* Type+B */
};
-static char tstr[] = " [|kerberos]";
-
-static struct tok type2str[] = {
+static const struct tok type2str[] = {
{ AUTH_MSG_KDC_REQUEST, "KDC_REQUEST" },
{ AUTH_MSG_KDC_REPLY, "KDC_REPLY" },
{ AUTH_MSG_APPL_REQUEST, "APPL_REQUEST" },
@@ -86,7 +83,7 @@ static struct tok type2str[] = {
{ 0, NULL }
};
-static struct tok kerr2str[] = {
+static const struct tok kerr2str[] = {
{ KERB_ERR_OK, "OK" },
{ KERB_ERR_NAME_EXP, "NAME_EXP" },
{ KERB_ERR_SERVICE_EXP, "SERVICE_EXP" },
@@ -102,7 +99,8 @@ static struct tok kerr2str[] = {
};
static const u_char *
-c_print(register const u_char *s, register const u_char *ep)
+c_print(netdissect_options *ndo,
+ register const u_char *s, register const u_char *ep)
{
register u_char c;
register int flag;
@@ -114,16 +112,15 @@ c_print(register const u_char *s, register const u_char *ep)
flag = 0;
break;
}
- if (!isascii(c)) {
- c = toascii(c);
- putchar('M');
- putchar('-');
+ if (!ND_ISASCII(c)) {
+ c = ND_TOASCII(c);
+ ND_PRINT((ndo, "M-"));
}
- if (!isprint(c)) {
+ if (!ND_ISPRINT(c)) {
c ^= 0x40; /* DEL to ?, others to alpha */
- putchar('^');
+ ND_PRINT((ndo, "^"));
}
- putchar(c);
+ ND_PRINT((ndo, "%c", c));
}
if (flag)
return NULL;
@@ -131,112 +128,115 @@ c_print(register const u_char *s, register const u_char *ep)
}
static const u_char *
-krb4_print_hdr(const u_char *cp)
+krb4_print_hdr(netdissect_options *ndo,
+ const u_char *cp)
{
cp += 2;
-#define PRINT if ((cp = c_print(cp, snapend)) == NULL) goto trunc
+#define PRINT if ((cp = c_print(ndo, cp, ndo->ndo_snapend)) == NULL) goto trunc
PRINT;
- putchar('.');
+ ND_PRINT((ndo, "."));
PRINT;
- putchar('@');
+ ND_PRINT((ndo, "@"));
PRINT;
return (cp);
trunc:
- fputs(tstr, stdout);
+ ND_PRINT((ndo, "%s", tstr));
return (NULL);
#undef PRINT
}
static void
-krb4_print(const u_char *cp)
+krb4_print(netdissect_options *ndo,
+ const u_char *cp)
{
register const struct krb *kp;
u_char type;
u_short len;
-#define PRINT if ((cp = c_print(cp, snapend)) == NULL) goto trunc
+#define PRINT if ((cp = c_print(ndo, cp, ndo->ndo_snapend)) == NULL) goto trunc
/* True if struct krb is little endian */
#define IS_LENDIAN(kp) (((kp)->type & 0x01) != 0)
#define KTOHSP(kp, cp) (IS_LENDIAN(kp) ? EXTRACT_LE_16BITS(cp) : EXTRACT_16BITS(cp))
- kp = (struct krb *)cp;
+ kp = (const struct krb *)cp;
- if ((&kp->type) >= snapend) {
- fputs(tstr, stdout);
+ if ((&kp->type) >= ndo->ndo_snapend) {
+ ND_PRINT((ndo, "%s", tstr));
return;
}
type = kp->type & (0xFF << 1);
- printf(" %s %s: ",
- IS_LENDIAN(kp) ? "le" : "be", tok2str(type2str, NULL, type));
+ ND_PRINT((ndo, " %s %s: ",
+ IS_LENDIAN(kp) ? "le" : "be", tok2str(type2str, NULL, type)));
switch (type) {
case AUTH_MSG_KDC_REQUEST:
- if ((cp = krb4_print_hdr(cp)) == NULL)
+ if ((cp = krb4_print_hdr(ndo, cp)) == NULL)
return;
cp += 4; /* ctime */
- TCHECK(*cp);
- printf(" %dmin ", *cp++ * 5);
+ ND_TCHECK(*cp);
+ ND_PRINT((ndo, " %dmin ", *cp++ * 5));
PRINT;
- putchar('.');
+ ND_PRINT((ndo, "."));
PRINT;
break;
case AUTH_MSG_APPL_REQUEST:
cp += 2;
- TCHECK(*cp);
- printf("v%d ", *cp++);
+ ND_TCHECK(*cp);
+ ND_PRINT((ndo, "v%d ", *cp++));
PRINT;
- TCHECK(*cp);
- printf(" (%d)", *cp++);
- TCHECK(*cp);
- printf(" (%d)", *cp);
+ ND_TCHECK(*cp);
+ ND_PRINT((ndo, " (%d)", *cp++));
+ ND_TCHECK(*cp);
+ ND_PRINT((ndo, " (%d)", *cp));
break;
case AUTH_MSG_KDC_REPLY:
- if ((cp = krb4_print_hdr(cp)) == NULL)
+ if ((cp = krb4_print_hdr(ndo, cp)) == NULL)
return;
cp += 10; /* timestamp + n + exp + kvno */
- TCHECK2(*cp, sizeof(short));
+ ND_TCHECK2(*cp, sizeof(short));
len = KTOHSP(kp, cp);
- printf(" (%d)", len);
+ ND_PRINT((ndo, " (%d)", len));
break;
case AUTH_MSG_ERR_REPLY:
- if ((cp = krb4_print_hdr(cp)) == NULL)
+ if ((cp = krb4_print_hdr(ndo, cp)) == NULL)
return;
cp += 4; /* timestamp */
- TCHECK2(*cp, sizeof(short));
- printf(" %s ", tok2str(kerr2str, NULL, KTOHSP(kp, cp)));
+ ND_TCHECK2(*cp, sizeof(short));
+ ND_PRINT((ndo, " %s ", tok2str(kerr2str, NULL, KTOHSP(kp, cp))));
cp += 4;
PRINT;
break;
default:
- fputs("(unknown)", stdout);
+ ND_PRINT((ndo, "(unknown)"));
break;
}
return;
trunc:
- fputs(tstr, stdout);
+ ND_PRINT((ndo, "%s", tstr));
}
void
-krb_print(const u_char *dat)
+krb_print(netdissect_options *ndo,
+ const u_char *dat)
{
register const struct krb *kp;
- kp = (struct krb *)dat;
+ kp = (const struct krb *)dat;
- if (dat >= snapend) {
- fputs(tstr, stdout);
+ if (dat >= ndo->ndo_snapend) {
+ ND_PRINT((ndo, "%s", tstr));
return;
}
@@ -245,19 +245,22 @@ krb_print(const u_char *dat)
case 1:
case 2:
case 3:
- printf(" v%d", kp->pvno);
+ ND_PRINT((ndo, " v%d", kp->pvno));
break;
case 4:
- printf(" v%d", kp->pvno);
- krb4_print((const u_char *)kp);
+ ND_PRINT((ndo, " v%d", kp->pvno));
+ krb4_print(ndo, (const u_char *)kp);
break;
case 106:
case 107:
- fputs(" v5", stdout);
+ ND_PRINT((ndo, " v5"));
/* Decode ASN.1 here "someday" */
break;
}
return;
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-krb-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-l2tp.c b/freebsd/contrib/tcpdump/print-l2tp.c
index d62e1c8e..1b79f92a 100644
--- a/freebsd/contrib/tcpdump/print-l2tp.c
+++ b/freebsd/contrib/tcpdump/print-l2tp.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
@@ -23,24 +26,54 @@
* L2TP support contributed by Motonori Shindo (mshindo@mshindo.net)
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-l2tp.c,v 1.20 2006-06-23 02:03:09 hannes Exp $";
-#endif
+/* \summary: Layer Two Tunneling Protocol (L2TP) printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
-
-#include <stdio.h>
+#include <netdissect-stdinc.h>
-#include "l2tp.h"
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
-static char tstr[] = " [|l2tp]";
+#define L2TP_FLAG_TYPE 0x8000 /* Type (0=Data, 1=Control) */
+#define L2TP_FLAG_LENGTH 0x4000 /* Length */
+#define L2TP_FLAG_SEQUENCE 0x0800 /* Sequence */
+#define L2TP_FLAG_OFFSET 0x0200 /* Offset */
+#define L2TP_FLAG_PRIORITY 0x0100 /* Priority */
+
+#define L2TP_VERSION_MASK 0x000f /* Version Mask */
+#define L2TP_VERSION_L2F 0x0001 /* L2F */
+#define L2TP_VERSION_L2TP 0x0002 /* L2TP */
+
+#define L2TP_AVP_HDR_FLAG_MANDATORY 0x8000 /* Mandatory Flag */
+#define L2TP_AVP_HDR_FLAG_HIDDEN 0x4000 /* Hidden Flag */
+#define L2TP_AVP_HDR_LEN_MASK 0x03ff /* Length Mask */
+
+#define L2TP_FRAMING_CAP_SYNC_MASK 0x00000001 /* Synchronous */
+#define L2TP_FRAMING_CAP_ASYNC_MASK 0x00000002 /* Asynchronous */
+
+#define L2TP_FRAMING_TYPE_SYNC_MASK 0x00000001 /* Synchronous */
+#define L2TP_FRAMING_TYPE_ASYNC_MASK 0x00000002 /* Asynchronous */
+
+#define L2TP_BEARER_CAP_DIGITAL_MASK 0x00000001 /* Digital */
+#define L2TP_BEARER_CAP_ANALOG_MASK 0x00000002 /* Analog */
+
+#define L2TP_BEARER_TYPE_DIGITAL_MASK 0x00000001 /* Digital */
+#define L2TP_BEARER_TYPE_ANALOG_MASK 0x00000002 /* Analog */
+
+/* Authen Type */
+#define L2TP_AUTHEN_TYPE_RESERVED 0x0000 /* Reserved */
+#define L2TP_AUTHEN_TYPE_TEXTUAL 0x0001 /* Textual username/password exchange */
+#define L2TP_AUTHEN_TYPE_CHAP 0x0002 /* PPP CHAP */
+#define L2TP_AUTHEN_TYPE_PAP 0x0003 /* PPP PAP */
+#define L2TP_AUTHEN_TYPE_NO_AUTH 0x0004 /* No Authentication */
+#define L2TP_AUTHEN_TYPE_MSCHAPv1 0x0005 /* MSCHAPv1 */
+
+#define L2TP_PROXY_AUTH_ID_MASK 0x00ff
+
+static const char tstr[] = " [|l2tp]";
#define L2TP_MSGTYPE_SCCRQ 1 /* Start-Control-Connection-Request */
#define L2TP_MSGTYPE_SCCRP 2 /* Start-Control-Connection-Reply */
@@ -57,7 +90,7 @@ static char tstr[] = " [|l2tp]";
#define L2TP_MSGTYPE_WEN 15 /* WAN-Error-Notify */
#define L2TP_MSGTYPE_SLI 16 /* Set-Link-Info */
-static struct tok l2tp_msgtype2str[] = {
+static const struct tok l2tp_msgtype2str[] = {
{ L2TP_MSGTYPE_SCCRQ, "SCCRQ" },
{ L2TP_MSGTYPE_SCCRP, "SCCRP" },
{ L2TP_MSGTYPE_SCCCN, "SCCCN" },
@@ -117,7 +150,7 @@ static struct tok l2tp_msgtype2str[] = {
#define L2TP_AVP_SEQ_REQUIRED 39 /* Sequencing Required */
#define L2TP_AVP_PPP_DISCON_CC 46 /* PPP Disconnect Cause Code */
-static struct tok l2tp_avp2str[] = {
+static const struct tok l2tp_avp2str[] = {
{ L2TP_AVP_MSGTYPE, "MSGTYPE" },
{ L2TP_AVP_RESULT_CODE, "RESULT_CODE" },
{ L2TP_AVP_PROTO_VER, "PROTO_VER" },
@@ -162,7 +195,7 @@ static struct tok l2tp_avp2str[] = {
{ 0, NULL }
};
-static struct tok l2tp_authentype2str[] = {
+static const struct tok l2tp_authentype2str[] = {
{ L2TP_AUTHEN_TYPE_RESERVED, "Reserved" },
{ L2TP_AUTHEN_TYPE_TEXTUAL, "Textual" },
{ L2TP_AUTHEN_TYPE_CHAP, "CHAP" },
@@ -176,7 +209,7 @@ static struct tok l2tp_authentype2str[] = {
#define L2TP_PPP_DISCON_CC_DIRECTION_AT_PEER 1
#define L2TP_PPP_DISCON_CC_DIRECTION_AT_LOCAL 2
-static struct tok l2tp_cc_direction2str[] = {
+static const struct tok l2tp_cc_direction2str[] = {
{ L2TP_PPP_DISCON_CC_DIRECTION_GLOBAL, "global error" },
{ L2TP_PPP_DISCON_CC_DIRECTION_AT_PEER, "at peer" },
{ L2TP_PPP_DISCON_CC_DIRECTION_AT_LOCAL,"at local" },
@@ -236,236 +269,236 @@ static char *l2tp_error_code_general[] = {
/* generic print out routines */
/******************************/
static void
-print_string(const u_char *dat, u_int length)
+print_string(netdissect_options *ndo, const u_char *dat, u_int length)
{
u_int i;
for (i=0; i<length; i++) {
- printf("%c", *dat++);
+ ND_PRINT((ndo, "%c", *dat++));
}
}
static void
-print_octets(const u_char *dat, u_int length)
+print_octets(netdissect_options *ndo, const u_char *dat, u_int length)
{
u_int i;
for (i=0; i<length; i++) {
- printf("%02x", *dat++);
+ ND_PRINT((ndo, "%02x", *dat++));
}
}
static void
-print_16bits_val(const u_int16_t *dat)
+print_16bits_val(netdissect_options *ndo, const uint16_t *dat)
{
- printf("%u", EXTRACT_16BITS(dat));
+ ND_PRINT((ndo, "%u", EXTRACT_16BITS(dat)));
}
static void
-print_32bits_val(const u_int32_t *dat)
+print_32bits_val(netdissect_options *ndo, const uint32_t *dat)
{
- printf("%lu", (u_long)EXTRACT_32BITS(dat));
+ ND_PRINT((ndo, "%lu", (u_long)EXTRACT_32BITS(dat)));
}
/***********************************/
/* AVP-specific print out routines */
/***********************************/
static void
-l2tp_msgtype_print(const u_char *dat)
+l2tp_msgtype_print(netdissect_options *ndo, const u_char *dat)
{
- u_int16_t *ptr = (u_int16_t*)dat;
+ const uint16_t *ptr = (const uint16_t *)dat;
- printf("%s", tok2str(l2tp_msgtype2str, "MSGTYPE-#%u",
- EXTRACT_16BITS(ptr)));
+ ND_PRINT((ndo, "%s", tok2str(l2tp_msgtype2str, "MSGTYPE-#%u",
+ EXTRACT_16BITS(ptr))));
}
static void
-l2tp_result_code_print(const u_char *dat, u_int length)
+l2tp_result_code_print(netdissect_options *ndo, const u_char *dat, u_int length)
{
- u_int16_t *ptr = (u_int16_t *)dat;
+ const uint16_t *ptr = (const uint16_t *)dat;
- printf("%u", EXTRACT_16BITS(ptr)); ptr++; /* Result Code */
+ ND_PRINT((ndo, "%u", EXTRACT_16BITS(ptr))); ptr++; /* Result Code */
if (length > 2) { /* Error Code (opt) */
- printf("/%u", EXTRACT_16BITS(ptr)); ptr++;
+ ND_PRINT((ndo, "/%u", EXTRACT_16BITS(ptr))); ptr++;
}
if (length > 4) { /* Error Message (opt) */
- printf(" ");
- print_string((u_char *)ptr, length - 4);
+ ND_PRINT((ndo, " "));
+ print_string(ndo, (const u_char *)ptr, length - 4);
}
}
static void
-l2tp_proto_ver_print(const u_int16_t *dat)
+l2tp_proto_ver_print(netdissect_options *ndo, const uint16_t *dat)
{
- printf("%u.%u", (EXTRACT_16BITS(dat) >> 8),
- (EXTRACT_16BITS(dat) & 0xff));
+ ND_PRINT((ndo, "%u.%u", (EXTRACT_16BITS(dat) >> 8),
+ (EXTRACT_16BITS(dat) & 0xff)));
}
static void
-l2tp_framing_cap_print(const u_char *dat)
+l2tp_framing_cap_print(netdissect_options *ndo, const u_char *dat)
{
- u_int32_t *ptr = (u_int32_t *)dat;
+ const uint32_t *ptr = (const uint32_t *)dat;
if (EXTRACT_32BITS(ptr) & L2TP_FRAMING_CAP_ASYNC_MASK) {
- printf("A");
+ ND_PRINT((ndo, "A"));
}
if (EXTRACT_32BITS(ptr) & L2TP_FRAMING_CAP_SYNC_MASK) {
- printf("S");
+ ND_PRINT((ndo, "S"));
}
}
static void
-l2tp_bearer_cap_print(const u_char *dat)
+l2tp_bearer_cap_print(netdissect_options *ndo, const u_char *dat)
{
- u_int32_t *ptr = (u_int32_t *)dat;
+ const uint32_t *ptr = (const uint32_t *)dat;
if (EXTRACT_32BITS(ptr) & L2TP_BEARER_CAP_ANALOG_MASK) {
- printf("A");
+ ND_PRINT((ndo, "A"));
}
if (EXTRACT_32BITS(ptr) & L2TP_BEARER_CAP_DIGITAL_MASK) {
- printf("D");
+ ND_PRINT((ndo, "D"));
}
}
static void
-l2tp_q931_cc_print(const u_char *dat, u_int length)
+l2tp_q931_cc_print(netdissect_options *ndo, const u_char *dat, u_int length)
{
- print_16bits_val((u_int16_t *)dat);
- printf(", %02x", dat[2]);
+ print_16bits_val(ndo, (const uint16_t *)dat);
+ ND_PRINT((ndo, ", %02x", dat[2]));
if (length > 3) {
- printf(" ");
- print_string(dat+3, length-3);
+ ND_PRINT((ndo, " "));
+ print_string(ndo, dat+3, length-3);
}
}
static void
-l2tp_bearer_type_print(const u_char *dat)
+l2tp_bearer_type_print(netdissect_options *ndo, const u_char *dat)
{
- u_int32_t *ptr = (u_int32_t *)dat;
+ const uint32_t *ptr = (const uint32_t *)dat;
if (EXTRACT_32BITS(ptr) & L2TP_BEARER_TYPE_ANALOG_MASK) {
- printf("A");
+ ND_PRINT((ndo, "A"));
}
if (EXTRACT_32BITS(ptr) & L2TP_BEARER_TYPE_DIGITAL_MASK) {
- printf("D");
+ ND_PRINT((ndo, "D"));
}
}
static void
-l2tp_framing_type_print(const u_char *dat)
+l2tp_framing_type_print(netdissect_options *ndo, const u_char *dat)
{
- u_int32_t *ptr = (u_int32_t *)dat;
+ const uint32_t *ptr = (const uint32_t *)dat;
if (EXTRACT_32BITS(ptr) & L2TP_FRAMING_TYPE_ASYNC_MASK) {
- printf("A");
+ ND_PRINT((ndo, "A"));
}
if (EXTRACT_32BITS(ptr) & L2TP_FRAMING_TYPE_SYNC_MASK) {
- printf("S");
+ ND_PRINT((ndo, "S"));
}
}
static void
-l2tp_packet_proc_delay_print(void)
+l2tp_packet_proc_delay_print(netdissect_options *ndo)
{
- printf("obsolete");
+ ND_PRINT((ndo, "obsolete"));
}
static void
-l2tp_proxy_auth_type_print(const u_char *dat)
+l2tp_proxy_auth_type_print(netdissect_options *ndo, const u_char *dat)
{
- u_int16_t *ptr = (u_int16_t *)dat;
+ const uint16_t *ptr = (const uint16_t *)dat;
- printf("%s", tok2str(l2tp_authentype2str,
- "AuthType-#%u", EXTRACT_16BITS(ptr)));
+ ND_PRINT((ndo, "%s", tok2str(l2tp_authentype2str,
+ "AuthType-#%u", EXTRACT_16BITS(ptr))));
}
static void
-l2tp_proxy_auth_id_print(const u_char *dat)
+l2tp_proxy_auth_id_print(netdissect_options *ndo, const u_char *dat)
{
- u_int16_t *ptr = (u_int16_t *)dat;
+ const uint16_t *ptr = (const uint16_t *)dat;
- printf("%u", EXTRACT_16BITS(ptr) & L2TP_PROXY_AUTH_ID_MASK);
+ ND_PRINT((ndo, "%u", EXTRACT_16BITS(ptr) & L2TP_PROXY_AUTH_ID_MASK));
}
static void
-l2tp_call_errors_print(const u_char *dat)
+l2tp_call_errors_print(netdissect_options *ndo, const u_char *dat)
{
- u_int16_t *ptr = (u_int16_t *)dat;
- u_int16_t val_h, val_l;
+ const uint16_t *ptr = (const uint16_t *)dat;
+ uint16_t val_h, val_l;
ptr++; /* skip "Reserved" */
val_h = EXTRACT_16BITS(ptr); ptr++;
val_l = EXTRACT_16BITS(ptr); ptr++;
- printf("CRCErr=%u ", (val_h<<16) + val_l);
+ ND_PRINT((ndo, "CRCErr=%u ", (val_h<<16) + val_l));
val_h = EXTRACT_16BITS(ptr); ptr++;
val_l = EXTRACT_16BITS(ptr); ptr++;
- printf("FrameErr=%u ", (val_h<<16) + val_l);
+ ND_PRINT((ndo, "FrameErr=%u ", (val_h<<16) + val_l));
val_h = EXTRACT_16BITS(ptr); ptr++;
val_l = EXTRACT_16BITS(ptr); ptr++;
- printf("HardOver=%u ", (val_h<<16) + val_l);
+ ND_PRINT((ndo, "HardOver=%u ", (val_h<<16) + val_l));
val_h = EXTRACT_16BITS(ptr); ptr++;
val_l = EXTRACT_16BITS(ptr); ptr++;
- printf("BufOver=%u ", (val_h<<16) + val_l);
+ ND_PRINT((ndo, "BufOver=%u ", (val_h<<16) + val_l));
val_h = EXTRACT_16BITS(ptr); ptr++;
val_l = EXTRACT_16BITS(ptr); ptr++;
- printf("Timeout=%u ", (val_h<<16) + val_l);
+ ND_PRINT((ndo, "Timeout=%u ", (val_h<<16) + val_l));
val_h = EXTRACT_16BITS(ptr); ptr++;
val_l = EXTRACT_16BITS(ptr); ptr++;
- printf("AlignErr=%u ", (val_h<<16) + val_l);
+ ND_PRINT((ndo, "AlignErr=%u ", (val_h<<16) + val_l));
}
static void
-l2tp_accm_print(const u_char *dat)
+l2tp_accm_print(netdissect_options *ndo, const u_char *dat)
{
- u_int16_t *ptr = (u_int16_t *)dat;
- u_int16_t val_h, val_l;
+ const uint16_t *ptr = (const uint16_t *)dat;
+ uint16_t val_h, val_l;
ptr++; /* skip "Reserved" */
val_h = EXTRACT_16BITS(ptr); ptr++;
val_l = EXTRACT_16BITS(ptr); ptr++;
- printf("send=%08x ", (val_h<<16) + val_l);
+ ND_PRINT((ndo, "send=%08x ", (val_h<<16) + val_l));
val_h = EXTRACT_16BITS(ptr); ptr++;
val_l = EXTRACT_16BITS(ptr); ptr++;
- printf("recv=%08x ", (val_h<<16) + val_l);
+ ND_PRINT((ndo, "recv=%08x ", (val_h<<16) + val_l));
}
static void
-l2tp_ppp_discon_cc_print(const u_char *dat, u_int length)
+l2tp_ppp_discon_cc_print(netdissect_options *ndo, const u_char *dat, u_int length)
{
- u_int16_t *ptr = (u_int16_t *)dat;
+ const uint16_t *ptr = (const uint16_t *)dat;
- printf("%04x, ", EXTRACT_16BITS(ptr)); ptr++; /* Disconnect Code */
- printf("%04x ", EXTRACT_16BITS(ptr)); ptr++; /* Control Protocol Number */
- printf("%s", tok2str(l2tp_cc_direction2str,
- "Direction-#%u", *((u_char *)ptr++)));
+ ND_PRINT((ndo, "%04x, ", EXTRACT_16BITS(ptr))); ptr++; /* Disconnect Code */
+ ND_PRINT((ndo, "%04x ", EXTRACT_16BITS(ptr))); ptr++; /* Control Protocol Number */
+ ND_PRINT((ndo, "%s", tok2str(l2tp_cc_direction2str,
+ "Direction-#%u", *((const u_char *)ptr++))));
if (length > 5) {
- printf(" ");
- print_string((const u_char *)ptr, length-5);
+ ND_PRINT((ndo, " "));
+ print_string(ndo, (const u_char *)ptr, length-5);
}
}
static void
-l2tp_avp_print(const u_char *dat, int length)
+l2tp_avp_print(netdissect_options *ndo, const u_char *dat, int length)
{
u_int len;
- const u_int16_t *ptr = (u_int16_t *)dat;
- u_int16_t attr_type;
+ const uint16_t *ptr = (const uint16_t *)dat;
+ uint16_t attr_type;
int hidden = FALSE;
if (length <= 0) {
return;
}
- printf(" ");
+ ND_PRINT((ndo, " "));
- TCHECK(*ptr); /* Flags & Length */
+ ND_TCHECK(*ptr); /* Flags & Length */
len = EXTRACT_16BITS(ptr) & L2TP_AVP_HDR_LEN_MASK;
/* If it is not long enough to contain the header, we'll give up. */
@@ -479,58 +512,58 @@ l2tp_avp_print(const u_char *dat, int length)
/* If it goes past the end of the remaining length of the captured
data, we'll give up. */
- TCHECK2(*ptr, len);
+ ND_TCHECK2(*ptr, len);
/* After this point, no need to worry about truncation */
if (EXTRACT_16BITS(ptr) & L2TP_AVP_HDR_FLAG_MANDATORY) {
- printf("*");
+ ND_PRINT((ndo, "*"));
}
if (EXTRACT_16BITS(ptr) & L2TP_AVP_HDR_FLAG_HIDDEN) {
hidden = TRUE;
- printf("?");
+ ND_PRINT((ndo, "?"));
}
ptr++;
if (EXTRACT_16BITS(ptr)) {
/* Vendor Specific Attribute */
- printf("VENDOR%04x:", EXTRACT_16BITS(ptr)); ptr++;
- printf("ATTR%04x", EXTRACT_16BITS(ptr)); ptr++;
- printf("(");
- print_octets((u_char *)ptr, len-6);
- printf(")");
+ ND_PRINT((ndo, "VENDOR%04x:", EXTRACT_16BITS(ptr))); ptr++;
+ ND_PRINT((ndo, "ATTR%04x", EXTRACT_16BITS(ptr))); ptr++;
+ ND_PRINT((ndo, "("));
+ print_octets(ndo, (const u_char *)ptr, len-6);
+ ND_PRINT((ndo, ")"));
} else {
/* IETF-defined Attributes */
ptr++;
attr_type = EXTRACT_16BITS(ptr); ptr++;
- printf("%s", tok2str(l2tp_avp2str, "AVP-#%u", attr_type));
- printf("(");
+ ND_PRINT((ndo, "%s", tok2str(l2tp_avp2str, "AVP-#%u", attr_type)));
+ ND_PRINT((ndo, "("));
if (hidden) {
- printf("???");
+ ND_PRINT((ndo, "???"));
} else {
switch (attr_type) {
case L2TP_AVP_MSGTYPE:
- l2tp_msgtype_print((u_char *)ptr);
+ l2tp_msgtype_print(ndo, (const u_char *)ptr);
break;
case L2TP_AVP_RESULT_CODE:
- l2tp_result_code_print((u_char *)ptr, len-6);
+ l2tp_result_code_print(ndo, (const u_char *)ptr, len-6);
break;
case L2TP_AVP_PROTO_VER:
- l2tp_proto_ver_print(ptr);
+ l2tp_proto_ver_print(ndo, ptr);
break;
case L2TP_AVP_FRAMING_CAP:
- l2tp_framing_cap_print((u_char *)ptr);
+ l2tp_framing_cap_print(ndo, (const u_char *)ptr);
break;
case L2TP_AVP_BEARER_CAP:
- l2tp_bearer_cap_print((u_char *)ptr);
+ l2tp_bearer_cap_print(ndo, (const u_char *)ptr);
break;
case L2TP_AVP_TIE_BREAKER:
- print_octets((u_char *)ptr, 8);
+ print_octets(ndo, (const u_char *)ptr, 8);
break;
case L2TP_AVP_FIRM_VER:
case L2TP_AVP_ASSND_TUN_ID:
case L2TP_AVP_RECV_WIN_SIZE:
case L2TP_AVP_ASSND_SESS_ID:
- print_16bits_val(ptr);
+ print_16bits_val(ndo, ptr);
break;
case L2TP_AVP_HOST_NAME:
case L2TP_AVP_VENDOR_NAME:
@@ -539,7 +572,7 @@ l2tp_avp_print(const u_char *dat, int length)
case L2TP_AVP_SUB_ADDRESS:
case L2TP_AVP_PROXY_AUTH_NAME:
case L2TP_AVP_PRIVATE_GRP_ID:
- print_string((u_char *)ptr, len-6);
+ print_string(ndo, (const u_char *)ptr, len-6);
break;
case L2TP_AVP_CHALLENGE:
case L2TP_AVP_INI_RECV_LCP:
@@ -548,13 +581,13 @@ l2tp_avp_print(const u_char *dat, int length)
case L2TP_AVP_PROXY_AUTH_CHAL:
case L2TP_AVP_PROXY_AUTH_RESP:
case L2TP_AVP_RANDOM_VECTOR:
- print_octets((u_char *)ptr, len-6);
+ print_octets(ndo, (const u_char *)ptr, len-6);
break;
case L2TP_AVP_Q931_CC:
- l2tp_q931_cc_print((u_char *)ptr, len-6);
+ l2tp_q931_cc_print(ndo, (const u_char *)ptr, len-6);
break;
case L2TP_AVP_CHALLENGE_RESP:
- print_octets((u_char *)ptr, 16);
+ print_octets(ndo, (const u_char *)ptr, 16);
break;
case L2TP_AVP_CALL_SER_NUM:
case L2TP_AVP_MINIMUM_BPS:
@@ -562,97 +595,97 @@ l2tp_avp_print(const u_char *dat, int length)
case L2TP_AVP_TX_CONN_SPEED:
case L2TP_AVP_PHY_CHANNEL_ID:
case L2TP_AVP_RX_CONN_SPEED:
- print_32bits_val((u_int32_t *)ptr);
+ print_32bits_val(ndo, (const uint32_t *)ptr);
break;
case L2TP_AVP_BEARER_TYPE:
- l2tp_bearer_type_print((u_char *)ptr);
+ l2tp_bearer_type_print(ndo, (const u_char *)ptr);
break;
case L2TP_AVP_FRAMING_TYPE:
- l2tp_framing_type_print((u_char *)ptr);
+ l2tp_framing_type_print(ndo, (const u_char *)ptr);
break;
case L2TP_AVP_PACKET_PROC_DELAY:
- l2tp_packet_proc_delay_print();
+ l2tp_packet_proc_delay_print(ndo);
break;
case L2TP_AVP_PROXY_AUTH_TYPE:
- l2tp_proxy_auth_type_print((u_char *)ptr);
+ l2tp_proxy_auth_type_print(ndo, (const u_char *)ptr);
break;
case L2TP_AVP_PROXY_AUTH_ID:
- l2tp_proxy_auth_id_print((u_char *)ptr);
+ l2tp_proxy_auth_id_print(ndo, (const u_char *)ptr);
break;
case L2TP_AVP_CALL_ERRORS:
- l2tp_call_errors_print((u_char *)ptr);
+ l2tp_call_errors_print(ndo, (const u_char *)ptr);
break;
case L2TP_AVP_ACCM:
- l2tp_accm_print((u_char *)ptr);
+ l2tp_accm_print(ndo, (const u_char *)ptr);
break;
case L2TP_AVP_SEQ_REQUIRED:
break; /* No Attribute Value */
case L2TP_AVP_PPP_DISCON_CC:
- l2tp_ppp_discon_cc_print((u_char *)ptr, len-6);
+ l2tp_ppp_discon_cc_print(ndo, (const u_char *)ptr, len-6);
break;
default:
break;
}
}
- printf(")");
+ ND_PRINT((ndo, ")"));
}
- l2tp_avp_print(dat+len, length-len);
+ l2tp_avp_print(ndo, dat+len, length-len);
return;
trunc:
- printf("|...");
+ ND_PRINT((ndo, "|..."));
}
void
-l2tp_print(const u_char *dat, u_int length)
+l2tp_print(netdissect_options *ndo, const u_char *dat, u_int length)
{
const u_char *ptr = dat;
u_int cnt = 0; /* total octets consumed */
- u_int16_t pad;
+ uint16_t pad;
int flag_t, flag_l, flag_s, flag_o;
- u_int16_t l2tp_len;
+ uint16_t l2tp_len;
flag_t = flag_l = flag_s = flag_o = FALSE;
- TCHECK2(*ptr, 2); /* Flags & Version */
+ ND_TCHECK2(*ptr, 2); /* Flags & Version */
if ((EXTRACT_16BITS(ptr) & L2TP_VERSION_MASK) == L2TP_VERSION_L2TP) {
- printf(" l2tp:");
+ ND_PRINT((ndo, " l2tp:"));
} else if ((EXTRACT_16BITS(ptr) & L2TP_VERSION_MASK) == L2TP_VERSION_L2F) {
- printf(" l2f:");
+ ND_PRINT((ndo, " l2f:"));
return; /* nothing to do */
} else {
- printf(" Unknown Version, neither L2F(1) nor L2TP(2)");
+ ND_PRINT((ndo, " Unknown Version, neither L2F(1) nor L2TP(2)"));
return; /* nothing we can do */
}
- printf("[");
+ ND_PRINT((ndo, "["));
if (EXTRACT_16BITS(ptr) & L2TP_FLAG_TYPE) {
flag_t = TRUE;
- printf("T");
+ ND_PRINT((ndo, "T"));
}
if (EXTRACT_16BITS(ptr) & L2TP_FLAG_LENGTH) {
flag_l = TRUE;
- printf("L");
+ ND_PRINT((ndo, "L"));
}
if (EXTRACT_16BITS(ptr) & L2TP_FLAG_SEQUENCE) {
flag_s = TRUE;
- printf("S");
+ ND_PRINT((ndo, "S"));
}
if (EXTRACT_16BITS(ptr) & L2TP_FLAG_OFFSET) {
flag_o = TRUE;
- printf("O");
+ ND_PRINT((ndo, "O"));
}
if (EXTRACT_16BITS(ptr) & L2TP_FLAG_PRIORITY)
- printf("P");
- printf("]");
+ ND_PRINT((ndo, "P"));
+ ND_PRINT((ndo, "]"));
ptr += 2;
cnt += 2;
if (flag_l) {
- TCHECK2(*ptr, 2); /* Length */
+ ND_TCHECK2(*ptr, 2); /* Length */
l2tp_len = EXTRACT_16BITS(ptr);
ptr += 2;
cnt += 2;
@@ -660,28 +693,28 @@ l2tp_print(const u_char *dat, u_int length)
l2tp_len = 0;
}
- TCHECK2(*ptr, 2); /* Tunnel ID */
- printf("(%u/", EXTRACT_16BITS(ptr));
+ ND_TCHECK2(*ptr, 2); /* Tunnel ID */
+ ND_PRINT((ndo, "(%u/", EXTRACT_16BITS(ptr)));
ptr += 2;
cnt += 2;
- TCHECK2(*ptr, 2); /* Session ID */
- printf("%u)", EXTRACT_16BITS(ptr));
+ ND_TCHECK2(*ptr, 2); /* Session ID */
+ ND_PRINT((ndo, "%u)", EXTRACT_16BITS(ptr)));
ptr += 2;
cnt += 2;
if (flag_s) {
- TCHECK2(*ptr, 2); /* Ns */
- printf("Ns=%u,", EXTRACT_16BITS(ptr));
+ ND_TCHECK2(*ptr, 2); /* Ns */
+ ND_PRINT((ndo, "Ns=%u,", EXTRACT_16BITS(ptr)));
ptr += 2;
cnt += 2;
- TCHECK2(*ptr, 2); /* Nr */
- printf("Nr=%u", EXTRACT_16BITS(ptr));
+ ND_TCHECK2(*ptr, 2); /* Nr */
+ ND_PRINT((ndo, "Nr=%u", EXTRACT_16BITS(ptr)));
ptr += 2;
cnt += 2;
}
if (flag_o) {
- TCHECK2(*ptr, 2); /* Offset Size */
+ ND_TCHECK2(*ptr, 2); /* Offset Size */
pad = EXTRACT_16BITS(ptr);
ptr += (2 + pad);
cnt += (2 + pad);
@@ -689,33 +722,36 @@ l2tp_print(const u_char *dat, u_int length)
if (flag_l) {
if (length < l2tp_len) {
- printf(" Length %u larger than packet", l2tp_len);
+ ND_PRINT((ndo, " Length %u larger than packet", l2tp_len));
return;
}
length = l2tp_len;
}
if (length < cnt) {
- printf(" Length %u smaller than header length", length);
+ ND_PRINT((ndo, " Length %u smaller than header length", length));
return;
}
if (flag_t) {
if (!flag_l) {
- printf(" No length");
+ ND_PRINT((ndo, " No length"));
return;
}
if (length - cnt == 0) {
- printf(" ZLB");
+ ND_PRINT((ndo, " ZLB"));
} else {
- l2tp_avp_print(ptr, length - cnt);
+ l2tp_avp_print(ndo, ptr, length - cnt);
}
} else {
- printf(" {");
- ppp_print(ptr, length - cnt);
- printf("}");
+ ND_PRINT((ndo, " {"));
+ ppp_print(ndo, ptr, length - cnt);
+ ND_PRINT((ndo, "}"));
}
return;
trunc:
- printf("%s", tstr);
+ ND_PRINT((ndo, "%s", tstr));
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-l2tp-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-lane.c b/freebsd/contrib/tcpdump/print-lane.c
index b637b984..f4ad16b1 100644
--- a/freebsd/contrib/tcpdump/print-lane.c
+++ b/freebsd/contrib/tcpdump/print-lane.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Marko Kiiskila carnil@cs.tut.fi
*
@@ -22,25 +25,31 @@
*
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-lane.c,v 1.25 2005-11-13 12:12:42 guy Exp $ (LBL)";
-#endif
+/* \summary: ATM LANE printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include <stdio.h>
-#include <pcap.h>
-
-#include "interface.h"
-#include "addrtoname.h"
+#include "netdissect.h"
#include "extract.h"
#include "ether.h"
-#include "lane.h"
+
+struct lecdatahdr_8023 {
+ uint16_t le_header;
+ uint8_t h_dest[ETHER_ADDR_LEN];
+ uint8_t h_source[ETHER_ADDR_LEN];
+ uint16_t h_type;
+};
+
+struct lane_controlhdr {
+ uint16_t lec_header;
+ uint8_t lec_proto;
+ uint8_t lec_vers;
+ uint16_t lec_opcode;
+};
static const struct tok lecop2str[] = {
{ 0x0001, "configure request" },
@@ -65,7 +74,7 @@ static const struct tok lecop2str[] = {
static void
lane_hdr_print(netdissect_options *ndo, const u_char *bp)
{
- (void)ND_PRINT((ndo, "lecid:%x ", EXTRACT_16BITS(bp)));
+ ND_PRINT((ndo, "lecid:%x ", EXTRACT_16BITS(bp)));
}
/*
@@ -77,23 +86,23 @@ lane_hdr_print(netdissect_options *ndo, const u_char *bp)
* This assumes 802.3, not 802.5, LAN emulation.
*/
void
-lane_print(const u_char *p, u_int length, u_int caplen)
+lane_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen)
{
- struct lane_controlhdr *lec;
+ const struct lane_controlhdr *lec;
if (caplen < sizeof(struct lane_controlhdr)) {
- printf("[|lane]");
+ ND_PRINT((ndo, "[|lane]"));
return;
}
- lec = (struct lane_controlhdr *)p;
+ lec = (const struct lane_controlhdr *)p;
if (EXTRACT_16BITS(&lec->lec_header) == 0xff00) {
/*
* LE Control.
*/
- printf("lec: proto %x vers %x %s",
+ ND_PRINT((ndo, "lec: proto %x vers %x %s",
lec->lec_proto, lec->lec_vers,
- tok2str(lecop2str, "opcode-#%u", EXTRACT_16BITS(&lec->lec_opcode)));
+ tok2str(lecop2str, "opcode-#%u", EXTRACT_16BITS(&lec->lec_opcode))));
return;
}
@@ -108,13 +117,16 @@ lane_print(const u_char *p, u_int length, u_int caplen)
* Now print the encapsulated frame, under the assumption
* that it's an Ethernet frame.
*/
- ether_print(gndo, p, length, caplen, lane_hdr_print, p - 2);
+ ether_print(ndo, p, length, caplen, lane_hdr_print, p - 2);
}
u_int
-lane_if_print(const struct pcap_pkthdr *h, const u_char *p)
+lane_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
{
- lane_print(p, h->len, h->caplen);
+ lane_print(ndo, p, h->len, h->caplen);
return (sizeof(struct lecdatahdr_8023));
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-lane-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-ldp.c b/freebsd/contrib/tcpdump/print-ldp.c
index a02f1271..6f89211b 100644
--- a/freebsd/contrib/tcpdump/print-ldp.c
+++ b/freebsd/contrib/tcpdump/print-ldp.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code
@@ -16,23 +19,15 @@
* and Steinar Haug (sthaug@nethelp.no)
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ldp.c,v 1.20 2006-06-23 02:03:09 hannes Exp $";
-#endif
+/* \summary: Label Distribution Protocol (LDP) printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
-#include "decode_prefix.h"
+#include "netdissect.h"
#include "extract.h"
#include "addrtoname.h"
@@ -55,10 +50,10 @@ static const char rcsid[] _U_ =
*/
struct ldp_common_header {
- u_int8_t version[2];
- u_int8_t pdu_length[2];
- u_int8_t lsr_id[4];
- u_int8_t label_space[2];
+ uint8_t version[2];
+ uint8_t pdu_length[2];
+ uint8_t lsr_id[4];
+ uint8_t label_space[2];
};
#define LDP_VERSION 1
@@ -88,13 +83,13 @@ struct ldp_common_header {
*/
struct ldp_msg_header {
- u_int8_t type[2];
- u_int8_t length[2];
- u_int8_t id[4];
+ uint8_t type[2];
+ uint8_t length[2];
+ uint8_t id[4];
};
-#define LDP_MASK_MSG_TYPE(x) ((x)&0x7fff)
-#define LDP_MASK_U_BIT(x) ((x)&0x8000)
+#define LDP_MASK_MSG_TYPE(x) ((x)&0x7fff)
+#define LDP_MASK_U_BIT(x) ((x)&0x8000)
#define LDP_MSG_NOTIF 0x0001
#define LDP_MSG_HELLO 0x0100
@@ -128,8 +123,8 @@ static const struct tok ldp_msg_values[] = {
{ 0, NULL}
};
-#define LDP_MASK_TLV_TYPE(x) ((x)&0x3fff)
-#define LDP_MASK_F_BIT(x) ((x)&0x4000)
+#define LDP_MASK_TLV_TYPE(x) ((x)&0x3fff)
+#define LDP_MASK_F_BIT(x) ((x)&0x4000)
#define LDP_TLV_FEC 0x0100
#define LDP_TLV_ADDRESS_LIST 0x0101
@@ -220,10 +215,9 @@ static const struct tok ldp_fec_martini_ifparm_vccv_cv_values[] = {
{ 0, NULL}
};
-int ldp_msg_print(register const u_char *);
-int ldp_tlv_print(register const u_char *);
-
-/*
+static int ldp_pdu_print(netdissect_options *, register const u_char *);
+
+/*
* ldp tlv header
*
* 0 1 2 3
@@ -241,14 +235,16 @@ int ldp_tlv_print(register const u_char *);
*/
#define TLV_TCHECK(minlen) \
- TCHECK2(*tptr, minlen); if (tlv_tlen < minlen) goto badtlv;
-
-int
-ldp_tlv_print(register const u_char *tptr) {
+ ND_TCHECK2(*tptr, minlen); if (tlv_tlen < minlen) goto badtlv;
+static int
+ldp_tlv_print(netdissect_options *ndo,
+ register const u_char *tptr,
+ u_short msg_tlen)
+{
struct ldp_tlv_header {
- u_int8_t type[2];
- u_int8_t length[2];
+ uint8_t type[2];
+ uint8_t length[2];
};
const struct ldp_tlv_header *ldp_tlv_header;
@@ -258,20 +254,25 @@ ldp_tlv_print(register const u_char *tptr) {
char buf[100];
int i;
- ldp_tlv_header = (const struct ldp_tlv_header *)tptr;
+ ldp_tlv_header = (const struct ldp_tlv_header *)tptr;
+ ND_TCHECK(*ldp_tlv_header);
tlv_len=EXTRACT_16BITS(ldp_tlv_header->length);
+ if (tlv_len + 4 > msg_tlen) {
+ ND_PRINT((ndo, "\n\t\t TLV contents go past end of message"));
+ return 0;
+ }
tlv_tlen=tlv_len;
tlv_type=LDP_MASK_TLV_TYPE(EXTRACT_16BITS(ldp_tlv_header->type));
/* FIXME vendor private / experimental check */
- printf("\n\t %s TLV (0x%04x), length: %u, Flags: [%s and %s forward if unknown]",
+ ND_PRINT((ndo, "\n\t %s TLV (0x%04x), length: %u, Flags: [%s and %s forward if unknown]",
tok2str(ldp_tlv_values,
"Unknown",
tlv_type),
tlv_type,
tlv_len,
LDP_MASK_U_BIT(EXTRACT_16BITS(&ldp_tlv_header->type)) ? "continue processing" : "ignore",
- LDP_MASK_F_BIT(EXTRACT_16BITS(&ldp_tlv_header->type)) ? "do" : "don't");
+ LDP_MASK_F_BIT(EXTRACT_16BITS(&ldp_tlv_header->type)) ? "do" : "don't"));
tptr+=sizeof(struct ldp_tlv_header);
@@ -279,25 +280,23 @@ ldp_tlv_print(register const u_char *tptr) {
case LDP_TLV_COMMON_HELLO:
TLV_TCHECK(4);
- printf("\n\t Hold Time: %us, Flags: [%s Hello%s]",
+ ND_PRINT((ndo, "\n\t Hold Time: %us, Flags: [%s Hello%s]",
EXTRACT_16BITS(tptr),
(EXTRACT_16BITS(tptr+2)&0x8000) ? "Targeted" : "Link",
- (EXTRACT_16BITS(tptr+2)&0x4000) ? ", Request for targeted Hellos" : "");
+ (EXTRACT_16BITS(tptr+2)&0x4000) ? ", Request for targeted Hellos" : ""));
break;
case LDP_TLV_IPV4_TRANSPORT_ADDR:
TLV_TCHECK(4);
- printf("\n\t IPv4 Transport Address: %s", ipaddr_string(tptr));
+ ND_PRINT((ndo, "\n\t IPv4 Transport Address: %s", ipaddr_string(ndo, tptr)));
break;
-#ifdef INET6
case LDP_TLV_IPV6_TRANSPORT_ADDR:
TLV_TCHECK(16);
- printf("\n\t IPv6 Transport Address: %s", ip6addr_string(tptr));
+ ND_PRINT((ndo, "\n\t IPv6 Transport Address: %s", ip6addr_string(ndo, tptr)));
break;
-#endif
case LDP_TLV_CONFIG_SEQ_NUMBER:
TLV_TCHECK(4);
- printf("\n\t Sequence Number: %u", EXTRACT_32BITS(tptr));
+ ND_PRINT((ndo, "\n\t Sequence Number: %u", EXTRACT_32BITS(tptr)));
break;
case LDP_TLV_ADDRESS_LIST:
@@ -305,27 +304,25 @@ ldp_tlv_print(register const u_char *tptr) {
af = EXTRACT_16BITS(tptr);
tptr+=LDP_TLV_ADDRESS_LIST_AFNUM_LEN;
tlv_tlen -= LDP_TLV_ADDRESS_LIST_AFNUM_LEN;
- printf("\n\t Address Family: %s, addresses",
- tok2str(af_values, "Unknown (%u)", af));
+ ND_PRINT((ndo, "\n\t Address Family: %s, addresses",
+ tok2str(af_values, "Unknown (%u)", af)));
switch (af) {
case AFNUM_INET:
while(tlv_tlen >= sizeof(struct in_addr)) {
- TCHECK2(*tptr, sizeof(struct in_addr));
- printf(" %s",ipaddr_string(tptr));
+ ND_TCHECK2(*tptr, sizeof(struct in_addr));
+ ND_PRINT((ndo, " %s", ipaddr_string(ndo, tptr)));
tlv_tlen-=sizeof(struct in_addr);
- tptr+=sizeof(struct in_addr);
+ tptr+=sizeof(struct in_addr);
}
break;
-#ifdef INET6
case AFNUM_INET6:
while(tlv_tlen >= sizeof(struct in6_addr)) {
- TCHECK2(*tptr, sizeof(struct in6_addr));
- printf(" %s",ip6addr_string(tptr));
+ ND_TCHECK2(*tptr, sizeof(struct in6_addr));
+ ND_PRINT((ndo, " %s", ip6addr_string(ndo, tptr)));
tlv_tlen-=sizeof(struct in6_addr);
- tptr+=sizeof(struct in6_addr);
+ tptr+=sizeof(struct in6_addr);
}
break;
-#endif
default:
/* unknown AF */
break;
@@ -334,19 +331,19 @@ ldp_tlv_print(register const u_char *tptr) {
case LDP_TLV_COMMON_SESSION:
TLV_TCHECK(8);
- printf("\n\t Version: %u, Keepalive: %us, Flags: [Downstream %s, Loop Detection %s]",
+ ND_PRINT((ndo, "\n\t Version: %u, Keepalive: %us, Flags: [Downstream %s, Loop Detection %s]",
EXTRACT_16BITS(tptr), EXTRACT_16BITS(tptr+2),
(EXTRACT_16BITS(tptr+6)&0x8000) ? "On Demand" : "Unsolicited",
(EXTRACT_16BITS(tptr+6)&0x4000) ? "Enabled" : "Disabled"
- );
+ ));
break;
case LDP_TLV_FEC:
TLV_TCHECK(1);
fec_type = *tptr;
- printf("\n\t %s FEC (0x%02x)",
+ ND_PRINT((ndo, "\n\t %s FEC (0x%02x)",
tok2str(ldp_fec_values, "Unknown", fec_type),
- fec_type);
+ fec_type));
tptr+=1;
tlv_tlen-=1;
@@ -360,62 +357,67 @@ ldp_tlv_print(register const u_char *tptr) {
tptr+=LDP_TLV_ADDRESS_LIST_AFNUM_LEN;
tlv_tlen-=LDP_TLV_ADDRESS_LIST_AFNUM_LEN;
if (af == AFNUM_INET) {
- i=decode_prefix4(tptr,tlv_tlen,buf,sizeof(buf));
+ i=decode_prefix4(ndo, tptr, tlv_tlen, buf, sizeof(buf));
if (i == -2)
goto trunc;
if (i == -3)
- printf(": IPv4 prefix (goes past end of TLV)");
+ ND_PRINT((ndo, ": IPv4 prefix (goes past end of TLV)"));
else if (i == -1)
- printf(": IPv4 prefix (invalid length)");
+ ND_PRINT((ndo, ": IPv4 prefix (invalid length)"));
else
- printf(": IPv4 prefix %s",buf);
+ ND_PRINT((ndo, ": IPv4 prefix %s", buf));
}
-#ifdef INET6
else if (af == AFNUM_INET6) {
- i=decode_prefix6(tptr,tlv_tlen,buf,sizeof(buf));
+ i=decode_prefix6(ndo, tptr, tlv_tlen, buf, sizeof(buf));
if (i == -2)
goto trunc;
if (i == -3)
- printf(": IPv4 prefix (goes past end of TLV)");
+ ND_PRINT((ndo, ": IPv4 prefix (goes past end of TLV)"));
else if (i == -1)
- printf(": IPv6 prefix (invalid length)");
+ ND_PRINT((ndo, ": IPv6 prefix (invalid length)"));
else
- printf(": IPv6 prefix %s",buf);
+ ND_PRINT((ndo, ": IPv6 prefix %s", buf));
}
-#endif
else
- printf(": Address family %u prefix", af);
+ ND_PRINT((ndo, ": Address family %u prefix", af));
break;
case LDP_FEC_HOSTADDRESS:
break;
case LDP_FEC_MARTINI_VC:
/*
+ * We assume the type was supposed to be one of the MPLS
+ * Pseudowire Types.
+ */
+ TLV_TCHECK(7);
+ vc_info_len = *(tptr+2);
+
+ /*
* According to RFC 4908, the VC info Length field can be zero,
* in which case not only are there no interface parameters,
* there's no VC ID.
*/
- TLV_TCHECK(7);
- vc_info_len = *(tptr+2);
-
if (vc_info_len == 0) {
- printf(": %s, %scontrol word, group-ID %u, VC-info-length: %u",
- tok2str(l2vpn_encaps_values, "Unknown", EXTRACT_16BITS(tptr)&0x7fff),
+ ND_PRINT((ndo, ": %s, %scontrol word, group-ID %u, VC-info-length: %u",
+ tok2str(mpls_pw_types_values, "Unknown", EXTRACT_16BITS(tptr)&0x7fff),
EXTRACT_16BITS(tptr)&0x8000 ? "" : "no ",
EXTRACT_32BITS(tptr+3),
- vc_info_len);
+ vc_info_len));
break;
}
/* Make sure we have the VC ID as well */
TLV_TCHECK(11);
- printf(": %s, %scontrol word, group-ID %u, VC-ID %u, VC-info-length: %u",
- tok2str(l2vpn_encaps_values, "Unknown", EXTRACT_16BITS(tptr)&0x7fff),
+ ND_PRINT((ndo, ": %s, %scontrol word, group-ID %u, VC-ID %u, VC-info-length: %u",
+ tok2str(mpls_pw_types_values, "Unknown", EXTRACT_16BITS(tptr)&0x7fff),
EXTRACT_16BITS(tptr)&0x8000 ? "" : "no ",
EXTRACT_32BITS(tptr+3),
EXTRACT_32BITS(tptr+7),
- vc_info_len);
- if (vc_info_len < 4)
- goto trunc; /* minimum 4, for the VC ID */
+ vc_info_len));
+ if (vc_info_len < 4) {
+ /* minimum 4, for the VC ID */
+ ND_PRINT((ndo, " (invalid, < 4"));
+ return(tlv_len+4); /* Type & Length fields not included */
+ }
vc_info_len -= 4; /* subtract out the VC ID, giving the length of the interface parameters */
/* Skip past the fixed information and the VC ID */
@@ -431,33 +433,33 @@ ldp_tlv_print(register const u_char *tptr) {
if (vc_info_len < vc_info_tlv_len)
break;
- printf("\n\t\tInterface Parameter: %s (0x%02x), len %u",
+ ND_PRINT((ndo, "\n\t\tInterface Parameter: %s (0x%02x), len %u",
tok2str(ldp_fec_martini_ifparm_values,"Unknown",vc_info_tlv_type),
vc_info_tlv_type,
- vc_info_tlv_len);
+ vc_info_tlv_len));
switch(vc_info_tlv_type) {
case LDP_FEC_MARTINI_IFPARM_MTU:
- printf(": %u",EXTRACT_16BITS(tptr+2));
+ ND_PRINT((ndo, ": %u", EXTRACT_16BITS(tptr+2)));
break;
case LDP_FEC_MARTINI_IFPARM_DESC:
- printf(": ");
+ ND_PRINT((ndo, ": "));
for (idx = 2; idx < vc_info_tlv_len; idx++)
- safeputchar(*(tptr+idx));
+ safeputchar(ndo, *(tptr + idx));
break;
case LDP_FEC_MARTINI_IFPARM_VCCV:
- printf("\n\t\t Control Channels (0x%02x) = [%s]",
+ ND_PRINT((ndo, "\n\t\t Control Channels (0x%02x) = [%s]",
*(tptr+2),
- bittok2str(ldp_fec_martini_ifparm_vccv_cc_values,"none",*(tptr+2)));
- printf("\n\t\t CV Types (0x%02x) = [%s]",
+ bittok2str(ldp_fec_martini_ifparm_vccv_cc_values, "none", *(tptr+2))));
+ ND_PRINT((ndo, "\n\t\t CV Types (0x%02x) = [%s]",
*(tptr+3),
- bittok2str(ldp_fec_martini_ifparm_vccv_cv_values,"none",*(tptr+3)));
+ bittok2str(ldp_fec_martini_ifparm_vccv_cv_values, "none", *(tptr+3))));
break;
default:
- print_unknown_data(tptr+2,"\n\t\t ",vc_info_tlv_len-2);
+ print_unknown_data(ndo, tptr+2, "\n\t\t ", vc_info_tlv_len-2);
break;
}
@@ -471,45 +473,45 @@ ldp_tlv_print(register const u_char *tptr) {
case LDP_TLV_GENERIC_LABEL:
TLV_TCHECK(4);
- printf("\n\t Label: %u", EXTRACT_32BITS(tptr) & 0xfffff);
+ ND_PRINT((ndo, "\n\t Label: %u", EXTRACT_32BITS(tptr) & 0xfffff));
break;
case LDP_TLV_STATUS:
TLV_TCHECK(8);
ui = EXTRACT_32BITS(tptr);
tptr+=4;
- printf("\n\t Status: 0x%02x, Flags: [%s and %s forward]",
+ ND_PRINT((ndo, "\n\t Status: 0x%02x, Flags: [%s and %s forward]",
ui&0x3fffffff,
ui&0x80000000 ? "Fatal error" : "Advisory Notification",
- ui&0x40000000 ? "do" : "don't");
+ ui&0x40000000 ? "do" : "don't"));
ui = EXTRACT_32BITS(tptr);
tptr+=4;
if (ui)
- printf(", causing Message ID: 0x%08x", ui);
+ ND_PRINT((ndo, ", causing Message ID: 0x%08x", ui));
break;
case LDP_TLV_FT_SESSION:
TLV_TCHECK(8);
ft_flags = EXTRACT_16BITS(tptr);
- printf("\n\t Flags: [%sReconnect, %sSave State, %sAll-Label Protection, %s Checkpoint, %sRe-Learn State]",
+ ND_PRINT((ndo, "\n\t Flags: [%sReconnect, %sSave State, %sAll-Label Protection, %s Checkpoint, %sRe-Learn State]",
ft_flags&0x8000 ? "" : "No ",
ft_flags&0x8 ? "" : "Don't ",
ft_flags&0x4 ? "" : "No ",
ft_flags&0x2 ? "Sequence Numbered Label" : "All Labels",
- ft_flags&0x1 ? "" : "Don't ");
+ ft_flags&0x1 ? "" : "Don't "));
tptr+=4;
ui = EXTRACT_32BITS(tptr);
if (ui)
- printf(", Reconnect Timeout: %ums", ui);
+ ND_PRINT((ndo, ", Reconnect Timeout: %ums", ui));
tptr+=4;
ui = EXTRACT_32BITS(tptr);
if (ui)
- printf(", Recovery Time: %ums", ui);
+ ND_PRINT((ndo, ", Recovery Time: %ums", ui));
break;
case LDP_TLV_MTU:
TLV_TCHECK(2);
- printf("\n\t MTU: %u", EXTRACT_16BITS(tptr));
+ ND_PRINT((ndo, "\n\t MTU: %u", EXTRACT_16BITS(tptr)));
break;
@@ -530,27 +532,28 @@ ldp_tlv_print(register const u_char *tptr) {
case LDP_TLV_LABEL_REQUEST_MSG_ID:
default:
- if (vflag <= 1)
- print_unknown_data(tptr,"\n\t ",tlv_tlen);
+ if (ndo->ndo_vflag <= 1)
+ print_unknown_data(ndo, tptr, "\n\t ", tlv_tlen);
break;
}
return(tlv_len+4); /* Type & Length fields not included */
-
+
trunc:
- printf("\n\t\t packet exceeded snapshot");
+ ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
return 0;
badtlv:
- printf("\n\t\t TLV contents go past end of TLV");
+ ND_PRINT((ndo, "\n\t\t TLV contents go past end of TLV"));
return(tlv_len+4); /* Type & Length fields not included */
}
void
-ldp_print(register const u_char *pptr, register u_int len) {
-
+ldp_print(netdissect_options *ndo,
+ register const u_char *pptr, register u_int len)
+{
int processed;
while (len > (sizeof(struct ldp_common_header) + sizeof(struct ldp_msg_header))) {
- processed = ldp_msg_print(pptr);
+ processed = ldp_pdu_print(ndo, pptr);
if (processed == 0)
return;
len -= processed;
@@ -558,10 +561,10 @@ ldp_print(register const u_char *pptr, register u_int len) {
}
}
-
-int
-ldp_msg_print(register const u_char *pptr) {
-
+static int
+ldp_pdu_print(netdissect_options *ndo,
+ register const u_char *pptr)
+{
const struct ldp_common_header *ldp_com_header;
const struct ldp_msg_header *ldp_msg_header;
const u_char *tptr,*msg_tptr;
@@ -569,68 +572,84 @@ ldp_msg_print(register const u_char *pptr) {
u_short pdu_len,msg_len,msg_type,msg_tlen;
int hexdump,processed;
- tptr=pptr;
ldp_com_header = (const struct ldp_common_header *)pptr;
- TCHECK(*ldp_com_header);
+ ND_TCHECK(*ldp_com_header);
/*
* Sanity checking of the header.
*/
if (EXTRACT_16BITS(&ldp_com_header->version) != LDP_VERSION) {
- printf("%sLDP version %u packet not supported",
- (vflag < 1) ? "" : "\n\t",
- EXTRACT_16BITS(&ldp_com_header->version));
+ ND_PRINT((ndo, "%sLDP version %u packet not supported",
+ (ndo->ndo_vflag < 1) ? "" : "\n\t",
+ EXTRACT_16BITS(&ldp_com_header->version)));
return 0;
}
- /* print the LSR-ID, label-space & length */
pdu_len = EXTRACT_16BITS(&ldp_com_header->pdu_length);
- printf("%sLDP, Label-Space-ID: %s:%u, pdu-length: %u",
- (vflag < 1) ? "" : "\n\t",
- ipaddr_string(&ldp_com_header->lsr_id),
+ if (pdu_len < sizeof(const struct ldp_common_header)-4) {
+ /* length too short */
+ ND_PRINT((ndo, "%sLDP, pdu-length: %u (too short, < %u)",
+ (ndo->ndo_vflag < 1) ? "" : "\n\t",
+ pdu_len,
+ (u_int)(sizeof(const struct ldp_common_header)-4)));
+ return 0;
+ }
+
+ /* print the LSR-ID, label-space & length */
+ ND_PRINT((ndo, "%sLDP, Label-Space-ID: %s:%u, pdu-length: %u",
+ (ndo->ndo_vflag < 1) ? "" : "\n\t",
+ ipaddr_string(ndo, &ldp_com_header->lsr_id),
EXTRACT_16BITS(&ldp_com_header->label_space),
- pdu_len);
+ pdu_len));
- /* bail out if non-verbose */
- if (vflag < 1)
+ /* bail out if non-verbose */
+ if (ndo->ndo_vflag < 1)
return 0;
/* ok they seem to want to know everything - lets fully decode it */
- tlen=pdu_len;
-
- tptr += sizeof(const struct ldp_common_header);
- tlen -= sizeof(const struct ldp_common_header)-4; /* Type & Length fields not included */
+ tptr = pptr + sizeof(const struct ldp_common_header);
+ tlen = pdu_len - (sizeof(const struct ldp_common_header)-4); /* Type & Length fields not included */
while(tlen>0) {
/* did we capture enough for fully decoding the msg header ? */
- TCHECK2(*tptr, sizeof(struct ldp_msg_header));
+ ND_TCHECK2(*tptr, sizeof(struct ldp_msg_header));
ldp_msg_header = (const struct ldp_msg_header *)tptr;
msg_len=EXTRACT_16BITS(ldp_msg_header->length);
msg_type=LDP_MASK_MSG_TYPE(EXTRACT_16BITS(ldp_msg_header->type));
+ if (msg_len < sizeof(struct ldp_msg_header)-4) {
+ /* length too short */
+ /* FIXME vendor private / experimental check */
+ ND_PRINT((ndo, "\n\t %s Message (0x%04x), length: %u (too short, < %u)",
+ tok2str(ldp_msg_values,
+ "Unknown",
+ msg_type),
+ msg_type,
+ msg_len,
+ (u_int)(sizeof(struct ldp_msg_header)-4)));
+ return 0;
+ }
+
/* FIXME vendor private / experimental check */
- printf("\n\t %s Message (0x%04x), length: %u, Message ID: 0x%08x, Flags: [%s if unknown]",
+ ND_PRINT((ndo, "\n\t %s Message (0x%04x), length: %u, Message ID: 0x%08x, Flags: [%s if unknown]",
tok2str(ldp_msg_values,
"Unknown",
msg_type),
msg_type,
msg_len,
EXTRACT_32BITS(&ldp_msg_header->id),
- LDP_MASK_U_BIT(EXTRACT_16BITS(&ldp_msg_header->type)) ? "continue processing" : "ignore");
-
- if (msg_len == 0) /* infinite loop protection */
- return 0;
+ LDP_MASK_U_BIT(EXTRACT_16BITS(&ldp_msg_header->type)) ? "continue processing" : "ignore"));
msg_tptr=tptr+sizeof(struct ldp_msg_header);
- msg_tlen=msg_len-sizeof(struct ldp_msg_header)+4; /* Type & Length fields not included */
+ msg_tlen=msg_len-(sizeof(struct ldp_msg_header)-4); /* Type & Length fields not included */
/* did we capture enough for fully decoding the message ? */
- TCHECK2(*tptr, msg_len);
+ ND_TCHECK2(*tptr, msg_len);
hexdump=FALSE;
switch(msg_type) {
-
+
case LDP_MSG_NOTIF:
case LDP_MSG_HELLO:
case LDP_MSG_INIT:
@@ -640,7 +659,7 @@ ldp_msg_print(register const u_char *pptr) {
case LDP_MSG_ADDRESS_WITHDRAW:
case LDP_MSG_LABEL_WITHDRAW:
while(msg_tlen >= 4) {
- processed = ldp_tlv_print(msg_tptr);
+ processed = ldp_tlv_print(ndo, msg_tptr, msg_tlen);
if (processed == 0)
break;
msg_tlen-=processed;
@@ -658,13 +677,13 @@ ldp_msg_print(register const u_char *pptr) {
case LDP_MSG_LABEL_ABORT_REQUEST:
default:
- if (vflag <= 1)
- print_unknown_data(msg_tptr,"\n\t ",msg_tlen);
+ if (ndo->ndo_vflag <= 1)
+ print_unknown_data(ndo, msg_tptr, "\n\t ", msg_tlen);
break;
}
/* do we want to see an additionally hexdump ? */
- if (vflag > 1 || hexdump==TRUE)
- print_unknown_data(tptr+sizeof(struct ldp_msg_header),"\n\t ",
+ if (ndo->ndo_vflag > 1 || hexdump==TRUE)
+ print_unknown_data(ndo, tptr+sizeof(struct ldp_msg_header), "\n\t ",
msg_len);
tptr += msg_len+4;
@@ -672,7 +691,16 @@ ldp_msg_print(register const u_char *pptr) {
}
return pdu_len+4;
trunc:
- printf("\n\t\t packet exceeded snapshot");
+ ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
return 0;
}
+/*
+ * Local Variables:
+ * c-style: whitesmith
+ * c-basic-offset: 8
+ * End:
+ */
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-ldp-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-lisp.c b/freebsd/contrib/tcpdump/print-lisp.c
new file mode 100644
index 00000000..040687a9
--- /dev/null
+++ b/freebsd/contrib/tcpdump/print-lisp.c
@@ -0,0 +1,457 @@
+#include <machine/rtems-bsd-user-space.h>
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
+/*
+ * Copyright (c) 2015 Ritesh Ranjan (r.ranjan789@gmail.com)
+ * All rights reserved.
+ *
+ * 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. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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: - Locator/Identifier Separation Protocol (LISP) printer */
+
+/*
+ * specification: RFC 6830
+ *
+ *
+ * The Map-Register message format is:
+ *
+ * 0 1 2 3
+ * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * |Type=3 |P|S|I|R| Reserved |M| Record Count |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Nonce . . . |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | . . . Nonce |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Key ID | Authentication Data Length |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * ~ Authentication Data ~
+ * +-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | | Record TTL |
+ * | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * R | Locator Count | EID mask-len | ACT |A| Reserved |
+ * e +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * c | Rsvd | Map-Version Number | EID-Prefix-AFI |
+ * o +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * r | EID-Prefix |
+ * d +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | /| Priority | Weight | M Priority | M Weight |
+ * | L +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | o | Unused Flags |L|p|R| Loc-AFI |
+ * | c +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | \| Locator |
+ * +-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *
+ *
+ * The Map-Notify message format is:
+ *
+ * 0 1 2 3
+ * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * |Type=4 |I|R| Reserved | Record Count |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Nonce . . . |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | . . . Nonce |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Key ID | Authentication Data Length |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * ~ Authentication Data ~
+ * +-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | | Record TTL |
+ * | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * R | Locator Count | EID mask-len | ACT |A| Reserved |
+ * e +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * c | Rsvd | Map-Version Number | EID-Prefix-AFI |
+ * o +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * r | EID-Prefix |
+ * d +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | /| Priority | Weight | M Priority | M Weight |
+ * | L +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | o | Unused Flags |L|p|R| Loc-AFI |
+ * | c +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | \| Locator |
+ * +-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <netdissect-stdinc.h>
+#include <netdissect.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include "ip.h"
+#include "ip6.h"
+
+#include "extract.h"
+#include "addrtoname.h"
+
+static const char tstr[] = " [|LISP]";
+
+#define IPv4_AFI 1
+#define IPv6_AFI 2
+#define TYPE_INDEX 4
+#define LISP_MAP_NOTIFY_IBIT_MASK 8
+#define LISP_MAP_REGISTER_IBIT_MASK 2
+
+enum {
+ LISP_MAP_REQUEST = 1,
+ LISP_MAP_REPLY,
+ LISP_MAP_REGISTER,
+ LISP_MAP_NOTIFY,
+ LISP_ENCAPSULATED_CONTROL_MESSAGE = 8
+};
+
+enum {
+ LISP_AUTH_NONE,
+ LISP_AUTH_SHA1,
+ LISP_AUTH_SHA256
+};
+
+static const struct tok lisp_type [] = {
+ { 0, "LISP-Reserved" },
+ { 1, "LISP-Map-Request" },
+ { 2, "LISP-Map-Reply" },
+ { 3, "LISP-Map-Register" },
+ { 4, "LISP-Map-Notify" },
+ { 8, "LISP-Encapsulated-Contol-Message" },
+ { 0, NULL }
+};
+
+/*
+ * P-Bit : Request for Proxy Map-Reply from the MS/MR
+ * S-Bit : Security Enhancement. ETR is LISP-SEC enabled. draft-ietf-lisp-sec
+ * I-Bit : 128 bit xTR-ID and 64 bit Site-ID present.
+ * xTR-ID and Site-ID help in differentiation of xTRs in multi xTR
+ * and multi Site deployment scenarios.
+ * R-Bit : Built for a Reencapsulating-Tunnel-Router. Used in Traffic
+ * Engineering and Service Chaining
+ */
+static const struct tok map_register_hdr_flag[] = {
+ { 0x08000000, "P-Proxy-Map-Reply" },
+ { 0x04000000, "S-LISP-SEC-Capable" },
+ { 0x02000000, "I-xTR-ID-Present" },
+ { 0x01000000, "R-Build-For-RTR" },
+ { 0x00000100, "M-Want-Map-Notify" },
+ { 0, NULL }
+};
+
+static const struct tok map_notify_hdr_flag[] = {
+ { 0x08000000, "I-xTR-ID-Present" },
+ { 0x04000000, "R-Build-For-RTR" },
+ { 0, NULL }
+};
+
+static const struct tok auth_type[] = {
+ { LISP_AUTH_NONE, "None" },
+ { LISP_AUTH_SHA1, "SHA1" },
+ { LISP_AUTH_SHA256, "SHA256" },
+ { 0, NULL}
+};
+
+static const struct tok lisp_eid_action[] = {
+ { 0, "No-Action" },
+ { 1, "Natively-Forward" },
+ { 2, "Send-Map-Request" },
+ { 3, "Drop" },
+ { 0, NULL}
+};
+
+static const struct tok lisp_loc_flag[] = {
+ { 0x0004, "Local-Locator" },
+ { 0x0002, "RLoc-Probed" },
+ { 0x0001, "Reachable" },
+ { 0, NULL }
+};
+
+typedef struct map_register_hdr {
+ nd_uint8_t type_and_flag;
+ nd_uint8_t reserved;
+ nd_uint8_t reserved_and_flag2;
+ nd_uint8_t record_count;
+ nd_uint64_t nonce;
+ nd_uint16_t key_id;
+ nd_uint16_t auth_data_len;
+} lisp_map_register_hdr;
+
+#define MAP_REGISTER_HDR_LEN sizeof(lisp_map_register_hdr)
+
+typedef struct map_register_eid {
+ nd_uint32_t ttl;
+ nd_uint8_t locator_count;
+ nd_uint8_t eid_prefix_mask_length;
+ nd_uint8_t act_auth_inc_res;
+ nd_uint8_t reserved;
+ nd_uint8_t reserved_version_hi;
+ nd_uint8_t version_low;
+ nd_uint16_t eid_prefix_afi;
+} lisp_map_register_eid;
+
+#define MAP_REGISTER_EID_LEN sizeof(lisp_map_register_eid)
+
+typedef struct map_register_loc {
+ nd_uint8_t priority;
+ nd_uint8_t weight;
+ nd_uint8_t m_priority;
+ nd_uint8_t m_weight;
+ nd_uint16_t unused_and_flag;
+ nd_uint16_t locator_afi;
+} lisp_map_register_loc;
+
+#define MAP_REGISTER_LOC_LEN sizeof(lisp_map_register_loc)
+
+static inline uint8_t extract_lisp_type(uint8_t);
+static inline uint8_t is_xtr_data_present(uint8_t , uint8_t);
+static void lisp_hdr_flag(netdissect_options *, const lisp_map_register_hdr *);
+static void action_flag(netdissect_options *, uint8_t);
+static void loc_hdr_flag(netdissect_options *, uint16_t);
+
+void lisp_print(netdissect_options *ndo, const u_char *bp, u_int length)
+{
+ uint8_t type;
+ uint8_t mask_len;
+ uint8_t loc_count;
+ uint8_t xtr_present;
+ uint8_t record_count;
+ uint16_t key_id;
+ uint16_t eid_afi;
+ uint16_t loc_afi;
+ uint16_t map_version;
+ uint16_t packet_offset;
+ uint16_t auth_data_len;
+ uint32_t ttl;
+ const u_char *packet_iterator;
+ const u_char *loc_ip_pointer;
+ const lisp_map_register_hdr *lisp_hdr;
+ const lisp_map_register_eid *lisp_eid;
+ const lisp_map_register_loc *lisp_loc;
+
+ /* Check if enough bytes for header are available */
+ ND_TCHECK2(*bp, MAP_REGISTER_HDR_LEN);
+ lisp_hdr = (const lisp_map_register_hdr *) bp;
+ lisp_hdr_flag(ndo, lisp_hdr);
+ /* Supporting only MAP NOTIFY and MAP REGISTER LISP packets */
+ type = extract_lisp_type(lisp_hdr->type_and_flag);
+ if ((type != LISP_MAP_REGISTER) && (type != LISP_MAP_NOTIFY))
+ return;
+
+ /* Find if the packet contains xTR and Site-ID data */
+ xtr_present = is_xtr_data_present(type, lisp_hdr->type_and_flag);
+
+ /* Extract the number of EID records present */
+ auth_data_len = EXTRACT_16BITS(&lisp_hdr->auth_data_len);
+ packet_iterator = (const u_char *)(lisp_hdr);
+ packet_offset = MAP_REGISTER_HDR_LEN;
+ record_count = lisp_hdr->record_count;
+
+ if (ndo->ndo_vflag) {
+ key_id = EXTRACT_16BITS(&lisp_hdr->key_id);
+ ND_PRINT((ndo, "\n %u record(s), ", record_count));
+ ND_PRINT((ndo, "Authentication %s,",
+ tok2str(auth_type, "unknown-type", key_id)));
+ hex_print(ndo, "\n Authentication-Data: ", packet_iterator +
+ packet_offset, auth_data_len);
+ } else {
+ ND_PRINT((ndo, " %u record(s),", record_count));
+ }
+ packet_offset += auth_data_len;
+
+ if (record_count == 0)
+ goto invalid;
+
+ /* Print all the EID records */
+ while ((length > packet_offset) && (record_count--)) {
+
+ ND_TCHECK2(*(packet_iterator + packet_offset), MAP_REGISTER_EID_LEN);
+ ND_PRINT((ndo, "\n"));
+ lisp_eid = (const lisp_map_register_eid *)
+ ((const u_char *)lisp_hdr + packet_offset);
+ packet_offset += MAP_REGISTER_EID_LEN;
+ mask_len = lisp_eid->eid_prefix_mask_length;
+ eid_afi = EXTRACT_16BITS(&lisp_eid->eid_prefix_afi);
+ loc_count = lisp_eid->locator_count;
+
+ if (ndo->ndo_vflag) {
+ ttl = EXTRACT_32BITS(&lisp_eid->ttl);
+ ND_PRINT((ndo, " Record TTL %u,", ttl));
+ action_flag(ndo, lisp_eid->act_auth_inc_res);
+ map_version = (((lisp_eid->reserved_version_hi) & 15 ) * 255) +
+ lisp_eid->version_low;
+ ND_PRINT((ndo, " Map Version: %u,", map_version));
+ }
+
+ switch (eid_afi) {
+ case IPv4_AFI:
+ ND_TCHECK2(*(packet_iterator + packet_offset), 4);
+ ND_PRINT((ndo, " EID %s/%u,", ipaddr_string(ndo,
+ packet_iterator + packet_offset), mask_len));
+ packet_offset += 4;
+ break;
+ case IPv6_AFI:
+ ND_TCHECK2(*(packet_iterator + packet_offset), 16);
+ ND_PRINT((ndo, " EID %s/%u,", ip6addr_string(ndo,
+ packet_iterator + packet_offset), mask_len));
+ packet_offset += 16;
+ break;
+ default:
+ /*
+ * No support for LCAF right now.
+ */
+ return;
+ break;
+ }
+
+ ND_PRINT((ndo, " %u locator(s)", loc_count));
+
+ while (loc_count--) {
+ ND_TCHECK2(*(packet_iterator + packet_offset), MAP_REGISTER_LOC_LEN);
+ lisp_loc = (const lisp_map_register_loc *) (packet_iterator + packet_offset);
+ loc_ip_pointer = (const u_char *) (lisp_loc + 1);
+ packet_offset += MAP_REGISTER_LOC_LEN;
+ loc_afi = EXTRACT_16BITS(&lisp_loc->locator_afi);
+
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo, "\n "));
+
+ switch (loc_afi) {
+ case IPv4_AFI:
+ ND_TCHECK2(*(packet_iterator + packet_offset), 4);
+ ND_PRINT((ndo, " LOC %s", ipaddr_string(ndo, loc_ip_pointer)));
+ packet_offset += 4;
+ break;
+ case IPv6_AFI:
+ ND_TCHECK2(*(packet_iterator + packet_offset), 16);
+ ND_PRINT((ndo, " LOC %s", ip6addr_string(ndo, loc_ip_pointer)));
+ packet_offset += 16;
+ break;
+ default:
+ break;
+ }
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo, "\n Priority/Weight %u/%u,"
+ " Multicast Priority/Weight %u/%u,",
+ lisp_loc->priority, lisp_loc->weight,
+ lisp_loc->m_priority, lisp_loc->m_weight));
+ loc_hdr_flag(ndo, EXTRACT_16BITS(&lisp_loc->unused_and_flag));
+ }
+ }
+ }
+
+ /*
+ * Print xTR and Site ID. Handle the fact that the packet could be invalid.
+ * If the xTR_ID_Present bit is not set, and we still have data to display,
+ * show it as hex data.
+ */
+ if (xtr_present) {
+ if (!ND_TTEST2(*(packet_iterator + packet_offset), 24))
+ goto invalid;
+ hex_print_with_offset(ndo, "\n xTR-ID: ", packet_iterator + packet_offset, 16, 0);
+ ND_PRINT((ndo, "\n SITE-ID: %" PRIu64,
+ EXTRACT_64BITS(packet_iterator + packet_offset + 16)));
+ } else {
+ /* Check if packet isn't over yet */
+ if (packet_iterator + packet_offset < ndo->ndo_snapend) {
+ hex_print_with_offset(ndo, "\n Data: ", packet_iterator + packet_offset,
+ (ndo->ndo_snapend - (packet_iterator + packet_offset)), 0);
+ }
+ }
+ return;
+trunc:
+ ND_PRINT((ndo, "\n %s", tstr));
+ return;
+invalid:
+ ND_PRINT((ndo, "\n %s", istr));
+ return;
+}
+
+static inline uint8_t extract_lisp_type(uint8_t lisp_hdr_flags)
+{
+ return (lisp_hdr_flags) >> TYPE_INDEX;
+}
+
+static inline uint8_t is_xtr_data_present(uint8_t type, uint8_t lisp_hdr_flags)
+{
+ uint8_t xtr_present = 0;
+
+ if (type == LISP_MAP_REGISTER)
+ xtr_present = (lisp_hdr_flags) & LISP_MAP_REGISTER_IBIT_MASK;
+ else if (type == LISP_MAP_NOTIFY)
+ xtr_present = (lisp_hdr_flags) & LISP_MAP_NOTIFY_IBIT_MASK;
+
+ return xtr_present;
+}
+
+static void lisp_hdr_flag(netdissect_options *ndo, const lisp_map_register_hdr *lisp_hdr)
+{
+ uint8_t type = extract_lisp_type(lisp_hdr->type_and_flag);
+
+ if (!ndo->ndo_vflag) {
+ ND_PRINT((ndo, "%s,", tok2str(lisp_type, "unknown-type-%u", type)));
+ return;
+ } else {
+ ND_PRINT((ndo, "%s,", tok2str(lisp_type, "unknown-type-%u", type)));
+ }
+
+ if (type == LISP_MAP_REGISTER) {
+ ND_PRINT((ndo, " flags [%s],", bittok2str(map_register_hdr_flag,
+ "none", EXTRACT_32BITS(lisp_hdr))));
+ } else if (type == LISP_MAP_NOTIFY) {
+ ND_PRINT((ndo, " flags [%s],", bittok2str(map_notify_hdr_flag,
+ "none", EXTRACT_32BITS(lisp_hdr))));
+ }
+
+ return;
+}
+
+static void action_flag(netdissect_options *ndo, uint8_t act_auth_inc_res)
+{
+ uint8_t action;
+ uint8_t authoritative;
+
+ authoritative = ((act_auth_inc_res >> 4) & 1);
+
+ if (authoritative)
+ ND_PRINT((ndo, " Authoritative,"));
+ else
+ ND_PRINT((ndo, " Non-Authoritative,"));
+
+ action = act_auth_inc_res >> 5;
+ ND_PRINT((ndo, " %s,", tok2str(lisp_eid_action, "unknown", action)));
+}
+
+static void loc_hdr_flag(netdissect_options *ndo, uint16_t flag)
+{
+ ND_PRINT((ndo, " flags [%s],", bittok2str(lisp_loc_flag, "none", flag)));
+}
+
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-lisp-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-llc.c b/freebsd/contrib/tcpdump/print-llc.c
index f8801d39..2a00bf7f 100644
--- a/freebsd/contrib/tcpdump/print-llc.c
+++ b/freebsd/contrib/tcpdump/print-llc.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1992, 1993, 1994, 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
@@ -22,33 +25,25 @@
*
* Code by Matt Thomas, Digital Equipment Corporation
* with an awful lot of hacking by Jeffrey Mogul, DECWRL
- *
- * $FreeBSD$
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-llc.c,v 1.75 2007-04-13 09:43:11 hannes Exp $";
-#endif
+/* \summary: IEEE 802.2 LLC printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include <stdio.h>
-#include <string.h>
-
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
-#include "extract.h" /* must come after interface.h */
+#include "extract.h"
#include "llc.h"
#include "ethertype.h"
#include "oui.h"
-static struct tok llc_values[] = {
+static const struct tok llc_values[] = {
{ LLCSAP_NULL, "Null" },
{ LLCSAP_GLOBAL, "Global" },
{ LLCSAP_8021B_I, "802.1B I" },
@@ -67,7 +62,7 @@ static struct tok llc_values[] = {
{ 0, NULL },
};
-static struct tok llc_cmd_values[] = {
+static const struct tok llc_cmd_values[] = {
{ LLC_UI, "ui" },
{ LLC_TEST, "test" },
{ LLC_XID, "xid" },
@@ -79,7 +74,7 @@ static struct tok llc_cmd_values[] = {
{ 0, NULL }
};
-static const struct tok llc_flag_values[] = {
+static const struct tok llc_flag_values[] = {
{ 0, "Command" },
{ LLC_GSAP, "Response" },
{ LLC_U_POLL, "Poll" },
@@ -90,14 +85,14 @@ static const struct tok llc_flag_values[] = {
};
-static const struct tok llc_ig_flag_values[] = {
+static const struct tok llc_ig_flag_values[] = {
{ 0, "Individual" },
{ LLC_IG, "Group" },
{ 0, NULL }
};
-static const struct tok llc_supervisory_values[] = {
+static const struct tok llc_supervisory_values[] = {
{ 0, "Receiver Ready" },
{ 1, "Receiver not Ready" },
{ 2, "Reject" },
@@ -105,16 +100,17 @@ static const struct tok llc_supervisory_values[] = {
};
-static const struct tok cisco_values[] = {
+static const struct tok cisco_values[] = {
{ PID_CISCO_CDP, "CDP" },
{ PID_CISCO_VTP, "VTP" },
{ PID_CISCO_DTP, "DTP" },
{ PID_CISCO_UDLD, "UDLD" },
{ PID_CISCO_PVST, "PVST" },
+ { PID_CISCO_VLANBRIDGE, "VLAN Bridge" },
{ 0, NULL }
};
-static const struct tok bridged_values[] = {
+static const struct tok bridged_values[] = {
{ PID_RFC2684_ETH_FCS, "Ethernet + FCS" },
{ PID_RFC2684_ETH_NOFCS, "Ethernet w/o FCS" },
{ PID_RFC2684_802_4_FCS, "802.4 + FCS" },
@@ -129,12 +125,12 @@ static const struct tok bridged_values[] = {
{ 0, NULL },
};
-static const struct tok null_values[] = {
+static const struct tok null_values[] = {
{ 0, NULL }
};
struct oui_tok {
- u_int32_t oui;
+ uint32_t oui;
const struct tok *tok;
};
@@ -148,23 +144,31 @@ static const struct oui_tok oui_to_tok[] = {
};
/*
- * Returns non-zero IFF it succeeds in printing the header
+ * If we printed information about the payload, returns the length of the LLC
+ * header, plus the length of any SNAP header following it.
+ *
+ * Otherwise (for example, if the packet has unknown SAPs or has a SNAP
+ * header with an unknown OUI/PID combination), returns the *negative*
+ * of that value.
*/
int
-llc_print(const u_char *p, u_int length, u_int caplen,
- const u_char *esrc, const u_char *edst, u_short *extracted_ethertype)
+llc_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen,
+ const struct lladdr_info *src, const struct lladdr_info *dst)
{
- u_int8_t dsap_field, dsap, ssap_field, ssap;
- u_int16_t control;
+ uint8_t dsap_field, dsap, ssap_field, ssap;
+ uint16_t control;
+ int hdrlen;
int is_u;
- register int ret;
-
- *extracted_ethertype = 0;
if (caplen < 3) {
- (void)printf("[|llc]");
- default_print((u_char *)p, caplen);
- return(0);
+ ND_PRINT((ndo, "[|llc]"));
+ ND_DEFAULTPRINT((const u_char *)p, caplen);
+ return (caplen);
+ }
+ if (length < 3) {
+ ND_PRINT((ndo, "[|llc]"));
+ ND_DEFAULTPRINT((const u_char *)p, caplen);
+ return (length);
}
dsap_field = *p;
@@ -182,15 +186,21 @@ llc_print(const u_char *p, u_int length, u_int caplen,
* U frame.
*/
is_u = 1;
+ hdrlen = 3; /* DSAP, SSAP, 1-byte control field */
} else {
/*
* The control field in I and S frames is
* 2 bytes...
*/
if (caplen < 4) {
- (void)printf("[|llc]");
- default_print((u_char *)p, caplen);
- return(0);
+ ND_PRINT((ndo, "[|llc]"));
+ ND_DEFAULTPRINT((const u_char *)p, caplen);
+ return (caplen);
+ }
+ if (length < 4) {
+ ND_PRINT((ndo, "[|llc]"));
+ ND_DEFAULTPRINT((const u_char *)p, caplen);
+ return (length);
}
/*
@@ -198,6 +208,7 @@ llc_print(const u_char *p, u_int length, u_int caplen,
*/
control = EXTRACT_LE_16BITS(p + 2);
is_u = 0;
+ hdrlen = 4; /* DSAP, SSAP, 2-byte control field */
}
if (ssap_field == LLCSAP_GLOBAL && dsap_field == LLCSAP_GLOBAL) {
@@ -216,42 +227,73 @@ llc_print(const u_char *p, u_int length, u_int caplen,
* least one capture file.)
*/
- if (eflag)
- printf("IPX 802.3: ");
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, "IPX 802.3: "));
- ipx_print(p, length);
- return (1);
+ ipx_print(ndo, p, length);
+ return (0); /* no LLC header */
}
dsap = dsap_field & ~LLC_IG;
ssap = ssap_field & ~LLC_GSAP;
- if (eflag) {
- printf("LLC, dsap %s (0x%02x) %s, ssap %s (0x%02x) %s",
+ if (ndo->ndo_eflag) {
+ ND_PRINT((ndo, "LLC, dsap %s (0x%02x) %s, ssap %s (0x%02x) %s",
tok2str(llc_values, "Unknown", dsap),
dsap,
tok2str(llc_ig_flag_values, "Unknown", dsap_field & LLC_IG),
tok2str(llc_values, "Unknown", ssap),
ssap,
- tok2str(llc_flag_values, "Unknown", ssap_field & LLC_GSAP));
+ tok2str(llc_flag_values, "Unknown", ssap_field & LLC_GSAP)));
if (is_u) {
- printf(", ctrl 0x%02x: ", control);
+ ND_PRINT((ndo, ", ctrl 0x%02x: ", control));
} else {
- printf(", ctrl 0x%04x: ", control);
+ ND_PRINT((ndo, ", ctrl 0x%04x: ", control));
}
}
+ /*
+ * Skip LLC header.
+ */
+ p += hdrlen;
+ length -= hdrlen;
+ caplen -= hdrlen;
+
+ if (ssap == LLCSAP_SNAP && dsap == LLCSAP_SNAP
+ && control == LLC_UI) {
+ /*
+ * XXX - what *is* the right bridge pad value here?
+ * Does anybody ever bridge one form of LAN traffic
+ * over a networking type that uses 802.2 LLC?
+ */
+ if (!snap_print(ndo, p, length, caplen, src, dst, 2)) {
+ /*
+ * Unknown packet type; tell our caller, by
+ * returning a negative value, so they
+ * can print the raw packet.
+ */
+ return (-(hdrlen + 5)); /* include LLC and SNAP header */
+ } else
+ return (hdrlen + 5); /* include LLC and SNAP header */
+ }
+
if (ssap == LLCSAP_8021D && dsap == LLCSAP_8021D &&
control == LLC_UI) {
- stp_print(p+3, length-3);
- return (1);
+ stp_print(ndo, p, length);
+ return (hdrlen);
}
if (ssap == LLCSAP_IP && dsap == LLCSAP_IP &&
control == LLC_UI) {
- ip_print(gndo, p+4, length-4);
- return (1);
+ /*
+ * This is an RFC 948-style IP packet, with
+ * an 802.3 header and an 802.2 LLC header
+ * with the source and destination SAPs being
+ * the IP SAP.
+ */
+ ip_print(ndo, p, length);
+ return (hdrlen);
}
if (ssap == LLCSAP_IPX && dsap == LLCSAP_IPX &&
@@ -260,17 +302,15 @@ llc_print(const u_char *p, u_int length, u_int caplen,
* This is an Ethernet_802.2 IPX frame, with an 802.3
* header and an 802.2 LLC header with the source and
* destination SAPs being the IPX SAP.
- *
- * Skip DSAP, LSAP, and control field.
*/
- if (eflag)
- printf("IPX 802.2: ");
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, "IPX 802.2: "));
- ipx_print(p+3, length-3);
- return (1);
+ ipx_print(ndo, p, length);
+ return (hdrlen);
}
-#ifdef TCPDUMP_DO_SMB
+#ifdef ENABLE_SMB
if (ssap == LLCSAP_NETBEUI && dsap == LLCSAP_NETBEUI
&& (!(control & LLC_S_FMT) || control == LLC_U_FMT)) {
/*
@@ -283,130 +323,131 @@ llc_print(const u_char *p, u_int length, u_int caplen,
* LLC_S_FMT, set in the first byte of the control field)
* and UI frames (whose control field is just 3, LLC_U_FMT).
*/
-
- /*
- * Skip the LLC header.
- */
- if (is_u) {
- p += 3;
- length -= 3;
- caplen -= 3;
- } else {
- p += 4;
- length -= 4;
- caplen -= 4;
- }
- netbeui_print(control, p, length);
- return (1);
+ netbeui_print(ndo, control, p, length);
+ return (hdrlen);
}
#endif
if (ssap == LLCSAP_ISONS && dsap == LLCSAP_ISONS
&& control == LLC_UI) {
- isoclns_print(p + 3, length - 3, caplen - 3);
- return (1);
- }
-
- if (ssap == LLCSAP_SNAP && dsap == LLCSAP_SNAP
- && control == LLC_UI) {
- /*
- * XXX - what *is* the right bridge pad value here?
- * Does anybody ever bridge one form of LAN traffic
- * over a networking type that uses 802.2 LLC?
- */
- ret = snap_print(p+3, length-3, caplen-3, 2);
- if (ret)
- return (ret);
+ isoclns_print(ndo, p, length, caplen);
+ return (hdrlen);
}
- if (!eflag) {
+ if (!ndo->ndo_eflag) {
if (ssap == dsap) {
- if (esrc == NULL || edst == NULL)
- (void)printf("%s ", tok2str(llc_values, "Unknown DSAP 0x%02x", dsap));
+ if (src == NULL || dst == NULL)
+ ND_PRINT((ndo, "%s ", tok2str(llc_values, "Unknown DSAP 0x%02x", dsap)));
else
- (void)printf("%s > %s %s ",
- etheraddr_string(esrc),
- etheraddr_string(edst),
- tok2str(llc_values, "Unknown DSAP 0x%02x", dsap));
+ ND_PRINT((ndo, "%s > %s %s ",
+ (src->addr_string)(ndo, src->addr),
+ (dst->addr_string)(ndo, dst->addr),
+ tok2str(llc_values, "Unknown DSAP 0x%02x", dsap)));
} else {
- if (esrc == NULL || edst == NULL)
- (void)printf("%s > %s ",
+ if (src == NULL || dst == NULL)
+ ND_PRINT((ndo, "%s > %s ",
tok2str(llc_values, "Unknown SSAP 0x%02x", ssap),
- tok2str(llc_values, "Unknown DSAP 0x%02x", dsap));
+ tok2str(llc_values, "Unknown DSAP 0x%02x", dsap)));
else
- (void)printf("%s %s > %s %s ",
- etheraddr_string(esrc),
+ ND_PRINT((ndo, "%s %s > %s %s ",
+ (src->addr_string)(ndo, src->addr),
tok2str(llc_values, "Unknown SSAP 0x%02x", ssap),
- etheraddr_string(edst),
- tok2str(llc_values, "Unknown DSAP 0x%02x", dsap));
+ (dst->addr_string)(ndo, dst->addr),
+ tok2str(llc_values, "Unknown DSAP 0x%02x", dsap)));
}
}
if (is_u) {
- printf("Unnumbered, %s, Flags [%s], length %u",
+ ND_PRINT((ndo, "Unnumbered, %s, Flags [%s], length %u",
tok2str(llc_cmd_values, "%02x", LLC_U_CMD(control)),
tok2str(llc_flag_values,"?",(ssap_field & LLC_GSAP) | (control & LLC_U_POLL)),
- length);
-
- p += 3;
- length -= 3;
- caplen -= 3;
+ length + hdrlen));
if ((control & ~LLC_U_POLL) == LLC_XID) {
+ if (length == 0) {
+ /*
+ * XID with no payload.
+ * This could, for example, be an SNA
+ * "short form" XID.
+ */
+ return (hdrlen);
+ }
+ if (caplen < 1) {
+ ND_PRINT((ndo, "[|llc]"));
+ if (caplen > 0)
+ ND_DEFAULTPRINT((const u_char *)p, caplen);
+ return (hdrlen);
+ }
if (*p == LLC_XID_FI) {
- printf(": %02x %02x", p[1], p[2]);
- p += 3;
- length -= 3;
- caplen -= 3;
+ if (caplen < 3 || length < 3) {
+ ND_PRINT((ndo, "[|llc]"));
+ if (caplen > 0)
+ ND_DEFAULTPRINT((const u_char *)p, caplen);
+ } else
+ ND_PRINT((ndo, ": %02x %02x", p[1], p[2]));
+ return (hdrlen);
}
}
} else {
if ((control & LLC_S_FMT) == LLC_S_FMT) {
- (void)printf("Supervisory, %s, rcv seq %u, Flags [%s], length %u",
+ ND_PRINT((ndo, "Supervisory, %s, rcv seq %u, Flags [%s], length %u",
tok2str(llc_supervisory_values,"?",LLC_S_CMD(control)),
LLC_IS_NR(control),
tok2str(llc_flag_values,"?",(ssap_field & LLC_GSAP) | (control & LLC_IS_POLL)),
- length);
+ length + hdrlen));
+ return (hdrlen); /* no payload to print */
} else {
- (void)printf("Information, send seq %u, rcv seq %u, Flags [%s], length %u",
+ ND_PRINT((ndo, "Information, send seq %u, rcv seq %u, Flags [%s], length %u",
LLC_I_NS(control),
LLC_IS_NR(control),
tok2str(llc_flag_values,"?",(ssap_field & LLC_GSAP) | (control & LLC_IS_POLL)),
- length);
+ length + hdrlen));
}
- p += 4;
- length -= 4;
- caplen -= 4;
}
- return(1);
+ return (-hdrlen);
+}
+
+static const struct tok *
+oui_to_struct_tok(uint32_t orgcode)
+{
+ const struct tok *tok = null_values;
+ const struct oui_tok *otp;
+
+ for (otp = &oui_to_tok[0]; otp->tok != NULL; otp++) {
+ if (otp->oui == orgcode) {
+ tok = otp->tok;
+ break;
+ }
+ }
+ return (tok);
}
int
-snap_print(const u_char *p, u_int length, u_int caplen, u_int bridge_pad)
+snap_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen,
+ const struct lladdr_info *src, const struct lladdr_info *dst,
+ u_int bridge_pad)
{
- u_int32_t orgcode;
+ uint32_t orgcode;
register u_short et;
register int ret;
- TCHECK2(*p, 5);
+ ND_TCHECK2(*p, 5);
+ if (caplen < 5 || length < 5)
+ goto trunc;
orgcode = EXTRACT_24BITS(p);
et = EXTRACT_16BITS(p + 3);
- if (eflag) {
- const struct tok *tok = null_values;
- const struct oui_tok *otp;
-
- for (otp = &oui_to_tok[0]; otp->tok != NULL; otp++) {
- if (otp->oui == orgcode) {
- tok = otp->tok;
- break;
- }
- }
- (void)printf("oui %s (0x%06x), %s %s (0x%04x): ",
+ if (ndo->ndo_eflag) {
+ /*
+ * Somebody's already printed the MAC addresses, if there
+ * are any, so just print the SNAP header, not the MAC
+ * addresses.
+ */
+ ND_PRINT((ndo, "oui %s (0x%06x), %s %s (0x%04x), length %u: ",
tok2str(oui_values, "Unknown", orgcode),
orgcode,
(orgcode == 0x000000 ? "ethertype" : "pid"),
- tok2str(tok, "Unknown", et),
- et);
+ tok2str(oui_to_struct_tok(orgcode), "Unknown", et),
+ et, length - 5));
}
p += 5;
length -= 5;
@@ -421,7 +462,7 @@ snap_print(const u_char *p, u_int length, u_int caplen, u_int bridge_pad)
* Cisco hardware; the protocol ID is
* an Ethernet protocol type.
*/
- ret = ethertype_print(gndo, et, p, length, caplen);
+ ret = ethertype_print(ndo, et, p, length, caplen, src, dst);
if (ret)
return (ret);
break;
@@ -436,7 +477,7 @@ snap_print(const u_char *p, u_int length, u_int caplen, u_int bridge_pad)
* but used 0x000000 and an Ethernet
* packet type for AARP packets.
*/
- ret = ethertype_print(gndo, et, p, length, caplen);
+ ret = ethertype_print(ndo, et, p, length, caplen, src, dst);
if (ret)
return (ret);
}
@@ -445,23 +486,25 @@ snap_print(const u_char *p, u_int length, u_int caplen, u_int bridge_pad)
case OUI_CISCO:
switch (et) {
case PID_CISCO_CDP:
- cdp_print(p, length, caplen);
+ cdp_print(ndo, p, length, caplen);
return (1);
case PID_CISCO_DTP:
- dtp_print(p, length);
+ dtp_print(ndo, p, length);
return (1);
case PID_CISCO_UDLD:
- udld_print(p, length);
+ udld_print(ndo, p, length);
return (1);
case PID_CISCO_VTP:
- vtp_print(p, length);
+ vtp_print(ndo, p, length);
return (1);
case PID_CISCO_PVST:
- stp_print(p, length);
+ case PID_CISCO_VLANBRIDGE:
+ stp_print(ndo, p, length);
return (1);
default:
break;
}
+ break;
case OUI_RFC2684:
switch (et) {
@@ -475,7 +518,7 @@ snap_print(const u_char *p, u_int length, u_int caplen, u_int bridge_pad)
/*
* Skip the padding.
*/
- TCHECK2(*p, bridge_pad);
+ ND_TCHECK2(*p, bridge_pad);
caplen -= bridge_pad;
length -= bridge_pad;
p += bridge_pad;
@@ -483,7 +526,7 @@ snap_print(const u_char *p, u_int length, u_int caplen, u_int bridge_pad)
/*
* What remains is an Ethernet packet.
*/
- ether_print(gndo, p, length, caplen, NULL, NULL);
+ ether_print(ndo, p, length, caplen, NULL, NULL);
return (1);
case PID_RFC2684_802_5_FCS:
@@ -496,7 +539,7 @@ snap_print(const u_char *p, u_int length, u_int caplen, u_int bridge_pad)
* Skip the padding, but not the Access
* Control field.
*/
- TCHECK2(*p, bridge_pad);
+ ND_TCHECK2(*p, bridge_pad);
caplen -= bridge_pad;
length -= bridge_pad;
p += bridge_pad;
@@ -505,7 +548,7 @@ snap_print(const u_char *p, u_int length, u_int caplen, u_int bridge_pad)
* What remains is an 802.5 Token Ring
* packet.
*/
- token_print(p, length, caplen);
+ token_print(ndo, p, length, caplen);
return (1);
case PID_RFC2684_FDDI_FCS:
@@ -517,7 +560,7 @@ snap_print(const u_char *p, u_int length, u_int caplen, u_int bridge_pad)
/*
* Skip the padding.
*/
- TCHECK2(*p, bridge_pad + 1);
+ ND_TCHECK2(*p, bridge_pad + 1);
caplen -= bridge_pad + 1;
length -= bridge_pad + 1;
p += bridge_pad + 1;
@@ -525,18 +568,45 @@ snap_print(const u_char *p, u_int length, u_int caplen, u_int bridge_pad)
/*
* What remains is an FDDI packet.
*/
- fddi_print(p, length, caplen);
+ fddi_print(ndo, p, length, caplen);
return (1);
case PID_RFC2684_BPDU:
- stp_print(p, length);
+ stp_print(ndo, p, length);
return (1);
}
}
+ if (!ndo->ndo_eflag) {
+ /*
+ * Nobody printed the link-layer addresses, so print them, if
+ * we have any.
+ */
+ if (src != NULL && dst != NULL) {
+ ND_PRINT((ndo, "%s > %s ",
+ (src->addr_string)(ndo, src->addr),
+ (dst->addr_string)(ndo, dst->addr)));
+ }
+ /*
+ * Print the SNAP header, but if the OUI is 000000, don't
+ * bother printing it, and report the PID as being an
+ * ethertype.
+ */
+ if (orgcode == 0x000000) {
+ ND_PRINT((ndo, "SNAP, ethertype %s (0x%04x), length %u: ",
+ tok2str(ethertype_values, "Unknown", et),
+ et, length));
+ } else {
+ ND_PRINT((ndo, "SNAP, oui %s (0x%06x), pid %s (0x%04x), length %u: ",
+ tok2str(oui_values, "Unknown", orgcode),
+ orgcode,
+ tok2str(oui_to_struct_tok(orgcode), "Unknown", et),
+ et, length));
+ }
+ }
return (0);
trunc:
- (void)printf("[|snap]");
+ ND_PRINT((ndo, "[|snap]"));
return (1);
}
@@ -547,3 +617,6 @@ trunc:
* c-basic-offset: 8
* End:
*/
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-llc-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-lldp.c b/freebsd/contrib/tcpdump/print-lldp.c
index 24e1c860..1dac40dc 100644
--- a/freebsd/contrib/tcpdump/print-lldp.c
+++ b/freebsd/contrib/tcpdump/print-lldp.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1998-2007 The TCPDUMP project
*
@@ -14,36 +17,29 @@
* LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE.
*
- * support for the IEEE Link Discovery Protocol as per 802.1AB
- *
* Original code by Hannes Gredler (hannes@juniper.net)
* IEEE and TIA extensions by Carles Kishimoto <carles.kishimoto@gmail.com>
* DCBX extensions by Kaladhar Musunuru <kaladharm@sourceforge.net>
*/
-#ifndef lint
-static const char rcsid[] _U_ =
-"@(#) $Header: /tcpdump/master/tcpdump/print-lldp.c,v 1.10 2008-03-20 09:30:56 hannes Exp $";
-#endif
+/* \summary: IEEE 802.1ab Link Layer Discovery Protocol (LLDP) printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
#include "addrtoname.h"
#include "af.h"
#include "oui.h"
-#define LLDP_EXTRACT_TYPE(x) (((x)&0xfe00)>>9)
-#define LLDP_EXTRACT_LEN(x) ((x)&0x01ff)
+#define LLDP_EXTRACT_TYPE(x) (((x)&0xfe00)>>9)
+#define LLDP_EXTRACT_LEN(x) ((x)&0x01ff)
/*
* TLV type codes
@@ -145,12 +141,26 @@ static const struct tok lldp_cap_values[] = {
#define LLDP_PRIVATE_8021_SUBTYPE_PROTOCOL_VLAN_ID 2
#define LLDP_PRIVATE_8021_SUBTYPE_VLAN_NAME 3
#define LLDP_PRIVATE_8021_SUBTYPE_PROTOCOL_IDENTITY 4
+#define LLDP_PRIVATE_8021_SUBTYPE_CONGESTION_NOTIFICATION 8
+#define LLDP_PRIVATE_8021_SUBTYPE_ETS_CONFIGURATION 9
+#define LLDP_PRIVATE_8021_SUBTYPE_ETS_RECOMMENDATION 10
+#define LLDP_PRIVATE_8021_SUBTYPE_PFC_CONFIGURATION 11
+#define LLDP_PRIVATE_8021_SUBTYPE_APPLICATION_PRIORITY 12
+#define LLDP_PRIVATE_8021_SUBTYPE_EVB 13
+#define LLDP_PRIVATE_8021_SUBTYPE_CDCP 14
static const struct tok lldp_8021_subtype_values[] = {
{ LLDP_PRIVATE_8021_SUBTYPE_PORT_VLAN_ID, "Port VLAN Id"},
{ LLDP_PRIVATE_8021_SUBTYPE_PROTOCOL_VLAN_ID, "Port and Protocol VLAN ID"},
{ LLDP_PRIVATE_8021_SUBTYPE_VLAN_NAME, "VLAN name"},
{ LLDP_PRIVATE_8021_SUBTYPE_PROTOCOL_IDENTITY, "Protocol Identity"},
+ { LLDP_PRIVATE_8021_SUBTYPE_CONGESTION_NOTIFICATION, "Congestion Notification"},
+ { LLDP_PRIVATE_8021_SUBTYPE_ETS_CONFIGURATION, "ETS Configuration"},
+ { LLDP_PRIVATE_8021_SUBTYPE_ETS_RECOMMENDATION, "ETS Recommendation"},
+ { LLDP_PRIVATE_8021_SUBTYPE_PFC_CONFIGURATION, "Priority Flow Control Configuration"},
+ { LLDP_PRIVATE_8021_SUBTYPE_APPLICATION_PRIORITY, "Application Priority"},
+ { LLDP_PRIVATE_8021_SUBTYPE_EVB, "EVB"},
+ { LLDP_PRIVATE_8021_SUBTYPE_CDCP,"CDCP"},
{ 0, NULL}
};
@@ -232,7 +242,7 @@ static const struct tok lldp_tia_location_lci_catype_values[] = {
static const struct tok lldp_tia_location_lci_what_values[] = {
{ 0, "location of DHCP server"},
- { 1, "location of the network element believed to be closest to the client"},
+ { 1, "location of the network element believed to be closest to the client"},
{ 2, "location of the client"},
{ 0, NULL}
};
@@ -461,7 +471,7 @@ static const struct tok lldp_tia_inventory_values[] = {
/*
* From RFC 3636 - ifMauAutoNegCapAdvertisedBits
- */
+ */
#define LLDP_MAU_PMD_OTHER (1 << 15)
#define LLDP_MAU_PMD_10BASE_T (1 << 14)
#define LLDP_MAU_PMD_10BASE_T_FD (1 << 13)
@@ -575,47 +585,109 @@ static const struct tok lldp_intf_numb_subtype_values[] = {
#define LLDP_INTF_NUM_LEN 5
+#define LLDP_EVB_MODE_NOT_SUPPORTED 0
+#define LLDP_EVB_MODE_EVB_BRIDGE 1
+#define LLDP_EVB_MODE_EVB_STATION 2
+#define LLDP_EVB_MODE_RESERVED 3
+
+static const struct tok lldp_evb_mode_values[]={
+ { LLDP_EVB_MODE_NOT_SUPPORTED, "Not Supported"},
+ { LLDP_EVB_MODE_EVB_BRIDGE, "EVB Bridge"},
+ { LLDP_EVB_MODE_EVB_STATION, "EVB Staion"},
+ { LLDP_EVB_MODE_RESERVED, "Reserved for future Standardization"},
+};
+
+#define NO_OF_BITS 8
+#define LLDP_PRIVATE_8021_SUBTYPE_CONGESTION_NOTIFICATION_LENGTH 6
+#define LLDP_PRIVATE_8021_SUBTYPE_ETS_CONFIGURATION_LENGTH 25
+#define LLDP_PRIVATE_8021_SUBTYPE_ETS_RECOMMENDATION_LENGTH 25
+#define LLDP_PRIVATE_8021_SUBTYPE_PFC_CONFIGURATION_LENGTH 6
+#define LLDP_PRIVATE_8021_SUBTYPE_APPLICATION_PRIORITY_MIN_LENGTH 5
+#define LLDP_PRIVATE_8021_SUBTYPE_EVB_LENGTH 9
+#define LLDP_PRIVATE_8021_SUBTYPE_CDCP_MIN_LENGTH 8
+
+#define LLDP_IANA_SUBTYPE_MUDURL 1
+
+static const struct tok lldp_iana_subtype_values[] = {
+ { LLDP_IANA_SUBTYPE_MUDURL, "MUD-URL" },
+ { 0, NULL }
+};
+
+
+static void
+print_ets_priority_assignment_table(netdissect_options *ndo,
+ const u_char *ptr)
+{
+ ND_PRINT((ndo, "\n\t Priority Assignment Table"));
+ ND_PRINT((ndo, "\n\t Priority : 0 1 2 3 4 5 6 7"));
+ ND_PRINT((ndo, "\n\t Value : %-3d %-3d %-3d %-3d %-3d %-3d %-3d %-3d",
+ ptr[0]>>4,ptr[0]&0x0f,ptr[1]>>4,ptr[1]&0x0f,ptr[2]>>4,
+ ptr[2] & 0x0f, ptr[3] >> 4, ptr[3] & 0x0f));
+}
+
+static void
+print_tc_bandwidth_table(netdissect_options *ndo,
+ const u_char *ptr)
+{
+ ND_PRINT((ndo, "\n\t TC Bandwidth Table"));
+ ND_PRINT((ndo, "\n\t TC%% : 0 1 2 3 4 5 6 7"));
+ ND_PRINT((ndo, "\n\t Value : %-3d %-3d %-3d %-3d %-3d %-3d %-3d %-3d",
+ ptr[0], ptr[1], ptr[2], ptr[3], ptr[4], ptr[5], ptr[6], ptr[7]));
+}
+
+static void
+print_tsa_assignment_table(netdissect_options *ndo,
+ const u_char *ptr)
+{
+ ND_PRINT((ndo, "\n\t TSA Assignment Table"));
+ ND_PRINT((ndo, "\n\t Traffic Class: 0 1 2 3 4 5 6 7"));
+ ND_PRINT((ndo, "\n\t Value : %-3d %-3d %-3d %-3d %-3d %-3d %-3d %-3d",
+ ptr[0], ptr[1], ptr[2], ptr[3], ptr[4], ptr[5], ptr[6], ptr[7]));
+}
+
/*
* Print IEEE 802.1 private extensions. (802.1AB annex E)
*/
static int
-lldp_private_8021_print(const u_char *tptr, u_int tlv_len)
+lldp_private_8021_print(netdissect_options *ndo,
+ const u_char *tptr, u_int tlv_len)
{
int subtype, hexdump = FALSE;
u_int sublen;
+ u_int tval;
+ uint8_t i;
if (tlv_len < 4) {
return hexdump;
}
subtype = *(tptr+3);
- printf("\n\t %s Subtype (%u)",
+ ND_PRINT((ndo, "\n\t %s Subtype (%u)",
tok2str(lldp_8021_subtype_values, "unknown", subtype),
- subtype);
+ subtype));
switch (subtype) {
case LLDP_PRIVATE_8021_SUBTYPE_PORT_VLAN_ID:
if (tlv_len < 6) {
return hexdump;
}
- printf("\n\t port vlan id (PVID): %u",
- EXTRACT_16BITS(tptr+4));
+ ND_PRINT((ndo, "\n\t port vlan id (PVID): %u",
+ EXTRACT_16BITS(tptr + 4)));
break;
case LLDP_PRIVATE_8021_SUBTYPE_PROTOCOL_VLAN_ID:
if (tlv_len < 7) {
return hexdump;
}
- printf("\n\t port and protocol vlan id (PPVID): %u, flags [%s] (0x%02x)",
+ ND_PRINT((ndo, "\n\t port and protocol vlan id (PPVID): %u, flags [%s] (0x%02x)",
EXTRACT_16BITS(tptr+5),
bittok2str(lldp_8021_port_protocol_id_values, "none", *(tptr+4)),
- *(tptr+4));
+ *(tptr + 4)));
break;
case LLDP_PRIVATE_8021_SUBTYPE_VLAN_NAME:
if (tlv_len < 6) {
return hexdump;
}
- printf("\n\t vlan id (VID): %u",
- EXTRACT_16BITS(tptr+4));
+ ND_PRINT((ndo, "\n\t vlan id (VID): %u", EXTRACT_16BITS(tptr + 4)));
if (tlv_len < 7) {
return hexdump;
}
@@ -623,8 +695,8 @@ lldp_private_8021_print(const u_char *tptr, u_int tlv_len)
if (tlv_len < 7+sublen) {
return hexdump;
}
- printf("\n\t vlan name: ");
- safeputs((const char *)tptr+7, sublen);
+ ND_PRINT((ndo, "\n\t vlan name: "));
+ safeputs(ndo, tptr + 7, sublen);
break;
case LLDP_PRIVATE_8021_SUBTYPE_PROTOCOL_IDENTITY:
if (tlv_len < 5) {
@@ -634,8 +706,138 @@ lldp_private_8021_print(const u_char *tptr, u_int tlv_len)
if (tlv_len < 5+sublen) {
return hexdump;
}
- printf("\n\t protocol identity: ");
- safeputs((const char *)tptr+5, sublen);
+ ND_PRINT((ndo, "\n\t protocol identity: "));
+ safeputs(ndo, tptr + 5, sublen);
+ break;
+ case LLDP_PRIVATE_8021_SUBTYPE_CONGESTION_NOTIFICATION:
+ if(tlv_len<LLDP_PRIVATE_8021_SUBTYPE_CONGESTION_NOTIFICATION_LENGTH){
+ return hexdump;
+ }
+ tval=*(tptr+4);
+ ND_PRINT((ndo, "\n\t Pre-Priority CNPV Indicator"));
+ ND_PRINT((ndo, "\n\t Priority : 0 1 2 3 4 5 6 7"));
+ ND_PRINT((ndo, "\n\t Value : "));
+ for(i=0;i<NO_OF_BITS;i++)
+ ND_PRINT((ndo, "%-2d ", (tval >> i) & 0x01));
+ tval=*(tptr+5);
+ ND_PRINT((ndo, "\n\t Pre-Priority Ready Indicator"));
+ ND_PRINT((ndo, "\n\t Priority : 0 1 2 3 4 5 6 7"));
+ ND_PRINT((ndo, "\n\t Value : "));
+ for(i=0;i<NO_OF_BITS;i++)
+ ND_PRINT((ndo, "%-2d ", (tval >> i) & 0x01));
+ break;
+
+ case LLDP_PRIVATE_8021_SUBTYPE_ETS_CONFIGURATION:
+ if(tlv_len<LLDP_PRIVATE_8021_SUBTYPE_ETS_CONFIGURATION_LENGTH) {
+ return hexdump;
+ }
+ tval=*(tptr+4);
+ ND_PRINT((ndo, "\n\t Willing:%d, CBS:%d, RES:%d, Max TCs:%d",
+ tval >> 7, (tval >> 6) & 0x02, (tval >> 3) & 0x07, tval & 0x07));
+
+ /*Print Priority Assignment Table*/
+ print_ets_priority_assignment_table(ndo, tptr + 5);
+
+ /*Print TC Bandwidth Table*/
+ print_tc_bandwidth_table(ndo, tptr + 9);
+
+ /* Print TSA Assignment Table */
+ print_tsa_assignment_table(ndo, tptr + 17);
+
+ break;
+
+ case LLDP_PRIVATE_8021_SUBTYPE_ETS_RECOMMENDATION:
+ if(tlv_len<LLDP_PRIVATE_8021_SUBTYPE_ETS_RECOMMENDATION_LENGTH) {
+ return hexdump;
+ }
+ ND_PRINT((ndo, "\n\t RES: %d", *(tptr + 4)));
+ /*Print Priority Assignment Table */
+ print_ets_priority_assignment_table(ndo, tptr + 5);
+ /*Print TC Bandwidth Table */
+ print_tc_bandwidth_table(ndo, tptr + 9);
+ /* Print TSA Assignment Table */
+ print_tsa_assignment_table(ndo, tptr + 17);
+ break;
+
+ case LLDP_PRIVATE_8021_SUBTYPE_PFC_CONFIGURATION:
+ if(tlv_len<LLDP_PRIVATE_8021_SUBTYPE_PFC_CONFIGURATION_LENGTH) {
+ return hexdump;
+ }
+ tval=*(tptr+4);
+ ND_PRINT((ndo, "\n\t Willing: %d, MBC: %d, RES: %d, PFC cap:%d ",
+ tval >> 7, (tval >> 6) & 0x01, (tval >> 4) & 0x03, (tval & 0x0f)));
+ ND_PRINT((ndo, "\n\t PFC Enable"));
+ tval=*(tptr+5);
+ ND_PRINT((ndo, "\n\t Priority : 0 1 2 3 4 5 6 7"));
+ ND_PRINT((ndo, "\n\t Value : "));
+ for(i=0;i<NO_OF_BITS;i++)
+ ND_PRINT((ndo, "%-2d ", (tval >> i) & 0x01));
+ break;
+
+ case LLDP_PRIVATE_8021_SUBTYPE_APPLICATION_PRIORITY:
+ if(tlv_len<LLDP_PRIVATE_8021_SUBTYPE_APPLICATION_PRIORITY_MIN_LENGTH) {
+ return hexdump;
+ }
+ ND_PRINT((ndo, "\n\t RES: %d", *(tptr + 4)));
+ if(tlv_len<=LLDP_PRIVATE_8021_SUBTYPE_APPLICATION_PRIORITY_MIN_LENGTH){
+ return hexdump;
+ }
+ /* Length of Application Priority Table */
+ sublen=tlv_len-5;
+ if(sublen%3!=0){
+ return hexdump;
+ }
+ i=0;
+ ND_PRINT((ndo, "\n\t Application Priority Table"));
+ while(i<sublen) {
+ tval=*(tptr+i+5);
+ ND_PRINT((ndo, "\n\t Priority: %d, RES: %d, Sel: %d",
+ tval >> 5, (tval >> 3) & 0x03, (tval & 0x07)));
+ ND_PRINT((ndo, "Protocol ID: %d", EXTRACT_16BITS(tptr + i + 5)));
+ i=i+3;
+ }
+ break;
+ case LLDP_PRIVATE_8021_SUBTYPE_EVB:
+ if(tlv_len<LLDP_PRIVATE_8021_SUBTYPE_EVB_LENGTH){
+ return hexdump;
+ }
+ ND_PRINT((ndo, "\n\t EVB Bridge Status"));
+ tval=*(tptr+4);
+ ND_PRINT((ndo, "\n\t RES: %d, BGID: %d, RRCAP: %d, RRCTR: %d",
+ tval >> 3, (tval >> 2) & 0x01, (tval >> 1) & 0x01, tval & 0x01));
+ ND_PRINT((ndo, "\n\t EVB Station Status"));
+ tval=*(tptr+5);
+ ND_PRINT((ndo, "\n\t RES: %d, SGID: %d, RRREQ: %d,RRSTAT: %d",
+ tval >> 4, (tval >> 3) & 0x01, (tval >> 2) & 0x01, tval & 0x03));
+ tval=*(tptr+6);
+ ND_PRINT((ndo, "\n\t R: %d, RTE: %d, ",tval >> 5, tval & 0x1f));
+ tval=*(tptr+7);
+ ND_PRINT((ndo, "EVB Mode: %s [%d]",
+ tok2str(lldp_evb_mode_values, "unknown", tval >> 6), tval >> 6));
+ ND_PRINT((ndo, "\n\t ROL: %d, RWD: %d, ", (tval >> 5) & 0x01, tval & 0x1f));
+ tval=*(tptr+8);
+ ND_PRINT((ndo, "RES: %d, ROL: %d, RKA: %d", tval >> 6, (tval >> 5) & 0x01, tval & 0x1f));
+ break;
+
+ case LLDP_PRIVATE_8021_SUBTYPE_CDCP:
+ if(tlv_len<LLDP_PRIVATE_8021_SUBTYPE_CDCP_MIN_LENGTH){
+ return hexdump;
+ }
+ tval=*(tptr+4);
+ ND_PRINT((ndo, "\n\t Role: %d, RES: %d, Scomp: %d ",
+ tval >> 7, (tval >> 4) & 0x07, (tval >> 3) & 0x01));
+ ND_PRINT((ndo, "ChnCap: %d", EXTRACT_16BITS(tptr + 6) & 0x0fff));
+ sublen=tlv_len-8;
+ if(sublen%3!=0) {
+ return hexdump;
+ }
+ i=0;
+ while(i<sublen) {
+ tval=EXTRACT_24BITS(tptr+i+8);
+ ND_PRINT((ndo, "\n\t SCID: %d, SVID: %d",
+ tval >> 12, tval & 0x000fff));
+ i=i+3;
+ }
break;
default:
@@ -650,7 +852,8 @@ lldp_private_8021_print(const u_char *tptr, u_int tlv_len)
* Print IEEE 802.3 private extensions. (802.3bc)
*/
static int
-lldp_private_8023_print(const u_char *tptr, u_int tlv_len)
+lldp_private_8023_print(netdissect_options *ndo,
+ const u_char *tptr, u_int tlv_len)
{
int subtype, hexdump = FALSE;
@@ -659,47 +862,47 @@ lldp_private_8023_print(const u_char *tptr, u_int tlv_len)
}
subtype = *(tptr+3);
- printf("\n\t %s Subtype (%u)",
+ ND_PRINT((ndo, "\n\t %s Subtype (%u)",
tok2str(lldp_8023_subtype_values, "unknown", subtype),
- subtype);
+ subtype));
switch (subtype) {
case LLDP_PRIVATE_8023_SUBTYPE_MACPHY:
if (tlv_len < 9) {
return hexdump;
}
- printf("\n\t autonegotiation [%s] (0x%02x)",
+ ND_PRINT((ndo, "\n\t autonegotiation [%s] (0x%02x)",
bittok2str(lldp_8023_autonegotiation_values, "none", *(tptr+4)),
- *(tptr+4));
- printf("\n\t PMD autoneg capability [%s] (0x%04x)",
+ *(tptr + 4)));
+ ND_PRINT((ndo, "\n\t PMD autoneg capability [%s] (0x%04x)",
bittok2str(lldp_pmd_capability_values,"unknown", EXTRACT_16BITS(tptr+5)),
- EXTRACT_16BITS(tptr+5));
- printf("\n\t MAU type %s (0x%04x)",
+ EXTRACT_16BITS(tptr + 5)));
+ ND_PRINT((ndo, "\n\t MAU type %s (0x%04x)",
tok2str(lldp_mau_types_values, "unknown", EXTRACT_16BITS(tptr+7)),
- EXTRACT_16BITS(tptr+7));
+ EXTRACT_16BITS(tptr + 7)));
break;
case LLDP_PRIVATE_8023_SUBTYPE_MDIPOWER:
if (tlv_len < 7) {
return hexdump;
}
- printf("\n\t MDI power support [%s], power pair %s, power class %s",
+ ND_PRINT((ndo, "\n\t MDI power support [%s], power pair %s, power class %s",
bittok2str(lldp_mdi_values, "none", *(tptr+4)),
tok2str(lldp_mdi_power_pairs_values, "unknown", *(tptr+5)),
- tok2str(lldp_mdi_power_class_values, "unknown", *(tptr+6)));
+ tok2str(lldp_mdi_power_class_values, "unknown", *(tptr + 6))));
break;
case LLDP_PRIVATE_8023_SUBTYPE_LINKAGGR:
if (tlv_len < 9) {
return hexdump;
}
- printf("\n\t aggregation status [%s], aggregation port ID %u",
+ ND_PRINT((ndo, "\n\t aggregation status [%s], aggregation port ID %u",
bittok2str(lldp_aggregation_values, "none", *(tptr+4)),
- EXTRACT_32BITS(tptr+5));
+ EXTRACT_32BITS(tptr + 5)));
break;
case LLDP_PRIVATE_8023_SUBTYPE_MTU:
- printf("\n\t MTU size %u", EXTRACT_16BITS(tptr+4));
+ ND_PRINT((ndo, "\n\t MTU size %u", EXTRACT_16BITS(tptr + 4)));
break;
default:
@@ -713,10 +916,10 @@ lldp_private_8023_print(const u_char *tptr, u_int tlv_len)
/*
* Extract 34bits of latitude/longitude coordinates.
*/
-static u_int64_t
+static uint64_t
lldp_extract_latlon(const u_char *tptr)
{
- u_int64_t latlon;
+ uint64_t latlon;
latlon = *tptr & 0x3;
latlon = (latlon << 32) | EXTRACT_32BITS(tptr+1);
@@ -724,55 +927,90 @@ lldp_extract_latlon(const u_char *tptr)
return latlon;
}
+/* objects defined in IANA subtype 00 00 5e
+ * (right now there is only one)
+ */
+
+
+static int
+lldp_private_iana_print(netdissect_options *ndo,
+ const u_char *tptr, u_int tlv_len)
+{
+ int subtype, hexdump = FALSE;
+
+ if (tlv_len < 8) {
+ return hexdump;
+ }
+ subtype = *(tptr+3);
+
+ ND_PRINT((ndo, "\n\t %s Subtype (%u)",
+ tok2str(lldp_iana_subtype_values, "unknown", subtype),
+ subtype));
+
+ switch (subtype) {
+ case LLDP_IANA_SUBTYPE_MUDURL:
+ ND_PRINT((ndo, "\n\t MUD-URL="));
+ (void)fn_printn(ndo, tptr+4, tlv_len-4, NULL);
+ break;
+ default:
+ hexdump=TRUE;
+ }
+
+ return hexdump;
+}
+
+
+
/*
* Print private TIA extensions.
*/
static int
-lldp_private_tia_print(const u_char *tptr, u_int tlv_len)
+lldp_private_tia_print(netdissect_options *ndo,
+ const u_char *tptr, u_int tlv_len)
{
int subtype, hexdump = FALSE;
- u_int8_t location_format;
- u_int16_t power_val;
+ uint8_t location_format;
+ uint16_t power_val;
u_int lci_len;
- u_int8_t ca_type, ca_len;
+ uint8_t ca_type, ca_len;
if (tlv_len < 4) {
return hexdump;
}
subtype = *(tptr+3);
- printf("\n\t %s Subtype (%u)",
+ ND_PRINT((ndo, "\n\t %s Subtype (%u)",
tok2str(lldp_tia_subtype_values, "unknown", subtype),
- subtype);
+ subtype));
switch (subtype) {
case LLDP_PRIVATE_TIA_SUBTYPE_CAPABILITIES:
if (tlv_len < 7) {
return hexdump;
}
- printf("\n\t Media capabilities [%s] (0x%04x)",
+ ND_PRINT((ndo, "\n\t Media capabilities [%s] (0x%04x)",
bittok2str(lldp_tia_capabilities_values, "none",
- EXTRACT_16BITS(tptr+4)), EXTRACT_16BITS(tptr+4));
- printf("\n\t Device type [%s] (0x%02x)",
+ EXTRACT_16BITS(tptr + 4)), EXTRACT_16BITS(tptr + 4)));
+ ND_PRINT((ndo, "\n\t Device type [%s] (0x%02x)",
tok2str(lldp_tia_device_type_values, "unknown", *(tptr+6)),
- *(tptr+6));
+ *(tptr + 6)));
break;
case LLDP_PRIVATE_TIA_SUBTYPE_NETWORK_POLICY:
if (tlv_len < 8) {
return hexdump;
}
- printf("\n\t Application type [%s] (0x%02x)",
+ ND_PRINT((ndo, "\n\t Application type [%s] (0x%02x)",
tok2str(lldp_tia_application_type_values, "none", *(tptr+4)),
- *(tptr+4));
- printf(", Flags [%s]", bittok2str(
- lldp_tia_network_policy_bits_values, "none", *(tptr+5)));
- printf("\n\t Vlan id %u",
- LLDP_EXTRACT_NETWORK_POLICY_VLAN(EXTRACT_16BITS(tptr+5)));
- printf(", L2 priority %u",
- LLDP_EXTRACT_NETWORK_POLICY_L2_PRIORITY(EXTRACT_16BITS(tptr+6)));
- printf(", DSCP value %u",
- LLDP_EXTRACT_NETWORK_POLICY_DSCP(EXTRACT_16BITS(tptr+6)));
+ *(tptr + 4)));
+ ND_PRINT((ndo, ", Flags [%s]", bittok2str(
+ lldp_tia_network_policy_bits_values, "none", *(tptr + 5))));
+ ND_PRINT((ndo, "\n\t Vlan id %u",
+ LLDP_EXTRACT_NETWORK_POLICY_VLAN(EXTRACT_16BITS(tptr + 5))));
+ ND_PRINT((ndo, ", L2 priority %u",
+ LLDP_EXTRACT_NETWORK_POLICY_L2_PRIORITY(EXTRACT_16BITS(tptr + 6))));
+ ND_PRINT((ndo, ", DSCP value %u",
+ LLDP_EXTRACT_NETWORK_POLICY_DSCP(EXTRACT_16BITS(tptr + 6))));
break;
case LLDP_PRIVATE_TIA_SUBTYPE_LOCAL_ID:
@@ -780,28 +1018,28 @@ lldp_private_tia_print(const u_char *tptr, u_int tlv_len)
return hexdump;
}
location_format = *(tptr+4);
- printf("\n\t Location data format %s (0x%02x)",
+ ND_PRINT((ndo, "\n\t Location data format %s (0x%02x)",
tok2str(lldp_tia_location_data_format_values, "unknown", location_format),
- location_format);
+ location_format));
switch (location_format) {
case LLDP_TIA_LOCATION_DATA_FORMAT_COORDINATE_BASED:
if (tlv_len < 21) {
return hexdump;
}
- printf("\n\t Latitude resolution %u, latitude value %" PRIu64,
- (*(tptr+5)>>2), lldp_extract_latlon(tptr+5));
- printf("\n\t Longitude resolution %u, longitude value %" PRIu64,
- (*(tptr+10)>>2), lldp_extract_latlon(tptr+10));
- printf("\n\t Altitude type %s (%u)",
+ ND_PRINT((ndo, "\n\t Latitude resolution %u, latitude value %" PRIu64,
+ (*(tptr + 5) >> 2), lldp_extract_latlon(tptr + 5)));
+ ND_PRINT((ndo, "\n\t Longitude resolution %u, longitude value %" PRIu64,
+ (*(tptr + 10) >> 2), lldp_extract_latlon(tptr + 10)));
+ ND_PRINT((ndo, "\n\t Altitude type %s (%u)",
tok2str(lldp_tia_location_altitude_type_values, "unknown",(*(tptr+15)>>4)),
- (*(tptr+15)>>4));
- printf("\n\t Altitude resolution %u, altitude value 0x%x",
+ (*(tptr + 15) >> 4)));
+ ND_PRINT((ndo, "\n\t Altitude resolution %u, altitude value 0x%x",
(EXTRACT_16BITS(tptr+15)>>6)&0x3f,
- ((EXTRACT_32BITS(tptr+16)&0x3fffffff)));
- printf("\n\t Datum %s (0x%02x)",
+ ((EXTRACT_32BITS(tptr + 16) & 0x3fffffff))));
+ ND_PRINT((ndo, "\n\t Datum %s (0x%02x)",
tok2str(lldp_tia_location_datum_type_values, "unknown", *(tptr+20)),
- *(tptr+20));
+ *(tptr + 20)));
break;
case LLDP_TIA_LOCATION_DATA_FORMAT_CIVIC_ADDRESS:
@@ -815,18 +1053,18 @@ lldp_private_tia_print(const u_char *tptr, u_int tlv_len)
if (tlv_len < 7+lci_len) {
return hexdump;
}
- printf("\n\t LCI length %u, LCI what %s (0x%02x), Country-code ",
+ ND_PRINT((ndo, "\n\t LCI length %u, LCI what %s (0x%02x), Country-code ",
lci_len,
tok2str(lldp_tia_location_lci_what_values, "unknown", *(tptr+6)),
- *(tptr+6));
+ *(tptr + 6)));
/* Country code */
- safeputs((const char *)(tptr+7), 2);
+ safeputs(ndo, tptr + 7, 2);
lci_len = lci_len-3;
tptr = tptr + 9;
- /* Decode each civic address element */
+ /* Decode each civic address element */
while (lci_len > 0) {
if (lci_len < 2) {
return hexdump;
@@ -835,11 +1073,11 @@ lldp_private_tia_print(const u_char *tptr, u_int tlv_len)
ca_len = *(tptr+1);
tptr += 2;
- lci_len -= 2;
+ lci_len -= 2;
- printf("\n\t CA type \'%s\' (%u), length %u: ",
+ ND_PRINT((ndo, "\n\t CA type \'%s\' (%u), length %u: ",
tok2str(lldp_tia_location_lci_catype_values, "unknown", ca_type),
- ca_type, ca_len);
+ ca_type, ca_len));
/* basic sanity check */
if ( ca_type == 0 || ca_len == 0) {
@@ -849,20 +1087,20 @@ lldp_private_tia_print(const u_char *tptr, u_int tlv_len)
return hexdump;
}
- safeputs((const char *)tptr, ca_len);
+ safeputs(ndo, tptr, ca_len);
tptr += ca_len;
lci_len -= ca_len;
}
break;
case LLDP_TIA_LOCATION_DATA_FORMAT_ECS_ELIN:
- printf("\n\t ECS ELIN id ");
- safeputs((const char *)tptr+5, tlv_len-5);
+ ND_PRINT((ndo, "\n\t ECS ELIN id "));
+ safeputs(ndo, tptr + 5, tlv_len - 5);
break;
default:
- printf("\n\t Location ID ");
- print_unknown_data(tptr+5, "\n\t ", tlv_len-5);
+ ND_PRINT((ndo, "\n\t Location ID "));
+ print_unknown_data(ndo, tptr + 5, "\n\t ", tlv_len - 5);
}
break;
@@ -870,18 +1108,18 @@ lldp_private_tia_print(const u_char *tptr, u_int tlv_len)
if (tlv_len < 7) {
return hexdump;
}
- printf("\n\t Power type [%s]",
- (*(tptr+4)&0xC0>>6) ? "PD device" : "PSE device");
- printf(", Power source [%s]",
- tok2str(lldp_tia_power_source_values, "none", (*(tptr+4)&0x30)>>4));
- printf("\n\t Power priority [%s] (0x%02x)",
+ ND_PRINT((ndo, "\n\t Power type [%s]",
+ (*(tptr + 4) & 0xC0 >> 6) ? "PD device" : "PSE device"));
+ ND_PRINT((ndo, ", Power source [%s]",
+ tok2str(lldp_tia_power_source_values, "none", (*(tptr + 4) & 0x30) >> 4)));
+ ND_PRINT((ndo, "\n\t Power priority [%s] (0x%02x)",
tok2str(lldp_tia_power_priority_values, "none", *(tptr+4)&0x0f),
- *(tptr+4)&0x0f);
+ *(tptr + 4) & 0x0f));
power_val = EXTRACT_16BITS(tptr+5);
if (power_val < LLDP_TIA_POWER_VAL_MAX) {
- printf(", Power %.1f Watts", ((float)power_val)/10);
+ ND_PRINT((ndo, ", Power %.1f Watts", ((float)power_val) / 10));
} else {
- printf(", Power %u (Reserved)", power_val);
+ ND_PRINT((ndo, ", Power %u (Reserved)", power_val));
}
break;
@@ -892,9 +1130,9 @@ lldp_private_tia_print(const u_char *tptr, u_int tlv_len)
case LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_MANUFACTURER_NAME:
case LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_MODEL_NAME:
case LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_ASSET_ID:
- printf("\n\t %s ",
- tok2str(lldp_tia_inventory_values, "unknown", subtype));
- safeputs((const char *)tptr+4, tlv_len-4);
+ ND_PRINT((ndo, "\n\t %s ",
+ tok2str(lldp_tia_inventory_values, "unknown", subtype)));
+ safeputs(ndo, tptr + 4, tlv_len - 4);
break;
default:
@@ -909,12 +1147,13 @@ lldp_private_tia_print(const u_char *tptr, u_int tlv_len)
* Print DCBX Protocol fields (V 1.01).
*/
static int
-lldp_private_dcbx_print(const u_char *pptr, u_int len)
+lldp_private_dcbx_print(netdissect_options *ndo,
+ const u_char *pptr, u_int len)
{
int subtype, hexdump = FALSE;
- u_int8_t tval;
- u_int16_t tlv;
- u_int32_t i, pgval, uval;
+ uint8_t tval;
+ uint16_t tlv;
+ uint32_t i, pgval, uval;
u_int tlen, tlv_type, tlv_len;
const u_char *tptr, *mptr;
@@ -923,9 +1162,9 @@ lldp_private_dcbx_print(const u_char *pptr, u_int len)
}
subtype = *(pptr+3);
- printf("\n\t %s Subtype (%u)",
+ ND_PRINT((ndo, "\n\t %s Subtype (%u)",
tok2str(lldp_dcbx_subtype_values, "unknown", subtype),
- subtype);
+ subtype));
/* by passing old version */
if (subtype == LLDP_DCBX_SUBTYPE_1)
@@ -936,7 +1175,7 @@ lldp_private_dcbx_print(const u_char *pptr, u_int len)
while (tlen >= sizeof(tlv)) {
- TCHECK2(*tptr, sizeof(tlv));
+ ND_TCHECK2(*tptr, sizeof(tlv));
tlv = EXTRACT_16BITS(tptr);
@@ -952,7 +1191,7 @@ lldp_private_dcbx_print(const u_char *pptr, u_int len)
break;
}
- TCHECK2(*tptr, tlv_len);
+ ND_TCHECK2(*tptr, tlv_len);
if (tlen < tlv_len) {
goto trunc;
}
@@ -963,89 +1202,92 @@ lldp_private_dcbx_print(const u_char *pptr, u_int len)
if (tlv_len < 10) {
goto trunc;
}
- printf("\n\t Control - Protocol Control (type 0x%x, length %d)",
- LLDP_DCBX_CONTROL_TLV, tlv_len);
- printf("\n\t Oper_Version: %d", *tptr);
- printf("\n\t Max_Version: %d", *(tptr+1));
- printf("\n\t Sequence Number: %d", EXTRACT_32BITS(tptr+2));
- printf("\n\t Acknowledgement Number: %d",
- EXTRACT_32BITS(tptr+6));
+ ND_PRINT((ndo, "\n\t Control - Protocol Control (type 0x%x, length %d)",
+ LLDP_DCBX_CONTROL_TLV, tlv_len));
+ ND_PRINT((ndo, "\n\t Oper_Version: %d", *tptr));
+ ND_PRINT((ndo, "\n\t Max_Version: %d", *(tptr + 1)));
+ ND_PRINT((ndo, "\n\t Sequence Number: %d", EXTRACT_32BITS(tptr + 2)));
+ ND_PRINT((ndo, "\n\t Acknowledgement Number: %d",
+ EXTRACT_32BITS(tptr + 6)));
break;
case LLDP_DCBX_PRIORITY_GROUPS_TLV:
if (tlv_len < 17) {
goto trunc;
}
- printf("\n\t Feature - Priority Group (type 0x%x, length %d)",
- LLDP_DCBX_PRIORITY_GROUPS_TLV, tlv_len);
- printf("\n\t Oper_Version: %d", *tptr);
- printf("\n\t Max_Version: %d", *(tptr+1));
- printf("\n\t Info block(0x%02X): ", *(tptr+2));
+ ND_PRINT((ndo, "\n\t Feature - Priority Group (type 0x%x, length %d)",
+ LLDP_DCBX_PRIORITY_GROUPS_TLV, tlv_len));
+ ND_PRINT((ndo, "\n\t Oper_Version: %d", *tptr));
+ ND_PRINT((ndo, "\n\t Max_Version: %d", *(tptr + 1)));
+ ND_PRINT((ndo, "\n\t Info block(0x%02X): ", *(tptr + 2)));
tval = *(tptr+2);
- printf("Enable bit: %d, Willing bit: %d, Error Bit: %d",
+ ND_PRINT((ndo, "Enable bit: %d, Willing bit: %d, Error Bit: %d",
(tval & 0x80) ? 1 : 0, (tval & 0x40) ? 1 : 0,
- (tval & 0x20) ? 1 : 0);
- printf("\n\t SubType: %d", *(tptr+3));
- printf("\n\t Priority Allocation");
-
+ (tval & 0x20) ? 1 : 0));
+ ND_PRINT((ndo, "\n\t SubType: %d", *(tptr + 3)));
+ ND_PRINT((ndo, "\n\t Priority Allocation"));
+
+ /*
+ * Array of 8 4-bit priority group ID values; we fetch all
+ * 32 bits and extract each nibble.
+ */
pgval = EXTRACT_32BITS(tptr+4);
for (i = 0; i <= 7; i++) {
- tval = *(tptr+4+(i/2));
- printf("\n\t PgId_%d: %d",
- i, (pgval >> (28-4*i)) & 0xF);
+ ND_PRINT((ndo, "\n\t PgId_%d: %d",
+ i, (pgval >> (28 - 4 * i)) & 0xF));
}
- printf("\n\t Priority Group Allocation");
+ ND_PRINT((ndo, "\n\t Priority Group Allocation"));
for (i = 0; i <= 7; i++)
- printf("\n\t Pg percentage[%d]: %d", i, *(tptr+8+i));
- printf("\n\t NumTCsSupported: %d", *(tptr+8+8));
+ ND_PRINT((ndo, "\n\t Pg percentage[%d]: %d", i, *(tptr + 8 + i)));
+ ND_PRINT((ndo, "\n\t NumTCsSupported: %d", *(tptr + 8 + 8)));
break;
case LLDP_DCBX_PRIORITY_FLOW_CONTROL_TLV:
if (tlv_len < 6) {
goto trunc;
}
- printf("\n\t Feature - Priority Flow Control");
- printf(" (type 0x%x, length %d)",
- LLDP_DCBX_PRIORITY_FLOW_CONTROL_TLV, tlv_len);
- printf("\n\t Oper_Version: %d", *tptr);
- printf("\n\t Max_Version: %d", *(tptr+1));
- printf("\n\t Info block(0x%02X): ", *(tptr+2));
+ ND_PRINT((ndo, "\n\t Feature - Priority Flow Control"));
+ ND_PRINT((ndo, " (type 0x%x, length %d)",
+ LLDP_DCBX_PRIORITY_FLOW_CONTROL_TLV, tlv_len));
+ ND_PRINT((ndo, "\n\t Oper_Version: %d", *tptr));
+ ND_PRINT((ndo, "\n\t Max_Version: %d", *(tptr + 1)));
+ ND_PRINT((ndo, "\n\t Info block(0x%02X): ", *(tptr + 2)));
tval = *(tptr+2);
- printf("Enable bit: %d, Willing bit: %d, Error Bit: %d",
+ ND_PRINT((ndo, "Enable bit: %d, Willing bit: %d, Error Bit: %d",
(tval & 0x80) ? 1 : 0, (tval & 0x40) ? 1 : 0,
- (tval & 0x20) ? 1 : 0);
- printf("\n\t SubType: %d", *(tptr+3));
+ (tval & 0x20) ? 1 : 0));
+ ND_PRINT((ndo, "\n\t SubType: %d", *(tptr + 3)));
tval = *(tptr+4);
- printf("\n\t PFC Config (0x%02X)", *(tptr+4));
+ ND_PRINT((ndo, "\n\t PFC Config (0x%02X)", *(tptr + 4)));
for (i = 0; i <= 7; i++)
- printf("\n\t Priority Bit %d: %s",
- i, (tval & (1 << i)) ? "Enabled" : "Disabled");
- printf("\n\t NumTCPFCSupported: %d", *(tptr+5));
+ ND_PRINT((ndo, "\n\t Priority Bit %d: %s",
+ i, (tval & (1 << i)) ? "Enabled" : "Disabled"));
+ ND_PRINT((ndo, "\n\t NumTCPFCSupported: %d", *(tptr + 5)));
break;
case LLDP_DCBX_APPLICATION_TLV:
if (tlv_len < 4) {
goto trunc;
}
- printf("\n\t Feature - Application (type 0x%x, length %d)",
- LLDP_DCBX_APPLICATION_TLV, tlv_len);
- printf("\n\t Oper_Version: %d", *tptr);
- printf("\n\t Max_Version: %d", *(tptr+1));
- printf("\n\t Info block(0x%02X): ", *(tptr+2));
+ ND_PRINT((ndo, "\n\t Feature - Application (type 0x%x, length %d)",
+ LLDP_DCBX_APPLICATION_TLV, tlv_len));
+ ND_PRINT((ndo, "\n\t Oper_Version: %d", *tptr));
+ ND_PRINT((ndo, "\n\t Max_Version: %d", *(tptr + 1)));
+ ND_PRINT((ndo, "\n\t Info block(0x%02X): ", *(tptr + 2)));
tval = *(tptr+2);
- printf("Enable bit: %d, Willing bit: %d, Error Bit: %d",
+ ND_PRINT((ndo, "Enable bit: %d, Willing bit: %d, Error Bit: %d",
(tval & 0x80) ? 1 : 0, (tval & 0x40) ? 1 : 0,
- (tval & 0x20) ? 1 : 0);
- printf("\n\t SubType: %d", *(tptr+3));
+ (tval & 0x20) ? 1 : 0));
+ ND_PRINT((ndo, "\n\t SubType: %d", *(tptr + 3)));
tval = tlv_len - 4;
mptr = tptr + 4;
while (tval >= 6) {
- printf("\n\t Application Value");
- printf("\n\t Application Protocol ID: 0x%04x",
- EXTRACT_16BITS(mptr));
+ ND_PRINT((ndo, "\n\t Application Value"));
+ ND_PRINT((ndo, "\n\t Application Protocol ID: 0x%04x",
+ EXTRACT_16BITS(mptr)));
uval = EXTRACT_24BITS(mptr+2);
- printf("\n\t SF (0x%x) Application Protocol ID is %s",
+ ND_PRINT((ndo, "\n\t SF (0x%x) Application Protocol ID is %s",
(uval >> 22),
- (uval >> 22) ? "Socket Number" : "L2 EtherType");
- printf("\n\t OUI: 0x%06x", uval & 0x3fffff);
- printf("\n\t User Priority Map: 0x%02x", *(mptr+5));
+ (uval >> 22) ? "Socket Number" : "L2 EtherType"));
+ ND_PRINT((ndo, "\n\t OUI: 0x%06x", uval & 0x3fffff));
+ ND_PRINT((ndo, "\n\t User Priority Map: 0x%02x", *(mptr + 5)));
tval = tval - 6;
mptr = mptr + 6;
}
@@ -1056,8 +1298,8 @@ lldp_private_dcbx_print(const u_char *pptr, u_int len)
}
/* do we also want to see a hex dump ? */
- if (vflag > 1 || (vflag && hexdump)) {
- print_unknown_data(tptr,"\n\t ", tlv_len);
+ if (ndo->ndo_vflag > 1 || (ndo->ndo_vflag && hexdump)) {
+ print_unknown_data(ndo, tptr, "\n\t ", tlv_len);
}
tlen -= tlv_len;
@@ -1069,11 +1311,11 @@ lldp_private_dcbx_print(const u_char *pptr, u_int len)
}
static char *
-lldp_network_addr_print(const u_char *tptr, u_int len) {
-
- u_int8_t af;
+lldp_network_addr_print(netdissect_options *ndo, const u_char *tptr, u_int len)
+{
+ uint8_t af;
static char buf[BUFSIZE];
- const char * (*pfunc)(const u_char *);
+ const char * (*pfunc)(netdissect_options *, const u_char *);
if (len < 1)
return NULL;
@@ -1083,15 +1325,15 @@ lldp_network_addr_print(const u_char *tptr, u_int len) {
case AFNUM_INET:
if (len < 4)
return NULL;
- pfunc = getname;
+ /* This cannot be assigned to ipaddr_string(), which is a macro. */
+ pfunc = getname;
break;
-#ifdef INET6
case AFNUM_INET6:
if (len < 16)
return NULL;
+ /* This cannot be assigned to ip6addr_string(), which is a macro. */
pfunc = getname6;
break;
-#endif
case AFNUM_802:
if (len < 6)
return NULL;
@@ -1107,20 +1349,21 @@ lldp_network_addr_print(const u_char *tptr, u_int len) {
tok2str(af_values, "Unknown", af), af);
} else {
snprintf(buf, sizeof(buf), "AFI %s (%u): %s",
- tok2str(af_values, "Unknown", af), af, (*pfunc)(tptr+1));
+ tok2str(af_values, "Unknown", af), af, (*pfunc)(ndo, tptr+1));
}
return buf;
}
static int
-lldp_mgmt_addr_tlv_print(const u_char *pptr, u_int len) {
-
- u_int8_t mgmt_addr_len, intf_num_subtype, oid_len;
+lldp_mgmt_addr_tlv_print(netdissect_options *ndo,
+ const u_char *pptr, u_int len)
+{
+ uint8_t mgmt_addr_len, intf_num_subtype, oid_len;
const u_char *tptr;
u_int tlen;
char *mgmt_addr;
-
+
tlen = len;
tptr = pptr;
@@ -1134,12 +1377,12 @@ lldp_mgmt_addr_tlv_print(const u_char *pptr, u_int len) {
return 0;
}
- mgmt_addr = lldp_network_addr_print(tptr, mgmt_addr_len);
+ mgmt_addr = lldp_network_addr_print(ndo, tptr, mgmt_addr_len);
if (mgmt_addr == NULL) {
return 0;
}
- printf("\n\t Management Address length %u, %s",
- mgmt_addr_len, mgmt_addr);
+ ND_PRINT((ndo, "\n\t Management Address length %u, %s",
+ mgmt_addr_len, mgmt_addr));
tptr += mgmt_addr_len;
tlen -= mgmt_addr_len;
@@ -1148,10 +1391,10 @@ lldp_mgmt_addr_tlv_print(const u_char *pptr, u_int len) {
}
intf_num_subtype = *tptr;
- printf("\n\t %s Interface Numbering (%u): %u",
+ ND_PRINT((ndo, "\n\t %s Interface Numbering (%u): %u",
tok2str(lldp_intf_numb_subtype_values, "Unknown", intf_num_subtype),
intf_num_subtype,
- EXTRACT_32BITS(tptr+1));
+ EXTRACT_32BITS(tptr + 1)));
tptr += LLDP_INTF_NUM_LEN;
tlen -= LLDP_INTF_NUM_LEN;
@@ -1166,31 +1409,32 @@ lldp_mgmt_addr_tlv_print(const u_char *pptr, u_int len) {
return 0;
}
if (oid_len) {
- printf("\n\t OID length %u", oid_len);
- safeputs((const char *)tptr+1, oid_len);
+ ND_PRINT((ndo, "\n\t OID length %u", oid_len));
+ safeputs(ndo, tptr + 1, oid_len);
}
}
return 1;
-}
+}
void
-lldp_print(register const u_char *pptr, register u_int len) {
-
- u_int8_t subtype;
- u_int16_t tlv, cap, ena_cap;
+lldp_print(netdissect_options *ndo,
+ register const u_char *pptr, register u_int len)
+{
+ uint8_t subtype;
+ uint16_t tlv, cap, ena_cap;
u_int oui, tlen, hexdump, tlv_type, tlv_len;
const u_char *tptr;
char *network_addr;
-
+
tptr = pptr;
tlen = len;
- printf("LLDP, length %u", len);
+ ND_PRINT((ndo, "LLDP, length %u", len));
while (tlen >= sizeof(tlv)) {
- TCHECK2(*tptr, sizeof(tlv));
+ ND_TCHECK2(*tptr, sizeof(tlv));
tlv = EXTRACT_16BITS(tptr);
@@ -1201,10 +1445,10 @@ lldp_print(register const u_char *pptr, register u_int len) {
tlen -= sizeof(tlv);
tptr += sizeof(tlv);
- if (vflag) {
- printf("\n\t%s TLV (%u), length %u",
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo, "\n\t%s TLV (%u), length %u",
tok2str(lldp_tlv_values, "Unknown", tlv_type),
- tlv_type, tlv_len);
+ tlv_type, tlv_len));
}
/* infinite loop check */
@@ -1212,7 +1456,7 @@ lldp_print(register const u_char *pptr, register u_int len) {
break;
}
- TCHECK2(*tptr, tlv_len);
+ ND_TCHECK2(*tptr, tlv_len);
if (tlen < tlv_len) {
goto trunc;
}
@@ -1220,21 +1464,21 @@ lldp_print(register const u_char *pptr, register u_int len) {
switch (tlv_type) {
case LLDP_CHASSIS_ID_TLV:
- if (vflag) {
+ if (ndo->ndo_vflag) {
if (tlv_len < 2) {
goto trunc;
}
subtype = *tptr;
- printf("\n\t Subtype %s (%u): ",
+ ND_PRINT((ndo, "\n\t Subtype %s (%u): ",
tok2str(lldp_chassis_subtype_values, "Unknown", subtype),
- subtype);
+ subtype));
switch (subtype) {
case LLDP_CHASSIS_MAC_ADDR_SUBTYPE:
if (tlv_len < 1+6) {
goto trunc;
}
- printf("%s", etheraddr_string(tptr+1));
+ ND_PRINT((ndo, "%s", etheraddr_string(ndo, tptr + 1)));
break;
case LLDP_CHASSIS_INTF_NAME_SUBTYPE: /* fall through */
@@ -1242,15 +1486,15 @@ lldp_print(register const u_char *pptr, register u_int len) {
case LLDP_CHASSIS_CHASSIS_COMP_SUBTYPE:
case LLDP_CHASSIS_INTF_ALIAS_SUBTYPE:
case LLDP_CHASSIS_PORT_COMP_SUBTYPE:
- safeputs((const char *)tptr+1, tlv_len-1);
+ safeputs(ndo, tptr + 1, tlv_len - 1);
break;
case LLDP_CHASSIS_NETWORK_ADDR_SUBTYPE:
- network_addr = lldp_network_addr_print(tptr+1, tlv_len-1);
+ network_addr = lldp_network_addr_print(ndo, tptr+1, tlv_len-1);
if (network_addr == NULL) {
goto trunc;
}
- printf("%s", network_addr);
+ ND_PRINT((ndo, "%s", network_addr));
break;
default:
@@ -1261,21 +1505,21 @@ lldp_print(register const u_char *pptr, register u_int len) {
break;
case LLDP_PORT_ID_TLV:
- if (vflag) {
+ if (ndo->ndo_vflag) {
if (tlv_len < 2) {
goto trunc;
}
subtype = *tptr;
- printf("\n\t Subtype %s (%u): ",
+ ND_PRINT((ndo, "\n\t Subtype %s (%u): ",
tok2str(lldp_port_subtype_values, "Unknown", subtype),
- subtype);
+ subtype));
switch (subtype) {
case LLDP_PORT_MAC_ADDR_SUBTYPE:
if (tlv_len < 1+6) {
goto trunc;
}
- printf("%s", etheraddr_string(tptr+1));
+ ND_PRINT((ndo, "%s", etheraddr_string(ndo, tptr + 1)));
break;
case LLDP_PORT_INTF_NAME_SUBTYPE: /* fall through */
@@ -1283,15 +1527,15 @@ lldp_print(register const u_char *pptr, register u_int len) {
case LLDP_PORT_AGENT_CIRC_ID_SUBTYPE:
case LLDP_PORT_INTF_ALIAS_SUBTYPE:
case LLDP_PORT_PORT_COMP_SUBTYPE:
- safeputs((const char *)tptr+1, tlv_len-1);
+ safeputs(ndo, tptr + 1, tlv_len - 1);
break;
case LLDP_PORT_NETWORK_ADDR_SUBTYPE:
- network_addr = lldp_network_addr_print(tptr+1, tlv_len-1);
+ network_addr = lldp_network_addr_print(ndo, tptr+1, tlv_len-1);
if (network_addr == NULL) {
goto trunc;
}
- printf("%s", network_addr);
+ ND_PRINT((ndo, "%s", network_addr));
break;
default:
@@ -1302,18 +1546,18 @@ lldp_print(register const u_char *pptr, register u_int len) {
break;
case LLDP_TTL_TLV:
- if (vflag) {
+ if (ndo->ndo_vflag) {
if (tlv_len < 2) {
goto trunc;
}
- printf(": TTL %us", EXTRACT_16BITS(tptr));
+ ND_PRINT((ndo, ": TTL %us", EXTRACT_16BITS(tptr)));
}
break;
case LLDP_PORT_DESCR_TLV:
- if (vflag) {
- printf(": ");
- safeputs((const char *)tptr, tlv_len);
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo, ": "));
+ safeputs(ndo, tptr, tlv_len);
}
break;
@@ -1322,19 +1566,19 @@ lldp_print(register const u_char *pptr, register u_int len) {
* The system name is also print in non-verbose mode
* similar to the CDP printer.
*/
- printf(": ");
- safeputs((const char *)tptr, tlv_len);
+ ND_PRINT((ndo, ": "));
+ safeputs(ndo, tptr, tlv_len);
break;
case LLDP_SYSTEM_DESCR_TLV:
- if (vflag) {
- printf("\n\t ");
- safeputs((const char *)tptr, tlv_len);
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo, "\n\t "));
+ safeputs(ndo, tptr, tlv_len);
}
break;
case LLDP_SYSTEM_CAP_TLV:
- if (vflag) {
+ if (ndo->ndo_vflag) {
/*
* XXX - IEEE Std 802.1AB-2009 says the first octet
* if a chassis ID subtype, with the system
@@ -1346,41 +1590,44 @@ lldp_print(register const u_char *pptr, register u_int len) {
}
cap = EXTRACT_16BITS(tptr);
ena_cap = EXTRACT_16BITS(tptr+2);
- printf("\n\t System Capabilities [%s] (0x%04x)",
- bittok2str(lldp_cap_values, "none", cap), cap);
- printf("\n\t Enabled Capabilities [%s] (0x%04x)",
- bittok2str(lldp_cap_values, "none", ena_cap), ena_cap);
+ ND_PRINT((ndo, "\n\t System Capabilities [%s] (0x%04x)",
+ bittok2str(lldp_cap_values, "none", cap), cap));
+ ND_PRINT((ndo, "\n\t Enabled Capabilities [%s] (0x%04x)",
+ bittok2str(lldp_cap_values, "none", ena_cap), ena_cap));
}
break;
case LLDP_MGMT_ADDR_TLV:
- if (vflag) {
- if (!lldp_mgmt_addr_tlv_print(tptr, tlv_len)) {
+ if (ndo->ndo_vflag) {
+ if (!lldp_mgmt_addr_tlv_print(ndo, tptr, tlv_len)) {
goto trunc;
}
}
break;
case LLDP_PRIVATE_TLV:
- if (vflag) {
+ if (ndo->ndo_vflag) {
if (tlv_len < 3) {
goto trunc;
}
oui = EXTRACT_24BITS(tptr);
- printf(": OUI %s (0x%06x)", tok2str(oui_values, "Unknown", oui), oui);
-
+ ND_PRINT((ndo, ": OUI %s (0x%06x)", tok2str(oui_values, "Unknown", oui), oui));
+
switch (oui) {
case OUI_IEEE_8021_PRIVATE:
- hexdump = lldp_private_8021_print(tptr, tlv_len);
+ hexdump = lldp_private_8021_print(ndo, tptr, tlv_len);
break;
case OUI_IEEE_8023_PRIVATE:
- hexdump = lldp_private_8023_print(tptr, tlv_len);
+ hexdump = lldp_private_8023_print(ndo, tptr, tlv_len);
+ break;
+ case OUI_IANA:
+ hexdump = lldp_private_iana_print(ndo, tptr, tlv_len);
break;
case OUI_TIA:
- hexdump = lldp_private_tia_print(tptr, tlv_len);
+ hexdump = lldp_private_tia_print(ndo, tptr, tlv_len);
break;
case OUI_DCBX:
- hexdump = lldp_private_dcbx_print(tptr, tlv_len);
+ hexdump = lldp_private_dcbx_print(ndo, tptr, tlv_len);
break;
default:
hexdump = TRUE;
@@ -1395,8 +1642,8 @@ lldp_print(register const u_char *pptr, register u_int len) {
}
/* do we also want to see a hex dump ? */
- if (vflag > 1 || (vflag && hexdump)) {
- print_unknown_data(tptr,"\n\t ", tlv_len);
+ if (ndo->ndo_vflag > 1 || (ndo->ndo_vflag && hexdump)) {
+ print_unknown_data(ndo, tptr, "\n\t ", tlv_len);
}
tlen -= tlv_len;
@@ -1404,7 +1651,7 @@ lldp_print(register const u_char *pptr, register u_int len) {
}
return;
trunc:
- printf("\n\t[|LLDP]");
+ ND_PRINT((ndo, "\n\t[|LLDP]"));
}
/*
@@ -1413,3 +1660,6 @@ lldp_print(register const u_char *pptr, register u_int len) {
* c-basic-offset: 4
* End:
*/
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-lldp-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-lmp.c b/freebsd/contrib/tcpdump/print-lmp.c
index d6774409..bb7824c4 100644
--- a/freebsd/contrib/tcpdump/print-lmp.c
+++ b/freebsd/contrib/tcpdump/print-lmp.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code
@@ -12,29 +15,22 @@
* LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE.
*
- * Support for the Link Management Protocol as per rfc 4204.
- *
* Original code by Hannes Gredler (hannes@juniper.net)
* Support for LMP service discovery extensions (defined by UNI 1.0) added
* by Manu Pathak (mapathak@cisco.com), May 2005
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-lmp.c,v 1.11 2007-08-02 17:32:49 hannes Exp $";
-#endif
+/* \summary: Link Management Protocol (LMP) printer */
+
+/* specification: RFC 4204 */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
#include "addrtoname.h"
#include "gmpls.h"
@@ -52,15 +48,15 @@ static const char rcsid[] _U_ =
*/
struct lmp_common_header {
- u_int8_t version_res[2];
- u_int8_t flags;
- u_int8_t msg_type;
- u_int8_t length[2];
- u_int8_t reserved[2];
+ uint8_t version_res[2];
+ uint8_t flags;
+ uint8_t msg_type;
+ uint8_t length[2];
+ uint8_t reserved[2];
};
#define LMP_VERSION 1
-#define LMP_EXTRACT_VERSION(x) (((x)&0xf0)>>4)
+#define LMP_EXTRACT_VERSION(x) (((x)&0xf0)>>4)
static const struct tok lmp_header_flag_values[] = {
{ 0x01, "Control Channel Down"},
@@ -207,7 +203,7 @@ static const struct tok lmp_msg_type_values[] = {
{ 0, NULL}
};
-/*
+/*
* LMP object header
*
* 0 1 2 3
@@ -218,20 +214,20 @@ static const struct tok lmp_msg_type_values[] = {
* | |
* // (object contents) //
* | |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
struct lmp_object_header {
- u_int8_t ctype;
- u_int8_t class_num;
- u_int8_t length[2];
+ uint8_t ctype;
+ uint8_t class_num;
+ uint8_t length[2];
};
#define LMP_OBJ_CC_ID 1
#define LMP_OBJ_NODE_ID 2
#define LMP_OBJ_LINK_ID 3
#define LMP_OBJ_INTERFACE_ID 4
-#define LMP_OBJ_MESSAGE_ID 5
+#define LMP_OBJ_MESSAGE_ID 5
#define LMP_OBJ_CONFIG 6
#define LMP_OBJ_HELLO 7
#define LMP_OBJ_VERIFY_BEGIN 8
@@ -281,13 +277,13 @@ static const struct tok lmp_data_link_subobj[] = {
#define LMP_CTYPE_LOC 1
#define LMP_CTYPE_RMT 2
#define LMP_CTYPE_UNMD 3
-
+
#define LMP_CTYPE_IPV4_LOC 1
#define LMP_CTYPE_IPV4_RMT 2
#define LMP_CTYPE_IPV6_LOC 3
#define LMP_CTYPE_IPV6_RMT 4
-#define LMP_CTYPE_UNMD_LOC 5
-#define LMP_CTYPE_UNMD_RMT 6
+#define LMP_CTYPE_UNMD_LOC 5
+#define LMP_CTYPE_UNMD_RMT 6
#define LMP_CTYPE_1 1
#define LMP_CTYPE_2 2
@@ -304,7 +300,7 @@ static const struct tok lmp_data_link_subobj[] = {
#define LMP_CTYPE_SERVICE_CONFIG_TRANSPARENCY_TCM 3
#define LMP_CTYPE_SERVICE_CONFIG_NETWORK_DIVERSITY 4
-/*
+/*
* Different link types allowed in the Client Port Service Attributes
* subobject defined for LMP Service Discovery in the UNI 1.0 spec
*/
@@ -363,8 +359,9 @@ static const struct tok lmp_ctype_values[] = {
};
void
-lmp_print(register const u_char *pptr, register u_int len) {
-
+lmp_print(netdissect_options *ndo,
+ register const u_char *pptr, register u_int len)
+{
const struct lmp_common_header *lmp_com_header;
const struct lmp_object_header *lmp_obj_header;
const u_char *tptr,*obj_tptr;
@@ -374,29 +371,29 @@ lmp_print(register const u_char *pptr, register u_int len) {
int link_type;
union { /* int to float conversion buffer */
- float f;
- u_int32_t i;
+ float f;
+ uint32_t i;
} bw;
tptr=pptr;
lmp_com_header = (const struct lmp_common_header *)pptr;
- TCHECK(*lmp_com_header);
+ ND_TCHECK(*lmp_com_header);
/*
* Sanity checking of the header.
*/
if (LMP_EXTRACT_VERSION(lmp_com_header->version_res[0]) != LMP_VERSION) {
- printf("LMP version %u packet not supported",
- LMP_EXTRACT_VERSION(lmp_com_header->version_res[0]));
+ ND_PRINT((ndo, "LMP version %u packet not supported",
+ LMP_EXTRACT_VERSION(lmp_com_header->version_res[0])));
return;
}
/* in non-verbose mode just lets print the basic Message Type*/
- if (vflag < 1) {
- printf("LMPv%u %s Message, length: %u",
+ if (ndo->ndo_vflag < 1) {
+ ND_PRINT((ndo, "LMPv%u %s Message, length: %u",
LMP_EXTRACT_VERSION(lmp_com_header->version_res[0]),
tok2str(lmp_msg_type_values, "unknown (%u)",lmp_com_header->msg_type),
- len);
+ len));
return;
}
@@ -404,19 +401,18 @@ lmp_print(register const u_char *pptr, register u_int len) {
tlen=EXTRACT_16BITS(lmp_com_header->length);
- printf("\n\tLMPv%u, msg-type: %s, Flags: [%s], length: %u",
+ ND_PRINT((ndo, "\n\tLMPv%u, msg-type: %s, Flags: [%s], length: %u",
LMP_EXTRACT_VERSION(lmp_com_header->version_res[0]),
tok2str(lmp_msg_type_values, "unknown, type: %u",lmp_com_header->msg_type),
bittok2str(lmp_header_flag_values,"none",lmp_com_header->flags),
- tlen);
+ tlen));
tptr+=sizeof(const struct lmp_common_header);
tlen-=sizeof(const struct lmp_common_header);
while(tlen>0) {
/* did we capture enough for fully decoding the object header ? */
- if (!TTEST2(*tptr, sizeof(struct lmp_object_header)))
- goto trunc;
+ ND_TCHECK2(*tptr, sizeof(struct lmp_object_header));
lmp_obj_header = (const struct lmp_object_header *)tptr;
lmp_obj_len=EXTRACT_16BITS(lmp_obj_header->length);
@@ -425,7 +421,7 @@ lmp_print(register const u_char *pptr, register u_int len) {
if(lmp_obj_len % 4 || lmp_obj_len < 4)
return;
- printf("\n\t %s Object (%u), Class-Type: %s (%u) Flags: [%snegotiable], length: %u",
+ ND_PRINT((ndo, "\n\t %s Object (%u), Class-Type: %s (%u) Flags: [%snegotiable], length: %u",
tok2str(lmp_obj_values,
"Unknown",
lmp_obj_header->class_num),
@@ -435,14 +431,13 @@ lmp_print(register const u_char *pptr, register u_int len) {
((lmp_obj_header->class_num)<<8)+lmp_obj_ctype),
lmp_obj_ctype,
(lmp_obj_header->ctype)&0x80 ? "" : "non-",
- lmp_obj_len);
+ lmp_obj_len));
obj_tptr=tptr+sizeof(struct lmp_object_header);
obj_tlen=lmp_obj_len-sizeof(struct lmp_object_header);
/* did we capture enough for fully decoding the object ? */
- if (!TTEST2(*tptr, lmp_obj_len))
- goto trunc;
+ ND_TCHECK2(*tptr, lmp_obj_len);
hexdump=FALSE;
switch(lmp_obj_header->class_num) {
@@ -451,9 +446,9 @@ lmp_print(register const u_char *pptr, register u_int len) {
switch(lmp_obj_ctype) {
case LMP_CTYPE_LOC:
case LMP_CTYPE_RMT:
- printf("\n\t Control Channel ID: %u (0x%08x)",
+ ND_PRINT((ndo, "\n\t Control Channel ID: %u (0x%08x)",
EXTRACT_32BITS(obj_tptr),
- EXTRACT_32BITS(obj_tptr));
+ EXTRACT_32BITS(obj_tptr)));
break;
default:
@@ -466,23 +461,21 @@ lmp_print(register const u_char *pptr, register u_int len) {
switch(lmp_obj_ctype) {
case LMP_CTYPE_IPV4_LOC:
case LMP_CTYPE_IPV4_RMT:
- printf("\n\t IPv4 Link ID: %s (0x%08x)",
- ipaddr_string(obj_tptr),
- EXTRACT_32BITS(obj_tptr));
+ ND_PRINT((ndo, "\n\t IPv4 Link ID: %s (0x%08x)",
+ ipaddr_string(ndo, obj_tptr),
+ EXTRACT_32BITS(obj_tptr)));
break;
-#ifdef INET6
case LMP_CTYPE_IPV6_LOC:
case LMP_CTYPE_IPV6_RMT:
- printf("\n\t IPv6 Link ID: %s (0x%08x)",
- ip6addr_string(obj_tptr),
- EXTRACT_32BITS(obj_tptr));
+ ND_PRINT((ndo, "\n\t IPv6 Link ID: %s (0x%08x)",
+ ip6addr_string(ndo, obj_tptr),
+ EXTRACT_32BITS(obj_tptr)));
break;
-#endif
case LMP_CTYPE_UNMD_LOC:
case LMP_CTYPE_UNMD_RMT:
- printf("\n\t Link ID: %u (0x%08x)",
+ ND_PRINT((ndo, "\n\t Link ID: %u (0x%08x)",
EXTRACT_32BITS(obj_tptr),
- EXTRACT_32BITS(obj_tptr));
+ EXTRACT_32BITS(obj_tptr)));
break;
default:
hexdump=TRUE;
@@ -492,14 +485,14 @@ lmp_print(register const u_char *pptr, register u_int len) {
case LMP_OBJ_MESSAGE_ID:
switch(lmp_obj_ctype) {
case LMP_CTYPE_1:
- printf("\n\t Message ID: %u (0x%08x)",
+ ND_PRINT((ndo, "\n\t Message ID: %u (0x%08x)",
EXTRACT_32BITS(obj_tptr),
- EXTRACT_32BITS(obj_tptr));
+ EXTRACT_32BITS(obj_tptr)));
break;
case LMP_CTYPE_2:
- printf("\n\t Message ID Ack: %u (0x%08x)",
+ ND_PRINT((ndo, "\n\t Message ID Ack: %u (0x%08x)",
EXTRACT_32BITS(obj_tptr),
- EXTRACT_32BITS(obj_tptr));
+ EXTRACT_32BITS(obj_tptr)));
break;
default:
hexdump=TRUE;
@@ -510,9 +503,9 @@ lmp_print(register const u_char *pptr, register u_int len) {
switch(lmp_obj_ctype) {
case LMP_CTYPE_LOC:
case LMP_CTYPE_RMT:
- printf("\n\t Node ID: %s (0x%08x)",
- ipaddr_string(obj_tptr),
- EXTRACT_32BITS(obj_tptr));
+ ND_PRINT((ndo, "\n\t Node ID: %s (0x%08x)",
+ ipaddr_string(ndo, obj_tptr),
+ EXTRACT_32BITS(obj_tptr)));
break;
default:
@@ -523,103 +516,101 @@ lmp_print(register const u_char *pptr, register u_int len) {
case LMP_OBJ_CONFIG:
switch(lmp_obj_ctype) {
case LMP_CTYPE_HELLO_CONFIG:
- printf("\n\t Hello Interval: %u\n\t Hello Dead Interval: %u",
+ ND_PRINT((ndo, "\n\t Hello Interval: %u\n\t Hello Dead Interval: %u",
EXTRACT_16BITS(obj_tptr),
- EXTRACT_16BITS(obj_tptr+2));
+ EXTRACT_16BITS(obj_tptr+2)));
break;
default:
hexdump=TRUE;
}
break;
-
+
case LMP_OBJ_HELLO:
switch(lmp_obj_ctype) {
case LMP_CTYPE_HELLO:
- printf("\n\t Tx Seq: %u, Rx Seq: %u",
+ ND_PRINT((ndo, "\n\t Tx Seq: %u, Rx Seq: %u",
EXTRACT_32BITS(obj_tptr),
- EXTRACT_32BITS(obj_tptr+4));
+ EXTRACT_32BITS(obj_tptr+4)));
break;
default:
hexdump=TRUE;
}
- break;
-
+ break;
+
case LMP_OBJ_TE_LINK:
- printf("\n\t Flags: [%s]",
+ ND_PRINT((ndo, "\n\t Flags: [%s]",
bittok2str(lmp_obj_te_link_flag_values,
"none",
- EXTRACT_16BITS(obj_tptr)>>8));
-
+ EXTRACT_16BITS(obj_tptr)>>8)));
+
switch(lmp_obj_ctype) {
case LMP_CTYPE_IPV4:
- printf("\n\t Local Link-ID: %s (0x%08x) \
- \n\t Remote Link-ID: %s (0x%08x)",
- ipaddr_string(obj_tptr+4),
+ ND_PRINT((ndo, "\n\t Local Link-ID: %s (0x%08x)"
+ "\n\t Remote Link-ID: %s (0x%08x)",
+ ipaddr_string(ndo, obj_tptr+4),
EXTRACT_32BITS(obj_tptr+4),
- ipaddr_string(obj_tptr+8),
- EXTRACT_32BITS(obj_tptr+8));
+ ipaddr_string(ndo, obj_tptr+8),
+ EXTRACT_32BITS(obj_tptr+8)));
break;
-
-#ifdef INET6
+
case LMP_CTYPE_IPV6:
-#endif
case LMP_CTYPE_UNMD:
default:
hexdump=TRUE;
}
break;
-
+
case LMP_OBJ_DATA_LINK:
- printf("\n\t Flags: [%s]",
+ ND_PRINT((ndo, "\n\t Flags: [%s]",
bittok2str(lmp_obj_data_link_flag_values,
"none",
- EXTRACT_16BITS(obj_tptr)>>8));
-
+ EXTRACT_16BITS(obj_tptr)>>8)));
+
switch(lmp_obj_ctype) {
case LMP_CTYPE_IPV4:
case LMP_CTYPE_UNMD:
- printf("\n\t Local Interface ID: %s (0x%08x) \
- \n\t Remote Interface ID: %s (0x%08x)",
- ipaddr_string(obj_tptr+4),
+ ND_PRINT((ndo, "\n\t Local Interface ID: %s (0x%08x)"
+ "\n\t Remote Interface ID: %s (0x%08x)",
+ ipaddr_string(ndo, obj_tptr+4),
EXTRACT_32BITS(obj_tptr+4),
- ipaddr_string(obj_tptr+8),
- EXTRACT_32BITS(obj_tptr+8));
-
- total_subobj_len = lmp_obj_len - 16;
+ ipaddr_string(ndo, obj_tptr+8),
+ EXTRACT_32BITS(obj_tptr+8)));
+
+ total_subobj_len = lmp_obj_len - 16;
offset = 12;
while (total_subobj_len > 0 && hexdump == FALSE ) {
subobj_type = EXTRACT_16BITS(obj_tptr+offset)>>8;
subobj_len = EXTRACT_16BITS(obj_tptr+offset)&0x00FF;
- printf("\n\t Subobject, Type: %s (%u), Length: %u",
+ ND_PRINT((ndo, "\n\t Subobject, Type: %s (%u), Length: %u",
tok2str(lmp_data_link_subobj,
"Unknown",
subobj_type),
subobj_type,
- subobj_len);
+ subobj_len));
switch(subobj_type) {
case INT_SWITCHING_TYPE_SUBOBJ:
- printf("\n\t Switching Type: %s (%u)",
- tok2str(gmpls_switch_cap_values,
- "Unknown",
+ ND_PRINT((ndo, "\n\t Switching Type: %s (%u)",
+ tok2str(gmpls_switch_cap_values,
+ "Unknown",
EXTRACT_16BITS(obj_tptr+offset+2)>>8),
- EXTRACT_16BITS(obj_tptr+offset+2)>>8);
- printf("\n\t Encoding Type: %s (%u)",
- tok2str(gmpls_encoding_values,
- "Unknown",
+ EXTRACT_16BITS(obj_tptr+offset+2)>>8));
+ ND_PRINT((ndo, "\n\t Encoding Type: %s (%u)",
+ tok2str(gmpls_encoding_values,
+ "Unknown",
EXTRACT_16BITS(obj_tptr+offset+2)&0x00FF),
- EXTRACT_16BITS(obj_tptr+offset+2)&0x00FF);
+ EXTRACT_16BITS(obj_tptr+offset+2)&0x00FF));
bw.i = EXTRACT_32BITS(obj_tptr+offset+4);
- printf("\n\t Min Reservable Bandwidth: %.3f Mbps",
- bw.f*8/1000000);
+ ND_PRINT((ndo, "\n\t Min Reservable Bandwidth: %.3f Mbps",
+ bw.f*8/1000000));
bw.i = EXTRACT_32BITS(obj_tptr+offset+8);
- printf("\n\t Max Reservable Bandwidth: %.3f Mbps",
- bw.f*8/1000000);
- break;
+ ND_PRINT((ndo, "\n\t Max Reservable Bandwidth: %.3f Mbps",
+ bw.f*8/1000000));
+ break;
case WAVELENGTH_SUBOBJ:
- printf("\n\t Wavelength: %u",
- EXTRACT_32BITS(obj_tptr+offset+4));
+ ND_PRINT((ndo, "\n\t Wavelength: %u",
+ EXTRACT_32BITS(obj_tptr+offset+4)));
break;
default:
/* Any Unknown Subobject ==> Exit loop */
@@ -629,70 +620,68 @@ lmp_print(register const u_char *pptr, register u_int len) {
total_subobj_len-=subobj_len;
offset+=subobj_len;
}
-
+
break;
-#ifdef INET6
case LMP_CTYPE_IPV6:
-#endif
default:
hexdump=TRUE;
}
- break;
-
+ break;
+
case LMP_OBJ_VERIFY_BEGIN:
switch(lmp_obj_ctype) {
case LMP_CTYPE_1:
- printf("\n\t Flags: %s",
+ ND_PRINT((ndo, "\n\t Flags: %s",
bittok2str(lmp_obj_begin_verify_flag_values,
"none",
- EXTRACT_16BITS(obj_tptr)));
- printf("\n\t Verify Interval: %u",
- EXTRACT_16BITS(obj_tptr+2));
- printf("\n\t Data links: %u",
- EXTRACT_32BITS(obj_tptr+4));
- printf("\n\t Encoding type: %s",
- tok2str(gmpls_encoding_values, "Unknown", *(obj_tptr+8)));
- printf("\n\t Verify Tranport Mechanism: %u (0x%x) %s",
+ EXTRACT_16BITS(obj_tptr))));
+ ND_PRINT((ndo, "\n\t Verify Interval: %u",
+ EXTRACT_16BITS(obj_tptr+2)));
+ ND_PRINT((ndo, "\n\t Data links: %u",
+ EXTRACT_32BITS(obj_tptr+4)));
+ ND_PRINT((ndo, "\n\t Encoding type: %s",
+ tok2str(gmpls_encoding_values, "Unknown", *(obj_tptr+8))));
+ ND_PRINT((ndo, "\n\t Verify Transport Mechanism: %u (0x%x)%s",
EXTRACT_16BITS(obj_tptr+10),
EXTRACT_16BITS(obj_tptr+10),
- EXTRACT_16BITS(obj_tptr+10)&8000 ? "(Payload test messages capable)" : "");
+ EXTRACT_16BITS(obj_tptr+10)&8000 ? " (Payload test messages capable)" : ""));
bw.i = EXTRACT_32BITS(obj_tptr+12);
- printf("\n\t Transmission Rate: %.3f Mbps",bw.f*8/1000000);
- printf("\n\t Wavelength: %u",
- EXTRACT_32BITS(obj_tptr+16));
+ ND_PRINT((ndo, "\n\t Transmission Rate: %.3f Mbps",bw.f*8/1000000));
+ ND_PRINT((ndo, "\n\t Wavelength: %u",
+ EXTRACT_32BITS(obj_tptr+16)));
break;
-
+
default:
hexdump=TRUE;
}
- break;
-
+ break;
+
case LMP_OBJ_VERIFY_BEGIN_ACK:
switch(lmp_obj_ctype) {
case LMP_CTYPE_1:
- printf("\n\t Verify Dead Interval: %u \
- \n\t Verify Transport Response: %u",
+ ND_PRINT((ndo, "\n\t Verify Dead Interval: %u"
+ "\n\t Verify Transport Response: %u",
EXTRACT_16BITS(obj_tptr),
- EXTRACT_16BITS(obj_tptr+2));
+ EXTRACT_16BITS(obj_tptr+2)));
break;
-
+
default:
hexdump=TRUE;
}
- break;
-
+ break;
+
case LMP_OBJ_VERIFY_ID:
switch(lmp_obj_ctype) {
case LMP_CTYPE_1:
- printf("\n\t Verify ID: %u",
- EXTRACT_32BITS(obj_tptr));
+ ND_PRINT((ndo, "\n\t Verify ID: %u",
+ EXTRACT_32BITS(obj_tptr)));
break;
-
+
default:
hexdump=TRUE;
}
- break;
-
+ break;
+
case LMP_OBJ_CHANNEL_STATUS:
switch(lmp_obj_ctype) {
case LMP_CTYPE_IPV4:
@@ -700,180 +689,176 @@ lmp_print(register const u_char *pptr, register u_int len) {
offset = 0;
/* Decode pairs: <Interface_ID (4 bytes), Channel_status (4 bytes)> */
while (offset < (lmp_obj_len-(int)sizeof(struct lmp_object_header)) ) {
- printf("\n\t Interface ID: %s (0x%08x)",
- ipaddr_string(obj_tptr+offset),
- EXTRACT_32BITS(obj_tptr+offset));
-
- printf("\n\t\t Active: %s (%u)", (EXTRACT_32BITS(obj_tptr+offset+4)>>31) ?
+ ND_PRINT((ndo, "\n\t Interface ID: %s (0x%08x)",
+ ipaddr_string(ndo, obj_tptr+offset),
+ EXTRACT_32BITS(obj_tptr+offset)));
+
+ ND_PRINT((ndo, "\n\t\t Active: %s (%u)", (EXTRACT_32BITS(obj_tptr+offset+4)>>31) ?
"Allocated" : "Non-allocated",
- (EXTRACT_32BITS(obj_tptr+offset+4)>>31));
-
- printf("\n\t\t Direction: %s (%u)", (EXTRACT_32BITS(obj_tptr+offset+4)>>30)&0x1 ?
+ (EXTRACT_32BITS(obj_tptr+offset+4)>>31)));
+
+ ND_PRINT((ndo, "\n\t\t Direction: %s (%u)", (EXTRACT_32BITS(obj_tptr+offset+4)>>30)&0x1 ?
"Transmit" : "Receive",
- (EXTRACT_32BITS(obj_tptr+offset+4)>>30)&0x1);
-
- printf("\n\t\t Channel Status: %s (%u)",
+ (EXTRACT_32BITS(obj_tptr+offset+4)>>30)&0x1));
+
+ ND_PRINT((ndo, "\n\t\t Channel Status: %s (%u)",
tok2str(lmp_obj_channel_status_values,
"Unknown",
EXTRACT_32BITS(obj_tptr+offset+4)&0x3FFFFFF),
- EXTRACT_32BITS(obj_tptr+offset+4)&0x3FFFFFF);
+ EXTRACT_32BITS(obj_tptr+offset+4)&0x3FFFFFF));
offset+=8;
}
break;
-#ifdef INET6
case LMP_CTYPE_IPV6:
-#endif
default:
hexdump=TRUE;
}
- break;
-
+ break;
+
case LMP_OBJ_CHANNEL_STATUS_REQ:
switch(lmp_obj_ctype) {
case LMP_CTYPE_IPV4:
case LMP_CTYPE_UNMD:
offset = 0;
while (offset < (lmp_obj_len-(int)sizeof(struct lmp_object_header)) ) {
- printf("\n\t Interface ID: %s (0x%08x)",
- ipaddr_string(obj_tptr+offset),
- EXTRACT_32BITS(obj_tptr+offset));
+ ND_PRINT((ndo, "\n\t Interface ID: %s (0x%08x)",
+ ipaddr_string(ndo, obj_tptr+offset),
+ EXTRACT_32BITS(obj_tptr+offset)));
offset+=4;
}
break;
-#ifdef INET6
case LMP_CTYPE_IPV6:
-#endif
default:
hexdump=TRUE;
}
- break;
-
+ break;
+
case LMP_OBJ_ERROR_CODE:
switch(lmp_obj_ctype) {
case LMP_CTYPE_BEGIN_VERIFY_ERROR:
- printf("\n\t Error Code: %s",
+ ND_PRINT((ndo, "\n\t Error Code: %s",
bittok2str(lmp_obj_begin_verify_error_values,
"none",
- EXTRACT_32BITS(obj_tptr)));
+ EXTRACT_32BITS(obj_tptr))));
break;
-
+
case LMP_CTYPE_LINK_SUMMARY_ERROR:
- printf("\n\t Error Code: %s",
+ ND_PRINT((ndo, "\n\t Error Code: %s",
bittok2str(lmp_obj_link_summary_error_values,
"none",
- EXTRACT_32BITS(obj_tptr)));
+ EXTRACT_32BITS(obj_tptr))));
break;
default:
hexdump=TRUE;
}
- break;
+ break;
case LMP_OBJ_SERVICE_CONFIG:
switch (lmp_obj_ctype) {
case LMP_CTYPE_SERVICE_CONFIG_SP:
-
- printf("\n\t Flags: %s",
+
+ ND_PRINT((ndo, "\n\t Flags: %s",
bittok2str(lmp_obj_service_config_sp_flag_values,
- "none",
- EXTRACT_16BITS(obj_tptr)>>8));
+ "none",
+ EXTRACT_16BITS(obj_tptr)>>8)));
- printf("\n\t UNI Version: %u",
- EXTRACT_16BITS(obj_tptr) & 0x00FF);
+ ND_PRINT((ndo, "\n\t UNI Version: %u",
+ EXTRACT_16BITS(obj_tptr) & 0x00FF));
break;
-
+
case LMP_CTYPE_SERVICE_CONFIG_CPSA:
-
+
link_type = EXTRACT_16BITS(obj_tptr)>>8;
-
- printf("\n\t Link Type: %s (%u)",
+
+ ND_PRINT((ndo, "\n\t Link Type: %s (%u)",
tok2str(lmp_sd_service_config_cpsa_link_type_values,
"Unknown", link_type),
- link_type);
-
+ link_type));
+
if (link_type == LMP_SD_SERVICE_CONFIG_CPSA_LINK_TYPE_SDH) {
- printf("\n\t Signal Type: %s (%u)",
+ ND_PRINT((ndo, "\n\t Signal Type: %s (%u)",
tok2str(lmp_sd_service_config_cpsa_signal_type_sdh_values,
"Unknown",
EXTRACT_16BITS(obj_tptr) & 0x00FF),
- EXTRACT_16BITS(obj_tptr) & 0x00FF);
+ EXTRACT_16BITS(obj_tptr) & 0x00FF));
}
-
+
if (link_type == LMP_SD_SERVICE_CONFIG_CPSA_LINK_TYPE_SONET) {
- printf("\n\t Signal Type: %s (%u)",
+ ND_PRINT((ndo, "\n\t Signal Type: %s (%u)",
tok2str(lmp_sd_service_config_cpsa_signal_type_sonet_values,
"Unknown",
EXTRACT_16BITS(obj_tptr) & 0x00FF),
- EXTRACT_16BITS(obj_tptr) & 0x00FF);
+ EXTRACT_16BITS(obj_tptr) & 0x00FF));
}
-
- printf("\n\t Transparency: %s",
+
+ ND_PRINT((ndo, "\n\t Transparency: %s",
bittok2str(lmp_obj_service_config_cpsa_tp_flag_values,
"none",
- EXTRACT_16BITS(obj_tptr+2)>>8));
-
- printf("\n\t Contiguous Concatenation Types: %s",
+ EXTRACT_16BITS(obj_tptr+2)>>8)));
+
+ ND_PRINT((ndo, "\n\t Contiguous Concatenation Types: %s",
bittok2str(lmp_obj_service_config_cpsa_cct_flag_values,
"none",
- EXTRACT_16BITS(obj_tptr+2)>>8 & 0x00FF));
-
- printf("\n\t Minimum NCC: %u",
- EXTRACT_16BITS(obj_tptr+4));
-
- printf("\n\t Maximum NCC: %u",
- EXTRACT_16BITS(obj_tptr+6));
-
- printf("\n\t Minimum NVC:%u",
- EXTRACT_16BITS(obj_tptr+8));
-
- printf("\n\t Maximum NVC:%u",
- EXTRACT_16BITS(obj_tptr+10));
-
- printf("\n\t Local Interface ID: %s (0x%08x)",
- ipaddr_string(obj_tptr+12),
- EXTRACT_32BITS(obj_tptr+12));
-
+ EXTRACT_16BITS(obj_tptr+2)>>8 & 0x00FF)));
+
+ ND_PRINT((ndo, "\n\t Minimum NCC: %u",
+ EXTRACT_16BITS(obj_tptr+4)));
+
+ ND_PRINT((ndo, "\n\t Maximum NCC: %u",
+ EXTRACT_16BITS(obj_tptr+6)));
+
+ ND_PRINT((ndo, "\n\t Minimum NVC:%u",
+ EXTRACT_16BITS(obj_tptr+8)));
+
+ ND_PRINT((ndo, "\n\t Maximum NVC:%u",
+ EXTRACT_16BITS(obj_tptr+10)));
+
+ ND_PRINT((ndo, "\n\t Local Interface ID: %s (0x%08x)",
+ ipaddr_string(ndo, obj_tptr+12),
+ EXTRACT_32BITS(obj_tptr+12)));
+
break;
-
+
case LMP_CTYPE_SERVICE_CONFIG_TRANSPARENCY_TCM:
-
- printf("\n\t Transparency Flags: %s",
+
+ ND_PRINT((ndo, "\n\t Transparency Flags: %s",
bittok2str(
lmp_obj_service_config_nsa_transparency_flag_values,
"none",
- EXTRACT_32BITS(obj_tptr)));
+ EXTRACT_32BITS(obj_tptr))));
- printf("\n\t TCM Monitoring Flags: %s",
+ ND_PRINT((ndo, "\n\t TCM Monitoring Flags: %s",
bittok2str(
lmp_obj_service_config_nsa_tcm_flag_values,
"none",
- EXTRACT_16BITS(obj_tptr+6) & 0x00FF));
-
+ EXTRACT_16BITS(obj_tptr+6) & 0x00FF)));
+
break;
-
+
case LMP_CTYPE_SERVICE_CONFIG_NETWORK_DIVERSITY:
-
- printf("\n\t Diversity: Flags: %s",
+
+ ND_PRINT((ndo, "\n\t Diversity: Flags: %s",
bittok2str(
lmp_obj_service_config_nsa_network_diversity_flag_values,
"none",
- EXTRACT_16BITS(obj_tptr+2) & 0x00FF));
+ EXTRACT_16BITS(obj_tptr+2) & 0x00FF)));
break;
default:
hexdump = TRUE;
- };
+ }
break;
default:
- if (vflag <= 1)
- print_unknown_data(obj_tptr,"\n\t ",obj_tlen);
+ if (ndo->ndo_vflag <= 1)
+ print_unknown_data(ndo,obj_tptr,"\n\t ",obj_tlen);
break;
}
/* do we want to see an additionally hexdump ? */
- if (vflag > 1 || hexdump==TRUE)
- print_unknown_data(tptr+sizeof(struct lmp_object_header),"\n\t ",
+ if (ndo->ndo_vflag > 1 || hexdump==TRUE)
+ print_unknown_data(ndo,tptr+sizeof(struct lmp_object_header),"\n\t ",
lmp_obj_len-sizeof(struct lmp_object_header));
tptr+=lmp_obj_len;
@@ -881,5 +866,14 @@ lmp_print(register const u_char *pptr, register u_int len) {
}
return;
trunc:
- printf("\n\t\t packet exceeded snapshot");
+ ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
}
+/*
+ * Local Variables:
+ * c-style: whitesmith
+ * c-basic-offset: 8
+ * End:
+ */
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-lmp-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-loopback.c b/freebsd/contrib/tcpdump/print-loopback.c
new file mode 100644
index 00000000..cf07663b
--- /dev/null
+++ b/freebsd/contrib/tcpdump/print-loopback.c
@@ -0,0 +1,144 @@
+#include <machine/rtems-bsd-user-space.h>
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
+/*
+ * Copyright (c) 2014 The TCPDUMP project
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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
+ * COPYRIGHT HOLDER 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: Loopback Protocol printer */
+
+/*
+ * originally defined as the Ethernet Configuration Testing Protocol.
+ * specification: http://www.mit.edu/people/jhawk/ctp.pdf
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <netdissect-stdinc.h>
+
+#include "netdissect.h"
+#include "extract.h"
+#include "ether.h"
+#include "addrtoname.h"
+
+static const char tstr[] = " [|loopback]";
+
+#define LOOPBACK_REPLY 1
+#define LOOPBACK_FWDDATA 2
+
+static const struct tok fcode_str[] = {
+ { LOOPBACK_REPLY, "Reply" },
+ { LOOPBACK_FWDDATA, "Forward Data" },
+ { 0, NULL }
+};
+
+static void
+loopback_message_print(netdissect_options *ndo, const u_char *cp, const u_int len)
+{
+ const u_char *ep = cp + len;
+ uint16_t function;
+
+ if (len < 2)
+ goto invalid;
+ /* function */
+ ND_TCHECK2(*cp, 2);
+ function = EXTRACT_LE_16BITS(cp);
+ cp += 2;
+ ND_PRINT((ndo, ", %s", tok2str(fcode_str, " invalid (%u)", function)));
+
+ switch (function) {
+ case LOOPBACK_REPLY:
+ if (len < 4)
+ goto invalid;
+ /* receipt number */
+ ND_TCHECK2(*cp, 2);
+ ND_PRINT((ndo, ", receipt number %u", EXTRACT_LE_16BITS(cp)));
+ cp += 2;
+ /* data */
+ ND_PRINT((ndo, ", data (%u octets)", len - 4));
+ ND_TCHECK2(*cp, len - 4);
+ break;
+ case LOOPBACK_FWDDATA:
+ if (len < 8)
+ goto invalid;
+ /* forwarding address */
+ ND_TCHECK2(*cp, ETHER_ADDR_LEN);
+ ND_PRINT((ndo, ", forwarding address %s", etheraddr_string(ndo, cp)));
+ cp += ETHER_ADDR_LEN;
+ /* data */
+ ND_PRINT((ndo, ", data (%u octets)", len - 8));
+ ND_TCHECK2(*cp, len - 8);
+ break;
+ default:
+ ND_TCHECK2(*cp, len - 2);
+ break;
+ }
+ return;
+
+invalid:
+ ND_PRINT((ndo, "%s", istr));
+ ND_TCHECK2(*cp, ep - cp);
+ return;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+}
+
+void
+loopback_print(netdissect_options *ndo, const u_char *cp, const u_int len)
+{
+ const u_char *ep = cp + len;
+ uint16_t skipCount;
+
+ ND_PRINT((ndo, "Loopback"));
+ if (len < 2)
+ goto invalid;
+ /* skipCount */
+ ND_TCHECK2(*cp, 2);
+ skipCount = EXTRACT_LE_16BITS(cp);
+ cp += 2;
+ ND_PRINT((ndo, ", skipCount %u", skipCount));
+ if (skipCount % 8)
+ ND_PRINT((ndo, " (bogus)"));
+ if (skipCount > len - 2)
+ goto invalid;
+ loopback_message_print(ndo, cp + skipCount, len - 2 - skipCount);
+ return;
+
+invalid:
+ ND_PRINT((ndo, "%s", istr));
+ ND_TCHECK2(*cp, ep - cp);
+ return;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+}
+
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-loopback-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-lspping.c b/freebsd/contrib/tcpdump/print-lspping.c
index aac0ca25..d1ac62ee 100644
--- a/freebsd/contrib/tcpdump/print-lspping.c
+++ b/freebsd/contrib/tcpdump/print-lspping.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code
@@ -15,29 +18,23 @@
* Original code by Hannes Gredler (hannes@juniper.net)
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-lspping.c,v 1.20 2008-01-28 14:20:43 hannes Exp $";
-#endif
+/* \summary: MPLS LSP PING printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
#include "addrtoname.h"
-#include "bgp.h"
#include "l2vpn.h"
#include "oui.h"
+/* RFC 4349 */
+
/*
* LSPPING common header
*
@@ -67,18 +64,18 @@ static const char rcsid[] _U_ =
*/
struct lspping_common_header {
- u_int8_t version[2];
- u_int8_t reserved[2];
- u_int8_t msg_type;
- u_int8_t reply_mode;
- u_int8_t return_code;
- u_int8_t return_subcode;
- u_int8_t sender_handle[4];
- u_int8_t seq_number[4];
- u_int8_t ts_sent_sec[4];
- u_int8_t ts_sent_usec[4];
- u_int8_t ts_rcvd_sec[4];
- u_int8_t ts_rcvd_usec[4];
+ uint8_t version[2];
+ uint8_t global_flags[2];
+ uint8_t msg_type;
+ uint8_t reply_mode;
+ uint8_t return_code;
+ uint8_t return_subcode;
+ uint8_t sender_handle[4];
+ uint8_t seq_number[4];
+ uint8_t ts_sent_sec[4];
+ uint8_t ts_sent_usec[4];
+ uint8_t ts_rcvd_sec[4];
+ uint8_t ts_rcvd_usec[4];
};
#define LSPPING_VERSION 1
@@ -111,10 +108,11 @@ static const struct tok lspping_return_code_values[] = {
{ 10, "Mapping for this FEC is not the given label at stack depth"},
{ 11, "No label entry at stack-depth"},
{ 12, "Protocol not associated with interface at FEC stack depth"},
+ { 13, "Premature termination of ping due to label stack shrinking to a single label"},
};
-/*
+/*
* LSPPING TLV header
* 0 1 2 3
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
@@ -130,16 +128,19 @@ static const struct tok lspping_return_code_values[] = {
*/
struct lspping_tlv_header {
- u_int8_t type[2];
- u_int8_t length[2];
+ uint8_t type[2];
+ uint8_t length[2];
};
#define LSPPING_TLV_TARGET_FEC_STACK 1
#define LSPPING_TLV_DOWNSTREAM_MAPPING 2
#define LSPPING_TLV_PAD 3
+/* not assigned 4 */
#define LSPPING_TLV_VENDOR_ENTERPRISE 5
#define LSPPING_TLV_VENDOR_ENTERPRISE_LEN 4
+/* not assigned 6 */
#define LSPPING_TLV_INTERFACE_LABEL_STACK 7
+/* not assigned 8 */
#define LSPPING_TLV_ERROR_CODE 9
#define LSPPING_TLV_REPLY_TOS_BYTE 10
#define LSPPING_TLV_BFD_DISCRIMINATOR 15 /* draft-ietf-bfd-mpls-02 */
@@ -159,17 +160,22 @@ static const struct tok lspping_tlv_values[] = {
{ 0, NULL}
};
-#define LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV4 1
-#define LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV6 2
-#define LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV4 3
-#define LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV6 4
-#define LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV4 6
-#define LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV6 7
-#define LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_ENDPT 8
-#define LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID_OLD 9
-#define LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID 10
-#define LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV4 11
-#define LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV6 12
+#define LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV4 1
+#define LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV6 2
+#define LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV4 3
+#define LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV6 4
+/* not assigned 5 */
+#define LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV4 6
+#define LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV6 7
+#define LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_ENDPT 8
+#define LSPPING_TLV_TARGETFEC_SUBTLV_FEC_128_PW_OLD 9
+#define LSPPING_TLV_TARGETFEC_SUBTLV_FEC_128_PW 10
+#define LSPPING_TLV_TARGETFEC_SUBTLV_FEC_129_PW 11
+#define LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV4 12
+#define LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV6 13
+#define LSPPING_TLV_TARGETFEC_SUBTLV_GENERIC_IPV4 14
+#define LSPPING_TLV_TARGETFEC_SUBTLV_GENERIC_IPV6 15
+#define LSPPING_TLV_TARGETFEC_SUBTLV_NIL_FEC 16
static const struct tok lspping_tlvtargetfec_subtlv_values[] = {
{ LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV4, "LDP IPv4 prefix"},
@@ -180,8 +186,8 @@ static const struct tok lspping_tlvtargetfec_subtlv_values[] = {
{ LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV4, "VPN IPv4 prefix"},
{ LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV6, "VPN IPv6 prefix"},
{ LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_ENDPT, "L2 VPN endpoint"},
- { LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID_OLD, "L2 circuit ID (old)"},
- { LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID, "L2 circuit ID"},
+ { LSPPING_TLV_TARGETFEC_SUBTLV_FEC_128_PW_OLD, "FEC 128 pseudowire (old)"},
+ { LSPPING_TLV_TARGETFEC_SUBTLV_FEC_128_PW, "FEC 128 pseudowire"},
{ LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV4, "BGP labeled IPv4 prefix"},
{ LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV6, "BGP labeled IPv6 prefix"},
{ 0, NULL}
@@ -197,8 +203,8 @@ static const struct tok lspping_tlvtargetfec_subtlv_values[] = {
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
struct lspping_tlv_targetfec_subtlv_ldp_ipv4_t {
- u_int8_t prefix [4];
- u_int8_t prefix_len;
+ uint8_t prefix [4];
+ uint8_t prefix_len;
};
/*
@@ -214,46 +220,8 @@ struct lspping_tlv_targetfec_subtlv_ldp_ipv4_t {
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
struct lspping_tlv_targetfec_subtlv_ldp_ipv6_t {
- u_int8_t prefix [16];
- u_int8_t prefix_len;
-};
-
-/*
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Sender identifier |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | IPv4 prefix |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Prefix Length | Must Be Zero |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-struct lspping_tlv_targetfec_subtlv_bgp_ipv4_t {
- u_int8_t sender_id [4];
- u_int8_t prefix [4];
- u_int8_t prefix_len;
-};
-
-/*
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Sender identifier |
- * | (16 octets) |
- * | |
- * | |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | IPv6 prefix |
- * | (16 octets) |
- * | |
- * | |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Prefix Length | Must Be Zero |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-struct lspping_tlv_targetfec_subtlv_bgp_ipv6_t {
- u_int8_t sender_id [16];
- u_int8_t prefix [16];
- u_int8_t prefix_len;
+ uint8_t prefix [16];
+ uint8_t prefix_len;
};
/*
@@ -272,13 +240,13 @@ struct lspping_tlv_targetfec_subtlv_bgp_ipv6_t {
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
struct lspping_tlv_targetfec_subtlv_rsvp_ipv4_t {
- u_int8_t tunnel_endpoint [4];
- u_int8_t res[2];
- u_int8_t tunnel_id[2];
- u_int8_t extended_tunnel_id[4];
- u_int8_t tunnel_sender [4];
- u_int8_t res2[2];
- u_int8_t lsp_id [2];
+ uint8_t tunnel_endpoint [4];
+ uint8_t res[2];
+ uint8_t tunnel_id[2];
+ uint8_t extended_tunnel_id[4];
+ uint8_t tunnel_sender [4];
+ uint8_t res2[2];
+ uint8_t lsp_id [2];
};
/*
@@ -306,13 +274,13 @@ struct lspping_tlv_targetfec_subtlv_rsvp_ipv4_t {
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
struct lspping_tlv_targetfec_subtlv_rsvp_ipv6_t {
- u_int8_t tunnel_endpoint [16];
- u_int8_t res[2];
- u_int8_t tunnel_id[2];
- u_int8_t extended_tunnel_id[16];
- u_int8_t tunnel_sender [16];
- u_int8_t res2[2];
- u_int8_t lsp_id [2];
+ uint8_t tunnel_endpoint [16];
+ uint8_t res[2];
+ uint8_t tunnel_id[2];
+ uint8_t extended_tunnel_id[16];
+ uint8_t tunnel_sender [16];
+ uint8_t res2[2];
+ uint8_t lsp_id [2];
};
/*
@@ -328,9 +296,9 @@ struct lspping_tlv_targetfec_subtlv_rsvp_ipv6_t {
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
struct lspping_tlv_targetfec_subtlv_l3vpn_ipv4_t {
- u_int8_t rd [8];
- u_int8_t prefix [4];
- u_int8_t prefix_len;
+ uint8_t rd [8];
+ uint8_t prefix [4];
+ uint8_t prefix_len;
};
/*
@@ -349,9 +317,9 @@ struct lspping_tlv_targetfec_subtlv_l3vpn_ipv4_t {
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
struct lspping_tlv_targetfec_subtlv_l3vpn_ipv6_t {
- u_int8_t rd [8];
- u_int8_t prefix [16];
- u_int8_t prefix_len;
+ uint8_t rd [8];
+ uint8_t prefix [16];
+ uint8_t prefix_len;
};
/*
@@ -361,17 +329,17 @@ struct lspping_tlv_targetfec_subtlv_l3vpn_ipv6_t {
* | Route Distinguisher |
* | (8 octets) |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Sender's CE ID | Receiver's CE ID |
+ * | Sender's VE ID | Receiver's VE ID |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Encapsulation Type | Must Be Zero |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* 0 1 2 3
*/
struct lspping_tlv_targetfec_subtlv_l2vpn_endpt_t {
- u_int8_t rd [8];
- u_int8_t sender_ce_id [2];
- u_int8_t receiver_ce_id [2];
- u_int8_t encapsulation[2];
+ uint8_t rd [8];
+ uint8_t sender_ve_id [2];
+ uint8_t receiver_ve_id [2];
+ uint8_t encapsulation[2];
};
/*
@@ -379,15 +347,15 @@ struct lspping_tlv_targetfec_subtlv_l2vpn_endpt_t {
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Remote PE Address |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | VC ID |
+ * | PW ID |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Encapsulation Type | Must Be Zero |
+ * | PW Type | Must Be Zero |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
-struct lspping_tlv_targetfec_subtlv_l2vpn_vcid_old_t {
- u_int8_t remote_pe_address [4];
- u_int8_t vc_id [4];
- u_int8_t encapsulation[2];
+struct lspping_tlv_targetfec_subtlv_fec_128_pw_old {
+ uint8_t remote_pe_address [4];
+ uint8_t pw_id [4];
+ uint8_t pw_type[2];
};
/*
@@ -397,16 +365,45 @@ struct lspping_tlv_targetfec_subtlv_l2vpn_vcid_old_t {
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Remote PE Address |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | VC ID |
+ * | PW ID |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Encapsulation Type | Must Be Zero |
+ * | PW Type | Must Be Zero |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+struct lspping_tlv_targetfec_subtlv_fec_128_pw {
+ uint8_t sender_pe_address [4];
+ uint8_t remote_pe_address [4];
+ uint8_t pw_id [4];
+ uint8_t pw_type[2];
+};
+
+/*
+ * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | IPv4 prefix |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Prefix Length | Must Be Zero |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+struct lspping_tlv_targetfec_subtlv_bgp_ipv4_t {
+ uint8_t prefix [4];
+ uint8_t prefix_len;
+};
+
+/*
+ * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | IPv6 prefix |
+ * | (16 octets) |
+ * | |
+ * | |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Prefix Length | Must Be Zero |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
-struct lspping_tlv_targetfec_subtlv_l2vpn_vcid_t {
- u_int8_t sender_pe_address [4];
- u_int8_t remote_pe_address [4];
- u_int8_t vc_id [4];
- u_int8_t encapsulation[2];
+struct lspping_tlv_targetfec_subtlv_bgp_ipv6_t {
+ uint8_t prefix [16];
+ uint8_t prefix_len;
};
/*
@@ -419,7 +416,7 @@ struct lspping_tlv_targetfec_subtlv_l2vpn_vcid_t {
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Downstream Interface Address (4 or 16 octets) |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Hash Key Type | Depth Limit | Multipath Length |
+ * | Multipath Type| Depth Limit | Multipath Length |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* . .
* . (Multipath Information) .
@@ -434,54 +431,83 @@ struct lspping_tlv_targetfec_subtlv_l2vpn_vcid_t {
* | Downstream Label | Protocol |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
+/* Enough to get the address type */
+struct lspping_tlv_downstream_map_t {
+ uint8_t mtu [2];
+ uint8_t address_type;
+ uint8_t ds_flags;
+};
+
struct lspping_tlv_downstream_map_ipv4_t {
- u_int8_t mtu [2];
- u_int8_t address_type;
- u_int8_t res;
- u_int8_t downstream_ip[4];
- u_int8_t downstream_interface[4];
+ uint8_t mtu [2];
+ uint8_t address_type;
+ uint8_t ds_flags;
+ uint8_t downstream_ip[4];
+ uint8_t downstream_interface[4];
+};
+
+struct lspping_tlv_downstream_map_ipv4_unmb_t {
+ uint8_t mtu [2];
+ uint8_t address_type;
+ uint8_t ds_flags;
+ uint8_t downstream_ip[4];
+ uint8_t downstream_interface[4];
};
struct lspping_tlv_downstream_map_ipv6_t {
- u_int8_t mtu [2];
- u_int8_t address_type;
- u_int8_t res;
- u_int8_t downstream_ip[16];
- u_int8_t downstream_interface[16];
+ uint8_t mtu [2];
+ uint8_t address_type;
+ uint8_t ds_flags;
+ uint8_t downstream_ip[16];
+ uint8_t downstream_interface[16];
+};
+
+struct lspping_tlv_downstream_map_ipv6_unmb_t {
+ uint8_t mtu [2];
+ uint8_t address_type;
+ uint8_t ds_flags;
+ uint8_t downstream_ip[16];
+ uint8_t downstream_interface[4];
};
struct lspping_tlv_downstream_map_info_t {
- u_int8_t hash_key_type;
- u_int8_t depth_limit;
- u_int8_t multipath_length [2];
+ uint8_t multipath_type;
+ uint8_t depth_limit;
+ uint8_t multipath_length [2];
};
-#define LSPPING_AFI_IPV4 1
-#define LSPPING_AFI_UNMB 2
-#define LSPPING_AFI_IPV6 3
+#define LSPPING_AFI_IPV4 1
+#define LSPPING_AFI_IPV4_UNMB 2
+#define LSPPING_AFI_IPV6 3
+#define LSPPING_AFI_IPV6_UNMB 4
static const struct tok lspping_tlv_downstream_addr_values[] = {
- { LSPPING_AFI_IPV4, "IPv4"},
- { LSPPING_AFI_IPV6, "IPv6"},
- { LSPPING_AFI_UNMB, "Unnumbered"},
+ { LSPPING_AFI_IPV4, "IPv4"},
+ { LSPPING_AFI_IPV4_UNMB, "Unnumbered IPv4"},
+ { LSPPING_AFI_IPV6, "IPv6"},
+ { LSPPING_AFI_IPV6_UNMB, "IPv6"},
{ 0, NULL}
};
void
-lspping_print(register const u_char *pptr, register u_int len) {
-
+lspping_print(netdissect_options *ndo,
+ register const u_char *pptr, register u_int len)
+{
const struct lspping_common_header *lspping_com_header;
const struct lspping_tlv_header *lspping_tlv_header;
const struct lspping_tlv_header *lspping_subtlv_header;
const u_char *tptr,*tlv_tptr,*subtlv_tptr;
- int tlen,lspping_tlv_len,lspping_tlv_type,tlv_tlen;
+ u_int tlen,lspping_tlv_len,lspping_tlv_type,tlv_tlen;
int tlv_hexdump,subtlv_hexdump;
- int lspping_subtlv_len,lspping_subtlv_type;
- struct timeval timestamp;
+ u_int lspping_subtlv_len,lspping_subtlv_type;
+ struct timeval timestamp;
union {
+ const struct lspping_tlv_downstream_map_t *lspping_tlv_downstream_map;
const struct lspping_tlv_downstream_map_ipv4_t *lspping_tlv_downstream_map_ipv4;
+ const struct lspping_tlv_downstream_map_ipv4_unmb_t *lspping_tlv_downstream_map_ipv4_unmb;
const struct lspping_tlv_downstream_map_ipv6_t *lspping_tlv_downstream_map_ipv6;
+ const struct lspping_tlv_downstream_map_ipv6_unmb_t *lspping_tlv_downstream_map_ipv6_unmb;
const struct lspping_tlv_downstream_map_info_t *lspping_tlv_downstream_map_info;
} tlv_ptr;
@@ -493,32 +519,34 @@ lspping_print(register const u_char *pptr, register u_int len) {
const struct lspping_tlv_targetfec_subtlv_l3vpn_ipv4_t *lspping_tlv_targetfec_subtlv_l3vpn_ipv4;
const struct lspping_tlv_targetfec_subtlv_l3vpn_ipv6_t *lspping_tlv_targetfec_subtlv_l3vpn_ipv6;
const struct lspping_tlv_targetfec_subtlv_l2vpn_endpt_t *lspping_tlv_targetfec_subtlv_l2vpn_endpt;
- const struct lspping_tlv_targetfec_subtlv_l2vpn_vcid_old_t *lspping_tlv_targetfec_subtlv_l2vpn_vcid_old;
- const struct lspping_tlv_targetfec_subtlv_l2vpn_vcid_t *lspping_tlv_targetfec_subtlv_l2vpn_vcid;
+ const struct lspping_tlv_targetfec_subtlv_fec_128_pw_old *lspping_tlv_targetfec_subtlv_l2vpn_vcid_old;
+ const struct lspping_tlv_targetfec_subtlv_fec_128_pw *lspping_tlv_targetfec_subtlv_l2vpn_vcid;
const struct lspping_tlv_targetfec_subtlv_bgp_ipv4_t *lspping_tlv_targetfec_subtlv_bgp_ipv4;
const struct lspping_tlv_targetfec_subtlv_bgp_ipv6_t *lspping_tlv_targetfec_subtlv_bgp_ipv6;
} subtlv_ptr;
tptr=pptr;
lspping_com_header = (const struct lspping_common_header *)pptr;
- TCHECK(*lspping_com_header);
+ if (len < sizeof(const struct lspping_common_header))
+ goto tooshort;
+ ND_TCHECK(*lspping_com_header);
/*
* Sanity checking of the header.
*/
if (EXTRACT_16BITS(&lspping_com_header->version[0]) != LSPPING_VERSION) {
- printf("LSP-PING version %u packet not supported",
- EXTRACT_16BITS(&lspping_com_header->version[0]));
+ ND_PRINT((ndo, "LSP-PING version %u packet not supported",
+ EXTRACT_16BITS(&lspping_com_header->version[0])));
return;
}
/* in non-verbose mode just lets print the basic Message Type*/
- if (vflag < 1) {
- printf("LSP-PINGv%u, %s, seq %u, length: %u",
+ if (ndo->ndo_vflag < 1) {
+ ND_PRINT((ndo, "LSP-PINGv%u, %s, seq %u, length: %u",
EXTRACT_16BITS(&lspping_com_header->version[0]),
tok2str(lspping_msg_type_values, "unknown (%u)",lspping_com_header->msg_type),
EXTRACT_32BITS(lspping_com_header->seq_number),
- len);
+ len));
return;
}
@@ -526,13 +554,13 @@ lspping_print(register const u_char *pptr, register u_int len) {
tlen=len;
- printf("\n\tLSP-PINGv%u, msg-type: %s (%u), length: %u\n\t reply-mode: %s (%u)",
+ ND_PRINT((ndo, "\n\tLSP-PINGv%u, msg-type: %s (%u), length: %u\n\t reply-mode: %s (%u)",
EXTRACT_16BITS(&lspping_com_header->version[0]),
tok2str(lspping_msg_type_values, "unknown",lspping_com_header->msg_type),
lspping_com_header->msg_type,
len,
tok2str(lspping_reply_mode_values, "unknown",lspping_com_header->reply_mode),
- lspping_com_header->reply_mode);
+ lspping_com_header->reply_mode));
/*
* the following return codes require that the subcode is attached
@@ -544,224 +572,290 @@ lspping_print(register const u_char *pptr, register u_int len) {
lspping_com_header->return_code == 10 ||
lspping_com_header->return_code == 11 ||
lspping_com_header->return_code == 12 )
- printf("\n\t Return Code: %s %u (%u)\n\t Return Subcode: (%u)",
+ ND_PRINT((ndo, "\n\t Return Code: %s %u (%u)\n\t Return Subcode: (%u)",
tok2str(lspping_return_code_values, "unknown",lspping_com_header->return_code),
- lspping_com_header->return_subcode,
+ lspping_com_header->return_subcode,
lspping_com_header->return_code,
- lspping_com_header->return_subcode);
+ lspping_com_header->return_subcode));
else
- printf("\n\t Return Code: %s (%u)\n\t Return Subcode: (%u)",
- tok2str(lspping_return_code_values, "unknown",lspping_com_header->return_code),
+ ND_PRINT((ndo, "\n\t Return Code: %s (%u)\n\t Return Subcode: (%u)",
+ tok2str(lspping_return_code_values, "unknown",lspping_com_header->return_code),
lspping_com_header->return_code,
- lspping_com_header->return_subcode);
-
- printf("\n\t Sender Handle: 0x%08x, Sequence: %u",
+ lspping_com_header->return_subcode));
+
+ ND_PRINT((ndo, "\n\t Sender Handle: 0x%08x, Sequence: %u",
EXTRACT_32BITS(lspping_com_header->sender_handle),
- EXTRACT_32BITS(lspping_com_header->seq_number));
+ EXTRACT_32BITS(lspping_com_header->seq_number)));
timestamp.tv_sec=EXTRACT_32BITS(lspping_com_header->ts_sent_sec);
- timestamp.tv_usec=EXTRACT_32BITS(lspping_com_header->ts_sent_usec);
- printf("\n\t Sender Timestamp: ");
- ts_print(&timestamp);
+ timestamp.tv_usec=EXTRACT_32BITS(lspping_com_header->ts_sent_usec);
+ ND_PRINT((ndo, "\n\t Sender Timestamp: "));
+ ts_print(ndo, &timestamp);
timestamp.tv_sec=EXTRACT_32BITS(lspping_com_header->ts_rcvd_sec);
- timestamp.tv_usec=EXTRACT_32BITS(lspping_com_header->ts_rcvd_usec);
- printf("Receiver Timestamp: ");
+ timestamp.tv_usec=EXTRACT_32BITS(lspping_com_header->ts_rcvd_usec);
+ ND_PRINT((ndo, "Receiver Timestamp: "));
if ((timestamp.tv_sec != 0) && (timestamp.tv_usec != 0))
- ts_print(&timestamp);
+ ts_print(ndo, &timestamp);
else
- printf("no timestamp");
+ ND_PRINT((ndo, "no timestamp"));
tptr+=sizeof(const struct lspping_common_header);
tlen-=sizeof(const struct lspping_common_header);
- while(tlen>(int)sizeof(struct lspping_tlv_header)) {
+ while (tlen != 0) {
+ /* Does the TLV go past the end of the packet? */
+ if (tlen < sizeof(struct lspping_tlv_header))
+ goto tooshort;
/* did we capture enough for fully decoding the tlv header ? */
- if (!TTEST2(*tptr, sizeof(struct lspping_tlv_header)))
- goto trunc;
+ ND_TCHECK2(*tptr, sizeof(struct lspping_tlv_header));
lspping_tlv_header = (const struct lspping_tlv_header *)tptr;
lspping_tlv_type=EXTRACT_16BITS(lspping_tlv_header->type);
lspping_tlv_len=EXTRACT_16BITS(lspping_tlv_header->length);
- /* some little sanity checking */
- if (lspping_tlv_type == 0 || lspping_tlv_len == 0)
- return;
-
- if(lspping_tlv_len < 4) {
- printf("\n\t ERROR: TLV %u bogus size %u",lspping_tlv_type,lspping_tlv_len);
- return;
- }
-
- printf("\n\t %s TLV (%u), length: %u",
+ ND_PRINT((ndo, "\n\t %s TLV (%u), length: %u",
tok2str(lspping_tlv_values,
"Unknown",
lspping_tlv_type),
lspping_tlv_type,
- lspping_tlv_len);
+ lspping_tlv_len));
+
+ /* some little sanity checking */
+ if (lspping_tlv_len == 0) {
+ tptr+=sizeof(struct lspping_tlv_header);
+ tlen-=sizeof(struct lspping_tlv_header);
+ continue; /* no value to dissect */
+ }
tlv_tptr=tptr+sizeof(struct lspping_tlv_header);
tlv_tlen=lspping_tlv_len; /* header not included -> no adjustment */
+ /* Does the TLV go past the end of the packet? */
+ if (tlen < lspping_tlv_len+sizeof(struct lspping_tlv_header))
+ goto tooshort;
/* did we capture enough for fully decoding the tlv ? */
- if (!TTEST2(*tptr, lspping_tlv_len))
- goto trunc;
+ ND_TCHECK2(*tlv_tptr, lspping_tlv_len);
tlv_hexdump=FALSE;
switch(lspping_tlv_type) {
case LSPPING_TLV_TARGET_FEC_STACK:
- while(tlv_tlen>(int)sizeof(struct lspping_tlv_header)) {
-
+ while (tlv_tlen != 0) {
+ /* Does the subTLV header go past the end of the TLV? */
+ if (tlv_tlen < sizeof(struct lspping_tlv_header)) {
+ ND_PRINT((ndo, "\n\t TLV is too short"));
+ tlv_hexdump = TRUE;
+ goto tlv_tooshort;
+ }
/* did we capture enough for fully decoding the subtlv header ? */
- if (!TTEST2(*tptr, sizeof(struct lspping_tlv_header)))
- goto trunc;
+ ND_TCHECK2(*tlv_tptr, sizeof(struct lspping_tlv_header));
subtlv_hexdump=FALSE;
lspping_subtlv_header = (const struct lspping_tlv_header *)tlv_tptr;
lspping_subtlv_type=EXTRACT_16BITS(lspping_subtlv_header->type);
lspping_subtlv_len=EXTRACT_16BITS(lspping_subtlv_header->length);
subtlv_tptr=tlv_tptr+sizeof(struct lspping_tlv_header);
-
- if (lspping_subtlv_len == 0)
- break;
- printf("\n\t %s subTLV (%u), length: %u",
+ /* Does the subTLV go past the end of the TLV? */
+ if (tlv_tlen < lspping_subtlv_len+sizeof(struct lspping_tlv_header)) {
+ ND_PRINT((ndo, "\n\t TLV is too short"));
+ tlv_hexdump = TRUE;
+ goto tlv_tooshort;
+ }
+
+ /* Did we capture enough for fully decoding the subTLV? */
+ ND_TCHECK2(*subtlv_tptr, lspping_subtlv_len);
+
+ ND_PRINT((ndo, "\n\t %s subTLV (%u), length: %u",
tok2str(lspping_tlvtargetfec_subtlv_values,
"Unknown",
lspping_subtlv_type),
lspping_subtlv_type,
- lspping_subtlv_len);
+ lspping_subtlv_len));
switch(lspping_subtlv_type) {
case LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV4:
- subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv4 = \
- (const struct lspping_tlv_targetfec_subtlv_ldp_ipv4_t *)subtlv_tptr;
- printf("\n\t %s/%u",
- ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv4->prefix),
- subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv4->prefix_len);
+ /* Is the subTLV length correct? */
+ if (lspping_subtlv_len != 5) {
+ ND_PRINT((ndo, "\n\t invalid subTLV length, should be 5"));
+ subtlv_hexdump=TRUE; /* unknown subTLV just hexdump it */
+ } else {
+ subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv4 = \
+ (const struct lspping_tlv_targetfec_subtlv_ldp_ipv4_t *)subtlv_tptr;
+ ND_PRINT((ndo, "\n\t %s/%u",
+ ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv4->prefix),
+ subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv4->prefix_len));
+ }
break;
-#ifdef INET6
case LSPPING_TLV_TARGETFEC_SUBTLV_LDP_IPV6:
- subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv6 = \
- (const struct lspping_tlv_targetfec_subtlv_ldp_ipv6_t *)subtlv_tptr;
- printf("\n\t %s/%u",
- ip6addr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv6->prefix),
- subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv6->prefix_len);
+ /* Is the subTLV length correct? */
+ if (lspping_subtlv_len != 17) {
+ ND_PRINT((ndo, "\n\t invalid subTLV length, should be 17"));
+ subtlv_hexdump=TRUE; /* unknown subTLV just hexdump it */
+ } else {
+ subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv6 = \
+ (const struct lspping_tlv_targetfec_subtlv_ldp_ipv6_t *)subtlv_tptr;
+ ND_PRINT((ndo, "\n\t %s/%u",
+ ip6addr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv6->prefix),
+ subtlv_ptr.lspping_tlv_targetfec_subtlv_ldp_ipv6->prefix_len));
+ }
break;
-#endif
case LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV4:
- subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv4 = \
- (const struct lspping_tlv_targetfec_subtlv_bgp_ipv4_t *)subtlv_tptr;
- printf("\n\t %s/%u, sender-id %s",
- ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv4->prefix),
- subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv4->prefix_len,
- ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv4->sender_id));
+ /* Is the subTLV length correct? */
+ if (lspping_subtlv_len != 5) {
+ ND_PRINT((ndo, "\n\t invalid subTLV length, should be 5"));
+ subtlv_hexdump=TRUE; /* unknown subTLV just hexdump it */
+ } else {
+ subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv4 = \
+ (const struct lspping_tlv_targetfec_subtlv_bgp_ipv4_t *)subtlv_tptr;
+ ND_PRINT((ndo, "\n\t %s/%u",
+ ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv4->prefix),
+ subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv4->prefix_len));
+ }
break;
-#ifdef INET6
case LSPPING_TLV_TARGETFEC_SUBTLV_BGP_IPV6:
- subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv6 = \
- (const struct lspping_tlv_targetfec_subtlv_bgp_ipv6_t *)subtlv_tptr;
- printf("\n\t %s/%u, sender-id %s",
- ip6addr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv6->prefix),
- subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv6->prefix_len,
- ip6addr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv6->sender_id));
+ /* Is the subTLV length correct? */
+ if (lspping_subtlv_len != 17) {
+ ND_PRINT((ndo, "\n\t invalid subTLV length, should be 17"));
+ subtlv_hexdump=TRUE; /* unknown subTLV just hexdump it */
+ } else {
+ subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv6 = \
+ (const struct lspping_tlv_targetfec_subtlv_bgp_ipv6_t *)subtlv_tptr;
+ ND_PRINT((ndo, "\n\t %s/%u",
+ ip6addr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv6->prefix),
+ subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv6->prefix_len));
+ }
break;
-#endif
case LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV4:
- subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4 = \
- (const struct lspping_tlv_targetfec_subtlv_rsvp_ipv4_t *)subtlv_tptr;
- printf("\n\t tunnel end-point %s, tunnel sender %s, lsp-id 0x%04x" \
- "\n\t tunnel-id 0x%04x, extended tunnel-id %s",
- ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->tunnel_endpoint),
- ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->tunnel_sender),
- EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->lsp_id),
- EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->tunnel_id),
- ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->extended_tunnel_id));
+ /* Is the subTLV length correct? */
+ if (lspping_subtlv_len != 20) {
+ ND_PRINT((ndo, "\n\t invalid subTLV length, should be 20"));
+ subtlv_hexdump=TRUE; /* unknown subTLV just hexdump it */
+ } else {
+ subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4 = \
+ (const struct lspping_tlv_targetfec_subtlv_rsvp_ipv4_t *)subtlv_tptr;
+ ND_PRINT((ndo, "\n\t tunnel end-point %s, tunnel sender %s, lsp-id 0x%04x" \
+ "\n\t tunnel-id 0x%04x, extended tunnel-id %s",
+ ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->tunnel_endpoint),
+ ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->tunnel_sender),
+ EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->lsp_id),
+ EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->tunnel_id),
+ ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv4->extended_tunnel_id)));
+ }
break;
-#ifdef INET6
case LSPPING_TLV_TARGETFEC_SUBTLV_RSVP_IPV6:
- subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6 = \
- (const struct lspping_tlv_targetfec_subtlv_rsvp_ipv6_t *)subtlv_tptr;
- printf("\n\t tunnel end-point %s, tunnel sender %s, lsp-id 0x%04x" \
- "\n\t tunnel-id 0x%04x, extended tunnel-id %s",
- ip6addr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->tunnel_endpoint),
- ip6addr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->tunnel_sender),
- EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->lsp_id),
- EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->tunnel_id),
- ip6addr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->extended_tunnel_id));
+ /* Is the subTLV length correct? */
+ if (lspping_subtlv_len != 56) {
+ ND_PRINT((ndo, "\n\t invalid subTLV length, should be 56"));
+ subtlv_hexdump=TRUE; /* unknown subTLV just hexdump it */
+ } else {
+ subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6 = \
+ (const struct lspping_tlv_targetfec_subtlv_rsvp_ipv6_t *)subtlv_tptr;
+ ND_PRINT((ndo, "\n\t tunnel end-point %s, tunnel sender %s, lsp-id 0x%04x" \
+ "\n\t tunnel-id 0x%04x, extended tunnel-id %s",
+ ip6addr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->tunnel_endpoint),
+ ip6addr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->tunnel_sender),
+ EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->lsp_id),
+ EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->tunnel_id),
+ ip6addr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_rsvp_ipv6->extended_tunnel_id)));
+ }
break;
-#endif
case LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV4:
- subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv4 = \
- (const struct lspping_tlv_targetfec_subtlv_l3vpn_ipv4_t *)subtlv_tptr;
- printf("\n\t RD: %s, %s/%u",
- bgp_vpn_rd_print(subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv4->rd),
- ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv4->prefix),
- subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv4->prefix_len);
+ /* Is the subTLV length correct? */
+ if (lspping_subtlv_len != 13) {
+ ND_PRINT((ndo, "\n\t invalid subTLV length, should be 13"));
+ subtlv_hexdump=TRUE; /* unknown subTLV just hexdump it */
+ } else {
+ subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv4 = \
+ (const struct lspping_tlv_targetfec_subtlv_l3vpn_ipv4_t *)subtlv_tptr;
+ ND_PRINT((ndo, "\n\t RD: %s, %s/%u",
+ bgp_vpn_rd_print(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv4->rd),
+ ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv4->prefix),
+ subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv4->prefix_len));
+ }
break;
-#ifdef INET6
case LSPPING_TLV_TARGETFEC_SUBTLV_L3VPN_IPV6:
- subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv6 = \
- (const struct lspping_tlv_targetfec_subtlv_l3vpn_ipv6_t *)subtlv_tptr;
- printf("\n\t RD: %s, %s/%u",
- bgp_vpn_rd_print(subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv6->rd),
- ip6addr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv6->prefix),
- subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv6->prefix_len);
+ /* Is the subTLV length correct? */
+ if (lspping_subtlv_len != 25) {
+ ND_PRINT((ndo, "\n\t invalid subTLV length, should be 25"));
+ subtlv_hexdump=TRUE; /* unknown subTLV just hexdump it */
+ } else {
+ subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv6 = \
+ (const struct lspping_tlv_targetfec_subtlv_l3vpn_ipv6_t *)subtlv_tptr;
+ ND_PRINT((ndo, "\n\t RD: %s, %s/%u",
+ bgp_vpn_rd_print(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv6->rd),
+ ip6addr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv6->prefix),
+ subtlv_ptr.lspping_tlv_targetfec_subtlv_l3vpn_ipv6->prefix_len));
+ }
break;
-#endif
case LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_ENDPT:
- subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt = \
- (const struct lspping_tlv_targetfec_subtlv_l2vpn_endpt_t *)subtlv_tptr;
- printf("\n\t RD: %s, Sender CE-ID: %u, Receiver CE-ID: %u" \
- "\n\t Encapsulation Type: %s (%u)",
- bgp_vpn_rd_print(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->rd),
- EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->sender_ce_id),
- EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->receiver_ce_id),
- tok2str(l2vpn_encaps_values,
- "unknown",
- EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->encapsulation)),
- EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->encapsulation));
-
+ /* Is the subTLV length correct? */
+ if (lspping_subtlv_len != 14) {
+ ND_PRINT((ndo, "\n\t invalid subTLV length, should be 14"));
+ subtlv_hexdump=TRUE; /* unknown subTLV just hexdump it */
+ } else {
+ subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt = \
+ (const struct lspping_tlv_targetfec_subtlv_l2vpn_endpt_t *)subtlv_tptr;
+ ND_PRINT((ndo, "\n\t RD: %s, Sender VE ID: %u, Receiver VE ID: %u" \
+ "\n\t Encapsulation Type: %s (%u)",
+ bgp_vpn_rd_print(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->rd),
+ EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->sender_ve_id),
+ EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->receiver_ve_id),
+ tok2str(mpls_pw_types_values,
+ "unknown",
+ EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->encapsulation)),
+ EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_endpt->encapsulation)));
+ }
break;
/* the old L2VPN VCID subTLV does not have support for the sender field */
- case LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID_OLD:
- subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old = \
- (const struct lspping_tlv_targetfec_subtlv_l2vpn_vcid_old_t *)subtlv_tptr;
- printf("\n\t Remote PE: %s" \
- "\n\t VC-ID: 0x%08x, Encapsulation Type: %s (%u)",
- ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old->remote_pe_address),
- EXTRACT_32BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old->vc_id),
- tok2str(l2vpn_encaps_values,
- "unknown",
- EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old->encapsulation)),
- EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old->encapsulation));
-
+ case LSPPING_TLV_TARGETFEC_SUBTLV_FEC_128_PW_OLD:
+ /* Is the subTLV length correct? */
+ if (lspping_subtlv_len != 10) {
+ ND_PRINT((ndo, "\n\t invalid subTLV length, should be 10"));
+ subtlv_hexdump=TRUE; /* unknown subTLV just hexdump it */
+ } else {
+ subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old = \
+ (const struct lspping_tlv_targetfec_subtlv_fec_128_pw_old *)subtlv_tptr;
+ ND_PRINT((ndo, "\n\t Remote PE: %s" \
+ "\n\t PW ID: 0x%08x, PW Type: %s (%u)",
+ ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old->remote_pe_address),
+ EXTRACT_32BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old->pw_id),
+ tok2str(mpls_pw_types_values,
+ "unknown",
+ EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old->pw_type)),
+ EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid_old->pw_type)));
+ }
break;
- case LSPPING_TLV_TARGETFEC_SUBTLV_L2VPN_VCID:
- subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid = \
- (const struct lspping_tlv_targetfec_subtlv_l2vpn_vcid_t *)subtlv_tptr;
- printf("\n\t Sender PE: %s, Remote PE: %s" \
- "\n\t VC-ID: 0x%08x, Encapsulation Type: %s (%u)",
- ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->sender_pe_address),
- ipaddr_string(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->remote_pe_address),
- EXTRACT_32BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->vc_id),
- tok2str(l2vpn_encaps_values,
- "unknown",
- EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->encapsulation)),
- EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->encapsulation));
-
+ case LSPPING_TLV_TARGETFEC_SUBTLV_FEC_128_PW:
+ /* Is the subTLV length correct? */
+ if (lspping_subtlv_len != 14) {
+ ND_PRINT((ndo, "\n\t invalid subTLV length, should be 14"));
+ subtlv_hexdump=TRUE; /* unknown subTLV just hexdump it */
+ } else {
+ subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid = \
+ (const struct lspping_tlv_targetfec_subtlv_fec_128_pw *)subtlv_tptr;
+ ND_PRINT((ndo, "\n\t Sender PE: %s, Remote PE: %s" \
+ "\n\t PW ID: 0x%08x, PW Type: %s (%u)",
+ ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->sender_pe_address),
+ ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->remote_pe_address),
+ EXTRACT_32BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->pw_id),
+ tok2str(mpls_pw_types_values,
+ "unknown",
+ EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->pw_type)),
+ EXTRACT_16BITS(subtlv_ptr.lspping_tlv_targetfec_subtlv_l2vpn_vcid->pw_type)));
+ }
break;
default:
@@ -769,59 +863,126 @@ lspping_print(register const u_char *pptr, register u_int len) {
break;
}
/* do we want to see an additionally subtlv hexdump ? */
- if (vflag > 1 || subtlv_hexdump==TRUE)
- print_unknown_data(tlv_tptr+sizeof(struct lspping_tlv_header), \
+ if (ndo->ndo_vflag > 1 || subtlv_hexdump==TRUE)
+ print_unknown_data(ndo, tlv_tptr+sizeof(struct lspping_tlv_header), \
"\n\t ",
lspping_subtlv_len);
+ /* All subTLVs are aligned to four octet boundary */
+ if (lspping_subtlv_len % 4) {
+ lspping_subtlv_len += 4 - (lspping_subtlv_len % 4);
+ /* Does the subTLV, including padding, go past the end of the TLV? */
+ if (tlv_tlen < lspping_subtlv_len+sizeof(struct lspping_tlv_header)) {
+ ND_PRINT((ndo, "\n\t\t TLV is too short"));
+ return;
+ }
+ }
tlv_tptr+=lspping_subtlv_len;
tlv_tlen-=lspping_subtlv_len+sizeof(struct lspping_tlv_header);
}
break;
case LSPPING_TLV_DOWNSTREAM_MAPPING:
+ /* Does the header go past the end of the TLV? */
+ if (tlv_tlen < sizeof(struct lspping_tlv_downstream_map_t)) {
+ ND_PRINT((ndo, "\n\t TLV is too short"));
+ tlv_hexdump = TRUE;
+ goto tlv_tooshort;
+ }
+ /* Did we capture enough to get the address family? */
+ ND_TCHECK2(*tlv_tptr, sizeof(struct lspping_tlv_downstream_map_t));
+
+ tlv_ptr.lspping_tlv_downstream_map= \
+ (const struct lspping_tlv_downstream_map_t *)tlv_tptr;
+
/* that strange thing with the downstream map TLV is that until now
- * we do not know if its IPv4 or IPv6 , after we found the adress-type
- * lets recast the tlv_tptr and move on */
-
- tlv_ptr.lspping_tlv_downstream_map_ipv4= \
- (const struct lspping_tlv_downstream_map_ipv4_t *)tlv_tptr;
- tlv_ptr.lspping_tlv_downstream_map_ipv6= \
- (const struct lspping_tlv_downstream_map_ipv6_t *)tlv_tptr;
- printf("\n\t MTU: %u, Address-Type: %s (%u)",
- EXTRACT_16BITS(tlv_ptr.lspping_tlv_downstream_map_ipv4->mtu),
+ * we do not know if its IPv4 or IPv6 or is unnumbered; after
+ * we find the address-type, we recast the tlv_tptr and move on. */
+
+ ND_PRINT((ndo, "\n\t MTU: %u, Address-Type: %s (%u)",
+ EXTRACT_16BITS(tlv_ptr.lspping_tlv_downstream_map->mtu),
tok2str(lspping_tlv_downstream_addr_values,
"unknown",
- tlv_ptr.lspping_tlv_downstream_map_ipv4->address_type),
- tlv_ptr.lspping_tlv_downstream_map_ipv4->address_type);
+ tlv_ptr.lspping_tlv_downstream_map->address_type),
+ tlv_ptr.lspping_tlv_downstream_map->address_type));
- switch(tlv_ptr.lspping_tlv_downstream_map_ipv4->address_type) {
+ switch(tlv_ptr.lspping_tlv_downstream_map->address_type) {
case LSPPING_AFI_IPV4:
- printf("\n\t Downstream IP: %s" \
+ /* Does the data go past the end of the TLV? */
+ if (tlv_tlen < sizeof(struct lspping_tlv_downstream_map_ipv4_t)) {
+ ND_PRINT((ndo, "\n\t TLV is too short"));
+ tlv_hexdump = TRUE;
+ goto tlv_tooshort;
+ }
+ /* Did we capture enough for this part of the TLV? */
+ ND_TCHECK2(*tlv_tptr, sizeof(struct lspping_tlv_downstream_map_ipv4_t));
+
+ tlv_ptr.lspping_tlv_downstream_map_ipv4= \
+ (const struct lspping_tlv_downstream_map_ipv4_t *)tlv_tptr;
+ ND_PRINT((ndo, "\n\t Downstream IP: %s" \
"\n\t Downstream Interface IP: %s",
- ipaddr_string(tlv_ptr.lspping_tlv_downstream_map_ipv4->downstream_ip),
- ipaddr_string(tlv_ptr.lspping_tlv_downstream_map_ipv4->downstream_interface));
+ ipaddr_string(ndo, tlv_ptr.lspping_tlv_downstream_map_ipv4->downstream_ip),
+ ipaddr_string(ndo, tlv_ptr.lspping_tlv_downstream_map_ipv4->downstream_interface)));
tlv_tptr+=sizeof(struct lspping_tlv_downstream_map_ipv4_t);
tlv_tlen-=sizeof(struct lspping_tlv_downstream_map_ipv4_t);
break;
-#ifdef INET6
- case LSPPING_AFI_IPV6:
- printf("\n\t Downstream IP: %s" \
+ case LSPPING_AFI_IPV4_UNMB:
+ /* Does the data go past the end of the TLV? */
+ if (tlv_tlen < sizeof(struct lspping_tlv_downstream_map_ipv4_unmb_t)) {
+ ND_PRINT((ndo, "\n\t TLV is too short"));
+ tlv_hexdump = TRUE;
+ goto tlv_tooshort;
+ }
+ /* Did we capture enough for this part of the TLV? */
+ ND_TCHECK2(*tlv_tptr, sizeof(struct lspping_tlv_downstream_map_ipv4_unmb_t));
+
+ tlv_ptr.lspping_tlv_downstream_map_ipv4_unmb= \
+ (const struct lspping_tlv_downstream_map_ipv4_unmb_t *)tlv_tptr;
+ ND_PRINT((ndo, "\n\t Downstream IP: %s" \
+ "\n\t Downstream Interface Index: 0x%08x",
+ ipaddr_string(ndo, tlv_ptr.lspping_tlv_downstream_map_ipv4_unmb->downstream_ip),
+ EXTRACT_32BITS(tlv_ptr.lspping_tlv_downstream_map_ipv4_unmb->downstream_interface)));
+ tlv_tptr+=sizeof(struct lspping_tlv_downstream_map_ipv4_unmb_t);
+ tlv_tlen-=sizeof(struct lspping_tlv_downstream_map_ipv4_unmb_t);
+ break;
+ case LSPPING_AFI_IPV6:
+ /* Does the data go past the end of the TLV? */
+ if (tlv_tlen < sizeof(struct lspping_tlv_downstream_map_ipv6_t)) {
+ ND_PRINT((ndo, "\n\t TLV is too short"));
+ tlv_hexdump = TRUE;
+ goto tlv_tooshort;
+ }
+ /* Did we capture enough for this part of the TLV? */
+ ND_TCHECK2(*tlv_tptr, sizeof(struct lspping_tlv_downstream_map_ipv6_t));
+
+ tlv_ptr.lspping_tlv_downstream_map_ipv6= \
+ (const struct lspping_tlv_downstream_map_ipv6_t *)tlv_tptr;
+ ND_PRINT((ndo, "\n\t Downstream IP: %s" \
"\n\t Downstream Interface IP: %s",
- ip6addr_string(tlv_ptr.lspping_tlv_downstream_map_ipv6->downstream_ip),
- ip6addr_string(tlv_ptr.lspping_tlv_downstream_map_ipv6->downstream_interface));
+ ip6addr_string(ndo, tlv_ptr.lspping_tlv_downstream_map_ipv6->downstream_ip),
+ ip6addr_string(ndo, tlv_ptr.lspping_tlv_downstream_map_ipv6->downstream_interface)));
tlv_tptr+=sizeof(struct lspping_tlv_downstream_map_ipv6_t);
tlv_tlen-=sizeof(struct lspping_tlv_downstream_map_ipv6_t);
break;
-#endif
- case LSPPING_AFI_UNMB:
- printf("\n\t Downstream IP: %s" \
+ case LSPPING_AFI_IPV6_UNMB:
+ /* Does the data go past the end of the TLV? */
+ if (tlv_tlen < sizeof(struct lspping_tlv_downstream_map_ipv6_unmb_t)) {
+ ND_PRINT((ndo, "\n\t TLV is too short"));
+ tlv_hexdump = TRUE;
+ goto tlv_tooshort;
+ }
+ /* Did we capture enough for this part of the TLV? */
+ ND_TCHECK2(*tlv_tptr, sizeof(struct lspping_tlv_downstream_map_ipv6_unmb_t));
+
+ tlv_ptr.lspping_tlv_downstream_map_ipv6_unmb= \
+ (const struct lspping_tlv_downstream_map_ipv6_unmb_t *)tlv_tptr;
+ ND_PRINT((ndo, "\n\t Downstream IP: %s" \
"\n\t Downstream Interface Index: 0x%08x",
- ipaddr_string(tlv_ptr.lspping_tlv_downstream_map_ipv4->downstream_ip),
- EXTRACT_32BITS(tlv_ptr.lspping_tlv_downstream_map_ipv4->downstream_interface));
- tlv_tptr+=sizeof(struct lspping_tlv_downstream_map_ipv4_t);
- tlv_tlen-=sizeof(struct lspping_tlv_downstream_map_ipv4_t);
+ ip6addr_string(ndo, tlv_ptr.lspping_tlv_downstream_map_ipv6_unmb->downstream_ip),
+ EXTRACT_32BITS(tlv_ptr.lspping_tlv_downstream_map_ipv6_unmb->downstream_interface)));
+ tlv_tptr+=sizeof(struct lspping_tlv_downstream_map_ipv6_unmb_t);
+ tlv_tlen-=sizeof(struct lspping_tlv_downstream_map_ipv6_unmb_t);
break;
default:
@@ -829,39 +990,55 @@ lspping_print(register const u_char *pptr, register u_int len) {
break;
}
+ /* Does the data go past the end of the TLV? */
+ if (tlv_tlen < sizeof(struct lspping_tlv_downstream_map_info_t)) {
+ ND_PRINT((ndo, "\n\t TLV is too short"));
+ tlv_hexdump = TRUE;
+ goto tlv_tooshort;
+ }
+ /* Did we capture enough for this part of the TLV? */
+ ND_TCHECK2(*tlv_tptr, sizeof(struct lspping_tlv_downstream_map_info_t));
+
tlv_ptr.lspping_tlv_downstream_map_info= \
(const struct lspping_tlv_downstream_map_info_t *)tlv_tptr;
-
- /* FIXME add hash-key type, depth limit, multipath processing */
+ /* FIXME add hash-key type, depth limit, multipath processing */
tlv_tptr+=sizeof(struct lspping_tlv_downstream_map_info_t);
tlv_tlen-=sizeof(struct lspping_tlv_downstream_map_info_t);
/* FIXME print downstream labels */
-
tlv_hexdump=TRUE; /* dump the TLV until code complete */
break;
case LSPPING_TLV_BFD_DISCRIMINATOR:
- tptr += sizeof(struct lspping_tlv_header);
- if (!TTEST2(*tptr, LSPPING_TLV_BFD_DISCRIMINATOR_LEN))
- goto trunc;
- printf("\n\t BFD Discriminator 0x%08x", EXTRACT_32BITS(tptr));
+ if (tlv_tlen < LSPPING_TLV_BFD_DISCRIMINATOR_LEN) {
+ ND_PRINT((ndo, "\n\t TLV is too short"));
+ tlv_hexdump = TRUE;
+ goto tlv_tooshort;
+ } else {
+ ND_TCHECK2(*tptr, LSPPING_TLV_BFD_DISCRIMINATOR_LEN);
+ ND_PRINT((ndo, "\n\t BFD Discriminator 0x%08x", EXTRACT_32BITS(tptr)));
+ }
break;
case LSPPING_TLV_VENDOR_ENTERPRISE:
{
- u_int32_t vendor_id;
-
- if (!TTEST2(*tptr, LSPPING_TLV_VENDOR_ENTERPRISE_LEN))
- goto trunc;
- vendor_id = EXTRACT_32BITS(tlv_tptr);
- printf("\n\t Vendor: %s (0x%04x)",
- tok2str(smi_values, "Unknown", vendor_id),
- vendor_id);
+ uint32_t vendor_id;
+
+ if (tlv_tlen < LSPPING_TLV_VENDOR_ENTERPRISE_LEN) {
+ ND_PRINT((ndo, "\n\t TLV is too short"));
+ tlv_hexdump = TRUE;
+ goto tlv_tooshort;
+ } else {
+ ND_TCHECK2(*tptr, LSPPING_TLV_VENDOR_ENTERPRISE_LEN);
+ vendor_id = EXTRACT_32BITS(tlv_tptr);
+ ND_PRINT((ndo, "\n\t Vendor: %s (0x%04x)",
+ tok2str(smi_values, "Unknown", vendor_id),
+ vendor_id));
+ }
}
break;
@@ -872,27 +1049,44 @@ lspping_print(register const u_char *pptr, register u_int len) {
case LSPPING_TLV_PAD:
case LSPPING_TLV_ERROR_CODE:
case LSPPING_TLV_VENDOR_PRIVATE:
-
+
default:
- if (vflag <= 1)
- print_unknown_data(tlv_tptr,"\n\t ",tlv_tlen);
+ if (ndo->ndo_vflag <= 1)
+ print_unknown_data(ndo, tlv_tptr, "\n\t ", tlv_tlen);
break;
}
/* do we want to see an additionally tlv hexdump ? */
- if (vflag > 1 || tlv_hexdump==TRUE)
- print_unknown_data(tptr+sizeof(struct lspping_tlv_header),"\n\t ",
+ tlv_tooshort:
+ if (ndo->ndo_vflag > 1 || tlv_hexdump==TRUE)
+ print_unknown_data(ndo, tptr+sizeof(struct lspping_tlv_header), "\n\t ",
lspping_tlv_len);
/* All TLVs are aligned to four octet boundary */
if (lspping_tlv_len % 4) {
lspping_tlv_len += (4 - lspping_tlv_len % 4);
+ /* Does the TLV, including padding, go past the end of the packet? */
+ if (tlen < lspping_tlv_len+sizeof(struct lspping_tlv_header))
+ goto tooshort;
}
tptr+=lspping_tlv_len+sizeof(struct lspping_tlv_header);
tlen-=lspping_tlv_len+sizeof(struct lspping_tlv_header);
}
return;
+tooshort:
+ ND_PRINT((ndo, "\n\t\t packet is too short"));
+ return;
trunc:
- printf("\n\t\t packet exceeded snapshot");
+ ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
+ return;
}
+/*
+ * Local Variables:
+ * c-style: whitesmith
+ * c-basic-offset: 8
+ * End:
+ */
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-lspping-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-lwapp.c b/freebsd/contrib/tcpdump/print-lwapp.c
index fb76203f..343231ef 100644
--- a/freebsd/contrib/tcpdump/print-lwapp.c
+++ b/freebsd/contrib/tcpdump/print-lwapp.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1998-2007 The TCPDUMP project
*
@@ -14,31 +17,24 @@
* LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE.
*
- * Support for the Light Weight Access Point Protocol as per draft-ohara-capwap-lwapp-04
- *
* Original code by Carles Kishimoto <carles.kishimoto@gmail.com>
*/
-#ifndef lint
-static const char rcsid[] _U_ =
-"@(#) $Header: /tcpdump/master/tcpdump/print-lwapp.c,v 1.1 2007-07-24 16:07:30 hannes Exp $";
-#endif
+/* \summary: Light Weight Access Point Protocol (LWAPP) printer */
+
+/* specification: RFC 5412 */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
#include "addrtoname.h"
-/*
+/*
* LWAPP transport (common) header
* 0 1 2 3
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
@@ -51,10 +47,10 @@ static const char rcsid[] _U_ =
*/
struct lwapp_transport_header {
- u_int8_t version;
- u_int8_t frag_id;
- u_int8_t length[2];
- u_int16_t status;
+ uint8_t version;
+ uint8_t frag_id;
+ uint8_t length[2];
+ uint16_t status;
};
/*
@@ -71,16 +67,16 @@ struct lwapp_transport_header {
*/
struct lwapp_control_header {
- u_int8_t msg_type;
- u_int8_t seq_num;
- u_int8_t len[2];
- u_int8_t session_id[4];
+ uint8_t msg_type;
+ uint8_t seq_num;
+ uint8_t len[2];
+ uint8_t session_id[4];
};
#define LWAPP_VERSION 0
-#define LWAPP_EXTRACT_VERSION(x) (((x)&0xC0)>>6)
-#define LWAPP_EXTRACT_RID(x) (((x)&0x38)>>3)
-#define LWAPP_EXTRACT_CONTROL_BIT(x) (((x)&0x04)>>2)
+#define LWAPP_EXTRACT_VERSION(x) (((x)&0xC0)>>6)
+#define LWAPP_EXTRACT_RID(x) (((x)&0x38)>>3)
+#define LWAPP_EXTRACT_CONTROL_BIT(x) (((x)&0x04)>>2)
static const struct tok lwapp_header_bits_values[] = {
{ 0x01, "Last Fragment Bit"},
@@ -156,9 +152,9 @@ static const struct tok lwapp_msg_type_values[] = {
{ 0, NULL}
};
-/*
+/*
* LWAPP message elements
- *
+ *
* 0 1 2 3
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
@@ -166,13 +162,14 @@ static const struct tok lwapp_msg_type_values[] = {
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
struct lwapp_message_header {
- u_int8_t type;
- u_int8_t length[2];
+ uint8_t type;
+ uint8_t length[2];
};
void
-lwapp_control_print(const u_char *pptr, u_int len, int has_ap_ident) {
-
+lwapp_control_print(netdissect_options *ndo,
+ const u_char *pptr, u_int len, int has_ap_ident)
+{
const struct lwapp_transport_header *lwapp_trans_header;
const struct lwapp_control_header *lwapp_control_header;
const u_char *tptr;
@@ -183,47 +180,45 @@ lwapp_control_print(const u_char *pptr, u_int len, int has_ap_ident) {
if (has_ap_ident) {
/* check if enough bytes for AP identity */
- if (!TTEST2(*tptr, 6))
- goto trunc;
+ ND_TCHECK2(*tptr, 6);
lwapp_trans_header = (const struct lwapp_transport_header *)(pptr+6);
} else {
lwapp_trans_header = (const struct lwapp_transport_header *)pptr;
}
- TCHECK(*lwapp_trans_header);
+ ND_TCHECK(*lwapp_trans_header);
/*
* Sanity checking of the header.
*/
if (LWAPP_EXTRACT_VERSION(lwapp_trans_header->version) != LWAPP_VERSION) {
- printf("LWAPP version %u packet not supported",
- LWAPP_EXTRACT_VERSION(lwapp_trans_header->version));
+ ND_PRINT((ndo, "LWAPP version %u packet not supported",
+ LWAPP_EXTRACT_VERSION(lwapp_trans_header->version)));
return;
}
/* non-verbose */
- if (vflag < 1) {
- printf("LWAPPv%u, %s frame, Flags [%s], length %u",
+ if (ndo->ndo_vflag < 1) {
+ ND_PRINT((ndo, "LWAPPv%u, %s frame, Flags [%s], length %u",
LWAPP_EXTRACT_VERSION(lwapp_trans_header->version),
LWAPP_EXTRACT_CONTROL_BIT(lwapp_trans_header->version) ? "Control" : "Data",
bittok2str(lwapp_header_bits_values,"none",(lwapp_trans_header->version)&0x07),
- len);
+ len));
return;
}
/* ok they seem to want to know everything - lets fully decode it */
tlen=EXTRACT_16BITS(lwapp_trans_header->length);
- printf("LWAPPv%u, %s frame, Radio-id %u, Flags [%s], Frag-id %u, length %u",
+ ND_PRINT((ndo, "LWAPPv%u, %s frame, Radio-id %u, Flags [%s], Frag-id %u, length %u",
LWAPP_EXTRACT_VERSION(lwapp_trans_header->version),
LWAPP_EXTRACT_CONTROL_BIT(lwapp_trans_header->version) ? "Control" : "Data",
LWAPP_EXTRACT_RID(lwapp_trans_header->version),
bittok2str(lwapp_header_bits_values,"none",(lwapp_trans_header->version)&0x07),
lwapp_trans_header->frag_id,
- tlen);
+ tlen));
if (has_ap_ident) {
- printf("\n\tAP identity: %s",
- etheraddr_string(tptr));
+ ND_PRINT((ndo, "\n\tAP identity: %s", etheraddr_string(ndo, tptr)));
tptr+=sizeof(const struct lwapp_transport_header)+6;
} else {
tptr+=sizeof(const struct lwapp_transport_header);
@@ -232,23 +227,21 @@ lwapp_control_print(const u_char *pptr, u_int len, int has_ap_ident) {
while(tlen>0) {
/* did we capture enough for fully decoding the object header ? */
- if (!TTEST2(*tptr, sizeof(struct lwapp_control_header)))
- goto trunc;
+ ND_TCHECK2(*tptr, sizeof(struct lwapp_control_header));
lwapp_control_header = (const struct lwapp_control_header *)tptr;
msg_tlen = EXTRACT_16BITS(lwapp_control_header->len);
- /* print message header */
- printf("\n\t Msg type: %s (%u), Seqnum: %u, Msg len: %d, Session: 0x%08x",
+ /* print message header */
+ ND_PRINT((ndo, "\n\t Msg type: %s (%u), Seqnum: %u, Msg len: %d, Session: 0x%08x",
tok2str(lwapp_msg_type_values,"Unknown",lwapp_control_header->msg_type),
lwapp_control_header->msg_type,
lwapp_control_header->seq_num,
msg_tlen,
- EXTRACT_32BITS(lwapp_control_header->session_id));
+ EXTRACT_32BITS(lwapp_control_header->session_id)));
/* did we capture enough for fully decoding the message */
- if (!TTEST2(*tptr, msg_tlen))
- goto trunc;
+ ND_TCHECK2(*tptr, msg_tlen);
/* XXX - Decode sub messages for each message */
switch(lwapp_control_header->msg_type) {
@@ -293,12 +286,13 @@ lwapp_control_print(const u_char *pptr, u_int len, int has_ap_ident) {
return;
trunc:
- printf("\n\t\t packet exceeded snapshot");
+ ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
}
void
-lwapp_data_print(const u_char *pptr, u_int len) {
-
+lwapp_data_print(netdissect_options *ndo,
+ const u_char *pptr, u_int len)
+{
const struct lwapp_transport_header *lwapp_trans_header;
const u_char *tptr;
int tlen;
@@ -306,51 +300,50 @@ lwapp_data_print(const u_char *pptr, u_int len) {
tptr=pptr;
/* check if enough bytes for AP identity */
- if (!TTEST2(*tptr, 6))
- goto trunc;
+ ND_TCHECK2(*tptr, 6);
lwapp_trans_header = (const struct lwapp_transport_header *)pptr;
- TCHECK(*lwapp_trans_header);
+ ND_TCHECK(*lwapp_trans_header);
/*
* Sanity checking of the header.
*/
if (LWAPP_EXTRACT_VERSION(lwapp_trans_header->version) != LWAPP_VERSION) {
- printf("LWAPP version %u packet not supported",
- LWAPP_EXTRACT_VERSION(lwapp_trans_header->version));
+ ND_PRINT((ndo, "LWAPP version %u packet not supported",
+ LWAPP_EXTRACT_VERSION(lwapp_trans_header->version)));
return;
}
/* non-verbose */
- if (vflag < 1) {
- printf("LWAPPv%u, %s frame, Flags [%s], length %u",
+ if (ndo->ndo_vflag < 1) {
+ ND_PRINT((ndo, "LWAPPv%u, %s frame, Flags [%s], length %u",
LWAPP_EXTRACT_VERSION(lwapp_trans_header->version),
LWAPP_EXTRACT_CONTROL_BIT(lwapp_trans_header->version) ? "Control" : "Data",
bittok2str(lwapp_header_bits_values,"none",(lwapp_trans_header->version)&0x07),
- len);
+ len));
return;
}
/* ok they seem to want to know everything - lets fully decode it */
tlen=EXTRACT_16BITS(lwapp_trans_header->length);
- printf("LWAPPv%u, %s frame, Radio-id %u, Flags [%s], Frag-id %u, length %u",
+ ND_PRINT((ndo, "LWAPPv%u, %s frame, Radio-id %u, Flags [%s], Frag-id %u, length %u",
LWAPP_EXTRACT_VERSION(lwapp_trans_header->version),
LWAPP_EXTRACT_CONTROL_BIT(lwapp_trans_header->version) ? "Control" : "Data",
LWAPP_EXTRACT_RID(lwapp_trans_header->version),
bittok2str(lwapp_header_bits_values,"none",(lwapp_trans_header->version)&0x07),
lwapp_trans_header->frag_id,
- tlen);
+ tlen));
tptr+=sizeof(const struct lwapp_transport_header);
tlen-=sizeof(const struct lwapp_transport_header);
/* FIX - An IEEE 802.11 frame follows - hexdump for now */
- print_unknown_data(tptr, "\n\t", tlen);
+ print_unknown_data(ndo, tptr, "\n\t", tlen);
return;
trunc:
- printf("\n\t\t packet exceeded snapshot");
+ ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
}
/*
@@ -359,3 +352,6 @@ lwapp_data_print(const u_char *pptr, u_int len) {
* c-basic-offset: 8
* End:
*/
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-lwapp-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-lwres.c b/freebsd/contrib/tcpdump/print-lwres.c
index a68a67a4..10e2a449 100644
--- a/freebsd/contrib/tcpdump/print-lwres.c
+++ b/freebsd/contrib/tcpdump/print-lwres.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (C) 2001 WIDE Project.
* All rights reserved.
@@ -29,30 +32,27 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-lwres.c,v 1.13 2004-03-24 01:54:29 guy Exp $ (LBL)";
-#endif
+/* \summary: BIND9 Lightweight Resolver protocol printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include "nameser.h"
#include <stdio.h>
#include <string.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
-#include "extract.h" /* must come after interface.h */
+#include "extract.h"
/* BIND9 lib/lwres/include/lwres */
-typedef u_int32_t lwres_uint32_t;
-typedef u_int16_t lwres_uint16_t;
-typedef u_int8_t lwres_uint8_t;
+typedef uint32_t lwres_uint32_t;
+typedef uint16_t lwres_uint16_t;
+typedef uint8_t lwres_uint8_t;
struct lwres_lwpacket {
lwres_uint32_t length;
@@ -177,7 +177,7 @@ typedef struct {
#define LWRES_MAX_ALIASES 16 /* max # of aliases */
#define LWRES_MAX_ADDRS 64 /* max # of addrs */
-struct tok opcode[] = {
+static const struct tok opcode[] = {
{ LWRES_OPCODE_NOOP, "noop", },
{ LWRES_OPCODE_GETADDRSBYNAME, "getaddrsbyname", },
{ LWRES_OPCODE_GETNAMEBYADDR, "getnamebyaddr", },
@@ -186,28 +186,24 @@ struct tok opcode[] = {
};
/* print-domain.c */
-extern struct tok ns_type2str[];
-extern struct tok ns_class2str[];
-
-static int lwres_printname(size_t, const char *);
-static int lwres_printnamelen(const char *);
-static int lwres_printbinlen(const char *);
-static int lwres_printaddr(lwres_addr_t *);
+extern const struct tok ns_type2str[];
+extern const struct tok ns_class2str[];
static int
-lwres_printname(size_t l, const char *p0)
+lwres_printname(netdissect_options *ndo,
+ size_t l, const char *p0)
{
const char *p;
size_t i;
p = p0;
/* + 1 for terminating \0 */
- if (p + l + 1 > (const char *)snapend)
+ if (p + l + 1 > (const char *)ndo->ndo_snapend)
goto trunc;
- printf(" ");
+ ND_PRINT((ndo, " "));
for (i = 0; i < l; i++)
- safeputchar(*p++);
+ safeputchar(ndo, *p++);
p++; /* skip terminating \0 */
return p - p0;
@@ -217,15 +213,16 @@ lwres_printname(size_t l, const char *p0)
}
static int
-lwres_printnamelen(const char *p)
+lwres_printnamelen(netdissect_options *ndo,
+ const char *p)
{
- u_int16_t l;
+ uint16_t l;
int advance;
- if (p + 2 > (const char *)snapend)
+ if (p + 2 > (const char *)ndo->ndo_snapend)
goto trunc;
l = EXTRACT_16BITS(p);
- advance = lwres_printname(l, p + 2);
+ advance = lwres_printname(ndo, l, p + 2);
if (advance < 0)
goto trunc;
return 2 + advance;
@@ -235,21 +232,22 @@ lwres_printnamelen(const char *p)
}
static int
-lwres_printbinlen(const char *p0)
+lwres_printbinlen(netdissect_options *ndo,
+ const char *p0)
{
const char *p;
- u_int16_t l;
+ uint16_t l;
int i;
p = p0;
- if (p + 2 > (const char *)snapend)
+ if (p + 2 > (const char *)ndo->ndo_snapend)
goto trunc;
l = EXTRACT_16BITS(p);
- if (p + 2 + l > (const char *)snapend)
+ if (p + 2 + l > (const char *)ndo->ndo_snapend)
goto trunc;
p += 2;
for (i = 0; i < l; i++)
- printf("%02x", *p++);
+ ND_PRINT((ndo, "%02x", *p++));
return p - p0;
trunc:
@@ -257,37 +255,36 @@ lwres_printbinlen(const char *p0)
}
static int
-lwres_printaddr(lwres_addr_t *ap)
+lwres_printaddr(netdissect_options *ndo,
+ const lwres_addr_t *ap)
{
- u_int16_t l;
+ uint16_t l;
const char *p;
int i;
- TCHECK(ap->length);
+ ND_TCHECK(ap->length);
l = EXTRACT_16BITS(&ap->length);
/* XXX ap points to packed struct */
p = (const char *)&ap->length + sizeof(ap->length);
- TCHECK2(*p, l);
+ ND_TCHECK2(*p, l);
switch (EXTRACT_32BITS(&ap->family)) {
case 1: /* IPv4 */
if (l < 4)
return -1;
- printf(" %s", ipaddr_string(p));
+ ND_PRINT((ndo, " %s", ipaddr_string(ndo, p)));
p += sizeof(struct in_addr);
break;
-#ifdef INET6
case 2: /* IPv6 */
if (l < 16)
return -1;
- printf(" %s", ip6addr_string(p));
+ ND_PRINT((ndo, " %s", ip6addr_string(ndo, p)));
p += sizeof(struct in6_addr);
break;
-#endif
default:
- printf(" %u/", EXTRACT_32BITS(&ap->family));
+ ND_PRINT((ndo, " %u/", EXTRACT_32BITS(&ap->family)));
for (i = 0; i < l; i++)
- printf("%02x", *p++);
+ ND_PRINT((ndo, "%02x", *p++));
}
return p - (const char *)ap;
@@ -297,22 +294,23 @@ lwres_printaddr(lwres_addr_t *ap)
}
void
-lwres_print(register const u_char *bp, u_int length)
+lwres_print(netdissect_options *ndo,
+ register const u_char *bp, u_int length)
{
const struct lwres_lwpacket *np;
- u_int32_t v;
+ uint32_t v;
const char *s;
int response;
int advance;
int unsupported = 0;
np = (const struct lwres_lwpacket *)bp;
- TCHECK(np->authlength);
+ ND_TCHECK(np->authlength);
- printf(" lwres");
+ ND_PRINT((ndo, " lwres"));
v = EXTRACT_16BITS(&np->version);
- if (vflag || v != LWRES_LWPACKETVERSION_0)
- printf(" v%u", v);
+ if (ndo->ndo_vflag || v != LWRES_LWPACKETVERSION_0)
+ ND_PRINT((ndo, " v%u", v));
if (v != LWRES_LWPACKETVERSION_0) {
s = (const char *)np + EXTRACT_32BITS(&np->length);
goto tail;
@@ -323,25 +321,25 @@ lwres_print(register const u_char *bp, u_int length)
/* opcode and pktflags */
v = EXTRACT_32BITS(&np->opcode);
s = tok2str(opcode, "#0x%x", v);
- printf(" %s%s", s, response ? "" : "?");
+ ND_PRINT((ndo, " %s%s", s, response ? "" : "?"));
/* pktflags */
v = EXTRACT_16BITS(&np->pktflags);
if (v & ~LWRES_LWPACKETFLAG_RESPONSE)
- printf("[0x%x]", v);
+ ND_PRINT((ndo, "[0x%x]", v));
- if (vflag > 1) {
- printf(" ("); /*)*/
- printf("serial:0x%x", EXTRACT_32BITS(&np->serial));
- printf(" result:0x%x", EXTRACT_32BITS(&np->result));
- printf(" recvlen:%u", EXTRACT_32BITS(&np->recvlength));
+ if (ndo->ndo_vflag > 1) {
+ ND_PRINT((ndo, " (")); /*)*/
+ ND_PRINT((ndo, "serial:0x%x", EXTRACT_32BITS(&np->serial)));
+ ND_PRINT((ndo, " result:0x%x", EXTRACT_32BITS(&np->result)));
+ ND_PRINT((ndo, " recvlen:%u", EXTRACT_32BITS(&np->recvlength)));
/* BIND910: not used */
- if (vflag > 2) {
- printf(" authtype:0x%x", EXTRACT_16BITS(&np->authtype));
- printf(" authlen:%u", EXTRACT_16BITS(&np->authlength));
+ if (ndo->ndo_vflag > 2) {
+ ND_PRINT((ndo, " authtype:0x%x", EXTRACT_16BITS(&np->authtype)));
+ ND_PRINT((ndo, " authlen:%u", EXTRACT_16BITS(&np->authlength)));
}
/*(*/
- printf(")");
+ ND_PRINT((ndo, ")"));
}
/* per-opcode content */
@@ -349,10 +347,10 @@ lwres_print(register const u_char *bp, u_int length)
/*
* queries
*/
- lwres_gabnrequest_t *gabn;
- lwres_gnbarequest_t *gnba;
- lwres_grbnrequest_t *grbn;
- u_int32_t l;
+ const lwres_gabnrequest_t *gabn;
+ const lwres_gnbarequest_t *gnba;
+ const lwres_grbnrequest_t *grbn;
+ uint32_t l;
gabn = NULL;
gnba = NULL;
@@ -362,72 +360,72 @@ lwres_print(register const u_char *bp, u_int length)
case LWRES_OPCODE_NOOP:
break;
case LWRES_OPCODE_GETADDRSBYNAME:
- gabn = (lwres_gabnrequest_t *)(np + 1);
- TCHECK(gabn->namelen);
+ gabn = (const lwres_gabnrequest_t *)(np + 1);
+ ND_TCHECK(gabn->namelen);
/* XXX gabn points to packed struct */
s = (const char *)&gabn->namelen +
sizeof(gabn->namelen);
l = EXTRACT_16BITS(&gabn->namelen);
/* BIND910: not used */
- if (vflag > 2) {
- printf(" flags:0x%x",
- EXTRACT_32BITS(&gabn->flags));
+ if (ndo->ndo_vflag > 2) {
+ ND_PRINT((ndo, " flags:0x%x",
+ EXTRACT_32BITS(&gabn->flags)));
}
v = EXTRACT_32BITS(&gabn->addrtypes);
switch (v & (LWRES_ADDRTYPE_V4 | LWRES_ADDRTYPE_V6)) {
case LWRES_ADDRTYPE_V4:
- printf(" IPv4");
+ ND_PRINT((ndo, " IPv4"));
break;
case LWRES_ADDRTYPE_V6:
- printf(" IPv6");
+ ND_PRINT((ndo, " IPv6"));
break;
case LWRES_ADDRTYPE_V4 | LWRES_ADDRTYPE_V6:
- printf(" IPv4/6");
+ ND_PRINT((ndo, " IPv4/6"));
break;
}
if (v & ~(LWRES_ADDRTYPE_V4 | LWRES_ADDRTYPE_V6))
- printf("[0x%x]", v);
+ ND_PRINT((ndo, "[0x%x]", v));
- advance = lwres_printname(l, s);
+ advance = lwres_printname(ndo, l, s);
if (advance < 0)
goto trunc;
s += advance;
break;
case LWRES_OPCODE_GETNAMEBYADDR:
- gnba = (lwres_gnbarequest_t *)(np + 1);
- TCHECK(gnba->addr);
+ gnba = (const lwres_gnbarequest_t *)(np + 1);
+ ND_TCHECK(gnba->addr);
/* BIND910: not used */
- if (vflag > 2) {
- printf(" flags:0x%x",
- EXTRACT_32BITS(&gnba->flags));
+ if (ndo->ndo_vflag > 2) {
+ ND_PRINT((ndo, " flags:0x%x",
+ EXTRACT_32BITS(&gnba->flags)));
}
s = (const char *)&gnba->addr;
- advance = lwres_printaddr(&gnba->addr);
+ advance = lwres_printaddr(ndo, &gnba->addr);
if (advance < 0)
goto trunc;
s += advance;
break;
case LWRES_OPCODE_GETRDATABYNAME:
/* XXX no trace, not tested */
- grbn = (lwres_grbnrequest_t *)(np + 1);
- TCHECK(grbn->namelen);
+ grbn = (const lwres_grbnrequest_t *)(np + 1);
+ ND_TCHECK(grbn->namelen);
/* BIND910: not used */
- if (vflag > 2) {
- printf(" flags:0x%x",
- EXTRACT_32BITS(&grbn->flags));
+ if (ndo->ndo_vflag > 2) {
+ ND_PRINT((ndo, " flags:0x%x",
+ EXTRACT_32BITS(&grbn->flags)));
}
- printf(" %s", tok2str(ns_type2str, "Type%d",
- EXTRACT_16BITS(&grbn->rdtype)));
+ ND_PRINT((ndo, " %s", tok2str(ns_type2str, "Type%d",
+ EXTRACT_16BITS(&grbn->rdtype))));
if (EXTRACT_16BITS(&grbn->rdclass) != C_IN) {
- printf(" %s", tok2str(ns_class2str, "Class%d",
- EXTRACT_16BITS(&grbn->rdclass)));
+ ND_PRINT((ndo, " %s", tok2str(ns_class2str, "Class%d",
+ EXTRACT_16BITS(&grbn->rdclass))));
}
/* XXX grbn points to packed struct */
@@ -435,7 +433,7 @@ lwres_print(register const u_char *bp, u_int length)
sizeof(grbn->namelen);
l = EXTRACT_16BITS(&grbn->namelen);
- advance = lwres_printname(l, s);
+ advance = lwres_printname(ndo, l, s);
if (advance < 0)
goto trunc;
s += advance;
@@ -448,11 +446,11 @@ lwres_print(register const u_char *bp, u_int length)
/*
* responses
*/
- lwres_gabnresponse_t *gabn;
- lwres_gnbaresponse_t *gnba;
- lwres_grbnresponse_t *grbn;
- u_int32_t l, na;
- u_int32_t i;
+ const lwres_gabnresponse_t *gabn;
+ const lwres_gnbaresponse_t *gnba;
+ const lwres_grbnresponse_t *grbn;
+ uint32_t l, na;
+ uint32_t i;
gabn = NULL;
gnba = NULL;
@@ -462,23 +460,23 @@ lwres_print(register const u_char *bp, u_int length)
case LWRES_OPCODE_NOOP:
break;
case LWRES_OPCODE_GETADDRSBYNAME:
- gabn = (lwres_gabnresponse_t *)(np + 1);
- TCHECK(gabn->realnamelen);
+ gabn = (const lwres_gabnresponse_t *)(np + 1);
+ ND_TCHECK(gabn->realnamelen);
/* XXX gabn points to packed struct */
s = (const char *)&gabn->realnamelen +
sizeof(gabn->realnamelen);
l = EXTRACT_16BITS(&gabn->realnamelen);
/* BIND910: not used */
- if (vflag > 2) {
- printf(" flags:0x%x",
- EXTRACT_32BITS(&gabn->flags));
+ if (ndo->ndo_vflag > 2) {
+ ND_PRINT((ndo, " flags:0x%x",
+ EXTRACT_32BITS(&gabn->flags)));
}
- printf(" %u/%u", EXTRACT_16BITS(&gabn->naliases),
- EXTRACT_16BITS(&gabn->naddrs));
+ ND_PRINT((ndo, " %u/%u", EXTRACT_16BITS(&gabn->naliases),
+ EXTRACT_16BITS(&gabn->naddrs)));
- advance = lwres_printname(l, s);
+ advance = lwres_printname(ndo, l, s);
if (advance < 0)
goto trunc;
s += advance;
@@ -486,7 +484,7 @@ lwres_print(register const u_char *bp, u_int length)
/* aliases */
na = EXTRACT_16BITS(&gabn->naliases);
for (i = 0; i < na; i++) {
- advance = lwres_printnamelen(s);
+ advance = lwres_printnamelen(ndo, s);
if (advance < 0)
goto trunc;
s += advance;
@@ -495,29 +493,29 @@ lwres_print(register const u_char *bp, u_int length)
/* addrs */
na = EXTRACT_16BITS(&gabn->naddrs);
for (i = 0; i < na; i++) {
- advance = lwres_printaddr((lwres_addr_t *)s);
+ advance = lwres_printaddr(ndo, (const lwres_addr_t *)s);
if (advance < 0)
goto trunc;
s += advance;
}
break;
case LWRES_OPCODE_GETNAMEBYADDR:
- gnba = (lwres_gnbaresponse_t *)(np + 1);
- TCHECK(gnba->realnamelen);
+ gnba = (const lwres_gnbaresponse_t *)(np + 1);
+ ND_TCHECK(gnba->realnamelen);
/* XXX gnba points to packed struct */
s = (const char *)&gnba->realnamelen +
sizeof(gnba->realnamelen);
l = EXTRACT_16BITS(&gnba->realnamelen);
/* BIND910: not used */
- if (vflag > 2) {
- printf(" flags:0x%x",
- EXTRACT_32BITS(&gnba->flags));
+ if (ndo->ndo_vflag > 2) {
+ ND_PRINT((ndo, " flags:0x%x",
+ EXTRACT_32BITS(&gnba->flags)));
}
- printf(" %u", EXTRACT_16BITS(&gnba->naliases));
+ ND_PRINT((ndo, " %u", EXTRACT_16BITS(&gnba->naliases)));
- advance = lwres_printname(l, s);
+ advance = lwres_printname(ndo, l, s);
if (advance < 0)
goto trunc;
s += advance;
@@ -525,7 +523,7 @@ lwres_print(register const u_char *bp, u_int length)
/* aliases */
na = EXTRACT_16BITS(&gnba->naliases);
for (i = 0; i < na; i++) {
- advance = lwres_printnamelen(s);
+ advance = lwres_printnamelen(ndo, s);
if (advance < 0)
goto trunc;
s += advance;
@@ -533,30 +531,30 @@ lwres_print(register const u_char *bp, u_int length)
break;
case LWRES_OPCODE_GETRDATABYNAME:
/* XXX no trace, not tested */
- grbn = (lwres_grbnresponse_t *)(np + 1);
- TCHECK(grbn->nsigs);
+ grbn = (const lwres_grbnresponse_t *)(np + 1);
+ ND_TCHECK(grbn->nsigs);
/* BIND910: not used */
- if (vflag > 2) {
- printf(" flags:0x%x",
- EXTRACT_32BITS(&grbn->flags));
+ if (ndo->ndo_vflag > 2) {
+ ND_PRINT((ndo, " flags:0x%x",
+ EXTRACT_32BITS(&grbn->flags)));
}
- printf(" %s", tok2str(ns_type2str, "Type%d",
- EXTRACT_16BITS(&grbn->rdtype)));
+ ND_PRINT((ndo, " %s", tok2str(ns_type2str, "Type%d",
+ EXTRACT_16BITS(&grbn->rdtype))));
if (EXTRACT_16BITS(&grbn->rdclass) != C_IN) {
- printf(" %s", tok2str(ns_class2str, "Class%d",
- EXTRACT_16BITS(&grbn->rdclass)));
+ ND_PRINT((ndo, " %s", tok2str(ns_class2str, "Class%d",
+ EXTRACT_16BITS(&grbn->rdclass))));
}
- printf(" TTL ");
- relts_print(EXTRACT_32BITS(&grbn->ttl));
- printf(" %u/%u", EXTRACT_16BITS(&grbn->nrdatas),
- EXTRACT_16BITS(&grbn->nsigs));
+ ND_PRINT((ndo, " TTL "));
+ unsigned_relts_print(ndo, EXTRACT_32BITS(&grbn->ttl));
+ ND_PRINT((ndo, " %u/%u", EXTRACT_16BITS(&grbn->nrdatas),
+ EXTRACT_16BITS(&grbn->nsigs)));
/* XXX grbn points to packed struct */
s = (const char *)&grbn->nsigs+ sizeof(grbn->nsigs);
- advance = lwres_printnamelen(s);
+ advance = lwres_printnamelen(ndo, s);
if (advance < 0)
goto trunc;
s += advance;
@@ -565,7 +563,7 @@ lwres_print(register const u_char *bp, u_int length)
na = EXTRACT_16BITS(&grbn->nrdatas);
for (i = 0; i < na; i++) {
/* XXX should decode resource data */
- advance = lwres_printbinlen(s);
+ advance = lwres_printbinlen(ndo, s);
if (advance < 0)
goto trunc;
s += advance;
@@ -575,7 +573,7 @@ lwres_print(register const u_char *bp, u_int length)
na = EXTRACT_16BITS(&grbn->nsigs);
for (i = 0; i < na; i++) {
/* XXX how should we print it? */
- advance = lwres_printbinlen(s);
+ advance = lwres_printbinlen(ndo, s);
if (advance < 0)
goto trunc;
s += advance;
@@ -590,14 +588,16 @@ lwres_print(register const u_char *bp, u_int length)
tail:
/* length mismatch */
if (EXTRACT_32BITS(&np->length) != length) {
- printf(" [len: %u != %u]", EXTRACT_32BITS(&np->length),
- length);
+ ND_PRINT((ndo, " [len: %u != %u]", EXTRACT_32BITS(&np->length),
+ length));
}
if (!unsupported && s < (const char *)np + EXTRACT_32BITS(&np->length))
- printf("[extra]");
+ ND_PRINT((ndo, "[extra]"));
return;
trunc:
- printf("[|lwres]");
- return;
+ ND_PRINT((ndo, "[|lwres]"));
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-lwres-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-m3ua.c b/freebsd/contrib/tcpdump/print-m3ua.c
new file mode 100644
index 00000000..f72e084e
--- /dev/null
+++ b/freebsd/contrib/tcpdump/print-m3ua.c
@@ -0,0 +1,347 @@
+#include <machine/rtems-bsd-user-space.h>
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
+/* Copyright (c) 2013, The TCPDUMP project
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT OWNER 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: Message Transfer Part 3 (MTP3) User Adaptation Layer (M3UA) printer */
+
+/* RFC 4666 */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <netdissect-stdinc.h>
+
+#include "netdissect.h"
+#include "extract.h"
+
+static const char tstr[] = " [|m3ua]";
+
+#define M3UA_REL_1_0 1
+
+struct m3ua_common_header {
+ uint8_t v;
+ uint8_t reserved;
+ uint8_t msg_class;
+ uint8_t msg_type;
+ uint32_t len;
+};
+
+struct m3ua_param_header {
+ uint16_t tag;
+ uint16_t len;
+};
+
+/* message classes */
+#define M3UA_MSGC_MGMT 0
+#define M3UA_MSGC_TRANSFER 1
+#define M3UA_MSGC_SSNM 2
+#define M3UA_MSGC_ASPSM 3
+#define M3UA_MSGC_ASPTM 4
+/* reserved values */
+#define M3UA_MSGC_RKM 9
+
+static const struct tok MessageClasses[] = {
+ { M3UA_MSGC_MGMT, "Management" },
+ { M3UA_MSGC_TRANSFER, "Transfer" },
+ { M3UA_MSGC_SSNM, "SS7" },
+ { M3UA_MSGC_ASPSM, "ASP" },
+ { M3UA_MSGC_ASPTM, "ASP" },
+ { M3UA_MSGC_RKM, "Routing Key Managment" },
+ { 0, NULL }
+};
+
+/* management messages */
+#define M3UA_MGMT_ERROR 0
+#define M3UA_MGMT_NOTIFY 1
+
+static const struct tok MgmtMessages[] = {
+ { M3UA_MGMT_ERROR, "Error" },
+ { M3UA_MGMT_NOTIFY, "Notify" },
+ { 0, NULL }
+};
+
+/* transfer messages */
+#define M3UA_TRANSFER_DATA 1
+
+static const struct tok TransferMessages[] = {
+ { M3UA_TRANSFER_DATA, "Data" },
+ { 0, NULL }
+};
+
+/* SS7 Signaling Network Management messages */
+#define M3UA_SSNM_DUNA 1
+#define M3UA_SSNM_DAVA 2
+#define M3UA_SSNM_DAUD 3
+#define M3UA_SSNM_SCON 4
+#define M3UA_SSNM_DUPU 5
+#define M3UA_SSNM_DRST 6
+
+static const struct tok SS7Messages[] = {
+ { M3UA_SSNM_DUNA, "Destination Unavailable" },
+ { M3UA_SSNM_DAVA, "Destination Available" },
+ { M3UA_SSNM_DAUD, "Destination State Audit" },
+ { M3UA_SSNM_SCON, "Signalling Congestion" },
+ { M3UA_SSNM_DUPU, "Destination User Part Unavailable" },
+ { M3UA_SSNM_DRST, "Destination Restricted" },
+ { 0, NULL }
+};
+
+/* ASP State Maintenance messages */
+#define M3UA_ASP_UP 1
+#define M3UA_ASP_DN 2
+#define M3UA_ASP_BEAT 3
+#define M3UA_ASP_UP_ACK 4
+#define M3UA_ASP_DN_ACK 5
+#define M3UA_ASP_BEAT_ACK 6
+
+static const struct tok ASPStateMessages[] = {
+ { M3UA_ASP_UP, "Up" },
+ { M3UA_ASP_DN, "Down" },
+ { M3UA_ASP_BEAT, "Heartbeat" },
+ { M3UA_ASP_UP_ACK, "Up Acknowledgement" },
+ { M3UA_ASP_DN_ACK, "Down Acknowledgement" },
+ { M3UA_ASP_BEAT_ACK, "Heartbeat Acknowledgement" },
+ { 0, NULL }
+};
+
+/* ASP Traffic Maintenance messages */
+#define M3UA_ASP_AC 1
+#define M3UA_ASP_IA 2
+#define M3UA_ASP_AC_ACK 3
+#define M3UA_ASP_IA_ACK 4
+
+static const struct tok ASPTrafficMessages[] = {
+ { M3UA_ASP_AC, "Active" },
+ { M3UA_ASP_IA, "Inactive" },
+ { M3UA_ASP_AC_ACK, "Active Acknowledgement" },
+ { M3UA_ASP_IA_ACK, "Inactive Acknowledgement" },
+ { 0, NULL }
+};
+
+/* Routing Key Management messages */
+#define M3UA_RKM_REQ 1
+#define M3UA_RKM_RSP 2
+#define M3UA_RKM_DEREQ 3
+#define M3UA_RKM_DERSP 4
+
+static const struct tok RoutingKeyMgmtMessages[] = {
+ { M3UA_RKM_REQ, "Registration Request" },
+ { M3UA_RKM_RSP, "Registration Response" },
+ { M3UA_RKM_DEREQ, "Deregistration Request" },
+ { M3UA_RKM_DERSP, "Deregistration Response" },
+ { 0, NULL }
+};
+
+/* M3UA Parameters */
+#define M3UA_PARAM_INFO 0x0004
+#define M3UA_PARAM_ROUTING_CTX 0x0006
+#define M3UA_PARAM_DIAGNOSTIC 0x0007
+#define M3UA_PARAM_HB_DATA 0x0009
+#define M3UA_PARAM_TRAFFIC_MODE_TYPE 0x000b
+#define M3UA_PARAM_ERROR_CODE 0x000c
+#define M3UA_PARAM_STATUS 0x000d
+#define M3UA_PARAM_ASP_ID 0x0011
+#define M3UA_PARAM_AFFECTED_POINT_CODE 0x0012
+#define M3UA_PARAM_CORR_ID 0x0013
+
+#define M3UA_PARAM_NETWORK_APPEARANCE 0x0200
+#define M3UA_PARAM_USER 0x0204
+#define M3UA_PARAM_CONGESTION_INDICATION 0x0205
+#define M3UA_PARAM_CONCERNED_DST 0x0206
+#define M3UA_PARAM_ROUTING_KEY 0x0207
+#define M3UA_PARAM_REG_RESULT 0x0208
+#define M3UA_PARAM_DEREG_RESULT 0x0209
+#define M3UA_PARAM_LOCAL_ROUTING_KEY_ID 0x020a
+#define M3UA_PARAM_DST_POINT_CODE 0x020b
+#define M3UA_PARAM_SI 0x020c
+#define M3UA_PARAM_ORIGIN_POINT_CODE_LIST 0x020e
+#define M3UA_PARAM_PROTO_DATA 0x0210
+#define M3UA_PARAM_REG_STATUS 0x0212
+#define M3UA_PARAM_DEREG_STATUS 0x0213
+
+static const struct tok ParamName[] = {
+ { M3UA_PARAM_INFO, "INFO String" },
+ { M3UA_PARAM_ROUTING_CTX, "Routing Context" },
+ { M3UA_PARAM_DIAGNOSTIC, "Diagnostic Info" },
+ { M3UA_PARAM_HB_DATA, "Heartbeat Data" },
+ { M3UA_PARAM_TRAFFIC_MODE_TYPE, "Traffic Mode Type" },
+ { M3UA_PARAM_ERROR_CODE, "Error Code" },
+ { M3UA_PARAM_STATUS, "Status" },
+ { M3UA_PARAM_ASP_ID, "ASP Identifier" },
+ { M3UA_PARAM_AFFECTED_POINT_CODE, "Affected Point Code" },
+ { M3UA_PARAM_CORR_ID, "Correlation ID" },
+ { M3UA_PARAM_NETWORK_APPEARANCE, "Network Appearance" },
+ { M3UA_PARAM_USER, "User/Cause" },
+ { M3UA_PARAM_CONGESTION_INDICATION, "Congestion Indications" },
+ { M3UA_PARAM_CONCERNED_DST, "Concerned Destination" },
+ { M3UA_PARAM_ROUTING_KEY, "Routing Key" },
+ { M3UA_PARAM_REG_RESULT, "Registration Result" },
+ { M3UA_PARAM_DEREG_RESULT, "Deregistration Result" },
+ { M3UA_PARAM_LOCAL_ROUTING_KEY_ID, "Local Routing Key Identifier" },
+ { M3UA_PARAM_DST_POINT_CODE, "Destination Point Code" },
+ { M3UA_PARAM_SI, "Service Indicators" },
+ { M3UA_PARAM_ORIGIN_POINT_CODE_LIST, "Originating Point Code List" },
+ { M3UA_PARAM_PROTO_DATA, "Protocol Data" },
+ { M3UA_PARAM_REG_STATUS, "Registration Status" },
+ { M3UA_PARAM_DEREG_STATUS, "Deregistration Status" },
+ { 0, NULL }
+};
+
+static void
+tag_value_print(netdissect_options *ndo,
+ const u_char *buf, const uint16_t tag, const uint16_t size)
+{
+ switch (tag) {
+ case M3UA_PARAM_NETWORK_APPEARANCE:
+ case M3UA_PARAM_ROUTING_CTX:
+ case M3UA_PARAM_CORR_ID:
+ /* buf and size don't include the header */
+ if (size < 4)
+ goto invalid;
+ ND_TCHECK2(*buf, size);
+ ND_PRINT((ndo, "0x%08x", EXTRACT_32BITS(buf)));
+ break;
+ /* ... */
+ default:
+ ND_PRINT((ndo, "(length %u)", size + (u_int)sizeof(struct m3ua_param_header)));
+ ND_TCHECK2(*buf, size);
+ }
+ return;
+
+invalid:
+ ND_PRINT((ndo, "%s", istr));
+ ND_TCHECK2(*buf, size);
+ return;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+}
+
+/*
+ * 0 1 2 3
+ * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Parameter Tag | Parameter Length |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * \ \
+ * / Parameter Value /
+ * \ \
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+static void
+m3ua_tags_print(netdissect_options *ndo,
+ const u_char *buf, const u_int size)
+{
+ const u_char *p = buf;
+ int align;
+ uint16_t hdr_tag;
+ uint16_t hdr_len;
+
+ while (p < buf + size) {
+ if (p + sizeof(struct m3ua_param_header) > buf + size)
+ goto invalid;
+ ND_TCHECK2(*p, sizeof(struct m3ua_param_header));
+ /* Parameter Tag */
+ hdr_tag = EXTRACT_16BITS(p);
+ ND_PRINT((ndo, "\n\t\t\t%s: ", tok2str(ParamName, "Unknown Parameter (0x%04x)", hdr_tag)));
+ /* Parameter Length */
+ hdr_len = EXTRACT_16BITS(p + 2);
+ if (hdr_len < sizeof(struct m3ua_param_header))
+ goto invalid;
+ /* Parameter Value */
+ align = (p + hdr_len - buf) % 4;
+ align = align ? 4 - align : 0;
+ ND_TCHECK2(*p, hdr_len + align);
+ tag_value_print(ndo, p, hdr_tag, hdr_len - sizeof(struct m3ua_param_header));
+ p += hdr_len + align;
+ }
+ return;
+
+invalid:
+ ND_PRINT((ndo, "%s", istr));
+ ND_TCHECK2(*buf, size);
+ return;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+}
+
+/*
+ * 0 1 2 3
+ * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Version | Reserved | Message Class | Message Type |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Message Length |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * \ \
+ * / /
+ */
+void
+m3ua_print(netdissect_options *ndo,
+ const u_char *buf, const u_int size)
+{
+ const struct m3ua_common_header *hdr = (const struct m3ua_common_header *) buf;
+ const struct tok *dict;
+
+ /* size includes the header */
+ if (size < sizeof(struct m3ua_common_header))
+ goto invalid;
+ ND_TCHECK(*hdr);
+ if (hdr->v != M3UA_REL_1_0)
+ return;
+
+ dict =
+ hdr->msg_class == M3UA_MSGC_MGMT ? MgmtMessages :
+ hdr->msg_class == M3UA_MSGC_TRANSFER ? TransferMessages :
+ hdr->msg_class == M3UA_MSGC_SSNM ? SS7Messages :
+ hdr->msg_class == M3UA_MSGC_ASPSM ? ASPStateMessages :
+ hdr->msg_class == M3UA_MSGC_ASPTM ? ASPTrafficMessages :
+ hdr->msg_class == M3UA_MSGC_RKM ? RoutingKeyMgmtMessages :
+ NULL;
+
+ ND_PRINT((ndo, "\n\t\t%s", tok2str(MessageClasses, "Unknown message class %i", hdr->msg_class)));
+ if (dict != NULL)
+ ND_PRINT((ndo, " %s Message", tok2str(dict, "Unknown (0x%02x)", hdr->msg_type)));
+
+ if (size != EXTRACT_32BITS(&hdr->len))
+ ND_PRINT((ndo, "\n\t\t\t@@@@@@ Corrupted length %u of message @@@@@@", EXTRACT_32BITS(&hdr->len)));
+ else
+ m3ua_tags_print(ndo, buf + sizeof(struct m3ua_common_header), EXTRACT_32BITS(&hdr->len) - sizeof(struct m3ua_common_header));
+ return;
+
+invalid:
+ ND_PRINT((ndo, "%s", istr));
+ ND_TCHECK2(*buf, size);
+ return;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+}
+
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-m3ua-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-medsa.c b/freebsd/contrib/tcpdump/print-medsa.c
new file mode 100644
index 00000000..96ddd725
--- /dev/null
+++ b/freebsd/contrib/tcpdump/print-medsa.c
@@ -0,0 +1,204 @@
+#include <machine/rtems-bsd-user-space.h>
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
+/*
+ * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code distributions
+ * retain the above copyright notice and this paragraph in its entirety, (2)
+ * distributions including binary code include the above copyright notice and
+ * this paragraph in its entirety in the documentation or other materials
+ * provided with the distribution, and (3) all advertising materials mentioning
+ * features or use of this software display the following acknowledgement:
+ * ``This product includes software developed by the University of California,
+ * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
+ * the University 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 ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+/* \summary: Marvell Extended Distributed Switch Architecture (MEDSA) printer */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <netdissect-stdinc.h>
+
+#include "netdissect.h"
+#include "ether.h"
+#include "ethertype.h"
+#include "addrtoname.h"
+#include "extract.h"
+
+static const char tstr[] = "[|MEDSA]";
+
+/*
+ * Marvell Extended Distributed Switch Archiecture.
+ *
+ * A Marvell propriatary header used for passing packets to/from
+ * specific ports of a switch. There is no open specification of this
+ * header, but is documented in the Marvell Switch data sheets. For
+ * background, see:
+ *
+ * https://lwn.net/Articles/302333/
+ */
+struct medsa_pkthdr {
+ u_char bytes[6];
+ u_short ether_type;
+};
+
+/* Bytes 0 and 1 are reserved and should contain 0 */
+#define TAG(medsa) (medsa->bytes[2] >> 6)
+#define TAG_TO_CPU 0
+#define TAG_FROM_CPU 1
+#define TAG_FORWARD 3
+#define SRC_TAG(medsa) ((medsa->bytes[2] >> 5) & 0x01)
+#define SRC_DEV(medsa) (medsa->bytes[2] & 0x1f)
+#define SRC_PORT(medsa) ((medsa->bytes[3] >> 3) & 0x01f)
+#define TRUNK(medsa) ((medsa->bytes[3] >> 2) & 0x01)
+#define CODE(medsa) ((medsa->bytes[3] & 0x06) | \
+ ((medsa->bytes[4] >> 4) & 0x01))
+#define CODE_BDPU 0
+#define CODE_IGMP_MLD 2
+#define CODE_ARP_MIRROR 4
+#define CFI(medsa) (medsa->bytes[3] & 0x01)
+#define PRI(medsa) (medsa->bytes[4] >> 5)
+#define VID(medsa) (((u_short)(medsa->bytes[4] & 0xf) << 8 | \
+ medsa->bytes[5]))
+
+static const struct tok tag_values[] = {
+ { TAG_TO_CPU, "To_CPU" },
+ { TAG_FROM_CPU, "From_CPU" },
+ { TAG_FORWARD, "Forward" },
+ { 0, NULL },
+};
+
+static const struct tok code_values[] = {
+ { CODE_BDPU, "BDPU" },
+ { CODE_IGMP_MLD, "IGMP/MLD" },
+ { CODE_ARP_MIRROR, "APR_Mirror" },
+ { 0, NULL },
+};
+
+static void
+medsa_print_full(netdissect_options *ndo,
+ const struct medsa_pkthdr *medsa,
+ u_int caplen)
+{
+ u_char tag = TAG(medsa);
+
+ ND_PRINT((ndo, "%s",
+ tok2str(tag_values, "Unknown (%u)", tag)));
+
+ switch (tag) {
+ case TAG_TO_CPU:
+ ND_PRINT((ndo, ", %stagged", SRC_TAG(medsa) ? "" : "un"));
+ ND_PRINT((ndo, ", dev.port:vlan %d.%d:%d",
+ SRC_DEV(medsa), SRC_PORT(medsa), VID(medsa)));
+
+ ND_PRINT((ndo, ", %s",
+ tok2str(code_values, "Unknown (%u)", CODE(medsa))));
+ if (CFI(medsa))
+ ND_PRINT((ndo, ", CFI"));
+
+ ND_PRINT((ndo, ", pri %d: ", PRI(medsa)));
+ break;
+ case TAG_FROM_CPU:
+ ND_PRINT((ndo, ", %stagged", SRC_TAG(medsa) ? "" : "un"));
+ ND_PRINT((ndo, ", dev.port:vlan %d.%d:%d",
+ SRC_DEV(medsa), SRC_PORT(medsa), VID(medsa)));
+
+ if (CFI(medsa))
+ ND_PRINT((ndo, ", CFI"));
+
+ ND_PRINT((ndo, ", pri %d: ", PRI(medsa)));
+ break;
+ case TAG_FORWARD:
+ ND_PRINT((ndo, ", %stagged", SRC_TAG(medsa) ? "" : "un"));
+ if (TRUNK(medsa))
+ ND_PRINT((ndo, ", dev.trunk:vlan %d.%d:%d",
+ SRC_DEV(medsa), SRC_PORT(medsa), VID(medsa)));
+ else
+ ND_PRINT((ndo, ", dev.port:vlan %d.%d:%d",
+ SRC_DEV(medsa), SRC_PORT(medsa), VID(medsa)));
+
+ if (CFI(medsa))
+ ND_PRINT((ndo, ", CFI"));
+
+ ND_PRINT((ndo, ", pri %d: ", PRI(medsa)));
+ break;
+ default:
+ ND_DEFAULTPRINT((const u_char *)medsa, caplen);
+ return;
+ }
+}
+
+void
+medsa_print(netdissect_options *ndo,
+ const u_char *bp, u_int length, u_int caplen,
+ const struct lladdr_info *src, const struct lladdr_info *dst)
+{
+ const struct medsa_pkthdr *medsa;
+ u_short ether_type;
+
+ medsa = (const struct medsa_pkthdr *)bp;
+ ND_TCHECK(*medsa);
+
+ if (!ndo->ndo_eflag)
+ ND_PRINT((ndo, "MEDSA %d.%d:%d: ",
+ SRC_DEV(medsa), SRC_PORT(medsa), VID(medsa)));
+ else
+ medsa_print_full(ndo, medsa, caplen);
+
+ bp += 8;
+ length -= 8;
+ caplen -= 8;
+
+ ether_type = EXTRACT_16BITS(&medsa->ether_type);
+ if (ether_type <= ETHERMTU) {
+ /* Try to print the LLC-layer header & higher layers */
+ if (llc_print(ndo, bp, length, caplen, src, dst) < 0) {
+ /* packet type not known, print raw packet */
+ if (!ndo->ndo_suppress_default_print)
+ ND_DEFAULTPRINT(bp, caplen);
+ }
+ } else {
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, "ethertype %s (0x%04x) ",
+ tok2str(ethertype_values, "Unknown",
+ ether_type),
+ ether_type));
+ if (ethertype_print(ndo, ether_type, bp, length, caplen, src, dst) == 0) {
+ /* ether_type not known, print raw packet */
+ if (!ndo->ndo_eflag)
+ ND_PRINT((ndo, "ethertype %s (0x%04x) ",
+ tok2str(ethertype_values, "Unknown",
+ ether_type),
+ ether_type));
+
+ if (!ndo->ndo_suppress_default_print)
+ ND_DEFAULTPRINT(bp, caplen);
+ }
+ }
+ return;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+}
+
+/*
+ * Local Variables:
+ * c-style: bsd
+ * End:
+ */
+
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-medsa-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-mobile.c b/freebsd/contrib/tcpdump/print-mobile.c
index b13ab43d..1770abf6 100644
--- a/freebsd/contrib/tcpdump/print-mobile.c
+++ b/freebsd/contrib/tcpdump/print-mobile.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/* $NetBSD: print-mobile.c,v 1.2 1998/09/30 08:57:01 hwr Exp $ */
/*
@@ -38,30 +41,25 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
+/* \summary: IPv4 mobility printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-mobile.c,v 1.15 2004-03-24 01:58:14 guy Exp $";
-#endif
-
-#include <tcpdump-stdinc.h>
-
-#include <stdio.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
-#include "extract.h" /* must come after interface.h */
+#include "extract.h"
#define MOBILE_SIZE (8)
struct mobile_ip {
- u_int16_t proto;
- u_int16_t hcheck;
- u_int32_t odst;
- u_int32_t osrc;
+ uint16_t proto;
+ uint16_t hcheck;
+ uint32_t odst;
+ uint32_t osrc;
};
#define OSRC_PRES 0x0080 /* old source is present */
@@ -70,9 +68,8 @@ struct mobile_ip {
* Deencapsulate and print a mobile-tunneled IP datagram
*/
void
-mobile_print(const u_char *bp, u_int length)
+mobile_print(netdissect_options *ndo, const u_char *bp, u_int length)
{
- const u_char *cp = bp +8 ;
const struct mobile_ip *mob;
struct cksum_vec vec[1];
u_short proto,crc;
@@ -80,35 +77,35 @@ mobile_print(const u_char *bp, u_int length)
mob = (const struct mobile_ip *)bp;
- if (length < MOBILE_SIZE || !TTEST(*mob)) {
- fputs("[|mobile]", stdout);
+ if (length < MOBILE_SIZE || !ND_TTEST(*mob)) {
+ ND_PRINT((ndo, "[|mobile]"));
return;
}
- fputs("mobile: ", stdout);
+ ND_PRINT((ndo, "mobile: "));
proto = EXTRACT_16BITS(&mob->proto);
crc = EXTRACT_16BITS(&mob->hcheck);
if (proto & OSRC_PRES) {
osp=1;
- cp +=4 ;
}
if (osp) {
- fputs("[S] ",stdout);
- if (vflag)
- (void)printf("%s ",ipaddr_string(&mob->osrc));
+ ND_PRINT((ndo, "[S] "));
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo, "%s ", ipaddr_string(ndo, &mob->osrc)));
} else {
- fputs("[] ",stdout);
+ ND_PRINT((ndo, "[] "));
}
- if (vflag) {
- (void)printf("> %s ",ipaddr_string(&mob->odst));
- (void)printf("(oproto=%d)",proto>>8);
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo, "> %s ", ipaddr_string(ndo, &mob->odst)));
+ ND_PRINT((ndo, "(oproto=%d)", proto>>8));
}
- vec[0].ptr = (const u_int8_t *)(void *)mob;
+ vec[0].ptr = (const uint8_t *)(const void *)mob;
vec[0].len = osp ? 12 : 8;
if (in_cksum(vec, 1)!=0) {
- (void)printf(" (bad checksum %d)",crc);
+ ND_PRINT((ndo, " (bad checksum %d)", crc));
}
-
- return;
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-mobile-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-mobility.c b/freebsd/contrib/tcpdump/print-mobility.c
index 3f564e79..6db654a4 100644
--- a/freebsd/contrib/tcpdump/print-mobility.c
+++ b/freebsd/contrib/tcpdump/print-mobility.c
@@ -1,9 +1,12 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (C) 2002 WIDE Project.
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -15,7 +18,7 @@
* 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
@@ -29,36 +32,31 @@
* SUCH DAMAGE.
*/
+/* \summary: IPv6 mobility printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-mobility.c,v 1.12 2005-04-20 22:21:00 guy Exp $";
-#endif
-
-#ifdef INET6
-#include <tcpdump-stdinc.h>
-
-#include <stdio.h>
+#include <netdissect-stdinc.h>
#include "ip6.h"
-
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
-#include "extract.h" /* must come after interface.h */
+#include "extract.h"
+
+static const char tstr[] = "[|MOBILITY]";
/* Mobility header */
struct ip6_mobility {
- u_int8_t ip6m_pproto; /* following payload protocol (for PG) */
- u_int8_t ip6m_len; /* length in units of 8 octets */
- u_int8_t ip6m_type; /* message type */
- u_int8_t reserved; /* reserved */
- u_int16_t ip6m_cksum; /* sum of IPv6 pseudo-header and MH */
+ uint8_t ip6m_pproto; /* following payload protocol (for PG) */
+ uint8_t ip6m_len; /* length in units of 8 octets */
+ uint8_t ip6m_type; /* message type */
+ uint8_t reserved; /* reserved */
+ uint16_t ip6m_cksum; /* sum of IPv6 pseudo-header and MH */
union {
- u_int16_t ip6m_un_data16[1]; /* type-specific field */
- u_int8_t ip6m_un_data8[2]; /* type-specific fiedl */
+ uint16_t ip6m_un_data16[1]; /* type-specific field */
+ uint8_t ip6m_un_data8[2]; /* type-specific field */
} ip6m_dataun;
};
@@ -67,6 +65,8 @@ struct ip6_mobility {
#define IP6M_MINLEN 8
+/* http://www.iana.org/assignments/mobility-parameters/mobility-parameters.xhtml */
+
/* message type */
#define IP6M_BINDING_REQUEST 0 /* Binding Refresh Request */
#define IP6M_HOME_TEST_INIT 1 /* Home Test Init */
@@ -76,6 +76,30 @@ struct ip6_mobility {
#define IP6M_BINDING_UPDATE 5 /* Binding Update */
#define IP6M_BINDING_ACK 6 /* Binding Acknowledgement */
#define IP6M_BINDING_ERROR 7 /* Binding Error */
+#define IP6M_MAX 7
+
+static const struct tok ip6m_str[] = {
+ { IP6M_BINDING_REQUEST, "BRR" },
+ { IP6M_HOME_TEST_INIT, "HoTI" },
+ { IP6M_CAREOF_TEST_INIT, "CoTI" },
+ { IP6M_HOME_TEST, "HoT" },
+ { IP6M_CAREOF_TEST, "CoT" },
+ { IP6M_BINDING_UPDATE, "BU" },
+ { IP6M_BINDING_ACK, "BA" },
+ { IP6M_BINDING_ERROR, "BE" },
+ { 0, NULL }
+};
+
+static const unsigned ip6m_hdrlen[IP6M_MAX + 1] = {
+ IP6M_MINLEN, /* IP6M_BINDING_REQUEST */
+ IP6M_MINLEN + 8, /* IP6M_HOME_TEST_INIT */
+ IP6M_MINLEN + 8, /* IP6M_CAREOF_TEST_INIT */
+ IP6M_MINLEN + 16, /* IP6M_HOME_TEST */
+ IP6M_MINLEN + 16, /* IP6M_CAREOF_TEST */
+ IP6M_MINLEN + 4, /* IP6M_BINDING_UPDATE */
+ IP6M_MINLEN + 4, /* IP6M_BINDING_ACK */
+ IP6M_MINLEN + 16, /* IP6M_BINDING_ERROR */
+};
/* Mobility Header Options */
#define IP6MOPT_MINLEN 2
@@ -90,98 +114,104 @@ struct ip6_mobility {
#define IP6MOPT_AUTH 0x5 /* Binding Authorization Data */
#define IP6MOPT_AUTH_MINLEN 12
-static void
-mobility_opt_print(const u_char *bp, int len)
+static int
+mobility_opt_print(netdissect_options *ndo,
+ const u_char *bp, const unsigned len)
{
- int i;
- int optlen;
+ unsigned i, optlen;
for (i = 0; i < len; i += optlen) {
+ ND_TCHECK(bp[i]);
if (bp[i] == IP6MOPT_PAD1)
optlen = 1;
else {
- if (i + 1 < len)
+ if (i + 1 < len) {
+ ND_TCHECK(bp[i + 1]);
optlen = bp[i + 1] + 2;
+ }
else
goto trunc;
}
if (i + optlen > len)
goto trunc;
+ ND_TCHECK(bp[i + optlen]);
switch (bp[i]) {
case IP6MOPT_PAD1:
- printf("(pad1)");
+ ND_PRINT((ndo, "(pad1)"));
break;
case IP6MOPT_PADN:
if (len - i < IP6MOPT_MINLEN) {
- printf("(padn: trunc)");
+ ND_PRINT((ndo, "(padn: trunc)"));
goto trunc;
}
- printf("(padn)");
+ ND_PRINT((ndo, "(padn)"));
break;
case IP6MOPT_REFRESH:
if (len - i < IP6MOPT_REFRESH_MINLEN) {
- printf("(refresh: trunc)");
+ ND_PRINT((ndo, "(refresh: trunc)"));
goto trunc;
}
/* units of 4 secs */
- printf("(refresh: %d)",
- EXTRACT_16BITS(&bp[i+2]) << 2);
+ ND_PRINT((ndo, "(refresh: %u)",
+ EXTRACT_16BITS(&bp[i+2]) << 2));
break;
case IP6MOPT_ALTCOA:
if (len - i < IP6MOPT_ALTCOA_MINLEN) {
- printf("(altcoa: trunc)");
+ ND_PRINT((ndo, "(altcoa: trunc)"));
goto trunc;
}
- printf("(alt-CoA: %s)", ip6addr_string(&bp[i+2]));
+ ND_PRINT((ndo, "(alt-CoA: %s)", ip6addr_string(ndo, &bp[i+2])));
break;
case IP6MOPT_NONCEID:
if (len - i < IP6MOPT_NONCEID_MINLEN) {
- printf("(ni: trunc)");
+ ND_PRINT((ndo, "(ni: trunc)"));
goto trunc;
}
- printf("(ni: ho=0x%04x co=0x%04x)",
+ ND_PRINT((ndo, "(ni: ho=0x%04x co=0x%04x)",
EXTRACT_16BITS(&bp[i+2]),
- EXTRACT_16BITS(&bp[i+4]));
+ EXTRACT_16BITS(&bp[i+4])));
break;
case IP6MOPT_AUTH:
if (len - i < IP6MOPT_AUTH_MINLEN) {
- printf("(auth: trunc)");
+ ND_PRINT((ndo, "(auth: trunc)"));
goto trunc;
}
- printf("(auth)");
+ ND_PRINT((ndo, "(auth)"));
break;
default:
if (len - i < IP6MOPT_MINLEN) {
- printf("(sopt_type %d: trunc)", bp[i]);
+ ND_PRINT((ndo, "(sopt_type %u: trunc)", bp[i]));
goto trunc;
}
- printf("(type-0x%02x: len=%d)", bp[i], bp[i + 1]);
+ ND_PRINT((ndo, "(type-0x%02x: len=%u)", bp[i], bp[i + 1]));
break;
}
}
- return;
+ return 0;
trunc:
- printf("[trunc] ");
+ return 1;
}
/*
* Mobility Header
*/
int
-mobility_print(const u_char *bp, const u_char *bp2 _U_)
+mobility_print(netdissect_options *ndo,
+ const u_char *bp, const u_char *bp2 _U_)
{
const struct ip6_mobility *mh;
const u_char *ep;
- int mhlen, hlen, type;
+ unsigned mhlen, hlen;
+ uint8_t type;
- mh = (struct ip6_mobility *)bp;
+ mh = (const struct ip6_mobility *)bp;
/* 'ep' points to the end of available data. */
- ep = snapend;
+ ep = ndo->ndo_snapend;
- if (!TTEST(mh->ip6m_len)) {
+ if (!ND_TTEST(mh->ip6m_len)) {
/*
* There's not enough captured data to include the
* mobility header length.
@@ -197,118 +227,118 @@ mobility_print(const u_char *bp, const u_char *bp2 _U_)
mhlen = ep - bp;
goto trunc;
}
- mhlen = (int)((mh->ip6m_len + 1) << 3);
+ mhlen = (mh->ip6m_len + 1) << 3;
/* XXX ip6m_cksum */
- TCHECK(mh->ip6m_type);
+ ND_TCHECK(mh->ip6m_type);
type = mh->ip6m_type;
+ if (type <= IP6M_MAX && mhlen < ip6m_hdrlen[type]) {
+ ND_PRINT((ndo, "(header length %u is too small for type %u)", mhlen, type));
+ goto trunc;
+ }
+ ND_PRINT((ndo, "mobility: %s", tok2str(ip6m_str, "type-#%u", type)));
switch (type) {
case IP6M_BINDING_REQUEST:
- printf("mobility: BRR");
hlen = IP6M_MINLEN;
break;
case IP6M_HOME_TEST_INIT:
case IP6M_CAREOF_TEST_INIT:
- printf("mobility: %soTI",
- type == IP6M_HOME_TEST_INIT ? "H" : "C");
hlen = IP6M_MINLEN;
- if (vflag) {
- TCHECK2(*mh, hlen + 8);
- printf(" %s Init Cookie=%08x:%08x",
+ if (ndo->ndo_vflag) {
+ ND_TCHECK2(*mh, hlen + 8);
+ ND_PRINT((ndo, " %s Init Cookie=%08x:%08x",
type == IP6M_HOME_TEST_INIT ? "Home" : "Care-of",
EXTRACT_32BITS(&bp[hlen]),
- EXTRACT_32BITS(&bp[hlen + 4]));
+ EXTRACT_32BITS(&bp[hlen + 4])));
}
hlen += 8;
break;
case IP6M_HOME_TEST:
case IP6M_CAREOF_TEST:
- printf("mobility: %soT",
- type == IP6M_HOME_TEST ? "H" : "C");
- TCHECK(mh->ip6m_data16[0]);
- printf(" nonce id=0x%x", EXTRACT_16BITS(&mh->ip6m_data16[0]));
+ ND_TCHECK(mh->ip6m_data16[0]);
+ ND_PRINT((ndo, " nonce id=0x%x", EXTRACT_16BITS(&mh->ip6m_data16[0])));
hlen = IP6M_MINLEN;
- if (vflag) {
- TCHECK2(*mh, hlen + 8);
- printf(" %s Init Cookie=%08x:%08x",
+ if (ndo->ndo_vflag) {
+ ND_TCHECK2(*mh, hlen + 8);
+ ND_PRINT((ndo, " %s Init Cookie=%08x:%08x",
type == IP6M_HOME_TEST ? "Home" : "Care-of",
EXTRACT_32BITS(&bp[hlen]),
- EXTRACT_32BITS(&bp[hlen + 4]));
+ EXTRACT_32BITS(&bp[hlen + 4])));
}
hlen += 8;
- if (vflag) {
- TCHECK2(*mh, hlen + 8);
- printf(" %s Keygen Token=%08x:%08x",
+ if (ndo->ndo_vflag) {
+ ND_TCHECK2(*mh, hlen + 8);
+ ND_PRINT((ndo, " %s Keygen Token=%08x:%08x",
type == IP6M_HOME_TEST ? "Home" : "Care-of",
EXTRACT_32BITS(&bp[hlen]),
- EXTRACT_32BITS(&bp[hlen + 4]));
+ EXTRACT_32BITS(&bp[hlen + 4])));
}
hlen += 8;
break;
case IP6M_BINDING_UPDATE:
- printf("mobility: BU");
- TCHECK(mh->ip6m_data16[0]);
- printf(" seq#=%d", EXTRACT_16BITS(&mh->ip6m_data16[0]));
+ ND_TCHECK(mh->ip6m_data16[0]);
+ ND_PRINT((ndo, " seq#=%u", EXTRACT_16BITS(&mh->ip6m_data16[0])));
hlen = IP6M_MINLEN;
- TCHECK2(*mh, hlen + 1);
+ ND_TCHECK2(*mh, hlen + 1);
if (bp[hlen] & 0xf0)
- printf(" ");
+ ND_PRINT((ndo, " "));
if (bp[hlen] & 0x80)
- printf("A");
+ ND_PRINT((ndo, "A"));
if (bp[hlen] & 0x40)
- printf("H");
+ ND_PRINT((ndo, "H"));
if (bp[hlen] & 0x20)
- printf("L");
+ ND_PRINT((ndo, "L"));
if (bp[hlen] & 0x10)
- printf("K");
+ ND_PRINT((ndo, "K"));
/* Reserved (4bits) */
hlen += 1;
/* Reserved (8bits) */
hlen += 1;
- TCHECK2(*mh, hlen + 2);
+ ND_TCHECK2(*mh, hlen + 2);
/* units of 4 secs */
- printf(" lifetime=%d", EXTRACT_16BITS(&bp[hlen]) << 2);
+ ND_PRINT((ndo, " lifetime=%u", EXTRACT_16BITS(&bp[hlen]) << 2));
hlen += 2;
break;
case IP6M_BINDING_ACK:
- printf("mobility: BA");
- TCHECK(mh->ip6m_data8[0]);
- printf(" status=%d", mh->ip6m_data8[0]);
+ ND_TCHECK(mh->ip6m_data8[0]);
+ ND_PRINT((ndo, " status=%u", mh->ip6m_data8[0]));
if (mh->ip6m_data8[1] & 0x80)
- printf(" K");
+ ND_PRINT((ndo, " K"));
/* Reserved (7bits) */
hlen = IP6M_MINLEN;
- TCHECK2(*mh, hlen + 2);
- printf(" seq#=%d", EXTRACT_16BITS(&bp[hlen]));
+ ND_TCHECK2(*mh, hlen + 2);
+ ND_PRINT((ndo, " seq#=%u", EXTRACT_16BITS(&bp[hlen])));
hlen += 2;
- TCHECK2(*mh, hlen + 2);
+ ND_TCHECK2(*mh, hlen + 2);
/* units of 4 secs */
- printf(" lifetime=%d", EXTRACT_16BITS(&bp[hlen]) << 2);
+ ND_PRINT((ndo, " lifetime=%u", EXTRACT_16BITS(&bp[hlen]) << 2));
hlen += 2;
break;
case IP6M_BINDING_ERROR:
- printf("mobility: BE");
- TCHECK(mh->ip6m_data8[0]);
- printf(" status=%d", mh->ip6m_data8[0]);
+ ND_TCHECK(mh->ip6m_data8[0]);
+ ND_PRINT((ndo, " status=%u", mh->ip6m_data8[0]));
/* Reserved */
hlen = IP6M_MINLEN;
- TCHECK2(*mh, hlen + 16);
- printf(" homeaddr %s", ip6addr_string(&bp[hlen]));
+ ND_TCHECK2(*mh, hlen + 16);
+ ND_PRINT((ndo, " homeaddr %s", ip6addr_string(ndo, &bp[hlen])));
hlen += 16;
break;
default:
- printf("mobility: type-#%d len=%d", type, mh->ip6m_len);
+ ND_PRINT((ndo, " len=%u", mh->ip6m_len));
return(mhlen);
break;
}
- if (vflag)
- mobility_opt_print(&bp[hlen], mhlen - hlen);
+ if (ndo->ndo_vflag)
+ if (mobility_opt_print(ndo, &bp[hlen], mhlen - hlen))
+ goto trunc;;
return(mhlen);
trunc:
- fputs("[|MOBILITY]", stdout);
+ ND_PRINT((ndo, "%s", tstr));
return(mhlen);
}
-#endif /* INET6 */
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-mobility-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-mpcp.c b/freebsd/contrib/tcpdump/print-mpcp.c
index f9ea1683..0cabd860 100644
--- a/freebsd/contrib/tcpdump/print-mpcp.c
+++ b/freebsd/contrib/tcpdump/print-mpcp.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1998-2006 The TCPDUMP project
*
@@ -14,37 +17,26 @@
* LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE.
*
- * support for the IEEE MPCP protocol as per 802.3ah
- *
* Original code by Hannes Gredler (hannes@juniper.net)
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-mpcp.c,v 1.2 2006-02-10 17:24:55 hannes Exp $";
-#endif
+/* \summary: IEEE 802.3ah Multi-Point Control Protocol (MPCP) printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
-#include "addrtoname.h"
-#include "ether.h"
#define MPCP_TIMESTAMP_LEN 4
#define MPCP_TIMESTAMP_DURATION_LEN 2
struct mpcp_common_header_t {
- u_int8_t opcode[2];
- u_int8_t timestamp[MPCP_TIMESTAMP_LEN];
+ uint8_t opcode[2];
+ uint8_t timestamp[MPCP_TIMESTAMP_LEN];
};
#define MPCP_OPCODE_PAUSE 0x0001
@@ -65,7 +57,7 @@ static const struct tok mpcp_opcode_values[] = {
};
#define MPCP_GRANT_NUMBER_LEN 1
-#define MPCP_GRANT_NUMBER_MASK 0x7
+#define MPCP_GRANT_NUMBER_MASK 0x7
static const struct tok mpcp_grant_flag_values[] = {
{ 0x08, "Discovery" },
{ 0x10, "Force Grant #1" },
@@ -76,13 +68,13 @@ static const struct tok mpcp_grant_flag_values[] = {
};
struct mpcp_grant_t {
- u_int8_t starttime[MPCP_TIMESTAMP_LEN];
- u_int8_t duration[MPCP_TIMESTAMP_DURATION_LEN];
+ uint8_t starttime[MPCP_TIMESTAMP_LEN];
+ uint8_t duration[MPCP_TIMESTAMP_DURATION_LEN];
};
struct mpcp_reg_req_t {
- u_int8_t flags;
- u_int8_t pending_grants;
+ uint8_t flags;
+ uint8_t pending_grants;
};
@@ -93,10 +85,10 @@ static const struct tok mpcp_reg_req_flag_values[] = {
};
struct mpcp_reg_t {
- u_int8_t assigned_port[2];
- u_int8_t flags;
- u_int8_t sync_time[MPCP_TIMESTAMP_DURATION_LEN];
- u_int8_t echoed_pending_grants;
+ uint8_t assigned_port[2];
+ uint8_t flags;
+ uint8_t sync_time[MPCP_TIMESTAMP_DURATION_LEN];
+ uint8_t echoed_pending_grants;
};
static const struct tok mpcp_reg_flag_values[] = {
@@ -122,9 +114,9 @@ static const struct tok mpcp_report_bitmap_values[] = {
};
struct mpcp_reg_ack_t {
- u_int8_t flags;
- u_int8_t echoed_assigned_port[2];
- u_int8_t echoed_sync_time[MPCP_TIMESTAMP_DURATION_LEN];
+ uint8_t flags;
+ uint8_t echoed_assigned_port[2];
+ uint8_t echoed_sync_time[MPCP_TIMESTAMP_DURATION_LEN];
};
static const struct tok mpcp_reg_ack_flag_values[] = {
@@ -134,8 +126,8 @@ static const struct tok mpcp_reg_ack_flag_values[] = {
};
void
-mpcp_print(register const u_char *pptr, register u_int length) {
-
+mpcp_print(netdissect_options *ndo, register const u_char *pptr, register u_int length)
+{
union {
const struct mpcp_common_header_t *common_header;
const struct mpcp_grant_t *grant;
@@ -146,23 +138,22 @@ mpcp_print(register const u_char *pptr, register u_int length) {
const u_char *tptr;
- u_int16_t opcode;
- u_int8_t grant_numbers, grant;
- u_int8_t queue_sets, queue_set, report_bitmap, report;
+ uint16_t opcode;
+ uint8_t grant_numbers, grant;
+ uint8_t queue_sets, queue_set, report_bitmap, report;
tptr=pptr;
mpcp.common_header = (const struct mpcp_common_header_t *)pptr;
- if (!TTEST2(*tptr, sizeof(const struct mpcp_common_header_t)))
- goto trunc;
+ ND_TCHECK2(*tptr, sizeof(const struct mpcp_common_header_t));
opcode = EXTRACT_16BITS(mpcp.common_header->opcode);
- printf("MPCP, Opcode %s", tok2str(mpcp_opcode_values, "Unknown (%u)", opcode));
+ ND_PRINT((ndo, "MPCP, Opcode %s", tok2str(mpcp_opcode_values, "Unknown (%u)", opcode)));
if (opcode != MPCP_OPCODE_PAUSE) {
- printf(", Timestamp %u ticks", EXTRACT_32BITS(mpcp.common_header->timestamp));
+ ND_PRINT((ndo, ", Timestamp %u ticks", EXTRACT_32BITS(mpcp.common_header->timestamp)));
}
- printf(", length %u", length);
+ ND_PRINT((ndo, ", length %u", length));
- if (!vflag)
+ if (!ndo->ndo_vflag)
return;
tptr += sizeof(const struct mpcp_common_header_t);
@@ -172,57 +163,51 @@ mpcp_print(register const u_char *pptr, register u_int length) {
break;
case MPCP_OPCODE_GATE:
- if (!TTEST2(*tptr, MPCP_GRANT_NUMBER_LEN))
- goto trunc;
+ ND_TCHECK2(*tptr, MPCP_GRANT_NUMBER_LEN);
grant_numbers = *tptr & MPCP_GRANT_NUMBER_MASK;
- printf("\n\tGrant Numbers %u, Flags [ %s ]",
+ ND_PRINT((ndo, "\n\tGrant Numbers %u, Flags [ %s ]",
grant_numbers,
bittok2str(mpcp_grant_flag_values,
"?",
- *tptr &~ MPCP_GRANT_NUMBER_MASK));
+ *tptr &~ MPCP_GRANT_NUMBER_MASK)));
tptr++;
for (grant = 1; grant <= grant_numbers; grant++) {
- if (!TTEST2(*tptr, sizeof(const struct mpcp_grant_t)))
- goto trunc;
- mpcp.grant = (const struct mpcp_grant_t *)tptr;
- printf("\n\tGrant #%u, Start-Time %u ticks, duration %u ticks",
+ ND_TCHECK2(*tptr, sizeof(const struct mpcp_grant_t));
+ mpcp.grant = (const struct mpcp_grant_t *)tptr;
+ ND_PRINT((ndo, "\n\tGrant #%u, Start-Time %u ticks, duration %u ticks",
grant,
EXTRACT_32BITS(mpcp.grant->starttime),
- EXTRACT_16BITS(mpcp.grant->duration));
+ EXTRACT_16BITS(mpcp.grant->duration)));
tptr += sizeof(const struct mpcp_grant_t);
}
- if (!TTEST2(*tptr, MPCP_TIMESTAMP_DURATION_LEN))
- goto trunc;
- printf("\n\tSync-Time %u ticks", EXTRACT_16BITS(tptr));
+ ND_TCHECK2(*tptr, MPCP_TIMESTAMP_DURATION_LEN);
+ ND_PRINT((ndo, "\n\tSync-Time %u ticks", EXTRACT_16BITS(tptr)));
break;
case MPCP_OPCODE_REPORT:
- if (!TTEST2(*tptr, MPCP_REPORT_QUEUESETS_LEN))
- goto trunc;
+ ND_TCHECK2(*tptr, MPCP_REPORT_QUEUESETS_LEN);
queue_sets = *tptr;
tptr+=MPCP_REPORT_QUEUESETS_LEN;
- printf("\n\tTotal Queue-Sets %u", queue_sets);
+ ND_PRINT((ndo, "\n\tTotal Queue-Sets %u", queue_sets));
for (queue_set = 1; queue_set < queue_sets; queue_set++) {
- if (!TTEST2(*tptr, MPCP_REPORT_REPORTBITMAP_LEN))
- goto trunc;
+ ND_TCHECK2(*tptr, MPCP_REPORT_REPORTBITMAP_LEN);
report_bitmap = *(tptr);
- printf("\n\t Queue-Set #%u, Report-Bitmap [ %s ]",
+ ND_PRINT((ndo, "\n\t Queue-Set #%u, Report-Bitmap [ %s ]",
queue_sets,
- bittok2str(mpcp_report_bitmap_values, "Unknown", report_bitmap));
+ bittok2str(mpcp_report_bitmap_values, "Unknown", report_bitmap)));
tptr++;
report=1;
- while (report_bitmap != 0) {
+ while (report_bitmap != 0) {
if (report_bitmap & 1) {
- if (!TTEST2(*tptr, MPCP_TIMESTAMP_DURATION_LEN))
- goto trunc;
- printf("\n\t Q%u Report, Duration %u ticks",
+ ND_TCHECK2(*tptr, MPCP_TIMESTAMP_DURATION_LEN);
+ ND_PRINT((ndo, "\n\t Q%u Report, Duration %u ticks",
report,
- EXTRACT_16BITS(tptr));
+ EXTRACT_16BITS(tptr)));
tptr+=MPCP_TIMESTAMP_DURATION_LEN;
}
report++;
@@ -232,45 +217,51 @@ mpcp_print(register const u_char *pptr, register u_int length) {
break;
case MPCP_OPCODE_REG_REQ:
- if (!TTEST2(*tptr, sizeof(const struct mpcp_reg_req_t)))
- goto trunc;
- mpcp.reg_req = (const struct mpcp_reg_req_t *)tptr;
- printf("\n\tFlags [ %s ], Pending-Grants %u",
+ ND_TCHECK2(*tptr, sizeof(const struct mpcp_reg_req_t));
+ mpcp.reg_req = (const struct mpcp_reg_req_t *)tptr;
+ ND_PRINT((ndo, "\n\tFlags [ %s ], Pending-Grants %u",
bittok2str(mpcp_reg_req_flag_values, "Reserved", mpcp.reg_req->flags),
- mpcp.reg_req->pending_grants);
+ mpcp.reg_req->pending_grants));
break;
case MPCP_OPCODE_REG:
- if (!TTEST2(*tptr, sizeof(const struct mpcp_reg_t)))
- goto trunc;
- mpcp.reg = (const struct mpcp_reg_t *)tptr;
- printf("\n\tAssigned-Port %u, Flags [ %s ]" \
+ ND_TCHECK2(*tptr, sizeof(const struct mpcp_reg_t));
+ mpcp.reg = (const struct mpcp_reg_t *)tptr;
+ ND_PRINT((ndo, "\n\tAssigned-Port %u, Flags [ %s ]" \
"\n\tSync-Time %u ticks, Echoed-Pending-Grants %u",
EXTRACT_16BITS(mpcp.reg->assigned_port),
bittok2str(mpcp_reg_flag_values, "Reserved", mpcp.reg->flags),
EXTRACT_16BITS(mpcp.reg->sync_time),
- mpcp.reg->echoed_pending_grants);
+ mpcp.reg->echoed_pending_grants));
break;
case MPCP_OPCODE_REG_ACK:
- if (!TTEST2(*tptr, sizeof(const struct mpcp_reg_ack_t)))
- goto trunc;
- mpcp.reg_ack = (const struct mpcp_reg_ack_t *)tptr;
- printf("\n\tEchoed-Assigned-Port %u, Flags [ %s ]" \
+ ND_TCHECK2(*tptr, sizeof(const struct mpcp_reg_ack_t));
+ mpcp.reg_ack = (const struct mpcp_reg_ack_t *)tptr;
+ ND_PRINT((ndo, "\n\tEchoed-Assigned-Port %u, Flags [ %s ]" \
"\n\tEchoed-Sync-Time %u ticks",
EXTRACT_16BITS(mpcp.reg_ack->echoed_assigned_port),
bittok2str(mpcp_reg_ack_flag_values, "Reserved", mpcp.reg_ack->flags),
- EXTRACT_16BITS(mpcp.reg_ack->echoed_sync_time));
+ EXTRACT_16BITS(mpcp.reg_ack->echoed_sync_time)));
break;
default:
/* unknown opcode - hexdump for now */
- print_unknown_data(pptr, "\n\t", length);
+ print_unknown_data(ndo,pptr, "\n\t", length);
break;
}
return;
trunc:
- printf("\n\t[|MPCP]");
+ ND_PRINT((ndo, "\n\t[|MPCP]"));
}
+/*
+ * Local Variables:
+ * c-style: whitesmith
+ * c-basic-offset: 8
+ * End:
+ */
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-mpcp-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-mpls.c b/freebsd/contrib/tcpdump/print-mpls.c
index 3a755f77..07fdbe54 100644
--- a/freebsd/contrib/tcpdump/print-mpls.c
+++ b/freebsd/contrib/tcpdump/print-mpls.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (C) 2001 WIDE Project. All rights reserved.
*
@@ -28,24 +31,16 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-mpls.c,v 1.14 2005-07-05 09:38:19 hannes Exp $ (LBL)";
-#endif
+/* \summary: Multi-Protocol Label Switching (MPLS) printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "addrtoname.h"
-#include "interface.h"
-#include "extract.h" /* must come after interface.h */
+#include "netdissect.h"
+#include "extract.h"
#include "mpls.h"
static const char *mpls_labelname[] = {
@@ -67,31 +62,36 @@ enum mpls_packet_type {
* RFC3032: MPLS label stack encoding
*/
void
-mpls_print(const u_char *bp, u_int length)
+mpls_print(netdissect_options *ndo, const u_char *bp, u_int length)
{
const u_char *p;
- u_int32_t label_entry;
- u_int16_t label_stack_depth = 0;
+ uint32_t label_entry;
+ uint16_t label_stack_depth = 0;
enum mpls_packet_type pt = PT_UNKNOWN;
p = bp;
- printf("MPLS");
+ ND_PRINT((ndo, "MPLS"));
do {
- TCHECK2(*p, sizeof(label_entry));
+ ND_TCHECK2(*p, sizeof(label_entry));
+ if (length < sizeof(label_entry)) {
+ ND_PRINT((ndo, "[|MPLS], length %u", length));
+ return;
+ }
label_entry = EXTRACT_32BITS(p);
- printf("%s(label %u",
- (label_stack_depth && vflag) ? "\n\t" : " ",
- MPLS_LABEL(label_entry));
+ ND_PRINT((ndo, "%s(label %u",
+ (label_stack_depth && ndo->ndo_vflag) ? "\n\t" : " ",
+ MPLS_LABEL(label_entry)));
label_stack_depth++;
- if (vflag &&
+ if (ndo->ndo_vflag &&
MPLS_LABEL(label_entry) < sizeof(mpls_labelname) / sizeof(mpls_labelname[0]))
- printf(" (%s)", mpls_labelname[MPLS_LABEL(label_entry)]);
- printf(", exp %u", MPLS_EXP(label_entry));
+ ND_PRINT((ndo, " (%s)", mpls_labelname[MPLS_LABEL(label_entry)]));
+ ND_PRINT((ndo, ", exp %u", MPLS_EXP(label_entry)));
if (MPLS_STACK(label_entry))
- printf(", [S]");
- printf(", ttl %u)", MPLS_TTL(label_entry));
+ ND_PRINT((ndo, ", [S]"));
+ ND_PRINT((ndo, ", ttl %u)", MPLS_TTL(label_entry)));
p += sizeof(label_entry);
+ length -= sizeof(label_entry);
} while (!MPLS_STACK(label_entry));
/*
@@ -134,6 +134,11 @@ mpls_print(const u_char *bp, u_int length)
* Cisco sends control-plane traffic MPLS-encapsulated in
* this fashion.
*/
+ ND_TCHECK(*p);
+ if (length < 1) {
+ /* nothing to print */
+ return;
+ }
switch(*p) {
case 0x45:
@@ -149,7 +154,7 @@ mpls_print(const u_char *bp, u_int length)
case 0x4f:
pt = PT_IPV4;
break;
-
+
case 0x60:
case 0x61:
case 0x62:
@@ -185,30 +190,23 @@ mpls_print(const u_char *bp, u_int length)
* Print the payload.
*/
if (pt == PT_UNKNOWN) {
- if (!suppress_default_print)
- default_print(p, length - (p - bp));
+ if (!ndo->ndo_suppress_default_print)
+ ND_DEFAULTPRINT(p, length);
return;
}
- if (vflag)
- printf("\n\t");
- else
- printf(" ");
+ ND_PRINT((ndo, ndo->ndo_vflag ? "\n\t" : " "));
switch (pt) {
case PT_IPV4:
- ip_print(gndo, p, length - (p - bp));
+ ip_print(ndo, p, length);
break;
case PT_IPV6:
-#ifdef INET6
- ip6_print(gndo, p, length - (p - bp));
-#else
- printf("IPv6, length: %u", length);
-#endif
+ ip6_print(ndo, p, length);
break;
case PT_OSI:
- isoclns_print(p, length - (p - bp), length - (p - bp));
+ isoclns_print(ndo, p, length, length);
break;
default:
@@ -217,7 +215,7 @@ mpls_print(const u_char *bp, u_int length)
return;
trunc:
- printf("[|MPLS]");
+ ND_PRINT((ndo, "[|MPLS]"));
}
@@ -227,3 +225,6 @@ trunc:
* c-basic-offset: 8
* End:
*/
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-mpls-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-mptcp.c b/freebsd/contrib/tcpdump/print-mptcp.c
new file mode 100644
index 00000000..eaa4aa20
--- /dev/null
+++ b/freebsd/contrib/tcpdump/print-mptcp.c
@@ -0,0 +1,438 @@
+#include <machine/rtems-bsd-user-space.h>
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
+/**
+ * Copyright (c) 2012
+ *
+ * Gregory Detal <gregory.detal@uclouvain.be>
+ * Christoph Paasch <christoph.paasch@uclouvain.be>
+ *
+ * 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 University nor of the Laboratory may be used
+ * to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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: Multipath TCP (MPTCP) printer */
+
+/* specification: RFC 6824 */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <netdissect-stdinc.h>
+
+#include "netdissect.h"
+#include "extract.h"
+#include "addrtoname.h"
+
+#include "tcp.h"
+
+#define MPTCP_SUB_CAPABLE 0x0
+#define MPTCP_SUB_JOIN 0x1
+#define MPTCP_SUB_DSS 0x2
+#define MPTCP_SUB_ADD_ADDR 0x3
+#define MPTCP_SUB_REMOVE_ADDR 0x4
+#define MPTCP_SUB_PRIO 0x5
+#define MPTCP_SUB_FAIL 0x6
+#define MPTCP_SUB_FCLOSE 0x7
+
+struct mptcp_option {
+ uint8_t kind;
+ uint8_t len;
+ uint8_t sub_etc; /* subtype upper 4 bits, other stuff lower 4 bits */
+};
+
+#define MPTCP_OPT_SUBTYPE(sub_etc) (((sub_etc) >> 4) & 0xF)
+
+struct mp_capable {
+ uint8_t kind;
+ uint8_t len;
+ uint8_t sub_ver;
+ uint8_t flags;
+ uint8_t sender_key[8];
+ uint8_t receiver_key[8];
+};
+
+#define MP_CAPABLE_OPT_VERSION(sub_ver) (((sub_ver) >> 0) & 0xF)
+#define MP_CAPABLE_C 0x80
+#define MP_CAPABLE_S 0x01
+
+struct mp_join {
+ uint8_t kind;
+ uint8_t len;
+ uint8_t sub_b;
+ uint8_t addr_id;
+ union {
+ struct {
+ uint8_t token[4];
+ uint8_t nonce[4];
+ } syn;
+ struct {
+ uint8_t mac[8];
+ uint8_t nonce[4];
+ } synack;
+ struct {
+ uint8_t mac[20];
+ } ack;
+ } u;
+};
+
+#define MP_JOIN_B 0x01
+
+struct mp_dss {
+ uint8_t kind;
+ uint8_t len;
+ uint8_t sub;
+ uint8_t flags;
+};
+
+#define MP_DSS_F 0x10
+#define MP_DSS_m 0x08
+#define MP_DSS_M 0x04
+#define MP_DSS_a 0x02
+#define MP_DSS_A 0x01
+
+struct mp_add_addr {
+ uint8_t kind;
+ uint8_t len;
+ uint8_t sub_ipver;
+ uint8_t addr_id;
+ union {
+ struct {
+ uint8_t addr[4];
+ uint8_t port[2];
+ } v4;
+ struct {
+ uint8_t addr[16];
+ uint8_t port[2];
+ } v6;
+ } u;
+};
+
+#define MP_ADD_ADDR_IPVER(sub_ipver) (((sub_ipver) >> 0) & 0xF)
+
+struct mp_remove_addr {
+ uint8_t kind;
+ uint8_t len;
+ uint8_t sub;
+ /* list of addr_id */
+ uint8_t addrs_id;
+};
+
+struct mp_fail {
+ uint8_t kind;
+ uint8_t len;
+ uint8_t sub;
+ uint8_t resv;
+ uint8_t data_seq[8];
+};
+
+struct mp_close {
+ uint8_t kind;
+ uint8_t len;
+ uint8_t sub;
+ uint8_t rsv;
+ uint8_t key[8];
+};
+
+struct mp_prio {
+ uint8_t kind;
+ uint8_t len;
+ uint8_t sub_b;
+ uint8_t addr_id;
+};
+
+#define MP_PRIO_B 0x01
+
+static int
+dummy_print(netdissect_options *ndo _U_,
+ const u_char *opt _U_, u_int opt_len _U_, u_char flags _U_)
+{
+ return 1;
+}
+
+static int
+mp_capable_print(netdissect_options *ndo,
+ const u_char *opt, u_int opt_len, u_char flags)
+{
+ const struct mp_capable *mpc = (const struct mp_capable *) opt;
+
+ if (!(opt_len == 12 && flags & TH_SYN) &&
+ !(opt_len == 20 && (flags & (TH_SYN | TH_ACK)) == TH_ACK))
+ return 0;
+
+ if (MP_CAPABLE_OPT_VERSION(mpc->sub_ver) != 0) {
+ ND_PRINT((ndo, " Unknown Version (%d)", MP_CAPABLE_OPT_VERSION(mpc->sub_ver)));
+ return 1;
+ }
+
+ if (mpc->flags & MP_CAPABLE_C)
+ ND_PRINT((ndo, " csum"));
+ ND_PRINT((ndo, " {0x%" PRIx64, EXTRACT_64BITS(mpc->sender_key)));
+ if (opt_len == 20) /* ACK */
+ ND_PRINT((ndo, ",0x%" PRIx64, EXTRACT_64BITS(mpc->receiver_key)));
+ ND_PRINT((ndo, "}"));
+ return 1;
+}
+
+static int
+mp_join_print(netdissect_options *ndo,
+ const u_char *opt, u_int opt_len, u_char flags)
+{
+ const struct mp_join *mpj = (const struct mp_join *) opt;
+
+ if (!(opt_len == 12 && flags & TH_SYN) &&
+ !(opt_len == 16 && (flags & (TH_SYN | TH_ACK)) == (TH_SYN | TH_ACK)) &&
+ !(opt_len == 24 && flags & TH_ACK))
+ return 0;
+
+ if (opt_len != 24) {
+ if (mpj->sub_b & MP_JOIN_B)
+ ND_PRINT((ndo, " backup"));
+ ND_PRINT((ndo, " id %u", mpj->addr_id));
+ }
+
+ switch (opt_len) {
+ case 12: /* SYN */
+ ND_PRINT((ndo, " token 0x%x" " nonce 0x%x",
+ EXTRACT_32BITS(mpj->u.syn.token),
+ EXTRACT_32BITS(mpj->u.syn.nonce)));
+ break;
+ case 16: /* SYN/ACK */
+ ND_PRINT((ndo, " hmac 0x%" PRIx64 " nonce 0x%x",
+ EXTRACT_64BITS(mpj->u.synack.mac),
+ EXTRACT_32BITS(mpj->u.synack.nonce)));
+ break;
+ case 24: {/* ACK */
+ size_t i;
+ ND_PRINT((ndo, " hmac 0x"));
+ for (i = 0; i < sizeof(mpj->u.ack.mac); ++i)
+ ND_PRINT((ndo, "%02x", mpj->u.ack.mac[i]));
+ }
+ default:
+ break;
+ }
+ return 1;
+}
+
+static u_int mp_dss_len(const struct mp_dss *m, int csum)
+{
+ u_int len;
+
+ len = 4;
+ if (m->flags & MP_DSS_A) {
+ /* Ack present - 4 or 8 octets */
+ len += (m->flags & MP_DSS_a) ? 8 : 4;
+ }
+ if (m->flags & MP_DSS_M) {
+ /*
+ * Data Sequence Number (DSN), Subflow Sequence Number (SSN),
+ * Data-Level Length present, and Checksum possibly present.
+ * All but the Checksum are 10 bytes if the m flag is
+ * clear (4-byte DSN) and 14 bytes if the m flag is set
+ * (8-byte DSN).
+ */
+ len += (m->flags & MP_DSS_m) ? 14 : 10;
+
+ /*
+ * The Checksum is present only if negotiated.
+ */
+ if (csum)
+ len += 2;
+ }
+ return len;
+}
+
+static int
+mp_dss_print(netdissect_options *ndo,
+ const u_char *opt, u_int opt_len, u_char flags)
+{
+ const struct mp_dss *mdss = (const struct mp_dss *) opt;
+
+ if ((opt_len != mp_dss_len(mdss, 1) &&
+ opt_len != mp_dss_len(mdss, 0)) || flags & TH_SYN)
+ return 0;
+
+ if (mdss->flags & MP_DSS_F)
+ ND_PRINT((ndo, " fin"));
+
+ opt += 4;
+ if (mdss->flags & MP_DSS_A) {
+ ND_PRINT((ndo, " ack "));
+ if (mdss->flags & MP_DSS_a) {
+ ND_PRINT((ndo, "%" PRIu64, EXTRACT_64BITS(opt)));
+ opt += 8;
+ } else {
+ ND_PRINT((ndo, "%u", EXTRACT_32BITS(opt)));
+ opt += 4;
+ }
+ }
+
+ if (mdss->flags & MP_DSS_M) {
+ ND_PRINT((ndo, " seq "));
+ if (mdss->flags & MP_DSS_m) {
+ ND_PRINT((ndo, "%" PRIu64, EXTRACT_64BITS(opt)));
+ opt += 8;
+ } else {
+ ND_PRINT((ndo, "%u", EXTRACT_32BITS(opt)));
+ opt += 4;
+ }
+ ND_PRINT((ndo, " subseq %u", EXTRACT_32BITS(opt)));
+ opt += 4;
+ ND_PRINT((ndo, " len %u", EXTRACT_16BITS(opt)));
+ opt += 2;
+
+ if (opt_len == mp_dss_len(mdss, 1))
+ ND_PRINT((ndo, " csum 0x%x", EXTRACT_16BITS(opt)));
+ }
+ return 1;
+}
+
+static int
+add_addr_print(netdissect_options *ndo,
+ const u_char *opt, u_int opt_len, u_char flags _U_)
+{
+ const struct mp_add_addr *add_addr = (const struct mp_add_addr *) opt;
+ u_int ipver = MP_ADD_ADDR_IPVER(add_addr->sub_ipver);
+
+ if (!((opt_len == 8 || opt_len == 10) && ipver == 4) &&
+ !((opt_len == 20 || opt_len == 22) && ipver == 6))
+ return 0;
+
+ ND_PRINT((ndo, " id %u", add_addr->addr_id));
+ switch (ipver) {
+ case 4:
+ ND_PRINT((ndo, " %s", ipaddr_string(ndo, add_addr->u.v4.addr)));
+ if (opt_len == 10)
+ ND_PRINT((ndo, ":%u", EXTRACT_16BITS(add_addr->u.v4.port)));
+ break;
+ case 6:
+ ND_PRINT((ndo, " %s", ip6addr_string(ndo, add_addr->u.v6.addr)));
+ if (opt_len == 22)
+ ND_PRINT((ndo, ":%u", EXTRACT_16BITS(add_addr->u.v6.port)));
+ break;
+ default:
+ return 0;
+ }
+
+ return 1;
+}
+
+static int
+remove_addr_print(netdissect_options *ndo,
+ const u_char *opt, u_int opt_len, u_char flags _U_)
+{
+ const struct mp_remove_addr *remove_addr = (const struct mp_remove_addr *) opt;
+ const uint8_t *addr_id = &remove_addr->addrs_id;
+
+ if (opt_len < 4)
+ return 0;
+
+ opt_len -= 3;
+ ND_PRINT((ndo, " id"));
+ while (opt_len--)
+ ND_PRINT((ndo, " %u", *addr_id++));
+ return 1;
+}
+
+static int
+mp_prio_print(netdissect_options *ndo,
+ const u_char *opt, u_int opt_len, u_char flags _U_)
+{
+ const struct mp_prio *mpp = (const struct mp_prio *) opt;
+
+ if (opt_len != 3 && opt_len != 4)
+ return 0;
+
+ if (mpp->sub_b & MP_PRIO_B)
+ ND_PRINT((ndo, " backup"));
+ else
+ ND_PRINT((ndo, " non-backup"));
+ if (opt_len == 4)
+ ND_PRINT((ndo, " id %u", mpp->addr_id));
+
+ return 1;
+}
+
+static int
+mp_fail_print(netdissect_options *ndo,
+ const u_char *opt, u_int opt_len, u_char flags _U_)
+{
+ if (opt_len != 12)
+ return 0;
+
+ ND_PRINT((ndo, " seq %" PRIu64, EXTRACT_64BITS(opt + 4)));
+ return 1;
+}
+
+static int
+mp_fast_close_print(netdissect_options *ndo,
+ const u_char *opt, u_int opt_len, u_char flags _U_)
+{
+ if (opt_len != 12)
+ return 0;
+
+ ND_PRINT((ndo, " key 0x%" PRIx64, EXTRACT_64BITS(opt + 4)));
+ return 1;
+}
+
+static const struct {
+ const char *name;
+ int (*print)(netdissect_options *, const u_char *, u_int, u_char);
+} mptcp_options[] = {
+ { "capable", mp_capable_print},
+ { "join", mp_join_print },
+ { "dss", mp_dss_print },
+ { "add-addr", add_addr_print },
+ { "rem-addr", remove_addr_print },
+ { "prio", mp_prio_print },
+ { "fail", mp_fail_print },
+ { "fast-close", mp_fast_close_print },
+ { "unknown", dummy_print },
+};
+
+int
+mptcp_print(netdissect_options *ndo,
+ const u_char *cp, u_int len, u_char flags)
+{
+ const struct mptcp_option *opt;
+ u_int subtype;
+
+ if (len < 3)
+ return 0;
+
+ opt = (const struct mptcp_option *) cp;
+ subtype = min(MPTCP_OPT_SUBTYPE(opt->sub_etc), MPTCP_SUB_FCLOSE + 1);
+
+ ND_PRINT((ndo, " %s", mptcp_options[subtype].name));
+ return mptcp_options[subtype].print(ndo, cp, len, flags);
+}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-mptcp-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-msdp.c b/freebsd/contrib/tcpdump/print-msdp.c
index 6269c2c2..457c2d19 100644
--- a/freebsd/contrib/tcpdump/print-msdp.c
+++ b/freebsd/contrib/tcpdump/print-msdp.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 2001 William C. Fenner.
* All rights reserved.
@@ -17,44 +20,39 @@
* LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-msdp.c,v 1.7 2005-04-06 21:32:41 mcr Exp $";
-#endif
+
+/* \summary: Multicast Source Discovery Protocol (MSDP) printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
-
-#include <stdio.h>
-#include <stdlib.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "extract.h"
#define MSDP_TYPE_MAX 7
void
-msdp_print(const unsigned char *sp, u_int length)
+msdp_print(netdissect_options *ndo, const u_char *sp, u_int length)
{
unsigned int type, len;
- TCHECK2(*sp, 3);
+ ND_TCHECK2(*sp, 3);
/* See if we think we're at the beginning of a compound packet */
type = *sp;
len = EXTRACT_16BITS(sp + 1);
if (len > 1500 || len < 3 || type == 0 || type > MSDP_TYPE_MAX)
goto trunc; /* not really truncated, but still not decodable */
- (void)printf(" msdp:");
+ ND_PRINT((ndo, " msdp:"));
while (length > 0) {
- TCHECK2(*sp, 3);
+ ND_TCHECK2(*sp, 3);
type = *sp;
len = EXTRACT_16BITS(sp + 1);
- if (len > 1400 || vflag)
- printf(" [len %u]", len);
+ if (len > 1400 || ndo->ndo_vflag)
+ ND_PRINT((ndo, " [len %u]", len));
if (len < 3)
goto trunc;
sp += 3;
@@ -63,35 +61,35 @@ msdp_print(const unsigned char *sp, u_int length)
case 1: /* IPv4 Source-Active */
case 3: /* IPv4 Source-Active Response */
if (type == 1)
- (void)printf(" SA");
+ ND_PRINT((ndo, " SA"));
else
- (void)printf(" SA-Response");
- TCHECK(*sp);
- (void)printf(" %u entries", *sp);
+ ND_PRINT((ndo, " SA-Response"));
+ ND_TCHECK(*sp);
+ ND_PRINT((ndo, " %u entries", *sp));
if ((u_int)((*sp * 12) + 8) < len) {
- (void)printf(" [w/data]");
- if (vflag > 1) {
- (void)printf(" ");
- ip_print(gndo, sp + *sp * 12 + 8 - 3,
+ ND_PRINT((ndo, " [w/data]"));
+ if (ndo->ndo_vflag > 1) {
+ ND_PRINT((ndo, " "));
+ ip_print(ndo, sp + *sp * 12 + 8 - 3,
len - (*sp * 12 + 8));
}
}
break;
case 2:
- (void)printf(" SA-Request");
- TCHECK2(*sp, 5);
- (void)printf(" for %s", ipaddr_string(sp + 1));
+ ND_PRINT((ndo, " SA-Request"));
+ ND_TCHECK2(*sp, 5);
+ ND_PRINT((ndo, " for %s", ipaddr_string(ndo, sp + 1)));
break;
case 4:
- (void)printf(" Keepalive");
+ ND_PRINT((ndo, " Keepalive"));
if (len != 3)
- (void)printf("[len=%d] ", len);
+ ND_PRINT((ndo, "[len=%d] ", len));
break;
case 5:
- (void)printf(" Notification");
+ ND_PRINT((ndo, " Notification"));
break;
default:
- (void)printf(" [type=%d len=%d]", type, len);
+ ND_PRINT((ndo, " [type=%d len=%d]", type, len));
break;
}
sp += (len - 3);
@@ -99,7 +97,7 @@ msdp_print(const unsigned char *sp, u_int length)
}
return;
trunc:
- (void)printf(" [|msdp]");
+ ND_PRINT((ndo, " [|msdp]"));
}
/*
@@ -108,3 +106,6 @@ trunc:
* c-basic-offset: 8
* End:
*/
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-msdp-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-msnlb.c b/freebsd/contrib/tcpdump/print-msnlb.c
index c0274a4f..21e9841d 100644
--- a/freebsd/contrib/tcpdump/print-msnlb.c
+++ b/freebsd/contrib/tcpdump/print-msnlb.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 2013 Romain Francoise <romain@orebokech.com>
*
@@ -28,41 +31,43 @@
* SUCH DAMAGE.
*/
+/* \summary: MS Network Load Balancing's (NLB) heartbeat printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
-
-#include <stdio.h>
-#include <string.h>
+#include <netdissect-stdinc.h>
#include "netdissect.h"
#include "addrtoname.h"
#include "extract.h"
struct msnlb_heartbeat_pkt {
- u_int32_t unknown1;
- u_int32_t unknown2;
- u_int32_t host_prio; /* little-endian */
- u_int32_t virtual_ip;
- u_int32_t host_ip;
+ uint32_t unknown1;
+ uint32_t unknown2;
+ uint32_t host_prio; /* little-endian */
+ uint32_t virtual_ip;
+ uint32_t host_ip;
/* the protocol is undocumented so we ignore the rest */
};
void
-msnlb_print(netdissect_options *ndo, const u_char *bp, u_int length)
+msnlb_print(netdissect_options *ndo, const u_char *bp)
{
const struct msnlb_heartbeat_pkt *hb;
- hb = (struct msnlb_heartbeat_pkt *)bp;
+ hb = (const struct msnlb_heartbeat_pkt *)bp;
ND_TCHECK(*hb);
ND_PRINT((ndo, "MS NLB heartbeat, host priority: %u,",
EXTRACT_LE_32BITS(&(hb->host_prio))));
- ND_PRINT((ndo, " cluster IP: %s,", ipaddr_string(&(hb->virtual_ip))));
- ND_PRINT((ndo, " host IP: %s", ipaddr_string(&(hb->host_ip))));
+ ND_PRINT((ndo, " cluster IP: %s,", ipaddr_string(ndo, &(hb->virtual_ip))));
+ ND_PRINT((ndo, " host IP: %s", ipaddr_string(ndo, &(hb->host_ip))));
return;
trunc:
ND_PRINT((ndo, "[|MS NLB]"));
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-msnlb-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-netbios.c b/freebsd/contrib/tcpdump/print-netbios.c
deleted file mode 100644
index fa32d146..00000000
--- a/freebsd/contrib/tcpdump/print-netbios.c
+++ /dev/null
@@ -1,93 +0,0 @@
-#include <machine/rtems-bsd-user-space.h>
-
-/*
- * Copyright (c) 1994, 1995, 1996
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that: (1) source code distributions
- * retain the above copyright notice and this paragraph in its entirety, (2)
- * distributions including binary code include the above copyright notice and
- * this paragraph in its entirety in the documentation or other materials
- * provided with the distribution, and (3) all advertising materials mentioning
- * features or use of this software display the following acknowledgement:
- * ``This product includes software developed by the University of California,
- * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
- * the University 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 ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Format and print NETBIOS packets.
- * Contributed by Brad Parker (brad@fcr.com).
- */
-
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-netbios.c,v 1.20 2003-11-16 09:36:29 guy Exp $";
-#endif
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <tcpdump-stdinc.h>
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#include "interface.h"
-#include "addrtoname.h"
-#include "netbios.h"
-#include "extract.h"
-
-/*
- * Print NETBIOS packets.
- */
-void
-netbios_print(struct p8022Hdr *nb, u_int length)
-{
- if (length < p8022Size) {
- (void)printf(" truncated-netbios %d", length);
- return;
- }
-
- if (nb->flags == UI) {
- (void)printf("802.1 UI ");
- } else {
- (void)printf("802.1 CONN ");
- }
-
- if ((u_char *)(nb + 1) > snapend) {
- printf(" [|netbios]");
- return;
- }
-
-/*
- netbios_decode(nb, (u_char *)nb + p8022Size, length - p8022Size);
-*/
-}
-
-#ifdef never
- (void)printf("%s.%d > ",
- ipxaddr_string(EXTRACT_32BITS(ipx->srcNet), ipx->srcNode),
- EXTRACT_16BITS(ipx->srcSkt));
-
- (void)printf("%s.%d:",
- ipxaddr_string(EXTRACT_32BITS(ipx->dstNet), ipx->dstNode),
- EXTRACT_16BITS(ipx->dstSkt));
-
- if ((u_char *)(ipx + 1) > snapend) {
- printf(" [|ipx]");
- return;
- }
-
- /* take length from ipx header */
- length = EXTRACT_16BITS(&ipx->length);
-
- ipx_decode(ipx, (u_char *)ipx + ipxSize, length - ipxSize);
-#endif
-
diff --git a/freebsd/contrib/tcpdump/print-nfs.c b/freebsd/contrib/tcpdump/print-nfs.c
index 34dbfa6c..5d8e1b4e 100644
--- a/freebsd/contrib/tcpdump/print-nfs.c
+++ b/freebsd/contrib/tcpdump/print-nfs.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
@@ -19,26 +22,20 @@
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * $FreeBSD$
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-nfs.c,v 1.111 2007-12-22 03:08:04 guy Exp $ (LBL)";
-#endif
+/* \summary: Network File System (NFS) printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include <pcap.h>
#include <stdio.h>
#include <string.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "extract.h"
@@ -46,25 +43,23 @@ static const char rcsid[] _U_ =
#include "nfsfh.h"
#include "ip.h"
-#ifdef INET6
#include "ip6.h"
-#endif
#include "rpc_auth.h"
#include "rpc_msg.h"
-static void nfs_printfh(const u_int32_t *, const u_int);
-static int xid_map_enter(const struct sunrpc_msg *, const u_char *);
-static int32_t xid_map_find(const struct sunrpc_msg *, const u_char *,
- u_int32_t *, u_int32_t *);
-static void interp_reply(const struct sunrpc_msg *, u_int32_t, u_int32_t, int);
-static const u_int32_t *parse_post_op_attr(const u_int32_t *, int);
-static void print_sattr3(const struct nfsv3_sattr *sa3, int verbose);
-static void print_nfsaddr(const u_char *, const char *, const char *);
+static const char tstr[] = " [|nfs]";
+
+static void nfs_printfh(netdissect_options *, const uint32_t *, const u_int);
+static int xid_map_enter(netdissect_options *, const struct sunrpc_msg *, const u_char *);
+static int xid_map_find(const struct sunrpc_msg *, const u_char *,
+ uint32_t *, uint32_t *);
+static void interp_reply(netdissect_options *, const struct sunrpc_msg *, uint32_t, uint32_t, int);
+static const uint32_t *parse_post_op_attr(netdissect_options *, const uint32_t *, int);
/*
* Mapping of old NFS Version 2 RPC numbers to generic numbers.
*/
-u_int32_t nfsv3_procid[NFS_NPROCS] = {
+static uint32_t nfsv3_procid[NFS_NPROCS] = {
NFSPROC_NULL,
NFSPROC_GETATTR,
NFSPROC_SETATTR,
@@ -93,6 +88,33 @@ u_int32_t nfsv3_procid[NFS_NPROCS] = {
NFSPROC_NOOP
};
+static const struct tok nfsproc_str[] = {
+ { NFSPROC_NOOP, "nop" },
+ { NFSPROC_NULL, "null" },
+ { NFSPROC_GETATTR, "getattr" },
+ { NFSPROC_SETATTR, "setattr" },
+ { NFSPROC_LOOKUP, "lookup" },
+ { NFSPROC_ACCESS, "access" },
+ { NFSPROC_READLINK, "readlink" },
+ { NFSPROC_READ, "read" },
+ { NFSPROC_WRITE, "write" },
+ { NFSPROC_CREATE, "create" },
+ { NFSPROC_MKDIR, "mkdir" },
+ { NFSPROC_SYMLINK, "symlink" },
+ { NFSPROC_MKNOD, "mknod" },
+ { NFSPROC_REMOVE, "remove" },
+ { NFSPROC_RMDIR, "rmdir" },
+ { NFSPROC_RENAME, "rename" },
+ { NFSPROC_LINK, "link" },
+ { NFSPROC_READDIR, "readdir" },
+ { NFSPROC_READDIRPLUS, "readdirplus" },
+ { NFSPROC_FSSTAT, "fsstat" },
+ { NFSPROC_FSINFO, "fsinfo" },
+ { NFSPROC_PATHCONF, "pathconf" },
+ { NFSPROC_COMMIT, "commit" },
+ { 0, NULL }
+};
+
/*
* NFS V2 and V3 status values.
*
@@ -104,7 +126,7 @@ u_int32_t nfsv3_procid[NFS_NPROCS] = {
* the first NFS server was the SunOS 2.0 one, and until 5.0 SunOS
* was primarily BSD-derived.
*/
-static struct tok status2str[] = {
+static const struct tok status2str[] = {
{ 1, "Operation not permitted" }, /* EPERM */
{ 2, "No such file or directory" }, /* ENOENT */
{ 5, "Input/output error" }, /* EIO */
@@ -142,14 +164,14 @@ static struct tok status2str[] = {
{ 0, NULL }
};
-static struct tok nfsv3_writemodes[] = {
+static const struct tok nfsv3_writemodes[] = {
{ 0, "unstable" },
{ 1, "datasync" },
{ 2, "filesync" },
{ 0, NULL }
};
-static struct tok type2str[] = {
+static const struct tok type2str[] = {
{ NFNON, "NON" },
{ NFREG, "REG" },
{ NFDIR, "DIR" },
@@ -160,100 +182,114 @@ static struct tok type2str[] = {
{ 0, NULL }
};
+static const struct tok sunrpc_auth_str[] = {
+ { SUNRPC_AUTH_OK, "OK" },
+ { SUNRPC_AUTH_BADCRED, "Bogus Credentials (seal broken)" },
+ { SUNRPC_AUTH_REJECTEDCRED, "Rejected Credentials (client should begin new session)" },
+ { SUNRPC_AUTH_BADVERF, "Bogus Verifier (seal broken)" },
+ { SUNRPC_AUTH_REJECTEDVERF, "Verifier expired or was replayed" },
+ { SUNRPC_AUTH_TOOWEAK, "Credentials are too weak" },
+ { SUNRPC_AUTH_INVALIDRESP, "Bogus response verifier" },
+ { SUNRPC_AUTH_FAILED, "Unknown failure" },
+ { 0, NULL }
+};
+
+static const struct tok sunrpc_str[] = {
+ { SUNRPC_PROG_UNAVAIL, "PROG_UNAVAIL" },
+ { SUNRPC_PROG_MISMATCH, "PROG_MISMATCH" },
+ { SUNRPC_PROC_UNAVAIL, "PROC_UNAVAIL" },
+ { SUNRPC_GARBAGE_ARGS, "GARBAGE_ARGS" },
+ { SUNRPC_SYSTEM_ERR, "SYSTEM_ERR" },
+ { 0, NULL }
+};
+
static void
-print_nfsaddr(const u_char *bp, const char *s, const char *d)
+print_nfsaddr(netdissect_options *ndo,
+ const u_char *bp, const char *s, const char *d)
{
- struct ip *ip;
-#ifdef INET6
- struct ip6_hdr *ip6;
+ const struct ip *ip;
+ const struct ip6_hdr *ip6;
char srcaddr[INET6_ADDRSTRLEN], dstaddr[INET6_ADDRSTRLEN];
-#else
-#ifndef INET_ADDRSTRLEN
-#define INET_ADDRSTRLEN 16
-#endif
- char srcaddr[INET_ADDRSTRLEN], dstaddr[INET_ADDRSTRLEN];
-#endif
srcaddr[0] = dstaddr[0] = '\0';
- switch (IP_V((struct ip *)bp)) {
+ switch (IP_V((const struct ip *)bp)) {
case 4:
- ip = (struct ip *)bp;
- strlcpy(srcaddr, ipaddr_string(&ip->ip_src), sizeof(srcaddr));
- strlcpy(dstaddr, ipaddr_string(&ip->ip_dst), sizeof(dstaddr));
+ ip = (const struct ip *)bp;
+ strlcpy(srcaddr, ipaddr_string(ndo, &ip->ip_src), sizeof(srcaddr));
+ strlcpy(dstaddr, ipaddr_string(ndo, &ip->ip_dst), sizeof(dstaddr));
break;
-#ifdef INET6
case 6:
- ip6 = (struct ip6_hdr *)bp;
- strlcpy(srcaddr, ip6addr_string(&ip6->ip6_src),
+ ip6 = (const struct ip6_hdr *)bp;
+ strlcpy(srcaddr, ip6addr_string(ndo, &ip6->ip6_src),
sizeof(srcaddr));
- strlcpy(dstaddr, ip6addr_string(&ip6->ip6_dst),
+ strlcpy(dstaddr, ip6addr_string(ndo, &ip6->ip6_dst),
sizeof(dstaddr));
break;
-#endif
default:
strlcpy(srcaddr, "?", sizeof(srcaddr));
strlcpy(dstaddr, "?", sizeof(dstaddr));
break;
}
- (void)printf("%s.%s > %s.%s: ", srcaddr, s, dstaddr, d);
+ ND_PRINT((ndo, "%s.%s > %s.%s: ", srcaddr, s, dstaddr, d));
}
-static const u_int32_t *
-parse_sattr3(const u_int32_t *dp, struct nfsv3_sattr *sa3)
+static const uint32_t *
+parse_sattr3(netdissect_options *ndo,
+ const uint32_t *dp, struct nfsv3_sattr *sa3)
{
- TCHECK(dp[0]);
+ ND_TCHECK(dp[0]);
sa3->sa_modeset = EXTRACT_32BITS(dp);
dp++;
if (sa3->sa_modeset) {
- TCHECK(dp[0]);
+ ND_TCHECK(dp[0]);
sa3->sa_mode = EXTRACT_32BITS(dp);
dp++;
}
- TCHECK(dp[0]);
+ ND_TCHECK(dp[0]);
sa3->sa_uidset = EXTRACT_32BITS(dp);
dp++;
if (sa3->sa_uidset) {
- TCHECK(dp[0]);
+ ND_TCHECK(dp[0]);
sa3->sa_uid = EXTRACT_32BITS(dp);
dp++;
}
- TCHECK(dp[0]);
+ ND_TCHECK(dp[0]);
sa3->sa_gidset = EXTRACT_32BITS(dp);
dp++;
if (sa3->sa_gidset) {
- TCHECK(dp[0]);
+ ND_TCHECK(dp[0]);
sa3->sa_gid = EXTRACT_32BITS(dp);
dp++;
}
- TCHECK(dp[0]);
+ ND_TCHECK(dp[0]);
sa3->sa_sizeset = EXTRACT_32BITS(dp);
dp++;
if (sa3->sa_sizeset) {
- TCHECK(dp[0]);
+ ND_TCHECK(dp[0]);
sa3->sa_size = EXTRACT_32BITS(dp);
dp++;
}
- TCHECK(dp[0]);
+ ND_TCHECK(dp[0]);
sa3->sa_atimetype = EXTRACT_32BITS(dp);
dp++;
if (sa3->sa_atimetype == NFSV3SATTRTIME_TOCLIENT) {
- TCHECK(dp[1]);
+ ND_TCHECK(dp[1]);
sa3->sa_atime.nfsv3_sec = EXTRACT_32BITS(dp);
dp++;
sa3->sa_atime.nfsv3_nsec = EXTRACT_32BITS(dp);
dp++;
}
- TCHECK(dp[0]);
+ ND_TCHECK(dp[0]);
sa3->sa_mtimetype = EXTRACT_32BITS(dp);
dp++;
if (sa3->sa_mtimetype == NFSV3SATTRTIME_TOCLIENT) {
- TCHECK(dp[1]);
+ ND_TCHECK(dp[1]);
sa3->sa_mtime.nfsv3_sec = EXTRACT_32BITS(dp);
dp++;
sa3->sa_mtime.nfsv3_nsec = EXTRACT_32BITS(dp);
@@ -268,41 +304,38 @@ trunc:
static int nfserr; /* true if we error rather than trunc */
static void
-print_sattr3(const struct nfsv3_sattr *sa3, int verbose)
+print_sattr3(netdissect_options *ndo,
+ const struct nfsv3_sattr *sa3, int verbose)
{
if (sa3->sa_modeset)
- printf(" mode %o", sa3->sa_mode);
+ ND_PRINT((ndo, " mode %o", sa3->sa_mode));
if (sa3->sa_uidset)
- printf(" uid %u", sa3->sa_uid);
+ ND_PRINT((ndo, " uid %u", sa3->sa_uid));
if (sa3->sa_gidset)
- printf(" gid %u", sa3->sa_gid);
+ ND_PRINT((ndo, " gid %u", sa3->sa_gid));
if (verbose > 1) {
if (sa3->sa_atimetype == NFSV3SATTRTIME_TOCLIENT)
- printf(" atime %u.%06u", sa3->sa_atime.nfsv3_sec,
- sa3->sa_atime.nfsv3_nsec);
+ ND_PRINT((ndo, " atime %u.%06u", sa3->sa_atime.nfsv3_sec,
+ sa3->sa_atime.nfsv3_nsec));
if (sa3->sa_mtimetype == NFSV3SATTRTIME_TOCLIENT)
- printf(" mtime %u.%06u", sa3->sa_mtime.nfsv3_sec,
- sa3->sa_mtime.nfsv3_nsec);
+ ND_PRINT((ndo, " mtime %u.%06u", sa3->sa_mtime.nfsv3_sec,
+ sa3->sa_mtime.nfsv3_nsec));
}
}
void
-nfsreply_print(register const u_char *bp, u_int length,
- register const u_char *bp2)
+nfsreply_print(netdissect_options *ndo,
+ register const u_char *bp, u_int length,
+ register const u_char *bp2)
{
register const struct sunrpc_msg *rp;
- u_int32_t proc, vers, reply_stat;
char srcid[20], dstid[20]; /*fits 32bit*/
- enum sunrpc_reject_stat rstat;
- u_int32_t rlow;
- u_int32_t rhigh;
- enum sunrpc_auth_stat rwhy;
nfserr = 0; /* assume no error */
rp = (const struct sunrpc_msg *)bp;
- TCHECK(rp->rm_xid);
- if (!nflag) {
+ ND_TCHECK(rp->rm_xid);
+ if (!ndo->ndo_nflag) {
strlcpy(srcid, "nfs", sizeof(srcid));
snprintf(dstid, sizeof(dstid), "%u",
EXTRACT_32BITS(&rp->rm_xid));
@@ -311,118 +344,101 @@ nfsreply_print(register const u_char *bp, u_int length,
snprintf(dstid, sizeof(dstid), "%u",
EXTRACT_32BITS(&rp->rm_xid));
}
- print_nfsaddr(bp2, srcid, dstid);
- TCHECK(rp->rm_reply.rp_stat);
+ print_nfsaddr(ndo, bp2, srcid, dstid);
+
+ nfsreply_print_noaddr(ndo, bp, length, bp2);
+ return;
+
+trunc:
+ if (!nfserr)
+ ND_PRINT((ndo, "%s", tstr));
+}
+
+void
+nfsreply_print_noaddr(netdissect_options *ndo,
+ register const u_char *bp, u_int length,
+ register const u_char *bp2)
+{
+ register const struct sunrpc_msg *rp;
+ uint32_t proc, vers, reply_stat;
+ enum sunrpc_reject_stat rstat;
+ uint32_t rlow;
+ uint32_t rhigh;
+ enum sunrpc_auth_stat rwhy;
+
+ nfserr = 0; /* assume no error */
+ rp = (const struct sunrpc_msg *)bp;
+
+ ND_TCHECK(rp->rm_reply.rp_stat);
reply_stat = EXTRACT_32BITS(&rp->rm_reply.rp_stat);
switch (reply_stat) {
case SUNRPC_MSG_ACCEPTED:
- (void)printf("reply ok %u", length);
+ ND_PRINT((ndo, "reply ok %u", length));
if (xid_map_find(rp, bp2, &proc, &vers) >= 0)
- interp_reply(rp, proc, vers, length);
+ interp_reply(ndo, rp, proc, vers, length);
break;
case SUNRPC_MSG_DENIED:
- (void)printf("reply ERR %u: ", length);
- TCHECK(rp->rm_reply.rp_reject.rj_stat);
+ ND_PRINT((ndo, "reply ERR %u: ", length));
+ ND_TCHECK(rp->rm_reply.rp_reject.rj_stat);
rstat = EXTRACT_32BITS(&rp->rm_reply.rp_reject.rj_stat);
switch (rstat) {
case SUNRPC_RPC_MISMATCH:
- TCHECK(rp->rm_reply.rp_reject.rj_vers.high);
+ ND_TCHECK(rp->rm_reply.rp_reject.rj_vers.high);
rlow = EXTRACT_32BITS(&rp->rm_reply.rp_reject.rj_vers.low);
rhigh = EXTRACT_32BITS(&rp->rm_reply.rp_reject.rj_vers.high);
- (void)printf("RPC Version mismatch (%u-%u)",
- rlow, rhigh);
+ ND_PRINT((ndo, "RPC Version mismatch (%u-%u)", rlow, rhigh));
break;
case SUNRPC_AUTH_ERROR:
- TCHECK(rp->rm_reply.rp_reject.rj_why);
+ ND_TCHECK(rp->rm_reply.rp_reject.rj_why);
rwhy = EXTRACT_32BITS(&rp->rm_reply.rp_reject.rj_why);
- (void)printf("Auth ");
- switch (rwhy) {
-
- case SUNRPC_AUTH_OK:
- (void)printf("OK");
- break;
-
- case SUNRPC_AUTH_BADCRED:
- (void)printf("Bogus Credentials (seal broken)");
- break;
-
- case SUNRPC_AUTH_REJECTEDCRED:
- (void)printf("Rejected Credentials (client should begin new session)");
- break;
-
- case SUNRPC_AUTH_BADVERF:
- (void)printf("Bogus Verifier (seal broken)");
- break;
-
- case SUNRPC_AUTH_REJECTEDVERF:
- (void)printf("Verifier expired or was replayed");
- break;
-
- case SUNRPC_AUTH_TOOWEAK:
- (void)printf("Credentials are too weak");
- break;
-
- case SUNRPC_AUTH_INVALIDRESP:
- (void)printf("Bogus response verifier");
- break;
-
- case SUNRPC_AUTH_FAILED:
- (void)printf("Unknown failure");
- break;
-
- default:
- (void)printf("Invalid failure code %u",
- (unsigned int)rwhy);
- break;
- }
+ ND_PRINT((ndo, "Auth %s", tok2str(sunrpc_auth_str, "Invalid failure code %u", rwhy)));
break;
default:
- (void)printf("Unknown reason for rejecting rpc message %u",
- (unsigned int)rstat);
+ ND_PRINT((ndo, "Unknown reason for rejecting rpc message %u", (unsigned int)rstat));
break;
}
break;
default:
- (void)printf("reply Unknown rpc response code=%u %u",
- reply_stat, length);
+ ND_PRINT((ndo, "reply Unknown rpc response code=%u %u", reply_stat, length));
break;
}
return;
trunc:
if (!nfserr)
- fputs(" [|nfs]", stdout);
+ ND_PRINT((ndo, "%s", tstr));
}
/*
* Return a pointer to the first file handle in the packet.
* If the packet was truncated, return 0.
*/
-static const u_int32_t *
-parsereq(register const struct sunrpc_msg *rp, register u_int length)
+static const uint32_t *
+parsereq(netdissect_options *ndo,
+ register const struct sunrpc_msg *rp, register u_int length)
{
- register const u_int32_t *dp;
+ register const uint32_t *dp;
register u_int len;
/*
* find the start of the req data (if we captured it)
*/
- dp = (u_int32_t *)&rp->rm_call.cb_cred;
- TCHECK(dp[1]);
+ dp = (const uint32_t *)&rp->rm_call.cb_cred;
+ ND_TCHECK(dp[1]);
len = EXTRACT_32BITS(&dp[1]);
if (len < length) {
dp += (len + (2 * sizeof(*dp) + 3)) / sizeof(*dp);
- TCHECK(dp[1]);
+ ND_TCHECK(dp[1]);
len = EXTRACT_32BITS(&dp[1]);
if (len < length) {
dp += (len + (2 * sizeof(*dp) + 3)) / sizeof(*dp);
- TCHECK2(dp[0], 0);
+ ND_TCHECK2(dp[0], 0);
return (dp);
}
}
@@ -434,20 +450,21 @@ trunc:
* Print out an NFS file handle and return a pointer to following word.
* If packet was truncated, return 0.
*/
-static const u_int32_t *
-parsefh(register const u_int32_t *dp, int v3)
+static const uint32_t *
+parsefh(netdissect_options *ndo,
+ register const uint32_t *dp, int v3)
{
u_int len;
if (v3) {
- TCHECK(dp[0]);
+ ND_TCHECK(dp[0]);
len = EXTRACT_32BITS(dp) / 4;
dp++;
} else
len = NFSX_V2FH / 4;
- if (TTEST2(*dp, len * sizeof(*dp))) {
- nfs_printfh(dp, len);
+ if (ND_TTEST2(*dp, len * sizeof(*dp))) {
+ nfs_printfh(ndo, dp, len);
return (dp + len);
}
trunc:
@@ -458,30 +475,31 @@ trunc:
* Print out a file name and return pointer to 32-bit word past it.
* If packet was truncated, return 0.
*/
-static const u_int32_t *
-parsefn(register const u_int32_t *dp)
+static const uint32_t *
+parsefn(netdissect_options *ndo,
+ register const uint32_t *dp)
{
- register u_int32_t len;
+ register uint32_t len;
register const u_char *cp;
/* Bail if we don't have the string length */
- TCHECK(*dp);
+ ND_TCHECK(*dp);
/* Fetch string length; convert to host order */
len = *dp++;
NTOHL(len);
- TCHECK2(*dp, ((len + 3) & ~3));
+ ND_TCHECK2(*dp, ((len + 3) & ~3));
- cp = (u_char *)dp;
+ cp = (const u_char *)dp;
/* Update 32-bit pointer (NFS filenames padded to 32-bit boundaries) */
dp += ((len + 3) & ~3) / sizeof(*dp);
- putchar('"');
- if (fn_printn(cp, len, snapend)) {
- putchar('"');
+ ND_PRINT((ndo, "\""));
+ if (fn_printn(ndo, cp, len, ndo->ndo_snapend)) {
+ ND_PRINT((ndo, "\""));
goto trunc;
}
- putchar('"');
+ ND_PRINT((ndo, "\""));
return (dp);
trunc:
@@ -493,46 +511,35 @@ trunc:
* Return pointer to 32-bit word past file name.
* If packet was truncated (or there was some other error), return 0.
*/
-static const u_int32_t *
-parsefhn(register const u_int32_t *dp, int v3)
+static const uint32_t *
+parsefhn(netdissect_options *ndo,
+ register const uint32_t *dp, int v3)
{
- dp = parsefh(dp, v3);
+ dp = parsefh(ndo, dp, v3);
if (dp == NULL)
return (NULL);
- putchar(' ');
- return (parsefn(dp));
+ ND_PRINT((ndo, " "));
+ return (parsefn(ndo, dp));
}
void
-nfsreq_print(register const u_char *bp, u_int length,
- register const u_char *bp2)
+nfsreq_print_noaddr(netdissect_options *ndo,
+ register const u_char *bp, u_int length,
+ register const u_char *bp2)
{
register const struct sunrpc_msg *rp;
- register const u_int32_t *dp;
+ register const uint32_t *dp;
nfs_type type;
int v3;
- u_int32_t proc;
- u_int32_t access_flags;
+ uint32_t proc;
+ uint32_t access_flags;
struct nfsv3_sattr sa3;
- char srcid[20], dstid[20]; /*fits 32bit*/
+ ND_PRINT((ndo, "%d", length));
nfserr = 0; /* assume no error */
rp = (const struct sunrpc_msg *)bp;
- TCHECK(rp->rm_xid);
- if (!nflag) {
- snprintf(srcid, sizeof(srcid), "%u",
- EXTRACT_32BITS(&rp->rm_xid));
- strlcpy(dstid, "nfs", sizeof(dstid));
- } else {
- snprintf(srcid, sizeof(srcid), "%u",
- EXTRACT_32BITS(&rp->rm_xid));
- snprintf(dstid, sizeof(dstid), "%u", NFS_PORT);
- }
- print_nfsaddr(bp2, srcid, dstid);
- (void)printf("%d", length);
-
- if (!xid_map_enter(rp, bp2)) /* record proc number for later on */
+ if (!xid_map_enter(ndo, rp, bp2)) /* record proc number for later on */
goto trunc;
v3 = (EXTRACT_32BITS(&rp->rm_call.cb_vers) == NFS_VER3);
@@ -541,307 +548,235 @@ nfsreq_print(register const u_char *bp, u_int length,
if (!v3 && proc < NFS_NPROCS)
proc = nfsv3_procid[proc];
+ ND_PRINT((ndo, " %s", tok2str(nfsproc_str, "proc-%u", proc)));
switch (proc) {
- case NFSPROC_NOOP:
- printf(" nop");
- return;
- case NFSPROC_NULL:
- printf(" null");
- return;
case NFSPROC_GETATTR:
- printf(" getattr");
- if ((dp = parsereq(rp, length)) != NULL &&
- parsefh(dp, v3) != NULL)
- return;
- break;
-
case NFSPROC_SETATTR:
- printf(" setattr");
- if ((dp = parsereq(rp, length)) != NULL &&
- parsefh(dp, v3) != NULL)
+ case NFSPROC_READLINK:
+ case NFSPROC_FSSTAT:
+ case NFSPROC_FSINFO:
+ case NFSPROC_PATHCONF:
+ if ((dp = parsereq(ndo, rp, length)) != NULL &&
+ parsefh(ndo, dp, v3) != NULL)
return;
break;
case NFSPROC_LOOKUP:
- printf(" lookup");
- if ((dp = parsereq(rp, length)) != NULL &&
- parsefhn(dp, v3) != NULL)
+ case NFSPROC_CREATE:
+ case NFSPROC_MKDIR:
+ case NFSPROC_REMOVE:
+ case NFSPROC_RMDIR:
+ if ((dp = parsereq(ndo, rp, length)) != NULL &&
+ parsefhn(ndo, dp, v3) != NULL)
return;
break;
case NFSPROC_ACCESS:
- printf(" access");
- if ((dp = parsereq(rp, length)) != NULL &&
- (dp = parsefh(dp, v3)) != NULL) {
- TCHECK(dp[0]);
+ if ((dp = parsereq(ndo, rp, length)) != NULL &&
+ (dp = parsefh(ndo, dp, v3)) != NULL) {
+ ND_TCHECK(dp[0]);
access_flags = EXTRACT_32BITS(&dp[0]);
if (access_flags & ~NFSV3ACCESS_FULL) {
/* NFSV3ACCESS definitions aren't up to date */
- printf(" %04x", access_flags);
+ ND_PRINT((ndo, " %04x", access_flags));
} else if ((access_flags & NFSV3ACCESS_FULL) == NFSV3ACCESS_FULL) {
- printf(" NFS_ACCESS_FULL");
+ ND_PRINT((ndo, " NFS_ACCESS_FULL"));
} else {
char separator = ' ';
if (access_flags & NFSV3ACCESS_READ) {
- printf(" NFS_ACCESS_READ");
+ ND_PRINT((ndo, " NFS_ACCESS_READ"));
separator = '|';
}
if (access_flags & NFSV3ACCESS_LOOKUP) {
- printf("%cNFS_ACCESS_LOOKUP", separator);
+ ND_PRINT((ndo, "%cNFS_ACCESS_LOOKUP", separator));
separator = '|';
}
if (access_flags & NFSV3ACCESS_MODIFY) {
- printf("%cNFS_ACCESS_MODIFY", separator);
+ ND_PRINT((ndo, "%cNFS_ACCESS_MODIFY", separator));
separator = '|';
}
if (access_flags & NFSV3ACCESS_EXTEND) {
- printf("%cNFS_ACCESS_EXTEND", separator);
+ ND_PRINT((ndo, "%cNFS_ACCESS_EXTEND", separator));
separator = '|';
}
if (access_flags & NFSV3ACCESS_DELETE) {
- printf("%cNFS_ACCESS_DELETE", separator);
+ ND_PRINT((ndo, "%cNFS_ACCESS_DELETE", separator));
separator = '|';
}
if (access_flags & NFSV3ACCESS_EXECUTE)
- printf("%cNFS_ACCESS_EXECUTE", separator);
+ ND_PRINT((ndo, "%cNFS_ACCESS_EXECUTE", separator));
}
return;
}
break;
- case NFSPROC_READLINK:
- printf(" readlink");
- if ((dp = parsereq(rp, length)) != NULL &&
- parsefh(dp, v3) != NULL)
- return;
- break;
-
case NFSPROC_READ:
- printf(" read");
- if ((dp = parsereq(rp, length)) != NULL &&
- (dp = parsefh(dp, v3)) != NULL) {
+ if ((dp = parsereq(ndo, rp, length)) != NULL &&
+ (dp = parsefh(ndo, dp, v3)) != NULL) {
if (v3) {
- TCHECK(dp[2]);
- printf(" %u bytes @ %" PRIu64,
+ ND_TCHECK(dp[2]);
+ ND_PRINT((ndo, " %u bytes @ %" PRIu64,
EXTRACT_32BITS(&dp[2]),
- EXTRACT_64BITS(&dp[0]));
+ EXTRACT_64BITS(&dp[0])));
} else {
- TCHECK(dp[1]);
- printf(" %u bytes @ %u",
+ ND_TCHECK(dp[1]);
+ ND_PRINT((ndo, " %u bytes @ %u",
EXTRACT_32BITS(&dp[1]),
- EXTRACT_32BITS(&dp[0]));
+ EXTRACT_32BITS(&dp[0])));
}
return;
}
break;
case NFSPROC_WRITE:
- printf(" write");
- if ((dp = parsereq(rp, length)) != NULL &&
- (dp = parsefh(dp, v3)) != NULL) {
+ if ((dp = parsereq(ndo, rp, length)) != NULL &&
+ (dp = parsefh(ndo, dp, v3)) != NULL) {
if (v3) {
- TCHECK(dp[2]);
- printf(" %u (%u) bytes @ %" PRIu64,
+ ND_TCHECK(dp[2]);
+ ND_PRINT((ndo, " %u (%u) bytes @ %" PRIu64,
EXTRACT_32BITS(&dp[4]),
EXTRACT_32BITS(&dp[2]),
- EXTRACT_64BITS(&dp[0]));
- if (vflag) {
+ EXTRACT_64BITS(&dp[0])));
+ if (ndo->ndo_vflag) {
dp += 3;
- TCHECK(dp[0]);
- printf(" <%s>",
+ ND_TCHECK(dp[0]);
+ ND_PRINT((ndo, " <%s>",
tok2str(nfsv3_writemodes,
- NULL, EXTRACT_32BITS(dp)));
+ NULL, EXTRACT_32BITS(dp))));
}
} else {
- TCHECK(dp[3]);
- printf(" %u (%u) bytes @ %u (%u)",
+ ND_TCHECK(dp[3]);
+ ND_PRINT((ndo, " %u (%u) bytes @ %u (%u)",
EXTRACT_32BITS(&dp[3]),
EXTRACT_32BITS(&dp[2]),
EXTRACT_32BITS(&dp[1]),
- EXTRACT_32BITS(&dp[0]));
+ EXTRACT_32BITS(&dp[0])));
}
return;
}
break;
- case NFSPROC_CREATE:
- printf(" create");
- if ((dp = parsereq(rp, length)) != NULL &&
- parsefhn(dp, v3) != NULL)
- return;
- break;
-
- case NFSPROC_MKDIR:
- printf(" mkdir");
- if ((dp = parsereq(rp, length)) != 0 && parsefhn(dp, v3) != 0)
- return;
- break;
-
case NFSPROC_SYMLINK:
- printf(" symlink");
- if ((dp = parsereq(rp, length)) != 0 &&
- (dp = parsefhn(dp, v3)) != 0) {
- fputs(" ->", stdout);
- if (v3 && (dp = parse_sattr3(dp, &sa3)) == 0)
+ if ((dp = parsereq(ndo, rp, length)) != NULL &&
+ (dp = parsefhn(ndo, dp, v3)) != NULL) {
+ ND_PRINT((ndo, " ->"));
+ if (v3 && (dp = parse_sattr3(ndo, dp, &sa3)) == NULL)
break;
- if (parsefn(dp) == 0)
+ if (parsefn(ndo, dp) == NULL)
break;
- if (v3 && vflag)
- print_sattr3(&sa3, vflag);
+ if (v3 && ndo->ndo_vflag)
+ print_sattr3(ndo, &sa3, ndo->ndo_vflag);
return;
}
break;
case NFSPROC_MKNOD:
- printf(" mknod");
- if ((dp = parsereq(rp, length)) != 0 &&
- (dp = parsefhn(dp, v3)) != 0) {
- TCHECK(*dp);
+ if ((dp = parsereq(ndo, rp, length)) != NULL &&
+ (dp = parsefhn(ndo, dp, v3)) != NULL) {
+ ND_TCHECK(*dp);
type = (nfs_type)EXTRACT_32BITS(dp);
dp++;
- if ((dp = parse_sattr3(dp, &sa3)) == 0)
+ if ((dp = parse_sattr3(ndo, dp, &sa3)) == NULL)
break;
- printf(" %s", tok2str(type2str, "unk-ft %d", type));
- if (vflag && (type == NFCHR || type == NFBLK)) {
- TCHECK(dp[1]);
- printf(" %u/%u",
+ ND_PRINT((ndo, " %s", tok2str(type2str, "unk-ft %d", type)));
+ if (ndo->ndo_vflag && (type == NFCHR || type == NFBLK)) {
+ ND_TCHECK(dp[1]);
+ ND_PRINT((ndo, " %u/%u",
EXTRACT_32BITS(&dp[0]),
- EXTRACT_32BITS(&dp[1]));
+ EXTRACT_32BITS(&dp[1])));
dp += 2;
}
- if (vflag)
- print_sattr3(&sa3, vflag);
+ if (ndo->ndo_vflag)
+ print_sattr3(ndo, &sa3, ndo->ndo_vflag);
return;
}
break;
- case NFSPROC_REMOVE:
- printf(" remove");
- if ((dp = parsereq(rp, length)) != NULL &&
- parsefhn(dp, v3) != NULL)
- return;
- break;
-
- case NFSPROC_RMDIR:
- printf(" rmdir");
- if ((dp = parsereq(rp, length)) != NULL &&
- parsefhn(dp, v3) != NULL)
- return;
- break;
-
case NFSPROC_RENAME:
- printf(" rename");
- if ((dp = parsereq(rp, length)) != NULL &&
- (dp = parsefhn(dp, v3)) != NULL) {
- fputs(" ->", stdout);
- if (parsefhn(dp, v3) != NULL)
+ if ((dp = parsereq(ndo, rp, length)) != NULL &&
+ (dp = parsefhn(ndo, dp, v3)) != NULL) {
+ ND_PRINT((ndo, " ->"));
+ if (parsefhn(ndo, dp, v3) != NULL)
return;
}
break;
case NFSPROC_LINK:
- printf(" link");
- if ((dp = parsereq(rp, length)) != NULL &&
- (dp = parsefh(dp, v3)) != NULL) {
- fputs(" ->", stdout);
- if (parsefhn(dp, v3) != NULL)
+ if ((dp = parsereq(ndo, rp, length)) != NULL &&
+ (dp = parsefh(ndo, dp, v3)) != NULL) {
+ ND_PRINT((ndo, " ->"));
+ if (parsefhn(ndo, dp, v3) != NULL)
return;
}
break;
case NFSPROC_READDIR:
- printf(" readdir");
- if ((dp = parsereq(rp, length)) != NULL &&
- (dp = parsefh(dp, v3)) != NULL) {
+ if ((dp = parsereq(ndo, rp, length)) != NULL &&
+ (dp = parsefh(ndo, dp, v3)) != NULL) {
if (v3) {
- TCHECK(dp[4]);
+ ND_TCHECK(dp[4]);
/*
* We shouldn't really try to interpret the
* offset cookie here.
*/
- printf(" %u bytes @ %" PRId64,
+ ND_PRINT((ndo, " %u bytes @ %" PRId64,
EXTRACT_32BITS(&dp[4]),
- EXTRACT_64BITS(&dp[0]));
- if (vflag)
- printf(" verf %08x%08x", dp[2],
- dp[3]);
+ EXTRACT_64BITS(&dp[0])));
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo, " verf %08x%08x", dp[2], dp[3]));
} else {
- TCHECK(dp[1]);
+ ND_TCHECK(dp[1]);
/*
* Print the offset as signed, since -1 is
* common, but offsets > 2^31 aren't.
*/
- printf(" %u bytes @ %d",
+ ND_PRINT((ndo, " %u bytes @ %d",
EXTRACT_32BITS(&dp[1]),
- EXTRACT_32BITS(&dp[0]));
+ EXTRACT_32BITS(&dp[0])));
}
return;
}
break;
case NFSPROC_READDIRPLUS:
- printf(" readdirplus");
- if ((dp = parsereq(rp, length)) != NULL &&
- (dp = parsefh(dp, v3)) != NULL) {
- TCHECK(dp[4]);
+ if ((dp = parsereq(ndo, rp, length)) != NULL &&
+ (dp = parsefh(ndo, dp, v3)) != NULL) {
+ ND_TCHECK(dp[4]);
/*
* We don't try to interpret the offset
* cookie here.
*/
- printf(" %u bytes @ %" PRId64,
+ ND_PRINT((ndo, " %u bytes @ %" PRId64,
EXTRACT_32BITS(&dp[4]),
- EXTRACT_64BITS(&dp[0]));
- if (vflag) {
- TCHECK(dp[5]);
- printf(" max %u verf %08x%08x",
- EXTRACT_32BITS(&dp[5]), dp[2], dp[3]);
+ EXTRACT_64BITS(&dp[0])));
+ if (ndo->ndo_vflag) {
+ ND_TCHECK(dp[5]);
+ ND_PRINT((ndo, " max %u verf %08x%08x",
+ EXTRACT_32BITS(&dp[5]), dp[2], dp[3]));
}
return;
}
break;
- case NFSPROC_FSSTAT:
- printf(" fsstat");
- if ((dp = parsereq(rp, length)) != NULL &&
- parsefh(dp, v3) != NULL)
- return;
- break;
-
- case NFSPROC_FSINFO:
- printf(" fsinfo");
- if ((dp = parsereq(rp, length)) != NULL &&
- parsefh(dp, v3) != NULL)
- return;
- break;
-
- case NFSPROC_PATHCONF:
- printf(" pathconf");
- if ((dp = parsereq(rp, length)) != NULL &&
- parsefh(dp, v3) != NULL)
- return;
- break;
-
case NFSPROC_COMMIT:
- printf(" commit");
- if ((dp = parsereq(rp, length)) != NULL &&
- (dp = parsefh(dp, v3)) != NULL) {
- TCHECK(dp[2]);
- printf(" %u bytes @ %" PRIu64,
+ if ((dp = parsereq(ndo, rp, length)) != NULL &&
+ (dp = parsefh(ndo, dp, v3)) != NULL) {
+ ND_TCHECK(dp[2]);
+ ND_PRINT((ndo, " %u bytes @ %" PRIu64,
EXTRACT_32BITS(&dp[2]),
- EXTRACT_64BITS(&dp[0]));
+ EXTRACT_64BITS(&dp[0])));
return;
}
break;
default:
- printf(" proc-%u", EXTRACT_32BITS(&rp->rm_call.cb_proc));
return;
}
trunc:
if (!nfserr)
- fputs(" [|nfs]", stdout);
+ ND_PRINT((ndo, "%s", tstr));
}
/*
@@ -854,23 +789,24 @@ trunc:
* additional hacking on the parser code.
*/
static void
-nfs_printfh(register const u_int32_t *dp, const u_int len)
+nfs_printfh(netdissect_options *ndo,
+ register const uint32_t *dp, const u_int len)
{
my_fsid fsid;
- ino_t ino;
+ uint32_t ino;
const char *sfsname = NULL;
char *spacep;
- if (uflag) {
+ if (ndo->ndo_uflag) {
u_int i;
char const *sep = "";
- printf(" fh[");
+ ND_PRINT((ndo, " fh["));
for (i=0; i<len; i++) {
- (void)printf("%s%x", sep, dp[i]);
+ ND_PRINT((ndo, "%s%x", sep, dp[i]));
sep = ":";
}
- printf("]");
+ ND_PRINT((ndo, "]"));
return;
}
@@ -888,17 +824,17 @@ nfs_printfh(register const u_int32_t *dp, const u_int len)
if (spacep)
*spacep = '\0';
- (void)printf(" fh %s/", temp);
+ ND_PRINT((ndo, " fh %s/", temp));
} else {
- (void)printf(" fh %d,%d/",
- fsid.Fsid_dev.Major, fsid.Fsid_dev.Minor);
+ ND_PRINT((ndo, " fh %d,%d/",
+ fsid.Fsid_dev.Major, fsid.Fsid_dev.Minor));
}
if(fsid.Fsid_dev.Minor == 257)
/* Print the undecoded handle */
- (void)printf("%s", fsid.Opaque_Handle);
+ ND_PRINT((ndo, "%s", fsid.Opaque_Handle));
else
- (void)printf("%ld", (long) ino);
+ ND_PRINT((ndo, "%ld", (long) ino));
}
/*
@@ -908,17 +844,12 @@ nfs_printfh(register const u_int32_t *dp, const u_int len)
*/
struct xid_map_entry {
- u_int32_t xid; /* transaction ID (net order) */
+ uint32_t xid; /* transaction ID (net order) */
int ipver; /* IP version (4 or 6) */
-#ifdef INET6
struct in6_addr client; /* client IP address (net order) */
struct in6_addr server; /* server IP address (net order) */
-#else
- struct in_addr client; /* client IP address (net order) */
- struct in_addr server; /* server IP address (net order) */
-#endif
- u_int32_t proc; /* call proc number (host order) */
- u_int32_t vers; /* program version (host order) */
+ uint32_t proc; /* call proc number (host order) */
+ uint32_t vers; /* program version (host order) */
};
/*
@@ -929,31 +860,28 @@ struct xid_map_entry {
#define XIDMAPSIZE 64
-struct xid_map_entry xid_map[XIDMAPSIZE];
+static struct xid_map_entry xid_map[XIDMAPSIZE];
-int xid_map_next = 0;
-int xid_map_hint = 0;
+static int xid_map_next = 0;
+static int xid_map_hint = 0;
static int
-xid_map_enter(const struct sunrpc_msg *rp, const u_char *bp)
+xid_map_enter(netdissect_options *ndo,
+ const struct sunrpc_msg *rp, const u_char *bp)
{
- struct ip *ip = NULL;
-#ifdef INET6
- struct ip6_hdr *ip6 = NULL;
-#endif
+ const struct ip *ip = NULL;
+ const struct ip6_hdr *ip6 = NULL;
struct xid_map_entry *xmep;
- if (!TTEST(rp->rm_call.cb_vers))
+ if (!ND_TTEST(rp->rm_call.cb_vers))
return (0);
- switch (IP_V((struct ip *)bp)) {
+ switch (IP_V((const struct ip *)bp)) {
case 4:
- ip = (struct ip *)bp;
+ ip = (const struct ip *)bp;
break;
-#ifdef INET6
case 6:
- ip6 = (struct ip6_hdr *)bp;
+ ip6 = (const struct ip6_hdr *)bp;
break;
-#endif
default:
return (1);
}
@@ -963,19 +891,17 @@ xid_map_enter(const struct sunrpc_msg *rp, const u_char *bp)
if (++xid_map_next >= XIDMAPSIZE)
xid_map_next = 0;
- xmep->xid = rp->rm_xid;
+ UNALIGNED_MEMCPY(&xmep->xid, &rp->rm_xid, sizeof(xmep->xid));
if (ip) {
xmep->ipver = 4;
- memcpy(&xmep->client, &ip->ip_src, sizeof(ip->ip_src));
- memcpy(&xmep->server, &ip->ip_dst, sizeof(ip->ip_dst));
+ UNALIGNED_MEMCPY(&xmep->client, &ip->ip_src, sizeof(ip->ip_src));
+ UNALIGNED_MEMCPY(&xmep->server, &ip->ip_dst, sizeof(ip->ip_dst));
}
-#ifdef INET6
else if (ip6) {
xmep->ipver = 6;
- memcpy(&xmep->client, &ip6->ip6_src, sizeof(ip6->ip6_src));
- memcpy(&xmep->server, &ip6->ip6_dst, sizeof(ip6->ip6_dst));
+ UNALIGNED_MEMCPY(&xmep->client, &ip6->ip6_src, sizeof(ip6->ip6_src));
+ UNALIGNED_MEMCPY(&xmep->server, &ip6->ip6_dst, sizeof(ip6->ip6_dst));
}
-#endif
xmep->proc = EXTRACT_32BITS(&rp->rm_call.cb_proc);
xmep->vers = EXTRACT_32BITS(&rp->rm_call.cb_vers);
return (1);
@@ -985,19 +911,18 @@ xid_map_enter(const struct sunrpc_msg *rp, const u_char *bp)
* Returns 0 and puts NFSPROC_xxx in proc return and
* version in vers return, or returns -1 on failure
*/
-static int32_t
-xid_map_find(const struct sunrpc_msg *rp, const u_char *bp, u_int32_t *proc,
- u_int32_t *vers)
+static int
+xid_map_find(const struct sunrpc_msg *rp, const u_char *bp, uint32_t *proc,
+ uint32_t *vers)
{
int i;
struct xid_map_entry *xmep;
- u_int32_t xid = rp->rm_xid;
- struct ip *ip = (struct ip *)bp;
-#ifdef INET6
- struct ip6_hdr *ip6 = (struct ip6_hdr *)bp;
-#endif
+ uint32_t xid;
+ const struct ip *ip = (const struct ip *)bp;
+ const struct ip6_hdr *ip6 = (const struct ip6_hdr *)bp;
int cmp;
+ UNALIGNED_MEMCPY(&xid, &rp->rm_xid, sizeof(xmep->xid));
/* Start searching from where we last left off */
i = xid_map_hint;
do {
@@ -1007,23 +932,21 @@ xid_map_find(const struct sunrpc_msg *rp, const u_char *bp, u_int32_t *proc,
goto nextitem;
switch (xmep->ipver) {
case 4:
- if (memcmp(&ip->ip_src, &xmep->server,
+ if (UNALIGNED_MEMCMP(&ip->ip_src, &xmep->server,
sizeof(ip->ip_src)) != 0 ||
- memcmp(&ip->ip_dst, &xmep->client,
+ UNALIGNED_MEMCMP(&ip->ip_dst, &xmep->client,
sizeof(ip->ip_dst)) != 0) {
cmp = 0;
}
break;
-#ifdef INET6
case 6:
- if (memcmp(&ip6->ip6_src, &xmep->server,
+ if (UNALIGNED_MEMCMP(&ip6->ip6_src, &xmep->server,
sizeof(ip6->ip6_src)) != 0 ||
- memcmp(&ip6->ip6_dst, &xmep->client,
+ UNALIGNED_MEMCMP(&ip6->ip6_dst, &xmep->client,
sizeof(ip6->ip6_dst)) != 0) {
cmp = 0;
}
break;
-#endif
default:
cmp = 0;
break;
@@ -1052,10 +975,11 @@ xid_map_find(const struct sunrpc_msg *rp, const u_char *bp, u_int32_t *proc,
* Return a pointer to the beginning of the actual results.
* If the packet was truncated, return 0.
*/
-static const u_int32_t *
-parserep(register const struct sunrpc_msg *rp, register u_int length)
+static const uint32_t *
+parserep(netdissect_options *ndo,
+ register const struct sunrpc_msg *rp, register u_int length)
{
- register const u_int32_t *dp;
+ register const uint32_t *dp;
u_int len;
enum sunrpc_accept_stat astat;
@@ -1063,7 +987,7 @@ parserep(register const struct sunrpc_msg *rp, register u_int length)
* Portability note:
* Here we find the address of the ar_verf credentials.
* Originally, this calculation was
- * dp = (u_int32_t *)&rp->rm_reply.rp_acpt.ar_verf
+ * dp = (uint32_t *)&rp->rm_reply.rp_acpt.ar_verf
* On the wire, the rp_acpt field starts immediately after
* the (32 bit) rp_stat field. However, rp_acpt (which is a
* "struct accepted_reply") contains a "struct opaque_auth",
@@ -1074,77 +998,48 @@ parserep(register const struct sunrpc_msg *rp, register u_int length)
* representation. Instead, we skip past the rp_stat field,
* which is an "enum" and so occupies one 32-bit word.
*/
- dp = ((const u_int32_t *)&rp->rm_reply) + 1;
- TCHECK(dp[1]);
+ dp = ((const uint32_t *)&rp->rm_reply) + 1;
+ ND_TCHECK(dp[1]);
len = EXTRACT_32BITS(&dp[1]);
if (len >= length)
return (NULL);
/*
* skip past the ar_verf credentials.
*/
- dp += (len + (2*sizeof(u_int32_t) + 3)) / sizeof(u_int32_t);
- TCHECK2(dp[0], 0);
+ dp += (len + (2*sizeof(uint32_t) + 3)) / sizeof(uint32_t);
+ ND_TCHECK2(dp[0], 0);
/*
* now we can check the ar_stat field
*/
astat = (enum sunrpc_accept_stat) EXTRACT_32BITS(dp);
- switch (astat) {
-
- case SUNRPC_SUCCESS:
- break;
-
- case SUNRPC_PROG_UNAVAIL:
- printf(" PROG_UNAVAIL");
- nfserr = 1; /* suppress trunc string */
- return (NULL);
-
- case SUNRPC_PROG_MISMATCH:
- printf(" PROG_MISMATCH");
- nfserr = 1; /* suppress trunc string */
- return (NULL);
-
- case SUNRPC_PROC_UNAVAIL:
- printf(" PROC_UNAVAIL");
- nfserr = 1; /* suppress trunc string */
- return (NULL);
-
- case SUNRPC_GARBAGE_ARGS:
- printf(" GARBAGE_ARGS");
- nfserr = 1; /* suppress trunc string */
- return (NULL);
-
- case SUNRPC_SYSTEM_ERR:
- printf(" SYSTEM_ERR");
- nfserr = 1; /* suppress trunc string */
- return (NULL);
-
- default:
- printf(" ar_stat %d", astat);
+ if (astat != SUNRPC_SUCCESS) {
+ ND_PRINT((ndo, " %s", tok2str(sunrpc_str, "ar_stat %d", astat)));
nfserr = 1; /* suppress trunc string */
return (NULL);
}
/* successful return */
- TCHECK2(*dp, sizeof(astat));
- return ((u_int32_t *) (sizeof(astat) + ((char *)dp)));
+ ND_TCHECK2(*dp, sizeof(astat));
+ return ((const uint32_t *) (sizeof(astat) + ((const char *)dp)));
trunc:
return (0);
}
-static const u_int32_t *
-parsestatus(const u_int32_t *dp, int *er)
+static const uint32_t *
+parsestatus(netdissect_options *ndo,
+ const uint32_t *dp, int *er)
{
int errnum;
- TCHECK(dp[0]);
+ ND_TCHECK(dp[0]);
errnum = EXTRACT_32BITS(&dp[0]);
if (er)
*er = errnum;
if (errnum != 0) {
- if (!qflag)
- printf(" ERROR: %s",
- tok2str(status2str, "unk %d", errnum));
+ if (!ndo->ndo_qflag)
+ ND_PRINT((ndo, " ERROR: %s",
+ tok2str(status2str, "unk %d", errnum)));
nfserr = 1;
}
return (dp + 1);
@@ -1152,166 +1047,171 @@ trunc:
return NULL;
}
-static const u_int32_t *
-parsefattr(const u_int32_t *dp, int verbose, int v3)
+static const uint32_t *
+parsefattr(netdissect_options *ndo,
+ const uint32_t *dp, int verbose, int v3)
{
const struct nfs_fattr *fap;
fap = (const struct nfs_fattr *)dp;
- TCHECK(fap->fa_gid);
+ ND_TCHECK(fap->fa_gid);
if (verbose) {
- printf(" %s %o ids %d/%d",
+ ND_PRINT((ndo, " %s %o ids %d/%d",
tok2str(type2str, "unk-ft %d ",
EXTRACT_32BITS(&fap->fa_type)),
EXTRACT_32BITS(&fap->fa_mode),
EXTRACT_32BITS(&fap->fa_uid),
- EXTRACT_32BITS(&fap->fa_gid));
+ EXTRACT_32BITS(&fap->fa_gid)));
if (v3) {
- TCHECK(fap->fa3_size);
- printf(" sz %" PRIu64,
- EXTRACT_64BITS((u_int32_t *)&fap->fa3_size));
+ ND_TCHECK(fap->fa3_size);
+ ND_PRINT((ndo, " sz %" PRIu64,
+ EXTRACT_64BITS((const uint32_t *)&fap->fa3_size)));
} else {
- TCHECK(fap->fa2_size);
- printf(" sz %d", EXTRACT_32BITS(&fap->fa2_size));
+ ND_TCHECK(fap->fa2_size);
+ ND_PRINT((ndo, " sz %d", EXTRACT_32BITS(&fap->fa2_size)));
}
}
/* print lots more stuff */
if (verbose > 1) {
if (v3) {
- TCHECK(fap->fa3_ctime);
- printf(" nlink %d rdev %d/%d",
+ ND_TCHECK(fap->fa3_ctime);
+ ND_PRINT((ndo, " nlink %d rdev %d/%d",
EXTRACT_32BITS(&fap->fa_nlink),
EXTRACT_32BITS(&fap->fa3_rdev.specdata1),
- EXTRACT_32BITS(&fap->fa3_rdev.specdata2));
- printf(" fsid %" PRIx64,
- EXTRACT_64BITS((u_int32_t *)&fap->fa3_fsid));
- printf(" fileid %" PRIx64,
- EXTRACT_64BITS((u_int32_t *)&fap->fa3_fileid));
- printf(" a/m/ctime %u.%06u",
+ EXTRACT_32BITS(&fap->fa3_rdev.specdata2)));
+ ND_PRINT((ndo, " fsid %" PRIx64,
+ EXTRACT_64BITS((const uint32_t *)&fap->fa3_fsid)));
+ ND_PRINT((ndo, " fileid %" PRIx64,
+ EXTRACT_64BITS((const uint32_t *)&fap->fa3_fileid)));
+ ND_PRINT((ndo, " a/m/ctime %u.%06u",
EXTRACT_32BITS(&fap->fa3_atime.nfsv3_sec),
- EXTRACT_32BITS(&fap->fa3_atime.nfsv3_nsec));
- printf(" %u.%06u",
+ EXTRACT_32BITS(&fap->fa3_atime.nfsv3_nsec)));
+ ND_PRINT((ndo, " %u.%06u",
EXTRACT_32BITS(&fap->fa3_mtime.nfsv3_sec),
- EXTRACT_32BITS(&fap->fa3_mtime.nfsv3_nsec));
- printf(" %u.%06u",
+ EXTRACT_32BITS(&fap->fa3_mtime.nfsv3_nsec)));
+ ND_PRINT((ndo, " %u.%06u",
EXTRACT_32BITS(&fap->fa3_ctime.nfsv3_sec),
- EXTRACT_32BITS(&fap->fa3_ctime.nfsv3_nsec));
+ EXTRACT_32BITS(&fap->fa3_ctime.nfsv3_nsec)));
} else {
- TCHECK(fap->fa2_ctime);
- printf(" nlink %d rdev %x fsid %x nodeid %x a/m/ctime",
+ ND_TCHECK(fap->fa2_ctime);
+ ND_PRINT((ndo, " nlink %d rdev 0x%x fsid 0x%x nodeid 0x%x a/m/ctime",
EXTRACT_32BITS(&fap->fa_nlink),
EXTRACT_32BITS(&fap->fa2_rdev),
EXTRACT_32BITS(&fap->fa2_fsid),
- EXTRACT_32BITS(&fap->fa2_fileid));
- printf(" %u.%06u",
+ EXTRACT_32BITS(&fap->fa2_fileid)));
+ ND_PRINT((ndo, " %u.%06u",
EXTRACT_32BITS(&fap->fa2_atime.nfsv2_sec),
- EXTRACT_32BITS(&fap->fa2_atime.nfsv2_usec));
- printf(" %u.%06u",
+ EXTRACT_32BITS(&fap->fa2_atime.nfsv2_usec)));
+ ND_PRINT((ndo, " %u.%06u",
EXTRACT_32BITS(&fap->fa2_mtime.nfsv2_sec),
- EXTRACT_32BITS(&fap->fa2_mtime.nfsv2_usec));
- printf(" %u.%06u",
+ EXTRACT_32BITS(&fap->fa2_mtime.nfsv2_usec)));
+ ND_PRINT((ndo, " %u.%06u",
EXTRACT_32BITS(&fap->fa2_ctime.nfsv2_sec),
- EXTRACT_32BITS(&fap->fa2_ctime.nfsv2_usec));
+ EXTRACT_32BITS(&fap->fa2_ctime.nfsv2_usec)));
}
}
- return ((const u_int32_t *)((unsigned char *)dp +
+ return ((const uint32_t *)((const unsigned char *)dp +
(v3 ? NFSX_V3FATTR : NFSX_V2FATTR)));
trunc:
return (NULL);
}
static int
-parseattrstat(const u_int32_t *dp, int verbose, int v3)
+parseattrstat(netdissect_options *ndo,
+ const uint32_t *dp, int verbose, int v3)
{
int er;
- dp = parsestatus(dp, &er);
+ dp = parsestatus(ndo, dp, &er);
if (dp == NULL)
return (0);
if (er)
return (1);
- return (parsefattr(dp, verbose, v3) != NULL);
+ return (parsefattr(ndo, dp, verbose, v3) != NULL);
}
static int
-parsediropres(const u_int32_t *dp)
+parsediropres(netdissect_options *ndo,
+ const uint32_t *dp)
{
int er;
- if (!(dp = parsestatus(dp, &er)))
+ if (!(dp = parsestatus(ndo, dp, &er)))
return (0);
if (er)
return (1);
- dp = parsefh(dp, 0);
+ dp = parsefh(ndo, dp, 0);
if (dp == NULL)
return (0);
- return (parsefattr(dp, vflag, 0) != NULL);
+ return (parsefattr(ndo, dp, ndo->ndo_vflag, 0) != NULL);
}
static int
-parselinkres(const u_int32_t *dp, int v3)
+parselinkres(netdissect_options *ndo,
+ const uint32_t *dp, int v3)
{
int er;
- dp = parsestatus(dp, &er);
+ dp = parsestatus(ndo, dp, &er);
if (dp == NULL)
return(0);
if (er)
return(1);
- if (v3 && !(dp = parse_post_op_attr(dp, vflag)))
+ if (v3 && !(dp = parse_post_op_attr(ndo, dp, ndo->ndo_vflag)))
return (0);
- putchar(' ');
- return (parsefn(dp) != NULL);
+ ND_PRINT((ndo, " "));
+ return (parsefn(ndo, dp) != NULL);
}
static int
-parsestatfs(const u_int32_t *dp, int v3)
+parsestatfs(netdissect_options *ndo,
+ const uint32_t *dp, int v3)
{
const struct nfs_statfs *sfsp;
int er;
- dp = parsestatus(dp, &er);
+ dp = parsestatus(ndo, dp, &er);
if (dp == NULL)
return (0);
if (!v3 && er)
return (1);
- if (qflag)
+ if (ndo->ndo_qflag)
return(1);
if (v3) {
- if (vflag)
- printf(" POST:");
- if (!(dp = parse_post_op_attr(dp, vflag)))
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo, " POST:"));
+ if (!(dp = parse_post_op_attr(ndo, dp, ndo->ndo_vflag)))
return (0);
}
- TCHECK2(*dp, (v3 ? NFSX_V3STATFS : NFSX_V2STATFS));
+ ND_TCHECK2(*dp, (v3 ? NFSX_V3STATFS : NFSX_V2STATFS));
sfsp = (const struct nfs_statfs *)dp;
if (v3) {
- printf(" tbytes %" PRIu64 " fbytes %" PRIu64 " abytes %" PRIu64,
- EXTRACT_64BITS((u_int32_t *)&sfsp->sf_tbytes),
- EXTRACT_64BITS((u_int32_t *)&sfsp->sf_fbytes),
- EXTRACT_64BITS((u_int32_t *)&sfsp->sf_abytes));
- if (vflag) {
- printf(" tfiles %" PRIu64 " ffiles %" PRIu64 " afiles %" PRIu64 " invar %u",
- EXTRACT_64BITS((u_int32_t *)&sfsp->sf_tfiles),
- EXTRACT_64BITS((u_int32_t *)&sfsp->sf_ffiles),
- EXTRACT_64BITS((u_int32_t *)&sfsp->sf_afiles),
- EXTRACT_32BITS(&sfsp->sf_invarsec));
+ ND_PRINT((ndo, " tbytes %" PRIu64 " fbytes %" PRIu64 " abytes %" PRIu64,
+ EXTRACT_64BITS((const uint32_t *)&sfsp->sf_tbytes),
+ EXTRACT_64BITS((const uint32_t *)&sfsp->sf_fbytes),
+ EXTRACT_64BITS((const uint32_t *)&sfsp->sf_abytes)));
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo, " tfiles %" PRIu64 " ffiles %" PRIu64 " afiles %" PRIu64 " invar %u",
+ EXTRACT_64BITS((const uint32_t *)&sfsp->sf_tfiles),
+ EXTRACT_64BITS((const uint32_t *)&sfsp->sf_ffiles),
+ EXTRACT_64BITS((const uint32_t *)&sfsp->sf_afiles),
+ EXTRACT_32BITS(&sfsp->sf_invarsec)));
}
} else {
- printf(" tsize %d bsize %d blocks %d bfree %d bavail %d",
+ ND_PRINT((ndo, " tsize %d bsize %d blocks %d bfree %d bavail %d",
EXTRACT_32BITS(&sfsp->sf_tsize),
EXTRACT_32BITS(&sfsp->sf_bsize),
EXTRACT_32BITS(&sfsp->sf_blocks),
EXTRACT_32BITS(&sfsp->sf_bfree),
- EXTRACT_32BITS(&sfsp->sf_bavail));
+ EXTRACT_32BITS(&sfsp->sf_bavail)));
}
return (1);
@@ -1320,52 +1220,55 @@ trunc:
}
static int
-parserddires(const u_int32_t *dp)
+parserddires(netdissect_options *ndo,
+ const uint32_t *dp)
{
int er;
- dp = parsestatus(dp, &er);
+ dp = parsestatus(ndo, dp, &er);
if (dp == NULL)
return (0);
if (er)
return (1);
- if (qflag)
+ if (ndo->ndo_qflag)
return (1);
- TCHECK(dp[2]);
- printf(" offset %x size %d ",
- EXTRACT_32BITS(&dp[0]), EXTRACT_32BITS(&dp[1]));
+ ND_TCHECK(dp[2]);
+ ND_PRINT((ndo, " offset 0x%x size %d ",
+ EXTRACT_32BITS(&dp[0]), EXTRACT_32BITS(&dp[1])));
if (dp[2] != 0)
- printf(" eof");
+ ND_PRINT((ndo, " eof"));
return (1);
trunc:
return (0);
}
-static const u_int32_t *
-parse_wcc_attr(const u_int32_t *dp)
+static const uint32_t *
+parse_wcc_attr(netdissect_options *ndo,
+ const uint32_t *dp)
{
- printf(" sz %" PRIu64, EXTRACT_64BITS(&dp[0]));
- printf(" mtime %u.%06u ctime %u.%06u",
+ ND_PRINT((ndo, " sz %" PRIu64, EXTRACT_64BITS(&dp[0])));
+ ND_PRINT((ndo, " mtime %u.%06u ctime %u.%06u",
EXTRACT_32BITS(&dp[2]), EXTRACT_32BITS(&dp[3]),
- EXTRACT_32BITS(&dp[4]), EXTRACT_32BITS(&dp[5]));
+ EXTRACT_32BITS(&dp[4]), EXTRACT_32BITS(&dp[5])));
return (dp + 6);
}
/*
* Pre operation attributes. Print only if vflag > 1.
*/
-static const u_int32_t *
-parse_pre_op_attr(const u_int32_t *dp, int verbose)
+static const uint32_t *
+parse_pre_op_attr(netdissect_options *ndo,
+ const uint32_t *dp, int verbose)
{
- TCHECK(dp[0]);
+ ND_TCHECK(dp[0]);
if (!EXTRACT_32BITS(&dp[0]))
return (dp + 1);
dp++;
- TCHECK2(*dp, 24);
+ ND_TCHECK2(*dp, 24);
if (verbose > 1) {
- return parse_wcc_attr(dp);
+ return parse_wcc_attr(ndo, dp);
} else {
/* If not verbose enough, just skip over wcc_attr */
return (dp + 6);
@@ -1377,56 +1280,59 @@ trunc:
/*
* Post operation attributes are printed if vflag >= 1
*/
-static const u_int32_t *
-parse_post_op_attr(const u_int32_t *dp, int verbose)
+static const uint32_t *
+parse_post_op_attr(netdissect_options *ndo,
+ const uint32_t *dp, int verbose)
{
- TCHECK(dp[0]);
+ ND_TCHECK(dp[0]);
if (!EXTRACT_32BITS(&dp[0]))
return (dp + 1);
dp++;
if (verbose) {
- return parsefattr(dp, verbose, 1);
+ return parsefattr(ndo, dp, verbose, 1);
} else
- return (dp + (NFSX_V3FATTR / sizeof (u_int32_t)));
+ return (dp + (NFSX_V3FATTR / sizeof (uint32_t)));
trunc:
return (NULL);
}
-static const u_int32_t *
-parse_wcc_data(const u_int32_t *dp, int verbose)
+static const uint32_t *
+parse_wcc_data(netdissect_options *ndo,
+ const uint32_t *dp, int verbose)
{
if (verbose > 1)
- printf(" PRE:");
- if (!(dp = parse_pre_op_attr(dp, verbose)))
+ ND_PRINT((ndo, " PRE:"));
+ if (!(dp = parse_pre_op_attr(ndo, dp, verbose)))
return (0);
if (verbose)
- printf(" POST:");
- return parse_post_op_attr(dp, verbose);
+ ND_PRINT((ndo, " POST:"));
+ return parse_post_op_attr(ndo, dp, verbose);
}
-static const u_int32_t *
-parsecreateopres(const u_int32_t *dp, int verbose)
+static const uint32_t *
+parsecreateopres(netdissect_options *ndo,
+ const uint32_t *dp, int verbose)
{
int er;
- if (!(dp = parsestatus(dp, &er)))
+ if (!(dp = parsestatus(ndo, dp, &er)))
return (0);
if (er)
- dp = parse_wcc_data(dp, verbose);
+ dp = parse_wcc_data(ndo, dp, verbose);
else {
- TCHECK(dp[0]);
+ ND_TCHECK(dp[0]);
if (!EXTRACT_32BITS(&dp[0]))
return (dp + 1);
dp++;
- if (!(dp = parsefh(dp, 1)))
+ if (!(dp = parsefh(ndo, dp, 1)))
return (0);
if (verbose) {
- if (!(dp = parse_post_op_attr(dp, verbose)))
+ if (!(dp = parse_post_op_attr(ndo, dp, verbose)))
return (0);
- if (vflag > 1) {
- printf(" dir attr:");
- dp = parse_wcc_data(dp, verbose);
+ if (ndo->ndo_vflag > 1) {
+ ND_PRINT((ndo, " dir attr:"));
+ dp = parse_wcc_data(ndo, dp, verbose);
}
}
}
@@ -1436,31 +1342,33 @@ trunc:
}
static int
-parsewccres(const u_int32_t *dp, int verbose)
+parsewccres(netdissect_options *ndo,
+ const uint32_t *dp, int verbose)
{
int er;
- if (!(dp = parsestatus(dp, &er)))
+ if (!(dp = parsestatus(ndo, dp, &er)))
return (0);
- return parse_wcc_data(dp, verbose) != 0;
+ return parse_wcc_data(ndo, dp, verbose) != NULL;
}
-static const u_int32_t *
-parsev3rddirres(const u_int32_t *dp, int verbose)
+static const uint32_t *
+parsev3rddirres(netdissect_options *ndo,
+ const uint32_t *dp, int verbose)
{
int er;
- if (!(dp = parsestatus(dp, &er)))
+ if (!(dp = parsestatus(ndo, dp, &er)))
return (0);
- if (vflag)
- printf(" POST:");
- if (!(dp = parse_post_op_attr(dp, verbose)))
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo, " POST:"));
+ if (!(dp = parse_post_op_attr(ndo, dp, verbose)))
return (0);
if (er)
return dp;
- if (vflag) {
- TCHECK(dp[1]);
- printf(" verf %08x%08x", dp[0], dp[1]);
+ if (ndo->ndo_vflag) {
+ ND_TCHECK(dp[1]);
+ ND_PRINT((ndo, " verf %08x%08x", dp[0], dp[1]));
dp += 2;
}
return dp;
@@ -1469,36 +1377,37 @@ trunc:
}
static int
-parsefsinfo(const u_int32_t *dp)
+parsefsinfo(netdissect_options *ndo,
+ const uint32_t *dp)
{
- struct nfsv3_fsinfo *sfp;
+ const struct nfsv3_fsinfo *sfp;
int er;
- if (!(dp = parsestatus(dp, &er)))
+ if (!(dp = parsestatus(ndo, dp, &er)))
return (0);
- if (vflag)
- printf(" POST:");
- if (!(dp = parse_post_op_attr(dp, vflag)))
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo, " POST:"));
+ if (!(dp = parse_post_op_attr(ndo, dp, ndo->ndo_vflag)))
return (0);
if (er)
return (1);
- sfp = (struct nfsv3_fsinfo *)dp;
- TCHECK(*sfp);
- printf(" rtmax %u rtpref %u wtmax %u wtpref %u dtpref %u",
+ sfp = (const struct nfsv3_fsinfo *)dp;
+ ND_TCHECK(*sfp);
+ ND_PRINT((ndo, " rtmax %u rtpref %u wtmax %u wtpref %u dtpref %u",
EXTRACT_32BITS(&sfp->fs_rtmax),
EXTRACT_32BITS(&sfp->fs_rtpref),
EXTRACT_32BITS(&sfp->fs_wtmax),
EXTRACT_32BITS(&sfp->fs_wtpref),
- EXTRACT_32BITS(&sfp->fs_dtpref));
- if (vflag) {
- printf(" rtmult %u wtmult %u maxfsz %" PRIu64,
+ EXTRACT_32BITS(&sfp->fs_dtpref)));
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo, " rtmult %u wtmult %u maxfsz %" PRIu64,
EXTRACT_32BITS(&sfp->fs_rtmult),
EXTRACT_32BITS(&sfp->fs_wtmult),
- EXTRACT_64BITS((u_int32_t *)&sfp->fs_maxfilesize));
- printf(" delta %u.%06u ",
+ EXTRACT_64BITS((const uint32_t *)&sfp->fs_maxfilesize)));
+ ND_PRINT((ndo, " delta %u.%06u ",
EXTRACT_32BITS(&sfp->fs_timedelta.nfsv3_sec),
- EXTRACT_32BITS(&sfp->fs_timedelta.nfsv3_nsec));
+ EXTRACT_32BITS(&sfp->fs_timedelta.nfsv3_nsec)));
}
return (1);
trunc:
@@ -1506,39 +1415,41 @@ trunc:
}
static int
-parsepathconf(const u_int32_t *dp)
+parsepathconf(netdissect_options *ndo,
+ const uint32_t *dp)
{
int er;
- struct nfsv3_pathconf *spp;
+ const struct nfsv3_pathconf *spp;
- if (!(dp = parsestatus(dp, &er)))
+ if (!(dp = parsestatus(ndo, dp, &er)))
return (0);
- if (vflag)
- printf(" POST:");
- if (!(dp = parse_post_op_attr(dp, vflag)))
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo, " POST:"));
+ if (!(dp = parse_post_op_attr(ndo, dp, ndo->ndo_vflag)))
return (0);
if (er)
return (1);
- spp = (struct nfsv3_pathconf *)dp;
- TCHECK(*spp);
+ spp = (const struct nfsv3_pathconf *)dp;
+ ND_TCHECK(*spp);
- printf(" linkmax %u namemax %u %s %s %s %s",
+ ND_PRINT((ndo, " linkmax %u namemax %u %s %s %s %s",
EXTRACT_32BITS(&spp->pc_linkmax),
EXTRACT_32BITS(&spp->pc_namemax),
EXTRACT_32BITS(&spp->pc_notrunc) ? "notrunc" : "",
EXTRACT_32BITS(&spp->pc_chownrestricted) ? "chownres" : "",
EXTRACT_32BITS(&spp->pc_caseinsensitive) ? "igncase" : "",
- EXTRACT_32BITS(&spp->pc_casepreserving) ? "keepcase" : "");
+ EXTRACT_32BITS(&spp->pc_casepreserving) ? "keepcase" : ""));
return (1);
trunc:
return (0);
}
static void
-interp_reply(const struct sunrpc_msg *rp, u_int32_t proc, u_int32_t vers, int length)
+interp_reply(netdissect_options *ndo,
+ const struct sunrpc_msg *rp, uint32_t proc, uint32_t vers, int length)
{
- register const u_int32_t *dp;
+ register const uint32_t *dp;
register int v3;
int er;
@@ -1547,309 +1458,261 @@ interp_reply(const struct sunrpc_msg *rp, u_int32_t proc, u_int32_t vers, int le
if (!v3 && proc < NFS_NPROCS)
proc = nfsv3_procid[proc];
+ ND_PRINT((ndo, " %s", tok2str(nfsproc_str, "proc-%u", proc)));
switch (proc) {
- case NFSPROC_NOOP:
- printf(" nop");
- return;
-
- case NFSPROC_NULL:
- printf(" null");
- return;
-
case NFSPROC_GETATTR:
- printf(" getattr");
- dp = parserep(rp, length);
- if (dp != NULL && parseattrstat(dp, !qflag, v3) != 0)
+ dp = parserep(ndo, rp, length);
+ if (dp != NULL && parseattrstat(ndo, dp, !ndo->ndo_qflag, v3) != 0)
return;
break;
case NFSPROC_SETATTR:
- printf(" setattr");
- if (!(dp = parserep(rp, length)))
+ if (!(dp = parserep(ndo, rp, length)))
return;
if (v3) {
- if (parsewccres(dp, vflag))
+ if (parsewccres(ndo, dp, ndo->ndo_vflag))
return;
} else {
- if (parseattrstat(dp, !qflag, 0) != 0)
+ if (parseattrstat(ndo, dp, !ndo->ndo_qflag, 0) != 0)
return;
}
break;
case NFSPROC_LOOKUP:
- printf(" lookup");
- if (!(dp = parserep(rp, length)))
+ if (!(dp = parserep(ndo, rp, length)))
break;
if (v3) {
- if (!(dp = parsestatus(dp, &er)))
+ if (!(dp = parsestatus(ndo, dp, &er)))
break;
if (er) {
- if (vflag > 1) {
- printf(" post dattr:");
- dp = parse_post_op_attr(dp, vflag);
+ if (ndo->ndo_vflag > 1) {
+ ND_PRINT((ndo, " post dattr:"));
+ dp = parse_post_op_attr(ndo, dp, ndo->ndo_vflag);
}
} else {
- if (!(dp = parsefh(dp, v3)))
+ if (!(dp = parsefh(ndo, dp, v3)))
break;
- if ((dp = parse_post_op_attr(dp, vflag)) &&
- vflag > 1) {
- printf(" post dattr:");
- dp = parse_post_op_attr(dp, vflag);
+ if ((dp = parse_post_op_attr(ndo, dp, ndo->ndo_vflag)) &&
+ ndo->ndo_vflag > 1) {
+ ND_PRINT((ndo, " post dattr:"));
+ dp = parse_post_op_attr(ndo, dp, ndo->ndo_vflag);
}
}
if (dp)
return;
} else {
- if (parsediropres(dp) != 0)
+ if (parsediropres(ndo, dp) != 0)
return;
}
break;
case NFSPROC_ACCESS:
- printf(" access");
- if (!(dp = parserep(rp, length)))
+ if (!(dp = parserep(ndo, rp, length)))
break;
- if (!(dp = parsestatus(dp, &er)))
+ if (!(dp = parsestatus(ndo, dp, &er)))
break;
- if (vflag)
- printf(" attr:");
- if (!(dp = parse_post_op_attr(dp, vflag)))
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo, " attr:"));
+ if (!(dp = parse_post_op_attr(ndo, dp, ndo->ndo_vflag)))
break;
if (!er)
- printf(" c %04x", EXTRACT_32BITS(&dp[0]));
+ ND_PRINT((ndo, " c %04x", EXTRACT_32BITS(&dp[0])));
return;
case NFSPROC_READLINK:
- printf(" readlink");
- dp = parserep(rp, length);
- if (dp != NULL && parselinkres(dp, v3) != 0)
+ dp = parserep(ndo, rp, length);
+ if (dp != NULL && parselinkres(ndo, dp, v3) != 0)
return;
break;
case NFSPROC_READ:
- printf(" read");
- if (!(dp = parserep(rp, length)))
+ if (!(dp = parserep(ndo, rp, length)))
break;
if (v3) {
- if (!(dp = parsestatus(dp, &er)))
+ if (!(dp = parsestatus(ndo, dp, &er)))
break;
- if (!(dp = parse_post_op_attr(dp, vflag)))
+ if (!(dp = parse_post_op_attr(ndo, dp, ndo->ndo_vflag)))
break;
if (er)
return;
- if (vflag) {
- TCHECK(dp[1]);
- printf(" %u bytes", EXTRACT_32BITS(&dp[0]));
+ if (ndo->ndo_vflag) {
+ ND_TCHECK(dp[1]);
+ ND_PRINT((ndo, " %u bytes", EXTRACT_32BITS(&dp[0])));
if (EXTRACT_32BITS(&dp[1]))
- printf(" EOF");
+ ND_PRINT((ndo, " EOF"));
}
return;
} else {
- if (parseattrstat(dp, vflag, 0) != 0)
+ if (parseattrstat(ndo, dp, ndo->ndo_vflag, 0) != 0)
return;
}
break;
case NFSPROC_WRITE:
- printf(" write");
- if (!(dp = parserep(rp, length)))
+ if (!(dp = parserep(ndo, rp, length)))
break;
if (v3) {
- if (!(dp = parsestatus(dp, &er)))
+ if (!(dp = parsestatus(ndo, dp, &er)))
break;
- if (!(dp = parse_wcc_data(dp, vflag)))
+ if (!(dp = parse_wcc_data(ndo, dp, ndo->ndo_vflag)))
break;
if (er)
return;
- if (vflag) {
- TCHECK(dp[0]);
- printf(" %u bytes", EXTRACT_32BITS(&dp[0]));
- if (vflag > 1) {
- TCHECK(dp[1]);
- printf(" <%s>",
+ if (ndo->ndo_vflag) {
+ ND_TCHECK(dp[0]);
+ ND_PRINT((ndo, " %u bytes", EXTRACT_32BITS(&dp[0])));
+ if (ndo->ndo_vflag > 1) {
+ ND_TCHECK(dp[1]);
+ ND_PRINT((ndo, " <%s>",
tok2str(nfsv3_writemodes,
- NULL, EXTRACT_32BITS(&dp[1])));
+ NULL, EXTRACT_32BITS(&dp[1]))));
}
return;
}
} else {
- if (parseattrstat(dp, vflag, v3) != 0)
+ if (parseattrstat(ndo, dp, ndo->ndo_vflag, v3) != 0)
return;
}
break;
case NFSPROC_CREATE:
- printf(" create");
- if (!(dp = parserep(rp, length)))
- break;
- if (v3) {
- if (parsecreateopres(dp, vflag) != 0)
- return;
- } else {
- if (parsediropres(dp) != 0)
- return;
- }
- break;
-
case NFSPROC_MKDIR:
- printf(" mkdir");
- if (!(dp = parserep(rp, length)))
+ if (!(dp = parserep(ndo, rp, length)))
break;
if (v3) {
- if (parsecreateopres(dp, vflag) != 0)
+ if (parsecreateopres(ndo, dp, ndo->ndo_vflag) != NULL)
return;
} else {
- if (parsediropres(dp) != 0)
+ if (parsediropres(ndo, dp) != 0)
return;
}
break;
case NFSPROC_SYMLINK:
- printf(" symlink");
- if (!(dp = parserep(rp, length)))
+ if (!(dp = parserep(ndo, rp, length)))
break;
if (v3) {
- if (parsecreateopres(dp, vflag) != 0)
+ if (parsecreateopres(ndo, dp, ndo->ndo_vflag) != NULL)
return;
} else {
- if (parsestatus(dp, &er) != 0)
+ if (parsestatus(ndo, dp, &er) != NULL)
return;
}
break;
case NFSPROC_MKNOD:
- printf(" mknod");
- if (!(dp = parserep(rp, length)))
+ if (!(dp = parserep(ndo, rp, length)))
break;
- if (parsecreateopres(dp, vflag) != 0)
+ if (parsecreateopres(ndo, dp, ndo->ndo_vflag) != NULL)
return;
break;
case NFSPROC_REMOVE:
- printf(" remove");
- if (!(dp = parserep(rp, length)))
- break;
- if (v3) {
- if (parsewccres(dp, vflag))
- return;
- } else {
- if (parsestatus(dp, &er) != 0)
- return;
- }
- break;
-
case NFSPROC_RMDIR:
- printf(" rmdir");
- if (!(dp = parserep(rp, length)))
+ if (!(dp = parserep(ndo, rp, length)))
break;
if (v3) {
- if (parsewccres(dp, vflag))
+ if (parsewccres(ndo, dp, ndo->ndo_vflag))
return;
} else {
- if (parsestatus(dp, &er) != 0)
+ if (parsestatus(ndo, dp, &er) != NULL)
return;
}
break;
case NFSPROC_RENAME:
- printf(" rename");
- if (!(dp = parserep(rp, length)))
+ if (!(dp = parserep(ndo, rp, length)))
break;
if (v3) {
- if (!(dp = parsestatus(dp, &er)))
+ if (!(dp = parsestatus(ndo, dp, &er)))
break;
- if (vflag) {
- printf(" from:");
- if (!(dp = parse_wcc_data(dp, vflag)))
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo, " from:"));
+ if (!(dp = parse_wcc_data(ndo, dp, ndo->ndo_vflag)))
break;
- printf(" to:");
- if (!(dp = parse_wcc_data(dp, vflag)))
+ ND_PRINT((ndo, " to:"));
+ if (!(dp = parse_wcc_data(ndo, dp, ndo->ndo_vflag)))
break;
}
return;
} else {
- if (parsestatus(dp, &er) != 0)
+ if (parsestatus(ndo, dp, &er) != NULL)
return;
}
break;
case NFSPROC_LINK:
- printf(" link");
- if (!(dp = parserep(rp, length)))
+ if (!(dp = parserep(ndo, rp, length)))
break;
if (v3) {
- if (!(dp = parsestatus(dp, &er)))
+ if (!(dp = parsestatus(ndo, dp, &er)))
break;
- if (vflag) {
- printf(" file POST:");
- if (!(dp = parse_post_op_attr(dp, vflag)))
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo, " file POST:"));
+ if (!(dp = parse_post_op_attr(ndo, dp, ndo->ndo_vflag)))
break;
- printf(" dir:");
- if (!(dp = parse_wcc_data(dp, vflag)))
+ ND_PRINT((ndo, " dir:"));
+ if (!(dp = parse_wcc_data(ndo, dp, ndo->ndo_vflag)))
break;
return;
}
} else {
- if (parsestatus(dp, &er) != 0)
+ if (parsestatus(ndo, dp, &er) != NULL)
return;
}
break;
case NFSPROC_READDIR:
- printf(" readdir");
- if (!(dp = parserep(rp, length)))
+ if (!(dp = parserep(ndo, rp, length)))
break;
if (v3) {
- if (parsev3rddirres(dp, vflag))
+ if (parsev3rddirres(ndo, dp, ndo->ndo_vflag))
return;
} else {
- if (parserddires(dp) != 0)
+ if (parserddires(ndo, dp) != 0)
return;
}
break;
case NFSPROC_READDIRPLUS:
- printf(" readdirplus");
- if (!(dp = parserep(rp, length)))
+ if (!(dp = parserep(ndo, rp, length)))
break;
- if (parsev3rddirres(dp, vflag))
+ if (parsev3rddirres(ndo, dp, ndo->ndo_vflag))
return;
break;
case NFSPROC_FSSTAT:
- printf(" fsstat");
- dp = parserep(rp, length);
- if (dp != NULL && parsestatfs(dp, v3) != 0)
+ dp = parserep(ndo, rp, length);
+ if (dp != NULL && parsestatfs(ndo, dp, v3) != 0)
return;
break;
case NFSPROC_FSINFO:
- printf(" fsinfo");
- dp = parserep(rp, length);
- if (dp != NULL && parsefsinfo(dp) != 0)
+ dp = parserep(ndo, rp, length);
+ if (dp != NULL && parsefsinfo(ndo, dp) != 0)
return;
break;
case NFSPROC_PATHCONF:
- printf(" pathconf");
- dp = parserep(rp, length);
- if (dp != NULL && parsepathconf(dp) != 0)
+ dp = parserep(ndo, rp, length);
+ if (dp != NULL && parsepathconf(ndo, dp) != 0)
return;
break;
case NFSPROC_COMMIT:
- printf(" commit");
- dp = parserep(rp, length);
- if (dp != NULL && parsewccres(dp, vflag) != 0)
+ dp = parserep(ndo, rp, length);
+ if (dp != NULL && parsewccres(ndo, dp, ndo->ndo_vflag) != 0)
return;
break;
default:
- printf(" proc-%u", proc);
return;
}
trunc:
if (!nfserr)
- fputs(" [|nfs]", stdout);
+ ND_PRINT((ndo, "%s", tstr));
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-nfs-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-nsh.c b/freebsd/contrib/tcpdump/print-nsh.c
new file mode 100644
index 00000000..764b96b0
--- /dev/null
+++ b/freebsd/contrib/tcpdump/print-nsh.c
@@ -0,0 +1,193 @@
+#include <machine/rtems-bsd-user-space.h>
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
+/* Copyright (c) 2015, bugyo
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT OWNER 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: Network Service Header (NSH) printer */
+
+/* specification: draft-ietf-sfc-nsh-01 */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <netdissect-stdinc.h>
+
+#include "netdissect.h"
+#include "extract.h"
+
+static const char tstr[] = " [|NSH]";
+static const struct tok nsh_flags [] = {
+ { 0x20, "O" },
+ { 0x10, "C" },
+ { 0, NULL }
+};
+
+#define NSH_BASE_HDR_LEN 4
+#define NSH_SERVICE_PATH_HDR_LEN 4
+#define NSH_HDR_WORD_SIZE 4U
+
+void
+nsh_print(netdissect_options *ndo, const u_char *bp, u_int len)
+{
+ int n, vn;
+ uint8_t ver;
+ uint8_t flags;
+ uint8_t length;
+ uint8_t md_type;
+ uint8_t next_protocol;
+ uint32_t service_path_id;
+ uint8_t service_index;
+ uint32_t ctx;
+ uint16_t tlv_class;
+ uint8_t tlv_type;
+ uint8_t tlv_len;
+ u_int next_len;
+
+ /* print Base Header and Service Path Header */
+ if (len < NSH_BASE_HDR_LEN + NSH_SERVICE_PATH_HDR_LEN)
+ goto trunc;
+
+ ND_TCHECK2(*bp, NSH_BASE_HDR_LEN + NSH_SERVICE_PATH_HDR_LEN);
+
+ ver = (uint8_t)(*bp >> 6);
+ flags = *bp;
+ bp += 1;
+ length = *bp;
+ bp += 1;
+ md_type = *bp;
+ bp += 1;
+ next_protocol = *bp;
+ bp += 1;
+ service_path_id = EXTRACT_24BITS(bp);
+ bp += 3;
+ service_index = *bp;
+ bp += 1;
+
+ ND_PRINT((ndo, "NSH, "));
+ if (ndo->ndo_vflag > 1) {
+ ND_PRINT((ndo, "ver %d, ", ver));
+ }
+ ND_PRINT((ndo, "flags [%s], ", bittok2str_nosep(nsh_flags, "none", flags)));
+ if (ndo->ndo_vflag > 2) {
+ ND_PRINT((ndo, "length %d, ", length));
+ ND_PRINT((ndo, "md type 0x%x, ", md_type));
+ }
+ if (ndo->ndo_vflag > 1) {
+ ND_PRINT((ndo, "next-protocol 0x%x, ", next_protocol));
+ }
+ ND_PRINT((ndo, "service-path-id 0x%06x, ", service_path_id));
+ ND_PRINT((ndo, "service-index 0x%x", service_index));
+
+ /* Make sure we have all the headers */
+ if (len < length * NSH_HDR_WORD_SIZE)
+ goto trunc;
+
+ ND_TCHECK2(*bp, length * NSH_HDR_WORD_SIZE);
+
+ /*
+ * length includes the lengths of the Base and Service Path headers.
+ * That means it must be at least 2.
+ */
+ if (length < 2)
+ goto trunc;
+
+ /*
+ * Print, or skip, the Context Headers.
+ * (length - 2) is the length of those headers.
+ */
+ if (ndo->ndo_vflag > 2) {
+ if (md_type == 0x01) {
+ for (n = 0; n < length - 2; n++) {
+ ctx = EXTRACT_32BITS(bp);
+ bp += NSH_HDR_WORD_SIZE;
+ ND_PRINT((ndo, "\n Context[%02d]: 0x%08x", n, ctx));
+ }
+ }
+ else if (md_type == 0x02) {
+ n = 0;
+ while (n < length - 2) {
+ tlv_class = EXTRACT_16BITS(bp);
+ bp += 2;
+ tlv_type = *bp;
+ bp += 1;
+ tlv_len = *bp;
+ bp += 1;
+
+ ND_PRINT((ndo, "\n TLV Class %d, Type %d, Len %d",
+ tlv_class, tlv_type, tlv_len));
+
+ n += 1;
+
+ if (length - 2 < n + tlv_len) {
+ ND_PRINT((ndo, " ERROR: invalid-tlv-length"));
+ return;
+ }
+
+ for (vn = 0; vn < tlv_len; vn++) {
+ ctx = EXTRACT_32BITS(bp);
+ bp += NSH_HDR_WORD_SIZE;
+ ND_PRINT((ndo, "\n Value[%02d]: 0x%08x", vn, ctx));
+ }
+ n += tlv_len;
+ }
+ }
+ else {
+ ND_PRINT((ndo, "ERROR: unknown-next-protocol"));
+ return;
+ }
+ }
+ else {
+ bp += (length - 2) * NSH_HDR_WORD_SIZE;
+ }
+ ND_PRINT((ndo, ndo->ndo_vflag ? "\n " : ": "));
+
+ /* print Next Protocol */
+ next_len = len - length * NSH_HDR_WORD_SIZE;
+ switch (next_protocol) {
+ case 0x1:
+ ip_print(ndo, bp, next_len);
+ break;
+ case 0x2:
+ ip6_print(ndo, bp, next_len);
+ break;
+ case 0x3:
+ ether_print(ndo, bp, next_len, ndo->ndo_snapend - bp, NULL, NULL);
+ break;
+ default:
+ ND_PRINT((ndo, "ERROR: unknown-next-protocol"));
+ return;
+ }
+
+ return;
+
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+}
+
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-nsh-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-ntp.c b/freebsd/contrib/tcpdump/print-ntp.c
index 9c37de1d..eb336870 100644
--- a/freebsd/contrib/tcpdump/print-ntp.c
+++ b/freebsd/contrib/tcpdump/print-ntp.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
@@ -20,43 +23,160 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * Format and print ntp packets.
* By Jeffrey Mogul/DECWRL
* loosely based on print-bootp.c
- *
- * $FreeBSD$
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ntp.c,v 1.43 2007-11-30 13:45:10 hannes Exp $ (LBL)";
-#endif
+/* \summary: Network Time Protocol (NTP) printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include <stdio.h>
-#include <string.h>
#ifdef HAVE_STRFTIME
#include <time.h>
#endif
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "extract.h"
+
+/*
+ * Based on ntp.h from the U of MD implementation
+ * This file is based on Version 2 of the NTP spec (RFC1119).
+ */
+
+/*
+ * Definitions for the masses
+ */
+#define JAN_1970 2208988800U /* 1970 - 1900 in seconds */
+
+/*
+ * Structure definitions for NTP fixed point values
+ *
+ * 0 1 2 3
+ * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Integer Part |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Fraction Part |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *
+ * 0 1 2 3
+ * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Integer Part | Fraction Part |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+*/
+struct l_fixedpt {
+ uint32_t int_part;
+ uint32_t fraction;
+};
+
+struct s_fixedpt {
+ uint16_t int_part;
+ uint16_t fraction;
+};
+
+/* rfc2030
+ * 1 2 3
+ * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * |LI | VN |Mode | Stratum | Poll | Precision |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Root Delay |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Root Dispersion |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Reference Identifier |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | |
+ * | Reference Timestamp (64) |
+ * | |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | |
+ * | Originate Timestamp (64) |
+ * | |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | |
+ * | Receive Timestamp (64) |
+ * | |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | |
+ * | Transmit Timestamp (64) |
+ * | |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Key Identifier (optional) (32) |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | |
+ * | |
+ * | Message Digest (optional) (128) |
+ * | |
+ * | |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+
+struct ntpdata {
+ u_char status; /* status of local clock and leap info */
+ u_char stratum; /* Stratum level */
+ u_char ppoll; /* poll value */
+ int precision:8;
+ struct s_fixedpt root_delay;
+ struct s_fixedpt root_dispersion;
+ uint32_t refid;
+ struct l_fixedpt ref_timestamp;
+ struct l_fixedpt org_timestamp;
+ struct l_fixedpt rec_timestamp;
+ struct l_fixedpt xmt_timestamp;
+ uint32_t key_id;
+ uint8_t message_digest[16];
+};
+/*
+ * Leap Second Codes (high order two bits)
+ */
+#define NO_WARNING 0x00 /* no warning */
+#define PLUS_SEC 0x40 /* add a second (61 seconds) */
+#define MINUS_SEC 0x80 /* minus a second (59 seconds) */
+#define ALARM 0xc0 /* alarm condition (clock unsynchronized) */
+
+/*
+ * Clock Status Bits that Encode Version
+ */
+#define NTPVERSION_1 0x08
+#define VERSIONMASK 0x38
+#define LEAPMASK 0xc0
#ifdef MODEMASK
#undef MODEMASK /* Solaris sucks */
#endif
-#include "ntp.h"
+#define MODEMASK 0x07
-static void p_sfix(const struct s_fixedpt *);
-static void p_ntp_time(const struct l_fixedpt *);
-static void p_ntp_delta(const struct l_fixedpt *, const struct l_fixedpt *);
+/*
+ * Code values
+ */
+#define MODE_UNSPEC 0 /* unspecified */
+#define MODE_SYM_ACT 1 /* symmetric active */
+#define MODE_SYM_PAS 2 /* symmetric passive */
+#define MODE_CLIENT 3 /* client */
+#define MODE_SERVER 4 /* server */
+#define MODE_BROADCAST 5 /* broadcast */
+#define MODE_RES1 6 /* reserved */
+#define MODE_RES2 7 /* reserved */
-static struct tok ntp_mode_values[] = {
+/*
+ * Stratum Definitions
+ */
+#define UNSPECIFIED 0
+#define PRIM_REF 1 /* radio clock */
+#define INFO_QUERY 62 /* **** THIS implementation dependent **** */
+#define INFO_REPLY 63 /* **** THIS implementation dependent **** */
+
+static void p_sfix(netdissect_options *ndo, const struct s_fixedpt *);
+static void p_ntp_time(netdissect_options *, const struct l_fixedpt *);
+static void p_ntp_delta(netdissect_options *, const struct l_fixedpt *, const struct l_fixedpt *);
+
+static const struct tok ntp_mode_values[] = {
{ MODE_UNSPEC, "unspecified" },
{ MODE_SYM_ACT, "symmetric active" },
{ MODE_SYM_PAS, "symmetric passive" },
@@ -68,7 +188,7 @@ static struct tok ntp_mode_values[] = {
{ 0, NULL }
};
-static struct tok ntp_leapind_values[] = {
+static const struct tok ntp_leapind_values[] = {
{ NO_WARNING, "" },
{ PLUS_SEC, "+1s" },
{ MINUS_SEC, "-1s" },
@@ -76,7 +196,7 @@ static struct tok ntp_leapind_values[] = {
{ 0, NULL }
};
-static struct tok ntp_stratum_values[] = {
+static const struct tok ntp_stratum_values[] = {
{ UNSPECIFIED, "unspecified" },
{ PRIM_REF, "primary reference" },
{ 0, NULL }
@@ -86,157 +206,160 @@ static struct tok ntp_stratum_values[] = {
* Print ntp requests
*/
void
-ntp_print(register const u_char *cp, u_int length)
+ntp_print(netdissect_options *ndo,
+ register const u_char *cp, u_int length)
{
register const struct ntpdata *bp;
int mode, version, leapind;
- bp = (struct ntpdata *)cp;
+ bp = (const struct ntpdata *)cp;
- TCHECK(bp->status);
+ ND_TCHECK(bp->status);
version = (int)(bp->status & VERSIONMASK) >> 3;
- printf("NTPv%d", version);
+ ND_PRINT((ndo, "NTPv%d", version));
mode = bp->status & MODEMASK;
- if (!vflag) {
- printf (", %s, length %u",
- tok2str(ntp_mode_values, "Unknown mode", mode),
- length);
- return;
- }
-
- printf (", length %u\n\t%s",
- length,
- tok2str(ntp_mode_values, "Unknown mode", mode));
+ if (!ndo->ndo_vflag) {
+ ND_PRINT((ndo, ", %s, length %u",
+ tok2str(ntp_mode_values, "Unknown mode", mode),
+ length));
+ return;
+ }
+
+ ND_PRINT((ndo, ", length %u\n\t%s",
+ length,
+ tok2str(ntp_mode_values, "Unknown mode", mode)));
leapind = bp->status & LEAPMASK;
- printf (", Leap indicator: %s (%u)",
- tok2str(ntp_leapind_values, "Unknown", leapind),
- leapind);
+ ND_PRINT((ndo, ", Leap indicator: %s (%u)",
+ tok2str(ntp_leapind_values, "Unknown", leapind),
+ leapind));
- TCHECK(bp->stratum);
- printf(", Stratum %u (%s)",
+ ND_TCHECK(bp->stratum);
+ ND_PRINT((ndo, ", Stratum %u (%s)",
bp->stratum,
- tok2str(ntp_stratum_values, (bp->stratum >=2 && bp->stratum<=15) ? "secondary reference" : "reserved", bp->stratum));
+ tok2str(ntp_stratum_values, (bp->stratum >=2 && bp->stratum<=15) ? "secondary reference" : "reserved", bp->stratum)));
- TCHECK(bp->ppoll);
- printf(", poll %u (%us)", bp->ppoll, 1 << bp->ppoll);
+ ND_TCHECK(bp->ppoll);
+ ND_PRINT((ndo, ", poll %u (%us)", bp->ppoll, 1 << bp->ppoll));
- /* Can't TCHECK bp->precision bitfield so bp->distance + 0 instead */
- TCHECK2(bp->root_delay, 0);
- printf(", precision %d", bp->precision);
+ /* Can't ND_TCHECK bp->precision bitfield so bp->distance + 0 instead */
+ ND_TCHECK2(bp->root_delay, 0);
+ ND_PRINT((ndo, ", precision %d", bp->precision));
- TCHECK(bp->root_delay);
- fputs("\n\tRoot Delay: ", stdout);
- p_sfix(&bp->root_delay);
+ ND_TCHECK(bp->root_delay);
+ ND_PRINT((ndo, "\n\tRoot Delay: "));
+ p_sfix(ndo, &bp->root_delay);
- TCHECK(bp->root_dispersion);
- fputs(", Root dispersion: ", stdout);
- p_sfix(&bp->root_dispersion);
+ ND_TCHECK(bp->root_dispersion);
+ ND_PRINT((ndo, ", Root dispersion: "));
+ p_sfix(ndo, &bp->root_dispersion);
- TCHECK(bp->refid);
- fputs(", Reference-ID: ", stdout);
+ ND_TCHECK(bp->refid);
+ ND_PRINT((ndo, ", Reference-ID: "));
/* Interpretation depends on stratum */
switch (bp->stratum) {
case UNSPECIFIED:
- printf("(unspec)");
+ ND_PRINT((ndo, "(unspec)"));
break;
case PRIM_REF:
- if (fn_printn((u_char *)&(bp->refid), 4, snapend))
+ if (fn_printn(ndo, (const u_char *)&(bp->refid), 4, ndo->ndo_snapend))
goto trunc;
break;
case INFO_QUERY:
- printf("%s INFO_QUERY", ipaddr_string(&(bp->refid)));
+ ND_PRINT((ndo, "%s INFO_QUERY", ipaddr_string(ndo, &(bp->refid))));
/* this doesn't have more content */
return;
case INFO_REPLY:
- printf("%s INFO_REPLY", ipaddr_string(&(bp->refid)));
+ ND_PRINT((ndo, "%s INFO_REPLY", ipaddr_string(ndo, &(bp->refid))));
/* this is too complex to be worth printing */
return;
default:
- printf("%s", ipaddr_string(&(bp->refid)));
+ ND_PRINT((ndo, "%s", ipaddr_string(ndo, &(bp->refid))));
break;
}
- TCHECK(bp->ref_timestamp);
- fputs("\n\t Reference Timestamp: ", stdout);
- p_ntp_time(&(bp->ref_timestamp));
+ ND_TCHECK(bp->ref_timestamp);
+ ND_PRINT((ndo, "\n\t Reference Timestamp: "));
+ p_ntp_time(ndo, &(bp->ref_timestamp));
- TCHECK(bp->org_timestamp);
- fputs("\n\t Originator Timestamp: ", stdout);
- p_ntp_time(&(bp->org_timestamp));
+ ND_TCHECK(bp->org_timestamp);
+ ND_PRINT((ndo, "\n\t Originator Timestamp: "));
+ p_ntp_time(ndo, &(bp->org_timestamp));
- TCHECK(bp->rec_timestamp);
- fputs("\n\t Receive Timestamp: ", stdout);
- p_ntp_time(&(bp->rec_timestamp));
+ ND_TCHECK(bp->rec_timestamp);
+ ND_PRINT((ndo, "\n\t Receive Timestamp: "));
+ p_ntp_time(ndo, &(bp->rec_timestamp));
- TCHECK(bp->xmt_timestamp);
- fputs("\n\t Transmit Timestamp: ", stdout);
- p_ntp_time(&(bp->xmt_timestamp));
+ ND_TCHECK(bp->xmt_timestamp);
+ ND_PRINT((ndo, "\n\t Transmit Timestamp: "));
+ p_ntp_time(ndo, &(bp->xmt_timestamp));
- fputs("\n\t Originator - Receive Timestamp: ", stdout);
- p_ntp_delta(&(bp->org_timestamp), &(bp->rec_timestamp));
+ ND_PRINT((ndo, "\n\t Originator - Receive Timestamp: "));
+ p_ntp_delta(ndo, &(bp->org_timestamp), &(bp->rec_timestamp));
- fputs("\n\t Originator - Transmit Timestamp: ", stdout);
- p_ntp_delta(&(bp->org_timestamp), &(bp->xmt_timestamp));
+ ND_PRINT((ndo, "\n\t Originator - Transmit Timestamp: "));
+ p_ntp_delta(ndo, &(bp->org_timestamp), &(bp->xmt_timestamp));
if ( (sizeof(struct ntpdata) - length) == 16) { /* Optional: key-id */
- TCHECK(bp->key_id);
- printf("\n\tKey id: %u", bp->key_id);
+ ND_TCHECK(bp->key_id);
+ ND_PRINT((ndo, "\n\tKey id: %u", bp->key_id));
} else if ( (sizeof(struct ntpdata) - length) == 0) { /* Optional: key-id + authentication */
- TCHECK(bp->key_id);
- printf("\n\tKey id: %u", bp->key_id);
- TCHECK2(bp->message_digest, sizeof (bp->message_digest));
- printf("\n\tAuthentication: %08x%08x%08x%08x",
+ ND_TCHECK(bp->key_id);
+ ND_PRINT((ndo, "\n\tKey id: %u", bp->key_id));
+ ND_TCHECK2(bp->message_digest, sizeof (bp->message_digest));
+ ND_PRINT((ndo, "\n\tAuthentication: %08x%08x%08x%08x",
EXTRACT_32BITS(bp->message_digest),
EXTRACT_32BITS(bp->message_digest + 4),
EXTRACT_32BITS(bp->message_digest + 8),
- EXTRACT_32BITS(bp->message_digest + 12));
+ EXTRACT_32BITS(bp->message_digest + 12)));
}
return;
trunc:
- fputs(" [|ntp]", stdout);
+ ND_PRINT((ndo, " [|ntp]"));
}
static void
-p_sfix(register const struct s_fixedpt *sfp)
+p_sfix(netdissect_options *ndo,
+ register const struct s_fixedpt *sfp)
{
register int i;
register int f;
- register float ff;
+ register double ff;
i = EXTRACT_16BITS(&sfp->int_part);
f = EXTRACT_16BITS(&sfp->fraction);
- ff = f / 65536.0; /* shift radix point by 16 bits */
- f = ff * 1000000.0; /* Treat fraction as parts per million */
- printf("%d.%06d", i, f);
+ ff = f / 65536.0; /* shift radix point by 16 bits */
+ f = (int)(ff * 1000000.0); /* Treat fraction as parts per million */
+ ND_PRINT((ndo, "%d.%06d", i, f));
}
#define FMAXINT (4294967296.0) /* floating point rep. of MAXINT */
static void
-p_ntp_time(register const struct l_fixedpt *lfp)
+p_ntp_time(netdissect_options *ndo,
+ register const struct l_fixedpt *lfp)
{
register int32_t i;
- register u_int32_t uf;
- register u_int32_t f;
- register float ff;
+ register uint32_t uf;
+ register uint32_t f;
+ register double ff;
i = EXTRACT_32BITS(&lfp->int_part);
uf = EXTRACT_32BITS(&lfp->fraction);
ff = uf;
if (ff < 0.0) /* some compilers are buggy */
ff += FMAXINT;
- ff = ff / FMAXINT; /* shift radix point by 32 bits */
- f = ff * 1000000000.0; /* treat fraction as parts per billion */
- printf("%u.%09d", i, f);
+ ff = ff / FMAXINT; /* shift radix point by 32 bits */
+ f = (uint32_t)(ff * 1000000000.0); /* treat fraction as parts per billion */
+ ND_PRINT((ndo, "%u.%09d", i, f));
#ifdef HAVE_STRFTIME
/*
@@ -249,21 +372,22 @@ p_ntp_time(register const struct l_fixedpt *lfp)
tm = localtime(&seconds);
strftime(time_buf, sizeof (time_buf), "%Y/%m/%d %H:%M:%S", tm);
- printf (" (%s)", time_buf);
+ ND_PRINT((ndo, " (%s)", time_buf));
}
#endif
}
/* Prints time difference between *lfp and *olfp */
static void
-p_ntp_delta(register const struct l_fixedpt *olfp,
- register const struct l_fixedpt *lfp)
+p_ntp_delta(netdissect_options *ndo,
+ register const struct l_fixedpt *olfp,
+ register const struct l_fixedpt *lfp)
{
register int32_t i;
- register u_int32_t u, uf;
- register u_int32_t ou, ouf;
- register u_int32_t f;
- register float ff;
+ register uint32_t u, uf;
+ register uint32_t ou, ouf;
+ register uint32_t f;
+ register double ff;
int signbit;
u = EXTRACT_32BITS(&lfp->int_part);
@@ -271,7 +395,7 @@ p_ntp_delta(register const struct l_fixedpt *olfp,
uf = EXTRACT_32BITS(&lfp->fraction);
ouf = EXTRACT_32BITS(&olfp->fraction);
if (ou == 0 && ouf == 0) {
- p_ntp_time(lfp);
+ p_ntp_time(ndo, lfp);
return;
}
@@ -301,12 +425,11 @@ p_ntp_delta(register const struct l_fixedpt *olfp,
ff = f;
if (ff < 0.0) /* some compilers are buggy */
ff += FMAXINT;
- ff = ff / FMAXINT; /* shift radix point by 32 bits */
- f = ff * 1000000000.0; /* treat fraction as parts per billion */
- if (signbit)
- putchar('-');
- else
- putchar('+');
- printf("%d.%09d", i, f);
+ ff = ff / FMAXINT; /* shift radix point by 32 bits */
+ f = (uint32_t)(ff * 1000000000.0); /* treat fraction as parts per billion */
+ ND_PRINT((ndo, "%s%d.%09d", signbit ? "-" : "+", i, f));
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-ntp-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-null.c b/freebsd/contrib/tcpdump/print-null.c
index ac727077..2187d2bd 100644
--- a/freebsd/contrib/tcpdump/print-null.c
+++ b/freebsd/contrib/tcpdump/print-null.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
@@ -19,32 +22,19 @@
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * $FreeBSD$
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-null.c,v 1.57 2006-03-23 14:58:44 hannes Exp $ (LBL)";
-#endif
+/* \summary: BSD loopback device printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include <pcap.h>
-#include <stdio.h>
#include <string.h>
-#include "interface.h"
-#include "addrtoname.h"
-
-#include "ip.h"
-#ifdef INET6
-#include "ip6.h"
-#endif
+#include "netdissect.h"
#include "af.h"
/*
@@ -68,17 +58,17 @@ static const char rcsid[] _U_ =
((((y)&0xff)<<24) | (((y)&0xff00)<<8) | (((y)&0xff0000)>>8) | (((y)>>24)&0xff))
static inline void
-null_hdr_print(u_int family, u_int length)
+null_hdr_print(netdissect_options *ndo, u_int family, u_int length)
{
- if (!qflag) {
- (void)printf("AF %s (%u)",
- tok2str(bsd_af_values,"Unknown",family),family);
+ if (!ndo->ndo_qflag) {
+ ND_PRINT((ndo, "AF %s (%u)",
+ tok2str(bsd_af_values,"Unknown",family),family));
} else {
- (void)printf("%s",
- tok2str(bsd_af_values,"Unknown AF %u",family));
+ ND_PRINT((ndo, "%s",
+ tok2str(bsd_af_values,"Unknown AF %u",family)));
}
- (void)printf(", length %u: ", length);
+ ND_PRINT((ndo, ", length %u: ", length));
}
/*
@@ -88,18 +78,18 @@ null_hdr_print(u_int family, u_int length)
* is the number of bytes actually captured.
*/
u_int
-null_if_print(const struct pcap_pkthdr *h, const u_char *p)
+null_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
{
u_int length = h->len;
u_int caplen = h->caplen;
u_int family;
if (caplen < NULL_HDRLEN) {
- printf("[|null]");
+ ND_PRINT((ndo, "[|null]"));
return (NULL_HDRLEN);
}
- memcpy((char *)&family, (char *)p, sizeof(family));
+ memcpy((char *)&family, (const char *)p, sizeof(family));
/*
* This isn't necessarily in our host byte order; if this is
@@ -112,8 +102,8 @@ null_if_print(const struct pcap_pkthdr *h, const u_char *p)
if ((family & 0xFFFF0000) != 0)
family = SWAPLONG(family);
- if (eflag)
- null_hdr_print(family, length);
+ if (ndo->ndo_eflag)
+ null_hdr_print(ndo, family, length);
length -= NULL_HDRLEN;
caplen -= NULL_HDRLEN;
@@ -122,35 +112,33 @@ null_if_print(const struct pcap_pkthdr *h, const u_char *p)
switch (family) {
case BSD_AFNUM_INET:
- ip_print(gndo, p, length);
+ ip_print(ndo, p, length);
break;
-#ifdef INET6
case BSD_AFNUM_INET6_BSD:
case BSD_AFNUM_INET6_FREEBSD:
case BSD_AFNUM_INET6_DARWIN:
- ip6_print(gndo, p, length);
+ ip6_print(ndo, p, length);
break;
-#endif
case BSD_AFNUM_ISO:
- isoclns_print(p, length, caplen);
+ isoclns_print(ndo, p, length, caplen);
break;
case BSD_AFNUM_APPLETALK:
- atalk_print(p, length);
+ atalk_print(ndo, p, length);
break;
case BSD_AFNUM_IPX:
- ipx_print(p, length);
+ ipx_print(ndo, p, length);
break;
default:
/* unknown AF_ value */
- if (!eflag)
- null_hdr_print(family, length + NULL_HDRLEN);
- if (!suppress_default_print)
- default_print(p, caplen);
+ if (!ndo->ndo_eflag)
+ null_hdr_print(ndo, family, length + NULL_HDRLEN);
+ if (!ndo->ndo_suppress_default_print)
+ ND_DEFAULTPRINT(p, caplen);
}
return (NULL_HDRLEN);
@@ -162,3 +150,6 @@ null_if_print(const struct pcap_pkthdr *h, const u_char *p)
* c-basic-offset: 8
* End:
*/
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-null-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-olsr.c b/freebsd/contrib/tcpdump/print-olsr.c
index 962c4d0e..fc1952de 100644
--- a/freebsd/contrib/tcpdump/print-olsr.c
+++ b/freebsd/contrib/tcpdump/print-olsr.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1998-2007 The TCPDUMP project
* Copyright (c) 2009 Florian Forster
@@ -15,25 +18,23 @@
* LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE.
*
- * Optimized Link State Protocl (OLSR) as per rfc3626
- *
* Original code by Hannes Gredler <hannes@juniper.net>
* IPv6 additions by Florian Forster <octo at verplant.org>
*/
+/* \summary: Optimized Link State Routing Protocol (OLSR) printer */
+
+/* specification: RFC 3626 */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
-
-#include <stdio.h>
-#include <string.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "extract.h"
-#include "ip.h"
/*
* RFC 3626 common header
@@ -67,8 +68,8 @@
*/
struct olsr_common {
- u_int8_t packet_len[2];
- u_int8_t packet_seq[2];
+ uint8_t packet_len[2];
+ uint8_t packet_seq[2];
};
#define OLSR_HELLO_MSG 1 /* rfc3626 */
@@ -80,7 +81,7 @@ struct olsr_common {
#define OLSR_HELLO_LQ_MSG 201 /* LQ extensions olsr.org */
#define OLSR_TC_LQ_MSG 202 /* LQ extensions olsr.org */
-static struct tok olsr_msg_values[] = {
+static const struct tok olsr_msg_values[] = {
{ OLSR_HELLO_MSG, "Hello" },
{ OLSR_TC_MSG, "TC" },
{ OLSR_MID_MSG, "MID" },
@@ -93,57 +94,77 @@ static struct tok olsr_msg_values[] = {
};
struct olsr_msg4 {
- u_int8_t msg_type;
- u_int8_t vtime;
- u_int8_t msg_len[2];
- u_int8_t originator[4];
- u_int8_t ttl;
- u_int8_t hopcount;
- u_int8_t msg_seq[2];
+ uint8_t msg_type;
+ uint8_t vtime;
+ uint8_t msg_len[2];
+ uint8_t originator[4];
+ uint8_t ttl;
+ uint8_t hopcount;
+ uint8_t msg_seq[2];
};
struct olsr_msg6 {
- u_int8_t msg_type;
- u_int8_t vtime;
- u_int8_t msg_len[2];
- u_int8_t originator[16];
- u_int8_t ttl;
- u_int8_t hopcount;
- u_int8_t msg_seq[2];
+ uint8_t msg_type;
+ uint8_t vtime;
+ uint8_t msg_len[2];
+ uint8_t originator[16];
+ uint8_t ttl;
+ uint8_t hopcount;
+ uint8_t msg_seq[2];
};
struct olsr_hello {
- u_int8_t res[2];
- u_int8_t htime;
- u_int8_t will;
+ uint8_t res[2];
+ uint8_t htime;
+ uint8_t will;
};
struct olsr_hello_link {
- u_int8_t link_code;
- u_int8_t res;
- u_int8_t len[2];
+ uint8_t link_code;
+ uint8_t res;
+ uint8_t len[2];
};
struct olsr_tc {
- u_int8_t ans_seq[2];
- u_int8_t res[2];
+ uint8_t ans_seq[2];
+ uint8_t res[2];
};
struct olsr_hna4 {
- u_int8_t network[4];
- u_int8_t mask[4];
+ uint8_t network[4];
+ uint8_t mask[4];
};
struct olsr_hna6 {
- u_int8_t network[16];
- u_int8_t mask[16];
+ uint8_t network[16];
+ uint8_t mask[16];
+};
+
+
+/** gateway HNA flags */
+enum gateway_hna_flags {
+ GW_HNA_FLAG_LINKSPEED = 1 << 0,
+ GW_HNA_FLAG_IPV4 = 1 << 1,
+ GW_HNA_FLAG_IPV4_NAT = 1 << 2,
+ GW_HNA_FLAG_IPV6 = 1 << 3,
+ GW_HNA_FLAG_IPV6PREFIX = 1 << 4
+};
+
+/** gateway HNA field byte offsets in the netmask field of the HNA */
+enum gateway_hna_fields {
+ GW_HNA_PAD = 0,
+ GW_HNA_FLAGS = 1,
+ GW_HNA_UPLINK = 2,
+ GW_HNA_DOWNLINK = 3,
+ GW_HNA_V6PREFIXLEN = 4,
+ GW_HNA_V6PREFIX = 5
};
#define OLSR_EXTRACT_LINK_TYPE(link_code) (link_code & 0x3)
#define OLSR_EXTRACT_NEIGHBOR_TYPE(link_code) (link_code >> 2)
-static struct tok olsr_link_type_values[] = {
+static const struct tok olsr_link_type_values[] = {
{ 0, "Unspecified" },
{ 1, "Asymmetric" },
{ 2, "Symmetric" },
@@ -151,7 +172,7 @@ static struct tok olsr_link_type_values[] = {
{ 0, NULL}
};
-static struct tok olsr_neighbor_type_values[] = {
+static const struct tok olsr_neighbor_type_values[] = {
{ 0, "Not-Neighbor" },
{ 1, "Symmetric" },
{ 2, "Symmetric-MPR" },
@@ -159,19 +180,50 @@ static struct tok olsr_neighbor_type_values[] = {
};
struct olsr_lq_neighbor4 {
- u_int8_t neighbor[4];
- u_int8_t link_quality;
- u_int8_t neighbor_link_quality;
- u_int8_t res[2];
+ uint8_t neighbor[4];
+ uint8_t link_quality;
+ uint8_t neighbor_link_quality;
+ uint8_t res[2];
};
struct olsr_lq_neighbor6 {
- u_int8_t neighbor[16];
- u_int8_t link_quality;
- u_int8_t neighbor_link_quality;
- u_int8_t res[2];
+ uint8_t neighbor[16];
+ uint8_t link_quality;
+ uint8_t neighbor_link_quality;
+ uint8_t res[2];
};
+#define MAX_SMARTGW_SPEED 320000000
+
+/**
+ * Convert an encoded 1 byte transport value (5 bits mantissa, 3 bits exponent)
+ * to an uplink/downlink speed value
+ *
+ * @param value the encoded 1 byte transport value
+ * @return the uplink/downlink speed value (in kbit/s)
+ */
+static uint32_t deserialize_gw_speed(uint8_t value) {
+ uint32_t speed;
+ uint32_t exp;
+
+ if (!value) {
+ return 0;
+ }
+
+ if (value == UINT8_MAX) {
+ /* maximum value: also return maximum value */
+ return MAX_SMARTGW_SPEED;
+ }
+
+ speed = (value >> 3) + 1;
+ exp = value & 7;
+
+ while (exp-- > 0) {
+ speed *= 10;
+ }
+ return speed;
+}
+
/*
* macro to convert the 8-bit mantissa/exponent to a double float
* taken from olsr.org.
@@ -183,74 +235,85 @@ struct olsr_lq_neighbor6 {
/*
* print a neighbor list with LQ extensions.
*/
-static void
-olsr_print_lq_neighbor4 (const u_char *msg_data, u_int hello_len)
+static int
+olsr_print_lq_neighbor4(netdissect_options *ndo,
+ const u_char *msg_data, u_int hello_len)
{
- struct olsr_lq_neighbor4 *lq_neighbor;
+ const struct olsr_lq_neighbor4 *lq_neighbor;
while (hello_len >= sizeof(struct olsr_lq_neighbor4)) {
- lq_neighbor = (struct olsr_lq_neighbor4 *)msg_data;
+ lq_neighbor = (const struct olsr_lq_neighbor4 *)msg_data;
+ if (!ND_TTEST(*lq_neighbor))
+ return (-1);
- printf("\n\t neighbor %s, link-quality %.2lf%%"
- ", neighbor-link-quality %.2lf%%",
- ipaddr_string(lq_neighbor->neighbor),
+ ND_PRINT((ndo, "\n\t neighbor %s, link-quality %.2f%%"
+ ", neighbor-link-quality %.2f%%",
+ ipaddr_string(ndo, lq_neighbor->neighbor),
((double)lq_neighbor->link_quality/2.55),
- ((double)lq_neighbor->neighbor_link_quality/2.55));
+ ((double)lq_neighbor->neighbor_link_quality/2.55)));
msg_data += sizeof(struct olsr_lq_neighbor4);
hello_len -= sizeof(struct olsr_lq_neighbor4);
}
+ return (0);
}
-#if INET6
-static void
-olsr_print_lq_neighbor6 (const u_char *msg_data, u_int hello_len)
+static int
+olsr_print_lq_neighbor6(netdissect_options *ndo,
+ const u_char *msg_data, u_int hello_len)
{
- struct olsr_lq_neighbor6 *lq_neighbor;
+ const struct olsr_lq_neighbor6 *lq_neighbor;
while (hello_len >= sizeof(struct olsr_lq_neighbor6)) {
- lq_neighbor = (struct olsr_lq_neighbor6 *)msg_data;
+ lq_neighbor = (const struct olsr_lq_neighbor6 *)msg_data;
+ if (!ND_TTEST(*lq_neighbor))
+ return (-1);
- printf("\n\t neighbor %s, link-quality %.2lf%%"
- ", neighbor-link-quality %.2lf%%",
- ip6addr_string(lq_neighbor->neighbor),
+ ND_PRINT((ndo, "\n\t neighbor %s, link-quality %.2f%%"
+ ", neighbor-link-quality %.2f%%",
+ ip6addr_string(ndo, lq_neighbor->neighbor),
((double)lq_neighbor->link_quality/2.55),
- ((double)lq_neighbor->neighbor_link_quality/2.55));
+ ((double)lq_neighbor->neighbor_link_quality/2.55)));
msg_data += sizeof(struct olsr_lq_neighbor6);
hello_len -= sizeof(struct olsr_lq_neighbor6);
}
+ return (0);
}
-#endif /* INET6 */
/*
* print a neighbor list.
*/
-static void
-olsr_print_neighbor (const u_char *msg_data, u_int hello_len)
+static int
+olsr_print_neighbor(netdissect_options *ndo,
+ const u_char *msg_data, u_int hello_len)
{
int neighbor;
- printf("\n\t neighbor\n\t\t");
+ ND_PRINT((ndo, "\n\t neighbor\n\t\t"));
neighbor = 1;
while (hello_len >= sizeof(struct in_addr)) {
+ if (!ND_TTEST2(*msg_data, sizeof(struct in_addr)))
+ return (-1);
/* print 4 neighbors per line */
- printf("%s%s", ipaddr_string(msg_data),
- neighbor % 4 == 0 ? "\n\t\t" : " ");
+ ND_PRINT((ndo, "%s%s", ipaddr_string(ndo, msg_data),
+ neighbor % 4 == 0 ? "\n\t\t" : " "));
msg_data += sizeof(struct in_addr);
hello_len -= sizeof(struct in_addr);
}
+ return (0);
}
void
-olsr_print (const u_char *pptr, u_int length, int is_ipv6)
+olsr_print(netdissect_options *ndo,
+ const u_char *pptr, u_int length, int is_ipv6)
{
union {
const struct olsr_common *common;
@@ -263,9 +326,9 @@ olsr_print (const u_char *pptr, u_int length, int is_ipv6)
} ptr;
u_int msg_type, msg_len, msg_tlen, hello_len;
- u_int16_t name_entry_type, name_entry_len;
+ uint16_t name_entry_type, name_entry_len;
u_int name_entry_padding;
- u_int8_t link_type, neighbor_type;
+ uint8_t link_type, neighbor_type;
const u_char *tptr, *msg_data;
tptr = pptr;
@@ -274,42 +337,38 @@ olsr_print (const u_char *pptr, u_int length, int is_ipv6)
goto trunc;
}
- if (!TTEST2(*tptr, sizeof(struct olsr_common))) {
- goto trunc;
- }
+ ND_TCHECK2(*tptr, sizeof(struct olsr_common));
- ptr.common = (struct olsr_common *)tptr;
- length = MIN(length, EXTRACT_16BITS(ptr.common->packet_len));
+ ptr.common = (const struct olsr_common *)tptr;
+ length = min(length, EXTRACT_16BITS(ptr.common->packet_len));
- printf("OLSRv%i, seq 0x%04x, length %u",
+ ND_PRINT((ndo, "OLSRv%i, seq 0x%04x, length %u",
(is_ipv6 == 0) ? 4 : 6,
EXTRACT_16BITS(ptr.common->packet_seq),
- length);
+ length));
tptr += sizeof(struct olsr_common);
/*
* In non-verbose mode, just print version.
*/
- if (vflag < 1) {
+ if (ndo->ndo_vflag < 1) {
return;
}
while (tptr < (pptr+length)) {
union
{
- struct olsr_msg4 *v4;
- struct olsr_msg6 *v6;
+ const struct olsr_msg4 *v4;
+ const struct olsr_msg6 *v6;
} msgptr;
int msg_len_valid = 0;
- if (!TTEST2(*tptr, sizeof(struct olsr_msg4)))
- goto trunc;
+ ND_TCHECK2(*tptr, sizeof(struct olsr_msg4));
-#if INET6
if (is_ipv6)
{
- msgptr.v6 = (struct olsr_msg6 *) tptr;
+ msgptr.v6 = (const struct olsr_msg6 *) tptr;
msg_type = msgptr.v6->msg_type;
msg_len = EXTRACT_16BITS(msgptr.v6->msg_len);
if ((msg_len >= sizeof (struct olsr_msg6))
@@ -321,23 +380,25 @@ olsr_print (const u_char *pptr, u_int length, int is_ipv6)
return;
}
- printf("\n\t%s Message (%#04x), originator %s, ttl %u, hop %u"
- "\n\t vtime %.3lfs, msg-seq 0x%04x, length %u%s",
+ ND_PRINT((ndo, "\n\t%s Message (%#04x), originator %s, ttl %u, hop %u"
+ "\n\t vtime %.3fs, msg-seq 0x%04x, length %u%s",
tok2str(olsr_msg_values, "Unknown", msg_type),
- msg_type, ip6addr_string(msgptr.v6->originator),
+ msg_type, ip6addr_string(ndo, msgptr.v6->originator),
msgptr.v6->ttl,
msgptr.v6->hopcount,
ME_TO_DOUBLE(msgptr.v6->vtime),
EXTRACT_16BITS(msgptr.v6->msg_seq),
- msg_len, (msg_len_valid == 0) ? " (invalid)" : "");
+ msg_len, (msg_len_valid == 0) ? " (invalid)" : ""));
+ if (!msg_len_valid) {
+ return;
+ }
msg_tlen = msg_len - sizeof(struct olsr_msg6);
msg_data = tptr + sizeof(struct olsr_msg6);
}
else /* (!is_ipv6) */
-#endif /* INET6 */
{
- msgptr.v4 = (struct olsr_msg4 *) tptr;
+ msgptr.v4 = (const struct olsr_msg4 *) tptr;
msg_type = msgptr.v4->msg_type;
msg_len = EXTRACT_16BITS(msgptr.v4->msg_len);
if ((msg_len >= sizeof (struct olsr_msg4))
@@ -349,15 +410,18 @@ olsr_print (const u_char *pptr, u_int length, int is_ipv6)
return;
}
- printf("\n\t%s Message (%#04x), originator %s, ttl %u, hop %u"
- "\n\t vtime %.3lfs, msg-seq 0x%04x, length %u%s",
+ ND_PRINT((ndo, "\n\t%s Message (%#04x), originator %s, ttl %u, hop %u"
+ "\n\t vtime %.3fs, msg-seq 0x%04x, length %u%s",
tok2str(olsr_msg_values, "Unknown", msg_type),
- msg_type, ipaddr_string(msgptr.v4->originator),
+ msg_type, ipaddr_string(ndo, msgptr.v4->originator),
msgptr.v4->ttl,
msgptr.v4->hopcount,
ME_TO_DOUBLE(msgptr.v4->vtime),
EXTRACT_16BITS(msgptr.v4->msg_seq),
- msg_len, (msg_len_valid == 0) ? " (invalid)" : "");
+ msg_len, (msg_len_valid == 0) ? " (invalid)" : ""));
+ if (!msg_len_valid) {
+ return;
+ }
msg_tlen = msg_len - sizeof(struct olsr_msg4);
msg_data = tptr + sizeof(struct olsr_msg4);
@@ -366,12 +430,13 @@ olsr_print (const u_char *pptr, u_int length, int is_ipv6)
switch (msg_type) {
case OLSR_HELLO_MSG:
case OLSR_HELLO_LQ_MSG:
- if (!TTEST2(*msg_data, sizeof(struct olsr_hello)))
+ if (msg_tlen < sizeof(struct olsr_hello))
goto trunc;
+ ND_TCHECK2(*msg_data, sizeof(struct olsr_hello));
- ptr.hello = (struct olsr_hello *)msg_data;
- printf("\n\t hello-time %.3lfs, MPR willingness %u",
- ME_TO_DOUBLE(ptr.hello->htime), ptr.hello->will);
+ ptr.hello = (const struct olsr_hello *)msg_data;
+ ND_PRINT((ndo, "\n\t hello-time %.3fs, MPR willingness %u",
+ ME_TO_DOUBLE(ptr.hello->htime), ptr.hello->will));
msg_data += sizeof(struct olsr_hello);
msg_tlen -= sizeof(struct olsr_hello);
@@ -381,10 +446,9 @@ olsr_print (const u_char *pptr, u_int length, int is_ipv6)
/*
* link-type.
*/
- if (!TTEST2(*msg_data, sizeof(struct olsr_hello_link)))
- goto trunc;
+ ND_TCHECK2(*msg_data, sizeof(struct olsr_hello_link));
- ptr.hello_link = (struct olsr_hello_link *)msg_data;
+ ptr.hello_link = (const struct olsr_hello_link *)msg_data;
hello_len = EXTRACT_16BITS(ptr.hello_link->len);
link_type = OLSR_EXTRACT_LINK_TYPE(ptr.hello_link->link_code);
@@ -394,11 +458,11 @@ olsr_print (const u_char *pptr, u_int length, int is_ipv6)
&& (hello_len >= sizeof(struct olsr_hello_link)))
hello_len_valid = 1;
- printf("\n\t link-type %s, neighbor-type %s, len %u%s",
+ ND_PRINT((ndo, "\n\t link-type %s, neighbor-type %s, len %u%s",
tok2str(olsr_link_type_values, "Unknown", link_type),
tok2str(olsr_neighbor_type_values, "Unknown", neighbor_type),
hello_len,
- (hello_len_valid == 0) ? " (invalid)" : "");
+ (hello_len_valid == 0) ? " (invalid)" : ""));
if (hello_len_valid == 0)
break;
@@ -407,15 +471,18 @@ olsr_print (const u_char *pptr, u_int length, int is_ipv6)
msg_tlen -= sizeof(struct olsr_hello_link);
hello_len -= sizeof(struct olsr_hello_link);
+ ND_TCHECK2(*msg_data, hello_len);
if (msg_type == OLSR_HELLO_MSG) {
- olsr_print_neighbor(msg_data, hello_len);
+ if (olsr_print_neighbor(ndo, msg_data, hello_len) == -1)
+ goto trunc;
} else {
-#if INET6
- if (is_ipv6)
- olsr_print_lq_neighbor6(msg_data, hello_len);
- else
-#endif
- olsr_print_lq_neighbor4(msg_data, hello_len);
+ if (is_ipv6) {
+ if (olsr_print_lq_neighbor6(ndo, msg_data, hello_len) == -1)
+ goto trunc;
+ } else {
+ if (olsr_print_lq_neighbor4(ndo, msg_data, hello_len) == -1)
+ goto trunc;
+ }
}
msg_data += hello_len;
@@ -425,24 +492,27 @@ olsr_print (const u_char *pptr, u_int length, int is_ipv6)
case OLSR_TC_MSG:
case OLSR_TC_LQ_MSG:
- if (!TTEST2(*msg_data, sizeof(struct olsr_tc)))
+ if (msg_tlen < sizeof(struct olsr_tc))
goto trunc;
+ ND_TCHECK2(*msg_data, sizeof(struct olsr_tc));
- ptr.tc = (struct olsr_tc *)msg_data;
- printf("\n\t advertised neighbor seq 0x%04x",
- EXTRACT_16BITS(ptr.tc->ans_seq));
+ ptr.tc = (const struct olsr_tc *)msg_data;
+ ND_PRINT((ndo, "\n\t advertised neighbor seq 0x%04x",
+ EXTRACT_16BITS(ptr.tc->ans_seq)));
msg_data += sizeof(struct olsr_tc);
msg_tlen -= sizeof(struct olsr_tc);
if (msg_type == OLSR_TC_MSG) {
- olsr_print_neighbor(msg_data, msg_tlen);
+ if (olsr_print_neighbor(ndo, msg_data, msg_tlen) == -1)
+ goto trunc;
} else {
-#if INET6
- if (is_ipv6)
- olsr_print_lq_neighbor6(msg_data, msg_tlen);
- else
-#endif
- olsr_print_lq_neighbor4(msg_data, msg_tlen);
+ if (is_ipv6) {
+ if (olsr_print_lq_neighbor6(ndo, msg_data, msg_tlen) == -1)
+ goto trunc;
+ } else {
+ if (olsr_print_lq_neighbor4(ndo, msg_data, msg_tlen) == -1)
+ goto trunc;
+ }
}
break;
@@ -450,20 +520,15 @@ olsr_print (const u_char *pptr, u_int length, int is_ipv6)
{
size_t addr_size = sizeof(struct in_addr);
-#if INET6
if (is_ipv6)
addr_size = sizeof(struct in6_addr);
-#endif
while (msg_tlen >= addr_size) {
- if (!TTEST2(*msg_data, addr_size))
- goto trunc;
+ ND_TCHECK2(*msg_data, addr_size);
+ ND_PRINT((ndo, "\n\t interface address %s",
+ is_ipv6 ? ip6addr_string(ndo, msg_data) :
+ ipaddr_string(ndo, msg_data)));
- printf("\n\t interface address %s",
-#if INET6
- is_ipv6 ? ip6addr_string(msg_data) :
-#endif
- ipaddr_string(msg_data));
msg_data += addr_size;
msg_tlen -= addr_size;
}
@@ -471,47 +536,80 @@ olsr_print (const u_char *pptr, u_int length, int is_ipv6)
}
case OLSR_HNA_MSG:
- printf("\n\t Advertised networks (total %u)",
- (unsigned int) (msg_tlen / sizeof(struct olsr_hna6)));
-#if INET6
if (is_ipv6)
{
int i = 0;
+
+ ND_PRINT((ndo, "\n\t Advertised networks (total %u)",
+ (unsigned int) (msg_tlen / sizeof(struct olsr_hna6))));
+
while (msg_tlen >= sizeof(struct olsr_hna6)) {
- struct olsr_hna6 *hna6;
+ const struct olsr_hna6 *hna6;
- if (!TTEST2(*msg_data, sizeof(struct olsr_hna6)))
- goto trunc;
+ ND_TCHECK2(*msg_data, sizeof(struct olsr_hna6));
- hna6 = (struct olsr_hna6 *)msg_data;
+ hna6 = (const struct olsr_hna6 *)msg_data;
- printf("\n\t #%i: %s/%u",
- i, ip6addr_string(hna6->network),
- mask62plen (hna6->mask));
+ ND_PRINT((ndo, "\n\t #%i: %s/%u",
+ i, ip6addr_string(ndo, hna6->network),
+ mask62plen (hna6->mask)));
msg_data += sizeof(struct olsr_hna6);
msg_tlen -= sizeof(struct olsr_hna6);
}
}
else
-#endif
{
int col = 0;
+
+ ND_PRINT((ndo, "\n\t Advertised networks (total %u)",
+ (unsigned int) (msg_tlen / sizeof(struct olsr_hna4))));
+
while (msg_tlen >= sizeof(struct olsr_hna4)) {
- if (!TTEST2(*msg_data, sizeof(struct olsr_hna4)))
- goto trunc;
+ ND_TCHECK2(*msg_data, sizeof(struct olsr_hna4));
- ptr.hna = (struct olsr_hna4 *)msg_data;
+ ptr.hna = (const struct olsr_hna4 *)msg_data;
/* print 4 prefixes per line */
- if (col == 0)
- printf ("\n\t ");
- else
- printf (", ");
-
- printf("%s/%u",
- ipaddr_string(ptr.hna->network),
- mask2plen(EXTRACT_32BITS(ptr.hna->mask)));
+ if (!ptr.hna->network[0] && !ptr.hna->network[1] &&
+ !ptr.hna->network[2] && !ptr.hna->network[3] &&
+ !ptr.hna->mask[GW_HNA_PAD] &&
+ ptr.hna->mask[GW_HNA_FLAGS]) {
+ /* smart gateway */
+ ND_PRINT((ndo, "%sSmart-Gateway:%s%s%s%s%s %u/%u",
+ col == 0 ? "\n\t " : ", ", /* indent */
+ /* sgw */
+ /* LINKSPEED */
+ (ptr.hna->mask[GW_HNA_FLAGS] &
+ GW_HNA_FLAG_LINKSPEED) ? " LINKSPEED" : "",
+ /* IPV4 */
+ (ptr.hna->mask[GW_HNA_FLAGS] &
+ GW_HNA_FLAG_IPV4) ? " IPV4" : "",
+ /* IPV4-NAT */
+ (ptr.hna->mask[GW_HNA_FLAGS] &
+ GW_HNA_FLAG_IPV4_NAT) ? " IPV4-NAT" : "",
+ /* IPV6 */
+ (ptr.hna->mask[GW_HNA_FLAGS] &
+ GW_HNA_FLAG_IPV6) ? " IPV6" : "",
+ /* IPv6PREFIX */
+ (ptr.hna->mask[GW_HNA_FLAGS] &
+ GW_HNA_FLAG_IPV6PREFIX) ? " IPv6-PREFIX" : "",
+ /* uplink */
+ (ptr.hna->mask[GW_HNA_FLAGS] &
+ GW_HNA_FLAG_LINKSPEED) ?
+ deserialize_gw_speed(ptr.hna->mask[GW_HNA_UPLINK]) : 0,
+ /* downlink */
+ (ptr.hna->mask[GW_HNA_FLAGS] &
+ GW_HNA_FLAG_LINKSPEED) ?
+ deserialize_gw_speed(ptr.hna->mask[GW_HNA_DOWNLINK]) : 0
+ ));
+ } else {
+ /* normal route */
+ ND_PRINT((ndo, "%s%s/%u",
+ col == 0 ? "\n\t " : ", ",
+ ipaddr_string(ndo, ptr.hna->network),
+ mask2plen(EXTRACT_32BITS(ptr.hna->mask))));
+ }
msg_data += sizeof(struct olsr_hna4);
msg_tlen -= sizeof(struct olsr_hna4);
@@ -537,12 +635,11 @@ olsr_print (const u_char *pptr, u_int length, int is_ipv6)
if (msg_tlen < 4)
goto trunc;
- if (!TTEST2(*msg_data, 4))
- goto trunc;
+ ND_TCHECK2(*msg_data, 4);
- printf("\n\t Version %u, Entries %u%s",
+ ND_PRINT((ndo, "\n\t Version %u, Entries %u%s",
EXTRACT_16BITS(msg_data),
- name_entries, (name_entries_valid == 0) ? " (invalid)" : "");
+ name_entries, (name_entries_valid == 0) ? " (invalid)" : ""));
if (name_entries_valid == 0)
break;
@@ -555,8 +652,7 @@ olsr_print (const u_char *pptr, u_int length, int is_ipv6)
if (msg_tlen < 4)
break;
- if (!TTEST2(*msg_data, 4))
- goto trunc;
+ ND_TCHECK2(*msg_data, 4);
name_entry_type = EXTRACT_16BITS(msg_data);
name_entry_len = EXTRACT_16BITS(msg_data+2);
@@ -567,9 +663,9 @@ olsr_print (const u_char *pptr, u_int length, int is_ipv6)
if ((name_entry_len > 0) && ((addr_size + name_entry_len) <= msg_tlen))
name_entry_len_valid = 1;
- printf("\n\t #%u: type %#06x, length %u%s",
+ ND_PRINT((ndo, "\n\t #%u: type %#06x, length %u%s",
(unsigned int) i, name_entry_type,
- name_entry_len, (name_entry_len_valid == 0) ? " (invalid)" : "");
+ name_entry_len, (name_entry_len_valid == 0) ? " (invalid)" : ""));
if (name_entry_len_valid == 0)
break;
@@ -582,19 +678,16 @@ olsr_print (const u_char *pptr, u_int length, int is_ipv6)
if (msg_tlen < addr_size + name_entry_len + name_entry_padding)
goto trunc;
- if (!TTEST2(*msg_data, addr_size + name_entry_len + name_entry_padding))
- goto trunc;
+ ND_TCHECK2(*msg_data, addr_size + name_entry_len + name_entry_padding);
-#if INET6
if (is_ipv6)
- printf(", address %s, name \"",
- ip6addr_string(msg_data));
+ ND_PRINT((ndo, ", address %s, name \"",
+ ip6addr_string(ndo, msg_data)));
else
-#endif
- printf(", address %s, name \"",
- ipaddr_string(msg_data));
- fn_printn(msg_data + addr_size, name_entry_len, NULL);
- printf("\"");
+ ND_PRINT((ndo, ", address %s, name \"",
+ ipaddr_string(ndo, msg_data)));
+ (void)fn_printn(ndo, msg_data + addr_size, name_entry_len, NULL);
+ ND_PRINT((ndo, "\""));
msg_data += addr_size + name_entry_len + name_entry_padding;
msg_tlen -= addr_size + name_entry_len + name_entry_padding;
@@ -608,7 +701,7 @@ olsr_print (const u_char *pptr, u_int length, int is_ipv6)
*/
case OLSR_POWERINFO_MSG:
default:
- print_unknown_data(msg_data, "\n\t ", msg_tlen);
+ print_unknown_data(ndo, msg_data, "\n\t ", msg_tlen);
break;
} /* switch (msg_type) */
tptr += msg_len;
@@ -617,7 +710,7 @@ olsr_print (const u_char *pptr, u_int length, int is_ipv6)
return;
trunc:
- printf("[|olsr]");
+ ND_PRINT((ndo, "[|olsr]"));
}
/*
@@ -626,3 +719,6 @@ olsr_print (const u_char *pptr, u_int length, int is_ipv6)
* c-basic-offset: 4
* End:
*/
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-olsr-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-openflow-1.0.c b/freebsd/contrib/tcpdump/print-openflow-1.0.c
new file mode 100644
index 00000000..bad2e7fc
--- /dev/null
+++ b/freebsd/contrib/tcpdump/print-openflow-1.0.c
@@ -0,0 +1,2568 @@
+#include <machine/rtems-bsd-user-space.h>
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
+/*
+ * This module implements decoding of OpenFlow protocol version 1.0 (wire
+ * protocol 0x01). The decoder implements terse (default), detailed (-v) and
+ * full (-vv) output formats and, as much as each format implies, detects and
+ * tries to work around sizing anomalies inside the messages. The decoder marks
+ * up bogus values of selected message fields and decodes partially captured
+ * messages up to the snapshot end. It is based on the specification below:
+ *
+ * [OF10] http://www.openflow.org/documents/openflow-spec-v1.0.0.pdf
+ *
+ * Most functions in this file take 3 arguments into account:
+ * * cp -- the pointer to the first octet to decode
+ * * len -- the length of the current structure as declared on the wire
+ * * ep -- the pointer to the end of the captured frame
+ * They return either the pointer to the next not-yet-decoded part of the frame
+ * or the value of ep, which means the current frame processing is over as it
+ * has been fully decoded or is invalid or truncated. This way it is possible
+ * to chain and nest such functions uniformly to decode an OF1.0 message, which
+ * consists of several layers of nested structures.
+ *
+ * Decoding of Ethernet frames nested in OFPT_PACKET_IN and OFPT_PACKET_OUT
+ * messages is done only when the verbosity level set by command-line argument
+ * is "-vvv" or higher. In that case the verbosity level is temporarily
+ * decremented by 3 during the nested frame decoding. For example, running
+ * tcpdump with "-vvvv" will do full decoding of OpenFlow and "-v" decoding of
+ * the nested frames.
+ *
+ * Partial decoding of Big Switch Networks vendor extensions is done after the
+ * oftest (OpenFlow Testing Framework) and Loxigen (library generator) source
+ * code.
+ *
+ *
+ * Copyright (c) 2013 The TCPDUMP project
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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
+ * COPYRIGHT HOLDER 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: OpenFlow protocol version 1.0 printer */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <netdissect-stdinc.h>
+
+#include "netdissect.h"
+#include "extract.h"
+#include "addrtoname.h"
+#include "ether.h"
+#include "ethertype.h"
+#include "ipproto.h"
+#include "oui.h"
+#include "openflow.h"
+
+static const char tstr[] = " [|openflow]";
+
+#define OFPT_HELLO 0x00
+#define OFPT_ERROR 0x01
+#define OFPT_ECHO_REQUEST 0x02
+#define OFPT_ECHO_REPLY 0x03
+#define OFPT_VENDOR 0x04
+#define OFPT_FEATURES_REQUEST 0x05
+#define OFPT_FEATURES_REPLY 0x06
+#define OFPT_GET_CONFIG_REQUEST 0x07
+#define OFPT_GET_CONFIG_REPLY 0x08
+#define OFPT_SET_CONFIG 0x09
+#define OFPT_PACKET_IN 0x0a
+#define OFPT_FLOW_REMOVED 0x0b
+#define OFPT_PORT_STATUS 0x0c
+#define OFPT_PACKET_OUT 0x0d
+#define OFPT_FLOW_MOD 0x0e
+#define OFPT_PORT_MOD 0x0f
+#define OFPT_STATS_REQUEST 0x10
+#define OFPT_STATS_REPLY 0x11
+#define OFPT_BARRIER_REQUEST 0x12
+#define OFPT_BARRIER_REPLY 0x13
+#define OFPT_QUEUE_GET_CONFIG_REQUEST 0x14
+#define OFPT_QUEUE_GET_CONFIG_REPLY 0x15
+static const struct tok ofpt_str[] = {
+ { OFPT_HELLO, "HELLO" },
+ { OFPT_ERROR, "ERROR" },
+ { OFPT_ECHO_REQUEST, "ECHO_REQUEST" },
+ { OFPT_ECHO_REPLY, "ECHO_REPLY" },
+ { OFPT_VENDOR, "VENDOR" },
+ { OFPT_FEATURES_REQUEST, "FEATURES_REQUEST" },
+ { OFPT_FEATURES_REPLY, "FEATURES_REPLY" },
+ { OFPT_GET_CONFIG_REQUEST, "GET_CONFIG_REQUEST" },
+ { OFPT_GET_CONFIG_REPLY, "GET_CONFIG_REPLY" },
+ { OFPT_SET_CONFIG, "SET_CONFIG" },
+ { OFPT_PACKET_IN, "PACKET_IN" },
+ { OFPT_FLOW_REMOVED, "FLOW_REMOVED" },
+ { OFPT_PORT_STATUS, "PORT_STATUS" },
+ { OFPT_PACKET_OUT, "PACKET_OUT" },
+ { OFPT_FLOW_MOD, "FLOW_MOD" },
+ { OFPT_PORT_MOD, "PORT_MOD" },
+ { OFPT_STATS_REQUEST, "STATS_REQUEST" },
+ { OFPT_STATS_REPLY, "STATS_REPLY" },
+ { OFPT_BARRIER_REQUEST, "BARRIER_REQUEST" },
+ { OFPT_BARRIER_REPLY, "BARRIER_REPLY" },
+ { OFPT_QUEUE_GET_CONFIG_REQUEST, "QUEUE_GET_CONFIG_REQUEST" },
+ { OFPT_QUEUE_GET_CONFIG_REPLY, "QUEUE_GET_CONFIG_REPLY" },
+ { 0, NULL }
+};
+
+#define OFPPC_PORT_DOWN (1 << 0)
+#define OFPPC_NO_STP (1 << 1)
+#define OFPPC_NO_RECV (1 << 2)
+#define OFPPC_NO_RECV_STP (1 << 3)
+#define OFPPC_NO_FLOOD (1 << 4)
+#define OFPPC_NO_FWD (1 << 5)
+#define OFPPC_NO_PACKET_IN (1 << 6)
+static const struct tok ofppc_bm[] = {
+ { OFPPC_PORT_DOWN, "PORT_DOWN" },
+ { OFPPC_NO_STP, "NO_STP" },
+ { OFPPC_NO_RECV, "NO_RECV" },
+ { OFPPC_NO_RECV_STP, "NO_RECV_STP" },
+ { OFPPC_NO_FLOOD, "NO_FLOOD" },
+ { OFPPC_NO_FWD, "NO_FWD" },
+ { OFPPC_NO_PACKET_IN, "NO_PACKET_IN" },
+ { 0, NULL }
+};
+#define OFPPC_U (~(OFPPC_PORT_DOWN | OFPPC_NO_STP | OFPPC_NO_RECV | \
+ OFPPC_NO_RECV_STP | OFPPC_NO_FLOOD | OFPPC_NO_FWD | \
+ OFPPC_NO_PACKET_IN))
+
+#define OFPPS_LINK_DOWN (1 << 0)
+#define OFPPS_STP_LISTEN (0 << 8)
+#define OFPPS_STP_LEARN (1 << 8)
+#define OFPPS_STP_FORWARD (2 << 8)
+#define OFPPS_STP_BLOCK (3 << 8)
+#define OFPPS_STP_MASK (3 << 8)
+static const struct tok ofpps_bm[] = {
+ { OFPPS_LINK_DOWN, "LINK_DOWN" },
+ { OFPPS_STP_LISTEN, "STP_LISTEN" },
+ { OFPPS_STP_LEARN, "STP_LEARN" },
+ { OFPPS_STP_FORWARD, "STP_FORWARD" },
+ { OFPPS_STP_BLOCK, "STP_BLOCK" },
+ { 0, NULL }
+};
+#define OFPPS_U (~(OFPPS_LINK_DOWN | OFPPS_STP_LISTEN | OFPPS_STP_LEARN | \
+ OFPPS_STP_FORWARD | OFPPS_STP_BLOCK))
+
+#define OFPP_MAX 0xff00
+#define OFPP_IN_PORT 0xfff8
+#define OFPP_TABLE 0xfff9
+#define OFPP_NORMAL 0xfffa
+#define OFPP_FLOOD 0xfffb
+#define OFPP_ALL 0xfffc
+#define OFPP_CONTROLLER 0xfffd
+#define OFPP_LOCAL 0xfffe
+#define OFPP_NONE 0xffff
+static const struct tok ofpp_str[] = {
+ { OFPP_MAX, "MAX" },
+ { OFPP_IN_PORT, "IN_PORT" },
+ { OFPP_TABLE, "TABLE" },
+ { OFPP_NORMAL, "NORMAL" },
+ { OFPP_FLOOD, "FLOOD" },
+ { OFPP_ALL, "ALL" },
+ { OFPP_CONTROLLER, "CONTROLLER" },
+ { OFPP_LOCAL, "LOCAL" },
+ { OFPP_NONE, "NONE" },
+ { 0, NULL }
+};
+
+#define OFPPF_10MB_HD (1 << 0)
+#define OFPPF_10MB_FD (1 << 1)
+#define OFPPF_100MB_HD (1 << 2)
+#define OFPPF_100MB_FD (1 << 3)
+#define OFPPF_1GB_HD (1 << 4)
+#define OFPPF_1GB_FD (1 << 5)
+#define OFPPF_10GB_FD (1 << 6)
+#define OFPPF_COPPER (1 << 7)
+#define OFPPF_FIBER (1 << 8)
+#define OFPPF_AUTONEG (1 << 9)
+#define OFPPF_PAUSE (1 << 10)
+#define OFPPF_PAUSE_ASYM (1 << 11)
+static const struct tok ofppf_bm[] = {
+ { OFPPF_10MB_HD, "10MB_HD" },
+ { OFPPF_10MB_FD, "10MB_FD" },
+ { OFPPF_100MB_HD, "100MB_HD" },
+ { OFPPF_100MB_FD, "100MB_FD" },
+ { OFPPF_1GB_HD, "1GB_HD" },
+ { OFPPF_1GB_FD, "1GB_FD" },
+ { OFPPF_10GB_FD, "10GB_FD" },
+ { OFPPF_COPPER, "COPPER" },
+ { OFPPF_FIBER, "FIBER" },
+ { OFPPF_AUTONEG, "AUTONEG" },
+ { OFPPF_PAUSE, "PAUSE" },
+ { OFPPF_PAUSE_ASYM, "PAUSE_ASYM" },
+ { 0, NULL }
+};
+#define OFPPF_U (~(OFPPF_10MB_HD | OFPPF_10MB_FD | OFPPF_100MB_HD | \
+ OFPPF_100MB_FD | OFPPF_1GB_HD | OFPPF_1GB_FD | \
+ OFPPF_10GB_FD | OFPPF_COPPER | OFPPF_FIBER | \
+ OFPPF_AUTONEG | OFPPF_PAUSE | OFPPF_PAUSE_ASYM))
+
+#define OFPQT_NONE 0x0000
+#define OFPQT_MIN_RATE 0x0001
+static const struct tok ofpqt_str[] = {
+ { OFPQT_NONE, "NONE" },
+ { OFPQT_MIN_RATE, "MIN_RATE" },
+ { 0, NULL }
+};
+
+#define OFPFW_IN_PORT (1 << 0)
+#define OFPFW_DL_VLAN (1 << 1)
+#define OFPFW_DL_SRC (1 << 2)
+#define OFPFW_DL_DST (1 << 3)
+#define OFPFW_DL_TYPE (1 << 4)
+#define OFPFW_NW_PROTO (1 << 5)
+#define OFPFW_TP_SRC (1 << 6)
+#define OFPFW_TP_DST (1 << 7)
+#define OFPFW_NW_SRC_SHIFT 8
+#define OFPFW_NW_SRC_BITS 6
+#define OFPFW_NW_SRC_MASK (((1 << OFPFW_NW_SRC_BITS) - 1) << OFPFW_NW_SRC_SHIFT)
+#define OFPFW_NW_DST_SHIFT 14
+#define OFPFW_NW_DST_BITS 6
+#define OFPFW_NW_DST_MASK (((1 << OFPFW_NW_DST_BITS) - 1) << OFPFW_NW_DST_SHIFT)
+#define OFPFW_DL_VLAN_PCP (1 << 20)
+#define OFPFW_NW_TOS (1 << 21)
+#define OFPFW_ALL ((1 << 22) - 1)
+static const struct tok ofpfw_bm[] = {
+ { OFPFW_IN_PORT, "IN_PORT" },
+ { OFPFW_DL_VLAN, "DL_VLAN" },
+ { OFPFW_DL_SRC, "DL_SRC" },
+ { OFPFW_DL_DST, "DL_DST" },
+ { OFPFW_DL_TYPE, "DL_TYPE" },
+ { OFPFW_NW_PROTO, "NW_PROTO" },
+ { OFPFW_TP_SRC, "TP_SRC" },
+ { OFPFW_TP_DST, "TP_DST" },
+ { OFPFW_DL_VLAN_PCP, "DL_VLAN_PCP" },
+ { OFPFW_NW_TOS, "NW_TOS" },
+ { 0, NULL }
+};
+/* The above array does not include bits 8~13 (OFPFW_NW_SRC_*) and 14~19
+ * (OFPFW_NW_DST_*), which are not a part of the bitmap and require decoding
+ * other than that of tok2str(). The macro below includes these bits such that
+ * they are not reported as bogus in the decoding. */
+#define OFPFW_U (~(OFPFW_ALL))
+
+#define OFPAT_OUTPUT 0x0000
+#define OFPAT_SET_VLAN_VID 0x0001
+#define OFPAT_SET_VLAN_PCP 0x0002
+#define OFPAT_STRIP_VLAN 0x0003
+#define OFPAT_SET_DL_SRC 0x0004
+#define OFPAT_SET_DL_DST 0x0005
+#define OFPAT_SET_NW_SRC 0x0006
+#define OFPAT_SET_NW_DST 0x0007
+#define OFPAT_SET_NW_TOS 0x0008
+#define OFPAT_SET_TP_SRC 0x0009
+#define OFPAT_SET_TP_DST 0x000a
+#define OFPAT_ENQUEUE 0x000b
+#define OFPAT_VENDOR 0xffff
+static const struct tok ofpat_str[] = {
+ { OFPAT_OUTPUT, "OUTPUT" },
+ { OFPAT_SET_VLAN_VID, "SET_VLAN_VID" },
+ { OFPAT_SET_VLAN_PCP, "SET_VLAN_PCP" },
+ { OFPAT_STRIP_VLAN, "STRIP_VLAN" },
+ { OFPAT_SET_DL_SRC, "SET_DL_SRC" },
+ { OFPAT_SET_DL_DST, "SET_DL_DST" },
+ { OFPAT_SET_NW_SRC, "SET_NW_SRC" },
+ { OFPAT_SET_NW_DST, "SET_NW_DST" },
+ { OFPAT_SET_NW_TOS, "SET_NW_TOS" },
+ { OFPAT_SET_TP_SRC, "SET_TP_SRC" },
+ { OFPAT_SET_TP_DST, "SET_TP_DST" },
+ { OFPAT_ENQUEUE, "ENQUEUE" },
+ { OFPAT_VENDOR, "VENDOR" },
+ { 0, NULL }
+};
+
+/* bit-shifted, w/o vendor action */
+static const struct tok ofpat_bm[] = {
+ { 1 << OFPAT_OUTPUT, "OUTPUT" },
+ { 1 << OFPAT_SET_VLAN_VID, "SET_VLAN_VID" },
+ { 1 << OFPAT_SET_VLAN_PCP, "SET_VLAN_PCP" },
+ { 1 << OFPAT_STRIP_VLAN, "STRIP_VLAN" },
+ { 1 << OFPAT_SET_DL_SRC, "SET_DL_SRC" },
+ { 1 << OFPAT_SET_DL_DST, "SET_DL_DST" },
+ { 1 << OFPAT_SET_NW_SRC, "SET_NW_SRC" },
+ { 1 << OFPAT_SET_NW_DST, "SET_NW_DST" },
+ { 1 << OFPAT_SET_NW_TOS, "SET_NW_TOS" },
+ { 1 << OFPAT_SET_TP_SRC, "SET_TP_SRC" },
+ { 1 << OFPAT_SET_TP_DST, "SET_TP_DST" },
+ { 1 << OFPAT_ENQUEUE, "ENQUEUE" },
+ { 0, NULL }
+};
+#define OFPAT_U (~(1 << OFPAT_OUTPUT | 1 << OFPAT_SET_VLAN_VID | \
+ 1 << OFPAT_SET_VLAN_PCP | 1 << OFPAT_STRIP_VLAN | \
+ 1 << OFPAT_SET_DL_SRC | 1 << OFPAT_SET_DL_DST | \
+ 1 << OFPAT_SET_NW_SRC | 1 << OFPAT_SET_NW_DST | \
+ 1 << OFPAT_SET_NW_TOS | 1 << OFPAT_SET_TP_SRC | \
+ 1 << OFPAT_SET_TP_DST | 1 << OFPAT_ENQUEUE))
+
+#define OFPC_FLOW_STATS (1 << 0)
+#define OFPC_TABLE_STATS (1 << 1)
+#define OFPC_PORT_STATS (1 << 2)
+#define OFPC_STP (1 << 3)
+#define OFPC_RESERVED (1 << 4)
+#define OFPC_IP_REASM (1 << 5)
+#define OFPC_QUEUE_STATS (1 << 6)
+#define OFPC_ARP_MATCH_IP (1 << 7)
+static const struct tok ofp_capabilities_bm[] = {
+ { OFPC_FLOW_STATS, "FLOW_STATS" },
+ { OFPC_TABLE_STATS, "TABLE_STATS" },
+ { OFPC_PORT_STATS, "PORT_STATS" },
+ { OFPC_STP, "STP" },
+ { OFPC_RESERVED, "RESERVED" }, /* not in the mask below */
+ { OFPC_IP_REASM, "IP_REASM" },
+ { OFPC_QUEUE_STATS, "QUEUE_STATS" },
+ { OFPC_ARP_MATCH_IP, "ARP_MATCH_IP" },
+ { 0, NULL }
+};
+#define OFPCAP_U (~(OFPC_FLOW_STATS | OFPC_TABLE_STATS | OFPC_PORT_STATS | \
+ OFPC_STP | OFPC_IP_REASM | OFPC_QUEUE_STATS | \
+ OFPC_ARP_MATCH_IP))
+
+#define OFPC_FRAG_NORMAL 0x0000
+#define OFPC_FRAG_DROP 0x0001
+#define OFPC_FRAG_REASM 0x0002
+#define OFPC_FRAG_MASK 0x0003
+static const struct tok ofp_config_str[] = {
+ { OFPC_FRAG_NORMAL, "FRAG_NORMAL" },
+ { OFPC_FRAG_DROP, "FRAG_DROP" },
+ { OFPC_FRAG_REASM, "FRAG_REASM" },
+ { 0, NULL }
+};
+
+#define OFPFC_ADD 0x0000
+#define OFPFC_MODIFY 0x0001
+#define OFPFC_MODIFY_STRICT 0x0002
+#define OFPFC_DELETE 0x0003
+#define OFPFC_DELETE_STRICT 0x0004
+static const struct tok ofpfc_str[] = {
+ { OFPFC_ADD, "ADD" },
+ { OFPFC_MODIFY, "MODIFY" },
+ { OFPFC_MODIFY_STRICT, "MODIFY_STRICT" },
+ { OFPFC_DELETE, "DELETE" },
+ { OFPFC_DELETE_STRICT, "DELETE_STRICT" },
+ { 0, NULL }
+};
+
+static const struct tok bufferid_str[] = {
+ { 0xffffffff, "NONE" },
+ { 0, NULL }
+};
+
+#define OFPFF_SEND_FLOW_REM (1 << 0)
+#define OFPFF_CHECK_OVERLAP (1 << 1)
+#define OFPFF_EMERG (1 << 2)
+static const struct tok ofpff_bm[] = {
+ { OFPFF_SEND_FLOW_REM, "SEND_FLOW_REM" },
+ { OFPFF_CHECK_OVERLAP, "CHECK_OVERLAP" },
+ { OFPFF_EMERG, "EMERG" },
+ { 0, NULL }
+};
+#define OFPFF_U (~(OFPFF_SEND_FLOW_REM | OFPFF_CHECK_OVERLAP | OFPFF_EMERG))
+
+#define OFPST_DESC 0x0000
+#define OFPST_FLOW 0x0001
+#define OFPST_AGGREGATE 0x0002
+#define OFPST_TABLE 0x0003
+#define OFPST_PORT 0x0004
+#define OFPST_QUEUE 0x0005
+#define OFPST_VENDOR 0xffff
+static const struct tok ofpst_str[] = {
+ { OFPST_DESC, "DESC" },
+ { OFPST_FLOW, "FLOW" },
+ { OFPST_AGGREGATE, "AGGREGATE" },
+ { OFPST_TABLE, "TABLE" },
+ { OFPST_PORT, "PORT" },
+ { OFPST_QUEUE, "QUEUE" },
+ { OFPST_VENDOR, "VENDOR" },
+ { 0, NULL }
+};
+
+static const struct tok tableid_str[] = {
+ { 0xfe, "EMERG" },
+ { 0xff, "ALL" },
+ { 0, NULL }
+};
+
+#define OFPQ_ALL 0xffffffff
+static const struct tok ofpq_str[] = {
+ { OFPQ_ALL, "ALL" },
+ { 0, NULL }
+};
+
+#define OFPSF_REPLY_MORE 0x0001
+static const struct tok ofpsf_reply_bm[] = {
+ { OFPSF_REPLY_MORE, "MORE" },
+ { 0, NULL }
+};
+#define OFPSF_REPLY_U (~(OFPSF_REPLY_MORE))
+
+#define OFPR_NO_MATCH 0x00
+#define OFPR_ACTION 0x01
+static const struct tok ofpr_str[] = {
+ { OFPR_NO_MATCH, "NO_MATCH" },
+ { OFPR_ACTION, "ACTION" },
+ { 0, NULL }
+};
+
+#define OFPRR_IDLE_TIMEOUT 0x00
+#define OFPRR_HARD_TIMEOUT 0x01
+#define OFPRR_DELETE 0x02
+static const struct tok ofprr_str[] = {
+ { OFPRR_IDLE_TIMEOUT, "IDLE_TIMEOUT" },
+ { OFPRR_HARD_TIMEOUT, "HARD_TIMEOUT" },
+ { OFPRR_DELETE, "DELETE" },
+ { 0, NULL }
+};
+
+#define OFPPR_ADD 0x00
+#define OFPPR_DELETE 0x01
+#define OFPPR_MODIFY 0x02
+static const struct tok ofppr_str[] = {
+ { OFPPR_ADD, "ADD" },
+ { OFPPR_DELETE, "DELETE" },
+ { OFPPR_MODIFY, "MODIFY" },
+ { 0, NULL }
+};
+
+#define OFPET_HELLO_FAILED 0x0000
+#define OFPET_BAD_REQUEST 0x0001
+#define OFPET_BAD_ACTION 0x0002
+#define OFPET_FLOW_MOD_FAILED 0x0003
+#define OFPET_PORT_MOD_FAILED 0x0004
+#define OFPET_QUEUE_OP_FAILED 0x0005
+static const struct tok ofpet_str[] = {
+ { OFPET_HELLO_FAILED, "HELLO_FAILED" },
+ { OFPET_BAD_REQUEST, "BAD_REQUEST" },
+ { OFPET_BAD_ACTION, "BAD_ACTION" },
+ { OFPET_FLOW_MOD_FAILED, "FLOW_MOD_FAILED" },
+ { OFPET_PORT_MOD_FAILED, "PORT_MOD_FAILED" },
+ { OFPET_QUEUE_OP_FAILED, "QUEUE_OP_FAILED" },
+ { 0, NULL }
+};
+
+#define OFPHFC_INCOMPATIBLE 0x0000
+#define OFPHFC_EPERM 0x0001
+static const struct tok ofphfc_str[] = {
+ { OFPHFC_INCOMPATIBLE, "INCOMPATIBLE" },
+ { OFPHFC_EPERM, "EPERM" },
+ { 0, NULL }
+};
+
+#define OFPBRC_BAD_VERSION 0x0000
+#define OFPBRC_BAD_TYPE 0x0001
+#define OFPBRC_BAD_STAT 0x0002
+#define OFPBRC_BAD_VENDOR 0x0003
+#define OFPBRC_BAD_SUBTYPE 0x0004
+#define OFPBRC_EPERM 0x0005
+#define OFPBRC_BAD_LEN 0x0006
+#define OFPBRC_BUFFER_EMPTY 0x0007
+#define OFPBRC_BUFFER_UNKNOWN 0x0008
+static const struct tok ofpbrc_str[] = {
+ { OFPBRC_BAD_VERSION, "BAD_VERSION" },
+ { OFPBRC_BAD_TYPE, "BAD_TYPE" },
+ { OFPBRC_BAD_STAT, "BAD_STAT" },
+ { OFPBRC_BAD_VENDOR, "BAD_VENDOR" },
+ { OFPBRC_BAD_SUBTYPE, "BAD_SUBTYPE" },
+ { OFPBRC_EPERM, "EPERM" },
+ { OFPBRC_BAD_LEN, "BAD_LEN" },
+ { OFPBRC_BUFFER_EMPTY, "BUFFER_EMPTY" },
+ { OFPBRC_BUFFER_UNKNOWN, "BUFFER_UNKNOWN" },
+ { 0, NULL }
+};
+
+#define OFPBAC_BAD_TYPE 0x0000
+#define OFPBAC_BAD_LEN 0x0001
+#define OFPBAC_BAD_VENDOR 0x0002
+#define OFPBAC_BAD_VENDOR_TYPE 0x0003
+#define OFPBAC_BAD_OUT_PORT 0x0004
+#define OFPBAC_BAD_ARGUMENT 0x0005
+#define OFPBAC_EPERM 0x0006
+#define OFPBAC_TOO_MANY 0x0007
+#define OFPBAC_BAD_QUEUE 0x0008
+static const struct tok ofpbac_str[] = {
+ { OFPBAC_BAD_TYPE, "BAD_TYPE" },
+ { OFPBAC_BAD_LEN, "BAD_LEN" },
+ { OFPBAC_BAD_VENDOR, "BAD_VENDOR" },
+ { OFPBAC_BAD_VENDOR_TYPE, "BAD_VENDOR_TYPE" },
+ { OFPBAC_BAD_OUT_PORT, "BAD_OUT_PORT" },
+ { OFPBAC_BAD_ARGUMENT, "BAD_ARGUMENT" },
+ { OFPBAC_EPERM, "EPERM" },
+ { OFPBAC_TOO_MANY, "TOO_MANY" },
+ { OFPBAC_BAD_QUEUE, "BAD_QUEUE" },
+ { 0, NULL }
+};
+
+#define OFPFMFC_ALL_TABLES_FULL 0x0000
+#define OFPFMFC_OVERLAP 0x0001
+#define OFPFMFC_EPERM 0x0002
+#define OFPFMFC_BAD_EMERG_TIMEOUT 0x0003
+#define OFPFMFC_BAD_COMMAND 0x0004
+#define OFPFMFC_UNSUPPORTED 0x0005
+static const struct tok ofpfmfc_str[] = {
+ { OFPFMFC_ALL_TABLES_FULL, "ALL_TABLES_FULL" },
+ { OFPFMFC_OVERLAP, "OVERLAP" },
+ { OFPFMFC_EPERM, "EPERM" },
+ { OFPFMFC_BAD_EMERG_TIMEOUT, "BAD_EMERG_TIMEOUT" },
+ { OFPFMFC_BAD_COMMAND, "BAD_COMMAND" },
+ { OFPFMFC_UNSUPPORTED, "UNSUPPORTED" },
+ { 0, NULL }
+};
+
+#define OFPPMFC_BAD_PORT 0x0000
+#define OFPPMFC_BAD_HW_ADDR 0x0001
+static const struct tok ofppmfc_str[] = {
+ { OFPPMFC_BAD_PORT, "BAD_PORT" },
+ { OFPPMFC_BAD_HW_ADDR, "BAD_HW_ADDR" },
+ { 0, NULL }
+};
+
+#define OFPQOFC_BAD_PORT 0x0000
+#define OFPQOFC_BAD_QUEUE 0x0001
+#define OFPQOFC_EPERM 0x0002
+static const struct tok ofpqofc_str[] = {
+ { OFPQOFC_BAD_PORT, "BAD_PORT" },
+ { OFPQOFC_BAD_QUEUE, "BAD_QUEUE" },
+ { OFPQOFC_EPERM, "EPERM" },
+ { 0, NULL }
+};
+
+static const struct tok empty_str[] = {
+ { 0, NULL }
+};
+
+/* lengths (fixed or minimal) of particular protocol structures */
+#define OF_SWITCH_CONFIG_LEN 12
+#define OF_PHY_PORT_LEN 48
+#define OF_SWITCH_FEATURES_LEN 32
+#define OF_PORT_STATUS_LEN 64
+#define OF_PORT_MOD_LEN 32
+#define OF_PACKET_IN_LEN 20
+#define OF_ACTION_OUTPUT_LEN 8
+#define OF_ACTION_VLAN_VID_LEN 8
+#define OF_ACTION_VLAN_PCP_LEN 8
+#define OF_ACTION_DL_ADDR_LEN 16
+#define OF_ACTION_NW_ADDR_LEN 8
+#define OF_ACTION_TP_PORT_LEN 8
+#define OF_ACTION_NW_TOS_LEN 8
+#define OF_ACTION_VENDOR_HEADER_LEN 8
+#define OF_ACTION_HEADER_LEN 8
+#define OF_PACKET_OUT_LEN 16
+#define OF_MATCH_LEN 40
+#define OF_FLOW_MOD_LEN 72
+#define OF_FLOW_REMOVED_LEN 88
+#define OF_ERROR_MSG_LEN 12
+#define OF_STATS_REQUEST_LEN 12
+#define OF_STATS_REPLY_LEN 12
+#define OF_DESC_STATS_LEN 1056
+#define OF_FLOW_STATS_REQUEST_LEN 44
+#define OF_FLOW_STATS_LEN 88
+#define OF_AGGREGATE_STATS_REQUEST_LEN 44
+#define OF_AGGREGATE_STATS_REPLY_LEN 24
+#define OF_TABLE_STATS_LEN 64
+#define OF_PORT_STATS_REQUEST_LEN 8
+#define OF_PORT_STATS_LEN 104
+#define OF_VENDOR_HEADER_LEN 12
+#define OF_QUEUE_PROP_HEADER_LEN 8
+#define OF_QUEUE_PROP_MIN_RATE_LEN 16
+#define OF_PACKET_QUEUE_LEN 8
+#define OF_QUEUE_GET_CONFIG_REQUEST_LEN 12
+#define OF_QUEUE_GET_CONFIG_REPLY_LEN 16
+#define OF_ACTION_ENQUEUE_LEN 16
+#define OF_QUEUE_STATS_REQUEST_LEN 8
+#define OF_QUEUE_STATS_LEN 32
+
+/* miscellaneous constants from [OF10] */
+#define OFP_MAX_TABLE_NAME_LEN 32
+#define OFP_MAX_PORT_NAME_LEN 16
+#define DESC_STR_LEN 256
+#define SERIAL_NUM_LEN 32
+#define OFP_VLAN_NONE 0xffff
+
+/* vendor extensions */
+#define BSN_SET_IP_MASK 0
+#define BSN_GET_IP_MASK_REQUEST 1
+#define BSN_GET_IP_MASK_REPLY 2
+#define BSN_SET_MIRRORING 3
+#define BSN_GET_MIRRORING_REQUEST 4
+#define BSN_GET_MIRRORING_REPLY 5
+#define BSN_SHELL_COMMAND 6
+#define BSN_SHELL_OUTPUT 7
+#define BSN_SHELL_STATUS 8
+#define BSN_GET_INTERFACES_REQUEST 9
+#define BSN_GET_INTERFACES_REPLY 10
+#define BSN_SET_PKTIN_SUPPRESSION_REQUEST 11
+#define BSN_SET_L2_TABLE_REQUEST 12
+#define BSN_GET_L2_TABLE_REQUEST 13
+#define BSN_GET_L2_TABLE_REPLY 14
+#define BSN_VIRTUAL_PORT_CREATE_REQUEST 15
+#define BSN_VIRTUAL_PORT_CREATE_REPLY 16
+#define BSN_VIRTUAL_PORT_REMOVE_REQUEST 17
+#define BSN_BW_ENABLE_SET_REQUEST 18
+#define BSN_BW_ENABLE_GET_REQUEST 19
+#define BSN_BW_ENABLE_GET_REPLY 20
+#define BSN_BW_CLEAR_DATA_REQUEST 21
+#define BSN_BW_CLEAR_DATA_REPLY 22
+#define BSN_BW_ENABLE_SET_REPLY 23
+#define BSN_SET_L2_TABLE_REPLY 24
+#define BSN_SET_PKTIN_SUPPRESSION_REPLY 25
+#define BSN_VIRTUAL_PORT_REMOVE_REPLY 26
+#define BSN_HYBRID_GET_REQUEST 27
+#define BSN_HYBRID_GET_REPLY 28
+ /* 29 */
+ /* 30 */
+#define BSN_PDU_TX_REQUEST 31
+#define BSN_PDU_TX_REPLY 32
+#define BSN_PDU_RX_REQUEST 33
+#define BSN_PDU_RX_REPLY 34
+#define BSN_PDU_RX_TIMEOUT 35
+
+static const struct tok bsn_subtype_str[] = {
+ { BSN_SET_IP_MASK, "SET_IP_MASK" },
+ { BSN_GET_IP_MASK_REQUEST, "GET_IP_MASK_REQUEST" },
+ { BSN_GET_IP_MASK_REPLY, "GET_IP_MASK_REPLY" },
+ { BSN_SET_MIRRORING, "SET_MIRRORING" },
+ { BSN_GET_MIRRORING_REQUEST, "GET_MIRRORING_REQUEST" },
+ { BSN_GET_MIRRORING_REPLY, "GET_MIRRORING_REPLY" },
+ { BSN_SHELL_COMMAND, "SHELL_COMMAND" },
+ { BSN_SHELL_OUTPUT, "SHELL_OUTPUT" },
+ { BSN_SHELL_STATUS, "SHELL_STATUS" },
+ { BSN_GET_INTERFACES_REQUEST, "GET_INTERFACES_REQUEST" },
+ { BSN_GET_INTERFACES_REPLY, "GET_INTERFACES_REPLY" },
+ { BSN_SET_PKTIN_SUPPRESSION_REQUEST, "SET_PKTIN_SUPPRESSION_REQUEST" },
+ { BSN_SET_L2_TABLE_REQUEST, "SET_L2_TABLE_REQUEST" },
+ { BSN_GET_L2_TABLE_REQUEST, "GET_L2_TABLE_REQUEST" },
+ { BSN_GET_L2_TABLE_REPLY, "GET_L2_TABLE_REPLY" },
+ { BSN_VIRTUAL_PORT_CREATE_REQUEST, "VIRTUAL_PORT_CREATE_REQUEST" },
+ { BSN_VIRTUAL_PORT_CREATE_REPLY, "VIRTUAL_PORT_CREATE_REPLY" },
+ { BSN_VIRTUAL_PORT_REMOVE_REQUEST, "VIRTUAL_PORT_REMOVE_REQUEST" },
+ { BSN_BW_ENABLE_SET_REQUEST, "BW_ENABLE_SET_REQUEST" },
+ { BSN_BW_ENABLE_GET_REQUEST, "BW_ENABLE_GET_REQUEST" },
+ { BSN_BW_ENABLE_GET_REPLY, "BW_ENABLE_GET_REPLY" },
+ { BSN_BW_CLEAR_DATA_REQUEST, "BW_CLEAR_DATA_REQUEST" },
+ { BSN_BW_CLEAR_DATA_REPLY, "BW_CLEAR_DATA_REPLY" },
+ { BSN_BW_ENABLE_SET_REPLY, "BW_ENABLE_SET_REPLY" },
+ { BSN_SET_L2_TABLE_REPLY, "SET_L2_TABLE_REPLY" },
+ { BSN_SET_PKTIN_SUPPRESSION_REPLY, "SET_PKTIN_SUPPRESSION_REPLY" },
+ { BSN_VIRTUAL_PORT_REMOVE_REPLY, "VIRTUAL_PORT_REMOVE_REPLY" },
+ { BSN_HYBRID_GET_REQUEST, "HYBRID_GET_REQUEST" },
+ { BSN_HYBRID_GET_REPLY, "HYBRID_GET_REPLY" },
+ { BSN_PDU_TX_REQUEST, "PDU_TX_REQUEST" },
+ { BSN_PDU_TX_REPLY, "PDU_TX_REPLY" },
+ { BSN_PDU_RX_REQUEST, "PDU_RX_REQUEST" },
+ { BSN_PDU_RX_REPLY, "PDU_RX_REPLY" },
+ { BSN_PDU_RX_TIMEOUT, "PDU_RX_TIMEOUT" },
+ { 0, NULL }
+};
+
+#define BSN_ACTION_MIRROR 1
+#define BSN_ACTION_SET_TUNNEL_DST 2
+ /* 3 */
+#define BSN_ACTION_CHECKSUM 4
+
+static const struct tok bsn_action_subtype_str[] = {
+ { BSN_ACTION_MIRROR, "MIRROR" },
+ { BSN_ACTION_SET_TUNNEL_DST, "SET_TUNNEL_DST" },
+ { BSN_ACTION_CHECKSUM, "CHECKSUM" },
+ { 0, NULL }
+};
+
+static const struct tok bsn_mirror_copy_stage_str[] = {
+ { 0, "INGRESS" },
+ { 1, "EGRESS" },
+ { 0, NULL },
+};
+
+static const struct tok bsn_onoff_str[] = {
+ { 0, "OFF" },
+ { 1, "ON" },
+ { 0, NULL },
+};
+
+static const char *
+vlan_str(const uint16_t vid)
+{
+ static char buf[sizeof("65535 (bogus)")];
+ const char *fmt;
+
+ if (vid == OFP_VLAN_NONE)
+ return "NONE";
+ fmt = (vid > 0 && vid < 0x0fff) ? "%u" : "%u (bogus)";
+ snprintf(buf, sizeof(buf), fmt, vid);
+ return buf;
+}
+
+static const char *
+pcp_str(const uint8_t pcp)
+{
+ static char buf[sizeof("255 (bogus)")];
+ snprintf(buf, sizeof(buf), pcp <= 7 ? "%u" : "%u (bogus)", pcp);
+ return buf;
+}
+
+static void
+of10_bitmap_print(netdissect_options *ndo,
+ const struct tok *t, const uint32_t v, const uint32_t u)
+{
+ const char *sep = " (";
+
+ if (v == 0)
+ return;
+ /* assigned bits */
+ for (; t->s != NULL; t++)
+ if (v & t->v) {
+ ND_PRINT((ndo, "%s%s", sep, t->s));
+ sep = ", ";
+ }
+ /* unassigned bits? */
+ ND_PRINT((ndo, v & u ? ") (bogus)" : ")"));
+}
+
+static const u_char *
+of10_data_print(netdissect_options *ndo,
+ const u_char *cp, const u_char *ep, const u_int len)
+{
+ if (len == 0)
+ return cp;
+ /* data */
+ ND_PRINT((ndo, "\n\t data (%u octets)", len));
+ ND_TCHECK2(*cp, len);
+ if (ndo->ndo_vflag >= 2)
+ hex_and_ascii_print(ndo, "\n\t ", cp, len);
+ return cp + len;
+
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return ep;
+}
+
+static const u_char *
+of10_bsn_message_print(netdissect_options *ndo,
+ const u_char *cp, const u_char *ep, const u_int len)
+{
+ const u_char *cp0 = cp;
+ uint32_t subtype;
+
+ if (len < 4)
+ goto invalid;
+ /* subtype */
+ ND_TCHECK2(*cp, 4);
+ subtype = EXTRACT_32BITS(cp);
+ cp += 4;
+ ND_PRINT((ndo, "\n\t subtype %s", tok2str(bsn_subtype_str, "unknown (0x%08x)", subtype)));
+ switch (subtype) {
+ case BSN_GET_IP_MASK_REQUEST:
+ /*
+ * 0 1 2 3
+ * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ * +---------------+---------------+---------------+---------------+
+ * | subtype |
+ * +---------------+---------------+---------------+---------------+
+ * | index | pad |
+ * +---------------+---------------+---------------+---------------+
+ * | pad |
+ * +---------------+---------------+---------------+---------------+
+ *
+ */
+ if (len != 12)
+ goto invalid;
+ /* index */
+ ND_TCHECK2(*cp, 1);
+ ND_PRINT((ndo, ", index %u", *cp));
+ cp += 1;
+ /* pad */
+ ND_TCHECK2(*cp, 7);
+ cp += 7;
+ break;
+ case BSN_SET_IP_MASK:
+ case BSN_GET_IP_MASK_REPLY:
+ /*
+ * 0 1 2 3
+ * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ * +---------------+---------------+---------------+---------------+
+ * | subtype |
+ * +---------------+---------------+---------------+---------------+
+ * | index | pad |
+ * +---------------+---------------+---------------+---------------+
+ * | mask |
+ * +---------------+---------------+---------------+---------------+
+ *
+ */
+ if (len != 12)
+ goto invalid;
+ /* index */
+ ND_TCHECK2(*cp, 1);
+ ND_PRINT((ndo, ", index %u", *cp));
+ cp += 1;
+ /* pad */
+ ND_TCHECK2(*cp, 3);
+ cp += 3;
+ /* mask */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, ", mask %s", ipaddr_string(ndo, cp)));
+ cp += 4;
+ break;
+ case BSN_SET_MIRRORING:
+ case BSN_GET_MIRRORING_REQUEST:
+ case BSN_GET_MIRRORING_REPLY:
+ /*
+ * 0 1 2 3
+ * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ * +---------------+---------------+---------------+---------------+
+ * | subtype |
+ * +---------------+---------------+---------------+---------------+
+ * | report m. p. | pad |
+ * +---------------+---------------+---------------+---------------+
+ *
+ */
+ if (len != 8)
+ goto invalid;
+ /* report_mirror_ports */
+ ND_TCHECK2(*cp, 1);
+ ND_PRINT((ndo, ", report_mirror_ports %s", tok2str(bsn_onoff_str, "bogus (%u)", *cp)));
+ cp += 1;
+ /* pad */
+ ND_TCHECK2(*cp, 3);
+ cp += 3;
+ break;
+ case BSN_GET_INTERFACES_REQUEST:
+ case BSN_GET_L2_TABLE_REQUEST:
+ case BSN_BW_ENABLE_GET_REQUEST:
+ case BSN_BW_CLEAR_DATA_REQUEST:
+ case BSN_HYBRID_GET_REQUEST:
+ /*
+ * 0 1 2 3
+ * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ * +---------------+---------------+---------------+---------------+
+ * | subtype |
+ * +---------------+---------------+---------------+---------------+
+ *
+ */
+ if (len != 4)
+ goto invalid;
+ break;
+ case BSN_VIRTUAL_PORT_REMOVE_REQUEST:
+ /*
+ * 0 1 2 3
+ * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ * +---------------+---------------+---------------+---------------+
+ * | subtype |
+ * +---------------+---------------+---------------+---------------+
+ * | vport_no |
+ * +---------------+---------------+---------------+---------------+
+ *
+ */
+ if (len != 8)
+ goto invalid;
+ /* vport_no */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, ", vport_no %u", EXTRACT_32BITS(cp)));
+ cp += 4;
+ break;
+ case BSN_SHELL_COMMAND:
+ /*
+ * 0 1 2 3
+ * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ * +---------------+---------------+---------------+---------------+
+ * | subtype |
+ * +---------------+---------------+---------------+---------------+
+ * | service |
+ * +---------------+---------------+---------------+---------------+
+ * | data ...
+ * +---------------+---------------+--------
+ *
+ */
+ if (len < 8)
+ goto invalid;
+ /* service */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, ", service %u", EXTRACT_32BITS(cp)));
+ cp += 4;
+ /* data */
+ ND_PRINT((ndo, ", data '"));
+ if (fn_printn(ndo, cp, len - 8, ep)) {
+ ND_PRINT((ndo, "'"));
+ goto trunc;
+ }
+ ND_PRINT((ndo, "'"));
+ cp += len - 8;
+ break;
+ case BSN_SHELL_OUTPUT:
+ /*
+ * 0 1 2 3
+ * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ * +---------------+---------------+---------------+---------------+
+ * | subtype |
+ * +---------------+---------------+---------------+---------------+
+ * | data ...
+ * +---------------+---------------+--------
+ *
+ */
+ /* already checked that len >= 4 */
+ /* data */
+ ND_PRINT((ndo, ", data '"));
+ if (fn_printn(ndo, cp, len - 4, ep)) {
+ ND_PRINT((ndo, "'"));
+ goto trunc;
+ }
+ ND_PRINT((ndo, "'"));
+ cp += len - 4;
+ break;
+ case BSN_SHELL_STATUS:
+ /*
+ * 0 1 2 3
+ * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ * +---------------+---------------+---------------+---------------+
+ * | subtype |
+ * +---------------+---------------+---------------+---------------+
+ * | status |
+ * +---------------+---------------+---------------+---------------+
+ *
+ */
+ if (len != 8)
+ goto invalid;
+ /* status */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, ", status 0x%08x", EXTRACT_32BITS(cp)));
+ cp += 4;
+ break;
+ default:
+ ND_TCHECK2(*cp, len - 4);
+ cp += len - 4;
+ }
+ return cp;
+
+invalid: /* skip the undersized data */
+ ND_PRINT((ndo, "%s", istr));
+ ND_TCHECK2(*cp0, len);
+ return cp0 + len;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return ep;
+}
+
+static const u_char *
+of10_bsn_actions_print(netdissect_options *ndo,
+ const u_char *cp, const u_char *ep, const u_int len)
+{
+ const u_char *cp0 = cp;
+ uint32_t subtype, vlan_tag;
+
+ if (len < 4)
+ goto invalid;
+ /* subtype */
+ ND_TCHECK2(*cp, 4);
+ subtype = EXTRACT_32BITS(cp);
+ cp += 4;
+ ND_PRINT((ndo, "\n\t subtype %s", tok2str(bsn_action_subtype_str, "unknown (0x%08x)", subtype)));
+ switch (subtype) {
+ case BSN_ACTION_MIRROR:
+ /*
+ * 0 1 2 3
+ * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ * +---------------+---------------+---------------+---------------+
+ * | subtype |
+ * +---------------+---------------+---------------+---------------+
+ * | dest_port |
+ * +---------------+---------------+---------------+---------------+
+ * | vlan_tag |
+ * +---------------+---------------+---------------+---------------+
+ * | copy_stage | pad |
+ * +---------------+---------------+---------------+---------------+
+ *
+ */
+ if (len != 16)
+ goto invalid;
+ /* dest_port */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, ", dest_port %u", EXTRACT_32BITS(cp)));
+ cp += 4;
+ /* vlan_tag */
+ ND_TCHECK2(*cp, 4);
+ vlan_tag = EXTRACT_32BITS(cp);
+ cp += 4;
+ switch (vlan_tag >> 16) {
+ case 0:
+ ND_PRINT((ndo, ", vlan_tag none"));
+ break;
+ case ETHERTYPE_8021Q:
+ ND_PRINT((ndo, ", vlan_tag 802.1Q (%s)", ieee8021q_tci_string(vlan_tag & 0xffff)));
+ break;
+ default:
+ ND_PRINT((ndo, ", vlan_tag unknown (0x%04x)", vlan_tag >> 16));
+ }
+ /* copy_stage */
+ ND_TCHECK2(*cp, 1);
+ ND_PRINT((ndo, ", copy_stage %s", tok2str(bsn_mirror_copy_stage_str, "unknown (%u)", *cp)));
+ cp += 1;
+ /* pad */
+ ND_TCHECK2(*cp, 3);
+ cp += 3;
+ break;
+ default:
+ ND_TCHECK2(*cp, len - 4);
+ cp += len - 4;
+ }
+
+ return cp;
+
+invalid:
+ ND_PRINT((ndo, "%s", istr));
+ ND_TCHECK2(*cp0, len);
+ return cp0 + len;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return ep;
+}
+
+static const u_char *
+of10_vendor_action_print(netdissect_options *ndo,
+ const u_char *cp, const u_char *ep, const u_int len)
+{
+ uint32_t vendor;
+ const u_char *(*decoder)(netdissect_options *, const u_char *, const u_char *, const u_int);
+
+ if (len < 4)
+ goto invalid;
+ /* vendor */
+ ND_TCHECK2(*cp, 4);
+ vendor = EXTRACT_32BITS(cp);
+ cp += 4;
+ ND_PRINT((ndo, ", vendor 0x%08x (%s)", vendor, of_vendor_name(vendor)));
+ /* data */
+ decoder =
+ vendor == OUI_BSN ? of10_bsn_actions_print :
+ of10_data_print;
+ return decoder(ndo, cp, ep, len - 4);
+
+invalid: /* skip the undersized data */
+ ND_PRINT((ndo, "%s", istr));
+ ND_TCHECK2(*cp, len);
+ return cp + len;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return ep;
+}
+
+static const u_char *
+of10_vendor_message_print(netdissect_options *ndo,
+ const u_char *cp, const u_char *ep, const u_int len)
+{
+ uint32_t vendor;
+ const u_char *(*decoder)(netdissect_options *, const u_char *, const u_char *, u_int);
+
+ if (len < 4)
+ goto invalid;
+ /* vendor */
+ ND_TCHECK2(*cp, 4);
+ vendor = EXTRACT_32BITS(cp);
+ cp += 4;
+ ND_PRINT((ndo, ", vendor 0x%08x (%s)", vendor, of_vendor_name(vendor)));
+ /* data */
+ decoder =
+ vendor == OUI_BSN ? of10_bsn_message_print :
+ of10_data_print;
+ return decoder(ndo, cp, ep, len - 4);
+
+invalid: /* skip the undersized data */
+ ND_PRINT((ndo, "%s", istr));
+ ND_TCHECK2(*cp, len);
+ return cp + len;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return ep;
+}
+
+/* Vendor ID is mandatory, data is optional. */
+static const u_char *
+of10_vendor_data_print(netdissect_options *ndo,
+ const u_char *cp, const u_char *ep, const u_int len)
+{
+ uint32_t vendor;
+
+ if (len < 4)
+ goto invalid;
+ /* vendor */
+ ND_TCHECK2(*cp, 4);
+ vendor = EXTRACT_32BITS(cp);
+ cp += 4;
+ ND_PRINT((ndo, ", vendor 0x%08x (%s)", vendor, of_vendor_name(vendor)));
+ /* data */
+ return of10_data_print(ndo, cp, ep, len - 4);
+
+invalid: /* skip the undersized data */
+ ND_PRINT((ndo, "%s", istr));
+ ND_TCHECK2(*cp, len);
+ return cp + len;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return ep;
+}
+
+static const u_char *
+of10_packet_data_print(netdissect_options *ndo,
+ const u_char *cp, const u_char *ep, const u_int len)
+{
+ if (len == 0)
+ return cp;
+ /* data */
+ ND_PRINT((ndo, "\n\t data (%u octets)", len));
+ if (ndo->ndo_vflag < 3)
+ return cp + len;
+ ND_TCHECK2(*cp, len);
+ ndo->ndo_vflag -= 3;
+ ND_PRINT((ndo, ", frame decoding below\n"));
+ ether_print(ndo, cp, len, ndo->ndo_snapend - cp, NULL, NULL);
+ ndo->ndo_vflag += 3;
+ return cp + len;
+
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return ep;
+}
+
+/* [OF10] Section 5.2.1 */
+static const u_char *
+of10_phy_ports_print(netdissect_options *ndo,
+ const u_char *cp, const u_char *ep, u_int len)
+{
+ const u_char *cp0 = cp;
+ const u_int len0 = len;
+
+ while (len) {
+ if (len < OF_PHY_PORT_LEN)
+ goto invalid;
+ /* port_no */
+ ND_TCHECK2(*cp, 2);
+ ND_PRINT((ndo, "\n\t port_no %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp))));
+ cp += 2;
+ /* hw_addr */
+ ND_TCHECK2(*cp, ETHER_ADDR_LEN);
+ ND_PRINT((ndo, ", hw_addr %s", etheraddr_string(ndo, cp)));
+ cp += ETHER_ADDR_LEN;
+ /* name */
+ ND_TCHECK2(*cp, OFP_MAX_PORT_NAME_LEN);
+ ND_PRINT((ndo, ", name '"));
+ fn_print(ndo, cp, cp + OFP_MAX_PORT_NAME_LEN);
+ ND_PRINT((ndo, "'"));
+ cp += OFP_MAX_PORT_NAME_LEN;
+
+ if (ndo->ndo_vflag < 2) {
+ ND_TCHECK2(*cp, 24);
+ cp += 24;
+ goto next_port;
+ }
+ /* config */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, "\n\t config 0x%08x", EXTRACT_32BITS(cp)));
+ of10_bitmap_print(ndo, ofppc_bm, EXTRACT_32BITS(cp), OFPPC_U);
+ cp += 4;
+ /* state */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, "\n\t state 0x%08x", EXTRACT_32BITS(cp)));
+ of10_bitmap_print(ndo, ofpps_bm, EXTRACT_32BITS(cp), OFPPS_U);
+ cp += 4;
+ /* curr */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, "\n\t curr 0x%08x", EXTRACT_32BITS(cp)));
+ of10_bitmap_print(ndo, ofppf_bm, EXTRACT_32BITS(cp), OFPPF_U);
+ cp += 4;
+ /* advertised */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, "\n\t advertised 0x%08x", EXTRACT_32BITS(cp)));
+ of10_bitmap_print(ndo, ofppf_bm, EXTRACT_32BITS(cp), OFPPF_U);
+ cp += 4;
+ /* supported */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, "\n\t supported 0x%08x", EXTRACT_32BITS(cp)));
+ of10_bitmap_print(ndo, ofppf_bm, EXTRACT_32BITS(cp), OFPPF_U);
+ cp += 4;
+ /* peer */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, "\n\t peer 0x%08x", EXTRACT_32BITS(cp)));
+ of10_bitmap_print(ndo, ofppf_bm, EXTRACT_32BITS(cp), OFPPF_U);
+ cp += 4;
+next_port:
+ len -= OF_PHY_PORT_LEN;
+ } /* while */
+ return cp;
+
+invalid: /* skip the undersized trailing data */
+ ND_PRINT((ndo, "%s", istr));
+ ND_TCHECK2(*cp0, len0);
+ return cp0 + len0;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return ep;
+}
+
+/* [OF10] Section 5.2.2 */
+static const u_char *
+of10_queue_props_print(netdissect_options *ndo,
+ const u_char *cp, const u_char *ep, u_int len)
+{
+ const u_char *cp0 = cp;
+ const u_int len0 = len;
+ uint16_t property, plen, rate;
+
+ while (len) {
+ u_char plen_bogus = 0, skip = 0;
+
+ if (len < OF_QUEUE_PROP_HEADER_LEN)
+ goto invalid;
+ /* property */
+ ND_TCHECK2(*cp, 2);
+ property = EXTRACT_16BITS(cp);
+ cp += 2;
+ ND_PRINT((ndo, "\n\t property %s", tok2str(ofpqt_str, "invalid (0x%04x)", property)));
+ /* len */
+ ND_TCHECK2(*cp, 2);
+ plen = EXTRACT_16BITS(cp);
+ cp += 2;
+ ND_PRINT((ndo, ", len %u", plen));
+ if (plen < OF_QUEUE_PROP_HEADER_LEN || plen > len)
+ goto invalid;
+ /* pad */
+ ND_TCHECK2(*cp, 4);
+ cp += 4;
+ /* property-specific constraints and decoding */
+ switch (property) {
+ case OFPQT_NONE:
+ plen_bogus = plen != OF_QUEUE_PROP_HEADER_LEN;
+ break;
+ case OFPQT_MIN_RATE:
+ plen_bogus = plen != OF_QUEUE_PROP_MIN_RATE_LEN;
+ break;
+ default:
+ skip = 1;
+ }
+ if (plen_bogus) {
+ ND_PRINT((ndo, " (bogus)"));
+ skip = 1;
+ }
+ if (skip) {
+ ND_TCHECK2(*cp, plen - 4);
+ cp += plen - 4;
+ goto next_property;
+ }
+ if (property == OFPQT_MIN_RATE) { /* the only case of property decoding */
+ /* rate */
+ ND_TCHECK2(*cp, 2);
+ rate = EXTRACT_16BITS(cp);
+ cp += 2;
+ if (rate > 1000)
+ ND_PRINT((ndo, ", rate disabled"));
+ else
+ ND_PRINT((ndo, ", rate %u.%u%%", rate / 10, rate % 10));
+ /* pad */
+ ND_TCHECK2(*cp, 6);
+ cp += 6;
+ }
+next_property:
+ len -= plen;
+ } /* while */
+ return cp;
+
+invalid: /* skip the rest of queue properties */
+ ND_PRINT((ndo, "%s", istr));
+ ND_TCHECK2(*cp0, len0);
+ return cp0 + len0;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return ep;
+}
+
+/* ibid */
+static const u_char *
+of10_queues_print(netdissect_options *ndo,
+ const u_char *cp, const u_char *ep, u_int len)
+{
+ const u_char *cp0 = cp;
+ const u_int len0 = len;
+ uint16_t desclen;
+
+ while (len) {
+ if (len < OF_PACKET_QUEUE_LEN)
+ goto invalid;
+ /* queue_id */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, "\n\t queue_id %u", EXTRACT_32BITS(cp)));
+ cp += 4;
+ /* len */
+ ND_TCHECK2(*cp, 2);
+ desclen = EXTRACT_16BITS(cp);
+ cp += 2;
+ ND_PRINT((ndo, ", len %u", desclen));
+ if (desclen < OF_PACKET_QUEUE_LEN || desclen > len)
+ goto invalid;
+ /* pad */
+ ND_TCHECK2(*cp, 2);
+ cp += 2;
+ /* properties */
+ if (ndo->ndo_vflag < 2) {
+ ND_TCHECK2(*cp, desclen - OF_PACKET_QUEUE_LEN);
+ cp += desclen - OF_PACKET_QUEUE_LEN;
+ goto next_queue;
+ }
+ if (ep == (cp = of10_queue_props_print(ndo, cp, ep, desclen - OF_PACKET_QUEUE_LEN)))
+ return ep; /* end of snapshot */
+next_queue:
+ len -= desclen;
+ } /* while */
+ return cp;
+
+invalid: /* skip the rest of queues */
+ ND_PRINT((ndo, "%s", istr));
+ ND_TCHECK2(*cp0, len0);
+ return cp0 + len0;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return ep;
+}
+
+/* [OF10] Section 5.2.3 */
+static const u_char *
+of10_match_print(netdissect_options *ndo,
+ const char *pfx, const u_char *cp, const u_char *ep)
+{
+ uint32_t wildcards;
+ uint16_t dl_type;
+ uint8_t nw_proto;
+ u_char nw_bits;
+ const char *field_name;
+
+ /* wildcards */
+ ND_TCHECK2(*cp, 4);
+ wildcards = EXTRACT_32BITS(cp);
+ if (wildcards & OFPFW_U)
+ ND_PRINT((ndo, "%swildcards 0x%08x (bogus)", pfx, wildcards));
+ cp += 4;
+ /* in_port */
+ ND_TCHECK2(*cp, 2);
+ if (! (wildcards & OFPFW_IN_PORT))
+ ND_PRINT((ndo, "%smatch in_port %s", pfx, tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp))));
+ cp += 2;
+ /* dl_src */
+ ND_TCHECK2(*cp, ETHER_ADDR_LEN);
+ if (! (wildcards & OFPFW_DL_SRC))
+ ND_PRINT((ndo, "%smatch dl_src %s", pfx, etheraddr_string(ndo, cp)));
+ cp += ETHER_ADDR_LEN;
+ /* dl_dst */
+ ND_TCHECK2(*cp, ETHER_ADDR_LEN);
+ if (! (wildcards & OFPFW_DL_DST))
+ ND_PRINT((ndo, "%smatch dl_dst %s", pfx, etheraddr_string(ndo, cp)));
+ cp += ETHER_ADDR_LEN;
+ /* dl_vlan */
+ ND_TCHECK2(*cp, 2);
+ if (! (wildcards & OFPFW_DL_VLAN))
+ ND_PRINT((ndo, "%smatch dl_vlan %s", pfx, vlan_str(EXTRACT_16BITS(cp))));
+ cp += 2;
+ /* dl_vlan_pcp */
+ ND_TCHECK2(*cp, 1);
+ if (! (wildcards & OFPFW_DL_VLAN_PCP))
+ ND_PRINT((ndo, "%smatch dl_vlan_pcp %s", pfx, pcp_str(*cp)));
+ cp += 1;
+ /* pad1 */
+ ND_TCHECK2(*cp, 1);
+ cp += 1;
+ /* dl_type */
+ ND_TCHECK2(*cp, 2);
+ dl_type = EXTRACT_16BITS(cp);
+ cp += 2;
+ if (! (wildcards & OFPFW_DL_TYPE))
+ ND_PRINT((ndo, "%smatch dl_type 0x%04x", pfx, dl_type));
+ /* nw_tos */
+ ND_TCHECK2(*cp, 1);
+ if (! (wildcards & OFPFW_NW_TOS))
+ ND_PRINT((ndo, "%smatch nw_tos 0x%02x", pfx, *cp));
+ cp += 1;
+ /* nw_proto */
+ ND_TCHECK2(*cp, 1);
+ nw_proto = *cp;
+ cp += 1;
+ if (! (wildcards & OFPFW_NW_PROTO)) {
+ field_name = ! (wildcards & OFPFW_DL_TYPE) && dl_type == ETHERTYPE_ARP
+ ? "arp_opcode" : "nw_proto";
+ ND_PRINT((ndo, "%smatch %s %u", pfx, field_name, nw_proto));
+ }
+ /* pad2 */
+ ND_TCHECK2(*cp, 2);
+ cp += 2;
+ /* nw_src */
+ ND_TCHECK2(*cp, 4);
+ nw_bits = (wildcards & OFPFW_NW_SRC_MASK) >> OFPFW_NW_SRC_SHIFT;
+ if (nw_bits < 32)
+ ND_PRINT((ndo, "%smatch nw_src %s/%u", pfx, ipaddr_string(ndo, cp), 32 - nw_bits));
+ cp += 4;
+ /* nw_dst */
+ ND_TCHECK2(*cp, 4);
+ nw_bits = (wildcards & OFPFW_NW_DST_MASK) >> OFPFW_NW_DST_SHIFT;
+ if (nw_bits < 32)
+ ND_PRINT((ndo, "%smatch nw_dst %s/%u", pfx, ipaddr_string(ndo, cp), 32 - nw_bits));
+ cp += 4;
+ /* tp_src */
+ ND_TCHECK2(*cp, 2);
+ if (! (wildcards & OFPFW_TP_SRC)) {
+ field_name = ! (wildcards & OFPFW_DL_TYPE) && dl_type == ETHERTYPE_IP
+ && ! (wildcards & OFPFW_NW_PROTO) && nw_proto == IPPROTO_ICMP
+ ? "icmp_type" : "tp_src";
+ ND_PRINT((ndo, "%smatch %s %u", pfx, field_name, EXTRACT_16BITS(cp)));
+ }
+ cp += 2;
+ /* tp_dst */
+ ND_TCHECK2(*cp, 2);
+ if (! (wildcards & OFPFW_TP_DST)) {
+ field_name = ! (wildcards & OFPFW_DL_TYPE) && dl_type == ETHERTYPE_IP
+ && ! (wildcards & OFPFW_NW_PROTO) && nw_proto == IPPROTO_ICMP
+ ? "icmp_code" : "tp_dst";
+ ND_PRINT((ndo, "%smatch %s %u", pfx, field_name, EXTRACT_16BITS(cp)));
+ }
+ return cp + 2;
+
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return ep;
+}
+
+/* [OF10] Section 5.2.4 */
+static const u_char *
+of10_actions_print(netdissect_options *ndo,
+ const char *pfx, const u_char *cp, const u_char *ep,
+ u_int len)
+{
+ const u_char *cp0 = cp;
+ const u_int len0 = len;
+ uint16_t type, alen, output_port;
+
+ while (len) {
+ u_char alen_bogus = 0, skip = 0;
+
+ if (len < OF_ACTION_HEADER_LEN)
+ goto invalid;
+ /* type */
+ ND_TCHECK2(*cp, 2);
+ type = EXTRACT_16BITS(cp);
+ cp += 2;
+ ND_PRINT((ndo, "%saction type %s", pfx, tok2str(ofpat_str, "invalid (0x%04x)", type)));
+ /* length */
+ ND_TCHECK2(*cp, 2);
+ alen = EXTRACT_16BITS(cp);
+ cp += 2;
+ ND_PRINT((ndo, ", len %u", alen));
+ /* On action size underrun/overrun skip the rest of the action list. */
+ if (alen < OF_ACTION_HEADER_LEN || alen > len)
+ goto invalid;
+ /* On action size inappropriate for the given type or invalid type just skip
+ * the current action, as the basic length constraint has been met. */
+ switch (type) {
+ case OFPAT_OUTPUT:
+ case OFPAT_SET_VLAN_VID:
+ case OFPAT_SET_VLAN_PCP:
+ case OFPAT_STRIP_VLAN:
+ case OFPAT_SET_NW_SRC:
+ case OFPAT_SET_NW_DST:
+ case OFPAT_SET_NW_TOS:
+ case OFPAT_SET_TP_SRC:
+ case OFPAT_SET_TP_DST:
+ alen_bogus = alen != 8;
+ break;
+ case OFPAT_SET_DL_SRC:
+ case OFPAT_SET_DL_DST:
+ case OFPAT_ENQUEUE:
+ alen_bogus = alen != 16;
+ break;
+ case OFPAT_VENDOR:
+ alen_bogus = alen % 8 != 0; /* already >= 8 so far */
+ break;
+ default:
+ skip = 1;
+ }
+ if (alen_bogus) {
+ ND_PRINT((ndo, " (bogus)"));
+ skip = 1;
+ }
+ if (skip) {
+ ND_TCHECK2(*cp, alen - 4);
+ cp += alen - 4;
+ goto next_action;
+ }
+ /* OK to decode the rest of the action structure */
+ switch (type) {
+ case OFPAT_OUTPUT:
+ /* port */
+ ND_TCHECK2(*cp, 2);
+ output_port = EXTRACT_16BITS(cp);
+ cp += 2;
+ ND_PRINT((ndo, ", port %s", tok2str(ofpp_str, "%u", output_port)));
+ /* max_len */
+ ND_TCHECK2(*cp, 2);
+ if (output_port == OFPP_CONTROLLER)
+ ND_PRINT((ndo, ", max_len %u", EXTRACT_16BITS(cp)));
+ cp += 2;
+ break;
+ case OFPAT_SET_VLAN_VID:
+ /* vlan_vid */
+ ND_TCHECK2(*cp, 2);
+ ND_PRINT((ndo, ", vlan_vid %s", vlan_str(EXTRACT_16BITS(cp))));
+ cp += 2;
+ /* pad */
+ ND_TCHECK2(*cp, 2);
+ cp += 2;
+ break;
+ case OFPAT_SET_VLAN_PCP:
+ /* vlan_pcp */
+ ND_TCHECK2(*cp, 1);
+ ND_PRINT((ndo, ", vlan_pcp %s", pcp_str(*cp)));
+ cp += 1;
+ /* pad */
+ ND_TCHECK2(*cp, 3);
+ cp += 3;
+ break;
+ case OFPAT_SET_DL_SRC:
+ case OFPAT_SET_DL_DST:
+ /* dl_addr */
+ ND_TCHECK2(*cp, ETHER_ADDR_LEN);
+ ND_PRINT((ndo, ", dl_addr %s", etheraddr_string(ndo, cp)));
+ cp += ETHER_ADDR_LEN;
+ /* pad */
+ ND_TCHECK2(*cp, 6);
+ cp += 6;
+ break;
+ case OFPAT_SET_NW_SRC:
+ case OFPAT_SET_NW_DST:
+ /* nw_addr */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, ", nw_addr %s", ipaddr_string(ndo, cp)));
+ cp += 4;
+ break;
+ case OFPAT_SET_NW_TOS:
+ /* nw_tos */
+ ND_TCHECK2(*cp, 1);
+ ND_PRINT((ndo, ", nw_tos 0x%02x", *cp));
+ cp += 1;
+ /* pad */
+ ND_TCHECK2(*cp, 3);
+ cp += 3;
+ break;
+ case OFPAT_SET_TP_SRC:
+ case OFPAT_SET_TP_DST:
+ /* nw_tos */
+ ND_TCHECK2(*cp, 2);
+ ND_PRINT((ndo, ", tp_port %u", EXTRACT_16BITS(cp)));
+ cp += 2;
+ /* pad */
+ ND_TCHECK2(*cp, 2);
+ cp += 2;
+ break;
+ case OFPAT_ENQUEUE:
+ /* port */
+ ND_TCHECK2(*cp, 2);
+ ND_PRINT((ndo, ", port %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp))));
+ cp += 2;
+ /* pad */
+ ND_TCHECK2(*cp, 6);
+ cp += 6;
+ /* queue_id */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, ", queue_id %s", tok2str(ofpq_str, "%u", EXTRACT_32BITS(cp))));
+ cp += 4;
+ break;
+ case OFPAT_VENDOR:
+ if (ep == (cp = of10_vendor_action_print(ndo, cp, ep, alen - 4)))
+ return ep; /* end of snapshot */
+ break;
+ case OFPAT_STRIP_VLAN:
+ /* pad */
+ ND_TCHECK2(*cp, 4);
+ cp += 4;
+ break;
+ } /* switch */
+next_action:
+ len -= alen;
+ } /* while */
+ return cp;
+
+invalid: /* skip the rest of actions */
+ ND_PRINT((ndo, "%s", istr));
+ ND_TCHECK2(*cp0, len0);
+ return cp0 + len0;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return ep;
+}
+
+/* [OF10] Section 5.3.1 */
+static const u_char *
+of10_features_reply_print(netdissect_options *ndo,
+ const u_char *cp, const u_char *ep, const u_int len)
+{
+ /* datapath_id */
+ ND_TCHECK2(*cp, 8);
+ ND_PRINT((ndo, "\n\t dpid 0x%016" PRIx64, EXTRACT_64BITS(cp)));
+ cp += 8;
+ /* n_buffers */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, ", n_buffers %u", EXTRACT_32BITS(cp)));
+ cp += 4;
+ /* n_tables */
+ ND_TCHECK2(*cp, 1);
+ ND_PRINT((ndo, ", n_tables %u", *cp));
+ cp += 1;
+ /* pad */
+ ND_TCHECK2(*cp, 3);
+ cp += 3;
+ /* capabilities */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, "\n\t capabilities 0x%08x", EXTRACT_32BITS(cp)));
+ of10_bitmap_print(ndo, ofp_capabilities_bm, EXTRACT_32BITS(cp), OFPCAP_U);
+ cp += 4;
+ /* actions */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, "\n\t actions 0x%08x", EXTRACT_32BITS(cp)));
+ of10_bitmap_print(ndo, ofpat_bm, EXTRACT_32BITS(cp), OFPAT_U);
+ cp += 4;
+ /* ports */
+ return of10_phy_ports_print(ndo, cp, ep, len - OF_SWITCH_FEATURES_LEN);
+
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return ep;
+}
+
+/* [OF10] Section 5.3.3 */
+static const u_char *
+of10_flow_mod_print(netdissect_options *ndo,
+ const u_char *cp, const u_char *ep, const u_int len)
+{
+ uint16_t command;
+
+ /* match */
+ if (ep == (cp = of10_match_print(ndo, "\n\t ", cp, ep)))
+ return ep; /* end of snapshot */
+ /* cookie */
+ ND_TCHECK2(*cp, 8);
+ ND_PRINT((ndo, "\n\t cookie 0x%016" PRIx64, EXTRACT_64BITS(cp)));
+ cp += 8;
+ /* command */
+ ND_TCHECK2(*cp, 2);
+ command = EXTRACT_16BITS(cp);
+ ND_PRINT((ndo, ", command %s", tok2str(ofpfc_str, "invalid (0x%04x)", command)));
+ cp += 2;
+ /* idle_timeout */
+ ND_TCHECK2(*cp, 2);
+ if (EXTRACT_16BITS(cp))
+ ND_PRINT((ndo, ", idle_timeout %u", EXTRACT_16BITS(cp)));
+ cp += 2;
+ /* hard_timeout */
+ ND_TCHECK2(*cp, 2);
+ if (EXTRACT_16BITS(cp))
+ ND_PRINT((ndo, ", hard_timeout %u", EXTRACT_16BITS(cp)));
+ cp += 2;
+ /* priority */
+ ND_TCHECK2(*cp, 2);
+ if (EXTRACT_16BITS(cp))
+ ND_PRINT((ndo, ", priority %u", EXTRACT_16BITS(cp)));
+ cp += 2;
+ /* buffer_id */
+ ND_TCHECK2(*cp, 4);
+ if (command == OFPFC_ADD || command == OFPFC_MODIFY ||
+ command == OFPFC_MODIFY_STRICT)
+ ND_PRINT((ndo, ", buffer_id %s", tok2str(bufferid_str, "0x%08x", EXTRACT_32BITS(cp))));
+ cp += 4;
+ /* out_port */
+ ND_TCHECK2(*cp, 2);
+ if (command == OFPFC_DELETE || command == OFPFC_DELETE_STRICT)
+ ND_PRINT((ndo, ", out_port %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp))));
+ cp += 2;
+ /* flags */
+ ND_TCHECK2(*cp, 2);
+ ND_PRINT((ndo, ", flags 0x%04x", EXTRACT_16BITS(cp)));
+ of10_bitmap_print(ndo, ofpff_bm, EXTRACT_16BITS(cp), OFPFF_U);
+ cp += 2;
+ /* actions */
+ return of10_actions_print(ndo, "\n\t ", cp, ep, len - OF_FLOW_MOD_LEN);
+
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return ep;
+}
+
+/* ibid */
+static const u_char *
+of10_port_mod_print(netdissect_options *ndo,
+ const u_char *cp, const u_char *ep)
+{
+ /* port_no */
+ ND_TCHECK2(*cp, 2);
+ ND_PRINT((ndo, "\n\t port_no %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp))));
+ cp += 2;
+ /* hw_addr */
+ ND_TCHECK2(*cp, ETHER_ADDR_LEN);
+ ND_PRINT((ndo, ", hw_addr %s", etheraddr_string(ndo, cp)));
+ cp += ETHER_ADDR_LEN;
+ /* config */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, "\n\t config 0x%08x", EXTRACT_32BITS(cp)));
+ of10_bitmap_print(ndo, ofppc_bm, EXTRACT_32BITS(cp), OFPPC_U);
+ cp += 4;
+ /* mask */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, "\n\t mask 0x%08x", EXTRACT_32BITS(cp)));
+ of10_bitmap_print(ndo, ofppc_bm, EXTRACT_32BITS(cp), OFPPC_U);
+ cp += 4;
+ /* advertise */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, "\n\t advertise 0x%08x", EXTRACT_32BITS(cp)));
+ of10_bitmap_print(ndo, ofppf_bm, EXTRACT_32BITS(cp), OFPPF_U);
+ cp += 4;
+ /* pad */
+ ND_TCHECK2(*cp, 4);
+ return cp + 4;
+
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return ep;
+}
+
+/* [OF10] Section 5.3.5 */
+static const u_char *
+of10_stats_request_print(netdissect_options *ndo,
+ const u_char *cp, const u_char *ep, u_int len)
+{
+ const u_char *cp0 = cp;
+ const u_int len0 = len;
+ uint16_t type;
+
+ /* type */
+ ND_TCHECK2(*cp, 2);
+ type = EXTRACT_16BITS(cp);
+ cp += 2;
+ ND_PRINT((ndo, "\n\t type %s", tok2str(ofpst_str, "invalid (0x%04x)", type)));
+ /* flags */
+ ND_TCHECK2(*cp, 2);
+ ND_PRINT((ndo, ", flags 0x%04x", EXTRACT_16BITS(cp)));
+ if (EXTRACT_16BITS(cp))
+ ND_PRINT((ndo, " (bogus)"));
+ cp += 2;
+ /* type-specific body of one of fixed lengths */
+ len -= OF_STATS_REQUEST_LEN;
+ switch(type) {
+ case OFPST_DESC:
+ case OFPST_TABLE:
+ if (len)
+ goto invalid;
+ return cp;
+ case OFPST_FLOW:
+ case OFPST_AGGREGATE:
+ if (len != OF_FLOW_STATS_REQUEST_LEN)
+ goto invalid;
+ /* match */
+ if (ep == (cp = of10_match_print(ndo, "\n\t ", cp, ep)))
+ return ep; /* end of snapshot */
+ /* table_id */
+ ND_TCHECK2(*cp, 1);
+ ND_PRINT((ndo, "\n\t table_id %s", tok2str(tableid_str, "%u", *cp)));
+ cp += 1;
+ /* pad */
+ ND_TCHECK2(*cp, 1);
+ cp += 1;
+ /* out_port */
+ ND_TCHECK2(*cp, 2);
+ ND_PRINT((ndo, ", out_port %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp))));
+ return cp + 2;
+ case OFPST_PORT:
+ if (len != OF_PORT_STATS_REQUEST_LEN)
+ goto invalid;
+ /* port_no */
+ ND_TCHECK2(*cp, 2);
+ ND_PRINT((ndo, "\n\t port_no %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp))));
+ cp += 2;
+ /* pad */
+ ND_TCHECK2(*cp, 6);
+ return cp + 6;
+ case OFPST_QUEUE:
+ if (len != OF_QUEUE_STATS_REQUEST_LEN)
+ goto invalid;
+ /* port_no */
+ ND_TCHECK2(*cp, 2);
+ ND_PRINT((ndo, "\n\t port_no %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp))));
+ cp += 2;
+ /* pad */
+ ND_TCHECK2(*cp, 2);
+ cp += 2;
+ /* queue_id */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, ", queue_id %s", tok2str(ofpq_str, "%u", EXTRACT_32BITS(cp))));
+ return cp + 4;
+ case OFPST_VENDOR:
+ return of10_vendor_data_print(ndo, cp, ep, len);
+ }
+ return cp;
+
+invalid: /* skip the message body */
+ ND_PRINT((ndo, "%s", istr));
+ ND_TCHECK2(*cp0, len0);
+ return cp0 + len0;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return ep;
+}
+
+/* ibid */
+static const u_char *
+of10_desc_stats_reply_print(netdissect_options *ndo,
+ const u_char *cp, const u_char *ep, const u_int len)
+{
+ if (len != OF_DESC_STATS_LEN)
+ goto invalid;
+ /* mfr_desc */
+ ND_TCHECK2(*cp, DESC_STR_LEN);
+ ND_PRINT((ndo, "\n\t mfr_desc '"));
+ fn_print(ndo, cp, cp + DESC_STR_LEN);
+ ND_PRINT((ndo, "'"));
+ cp += DESC_STR_LEN;
+ /* hw_desc */
+ ND_TCHECK2(*cp, DESC_STR_LEN);
+ ND_PRINT((ndo, "\n\t hw_desc '"));
+ fn_print(ndo, cp, cp + DESC_STR_LEN);
+ ND_PRINT((ndo, "'"));
+ cp += DESC_STR_LEN;
+ /* sw_desc */
+ ND_TCHECK2(*cp, DESC_STR_LEN);
+ ND_PRINT((ndo, "\n\t sw_desc '"));
+ fn_print(ndo, cp, cp + DESC_STR_LEN);
+ ND_PRINT((ndo, "'"));
+ cp += DESC_STR_LEN;
+ /* serial_num */
+ ND_TCHECK2(*cp, SERIAL_NUM_LEN);
+ ND_PRINT((ndo, "\n\t serial_num '"));
+ fn_print(ndo, cp, cp + SERIAL_NUM_LEN);
+ ND_PRINT((ndo, "'"));
+ cp += SERIAL_NUM_LEN;
+ /* dp_desc */
+ ND_TCHECK2(*cp, DESC_STR_LEN);
+ ND_PRINT((ndo, "\n\t dp_desc '"));
+ fn_print(ndo, cp, cp + DESC_STR_LEN);
+ ND_PRINT((ndo, "'"));
+ return cp + DESC_STR_LEN;
+
+invalid: /* skip the message body */
+ ND_PRINT((ndo, "%s", istr));
+ ND_TCHECK2(*cp, len);
+ return cp + len;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return ep;
+}
+
+/* ibid */
+static const u_char *
+of10_flow_stats_reply_print(netdissect_options *ndo,
+ const u_char *cp, const u_char *ep, u_int len)
+{
+ const u_char *cp0 = cp;
+ const u_int len0 = len;
+ uint16_t entry_len;
+
+ while (len) {
+ if (len < OF_FLOW_STATS_LEN)
+ goto invalid;
+ /* length */
+ ND_TCHECK2(*cp, 2);
+ entry_len = EXTRACT_16BITS(cp);
+ ND_PRINT((ndo, "\n\t length %u", entry_len));
+ if (entry_len < OF_FLOW_STATS_LEN || entry_len > len)
+ goto invalid;
+ cp += 2;
+ /* table_id */
+ ND_TCHECK2(*cp, 1);
+ ND_PRINT((ndo, ", table_id %s", tok2str(tableid_str, "%u", *cp)));
+ cp += 1;
+ /* pad */
+ ND_TCHECK2(*cp, 1);
+ cp += 1;
+ /* match */
+ if (ep == (cp = of10_match_print(ndo, "\n\t ", cp, ep)))
+ return ep; /* end of snapshot */
+ /* duration_sec */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, "\n\t duration_sec %u", EXTRACT_32BITS(cp)));
+ cp += 4;
+ /* duration_nsec */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, ", duration_nsec %u", EXTRACT_32BITS(cp)));
+ cp += 4;
+ /* priority */
+ ND_TCHECK2(*cp, 2);
+ ND_PRINT((ndo, ", priority %u", EXTRACT_16BITS(cp)));
+ cp += 2;
+ /* idle_timeout */
+ ND_TCHECK2(*cp, 2);
+ ND_PRINT((ndo, ", idle_timeout %u", EXTRACT_16BITS(cp)));
+ cp += 2;
+ /* hard_timeout */
+ ND_TCHECK2(*cp, 2);
+ ND_PRINT((ndo, ", hard_timeout %u", EXTRACT_16BITS(cp)));
+ cp += 2;
+ /* pad2 */
+ ND_TCHECK2(*cp, 6);
+ cp += 6;
+ /* cookie */
+ ND_TCHECK2(*cp, 8);
+ ND_PRINT((ndo, ", cookie 0x%016" PRIx64, EXTRACT_64BITS(cp)));
+ cp += 8;
+ /* packet_count */
+ ND_TCHECK2(*cp, 8);
+ ND_PRINT((ndo, ", packet_count %" PRIu64, EXTRACT_64BITS(cp)));
+ cp += 8;
+ /* byte_count */
+ ND_TCHECK2(*cp, 8);
+ ND_PRINT((ndo, ", byte_count %" PRIu64, EXTRACT_64BITS(cp)));
+ cp += 8;
+ /* actions */
+ if (ep == (cp = of10_actions_print(ndo, "\n\t ", cp, ep, entry_len - OF_FLOW_STATS_LEN)))
+ return ep; /* end of snapshot */
+
+ len -= entry_len;
+ } /* while */
+ return cp;
+
+invalid: /* skip the rest of flow statistics entries */
+ ND_PRINT((ndo, "%s", istr));
+ ND_TCHECK2(*cp0, len0);
+ return cp0 + len0;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return ep;
+}
+
+/* ibid */
+static const u_char *
+of10_aggregate_stats_reply_print(netdissect_options *ndo,
+ const u_char *cp, const u_char *ep,
+ const u_int len)
+{
+ if (len != OF_AGGREGATE_STATS_REPLY_LEN)
+ goto invalid;
+ /* packet_count */
+ ND_TCHECK2(*cp, 8);
+ ND_PRINT((ndo, "\n\t packet_count %" PRIu64, EXTRACT_64BITS(cp)));
+ cp += 8;
+ /* byte_count */
+ ND_TCHECK2(*cp, 8);
+ ND_PRINT((ndo, ", byte_count %" PRIu64, EXTRACT_64BITS(cp)));
+ cp += 8;
+ /* flow_count */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, ", flow_count %u", EXTRACT_32BITS(cp)));
+ cp += 4;
+ /* pad */
+ ND_TCHECK2(*cp, 4);
+ return cp + 4;
+
+invalid: /* skip the message body */
+ ND_PRINT((ndo, "%s", istr));
+ ND_TCHECK2(*cp, len);
+ return cp + len;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return ep;
+}
+
+/* ibid */
+static const u_char *
+of10_table_stats_reply_print(netdissect_options *ndo,
+ const u_char *cp, const u_char *ep, u_int len)
+{
+ const u_char *cp0 = cp;
+ const u_int len0 = len;
+
+ while (len) {
+ if (len < OF_TABLE_STATS_LEN)
+ goto invalid;
+ /* table_id */
+ ND_TCHECK2(*cp, 1);
+ ND_PRINT((ndo, "\n\t table_id %s", tok2str(tableid_str, "%u", *cp)));
+ cp += 1;
+ /* pad */
+ ND_TCHECK2(*cp, 3);
+ cp += 3;
+ /* name */
+ ND_TCHECK2(*cp, OFP_MAX_TABLE_NAME_LEN);
+ ND_PRINT((ndo, ", name '"));
+ fn_print(ndo, cp, cp + OFP_MAX_TABLE_NAME_LEN);
+ ND_PRINT((ndo, "'"));
+ cp += OFP_MAX_TABLE_NAME_LEN;
+ /* wildcards */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, "\n\t wildcards 0x%08x", EXTRACT_32BITS(cp)));
+ of10_bitmap_print(ndo, ofpfw_bm, EXTRACT_32BITS(cp), OFPFW_U);
+ cp += 4;
+ /* max_entries */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, "\n\t max_entries %u", EXTRACT_32BITS(cp)));
+ cp += 4;
+ /* active_count */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, ", active_count %u", EXTRACT_32BITS(cp)));
+ cp += 4;
+ /* lookup_count */
+ ND_TCHECK2(*cp, 8);
+ ND_PRINT((ndo, ", lookup_count %" PRIu64, EXTRACT_64BITS(cp)));
+ cp += 8;
+ /* matched_count */
+ ND_TCHECK2(*cp, 8);
+ ND_PRINT((ndo, ", matched_count %" PRIu64, EXTRACT_64BITS(cp)));
+ cp += 8;
+
+ len -= OF_TABLE_STATS_LEN;
+ } /* while */
+ return cp;
+
+invalid: /* skip the undersized trailing data */
+ ND_PRINT((ndo, "%s", istr));
+ ND_TCHECK2(*cp0, len0);
+ return cp0 + len0;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return ep;
+}
+
+/* ibid */
+static const u_char *
+of10_port_stats_reply_print(netdissect_options *ndo,
+ const u_char *cp, const u_char *ep, u_int len)
+{
+ const u_char *cp0 = cp;
+ const u_int len0 = len;
+
+ while (len) {
+ if (len < OF_PORT_STATS_LEN)
+ goto invalid;
+ /* port_no */
+ ND_TCHECK2(*cp, 2);
+ ND_PRINT((ndo, "\n\t port_no %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp))));
+ cp += 2;
+ if (ndo->ndo_vflag < 2) {
+ ND_TCHECK2(*cp, OF_PORT_STATS_LEN - 2);
+ cp += OF_PORT_STATS_LEN - 2;
+ goto next_port;
+ }
+ /* pad */
+ ND_TCHECK2(*cp, 6);
+ cp += 6;
+ /* rx_packets */
+ ND_TCHECK2(*cp, 8);
+ ND_PRINT((ndo, ", rx_packets %" PRIu64, EXTRACT_64BITS(cp)));
+ cp += 8;
+ /* tx_packets */
+ ND_TCHECK2(*cp, 8);
+ ND_PRINT((ndo, ", tx_packets %" PRIu64, EXTRACT_64BITS(cp)));
+ cp += 8;
+ /* rx_bytes */
+ ND_TCHECK2(*cp, 8);
+ ND_PRINT((ndo, ", rx_bytes %" PRIu64, EXTRACT_64BITS(cp)));
+ cp += 8;
+ /* tx_bytes */
+ ND_TCHECK2(*cp, 8);
+ ND_PRINT((ndo, ", tx_bytes %" PRIu64, EXTRACT_64BITS(cp)));
+ cp += 8;
+ /* rx_dropped */
+ ND_TCHECK2(*cp, 8);
+ ND_PRINT((ndo, ", rx_dropped %" PRIu64, EXTRACT_64BITS(cp)));
+ cp += 8;
+ /* tx_dropped */
+ ND_TCHECK2(*cp, 8);
+ ND_PRINT((ndo, ", tx_dropped %" PRIu64, EXTRACT_64BITS(cp)));
+ cp += 8;
+ /* rx_errors */
+ ND_TCHECK2(*cp, 8);
+ ND_PRINT((ndo, ", rx_errors %" PRIu64, EXTRACT_64BITS(cp)));
+ cp += 8;
+ /* tx_errors */
+ ND_TCHECK2(*cp, 8);
+ ND_PRINT((ndo, ", tx_errors %" PRIu64, EXTRACT_64BITS(cp)));
+ cp += 8;
+ /* rx_frame_err */
+ ND_TCHECK2(*cp, 8);
+ ND_PRINT((ndo, ", rx_frame_err %" PRIu64, EXTRACT_64BITS(cp)));
+ cp += 8;
+ /* rx_over_err */
+ ND_TCHECK2(*cp, 8);
+ ND_PRINT((ndo, ", rx_over_err %" PRIu64, EXTRACT_64BITS(cp)));
+ cp += 8;
+ /* rx_crc_err */
+ ND_TCHECK2(*cp, 8);
+ ND_PRINT((ndo, ", rx_crc_err %" PRIu64, EXTRACT_64BITS(cp)));
+ cp += 8;
+ /* collisions */
+ ND_TCHECK2(*cp, 8);
+ ND_PRINT((ndo, ", collisions %" PRIu64, EXTRACT_64BITS(cp)));
+ cp += 8;
+next_port:
+ len -= OF_PORT_STATS_LEN;
+ } /* while */
+ return cp;
+
+invalid: /* skip the undersized trailing data */
+ ND_PRINT((ndo, "%s", istr));
+ ND_TCHECK2(*cp0, len0);
+ return cp0 + len0;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return ep;
+}
+
+/* ibid */
+static const u_char *
+of10_queue_stats_reply_print(netdissect_options *ndo,
+ const u_char *cp, const u_char *ep, u_int len)
+{
+ const u_char *cp0 = cp;
+ const u_int len0 = len;
+
+ while (len) {
+ if (len < OF_QUEUE_STATS_LEN)
+ goto invalid;
+ /* port_no */
+ ND_TCHECK2(*cp, 2);
+ ND_PRINT((ndo, "\n\t port_no %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp))));
+ cp += 2;
+ /* pad */
+ ND_TCHECK2(*cp, 2);
+ cp += 2;
+ /* queue_id */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, ", queue_id %u", EXTRACT_32BITS(cp)));
+ cp += 4;
+ /* tx_bytes */
+ ND_TCHECK2(*cp, 8);
+ ND_PRINT((ndo, ", tx_bytes %" PRIu64, EXTRACT_64BITS(cp)));
+ cp += 8;
+ /* tx_packets */
+ ND_TCHECK2(*cp, 8);
+ ND_PRINT((ndo, ", tx_packets %" PRIu64, EXTRACT_64BITS(cp)));
+ cp += 8;
+ /* tx_errors */
+ ND_TCHECK2(*cp, 8);
+ ND_PRINT((ndo, ", tx_errors %" PRIu64, EXTRACT_64BITS(cp)));
+ cp += 8;
+
+ len -= OF_QUEUE_STATS_LEN;
+ } /* while */
+ return cp;
+
+invalid: /* skip the undersized trailing data */
+ ND_PRINT((ndo, "%s", istr));
+ ND_TCHECK2(*cp0, len0);
+ return cp0 + len0;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return ep;
+}
+
+/* ibid */
+static const u_char *
+of10_stats_reply_print(netdissect_options *ndo,
+ const u_char *cp, const u_char *ep, const u_int len)
+{
+ const u_char *cp0 = cp;
+ uint16_t type;
+
+ /* type */
+ ND_TCHECK2(*cp, 2);
+ type = EXTRACT_16BITS(cp);
+ ND_PRINT((ndo, "\n\t type %s", tok2str(ofpst_str, "invalid (0x%04x)", type)));
+ cp += 2;
+ /* flags */
+ ND_TCHECK2(*cp, 2);
+ ND_PRINT((ndo, ", flags 0x%04x", EXTRACT_16BITS(cp)));
+ of10_bitmap_print(ndo, ofpsf_reply_bm, EXTRACT_16BITS(cp), OFPSF_REPLY_U);
+ cp += 2;
+
+ if (ndo->ndo_vflag > 0) {
+ const u_char *(*decoder)(netdissect_options *, const u_char *, const u_char *, u_int) =
+ type == OFPST_DESC ? of10_desc_stats_reply_print :
+ type == OFPST_FLOW ? of10_flow_stats_reply_print :
+ type == OFPST_AGGREGATE ? of10_aggregate_stats_reply_print :
+ type == OFPST_TABLE ? of10_table_stats_reply_print :
+ type == OFPST_PORT ? of10_port_stats_reply_print :
+ type == OFPST_QUEUE ? of10_queue_stats_reply_print :
+ type == OFPST_VENDOR ? of10_vendor_data_print :
+ NULL;
+ if (decoder != NULL)
+ return decoder(ndo, cp, ep, len - OF_STATS_REPLY_LEN);
+ }
+ ND_TCHECK2(*cp0, len);
+ return cp0 + len;
+
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return ep;
+}
+
+/* [OF10] Section 5.3.6 */
+static const u_char *
+of10_packet_out_print(netdissect_options *ndo,
+ const u_char *cp, const u_char *ep, const u_int len)
+{
+ const u_char *cp0 = cp;
+ const u_int len0 = len;
+ uint16_t actions_len;
+
+ /* buffer_id */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, "\n\t buffer_id 0x%08x", EXTRACT_32BITS(cp)));
+ cp += 4;
+ /* in_port */
+ ND_TCHECK2(*cp, 2);
+ ND_PRINT((ndo, ", in_port %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp))));
+ cp += 2;
+ /* actions_len */
+ ND_TCHECK2(*cp, 2);
+ actions_len = EXTRACT_16BITS(cp);
+ cp += 2;
+ if (actions_len > len - OF_PACKET_OUT_LEN)
+ goto invalid;
+ /* actions */
+ if (ep == (cp = of10_actions_print(ndo, "\n\t ", cp, ep, actions_len)))
+ return ep; /* end of snapshot */
+ /* data */
+ return of10_packet_data_print(ndo, cp, ep, len - OF_PACKET_OUT_LEN - actions_len);
+
+invalid: /* skip the rest of the message body */
+ ND_PRINT((ndo, "%s", istr));
+ ND_TCHECK2(*cp0, len0);
+ return cp0 + len0;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return ep;
+}
+
+/* [OF10] Section 5.4.1 */
+static const u_char *
+of10_packet_in_print(netdissect_options *ndo,
+ const u_char *cp, const u_char *ep, const u_int len)
+{
+ /* buffer_id */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, "\n\t buffer_id %s", tok2str(bufferid_str, "0x%08x", EXTRACT_32BITS(cp))));
+ cp += 4;
+ /* total_len */
+ ND_TCHECK2(*cp, 2);
+ ND_PRINT((ndo, ", total_len %u", EXTRACT_16BITS(cp)));
+ cp += 2;
+ /* in_port */
+ ND_TCHECK2(*cp, 2);
+ ND_PRINT((ndo, ", in_port %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp))));
+ cp += 2;
+ /* reason */
+ ND_TCHECK2(*cp, 1);
+ ND_PRINT((ndo, ", reason %s", tok2str(ofpr_str, "invalid (0x%02x)", *cp)));
+ cp += 1;
+ /* pad */
+ ND_TCHECK2(*cp, 1);
+ cp += 1;
+ /* data */
+ /* 2 mock octets count in OF_PACKET_IN_LEN but not in len */
+ return of10_packet_data_print(ndo, cp, ep, len - (OF_PACKET_IN_LEN - 2));
+
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return ep;
+}
+
+/* [OF10] Section 5.4.2 */
+static const u_char *
+of10_flow_removed_print(netdissect_options *ndo,
+ const u_char *cp, const u_char *ep)
+{
+ /* match */
+ if (ep == (cp = of10_match_print(ndo, "\n\t ", cp, ep)))
+ return ep; /* end of snapshot */
+ /* cookie */
+ ND_TCHECK2(*cp, 8);
+ ND_PRINT((ndo, "\n\t cookie 0x%016" PRIx64, EXTRACT_64BITS(cp)));
+ cp += 8;
+ /* priority */
+ ND_TCHECK2(*cp, 2);
+ if (EXTRACT_16BITS(cp))
+ ND_PRINT((ndo, ", priority %u", EXTRACT_16BITS(cp)));
+ cp += 2;
+ /* reason */
+ ND_TCHECK2(*cp, 1);
+ ND_PRINT((ndo, ", reason %s", tok2str(ofprr_str, "unknown (0x%02x)", *cp)));
+ cp += 1;
+ /* pad */
+ ND_TCHECK2(*cp, 1);
+ cp += 1;
+ /* duration_sec */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, ", duration_sec %u", EXTRACT_32BITS(cp)));
+ cp += 4;
+ /* duration_nsec */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, ", duration_nsec %u", EXTRACT_32BITS(cp)));
+ cp += 4;
+ /* idle_timeout */
+ ND_TCHECK2(*cp, 2);
+ if (EXTRACT_16BITS(cp))
+ ND_PRINT((ndo, ", idle_timeout %u", EXTRACT_16BITS(cp)));
+ cp += 2;
+ /* pad2 */
+ ND_TCHECK2(*cp, 2);
+ cp += 2;
+ /* packet_count */
+ ND_TCHECK2(*cp, 8);
+ ND_PRINT((ndo, ", packet_count %" PRIu64, EXTRACT_64BITS(cp)));
+ cp += 8;
+ /* byte_count */
+ ND_TCHECK2(*cp, 8);
+ ND_PRINT((ndo, ", byte_count %" PRIu64, EXTRACT_64BITS(cp)));
+ return cp + 8;
+
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return ep;
+}
+
+/* [OF10] Section 5.4.4 */
+static const u_char *
+of10_error_print(netdissect_options *ndo,
+ const u_char *cp, const u_char *ep, const u_int len)
+{
+ uint16_t type;
+ const struct tok *code_str;
+
+ /* type */
+ ND_TCHECK2(*cp, 2);
+ type = EXTRACT_16BITS(cp);
+ cp += 2;
+ ND_PRINT((ndo, "\n\t type %s", tok2str(ofpet_str, "invalid (0x%04x)", type)));
+ /* code */
+ ND_TCHECK2(*cp, 2);
+ code_str =
+ type == OFPET_HELLO_FAILED ? ofphfc_str :
+ type == OFPET_BAD_REQUEST ? ofpbrc_str :
+ type == OFPET_BAD_ACTION ? ofpbac_str :
+ type == OFPET_FLOW_MOD_FAILED ? ofpfmfc_str :
+ type == OFPET_PORT_MOD_FAILED ? ofppmfc_str :
+ type == OFPET_QUEUE_OP_FAILED ? ofpqofc_str :
+ empty_str;
+ ND_PRINT((ndo, ", code %s", tok2str(code_str, "invalid (0x%04x)", EXTRACT_16BITS(cp))));
+ cp += 2;
+ /* data */
+ return of10_data_print(ndo, cp, ep, len - OF_ERROR_MSG_LEN);
+
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return ep;
+}
+
+const u_char *
+of10_header_body_print(netdissect_options *ndo,
+ const u_char *cp, const u_char *ep, const uint8_t type,
+ const uint16_t len, const uint32_t xid)
+{
+ const u_char *cp0 = cp;
+ const u_int len0 = len;
+ /* Thus far message length is not less than the basic header size, but most
+ * message types have additional assorted constraints on the length. Wherever
+ * possible, check that message length meets the constraint, in remaining
+ * cases check that the length is OK to begin decoding and leave any final
+ * verification up to a lower-layer function. When the current message is
+ * invalid, proceed to the next message. */
+
+ /* [OF10] Section 5.1 */
+ ND_PRINT((ndo, "\n\tversion 1.0, type %s, length %u, xid 0x%08x",
+ tok2str(ofpt_str, "invalid (0x%02x)", type), len, xid));
+ switch (type) {
+ /* OpenFlow header only. */
+ case OFPT_FEATURES_REQUEST: /* [OF10] Section 5.3.1 */
+ case OFPT_GET_CONFIG_REQUEST: /* [OF10] Section 5.3.2 */
+ case OFPT_BARRIER_REQUEST: /* [OF10] Section 5.3.7 */
+ case OFPT_BARRIER_REPLY: /* ibid */
+ if (len != OF_HEADER_LEN)
+ goto invalid;
+ break;
+
+ /* OpenFlow header and fixed-size message body. */
+ case OFPT_SET_CONFIG: /* [OF10] Section 5.3.2 */
+ case OFPT_GET_CONFIG_REPLY: /* ibid */
+ if (len != OF_SWITCH_CONFIG_LEN)
+ goto invalid;
+ if (ndo->ndo_vflag < 1)
+ goto next_message;
+ /* flags */
+ ND_TCHECK2(*cp, 2);
+ ND_PRINT((ndo, "\n\t flags %s", tok2str(ofp_config_str, "invalid (0x%04x)", EXTRACT_16BITS(cp))));
+ cp += 2;
+ /* miss_send_len */
+ ND_TCHECK2(*cp, 2);
+ ND_PRINT((ndo, ", miss_send_len %u", EXTRACT_16BITS(cp)));
+ return cp + 2;
+ case OFPT_PORT_MOD:
+ if (len != OF_PORT_MOD_LEN)
+ goto invalid;
+ if (ndo->ndo_vflag < 1)
+ goto next_message;
+ return of10_port_mod_print(ndo, cp, ep);
+ case OFPT_QUEUE_GET_CONFIG_REQUEST: /* [OF10] Section 5.3.4 */
+ if (len != OF_QUEUE_GET_CONFIG_REQUEST_LEN)
+ goto invalid;
+ if (ndo->ndo_vflag < 1)
+ goto next_message;
+ /* port */
+ ND_TCHECK2(*cp, 2);
+ ND_PRINT((ndo, "\n\t port_no %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp))));
+ cp += 2;
+ /* pad */
+ ND_TCHECK2(*cp, 2);
+ return cp + 2;
+ case OFPT_FLOW_REMOVED:
+ if (len != OF_FLOW_REMOVED_LEN)
+ goto invalid;
+ if (ndo->ndo_vflag < 1)
+ goto next_message;
+ return of10_flow_removed_print(ndo, cp, ep);
+ case OFPT_PORT_STATUS: /* [OF10] Section 5.4.3 */
+ if (len != OF_PORT_STATUS_LEN)
+ goto invalid;
+ if (ndo->ndo_vflag < 1)
+ goto next_message;
+ /* reason */
+ ND_TCHECK2(*cp, 1);
+ ND_PRINT((ndo, "\n\t reason %s", tok2str(ofppr_str, "invalid (0x%02x)", *cp)));
+ cp += 1;
+ /* pad */
+ ND_TCHECK2(*cp, 7);
+ cp += 7;
+ /* desc */
+ return of10_phy_ports_print(ndo, cp, ep, OF_PHY_PORT_LEN);
+
+ /* OpenFlow header, fixed-size message body and n * fixed-size data units. */
+ case OFPT_FEATURES_REPLY:
+ if (len < OF_SWITCH_FEATURES_LEN)
+ goto invalid;
+ if (ndo->ndo_vflag < 1)
+ goto next_message;
+ return of10_features_reply_print(ndo, cp, ep, len);
+
+ /* OpenFlow header and variable-size data. */
+ case OFPT_HELLO: /* [OF10] Section 5.5.1 */
+ case OFPT_ECHO_REQUEST: /* [OF10] Section 5.5.2 */
+ case OFPT_ECHO_REPLY: /* [OF10] Section 5.5.3 */
+ if (ndo->ndo_vflag < 1)
+ goto next_message;
+ return of10_data_print(ndo, cp, ep, len - OF_HEADER_LEN);
+
+ /* OpenFlow header, fixed-size message body and variable-size data. */
+ case OFPT_ERROR:
+ if (len < OF_ERROR_MSG_LEN)
+ goto invalid;
+ if (ndo->ndo_vflag < 1)
+ goto next_message;
+ return of10_error_print(ndo, cp, ep, len);
+ case OFPT_VENDOR:
+ /* [OF10] Section 5.5.4 */
+ if (len < OF_VENDOR_HEADER_LEN)
+ goto invalid;
+ if (ndo->ndo_vflag < 1)
+ goto next_message;
+ return of10_vendor_message_print(ndo, cp, ep, len - OF_HEADER_LEN);
+ case OFPT_PACKET_IN:
+ /* 2 mock octets count in OF_PACKET_IN_LEN but not in len */
+ if (len < OF_PACKET_IN_LEN - 2)
+ goto invalid;
+ if (ndo->ndo_vflag < 1)
+ goto next_message;
+ return of10_packet_in_print(ndo, cp, ep, len);
+
+ /* a. OpenFlow header. */
+ /* b. OpenFlow header and one of the fixed-size message bodies. */
+ /* c. OpenFlow header, fixed-size message body and variable-size data. */
+ case OFPT_STATS_REQUEST:
+ if (len < OF_STATS_REQUEST_LEN)
+ goto invalid;
+ if (ndo->ndo_vflag < 1)
+ goto next_message;
+ return of10_stats_request_print(ndo, cp, ep, len);
+
+ /* a. OpenFlow header and fixed-size message body. */
+ /* b. OpenFlow header and n * fixed-size data units. */
+ /* c. OpenFlow header and n * variable-size data units. */
+ /* d. OpenFlow header, fixed-size message body and variable-size data. */
+ case OFPT_STATS_REPLY:
+ if (len < OF_STATS_REPLY_LEN)
+ goto invalid;
+ if (ndo->ndo_vflag < 1)
+ goto next_message;
+ return of10_stats_reply_print(ndo, cp, ep, len);
+
+ /* OpenFlow header and n * variable-size data units and variable-size data. */
+ case OFPT_PACKET_OUT:
+ if (len < OF_PACKET_OUT_LEN)
+ goto invalid;
+ if (ndo->ndo_vflag < 1)
+ goto next_message;
+ return of10_packet_out_print(ndo, cp, ep, len);
+
+ /* OpenFlow header, fixed-size message body and n * variable-size data units. */
+ case OFPT_FLOW_MOD:
+ if (len < OF_FLOW_MOD_LEN)
+ goto invalid;
+ if (ndo->ndo_vflag < 1)
+ goto next_message;
+ return of10_flow_mod_print(ndo, cp, ep, len);
+
+ /* OpenFlow header, fixed-size message body and n * variable-size data units. */
+ case OFPT_QUEUE_GET_CONFIG_REPLY: /* [OF10] Section 5.3.4 */
+ if (len < OF_QUEUE_GET_CONFIG_REPLY_LEN)
+ goto invalid;
+ if (ndo->ndo_vflag < 1)
+ goto next_message;
+ /* port */
+ ND_TCHECK2(*cp, 2);
+ ND_PRINT((ndo, "\n\t port_no %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp))));
+ cp += 2;
+ /* pad */
+ ND_TCHECK2(*cp, 6);
+ cp += 6;
+ /* queues */
+ return of10_queues_print(ndo, cp, ep, len - OF_QUEUE_GET_CONFIG_REPLY_LEN);
+ } /* switch (type) */
+ goto next_message;
+
+invalid: /* skip the message body */
+ ND_PRINT((ndo, "%s", istr));
+next_message:
+ ND_TCHECK2(*cp0, len0 - OF_HEADER_LEN);
+ return cp0 + len0 - OF_HEADER_LEN;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return ep;
+}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-openflow-1.0-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-openflow.c b/freebsd/contrib/tcpdump/print-openflow.c
new file mode 100644
index 00000000..4368741b
--- /dev/null
+++ b/freebsd/contrib/tcpdump/print-openflow.c
@@ -0,0 +1,150 @@
+#include <machine/rtems-bsd-user-space.h>
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
+/*
+ * This module implements printing of the very basic (version-independent)
+ * OpenFlow header and iteration over OpenFlow messages. It is intended for
+ * dispatching of version-specific OpenFlow message decoding.
+ *
+ *
+ * Copyright (c) 2013 The TCPDUMP project
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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
+ * COPYRIGHT HOLDER 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: version-independent OpenFlow printer */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <netdissect-stdinc.h>
+
+#include "netdissect.h"
+#include "extract.h"
+#include "openflow.h"
+#include "oui.h"
+
+static const char tstr[] = " [|openflow]";
+
+#define OF_VER_1_0 0x01
+
+const struct tok onf_exp_str[] = {
+ { ONF_EXP_ONF, "ONF Extensions" },
+ { ONF_EXP_BUTE, "Budapest University of Technology and Economics" },
+ { ONF_EXP_NOVIFLOW, "NoviFlow" },
+ { ONF_EXP_L3, "L3+ Extensions, Vendor Neutral" },
+ { ONF_EXP_L4L7, "L4-L7 Extensions" },
+ { ONF_EXP_WMOB, "Wireless and Mobility Extensions" },
+ { ONF_EXP_FABS, "Forwarding Abstractions Extensions" },
+ { ONF_EXP_OTRANS, "Optical Transport Extensions" },
+ { 0, NULL }
+};
+
+const char *
+of_vendor_name(const uint32_t vendor)
+{
+ const struct tok *table = (vendor & 0xff000000) == 0 ? oui_values : onf_exp_str;
+ return tok2str(table, "unknown", vendor);
+}
+
+static void
+of_header_print(netdissect_options *ndo, const uint8_t version, const uint8_t type,
+ const uint16_t length, const uint32_t xid)
+{
+ ND_PRINT((ndo, "\n\tversion unknown (0x%02x), type 0x%02x, length %u, xid 0x%08x",
+ version, type, length, xid));
+}
+
+/* Print a single OpenFlow message. */
+static const u_char *
+of_header_body_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
+{
+ uint8_t version, type;
+ uint16_t length;
+ uint32_t xid;
+
+ if (ep < cp + OF_HEADER_LEN)
+ goto invalid;
+ /* version */
+ ND_TCHECK2(*cp, 1);
+ version = *cp;
+ cp += 1;
+ /* type */
+ ND_TCHECK2(*cp, 1);
+ type = *cp;
+ cp += 1;
+ /* length */
+ ND_TCHECK2(*cp, 2);
+ length = EXTRACT_16BITS(cp);
+ cp += 2;
+ /* xid */
+ ND_TCHECK2(*cp, 4);
+ xid = EXTRACT_32BITS(cp);
+ cp += 4;
+ /* Message length includes the header length and a message always includes
+ * the basic header. A message length underrun fails decoding of the rest of
+ * the current packet. At the same time, try decoding as much of the current
+ * message as possible even when it does not end within the current TCP
+ * segment. */
+ if (length < OF_HEADER_LEN) {
+ of_header_print(ndo, version, type, length, xid);
+ goto invalid;
+ }
+ /* Decode known protocol versions further without printing the header (the
+ * type decoding is version-specific. */
+ switch (version) {
+ case OF_VER_1_0:
+ return of10_header_body_print(ndo, cp, ep, type, length, xid);
+ default:
+ of_header_print(ndo, version, type, length, xid);
+ ND_TCHECK2(*cp, length - OF_HEADER_LEN);
+ return cp + length - OF_HEADER_LEN; /* done with current message */
+ }
+
+invalid: /* fail current packet */
+ ND_PRINT((ndo, "%s", istr));
+ ND_TCHECK2(*cp, ep - cp);
+ return ep;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return ep;
+}
+
+/* Print a TCP segment worth of OpenFlow messages presuming the segment begins
+ * on a message boundary. */
+void
+openflow_print(netdissect_options *ndo, const u_char *cp, const u_int len)
+{
+ const u_char *ep = cp + len;
+
+ ND_PRINT((ndo, ": OpenFlow"));
+ while (cp < ep)
+ cp = of_header_body_print(ndo, cp, ep);
+}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-openflow-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-ospf.c b/freebsd/contrib/tcpdump/print-ospf.c
index 769a29f0..1655dde5 100644
--- a/freebsd/contrib/tcpdump/print-ospf.c
+++ b/freebsd/contrib/tcpdump/print-ospf.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1992, 1993, 1994, 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
@@ -23,29 +26,24 @@
* OSPF support contributed by Jeffrey Honig (jch@mitchell.cit.cornell.edu)
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ospf.c,v 1.66 2007-10-08 07:53:21 hannes Exp $ (LBL)";
-#endif
+/* \summary: Open Shortest Path First (OSPF) printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
-
-#include <stdio.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "extract.h"
#include "gmpls.h"
#include "ospf.h"
-#include "ip.h"
+static const char tstr[] = " [|ospf2]";
-static struct tok ospf_option_values[] = {
+static const struct tok ospf_option_values[] = {
{ OSPF_OPTION_T, "MultiTopology" }, /* draft-ietf-ospf-mt-09 */
{ OSPF_OPTION_E, "External" },
{ OSPF_OPTION_MC, "Multicast" },
@@ -57,14 +55,14 @@ static struct tok ospf_option_values[] = {
{ 0, NULL }
};
-static struct tok ospf_authtype_values[] = {
+static const struct tok ospf_authtype_values[] = {
{ OSPF_AUTH_NONE, "none" },
{ OSPF_AUTH_SIMPLE, "simple" },
{ OSPF_AUTH_MD5, "MD5" },
{ 0, NULL }
};
-static struct tok ospf_rla_flag_values[] = {
+static const struct tok ospf_rla_flag_values[] = {
{ RLA_FLAG_B, "ABR" },
{ RLA_FLAG_E, "ASBR" },
{ RLA_FLAG_W1, "Virtual" },
@@ -72,7 +70,7 @@ static struct tok ospf_rla_flag_values[] = {
{ 0, NULL }
};
-static struct tok type2str[] = {
+static const struct tok type2str[] = {
{ OSPF_TYPE_UMD, "UMD" },
{ OSPF_TYPE_HELLO, "Hello" },
{ OSPF_TYPE_DD, "Database Description" },
@@ -82,7 +80,7 @@ static struct tok type2str[] = {
{ 0, NULL }
};
-static struct tok lsa_values[] = {
+static const struct tok lsa_values[] = {
{ LS_TYPE_ROUTER, "Router" },
{ LS_TYPE_NETWORK, "Network" },
{ LS_TYPE_SUM_IP, "Summary" },
@@ -96,7 +94,7 @@ static struct tok lsa_values[] = {
{ 0, NULL }
};
-static struct tok ospf_dd_flag_values[] = {
+static const struct tok ospf_dd_flag_values[] = {
{ OSPF_DB_INIT, "Init" },
{ OSPF_DB_MORE, "More" },
{ OSPF_DB_MASTER, "Master" },
@@ -104,20 +102,20 @@ static struct tok ospf_dd_flag_values[] = {
{ 0, NULL }
};
-static struct tok lsa_opaque_values[] = {
+static const struct tok lsa_opaque_values[] = {
{ LS_OPAQUE_TYPE_TE, "Traffic Engineering" },
{ LS_OPAQUE_TYPE_GRACE, "Graceful restart" },
{ LS_OPAQUE_TYPE_RI, "Router Information" },
{ 0, NULL }
};
-static struct tok lsa_opaque_te_tlv_values[] = {
+static const struct tok lsa_opaque_te_tlv_values[] = {
{ LS_OPAQUE_TE_TLV_ROUTER, "Router Address" },
{ LS_OPAQUE_TE_TLV_LINK, "Link" },
{ 0, NULL }
};
-static struct tok lsa_opaque_te_link_tlv_subtlv_values[] = {
+static const struct tok lsa_opaque_te_link_tlv_subtlv_values[] = {
{ LS_OPAQUE_TE_LINK_SUBTLV_LINK_TYPE, "Link Type" },
{ LS_OPAQUE_TE_LINK_SUBTLV_LINK_ID, "Link ID" },
{ LS_OPAQUE_TE_LINK_SUBTLV_LOCAL_IP, "Local Interface IP address" },
@@ -135,14 +133,14 @@ static struct tok lsa_opaque_te_link_tlv_subtlv_values[] = {
{ 0, NULL }
};
-static struct tok lsa_opaque_grace_tlv_values[] = {
+static const struct tok lsa_opaque_grace_tlv_values[] = {
{ LS_OPAQUE_GRACE_TLV_PERIOD, "Grace Period" },
{ LS_OPAQUE_GRACE_TLV_REASON, "Graceful restart Reason" },
{ LS_OPAQUE_GRACE_TLV_INT_ADDRESS, "IPv4 interface address" },
{ 0, NULL }
};
-static struct tok lsa_opaque_grace_tlv_reason_values[] = {
+static const struct tok lsa_opaque_grace_tlv_reason_values[] = {
{ LS_OPAQUE_GRACE_TLV_REASON_UNKNOWN, "Unknown" },
{ LS_OPAQUE_GRACE_TLV_REASON_SW_RESTART, "Software Restart" },
{ LS_OPAQUE_GRACE_TLV_REASON_SW_UPGRADE, "Software Reload/Upgrade" },
@@ -150,18 +148,18 @@ static struct tok lsa_opaque_grace_tlv_reason_values[] = {
{ 0, NULL }
};
-static struct tok lsa_opaque_te_tlv_link_type_sub_tlv_values[] = {
+static const struct tok lsa_opaque_te_tlv_link_type_sub_tlv_values[] = {
{ LS_OPAQUE_TE_LINK_SUBTLV_LINK_TYPE_PTP, "Point-to-point" },
{ LS_OPAQUE_TE_LINK_SUBTLV_LINK_TYPE_MA, "Multi-Access" },
{ 0, NULL }
};
-static struct tok lsa_opaque_ri_tlv_values[] = {
+static const struct tok lsa_opaque_ri_tlv_values[] = {
{ LS_OPAQUE_RI_TLV_CAP, "Router Capabilities" },
{ 0, NULL }
};
-static struct tok lsa_opaque_ri_tlv_cap_values[] = {
+static const struct tok lsa_opaque_ri_tlv_cap_values[] = {
{ 1, "Reserved" },
{ 2, "Reserved" },
{ 4, "Reserved" },
@@ -175,54 +173,44 @@ static struct tok lsa_opaque_ri_tlv_cap_values[] = {
{ 0, NULL }
};
-static struct tok ospf_lls_tlv_values[] = {
+static const struct tok ospf_lls_tlv_values[] = {
{ OSPF_LLS_EO, "Extended Options" },
{ OSPF_LLS_MD5, "MD5 Authentication" },
{ 0, NULL }
};
-static struct tok ospf_lls_eo_options[] = {
+static const struct tok ospf_lls_eo_options[] = {
{ OSPF_LLS_EO_LR, "LSDB resync" },
{ OSPF_LLS_EO_RS, "Restart" },
{ 0, NULL }
};
-static char tstr[] = " [|ospf2]";
-
-#ifdef WIN32
-#define inline __inline
-#endif /* WIN32 */
-
-static int ospf_print_lshdr(const struct lsa_hdr *);
-static const u_char *ospf_print_lsa(const struct lsa *);
-static int ospf_decode_v2(const struct ospfhdr *, const u_char *);
-static int ospf_decode_lls(const struct ospfhdr *, register u_int);
-
int
-ospf_print_grace_lsa (const u_int8_t *tptr, u_int ls_length) {
-
+ospf_print_grace_lsa(netdissect_options *ndo,
+ const uint8_t *tptr, u_int ls_length)
+{
u_int tlv_type, tlv_length;
while (ls_length > 0) {
- TCHECK2(*tptr, 4);
+ ND_TCHECK2(*tptr, 4);
if (ls_length < 4) {
- printf("\n\t Remaining LS length %u < 4", ls_length);
+ ND_PRINT((ndo, "\n\t Remaining LS length %u < 4", ls_length));
return -1;
}
tlv_type = EXTRACT_16BITS(tptr);
tlv_length = EXTRACT_16BITS(tptr+2);
tptr+=4;
ls_length-=4;
-
- printf("\n\t %s TLV (%u), length %u, value: ",
+
+ ND_PRINT((ndo, "\n\t %s TLV (%u), length %u, value: ",
tok2str(lsa_opaque_grace_tlv_values,"unknown",tlv_type),
tlv_type,
- tlv_length);
+ tlv_length));
if (tlv_length > ls_length) {
- printf("\n\t Bogus length %u > %u", tlv_length,
- ls_length);
+ ND_PRINT((ndo, "\n\t Bogus length %u > %u", tlv_length,
+ ls_length));
return -1;
}
@@ -231,38 +219,38 @@ ospf_print_grace_lsa (const u_int8_t *tptr, u_int ls_length) {
return -1;
}
- TCHECK2(*tptr, tlv_length);
+ ND_TCHECK2(*tptr, tlv_length);
switch(tlv_type) {
case LS_OPAQUE_GRACE_TLV_PERIOD:
if (tlv_length != 4) {
- printf("\n\t Bogus length %u != 4", tlv_length);
+ ND_PRINT((ndo, "\n\t Bogus length %u != 4", tlv_length));
return -1;
}
- printf("%us",EXTRACT_32BITS(tptr));
+ ND_PRINT((ndo, "%us", EXTRACT_32BITS(tptr)));
break;
case LS_OPAQUE_GRACE_TLV_REASON:
if (tlv_length != 1) {
- printf("\n\t Bogus length %u != 1", tlv_length);
+ ND_PRINT((ndo, "\n\t Bogus length %u != 1", tlv_length));
return -1;
}
- printf("%s (%u)",
+ ND_PRINT((ndo, "%s (%u)",
tok2str(lsa_opaque_grace_tlv_reason_values, "Unknown", *tptr),
- *tptr);
+ *tptr));
break;
case LS_OPAQUE_GRACE_TLV_INT_ADDRESS:
if (tlv_length != 4) {
- printf("\n\t Bogus length %u != 4", tlv_length);
+ ND_PRINT((ndo, "\n\t Bogus length %u != 4", tlv_length));
return -1;
}
- printf("%s", ipaddr_string(tptr));
+ ND_PRINT((ndo, "%s", ipaddr_string(ndo, tptr)));
break;
default:
- if (vflag <= 1) {
- if(!print_unknown_data(tptr,"\n\t ",tlv_length))
+ if (ndo->ndo_vflag <= 1) {
+ if (!print_unknown_data(ndo, tptr, "\n\t ", tlv_length))
return -1;
}
break;
@@ -281,34 +269,35 @@ trunc:
}
int
-ospf_print_te_lsa (const u_int8_t *tptr, u_int ls_length) {
-
+ospf_print_te_lsa(netdissect_options *ndo,
+ const uint8_t *tptr, u_int ls_length)
+{
u_int tlv_type, tlv_length, subtlv_type, subtlv_length;
u_int priority_level, te_class, count_srlg;
union { /* int to float conversion buffer for several subTLVs */
- float f;
- u_int32_t i;
+ float f;
+ uint32_t i;
} bw;
while (ls_length != 0) {
- TCHECK2(*tptr, 4);
+ ND_TCHECK2(*tptr, 4);
if (ls_length < 4) {
- printf("\n\t Remaining LS length %u < 4", ls_length);
+ ND_PRINT((ndo, "\n\t Remaining LS length %u < 4", ls_length));
return -1;
}
tlv_type = EXTRACT_16BITS(tptr);
tlv_length = EXTRACT_16BITS(tptr+2);
tptr+=4;
ls_length-=4;
-
- printf("\n\t %s TLV (%u), length: %u",
+
+ ND_PRINT((ndo, "\n\t %s TLV (%u), length: %u",
tok2str(lsa_opaque_te_tlv_values,"unknown",tlv_type),
tlv_type,
- tlv_length);
+ tlv_length));
if (tlv_length > ls_length) {
- printf("\n\t Bogus length %u > %u", tlv_length,
- ls_length);
+ ND_PRINT((ndo, "\n\t Bogus length %u > %u", tlv_length,
+ ls_length));
return -1;
}
@@ -321,108 +310,166 @@ ospf_print_te_lsa (const u_int8_t *tptr, u_int ls_length) {
case LS_OPAQUE_TE_TLV_LINK:
while (tlv_length >= sizeof(subtlv_type) + sizeof(subtlv_length)) {
if (tlv_length < 4) {
- printf("\n\t Remaining TLV length %u < 4",
- tlv_length);
+ ND_PRINT((ndo, "\n\t Remaining TLV length %u < 4",
+ tlv_length));
return -1;
}
- TCHECK2(*tptr, 4);
+ ND_TCHECK2(*tptr, 4);
subtlv_type = EXTRACT_16BITS(tptr);
subtlv_length = EXTRACT_16BITS(tptr+2);
tptr+=4;
tlv_length-=4;
-
- printf("\n\t %s subTLV (%u), length: %u",
+
+ /* Infinite loop protection */
+ if (subtlv_type == 0 || subtlv_length == 0)
+ goto invalid;
+
+ ND_PRINT((ndo, "\n\t %s subTLV (%u), length: %u",
tok2str(lsa_opaque_te_link_tlv_subtlv_values,"unknown",subtlv_type),
subtlv_type,
- subtlv_length);
-
- TCHECK2(*tptr, subtlv_length);
+ subtlv_length));
+
+ ND_TCHECK2(*tptr, subtlv_length);
switch(subtlv_type) {
case LS_OPAQUE_TE_LINK_SUBTLV_ADMIN_GROUP:
- printf(", 0x%08x", EXTRACT_32BITS(tptr));
+ if (subtlv_length != 4) {
+ ND_PRINT((ndo, " != 4"));
+ goto invalid;
+ }
+ ND_PRINT((ndo, ", 0x%08x", EXTRACT_32BITS(tptr)));
break;
case LS_OPAQUE_TE_LINK_SUBTLV_LINK_ID:
case LS_OPAQUE_TE_LINK_SUBTLV_LINK_LOCAL_REMOTE_ID:
- printf(", %s (0x%08x)",
- ipaddr_string(tptr),
- EXTRACT_32BITS(tptr));
+ if (subtlv_length != 4 && subtlv_length != 8) {
+ ND_PRINT((ndo, " != 4 && != 8"));
+ goto invalid;
+ }
+ ND_PRINT((ndo, ", %s (0x%08x)",
+ ipaddr_string(ndo, tptr),
+ EXTRACT_32BITS(tptr)));
if (subtlv_length == 8) /* rfc4203 */
- printf(", %s (0x%08x)",
- ipaddr_string(tptr+4),
- EXTRACT_32BITS(tptr+4));
+ ND_PRINT((ndo, ", %s (0x%08x)",
+ ipaddr_string(ndo, tptr+4),
+ EXTRACT_32BITS(tptr + 4)));
break;
case LS_OPAQUE_TE_LINK_SUBTLV_LOCAL_IP:
case LS_OPAQUE_TE_LINK_SUBTLV_REMOTE_IP:
- printf(", %s", ipaddr_string(tptr));
+ if (subtlv_length != 4) {
+ ND_PRINT((ndo, " != 4"));
+ goto invalid;
+ }
+ ND_PRINT((ndo, ", %s", ipaddr_string(ndo, tptr)));
break;
case LS_OPAQUE_TE_LINK_SUBTLV_MAX_BW:
case LS_OPAQUE_TE_LINK_SUBTLV_MAX_RES_BW:
+ if (subtlv_length != 4) {
+ ND_PRINT((ndo, " != 4"));
+ goto invalid;
+ }
bw.i = EXTRACT_32BITS(tptr);
- printf(", %.3f Mbps", bw.f*8/1000000 );
+ ND_PRINT((ndo, ", %.3f Mbps", bw.f * 8 / 1000000));
break;
case LS_OPAQUE_TE_LINK_SUBTLV_UNRES_BW:
+ if (subtlv_length != 32) {
+ ND_PRINT((ndo, " != 32"));
+ goto invalid;
+ }
for (te_class = 0; te_class < 8; te_class++) {
bw.i = EXTRACT_32BITS(tptr+te_class*4);
- printf("\n\t\tTE-Class %u: %.3f Mbps",
+ ND_PRINT((ndo, "\n\t\tTE-Class %u: %.3f Mbps",
te_class,
- bw.f*8/1000000 );
+ bw.f * 8 / 1000000));
}
break;
case LS_OPAQUE_TE_LINK_SUBTLV_BW_CONSTRAINTS:
- printf("\n\t\tBandwidth Constraints Model ID: %s (%u)",
+ if (subtlv_length < 4) {
+ ND_PRINT((ndo, " < 4"));
+ goto invalid;
+ }
+ /* BC Model Id (1 octet) + Reserved (3 octets) */
+ ND_PRINT((ndo, "\n\t\tBandwidth Constraints Model ID: %s (%u)",
tok2str(diffserv_te_bc_values, "unknown", *tptr),
- *tptr);
+ *tptr));
+ if (subtlv_length % 4 != 0) {
+ ND_PRINT((ndo, "\n\t\tlength %u != N x 4", subtlv_length));
+ goto invalid;
+ }
+ if (subtlv_length > 36) {
+ ND_PRINT((ndo, "\n\t\tlength %u > 36", subtlv_length));
+ goto invalid;
+ }
/* decode BCs until the subTLV ends */
for (te_class = 0; te_class < (subtlv_length-4)/4; te_class++) {
bw.i = EXTRACT_32BITS(tptr+4+te_class*4);
- printf("\n\t\t Bandwidth constraint CT%u: %.3f Mbps",
+ ND_PRINT((ndo, "\n\t\t Bandwidth constraint CT%u: %.3f Mbps",
te_class,
- bw.f*8/1000000 );
+ bw.f * 8 / 1000000));
}
break;
case LS_OPAQUE_TE_LINK_SUBTLV_TE_METRIC:
- printf(", Metric %u", EXTRACT_32BITS(tptr));
+ if (subtlv_length != 4) {
+ ND_PRINT((ndo, " != 4"));
+ goto invalid;
+ }
+ ND_PRINT((ndo, ", Metric %u", EXTRACT_32BITS(tptr)));
break;
case LS_OPAQUE_TE_LINK_SUBTLV_LINK_PROTECTION_TYPE:
- printf(", %s, Priority %u",
- bittok2str(gmpls_link_prot_values, "none", *tptr),
- *(tptr+1));
+ /* Protection Cap (1 octet) + Reserved ((3 octets) */
+ if (subtlv_length != 4) {
+ ND_PRINT((ndo, " != 4"));
+ goto invalid;
+ }
+ ND_PRINT((ndo, ", %s",
+ bittok2str(gmpls_link_prot_values, "none", *tptr)));
break;
case LS_OPAQUE_TE_LINK_SUBTLV_INTF_SW_CAP_DESCR:
- printf("\n\t\tInterface Switching Capability: %s",
- tok2str(gmpls_switch_cap_values, "Unknown", *(tptr)));
- printf("\n\t\tLSP Encoding: %s\n\t\tMax LSP Bandwidth:",
- tok2str(gmpls_encoding_values, "Unknown", *(tptr+1)));
+ if (subtlv_length < 36) {
+ ND_PRINT((ndo, " < 36"));
+ goto invalid;
+ }
+ /* Switching Cap (1 octet) + Encoding (1) + Reserved (2) */
+ ND_PRINT((ndo, "\n\t\tInterface Switching Capability: %s",
+ tok2str(gmpls_switch_cap_values, "Unknown", *(tptr))));
+ ND_PRINT((ndo, "\n\t\tLSP Encoding: %s\n\t\tMax LSP Bandwidth:",
+ tok2str(gmpls_encoding_values, "Unknown", *(tptr + 1))));
for (priority_level = 0; priority_level < 8; priority_level++) {
bw.i = EXTRACT_32BITS(tptr+4+(priority_level*4));
- printf("\n\t\t priority level %d: %.3f Mbps",
+ ND_PRINT((ndo, "\n\t\t priority level %d: %.3f Mbps",
priority_level,
- bw.f*8/1000000 );
+ bw.f * 8 / 1000000));
}
break;
case LS_OPAQUE_TE_LINK_SUBTLV_LINK_TYPE:
- printf(", %s (%u)",
+ if (subtlv_length != 1) {
+ ND_PRINT((ndo, " != 1"));
+ goto invalid;
+ }
+ ND_PRINT((ndo, ", %s (%u)",
tok2str(lsa_opaque_te_tlv_link_type_sub_tlv_values,"unknown",*tptr),
- *tptr);
+ *tptr));
break;
case LS_OPAQUE_TE_LINK_SUBTLV_SHARED_RISK_GROUP:
+ if (subtlv_length % 4 != 0) {
+ ND_PRINT((ndo, " != N x 4"));
+ goto invalid;
+ }
count_srlg = subtlv_length / 4;
if (count_srlg != 0)
- printf("\n\t\t Shared risk group: ");
+ ND_PRINT((ndo, "\n\t\t Shared risk group: "));
while (count_srlg > 0) {
bw.i = EXTRACT_32BITS(tptr);
- printf("%d",bw.i);
+ ND_PRINT((ndo, "%d", bw.i));
tptr+=4;
count_srlg--;
if (count_srlg > 0)
- printf(", ");
+ ND_PRINT((ndo, ", "));
}
break;
default:
- if (vflag <= 1) {
- if(!print_unknown_data(tptr,"\n\t\t",subtlv_length))
+ if (ndo->ndo_vflag <= 1) {
+ if (!print_unknown_data(ndo, tptr, "\n\t\t", subtlv_length))
return -1;
}
break;
@@ -430,25 +477,25 @@ ospf_print_te_lsa (const u_int8_t *tptr, u_int ls_length) {
/* in OSPF everything has to be 32-bit aligned, including subTLVs */
if (subtlv_length%4 != 0)
subtlv_length+=4-(subtlv_length%4);
-
+
tlv_length-=subtlv_length;
tptr+=subtlv_length;
-
+
}
break;
-
+
case LS_OPAQUE_TE_TLV_ROUTER:
if (tlv_length < 4) {
- printf("\n\t TLV length %u < 4", tlv_length);
+ ND_PRINT((ndo, "\n\t TLV length %u < 4", tlv_length));
return -1;
}
- TCHECK2(*tptr, 4);
- printf(", %s", ipaddr_string(tptr));
+ ND_TCHECK2(*tptr, 4);
+ ND_PRINT((ndo, ", %s", ipaddr_string(ndo, tptr)));
break;
-
+
default:
- if (vflag <= 1) {
- if(!print_unknown_data(tptr,"\n\t ",tlv_length))
+ if (ndo->ndo_vflag <= 1) {
+ if (!print_unknown_data(ndo, tptr, "\n\t ", tlv_length))
return -1;
}
break;
@@ -462,36 +509,39 @@ ospf_print_te_lsa (const u_int8_t *tptr, u_int ls_length) {
return 0;
trunc:
return -1;
+invalid:
+ ND_PRINT((ndo, "%s", istr));
+ return -1;
}
-
static int
-ospf_print_lshdr(register const struct lsa_hdr *lshp)
+ospf_print_lshdr(netdissect_options *ndo,
+ register const struct lsa_hdr *lshp)
{
u_int ls_length;
- TCHECK(lshp->ls_length);
+ ND_TCHECK(lshp->ls_length);
ls_length = EXTRACT_16BITS(&lshp->ls_length);
if (ls_length < sizeof(struct lsa_hdr)) {
- printf("\n\t Bogus length %u < header (%lu)", ls_length,
- (unsigned long)sizeof(struct lsa_hdr));
+ ND_PRINT((ndo, "\n\t Bogus length %u < header (%lu)", ls_length,
+ (unsigned long)sizeof(struct lsa_hdr)));
return(-1);
}
- TCHECK(lshp->ls_seq); /* XXX - ls_length check checked this */
- printf("\n\t Advertising Router %s, seq 0x%08x, age %us, length %u",
- ipaddr_string(&lshp->ls_router),
- EXTRACT_32BITS(&lshp->ls_seq),
- EXTRACT_16BITS(&lshp->ls_age),
- ls_length-(u_int)sizeof(struct lsa_hdr));
+ ND_TCHECK(lshp->ls_seq); /* XXX - ls_length check checked this */
+ ND_PRINT((ndo, "\n\t Advertising Router %s, seq 0x%08x, age %us, length %u",
+ ipaddr_string(ndo, &lshp->ls_router),
+ EXTRACT_32BITS(&lshp->ls_seq),
+ EXTRACT_16BITS(&lshp->ls_age),
+ ls_length - (u_int)sizeof(struct lsa_hdr)));
- TCHECK(lshp->ls_type); /* XXX - ls_length check checked this */
+ ND_TCHECK(lshp->ls_type); /* XXX - ls_length check checked this */
switch (lshp->ls_type) {
- /* the LSA header for opaque LSAs was slightly changed */
+ /* the LSA header for opaque LSAs was slightly changed */
case LS_TYPE_OPAQUE_LL:
case LS_TYPE_OPAQUE_AL:
case LS_TYPE_OPAQUE_DW:
- printf("\n\t %s LSA (%d), Opaque-Type %s LSA (%u), Opaque-ID %u",
+ ND_PRINT((ndo, "\n\t %s LSA (%d), Opaque-Type %s LSA (%u), Opaque-ID %u",
tok2str(lsa_values,"unknown",lshp->ls_type),
lshp->ls_type,
@@ -500,21 +550,21 @@ ospf_print_lshdr(register const struct lsa_hdr *lshp)
*(&lshp->un_lsa_id.opaque_field.opaque_type)),
*(&lshp->un_lsa_id.opaque_field.opaque_type),
EXTRACT_24BITS(&lshp->un_lsa_id.opaque_field.opaque_id)
-
- );
+
+ ));
break;
- /* all other LSA types use regular style LSA headers */
- default:
- printf("\n\t %s LSA (%d), LSA-ID: %s",
+ /* all other LSA types use regular style LSA headers */
+ default:
+ ND_PRINT((ndo, "\n\t %s LSA (%d), LSA-ID: %s",
tok2str(lsa_values,"unknown",lshp->ls_type),
lshp->ls_type,
- ipaddr_string(&lshp->un_lsa_id.lsa_id));
+ ipaddr_string(ndo, &lshp->un_lsa_id.lsa_id)));
break;
}
- TCHECK(lshp->ls_options); /* XXX - ls_length check checked this */
- printf("\n\t Options: [%s]", bittok2str(ospf_option_values,"none",lshp->ls_options));
+ ND_TCHECK(lshp->ls_options); /* XXX - ls_length check checked this */
+ ND_PRINT((ndo, "\n\t Options: [%s]", bittok2str(ospf_option_values, "none", lshp->ls_options)));
return (ls_length);
trunc:
@@ -522,18 +572,19 @@ trunc:
}
/* draft-ietf-ospf-mt-09 */
-static struct tok ospf_topology_values[] = {
- { 0, "default " },
- { 1, "multicast " },
- { 2, "management " },
+static const struct tok ospf_topology_values[] = {
+ { 0, "default" },
+ { 1, "multicast" },
+ { 2, "management" },
{ 0, NULL }
};
/*
* Print all the per-topology metrics.
*/
-static void
-ospf_print_tos_metrics(const union un_tos *tos)
+static int
+ospf_print_tos_metrics(netdissect_options *ndo,
+ const union un_tos *tos)
{
int metric_count;
int toscount;
@@ -544,16 +595,20 @@ ospf_print_tos_metrics(const union un_tos *tos)
/*
* All but the first metric contain a valid topology id.
*/
- while (toscount) {
- printf("\n\t\ttopology %s(%u), metric %u",
- tok2str(ospf_topology_values, "",
+ while (toscount > 0) {
+ ND_TCHECK(*tos);
+ ND_PRINT((ndo, "\n\t\ttopology %s (%u), metric %u",
+ tok2str(ospf_topology_values, "Unknown",
metric_count ? tos->metrics.tos_type : 0),
metric_count ? tos->metrics.tos_type : 0,
- EXTRACT_16BITS(&tos->metrics.tos_metric));
+ EXTRACT_16BITS(&tos->metrics.tos_metric)));
metric_count++;
tos++;
toscount--;
}
+ return 0;
+trunc:
+ return 1;
}
/*
@@ -561,158 +616,159 @@ ospf_print_tos_metrics(const union un_tos *tos)
* field is less than the length of the LSA header, return NULl, else
* return pointer to data past end of LSA.
*/
-static const u_int8_t *
-ospf_print_lsa(register const struct lsa *lsap)
+static const uint8_t *
+ospf_print_lsa(netdissect_options *ndo,
+ register const struct lsa *lsap)
{
- register const u_int8_t *ls_end;
+ register const uint8_t *ls_end;
register const struct rlalink *rlp;
register const struct in_addr *ap;
register const struct aslametric *almp;
register const struct mcla *mcp;
- register const u_int32_t *lp;
+ register const uint32_t *lp;
register int j, tlv_type, tlv_length, topology;
register int ls_length;
- const u_int8_t *tptr;
+ const uint8_t *tptr;
- tptr = (u_int8_t *)lsap->lsa_un.un_unknown; /* squelch compiler warnings */
- ls_length = ospf_print_lshdr(&lsap->ls_hdr);
+ tptr = (const uint8_t *)lsap->lsa_un.un_unknown; /* squelch compiler warnings */
+ ls_length = ospf_print_lshdr(ndo, &lsap->ls_hdr);
if (ls_length == -1)
return(NULL);
- ls_end = (u_int8_t *)lsap + ls_length;
+ ls_end = (const uint8_t *)lsap + ls_length;
ls_length -= sizeof(struct lsa_hdr);
switch (lsap->ls_hdr.ls_type) {
case LS_TYPE_ROUTER:
- TCHECK(lsap->lsa_un.un_rla.rla_flags);
- printf("\n\t Router LSA Options: [%s]", bittok2str(ospf_rla_flag_values,"none",lsap->lsa_un.un_rla.rla_flags));
+ ND_TCHECK(lsap->lsa_un.un_rla.rla_flags);
+ ND_PRINT((ndo, "\n\t Router LSA Options: [%s]",
+ bittok2str(ospf_rla_flag_values, "none", lsap->lsa_un.un_rla.rla_flags)));
- TCHECK(lsap->lsa_un.un_rla.rla_count);
+ ND_TCHECK(lsap->lsa_un.un_rla.rla_count);
j = EXTRACT_16BITS(&lsap->lsa_un.un_rla.rla_count);
- TCHECK(lsap->lsa_un.un_rla.rla_link);
+ ND_TCHECK(lsap->lsa_un.un_rla.rla_link);
rlp = lsap->lsa_un.un_rla.rla_link;
while (j--) {
- TCHECK(*rlp);
+ ND_TCHECK(*rlp);
switch (rlp->un_tos.link.link_type) {
case RLA_TYPE_VIRTUAL:
- printf("\n\t Virtual Link: Neighbor Router-ID: %s, Interface Address: %s",
- ipaddr_string(&rlp->link_id),
- ipaddr_string(&rlp->link_data));
- break;
+ ND_PRINT((ndo, "\n\t Virtual Link: Neighbor Router-ID: %s, Interface Address: %s",
+ ipaddr_string(ndo, &rlp->link_id),
+ ipaddr_string(ndo, &rlp->link_data)));
+ break;
case RLA_TYPE_ROUTER:
- printf("\n\t Neighbor Router-ID: %s, Interface Address: %s",
- ipaddr_string(&rlp->link_id),
- ipaddr_string(&rlp->link_data));
+ ND_PRINT((ndo, "\n\t Neighbor Router-ID: %s, Interface Address: %s",
+ ipaddr_string(ndo, &rlp->link_id),
+ ipaddr_string(ndo, &rlp->link_data)));
break;
case RLA_TYPE_TRANSIT:
- printf("\n\t Neighbor Network-ID: %s, Interface Address: %s",
- ipaddr_string(&rlp->link_id),
- ipaddr_string(&rlp->link_data));
+ ND_PRINT((ndo, "\n\t Neighbor Network-ID: %s, Interface Address: %s",
+ ipaddr_string(ndo, &rlp->link_id),
+ ipaddr_string(ndo, &rlp->link_data)));
break;
case RLA_TYPE_STUB:
- printf("\n\t Stub Network: %s, Mask: %s",
- ipaddr_string(&rlp->link_id),
- ipaddr_string(&rlp->link_data));
+ ND_PRINT((ndo, "\n\t Stub Network: %s, Mask: %s",
+ ipaddr_string(ndo, &rlp->link_id),
+ ipaddr_string(ndo, &rlp->link_data)));
break;
default:
- printf("\n\t Unknown Router Link Type (%u)",
- rlp->un_tos.link.link_type);
+ ND_PRINT((ndo, "\n\t Unknown Router Link Type (%u)",
+ rlp->un_tos.link.link_type));
return (ls_end);
}
- ospf_print_tos_metrics(&rlp->un_tos);
+ if (ospf_print_tos_metrics(ndo, &rlp->un_tos))
+ goto trunc;
- rlp = (struct rlalink *)((u_char *)(rlp + 1) +
+ rlp = (const struct rlalink *)((const u_char *)(rlp + 1) +
((rlp->un_tos.link.link_tos_count) * sizeof(union un_tos)));
}
break;
case LS_TYPE_NETWORK:
- TCHECK(lsap->lsa_un.un_nla.nla_mask);
- printf("\n\t Mask %s\n\t Connected Routers:",
- ipaddr_string(&lsap->lsa_un.un_nla.nla_mask));
+ ND_TCHECK(lsap->lsa_un.un_nla.nla_mask);
+ ND_PRINT((ndo, "\n\t Mask %s\n\t Connected Routers:",
+ ipaddr_string(ndo, &lsap->lsa_un.un_nla.nla_mask)));
ap = lsap->lsa_un.un_nla.nla_router;
- while ((u_char *)ap < ls_end) {
- TCHECK(*ap);
- printf("\n\t %s", ipaddr_string(ap));
+ while ((const u_char *)ap < ls_end) {
+ ND_TCHECK(*ap);
+ ND_PRINT((ndo, "\n\t %s", ipaddr_string(ndo, ap)));
++ap;
}
break;
case LS_TYPE_SUM_IP:
- TCHECK(lsap->lsa_un.un_nla.nla_mask);
- printf("\n\t Mask %s",
- ipaddr_string(&lsap->lsa_un.un_sla.sla_mask));
- TCHECK(lsap->lsa_un.un_sla.sla_tosmetric);
+ ND_TCHECK(lsap->lsa_un.un_nla.nla_mask);
+ ND_PRINT((ndo, "\n\t Mask %s",
+ ipaddr_string(ndo, &lsap->lsa_un.un_sla.sla_mask)));
+ ND_TCHECK(lsap->lsa_un.un_sla.sla_tosmetric);
lp = lsap->lsa_un.un_sla.sla_tosmetric;
- while ((u_char *)lp < ls_end) {
- register u_int32_t ul;
+ while ((const u_char *)lp < ls_end) {
+ register uint32_t ul;
- TCHECK(*lp);
+ ND_TCHECK(*lp);
ul = EXTRACT_32BITS(lp);
topology = (ul & SLA_MASK_TOS) >> SLA_SHIFT_TOS;
- printf("\n\t\ttopology %s(%u) metric %d",
- tok2str(ospf_topology_values, "", topology),
+ ND_PRINT((ndo, "\n\t\ttopology %s (%u) metric %d",
+ tok2str(ospf_topology_values, "Unknown", topology),
topology,
- ul & SLA_MASK_METRIC);
+ ul & SLA_MASK_METRIC));
++lp;
}
break;
case LS_TYPE_SUM_ABR:
- TCHECK(lsap->lsa_un.un_sla.sla_tosmetric);
+ ND_TCHECK(lsap->lsa_un.un_sla.sla_tosmetric);
lp = lsap->lsa_un.un_sla.sla_tosmetric;
- while ((u_char *)lp < ls_end) {
- register u_int32_t ul;
+ while ((const u_char *)lp < ls_end) {
+ register uint32_t ul;
- TCHECK(*lp);
+ ND_TCHECK(*lp);
ul = EXTRACT_32BITS(lp);
topology = (ul & SLA_MASK_TOS) >> SLA_SHIFT_TOS;
- printf("\n\t\ttopology %s(%u) metric %d",
- tok2str(ospf_topology_values, "", topology),
+ ND_PRINT((ndo, "\n\t\ttopology %s (%u) metric %d",
+ tok2str(ospf_topology_values, "Unknown", topology),
topology,
- ul & SLA_MASK_METRIC);
+ ul & SLA_MASK_METRIC));
++lp;
}
break;
case LS_TYPE_ASE:
case LS_TYPE_NSSA: /* fall through - those LSAs share the same format */
- TCHECK(lsap->lsa_un.un_nla.nla_mask);
- printf("\n\t Mask %s",
- ipaddr_string(&lsap->lsa_un.un_asla.asla_mask));
+ ND_TCHECK(lsap->lsa_un.un_nla.nla_mask);
+ ND_PRINT((ndo, "\n\t Mask %s",
+ ipaddr_string(ndo, &lsap->lsa_un.un_asla.asla_mask)));
- TCHECK(lsap->lsa_un.un_sla.sla_tosmetric);
+ ND_TCHECK(lsap->lsa_un.un_sla.sla_tosmetric);
almp = lsap->lsa_un.un_asla.asla_metric;
- while ((u_char *)almp < ls_end) {
- register u_int32_t ul;
+ while ((const u_char *)almp < ls_end) {
+ register uint32_t ul;
- TCHECK(almp->asla_tosmetric);
+ ND_TCHECK(almp->asla_tosmetric);
ul = EXTRACT_32BITS(&almp->asla_tosmetric);
topology = ((ul & ASLA_MASK_TOS) >> ASLA_SHIFT_TOS);
- printf("\n\t\ttopology %s(%u), type %d, metric",
- tok2str(ospf_topology_values, "", topology),
+ ND_PRINT((ndo, "\n\t\ttopology %s (%u), type %d, metric",
+ tok2str(ospf_topology_values, "Unknown", topology),
topology,
- (ul & ASLA_FLAG_EXTERNAL) ? 2 : 1);
- if ((ul & ASLA_MASK_METRIC)==0xffffff)
- printf(" infinite");
- else
- printf(" %d", (ul & ASLA_MASK_METRIC));
+ (ul & ASLA_FLAG_EXTERNAL) ? 2 : 1));
+ if ((ul & ASLA_MASK_METRIC) == 0xffffff)
+ ND_PRINT((ndo, " infinite"));
+ else
+ ND_PRINT((ndo, " %d", (ul & ASLA_MASK_METRIC)));
- TCHECK(almp->asla_forward);
+ ND_TCHECK(almp->asla_forward);
if (almp->asla_forward.s_addr) {
- printf(", forward %s",
- ipaddr_string(&almp->asla_forward));
+ ND_PRINT((ndo, ", forward %s", ipaddr_string(ndo, &almp->asla_forward)));
}
- TCHECK(almp->asla_tag);
+ ND_TCHECK(almp->asla_tag);
if (almp->asla_tag.s_addr) {
- printf(", tag %s",
- ipaddr_string(&almp->asla_tag));
+ ND_PRINT((ndo, ", tag %s", ipaddr_string(ndo, &almp->asla_tag)));
}
++almp;
}
@@ -721,23 +777,23 @@ ospf_print_lsa(register const struct lsa *lsap)
case LS_TYPE_GROUP:
/* Multicast extensions as of 23 July 1991 */
mcp = lsap->lsa_un.un_mcla;
- while ((u_char *)mcp < ls_end) {
- TCHECK(mcp->mcla_vid);
+ while ((const u_char *)mcp < ls_end) {
+ ND_TCHECK(mcp->mcla_vid);
switch (EXTRACT_32BITS(&mcp->mcla_vtype)) {
case MCLA_VERTEX_ROUTER:
- printf("\n\t Router Router-ID %s",
- ipaddr_string(&mcp->mcla_vid));
+ ND_PRINT((ndo, "\n\t Router Router-ID %s",
+ ipaddr_string(ndo, &mcp->mcla_vid)));
break;
case MCLA_VERTEX_NETWORK:
- printf("\n\t Network Designated Router %s",
- ipaddr_string(&mcp->mcla_vid));
+ ND_PRINT((ndo, "\n\t Network Designated Router %s",
+ ipaddr_string(ndo, &mcp->mcla_vid)));
break;
default:
- printf("\n\t unknown VertexType (%u)",
- EXTRACT_32BITS(&mcp->mcla_vtype));
+ ND_PRINT((ndo, "\n\t unknown VertexType (%u)",
+ EXTRACT_32BITS(&mcp->mcla_vtype)));
break;
}
++mcp;
@@ -745,48 +801,48 @@ ospf_print_lsa(register const struct lsa *lsap)
break;
case LS_TYPE_OPAQUE_LL: /* fall through */
- case LS_TYPE_OPAQUE_AL:
+ case LS_TYPE_OPAQUE_AL:
case LS_TYPE_OPAQUE_DW:
switch (*(&lsap->ls_hdr.un_lsa_id.opaque_field.opaque_type)) {
case LS_OPAQUE_TYPE_RI:
- tptr = (u_int8_t *)(&lsap->lsa_un.un_ri_tlv.type);
+ tptr = (const uint8_t *)(&lsap->lsa_un.un_ri_tlv.type);
while (ls_length != 0) {
- TCHECK2(*tptr, 4);
+ ND_TCHECK2(*tptr, 4);
if (ls_length < 4) {
- printf("\n\t Remaining LS length %u < 4", ls_length);
+ ND_PRINT((ndo, "\n\t Remaining LS length %u < 4", ls_length));
return(ls_end);
}
tlv_type = EXTRACT_16BITS(tptr);
tlv_length = EXTRACT_16BITS(tptr+2);
tptr+=4;
ls_length-=4;
-
- printf("\n\t %s TLV (%u), length: %u, value: ",
+
+ ND_PRINT((ndo, "\n\t %s TLV (%u), length: %u, value: ",
tok2str(lsa_opaque_ri_tlv_values,"unknown",tlv_type),
tlv_type,
- tlv_length);
+ tlv_length));
if (tlv_length > ls_length) {
- printf("\n\t Bogus length %u > %u", tlv_length,
- ls_length);
+ ND_PRINT((ndo, "\n\t Bogus length %u > %u", tlv_length,
+ ls_length));
return(ls_end);
}
- TCHECK2(*tptr, tlv_length);
+ ND_TCHECK2(*tptr, tlv_length);
switch(tlv_type) {
case LS_OPAQUE_RI_TLV_CAP:
if (tlv_length != 4) {
- printf("\n\t Bogus length %u != 4", tlv_length);
+ ND_PRINT((ndo, "\n\t Bogus length %u != 4", tlv_length));
return(ls_end);
}
- printf("Capabilities: %s",
- bittok2str(lsa_opaque_ri_tlv_cap_values, "Unknown", EXTRACT_32BITS(tptr)));
+ ND_PRINT((ndo, "Capabilities: %s",
+ bittok2str(lsa_opaque_ri_tlv_cap_values, "Unknown", EXTRACT_32BITS(tptr))));
break;
default:
- if (vflag <= 1) {
- if(!print_unknown_data(tptr,"\n\t ",tlv_length))
+ if (ndo->ndo_vflag <= 1) {
+ if (!print_unknown_data(ndo, tptr, "\n\t ", tlv_length))
return(ls_end);
}
break;
@@ -798,50 +854,50 @@ ospf_print_lsa(register const struct lsa *lsap)
break;
case LS_OPAQUE_TYPE_GRACE:
- if (ospf_print_grace_lsa((u_int8_t *)(&lsap->lsa_un.un_grace_tlv.type),
+ if (ospf_print_grace_lsa(ndo, (const uint8_t *)(&lsap->lsa_un.un_grace_tlv.type),
ls_length) == -1) {
return(ls_end);
}
break;
case LS_OPAQUE_TYPE_TE:
- if (ospf_print_te_lsa((u_int8_t *)(&lsap->lsa_un.un_te_lsa_tlv.type),
+ if (ospf_print_te_lsa(ndo, (const uint8_t *)(&lsap->lsa_un.un_te_lsa_tlv.type),
ls_length) == -1) {
return(ls_end);
}
break;
default:
- if (vflag <= 1) {
- if(!print_unknown_data((u_int8_t *)lsap->lsa_un.un_unknown,
+ if (ndo->ndo_vflag <= 1) {
+ if (!print_unknown_data(ndo, (const uint8_t *)lsap->lsa_un.un_unknown,
"\n\t ", ls_length))
return(ls_end);
- }
+ }
break;
}
}
/* do we want to see an additionally hexdump ? */
- if (vflag> 1)
- if(!print_unknown_data((u_int8_t *)lsap->lsa_un.un_unknown,
+ if (ndo->ndo_vflag> 1)
+ if (!print_unknown_data(ndo, (const uint8_t *)lsap->lsa_un.un_unknown,
"\n\t ", ls_length)) {
return(ls_end);
}
-
+
return (ls_end);
trunc:
return (NULL);
}
static int
-ospf_decode_lls(register const struct ospfhdr *op,
- register u_int length)
+ospf_decode_lls(netdissect_options *ndo,
+ register const struct ospfhdr *op, register u_int length)
{
register const u_char *dptr;
register const u_char *dataend;
register u_int length2;
- register u_int16_t lls_type, lls_len;
- register u_int32_t lls_flags;
+ register uint16_t lls_type, lls_len;
+ register uint32_t lls_flags;
switch (op->ospf_type) {
@@ -861,59 +917,59 @@ ospf_decode_lls(register const struct ospfhdr *op,
/* dig deeper if LLS data is available; see RFC4813 */
length2 = EXTRACT_16BITS(&op->ospf_len);
- dptr = (u_char *)op + length2;
- dataend = (u_char *)op + length;
+ dptr = (const u_char *)op + length2;
+ dataend = (const u_char *)op + length;
if (EXTRACT_16BITS(&op->ospf_authtype) == OSPF_AUTH_MD5) {
dptr = dptr + op->ospf_authdata[3];
length2 += op->ospf_authdata[3];
}
if (length2 >= length) {
- printf("\n\t[LLS truncated]");
+ ND_PRINT((ndo, "\n\t[LLS truncated]"));
return (1);
}
- TCHECK2(*dptr, 2);
- printf("\n\t LLS: checksum: 0x%04x", (u_int)EXTRACT_16BITS(dptr));
+ ND_TCHECK2(*dptr, 2);
+ ND_PRINT((ndo, "\n\t LLS: checksum: 0x%04x", (u_int)EXTRACT_16BITS(dptr)));
dptr += 2;
- TCHECK2(*dptr, 2);
+ ND_TCHECK2(*dptr, 2);
length2 = EXTRACT_16BITS(dptr);
- printf(", length: %u", length2);
+ ND_PRINT((ndo, ", length: %u", length2));
dptr += 2;
- TCHECK(*dptr);
+ ND_TCHECK(*dptr);
while (dptr < dataend) {
- TCHECK2(*dptr, 2);
+ ND_TCHECK2(*dptr, 2);
lls_type = EXTRACT_16BITS(dptr);
- printf("\n\t %s (%u)",
+ ND_PRINT((ndo, "\n\t %s (%u)",
tok2str(ospf_lls_tlv_values,"Unknown TLV",lls_type),
- lls_type);
+ lls_type));
dptr += 2;
- TCHECK2(*dptr, 2);
+ ND_TCHECK2(*dptr, 2);
lls_len = EXTRACT_16BITS(dptr);
- printf(", length: %u", lls_len);
+ ND_PRINT((ndo, ", length: %u", lls_len));
dptr += 2;
switch (lls_type) {
case OSPF_LLS_EO:
if (lls_len != 4) {
- printf(" [should be 4]");
+ ND_PRINT((ndo, " [should be 4]"));
lls_len = 4;
}
- TCHECK2(*dptr, 4);
+ ND_TCHECK2(*dptr, 4);
lls_flags = EXTRACT_32BITS(dptr);
- printf("\n\t Options: 0x%08x [%s]", lls_flags,
- bittok2str(ospf_lls_eo_options,"?",lls_flags));
+ ND_PRINT((ndo, "\n\t Options: 0x%08x [%s]", lls_flags,
+ bittok2str(ospf_lls_eo_options, "?", lls_flags)));
break;
case OSPF_LLS_MD5:
if (lls_len != 20) {
- printf(" [should be 20]");
+ ND_PRINT((ndo, " [should be 20]"));
lls_len = 20;
}
- TCHECK2(*dptr, 4);
- printf("\n\t Sequence number: 0x%08x", EXTRACT_32BITS(dptr));
+ ND_TCHECK2(*dptr, 4);
+ ND_PRINT((ndo, "\n\t Sequence number: 0x%08x", EXTRACT_32BITS(dptr)));
break;
}
@@ -926,14 +982,14 @@ trunc:
}
static int
-ospf_decode_v2(register const struct ospfhdr *op,
- register const u_char *dataend)
+ospf_decode_v2(netdissect_options *ndo,
+ register const struct ospfhdr *op, register const u_char *dataend)
{
register const struct in_addr *ap;
register const struct lsr *lsrp;
register const struct lsa_hdr *lshp;
register const struct lsa *lsap;
- register u_int32_t lsa_count,lsa_count_max;
+ register uint32_t lsa_count,lsa_count_max;
switch (op->ospf_type) {
@@ -945,95 +1001,96 @@ ospf_decode_v2(register const struct ospfhdr *op,
break;
case OSPF_TYPE_HELLO:
- printf("\n\tOptions [%s]",
- bittok2str(ospf_option_values,"none",op->ospf_hello.hello_options));
-
- TCHECK(op->ospf_hello.hello_deadint);
- printf("\n\t Hello Timer %us, Dead Timer %us, Mask %s, Priority %u",
- EXTRACT_16BITS(&op->ospf_hello.hello_helloint),
- EXTRACT_32BITS(&op->ospf_hello.hello_deadint),
- ipaddr_string(&op->ospf_hello.hello_mask),
- op->ospf_hello.hello_priority);
-
- TCHECK(op->ospf_hello.hello_dr);
+ ND_TCHECK(op->ospf_hello.hello_options);
+ ND_PRINT((ndo, "\n\tOptions [%s]",
+ bittok2str(ospf_option_values,"none",op->ospf_hello.hello_options)));
+
+ ND_TCHECK(op->ospf_hello.hello_deadint);
+ ND_PRINT((ndo, "\n\t Hello Timer %us, Dead Timer %us, Mask %s, Priority %u",
+ EXTRACT_16BITS(&op->ospf_hello.hello_helloint),
+ EXTRACT_32BITS(&op->ospf_hello.hello_deadint),
+ ipaddr_string(ndo, &op->ospf_hello.hello_mask),
+ op->ospf_hello.hello_priority));
+
+ ND_TCHECK(op->ospf_hello.hello_dr);
if (op->ospf_hello.hello_dr.s_addr != 0)
- printf("\n\t Designated Router %s",
- ipaddr_string(&op->ospf_hello.hello_dr));
+ ND_PRINT((ndo, "\n\t Designated Router %s",
+ ipaddr_string(ndo, &op->ospf_hello.hello_dr)));
- TCHECK(op->ospf_hello.hello_bdr);
+ ND_TCHECK(op->ospf_hello.hello_bdr);
if (op->ospf_hello.hello_bdr.s_addr != 0)
- printf(", Backup Designated Router %s",
- ipaddr_string(&op->ospf_hello.hello_bdr));
-
- ap = op->ospf_hello.hello_neighbor;
- if ((u_char *)ap < dataend)
- printf("\n\t Neighbor List:");
- while ((u_char *)ap < dataend) {
- TCHECK(*ap);
- printf("\n\t %s", ipaddr_string(ap));
- ++ap;
- }
+ ND_PRINT((ndo, ", Backup Designated Router %s",
+ ipaddr_string(ndo, &op->ospf_hello.hello_bdr)));
+
+ ap = op->ospf_hello.hello_neighbor;
+ if ((const u_char *)ap < dataend)
+ ND_PRINT((ndo, "\n\t Neighbor List:"));
+ while ((const u_char *)ap < dataend) {
+ ND_TCHECK(*ap);
+ ND_PRINT((ndo, "\n\t %s", ipaddr_string(ndo, ap)));
+ ++ap;
+ }
break; /* HELLO */
case OSPF_TYPE_DD:
- TCHECK(op->ospf_db.db_options);
- printf("\n\tOptions [%s]",
- bittok2str(ospf_option_values,"none",op->ospf_db.db_options));
- TCHECK(op->ospf_db.db_flags);
- printf(", DD Flags [%s]",
- bittok2str(ospf_dd_flag_values,"none",op->ospf_db.db_flags));
- TCHECK(op->ospf_db.db_ifmtu);
- if (op->ospf_db.db_ifmtu) {
- printf(", MTU: %u", EXTRACT_16BITS(&op->ospf_db.db_ifmtu));
- }
- TCHECK(op->ospf_db.db_seq);
- printf(", Sequence: 0x%08x", EXTRACT_32BITS(&op->ospf_db.db_seq));
+ ND_TCHECK(op->ospf_db.db_options);
+ ND_PRINT((ndo, "\n\tOptions [%s]",
+ bittok2str(ospf_option_values, "none", op->ospf_db.db_options)));
+ ND_TCHECK(op->ospf_db.db_flags);
+ ND_PRINT((ndo, ", DD Flags [%s]",
+ bittok2str(ospf_dd_flag_values, "none", op->ospf_db.db_flags)));
+ ND_TCHECK(op->ospf_db.db_ifmtu);
+ if (op->ospf_db.db_ifmtu) {
+ ND_PRINT((ndo, ", MTU: %u", EXTRACT_16BITS(&op->ospf_db.db_ifmtu)));
+ }
+ ND_TCHECK(op->ospf_db.db_seq);
+ ND_PRINT((ndo, ", Sequence: 0x%08x", EXTRACT_32BITS(&op->ospf_db.db_seq)));
- /* Print all the LS adv's */
- lshp = op->ospf_db.db_lshdr;
- while (((u_char *)lshp < dataend) && ospf_print_lshdr(lshp) != -1) {
- ++lshp;
- }
+ /* Print all the LS adv's */
+ lshp = op->ospf_db.db_lshdr;
+ while (((const u_char *)lshp < dataend) && ospf_print_lshdr(ndo, lshp) != -1) {
+ ++lshp;
+ }
break;
case OSPF_TYPE_LS_REQ:
lsrp = op->ospf_lsr;
- while ((u_char *)lsrp < dataend) {
- TCHECK(*lsrp);
+ while ((const u_char *)lsrp < dataend) {
+ ND_TCHECK(*lsrp);
- printf("\n\t Advertising Router: %s, %s LSA (%u)",
- ipaddr_string(&lsrp->ls_router),
+ ND_PRINT((ndo, "\n\t Advertising Router: %s, %s LSA (%u)",
+ ipaddr_string(ndo, &lsrp->ls_router),
tok2str(lsa_values,"unknown",EXTRACT_32BITS(lsrp->ls_type)),
- EXTRACT_32BITS(&lsrp->ls_type));
+ EXTRACT_32BITS(&lsrp->ls_type)));
switch (EXTRACT_32BITS(lsrp->ls_type)) {
/* the LSA header for opaque LSAs was slightly changed */
case LS_TYPE_OPAQUE_LL:
case LS_TYPE_OPAQUE_AL:
case LS_TYPE_OPAQUE_DW:
- printf(", Opaque-Type: %s LSA (%u), Opaque-ID: %u",
+ ND_PRINT((ndo, ", Opaque-Type: %s LSA (%u), Opaque-ID: %u",
tok2str(lsa_opaque_values, "unknown",lsrp->un_ls_stateid.opaque_field.opaque_type),
lsrp->un_ls_stateid.opaque_field.opaque_type,
- EXTRACT_24BITS(&lsrp->un_ls_stateid.opaque_field.opaque_id));
+ EXTRACT_24BITS(&lsrp->un_ls_stateid.opaque_field.opaque_id)));
break;
default:
- printf(", LSA-ID: %s",
- ipaddr_string(&lsrp->un_ls_stateid.ls_stateid));
+ ND_PRINT((ndo, ", LSA-ID: %s",
+ ipaddr_string(ndo, &lsrp->un_ls_stateid.ls_stateid)));
break;
}
-
+
++lsrp;
}
break;
case OSPF_TYPE_LS_UPDATE:
lsap = op->ospf_lsu.lsu_lsa;
- TCHECK(op->ospf_lsu.lsu_count);
+ ND_TCHECK(op->ospf_lsu.lsu_count);
lsa_count_max = EXTRACT_32BITS(&op->ospf_lsu.lsu_count);
- printf(", %d LSA%s",lsa_count_max, PLURAL_SUFFIX(lsa_count_max));
+ ND_PRINT((ndo, ", %d LSA%s", lsa_count_max, PLURAL_SUFFIX(lsa_count_max)));
for (lsa_count=1;lsa_count <= lsa_count_max;lsa_count++) {
- printf("\n\t LSA #%u",lsa_count);
- lsap = (const struct lsa *)ospf_print_lsa(lsap);
+ ND_PRINT((ndo, "\n\t LSA #%u", lsa_count));
+ lsap = (const struct lsa *)ospf_print_lsa(ndo, lsap);
if (lsap == NULL)
goto trunc;
}
@@ -1041,7 +1098,7 @@ ospf_decode_v2(register const struct ospfhdr *op,
case OSPF_TYPE_LS_ACK:
lshp = op->ospf_lsa.lsa_lshdr;
- while (ospf_print_lshdr(lshp) != -1) {
+ while (ospf_print_lshdr(ndo, lshp) != -1) {
++lshp;
}
break;
@@ -1055,40 +1112,38 @@ trunc:
}
void
-ospf_print(register const u_char *bp, register u_int length,
- const u_char *bp2 _U_)
+ospf_print(netdissect_options *ndo,
+ register const u_char *bp, register u_int length,
+ const u_char *bp2 _U_)
{
register const struct ospfhdr *op;
register const u_char *dataend;
register const char *cp;
- op = (struct ospfhdr *)bp;
+ op = (const struct ospfhdr *)bp;
- /* XXX Before we do anything else, strip off the MD5 trailer */
- TCHECK(op->ospf_authtype);
- if (EXTRACT_16BITS(&op->ospf_authtype) == OSPF_AUTH_MD5) {
- length -= OSPF_AUTH_MD5_LEN;
- snapend -= OSPF_AUTH_MD5_LEN;
- }
+ /* XXX Before we do anything else, strip off the MD5 trailer */
+ ND_TCHECK(op->ospf_authtype);
+ if (EXTRACT_16BITS(&op->ospf_authtype) == OSPF_AUTH_MD5) {
+ length -= OSPF_AUTH_MD5_LEN;
+ ndo->ndo_snapend -= OSPF_AUTH_MD5_LEN;
+ }
/* If the type is valid translate it, or just print the type */
/* value. If it's not valid, say so and return */
- TCHECK(op->ospf_type);
+ ND_TCHECK(op->ospf_type);
cp = tok2str(type2str, "unknown LS-type", op->ospf_type);
- printf("OSPFv%u, %s, length %u",
- op->ospf_version,
- cp,
- length);
+ ND_PRINT((ndo, "OSPFv%u, %s, length %u", op->ospf_version, cp, length));
if (*cp == 'u')
return;
- if(!vflag) { /* non verbose - so lets bail out here */
- return;
- }
+ if (!ndo->ndo_vflag) { /* non verbose - so lets bail out here */
+ return;
+ }
- TCHECK(op->ospf_len);
+ ND_TCHECK(op->ospf_len);
if (length != EXTRACT_16BITS(&op->ospf_len)) {
- printf(" [len %d]", EXTRACT_16BITS(&op->ospf_len));
+ ND_PRINT((ndo, " [len %d]", EXTRACT_16BITS(&op->ospf_len)));
}
if (length > EXTRACT_16BITS(&op->ospf_len)) {
@@ -1097,22 +1152,22 @@ ospf_print(register const u_char *bp, register u_int length,
dataend = bp + length;
}
- TCHECK(op->ospf_routerid);
- printf("\n\tRouter-ID %s", ipaddr_string(&op->ospf_routerid));
+ ND_TCHECK(op->ospf_routerid);
+ ND_PRINT((ndo, "\n\tRouter-ID %s", ipaddr_string(ndo, &op->ospf_routerid)));
- TCHECK(op->ospf_areaid);
+ ND_TCHECK(op->ospf_areaid);
if (op->ospf_areaid.s_addr != 0)
- printf(", Area %s", ipaddr_string(&op->ospf_areaid));
+ ND_PRINT((ndo, ", Area %s", ipaddr_string(ndo, &op->ospf_areaid)));
else
- printf(", Backbone Area");
+ ND_PRINT((ndo, ", Backbone Area"));
- if (vflag) {
+ if (ndo->ndo_vflag) {
/* Print authentication data (should we really do this?) */
- TCHECK2(op->ospf_authdata[0], sizeof(op->ospf_authdata));
+ ND_TCHECK2(op->ospf_authdata[0], sizeof(op->ospf_authdata));
- printf(", Authentication Type: %s (%u)",
- tok2str(ospf_authtype_values,"unknown",EXTRACT_16BITS(&op->ospf_authtype)),
- EXTRACT_16BITS(&op->ospf_authtype));
+ ND_PRINT((ndo, ", Authentication Type: %s (%u)",
+ tok2str(ospf_authtype_values, "unknown", EXTRACT_16BITS(&op->ospf_authtype)),
+ EXTRACT_16BITS(&op->ospf_authtype)));
switch (EXTRACT_16BITS(&op->ospf_authtype)) {
@@ -1120,15 +1175,15 @@ ospf_print(register const u_char *bp, register u_int length,
break;
case OSPF_AUTH_SIMPLE:
- printf("\n\tSimple text password: ");
- safeputs((const char *)op->ospf_authdata, OSPF_AUTH_SIMPLE_LEN);
+ ND_PRINT((ndo, "\n\tSimple text password: "));
+ safeputs(ndo, op->ospf_authdata, OSPF_AUTH_SIMPLE_LEN);
break;
case OSPF_AUTH_MD5:
- printf("\n\tKey-ID: %u, Auth-Length: %u, Crypto Sequence Number: 0x%08x",
- *((op->ospf_authdata)+2),
- *((op->ospf_authdata)+3),
- EXTRACT_32BITS((op->ospf_authdata)+4));
+ ND_PRINT((ndo, "\n\tKey-ID: %u, Auth-Length: %u, Crypto Sequence Number: 0x%08x",
+ *((op->ospf_authdata) + 2),
+ *((op->ospf_authdata) + 3),
+ EXTRACT_32BITS((op->ospf_authdata) + 4)));
break;
default:
@@ -1140,20 +1195,23 @@ ospf_print(register const u_char *bp, register u_int length,
case 2:
/* ospf version 2 */
- if (ospf_decode_v2(op, dataend))
+ if (ospf_decode_v2(ndo, op, dataend))
goto trunc;
if (length > EXTRACT_16BITS(&op->ospf_len)) {
- if (ospf_decode_lls(op, length))
+ if (ospf_decode_lls(ndo, op, length))
goto trunc;
}
break;
default:
- printf(" ospf [version %d]", op->ospf_version);
+ ND_PRINT((ndo, " ospf [version %d]", op->ospf_version));
break;
} /* end switch on version */
return;
trunc:
- fputs(tstr, stdout);
+ ND_PRINT((ndo, "%s", tstr));
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-ospf-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-ospf6.c b/freebsd/contrib/tcpdump/print-ospf6.c
index 419cf705..7b23bb64 100644
--- a/freebsd/contrib/tcpdump/print-ospf6.c
+++ b/freebsd/contrib/tcpdump/print-ospf6.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1992, 1993, 1994, 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
@@ -23,34 +26,281 @@
* OSPF support contributed by Jeffrey Honig (jch@mitchell.cit.cornell.edu)
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ospf6.c,v 1.15 2006-09-13 06:31:11 guy Exp $ (LBL)";
-#endif
+/* \summary: IPv6 Open Shortest Path First (OSPFv3) printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include <stdio.h>
#include <string.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "extract.h"
#include "ospf.h"
-#include "ospf6.h"
+
+#define OSPF_TYPE_HELLO 1 /* Hello */
+#define OSPF_TYPE_DD 2 /* Database Description */
+#define OSPF_TYPE_LS_REQ 3 /* Link State Request */
+#define OSPF_TYPE_LS_UPDATE 4 /* Link State Update */
+#define OSPF_TYPE_LS_ACK 5 /* Link State Ack */
+
+/* Options *_options */
+#define OSPF6_OPTION_V6 0x01 /* V6 bit: A bit for peeping tom */
+#define OSPF6_OPTION_E 0x02 /* E bit: External routes advertised */
+#define OSPF6_OPTION_MC 0x04 /* MC bit: Multicast capable */
+#define OSPF6_OPTION_N 0x08 /* N bit: For type-7 LSA */
+#define OSPF6_OPTION_R 0x10 /* R bit: Router bit */
+#define OSPF6_OPTION_DC 0x20 /* DC bit: Demand circuits */
+/* The field is actually 24-bit (RFC5340 Section A.2). */
+#define OSPF6_OPTION_AF 0x0100 /* AF bit: Multiple address families */
+#define OSPF6_OPTION_L 0x0200 /* L bit: Link-local signaling (LLS) */
+#define OSPF6_OPTION_AT 0x0400 /* AT bit: Authentication trailer */
+
+
+/* db_flags */
+#define OSPF6_DB_INIT 0x04 /* */
+#define OSPF6_DB_MORE 0x02
+#define OSPF6_DB_MASTER 0x01
+#define OSPF6_DB_M6 0x10 /* IPv6 MTU */
+
+/* ls_type */
+#define LS_TYPE_ROUTER 1 /* router link */
+#define LS_TYPE_NETWORK 2 /* network link */
+#define LS_TYPE_INTER_AP 3 /* Inter-Area-Prefix */
+#define LS_TYPE_INTER_AR 4 /* Inter-Area-Router */
+#define LS_TYPE_ASE 5 /* ASE */
+#define LS_TYPE_GROUP 6 /* Group membership */
+#define LS_TYPE_NSSA 7 /* NSSA */
+#define LS_TYPE_LINK 8 /* Link LSA */
+#define LS_TYPE_INTRA_AP 9 /* Intra-Area-Prefix */
+#define LS_TYPE_INTRA_ATE 10 /* Intra-Area-TE */
+#define LS_TYPE_GRACE 11 /* Grace LSA */
+#define LS_TYPE_RI 12 /* Router information */
+#define LS_TYPE_INTER_ASTE 13 /* Inter-AS-TE */
+#define LS_TYPE_L1VPN 14 /* L1VPN */
+#define LS_TYPE_MASK 0x1fff
+
+#define LS_SCOPE_LINKLOCAL 0x0000
+#define LS_SCOPE_AREA 0x2000
+#define LS_SCOPE_AS 0x4000
+#define LS_SCOPE_MASK 0x6000
+#define LS_SCOPE_U 0x8000
+
+/* rla_link.link_type */
+#define RLA_TYPE_ROUTER 1 /* point-to-point to another router */
+#define RLA_TYPE_TRANSIT 2 /* connection to transit network */
+#define RLA_TYPE_VIRTUAL 4 /* virtual link */
+
+/* rla_flags */
+#define RLA_FLAG_B 0x01
+#define RLA_FLAG_E 0x02
+#define RLA_FLAG_V 0x04
+#define RLA_FLAG_W 0x08
+#define RLA_FLAG_N 0x10
+
+/* lsa_prefix options */
+#define LSA_PREFIX_OPT_NU 0x01
+#define LSA_PREFIX_OPT_LA 0x02
+#define LSA_PREFIX_OPT_MC 0x04
+#define LSA_PREFIX_OPT_P 0x08
+#define LSA_PREFIX_OPT_DN 0x10
+
+/* sla_tosmetric breakdown */
+#define SLA_MASK_TOS 0x7f000000
+#define SLA_MASK_METRIC 0x00ffffff
+#define SLA_SHIFT_TOS 24
+
+/* asla_metric */
+#define ASLA_FLAG_FWDADDR 0x02000000
+#define ASLA_FLAG_ROUTETAG 0x01000000
+#define ASLA_MASK_METRIC 0x00ffffff
+
+/* RFC6506 Section 4.1 */
+#define OSPF6_AT_HDRLEN 16U
+#define OSPF6_AUTH_TYPE_HMAC 0x0001
+
+typedef uint32_t rtrid_t;
+
+/* link state advertisement header */
+struct lsa6_hdr {
+ uint16_t ls_age;
+ uint16_t ls_type;
+ rtrid_t ls_stateid;
+ rtrid_t ls_router;
+ uint32_t ls_seq;
+ uint16_t ls_chksum;
+ uint16_t ls_length;
+};
+
+/* Length of an IPv6 address, in bytes. */
+#define IPV6_ADDR_LEN_BYTES (128/8)
+
+struct lsa6_prefix {
+ uint8_t lsa_p_len;
+ uint8_t lsa_p_opt;
+ uint16_t lsa_p_metric;
+ uint8_t lsa_p_prefix[IPV6_ADDR_LEN_BYTES]; /* maximum length */
+};
+
+/* link state advertisement */
+struct lsa6 {
+ struct lsa6_hdr ls_hdr;
+
+ /* Link state types */
+ union {
+ /* Router links advertisements */
+ struct {
+ union {
+ uint8_t flg;
+ uint32_t opt;
+ } rla_flgandopt;
+#define rla_flags rla_flgandopt.flg
+#define rla_options rla_flgandopt.opt
+ struct rlalink6 {
+ uint8_t link_type;
+ uint8_t link_zero[1];
+ uint16_t link_metric;
+ uint32_t link_ifid;
+ uint32_t link_nifid;
+ rtrid_t link_nrtid;
+ } rla_link[1]; /* may repeat */
+ } un_rla;
+
+ /* Network links advertisements */
+ struct {
+ uint32_t nla_options;
+ rtrid_t nla_router[1]; /* may repeat */
+ } un_nla;
+
+ /* Inter Area Prefix LSA */
+ struct {
+ uint32_t inter_ap_metric;
+ struct lsa6_prefix inter_ap_prefix[1];
+ } un_inter_ap;
+
+ /* AS external links advertisements */
+ struct {
+ uint32_t asla_metric;
+ struct lsa6_prefix asla_prefix[1];
+ /* some optional fields follow */
+ } un_asla;
+
+#if 0
+ /* Summary links advertisements */
+ struct {
+ struct in_addr sla_mask;
+ uint32_t sla_tosmetric[1]; /* may repeat */
+ } un_sla;
+
+ /* Multicast group membership */
+ struct mcla {
+ uint32_t mcla_vtype;
+ struct in_addr mcla_vid;
+ } un_mcla[1];
+#endif
+
+ /* Type 7 LSA */
+
+ /* Link LSA */
+ struct llsa {
+ union {
+ uint8_t pri;
+ uint32_t opt;
+ } llsa_priandopt;
+#define llsa_priority llsa_priandopt.pri
+#define llsa_options llsa_priandopt.opt
+ struct in6_addr llsa_lladdr;
+ uint32_t llsa_nprefix;
+ struct lsa6_prefix llsa_prefix[1];
+ } un_llsa;
+
+ /* Intra-Area-Prefix */
+ struct {
+ uint16_t intra_ap_nprefix;
+ uint16_t intra_ap_lstype;
+ rtrid_t intra_ap_lsid;
+ rtrid_t intra_ap_rtid;
+ struct lsa6_prefix intra_ap_prefix[1];
+ } un_intra_ap;
+ } lsa_un;
+};
+
+/*
+ * the main header
+ */
+struct ospf6hdr {
+ uint8_t ospf6_version;
+ uint8_t ospf6_type;
+ uint16_t ospf6_len;
+ rtrid_t ospf6_routerid;
+ rtrid_t ospf6_areaid;
+ uint16_t ospf6_chksum;
+ uint8_t ospf6_instanceid;
+ uint8_t ospf6_rsvd;
+};
+
+/*
+ * The OSPF6 header length is 16 bytes, regardless of how your compiler
+ * might choose to pad the above structure.
+ */
+#define OSPF6HDR_LEN 16
+
+/* Hello packet */
+struct hello6 {
+ uint32_t hello_ifid;
+ union {
+ uint8_t pri;
+ uint32_t opt;
+ } hello_priandopt;
+#define hello_priority hello_priandopt.pri
+#define hello_options hello_priandopt.opt
+ uint16_t hello_helloint;
+ uint16_t hello_deadint;
+ rtrid_t hello_dr;
+ rtrid_t hello_bdr;
+ rtrid_t hello_neighbor[1]; /* may repeat */
+};
+
+/* Database Description packet */
+struct dd6 {
+ uint32_t db_options;
+ uint16_t db_mtu;
+ uint8_t db_mbz;
+ uint8_t db_flags;
+ uint32_t db_seq;
+ struct lsa6_hdr db_lshdr[1]; /* may repeat */
+};
+
+/* Link State Request */
+struct lsr6 {
+ uint16_t ls_mbz;
+ uint16_t ls_type;
+ rtrid_t ls_stateid;
+ rtrid_t ls_router;
+};
+
+/* Link State Update */
+struct lsu6 {
+ uint32_t lsu_count;
+ struct lsa6 lsu_lsa[1]; /* may repeat */
+};
+
+static const char tstr[] = " [|ospf3]";
static const struct tok ospf6_option_values[] = {
{ OSPF6_OPTION_V6, "V6" },
{ OSPF6_OPTION_E, "External" },
- { OSPF6_OPTION_MC, "Multicast" },
+ { OSPF6_OPTION_MC, "Deprecated" },
{ OSPF6_OPTION_N, "NSSA" },
{ OSPF6_OPTION_R, "Router" },
{ OSPF6_OPTION_DC, "Demand Circuit" },
+ { OSPF6_OPTION_AF, "AFs Support" },
+ { OSPF6_OPTION_L, "LLS" },
+ { OSPF6_OPTION_AT, "Authentication Trailer" },
{ 0, NULL }
};
@@ -65,12 +315,12 @@ static const struct tok ospf6_rla_flag_values[] = {
static const struct tok ospf6_asla_flag_values[] = {
{ ASLA_FLAG_EXTERNAL, "External Type 2" },
- { ASLA_FLAG_FWDADDR, "Fforwarding" },
+ { ASLA_FLAG_FWDADDR, "Forwarding" },
{ ASLA_FLAG_ROUTETAG, "Tag" },
{ 0, NULL }
};
-static struct tok ospf6_type_values[] = {
+static const struct tok ospf6_type_values[] = {
{ OSPF_TYPE_HELLO, "Hello" },
{ OSPF_TYPE_DD, "Database Description" },
{ OSPF_TYPE_LS_REQ, "LS-Request" },
@@ -79,82 +329,81 @@ static struct tok ospf6_type_values[] = {
{ 0, NULL }
};
-static struct tok ospf6_lsa_values[] = {
+static const struct tok ospf6_lsa_values[] = {
{ LS_TYPE_ROUTER, "Router" },
{ LS_TYPE_NETWORK, "Network" },
{ LS_TYPE_INTER_AP, "Inter-Area Prefix" },
{ LS_TYPE_INTER_AR, "Inter-Area Router" },
{ LS_TYPE_ASE, "External" },
- { LS_TYPE_GROUP, "Multicast Group" },
+ { LS_TYPE_GROUP, "Deprecated" },
{ LS_TYPE_NSSA, "NSSA" },
{ LS_TYPE_LINK, "Link" },
{ LS_TYPE_INTRA_AP, "Intra-Area Prefix" },
{ LS_TYPE_INTRA_ATE, "Intra-Area TE" },
{ LS_TYPE_GRACE, "Grace" },
+ { LS_TYPE_RI, "Router Information" },
+ { LS_TYPE_INTER_ASTE, "Inter-AS-TE" },
+ { LS_TYPE_L1VPN, "Layer 1 VPN" },
{ 0, NULL }
};
-static struct tok ospf6_ls_scope_values[] = {
+static const struct tok ospf6_ls_scope_values[] = {
{ LS_SCOPE_LINKLOCAL, "Link Local" },
{ LS_SCOPE_AREA, "Area Local" },
{ LS_SCOPE_AS, "Domain Wide" },
{ 0, NULL }
};
-static struct tok ospf6_dd_flag_values[] = {
+static const struct tok ospf6_dd_flag_values[] = {
{ OSPF6_DB_INIT, "Init" },
{ OSPF6_DB_MORE, "More" },
{ OSPF6_DB_MASTER, "Master" },
+ { OSPF6_DB_M6, "IPv6 MTU" },
{ 0, NULL }
};
-static struct tok ospf6_lsa_prefix_option_values[] = {
+static const struct tok ospf6_lsa_prefix_option_values[] = {
{ LSA_PREFIX_OPT_NU, "No Unicast" },
{ LSA_PREFIX_OPT_LA, "Local address" },
- { LSA_PREFIX_OPT_MC, "Multicast" },
+ { LSA_PREFIX_OPT_MC, "Deprecated" },
{ LSA_PREFIX_OPT_P, "Propagate" },
{ LSA_PREFIX_OPT_DN, "Down" },
{ 0, NULL }
};
-static char tstr[] = " [|ospf3]";
-
-#ifdef WIN32
-#define inline __inline
-#endif /* WIN32 */
-
-/* Forwards */
-static void ospf6_print_ls_type(u_int, const rtrid_t *);
-static int ospf6_print_lshdr(const struct lsa6_hdr *);
-static int ospf6_print_lsa(const struct lsa6 *);
-static int ospf6_decode_v3(const struct ospf6hdr *, const u_char *);
-
+static const struct tok ospf6_auth_type_str[] = {
+ { OSPF6_AUTH_TYPE_HMAC, "HMAC" },
+ { 0, NULL }
+};
static void
-ospf6_print_ls_type(register u_int ls_type, register const rtrid_t *ls_stateid)
+ospf6_print_ls_type(netdissect_options *ndo,
+ register u_int ls_type, register const rtrid_t *ls_stateid)
{
- printf("\n\t %s LSA (%d), %s Scope%s, LSA-ID %s",
+ ND_PRINT((ndo, "\n\t %s LSA (%d), %s Scope%s, LSA-ID %s",
tok2str(ospf6_lsa_values, "Unknown", ls_type & LS_TYPE_MASK),
ls_type & LS_TYPE_MASK,
tok2str(ospf6_ls_scope_values, "Unknown", ls_type & LS_SCOPE_MASK),
ls_type &0x8000 ? ", transitive" : "", /* U-bit */
- ipaddr_string(ls_stateid));
+ ipaddr_string(ndo, ls_stateid)));
}
static int
-ospf6_print_lshdr(register const struct lsa6_hdr *lshp)
+ospf6_print_lshdr(netdissect_options *ndo,
+ register const struct lsa6_hdr *lshp, const u_char *dataend)
{
+ if ((const u_char *)(lshp + 1) > dataend)
+ goto trunc;
+ ND_TCHECK(lshp->ls_type);
+ ND_TCHECK(lshp->ls_seq);
- TCHECK(lshp->ls_type);
- TCHECK(lshp->ls_seq);
-
- printf("\n\t Advertising Router %s, seq 0x%08x, age %us, length %u",
- ipaddr_string(&lshp->ls_router),
+ ND_PRINT((ndo, "\n\t Advertising Router %s, seq 0x%08x, age %us, length %u",
+ ipaddr_string(ndo, &lshp->ls_router),
EXTRACT_32BITS(&lshp->ls_seq),
EXTRACT_16BITS(&lshp->ls_age),
- EXTRACT_16BITS(&lshp->ls_length)-(u_int)sizeof(struct lsa6_hdr));
+ EXTRACT_16BITS(&lshp->ls_length)-(u_int)sizeof(struct lsa6_hdr)));
- ospf6_print_ls_type(EXTRACT_16BITS(&lshp->ls_type), &lshp->ls_stateid);
+ ospf6_print_ls_type(ndo, EXTRACT_16BITS(&lshp->ls_type), &lshp->ls_stateid);
return (0);
trunc:
@@ -162,36 +411,37 @@ trunc:
}
static int
-ospf6_print_lsaprefix(const u_int8_t *tptr, u_int lsa_length)
+ospf6_print_lsaprefix(netdissect_options *ndo,
+ const uint8_t *tptr, u_int lsa_length)
{
- const struct lsa6_prefix *lsapp = (struct lsa6_prefix *)tptr;
+ const struct lsa6_prefix *lsapp = (const struct lsa6_prefix *)tptr;
u_int wordlen;
struct in6_addr prefix;
- if (lsa_length < sizeof (*lsapp) - 4)
+ if (lsa_length < sizeof (*lsapp) - IPV6_ADDR_LEN_BYTES)
goto trunc;
- lsa_length -= sizeof (*lsapp) - 4;
- TCHECK2(*lsapp, sizeof (*lsapp) - 4);
+ lsa_length -= sizeof (*lsapp) - IPV6_ADDR_LEN_BYTES;
+ ND_TCHECK2(*lsapp, sizeof (*lsapp) - IPV6_ADDR_LEN_BYTES);
wordlen = (lsapp->lsa_p_len + 31) / 32;
if (wordlen * 4 > sizeof(struct in6_addr)) {
- printf(" bogus prefixlen /%d", lsapp->lsa_p_len);
+ ND_PRINT((ndo, " bogus prefixlen /%d", lsapp->lsa_p_len));
goto trunc;
}
if (lsa_length < wordlen * 4)
goto trunc;
lsa_length -= wordlen * 4;
- TCHECK2(lsapp->lsa_p_prefix, wordlen * 4);
+ ND_TCHECK2(lsapp->lsa_p_prefix, wordlen * 4);
memset(&prefix, 0, sizeof(prefix));
memcpy(&prefix, lsapp->lsa_p_prefix, wordlen * 4);
- printf("\n\t\t%s/%d", ip6addr_string(&prefix),
- lsapp->lsa_p_len);
+ ND_PRINT((ndo, "\n\t\t%s/%d", ip6addr_string(ndo, &prefix),
+ lsapp->lsa_p_len));
if (lsapp->lsa_p_opt) {
- printf(", Options [%s]",
+ ND_PRINT((ndo, ", Options [%s]",
bittok2str(ospf6_lsa_prefix_option_values,
- "none", lsapp->lsa_p_opt));
+ "none", lsapp->lsa_p_opt)));
}
- printf(", metric %u", EXTRACT_16BITS(&lsapp->lsa_p_metric));
- return sizeof(*lsapp) - 4 + wordlen * 4;
+ ND_PRINT((ndo, ", metric %u", EXTRACT_16BITS(&lsapp->lsa_p_metric)));
+ return sizeof(*lsapp) - IPV6_ADDR_LEN_BYTES + wordlen * 4;
trunc:
return -1;
@@ -202,7 +452,8 @@ trunc:
* Print a single link state advertisement. If truncated return 1, else 0.
*/
static int
-ospf6_print_lsa(register const struct lsa6 *lsap)
+ospf6_print_lsa(netdissect_options *ndo,
+ register const struct lsa6 *lsap, const u_char *dataend)
{
register const struct rlalink6 *rlp;
#if 0
@@ -216,17 +467,17 @@ ospf6_print_lsa(register const struct lsa6 *lsap)
register const struct llsa *llsap;
register const struct lsa6_prefix *lsapp;
#if 0
- register const u_int32_t *lp;
+ register const uint32_t *lp;
#endif
register u_int prefixes;
register int bytelen;
register u_int length, lsa_length;
- u_int32_t flags32;
- const u_int8_t *tptr;
+ uint32_t flags32;
+ const uint8_t *tptr;
- if (ospf6_print_lshdr(&lsap->ls_hdr))
+ if (ospf6_print_lshdr(ndo, &lsap->ls_hdr, dataend))
return (1);
- TCHECK(lsap->ls_hdr.ls_length);
+ ND_TCHECK(lsap->ls_hdr.ls_length);
length = EXTRACT_16BITS(&lsap->ls_hdr.ls_length);
/*
@@ -235,62 +486,62 @@ ospf6_print_lsa(register const struct lsa6 *lsap)
* If it does, find the length of what follows the
* header.
*/
- if (length < sizeof(struct lsa6_hdr))
+ if (length < sizeof(struct lsa6_hdr) || (const u_char *)lsap + length > dataend)
return (1);
lsa_length = length - sizeof(struct lsa6_hdr);
- tptr = (u_int8_t *)lsap+sizeof(struct lsa6_hdr);
+ tptr = (const uint8_t *)lsap+sizeof(struct lsa6_hdr);
switch (EXTRACT_16BITS(&lsap->ls_hdr.ls_type)) {
case LS_TYPE_ROUTER | LS_SCOPE_AREA:
if (lsa_length < sizeof (lsap->lsa_un.un_rla.rla_options))
return (1);
lsa_length -= sizeof (lsap->lsa_un.un_rla.rla_options);
- TCHECK(lsap->lsa_un.un_rla.rla_options);
- printf("\n\t Options [%s]",
- bittok2str(ospf6_option_values, "none",
- EXTRACT_32BITS(&lsap->lsa_un.un_rla.rla_options)));
- printf(", RLA-Flags [%s]",
- bittok2str(ospf6_rla_flag_values, "none",
- lsap->lsa_un.un_rla.rla_flags));
+ ND_TCHECK(lsap->lsa_un.un_rla.rla_options);
+ ND_PRINT((ndo, "\n\t Options [%s]",
+ bittok2str(ospf6_option_values, "none",
+ EXTRACT_32BITS(&lsap->lsa_un.un_rla.rla_options))));
+ ND_PRINT((ndo, ", RLA-Flags [%s]",
+ bittok2str(ospf6_rla_flag_values, "none",
+ lsap->lsa_un.un_rla.rla_flags)));
rlp = lsap->lsa_un.un_rla.rla_link;
while (lsa_length != 0) {
if (lsa_length < sizeof (*rlp))
return (1);
lsa_length -= sizeof (*rlp);
- TCHECK(*rlp);
+ ND_TCHECK(*rlp);
switch (rlp->link_type) {
case RLA_TYPE_VIRTUAL:
- printf("\n\t Virtual Link: Neighbor Router-ID %s"
+ ND_PRINT((ndo, "\n\t Virtual Link: Neighbor Router-ID %s"
"\n\t Neighbor Interface-ID %s, Interface %s",
- ipaddr_string(&rlp->link_nrtid),
- ipaddr_string(&rlp->link_nifid),
- ipaddr_string(&rlp->link_ifid));
+ ipaddr_string(ndo, &rlp->link_nrtid),
+ ipaddr_string(ndo, &rlp->link_nifid),
+ ipaddr_string(ndo, &rlp->link_ifid)));
break;
case RLA_TYPE_ROUTER:
- printf("\n\t Neighbor Router-ID %s"
+ ND_PRINT((ndo, "\n\t Neighbor Router-ID %s"
"\n\t Neighbor Interface-ID %s, Interface %s",
- ipaddr_string(&rlp->link_nrtid),
- ipaddr_string(&rlp->link_nifid),
- ipaddr_string(&rlp->link_ifid));
+ ipaddr_string(ndo, &rlp->link_nrtid),
+ ipaddr_string(ndo, &rlp->link_nifid),
+ ipaddr_string(ndo, &rlp->link_ifid)));
break;
case RLA_TYPE_TRANSIT:
- printf("\n\t Neighbor Network-ID %s"
+ ND_PRINT((ndo, "\n\t Neighbor Network-ID %s"
"\n\t Neighbor Interface-ID %s, Interface %s",
- ipaddr_string(&rlp->link_nrtid),
- ipaddr_string(&rlp->link_nifid),
- ipaddr_string(&rlp->link_ifid));
+ ipaddr_string(ndo, &rlp->link_nrtid),
+ ipaddr_string(ndo, &rlp->link_nifid),
+ ipaddr_string(ndo, &rlp->link_ifid)));
break;
default:
- printf("\n\t Unknown Router Links Type 0x%02x",
- rlp->link_type);
+ ND_PRINT((ndo, "\n\t Unknown Router Links Type 0x%02x",
+ rlp->link_type));
return (0);
}
- printf(", metric %d", EXTRACT_16BITS(&rlp->link_metric));
+ ND_PRINT((ndo, ", metric %d", EXTRACT_16BITS(&rlp->link_metric)));
rlp++;
}
break;
@@ -299,19 +550,19 @@ ospf6_print_lsa(register const struct lsa6 *lsap)
if (lsa_length < sizeof (lsap->lsa_un.un_nla.nla_options))
return (1);
lsa_length -= sizeof (lsap->lsa_un.un_nla.nla_options);
- TCHECK(lsap->lsa_un.un_nla.nla_options);
- printf("\n\t Options [%s]",
- bittok2str(ospf6_option_values, "none",
- EXTRACT_32BITS(&lsap->lsa_un.un_nla.nla_options)));
+ ND_TCHECK(lsap->lsa_un.un_nla.nla_options);
+ ND_PRINT((ndo, "\n\t Options [%s]",
+ bittok2str(ospf6_option_values, "none",
+ EXTRACT_32BITS(&lsap->lsa_un.un_nla.nla_options))));
- printf("\n\t Connected Routers:");
+ ND_PRINT((ndo, "\n\t Connected Routers:"));
ap = lsap->lsa_un.un_nla.nla_router;
while (lsa_length != 0) {
if (lsa_length < sizeof (*ap))
return (1);
lsa_length -= sizeof (*ap);
- TCHECK(*ap);
- printf("\n\t\t%s", ipaddr_string(ap));
+ ND_TCHECK(*ap);
+ ND_PRINT((ndo, "\n\t\t%s", ipaddr_string(ndo, ap)));
++ap;
}
break;
@@ -320,13 +571,13 @@ ospf6_print_lsa(register const struct lsa6 *lsap)
if (lsa_length < sizeof (lsap->lsa_un.un_inter_ap.inter_ap_metric))
return (1);
lsa_length -= sizeof (lsap->lsa_un.un_inter_ap.inter_ap_metric);
- TCHECK(lsap->lsa_un.un_inter_ap.inter_ap_metric);
- printf(", metric %u",
- EXTRACT_32BITS(&lsap->lsa_un.un_inter_ap.inter_ap_metric) & SLA_MASK_METRIC);
+ ND_TCHECK(lsap->lsa_un.un_inter_ap.inter_ap_metric);
+ ND_PRINT((ndo, ", metric %u",
+ EXTRACT_32BITS(&lsap->lsa_un.un_inter_ap.inter_ap_metric) & SLA_MASK_METRIC));
- tptr = (u_int8_t *)lsap->lsa_un.un_inter_ap.inter_ap_prefix;
+ tptr = (const uint8_t *)lsap->lsa_un.un_inter_ap.inter_ap_prefix;
while (lsa_length != 0) {
- bytelen = ospf6_print_lsaprefix(tptr, lsa_length);
+ bytelen = ospf6_print_lsaprefix(ndo, tptr, lsa_length);
if (bytelen < 0)
goto trunc;
lsa_length -= bytelen;
@@ -338,53 +589,53 @@ ospf6_print_lsa(register const struct lsa6 *lsap)
if (lsa_length < sizeof (lsap->lsa_un.un_asla.asla_metric))
return (1);
lsa_length -= sizeof (lsap->lsa_un.un_asla.asla_metric);
- TCHECK(lsap->lsa_un.un_asla.asla_metric);
+ ND_TCHECK(lsap->lsa_un.un_asla.asla_metric);
flags32 = EXTRACT_32BITS(&lsap->lsa_un.un_asla.asla_metric);
- printf("\n\t Flags [%s]",
- bittok2str(ospf6_asla_flag_values, "none", flags32));
- printf(" metric %u",
+ ND_PRINT((ndo, "\n\t Flags [%s]",
+ bittok2str(ospf6_asla_flag_values, "none", flags32)));
+ ND_PRINT((ndo, " metric %u",
EXTRACT_32BITS(&lsap->lsa_un.un_asla.asla_metric) &
- ASLA_MASK_METRIC);
+ ASLA_MASK_METRIC));
- tptr = (u_int8_t *)lsap->lsa_un.un_asla.asla_prefix;
- lsapp = (struct lsa6_prefix *)tptr;
- bytelen = ospf6_print_lsaprefix(tptr, lsa_length);
+ tptr = (const uint8_t *)lsap->lsa_un.un_asla.asla_prefix;
+ lsapp = (const struct lsa6_prefix *)tptr;
+ bytelen = ospf6_print_lsaprefix(ndo, tptr, lsa_length);
if (bytelen < 0)
goto trunc;
lsa_length -= bytelen;
tptr += bytelen;
if ((flags32 & ASLA_FLAG_FWDADDR) != 0) {
- struct in6_addr *fwdaddr6;
+ const struct in6_addr *fwdaddr6;
- fwdaddr6 = (struct in6_addr *)tptr;
+ fwdaddr6 = (const struct in6_addr *)tptr;
if (lsa_length < sizeof (*fwdaddr6))
return (1);
lsa_length -= sizeof (*fwdaddr6);
- TCHECK(*fwdaddr6);
- printf(" forward %s",
- ip6addr_string(fwdaddr6));
+ ND_TCHECK(*fwdaddr6);
+ ND_PRINT((ndo, " forward %s",
+ ip6addr_string(ndo, fwdaddr6)));
tptr += sizeof(*fwdaddr6);
}
if ((flags32 & ASLA_FLAG_ROUTETAG) != 0) {
- if (lsa_length < sizeof (u_int32_t))
+ if (lsa_length < sizeof (uint32_t))
return (1);
- lsa_length -= sizeof (u_int32_t);
- TCHECK(*(u_int32_t *)tptr);
- printf(" tag %s",
- ipaddr_string((u_int32_t *)tptr));
- tptr += sizeof(u_int32_t);
+ lsa_length -= sizeof (uint32_t);
+ ND_TCHECK(*(const uint32_t *)tptr);
+ ND_PRINT((ndo, " tag %s",
+ ipaddr_string(ndo, (const uint32_t *)tptr)));
+ tptr += sizeof(uint32_t);
}
if (lsapp->lsa_p_metric) {
- if (lsa_length < sizeof (u_int32_t))
+ if (lsa_length < sizeof (uint32_t))
return (1);
- lsa_length -= sizeof (u_int32_t);
- TCHECK(*(u_int32_t *)tptr);
- printf(" RefLSID: %s",
- ipaddr_string((u_int32_t *)tptr));
- tptr += sizeof(u_int32_t);
+ lsa_length -= sizeof (uint32_t);
+ ND_TCHECK(*(const uint32_t *)tptr);
+ ND_PRINT((ndo, " RefLSID: %s",
+ ipaddr_string(ndo, (const uint32_t *)tptr)));
+ tptr += sizeof(uint32_t);
}
break;
@@ -394,23 +645,23 @@ ospf6_print_lsa(register const struct lsa6 *lsap)
if (lsa_length < sizeof (llsap->llsa_priandopt))
return (1);
lsa_length -= sizeof (llsap->llsa_priandopt);
- TCHECK(llsap->llsa_priandopt);
- printf("\n\t Options [%s]",
- bittok2str(ospf6_option_values, "none",
- EXTRACT_32BITS(&llsap->llsa_options)));
+ ND_TCHECK(llsap->llsa_priandopt);
+ ND_PRINT((ndo, "\n\t Options [%s]",
+ bittok2str(ospf6_option_values, "none",
+ EXTRACT_32BITS(&llsap->llsa_options))));
if (lsa_length < sizeof (llsap->llsa_lladdr) + sizeof (llsap->llsa_nprefix))
return (1);
lsa_length -= sizeof (llsap->llsa_lladdr) + sizeof (llsap->llsa_nprefix);
prefixes = EXTRACT_32BITS(&llsap->llsa_nprefix);
- printf("\n\t Priority %d, Link-local address %s, Prefixes %d:",
+ ND_PRINT((ndo, "\n\t Priority %d, Link-local address %s, Prefixes %d:",
llsap->llsa_priority,
- ip6addr_string(&llsap->llsa_lladdr),
- prefixes);
+ ip6addr_string(ndo, &llsap->llsa_lladdr),
+ prefixes));
- tptr = (u_int8_t *)llsap->llsa_prefix;
+ tptr = (const uint8_t *)llsap->llsa_prefix;
while (prefixes > 0) {
- bytelen = ospf6_print_lsaprefix(tptr, lsa_length);
+ bytelen = ospf6_print_lsaprefix(ndo, tptr, lsa_length);
if (bytelen < 0)
goto trunc;
prefixes--;
@@ -424,21 +675,21 @@ ospf6_print_lsa(register const struct lsa6 *lsap)
if (lsa_length < sizeof (lsap->lsa_un.un_intra_ap.intra_ap_rtid))
return (1);
lsa_length -= sizeof (lsap->lsa_un.un_intra_ap.intra_ap_rtid);
- TCHECK(lsap->lsa_un.un_intra_ap.intra_ap_rtid);
- ospf6_print_ls_type(
+ ND_TCHECK(lsap->lsa_un.un_intra_ap.intra_ap_rtid);
+ ospf6_print_ls_type(ndo,
EXTRACT_16BITS(&lsap->lsa_un.un_intra_ap.intra_ap_lstype),
&lsap->lsa_un.un_intra_ap.intra_ap_lsid);
if (lsa_length < sizeof (lsap->lsa_un.un_intra_ap.intra_ap_nprefix))
return (1);
lsa_length -= sizeof (lsap->lsa_un.un_intra_ap.intra_ap_nprefix);
- TCHECK(lsap->lsa_un.un_intra_ap.intra_ap_nprefix);
+ ND_TCHECK(lsap->lsa_un.un_intra_ap.intra_ap_nprefix);
prefixes = EXTRACT_16BITS(&lsap->lsa_un.un_intra_ap.intra_ap_nprefix);
- printf("\n\t Prefixes %d:", prefixes);
+ ND_PRINT((ndo, "\n\t Prefixes %d:", prefixes));
- tptr = (u_int8_t *)lsap->lsa_un.un_intra_ap.intra_ap_prefix;
+ tptr = (const uint8_t *)lsap->lsa_un.un_intra_ap.intra_ap_prefix;
while (prefixes > 0) {
- bytelen = ospf6_print_lsaprefix(tptr, lsa_length);
+ bytelen = ospf6_print_lsaprefix(ndo, tptr, lsa_length);
if (bytelen < 0)
goto trunc;
prefixes--;
@@ -448,19 +699,19 @@ ospf6_print_lsa(register const struct lsa6 *lsap)
break;
case LS_TYPE_GRACE | LS_SCOPE_LINKLOCAL:
- if (ospf_print_grace_lsa(tptr, lsa_length) == -1) {
+ if (ospf_print_grace_lsa(ndo, tptr, lsa_length) == -1) {
return 1;
}
break;
case LS_TYPE_INTRA_ATE | LS_SCOPE_LINKLOCAL:
- if (ospf_print_te_lsa(tptr, lsa_length) == -1) {
+ if (ospf_print_te_lsa(ndo, tptr, lsa_length) == -1) {
return 1;
}
break;
default:
- if(!print_unknown_data(tptr,
+ if(!print_unknown_data(ndo,tptr,
"\n\t ",
lsa_length)) {
return (1);
@@ -474,8 +725,9 @@ trunc:
}
static int
-ospf6_decode_v3(register const struct ospf6hdr *op,
- register const u_char *dataend)
+ospf6_decode_v3(netdissect_options *ndo,
+ register const struct ospf6hdr *op,
+ register const u_char *dataend)
{
register const rtrid_t *ap;
register const struct lsr6 *lsrp;
@@ -485,66 +737,74 @@ ospf6_decode_v3(register const struct ospf6hdr *op,
switch (op->ospf6_type) {
- case OSPF_TYPE_HELLO:
- printf("\n\tOptions [%s]",
- bittok2str(ospf6_option_values, "none",
- EXTRACT_32BITS(&op->ospf6_hello.hello_options)));
-
- TCHECK(op->ospf6_hello.hello_deadint);
- printf("\n\t Hello Timer %us, Dead Timer %us, Interface-ID %s, Priority %u",
- EXTRACT_16BITS(&op->ospf6_hello.hello_helloint),
- EXTRACT_16BITS(&op->ospf6_hello.hello_deadint),
- ipaddr_string(&op->ospf6_hello.hello_ifid),
- op->ospf6_hello.hello_priority);
-
- TCHECK(op->ospf6_hello.hello_dr);
- if (op->ospf6_hello.hello_dr != 0)
- printf("\n\t Designated Router %s",
- ipaddr_string(&op->ospf6_hello.hello_dr));
- TCHECK(op->ospf6_hello.hello_bdr);
- if (op->ospf6_hello.hello_bdr != 0)
- printf(", Backup Designated Router %s",
- ipaddr_string(&op->ospf6_hello.hello_bdr));
- if (vflag) {
- printf("\n\t Neighbor List:");
- ap = op->ospf6_hello.hello_neighbor;
- while ((u_char *)ap < dataend) {
- TCHECK(*ap);
- printf("\n\t %s", ipaddr_string(ap));
+ case OSPF_TYPE_HELLO: {
+ register const struct hello6 *hellop = (const struct hello6 *)((const uint8_t *)op + OSPF6HDR_LEN);
+
+ ND_PRINT((ndo, "\n\tOptions [%s]",
+ bittok2str(ospf6_option_values, "none",
+ EXTRACT_32BITS(&hellop->hello_options))));
+
+ ND_TCHECK(hellop->hello_deadint);
+ ND_PRINT((ndo, "\n\t Hello Timer %us, Dead Timer %us, Interface-ID %s, Priority %u",
+ EXTRACT_16BITS(&hellop->hello_helloint),
+ EXTRACT_16BITS(&hellop->hello_deadint),
+ ipaddr_string(ndo, &hellop->hello_ifid),
+ hellop->hello_priority));
+
+ ND_TCHECK(hellop->hello_dr);
+ if (EXTRACT_32BITS(&hellop->hello_dr) != 0)
+ ND_PRINT((ndo, "\n\t Designated Router %s",
+ ipaddr_string(ndo, &hellop->hello_dr)));
+ ND_TCHECK(hellop->hello_bdr);
+ if (EXTRACT_32BITS(&hellop->hello_bdr) != 0)
+ ND_PRINT((ndo, ", Backup Designated Router %s",
+ ipaddr_string(ndo, &hellop->hello_bdr)));
+ if (ndo->ndo_vflag > 1) {
+ ND_PRINT((ndo, "\n\t Neighbor List:"));
+ ap = hellop->hello_neighbor;
+ while ((const u_char *)ap < dataend) {
+ ND_TCHECK(*ap);
+ ND_PRINT((ndo, "\n\t %s", ipaddr_string(ndo, ap)));
++ap;
}
}
break; /* HELLO */
+ }
- case OSPF_TYPE_DD:
- TCHECK(op->ospf6_db.db_options);
- printf("\n\tOptions [%s]",
- bittok2str(ospf6_option_values, "none",
- EXTRACT_32BITS(&op->ospf6_db.db_options)));
- TCHECK(op->ospf6_db.db_flags);
- printf(", DD Flags [%s]",
- bittok2str(ospf6_dd_flag_values,"none",op->ospf6_db.db_flags));
-
- TCHECK(op->ospf6_db.db_seq);
- printf(", MTU %u, DD-Sequence 0x%08x",
- EXTRACT_16BITS(&op->ospf6_db.db_mtu),
- EXTRACT_32BITS(&op->ospf6_db.db_seq));
-
- /* Print all the LS adv's */
- lshp = op->ospf6_db.db_lshdr;
- while (!ospf6_print_lshdr(lshp)) {
- ++lshp;
- }
+ case OSPF_TYPE_DD: {
+ register const struct dd6 *ddp = (const struct dd6 *)((const uint8_t *)op + OSPF6HDR_LEN);
+
+ ND_TCHECK(ddp->db_options);
+ ND_PRINT((ndo, "\n\tOptions [%s]",
+ bittok2str(ospf6_option_values, "none",
+ EXTRACT_32BITS(&ddp->db_options))));
+ ND_TCHECK(ddp->db_flags);
+ ND_PRINT((ndo, ", DD Flags [%s]",
+ bittok2str(ospf6_dd_flag_values,"none",ddp->db_flags)));
+
+ ND_TCHECK(ddp->db_seq);
+ ND_PRINT((ndo, ", MTU %u, DD-Sequence 0x%08x",
+ EXTRACT_16BITS(&ddp->db_mtu),
+ EXTRACT_32BITS(&ddp->db_seq)));
+ if (ndo->ndo_vflag > 1) {
+ /* Print all the LS adv's */
+ lshp = ddp->db_lshdr;
+ while ((const u_char *)lshp < dataend) {
+ if (ospf6_print_lshdr(ndo, lshp++, dataend))
+ goto trunc;
+ }
+ }
break;
+ }
case OSPF_TYPE_LS_REQ:
- if (vflag) {
- lsrp = op->ospf6_lsr;
- while ((u_char *)lsrp < dataend) {
- TCHECK(*lsrp);
- printf("\n\t Advertising Router %s",
- ipaddr_string(&lsrp->ls_router));
- ospf6_print_ls_type(EXTRACT_16BITS(&lsrp->ls_type),
+ if (ndo->ndo_vflag > 1) {
+ lsrp = (const struct lsr6 *)((const uint8_t *)op + OSPF6HDR_LEN);
+ while ((const u_char *)lsrp < dataend) {
+ ND_TCHECK(*lsrp);
+ ND_PRINT((ndo, "\n\t Advertising Router %s",
+ ipaddr_string(ndo, &lsrp->ls_router)));
+ ospf6_print_ls_type(ndo, EXTRACT_16BITS(&lsrp->ls_type),
&lsrp->ls_stateid);
++lsrp;
}
@@ -552,26 +812,27 @@ ospf6_decode_v3(register const struct ospf6hdr *op,
break;
case OSPF_TYPE_LS_UPDATE:
- if (vflag) {
- lsap = op->ospf6_lsu.lsu_lsa;
- TCHECK(op->ospf6_lsu.lsu_count);
- i = EXTRACT_32BITS(&op->ospf6_lsu.lsu_count);
- while (i--) {
- if (ospf6_print_lsa(lsap))
+ if (ndo->ndo_vflag > 1) {
+ register const struct lsu6 *lsup = (const struct lsu6 *)((const uint8_t *)op + OSPF6HDR_LEN);
+
+ ND_TCHECK(lsup->lsu_count);
+ i = EXTRACT_32BITS(&lsup->lsu_count);
+ lsap = lsup->lsu_lsa;
+ while ((const u_char *)lsap < dataend && i--) {
+ if (ospf6_print_lsa(ndo, lsap, dataend))
goto trunc;
- lsap = (struct lsa6 *)((u_char *)lsap +
+ lsap = (const struct lsa6 *)((const u_char *)lsap +
EXTRACT_16BITS(&lsap->ls_hdr.ls_length));
}
}
break;
-
case OSPF_TYPE_LS_ACK:
- if (vflag) {
- lshp = op->ospf6_lsa.lsa_lshdr;
-
- while (!ospf6_print_lshdr(lshp)) {
- ++lshp;
+ if (ndo->ndo_vflag > 1) {
+ lshp = (const struct lsa6_hdr *)((const uint8_t *)op + OSPF6HDR_LEN);
+ while ((const u_char *)lshp < dataend) {
+ if (ospf6_print_lshdr(ndo, lshp++, dataend))
+ goto trunc;
}
}
break;
@@ -584,63 +845,174 @@ trunc:
return (1);
}
+/* RFC5613 Section 2.2 (w/o the TLVs) */
+static int
+ospf6_print_lls(netdissect_options *ndo,
+ const u_char *cp, const u_int len)
+{
+ uint16_t llsdatalen;
+
+ if (len == 0)
+ return 0;
+ if (len < OSPF_LLS_HDRLEN)
+ goto trunc;
+ /* Checksum */
+ ND_TCHECK2(*cp, 2);
+ ND_PRINT((ndo, "\n\tLLS Checksum 0x%04x", EXTRACT_16BITS(cp)));
+ cp += 2;
+ /* LLS Data Length */
+ ND_TCHECK2(*cp, 2);
+ llsdatalen = EXTRACT_16BITS(cp);
+ ND_PRINT((ndo, ", Data Length %u", llsdatalen));
+ if (llsdatalen < OSPF_LLS_HDRLEN || llsdatalen > len)
+ goto trunc;
+ cp += 2;
+ /* LLS TLVs */
+ ND_TCHECK2(*cp, llsdatalen - OSPF_LLS_HDRLEN);
+ /* FIXME: code in print-ospf.c can be reused to decode the TLVs */
+
+ return llsdatalen;
+trunc:
+ return -1;
+}
+
+/* RFC6506 Section 4.1 */
+static int
+ospf6_decode_at(netdissect_options *ndo,
+ const u_char *cp, const u_int len)
+{
+ uint16_t authdatalen;
+
+ if (len == 0)
+ return 0;
+ if (len < OSPF6_AT_HDRLEN)
+ goto trunc;
+ /* Authentication Type */
+ ND_TCHECK2(*cp, 2);
+ ND_PRINT((ndo, "\n\tAuthentication Type %s", tok2str(ospf6_auth_type_str, "unknown (0x%04x)", EXTRACT_16BITS(cp))));
+ cp += 2;
+ /* Auth Data Len */
+ ND_TCHECK2(*cp, 2);
+ authdatalen = EXTRACT_16BITS(cp);
+ ND_PRINT((ndo, ", Length %u", authdatalen));
+ if (authdatalen < OSPF6_AT_HDRLEN || authdatalen > len)
+ goto trunc;
+ cp += 2;
+ /* Reserved */
+ ND_TCHECK2(*cp, 2);
+ cp += 2;
+ /* Security Association ID */
+ ND_TCHECK2(*cp, 2);
+ ND_PRINT((ndo, ", SAID %u", EXTRACT_16BITS(cp)));
+ cp += 2;
+ /* Cryptographic Sequence Number (High-Order 32 Bits) */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, ", CSN 0x%08x", EXTRACT_32BITS(cp)));
+ cp += 4;
+ /* Cryptographic Sequence Number (Low-Order 32 Bits) */
+ ND_TCHECK2(*cp, 4);
+ ND_PRINT((ndo, ":%08x", EXTRACT_32BITS(cp)));
+ cp += 4;
+ /* Authentication Data */
+ ND_TCHECK2(*cp, authdatalen - OSPF6_AT_HDRLEN);
+ if (ndo->ndo_vflag > 1)
+ print_unknown_data(ndo,cp, "\n\tAuthentication Data ", authdatalen - OSPF6_AT_HDRLEN);
+ return 0;
+
+trunc:
+ return 1;
+}
+
+/* The trailing data may include LLS and/or AT data (in this specific order).
+ * LLS data may be present only in Hello and DBDesc packets with the L-bit set.
+ * AT data may be present in Hello and DBDesc packets with the AT-bit set or in
+ * any other packet type, thus decode the AT data regardless of the AT-bit.
+ */
+static int
+ospf6_decode_v3_trailer(netdissect_options *ndo,
+ const struct ospf6hdr *op, const u_char *cp, const unsigned len)
+{
+ int llslen = 0;
+ int lls_hello = 0;
+ int lls_dd = 0;
+
+ if (op->ospf6_type == OSPF_TYPE_HELLO) {
+ const struct hello6 *hellop = (const struct hello6 *)((const uint8_t *)op + OSPF6HDR_LEN);
+ if (EXTRACT_32BITS(&hellop->hello_options) & OSPF6_OPTION_L)
+ lls_hello = 1;
+ } else if (op->ospf6_type == OSPF_TYPE_DD) {
+ const struct dd6 *ddp = (const struct dd6 *)((const uint8_t *)op + OSPF6HDR_LEN);
+ if (EXTRACT_32BITS(&ddp->db_options) & OSPF6_OPTION_L)
+ lls_dd = 1;
+ }
+ if ((lls_hello || lls_dd) && (llslen = ospf6_print_lls(ndo, cp, len)) < 0)
+ goto trunc;
+ return ospf6_decode_at(ndo, cp + llslen, len - llslen);
+
+trunc:
+ return 1;
+}
+
void
-ospf6_print(register const u_char *bp, register u_int length)
+ospf6_print(netdissect_options *ndo,
+ register const u_char *bp, register u_int length)
{
register const struct ospf6hdr *op;
register const u_char *dataend;
register const char *cp;
+ uint16_t datalen;
- op = (struct ospf6hdr *)bp;
+ op = (const struct ospf6hdr *)bp;
/* If the type is valid translate it, or just print the type */
/* value. If it's not valid, say so and return */
- TCHECK(op->ospf6_type);
- cp = tok2str(ospf6_type_values, "unknown LS-type", op->ospf6_type);
- printf("OSPFv%u, %s, length %d", op->ospf6_version, cp, length);
+ ND_TCHECK(op->ospf6_type);
+ cp = tok2str(ospf6_type_values, "unknown packet type (%u)", op->ospf6_type);
+ ND_PRINT((ndo, "OSPFv%u, %s, length %d", op->ospf6_version, cp, length));
if (*cp == 'u') {
return;
- }
+ }
- if(!vflag) { /* non verbose - so lets bail out here */
- return;
- }
+ if(!ndo->ndo_vflag) { /* non verbose - so lets bail out here */
+ return;
+ }
- TCHECK(op->ospf6_len);
- if (length != EXTRACT_16BITS(&op->ospf6_len)) {
- printf(" [len %d]", EXTRACT_16BITS(&op->ospf6_len));
+ /* OSPFv3 data always comes first and optional trailing data may follow. */
+ ND_TCHECK(op->ospf6_len);
+ datalen = EXTRACT_16BITS(&op->ospf6_len);
+ if (datalen > length) {
+ ND_PRINT((ndo, " [len %d]", datalen));
return;
}
- dataend = bp + length;
+ dataend = bp + datalen;
- /* Print the routerid if it is not the same as the source */
- TCHECK(op->ospf6_routerid);
- printf("\n\tRouter-ID %s", ipaddr_string(&op->ospf6_routerid));
+ ND_TCHECK(op->ospf6_routerid);
+ ND_PRINT((ndo, "\n\tRouter-ID %s", ipaddr_string(ndo, &op->ospf6_routerid)));
- TCHECK(op->ospf6_areaid);
- if (op->ospf6_areaid != 0)
- printf(", Area %s", ipaddr_string(&op->ospf6_areaid));
+ ND_TCHECK(op->ospf6_areaid);
+ if (EXTRACT_32BITS(&op->ospf6_areaid) != 0)
+ ND_PRINT((ndo, ", Area %s", ipaddr_string(ndo, &op->ospf6_areaid)));
else
- printf(", Backbone Area");
- TCHECK(op->ospf6_instanceid);
+ ND_PRINT((ndo, ", Backbone Area"));
+ ND_TCHECK(op->ospf6_instanceid);
if (op->ospf6_instanceid)
- printf(", Instance %u", op->ospf6_instanceid);
+ ND_PRINT((ndo, ", Instance %u", op->ospf6_instanceid));
/* Do rest according to version. */
switch (op->ospf6_version) {
case 3:
/* ospf version 3 */
- if (ospf6_decode_v3(op, dataend))
+ if (ospf6_decode_v3(ndo, op, dataend) ||
+ ospf6_decode_v3_trailer(ndo, op, dataend, length - datalen))
goto trunc;
break;
-
- default:
- printf(" ospf [version %d]", op->ospf6_version);
- break;
} /* end switch on version */
return;
trunc:
- fputs(tstr, stdout);
+ ND_PRINT((ndo, "%s", tstr));
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-ospf6-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-otv.c b/freebsd/contrib/tcpdump/print-otv.c
index 12da24c8..53bbc2f6 100644
--- a/freebsd/contrib/tcpdump/print-otv.c
+++ b/freebsd/contrib/tcpdump/print-otv.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code
@@ -15,20 +18,18 @@
* Original code by Francesco Fondelli (francesco dot fondelli, gmail dot com)
*/
+/* \summary: Overlay Transport Virtualization (OTV) printer */
+
+/* specification: draft-hasmit-otv-04 */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
-#include "addrtoname.h"
-
-#include "udp.h"
/*
* OTV header, draft-hasmit-otv-04
@@ -43,39 +44,37 @@
*/
void
-otv_print(const u_char *bp, u_int len)
+otv_print(netdissect_options *ndo, const u_char *bp, u_int len)
{
- u_int8_t flags;
- u_int32_t overlay_id;
- u_int32_t instance_id;
-
- if (len < 8) {
- printf("[|OTV]");
- return;
- }
+ uint8_t flags;
+
+ ND_PRINT((ndo, "OTV, "));
+ if (len < 8)
+ goto trunc;
+ ND_TCHECK(*bp);
flags = *bp;
+ ND_PRINT((ndo, "flags [%s] (0x%02x), ", flags & 0x08 ? "I" : ".", flags));
bp += 1;
- overlay_id = EXTRACT_24BITS(bp);
+ ND_TCHECK2(*bp, 3);
+ ND_PRINT((ndo, "overlay %u, ", EXTRACT_24BITS(bp)));
bp += 3;
- instance_id = EXTRACT_24BITS(bp);
- bp += 4;
-
- printf("OTV, ");
-
- fputs("flags [", stdout);
- if (flags & 0x08)
- fputs("I", stdout);
- else
- fputs(".", stdout);
- fputs("] ", stdout);
+ ND_TCHECK2(*bp, 3);
+ ND_PRINT((ndo, "instance %u\n", EXTRACT_24BITS(bp)));
+ bp += 3;
- printf("(0x%02x), ", flags);
- printf("overlay %u, ", overlay_id);
- printf("instance %u\n", instance_id);
+ /* Reserved */
+ ND_TCHECK(*bp);
+ bp += 1;
- ether_print(gndo, bp, len - 8, len - 8, NULL, NULL);
+ ether_print(ndo, bp, len - 8, ndo->ndo_snapend - bp, NULL, NULL);
return;
+
+trunc:
+ ND_PRINT((ndo, " [|OTV]"));
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-otv-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-pflog.c b/freebsd/contrib/tcpdump/print-pflog.c
index ff913129..c93de3e9 100644
--- a/freebsd/contrib/tcpdump/print-pflog.c
+++ b/freebsd/contrib/tcpdump/print-pflog.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996
* The Regents of the University of California. All rights reserved.
@@ -21,10 +24,7 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-pflog.c,v 1.16 2007-09-12 19:36:18 guy Exp $ (LBL)";
-#endif
+/* \summary: OpenBSD packet filter log file printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -39,16 +39,14 @@ static const char rcsid[] _U_ =
#include <net/pfvar.h>
#include <net/if_pflog.h>
-#include <tcpdump-stdinc.h>
-
-#include <stdio.h>
-#include <pcap.h>
+#include <netdissect-stdinc.h>
+#include "netdissect.h"
#include "extract.h"
-#include "interface.h"
-#include "addrtoname.h"
-static struct tok pf_reasons[] = {
+static const char tstr[] = "[|pflog]";
+
+static const struct tok pf_reasons[] = {
{ 0, "0(match)" },
{ 1, "1(bad-offset)" },
{ 2, "2(fragment)" },
@@ -67,7 +65,7 @@ static struct tok pf_reasons[] = {
{ 0, NULL }
};
-static struct tok pf_actions[] = {
+static const struct tok pf_actions[] = {
{ PF_PASS, "pass" },
{ PF_DROP, "block" },
{ PF_SCRUB, "scrub" },
@@ -81,7 +79,7 @@ static struct tok pf_actions[] = {
{ 0, NULL }
};
-static struct tok pf_directions[] = {
+static const struct tok pf_directions[] = {
{ PF_INOUT, "in/out" },
{ PF_IN, "in" },
{ PF_OUT, "out" },
@@ -93,58 +91,58 @@ static struct tok pf_directions[] = {
#define OPENBSD_AF_INET6 24
static void
-pflog_print(const struct pfloghdr *hdr)
+pflog_print(netdissect_options *ndo, const struct pfloghdr *hdr)
{
- u_int32_t rulenr, subrulenr;
+ uint32_t rulenr, subrulenr;
rulenr = EXTRACT_32BITS(&hdr->rulenr);
subrulenr = EXTRACT_32BITS(&hdr->subrulenr);
- if (subrulenr == (u_int32_t)-1)
- printf("rule %u/", rulenr);
+ if (subrulenr == (uint32_t)-1)
+ ND_PRINT((ndo, "rule %u/", rulenr));
else
- printf("rule %u.%s.%u/", rulenr, hdr->ruleset, subrulenr);
+ ND_PRINT((ndo, "rule %u.%s.%u/", rulenr, hdr->ruleset, subrulenr));
- printf("%s: %s %s on %s: ",
+ ND_PRINT((ndo, "%s: %s %s on %s: ",
tok2str(pf_reasons, "unkn(%u)", hdr->reason),
tok2str(pf_actions, "unkn(%u)", hdr->action),
tok2str(pf_directions, "unkn(%u)", hdr->dir),
- hdr->ifname);
+ hdr->ifname));
}
u_int
-pflog_if_print(const struct pcap_pkthdr *h, register const u_char *p)
+pflog_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h,
+ register const u_char *p)
{
u_int length = h->len;
u_int hdrlen;
u_int caplen = h->caplen;
const struct pfloghdr *hdr;
- u_int8_t af;
+ uint8_t af;
/* check length */
- if (caplen < sizeof(u_int8_t)) {
- printf("[|pflog]");
+ if (caplen < sizeof(uint8_t)) {
+ ND_PRINT((ndo, "%s", tstr));
return (caplen);
}
#define MIN_PFLOG_HDRLEN 45
- hdr = (struct pfloghdr *)p;
+ hdr = (const struct pfloghdr *)p;
if (hdr->length < MIN_PFLOG_HDRLEN) {
- printf("[pflog: invalid header length!]");
+ ND_PRINT((ndo, "[pflog: invalid header length!]"));
return (hdr->length); /* XXX: not really */
}
hdrlen = BPF_WORDALIGN(hdr->length);
if (caplen < hdrlen) {
- printf("[|pflog]");
+ ND_PRINT((ndo, "%s", tstr));
return (hdrlen); /* XXX: true? */
}
/* print what we know */
- hdr = (struct pfloghdr *)p;
- TCHECK(*hdr);
- if (eflag)
- pflog_print(hdr);
-
+ ND_TCHECK(*hdr);
+ if (ndo->ndo_eflag)
+ pflog_print(ndo, hdr);
+
/* skip to the real packet */
af = hdr->af;
length -= hdrlen;
@@ -156,29 +154,31 @@ pflog_if_print(const struct pcap_pkthdr *h, register const u_char *p)
#if OPENBSD_AF_INET != AF_INET
case OPENBSD_AF_INET: /* XXX: read pcap files */
#endif
- ip_print(gndo, p, length);
+ ip_print(ndo, p, length);
break;
-#ifdef INET6
+#if defined(AF_INET6) || defined(OPENBSD_AF_INET6)
+#ifdef AF_INET6
case AF_INET6:
-#if OPENBSD_AF_INET6 != AF_INET6
+#endif /* AF_INET6 */
+#if !defined(AF_INET6) || OPENBSD_AF_INET6 != AF_INET6
case OPENBSD_AF_INET6: /* XXX: read pcap files */
-#endif
- ip6_print(gndo, p, length);
+#endif /* !defined(AF_INET6) || OPENBSD_AF_INET6 != AF_INET6 */
+ ip6_print(ndo, p, length);
break;
-#endif
+#endif /* defined(AF_INET6) || defined(OPENBSD_AF_INET6) */
default:
/* address family not handled, print raw packet */
- if (!eflag)
- pflog_print(hdr);
- if (!suppress_default_print)
- default_print(p, caplen);
+ if (!ndo->ndo_eflag)
+ pflog_print(ndo, hdr);
+ if (!ndo->ndo_suppress_default_print)
+ ND_DEFAULTPRINT(p, caplen);
}
-
+
return (hdrlen);
trunc:
- printf("[|pflog]");
+ ND_PRINT((ndo, "%s", tstr));
return (hdrlen);
}
@@ -188,3 +188,6 @@ trunc:
* c-basic-offset: 8
* End:
*/
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-pflog-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-pfsync.c b/freebsd/contrib/tcpdump/print-pfsync.c
index fc71f732..5f7a9bfb 100644
--- a/freebsd/contrib/tcpdump/print-pfsync.c
+++ b/freebsd/contrib/tcpdump/print-pfsync.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 2012 Gleb Smirnoff <glebius@FreeBSD.org>
* Copyright (c) 2002 Michael Shalayeff
@@ -35,25 +38,29 @@
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
-
+#ifndef HAVE_NET_PFVAR_H
+#error "No pf headers available"
+#endif
#include <sys/endian.h>
#include <net/if.h>
-#define TCPSTATES
-#include <net/pfvar.h> /* XXX */
+#include <net/pfvar.h>
#include <net/if_pfsync.h>
-#include <netinet/ip.h>
+#define TCPSTATES
#include <netinet/tcp_fsm.h>
+#include <netdissect-stdinc.h>
#include <string.h>
+#include "netdissect.h"
#include "interface.h"
#include "addrtoname.h"
-static void pfsync_print(struct pfsync_header *, const u_char *, u_int);
-static void print_src_dst(const struct pfsync_state_peer *,
+static void pfsync_print(netdissect_options *, struct pfsync_header *,
+ const u_char *, u_int);
+static void print_src_dst(netdissect_options *,
+ const struct pfsync_state_peer *,
const struct pfsync_state_peer *, uint8_t);
-static void print_state(struct pfsync_state *);
+static void print_state(netdissect_options *, struct pfsync_state *);
#ifdef notyet
void
@@ -65,7 +72,7 @@ pfsync_if_print(u_char *user, const struct pcap_pkthdr *h,
ts_print(&h->ts);
if (caplen < PFSYNC_HDRLEN) {
- printf("[|pfsync]");
+ ND_PRINT((ndo, "[|pfsync]"));
goto out;
}
@@ -76,37 +83,40 @@ out:
if (xflag) {
default_print((const u_char *)p, caplen);
}
- putchar('\n');
+ safeputchar(ndo, '\n');
}
#endif /* notyet */
void
-pfsync_ip_print(const u_char *bp, u_int len)
+pfsync_ip_print(netdissect_options *ndo , const u_char *bp, u_int len)
{
struct pfsync_header *hdr = (struct pfsync_header *)bp;
if (len < PFSYNC_HDRLEN)
- printf("[|pfsync]");
+ ND_PRINT((ndo, "[|pfsync]"));
else
- pfsync_print(hdr, bp + sizeof(struct pfsync_header),
+ pfsync_print(ndo, hdr, bp + sizeof(struct pfsync_header),
len - sizeof(struct pfsync_header));
}
struct pfsync_actions {
const char *name;
size_t len;
- void (*print)(const void *);
+ void (*print)(netdissect_options *, const void *);
};
-static void pfsync_print_clr(const void *);
-static void pfsync_print_state(const void *);
-static void pfsync_print_ins_ack(const void *);
-static void pfsync_print_upd_c(const void *);
-static void pfsync_print_upd_req(const void *);
-static void pfsync_print_del_c(const void *);
-static void pfsync_print_bus(const void *);
-static void pfsync_print_tdb(const void *);
-
+static void pfsync_print_clr(netdissect_options *, const void *);
+static void pfsync_print_state(netdissect_options *, const void *);
+static void pfsync_print_ins_ack(netdissect_options *, const void *);
+static void pfsync_print_upd_c(netdissect_options *, const void *);
+static void pfsync_print_upd_req(netdissect_options *, const void *);
+static void pfsync_print_del_c(netdissect_options *, const void *);
+static void pfsync_print_bus(netdissect_options *, const void *);
+static void pfsync_print_tdb(netdissect_options *, const void *);
+
+#ifdef __rtems__
+static const
+#endif /* __rtems__ */
struct pfsync_actions actions[] = {
{ "clear all", sizeof(struct pfsync_clr), pfsync_print_clr },
{ "insert", sizeof(struct pfsync_state), pfsync_print_state },
@@ -128,7 +138,8 @@ struct pfsync_actions actions[] = {
};
static void
-pfsync_print(struct pfsync_header *hdr, const u_char *bp, u_int len)
+pfsync_print(netdissect_options *ndo, struct pfsync_header *hdr,
+ const u_char *bp, u_int len)
{
struct pfsync_subheader *subh;
int count, plen, i;
@@ -136,7 +147,7 @@ pfsync_print(struct pfsync_header *hdr, const u_char *bp, u_int len)
plen = ntohs(hdr->len);
- printf("PFSYNCv%d len %d", hdr->version, plen);
+ ND_PRINT((ndo, "PFSYNCv%d len %d", hdr->version, plen));
if (hdr->version != PFSYNC_VERSION)
return;
@@ -153,19 +164,22 @@ pfsync_print(struct pfsync_header *hdr, const u_char *bp, u_int len)
plen -= sizeof(*subh);
if (subh->action >= PFSYNC_ACT_MAX) {
- printf("\n act UNKNOWN id %d", subh->action);
+ ND_PRINT((ndo, "\n act UNKNOWN id %d",
+ subh->action));
return;
}
count = ntohs(subh->count);
- printf("\n %s count %d", actions[subh->action].name, count);
+ ND_PRINT((ndo, "\n %s count %d", actions[subh->action].name,
+ count));
alen = actions[subh->action].len;
if (subh->action == PFSYNC_ACT_EOF)
return;
if (actions[subh->action].print == NULL) {
- printf("\n unimplemented action %hhu", subh->action);
+ ND_PRINT((ndo, "\n unimplemented action %hhu",
+ subh->action));
return;
}
@@ -175,8 +189,8 @@ pfsync_print(struct pfsync_header *hdr, const u_char *bp, u_int len)
break;
}
- if (vflag)
- actions[subh->action].print(bp);
+ if (ndo->ndo_vflag)
+ actions[subh->action].print(ndo, bp);
bp += alen;
len -= alen;
@@ -185,78 +199,78 @@ pfsync_print(struct pfsync_header *hdr, const u_char *bp, u_int len)
}
if (plen > 0) {
- printf("\n ...");
+ ND_PRINT((ndo, "\n ..."));
return;
}
if (plen < 0) {
- printf("\n invalid header length");
+ ND_PRINT((ndo, "\n invalid header length"));
return;
}
if (len > 0)
- printf("\n invalid packet length");
+ ND_PRINT((ndo, "\n invalid packet length"));
}
static void
-pfsync_print_clr(const void *bp)
+pfsync_print_clr(netdissect_options *ndo, const void *bp)
{
const struct pfsync_clr *clr = bp;
- printf("\n\tcreatorid: %08x", htonl(clr->creatorid));
+ ND_PRINT((ndo, "\n\tcreatorid: %08x", htonl(clr->creatorid)));
if (clr->ifname[0] != '\0')
- printf(" interface: %s", clr->ifname);
+ ND_PRINT((ndo, " interface: %s", clr->ifname));
}
static void
-pfsync_print_state(const void *bp)
+pfsync_print_state(netdissect_options *ndo, const void *bp)
{
struct pfsync_state *st = (struct pfsync_state *)bp;
- putchar('\n');
- print_state(st);
+ safeputchar(ndo, '\n');
+ print_state(ndo, st);
}
static void
-pfsync_print_ins_ack(const void *bp)
+pfsync_print_ins_ack(netdissect_options *ndo, const void *bp)
{
const struct pfsync_ins_ack *iack = bp;
- printf("\n\tid: %016jx creatorid: %08x", (uintmax_t )be64toh(iack->id),
- ntohl(iack->creatorid));
+ ND_PRINT((ndo, "\n\tid: %016jx creatorid: %08x",
+ (uintmax_t)be64toh(iack->id), ntohl(iack->creatorid)));
}
static void
-pfsync_print_upd_c(const void *bp)
+pfsync_print_upd_c(netdissect_options *ndo, const void *bp)
{
const struct pfsync_upd_c *u = bp;
- printf("\n\tid: %016jx creatorid: %08x", (uintmax_t )be64toh(u->id),
- ntohl(u->creatorid));
- if (vflag > 2) {
- printf("\n\tTCP? :");
- print_src_dst(&u->src, &u->dst, IPPROTO_TCP);
+ ND_PRINT((ndo, "\n\tid: %016jx creatorid: %08x",
+ (uintmax_t)be64toh(u->id), ntohl(u->creatorid)));
+ if (ndo->ndo_vflag > 2) {
+ ND_PRINT((ndo, "\n\tTCP? :"));
+ print_src_dst(ndo, &u->src, &u->dst, IPPROTO_TCP);
}
}
static void
-pfsync_print_upd_req(const void *bp)
+pfsync_print_upd_req(netdissect_options *ndo, const void *bp)
{
const struct pfsync_upd_req *ur = bp;
- printf("\n\tid: %016jx creatorid: %08x", (uintmax_t )be64toh(ur->id),
- ntohl(ur->creatorid));
+ ND_PRINT((ndo, "\n\tid: %016jx creatorid: %08x",
+ (uintmax_t)be64toh(ur->id), ntohl(ur->creatorid)));
}
static void
-pfsync_print_del_c(const void *bp)
+pfsync_print_del_c(netdissect_options *ndo, const void *bp)
{
const struct pfsync_del_c *d = bp;
- printf("\n\tid: %016jx creatorid: %08x", (uintmax_t )be64toh(d->id),
- ntohl(d->creatorid));
+ ND_PRINT((ndo, "\n\tid: %016jx creatorid: %08x",
+ (uintmax_t)be64toh(d->id), ntohl(d->creatorid)));
}
static void
-pfsync_print_bus(const void *bp)
+pfsync_print_bus(netdissect_options *ndo, const void *bp)
{
const struct pfsync_bus *b = bp;
uint32_t endtime;
@@ -281,95 +295,95 @@ pfsync_print_bus(const void *bp)
break;
}
- printf("\n\tcreatorid: %08x age: %.2u:%.2u:%.2u status: %s",
- htonl(b->creatorid), endtime, min, sec, status);
+ ND_PRINT((ndo, "\n\tcreatorid: %08x age: %.2u:%.2u:%.2u status: %s",
+ htonl(b->creatorid), endtime, min, sec, status));
}
static void
-pfsync_print_tdb(const void *bp)
+pfsync_print_tdb(netdissect_options *ndo, const void *bp)
{
const struct pfsync_tdb *t = bp;
- printf("\n\tspi: 0x%08x rpl: %ju cur_bytes: %ju",
+ ND_PRINT((ndo, "\n\tspi: 0x%08x rpl: %ju cur_bytes: %ju",
ntohl(t->spi), (uintmax_t )be64toh(t->rpl),
- (uintmax_t )be64toh(t->cur_bytes));
+ (uintmax_t )be64toh(t->cur_bytes)));
}
static void
-print_host(struct pf_addr *addr, uint16_t port, sa_family_t af,
- const char *proto)
+print_host(netdissect_options *ndo, struct pf_addr *addr, uint16_t port,
+ sa_family_t af, const char *proto)
{
char buf[48];
if (inet_ntop(af, addr, buf, sizeof(buf)) == NULL)
- printf("?");
+ ND_PRINT((ndo, "?"));
else
- printf("%s", buf);
+ ND_PRINT((ndo, "%s", buf));
if (port)
- printf(".%hu", ntohs(port));
+ ND_PRINT((ndo, ".%hu", ntohs(port)));
}
static void
-print_seq(const struct pfsync_state_peer *p)
+print_seq(netdissect_options *ndo, const struct pfsync_state_peer *p)
{
if (p->seqdiff)
- printf("[%u + %u](+%u)", ntohl(p->seqlo),
- ntohl(p->seqhi) - ntohl(p->seqlo), ntohl(p->seqdiff));
+ ND_PRINT((ndo, "[%u + %u](+%u)", ntohl(p->seqlo),
+ ntohl(p->seqhi) - ntohl(p->seqlo), ntohl(p->seqdiff)));
else
- printf("[%u + %u]", ntohl(p->seqlo),
- ntohl(p->seqhi) - ntohl(p->seqlo));
+ ND_PRINT((ndo, "[%u + %u]", ntohl(p->seqlo),
+ ntohl(p->seqhi) - ntohl(p->seqlo)));
}
static void
-print_src_dst(const struct pfsync_state_peer *src,
+print_src_dst(netdissect_options *ndo, const struct pfsync_state_peer *src,
const struct pfsync_state_peer *dst, uint8_t proto)
{
if (proto == IPPROTO_TCP) {
if (src->state <= TCPS_TIME_WAIT &&
dst->state <= TCPS_TIME_WAIT)
- printf(" %s:%s", tcpstates[src->state],
- tcpstates[dst->state]);
+ ND_PRINT((ndo, " %s:%s", tcpstates[src->state],
+ tcpstates[dst->state]));
else if (src->state == PF_TCPS_PROXY_SRC ||
dst->state == PF_TCPS_PROXY_SRC)
- printf(" PROXY:SRC");
+ ND_PRINT((ndo, " PROXY:SRC"));
else if (src->state == PF_TCPS_PROXY_DST ||
dst->state == PF_TCPS_PROXY_DST)
- printf(" PROXY:DST");
+ ND_PRINT((ndo, " PROXY:DST"));
else
- printf(" <BAD STATE LEVELS %u:%u>",
- src->state, dst->state);
- if (vflag > 1) {
- printf("\n\t");
- print_seq(src);
+ ND_PRINT((ndo, " <BAD STATE LEVELS %u:%u>",
+ src->state, dst->state));
+ if (ndo->ndo_vflag > 1) {
+ ND_PRINT((ndo, "\n\t"));
+ print_seq(ndo, src);
if (src->wscale && dst->wscale)
- printf(" wscale %u",
- src->wscale & PF_WSCALE_MASK);
- printf(" ");
- print_seq(dst);
+ ND_PRINT((ndo, " wscale %u",
+ src->wscale & PF_WSCALE_MASK));
+ ND_PRINT((ndo, " "));
+ print_seq(ndo, dst);
if (src->wscale && dst->wscale)
- printf(" wscale %u",
- dst->wscale & PF_WSCALE_MASK);
+ ND_PRINT((ndo, " wscale %u",
+ dst->wscale & PF_WSCALE_MASK));
}
} else if (proto == IPPROTO_UDP && src->state < PFUDPS_NSTATES &&
dst->state < PFUDPS_NSTATES) {
const char *states[] = PFUDPS_NAMES;
- printf(" %s:%s", states[src->state], states[dst->state]);
+ ND_PRINT((ndo, " %s:%s", states[src->state], states[dst->state]));
} else if (proto != IPPROTO_ICMP && src->state < PFOTHERS_NSTATES &&
dst->state < PFOTHERS_NSTATES) {
/* XXX ICMP doesn't really have state levels */
const char *states[] = PFOTHERS_NAMES;
- printf(" %s:%s", states[src->state], states[dst->state]);
+ ND_PRINT((ndo, " %s:%s", states[src->state], states[dst->state]));
} else {
- printf(" %u:%u", src->state, dst->state);
+ ND_PRINT((ndo, " %u:%u", src->state, dst->state));
}
}
static void
-print_state(struct pfsync_state *s)
+print_state(netdissect_options *ndo, struct pfsync_state *s)
{
struct pfsync_state_peer *src, *dst;
struct pfsync_state_key *sk, *nk;
@@ -390,31 +404,31 @@ print_state(struct pfsync_state *s)
if (s->proto == IPPROTO_ICMP || s->proto == IPPROTO_ICMPV6)
sk->port[1] = nk->port[1];
}
- printf("\t%s ", s->ifname);
- printf("proto %u ", s->proto);
+ ND_PRINT((ndo, "\t%s ", s->ifname));
+ ND_PRINT((ndo, "proto %u ", s->proto));
- print_host(&nk->addr[1], nk->port[1], s->af, NULL);
+ print_host(ndo, &nk->addr[1], nk->port[1], s->af, NULL);
if (PF_ANEQ(&nk->addr[1], &sk->addr[1], s->af) ||
nk->port[1] != sk->port[1]) {
- printf(" (");
- print_host(&sk->addr[1], sk->port[1], s->af, NULL);
- printf(")");
+ ND_PRINT((ndo, " ("));
+ print_host(ndo, &sk->addr[1], sk->port[1], s->af, NULL);
+ ND_PRINT((ndo, ")"));
}
if (s->direction == PF_OUT)
- printf(" -> ");
+ ND_PRINT((ndo, " -> "));
else
- printf(" <- ");
- print_host(&nk->addr[0], nk->port[0], s->af, NULL);
+ ND_PRINT((ndo, " <- "));
+ print_host(ndo, &nk->addr[0], nk->port[0], s->af, NULL);
if (PF_ANEQ(&nk->addr[0], &sk->addr[0], s->af) ||
nk->port[0] != sk->port[0]) {
- printf(" (");
- print_host(&sk->addr[0], sk->port[0], s->af, NULL);
- printf(")");
+ ND_PRINT((ndo, " ("));
+ print_host(ndo, &sk->addr[0], sk->port[0], s->af, NULL);
+ ND_PRINT((ndo, ")"));
}
- print_src_dst(src, dst, s->proto);
+ print_src_dst(ndo, src, dst, s->proto);
- if (vflag > 1) {
+ if (ndo->ndo_vflag > 1) {
uint64_t packets[2];
uint64_t bytes[2];
uint32_t creation = ntohl(s->creation);
@@ -424,30 +438,33 @@ print_state(struct pfsync_state *s)
creation /= 60;
min = creation % 60;
creation /= 60;
- printf("\n\tage %.2u:%.2u:%.2u", creation, min, sec);
+ ND_PRINT((ndo, "\n\tage %.2u:%.2u:%.2u", creation, min, sec));
sec = expire % 60;
expire /= 60;
min = expire % 60;
expire /= 60;
- printf(", expires in %.2u:%.2u:%.2u", expire, min, sec);
+ ND_PRINT((ndo, ", expires in %.2u:%.2u:%.2u", expire, min, sec));
bcopy(s->packets[0], &packets[0], sizeof(uint64_t));
bcopy(s->packets[1], &packets[1], sizeof(uint64_t));
bcopy(s->bytes[0], &bytes[0], sizeof(uint64_t));
bcopy(s->bytes[1], &bytes[1], sizeof(uint64_t));
- printf(", %ju:%ju pkts, %ju:%ju bytes",
+ ND_PRINT((ndo, ", %ju:%ju pkts, %ju:%ju bytes",
be64toh(packets[0]), be64toh(packets[1]),
- be64toh(bytes[0]), be64toh(bytes[1]));
+ be64toh(bytes[0]), be64toh(bytes[1])));
if (s->anchor != ntohl(-1))
- printf(", anchor %u", ntohl(s->anchor));
+ ND_PRINT((ndo, ", anchor %u", ntohl(s->anchor)));
if (s->rule != ntohl(-1))
- printf(", rule %u", ntohl(s->rule));
+ ND_PRINT((ndo, ", rule %u", ntohl(s->rule)));
}
- if (vflag > 1) {
+ if (ndo->ndo_vflag > 1) {
uint64_t id;
bcopy(&s->id, &id, sizeof(uint64_t));
- printf("\n\tid: %016jx creatorid: %08x",
- (uintmax_t )be64toh(id), ntohl(s->creatorid));
+ ND_PRINT((ndo, "\n\tid: %016jx creatorid: %08x",
+ (uintmax_t )be64toh(id), ntohl(s->creatorid)));
}
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-pfsync-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-pgm.c b/freebsd/contrib/tcpdump/print-pgm.c
index 065cffc8..da11d2e2 100644
--- a/freebsd/contrib/tcpdump/print-pgm.c
+++ b/freebsd/contrib/tcpdump/print-pgm.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code
@@ -15,91 +18,84 @@
* Original code by Andy Heffernan (ahh@juniper.net)
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-pgm.c,v 1.5 2005-06-07 22:05:58 guy Exp $";
-#endif
+/* \summary: Pragmatic General Multicast (PGM) printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
#include "addrtoname.h"
+#include "addrtostr.h"
#include "ip.h"
-#ifdef INET6
#include "ip6.h"
-#endif
#include "ipproto.h"
+#include "af.h"
/*
* PGM header (RFC 3208)
*/
struct pgm_header {
- u_int16_t pgm_sport;
- u_int16_t pgm_dport;
- u_int8_t pgm_type;
- u_int8_t pgm_options;
- u_int16_t pgm_sum;
- u_int8_t pgm_gsid[6];
- u_int16_t pgm_length;
+ uint16_t pgm_sport;
+ uint16_t pgm_dport;
+ uint8_t pgm_type;
+ uint8_t pgm_options;
+ uint16_t pgm_sum;
+ uint8_t pgm_gsid[6];
+ uint16_t pgm_length;
};
struct pgm_spm {
- u_int32_t pgms_seq;
- u_int32_t pgms_trailseq;
- u_int32_t pgms_leadseq;
- u_int16_t pgms_nla_afi;
- u_int16_t pgms_reserved;
- /* ... u_int8_t pgms_nla[0]; */
+ uint32_t pgms_seq;
+ uint32_t pgms_trailseq;
+ uint32_t pgms_leadseq;
+ uint16_t pgms_nla_afi;
+ uint16_t pgms_reserved;
+ /* ... uint8_t pgms_nla[0]; */
/* ... options */
};
struct pgm_nak {
- u_int32_t pgmn_seq;
- u_int16_t pgmn_source_afi;
- u_int16_t pgmn_reserved;
- /* ... u_int8_t pgmn_source[0]; */
- /* ... u_int16_t pgmn_group_afi */
- /* ... u_int16_t pgmn_reserved2; */
- /* ... u_int8_t pgmn_group[0]; */
+ uint32_t pgmn_seq;
+ uint16_t pgmn_source_afi;
+ uint16_t pgmn_reserved;
+ /* ... uint8_t pgmn_source[0]; */
+ /* ... uint16_t pgmn_group_afi */
+ /* ... uint16_t pgmn_reserved2; */
+ /* ... uint8_t pgmn_group[0]; */
/* ... options */
};
struct pgm_ack {
- u_int32_t pgma_rx_max_seq;
- u_int32_t pgma_bitmap;
+ uint32_t pgma_rx_max_seq;
+ uint32_t pgma_bitmap;
/* ... options */
};
struct pgm_poll {
- u_int32_t pgmp_seq;
- u_int16_t pgmp_round;
- u_int16_t pgmp_reserved;
+ uint32_t pgmp_seq;
+ uint16_t pgmp_round;
+ uint16_t pgmp_reserved;
/* ... options */
};
struct pgm_polr {
- u_int32_t pgmp_seq;
- u_int16_t pgmp_round;
- u_int16_t pgmp_subtype;
- u_int16_t pgmp_nla_afi;
- u_int16_t pgmp_reserved;
- /* ... u_int8_t pgmp_nla[0]; */
+ uint32_t pgmp_seq;
+ uint16_t pgmp_round;
+ uint16_t pgmp_subtype;
+ uint16_t pgmp_nla_afi;
+ uint16_t pgmp_reserved;
+ /* ... uint8_t pgmp_nla[0]; */
/* ... options */
};
struct pgm_data {
- u_int32_t pgmd_seq;
- u_int32_t pgmd_trailseq;
+ uint32_t pgmd_seq;
+ uint32_t pgmd_trailseq;
/* ... options */
};
@@ -144,65 +140,45 @@ typedef enum _pgm_type {
#define PGM_OPT_PGMCC_DATA 0x12
#define PGM_OPT_PGMCC_FEEDBACK 0x13
-
+
#define PGM_OPT_MASK 0x7f
#define PGM_OPT_END 0x80 /* end of options marker */
#define PGM_MIN_OPT_LEN 4
-#ifndef AFI_IP
-#define AFI_IP 1
-#define AFI_IP6 2
-#endif
-
void
-pgm_print(register const u_char *bp, register u_int length,
- register const u_char *bp2)
+pgm_print(netdissect_options *ndo,
+ register const u_char *bp, register u_int length,
+ register const u_char *bp2)
{
register const struct pgm_header *pgm;
register const struct ip *ip;
register char ch;
- u_int16_t sport, dport;
- int addr_size;
- const void *nla;
- int nla_af;
-#ifdef INET6
+ uint16_t sport, dport;
+ u_int nla_afnum;
char nla_buf[INET6_ADDRSTRLEN];
register const struct ip6_hdr *ip6;
-#else
- char nla_buf[INET_ADDRSTRLEN];
-#endif
- u_int8_t opt_type, opt_len, flags1, flags2;
- u_int32_t seq, opts_len, len, offset;
+ uint8_t opt_type, opt_len;
+ uint32_t seq, opts_len, len, offset;
- pgm = (struct pgm_header *)bp;
- ip = (struct ip *)bp2;
-#ifdef INET6
+ pgm = (const struct pgm_header *)bp;
+ ip = (const struct ip *)bp2;
if (IP_V(ip) == 6)
- ip6 = (struct ip6_hdr *)bp2;
+ ip6 = (const struct ip6_hdr *)bp2;
else
ip6 = NULL;
-#else /* INET6 */
- if (IP_V(ip) == 6) {
- (void)printf("Can't handle IPv6");
- return;
- }
-#endif /* INET6 */
ch = '\0';
- if (!TTEST(pgm->pgm_dport)) {
-#ifdef INET6
+ if (!ND_TTEST(pgm->pgm_dport)) {
if (ip6) {
- (void)printf("%s > %s: [|pgm]",
- ip6addr_string(&ip6->ip6_src),
- ip6addr_string(&ip6->ip6_dst));
+ ND_PRINT((ndo, "%s > %s: [|pgm]",
+ ip6addr_string(ndo, &ip6->ip6_src),
+ ip6addr_string(ndo, &ip6->ip6_dst)));
return;
- } else
-#endif /* INET6 */
- {
- (void)printf("%s > %s: [|pgm]",
- ipaddr_string(&ip->ip_src),
- ipaddr_string(&ip->ip_dst));
+ } else {
+ ND_PRINT((ndo, "%s > %s: [|pgm]",
+ ipaddr_string(ndo, &ip->ip_src),
+ ipaddr_string(ndo, &ip->ip_dst)));
return;
}
}
@@ -210,282 +186,253 @@ pgm_print(register const u_char *bp, register u_int length,
sport = EXTRACT_16BITS(&pgm->pgm_sport);
dport = EXTRACT_16BITS(&pgm->pgm_dport);
-#ifdef INET6
if (ip6) {
if (ip6->ip6_nxt == IPPROTO_PGM) {
- (void)printf("%s.%s > %s.%s: ",
- ip6addr_string(&ip6->ip6_src),
- tcpport_string(sport),
- ip6addr_string(&ip6->ip6_dst),
- tcpport_string(dport));
+ ND_PRINT((ndo, "%s.%s > %s.%s: ",
+ ip6addr_string(ndo, &ip6->ip6_src),
+ tcpport_string(ndo, sport),
+ ip6addr_string(ndo, &ip6->ip6_dst),
+ tcpport_string(ndo, dport)));
} else {
- (void)printf("%s > %s: ",
- tcpport_string(sport), tcpport_string(dport));
+ ND_PRINT((ndo, "%s > %s: ",
+ tcpport_string(ndo, sport), tcpport_string(ndo, dport)));
}
- } else
-#endif /*INET6*/
- {
+ } else {
if (ip->ip_p == IPPROTO_PGM) {
- (void)printf("%s.%s > %s.%s: ",
- ipaddr_string(&ip->ip_src),
- tcpport_string(sport),
- ipaddr_string(&ip->ip_dst),
- tcpport_string(dport));
+ ND_PRINT((ndo, "%s.%s > %s.%s: ",
+ ipaddr_string(ndo, &ip->ip_src),
+ tcpport_string(ndo, sport),
+ ipaddr_string(ndo, &ip->ip_dst),
+ tcpport_string(ndo, dport)));
} else {
- (void)printf("%s > %s: ",
- tcpport_string(sport), tcpport_string(dport));
+ ND_PRINT((ndo, "%s > %s: ",
+ tcpport_string(ndo, sport), tcpport_string(ndo, dport)));
}
}
- TCHECK(*pgm);
+ ND_TCHECK(*pgm);
- (void)printf("PGM, length %u", pgm->pgm_length);
+ ND_PRINT((ndo, "PGM, length %u", EXTRACT_16BITS(&pgm->pgm_length)));
- if (!vflag)
+ if (!ndo->ndo_vflag)
return;
- if (length > pgm->pgm_length)
- length = pgm->pgm_length;
-
- (void)printf(" 0x%02x%02x%02x%02x%02x%02x ",
+ ND_PRINT((ndo, " 0x%02x%02x%02x%02x%02x%02x ",
pgm->pgm_gsid[0],
pgm->pgm_gsid[1],
pgm->pgm_gsid[2],
pgm->pgm_gsid[3],
pgm->pgm_gsid[4],
- pgm->pgm_gsid[5]);
+ pgm->pgm_gsid[5]));
switch (pgm->pgm_type) {
case PGM_SPM: {
- struct pgm_spm *spm;
+ const struct pgm_spm *spm;
- spm = (struct pgm_spm *)(pgm + 1);
- TCHECK(*spm);
+ spm = (const struct pgm_spm *)(pgm + 1);
+ ND_TCHECK(*spm);
+ bp = (const u_char *) (spm + 1);
switch (EXTRACT_16BITS(&spm->pgms_nla_afi)) {
- case AFI_IP:
- addr_size = sizeof(struct in_addr);
- nla_af = AF_INET;
+ case AFNUM_INET:
+ ND_TCHECK2(*bp, sizeof(struct in_addr));
+ addrtostr(bp, nla_buf, sizeof(nla_buf));
+ bp += sizeof(struct in_addr);
break;
-#ifdef INET6
- case AFI_IP6:
- addr_size = sizeof(struct in6_addr);
- nla_af = AF_INET6;
+ case AFNUM_INET6:
+ ND_TCHECK2(*bp, sizeof(struct in6_addr));
+ addrtostr6(bp, nla_buf, sizeof(nla_buf));
+ bp += sizeof(struct in6_addr);
break;
-#endif
default:
goto trunc;
break;
}
- bp = (u_char *) (spm + 1);
- TCHECK2(*bp, addr_size);
- nla = bp;
- bp += addr_size;
- inet_ntop(nla_af, nla, nla_buf, sizeof(nla_buf));
- (void)printf("SPM seq %u trail %u lead %u nla %s",
+ ND_PRINT((ndo, "SPM seq %u trail %u lead %u nla %s",
EXTRACT_32BITS(&spm->pgms_seq),
EXTRACT_32BITS(&spm->pgms_trailseq),
EXTRACT_32BITS(&spm->pgms_leadseq),
- nla_buf);
+ nla_buf));
break;
}
case PGM_POLL: {
- struct pgm_poll *poll;
-
- poll = (struct pgm_poll *)(pgm + 1);
- TCHECK(*poll);
- (void)printf("POLL seq %u round %u",
- EXTRACT_32BITS(&poll->pgmp_seq),
- EXTRACT_16BITS(&poll->pgmp_round));
- bp = (u_char *) (poll + 1);
+ const struct pgm_poll *poll_msg;
+
+ poll_msg = (const struct pgm_poll *)(pgm + 1);
+ ND_TCHECK(*poll_msg);
+ ND_PRINT((ndo, "POLL seq %u round %u",
+ EXTRACT_32BITS(&poll_msg->pgmp_seq),
+ EXTRACT_16BITS(&poll_msg->pgmp_round)));
+ bp = (const u_char *) (poll_msg + 1);
break;
}
case PGM_POLR: {
- struct pgm_polr *polr;
- u_int32_t ivl, rnd, mask;
+ const struct pgm_polr *polr;
+ uint32_t ivl, rnd, mask;
- polr = (struct pgm_polr *)(pgm + 1);
- TCHECK(*polr);
+ polr = (const struct pgm_polr *)(pgm + 1);
+ ND_TCHECK(*polr);
+ bp = (const u_char *) (polr + 1);
switch (EXTRACT_16BITS(&polr->pgmp_nla_afi)) {
- case AFI_IP:
- addr_size = sizeof(struct in_addr);
- nla_af = AF_INET;
+ case AFNUM_INET:
+ ND_TCHECK2(*bp, sizeof(struct in_addr));
+ addrtostr(bp, nla_buf, sizeof(nla_buf));
+ bp += sizeof(struct in_addr);
break;
-#ifdef INET6
- case AFI_IP6:
- addr_size = sizeof(struct in6_addr);
- nla_af = AF_INET6;
+ case AFNUM_INET6:
+ ND_TCHECK2(*bp, sizeof(struct in6_addr));
+ addrtostr6(bp, nla_buf, sizeof(nla_buf));
+ bp += sizeof(struct in6_addr);
break;
-#endif
default:
goto trunc;
break;
}
- bp = (u_char *) (polr + 1);
- TCHECK2(*bp, addr_size);
- nla = bp;
- bp += addr_size;
- inet_ntop(nla_af, nla, nla_buf, sizeof(nla_buf));
-
- TCHECK2(*bp, sizeof(u_int32_t));
+ ND_TCHECK2(*bp, sizeof(uint32_t));
ivl = EXTRACT_32BITS(bp);
- bp += sizeof(u_int32_t);
+ bp += sizeof(uint32_t);
- TCHECK2(*bp, sizeof(u_int32_t));
+ ND_TCHECK2(*bp, sizeof(uint32_t));
rnd = EXTRACT_32BITS(bp);
- bp += sizeof(u_int32_t);
+ bp += sizeof(uint32_t);
- TCHECK2(*bp, sizeof(u_int32_t));
+ ND_TCHECK2(*bp, sizeof(uint32_t));
mask = EXTRACT_32BITS(bp);
- bp += sizeof(u_int32_t);
+ bp += sizeof(uint32_t);
- (void)printf("POLR seq %u round %u nla %s ivl %u rnd 0x%08x "
+ ND_PRINT((ndo, "POLR seq %u round %u nla %s ivl %u rnd 0x%08x "
"mask 0x%08x", EXTRACT_32BITS(&polr->pgmp_seq),
- EXTRACT_16BITS(&polr->pgmp_round), nla_buf, ivl, rnd, mask);
+ EXTRACT_16BITS(&polr->pgmp_round), nla_buf, ivl, rnd, mask));
break;
}
case PGM_ODATA: {
- struct pgm_data *odata;
+ const struct pgm_data *odata;
- odata = (struct pgm_data *)(pgm + 1);
- TCHECK(*odata);
- (void)printf("ODATA trail %u seq %u",
+ odata = (const struct pgm_data *)(pgm + 1);
+ ND_TCHECK(*odata);
+ ND_PRINT((ndo, "ODATA trail %u seq %u",
EXTRACT_32BITS(&odata->pgmd_trailseq),
- EXTRACT_32BITS(&odata->pgmd_seq));
- bp = (u_char *) (odata + 1);
+ EXTRACT_32BITS(&odata->pgmd_seq)));
+ bp = (const u_char *) (odata + 1);
break;
}
case PGM_RDATA: {
- struct pgm_data *rdata;
+ const struct pgm_data *rdata;
- rdata = (struct pgm_data *)(pgm + 1);
- TCHECK(*rdata);
- (void)printf("RDATA trail %u seq %u",
+ rdata = (const struct pgm_data *)(pgm + 1);
+ ND_TCHECK(*rdata);
+ ND_PRINT((ndo, "RDATA trail %u seq %u",
EXTRACT_32BITS(&rdata->pgmd_trailseq),
- EXTRACT_32BITS(&rdata->pgmd_seq));
- bp = (u_char *) (rdata + 1);
+ EXTRACT_32BITS(&rdata->pgmd_seq)));
+ bp = (const u_char *) (rdata + 1);
break;
}
case PGM_NAK:
case PGM_NULLNAK:
case PGM_NCF: {
- struct pgm_nak *nak;
- const void *source, *group;
- int source_af, group_af;
-#ifdef INET6
+ const struct pgm_nak *nak;
char source_buf[INET6_ADDRSTRLEN], group_buf[INET6_ADDRSTRLEN];
-#else
- char source_buf[INET_ADDRSTRLEN], group_buf[INET_ADDRSTRLEN];
-#endif
- nak = (struct pgm_nak *)(pgm + 1);
- TCHECK(*nak);
+ nak = (const struct pgm_nak *)(pgm + 1);
+ ND_TCHECK(*nak);
+ bp = (const u_char *) (nak + 1);
/*
* Skip past the source, saving info along the way
* and stopping if we don't have enough.
*/
switch (EXTRACT_16BITS(&nak->pgmn_source_afi)) {
- case AFI_IP:
- addr_size = sizeof(struct in_addr);
- source_af = AF_INET;
+ case AFNUM_INET:
+ ND_TCHECK2(*bp, sizeof(struct in_addr));
+ addrtostr(bp, source_buf, sizeof(source_buf));
+ bp += sizeof(struct in_addr);
break;
-#ifdef INET6
- case AFI_IP6:
- addr_size = sizeof(struct in6_addr);
- source_af = AF_INET6;
+ case AFNUM_INET6:
+ ND_TCHECK2(*bp, sizeof(struct in6_addr));
+ addrtostr6(bp, source_buf, sizeof(source_buf));
+ bp += sizeof(struct in6_addr);
break;
-#endif
default:
goto trunc;
break;
}
- bp = (u_char *) (nak + 1);
- TCHECK2(*bp, addr_size);
- source = bp;
- bp += addr_size;
/*
* Skip past the group, saving info along the way
* and stopping if we don't have enough.
*/
+ bp += (2 * sizeof(uint16_t));
switch (EXTRACT_16BITS(bp)) {
- case AFI_IP:
- addr_size = sizeof(struct in_addr);
- group_af = AF_INET;
+ case AFNUM_INET:
+ ND_TCHECK2(*bp, sizeof(struct in_addr));
+ addrtostr(bp, group_buf, sizeof(group_buf));
+ bp += sizeof(struct in_addr);
break;
-#ifdef INET6
- case AFI_IP6:
- addr_size = sizeof(struct in6_addr);
- group_af = AF_INET6;
+ case AFNUM_INET6:
+ ND_TCHECK2(*bp, sizeof(struct in6_addr));
+ addrtostr6(bp, group_buf, sizeof(group_buf));
+ bp += sizeof(struct in6_addr);
break;
-#endif
default:
goto trunc;
break;
}
- bp += (2 * sizeof(u_int16_t));
- TCHECK2(*bp, addr_size);
- group = bp;
- bp += addr_size;
/*
* Options decoding can go here.
*/
- inet_ntop(source_af, source, source_buf, sizeof(source_buf));
- inet_ntop(group_af, group, group_buf, sizeof(group_buf));
switch (pgm->pgm_type) {
case PGM_NAK:
- (void)printf("NAK ");
+ ND_PRINT((ndo, "NAK "));
break;
case PGM_NULLNAK:
- (void)printf("NNAK ");
+ ND_PRINT((ndo, "NNAK "));
break;
case PGM_NCF:
- (void)printf("NCF ");
+ ND_PRINT((ndo, "NCF "));
break;
default:
break;
}
- (void)printf("(%s -> %s), seq %u",
- source_buf, group_buf, EXTRACT_32BITS(&nak->pgmn_seq));
+ ND_PRINT((ndo, "(%s -> %s), seq %u",
+ source_buf, group_buf, EXTRACT_32BITS(&nak->pgmn_seq)));
break;
}
case PGM_ACK: {
- struct pgm_ack *ack;
+ const struct pgm_ack *ack;
- ack = (struct pgm_ack *)(pgm + 1);
- TCHECK(*ack);
- (void)printf("ACK seq %u",
- EXTRACT_32BITS(&ack->pgma_rx_max_seq));
- bp = (u_char *) (ack + 1);
+ ack = (const struct pgm_ack *)(pgm + 1);
+ ND_TCHECK(*ack);
+ ND_PRINT((ndo, "ACK seq %u",
+ EXTRACT_32BITS(&ack->pgma_rx_max_seq)));
+ bp = (const u_char *) (ack + 1);
break;
}
case PGM_SPMR:
- (void)printf("SPMR");
+ ND_PRINT((ndo, "SPMR"));
break;
default:
- (void)printf("UNKNOWN type %0x02x", pgm->pgm_type);
+ ND_PRINT((ndo, "UNKNOWN type 0x%02x", pgm->pgm_type));
break;
}
- if (pgm->pgm_options & PGM_OPT_BIT_PRESENT) {
+ if (pgm->pgm_options & PGM_OPT_BIT_PRESENT) {
/*
* make sure there's enough for the first option header
*/
- if (!TTEST2(*bp, PGM_MIN_OPT_LEN)) {
- (void)printf("[|OPT]");
+ if (!ND_TTEST2(*bp, PGM_MIN_OPT_LEN)) {
+ ND_PRINT((ndo, "[|OPT]"));
return;
- }
+ }
/*
* That option header MUST be an OPT_LENGTH option
@@ -493,341 +440,331 @@ pgm_print(register const u_char *bp, register u_int length,
*/
opt_type = *bp++;
if ((opt_type & PGM_OPT_MASK) != PGM_OPT_LENGTH) {
- (void)printf("[First option bad, should be PGM_OPT_LENGTH, is %u]", opt_type & PGM_OPT_MASK);
+ ND_PRINT((ndo, "[First option bad, should be PGM_OPT_LENGTH, is %u]", opt_type & PGM_OPT_MASK));
return;
}
opt_len = *bp++;
if (opt_len != 4) {
- (void)printf("[Bad OPT_LENGTH option, length %u != 4]", opt_len);
+ ND_PRINT((ndo, "[Bad OPT_LENGTH option, length %u != 4]", opt_len));
return;
}
opts_len = EXTRACT_16BITS(bp);
if (opts_len < 4) {
- (void)printf("[Bad total option length %u < 4]", opts_len);
+ ND_PRINT((ndo, "[Bad total option length %u < 4]", opts_len));
return;
}
- bp += sizeof(u_int16_t);
- (void)printf(" OPTS LEN %d", opts_len);
+ bp += sizeof(uint16_t);
+ ND_PRINT((ndo, " OPTS LEN %d", opts_len));
opts_len -= 4;
while (opts_len) {
if (opts_len < PGM_MIN_OPT_LEN) {
- (void)printf("[Total option length leaves no room for final option]");
+ ND_PRINT((ndo, "[Total option length leaves no room for final option]"));
return;
}
opt_type = *bp++;
opt_len = *bp++;
if (opt_len < PGM_MIN_OPT_LEN) {
- (void)printf("[Bad option, length %u < %u]", opt_len,
- PGM_MIN_OPT_LEN);
+ ND_PRINT((ndo, "[Bad option, length %u < %u]", opt_len,
+ PGM_MIN_OPT_LEN));
break;
}
if (opts_len < opt_len) {
- (void)printf("[Total option length leaves no room for final option]");
+ ND_PRINT((ndo, "[Total option length leaves no room for final option]"));
return;
}
- if (!TTEST2(*bp, opt_len - 2)) {
- (void)printf(" [|OPT]");
+ if (!ND_TTEST2(*bp, opt_len - 2)) {
+ ND_PRINT((ndo, " [|OPT]"));
return;
- }
+ }
switch (opt_type & PGM_OPT_MASK) {
case PGM_OPT_LENGTH:
if (opt_len != 4) {
- (void)printf("[Bad OPT_LENGTH option, length %u != 4]", opt_len);
+ ND_PRINT((ndo, "[Bad OPT_LENGTH option, length %u != 4]", opt_len));
return;
}
- (void)printf(" OPTS LEN (extra?) %d", EXTRACT_16BITS(bp));
- bp += sizeof(u_int16_t);
+ ND_PRINT((ndo, " OPTS LEN (extra?) %d", EXTRACT_16BITS(bp)));
+ bp += sizeof(uint16_t);
opts_len -= 4;
break;
case PGM_OPT_FRAGMENT:
if (opt_len != 16) {
- (void)printf("[Bad OPT_FRAGMENT option, length %u != 16]", opt_len);
+ ND_PRINT((ndo, "[Bad OPT_FRAGMENT option, length %u != 16]", opt_len));
return;
}
- flags1 = *bp++;
- flags2 = *bp++;
+ bp += 2;
seq = EXTRACT_32BITS(bp);
- bp += sizeof(u_int32_t);
+ bp += sizeof(uint32_t);
offset = EXTRACT_32BITS(bp);
- bp += sizeof(u_int32_t);
+ bp += sizeof(uint32_t);
len = EXTRACT_32BITS(bp);
- bp += sizeof(u_int32_t);
- (void)printf(" FRAG seq %u off %u len %u", seq, offset, len);
+ bp += sizeof(uint32_t);
+ ND_PRINT((ndo, " FRAG seq %u off %u len %u", seq, offset, len));
opts_len -= 16;
break;
case PGM_OPT_NAK_LIST:
- flags1 = *bp++;
- flags2 = *bp++;
- opt_len -= sizeof(u_int32_t); /* option header */
- (void)printf(" NAK LIST");
+ bp += 2;
+ opt_len -= sizeof(uint32_t); /* option header */
+ ND_PRINT((ndo, " NAK LIST"));
while (opt_len) {
- if (opt_len < sizeof(u_int32_t)) {
- (void)printf("[Option length not a multiple of 4]");
+ if (opt_len < sizeof(uint32_t)) {
+ ND_PRINT((ndo, "[Option length not a multiple of 4]"));
return;
}
- TCHECK2(*bp, sizeof(u_int32_t));
- (void)printf(" %u", EXTRACT_32BITS(bp));
- bp += sizeof(u_int32_t);
- opt_len -= sizeof(u_int32_t);
- opts_len -= sizeof(u_int32_t);
+ ND_TCHECK2(*bp, sizeof(uint32_t));
+ ND_PRINT((ndo, " %u", EXTRACT_32BITS(bp)));
+ bp += sizeof(uint32_t);
+ opt_len -= sizeof(uint32_t);
+ opts_len -= sizeof(uint32_t);
}
break;
case PGM_OPT_JOIN:
if (opt_len != 8) {
- (void)printf("[Bad OPT_JOIN option, length %u != 8]", opt_len);
+ ND_PRINT((ndo, "[Bad OPT_JOIN option, length %u != 8]", opt_len));
return;
}
- flags1 = *bp++;
- flags2 = *bp++;
+ bp += 2;
seq = EXTRACT_32BITS(bp);
- bp += sizeof(u_int32_t);
- (void)printf(" JOIN %u", seq);
+ bp += sizeof(uint32_t);
+ ND_PRINT((ndo, " JOIN %u", seq));
opts_len -= 8;
break;
case PGM_OPT_NAK_BO_IVL:
if (opt_len != 12) {
- (void)printf("[Bad OPT_NAK_BO_IVL option, length %u != 12]", opt_len);
+ ND_PRINT((ndo, "[Bad OPT_NAK_BO_IVL option, length %u != 12]", opt_len));
return;
}
- flags1 = *bp++;
- flags2 = *bp++;
+ bp += 2;
offset = EXTRACT_32BITS(bp);
- bp += sizeof(u_int32_t);
+ bp += sizeof(uint32_t);
seq = EXTRACT_32BITS(bp);
- bp += sizeof(u_int32_t);
- (void)printf(" BACKOFF ivl %u ivlseq %u", offset, seq);
+ bp += sizeof(uint32_t);
+ ND_PRINT((ndo, " BACKOFF ivl %u ivlseq %u", offset, seq));
opts_len -= 12;
break;
case PGM_OPT_NAK_BO_RNG:
if (opt_len != 12) {
- (void)printf("[Bad OPT_NAK_BO_RNG option, length %u != 12]", opt_len);
+ ND_PRINT((ndo, "[Bad OPT_NAK_BO_RNG option, length %u != 12]", opt_len));
return;
}
- flags1 = *bp++;
- flags2 = *bp++;
+ bp += 2;
offset = EXTRACT_32BITS(bp);
- bp += sizeof(u_int32_t);
+ bp += sizeof(uint32_t);
seq = EXTRACT_32BITS(bp);
- bp += sizeof(u_int32_t);
- (void)printf(" BACKOFF max %u min %u", offset, seq);
+ bp += sizeof(uint32_t);
+ ND_PRINT((ndo, " BACKOFF max %u min %u", offset, seq));
opts_len -= 12;
break;
case PGM_OPT_REDIRECT:
- flags1 = *bp++;
- flags2 = *bp++;
- switch (EXTRACT_16BITS(bp)) {
- case AFI_IP:
- addr_size = sizeof(struct in_addr);
- nla_af = AF_INET;
+ bp += 2;
+ nla_afnum = EXTRACT_16BITS(bp);
+ bp += (2 * sizeof(uint16_t));
+ switch (nla_afnum) {
+ case AFNUM_INET:
+ if (opt_len != 4 + sizeof(struct in_addr)) {
+ ND_PRINT((ndo, "[Bad OPT_REDIRECT option, length %u != 4 + address size]", opt_len));
+ return;
+ }
+ ND_TCHECK2(*bp, sizeof(struct in_addr));
+ addrtostr(bp, nla_buf, sizeof(nla_buf));
+ bp += sizeof(struct in_addr);
+ opts_len -= 4 + sizeof(struct in_addr);
break;
-#ifdef INET6
- case AFI_IP6:
- addr_size = sizeof(struct in6_addr);
- nla_af = AF_INET6;
+ case AFNUM_INET6:
+ if (opt_len != 4 + sizeof(struct in6_addr)) {
+ ND_PRINT((ndo, "[Bad OPT_REDIRECT option, length %u != 4 + address size]", opt_len));
+ return;
+ }
+ ND_TCHECK2(*bp, sizeof(struct in6_addr));
+ addrtostr6(bp, nla_buf, sizeof(nla_buf));
+ bp += sizeof(struct in6_addr);
+ opts_len -= 4 + sizeof(struct in6_addr);
break;
-#endif
default:
goto trunc;
break;
}
- bp += (2 * sizeof(u_int16_t));
- if (opt_len != 4 + addr_size) {
- (void)printf("[Bad OPT_REDIRECT option, length %u != 4 + address size]", opt_len);
- return;
- }
- TCHECK2(*bp, addr_size);
- nla = bp;
- bp += addr_size;
- inet_ntop(nla_af, nla, nla_buf, sizeof(nla_buf));
- (void)printf(" REDIRECT %s", (char *)nla);
- opts_len -= 4 + addr_size;
+ ND_PRINT((ndo, " REDIRECT %s", nla_buf));
break;
case PGM_OPT_PARITY_PRM:
if (opt_len != 8) {
- (void)printf("[Bad OPT_PARITY_PRM option, length %u != 8]", opt_len);
+ ND_PRINT((ndo, "[Bad OPT_PARITY_PRM option, length %u != 8]", opt_len));
return;
}
- flags1 = *bp++;
- flags2 = *bp++;
+ bp += 2;
len = EXTRACT_32BITS(bp);
- bp += sizeof(u_int32_t);
- (void)printf(" PARITY MAXTGS %u", len);
+ bp += sizeof(uint32_t);
+ ND_PRINT((ndo, " PARITY MAXTGS %u", len));
opts_len -= 8;
break;
case PGM_OPT_PARITY_GRP:
if (opt_len != 8) {
- (void)printf("[Bad OPT_PARITY_GRP option, length %u != 8]", opt_len);
+ ND_PRINT((ndo, "[Bad OPT_PARITY_GRP option, length %u != 8]", opt_len));
return;
}
- flags1 = *bp++;
- flags2 = *bp++;
+ bp += 2;
seq = EXTRACT_32BITS(bp);
- bp += sizeof(u_int32_t);
- (void)printf(" PARITY GROUP %u", seq);
+ bp += sizeof(uint32_t);
+ ND_PRINT((ndo, " PARITY GROUP %u", seq));
opts_len -= 8;
break;
case PGM_OPT_CURR_TGSIZE:
if (opt_len != 8) {
- (void)printf("[Bad OPT_CURR_TGSIZE option, length %u != 8]", opt_len);
+ ND_PRINT((ndo, "[Bad OPT_CURR_TGSIZE option, length %u != 8]", opt_len));
return;
}
- flags1 = *bp++;
- flags2 = *bp++;
+ bp += 2;
len = EXTRACT_32BITS(bp);
- bp += sizeof(u_int32_t);
- (void)printf(" PARITY ATGS %u", len);
+ bp += sizeof(uint32_t);
+ ND_PRINT((ndo, " PARITY ATGS %u", len));
opts_len -= 8;
break;
case PGM_OPT_NBR_UNREACH:
if (opt_len != 4) {
- (void)printf("[Bad OPT_NBR_UNREACH option, length %u != 4]", opt_len);
+ ND_PRINT((ndo, "[Bad OPT_NBR_UNREACH option, length %u != 4]", opt_len));
return;
}
- flags1 = *bp++;
- flags2 = *bp++;
- (void)printf(" NBR_UNREACH");
+ bp += 2;
+ ND_PRINT((ndo, " NBR_UNREACH"));
opts_len -= 4;
break;
case PGM_OPT_PATH_NLA:
- (void)printf(" PATH_NLA [%d]", opt_len);
+ ND_PRINT((ndo, " PATH_NLA [%d]", opt_len));
bp += opt_len;
opts_len -= opt_len;
break;
case PGM_OPT_SYN:
if (opt_len != 4) {
- (void)printf("[Bad OPT_SYN option, length %u != 4]", opt_len);
+ ND_PRINT((ndo, "[Bad OPT_SYN option, length %u != 4]", opt_len));
return;
}
- flags1 = *bp++;
- flags2 = *bp++;
- (void)printf(" SYN");
+ bp += 2;
+ ND_PRINT((ndo, " SYN"));
opts_len -= 4;
break;
case PGM_OPT_FIN:
if (opt_len != 4) {
- (void)printf("[Bad OPT_FIN option, length %u != 4]", opt_len);
+ ND_PRINT((ndo, "[Bad OPT_FIN option, length %u != 4]", opt_len));
return;
}
- flags1 = *bp++;
- flags2 = *bp++;
- (void)printf(" FIN");
+ bp += 2;
+ ND_PRINT((ndo, " FIN"));
opts_len -= 4;
break;
case PGM_OPT_RST:
if (opt_len != 4) {
- (void)printf("[Bad OPT_RST option, length %u != 4]", opt_len);
+ ND_PRINT((ndo, "[Bad OPT_RST option, length %u != 4]", opt_len));
return;
}
- flags1 = *bp++;
- flags2 = *bp++;
- (void)printf(" RST");
+ bp += 2;
+ ND_PRINT((ndo, " RST"));
opts_len -= 4;
break;
case PGM_OPT_CR:
- (void)printf(" CR");
+ ND_PRINT((ndo, " CR"));
bp += opt_len;
opts_len -= opt_len;
break;
case PGM_OPT_CRQST:
if (opt_len != 4) {
- (void)printf("[Bad OPT_CRQST option, length %u != 4]", opt_len);
+ ND_PRINT((ndo, "[Bad OPT_CRQST option, length %u != 4]", opt_len));
return;
}
- flags1 = *bp++;
- flags2 = *bp++;
- (void)printf(" CRQST");
+ bp += 2;
+ ND_PRINT((ndo, " CRQST"));
opts_len -= 4;
break;
case PGM_OPT_PGMCC_DATA:
- flags1 = *bp++;
- flags2 = *bp++;
+ bp += 2;
offset = EXTRACT_32BITS(bp);
- bp += sizeof(u_int32_t);
- switch (EXTRACT_16BITS(bp)) {
- case AFI_IP:
- addr_size = sizeof(struct in_addr);
- nla_af = AF_INET;
+ bp += sizeof(uint32_t);
+ nla_afnum = EXTRACT_16BITS(bp);
+ bp += (2 * sizeof(uint16_t));
+ switch (nla_afnum) {
+ case AFNUM_INET:
+ if (opt_len != 12 + sizeof(struct in_addr)) {
+ ND_PRINT((ndo, "[Bad OPT_PGMCC_DATA option, length %u != 12 + address size]", opt_len));
+ return;
+ }
+ ND_TCHECK2(*bp, sizeof(struct in_addr));
+ addrtostr(bp, nla_buf, sizeof(nla_buf));
+ bp += sizeof(struct in_addr);
+ opts_len -= 12 + sizeof(struct in_addr);
break;
-#ifdef INET6
- case AFI_IP6:
- addr_size = sizeof(struct in6_addr);
- nla_af = AF_INET6;
+ case AFNUM_INET6:
+ if (opt_len != 12 + sizeof(struct in6_addr)) {
+ ND_PRINT((ndo, "[Bad OPT_PGMCC_DATA option, length %u != 12 + address size]", opt_len));
+ return;
+ }
+ ND_TCHECK2(*bp, sizeof(struct in6_addr));
+ addrtostr6(bp, nla_buf, sizeof(nla_buf));
+ bp += sizeof(struct in6_addr);
+ opts_len -= 12 + sizeof(struct in6_addr);
break;
-#endif
default:
goto trunc;
break;
}
- bp += (2 * sizeof(u_int16_t));
- if (opt_len != 12 + addr_size) {
- (void)printf("[Bad OPT_PGMCC_DATA option, length %u != 12 + address size]", opt_len);
- return;
- }
- TCHECK2(*bp, addr_size);
- nla = bp;
- bp += addr_size;
- inet_ntop(nla_af, nla, nla_buf, sizeof(nla_buf));
- (void)printf(" PGMCC DATA %u %s", offset, (char*)nla);
- opts_len -= 16;
+ ND_PRINT((ndo, " PGMCC DATA %u %s", offset, nla_buf));
break;
case PGM_OPT_PGMCC_FEEDBACK:
- flags1 = *bp++;
- flags2 = *bp++;
+ bp += 2;
offset = EXTRACT_32BITS(bp);
- bp += sizeof(u_int32_t);
- switch (EXTRACT_16BITS(bp)) {
- case AFI_IP:
- addr_size = sizeof(struct in_addr);
- nla_af = AF_INET;
+ bp += sizeof(uint32_t);
+ nla_afnum = EXTRACT_16BITS(bp);
+ bp += (2 * sizeof(uint16_t));
+ switch (nla_afnum) {
+ case AFNUM_INET:
+ if (opt_len != 12 + sizeof(struct in_addr)) {
+ ND_PRINT((ndo, "[Bad OPT_PGMCC_DATA option, length %u != 12 + address size]", opt_len));
+ return;
+ }
+ ND_TCHECK2(*bp, sizeof(struct in_addr));
+ addrtostr(bp, nla_buf, sizeof(nla_buf));
+ bp += sizeof(struct in_addr);
+ opts_len -= 12 + sizeof(struct in_addr);
break;
-#ifdef INET6
- case AFI_IP6:
- addr_size = sizeof(struct in6_addr);
- nla_af = AF_INET6;
+ case AFNUM_INET6:
+ if (opt_len != 12 + sizeof(struct in6_addr)) {
+ ND_PRINT((ndo, "[Bad OPT_PGMCC_DATA option, length %u != 12 + address size]", opt_len));
+ return;
+ }
+ ND_TCHECK2(*bp, sizeof(struct in6_addr));
+ addrtostr6(bp, nla_buf, sizeof(nla_buf));
+ bp += sizeof(struct in6_addr);
+ opts_len -= 12 + sizeof(struct in6_addr);
break;
-#endif
default:
goto trunc;
break;
}
- bp += (2 * sizeof(u_int16_t));
- if (opt_len != 12 + addr_size) {
- (void)printf("[Bad OPT_PGMCC_FEEDBACK option, length %u != 12 + address size]", opt_len);
- return;
- }
- TCHECK2(*bp, addr_size);
- nla = bp;
- bp += addr_size;
- inet_ntop(nla_af, nla, nla_buf, sizeof(nla_buf));
- (void)printf(" PGMCC FEEDBACK %u %s", offset, (char*)nla);
- opts_len -= 16;
+ ND_PRINT((ndo, " PGMCC FEEDBACK %u %s", offset, nla_buf));
break;
default:
- (void)printf(" OPT_%02X [%d] ", opt_type, opt_len);
+ ND_PRINT((ndo, " OPT_%02X [%d] ", opt_type, opt_len));
bp += opt_len;
opts_len -= opt_len;
break;
@@ -838,12 +775,18 @@ pgm_print(register const u_char *bp, register u_int length,
}
}
- (void)printf(" [%u]", EXTRACT_16BITS(&pgm->pgm_length));
+ ND_PRINT((ndo, " [%u]", length));
+ if (ndo->ndo_packettype == PT_PGM_ZMTP1 &&
+ (pgm->pgm_type == PGM_ODATA || pgm->pgm_type == PGM_RDATA))
+ zmtp1_print_datagram(ndo, bp, EXTRACT_16BITS(&pgm->pgm_length));
return;
trunc:
- fputs("[|pgm]", stdout);
+ ND_PRINT((ndo, "[|pgm]"));
if (ch != '\0')
- putchar('>');
+ ND_PRINT((ndo, ">"));
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-pgm-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-pim.c b/freebsd/contrib/tcpdump/print-pim.c
index 32a549c6..ff5191fd 100644
--- a/freebsd/contrib/tcpdump/print-pim.c
+++ b/freebsd/contrib/tcpdump/print-pim.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1995, 1996
* The Regents of the University of California. All rights reserved.
@@ -19,29 +22,44 @@
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * $FreeBSD$
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-pim.c,v 1.49 2006-02-13 01:31:35 hannes Exp $ (LBL)";
-#endif
+/* \summary: Protocol Independent Multicast (PIM) printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
-
-#include <stdio.h>
-#include <stdlib.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "extract.h"
#include "ip.h"
+#include "ip6.h"
+#include "ipproto.h"
+
+#define PIMV1_TYPE_QUERY 0
+#define PIMV1_TYPE_REGISTER 1
+#define PIMV1_TYPE_REGISTER_STOP 2
+#define PIMV1_TYPE_JOIN_PRUNE 3
+#define PIMV1_TYPE_RP_REACHABILITY 4
+#define PIMV1_TYPE_ASSERT 5
+#define PIMV1_TYPE_GRAFT 6
+#define PIMV1_TYPE_GRAFT_ACK 7
+
+static const struct tok pimv1_type_str[] = {
+ { PIMV1_TYPE_QUERY, "Query" },
+ { PIMV1_TYPE_REGISTER, "Register" },
+ { PIMV1_TYPE_REGISTER_STOP, "Register-Stop" },
+ { PIMV1_TYPE_JOIN_PRUNE, "Join/Prune" },
+ { PIMV1_TYPE_RP_REACHABILITY, "RP-reachable" },
+ { PIMV1_TYPE_ASSERT, "Assert" },
+ { PIMV1_TYPE_GRAFT, "Graft" },
+ { PIMV1_TYPE_GRAFT_ACK, "Graft-ACK" },
+ { 0, NULL }
+};
#define PIMV2_TYPE_HELLO 0
#define PIMV2_TYPE_REGISTER 1
@@ -53,8 +71,10 @@ static const char rcsid[] _U_ =
#define PIMV2_TYPE_GRAFT_ACK 7
#define PIMV2_TYPE_CANDIDATE_RP 8
#define PIMV2_TYPE_PRUNE_REFRESH 9
+#define PIMV2_TYPE_DF_ELECTION 10
+#define PIMV2_TYPE_ECMP_REDIRECT 11
-static struct tok pimv2_type_values[] = {
+static const struct tok pimv2_type_values[] = {
{ PIMV2_TYPE_HELLO, "Hello" },
{ PIMV2_TYPE_REGISTER, "Register" },
{ PIMV2_TYPE_REGISTER_STOP, "Register Stop" },
@@ -65,6 +85,8 @@ static struct tok pimv2_type_values[] = {
{ PIMV2_TYPE_GRAFT_ACK, "Graft Acknowledgement" },
{ PIMV2_TYPE_CANDIDATE_RP, "Candidate RP Advertisement" },
{ PIMV2_TYPE_PRUNE_REFRESH, "Prune Refresh" },
+ { PIMV2_TYPE_DF_ELECTION, "DF Election" },
+ { PIMV2_TYPE_ECMP_REDIRECT, "ECMP Redirect" },
{ 0, NULL}
};
@@ -78,7 +100,7 @@ static struct tok pimv2_type_values[] = {
#define PIMV2_HELLO_OPTION_ADDRESS_LIST 24
#define PIMV2_HELLO_OPTION_ADDRESS_LIST_OLD 65001
-static struct tok pimv2_hello_option_values[] = {
+static const struct tok pimv2_hello_option_values[] = {
{ PIMV2_HELLO_OPTION_HOLDTIME, "Hold Time" },
{ PIMV2_HELLO_OPTION_LANPRUNEDELAY, "LAN Prune Delay" },
{ PIMV2_HELLO_OPTION_DR_PRIORITY_OLD, "DR Priority (Old)" },
@@ -95,11 +117,11 @@ static struct tok pimv2_hello_option_values[] = {
#define PIMV2_REGISTER_FLAG_BORDER 0x80000000
#define PIMV2_REGISTER_FLAG_NULL 0x40000000
-static struct tok pimv2_register_flag_values[] = {
+static const struct tok pimv2_register_flag_values[] = {
{ PIMV2_REGISTER_FLAG_BORDER, "Border" },
{ PIMV2_REGISTER_FLAG_NULL, "Null" },
{ 0, NULL}
-};
+};
/*
* XXX: We consider a case where IPv6 is not ready yet for portability,
@@ -107,7 +129,7 @@ static struct tok pimv2_register_flag_values[] = {
*/
struct pim {
- u_int8_t pim_typever;
+ uint8_t pim_typever;
/* upper 4bit: PIM version number; 2 for PIMv2 */
/* lower 4bit: the PIM message type, currently they are:
* Hello, Register, Register-Stop, Join/Prune,
@@ -120,54 +142,53 @@ struct pim {
u_short pim_cksum; /* IP style check sum */
};
-static void pimv2_print(register const u_char *bp, register u_int len, u_int cksum);
+static void pimv2_print(netdissect_options *, register const u_char *bp, register u_int len, const u_char *);
static void
-pimv1_join_prune_print(register const u_char *bp, register u_int len)
+pimv1_join_prune_print(netdissect_options *ndo,
+ register const u_char *bp, register u_int len)
{
- int maddrlen, addrlen, ngroups, njoin, nprune;
+ int ngroups, njoin, nprune;
int njp;
/* If it's a single group and a single source, use 1-line output. */
- if (TTEST2(bp[0], 30) && bp[11] == 1 &&
+ if (ND_TTEST2(bp[0], 30) && bp[11] == 1 &&
((njoin = EXTRACT_16BITS(&bp[20])) + EXTRACT_16BITS(&bp[22])) == 1) {
int hold;
- (void)printf(" RPF %s ", ipaddr_string(bp));
+ ND_PRINT((ndo, " RPF %s ", ipaddr_string(ndo, bp)));
hold = EXTRACT_16BITS(&bp[6]);
if (hold != 180) {
- (void)printf("Hold ");
- relts_print(hold);
+ ND_PRINT((ndo, "Hold "));
+ unsigned_relts_print(ndo, hold);
}
- (void)printf("%s (%s/%d, %s", njoin ? "Join" : "Prune",
- ipaddr_string(&bp[26]), bp[25] & 0x3f,
- ipaddr_string(&bp[12]));
+ ND_PRINT((ndo, "%s (%s/%d, %s", njoin ? "Join" : "Prune",
+ ipaddr_string(ndo, &bp[26]), bp[25] & 0x3f,
+ ipaddr_string(ndo, &bp[12])));
if (EXTRACT_32BITS(&bp[16]) != 0xffffffff)
- (void)printf("/%s", ipaddr_string(&bp[16]));
- (void)printf(") %s%s %s",
+ ND_PRINT((ndo, "/%s", ipaddr_string(ndo, &bp[16])));
+ ND_PRINT((ndo, ") %s%s %s",
(bp[24] & 0x01) ? "Sparse" : "Dense",
(bp[25] & 0x80) ? " WC" : "",
- (bp[25] & 0x40) ? "RP" : "SPT");
+ (bp[25] & 0x40) ? "RP" : "SPT"));
return;
}
- TCHECK2(bp[0], sizeof(struct in_addr));
- if (vflag > 1)
- (void)printf("\n");
- (void)printf(" Upstream Nbr: %s", ipaddr_string(bp));
- TCHECK2(bp[6], 2);
- if (vflag > 1)
- (void)printf("\n");
- (void)printf(" Hold time: ");
- relts_print(EXTRACT_16BITS(&bp[6]));
- if (vflag < 2)
+ ND_TCHECK2(bp[0], sizeof(struct in_addr));
+ if (ndo->ndo_vflag > 1)
+ ND_PRINT((ndo, "\n"));
+ ND_PRINT((ndo, " Upstream Nbr: %s", ipaddr_string(ndo, bp)));
+ ND_TCHECK2(bp[6], 2);
+ if (ndo->ndo_vflag > 1)
+ ND_PRINT((ndo, "\n"));
+ ND_PRINT((ndo, " Hold time: "));
+ unsigned_relts_print(ndo, EXTRACT_16BITS(&bp[6]));
+ if (ndo->ndo_vflag < 2)
return;
bp += 8;
len -= 8;
- TCHECK2(bp[0], 4);
- maddrlen = bp[1];
- addrlen = bp[2];
+ ND_TCHECK2(bp[0], 4);
ngroups = bp[3];
bp += 4;
len -= 4;
@@ -176,15 +197,15 @@ pimv1_join_prune_print(register const u_char *bp, register u_int len)
* XXX - does the address have length "addrlen" and the
* mask length "maddrlen"?
*/
- TCHECK2(bp[0], sizeof(struct in_addr));
- (void)printf("\n\tGroup: %s", ipaddr_string(bp));
- TCHECK2(bp[4], sizeof(struct in_addr));
+ ND_TCHECK2(bp[0], sizeof(struct in_addr));
+ ND_PRINT((ndo, "\n\tGroup: %s", ipaddr_string(ndo, bp)));
+ ND_TCHECK2(bp[4], sizeof(struct in_addr));
if (EXTRACT_32BITS(&bp[4]) != 0xffffffff)
- (void)printf("/%s", ipaddr_string(&bp[4]));
- TCHECK2(bp[8], 4);
+ ND_PRINT((ndo, "/%s", ipaddr_string(ndo, &bp[4])));
+ ND_TCHECK2(bp[8], 4);
njoin = EXTRACT_16BITS(&bp[8]);
nprune = EXTRACT_16BITS(&bp[10]);
- (void)printf(" joined: %d pruned: %d", njoin, nprune);
+ ND_PRINT((ndo, " joined: %d pruned: %d", njoin, nprune));
bp += 12;
len -= 12;
for (njp = 0; njp < (njoin + nprune); njp++) {
@@ -194,127 +215,108 @@ pimv1_join_prune_print(register const u_char *bp, register u_int len)
type = "Join ";
else
type = "Prune";
- TCHECK2(bp[0], 6);
- (void)printf("\n\t%s %s%s%s%s/%d", type,
+ ND_TCHECK2(bp[0], 6);
+ ND_PRINT((ndo, "\n\t%s %s%s%s%s/%d", type,
(bp[0] & 0x01) ? "Sparse " : "Dense ",
(bp[1] & 0x80) ? "WC " : "",
(bp[1] & 0x40) ? "RP " : "SPT ",
- ipaddr_string(&bp[2]), bp[1] & 0x3f);
+ ipaddr_string(ndo, &bp[2]), bp[1] & 0x3f));
bp += 6;
len -= 6;
}
}
return;
trunc:
- (void)printf("[|pim]");
+ ND_PRINT((ndo, "[|pim]"));
return;
}
void
-pimv1_print(register const u_char *bp, register u_int len)
+pimv1_print(netdissect_options *ndo,
+ register const u_char *bp, register u_int len)
{
register const u_char *ep;
register u_char type;
- ep = (const u_char *)snapend;
+ ep = (const u_char *)ndo->ndo_snapend;
if (bp >= ep)
return;
- TCHECK(bp[1]);
+ ND_TCHECK(bp[1]);
type = bp[1];
+ ND_PRINT((ndo, " %s", tok2str(pimv1_type_str, "[type %u]", type)));
switch (type) {
- case 0:
- (void)printf(" Query");
- if (TTEST(bp[8])) {
+ case PIMV1_TYPE_QUERY:
+ if (ND_TTEST(bp[8])) {
switch (bp[8] >> 4) {
case 0:
- (void)printf(" Dense-mode");
+ ND_PRINT((ndo, " Dense-mode"));
break;
case 1:
- (void)printf(" Sparse-mode");
+ ND_PRINT((ndo, " Sparse-mode"));
break;
case 2:
- (void)printf(" Sparse-Dense-mode");
+ ND_PRINT((ndo, " Sparse-Dense-mode"));
break;
default:
- (void)printf(" mode-%d", bp[8] >> 4);
+ ND_PRINT((ndo, " mode-%d", bp[8] >> 4));
break;
}
}
- if (vflag) {
- TCHECK2(bp[10],2);
- (void)printf(" (Hold-time ");
- relts_print(EXTRACT_16BITS(&bp[10]));
- (void)printf(")");
+ if (ndo->ndo_vflag) {
+ ND_TCHECK2(bp[10],2);
+ ND_PRINT((ndo, " (Hold-time "));
+ unsigned_relts_print(ndo, EXTRACT_16BITS(&bp[10]));
+ ND_PRINT((ndo, ")"));
}
break;
- case 1:
- (void)printf(" Register");
- TCHECK2(bp[8], 20); /* ip header */
- (void)printf(" for %s > %s", ipaddr_string(&bp[20]),
- ipaddr_string(&bp[24]));
+ case PIMV1_TYPE_REGISTER:
+ ND_TCHECK2(bp[8], 20); /* ip header */
+ ND_PRINT((ndo, " for %s > %s", ipaddr_string(ndo, &bp[20]),
+ ipaddr_string(ndo, &bp[24])));
break;
- case 2:
- (void)printf(" Register-Stop");
- TCHECK2(bp[12], sizeof(struct in_addr));
- (void)printf(" for %s > %s", ipaddr_string(&bp[8]),
- ipaddr_string(&bp[12]));
+ case PIMV1_TYPE_REGISTER_STOP:
+ ND_TCHECK2(bp[12], sizeof(struct in_addr));
+ ND_PRINT((ndo, " for %s > %s", ipaddr_string(ndo, &bp[8]),
+ ipaddr_string(ndo, &bp[12])));
break;
- case 3:
- (void)printf(" Join/Prune");
- if (vflag)
- pimv1_join_prune_print(&bp[8], len - 8);
- break;
- case 4:
- (void)printf(" RP-reachable");
- if (vflag) {
- TCHECK2(bp[22], 2);
- (void)printf(" group %s",
- ipaddr_string(&bp[8]));
+ case PIMV1_TYPE_RP_REACHABILITY:
+ if (ndo->ndo_vflag) {
+ ND_TCHECK2(bp[22], 2);
+ ND_PRINT((ndo, " group %s", ipaddr_string(ndo, &bp[8])));
if (EXTRACT_32BITS(&bp[12]) != 0xffffffff)
- (void)printf("/%s", ipaddr_string(&bp[12]));
- (void)printf(" RP %s hold ", ipaddr_string(&bp[16]));
- relts_print(EXTRACT_16BITS(&bp[22]));
+ ND_PRINT((ndo, "/%s", ipaddr_string(ndo, &bp[12])));
+ ND_PRINT((ndo, " RP %s hold ", ipaddr_string(ndo, &bp[16])));
+ unsigned_relts_print(ndo, EXTRACT_16BITS(&bp[22]));
}
break;
- case 5:
- (void)printf(" Assert");
- TCHECK2(bp[16], sizeof(struct in_addr));
- (void)printf(" for %s > %s", ipaddr_string(&bp[16]),
- ipaddr_string(&bp[8]));
+ case PIMV1_TYPE_ASSERT:
+ ND_TCHECK2(bp[16], sizeof(struct in_addr));
+ ND_PRINT((ndo, " for %s > %s", ipaddr_string(ndo, &bp[16]),
+ ipaddr_string(ndo, &bp[8])));
if (EXTRACT_32BITS(&bp[12]) != 0xffffffff)
- (void)printf("/%s", ipaddr_string(&bp[12]));
- TCHECK2(bp[24], 4);
- (void)printf(" %s pref %d metric %d",
+ ND_PRINT((ndo, "/%s", ipaddr_string(ndo, &bp[12])));
+ ND_TCHECK2(bp[24], 4);
+ ND_PRINT((ndo, " %s pref %d metric %d",
(bp[20] & 0x80) ? "RP-tree" : "SPT",
EXTRACT_32BITS(&bp[20]) & 0x7fffffff,
- EXTRACT_32BITS(&bp[24]));
- break;
- case 6:
- (void)printf(" Graft");
- if (vflag)
- pimv1_join_prune_print(&bp[8], len - 8);
- break;
- case 7:
- (void)printf(" Graft-ACK");
- if (vflag)
- pimv1_join_prune_print(&bp[8], len - 8);
+ EXTRACT_32BITS(&bp[24])));
break;
- case 8:
- (void)printf(" Mode");
- break;
- default:
- (void)printf(" [type %d]", type);
+ case PIMV1_TYPE_JOIN_PRUNE:
+ case PIMV1_TYPE_GRAFT:
+ case PIMV1_TYPE_GRAFT_ACK:
+ if (ndo->ndo_vflag)
+ pimv1_join_prune_print(ndo, &bp[8], len - 8);
break;
}
if ((bp[4] >> 4) != 1)
- (void)printf(" [v%d]", bp[4] >> 4);
+ ND_PRINT((ndo, " [v%d]", bp[4] >> 4));
return;
trunc:
- (void)printf("[|pim]");
+ ND_PRINT((ndo, "[|pim]"));
return;
}
@@ -325,37 +327,38 @@ trunc:
* This implements version 1+, dated Sept 9, 1998.
*/
void
-cisco_autorp_print(register const u_char *bp, register u_int len)
+cisco_autorp_print(netdissect_options *ndo,
+ register const u_char *bp, register u_int len)
{
int type;
int numrps;
int hold;
- TCHECK(bp[0]);
- (void)printf(" auto-rp ");
+ ND_TCHECK(bp[0]);
+ ND_PRINT((ndo, " auto-rp "));
type = bp[0];
switch (type) {
case 0x11:
- (void)printf("candidate-advert");
+ ND_PRINT((ndo, "candidate-advert"));
break;
case 0x12:
- (void)printf("mapping");
+ ND_PRINT((ndo, "mapping"));
break;
default:
- (void)printf("type-0x%02x", type);
+ ND_PRINT((ndo, "type-0x%02x", type));
break;
}
- TCHECK(bp[1]);
+ ND_TCHECK(bp[1]);
numrps = bp[1];
- TCHECK2(bp[2], 2);
- (void)printf(" Hold ");
+ ND_TCHECK2(bp[2], 2);
+ ND_PRINT((ndo, " Hold "));
hold = EXTRACT_16BITS(&bp[2]);
if (hold)
- relts_print(EXTRACT_16BITS(&bp[2]));
+ unsigned_relts_print(ndo, EXTRACT_16BITS(&bp[2]));
else
- printf("FOREVER");
+ ND_PRINT((ndo, "FOREVER"));
/* Next 4 bytes are reserved. */
@@ -378,34 +381,34 @@ cisco_autorp_print(register const u_char *bp, register u_int len)
int nentries;
char s;
- TCHECK2(bp[0], 4);
- (void)printf(" RP %s", ipaddr_string(bp));
- TCHECK(bp[4]);
+ ND_TCHECK2(bp[0], 4);
+ ND_PRINT((ndo, " RP %s", ipaddr_string(ndo, bp)));
+ ND_TCHECK(bp[4]);
switch (bp[4] & 0x3) {
- case 0: printf(" PIMv?");
+ case 0: ND_PRINT((ndo, " PIMv?"));
break;
- case 1: printf(" PIMv1");
+ case 1: ND_PRINT((ndo, " PIMv1"));
break;
- case 2: printf(" PIMv2");
+ case 2: ND_PRINT((ndo, " PIMv2"));
break;
- case 3: printf(" PIMv1+2");
+ case 3: ND_PRINT((ndo, " PIMv1+2"));
break;
}
if (bp[4] & 0xfc)
- (void)printf(" [rsvd=0x%02x]", bp[4] & 0xfc);
- TCHECK(bp[5]);
+ ND_PRINT((ndo, " [rsvd=0x%02x]", bp[4] & 0xfc));
+ ND_TCHECK(bp[5]);
nentries = bp[5];
bp += 6; len -= 6;
s = ' ';
for (; nentries; nentries--) {
- TCHECK2(bp[0], 6);
- (void)printf("%c%s%s/%d", s, bp[0] & 1 ? "!" : "",
- ipaddr_string(&bp[2]), bp[1]);
+ ND_TCHECK2(bp[0], 6);
+ ND_PRINT((ndo, "%c%s%s/%d", s, bp[0] & 1 ? "!" : "",
+ ipaddr_string(ndo, &bp[2]), bp[1]));
if (bp[0] & 0x02) {
- (void)printf(" bidir");
+ ND_PRINT((ndo, " bidir"));
}
if (bp[0] & 0xfc) {
- (void)printf("[rsvd=0x%02x]", bp[0] & 0xfc);
+ ND_PRINT((ndo, "[rsvd=0x%02x]", bp[0] & 0xfc));
}
s = ',';
bp += 6; len -= 6;
@@ -414,43 +417,44 @@ cisco_autorp_print(register const u_char *bp, register u_int len)
return;
trunc:
- (void)printf("[|autorp]");
+ ND_PRINT((ndo, "[|autorp]"));
return;
}
void
-pim_print(register const u_char *bp, register u_int len, u_int cksum)
+pim_print(netdissect_options *ndo,
+ register const u_char *bp, register u_int len, const u_char *bp2)
{
register const u_char *ep;
- register struct pim *pim = (struct pim *)bp;
+ register const struct pim *pim = (const struct pim *)bp;
- ep = (const u_char *)snapend;
+ ep = (const u_char *)ndo->ndo_snapend;
if (bp >= ep)
return;
#ifdef notyet /* currently we see only version and type */
- TCHECK(pim->pim_rsv);
+ ND_TCHECK(pim->pim_rsv);
#endif
switch (PIM_VER(pim->pim_typever)) {
case 2:
- if (!vflag) {
- printf("PIMv%u, %s, length %u",
- PIM_VER(pim->pim_typever),
- tok2str(pimv2_type_values,"Unknown Type",PIM_TYPE(pim->pim_typever)),
- len);
- return;
- } else {
- printf("PIMv%u, length %u\n\t%s",
- PIM_VER(pim->pim_typever),
- len,
- tok2str(pimv2_type_values,"Unknown Type",PIM_TYPE(pim->pim_typever)));
- pimv2_print(bp, len, cksum);
- }
- break;
+ if (!ndo->ndo_vflag) {
+ ND_PRINT((ndo, "PIMv%u, %s, length %u",
+ PIM_VER(pim->pim_typever),
+ tok2str(pimv2_type_values,"Unknown Type",PIM_TYPE(pim->pim_typever)),
+ len));
+ return;
+ } else {
+ ND_PRINT((ndo, "PIMv%u, length %u\n\t%s",
+ PIM_VER(pim->pim_typever),
+ len,
+ tok2str(pimv2_type_values,"Unknown Type",PIM_TYPE(pim->pim_typever))));
+ pimv2_print(ndo, bp, len, bp2);
+ }
+ break;
default:
- printf("PIMv%u, length %u",
- PIM_VER(pim->pim_typever),
- len);
+ ND_PRINT((ndo, "PIMv%u, length %u",
+ PIM_VER(pim->pim_typever),
+ len));
break;
}
return;
@@ -523,26 +527,25 @@ enum pimv2_addrtype {
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
static int
-pimv2_addr_print(const u_char *bp, enum pimv2_addrtype at, int silent)
+pimv2_addr_print(netdissect_options *ndo,
+ const u_char *bp, enum pimv2_addrtype at, int silent)
{
int af;
int len, hdrlen;
- TCHECK(bp[0]);
+ ND_TCHECK(bp[0]);
if (pimv2_addr_len == 0) {
- TCHECK(bp[1]);
+ ND_TCHECK(bp[1]);
switch (bp[0]) {
case 1:
af = AF_INET;
len = sizeof(struct in_addr);
break;
-#ifdef INET6
case 2:
af = AF_INET6;
len = sizeof(struct in6_addr);
break;
-#endif
default:
return -1;
}
@@ -554,11 +557,9 @@ pimv2_addr_print(const u_char *bp, enum pimv2_addrtype at, int silent)
case sizeof(struct in_addr):
af = AF_INET;
break;
-#ifdef INET6
case sizeof(struct in6_addr):
af = AF_INET6;
break;
-#endif
default:
return -1;
break;
@@ -570,49 +571,45 @@ pimv2_addr_print(const u_char *bp, enum pimv2_addrtype at, int silent)
bp += hdrlen;
switch (at) {
case pimv2_unicast:
- TCHECK2(bp[0], len);
+ ND_TCHECK2(bp[0], len);
if (af == AF_INET) {
if (!silent)
- (void)printf("%s", ipaddr_string(bp));
+ ND_PRINT((ndo, "%s", ipaddr_string(ndo, bp)));
}
-#ifdef INET6
else if (af == AF_INET6) {
if (!silent)
- (void)printf("%s", ip6addr_string(bp));
+ ND_PRINT((ndo, "%s", ip6addr_string(ndo, bp)));
}
-#endif
return hdrlen + len;
case pimv2_group:
case pimv2_source:
- TCHECK2(bp[0], len + 2);
+ ND_TCHECK2(bp[0], len + 2);
if (af == AF_INET) {
if (!silent) {
- (void)printf("%s", ipaddr_string(bp + 2));
+ ND_PRINT((ndo, "%s", ipaddr_string(ndo, bp + 2)));
if (bp[1] != 32)
- (void)printf("/%u", bp[1]);
+ ND_PRINT((ndo, "/%u", bp[1]));
}
}
-#ifdef INET6
else if (af == AF_INET6) {
if (!silent) {
- (void)printf("%s", ip6addr_string(bp + 2));
+ ND_PRINT((ndo, "%s", ip6addr_string(ndo, bp + 2)));
if (bp[1] != 128)
- (void)printf("/%u", bp[1]);
+ ND_PRINT((ndo, "/%u", bp[1]));
}
}
-#endif
if (bp[0] && !silent) {
if (at == pimv2_group) {
- (void)printf("(0x%02x)", bp[0]);
+ ND_PRINT((ndo, "(0x%02x)", bp[0]));
} else {
- (void)printf("(%s%s%s",
+ ND_PRINT((ndo, "(%s%s%s",
bp[0] & 0x04 ? "S" : "",
bp[0] & 0x02 ? "W" : "",
- bp[0] & 0x01 ? "R" : "");
+ bp[0] & 0x01 ? "R" : ""));
if (bp[0] & 0xf8) {
- (void) printf("+0x%02x", bp[0] & 0xf8);
+ ND_PRINT((ndo, "+0x%02x", bp[0] & 0xf8));
}
- (void)printf(")");
+ ND_PRINT((ndo, ")"));
}
}
return hdrlen + 2 + len;
@@ -623,111 +620,180 @@ trunc:
return -1;
}
+enum checksum_status {
+ CORRECT,
+ INCORRECT,
+ UNVERIFIED
+};
+
+static enum checksum_status
+pimv2_check_checksum(netdissect_options *ndo, const u_char *bp,
+ const u_char *bp2, u_int len)
+{
+ const struct ip *ip;
+ u_int cksum;
+
+ if (!ND_TTEST2(bp[0], len)) {
+ /* We don't have all the data. */
+ return (UNVERIFIED);
+ }
+ ip = (const struct ip *)bp2;
+ if (IP_V(ip) == 4) {
+ struct cksum_vec vec[1];
+
+ vec[0].ptr = bp;
+ vec[0].len = len;
+ cksum = in_cksum(vec, 1);
+ return (cksum ? INCORRECT : CORRECT);
+ } else if (IP_V(ip) == 6) {
+ const struct ip6_hdr *ip6;
+
+ ip6 = (const struct ip6_hdr *)bp2;
+ cksum = nextproto6_cksum(ndo, ip6, bp, len, len, IPPROTO_PIM);
+ return (cksum ? INCORRECT : CORRECT);
+ } else {
+ return (UNVERIFIED);
+ }
+}
+
static void
-pimv2_print(register const u_char *bp, register u_int len, u_int cksum)
+pimv2_print(netdissect_options *ndo,
+ register const u_char *bp, register u_int len, const u_char *bp2)
{
register const u_char *ep;
- register struct pim *pim = (struct pim *)bp;
+ register const struct pim *pim = (const struct pim *)bp;
int advance;
+ enum checksum_status cksum_status;
- ep = (const u_char *)snapend;
+ ep = (const u_char *)ndo->ndo_snapend;
if (bp >= ep)
return;
if (ep > bp + len)
ep = bp + len;
- TCHECK(pim->pim_rsv);
+ ND_TCHECK(pim->pim_rsv);
pimv2_addr_len = pim->pim_rsv;
if (pimv2_addr_len != 0)
- (void)printf(", RFC2117-encoding");
+ ND_PRINT((ndo, ", RFC2117-encoding"));
- printf(", cksum 0x%04x ", EXTRACT_16BITS(&pim->pim_cksum));
- if (EXTRACT_16BITS(&pim->pim_cksum) == 0) {
- printf("(unverified)");
- } else {
- printf("(%scorrect)", TTEST2(bp[0], len) && cksum ? "in" : "" );
- }
+ ND_PRINT((ndo, ", cksum 0x%04x ", EXTRACT_16BITS(&pim->pim_cksum)));
+ if (EXTRACT_16BITS(&pim->pim_cksum) == 0) {
+ ND_PRINT((ndo, "(unverified)"));
+ } else {
+ if (PIM_TYPE(pim->pim_typever) == PIMV2_TYPE_REGISTER) {
+ /*
+ * The checksum only covers the packet header,
+ * not the encapsulated packet.
+ */
+ cksum_status = pimv2_check_checksum(ndo, bp, bp2, 8);
+ if (cksum_status == INCORRECT) {
+ /*
+ * To quote RFC 4601, "For interoperability
+ * reasons, a message carrying a checksum
+ * calculated over the entire PIM Register
+ * message should also be accepted."
+ */
+ cksum_status = pimv2_check_checksum(ndo, bp, bp2, len);
+ }
+ } else {
+ /*
+ * The checksum covers the entire packet.
+ */
+ cksum_status = pimv2_check_checksum(ndo, bp, bp2, len);
+ }
+ switch (cksum_status) {
+
+ case CORRECT:
+ ND_PRINT((ndo, "(correct)"));
+ break;
+
+ case INCORRECT:
+ ND_PRINT((ndo, "(incorrect)"));
+ break;
+
+ case UNVERIFIED:
+ ND_PRINT((ndo, "(unverified)"));
+ break;
+ }
+ }
switch (PIM_TYPE(pim->pim_typever)) {
case PIMV2_TYPE_HELLO:
{
- u_int16_t otype, olen;
+ uint16_t otype, olen;
bp += 4;
while (bp < ep) {
- TCHECK2(bp[0], 4);
+ ND_TCHECK2(bp[0], 4);
otype = EXTRACT_16BITS(&bp[0]);
olen = EXTRACT_16BITS(&bp[2]);
- TCHECK2(bp[0], 4 + olen);
-
- printf("\n\t %s Option (%u), length %u, Value: ",
- tok2str( pimv2_hello_option_values,"Unknown",otype),
- otype,
- olen);
+ ND_TCHECK2(bp[0], 4 + olen);
+ ND_PRINT((ndo, "\n\t %s Option (%u), length %u, Value: ",
+ tok2str(pimv2_hello_option_values, "Unknown", otype),
+ otype,
+ olen));
bp += 4;
switch (otype) {
case PIMV2_HELLO_OPTION_HOLDTIME:
- relts_print(EXTRACT_16BITS(bp));
- break;
+ unsigned_relts_print(ndo, EXTRACT_16BITS(bp));
+ break;
case PIMV2_HELLO_OPTION_LANPRUNEDELAY:
if (olen != 4) {
- (void)printf("ERROR: Option Length != 4 Bytes (%u)", olen);
+ ND_PRINT((ndo, "ERROR: Option Length != 4 Bytes (%u)", olen));
} else {
char t_bit;
- u_int16_t lan_delay, override_interval;
+ uint16_t lan_delay, override_interval;
lan_delay = EXTRACT_16BITS(bp);
override_interval = EXTRACT_16BITS(bp+2);
t_bit = (lan_delay & 0x8000)? 1 : 0;
lan_delay &= ~0x8000;
- (void)printf("\n\t T-bit=%d, LAN delay %dms, Override interval %dms",
- t_bit, lan_delay, override_interval);
+ ND_PRINT((ndo, "\n\t T-bit=%d, LAN delay %dms, Override interval %dms",
+ t_bit, lan_delay, override_interval));
}
break;
case PIMV2_HELLO_OPTION_DR_PRIORITY_OLD:
case PIMV2_HELLO_OPTION_DR_PRIORITY:
- switch (olen) {
- case 0:
- printf("Bi-Directional Capability (Old)");
- break;
- case 4:
- printf("%u", EXTRACT_32BITS(bp));
- break;
- default:
- printf("ERROR: Option Length != 4 Bytes (%u)", olen);
- break;
- }
- break;
+ switch (olen) {
+ case 0:
+ ND_PRINT((ndo, "Bi-Directional Capability (Old)"));
+ break;
+ case 4:
+ ND_PRINT((ndo, "%u", EXTRACT_32BITS(bp)));
+ break;
+ default:
+ ND_PRINT((ndo, "ERROR: Option Length != 4 Bytes (%u)", olen));
+ break;
+ }
+ break;
case PIMV2_HELLO_OPTION_GENID:
- (void)printf("0x%08x", EXTRACT_32BITS(bp));
+ ND_PRINT((ndo, "0x%08x", EXTRACT_32BITS(bp)));
break;
case PIMV2_HELLO_OPTION_REFRESH_CAP:
- (void)printf("v%d", *bp);
+ ND_PRINT((ndo, "v%d", *bp));
if (*(bp+1) != 0) {
- (void)printf(", interval ");
- relts_print(*(bp+1));
+ ND_PRINT((ndo, ", interval "));
+ unsigned_relts_print(ndo, *(bp+1));
}
if (EXTRACT_16BITS(bp+2) != 0) {
- (void)printf(" ?0x%04x?", EXTRACT_16BITS(bp+2));
+ ND_PRINT((ndo, " ?0x%04x?", EXTRACT_16BITS(bp+2)));
}
break;
case PIMV2_HELLO_OPTION_BIDIR_CAP:
break;
- case PIMV2_HELLO_OPTION_ADDRESS_LIST_OLD:
- case PIMV2_HELLO_OPTION_ADDRESS_LIST:
- if (vflag > 1) {
+ case PIMV2_HELLO_OPTION_ADDRESS_LIST_OLD:
+ case PIMV2_HELLO_OPTION_ADDRESS_LIST:
+ if (ndo->ndo_vflag > 1) {
const u_char *ptr = bp;
while (ptr < (bp+olen)) {
- int advance;
-
- printf("\n\t ");
- advance = pimv2_addr_print(ptr, pimv2_unicast, 0);
+ ND_PRINT((ndo, "\n\t "));
+ advance = pimv2_addr_print(ndo, ptr, pimv2_unicast, 0);
if (advance < 0) {
- printf("...");
+ ND_PRINT((ndo, "..."));
break;
}
ptr += advance;
@@ -735,13 +801,13 @@ pimv2_print(register const u_char *bp, register u_int len, u_int cksum)
}
break;
default:
- if (vflag <= 1)
- print_unknown_data(bp,"\n\t ",olen);
- break;
+ if (ndo->ndo_vflag <= 1)
+ print_unknown_data(ndo, bp, "\n\t ", olen);
+ break;
}
- /* do we want to see an additionally hexdump ? */
- if (vflag> 1)
- print_unknown_data(bp,"\n\t ",olen);
+ /* do we want to see an additionally hexdump ? */
+ if (ndo->ndo_vflag> 1)
+ print_unknown_data(ndo, bp, "\n\t ", olen);
bp += olen;
}
break;
@@ -749,37 +815,36 @@ pimv2_print(register const u_char *bp, register u_int len, u_int cksum)
case PIMV2_TYPE_REGISTER:
{
- struct ip *ip;
+ const struct ip *ip;
- if (!TTEST2(*(bp+4), PIMV2_REGISTER_FLAG_LEN))
- goto trunc;
+ ND_TCHECK2(*(bp + 4), PIMV2_REGISTER_FLAG_LEN);
- printf(", Flags [ %s ]\n\t",
- tok2str(pimv2_register_flag_values,
- "none",
- EXTRACT_32BITS(bp+4)));
+ ND_PRINT((ndo, ", Flags [ %s ]\n\t",
+ tok2str(pimv2_register_flag_values,
+ "none",
+ EXTRACT_32BITS(bp+4))));
bp += 8; len -= 8;
/* encapsulated multicast packet */
- ip = (struct ip *)bp;
+ ip = (const struct ip *)bp;
switch (IP_V(ip)) {
case 0: /* Null header */
- (void)printf("IP-Null-header %s > %s",
- ipaddr_string(&ip->ip_src),
- ipaddr_string(&ip->ip_dst));
+ ND_PRINT((ndo, "IP-Null-header %s > %s",
+ ipaddr_string(ndo, &ip->ip_src),
+ ipaddr_string(ndo, &ip->ip_dst)));
break;
case 4: /* IPv4 */
- ip_print(gndo, bp, len);
+ ip_print(ndo, bp, len);
break;
-#ifdef INET6
+
case 6: /* IPv6 */
- ip6_print(gndo, bp, len);
+ ip6_print(ndo, bp, len);
+ break;
+
+ default:
+ ND_PRINT((ndo, "IP ver %d", IP_V(ip)));
break;
-#endif
- default:
- (void)printf("IP ver %d", IP_V(ip));
- break;
}
break;
}
@@ -788,17 +853,17 @@ pimv2_print(register const u_char *bp, register u_int len, u_int cksum)
bp += 4; len -= 4;
if (bp >= ep)
break;
- (void)printf(" group=");
- if ((advance = pimv2_addr_print(bp, pimv2_group, 0)) < 0) {
- (void)printf("...");
+ ND_PRINT((ndo, " group="));
+ if ((advance = pimv2_addr_print(ndo, bp, pimv2_group, 0)) < 0) {
+ ND_PRINT((ndo, "..."));
break;
}
bp += advance; len -= advance;
if (bp >= ep)
break;
- (void)printf(" source=");
- if ((advance = pimv2_addr_print(bp, pimv2_unicast, 0)) < 0) {
- (void)printf("...");
+ ND_PRINT((ndo, " source="));
+ if ((advance = pimv2_addr_print(ndo, bp, pimv2_unicast, 0)) < 0) {
+ ND_PRINT((ndo, "..."));
break;
}
bp += advance; len -= advance;
@@ -845,19 +910,19 @@ pimv2_print(register const u_char *bp, register u_int len, u_int cksum)
*/
{
- u_int8_t ngroup;
- u_int16_t holdtime;
- u_int16_t njoin;
- u_int16_t nprune;
+ uint8_t ngroup;
+ uint16_t holdtime;
+ uint16_t njoin;
+ uint16_t nprune;
int i, j;
bp += 4; len -= 4;
if (PIM_TYPE(pim->pim_typever) != 7) { /*not for Graft-ACK*/
if (bp >= ep)
break;
- (void)printf(", upstream-neighbor: ");
- if ((advance = pimv2_addr_print(bp, pimv2_unicast, 0)) < 0) {
- (void)printf("...");
+ ND_PRINT((ndo, ", upstream-neighbor: "));
+ if ((advance = pimv2_addr_print(ndo, bp, pimv2_unicast, 0)) < 0) {
+ ND_PRINT((ndo, "..."));
break;
}
bp += advance; len -= advance;
@@ -866,44 +931,44 @@ pimv2_print(register const u_char *bp, register u_int len, u_int cksum)
break;
ngroup = bp[1];
holdtime = EXTRACT_16BITS(&bp[2]);
- (void)printf("\n\t %u group(s)", ngroup);
+ ND_PRINT((ndo, "\n\t %u group(s)", ngroup));
if (PIM_TYPE(pim->pim_typever) != 7) { /*not for Graft-ACK*/
- (void)printf(", holdtime: ");
+ ND_PRINT((ndo, ", holdtime: "));
if (holdtime == 0xffff)
- (void)printf("infinite");
+ ND_PRINT((ndo, "infinite"));
else
- relts_print(holdtime);
+ unsigned_relts_print(ndo, holdtime);
}
bp += 4; len -= 4;
for (i = 0; i < ngroup; i++) {
if (bp >= ep)
goto jp_done;
- (void)printf("\n\t group #%u: ", i+1);
- if ((advance = pimv2_addr_print(bp, pimv2_group, 0)) < 0) {
- (void)printf("...)");
+ ND_PRINT((ndo, "\n\t group #%u: ", i+1));
+ if ((advance = pimv2_addr_print(ndo, bp, pimv2_group, 0)) < 0) {
+ ND_PRINT((ndo, "...)"));
goto jp_done;
}
bp += advance; len -= advance;
if (bp + 4 > ep) {
- (void)printf("...)");
+ ND_PRINT((ndo, "...)"));
goto jp_done;
}
njoin = EXTRACT_16BITS(&bp[0]);
nprune = EXTRACT_16BITS(&bp[2]);
- (void)printf(", joined sources: %u, pruned sources: %u", njoin,nprune);
+ ND_PRINT((ndo, ", joined sources: %u, pruned sources: %u", njoin, nprune));
bp += 4; len -= 4;
for (j = 0; j < njoin; j++) {
- (void)printf("\n\t joined source #%u: ",j+1);
- if ((advance = pimv2_addr_print(bp, pimv2_source, 0)) < 0) {
- (void)printf("...)");
+ ND_PRINT((ndo, "\n\t joined source #%u: ", j+1));
+ if ((advance = pimv2_addr_print(ndo, bp, pimv2_source, 0)) < 0) {
+ ND_PRINT((ndo, "...)"));
goto jp_done;
}
bp += advance; len -= advance;
}
for (j = 0; j < nprune; j++) {
- (void)printf("\n\t pruned source #%u: ",j+1);
- if ((advance = pimv2_addr_print(bp, pimv2_source, 0)) < 0) {
- (void)printf("...)");
+ ND_PRINT((ndo, "\n\t pruned source #%u: ", j+1));
+ if ((advance = pimv2_addr_print(ndo, bp, pimv2_source, 0)) < 0) {
+ ND_PRINT((ndo, "...)"));
goto jp_done;
}
bp += advance; len -= advance;
@@ -919,72 +984,72 @@ pimv2_print(register const u_char *bp, register u_int len, u_int cksum)
bp += 4;
/* Fragment Tag, Hash Mask len, and BSR-priority */
- if (bp + sizeof(u_int16_t) >= ep) break;
- (void)printf(" tag=%x", EXTRACT_16BITS(bp));
- bp += sizeof(u_int16_t);
+ if (bp + sizeof(uint16_t) >= ep) break;
+ ND_PRINT((ndo, " tag=%x", EXTRACT_16BITS(bp)));
+ bp += sizeof(uint16_t);
if (bp >= ep) break;
- (void)printf(" hashmlen=%d", bp[0]);
+ ND_PRINT((ndo, " hashmlen=%d", bp[0]));
if (bp + 1 >= ep) break;
- (void)printf(" BSRprio=%d", bp[1]);
+ ND_PRINT((ndo, " BSRprio=%d", bp[1]));
bp += 2;
/* Encoded-Unicast-BSR-Address */
if (bp >= ep) break;
- (void)printf(" BSR=");
- if ((advance = pimv2_addr_print(bp, pimv2_unicast, 0)) < 0) {
- (void)printf("...");
+ ND_PRINT((ndo, " BSR="));
+ if ((advance = pimv2_addr_print(ndo, bp, pimv2_unicast, 0)) < 0) {
+ ND_PRINT((ndo, "..."));
break;
}
bp += advance;
for (i = 0; bp < ep; i++) {
/* Encoded-Group Address */
- (void)printf(" (group%d: ", i);
- if ((advance = pimv2_addr_print(bp, pimv2_group, 0))
+ ND_PRINT((ndo, " (group%d: ", i));
+ if ((advance = pimv2_addr_print(ndo, bp, pimv2_group, 0))
< 0) {
- (void)printf("...)");
+ ND_PRINT((ndo, "...)"));
goto bs_done;
}
bp += advance;
/* RP-Count, Frag RP-Cnt, and rsvd */
if (bp >= ep) {
- (void)printf("...)");
+ ND_PRINT((ndo, "...)"));
goto bs_done;
}
- (void)printf(" RPcnt=%d", bp[0]);
+ ND_PRINT((ndo, " RPcnt=%d", bp[0]));
if (bp + 1 >= ep) {
- (void)printf("...)");
+ ND_PRINT((ndo, "...)"));
goto bs_done;
}
- (void)printf(" FRPcnt=%d", frpcnt = bp[1]);
+ ND_PRINT((ndo, " FRPcnt=%d", frpcnt = bp[1]));
bp += 4;
for (j = 0; j < frpcnt && bp < ep; j++) {
/* each RP info */
- (void)printf(" RP%d=", j);
- if ((advance = pimv2_addr_print(bp,
+ ND_PRINT((ndo, " RP%d=", j));
+ if ((advance = pimv2_addr_print(ndo, bp,
pimv2_unicast,
0)) < 0) {
- (void)printf("...)");
+ ND_PRINT((ndo, "...)"));
goto bs_done;
}
bp += advance;
if (bp + 1 >= ep) {
- (void)printf("...)");
+ ND_PRINT((ndo, "...)"));
goto bs_done;
}
- (void)printf(",holdtime=");
- relts_print(EXTRACT_16BITS(bp));
+ ND_PRINT((ndo, ",holdtime="));
+ unsigned_relts_print(ndo, EXTRACT_16BITS(bp));
if (bp + 2 >= ep) {
- (void)printf("...)");
+ ND_PRINT((ndo, "...)"));
goto bs_done;
}
- (void)printf(",prio=%d", bp[2]);
+ ND_PRINT((ndo, ",prio=%d", bp[2]));
bp += 4;
}
- (void)printf(")");
+ ND_PRINT((ndo, ")"));
}
bs_done:
break;
@@ -993,26 +1058,26 @@ pimv2_print(register const u_char *bp, register u_int len, u_int cksum)
bp += 4; len -= 4;
if (bp >= ep)
break;
- (void)printf(" group=");
- if ((advance = pimv2_addr_print(bp, pimv2_group, 0)) < 0) {
- (void)printf("...");
+ ND_PRINT((ndo, " group="));
+ if ((advance = pimv2_addr_print(ndo, bp, pimv2_group, 0)) < 0) {
+ ND_PRINT((ndo, "..."));
break;
}
bp += advance; len -= advance;
if (bp >= ep)
break;
- (void)printf(" src=");
- if ((advance = pimv2_addr_print(bp, pimv2_unicast, 0)) < 0) {
- (void)printf("...");
+ ND_PRINT((ndo, " src="));
+ if ((advance = pimv2_addr_print(ndo, bp, pimv2_unicast, 0)) < 0) {
+ ND_PRINT((ndo, "..."));
break;
}
bp += advance; len -= advance;
if (bp + 8 > ep)
break;
if (bp[0] & 0x80)
- (void)printf(" RPT");
- (void)printf(" pref=%u", EXTRACT_32BITS(&bp[0]) & 0x7fffffff);
- (void)printf(" metric=%u", EXTRACT_32BITS(&bp[4]));
+ ND_PRINT((ndo, " RPT"));
+ ND_PRINT((ndo, " pref=%u", EXTRACT_32BITS(&bp[0]) & 0x7fffffff));
+ ND_PRINT((ndo, " metric=%u", EXTRACT_32BITS(&bp[4])));
break;
case PIMV2_TYPE_CANDIDATE_RP:
@@ -1022,30 +1087,30 @@ pimv2_print(register const u_char *bp, register u_int len, u_int cksum)
/* Prefix-Cnt, Priority, and Holdtime */
if (bp >= ep) break;
- (void)printf(" prefix-cnt=%d", bp[0]);
+ ND_PRINT((ndo, " prefix-cnt=%d", bp[0]));
pfxcnt = bp[0];
if (bp + 1 >= ep) break;
- (void)printf(" prio=%d", bp[1]);
+ ND_PRINT((ndo, " prio=%d", bp[1]));
if (bp + 3 >= ep) break;
- (void)printf(" holdtime=");
- relts_print(EXTRACT_16BITS(&bp[2]));
+ ND_PRINT((ndo, " holdtime="));
+ unsigned_relts_print(ndo, EXTRACT_16BITS(&bp[2]));
bp += 4;
/* Encoded-Unicast-RP-Address */
if (bp >= ep) break;
- (void)printf(" RP=");
- if ((advance = pimv2_addr_print(bp, pimv2_unicast, 0)) < 0) {
- (void)printf("...");
+ ND_PRINT((ndo, " RP="));
+ if ((advance = pimv2_addr_print(ndo, bp, pimv2_unicast, 0)) < 0) {
+ ND_PRINT((ndo, "..."));
break;
}
bp += advance;
/* Encoded-Group Addresses */
for (i = 0; i < pfxcnt && bp < ep; i++) {
- (void)printf(" Group%d=", i);
- if ((advance = pimv2_addr_print(bp, pimv2_group, 0))
+ ND_PRINT((ndo, " Group%d=", i));
+ if ((advance = pimv2_addr_print(ndo, bp, pimv2_group, 0))
< 0) {
- (void)printf("...");
+ ND_PRINT((ndo, "..."));
break;
}
bp += advance;
@@ -1054,39 +1119,39 @@ pimv2_print(register const u_char *bp, register u_int len, u_int cksum)
}
case PIMV2_TYPE_PRUNE_REFRESH:
- (void)printf(" src=");
- if ((advance = pimv2_addr_print(bp, pimv2_unicast, 0)) < 0) {
- (void)printf("...");
+ ND_PRINT((ndo, " src="));
+ if ((advance = pimv2_addr_print(ndo, bp, pimv2_unicast, 0)) < 0) {
+ ND_PRINT((ndo, "..."));
break;
}
bp += advance;
- (void)printf(" grp=");
- if ((advance = pimv2_addr_print(bp, pimv2_group, 0)) < 0) {
- (void)printf("...");
+ ND_PRINT((ndo, " grp="));
+ if ((advance = pimv2_addr_print(ndo, bp, pimv2_group, 0)) < 0) {
+ ND_PRINT((ndo, "..."));
break;
}
bp += advance;
- (void)printf(" forwarder=");
- if ((advance = pimv2_addr_print(bp, pimv2_unicast, 0)) < 0) {
- (void)printf("...");
+ ND_PRINT((ndo, " forwarder="));
+ if ((advance = pimv2_addr_print(ndo, bp, pimv2_unicast, 0)) < 0) {
+ ND_PRINT((ndo, "..."));
break;
}
bp += advance;
- TCHECK2(bp[0], 2);
- (void)printf(" TUNR ");
- relts_print(EXTRACT_16BITS(bp));
+ ND_TCHECK2(bp[0], 2);
+ ND_PRINT((ndo, " TUNR "));
+ unsigned_relts_print(ndo, EXTRACT_16BITS(bp));
break;
default:
- (void)printf(" [type %d]", PIM_TYPE(pim->pim_typever));
+ ND_PRINT((ndo, " [type %d]", PIM_TYPE(pim->pim_typever)));
break;
}
return;
trunc:
- (void)printf("[|pim]");
+ ND_PRINT((ndo, "[|pim]"));
}
/*
@@ -1095,3 +1160,6 @@ trunc:
* c-basic-offset: 8
* End:
*/
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-pim-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-pktap.c b/freebsd/contrib/tcpdump/print-pktap.c
new file mode 100644
index 00000000..2b5e30a4
--- /dev/null
+++ b/freebsd/contrib/tcpdump/print-pktap.c
@@ -0,0 +1,177 @@
+#include <machine/rtems-bsd-user-space.h>
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
+/*
+ * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2000
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code distributions
+ * retain the above copyright notice and this paragraph in its entirety, (2)
+ * distributions including binary code include the above copyright notice and
+ * this paragraph in its entirety in the documentation or other materials
+ * provided with the distribution, and (3) all advertising materials mentioning
+ * features or use of this software display the following acknowledgement:
+ * ``This product includes software developed by the University of California,
+ * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
+ * the University 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 ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+/* \summary: Apple's DLT_PKTAP printer */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <netdissect-stdinc.h>
+
+#include "netdissect.h"
+#include "extract.h"
+
+#ifdef DLT_PKTAP
+
+/*
+ * XXX - these are little-endian in the captures I've seen, but Apple
+ * no longer make any big-endian machines (Macs use x86, iOS machines
+ * use ARM and run it little-endian), so that might be by definition
+ * or they might be host-endian.
+ *
+ * If a big-endian PKTAP file ever shows up, and it comes from a
+ * big-endian machine, presumably these are host-endian, and we need
+ * to just fetch the fields directly in tcpdump but byte-swap them
+ * to host byte order in libpcap.
+ */
+typedef struct pktap_header {
+ uint32_t pkt_len; /* length of pktap header */
+ uint32_t pkt_rectype; /* type of record */
+ uint32_t pkt_dlt; /* DLT type of this packet */
+ char pkt_ifname[24]; /* interface name */
+ uint32_t pkt_flags;
+ uint32_t pkt_pfamily; /* "protocol family" */
+ uint32_t pkt_llhdrlen; /* link-layer header length? */
+ uint32_t pkt_lltrlrlen; /* link-layer trailer length? */
+ uint32_t pkt_pid; /* process ID */
+ char pkt_cmdname[20]; /* command name */
+ uint32_t pkt_svc_class; /* "service class" */
+ uint16_t pkt_iftype; /* "interface type" */
+ uint16_t pkt_ifunit; /* unit number of interface? */
+ uint32_t pkt_epid; /* "effective process ID" */
+ char pkt_ecmdname[20]; /* "effective command name" */
+} pktap_header_t;
+
+/*
+ * Record types.
+ */
+#define PKT_REC_NONE 0 /* nothing follows the header */
+#define PKT_REC_PACKET 1 /* a packet follows the header */
+
+static inline void
+pktap_header_print(netdissect_options *ndo, const u_char *bp, u_int length)
+{
+ const pktap_header_t *hdr;
+ uint32_t dlt, hdrlen;
+ const char *dltname;
+
+ hdr = (const pktap_header_t *)bp;
+
+ dlt = EXTRACT_LE_32BITS(&hdr->pkt_dlt);
+ hdrlen = EXTRACT_LE_32BITS(&hdr->pkt_len);
+ dltname = pcap_datalink_val_to_name(dlt);
+ if (!ndo->ndo_qflag) {
+ ND_PRINT((ndo,"DLT %s (%d) len %d",
+ (dltname != NULL ? dltname : "UNKNOWN"), dlt, hdrlen));
+ } else {
+ ND_PRINT((ndo,"%s", (dltname != NULL ? dltname : "UNKNOWN")));
+ }
+
+ ND_PRINT((ndo, ", length %u: ", length));
+}
+
+/*
+ * This is the top level routine of the printer. 'p' points
+ * to the ether header of the packet, 'h->ts' is the timestamp,
+ * 'h->len' is the length of the packet off the wire, and 'h->caplen'
+ * is the number of bytes actually captured.
+ */
+u_int
+pktap_if_print(netdissect_options *ndo,
+ const struct pcap_pkthdr *h, const u_char *p)
+{
+ uint32_t dlt, hdrlen, rectype;
+ u_int caplen = h->caplen;
+ u_int length = h->len;
+ if_printer printer;
+ const pktap_header_t *hdr;
+
+ if (caplen < sizeof(pktap_header_t) || length < sizeof(pktap_header_t)) {
+ ND_PRINT((ndo, "[|pktap]"));
+ return (0);
+ }
+ hdr = (const pktap_header_t *)p;
+ dlt = EXTRACT_LE_32BITS(&hdr->pkt_dlt);
+ hdrlen = EXTRACT_LE_32BITS(&hdr->pkt_len);
+ if (hdrlen < sizeof(pktap_header_t)) {
+ /*
+ * Claimed header length < structure length.
+ * XXX - does this just mean some fields aren't
+ * being supplied, or is it truly an error (i.e.,
+ * is the length supplied so that the header can
+ * be expanded in the future)?
+ */
+ ND_PRINT((ndo, "[|pktap]"));
+ return (0);
+ }
+ if (caplen < hdrlen || length < hdrlen) {
+ ND_PRINT((ndo, "[|pktap]"));
+ return (hdrlen);
+ }
+
+ if (ndo->ndo_eflag)
+ pktap_header_print(ndo, p, length);
+
+ length -= hdrlen;
+ caplen -= hdrlen;
+ p += hdrlen;
+
+ rectype = EXTRACT_LE_32BITS(&hdr->pkt_rectype);
+ switch (rectype) {
+
+ case PKT_REC_NONE:
+ ND_PRINT((ndo, "no data"));
+ break;
+
+ case PKT_REC_PACKET:
+ if ((printer = lookup_printer(dlt)) != NULL) {
+ hdrlen += printer(ndo, h, p);
+ } else {
+ if (!ndo->ndo_eflag)
+ pktap_header_print(ndo, (const u_char *)hdr,
+ length + hdrlen);
+
+ if (!ndo->ndo_suppress_default_print)
+ ND_DEFAULTPRINT(p, caplen);
+ }
+ break;
+ }
+
+ return (hdrlen);
+}
+
+/*
+ * Local Variables:
+ * c-style: whitesmith
+ * c-basic-offset: 8
+ * End:
+ */
+
+#endif /* DLT_PKTAP */
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-pktap-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-ppi.c b/freebsd/contrib/tcpdump/print-ppi.c
index b78d8730..04e9ddfe 100644
--- a/freebsd/contrib/tcpdump/print-ppi.c
+++ b/freebsd/contrib/tcpdump/print-ppi.c
@@ -1,84 +1,114 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Oracle
*/
+
+/* \summary: Oracle DLT_PPI printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
-
-#include <stdio.h>
-#include <pcap.h>
+#include <netdissect-stdinc.h>
#include "netdissect.h"
-#include "interface.h"
#include "extract.h"
-#include "ppi.h"
+
+typedef struct ppi_header {
+ uint8_t ppi_ver;
+ uint8_t ppi_flags;
+ uint16_t ppi_len;
+ uint32_t ppi_dlt;
+} ppi_header_t;
+
+#define PPI_HDRLEN 8
#ifdef DLT_PPI
static inline void
-ppi_header_print(struct netdissect_options *ndo, const u_char *bp, u_int length)
+ppi_header_print(netdissect_options *ndo, const u_char *bp, u_int length)
{
const ppi_header_t *hdr;
- u_int32_t dlt;
- u_int16_t len;
+ uint16_t len;
+ uint32_t dlt;
+ const char *dltname;
hdr = (const ppi_header_t *)bp;
- len = EXTRACT_16BITS(&hdr->ppi_len);
- dlt = EXTRACT_32BITS(&hdr->ppi_dlt);
+ len = EXTRACT_LE_16BITS(&hdr->ppi_len);
+ dlt = EXTRACT_LE_32BITS(&hdr->ppi_dlt);
+ dltname = pcap_datalink_val_to_name(dlt);
if (!ndo->ndo_qflag) {
- ND_PRINT((ndo,", V.%d DLT %s (%d) len %d", hdr->ppi_ver,
- pcap_datalink_val_to_name(dlt), dlt,
+ ND_PRINT((ndo, "V.%d DLT %s (%d) len %d", hdr->ppi_ver,
+ (dltname != NULL ? dltname : "UNKNOWN"), dlt,
len));
} else {
- ND_PRINT((ndo,", %s", pcap_datalink_val_to_name(dlt)));
+ ND_PRINT((ndo, "%s", (dltname != NULL ? dltname : "UNKNOWN")));
}
ND_PRINT((ndo, ", length %u: ", length));
}
-static void
-ppi_print(struct netdissect_options *ndo,
+static u_int
+ppi_print(netdissect_options *ndo,
const struct pcap_pkthdr *h, const u_char *p)
{
- if_ndo_printer ndo_printer;
- if_printer printer;
- ppi_header_t *hdr;
+ if_printer printer;
+ const ppi_header_t *hdr;
u_int caplen = h->caplen;
u_int length = h->len;
- u_int32_t dlt;
+ uint16_t len;
+ uint32_t dlt;
+ uint32_t hdrlen;
+ struct pcap_pkthdr nhdr;
if (caplen < sizeof(ppi_header_t)) {
ND_PRINT((ndo, "[|ppi]"));
- return;
+ return (caplen);
}
- hdr = (ppi_header_t *)p;
- dlt = EXTRACT_32BITS(&hdr->ppi_dlt);
+
+ hdr = (const ppi_header_t *)p;
+ len = EXTRACT_LE_16BITS(&hdr->ppi_len);
+ if (caplen < len) {
+ /*
+ * If we don't have the entire PPI header, don't
+ * bother.
+ */
+ ND_PRINT((ndo, "[|ppi]"));
+ return (caplen);
+ }
+ if (len < sizeof(ppi_header_t)) {
+ ND_PRINT((ndo, "[|ppi]"));
+ return (len);
+ }
+ dlt = EXTRACT_LE_32BITS(&hdr->ppi_dlt);
if (ndo->ndo_eflag)
ppi_header_print(ndo, p, length);
- length -= sizeof(ppi_header_t);
- caplen -= sizeof(ppi_header_t);
- p += sizeof(ppi_header_t);
+ length -= len;
+ caplen -= len;
+ p += len;
if ((printer = lookup_printer(dlt)) != NULL) {
- printer(h, p);
- } else if ((ndo_printer = lookup_ndo_printer(dlt)) != NULL) {
- ndo_printer(ndo, h, p);
+ nhdr = *h;
+ nhdr.caplen = caplen;
+ nhdr.len = length;
+ hdrlen = printer(ndo, &nhdr, p);
} else {
if (!ndo->ndo_eflag)
- ppi_header_print(ndo, (u_char *)hdr,
- length + sizeof(ppi_header_t));
+ ppi_header_print(ndo, (const u_char *)hdr, length + len);
if (!ndo->ndo_suppress_default_print)
- ndo->ndo_default_print(ndo, p, caplen);
+ ND_DEFAULTPRINT(p, caplen);
+ hdrlen = 0;
}
+ return (len + hdrlen);
}
/*
@@ -88,12 +118,10 @@ ppi_print(struct netdissect_options *ndo,
* is the number of bytes actually captured.
*/
u_int
-ppi_if_print(struct netdissect_options *ndo,
+ppi_if_print(netdissect_options *ndo,
const struct pcap_pkthdr *h, const u_char *p)
{
- ppi_print(ndo, h, p);
-
- return (sizeof(ppi_header_t));
+ return (ppi_print(ndo, h, p));
}
/*
@@ -104,3 +132,6 @@ ppi_if_print(struct netdissect_options *ndo,
*/
#endif /* DLT_PPI */
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-ppi-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-ppp.c b/freebsd/contrib/tcpdump/print-ppp.c
index 23eb21a2..05aa0b6a 100644
--- a/freebsd/contrib/tcpdump/print-ppp.c
+++ b/freebsd/contrib/tcpdump/print-ppp.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
@@ -22,10 +25,10 @@
*
* Extensively modified by Motonori Shindo (mshindo@mshindo.net) for more
* complete PPP support.
- *
- * $FreeBSD$
*/
+/* \summary: Point to Point Protocol (PPP) printer */
+
/*
* TODO:
* o resolve XXX as much as possible
@@ -33,27 +36,20 @@
* o BAP support
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ppp.c,v 1.114 2005-12-05 11:35:58 hannes Exp $ (LBL)";
-#endif
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#ifdef __bsdi__
#include <net/slcompress.h>
#include <net/if_ppp.h>
#endif
-#include <pcap.h>
-#include <stdio.h>
#include <stdlib.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
#include "addrtoname.h"
#include "ppp.h"
@@ -69,7 +65,7 @@ static const char rcsid[] _U_ =
/* Protocol Codes defined in ppp.h */
-struct tok ppptype2str[] = {
+static const struct tok ppptype2str[] = {
{ PPP_IP, "IP" },
{ PPP_OSI, "OSI" },
{ PPP_NS, "NS" },
@@ -111,6 +107,7 @@ struct tok ppptype2str[] = {
{ PPP_BACP, "BACP" },
{ PPP_BAP, "BAP" },
{ PPP_MPCP, "MLPPP-CP" },
+ { PPP_CCP, "CCP" },
{ 0, NULL }
};
@@ -133,7 +130,7 @@ struct tok ppptype2str[] = {
#define CPCODES_RESET_REQ 14 /* Reset-Request (CCP only) RFC1962 */
#define CPCODES_RESET_REP 15 /* Reset-Reply (CCP only) */
-struct tok cpcodes[] = {
+static const struct tok cpcodes[] = {
{CPCODES_VEXT, "Vendor-Extension"}, /* RFC2153 */
{CPCODES_CONF_REQ, "Conf-Request"},
{CPCODES_CONF_ACK, "Conf-Ack"},
@@ -247,7 +244,7 @@ static const char *lcpconfopts[] = {
/* 27-254 unassigned */
#define CCPOPT_RESV 255 /* RFC1962 */
-const struct tok ccpconfopts_values[] = {
+static const struct tok ccpconfopts_values[] = {
{ CCPOPT_OUI, "OUI" },
{ CCPOPT_PRED1, "Pred-1" },
{ CCPOPT_PRED2, "Pred-2" },
@@ -270,7 +267,7 @@ const struct tok ccpconfopts_values[] = {
#define BACPOPT_FPEER 1 /* RFC2125 */
-const struct tok bacconfopts_values[] = {
+static const struct tok bacconfopts_values[] = {
{ BACPOPT_FPEER, "Favored-Peer" },
{0, NULL}
};
@@ -288,7 +285,7 @@ const struct tok bacconfopts_values[] = {
#define IPCPOPT_SECDNS 131 /* RFC1877 */
#define IPCPOPT_SECNBNS 132 /* RFC1877 */
-struct tok ipcpopt_values[] = {
+static const struct tok ipcpopt_values[] = {
{ IPCPOPT_2ADDR, "IP-Addrs" },
{ IPCPOPT_IPCOMP, "IP-Comp" },
{ IPCPOPT_ADDR, "IP-Addr" },
@@ -303,13 +300,13 @@ struct tok ipcpopt_values[] = {
#define IPCPOPT_IPCOMP_HDRCOMP 0x61 /* rfc3544 */
#define IPCPOPT_IPCOMP_MINLEN 14
-struct tok ipcpopt_compproto_values[] = {
+static const struct tok ipcpopt_compproto_values[] = {
{ PPP_VJC, "VJ-Comp" },
{ IPCPOPT_IPCOMP_HDRCOMP, "IP Header Compression" },
{ 0, NULL }
};
-struct tok ipcpopt_compproto_subopt_values[] = {
+static const struct tok ipcpopt_compproto_subopt_values[] = {
{ 1, "RTP-Compression" },
{ 2, "Enhanced RTP-Compression" },
{ 0, NULL }
@@ -318,7 +315,7 @@ struct tok ipcpopt_compproto_subopt_values[] = {
/* IP6CP Config Options */
#define IP6CP_IFID 1
-struct tok ip6cpopt_values[] = {
+static const struct tok ip6cpopt_values[] = {
{ IP6CP_IFID, "Interface-ID" },
{ 0, NULL }
};
@@ -337,7 +334,7 @@ struct tok ip6cpopt_values[] = {
#define AUTHALG_MSCHAP1 128 /* RFC2433 */
#define AUTHALG_MSCHAP2 129 /* RFC2795 */
-struct tok authalg_values[] = {
+static const struct tok authalg_values[] = {
{ AUTHALG_CHAPMD5, "MD5" },
{ AUTHALG_MSCHAP1, "MS-CHAPv1" },
{ AUTHALG_MSCHAP2, "MS-CHAPv2" },
@@ -362,7 +359,7 @@ struct tok authalg_values[] = {
#define CALLBACK_X500 4 /* X.500 distinguished name */
#define CALLBACK_CBCP 6 /* Location is determined during CBCP nego */
-struct tok ppp_callback_values[] = {
+static const struct tok ppp_callback_values[] = {
{ CALLBACK_AUTH, "UserAuth" },
{ CALLBACK_DSTR, "DialString" },
{ CALLBACK_LID, "LocalID" },
@@ -379,7 +376,7 @@ struct tok ppp_callback_values[] = {
#define CHAP_SUCC 3
#define CHAP_FAIL 4
-struct tok chapcode_values[] = {
+static const struct tok chapcode_values[] = {
{ CHAP_CHAL, "Challenge" },
{ CHAP_RESP, "Response" },
{ CHAP_SUCC, "Success" },
@@ -393,7 +390,7 @@ struct tok chapcode_values[] = {
#define PAP_AACK 2
#define PAP_ANAK 3
-struct tok papcode_values[] = {
+static const struct tok papcode_values[] = {
{ PAP_AREQ, "Auth-Req" },
{ PAP_AACK, "Auth-ACK" },
{ PAP_ANAK, "Auth-NACK" },
@@ -410,73 +407,68 @@ struct tok papcode_values[] = {
#define BAP_CSIND 7
#define BAP_CSRES 8
-static void handle_ctrl_proto (u_int proto,const u_char *p, int length);
-static void handle_chap (const u_char *p, int length);
-static void handle_pap (const u_char *p, int length);
-static void handle_bap (const u_char *p, int length);
-static void handle_mlppp(const u_char *p, int length);
-static int print_lcp_config_options (const u_char *p, int);
-static int print_ipcp_config_options (const u_char *p, int);
-static int print_ip6cp_config_options (const u_char *p, int);
-static int print_ccp_config_options (const u_char *p, int);
-static int print_bacp_config_options (const u_char *p, int);
-static void handle_ppp (u_int proto, const u_char *p, int length);
-static void ppp_hdlc(const u_char *p, int length);
+static int print_lcp_config_options(netdissect_options *, const u_char *p, int);
+static int print_ipcp_config_options(netdissect_options *, const u_char *p, int);
+static int print_ip6cp_config_options(netdissect_options *, const u_char *p, int);
+static int print_ccp_config_options(netdissect_options *, const u_char *p, int);
+static int print_bacp_config_options(netdissect_options *, const u_char *p, int);
+static void handle_ppp(netdissect_options *, u_int proto, const u_char *p, int length);
/* generic Control Protocol (e.g. LCP, IPCP, CCP, etc.) handler */
static void
-handle_ctrl_proto(u_int proto, const u_char *pptr, int length)
+handle_ctrl_proto(netdissect_options *ndo,
+ u_int proto, const u_char *pptr, int length)
{
const char *typestr;
u_int code, len;
- int (*pfunc)(const u_char *, int);
+ int (*pfunc)(netdissect_options *, const u_char *, int);
int x, j;
const u_char *tptr;
tptr=pptr;
typestr = tok2str(ppptype2str, "unknown ctrl-proto (0x%04x)", proto);
- printf("%s, ",typestr);
+ ND_PRINT((ndo, "%s, ", typestr));
if (length < 4) /* FIXME weak boundary checking */
goto trunc;
- TCHECK2(*tptr, 2);
+ ND_TCHECK2(*tptr, 2);
code = *tptr++;
-
- printf("%s (0x%02x), id %u, length %u",
- tok2str(cpcodes, "Unknown Opcode",code),
- code,
- *tptr++, /* ID */
- length+2);
-
- if (!vflag)
- return;
+
+ ND_PRINT((ndo, "%s (0x%02x), id %u, length %u",
+ tok2str(cpcodes, "Unknown Opcode",code),
+ code,
+ *tptr++, /* ID */
+ length + 2));
+
+ if (!ndo->ndo_vflag)
+ return;
if (length <= 4)
return; /* there may be a NULL confreq etc. */
- TCHECK2(*tptr, 2);
+ ND_TCHECK2(*tptr, 2);
len = EXTRACT_16BITS(tptr);
tptr += 2;
- printf("\n\tencoded length %u (=Option(s) length %u)",len,len-4);
+ ND_PRINT((ndo, "\n\tencoded length %u (=Option(s) length %u)", len, len - 4));
- if (vflag>1)
- print_unknown_data(pptr-2,"\n\t",6);
+ if (ndo->ndo_vflag > 1)
+ print_unknown_data(ndo, pptr - 2, "\n\t", 6);
switch (code) {
case CPCODES_VEXT:
if (length < 11)
break;
- TCHECK2(*tptr, 4);
- printf("\n\t Magic-Num 0x%08x", EXTRACT_32BITS(tptr));
+ ND_TCHECK2(*tptr, 4);
+ ND_PRINT((ndo, "\n\t Magic-Num 0x%08x", EXTRACT_32BITS(tptr)));
tptr += 4;
- TCHECK2(*tptr, 3);
- printf(" Vendor: %s (%u)",
+ ND_TCHECK2(*tptr, 3);
+ ND_PRINT((ndo, " Vendor: %s (%u)",
tok2str(oui_values,"Unknown",EXTRACT_24BITS(tptr)),
- EXTRACT_24BITS(tptr));
+ EXTRACT_24BITS(tptr)));
/* XXX: need to decode Kind and Value(s)? */
break;
case CPCODES_CONF_REQ:
@@ -512,8 +504,8 @@ handle_ctrl_proto(u_int proto, const u_char *pptr, int length)
if (pfunc == NULL) /* catch the above null pointer if unknown CP */
break;
-
- if ((j = (*pfunc)(tptr, len)) == 0)
+
+ if ((j = (*pfunc)(ndo, tptr, len)) == 0)
break;
x -= j;
tptr += j;
@@ -530,209 +522,239 @@ handle_ctrl_proto(u_int proto, const u_char *pptr, int length)
case CPCODES_PROT_REJ:
if (length < 6)
break;
- TCHECK2(*tptr, 2);
- printf("\n\t Rejected %s Protocol (0x%04x)",
+ ND_TCHECK2(*tptr, 2);
+ ND_PRINT((ndo, "\n\t Rejected %s Protocol (0x%04x)",
tok2str(ppptype2str,"unknown", EXTRACT_16BITS(tptr)),
- EXTRACT_16BITS(tptr));
+ EXTRACT_16BITS(tptr)));
/* XXX: need to decode Rejected-Information? - hexdump for now */
- if (len > 6) {
- printf("\n\t Rejected Packet");
- print_unknown_data(tptr+2,"\n\t ",len-2);
- }
+ if (len > 6) {
+ ND_PRINT((ndo, "\n\t Rejected Packet"));
+ print_unknown_data(ndo, tptr + 2, "\n\t ", len - 2);
+ }
break;
case CPCODES_ECHO_REQ:
case CPCODES_ECHO_RPL:
case CPCODES_DISC_REQ:
if (length < 8)
break;
- TCHECK2(*tptr, 4);
- printf("\n\t Magic-Num 0x%08x", EXTRACT_32BITS(tptr));
+ ND_TCHECK2(*tptr, 4);
+ ND_PRINT((ndo, "\n\t Magic-Num 0x%08x", EXTRACT_32BITS(tptr)));
/* XXX: need to decode Data? - hexdump for now */
- if (len > 8) {
- printf("\n\t -----trailing data-----");
- TCHECK2(tptr[4], len-8);
- print_unknown_data(tptr+4,"\n\t ",len-8);
- }
+ if (len > 8) {
+ ND_PRINT((ndo, "\n\t -----trailing data-----"));
+ ND_TCHECK2(tptr[4], len - 8);
+ print_unknown_data(ndo, tptr + 4, "\n\t ", len - 8);
+ }
break;
case CPCODES_ID:
if (length < 8)
break;
- TCHECK2(*tptr, 4);
- printf("\n\t Magic-Num 0x%08x", EXTRACT_32BITS(tptr));
+ ND_TCHECK2(*tptr, 4);
+ ND_PRINT((ndo, "\n\t Magic-Num 0x%08x", EXTRACT_32BITS(tptr)));
/* RFC 1661 says this is intended to be human readable */
- if (len > 8) {
- printf("\n\t Message\n\t ");
- fn_printn(tptr+4,len-4,snapend);
- }
+ if (len > 8) {
+ ND_PRINT((ndo, "\n\t Message\n\t "));
+ if (fn_printn(ndo, tptr + 4, len - 4, ndo->ndo_snapend))
+ goto trunc;
+ }
break;
case CPCODES_TIME_REM:
if (length < 12)
break;
- TCHECK2(*tptr, 4);
- printf("\n\t Magic-Num 0x%08x", EXTRACT_32BITS(tptr));
- TCHECK2(*(tptr + 4), 4);
- printf(", Seconds-Remaining %us", EXTRACT_32BITS(tptr + 4));
+ ND_TCHECK2(*tptr, 4);
+ ND_PRINT((ndo, "\n\t Magic-Num 0x%08x", EXTRACT_32BITS(tptr)));
+ ND_TCHECK2(*(tptr + 4), 4);
+ ND_PRINT((ndo, ", Seconds-Remaining %us", EXTRACT_32BITS(tptr + 4)));
/* XXX: need to decode Message? */
break;
default:
- /* XXX this is dirty but we do not get the
- * original pointer passed to the begin
- * the PPP packet */
- if (vflag <= 1)
- print_unknown_data(pptr-2,"\n\t ",length+2);
+ /* XXX this is dirty but we do not get the
+ * original pointer passed to the begin
+ * the PPP packet */
+ if (ndo->ndo_vflag <= 1)
+ print_unknown_data(ndo, pptr - 2, "\n\t ", length + 2);
break;
}
return;
trunc:
- printf("[|%s]", typestr);
+ ND_PRINT((ndo, "[|%s]", typestr));
}
/* LCP config options */
static int
-print_lcp_config_options(const u_char *p, int length)
+print_lcp_config_options(netdissect_options *ndo,
+ const u_char *p, int length)
{
int len, opt;
if (length < 2)
return 0;
- TCHECK2(*p, 2);
+ ND_TCHECK2(*p, 2);
len = p[1];
opt = p[0];
if (length < len)
return 0;
if (len < 2) {
if ((opt >= LCPOPT_MIN) && (opt <= LCPOPT_MAX))
- printf("\n\t %s Option (0x%02x), length %u (bogus, should be >= 2)", lcpconfopts[opt],opt,len);
+ ND_PRINT((ndo, "\n\t %s Option (0x%02x), length %u (length bogus, should be >= 2)",
+ lcpconfopts[opt], opt, len));
else
- printf("\n\tunknown LCP option 0x%02x", opt);
+ ND_PRINT((ndo, "\n\tunknown LCP option 0x%02x", opt));
return 0;
}
if ((opt >= LCPOPT_MIN) && (opt <= LCPOPT_MAX))
- printf("\n\t %s Option (0x%02x), length %u: ", lcpconfopts[opt],opt,len);
+ ND_PRINT((ndo, "\n\t %s Option (0x%02x), length %u", lcpconfopts[opt], opt, len));
else {
- printf("\n\tunknown LCP option 0x%02x", opt);
+ ND_PRINT((ndo, "\n\tunknown LCP option 0x%02x", opt));
return len;
}
switch (opt) {
case LCPOPT_VEXT:
- if (len >= 6) {
- TCHECK2(*(p + 2), 3);
- printf("Vendor: %s (%u)",
- tok2str(oui_values,"Unknown",EXTRACT_24BITS(p+2)),
- EXTRACT_24BITS(p+2));
+ if (len < 6) {
+ ND_PRINT((ndo, " (length bogus, should be >= 6)"));
+ return len;
+ }
+ ND_TCHECK2(*(p + 2), 3);
+ ND_PRINT((ndo, ": Vendor: %s (%u)",
+ tok2str(oui_values,"Unknown",EXTRACT_24BITS(p+2)),
+ EXTRACT_24BITS(p + 2)));
#if 0
- TCHECK(p[5]);
- printf(", kind: 0x%02x", p[5]);
- printf(", Value: 0x")
- for (i = 0; i < len - 6; i++) {
- TCHECK(p[6 + i]);
- printf("%02x", p[6 + i]);
- }
-#endif
+ ND_TCHECK(p[5]);
+ ND_PRINT((ndo, ", kind: 0x%02x", p[5]));
+ ND_PRINT((ndo, ", Value: 0x"));
+ for (i = 0; i < len - 6; i++) {
+ ND_TCHECK(p[6 + i]);
+ ND_PRINT((ndo, "%02x", p[6 + i]));
}
+#endif
break;
case LCPOPT_MRU:
- if (len == 4) {
- TCHECK2(*(p + 2), 2);
- printf("%u", EXTRACT_16BITS(p + 2));
+ if (len != 4) {
+ ND_PRINT((ndo, " (length bogus, should be = 4)"));
+ return len;
}
+ ND_TCHECK2(*(p + 2), 2);
+ ND_PRINT((ndo, ": %u", EXTRACT_16BITS(p + 2)));
break;
case LCPOPT_ACCM:
- if (len == 6) {
- TCHECK2(*(p + 2), 4);
- printf("0x%08x", EXTRACT_32BITS(p + 2));
+ if (len != 6) {
+ ND_PRINT((ndo, " (length bogus, should be = 6)"));
+ return len;
}
+ ND_TCHECK2(*(p + 2), 4);
+ ND_PRINT((ndo, ": 0x%08x", EXTRACT_32BITS(p + 2)));
break;
case LCPOPT_AP:
- if (len >= 4) {
- TCHECK2(*(p + 2), 2);
- printf("%s", tok2str(ppptype2str,"Unknown Auth Proto (0x04x)",EXTRACT_16BITS(p+2)));
-
- switch (EXTRACT_16BITS(p+2)) {
- case PPP_CHAP:
- TCHECK(p[4]);
- printf(", %s",tok2str(authalg_values,"Unknown Auth Alg %u",p[4]));
+ if (len < 4) {
+ ND_PRINT((ndo, " (length bogus, should be >= 4)"));
+ return len;
+ }
+ ND_TCHECK2(*(p + 2), 2);
+ ND_PRINT((ndo, ": %s", tok2str(ppptype2str, "Unknown Auth Proto (0x04x)", EXTRACT_16BITS(p + 2))));
+
+ switch (EXTRACT_16BITS(p+2)) {
+ case PPP_CHAP:
+ ND_TCHECK(p[4]);
+ ND_PRINT((ndo, ", %s", tok2str(authalg_values, "Unknown Auth Alg %u", p[4])));
break;
- case PPP_PAP: /* fall through */
- case PPP_EAP:
- case PPP_SPAP:
- case PPP_SPAP_OLD:
+ case PPP_PAP: /* fall through */
+ case PPP_EAP:
+ case PPP_SPAP:
+ case PPP_SPAP_OLD:
break;
- default:
- print_unknown_data(p,"\n\t",len);
- }
+ default:
+ print_unknown_data(ndo, p, "\n\t", len);
}
break;
case LCPOPT_QP:
- if (len >= 4) {
- TCHECK2(*(p + 2), 2);
- if (EXTRACT_16BITS(p+2) == PPP_LQM)
- printf(" LQR");
- else
- printf(" unknown");
+ if (len < 4) {
+ ND_PRINT((ndo, " (length bogus, should be >= 4)"));
+ return 0;
}
+ ND_TCHECK2(*(p + 2), 2);
+ if (EXTRACT_16BITS(p+2) == PPP_LQM)
+ ND_PRINT((ndo, ": LQR"));
+ else
+ ND_PRINT((ndo, ": unknown"));
break;
case LCPOPT_MN:
- if (len == 6) {
- TCHECK2(*(p + 2), 4);
- printf("0x%08x", EXTRACT_32BITS(p + 2));
+ if (len != 6) {
+ ND_PRINT((ndo, " (length bogus, should be = 6)"));
+ return 0;
}
+ ND_TCHECK2(*(p + 2), 4);
+ ND_PRINT((ndo, ": 0x%08x", EXTRACT_32BITS(p + 2)));
break;
case LCPOPT_PFC:
break;
case LCPOPT_ACFC:
break;
case LCPOPT_LD:
- if (len == 4) {
- TCHECK2(*(p + 2), 2);
- printf("0x%04x", EXTRACT_16BITS(p + 2));
+ if (len != 4) {
+ ND_PRINT((ndo, " (length bogus, should be = 4)"));
+ return 0;
}
+ ND_TCHECK2(*(p + 2), 2);
+ ND_PRINT((ndo, ": 0x%04x", EXTRACT_16BITS(p + 2)));
break;
case LCPOPT_CBACK:
- if (len < 3)
- break;
- TCHECK(p[2]);
- printf("Callback Operation %s (%u)",
- tok2str(ppp_callback_values,"Unknown",p[2]),
- p[2]);
+ if (len < 3) {
+ ND_PRINT((ndo, " (length bogus, should be >= 3)"));
+ return 0;
+ }
+ ND_PRINT((ndo, ": "));
+ ND_TCHECK(p[2]);
+ ND_PRINT((ndo, ": Callback Operation %s (%u)",
+ tok2str(ppp_callback_values, "Unknown", p[2]),
+ p[2]));
break;
case LCPOPT_MLMRRU:
- if (len == 4) {
- TCHECK2(*(p + 2), 2);
- printf("%u", EXTRACT_16BITS(p + 2));
+ if (len != 4) {
+ ND_PRINT((ndo, " (length bogus, should be = 4)"));
+ return 0;
}
+ ND_TCHECK2(*(p + 2), 2);
+ ND_PRINT((ndo, ": %u", EXTRACT_16BITS(p + 2)));
break;
case LCPOPT_MLED:
- if (len < 3)
- break;
- TCHECK(p[2]);
+ if (len < 3) {
+ ND_PRINT((ndo, " (length bogus, should be >= 3)"));
+ return 0;
+ }
+ ND_TCHECK(p[2]);
switch (p[2]) { /* class */
case MEDCLASS_NULL:
- printf("Null");
+ ND_PRINT((ndo, ": Null"));
break;
case MEDCLASS_LOCAL:
- printf("Local"); /* XXX */
+ ND_PRINT((ndo, ": Local")); /* XXX */
break;
case MEDCLASS_IPV4:
- if (len != 7)
- break;
- TCHECK2(*(p + 3), 4);
- printf("IPv4 %s", ipaddr_string(p + 3));
+ if (len != 7) {
+ ND_PRINT((ndo, " (length bogus, should be = 7)"));
+ return 0;
+ }
+ ND_TCHECK2(*(p + 3), 4);
+ ND_PRINT((ndo, ": IPv4 %s", ipaddr_string(ndo, p + 3)));
break;
case MEDCLASS_MAC:
- if (len != 9)
- break;
- TCHECK(p[8]);
- printf("MAC %02x:%02x:%02x:%02x:%02x:%02x",
- p[3], p[4], p[5], p[6], p[7], p[8]);
+ if (len != 9) {
+ ND_PRINT((ndo, " (length bogus, should be = 9)"));
+ return 0;
+ }
+ ND_TCHECK2(*(p + 3), 6);
+ ND_PRINT((ndo, ": MAC %s", etheraddr_string(ndo, p + 3)));
break;
case MEDCLASS_MNB:
- printf("Magic-Num-Block"); /* XXX */
+ ND_PRINT((ndo, ": Magic-Num-Block")); /* XXX */
break;
case MEDCLASS_PSNDN:
- printf("PSNDN"); /* XXX */
+ ND_PRINT((ndo, ": PSNDN")); /* XXX */
+ break;
+ default:
+ ND_PRINT((ndo, ": Unknown class %u", p[2]));
break;
}
break;
@@ -760,46 +782,50 @@ print_lcp_config_options(const u_char *p, int length)
case LCPOPT_PPPMUX:
break;
#endif
- default:
- if(vflag<2)
- print_unknown_data(&p[2],"\n\t ",len-2);
- break;
+ default:
+ /*
+ * Unknown option; dump it as raw bytes now if we're
+ * not going to do so below.
+ */
+ if (ndo->ndo_vflag < 2)
+ print_unknown_data(ndo, &p[2], "\n\t ", len - 2);
+ break;
}
-
- if (vflag>1)
- print_unknown_data(&p[2],"\n\t ",len-2); /* exclude TLV header */
+
+ if (ndo->ndo_vflag > 1)
+ print_unknown_data(ndo, &p[2], "\n\t ", len - 2); /* exclude TLV header */
return len;
trunc:
- printf("[|lcp]");
+ ND_PRINT((ndo, "[|lcp]"));
return 0;
}
/* ML-PPP*/
-struct tok ppp_ml_flag_values[] = {
+static const struct tok ppp_ml_flag_values[] = {
{ 0x80, "begin" },
{ 0x40, "end" },
{ 0, NULL }
};
static void
-handle_mlppp(const u_char *p, int length) {
-
- if (!eflag)
- printf("MLPPP, ");
+handle_mlppp(netdissect_options *ndo,
+ const u_char *p, int length)
+{
+ if (!ndo->ndo_eflag)
+ ND_PRINT((ndo, "MLPPP, "));
- printf("seq 0x%03x, Flags [%s], length %u",
+ ND_PRINT((ndo, "seq 0x%03x, Flags [%s], length %u",
(EXTRACT_16BITS(p))&0x0fff, /* only support 12-Bit sequence space for now */
bittok2str(ppp_ml_flag_values, "none", *p & 0xc0),
- length);
-
- return;
+ length));
}
/* CHAP */
static void
-handle_chap(const u_char *p, int length)
+handle_chap(netdissect_options *ndo,
+ const u_char *p, int length)
{
u_int code, len;
int val_size, name_size, msg_size;
@@ -808,26 +834,26 @@ handle_chap(const u_char *p, int length)
p0 = p;
if (length < 1) {
- printf("[|chap]");
+ ND_PRINT((ndo, "[|chap]"));
return;
} else if (length < 4) {
- TCHECK(*p);
- printf("[|chap 0x%02x]", *p);
+ ND_TCHECK(*p);
+ ND_PRINT((ndo, "[|chap 0x%02x]", *p));
return;
}
- TCHECK(*p);
+ ND_TCHECK(*p);
code = *p;
- printf("CHAP, %s (0x%02x)",
+ ND_PRINT((ndo, "CHAP, %s (0x%02x)",
tok2str(chapcode_values,"unknown",code),
- code);
+ code));
p++;
- TCHECK(*p);
- printf(", id %u", *p); /* ID */
+ ND_TCHECK(*p);
+ ND_PRINT((ndo, ", id %u", *p)); /* ID */
p++;
- TCHECK2(*p, 2);
+ ND_TCHECK2(*p, 2);
len = EXTRACT_16BITS(p);
p += 2;
@@ -843,42 +869,43 @@ handle_chap(const u_char *p, int length)
case CHAP_RESP:
if (length - (p - p0) < 1)
return;
- TCHECK(*p);
+ ND_TCHECK(*p);
val_size = *p; /* value size */
p++;
if (length - (p - p0) < val_size)
return;
- printf(", Value ");
+ ND_PRINT((ndo, ", Value "));
for (i = 0; i < val_size; i++) {
- TCHECK(*p);
- printf("%02x", *p++);
+ ND_TCHECK(*p);
+ ND_PRINT((ndo, "%02x", *p++));
}
name_size = len - (p - p0);
- printf(", Name ");
+ ND_PRINT((ndo, ", Name "));
for (i = 0; i < name_size; i++) {
- TCHECK(*p);
- safeputchar(*p++);
+ ND_TCHECK(*p);
+ safeputchar(ndo, *p++);
}
break;
case CHAP_SUCC:
case CHAP_FAIL:
msg_size = len - (p - p0);
- printf(", Msg ");
+ ND_PRINT((ndo, ", Msg "));
for (i = 0; i< msg_size; i++) {
- TCHECK(*p);
- safeputchar(*p++);
+ ND_TCHECK(*p);
+ safeputchar(ndo, *p++);
}
break;
}
return;
trunc:
- printf("[|chap]");
+ ND_PRINT((ndo, "[|chap]"));
}
/* PAP (see RFC 1334) */
static void
-handle_pap(const u_char *p, int length)
+handle_pap(netdissect_options *ndo,
+ const u_char *p, int length)
{
u_int code, len;
int peerid_len, passwd_len, msg_len;
@@ -887,92 +914,103 @@ handle_pap(const u_char *p, int length)
p0 = p;
if (length < 1) {
- printf("[|pap]");
+ ND_PRINT((ndo, "[|pap]"));
return;
} else if (length < 4) {
- TCHECK(*p);
- printf("[|pap 0x%02x]", *p);
+ ND_TCHECK(*p);
+ ND_PRINT((ndo, "[|pap 0x%02x]", *p));
return;
}
- TCHECK(*p);
+ ND_TCHECK(*p);
code = *p;
- printf("PAP, %s (0x%02x)",
- tok2str(papcode_values,"unknown",code),
- code);
+ ND_PRINT((ndo, "PAP, %s (0x%02x)",
+ tok2str(papcode_values, "unknown", code),
+ code));
p++;
- TCHECK(*p);
- printf(", id %u", *p); /* ID */
+ ND_TCHECK(*p);
+ ND_PRINT((ndo, ", id %u", *p)); /* ID */
p++;
- TCHECK2(*p, 2);
+ ND_TCHECK2(*p, 2);
len = EXTRACT_16BITS(p);
p += 2;
if ((int)len > length) {
- printf(", length %u > packet size", len);
+ ND_PRINT((ndo, ", length %u > packet size", len));
return;
}
length = len;
if (length < (p - p0)) {
- printf(", length %u < PAP header length", length);
+ ND_PRINT((ndo, ", length %u < PAP header length", length));
return;
}
switch (code) {
case PAP_AREQ:
+ /* A valid Authenticate-Request is 6 or more octets long. */
+ if (len < 6)
+ goto trunc;
if (length - (p - p0) < 1)
return;
- TCHECK(*p);
+ ND_TCHECK(*p);
peerid_len = *p; /* Peer-ID Length */
p++;
if (length - (p - p0) < peerid_len)
return;
- printf(", Peer ");
+ ND_PRINT((ndo, ", Peer "));
for (i = 0; i < peerid_len; i++) {
- TCHECK(*p);
- safeputchar(*p++);
+ ND_TCHECK(*p);
+ safeputchar(ndo, *p++);
}
if (length - (p - p0) < 1)
return;
- TCHECK(*p);
+ ND_TCHECK(*p);
passwd_len = *p; /* Password Length */
p++;
if (length - (p - p0) < passwd_len)
return;
- printf(", Name ");
+ ND_PRINT((ndo, ", Name "));
for (i = 0; i < passwd_len; i++) {
- TCHECK(*p);
- safeputchar(*p++);
+ ND_TCHECK(*p);
+ safeputchar(ndo, *p++);
}
break;
case PAP_AACK:
case PAP_ANAK:
+ /* Although some implementations ignore truncation at
+ * this point and at least one generates a truncated
+ * packet, RFC 1334 section 2.2.2 clearly states that
+ * both AACK and ANAK are at least 5 bytes long.
+ */
+ if (len < 5)
+ goto trunc;
if (length - (p - p0) < 1)
return;
- TCHECK(*p);
+ ND_TCHECK(*p);
msg_len = *p; /* Msg-Length */
p++;
if (length - (p - p0) < msg_len)
return;
- printf(", Msg ");
+ ND_PRINT((ndo, ", Msg "));
for (i = 0; i< msg_len; i++) {
- TCHECK(*p);
- safeputchar(*p++);
+ ND_TCHECK(*p);
+ safeputchar(ndo, *p++);
}
break;
}
return;
trunc:
- printf("[|pap]");
+ ND_PRINT((ndo, "[|pap]"));
}
/* BAP */
static void
-handle_bap(const u_char *p _U_, int length _U_)
+handle_bap(netdissect_options *ndo _U_,
+ const u_char *p _U_, int length _U_)
{
/* XXX: to be supported!! */
}
@@ -980,91 +1018,99 @@ handle_bap(const u_char *p _U_, int length _U_)
/* IPCP config options */
static int
-print_ipcp_config_options(const u_char *p, int length)
+print_ipcp_config_options(netdissect_options *ndo,
+ const u_char *p, int length)
{
int len, opt;
u_int compproto, ipcomp_subopttotallen, ipcomp_subopt, ipcomp_suboptlen;
if (length < 2)
return 0;
- TCHECK2(*p, 2);
+ ND_TCHECK2(*p, 2);
len = p[1];
opt = p[0];
if (length < len)
return 0;
if (len < 2) {
- printf("\n\t %s Option (0x%02x), length %u (bogus, should be >= 2)",
+ ND_PRINT((ndo, "\n\t %s Option (0x%02x), length %u (length bogus, should be >= 2)",
tok2str(ipcpopt_values,"unknown",opt),
opt,
- len);
+ len));
return 0;
}
- printf("\n\t %s Option (0x%02x), length %u: ",
+ ND_PRINT((ndo, "\n\t %s Option (0x%02x), length %u",
tok2str(ipcpopt_values,"unknown",opt),
opt,
- len);
+ len));
switch (opt) {
case IPCPOPT_2ADDR: /* deprecated */
- if (len != 10)
- goto invlen;
- TCHECK2(*(p + 6), 4);
- printf("src %s, dst %s",
- ipaddr_string(p + 2),
- ipaddr_string(p + 6));
+ if (len != 10) {
+ ND_PRINT((ndo, " (length bogus, should be = 10)"));
+ return len;
+ }
+ ND_TCHECK2(*(p + 6), 4);
+ ND_PRINT((ndo, ": src %s, dst %s",
+ ipaddr_string(ndo, p + 2),
+ ipaddr_string(ndo, p + 6)));
break;
case IPCPOPT_IPCOMP:
- if (len < 4)
- goto invlen;
- TCHECK2(*(p + 2), 2);
- compproto = EXTRACT_16BITS(p+2);
+ if (len < 4) {
+ ND_PRINT((ndo, " (length bogus, should be >= 4)"));
+ return 0;
+ }
+ ND_TCHECK2(*(p + 2), 2);
+ compproto = EXTRACT_16BITS(p+2);
- printf("%s (0x%02x):",
- tok2str(ipcpopt_compproto_values,"Unknown",compproto),
- compproto);
+ ND_PRINT((ndo, ": %s (0x%02x):",
+ tok2str(ipcpopt_compproto_values, "Unknown", compproto),
+ compproto));
switch (compproto) {
case PPP_VJC:
/* XXX: VJ-Comp parameters should be decoded */
break;
case IPCPOPT_IPCOMP_HDRCOMP:
- if (len < IPCPOPT_IPCOMP_MINLEN)
- goto invlen;
+ if (len < IPCPOPT_IPCOMP_MINLEN) {
+ ND_PRINT((ndo, " (length bogus, should be >= %u)",
+ IPCPOPT_IPCOMP_MINLEN));
+ return 0;
+ }
- TCHECK2(*(p + 2), IPCPOPT_IPCOMP_MINLEN);
- printf("\n\t TCP Space %u, non-TCP Space %u" \
+ ND_TCHECK2(*(p + 2), IPCPOPT_IPCOMP_MINLEN);
+ ND_PRINT((ndo, "\n\t TCP Space %u, non-TCP Space %u" \
", maxPeriod %u, maxTime %u, maxHdr %u",
EXTRACT_16BITS(p+4),
EXTRACT_16BITS(p+6),
EXTRACT_16BITS(p+8),
EXTRACT_16BITS(p+10),
- EXTRACT_16BITS(p+12));
+ EXTRACT_16BITS(p+12)));
/* suboptions present ? */
if (len > IPCPOPT_IPCOMP_MINLEN) {
ipcomp_subopttotallen = len - IPCPOPT_IPCOMP_MINLEN;
p += IPCPOPT_IPCOMP_MINLEN;
-
- printf("\n\t Suboptions, length %u", ipcomp_subopttotallen);
+
+ ND_PRINT((ndo, "\n\t Suboptions, length %u", ipcomp_subopttotallen));
while (ipcomp_subopttotallen >= 2) {
- TCHECK2(*p, 2);
+ ND_TCHECK2(*p, 2);
ipcomp_subopt = *p;
ipcomp_suboptlen = *(p+1);
-
+
/* sanity check */
if (ipcomp_subopt == 0 ||
ipcomp_suboptlen == 0 )
break;
/* XXX: just display the suboptions for now */
- printf("\n\t\t%s Suboption #%u, length %u",
+ ND_PRINT((ndo, "\n\t\t%s Suboption #%u, length %u",
tok2str(ipcpopt_compproto_subopt_values,
"Unknown",
ipcomp_subopt),
ipcomp_subopt,
- ipcomp_suboptlen);
+ ipcomp_suboptlen));
ipcomp_subopttotallen -= ipcomp_suboptlen;
p += ipcomp_suboptlen;
@@ -1082,114 +1128,153 @@ print_ipcp_config_options(const u_char *p, int length)
case IPCPOPT_PRINBNS:
case IPCPOPT_SECDNS:
case IPCPOPT_SECNBNS:
- if (len != 6)
- goto invlen;
- TCHECK2(*(p + 2), 4);
- printf("%s", ipaddr_string(p + 2));
+ if (len != 6) {
+ ND_PRINT((ndo, " (length bogus, should be = 6)"));
+ return 0;
+ }
+ ND_TCHECK2(*(p + 2), 4);
+ ND_PRINT((ndo, ": %s", ipaddr_string(ndo, p + 2)));
break;
default:
- if(vflag<2)
- print_unknown_data(&p[2],"\n\t ",len-2);
+ /*
+ * Unknown option; dump it as raw bytes now if we're
+ * not going to do so below.
+ */
+ if (ndo->ndo_vflag < 2)
+ print_unknown_data(ndo, &p[2], "\n\t ", len - 2);
break;
}
- if (vflag>1)
- print_unknown_data(&p[2],"\n\t ",len-2); /* exclude TLV header */
+ if (ndo->ndo_vflag > 1)
+ print_unknown_data(ndo, &p[2], "\n\t ", len - 2); /* exclude TLV header */
return len;
-invlen:
- printf(", invalid-length-%d", opt);
- return 0;
-
trunc:
- printf("[|ipcp]");
+ ND_PRINT((ndo, "[|ipcp]"));
return 0;
}
/* IP6CP config options */
static int
-print_ip6cp_config_options(const u_char *p, int length)
+print_ip6cp_config_options(netdissect_options *ndo,
+ const u_char *p, int length)
{
int len, opt;
if (length < 2)
return 0;
- TCHECK2(*p, 2);
+ ND_TCHECK2(*p, 2);
len = p[1];
opt = p[0];
if (length < len)
return 0;
if (len < 2) {
- printf("\n\t %s Option (0x%02x), length %u (bogus, should be >= 2)",
+ ND_PRINT((ndo, "\n\t %s Option (0x%02x), length %u (length bogus, should be >= 2)",
tok2str(ip6cpopt_values,"unknown",opt),
opt,
- len);
- return 0;
+ len));
+ return 0;
}
- printf("\n\t %s Option (0x%02x), length %u: ",
+ ND_PRINT((ndo, "\n\t %s Option (0x%02x), length %u",
tok2str(ip6cpopt_values,"unknown",opt),
opt,
- len);
+ len));
switch (opt) {
case IP6CP_IFID:
- if (len != 10)
- goto invlen;
- TCHECK2(*(p + 2), 8);
- printf("%04x:%04x:%04x:%04x",
+ if (len != 10) {
+ ND_PRINT((ndo, " (length bogus, should be = 10)"));
+ return len;
+ }
+ ND_TCHECK2(*(p + 2), 8);
+ ND_PRINT((ndo, ": %04x:%04x:%04x:%04x",
EXTRACT_16BITS(p + 2),
EXTRACT_16BITS(p + 4),
EXTRACT_16BITS(p + 6),
- EXTRACT_16BITS(p + 8));
+ EXTRACT_16BITS(p + 8)));
break;
default:
- if(vflag<2)
- print_unknown_data(&p[2],"\n\t ",len-2);
+ /*
+ * Unknown option; dump it as raw bytes now if we're
+ * not going to do so below.
+ */
+ if (ndo->ndo_vflag < 2)
+ print_unknown_data(ndo, &p[2], "\n\t ", len - 2);
break;
}
- if (vflag>1)
- print_unknown_data(&p[2],"\n\t ",len-2); /* exclude TLV header */
+ if (ndo->ndo_vflag > 1)
+ print_unknown_data(ndo, &p[2], "\n\t ", len - 2); /* exclude TLV header */
return len;
-invlen:
- printf(", invalid-length-%d", opt);
- return 0;
-
trunc:
- printf("[|ip6cp]");
+ ND_PRINT((ndo, "[|ip6cp]"));
return 0;
}
/* CCP config options */
static int
-print_ccp_config_options(const u_char *p, int length)
+print_ccp_config_options(netdissect_options *ndo,
+ const u_char *p, int length)
{
int len, opt;
if (length < 2)
return 0;
- TCHECK2(*p, 2);
+ ND_TCHECK2(*p, 2);
len = p[1];
opt = p[0];
if (length < len)
return 0;
if (len < 2) {
- printf("\n\t %s Option (0x%02x), length %u (bogus, should be >= 2)",
- tok2str(ccpconfopts_values, "Unknown", opt),
- opt,
- len);
- return 0;
- }
+ ND_PRINT((ndo, "\n\t %s Option (0x%02x), length %u (length bogus, should be >= 2)",
+ tok2str(ccpconfopts_values, "Unknown", opt),
+ opt,
+ len));
+ return 0;
+ }
- printf("\n\t %s Option (0x%02x), length %u:",
- tok2str(ccpconfopts_values, "Unknown", opt),
- opt,
- len);
+ ND_PRINT((ndo, "\n\t %s Option (0x%02x), length %u",
+ tok2str(ccpconfopts_values, "Unknown", opt),
+ opt,
+ len));
switch (opt) {
- /* fall through --> default: nothing supported yet */
+ case CCPOPT_BSDCOMP:
+ if (len < 3) {
+ ND_PRINT((ndo, " (length bogus, should be >= 3)"));
+ return len;
+ }
+ ND_TCHECK2(*(p + 2), 1);
+ ND_PRINT((ndo, ": Version: %u, Dictionary Bits: %u",
+ p[2] >> 5, p[2] & 0x1f));
+ break;
+ case CCPOPT_MVRCA:
+ if (len < 4) {
+ ND_PRINT((ndo, " (length bogus, should be >= 4)"));
+ return len;
+ }
+ ND_TCHECK2(*(p + 2), 1);
+ ND_PRINT((ndo, ": Features: %u, PxP: %s, History: %u, #CTX-ID: %u",
+ (p[2] & 0xc0) >> 6,
+ (p[2] & 0x20) ? "Enabled" : "Disabled",
+ p[2] & 0x1f, p[3]));
+ break;
+ case CCPOPT_DEFLATE:
+ if (len < 4) {
+ ND_PRINT((ndo, " (length bogus, should be >= 4)"));
+ return len;
+ }
+ ND_TCHECK2(*(p + 2), 1);
+ ND_PRINT((ndo, ": Window: %uK, Method: %s (0x%x), MBZ: %u, CHK: %u",
+ (p[2] & 0xf0) >> 4,
+ ((p[2] & 0x0f) == 8) ? "zlib" : "unkown",
+ p[2] & 0x0f, (p[3] & 0xfc) >> 2, p[3] & 0x03));
+ break;
+
+/* XXX: to be supported */
+#if 0
case CCPOPT_OUI:
case CCPOPT_PRED1:
case CCPOPT_PRED2:
@@ -1199,82 +1284,98 @@ print_ccp_config_options(const u_char *p, int length)
case CCPOPT_MPPC:
case CCPOPT_GFZA:
case CCPOPT_V42BIS:
- case CCPOPT_BSDCOMP:
case CCPOPT_LZSDCP:
- case CCPOPT_MVRCA:
case CCPOPT_DEC:
- case CCPOPT_DEFLATE:
case CCPOPT_RESV:
+ break;
+#endif
default:
- if(vflag<2)
- print_unknown_data(&p[2],"\n\t ",len-2);
+ /*
+ * Unknown option; dump it as raw bytes now if we're
+ * not going to do so below.
+ */
+ if (ndo->ndo_vflag < 2)
+ print_unknown_data(ndo, &p[2], "\n\t ", len - 2);
break;
}
- if (vflag>1)
- print_unknown_data(&p[2],"\n\t ",len-2); /* exclude TLV header */
+ if (ndo->ndo_vflag > 1)
+ print_unknown_data(ndo, &p[2], "\n\t ", len - 2); /* exclude TLV header */
return len;
trunc:
- printf("[|ccp]");
+ ND_PRINT((ndo, "[|ccp]"));
return 0;
}
/* BACP config options */
static int
-print_bacp_config_options(const u_char *p, int length)
+print_bacp_config_options(netdissect_options *ndo,
+ const u_char *p, int length)
{
int len, opt;
if (length < 2)
return 0;
- TCHECK2(*p, 2);
+ ND_TCHECK2(*p, 2);
len = p[1];
opt = p[0];
if (length < len)
return 0;
if (len < 2) {
- printf("\n\t %s Option (0x%02x), length %u (bogus, should be >= 2)",
- tok2str(bacconfopts_values, "Unknown", opt),
- opt,
- len);
- return 0;
- }
+ ND_PRINT((ndo, "\n\t %s Option (0x%02x), length %u (length bogus, should be >= 2)",
+ tok2str(bacconfopts_values, "Unknown", opt),
+ opt,
+ len));
+ return 0;
+ }
- printf("\n\t %s Option (0x%02x), length %u:",
- tok2str(bacconfopts_values, "Unknown", opt),
- opt,
- len);
+ ND_PRINT((ndo, "\n\t %s Option (0x%02x), length %u",
+ tok2str(bacconfopts_values, "Unknown", opt),
+ opt,
+ len));
switch (opt) {
case BACPOPT_FPEER:
- TCHECK2(*(p + 2), 4);
- printf(", Magic-Num 0x%08x", EXTRACT_32BITS(p + 2));
- break;
+ if (len != 6) {
+ ND_PRINT((ndo, " (length bogus, should be = 6)"));
+ return len;
+ }
+ ND_TCHECK2(*(p + 2), 4);
+ ND_PRINT((ndo, ": Magic-Num 0x%08x", EXTRACT_32BITS(p + 2)));
+ break;
default:
- if(vflag<2)
- print_unknown_data(&p[2],"\n\t ",len-2);
+ /*
+ * Unknown option; dump it as raw bytes now if we're
+ * not going to do so below.
+ */
+ if (ndo->ndo_vflag < 2)
+ print_unknown_data(ndo, &p[2], "\n\t ", len - 2);
break;
}
- if (vflag>1)
- print_unknown_data(&p[2],"\n\t ",len-2); /* exclude TLV header */
+ if (ndo->ndo_vflag > 1)
+ print_unknown_data(ndo, &p[2], "\n\t ", len - 2); /* exclude TLV header */
return len;
trunc:
- printf("[|bacp]");
+ ND_PRINT((ndo, "[|bacp]"));
return 0;
}
-
static void
-ppp_hdlc(const u_char *p, int length)
+ppp_hdlc(netdissect_options *ndo,
+ const u_char *p, int length)
{
- u_char *b, *s, *t, c;
+ u_char *b, *t, c;
+ const u_char *s;
int i, proto;
const void *se;
- b = (u_int8_t *)malloc(length);
+ if (length <= 0)
+ return;
+
+ b = (u_char *)malloc(length);
if (b == NULL)
return;
@@ -1283,64 +1384,74 @@ ppp_hdlc(const u_char *p, int length)
* Do this so that we dont overwrite the original packet
* contents.
*/
- for (s = (u_char *)p, t = b, i = length; i > 0; i--) {
+ for (s = p, t = b, i = length; i > 0 && ND_TTEST(*s); i--) {
c = *s++;
if (c == 0x7d) {
- if (i > 1) {
- i--;
- c = *s++ ^ 0x20;
- } else
- continue;
+ if (i <= 1 || !ND_TTEST(*s))
+ break;
+ i--;
+ c = *s++ ^ 0x20;
}
*t++ = c;
}
- se = snapend;
- snapend = t;
+ se = ndo->ndo_snapend;
+ ndo->ndo_snapend = t;
+ length = t - b;
/* now lets guess about the payload codepoint format */
+ if (length < 1)
+ goto trunc;
proto = *b; /* start with a one-octet codepoint guess */
-
+
switch (proto) {
case PPP_IP:
- ip_print(gndo, b+1, t - b - 1);
+ ip_print(ndo, b + 1, length - 1);
goto cleanup;
-#ifdef INET6
case PPP_IPV6:
- ip6_print(gndo, b+1, t - b - 1);
+ ip6_print(ndo, b + 1, length - 1);
goto cleanup;
-#endif
default: /* no luck - try next guess */
break;
}
+ if (length < 2)
+ goto trunc;
proto = EXTRACT_16BITS(b); /* next guess - load two octets */
switch (proto) {
case (PPP_ADDRESS << 8 | PPP_CONTROL): /* looks like a PPP frame */
+ if (length < 4)
+ goto trunc;
proto = EXTRACT_16BITS(b+2); /* load the PPP proto-id */
- handle_ppp(proto, b+4, t - b - 4);
+ handle_ppp(ndo, proto, b + 4, length - 4);
break;
default: /* last guess - proto must be a PPP proto-id */
- handle_ppp(proto, b+2, t - b - 2);
+ handle_ppp(ndo, proto, b + 2, length - 2);
break;
}
cleanup:
- snapend = se;
+ ndo->ndo_snapend = se;
free(b);
return;
+
+trunc:
+ ndo->ndo_snapend = se;
+ free(b);
+ ND_PRINT((ndo, "[|ppp]"));
}
/* PPP */
static void
-handle_ppp(u_int proto, const u_char *p, int length)
+handle_ppp(netdissect_options *ndo,
+ u_int proto, const u_char *p, int length)
{
- if ((proto & 0xff00) == 0x7e00) {/* is this an escape code ? */
- ppp_hdlc(p-1, length);
- return;
- }
+ if ((proto & 0xff00) == 0x7e00) { /* is this an escape code ? */
+ ppp_hdlc(ndo, p - 1, length);
+ return;
+ }
switch (proto) {
case PPP_LCP: /* fall through */
@@ -1350,55 +1461,54 @@ handle_ppp(u_int proto, const u_char *p, int length)
case PPP_IPV6CP:
case PPP_CCP:
case PPP_BACP:
- handle_ctrl_proto(proto, p, length);
+ handle_ctrl_proto(ndo, proto, p, length);
+ break;
+ case PPP_ML:
+ handle_mlppp(ndo, p, length);
break;
- case PPP_ML:
- handle_mlppp(p, length);
- break;
case PPP_CHAP:
- handle_chap(p, length);
+ handle_chap(ndo, p, length);
break;
case PPP_PAP:
- handle_pap(p, length);
+ handle_pap(ndo, p, length);
break;
case PPP_BAP: /* XXX: not yet completed */
- handle_bap(p, length);
+ handle_bap(ndo, p, length);
break;
case ETHERTYPE_IP: /*XXX*/
case PPP_VJNC:
case PPP_IP:
- ip_print(gndo, p, length);
+ ip_print(ndo, p, length);
break;
-#ifdef INET6
case ETHERTYPE_IPV6: /*XXX*/
case PPP_IPV6:
- ip6_print(gndo, p, length);
+ ip6_print(ndo, p, length);
break;
-#endif
case ETHERTYPE_IPX: /*XXX*/
case PPP_IPX:
- ipx_print(p, length);
+ ipx_print(ndo, p, length);
break;
case PPP_OSI:
- isoclns_print(p, length, length);
- break;
+ isoclns_print(ndo, p, length, length);
+ break;
case PPP_MPLS_UCAST:
case PPP_MPLS_MCAST:
- mpls_print(p, length);
+ mpls_print(ndo, p, length);
break;
case PPP_COMP:
- printf("compressed PPP data");
+ ND_PRINT((ndo, "compressed PPP data"));
break;
default:
- printf("%s ", tok2str(ppptype2str, "unknown PPP protocol (0x%04x)", proto));
- print_unknown_data(p,"\n\t",length);
+ ND_PRINT((ndo, "%s ", tok2str(ppptype2str, "unknown PPP protocol (0x%04x)", proto)));
+ print_unknown_data(ndo, p, "\n\t", length);
break;
}
}
/* Standard PPP printer */
u_int
-ppp_print(register const u_char *p, u_int length)
+ppp_print(netdissect_options *ndo,
+ register const u_char *p, u_int length)
{
u_int proto,ppp_header;
u_int olen = length; /* _o_riginal length */
@@ -1410,18 +1520,18 @@ ppp_print(register const u_char *p, u_int length)
*/
if (length < 2)
goto trunc;
- TCHECK2(*p, 2);
+ ND_TCHECK2(*p, 2);
ppp_header = EXTRACT_16BITS(p);
switch(ppp_header) {
case (PPP_WITHDIRECTION_IN << 8 | PPP_CONTROL):
- if (eflag) printf("In ");
+ if (ndo->ndo_eflag) ND_PRINT((ndo, "In "));
p += 2;
length -= 2;
hdr_len += 2;
break;
case (PPP_WITHDIRECTION_OUT << 8 | PPP_CONTROL):
- if (eflag) printf("Out ");
+ if (ndo->ndo_eflag) ND_PRINT((ndo, "Out "));
p += 2;
length -= 2;
hdr_len += 2;
@@ -1438,43 +1548,44 @@ ppp_print(register const u_char *p, u_int length)
if (length < 2)
goto trunc;
- TCHECK(*p);
+ ND_TCHECK(*p);
if (*p % 2) {
proto = *p; /* PFC is used */
p++;
length--;
hdr_len++;
} else {
- TCHECK2(*p, 2);
+ ND_TCHECK2(*p, 2);
proto = EXTRACT_16BITS(p);
p += 2;
length -= 2;
hdr_len += 2;
}
- if (eflag)
- printf("%s (0x%04x), length %u: ",
- tok2str(ppptype2str, "unknown", proto),
- proto,
- olen);
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, "%s (0x%04x), length %u: ",
+ tok2str(ppptype2str, "unknown", proto),
+ proto,
+ olen));
- handle_ppp(proto, p, length);
+ handle_ppp(ndo, proto, p, length);
return (hdr_len);
trunc:
- printf("[|ppp]");
+ ND_PRINT((ndo, "[|ppp]"));
return (0);
}
/* PPP I/F printer */
u_int
-ppp_if_print(const struct pcap_pkthdr *h, register const u_char *p)
+ppp_if_print(netdissect_options *ndo,
+ const struct pcap_pkthdr *h, register const u_char *p)
{
register u_int length = h->len;
register u_int caplen = h->caplen;
if (caplen < PPP_HDRLEN) {
- printf("[|ppp]");
+ ND_PRINT((ndo, "[|ppp]"));
return (caplen);
}
@@ -1515,11 +1626,11 @@ ppp_if_print(const struct pcap_pkthdr *h, register const u_char *p)
* (Is the Cisco framing in question what DLT_C_HDLC, in
* BSD/OS, is?)
*/
- if (eflag)
- printf("%c %4d %02x ", p[0] ? 'O' : 'I', length, p[1]);
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, "%c %4d %02x ", p[0] ? 'O' : 'I', length, p[1]));
#endif
- ppp_print(p, length);
+ ppp_print(ndo, p, length);
return (0);
}
@@ -1534,7 +1645,8 @@ ppp_if_print(const struct pcap_pkthdr *h, register const u_char *p)
* This handles, for example, DLT_PPP_SERIAL in NetBSD.
*/
u_int
-ppp_hdlc_if_print(const struct pcap_pkthdr *h, register const u_char *p)
+ppp_hdlc_if_print(netdissect_options *ndo,
+ const struct pcap_pkthdr *h, register const u_char *p)
{
register u_int length = h->len;
register u_int caplen = h->caplen;
@@ -1542,7 +1654,7 @@ ppp_hdlc_if_print(const struct pcap_pkthdr *h, register const u_char *p)
u_int hdrlen = 0;
if (caplen < 2) {
- printf("[|ppp]");
+ ND_PRINT((ndo, "[|ppp]"));
return (caplen);
}
@@ -1550,12 +1662,12 @@ ppp_hdlc_if_print(const struct pcap_pkthdr *h, register const u_char *p)
case PPP_ADDRESS:
if (caplen < 4) {
- printf("[|ppp]");
+ ND_PRINT((ndo, "[|ppp]"));
return (caplen);
}
- if (eflag)
- printf("%02x %02x %d ", p[0], p[1], length);
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, "%02x %02x %d ", p[0], p[1], length));
p += 2;
length -= 2;
hdrlen += 2;
@@ -1564,20 +1676,24 @@ ppp_hdlc_if_print(const struct pcap_pkthdr *h, register const u_char *p)
p += 2;
length -= 2;
hdrlen += 2;
- printf("%s: ", tok2str(ppptype2str, "unknown PPP protocol (0x%04x)", proto));
+ ND_PRINT((ndo, "%s: ", tok2str(ppptype2str, "unknown PPP protocol (0x%04x)", proto)));
- handle_ppp(proto, p, length);
+ handle_ppp(ndo, proto, p, length);
break;
case CHDLC_UNICAST:
case CHDLC_BCAST:
- return (chdlc_if_print(h, p));
+ return (chdlc_if_print(ndo, h, p));
default:
- if (eflag)
- printf("%02x %02x %d ", p[0], p[1], length);
+ if (caplen < 4) {
+ ND_PRINT((ndo, "[|ppp]"));
+ return (caplen);
+ }
+
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, "%02x %02x %d ", p[0], p[1], length));
p += 2;
- length -= 2;
hdrlen += 2;
/*
@@ -1585,7 +1701,7 @@ ppp_hdlc_if_print(const struct pcap_pkthdr *h, register const u_char *p)
* the next two octets as an Ethernet type; does that
* ever happen?
*/
- printf("unknown addr %02x; ctrl %02x", p[0], p[1]);
+ ND_PRINT((ndo, "unknown addr %02x; ctrl %02x", p[0], p[1]));
break;
}
@@ -1596,18 +1712,19 @@ ppp_hdlc_if_print(const struct pcap_pkthdr *h, register const u_char *p)
/* BSD/OS specific PPP printer */
u_int
-ppp_bsdos_if_print(const struct pcap_pkthdr *h _U_, register const u_char *p _U_)
+ppp_bsdos_if_print(netdissect_options *ndo _U_,
+ const struct pcap_pkthdr *h _U_, register const u_char *p _U_)
{
register int hdrlength;
#ifdef __bsdi__
register u_int length = h->len;
register u_int caplen = h->caplen;
- u_int16_t ptype;
+ uint16_t ptype;
const u_char *q;
int i;
if (caplen < PPP_BSDI_HDRLEN) {
- printf("[|ppp]");
+ ND_PRINT((ndo, "[|ppp]"));
return (caplen)
}
@@ -1615,34 +1732,34 @@ ppp_bsdos_if_print(const struct pcap_pkthdr *h _U_, register const u_char *p _U_
#if 0
if (p[0] == PPP_ADDRESS && p[1] == PPP_CONTROL) {
- if (eflag)
- printf("%02x %02x ", p[0], p[1]);
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, "%02x %02x ", p[0], p[1]));
p += 2;
hdrlength = 2;
}
- if (eflag)
- printf("%d ", length);
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, "%d ", length));
/* Retrieve the protocol type */
if (*p & 01) {
/* Compressed protocol field */
ptype = *p;
- if (eflag)
- printf("%02x ", ptype);
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, "%02x ", ptype));
p++;
hdrlength += 1;
} else {
/* Un-compressed protocol field */
ptype = EXTRACT_16BITS(p);
- if (eflag)
- printf("%04x ", ptype);
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, "%04x ", ptype));
p += 2;
hdrlength += 2;
}
#else
ptype = 0; /*XXX*/
- if (eflag)
- printf("%c ", p[SLC_DIR] ? 'O' : 'I');
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, "%c ", p[SLC_DIR] ? 'O' : 'I'));
if (p[SLC_LLHL]) {
/* link level header */
struct ppp_header *ph;
@@ -1651,72 +1768,68 @@ ppp_bsdos_if_print(const struct pcap_pkthdr *h _U_, register const u_char *p _U_
ph = (struct ppp_header *)q;
if (ph->phdr_addr == PPP_ADDRESS
&& ph->phdr_ctl == PPP_CONTROL) {
- if (eflag)
- printf("%02x %02x ", q[0], q[1]);
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, "%02x %02x ", q[0], q[1]));
ptype = EXTRACT_16BITS(&ph->phdr_type);
- if (eflag && (ptype == PPP_VJC || ptype == PPP_VJNC)) {
- printf("%s ", tok2str(ppptype2str,
- "proto-#%d", ptype));
+ if (ndo->ndo_eflag && (ptype == PPP_VJC || ptype == PPP_VJNC)) {
+ ND_PRINT((ndo, "%s ", tok2str(ppptype2str,
+ "proto-#%d", ptype)));
}
} else {
- if (eflag) {
- printf("LLH=[");
+ if (ndo->ndo_eflag) {
+ ND_PRINT((ndo, "LLH=["));
for (i = 0; i < p[SLC_LLHL]; i++)
- printf("%02x", q[i]);
- printf("] ");
+ ND_PRINT((ndo, "%02x", q[i]));
+ ND_PRINT((ndo, "] "));
}
}
}
- if (eflag)
- printf("%d ", length);
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, "%d ", length));
if (p[SLC_CHL]) {
q = p + SLC_BPFHDRLEN + p[SLC_LLHL];
switch (ptype) {
case PPP_VJC:
- ptype = vjc_print(q, ptype);
+ ptype = vjc_print(ndo, q, ptype);
hdrlength = PPP_BSDI_HDRLEN;
p += hdrlength;
switch (ptype) {
case PPP_IP:
- ip_print(gndo, p, length);
+ ip_print(ndo, p, length);
break;
-#ifdef INET6
case PPP_IPV6:
- ip6_print(gndo, p, length);
+ ip6_print(ndo, p, length);
break;
-#endif
case PPP_MPLS_UCAST:
case PPP_MPLS_MCAST:
- mpls_print(p, length);
+ mpls_print(ndo, p, length);
break;
}
goto printx;
case PPP_VJNC:
- ptype = vjc_print(q, ptype);
+ ptype = vjc_print(ndo, q, ptype);
hdrlength = PPP_BSDI_HDRLEN;
p += hdrlength;
switch (ptype) {
case PPP_IP:
- ip_print(gndo, p, length);
+ ip_print(ndo, p, length);
break;
-#ifdef INET6
case PPP_IPV6:
- ip6_print(gndo, p, length);
+ ip6_print(ndo, p, length);
break;
-#endif
case PPP_MPLS_UCAST:
case PPP_MPLS_MCAST:
- mpls_print(p, length);
+ mpls_print(ndo, p, length);
break;
}
goto printx;
default:
- if (eflag) {
- printf("CH=[");
+ if (ndo->ndo_eflag) {
+ ND_PRINT((ndo, "CH=["));
for (i = 0; i < p[SLC_LLHL]; i++)
- printf("%02x", q[i]);
- printf("] ");
+ ND_PRINT((ndo, "%02x", q[i]));
+ ND_PRINT((ndo, "] "));
}
break;
}
@@ -1732,17 +1845,15 @@ ppp_bsdos_if_print(const struct pcap_pkthdr *h _U_, register const u_char *p _U_
case PPP_IP:
ip_print(p, length);
break;
-#ifdef INET6
case PPP_IPV6:
- ip6_print(gndo, p, length);
+ ip6_print(ndo, p, length);
+ break;
+ case PPP_MPLS_UCAST:
+ case PPP_MPLS_MCAST:
+ mpls_print(ndo, p, length);
break;
-#endif
- case PPP_MPLS_UCAST:
- case PPP_MPLS_MCAST:
- mpls_print(gndo, p, length);
- break;
default:
- printf("%s ", tok2str(ppptype2str, "unknown PPP protocol (0x%04x)", ptype));
+ ND_PRINT((ndo, "%s ", tok2str(ppptype2str, "unknown PPP protocol (0x%04x)", ptype)));
}
printx:
@@ -1759,3 +1870,6 @@ printx:
* c-basic-offset: 8
* End:
*/
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-ppp-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-pppoe.c b/freebsd/contrib/tcpdump/print-pppoe.c
index af12682f..de42fbdf 100644
--- a/freebsd/contrib/tcpdump/print-pppoe.c
+++ b/freebsd/contrib/tcpdump/print-pppoe.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
@@ -19,30 +22,20 @@
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Original code by Greg Stark <gsstark@mit.edu>
+ *
+ * Original code by Greg Stark <gsstark@mit.edu>
*/
-#ifndef lint
-static const char rcsid[] _U_ =
-"@(#) $Header: /tcpdump/master/tcpdump/print-pppoe.c,v 1.31 2005-04-26 19:48:38 guy Exp $ (LBL)";
-#endif
+/* \summary: PPP-over-Ethernet (PPPoE) printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include <stdio.h>
-#include <string.h>
-
-#include "interface.h"
-#include "addrtoname.h"
-#include "ppp.h"
-#include "ethertype.h"
-#include "ether.h"
-#include "extract.h" /* must come after interface.h */
+#include "netdissect.h"
+#include "extract.h"
/* Codes */
enum {
@@ -53,7 +46,7 @@ enum {
PPPOE_PADT = 0xa7
};
-static struct tok pppoecode2str[] = {
+static const struct tok pppoecode2str[] = {
{ PPPOE_PADI, "PADI" },
{ PPPOE_PADO, "PADO" },
{ PPPOE_PADR, "PADR" },
@@ -78,7 +71,7 @@ enum {
PPPOE_GENERIC_ERROR = 0x0203
};
-static struct tok pppoetag2str[] = {
+static const struct tok pppoetag2str[] = {
{ PPPOE_EOL, "EOL" },
{ PPPOE_SERVICE_NAME, "Service-Name" },
{ PPPOE_AC_NAME, "AC-Name" },
@@ -97,25 +90,25 @@ static struct tok pppoetag2str[] = {
#define MAXTAGPRINT 80
u_int
-pppoe_if_print(const struct pcap_pkthdr *h, register const u_char *p)
+pppoe_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, register const u_char *p)
{
- return (pppoe_print(p, h->len));
+ return (pppoe_print(ndo, p, h->len));
}
u_int
-pppoe_print(register const u_char *bp, u_int length)
+pppoe_print(netdissect_options *ndo, register const u_char *bp, u_int length)
{
- u_int16_t pppoe_ver, pppoe_type, pppoe_code, pppoe_sessionid;
+ uint16_t pppoe_ver, pppoe_type, pppoe_code, pppoe_sessionid;
u_int pppoe_length;
const u_char *pppoe_packet, *pppoe_payload;
if (length < PPPOE_HDRLEN) {
- (void)printf("truncated-pppoe %u", length);
+ ND_PRINT((ndo, "truncated-pppoe %u", length));
return (length);
}
length -= PPPOE_HDRLEN;
pppoe_packet = bp;
- TCHECK2(*pppoe_packet, PPPOE_HDRLEN);
+ ND_TCHECK2(*pppoe_packet, PPPOE_HDRLEN);
pppoe_ver = (pppoe_packet[0] & 0xF0) >> 4;
pppoe_type = (pppoe_packet[0] & 0x0F);
pppoe_code = pppoe_packet[1];
@@ -124,22 +117,22 @@ pppoe_print(register const u_char *bp, u_int length)
pppoe_payload = pppoe_packet + PPPOE_HDRLEN;
if (pppoe_ver != 1) {
- printf(" [ver %d]",pppoe_ver);
+ ND_PRINT((ndo, " [ver %d]",pppoe_ver));
}
if (pppoe_type != 1) {
- printf(" [type %d]",pppoe_type);
+ ND_PRINT((ndo, " [type %d]",pppoe_type));
}
- printf("PPPoE %s", tok2str(pppoecode2str, "PAD-%x", pppoe_code));
+ ND_PRINT((ndo, "PPPoE %s", tok2str(pppoecode2str, "PAD-%x", pppoe_code)));
if (pppoe_code == PPPOE_PADI && pppoe_length > 1484 - PPPOE_HDRLEN) {
- printf(" [len %u!]",pppoe_length);
+ ND_PRINT((ndo, " [len %u!]",pppoe_length));
}
if (pppoe_length > length) {
- printf(" [len %u > %u!]", pppoe_length, length);
+ ND_PRINT((ndo, " [len %u > %u!]", pppoe_length, length));
pppoe_length = length;
}
if (pppoe_sessionid) {
- printf(" [ses 0x%x]", pppoe_sessionid);
+ ND_PRINT((ndo, " [ses 0x%x]", pppoe_sessionid));
}
if (pppoe_code) {
@@ -153,49 +146,49 @@ pppoe_print(register const u_char *bp, u_int length)
* tag_type is previous tag or 0xffff for first iteration
*/
while (tag_type && p < pppoe_payload + pppoe_length) {
- TCHECK2(*p, 4);
+ ND_TCHECK2(*p, 4);
tag_type = EXTRACT_16BITS(p);
tag_len = EXTRACT_16BITS(p + 2);
p += 4;
/* p points to tag_value */
if (tag_len) {
- unsigned isascii = 0, isgarbage = 0;
+ unsigned ascii_count = 0, garbage_count = 0;
const u_char *v;
char tag_str[MAXTAGPRINT];
unsigned tag_str_len = 0;
/* TODO print UTF-8 decoded text */
- TCHECK2(*p, tag_len);
+ ND_TCHECK2(*p, tag_len);
for (v = p; v < p + tag_len && tag_str_len < MAXTAGPRINT-1; v++)
if (*v >= 32 && *v < 127) {
tag_str[tag_str_len++] = *v;
- isascii++;
+ ascii_count++;
} else {
tag_str[tag_str_len++] = '.';
- isgarbage++;
+ garbage_count++;
}
tag_str[tag_str_len] = 0;
- if (isascii > isgarbage) {
- printf(" [%s \"%*.*s\"]",
+ if (ascii_count > garbage_count) {
+ ND_PRINT((ndo, " [%s \"%*.*s\"]",
tok2str(pppoetag2str, "TAG-0x%x", tag_type),
(int)tag_str_len,
(int)tag_str_len,
- tag_str);
+ tag_str));
} else {
/* Print hex, not fast to abuse printf but this doesn't get used much */
- printf(" [%s 0x", tok2str(pppoetag2str, "TAG-0x%x", tag_type));
+ ND_PRINT((ndo, " [%s 0x", tok2str(pppoetag2str, "TAG-0x%x", tag_type)));
for (v=p; v<p+tag_len; v++) {
- printf("%02X", *v);
+ ND_PRINT((ndo, "%02X", *v));
}
- printf("]");
+ ND_PRINT((ndo, "]"));
}
-
+
} else
- printf(" [%s]", tok2str(pppoetag2str,
- "TAG-0x%x", tag_type));
+ ND_PRINT((ndo, " [%s]", tok2str(pppoetag2str,
+ "TAG-0x%x", tag_type)));
p += tag_len;
/* p points to next tag */
@@ -203,11 +196,14 @@ pppoe_print(register const u_char *bp, u_int length)
return (0);
} else {
/* PPPoE data */
- printf(" ");
- return (PPPOE_HDRLEN + ppp_print(pppoe_payload, pppoe_length));
+ ND_PRINT((ndo, " "));
+ return (PPPOE_HDRLEN + ppp_print(ndo, pppoe_payload, pppoe_length));
}
trunc:
- printf("[|pppoe]");
+ ND_PRINT((ndo, "[|pppoe]"));
return (PPPOE_HDRLEN);
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-pppoe-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-pptp.c b/freebsd/contrib/tcpdump/print-pptp.c
index 27eb7c72..f2a28997 100644
--- a/freebsd/contrib/tcpdump/print-pptp.c
+++ b/freebsd/contrib/tcpdump/print-pptp.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
@@ -23,24 +26,18 @@
* PPTP support contributed by Motonori Shindo (mshindo@mshindo.net)
*/
-
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-pptp.c,v 1.12 2006-06-23 02:03:09 hannes Exp $";
-#endif
+/* \summary: Point-to-Point Tunnelling Protocol (PPTP) printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include <stdio.h>
-
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
-static char tstr[] = " [|pptp]";
+static const char tstr[] = " [|pptp]";
#define PPTP_MSG_TYPE_CTRL 1 /* Control Message */
#define PPTP_MSG_TYPE_MGMT 2 /* Management Message (currently not used */
@@ -93,147 +90,147 @@ static const char *pptp_message_type_string[] = {
/* common for all PPTP control messages */
struct pptp_hdr {
- u_int16_t length;
- u_int16_t msg_type;
- u_int32_t magic_cookie;
- u_int16_t ctrl_msg_type;
- u_int16_t reserved0;
+ uint16_t length;
+ uint16_t msg_type;
+ uint32_t magic_cookie;
+ uint16_t ctrl_msg_type;
+ uint16_t reserved0;
};
struct pptp_msg_sccrq {
- u_int16_t proto_ver;
- u_int16_t reserved1;
- u_int32_t framing_cap;
- u_int32_t bearer_cap;
- u_int16_t max_channel;
- u_int16_t firm_rev;
+ uint16_t proto_ver;
+ uint16_t reserved1;
+ uint32_t framing_cap;
+ uint32_t bearer_cap;
+ uint16_t max_channel;
+ uint16_t firm_rev;
u_char hostname[64];
u_char vendor[64];
};
struct pptp_msg_sccrp {
- u_int16_t proto_ver;
- u_int8_t result_code;
- u_int8_t err_code;
- u_int32_t framing_cap;
- u_int32_t bearer_cap;
- u_int16_t max_channel;
- u_int16_t firm_rev;
+ uint16_t proto_ver;
+ uint8_t result_code;
+ uint8_t err_code;
+ uint32_t framing_cap;
+ uint32_t bearer_cap;
+ uint16_t max_channel;
+ uint16_t firm_rev;
u_char hostname[64];
u_char vendor[64];
};
struct pptp_msg_stopccrq {
- u_int8_t reason;
- u_int8_t reserved1;
- u_int16_t reserved2;
+ uint8_t reason;
+ uint8_t reserved1;
+ uint16_t reserved2;
};
struct pptp_msg_stopccrp {
- u_int8_t result_code;
- u_int8_t err_code;
- u_int16_t reserved1;
+ uint8_t result_code;
+ uint8_t err_code;
+ uint16_t reserved1;
};
struct pptp_msg_echorq {
- u_int32_t id;
+ uint32_t id;
};
struct pptp_msg_echorp {
- u_int32_t id;
- u_int8_t result_code;
- u_int8_t err_code;
- u_int16_t reserved1;
+ uint32_t id;
+ uint8_t result_code;
+ uint8_t err_code;
+ uint16_t reserved1;
};
struct pptp_msg_ocrq {
- u_int16_t call_id;
- u_int16_t call_ser;
- u_int32_t min_bps;
- u_int32_t max_bps;
- u_int32_t bearer_type;
- u_int32_t framing_type;
- u_int16_t recv_winsiz;
- u_int16_t pkt_proc_delay;
- u_int16_t phone_no_len;
- u_int16_t reserved1;
+ uint16_t call_id;
+ uint16_t call_ser;
+ uint32_t min_bps;
+ uint32_t max_bps;
+ uint32_t bearer_type;
+ uint32_t framing_type;
+ uint16_t recv_winsiz;
+ uint16_t pkt_proc_delay;
+ uint16_t phone_no_len;
+ uint16_t reserved1;
u_char phone_no[64];
u_char subaddr[64];
};
struct pptp_msg_ocrp {
- u_int16_t call_id;
- u_int16_t peer_call_id;
- u_int8_t result_code;
- u_int8_t err_code;
- u_int16_t cause_code;
- u_int32_t conn_speed;
- u_int16_t recv_winsiz;
- u_int16_t pkt_proc_delay;
- u_int32_t phy_chan_id;
+ uint16_t call_id;
+ uint16_t peer_call_id;
+ uint8_t result_code;
+ uint8_t err_code;
+ uint16_t cause_code;
+ uint32_t conn_speed;
+ uint16_t recv_winsiz;
+ uint16_t pkt_proc_delay;
+ uint32_t phy_chan_id;
};
struct pptp_msg_icrq {
- u_int16_t call_id;
- u_int16_t call_ser;
- u_int32_t bearer_type;
- u_int32_t phy_chan_id;
- u_int16_t dialed_no_len;
- u_int16_t dialing_no_len;
+ uint16_t call_id;
+ uint16_t call_ser;
+ uint32_t bearer_type;
+ uint32_t phy_chan_id;
+ uint16_t dialed_no_len;
+ uint16_t dialing_no_len;
u_char dialed_no[64]; /* DNIS */
u_char dialing_no[64]; /* CLID */
u_char subaddr[64];
};
struct pptp_msg_icrp {
- u_int16_t call_id;
- u_int16_t peer_call_id;
- u_int8_t result_code;
- u_int8_t err_code;
- u_int16_t recv_winsiz;
- u_int16_t pkt_proc_delay;
- u_int16_t reserved1;
+ uint16_t call_id;
+ uint16_t peer_call_id;
+ uint8_t result_code;
+ uint8_t err_code;
+ uint16_t recv_winsiz;
+ uint16_t pkt_proc_delay;
+ uint16_t reserved1;
};
struct pptp_msg_iccn {
- u_int16_t peer_call_id;
- u_int16_t reserved1;
- u_int32_t conn_speed;
- u_int16_t recv_winsiz;
- u_int16_t pkt_proc_delay;
- u_int32_t framing_type;
+ uint16_t peer_call_id;
+ uint16_t reserved1;
+ uint32_t conn_speed;
+ uint16_t recv_winsiz;
+ uint16_t pkt_proc_delay;
+ uint32_t framing_type;
};
struct pptp_msg_ccrq {
- u_int16_t call_id;
- u_int16_t reserved1;
+ uint16_t call_id;
+ uint16_t reserved1;
};
struct pptp_msg_cdn {
- u_int16_t call_id;
- u_int8_t result_code;
- u_int8_t err_code;
- u_int16_t cause_code;
- u_int16_t reserved1;
+ uint16_t call_id;
+ uint8_t result_code;
+ uint8_t err_code;
+ uint16_t cause_code;
+ uint16_t reserved1;
u_char call_stats[128];
};
struct pptp_msg_wen {
- u_int16_t peer_call_id;
- u_int16_t reserved1;
- u_int32_t crc_err;
- u_int32_t framing_err;
- u_int32_t hardware_overrun;
- u_int32_t buffer_overrun;
- u_int32_t timeout_err;
- u_int32_t align_err;
+ uint16_t peer_call_id;
+ uint16_t reserved1;
+ uint32_t crc_err;
+ uint32_t framing_err;
+ uint32_t hardware_overrun;
+ uint32_t buffer_overrun;
+ uint32_t timeout_err;
+ uint32_t align_err;
};
struct pptp_msg_sli {
- u_int16_t peer_call_id;
- u_int16_t reserved1;
- u_int32_t send_accm;
- u_int32_t recv_accm;
+ uint16_t peer_call_id;
+ uint16_t reserved1;
+ uint32_t send_accm;
+ uint32_t recv_accm;
};
/* attributes that appear more than once in above messages:
@@ -241,27 +238,27 @@ struct pptp_msg_sli {
Number of
occurence attributes
--------------------------------------
- 2 u_int32_t bearer_cap;
- 2 u_int32_t bearer_type;
- 6 u_int16_t call_id;
- 2 u_int16_t call_ser;
- 2 u_int16_t cause_code;
- 2 u_int32_t conn_speed;
- 6 u_int8_t err_code;
- 2 u_int16_t firm_rev;
- 2 u_int32_t framing_cap;
- 2 u_int32_t framing_type;
+ 2 uint32_t bearer_cap;
+ 2 uint32_t bearer_type;
+ 6 uint16_t call_id;
+ 2 uint16_t call_ser;
+ 2 uint16_t cause_code;
+ 2 uint32_t conn_speed;
+ 6 uint8_t err_code;
+ 2 uint16_t firm_rev;
+ 2 uint32_t framing_cap;
+ 2 uint32_t framing_type;
2 u_char hostname[64];
- 2 u_int32_t id;
- 2 u_int16_t max_channel;
- 5 u_int16_t peer_call_id;
- 2 u_int32_t phy_chan_id;
- 4 u_int16_t pkt_proc_delay;
- 2 u_int16_t proto_ver;
- 4 u_int16_t recv_winsiz;
- 2 u_int8_t reserved1;
- 9 u_int16_t reserved1;
- 6 u_int8_t result_code;
+ 2 uint32_t id;
+ 2 uint16_t max_channel;
+ 5 uint16_t peer_call_id;
+ 2 uint32_t phy_chan_id;
+ 4 uint16_t pkt_proc_delay;
+ 2 uint16_t proto_ver;
+ 4 uint16_t recv_winsiz;
+ 2 uint8_t reserved1;
+ 9 uint16_t reserved1;
+ 6 uint8_t result_code;
2 u_char subaddr[64];
2 u_char vendor[64];
@@ -274,781 +271,733 @@ struct pptp_msg_sli {
/******************************************/
/* In these attribute-specific print-out functions, it't not necessary
- to do TCHECK because they are already checked in the caller of
+ to do ND_TCHECK because they are already checked in the caller of
these functions. */
static void
-pptp_bearer_cap_print(const u_int32_t *bearer_cap)
+pptp_bearer_cap_print(netdissect_options *ndo,
+ const uint32_t *bearer_cap)
{
- printf(" BEARER_CAP(");
- if (EXTRACT_32BITS(bearer_cap) & PPTP_BEARER_CAP_DIGITAL_MASK) {
- printf("D");
- }
- if (EXTRACT_32BITS(bearer_cap) & PPTP_BEARER_CAP_ANALOG_MASK) {
- printf("A");
- }
- printf(")");
+ ND_PRINT((ndo, " BEARER_CAP(%s%s)",
+ EXTRACT_32BITS(bearer_cap) & PPTP_BEARER_CAP_DIGITAL_MASK ? "D" : "",
+ EXTRACT_32BITS(bearer_cap) & PPTP_BEARER_CAP_ANALOG_MASK ? "A" : ""));
}
+static const struct tok pptp_btype_str[] = {
+ { 1, "A" }, /* Analog */
+ { 2, "D" }, /* Digital */
+ { 3, "Any" },
+ { 0, NULL }
+};
+
static void
-pptp_bearer_type_print(const u_int32_t *bearer_type)
+pptp_bearer_type_print(netdissect_options *ndo,
+ const uint32_t *bearer_type)
{
- printf(" BEARER_TYPE(");
- switch (EXTRACT_32BITS(bearer_type)) {
- case 1:
- printf("A"); /* Analog */
- break;
- case 2:
- printf("D"); /* Digital */
- break;
- case 3:
- printf("Any");
- break;
- default:
- printf("?");
- break;
- }
- printf(")");
+ ND_PRINT((ndo, " BEARER_TYPE(%s)",
+ tok2str(pptp_btype_str, "?", EXTRACT_32BITS(bearer_type))));
}
static void
-pptp_call_id_print(const u_int16_t *call_id)
+pptp_call_id_print(netdissect_options *ndo,
+ const uint16_t *call_id)
{
- printf(" CALL_ID(%u)", EXTRACT_16BITS(call_id));
+ ND_PRINT((ndo, " CALL_ID(%u)", EXTRACT_16BITS(call_id)));
}
static void
-pptp_call_ser_print(const u_int16_t *call_ser)
+pptp_call_ser_print(netdissect_options *ndo,
+ const uint16_t *call_ser)
{
- printf(" CALL_SER_NUM(%u)", EXTRACT_16BITS(call_ser));
+ ND_PRINT((ndo, " CALL_SER_NUM(%u)", EXTRACT_16BITS(call_ser)));
}
static void
-pptp_cause_code_print(const u_int16_t *cause_code)
+pptp_cause_code_print(netdissect_options *ndo,
+ const uint16_t *cause_code)
{
- printf(" CAUSE_CODE(%u)", EXTRACT_16BITS(cause_code));
+ ND_PRINT((ndo, " CAUSE_CODE(%u)", EXTRACT_16BITS(cause_code)));
}
static void
-pptp_conn_speed_print(const u_int32_t *conn_speed)
+pptp_conn_speed_print(netdissect_options *ndo,
+ const uint32_t *conn_speed)
{
- printf(" CONN_SPEED(%u)", EXTRACT_32BITS(conn_speed));
+ ND_PRINT((ndo, " CONN_SPEED(%u)", EXTRACT_32BITS(conn_speed)));
}
+static const struct tok pptp_errcode_str[] = {
+ { 0, "None" },
+ { 1, "Not-Connected" },
+ { 2, "Bad-Format" },
+ { 3, "Bad-Value" },
+ { 4, "No-Resource" },
+ { 5, "Bad-Call-ID" },
+ { 6, "PAC-Error" },
+ { 0, NULL }
+};
+
static void
-pptp_err_code_print(const u_int8_t *err_code)
+pptp_err_code_print(netdissect_options *ndo,
+ const uint8_t *err_code)
{
- printf(" ERR_CODE(%u", *err_code);
- if (vflag) {
- switch (*err_code) {
- case 0:
- printf(":None");
- break;
- case 1:
- printf(":Not-Connected");
- break;
- case 2:
- printf(":Bad-Format");
- break;
- case 3:
- printf(":Bad-Valude");
- break;
- case 4:
- printf(":No-Resource");
- break;
- case 5:
- printf(":Bad-Call-ID");
- break;
- case 6:
- printf(":PAC-Error");
- break;
- default:
- printf(":?");
- break;
- }
+ ND_PRINT((ndo, " ERR_CODE(%u", *err_code));
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo, ":%s", tok2str(pptp_errcode_str, "?", *err_code)));
}
- printf(")");
+ ND_PRINT((ndo, ")"));
}
static void
-pptp_firm_rev_print(const u_int16_t *firm_rev)
+pptp_firm_rev_print(netdissect_options *ndo,
+ const uint16_t *firm_rev)
{
- printf(" FIRM_REV(%u)", EXTRACT_16BITS(firm_rev));
+ ND_PRINT((ndo, " FIRM_REV(%u)", EXTRACT_16BITS(firm_rev)));
}
static void
-pptp_framing_cap_print(const u_int32_t *framing_cap)
+pptp_framing_cap_print(netdissect_options *ndo,
+ const uint32_t *framing_cap)
{
- printf(" FRAME_CAP(");
+ ND_PRINT((ndo, " FRAME_CAP("));
if (EXTRACT_32BITS(framing_cap) & PPTP_FRAMING_CAP_ASYNC_MASK) {
- printf("A"); /* Async */
+ ND_PRINT((ndo, "A")); /* Async */
}
if (EXTRACT_32BITS(framing_cap) & PPTP_FRAMING_CAP_SYNC_MASK) {
- printf("S"); /* Sync */
+ ND_PRINT((ndo, "S")); /* Sync */
}
- printf(")");
+ ND_PRINT((ndo, ")"));
}
+static const struct tok pptp_ftype_str[] = {
+ { 1, "A" }, /* Async */
+ { 2, "S" }, /* Sync */
+ { 3, "E" }, /* Either */
+ { 0, NULL }
+};
+
static void
-pptp_framing_type_print(const u_int32_t *framing_type)
+pptp_framing_type_print(netdissect_options *ndo,
+ const uint32_t *framing_type)
{
- printf(" FRAME_TYPE(");
- switch (EXTRACT_32BITS(framing_type)) {
- case 1:
- printf("A"); /* Async */
- break;
- case 2:
- printf("S"); /* Sync */
- break;
- case 3:
- printf("E"); /* Either */
- break;
- default:
- printf("?");
- break;
- }
- printf(")");
+ ND_PRINT((ndo, " FRAME_TYPE(%s)",
+ tok2str(pptp_ftype_str, "?", EXTRACT_32BITS(framing_type))));
}
static void
-pptp_hostname_print(const u_char *hostname)
+pptp_hostname_print(netdissect_options *ndo,
+ const u_char *hostname)
{
- printf(" HOSTNAME(%.64s)", hostname);
+ ND_PRINT((ndo, " HOSTNAME(%.64s)", hostname));
}
static void
-pptp_id_print(const u_int32_t *id)
+pptp_id_print(netdissect_options *ndo,
+ const uint32_t *id)
{
- printf(" ID(%u)", EXTRACT_32BITS(id));
+ ND_PRINT((ndo, " ID(%u)", EXTRACT_32BITS(id)));
}
static void
-pptp_max_channel_print(const u_int16_t *max_channel)
+pptp_max_channel_print(netdissect_options *ndo,
+ const uint16_t *max_channel)
{
- printf(" MAX_CHAN(%u)", EXTRACT_16BITS(max_channel));
+ ND_PRINT((ndo, " MAX_CHAN(%u)", EXTRACT_16BITS(max_channel)));
}
static void
-pptp_peer_call_id_print(const u_int16_t *peer_call_id)
+pptp_peer_call_id_print(netdissect_options *ndo,
+ const uint16_t *peer_call_id)
{
- printf(" PEER_CALL_ID(%u)", EXTRACT_16BITS(peer_call_id));
+ ND_PRINT((ndo, " PEER_CALL_ID(%u)", EXTRACT_16BITS(peer_call_id)));
}
static void
-pptp_phy_chan_id_print(const u_int32_t *phy_chan_id)
+pptp_phy_chan_id_print(netdissect_options *ndo,
+ const uint32_t *phy_chan_id)
{
- printf(" PHY_CHAN_ID(%u)", EXTRACT_32BITS(phy_chan_id));
+ ND_PRINT((ndo, " PHY_CHAN_ID(%u)", EXTRACT_32BITS(phy_chan_id)));
}
static void
-pptp_pkt_proc_delay_print(const u_int16_t *pkt_proc_delay)
+pptp_pkt_proc_delay_print(netdissect_options *ndo,
+ const uint16_t *pkt_proc_delay)
{
- printf(" PROC_DELAY(%u)", EXTRACT_16BITS(pkt_proc_delay));
+ ND_PRINT((ndo, " PROC_DELAY(%u)", EXTRACT_16BITS(pkt_proc_delay)));
}
static void
-pptp_proto_ver_print(const u_int16_t *proto_ver)
+pptp_proto_ver_print(netdissect_options *ndo,
+ const uint16_t *proto_ver)
{
- printf(" PROTO_VER(%u.%u)", /* Version.Revision */
+ ND_PRINT((ndo, " PROTO_VER(%u.%u)", /* Version.Revision */
EXTRACT_16BITS(proto_ver) >> 8,
- EXTRACT_16BITS(proto_ver) & 0xff);
+ EXTRACT_16BITS(proto_ver) & 0xff));
}
static void
-pptp_recv_winsiz_print(const u_int16_t *recv_winsiz)
+pptp_recv_winsiz_print(netdissect_options *ndo,
+ const uint16_t *recv_winsiz)
{
- printf(" RECV_WIN(%u)", EXTRACT_16BITS(recv_winsiz));
+ ND_PRINT((ndo, " RECV_WIN(%u)", EXTRACT_16BITS(recv_winsiz)));
}
+static const struct tok pptp_scrrp_str[] = {
+ { 1, "Successful channel establishment" },
+ { 2, "General error" },
+ { 3, "Command channel already exists" },
+ { 4, "Requester is not authorized to establish a command channel" },
+ { 5, "The protocol version of the requester is not supported" },
+ { 0, NULL }
+};
+
+static const struct tok pptp_echorp_str[] = {
+ { 1, "OK" },
+ { 2, "General Error" },
+ { 0, NULL }
+};
+
+static const struct tok pptp_ocrp_str[] = {
+ { 1, "Connected" },
+ { 2, "General Error" },
+ { 3, "No Carrier" },
+ { 4, "Busy" },
+ { 5, "No Dial Tone" },
+ { 6, "Time-out" },
+ { 7, "Do Not Accept" },
+ { 0, NULL }
+};
+
+static const struct tok pptp_icrp_str[] = {
+ { 1, "Connect" },
+ { 2, "General Error" },
+ { 3, "Do Not Accept" },
+ { 0, NULL }
+};
+
+static const struct tok pptp_cdn_str[] = {
+ { 1, "Lost Carrier" },
+ { 2, "General Error" },
+ { 3, "Admin Shutdown" },
+ { 4, "Request" },
+ { 0, NULL }
+};
+
static void
-pptp_result_code_print(const u_int8_t *result_code, int ctrl_msg_type)
-{
- printf(" RESULT_CODE(%u", *result_code);
- if (vflag) {
- switch (ctrl_msg_type) {
- case PPTP_CTRL_MSG_TYPE_SCCRP:
- switch (*result_code) {
- case 1:
- printf(":Successful channel establishment");
- break;
- case 2:
- printf(":General error");
- break;
- case 3:
- printf(":Command channel already exists");
- break;
- case 4:
- printf(":Requester is not authorized to establish a command channel");
- break;
- case 5:
- printf(":The protocol version of the requester is not supported");
- break;
- default:
- printf(":?");
- break;
- }
- break;
- case PPTP_CTRL_MSG_TYPE_StopCCRP:
- case PPTP_CTRL_MSG_TYPE_ECHORP:
- switch (*result_code) {
- case 1:
- printf(":OK");
- break;
- case 2:
- printf(":General Error");
- break;
- default:
- printf(":?");
- break;
- }
- break;
- case PPTP_CTRL_MSG_TYPE_OCRP:
- switch (*result_code) {
- case 1:
- printf(":Connected");
- break;
- case 2:
- printf(":General Error");
- break;
- case 3:
- printf(":No Carrier");
- break;
- case 4:
- printf(":Busy");
- break;
- case 5:
- printf(":No Dial Tone");
- break;
- case 6:
- printf(":Time-out");
- break;
- case 7:
- printf(":Do Not Accept");
- break;
- default:
- printf(":?");
- break;
- }
- break;
- case PPTP_CTRL_MSG_TYPE_ICRP:
- switch (*result_code) {
- case 1:
- printf(":Connect");
- break;
- case 2:
- printf(":General Error");
- break;
- case 3:
- printf(":Do Not Accept");
- break;
- default:
- printf(":?");
- break;
- }
- break;
- case PPTP_CTRL_MSG_TYPE_CDN:
- switch (*result_code) {
- case 1:
- printf(":Lost Carrier");
- break;
- case 2:
- printf(":General Error");
- break;
- case 3:
- printf(":Admin Shutdown");
- break;
- case 4:
- printf(":Request");
- default:
- printf(":?");
- break;
- break;
- }
- default:
- /* assertion error */
- break;
- }
+pptp_result_code_print(netdissect_options *ndo,
+ const uint8_t *result_code, int ctrl_msg_type)
+{
+ ND_PRINT((ndo, " RESULT_CODE(%u", *result_code));
+ if (ndo->ndo_vflag) {
+ const struct tok *dict =
+ ctrl_msg_type == PPTP_CTRL_MSG_TYPE_SCCRP ? pptp_scrrp_str :
+ ctrl_msg_type == PPTP_CTRL_MSG_TYPE_StopCCRP ? pptp_echorp_str :
+ ctrl_msg_type == PPTP_CTRL_MSG_TYPE_ECHORP ? pptp_echorp_str :
+ ctrl_msg_type == PPTP_CTRL_MSG_TYPE_OCRP ? pptp_ocrp_str :
+ ctrl_msg_type == PPTP_CTRL_MSG_TYPE_ICRP ? pptp_icrp_str :
+ ctrl_msg_type == PPTP_CTRL_MSG_TYPE_CDN ? pptp_cdn_str :
+ NULL; /* assertion error */
+ if (dict != NULL)
+ ND_PRINT((ndo, ":%s", tok2str(dict, "?", *result_code)));
}
- printf(")");
+ ND_PRINT((ndo, ")"));
}
static void
-pptp_subaddr_print(const u_char *subaddr)
+pptp_subaddr_print(netdissect_options *ndo,
+ const u_char *subaddr)
{
- printf(" SUB_ADDR(%.64s)", subaddr);
+ ND_PRINT((ndo, " SUB_ADDR(%.64s)", subaddr));
}
static void
-pptp_vendor_print(const u_char *vendor)
+pptp_vendor_print(netdissect_options *ndo,
+ const u_char *vendor)
{
- printf(" VENDOR(%.64s)", vendor);
+ ND_PRINT((ndo, " VENDOR(%.64s)", vendor));
}
/************************************/
/* PPTP message print out functions */
/************************************/
static void
-pptp_sccrq_print(const u_char *dat)
-{
- struct pptp_msg_sccrq *ptr = (struct pptp_msg_sccrq *)dat;
-
- TCHECK(ptr->proto_ver);
- pptp_proto_ver_print(&ptr->proto_ver);
- TCHECK(ptr->reserved1);
- TCHECK(ptr->framing_cap);
- pptp_framing_cap_print(&ptr->framing_cap);
- TCHECK(ptr->bearer_cap);
- pptp_bearer_cap_print(&ptr->bearer_cap);
- TCHECK(ptr->max_channel);
- pptp_max_channel_print(&ptr->max_channel);
- TCHECK(ptr->firm_rev);
- pptp_firm_rev_print(&ptr->firm_rev);
- TCHECK(ptr->hostname);
- pptp_hostname_print(&ptr->hostname[0]);
- TCHECK(ptr->vendor);
- pptp_vendor_print(&ptr->vendor[0]);
+pptp_sccrq_print(netdissect_options *ndo,
+ const u_char *dat)
+{
+ const struct pptp_msg_sccrq *ptr = (const struct pptp_msg_sccrq *)dat;
+
+ ND_TCHECK(ptr->proto_ver);
+ pptp_proto_ver_print(ndo, &ptr->proto_ver);
+ ND_TCHECK(ptr->reserved1);
+ ND_TCHECK(ptr->framing_cap);
+ pptp_framing_cap_print(ndo, &ptr->framing_cap);
+ ND_TCHECK(ptr->bearer_cap);
+ pptp_bearer_cap_print(ndo, &ptr->bearer_cap);
+ ND_TCHECK(ptr->max_channel);
+ pptp_max_channel_print(ndo, &ptr->max_channel);
+ ND_TCHECK(ptr->firm_rev);
+ pptp_firm_rev_print(ndo, &ptr->firm_rev);
+ ND_TCHECK(ptr->hostname);
+ pptp_hostname_print(ndo, &ptr->hostname[0]);
+ ND_TCHECK(ptr->vendor);
+ pptp_vendor_print(ndo, &ptr->vendor[0]);
return;
trunc:
- printf("%s", tstr);
-}
-
-static void
-pptp_sccrp_print(const u_char *dat)
-{
- struct pptp_msg_sccrp *ptr = (struct pptp_msg_sccrp *)dat;
-
- TCHECK(ptr->proto_ver);
- pptp_proto_ver_print(&ptr->proto_ver);
- TCHECK(ptr->result_code);
- pptp_result_code_print(&ptr->result_code, PPTP_CTRL_MSG_TYPE_SCCRP);
- TCHECK(ptr->err_code);
- pptp_err_code_print(&ptr->err_code);
- TCHECK(ptr->framing_cap);
- pptp_framing_cap_print(&ptr->framing_cap);
- TCHECK(ptr->bearer_cap);
- pptp_bearer_cap_print(&ptr->bearer_cap);
- TCHECK(ptr->max_channel);
- pptp_max_channel_print(&ptr->max_channel);
- TCHECK(ptr->firm_rev);
- pptp_firm_rev_print(&ptr->firm_rev);
- TCHECK(ptr->hostname);
- pptp_hostname_print(&ptr->hostname[0]);
- TCHECK(ptr->vendor);
- pptp_vendor_print(&ptr->vendor[0]);
+ ND_PRINT((ndo, "%s", tstr));
+}
+
+static void
+pptp_sccrp_print(netdissect_options *ndo,
+ const u_char *dat)
+{
+ const struct pptp_msg_sccrp *ptr = (const struct pptp_msg_sccrp *)dat;
+
+ ND_TCHECK(ptr->proto_ver);
+ pptp_proto_ver_print(ndo, &ptr->proto_ver);
+ ND_TCHECK(ptr->result_code);
+ pptp_result_code_print(ndo, &ptr->result_code, PPTP_CTRL_MSG_TYPE_SCCRP);
+ ND_TCHECK(ptr->err_code);
+ pptp_err_code_print(ndo, &ptr->err_code);
+ ND_TCHECK(ptr->framing_cap);
+ pptp_framing_cap_print(ndo, &ptr->framing_cap);
+ ND_TCHECK(ptr->bearer_cap);
+ pptp_bearer_cap_print(ndo, &ptr->bearer_cap);
+ ND_TCHECK(ptr->max_channel);
+ pptp_max_channel_print(ndo, &ptr->max_channel);
+ ND_TCHECK(ptr->firm_rev);
+ pptp_firm_rev_print(ndo, &ptr->firm_rev);
+ ND_TCHECK(ptr->hostname);
+ pptp_hostname_print(ndo, &ptr->hostname[0]);
+ ND_TCHECK(ptr->vendor);
+ pptp_vendor_print(ndo, &ptr->vendor[0]);
return;
trunc:
- printf("%s", tstr);
+ ND_PRINT((ndo, "%s", tstr));
}
static void
-pptp_stopccrq_print(const u_char *dat)
+pptp_stopccrq_print(netdissect_options *ndo,
+ const u_char *dat)
{
- struct pptp_msg_stopccrq *ptr = (struct pptp_msg_stopccrq *)dat;
+ const struct pptp_msg_stopccrq *ptr = (const struct pptp_msg_stopccrq *)dat;
- TCHECK(ptr->reason);
- printf(" REASON(%u", ptr->reason);
- if (vflag) {
+ ND_TCHECK(ptr->reason);
+ ND_PRINT((ndo, " REASON(%u", ptr->reason));
+ if (ndo->ndo_vflag) {
switch (ptr->reason) {
case 1:
- printf(":None");
+ ND_PRINT((ndo, ":None"));
break;
case 2:
- printf(":Stop-Protocol");
+ ND_PRINT((ndo, ":Stop-Protocol"));
break;
case 3:
- printf(":Stop-Local-Shutdown");
+ ND_PRINT((ndo, ":Stop-Local-Shutdown"));
break;
default:
- printf(":?");
+ ND_PRINT((ndo, ":?"));
break;
}
}
- printf(")");
- TCHECK(ptr->reserved1);
- TCHECK(ptr->reserved2);
+ ND_PRINT((ndo, ")"));
+ ND_TCHECK(ptr->reserved1);
+ ND_TCHECK(ptr->reserved2);
return;
trunc:
- printf("%s", tstr);
+ ND_PRINT((ndo, "%s", tstr));
}
static void
-pptp_stopccrp_print(const u_char *dat)
+pptp_stopccrp_print(netdissect_options *ndo,
+ const u_char *dat)
{
- struct pptp_msg_stopccrp *ptr = (struct pptp_msg_stopccrp *)dat;
+ const struct pptp_msg_stopccrp *ptr = (const struct pptp_msg_stopccrp *)dat;
- TCHECK(ptr->result_code);
- pptp_result_code_print(&ptr->result_code, PPTP_CTRL_MSG_TYPE_StopCCRP);
- TCHECK(ptr->err_code);
- pptp_err_code_print(&ptr->err_code);
- TCHECK(ptr->reserved1);
+ ND_TCHECK(ptr->result_code);
+ pptp_result_code_print(ndo, &ptr->result_code, PPTP_CTRL_MSG_TYPE_StopCCRP);
+ ND_TCHECK(ptr->err_code);
+ pptp_err_code_print(ndo, &ptr->err_code);
+ ND_TCHECK(ptr->reserved1);
return;
trunc:
- printf("%s", tstr);
+ ND_PRINT((ndo, "%s", tstr));
}
static void
-pptp_echorq_print(const u_char *dat)
+pptp_echorq_print(netdissect_options *ndo,
+ const u_char *dat)
{
- struct pptp_msg_echorq *ptr = (struct pptp_msg_echorq *)dat;
+ const struct pptp_msg_echorq *ptr = (const struct pptp_msg_echorq *)dat;
- TCHECK(ptr->id);
- pptp_id_print(&ptr->id);
+ ND_TCHECK(ptr->id);
+ pptp_id_print(ndo, &ptr->id);
return;
trunc:
- printf("%s", tstr);
+ ND_PRINT((ndo, "%s", tstr));
}
static void
-pptp_echorp_print(const u_char *dat)
+pptp_echorp_print(netdissect_options *ndo,
+ const u_char *dat)
{
- struct pptp_msg_echorp *ptr = (struct pptp_msg_echorp *)dat;
+ const struct pptp_msg_echorp *ptr = (const struct pptp_msg_echorp *)dat;
- TCHECK(ptr->id);
- pptp_id_print(&ptr->id);
- TCHECK(ptr->result_code);
- pptp_result_code_print(&ptr->result_code, PPTP_CTRL_MSG_TYPE_ECHORP);
- TCHECK(ptr->err_code);
- pptp_err_code_print(&ptr->err_code);
- TCHECK(ptr->reserved1);
+ ND_TCHECK(ptr->id);
+ pptp_id_print(ndo, &ptr->id);
+ ND_TCHECK(ptr->result_code);
+ pptp_result_code_print(ndo, &ptr->result_code, PPTP_CTRL_MSG_TYPE_ECHORP);
+ ND_TCHECK(ptr->err_code);
+ pptp_err_code_print(ndo, &ptr->err_code);
+ ND_TCHECK(ptr->reserved1);
return;
trunc:
- printf("%s", tstr);
-}
-
-static void
-pptp_ocrq_print(const u_char *dat)
-{
- struct pptp_msg_ocrq *ptr = (struct pptp_msg_ocrq *)dat;
-
- TCHECK(ptr->call_id);
- pptp_call_id_print(&ptr->call_id);
- TCHECK(ptr->call_ser);
- pptp_call_ser_print(&ptr->call_ser);
- TCHECK(ptr->min_bps);
- printf(" MIN_BPS(%u)", EXTRACT_32BITS(&ptr->min_bps));
- TCHECK(ptr->max_bps);
- printf(" MAX_BPS(%u)", EXTRACT_32BITS(&ptr->max_bps));
- TCHECK(ptr->bearer_type);
- pptp_bearer_type_print(&ptr->bearer_type);
- TCHECK(ptr->framing_type);
- pptp_framing_type_print(&ptr->framing_type);
- TCHECK(ptr->recv_winsiz);
- pptp_recv_winsiz_print(&ptr->recv_winsiz);
- TCHECK(ptr->pkt_proc_delay);
- pptp_pkt_proc_delay_print(&ptr->pkt_proc_delay);
- TCHECK(ptr->phone_no_len);
- printf(" PHONE_NO_LEN(%u)", EXTRACT_16BITS(&ptr->phone_no_len));
- TCHECK(ptr->reserved1);
- TCHECK(ptr->phone_no);
- printf(" PHONE_NO(%.64s)", ptr->phone_no);
- TCHECK(ptr->subaddr);
- pptp_subaddr_print(&ptr->subaddr[0]);
+ ND_PRINT((ndo, "%s", tstr));
+}
+
+static void
+pptp_ocrq_print(netdissect_options *ndo,
+ const u_char *dat)
+{
+ const struct pptp_msg_ocrq *ptr = (const struct pptp_msg_ocrq *)dat;
+
+ ND_TCHECK(ptr->call_id);
+ pptp_call_id_print(ndo, &ptr->call_id);
+ ND_TCHECK(ptr->call_ser);
+ pptp_call_ser_print(ndo, &ptr->call_ser);
+ ND_TCHECK(ptr->min_bps);
+ ND_PRINT((ndo, " MIN_BPS(%u)", EXTRACT_32BITS(&ptr->min_bps)));
+ ND_TCHECK(ptr->max_bps);
+ ND_PRINT((ndo, " MAX_BPS(%u)", EXTRACT_32BITS(&ptr->max_bps)));
+ ND_TCHECK(ptr->bearer_type);
+ pptp_bearer_type_print(ndo, &ptr->bearer_type);
+ ND_TCHECK(ptr->framing_type);
+ pptp_framing_type_print(ndo, &ptr->framing_type);
+ ND_TCHECK(ptr->recv_winsiz);
+ pptp_recv_winsiz_print(ndo, &ptr->recv_winsiz);
+ ND_TCHECK(ptr->pkt_proc_delay);
+ pptp_pkt_proc_delay_print(ndo, &ptr->pkt_proc_delay);
+ ND_TCHECK(ptr->phone_no_len);
+ ND_PRINT((ndo, " PHONE_NO_LEN(%u)", EXTRACT_16BITS(&ptr->phone_no_len)));
+ ND_TCHECK(ptr->reserved1);
+ ND_TCHECK(ptr->phone_no);
+ ND_PRINT((ndo, " PHONE_NO(%.64s)", ptr->phone_no));
+ ND_TCHECK(ptr->subaddr);
+ pptp_subaddr_print(ndo, &ptr->subaddr[0]);
return;
trunc:
- printf("%s", tstr);
-}
-
-static void
-pptp_ocrp_print(const u_char *dat)
-{
- struct pptp_msg_ocrp *ptr = (struct pptp_msg_ocrp *)dat;
-
- TCHECK(ptr->call_id);
- pptp_call_id_print(&ptr->call_id);
- TCHECK(ptr->peer_call_id);
- pptp_peer_call_id_print(&ptr->peer_call_id);
- TCHECK(ptr->result_code);
- pptp_result_code_print(&ptr->result_code, PPTP_CTRL_MSG_TYPE_OCRP);
- TCHECK(ptr->err_code);
- pptp_err_code_print(&ptr->err_code);
- TCHECK(ptr->cause_code);
- pptp_cause_code_print(&ptr->cause_code);
- TCHECK(ptr->conn_speed);
- pptp_conn_speed_print(&ptr->conn_speed);
- TCHECK(ptr->recv_winsiz);
- pptp_recv_winsiz_print(&ptr->recv_winsiz);
- TCHECK(ptr->pkt_proc_delay);
- pptp_pkt_proc_delay_print(&ptr->pkt_proc_delay);
- TCHECK(ptr->phy_chan_id);
- pptp_phy_chan_id_print(&ptr->phy_chan_id);
+ ND_PRINT((ndo, "%s", tstr));
+}
+
+static void
+pptp_ocrp_print(netdissect_options *ndo,
+ const u_char *dat)
+{
+ const struct pptp_msg_ocrp *ptr = (const struct pptp_msg_ocrp *)dat;
+
+ ND_TCHECK(ptr->call_id);
+ pptp_call_id_print(ndo, &ptr->call_id);
+ ND_TCHECK(ptr->peer_call_id);
+ pptp_peer_call_id_print(ndo, &ptr->peer_call_id);
+ ND_TCHECK(ptr->result_code);
+ pptp_result_code_print(ndo, &ptr->result_code, PPTP_CTRL_MSG_TYPE_OCRP);
+ ND_TCHECK(ptr->err_code);
+ pptp_err_code_print(ndo, &ptr->err_code);
+ ND_TCHECK(ptr->cause_code);
+ pptp_cause_code_print(ndo, &ptr->cause_code);
+ ND_TCHECK(ptr->conn_speed);
+ pptp_conn_speed_print(ndo, &ptr->conn_speed);
+ ND_TCHECK(ptr->recv_winsiz);
+ pptp_recv_winsiz_print(ndo, &ptr->recv_winsiz);
+ ND_TCHECK(ptr->pkt_proc_delay);
+ pptp_pkt_proc_delay_print(ndo, &ptr->pkt_proc_delay);
+ ND_TCHECK(ptr->phy_chan_id);
+ pptp_phy_chan_id_print(ndo, &ptr->phy_chan_id);
return;
trunc:
- printf("%s", tstr);
-}
-
-static void
-pptp_icrq_print(const u_char *dat)
-{
- struct pptp_msg_icrq *ptr = (struct pptp_msg_icrq *)dat;
-
- TCHECK(ptr->call_id);
- pptp_call_id_print(&ptr->call_id);
- TCHECK(ptr->call_ser);
- pptp_call_ser_print(&ptr->call_ser);
- TCHECK(ptr->bearer_type);
- pptp_bearer_type_print(&ptr->bearer_type);
- TCHECK(ptr->phy_chan_id);
- pptp_phy_chan_id_print(&ptr->phy_chan_id);
- TCHECK(ptr->dialed_no_len);
- printf(" DIALED_NO_LEN(%u)", EXTRACT_16BITS(&ptr->dialed_no_len));
- TCHECK(ptr->dialing_no_len);
- printf(" DIALING_NO_LEN(%u)", EXTRACT_16BITS(&ptr->dialing_no_len));
- TCHECK(ptr->dialed_no);
- printf(" DIALED_NO(%.64s)", ptr->dialed_no);
- TCHECK(ptr->dialing_no);
- printf(" DIALING_NO(%.64s)", ptr->dialing_no);
- TCHECK(ptr->subaddr);
- pptp_subaddr_print(&ptr->subaddr[0]);
+ ND_PRINT((ndo, "%s", tstr));
+}
+
+static void
+pptp_icrq_print(netdissect_options *ndo,
+ const u_char *dat)
+{
+ const struct pptp_msg_icrq *ptr = (const struct pptp_msg_icrq *)dat;
+
+ ND_TCHECK(ptr->call_id);
+ pptp_call_id_print(ndo, &ptr->call_id);
+ ND_TCHECK(ptr->call_ser);
+ pptp_call_ser_print(ndo, &ptr->call_ser);
+ ND_TCHECK(ptr->bearer_type);
+ pptp_bearer_type_print(ndo, &ptr->bearer_type);
+ ND_TCHECK(ptr->phy_chan_id);
+ pptp_phy_chan_id_print(ndo, &ptr->phy_chan_id);
+ ND_TCHECK(ptr->dialed_no_len);
+ ND_PRINT((ndo, " DIALED_NO_LEN(%u)", EXTRACT_16BITS(&ptr->dialed_no_len)));
+ ND_TCHECK(ptr->dialing_no_len);
+ ND_PRINT((ndo, " DIALING_NO_LEN(%u)", EXTRACT_16BITS(&ptr->dialing_no_len)));
+ ND_TCHECK(ptr->dialed_no);
+ ND_PRINT((ndo, " DIALED_NO(%.64s)", ptr->dialed_no));
+ ND_TCHECK(ptr->dialing_no);
+ ND_PRINT((ndo, " DIALING_NO(%.64s)", ptr->dialing_no));
+ ND_TCHECK(ptr->subaddr);
+ pptp_subaddr_print(ndo, &ptr->subaddr[0]);
return;
trunc:
- printf("%s", tstr);
+ ND_PRINT((ndo, "%s", tstr));
}
static void
-pptp_icrp_print(const u_char *dat)
+pptp_icrp_print(netdissect_options *ndo,
+ const u_char *dat)
{
- struct pptp_msg_icrp *ptr = (struct pptp_msg_icrp *)dat;
-
- TCHECK(ptr->call_id);
- pptp_call_id_print(&ptr->call_id);
- TCHECK(ptr->peer_call_id);
- pptp_peer_call_id_print(&ptr->peer_call_id);
- TCHECK(ptr->result_code);
- pptp_result_code_print(&ptr->result_code, PPTP_CTRL_MSG_TYPE_ICRP);
- TCHECK(ptr->err_code);
- pptp_err_code_print(&ptr->err_code);
- TCHECK(ptr->recv_winsiz);
- pptp_recv_winsiz_print(&ptr->recv_winsiz);
- TCHECK(ptr->pkt_proc_delay);
- pptp_pkt_proc_delay_print(&ptr->pkt_proc_delay);
- TCHECK(ptr->reserved1);
+ const struct pptp_msg_icrp *ptr = (const struct pptp_msg_icrp *)dat;
+
+ ND_TCHECK(ptr->call_id);
+ pptp_call_id_print(ndo, &ptr->call_id);
+ ND_TCHECK(ptr->peer_call_id);
+ pptp_peer_call_id_print(ndo, &ptr->peer_call_id);
+ ND_TCHECK(ptr->result_code);
+ pptp_result_code_print(ndo, &ptr->result_code, PPTP_CTRL_MSG_TYPE_ICRP);
+ ND_TCHECK(ptr->err_code);
+ pptp_err_code_print(ndo, &ptr->err_code);
+ ND_TCHECK(ptr->recv_winsiz);
+ pptp_recv_winsiz_print(ndo, &ptr->recv_winsiz);
+ ND_TCHECK(ptr->pkt_proc_delay);
+ pptp_pkt_proc_delay_print(ndo, &ptr->pkt_proc_delay);
+ ND_TCHECK(ptr->reserved1);
return;
trunc:
- printf("%s", tstr);
+ ND_PRINT((ndo, "%s", tstr));
}
static void
-pptp_iccn_print(const u_char *dat)
+pptp_iccn_print(netdissect_options *ndo,
+ const u_char *dat)
{
- struct pptp_msg_iccn *ptr = (struct pptp_msg_iccn *)dat;
-
- TCHECK(ptr->peer_call_id);
- pptp_peer_call_id_print(&ptr->peer_call_id);
- TCHECK(ptr->reserved1);
- TCHECK(ptr->conn_speed);
- pptp_conn_speed_print(&ptr->conn_speed);
- TCHECK(ptr->recv_winsiz);
- pptp_recv_winsiz_print(&ptr->recv_winsiz);
- TCHECK(ptr->pkt_proc_delay);
- pptp_pkt_proc_delay_print(&ptr->pkt_proc_delay);
- TCHECK(ptr->framing_type);
- pptp_framing_type_print(&ptr->framing_type);
+ const struct pptp_msg_iccn *ptr = (const struct pptp_msg_iccn *)dat;
+
+ ND_TCHECK(ptr->peer_call_id);
+ pptp_peer_call_id_print(ndo, &ptr->peer_call_id);
+ ND_TCHECK(ptr->reserved1);
+ ND_TCHECK(ptr->conn_speed);
+ pptp_conn_speed_print(ndo, &ptr->conn_speed);
+ ND_TCHECK(ptr->recv_winsiz);
+ pptp_recv_winsiz_print(ndo, &ptr->recv_winsiz);
+ ND_TCHECK(ptr->pkt_proc_delay);
+ pptp_pkt_proc_delay_print(ndo, &ptr->pkt_proc_delay);
+ ND_TCHECK(ptr->framing_type);
+ pptp_framing_type_print(ndo, &ptr->framing_type);
return;
trunc:
- printf("%s", tstr);
+ ND_PRINT((ndo, "%s", tstr));
}
static void
-pptp_ccrq_print(const u_char *dat)
+pptp_ccrq_print(netdissect_options *ndo,
+ const u_char *dat)
{
- struct pptp_msg_ccrq *ptr = (struct pptp_msg_ccrq *)dat;
+ const struct pptp_msg_ccrq *ptr = (const struct pptp_msg_ccrq *)dat;
- TCHECK(ptr->call_id);
- pptp_call_id_print(&ptr->call_id);
- TCHECK(ptr->reserved1);
+ ND_TCHECK(ptr->call_id);
+ pptp_call_id_print(ndo, &ptr->call_id);
+ ND_TCHECK(ptr->reserved1);
return;
trunc:
- printf("%s", tstr);
+ ND_PRINT((ndo, "%s", tstr));
}
static void
-pptp_cdn_print(const u_char *dat)
+pptp_cdn_print(netdissect_options *ndo,
+ const u_char *dat)
{
- struct pptp_msg_cdn *ptr = (struct pptp_msg_cdn *)dat;
-
- TCHECK(ptr->call_id);
- pptp_call_id_print(&ptr->call_id);
- TCHECK(ptr->result_code);
- pptp_result_code_print(&ptr->result_code, PPTP_CTRL_MSG_TYPE_CDN);
- TCHECK(ptr->err_code);
- pptp_err_code_print(&ptr->err_code);
- TCHECK(ptr->cause_code);
- pptp_cause_code_print(&ptr->cause_code);
- TCHECK(ptr->reserved1);
- TCHECK(ptr->call_stats);
- printf(" CALL_STATS(%.128s)", ptr->call_stats);
+ const struct pptp_msg_cdn *ptr = (const struct pptp_msg_cdn *)dat;
+
+ ND_TCHECK(ptr->call_id);
+ pptp_call_id_print(ndo, &ptr->call_id);
+ ND_TCHECK(ptr->result_code);
+ pptp_result_code_print(ndo, &ptr->result_code, PPTP_CTRL_MSG_TYPE_CDN);
+ ND_TCHECK(ptr->err_code);
+ pptp_err_code_print(ndo, &ptr->err_code);
+ ND_TCHECK(ptr->cause_code);
+ pptp_cause_code_print(ndo, &ptr->cause_code);
+ ND_TCHECK(ptr->reserved1);
+ ND_TCHECK(ptr->call_stats);
+ ND_PRINT((ndo, " CALL_STATS(%.128s)", ptr->call_stats));
return;
trunc:
- printf("%s", tstr);
+ ND_PRINT((ndo, "%s", tstr));
}
static void
-pptp_wen_print(const u_char *dat)
+pptp_wen_print(netdissect_options *ndo,
+ const u_char *dat)
{
- struct pptp_msg_wen *ptr = (struct pptp_msg_wen *)dat;
-
- TCHECK(ptr->peer_call_id);
- pptp_peer_call_id_print(&ptr->peer_call_id);
- TCHECK(ptr->reserved1);
- TCHECK(ptr->crc_err);
- printf(" CRC_ERR(%u)", EXTRACT_32BITS(&ptr->crc_err));
- TCHECK(ptr->framing_err);
- printf(" FRAMING_ERR(%u)", EXTRACT_32BITS(&ptr->framing_err));
- TCHECK(ptr->hardware_overrun);
- printf(" HARDWARE_OVERRUN(%u)", EXTRACT_32BITS(&ptr->hardware_overrun));
- TCHECK(ptr->buffer_overrun);
- printf(" BUFFER_OVERRUN(%u)", EXTRACT_32BITS(&ptr->buffer_overrun));
- TCHECK(ptr->timeout_err);
- printf(" TIMEOUT_ERR(%u)", EXTRACT_32BITS(&ptr->timeout_err));
- TCHECK(ptr->align_err);
- printf(" ALIGN_ERR(%u)", EXTRACT_32BITS(&ptr->align_err));
+ const struct pptp_msg_wen *ptr = (const struct pptp_msg_wen *)dat;
+
+ ND_TCHECK(ptr->peer_call_id);
+ pptp_peer_call_id_print(ndo, &ptr->peer_call_id);
+ ND_TCHECK(ptr->reserved1);
+ ND_TCHECK(ptr->crc_err);
+ ND_PRINT((ndo, " CRC_ERR(%u)", EXTRACT_32BITS(&ptr->crc_err)));
+ ND_TCHECK(ptr->framing_err);
+ ND_PRINT((ndo, " FRAMING_ERR(%u)", EXTRACT_32BITS(&ptr->framing_err)));
+ ND_TCHECK(ptr->hardware_overrun);
+ ND_PRINT((ndo, " HARDWARE_OVERRUN(%u)", EXTRACT_32BITS(&ptr->hardware_overrun)));
+ ND_TCHECK(ptr->buffer_overrun);
+ ND_PRINT((ndo, " BUFFER_OVERRUN(%u)", EXTRACT_32BITS(&ptr->buffer_overrun)));
+ ND_TCHECK(ptr->timeout_err);
+ ND_PRINT((ndo, " TIMEOUT_ERR(%u)", EXTRACT_32BITS(&ptr->timeout_err)));
+ ND_TCHECK(ptr->align_err);
+ ND_PRINT((ndo, " ALIGN_ERR(%u)", EXTRACT_32BITS(&ptr->align_err)));
return;
trunc:
- printf("%s", tstr);
+ ND_PRINT((ndo, "%s", tstr));
}
static void
-pptp_sli_print(const u_char *dat)
+pptp_sli_print(netdissect_options *ndo,
+ const u_char *dat)
{
- struct pptp_msg_sli *ptr = (struct pptp_msg_sli *)dat;
+ const struct pptp_msg_sli *ptr = (const struct pptp_msg_sli *)dat;
- TCHECK(ptr->peer_call_id);
- pptp_peer_call_id_print(&ptr->peer_call_id);
- TCHECK(ptr->reserved1);
- TCHECK(ptr->send_accm);
- printf(" SEND_ACCM(0x%08x)", EXTRACT_32BITS(&ptr->send_accm));
- TCHECK(ptr->recv_accm);
- printf(" RECV_ACCM(0x%08x)", EXTRACT_32BITS(&ptr->recv_accm));
+ ND_TCHECK(ptr->peer_call_id);
+ pptp_peer_call_id_print(ndo, &ptr->peer_call_id);
+ ND_TCHECK(ptr->reserved1);
+ ND_TCHECK(ptr->send_accm);
+ ND_PRINT((ndo, " SEND_ACCM(0x%08x)", EXTRACT_32BITS(&ptr->send_accm)));
+ ND_TCHECK(ptr->recv_accm);
+ ND_PRINT((ndo, " RECV_ACCM(0x%08x)", EXTRACT_32BITS(&ptr->recv_accm)));
return;
trunc:
- printf("%s", tstr);
+ ND_PRINT((ndo, "%s", tstr));
}
void
-pptp_print(const u_char *dat)
+pptp_print(netdissect_options *ndo,
+ const u_char *dat)
{
const struct pptp_hdr *hdr;
- u_int32_t mc;
- u_int16_t ctrl_msg_type;
+ uint32_t mc;
+ uint16_t ctrl_msg_type;
- printf(": pptp");
+ ND_PRINT((ndo, ": pptp"));
- hdr = (struct pptp_hdr *)dat;
+ hdr = (const struct pptp_hdr *)dat;
- TCHECK(hdr->length);
- if (vflag) {
- printf(" Length=%u", EXTRACT_16BITS(&hdr->length));
+ ND_TCHECK(hdr->length);
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo, " Length=%u", EXTRACT_16BITS(&hdr->length)));
}
- TCHECK(hdr->msg_type);
- if (vflag) {
+ ND_TCHECK(hdr->msg_type);
+ if (ndo->ndo_vflag) {
switch(EXTRACT_16BITS(&hdr->msg_type)) {
case PPTP_MSG_TYPE_CTRL:
- printf(" CTRL-MSG");
+ ND_PRINT((ndo, " CTRL-MSG"));
break;
case PPTP_MSG_TYPE_MGMT:
- printf(" MGMT-MSG");
+ ND_PRINT((ndo, " MGMT-MSG"));
break;
default:
- printf(" UNKNOWN-MSG-TYPE");
+ ND_PRINT((ndo, " UNKNOWN-MSG-TYPE"));
break;
}
}
- TCHECK(hdr->magic_cookie);
+ ND_TCHECK(hdr->magic_cookie);
mc = EXTRACT_32BITS(&hdr->magic_cookie);
if (mc != PPTP_MAGIC_COOKIE) {
- printf(" UNEXPECTED Magic-Cookie!!(%08x)", mc);
+ ND_PRINT((ndo, " UNEXPECTED Magic-Cookie!!(%08x)", mc));
}
- if (vflag || mc != PPTP_MAGIC_COOKIE) {
- printf(" Magic-Cookie=%08x", mc);
+ if (ndo->ndo_vflag || mc != PPTP_MAGIC_COOKIE) {
+ ND_PRINT((ndo, " Magic-Cookie=%08x", mc));
}
- TCHECK(hdr->ctrl_msg_type);
+ ND_TCHECK(hdr->ctrl_msg_type);
ctrl_msg_type = EXTRACT_16BITS(&hdr->ctrl_msg_type);
if (ctrl_msg_type < PPTP_MAX_MSGTYPE_INDEX) {
- printf(" CTRL_MSGTYPE=%s",
- pptp_message_type_string[ctrl_msg_type]);
+ ND_PRINT((ndo, " CTRL_MSGTYPE=%s",
+ pptp_message_type_string[ctrl_msg_type]));
} else {
- printf(" UNKNOWN_CTRL_MSGTYPE(%u)", ctrl_msg_type);
+ ND_PRINT((ndo, " UNKNOWN_CTRL_MSGTYPE(%u)", ctrl_msg_type));
}
- TCHECK(hdr->reserved0);
+ ND_TCHECK(hdr->reserved0);
dat += 12;
switch(ctrl_msg_type) {
case PPTP_CTRL_MSG_TYPE_SCCRQ:
- pptp_sccrq_print(dat);
+ pptp_sccrq_print(ndo, dat);
break;
case PPTP_CTRL_MSG_TYPE_SCCRP:
- pptp_sccrp_print(dat);
+ pptp_sccrp_print(ndo, dat);
break;
case PPTP_CTRL_MSG_TYPE_StopCCRQ:
- pptp_stopccrq_print(dat);
+ pptp_stopccrq_print(ndo, dat);
break;
case PPTP_CTRL_MSG_TYPE_StopCCRP:
- pptp_stopccrp_print(dat);
+ pptp_stopccrp_print(ndo, dat);
break;
case PPTP_CTRL_MSG_TYPE_ECHORQ:
- pptp_echorq_print(dat);
+ pptp_echorq_print(ndo, dat);
break;
case PPTP_CTRL_MSG_TYPE_ECHORP:
- pptp_echorp_print(dat);
+ pptp_echorp_print(ndo, dat);
break;
case PPTP_CTRL_MSG_TYPE_OCRQ:
- pptp_ocrq_print(dat);
+ pptp_ocrq_print(ndo, dat);
break;
case PPTP_CTRL_MSG_TYPE_OCRP:
- pptp_ocrp_print(dat);
+ pptp_ocrp_print(ndo, dat);
break;
case PPTP_CTRL_MSG_TYPE_ICRQ:
- pptp_icrq_print(dat);
+ pptp_icrq_print(ndo, dat);
break;
case PPTP_CTRL_MSG_TYPE_ICRP:
- pptp_icrp_print(dat);
+ pptp_icrp_print(ndo, dat);
break;
case PPTP_CTRL_MSG_TYPE_ICCN:
- pptp_iccn_print(dat);
+ pptp_iccn_print(ndo, dat);
break;
case PPTP_CTRL_MSG_TYPE_CCRQ:
- pptp_ccrq_print(dat);
+ pptp_ccrq_print(ndo, dat);
break;
case PPTP_CTRL_MSG_TYPE_CDN:
- pptp_cdn_print(dat);
+ pptp_cdn_print(ndo, dat);
break;
case PPTP_CTRL_MSG_TYPE_WEN:
- pptp_wen_print(dat);
+ pptp_wen_print(ndo, dat);
break;
case PPTP_CTRL_MSG_TYPE_SLI:
- pptp_sli_print(dat);
+ pptp_sli_print(ndo, dat);
break;
default:
/* do nothing */
@@ -1058,5 +1007,8 @@ pptp_print(const u_char *dat)
return;
trunc:
- printf("%s", tstr);
+ ND_PRINT((ndo, "%s", tstr));
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-pptp-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-radius.c b/freebsd/contrib/tcpdump/print-radius.c
index 3ae0a4b1..24282b6b 100644
--- a/freebsd/contrib/tcpdump/print-radius.c
+++ b/freebsd/contrib/tcpdump/print-radius.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (C) 2000 Alfredo Andres Omella. All rights reserved.
*
@@ -21,6 +24,9 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
+
+/* \summary: Radius protocol printer */
+
/*
* Radius printer routines as specified on:
*
@@ -39,37 +45,42 @@
* RFC 2869:
* "RADIUS Extensions"
*
+ * RFC 3580:
+ * "IEEE 802.1X Remote Authentication Dial In User Service (RADIUS)"
+ * "Usage Guidelines"
+ *
+ * RFC 4675:
+ * "RADIUS Attributes for Virtual LAN and Priority Support"
+ *
+ * RFC 5176:
+ * "Dynamic Authorization Extensions to RADIUS"
+ *
* Alfredo Andres Omella (aandres@s21sec.com) v0.1 2000/09/15
*
* TODO: Among other things to print ok MacIntosh and Vendor values
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "$Id: print-radius.c,v 1.28 2005-09-26 01:01:55 guy Exp $";
-#endif
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <string.h>
-#include <stdio.h>
-
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "extract.h"
#include "oui.h"
+static const char tstr[] = " [|radius]";
+
#define TAM_SIZE(x) (sizeof(x)/sizeof(x[0]) )
#define PRINT_HEX(bytes_len, ptr_data) \
while(bytes_len) \
{ \
- printf("%02X", *ptr_data ); \
+ ND_PRINT((ndo, "%02X", *ptr_data )); \
ptr_data++; \
bytes_len--; \
}
@@ -84,17 +95,29 @@ static const char rcsid[] _U_ =
#define RADCMD_ACCESS_CHA 11 /* Access-Challenge */
#define RADCMD_STATUS_SER 12 /* Status-Server */
#define RADCMD_STATUS_CLI 13 /* Status-Client */
+#define RADCMD_DISCON_REQ 40 /* Disconnect-Request */
+#define RADCMD_DISCON_ACK 41 /* Disconnect-ACK */
+#define RADCMD_DISCON_NAK 42 /* Disconnect-NAK */
+#define RADCMD_COA_REQ 43 /* CoA-Request */
+#define RADCMD_COA_ACK 44 /* CoA-ACK */
+#define RADCMD_COA_NAK 45 /* CoA-NAK */
#define RADCMD_RESERVED 255 /* Reserved */
-static struct tok radius_command_values[] = {
- { RADCMD_ACCESS_REQ, "Access Request" },
- { RADCMD_ACCESS_ACC, "Access Accept" },
- { RADCMD_ACCESS_REJ, "Access Reject" },
- { RADCMD_ACCOUN_REQ, "Accounting Request" },
- { RADCMD_ACCOUN_RES, "Accounting Response" },
- { RADCMD_ACCESS_CHA, "Access Challenge" },
- { RADCMD_STATUS_SER, "Status Server" },
- { RADCMD_STATUS_CLI, "Status Client" },
+static const struct tok radius_command_values[] = {
+ { RADCMD_ACCESS_REQ, "Access-Request" },
+ { RADCMD_ACCESS_ACC, "Access-Accept" },
+ { RADCMD_ACCESS_REJ, "Access-Reject" },
+ { RADCMD_ACCOUN_REQ, "Accounting-Request" },
+ { RADCMD_ACCOUN_RES, "Accounting-Response" },
+ { RADCMD_ACCESS_CHA, "Access-Challenge" },
+ { RADCMD_STATUS_SER, "Status-Server" },
+ { RADCMD_STATUS_CLI, "Status-Client" },
+ { RADCMD_DISCON_REQ, "Disconnect-Request" },
+ { RADCMD_DISCON_ACK, "Disconnect-ACK" },
+ { RADCMD_DISCON_NAK, "Disconnect-NAK" },
+ { RADCMD_COA_REQ, "CoA-Request" },
+ { RADCMD_COA_ACK, "CoA-ACK" },
+ { RADCMD_COA_NAK, "CoA-NAK" },
{ RADCMD_RESERVED, "Reserved" },
{ 0, NULL}
};
@@ -115,6 +138,9 @@ static struct tok radius_command_values[] = {
#define ACCT_DELAY 41
#define ACCT_SESSION_TIME 46
+#define EGRESS_VLAN_ID 56
+#define EGRESS_VLAN_NAME 58
+
#define TUNNEL_TYPE 64
#define TUNNEL_MEDIUM 65
#define TUNNEL_CLIENT_END 66
@@ -137,25 +163,34 @@ static struct tok radius_command_values[] = {
/* End Radius Attribute types */
/********************************/
+#define RFC4675_TAGGED 0x31
+#define RFC4675_UNTAGGED 0x32
+
+static const struct tok rfc4675_tagged[] = {
+ { RFC4675_TAGGED, "Tagged" },
+ { RFC4675_UNTAGGED, "Untagged" },
+ { 0, NULL}
+};
+
-static void print_attr_string(register u_char *, u_int, u_short );
-static void print_attr_num(register u_char *, u_int, u_short );
-static void print_vendor_attr(register u_char *, u_int, u_short );
-static void print_attr_address(register u_char *, u_int, u_short);
-static void print_attr_time(register u_char *, u_int, u_short);
-static void print_attr_strange(register u_char *, u_int, u_short);
+static void print_attr_string(netdissect_options *, register const u_char *, u_int, u_short );
+static void print_attr_num(netdissect_options *, register const u_char *, u_int, u_short );
+static void print_vendor_attr(netdissect_options *, register const u_char *, u_int, u_short );
+static void print_attr_address(netdissect_options *, register const u_char *, u_int, u_short);
+static void print_attr_time(netdissect_options *, register const u_char *, u_int, u_short);
+static void print_attr_strange(netdissect_options *, register const u_char *, u_int, u_short);
-struct radius_hdr { u_int8_t code; /* Radius packet code */
- u_int8_t id; /* Radius packet id */
- u_int16_t len; /* Radius total length */
- u_int8_t auth[16]; /* Authenticator */
+struct radius_hdr { uint8_t code; /* Radius packet code */
+ uint8_t id; /* Radius packet id */
+ uint16_t len; /* Radius total length */
+ uint8_t auth[16]; /* Authenticator */
};
#define MIN_RADIUS_LEN 20
-struct radius_attr { u_int8_t type; /* Attribute type */
- u_int8_t len; /* Attribute length */
+struct radius_attr { uint8_t type; /* Attribute type */
+ uint8_t len; /* Attribute length */
};
@@ -216,6 +251,12 @@ static const char *term_action[]={ "Default",
"RADIUS-Request",
};
+/* Ingress-Filters Attribute standard values */
+static const char *ingress_filters[]={ NULL,
+ "Enabled",
+ "Disabled",
+ };
+
/* NAS-Port-Type Attribute standard values */
static const char *nas_port_type[]={ "Async",
"Sync",
@@ -301,6 +342,7 @@ static const char *tunnel_type[]={ NULL,
"GRE",
"DVS",
"IP-in-IP Tunneling",
+ "VLAN",
};
/* Tunnel-Medium-Type Attribute standard values */
@@ -335,105 +377,106 @@ static const char *prompt[]={ "No Echo",
};
-struct attrtype { const char *name; /* Attribute name */
+static struct attrtype {
+ const char *name; /* Attribute name */
const char **subtypes; /* Standard Values (if any) */
u_char siz_subtypes; /* Size of total standard values */
u_char first_subtype; /* First standard value is 0 or 1 */
- void (*print_func)(register u_char *, u_int, u_short );
+ void (*print_func)(netdissect_options *, register const u_char *, u_int, u_short);
} attr_type[]=
{
{ NULL, NULL, 0, 0, NULL },
- { "Username", NULL, 0, 0, print_attr_string },
- { "Password", NULL, 0, 0, NULL },
- { "CHAP Password", NULL, 0, 0, NULL },
- { "NAS IP Address", NULL, 0, 0, print_attr_address },
- { "NAS Port", NULL, 0, 0, print_attr_num },
- { "Service Type", serv_type, TAM_SIZE(serv_type)-1, 1, print_attr_num },
- { "Framed Protocol", frm_proto, TAM_SIZE(frm_proto)-1, 1, print_attr_num },
- { "Framed IP Address", NULL, 0, 0, print_attr_address },
- { "Framed IP Network", NULL, 0, 0, print_attr_address },
- { "Framed Routing", frm_routing, TAM_SIZE(frm_routing), 0, print_attr_num },
- { "Filter ID", NULL, 0, 0, print_attr_string },
- { "Framed MTU", NULL, 0, 0, print_attr_num },
- { "Framed Compression", frm_comp, TAM_SIZE(frm_comp), 0, print_attr_num },
- { "Login IP Host", NULL, 0, 0, print_attr_address },
- { "Login Service", login_serv, TAM_SIZE(login_serv), 0, print_attr_num },
- { "Login TCP Port", NULL, 0, 0, print_attr_num },
+ { "User-Name", NULL, 0, 0, print_attr_string },
+ { "User-Password", NULL, 0, 0, NULL },
+ { "CHAP-Password", NULL, 0, 0, NULL },
+ { "NAS-IP-Address", NULL, 0, 0, print_attr_address },
+ { "NAS-Port", NULL, 0, 0, print_attr_num },
+ { "Service-Type", serv_type, TAM_SIZE(serv_type)-1, 1, print_attr_num },
+ { "Framed-Protocol", frm_proto, TAM_SIZE(frm_proto)-1, 1, print_attr_num },
+ { "Framed-IP-Address", NULL, 0, 0, print_attr_address },
+ { "Framed-IP-Netmask", NULL, 0, 0, print_attr_address },
+ { "Framed-Routing", frm_routing, TAM_SIZE(frm_routing), 0, print_attr_num },
+ { "Filter-Id", NULL, 0, 0, print_attr_string },
+ { "Framed-MTU", NULL, 0, 0, print_attr_num },
+ { "Framed-Compression", frm_comp, TAM_SIZE(frm_comp), 0, print_attr_num },
+ { "Login-IP-Host", NULL, 0, 0, print_attr_address },
+ { "Login-Service", login_serv, TAM_SIZE(login_serv), 0, print_attr_num },
+ { "Login-TCP-Port", NULL, 0, 0, print_attr_num },
{ "Unassigned", NULL, 0, 0, NULL }, /*17*/
- { "Reply", NULL, 0, 0, print_attr_string },
- { "Callback-number", NULL, 0, 0, print_attr_string },
- { "Callback-ID", NULL, 0, 0, print_attr_string },
+ { "Reply-Message", NULL, 0, 0, print_attr_string },
+ { "Callback-Number", NULL, 0, 0, print_attr_string },
+ { "Callback-Id", NULL, 0, 0, print_attr_string },
{ "Unassigned", NULL, 0, 0, NULL }, /*21*/
- { "Framed Route", NULL, 0, 0, print_attr_string },
- { "Framed IPX Network", NULL, 0, 0, print_attr_num },
+ { "Framed-Route", NULL, 0, 0, print_attr_string },
+ { "Framed-IPX-Network", NULL, 0, 0, print_attr_num },
{ "State", NULL, 0, 0, print_attr_string },
{ "Class", NULL, 0, 0, print_attr_string },
- { "Vendor Specific", NULL, 0, 0, print_vendor_attr },
- { "Session Timeout", NULL, 0, 0, print_attr_num },
- { "Idle Timeout", NULL, 0, 0, print_attr_num },
- { "Termination Action", term_action, TAM_SIZE(term_action), 0, print_attr_num },
- { "Called Station", NULL, 0, 0, print_attr_string },
- { "Calling Station", NULL, 0, 0, print_attr_string },
- { "NAS ID", NULL, 0, 0, print_attr_string },
- { "Proxy State", NULL, 0, 0, print_attr_string },
- { "Login LAT Service", NULL, 0, 0, print_attr_string },
- { "Login LAT Node", NULL, 0, 0, print_attr_string },
- { "Login LAT Group", NULL, 0, 0, print_attr_string },
- { "Framed Appletalk Link", NULL, 0, 0, print_attr_num },
- { "Framed Appltalk Net", NULL, 0, 0, print_attr_num },
- { "Framed Appletalk Zone", NULL, 0, 0, print_attr_string },
- { "Accounting Status", acct_status, TAM_SIZE(acct_status)-1, 1, print_attr_num },
- { "Accounting Delay", NULL, 0, 0, print_attr_num },
- { "Accounting Input Octets", NULL, 0, 0, print_attr_num },
- { "Accounting Output Octets", NULL, 0, 0, print_attr_num },
- { "Accounting Session ID", NULL, 0, 0, print_attr_string },
- { "Accounting Authentication", acct_auth, TAM_SIZE(acct_auth)-1, 1, print_attr_num },
- { "Accounting Session Time", NULL, 0, 0, print_attr_num },
- { "Accounting Input Packets", NULL, 0, 0, print_attr_num },
- { "Accounting Output Packets", NULL, 0, 0, print_attr_num },
- { "Accounting Termination Cause", acct_term, TAM_SIZE(acct_term)-1, 1, print_attr_num },
- { "Accounting Multilink Session ID", NULL, 0, 0, print_attr_string },
- { "Accounting Link Count", NULL, 0, 0, print_attr_num },
- { "Accounting Input Giga", NULL, 0, 0, print_attr_num },
- { "Accounting Output Giga", NULL, 0, 0, print_attr_num },
+ { "Vendor-Specific", NULL, 0, 0, print_vendor_attr },
+ { "Session-Timeout", NULL, 0, 0, print_attr_num },
+ { "Idle-Timeout", NULL, 0, 0, print_attr_num },
+ { "Termination-Action", term_action, TAM_SIZE(term_action), 0, print_attr_num },
+ { "Called-Station-Id", NULL, 0, 0, print_attr_string },
+ { "Calling-Station-Id", NULL, 0, 0, print_attr_string },
+ { "NAS-Identifier", NULL, 0, 0, print_attr_string },
+ { "Proxy-State", NULL, 0, 0, print_attr_string },
+ { "Login-LAT-Service", NULL, 0, 0, print_attr_string },
+ { "Login-LAT-Node", NULL, 0, 0, print_attr_string },
+ { "Login-LAT-Group", NULL, 0, 0, print_attr_string },
+ { "Framed-AppleTalk-Link", NULL, 0, 0, print_attr_num },
+ { "Framed-AppleTalk-Network", NULL, 0, 0, print_attr_num },
+ { "Framed-AppleTalk-Zone", NULL, 0, 0, print_attr_string },
+ { "Acct-Status-Type", acct_status, TAM_SIZE(acct_status)-1, 1, print_attr_num },
+ { "Acct-Delay-Time", NULL, 0, 0, print_attr_num },
+ { "Acct-Input-Octets", NULL, 0, 0, print_attr_num },
+ { "Acct-Output-Octets", NULL, 0, 0, print_attr_num },
+ { "Acct-Session-Id", NULL, 0, 0, print_attr_string },
+ { "Acct-Authentic", acct_auth, TAM_SIZE(acct_auth)-1, 1, print_attr_num },
+ { "Acct-Session-Time", NULL, 0, 0, print_attr_num },
+ { "Acct-Input-Packets", NULL, 0, 0, print_attr_num },
+ { "Acct-Output-Packets", NULL, 0, 0, print_attr_num },
+ { "Acct-Terminate-Cause", acct_term, TAM_SIZE(acct_term)-1, 1, print_attr_num },
+ { "Acct-Multi-Session-Id", NULL, 0, 0, print_attr_string },
+ { "Acct-Link-Count", NULL, 0, 0, print_attr_num },
+ { "Acct-Input-Gigawords", NULL, 0, 0, print_attr_num },
+ { "Acct-Output-Gigawords", NULL, 0, 0, print_attr_num },
{ "Unassigned", NULL, 0, 0, NULL }, /*54*/
- { "Event Timestamp", NULL, 0, 0, print_attr_time },
- { "Unassigned", NULL, 0, 0, NULL }, /*56*/
- { "Unassigned", NULL, 0, 0, NULL }, /*57*/
- { "Unassigned", NULL, 0, 0, NULL }, /*58*/
- { "Unassigned", NULL, 0, 0, NULL }, /*59*/
- { "CHAP challenge", NULL, 0, 0, print_attr_string },
- { "NAS Port Type", nas_port_type, TAM_SIZE(nas_port_type), 0, print_attr_num },
- { "Port Limit", NULL, 0, 0, print_attr_num },
- { "Login LAT Port", NULL, 0, 0, print_attr_string }, /*63*/
- { "Tunnel Type", tunnel_type, TAM_SIZE(tunnel_type)-1, 1, print_attr_num },
- { "Tunnel Medium", tunnel_medium, TAM_SIZE(tunnel_medium)-1, 1, print_attr_num },
- { "Tunnel Client End", NULL, 0, 0, print_attr_string },
- { "Tunnel Server End", NULL, 0, 0, print_attr_string },
- { "Accounting Tunnel connect", NULL, 0, 0, print_attr_string },
- { "Tunnel Password", NULL, 0, 0, print_attr_string },
- { "ARAP Password", NULL, 0, 0, print_attr_strange },
- { "ARAP Feature", NULL, 0, 0, print_attr_strange },
- { "ARAP Zone Acces", arap_zone, TAM_SIZE(arap_zone)-1, 1, print_attr_num }, /*72*/
- { "ARAP Security", NULL, 0, 0, print_attr_string },
- { "ARAP Security Data", NULL, 0, 0, print_attr_string },
- { "Password Retry", NULL, 0, 0, print_attr_num },
+ { "Event-Timestamp", NULL, 0, 0, print_attr_time },
+ { "Egress-VLANID", NULL, 0, 0, print_attr_num },
+ { "Ingress-Filters", ingress_filters, TAM_SIZE(ingress_filters)-1, 1, print_attr_num },
+ { "Egress-VLAN-Name", NULL, 0, 0, print_attr_string },
+ { "User-Priority-Table", NULL, 0, 0, NULL },
+ { "CHAP-Challenge", NULL, 0, 0, print_attr_string },
+ { "NAS-Port-Type", nas_port_type, TAM_SIZE(nas_port_type), 0, print_attr_num },
+ { "Port-Limit", NULL, 0, 0, print_attr_num },
+ { "Login-LAT-Port", NULL, 0, 0, print_attr_string }, /*63*/
+ { "Tunnel-Type", tunnel_type, TAM_SIZE(tunnel_type)-1, 1, print_attr_num },
+ { "Tunnel-Medium-Type", tunnel_medium, TAM_SIZE(tunnel_medium)-1, 1, print_attr_num },
+ { "Tunnel-Client-Endpoint", NULL, 0, 0, print_attr_string },
+ { "Tunnel-Server-Endpoint", NULL, 0, 0, print_attr_string },
+ { "Acct-Tunnel-Connection", NULL, 0, 0, print_attr_string },
+ { "Tunnel-Password", NULL, 0, 0, print_attr_string },
+ { "ARAP-Password", NULL, 0, 0, print_attr_strange },
+ { "ARAP-Features", NULL, 0, 0, print_attr_strange },
+ { "ARAP-Zone-Access", arap_zone, TAM_SIZE(arap_zone)-1, 1, print_attr_num }, /*72*/
+ { "ARAP-Security", NULL, 0, 0, print_attr_string },
+ { "ARAP-Security-Data", NULL, 0, 0, print_attr_string },
+ { "Password-Retry", NULL, 0, 0, print_attr_num },
{ "Prompt", prompt, TAM_SIZE(prompt), 0, print_attr_num },
- { "Connect Info", NULL, 0, 0, print_attr_string },
- { "Config Token", NULL, 0, 0, print_attr_string },
- { "EAP Message", NULL, 0, 0, print_attr_string },
- { "Message Authentication", NULL, 0, 0, print_attr_string }, /*80*/
- { "Tunnel Private Group", NULL, 0, 0, print_attr_string },
- { "Tunnel Assigned ID", NULL, 0, 0, print_attr_string },
- { "Tunnel Preference", NULL, 0, 0, print_attr_num },
- { "ARAP Challenge Response", NULL, 0, 0, print_attr_strange },
- { "Accounting Interim Interval", NULL, 0, 0, print_attr_num },
- { "Accounting Tunnel packets lost", NULL, 0, 0, print_attr_num }, /*86*/
- { "NAS Port ID", NULL, 0, 0, print_attr_string },
- { "Framed Pool", NULL, 0, 0, print_attr_string },
- { "Unassigned", NULL, 0, 0, NULL },
- { "Tunnel Client Authentication ID", NULL, 0, 0, print_attr_string },
- { "Tunnel Server Authentication ID", NULL, 0, 0, print_attr_string },
+ { "Connect-Info", NULL, 0, 0, print_attr_string },
+ { "Configuration-Token", NULL, 0, 0, print_attr_string },
+ { "EAP-Message", NULL, 0, 0, print_attr_string },
+ { "Message-Authenticator", NULL, 0, 0, print_attr_string }, /*80*/
+ { "Tunnel-Private-Group-ID", NULL, 0, 0, print_attr_string },
+ { "Tunnel-Assignment-ID", NULL, 0, 0, print_attr_string },
+ { "Tunnel-Preference", NULL, 0, 0, print_attr_num },
+ { "ARAP-Challenge-Response", NULL, 0, 0, print_attr_strange },
+ { "Acct-Interim-Interval", NULL, 0, 0, print_attr_num },
+ { "Acct-Tunnel-Packets-Lost", NULL, 0, 0, print_attr_num }, /*86*/
+ { "NAS-Port-Id", NULL, 0, 0, print_attr_string },
+ { "Framed-Pool", NULL, 0, 0, print_attr_string },
+ { "CUI", NULL, 0, 0, print_attr_string },
+ { "Tunnel-Client-Auth-ID", NULL, 0, 0, print_attr_string },
+ { "Tunnel-Server-Auth-ID", NULL, 0, 0, print_attr_string },
{ "Unassigned", NULL, 0, 0, NULL }, /*92*/
{ "Unassigned", NULL, 0, 0, NULL } /*93*/
};
@@ -447,25 +490,28 @@ struct attrtype { const char *name; /* Attribute name */
/* Returns nothing. */
/*****************************/
static void
-print_attr_string(register u_char *data, u_int length, u_short attr_code )
+print_attr_string(netdissect_options *ndo,
+ register const u_char *data, u_int length, u_short attr_code)
{
register u_int i;
- TCHECK2(data[0],length);
+ ND_TCHECK2(data[0],length);
switch(attr_code)
{
case TUNNEL_PASS:
if (length < 3)
{
- printf(" [|radius]");
+ ND_PRINT((ndo, "%s", tstr));
return;
}
if (*data && (*data <=0x1F) )
- printf("Tag %u, ",*data);
+ ND_PRINT((ndo, "Tag[%u] ", *data));
+ else
+ ND_PRINT((ndo, "Tag[Unused] "));
data++;
length--;
- printf("Salt %u ",EXTRACT_16BITS(data) );
+ ND_PRINT((ndo, "Salt %u ", EXTRACT_16BITS(data)));
data+=2;
length-=2;
break;
@@ -479,31 +525,41 @@ print_attr_string(register u_char *data, u_int length, u_short attr_code )
{
if (length < 1)
{
- printf(" [|radius]");
+ ND_PRINT((ndo, "%s", tstr));
return;
}
- printf("Tag %u",*data);
+ if (*data)
+ ND_PRINT((ndo, "Tag[%u] ", *data));
+ else
+ ND_PRINT((ndo, "Tag[Unused] "));
data++;
length--;
}
break;
+ case EGRESS_VLAN_NAME:
+ ND_PRINT((ndo, "%s (0x%02x) ",
+ tok2str(rfc4675_tagged,"Unknown tag",*data),
+ *data));
+ data++;
+ length--;
+ break;
}
for (i=0; *data && i < length ; i++, data++)
- printf("%c",(*data < 32 || *data > 128) ? '.' : *data );
+ ND_PRINT((ndo, "%c", (*data < 32 || *data > 126) ? '.' : *data));
return;
trunc:
- printf(" [|radius]");
+ ND_PRINT((ndo, "%s", tstr));
}
/*
* print vendor specific attributes
*/
-
static void
-print_vendor_attr(register u_char *data, u_int length, u_short attr_code _U_)
+print_vendor_attr(netdissect_options *ndo,
+ register const u_char *data, u_int length, u_short attr_code _U_)
{
u_int idx;
u_int vendor_id;
@@ -512,55 +568,53 @@ print_vendor_attr(register u_char *data, u_int length, u_short attr_code _U_)
if (length < 4)
goto trunc;
- TCHECK2(*data, 4);
+ ND_TCHECK2(*data, 4);
vendor_id = EXTRACT_32BITS(data);
data+=4;
length-=4;
- printf("Vendor: %s (%u)",
+ ND_PRINT((ndo, "Vendor: %s (%u)",
tok2str(smi_values,"Unknown",vendor_id),
- vendor_id);
+ vendor_id));
while (length >= 2) {
- TCHECK2(*data, 2);
+ ND_TCHECK2(*data, 2);
vendor_type = *(data);
vendor_length = *(data+1);
if (vendor_length < 2)
{
- printf("\n\t Vendor Attribute: %u, Length: %u (bogus, must be >= 2)",
+ ND_PRINT((ndo, "\n\t Vendor Attribute: %u, Length: %u (bogus, must be >= 2)",
vendor_type,
- vendor_length);
+ vendor_length));
return;
}
if (vendor_length > length)
{
- printf("\n\t Vendor Attribute: %u, Length: %u (bogus, goes past end of vendor-specific attribute)",
+ ND_PRINT((ndo, "\n\t Vendor Attribute: %u, Length: %u (bogus, goes past end of vendor-specific attribute)",
vendor_type,
- vendor_length);
+ vendor_length));
return;
}
data+=2;
vendor_length-=2;
length-=2;
- TCHECK2(*data, vendor_length);
+ ND_TCHECK2(*data, vendor_length);
- printf("\n\t Vendor Attribute: %u, Length: %u, Value: ",
+ ND_PRINT((ndo, "\n\t Vendor Attribute: %u, Length: %u, Value: ",
vendor_type,
- vendor_length);
+ vendor_length));
for (idx = 0; idx < vendor_length ; idx++, data++)
- printf("%c",(*data < 32 || *data > 128) ? '.' : *data );
+ ND_PRINT((ndo, "%c", (*data < 32 || *data > 126) ? '.' : *data));
length-=vendor_length;
}
return;
trunc:
- printf(" [|radius]");
+ ND_PRINT((ndo, "%s", tstr));
}
-
-
/******************************/
/* Print an attribute numeric */
/* value pointed by 'data' */
@@ -569,31 +623,31 @@ print_vendor_attr(register u_char *data, u_int length, u_short attr_code _U_)
/* Returns nothing. */
/******************************/
static void
-print_attr_num(register u_char *data, u_int length, u_short attr_code )
+print_attr_num(netdissect_options *ndo,
+ register const u_char *data, u_int length, u_short attr_code)
{
- u_int8_t tag;
- u_int32_t timeout;
+ uint32_t timeout;
if (length != 4)
{
- printf("ERROR: length %u != 4", length);
+ ND_PRINT((ndo, "ERROR: length %u != 4", length));
return;
}
- TCHECK2(data[0],4);
+ ND_TCHECK2(data[0],4);
/* This attribute has standard values */
if (attr_type[attr_code].siz_subtypes)
{
static const char **table;
- u_int32_t data_value;
+ uint32_t data_value;
table = attr_type[attr_code].subtypes;
if ( (attr_code == TUNNEL_TYPE) || (attr_code == TUNNEL_MEDIUM) )
{
if (!*data)
- printf("Tag[Unused]");
+ ND_PRINT((ndo, "Tag[Unused] "));
else
- printf("Tag[%d]", *data);
+ ND_PRINT((ndo, "Tag[%d] ", *data));
data++;
data_value = EXTRACT_24BITS(data);
}
@@ -601,12 +655,12 @@ print_attr_num(register u_char *data, u_int length, u_short attr_code )
{
data_value = EXTRACT_32BITS(data);
}
- if ( data_value <= (u_int32_t)(attr_type[attr_code].siz_subtypes - 1 +
+ if ( data_value <= (uint32_t)(attr_type[attr_code].siz_subtypes - 1 +
attr_type[attr_code].first_subtype) &&
data_value >= attr_type[attr_code].first_subtype )
- printf("%s",table[data_value]);
+ ND_PRINT((ndo, "%s", table[data_value]));
else
- printf("#%u",data_value);
+ ND_PRINT((ndo, "#%u", data_value));
}
else
{
@@ -614,9 +668,9 @@ print_attr_num(register u_char *data, u_int length, u_short attr_code )
{
case FRM_IPX:
if (EXTRACT_32BITS( data) == 0xFFFFFFFE )
- printf("NAS Select");
+ ND_PRINT((ndo, "NAS Select"));
else
- printf("%d",EXTRACT_32BITS( data) );
+ ND_PRINT((ndo, "%d", EXTRACT_32BITS(data)));
break;
case SESSION_TIMEOUT:
@@ -626,44 +680,52 @@ print_attr_num(register u_char *data, u_int length, u_short attr_code )
case ACCT_INT_INTERVAL:
timeout = EXTRACT_32BITS( data);
if ( timeout < 60 )
- printf( "%02d secs", timeout);
+ ND_PRINT((ndo, "%02d secs", timeout));
else
{
if ( timeout < 3600 )
- printf( "%02d:%02d min",
- timeout / 60, timeout % 60);
+ ND_PRINT((ndo, "%02d:%02d min",
+ timeout / 60, timeout % 60));
else
- printf( "%02d:%02d:%02d hours",
+ ND_PRINT((ndo, "%02d:%02d:%02d hours",
timeout / 3600, (timeout % 3600) / 60,
- timeout % 60);
+ timeout % 60));
}
break;
case FRM_ATALK_LINK:
if (EXTRACT_32BITS(data) )
- printf("%d",EXTRACT_32BITS(data) );
+ ND_PRINT((ndo, "%d", EXTRACT_32BITS(data)));
else
- printf("Unnumbered" );
+ ND_PRINT((ndo, "Unnumbered"));
break;
case FRM_ATALK_NETWORK:
if (EXTRACT_32BITS(data) )
- printf("%d",EXTRACT_32BITS(data) );
+ ND_PRINT((ndo, "%d", EXTRACT_32BITS(data)));
else
- printf("NAS assigned" );
+ ND_PRINT((ndo, "NAS assigned"));
break;
case TUNNEL_PREFERENCE:
- tag = *data;
- data++;
- if (tag == 0)
- printf("Tag (Unused) %d",EXTRACT_24BITS(data) );
+ if (*data)
+ ND_PRINT((ndo, "Tag[%d] ", *data));
else
- printf("Tag (%d) %d", tag, EXTRACT_24BITS(data) );
+ ND_PRINT((ndo, "Tag[Unused] "));
+ data++;
+ ND_PRINT((ndo, "%d", EXTRACT_24BITS(data)));
+ break;
+
+ case EGRESS_VLAN_ID:
+ ND_PRINT((ndo, "%s (0x%02x) ",
+ tok2str(rfc4675_tagged,"Unknown tag",*data),
+ *data));
+ data++;
+ ND_PRINT((ndo, "%d", EXTRACT_24BITS(data)));
break;
default:
- printf("%d",EXTRACT_32BITS( data) );
+ ND_PRINT((ndo, "%d", EXTRACT_32BITS(data)));
break;
} /* switch */
@@ -673,10 +735,9 @@ print_attr_num(register u_char *data, u_int length, u_short attr_code )
return;
trunc:
- printf(" [|radius]");
+ ND_PRINT((ndo, "%s", tstr));
}
-
/*****************************/
/* Print an attribute IPv4 */
/* address value pointed by */
@@ -685,41 +746,41 @@ print_attr_num(register u_char *data, u_int length, u_short attr_code )
/* Returns nothing. */
/*****************************/
static void
-print_attr_address(register u_char *data, u_int length, u_short attr_code )
+print_attr_address(netdissect_options *ndo,
+ register const u_char *data, u_int length, u_short attr_code)
{
if (length != 4)
{
- printf("ERROR: length %u != 4", length);
+ ND_PRINT((ndo, "ERROR: length %u != 4", length));
return;
}
- TCHECK2(data[0],4);
+ ND_TCHECK2(data[0],4);
switch(attr_code)
{
case FRM_IPADDR:
case LOG_IPHOST:
if (EXTRACT_32BITS(data) == 0xFFFFFFFF )
- printf("User Selected");
+ ND_PRINT((ndo, "User Selected"));
else
if (EXTRACT_32BITS(data) == 0xFFFFFFFE )
- printf("NAS Select");
+ ND_PRINT((ndo, "NAS Select"));
else
- printf("%s",ipaddr_string(data));
+ ND_PRINT((ndo, "%s",ipaddr_string(ndo, data)));
break;
default:
- printf("%s",ipaddr_string(data) );
+ ND_PRINT((ndo, "%s", ipaddr_string(ndo, data)));
break;
}
return;
trunc:
- printf(" [|radius]");
+ ND_PRINT((ndo, "%s", tstr));
}
-
/*************************************/
/* Print an attribute of 'secs since */
/* January 1, 1970 00:00 UTC' value */
@@ -728,31 +789,32 @@ print_attr_address(register u_char *data, u_int length, u_short attr_code )
/*************************************/
/* Returns nothing. */
/*************************************/
-static void print_attr_time(register u_char *data, u_int length, u_short attr_code _U_)
+static void
+print_attr_time(netdissect_options *ndo,
+ register const u_char *data, u_int length, u_short attr_code _U_)
{
time_t attr_time;
char string[26];
if (length != 4)
{
- printf("ERROR: length %u != 4", length);
+ ND_PRINT((ndo, "ERROR: length %u != 4", length));
return;
}
- TCHECK2(data[0],4);
+ ND_TCHECK2(data[0],4);
attr_time = EXTRACT_32BITS(data);
strlcpy(string, ctime(&attr_time), sizeof(string));
/* Get rid of the newline */
string[24] = '\0';
- printf("%.24s", string);
+ ND_PRINT((ndo, "%.24s", string));
return;
trunc:
- printf(" [|radius]");
+ ND_PRINT((ndo, "%s", tstr));
}
-
/***********************************/
/* Print an attribute of 'strange' */
/* data format pointed by 'data' */
@@ -760,7 +822,9 @@ static void print_attr_time(register u_char *data, u_int length, u_short attr_co
/***********************************/
/* Returns nothing. */
/***********************************/
-static void print_attr_strange(register u_char *data, u_int length, u_short attr_code)
+static void
+print_attr_strange(netdissect_options *ndo,
+ register const u_char *data, u_int length, u_short attr_code)
{
u_short len_data;
@@ -769,45 +833,45 @@ static void print_attr_strange(register u_char *data, u_int length, u_short attr
case ARAP_PASS:
if (length != 16)
{
- printf("ERROR: length %u != 16", length);
+ ND_PRINT((ndo, "ERROR: length %u != 16", length));
return;
}
- printf("User_challenge (");
- TCHECK2(data[0],8);
+ ND_PRINT((ndo, "User_challenge ("));
+ ND_TCHECK2(data[0],8);
len_data = 8;
PRINT_HEX(len_data, data);
- printf(") User_resp(");
- TCHECK2(data[0],8);
+ ND_PRINT((ndo, ") User_resp("));
+ ND_TCHECK2(data[0],8);
len_data = 8;
PRINT_HEX(len_data, data);
- printf(")");
+ ND_PRINT((ndo, ")"));
break;
case ARAP_FEATURES:
if (length != 14)
{
- printf("ERROR: length %u != 14", length);
+ ND_PRINT((ndo, "ERROR: length %u != 14", length));
return;
}
- TCHECK2(data[0],1);
+ ND_TCHECK2(data[0],1);
if (*data)
- printf("User can change password");
+ ND_PRINT((ndo, "User can change password"));
else
- printf("User cannot change password");
+ ND_PRINT((ndo, "User cannot change password"));
data++;
- TCHECK2(data[0],1);
- printf(", Min password length: %d",*data);
+ ND_TCHECK2(data[0],1);
+ ND_PRINT((ndo, ", Min password length: %d", *data));
data++;
- printf(", created at: ");
- TCHECK2(data[0],4);
+ ND_PRINT((ndo, ", created at: "));
+ ND_TCHECK2(data[0],4);
len_data = 4;
PRINT_HEX(len_data, data);
- printf(", expires in: ");
- TCHECK2(data[0],4);
+ ND_PRINT((ndo, ", expires in: "));
+ ND_TCHECK2(data[0],4);
len_data = 4;
PRINT_HEX(len_data, data);
- printf(", Current Time: ");
- TCHECK2(data[0],4);
+ ND_PRINT((ndo, ", Current Time: "));
+ ND_TCHECK2(data[0],4);
len_data = 4;
PRINT_HEX(len_data, data);
break;
@@ -815,10 +879,10 @@ static void print_attr_strange(register u_char *data, u_int length, u_short attr
case ARAP_CHALLENGE_RESP:
if (length < 8)
{
- printf("ERROR: length %u != 8", length);
+ ND_PRINT((ndo, "ERROR: length %u != 8", length));
return;
}
- TCHECK2(data[0],8);
+ ND_TCHECK2(data[0],8);
len_data = 8;
PRINT_HEX(len_data, data);
break;
@@ -826,47 +890,46 @@ static void print_attr_strange(register u_char *data, u_int length, u_short attr
return;
trunc:
- printf(" [|radius]");
+ ND_PRINT((ndo, "%s", tstr));
}
-
-
static void
-radius_attrs_print(register const u_char *attr, u_int length)
+radius_attrs_print(netdissect_options *ndo,
+ register const u_char *attr, u_int length)
{
- register const struct radius_attr *rad_attr = (struct radius_attr *)attr;
+ register const struct radius_attr *rad_attr = (const struct radius_attr *)attr;
const char *attr_string;
while (length > 0)
{
if (length < 2)
goto trunc;
- TCHECK(*rad_attr);
-
+ ND_TCHECK(*rad_attr);
+
if (rad_attr->type > 0 && rad_attr->type < TAM_SIZE(attr_type))
attr_string = attr_type[rad_attr->type].name;
else
attr_string = "Unknown";
if (rad_attr->len < 2)
{
- printf("\n\t %s Attribute (%u), length: %u (bogus, must be >= 2)",
+ ND_PRINT((ndo, "\n\t %s Attribute (%u), length: %u (bogus, must be >= 2)",
attr_string,
rad_attr->type,
- rad_attr->len);
+ rad_attr->len));
return;
}
if (rad_attr->len > length)
{
- printf("\n\t %s Attribute (%u), length: %u (bogus, goes past end of packet)",
+ ND_PRINT((ndo, "\n\t %s Attribute (%u), length: %u (bogus, goes past end of packet)",
attr_string,
rad_attr->type,
- rad_attr->len);
+ rad_attr->len));
return;
}
- printf("\n\t %s Attribute (%u), length: %u, Value: ",
+ ND_PRINT((ndo, "\n\t %s Attribute (%u), length: %u, Value: ",
attr_string,
rad_attr->type,
- rad_attr->len);
+ rad_attr->len));
if (rad_attr->type < TAM_SIZE(attr_type))
{
@@ -874,66 +937,69 @@ radius_attrs_print(register const u_char *attr, u_int length)
{
if ( attr_type[rad_attr->type].print_func )
(*attr_type[rad_attr->type].print_func)(
- ((u_char *)(rad_attr+1)),
+ ndo, ((const u_char *)(rad_attr+1)),
rad_attr->len - 2, rad_attr->type);
}
}
/* do we also want to see a hex dump ? */
- if (vflag> 1)
- print_unknown_data((u_char *)rad_attr+2,"\n\t ",(rad_attr->len)-2);
+ if (ndo->ndo_vflag> 1)
+ print_unknown_data(ndo, (const u_char *)rad_attr+2, "\n\t ", (rad_attr->len)-2);
length-=(rad_attr->len);
- rad_attr = (struct radius_attr *)( ((char *)(rad_attr))+rad_attr->len);
+ rad_attr = (const struct radius_attr *)( ((const char *)(rad_attr))+rad_attr->len);
}
return;
trunc:
- printf(" [|radius]");
+ ND_PRINT((ndo, "%s", tstr));
}
-
void
-radius_print(const u_char *dat, u_int length)
+radius_print(netdissect_options *ndo,
+ const u_char *dat, u_int length)
{
register const struct radius_hdr *rad;
u_int len, auth_idx;
- TCHECK2(*dat, MIN_RADIUS_LEN);
- rad = (struct radius_hdr *)dat;
+ ND_TCHECK2(*dat, MIN_RADIUS_LEN);
+ rad = (const struct radius_hdr *)dat;
len = EXTRACT_16BITS(&rad->len);
if (len < MIN_RADIUS_LEN)
{
- printf(" [|radius]");
+ ND_PRINT((ndo, "%s", tstr));
return;
}
if (len > length)
len = length;
- if (vflag < 1) {
- printf("RADIUS, %s (%u), id: 0x%02x length: %u",
+ if (ndo->ndo_vflag < 1) {
+ ND_PRINT((ndo, "RADIUS, %s (%u), id: 0x%02x length: %u",
tok2str(radius_command_values,"Unknown Command",rad->code),
rad->code,
rad->id,
- len);
+ len));
return;
}
else {
- printf("RADIUS, length: %u\n\t%s (%u), id: 0x%02x, Authenticator: ",
+ ND_PRINT((ndo, "RADIUS, length: %u\n\t%s (%u), id: 0x%02x, Authenticator: ",
len,
tok2str(radius_command_values,"Unknown Command",rad->code),
rad->code,
- rad->id);
+ rad->id));
for(auth_idx=0; auth_idx < 16; auth_idx++)
- printf("%02x", rad->auth[auth_idx] );
+ ND_PRINT((ndo, "%02x", rad->auth[auth_idx]));
}
if (len > MIN_RADIUS_LEN)
- radius_attrs_print( dat + MIN_RADIUS_LEN, len - MIN_RADIUS_LEN);
+ radius_attrs_print(ndo, dat + MIN_RADIUS_LEN, len - MIN_RADIUS_LEN);
return;
trunc:
- printf(" [|radius]");
+ ND_PRINT((ndo, "%s", tstr));
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-radius-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-raw.c b/freebsd/contrib/tcpdump/print-raw.c
index ec257de6..872996e2 100644
--- a/freebsd/contrib/tcpdump/print-raw.c
+++ b/freebsd/contrib/tcpdump/print-raw.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1996
* The Regents of the University of California. All rights reserved.
@@ -21,35 +24,30 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-raw.c,v 1.41 2003-11-16 09:36:34 guy Exp $ (LBL)";
-#endif
+/* \summary: Raw IP printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
-
-#include <pcap.h>
-#include <stdio.h>
-#include <string.h>
+#include <netdissect-stdinc.h>
-#include "addrtoname.h"
-#include "interface.h"
+#include "netdissect.h"
/*
* The DLT_RAW packet has no header. It contains a raw IP packet.
*/
u_int
-raw_if_print(const struct pcap_pkthdr *h, const u_char *p)
+raw_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
{
- if (eflag)
- printf("ip: ");
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, "ip: "));
- ipN_print(p, h->len);
+ ipN_print(ndo, p, h->len);
return (0);
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-raw-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-resp.c b/freebsd/contrib/tcpdump/print-resp.c
new file mode 100644
index 00000000..58d21fca
--- /dev/null
+++ b/freebsd/contrib/tcpdump/print-resp.c
@@ -0,0 +1,546 @@
+#include <machine/rtems-bsd-user-space.h>
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
+/*
+ * Copyright (c) 2015 The TCPDUMP project
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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
+ * COPYRIGHT HOLDER 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.
+ *
+ * Initial contribution by Andrew Darqui (andrew.darqui@gmail.com).
+ */
+
+/* \summary: REdis Serialization Protocol (RESP) printer */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <netdissect-stdinc.h>
+#include "netdissect.h"
+#include <limits.h>
+#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+
+#include "extract.h"
+
+static const char tstr[] = " [|RESP]";
+
+/*
+ * For information regarding RESP, see: http://redis.io/topics/protocol
+ */
+
+#define RESP_SIMPLE_STRING '+'
+#define RESP_ERROR '-'
+#define RESP_INTEGER ':'
+#define RESP_BULK_STRING '$'
+#define RESP_ARRAY '*'
+
+#define resp_print_empty(ndo) ND_PRINT((ndo, " empty"))
+#define resp_print_null(ndo) ND_PRINT((ndo, " null"))
+#define resp_print_length_too_large(ndo) ND_PRINT((ndo, " length too large"))
+#define resp_print_length_negative(ndo) ND_PRINT((ndo, " length negative and not -1"))
+#define resp_print_invalid(ndo) ND_PRINT((ndo, " invalid"))
+
+void resp_print(netdissect_options *, const u_char *, u_int);
+static int resp_parse(netdissect_options *, register const u_char *, int);
+static int resp_print_string_error_integer(netdissect_options *, register const u_char *, int);
+static int resp_print_simple_string(netdissect_options *, register const u_char *, int);
+static int resp_print_integer(netdissect_options *, register const u_char *, int);
+static int resp_print_error(netdissect_options *, register const u_char *, int);
+static int resp_print_bulk_string(netdissect_options *, register const u_char *, int);
+static int resp_print_bulk_array(netdissect_options *, register const u_char *, int);
+static int resp_print_inline(netdissect_options *, register const u_char *, int);
+static int resp_get_length(netdissect_options *, register const u_char *, int, const u_char **);
+
+#define LCHECK2(_tot_len, _len) \
+ { \
+ if (_tot_len < _len) \
+ goto trunc; \
+ }
+
+#define LCHECK(_tot_len) LCHECK2(_tot_len, 1)
+
+/*
+ * FIND_CRLF:
+ * Attempts to move our 'ptr' forward until a \r\n is found,
+ * while also making sure we don't exceed the buffer '_len'
+ * or go past the end of the captured data.
+ * If we exceed or go past the end of the captured data,
+ * jump to trunc.
+ */
+#define FIND_CRLF(_ptr, _len) \
+ for (;;) { \
+ LCHECK2(_len, 2); \
+ ND_TCHECK2(*_ptr, 2); \
+ if (*_ptr == '\r' && *(_ptr+1) == '\n') \
+ break; \
+ _ptr++; \
+ _len--; \
+ }
+
+/*
+ * CONSUME_CRLF
+ * Consume a CRLF that we've just found.
+ */
+#define CONSUME_CRLF(_ptr, _len) \
+ _ptr += 2; \
+ _len -= 2;
+
+/*
+ * FIND_CR_OR_LF
+ * Attempts to move our '_ptr' forward until a \r or \n is found,
+ * while also making sure we don't exceed the buffer '_len'
+ * or go past the end of the captured data.
+ * If we exceed or go past the end of the captured data,
+ * jump to trunc.
+ */
+#define FIND_CR_OR_LF(_ptr, _len) \
+ for (;;) { \
+ LCHECK(_len); \
+ ND_TCHECK(*_ptr); \
+ if (*_ptr == '\r' || *_ptr == '\n') \
+ break; \
+ _ptr++; \
+ _len--; \
+ }
+
+/*
+ * CONSUME_CR_OR_LF
+ * Consume all consecutive \r and \n bytes.
+ * If we exceed '_len' or go past the end of the captured data,
+ * jump to trunc.
+ */
+#define CONSUME_CR_OR_LF(_ptr, _len) \
+ { \
+ int _found_cr_or_lf = 0; \
+ for (;;) { \
+ /* \
+ * Have we hit the end of data? \
+ */ \
+ if (_len == 0 || !ND_TTEST(*_ptr)) { \
+ /* \
+ * Yes. Have we seen a \r \
+ * or \n? \
+ */ \
+ if (_found_cr_or_lf) { \
+ /* \
+ * Yes. Just stop. \
+ */ \
+ break; \
+ } \
+ /* \
+ * No. We ran out of packet. \
+ */ \
+ goto trunc; \
+ } \
+ if (*_ptr != '\r' && *_ptr != '\n') \
+ break; \
+ _found_cr_or_lf = 1; \
+ _ptr++; \
+ _len--; \
+ } \
+ }
+
+/*
+ * SKIP_OPCODE
+ * Skip over the opcode character.
+ * The opcode has already been fetched, so we know it's there, and don't
+ * need to do any checks.
+ */
+#define SKIP_OPCODE(_ptr, _tot_len) \
+ _ptr++; \
+ _tot_len--;
+
+/*
+ * GET_LENGTH
+ * Get a bulk string or array length.
+ */
+#define GET_LENGTH(_ndo, _tot_len, _ptr, _len) \
+ { \
+ const u_char *_endp; \
+ _len = resp_get_length(_ndo, _ptr, _tot_len, &_endp); \
+ _tot_len -= (_endp - _ptr); \
+ _ptr = _endp; \
+ }
+
+/*
+ * TEST_RET_LEN
+ * If ret_len is < 0, jump to the trunc tag which returns (-1)
+ * and 'bubbles up' to printing tstr. Otherwise, return ret_len.
+ */
+#define TEST_RET_LEN(rl) \
+ if (rl < 0) { goto trunc; } else { return rl; }
+
+/*
+ * TEST_RET_LEN_NORETURN
+ * If ret_len is < 0, jump to the trunc tag which returns (-1)
+ * and 'bubbles up' to printing tstr. Otherwise, continue onward.
+ */
+#define TEST_RET_LEN_NORETURN(rl) \
+ if (rl < 0) { goto trunc; }
+
+/*
+ * RESP_PRINT_SEGMENT
+ * Prints a segment in the form of: ' "<stuff>"\n"
+ * Assumes the data has already been verified as present.
+ */
+#define RESP_PRINT_SEGMENT(_ndo, _bp, _len) \
+ ND_PRINT((_ndo, " \"")); \
+ if (fn_printn(_ndo, _bp, _len, _ndo->ndo_snapend)) \
+ goto trunc; \
+ fn_print_char(_ndo, '"');
+
+void
+resp_print(netdissect_options *ndo, const u_char *bp, u_int length)
+{
+ int ret_len = 0, length_cur = length;
+
+ if(!bp || length <= 0)
+ return;
+
+ ND_PRINT((ndo, ": RESP"));
+ while (length_cur > 0) {
+ /*
+ * This block supports redis pipelining.
+ * For example, multiple operations can be pipelined within the same string:
+ * "*2\r\n\$4\r\nINCR\r\n\$1\r\nz\r\n*2\r\n\$4\r\nINCR\r\n\$1\r\nz\r\n*2\r\n\$4\r\nINCR\r\n\$1\r\nz\r\n"
+ * or
+ * "PING\r\nPING\r\nPING\r\n"
+ * In order to handle this case, we must try and parse 'bp' until
+ * 'length' bytes have been processed or we reach a trunc condition.
+ */
+ ret_len = resp_parse(ndo, bp, length_cur);
+ TEST_RET_LEN_NORETURN(ret_len);
+ bp += ret_len;
+ length_cur -= ret_len;
+ }
+
+ return;
+
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+}
+
+static int
+resp_parse(netdissect_options *ndo, register const u_char *bp, int length)
+{
+ u_char op;
+ int ret_len;
+
+ LCHECK2(length, 1);
+ ND_TCHECK(*bp);
+ op = *bp;
+
+ /* bp now points to the op, so these routines must skip it */
+ switch(op) {
+ case RESP_SIMPLE_STRING: ret_len = resp_print_simple_string(ndo, bp, length); break;
+ case RESP_INTEGER: ret_len = resp_print_integer(ndo, bp, length); break;
+ case RESP_ERROR: ret_len = resp_print_error(ndo, bp, length); break;
+ case RESP_BULK_STRING: ret_len = resp_print_bulk_string(ndo, bp, length); break;
+ case RESP_ARRAY: ret_len = resp_print_bulk_array(ndo, bp, length); break;
+ default: ret_len = resp_print_inline(ndo, bp, length); break;
+ }
+
+ /*
+ * This gives up with a "truncated" indicator for all errors,
+ * including invalid packet errors; that's what we want, as
+ * we have to give up on further parsing in that case.
+ */
+ TEST_RET_LEN(ret_len);
+
+trunc:
+ return (-1);
+}
+
+static int
+resp_print_simple_string(netdissect_options *ndo, register const u_char *bp, int length) {
+ return resp_print_string_error_integer(ndo, bp, length);
+}
+
+static int
+resp_print_integer(netdissect_options *ndo, register const u_char *bp, int length) {
+ return resp_print_string_error_integer(ndo, bp, length);
+}
+
+static int
+resp_print_error(netdissect_options *ndo, register const u_char *bp, int length) {
+ return resp_print_string_error_integer(ndo, bp, length);
+}
+
+static int
+resp_print_string_error_integer(netdissect_options *ndo, register const u_char *bp, int length) {
+ int length_cur = length, len, ret_len;
+ const u_char *bp_ptr;
+
+ /* bp points to the op; skip it */
+ SKIP_OPCODE(bp, length_cur);
+ bp_ptr = bp;
+
+ /*
+ * bp now prints past the (+-;) opcode, so it's pointing to the first
+ * character of the string (which could be numeric).
+ * +OK\r\n
+ * -ERR ...\r\n
+ * :02912309\r\n
+ *
+ * Find the \r\n with FIND_CRLF().
+ */
+ FIND_CRLF(bp_ptr, length_cur);
+
+ /*
+ * bp_ptr points to the \r\n, so bp_ptr - bp is the length of text
+ * preceding the \r\n. That includes the opcode, so don't print
+ * that.
+ */
+ len = (bp_ptr - bp);
+ RESP_PRINT_SEGMENT(ndo, bp, len);
+ ret_len = 1 /*<opcode>*/ + len /*<string>*/ + 2 /*<CRLF>*/;
+
+ TEST_RET_LEN(ret_len);
+
+trunc:
+ return (-1);
+}
+
+static int
+resp_print_bulk_string(netdissect_options *ndo, register const u_char *bp, int length) {
+ int length_cur = length, string_len;
+
+ /* bp points to the op; skip it */
+ SKIP_OPCODE(bp, length_cur);
+
+ /* <length>\r\n */
+ GET_LENGTH(ndo, length_cur, bp, string_len);
+
+ if (string_len >= 0) {
+ /* Byte string of length string_len, starting at bp */
+ if (string_len == 0)
+ resp_print_empty(ndo);
+ else {
+ LCHECK2(length_cur, string_len);
+ ND_TCHECK2(*bp, string_len);
+ RESP_PRINT_SEGMENT(ndo, bp, string_len);
+ bp += string_len;
+ length_cur -= string_len;
+ }
+
+ /*
+ * Find the \r\n at the end of the string and skip past it.
+ * XXX - report an error if the \r\n isn't immediately after
+ * the item?
+ */
+ FIND_CRLF(bp, length_cur);
+ CONSUME_CRLF(bp, length_cur);
+ } else {
+ /* null, truncated, or invalid for some reason */
+ switch(string_len) {
+ case (-1): resp_print_null(ndo); break;
+ case (-2): goto trunc;
+ case (-3): resp_print_length_too_large(ndo); break;
+ case (-4): resp_print_length_negative(ndo); break;
+ default: resp_print_invalid(ndo); break;
+ }
+ }
+
+ return (length - length_cur);
+
+trunc:
+ return (-1);
+}
+
+static int
+resp_print_bulk_array(netdissect_options *ndo, register const u_char *bp, int length) {
+ u_int length_cur = length;
+ int array_len, i, ret_len;
+
+ /* bp points to the op; skip it */
+ SKIP_OPCODE(bp, length_cur);
+
+ /* <array_length>\r\n */
+ GET_LENGTH(ndo, length_cur, bp, array_len);
+
+ if (array_len > 0) {
+ /* non empty array */
+ for (i = 0; i < array_len; i++) {
+ ret_len = resp_parse(ndo, bp, length_cur);
+
+ TEST_RET_LEN_NORETURN(ret_len);
+
+ bp += ret_len;
+ length_cur -= ret_len;
+ }
+ } else {
+ /* empty, null, truncated, or invalid */
+ switch(array_len) {
+ case 0: resp_print_empty(ndo); break;
+ case (-1): resp_print_null(ndo); break;
+ case (-2): goto trunc;
+ case (-3): resp_print_length_too_large(ndo); break;
+ case (-4): resp_print_length_negative(ndo); break;
+ default: resp_print_invalid(ndo); break;
+ }
+ }
+
+ return (length - length_cur);
+
+trunc:
+ return (-1);
+}
+
+static int
+resp_print_inline(netdissect_options *ndo, register const u_char *bp, int length) {
+ int length_cur = length;
+ int len;
+ const u_char *bp_ptr;
+
+ /*
+ * Inline commands are simply 'strings' followed by \r or \n or both.
+ * Redis will do its best to split/parse these strings.
+ * This feature of redis is implemented to support the ability of
+ * command parsing from telnet/nc sessions etc.
+ *
+ * <string><\r||\n||\r\n...>
+ */
+
+ /*
+ * Skip forward past any leading \r, \n, or \r\n.
+ */
+ CONSUME_CR_OR_LF(bp, length_cur);
+ bp_ptr = bp;
+
+ /*
+ * Scan forward looking for \r or \n.
+ */
+ FIND_CR_OR_LF(bp_ptr, length_cur);
+
+ /*
+ * Found it; bp_ptr points to the \r or \n, so bp_ptr - bp is the
+ * Length of the line text that preceeds it. Print it.
+ */
+ len = (bp_ptr - bp);
+ RESP_PRINT_SEGMENT(ndo, bp, len);
+
+ /*
+ * Skip forward past the \r, \n, or \r\n.
+ */
+ CONSUME_CR_OR_LF(bp_ptr, length_cur);
+
+ /*
+ * Return the number of bytes we processed.
+ */
+ return (length - length_cur);
+
+trunc:
+ return (-1);
+}
+
+static int
+resp_get_length(netdissect_options *ndo, register const u_char *bp, int len, const u_char **endp)
+{
+ int result;
+ u_char c;
+ int saw_digit;
+ int neg;
+ int too_large;
+
+ if (len == 0)
+ goto trunc;
+ ND_TCHECK(*bp);
+ too_large = 0;
+ neg = 0;
+ if (*bp == '-') {
+ neg = 1;
+ bp++;
+ len--;
+ }
+ result = 0;
+ saw_digit = 0;
+
+ for (;;) {
+ if (len == 0)
+ goto trunc;
+ ND_TCHECK(*bp);
+ c = *bp;
+ if (!(c >= '0' && c <= '9')) {
+ if (!saw_digit)
+ goto invalid;
+ break;
+ }
+ c -= '0';
+ if (result > (INT_MAX / 10)) {
+ /* This will overflow an int when we multiply it by 10. */
+ too_large = 1;
+ } else {
+ result *= 10;
+ if (result == INT_MAX && c > (INT_MAX % 10)) {
+ /* This will overflow an int when we add c */
+ too_large = 1;
+ } else
+ result += c;
+ }
+ bp++;
+ len--;
+ saw_digit = 1;
+ }
+ if (!saw_digit)
+ goto invalid;
+
+ /*
+ * OK, the next thing should be \r\n.
+ */
+ if (len == 0)
+ goto trunc;
+ ND_TCHECK(*bp);
+ if (*bp != '\r')
+ goto invalid;
+ bp++;
+ len--;
+ if (len == 0)
+ goto trunc;
+ ND_TCHECK(*bp);
+ if (*bp != '\n')
+ goto invalid;
+ bp++;
+ len--;
+ *endp = bp;
+ if (neg) {
+ /* -1 means "null", anything else is invalid */
+ if (too_large || result != 1)
+ return (-4);
+ result = -1;
+ }
+ return (too_large ? -3 : result);
+
+trunc:
+ return (-2);
+
+invalid:
+ return (-5);
+}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-resp-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-rip.c b/freebsd/contrib/tcpdump/print-rip.c
index 8d6aced0..d37df76f 100644
--- a/freebsd/contrib/tcpdump/print-rip.c
+++ b/freebsd/contrib/tcpdump/print-rip.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1989, 1990, 1991, 1993, 1994, 1996
* The Regents of the University of California. All rights reserved.
@@ -21,30 +24,28 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-rip.c,v 1.59 2006-03-23 14:58:44 hannes Exp $ (LBL)";
-#endif
+/* \summary: Routing Information Protocol (RIP) printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <stdio.h>
-#include <string.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
-#include "extract.h" /* must come after interface.h */
+#include "extract.h"
#include "af.h"
+static const char tstr[] = "[|rip]";
+
struct rip {
- u_int8_t rip_cmd; /* request/response */
- u_int8_t rip_vers; /* protocol version # */
- u_int8_t unused[2]; /* unused */
+ uint8_t rip_cmd; /* request/response */
+ uint8_t rip_vers; /* protocol version # */
+ uint8_t unused[2]; /* unused */
};
#define RIPCMD_REQUEST 1 /* want info */
@@ -69,7 +70,7 @@ static const struct tok rip_cmd_values[] = {
/*
* rfc 1723
- *
+ *
* 0 1 2 3 3
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
@@ -89,118 +90,121 @@ static const struct tok rip_cmd_values[] = {
*/
struct rip_netinfo {
- u_int16_t rip_family;
- u_int16_t rip_tag;
- u_int32_t rip_dest;
- u_int32_t rip_dest_mask;
- u_int32_t rip_router;
- u_int32_t rip_metric; /* cost of route */
+ uint16_t rip_family;
+ uint16_t rip_tag;
+ uint32_t rip_dest;
+ uint32_t rip_dest_mask;
+ uint32_t rip_router;
+ uint32_t rip_metric; /* cost of route */
};
static void
-rip_entry_print_v1(register const struct rip_netinfo *ni)
+rip_entry_print_v1(netdissect_options *ndo,
+ register const struct rip_netinfo *ni)
{
register u_short family;
/* RFC 1058 */
family = EXTRACT_16BITS(&ni->rip_family);
if (family != BSD_AFNUM_INET && family != 0) {
- printf("\n\t AFI %s, ", tok2str(bsd_af_values, "Unknown (%u)", family));
- print_unknown_data((u_int8_t *)&ni->rip_family,"\n\t ",RIP_ROUTELEN);
+ ND_PRINT((ndo, "\n\t AFI %s, ", tok2str(bsd_af_values, "Unknown (%u)", family)));
+ print_unknown_data(ndo, (const uint8_t *)&ni->rip_family, "\n\t ", RIP_ROUTELEN);
return;
}
if (EXTRACT_16BITS(&ni->rip_tag) ||
EXTRACT_32BITS(&ni->rip_dest_mask) ||
EXTRACT_32BITS(&ni->rip_router)) {
/* MBZ fields not zero */
- print_unknown_data((u_int8_t *)&ni->rip_family,"\n\t ",RIP_ROUTELEN);
+ print_unknown_data(ndo, (const uint8_t *)&ni->rip_family, "\n\t ", RIP_ROUTELEN);
return;
}
if (family == 0) {
- printf("\n\t AFI 0, %s, metric: %u",
- ipaddr_string(&ni->rip_dest),
- EXTRACT_32BITS(&ni->rip_metric));
+ ND_PRINT((ndo, "\n\t AFI 0, %s, metric: %u",
+ ipaddr_string(ndo, &ni->rip_dest),
+ EXTRACT_32BITS(&ni->rip_metric)));
return;
} /* BSD_AFNUM_INET */
- printf("\n\t %s, metric: %u",
- ipaddr_string(&ni->rip_dest),
- EXTRACT_32BITS(&ni->rip_metric));
+ ND_PRINT((ndo, "\n\t %s, metric: %u",
+ ipaddr_string(ndo, &ni->rip_dest),
+ EXTRACT_32BITS(&ni->rip_metric)));
}
static unsigned
-rip_entry_print_v2(register const struct rip_netinfo *ni, const unsigned remaining)
+rip_entry_print_v2(netdissect_options *ndo,
+ register const struct rip_netinfo *ni, const unsigned remaining)
{
register u_short family;
family = EXTRACT_16BITS(&ni->rip_family);
if (family == 0xFFFF) { /* variable-sized authentication structures */
- u_int16_t auth_type = EXTRACT_16BITS(&ni->rip_tag);
+ uint16_t auth_type = EXTRACT_16BITS(&ni->rip_tag);
if (auth_type == 2) {
- register u_char *p = (u_char *)&ni->rip_dest;
+ register const u_char *p = (const u_char *)&ni->rip_dest;
u_int i = 0;
- printf("\n\t Simple Text Authentication data: ");
+ ND_PRINT((ndo, "\n\t Simple Text Authentication data: "));
for (; i < RIP_AUTHLEN; p++, i++)
- putchar (isprint(*p) ? *p : '.');
+ ND_PRINT((ndo, "%c", ND_ISPRINT(*p) ? *p : '.'));
} else if (auth_type == 3) {
- printf("\n\t Auth header:");
- printf(" Packet Len %u,", EXTRACT_16BITS((u_int8_t *)ni + 4));
- printf(" Key-ID %u,", *((u_int8_t *)ni + 6));
- printf(" Auth Data Len %u,", *((u_int8_t *)ni + 7));
- printf(" SeqNo %u,", EXTRACT_32BITS(&ni->rip_dest_mask));
- printf(" MBZ %u,", EXTRACT_32BITS(&ni->rip_router));
- printf(" MBZ %u", EXTRACT_32BITS(&ni->rip_metric));
+ ND_PRINT((ndo, "\n\t Auth header:"));
+ ND_PRINT((ndo, " Packet Len %u,", EXTRACT_16BITS((const uint8_t *)ni + 4)));
+ ND_PRINT((ndo, " Key-ID %u,", *((const uint8_t *)ni + 6)));
+ ND_PRINT((ndo, " Auth Data Len %u,", *((const uint8_t *)ni + 7)));
+ ND_PRINT((ndo, " SeqNo %u,", EXTRACT_32BITS(&ni->rip_dest_mask)));
+ ND_PRINT((ndo, " MBZ %u,", EXTRACT_32BITS(&ni->rip_router)));
+ ND_PRINT((ndo, " MBZ %u", EXTRACT_32BITS(&ni->rip_metric)));
} else if (auth_type == 1) {
- printf("\n\t Auth trailer:");
- print_unknown_data((u_int8_t *)&ni->rip_dest,"\n\t ",remaining);
+ ND_PRINT((ndo, "\n\t Auth trailer:"));
+ print_unknown_data(ndo, (const uint8_t *)&ni->rip_dest, "\n\t ", remaining);
return remaining; /* AT spans till the packet end */
- } else {
- printf("\n\t Unknown (%u) Authentication data:",
- EXTRACT_16BITS(&ni->rip_tag));
- print_unknown_data((u_int8_t *)&ni->rip_dest,"\n\t ",remaining);
+ } else {
+ ND_PRINT((ndo, "\n\t Unknown (%u) Authentication data:",
+ EXTRACT_16BITS(&ni->rip_tag)));
+ print_unknown_data(ndo, (const uint8_t *)&ni->rip_dest, "\n\t ", remaining);
}
} else if (family != BSD_AFNUM_INET && family != 0) {
- printf("\n\t AFI %s", tok2str(bsd_af_values, "Unknown (%u)", family));
- print_unknown_data((u_int8_t *)&ni->rip_tag,"\n\t ",RIP_ROUTELEN-2);
+ ND_PRINT((ndo, "\n\t AFI %s", tok2str(bsd_af_values, "Unknown (%u)", family)));
+ print_unknown_data(ndo, (const uint8_t *)&ni->rip_tag, "\n\t ", RIP_ROUTELEN-2);
} else { /* BSD_AFNUM_INET or AFI 0 */
- printf("\n\t AFI %s, %15s/%-2d, tag 0x%04x, metric: %u, next-hop: ",
+ ND_PRINT((ndo, "\n\t AFI %s, %15s/%-2d, tag 0x%04x, metric: %u, next-hop: ",
tok2str(bsd_af_values, "%u", family),
- ipaddr_string(&ni->rip_dest),
+ ipaddr_string(ndo, &ni->rip_dest),
mask2plen(EXTRACT_32BITS(&ni->rip_dest_mask)),
EXTRACT_16BITS(&ni->rip_tag),
- EXTRACT_32BITS(&ni->rip_metric));
+ EXTRACT_32BITS(&ni->rip_metric)));
if (EXTRACT_32BITS(&ni->rip_router))
- printf("%s", ipaddr_string(&ni->rip_router));
- else
- printf("self");
+ ND_PRINT((ndo, "%s", ipaddr_string(ndo, &ni->rip_router)));
+ else
+ ND_PRINT((ndo, "self"));
}
return sizeof (*ni);
}
void
-rip_print(const u_char *dat, u_int length)
+rip_print(netdissect_options *ndo,
+ const u_char *dat, u_int length)
{
register const struct rip *rp;
register const struct rip_netinfo *ni;
register u_int i, j;
- if (snapend < dat) {
- printf(" [|rip]");
+ if (ndo->ndo_snapend < dat) {
+ ND_PRINT((ndo, " %s", tstr));
return;
}
- i = snapend - dat;
+ i = ndo->ndo_snapend - dat;
if (i > length)
i = length;
if (i < sizeof(*rp)) {
- printf(" [|rip]");
+ ND_PRINT((ndo, " %s", tstr));
return;
}
i -= sizeof(*rp);
- rp = (struct rip *)dat;
+ rp = (const struct rip *)dat;
- printf("%sRIPv%u",
- (vflag >= 1) ? "\n\t" : "",
- rp->rip_vers);
+ ND_PRINT((ndo, "%sRIPv%u",
+ (ndo->ndo_vflag >= 1) ? "\n\t" : "",
+ rp->rip_vers));
switch (rp->rip_vers) {
case 0:
@@ -215,38 +219,38 @@ rip_print(const u_char *dat, u_int length)
*
* so perhaps we should just dump the packet, in hex.
*/
- print_unknown_data((u_int8_t *)&rp->rip_cmd,"\n\t",length);
+ print_unknown_data(ndo, (const uint8_t *)&rp->rip_cmd, "\n\t", length);
break;
default:
/* dump version and lets see if we know the commands name*/
- printf(", %s, length: %u",
+ ND_PRINT((ndo, ", %s, length: %u",
tok2str(rip_cmd_values,
"unknown command (%u)",
rp->rip_cmd),
- length);
+ length));
- if (vflag < 1)
+ if (ndo->ndo_vflag < 1)
return;
switch (rp->rip_cmd) {
case RIPCMD_REQUEST:
case RIPCMD_RESPONSE:
j = length / sizeof(*ni);
- printf(", routes: %u%s", j, rp->rip_vers == 2 ? " or less" : "");
- ni = (struct rip_netinfo *)(rp + 1);
+ ND_PRINT((ndo, ", routes: %u%s", j, rp->rip_vers == 2 ? " or less" : ""));
+ ni = (const struct rip_netinfo *)(rp + 1);
for (; i >= sizeof(*ni); ++ni) {
if (rp->rip_vers == 1)
{
- rip_entry_print_v1(ni);
+ rip_entry_print_v1(ndo, ni);
i -= sizeof(*ni);
}
else if (rp->rip_vers == 2)
- i -= rip_entry_print_v2(ni, i);
+ i -= rip_entry_print_v2(ndo, ni, i);
else
break;
}
if (i)
- printf("[|rip]");
+ ND_PRINT((ndo, "%s", tstr));
break;
case RIPCMD_TRACEOFF:
@@ -257,18 +261,21 @@ rip_print(const u_char *dat, u_int length)
case RIPCMD_TRACEON:
/* fall through */
default:
- if (vflag <= 1) {
- if(!print_unknown_data((u_int8_t *)rp,"\n\t",length))
+ if (ndo->ndo_vflag <= 1) {
+ if(!print_unknown_data(ndo, (const uint8_t *)rp, "\n\t", length))
return;
}
break;
}
/* do we want to see an additionally hexdump ? */
- if (vflag> 1) {
- if(!print_unknown_data((u_int8_t *)rp,"\n\t",length))
+ if (ndo->ndo_vflag> 1) {
+ if(!print_unknown_data(ndo, (const uint8_t *)rp, "\n\t", length))
return;
}
}
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-rip-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-ripng.c b/freebsd/contrib/tcpdump/print-ripng.c
index 7ce8e977..cb85905c 100644
--- a/freebsd/contrib/tcpdump/print-ripng.c
+++ b/freebsd/contrib/tcpdump/print-ripng.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1989, 1990, 1991, 1993, 1994
* The Regents of the University of California. All rights reserved.
@@ -21,25 +24,72 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ripng.c,v 1.18 2005-01-04 00:15:54 guy Exp $";
-#endif
+/* \summary: IPv6 Routing Information Protocol (RIPng) printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#ifdef INET6
+#include <netdissect-stdinc.h>
-#include <tcpdump-stdinc.h>
-#include <stdio.h>
-
-#include "route6d.h"
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "extract.h"
+/*
+ * Copyright (C) 1995, 1996, 1997 and 1998 WIDE Project.
+ * All rights reserved.
+ *
+ * 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.
+ */
+#define RIP6_VERSION 1
+
+#define RIP6_REQUEST 1
+#define RIP6_RESPONSE 2
+
+struct netinfo6 {
+ struct in6_addr rip6_dest;
+ uint16_t rip6_tag;
+ uint8_t rip6_plen;
+ uint8_t rip6_metric;
+};
+
+struct rip6 {
+ uint8_t rip6_cmd;
+ uint8_t rip6_vers;
+ uint8_t rip6_res1[2];
+ union {
+ struct netinfo6 ru6_nets[1];
+ char ru6_tracefile[1];
+ } rip6un;
+#define rip6_nets rip6un.ru6_nets
+#define rip6_tracefile rip6un.ru6_tracefile
+};
+
+#define HOPCNT_INFINITY6 16
+
#if !defined(IN6_IS_ADDR_UNSPECIFIED) && !defined(_MSC_VER) /* MSVC inline */
static int IN6_IS_ADDR_UNSPECIFIED(const struct in6_addr *addr)
{
@@ -49,30 +99,30 @@ static int IN6_IS_ADDR_UNSPECIFIED(const struct in6_addr *addr)
#endif
static int
-rip6_entry_print(register const struct netinfo6 *ni, int metric)
+rip6_entry_print(netdissect_options *ndo, register const struct netinfo6 *ni, int metric)
{
int l;
- l = printf("%s/%d", ip6addr_string(&ni->rip6_dest), ni->rip6_plen);
+ l = ND_PRINT((ndo, "%s/%d", ip6addr_string(ndo, &ni->rip6_dest), ni->rip6_plen));
if (ni->rip6_tag)
- l += printf(" [%d]", EXTRACT_16BITS(&ni->rip6_tag));
+ l += ND_PRINT((ndo, " [%d]", EXTRACT_16BITS(&ni->rip6_tag)));
if (metric)
- l += printf(" (%d)", ni->rip6_metric);
+ l += ND_PRINT((ndo, " (%d)", ni->rip6_metric));
return l;
}
void
-ripng_print(const u_char *dat, unsigned int length)
+ripng_print(netdissect_options *ndo, const u_char *dat, unsigned int length)
{
- register const struct rip6 *rp = (struct rip6 *)dat;
+ register const struct rip6 *rp = (const struct rip6 *)dat;
register const struct netinfo6 *ni;
register u_int amt;
register u_int i;
int j;
int trunc;
- if (snapend < dat)
+ if (ndo->ndo_snapend < dat)
return;
- amt = snapend - dat;
+ amt = ndo->ndo_snapend - dat;
i = min(length, amt);
if (i < (sizeof(struct rip6) - sizeof(struct netinfo6)))
return;
@@ -85,46 +135,48 @@ ripng_print(const u_char *dat, unsigned int length)
if (j == 1
&& rp->rip6_nets->rip6_metric == HOPCNT_INFINITY6
&& IN6_IS_ADDR_UNSPECIFIED(&rp->rip6_nets->rip6_dest)) {
- printf(" ripng-req dump");
+ ND_PRINT((ndo, " ripng-req dump"));
break;
}
if (j * sizeof(*ni) != length - 4)
- printf(" ripng-req %d[%u]:", j, length);
+ ND_PRINT((ndo, " ripng-req %d[%u]:", j, length));
else
- printf(" ripng-req %d:", j);
+ ND_PRINT((ndo, " ripng-req %d:", j));
trunc = ((i / sizeof(*ni)) * sizeof(*ni) != i);
for (ni = rp->rip6_nets; i >= sizeof(*ni);
i -= sizeof(*ni), ++ni) {
- if (vflag > 1)
- printf("\n\t");
+ if (ndo->ndo_vflag > 1)
+ ND_PRINT((ndo, "\n\t"));
else
- printf(" ");
- rip6_entry_print(ni, 0);
+ ND_PRINT((ndo, " "));
+ rip6_entry_print(ndo, ni, 0);
}
break;
case RIP6_RESPONSE:
j = length / sizeof(*ni);
if (j * sizeof(*ni) != length - 4)
- printf(" ripng-resp %d[%u]:", j, length);
+ ND_PRINT((ndo, " ripng-resp %d[%u]:", j, length));
else
- printf(" ripng-resp %d:", j);
+ ND_PRINT((ndo, " ripng-resp %d:", j));
trunc = ((i / sizeof(*ni)) * sizeof(*ni) != i);
for (ni = rp->rip6_nets; i >= sizeof(*ni);
i -= sizeof(*ni), ++ni) {
- if (vflag > 1)
- printf("\n\t");
+ if (ndo->ndo_vflag > 1)
+ ND_PRINT((ndo, "\n\t"));
else
- printf(" ");
- rip6_entry_print(ni, ni->rip6_metric);
+ ND_PRINT((ndo, " "));
+ rip6_entry_print(ndo, ni, ni->rip6_metric);
}
if (trunc)
- printf("[|ripng]");
+ ND_PRINT((ndo, "[|ripng]"));
break;
default:
- printf(" ripng-%d ?? %u", rp->rip6_cmd, length);
+ ND_PRINT((ndo, " ripng-%d ?? %u", rp->rip6_cmd, length));
break;
}
if (rp->rip6_vers != RIP6_VERSION)
- printf(" [vers %d]", rp->rip6_vers);
+ ND_PRINT((ndo, " [vers %d]", rp->rip6_vers));
}
-#endif /* INET6 */
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-ripng-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-rpki-rtr.c b/freebsd/contrib/tcpdump/print-rpki-rtr.c
index 42c3ac1b..dc7fea0d 100644
--- a/freebsd/contrib/tcpdump/print-rpki-rtr.c
+++ b/freebsd/contrib/tcpdump/print-rpki-rtr.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1998-2011 The TCPDUMP project
*
@@ -14,30 +17,27 @@
* LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE.
*
- * support for the The RPKI/Router Protocol as RFC6810
- *
* Original code by Hannes Gredler (hannes@juniper.net)
*/
-#ifndef lint
-static const char rcsid[] _U_ =
-"@(#) $Header: /tcpdump/master/tcpdump/print-rpki_rtr.c,v 1.10 2008-03-20 09:30:56 hannes Exp $";
-#endif
+/* \summary: Resource Public Key Infrastructure (RPKI) to Router Protocol printer */
+
+/* specification: RFC 6810 */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include <stdio.h>
-#include <stdlib.h>
#include <string.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
#include "addrtoname.h"
+static const char tstr[] = "[|RPKI-RTR]";
+
/*
* RPKI/Router PDU header
*
@@ -128,7 +128,7 @@ static const struct tok rpki_rtr_error_codes[] = {
};
/*
- * Build a identation string for a given identation level.
+ * Build a indentation string for a given indentation level.
* XXX this should be really in util.c
*/
static char *
@@ -176,23 +176,24 @@ indent_string (u_int indent)
/*
* Print a single PDU.
*/
-static void
-rpki_rtr_pdu_print (const u_char *tptr, u_int indent)
+static int
+rpki_rtr_pdu_print (netdissect_options *ndo, const u_char *tptr, u_int indent)
{
const rpki_rtr_pdu *pdu_header;
u_int pdu_type, pdu_len, hexdump;
const u_char *msg;
- pdu_header = (rpki_rtr_pdu *)tptr;
+ pdu_header = (const rpki_rtr_pdu *)tptr;
pdu_type = pdu_header->pdu_type;
pdu_len = EXTRACT_32BITS(pdu_header->length);
+ ND_TCHECK2(*tptr, pdu_len);
hexdump = FALSE;
- printf("%sRPKI-RTRv%u, %s PDU (%u), length: %u",
+ ND_PRINT((ndo, "%sRPKI-RTRv%u, %s PDU (%u), length: %u",
indent_string(8),
pdu_header->version,
tok2str(rpki_rtr_pdu_values, "Unknown", pdu_type),
- pdu_type, pdu_len);
+ pdu_type, pdu_len));
switch (pdu_type) {
@@ -203,10 +204,10 @@ rpki_rtr_pdu_print (const u_char *tptr, u_int indent)
case RPKI_RTR_SERIAL_QUERY_PDU:
case RPKI_RTR_END_OF_DATA_PDU:
msg = (const u_char *)(pdu_header + 1);
- printf("%sSession ID: 0x%04x, Serial: %u",
+ ND_PRINT((ndo, "%sSession ID: 0x%04x, Serial: %u",
indent_string(indent+2),
EXTRACT_16BITS(pdu_header->u.session_id),
- EXTRACT_32BITS(msg));
+ EXTRACT_32BITS(msg)));
break;
/*
@@ -221,54 +222,52 @@ rpki_rtr_pdu_print (const u_char *tptr, u_int indent)
break;
case RPKI_RTR_CACHE_RESPONSE_PDU:
- printf("%sSession ID: 0x%04x",
+ ND_PRINT((ndo, "%sSession ID: 0x%04x",
indent_string(indent+2),
- EXTRACT_16BITS(pdu_header->u.session_id));
+ EXTRACT_16BITS(pdu_header->u.session_id)));
break;
case RPKI_RTR_IPV4_PREFIX_PDU:
{
- rpki_rtr_pdu_ipv4_prefix *pdu;
+ const rpki_rtr_pdu_ipv4_prefix *pdu;
- pdu = (rpki_rtr_pdu_ipv4_prefix *)tptr;
- printf("%sIPv4 Prefix %s/%u-%u, origin-as %u, flags 0x%02x",
+ pdu = (const rpki_rtr_pdu_ipv4_prefix *)tptr;
+ ND_PRINT((ndo, "%sIPv4 Prefix %s/%u-%u, origin-as %u, flags 0x%02x",
indent_string(indent+2),
- ipaddr_string(pdu->prefix),
+ ipaddr_string(ndo, pdu->prefix),
pdu->prefix_length, pdu->max_length,
- EXTRACT_32BITS(pdu->as), pdu->flags);
+ EXTRACT_32BITS(pdu->as), pdu->flags));
}
break;
-#ifdef INET6
case RPKI_RTR_IPV6_PREFIX_PDU:
{
- rpki_rtr_pdu_ipv6_prefix *pdu;
+ const rpki_rtr_pdu_ipv6_prefix *pdu;
- pdu = (rpki_rtr_pdu_ipv6_prefix *)tptr;
- printf("%sIPv6 Prefix %s/%u-%u, origin-as %u, flags 0x%02x",
+ pdu = (const rpki_rtr_pdu_ipv6_prefix *)tptr;
+ ND_PRINT((ndo, "%sIPv6 Prefix %s/%u-%u, origin-as %u, flags 0x%02x",
indent_string(indent+2),
- ip6addr_string(pdu->prefix),
+ ip6addr_string(ndo, pdu->prefix),
pdu->prefix_length, pdu->max_length,
- EXTRACT_32BITS(pdu->as), pdu->flags);
+ EXTRACT_32BITS(pdu->as), pdu->flags));
}
break;
-#endif
case RPKI_RTR_ERROR_REPORT_PDU:
{
- rpki_rtr_pdu_error_report *pdu;
+ const rpki_rtr_pdu_error_report *pdu;
u_int encapsulated_pdu_length, text_length, tlen, error_code;
- u_char buf[80];
- pdu = (rpki_rtr_pdu_error_report *)tptr;
+ pdu = (const rpki_rtr_pdu_error_report *)tptr;
encapsulated_pdu_length = EXTRACT_32BITS(pdu->encapsulated_pdu_length);
+ ND_TCHECK2(*tptr, encapsulated_pdu_length);
tlen = pdu_len;
error_code = EXTRACT_16BITS(pdu->pdu_header.u.error_code);
- printf("%sError code: %s (%u), Encapsulated PDU length: %u",
+ ND_PRINT((ndo, "%sError code: %s (%u), Encapsulated PDU length: %u",
indent_string(indent+2),
tok2str(rpki_rtr_error_codes, "Unknown", error_code),
- error_code, encapsulated_pdu_length);
+ error_code, encapsulated_pdu_length));
tptr += sizeof(*pdu);
tlen -= sizeof(*pdu);
@@ -278,8 +277,9 @@ rpki_rtr_pdu_print (const u_char *tptr, u_int indent)
*/
if (encapsulated_pdu_length &&
(encapsulated_pdu_length <= tlen)) {
- printf("%s-----encapsulated PDU-----", indent_string(indent+4));
- rpki_rtr_pdu_print(tptr, indent+2);
+ ND_PRINT((ndo, "%s-----encapsulated PDU-----", indent_string(indent+4)));
+ if (rpki_rtr_pdu_print(ndo, tptr, indent+2))
+ goto trunc;
}
tptr += encapsulated_pdu_length;
@@ -287,17 +287,18 @@ rpki_rtr_pdu_print (const u_char *tptr, u_int indent)
/*
* Extract, trail-zero and print the Error message.
- */
+ */
text_length = 0;
if (tlen > 4) {
text_length = EXTRACT_32BITS(tptr);
tptr += 4;
tlen -= 4;
}
+ ND_TCHECK2(*tptr, text_length);
if (text_length && (text_length <= tlen )) {
- memcpy(buf, tptr, MIN(sizeof(buf)-1, text_length));
- buf[text_length] = '\0';
- printf("%sError text: %s", indent_string(indent+2), buf);
+ ND_PRINT((ndo, "%sError text: ", indent_string(indent+2)));
+ if (fn_printn(ndo, tptr, text_length, ndo->ndo_snapend))
+ goto trunc;
}
}
break;
@@ -306,19 +307,23 @@ rpki_rtr_pdu_print (const u_char *tptr, u_int indent)
/*
* Unknown data, please hexdump.
- */
+ */
hexdump = TRUE;
}
/* do we also want to see a hex dump ? */
- if (vflag > 1 || (vflag && hexdump)) {
- print_unknown_data(tptr,"\n\t ", pdu_len);
+ if (ndo->ndo_vflag > 1 || (ndo->ndo_vflag && hexdump)) {
+ print_unknown_data(ndo,tptr,"\n\t ", pdu_len);
}
+ return 0;
+
+trunc:
+ return 1;
}
void
-rpki_rtr_print(register const u_char *pptr, register u_int len) {
-
+rpki_rtr_print(netdissect_options *ndo, register const u_char *pptr, register u_int len)
+{
u_int tlen, pdu_type, pdu_len;
const u_char *tptr;
const rpki_rtr_pdu *pdu_header;
@@ -326,25 +331,25 @@ rpki_rtr_print(register const u_char *pptr, register u_int len) {
tptr = pptr;
tlen = len;
- if (!vflag) {
- printf(", RPKI-RTR");
+ if (!ndo->ndo_vflag) {
+ ND_PRINT((ndo, ", RPKI-RTR"));
return;
}
while (tlen >= sizeof(rpki_rtr_pdu)) {
- TCHECK2(*tptr, sizeof(rpki_rtr_pdu));
+ ND_TCHECK2(*tptr, sizeof(rpki_rtr_pdu));
- pdu_header = (rpki_rtr_pdu *)tptr;
+ pdu_header = (const rpki_rtr_pdu *)tptr;
pdu_type = pdu_header->pdu_type;
pdu_len = EXTRACT_32BITS(pdu_header->length);
+ ND_TCHECK2(*tptr, pdu_len);
/* infinite loop check */
if (!pdu_type || !pdu_len) {
break;
}
- TCHECK2(*tptr, pdu_len);
if (tlen < pdu_len) {
goto trunc;
}
@@ -352,14 +357,15 @@ rpki_rtr_print(register const u_char *pptr, register u_int len) {
/*
* Print the PDU.
*/
- rpki_rtr_pdu_print(tptr, 8);
+ if (rpki_rtr_pdu_print(ndo, tptr, 8))
+ goto trunc;
tlen -= pdu_len;
tptr += pdu_len;
}
return;
- trunc:
- printf("\n\t[|RPKI-RTR]");
+trunc:
+ ND_PRINT((ndo, "\n\t%s", tstr));
}
/*
@@ -368,3 +374,6 @@ rpki_rtr_print(register const u_char *pptr, register u_int len) {
* c-basic-offset: 4
* End:
*/
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-rpki-rtr-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-rrcp.c b/freebsd/contrib/tcpdump/print-rrcp.c
index 57ed68ef..5615e10f 100644
--- a/freebsd/contrib/tcpdump/print-rrcp.c
+++ b/freebsd/contrib/tcpdump/print-rrcp.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 2007 - Andrey "nording" Chernyak <andrew@nording.ru>
*
@@ -23,29 +26,19 @@
* and Realtek Echo Protocol (RRCP-REP) packets.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-rrcp.c,v 1.2 2008-04-11 17:21:34 gianluca Exp $";
-#endif
+/* \summary: Realtek Remote Control Protocol (RRCP) printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
-
-#include <stdio.h>
-#include <string.h>
+#include <netdissect-stdinc.h>
#include "netdissect.h"
#include "addrtoname.h"
#include "extract.h"
#include "ether.h"
-#ifndef ETH_ALEN
-#define ETH_ALEN 6
-#endif
-
#define RRCP_OPCODE_MASK 0x7F /* 0x00 = hello, 0x01 = get, 0x02 = set */
#define RRCP_ISREPLY 0x80 /* 0 = request to switch, 0x80 = reply from switch */
@@ -85,61 +78,60 @@ static const struct tok opcode_values[] = {
void
rrcp_print(netdissect_options *ndo,
register const u_char *cp,
- u_int length _U_)
+ u_int length _U_,
+ const struct lladdr_info *src,
+ const struct lladdr_info *dst)
{
- const u_char *rrcp;
- u_int8_t rrcp_proto;
- u_int8_t rrcp_opcode;
- register const struct ether_header *ep;
- char proto_str[16];
- char opcode_str[32];
-
- ep = (const struct ether_header *)cp;
- rrcp = cp + ETHER_HDRLEN;
-
- ND_TCHECK(*(rrcp + RRCP_PROTO_OFFSET));
- rrcp_proto = *(rrcp + RRCP_PROTO_OFFSET);
- ND_TCHECK(*(rrcp + RRCP_OPCODE_ISREPLY_OFFSET));
- rrcp_opcode = (*(rrcp + RRCP_OPCODE_ISREPLY_OFFSET)) & RRCP_OPCODE_MASK;
- ND_PRINT((ndo, "%s > %s, %s %s",
- etheraddr_string(ESRC(ep)),
- etheraddr_string(EDST(ep)),
- tok2strbuf(proto_values,"RRCP-0x%02x",rrcp_proto,proto_str,sizeof(proto_str)),
- ((*(rrcp + RRCP_OPCODE_ISREPLY_OFFSET)) & RRCP_ISREPLY) ? "reply" : "query"));
+ uint8_t rrcp_proto;
+ uint8_t rrcp_opcode;
+
+ ND_TCHECK(*(cp + RRCP_PROTO_OFFSET));
+ rrcp_proto = *(cp + RRCP_PROTO_OFFSET);
+ ND_TCHECK(*(cp + RRCP_OPCODE_ISREPLY_OFFSET));
+ rrcp_opcode = (*(cp + RRCP_OPCODE_ISREPLY_OFFSET)) & RRCP_OPCODE_MASK;
+ if (src != NULL && dst != NULL) {
+ ND_PRINT((ndo, "%s > %s, ",
+ (src->addr_string)(ndo, src->addr),
+ (dst->addr_string)(ndo, dst->addr)));
+ }
+ ND_PRINT((ndo, "%s %s",
+ tok2str(proto_values,"RRCP-0x%02x",rrcp_proto),
+ ((*(cp + RRCP_OPCODE_ISREPLY_OFFSET)) & RRCP_ISREPLY) ? "reply" : "query"));
if (rrcp_proto==1){
ND_PRINT((ndo, ": %s",
- tok2strbuf(opcode_values,"unknown opcode (0x%02x)",rrcp_opcode,opcode_str,sizeof(opcode_str))));
+ tok2str(opcode_values,"unknown opcode (0x%02x)",rrcp_opcode)));
}
if (rrcp_opcode==1 || rrcp_opcode==2){
- ND_TCHECK2(*(rrcp + RRCP_REG_ADDR_OFFSET), 6);
+ ND_TCHECK2(*(cp + RRCP_REG_ADDR_OFFSET), 6);
ND_PRINT((ndo, " addr=0x%04x, data=0x%08x",
- EXTRACT_LE_16BITS(rrcp + RRCP_REG_ADDR_OFFSET),
- EXTRACT_LE_32BITS(rrcp + RRCP_REG_DATA_OFFSET)));
+ EXTRACT_LE_16BITS(cp + RRCP_REG_ADDR_OFFSET),
+ EXTRACT_LE_32BITS(cp + RRCP_REG_DATA_OFFSET)));
}
if (rrcp_proto==1){
- ND_TCHECK2(*(rrcp + RRCP_AUTHKEY_OFFSET), 2);
+ ND_TCHECK2(*(cp + RRCP_AUTHKEY_OFFSET), 2);
ND_PRINT((ndo, ", auth=0x%04x",
- EXTRACT_16BITS(rrcp + RRCP_AUTHKEY_OFFSET)));
+ EXTRACT_16BITS(cp + RRCP_AUTHKEY_OFFSET)));
}
if (rrcp_proto==1 && rrcp_opcode==0 &&
- ((*(rrcp + RRCP_OPCODE_ISREPLY_OFFSET)) & RRCP_ISREPLY)){
- ND_TCHECK2(*(rrcp + RRCP_VENDOR_ID_OFFSET), 4);
+ ((*(cp + RRCP_OPCODE_ISREPLY_OFFSET)) & RRCP_ISREPLY)){
+ ND_TCHECK2(*(cp + RRCP_VENDOR_ID_OFFSET), 4);
ND_PRINT((ndo, " downlink_port=%d, uplink_port=%d, uplink_mac=%s, vendor_id=%08x ,chip_id=%04x ",
- *(rrcp + RRCP_DOWNLINK_PORT_OFFSET),
- *(rrcp + RRCP_UPLINK_PORT_OFFSET),
- etheraddr_string(rrcp + RRCP_UPLINK_MAC_OFFSET),
- EXTRACT_32BITS(rrcp + RRCP_VENDOR_ID_OFFSET),
- EXTRACT_16BITS(rrcp + RRCP_CHIP_ID_OFFSET)));
+ *(cp + RRCP_DOWNLINK_PORT_OFFSET),
+ *(cp + RRCP_UPLINK_PORT_OFFSET),
+ etheraddr_string(ndo, cp + RRCP_UPLINK_MAC_OFFSET),
+ EXTRACT_32BITS(cp + RRCP_VENDOR_ID_OFFSET),
+ EXTRACT_16BITS(cp + RRCP_CHIP_ID_OFFSET)));
}else if (rrcp_opcode==1 || rrcp_opcode==2 || rrcp_proto==2){
- ND_TCHECK2(*(rrcp + RRCP_COOKIE2_OFFSET), 4);
+ ND_TCHECK2(*(cp + RRCP_COOKIE2_OFFSET), 4);
ND_PRINT((ndo, ", cookie=0x%08x%08x ",
- EXTRACT_32BITS(rrcp + RRCP_COOKIE2_OFFSET),
- EXTRACT_32BITS(rrcp + RRCP_COOKIE1_OFFSET)));
+ EXTRACT_32BITS(cp + RRCP_COOKIE2_OFFSET),
+ EXTRACT_32BITS(cp + RRCP_COOKIE1_OFFSET)));
}
- if (!ndo->ndo_vflag)
- return;
return;
trunc:
ND_PRINT((ndo, "[|rrcp]"));
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-rrcp-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-rsvp.c b/freebsd/contrib/tcpdump/print-rsvp.c
index 009ef0c5..223d9ece 100644
--- a/freebsd/contrib/tcpdump/print-rsvp.c
+++ b/freebsd/contrib/tcpdump/print-rsvp.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1998-2007 The TCPDUMP project
*
@@ -17,22 +20,15 @@
* Original code by Hannes Gredler (hannes@juniper.net)
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-rsvp.c,v 1.50 2008-08-16 11:36:20 hannes Exp $";
-#endif
+/* \summary: Resource ReSerVation Protocol (RSVP) printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
#include "addrtoname.h"
#include "ethertype.h"
@@ -40,6 +36,8 @@ static const char rcsid[] _U_ =
#include "af.h"
#include "signature.h"
+static const char tstr[] = " [|rsvp]";
+
/*
* RFC 2205 common header
*
@@ -53,18 +51,18 @@ static const char rcsid[] _U_ =
*/
struct rsvp_common_header {
- u_int8_t version_flags;
- u_int8_t msg_type;
- u_int8_t checksum[2];
- u_int8_t ttl;
- u_int8_t reserved;
- u_int8_t length[2];
+ uint8_t version_flags;
+ uint8_t msg_type;
+ uint8_t checksum[2];
+ uint8_t ttl;
+ uint8_t reserved;
+ uint8_t length[2];
};
-/*
+/*
* RFC2205 object header
*
- *
+ *
* 0 1 2 3
* +-------------+-------------+-------------+-------------+
* | Length (bytes) | Class-Num | C-Type |
@@ -76,13 +74,13 @@ struct rsvp_common_header {
*/
struct rsvp_object_header {
- u_int8_t length[2];
- u_int8_t class_num;
- u_int8_t ctype;
+ uint8_t length[2];
+ uint8_t class_num;
+ uint8_t ctype;
};
#define RSVP_VERSION 1
-#define RSVP_EXTRACT_VERSION(x) (((x)&0xf0)>>4)
+#define RSVP_EXTRACT_VERSION(x) (((x)&0xf0)>>4)
#define RSVP_EXTRACT_FLAGS(x) ((x)&0x0f)
#define RSVP_MSGTYPE_PATH 1
@@ -92,7 +90,7 @@ struct rsvp_object_header {
#define RSVP_MSGTYPE_PATHTEAR 5
#define RSVP_MSGTYPE_RESVTEAR 6
#define RSVP_MSGTYPE_RESVCONF 7
-#define RSVP_MSGTYPE_AGGREGATE 12
+#define RSVP_MSGTYPE_BUNDLE 12
#define RSVP_MSGTYPE_ACK 13
#define RSVP_MSGTYPE_HELLO_OLD 14 /* ancient Hellos */
#define RSVP_MSGTYPE_SREFRESH 15
@@ -106,7 +104,7 @@ static const struct tok rsvp_msg_type_values[] = {
{ RSVP_MSGTYPE_PATHTEAR, "PathTear" },
{ RSVP_MSGTYPE_RESVTEAR, "ResvTear" },
{ RSVP_MSGTYPE_RESVCONF, "ResvConf" },
- { RSVP_MSGTYPE_AGGREGATE, "Aggregate" },
+ { RSVP_MSGTYPE_BUNDLE, "Bundle" },
{ RSVP_MSGTYPE_ACK, "Acknowledgement" },
{ RSVP_MSGTYPE_HELLO_OLD, "Hello (Old)" },
{ RSVP_MSGTYPE_SREFRESH, "Refresh" },
@@ -123,7 +121,7 @@ static const struct tok rsvp_header_flag_values[] = {
#define RSVP_OBJ_RSVP_HOP 3 /* rfc2205, rfc3473 */
#define RSVP_OBJ_INTEGRITY 4 /* rfc2747 */
#define RSVP_OBJ_TIME_VALUES 5 /* rfc2205 */
-#define RSVP_OBJ_ERROR_SPEC 6
+#define RSVP_OBJ_ERROR_SPEC 6
#define RSVP_OBJ_SCOPE 7
#define RSVP_OBJ_STYLE 8 /* rfc2205 */
#define RSVP_OBJ_FLOWSPEC 9 /* rfc2215 */
@@ -302,11 +300,11 @@ static const struct tok rsvp_ctype_values[] = {
};
struct rsvp_obj_integrity_t {
- u_int8_t flags;
- u_int8_t res;
- u_int8_t key_id[6];
- u_int8_t sequence[8];
- u_int8_t digest[16];
+ uint8_t flags;
+ uint8_t res;
+ uint8_t key_id[6];
+ uint8_t sequence[8];
+ uint8_t digest[16];
};
static const struct tok rsvp_obj_integrity_flag_values[] = {
@@ -315,14 +313,14 @@ static const struct tok rsvp_obj_integrity_flag_values[] = {
};
struct rsvp_obj_frr_t {
- u_int8_t setup_prio;
- u_int8_t hold_prio;
- u_int8_t hop_limit;
- u_int8_t flags;
- u_int8_t bandwidth[4];
- u_int8_t include_any[4];
- u_int8_t exclude_any[4];
- u_int8_t include_all[4];
+ uint8_t setup_prio;
+ uint8_t hold_prio;
+ uint8_t hop_limit;
+ uint8_t flags;
+ uint8_t bandwidth[4];
+ uint8_t include_any[4];
+ uint8_t exclude_any[4];
+ uint8_t include_all[4];
};
@@ -392,7 +390,7 @@ static const struct tok rsvp_intserv_parameter_id_values[] = {
{ 0, NULL}
};
-static struct tok rsvp_session_attribute_flag_values[] = {
+static const struct tok rsvp_session_attribute_flag_values[] = {
{ 0x01, "Local Protection" },
{ 0x02, "Label Recording" },
{ 0x04, "SE Style" },
@@ -401,7 +399,7 @@ static struct tok rsvp_session_attribute_flag_values[] = {
{ 0, NULL}
};
-static struct tok rsvp_obj_prop_tlv_values[] = {
+static const struct tok rsvp_obj_prop_tlv_values[] = {
{ 0x01, "Cos" },
{ 0x02, "Metric 1" },
{ 0x04, "Metric 2" },
@@ -415,7 +413,7 @@ static struct tok rsvp_obj_prop_tlv_values[] = {
#define RSVP_OBJ_ERROR_SPEC_CODE_DIFFSERV_TE 28
#define RSVP_OBJ_ERROR_SPEC_CODE_DIFFSERV_TE_OLD 125
-static struct tok rsvp_obj_error_code_values[] = {
+static const struct tok rsvp_obj_error_code_values[] = {
{ RSVP_OBJ_ERROR_SPEC_CODE_ROUTING, "Routing Problem" },
{ RSVP_OBJ_ERROR_SPEC_CODE_NOTIFY, "Notify Error" },
{ RSVP_OBJ_ERROR_SPEC_CODE_DIFFSERV_TE, "Diffserv TE Error" },
@@ -423,7 +421,7 @@ static struct tok rsvp_obj_error_code_values[] = {
{ 0, NULL}
};
-static struct tok rsvp_obj_error_code_routing_values[] = {
+static const struct tok rsvp_obj_error_code_routing_values[] = {
{ 1, "Bad EXPLICIT_ROUTE object" },
{ 2, "Bad strict node" },
{ 3, "Bad loose node" },
@@ -437,14 +435,14 @@ static struct tok rsvp_obj_error_code_routing_values[] = {
{ 0, NULL}
};
-static struct tok rsvp_obj_error_code_diffserv_te_values[] = {
+static const struct tok rsvp_obj_error_code_diffserv_te_values[] = {
{ 1, "Unexpected CT object" },
{ 2, "Unsupported CT" },
{ 3, "Invalid CT value" },
{ 4, "CT/setup priority do not form a configured TE-Class" },
{ 5, "CT/holding priority do not form a configured TE-Class" },
{ 6, "CT/setup priority and CT/holding priority do not form a configured TE-Class" },
- { 7, "Inconsistency between signaled PSC and signaled CT" },
+ { 7, "Inconsistency between signaled PSC and signaled CT" },
{ 8, "Inconsistency between signaled PHBs and signaled CT" },
{ 0, NULL}
};
@@ -488,33 +486,33 @@ static const struct tok rsvp_obj_generalized_uni_values[] = {
{ 0, NULL}
};
-static int rsvp_intserv_print(const u_char *, u_short);
-
-/*
+/*
* this is a dissector for all the intserv defined
* specs as defined per rfc2215
* it is called from various rsvp objects;
* returns the amount of bytes being processed
*/
static int
-rsvp_intserv_print(const u_char *tptr, u_short obj_tlen) {
-
+rsvp_intserv_print(netdissect_options *ndo,
+ const u_char *tptr, u_short obj_tlen)
+{
int parameter_id,parameter_length;
union {
float f;
- u_int32_t i;
+ uint32_t i;
} bw;
if (obj_tlen < 4)
return 0;
parameter_id = *(tptr);
+ ND_TCHECK2(*(tptr + 2), 2);
parameter_length = EXTRACT_16BITS(tptr+2)<<2; /* convert wordcount to bytecount */
- printf("\n\t Parameter ID: %s (%u), length: %u, Flags: [0x%02x]",
+ ND_PRINT((ndo, "\n\t Parameter ID: %s (%u), length: %u, Flags: [0x%02x]",
tok2str(rsvp_intserv_parameter_id_values,"unknown",parameter_id),
parameter_id,
parameter_length,
- *(tptr+1));
+ *(tptr + 1)));
if (obj_tlen < parameter_length+4)
return 0;
@@ -528,8 +526,10 @@ rsvp_intserv_print(const u_char *tptr, u_short obj_tlen) {
* | IS hop cnt (32-bit unsigned integer) |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
- if (parameter_length == 4)
- printf("\n\t\tIS hop count: %u", EXTRACT_32BITS(tptr+4));
+ if (parameter_length == 4) {
+ ND_TCHECK2(*(tptr + 4), 4);
+ ND_PRINT((ndo, "\n\t\tIS hop count: %u", EXTRACT_32BITS(tptr + 4)));
+ }
break;
case 6:
@@ -541,8 +541,9 @@ rsvp_intserv_print(const u_char *tptr, u_short obj_tlen) {
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
if (parameter_length == 4) {
+ ND_TCHECK2(*(tptr + 4), 4);
bw.i = EXTRACT_32BITS(tptr+4);
- printf("\n\t\tPath b/w estimate: %.10g Mbps", bw.f/125000);
+ ND_PRINT((ndo, "\n\t\tPath b/w estimate: %.10g Mbps", bw.f / 125000));
}
break;
@@ -555,11 +556,12 @@ rsvp_intserv_print(const u_char *tptr, u_short obj_tlen) {
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
if (parameter_length == 4) {
- printf("\n\t\tMinimum path latency: ");
+ ND_TCHECK2(*(tptr + 4), 4);
+ ND_PRINT((ndo, "\n\t\tMinimum path latency: "));
if (EXTRACT_32BITS(tptr+4) == 0xffffffff)
- printf("don't care");
+ ND_PRINT((ndo, "don't care"));
else
- printf("%u", EXTRACT_32BITS(tptr+4));
+ ND_PRINT((ndo, "%u", EXTRACT_32BITS(tptr + 4)));
}
break;
@@ -572,11 +574,13 @@ rsvp_intserv_print(const u_char *tptr, u_short obj_tlen) {
* | Composed MTU (32-bit unsigned integer) |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
- if (parameter_length == 4)
- printf("\n\t\tComposed MTU: %u bytes", EXTRACT_32BITS(tptr+4));
+ if (parameter_length == 4) {
+ ND_TCHECK2(*(tptr + 4), 4);
+ ND_PRINT((ndo, "\n\t\tComposed MTU: %u bytes", EXTRACT_32BITS(tptr + 4)));
+ }
break;
case 127:
- /*
+ /*
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | 127 (e) | 0 (f) | 5 (g) |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
@@ -593,19 +597,20 @@ rsvp_intserv_print(const u_char *tptr, u_short obj_tlen) {
*/
if (parameter_length == 20) {
+ ND_TCHECK2(*(tptr + 4), 20);
bw.i = EXTRACT_32BITS(tptr+4);
- printf("\n\t\tToken Bucket Rate: %.10g Mbps", bw.f/125000);
+ ND_PRINT((ndo, "\n\t\tToken Bucket Rate: %.10g Mbps", bw.f / 125000));
bw.i = EXTRACT_32BITS(tptr+8);
- printf("\n\t\tToken Bucket Size: %.10g bytes", bw.f);
+ ND_PRINT((ndo, "\n\t\tToken Bucket Size: %.10g bytes", bw.f));
bw.i = EXTRACT_32BITS(tptr+12);
- printf("\n\t\tPeak Data Rate: %.10g Mbps", bw.f/125000);
- printf("\n\t\tMinimum Policed Unit: %u bytes", EXTRACT_32BITS(tptr+16));
- printf("\n\t\tMaximum Packet Size: %u bytes", EXTRACT_32BITS(tptr+20));
+ ND_PRINT((ndo, "\n\t\tPeak Data Rate: %.10g Mbps", bw.f / 125000));
+ ND_PRINT((ndo, "\n\t\tMinimum Policed Unit: %u bytes", EXTRACT_32BITS(tptr + 16)));
+ ND_PRINT((ndo, "\n\t\tMaximum Packet Size: %u bytes", EXTRACT_32BITS(tptr + 20)));
}
break;
case 130:
- /*
+ /*
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | 130 (h) | 0 (i) | 2 (j) |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
@@ -616,9 +621,10 @@ rsvp_intserv_print(const u_char *tptr, u_short obj_tlen) {
*/
if (parameter_length == 8) {
+ ND_TCHECK2(*(tptr + 4), 8);
bw.i = EXTRACT_32BITS(tptr+4);
- printf("\n\t\tRate: %.10g Mbps", bw.f/125000);
- printf("\n\t\tSlack Term: %u", EXTRACT_32BITS(tptr+8));
+ ND_PRINT((ndo, "\n\t\tRate: %.10g Mbps", bw.f / 125000));
+ ND_PRINT((ndo, "\n\t\tSlack Term: %u", EXTRACT_32BITS(tptr + 8)));
}
break;
@@ -626,29 +632,41 @@ rsvp_intserv_print(const u_char *tptr, u_short obj_tlen) {
case 134:
case 135:
case 136:
- if (parameter_length == 4)
- printf("\n\t\tValue: %u", EXTRACT_32BITS(tptr+4));
+ if (parameter_length == 4) {
+ ND_TCHECK2(*(tptr + 4), 4);
+ ND_PRINT((ndo, "\n\t\tValue: %u", EXTRACT_32BITS(tptr + 4)));
+ }
break;
default:
- if (vflag <= 1)
- print_unknown_data(tptr+4,"\n\t\t",parameter_length);
+ if (ndo->ndo_vflag <= 1)
+ print_unknown_data(ndo, tptr + 4, "\n\t\t", parameter_length);
}
return (parameter_length+4); /* header length 4 bytes */
+
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return 0;
}
-static int
-rsvp_obj_print (const u_char *pptr
-#ifndef HAVE_LIBCRYPTO
-_U_
-#endif
-, u_int plen
-#ifndef HAVE_LIBCRYPTO
-_U_
-#endif
-, const u_char *tptr,
- const char *ident, u_int tlen) {
+/*
+ * Clear checksum prior to signature verification.
+ */
+static void
+rsvp_clear_checksum(void *header)
+{
+ struct rsvp_common_header *rsvp_com_header = (struct rsvp_common_header *) header;
+
+ rsvp_com_header->checksum[0] = 0;
+ rsvp_com_header->checksum[1] = 0;
+}
+static int
+rsvp_obj_print(netdissect_options *ndo,
+ const u_char *pptr, u_int plen, const u_char *tptr,
+ const char *ident, u_int tlen,
+ const struct rsvp_common_header *rsvp_com_header)
+{
const struct rsvp_object_header *rsvp_obj_header;
const u_char *obj_tptr;
union {
@@ -660,52 +678,51 @@ _U_
int hexdump,processed,padbytes,error_code,error_value,i,sigcheck;
union {
float f;
- u_int32_t i;
+ uint32_t i;
} bw;
- u_int8_t namelen;
+ uint8_t namelen;
u_int action, subchannel;
while(tlen>=sizeof(struct rsvp_object_header)) {
/* did we capture enough for fully decoding the object header ? */
- if (!TTEST2(*tptr, sizeof(struct rsvp_object_header)))
- goto trunc;
+ ND_TCHECK2(*tptr, sizeof(struct rsvp_object_header));
rsvp_obj_header = (const struct rsvp_object_header *)tptr;
rsvp_obj_len=EXTRACT_16BITS(rsvp_obj_header->length);
rsvp_obj_ctype=rsvp_obj_header->ctype;
if(rsvp_obj_len % 4) {
- printf("%sERROR: object header size %u not a multiple of 4", ident, rsvp_obj_len);
+ ND_PRINT((ndo, "%sERROR: object header size %u not a multiple of 4", ident, rsvp_obj_len));
return -1;
}
if(rsvp_obj_len < sizeof(struct rsvp_object_header)) {
- printf("%sERROR: object header too short %u < %lu", ident, rsvp_obj_len,
- (unsigned long)sizeof(const struct rsvp_object_header));
+ ND_PRINT((ndo, "%sERROR: object header too short %u < %lu", ident, rsvp_obj_len,
+ (unsigned long)sizeof(const struct rsvp_object_header)));
return -1;
}
- printf("%s%s Object (%u) Flags: [%s",
+ ND_PRINT((ndo, "%s%s Object (%u) Flags: [%s",
ident,
tok2str(rsvp_obj_values,
"Unknown",
rsvp_obj_header->class_num),
rsvp_obj_header->class_num,
- ((rsvp_obj_header->class_num)&0x80) ? "ignore" : "reject");
+ ((rsvp_obj_header->class_num) & 0x80) ? "ignore" : "reject"));
if (rsvp_obj_header->class_num > 128)
- printf(" %s",
- ((rsvp_obj_header->class_num)&0x40) ? "and forward" : "silently");
+ ND_PRINT((ndo, " %s",
+ ((rsvp_obj_header->class_num) & 0x40) ? "and forward" : "silently"));
- printf(" if unknown], Class-Type: %s (%u), length: %u",
+ ND_PRINT((ndo, " if unknown], Class-Type: %s (%u), length: %u",
tok2str(rsvp_ctype_values,
"Unknown",
((rsvp_obj_header->class_num)<<8)+rsvp_obj_ctype),
rsvp_obj_ctype,
- rsvp_obj_len);
-
+ rsvp_obj_len));
+
if(tlen < rsvp_obj_len) {
- printf("%sERROR: object goes past end of objects TLV", ident);
+ ND_PRINT((ndo, "%sERROR: object goes past end of objects TLV", ident));
return -1;
}
@@ -713,7 +730,7 @@ _U_
obj_tlen=rsvp_obj_len-sizeof(struct rsvp_object_header);
/* did we capture enough for fully decoding the object ? */
- if (!TTEST2(*tptr, rsvp_obj_len))
+ if (!ND_TTEST2(*tptr, rsvp_obj_len))
return -1;
hexdump=FALSE;
@@ -723,79 +740,77 @@ _U_
case RSVP_CTYPE_IPV4:
if (obj_tlen < 8)
return -1;
- printf("%s IPv4 DestAddress: %s, Protocol ID: 0x%02x",
+ ND_PRINT((ndo, "%s IPv4 DestAddress: %s, Protocol ID: 0x%02x",
ident,
- ipaddr_string(obj_tptr),
- *(obj_tptr+sizeof(struct in_addr)));
- printf("%s Flags: [0x%02x], DestPort %u",
+ ipaddr_string(ndo, obj_tptr),
+ *(obj_tptr + sizeof(struct in_addr))));
+ ND_PRINT((ndo, "%s Flags: [0x%02x], DestPort %u",
ident,
*(obj_tptr+5),
- EXTRACT_16BITS(obj_tptr+6));
+ EXTRACT_16BITS(obj_tptr + 6)));
obj_tlen-=8;
- obj_tptr+=8;
+ obj_tptr+=8;
break;
-#ifdef INET6
case RSVP_CTYPE_IPV6:
if (obj_tlen < 20)
return -1;
- printf("%s IPv6 DestAddress: %s, Protocol ID: 0x%02x",
+ ND_PRINT((ndo, "%s IPv6 DestAddress: %s, Protocol ID: 0x%02x",
ident,
- ip6addr_string(obj_tptr),
- *(obj_tptr+sizeof(struct in6_addr)));
- printf("%s Flags: [0x%02x], DestPort %u",
+ ip6addr_string(ndo, obj_tptr),
+ *(obj_tptr + sizeof(struct in6_addr))));
+ ND_PRINT((ndo, "%s Flags: [0x%02x], DestPort %u",
ident,
*(obj_tptr+sizeof(struct in6_addr)+1),
- EXTRACT_16BITS(obj_tptr+sizeof(struct in6_addr)+2));
+ EXTRACT_16BITS(obj_tptr + sizeof(struct in6_addr) + 2)));
obj_tlen-=20;
- obj_tptr+=20;
+ obj_tptr+=20;
break;
case RSVP_CTYPE_TUNNEL_IPV6:
if (obj_tlen < 36)
return -1;
- printf("%s IPv6 Tunnel EndPoint: %s, Tunnel ID: 0x%04x, Extended Tunnel ID: %s",
+ ND_PRINT((ndo, "%s IPv6 Tunnel EndPoint: %s, Tunnel ID: 0x%04x, Extended Tunnel ID: %s",
ident,
- ip6addr_string(obj_tptr),
+ ip6addr_string(ndo, obj_tptr),
EXTRACT_16BITS(obj_tptr+18),
- ip6addr_string(obj_tptr+20));
+ ip6addr_string(ndo, obj_tptr + 20)));
obj_tlen-=36;
- obj_tptr+=36;
+ obj_tptr+=36;
break;
case RSVP_CTYPE_14: /* IPv6 p2mp LSP Tunnel */
if (obj_tlen < 26)
return -1;
- printf("%s IPv6 P2MP LSP ID: 0x%08x, Tunnel ID: 0x%04x, Extended Tunnel ID: %s",
+ ND_PRINT((ndo, "%s IPv6 P2MP LSP ID: 0x%08x, Tunnel ID: 0x%04x, Extended Tunnel ID: %s",
ident,
EXTRACT_32BITS(obj_tptr),
EXTRACT_16BITS(obj_tptr+6),
- ip6addr_string(obj_tptr+8));
+ ip6addr_string(ndo, obj_tptr + 8)));
obj_tlen-=26;
- obj_tptr+=26;
+ obj_tptr+=26;
break;
-#endif
case RSVP_CTYPE_13: /* IPv4 p2mp LSP Tunnel */
if (obj_tlen < 12)
return -1;
- printf("%s IPv4 P2MP LSP ID: %s, Tunnel ID: 0x%04x, Extended Tunnel ID: %s",
+ ND_PRINT((ndo, "%s IPv4 P2MP LSP ID: %s, Tunnel ID: 0x%04x, Extended Tunnel ID: %s",
ident,
- ipaddr_string(obj_tptr),
+ ipaddr_string(ndo, obj_tptr),
EXTRACT_16BITS(obj_tptr+6),
- ipaddr_string(obj_tptr+8));
+ ipaddr_string(ndo, obj_tptr + 8)));
obj_tlen-=12;
- obj_tptr+=12;
+ obj_tptr+=12;
break;
case RSVP_CTYPE_TUNNEL_IPV4:
case RSVP_CTYPE_UNI_IPV4:
if (obj_tlen < 12)
return -1;
- printf("%s IPv4 Tunnel EndPoint: %s, Tunnel ID: 0x%04x, Extended Tunnel ID: %s",
+ ND_PRINT((ndo, "%s IPv4 Tunnel EndPoint: %s, Tunnel ID: 0x%04x, Extended Tunnel ID: %s",
ident,
- ipaddr_string(obj_tptr),
+ ipaddr_string(ndo, obj_tptr),
EXTRACT_16BITS(obj_tptr+6),
- ipaddr_string(obj_tptr+8));
+ ipaddr_string(ndo, obj_tptr + 8)));
obj_tlen-=12;
- obj_tptr+=12;
+ obj_tptr+=12;
break;
default:
hexdump=TRUE;
@@ -807,23 +822,21 @@ _U_
case RSVP_CTYPE_IPV4:
if (obj_tlen < sizeof(struct in_addr))
return -1;
- printf("%s IPv4 Receiver Address: %s",
+ ND_PRINT((ndo, "%s IPv4 Receiver Address: %s",
ident,
- ipaddr_string(obj_tptr));
+ ipaddr_string(ndo, obj_tptr)));
obj_tlen-=sizeof(struct in_addr);
- obj_tptr+=sizeof(struct in_addr);
+ obj_tptr+=sizeof(struct in_addr);
break;
-#ifdef INET6
case RSVP_CTYPE_IPV6:
if (obj_tlen < sizeof(struct in6_addr))
return -1;
- printf("%s IPv6 Receiver Address: %s",
+ ND_PRINT((ndo, "%s IPv6 Receiver Address: %s",
ident,
- ip6addr_string(obj_tptr));
+ ip6addr_string(ndo, obj_tptr)));
obj_tlen-=sizeof(struct in6_addr);
- obj_tptr+=sizeof(struct in6_addr);
+ obj_tptr+=sizeof(struct in6_addr);
break;
-#endif
default:
hexdump=TRUE;
}
@@ -834,23 +847,21 @@ _U_
case RSVP_CTYPE_IPV4:
if (obj_tlen < sizeof(struct in_addr))
return -1;
- printf("%s IPv4 Notify Node Address: %s",
+ ND_PRINT((ndo, "%s IPv4 Notify Node Address: %s",
ident,
- ipaddr_string(obj_tptr));
+ ipaddr_string(ndo, obj_tptr)));
obj_tlen-=sizeof(struct in_addr);
- obj_tptr+=sizeof(struct in_addr);
+ obj_tptr+=sizeof(struct in_addr);
break;
-#ifdef INET6
case RSVP_CTYPE_IPV6:
if (obj_tlen < sizeof(struct in6_addr))
return-1;
- printf("%s IPv6 Notify Node Address: %s",
+ ND_PRINT((ndo, "%s IPv6 Notify Node Address: %s",
ident,
- ip6addr_string(obj_tptr));
+ ip6addr_string(ndo, obj_tptr)));
obj_tlen-=sizeof(struct in6_addr);
- obj_tptr+=sizeof(struct in6_addr);
+ obj_tptr+=sizeof(struct in6_addr);
break;
-#endif
default:
hexdump=TRUE;
}
@@ -863,7 +874,7 @@ _U_
switch(rsvp_obj_ctype) {
case RSVP_CTYPE_1:
while(obj_tlen >= 4 ) {
- printf("%s Label: %u", ident, EXTRACT_32BITS(obj_tptr));
+ ND_PRINT((ndo, "%s Label: %u", ident, EXTRACT_32BITS(obj_tptr)));
obj_tlen-=4;
obj_tptr+=4;
}
@@ -871,21 +882,21 @@ _U_
case RSVP_CTYPE_2:
if (obj_tlen < 4)
return-1;
- printf("%s Generalized Label: %u",
+ ND_PRINT((ndo, "%s Generalized Label: %u",
ident,
- EXTRACT_32BITS(obj_tptr));
+ EXTRACT_32BITS(obj_tptr)));
obj_tlen-=4;
obj_tptr+=4;
break;
case RSVP_CTYPE_3:
if (obj_tlen < 12)
return-1;
- printf("%s Waveband ID: %u%s Start Label: %u, Stop Label: %u",
+ ND_PRINT((ndo, "%s Waveband ID: %u%s Start Label: %u, Stop Label: %u",
ident,
EXTRACT_32BITS(obj_tptr),
ident,
EXTRACT_32BITS(obj_tptr+4),
- EXTRACT_32BITS(obj_tptr+8));
+ EXTRACT_32BITS(obj_tptr + 8)));
obj_tlen-=12;
obj_tptr+=12;
break;
@@ -899,12 +910,12 @@ _U_
case RSVP_CTYPE_1:
if (obj_tlen < 4)
return-1;
- printf("%s Reservation Style: %s, Flags: [0x%02x]",
+ ND_PRINT((ndo, "%s Reservation Style: %s, Flags: [0x%02x]",
ident,
tok2str(rsvp_resstyle_values,
"Unknown",
EXTRACT_24BITS(obj_tptr+1)),
- *(obj_tptr));
+ *(obj_tptr)));
obj_tlen-=4;
obj_tptr+=4;
break;
@@ -918,60 +929,58 @@ _U_
case RSVP_CTYPE_IPV4:
if (obj_tlen < 8)
return-1;
- printf("%s Source Address: %s, Source Port: %u",
+ ND_PRINT((ndo, "%s Source Address: %s, Source Port: %u",
ident,
- ipaddr_string(obj_tptr),
- EXTRACT_16BITS(obj_tptr+6));
+ ipaddr_string(ndo, obj_tptr),
+ EXTRACT_16BITS(obj_tptr + 6)));
obj_tlen-=8;
obj_tptr+=8;
break;
-#ifdef INET6
case RSVP_CTYPE_IPV6:
if (obj_tlen < 20)
return-1;
- printf("%s Source Address: %s, Source Port: %u",
+ ND_PRINT((ndo, "%s Source Address: %s, Source Port: %u",
ident,
- ip6addr_string(obj_tptr),
- EXTRACT_16BITS(obj_tptr+18));
+ ip6addr_string(ndo, obj_tptr),
+ EXTRACT_16BITS(obj_tptr + 18)));
obj_tlen-=20;
obj_tptr+=20;
break;
case RSVP_CTYPE_13: /* IPv6 p2mp LSP tunnel */
if (obj_tlen < 40)
return-1;
- printf("%s IPv6 Tunnel Sender Address: %s, LSP ID: 0x%04x"
+ ND_PRINT((ndo, "%s IPv6 Tunnel Sender Address: %s, LSP ID: 0x%04x"
"%s Sub-Group Originator ID: %s, Sub-Group ID: 0x%04x",
ident,
- ip6addr_string(obj_tptr),
+ ip6addr_string(ndo, obj_tptr),
EXTRACT_16BITS(obj_tptr+18),
ident,
- ip6addr_string(obj_tptr+20),
- EXTRACT_16BITS(obj_tptr+38));
+ ip6addr_string(ndo, obj_tptr+20),
+ EXTRACT_16BITS(obj_tptr + 38)));
obj_tlen-=40;
obj_tptr+=40;
break;
-#endif
case RSVP_CTYPE_TUNNEL_IPV4:
if (obj_tlen < 8)
return-1;
- printf("%s IPv4 Tunnel Sender Address: %s, LSP-ID: 0x%04x",
+ ND_PRINT((ndo, "%s IPv4 Tunnel Sender Address: %s, LSP-ID: 0x%04x",
ident,
- ipaddr_string(obj_tptr),
- EXTRACT_16BITS(obj_tptr+6));
+ ipaddr_string(ndo, obj_tptr),
+ EXTRACT_16BITS(obj_tptr + 6)));
obj_tlen-=8;
obj_tptr+=8;
break;
case RSVP_CTYPE_12: /* IPv4 p2mp LSP tunnel */
if (obj_tlen < 16)
return-1;
- printf("%s IPv4 Tunnel Sender Address: %s, LSP ID: 0x%04x"
+ ND_PRINT((ndo, "%s IPv4 Tunnel Sender Address: %s, LSP ID: 0x%04x"
"%s Sub-Group Originator ID: %s, Sub-Group ID: 0x%04x",
ident,
- ipaddr_string(obj_tptr),
+ ipaddr_string(ndo, obj_tptr),
EXTRACT_16BITS(obj_tptr+6),
ident,
- ipaddr_string(obj_tptr+8),
- EXTRACT_16BITS(obj_tptr+12));
+ ipaddr_string(ndo, obj_tptr+8),
+ EXTRACT_16BITS(obj_tptr + 12)));
obj_tlen-=16;
obj_tptr+=16;
break;
@@ -984,11 +993,11 @@ _U_
switch(rsvp_obj_ctype) {
case RSVP_CTYPE_1:
while(obj_tlen >= 4 ) {
- printf("%s L3 Protocol ID: %s",
+ ND_PRINT((ndo, "%s L3 Protocol ID: %s",
ident,
tok2str(ethertype_values,
"Unknown Protocol (0x%04x)",
- EXTRACT_16BITS(obj_tptr+2)));
+ EXTRACT_16BITS(obj_tptr + 2))));
obj_tlen-=4;
obj_tptr+=4;
}
@@ -996,50 +1005,50 @@ _U_
case RSVP_CTYPE_2:
if (obj_tlen < 12)
return-1;
- printf("%s L3 Protocol ID: %s",
+ ND_PRINT((ndo, "%s L3 Protocol ID: %s",
ident,
tok2str(ethertype_values,
"Unknown Protocol (0x%04x)",
- EXTRACT_16BITS(obj_tptr+2)));
- printf(",%s merge capability",((*(obj_tptr+4))&0x80) ? "no" : "" );
- printf("%s Minimum VPI/VCI: %u/%u",
+ EXTRACT_16BITS(obj_tptr + 2))));
+ ND_PRINT((ndo, ",%s merge capability",((*(obj_tptr + 4)) & 0x80) ? "no" : "" ));
+ ND_PRINT((ndo, "%s Minimum VPI/VCI: %u/%u",
ident,
(EXTRACT_16BITS(obj_tptr+4))&0xfff,
- (EXTRACT_16BITS(obj_tptr+6))&0xfff);
- printf("%s Maximum VPI/VCI: %u/%u",
+ (EXTRACT_16BITS(obj_tptr + 6)) & 0xfff));
+ ND_PRINT((ndo, "%s Maximum VPI/VCI: %u/%u",
ident,
(EXTRACT_16BITS(obj_tptr+8))&0xfff,
- (EXTRACT_16BITS(obj_tptr+10))&0xfff);
+ (EXTRACT_16BITS(obj_tptr + 10)) & 0xfff));
obj_tlen-=12;
obj_tptr+=12;
break;
case RSVP_CTYPE_3:
if (obj_tlen < 12)
return-1;
- printf("%s L3 Protocol ID: %s",
+ ND_PRINT((ndo, "%s L3 Protocol ID: %s",
ident,
tok2str(ethertype_values,
"Unknown Protocol (0x%04x)",
- EXTRACT_16BITS(obj_tptr+2)));
- printf("%s Minimum/Maximum DLCI: %u/%u, %s%s bit DLCI",
+ EXTRACT_16BITS(obj_tptr + 2))));
+ ND_PRINT((ndo, "%s Minimum/Maximum DLCI: %u/%u, %s%s bit DLCI",
ident,
(EXTRACT_32BITS(obj_tptr+4))&0x7fffff,
(EXTRACT_32BITS(obj_tptr+8))&0x7fffff,
(((EXTRACT_16BITS(obj_tptr+4)>>7)&3) == 0 ) ? "10" : "",
- (((EXTRACT_16BITS(obj_tptr+4)>>7)&3) == 2 ) ? "23" : "");
+ (((EXTRACT_16BITS(obj_tptr + 4) >> 7) & 3) == 2 ) ? "23" : ""));
obj_tlen-=12;
obj_tptr+=12;
break;
case RSVP_CTYPE_4:
if (obj_tlen < 4)
return-1;
- printf("%s LSP Encoding Type: %s (%u)",
+ ND_PRINT((ndo, "%s LSP Encoding Type: %s (%u)",
ident,
tok2str(gmpls_encoding_values,
"Unknown",
*obj_tptr),
- *obj_tptr);
- printf("%s Switching Type: %s (%u), Payload ID: %s (0x%04x)",
+ *obj_tptr));
+ ND_PRINT((ndo, "%s Switching Type: %s (%u), Payload ID: %s (0x%04x)",
ident,
tok2str(gmpls_switch_cap_values,
"Unknown",
@@ -1048,7 +1057,7 @@ _U_
tok2str(gmpls_payload_values,
"Unknown",
EXTRACT_16BITS(obj_tptr+2)),
- EXTRACT_16BITS(obj_tptr+2));
+ EXTRACT_16BITS(obj_tptr + 2)));
obj_tlen-=4;
obj_tptr+=4;
break;
@@ -1062,30 +1071,52 @@ _U_
switch(rsvp_obj_ctype) {
case RSVP_CTYPE_IPV4:
while(obj_tlen >= 4 ) {
- printf("%s Subobject Type: %s, length %u",
+ u_char length;
+
+ ND_TCHECK2(*obj_tptr, 4);
+ length = *(obj_tptr + 1);
+ ND_PRINT((ndo, "%s Subobject Type: %s, length %u",
ident,
tok2str(rsvp_obj_xro_values,
"Unknown %u",
RSVP_OBJ_XRO_MASK_SUBOBJ(*obj_tptr)),
- *(obj_tptr+1));
+ length));
- if (*(obj_tptr+1) == 0) { /* prevent infinite loops */
- printf("%s ERROR: zero length ERO subtype",ident);
+ if (length == 0) { /* prevent infinite loops */
+ ND_PRINT((ndo, "%s ERROR: zero length ERO subtype", ident));
break;
}
switch(RSVP_OBJ_XRO_MASK_SUBOBJ(*obj_tptr)) {
+ u_char prefix_length;
+
case RSVP_OBJ_XRO_IPV4:
- printf(", %s, %s/%u, Flags: [%s]",
+ if (length != 8) {
+ ND_PRINT((ndo, " ERROR: length != 8"));
+ goto invalid;
+ }
+ ND_TCHECK2(*obj_tptr, 8);
+ prefix_length = *(obj_tptr+6);
+ if (prefix_length != 32) {
+ ND_PRINT((ndo, " ERROR: Prefix length %u != 32",
+ prefix_length));
+ goto invalid;
+ }
+ ND_PRINT((ndo, ", %s, %s/%u, Flags: [%s]",
RSVP_OBJ_XRO_MASK_LOOSE(*obj_tptr) ? "Loose" : "Strict",
- ipaddr_string(obj_tptr+2),
+ ipaddr_string(ndo, obj_tptr+2),
*(obj_tptr+6),
bittok2str(rsvp_obj_rro_flag_values,
"none",
- *(obj_tptr+7))); /* rfc3209 says that this field is rsvd. */
+ *(obj_tptr + 7)))); /* rfc3209 says that this field is rsvd. */
break;
case RSVP_OBJ_XRO_LABEL:
- printf(", Flags: [%s] (%#x), Class-Type: %s (%u), %u",
+ if (length != 8) {
+ ND_PRINT((ndo, " ERROR: length != 8"));
+ goto invalid;
+ }
+ ND_TCHECK2(*obj_tptr, 8);
+ ND_PRINT((ndo, ", Flags: [%s] (%#x), Class-Type: %s (%u), %u",
bittok2str(rsvp_obj_rro_label_flag_values,
"none",
*(obj_tptr+2)),
@@ -1094,7 +1125,7 @@ _U_
"Unknown",
*(obj_tptr+3) + 256*RSVP_OBJ_RRO),
*(obj_tptr+3),
- EXTRACT_32BITS(obj_tptr+4));
+ EXTRACT_32BITS(obj_tptr + 4)));
}
obj_tlen-=*(obj_tptr+1);
obj_tptr+=*(obj_tptr+1);
@@ -1111,10 +1142,10 @@ _U_
case RSVP_CTYPE_2:
if (obj_tlen < 8)
return-1;
- printf("%s Source Instance: 0x%08x, Destination Instance: 0x%08x",
+ ND_PRINT((ndo, "%s Source Instance: 0x%08x, Destination Instance: 0x%08x",
ident,
EXTRACT_32BITS(obj_tptr),
- EXTRACT_32BITS(obj_tptr+4));
+ EXTRACT_32BITS(obj_tptr + 4)));
obj_tlen-=8;
obj_tptr+=8;
break;
@@ -1128,10 +1159,10 @@ _U_
case RSVP_CTYPE_1:
if (obj_tlen < 8)
return-1;
- printf("%s Restart Time: %ums, Recovery Time: %ums",
+ ND_PRINT((ndo, "%s Restart Time: %ums, Recovery Time: %ums",
ident,
EXTRACT_32BITS(obj_tptr),
- EXTRACT_32BITS(obj_tptr+4));
+ EXTRACT_32BITS(obj_tptr + 4)));
obj_tlen-=8;
obj_tptr+=8;
break;
@@ -1148,17 +1179,17 @@ _U_
namelen = *(obj_tptr+3);
if (obj_tlen < 4+namelen)
return-1;
- printf("%s Session Name: ", ident);
+ ND_PRINT((ndo, "%s Session Name: ", ident));
for (i = 0; i < namelen; i++)
- safeputchar(*(obj_tptr+4+i));
- printf("%s Setup Priority: %u, Holding Priority: %u, Flags: [%s] (%#x)",
+ safeputchar(ndo, *(obj_tptr + 4 + i));
+ ND_PRINT((ndo, "%s Setup Priority: %u, Holding Priority: %u, Flags: [%s] (%#x)",
ident,
(int)*obj_tptr,
(int)*(obj_tptr+1),
bittok2str(rsvp_session_attribute_flag_values,
"none",
*(obj_tptr+2)),
- *(obj_tptr+2));
+ *(obj_tptr + 2)));
obj_tlen-=4+*(obj_tptr+3);
obj_tptr+=4+*(obj_tptr+3);
break;
@@ -1171,7 +1202,7 @@ _U_
switch(rsvp_obj_ctype) {
int subobj_type,af,subobj_len,total_subobj_len;
- case RSVP_CTYPE_1:
+ case RSVP_CTYPE_1:
if (obj_tlen < 4)
return-1;
@@ -1183,12 +1214,15 @@ _U_
subobj_type = (EXTRACT_16BITS(obj_tptr+2))>>8;
af = (EXTRACT_16BITS(obj_tptr+2))&0x00FF;
- printf("%s Subobject Type: %s (%u), AF: %s (%u), length: %u",
+ ND_PRINT((ndo, "%s Subobject Type: %s (%u), AF: %s (%u), length: %u",
ident,
tok2str(rsvp_obj_generalized_uni_values, "Unknown", subobj_type),
subobj_type,
tok2str(af_values, "Unknown", af), af,
- subobj_len);
+ subobj_len));
+
+ if(subobj_len == 0)
+ goto invalid;
switch(subobj_type) {
case RSVP_GEN_UNI_SUBOBJ_SOURCE_TNA_ADDRESS:
@@ -1198,17 +1232,15 @@ _U_
case AFNUM_INET:
if (subobj_len < 8)
return -1;
- printf("%s UNI IPv4 TNA address: %s",
- ident, ipaddr_string(obj_tptr+4));
+ ND_PRINT((ndo, "%s UNI IPv4 TNA address: %s",
+ ident, ipaddr_string(ndo, obj_tptr + 4)));
break;
-#ifdef INET6
case AFNUM_INET6:
if (subobj_len < 20)
return -1;
- printf("%s UNI IPv6 TNA address: %s",
- ident, ip6addr_string(obj_tptr+4));
+ ND_PRINT((ndo, "%s UNI IPv6 TNA address: %s",
+ ident, ip6addr_string(ndo, obj_tptr + 4)));
break;
-#endif
case AFNUM_NSAP:
if (subobj_len) {
/* unless we have a TLV parser lets just hexdump */
@@ -1230,12 +1262,12 @@ _U_
return -1;
}
- printf("%s U-bit: %x, Label type: %u, Logical port id: %u, Label: %u",
+ ND_PRINT((ndo, "%s U-bit: %x, Label type: %u, Logical port id: %u, Label: %u",
ident,
((EXTRACT_32BITS(obj_tptr+4))>>31),
((EXTRACT_32BITS(obj_tptr+4))&0xFF),
EXTRACT_32BITS(obj_tptr+8),
- EXTRACT_32BITS(obj_tptr+12));
+ EXTRACT_32BITS(obj_tptr + 12)));
break;
case RSVP_GEN_UNI_SUBOBJ_SERVICE_LEVEL:
@@ -1243,8 +1275,8 @@ _U_
return -1;
}
- printf("%s Service level: %u",
- ident, (EXTRACT_32BITS(obj_tptr+4))>>24);
+ ND_PRINT((ndo, "%s Service level: %u",
+ ident, (EXTRACT_32BITS(obj_tptr + 4)) >> 24));
break;
default:
@@ -1273,29 +1305,27 @@ _U_
case RSVP_CTYPE_IPV4:
if (obj_tlen < 8)
return-1;
- printf("%s Previous/Next Interface: %s, Logical Interface Handle: 0x%08x",
+ ND_PRINT((ndo, "%s Previous/Next Interface: %s, Logical Interface Handle: 0x%08x",
ident,
- ipaddr_string(obj_tptr),
- EXTRACT_32BITS(obj_tptr+4));
+ ipaddr_string(ndo, obj_tptr),
+ EXTRACT_32BITS(obj_tptr + 4)));
obj_tlen-=8;
obj_tptr+=8;
if (obj_tlen)
hexdump=TRUE; /* unless we have a TLV parser lets just hexdump */
break;
-#ifdef INET6
case RSVP_CTYPE_4: /* fall through - FIXME add TLV parser */
case RSVP_CTYPE_IPV6:
if (obj_tlen < 20)
return-1;
- printf("%s Previous/Next Interface: %s, Logical Interface Handle: 0x%08x",
+ ND_PRINT((ndo, "%s Previous/Next Interface: %s, Logical Interface Handle: 0x%08x",
ident,
- ip6addr_string(obj_tptr),
- EXTRACT_32BITS(obj_tptr+16));
+ ip6addr_string(ndo, obj_tptr),
+ EXTRACT_32BITS(obj_tptr + 16)));
obj_tlen-=20;
obj_tptr+=20;
hexdump=TRUE; /* unless we have a TLV parser lets just hexdump */
break;
-#endif
default:
hexdump=TRUE;
}
@@ -1306,9 +1336,9 @@ _U_
case RSVP_CTYPE_1:
if (obj_tlen < 4)
return-1;
- printf("%s Refresh Period: %ums",
+ ND_PRINT((ndo, "%s Refresh Period: %ums",
ident,
- EXTRACT_32BITS(obj_tptr));
+ EXTRACT_32BITS(obj_tptr)));
obj_tlen-=4;
obj_tptr+=4;
break;
@@ -1325,27 +1355,27 @@ _U_
case RSVP_CTYPE_2:
if (obj_tlen < 4)
return-1;
- printf("%s Msg-Version: %u, length: %u",
+ ND_PRINT((ndo, "%s Msg-Version: %u, length: %u",
ident,
(*obj_tptr & 0xf0) >> 4,
- EXTRACT_16BITS(obj_tptr+2)<<2);
+ EXTRACT_16BITS(obj_tptr + 2) << 2));
obj_tptr+=4; /* get to the start of the service header */
obj_tlen-=4;
while (obj_tlen >= 4) {
intserv_serv_tlen=EXTRACT_16BITS(obj_tptr+2)<<2;
- printf("%s Service Type: %s (%u), break bit %s set, Service length: %u",
+ ND_PRINT((ndo, "%s Service Type: %s (%u), break bit %s set, Service length: %u",
ident,
tok2str(rsvp_intserv_service_type_values,"unknown",*(obj_tptr)),
*(obj_tptr),
(*(obj_tptr+1)&0x80) ? "" : "not",
- intserv_serv_tlen);
-
+ intserv_serv_tlen));
+
obj_tptr+=4; /* get to the start of the parameter list */
obj_tlen-=4;
while (intserv_serv_tlen>=4) {
- processed = rsvp_intserv_print(obj_tptr, obj_tlen);
+ processed = rsvp_intserv_print(ndo, obj_tptr, obj_tlen);
if (processed == 0)
break;
obj_tlen-=processed;
@@ -1364,80 +1394,78 @@ _U_
case RSVP_CTYPE_IPV4:
if (obj_tlen < 8)
return-1;
- printf("%s Source Address: %s, Source Port: %u",
+ ND_PRINT((ndo, "%s Source Address: %s, Source Port: %u",
ident,
- ipaddr_string(obj_tptr),
- EXTRACT_16BITS(obj_tptr+6));
+ ipaddr_string(ndo, obj_tptr),
+ EXTRACT_16BITS(obj_tptr + 6)));
obj_tlen-=8;
obj_tptr+=8;
break;
-#ifdef INET6
case RSVP_CTYPE_IPV6:
if (obj_tlen < 20)
return-1;
- printf("%s Source Address: %s, Source Port: %u",
+ ND_PRINT((ndo, "%s Source Address: %s, Source Port: %u",
ident,
- ip6addr_string(obj_tptr),
- EXTRACT_16BITS(obj_tptr+18));
+ ip6addr_string(ndo, obj_tptr),
+ EXTRACT_16BITS(obj_tptr + 18)));
obj_tlen-=20;
obj_tptr+=20;
break;
case RSVP_CTYPE_3:
if (obj_tlen < 20)
return-1;
- printf("%s Source Address: %s, Flow Label: %u",
+ ND_PRINT((ndo, "%s Source Address: %s, Flow Label: %u",
ident,
- ip6addr_string(obj_tptr),
- EXTRACT_24BITS(obj_tptr+17));
+ ip6addr_string(ndo, obj_tptr),
+ EXTRACT_24BITS(obj_tptr + 17)));
obj_tlen-=20;
obj_tptr+=20;
break;
case RSVP_CTYPE_TUNNEL_IPV6:
if (obj_tlen < 20)
return-1;
- printf("%s Source Address: %s, LSP-ID: 0x%04x",
+ ND_PRINT((ndo, "%s Source Address: %s, LSP-ID: 0x%04x",
ident,
- ipaddr_string(obj_tptr),
- EXTRACT_16BITS(obj_tptr+18));
+ ipaddr_string(ndo, obj_tptr),
+ EXTRACT_16BITS(obj_tptr + 18)));
obj_tlen-=20;
obj_tptr+=20;
break;
case RSVP_CTYPE_13: /* IPv6 p2mp LSP tunnel */
if (obj_tlen < 40)
return-1;
- printf("%s IPv6 Tunnel Sender Address: %s, LSP ID: 0x%04x"
+ ND_PRINT((ndo, "%s IPv6 Tunnel Sender Address: %s, LSP ID: 0x%04x"
"%s Sub-Group Originator ID: %s, Sub-Group ID: 0x%04x",
ident,
- ip6addr_string(obj_tptr),
+ ip6addr_string(ndo, obj_tptr),
EXTRACT_16BITS(obj_tptr+18),
ident,
- ip6addr_string(obj_tptr+20),
- EXTRACT_16BITS(obj_tptr+38));
+ ip6addr_string(ndo, obj_tptr+20),
+ EXTRACT_16BITS(obj_tptr + 38)));
obj_tlen-=40;
obj_tptr+=40;
break;
-#endif
case RSVP_CTYPE_TUNNEL_IPV4:
if (obj_tlen < 8)
return-1;
- printf("%s Source Address: %s, LSP-ID: 0x%04x",
+ ND_PRINT((ndo, "%s Source Address: %s, LSP-ID: 0x%04x",
ident,
- ipaddr_string(obj_tptr),
- EXTRACT_16BITS(obj_tptr+6));
+ ipaddr_string(ndo, obj_tptr),
+ EXTRACT_16BITS(obj_tptr + 6)));
obj_tlen-=8;
obj_tptr+=8;
break;
case RSVP_CTYPE_12: /* IPv4 p2mp LSP tunnel */
if (obj_tlen < 16)
return-1;
- printf("%s IPv4 Tunnel Sender Address: %s, LSP ID: 0x%04x"
+ ND_PRINT((ndo, "%s IPv4 Tunnel Sender Address: %s, LSP ID: 0x%04x"
"%s Sub-Group Originator ID: %s, Sub-Group ID: 0x%04x",
ident,
- ipaddr_string(obj_tptr),
+ ipaddr_string(ndo, obj_tptr),
EXTRACT_16BITS(obj_tptr+6),
ident,
- ipaddr_string(obj_tptr+8),
- EXTRACT_16BITS(obj_tptr+12));
+ ipaddr_string(ndo, obj_tptr+8),
+ EXTRACT_16BITS(obj_tptr + 12)));
obj_tlen-=16;
obj_tptr+=16;
break;
@@ -1455,17 +1483,17 @@ _U_
case RSVP_CTYPE_1: /* new style */
if (obj_tlen < sizeof(struct rsvp_obj_frr_t))
return-1;
- printf("%s Setup Priority: %u, Holding Priority: %u, Hop-limit: %u, Bandwidth: %.10g Mbps",
+ ND_PRINT((ndo, "%s Setup Priority: %u, Holding Priority: %u, Hop-limit: %u, Bandwidth: %.10g Mbps",
ident,
(int)obj_ptr.rsvp_obj_frr->setup_prio,
(int)obj_ptr.rsvp_obj_frr->hold_prio,
(int)obj_ptr.rsvp_obj_frr->hop_limit,
- bw.f*8/1000000);
- printf("%s Include-any: 0x%08x, Exclude-any: 0x%08x, Include-all: 0x%08x",
+ bw.f * 8 / 1000000));
+ ND_PRINT((ndo, "%s Include-any: 0x%08x, Exclude-any: 0x%08x, Include-all: 0x%08x",
ident,
EXTRACT_32BITS(obj_ptr.rsvp_obj_frr->include_any),
EXTRACT_32BITS(obj_ptr.rsvp_obj_frr->exclude_any),
- EXTRACT_32BITS(obj_ptr.rsvp_obj_frr->include_all));
+ EXTRACT_32BITS(obj_ptr.rsvp_obj_frr->include_all)));
obj_tlen-=sizeof(struct rsvp_obj_frr_t);
obj_tptr+=sizeof(struct rsvp_obj_frr_t);
break;
@@ -1473,16 +1501,16 @@ _U_
case RSVP_CTYPE_TUNNEL_IPV4: /* old style */
if (obj_tlen < 16)
return-1;
- printf("%s Setup Priority: %u, Holding Priority: %u, Hop-limit: %u, Bandwidth: %.10g Mbps",
+ ND_PRINT((ndo, "%s Setup Priority: %u, Holding Priority: %u, Hop-limit: %u, Bandwidth: %.10g Mbps",
ident,
(int)obj_ptr.rsvp_obj_frr->setup_prio,
(int)obj_ptr.rsvp_obj_frr->hold_prio,
(int)obj_ptr.rsvp_obj_frr->hop_limit,
- bw.f*8/1000000);
- printf("%s Include Colors: 0x%08x, Exclude Colors: 0x%08x",
+ bw.f * 8 / 1000000));
+ ND_PRINT((ndo, "%s Include Colors: 0x%08x, Exclude Colors: 0x%08x",
ident,
EXTRACT_32BITS(obj_ptr.rsvp_obj_frr->include_any),
- EXTRACT_32BITS(obj_ptr.rsvp_obj_frr->exclude_any));
+ EXTRACT_32BITS(obj_ptr.rsvp_obj_frr->exclude_any)));
obj_tlen-=16;
obj_tptr+=16;
break;
@@ -1496,10 +1524,10 @@ _U_
switch(rsvp_obj_ctype) {
case RSVP_CTYPE_TUNNEL_IPV4:
while(obj_tlen >= 8) {
- printf("%s PLR-ID: %s, Avoid-Node-ID: %s",
+ ND_PRINT((ndo, "%s PLR-ID: %s, Avoid-Node-ID: %s",
ident,
- ipaddr_string(obj_tptr),
- ipaddr_string(obj_tptr+4));
+ ipaddr_string(ndo, obj_tptr),
+ ipaddr_string(ndo, obj_tptr + 4)));
obj_tlen-=8;
obj_tptr+=8;
}
@@ -1513,9 +1541,9 @@ _U_
case RSVP_OBJ_CLASSTYPE_OLD: /* fall through */
switch(rsvp_obj_ctype) {
case RSVP_CTYPE_1:
- printf("%s CT: %u",
+ ND_PRINT((ndo, "%s CT: %u",
ident,
- EXTRACT_32BITS(obj_tptr)&0x7);
+ EXTRACT_32BITS(obj_tptr) & 0x7));
obj_tlen-=4;
obj_tptr+=4;
break;
@@ -1532,52 +1560,51 @@ _U_
return-1;
error_code=*(obj_tptr+5);
error_value=EXTRACT_16BITS(obj_tptr+6);
- printf("%s Error Node Address: %s, Flags: [0x%02x]%s Error Code: %s (%u)",
+ ND_PRINT((ndo, "%s Error Node Address: %s, Flags: [0x%02x]%s Error Code: %s (%u)",
ident,
- ipaddr_string(obj_tptr),
+ ipaddr_string(ndo, obj_tptr),
*(obj_tptr+4),
ident,
tok2str(rsvp_obj_error_code_values,"unknown",error_code),
- error_code);
+ error_code));
switch (error_code) {
case RSVP_OBJ_ERROR_SPEC_CODE_ROUTING:
- printf(", Error Value: %s (%u)",
+ ND_PRINT((ndo, ", Error Value: %s (%u)",
tok2str(rsvp_obj_error_code_routing_values,"unknown",error_value),
- error_value);
+ error_value));
break;
case RSVP_OBJ_ERROR_SPEC_CODE_DIFFSERV_TE: /* fall through */
case RSVP_OBJ_ERROR_SPEC_CODE_DIFFSERV_TE_OLD:
- printf(", Error Value: %s (%u)",
+ ND_PRINT((ndo, ", Error Value: %s (%u)",
tok2str(rsvp_obj_error_code_diffserv_te_values,"unknown",error_value),
- error_value);
+ error_value));
break;
default:
- printf(", Unknown Error Value (%u)", error_value);
+ ND_PRINT((ndo, ", Unknown Error Value (%u)", error_value));
break;
}
obj_tlen-=8;
obj_tptr+=8;
break;
-#ifdef INET6
case RSVP_CTYPE_4: /* fall through - FIXME add TLV parser */
case RSVP_CTYPE_IPV6:
if (obj_tlen < 20)
return-1;
error_code=*(obj_tptr+17);
error_value=EXTRACT_16BITS(obj_tptr+18);
- printf("%s Error Node Address: %s, Flags: [0x%02x]%s Error Code: %s (%u)",
+ ND_PRINT((ndo, "%s Error Node Address: %s, Flags: [0x%02x]%s Error Code: %s (%u)",
ident,
- ip6addr_string(obj_tptr),
+ ip6addr_string(ndo, obj_tptr),
*(obj_tptr+16),
ident,
tok2str(rsvp_obj_error_code_values,"unknown",error_code),
- error_code);
+ error_code));
switch (error_code) {
case RSVP_OBJ_ERROR_SPEC_CODE_ROUTING:
- printf(", Error Value: %s (%u)",
+ ND_PRINT((ndo, ", Error Value: %s (%u)",
tok2str(rsvp_obj_error_code_routing_values,"unknown",error_value),
- error_value);
+ error_value));
break;
default:
break;
@@ -1585,7 +1612,6 @@ _U_
obj_tlen-=20;
obj_tptr+=20;
break;
-#endif
default:
hexdump=TRUE;
}
@@ -1597,24 +1623,24 @@ _U_
if (obj_tlen < 4)
return-1;
padbytes = EXTRACT_16BITS(obj_tptr+2);
- printf("%s TLV count: %u, padding bytes: %u",
+ ND_PRINT((ndo, "%s TLV count: %u, padding bytes: %u",
ident,
EXTRACT_16BITS(obj_tptr),
- padbytes);
+ padbytes));
obj_tlen-=4;
obj_tptr+=4;
/* loop through as long there is anything longer than the TLV header (2) */
while(obj_tlen >= 2 + padbytes) {
- printf("%s %s TLV (0x%02x), length: %u", /* length includes header */
+ ND_PRINT((ndo, "%s %s TLV (0x%02x), length: %u", /* length includes header */
ident,
tok2str(rsvp_obj_prop_tlv_values,"unknown",*obj_tptr),
*obj_tptr,
- *(obj_tptr+1));
+ *(obj_tptr + 1)));
if (obj_tlen < *(obj_tptr+1))
return-1;
if (*(obj_tptr+1) < 2)
return -1;
- print_unknown_data(obj_tptr+2,"\n\t\t",*(obj_tptr+1)-2);
+ print_unknown_data(ndo, obj_tptr + 2, "\n\t\t", *(obj_tptr + 1) - 2);
obj_tlen-=*(obj_tptr+1);
obj_tptr+=*(obj_tptr+1);
}
@@ -1632,18 +1658,18 @@ _U_
case RSVP_CTYPE_2:
if (obj_tlen < 8)
return-1;
- printf("%s Flags [0x%02x], epoch: %u",
+ ND_PRINT((ndo, "%s Flags [0x%02x], epoch: %u",
ident,
*obj_tptr,
- EXTRACT_24BITS(obj_tptr+1));
+ EXTRACT_24BITS(obj_tptr + 1)));
obj_tlen-=4;
obj_tptr+=4;
/* loop through as long there are no messages left */
while(obj_tlen >= 4) {
- printf("%s Message-ID 0x%08x (%u)",
+ ND_PRINT((ndo, "%s Message-ID 0x%08x (%u)",
ident,
EXTRACT_32BITS(obj_tptr),
- EXTRACT_32BITS(obj_tptr));
+ EXTRACT_32BITS(obj_tptr)));
obj_tlen-=4;
obj_tptr+=4;
}
@@ -1659,7 +1685,7 @@ _U_
if (obj_tlen < sizeof(struct rsvp_obj_integrity_t))
return-1;
obj_ptr.rsvp_obj_integrity = (const struct rsvp_obj_integrity_t *)obj_tptr;
- printf("%s Key-ID 0x%04x%08x, Sequence 0x%08x%08x, Flags [%s]",
+ ND_PRINT((ndo, "%s Key-ID 0x%04x%08x, Sequence 0x%08x%08x, Flags [%s]",
ident,
EXTRACT_16BITS(obj_ptr.rsvp_obj_integrity->key_id),
EXTRACT_32BITS(obj_ptr.rsvp_obj_integrity->key_id+2),
@@ -1667,21 +1693,19 @@ _U_
EXTRACT_32BITS(obj_ptr.rsvp_obj_integrity->sequence+4),
bittok2str(rsvp_obj_integrity_flag_values,
"none",
- obj_ptr.rsvp_obj_integrity->flags));
- printf("%s MD5-sum 0x%08x%08x%08x%08x ",
+ obj_ptr.rsvp_obj_integrity->flags)));
+ ND_PRINT((ndo, "%s MD5-sum 0x%08x%08x%08x%08x ",
ident,
EXTRACT_32BITS(obj_ptr.rsvp_obj_integrity->digest),
EXTRACT_32BITS(obj_ptr.rsvp_obj_integrity->digest+4),
EXTRACT_32BITS(obj_ptr.rsvp_obj_integrity->digest+8),
- EXTRACT_32BITS(obj_ptr.rsvp_obj_integrity->digest+12));
+ EXTRACT_32BITS(obj_ptr.rsvp_obj_integrity->digest + 12)));
-#ifdef HAVE_LIBCRYPTO
- sigcheck = signature_verify(pptr, plen, (unsigned char *)obj_ptr.\
- rsvp_obj_integrity->digest);
-#else
- sigcheck = CANT_CHECK_SIGNATURE;
-#endif
- printf(" (%s)", tok2str(signature_check_values, "Unknown", sigcheck));
+ sigcheck = signature_verify(ndo, pptr, plen,
+ obj_ptr.rsvp_obj_integrity->digest,
+ rsvp_clear_checksum,
+ rsvp_com_header);
+ ND_PRINT((ndo, " (%s)", tok2str(signature_check_values, "Unknown", sigcheck)));
obj_tlen+=sizeof(struct rsvp_obj_integrity_t);
obj_tptr+=sizeof(struct rsvp_obj_integrity_t);
@@ -1689,16 +1713,16 @@ _U_
default:
hexdump=TRUE;
}
- break;
+ break;
case RSVP_OBJ_ADMIN_STATUS:
switch(rsvp_obj_ctype) {
- case RSVP_CTYPE_1:
+ case RSVP_CTYPE_1:
if (obj_tlen < 4)
return-1;
- printf("%s Flags [%s]", ident,
+ ND_PRINT((ndo, "%s Flags [%s]", ident,
bittok2str(rsvp_obj_admin_status_flag_values, "none",
- EXTRACT_32BITS(obj_tptr)));
+ EXTRACT_32BITS(obj_tptr))));
obj_tlen-=4;
obj_tptr+=4;
break;
@@ -1709,14 +1733,14 @@ _U_
case RSVP_OBJ_LABEL_SET:
switch(rsvp_obj_ctype) {
- case RSVP_CTYPE_1:
+ case RSVP_CTYPE_1:
if (obj_tlen < 4)
return-1;
action = (EXTRACT_16BITS(obj_tptr)>>8);
- printf("%s Action: %s (%u), Label type: %u", ident,
+ ND_PRINT((ndo, "%s Action: %s (%u), Label type: %u", ident,
tok2str(rsvp_obj_label_set_action_values, "Unknown", action),
- action, ((EXTRACT_32BITS(obj_tptr) & 0x7F)));
+ action, ((EXTRACT_32BITS(obj_tptr) & 0x7F))));
switch (action) {
case LABEL_SET_INCLUSIVE_RANGE:
@@ -1725,9 +1749,9 @@ _U_
/* only a couple of subchannels are expected */
if (obj_tlen < 12)
return -1;
- printf("%s Start range: %u, End range: %u", ident,
+ ND_PRINT((ndo, "%s Start range: %u, End range: %u", ident,
EXTRACT_32BITS(obj_tptr+4),
- EXTRACT_32BITS(obj_tptr+8));
+ EXTRACT_32BITS(obj_tptr + 8)));
obj_tlen-=12;
obj_tptr+=12;
break;
@@ -1737,8 +1761,8 @@ _U_
obj_tptr+=4;
subchannel = 1;
while(obj_tlen >= 4 ) {
- printf("%s Subchannel #%u: %u", ident, subchannel,
- EXTRACT_32BITS(obj_tptr));
+ ND_PRINT((ndo, "%s Subchannel #%u: %u", ident, subchannel,
+ EXTRACT_32BITS(obj_tptr)));
obj_tptr+=4;
obj_tlen-=4;
subchannel++;
@@ -1752,26 +1776,24 @@ _U_
case RSVP_OBJ_S2L:
switch (rsvp_obj_ctype) {
- case RSVP_CTYPE_IPV4:
+ case RSVP_CTYPE_IPV4:
if (obj_tlen < 4)
return-1;
- printf("%s Sub-LSP destination address: %s",
- ident, ipaddr_string(obj_tptr));
+ ND_PRINT((ndo, "%s Sub-LSP destination address: %s",
+ ident, ipaddr_string(ndo, obj_tptr)));
obj_tlen-=4;
obj_tptr+=4;
break;
-#ifdef INET6
- case RSVP_CTYPE_IPV6:
+ case RSVP_CTYPE_IPV6:
if (obj_tlen < 16)
return-1;
- printf("%s Sub-LSP destination address: %s",
- ident, ip6addr_string(obj_tptr));
+ ND_PRINT((ndo, "%s Sub-LSP destination address: %s",
+ ident, ip6addr_string(ndo, obj_tptr)));
obj_tlen-=16;
obj_tptr+=16;
break;
-#endif
default:
hexdump=TRUE;
}
@@ -1786,52 +1808,56 @@ _U_
case RSVP_OBJ_ACCEPT_LABEL_SET:
case RSVP_OBJ_PROTECTION:
default:
- if (vflag <= 1)
- print_unknown_data(obj_tptr,"\n\t ",obj_tlen); /* FIXME indentation */
+ if (ndo->ndo_vflag <= 1)
+ print_unknown_data(ndo, obj_tptr, "\n\t ", obj_tlen); /* FIXME indentation */
break;
}
/* do we also want to see a hex dump ? */
- if (vflag > 1 || hexdump==TRUE)
- print_unknown_data(tptr+sizeof(struct rsvp_object_header),"\n\t ", /* FIXME indentation */
- rsvp_obj_len-sizeof(struct rsvp_object_header));
+ if (ndo->ndo_vflag > 1 || hexdump == TRUE)
+ print_unknown_data(ndo, tptr + sizeof(struct rsvp_object_header), "\n\t ", /* FIXME indentation */
+ rsvp_obj_len - sizeof(struct rsvp_object_header));
tptr+=rsvp_obj_len;
tlen-=rsvp_obj_len;
}
return 0;
+invalid:
+ ND_PRINT((ndo, "%s", istr));
+ return -1;
trunc:
- printf("\n\t\t packet exceeded snapshot");
+ ND_PRINT((ndo, "\n\t\t"));
+ ND_PRINT((ndo, "%s", tstr));
return -1;
}
-
void
-rsvp_print(register const u_char *pptr, register u_int len) {
-
- struct rsvp_common_header *rsvp_com_header;
- const u_char *tptr,*subtptr;
- u_short plen, tlen, subtlen;
+rsvp_print(netdissect_options *ndo,
+ register const u_char *pptr, register u_int len)
+{
+ const struct rsvp_common_header *rsvp_com_header;
+ const u_char *tptr;
+ u_short plen, tlen;
tptr=pptr;
- rsvp_com_header = (struct rsvp_common_header *)pptr;
- TCHECK(*rsvp_com_header);
+ rsvp_com_header = (const struct rsvp_common_header *)pptr;
+ ND_TCHECK(*rsvp_com_header);
/*
* Sanity checking of the header.
*/
if (RSVP_EXTRACT_VERSION(rsvp_com_header->version_flags) != RSVP_VERSION) {
- printf("ERROR: RSVP version %u packet not supported",
- RSVP_EXTRACT_VERSION(rsvp_com_header->version_flags));
+ ND_PRINT((ndo, "ERROR: RSVP version %u packet not supported",
+ RSVP_EXTRACT_VERSION(rsvp_com_header->version_flags)));
return;
}
/* in non-verbose mode just lets print the basic Message Type*/
- if (vflag < 1) {
- printf("RSVPv%u %s Message, length: %u",
+ if (ndo->ndo_vflag < 1) {
+ ND_PRINT((ndo, "RSVPv%u %s Message, length: %u",
RSVP_EXTRACT_VERSION(rsvp_com_header->version_flags),
tok2str(rsvp_msg_type_values, "unknown (%u)",rsvp_com_header->msg_type),
- len);
+ len));
return;
}
@@ -1839,24 +1865,18 @@ rsvp_print(register const u_char *pptr, register u_int len) {
plen = tlen = EXTRACT_16BITS(rsvp_com_header->length);
- printf("\n\tRSVPv%u %s Message (%u), Flags: [%s], length: %u, ttl: %u, checksum: 0x%04x",
+ ND_PRINT((ndo, "\n\tRSVPv%u %s Message (%u), Flags: [%s], length: %u, ttl: %u, checksum: 0x%04x",
RSVP_EXTRACT_VERSION(rsvp_com_header->version_flags),
tok2str(rsvp_msg_type_values, "unknown, type: %u",rsvp_com_header->msg_type),
rsvp_com_header->msg_type,
bittok2str(rsvp_header_flag_values,"none",RSVP_EXTRACT_FLAGS(rsvp_com_header->version_flags)),
tlen,
rsvp_com_header->ttl,
- EXTRACT_16BITS(rsvp_com_header->checksum));
-
- /*
- * Clear checksum prior to signature verification.
- */
- rsvp_com_header->checksum[0] = 0;
- rsvp_com_header->checksum[1] = 0;
+ EXTRACT_16BITS(rsvp_com_header->checksum)));
if (tlen < sizeof(const struct rsvp_common_header)) {
- printf("ERROR: common header too short %u < %lu", tlen,
- (unsigned long)sizeof(const struct rsvp_common_header));
+ ND_PRINT((ndo, "ERROR: common header too short %u < %lu", tlen,
+ (unsigned long)sizeof(const struct rsvp_common_header)));
return;
}
@@ -1865,53 +1885,60 @@ rsvp_print(register const u_char *pptr, register u_int len) {
switch(rsvp_com_header->msg_type) {
- case RSVP_MSGTYPE_AGGREGATE:
+ case RSVP_MSGTYPE_BUNDLE:
+ /*
+ * Process each submessage in the bundle message.
+ * Bundle messages may not contain bundle submessages, so we don't
+ * need to handle bundle submessages specially.
+ */
while(tlen > 0) {
- subtptr=tptr;
- rsvp_com_header = (struct rsvp_common_header *)subtptr;
- TCHECK(*rsvp_com_header);
+ const u_char *subpptr=tptr, *subtptr;
+ u_short subplen, subtlen;
+
+ subtptr=subpptr;
+
+ rsvp_com_header = (const struct rsvp_common_header *)subpptr;
+ ND_TCHECK(*rsvp_com_header);
/*
* Sanity checking of the header.
*/
if (RSVP_EXTRACT_VERSION(rsvp_com_header->version_flags) != RSVP_VERSION) {
- printf("ERROR: RSVP version %u packet not supported",
- RSVP_EXTRACT_VERSION(rsvp_com_header->version_flags));
+ ND_PRINT((ndo, "ERROR: RSVP version %u packet not supported",
+ RSVP_EXTRACT_VERSION(rsvp_com_header->version_flags)));
return;
}
- subtlen=EXTRACT_16BITS(rsvp_com_header->length);
-
- printf("\n\t RSVPv%u %s Message (%u), Flags: [%s], length: %u, ttl: %u, checksum: 0x%04x",
+
+ subplen = subtlen = EXTRACT_16BITS(rsvp_com_header->length);
+
+ ND_PRINT((ndo, "\n\t RSVPv%u %s Message (%u), Flags: [%s], length: %u, ttl: %u, checksum: 0x%04x",
RSVP_EXTRACT_VERSION(rsvp_com_header->version_flags),
tok2str(rsvp_msg_type_values, "unknown, type: %u",rsvp_com_header->msg_type),
rsvp_com_header->msg_type,
bittok2str(rsvp_header_flag_values,"none",RSVP_EXTRACT_FLAGS(rsvp_com_header->version_flags)),
subtlen,
rsvp_com_header->ttl,
- EXTRACT_16BITS(rsvp_com_header->checksum));
+ EXTRACT_16BITS(rsvp_com_header->checksum)));
- /*
- * Clear checksum prior to signature verification.
- */
- rsvp_com_header->checksum[0] = 0;
- rsvp_com_header->checksum[1] = 0;
-
if (subtlen < sizeof(const struct rsvp_common_header)) {
- printf("ERROR: common header too short %u < %lu", subtlen,
- (unsigned long)sizeof(const struct rsvp_common_header));
+ ND_PRINT((ndo, "ERROR: common header too short %u < %lu", subtlen,
+ (unsigned long)sizeof(const struct rsvp_common_header)));
return;
}
if (tlen < subtlen) {
- printf("ERROR: common header too large %u > %u", subtlen,
- tlen);
+ ND_PRINT((ndo, "ERROR: common header too large %u > %u", subtlen,
+ tlen));
return;
}
subtptr+=sizeof(const struct rsvp_common_header);
subtlen-=sizeof(const struct rsvp_common_header);
- if (rsvp_obj_print(pptr, plen, subtptr,"\n\t ", subtlen) == -1)
+ /*
+ * Print all objects in the submessage.
+ */
+ if (rsvp_obj_print(ndo, subpptr, subplen, subtptr, "\n\t ", subtlen, rsvp_com_header) == -1)
return;
tptr+=subtlen+sizeof(const struct rsvp_common_header);
@@ -1931,16 +1958,23 @@ rsvp_print(register const u_char *pptr, register u_int len) {
case RSVP_MSGTYPE_HELLO:
case RSVP_MSGTYPE_ACK:
case RSVP_MSGTYPE_SREFRESH:
- if (rsvp_obj_print(pptr, plen, tptr,"\n\t ", tlen) == -1)
+ /*
+ * Print all objects in the message.
+ */
+ if (rsvp_obj_print(ndo, pptr, plen, tptr, "\n\t ", tlen, rsvp_com_header) == -1)
return;
break;
- default:
- print_unknown_data(tptr,"\n\t ",tlen);
+ default:
+ print_unknown_data(ndo, tptr, "\n\t ", tlen);
break;
}
return;
trunc:
- printf("\n\t\t packet exceeded snapshot");
+ ND_PRINT((ndo, "\n\t\t"));
+ ND_PRINT((ndo, "%s", tstr));
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-rsvp-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-rt6.c b/freebsd/contrib/tcpdump/print-rt6.c
index c9501c92..e90143c5 100644
--- a/freebsd/contrib/tcpdump/print-rt6.c
+++ b/freebsd/contrib/tcpdump/print-rt6.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1988, 1989, 1990, 1991, 1993, 1994
* The Regents of the University of California. All rights reserved.
@@ -21,29 +24,24 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-rt6.c,v 1.27 2005-04-20 22:34:57 guy Exp $";
-#endif
+/* \summary: IPv6 routing header printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#ifdef INET6
-
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include <stdio.h>
+#include <string.h>
#include "ip6.h"
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "extract.h"
int
-rt6_print(register const u_char *bp, const u_char *bp2 _U_)
+rt6_print(netdissect_options *ndo, register const u_char *bp, const u_char *bp2 _U_)
{
register const struct ip6_rthdr *dp;
register const struct ip6_rthdr0 *dp0;
@@ -51,33 +49,27 @@ rt6_print(register const u_char *bp, const u_char *bp2 _U_)
int i, len;
register const struct in6_addr *addr;
- dp = (struct ip6_rthdr *)bp;
+ dp = (const struct ip6_rthdr *)bp;
len = dp->ip6r_len;
/* 'ep' points to the end of available data. */
- ep = snapend;
+ ep = ndo->ndo_snapend;
- TCHECK(dp->ip6r_segleft);
+ ND_TCHECK(dp->ip6r_segleft);
- printf("srcrt (len=%d", dp->ip6r_len); /*)*/
- printf(", type=%d", dp->ip6r_type);
- printf(", segleft=%d", dp->ip6r_segleft);
+ ND_PRINT((ndo, "srcrt (len=%d", dp->ip6r_len)); /*)*/
+ ND_PRINT((ndo, ", type=%d", dp->ip6r_type));
+ ND_PRINT((ndo, ", segleft=%d", dp->ip6r_segleft));
switch (dp->ip6r_type) {
-#ifndef IPV6_RTHDR_TYPE_0
-#define IPV6_RTHDR_TYPE_0 0
-#endif
-#ifndef IPV6_RTHDR_TYPE_2
-#define IPV6_RTHDR_TYPE_2 2
-#endif
case IPV6_RTHDR_TYPE_0:
case IPV6_RTHDR_TYPE_2: /* Mobile IPv6 ID-20 */
- dp0 = (struct ip6_rthdr0 *)dp;
+ dp0 = (const struct ip6_rthdr0 *)dp;
- TCHECK(dp0->ip6r0_reserved);
- if (dp0->ip6r0_reserved || vflag) {
- printf(", rsv=0x%0x",
- EXTRACT_32BITS(&dp0->ip6r0_reserved));
+ ND_TCHECK(dp0->ip6r0_reserved);
+ if (dp0->ip6r0_reserved || ndo->ndo_vflag) {
+ ND_PRINT((ndo, ", rsv=0x%0x",
+ EXTRACT_32BITS(&dp0->ip6r0_reserved)));
}
if (len % 2 == 1)
@@ -85,14 +77,14 @@ rt6_print(register const u_char *bp, const u_char *bp2 _U_)
len >>= 1;
addr = &dp0->ip6r0_addr[0];
for (i = 0; i < len; i++) {
- if ((u_char *)(addr + 1) > ep)
+ if ((const u_char *)(addr + 1) > ep)
goto trunc;
- printf(", [%d]%s", i, ip6addr_string(addr));
+ ND_PRINT((ndo, ", [%d]%s", i, ip6addr_string(ndo, addr)));
addr++;
}
/*(*/
- printf(") ");
+ ND_PRINT((ndo, ") "));
return((dp0->ip6r0_len + 1) << 3);
break;
default:
@@ -101,7 +93,9 @@ rt6_print(register const u_char *bp, const u_char *bp2 _U_)
}
trunc:
- fputs("[|srcrt]", stdout);
+ ND_PRINT((ndo, "[|srcrt]"));
return -1;
}
-#endif /* INET6 */
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-rt6-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-rtsp.c b/freebsd/contrib/tcpdump/print-rtsp.c
new file mode 100644
index 00000000..2b7d2ac4
--- /dev/null
+++ b/freebsd/contrib/tcpdump/print-rtsp.c
@@ -0,0 +1,55 @@
+#include <machine/rtems-bsd-user-space.h>
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
+/*
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code
+ * distributions retain the above copyright notice and this paragraph
+ * in its entirety, and (2) distributions including binary code include
+ * the above copyright notice and this paragraph in its entirety in
+ * the documentation or other materials provided with the distribution.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND
+ * WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
+ * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE.
+ */
+
+/* \summary: Real Time Streaming Protocol (RTSP) printer */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <netdissect-stdinc.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "netdissect.h"
+#include "extract.h"
+
+static const char *rtspcmds[] = {
+ "DESCRIBE",
+ "ANNOUNCE",
+ "GET_PARAMETER",
+ "OPTIONS",
+ "PAUSE",
+ "PLAY",
+ "RECORD",
+ "REDIRECT",
+ "SETUP",
+ "SET_PARAMETER",
+ "TEARDOWN",
+ NULL
+};
+
+void
+rtsp_print(netdissect_options *ndo, const u_char *pptr, u_int len)
+{
+ txtproto_print(ndo, pptr, len, "rtsp", rtspcmds, RESP_CODE_SECOND_TOKEN);
+}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-rtsp-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-rx.c b/freebsd/contrib/tcpdump/print-rx.c
index 26ed1c63..f86c0f84 100644
--- a/freebsd/contrib/tcpdump/print-rx.c
+++ b/freebsd/contrib/tcpdump/print-rx.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright: (c) 2000 United States Government as represented by the
* Secretary of the Navy. All rights reserved.
@@ -22,6 +25,9 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
+
+/* \summary: AFS RX printer */
+
/*
* This code unmangles RX packets. RX is the mutant form of RPC that AFS
* uses to communicate between clients and servers.
@@ -34,11 +40,6 @@
* Ken Hornstein <kenh@cmf.nrl.navy.mil>
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-rx.c,v 1.42 2008-07-01 07:44:50 guy Exp $";
-#endif
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -46,17 +47,95 @@ static const char rcsid[] _U_ =
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "extract.h"
-#include "rx.h"
-
#include "ip.h"
-static struct tok rx_types[] = {
+#define FS_RX_PORT 7000
+#define CB_RX_PORT 7001
+#define PROT_RX_PORT 7002
+#define VLDB_RX_PORT 7003
+#define KAUTH_RX_PORT 7004
+#define VOL_RX_PORT 7005
+#define ERROR_RX_PORT 7006 /* Doesn't seem to be used */
+#define BOS_RX_PORT 7007
+
+#define AFSNAMEMAX 256
+#define AFSOPAQUEMAX 1024
+#define PRNAMEMAX 64
+#define VLNAMEMAX 65
+#define KANAMEMAX 64
+#define BOSNAMEMAX 256
+
+#define PRSFS_READ 1 /* Read files */
+#define PRSFS_WRITE 2 /* Write files */
+#define PRSFS_INSERT 4 /* Insert files into a directory */
+#define PRSFS_LOOKUP 8 /* Lookup files into a directory */
+#define PRSFS_DELETE 16 /* Delete files */
+#define PRSFS_LOCK 32 /* Lock files */
+#define PRSFS_ADMINISTER 64 /* Change ACL's */
+
+struct rx_header {
+ uint32_t epoch;
+ uint32_t cid;
+ uint32_t callNumber;
+ uint32_t seq;
+ uint32_t serial;
+ uint8_t type;
+#define RX_PACKET_TYPE_DATA 1
+#define RX_PACKET_TYPE_ACK 2
+#define RX_PACKET_TYPE_BUSY 3
+#define RX_PACKET_TYPE_ABORT 4
+#define RX_PACKET_TYPE_ACKALL 5
+#define RX_PACKET_TYPE_CHALLENGE 6
+#define RX_PACKET_TYPE_RESPONSE 7
+#define RX_PACKET_TYPE_DEBUG 8
+#define RX_PACKET_TYPE_PARAMS 9
+#define RX_PACKET_TYPE_VERSION 13
+ uint8_t flags;
+#define RX_CLIENT_INITIATED 1
+#define RX_REQUEST_ACK 2
+#define RX_LAST_PACKET 4
+#define RX_MORE_PACKETS 8
+#define RX_FREE_PACKET 16
+#define RX_SLOW_START_OK 32
+#define RX_JUMBO_PACKET 32
+ uint8_t userStatus;
+ uint8_t securityIndex;
+ uint16_t spare; /* How clever: even though the AFS */
+ uint16_t serviceId; /* header files indicate that the */
+}; /* serviceId is first, it's really */
+ /* encoded _after_ the spare field */
+ /* I wasted a day figuring that out! */
+
+#define NUM_RX_FLAGS 7
+
+#define RX_MAXACKS 255
+
+struct rx_ackPacket {
+ uint16_t bufferSpace; /* Number of packet buffers available */
+ uint16_t maxSkew; /* Max diff between ack'd packet and */
+ /* highest packet received */
+ uint32_t firstPacket; /* The first packet in ack list */
+ uint32_t previousPacket; /* Previous packet recv'd (obsolete) */
+ uint32_t serial; /* # of packet that prompted the ack */
+ uint8_t reason; /* Reason for acknowledgement */
+ uint8_t nAcks; /* Number of acknowledgements */
+ uint8_t acks[RX_MAXACKS]; /* Up to RX_MAXACKS acknowledgements */
+};
+
+/*
+ * Values for the acks array
+ */
+
+#define RX_ACK_TYPE_NACK 0 /* Don't have this packet */
+#define RX_ACK_TYPE_ACK 1 /* I have this packet */
+
+static const struct tok rx_types[] = {
{ RX_PACKET_TYPE_DATA, "data" },
{ RX_PACKET_TYPE_ACK, "ack" },
{ RX_PACKET_TYPE_BUSY, "busy" },
@@ -70,7 +149,7 @@ static struct tok rx_types[] = {
{ 0, NULL },
};
-static struct double_tok {
+static const struct double_tok {
int flag; /* Rx flag */
int packetType; /* Packet type */
const char *s; /* Flag string */
@@ -84,7 +163,7 @@ static struct double_tok {
{ RX_JUMBO_PACKET, RX_PACKET_TYPE_DATA, "jumbogram" }
};
-static struct tok fs_req[] = {
+static const struct tok fs_req[] = {
{ 130, "fetch-data" },
{ 131, "fetch-acl" },
{ 132, "fetch-status" },
@@ -129,7 +208,7 @@ static struct tok fs_req[] = {
{ 0, NULL },
};
-static struct tok cb_req[] = {
+static const struct tok cb_req[] = {
{ 204, "callback" },
{ 205, "initcb" },
{ 206, "probe" },
@@ -151,7 +230,7 @@ static struct tok cb_req[] = {
{ 0, NULL },
};
-static struct tok pt_req[] = {
+static const struct tok pt_req[] = {
{ 500, "new-user" },
{ 501, "where-is-it" },
{ 502, "dump-entry" },
@@ -178,7 +257,7 @@ static struct tok pt_req[] = {
{ 0, NULL },
};
-static struct tok vldb_req[] = {
+static const struct tok vldb_req[] = {
{ 501, "create-entry" },
{ 502, "delete-entry" },
{ 503, "get-entry-by-id" },
@@ -216,7 +295,7 @@ static struct tok vldb_req[] = {
{ 0, NULL },
};
-static struct tok kauth_req[] = {
+static const struct tok kauth_req[] = {
{ 1, "auth-old" },
{ 21, "authenticate" },
{ 22, "authenticate-v2" },
@@ -238,7 +317,7 @@ static struct tok kauth_req[] = {
{ 0, NULL },
};
-static struct tok vol_req[] = {
+static const struct tok vol_req[] = {
{ 100, "create-volume" },
{ 101, "delete-volume" },
{ 102, "restore" },
@@ -274,7 +353,7 @@ static struct tok vol_req[] = {
{ 0, NULL },
};
-static struct tok bos_req[] = {
+static const struct tok bos_req[] = {
{ 80, "create-bnode" },
{ 81, "delete-bnode" },
{ 82, "set-status" },
@@ -315,7 +394,7 @@ static struct tok bos_req[] = {
{ 0, NULL },
};
-static struct tok ubik_req[] = {
+static const struct tok ubik_req[] = {
{ 10000, "vote-beacon" },
{ 10001, "vote-debug-old" },
{ 10002, "vote-sdebug-old" },
@@ -346,14 +425,14 @@ static struct tok ubik_req[] = {
#define DISK_LOW 20000
#define DISK_HIGH 20013
-static struct tok cb_types[] = {
+static const struct tok cb_types[] = {
{ 1, "exclusive" },
{ 2, "shared" },
{ 3, "dropped" },
{ 0, NULL },
};
-static struct tok ubik_lock_types[] = {
+static const struct tok ubik_lock_types[] = {
{ 1, "read" },
{ 2, "write" },
{ 3, "wait" },
@@ -362,7 +441,7 @@ static struct tok ubik_lock_types[] = {
static const char *voltype[] = { "read-write", "read-only", "backup" };
-static struct tok afs_fs_errors[] = {
+static const struct tok afs_fs_errors[] = {
{ 101, "salvage volume" },
{ 102, "no such vnode" },
{ 103, "no such volume" },
@@ -375,7 +454,7 @@ static struct tok afs_fs_errors[] = {
{ 110, "volume busy" },
{ 111, "volume moved" },
{ 112, "AFS IO error" },
- { -100, "restarting fileserver" },
+ { 0xffffff9c, "restarting fileserver" }, /* -100, sic! */
{ 0, NULL }
};
@@ -383,7 +462,7 @@ static struct tok afs_fs_errors[] = {
* Reasons for acknowledging a packet
*/
-static struct tok rx_ack_reasons[] = {
+static const struct tok rx_ack_reasons[] = {
{ 1, "ack requested" },
{ 2, "duplicate packet" },
{ 3, "out of sequence" },
@@ -402,12 +481,12 @@ static struct tok rx_ack_reasons[] = {
*/
struct rx_cache_entry {
- u_int32_t callnum; /* Call number (net order) */
+ uint32_t callnum; /* Call number (net order) */
struct in_addr client; /* client IP address (net order) */
struct in_addr server; /* server IP address (net order) */
int dport; /* server port (host order) */
u_short serviceId; /* Service identifier (net order) */
- u_int32_t opcode; /* RX opcode (host order) */
+ uint32_t opcode; /* RX opcode (host order) */
};
#define RX_CACHE_SIZE 64
@@ -416,31 +495,31 @@ static struct rx_cache_entry rx_cache[RX_CACHE_SIZE];
static int rx_cache_next = 0;
static int rx_cache_hint = 0;
-static void rx_cache_insert(const u_char *, const struct ip *, int);
+static void rx_cache_insert(netdissect_options *, const u_char *, const struct ip *, int);
static int rx_cache_find(const struct rx_header *, const struct ip *,
int, int32_t *);
-static void fs_print(const u_char *, int);
-static void fs_reply_print(const u_char *, int, int32_t);
-static void acl_print(u_char *, int, u_char *);
-static void cb_print(const u_char *, int);
-static void cb_reply_print(const u_char *, int, int32_t);
-static void prot_print(const u_char *, int);
-static void prot_reply_print(const u_char *, int, int32_t);
-static void vldb_print(const u_char *, int);
-static void vldb_reply_print(const u_char *, int, int32_t);
-static void kauth_print(const u_char *, int);
-static void kauth_reply_print(const u_char *, int, int32_t);
-static void vol_print(const u_char *, int);
-static void vol_reply_print(const u_char *, int, int32_t);
-static void bos_print(const u_char *, int);
-static void bos_reply_print(const u_char *, int, int32_t);
-static void ubik_print(const u_char *);
-static void ubik_reply_print(const u_char *, int, int32_t);
-
-static void rx_ack_print(const u_char *, int);
-
-static int is_ubik(u_int32_t);
+static void fs_print(netdissect_options *, const u_char *, int);
+static void fs_reply_print(netdissect_options *, const u_char *, int, int32_t);
+static void acl_print(netdissect_options *, u_char *, int, u_char *);
+static void cb_print(netdissect_options *, const u_char *, int);
+static void cb_reply_print(netdissect_options *, const u_char *, int, int32_t);
+static void prot_print(netdissect_options *, const u_char *, int);
+static void prot_reply_print(netdissect_options *, const u_char *, int, int32_t);
+static void vldb_print(netdissect_options *, const u_char *, int);
+static void vldb_reply_print(netdissect_options *, const u_char *, int, int32_t);
+static void kauth_print(netdissect_options *, const u_char *, int);
+static void kauth_reply_print(netdissect_options *, const u_char *, int, int32_t);
+static void vol_print(netdissect_options *, const u_char *, int);
+static void vol_reply_print(netdissect_options *, const u_char *, int, int32_t);
+static void bos_print(netdissect_options *, const u_char *, int);
+static void bos_reply_print(netdissect_options *, const u_char *, int, int32_t);
+static void ubik_print(netdissect_options *, const u_char *);
+static void ubik_reply_print(netdissect_options *, const u_char *, int, int32_t);
+
+static void rx_ack_print(netdissect_options *, const u_char *, int);
+
+static int is_ubik(uint32_t);
/*
* Handle the rx-level packet. See if we know what port it's going to so
@@ -448,51 +527,52 @@ static int is_ubik(u_int32_t);
*/
void
-rx_print(register const u_char *bp, int length, int sport, int dport,
- u_char *bp2)
+rx_print(netdissect_options *ndo,
+ register const u_char *bp, int length, int sport, int dport,
+ const u_char *bp2)
{
- register struct rx_header *rxh;
+ register const struct rx_header *rxh;
int i;
int32_t opcode;
- if (snapend - bp < (int)sizeof (struct rx_header)) {
- printf(" [|rx] (%d)", length);
+ if (ndo->ndo_snapend - bp < (int)sizeof (struct rx_header)) {
+ ND_PRINT((ndo, " [|rx] (%d)", length));
return;
}
- rxh = (struct rx_header *) bp;
+ rxh = (const struct rx_header *) bp;
- printf(" rx %s", tok2str(rx_types, "type %d", rxh->type));
+ ND_PRINT((ndo, " rx %s", tok2str(rx_types, "type %d", rxh->type)));
- if (vflag) {
+ if (ndo->ndo_vflag) {
int firstflag = 0;
- if (vflag > 1)
- printf(" cid %08x call# %d",
+ if (ndo->ndo_vflag > 1)
+ ND_PRINT((ndo, " cid %08x call# %d",
(int) EXTRACT_32BITS(&rxh->cid),
- (int) EXTRACT_32BITS(&rxh->callNumber));
+ (int) EXTRACT_32BITS(&rxh->callNumber)));
- printf(" seq %d ser %d",
+ ND_PRINT((ndo, " seq %d ser %d",
(int) EXTRACT_32BITS(&rxh->seq),
- (int) EXTRACT_32BITS(&rxh->serial));
+ (int) EXTRACT_32BITS(&rxh->serial)));
- if (vflag > 2)
- printf(" secindex %d serviceid %hu",
+ if (ndo->ndo_vflag > 2)
+ ND_PRINT((ndo, " secindex %d serviceid %hu",
(int) rxh->securityIndex,
- EXTRACT_16BITS(&rxh->serviceId));
+ EXTRACT_16BITS(&rxh->serviceId)));
- if (vflag > 1)
+ if (ndo->ndo_vflag > 1)
for (i = 0; i < NUM_RX_FLAGS; i++) {
if (rxh->flags & rx_flags[i].flag &&
(!rx_flags[i].packetType ||
rxh->type == rx_flags[i].packetType)) {
if (!firstflag) {
firstflag = 1;
- printf(" ");
+ ND_PRINT((ndo, " "));
} else {
- printf(",");
+ ND_PRINT((ndo, ","));
}
- printf("<%s>", rx_flags[i].s);
+ ND_PRINT((ndo, "<%s>", rx_flags[i].s));
}
}
}
@@ -515,29 +595,29 @@ rx_print(register const u_char *bp, int length, int sport, int dport,
* have a chance to print out replies
*/
- rx_cache_insert(bp, (const struct ip *) bp2, dport);
+ rx_cache_insert(ndo, bp, (const struct ip *) bp2, dport);
switch (dport) {
case FS_RX_PORT: /* AFS file service */
- fs_print(bp, length);
+ fs_print(ndo, bp, length);
break;
case CB_RX_PORT: /* AFS callback service */
- cb_print(bp, length);
+ cb_print(ndo, bp, length);
break;
case PROT_RX_PORT: /* AFS protection service */
- prot_print(bp, length);
+ prot_print(ndo, bp, length);
break;
case VLDB_RX_PORT: /* AFS VLDB service */
- vldb_print(bp, length);
+ vldb_print(ndo, bp, length);
break;
case KAUTH_RX_PORT: /* AFS Kerberos auth service */
- kauth_print(bp, length);
+ kauth_print(ndo, bp, length);
break;
case VOL_RX_PORT: /* AFS Volume service */
- vol_print(bp, length);
+ vol_print(ndo, bp, length);
break;
case BOS_RX_PORT: /* AFS BOS service */
- bos_print(bp, length);
+ bos_print(ndo, bp, length);
break;
default:
;
@@ -559,25 +639,25 @@ rx_print(register const u_char *bp, int length, int sport, int dport,
switch (sport) {
case FS_RX_PORT: /* AFS file service */
- fs_reply_print(bp, length, opcode);
+ fs_reply_print(ndo, bp, length, opcode);
break;
case CB_RX_PORT: /* AFS callback service */
- cb_reply_print(bp, length, opcode);
+ cb_reply_print(ndo, bp, length, opcode);
break;
case PROT_RX_PORT: /* AFS PT service */
- prot_reply_print(bp, length, opcode);
+ prot_reply_print(ndo, bp, length, opcode);
break;
case VLDB_RX_PORT: /* AFS VLDB service */
- vldb_reply_print(bp, length, opcode);
+ vldb_reply_print(ndo, bp, length, opcode);
break;
case KAUTH_RX_PORT: /* AFS Kerberos auth service */
- kauth_reply_print(bp, length, opcode);
+ kauth_reply_print(ndo, bp, length, opcode);
break;
case VOL_RX_PORT: /* AFS Volume service */
- vol_reply_print(bp, length, opcode);
+ vol_reply_print(ndo, bp, length, opcode);
break;
case BOS_RX_PORT: /* AFS BOS service */
- bos_reply_print(bp, length, opcode);
+ bos_reply_print(ndo, bp, length, opcode);
break;
default:
;
@@ -590,10 +670,10 @@ rx_print(register const u_char *bp, int length, int sport, int dport,
*/
} else if (rxh->type == RX_PACKET_TYPE_ACK)
- rx_ack_print(bp, length);
+ rx_ack_print(ndo, bp, length);
- printf(" (%d)", length);
+ ND_PRINT((ndo, " (%d)", length));
}
/*
@@ -601,12 +681,13 @@ rx_print(register const u_char *bp, int length, int sport, int dport,
*/
static void
-rx_cache_insert(const u_char *bp, const struct ip *ip, int dport)
+rx_cache_insert(netdissect_options *ndo,
+ const u_char *bp, const struct ip *ip, int dport)
{
struct rx_cache_entry *rxent;
const struct rx_header *rxh = (const struct rx_header *) bp;
- if (snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t)))
+ if (ndo->ndo_snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t)))
return;
rxent = &rx_cache[rx_cache_next];
@@ -615,8 +696,8 @@ rx_cache_insert(const u_char *bp, const struct ip *ip, int dport)
rx_cache_next = 0;
rxent->callnum = rxh->callNumber;
- rxent->client = ip->ip_src;
- rxent->server = ip->ip_dst;
+ UNALIGNED_MEMCPY(&rxent->client, &ip->ip_src, sizeof(uint32_t));
+ UNALIGNED_MEMCPY(&rxent->server, &ip->ip_dst, sizeof(uint32_t));
rxent->dport = dport;
rxent->serviceId = rxh->serviceId;
rxent->opcode = EXTRACT_32BITS(bp + sizeof(struct rx_header));
@@ -635,8 +716,11 @@ rx_cache_find(const struct rx_header *rxh, const struct ip *ip, int sport,
{
int i;
struct rx_cache_entry *rxent;
- u_int32_t clip = ip->ip_dst.s_addr;
- u_int32_t sip = ip->ip_src.s_addr;
+ uint32_t clip;
+ uint32_t sip;
+
+ UNALIGNED_MEMCPY(&clip, &ip->ip_dst, sizeof(uint32_t));
+ UNALIGNED_MEMCPY(&sip, &ip->ip_src, sizeof(uint32_t));
/* Start the search where we last left off */
@@ -655,7 +739,7 @@ rx_cache_find(const struct rx_header *rxh, const struct ip *ip, int sport,
*opcode = rxent->opcode;
return(1);
}
- if (++i > RX_CACHE_SIZE)
+ if (++i >= RX_CACHE_SIZE)
i = 0;
} while (i != rx_cache_hint);
@@ -668,101 +752,101 @@ rx_cache_find(const struct rx_header *rxh, const struct ip *ip, int sport,
*/
#define FIDOUT() { unsigned long n1, n2, n3; \
- TCHECK2(bp[0], sizeof(int32_t) * 3); \
+ ND_TCHECK2(bp[0], sizeof(int32_t) * 3); \
n1 = EXTRACT_32BITS(bp); \
bp += sizeof(int32_t); \
n2 = EXTRACT_32BITS(bp); \
bp += sizeof(int32_t); \
n3 = EXTRACT_32BITS(bp); \
bp += sizeof(int32_t); \
- printf(" fid %d/%d/%d", (int) n1, (int) n2, (int) n3); \
+ ND_PRINT((ndo, " fid %d/%d/%d", (int) n1, (int) n2, (int) n3)); \
}
-#define STROUT(MAX) { unsigned int i; \
- TCHECK2(bp[0], sizeof(int32_t)); \
- i = EXTRACT_32BITS(bp); \
- if (i > (MAX)) \
+#define STROUT(MAX) { unsigned int _i; \
+ ND_TCHECK2(bp[0], sizeof(int32_t)); \
+ _i = EXTRACT_32BITS(bp); \
+ if (_i > (MAX)) \
goto trunc; \
bp += sizeof(int32_t); \
- printf(" \""); \
- if (fn_printn(bp, i, snapend)) \
+ ND_PRINT((ndo, " \"")); \
+ if (fn_printn(ndo, bp, _i, ndo->ndo_snapend)) \
goto trunc; \
- printf("\""); \
- bp += ((i + sizeof(int32_t) - 1) / sizeof(int32_t)) * sizeof(int32_t); \
+ ND_PRINT((ndo, "\"")); \
+ bp += ((_i + sizeof(int32_t) - 1) / sizeof(int32_t)) * sizeof(int32_t); \
}
-#define INTOUT() { int i; \
- TCHECK2(bp[0], sizeof(int32_t)); \
- i = (int) EXTRACT_32BITS(bp); \
+#define INTOUT() { int _i; \
+ ND_TCHECK2(bp[0], sizeof(int32_t)); \
+ _i = (int) EXTRACT_32BITS(bp); \
bp += sizeof(int32_t); \
- printf(" %d", i); \
+ ND_PRINT((ndo, " %d", _i)); \
}
-#define UINTOUT() { unsigned long i; \
- TCHECK2(bp[0], sizeof(int32_t)); \
- i = EXTRACT_32BITS(bp); \
+#define UINTOUT() { unsigned long _i; \
+ ND_TCHECK2(bp[0], sizeof(int32_t)); \
+ _i = EXTRACT_32BITS(bp); \
bp += sizeof(int32_t); \
- printf(" %lu", i); \
+ ND_PRINT((ndo, " %lu", _i)); \
}
-#define UINT64OUT() { u_int64_t i; \
- TCHECK2(bp[0], sizeof(u_int64_t)); \
- i = EXTRACT_64BITS(bp); \
- bp += sizeof(u_int64_t); \
- printf(" %" PRIu64, i); \
+#define UINT64OUT() { uint64_t _i; \
+ ND_TCHECK2(bp[0], sizeof(uint64_t)); \
+ _i = EXTRACT_64BITS(bp); \
+ bp += sizeof(uint64_t); \
+ ND_PRINT((ndo, " %" PRIu64, _i)); \
}
-#define DATEOUT() { time_t t; struct tm *tm; char str[256]; \
- TCHECK2(bp[0], sizeof(int32_t)); \
- t = (time_t) EXTRACT_32BITS(bp); \
+#define DATEOUT() { time_t _t; struct tm *tm; char str[256]; \
+ ND_TCHECK2(bp[0], sizeof(int32_t)); \
+ _t = (time_t) EXTRACT_32BITS(bp); \
bp += sizeof(int32_t); \
- tm = localtime(&t); \
- strftime(str, 256, "%Y/%m/%d %T", tm); \
- printf(" %s", str); \
+ tm = localtime(&_t); \
+ strftime(str, 256, "%Y/%m/%d %H:%M:%S", tm); \
+ ND_PRINT((ndo, " %s", str)); \
}
-#define STOREATTROUT() { unsigned long mask, i; \
- TCHECK2(bp[0], (sizeof(int32_t)*6)); \
+#define STOREATTROUT() { unsigned long mask, _i; \
+ ND_TCHECK2(bp[0], (sizeof(int32_t)*6)); \
mask = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
- if (mask) printf (" StoreStatus"); \
- if (mask & 1) { printf(" date"); DATEOUT(); } \
+ if (mask) ND_PRINT((ndo, " StoreStatus")); \
+ if (mask & 1) { ND_PRINT((ndo, " date")); DATEOUT(); } \
else bp += sizeof(int32_t); \
- i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
- if (mask & 2) printf(" owner %lu", i); \
- i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
- if (mask & 4) printf(" group %lu", i); \
- i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
- if (mask & 8) printf(" mode %lo", i & 07777); \
- i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
- if (mask & 16) printf(" segsize %lu", i); \
+ _i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
+ if (mask & 2) ND_PRINT((ndo, " owner %lu", _i)); \
+ _i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
+ if (mask & 4) ND_PRINT((ndo, " group %lu", _i)); \
+ _i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
+ if (mask & 8) ND_PRINT((ndo, " mode %lo", _i & 07777)); \
+ _i = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
+ if (mask & 16) ND_PRINT((ndo, " segsize %lu", _i)); \
/* undocumented in 3.3 docu */ \
- if (mask & 1024) printf(" fsync"); \
+ if (mask & 1024) ND_PRINT((ndo, " fsync")); \
}
#define UBIK_VERSIONOUT() {int32_t epoch; int32_t counter; \
- TCHECK2(bp[0], sizeof(int32_t) * 2); \
+ ND_TCHECK2(bp[0], sizeof(int32_t) * 2); \
epoch = EXTRACT_32BITS(bp); \
bp += sizeof(int32_t); \
counter = EXTRACT_32BITS(bp); \
bp += sizeof(int32_t); \
- printf(" %d.%d", epoch, counter); \
+ ND_PRINT((ndo, " %d.%d", epoch, counter)); \
}
-#define AFSUUIDOUT() {u_int32_t temp; int i; \
- TCHECK2(bp[0], 11*sizeof(u_int32_t)); \
+#define AFSUUIDOUT() {uint32_t temp; int _i; \
+ ND_TCHECK2(bp[0], 11*sizeof(uint32_t)); \
temp = EXTRACT_32BITS(bp); \
- bp += sizeof(u_int32_t); \
- printf(" %08x", temp); \
+ bp += sizeof(uint32_t); \
+ ND_PRINT((ndo, " %08x", temp)); \
temp = EXTRACT_32BITS(bp); \
- bp += sizeof(u_int32_t); \
- printf("%04x", temp); \
+ bp += sizeof(uint32_t); \
+ ND_PRINT((ndo, "%04x", temp)); \
temp = EXTRACT_32BITS(bp); \
- bp += sizeof(u_int32_t); \
- printf("%04x", temp); \
- for (i = 0; i < 8; i++) { \
+ bp += sizeof(uint32_t); \
+ ND_PRINT((ndo, "%04x", temp)); \
+ for (_i = 0; _i < 8; _i++) { \
temp = EXTRACT_32BITS(bp); \
- bp += sizeof(u_int32_t); \
- printf("%02x", (unsigned char) temp); \
+ bp += sizeof(uint32_t); \
+ ND_PRINT((ndo, "%02x", (unsigned char) temp)); \
} \
}
@@ -775,27 +859,27 @@ rx_cache_find(const struct rx_header *rxh, const struct ip *ip, int sport,
int k; \
if ((MAX) + 1 > sizeof(s)) \
goto trunc; \
- TCHECK2(bp[0], (MAX) * sizeof(int32_t)); \
+ ND_TCHECK2(bp[0], (MAX) * sizeof(int32_t)); \
sp = s; \
for (k = 0; k < (MAX); k++) { \
*sp++ = (u_char) EXTRACT_32BITS(bp); \
bp += sizeof(int32_t); \
} \
s[(MAX)] = '\0'; \
- printf(" \""); \
- fn_print(s, NULL); \
- printf("\""); \
+ ND_PRINT((ndo, " \"")); \
+ fn_print(ndo, s, NULL); \
+ ND_PRINT((ndo, "\"")); \
}
#define DESTSERVEROUT() { unsigned long n1, n2, n3; \
- TCHECK2(bp[0], sizeof(int32_t) * 3); \
+ ND_TCHECK2(bp[0], sizeof(int32_t) * 3); \
n1 = EXTRACT_32BITS(bp); \
bp += sizeof(int32_t); \
n2 = EXTRACT_32BITS(bp); \
bp += sizeof(int32_t); \
n3 = EXTRACT_32BITS(bp); \
bp += sizeof(int32_t); \
- printf(" server %d:%d:%d", (int) n1, (int) n2, (int) n3); \
+ ND_PRINT((ndo, " server %d:%d:%d", (int) n1, (int) n2, (int) n3)); \
}
/*
@@ -803,7 +887,8 @@ rx_cache_find(const struct rx_header *rxh, const struct ip *ip, int sport,
*/
static void
-fs_print(register const u_char *bp, int length)
+fs_print(netdissect_options *ndo,
+ register const u_char *bp, int length)
{
int fs_op;
unsigned long i;
@@ -811,7 +896,7 @@ fs_print(register const u_char *bp, int length)
if (length <= (int)sizeof(struct rx_header))
return;
- if (snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) {
+ if (ndo->ndo_snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) {
goto trunc;
}
@@ -822,7 +907,7 @@ fs_print(register const u_char *bp, int length)
fs_op = EXTRACT_32BITS(bp + sizeof(struct rx_header));
- printf(" fs call %s", tok2str(fs_req, "op#%d", fs_op));
+ ND_PRINT((ndo, " fs call %s", tok2str(fs_req, "op#%d", fs_op)));
/*
* Print out arguments to some of the AFS calls. This stuff is
@@ -838,9 +923,9 @@ fs_print(register const u_char *bp, int length)
switch (fs_op) {
case 130: /* Fetch data */
FIDOUT();
- printf(" offset");
+ ND_PRINT((ndo, " offset"));
UINTOUT();
- printf(" length");
+ ND_PRINT((ndo, " length"));
UINTOUT();
break;
case 131: /* Fetch ACL */
@@ -860,25 +945,25 @@ fs_print(register const u_char *bp, int length)
case 133: /* Store data */
FIDOUT();
STOREATTROUT();
- printf(" offset");
+ ND_PRINT((ndo, " offset"));
UINTOUT();
- printf(" length");
+ ND_PRINT((ndo, " length"));
UINTOUT();
- printf(" flen");
+ ND_PRINT((ndo, " flen"));
UINTOUT();
break;
case 134: /* Store ACL */
{
char a[AFSOPAQUEMAX+1];
FIDOUT();
- TCHECK2(bp[0], 4);
+ ND_TCHECK2(bp[0], 4);
i = EXTRACT_32BITS(bp);
bp += sizeof(int32_t);
- TCHECK2(bp[0], i);
+ ND_TCHECK2(bp[0], i);
i = min(AFSOPAQUEMAX, i);
- strncpy(a, (char *) bp, i);
+ strncpy(a, (const char *) bp, i);
a[i] = '\0';
- acl_print((u_char *) a, sizeof(a), (u_char *) a + i);
+ acl_print(ndo, (u_char *) a, sizeof(a), (u_char *) a + i);
break;
}
case 137: /* Create file */
@@ -893,23 +978,23 @@ fs_print(register const u_char *bp, int length)
STROUT(AFSNAMEMAX);
break;
case 138: /* Rename file */
- printf(" old");
+ ND_PRINT((ndo, " old"));
FIDOUT();
STROUT(AFSNAMEMAX);
- printf(" new");
+ ND_PRINT((ndo, " new"));
FIDOUT();
STROUT(AFSNAMEMAX);
break;
case 139: /* Symlink */
FIDOUT();
STROUT(AFSNAMEMAX);
- printf(" link to");
+ ND_PRINT((ndo, " link to"));
STROUT(AFSNAMEMAX);
break;
case 140: /* Link */
FIDOUT();
STROUT(AFSNAMEMAX);
- printf(" link to");
+ ND_PRINT((ndo, " link to"));
FIDOUT();
break;
case 148: /* Get volume info */
@@ -917,48 +1002,48 @@ fs_print(register const u_char *bp, int length)
break;
case 149: /* Get volume stats */
case 150: /* Set volume stats */
- printf(" volid");
+ ND_PRINT((ndo, " volid"));
UINTOUT();
break;
case 154: /* New get volume info */
- printf(" volname");
+ ND_PRINT((ndo, " volname"));
STROUT(AFSNAMEMAX);
break;
case 155: /* Bulk stat */
case 65536: /* Inline bulk stat */
{
unsigned long j;
- TCHECK2(bp[0], 4);
+ ND_TCHECK2(bp[0], 4);
j = EXTRACT_32BITS(bp);
bp += sizeof(int32_t);
for (i = 0; i < j; i++) {
FIDOUT();
if (i != j - 1)
- printf(",");
+ ND_PRINT((ndo, ","));
}
if (j == 0)
- printf(" <none!>");
+ ND_PRINT((ndo, " <none!>"));
}
case 65537: /* Fetch data 64 */
FIDOUT();
- printf(" offset");
+ ND_PRINT((ndo, " offset"));
UINT64OUT();
- printf(" length");
+ ND_PRINT((ndo, " length"));
UINT64OUT();
break;
case 65538: /* Store data 64 */
FIDOUT();
STOREATTROUT();
- printf(" offset");
+ ND_PRINT((ndo, " offset"));
UINT64OUT();
- printf(" length");
+ ND_PRINT((ndo, " length"));
UINT64OUT();
- printf(" flen");
+ ND_PRINT((ndo, " flen"));
UINT64OUT();
break;
case 65541: /* CallBack rx conn address */
- printf(" addr");
+ ND_PRINT((ndo, " addr"));
UINTOUT();
default:
;
@@ -967,7 +1052,7 @@ fs_print(register const u_char *bp, int length)
return;
trunc:
- printf(" [|fs]");
+ ND_PRINT((ndo, " [|fs]"));
}
/*
@@ -975,22 +1060,23 @@ trunc:
*/
static void
-fs_reply_print(register const u_char *bp, int length, int32_t opcode)
+fs_reply_print(netdissect_options *ndo,
+ register const u_char *bp, int length, int32_t opcode)
{
unsigned long i;
- struct rx_header *rxh;
+ const struct rx_header *rxh;
if (length <= (int)sizeof(struct rx_header))
return;
- rxh = (struct rx_header *) bp;
+ rxh = (const struct rx_header *) bp;
/*
* Print out the afs call we're invoking. The table used here was
* gleaned from fsint/afsint.xg
*/
- printf(" fs reply %s", tok2str(fs_req, "op#%d", opcode));
+ ND_PRINT((ndo, " fs reply %s", tok2str(fs_req, "op#%d", opcode)));
bp += sizeof(struct rx_header);
@@ -1003,23 +1089,23 @@ fs_reply_print(register const u_char *bp, int length, int32_t opcode)
case 131: /* Fetch ACL */
{
char a[AFSOPAQUEMAX+1];
- TCHECK2(bp[0], 4);
+ ND_TCHECK2(bp[0], 4);
i = EXTRACT_32BITS(bp);
bp += sizeof(int32_t);
- TCHECK2(bp[0], i);
+ ND_TCHECK2(bp[0], i);
i = min(AFSOPAQUEMAX, i);
- strncpy(a, (char *) bp, i);
+ strncpy(a, (const char *) bp, i);
a[i] = '\0';
- acl_print((u_char *) a, sizeof(a), (u_char *) a + i);
+ acl_print(ndo, (u_char *) a, sizeof(a), (u_char *) a + i);
break;
}
case 137: /* Create file */
case 141: /* MakeDir */
- printf(" new");
+ ND_PRINT((ndo, " new"));
FIDOUT();
break;
case 151: /* Get root volume */
- printf(" root volume");
+ ND_PRINT((ndo, " root volume"));
STROUT(AFSNAMEMAX);
break;
case 153: /* Get time */
@@ -1029,24 +1115,22 @@ fs_reply_print(register const u_char *bp, int length, int32_t opcode)
;
}
} else if (rxh->type == RX_PACKET_TYPE_ABORT) {
- int i;
-
/*
* Otherwise, just print out the return code
*/
- TCHECK2(bp[0], sizeof(int32_t));
+ ND_TCHECK2(bp[0], sizeof(int32_t));
i = (int) EXTRACT_32BITS(bp);
bp += sizeof(int32_t);
- printf(" error %s", tok2str(afs_fs_errors, "#%d", i));
+ ND_PRINT((ndo, " error %s", tok2str(afs_fs_errors, "#%d", i)));
} else {
- printf(" strange fs reply of type %d", rxh->type);
+ ND_PRINT((ndo, " strange fs reply of type %d", rxh->type));
}
return;
trunc:
- printf(" [|fs]");
+ ND_PRINT((ndo, " [|fs]"));
}
/*
@@ -1064,7 +1148,8 @@ trunc:
*/
static void
-acl_print(u_char *s, int maxsize, u_char *end)
+acl_print(netdissect_options *ndo,
+ u_char *s, int maxsize, u_char *end)
{
int pos, neg, acl;
int n, i;
@@ -1087,31 +1172,25 @@ acl_print(u_char *s, int maxsize, u_char *end)
*/
#define ACLOUT(acl) \
- if (acl & PRSFS_READ) \
- printf("r"); \
- if (acl & PRSFS_LOOKUP) \
- printf("l"); \
- if (acl & PRSFS_INSERT) \
- printf("i"); \
- if (acl & PRSFS_DELETE) \
- printf("d"); \
- if (acl & PRSFS_WRITE) \
- printf("w"); \
- if (acl & PRSFS_LOCK) \
- printf("k"); \
- if (acl & PRSFS_ADMINISTER) \
- printf("a");
+ ND_PRINT((ndo, "%s%s%s%s%s%s%s", \
+ acl & PRSFS_READ ? "r" : "", \
+ acl & PRSFS_LOOKUP ? "l" : "", \
+ acl & PRSFS_INSERT ? "i" : "", \
+ acl & PRSFS_DELETE ? "d" : "", \
+ acl & PRSFS_WRITE ? "w" : "", \
+ acl & PRSFS_LOCK ? "k" : "", \
+ acl & PRSFS_ADMINISTER ? "a" : ""));
for (i = 0; i < pos; i++) {
snprintf(fmt, sizeof(fmt), "%%%ds %%d\n%%n", maxsize - 1);
if (sscanf((char *) s, fmt, user, &acl, &n) != 2)
goto finish;
s += n;
- printf(" +{");
- fn_print((u_char *)user, NULL);
- printf(" ");
+ ND_PRINT((ndo, " +{"));
+ fn_print(ndo, (u_char *)user, NULL);
+ ND_PRINT((ndo, " "));
ACLOUT(acl);
- printf("}");
+ ND_PRINT((ndo, "}"));
if (s > end)
goto finish;
}
@@ -1121,11 +1200,11 @@ acl_print(u_char *s, int maxsize, u_char *end)
if (sscanf((char *) s, fmt, user, &acl, &n) != 2)
goto finish;
s += n;
- printf(" -{");
- fn_print((u_char *)user, NULL);
- printf(" ");
+ ND_PRINT((ndo, " -{"));
+ fn_print(ndo, (u_char *)user, NULL);
+ ND_PRINT((ndo, " "));
ACLOUT(acl);
- printf("}");
+ ND_PRINT((ndo, "}"));
if (s > end)
goto finish;
}
@@ -1142,7 +1221,8 @@ finish:
*/
static void
-cb_print(register const u_char *bp, int length)
+cb_print(netdissect_options *ndo,
+ register const u_char *bp, int length)
{
int cb_op;
unsigned long i;
@@ -1150,7 +1230,7 @@ cb_print(register const u_char *bp, int length)
if (length <= (int)sizeof(struct rx_header))
return;
- if (snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) {
+ if (ndo->ndo_snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) {
goto trunc;
}
@@ -1161,7 +1241,7 @@ cb_print(register const u_char *bp, int length)
cb_op = EXTRACT_32BITS(bp + sizeof(struct rx_header));
- printf(" cb call %s", tok2str(cb_req, "op#%d", cb_op));
+ ND_PRINT((ndo, " cb call %s", tok2str(cb_req, "op#%d", cb_op)));
bp += sizeof(struct rx_header) + 4;
@@ -1174,38 +1254,38 @@ cb_print(register const u_char *bp, int length)
case 204: /* Callback */
{
unsigned long j, t;
- TCHECK2(bp[0], 4);
+ ND_TCHECK2(bp[0], 4);
j = EXTRACT_32BITS(bp);
bp += sizeof(int32_t);
for (i = 0; i < j; i++) {
FIDOUT();
if (i != j - 1)
- printf(",");
+ ND_PRINT((ndo, ","));
}
if (j == 0)
- printf(" <none!>");
+ ND_PRINT((ndo, " <none!>"));
j = EXTRACT_32BITS(bp);
bp += sizeof(int32_t);
if (j != 0)
- printf(";");
+ ND_PRINT((ndo, ";"));
for (i = 0; i < j; i++) {
- printf(" ver");
+ ND_PRINT((ndo, " ver"));
INTOUT();
- printf(" expires");
+ ND_PRINT((ndo, " expires"));
DATEOUT();
- TCHECK2(bp[0], 4);
+ ND_TCHECK2(bp[0], 4);
t = EXTRACT_32BITS(bp);
bp += sizeof(int32_t);
tok2str(cb_types, "type %d", t);
}
}
case 214: {
- printf(" afsuuid");
+ ND_PRINT((ndo, " afsuuid"));
AFSUUIDOUT();
break;
}
@@ -1216,7 +1296,7 @@ cb_print(register const u_char *bp, int length)
return;
trunc:
- printf(" [|cb]");
+ ND_PRINT((ndo, " [|cb]"));
}
/*
@@ -1224,21 +1304,22 @@ trunc:
*/
static void
-cb_reply_print(register const u_char *bp, int length, int32_t opcode)
+cb_reply_print(netdissect_options *ndo,
+ register const u_char *bp, int length, int32_t opcode)
{
- struct rx_header *rxh;
+ const struct rx_header *rxh;
if (length <= (int)sizeof(struct rx_header))
return;
- rxh = (struct rx_header *) bp;
+ rxh = (const struct rx_header *) bp;
/*
* Print out the afs call we're invoking. The table used here was
* gleaned from fsint/afscbint.xg
*/
- printf(" cb reply %s", tok2str(cb_req, "op#%d", opcode));
+ ND_PRINT((ndo, " cb reply %s", tok2str(cb_req, "op#%d", opcode)));
bp += sizeof(struct rx_header);
@@ -1258,14 +1339,14 @@ cb_reply_print(register const u_char *bp, int length, int32_t opcode)
/*
* Otherwise, just print out the return code
*/
- printf(" errcode");
+ ND_PRINT((ndo, " errcode"));
INTOUT();
}
return;
trunc:
- printf(" [|cb]");
+ ND_PRINT((ndo, " [|cb]"));
}
/*
@@ -1273,7 +1354,8 @@ trunc:
*/
static void
-prot_print(register const u_char *bp, int length)
+prot_print(netdissect_options *ndo,
+ register const u_char *bp, int length)
{
unsigned long i;
int pt_op;
@@ -1281,7 +1363,7 @@ prot_print(register const u_char *bp, int length)
if (length <= (int)sizeof(struct rx_header))
return;
- if (snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) {
+ if (ndo->ndo_snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) {
goto trunc;
}
@@ -1292,14 +1374,14 @@ prot_print(register const u_char *bp, int length)
pt_op = EXTRACT_32BITS(bp + sizeof(struct rx_header));
- printf(" pt");
+ ND_PRINT((ndo, " pt"));
if (is_ubik(pt_op)) {
- ubik_print(bp);
+ ubik_print(ndo, bp);
return;
}
- printf(" call %s", tok2str(pt_req, "op#%d", pt_op));
+ ND_PRINT((ndo, " call %s", tok2str(pt_req, "op#%d", pt_op)));
/*
* Decode some of the arguments to the PT calls
@@ -1310,9 +1392,9 @@ prot_print(register const u_char *bp, int length)
switch (pt_op) {
case 500: /* I New User */
STROUT(PRNAMEMAX);
- printf(" id");
+ ND_PRINT((ndo, " id"));
INTOUT();
- printf(" oldid");
+ ND_PRINT((ndo, " oldid"));
INTOUT();
break;
case 501: /* Where is it */
@@ -1324,25 +1406,25 @@ prot_print(register const u_char *bp, int length)
case 518: /* Get CPS2 */
case 519: /* Get host CPS */
case 530: /* List super groups */
- printf(" id");
+ ND_PRINT((ndo, " id"));
INTOUT();
break;
case 502: /* Dump entry */
- printf(" pos");
+ ND_PRINT((ndo, " pos"));
INTOUT();
break;
case 503: /* Add to group */
case 507: /* Remove from group */
case 515: /* Is a member of? */
- printf(" uid");
+ ND_PRINT((ndo, " uid"));
INTOUT();
- printf(" gid");
+ ND_PRINT((ndo, " gid"));
INTOUT();
break;
case 504: /* Name to ID */
{
unsigned long j;
- TCHECK2(bp[0], 4);
+ ND_TCHECK2(bp[0], 4);
j = EXTRACT_32BITS(bp);
bp += sizeof(int32_t);
@@ -1357,46 +1439,46 @@ prot_print(register const u_char *bp, int length)
VECOUT(PRNAMEMAX);
}
if (j == 0)
- printf(" <none!>");
+ ND_PRINT((ndo, " <none!>"));
}
break;
case 505: /* Id to name */
{
unsigned long j;
- printf(" ids:");
- TCHECK2(bp[0], 4);
+ ND_PRINT((ndo, " ids:"));
+ ND_TCHECK2(bp[0], 4);
i = EXTRACT_32BITS(bp);
bp += sizeof(int32_t);
for (j = 0; j < i; j++)
INTOUT();
if (j == 0)
- printf(" <none!>");
+ ND_PRINT((ndo, " <none!>"));
}
break;
case 509: /* New entry */
STROUT(PRNAMEMAX);
- printf(" flag");
+ ND_PRINT((ndo, " flag"));
INTOUT();
- printf(" oid");
+ ND_PRINT((ndo, " oid"));
INTOUT();
break;
case 511: /* Set max */
- printf(" id");
+ ND_PRINT((ndo, " id"));
INTOUT();
- printf(" gflag");
+ ND_PRINT((ndo, " gflag"));
INTOUT();
break;
case 513: /* Change entry */
- printf(" id");
+ ND_PRINT((ndo, " id"));
INTOUT();
STROUT(PRNAMEMAX);
- printf(" oldid");
+ ND_PRINT((ndo, " oldid"));
INTOUT();
- printf(" newid");
+ ND_PRINT((ndo, " newid"));
INTOUT();
break;
case 520: /* Update entry */
- printf(" id");
+ ND_PRINT((ndo, " id"));
INTOUT();
STROUT(PRNAMEMAX);
break;
@@ -1408,7 +1490,7 @@ prot_print(register const u_char *bp, int length)
return;
trunc:
- printf(" [|pt]");
+ ND_PRINT((ndo, " [|pt]"));
}
/*
@@ -1416,15 +1498,16 @@ trunc:
*/
static void
-prot_reply_print(register const u_char *bp, int length, int32_t opcode)
+prot_reply_print(netdissect_options *ndo,
+ register const u_char *bp, int length, int32_t opcode)
{
- struct rx_header *rxh;
+ const struct rx_header *rxh;
unsigned long i;
if (length < (int)sizeof(struct rx_header))
return;
- rxh = (struct rx_header *) bp;
+ rxh = (const struct rx_header *) bp;
/*
* Print out the afs call we're invoking. The table used here was
@@ -1432,14 +1515,14 @@ prot_reply_print(register const u_char *bp, int length, int32_t opcode)
* Ubik call, however.
*/
- printf(" pt");
+ ND_PRINT((ndo, " pt"));
if (is_ubik(opcode)) {
- ubik_reply_print(bp, length, opcode);
+ ubik_reply_print(ndo, bp, length, opcode);
return;
}
- printf(" reply %s", tok2str(pt_req, "op#%d", opcode));
+ ND_PRINT((ndo, " reply %s", tok2str(pt_req, "op#%d", opcode)));
bp += sizeof(struct rx_header);
@@ -1452,20 +1535,20 @@ prot_reply_print(register const u_char *bp, int length, int32_t opcode)
case 504: /* Name to ID */
{
unsigned long j;
- printf(" ids:");
- TCHECK2(bp[0], 4);
+ ND_PRINT((ndo, " ids:"));
+ ND_TCHECK2(bp[0], 4);
i = EXTRACT_32BITS(bp);
bp += sizeof(int32_t);
for (j = 0; j < i; j++)
INTOUT();
if (j == 0)
- printf(" <none!>");
+ ND_PRINT((ndo, " <none!>"));
}
break;
case 505: /* ID to name */
{
unsigned long j;
- TCHECK2(bp[0], 4);
+ ND_TCHECK2(bp[0], 4);
j = EXTRACT_32BITS(bp);
bp += sizeof(int32_t);
@@ -1480,7 +1563,7 @@ prot_reply_print(register const u_char *bp, int length, int32_t opcode)
VECOUT(PRNAMEMAX);
}
if (j == 0)
- printf(" <none!>");
+ ND_PRINT((ndo, " <none!>"));
}
break;
case 508: /* Get CPS */
@@ -1490,20 +1573,20 @@ prot_reply_print(register const u_char *bp, int length, int32_t opcode)
case 519: /* Get host CPS */
{
unsigned long j;
- TCHECK2(bp[0], 4);
+ ND_TCHECK2(bp[0], 4);
j = EXTRACT_32BITS(bp);
bp += sizeof(int32_t);
for (i = 0; i < j; i++) {
INTOUT();
}
if (j == 0)
- printf(" <none!>");
+ ND_PRINT((ndo, " <none!>"));
}
break;
case 510: /* List max */
- printf(" maxuid");
+ ND_PRINT((ndo, " maxuid"));
INTOUT();
- printf(" maxgid");
+ ND_PRINT((ndo, " maxgid"));
INTOUT();
break;
default:
@@ -1513,14 +1596,14 @@ prot_reply_print(register const u_char *bp, int length, int32_t opcode)
/*
* Otherwise, just print out the return code
*/
- printf(" errcode");
+ ND_PRINT((ndo, " errcode"));
INTOUT();
}
return;
trunc:
- printf(" [|pt]");
+ ND_PRINT((ndo, " [|pt]"));
}
/*
@@ -1528,7 +1611,8 @@ trunc:
*/
static void
-vldb_print(register const u_char *bp, int length)
+vldb_print(netdissect_options *ndo,
+ register const u_char *bp, int length)
{
int vldb_op;
unsigned long i;
@@ -1536,7 +1620,7 @@ vldb_print(register const u_char *bp, int length)
if (length <= (int)sizeof(struct rx_header))
return;
- if (snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) {
+ if (ndo->ndo_snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) {
goto trunc;
}
@@ -1547,13 +1631,13 @@ vldb_print(register const u_char *bp, int length)
vldb_op = EXTRACT_32BITS(bp + sizeof(struct rx_header));
- printf(" vldb");
+ ND_PRINT((ndo, " vldb"));
if (is_ubik(vldb_op)) {
- ubik_print(bp);
+ ubik_print(ndo, bp);
return;
}
- printf(" call %s", tok2str(vldb_req, "op#%d", vldb_op));
+ ND_PRINT((ndo, " call %s", tok2str(vldb_req, "op#%d", vldb_op)));
/*
* Decode some of the arguments to the VLDB calls
@@ -1572,13 +1656,13 @@ vldb_print(register const u_char *bp, int length)
case 508: /* Set lock */
case 509: /* Release lock */
case 518: /* Get entry by ID N */
- printf(" volid");
+ ND_PRINT((ndo, " volid"));
INTOUT();
- TCHECK2(bp[0], sizeof(int32_t));
+ ND_TCHECK2(bp[0], sizeof(int32_t));
i = EXTRACT_32BITS(bp);
bp += sizeof(int32_t);
if (i <= 2)
- printf(" type %s", voltype[i]);
+ ND_PRINT((ndo, " type %s", voltype[i]));
break;
case 504: /* Get entry by name */
case 519: /* Get entry by name N */
@@ -1587,23 +1671,23 @@ vldb_print(register const u_char *bp, int length)
STROUT(VLNAMEMAX);
break;
case 505: /* Get new vol id */
- printf(" bump");
+ ND_PRINT((ndo, " bump"));
INTOUT();
break;
case 506: /* Replace entry */
case 520: /* Replace entry N */
- printf(" volid");
+ ND_PRINT((ndo, " volid"));
INTOUT();
- TCHECK2(bp[0], sizeof(int32_t));
+ ND_TCHECK2(bp[0], sizeof(int32_t));
i = EXTRACT_32BITS(bp);
bp += sizeof(int32_t);
if (i <= 2)
- printf(" type %s", voltype[i]);
+ ND_PRINT((ndo, " type %s", voltype[i]));
VECOUT(VLNAMEMAX);
break;
case 510: /* List entry */
case 521: /* List entry N */
- printf(" index");
+ ND_PRINT((ndo, " index"));
INTOUT();
break;
default:
@@ -1613,7 +1697,7 @@ vldb_print(register const u_char *bp, int length)
return;
trunc:
- printf(" [|vldb]");
+ ND_PRINT((ndo, " [|vldb]"));
}
/*
@@ -1621,15 +1705,16 @@ trunc:
*/
static void
-vldb_reply_print(register const u_char *bp, int length, int32_t opcode)
+vldb_reply_print(netdissect_options *ndo,
+ register const u_char *bp, int length, int32_t opcode)
{
- struct rx_header *rxh;
+ const struct rx_header *rxh;
unsigned long i;
if (length < (int)sizeof(struct rx_header))
return;
- rxh = (struct rx_header *) bp;
+ rxh = (const struct rx_header *) bp;
/*
* Print out the afs call we're invoking. The table used here was
@@ -1637,14 +1722,14 @@ vldb_reply_print(register const u_char *bp, int length, int32_t opcode)
* Ubik call, however.
*/
- printf(" vldb");
+ ND_PRINT((ndo, " vldb"));
if (is_ubik(opcode)) {
- ubik_reply_print(bp, length, opcode);
+ ubik_reply_print(ndo, bp, length, opcode);
return;
}
- printf(" reply %s", tok2str(vldb_req, "op#%d", opcode));
+ ND_PRINT((ndo, " reply %s", tok2str(vldb_req, "op#%d", opcode)));
bp += sizeof(struct rx_header);
@@ -1655,93 +1740,93 @@ vldb_reply_print(register const u_char *bp, int length, int32_t opcode)
if (rxh->type == RX_PACKET_TYPE_DATA)
switch (opcode) {
case 510: /* List entry */
- printf(" count");
+ ND_PRINT((ndo, " count"));
INTOUT();
- printf(" nextindex");
+ ND_PRINT((ndo, " nextindex"));
INTOUT();
case 503: /* Get entry by id */
case 504: /* Get entry by name */
{ unsigned long nservers, j;
VECOUT(VLNAMEMAX);
- TCHECK2(bp[0], sizeof(int32_t));
+ ND_TCHECK2(bp[0], sizeof(int32_t));
bp += sizeof(int32_t);
- printf(" numservers");
- TCHECK2(bp[0], sizeof(int32_t));
+ ND_PRINT((ndo, " numservers"));
+ ND_TCHECK2(bp[0], sizeof(int32_t));
nservers = EXTRACT_32BITS(bp);
bp += sizeof(int32_t);
- printf(" %lu", nservers);
- printf(" servers");
+ ND_PRINT((ndo, " %lu", nservers));
+ ND_PRINT((ndo, " servers"));
for (i = 0; i < 8; i++) {
- TCHECK2(bp[0], sizeof(int32_t));
+ ND_TCHECK2(bp[0], sizeof(int32_t));
if (i < nservers)
- printf(" %s",
- intoa(((struct in_addr *) bp)->s_addr));
+ ND_PRINT((ndo, " %s",
+ intoa(((const struct in_addr *) bp)->s_addr)));
bp += sizeof(int32_t);
}
- printf(" partitions");
+ ND_PRINT((ndo, " partitions"));
for (i = 0; i < 8; i++) {
- TCHECK2(bp[0], sizeof(int32_t));
+ ND_TCHECK2(bp[0], sizeof(int32_t));
j = EXTRACT_32BITS(bp);
if (i < nservers && j <= 26)
- printf(" %c", 'a' + (int)j);
+ ND_PRINT((ndo, " %c", 'a' + (int)j));
else if (i < nservers)
- printf(" %lu", j);
+ ND_PRINT((ndo, " %lu", j));
bp += sizeof(int32_t);
}
- TCHECK2(bp[0], 8 * sizeof(int32_t));
+ ND_TCHECK2(bp[0], 8 * sizeof(int32_t));
bp += 8 * sizeof(int32_t);
- printf(" rwvol");
+ ND_PRINT((ndo, " rwvol"));
UINTOUT();
- printf(" rovol");
+ ND_PRINT((ndo, " rovol"));
UINTOUT();
- printf(" backup");
+ ND_PRINT((ndo, " backup"));
UINTOUT();
}
break;
case 505: /* Get new volume ID */
- printf(" newvol");
+ ND_PRINT((ndo, " newvol"));
UINTOUT();
break;
case 521: /* List entry */
case 529: /* List entry U */
- printf(" count");
+ ND_PRINT((ndo, " count"));
INTOUT();
- printf(" nextindex");
+ ND_PRINT((ndo, " nextindex"));
INTOUT();
case 518: /* Get entry by ID N */
case 519: /* Get entry by name N */
{ unsigned long nservers, j;
VECOUT(VLNAMEMAX);
- printf(" numservers");
- TCHECK2(bp[0], sizeof(int32_t));
+ ND_PRINT((ndo, " numservers"));
+ ND_TCHECK2(bp[0], sizeof(int32_t));
nservers = EXTRACT_32BITS(bp);
bp += sizeof(int32_t);
- printf(" %lu", nservers);
- printf(" servers");
+ ND_PRINT((ndo, " %lu", nservers));
+ ND_PRINT((ndo, " servers"));
for (i = 0; i < 13; i++) {
- TCHECK2(bp[0], sizeof(int32_t));
+ ND_TCHECK2(bp[0], sizeof(int32_t));
if (i < nservers)
- printf(" %s",
- intoa(((struct in_addr *) bp)->s_addr));
+ ND_PRINT((ndo, " %s",
+ intoa(((const struct in_addr *) bp)->s_addr)));
bp += sizeof(int32_t);
}
- printf(" partitions");
+ ND_PRINT((ndo, " partitions"));
for (i = 0; i < 13; i++) {
- TCHECK2(bp[0], sizeof(int32_t));
+ ND_TCHECK2(bp[0], sizeof(int32_t));
j = EXTRACT_32BITS(bp);
if (i < nservers && j <= 26)
- printf(" %c", 'a' + (int)j);
+ ND_PRINT((ndo, " %c", 'a' + (int)j));
else if (i < nservers)
- printf(" %lu", j);
+ ND_PRINT((ndo, " %lu", j));
bp += sizeof(int32_t);
}
- TCHECK2(bp[0], 13 * sizeof(int32_t));
+ ND_TCHECK2(bp[0], 13 * sizeof(int32_t));
bp += 13 * sizeof(int32_t);
- printf(" rwvol");
+ ND_PRINT((ndo, " rwvol"));
UINTOUT();
- printf(" rovol");
+ ND_PRINT((ndo, " rovol"));
UINTOUT();
- printf(" backup");
+ ND_PRINT((ndo, " backup"));
UINTOUT();
}
break;
@@ -1749,40 +1834,40 @@ vldb_reply_print(register const u_char *bp, int length, int32_t opcode)
case 527: /* Get entry by name U */
{ unsigned long nservers, j;
VECOUT(VLNAMEMAX);
- printf(" numservers");
- TCHECK2(bp[0], sizeof(int32_t));
+ ND_PRINT((ndo, " numservers"));
+ ND_TCHECK2(bp[0], sizeof(int32_t));
nservers = EXTRACT_32BITS(bp);
bp += sizeof(int32_t);
- printf(" %lu", nservers);
- printf(" servers");
+ ND_PRINT((ndo, " %lu", nservers));
+ ND_PRINT((ndo, " servers"));
for (i = 0; i < 13; i++) {
if (i < nservers) {
- printf(" afsuuid");
+ ND_PRINT((ndo, " afsuuid"));
AFSUUIDOUT();
} else {
- TCHECK2(bp[0], 44);
+ ND_TCHECK2(bp[0], 44);
bp += 44;
}
}
- TCHECK2(bp[0], 4 * 13);
+ ND_TCHECK2(bp[0], 4 * 13);
bp += 4 * 13;
- printf(" partitions");
+ ND_PRINT((ndo, " partitions"));
for (i = 0; i < 13; i++) {
- TCHECK2(bp[0], sizeof(int32_t));
+ ND_TCHECK2(bp[0], sizeof(int32_t));
j = EXTRACT_32BITS(bp);
if (i < nservers && j <= 26)
- printf(" %c", 'a' + (int)j);
+ ND_PRINT((ndo, " %c", 'a' + (int)j));
else if (i < nservers)
- printf(" %lu", j);
+ ND_PRINT((ndo, " %lu", j));
bp += sizeof(int32_t);
}
- TCHECK2(bp[0], 13 * sizeof(int32_t));
+ ND_TCHECK2(bp[0], 13 * sizeof(int32_t));
bp += 13 * sizeof(int32_t);
- printf(" rwvol");
+ ND_PRINT((ndo, " rwvol"));
UINTOUT();
- printf(" rovol");
+ ND_PRINT((ndo, " rovol"));
UINTOUT();
- printf(" backup");
+ ND_PRINT((ndo, " backup"));
UINTOUT();
}
default:
@@ -1793,14 +1878,14 @@ vldb_reply_print(register const u_char *bp, int length, int32_t opcode)
/*
* Otherwise, just print out the return code
*/
- printf(" errcode");
+ ND_PRINT((ndo, " errcode"));
INTOUT();
}
return;
trunc:
- printf(" [|vldb]");
+ ND_PRINT((ndo, " [|vldb]"));
}
/*
@@ -1808,14 +1893,15 @@ trunc:
*/
static void
-kauth_print(register const u_char *bp, int length)
+kauth_print(netdissect_options *ndo,
+ register const u_char *bp, int length)
{
int kauth_op;
if (length <= (int)sizeof(struct rx_header))
return;
- if (snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) {
+ if (ndo->ndo_snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) {
goto trunc;
}
@@ -1826,15 +1912,15 @@ kauth_print(register const u_char *bp, int length)
kauth_op = EXTRACT_32BITS(bp + sizeof(struct rx_header));
- printf(" kauth");
+ ND_PRINT((ndo, " kauth"));
if (is_ubik(kauth_op)) {
- ubik_print(bp);
+ ubik_print(ndo, bp);
return;
}
- printf(" call %s", tok2str(kauth_req, "op#%d", kauth_op));
+ ND_PRINT((ndo, " call %s", tok2str(kauth_req, "op#%d", kauth_op)));
/*
* Decode some of the arguments to the KA calls
@@ -1843,7 +1929,7 @@ kauth_print(register const u_char *bp, int length)
bp += sizeof(struct rx_header) + 4;
switch (kauth_op) {
- case 1: /* Authenticate old */;
+ case 1: /* Authenticate old */
case 21: /* Authenticate */
case 22: /* Authenticate-V2 */
case 2: /* Change PW */
@@ -1853,7 +1939,7 @@ kauth_print(register const u_char *bp, int length)
case 8: /* Get entry */
case 14: /* Unlock */
case 15: /* Lock status */
- printf(" principal");
+ ND_PRINT((ndo, " principal"));
STROUT(KANAMEMAX);
STROUT(KANAMEMAX);
break;
@@ -1861,29 +1947,29 @@ kauth_print(register const u_char *bp, int length)
case 23: /* GetTicket */
{
int i;
- printf(" kvno");
+ ND_PRINT((ndo, " kvno"));
INTOUT();
- printf(" domain");
+ ND_PRINT((ndo, " domain"));
STROUT(KANAMEMAX);
- TCHECK2(bp[0], sizeof(int32_t));
+ ND_TCHECK2(bp[0], sizeof(int32_t));
i = (int) EXTRACT_32BITS(bp);
bp += sizeof(int32_t);
- TCHECK2(bp[0], i);
+ ND_TCHECK2(bp[0], i);
bp += i;
- printf(" principal");
+ ND_PRINT((ndo, " principal"));
STROUT(KANAMEMAX);
STROUT(KANAMEMAX);
break;
}
case 4: /* Set Password */
- printf(" principal");
+ ND_PRINT((ndo, " principal"));
STROUT(KANAMEMAX);
STROUT(KANAMEMAX);
- printf(" kvno");
+ ND_PRINT((ndo, " kvno"));
INTOUT();
break;
case 12: /* Get password */
- printf(" name");
+ ND_PRINT((ndo, " name"));
STROUT(KANAMEMAX);
break;
default:
@@ -1893,7 +1979,7 @@ kauth_print(register const u_char *bp, int length)
return;
trunc:
- printf(" [|kauth]");
+ ND_PRINT((ndo, " [|kauth]"));
}
/*
@@ -1901,28 +1987,29 @@ trunc:
*/
static void
-kauth_reply_print(register const u_char *bp, int length, int32_t opcode)
+kauth_reply_print(netdissect_options *ndo,
+ register const u_char *bp, int length, int32_t opcode)
{
- struct rx_header *rxh;
+ const struct rx_header *rxh;
if (length <= (int)sizeof(struct rx_header))
return;
- rxh = (struct rx_header *) bp;
+ rxh = (const struct rx_header *) bp;
/*
* Print out the afs call we're invoking. The table used here was
* gleaned from kauth/kauth.rg
*/
- printf(" kauth");
+ ND_PRINT((ndo, " kauth"));
if (is_ubik(opcode)) {
- ubik_reply_print(bp, length, opcode);
+ ubik_reply_print(ndo, bp, length, opcode);
return;
}
- printf(" reply %s", tok2str(kauth_req, "op#%d", opcode));
+ ND_PRINT((ndo, " reply %s", tok2str(kauth_req, "op#%d", opcode)));
bp += sizeof(struct rx_header);
@@ -1937,14 +2024,14 @@ kauth_reply_print(register const u_char *bp, int length, int32_t opcode)
/*
* Otherwise, just print out the return code
*/
- printf(" errcode");
+ ND_PRINT((ndo, " errcode"));
INTOUT();
}
return;
trunc:
- printf(" [|kauth]");
+ ND_PRINT((ndo, " [|kauth]"));
}
/*
@@ -1952,14 +2039,15 @@ trunc:
*/
static void
-vol_print(register const u_char *bp, int length)
+vol_print(netdissect_options *ndo,
+ register const u_char *bp, int length)
{
int vol_op;
if (length <= (int)sizeof(struct rx_header))
return;
- if (snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) {
+ if (ndo->ndo_snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) {
goto trunc;
}
@@ -1970,126 +2058,126 @@ vol_print(register const u_char *bp, int length)
vol_op = EXTRACT_32BITS(bp + sizeof(struct rx_header));
- printf(" vol call %s", tok2str(vol_req, "op#%d", vol_op));
+ ND_PRINT((ndo, " vol call %s", tok2str(vol_req, "op#%d", vol_op)));
bp += sizeof(struct rx_header) + 4;
switch (vol_op) {
case 100: /* Create volume */
- printf(" partition");
+ ND_PRINT((ndo, " partition"));
UINTOUT();
- printf(" name");
+ ND_PRINT((ndo, " name"));
STROUT(AFSNAMEMAX);
- printf(" type");
+ ND_PRINT((ndo, " type"));
UINTOUT();
- printf(" parent");
+ ND_PRINT((ndo, " parent"));
UINTOUT();
break;
case 101: /* Delete volume */
case 107: /* Get flags */
- printf(" trans");
+ ND_PRINT((ndo, " trans"));
UINTOUT();
break;
case 102: /* Restore */
- printf(" totrans");
+ ND_PRINT((ndo, " totrans"));
UINTOUT();
- printf(" flags");
+ ND_PRINT((ndo, " flags"));
UINTOUT();
break;
case 103: /* Forward */
- printf(" fromtrans");
+ ND_PRINT((ndo, " fromtrans"));
UINTOUT();
- printf(" fromdate");
+ ND_PRINT((ndo, " fromdate"));
DATEOUT();
DESTSERVEROUT();
- printf(" desttrans");
+ ND_PRINT((ndo, " desttrans"));
INTOUT();
break;
case 104: /* End trans */
- printf(" trans");
+ ND_PRINT((ndo, " trans"));
UINTOUT();
break;
case 105: /* Clone */
- printf(" trans");
+ ND_PRINT((ndo, " trans"));
UINTOUT();
- printf(" purgevol");
+ ND_PRINT((ndo, " purgevol"));
UINTOUT();
- printf(" newtype");
+ ND_PRINT((ndo, " newtype"));
UINTOUT();
- printf(" newname");
+ ND_PRINT((ndo, " newname"));
STROUT(AFSNAMEMAX);
break;
case 106: /* Set flags */
- printf(" trans");
+ ND_PRINT((ndo, " trans"));
UINTOUT();
- printf(" flags");
+ ND_PRINT((ndo, " flags"));
UINTOUT();
break;
case 108: /* Trans create */
- printf(" vol");
+ ND_PRINT((ndo, " vol"));
UINTOUT();
- printf(" partition");
+ ND_PRINT((ndo, " partition"));
UINTOUT();
- printf(" flags");
+ ND_PRINT((ndo, " flags"));
UINTOUT();
break;
case 109: /* Dump */
case 655537: /* Get size */
- printf(" fromtrans");
+ ND_PRINT((ndo, " fromtrans"));
UINTOUT();
- printf(" fromdate");
+ ND_PRINT((ndo, " fromdate"));
DATEOUT();
break;
case 110: /* Get n-th volume */
- printf(" index");
+ ND_PRINT((ndo, " index"));
UINTOUT();
break;
case 111: /* Set forwarding */
- printf(" tid");
+ ND_PRINT((ndo, " tid"));
UINTOUT();
- printf(" newsite");
+ ND_PRINT((ndo, " newsite"));
UINTOUT();
break;
case 112: /* Get name */
case 113: /* Get status */
- printf(" tid");
+ ND_PRINT((ndo, " tid"));
break;
case 114: /* Signal restore */
- printf(" name");
+ ND_PRINT((ndo, " name"));
STROUT(AFSNAMEMAX);
- printf(" type");
+ ND_PRINT((ndo, " type"));
UINTOUT();
- printf(" pid");
+ ND_PRINT((ndo, " pid"));
UINTOUT();
- printf(" cloneid");
+ ND_PRINT((ndo, " cloneid"));
UINTOUT();
break;
case 116: /* List volumes */
- printf(" partition");
+ ND_PRINT((ndo, " partition"));
UINTOUT();
- printf(" flags");
+ ND_PRINT((ndo, " flags"));
UINTOUT();
break;
case 117: /* Set id types */
- printf(" tid");
+ ND_PRINT((ndo, " tid"));
UINTOUT();
- printf(" name");
+ ND_PRINT((ndo, " name"));
STROUT(AFSNAMEMAX);
- printf(" type");
+ ND_PRINT((ndo, " type"));
UINTOUT();
- printf(" pid");
+ ND_PRINT((ndo, " pid"));
UINTOUT();
- printf(" clone");
+ ND_PRINT((ndo, " clone"));
UINTOUT();
- printf(" backup");
+ ND_PRINT((ndo, " backup"));
UINTOUT();
break;
case 119: /* Partition info */
- printf(" name");
+ ND_PRINT((ndo, " name"));
STROUT(AFSNAMEMAX);
break;
case 120: /* Reclone */
- printf(" tid");
+ ND_PRINT((ndo, " tid"));
UINTOUT();
break;
case 121: /* List one volume */
@@ -2097,46 +2185,46 @@ vol_print(register const u_char *bp, int length)
case 124: /* Extended List volumes */
case 125: /* Extended List one volume */
case 65536: /* Convert RO to RW volume */
- printf(" partid");
+ ND_PRINT((ndo, " partid"));
UINTOUT();
- printf(" volid");
+ ND_PRINT((ndo, " volid"));
UINTOUT();
break;
case 123: /* Set date */
- printf(" tid");
+ ND_PRINT((ndo, " tid"));
UINTOUT();
- printf(" date");
+ ND_PRINT((ndo, " date"));
DATEOUT();
break;
case 126: /* Set info */
- printf(" tid");
+ ND_PRINT((ndo, " tid"));
UINTOUT();
break;
case 128: /* Forward multiple */
- printf(" fromtrans");
+ ND_PRINT((ndo, " fromtrans"));
UINTOUT();
- printf(" fromdate");
+ ND_PRINT((ndo, " fromdate"));
DATEOUT();
{
unsigned long i, j;
- TCHECK2(bp[0], 4);
+ ND_TCHECK2(bp[0], 4);
j = EXTRACT_32BITS(bp);
bp += sizeof(int32_t);
for (i = 0; i < j; i++) {
DESTSERVEROUT();
if (i != j - 1)
- printf(",");
+ ND_PRINT((ndo, ","));
}
if (j == 0)
- printf(" <none!>");
+ ND_PRINT((ndo, " <none!>"));
}
break;
case 65538: /* Dump version 2 */
- printf(" fromtrans");
+ ND_PRINT((ndo, " fromtrans"));
UINTOUT();
- printf(" fromdate");
+ ND_PRINT((ndo, " fromdate"));
DATEOUT();
- printf(" flags");
+ ND_PRINT((ndo, " flags"));
UINTOUT();
break;
default:
@@ -2145,7 +2233,7 @@ vol_print(register const u_char *bp, int length)
return;
trunc:
- printf(" [|vol]");
+ ND_PRINT((ndo, " [|vol]"));
}
/*
@@ -2153,21 +2241,22 @@ trunc:
*/
static void
-vol_reply_print(register const u_char *bp, int length, int32_t opcode)
+vol_reply_print(netdissect_options *ndo,
+ register const u_char *bp, int length, int32_t opcode)
{
- struct rx_header *rxh;
+ const struct rx_header *rxh;
if (length <= (int)sizeof(struct rx_header))
return;
- rxh = (struct rx_header *) bp;
+ rxh = (const struct rx_header *) bp;
/*
* Print out the afs call we're invoking. The table used here was
* gleaned from volser/volint.xg
*/
- printf(" vol reply %s", tok2str(vol_req, "op#%d", opcode));
+ ND_PRINT((ndo, " vol reply %s", tok2str(vol_req, "op#%d", opcode)));
bp += sizeof(struct rx_header);
@@ -2178,66 +2267,66 @@ vol_reply_print(register const u_char *bp, int length, int32_t opcode)
if (rxh->type == RX_PACKET_TYPE_DATA) {
switch (opcode) {
case 100: /* Create volume */
- printf(" volid");
+ ND_PRINT((ndo, " volid"));
UINTOUT();
- printf(" trans");
+ ND_PRINT((ndo, " trans"));
UINTOUT();
break;
case 104: /* End transaction */
UINTOUT();
break;
case 105: /* Clone */
- printf(" newvol");
+ ND_PRINT((ndo, " newvol"));
UINTOUT();
break;
case 107: /* Get flags */
UINTOUT();
break;
case 108: /* Transaction create */
- printf(" trans");
+ ND_PRINT((ndo, " trans"));
UINTOUT();
break;
case 110: /* Get n-th volume */
- printf(" volume");
+ ND_PRINT((ndo, " volume"));
UINTOUT();
- printf(" partition");
+ ND_PRINT((ndo, " partition"));
UINTOUT();
break;
case 112: /* Get name */
STROUT(AFSNAMEMAX);
break;
case 113: /* Get status */
- printf(" volid");
+ ND_PRINT((ndo, " volid"));
UINTOUT();
- printf(" nextuniq");
+ ND_PRINT((ndo, " nextuniq"));
UINTOUT();
- printf(" type");
+ ND_PRINT((ndo, " type"));
UINTOUT();
- printf(" parentid");
+ ND_PRINT((ndo, " parentid"));
UINTOUT();
- printf(" clone");
+ ND_PRINT((ndo, " clone"));
UINTOUT();
- printf(" backup");
+ ND_PRINT((ndo, " backup"));
UINTOUT();
- printf(" restore");
+ ND_PRINT((ndo, " restore"));
UINTOUT();
- printf(" maxquota");
+ ND_PRINT((ndo, " maxquota"));
UINTOUT();
- printf(" minquota");
+ ND_PRINT((ndo, " minquota"));
UINTOUT();
- printf(" owner");
+ ND_PRINT((ndo, " owner"));
UINTOUT();
- printf(" create");
+ ND_PRINT((ndo, " create"));
DATEOUT();
- printf(" access");
+ ND_PRINT((ndo, " access"));
DATEOUT();
- printf(" update");
+ ND_PRINT((ndo, " update"));
DATEOUT();
- printf(" expire");
+ ND_PRINT((ndo, " expire"));
DATEOUT();
- printf(" backup");
+ ND_PRINT((ndo, " backup"));
DATEOUT();
- printf(" copy");
+ ND_PRINT((ndo, " copy"));
DATEOUT();
break;
case 115: /* Old list partitions */
@@ -2246,24 +2335,24 @@ vol_reply_print(register const u_char *bp, int length, int32_t opcode)
case 121: /* List one volume */
{
unsigned long i, j;
- TCHECK2(bp[0], 4);
+ ND_TCHECK2(bp[0], 4);
j = EXTRACT_32BITS(bp);
bp += sizeof(int32_t);
for (i = 0; i < j; i++) {
- printf(" name");
+ ND_PRINT((ndo, " name"));
VECOUT(32);
- printf(" volid");
+ ND_PRINT((ndo, " volid"));
UINTOUT();
- printf(" type");
+ ND_PRINT((ndo, " type"));
bp += sizeof(int32_t) * 21;
if (i != j - 1)
- printf(",");
+ ND_PRINT((ndo, ","));
}
if (j == 0)
- printf(" <none!>");
+ ND_PRINT((ndo, " <none!>"));
}
break;
-
+
default:
;
@@ -2272,14 +2361,14 @@ vol_reply_print(register const u_char *bp, int length, int32_t opcode)
/*
* Otherwise, just print out the return code
*/
- printf(" errcode");
+ ND_PRINT((ndo, " errcode"));
INTOUT();
}
return;
trunc:
- printf(" [|vol]");
+ ND_PRINT((ndo, " [|vol]"));
}
/*
@@ -2287,14 +2376,15 @@ trunc:
*/
static void
-bos_print(register const u_char *bp, int length)
+bos_print(netdissect_options *ndo,
+ register const u_char *bp, int length)
{
int bos_op;
if (length <= (int)sizeof(struct rx_header))
return;
- if (snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) {
+ if (ndo->ndo_snapend - bp + 1 <= (int)(sizeof(struct rx_header) + sizeof(int32_t))) {
goto trunc;
}
@@ -2305,7 +2395,7 @@ bos_print(register const u_char *bp, int length)
bos_op = EXTRACT_32BITS(bp + sizeof(struct rx_header));
- printf(" bos call %s", tok2str(bos_req, "op#%d", bos_op));
+ ND_PRINT((ndo, " bos call %s", tok2str(bos_req, "op#%d", bos_op)));
/*
* Decode some of the arguments to the BOS calls
@@ -2315,9 +2405,9 @@ bos_print(register const u_char *bp, int length)
switch (bos_op) {
case 80: /* Create B node */
- printf(" type");
+ ND_PRINT((ndo, " type"));
STROUT(BOSNAMEMAX);
- printf(" instance");
+ ND_PRINT((ndo, " instance"));
STROUT(BOSNAMEMAX);
break;
case 81: /* Delete B node */
@@ -2338,12 +2428,12 @@ bos_print(register const u_char *bp, int length)
case 82: /* Set status */
case 98: /* Set T status */
STROUT(BOSNAMEMAX);
- printf(" status");
+ ND_PRINT((ndo, " status"));
INTOUT();
break;
case 86: /* Get instance parm */
STROUT(BOSNAMEMAX);
- printf(" num");
+ ND_PRINT((ndo, " num"));
INTOUT();
break;
case 84: /* Enumerate instance */
@@ -2356,11 +2446,11 @@ bos_print(register const u_char *bp, int length)
break;
case 105: /* Install */
STROUT(BOSNAMEMAX);
- printf(" size");
+ ND_PRINT((ndo, " size"));
INTOUT();
- printf(" flags");
+ ND_PRINT((ndo, " flags"));
INTOUT();
- printf(" date");
+ ND_PRINT((ndo, " date"));
INTOUT();
break;
default:
@@ -2370,7 +2460,7 @@ bos_print(register const u_char *bp, int length)
return;
trunc:
- printf(" [|bos]");
+ ND_PRINT((ndo, " [|bos]"));
}
/*
@@ -2378,21 +2468,22 @@ trunc:
*/
static void
-bos_reply_print(register const u_char *bp, int length, int32_t opcode)
+bos_reply_print(netdissect_options *ndo,
+ register const u_char *bp, int length, int32_t opcode)
{
- struct rx_header *rxh;
+ const struct rx_header *rxh;
if (length <= (int)sizeof(struct rx_header))
return;
- rxh = (struct rx_header *) bp;
+ rxh = (const struct rx_header *) bp;
/*
* Print out the afs call we're invoking. The table used here was
* gleaned from volser/volint.xg
*/
- printf(" bos reply %s", tok2str(bos_req, "op#%d", opcode));
+ ND_PRINT((ndo, " bos reply %s", tok2str(bos_req, "op#%d", opcode)));
bp += sizeof(struct rx_header);
@@ -2407,14 +2498,14 @@ bos_reply_print(register const u_char *bp, int length, int32_t opcode)
/*
* Otherwise, just print out the return code
*/
- printf(" errcode");
+ ND_PRINT((ndo, " errcode"));
INTOUT();
}
return;
trunc:
- printf(" [|bos]");
+ ND_PRINT((ndo, " [|bos]"));
}
/*
@@ -2422,7 +2513,7 @@ trunc:
*/
static int
-is_ubik(u_int32_t opcode)
+is_ubik(uint32_t opcode)
{
if ((opcode >= VOTE_LOW && opcode <= VOTE_HIGH) ||
(opcode >= DISK_LOW && opcode <= DISK_HIGH))
@@ -2436,7 +2527,8 @@ is_ubik(u_int32_t opcode)
*/
static void
-ubik_print(register const u_char *bp)
+ubik_print(netdissect_options *ndo,
+ register const u_char *bp)
{
int ubik_op;
int32_t temp;
@@ -2448,7 +2540,7 @@ ubik_print(register const u_char *bp)
ubik_op = EXTRACT_32BITS(bp + sizeof(struct rx_header));
- printf(" ubik call %s", tok2str(ubik_req, "op#%d", ubik_op));
+ ND_PRINT((ndo, " ubik call %s", tok2str(ubik_req, "op#%d", ubik_op)));
/*
* Decode some of the arguments to the Ubik calls
@@ -2458,19 +2550,19 @@ ubik_print(register const u_char *bp)
switch (ubik_op) {
case 10000: /* Beacon */
- TCHECK2(bp[0], 4);
+ ND_TCHECK2(bp[0], 4);
temp = EXTRACT_32BITS(bp);
bp += sizeof(int32_t);
- printf(" syncsite %s", temp ? "yes" : "no");
- printf(" votestart");
+ ND_PRINT((ndo, " syncsite %s", temp ? "yes" : "no"));
+ ND_PRINT((ndo, " votestart"));
DATEOUT();
- printf(" dbversion");
+ ND_PRINT((ndo, " dbversion"));
UBIK_VERSIONOUT();
- printf(" tid");
+ ND_PRINT((ndo, " tid"));
UBIK_VERSIONOUT();
break;
case 10003: /* Get sync site */
- printf(" site");
+ ND_PRINT((ndo, " site"));
UINTOUT();
break;
case 20000: /* Begin */
@@ -2478,56 +2570,56 @@ ubik_print(register const u_char *bp)
case 20007: /* Abort */
case 20008: /* Release locks */
case 20010: /* Writev */
- printf(" tid");
+ ND_PRINT((ndo, " tid"));
UBIK_VERSIONOUT();
break;
case 20002: /* Lock */
- printf(" tid");
+ ND_PRINT((ndo, " tid"));
UBIK_VERSIONOUT();
- printf(" file");
+ ND_PRINT((ndo, " file"));
INTOUT();
- printf(" pos");
+ ND_PRINT((ndo, " pos"));
INTOUT();
- printf(" length");
+ ND_PRINT((ndo, " length"));
INTOUT();
temp = EXTRACT_32BITS(bp);
bp += sizeof(int32_t);
tok2str(ubik_lock_types, "type %d", temp);
break;
case 20003: /* Write */
- printf(" tid");
+ ND_PRINT((ndo, " tid"));
UBIK_VERSIONOUT();
- printf(" file");
+ ND_PRINT((ndo, " file"));
INTOUT();
- printf(" pos");
+ ND_PRINT((ndo, " pos"));
INTOUT();
break;
case 20005: /* Get file */
- printf(" file");
+ ND_PRINT((ndo, " file"));
INTOUT();
break;
case 20006: /* Send file */
- printf(" file");
+ ND_PRINT((ndo, " file"));
INTOUT();
- printf(" length");
+ ND_PRINT((ndo, " length"));
INTOUT();
- printf(" dbversion");
+ ND_PRINT((ndo, " dbversion"));
UBIK_VERSIONOUT();
break;
case 20009: /* Truncate */
- printf(" tid");
+ ND_PRINT((ndo, " tid"));
UBIK_VERSIONOUT();
- printf(" file");
+ ND_PRINT((ndo, " file"));
INTOUT();
- printf(" length");
+ ND_PRINT((ndo, " length"));
INTOUT();
break;
case 20012: /* Set version */
- printf(" tid");
+ ND_PRINT((ndo, " tid"));
UBIK_VERSIONOUT();
- printf(" oldversion");
+ ND_PRINT((ndo, " oldversion"));
UBIK_VERSIONOUT();
- printf(" newversion");
+ ND_PRINT((ndo, " newversion"));
UBIK_VERSIONOUT();
break;
default:
@@ -2537,7 +2629,7 @@ ubik_print(register const u_char *bp)
return;
trunc:
- printf(" [|ubik]");
+ ND_PRINT((ndo, " [|ubik]"));
}
/*
@@ -2545,21 +2637,22 @@ trunc:
*/
static void
-ubik_reply_print(register const u_char *bp, int length, int32_t opcode)
+ubik_reply_print(netdissect_options *ndo,
+ register const u_char *bp, int length, int32_t opcode)
{
- struct rx_header *rxh;
+ const struct rx_header *rxh;
if (length < (int)sizeof(struct rx_header))
return;
- rxh = (struct rx_header *) bp;
+ rxh = (const struct rx_header *) bp;
/*
* Print out the ubik call we're invoking. This table was gleaned
* from ubik/ubik_int.xg
*/
- printf(" ubik reply %s", tok2str(ubik_req, "op#%d", opcode));
+ ND_PRINT((ndo, " ubik reply %s", tok2str(ubik_req, "op#%d", opcode)));
bp += sizeof(struct rx_header);
@@ -2570,10 +2663,10 @@ ubik_reply_print(register const u_char *bp, int length, int32_t opcode)
if (rxh->type == RX_PACKET_TYPE_DATA)
switch (opcode) {
case 10000: /* Beacon */
- printf(" vote no");
+ ND_PRINT((ndo, " vote no"));
break;
case 20004: /* Get version */
- printf(" dbversion");
+ ND_PRINT((ndo, " dbversion"));
UBIK_VERSIONOUT();
break;
default:
@@ -2589,18 +2682,18 @@ ubik_reply_print(register const u_char *bp, int length, int32_t opcode)
else
switch (opcode) {
case 10000: /* Beacon */
- printf(" vote yes until");
+ ND_PRINT((ndo, " vote yes until"));
DATEOUT();
break;
default:
- printf(" errcode");
+ ND_PRINT((ndo, " errcode"));
INTOUT();
}
return;
trunc:
- printf(" [|ubik]");
+ ND_PRINT((ndo, " [|ubik]"));
}
/*
@@ -2608,11 +2701,12 @@ trunc:
*/
static void
-rx_ack_print(register const u_char *bp, int length)
+rx_ack_print(netdissect_options *ndo,
+ register const u_char *bp, int length)
{
- struct rx_ackPacket *rxa;
+ const struct rx_ackPacket *rxa;
int i, start, last;
- u_int32_t firstPacket;
+ uint32_t firstPacket;
if (length < (int)sizeof(struct rx_header))
return;
@@ -2627,24 +2721,24 @@ rx_ack_print(register const u_char *bp, int length)
* rx_ackPacket structure.
*/
- TCHECK2(bp[0], sizeof(struct rx_ackPacket) - RX_MAXACKS);
+ ND_TCHECK2(bp[0], sizeof(struct rx_ackPacket) - RX_MAXACKS);
- rxa = (struct rx_ackPacket *) bp;
+ rxa = (const struct rx_ackPacket *) bp;
bp += (sizeof(struct rx_ackPacket) - RX_MAXACKS);
/*
* Print out a few useful things from the ack packet structure
*/
- if (vflag > 2)
- printf(" bufspace %d maxskew %d",
+ if (ndo->ndo_vflag > 2)
+ ND_PRINT((ndo, " bufspace %d maxskew %d",
(int) EXTRACT_16BITS(&rxa->bufferSpace),
- (int) EXTRACT_16BITS(&rxa->maxSkew));
+ (int) EXTRACT_16BITS(&rxa->maxSkew)));
firstPacket = EXTRACT_32BITS(&rxa->firstPacket);
- printf(" first %d serial %d reason %s",
+ ND_PRINT((ndo, " first %d serial %d reason %s",
firstPacket, EXTRACT_32BITS(&rxa->serial),
- tok2str(rx_ack_reasons, "#%d", (int) rxa->reason));
+ tok2str(rx_ack_reasons, "#%d", (int) rxa->reason)));
/*
* Okay, now we print out the ack array. The way _this_ works
@@ -2667,7 +2761,7 @@ rx_ack_print(register const u_char *bp, int length)
if (rxa->nAcks != 0) {
- TCHECK2(bp[0], rxa->nAcks);
+ ND_TCHECK2(bp[0], rxa->nAcks);
/*
* Sigh, this is gross, but it seems to work to collapse
@@ -2685,13 +2779,12 @@ rx_ack_print(register const u_char *bp, int length)
*/
if (last == -2) {
- printf(" acked %d",
- firstPacket + i);
+ ND_PRINT((ndo, " acked %d", firstPacket + i));
start = i;
}
/*
- * Otherwise, if the there is a skip in
+ * Otherwise, if there is a skip in
* the range (such as an nacked packet in
* the middle of some acked packets),
* then print the current packet number
@@ -2700,7 +2793,7 @@ rx_ack_print(register const u_char *bp, int length)
*/
else if (last != i - 1) {
- printf(",%d", firstPacket + i);
+ ND_PRINT((ndo, ",%d", firstPacket + i));
start = i;
}
@@ -2726,7 +2819,7 @@ rx_ack_print(register const u_char *bp, int length)
* range.
*/
} else if (last == i - 1 && start != last)
- printf("-%d", firstPacket + i - 1);
+ ND_PRINT((ndo, "-%d", firstPacket + i - 1));
/*
* So, what's going on here? We ran off the end of the
@@ -2740,7 +2833,7 @@ rx_ack_print(register const u_char *bp, int length)
*/
if (last == i - 1 && start != last)
- printf("-%d", firstPacket + i - 1);
+ ND_PRINT((ndo, "-%d", firstPacket + i - 1));
/*
* Same as above, just without comments
@@ -2749,19 +2842,18 @@ rx_ack_print(register const u_char *bp, int length)
for (i = 0, start = last = -2; i < rxa->nAcks; i++)
if (rxa->acks[i] == RX_ACK_TYPE_NACK) {
if (last == -2) {
- printf(" nacked %d",
- firstPacket + i);
+ ND_PRINT((ndo, " nacked %d", firstPacket + i));
start = i;
} else if (last != i - 1) {
- printf(",%d", firstPacket + i);
+ ND_PRINT((ndo, ",%d", firstPacket + i));
start = i;
}
last = i;
} else if (last == i - 1 && start != last)
- printf("-%d", firstPacket + i - 1);
+ ND_PRINT((ndo, "-%d", firstPacket + i - 1));
if (last == i - 1 && start != last)
- printf("-%d", firstPacket + i - 1);
+ ND_PRINT((ndo, "-%d", firstPacket + i - 1));
bp += rxa->nAcks;
}
@@ -2772,29 +2864,32 @@ rx_ack_print(register const u_char *bp, int length)
* you may or may not see them
*/
-#define TRUNCRET(n) if (snapend - bp + 1 <= n) return;
+#define TRUNCRET(n) if (ndo->ndo_snapend - bp + 1 <= n) return;
- if (vflag > 1) {
+ if (ndo->ndo_vflag > 1) {
TRUNCRET(4);
- printf(" ifmtu");
+ ND_PRINT((ndo, " ifmtu"));
INTOUT();
TRUNCRET(4);
- printf(" maxmtu");
+ ND_PRINT((ndo, " maxmtu"));
INTOUT();
TRUNCRET(4);
- printf(" rwind");
+ ND_PRINT((ndo, " rwind"));
INTOUT();
TRUNCRET(4);
- printf(" maxpackets");
+ ND_PRINT((ndo, " maxpackets"));
INTOUT();
}
return;
trunc:
- printf(" [|ack]");
+ ND_PRINT((ndo, " [|ack]"));
}
#undef TRUNCRET
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-rx-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-sctp.c b/freebsd/contrib/tcpdump/print-sctp.c
index afd3f7d2..7df9b795 100644
--- a/freebsd/contrib/tcpdump/print-sctp.c
+++ b/freebsd/contrib/tcpdump/print-sctp.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/* Copyright (c) 2001 NETLAB, Temple University
* Copyright (c) 2001 Protocol Engineering Lab, University of Delaware
*
@@ -35,43 +38,451 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
-"@(#) $Header: /tcpdump/master/tcpdump/print-sctp.c,v 1.21 2007-09-13 18:03:49 guy Exp $ (NETLAB/PEL)";
-#endif
+/* \summary: Stream Control Transmission Protocol (SCTP) printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
-
-#include "sctpHeader.h"
-#include "sctpConstants.h"
-#include <assert.h>
+#include <netdissect-stdinc.h>
-#include <stdio.h>
-#include <string.h>
-
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
-#include "extract.h" /* must come after interface.h */
+#include "extract.h"
#include "ip.h"
-#ifdef INET6
#include "ip6.h"
-#endif
+
+/* Definitions from:
+ *
+ * SCTP reference Implementation Copyright (C) 1999 Cisco And Motorola
+ *
+ * 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 Cisco nor of Motorola may be used
+ * to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
+ *
+ * This file is part of the SCTP reference Implementation
+ *
+ *
+ * Please send any bug reports or fixes you make to one of the following email
+ * addresses:
+ *
+ * rstewar1@email.mot.com
+ * kmorneau@cisco.com
+ * qxie1@email.mot.com
+ *
+ * Any bugs reported given to us we will try to fix... any fixes shared will
+ * be incorperated into the next SCTP release.
+ */
+
+/* The valid defines for all message
+ * types know to SCTP. 0 is reserved
+ */
+#define SCTP_DATA 0x00
+#define SCTP_INITIATION 0x01
+#define SCTP_INITIATION_ACK 0x02
+#define SCTP_SELECTIVE_ACK 0x03
+#define SCTP_HEARTBEAT_REQUEST 0x04
+#define SCTP_HEARTBEAT_ACK 0x05
+#define SCTP_ABORT_ASSOCIATION 0x06
+#define SCTP_SHUTDOWN 0x07
+#define SCTP_SHUTDOWN_ACK 0x08
+#define SCTP_OPERATION_ERR 0x09
+#define SCTP_COOKIE_ECHO 0x0a
+#define SCTP_COOKIE_ACK 0x0b
+#define SCTP_ECN_ECHO 0x0c
+#define SCTP_ECN_CWR 0x0d
+#define SCTP_SHUTDOWN_COMPLETE 0x0e
+#define SCTP_FORWARD_CUM_TSN 0xc0
+#define SCTP_RELIABLE_CNTL 0xc1
+#define SCTP_RELIABLE_CNTL_ACK 0xc2
+
+static const struct tok sctp_chunkid_str[] = {
+ { SCTP_DATA, "DATA" },
+ { SCTP_INITIATION, "INIT" },
+ { SCTP_INITIATION_ACK, "INIT ACK" },
+ { SCTP_SELECTIVE_ACK, "SACK" },
+ { SCTP_HEARTBEAT_REQUEST, "HB REQ" },
+ { SCTP_HEARTBEAT_ACK, "HB ACK" },
+ { SCTP_ABORT_ASSOCIATION, "ABORT" },
+ { SCTP_SHUTDOWN, "SHUTDOWN" },
+ { SCTP_SHUTDOWN_ACK, "SHUTDOWN ACK" },
+ { SCTP_OPERATION_ERR, "OP ERR" },
+ { SCTP_COOKIE_ECHO, "COOKIE ECHO" },
+ { SCTP_COOKIE_ACK, "COOKIE ACK" },
+ { SCTP_ECN_ECHO, "ECN ECHO" },
+ { SCTP_ECN_CWR, "ECN CWR" },
+ { SCTP_SHUTDOWN_COMPLETE, "SHUTDOWN COMPLETE" },
+ { SCTP_FORWARD_CUM_TSN, "FOR CUM TSN" },
+ { SCTP_RELIABLE_CNTL, "REL CTRL" },
+ { SCTP_RELIABLE_CNTL_ACK, "REL CTRL ACK" },
+ { 0, NULL }
+};
+
+/* Data Chuck Specific Flags */
+#define SCTP_DATA_FRAG_MASK 0x03
+#define SCTP_DATA_MIDDLE_FRAG 0x00
+#define SCTP_DATA_LAST_FRAG 0x01
+#define SCTP_DATA_FIRST_FRAG 0x02
+#define SCTP_DATA_NOT_FRAG 0x03
+#define SCTP_DATA_UNORDERED 0x04
+
+#define SCTP_ADDRMAX 60
#define CHAN_HP 6704
#define CHAN_MP 6705
#define CHAN_LP 6706
-struct tok ForCES_channels[] = {
+/* the sctp common header */
+
+struct sctpHeader{
+ uint16_t source;
+ uint16_t destination;
+ uint32_t verificationTag;
+ uint32_t adler32;
+};
+
+/* various descriptor parsers */
+
+struct sctpChunkDesc{
+ uint8_t chunkID;
+ uint8_t chunkFlg;
+ uint16_t chunkLength;
+};
+
+struct sctpParamDesc{
+ uint16_t paramType;
+ uint16_t paramLength;
+};
+
+
+struct sctpRelChunkDesc{
+ struct sctpChunkDesc chk;
+ uint32_t serialNumber;
+};
+
+struct sctpVendorSpecificParam {
+ struct sctpParamDesc p; /* type must be 0xfffe */
+ uint32_t vendorId; /* vendor ID from RFC 1700 */
+ uint16_t vendorSpecificType;
+ uint16_t vendorSpecificLen;
+};
+
+
+/* Structures for the control parts */
+
+
+
+/* Sctp association init request/ack */
+
+/* this is used for init ack, too */
+struct sctpInitiation{
+ uint32_t initTag; /* tag of mine */
+ uint32_t rcvWindowCredit; /* rwnd */
+ uint16_t NumPreopenStreams; /* OS */
+ uint16_t MaxInboundStreams; /* MIS */
+ uint32_t initialTSN;
+ /* optional param's follow in sctpParamDesc form */
+};
+
+struct sctpV4IpAddress{
+ struct sctpParamDesc p; /* type is set to SCTP_IPV4_PARAM_TYPE, len=10 */
+ uint32_t ipAddress;
+};
+
+
+struct sctpV6IpAddress{
+ struct sctpParamDesc p; /* type is set to SCTP_IPV6_PARAM_TYPE, len=22 */
+ uint8_t ipAddress[16];
+};
+
+struct sctpDNSName{
+ struct sctpParamDesc param;
+ uint8_t name[1];
+};
+
+
+struct sctpCookiePreserve{
+ struct sctpParamDesc p; /* type is set to SCTP_COOKIE_PRESERVE, len=8 */
+ uint32_t extraTime;
+};
+
+
+struct sctpTimeStamp{
+ uint32_t ts_sec;
+ uint32_t ts_usec;
+};
+
+/* wire structure of my cookie */
+struct cookieMessage{
+ uint32_t TieTag_curTag; /* copied from assoc if present */
+ uint32_t TieTag_hisTag; /* copied from assoc if present */
+ int32_t cookieLife; /* life I will award this cookie */
+ struct sctpTimeStamp timeEnteringState; /* the time I built cookie */
+ struct sctpInitiation initAckISent; /* the INIT-ACK that I sent to my peer */
+ uint32_t addressWhereISent[4]; /* I make this 4 ints so I get 128bits for future */
+ int32_t addrtype; /* address type */
+ uint16_t locScope; /* V6 local scope flag */
+ uint16_t siteScope; /* V6 site scope flag */
+ /* at the end is tacked on the INIT chunk sent in
+ * its entirety and of course our
+ * signature.
+ */
+};
+
+
+/* this guy is for use when
+ * I have a initiate message gloming the
+ * things together.
+
+ */
+struct sctpUnifiedInit{
+ struct sctpChunkDesc uh;
+ struct sctpInitiation initm;
+};
+
+struct sctpSendableInit{
+ struct sctpHeader mh;
+ struct sctpUnifiedInit msg;
+};
+
+
+/* Selective Acknowledgement
+ * has the following structure with
+ * a optional ammount of trailing int's
+ * on the last part (based on the numberOfDesc
+ * field).
+ */
+
+struct sctpSelectiveAck{
+ uint32_t highestConseqTSN;
+ uint32_t updatedRwnd;
+ uint16_t numberOfdesc;
+ uint16_t numDupTsns;
+};
+
+struct sctpSelectiveFrag{
+ uint16_t fragmentStart;
+ uint16_t fragmentEnd;
+};
+
+
+struct sctpUnifiedSack{
+ struct sctpChunkDesc uh;
+ struct sctpSelectiveAck sack;
+};
+
+/* for both RTT request/response the
+ * following is sent
+ */
+
+struct sctpHBrequest {
+ uint32_t time_value_1;
+ uint32_t time_value_2;
+};
+
+/* here is what I read and respond with to. */
+struct sctpHBunified{
+ struct sctpChunkDesc hdr;
+ struct sctpParamDesc hb;
+};
+
+
+/* here is what I send */
+struct sctpHBsender{
+ struct sctpChunkDesc hdr;
+ struct sctpParamDesc hb;
+ struct sctpHBrequest rtt;
+ int8_t addrFmt[SCTP_ADDRMAX];
+ uint16_t userreq;
+};
+
+
+
+/* for the abort and shutdown ACK
+ * we must carry the init tag in the common header. Just the
+ * common header is all that is needed with a chunk descriptor.
+ */
+struct sctpUnifiedAbort{
+ struct sctpChunkDesc uh;
+};
+
+struct sctpUnifiedAbortLight{
+ struct sctpHeader mh;
+ struct sctpChunkDesc uh;
+};
+
+struct sctpUnifiedAbortHeavy{
+ struct sctpHeader mh;
+ struct sctpChunkDesc uh;
+ uint16_t causeCode;
+ uint16_t causeLen;
+};
+
+/* For the graceful shutdown we must carry
+ * the tag (in common header) and the highest consequitive acking value
+ */
+struct sctpShutdown {
+ uint32_t TSN_Seen;
+};
+
+struct sctpUnifiedShutdown{
+ struct sctpChunkDesc uh;
+ struct sctpShutdown shut;
+};
+
+/* in the unified message we add the trailing
+ * stream id since it is the only message
+ * that is defined as a operation error.
+ */
+struct sctpOpErrorCause{
+ uint16_t cause;
+ uint16_t causeLen;
+};
+
+struct sctpUnifiedOpError{
+ struct sctpChunkDesc uh;
+ struct sctpOpErrorCause c;
+};
+
+struct sctpUnifiedStreamError{
+ struct sctpHeader mh;
+ struct sctpChunkDesc uh;
+ struct sctpOpErrorCause c;
+ uint16_t strmNum;
+ uint16_t reserved;
+};
+
+struct staleCookieMsg{
+ struct sctpHeader mh;
+ struct sctpChunkDesc uh;
+ struct sctpOpErrorCause c;
+ uint32_t moretime;
+};
+
+/* the following is used in all sends
+ * where nothing is needed except the
+ * chunk/type i.e. shutdownAck Abort */
+
+struct sctpUnifiedSingleMsg{
+ struct sctpHeader mh;
+ struct sctpChunkDesc uh;
+};
+
+struct sctpDataPart{
+ uint32_t TSN;
+ uint16_t streamId;
+ uint16_t sequence;
+ uint32_t payloadtype;
+};
+
+struct sctpUnifiedDatagram{
+ struct sctpChunkDesc uh;
+ struct sctpDataPart dp;
+};
+
+struct sctpECN_echo{
+ struct sctpChunkDesc uh;
+ uint32_t Lowest_TSN;
+};
+
+
+struct sctpCWR{
+ struct sctpChunkDesc uh;
+ uint32_t TSN_reduced_at;
+};
+
+static const struct tok ForCES_channels[] = {
{ CHAN_HP, "ForCES HP" },
{ CHAN_MP, "ForCES MP" },
{ CHAN_LP, "ForCES LP" },
{ 0, NULL }
};
+/* data chunk's payload protocol identifiers */
+
+#define SCTP_PPID_IUA 1
+#define SCTP_PPID_M2UA 2
+#define SCTP_PPID_M3UA 3
+#define SCTP_PPID_SUA 4
+#define SCTP_PPID_M2PA 5
+#define SCTP_PPID_V5UA 6
+#define SCTP_PPID_H248 7
+#define SCTP_PPID_BICC 8
+#define SCTP_PPID_TALI 9
+#define SCTP_PPID_DUA 10
+#define SCTP_PPID_ASAP 11
+#define SCTP_PPID_ENRP 12
+#define SCTP_PPID_H323 13
+#define SCTP_PPID_QIPC 14
+#define SCTP_PPID_SIMCO 15
+#define SCTP_PPID_DDPSC 16
+#define SCTP_PPID_DDPSSC 17
+#define SCTP_PPID_S1AP 18
+#define SCTP_PPID_RUA 19
+#define SCTP_PPID_HNBAP 20
+#define SCTP_PPID_FORCES_HP 21
+#define SCTP_PPID_FORCES_MP 22
+#define SCTP_PPID_FORCES_LP 23
+#define SCTP_PPID_SBC_AP 24
+#define SCTP_PPID_NBAP 25
+/* 26 */
+#define SCTP_PPID_X2AP 27
+
+static const struct tok PayloadProto_idents[] = {
+ { SCTP_PPID_IUA, "ISDN Q.921" },
+ { SCTP_PPID_M2UA, "M2UA" },
+ { SCTP_PPID_M3UA, "M3UA" },
+ { SCTP_PPID_SUA, "SUA" },
+ { SCTP_PPID_M2PA, "M2PA" },
+ { SCTP_PPID_V5UA, "V5.2" },
+ { SCTP_PPID_H248, "H.248" },
+ { SCTP_PPID_BICC, "BICC" },
+ { SCTP_PPID_TALI, "TALI" },
+ { SCTP_PPID_DUA, "DUA" },
+ { SCTP_PPID_ASAP, "ASAP" },
+ { SCTP_PPID_ENRP, "ENRP" },
+ { SCTP_PPID_H323, "H.323" },
+ { SCTP_PPID_QIPC, "Q.IPC" },
+ { SCTP_PPID_SIMCO, "SIMCO" },
+ { SCTP_PPID_DDPSC, "DDPSC" },
+ { SCTP_PPID_DDPSSC, "DDPSSC" },
+ { SCTP_PPID_S1AP, "S1AP" },
+ { SCTP_PPID_RUA, "RUA" },
+ { SCTP_PPID_HNBAP, "HNBAP" },
+ { SCTP_PPID_FORCES_HP, "ForCES HP" },
+ { SCTP_PPID_FORCES_MP, "ForCES MP" },
+ { SCTP_PPID_FORCES_LP, "ForCES LP" },
+ { SCTP_PPID_SBC_AP, "SBc-AP" },
+ { SCTP_PPID_NBAP, "NBAP" },
+ /* 26 */
+ { SCTP_PPID_X2AP, "X2AP" },
+ { 0, NULL }
+};
+
+
static inline int isForCES_port(u_short Port)
{
if (Port == CHAN_HP)
@@ -84,133 +495,129 @@ static inline int isForCES_port(u_short Port)
return 0;
}
-void sctp_print(const u_char *bp, /* beginning of sctp packet */
- const u_char *bp2, /* beginning of enclosing */
- u_int sctpPacketLength) /* ip packet */
+void sctp_print(netdissect_options *ndo,
+ const u_char *bp, /* beginning of sctp packet */
+ const u_char *bp2, /* beginning of enclosing */
+ u_int sctpPacketLength) /* ip packet */
{
+ u_int sctpPacketLengthRemaining;
const struct sctpHeader *sctpPktHdr;
const struct ip *ip;
-#ifdef INET6
const struct ip6_hdr *ip6;
-#endif
- const void *endPacketPtr;
u_short sourcePort, destPort;
int chunkCount;
const struct sctpChunkDesc *chunkDescPtr;
- const void *nextChunk;
const char *sep;
int isforces = 0;
-
- sctpPktHdr = (const struct sctpHeader*) bp;
- endPacketPtr = (const u_char*)sctpPktHdr+sctpPacketLength;
-
- if( (u_long) endPacketPtr > (u_long) snapend)
- endPacketPtr = (const void *) snapend;
- ip = (struct ip *)bp2;
-#ifdef INET6
- if (IP_V(ip) == 6)
- ip6 = (const struct ip6_hdr *)bp2;
- else
- ip6 = NULL;
-#endif /*INET6*/
- TCHECK(*sctpPktHdr);
-
if (sctpPacketLength < sizeof(struct sctpHeader))
{
- (void)printf("truncated-sctp - %ld bytes missing!",
- (long)sctpPacketLength-sizeof(struct sctpHeader));
+ ND_PRINT((ndo, "truncated-sctp - %ld bytes missing!",
+ (long)(sizeof(struct sctpHeader) - sctpPacketLength)));
return;
}
-
- /* sctpPacketLength -= sizeof(struct sctpHeader); packet length */
- /* is now only as long as the payload */
+ sctpPktHdr = (const struct sctpHeader*) bp;
+ ND_TCHECK(*sctpPktHdr);
+ sctpPacketLengthRemaining = sctpPacketLength;
sourcePort = EXTRACT_16BITS(&sctpPktHdr->source);
destPort = EXTRACT_16BITS(&sctpPktHdr->destination);
-#ifdef INET6
+ ip = (const struct ip *)bp2;
+ if (IP_V(ip) == 6)
+ ip6 = (const struct ip6_hdr *)bp2;
+ else
+ ip6 = NULL;
+
if (ip6) {
- (void)printf("%s.%d > %s.%d: sctp",
- ip6addr_string(&ip6->ip6_src),
+ ND_PRINT((ndo, "%s.%d > %s.%d: sctp",
+ ip6addr_string(ndo, &ip6->ip6_src),
sourcePort,
- ip6addr_string(&ip6->ip6_dst),
- destPort);
+ ip6addr_string(ndo, &ip6->ip6_dst),
+ destPort));
} else
-#endif /*INET6*/
{
- (void)printf("%s.%d > %s.%d: sctp",
- ipaddr_string(&ip->ip_src),
+ ND_PRINT((ndo, "%s.%d > %s.%d: sctp",
+ ipaddr_string(ndo, &ip->ip_src),
sourcePort,
- ipaddr_string(&ip->ip_dst),
- destPort);
+ ipaddr_string(ndo, &ip->ip_dst),
+ destPort));
}
- fflush(stdout);
if (isForCES_port(sourcePort)) {
- printf("[%s]", tok2str(ForCES_channels, NULL, sourcePort));
+ ND_PRINT((ndo, "[%s]", tok2str(ForCES_channels, NULL, sourcePort)));
isforces = 1;
}
if (isForCES_port(destPort)) {
- printf("[%s]", tok2str(ForCES_channels, NULL, destPort));
+ ND_PRINT((ndo, "[%s]", tok2str(ForCES_channels, NULL, destPort)));
isforces = 1;
}
- if (vflag >= 2)
+ bp += sizeof(struct sctpHeader);
+ sctpPacketLengthRemaining -= sizeof(struct sctpHeader);
+
+ if (ndo->ndo_vflag >= 2)
sep = "\n\t";
else
sep = " (";
/* cycle through all chunks, printing information on each one */
- for (chunkCount = 0,
- chunkDescPtr = (const struct sctpChunkDesc *)
- ((const u_char*) sctpPktHdr + sizeof(struct sctpHeader));
- chunkDescPtr != NULL &&
- ( (const void *)
- ((const u_char *) chunkDescPtr + sizeof(struct sctpChunkDesc))
- <= endPacketPtr);
-
- chunkDescPtr = (const struct sctpChunkDesc *) nextChunk, chunkCount++)
+ for (chunkCount = 0, chunkDescPtr = (const struct sctpChunkDesc *)bp;
+ sctpPacketLengthRemaining != 0;
+ chunkCount++)
{
- u_int16_t chunkLength;
- const u_char *chunkEnd;
- u_int16_t align;
+ uint16_t chunkLength, chunkLengthRemaining;
+ uint16_t align;
- TCHECK(*chunkDescPtr);
+ chunkDescPtr = (const struct sctpChunkDesc *)bp;
+ if (sctpPacketLengthRemaining < sizeof(*chunkDescPtr)) {
+ ND_PRINT((ndo, "%s%d) [chunk descriptor cut off at end of packet]", sep, chunkCount+1));
+ break;
+ }
+ ND_TCHECK(*chunkDescPtr);
chunkLength = EXTRACT_16BITS(&chunkDescPtr->chunkLength);
if (chunkLength < sizeof(*chunkDescPtr)) {
- printf("%s%d) [Bad chunk length %u]", sep, chunkCount+1, chunkLength);
- break;
+ ND_PRINT((ndo, "%s%d) [Bad chunk length %u, < size of chunk descriptor]", sep, chunkCount+1, chunkLength));
+ break;
}
+ chunkLengthRemaining = chunkLength;
- TCHECK2(*((u_int8_t *)chunkDescPtr), chunkLength);
- chunkEnd = ((const u_char*)chunkDescPtr + chunkLength);
-
- align=chunkLength % 4;
+ align = chunkLength % 4;
if (align != 0)
align = 4 - align;
- nextChunk = (const void *) (chunkEnd + align);
+ if (sctpPacketLengthRemaining < align) {
+ ND_PRINT((ndo, "%s%d) [Bad chunk length %u, > remaining data in packet]", sep, chunkCount+1, chunkLength));
+ break;
+ }
+
+ ND_TCHECK2(*bp, chunkLength);
+
+ bp += sizeof(*chunkDescPtr);
+ sctpPacketLengthRemaining -= sizeof(*chunkDescPtr);
+ chunkLengthRemaining -= sizeof(*chunkDescPtr);
- printf("%s%d) ", sep, chunkCount+1);
+ ND_PRINT((ndo, "%s%d) ", sep, chunkCount+1));
+ ND_PRINT((ndo, "[%s] ", tok2str(sctp_chunkid_str, "Unknown chunk type: 0x%x",
+ chunkDescPtr->chunkID)));
switch (chunkDescPtr->chunkID)
{
case SCTP_DATA :
{
const struct sctpDataPart *dataHdrPtr;
-
- printf("[DATA] ");
+ uint32_t ppid;
+ u_int payload_size;
if ((chunkDescPtr->chunkFlg & SCTP_DATA_UNORDERED)
== SCTP_DATA_UNORDERED)
- printf("(U)");
+ ND_PRINT((ndo, "(U)"));
if ((chunkDescPtr->chunkFlg & SCTP_DATA_FIRST_FRAG)
== SCTP_DATA_FIRST_FRAG)
- printf("(B)");
+ ND_PRINT((ndo, "(B)"));
if ((chunkDescPtr->chunkFlg & SCTP_DATA_LAST_FRAG)
== SCTP_DATA_LAST_FRAG)
- printf("(E)");
+ ND_PRINT((ndo, "(E)"));
if( ((chunkDescPtr->chunkFlg & SCTP_DATA_UNORDERED)
== SCTP_DATA_UNORDERED)
@@ -220,92 +627,113 @@ void sctp_print(const u_char *bp, /* beginning of sctp packet */
||
((chunkDescPtr->chunkFlg & SCTP_DATA_LAST_FRAG)
== SCTP_DATA_LAST_FRAG) )
- printf(" ");
-
- dataHdrPtr=(const struct sctpDataPart*)(chunkDescPtr+1);
+ ND_PRINT((ndo, " "));
+
+ if (chunkLengthRemaining < sizeof(*dataHdrPtr)) {
+ ND_PRINT((ndo, "bogus chunk length %u]", chunkLength));
+ return;
+ }
+ dataHdrPtr=(const struct sctpDataPart*)bp;
+
+ ppid = EXTRACT_32BITS(&dataHdrPtr->payloadtype);
+ ND_PRINT((ndo, "[TSN: %u] ", EXTRACT_32BITS(&dataHdrPtr->TSN)));
+ ND_PRINT((ndo, "[SID: %u] ", EXTRACT_16BITS(&dataHdrPtr->streamId)));
+ ND_PRINT((ndo, "[SSEQ %u] ", EXTRACT_16BITS(&dataHdrPtr->sequence)));
+ ND_PRINT((ndo, "[PPID %s] ",
+ tok2str(PayloadProto_idents, "0x%x", ppid)));
+
+ if (!isforces) {
+ isforces = (ppid == SCTP_PPID_FORCES_HP) ||
+ (ppid == SCTP_PPID_FORCES_MP) ||
+ (ppid == SCTP_PPID_FORCES_LP);
+ }
+
+ bp += sizeof(*dataHdrPtr);
+ sctpPacketLengthRemaining -= sizeof(*dataHdrPtr);
+ chunkLengthRemaining -= sizeof(*dataHdrPtr);
+ payload_size = chunkLengthRemaining;
+ if (payload_size == 0) {
+ ND_PRINT((ndo, "bogus chunk length %u]", chunkLength));
+ return;
+ }
- printf("[TSN: %u] ", EXTRACT_32BITS(&dataHdrPtr->TSN));
- printf("[SID: %u] ", EXTRACT_16BITS(&dataHdrPtr->streamId));
- printf("[SSEQ %u] ", EXTRACT_16BITS(&dataHdrPtr->sequence));
- printf("[PPID 0x%x] ", EXTRACT_32BITS(&dataHdrPtr->payloadtype));
- fflush(stdout);
if (isforces) {
- const u_char *payloadPtr;
- u_int chunksize = sizeof(struct sctpDataPart)+
- sizeof(struct sctpChunkDesc);
- payloadPtr = (const u_char *) (dataHdrPtr + 1);
- if (EXTRACT_16BITS(&chunkDescPtr->chunkLength) <
- sizeof(struct sctpDataPart)+
- sizeof(struct sctpChunkDesc)+1) {
- /* Less than 1 byte of chunk payload */
- printf("bogus ForCES chunk length %u]",
- EXTRACT_16BITS(&chunkDescPtr->chunkLength));
- return;
- }
-
- forces_print(payloadPtr, EXTRACT_16BITS(&chunkDescPtr->chunkLength)- chunksize);
- } else if (vflag >= 2) { /* if verbose output is specified */
+ forces_print(ndo, bp, payload_size);
+ } else if (ndo->ndo_vflag >= 2) { /* if verbose output is specified */
/* at the command line */
- const u_char *payloadPtr;
-
- printf("[Payload");
-
- if (!suppress_default_print) {
- payloadPtr = (const u_char *) (++dataHdrPtr);
- printf(":");
- if (EXTRACT_16BITS(&chunkDescPtr->chunkLength) <
- sizeof(struct sctpDataPart)+
- sizeof(struct sctpChunkDesc)+1) {
- /* Less than 1 byte of chunk payload */
- printf("bogus chunk length %u]",
- EXTRACT_16BITS(&chunkDescPtr->chunkLength));
- return;
+ switch (ppid) {
+ case SCTP_PPID_M3UA :
+ m3ua_print(ndo, bp, payload_size);
+ break;
+ default:
+ ND_PRINT((ndo, "[Payload"));
+ if (!ndo->ndo_suppress_default_print) {
+ ND_PRINT((ndo, ":"));
+ ND_DEFAULTPRINT(bp, payload_size);
}
- default_print(payloadPtr,
- EXTRACT_16BITS(&chunkDescPtr->chunkLength) -
- (sizeof(struct sctpDataPart)+
- sizeof(struct sctpChunkDesc)));
- } else
- printf("]");
- }
+ ND_PRINT((ndo, "]"));
+ break;
+ }
+ }
+ bp += payload_size;
+ sctpPacketLengthRemaining -= payload_size;
+ chunkLengthRemaining -= payload_size;
break;
}
case SCTP_INITIATION :
{
const struct sctpInitiation *init;
- printf("[INIT] ");
- init=(const struct sctpInitiation*)(chunkDescPtr+1);
- printf("[init tag: %u] ", EXTRACT_32BITS(&init->initTag));
- printf("[rwnd: %u] ", EXTRACT_32BITS(&init->rcvWindowCredit));
- printf("[OS: %u] ", EXTRACT_16BITS(&init->NumPreopenStreams));
- printf("[MIS: %u] ", EXTRACT_16BITS(&init->MaxInboundStreams));
- printf("[init TSN: %u] ", EXTRACT_32BITS(&init->initialTSN));
-
-#if(0) /* ALC you can add code for optional params here */
- if( (init+1) < chunkEnd )
- printf(" @@@@@ UNFINISHED @@@@@@%s\n",
- "Optional params present, but not printed.");
+ if (chunkLengthRemaining < sizeof(*init)) {
+ ND_PRINT((ndo, "bogus chunk length %u]", chunkLength));
+ return;
+ }
+ init=(const struct sctpInitiation*)bp;
+ ND_PRINT((ndo, "[init tag: %u] ", EXTRACT_32BITS(&init->initTag)));
+ ND_PRINT((ndo, "[rwnd: %u] ", EXTRACT_32BITS(&init->rcvWindowCredit)));
+ ND_PRINT((ndo, "[OS: %u] ", EXTRACT_16BITS(&init->NumPreopenStreams)));
+ ND_PRINT((ndo, "[MIS: %u] ", EXTRACT_16BITS(&init->MaxInboundStreams)));
+ ND_PRINT((ndo, "[init TSN: %u] ", EXTRACT_32BITS(&init->initialTSN)));
+ bp += sizeof(*init);
+ sctpPacketLengthRemaining -= sizeof(*init);
+ chunkLengthRemaining -= sizeof(*init);
+
+#if 0 /* ALC you can add code for optional params here */
+ if( chunkLengthRemaining != 0 )
+ ND_PRINT((ndo, " @@@@@ UNFINISHED @@@@@@%s\n",
+ "Optional params present, but not printed."));
#endif
+ bp += chunkLengthRemaining;
+ sctpPacketLengthRemaining -= chunkLengthRemaining;
+ chunkLengthRemaining = 0;
break;
}
case SCTP_INITIATION_ACK :
{
const struct sctpInitiation *init;
- printf("[INIT ACK] ");
- init=(const struct sctpInitiation*)(chunkDescPtr+1);
- printf("[init tag: %u] ", EXTRACT_32BITS(&init->initTag));
- printf("[rwnd: %u] ", EXTRACT_32BITS(&init->rcvWindowCredit));
- printf("[OS: %u] ", EXTRACT_16BITS(&init->NumPreopenStreams));
- printf("[MIS: %u] ", EXTRACT_16BITS(&init->MaxInboundStreams));
- printf("[init TSN: %u] ", EXTRACT_32BITS(&init->initialTSN));
-
-#if(0) /* ALC you can add code for optional params here */
- if( (init+1) < chunkEnd )
- printf(" @@@@@ UNFINISHED @@@@@@%s\n",
- "Optional params present, but not printed.");
+ if (chunkLengthRemaining < sizeof(*init)) {
+ ND_PRINT((ndo, "bogus chunk length %u]", chunkLength));
+ return;
+ }
+ init=(const struct sctpInitiation*)bp;
+ ND_PRINT((ndo, "[init tag: %u] ", EXTRACT_32BITS(&init->initTag)));
+ ND_PRINT((ndo, "[rwnd: %u] ", EXTRACT_32BITS(&init->rcvWindowCredit)));
+ ND_PRINT((ndo, "[OS: %u] ", EXTRACT_16BITS(&init->NumPreopenStreams)));
+ ND_PRINT((ndo, "[MIS: %u] ", EXTRACT_16BITS(&init->MaxInboundStreams)));
+ ND_PRINT((ndo, "[init TSN: %u] ", EXTRACT_32BITS(&init->initialTSN)));
+ bp += sizeof(*init);
+ sctpPacketLengthRemaining -= sizeof(*init);
+ chunkLengthRemaining -= sizeof(*init);
+
+#if 0 /* ALC you can add code for optional params here */
+ if( chunkLengthRemaining != 0 )
+ ND_PRINT((ndo, " @@@@@ UNFINISHED @@@@@@%s\n",
+ "Optional params present, but not printed."));
#endif
+ bp += chunkLengthRemaining;
+ sctpPacketLengthRemaining -= chunkLengthRemaining;
+ chunkLengthRemaining = 0;
break;
}
case SCTP_SELECTIVE_ACK:
@@ -315,95 +743,83 @@ void sctp_print(const u_char *bp, /* beginning of sctp packet */
int fragNo, tsnNo;
const u_char *dupTSN;
- printf("[SACK] ");
- sack=(const struct sctpSelectiveAck*)(chunkDescPtr+1);
- printf("[cum ack %u] ", EXTRACT_32BITS(&sack->highestConseqTSN));
- printf("[a_rwnd %u] ", EXTRACT_32BITS(&sack->updatedRwnd));
- printf("[#gap acks %u] ", EXTRACT_16BITS(&sack->numberOfdesc));
- printf("[#dup tsns %u] ", EXTRACT_16BITS(&sack->numDupTsns));
+ if (chunkLengthRemaining < sizeof(*sack)) {
+ ND_PRINT((ndo, "bogus chunk length %u]", chunkLength));
+ return;
+ }
+ sack=(const struct sctpSelectiveAck*)bp;
+ ND_PRINT((ndo, "[cum ack %u] ", EXTRACT_32BITS(&sack->highestConseqTSN)));
+ ND_PRINT((ndo, "[a_rwnd %u] ", EXTRACT_32BITS(&sack->updatedRwnd)));
+ ND_PRINT((ndo, "[#gap acks %u] ", EXTRACT_16BITS(&sack->numberOfdesc)));
+ ND_PRINT((ndo, "[#dup tsns %u] ", EXTRACT_16BITS(&sack->numDupTsns)));
+ bp += sizeof(*sack);
+ sctpPacketLengthRemaining -= sizeof(*sack);
+ chunkLengthRemaining -= sizeof(*sack);
/* print gaps */
- for (frag = ( (const struct sctpSelectiveFrag *)
- ((const struct sctpSelectiveAck *) sack+1)),
- fragNo=0;
- (const void *)frag < nextChunk && fragNo < EXTRACT_16BITS(&sack->numberOfdesc);
- frag++, fragNo++)
- printf("\n\t\t[gap ack block #%d: start = %u, end = %u] ",
+ for (fragNo=0;
+ chunkLengthRemaining != 0 && fragNo < EXTRACT_16BITS(&sack->numberOfdesc);
+ bp += sizeof(*frag), sctpPacketLengthRemaining -= sizeof(*frag), chunkLengthRemaining -= sizeof(*frag), fragNo++) {
+ if (chunkLengthRemaining < sizeof(*frag)) {
+ ND_PRINT((ndo, "bogus chunk length %u]", chunkLength));
+ return;
+ }
+ frag = (const struct sctpSelectiveFrag *)bp;
+ ND_PRINT((ndo, "\n\t\t[gap ack block #%d: start = %u, end = %u] ",
fragNo+1,
EXTRACT_32BITS(&sack->highestConseqTSN) + EXTRACT_16BITS(&frag->fragmentStart),
- EXTRACT_32BITS(&sack->highestConseqTSN) + EXTRACT_16BITS(&frag->fragmentEnd));
-
+ EXTRACT_32BITS(&sack->highestConseqTSN) + EXTRACT_16BITS(&frag->fragmentEnd)));
+ }
/* print duplicate TSNs */
- for (dupTSN = (const u_char *)frag, tsnNo=0;
- (const void *) dupTSN < nextChunk && tsnNo<EXTRACT_16BITS(&sack->numDupTsns);
- dupTSN += 4, tsnNo++)
- printf("\n\t\t[dup TSN #%u: %u] ", tsnNo+1,
- EXTRACT_32BITS(dupTSN));
-
+ for (tsnNo=0;
+ chunkLengthRemaining != 0 && tsnNo<EXTRACT_16BITS(&sack->numDupTsns);
+ bp += 4, sctpPacketLengthRemaining -= 4, chunkLengthRemaining -= 4, tsnNo++) {
+ if (chunkLengthRemaining < 4) {
+ ND_PRINT((ndo, "bogus chunk length %u]", chunkLength));
+ return;
+ }
+ dupTSN = (const u_char *)bp;
+ ND_PRINT((ndo, "\n\t\t[dup TSN #%u: %u] ", tsnNo+1,
+ EXTRACT_32BITS(dupTSN)));
+ }
break;
}
- case SCTP_HEARTBEAT_REQUEST :
+ default :
{
- const struct sctpHBsender *hb;
-
- hb=(const struct sctpHBsender*)chunkDescPtr;
-
- printf("[HB REQ] ");
-
+ bp += chunkLengthRemaining;
+ sctpPacketLengthRemaining -= chunkLengthRemaining;
+ chunkLengthRemaining = 0;
break;
}
- case SCTP_HEARTBEAT_ACK :
- printf("[HB ACK] ");
- break;
- case SCTP_ABORT_ASSOCIATION :
- printf("[ABORT] ");
- break;
- case SCTP_SHUTDOWN :
- printf("[SHUTDOWN] ");
- break;
- case SCTP_SHUTDOWN_ACK :
- printf("[SHUTDOWN ACK] ");
- break;
- case SCTP_OPERATION_ERR :
- printf("[OP ERR] ");
- break;
- case SCTP_COOKIE_ECHO :
- printf("[COOKIE ECHO] ");
- break;
- case SCTP_COOKIE_ACK :
- printf("[COOKIE ACK] ");
- break;
- case SCTP_ECN_ECHO :
- printf("[ECN ECHO] ");
- break;
- case SCTP_ECN_CWR :
- printf("[ECN CWR] ");
- break;
- case SCTP_SHUTDOWN_COMPLETE :
- printf("[SHUTDOWN COMPLETE] ");
- break;
- case SCTP_FORWARD_CUM_TSN :
- printf("[FOR CUM TSN] ");
- break;
- case SCTP_RELIABLE_CNTL :
- printf("[REL CTRL] ");
- break;
- case SCTP_RELIABLE_CNTL_ACK :
- printf("[REL CTRL ACK] ");
- break;
- default :
- printf("[Unknown chunk type: 0x%x]", chunkDescPtr->chunkID);
- return;
}
- if (vflag < 2)
- sep = ", (";
+ /*
+ * Any extra stuff at the end of the chunk?
+ * XXX - report this?
+ */
+ bp += chunkLengthRemaining;
+ sctpPacketLengthRemaining -= chunkLengthRemaining;
+
+ if (ndo->ndo_vflag < 2)
+ sep = ", (";
+
+ if (align != 0) {
+ /*
+ * Fail if the alignment padding isn't in the captured data.
+ * Otherwise, skip it.
+ */
+ ND_TCHECK2(*bp, align);
+ bp += align;
+ sctpPacketLengthRemaining -= align;
+ }
}
return;
trunc:
- printf("[|sctp]");
- return;
+ ND_PRINT((ndo, "[|sctp]"));
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-sctp-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-sflow.c b/freebsd/contrib/tcpdump/print-sflow.c
index a82f7e81..31d0d9ef 100644
--- a/freebsd/contrib/tcpdump/print-sflow.c
+++ b/freebsd/contrib/tcpdump/print-sflow.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1998-2007 The TCPDUMP project
*
@@ -14,35 +17,28 @@
* LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE.
*
- * The SFLOW protocol as per http://www.sflow.org/developers/specifications.php
- *
* Original code by Carles Kishimoto <carles.kishimoto@gmail.com>
*
* Expansion and refactoring by Rick Jones <rick.jones2@hp.com>
*/
-#ifndef lint
-static const char rcsid[] _U_ =
-"@(#) $Header: /tcpdump/master/tcpdump/print-sflow.c,v 1.1 2007-08-08 17:20:58 hannes Exp $";
-#endif
+/* \summary: sFlow protocol printer */
+
+/* specification: http://www.sflow.org/developers/specifications.php */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
#include "addrtoname.h"
-/*
+/*
* sFlow datagram
- *
+ *
* 0 1 2 3
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
@@ -60,22 +56,22 @@ static const char rcsid[] _U_ =
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | num samples in datagram |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- *
+ *
*/
struct sflow_datagram_t {
- u_int8_t version[4];
- u_int8_t ip_version[4];
- u_int8_t agent[4];
- u_int8_t agent_id[4];
- u_int8_t seqnum[4];
- u_int8_t uptime[4];
- u_int8_t samples[4];
+ uint8_t version[4];
+ uint8_t ip_version[4];
+ uint8_t agent[4];
+ uint8_t agent_id[4];
+ uint8_t seqnum[4];
+ uint8_t uptime[4];
+ uint8_t samples[4];
};
struct sflow_sample_header {
- u_int8_t format[4];
- u_int8_t len[4];
+ uint8_t format[4];
+ uint8_t len[4];
};
#define SFLOW_FLOW_SAMPLE 1
@@ -92,29 +88,29 @@ static const struct tok sflow_format_values[] = {
};
struct sflow_flow_sample_t {
- u_int8_t seqnum[4];
- u_int8_t typesource[4];
- u_int8_t rate[4];
- u_int8_t pool[4];
- u_int8_t drops[4];
- u_int8_t in_interface[4];
- u_int8_t out_interface[4];
- u_int8_t records[4];
+ uint8_t seqnum[4];
+ uint8_t typesource[4];
+ uint8_t rate[4];
+ uint8_t pool[4];
+ uint8_t drops[4];
+ uint8_t in_interface[4];
+ uint8_t out_interface[4];
+ uint8_t records[4];
};
struct sflow_expanded_flow_sample_t {
- u_int8_t seqnum[4];
- u_int8_t type[4];
- u_int8_t index[4];
- u_int8_t rate[4];
- u_int8_t pool[4];
- u_int8_t drops[4];
- u_int8_t in_interface_format[4];
- u_int8_t in_interface_value[4];
- u_int8_t out_interface_format[4];
- u_int8_t out_interface_value[4];
- u_int8_t records[4];
+ uint8_t seqnum[4];
+ uint8_t type[4];
+ uint8_t index[4];
+ uint8_t rate[4];
+ uint8_t pool[4];
+ uint8_t drops[4];
+ uint8_t in_interface_format[4];
+ uint8_t in_interface_value[4];
+ uint8_t out_interface_format[4];
+ uint8_t out_interface_value[4];
+ uint8_t records[4];
};
#define SFLOW_FLOW_RAW_PACKET 1
@@ -164,49 +160,49 @@ static const struct tok sflow_flow_raw_protocol_values[] = {
{ SFLOW_HEADER_PROTOCOL_IPV6, "IPv6"},
{ 0, NULL}
};
-
+
struct sflow_expanded_flow_raw_t {
- u_int8_t protocol[4];
- u_int8_t length[4];
- u_int8_t stripped_bytes[4];
- u_int8_t header_size[4];
+ uint8_t protocol[4];
+ uint8_t length[4];
+ uint8_t stripped_bytes[4];
+ uint8_t header_size[4];
};
struct sflow_ethernet_frame_t {
- u_int8_t length[4];
- u_int8_t src_mac[8];
- u_int8_t dst_mac[8];
- u_int8_t type[4];
+ uint8_t length[4];
+ uint8_t src_mac[8];
+ uint8_t dst_mac[8];
+ uint8_t type[4];
};
struct sflow_extended_switch_data_t {
- u_int8_t src_vlan[4];
- u_int8_t src_pri[4];
- u_int8_t dst_vlan[4];
- u_int8_t dst_pri[4];
+ uint8_t src_vlan[4];
+ uint8_t src_pri[4];
+ uint8_t dst_vlan[4];
+ uint8_t dst_pri[4];
};
struct sflow_counter_record_t {
- u_int8_t format[4];
- u_int8_t length[4];
+ uint8_t format[4];
+ uint8_t length[4];
};
struct sflow_flow_record_t {
- u_int8_t format[4];
- u_int8_t length[4];
+ uint8_t format[4];
+ uint8_t length[4];
};
struct sflow_counter_sample_t {
- u_int8_t seqnum[4];
- u_int8_t typesource[4];
- u_int8_t records[4];
+ uint8_t seqnum[4];
+ uint8_t typesource[4];
+ uint8_t records[4];
};
struct sflow_expanded_counter_sample_t {
- u_int8_t seqnum[4];
- u_int8_t type[4];
- u_int8_t index[4];
- u_int8_t records[4];
+ uint8_t seqnum[4];
+ uint8_t type[4];
+ uint8_t index[4];
+ uint8_t records[4];
};
#define SFLOW_COUNTER_GENERIC 1
@@ -239,239 +235,265 @@ static const struct tok sflow_iface_direction_values[] = {
{ SFLOW_IFACE_DIRECTION_IN, "in"},
{ SFLOW_IFACE_DIRECTION_OUT, "out"},
{ 0, NULL}
-};
+};
struct sflow_generic_counter_t {
- u_int8_t ifindex[4];
- u_int8_t iftype[4];
- u_int8_t ifspeed[8];
- u_int8_t ifdirection[4];
- u_int8_t ifstatus[4];
- u_int8_t ifinoctets[8];
- u_int8_t ifinunicastpkts[4];
- u_int8_t ifinmulticastpkts[4];
- u_int8_t ifinbroadcastpkts[4];
- u_int8_t ifindiscards[4];
- u_int8_t ifinerrors[4];
- u_int8_t ifinunkownprotos[4];
- u_int8_t ifoutoctets[8];
- u_int8_t ifoutunicastpkts[4];
- u_int8_t ifoutmulticastpkts[4];
- u_int8_t ifoutbroadcastpkts[4];
- u_int8_t ifoutdiscards[4];
- u_int8_t ifouterrors[4];
- u_int8_t ifpromiscmode[4];
+ uint8_t ifindex[4];
+ uint8_t iftype[4];
+ uint8_t ifspeed[8];
+ uint8_t ifdirection[4];
+ uint8_t ifstatus[4];
+ uint8_t ifinoctets[8];
+ uint8_t ifinunicastpkts[4];
+ uint8_t ifinmulticastpkts[4];
+ uint8_t ifinbroadcastpkts[4];
+ uint8_t ifindiscards[4];
+ uint8_t ifinerrors[4];
+ uint8_t ifinunkownprotos[4];
+ uint8_t ifoutoctets[8];
+ uint8_t ifoutunicastpkts[4];
+ uint8_t ifoutmulticastpkts[4];
+ uint8_t ifoutbroadcastpkts[4];
+ uint8_t ifoutdiscards[4];
+ uint8_t ifouterrors[4];
+ uint8_t ifpromiscmode[4];
};
struct sflow_ethernet_counter_t {
- u_int8_t alignerrors[4];
- u_int8_t fcserrors[4];
- u_int8_t single_collision_frames[4];
- u_int8_t multiple_collision_frames[4];
- u_int8_t test_errors[4];
- u_int8_t deferred_transmissions[4];
- u_int8_t late_collisions[4];
- u_int8_t excessive_collisions[4];
- u_int8_t mac_transmit_errors[4];
- u_int8_t carrier_sense_errors[4];
- u_int8_t frame_too_longs[4];
- u_int8_t mac_receive_errors[4];
- u_int8_t symbol_errors[4];
+ uint8_t alignerrors[4];
+ uint8_t fcserrors[4];
+ uint8_t single_collision_frames[4];
+ uint8_t multiple_collision_frames[4];
+ uint8_t test_errors[4];
+ uint8_t deferred_transmissions[4];
+ uint8_t late_collisions[4];
+ uint8_t excessive_collisions[4];
+ uint8_t mac_transmit_errors[4];
+ uint8_t carrier_sense_errors[4];
+ uint8_t frame_too_longs[4];
+ uint8_t mac_receive_errors[4];
+ uint8_t symbol_errors[4];
};
struct sflow_100basevg_counter_t {
- u_int8_t in_highpriority_frames[4];
- u_int8_t in_highpriority_octets[8];
- u_int8_t in_normpriority_frames[4];
- u_int8_t in_normpriority_octets[8];
- u_int8_t in_ipmerrors[4];
- u_int8_t in_oversized[4];
- u_int8_t in_data_errors[4];
- u_int8_t in_null_addressed_frames[4];
- u_int8_t out_highpriority_frames[4];
- u_int8_t out_highpriority_octets[8];
- u_int8_t transitioninto_frames[4];
- u_int8_t hc_in_highpriority_octets[8];
- u_int8_t hc_in_normpriority_octets[8];
- u_int8_t hc_out_highpriority_octets[8];
+ uint8_t in_highpriority_frames[4];
+ uint8_t in_highpriority_octets[8];
+ uint8_t in_normpriority_frames[4];
+ uint8_t in_normpriority_octets[8];
+ uint8_t in_ipmerrors[4];
+ uint8_t in_oversized[4];
+ uint8_t in_data_errors[4];
+ uint8_t in_null_addressed_frames[4];
+ uint8_t out_highpriority_frames[4];
+ uint8_t out_highpriority_octets[8];
+ uint8_t transitioninto_frames[4];
+ uint8_t hc_in_highpriority_octets[8];
+ uint8_t hc_in_normpriority_octets[8];
+ uint8_t hc_out_highpriority_octets[8];
};
struct sflow_vlan_counter_t {
- u_int8_t vlan_id[4];
- u_int8_t octets[8];
- u_int8_t unicast_pkt[4];
- u_int8_t multicast_pkt[4];
- u_int8_t broadcast_pkt[4];
- u_int8_t discards[4];
+ uint8_t vlan_id[4];
+ uint8_t octets[8];
+ uint8_t unicast_pkt[4];
+ uint8_t multicast_pkt[4];
+ uint8_t broadcast_pkt[4];
+ uint8_t discards[4];
};
static int
-print_sflow_counter_generic(const u_char *pointer, u_int len) {
-
+print_sflow_counter_generic(netdissect_options *ndo,
+ const u_char *pointer, u_int len)
+{
const struct sflow_generic_counter_t *sflow_gen_counter;
if (len < sizeof(struct sflow_generic_counter_t))
return 1;
-
sflow_gen_counter = (const struct sflow_generic_counter_t *)pointer;
- printf("\n\t ifindex %u, iftype %u, ifspeed %" PRIu64 ", ifdirection %u (%s)",
+ ND_TCHECK(*sflow_gen_counter);
+ ND_PRINT((ndo, "\n\t ifindex %u, iftype %u, ifspeed %" PRIu64 ", ifdirection %u (%s)",
EXTRACT_32BITS(sflow_gen_counter->ifindex),
EXTRACT_32BITS(sflow_gen_counter->iftype),
EXTRACT_64BITS(sflow_gen_counter->ifspeed),
EXTRACT_32BITS(sflow_gen_counter->ifdirection),
tok2str(sflow_iface_direction_values, "Unknown",
- EXTRACT_32BITS(sflow_gen_counter->ifdirection)));
- printf("\n\t ifstatus %u, adminstatus: %s, operstatus: %s",
+ EXTRACT_32BITS(sflow_gen_counter->ifdirection))));
+ ND_PRINT((ndo, "\n\t ifstatus %u, adminstatus: %s, operstatus: %s",
EXTRACT_32BITS(sflow_gen_counter->ifstatus),
EXTRACT_32BITS(sflow_gen_counter->ifstatus)&1 ? "up" : "down",
- (EXTRACT_32BITS(sflow_gen_counter->ifstatus)>>1)&1 ? "up" : "down");
- printf("\n\t In octets %" PRIu64
+ (EXTRACT_32BITS(sflow_gen_counter->ifstatus)>>1)&1 ? "up" : "down"));
+ ND_PRINT((ndo, "\n\t In octets %" PRIu64
", unicast pkts %u, multicast pkts %u, broadcast pkts %u, discards %u",
EXTRACT_64BITS(sflow_gen_counter->ifinoctets),
EXTRACT_32BITS(sflow_gen_counter->ifinunicastpkts),
EXTRACT_32BITS(sflow_gen_counter->ifinmulticastpkts),
EXTRACT_32BITS(sflow_gen_counter->ifinbroadcastpkts),
- EXTRACT_32BITS(sflow_gen_counter->ifindiscards));
- printf("\n\t In errors %u, unknown protos %u",
+ EXTRACT_32BITS(sflow_gen_counter->ifindiscards)));
+ ND_PRINT((ndo, "\n\t In errors %u, unknown protos %u",
EXTRACT_32BITS(sflow_gen_counter->ifinerrors),
- EXTRACT_32BITS(sflow_gen_counter->ifinunkownprotos));
- printf("\n\t Out octets %" PRIu64
+ EXTRACT_32BITS(sflow_gen_counter->ifinunkownprotos)));
+ ND_PRINT((ndo, "\n\t Out octets %" PRIu64
", unicast pkts %u, multicast pkts %u, broadcast pkts %u, discards %u",
EXTRACT_64BITS(sflow_gen_counter->ifoutoctets),
EXTRACT_32BITS(sflow_gen_counter->ifoutunicastpkts),
EXTRACT_32BITS(sflow_gen_counter->ifoutmulticastpkts),
EXTRACT_32BITS(sflow_gen_counter->ifoutbroadcastpkts),
- EXTRACT_32BITS(sflow_gen_counter->ifoutdiscards));
- printf("\n\t Out errors %u, promisc mode %u",
+ EXTRACT_32BITS(sflow_gen_counter->ifoutdiscards)));
+ ND_PRINT((ndo, "\n\t Out errors %u, promisc mode %u",
EXTRACT_32BITS(sflow_gen_counter->ifouterrors),
- EXTRACT_32BITS(sflow_gen_counter->ifpromiscmode));
+ EXTRACT_32BITS(sflow_gen_counter->ifpromiscmode)));
return 0;
+
+trunc:
+ return 1;
}
static int
-print_sflow_counter_ethernet(const u_char *pointer, u_int len){
-
+print_sflow_counter_ethernet(netdissect_options *ndo,
+ const u_char *pointer, u_int len)
+{
const struct sflow_ethernet_counter_t *sflow_eth_counter;
if (len < sizeof(struct sflow_ethernet_counter_t))
return 1;
sflow_eth_counter = (const struct sflow_ethernet_counter_t *)pointer;
- printf("\n\t align errors %u, fcs errors %u, single collision %u, multiple collision %u, test error %u",
+ ND_TCHECK(*sflow_eth_counter);
+ ND_PRINT((ndo, "\n\t align errors %u, fcs errors %u, single collision %u, multiple collision %u, test error %u",
EXTRACT_32BITS(sflow_eth_counter->alignerrors),
EXTRACT_32BITS(sflow_eth_counter->fcserrors),
EXTRACT_32BITS(sflow_eth_counter->single_collision_frames),
EXTRACT_32BITS(sflow_eth_counter->multiple_collision_frames),
- EXTRACT_32BITS(sflow_eth_counter->test_errors));
- printf("\n\t deferred %u, late collision %u, excessive collision %u, mac trans error %u",
+ EXTRACT_32BITS(sflow_eth_counter->test_errors)));
+ ND_PRINT((ndo, "\n\t deferred %u, late collision %u, excessive collision %u, mac trans error %u",
EXTRACT_32BITS(sflow_eth_counter->deferred_transmissions),
EXTRACT_32BITS(sflow_eth_counter->late_collisions),
EXTRACT_32BITS(sflow_eth_counter->excessive_collisions),
- EXTRACT_32BITS(sflow_eth_counter->mac_transmit_errors));
- printf("\n\t carrier error %u, frames too long %u, mac receive errors %u, symbol errors %u",
+ EXTRACT_32BITS(sflow_eth_counter->mac_transmit_errors)));
+ ND_PRINT((ndo, "\n\t carrier error %u, frames too long %u, mac receive errors %u, symbol errors %u",
EXTRACT_32BITS(sflow_eth_counter->carrier_sense_errors),
EXTRACT_32BITS(sflow_eth_counter->frame_too_longs),
EXTRACT_32BITS(sflow_eth_counter->mac_receive_errors),
- EXTRACT_32BITS(sflow_eth_counter->symbol_errors));
+ EXTRACT_32BITS(sflow_eth_counter->symbol_errors)));
return 0;
+
+trunc:
+ return 1;
}
static int
-print_sflow_counter_token_ring(const u_char *pointer _U_, u_int len _U_) {
-
+print_sflow_counter_token_ring(netdissect_options *ndo _U_,
+ const u_char *pointer _U_, u_int len _U_)
+{
return 0;
}
static int
-print_sflow_counter_basevg(const u_char *pointer, u_int len) {
-
+print_sflow_counter_basevg(netdissect_options *ndo,
+ const u_char *pointer, u_int len)
+{
const struct sflow_100basevg_counter_t *sflow_100basevg_counter;
if (len < sizeof(struct sflow_100basevg_counter_t))
return 1;
sflow_100basevg_counter = (const struct sflow_100basevg_counter_t *)pointer;
- printf("\n\t in high prio frames %u, in high prio octets %" PRIu64,
+ ND_TCHECK(*sflow_100basevg_counter);
+ ND_PRINT((ndo, "\n\t in high prio frames %u, in high prio octets %" PRIu64,
EXTRACT_32BITS(sflow_100basevg_counter->in_highpriority_frames),
- EXTRACT_64BITS(sflow_100basevg_counter->in_highpriority_octets));
- printf("\n\t in norm prio frames %u, in norm prio octets %" PRIu64,
+ EXTRACT_64BITS(sflow_100basevg_counter->in_highpriority_octets)));
+ ND_PRINT((ndo, "\n\t in norm prio frames %u, in norm prio octets %" PRIu64,
EXTRACT_32BITS(sflow_100basevg_counter->in_normpriority_frames),
- EXTRACT_64BITS(sflow_100basevg_counter->in_normpriority_octets));
- printf("\n\t in ipm errors %u, oversized %u, in data errors %u, null addressed frames %u",
+ EXTRACT_64BITS(sflow_100basevg_counter->in_normpriority_octets)));
+ ND_PRINT((ndo, "\n\t in ipm errors %u, oversized %u, in data errors %u, null addressed frames %u",
EXTRACT_32BITS(sflow_100basevg_counter->in_ipmerrors),
EXTRACT_32BITS(sflow_100basevg_counter->in_oversized),
EXTRACT_32BITS(sflow_100basevg_counter->in_data_errors),
- EXTRACT_32BITS(sflow_100basevg_counter->in_null_addressed_frames));
- printf("\n\t out high prio frames %u, out high prio octets %" PRIu64
+ EXTRACT_32BITS(sflow_100basevg_counter->in_null_addressed_frames)));
+ ND_PRINT((ndo, "\n\t out high prio frames %u, out high prio octets %" PRIu64
", trans into frames %u",
EXTRACT_32BITS(sflow_100basevg_counter->out_highpriority_frames),
EXTRACT_64BITS(sflow_100basevg_counter->out_highpriority_octets),
- EXTRACT_32BITS(sflow_100basevg_counter->transitioninto_frames));
- printf("\n\t in hc high prio octets %" PRIu64
+ EXTRACT_32BITS(sflow_100basevg_counter->transitioninto_frames)));
+ ND_PRINT((ndo, "\n\t in hc high prio octets %" PRIu64
", in hc norm prio octets %" PRIu64
", out hc high prio octets %" PRIu64,
EXTRACT_64BITS(sflow_100basevg_counter->hc_in_highpriority_octets),
EXTRACT_64BITS(sflow_100basevg_counter->hc_in_normpriority_octets),
- EXTRACT_64BITS(sflow_100basevg_counter->hc_out_highpriority_octets));
+ EXTRACT_64BITS(sflow_100basevg_counter->hc_out_highpriority_octets)));
return 0;
+
+trunc:
+ return 1;
}
static int
-print_sflow_counter_vlan(const u_char *pointer, u_int len) {
-
+print_sflow_counter_vlan(netdissect_options *ndo,
+ const u_char *pointer, u_int len)
+{
const struct sflow_vlan_counter_t *sflow_vlan_counter;
-
+
if (len < sizeof(struct sflow_vlan_counter_t))
return 1;
sflow_vlan_counter = (const struct sflow_vlan_counter_t *)pointer;
- printf("\n\t vlan_id %u, octets %" PRIu64
+ ND_TCHECK(*sflow_vlan_counter);
+ ND_PRINT((ndo, "\n\t vlan_id %u, octets %" PRIu64
", unicast_pkt %u, multicast_pkt %u, broadcast_pkt %u, discards %u",
EXTRACT_32BITS(sflow_vlan_counter->vlan_id),
EXTRACT_64BITS(sflow_vlan_counter->octets),
EXTRACT_32BITS(sflow_vlan_counter->unicast_pkt),
EXTRACT_32BITS(sflow_vlan_counter->multicast_pkt),
EXTRACT_32BITS(sflow_vlan_counter->broadcast_pkt),
- EXTRACT_32BITS(sflow_vlan_counter->discards));
+ EXTRACT_32BITS(sflow_vlan_counter->discards)));
return 0;
+
+trunc:
+ return 1;
}
struct sflow_processor_counter_t {
- u_int8_t five_sec_util[4];
- u_int8_t one_min_util[4];
- u_int8_t five_min_util[4];
- u_int8_t total_memory[8];
- u_int8_t free_memory[8];
+ uint8_t five_sec_util[4];
+ uint8_t one_min_util[4];
+ uint8_t five_min_util[4];
+ uint8_t total_memory[8];
+ uint8_t free_memory[8];
};
static int
-print_sflow_counter_processor(const u_char *pointer, u_int len) {
-
+print_sflow_counter_processor(netdissect_options *ndo,
+ const u_char *pointer, u_int len)
+{
const struct sflow_processor_counter_t *sflow_processor_counter;
if (len < sizeof(struct sflow_processor_counter_t))
return 1;
sflow_processor_counter = (const struct sflow_processor_counter_t *)pointer;
- printf("\n\t 5sec %u, 1min %u, 5min %u, total_mem %" PRIu64
+ ND_TCHECK(*sflow_processor_counter);
+ ND_PRINT((ndo, "\n\t 5sec %u, 1min %u, 5min %u, total_mem %" PRIu64
", total_mem %" PRIu64,
EXTRACT_32BITS(sflow_processor_counter->five_sec_util),
EXTRACT_32BITS(sflow_processor_counter->one_min_util),
EXTRACT_32BITS(sflow_processor_counter->five_min_util),
EXTRACT_64BITS(sflow_processor_counter->total_memory),
- EXTRACT_64BITS(sflow_processor_counter->free_memory));
+ EXTRACT_64BITS(sflow_processor_counter->free_memory)));
return 0;
+
+trunc:
+ return 1;
}
static int
-sflow_print_counter_records(const u_char *pointer, u_int len, u_int records) {
-
+sflow_print_counter_records(netdissect_options *ndo,
+ const u_char *pointer, u_int len, u_int records)
+{
u_int nrecords;
const u_char *tptr;
u_int tlen;
@@ -489,16 +511,17 @@ sflow_print_counter_records(const u_char *pointer, u_int len, u_int records) {
if (tlen < sizeof(struct sflow_counter_record_t))
return 1;
sflow_counter_record = (const struct sflow_counter_record_t *)tptr;
+ ND_TCHECK(*sflow_counter_record);
enterprise = EXTRACT_32BITS(sflow_counter_record->format);
counter_type = enterprise & 0x0FFF;
enterprise = enterprise >> 20;
counter_len = EXTRACT_32BITS(sflow_counter_record->length);
- printf("\n\t enterprise %u, %s (%u) length %u",
+ ND_PRINT((ndo, "\n\t enterprise %u, %s (%u) length %u",
enterprise,
(enterprise == 0) ? tok2str(sflow_counter_type_values,"Unknown",counter_type) : "Unknown",
counter_type,
- counter_len);
+ counter_len));
tptr += sizeof(struct sflow_counter_record_t);
tlen -= sizeof(struct sflow_counter_record_t);
@@ -508,80 +531,86 @@ sflow_print_counter_records(const u_char *pointer, u_int len, u_int records) {
if (enterprise == 0) {
switch (counter_type) {
case SFLOW_COUNTER_GENERIC:
- if (print_sflow_counter_generic(tptr,tlen))
+ if (print_sflow_counter_generic(ndo, tptr, tlen))
return 1;
break;
case SFLOW_COUNTER_ETHERNET:
- if (print_sflow_counter_ethernet(tptr,tlen))
+ if (print_sflow_counter_ethernet(ndo, tptr, tlen))
return 1;
break;
case SFLOW_COUNTER_TOKEN_RING:
- if (print_sflow_counter_token_ring(tptr,tlen))
+ if (print_sflow_counter_token_ring(ndo, tptr,tlen))
return 1;
break;
case SFLOW_COUNTER_BASEVG:
- if (print_sflow_counter_basevg(tptr,tlen))
+ if (print_sflow_counter_basevg(ndo, tptr, tlen))
return 1;
break;
case SFLOW_COUNTER_VLAN:
- if (print_sflow_counter_vlan(tptr,tlen))
+ if (print_sflow_counter_vlan(ndo, tptr, tlen))
return 1;
break;
case SFLOW_COUNTER_PROCESSOR:
- if (print_sflow_counter_processor(tptr,tlen))
+ if (print_sflow_counter_processor(ndo, tptr, tlen))
return 1;
break;
default:
- if (vflag <= 1)
- print_unknown_data(tptr, "\n\t\t", counter_len);
+ if (ndo->ndo_vflag <= 1)
+ print_unknown_data(ndo, tptr, "\n\t\t", counter_len);
break;
}
}
tptr += counter_len;
tlen -= counter_len;
nrecords--;
-
+
}
return 0;
-}
+trunc:
+ return 1;
+}
static int
-sflow_print_counter_sample(const u_char *pointer, u_int len) {
-
+sflow_print_counter_sample(netdissect_options *ndo,
+ const u_char *pointer, u_int len)
+{
const struct sflow_counter_sample_t *sflow_counter_sample;
u_int nrecords;
u_int typesource;
u_int type;
u_int index;
-
if (len < sizeof(struct sflow_counter_sample_t))
return 1;
sflow_counter_sample = (const struct sflow_counter_sample_t *)pointer;
+ ND_TCHECK(*sflow_counter_sample);
typesource = EXTRACT_32BITS(sflow_counter_sample->typesource);
nrecords = EXTRACT_32BITS(sflow_counter_sample->records);
type = typesource >> 24;
index = typesource & 0x0FFF;
-
- printf(" seqnum %u, type %u, idx %u, records %u",
+
+ ND_PRINT((ndo, " seqnum %u, type %u, idx %u, records %u",
EXTRACT_32BITS(sflow_counter_sample->seqnum),
type,
index,
- nrecords);
+ nrecords));
- return sflow_print_counter_records(pointer + sizeof(struct sflow_counter_sample_t),
+ return sflow_print_counter_records(ndo, pointer + sizeof(struct sflow_counter_sample_t),
len - sizeof(struct sflow_counter_sample_t),
nrecords);
+trunc:
+ return 1;
}
static int
-sflow_print_expanded_counter_sample(const u_char *pointer, u_int len) {
-
+sflow_print_expanded_counter_sample(netdissect_options *ndo,
+ const u_char *pointer, u_int len)
+{
const struct sflow_expanded_counter_sample_t *sflow_expanded_counter_sample;
u_int nrecords;
@@ -590,81 +619,100 @@ sflow_print_expanded_counter_sample(const u_char *pointer, u_int len) {
return 1;
sflow_expanded_counter_sample = (const struct sflow_expanded_counter_sample_t *)pointer;
+ ND_TCHECK(*sflow_expanded_counter_sample);
nrecords = EXTRACT_32BITS(sflow_expanded_counter_sample->records);
- printf(" seqnum %u, type %u, idx %u, records %u",
+ ND_PRINT((ndo, " seqnum %u, type %u, idx %u, records %u",
EXTRACT_32BITS(sflow_expanded_counter_sample->seqnum),
EXTRACT_32BITS(sflow_expanded_counter_sample->type),
EXTRACT_32BITS(sflow_expanded_counter_sample->index),
- nrecords);
-
- return sflow_print_counter_records(pointer + sizeof(struct sflow_expanded_counter_sample_t),
+ nrecords));
+
+ return sflow_print_counter_records(ndo, pointer + sizeof(struct sflow_expanded_counter_sample_t),
len - sizeof(struct sflow_expanded_counter_sample_t),
nrecords);
+trunc:
+ return 1;
}
static int
-print_sflow_raw_packet(const u_char *pointer, u_int len) {
-
+print_sflow_raw_packet(netdissect_options *ndo,
+ const u_char *pointer, u_int len)
+{
const struct sflow_expanded_flow_raw_t *sflow_flow_raw;
if (len < sizeof(struct sflow_expanded_flow_raw_t))
return 1;
sflow_flow_raw = (const struct sflow_expanded_flow_raw_t *)pointer;
- printf("\n\t protocol %s (%u), length %u, stripped bytes %u, header_size %u",
+ ND_TCHECK(*sflow_flow_raw);
+ ND_PRINT((ndo, "\n\t protocol %s (%u), length %u, stripped bytes %u, header_size %u",
tok2str(sflow_flow_raw_protocol_values,"Unknown",EXTRACT_32BITS(sflow_flow_raw->protocol)),
EXTRACT_32BITS(sflow_flow_raw->protocol),
EXTRACT_32BITS(sflow_flow_raw->length),
EXTRACT_32BITS(sflow_flow_raw->stripped_bytes),
- EXTRACT_32BITS(sflow_flow_raw->header_size));
+ EXTRACT_32BITS(sflow_flow_raw->header_size)));
/* QUESTION - should we attempt to print the raw header itself?
assuming of course there is wnough data present to do so... */
return 0;
+
+trunc:
+ return 1;
}
static int
-print_sflow_ethernet_frame(const u_char *pointer, u_int len) {
-
+print_sflow_ethernet_frame(netdissect_options *ndo,
+ const u_char *pointer, u_int len)
+{
const struct sflow_ethernet_frame_t *sflow_ethernet_frame;
if (len < sizeof(struct sflow_ethernet_frame_t))
return 1;
sflow_ethernet_frame = (const struct sflow_ethernet_frame_t *)pointer;
+ ND_TCHECK(*sflow_ethernet_frame);
- printf("\n\t frame len %u, type %u",
+ ND_PRINT((ndo, "\n\t frame len %u, type %u",
EXTRACT_32BITS(sflow_ethernet_frame->length),
- EXTRACT_32BITS(sflow_ethernet_frame->type));
+ EXTRACT_32BITS(sflow_ethernet_frame->type)));
return 0;
+
+trunc:
+ return 1;
}
static int
-print_sflow_extended_switch_data(const u_char *pointer, u_int len) {
-
+print_sflow_extended_switch_data(netdissect_options *ndo,
+ const u_char *pointer, u_int len)
+{
const struct sflow_extended_switch_data_t *sflow_extended_sw_data;
if (len < sizeof(struct sflow_extended_switch_data_t))
return 1;
sflow_extended_sw_data = (const struct sflow_extended_switch_data_t *)pointer;
- printf("\n\t src vlan %u, src pri %u, dst vlan %u, dst pri %u",
+ ND_TCHECK(*sflow_extended_sw_data);
+ ND_PRINT((ndo, "\n\t src vlan %u, src pri %u, dst vlan %u, dst pri %u",
EXTRACT_32BITS(sflow_extended_sw_data->src_vlan),
EXTRACT_32BITS(sflow_extended_sw_data->src_pri),
EXTRACT_32BITS(sflow_extended_sw_data->dst_vlan),
- EXTRACT_32BITS(sflow_extended_sw_data->dst_pri));
+ EXTRACT_32BITS(sflow_extended_sw_data->dst_pri)));
return 0;
+
+trunc:
+ return 1;
}
static int
-sflow_print_flow_records(const u_char *pointer, u_int len, u_int records) {
-
+sflow_print_flow_records(netdissect_options *ndo,
+ const u_char *pointer, u_int len, u_int records)
+{
u_int nrecords;
const u_char *tptr;
u_int tlen;
@@ -683,19 +731,20 @@ sflow_print_flow_records(const u_char *pointer, u_int len, u_int records) {
return 1;
sflow_flow_record = (const struct sflow_flow_record_t *)tptr;
+ ND_TCHECK(*sflow_flow_record);
/* so, the funky encoding means we cannot blythly mask-off
bits, we must also check the enterprise. */
-
+
enterprise = EXTRACT_32BITS(sflow_flow_record->format);
flow_type = enterprise & 0x0FFF;
enterprise = enterprise >> 12;
flow_len = EXTRACT_32BITS(sflow_flow_record->length);
- printf("\n\t enterprise %u %s (%u) length %u",
+ ND_PRINT((ndo, "\n\t enterprise %u %s (%u) length %u",
enterprise,
(enterprise == 0) ? tok2str(sflow_flow_type_values,"Unknown",flow_type) : "Unknown",
flow_type,
- flow_len);
+ flow_len));
tptr += sizeof(struct sflow_flow_record_t);
tlen -= sizeof(struct sflow_flow_record_t);
@@ -706,15 +755,15 @@ sflow_print_flow_records(const u_char *pointer, u_int len, u_int records) {
if (enterprise == 0) {
switch (flow_type) {
case SFLOW_FLOW_RAW_PACKET:
- if (print_sflow_raw_packet(tptr,tlen))
+ if (print_sflow_raw_packet(ndo, tptr, tlen))
return 1;
break;
case SFLOW_FLOW_EXTENDED_SWITCH_DATA:
- if (print_sflow_extended_switch_data(tptr,tlen))
+ if (print_sflow_extended_switch_data(ndo, tptr, tlen))
return 1;
break;
case SFLOW_FLOW_ETHERNET_FRAME:
- if (print_sflow_ethernet_frame(tptr,tlen))
+ if (print_sflow_ethernet_frame(ndo, tptr, tlen))
return 1;
break;
/* FIXME these need a decoder */
@@ -733,8 +782,8 @@ sflow_print_flow_records(const u_char *pointer, u_int len, u_int records) {
case SFLOW_FLOW_EXTENDED_VLAN_TUNNEL:
break;
default:
- if (vflag <= 1)
- print_unknown_data(tptr, "\n\t\t", flow_len);
+ if (ndo->ndo_vflag <= 1)
+ print_unknown_data(ndo, tptr, "\n\t\t", flow_len);
break;
}
}
@@ -745,11 +794,15 @@ sflow_print_flow_records(const u_char *pointer, u_int len, u_int records) {
}
return 0;
+
+trunc:
+ return 1;
}
static int
-sflow_print_flow_sample(const u_char *pointer, u_int len) {
-
+sflow_print_flow_sample(netdissect_options *ndo,
+ const u_char *pointer, u_int len)
+{
const struct sflow_flow_sample_t *sflow_flow_sample;
u_int nrecords;
u_int typesource;
@@ -759,14 +812,15 @@ sflow_print_flow_sample(const u_char *pointer, u_int len) {
if (len < sizeof(struct sflow_flow_sample_t))
return 1;
- sflow_flow_sample = (struct sflow_flow_sample_t *)pointer;
+ sflow_flow_sample = (const struct sflow_flow_sample_t *)pointer;
+ ND_TCHECK(*sflow_flow_sample);
typesource = EXTRACT_32BITS(sflow_flow_sample->typesource);
nrecords = EXTRACT_32BITS(sflow_flow_sample->records);
type = typesource >> 24;
index = typesource & 0x0FFF;
- printf(" seqnum %u, type %u, idx %u, rate %u, pool %u, drops %u, input %u output %u records %u",
+ ND_PRINT((ndo, " seqnum %u, type %u, idx %u, rate %u, pool %u, drops %u, input %u output %u records %u",
EXTRACT_32BITS(sflow_flow_sample->seqnum),
type,
index,
@@ -775,17 +829,20 @@ sflow_print_flow_sample(const u_char *pointer, u_int len) {
EXTRACT_32BITS(sflow_flow_sample->drops),
EXTRACT_32BITS(sflow_flow_sample->in_interface),
EXTRACT_32BITS(sflow_flow_sample->out_interface),
- nrecords);
+ nrecords));
- return sflow_print_flow_records(pointer + sizeof(struct sflow_flow_sample_t),
+ return sflow_print_flow_records(ndo, pointer + sizeof(struct sflow_flow_sample_t),
len - sizeof(struct sflow_flow_sample_t),
nrecords);
+trunc:
+ return 1;
}
static int
-sflow_print_expanded_flow_sample(const u_char *pointer, u_int len) {
-
+sflow_print_expanded_flow_sample(netdissect_options *ndo,
+ const u_char *pointer, u_int len)
+{
const struct sflow_expanded_flow_sample_t *sflow_expanded_flow_sample;
u_int nrecords;
@@ -793,71 +850,74 @@ sflow_print_expanded_flow_sample(const u_char *pointer, u_int len) {
return 1;
sflow_expanded_flow_sample = (const struct sflow_expanded_flow_sample_t *)pointer;
+ ND_TCHECK(*sflow_expanded_flow_sample);
nrecords = EXTRACT_32BITS(sflow_expanded_flow_sample->records);
- printf(" seqnum %u, type %u, idx %u, rate %u, pool %u, drops %u, records %u",
+ ND_PRINT((ndo, " seqnum %u, type %u, idx %u, rate %u, pool %u, drops %u, records %u",
EXTRACT_32BITS(sflow_expanded_flow_sample->seqnum),
EXTRACT_32BITS(sflow_expanded_flow_sample->type),
EXTRACT_32BITS(sflow_expanded_flow_sample->index),
EXTRACT_32BITS(sflow_expanded_flow_sample->rate),
EXTRACT_32BITS(sflow_expanded_flow_sample->pool),
EXTRACT_32BITS(sflow_expanded_flow_sample->drops),
- EXTRACT_32BITS(sflow_expanded_flow_sample->records));
-
- return sflow_print_flow_records(pointer + sizeof(struct sflow_expanded_flow_sample_t),
+ EXTRACT_32BITS(sflow_expanded_flow_sample->records)));
+
+ return sflow_print_flow_records(ndo, pointer + sizeof(struct sflow_expanded_flow_sample_t),
len - sizeof(struct sflow_expanded_flow_sample_t),
nrecords);
+trunc:
+ return 1;
}
void
-sflow_print(const u_char *pptr, u_int len) {
-
+sflow_print(netdissect_options *ndo,
+ const u_char *pptr, u_int len)
+{
const struct sflow_datagram_t *sflow_datagram;
const struct sflow_sample_header *sflow_sample;
const u_char *tptr;
u_int tlen;
- u_int32_t sflow_sample_type, sflow_sample_len;
- u_int32_t nsamples;
-
+ uint32_t sflow_sample_type, sflow_sample_len;
+ uint32_t nsamples;
tptr = pptr;
tlen = len;
sflow_datagram = (const struct sflow_datagram_t *)pptr;
- TCHECK(*sflow_datagram);
+ ND_TCHECK(*sflow_datagram);
/*
* Sanity checking of the header.
*/
if (EXTRACT_32BITS(sflow_datagram->version) != 5) {
- printf("sFlow version %u packet not supported",
- EXTRACT_32BITS(sflow_datagram->version));
+ ND_PRINT((ndo, "sFlow version %u packet not supported",
+ EXTRACT_32BITS(sflow_datagram->version)));
return;
}
- if (vflag < 1) {
- printf("sFlowv%u, %s agent %s, agent-id %u, length %u",
+ if (ndo->ndo_vflag < 1) {
+ ND_PRINT((ndo, "sFlowv%u, %s agent %s, agent-id %u, length %u",
EXTRACT_32BITS(sflow_datagram->version),
EXTRACT_32BITS(sflow_datagram->ip_version) == 1 ? "IPv4" : "IPv6",
- ipaddr_string(sflow_datagram->agent),
- EXTRACT_32BITS(sflow_datagram->samples),
- len);
+ ipaddr_string(ndo, sflow_datagram->agent),
+ EXTRACT_32BITS(sflow_datagram->agent_id),
+ len));
return;
}
/* ok they seem to want to know everything - lets fully decode it */
nsamples=EXTRACT_32BITS(sflow_datagram->samples);
- printf("sFlowv%u, %s agent %s, agent-id %u, seqnum %u, uptime %u, samples %u, length %u",
+ ND_PRINT((ndo, "sFlowv%u, %s agent %s, agent-id %u, seqnum %u, uptime %u, samples %u, length %u",
EXTRACT_32BITS(sflow_datagram->version),
EXTRACT_32BITS(sflow_datagram->ip_version) == 1 ? "IPv4" : "IPv6",
- ipaddr_string(sflow_datagram->agent),
+ ipaddr_string(ndo, sflow_datagram->agent),
EXTRACT_32BITS(sflow_datagram->agent_id),
EXTRACT_32BITS(sflow_datagram->seqnum),
EXTRACT_32BITS(sflow_datagram->uptime),
nsamples,
- len);
+ len));
/* skip Common header */
tptr += sizeof(const struct sflow_datagram_t);
@@ -865,7 +925,7 @@ sflow_print(const u_char *pptr, u_int len) {
while (nsamples > 0 && tlen > 0) {
sflow_sample = (const struct sflow_sample_header *)tptr;
- TCHECK(*sflow_sample);
+ ND_TCHECK(*sflow_sample);
sflow_sample_type = (EXTRACT_32BITS(sflow_sample->format)&0x0FFF);
sflow_sample_len = EXTRACT_32BITS(sflow_sample->len);
@@ -875,11 +935,11 @@ sflow_print(const u_char *pptr, u_int len) {
tptr += sizeof(struct sflow_sample_header);
tlen -= sizeof(struct sflow_sample_header);
-
- printf("\n\t%s (%u), length %u,",
+
+ ND_PRINT((ndo, "\n\t%s (%u), length %u,",
tok2str(sflow_format_values, "Unknown", sflow_sample_type),
sflow_sample_type,
- sflow_sample_len);
+ sflow_sample_len));
/* basic sanity check */
if (sflow_sample_type == 0 || sflow_sample_len ==0) {
@@ -890,32 +950,32 @@ sflow_print(const u_char *pptr, u_int len) {
goto trunc;
/* did we capture enough for fully decoding the sample ? */
- TCHECK2(*tptr, sflow_sample_len);
+ ND_TCHECK2(*tptr, sflow_sample_len);
switch(sflow_sample_type) {
case SFLOW_FLOW_SAMPLE:
- if (sflow_print_flow_sample(tptr,tlen))
+ if (sflow_print_flow_sample(ndo, tptr, tlen))
goto trunc;
break;
case SFLOW_COUNTER_SAMPLE:
- if (sflow_print_counter_sample(tptr,tlen))
+ if (sflow_print_counter_sample(ndo, tptr,tlen))
goto trunc;
break;
case SFLOW_EXPANDED_FLOW_SAMPLE:
- if (sflow_print_expanded_flow_sample(tptr,tlen))
+ if (sflow_print_expanded_flow_sample(ndo, tptr, tlen))
goto trunc;
break;
case SFLOW_EXPANDED_COUNTER_SAMPLE:
- if (sflow_print_expanded_counter_sample(tptr,tlen))
+ if (sflow_print_expanded_counter_sample(ndo, tptr,tlen))
goto trunc;
break;
default:
- if (vflag <= 1)
- print_unknown_data(tptr, "\n\t ", sflow_sample_len);
+ if (ndo->ndo_vflag <= 1)
+ print_unknown_data(ndo, tptr, "\n\t ", sflow_sample_len);
break;
}
tptr += sflow_sample_len;
@@ -925,7 +985,7 @@ sflow_print(const u_char *pptr, u_int len) {
return;
trunc:
- printf("[|SFLOW]");
+ ND_PRINT((ndo, "[|SFLOW]"));
}
/*
@@ -934,3 +994,6 @@ sflow_print(const u_char *pptr, u_int len) {
* c-basic-offset: 4
* End:
*/
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-sflow-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-sip.c b/freebsd/contrib/tcpdump/print-sip.c
index 266fcbe7..afb214a8 100644
--- a/freebsd/contrib/tcpdump/print-sip.c
+++ b/freebsd/contrib/tcpdump/print-sip.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code
@@ -13,54 +16,47 @@
* FOR A PARTICULAR PURPOSE.
*
* Original code by Hannes Gredler (hannes@juniper.net)
+ * Turned into common "text protocol" code, which this uses, by
+ * Guy Harris.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-sip.c,v 1.1 2004-07-27 17:04:20 hannes Exp $";
-#endif
+/* \summary: Session Initiation Protocol (SIP) printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
-
-#include <stdio.h>
-#include <stdlib.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
-#include "udp.h"
+static const char *sipcmds[] = {
+ "ACK",
+ "BYE",
+ "CANCEL",
+ "DO",
+ "INFO",
+ "INVITE",
+ "MESSAGE",
+ "NOTIFY",
+ "OPTIONS",
+ "PRACK",
+ "QAUTH",
+ "REFER",
+ "REGISTER",
+ "SPRACK",
+ "SUBSCRIBE",
+ "UPDATE",
+ "PUBLISH",
+ NULL
+};
void
-sip_print(register const u_char *pptr, register u_int len)
+sip_print(netdissect_options *ndo, const u_char *pptr, u_int len)
{
- u_int idx;
-
- printf("SIP, length: %u%s", len, vflag ? "\n\t" : "");
-
- /* in non-verbose mode just lets print the protocol and length */
- if (vflag < 1)
- return;
-
- for (idx = 0; idx < len; idx++) {
- TCHECK2(*(pptr+idx), 2);
- if (EXTRACT_16BITS(pptr+idx) != 0x0d0a) { /* linefeed ? */
- safeputchar(*(pptr+idx));
- } else {
- printf("\n\t");
- idx+=1;
- }
- }
-
- /* do we want to see an additionally hexdump ? */
- if (vflag> 1)
- print_unknown_data(pptr,"\n\t",len);
-
- return;
-
-trunc:
- printf("[|sip]");
+ txtproto_print(ndo, pptr, len, "sip", sipcmds, RESP_CODE_SECOND_TOKEN);
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-sip-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-sl.c b/freebsd/contrib/tcpdump/print-sl.c
index 9496a918..53cfadb7 100644
--- a/freebsd/contrib/tcpdump/print-sl.c
+++ b/freebsd/contrib/tcpdump/print-sl.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1989, 1990, 1991, 1993, 1994, 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
@@ -19,124 +22,135 @@
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * $FreeBSD$
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-sl.c,v 1.65 2005-04-06 21:32:42 mcr Exp $ (LBL)";
-#endif
+/* \summary: Compressed Serial Line Internet Protocol printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
-
-#include <pcap.h>
-#include <stdio.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
-#include "addrtoname.h"
-#include "extract.h" /* must come after interface.h */
+#include "netdissect.h"
+#include "extract.h"
#include "ip.h"
#include "tcp.h"
-#include "slip.h"
#include "slcompress.h"
+/*
+ * definitions of the pseudo- link-level header attached to slip
+ * packets grabbed by the packet filter (bpf) traffic monitor.
+ */
+#define SLIP_HDRLEN 16
+
+#define SLX_DIR 0
+#define SLX_CHDR 1
+#define CHDR_LEN 15
+
+#define SLIPDIR_IN 0
+#define SLIPDIR_OUT 1
+
+static const char tstr[] = "[|slip]";
+
static u_int lastlen[2][256];
static u_int lastconn = 255;
-static void sliplink_print(const u_char *, const struct ip *, u_int);
-static void compressed_sl_print(const u_char *, const struct ip *, u_int, int);
+static void sliplink_print(netdissect_options *, const u_char *, const struct ip *, u_int);
+static void compressed_sl_print(netdissect_options *, const u_char *, const struct ip *, u_int, int);
u_int
-sl_if_print(const struct pcap_pkthdr *h, const u_char *p)
+sl_if_print(netdissect_options *ndo,
+ const struct pcap_pkthdr *h, const u_char *p)
{
register u_int caplen = h->caplen;
register u_int length = h->len;
register const struct ip *ip;
- if (caplen < SLIP_HDRLEN) {
- printf("[|slip]");
+ if (caplen < SLIP_HDRLEN || length < SLIP_HDRLEN) {
+ ND_PRINT((ndo, "%s", tstr));
return (caplen);
}
+ caplen -= SLIP_HDRLEN;
length -= SLIP_HDRLEN;
- ip = (struct ip *)(p + SLIP_HDRLEN);
+ ip = (const struct ip *)(p + SLIP_HDRLEN);
- if (eflag)
- sliplink_print(p, ip, length);
+ if (ndo->ndo_eflag)
+ sliplink_print(ndo, p, ip, length);
+
+ if (caplen < 1 || length < 1) {
+ ND_PRINT((ndo, "%s", tstr));
+ return (caplen + SLIP_HDRLEN);
+ }
switch (IP_V(ip)) {
case 4:
- ip_print(gndo, (u_char *)ip, length);
+ ip_print(ndo, (const u_char *)ip, length);
break;
-#ifdef INET6
case 6:
- ip6_print(gndo, (u_char *)ip, length);
+ ip6_print(ndo, (const u_char *)ip, length);
break;
-#endif
default:
- printf ("ip v%d", IP_V(ip));
+ ND_PRINT((ndo, "ip v%d", IP_V(ip)));
}
return (SLIP_HDRLEN);
}
u_int
-sl_bsdos_if_print(const struct pcap_pkthdr *h, const u_char *p)
+sl_bsdos_if_print(netdissect_options *ndo,
+ const struct pcap_pkthdr *h, const u_char *p)
{
register u_int caplen = h->caplen;
register u_int length = h->len;
register const struct ip *ip;
if (caplen < SLIP_HDRLEN) {
- printf("[|slip]");
+ ND_PRINT((ndo, "%s", tstr));
return (caplen);
}
length -= SLIP_HDRLEN;
- ip = (struct ip *)(p + SLIP_HDRLEN);
+ ip = (const struct ip *)(p + SLIP_HDRLEN);
#ifdef notdef
- if (eflag)
- sliplink_print(p, ip, length);
+ if (ndo->ndo_eflag)
+ sliplink_print(ndo, p, ip, length);
#endif
- ip_print(gndo, (u_char *)ip, length);
+ ip_print(ndo, (const u_char *)ip, length);
return (SLIP_HDRLEN);
}
static void
-sliplink_print(register const u_char *p, register const struct ip *ip,
- register u_int length)
+sliplink_print(netdissect_options *ndo,
+ register const u_char *p, register const struct ip *ip,
+ register u_int length)
{
int dir;
u_int hlen;
dir = p[SLX_DIR];
- putchar(dir == SLIPDIR_IN ? 'I' : 'O');
- putchar(' ');
+ ND_PRINT((ndo, dir == SLIPDIR_IN ? "I " : "O "));
- if (nflag) {
+ if (ndo->ndo_nflag) {
/* XXX just dump the header */
register int i;
for (i = SLX_CHDR; i < SLX_CHDR + CHDR_LEN - 1; ++i)
- printf("%02x.", p[i]);
- printf("%02x: ", p[SLX_CHDR + CHDR_LEN - 1]);
+ ND_PRINT((ndo, "%02x.", p[i]));
+ ND_PRINT((ndo, "%02x: ", p[SLX_CHDR + CHDR_LEN - 1]));
return;
}
switch (p[SLX_CHDR] & 0xf0) {
case TYPE_IP:
- printf("ip %d: ", length + SLIP_HDRLEN);
+ ND_PRINT((ndo, "ip %d: ", length + SLIP_HDRLEN));
break;
case TYPE_UNCOMPRESSED_TCP:
@@ -145,25 +159,26 @@ sliplink_print(register const u_char *p, register const struct ip *ip,
* Get it from the link layer since sl_uncompress_tcp()
* has restored the IP header copy to IPPROTO_TCP.
*/
- lastconn = ((struct ip *)&p[SLX_CHDR])->ip_p;
+ lastconn = ((const struct ip *)&p[SLX_CHDR])->ip_p;
hlen = IP_HL(ip);
- hlen += TH_OFF((struct tcphdr *)&((int *)ip)[hlen]);
+ hlen += TH_OFF((const struct tcphdr *)&((const int *)ip)[hlen]);
lastlen[dir][lastconn] = length - (hlen << 2);
- printf("utcp %d: ", lastconn);
+ ND_PRINT((ndo, "utcp %d: ", lastconn));
break;
default:
if (p[SLX_CHDR] & TYPE_COMPRESSED_TCP) {
- compressed_sl_print(&p[SLX_CHDR], ip,
+ compressed_sl_print(ndo, &p[SLX_CHDR], ip,
length, dir);
- printf(": ");
+ ND_PRINT((ndo, ": "));
} else
- printf("slip-%d!: ", p[SLX_CHDR]);
+ ND_PRINT((ndo, "slip-%d!: ", p[SLX_CHDR]));
}
}
static const u_char *
-print_sl_change(const char *str, register const u_char *cp)
+print_sl_change(netdissect_options *ndo,
+ const char *str, register const u_char *cp)
{
register u_int i;
@@ -171,12 +186,13 @@ print_sl_change(const char *str, register const u_char *cp)
i = EXTRACT_16BITS(cp);
cp += 2;
}
- printf(" %s%d", str, i);
+ ND_PRINT((ndo, " %s%d", str, i));
return (cp);
}
static const u_char *
-print_sl_winchange(register const u_char *cp)
+print_sl_winchange(netdissect_options *ndo,
+ register const u_char *cp)
{
register short i;
@@ -185,15 +201,16 @@ print_sl_winchange(register const u_char *cp)
cp += 2;
}
if (i >= 0)
- printf(" W+%d", i);
+ ND_PRINT((ndo, " W+%d", i));
else
- printf(" W%d", i);
+ ND_PRINT((ndo, " W%d", i));
return (cp);
}
static void
-compressed_sl_print(const u_char *chdr, const struct ip *ip,
- u_int length, int dir)
+compressed_sl_print(netdissect_options *ndo,
+ const u_char *chdr, const struct ip *ip,
+ u_int length, int dir)
{
register const u_char *cp = chdr;
register u_int flags, hlen;
@@ -201,35 +218,35 @@ compressed_sl_print(const u_char *chdr, const struct ip *ip,
flags = *cp++;
if (flags & NEW_C) {
lastconn = *cp++;
- printf("ctcp %d", lastconn);
+ ND_PRINT((ndo, "ctcp %d", lastconn));
} else
- printf("ctcp *");
+ ND_PRINT((ndo, "ctcp *"));
/* skip tcp checksum */
cp += 2;
switch (flags & SPECIALS_MASK) {
case SPECIAL_I:
- printf(" *SA+%d", lastlen[dir][lastconn]);
+ ND_PRINT((ndo, " *SA+%d", lastlen[dir][lastconn]));
break;
case SPECIAL_D:
- printf(" *S+%d", lastlen[dir][lastconn]);
+ ND_PRINT((ndo, " *S+%d", lastlen[dir][lastconn]));
break;
default:
if (flags & NEW_U)
- cp = print_sl_change("U=", cp);
+ cp = print_sl_change(ndo, "U=", cp);
if (flags & NEW_W)
- cp = print_sl_winchange(cp);
+ cp = print_sl_winchange(ndo, cp);
if (flags & NEW_A)
- cp = print_sl_change("A+", cp);
+ cp = print_sl_change(ndo, "A+", cp);
if (flags & NEW_S)
- cp = print_sl_change("S+", cp);
+ cp = print_sl_change(ndo, "S+", cp);
break;
}
if (flags & NEW_I)
- cp = print_sl_change("I+", cp);
+ cp = print_sl_change(ndo, "I+", cp);
/*
* 'hlen' is the length of the uncompressed TCP/IP header (in words).
@@ -237,7 +254,10 @@ compressed_sl_print(const u_char *chdr, const struct ip *ip,
* 'length - hlen' is the amount of data in the packet.
*/
hlen = IP_HL(ip);
- hlen += TH_OFF((struct tcphdr *)&((int32_t *)ip)[hlen]);
+ hlen += TH_OFF((const struct tcphdr *)&((const int32_t *)ip)[hlen]);
lastlen[dir][lastconn] = length - (hlen << 2);
- printf(" %d (%ld)", lastlen[dir][lastconn], (long)(cp - chdr));
+ ND_PRINT((ndo, " %d (%ld)", lastlen[dir][lastconn], (long)(cp - chdr)));
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-sl-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-sll.c b/freebsd/contrib/tcpdump/print-sll.c
index 264eeb30..52a84404 100644
--- a/freebsd/contrib/tcpdump/print-sll.c
+++ b/freebsd/contrib/tcpdump/print-sll.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
@@ -20,30 +23,111 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-sll.c,v 1.19 2005-11-13 12:12:43 guy Exp $ (LBL)";
-#endif
+
+/* \summary: Linux cooked sockets capture printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include <stdio.h>
-#include <string.h>
-#include <pcap.h>
-
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "ethertype.h"
#include "extract.h"
#include "ether.h"
-#include "sll.h"
-const struct tok sll_pkttype_values[] = {
+/*
+ * For captures on Linux cooked sockets, we construct a fake header
+ * that includes:
+ *
+ * a 2-byte "packet type" which is one of:
+ *
+ * LINUX_SLL_HOST packet was sent to us
+ * LINUX_SLL_BROADCAST packet was broadcast
+ * LINUX_SLL_MULTICAST packet was multicast
+ * LINUX_SLL_OTHERHOST packet was sent to somebody else
+ * LINUX_SLL_OUTGOING packet was sent *by* us;
+ *
+ * a 2-byte Ethernet protocol field;
+ *
+ * a 2-byte link-layer type;
+ *
+ * a 2-byte link-layer address length;
+ *
+ * an 8-byte source link-layer address, whose actual length is
+ * specified by the previous value.
+ *
+ * All fields except for the link-layer address are in network byte order.
+ *
+ * DO NOT change the layout of this structure, or change any of the
+ * LINUX_SLL_ values below. If you must change the link-layer header
+ * for a "cooked" Linux capture, introduce a new DLT_ type (ask
+ * "tcpdump-workers@lists.tcpdump.org" for one, so that you don't give it
+ * a value that collides with a value already being used), and use the
+ * new header in captures of that type, so that programs that can
+ * handle DLT_LINUX_SLL captures will continue to handle them correctly
+ * without any change, and so that capture files with different headers
+ * can be told apart and programs that read them can dissect the
+ * packets in them.
+ *
+ * This structure, and the #defines below, must be the same in the
+ * libpcap and tcpdump versions of "sll.h".
+ */
+
+/*
+ * A DLT_LINUX_SLL fake link-layer header.
+ */
+#define SLL_HDR_LEN 16 /* total header length */
+#define SLL_ADDRLEN 8 /* length of address field */
+
+struct sll_header {
+ uint16_t sll_pkttype; /* packet type */
+ uint16_t sll_hatype; /* link-layer address type */
+ uint16_t sll_halen; /* link-layer address length */
+ uint8_t sll_addr[SLL_ADDRLEN]; /* link-layer address */
+ uint16_t sll_protocol; /* protocol */
+};
+
+/*
+ * The LINUX_SLL_ values for "sll_pkttype"; these correspond to the
+ * PACKET_ values on Linux, but are defined here so that they're
+ * available even on systems other than Linux, and so that they
+ * don't change even if the PACKET_ values change.
+ */
+#define LINUX_SLL_HOST 0
+#define LINUX_SLL_BROADCAST 1
+#define LINUX_SLL_MULTICAST 2
+#define LINUX_SLL_OTHERHOST 3
+#define LINUX_SLL_OUTGOING 4
+
+/*
+ * The LINUX_SLL_ values for "sll_protocol"; these correspond to the
+ * ETH_P_ values on Linux, but are defined here so that they're
+ * available even on systems other than Linux. We assume, for now,
+ * that the ETH_P_ values won't change in Linux; if they do, then:
+ *
+ * if we don't translate them in "pcap-linux.c", capture files
+ * won't necessarily be readable if captured on a system that
+ * defines ETH_P_ values that don't match these values;
+ *
+ * if we do translate them in "pcap-linux.c", that makes life
+ * unpleasant for the BPF code generator, as the values you test
+ * for in the kernel aren't the values that you test for when
+ * reading a capture file, so the fixup code run on BPF programs
+ * handed to the kernel ends up having to do more work.
+ *
+ * Add other values here as necessary, for handling packet types that
+ * might show up on non-Ethernet, non-802.x networks. (Not all the ones
+ * in the Linux "if_ether.h" will, I suspect, actually show up in
+ * captures.)
+ */
+#define LINUX_SLL_P_802_3 0x0001 /* Novell 802.3 frames without 802.2 LLC header */
+#define LINUX_SLL_P_802_2 0x0004 /* 802.2 frames (not D/I/X Ethernet) */
+
+static const struct tok sll_pkttype_values[] = {
{ LINUX_SLL_HOST, "In" },
{ LINUX_SLL_BROADCAST, "B" },
{ LINUX_SLL_MULTICAST, "M" },
@@ -53,11 +137,11 @@ const struct tok sll_pkttype_values[] = {
};
static inline void
-sll_print(register const struct sll_header *sllp, u_int length)
+sll_print(netdissect_options *ndo, register const struct sll_header *sllp, u_int length)
{
u_short ether_type;
- printf("%3s ",tok2str(sll_pkttype_values,"?",EXTRACT_16BITS(&sllp->sll_pkttype)));
+ ND_PRINT((ndo, "%3s ",tok2str(sll_pkttype_values,"?",EXTRACT_16BITS(&sllp->sll_pkttype))));
/*
* XXX - check the link-layer address type value?
@@ -65,11 +149,11 @@ sll_print(register const struct sll_header *sllp, u_int length)
* XXX - print others as strings of hex?
*/
if (EXTRACT_16BITS(&sllp->sll_halen) == 6)
- (void)printf("%s ", etheraddr_string(sllp->sll_addr));
+ ND_PRINT((ndo, "%s ", etheraddr_string(ndo, sllp->sll_addr)));
- if (!qflag) {
+ if (!ndo->ndo_qflag) {
ether_type = EXTRACT_16BITS(&sllp->sll_protocol);
-
+
if (ether_type <= ETHERMTU) {
/*
* Not an Ethernet type; what type is it?
@@ -80,30 +164,30 @@ sll_print(register const struct sll_header *sllp, u_int length)
/*
* Ethernet_802.3 IPX frame.
*/
- (void)printf("802.3");
+ ND_PRINT((ndo, "802.3"));
break;
case LINUX_SLL_P_802_2:
/*
* 802.2.
*/
- (void)printf("802.2");
+ ND_PRINT((ndo, "802.2"));
break;
default:
/*
* What is it?
*/
- (void)printf("ethertype Unknown (0x%04x)",
- ether_type);
+ ND_PRINT((ndo, "ethertype Unknown (0x%04x)",
+ ether_type));
break;
}
} else {
- (void)printf("ethertype %s (0x%04x)",
+ ND_PRINT((ndo, "ethertype %s (0x%04x)",
tok2str(ethertype_values, "Unknown", ether_type),
- ether_type);
+ ether_type));
}
- (void)printf(", length %u: ", length);
+ ND_PRINT((ndo, ", length %u: ", length));
}
}
@@ -114,13 +198,14 @@ sll_print(register const struct sll_header *sllp, u_int length)
* is the number of bytes actually captured.
*/
u_int
-sll_if_print(const struct pcap_pkthdr *h, const u_char *p)
+sll_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
{
u_int caplen = h->caplen;
u_int length = h->len;
register const struct sll_header *sllp;
u_short ether_type;
- u_short extracted_ethertype;
+ int llc_hdrlen;
+ u_int hdrlen;
if (caplen < SLL_HDR_LEN) {
/*
@@ -128,14 +213,14 @@ sll_if_print(const struct pcap_pkthdr *h, const u_char *p)
* adds this many bytes of header to every packet in a
* cooked socket capture.
*/
- printf("[|sll]");
+ ND_PRINT((ndo, "[|sll]"));
return (caplen);
}
sllp = (const struct sll_header *)p;
- if (eflag)
- sll_print(sllp, length);
+ if (ndo->ndo_eflag)
+ sll_print(ndo, sllp, length);
/*
* Go past the cooked-mode header.
@@ -143,6 +228,7 @@ sll_if_print(const struct pcap_pkthdr *h, const u_char *p)
length -= SLL_HDR_LEN;
caplen -= SLL_HDR_LEN;
p += SLL_HDR_LEN;
+ hdrlen = SLL_HDR_LEN;
ether_type = EXTRACT_16BITS(&sllp->sll_protocol);
@@ -161,7 +247,7 @@ recurse:
/*
* Ethernet_802.3 IPX frame.
*/
- ipx_print(p, length);
+ ipx_print(ndo, p, length);
break;
case LINUX_SLL_P_802_2:
@@ -169,25 +255,19 @@ recurse:
* 802.2.
* Try to print the LLC-layer header & higher layers.
*/
- if (llc_print(p, length, caplen, NULL, NULL,
- &extracted_ethertype) == 0)
+ llc_hdrlen = llc_print(ndo, p, length, caplen, NULL, NULL);
+ if (llc_hdrlen < 0)
goto unknown; /* unknown LLC type */
+ hdrlen += llc_hdrlen;
break;
default:
- extracted_ethertype = 0;
/*FALLTHROUGH*/
unknown:
- /* ether_type not known, print raw packet */
- if (!eflag)
- sll_print(sllp, length + SLL_HDR_LEN);
- if (extracted_ethertype) {
- printf("(LLC %s) ",
- etherproto_string(htons(extracted_ethertype)));
- }
- if (!suppress_default_print)
- default_print(p, caplen);
+ /* packet type not known, print raw packet */
+ if (!ndo->ndo_suppress_default_print)
+ ND_DEFAULTPRINT(p, caplen);
break;
}
} else if (ether_type == ETHERTYPE_8021Q) {
@@ -195,39 +275,44 @@ recurse:
* Print VLAN information, and then go back and process
* the enclosed type field.
*/
- if (caplen < 4 || length < 4) {
- printf("[|vlan]");
- return (SLL_HDR_LEN);
+ if (caplen < 4) {
+ ND_PRINT((ndo, "[|vlan]"));
+ return (hdrlen + caplen);
+ }
+ if (length < 4) {
+ ND_PRINT((ndo, "[|vlan]"));
+ return (hdrlen + length);
}
- if (eflag) {
- u_int16_t tag = EXTRACT_16BITS(p);
+ if (ndo->ndo_eflag) {
+ uint16_t tag = EXTRACT_16BITS(p);
- printf("vlan %u, p %u%s, ",
- tag & 0xfff,
- tag >> 13,
- (tag & 0x1000) ? ", CFI" : "");
+ ND_PRINT((ndo, "%s, ", ieee8021q_tci_string(tag)));
}
ether_type = EXTRACT_16BITS(p + 2);
if (ether_type <= ETHERMTU)
ether_type = LINUX_SLL_P_802_2;
- if (!qflag) {
- (void)printf("ethertype %s, ",
- tok2str(ethertype_values, "Unknown", ether_type));
+ if (!ndo->ndo_qflag) {
+ ND_PRINT((ndo, "ethertype %s, ",
+ tok2str(ethertype_values, "Unknown", ether_type)));
}
p += 4;
length -= 4;
caplen -= 4;
+ hdrlen += 4;
goto recurse;
} else {
- if (ethertype_print(gndo, ether_type, p, length, caplen) == 0) {
+ if (ethertype_print(ndo, ether_type, p, length, caplen, NULL, NULL) == 0) {
/* ether_type not known, print raw packet */
- if (!eflag)
- sll_print(sllp, length + SLL_HDR_LEN);
- if (!suppress_default_print)
- default_print(p, caplen);
+ if (!ndo->ndo_eflag)
+ sll_print(ndo, sllp, length + SLL_HDR_LEN);
+ if (!ndo->ndo_suppress_default_print)
+ ND_DEFAULTPRINT(p, caplen);
}
}
- return (SLL_HDR_LEN);
+ return (hdrlen);
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-sll-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-slow.c b/freebsd/contrib/tcpdump/print-slow.c
index f4430887..14c082c0 100644
--- a/freebsd/contrib/tcpdump/print-slow.c
+++ b/freebsd/contrib/tcpdump/print-slow.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1998-2006 The TCPDUMP project
*
@@ -20,32 +23,20 @@
* Original code by Hannes Gredler (hannes@juniper.net)
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-slow.c,v 1.8 2006-10-12 05:44:33 hannes Exp $";
-#endif
+/* \summary: IEEE "slow protocols" (802.3ad/802.3ah) printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
#include "addrtoname.h"
#include "ether.h"
#include "oui.h"
-struct slow_common_header_t {
- u_int8_t proto_subtype;
- u_int8_t version;
-};
-
#define SLOW_PROTO_LACP 1
#define SLOW_PROTO_MARKER 2
#define SLOW_PROTO_OAM 3
@@ -69,7 +60,7 @@ static const struct tok slow_oam_flag_values[] = {
{ 0x0020, "Remote Evaluating" },
{ 0x0040, "Remote Stable" },
{ 0, NULL}
-};
+};
#define SLOW_OAM_CODE_INFO 0x00
#define SLOW_OAM_CODE_EVENT_NOTIF 0x01
@@ -89,15 +80,15 @@ static const struct tok slow_oam_code_values[] = {
};
struct slow_oam_info_t {
- u_int8_t info_type;
- u_int8_t info_length;
- u_int8_t oam_version;
- u_int8_t revision[2];
- u_int8_t state;
- u_int8_t oam_config;
- u_int8_t oam_pdu_config[2];
- u_int8_t oui[3];
- u_int8_t vendor_private[4];
+ uint8_t info_type;
+ uint8_t info_length;
+ uint8_t oam_version;
+ uint8_t revision[2];
+ uint8_t state;
+ uint8_t oam_config;
+ uint8_t oam_pdu_config[2];
+ uint8_t oui[3];
+ uint8_t vendor_private[4];
};
#define SLOW_OAM_INFO_TYPE_END_OF_TLV 0x00
@@ -159,29 +150,29 @@ static const struct tok slow_oam_link_event_values[] = {
};
struct slow_oam_link_event_t {
- u_int8_t event_type;
- u_int8_t event_length;
- u_int8_t time_stamp[2];
- u_int8_t window[8];
- u_int8_t threshold[8];
- u_int8_t errors[8];
- u_int8_t errors_running_total[8];
- u_int8_t event_running_total[4];
+ uint8_t event_type;
+ uint8_t event_length;
+ uint8_t time_stamp[2];
+ uint8_t window[8];
+ uint8_t threshold[8];
+ uint8_t errors[8];
+ uint8_t errors_running_total[8];
+ uint8_t event_running_total[4];
};
struct slow_oam_variablerequest_t {
- u_int8_t branch;
- u_int8_t leaf[2];
+ uint8_t branch;
+ uint8_t leaf[2];
};
struct slow_oam_variableresponse_t {
- u_int8_t branch;
- u_int8_t leaf[2];
- u_int8_t length;
+ uint8_t branch;
+ uint8_t leaf[2];
+ uint8_t length;
};
struct slow_oam_loopbackctrl_t {
- u_int8_t command;
+ uint8_t command;
};
static const struct tok slow_oam_loopbackctrl_cmd_values[] = {
@@ -191,38 +182,38 @@ static const struct tok slow_oam_loopbackctrl_cmd_values[] = {
};
struct tlv_header_t {
- u_int8_t type;
- u_int8_t length;
+ uint8_t type;
+ uint8_t length;
};
-#define LACP_TLV_TERMINATOR 0x00
-#define LACP_TLV_ACTOR_INFO 0x01
-#define LACP_TLV_PARTNER_INFO 0x02
-#define LACP_TLV_COLLECTOR_INFO 0x03
+#define LACP_MARKER_TLV_TERMINATOR 0x00 /* same code for LACP and Marker */
+
+#define LACP_TLV_ACTOR_INFO 0x01
+#define LACP_TLV_PARTNER_INFO 0x02
+#define LACP_TLV_COLLECTOR_INFO 0x03
-#define MARKER_TLV_TERMINATOR 0x00
-#define MARKER_TLV_MARKER_INFO 0x01
+#define MARKER_TLV_MARKER_INFO 0x01
static const struct tok slow_tlv_values[] = {
- { (SLOW_PROTO_LACP << 8) + LACP_TLV_TERMINATOR, "Terminator"},
+ { (SLOW_PROTO_LACP << 8) + LACP_MARKER_TLV_TERMINATOR, "Terminator"},
{ (SLOW_PROTO_LACP << 8) + LACP_TLV_ACTOR_INFO, "Actor Information"},
{ (SLOW_PROTO_LACP << 8) + LACP_TLV_PARTNER_INFO, "Partner Information"},
{ (SLOW_PROTO_LACP << 8) + LACP_TLV_COLLECTOR_INFO, "Collector Information"},
- { (SLOW_PROTO_MARKER << 8) + MARKER_TLV_TERMINATOR, "Terminator"},
+ { (SLOW_PROTO_MARKER << 8) + LACP_MARKER_TLV_TERMINATOR, "Terminator"},
{ (SLOW_PROTO_MARKER << 8) + MARKER_TLV_MARKER_INFO, "Marker Information"},
{ 0, NULL}
};
struct lacp_tlv_actor_partner_info_t {
- u_int8_t sys_pri[2];
- u_int8_t sys[ETHER_ADDR_LEN];
- u_int8_t key[2];
- u_int8_t port_pri[2];
- u_int8_t port[2];
- u_int8_t state;
- u_int8_t pad[3];
-};
+ uint8_t sys_pri[2];
+ uint8_t sys[ETHER_ADDR_LEN];
+ uint8_t key[2];
+ uint8_t port_pri[2];
+ uint8_t port[2];
+ uint8_t state;
+ uint8_t pad[3];
+};
static const struct tok lacp_tlv_actor_partner_info_state_values[] = {
{ 0x01, "Activity"},
@@ -237,49 +228,57 @@ static const struct tok lacp_tlv_actor_partner_info_state_values[] = {
};
struct lacp_tlv_collector_info_t {
- u_int8_t max_delay[2];
- u_int8_t pad[12];
-};
+ uint8_t max_delay[2];
+ uint8_t pad[12];
+};
struct marker_tlv_marker_info_t {
- u_int8_t req_port[2];
- u_int8_t req_sys[ETHER_ADDR_LEN];
- u_int8_t req_trans_id[4];
- u_int8_t pad[2];
-};
+ uint8_t req_port[2];
+ uint8_t req_sys[ETHER_ADDR_LEN];
+ uint8_t req_trans_id[4];
+ uint8_t pad[2];
+};
struct lacp_marker_tlv_terminator_t {
- u_int8_t pad[50];
-};
-
-void slow_marker_lacp_print(register const u_char *, register u_int);
-void slow_oam_print(register const u_char *, register u_int);
+ uint8_t pad[50];
+};
-const struct slow_common_header_t *slow_com_header;
+static void slow_marker_lacp_print(netdissect_options *, register const u_char *, register u_int, u_int);
+static void slow_oam_print(netdissect_options *, register const u_char *, register u_int);
void
-slow_print(register const u_char *pptr, register u_int len) {
-
+slow_print(netdissect_options *ndo,
+ register const u_char *pptr, register u_int len)
+{
int print_version;
+ u_int subtype;
- slow_com_header = (const struct slow_common_header_t *)pptr;
- TCHECK(*slow_com_header);
+ if (len < 1)
+ goto tooshort;
+ ND_TCHECK(*pptr);
+ subtype = *pptr;
/*
* Sanity checking of the header.
*/
- switch (slow_com_header->proto_subtype) {
+ switch (subtype) {
case SLOW_PROTO_LACP:
- if (slow_com_header->version != LACP_VERSION) {
- printf("LACP version %u packet not supported",slow_com_header->version);
+ if (len < 2)
+ goto tooshort;
+ ND_TCHECK(*(pptr+1));
+ if (*(pptr+1) != LACP_VERSION) {
+ ND_PRINT((ndo, "LACP version %u packet not supported", *(pptr+1)));
return;
}
print_version = 1;
break;
case SLOW_PROTO_MARKER:
- if (slow_com_header->version != MARKER_VERSION) {
- printf("MARKER version %u packet not supported",slow_com_header->version);
+ if (len < 2)
+ goto tooshort;
+ ND_TCHECK(*(pptr+1));
+ if (*(pptr+1) != MARKER_VERSION) {
+ ND_PRINT((ndo, "MARKER version %u packet not supported", *(pptr+1)));
return;
}
print_version = 1;
@@ -295,52 +294,67 @@ slow_print(register const u_char *pptr, register u_int len) {
break;
}
- if (print_version) {
- printf("%sv%u, length %u",
- tok2str(slow_proto_values, "unknown (%u)",slow_com_header->proto_subtype),
- slow_com_header->version,
- len);
+ if (print_version == 1) {
+ ND_PRINT((ndo, "%sv%u, length %u",
+ tok2str(slow_proto_values, "unknown (%u)", subtype),
+ *(pptr+1),
+ len));
} else {
/* some slow protos don't have a version number in the header */
- printf("%s, length %u",
- tok2str(slow_proto_values, "unknown (%u)",slow_com_header->proto_subtype),
- len);
+ ND_PRINT((ndo, "%s, length %u",
+ tok2str(slow_proto_values, "unknown (%u)", subtype),
+ len));
}
/* unrecognized subtype */
if (print_version == -1) {
- print_unknown_data(pptr, "\n\t", len);
+ print_unknown_data(ndo, pptr, "\n\t", len);
return;
}
- if (!vflag)
+ if (!ndo->ndo_vflag)
return;
- switch (slow_com_header->proto_subtype) {
+ switch (subtype) {
default: /* should not happen */
break;
case SLOW_PROTO_OAM:
- /* skip proto_subtype */
- slow_oam_print(pptr+1, len-1);
+ /* skip subtype */
+ len -= 1;
+ pptr += 1;
+ slow_oam_print(ndo, pptr, len);
break;
case SLOW_PROTO_LACP: /* LACP and MARKER share the same semantics */
case SLOW_PROTO_MARKER:
- /* skip slow_common_header */
- len -= sizeof(const struct slow_common_header_t);
- pptr += sizeof(const struct slow_common_header_t);
- slow_marker_lacp_print(pptr, len);
+ /* skip subtype and version */
+ len -= 2;
+ pptr += 2;
+ slow_marker_lacp_print(ndo, pptr, len, subtype);
break;
}
return;
+tooshort:
+ if (!ndo->ndo_vflag)
+ ND_PRINT((ndo, " (packet is too short)"));
+ else
+ ND_PRINT((ndo, "\n\t\t packet is too short"));
+ return;
+
trunc:
- printf("\n\t\t packet exceeded snapshot");
+ if (!ndo->ndo_vflag)
+ ND_PRINT((ndo, " (packet exceeded snapshot)"));
+ else
+ ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
}
-void slow_marker_lacp_print(register const u_char *tptr, register u_int tlen) {
-
+static void
+slow_marker_lacp_print(netdissect_options *ndo,
+ register const u_char *tptr, register u_int tlen,
+ u_int proto_subtype)
+{
const struct tlv_header_t *tlv_header;
const u_char *tlv_tptr;
u_int tlv_len, tlv_tlen;
@@ -351,99 +365,116 @@ void slow_marker_lacp_print(register const u_char *tptr, register u_int tlen) {
const struct lacp_tlv_collector_info_t *lacp_tlv_collector_info;
const struct marker_tlv_marker_info_t *marker_tlv_marker_info;
} tlv_ptr;
-
+
while(tlen>0) {
+ /* is the packet big enough to include the tlv header ? */
+ if (tlen < sizeof(struct tlv_header_t))
+ goto tooshort;
/* did we capture enough for fully decoding the tlv header ? */
- TCHECK2(*tptr, sizeof(struct tlv_header_t));
+ ND_TCHECK2(*tptr, sizeof(struct tlv_header_t));
tlv_header = (const struct tlv_header_t *)tptr;
tlv_len = tlv_header->length;
- printf("\n\t%s TLV (0x%02x), length %u",
+ ND_PRINT((ndo, "\n\t%s TLV (0x%02x), length %u",
tok2str(slow_tlv_values,
"Unknown",
- (slow_com_header->proto_subtype << 8) + tlv_header->type),
+ (proto_subtype << 8) + tlv_header->type),
tlv_header->type,
- tlv_len);
-
- if ((tlv_len < sizeof(struct tlv_header_t) ||
- tlv_len > tlen) &&
- tlv_header->type != LACP_TLV_TERMINATOR &&
- tlv_header->type != MARKER_TLV_TERMINATOR) {
- printf("\n\t-----trailing data-----");
- print_unknown_data(tptr+sizeof(struct tlv_header_t),"\n\t ",tlen);
+ tlv_len));
+
+ if (tlv_header->type == LACP_MARKER_TLV_TERMINATOR) {
+ /*
+ * This TLV has a length of zero, and means there are no
+ * more TLVs to process.
+ */
return;
}
- tlv_tptr=tptr+sizeof(struct tlv_header_t);
- tlv_tlen=tlv_len-sizeof(struct tlv_header_t);
+ /* length includes the type and length fields */
+ if (tlv_len < sizeof(struct tlv_header_t)) {
+ ND_PRINT((ndo, "\n\t ERROR: illegal length - should be >= %lu",
+ (unsigned long) sizeof(struct tlv_header_t)));
+ return;
+ }
+ /* is the packet big enough to include the tlv ? */
+ if (tlen < tlv_len)
+ goto tooshort;
/* did we capture enough for fully decoding the tlv ? */
- TCHECK2(*tptr, tlv_len);
+ ND_TCHECK2(*tptr, tlv_len);
+
+ tlv_tptr=tptr+sizeof(struct tlv_header_t);
+ tlv_tlen=tlv_len-sizeof(struct tlv_header_t);
- switch((slow_com_header->proto_subtype << 8) + tlv_header->type) {
+ switch((proto_subtype << 8) + tlv_header->type) {
/* those two TLVs have the same structure -> fall through */
case ((SLOW_PROTO_LACP << 8) + LACP_TLV_ACTOR_INFO):
case ((SLOW_PROTO_LACP << 8) + LACP_TLV_PARTNER_INFO):
+ if (tlv_tlen !=
+ sizeof(struct lacp_tlv_actor_partner_info_t)) {
+ ND_PRINT((ndo, "\n\t ERROR: illegal length - should be %lu",
+ (unsigned long) (sizeof(struct tlv_header_t) + sizeof(struct lacp_tlv_actor_partner_info_t))));
+ goto badlength;
+ }
+
tlv_ptr.lacp_tlv_actor_partner_info = (const struct lacp_tlv_actor_partner_info_t *)tlv_tptr;
- printf("\n\t System %s, System Priority %u, Key %u" \
+ ND_PRINT((ndo, "\n\t System %s, System Priority %u, Key %u" \
", Port %u, Port Priority %u\n\t State Flags [%s]",
- etheraddr_string(tlv_ptr.lacp_tlv_actor_partner_info->sys),
+ etheraddr_string(ndo, tlv_ptr.lacp_tlv_actor_partner_info->sys),
EXTRACT_16BITS(tlv_ptr.lacp_tlv_actor_partner_info->sys_pri),
EXTRACT_16BITS(tlv_ptr.lacp_tlv_actor_partner_info->key),
EXTRACT_16BITS(tlv_ptr.lacp_tlv_actor_partner_info->port),
EXTRACT_16BITS(tlv_ptr.lacp_tlv_actor_partner_info->port_pri),
bittok2str(lacp_tlv_actor_partner_info_state_values,
"none",
- tlv_ptr.lacp_tlv_actor_partner_info->state));
+ tlv_ptr.lacp_tlv_actor_partner_info->state)));
break;
case ((SLOW_PROTO_LACP << 8) + LACP_TLV_COLLECTOR_INFO):
+ if (tlv_tlen !=
+ sizeof(struct lacp_tlv_collector_info_t)) {
+ ND_PRINT((ndo, "\n\t ERROR: illegal length - should be %lu",
+ (unsigned long) (sizeof(struct tlv_header_t) + sizeof(struct lacp_tlv_collector_info_t))));
+ goto badlength;
+ }
+
tlv_ptr.lacp_tlv_collector_info = (const struct lacp_tlv_collector_info_t *)tlv_tptr;
- printf("\n\t Max Delay %u",
- EXTRACT_16BITS(tlv_ptr.lacp_tlv_collector_info->max_delay));
+ ND_PRINT((ndo, "\n\t Max Delay %u",
+ EXTRACT_16BITS(tlv_ptr.lacp_tlv_collector_info->max_delay)));
break;
case ((SLOW_PROTO_MARKER << 8) + MARKER_TLV_MARKER_INFO):
+ if (tlv_tlen !=
+ sizeof(struct marker_tlv_marker_info_t)) {
+ ND_PRINT((ndo, "\n\t ERROR: illegal length - should be %lu",
+ (unsigned long) (sizeof(struct tlv_header_t) + sizeof(struct marker_tlv_marker_info_t))));
+ goto badlength;
+ }
+
tlv_ptr.marker_tlv_marker_info = (const struct marker_tlv_marker_info_t *)tlv_tptr;
- printf("\n\t Request System %s, Request Port %u, Request Transaction ID 0x%08x",
- etheraddr_string(tlv_ptr.marker_tlv_marker_info->req_sys),
+ ND_PRINT((ndo, "\n\t Request System %s, Request Port %u, Request Transaction ID 0x%08x",
+ etheraddr_string(ndo, tlv_ptr.marker_tlv_marker_info->req_sys),
EXTRACT_16BITS(tlv_ptr.marker_tlv_marker_info->req_port),
- EXTRACT_32BITS(tlv_ptr.marker_tlv_marker_info->req_trans_id));
-
- break;
-
- /* those two TLVs have the same structure -> fall through */
- case ((SLOW_PROTO_LACP << 8) + LACP_TLV_TERMINATOR):
- case ((SLOW_PROTO_MARKER << 8) + LACP_TLV_TERMINATOR):
- tlv_ptr.lacp_marker_tlv_terminator = (const struct lacp_marker_tlv_terminator_t *)tlv_tptr;
- if (tlv_len == 0) {
- tlv_len = sizeof(tlv_ptr.lacp_marker_tlv_terminator->pad) +
- sizeof(struct tlv_header_t);
- /* tell the user that we modified the length field */
- if (vflag>1)
- printf(" (=%u)",tlv_len);
- /* we have messed around with the length field - now we need to check
- * again if there are enough bytes on the wire for the hexdump */
- TCHECK2(tlv_ptr.lacp_marker_tlv_terminator->pad[0],
- sizeof(tlv_ptr.lacp_marker_tlv_terminator->pad));
- }
+ EXTRACT_32BITS(tlv_ptr.marker_tlv_marker_info->req_trans_id)));
break;
default:
- if (vflag <= 1)
- print_unknown_data(tlv_tptr,"\n\t ",tlv_tlen);
+ if (ndo->ndo_vflag <= 1)
+ print_unknown_data(ndo, tlv_tptr, "\n\t ", tlv_tlen);
break;
}
+
+ badlength:
/* do we want to see an additional hexdump ? */
- if (vflag > 1) {
- print_unknown_data(tptr+sizeof(struct tlv_header_t),"\n\t ",
+ if (ndo->ndo_vflag > 1) {
+ print_unknown_data(ndo, tptr+sizeof(struct tlv_header_t), "\n\t ",
tlv_len-sizeof(struct tlv_header_t));
}
@@ -451,22 +482,29 @@ void slow_marker_lacp_print(register const u_char *tptr, register u_int tlen) {
tlen-=tlv_len;
}
return;
+
+tooshort:
+ ND_PRINT((ndo, "\n\t\t packet is too short"));
+ return;
+
trunc:
- printf("\n\t\t packet exceeded snapshot");
+ ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
}
-void slow_oam_print(register const u_char *tptr, register u_int tlen) {
-
+static void
+slow_oam_print(netdissect_options *ndo,
+ register const u_char *tptr, register u_int tlen)
+{
u_int hexdump;
struct slow_oam_common_header_t {
- u_int8_t flags[2];
- u_int8_t code;
+ uint8_t flags[2];
+ uint8_t code;
};
struct slow_oam_tlv_header_t {
- u_int8_t type;
- u_int8_t length;
+ uint8_t type;
+ uint8_t length;
};
union {
@@ -481,84 +519,100 @@ void slow_oam_print(register const u_char *tptr, register u_int tlen) {
const struct slow_oam_variableresponse_t *slow_oam_variableresponse;
const struct slow_oam_loopbackctrl_t *slow_oam_loopbackctrl;
} tlv;
-
- ptr.slow_oam_common_header = (struct slow_oam_common_header_t *)tptr;
+
+ ptr.slow_oam_common_header = (const struct slow_oam_common_header_t *)tptr;
+ if (tlen < sizeof(*ptr.slow_oam_common_header))
+ goto tooshort;
+ ND_TCHECK(*ptr.slow_oam_common_header);
tptr += sizeof(struct slow_oam_common_header_t);
tlen -= sizeof(struct slow_oam_common_header_t);
- printf("\n\tCode %s OAM PDU, Flags [%s]",
+ ND_PRINT((ndo, "\n\tCode %s OAM PDU, Flags [%s]",
tok2str(slow_oam_code_values, "Unknown (%u)", ptr.slow_oam_common_header->code),
bittok2str(slow_oam_flag_values,
"none",
- EXTRACT_16BITS(&ptr.slow_oam_common_header->flags)));
+ EXTRACT_16BITS(&ptr.slow_oam_common_header->flags))));
switch (ptr.slow_oam_common_header->code) {
case SLOW_OAM_CODE_INFO:
while (tlen > 0) {
ptr.slow_oam_tlv_header = (const struct slow_oam_tlv_header_t *)tptr;
- printf("\n\t %s Information Type (%u), length %u",
+ if (tlen < sizeof(*ptr.slow_oam_tlv_header))
+ goto tooshort;
+ ND_TCHECK(*ptr.slow_oam_tlv_header);
+ ND_PRINT((ndo, "\n\t %s Information Type (%u), length %u",
tok2str(slow_oam_info_type_values, "Reserved",
ptr.slow_oam_tlv_header->type),
ptr.slow_oam_tlv_header->type,
- ptr.slow_oam_tlv_header->length);
+ ptr.slow_oam_tlv_header->length));
+
+ if (ptr.slow_oam_tlv_header->type == SLOW_OAM_INFO_TYPE_END_OF_TLV) {
+ /*
+ * As IEEE Std 802.3-2015 says for the End of TLV Marker,
+ * "(the length and value of the Type 0x00 TLV can be ignored)".
+ */
+ return;
+ }
+
+ /* length includes the type and length fields */
+ if (ptr.slow_oam_tlv_header->length < sizeof(struct slow_oam_tlv_header_t)) {
+ ND_PRINT((ndo, "\n\t ERROR: illegal length - should be >= %u",
+ (u_int)sizeof(struct slow_oam_tlv_header_t)));
+ return;
+ }
+
+ if (tlen < ptr.slow_oam_tlv_header->length)
+ goto tooshort;
+ ND_TCHECK2(*tptr, ptr.slow_oam_tlv_header->length);
hexdump = FALSE;
switch (ptr.slow_oam_tlv_header->type) {
- case SLOW_OAM_INFO_TYPE_END_OF_TLV:
- if (ptr.slow_oam_tlv_header->length != 0) {
- printf("\n\t ERROR: illegal length - should be 0");
- }
- return;
-
case SLOW_OAM_INFO_TYPE_LOCAL: /* identical format - fall through */
case SLOW_OAM_INFO_TYPE_REMOTE:
tlv.slow_oam_info = (const struct slow_oam_info_t *)tptr;
-
+
if (tlv.slow_oam_info->info_length !=
sizeof(struct slow_oam_info_t)) {
- printf("\n\t ERROR: illegal length - should be %lu",
- (unsigned long) sizeof(struct slow_oam_info_t));
- return;
+ ND_PRINT((ndo, "\n\t ERROR: illegal length - should be %lu",
+ (unsigned long) sizeof(struct slow_oam_info_t)));
+ hexdump = TRUE;
+ goto badlength_code_info;
}
- printf("\n\t OAM-Version %u, Revision %u",
+ ND_PRINT((ndo, "\n\t OAM-Version %u, Revision %u",
tlv.slow_oam_info->oam_version,
- EXTRACT_16BITS(&tlv.slow_oam_info->revision));
+ EXTRACT_16BITS(&tlv.slow_oam_info->revision)));
- printf("\n\t State-Parser-Action %s, State-MUX-Action %s",
+ ND_PRINT((ndo, "\n\t State-Parser-Action %s, State-MUX-Action %s",
tok2str(slow_oam_info_type_state_parser_values, "Reserved",
tlv.slow_oam_info->state & OAM_INFO_TYPE_PARSER_MASK),
tok2str(slow_oam_info_type_state_mux_values, "Reserved",
- tlv.slow_oam_info->state & OAM_INFO_TYPE_MUX_MASK));
- printf("\n\t OAM-Config Flags [%s], OAM-PDU-Config max-PDU size %u",
+ tlv.slow_oam_info->state & OAM_INFO_TYPE_MUX_MASK)));
+ ND_PRINT((ndo, "\n\t OAM-Config Flags [%s], OAM-PDU-Config max-PDU size %u",
bittok2str(slow_oam_info_type_oam_config_values, "none",
tlv.slow_oam_info->oam_config),
EXTRACT_16BITS(&tlv.slow_oam_info->oam_pdu_config) &
- OAM_INFO_TYPE_PDU_SIZE_MASK);
- printf("\n\t OUI %s (0x%06x), Vendor-Private 0x%08x",
+ OAM_INFO_TYPE_PDU_SIZE_MASK));
+ ND_PRINT((ndo, "\n\t OUI %s (0x%06x), Vendor-Private 0x%08x",
tok2str(oui_values, "Unknown",
EXTRACT_24BITS(&tlv.slow_oam_info->oui)),
EXTRACT_24BITS(&tlv.slow_oam_info->oui),
- EXTRACT_32BITS(&tlv.slow_oam_info->vendor_private));
+ EXTRACT_32BITS(&tlv.slow_oam_info->vendor_private)));
break;
-
+
case SLOW_OAM_INFO_TYPE_ORG_SPECIFIC:
hexdump = TRUE;
break;
-
+
default:
hexdump = TRUE;
break;
}
- /* infinite loop check */
- if (!ptr.slow_oam_tlv_header->length) {
- return;
- }
-
+ badlength_code_info:
/* do we also want to see a hex dump ? */
- if (vflag > 1 || hexdump==TRUE) {
- print_unknown_data(tptr,"\n\t ",
+ if (ndo->ndo_vflag > 1 || hexdump==TRUE) {
+ print_unknown_data(ndo, tptr, "\n\t ",
ptr.slow_oam_tlv_header->length);
}
@@ -568,36 +622,62 @@ void slow_oam_print(register const u_char *tptr, register u_int tlen) {
break;
case SLOW_OAM_CODE_EVENT_NOTIF:
+ /* Sequence number */
+ if (tlen < 2)
+ goto tooshort;
+ ND_TCHECK2(*tptr, 2);
+ ND_PRINT((ndo, "\n\t Sequence Number %u", EXTRACT_16BITS(tptr)));
+ tlen -= 2;
+ tptr += 2;
+
+ /* TLVs */
while (tlen > 0) {
ptr.slow_oam_tlv_header = (const struct slow_oam_tlv_header_t *)tptr;
- printf("\n\t %s Link Event Type (%u), length %u",
+ if (tlen < sizeof(*ptr.slow_oam_tlv_header))
+ goto tooshort;
+ ND_TCHECK(*ptr.slow_oam_tlv_header);
+ ND_PRINT((ndo, "\n\t %s Link Event Type (%u), length %u",
tok2str(slow_oam_link_event_values, "Reserved",
ptr.slow_oam_tlv_header->type),
ptr.slow_oam_tlv_header->type,
- ptr.slow_oam_tlv_header->length);
+ ptr.slow_oam_tlv_header->length));
+
+ if (ptr.slow_oam_tlv_header->type == SLOW_OAM_INFO_TYPE_END_OF_TLV) {
+ /*
+ * As IEEE Std 802.3-2015 says for the End of TLV Marker,
+ * "(the length and value of the Type 0x00 TLV can be ignored)".
+ */
+ return;
+ }
+
+ /* length includes the type and length fields */
+ if (ptr.slow_oam_tlv_header->length < sizeof(struct slow_oam_tlv_header_t)) {
+ ND_PRINT((ndo, "\n\t ERROR: illegal length - should be >= %u",
+ (u_int)sizeof(struct slow_oam_tlv_header_t)));
+ return;
+ }
+
+ if (tlen < ptr.slow_oam_tlv_header->length)
+ goto tooshort;
+ ND_TCHECK2(*tptr, ptr.slow_oam_tlv_header->length);
hexdump = FALSE;
switch (ptr.slow_oam_tlv_header->type) {
- case SLOW_OAM_LINK_EVENT_END_OF_TLV:
- if (ptr.slow_oam_tlv_header->length != 0) {
- printf("\n\t ERROR: illegal length - should be 0");
- }
- return;
-
case SLOW_OAM_LINK_EVENT_ERR_SYM_PER: /* identical format - fall through */
case SLOW_OAM_LINK_EVENT_ERR_FRM:
case SLOW_OAM_LINK_EVENT_ERR_FRM_PER:
case SLOW_OAM_LINK_EVENT_ERR_FRM_SUMM:
tlv.slow_oam_link_event = (const struct slow_oam_link_event_t *)tptr;
-
+
if (tlv.slow_oam_link_event->event_length !=
sizeof(struct slow_oam_link_event_t)) {
- printf("\n\t ERROR: illegal length - should be %lu",
- (unsigned long) sizeof(struct slow_oam_link_event_t));
- return;
+ ND_PRINT((ndo, "\n\t ERROR: illegal length - should be %lu",
+ (unsigned long) sizeof(struct slow_oam_link_event_t)));
+ hexdump = TRUE;
+ goto badlength_event_notif;
}
- printf("\n\t Timestamp %u ms, Errored Window %" PRIu64
+ ND_PRINT((ndo, "\n\t Timestamp %u ms, Errored Window %" PRIu64
"\n\t Errored Threshold %" PRIu64
"\n\t Errors %" PRIu64
"\n\t Error Running Total %" PRIu64
@@ -607,26 +687,22 @@ void slow_oam_print(register const u_char *tptr, register u_int tlen) {
EXTRACT_64BITS(&tlv.slow_oam_link_event->threshold),
EXTRACT_64BITS(&tlv.slow_oam_link_event->errors),
EXTRACT_64BITS(&tlv.slow_oam_link_event->errors_running_total),
- EXTRACT_32BITS(&tlv.slow_oam_link_event->event_running_total));
+ EXTRACT_32BITS(&tlv.slow_oam_link_event->event_running_total)));
break;
-
+
case SLOW_OAM_LINK_EVENT_ORG_SPECIFIC:
hexdump = TRUE;
break;
-
+
default:
hexdump = TRUE;
break;
}
- /* infinite loop check */
- if (!ptr.slow_oam_tlv_header->length) {
- return;
- }
-
+ badlength_event_notif:
/* do we also want to see a hex dump ? */
- if (vflag > 1 || hexdump==TRUE) {
- print_unknown_data(tptr,"\n\t ",
+ if (ndo->ndo_vflag > 1 || hexdump==TRUE) {
+ print_unknown_data(ndo, tptr, "\n\t ",
ptr.slow_oam_tlv_header->length);
}
@@ -634,16 +710,19 @@ void slow_oam_print(register const u_char *tptr, register u_int tlen) {
tptr += ptr.slow_oam_tlv_header->length;
}
break;
-
+
case SLOW_OAM_CODE_LOOPBACK_CTRL:
tlv.slow_oam_loopbackctrl = (const struct slow_oam_loopbackctrl_t *)tptr;
- printf("\n\t Command %s (%u)",
+ if (tlen < sizeof(*tlv.slow_oam_loopbackctrl))
+ goto tooshort;
+ ND_TCHECK(*tlv.slow_oam_loopbackctrl);
+ ND_PRINT((ndo, "\n\t Command %s (%u)",
tok2str(slow_oam_loopbackctrl_cmd_values,
"Unknown",
tlv.slow_oam_loopbackctrl->command),
- tlv.slow_oam_loopbackctrl->command);
- tptr ++;
- tlen --;
+ tlv.slow_oam_loopbackctrl->command));
+ tptr ++;
+ tlen --;
break;
/*
@@ -654,10 +733,20 @@ void slow_oam_print(register const u_char *tptr, register u_int tlen) {
case SLOW_OAM_CODE_VAR_RESPONSE:
case SLOW_OAM_CODE_PRIVATE:
default:
- if (vflag <= 1) {
- print_unknown_data(tptr,"\n\t ", tlen);
+ if (ndo->ndo_vflag <= 1) {
+ print_unknown_data(ndo, tptr, "\n\t ", tlen);
}
break;
}
return;
+
+tooshort:
+ ND_PRINT((ndo, "\n\t\t packet is too short"));
+ return;
+
+trunc:
+ ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-slow-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-smb.c b/freebsd/contrib/tcpdump/print-smb.c
index ba826762..4c93541b 100644
--- a/freebsd/contrib/tcpdump/print-smb.c
+++ b/freebsd/contrib/tcpdump/print-smb.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (C) Andrew Tridgell 1995-1999
*
@@ -8,24 +11,22 @@
* or later
*/
+/* \summary: SMB/CIFS printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-smb.c,v 1.47 2007-12-09 00:30:47 guy Exp $";
-#endif
+#include <netdissect-stdinc.h>
-#include <tcpdump-stdinc.h>
-
-#include <stdio.h>
#include <string.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
#include "smb.h"
+static const char tstr[] = "[|SMB]";
+
static int request = 0;
static int unicodestr = 0;
@@ -36,7 +37,7 @@ struct smbdescript {
const char *req_f2;
const char *rep_f1;
const char *rep_f2;
- void (*fn)(const u_char *, const u_char *, const u_char *, const u_char *);
+ void (*fn)(netdissect_options *, const u_char *, const u_char *, const u_char *, const u_char *);
};
struct smbdescriptint {
@@ -44,7 +45,7 @@ struct smbdescriptint {
const char *req_f2;
const char *rep_f1;
const char *rep_f2;
- void (*fn)(const u_char *, const u_char *, int, int);
+ void (*fn)(netdissect_options *, const u_char *, const u_char *, int, int);
};
struct smbfns
@@ -67,8 +68,8 @@ struct smbfnsint
#define FLG_CHAIN (1 << 0)
-static struct smbfns *
-smbfind(int id, struct smbfns *list)
+static const struct smbfns *
+smbfind(int id, const struct smbfns *list)
{
int sindex;
@@ -79,8 +80,8 @@ smbfind(int id, struct smbfns *list)
return(&list[0]);
}
-static struct smbfnsint *
-smbfindint(int id, struct smbfnsint *list)
+static const struct smbfnsint *
+smbfindint(int id, const struct smbfnsint *list)
{
int sindex;
@@ -92,7 +93,8 @@ smbfindint(int id, struct smbfnsint *list)
}
static void
-trans2_findfirst(const u_char *param, const u_char *data, int pcnt, int dcnt)
+trans2_findfirst(netdissect_options *ndo,
+ const u_char *param, const u_char *data, int pcnt, int dcnt)
{
const char *fmt;
@@ -101,24 +103,25 @@ trans2_findfirst(const u_char *param, const u_char *data, int pcnt, int dcnt)
else
fmt = "Handle=[w]\nCount=[d]\nEOS=[w]\nEoffset=[d]\nLastNameOfs=[w]\n";
- smb_fdata(param, fmt, param + pcnt, unicodestr);
+ smb_fdata(ndo, param, fmt, param + pcnt, unicodestr);
if (dcnt) {
- printf("data:\n");
- print_data(data, dcnt);
+ ND_PRINT((ndo, "data:\n"));
+ smb_print_data(ndo, data, dcnt);
}
}
static void
-trans2_qfsinfo(const u_char *param, const u_char *data, int pcnt, int dcnt)
+trans2_qfsinfo(netdissect_options *ndo,
+ const u_char *param, const u_char *data, int pcnt, int dcnt)
{
static int level = 0;
const char *fmt="";
if (request) {
- TCHECK2(*param, 2);
+ ND_TCHECK2(*param, 2);
level = EXTRACT_LE_16BITS(param);
fmt = "InfoLevel=[d]\n";
- smb_fdata(param, fmt, param + pcnt, unicodestr);
+ smb_fdata(ndo, param, fmt, param + pcnt, unicodestr);
} else {
switch (level) {
case 1:
@@ -134,19 +137,18 @@ trans2_qfsinfo(const u_char *param, const u_char *data, int pcnt, int dcnt)
fmt = "UnknownLevel\n";
break;
}
- smb_fdata(data, fmt, data + dcnt, unicodestr);
+ smb_fdata(ndo, data, fmt, data + dcnt, unicodestr);
}
if (dcnt) {
- printf("data:\n");
- print_data(data, dcnt);
+ ND_PRINT((ndo, "data:\n"));
+ smb_print_data(ndo, data, dcnt);
}
return;
trunc:
- printf("[|SMB]");
- return;
+ ND_PRINT((ndo, "%s", tstr));
}
-struct smbfnsint trans2_fns[] = {
+static const struct smbfnsint trans2_fns[] = {
{ 0, "TRANSACT2_OPEN", 0,
{ "Flags2=[w]\nMode=[w]\nSearchAttrib=[A]\nAttrib=[A]\nTime=[T2]\nOFun=[w]\nSize=[D]\nRes=([w, w, w, w, w])\nPath=[S]",
NULL,
@@ -172,18 +174,19 @@ struct smbfnsint trans2_fns[] = {
static void
-print_trans2(const u_char *words, const u_char *dat, const u_char *buf, const u_char *maxbuf)
+print_trans2(netdissect_options *ndo,
+ const u_char *words, const u_char *dat, const u_char *buf, const u_char *maxbuf)
{
u_int bcc;
- static struct smbfnsint *fn = &trans2_fns[0];
+ static const struct smbfnsint *fn = &trans2_fns[0];
const u_char *data, *param;
const u_char *w = words + 1;
const char *f1 = NULL, *f2 = NULL;
int pcnt, dcnt;
- TCHECK(words[0]);
+ ND_TCHECK(words[0]);
if (request) {
- TCHECK2(w[14 * 2], 2);
+ ND_TCHECK2(w[14 * 2], 2);
pcnt = EXTRACT_LE_16BITS(w + 9 * 2);
param = buf + EXTRACT_LE_16BITS(w + 10 * 2);
dcnt = EXTRACT_LE_16BITS(w + 11 * 2);
@@ -191,151 +194,151 @@ print_trans2(const u_char *words, const u_char *dat, const u_char *buf, const u_
fn = smbfindint(EXTRACT_LE_16BITS(w + 14 * 2), trans2_fns);
} else {
if (words[0] == 0) {
- printf("%s\n", fn->name);
- printf("Trans2Interim\n");
+ ND_PRINT((ndo, "%s\n", fn->name));
+ ND_PRINT((ndo, "Trans2Interim\n"));
return;
}
- TCHECK2(w[7 * 2], 2);
+ ND_TCHECK2(w[7 * 2], 2);
pcnt = EXTRACT_LE_16BITS(w + 3 * 2);
param = buf + EXTRACT_LE_16BITS(w + 4 * 2);
dcnt = EXTRACT_LE_16BITS(w + 6 * 2);
data = buf + EXTRACT_LE_16BITS(w + 7 * 2);
}
- printf("%s param_length=%d data_length=%d\n", fn->name, pcnt, dcnt);
+ ND_PRINT((ndo, "%s param_length=%d data_length=%d\n", fn->name, pcnt, dcnt));
if (request) {
if (words[0] == 8) {
- smb_fdata(words + 1,
+ smb_fdata(ndo, words + 1,
"Trans2Secondary\nTotParam=[d]\nTotData=[d]\nParamCnt=[d]\nParamOff=[d]\nParamDisp=[d]\nDataCnt=[d]\nDataOff=[d]\nDataDisp=[d]\nHandle=[d]\n",
maxbuf, unicodestr);
return;
} else {
- smb_fdata(words + 1,
+ smb_fdata(ndo, words + 1,
"TotParam=[d]\nTotData=[d]\nMaxParam=[d]\nMaxData=[d]\nMaxSetup=[b][P1]\nFlags=[w]\nTimeOut=[D]\nRes1=[w]\nParamCnt=[d]\nParamOff=[d]\nDataCnt=[d]\nDataOff=[d]\nSetupCnt=[b][P1]\n",
words + 1 + 14 * 2, unicodestr);
}
f1 = fn->descript.req_f1;
f2 = fn->descript.req_f2;
} else {
- smb_fdata(words + 1,
+ smb_fdata(ndo, words + 1,
"TotParam=[d]\nTotData=[d]\nRes1=[w]\nParamCnt=[d]\nParamOff=[d]\nParamDisp[d]\nDataCnt=[d]\nDataOff=[d]\nDataDisp=[d]\nSetupCnt=[b][P1]\n",
words + 1 + 10 * 2, unicodestr);
f1 = fn->descript.rep_f1;
f2 = fn->descript.rep_f2;
}
- TCHECK2(*dat, 2);
+ ND_TCHECK2(*dat, 2);
bcc = EXTRACT_LE_16BITS(dat);
- printf("smb_bcc=%u\n", bcc);
+ ND_PRINT((ndo, "smb_bcc=%u\n", bcc));
if (fn->descript.fn)
- (*fn->descript.fn)(param, data, pcnt, dcnt);
+ (*fn->descript.fn)(ndo, param, data, pcnt, dcnt);
else {
- smb_fdata(param, f1 ? f1 : "Parameters=\n", param + pcnt, unicodestr);
- smb_fdata(data, f2 ? f2 : "Data=\n", data + dcnt, unicodestr);
+ smb_fdata(ndo, param, f1 ? f1 : "Parameters=\n", param + pcnt, unicodestr);
+ smb_fdata(ndo, data, f2 ? f2 : "Data=\n", data + dcnt, unicodestr);
}
return;
trunc:
- printf("[|SMB]");
- return;
+ ND_PRINT((ndo, "%s", tstr));
}
-
static void
-print_browse(const u_char *param, int paramlen, const u_char *data, int datalen)
+print_browse(netdissect_options *ndo,
+ const u_char *param, int paramlen, const u_char *data, int datalen)
{
const u_char *maxbuf = data + datalen;
int command;
- TCHECK(data[0]);
+ ND_TCHECK(data[0]);
command = data[0];
- smb_fdata(param, "BROWSE PACKET\n|Param ", param+paramlen, unicodestr);
+ smb_fdata(ndo, param, "BROWSE PACKET\n|Param ", param+paramlen, unicodestr);
switch (command) {
case 0xF:
- data = smb_fdata(data,
+ data = smb_fdata(ndo, data,
"BROWSE PACKET:\nType=[B] (LocalMasterAnnouncement)\nUpdateCount=[w]\nRes1=[B]\nAnnounceInterval=[d]\nName=[n2]\nMajorVersion=[B]\nMinorVersion=[B]\nServerType=[W]\nElectionVersion=[w]\nBrowserConstant=[w]\n",
maxbuf, unicodestr);
break;
case 0x1:
- data = smb_fdata(data,
+ data = smb_fdata(ndo, data,
"BROWSE PACKET:\nType=[B] (HostAnnouncement)\nUpdateCount=[w]\nRes1=[B]\nAnnounceInterval=[d]\nName=[n2]\nMajorVersion=[B]\nMinorVersion=[B]\nServerType=[W]\nElectionVersion=[w]\nBrowserConstant=[w]\n",
maxbuf, unicodestr);
break;
case 0x2:
- data = smb_fdata(data,
+ data = smb_fdata(ndo, data,
"BROWSE PACKET:\nType=[B] (AnnouncementRequest)\nFlags=[B]\nReplySystemName=[S]\n",
maxbuf, unicodestr);
break;
case 0xc:
- data = smb_fdata(data,
+ data = smb_fdata(ndo, data,
"BROWSE PACKET:\nType=[B] (WorkgroupAnnouncement)\nUpdateCount=[w]\nRes1=[B]\nAnnounceInterval=[d]\nName=[n2]\nMajorVersion=[B]\nMinorVersion=[B]\nServerType=[W]\nCommentPointer=[W]\nServerName=[S]\n",
maxbuf, unicodestr);
break;
case 0x8:
- data = smb_fdata(data,
+ data = smb_fdata(ndo, data,
"BROWSE PACKET:\nType=[B] (ElectionFrame)\nElectionVersion=[B]\nOSSummary=[W]\nUptime=[(W, W)]\nServerName=[S]\n",
maxbuf, unicodestr);
break;
case 0xb:
- data = smb_fdata(data,
+ data = smb_fdata(ndo, data,
"BROWSE PACKET:\nType=[B] (BecomeBackupBrowser)\nName=[S]\n",
maxbuf, unicodestr);
break;
case 0x9:
- data = smb_fdata(data,
+ data = smb_fdata(ndo, data,
"BROWSE PACKET:\nType=[B] (GetBackupList)\nListCount?=[B]\nToken=[W]\n",
maxbuf, unicodestr);
break;
case 0xa:
- data = smb_fdata(data,
+ data = smb_fdata(ndo, data,
"BROWSE PACKET:\nType=[B] (BackupListResponse)\nServerCount?=[B]\nToken=[W]\n*Name=[S]\n",
maxbuf, unicodestr);
break;
case 0xd:
- data = smb_fdata(data,
+ data = smb_fdata(ndo, data,
"BROWSE PACKET:\nType=[B] (MasterAnnouncement)\nMasterName=[S]\n",
maxbuf, unicodestr);
break;
case 0xe:
- data = smb_fdata(data,
+ data = smb_fdata(ndo, data,
"BROWSE PACKET:\nType=[B] (ResetBrowser)\nOptions=[B]\n", maxbuf, unicodestr);
break;
default:
- data = smb_fdata(data, "Unknown Browser Frame ", maxbuf, unicodestr);
+ data = smb_fdata(ndo, data, "Unknown Browser Frame ", maxbuf, unicodestr);
break;
}
return;
trunc:
- printf("[|SMB]");
- return;
+ ND_PRINT((ndo, "%s", tstr));
}
static void
-print_ipc(const u_char *param, int paramlen, const u_char *data, int datalen)
+print_ipc(netdissect_options *ndo,
+ const u_char *param, int paramlen, const u_char *data, int datalen)
{
if (paramlen)
- smb_fdata(param, "Command=[w]\nStr1=[S]\nStr2=[S]\n", param + paramlen,
+ smb_fdata(ndo, param, "Command=[w]\nStr1=[S]\nStr2=[S]\n", param + paramlen,
unicodestr);
if (datalen)
- smb_fdata(data, "IPC ", data + datalen, unicodestr);
+ smb_fdata(ndo, data, "IPC ", data + datalen, unicodestr);
}
static void
-print_trans(const u_char *words, const u_char *data1, const u_char *buf, const u_char *maxbuf)
+print_trans(netdissect_options *ndo,
+ const u_char *words, const u_char *data1, const u_char *buf, const u_char *maxbuf)
{
u_int bcc;
const char *f1, *f2, *f3, *f4;
@@ -344,7 +347,7 @@ print_trans(const u_char *words, const u_char *data1, const u_char *buf, const u
int datalen, paramlen;
if (request) {
- TCHECK2(w[12 * 2], 2);
+ ND_TCHECK2(w[12 * 2], 2);
paramlen = EXTRACT_LE_16BITS(w + 9 * 2);
param = buf + EXTRACT_LE_16BITS(w + 10 * 2);
datalen = EXTRACT_LE_16BITS(w + 11 * 2);
@@ -354,7 +357,7 @@ print_trans(const u_char *words, const u_char *data1, const u_char *buf, const u
f3 = "|Param ";
f4 = "|Data ";
} else {
- TCHECK2(w[7 * 2], 2);
+ ND_TCHECK2(w[7 * 2], 2);
paramlen = EXTRACT_LE_16BITS(w + 3 * 2);
param = buf + EXTRACT_LE_16BITS(w + 4 * 2);
datalen = EXTRACT_LE_16BITS(w + 6 * 2);
@@ -365,44 +368,44 @@ print_trans(const u_char *words, const u_char *data1, const u_char *buf, const u
f4 = "|Data ";
}
- smb_fdata(words + 1, f1, SMBMIN(words + 1 + 2 * words[0], maxbuf),
+ smb_fdata(ndo, words + 1, f1, min(words + 1 + 2 * words[0], maxbuf),
unicodestr);
- TCHECK2(*data1, 2);
+ ND_TCHECK2(*data1, 2);
bcc = EXTRACT_LE_16BITS(data1);
- printf("smb_bcc=%u\n", bcc);
+ ND_PRINT((ndo, "smb_bcc=%u\n", bcc));
if (bcc > 0) {
- smb_fdata(data1 + 2, f2, maxbuf - (paramlen + datalen), unicodestr);
+ smb_fdata(ndo, data1 + 2, f2, maxbuf - (paramlen + datalen), unicodestr);
if (strcmp((const char *)(data1 + 2), "\\MAILSLOT\\BROWSE") == 0) {
- print_browse(param, paramlen, data, datalen);
+ print_browse(ndo, param, paramlen, data, datalen);
return;
}
if (strcmp((const char *)(data1 + 2), "\\PIPE\\LANMAN") == 0) {
- print_ipc(param, paramlen, data, datalen);
+ print_ipc(ndo, param, paramlen, data, datalen);
return;
}
if (paramlen)
- smb_fdata(param, f3, SMBMIN(param + paramlen, maxbuf), unicodestr);
+ smb_fdata(ndo, param, f3, min(param + paramlen, maxbuf), unicodestr);
if (datalen)
- smb_fdata(data, f4, SMBMIN(data + datalen, maxbuf), unicodestr);
+ smb_fdata(ndo, data, f4, min(data + datalen, maxbuf), unicodestr);
}
return;
trunc:
- printf("[|SMB]");
- return;
+ ND_PRINT((ndo, "%s", tstr));
}
static void
-print_negprot(const u_char *words, const u_char *data, const u_char *buf _U_, const u_char *maxbuf)
+print_negprot(netdissect_options *ndo,
+ const u_char *words, const u_char *data, const u_char *buf _U_, const u_char *maxbuf)
{
u_int wct, bcc;
const char *f1 = NULL, *f2 = NULL;
- TCHECK(words[0]);
+ ND_TCHECK(words[0]);
wct = words[0];
if (request)
f2 = "*|Dialect=[Y]\n";
@@ -416,34 +419,34 @@ print_negprot(const u_char *words, const u_char *data, const u_char *buf _U_, co
}
if (f1)
- smb_fdata(words + 1, f1, SMBMIN(words + 1 + wct * 2, maxbuf),
+ smb_fdata(ndo, words + 1, f1, min(words + 1 + wct * 2, maxbuf),
unicodestr);
else
- print_data(words + 1, SMBMIN(wct * 2, PTR_DIFF(maxbuf, words + 1)));
+ smb_print_data(ndo, words + 1, min(wct * 2, PTR_DIFF(maxbuf, words + 1)));
- TCHECK2(*data, 2);
+ ND_TCHECK2(*data, 2);
bcc = EXTRACT_LE_16BITS(data);
- printf("smb_bcc=%u\n", bcc);
+ ND_PRINT((ndo, "smb_bcc=%u\n", bcc));
if (bcc > 0) {
if (f2)
- smb_fdata(data + 2, f2, SMBMIN(data + 2 + EXTRACT_LE_16BITS(data),
+ smb_fdata(ndo, data + 2, f2, min(data + 2 + EXTRACT_LE_16BITS(data),
maxbuf), unicodestr);
else
- print_data(data + 2, SMBMIN(EXTRACT_LE_16BITS(data), PTR_DIFF(maxbuf, data + 2)));
+ smb_print_data(ndo, data + 2, min(EXTRACT_LE_16BITS(data), PTR_DIFF(maxbuf, data + 2)));
}
return;
trunc:
- printf("[|SMB]");
- return;
+ ND_PRINT((ndo, "%s", tstr));
}
static void
-print_sesssetup(const u_char *words, const u_char *data, const u_char *buf _U_, const u_char *maxbuf)
+print_sesssetup(netdissect_options *ndo,
+ const u_char *words, const u_char *data, const u_char *buf _U_, const u_char *maxbuf)
{
u_int wct, bcc;
const char *f1 = NULL, *f2 = NULL;
- TCHECK(words[0]);
+ ND_TCHECK(words[0]);
wct = words[0];
if (request) {
if (wct == 10)
@@ -460,39 +463,39 @@ print_sesssetup(const u_char *words, const u_char *data, const u_char *buf _U_,
}
if (f1)
- smb_fdata(words + 1, f1, SMBMIN(words + 1 + wct * 2, maxbuf),
+ smb_fdata(ndo, words + 1, f1, min(words + 1 + wct * 2, maxbuf),
unicodestr);
else
- print_data(words + 1, SMBMIN(wct * 2, PTR_DIFF(maxbuf, words + 1)));
+ smb_print_data(ndo, words + 1, min(wct * 2, PTR_DIFF(maxbuf, words + 1)));
- TCHECK2(*data, 2);
+ ND_TCHECK2(*data, 2);
bcc = EXTRACT_LE_16BITS(data);
- printf("smb_bcc=%u\n", bcc);
+ ND_PRINT((ndo, "smb_bcc=%u\n", bcc));
if (bcc > 0) {
if (f2)
- smb_fdata(data + 2, f2, SMBMIN(data + 2 + EXTRACT_LE_16BITS(data),
+ smb_fdata(ndo, data + 2, f2, min(data + 2 + EXTRACT_LE_16BITS(data),
maxbuf), unicodestr);
else
- print_data(data + 2, SMBMIN(EXTRACT_LE_16BITS(data), PTR_DIFF(maxbuf, data + 2)));
+ smb_print_data(ndo, data + 2, min(EXTRACT_LE_16BITS(data), PTR_DIFF(maxbuf, data + 2)));
}
return;
trunc:
- printf("[|SMB]");
- return;
+ ND_PRINT((ndo, "%s", tstr));
}
static void
-print_lockingandx(const u_char *words, const u_char *data, const u_char *buf _U_, const u_char *maxbuf)
+print_lockingandx(netdissect_options *ndo,
+ const u_char *words, const u_char *data, const u_char *buf _U_, const u_char *maxbuf)
{
u_int wct, bcc;
const u_char *maxwords;
const char *f1 = NULL, *f2 = NULL;
- TCHECK(words[0]);
+ ND_TCHECK(words[0]);
wct = words[0];
if (request) {
f1 = "Com2=[w]\nOff2=[d]\nHandle=[d]\nLockType=[w]\nTimeOut=[D]\nUnlockCount=[d]\nLockCount=[d]\n";
- TCHECK(words[7]);
+ ND_TCHECK(words[7]);
if (words[7] & 0x10)
f2 = "*Process=[d]\n[P2]Offset=[M]\nLength=[M]\n";
else
@@ -501,28 +504,27 @@ print_lockingandx(const u_char *words, const u_char *data, const u_char *buf _U_
f1 = "Com2=[w]\nOff2=[d]\n";
}
- maxwords = SMBMIN(words + 1 + wct * 2, maxbuf);
+ maxwords = min(words + 1 + wct * 2, maxbuf);
if (wct)
- smb_fdata(words + 1, f1, maxwords, unicodestr);
+ smb_fdata(ndo, words + 1, f1, maxwords, unicodestr);
- TCHECK2(*data, 2);
+ ND_TCHECK2(*data, 2);
bcc = EXTRACT_LE_16BITS(data);
- printf("smb_bcc=%u\n", bcc);
+ ND_PRINT((ndo, "smb_bcc=%u\n", bcc));
if (bcc > 0) {
if (f2)
- smb_fdata(data + 2, f2, SMBMIN(data + 2 + EXTRACT_LE_16BITS(data),
+ smb_fdata(ndo, data + 2, f2, min(data + 2 + EXTRACT_LE_16BITS(data),
maxbuf), unicodestr);
else
- print_data(data + 2, SMBMIN(EXTRACT_LE_16BITS(data), PTR_DIFF(maxbuf, data + 2)));
+ smb_print_data(ndo, data + 2, min(EXTRACT_LE_16BITS(data), PTR_DIFF(maxbuf, data + 2)));
}
return;
trunc:
- printf("[|SMB]");
- return;
+ ND_PRINT((ndo, "%s", tstr));
}
-static struct smbfns smb_fns[] = {
+static const struct smbfns smb_fns[] = {
{ -1, "SMBunknown", 0, DEFDESCRIPT },
{ SMBtcon, "SMBtcon", 0,
@@ -794,47 +796,50 @@ static struct smbfns smb_fns[] = {
* print a SMB message
*/
static void
-print_smb(const u_char *buf, const u_char *maxbuf)
+print_smb(netdissect_options *ndo,
+ const u_char *buf, const u_char *maxbuf)
{
- u_int16_t flags2;
+ uint16_t flags2;
int nterrcodes;
int command;
- u_int32_t nterror;
+ uint32_t nterror;
const u_char *words, *maxwords, *data;
- struct smbfns *fn;
+ const struct smbfns *fn;
const char *fmt_smbheader =
"[P4]SMB Command = [B]\nError class = [BP1]\nError code = [d]\nFlags1 = [B]\nFlags2 = [B][P13]\nTree ID = [d]\nProc ID = [d]\nUID = [d]\nMID = [d]\nWord Count = [b]\n";
int smboffset;
- TCHECK(buf[9]);
+ ND_TCHECK(buf[9]);
request = (buf[9] & 0x80) ? 0 : 1;
- flags2 = EXTRACT_LE_16BITS(&buf[10]);
- unicodestr = flags2 & 0x8000;
- nterrcodes = flags2 & 0x4000;
startbuf = buf;
command = buf[4];
fn = smbfind(command, smb_fns);
- if (vflag > 1)
- printf("\n");
+ if (ndo->ndo_vflag > 1)
+ ND_PRINT((ndo, "\n"));
- printf("SMB PACKET: %s (%s)\n", fn->name, request ? "REQUEST" : "REPLY");
+ ND_PRINT((ndo, "SMB PACKET: %s (%s)\n", fn->name, request ? "REQUEST" : "REPLY"));
- if (vflag < 2)
+ if (ndo->ndo_vflag < 2)
return;
+ ND_TCHECK_16BITS(&buf[10]);
+ flags2 = EXTRACT_LE_16BITS(&buf[10]);
+ unicodestr = flags2 & 0x8000;
+ nterrcodes = flags2 & 0x4000;
+
/* print out the header */
- smb_fdata(buf, fmt_smbheader, buf + 33, unicodestr);
+ smb_fdata(ndo, buf, fmt_smbheader, buf + 33, unicodestr);
if (nterrcodes) {
nterror = EXTRACT_LE_32BITS(&buf[5]);
if (nterror)
- printf("NTError = %s\n", nt_errstr(nterror));
+ ND_PRINT((ndo, "NTError = %s\n", nt_errstr(nterror)));
} else {
if (buf[5])
- printf("SMBError = %s\n", smb_errstr(buf[5], EXTRACT_LE_16BITS(&buf[7])));
+ ND_PRINT((ndo, "SMBError = %s\n", smb_errstr(buf[5], EXTRACT_LE_16BITS(&buf[7]))));
}
smboffset = 32;
@@ -846,10 +851,10 @@ print_smb(const u_char *buf, const u_char *maxbuf)
int newsmboffset;
words = buf + smboffset;
- TCHECK(words[0]);
+ ND_TCHECK(words[0]);
wct = words[0];
data = words + 1 + wct * 2;
- maxwords = SMBMIN(data, maxbuf);
+ maxwords = min(data, maxbuf);
if (request) {
f1 = fn->descript.req_f1;
@@ -860,33 +865,33 @@ print_smb(const u_char *buf, const u_char *maxbuf)
}
if (fn->descript.fn)
- (*fn->descript.fn)(words, data, buf, maxbuf);
+ (*fn->descript.fn)(ndo, words, data, buf, maxbuf);
else {
if (wct) {
if (f1)
- smb_fdata(words + 1, f1, words + 1 + wct * 2, unicodestr);
+ smb_fdata(ndo, words + 1, f1, words + 1 + wct * 2, unicodestr);
else {
int i;
int v;
for (i = 0; &words[1 + 2 * i] < maxwords; i++) {
- TCHECK2(words[1 + 2 * i], 2);
+ ND_TCHECK2(words[1 + 2 * i], 2);
v = EXTRACT_LE_16BITS(words + 1 + 2 * i);
- printf("smb_vwv[%d]=%d (0x%X)\n", i, v, v);
+ ND_PRINT((ndo, "smb_vwv[%d]=%d (0x%X)\n", i, v, v));
}
}
}
- TCHECK2(*data, 2);
+ ND_TCHECK2(*data, 2);
bcc = EXTRACT_LE_16BITS(data);
- printf("smb_bcc=%u\n", bcc);
+ ND_PRINT((ndo, "smb_bcc=%u\n", bcc));
if (f2) {
if (bcc > 0)
- smb_fdata(data + 2, f2, data + 2 + bcc, unicodestr);
+ smb_fdata(ndo, data + 2, f2, data + 2 + bcc, unicodestr);
} else {
if (bcc > 0) {
- printf("smb_buf[]=\n");
- print_data(data + 2, SMBMIN(bcc, PTR_DIFF(maxbuf, data + 2)));
+ ND_PRINT((ndo, "smb_buf[]=\n"));
+ smb_print_data(ndo, data + 2, min(bcc, PTR_DIFF(maxbuf, data + 2)));
}
}
}
@@ -895,29 +900,28 @@ print_smb(const u_char *buf, const u_char *maxbuf)
break;
if (wct == 0)
break;
- TCHECK(words[1]);
+ ND_TCHECK(words[1]);
command = words[1];
if (command == 0xFF)
break;
- TCHECK2(words[3], 2);
- newsmboffset = EXTRACT_LE_16BITS(words + 3);
+ ND_TCHECK2(words[3], 2);
+ newsmboffset = EXTRACT_LE_16BITS(words + 3);
fn = smbfind(command, smb_fns);
- printf("\nSMB PACKET: %s (%s) (CHAINED)\n",
- fn->name, request ? "REQUEST" : "REPLY");
+ ND_PRINT((ndo, "\nSMB PACKET: %s (%s) (CHAINED)\n",
+ fn->name, request ? "REQUEST" : "REPLY"));
if (newsmboffset <= smboffset) {
- printf("Bad andX offset: %u <= %u\n", newsmboffset, smboffset);
+ ND_PRINT((ndo, "Bad andX offset: %u <= %u\n", newsmboffset, smboffset));
break;
}
smboffset = newsmboffset;
}
- printf("\n");
+ ND_PRINT((ndo, "\n"));
return;
trunc:
- printf("[|SMB]");
- return;
+ ND_PRINT((ndo, "%s", tstr));
}
@@ -925,7 +929,8 @@ trunc:
* print a NBT packet received across tcp on port 139
*/
void
-nbt_tcp_print(const u_char *data, int length)
+nbt_tcp_print(netdissect_options *ndo,
+ const u_char *data, int length)
{
int caplen;
int type;
@@ -934,9 +939,9 @@ nbt_tcp_print(const u_char *data, int length)
if (length < 4)
goto trunc;
- if (snapend < data)
+ if (ndo->ndo_snapend < data)
goto trunc;
- caplen = snapend - data;
+ caplen = ndo->ndo_snapend - data;
if (caplen < 4)
goto trunc;
maxbuf = data + caplen;
@@ -947,19 +952,19 @@ nbt_tcp_print(const u_char *data, int length)
startbuf = data;
- if (vflag < 2) {
- printf(" NBT Session Packet: ");
+ if (ndo->ndo_vflag < 2) {
+ ND_PRINT((ndo, " NBT Session Packet: "));
switch (type) {
case 0x00:
- printf("Session Message");
+ ND_PRINT((ndo, "Session Message"));
break;
case 0x81:
- printf("Session Request");
+ ND_PRINT((ndo, "Session Request"));
break;
case 0x82:
- printf("Session Granted");
+ ND_PRINT((ndo, "Session Granted"));
break;
case 0x83:
@@ -974,64 +979,64 @@ nbt_tcp_print(const u_char *data, int length)
goto trunc;
ecode = data[4];
- printf("Session Reject, ");
+ ND_PRINT((ndo, "Session Reject, "));
switch (ecode) {
case 0x80:
- printf("Not listening on called name");
+ ND_PRINT((ndo, "Not listening on called name"));
break;
case 0x81:
- printf("Not listening for calling name");
+ ND_PRINT((ndo, "Not listening for calling name"));
break;
case 0x82:
- printf("Called name not present");
+ ND_PRINT((ndo, "Called name not present"));
break;
case 0x83:
- printf("Called name present, but insufficient resources");
+ ND_PRINT((ndo, "Called name present, but insufficient resources"));
break;
default:
- printf("Unspecified error 0x%X", ecode);
+ ND_PRINT((ndo, "Unspecified error 0x%X", ecode));
break;
}
}
break;
case 0x85:
- printf("Session Keepalive");
+ ND_PRINT((ndo, "Session Keepalive"));
break;
default:
- data = smb_fdata(data, "Unknown packet type [rB]", maxbuf, 0);
+ data = smb_fdata(ndo, data, "Unknown packet type [rB]", maxbuf, 0);
break;
}
} else {
- printf ("\n>>> NBT Session Packet\n");
+ ND_PRINT((ndo, "\n>>> NBT Session Packet\n"));
switch (type) {
case 0x00:
- data = smb_fdata(data, "[P1]NBT Session Message\nFlags=[B]\nLength=[rd]\n",
+ data = smb_fdata(ndo, data, "[P1]NBT Session Message\nFlags=[B]\nLength=[rd]\n",
data + 4, 0);
if (data == NULL)
break;
if (nbt_len >= 4 && caplen >= 4 && memcmp(data,"\377SMB",4) == 0) {
if ((int)nbt_len > caplen) {
if ((int)nbt_len > length)
- printf("WARNING: Packet is continued in later TCP segments\n");
+ ND_PRINT((ndo, "WARNING: Packet is continued in later TCP segments\n"));
else
- printf("WARNING: Short packet. Try increasing the snap length by %d\n",
- nbt_len - caplen);
+ ND_PRINT((ndo, "WARNING: Short packet. Try increasing the snap length by %d\n",
+ nbt_len - caplen));
}
- print_smb(data, maxbuf > data + nbt_len ? data + nbt_len : maxbuf);
+ print_smb(ndo, data, maxbuf > data + nbt_len ? data + nbt_len : maxbuf);
} else
- printf("Session packet:(raw data or continuation?)\n");
+ ND_PRINT((ndo, "Session packet:(raw data or continuation?)\n"));
break;
case 0x81:
- data = smb_fdata(data,
+ data = smb_fdata(ndo, data,
"[P1]NBT Session Request\nFlags=[B]\nLength=[rd]\nDestination=[n1]\nSource=[n1]\n",
maxbuf, 0);
break;
case 0x82:
- data = smb_fdata(data, "[P1]NBT Session Granted\nFlags=[B]\nLength=[rd]\n", maxbuf, 0);
+ data = smb_fdata(ndo, data, "[P1]NBT Session Granted\nFlags=[B]\nLength=[rd]\n", maxbuf, 0);
break;
case 0x83:
@@ -1040,7 +1045,7 @@ nbt_tcp_print(const u_char *data, int length)
int ecode;
origdata = data;
- data = smb_fdata(data, "[P1]NBT SessionReject\nFlags=[B]\nLength=[rd]\nReason=[B]\n",
+ data = smb_fdata(ndo, data, "[P1]NBT SessionReject\nFlags=[B]\nLength=[rd]\nReason=[B]\n",
maxbuf, 0);
if (data == NULL)
break;
@@ -1048,19 +1053,19 @@ nbt_tcp_print(const u_char *data, int length)
ecode = origdata[4];
switch (ecode) {
case 0x80:
- printf("Not listening on called name\n");
+ ND_PRINT((ndo, "Not listening on called name\n"));
break;
case 0x81:
- printf("Not listening for calling name\n");
+ ND_PRINT((ndo, "Not listening for calling name\n"));
break;
case 0x82:
- printf("Called name not present\n");
+ ND_PRINT((ndo, "Called name not present\n"));
break;
case 0x83:
- printf("Called name present, but insufficient resources\n");
+ ND_PRINT((ndo, "Called name present, but insufficient resources\n"));
break;
default:
- printf("Unspecified error 0x%X\n", ecode);
+ ND_PRINT((ndo, "Unspecified error 0x%X\n", ecode));
break;
}
}
@@ -1068,37 +1073,45 @@ nbt_tcp_print(const u_char *data, int length)
break;
case 0x85:
- data = smb_fdata(data, "[P1]NBT Session Keepalive\nFlags=[B]\nLength=[rd]\n", maxbuf, 0);
+ data = smb_fdata(ndo, data, "[P1]NBT Session Keepalive\nFlags=[B]\nLength=[rd]\n", maxbuf, 0);
break;
default:
- data = smb_fdata(data, "NBT - Unknown packet type\nType=[B]\n", maxbuf, 0);
+ data = smb_fdata(ndo, data, "NBT - Unknown packet type\nType=[B]\n", maxbuf, 0);
break;
}
- printf("\n");
- fflush(stdout);
+ ND_PRINT((ndo, "\n"));
}
return;
trunc:
- printf("[|SMB]");
- return;
+ ND_PRINT((ndo, "%s", tstr));
}
+static const struct tok opcode_str[] = {
+ { 0, "QUERY" },
+ { 5, "REGISTRATION" },
+ { 6, "RELEASE" },
+ { 7, "WACK" },
+ { 8, "REFRESH(8)" },
+ { 9, "REFRESH" },
+ { 15, "MULTIHOMED REGISTRATION" },
+ { 0, NULL }
+};
/*
* print a NBT packet received across udp on port 137
*/
void
-nbt_udp137_print(const u_char *data, int length)
+nbt_udp137_print(netdissect_options *ndo,
+ const u_char *data, int length)
{
const u_char *maxbuf = data + length;
int name_trn_id, response, opcode, nm_flags, rcode;
int qdcount, ancount, nscount, arcount;
- const char *opcodestr;
const u_char *p;
int total, i;
- TCHECK2(data[10], 2);
+ ND_TCHECK2(data[10], 2);
name_trn_id = EXTRACT_16BITS(data);
response = (data[2] >> 7);
opcode = (data[2] >> 3) & 0xF;
@@ -1113,59 +1126,36 @@ nbt_udp137_print(const u_char *data, int length)
if (maxbuf <= data)
return;
- if (vflag > 1)
- printf("\n>>> ");
-
- printf("NBT UDP PACKET(137): ");
+ if (ndo->ndo_vflag > 1)
+ ND_PRINT((ndo, "\n>>> "));
- switch (opcode) {
- case 0: opcodestr = "QUERY"; break;
- case 5: opcodestr = "REGISTRATION"; break;
- case 6: opcodestr = "RELEASE"; break;
- case 7: opcodestr = "WACK"; break;
- case 8: opcodestr = "REFRESH(8)"; break;
- case 9: opcodestr = "REFRESH"; break;
- case 15: opcodestr = "MULTIHOMED REGISTRATION"; break;
- default: opcodestr = "OPUNKNOWN"; break;
- }
- printf("%s", opcodestr);
+ ND_PRINT((ndo, "NBT UDP PACKET(137): %s", tok2str(opcode_str, "OPUNKNOWN", opcode)));
if (response) {
- if (rcode)
- printf("; NEGATIVE");
- else
- printf("; POSITIVE");
+ ND_PRINT((ndo, "; %s", rcode ? "NEGATIVE" : "POSITIVE"));
}
+ ND_PRINT((ndo, "; %s; %s", response ? "RESPONSE" : "REQUEST",
+ (nm_flags & 1) ? "BROADCAST" : "UNICAST"));
- if (response)
- printf("; RESPONSE");
- else
- printf("; REQUEST");
-
- if (nm_flags & 1)
- printf("; BROADCAST");
- else
- printf("; UNICAST");
-
- if (vflag < 2)
+ if (ndo->ndo_vflag < 2)
return;
- printf("\nTrnID=0x%X\nOpCode=%d\nNmFlags=0x%X\nRcode=%d\nQueryCount=%d\nAnswerCount=%d\nAuthorityCount=%d\nAddressRecCount=%d\n",
+ ND_PRINT((ndo, "\nTrnID=0x%X\nOpCode=%d\nNmFlags=0x%X\nRcode=%d\nQueryCount=%d\nAnswerCount=%d\nAuthorityCount=%d\nAddressRecCount=%d\n",
name_trn_id, opcode, nm_flags, rcode, qdcount, ancount, nscount,
- arcount);
+ arcount));
p = data + 12;
total = ancount + nscount + arcount;
if (qdcount > 100 || total > 100) {
- printf("Corrupt packet??\n");
+ ND_PRINT((ndo, "Corrupt packet??\n"));
return;
}
if (qdcount) {
- printf("QuestionRecords:\n");
+ ND_PRINT((ndo, "QuestionRecords:\n"));
for (i = 0; i < qdcount; i++) {
- p = smb_fdata(p,
+ p = smb_fdata(ndo, p,
"|Name=[n1]\nQuestionType=[rw]\nQuestionClass=[rw]\n#",
maxbuf, 0);
if (p == NULL)
@@ -1174,60 +1164,62 @@ nbt_udp137_print(const u_char *data, int length)
}
if (total) {
- printf("\nResourceRecords:\n");
+ ND_PRINT((ndo, "\nResourceRecords:\n"));
for (i = 0; i < total; i++) {
int rdlen;
int restype;
- p = smb_fdata(p, "Name=[n1]\n#", maxbuf, 0);
+ p = smb_fdata(ndo, p, "Name=[n1]\n#", maxbuf, 0);
if (p == NULL)
goto out;
+ ND_TCHECK_16BITS(p);
restype = EXTRACT_16BITS(p);
- p = smb_fdata(p, "ResType=[rw]\nResClass=[rw]\nTTL=[rD]\n", p + 8, 0);
+ p = smb_fdata(ndo, p, "ResType=[rw]\nResClass=[rw]\nTTL=[rD]\n", p + 8, 0);
if (p == NULL)
goto out;
+ ND_TCHECK_16BITS(p);
rdlen = EXTRACT_16BITS(p);
- printf("ResourceLength=%d\nResourceData=\n", rdlen);
+ ND_PRINT((ndo, "ResourceLength=%d\nResourceData=\n", rdlen));
p += 2;
if (rdlen == 6) {
- p = smb_fdata(p, "AddrType=[rw]\nAddress=[b.b.b.b]\n", p + rdlen, 0);
+ p = smb_fdata(ndo, p, "AddrType=[rw]\nAddress=[b.b.b.b]\n", p + rdlen, 0);
if (p == NULL)
goto out;
} else {
if (restype == 0x21) {
int numnames;
- TCHECK(*p);
+ ND_TCHECK(*p);
numnames = p[0];
- p = smb_fdata(p, "NumNames=[B]\n", p + 1, 0);
+ p = smb_fdata(ndo, p, "NumNames=[B]\n", p + 1, 0);
if (p == NULL)
goto out;
while (numnames--) {
- p = smb_fdata(p, "Name=[n2]\t#", maxbuf, 0);
+ p = smb_fdata(ndo, p, "Name=[n2]\t#", maxbuf, 0);
if (p == NULL)
goto out;
- TCHECK(*p);
+ ND_TCHECK(*p);
if (p[0] & 0x80)
- printf("<GROUP> ");
+ ND_PRINT((ndo, "<GROUP> "));
switch (p[0] & 0x60) {
- case 0x00: printf("B "); break;
- case 0x20: printf("P "); break;
- case 0x40: printf("M "); break;
- case 0x60: printf("_ "); break;
+ case 0x00: ND_PRINT((ndo, "B ")); break;
+ case 0x20: ND_PRINT((ndo, "P ")); break;
+ case 0x40: ND_PRINT((ndo, "M ")); break;
+ case 0x60: ND_PRINT((ndo, "_ ")); break;
}
if (p[0] & 0x10)
- printf("<DEREGISTERING> ");
+ ND_PRINT((ndo, "<DEREGISTERING> "));
if (p[0] & 0x08)
- printf("<CONFLICT> ");
+ ND_PRINT((ndo, "<CONFLICT> "));
if (p[0] & 0x04)
- printf("<ACTIVE> ");
+ ND_PRINT((ndo, "<ACTIVE> "));
if (p[0] & 0x02)
- printf("<PERMANENT> ");
- printf("\n");
+ ND_PRINT((ndo, "<PERMANENT> "));
+ ND_PRINT((ndo, "\n"));
p += 2;
}
} else {
- print_data(p, min(rdlen, length - (p - data)));
+ smb_print_data(ndo, p, min(rdlen, length - (p - data)));
p += rdlen;
}
}
@@ -1235,22 +1227,21 @@ nbt_udp137_print(const u_char *data, int length)
}
if (p < maxbuf)
- smb_fdata(p, "AdditionalData:\n", maxbuf, 0);
+ smb_fdata(ndo, p, "AdditionalData:\n", maxbuf, 0);
out:
- printf("\n");
- fflush(stdout);
+ ND_PRINT((ndo, "\n"));
return;
trunc:
- printf("[|SMB]");
- return;
+ ND_PRINT((ndo, "%s", tstr));
}
/*
* Print an SMB-over-TCP packet received across tcp on port 445
*/
void
-smb_tcp_print (const u_char * data, int length)
+smb_tcp_print(netdissect_options *ndo,
+ const u_char * data, int length)
{
int caplen;
u_int smb_len;
@@ -1258,9 +1249,9 @@ smb_tcp_print (const u_char * data, int length)
if (length < 4)
goto trunc;
- if (snapend < data)
+ if (ndo->ndo_snapend < data)
goto trunc;
- caplen = snapend - data;
+ caplen = ndo->ndo_snapend - data;
if (caplen < 4)
goto trunc;
maxbuf = data + caplen;
@@ -1274,40 +1265,41 @@ smb_tcp_print (const u_char * data, int length)
if (smb_len >= 4 && caplen >= 4 && memcmp(data,"\377SMB",4) == 0) {
if ((int)smb_len > caplen) {
if ((int)smb_len > length)
- printf("WARNING: Packet is continued in later TCP segments\n");
+ ND_PRINT((ndo, " WARNING: Packet is continued in later TCP segments\n"));
else
- printf("WARNING: Short packet. Try increasing the snap length by %d\n",
- smb_len - caplen);
- }
- print_smb(data, maxbuf > data + smb_len ? data + smb_len : maxbuf);
+ ND_PRINT((ndo, " WARNING: Short packet. Try increasing the snap length by %d\n",
+ smb_len - caplen));
+ } else
+ ND_PRINT((ndo, " "));
+ print_smb(ndo, data, maxbuf > data + smb_len ? data + smb_len : maxbuf);
} else
- printf("SMB-over-TCP packet:(raw data or continuation?)\n");
+ ND_PRINT((ndo, " SMB-over-TCP packet:(raw data or continuation?)\n"));
return;
trunc:
- printf("[|SMB]");
- return;
+ ND_PRINT((ndo, "%s", tstr));
}
/*
* print a NBT packet received across udp on port 138
*/
void
-nbt_udp138_print(const u_char *data, int length)
+nbt_udp138_print(netdissect_options *ndo,
+ const u_char *data, int length)
{
const u_char *maxbuf = data + length;
- if (maxbuf > snapend)
- maxbuf = snapend;
+ if (maxbuf > ndo->ndo_snapend)
+ maxbuf = ndo->ndo_snapend;
if (maxbuf <= data)
return;
startbuf = data;
- if (vflag < 2) {
- printf("NBT UDP PACKET(138)");
+ if (ndo->ndo_vflag < 2) {
+ ND_PRINT((ndo, "NBT UDP PACKET(138)"));
return;
}
- data = smb_fdata(data,
+ data = smb_fdata(ndo, data,
"\n>>> NBT UDP PACKET(138) Res=[rw] ID=[rw] IP=[b.b.b.b] Port=[rd] Length=[rd] Res2=[rw]\nSourceName=[n1]\nDestName=[n1]\n#",
maxbuf, 0);
@@ -1317,18 +1309,17 @@ nbt_udp138_print(const u_char *data, int length)
goto out;
if (memcmp(data, "\377SMB",4) == 0)
- print_smb(data, maxbuf);
+ print_smb(ndo, data, maxbuf);
}
out:
- printf("\n");
- fflush(stdout);
+ ND_PRINT((ndo, "\n"));
}
/*
print netbeui frames
*/
-struct nbf_strings {
+static struct nbf_strings {
const char *name;
const char *nonverbose;
const char *verbose;
@@ -1384,7 +1375,8 @@ struct nbf_strings {
};
void
-netbeui_print(u_short control, const u_char *data, int length)
+netbeui_print(netdissect_options *ndo,
+ u_short control, const u_char *data, int length)
{
const u_char *maxbuf = data + length;
int len;
@@ -1392,9 +1384,9 @@ netbeui_print(u_short control, const u_char *data, int length)
const u_char *data2;
int is_truncated = 0;
- if (maxbuf > snapend)
- maxbuf = snapend;
- TCHECK(data[4]);
+ if (maxbuf > ndo->ndo_snapend)
+ maxbuf = ndo->ndo_snapend;
+ ND_TCHECK(data[4]);
len = EXTRACT_LE_16BITS(data);
command = data[4];
data2 = data + len;
@@ -1405,36 +1397,36 @@ netbeui_print(u_short control, const u_char *data, int length)
startbuf = data;
- if (vflag < 2) {
- printf("NBF Packet: ");
- data = smb_fdata(data, "[P5]#", maxbuf, 0);
+ if (ndo->ndo_vflag < 2) {
+ ND_PRINT((ndo, "NBF Packet: "));
+ data = smb_fdata(ndo, data, "[P5]#", maxbuf, 0);
} else {
- printf("\n>>> NBF Packet\nType=0x%X ", control);
- data = smb_fdata(data, "Length=[d] Signature=[w] Command=[B]\n#", maxbuf, 0);
+ ND_PRINT((ndo, "\n>>> NBF Packet\nType=0x%X ", control));
+ data = smb_fdata(ndo, data, "Length=[d] Signature=[w] Command=[B]\n#", maxbuf, 0);
}
if (data == NULL)
goto out;
if (command > 0x1f || nbf_strings[command].name == NULL) {
- if (vflag < 2)
- data = smb_fdata(data, "Unknown NBF Command#", data2, 0);
+ if (ndo->ndo_vflag < 2)
+ data = smb_fdata(ndo, data, "Unknown NBF Command#", data2, 0);
else
- data = smb_fdata(data, "Unknown NBF Command\n", data2, 0);
+ data = smb_fdata(ndo, data, "Unknown NBF Command\n", data2, 0);
} else {
- if (vflag < 2) {
- printf("%s", nbf_strings[command].name);
+ if (ndo->ndo_vflag < 2) {
+ ND_PRINT((ndo, "%s", nbf_strings[command].name));
if (nbf_strings[command].nonverbose != NULL)
- data = smb_fdata(data, nbf_strings[command].nonverbose, data2, 0);
+ data = smb_fdata(ndo, data, nbf_strings[command].nonverbose, data2, 0);
} else {
- printf("%s:\n", nbf_strings[command].name);
+ ND_PRINT((ndo, "%s:\n", nbf_strings[command].name));
if (nbf_strings[command].verbose != NULL)
- data = smb_fdata(data, nbf_strings[command].verbose, data2, 0);
+ data = smb_fdata(ndo, data, nbf_strings[command].verbose, data2, 0);
else
- printf("\n");
+ ND_PRINT((ndo, "\n"));
}
}
- if (vflag < 2)
+ if (ndo->ndo_vflag < 2)
return;
if (data == NULL)
@@ -1455,26 +1447,25 @@ netbeui_print(u_short control, const u_char *data, int length)
goto out;
if (memcmp(data2, "\377SMB",4) == 0)
- print_smb(data2, maxbuf);
+ print_smb(ndo, data2, maxbuf);
else {
int i;
for (i = 0; i < 128; i++) {
if (&data2[i + 3] >= maxbuf)
break;
if (memcmp(&data2[i], "\377SMB", 4) == 0) {
- printf("found SMB packet at %d\n", i);
- print_smb(&data2[i], maxbuf);
+ ND_PRINT((ndo, "found SMB packet at %d\n", i));
+ print_smb(ndo, &data2[i], maxbuf);
break;
}
}
}
out:
- printf("\n");
+ ND_PRINT((ndo, "\n"));
return;
trunc:
- printf("[|SMB]");
- return;
+ ND_PRINT((ndo, "%s", tstr));
}
@@ -1482,7 +1473,8 @@ trunc:
* print IPX-Netbios frames
*/
void
-ipx_netbios_print(const u_char *data, u_int length)
+ipx_netbios_print(netdissect_options *ndo,
+ const u_char *data, u_int length)
{
/*
* this is a hack till I work out how to parse the rest of the
@@ -1493,20 +1485,22 @@ ipx_netbios_print(const u_char *data, u_int length)
maxbuf = data + length;
/* Don't go past the end of the captured data in the packet. */
- if (maxbuf > snapend)
- maxbuf = snapend;
+ if (maxbuf > ndo->ndo_snapend)
+ maxbuf = ndo->ndo_snapend;
startbuf = data;
for (i = 0; i < 128; i++) {
if (&data[i + 4] > maxbuf)
break;
if (memcmp(&data[i], "\377SMB", 4) == 0) {
- smb_fdata(data, "\n>>> IPX transport ", &data[i], 0);
- print_smb(&data[i], maxbuf);
- printf("\n");
- fflush(stdout);
+ smb_fdata(ndo, data, "\n>>> IPX transport ", &data[i], 0);
+ print_smb(ndo, &data[i], maxbuf);
+ ND_PRINT((ndo, "\n"));
break;
}
}
if (i == 128)
- smb_fdata(data, "\n>>> Unknown IPX ", maxbuf, 0);
+ smb_fdata(ndo, data, "\n>>> Unknown IPX ", maxbuf, 0);
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-smb-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-smtp.c b/freebsd/contrib/tcpdump/print-smtp.c
new file mode 100644
index 00000000..4e26d4fe
--- /dev/null
+++ b/freebsd/contrib/tcpdump/print-smtp.c
@@ -0,0 +1,40 @@
+#include <machine/rtems-bsd-user-space.h>
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
+/*
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code
+ * distributions retain the above copyright notice and this paragraph
+ * in its entirety, and (2) distributions including binary code include
+ * the above copyright notice and this paragraph in its entirety in
+ * the documentation or other materials provided with the distribution.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND
+ * WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
+ * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE.
+ */
+
+/* \summary: Simple Mail Transfer Protocol (SMTP) printer */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <netdissect-stdinc.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "netdissect.h"
+#include "extract.h"
+
+void
+smtp_print(netdissect_options *ndo, const u_char *pptr, u_int len)
+{
+ txtproto_print(ndo, pptr, len, "smtp", NULL, 0);
+}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-smtp-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-snmp.c b/freebsd/contrib/tcpdump/print-snmp.c
index e585a4b5..0e822e54 100644
--- a/freebsd/contrib/tcpdump/print-snmp.c
+++ b/freebsd/contrib/tcpdump/print-snmp.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996, 1997
* John Robert LoVerso. All rights reserved.
@@ -58,34 +61,32 @@
# @(#)snmp.awk.x 1.1 (LANL) 1/15/90
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-snmp.c,v 1.64 2005-05-06 07:56:53 guy Exp $ (LBL)";
-#endif
+/* \summary: Simple Network Management Protocol (SNMP) printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <stdio.h>
#include <string.h>
-#ifdef HAVE_SMI_H
+#ifdef USE_LIBSMI
#include <smi.h>
#endif
-#include "interface.h"
-#include "addrtoname.h"
+#include "netdissect.h"
#undef OPAQUE /* defined in <wingdi.h> */
+static const char tstr[] = "[|snmp]";
+
/*
* Universal ASN.1 types
* (we only care about the tag values for those allowed in the Internet SMI)
*/
-const char *Universal[] = {
+static const char *Universal[] = {
"U-0",
"Boolean",
"Integer",
@@ -108,7 +109,7 @@ const char *Universal[] = {
/*
* Application-wide ASN.1 types from the Internet SMI and their tags
*/
-const char *Application[] = {
+static const char *Application[] = {
"IpAddress",
#define IPADDR 0
"Counter",
@@ -127,7 +128,7 @@ const char *Application[] = {
/*
* Context-specific ASN.1 types for the SNMP PDUs and their tags
*/
-const char *Context[] = {
+static const char *Context[] = {
"GetRequest",
#define GETREQ 0
"GetNextRequest",
@@ -157,7 +158,7 @@ const char *Context[] = {
/*
* Context-specific ASN.1 types for the SNMP Exceptions and their tags
*/
-const char *Exceptions[] = {
+static const char *Exceptions[] = {
"noSuchObject",
#define NOSUCHOBJECT 0
"noSuchInstance",
@@ -170,14 +171,14 @@ const char *Exceptions[] = {
* Private ASN.1 types
* The Internet SMI does not specify any
*/
-const char *Private[] = {
+static const char *Private[] = {
"P-0"
};
/*
* error-status values for any SNMP PDU
*/
-const char *ErrorStatus[] = {
+static const char *ErrorStatus[] = {
"noError",
"tooBig",
"noSuchName",
@@ -206,7 +207,7 @@ const char *ErrorStatus[] = {
/*
* generic-trap values in the SNMP Trap-PDU
*/
-const char *GenericTrap[] = {
+static const char *GenericTrap[] = {
"coldStart",
"warmStart",
"linkDown",
@@ -227,7 +228,7 @@ const char *GenericTrap[] = {
* type definitions.
*/
#define defineCLASS(x) { "x", x, sizeof(x)/sizeof(x[0]) } /* not ANSI-C */
-struct {
+static const struct {
const char *name;
const char **Id;
int numIDs;
@@ -247,7 +248,7 @@ struct {
/*
* defined forms for ASN.1 types
*/
-const char *Form[] = {
+static const char *Form[] = {
"Primitive",
#define PRIMITIVE 0
"Constructed",
@@ -258,7 +259,7 @@ const char *Form[] = {
* A structure for the OID tree for the compiled-in MIB.
* This is stored as a general-order tree.
*/
-struct obj {
+static struct obj {
const char *desc; /* name of object */
u_char oid; /* sub-id following parent */
u_char type; /* object type (unused) */
@@ -280,28 +281,46 @@ struct obj {
* Currently, this includes the prefixes for the Internet MIB, the
* private enterprises tree, and the experimental tree.
*/
-struct obj_abrev {
+#define OID_FIRST_OCTET(x, y) (((x)*40) + (y)) /* X.690 8.19.4 */
+
+#ifndef NO_ABREV_MIB
+static const uint8_t mib_oid[] = { OID_FIRST_OCTET(1, 3), 6, 1, 2, 1 };
+#endif
+#ifndef NO_ABREV_ENTER
+static const uint8_t enterprises_oid[] = { OID_FIRST_OCTET(1, 3), 6, 1, 4, 1 };
+#endif
+#ifndef NO_ABREV_EXPERI
+static const uint8_t experimental_oid[] = { OID_FIRST_OCTET(1, 3), 6, 1, 3 };
+#endif
+#ifndef NO_ABBREV_SNMPMODS
+static const uint8_t snmpModules_oid[] = { OID_FIRST_OCTET(1, 3), 6, 1, 6, 3 };
+#endif
+
+#define OBJ_ABBREV_ENTRY(prefix, obj) \
+ { prefix, &_ ## obj ## _obj, obj ## _oid, sizeof (obj ## _oid) }
+static const struct obj_abrev {
const char *prefix; /* prefix for this abrev */
struct obj *node; /* pointer into object table */
- const char *oid; /* ASN.1 encoded OID */
+ const uint8_t *oid; /* ASN.1 encoded OID */
+ size_t oid_len; /* length of OID */
} obj_abrev_list[] = {
#ifndef NO_ABREV_MIB
/* .iso.org.dod.internet.mgmt.mib */
- { "", &_mib_obj, "\53\6\1\2\1" },
+ OBJ_ABBREV_ENTRY("", mib),
#endif
#ifndef NO_ABREV_ENTER
/* .iso.org.dod.internet.private.enterprises */
- { "E:", &_enterprises_obj, "\53\6\1\4\1" },
+ OBJ_ABBREV_ENTRY("E:", enterprises),
#endif
#ifndef NO_ABREV_EXPERI
/* .iso.org.dod.internet.experimental */
- { "X:", &_experimental_obj, "\53\6\1\3" },
+ OBJ_ABBREV_ENTRY("X:", experimental),
#endif
#ifndef NO_ABBREV_SNMPMODS
/* .iso.org.dod.internet.snmpV2.snmpModules */
- { "S:", &_snmpModules_obj, "\53\6\1\6\3" },
+ OBJ_ABBREV_ENTRY("S:", snmpModules),
#endif
- { 0,0,0 }
+ { 0,0,0,0 }
};
/*
@@ -317,10 +336,10 @@ struct obj_abrev {
} while ((objp = objp->next) != NULL); \
} \
if (objp) { \
- printf(suppressdot?"%s":".%s", objp->desc); \
+ ND_PRINT((ndo, suppressdot?"%s":".%s", objp->desc)); \
objp = objp->child; \
} else \
- printf(suppressdot?"%u":".%u", (o)); \
+ ND_PRINT((ndo, suppressdot?"%u":".%u", (o))); \
}
/*
@@ -328,16 +347,13 @@ struct obj_abrev {
* temporary internal representation while decoding an ASN.1 data stream.
*/
struct be {
- u_int32_t asnlen;
+ uint32_t asnlen;
union {
- caddr_t raw;
+ const uint8_t *raw;
int32_t integer;
- u_int32_t uns;
+ uint32_t uns;
const u_char *str;
- struct {
- u_int32_t high;
- u_int32_t low;
- } uns64;
+ uint64_t uns64;
} data;
u_short id;
u_char form, class; /* tag info */
@@ -362,7 +378,7 @@ struct be {
/*
* SNMP versions recognized by this module
*/
-const char *SnmpVersion[] = {
+static const char *SnmpVersion[] = {
"SNMPv1",
#define SNMP_VERSION_1 0
"SNMPv2c",
@@ -405,7 +421,8 @@ const char *SnmpVersion[] = {
* O/w, this returns the number of bytes parsed from "p".
*/
static int
-asn1_parse(register const u_char *p, u_int len, struct be *elem)
+asn1_parse(netdissect_options *ndo,
+ register const u_char *p, u_int len, struct be *elem)
{
u_char form, class, id;
int i, hdr;
@@ -413,10 +430,10 @@ asn1_parse(register const u_char *p, u_int len, struct be *elem)
elem->asnlen = 0;
elem->type = BE_ANY;
if (len < 1) {
- fputs("[nothing to parse]", stdout);
+ ND_PRINT((ndo, "[nothing to parse]"));
return -1;
}
- TCHECK(*p);
+ ND_TCHECK(*p);
/*
* it would be nice to use a bit field, but you can't depend on them.
@@ -450,58 +467,64 @@ asn1_parse(register const u_char *p, u_int len, struct be *elem)
* bit set. XXX - this doesn't handle a value
* that won't fit in 32 bits.
*/
- for (id = 0; *p & ASN_BIT8; len--, hdr++, p++) {
+ id = 0;
+ ND_TCHECK(*p);
+ while (*p & ASN_BIT8) {
if (len < 1) {
- fputs("[Xtagfield?]", stdout);
+ ND_PRINT((ndo, "[Xtagfield?]"));
return -1;
}
- TCHECK(*p);
id = (id << 7) | (*p & ~ASN_BIT8);
+ len--;
+ hdr++;
+ p++;
+ ND_TCHECK(*p);
}
if (len < 1) {
- fputs("[Xtagfield?]", stdout);
+ ND_PRINT((ndo, "[Xtagfield?]"));
return -1;
}
- TCHECK(*p);
+ ND_TCHECK(*p);
elem->id = id = (id << 7) | *p;
--len;
++hdr;
++p;
}
if (len < 1) {
- fputs("[no asnlen]", stdout);
+ ND_PRINT((ndo, "[no asnlen]"));
return -1;
}
- TCHECK(*p);
+ ND_TCHECK(*p);
elem->asnlen = *p;
p++; len--; hdr++;
if (elem->asnlen & ASN_BIT8) {
- u_int32_t noct = elem->asnlen % ASN_BIT8;
+ uint32_t noct = elem->asnlen % ASN_BIT8;
elem->asnlen = 0;
if (len < noct) {
- printf("[asnlen? %d<%d]", len, noct);
+ ND_PRINT((ndo, "[asnlen? %d<%d]", len, noct));
return -1;
}
- TCHECK2(*p, noct);
+ ND_TCHECK2(*p, noct);
for (; noct-- > 0; len--, hdr++)
elem->asnlen = (elem->asnlen << ASN_SHIFT8) | *p++;
}
if (len < elem->asnlen) {
- printf("[len%d<asnlen%u]", len, elem->asnlen);
+ ND_PRINT((ndo, "[len%d<asnlen%u]", len, elem->asnlen));
return -1;
}
if (form >= sizeof(Form)/sizeof(Form[0])) {
- printf("[form?%d]", form);
+ ND_PRINT((ndo, "[form?%d]", form));
return -1;
}
if (class >= sizeof(Class)/sizeof(Class[0])) {
- printf("[class?%c/%d]", *Form[form], class);
+ ND_PRINT((ndo, "[class?%c/%d]", *Form[form], class));
return -1;
}
if ((int)id >= Class[class].numIDs) {
- printf("[id?%c/%s/%d]", *Form[form], Class[class].name, id);
+ ND_PRINT((ndo, "[id?%c/%s/%d]", *Form[form], Class[class].name, id));
return -1;
}
+ ND_TCHECK2(*p, elem->asnlen);
switch (form) {
case PRIMITIVE:
@@ -518,7 +541,10 @@ asn1_parse(register const u_char *p, u_int len, struct be *elem)
elem->type = BE_INT;
data = 0;
- TCHECK2(*p, elem->asnlen);
+ if (elem->asnlen == 0) {
+ ND_PRINT((ndo, "[asnlen=0]"));
+ return -1;
+ }
if (*p & ASN_BIT8) /* negative */
data = -1;
for (i = elem->asnlen; i-- > 0; p++)
@@ -529,7 +555,7 @@ asn1_parse(register const u_char *p, u_int len, struct be *elem)
case OBJECTID:
elem->type = BE_OID;
- elem->data.raw = (caddr_t)p;
+ elem->data.raw = (const uint8_t *)p;
break;
case ASN_NULL:
@@ -539,9 +565,8 @@ asn1_parse(register const u_char *p, u_int len, struct be *elem)
default:
elem->type = BE_OCTET;
- elem->data.raw = (caddr_t)p;
- printf("[P/U/%s]",
- Class[class].Id[id]);
+ elem->data.raw = (const uint8_t *)p;
+ ND_PRINT((ndo, "[P/U/%s]", Class[class].Id[id]));
break;
}
break;
@@ -550,14 +575,13 @@ asn1_parse(register const u_char *p, u_int len, struct be *elem)
switch (id) {
case IPADDR:
elem->type = BE_INETADDR;
- elem->data.raw = (caddr_t)p;
+ elem->data.raw = (const uint8_t *)p;
break;
case COUNTER:
case GAUGE:
case TIMETICKS: {
- register u_int32_t data;
- TCHECK2(*p, elem->asnlen);
+ register uint32_t data;
elem->type = BE_UNS;
data = 0;
for (i = elem->asnlen; i-- > 0; p++)
@@ -567,25 +591,20 @@ asn1_parse(register const u_char *p, u_int len, struct be *elem)
}
case COUNTER64: {
- register u_int32_t high, low;
- TCHECK2(*p, elem->asnlen);
+ register uint64_t data64;
elem->type = BE_UNS64;
- high = 0, low = 0;
- for (i = elem->asnlen; i-- > 0; p++) {
- high = (high << 8) |
- ((low & 0xFF000000) >> 24);
- low = (low << 8) | *p;
- }
- elem->data.uns64.high = high;
- elem->data.uns64.low = low;
+ data64 = 0;
+ for (i = elem->asnlen; i-- > 0; p++)
+ data64 = (data64 << 8) + *p;
+ elem->data.uns64 = data64;
break;
}
default:
elem->type = BE_OCTET;
- elem->data.raw = (caddr_t)p;
- printf("[P/A/%s]",
- Class[class].Id[id]);
+ elem->data.raw = (const uint8_t *)p;
+ ND_PRINT((ndo, "[P/A/%s]",
+ Class[class].Id[id]));
break;
}
break;
@@ -610,11 +629,9 @@ asn1_parse(register const u_char *p, u_int len, struct be *elem)
break;
default:
- printf("[P/%s/%s]",
- Class[class].name, Class[class].Id[id]);
- TCHECK2(*p, elem->asnlen);
+ ND_PRINT((ndo, "[P/%s/%s]", Class[class].name, Class[class].Id[id]));
elem->type = BE_OCTET;
- elem->data.raw = (caddr_t)p;
+ elem->data.raw = (const uint8_t *)p;
break;
}
break;
@@ -625,27 +642,26 @@ asn1_parse(register const u_char *p, u_int len, struct be *elem)
switch (id) {
case SEQUENCE:
elem->type = BE_SEQ;
- elem->data.raw = (caddr_t)p;
+ elem->data.raw = (const uint8_t *)p;
break;
default:
elem->type = BE_OCTET;
- elem->data.raw = (caddr_t)p;
- printf("C/U/%s", Class[class].Id[id]);
+ elem->data.raw = (const uint8_t *)p;
+ ND_PRINT((ndo, "C/U/%s", Class[class].Id[id]));
break;
}
break;
case CONTEXT:
elem->type = BE_PDU;
- elem->data.raw = (caddr_t)p;
+ elem->data.raw = (const uint8_t *)p;
break;
default:
elem->type = BE_OCTET;
- elem->data.raw = (caddr_t)p;
- printf("C/%s/%s",
- Class[class].name, Class[class].Id[id]);
+ elem->data.raw = (const uint8_t *)p;
+ ND_PRINT((ndo, "C/%s/%s", Class[class].name, Class[class].Id[id]));
break;
}
break;
@@ -655,7 +671,57 @@ asn1_parse(register const u_char *p, u_int len, struct be *elem)
return elem->asnlen + hdr;
trunc:
- fputs("[|snmp]", stdout);
+ ND_PRINT((ndo, "%s", tstr));
+ return -1;
+}
+
+static int
+asn1_print_octets(netdissect_options *ndo, struct be *elem)
+{
+ const u_char *p = (const u_char *)elem->data.raw;
+ uint32_t asnlen = elem->asnlen;
+ uint32_t i;
+
+ ND_TCHECK2(*p, asnlen);
+ for (i = asnlen; i-- > 0; p++)
+ ND_PRINT((ndo, "_%.2x", *p));
+ return 0;
+
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return -1;
+}
+
+static int
+asn1_print_string(netdissect_options *ndo, struct be *elem)
+{
+ register int printable = 1, first = 1;
+ const u_char *p;
+ uint32_t asnlen = elem->asnlen;
+ uint32_t i;
+
+ p = elem->data.str;
+ ND_TCHECK2(*p, asnlen);
+ for (i = asnlen; printable && i-- > 0; p++)
+ printable = ND_ISPRINT(*p);
+ p = elem->data.str;
+ if (printable) {
+ ND_PRINT((ndo, "\""));
+ if (fn_printn(ndo, p, asnlen, ndo->ndo_snapend)) {
+ ND_PRINT((ndo, "\""));
+ goto trunc;
+ }
+ ND_PRINT((ndo, "\""));
+ } else {
+ for (i = asnlen; i-- > 0; p++) {
+ ND_PRINT((ndo, first ? "%.2x" : "_%.2x", *p));
+ first = 0;
+ }
+ }
+ return 0;
+
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
return -1;
}
@@ -665,55 +731,60 @@ trunc:
* BE form was added.
*/
static int
-asn1_print(struct be *elem)
+asn1_print(netdissect_options *ndo,
+ struct be *elem)
{
- u_char *p = (u_char *)elem->data.raw;
- u_int32_t asnlen = elem->asnlen;
- u_int32_t i;
+ const u_char *p;
+ uint32_t asnlen = elem->asnlen;
+ uint32_t i;
switch (elem->type) {
case BE_OCTET:
- TCHECK2(*p, asnlen);
- for (i = asnlen; i-- > 0; p++)
- printf("_%.2x", *p);
+ if (asn1_print_octets(ndo, elem) == -1)
+ return -1;
break;
case BE_NULL:
break;
case BE_OID: {
- int o = 0, first = -1, i = asnlen;
+ int o = 0, first = -1;
- if (!sflag && !nflag && asnlen > 2) {
- struct obj_abrev *a = &obj_abrev_list[0];
- size_t a_len = strlen(a->oid);
+ p = (const u_char *)elem->data.raw;
+ i = asnlen;
+ if (!ndo->ndo_nflag && asnlen > 2) {
+ const struct obj_abrev *a = &obj_abrev_list[0];
for (; a->node; a++) {
- TCHECK2(*p, a_len);
- if (memcmp(a->oid, (char *)p, a_len) == 0) {
+ if (i < a->oid_len)
+ continue;
+ if (!ND_TTEST2(*p, a->oid_len))
+ continue;
+ if (memcmp(a->oid, p, a->oid_len) == 0) {
objp = a->node->child;
- i -= strlen(a->oid);
- p += strlen(a->oid);
- fputs(a->prefix, stdout);
+ i -= a->oid_len;
+ p += a->oid_len;
+ ND_PRINT((ndo, "%s", a->prefix));
first = 1;
break;
}
}
}
- for (; !sflag && i-- > 0; p++) {
- TCHECK(*p);
+ for (; i-- > 0; p++) {
+ ND_TCHECK(*p);
o = (o << ASN_SHIFT7) + (*p & ~ASN_BIT8);
if (*p & ASN_LONGLEN)
continue;
/*
- * first subitem encodes two items with 1st*OIDMUX+2nd
+ * first subitem encodes two items with
+ * 1st*OIDMUX+2nd
* (see X.690:1997 clause 8.19 for the details)
*/
if (first < 0) {
int s;
- if (!nflag)
+ if (!ndo->ndo_nflag)
objp = mibroot;
first = 0;
s = o / OIDMUX;
@@ -730,113 +801,58 @@ asn1_print(struct be *elem)
}
case BE_INT:
- printf("%d", elem->data.integer);
+ ND_PRINT((ndo, "%d", elem->data.integer));
break;
case BE_UNS:
- printf("%u", elem->data.uns);
+ ND_PRINT((ndo, "%u", elem->data.uns));
break;
- case BE_UNS64: { /* idea borrowed from by Marshall Rose */
- double d;
- int j, carry;
- char *cpf, *cpl, last[6], first[30];
- if (elem->data.uns64.high == 0) {
- printf("%u", elem->data.uns64.low);
- break;
- }
- d = elem->data.uns64.high * 4294967296.0; /* 2^32 */
- if (elem->data.uns64.high <= 0x1fffff) {
- d += elem->data.uns64.low;
-#if 0 /*is looks illegal, but what is the intention?*/
- printf("%.f", d);
-#else
- printf("%f", d);
-#endif
- break;
- }
- d += (elem->data.uns64.low & 0xfffff000);
-#if 0 /*is looks illegal, but what is the intention?*/
- snprintf(first, sizeof(first), "%.f", d);
-#else
- snprintf(first, sizeof(first), "%f", d);
-#endif
- snprintf(last, sizeof(last), "%5.5d",
- elem->data.uns64.low & 0xfff);
- for (carry = 0, cpf = first+strlen(first)-1, cpl = last+4;
- cpl >= last;
- cpf--, cpl--) {
- j = carry + (*cpf - '0') + (*cpl - '0');
- if (j > 9) {
- j -= 10;
- carry = 1;
- } else {
- carry = 0;
- }
- *cpf = j + '0';
- }
- fputs(first, stdout);
+ case BE_UNS64:
+ ND_PRINT((ndo, "%" PRIu64, elem->data.uns64));
break;
- }
- case BE_STR: {
- register int printable = 1, first = 1;
- const u_char *p = elem->data.str;
- TCHECK2(*p, asnlen);
- for (i = asnlen; printable && i-- > 0; p++)
- printable = isprint(*p) || isspace(*p);
- p = elem->data.str;
- if (printable) {
- putchar('"');
- if (fn_printn(p, asnlen, snapend)) {
- putchar('"');
- goto trunc;
- }
- putchar('"');
- } else
- for (i = asnlen; i-- > 0; p++) {
- printf(first ? "%.2x" : "_%.2x", *p);
- first = 0;
- }
+ case BE_STR:
+ if (asn1_print_string(ndo, elem) == -1)
+ return -1;
break;
- }
case BE_SEQ:
- printf("Seq(%u)", elem->asnlen);
+ ND_PRINT((ndo, "Seq(%u)", elem->asnlen));
break;
case BE_INETADDR:
if (asnlen != ASNLEN_INETADDR)
- printf("[inetaddr len!=%d]", ASNLEN_INETADDR);
- TCHECK2(*p, asnlen);
+ ND_PRINT((ndo, "[inetaddr len!=%d]", ASNLEN_INETADDR));
+ p = (const u_char *)elem->data.raw;
+ ND_TCHECK2(*p, asnlen);
for (i = asnlen; i-- != 0; p++) {
- printf((i == asnlen-1) ? "%u" : ".%u", *p);
+ ND_PRINT((ndo, (i == asnlen-1) ? "%u" : ".%u", *p));
}
break;
case BE_NOSUCHOBJECT:
case BE_NOSUCHINST:
case BE_ENDOFMIBVIEW:
- printf("[%s]", Class[EXCEPTIONS].Id[elem->id]);
+ ND_PRINT((ndo, "[%s]", Class[EXCEPTIONS].Id[elem->id]));
break;
case BE_PDU:
- printf("%s(%u)",
- Class[CONTEXT].Id[elem->id], elem->asnlen);
+ ND_PRINT((ndo, "%s(%u)", Class[CONTEXT].Id[elem->id], elem->asnlen));
break;
case BE_ANY:
- fputs("[BE_ANY!?]", stdout);
+ ND_PRINT((ndo, "[BE_ANY!?]"));
break;
default:
- fputs("[be!?]", stdout);
+ ND_PRINT((ndo, "[be!?]"));
break;
}
return 0;
trunc:
- fputs("[|snmp]", stdout);
+ ND_PRINT((ndo, "%s", tstr));
return -1;
}
@@ -857,15 +873,15 @@ asn1_decode(u_char *p, u_int length)
int i = 0;
while (i >= 0 && length > 0) {
- i = asn1_parse(p, length, &elem);
+ i = asn1_parse(ndo, p, length, &elem);
if (i >= 0) {
- fputs(" ", stdout);
- if (asn1_print(&elem) < 0)
+ ND_PRINT((ndo, " "));
+ if (asn1_print(ndo, &elem) < 0)
return;
if (elem.type == BE_SEQ || elem.type == BE_PDU) {
- fputs(" {", stdout);
+ ND_PRINT((ndo, " {"));
asn1_decode(elem.data.raw, elem.asnlen);
- fputs(" }", stdout);
+ ND_PRINT((ndo, " }"));
}
length -= i;
p += i;
@@ -874,14 +890,14 @@ asn1_decode(u_char *p, u_int length)
}
#endif
-#ifdef LIBSMI
+#ifdef USE_LIBSMI
struct smi2be {
SmiBasetype basetype;
int be;
};
-static struct smi2be smi2betab[] = {
+static const struct smi2be smi2betab[] = {
{ SMI_BASETYPE_INTEGER32, BE_INT },
{ SMI_BASETYPE_OCTETSTRING, BE_STR },
{ SMI_BASETYPE_OCTETSTRING, BE_INETADDR },
@@ -898,15 +914,17 @@ static struct smi2be smi2betab[] = {
};
static int
-smi_decode_oid(struct be *elem, unsigned int *oid,
- unsigned int oidsize, unsigned int *oidlen)
+smi_decode_oid(netdissect_options *ndo,
+ struct be *elem, unsigned int *oid,
+ unsigned int oidsize, unsigned int *oidlen)
{
- u_char *p = (u_char *)elem->data.raw;
- u_int32_t asnlen = elem->asnlen;
+ const u_char *p = (const u_char *)elem->data.raw;
+ uint32_t asnlen = elem->asnlen;
int o = 0, first = -1, i = asnlen;
+ unsigned int firstval;
- for (*oidlen = 0; sflag && i-- > 0; p++) {
- TCHECK(*p);
+ for (*oidlen = 0; i-- > 0; p++) {
+ ND_TCHECK(*p);
o = (o << ASN_SHIFT7) + (*p & ~ASN_BIT8);
if (*p & ASN_LONGLEN)
continue;
@@ -916,13 +934,13 @@ smi_decode_oid(struct be *elem, unsigned int *oid,
* (see X.690:1997 clause 8.19 for the details)
*/
if (first < 0) {
- first = 0;
+ first = 0;
+ firstval = o / OIDMUX;
+ if (firstval > 2) firstval = 2;
+ o -= firstval * OIDMUX;
if (*oidlen < oidsize) {
- oid[*oidlen] = o / OIDMUX;
- if (oid[*oidlen] > 2) oid[*oidlen] = 2;
+ oid[(*oidlen)++] = firstval;
}
- o -= oid[*oidlen] * OIDMUX;
- if (*oidlen < oidsize) (*oidlen)++;
}
if (*oidlen < oidsize) {
oid[(*oidlen)++] = o;
@@ -932,7 +950,7 @@ smi_decode_oid(struct be *elem, unsigned int *oid,
return 0;
trunc:
- fputs("[|snmp]", stdout);
+ ND_PRINT((ndo, "%s", tstr));
return -1;
}
@@ -1026,29 +1044,34 @@ static int smi_check_range(SmiType *smiType, struct be *elem)
return ok;
}
-static SmiNode *smi_print_variable(struct be *elem, int *status)
+static SmiNode *
+smi_print_variable(netdissect_options *ndo,
+ struct be *elem, int *status)
{
unsigned int oid[128], oidlen;
SmiNode *smiNode = NULL;
unsigned int i;
- *status = smi_decode_oid(elem, oid, sizeof(oid)/sizeof(unsigned int),
+ if (!nd_smi_module_loaded) {
+ *status = asn1_print(ndo, elem);
+ return NULL;
+ }
+ *status = smi_decode_oid(ndo, elem, oid, sizeof(oid) / sizeof(unsigned int),
&oidlen);
if (*status < 0)
return NULL;
smiNode = smiGetNodeByOID(oidlen, oid);
if (! smiNode) {
- *status = asn1_print(elem);
+ *status = asn1_print(ndo, elem);
return NULL;
}
- if (vflag) {
- fputs(smiGetNodeModule(smiNode)->name, stdout);
- fputs("::", stdout);
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo, "%s::", smiGetNodeModule(smiNode)->name));
}
- fputs(smiNode->name, stdout);
+ ND_PRINT((ndo, "%s", smiNode->name));
if (smiNode->oidlen < oidlen) {
- for (i = smiNode->oidlen; i < oidlen; i++) {
- printf(".%u", oid[i]);
+ for (i = smiNode->oidlen; i < oidlen; i++) {
+ ND_PRINT((ndo, ".%u", oid[i]));
}
}
*status = 0;
@@ -1056,7 +1079,8 @@ static SmiNode *smi_print_variable(struct be *elem, int *status)
}
static int
-smi_print_value(SmiNode *smiNode, u_char pduid, struct be *elem)
+smi_print_value(netdissect_options *ndo,
+ SmiNode *smiNode, u_short pduid, struct be *elem)
{
unsigned int i, oid[128], oidlen;
SmiType *smiType;
@@ -1065,43 +1089,43 @@ smi_print_value(SmiNode *smiNode, u_char pduid, struct be *elem)
if (! smiNode || ! (smiNode->nodekind
& (SMI_NODEKIND_SCALAR | SMI_NODEKIND_COLUMN))) {
- return asn1_print(elem);
+ return asn1_print(ndo, elem);
}
if (elem->type == BE_NOSUCHOBJECT
|| elem->type == BE_NOSUCHINST
|| elem->type == BE_ENDOFMIBVIEW) {
- return asn1_print(elem);
+ return asn1_print(ndo, elem);
}
if (NOTIFY_CLASS(pduid) && smiNode->access < SMI_ACCESS_NOTIFY) {
- fputs("[notNotifyable]", stdout);
+ ND_PRINT((ndo, "[notNotifyable]"));
}
if (READ_CLASS(pduid) && smiNode->access < SMI_ACCESS_READ_ONLY) {
- fputs("[notReadable]", stdout);
+ ND_PRINT((ndo, "[notReadable]"));
}
if (WRITE_CLASS(pduid) && smiNode->access < SMI_ACCESS_READ_WRITE) {
- fputs("[notWritable]", stdout);
+ ND_PRINT((ndo, "[notWritable]"));
}
if (RESPONSE_CLASS(pduid)
&& smiNode->access == SMI_ACCESS_NOT_ACCESSIBLE) {
- fputs("[noAccess]", stdout);
+ ND_PRINT((ndo, "[noAccess]"));
}
smiType = smiGetNodeType(smiNode);
if (! smiType) {
- return asn1_print(elem);
+ return asn1_print(ndo, elem);
}
if (! smi_check_type(smiType->basetype, elem->type)) {
- fputs("[wrongType]", stdout);
+ ND_PRINT((ndo, "[wrongType]"));
}
if (! smi_check_range(smiType, elem)) {
- fputs("[outOfRange]", stdout);
+ ND_PRINT((ndo, "[outOfRange]"));
}
/* resolve bits to named bits */
@@ -1117,23 +1141,24 @@ smi_print_value(SmiNode *smiNode, u_char pduid, struct be *elem)
if (smiType->basetype == SMI_BASETYPE_BITS) {
/* print bit labels */
} else {
- smi_decode_oid(elem, oid,
- sizeof(oid)/sizeof(unsigned int),
- &oidlen);
- smiNode = smiGetNodeByOID(oidlen, oid);
- if (smiNode) {
- if (vflag) {
- fputs(smiGetNodeModule(smiNode)->name, stdout);
- fputs("::", stdout);
- }
- fputs(smiNode->name, stdout);
- if (smiNode->oidlen < oidlen) {
- for (i = smiNode->oidlen;
- i < oidlen; i++) {
- printf(".%u", oid[i]);
+ if (nd_smi_module_loaded &&
+ smi_decode_oid(ndo, elem, oid,
+ sizeof(oid)/sizeof(unsigned int),
+ &oidlen) == 0) {
+ smiNode = smiGetNodeByOID(oidlen, oid);
+ if (smiNode) {
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo, "%s::", smiGetNodeModule(smiNode)->name));
+ }
+ ND_PRINT((ndo, "%s", smiNode->name));
+ if (smiNode->oidlen < oidlen) {
+ for (i = smiNode->oidlen;
+ i < oidlen; i++) {
+ ND_PRINT((ndo, ".%u", oid[i]));
+ }
}
+ done++;
}
- done++;
}
}
break;
@@ -1145,8 +1170,8 @@ smi_print_value(SmiNode *smiNode, u_char pduid, struct be *elem)
nn = smiGetNextNamedNumber(nn)) {
if (nn->value.value.integer32
== elem->data.integer) {
- fputs(nn->name, stdout);
- printf("(%d)", elem->data.integer);
+ ND_PRINT((ndo, "%s", nn->name));
+ ND_PRINT((ndo, "(%d)", elem->data.integer));
done++;
break;
}
@@ -1156,7 +1181,7 @@ smi_print_value(SmiNode *smiNode, u_char pduid, struct be *elem)
}
if (! done) {
- return asn1_print(elem);
+ return asn1_print(ndo, elem);
}
return 0;
}
@@ -1199,61 +1224,62 @@ smi_print_value(SmiNode *smiNode, u_char pduid, struct be *elem)
* Decode SNMP varBind
*/
static void
-varbind_print(u_char pduid, const u_char *np, u_int length)
+varbind_print(netdissect_options *ndo,
+ u_short pduid, const u_char *np, u_int length)
{
struct be elem;
int count = 0, ind;
-#ifdef LIBSMI
+#ifdef USE_LIBSMI
SmiNode *smiNode = NULL;
#endif
int status;
/* Sequence of varBind */
- if ((count = asn1_parse(np, length, &elem)) < 0)
+ if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
return;
if (elem.type != BE_SEQ) {
- fputs("[!SEQ of varbind]", stdout);
- asn1_print(&elem);
+ ND_PRINT((ndo, "[!SEQ of varbind]"));
+ asn1_print(ndo, &elem);
return;
}
if ((u_int)count < length)
- printf("[%d extra after SEQ of varbind]", length - count);
+ ND_PRINT((ndo, "[%d extra after SEQ of varbind]", length - count));
/* descend */
length = elem.asnlen;
- np = (u_char *)elem.data.raw;
+ np = (const u_char *)elem.data.raw;
for (ind = 1; length > 0; ind++) {
const u_char *vbend;
u_int vblength;
- fputs(" ", stdout);
+ ND_PRINT((ndo, " "));
/* Sequence */
- if ((count = asn1_parse(np, length, &elem)) < 0)
+ if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
return;
if (elem.type != BE_SEQ) {
- fputs("[!varbind]", stdout);
- asn1_print(&elem);
+ ND_PRINT((ndo, "[!varbind]"));
+ asn1_print(ndo, &elem);
return;
}
vbend = np + count;
vblength = length - count;
/* descend */
length = elem.asnlen;
- np = (u_char *)elem.data.raw;
+ np = (const u_char *)elem.data.raw;
/* objName (OID) */
- if ((count = asn1_parse(np, length, &elem)) < 0)
+ if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
return;
if (elem.type != BE_OID) {
- fputs("[objName!=OID]", stdout);
- asn1_print(&elem);
+ ND_PRINT((ndo, "[objName!=OID]"));
+ asn1_print(ndo, &elem);
return;
}
-#ifdef LIBSMI
- smiNode = smi_print_variable(&elem, &status);
+#ifdef USE_LIBSMI
+ smiNode = smi_print_variable(ndo, &elem, &status);
#else
- status = asn1_print(&elem);
+ status = asn1_print(ndo, &elem);
#endif
if (status < 0)
return;
@@ -1262,24 +1288,24 @@ varbind_print(u_char pduid, const u_char *np, u_int length)
if (pduid != GETREQ && pduid != GETNEXTREQ
&& pduid != GETBULKREQ)
- fputs("=", stdout);
+ ND_PRINT((ndo, "="));
/* objVal (ANY) */
- if ((count = asn1_parse(np, length, &elem)) < 0)
+ if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
return;
if (pduid == GETREQ || pduid == GETNEXTREQ
|| pduid == GETBULKREQ) {
if (elem.type != BE_NULL) {
- fputs("[objVal!=NULL]", stdout);
- if (asn1_print(&elem) < 0)
+ ND_PRINT((ndo, "[objVal!=NULL]"));
+ if (asn1_print(ndo, &elem) < 0)
return;
}
} else {
if (elem.type != BE_NULL) {
-#ifdef LIBSMI
- status = smi_print_value(smiNode, pduid, &elem);
+#ifdef USE_LIBSMI
+ status = smi_print_value(ndo, smiNode, pduid, &elem);
#else
- status = asn1_print(&elem);
+ status = asn1_print(ndo, &elem);
#endif
}
if (status < 0)
@@ -1295,79 +1321,76 @@ varbind_print(u_char pduid, const u_char *np, u_int length)
* GetBulk, Inform, V2Trap, and Report
*/
static void
-snmppdu_print(u_short pduid, const u_char *np, u_int length)
+snmppdu_print(netdissect_options *ndo,
+ u_short pduid, const u_char *np, u_int length)
{
struct be elem;
- int count = 0, error;
+ int count = 0, error_status;
/* reqId (Integer) */
- if ((count = asn1_parse(np, length, &elem)) < 0)
+ if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
return;
if (elem.type != BE_INT) {
- fputs("[reqId!=INT]", stdout);
- asn1_print(&elem);
+ ND_PRINT((ndo, "[reqId!=INT]"));
+ asn1_print(ndo, &elem);
return;
}
- if (vflag)
- printf("R=%d ", elem.data.integer);
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo, "R=%d ", elem.data.integer));
length -= count;
np += count;
/* errorStatus (Integer) */
- if ((count = asn1_parse(np, length, &elem)) < 0)
+ if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
return;
if (elem.type != BE_INT) {
- fputs("[errorStatus!=INT]", stdout);
- asn1_print(&elem);
+ ND_PRINT((ndo, "[errorStatus!=INT]"));
+ asn1_print(ndo, &elem);
return;
}
- error = 0;
+ error_status = 0;
if ((pduid == GETREQ || pduid == GETNEXTREQ || pduid == SETREQ
|| pduid == INFORMREQ || pduid == V2TRAP || pduid == REPORT)
&& elem.data.integer != 0) {
char errbuf[20];
- printf("[errorStatus(%s)!=0]",
- DECODE_ErrorStatus(elem.data.integer));
+ ND_PRINT((ndo, "[errorStatus(%s)!=0]",
+ DECODE_ErrorStatus(elem.data.integer)));
} else if (pduid == GETBULKREQ) {
- printf(" N=%d", elem.data.integer);
+ ND_PRINT((ndo, " N=%d", elem.data.integer));
} else if (elem.data.integer != 0) {
char errbuf[20];
- printf(" %s", DECODE_ErrorStatus(elem.data.integer));
- error = elem.data.integer;
+ ND_PRINT((ndo, " %s", DECODE_ErrorStatus(elem.data.integer)));
+ error_status = elem.data.integer;
}
length -= count;
np += count;
/* errorIndex (Integer) */
- if ((count = asn1_parse(np, length, &elem)) < 0)
+ if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
return;
if (elem.type != BE_INT) {
- fputs("[errorIndex!=INT]", stdout);
- asn1_print(&elem);
+ ND_PRINT((ndo, "[errorIndex!=INT]"));
+ asn1_print(ndo, &elem);
return;
}
if ((pduid == GETREQ || pduid == GETNEXTREQ || pduid == SETREQ
|| pduid == INFORMREQ || pduid == V2TRAP || pduid == REPORT)
&& elem.data.integer != 0)
- printf("[errorIndex(%d)!=0]", elem.data.integer);
+ ND_PRINT((ndo, "[errorIndex(%d)!=0]", elem.data.integer));
else if (pduid == GETBULKREQ)
- printf(" M=%d", elem.data.integer);
+ ND_PRINT((ndo, " M=%d", elem.data.integer));
else if (elem.data.integer != 0) {
- if (!error)
- printf("[errorIndex(%d) w/o errorStatus]",
- elem.data.integer);
- else {
- printf("@%d", elem.data.integer);
- error = elem.data.integer;
- }
- } else if (error) {
- fputs("[errorIndex==0]", stdout);
- error = 0;
+ if (!error_status)
+ ND_PRINT((ndo, "[errorIndex(%d) w/o errorStatus]", elem.data.integer));
+ else
+ ND_PRINT((ndo, "@%d", elem.data.integer));
+ } else if (error_status) {
+ ND_PRINT((ndo, "[errorIndex==0]"));
}
length -= count;
np += count;
- varbind_print(pduid, np, length);
+ varbind_print(ndo, pduid, np, length);
return;
}
@@ -1375,89 +1398,90 @@ snmppdu_print(u_short pduid, const u_char *np, u_int length)
* Decode SNMP Trap PDU
*/
static void
-trappdu_print(const u_char *np, u_int length)
+trappdu_print(netdissect_options *ndo,
+ const u_char *np, u_int length)
{
struct be elem;
int count = 0, generic;
- putchar(' ');
+ ND_PRINT((ndo, " "));
/* enterprise (oid) */
- if ((count = asn1_parse(np, length, &elem)) < 0)
+ if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
return;
if (elem.type != BE_OID) {
- fputs("[enterprise!=OID]", stdout);
- asn1_print(&elem);
+ ND_PRINT((ndo, "[enterprise!=OID]"));
+ asn1_print(ndo, &elem);
return;
}
- if (asn1_print(&elem) < 0)
+ if (asn1_print(ndo, &elem) < 0)
return;
length -= count;
np += count;
- putchar(' ');
+ ND_PRINT((ndo, " "));
/* agent-addr (inetaddr) */
- if ((count = asn1_parse(np, length, &elem)) < 0)
+ if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
return;
if (elem.type != BE_INETADDR) {
- fputs("[agent-addr!=INETADDR]", stdout);
- asn1_print(&elem);
+ ND_PRINT((ndo, "[agent-addr!=INETADDR]"));
+ asn1_print(ndo, &elem);
return;
}
- if (asn1_print(&elem) < 0)
+ if (asn1_print(ndo, &elem) < 0)
return;
length -= count;
np += count;
/* generic-trap (Integer) */
- if ((count = asn1_parse(np, length, &elem)) < 0)
+ if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
return;
if (elem.type != BE_INT) {
- fputs("[generic-trap!=INT]", stdout);
- asn1_print(&elem);
+ ND_PRINT((ndo, "[generic-trap!=INT]"));
+ asn1_print(ndo, &elem);
return;
}
generic = elem.data.integer;
{
char buf[20];
- printf(" %s", DECODE_GenericTrap(generic));
+ ND_PRINT((ndo, " %s", DECODE_GenericTrap(generic)));
}
length -= count;
np += count;
/* specific-trap (Integer) */
- if ((count = asn1_parse(np, length, &elem)) < 0)
+ if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
return;
if (elem.type != BE_INT) {
- fputs("[specific-trap!=INT]", stdout);
- asn1_print(&elem);
+ ND_PRINT((ndo, "[specific-trap!=INT]"));
+ asn1_print(ndo, &elem);
return;
}
if (generic != GT_ENTERPRISE) {
if (elem.data.integer != 0)
- printf("[specific-trap(%d)!=0]", elem.data.integer);
+ ND_PRINT((ndo, "[specific-trap(%d)!=0]", elem.data.integer));
} else
- printf(" s=%d", elem.data.integer);
+ ND_PRINT((ndo, " s=%d", elem.data.integer));
length -= count;
np += count;
- putchar(' ');
+ ND_PRINT((ndo, " "));
/* time-stamp (TimeTicks) */
- if ((count = asn1_parse(np, length, &elem)) < 0)
+ if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
return;
if (elem.type != BE_UNS) { /* XXX */
- fputs("[time-stamp!=TIMETICKS]", stdout);
- asn1_print(&elem);
+ ND_PRINT((ndo, "[time-stamp!=TIMETICKS]"));
+ asn1_print(ndo, &elem);
return;
}
- if (asn1_print(&elem) < 0)
+ if (asn1_print(ndo, &elem) < 0)
return;
length -= count;
np += count;
- varbind_print (TRAP, np, length);
+ varbind_print(ndo, TRAP, np, length);
return;
}
@@ -1465,45 +1489,46 @@ trappdu_print(const u_char *np, u_int length)
* Decode arbitrary SNMP PDUs.
*/
static void
-pdu_print(const u_char *np, u_int length, int version)
+pdu_print(netdissect_options *ndo,
+ const u_char *np, u_int length, int version)
{
struct be pdu;
int count = 0;
/* PDU (Context) */
- if ((count = asn1_parse(np, length, &pdu)) < 0)
+ if ((count = asn1_parse(ndo, np, length, &pdu)) < 0)
return;
if (pdu.type != BE_PDU) {
- fputs("[no PDU]", stdout);
+ ND_PRINT((ndo, "[no PDU]"));
return;
}
if ((u_int)count < length)
- printf("[%d extra after PDU]", length - count);
- if (vflag) {
- fputs("{ ", stdout);
+ ND_PRINT((ndo, "[%d extra after PDU]", length - count));
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo, "{ "));
}
- if (asn1_print(&pdu) < 0)
+ if (asn1_print(ndo, &pdu) < 0)
return;
- fputs(" ", stdout);
+ ND_PRINT((ndo, " "));
/* descend into PDU */
length = pdu.asnlen;
- np = (u_char *)pdu.data.raw;
+ np = (const u_char *)pdu.data.raw;
if (version == SNMP_VERSION_1 &&
(pdu.id == GETBULKREQ || pdu.id == INFORMREQ ||
pdu.id == V2TRAP || pdu.id == REPORT)) {
- printf("[v2 PDU in v1 message]");
+ ND_PRINT((ndo, "[v2 PDU in v1 message]"));
return;
}
if (version == SNMP_VERSION_2 && pdu.id == TRAP) {
- printf("[v1 PDU in v2 message]");
+ ND_PRINT((ndo, "[v1 PDU in v2 message]"));
return;
}
switch (pdu.id) {
case TRAP:
- trappdu_print(np, length);
+ trappdu_print(ndo, np, length);
break;
case GETREQ:
case GETNEXTREQ:
@@ -1513,12 +1538,12 @@ pdu_print(const u_char *np, u_int length, int version)
case INFORMREQ:
case V2TRAP:
case REPORT:
- snmppdu_print(pdu.id, np, length);
+ snmppdu_print(ndo, pdu.id, np, length);
break;
}
- if (vflag) {
- fputs(" } ", stdout);
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo, " } "));
}
}
@@ -1526,185 +1551,198 @@ pdu_print(const u_char *np, u_int length, int version)
* Decode a scoped SNMP PDU.
*/
static void
-scopedpdu_print(const u_char *np, u_int length, int version)
+scopedpdu_print(netdissect_options *ndo,
+ const u_char *np, u_int length, int version)
{
struct be elem;
- int i, count = 0;
+ int count = 0;
/* Sequence */
- if ((count = asn1_parse(np, length, &elem)) < 0)
+ if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
return;
if (elem.type != BE_SEQ) {
- fputs("[!scoped PDU]", stdout);
- asn1_print(&elem);
+ ND_PRINT((ndo, "[!scoped PDU]"));
+ asn1_print(ndo, &elem);
return;
}
length = elem.asnlen;
- np = (u_char *)elem.data.raw;
+ np = (const u_char *)elem.data.raw;
/* contextEngineID (OCTET STRING) */
- if ((count = asn1_parse(np, length, &elem)) < 0)
+ if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
return;
if (elem.type != BE_STR) {
- fputs("[contextEngineID!=STR]", stdout);
- asn1_print(&elem);
+ ND_PRINT((ndo, "[contextEngineID!=STR]"));
+ asn1_print(ndo, &elem);
return;
}
length -= count;
np += count;
- fputs("E= ", stdout);
- for (i = 0; i < (int)elem.asnlen; i++) {
- printf("0x%02X", elem.data.str[i]);
- }
- fputs(" ", stdout);
+ ND_PRINT((ndo, "E="));
+ if (asn1_print_octets(ndo, &elem) == -1)
+ return;
+ ND_PRINT((ndo, " "));
/* contextName (OCTET STRING) */
- if ((count = asn1_parse(np, length, &elem)) < 0)
+ if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
return;
if (elem.type != BE_STR) {
- fputs("[contextName!=STR]", stdout);
- asn1_print(&elem);
+ ND_PRINT((ndo, "[contextName!=STR]"));
+ asn1_print(ndo, &elem);
return;
}
length -= count;
np += count;
- printf("C=%.*s ", (int)elem.asnlen, elem.data.str);
+ ND_PRINT((ndo, "C="));
+ if (asn1_print_string(ndo, &elem) == -1)
+ return;
+ ND_PRINT((ndo, " "));
- pdu_print(np, length, version);
+ pdu_print(ndo, np, length, version);
}
/*
* Decode SNMP Community Header (SNMPv1 and SNMPv2c)
*/
static void
-community_print(const u_char *np, u_int length, int version)
+community_print(netdissect_options *ndo,
+ const u_char *np, u_int length, int version)
{
struct be elem;
int count = 0;
/* Community (String) */
- if ((count = asn1_parse(np, length, &elem)) < 0)
+ if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
return;
if (elem.type != BE_STR) {
- fputs("[comm!=STR]", stdout);
- asn1_print(&elem);
+ ND_PRINT((ndo, "[comm!=STR]"));
+ asn1_print(ndo, &elem);
return;
}
/* default community */
if (!(elem.asnlen == sizeof(DEF_COMMUNITY) - 1 &&
- strncmp((char *)elem.data.str, DEF_COMMUNITY,
- sizeof(DEF_COMMUNITY) - 1) == 0))
+ strncmp((const char *)elem.data.str, DEF_COMMUNITY,
+ sizeof(DEF_COMMUNITY) - 1) == 0)) {
/* ! "public" */
- printf("C=%.*s ", (int)elem.asnlen, elem.data.str);
+ ND_PRINT((ndo, "C="));
+ if (asn1_print_string(ndo, &elem) == -1)
+ return;
+ ND_PRINT((ndo, " "));
+ }
length -= count;
np += count;
- pdu_print(np, length, version);
+ pdu_print(ndo, np, length, version);
}
/*
* Decode SNMPv3 User-based Security Message Header (SNMPv3)
*/
static void
-usm_print(const u_char *np, u_int length)
+usm_print(netdissect_options *ndo,
+ const u_char *np, u_int length)
{
struct be elem;
int count = 0;
/* Sequence */
- if ((count = asn1_parse(np, length, &elem)) < 0)
+ if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
return;
if (elem.type != BE_SEQ) {
- fputs("[!usm]", stdout);
- asn1_print(&elem);
+ ND_PRINT((ndo, "[!usm]"));
+ asn1_print(ndo, &elem);
return;
}
length = elem.asnlen;
- np = (u_char *)elem.data.raw;
+ np = (const u_char *)elem.data.raw;
/* msgAuthoritativeEngineID (OCTET STRING) */
- if ((count = asn1_parse(np, length, &elem)) < 0)
+ if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
return;
if (elem.type != BE_STR) {
- fputs("[msgAuthoritativeEngineID!=STR]", stdout);
- asn1_print(&elem);
+ ND_PRINT((ndo, "[msgAuthoritativeEngineID!=STR]"));
+ asn1_print(ndo, &elem);
return;
}
length -= count;
np += count;
/* msgAuthoritativeEngineBoots (INTEGER) */
- if ((count = asn1_parse(np, length, &elem)) < 0)
+ if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
return;
if (elem.type != BE_INT) {
- fputs("[msgAuthoritativeEngineBoots!=INT]", stdout);
- asn1_print(&elem);
+ ND_PRINT((ndo, "[msgAuthoritativeEngineBoots!=INT]"));
+ asn1_print(ndo, &elem);
return;
}
- if (vflag)
- printf("B=%d ", elem.data.integer);
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo, "B=%d ", elem.data.integer));
length -= count;
np += count;
/* msgAuthoritativeEngineTime (INTEGER) */
- if ((count = asn1_parse(np, length, &elem)) < 0)
+ if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
return;
if (elem.type != BE_INT) {
- fputs("[msgAuthoritativeEngineTime!=INT]", stdout);
- asn1_print(&elem);
+ ND_PRINT((ndo, "[msgAuthoritativeEngineTime!=INT]"));
+ asn1_print(ndo, &elem);
return;
}
- if (vflag)
- printf("T=%d ", elem.data.integer);
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo, "T=%d ", elem.data.integer));
length -= count;
np += count;
/* msgUserName (OCTET STRING) */
- if ((count = asn1_parse(np, length, &elem)) < 0)
+ if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
return;
if (elem.type != BE_STR) {
- fputs("[msgUserName!=STR]", stdout);
- asn1_print(&elem);
+ ND_PRINT((ndo, "[msgUserName!=STR]"));
+ asn1_print(ndo, &elem);
return;
}
length -= count;
np += count;
- printf("U=%.*s ", (int)elem.asnlen, elem.data.str);
+ ND_PRINT((ndo, "U="));
+ if (asn1_print_string(ndo, &elem) == -1)
+ return;
+ ND_PRINT((ndo, " "));
/* msgAuthenticationParameters (OCTET STRING) */
- if ((count = asn1_parse(np, length, &elem)) < 0)
+ if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
return;
if (elem.type != BE_STR) {
- fputs("[msgAuthenticationParameters!=STR]", stdout);
- asn1_print(&elem);
+ ND_PRINT((ndo, "[msgAuthenticationParameters!=STR]"));
+ asn1_print(ndo, &elem);
return;
}
length -= count;
np += count;
/* msgPrivacyParameters (OCTET STRING) */
- if ((count = asn1_parse(np, length, &elem)) < 0)
+ if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
return;
if (elem.type != BE_STR) {
- fputs("[msgPrivacyParameters!=STR]", stdout);
- asn1_print(&elem);
+ ND_PRINT((ndo, "[msgPrivacyParameters!=STR]"));
+ asn1_print(ndo, &elem);
return;
}
length -= count;
np += count;
if ((u_int)count < length)
- printf("[%d extra after usm SEQ]", length - count);
+ ND_PRINT((ndo, "[%d extra after usm SEQ]", length - count));
}
/*
* Decode SNMPv3 Message Header (SNMPv3)
*/
static void
-v3msg_print(const u_char *np, u_int length)
+v3msg_print(netdissect_options *ndo,
+ const u_char *np, u_int length)
{
struct be elem;
int count = 0;
@@ -1714,75 +1752,74 @@ v3msg_print(const u_char *np, u_int length)
int xlength = length;
/* Sequence */
- if ((count = asn1_parse(np, length, &elem)) < 0)
+ if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
return;
if (elem.type != BE_SEQ) {
- fputs("[!message]", stdout);
- asn1_print(&elem);
+ ND_PRINT((ndo, "[!message]"));
+ asn1_print(ndo, &elem);
return;
}
length = elem.asnlen;
- np = (u_char *)elem.data.raw;
+ np = (const u_char *)elem.data.raw;
- if (vflag) {
- fputs("{ ", stdout);
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo, "{ "));
}
/* msgID (INTEGER) */
- if ((count = asn1_parse(np, length, &elem)) < 0)
+ if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
return;
if (elem.type != BE_INT) {
- fputs("[msgID!=INT]", stdout);
- asn1_print(&elem);
+ ND_PRINT((ndo, "[msgID!=INT]"));
+ asn1_print(ndo, &elem);
return;
}
length -= count;
np += count;
/* msgMaxSize (INTEGER) */
- if ((count = asn1_parse(np, length, &elem)) < 0)
+ if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
return;
if (elem.type != BE_INT) {
- fputs("[msgMaxSize!=INT]", stdout);
- asn1_print(&elem);
+ ND_PRINT((ndo, "[msgMaxSize!=INT]"));
+ asn1_print(ndo, &elem);
return;
}
length -= count;
np += count;
/* msgFlags (OCTET STRING) */
- if ((count = asn1_parse(np, length, &elem)) < 0)
+ if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
return;
if (elem.type != BE_STR) {
- fputs("[msgFlags!=STR]", stdout);
- asn1_print(&elem);
+ ND_PRINT((ndo, "[msgFlags!=STR]"));
+ asn1_print(ndo, &elem);
return;
}
if (elem.asnlen != 1) {
- printf("[msgFlags size %d]", elem.asnlen);
+ ND_PRINT((ndo, "[msgFlags size %d]", elem.asnlen));
return;
}
flags = elem.data.str[0];
if (flags != 0x00 && flags != 0x01 && flags != 0x03
&& flags != 0x04 && flags != 0x05 && flags != 0x07) {
- printf("[msgFlags=0x%02X]", flags);
+ ND_PRINT((ndo, "[msgFlags=0x%02X]", flags));
return;
}
length -= count;
np += count;
- fputs("F=", stdout);
- if (flags & 0x01) fputs("a", stdout);
- if (flags & 0x02) fputs("p", stdout);
- if (flags & 0x04) fputs("r", stdout);
- fputs(" ", stdout);
+ ND_PRINT((ndo, "F=%s%s%s ",
+ flags & 0x01 ? "a" : "",
+ flags & 0x02 ? "p" : "",
+ flags & 0x04 ? "r" : ""));
/* msgSecurityModel (INTEGER) */
- if ((count = asn1_parse(np, length, &elem)) < 0)
+ if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
return;
if (elem.type != BE_INT) {
- fputs("[msgSecurityModel!=INT]", stdout);
- asn1_print(&elem);
+ ND_PRINT((ndo, "[msgSecurityModel!=INT]"));
+ asn1_print(ndo, &elem);
return;
}
model = elem.data.integer;
@@ -1790,18 +1827,18 @@ v3msg_print(const u_char *np, u_int length)
np += count;
if ((u_int)count < length)
- printf("[%d extra after message SEQ]", length - count);
+ ND_PRINT((ndo, "[%d extra after message SEQ]", length - count));
- if (vflag) {
- fputs("} ", stdout);
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo, "} "));
}
if (model == 3) {
- if (vflag) {
- fputs("{ USM ", stdout);
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo, "{ USM "));
}
} else {
- printf("[security model %d]", model);
+ ND_PRINT((ndo, "[security model %d]", model));
return;
}
@@ -1809,31 +1846,31 @@ v3msg_print(const u_char *np, u_int length)
length = xlength - (np - xnp);
/* msgSecurityParameters (OCTET STRING) */
- if ((count = asn1_parse(np, length, &elem)) < 0)
+ if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
return;
if (elem.type != BE_STR) {
- fputs("[msgSecurityParameters!=STR]", stdout);
- asn1_print(&elem);
+ ND_PRINT((ndo, "[msgSecurityParameters!=STR]"));
+ asn1_print(ndo, &elem);
return;
}
length -= count;
np += count;
if (model == 3) {
- usm_print(elem.data.str, elem.asnlen);
- if (vflag) {
- fputs("} ", stdout);
+ usm_print(ndo, elem.data.str, elem.asnlen);
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo, "} "));
}
}
- if (vflag) {
- fputs("{ ScopedPDU ", stdout);
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo, "{ ScopedPDU "));
}
- scopedpdu_print(np, length, 3);
+ scopedpdu_print(ndo, np, length, 3);
- if (vflag) {
- fputs("} ", stdout);
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo, "} "));
}
}
@@ -1841,34 +1878,35 @@ v3msg_print(const u_char *np, u_int length)
* Decode SNMP header and pass on to PDU printing routines
*/
void
-snmp_print(const u_char *np, u_int length)
+snmp_print(netdissect_options *ndo,
+ const u_char *np, u_int length)
{
struct be elem;
int count = 0;
int version = 0;
- putchar(' ');
+ ND_PRINT((ndo, " "));
/* initial Sequence */
- if ((count = asn1_parse(np, length, &elem)) < 0)
+ if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
return;
if (elem.type != BE_SEQ) {
- fputs("[!init SEQ]", stdout);
- asn1_print(&elem);
+ ND_PRINT((ndo, "[!init SEQ]"));
+ asn1_print(ndo, &elem);
return;
}
if ((u_int)count < length)
- printf("[%d extra after iSEQ]", length - count);
+ ND_PRINT((ndo, "[%d extra after iSEQ]", length - count));
/* descend */
length = elem.asnlen;
- np = (u_char *)elem.data.raw;
+ np = (const u_char *)elem.data.raw;
/* Version (INTEGER) */
- if ((count = asn1_parse(np, length, &elem)) < 0)
+ if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
return;
if (elem.type != BE_INT) {
- fputs("[version!=INT]", stdout);
- asn1_print(&elem);
+ ND_PRINT((ndo, "[version!=INT]"));
+ asn1_print(ndo, &elem);
return;
}
@@ -1876,11 +1914,11 @@ snmp_print(const u_char *np, u_int length)
case SNMP_VERSION_1:
case SNMP_VERSION_2:
case SNMP_VERSION_3:
- if (vflag)
- printf("{ %s ", SnmpVersion[elem.data.integer]);
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo, "{ %s ", SnmpVersion[elem.data.integer]));
break;
default:
- printf("[version = %d]", elem.data.integer);
+ ND_PRINT((ndo, "SNMP [version = %d]", elem.data.integer));
return;
}
version = elem.data.integer;
@@ -1890,17 +1928,20 @@ snmp_print(const u_char *np, u_int length)
switch (version) {
case SNMP_VERSION_1:
case SNMP_VERSION_2:
- community_print(np, length, version);
+ community_print(ndo, np, length, version);
break;
case SNMP_VERSION_3:
- v3msg_print(np, length);
+ v3msg_print(ndo, np, length);
break;
default:
- printf("[version = %d]", elem.data.integer);
+ ND_PRINT((ndo, "[version = %d]", elem.data.integer));
break;
}
- if (vflag) {
- fputs("} ", stdout);
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo, "} "));
}
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-snmp-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-stp.c b/freebsd/contrib/tcpdump/print-stp.c
index 6cd9432e..5563271c 100644
--- a/freebsd/contrib/tcpdump/print-stp.c
+++ b/freebsd/contrib/tcpdump/print-stp.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 2000 Lennert Buytenhek
*
@@ -7,48 +10,41 @@
* BSD-style license that accompanies tcpdump or the GNU General
* Public License
*
- * Format and print IEEE 802.1d spanning tree protocol packets.
* Contributed by Lennert Buytenhek <buytenh@gnu.org>
*/
-#ifndef lint
-static const char rcsid[] _U_ =
-"@(#) $Header: /tcpdump/master/tcpdump/print-stp.c,v 1.20 2007-03-18 17:11:46 hannes Exp $";
-#endif
+/* \summary: IEEE 802.1d Spanning Tree Protocol (STP) printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include <stdlib.h>
#include <stdio.h>
-#include <string.h>
-#include "interface.h"
-#include "addrtoname.h"
+#include "netdissect.h"
#include "extract.h"
-#define RSTP_EXTRACT_PORT_ROLE(x) (((x)&0x0C)>>2)
+#define RSTP_EXTRACT_PORT_ROLE(x) (((x)&0x0C)>>2)
/* STP timers are expressed in multiples of 1/256th second */
#define STP_TIME_BASE 256
#define STP_BPDU_MSTP_MIN_LEN 102
struct stp_bpdu_ {
- u_int8_t protocol_id[2];
- u_int8_t protocol_version;
- u_int8_t bpdu_type;
- u_int8_t flags;
- u_int8_t root_id[8];
- u_int8_t root_path_cost[4];
- u_int8_t bridge_id[8];
- u_int8_t port_id[2];
- u_int8_t message_age[2];
- u_int8_t max_age[2];
- u_int8_t hello_time[2];
- u_int8_t forward_delay[2];
- u_int8_t v1_length;
+ uint8_t protocol_id[2];
+ uint8_t protocol_version;
+ uint8_t bpdu_type;
+ uint8_t flags;
+ uint8_t root_id[8];
+ uint8_t root_path_cost[4];
+ uint8_t bridge_id[8];
+ uint8_t port_id[2];
+ uint8_t message_age[2];
+ uint8_t max_age[2];
+ uint8_t hello_time[2];
+ uint8_t forward_delay[2];
+ uint8_t v1_length;
};
#define STP_PROTO_REGULAR 0x00
@@ -56,7 +52,7 @@ struct stp_bpdu_ {
#define STP_PROTO_MSTP 0x03
#define STP_PROTO_SPB 0x04
-struct tok stp_proto_values[] = {
+static const struct tok stp_proto_values[] = {
{ STP_PROTO_REGULAR, "802.1d" },
{ STP_PROTO_RAPID, "802.1w" },
{ STP_PROTO_MSTP, "802.1s" },
@@ -68,7 +64,7 @@ struct tok stp_proto_values[] = {
#define STP_BPDU_TYPE_RSTP 0x02
#define STP_BPDU_TYPE_TOPO_CHANGE 0x80
-struct tok stp_bpdu_flag_values[] = {
+static const struct tok stp_bpdu_flag_values[] = {
{ 0x01, "Topology change" },
{ 0x02, "Proposal" },
{ 0x10, "Learn" },
@@ -78,14 +74,14 @@ struct tok stp_bpdu_flag_values[] = {
{ 0, NULL}
};
-struct tok stp_bpdu_type_values[] = {
+static const struct tok stp_bpdu_type_values[] = {
{ STP_BPDU_TYPE_CONFIG, "Config" },
{ STP_BPDU_TYPE_RSTP, "Rapid STP" },
{ STP_BPDU_TYPE_TOPO_CHANGE, "Topology Change" },
{ 0, NULL}
};
-struct tok rstp_obj_port_role_values[] = {
+static const struct tok rstp_obj_port_role_values[] = {
{ 0x00, "Unknown" },
{ 0x01, "Alternate" },
{ 0x02, "Root" },
@@ -93,6 +89,8 @@ struct tok rstp_obj_port_role_values[] = {
{ 0, NULL}
};
+#define ND_TCHECK_BRIDGE_ID(p) ND_TCHECK2(*(p), 8)
+
static char *
stp_print_bridge_id(const u_char *p)
{
@@ -105,38 +103,46 @@ stp_print_bridge_id(const u_char *p)
return bridge_id_str;
}
-static void
-stp_print_config_bpdu(const struct stp_bpdu_ *stp_bpdu, u_int length)
+static int
+stp_print_config_bpdu(netdissect_options *ndo, const struct stp_bpdu_ *stp_bpdu,
+ u_int length)
{
- printf(", Flags [%s]",
- bittok2str(stp_bpdu_flag_values, "none", stp_bpdu->flags));
+ ND_TCHECK(stp_bpdu->flags);
+ ND_PRINT((ndo, ", Flags [%s]",
+ bittok2str(stp_bpdu_flag_values, "none", stp_bpdu->flags)));
- printf(", bridge-id %s.%04x, length %u",
+ ND_TCHECK(stp_bpdu->port_id);
+ ND_PRINT((ndo, ", bridge-id %s.%04x, length %u",
stp_print_bridge_id((const u_char *)&stp_bpdu->bridge_id),
- EXTRACT_16BITS(&stp_bpdu->port_id), length);
+ EXTRACT_16BITS(&stp_bpdu->port_id), length));
/* in non-verbose mode just print the bridge-id */
- if (!vflag) {
- return;
+ if (!ndo->ndo_vflag) {
+ return 1;
}
- printf("\n\tmessage-age %.2fs, max-age %.2fs"
+ ND_TCHECK(stp_bpdu->forward_delay);
+ ND_PRINT((ndo, "\n\tmessage-age %.2fs, max-age %.2fs"
", hello-time %.2fs, forwarding-delay %.2fs",
(float)EXTRACT_16BITS(&stp_bpdu->message_age) / STP_TIME_BASE,
(float)EXTRACT_16BITS(&stp_bpdu->max_age) / STP_TIME_BASE,
(float)EXTRACT_16BITS(&stp_bpdu->hello_time) / STP_TIME_BASE,
- (float)EXTRACT_16BITS(&stp_bpdu->forward_delay) / STP_TIME_BASE);
+ (float)EXTRACT_16BITS(&stp_bpdu->forward_delay) / STP_TIME_BASE));
- printf("\n\troot-id %s, root-pathcost %u",
+ ND_PRINT((ndo, "\n\troot-id %s, root-pathcost %u",
stp_print_bridge_id((const u_char *)&stp_bpdu->root_id),
- EXTRACT_32BITS(&stp_bpdu->root_path_cost));
+ EXTRACT_32BITS(&stp_bpdu->root_path_cost)));
/* Port role is only valid for 802.1w */
if (stp_bpdu->protocol_version == STP_PROTO_RAPID) {
- printf(", port-role %s",
+ ND_PRINT((ndo, ", port-role %s",
tok2str(rstp_obj_port_role_values, "Unknown",
- RSTP_EXTRACT_PORT_ROLE(stp_bpdu->flags)));
+ RSTP_EXTRACT_PORT_ROLE(stp_bpdu->flags))));
}
+ return 1;
+
+trunc:
+ return 0;
}
/*
@@ -146,7 +152,7 @@ stp_print_config_bpdu(const struct stp_bpdu_ *stp_bpdu, u_int length)
* MSTP BPDU
*
* 2 - bytes Protocol Id
- * 1 - byte Protocol Ver.
+ * 1 - byte Protocol Ver.
* 1 - byte BPDU tye
* 1 - byte Flags
* 8 - bytes CIST Root Identifier
@@ -173,11 +179,11 @@ stp_print_config_bpdu(const struct stp_bpdu_ *stp_bpdu, u_int length)
* Ref. IEEE 802.1aq. Section 14
*
* 2 - bytes Version 4 length
- * 1 - byte Aux Config Identifier
+ * 1 - byte Aux Config Identifier
* 32 - bytes Aux Config Name
* 2 - bytes Aux Revision level
* 16 - bytes Aux Config Digest [MD5]
- * 1 - byte (1 - 2) Agreement Number
+ * 1 - byte (1 - 2) Agreement Number
* (3 - 4) Discarded Agreement Number
* (5) Agreement Valid Flag
* (6) Restricted Role Flag
@@ -234,150 +240,190 @@ stp_print_config_bpdu(const struct stp_bpdu_ *stp_bpdu, u_int length)
#define SPB_BPDU_AGREEMENT_RES2_OFFSET SPB_BPDU_AGREEMENT_RES1_OFFSET + 4
#define SPB_BPDU_AGREEMENT_DIGEST_OFFSET SPB_BPDU_AGREEMENT_RES2_OFFSET + 4
-
-static void
-stp_print_mstp_bpdu(const struct stp_bpdu_ *stp_bpdu, u_int length)
+static int
+stp_print_mstp_bpdu(netdissect_options *ndo, const struct stp_bpdu_ *stp_bpdu,
+ u_int length)
{
const u_char *ptr;
- u_int16_t v3len;
- u_int16_t len;
- u_int16_t msti;
- u_int16_t offset;
+ uint16_t v3len;
+ uint16_t len;
+ uint16_t msti;
+ u_int offset;
ptr = (const u_char *)stp_bpdu;
- printf(", CIST Flags [%s], length %u",
- bittok2str(stp_bpdu_flag_values, "none", stp_bpdu->flags), length);
+ ND_PRINT((ndo, ", CIST Flags [%s], length %u",
+ bittok2str(stp_bpdu_flag_values, "none", stp_bpdu->flags), length));
/*
- * in non-verbose mode just print the flags. We dont read that much
- * of the packet (DEFAULT_SNAPLEN) to print out cist bridge-id
+ * in non-verbose mode just print the flags.
*/
- if (!vflag) {
- return;
+ if (!ndo->ndo_vflag) {
+ return 1;
}
- printf("\n\tport-role %s, ",
+ ND_PRINT((ndo, "\n\tport-role %s, ",
tok2str(rstp_obj_port_role_values, "Unknown",
- RSTP_EXTRACT_PORT_ROLE(stp_bpdu->flags)));
+ RSTP_EXTRACT_PORT_ROLE(stp_bpdu->flags))));
- printf("CIST root-id %s, CIST ext-pathcost %u ",
+ ND_TCHECK(stp_bpdu->root_path_cost);
+ ND_PRINT((ndo, "CIST root-id %s, CIST ext-pathcost %u",
stp_print_bridge_id((const u_char *)&stp_bpdu->root_id),
- EXTRACT_32BITS(&stp_bpdu->root_path_cost));
+ EXTRACT_32BITS(&stp_bpdu->root_path_cost)));
- printf("\n\tCIST regional-root-id %s, ",
- stp_print_bridge_id((const u_char *)&stp_bpdu->bridge_id));
+ ND_TCHECK(stp_bpdu->bridge_id);
+ ND_PRINT((ndo, "\n\tCIST regional-root-id %s, ",
+ stp_print_bridge_id((const u_char *)&stp_bpdu->bridge_id)));
- printf("CIST port-id %04x, ", EXTRACT_16BITS(&stp_bpdu->port_id));
+ ND_TCHECK(stp_bpdu->port_id);
+ ND_PRINT((ndo, "CIST port-id %04x,", EXTRACT_16BITS(&stp_bpdu->port_id)));
- printf("\n\tmessage-age %.2fs, max-age %.2fs"
+ ND_TCHECK(stp_bpdu->forward_delay);
+ ND_PRINT((ndo, "\n\tmessage-age %.2fs, max-age %.2fs"
", hello-time %.2fs, forwarding-delay %.2fs",
(float)EXTRACT_16BITS(&stp_bpdu->message_age) / STP_TIME_BASE,
(float)EXTRACT_16BITS(&stp_bpdu->max_age) / STP_TIME_BASE,
(float)EXTRACT_16BITS(&stp_bpdu->hello_time) / STP_TIME_BASE,
- (float)EXTRACT_16BITS(&stp_bpdu->forward_delay) / STP_TIME_BASE);
-
- printf ("\n\tv3len %d, ", EXTRACT_16BITS(ptr + MST_BPDU_VER3_LEN_OFFSET));
- printf("MCID Name %s, rev %u, "
+ (float)EXTRACT_16BITS(&stp_bpdu->forward_delay) / STP_TIME_BASE));
+
+ ND_TCHECK_16BITS(ptr + MST_BPDU_VER3_LEN_OFFSET);
+ ND_PRINT((ndo, "\n\tv3len %d, ", EXTRACT_16BITS(ptr + MST_BPDU_VER3_LEN_OFFSET)));
+ ND_TCHECK_32BITS(ptr + MST_BPDU_CONFIG_DIGEST_OFFSET + 12);
+ ND_PRINT((ndo, "MCID Name "));
+ if (fn_printzp(ndo, ptr + MST_BPDU_CONFIG_NAME_OFFSET, 32, ndo->ndo_snapend))
+ goto trunc;
+ ND_PRINT((ndo, ", rev %u,"
"\n\t\tdigest %08x%08x%08x%08x, ",
- ptr + MST_BPDU_CONFIG_NAME_OFFSET,
EXTRACT_16BITS(ptr + MST_BPDU_CONFIG_NAME_OFFSET + 32),
- EXTRACT_32BITS(ptr + MST_BPDU_CONFIG_DIGEST_OFFSET),
- EXTRACT_32BITS(ptr + MST_BPDU_CONFIG_DIGEST_OFFSET + 4),
+ EXTRACT_32BITS(ptr + MST_BPDU_CONFIG_DIGEST_OFFSET),
+ EXTRACT_32BITS(ptr + MST_BPDU_CONFIG_DIGEST_OFFSET + 4),
EXTRACT_32BITS(ptr + MST_BPDU_CONFIG_DIGEST_OFFSET + 8),
- EXTRACT_32BITS(ptr + MST_BPDU_CONFIG_DIGEST_OFFSET + 12));
+ EXTRACT_32BITS(ptr + MST_BPDU_CONFIG_DIGEST_OFFSET + 12)));
- printf ("CIST int-root-pathcost %u, ",
- EXTRACT_32BITS(ptr + MST_BPDU_CIST_INT_PATH_COST_OFFSET));
+ ND_TCHECK_32BITS(ptr + MST_BPDU_CIST_INT_PATH_COST_OFFSET);
+ ND_PRINT((ndo, "CIST int-root-pathcost %u,",
+ EXTRACT_32BITS(ptr + MST_BPDU_CIST_INT_PATH_COST_OFFSET)));
- printf("\n\tCIST bridge-id %s, ",
- stp_print_bridge_id(ptr + MST_BPDU_CIST_BRIDGE_ID_OFFSET));
+ ND_TCHECK_BRIDGE_ID(ptr + MST_BPDU_CIST_BRIDGE_ID_OFFSET);
+ ND_PRINT((ndo, "\n\tCIST bridge-id %s, ",
+ stp_print_bridge_id(ptr + MST_BPDU_CIST_BRIDGE_ID_OFFSET)));
- printf("CIST remaining-hops %d", ptr[MST_BPDU_CIST_REMAIN_HOPS_OFFSET]);
+ ND_TCHECK(ptr[MST_BPDU_CIST_REMAIN_HOPS_OFFSET]);
+ ND_PRINT((ndo, "CIST remaining-hops %d", ptr[MST_BPDU_CIST_REMAIN_HOPS_OFFSET]));
/* Dump all MSTI's */
+ ND_TCHECK_16BITS(ptr + MST_BPDU_VER3_LEN_OFFSET);
v3len = EXTRACT_16BITS(ptr + MST_BPDU_VER3_LEN_OFFSET);
if (v3len > MST_BPDU_CONFIG_INFO_LENGTH) {
len = v3len - MST_BPDU_CONFIG_INFO_LENGTH;
offset = MST_BPDU_MSTI_OFFSET;
while (len >= MST_BPDU_MSTI_LENGTH) {
+ ND_TCHECK2(*(ptr + offset), MST_BPDU_MSTI_LENGTH);
+
msti = EXTRACT_16BITS(ptr + offset +
MST_BPDU_MSTI_ROOT_PRIO_OFFSET);
msti = msti & 0x0FFF;
- printf("\n\tMSTI %d, Flags [%s], port-role %s",
+ ND_PRINT((ndo, "\n\tMSTI %d, Flags [%s], port-role %s",
msti, bittok2str(stp_bpdu_flag_values, "none", ptr[offset]),
tok2str(rstp_obj_port_role_values, "Unknown",
- RSTP_EXTRACT_PORT_ROLE(ptr[offset])));
- printf("\n\t\tMSTI regional-root-id %s, pathcost %u",
+ RSTP_EXTRACT_PORT_ROLE(ptr[offset]))));
+ ND_PRINT((ndo, "\n\t\tMSTI regional-root-id %s, pathcost %u",
stp_print_bridge_id(ptr + offset +
MST_BPDU_MSTI_ROOT_PRIO_OFFSET),
EXTRACT_32BITS(ptr + offset +
- MST_BPDU_MSTI_ROOT_PATH_COST_OFFSET));
- printf("\n\t\tMSTI bridge-prio %d, port-prio %d, hops %d",
+ MST_BPDU_MSTI_ROOT_PATH_COST_OFFSET)));
+ ND_PRINT((ndo, "\n\t\tMSTI bridge-prio %d, port-prio %d, hops %d",
ptr[offset + MST_BPDU_MSTI_BRIDGE_PRIO_OFFSET] >> 4,
ptr[offset + MST_BPDU_MSTI_PORT_PRIO_OFFSET] >> 4,
- ptr[offset + MST_BPDU_MSTI_REMAIN_HOPS_OFFSET]);
+ ptr[offset + MST_BPDU_MSTI_REMAIN_HOPS_OFFSET]));
len -= MST_BPDU_MSTI_LENGTH;
offset += MST_BPDU_MSTI_LENGTH;
}
}
+ return 1;
+
+trunc:
+ return 0;
+}
+
+static int
+stp_print_spb_bpdu(netdissect_options *ndo, const struct stp_bpdu_ *stp_bpdu,
+ u_int offset)
+{
+ const u_char *ptr;
+
+ /*
+ * in non-verbose mode don't print anything.
+ */
+ if (!ndo->ndo_vflag) {
+ return 1;
+ }
- if ((length-offset) >= SPB_BPDU_MIN_LEN)
- {
- printf("\n\tv4len %d AUXMCID Name %s, Rev %u, \n\t\tdigest %08x%08x%08x%08x",
- EXTRACT_16BITS (ptr + offset),
- ptr + offset + SPB_BPDU_CONFIG_NAME_OFFSET,
- EXTRACT_16BITS(ptr + offset + SPB_BPDU_CONFIG_REV_OFFSET),
- EXTRACT_32BITS(ptr + offset + SPB_BPDU_CONFIG_DIGEST_OFFSET),
- EXTRACT_32BITS(ptr + offset + SPB_BPDU_CONFIG_DIGEST_OFFSET + 4),
- EXTRACT_32BITS(ptr + offset + SPB_BPDU_CONFIG_DIGEST_OFFSET + 8),
- EXTRACT_32BITS(ptr + offset + SPB_BPDU_CONFIG_DIGEST_OFFSET + 12));
-
- printf("\n\tAgreement num %d, Discarded Agreement num %d, Agreement valid-"
- "flag %d, \n\tRestricted role-flag: %d, Format id %d cap %d, "
- "Convention id %d cap %d, \n\tEdge count %d, "
- "Agreement digest %08x%08x%08x%08x%08x\n",
- ptr[offset + SPB_BPDU_AGREEMENT_OFFSET]>>6,
- ptr[offset + SPB_BPDU_AGREEMENT_OFFSET]>>4 & 0x3,
- ptr[offset + SPB_BPDU_AGREEMENT_OFFSET]>>3 & 0x1,
- ptr[offset + SPB_BPDU_AGREEMENT_OFFSET]>>2 & 0x1,
- ptr[offset + SPB_BPDU_AGREEMENT_FORMAT_OFFSET]>>4,
- ptr[offset + SPB_BPDU_AGREEMENT_FORMAT_OFFSET]&0x00ff,
- ptr[offset + SPB_BPDU_AGREEMENT_CON_OFFSET]>>4,
- ptr[offset + SPB_BPDU_AGREEMENT_CON_OFFSET]&0x00ff,
- EXTRACT_16BITS(ptr + offset + SPB_BPDU_AGREEMENT_EDGE_OFFSET),
- EXTRACT_32BITS(ptr + offset + SPB_BPDU_AGREEMENT_DIGEST_OFFSET),
- EXTRACT_32BITS(ptr + offset + SPB_BPDU_AGREEMENT_DIGEST_OFFSET)+4,
- EXTRACT_32BITS(ptr + offset + SPB_BPDU_AGREEMENT_DIGEST_OFFSET)+8,
- EXTRACT_32BITS(ptr + offset + SPB_BPDU_AGREEMENT_DIGEST_OFFSET)+12,
- EXTRACT_32BITS(ptr + offset + SPB_BPDU_AGREEMENT_DIGEST_OFFSET)+16);
- }
+ ptr = (const u_char *)stp_bpdu;
+ ND_TCHECK_32BITS(ptr + offset + SPB_BPDU_AGREEMENT_DIGEST_OFFSET + 16);
+
+ ND_PRINT((ndo, "\n\tv4len %d, ", EXTRACT_16BITS (ptr + offset)));
+ ND_PRINT((ndo, "AUXMCID Name "));
+ if (fn_printzp(ndo, ptr + offset + SPB_BPDU_CONFIG_NAME_OFFSET, 32,
+ ndo->ndo_snapend))
+ goto trunc;
+ ND_PRINT((ndo, ", Rev %u,\n\t\tdigest %08x%08x%08x%08x",
+ EXTRACT_16BITS(ptr + offset + SPB_BPDU_CONFIG_REV_OFFSET),
+ EXTRACT_32BITS(ptr + offset + SPB_BPDU_CONFIG_DIGEST_OFFSET),
+ EXTRACT_32BITS(ptr + offset + SPB_BPDU_CONFIG_DIGEST_OFFSET + 4),
+ EXTRACT_32BITS(ptr + offset + SPB_BPDU_CONFIG_DIGEST_OFFSET + 8),
+ EXTRACT_32BITS(ptr + offset + SPB_BPDU_CONFIG_DIGEST_OFFSET + 12)));
+
+ ND_PRINT((ndo, "\n\tAgreement num %d, Discarded Agreement num %d, Agreement valid-"
+ "flag %d,\n\tRestricted role-flag: %d, Format id %d cap %d, "
+ "Convention id %d cap %d,\n\tEdge count %d, "
+ "Agreement digest %08x%08x%08x%08x%08x\n",
+ ptr[offset + SPB_BPDU_AGREEMENT_OFFSET]>>6,
+ ptr[offset + SPB_BPDU_AGREEMENT_OFFSET]>>4 & 0x3,
+ ptr[offset + SPB_BPDU_AGREEMENT_OFFSET]>>3 & 0x1,
+ ptr[offset + SPB_BPDU_AGREEMENT_OFFSET]>>2 & 0x1,
+ ptr[offset + SPB_BPDU_AGREEMENT_FORMAT_OFFSET]>>4,
+ ptr[offset + SPB_BPDU_AGREEMENT_FORMAT_OFFSET]&0x00ff,
+ ptr[offset + SPB_BPDU_AGREEMENT_CON_OFFSET]>>4,
+ ptr[offset + SPB_BPDU_AGREEMENT_CON_OFFSET]&0x00ff,
+ EXTRACT_16BITS(ptr + offset + SPB_BPDU_AGREEMENT_EDGE_OFFSET),
+ EXTRACT_32BITS(ptr + offset + SPB_BPDU_AGREEMENT_DIGEST_OFFSET),
+ EXTRACT_32BITS(ptr + offset + SPB_BPDU_AGREEMENT_DIGEST_OFFSET+4),
+ EXTRACT_32BITS(ptr + offset + SPB_BPDU_AGREEMENT_DIGEST_OFFSET+8),
+ EXTRACT_32BITS(ptr + offset + SPB_BPDU_AGREEMENT_DIGEST_OFFSET+12),
+ EXTRACT_32BITS(ptr + offset + SPB_BPDU_AGREEMENT_DIGEST_OFFSET+16)));
+ return 1;
+
+trunc:
+ return 0;
}
/*
* Print 802.1d / 802.1w / 802.1q (mstp) / 802.1aq (spb) packets.
*/
void
-stp_print(const u_char *p, u_int length)
+stp_print(netdissect_options *ndo, const u_char *p, u_int length)
{
const struct stp_bpdu_ *stp_bpdu;
- u_int16_t mstp_len;
- u_int16_t spb_len;
-
- stp_bpdu = (struct stp_bpdu_*)p;
+ u_int mstp_len;
+ u_int spb_len;
+
+ stp_bpdu = (const struct stp_bpdu_*)p;
/* Minimum STP Frame size. */
if (length < 4)
goto trunc;
-
+
+ ND_TCHECK(stp_bpdu->protocol_id);
if (EXTRACT_16BITS(&stp_bpdu->protocol_id)) {
- printf("unknown STP version, length %u", length);
+ ND_PRINT((ndo, "unknown STP version, length %u", length));
return;
}
- printf("STP %s", tok2str(stp_proto_values, "Unknown STP protocol (0x%02x)",
- stp_bpdu->protocol_version));
+ ND_TCHECK(stp_bpdu->protocol_version);
+ ND_PRINT((ndo, "STP %s", tok2str(stp_proto_values, "Unknown STP protocol (0x%02x)",
+ stp_bpdu->protocol_version)));
switch (stp_bpdu->protocol_version) {
case STP_PROTO_REGULAR:
@@ -389,15 +435,17 @@ stp_print(const u_char *p, u_int length)
return;
}
- printf(", %s", tok2str(stp_bpdu_type_values, "Unknown BPDU Type (0x%02x)",
- stp_bpdu->bpdu_type));
+ ND_TCHECK(stp_bpdu->bpdu_type);
+ ND_PRINT((ndo, ", %s", tok2str(stp_bpdu_type_values, "Unknown BPDU Type (0x%02x)",
+ stp_bpdu->bpdu_type)));
switch (stp_bpdu->bpdu_type) {
case STP_BPDU_TYPE_CONFIG:
if (length < sizeof(struct stp_bpdu_) - 1) {
goto trunc;
}
- stp_print_config_bpdu(stp_bpdu, length);
+ if (!stp_print_config_bpdu(ndo, stp_bpdu, length))
+ goto trunc;
break;
case STP_BPDU_TYPE_RSTP:
@@ -405,24 +453,29 @@ stp_print(const u_char *p, u_int length)
if (length < sizeof(struct stp_bpdu_)) {
goto trunc;
}
- stp_print_config_bpdu(stp_bpdu, length);
+ if (!stp_print_config_bpdu(ndo, stp_bpdu, length))
+ goto trunc;
} else if (stp_bpdu->protocol_version == STP_PROTO_MSTP ||
stp_bpdu->protocol_version == STP_PROTO_SPB) {
if (length < STP_BPDU_MSTP_MIN_LEN) {
goto trunc;
}
+ ND_TCHECK(stp_bpdu->v1_length);
if (stp_bpdu->v1_length != 0) {
/* FIX ME: Emit a message here ? */
goto trunc;
}
/* Validate v3 length */
+ ND_TCHECK_16BITS(p + MST_BPDU_VER3_LEN_OFFSET);
mstp_len = EXTRACT_16BITS(p + MST_BPDU_VER3_LEN_OFFSET);
mstp_len += 2; /* length encoding itself is 2 bytes */
if (length < (sizeof(struct stp_bpdu_) + mstp_len)) {
goto trunc;
}
+ if (!stp_print_mstp_bpdu(ndo, stp_bpdu, length))
+ goto trunc;
if (stp_bpdu->protocol_version == STP_PROTO_SPB)
{
@@ -433,9 +486,9 @@ stp_print(const u_char *p, u_int length)
spb_len < SPB_BPDU_MIN_LEN) {
goto trunc;
}
+ if (!stp_print_spb_bpdu(ndo, stp_bpdu, (sizeof(struct stp_bpdu_) + mstp_len)))
+ goto trunc;
}
-
- stp_print_mstp_bpdu(stp_bpdu, length);
}
break;
@@ -448,8 +501,8 @@ stp_print(const u_char *p, u_int length)
}
return;
- trunc:
- printf("[|stp %d]", length);
+trunc:
+ ND_PRINT((ndo, "[|stp %d]", length));
}
/*
@@ -458,3 +511,6 @@ stp_print(const u_char *p, u_int length)
* c-basic-offset: 4
* End:
*/
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-stp-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-sunatm.c b/freebsd/contrib/tcpdump/print-sunatm.c
index 2cd223da..111b111e 100644
--- a/freebsd/contrib/tcpdump/print-sunatm.c
+++ b/freebsd/contrib/tcpdump/print-sunatm.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1997 Yen Yen Lim and North Dakota State University
* All rights reserved.
@@ -31,29 +34,22 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-sunatm.c,v 1.8 2004-03-17 23:24:38 guy Exp $ (LBL)";
-#endif
+
+/* \summary: SunATM DLPI capture printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
-
+#include <netdissect-stdinc.h>
+
struct mbuf;
struct rtentry;
-
-#include <stdio.h>
-#include <pcap.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
-#include "addrtoname.h"
#include "atm.h"
-#include "atmuni31.h"
/* SunATM header for ATM packet */
#define DIR_POS 0 /* Direction (0x80 = transmit, 0x00 = receive) */
@@ -72,7 +68,8 @@ struct rtentry;
* is the number of bytes actually captured.
*/
u_int
-sunatm_if_print(const struct pcap_pkthdr *h, const u_char *p)
+sunatm_if_print(netdissect_options *ndo,
+ const struct pcap_pkthdr *h, const u_char *p)
{
u_int caplen = h->caplen;
u_int length = h->len;
@@ -81,15 +78,12 @@ sunatm_if_print(const struct pcap_pkthdr *h, const u_char *p)
u_int traftype;
if (caplen < PKT_BEGIN_POS) {
- printf("[|atm]");
+ ND_PRINT((ndo, "[|atm]"));
return (caplen);
}
- if (eflag) {
- if (p[DIR_POS] & 0x80)
- printf("Tx: ");
- else
- printf("Rx: ");
+ if (ndo->ndo_eflag) {
+ ND_PRINT((ndo, p[DIR_POS] & 0x80 ? "Tx: " : "Rx: "));
}
switch (p[DIR_POS] & 0x0f) {
@@ -113,7 +107,10 @@ sunatm_if_print(const struct pcap_pkthdr *h, const u_char *p)
p += PKT_BEGIN_POS;
caplen -= PKT_BEGIN_POS;
length -= PKT_BEGIN_POS;
- atm_print(vpi, vci, traftype, p, length, caplen);
+ atm_print(ndo, vpi, vci, traftype, p, length, caplen);
return (PKT_BEGIN_POS);
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-sunatm-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-sunrpc.c b/freebsd/contrib/tcpdump/print-sunrpc.c
index 07eddff2..85b1461a 100644
--- a/freebsd/contrib/tcpdump/print-sunrpc.c
+++ b/freebsd/contrib/tcpdump/print-sunrpc.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1992, 1993, 1994, 1995, 1996
* The Regents of the University of California. All rights reserved.
@@ -174,3 +177,6 @@ progstr(prog)
#endif
return (buf);
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-sunrpc-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-symantec.c b/freebsd/contrib/tcpdump/print-symantec.c
index d42e6faa..19343a48 100644
--- a/freebsd/contrib/tcpdump/print-symantec.c
+++ b/freebsd/contrib/tcpdump/print-symantec.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2000
* The Regents of the University of California. All rights reserved.
@@ -20,57 +23,51 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-symantec.c,v 1.5 2005-07-07 01:22:21 guy Exp $ (LBL)";
-#endif
+
+/* \summary: Symantec Enterprise Firewall printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include <stdio.h>
-#include <pcap.h>
-
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
-#include "addrtoname.h"
#include "ethertype.h"
#include "ether.h"
struct symantec_header {
- u_int8_t stuff1[6];
- u_int16_t ether_type;
- u_int8_t stuff2[36];
+ uint8_t stuff1[6];
+ uint16_t ether_type;
+ uint8_t stuff2[36];
};
static inline void
-symantec_hdr_print(register const u_char *bp, u_int length)
+symantec_hdr_print(netdissect_options *ndo, register const u_char *bp, u_int length)
{
register const struct symantec_header *sp;
- u_int16_t etype;
+ uint16_t etype;
sp = (const struct symantec_header *)bp;
etype = EXTRACT_16BITS(&sp->ether_type);
- if (!qflag) {
+ if (!ndo->ndo_qflag) {
if (etype <= ETHERMTU)
- (void)printf("invalid ethertype %u", etype);
- else
- (void)printf("ethertype %s (0x%04x)",
+ ND_PRINT((ndo, "invalid ethertype %u", etype));
+ else
+ ND_PRINT((ndo, "ethertype %s (0x%04x)",
tok2str(ethertype_values,"Unknown", etype),
- etype);
+ etype));
} else {
if (etype <= ETHERMTU)
- (void)printf("invalid ethertype %u", etype);
- else
- (void)printf("%s", tok2str(ethertype_values,"Unknown Ethertype (0x%04x)", etype));
+ ND_PRINT((ndo, "invalid ethertype %u", etype));
+ else
+ ND_PRINT((ndo, "%s", tok2str(ethertype_values,"Unknown Ethertype (0x%04x)", etype)));
}
- (void)printf(", length %u: ", length);
+ ND_PRINT((ndo, ", length %u: ", length));
}
/*
@@ -80,43 +77,46 @@ symantec_hdr_print(register const u_char *bp, u_int length)
* is the number of bytes actually captured.
*/
u_int
-symantec_if_print(const struct pcap_pkthdr *h, const u_char *p)
+symantec_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
{
u_int length = h->len;
u_int caplen = h->caplen;
- struct symantec_header *sp;
+ const struct symantec_header *sp;
u_short ether_type;
if (caplen < sizeof (struct symantec_header)) {
- printf("[|symantec]");
+ ND_PRINT((ndo, "[|symantec]"));
return caplen;
}
- if (eflag)
- symantec_hdr_print(p, length);
+ if (ndo->ndo_eflag)
+ symantec_hdr_print(ndo, p, length);
length -= sizeof (struct symantec_header);
caplen -= sizeof (struct symantec_header);
- sp = (struct symantec_header *)p;
+ sp = (const struct symantec_header *)p;
p += sizeof (struct symantec_header);
ether_type = EXTRACT_16BITS(&sp->ether_type);
if (ether_type <= ETHERMTU) {
/* ether_type not known, print raw packet */
- if (!eflag)
- symantec_hdr_print((u_char *)sp, length + sizeof (struct symantec_header));
+ if (!ndo->ndo_eflag)
+ symantec_hdr_print(ndo, (const u_char *)sp, length + sizeof (struct symantec_header));
- if (!suppress_default_print)
- default_print(p, caplen);
- } else if (ethertype_print(gndo, ether_type, p, length, caplen) == 0) {
+ if (!ndo->ndo_suppress_default_print)
+ ND_DEFAULTPRINT(p, caplen);
+ } else if (ethertype_print(ndo, ether_type, p, length, caplen, NULL, NULL) == 0) {
/* ether_type not known, print raw packet */
- if (!eflag)
- symantec_hdr_print((u_char *)sp, length + sizeof (struct symantec_header));
+ if (!ndo->ndo_eflag)
+ symantec_hdr_print(ndo, (const u_char *)sp, length + sizeof (struct symantec_header));
- if (!suppress_default_print)
- default_print(p, caplen);
- }
+ if (!ndo->ndo_suppress_default_print)
+ ND_DEFAULTPRINT(p, caplen);
+ }
return (sizeof (struct symantec_header));
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-symantec-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-syslog.c b/freebsd/contrib/tcpdump/print-syslog.c
index 8585ee00..e2ee5502 100644
--- a/freebsd/contrib/tcpdump/print-syslog.c
+++ b/freebsd/contrib/tcpdump/print-syslog.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1998-2004 Hannes Gredler <hannes@tcpdump.org>
* The TCPDUMP project
@@ -16,25 +19,20 @@
* FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-syslog.c,v 1.1 2004-10-29 11:42:53 hannes Exp $";
-#endif
+/* \summary: Syslog protocol printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
-
-#include <stdio.h>
-#include <stdlib.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
-#include "addrtoname.h"
-/*
+static const char tstr[] = "[|syslog]";
+
+/*
* tokenlists and #defines taken from Ethereal - Network traffic analyzer
* by Gerald Combs <gerald@ethereal.com>
*/
@@ -84,11 +82,12 @@ static const struct tok syslog_facility_values[] = {
};
void
-syslog_print(register const u_char *pptr, register u_int len)
+syslog_print(netdissect_options *ndo,
+ register const u_char *pptr, register u_int len)
{
- u_int16_t msg_off = 0;
- u_int16_t pri = 0;
- u_int16_t facility,severity;
+ uint16_t msg_off = 0;
+ uint16_t pri = 0;
+ uint16_t facility,severity;
/* extract decimal figures that are
* encapsulated within < > tags
@@ -96,70 +95,60 @@ syslog_print(register const u_char *pptr, register u_int len)
* severity and facility values
*/
- if (!TTEST2(*pptr, 1))
- goto trunc;
-
+ ND_TCHECK2(*pptr, 1);
if (*(pptr+msg_off) == '<') {
msg_off++;
-
- if (!TTEST2(*(pptr+msg_off), 1))
- goto trunc;
-
+ ND_TCHECK2(*(pptr + msg_off), 1);
while ( *(pptr+msg_off) >= '0' &&
*(pptr+msg_off) <= '9' &&
msg_off <= SYSLOG_MAX_DIGITS) {
-
- if (!TTEST2(*(pptr+msg_off), 1))
- goto trunc;
-
pri = pri * 10 + (*(pptr+msg_off) - '0');
msg_off++;
-
- if (!TTEST2(*(pptr+msg_off), 1))
- goto trunc;
-
- if (*(pptr+msg_off) == '>')
- msg_off++;
+ ND_TCHECK2(*(pptr + msg_off), 1);
+ }
+ if (*(pptr+msg_off) != '>') {
+ ND_PRINT((ndo, "%s", tstr));
+ return;
}
+ msg_off++;
} else {
- printf("[|syslog]");
+ ND_PRINT((ndo, "%s", tstr));
return;
}
facility = (pri & SYSLOG_FACILITY_MASK) >> 3;
severity = pri & SYSLOG_SEVERITY_MASK;
-
- if (vflag < 1 )
+ if (ndo->ndo_vflag < 1 )
{
- printf("SYSLOG %s.%s, length: %u",
+ ND_PRINT((ndo, "SYSLOG %s.%s, length: %u",
tok2str(syslog_facility_values, "unknown (%u)", facility),
tok2str(syslog_severity_values, "unknown (%u)", severity),
- len);
+ len));
return;
}
-
- printf("SYSLOG, length: %u\n\tFacility %s (%u), Severity %s (%u)\n\tMsg: ",
+
+ ND_PRINT((ndo, "SYSLOG, length: %u\n\tFacility %s (%u), Severity %s (%u)\n\tMsg: ",
len,
tok2str(syslog_facility_values, "unknown (%u)", facility),
facility,
tok2str(syslog_severity_values, "unknown (%u)", severity),
- severity);
+ severity));
/* print the syslog text in verbose mode */
for (; msg_off < len; msg_off++) {
- if (!TTEST2(*(pptr+msg_off), 1))
- goto trunc;
- safeputchar(*(pptr+msg_off));
+ ND_TCHECK2(*(pptr + msg_off), 1);
+ safeputchar(ndo, *(pptr + msg_off));
}
- if (vflag > 1) {
- if(!print_unknown_data(pptr,"\n\t",len))
- return;
- }
-
+ if (ndo->ndo_vflag > 1)
+ print_unknown_data(ndo, pptr, "\n\t", len);
+
return;
trunc:
- printf("[|syslog]");
+ ND_PRINT((ndo, "%s", tstr));
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-syslog-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-tcp.c b/freebsd/contrib/tcpdump/print-tcp.c
index c377bac9..90417d3b 100644
--- a/freebsd/contrib/tcpdump/print-tcp.c
+++ b/freebsd/contrib/tcpdump/print-tcp.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/* $NetBSD: print-tcp.c,v 1.9 2007/07/26 18:15:12 plunky Exp $ */
/*
@@ -25,9 +28,9 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
+/* \summary: TCP printer */
+
#ifndef lint
-static const char rcsid[] _U_ =
-"@(#) $Header: /tcpdump/master/tcpdump/print-tcp.c,v 1.135 2008-11-09 23:35:03 mcr Exp $ (LBL)";
#else
__RCSID("$NetBSD: print-tcp.c,v 1.8 2007/07/24 11:53:48 drochner Exp $");
#endif
@@ -36,49 +39,42 @@ __RCSID("$NetBSD: print-tcp.c,v 1.8 2007/07/24 11:53:48 drochner Exp $");
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "extract.h"
#include "tcp.h"
#include "ip.h"
-#ifdef INET6
#include "ip6.h"
-#endif
#include "ipproto.h"
#include "rpc_auth.h"
#include "rpc_msg.h"
-#include "nameser.h"
-
#ifdef HAVE_LIBCRYPTO
#include <openssl/md5.h>
-#include <signature.h>
+#include "signature.h"
-static int tcp_verify_signature(const struct ip *ip, const struct tcphdr *tp,
+static int tcp_verify_signature(netdissect_options *ndo,
+ const struct ip *ip, const struct tcphdr *tp,
const u_char *data, int length, const u_char *rcvsig);
#endif
-static void print_tcp_rst_data(register const u_char *sp, u_int length);
+static void print_tcp_rst_data(netdissect_options *, register const u_char *sp, u_int length);
+static void print_tcp_fastopen_option(netdissect_options *ndo, register const u_char *cp,
+ u_int datalen, int exp);
#define MAX_RST_DATA_LEN 30
struct tha {
-#ifndef INET6
struct in_addr src;
struct in_addr dst;
-#else
- struct in6_addr src;
- struct in6_addr dst;
-#endif /*INET6*/
u_int port;
};
@@ -89,14 +85,28 @@ struct tcp_seq_hash {
tcp_seq ack;
};
+struct tha6 {
+ struct in6_addr src;
+ struct in6_addr dst;
+ u_int port;
+};
+
+struct tcp_seq_hash6 {
+ struct tcp_seq_hash6 *nxt;
+ struct tha6 addr;
+ tcp_seq seq;
+ tcp_seq ack;
+};
+
#define TSEQ_HASHSIZE 919
/* These tcp optinos do not have the size octet */
#define ZEROLENOPT(o) ((o) == TCPOPT_EOL || (o) == TCPOPT_NOP)
-static struct tcp_seq_hash tcp_seq_hash[TSEQ_HASHSIZE];
+static struct tcp_seq_hash tcp_seq_hash4[TSEQ_HASHSIZE];
+static struct tcp_seq_hash6 tcp_seq_hash6[TSEQ_HASHSIZE];
-struct tok tcp_flag_values[] = {
+static const struct tok tcp_flag_values[] = {
{ TH_FIN, "F" },
{ TH_SYN, "S" },
{ TH_RST, "R" },
@@ -108,7 +118,7 @@ struct tok tcp_flag_values[] = {
{ 0, NULL }
};
-struct tok tcp_option_values[] = {
+static const struct tok tcp_option_values[] = {
{ TCPOPT_EOL, "eol" },
{ TCPOPT_NOP, "nop" },
{ TCPOPT_MAXSEG, "mss" },
@@ -122,328 +132,293 @@ struct tok tcp_option_values[] = {
{ TCPOPT_CCNEW, "ccnew" },
{ TCPOPT_CCECHO, "" },
{ TCPOPT_SIGNATURE, "md5" },
- { TCPOPT_AUTH, "enhanced auth" },
+ { TCPOPT_SCPS, "scps" },
{ TCPOPT_UTO, "uto" },
+ { TCPOPT_TCPAO, "tcp-ao" },
+ { TCPOPT_MPTCP, "mptcp" },
+ { TCPOPT_FASTOPEN, "tfo" },
+ { TCPOPT_EXPERIMENT2, "exp" },
{ 0, NULL }
};
-static int tcp_cksum(register const struct ip *ip,
- register const struct tcphdr *tp,
- register u_int len)
+static int
+tcp_cksum(netdissect_options *ndo,
+ register const struct ip *ip,
+ register const struct tcphdr *tp,
+ register u_int len)
{
- return (nextproto4_cksum(ip, (const u_int8_t *)tp, len,
- IPPROTO_TCP));
+ return nextproto4_cksum(ndo, ip, (const uint8_t *)tp, len, len,
+ IPPROTO_TCP);
+}
+
+static int
+tcp6_cksum(netdissect_options *ndo,
+ register const struct ip6_hdr *ip6,
+ register const struct tcphdr *tp,
+ register u_int len)
+{
+ return nextproto6_cksum(ndo, ip6, (const uint8_t *)tp, len, len,
+ IPPROTO_TCP);
}
void
-tcp_print(register const u_char *bp, register u_int length,
- register const u_char *bp2, int fragmented)
+tcp_print(netdissect_options *ndo,
+ register const u_char *bp, register u_int length,
+ register const u_char *bp2, int fragmented)
{
register const struct tcphdr *tp;
register const struct ip *ip;
register u_char flags;
register u_int hlen;
register char ch;
- u_int16_t sport, dport, win, urp;
- u_int32_t seq, ack, thseq, thack;
+ uint16_t sport, dport, win, urp;
+ uint32_t seq, ack, thseq, thack;
u_int utoval;
- int threv;
-#ifdef INET6
+ uint16_t magic;
+ register int rev;
register const struct ip6_hdr *ip6;
-#endif
- tp = (struct tcphdr *)bp;
- ip = (struct ip *)bp2;
-#ifdef INET6
+ tp = (const struct tcphdr *)bp;
+ ip = (const struct ip *)bp2;
if (IP_V(ip) == 6)
- ip6 = (struct ip6_hdr *)bp2;
+ ip6 = (const struct ip6_hdr *)bp2;
else
ip6 = NULL;
-#endif /*INET6*/
ch = '\0';
- if (!TTEST(tp->th_dport)) {
- (void)printf("%s > %s: [|tcp]",
- ipaddr_string(&ip->ip_src),
- ipaddr_string(&ip->ip_dst));
+ if (!ND_TTEST(tp->th_dport)) {
+ ND_PRINT((ndo, "%s > %s: [|tcp]",
+ ipaddr_string(ndo, &ip->ip_src),
+ ipaddr_string(ndo, &ip->ip_dst)));
return;
}
sport = EXTRACT_16BITS(&tp->th_sport);
dport = EXTRACT_16BITS(&tp->th_dport);
- hlen = TH_OFF(tp) * 4;
-
- /*
- * If data present, header length valid, and NFS port used,
- * assume NFS.
- * Pass offset of data plus 4 bytes for RPC TCP msg length
- * to NFS print routines.
- */
- if (!qflag && hlen >= sizeof(*tp) && hlen <= length &&
- (length - hlen) >= 4) {
- u_char *fraglenp;
- u_int32_t fraglen;
- register struct sunrpc_msg *rp;
- enum sunrpc_msg_type direction;
-
- fraglenp = (u_char *)tp + hlen;
- if (TTEST2(*fraglenp, 4)) {
- fraglen = EXTRACT_32BITS(fraglenp) & 0x7FFFFFFF;
- if (fraglen > (length - hlen) - 4)
- fraglen = (length - hlen) - 4;
- rp = (struct sunrpc_msg *)(fraglenp + 4);
- if (TTEST(rp->rm_direction)) {
- direction = (enum sunrpc_msg_type)EXTRACT_32BITS(&rp->rm_direction);
- if (dport == NFS_PORT &&
- direction == SUNRPC_CALL) {
- nfsreq_print((u_char *)rp, fraglen,
- (u_char *)ip);
- return;
- }
- if (sport == NFS_PORT &&
- direction == SUNRPC_REPLY) {
- nfsreply_print((u_char *)rp, fraglen,
- (u_char *)ip);
- return;
- }
- }
- }
- }
-#ifdef INET6
if (ip6) {
if (ip6->ip6_nxt == IPPROTO_TCP) {
- (void)printf("%s.%s > %s.%s: ",
- ip6addr_string(&ip6->ip6_src),
- tcpport_string(sport),
- ip6addr_string(&ip6->ip6_dst),
- tcpport_string(dport));
+ ND_PRINT((ndo, "%s.%s > %s.%s: ",
+ ip6addr_string(ndo, &ip6->ip6_src),
+ tcpport_string(ndo, sport),
+ ip6addr_string(ndo, &ip6->ip6_dst),
+ tcpport_string(ndo, dport)));
} else {
- (void)printf("%s > %s: ",
- tcpport_string(sport), tcpport_string(dport));
+ ND_PRINT((ndo, "%s > %s: ",
+ tcpport_string(ndo, sport), tcpport_string(ndo, dport)));
}
- } else
-#endif /*INET6*/
- {
+ } else {
if (ip->ip_p == IPPROTO_TCP) {
- (void)printf("%s.%s > %s.%s: ",
- ipaddr_string(&ip->ip_src),
- tcpport_string(sport),
- ipaddr_string(&ip->ip_dst),
- tcpport_string(dport));
+ ND_PRINT((ndo, "%s.%s > %s.%s: ",
+ ipaddr_string(ndo, &ip->ip_src),
+ tcpport_string(ndo, sport),
+ ipaddr_string(ndo, &ip->ip_dst),
+ tcpport_string(ndo, dport)));
} else {
- (void)printf("%s > %s: ",
- tcpport_string(sport), tcpport_string(dport));
+ ND_PRINT((ndo, "%s > %s: ",
+ tcpport_string(ndo, sport), tcpport_string(ndo, dport)));
}
}
+ ND_TCHECK(*tp);
+
+ hlen = TH_OFF(tp) * 4;
+
if (hlen < sizeof(*tp)) {
- (void)printf(" tcp %d [bad hdr length %u - too short, < %lu]",
- length - hlen, hlen, (unsigned long)sizeof(*tp));
+ ND_PRINT((ndo, " tcp %d [bad hdr length %u - too short, < %lu]",
+ length - hlen, hlen, (unsigned long)sizeof(*tp)));
return;
}
- TCHECK(*tp);
-
seq = EXTRACT_32BITS(&tp->th_seq);
ack = EXTRACT_32BITS(&tp->th_ack);
win = EXTRACT_16BITS(&tp->th_win);
urp = EXTRACT_16BITS(&tp->th_urp);
- if (qflag) {
- (void)printf("tcp %d", length - hlen);
+ if (ndo->ndo_qflag) {
+ ND_PRINT((ndo, "tcp %d", length - hlen));
if (hlen > length) {
- (void)printf(" [bad hdr length %u - too long, > %u]",
- hlen, length);
+ ND_PRINT((ndo, " [bad hdr length %u - too long, > %u]",
+ hlen, length));
}
return;
}
flags = tp->th_flags;
- printf("Flags [%s]", bittok2str_nosep(tcp_flag_values, "none", flags));
+ ND_PRINT((ndo, "Flags [%s]", bittok2str_nosep(tcp_flag_values, "none", flags)));
- if (!Sflag && (flags & TH_ACK)) {
- register struct tcp_seq_hash *th;
- const void *src, *dst;
- register int rev;
- struct tha tha;
+ if (!ndo->ndo_Sflag && (flags & TH_ACK)) {
/*
* Find (or record) the initial sequence numbers for
* this conversation. (we pick an arbitrary
* collating order so there's only one entry for
* both directions).
*/
-#ifdef INET6
rev = 0;
if (ip6) {
+ register struct tcp_seq_hash6 *th;
+ struct tcp_seq_hash6 *tcp_seq_hash;
+ const struct in6_addr *src, *dst;
+ struct tha6 tha;
+
+ tcp_seq_hash = tcp_seq_hash6;
src = &ip6->ip6_src;
dst = &ip6->ip6_dst;
if (sport > dport)
rev = 1;
else if (sport == dport) {
- if (memcmp(src, dst, sizeof ip6->ip6_dst) > 0)
+ if (UNALIGNED_MEMCMP(src, dst, sizeof ip6->ip6_dst) > 0)
rev = 1;
}
if (rev) {
- memcpy(&tha.src, dst, sizeof ip6->ip6_dst);
- memcpy(&tha.dst, src, sizeof ip6->ip6_src);
+ UNALIGNED_MEMCPY(&tha.src, dst, sizeof ip6->ip6_dst);
+ UNALIGNED_MEMCPY(&tha.dst, src, sizeof ip6->ip6_src);
tha.port = dport << 16 | sport;
} else {
- memcpy(&tha.dst, dst, sizeof ip6->ip6_dst);
- memcpy(&tha.src, src, sizeof ip6->ip6_src);
+ UNALIGNED_MEMCPY(&tha.dst, dst, sizeof ip6->ip6_dst);
+ UNALIGNED_MEMCPY(&tha.src, src, sizeof ip6->ip6_src);
tha.port = sport << 16 | dport;
}
+
+ for (th = &tcp_seq_hash[tha.port % TSEQ_HASHSIZE];
+ th->nxt; th = th->nxt)
+ if (memcmp((char *)&tha, (char *)&th->addr,
+ sizeof(th->addr)) == 0)
+ break;
+
+ if (!th->nxt || (flags & TH_SYN)) {
+ /* didn't find it or new conversation */
+ if (th->nxt == NULL) {
+ th->nxt = (struct tcp_seq_hash6 *)
+ calloc(1, sizeof(*th));
+ if (th->nxt == NULL)
+ (*ndo->ndo_error)(ndo,
+ "tcp_print: calloc");
+ }
+ th->addr = tha;
+ if (rev)
+ th->ack = seq, th->seq = ack - 1;
+ else
+ th->seq = seq, th->ack = ack - 1;
+ } else {
+ if (rev)
+ seq -= th->ack, ack -= th->seq;
+ else
+ seq -= th->seq, ack -= th->ack;
+ }
+
+ thseq = th->seq;
+ thack = th->ack;
} else {
- /*
- * Zero out the tha structure; the src and dst
- * fields are big enough to hold an IPv6
- * address, but we only have IPv4 addresses
- * and thus must clear out the remaining 124
- * bits.
- *
- * XXX - should we just clear those bytes after
- * copying the IPv4 addresses, rather than
- * zeroing out the entire structure and then
- * overwriting some of the zeroes?
- *
- * XXX - this could fail if we see TCP packets
- * with an IPv6 address with the lower 124 bits
- * all zero and also see TCP packes with an
- * IPv4 address with the same 32 bits as the
- * upper 32 bits of the IPv6 address in question.
- * Can that happen? Is it likely enough to be
- * an issue?
- */
- memset(&tha, 0, sizeof(tha));
- src = &ip->ip_src;
- dst = &ip->ip_dst;
+ register struct tcp_seq_hash *th;
+ struct tcp_seq_hash *tcp_seq_hash;
+ struct tha tha;
+
+ tcp_seq_hash = tcp_seq_hash4;
if (sport > dport)
rev = 1;
else if (sport == dport) {
- if (memcmp(src, dst, sizeof ip->ip_dst) > 0)
+ if (UNALIGNED_MEMCMP(&ip->ip_src, &ip->ip_dst, sizeof ip->ip_dst) > 0)
rev = 1;
}
if (rev) {
- memcpy(&tha.src, dst, sizeof ip->ip_dst);
- memcpy(&tha.dst, src, sizeof ip->ip_src);
+ UNALIGNED_MEMCPY(&tha.src, &ip->ip_dst, sizeof ip->ip_dst);
+ UNALIGNED_MEMCPY(&tha.dst, &ip->ip_src, sizeof ip->ip_src);
tha.port = dport << 16 | sport;
} else {
- memcpy(&tha.dst, dst, sizeof ip->ip_dst);
- memcpy(&tha.src, src, sizeof ip->ip_src);
+ UNALIGNED_MEMCPY(&tha.dst, &ip->ip_dst, sizeof ip->ip_dst);
+ UNALIGNED_MEMCPY(&tha.src, &ip->ip_src, sizeof ip->ip_src);
tha.port = sport << 16 | dport;
}
- }
-#else
- rev = 0;
- src = &ip->ip_src;
- dst = &ip->ip_dst;
- if (sport > dport)
- rev = 1;
- else if (sport == dport) {
- if (memcmp(src, dst, sizeof ip->ip_dst) > 0)
- rev = 1;
- }
- if (rev) {
- memcpy(&tha.src, dst, sizeof ip->ip_dst);
- memcpy(&tha.dst, src, sizeof ip->ip_src);
- tha.port = dport << 16 | sport;
- } else {
- memcpy(&tha.dst, dst, sizeof ip->ip_dst);
- memcpy(&tha.src, src, sizeof ip->ip_src);
- tha.port = sport << 16 | dport;
- }
-#endif
- threv = rev;
- for (th = &tcp_seq_hash[tha.port % TSEQ_HASHSIZE];
- th->nxt; th = th->nxt)
- if (memcmp((char *)&tha, (char *)&th->addr,
- sizeof(th->addr)) == 0)
- break;
+ for (th = &tcp_seq_hash[tha.port % TSEQ_HASHSIZE];
+ th->nxt; th = th->nxt)
+ if (memcmp((char *)&tha, (char *)&th->addr,
+ sizeof(th->addr)) == 0)
+ break;
- if (!th->nxt || (flags & TH_SYN)) {
- /* didn't find it or new conversation */
- if (th->nxt == NULL) {
- th->nxt = (struct tcp_seq_hash *)
- calloc(1, sizeof(*th));
- if (th->nxt == NULL)
- error("tcp_print: calloc");
+ if (!th->nxt || (flags & TH_SYN)) {
+ /* didn't find it or new conversation */
+ if (th->nxt == NULL) {
+ th->nxt = (struct tcp_seq_hash *)
+ calloc(1, sizeof(*th));
+ if (th->nxt == NULL)
+ (*ndo->ndo_error)(ndo,
+ "tcp_print: calloc");
+ }
+ th->addr = tha;
+ if (rev)
+ th->ack = seq, th->seq = ack - 1;
+ else
+ th->seq = seq, th->ack = ack - 1;
+ } else {
+ if (rev)
+ seq -= th->ack, ack -= th->seq;
+ else
+ seq -= th->seq, ack -= th->ack;
}
- th->addr = tha;
- if (rev)
- th->ack = seq, th->seq = ack - 1;
- else
- th->seq = seq, th->ack = ack - 1;
- } else {
- if (rev)
- seq -= th->ack, ack -= th->seq;
- else
- seq -= th->seq, ack -= th->ack;
- }
- thseq = th->seq;
- thack = th->ack;
+ thseq = th->seq;
+ thack = th->ack;
+ }
} else {
/*fool gcc*/
- thseq = thack = threv = 0;
+ thseq = thack = rev = 0;
}
if (hlen > length) {
- (void)printf(" [bad hdr length %u - too long, > %u]",
- hlen, length);
+ ND_PRINT((ndo, " [bad hdr length %u - too long, > %u]",
+ hlen, length));
return;
}
- if (vflag && !Kflag && !fragmented) {
+ if (ndo->ndo_vflag && !ndo->ndo_Kflag && !fragmented) {
/* Check the checksum, if possible. */
- u_int16_t sum, tcp_sum;
+ uint16_t sum, tcp_sum;
if (IP_V(ip) == 4) {
- if (TTEST2(tp->th_sport, length)) {
- sum = tcp_cksum(ip, tp, length);
+ if (ND_TTEST2(tp->th_sport, length)) {
+ sum = tcp_cksum(ndo, ip, tp, length);
tcp_sum = EXTRACT_16BITS(&tp->th_sum);
- (void)printf(", cksum 0x%04x", tcp_sum);
+ ND_PRINT((ndo, ", cksum 0x%04x", tcp_sum));
if (sum != 0)
- (void)printf(" (incorrect -> 0x%04x)",
- in_cksum_shouldbe(tcp_sum, sum));
+ ND_PRINT((ndo, " (incorrect -> 0x%04x)",
+ in_cksum_shouldbe(tcp_sum, sum)));
else
- (void)printf(" (correct)");
+ ND_PRINT((ndo, " (correct)"));
}
- }
-#ifdef INET6
- else if (IP_V(ip) == 6 && ip6->ip6_plen) {
- if (TTEST2(tp->th_sport, length)) {
- sum = nextproto6_cksum(ip6, (const u_int8_t *)tp, length, IPPROTO_TCP);
+ } else if (IP_V(ip) == 6 && ip6->ip6_plen) {
+ if (ND_TTEST2(tp->th_sport, length)) {
+ sum = tcp6_cksum(ndo, ip6, tp, length);
tcp_sum = EXTRACT_16BITS(&tp->th_sum);
- (void)printf(", cksum 0x%04x", tcp_sum);
+ ND_PRINT((ndo, ", cksum 0x%04x", tcp_sum));
if (sum != 0)
- (void)printf(" (incorrect -> 0x%04x)",
- in_cksum_shouldbe(tcp_sum, sum));
+ ND_PRINT((ndo, " (incorrect -> 0x%04x)",
+ in_cksum_shouldbe(tcp_sum, sum)));
else
- (void)printf(" (correct)");
+ ND_PRINT((ndo, " (correct)"));
}
}
-#endif
}
length -= hlen;
- if (vflag > 1 || length > 0 || flags & (TH_SYN | TH_FIN | TH_RST)) {
- (void)printf(", seq %u", seq);
+ if (ndo->ndo_vflag > 1 || length > 0 || flags & (TH_SYN | TH_FIN | TH_RST)) {
+ ND_PRINT((ndo, ", seq %u", seq));
if (length > 0) {
- (void)printf(":%u", seq + length);
+ ND_PRINT((ndo, ":%u", seq + length));
}
}
if (flags & TH_ACK) {
- (void)printf(", ack %u", ack);
+ ND_PRINT((ndo, ", ack %u", ack));
}
- (void)printf(", win %d", win);
+ ND_PRINT((ndo, ", win %d", win));
if (flags & TH_URG)
- (void)printf(", urg %d", urp);
+ ND_PRINT((ndo, ", urg %d", urp));
/*
* Handle any options.
*/
@@ -454,16 +429,16 @@ tcp_print(register const u_char *bp, register u_int length,
hlen -= sizeof(*tp);
cp = (const u_char *)tp + sizeof(*tp);
- printf(", options [");
+ ND_PRINT((ndo, ", options ["));
while (hlen > 0) {
if (ch != '\0')
- putchar(ch);
- TCHECK(*cp);
+ ND_PRINT((ndo, "%c", ch));
+ ND_TCHECK(*cp);
opt = *cp++;
if (ZEROLENOPT(opt))
len = 1;
else {
- TCHECK(*cp);
+ ND_TCHECK(*cp);
len = *cp++; /* total including type, len */
if (len < 2 || len > hlen)
goto bad;
@@ -473,46 +448,46 @@ tcp_print(register const u_char *bp, register u_int length,
datalen = 0;
/* Bail if "l" bytes of data are not left or were not captured */
-#define LENCHECK(l) { if ((l) > hlen) goto bad; TCHECK2(*cp, l); }
+#define LENCHECK(l) { if ((l) > hlen) goto bad; ND_TCHECK2(*cp, l); }
- printf("%s", tok2str(tcp_option_values, "Unknown Option %u", opt));
+ ND_PRINT((ndo, "%s", tok2str(tcp_option_values, "unknown-%u", opt)));
switch (opt) {
case TCPOPT_MAXSEG:
datalen = 2;
LENCHECK(datalen);
- (void)printf(" %u", EXTRACT_16BITS(cp));
+ ND_PRINT((ndo, " %u", EXTRACT_16BITS(cp)));
break;
case TCPOPT_WSCALE:
datalen = 1;
LENCHECK(datalen);
- (void)printf(" %u", *cp);
+ ND_PRINT((ndo, " %u", *cp));
break;
case TCPOPT_SACK:
datalen = len - 2;
if (datalen % 8 != 0) {
- (void)printf("malformed sack");
+ ND_PRINT((ndo, " invalid sack"));
} else {
- u_int32_t s, e;
+ uint32_t s, e;
- (void)printf(" %d ", datalen / 8);
+ ND_PRINT((ndo, " %d ", datalen / 8));
for (i = 0; i < datalen; i += 8) {
LENCHECK(i + 4);
s = EXTRACT_32BITS(cp + i);
LENCHECK(i + 8);
e = EXTRACT_32BITS(cp + i + 4);
- if (threv) {
+ if (rev) {
s -= thseq;
e -= thseq;
} else {
s -= thack;
e -= thack;
}
- (void)printf("{%u:%u}", s, e);
+ ND_PRINT((ndo, "{%u:%u}", s, e));
}
}
break;
@@ -529,53 +504,74 @@ tcp_print(register const u_char *bp, register u_int length,
*/
datalen = 4;
LENCHECK(datalen);
- (void)printf(" %u", EXTRACT_32BITS(cp));
+ ND_PRINT((ndo, " %u", EXTRACT_32BITS(cp)));
break;
case TCPOPT_TIMESTAMP:
datalen = 8;
LENCHECK(datalen);
- (void)printf(" val %u ecr %u",
+ ND_PRINT((ndo, " val %u ecr %u",
EXTRACT_32BITS(cp),
- EXTRACT_32BITS(cp + 4));
+ EXTRACT_32BITS(cp + 4)));
break;
case TCPOPT_SIGNATURE:
datalen = TCP_SIGLEN;
LENCHECK(datalen);
+ ND_PRINT((ndo, " "));
#ifdef HAVE_LIBCRYPTO
- switch (tcp_verify_signature(ip, tp,
+ switch (tcp_verify_signature(ndo, ip, tp,
bp + TH_OFF(tp) * 4, length, cp)) {
case SIGNATURE_VALID:
- (void)printf("valid");
+ ND_PRINT((ndo, "valid"));
break;
case SIGNATURE_INVALID:
- (void)printf("invalid");
+ ND_PRINT((ndo, "invalid"));
break;
case CANT_CHECK_SIGNATURE:
- (void)printf("can't check - ");
+ ND_PRINT((ndo, "can't check - "));
for (i = 0; i < TCP_SIGLEN; ++i)
- (void)printf("%02x", cp[i]);
+ ND_PRINT((ndo, "%02x", cp[i]));
break;
}
#else
for (i = 0; i < TCP_SIGLEN; ++i)
- (void)printf("%02x", cp[i]);
+ ND_PRINT((ndo, "%02x", cp[i]));
#endif
break;
- case TCPOPT_AUTH:
- (void)printf("keyid %d", *cp++);
- datalen = len - 3;
- for (i = 0; i < datalen; ++i) {
- LENCHECK(i);
- (void)printf("%02x", cp[i]);
- }
+ case TCPOPT_SCPS:
+ datalen = 2;
+ LENCHECK(datalen);
+ ND_PRINT((ndo, " cap %02x id %u", cp[0], cp[1]));
break;
+ case TCPOPT_TCPAO:
+ datalen = len - 2;
+ /* RFC 5925 Section 2.2:
+ * "The Length value MUST be greater than or equal to 4."
+ * (This includes the Kind and Length fields already processed
+ * at this point.)
+ */
+ if (datalen < 2) {
+ ND_PRINT((ndo, " invalid"));
+ } else {
+ LENCHECK(1);
+ ND_PRINT((ndo, " keyid %u", cp[0]));
+ LENCHECK(2);
+ ND_PRINT((ndo, " rnextkeyid %u", cp[1]));
+ if (datalen > 2) {
+ ND_PRINT((ndo, " mac 0x"));
+ for (i = 2; i < datalen; i++) {
+ LENCHECK(i + 1);
+ ND_PRINT((ndo, "%02x", cp[i]));
+ }
+ }
+ }
+ break;
case TCPOPT_EOL:
case TCPOPT_NOP:
@@ -590,19 +586,57 @@ tcp_print(register const u_char *bp, register u_int length,
datalen = 2;
LENCHECK(datalen);
utoval = EXTRACT_16BITS(cp);
- (void)printf("0x%x", utoval);
+ ND_PRINT((ndo, " 0x%x", utoval));
if (utoval & 0x0001)
utoval = (utoval >> 1) * 60;
else
utoval >>= 1;
- (void)printf(" %u", utoval);
+ ND_PRINT((ndo, " %u", utoval));
+ break;
+
+ case TCPOPT_MPTCP:
+ datalen = len - 2;
+ LENCHECK(datalen);
+ if (!mptcp_print(ndo, cp-2, len, flags))
+ goto bad;
+ break;
+
+ case TCPOPT_FASTOPEN:
+ datalen = len - 2;
+ LENCHECK(datalen);
+ ND_PRINT((ndo, " "));
+ print_tcp_fastopen_option(ndo, cp, datalen, FALSE);
+ break;
+
+ case TCPOPT_EXPERIMENT2:
+ datalen = len - 2;
+ LENCHECK(datalen);
+ if (datalen < 2)
+ goto bad;
+ /* RFC6994 */
+ magic = EXTRACT_16BITS(cp);
+ ND_PRINT((ndo, "-"));
+
+ switch(magic) {
+
+ case 0xf989: /* TCP Fast Open RFC 7413 */
+ print_tcp_fastopen_option(ndo, cp + 2, datalen - 2, TRUE);
+ break;
+
+ default:
+ /* Unknown magic number */
+ ND_PRINT((ndo, "%04x", magic));
+ break;
+ }
break;
default:
datalen = len - 2;
+ if (datalen)
+ ND_PRINT((ndo, " 0x"));
for (i = 0; i < datalen; ++i) {
- LENCHECK(i);
- (void)printf("%02x", cp[i]);
+ LENCHECK(i + 1);
+ ND_PRINT((ndo, "%02x", cp[i]));
}
break;
}
@@ -616,18 +650,18 @@ tcp_print(register const u_char *bp, register u_int length,
if (!ZEROLENOPT(opt))
++datalen; /* size octet */
if (datalen != len)
- (void)printf("[len %d]", len);
+ ND_PRINT((ndo, "[len %d]", len));
ch = ',';
if (opt == TCPOPT_EOL)
break;
}
- putchar(']');
+ ND_PRINT((ndo, "]"));
}
/*
* Print length field before crawling down the stack.
*/
- printf(", length %u", length);
+ ND_PRINT((ndo, ", length %u", length));
if (length <= 0)
return;
@@ -636,62 +670,109 @@ tcp_print(register const u_char *bp, register u_int length,
* Decode payload if necessary.
*/
bp += TH_OFF(tp) * 4;
- if ((flags & TH_RST) && vflag) {
- print_tcp_rst_data(bp, length);
+ if ((flags & TH_RST) && ndo->ndo_vflag) {
+ print_tcp_rst_data(ndo, bp, length);
return;
- }
+ }
- if (packettype) {
- switch (packettype) {
+ if (ndo->ndo_packettype) {
+ switch (ndo->ndo_packettype) {
case PT_ZMTP1:
- zmtp1_print(bp, length);
+ zmtp1_print(ndo, bp, length);
+ break;
+ case PT_RESP:
+ resp_print(ndo, bp, length);
break;
}
return;
}
- if (sport == TELNET_PORT || dport == TELNET_PORT) {
- if (!qflag && vflag)
- telnet_print(bp, length);
- } else if (sport == BGP_PORT || dport == BGP_PORT)
- bgp_print(bp, length);
- else if (sport == PPTP_PORT || dport == PPTP_PORT)
- pptp_print(bp);
-#ifdef TCPDUMP_DO_SMB
- else if (sport == NETBIOS_SSN_PORT || dport == NETBIOS_SSN_PORT)
- nbt_tcp_print(bp, length);
- else if (sport == SMB_PORT || dport == SMB_PORT)
- smb_tcp_print(bp, length);
+ if (IS_SRC_OR_DST_PORT(TELNET_PORT)) {
+ telnet_print(ndo, bp, length);
+ } else if (IS_SRC_OR_DST_PORT(SMTP_PORT)) {
+ ND_PRINT((ndo, ": "));
+ smtp_print(ndo, bp, length);
+ } else if (IS_SRC_OR_DST_PORT(BGP_PORT))
+ bgp_print(ndo, bp, length);
+ else if (IS_SRC_OR_DST_PORT(PPTP_PORT))
+ pptp_print(ndo, bp);
+ else if (IS_SRC_OR_DST_PORT(REDIS_PORT))
+ resp_print(ndo, bp, length);
+#ifdef ENABLE_SMB
+ else if (IS_SRC_OR_DST_PORT(NETBIOS_SSN_PORT))
+ nbt_tcp_print(ndo, bp, length);
+ else if (IS_SRC_OR_DST_PORT(SMB_PORT))
+ smb_tcp_print(ndo, bp, length);
#endif
- else if (sport == BEEP_PORT || dport == BEEP_PORT)
- beep_print(bp, length);
- else if (length > 2 &&
- (sport == NAMESERVER_PORT || dport == NAMESERVER_PORT ||
- sport == MULTICASTDNS_PORT || dport == MULTICASTDNS_PORT)) {
+ else if (IS_SRC_OR_DST_PORT(BEEP_PORT))
+ beep_print(ndo, bp, length);
+ else if (IS_SRC_OR_DST_PORT(OPENFLOW_PORT_OLD) || IS_SRC_OR_DST_PORT(OPENFLOW_PORT_IANA))
+ openflow_print(ndo, bp, length);
+ else if (IS_SRC_OR_DST_PORT(FTP_PORT)) {
+ ND_PRINT((ndo, ": "));
+ ftp_print(ndo, bp, length);
+ } else if (IS_SRC_OR_DST_PORT(HTTP_PORT) || IS_SRC_OR_DST_PORT(HTTP_PORT_ALT)) {
+ ND_PRINT((ndo, ": "));
+ http_print(ndo, bp, length);
+ } else if (IS_SRC_OR_DST_PORT(RTSP_PORT) || IS_SRC_OR_DST_PORT(RTSP_PORT_ALT)) {
+ ND_PRINT((ndo, ": "));
+ rtsp_print(ndo, bp, length);
+ } else if (length > 2 &&
+ (IS_SRC_OR_DST_PORT(NAMESERVER_PORT))) {
/*
* TCP DNS query has 2byte length at the head.
* XXX packet could be unaligned, it can go strange
*/
- ns_print(bp + 2, length - 2, 0);
- } else if (sport == MSDP_PORT || dport == MSDP_PORT) {
- msdp_print(bp, length);
- } else if (sport == RPKI_RTR_PORT || dport == RPKI_RTR_PORT) {
- rpki_rtr_print(bp, length);
+ ns_print(ndo, bp + 2, length - 2, 0);
+ } else if (IS_SRC_OR_DST_PORT(MSDP_PORT)) {
+ msdp_print(ndo, bp, length);
+ } else if (IS_SRC_OR_DST_PORT(RPKI_RTR_PORT)) {
+ rpki_rtr_print(ndo, bp, length);
}
- else if (length > 0 && (sport == LDP_PORT || dport == LDP_PORT)) {
- ldp_print(bp, length);
+ else if (length > 0 && (IS_SRC_OR_DST_PORT(LDP_PORT))) {
+ ldp_print(ndo, bp, length);
+ }
+ else if ((IS_SRC_OR_DST_PORT(NFS_PORT)) &&
+ length >= 4 && ND_TTEST2(*bp, 4)) {
+ /*
+ * If data present, header length valid, and NFS port used,
+ * assume NFS.
+ * Pass offset of data plus 4 bytes for RPC TCP msg length
+ * to NFS print routines.
+ */
+ uint32_t fraglen;
+ register const struct sunrpc_msg *rp;
+ enum sunrpc_msg_type direction;
+
+ fraglen = EXTRACT_32BITS(bp) & 0x7FFFFFFF;
+ if (fraglen > (length) - 4)
+ fraglen = (length) - 4;
+ rp = (const struct sunrpc_msg *)(bp + 4);
+ if (ND_TTEST(rp->rm_direction)) {
+ direction = (enum sunrpc_msg_type)EXTRACT_32BITS(&rp->rm_direction);
+ if (dport == NFS_PORT && direction == SUNRPC_CALL) {
+ ND_PRINT((ndo, ": NFS request xid %u ", EXTRACT_32BITS(&rp->rm_xid)));
+ nfsreq_print_noaddr(ndo, (const u_char *)rp, fraglen, (const u_char *)ip);
+ return;
+ }
+ if (sport == NFS_PORT && direction == SUNRPC_REPLY) {
+ ND_PRINT((ndo, ": NFS reply xid %u ", EXTRACT_32BITS(&rp->rm_xid)));
+ nfsreply_print_noaddr(ndo, (const u_char *)rp, fraglen, (const u_char *)ip);
+ return;
+ }
+ }
}
return;
bad:
- fputs("[bad opt]", stdout);
+ ND_PRINT((ndo, "[bad opt]"));
if (ch != '\0')
- putchar('>');
+ ND_PRINT((ndo, ">"));
return;
trunc:
- fputs("[|tcp]", stdout);
+ ND_PRINT((ndo, "[|tcp]"));
if (ch != '\0')
- putchar('>');
+ ND_PRINT((ndo, ">"));
}
/*
@@ -710,51 +791,73 @@ tcp_print(register const u_char *bp, register u_int length,
*/
static void
-print_tcp_rst_data(register const u_char *sp, u_int length)
+print_tcp_rst_data(netdissect_options *ndo,
+ register const u_char *sp, u_int length)
{
int c;
- if (TTEST2(*sp, length))
- printf(" [RST");
- else
- printf(" [!RST");
+ ND_PRINT((ndo, ND_TTEST2(*sp, length) ? " [RST" : " [!RST"));
if (length > MAX_RST_DATA_LEN) {
length = MAX_RST_DATA_LEN; /* can use -X for longer */
- putchar('+'); /* indicate we truncate */
+ ND_PRINT((ndo, "+")); /* indicate we truncate */
}
- putchar(' ');
- while (length-- && sp <= snapend) {
+ ND_PRINT((ndo, " "));
+ while (length-- && sp < ndo->ndo_snapend) {
c = *sp++;
- safeputchar(c);
+ safeputchar(ndo, c);
+ }
+ ND_PRINT((ndo, "]"));
+}
+
+static void
+print_tcp_fastopen_option(netdissect_options *ndo, register const u_char *cp,
+ u_int datalen, int exp)
+{
+ u_int i;
+
+ if (exp)
+ ND_PRINT((ndo, "tfo"));
+
+ if (datalen == 0) {
+ /* Fast Open Cookie Request */
+ ND_PRINT((ndo, " cookiereq"));
+ } else {
+ /* Fast Open Cookie */
+ if (datalen % 2 != 0 || datalen < 4 || datalen > 16) {
+ ND_PRINT((ndo, " invalid"));
+ } else {
+ ND_PRINT((ndo, " cookie "));
+ for (i = 0; i < datalen; ++i)
+ ND_PRINT((ndo, "%02x", cp[i]));
+ }
}
- putchar(']');
}
#ifdef HAVE_LIBCRYPTO
+USES_APPLE_DEPRECATED_API
static int
-tcp_verify_signature(const struct ip *ip, const struct tcphdr *tp,
+tcp_verify_signature(netdissect_options *ndo,
+ const struct ip *ip, const struct tcphdr *tp,
const u_char *data, int length, const u_char *rcvsig)
{
struct tcphdr tp1;
u_char sig[TCP_SIGLEN];
char zero_proto = 0;
MD5_CTX ctx;
- u_int16_t savecsum, tlen;
-#ifdef INET6
- struct ip6_hdr *ip6;
- u_int32_t len32;
- u_int8_t nxt;
-#endif
+ uint16_t savecsum, tlen;
+ const struct ip6_hdr *ip6;
+ uint32_t len32;
+ uint8_t nxt;
- if (data + length > snapend) {
- printf("snaplen too short, ");
+ if (data + length > ndo->ndo_snapend) {
+ ND_PRINT((ndo, "snaplen too short, "));
return (CANT_CHECK_SIGNATURE);
}
tp1 = *tp;
- if (sigsecret == NULL) {
- printf("shared secret not supplied with -M, ");
+ if (ndo->ndo_sigsecret == NULL) {
+ ND_PRINT((ndo, "shared secret not supplied with -M, "));
return (CANT_CHECK_SIGNATURE);
}
@@ -763,33 +866,27 @@ tcp_verify_signature(const struct ip *ip, const struct tcphdr *tp,
* Step 1: Update MD5 hash with IP pseudo-header.
*/
if (IP_V(ip) == 4) {
- MD5_Update(&ctx, (char *)&ip->ip_src, sizeof(ip->ip_src));
- MD5_Update(&ctx, (char *)&ip->ip_dst, sizeof(ip->ip_dst));
- MD5_Update(&ctx, (char *)&zero_proto, sizeof(zero_proto));
- MD5_Update(&ctx, (char *)&ip->ip_p, sizeof(ip->ip_p));
+ MD5_Update(&ctx, (const char *)&ip->ip_src, sizeof(ip->ip_src));
+ MD5_Update(&ctx, (const char *)&ip->ip_dst, sizeof(ip->ip_dst));
+ MD5_Update(&ctx, (const char *)&zero_proto, sizeof(zero_proto));
+ MD5_Update(&ctx, (const char *)&ip->ip_p, sizeof(ip->ip_p));
tlen = EXTRACT_16BITS(&ip->ip_len) - IP_HL(ip) * 4;
tlen = htons(tlen);
- MD5_Update(&ctx, (char *)&tlen, sizeof(tlen));
-#ifdef INET6
+ MD5_Update(&ctx, (const char *)&tlen, sizeof(tlen));
} else if (IP_V(ip) == 6) {
- ip6 = (struct ip6_hdr *)ip;
- MD5_Update(&ctx, (char *)&ip6->ip6_src, sizeof(ip6->ip6_src));
- MD5_Update(&ctx, (char *)&ip6->ip6_dst, sizeof(ip6->ip6_dst));
+ ip6 = (const struct ip6_hdr *)ip;
+ MD5_Update(&ctx, (const char *)&ip6->ip6_src, sizeof(ip6->ip6_src));
+ MD5_Update(&ctx, (const char *)&ip6->ip6_dst, sizeof(ip6->ip6_dst));
len32 = htonl(EXTRACT_16BITS(&ip6->ip6_plen));
- MD5_Update(&ctx, (char *)&len32, sizeof(len32));
+ MD5_Update(&ctx, (const char *)&len32, sizeof(len32));
nxt = 0;
- MD5_Update(&ctx, (char *)&nxt, sizeof(nxt));
- MD5_Update(&ctx, (char *)&nxt, sizeof(nxt));
- MD5_Update(&ctx, (char *)&nxt, sizeof(nxt));
+ MD5_Update(&ctx, (const char *)&nxt, sizeof(nxt));
+ MD5_Update(&ctx, (const char *)&nxt, sizeof(nxt));
+ MD5_Update(&ctx, (const char *)&nxt, sizeof(nxt));
nxt = IPPROTO_TCP;
- MD5_Update(&ctx, (char *)&nxt, sizeof(nxt));
-#endif
+ MD5_Update(&ctx, (const char *)&nxt, sizeof(nxt));
} else {
-#ifdef INET6
- printf("IP version not 4 or 6, ");
-#else
- printf("IP version not 4, ");
-#endif
+ ND_PRINT((ndo, "IP version not 4 or 6, "));
return (CANT_CHECK_SIGNATURE);
}
@@ -799,7 +896,7 @@ tcp_verify_signature(const struct ip *ip, const struct tcphdr *tp,
*/
savecsum = tp1.th_sum;
tp1.th_sum = 0;
- MD5_Update(&ctx, (char *)&tp1, sizeof(struct tcphdr));
+ MD5_Update(&ctx, (const char *)&tp1, sizeof(struct tcphdr));
tp1.th_sum = savecsum;
/*
* Step 3: Update MD5 hash with TCP segment data, if present.
@@ -809,7 +906,7 @@ tcp_verify_signature(const struct ip *ip, const struct tcphdr *tp,
/*
* Step 4: Update MD5 hash with shared secret.
*/
- MD5_Update(&ctx, sigsecret, strlen(sigsecret));
+ MD5_Update(&ctx, ndo->ndo_sigsecret, strlen(ndo->ndo_sigsecret));
MD5_Final(sig, &ctx);
if (memcmp(rcvsig, sig, TCP_SIGLEN) == 0)
@@ -817,6 +914,7 @@ tcp_verify_signature(const struct ip *ip, const struct tcphdr *tp,
else
return (SIGNATURE_INVALID);
}
+USES_APPLE_RST
#endif /* HAVE_LIBCRYPTO */
/*
@@ -825,3 +923,6 @@ tcp_verify_signature(const struct ip *ip, const struct tcphdr *tp,
* c-basic-offset: 8
* End:
*/
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-tcp-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-telnet.c b/freebsd/contrib/tcpdump/print-telnet.c
index a2091789..e883d9e2 100644
--- a/freebsd/contrib/tcpdump/print-telnet.c
+++ b/freebsd/contrib/tcpdump/print-telnet.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/* $NetBSD: print-telnet.c,v 1.2 1999/10/11 12:40:12 sjg Exp $ */
/*-
@@ -47,27 +50,307 @@
* are preserved in all copies.
*/
+/* \summary: Telnet option printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-telnet.c,v 1.24 2003-12-29 11:05:10 hannes Exp $";
-#endif
-
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "interface.h"
-#include "addrtoname.h"
+#include "netdissect.h"
+
+static const char tstr[] = " [|telnet]";
#define TELCMDS
#define TELOPTS
-#include "telnet.h"
+
+/* NetBSD: telnet.h,v 1.9 2001/06/11 01:50:50 wiz Exp */
+
+/*
+ * Definitions for the TELNET protocol.
+ */
+#define IAC 255 /* interpret as command: */
+#define DONT 254 /* you are not to use option */
+#define DO 253 /* please, you use option */
+#define WONT 252 /* I won't use option */
+#define WILL 251 /* I will use option */
+#define SB 250 /* interpret as subnegotiation */
+#define GA 249 /* you may reverse the line */
+#define EL 248 /* erase the current line */
+#define EC 247 /* erase the current character */
+#define AYT 246 /* are you there */
+#define AO 245 /* abort output--but let prog finish */
+#define IP 244 /* interrupt process--permanently */
+#define BREAK 243 /* break */
+#define DM 242 /* data mark--for connect. cleaning */
+#define NOP 241 /* nop */
+#define SE 240 /* end sub negotiation */
+#define EOR 239 /* end of record (transparent mode) */
+#define ABORT 238 /* Abort process */
+#define SUSP 237 /* Suspend process */
+#define xEOF 236 /* End of file: EOF is already used... */
+
+#define SYNCH 242 /* for telfunc calls */
+
+#ifdef TELCMDS
+static const char *telcmds[] = {
+ "EOF", "SUSP", "ABORT", "EOR",
+ "SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", "EC",
+ "EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC", 0,
+};
+#else
+extern char *telcmds[];
+#endif
+
+#define TELCMD_FIRST xEOF
+#define TELCMD_LAST IAC
+#define TELCMD_OK(x) ((unsigned int)(x) <= TELCMD_LAST && \
+ (unsigned int)(x) >= TELCMD_FIRST)
+#define TELCMD(x) telcmds[(x)-TELCMD_FIRST]
+
+/* telnet options */
+#define TELOPT_BINARY 0 /* 8-bit data path */
+#define TELOPT_ECHO 1 /* echo */
+#define TELOPT_RCP 2 /* prepare to reconnect */
+#define TELOPT_SGA 3 /* suppress go ahead */
+#define TELOPT_NAMS 4 /* approximate message size */
+#define TELOPT_STATUS 5 /* give status */
+#define TELOPT_TM 6 /* timing mark */
+#define TELOPT_RCTE 7 /* remote controlled transmission and echo */
+#define TELOPT_NAOL 8 /* negotiate about output line width */
+#define TELOPT_NAOP 9 /* negotiate about output page size */
+#define TELOPT_NAOCRD 10 /* negotiate about CR disposition */
+#define TELOPT_NAOHTS 11 /* negotiate about horizontal tabstops */
+#define TELOPT_NAOHTD 12 /* negotiate about horizontal tab disposition */
+#define TELOPT_NAOFFD 13 /* negotiate about formfeed disposition */
+#define TELOPT_NAOVTS 14 /* negotiate about vertical tab stops */
+#define TELOPT_NAOVTD 15 /* negotiate about vertical tab disposition */
+#define TELOPT_NAOLFD 16 /* negotiate about output LF disposition */
+#define TELOPT_XASCII 17 /* extended ascic character set */
+#define TELOPT_LOGOUT 18 /* force logout */
+#define TELOPT_BM 19 /* byte macro */
+#define TELOPT_DET 20 /* data entry terminal */
+#define TELOPT_SUPDUP 21 /* supdup protocol */
+#define TELOPT_SUPDUPOUTPUT 22 /* supdup output */
+#define TELOPT_SNDLOC 23 /* send location */
+#define TELOPT_TTYPE 24 /* terminal type */
+#define TELOPT_EOR 25 /* end or record */
+#define TELOPT_TUID 26 /* TACACS user identification */
+#define TELOPT_OUTMRK 27 /* output marking */
+#define TELOPT_TTYLOC 28 /* terminal location number */
+#define TELOPT_3270REGIME 29 /* 3270 regime */
+#define TELOPT_X3PAD 30 /* X.3 PAD */
+#define TELOPT_NAWS 31 /* window size */
+#define TELOPT_TSPEED 32 /* terminal speed */
+#define TELOPT_LFLOW 33 /* remote flow control */
+#define TELOPT_LINEMODE 34 /* Linemode option */
+#define TELOPT_XDISPLOC 35 /* X Display Location */
+#define TELOPT_OLD_ENVIRON 36 /* Old - Environment variables */
+#define TELOPT_AUTHENTICATION 37/* Authenticate */
+#define TELOPT_ENCRYPT 38 /* Encryption option */
+#define TELOPT_NEW_ENVIRON 39 /* New - Environment variables */
+#define TELOPT_EXOPL 255 /* extended-options-list */
+
+
+#define NTELOPTS (1+TELOPT_NEW_ENVIRON)
+#ifdef TELOPTS
+static const char *telopts[NTELOPTS+1] = {
+ "BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD", "NAME",
+ "STATUS", "TIMING MARK", "RCTE", "NAOL", "NAOP",
+ "NAOCRD", "NAOHTS", "NAOHTD", "NAOFFD", "NAOVTS",
+ "NAOVTD", "NAOLFD", "EXTEND ASCII", "LOGOUT", "BYTE MACRO",
+ "DATA ENTRY TERMINAL", "SUPDUP", "SUPDUP OUTPUT",
+ "SEND LOCATION", "TERMINAL TYPE", "END OF RECORD",
+ "TACACS UID", "OUTPUT MARKING", "TTYLOC",
+ "3270 REGIME", "X.3 PAD", "NAWS", "TSPEED", "LFLOW",
+ "LINEMODE", "XDISPLOC", "OLD-ENVIRON", "AUTHENTICATION",
+ "ENCRYPT", "NEW-ENVIRON",
+ 0,
+};
+#define TELOPT_FIRST TELOPT_BINARY
+#define TELOPT_LAST TELOPT_NEW_ENVIRON
+#define TELOPT_OK(x) ((unsigned int)(x) <= TELOPT_LAST)
+#define TELOPT(x) telopts[(x)-TELOPT_FIRST]
+#endif
+
+/* sub-option qualifiers */
+#define TELQUAL_IS 0 /* option is... */
+#define TELQUAL_SEND 1 /* send option */
+#define TELQUAL_INFO 2 /* ENVIRON: informational version of IS */
+#define TELQUAL_REPLY 2 /* AUTHENTICATION: client version of IS */
+#define TELQUAL_NAME 3 /* AUTHENTICATION: client version of IS */
+
+#define LFLOW_OFF 0 /* Disable remote flow control */
+#define LFLOW_ON 1 /* Enable remote flow control */
+#define LFLOW_RESTART_ANY 2 /* Restart output on any char */
+#define LFLOW_RESTART_XON 3 /* Restart output only on XON */
+
+/*
+ * LINEMODE suboptions
+ */
+
+#define LM_MODE 1
+#define LM_FORWARDMASK 2
+#define LM_SLC 3
+
+#define MODE_EDIT 0x01
+#define MODE_TRAPSIG 0x02
+#define MODE_ACK 0x04
+#define MODE_SOFT_TAB 0x08
+#define MODE_LIT_ECHO 0x10
+
+#define MODE_MASK 0x1f
+
+#define SLC_SYNCH 1
+#define SLC_BRK 2
+#define SLC_IP 3
+#define SLC_AO 4
+#define SLC_AYT 5
+#define SLC_EOR 6
+#define SLC_ABORT 7
+#define SLC_EOF 8
+#define SLC_SUSP 9
+#define SLC_EC 10
+#define SLC_EL 11
+#define SLC_EW 12
+#define SLC_RP 13
+#define SLC_LNEXT 14
+#define SLC_XON 15
+#define SLC_XOFF 16
+#define SLC_FORW1 17
+#define SLC_FORW2 18
+#define SLC_MCL 19
+#define SLC_MCR 20
+#define SLC_MCWL 21
+#define SLC_MCWR 22
+#define SLC_MCBOL 23
+#define SLC_MCEOL 24
+#define SLC_INSRT 25
+#define SLC_OVER 26
+#define SLC_ECR 27
+#define SLC_EWR 28
+#define SLC_EBOL 29
+#define SLC_EEOL 30
+
+#define NSLC 30
+
+/*
+ * For backwards compatibility, we define SLC_NAMES to be the
+ * list of names if SLC_NAMES is not defined.
+ */
+#define SLC_NAMELIST "0", "SYNCH", "BRK", "IP", "AO", "AYT", "EOR", \
+ "ABORT", "EOF", "SUSP", "EC", "EL", "EW", "RP", \
+ "LNEXT", "XON", "XOFF", "FORW1", "FORW2", \
+ "MCL", "MCR", "MCWL", "MCWR", "MCBOL", \
+ "MCEOL", "INSRT", "OVER", "ECR", "EWR", \
+ "EBOL", "EEOL", \
+ 0,
+
+#ifdef SLC_NAMES
+const char *slc_names[] = {
+ SLC_NAMELIST
+};
+#else
+extern char *slc_names[];
+#define SLC_NAMES SLC_NAMELIST
+#endif
+
+#define SLC_NAME_OK(x) ((unsigned int)(x) <= NSLC)
+#define SLC_NAME(x) slc_names[x]
+
+#define SLC_NOSUPPORT 0
+#define SLC_CANTCHANGE 1
+#define SLC_VARIABLE 2
+#define SLC_DEFAULT 3
+#define SLC_LEVELBITS 0x03
+
+#define SLC_FUNC 0
+#define SLC_FLAGS 1
+#define SLC_VALUE 2
+
+#define SLC_ACK 0x80
+#define SLC_FLUSHIN 0x40
+#define SLC_FLUSHOUT 0x20
+
+#define OLD_ENV_VAR 1
+#define OLD_ENV_VALUE 0
+#define NEW_ENV_VAR 0
+#define NEW_ENV_VALUE 1
+#define ENV_ESC 2
+#define ENV_USERVAR 3
+
+/*
+ * AUTHENTICATION suboptions
+ */
+
+/*
+ * Who is authenticating who ...
+ */
+#define AUTH_WHO_CLIENT 0 /* Client authenticating server */
+#define AUTH_WHO_SERVER 1 /* Server authenticating client */
+#define AUTH_WHO_MASK 1
+
+#define AUTHTYPE_NULL 0
+#define AUTHTYPE_KERBEROS_V4 1
+#define AUTHTYPE_KERBEROS_V5 2
+#define AUTHTYPE_SPX 3
+#define AUTHTYPE_MINK 4
+#define AUTHTYPE_CNT 5
+
+#define AUTHTYPE_TEST 99
+
+#ifdef AUTH_NAMES
+const char *authtype_names[] = {
+ "NULL", "KERBEROS_V4", "KERBEROS_V5", "SPX", "MINK", 0,
+};
+#else
+extern char *authtype_names[];
+#endif
+
+#define AUTHTYPE_NAME_OK(x) ((unsigned int)(x) < AUTHTYPE_CNT)
+#define AUTHTYPE_NAME(x) authtype_names[x]
+
+/*
+ * ENCRYPTion suboptions
+ */
+#define ENCRYPT_IS 0 /* I pick encryption type ... */
+#define ENCRYPT_SUPPORT 1 /* I support encryption types ... */
+#define ENCRYPT_REPLY 2 /* Initial setup response */
+#define ENCRYPT_START 3 /* Am starting to send encrypted */
+#define ENCRYPT_END 4 /* Am ending encrypted */
+#define ENCRYPT_REQSTART 5 /* Request you start encrypting */
+#define ENCRYPT_REQEND 6 /* Request you send encrypting */
+#define ENCRYPT_ENC_KEYID 7
+#define ENCRYPT_DEC_KEYID 8
+#define ENCRYPT_CNT 9
+
+#define ENCTYPE_ANY 0
+#define ENCTYPE_DES_CFB64 1
+#define ENCTYPE_DES_OFB64 2
+#define ENCTYPE_CNT 3
+
+#ifdef ENCRYPT_NAMES
+const char *encrypt_names[] = {
+ "IS", "SUPPORT", "REPLY", "START", "END",
+ "REQUEST-START", "REQUEST-END", "ENC-KEYID", "DEC-KEYID",
+ 0,
+};
+const char *enctype_names[] = {
+ "ANY", "DES_CFB64", "DES_OFB64", 0,
+};
+#else
+extern char *encrypt_names[];
+extern char *enctype_names[];
+#endif
+
+#define ENCRYPT_NAME_OK(x) ((unsigned int)(x) < ENCRYPT_CNT)
+#define ENCRYPT_NAME(x) encrypt_names[x]
+
+#define ENCTYPE_NAME_OK(x) ((unsigned int)(x) < ENCTYPE_CNT)
+#define ENCTYPE_NAME(x) enctype_names[x]
/* normal */
static const char *cmds[] = {
@@ -109,7 +392,7 @@ numstr(int x)
/* sp points to IAC byte */
static int
-telnet_parse(const u_char *sp, u_int length, int print)
+telnet_parse(netdissect_options *ndo, const u_char *sp, u_int length, int print)
{
int i, x;
u_int c;
@@ -118,7 +401,7 @@ telnet_parse(const u_char *sp, u_int length, int print)
do { \
if (length < 1) \
goto pktend; \
- TCHECK(*sp); \
+ ND_TCHECK(*sp); \
c = *sp++; \
length--; \
} while (0)
@@ -131,7 +414,7 @@ telnet_parse(const u_char *sp, u_int length, int print)
FETCH(c, sp, length);
if (c == IAC) { /* <IAC><IAC>! */
if (print)
- printf("IAC IAC");
+ ND_PRINT((ndo, "IAC IAC"));
goto done;
}
@@ -149,16 +432,17 @@ telnet_parse(const u_char *sp, u_int length, int print)
FETCH(x, sp, length);
if (x >= 0 && x < NTELOPTS) {
if (print)
- (void)printf("%s %s", telcmds[i], telopts[x]);
+ ND_PRINT((ndo, "%s %s", telcmds[i], telopts[x]));
} else {
if (print)
- (void)printf("%s %#x", telcmds[i], x);
+ ND_PRINT((ndo, "%s %#x", telcmds[i], x));
}
if (c != SB)
break;
/* IAC SB .... IAC SE */
p = sp;
while (length > (u_int)(p + 1 - sp)) {
+ ND_TCHECK2(*p, 2);
if (p[0] == IAC && p[1] == SE)
break;
p++;
@@ -172,47 +456,46 @@ telnet_parse(const u_char *sp, u_int length, int print)
break;
FETCH(c, sp, length);
if (print)
- (void)printf(" %s", STR_OR_ID(c, authcmd));
+ ND_PRINT((ndo, " %s", STR_OR_ID(c, authcmd)));
if (p <= sp)
break;
FETCH(c, sp, length);
if (print)
- (void)printf(" %s", STR_OR_ID(c, authtype));
+ ND_PRINT((ndo, " %s", STR_OR_ID(c, authtype)));
break;
case TELOPT_ENCRYPT:
if (p <= sp)
break;
FETCH(c, sp, length);
if (print)
- (void)printf(" %s", STR_OR_ID(c, enccmd));
+ ND_PRINT((ndo, " %s", STR_OR_ID(c, enccmd)));
if (p <= sp)
break;
FETCH(c, sp, length);
if (print)
- (void)printf(" %s", STR_OR_ID(c, enctype));
+ ND_PRINT((ndo, " %s", STR_OR_ID(c, enctype)));
break;
default:
if (p <= sp)
break;
FETCH(c, sp, length);
if (print)
- (void)printf(" %s", STR_OR_ID(c, cmds));
+ ND_PRINT((ndo, " %s", STR_OR_ID(c, cmds)));
break;
}
while (p > sp) {
FETCH(x, sp, length);
if (print)
- (void)printf(" %#x", x);
+ ND_PRINT((ndo, " %#x", x));
}
/* terminating IAC SE */
if (print)
- (void)printf(" SE");
+ ND_PRINT((ndo, " SE"));
sp += 2;
- length -= 2;
break;
default:
if (print)
- (void)printf("%s", telcmds[i]);
+ ND_PRINT((ndo, "%s", telcmds[i]));
goto done;
}
@@ -220,14 +503,14 @@ done:
return sp - osp;
trunc:
- (void)printf("[|telnet]");
+ ND_PRINT((ndo, "%s", tstr));
pktend:
return -1;
#undef FETCH
}
void
-telnet_print(const u_char *sp, u_int length)
+telnet_print(netdissect_options *ndo, const u_char *sp, u_int length)
{
int first = 1;
const u_char *osp;
@@ -235,35 +518,47 @@ telnet_print(const u_char *sp, u_int length)
osp = sp;
+ ND_TCHECK(*sp);
while (length > 0 && *sp == IAC) {
- l = telnet_parse(sp, length, 0);
+ /*
+ * Parse the Telnet command without printing it,
+ * to determine its length.
+ */
+ l = telnet_parse(ndo, sp, length, 0);
if (l < 0)
break;
/*
* now print it
*/
- if (Xflag && 2 < vflag) {
+ if (ndo->ndo_Xflag && 2 < ndo->ndo_vflag) {
if (first)
- printf("\nTelnet:");
- hex_print_with_offset("\n", sp, l, sp - osp);
+ ND_PRINT((ndo, "\nTelnet:"));
+ hex_print_with_offset(ndo, "\n", sp, l, sp - osp);
if (l > 8)
- printf("\n\t\t\t\t");
+ ND_PRINT((ndo, "\n\t\t\t\t"));
else
- printf("%*s\t", (8 - l) * 3, "");
+ ND_PRINT((ndo, "%*s\t", (8 - l) * 3, ""));
} else
- printf("%s", (first) ? " [telnet " : ", ");
+ ND_PRINT((ndo, "%s", (first) ? " [telnet " : ", "));
- (void)telnet_parse(sp, length, 1);
+ (void)telnet_parse(ndo, sp, length, 1);
first = 0;
sp += l;
length -= l;
+ ND_TCHECK(*sp);
}
if (!first) {
- if (Xflag && 2 < vflag)
- printf("\n");
+ if (ndo->ndo_Xflag && 2 < ndo->ndo_vflag)
+ ND_PRINT((ndo, "\n"));
else
- printf("]");
+ ND_PRINT((ndo, "]"));
}
+ return;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-telnet-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-tftp.c b/freebsd/contrib/tcpdump/print-tftp.c
index 2a2f70b4..1c51e74d 100644
--- a/freebsd/contrib/tcpdump/print-tftp.c
+++ b/freebsd/contrib/tcpdump/print-tftp.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
@@ -19,35 +22,66 @@
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Format and print trivial file transfer protocol packets.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-tftp.c,v 1.39 2008-04-11 16:47:38 gianluca Exp $ (LBL)";
-#endif
+/* \summary: Trivial File Transfer Protocol (TFTP) printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#ifdef SEGSIZE
-#undef SEGSIZE /* SINIX sucks */
-#endif
-
-#include <stdio.h>
#include <string.h>
-#include "interface.h"
-#include "addrtoname.h"
+#include "netdissect.h"
#include "extract.h"
-#include "tftp.h"
+
+/*
+ * Trivial File Transfer Protocol (IEN-133)
+ */
+
+/*
+ * Packet types.
+ */
+#define RRQ 01 /* read request */
+#define WRQ 02 /* write request */
+#define DATA 03 /* data packet */
+#define ACK 04 /* acknowledgement */
+#define TFTP_ERROR 05 /* error code */
+#define OACK 06 /* option acknowledgement */
+
+struct tftphdr {
+ unsigned short th_opcode; /* packet type */
+ union {
+ unsigned short tu_block; /* block # */
+ unsigned short tu_code; /* error code */
+ char tu_stuff[1]; /* request packet stuff */
+ } th_u;
+ char th_data[1]; /* data or error string */
+};
+
+#define th_block th_u.tu_block
+#define th_code th_u.tu_code
+#define th_stuff th_u.tu_stuff
+#define th_msg th_data
+
+/*
+ * Error codes.
+ */
+#define EUNDEF 0 /* not defined */
+#define ENOTFOUND 1 /* file not found */
+#define EACCESS 2 /* access violation */
+#define ENOSPACE 3 /* disk full or allocation exceeded */
+#define EBADOP 4 /* illegal TFTP operation */
+#define EBADID 5 /* unknown transfer ID */
+#define EEXISTS 6 /* file already exists */
+#define ENOUSER 7 /* no such user */
+
+static const char tstr[] = " [|tftp]";
/* op code to string mapping */
-static struct tok op2str[] = {
+static const struct tok op2str[] = {
{ RRQ, "RRQ" }, /* read request */
{ WRQ, "WRQ" }, /* write request */
{ DATA, "DATA" }, /* data packet */
@@ -58,7 +92,7 @@ static struct tok op2str[] = {
};
/* error code to string mapping */
-static struct tok err2str[] = {
+static const struct tok err2str[] = {
{ EUNDEF, "EUNDEF" }, /* not defined */
{ ENOTFOUND, "ENOTFOUND" }, /* file not found */
{ EACCESS, "EACCESS" }, /* access violation */
@@ -74,24 +108,28 @@ static struct tok err2str[] = {
* Print trivial file transfer program requests
*/
void
-tftp_print(register const u_char *bp, u_int length)
+tftp_print(netdissect_options *ndo,
+ register const u_char *bp, u_int length)
{
register const struct tftphdr *tp;
register const char *cp;
register const u_char *p;
- register int opcode, i;
- static char tstr[] = " [|tftp]";
+ register int opcode;
+ u_int ui;
tp = (const struct tftphdr *)bp;
/* Print length */
- printf(" %d", length);
+ ND_PRINT((ndo, " %d", length));
/* Print tftp request type */
- TCHECK(tp->th_opcode);
+ if (length < 2)
+ goto trunc;
+ ND_TCHECK(tp->th_opcode);
opcode = EXTRACT_16BITS(&tp->th_opcode);
cp = tok2str(op2str, "tftp-#%d", opcode);
- printf(" %s", cp);
+ length -= 2;
+ ND_PRINT((ndo, " %s", cp));
/* Bail if bogus opcode */
if (*cp == 't')
return;
@@ -100,56 +138,93 @@ tftp_print(register const u_char *bp, u_int length)
case RRQ:
case WRQ:
+ p = (const u_char *)tp->th_stuff;
+ if (length == 0)
+ goto trunc;
+ ND_PRINT((ndo, " "));
+ /* Print filename */
+ ND_PRINT((ndo, "\""));
+ ui = fn_printztn(ndo, p, length, ndo->ndo_snapend);
+ ND_PRINT((ndo, "\""));
+ if (ui == 0)
+ goto trunc;
+ p += ui;
+ length -= ui;
+
+ /* Print the mode - RRQ and WRQ only */
+ if (length == 0)
+ goto trunc; /* no mode */
+ ND_PRINT((ndo, " "));
+ ui = fn_printztn(ndo, p, length, ndo->ndo_snapend);
+ if (ui == 0)
+ goto trunc;
+ p += ui;
+ length -= ui;
+
+ /* Print options, if any */
+ while (length != 0) {
+ ND_TCHECK(*p);
+ if (*p != '\0')
+ ND_PRINT((ndo, " "));
+ ui = fn_printztn(ndo, p, length, ndo->ndo_snapend);
+ if (ui == 0)
+ goto trunc;
+ p += ui;
+ length -= ui;
+ }
+ break;
+
case OACK:
- p = (u_char *)tp->th_stuff;
- putchar(' ');
- /* Print filename or first option */
- if (opcode != OACK)
- putchar('"');
- i = fn_print(p, snapend);
- if (opcode != OACK)
- putchar('"');
-
- /* Print the mode (RRQ and WRQ only) and any options */
- while ((p = (const u_char *)strchr((const char *)p, '\0')) != NULL) {
- if (length <= (u_int)(p - (const u_char *)&tp->th_block))
- break;
- p++;
- if (*p != '\0') {
- putchar(' ');
- fn_print(p, snapend);
- }
+ p = (const u_char *)tp->th_stuff;
+ /* Print options */
+ while (length != 0) {
+ ND_TCHECK(*p);
+ if (*p != '\0')
+ ND_PRINT((ndo, " "));
+ ui = fn_printztn(ndo, p, length, ndo->ndo_snapend);
+ if (ui == 0)
+ goto trunc;
+ p += ui;
+ length -= ui;
}
-
- if (i)
- goto trunc;
break;
case ACK:
case DATA:
- TCHECK(tp->th_block);
- printf(" block %d", EXTRACT_16BITS(&tp->th_block));
+ if (length < 2)
+ goto trunc; /* no block number */
+ ND_TCHECK(tp->th_block);
+ ND_PRINT((ndo, " block %d", EXTRACT_16BITS(&tp->th_block)));
break;
case TFTP_ERROR:
/* Print error code string */
- TCHECK(tp->th_code);
- printf(" %s \"", tok2str(err2str, "tftp-err-#%d \"",
- EXTRACT_16BITS(&tp->th_code)));
+ if (length < 2)
+ goto trunc; /* no error code */
+ ND_TCHECK(tp->th_code);
+ ND_PRINT((ndo, " %s", tok2str(err2str, "tftp-err-#%d \"",
+ EXTRACT_16BITS(&tp->th_code))));
+ length -= 2;
/* Print error message string */
- i = fn_print((const u_char *)tp->th_data, snapend);
- putchar('"');
- if (i)
+ if (length == 0)
+ goto trunc; /* no error message */
+ ND_PRINT((ndo, " \""));
+ ui = fn_printztn(ndo, (const u_char *)tp->th_data, length, ndo->ndo_snapend);
+ ND_PRINT((ndo, "\""));
+ if (ui == 0)
goto trunc;
break;
default:
/* We shouldn't get here */
- printf("(unknown #%d)", opcode);
+ ND_PRINT((ndo, "(unknown #%d)", opcode));
break;
}
return;
trunc:
- fputs(tstr, stdout);
+ ND_PRINT((ndo, "%s", tstr));
return;
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-tftp-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-timed.c b/freebsd/contrib/tcpdump/print-timed.c
index b9fabef7..9abbb850 100644
--- a/freebsd/contrib/tcpdump/print-timed.c
+++ b/freebsd/contrib/tcpdump/print-timed.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 2000 Ben Smithurst <ben@scientia.demon.co.uk>
* All rights reserved.
@@ -21,24 +24,75 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-timed.c,v 1.9 2003-11-16 09:36:40 guy Exp $";
-#endif
+/* \summary: BSD time daemon protocol printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
-
-#include <stdio.h>
-#include <string.h>
+#include <netdissect-stdinc.h>
-#include "timed.h"
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
+/*
+ * Time Synchronization Protocol
+ *
+ * http://docs.freebsd.org/44doc/smm/12.timed/paper.pdf
+ */
+
+struct tsp_timeval {
+ uint32_t tv_sec;
+ uint32_t tv_usec;
+};
+
+struct tsp {
+ uint8_t tsp_type;
+ uint8_t tsp_vers;
+ uint16_t tsp_seq;
+ union {
+ struct tsp_timeval tspu_time;
+ int8_t tspu_hopcnt;
+ } tsp_u;
+ int8_t tsp_name[256];
+};
+
+#define tsp_time tsp_u.tspu_time
+#define tsp_hopcnt tsp_u.tspu_hopcnt
+
+/*
+ * Command types.
+ */
+#define TSP_ANY 0 /* match any types */
+#define TSP_ADJTIME 1 /* send adjtime */
+#define TSP_ACK 2 /* generic acknowledgement */
+#define TSP_MASTERREQ 3 /* ask for master's name */
+#define TSP_MASTERACK 4 /* acknowledge master request */
+#define TSP_SETTIME 5 /* send network time */
+#define TSP_MASTERUP 6 /* inform slaves that master is up */
+#define TSP_SLAVEUP 7 /* slave is up but not polled */
+#define TSP_ELECTION 8 /* advance candidature for master */
+#define TSP_ACCEPT 9 /* support candidature of master */
+#define TSP_REFUSE 10 /* reject candidature of master */
+#define TSP_CONFLICT 11 /* two or more masters present */
+#define TSP_RESOLVE 12 /* masters' conflict resolution */
+#define TSP_QUIT 13 /* reject candidature if master is up */
+#define TSP_DATE 14 /* reset the time (date command) */
+#define TSP_DATEREQ 15 /* remote request to reset the time */
+#define TSP_DATEACK 16 /* acknowledge time setting */
+#define TSP_TRACEON 17 /* turn tracing on */
+#define TSP_TRACEOFF 18 /* turn tracing off */
+#define TSP_MSITE 19 /* find out master's site */
+#define TSP_MSITEREQ 20 /* remote master's site request */
+#define TSP_TEST 21 /* for testing election algo */
+#define TSP_SETDATE 22 /* New from date command */
+#define TSP_SETDATEREQ 23 /* New remote for above */
+#define TSP_LOOP 24 /* loop detection packet */
+
+#define TSPTYPENUMBER 25
+
+static const char tstr[] = "[|timed]";
+
static const char *tsptype[TSPTYPENUMBER] =
{ "ANY", "ADJTIME", "ACK", "MASTERREQ", "MASTERACK", "SETTIME", "MASTERUP",
"SLAVEUP", "ELECTION", "ACCEPT", "REFUSE", "CONFLICT", "RESOLVE", "QUIT",
@@ -46,68 +100,59 @@ static const char *tsptype[TSPTYPENUMBER] =
"TEST", "SETDATE", "SETDATEREQ", "LOOP" };
void
-timed_print(register const u_char *bp)
+timed_print(netdissect_options *ndo,
+ register const u_char *bp)
{
-#define endof(x) ((u_char *)&(x) + sizeof (x))
- struct tsp *tsp = (struct tsp *)bp;
+ const struct tsp *tsp = (const struct tsp *)bp;
long sec, usec;
- const u_char *end;
- if (endof(tsp->tsp_type) > snapend) {
- fputs("[|timed]", stdout);
- return;
- }
+ ND_TCHECK(tsp->tsp_type);
if (tsp->tsp_type < TSPTYPENUMBER)
- printf("TSP_%s", tsptype[tsp->tsp_type]);
+ ND_PRINT((ndo, "TSP_%s", tsptype[tsp->tsp_type]));
else
- printf("(tsp_type %#x)", tsp->tsp_type);
+ ND_PRINT((ndo, "(tsp_type %#x)", tsp->tsp_type));
- if (endof(tsp->tsp_vers) > snapend) {
- fputs(" [|timed]", stdout);
- return;
- }
- printf(" vers %d", tsp->tsp_vers);
+ ND_TCHECK(tsp->tsp_vers);
+ ND_PRINT((ndo, " vers %u", tsp->tsp_vers));
- if (endof(tsp->tsp_seq) > snapend) {
- fputs(" [|timed]", stdout);
- return;
- }
- printf(" seq %d", tsp->tsp_seq);
+ ND_TCHECK(tsp->tsp_seq);
+ ND_PRINT((ndo, " seq %u", tsp->tsp_seq));
- if (tsp->tsp_type == TSP_LOOP) {
- if (endof(tsp->tsp_hopcnt) > snapend) {
- fputs(" [|timed]", stdout);
- return;
- }
- printf(" hopcnt %d", tsp->tsp_hopcnt);
- } else if (tsp->tsp_type == TSP_SETTIME ||
- tsp->tsp_type == TSP_ADJTIME ||
- tsp->tsp_type == TSP_SETDATE ||
- tsp->tsp_type == TSP_SETDATEREQ) {
- if (endof(tsp->tsp_time) > snapend) {
- fputs(" [|timed]", stdout);
- return;
- }
+ switch (tsp->tsp_type) {
+ case TSP_LOOP:
+ ND_TCHECK(tsp->tsp_hopcnt);
+ ND_PRINT((ndo, " hopcnt %u", tsp->tsp_hopcnt));
+ break;
+ case TSP_SETTIME:
+ case TSP_ADJTIME:
+ case TSP_SETDATE:
+ case TSP_SETDATEREQ:
+ ND_TCHECK(tsp->tsp_time);
sec = EXTRACT_32BITS(&tsp->tsp_time.tv_sec);
usec = EXTRACT_32BITS(&tsp->tsp_time.tv_usec);
+ /* XXX The comparison below is always false? */
if (usec < 0)
- /* corrupt, skip the rest of the packet */
+ /* invalid, skip the rest of the packet */
return;
- fputs(" time ", stdout);
+ ND_PRINT((ndo, " time "));
if (sec < 0 && usec != 0) {
sec++;
if (sec == 0)
- fputc('-', stdout);
+ ND_PRINT((ndo, "-"));
usec = 1000000 - usec;
}
- printf("%ld.%06ld", sec, usec);
+ ND_PRINT((ndo, "%ld.%06ld", sec, usec));
+ break;
}
+ ND_TCHECK(tsp->tsp_name);
+ ND_PRINT((ndo, " name "));
+ if (fn_print(ndo, (const u_char *)tsp->tsp_name, (const u_char *)tsp->tsp_name + sizeof(tsp->tsp_name)))
+ goto trunc;
+ return;
- end = memchr(tsp->tsp_name, '\0', snapend - (u_char *)tsp->tsp_name);
- if (end == NULL)
- fputs(" [|timed]", stdout);
- else {
- fputs(" name ", stdout);
- fwrite(tsp->tsp_name, end - (u_char *)tsp->tsp_name, 1, stdout);
- }
+trunc:
+ ND_PRINT((ndo, " %s", tstr));
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-timed-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-tipc.c b/freebsd/contrib/tcpdump/print-tipc.c
index d0a20b58..15f209ac 100644
--- a/freebsd/contrib/tcpdump/print-tipc.c
+++ b/freebsd/contrib/tcpdump/print-tipc.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
@@ -21,32 +24,26 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-arp.c,v 1.66 2006-03-03 22:53:21 hannes Exp $ (LBL)";
-#endif
+/* \summary: Transparent Inter-Process Communication (TIPC) protocol printer */
+
+/*
+ * specification:
+ * http://tipc.sourceforge.net/doc/draft-spec-tipc-07.html
+ * http://tipc.sourceforge.net/doc/tipc_message_formats.html
+ */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
-
-#include <stdio.h>
-#include <string.h>
+#include <netdissect-stdinc.h>
#include "netdissect.h"
-#include "addrtoname.h"
#include "ether.h"
#include "ethertype.h"
-#include "extract.h" /* must come after interface.h */
+#include "extract.h"
-/*
- * Transparent Inter-Process Communication (TIPC) protocol.
- *
- * http://tipc.sourceforge.net/doc/draft-spec-tipc-07.html
- * http://tipc.sourceforge.net/doc/tipc_message_formats.html
- */
+static const char tstr[] = "[|TIPC]";
#define TIPC_USER_LOW_IMPORTANCE 0
#define TIPC_USER_MEDIUM_IMPORTANCE 1
@@ -71,8 +68,8 @@ static const char rcsid[] _U_ =
#define TIPC_NODE(addr) (((addr) >> 0) & 0xFFF)
struct tipc_pkthdr {
- u_int32_t w0;
- u_int32_t w1;
+ uint32_t w0;
+ uint32_t w1;
};
#define TIPC_VER(w0) (((w0) >> 29) & 0x07)
@@ -115,30 +112,30 @@ static const struct tok tipc_linkconf_mtype_values[] = {
};
struct payload_tipc_pkthdr {
- u_int32_t w0;
- u_int32_t w1;
- u_int32_t w2;
- u_int32_t prev_node;
- u_int32_t orig_port;
- u_int32_t dest_port;
- u_int32_t orig_node;
- u_int32_t dest_node;
- u_int32_t name_type;
- u_int32_t w9;
- u_int32_t wA;
+ uint32_t w0;
+ uint32_t w1;
+ uint32_t w2;
+ uint32_t prev_node;
+ uint32_t orig_port;
+ uint32_t dest_port;
+ uint32_t orig_node;
+ uint32_t dest_node;
+ uint32_t name_type;
+ uint32_t w9;
+ uint32_t wA;
};
struct internal_tipc_pkthdr {
- u_int32_t w0;
- u_int32_t w1;
- u_int32_t w2;
- u_int32_t prev_node;
- u_int32_t w4;
- u_int32_t w5;
- u_int32_t orig_node;
- u_int32_t dest_node;
- u_int32_t trans_seq;
- u_int32_t w9;
+ uint32_t w0;
+ uint32_t w1;
+ uint32_t w2;
+ uint32_t prev_node;
+ uint32_t w4;
+ uint32_t w5;
+ uint32_t orig_node;
+ uint32_t dest_node;
+ uint32_t trans_seq;
+ uint32_t w9;
};
#define TIPC_SEQ_GAP(w1) (((w1) >> 16) & 0x1FFF)
@@ -151,13 +148,13 @@ struct internal_tipc_pkthdr {
#define TIPC_LINK_TOL(w9) (((w9) >> 0) & 0xFFFF)
struct link_conf_tipc_pkthdr {
- u_int32_t w0;
- u_int32_t w1;
- u_int32_t dest_domain;
- u_int32_t prev_node;
- u_int32_t ntwrk_id;
- u_int32_t w5;
- u_int8_t media_address[16];
+ uint32_t w0;
+ uint32_t w1;
+ uint32_t dest_domain;
+ uint32_t prev_node;
+ uint32_t ntwrk_id;
+ uint32_t w5;
+ uint8_t media_address[16];
};
#define TIPC_NODE_SIG(w1) (((w1) >> 0) & 0xFFFF)
@@ -166,7 +163,7 @@ struct link_conf_tipc_pkthdr {
static void
print_payload(netdissect_options *ndo, const struct payload_tipc_pkthdr *ap)
{
- u_int32_t w0, w1, w2;
+ uint32_t w0, w1, w2;
u_int user;
u_int hsize;
u_int msize;
@@ -225,13 +222,13 @@ print_payload(netdissect_options *ndo, const struct payload_tipc_pkthdr *ap)
return;
trunc:
- ND_PRINT((ndo, "[|TIPC]"));
+ ND_PRINT((ndo, "%s", tstr));
}
-
+
static void
print_internal(netdissect_options *ndo, const struct internal_tipc_pkthdr *ap)
{
- u_int32_t w0, w1, w2, w4, w5, w9;
+ uint32_t w0, w1, w2, w4, w5, w9;
u_int user;
u_int hsize;
u_int msize;
@@ -293,13 +290,13 @@ print_internal(netdissect_options *ndo, const struct internal_tipc_pkthdr *ap)
return;
trunc:
- ND_PRINT((ndo, "[|TIPC]"));
+ ND_PRINT((ndo, "%s", tstr));
}
static void
print_link_conf(netdissect_options *ndo, const struct link_conf_tipc_pkthdr *ap)
{
- u_int32_t w0, w1, w5;
+ uint32_t w0, w1, w5;
u_int user;
u_int hsize;
u_int msize;
@@ -317,7 +314,6 @@ print_link_conf(netdissect_options *ndo, const struct link_conf_tipc_pkthdr *ap)
msize = TIPC_MSIZE(w0);
w1 = EXTRACT_32BITS(&ap->w1);
mtype = TIPC_MTYPE(w1);
- prev_node = EXTRACT_32BITS(&ap->prev_node);
dest_domain = EXTRACT_32BITS(&ap->dest_domain);
prev_node = EXTRACT_32BITS(&ap->prev_node);
@@ -340,7 +336,7 @@ print_link_conf(netdissect_options *ndo, const struct link_conf_tipc_pkthdr *ap)
return;
trunc:
- ND_PRINT((ndo, "[|TIPC]"));
+ ND_PRINT((ndo, "%s", tstr));
}
void
@@ -348,10 +344,10 @@ tipc_print(netdissect_options *ndo, const u_char *bp, u_int length _U_,
u_int caplen _U_)
{
const struct tipc_pkthdr *ap;
- u_int32_t w0;
+ uint32_t w0;
u_int user;
- ap = (struct tipc_pkthdr *)bp;
+ ap = (const struct tipc_pkthdr *)bp;
ND_TCHECK(ap->w0);
w0 = EXTRACT_32BITS(&ap->w0);
user = TIPC_USER(w0);
@@ -364,11 +360,11 @@ tipc_print(netdissect_options *ndo, const u_char *bp, u_int length _U_,
case TIPC_USER_CRITICAL_IMPORTANCE:
case TIPC_USER_NAME_DISTRIBUTOR:
case TIPC_USER_CONN_MANAGER:
- print_payload(ndo, (struct payload_tipc_pkthdr *)bp);
- break;
+ print_payload(ndo, (const struct payload_tipc_pkthdr *)bp);
+ break;
case TIPC_USER_LINK_CONFIG:
- print_link_conf(ndo, (struct link_conf_tipc_pkthdr *)bp);
+ print_link_conf(ndo, (const struct link_conf_tipc_pkthdr *)bp);
break;
case TIPC_USER_BCAST_PROTOCOL:
@@ -376,14 +372,14 @@ tipc_print(netdissect_options *ndo, const u_char *bp, u_int length _U_,
case TIPC_USER_LINK_PROTOCOL:
case TIPC_USER_CHANGEOVER_PROTOCOL:
case TIPC_USER_MSG_FRAGMENTER:
- print_internal(ndo, (struct internal_tipc_pkthdr *)bp);
+ print_internal(ndo, (const struct internal_tipc_pkthdr *)bp);
break;
}
return;
trunc:
- ND_PRINT((ndo, "[|TIPC]"));
+ ND_PRINT((ndo, "%s", tstr));
}
/*
@@ -392,3 +388,6 @@ trunc:
* End:
*/
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-tipc-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-token.c b/freebsd/contrib/tcpdump/print-token.c
index 5d1a44c3..27012e05 100644
--- a/freebsd/contrib/tcpdump/print-token.c
+++ b/freebsd/contrib/tcpdump/print-token.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996
* The Regents of the University of California. All rights reserved.
@@ -24,31 +27,76 @@
*
* Further tweaked to more closely resemble print-fddi.c
* Guy Harris <guy@alum.mit.edu>
- *
- * $FreeBSD$
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-token.c,v 1.27 2005-11-13 12:12:43 guy Exp $";
-#endif
+
+/* \summary: Token Ring printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include <pcap.h>
-#include <stdio.h>
#include <string.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
#include "addrtoname.h"
-#include "ethertype.h"
-
#include "ether.h"
-#include "token.h"
+
+/*
+ * Copyright (c) 1998, Larry Lile
+ * All rights reserved.
+ *
+ * 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 unmodified, 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ *
+ */
+
+#define TOKEN_HDRLEN 14
+#define TOKEN_RING_MAC_LEN 6
+#define ROUTING_SEGMENT_MAX 16
+#define IS_SOURCE_ROUTED(trp) ((trp)->token_shost[0] & 0x80)
+#define FRAME_TYPE(trp) (((trp)->token_fc & 0xC0) >> 6)
+#define TOKEN_FC_LLC 1
+
+#define BROADCAST(trp) ((EXTRACT_16BITS(&(trp)->token_rcf) & 0xE000) >> 13)
+#define RIF_LENGTH(trp) ((EXTRACT_16BITS(&(trp)->token_rcf) & 0x1f00) >> 8)
+#define DIRECTION(trp) ((EXTRACT_16BITS(&(trp)->token_rcf) & 0x0080) >> 7)
+#define LARGEST_FRAME(trp) ((EXTRACT_16BITS(&(trp)->token_rcf) & 0x0070) >> 4)
+#define RING_NUMBER(trp, x) ((EXTRACT_16BITS(&(trp)->token_rseg[x]) & 0xfff0) >> 4)
+#define BRIDGE_NUMBER(trp, x) ((EXTRACT_16BITS(&(trp)->token_rseg[x]) & 0x000f))
+#define SEGMENT_COUNT(trp) ((int)((RIF_LENGTH(trp) - 2) / 2))
+
+struct token_header {
+ uint8_t token_ac;
+ uint8_t token_fc;
+ uint8_t token_dhost[TOKEN_RING_MAC_LEN];
+ uint8_t token_shost[TOKEN_RING_MAC_LEN];
+ uint16_t token_rcf;
+ uint16_t token_rseg[ROUTING_SEGMENT_MAX];
+};
+
+static const char tstr[] = "[|token-ring]";
/* Extract src, dst addresses */
static inline void
@@ -62,22 +110,22 @@ extract_token_addrs(const struct token_header *trp, char *fsrc, char *fdst)
* Print the TR MAC header
*/
static inline void
-token_hdr_print(register const struct token_header *trp, register u_int length,
- register const u_char *fsrc, register const u_char *fdst)
+token_hdr_print(netdissect_options *ndo,
+ register const struct token_header *trp, register u_int length,
+ register const u_char *fsrc, register const u_char *fdst)
{
const char *srcname, *dstname;
- srcname = etheraddr_string(fsrc);
- dstname = etheraddr_string(fdst);
+ srcname = etheraddr_string(ndo, fsrc);
+ dstname = etheraddr_string(ndo, fdst);
- if (vflag)
- (void) printf("%02x %02x %s %s %d: ",
+ if (!ndo->ndo_qflag)
+ ND_PRINT((ndo, "%02x %02x ",
trp->token_ac,
- trp->token_fc,
- srcname, dstname,
- length);
- else
- printf("%s %s %d: ", srcname, dstname, length);
+ trp->token_fc));
+ ND_PRINT((ndo, "%s > %s, length %u: ",
+ srcname, dstname,
+ length));
}
static const char *broadcast_indicator[] = {
@@ -103,18 +151,19 @@ static const char *largest_frame[] = {
};
u_int
-token_print(const u_char *p, u_int length, u_int caplen)
+token_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen)
{
const struct token_header *trp;
- u_short extracted_ethertype;
+ int llc_hdrlen;
struct ether_header ehdr;
+ struct lladdr_info src, dst;
u_int route_len = 0, hdr_len = TOKEN_HDRLEN;
int seg;
trp = (const struct token_header *)p;
if (caplen < TOKEN_HDRLEN) {
- printf("[|token-ring]");
+ ND_PRINT((ndo, "%s", tstr));
return hdr_len;
}
@@ -128,38 +177,43 @@ token_print(const u_char *p, u_int length, u_int caplen)
/* Clear source-routed bit */
*ESRC(&ehdr) &= 0x7f;
- if (eflag)
- token_hdr_print(trp, length, ESRC(&ehdr), EDST(&ehdr));
+ if (ndo->ndo_eflag)
+ token_hdr_print(ndo, trp, length, ESRC(&ehdr), EDST(&ehdr));
if (caplen < TOKEN_HDRLEN + 2) {
- printf("[|token-ring]");
+ ND_PRINT((ndo, "%s", tstr));
return hdr_len;
}
route_len = RIF_LENGTH(trp);
hdr_len += route_len;
if (caplen < hdr_len) {
- printf("[|token-ring]");
+ ND_PRINT((ndo, "%s", tstr));
return hdr_len;
}
- if (vflag) {
- printf("%s ", broadcast_indicator[BROADCAST(trp)]);
- printf("%s", direction[DIRECTION(trp)]);
+ if (ndo->ndo_vflag) {
+ ND_PRINT((ndo, "%s ", broadcast_indicator[BROADCAST(trp)]));
+ ND_PRINT((ndo, "%s", direction[DIRECTION(trp)]));
for (seg = 0; seg < SEGMENT_COUNT(trp); seg++)
- printf(" [%d:%d]", RING_NUMBER(trp, seg),
- BRIDGE_NUMBER(trp, seg));
+ ND_PRINT((ndo, " [%d:%d]", RING_NUMBER(trp, seg),
+ BRIDGE_NUMBER(trp, seg)));
} else {
- printf("rt = %x", EXTRACT_16BITS(&trp->token_rcf));
+ ND_PRINT((ndo, "rt = %x", EXTRACT_16BITS(&trp->token_rcf)));
for (seg = 0; seg < SEGMENT_COUNT(trp); seg++)
- printf(":%x", EXTRACT_16BITS(&trp->token_rseg[seg]));
+ ND_PRINT((ndo, ":%x", EXTRACT_16BITS(&trp->token_rseg[seg])));
}
- printf(" (%s) ", largest_frame[LARGEST_FRAME(trp)]);
+ ND_PRINT((ndo, " (%s) ", largest_frame[LARGEST_FRAME(trp)]));
} else {
- if (eflag)
- token_hdr_print(trp, length, ESRC(&ehdr), EDST(&ehdr));
+ if (ndo->ndo_eflag)
+ token_hdr_print(ndo, trp, length, ESRC(&ehdr), EDST(&ehdr));
}
+ src.addr = ESRC(&ehdr);
+ src.addr_string = etheraddr_string;
+ dst.addr = EDST(&ehdr);
+ dst.addr_string = etheraddr_string;
+
/* Skip over token ring MAC header and routing information */
length -= hdr_len;
p += hdr_len;
@@ -168,28 +222,22 @@ token_print(const u_char *p, u_int length, u_int caplen)
/* Frame Control field determines interpretation of packet */
if (FRAME_TYPE(trp) == TOKEN_FC_LLC) {
/* Try to print the LLC-layer header & higher layers */
- if (llc_print(p, length, caplen, ESRC(&ehdr), EDST(&ehdr),
- &extracted_ethertype) == 0) {
- /* ether_type not known, print raw packet */
- if (!eflag)
- token_hdr_print(trp,
- length + TOKEN_HDRLEN + route_len,
- ESRC(&ehdr), EDST(&ehdr));
- if (extracted_ethertype) {
- printf("(LLC %s) ",
- etherproto_string(htons(extracted_ethertype)));
- }
- if (!suppress_default_print)
- default_print(p, caplen);
+ llc_hdrlen = llc_print(ndo, p, length, caplen, &src, &dst);
+ if (llc_hdrlen < 0) {
+ /* packet type not known, print raw packet */
+ if (!ndo->ndo_suppress_default_print)
+ ND_DEFAULTPRINT(p, caplen);
+ llc_hdrlen = -llc_hdrlen;
}
+ hdr_len += llc_hdrlen;
} else {
/* Some kinds of TR packet we cannot handle intelligently */
/* XXX - dissect MAC packets if frame type is 0 */
- if (!eflag)
- token_hdr_print(trp, length + TOKEN_HDRLEN + route_len,
+ if (!ndo->ndo_eflag)
+ token_hdr_print(ndo, trp, length + TOKEN_HDRLEN + route_len,
ESRC(&ehdr), EDST(&ehdr));
- if (!suppress_default_print)
- default_print(p, caplen);
+ if (!ndo->ndo_suppress_default_print)
+ ND_DEFAULTPRINT(p, caplen);
}
return (hdr_len);
}
@@ -201,7 +249,10 @@ token_print(const u_char *p, u_int length, u_int caplen)
* is the number of bytes actually captured.
*/
u_int
-token_if_print(const struct pcap_pkthdr *h, const u_char *p)
+token_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
{
- return (token_print(p, h->len, h->caplen));
+ return (token_print(ndo, p, h->len, h->caplen));
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-token-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-udld.c b/freebsd/contrib/tcpdump/print-udld.c
index 82135c9d..22c1d440 100644
--- a/freebsd/contrib/tcpdump/print-udld.c
+++ b/freebsd/contrib/tcpdump/print-udld.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1998-2007 The TCPDUMP project
*
@@ -14,25 +17,23 @@
* LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE.
*
- * UNIDIRECTIONAL LINK DETECTION (UDLD) as per
- * http://www.ietf.org/internet-drafts/draft-foschiano-udld-02.txt
- *
* Original code by Carles Kishimoto <carles.kishimoto@gmail.com>
*/
+/* \summary: Cisco UniDirectional Link Detection (UDLD) protocol printer */
+
+/* specification: RFC 5171 */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include <stdio.h>
-#include <string.h>
+#include "netdissect.h"
+#include "extract.h"
-#include "interface.h"
-#include "addrtoname.h"
-#include "extract.h"
-#include "nlpid.h"
+static const char tstr[] = " [|udld]";
#define UDLD_HEADER_LEN 4
#define UDLD_DEVICE_ID_TLV 0x0001
@@ -43,7 +44,7 @@
#define UDLD_DEVICE_NAME_TLV 0x0006
#define UDLD_SEQ_NUMBER_TLV 0x0007
-static struct tok udld_tlv_values[] = {
+static const struct tok udld_tlv_values[] = {
{ UDLD_DEVICE_ID_TLV, "Device-ID TLV"},
{ UDLD_PORT_ID_TLV, "Port-ID TLV"},
{ UDLD_ECHO_TLV, "Echo TLV"},
@@ -54,7 +55,7 @@ static struct tok udld_tlv_values[] = {
{ 0, NULL}
};
-static struct tok udld_code_values[] = {
+static const struct tok udld_code_values[] = {
{ 0x00, "Reserved"},
{ 0x01, "Probe message"},
{ 0x02, "Echo message"},
@@ -62,30 +63,43 @@ static struct tok udld_code_values[] = {
{ 0, NULL}
};
-static struct tok udld_flags_values[] = {
+static const struct tok udld_flags_values[] = {
{ 0x00, "RT"},
{ 0x01, "RSY"},
{ 0, NULL}
};
/*
+ * UDLD's Protocol Data Unit format:
+ *
+ * 0 1 2 3
+ * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Ver | Opcode | Flags | Checksum |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | List of TLVs (variable length list) |
+ * | ... |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *
+ * TLV format:
*
- * 0 1 2 3
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Ver | Opcode | Flags | Checksum |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | List of TLVs (variable length list) |
- * | ... |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * 0 1 2 3
+ * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | TYPE | LENGTH |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | VALUE |
+ * | ... |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*
+ * LENGTH: Length in bytes of the Type, Length, and Value fields.
*/
-#define UDLD_EXTRACT_VERSION(x) (((x)&0xe0)>>5)
-#define UDLD_EXTRACT_OPCODE(x) ((x)&0x1f)
+#define UDLD_EXTRACT_VERSION(x) (((x)&0xe0)>>5)
+#define UDLD_EXTRACT_OPCODE(x) ((x)&0x1f)
void
-udld_print (const u_char *pptr, u_int length)
+udld_print (netdissect_options *ndo, const u_char *pptr, u_int length)
{
int code, type, len;
const u_char *tptr;
@@ -93,78 +107,92 @@ udld_print (const u_char *pptr, u_int length)
if (length < UDLD_HEADER_LEN)
goto trunc;
- tptr = pptr;
+ tptr = pptr;
- if (!TTEST2(*tptr, UDLD_HEADER_LEN))
- goto trunc;
+ ND_TCHECK2(*tptr, UDLD_HEADER_LEN);
code = UDLD_EXTRACT_OPCODE(*tptr);
- printf("UDLDv%u, Code %s (%x), Flags [%s] (0x%02x), length %u",
+ ND_PRINT((ndo, "UDLDv%u, Code %s (%x), Flags [%s] (0x%02x), length %u",
UDLD_EXTRACT_VERSION(*tptr),
tok2str(udld_code_values, "Reserved", code),
code,
bittok2str(udld_flags_values, "none", *(tptr+1)),
*(tptr+1),
- length);
+ length));
/*
* In non-verbose mode, just print version and opcode type
*/
- if (vflag < 1) {
+ if (ndo->ndo_vflag < 1) {
return;
}
- printf("\n\tChecksum 0x%04x (unverified)", EXTRACT_16BITS(tptr+2));
+ ND_PRINT((ndo, "\n\tChecksum 0x%04x (unverified)", EXTRACT_16BITS(tptr+2)));
tptr += UDLD_HEADER_LEN;
while (tptr < (pptr+length)) {
- if (!TTEST2(*tptr, 4))
- goto trunc;
-
+ ND_TCHECK2(*tptr, 4);
type = EXTRACT_16BITS(tptr);
- len = EXTRACT_16BITS(tptr+2);
- len -= 4;
- tptr += 4;
+ len = EXTRACT_16BITS(tptr+2);
+
+ ND_PRINT((ndo, "\n\t%s (0x%04x) TLV, length %u",
+ tok2str(udld_tlv_values, "Unknown", type),
+ type, len));
+
+ if (type == 0)
+ goto invalid;
/* infinite loop check */
- if (type == 0 || len == 0) {
- return;
- }
+ if (len <= 4)
+ goto invalid;
- printf("\n\t%s (0x%04x) TLV, length %u",
- tok2str(udld_tlv_values, "Unknown", type),
- type, len);
+ len -= 4;
+ tptr += 4;
+
+ ND_TCHECK2(*tptr, len);
switch (type) {
case UDLD_DEVICE_ID_TLV:
case UDLD_PORT_ID_TLV:
+ case UDLD_DEVICE_NAME_TLV:
+ ND_PRINT((ndo, ", "));
+ fn_printzp(ndo, tptr, len, NULL);
+ break;
+
case UDLD_ECHO_TLV:
- case UDLD_DEVICE_NAME_TLV:
- printf(", %s", tptr);
+ ND_PRINT((ndo, ", "));
+ (void)fn_printn(ndo, tptr, len, NULL);
break;
- case UDLD_MESSAGE_INTERVAL_TLV:
+ case UDLD_MESSAGE_INTERVAL_TLV:
case UDLD_TIMEOUT_INTERVAL_TLV:
- printf(", %us", (*tptr));
+ if (len != 1)
+ goto invalid;
+ ND_PRINT((ndo, ", %us", (*tptr)));
break;
case UDLD_SEQ_NUMBER_TLV:
- printf(", %u", EXTRACT_32BITS(tptr));
+ if (len != 4)
+ goto invalid;
+ ND_PRINT((ndo, ", %u", EXTRACT_32BITS(tptr)));
break;
default:
break;
- }
+ }
tptr += len;
}
return;
- trunc:
- printf("[|udld]");
+invalid:
+ ND_PRINT((ndo, "%s", istr));
+ return;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
}
/*
@@ -173,3 +201,6 @@ udld_print (const u_char *pptr, u_int length)
* c-basic-offset: 4
* End:
*/
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-udld-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-udp.c b/freebsd/contrib/tcpdump/print-udp.c
index fa419fb8..62c49866 100644
--- a/freebsd/contrib/tcpdump/print-udp.c
+++ b/freebsd/contrib/tcpdump/print-udp.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
@@ -19,29 +22,17 @@
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * $FreeBSD$
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-udp.c,v 1.142 2007-08-08 17:20:58 hannes Exp $ (LBL)";
-#endif
+/* \summary: UDP printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
-
-#ifdef SEGSIZE
-#undef SEGSIZE
-#endif
-
-#include <stdio.h>
-#include <string.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "extract.h"
#include "appletalk.h"
@@ -49,26 +40,27 @@ static const char rcsid[] _U_ =
#include "udp.h"
#include "ip.h"
-#ifdef INET6
#include "ip6.h"
-#endif
#include "ipproto.h"
#include "rpc_auth.h"
#include "rpc_msg.h"
-#include "nameser.h"
#include "nfs.h"
-#include "bootp.h"
+
+static const char vat_tstr[] = " [|vat]";
+static const char rtp_tstr[] = " [|rtp]";
+static const char rtcp_tstr[] = " [|rtcp]";
+static const char udp_tstr[] = " [|udp]";
struct rtcphdr {
- u_int16_t rh_flags; /* T:2 P:1 CNT:5 PT:8 */
- u_int16_t rh_len; /* length of message (in words) */
- u_int32_t rh_ssrc; /* synchronization src id */
+ uint16_t rh_flags; /* T:2 P:1 CNT:5 PT:8 */
+ uint16_t rh_len; /* length of message (in words) */
+ uint32_t rh_ssrc; /* synchronization src id */
};
typedef struct {
- u_int32_t upper; /* more significant 32 bits */
- u_int32_t lower; /* less significant 32 bits */
+ uint32_t upper; /* more significant 32 bits */
+ uint32_t lower; /* less significant 32 bits */
} ntp64;
/*
@@ -76,9 +68,9 @@ typedef struct {
*/
struct rtcp_sr {
ntp64 sr_ntp; /* 64-bit ntp timestamp */
- u_int32_t sr_ts; /* reference media timestamp */
- u_int32_t sr_np; /* no. packets sent */
- u_int32_t sr_nb; /* no. bytes sent */
+ uint32_t sr_ts; /* reference media timestamp */
+ uint32_t sr_np; /* no. packets sent */
+ uint32_t sr_nb; /* no. bytes sent */
};
/*
@@ -86,12 +78,12 @@ struct rtcp_sr {
* Time stamps are middle 32-bits of ntp timestamp.
*/
struct rtcp_rr {
- u_int32_t rr_srcid; /* sender being reported */
- u_int32_t rr_nl; /* no. packets lost */
- u_int32_t rr_ls; /* extended last seq number received */
- u_int32_t rr_dv; /* jitter (delay variance) */
- u_int32_t rr_lsr; /* orig. ts from last rr from this src */
- u_int32_t rr_dlsr; /* time from recpt of last rr to xmit time */
+ uint32_t rr_srcid; /* sender being reported */
+ uint32_t rr_nl; /* no. packets lost */
+ uint32_t rr_ls; /* extended last seq number received */
+ uint32_t rr_dv; /* jitter (delay variance) */
+ uint32_t rr_lsr; /* orig. ts from last rr from this src */
+ uint32_t rr_dlsr; /* time from recpt of last rr to xmit time */
};
/*XXX*/
@@ -110,55 +102,72 @@ struct rtcp_rr {
#define RTCP_PT_APP 204
static void
-vat_print(const void *hdr, register const struct udphdr *up)
+vat_print(netdissect_options *ndo, const void *hdr, register const struct udphdr *up)
{
/* vat/vt audio */
- u_int ts = *(u_int16_t *)hdr;
+ u_int ts;
+
+ ND_TCHECK_16BITS((const u_int *)hdr);
+ ts = EXTRACT_16BITS(hdr);
if ((ts & 0xf060) != 0) {
/* probably vt */
- (void)printf("udp/vt %u %d / %d",
- (u_int32_t)(EXTRACT_16BITS(&up->uh_ulen) - sizeof(*up)),
- ts & 0x3ff, ts >> 10);
+ ND_TCHECK_16BITS(&up->uh_ulen);
+ ND_PRINT((ndo, "udp/vt %u %d / %d",
+ (uint32_t)(EXTRACT_16BITS(&up->uh_ulen) - sizeof(*up)),
+ ts & 0x3ff, ts >> 10));
} else {
/* probably vat */
- u_int32_t i0 = EXTRACT_32BITS(&((u_int *)hdr)[0]);
- u_int32_t i1 = EXTRACT_32BITS(&((u_int *)hdr)[1]);
- printf("udp/vat %u c%d %u%s",
- (u_int32_t)(EXTRACT_16BITS(&up->uh_ulen) - sizeof(*up) - 8),
+ uint32_t i0, i1;
+
+ ND_TCHECK_32BITS(&((const u_int *)hdr)[0]);
+ i0 = EXTRACT_32BITS(&((const u_int *)hdr)[0]);
+ ND_TCHECK_32BITS(&((const u_int *)hdr)[1]);
+ i1 = EXTRACT_32BITS(&((const u_int *)hdr)[1]);
+ ND_TCHECK_16BITS(&up->uh_ulen);
+ ND_PRINT((ndo, "udp/vat %u c%d %u%s",
+ (uint32_t)(EXTRACT_16BITS(&up->uh_ulen) - sizeof(*up) - 8),
i0 & 0xffff,
- i1, i0 & 0x800000? "*" : "");
+ i1, i0 & 0x800000? "*" : ""));
/* audio format */
if (i0 & 0x1f0000)
- printf(" f%d", (i0 >> 16) & 0x1f);
+ ND_PRINT((ndo, " f%d", (i0 >> 16) & 0x1f));
if (i0 & 0x3f000000)
- printf(" s%d", (i0 >> 24) & 0x3f);
+ ND_PRINT((ndo, " s%d", (i0 >> 24) & 0x3f));
}
+
+trunc:
+ ND_PRINT((ndo, "%s", vat_tstr));
}
static void
-rtp_print(const void *hdr, u_int len, register const struct udphdr *up)
+rtp_print(netdissect_options *ndo, const void *hdr, u_int len,
+ register const struct udphdr *up)
{
/* rtp v1 or v2 */
- u_int *ip = (u_int *)hdr;
- u_int hasopt, hasext, contype, hasmarker;
- u_int32_t i0 = EXTRACT_32BITS(&((u_int *)hdr)[0]);
- u_int32_t i1 = EXTRACT_32BITS(&((u_int *)hdr)[1]);
- u_int dlen = EXTRACT_16BITS(&up->uh_ulen) - sizeof(*up) - 8;
+ const u_int *ip = (const u_int *)hdr;
+ u_int hasopt, hasext, contype, hasmarker, dlen;
+ uint32_t i0, i1;
const char * ptype;
+ ND_TCHECK_32BITS(&((const u_int *)hdr)[0]);
+ i0 = EXTRACT_32BITS(&((const u_int *)hdr)[0]);
+ ND_TCHECK_32BITS(&((const u_int *)hdr)[1]);
+ i1 = EXTRACT_32BITS(&((const u_int *)hdr)[1]);
+ ND_TCHECK_16BITS(&up->uh_ulen);
+ dlen = EXTRACT_16BITS(&up->uh_ulen) - sizeof(*up) - 8;
ip += 2;
len >>= 2;
len -= 2;
hasopt = 0;
hasext = 0;
if ((i0 >> 30) == 1) {
- /* rtp v1 */
+ /* rtp v1 - draft-ietf-avt-rtp-04 */
hasopt = i0 & 0x800000;
contype = (i0 >> 16) & 0x3f;
hasmarker = i0 & 0x400000;
ptype = "rtpv1";
} else {
- /* rtp v2 */
+ /* rtp v2 - RFC 3550 */
hasext = i0 & 0x10000000;
contype = (i0 >> 16) & 0x7f;
hasmarker = i0 & 0x800000;
@@ -167,23 +176,25 @@ rtp_print(const void *hdr, u_int len, register const struct udphdr *up)
ip += 1;
len -= 1;
}
- printf("udp/%s %d c%d %s%s %d %u",
+ ND_PRINT((ndo, "udp/%s %d c%d %s%s %d %u",
ptype,
dlen,
contype,
(hasopt || hasext)? "+" : "",
hasmarker? "*" : "",
i0 & 0xffff,
- i1);
- if (vflag) {
- printf(" %u", EXTRACT_32BITS(&((u_int *)hdr)[2]));
+ i1));
+ if (ndo->ndo_vflag) {
+ ND_TCHECK_32BITS(&((const u_int *)hdr)[2]);
+ ND_PRINT((ndo, " %u", EXTRACT_32BITS(&((const u_int *)hdr)[2])));
if (hasopt) {
u_int i2, optlen;
do {
- i2 = ip[0];
+ ND_TCHECK_32BITS(ip);
+ i2 = EXTRACT_32BITS(ip);
optlen = (i2 >> 16) & 0xff;
if (optlen == 0 || optlen > len) {
- printf(" !opt");
+ ND_PRINT((ndo, " !opt"));
return;
}
ip += optlen;
@@ -192,121 +203,124 @@ rtp_print(const void *hdr, u_int len, register const struct udphdr *up)
}
if (hasext) {
u_int i2, extlen;
- i2 = ip[0];
+ ND_TCHECK_32BITS(ip);
+ i2 = EXTRACT_32BITS(ip);
extlen = (i2 & 0xffff) + 1;
if (extlen > len) {
- printf(" !ext");
+ ND_PRINT((ndo, " !ext"));
return;
}
ip += extlen;
}
+ ND_TCHECK_32BITS(ip);
if (contype == 0x1f) /*XXX H.261 */
- printf(" 0x%04x", ip[0] >> 16);
+ ND_PRINT((ndo, " 0x%04x", EXTRACT_32BITS(ip) >> 16));
}
+
+trunc:
+ ND_PRINT((ndo, "%s", rtp_tstr));
}
static const u_char *
-rtcp_print(const u_char *hdr, const u_char *ep)
+rtcp_print(netdissect_options *ndo, const u_char *hdr, const u_char *ep)
{
/* rtp v2 control (rtcp) */
- struct rtcp_rr *rr = 0;
- struct rtcp_sr *sr;
- struct rtcphdr *rh = (struct rtcphdr *)hdr;
+ const struct rtcp_rr *rr = 0;
+ const struct rtcp_sr *sr;
+ const struct rtcphdr *rh = (const struct rtcphdr *)hdr;
u_int len;
- u_int16_t flags;
+ uint16_t flags;
int cnt;
double ts, dts;
- if ((u_char *)(rh + 1) > ep) {
- printf(" [|rtcp]");
- return (ep);
- }
+ if ((const u_char *)(rh + 1) > ep)
+ goto trunc;
+ ND_TCHECK(*rh);
len = (EXTRACT_16BITS(&rh->rh_len) + 1) * 4;
flags = EXTRACT_16BITS(&rh->rh_flags);
cnt = (flags >> 8) & 0x1f;
switch (flags & 0xff) {
case RTCP_PT_SR:
- sr = (struct rtcp_sr *)(rh + 1);
- printf(" sr");
+ sr = (const struct rtcp_sr *)(rh + 1);
+ ND_PRINT((ndo, " sr"));
if (len != cnt * sizeof(*rr) + sizeof(*sr) + sizeof(*rh))
- printf(" [%d]", len);
- if (vflag)
- printf(" %u", EXTRACT_32BITS(&rh->rh_ssrc));
- if ((u_char *)(sr + 1) > ep) {
- printf(" [|rtcp]");
- return (ep);
- }
+ ND_PRINT((ndo, " [%d]", len));
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo, " %u", EXTRACT_32BITS(&rh->rh_ssrc)));
+ if ((const u_char *)(sr + 1) > ep)
+ goto trunc;
+ ND_TCHECK(*sr);
ts = (double)(EXTRACT_32BITS(&sr->sr_ntp.upper)) +
((double)(EXTRACT_32BITS(&sr->sr_ntp.lower)) /
4294967296.0);
- printf(" @%.2f %u %up %ub", ts, EXTRACT_32BITS(&sr->sr_ts),
- EXTRACT_32BITS(&sr->sr_np), EXTRACT_32BITS(&sr->sr_nb));
- rr = (struct rtcp_rr *)(sr + 1);
+ ND_PRINT((ndo, " @%.2f %u %up %ub", ts, EXTRACT_32BITS(&sr->sr_ts),
+ EXTRACT_32BITS(&sr->sr_np), EXTRACT_32BITS(&sr->sr_nb)));
+ rr = (const struct rtcp_rr *)(sr + 1);
break;
case RTCP_PT_RR:
- printf(" rr");
+ ND_PRINT((ndo, " rr"));
if (len != cnt * sizeof(*rr) + sizeof(*rh))
- printf(" [%d]", len);
- rr = (struct rtcp_rr *)(rh + 1);
- if (vflag)
- printf(" %u", EXTRACT_32BITS(&rh->rh_ssrc));
+ ND_PRINT((ndo, " [%d]", len));
+ rr = (const struct rtcp_rr *)(rh + 1);
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo, " %u", EXTRACT_32BITS(&rh->rh_ssrc)));
break;
case RTCP_PT_SDES:
- printf(" sdes %d", len);
- if (vflag)
- printf(" %u", EXTRACT_32BITS(&rh->rh_ssrc));
+ ND_PRINT((ndo, " sdes %d", len));
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo, " %u", EXTRACT_32BITS(&rh->rh_ssrc)));
cnt = 0;
break;
case RTCP_PT_BYE:
- printf(" bye %d", len);
- if (vflag)
- printf(" %u", EXTRACT_32BITS(&rh->rh_ssrc));
+ ND_PRINT((ndo, " bye %d", len));
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo, " %u", EXTRACT_32BITS(&rh->rh_ssrc)));
cnt = 0;
break;
default:
- printf(" type-0x%x %d", flags & 0xff, len);
+ ND_PRINT((ndo, " type-0x%x %d", flags & 0xff, len));
cnt = 0;
break;
}
if (cnt > 1)
- printf(" c%d", cnt);
+ ND_PRINT((ndo, " c%d", cnt));
while (--cnt >= 0) {
- if ((u_char *)(rr + 1) > ep) {
- printf(" [|rtcp]");
- return (ep);
- }
- if (vflag)
- printf(" %u", EXTRACT_32BITS(&rr->rr_srcid));
+ if ((const u_char *)(rr + 1) > ep)
+ goto trunc;
+ ND_TCHECK(*rr);
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo, " %u", EXTRACT_32BITS(&rr->rr_srcid)));
ts = (double)(EXTRACT_32BITS(&rr->rr_lsr)) / 65536.;
dts = (double)(EXTRACT_32BITS(&rr->rr_dlsr)) / 65536.;
- printf(" %ul %us %uj @%.2f+%.2f",
+ ND_PRINT((ndo, " %ul %us %uj @%.2f+%.2f",
EXTRACT_32BITS(&rr->rr_nl) & 0x00ffffff,
EXTRACT_32BITS(&rr->rr_ls),
- EXTRACT_32BITS(&rr->rr_dv), ts, dts);
+ EXTRACT_32BITS(&rr->rr_dv), ts, dts));
}
return (hdr + len);
+
+trunc:
+ ND_PRINT((ndo, "%s", rtcp_tstr));
+ return ep;
}
-static int udp_cksum(register const struct ip *ip,
+static int udp_cksum(netdissect_options *ndo, register const struct ip *ip,
register const struct udphdr *up,
register u_int len)
{
- return (nextproto4_cksum(ip, (const u_int8_t *)(void *)up, len,
- IPPROTO_UDP));
+ return nextproto4_cksum(ndo, ip, (const uint8_t *)(const void *)up, len, len,
+ IPPROTO_UDP);
}
-#ifdef INET6
-static int udp6_cksum(const struct ip6_hdr *ip6, const struct udphdr *up,
- u_int len)
+static int udp6_cksum(netdissect_options *ndo, const struct ip6_hdr *ip6,
+ const struct udphdr *up, u_int len)
{
- return (nextproto6_cksum(ip6, (const u_int8_t *)(void *)up, len,
- IPPROTO_UDP));
+ return nextproto6_cksum(ndo, ip6, (const uint8_t *)(const void *)up, len, len,
+ IPPROTO_UDP);
}
-#endif
static void
-udpipaddr_print(const struct ip *ip, int sport, int dport)
+udpipaddr_print(netdissect_options *ndo, const struct ip *ip, int sport, int dport)
{
-#ifdef INET6
const struct ip6_hdr *ip6;
if (IP_V(ip) == 6)
@@ -317,371 +331,389 @@ udpipaddr_print(const struct ip *ip, int sport, int dport)
if (ip6) {
if (ip6->ip6_nxt == IPPROTO_UDP) {
if (sport == -1) {
- (void)printf("%s > %s: ",
- ip6addr_string(&ip6->ip6_src),
- ip6addr_string(&ip6->ip6_dst));
+ ND_PRINT((ndo, "%s > %s: ",
+ ip6addr_string(ndo, &ip6->ip6_src),
+ ip6addr_string(ndo, &ip6->ip6_dst)));
} else {
- (void)printf("%s.%s > %s.%s: ",
- ip6addr_string(&ip6->ip6_src),
- udpport_string(sport),
- ip6addr_string(&ip6->ip6_dst),
- udpport_string(dport));
+ ND_PRINT((ndo, "%s.%s > %s.%s: ",
+ ip6addr_string(ndo, &ip6->ip6_src),
+ udpport_string(ndo, sport),
+ ip6addr_string(ndo, &ip6->ip6_dst),
+ udpport_string(ndo, dport)));
}
} else {
if (sport != -1) {
- (void)printf("%s > %s: ",
- udpport_string(sport),
- udpport_string(dport));
+ ND_PRINT((ndo, "%s > %s: ",
+ udpport_string(ndo, sport),
+ udpport_string(ndo, dport)));
}
}
- } else
-#endif /*INET6*/
- {
+ } else {
if (ip->ip_p == IPPROTO_UDP) {
if (sport == -1) {
- (void)printf("%s > %s: ",
- ipaddr_string(&ip->ip_src),
- ipaddr_string(&ip->ip_dst));
+ ND_PRINT((ndo, "%s > %s: ",
+ ipaddr_string(ndo, &ip->ip_src),
+ ipaddr_string(ndo, &ip->ip_dst)));
} else {
- (void)printf("%s.%s > %s.%s: ",
- ipaddr_string(&ip->ip_src),
- udpport_string(sport),
- ipaddr_string(&ip->ip_dst),
- udpport_string(dport));
+ ND_PRINT((ndo, "%s.%s > %s.%s: ",
+ ipaddr_string(ndo, &ip->ip_src),
+ udpport_string(ndo, sport),
+ ipaddr_string(ndo, &ip->ip_dst),
+ udpport_string(ndo, dport)));
}
} else {
if (sport != -1) {
- (void)printf("%s > %s: ",
- udpport_string(sport),
- udpport_string(dport));
+ ND_PRINT((ndo, "%s > %s: ",
+ udpport_string(ndo, sport),
+ udpport_string(ndo, dport)));
}
}
}
}
void
-udp_print(register const u_char *bp, u_int length,
+udp_print(netdissect_options *ndo, register const u_char *bp, u_int length,
register const u_char *bp2, int fragmented)
{
register const struct udphdr *up;
register const struct ip *ip;
register const u_char *cp;
register const u_char *ep = bp + length;
- u_int16_t sport, dport, ulen;
-#ifdef INET6
+ uint16_t sport, dport, ulen;
register const struct ip6_hdr *ip6;
-#endif
- if (ep > snapend)
- ep = snapend;
- up = (struct udphdr *)bp;
- ip = (struct ip *)bp2;
-#ifdef INET6
+ if (ep > ndo->ndo_snapend)
+ ep = ndo->ndo_snapend;
+ up = (const struct udphdr *)bp;
+ ip = (const struct ip *)bp2;
if (IP_V(ip) == 6)
- ip6 = (struct ip6_hdr *)bp2;
+ ip6 = (const struct ip6_hdr *)bp2;
else
ip6 = NULL;
-#endif /*INET6*/
- cp = (u_char *)(up + 1);
- if (!TTEST(up->uh_dport)) {
- udpipaddr_print(ip, -1, -1);
- (void)printf("[|udp]");
- return;
+ if (!ND_TTEST(up->uh_dport)) {
+ udpipaddr_print(ndo, ip, -1, -1);
+ goto trunc;
}
sport = EXTRACT_16BITS(&up->uh_sport);
dport = EXTRACT_16BITS(&up->uh_dport);
if (length < sizeof(struct udphdr)) {
- udpipaddr_print(ip, sport, dport);
- (void)printf("truncated-udp %d", length);
+ udpipaddr_print(ndo, ip, sport, dport);
+ ND_PRINT((ndo, "truncated-udp %d", length));
return;
}
- length -= sizeof(struct udphdr);
-
- if (cp > snapend) {
- udpipaddr_print(ip, sport, dport);
- (void)printf("[|udp]");
- return;
+ if (!ND_TTEST(up->uh_ulen)) {
+ udpipaddr_print(ndo, ip, sport, dport);
+ goto trunc;
}
-
ulen = EXTRACT_16BITS(&up->uh_ulen);
- if (ulen < 8) {
- udpipaddr_print(ip, sport, dport);
- (void)printf("truncated-udplength %d", ulen);
+ if (ulen < sizeof(struct udphdr)) {
+ udpipaddr_print(ndo, ip, sport, dport);
+ ND_PRINT((ndo, "truncated-udplength %d", ulen));
return;
}
- if (packettype) {
- register struct sunrpc_msg *rp;
+ ulen -= sizeof(struct udphdr);
+ length -= sizeof(struct udphdr);
+ if (ulen < length)
+ length = ulen;
+
+ cp = (const u_char *)(up + 1);
+ if (cp > ndo->ndo_snapend) {
+ udpipaddr_print(ndo, ip, sport, dport);
+ goto trunc;
+ }
+
+ if (ndo->ndo_packettype) {
+ register const struct sunrpc_msg *rp;
enum sunrpc_msg_type direction;
- switch (packettype) {
+ switch (ndo->ndo_packettype) {
case PT_VAT:
- udpipaddr_print(ip, sport, dport);
- vat_print((void *)(up + 1), up);
+ udpipaddr_print(ndo, ip, sport, dport);
+ vat_print(ndo, (const void *)(up + 1), up);
break;
case PT_WB:
- udpipaddr_print(ip, sport, dport);
- wb_print((void *)(up + 1), length);
+ udpipaddr_print(ndo, ip, sport, dport);
+ wb_print(ndo, (const void *)(up + 1), length);
break;
case PT_RPC:
- rp = (struct sunrpc_msg *)(up + 1);
+ rp = (const struct sunrpc_msg *)(up + 1);
direction = (enum sunrpc_msg_type)EXTRACT_32BITS(&rp->rm_direction);
#ifndef __rtems__
if (direction == SUNRPC_CALL)
- sunrpcrequest_print((u_char *)rp, length,
- (u_char *)ip);
+ sunrpcrequest_print(ndo, (const u_char *)rp, length,
+ (const u_char *)ip);
else
-#endif
- nfsreply_print((u_char *)rp, length,
- (u_char *)ip); /*XXX*/
+#endif /* __rtems__ */
+ nfsreply_print(ndo, (const u_char *)rp, length,
+ (const u_char *)ip); /*XXX*/
break;
case PT_RTP:
- udpipaddr_print(ip, sport, dport);
- rtp_print((void *)(up + 1), length, up);
+ udpipaddr_print(ndo, ip, sport, dport);
+ rtp_print(ndo, (const void *)(up + 1), length, up);
break;
case PT_RTCP:
- udpipaddr_print(ip, sport, dport);
+ udpipaddr_print(ndo, ip, sport, dport);
while (cp < ep)
- cp = rtcp_print(cp, ep);
+ cp = rtcp_print(ndo, cp, ep);
break;
case PT_SNMP:
- udpipaddr_print(ip, sport, dport);
- snmp_print((const u_char *)(up + 1), length);
+ udpipaddr_print(ndo, ip, sport, dport);
+ snmp_print(ndo, (const u_char *)(up + 1), length);
break;
case PT_CNFP:
- udpipaddr_print(ip, sport, dport);
- cnfp_print(cp, (const u_char *)ip);
+ udpipaddr_print(ndo, ip, sport, dport);
+ cnfp_print(ndo, cp);
break;
case PT_TFTP:
- udpipaddr_print(ip, sport, dport);
- tftp_print(cp, length);
+ udpipaddr_print(ndo, ip, sport, dport);
+ tftp_print(ndo, cp, length);
break;
case PT_AODV:
- udpipaddr_print(ip, sport, dport);
- aodv_print((const u_char *)(up + 1), length,
-#ifdef INET6
+ udpipaddr_print(ndo, ip, sport, dport);
+ aodv_print(ndo, (const u_char *)(up + 1), length,
ip6 != NULL);
-#else
- 0);
-#endif
break;
case PT_RADIUS:
- udpipaddr_print(ip, sport, dport);
- radius_print(cp, length);
+ udpipaddr_print(ndo, ip, sport, dport);
+ radius_print(ndo, cp, length);
break;
case PT_VXLAN:
- udpipaddr_print(ip, sport, dport);
- vxlan_print((const u_char *)(up + 1), length);
+ udpipaddr_print(ndo, ip, sport, dport);
+ vxlan_print(ndo, (const u_char *)(up + 1), length);
+ break;
+
+ case PT_PGM:
+ case PT_PGM_ZMTP1:
+ udpipaddr_print(ndo, ip, sport, dport);
+ pgm_print(ndo, cp, length, bp2);
+ break;
+ case PT_LMP:
+ udpipaddr_print(ndo, ip, sport, dport);
+ lmp_print(ndo, cp, length);
break;
}
return;
}
- if (!qflag) {
- register struct sunrpc_msg *rp;
+ udpipaddr_print(ndo, ip, sport, dport);
+ if (!ndo->ndo_qflag) {
+ register const struct sunrpc_msg *rp;
enum sunrpc_msg_type direction;
- rp = (struct sunrpc_msg *)(up + 1);
- if (TTEST(rp->rm_direction)) {
+ rp = (const struct sunrpc_msg *)(up + 1);
+ if (ND_TTEST(rp->rm_direction)) {
direction = (enum sunrpc_msg_type)EXTRACT_32BITS(&rp->rm_direction);
if (dport == NFS_PORT && direction == SUNRPC_CALL) {
- nfsreq_print((u_char *)rp, length,
- (u_char *)ip);
+ ND_PRINT((ndo, "NFS request xid %u ", EXTRACT_32BITS(&rp->rm_xid)));
+ nfsreq_print_noaddr(ndo, (const u_char *)rp, length,
+ (const u_char *)ip);
return;
}
if (sport == NFS_PORT && direction == SUNRPC_REPLY) {
- nfsreply_print((u_char *)rp, length,
- (u_char *)ip);
+ ND_PRINT((ndo, "NFS reply xid %u ", EXTRACT_32BITS(&rp->rm_xid)));
+ nfsreply_print_noaddr(ndo, (const u_char *)rp, length,
+ (const u_char *)ip);
return;
}
#ifdef notdef
if (dport == SUNRPC_PORT && direction == SUNRPC_CALL) {
- sunrpcrequest_print((u_char *)rp, length, (u_char *)ip);
+ sunrpcrequest_print((const u_char *)rp, length, (const u_char *)ip);
return;
}
#endif
}
- if (TTEST(((struct LAP *)cp)->type) &&
- ((struct LAP *)cp)->type == lapDDP &&
- (atalk_port(sport) || atalk_port(dport))) {
- if (vflag)
- fputs("kip ", stdout);
- llap_print(cp, length);
- return;
- }
}
- udpipaddr_print(ip, sport, dport);
- if (vflag && !Kflag && !fragmented) {
+ if (ndo->ndo_vflag && !ndo->ndo_Kflag && !fragmented) {
/* Check the checksum, if possible. */
- u_int16_t sum, udp_sum;
+ uint16_t sum, udp_sum;
/*
* XXX - do this even if vflag == 1?
* TCP does, and we do so for UDP-over-IPv6.
*/
- if (IP_V(ip) == 4 && (vflag > 1)) {
+ if (IP_V(ip) == 4 && (ndo->ndo_vflag > 1)) {
udp_sum = EXTRACT_16BITS(&up->uh_sum);
if (udp_sum == 0) {
- (void)printf("[no cksum] ");
- } else if (TTEST2(cp[0], length)) {
- sum = udp_cksum(ip, up, length + sizeof(struct udphdr));
+ ND_PRINT((ndo, "[no cksum] "));
+ } else if (ND_TTEST2(cp[0], length)) {
+ sum = udp_cksum(ndo, ip, up, length + sizeof(struct udphdr));
if (sum != 0) {
- (void)printf("[bad udp cksum 0x%04x -> 0x%04x!] ",
+ ND_PRINT((ndo, "[bad udp cksum 0x%04x -> 0x%04x!] ",
udp_sum,
- in_cksum_shouldbe(udp_sum, sum));
+ in_cksum_shouldbe(udp_sum, sum)));
} else
- (void)printf("[udp sum ok] ");
+ ND_PRINT((ndo, "[udp sum ok] "));
}
}
-#ifdef INET6
else if (IP_V(ip) == 6 && ip6->ip6_plen) {
/* for IPv6, UDP checksum is mandatory */
- if (TTEST2(cp[0], length)) {
- sum = udp6_cksum(ip6, up, length + sizeof(struct udphdr));
+ if (ND_TTEST2(cp[0], length)) {
+ sum = udp6_cksum(ndo, ip6, up, length + sizeof(struct udphdr));
udp_sum = EXTRACT_16BITS(&up->uh_sum);
if (sum != 0) {
- (void)printf("[bad udp cksum 0x%04x -> 0x%04x!] ",
+ ND_PRINT((ndo, "[bad udp cksum 0x%04x -> 0x%04x!] ",
udp_sum,
- in_cksum_shouldbe(udp_sum, sum));
+ in_cksum_shouldbe(udp_sum, sum)));
} else
- (void)printf("[udp sum ok] ");
+ ND_PRINT((ndo, "[udp sum ok] "));
}
}
-#endif
}
- if (!qflag) {
-#define ISPORT(p) (dport == (p) || sport == (p))
- if (ISPORT(NAMESERVER_PORT))
- ns_print((const u_char *)(up + 1), length, 0);
- else if (ISPORT(MULTICASTDNS_PORT))
- ns_print((const u_char *)(up + 1), length, 1);
- else if (ISPORT(TIMED_PORT))
- timed_print((const u_char *)(up + 1));
- else if (ISPORT(TFTP_PORT))
- tftp_print((const u_char *)(up + 1), length);
- else if (ISPORT(IPPORT_BOOTPC) || ISPORT(IPPORT_BOOTPS))
- bootp_print((const u_char *)(up + 1), length);
- else if (ISPORT(RIP_PORT))
- rip_print((const u_char *)(up + 1), length);
- else if (ISPORT(AODV_PORT))
- aodv_print((const u_char *)(up + 1), length,
-#ifdef INET6
+ if (!ndo->ndo_qflag) {
+ if (IS_SRC_OR_DST_PORT(NAMESERVER_PORT))
+ ns_print(ndo, (const u_char *)(up + 1), length, 0);
+ else if (IS_SRC_OR_DST_PORT(MULTICASTDNS_PORT))
+ ns_print(ndo, (const u_char *)(up + 1), length, 1);
+ else if (IS_SRC_OR_DST_PORT(TIMED_PORT))
+ timed_print(ndo, (const u_char *)(up + 1));
+ else if (IS_SRC_OR_DST_PORT(TFTP_PORT))
+ tftp_print(ndo, (const u_char *)(up + 1), length);
+ else if (IS_SRC_OR_DST_PORT(BOOTPC_PORT) || IS_SRC_OR_DST_PORT(BOOTPS_PORT))
+ bootp_print(ndo, (const u_char *)(up + 1), length);
+ else if (IS_SRC_OR_DST_PORT(RIP_PORT))
+ rip_print(ndo, (const u_char *)(up + 1), length);
+ else if (IS_SRC_OR_DST_PORT(AODV_PORT))
+ aodv_print(ndo, (const u_char *)(up + 1), length,
ip6 != NULL);
-#else
- 0);
-#endif
- else if (ISPORT(ISAKMP_PORT))
- isakmp_print(gndo, (const u_char *)(up + 1), length, bp2);
- else if (ISPORT(ISAKMP_PORT_NATT))
- isakmp_rfc3948_print(gndo, (const u_char *)(up + 1), length, bp2);
+ else if (IS_SRC_OR_DST_PORT(ISAKMP_PORT))
+ isakmp_print(ndo, (const u_char *)(up + 1), length, bp2);
+ else if (IS_SRC_OR_DST_PORT(ISAKMP_PORT_NATT))
+ isakmp_rfc3948_print(ndo, (const u_char *)(up + 1), length, bp2);
#if 1 /*???*/
- else if (ISPORT(ISAKMP_PORT_USER1) || ISPORT(ISAKMP_PORT_USER2))
- isakmp_print(gndo, (const u_char *)(up + 1), length, bp2);
+ else if (IS_SRC_OR_DST_PORT(ISAKMP_PORT_USER1) || IS_SRC_OR_DST_PORT(ISAKMP_PORT_USER2))
+ isakmp_print(ndo, (const u_char *)(up + 1), length, bp2);
#endif
- else if (ISPORT(SNMP_PORT) || ISPORT(SNMPTRAP_PORT))
- snmp_print((const u_char *)(up + 1), length);
- else if (ISPORT(NTP_PORT))
- ntp_print((const u_char *)(up + 1), length);
- else if (ISPORT(KERBEROS_PORT) || ISPORT(KERBEROS_SEC_PORT))
- krb_print((const void *)(up + 1));
- else if (ISPORT(L2TP_PORT))
- l2tp_print((const u_char *)(up + 1), length);
-#ifdef TCPDUMP_DO_SMB
- else if (ISPORT(NETBIOS_NS_PORT))
- nbt_udp137_print((const u_char *)(up + 1), length);
- else if (ISPORT(NETBIOS_DGRAM_PORT))
- nbt_udp138_print((const u_char *)(up + 1), length);
+ else if (IS_SRC_OR_DST_PORT(SNMP_PORT) || IS_SRC_OR_DST_PORT(SNMPTRAP_PORT))
+ snmp_print(ndo, (const u_char *)(up + 1), length);
+ else if (IS_SRC_OR_DST_PORT(NTP_PORT))
+ ntp_print(ndo, (const u_char *)(up + 1), length);
+ else if (IS_SRC_OR_DST_PORT(KERBEROS_PORT) || IS_SRC_OR_DST_PORT(KERBEROS_SEC_PORT))
+ krb_print(ndo, (const void *)(up + 1));
+ else if (IS_SRC_OR_DST_PORT(L2TP_PORT))
+ l2tp_print(ndo, (const u_char *)(up + 1), length);
+#ifdef ENABLE_SMB
+ else if (IS_SRC_OR_DST_PORT(NETBIOS_NS_PORT))
+ nbt_udp137_print(ndo, (const u_char *)(up + 1), length);
+ else if (IS_SRC_OR_DST_PORT(NETBIOS_DGRAM_PORT))
+ nbt_udp138_print(ndo, (const u_char *)(up + 1), length);
#endif
- else if (dport == 3456)
- vat_print((const void *)(up + 1), up);
- else if (ISPORT(ZEPHYR_SRV_PORT) || ISPORT(ZEPHYR_CLT_PORT))
- zephyr_print((const void *)(up + 1), length);
+ else if (dport == VAT_PORT)
+ vat_print(ndo, (const void *)(up + 1), up);
+ else if (IS_SRC_OR_DST_PORT(ZEPHYR_SRV_PORT) || IS_SRC_OR_DST_PORT(ZEPHYR_CLT_PORT))
+ zephyr_print(ndo, (const void *)(up + 1), length);
/*
* Since there are 10 possible ports to check, I think
* a <> test would be more efficient
*/
else if ((sport >= RX_PORT_LOW && sport <= RX_PORT_HIGH) ||
(dport >= RX_PORT_LOW && dport <= RX_PORT_HIGH))
- rx_print((const void *)(up + 1), length, sport, dport,
- (u_char *) ip);
-#ifdef INET6
- else if (ISPORT(RIPNG_PORT))
- ripng_print((const u_char *)(up + 1), length);
- else if (ISPORT(DHCP6_SERV_PORT) || ISPORT(DHCP6_CLI_PORT))
- dhcp6_print((const u_char *)(up + 1), length);
- else if (ISPORT(BABEL_PORT) || ISPORT(BABEL_PORT_OLD))
- babel_print((const u_char *)(up + 1), length);
-#endif /*INET6*/
+ rx_print(ndo, (const void *)(up + 1), length, sport, dport,
+ (const u_char *) ip);
+ else if (IS_SRC_OR_DST_PORT(RIPNG_PORT))
+ ripng_print(ndo, (const u_char *)(up + 1), length);
+ else if (IS_SRC_OR_DST_PORT(DHCP6_SERV_PORT) || IS_SRC_OR_DST_PORT(DHCP6_CLI_PORT))
+ dhcp6_print(ndo, (const u_char *)(up + 1), length);
+ else if (IS_SRC_OR_DST_PORT(AHCP_PORT))
+ ahcp_print(ndo, (const u_char *)(up + 1), length);
+ else if (IS_SRC_OR_DST_PORT(BABEL_PORT) || IS_SRC_OR_DST_PORT(BABEL_PORT_OLD))
+ babel_print(ndo, (const u_char *)(up + 1), length);
+ else if (IS_SRC_OR_DST_PORT(HNCP_PORT))
+ hncp_print(ndo, (const u_char *)(up + 1), length);
/*
* Kludge in test for whiteboard packets.
*/
- else if (dport == 4567)
- wb_print((const void *)(up + 1), length);
- else if (ISPORT(CISCO_AUTORP_PORT))
- cisco_autorp_print((const void *)(up + 1), length);
- else if (ISPORT(RADIUS_PORT) ||
- ISPORT(RADIUS_NEW_PORT) ||
- ISPORT(RADIUS_ACCOUNTING_PORT) ||
- ISPORT(RADIUS_NEW_ACCOUNTING_PORT) )
- radius_print((const u_char *)(up+1), length);
+ else if (dport == WB_PORT)
+ wb_print(ndo, (const void *)(up + 1), length);
+ else if (IS_SRC_OR_DST_PORT(CISCO_AUTORP_PORT))
+ cisco_autorp_print(ndo, (const void *)(up + 1), length);
+ else if (IS_SRC_OR_DST_PORT(RADIUS_PORT) ||
+ IS_SRC_OR_DST_PORT(RADIUS_NEW_PORT) ||
+ IS_SRC_OR_DST_PORT(RADIUS_ACCOUNTING_PORT) ||
+ IS_SRC_OR_DST_PORT(RADIUS_NEW_ACCOUNTING_PORT) ||
+ IS_SRC_OR_DST_PORT(RADIUS_CISCO_COA_PORT) ||
+ IS_SRC_OR_DST_PORT(RADIUS_COA_PORT) )
+ radius_print(ndo, (const u_char *)(up+1), length);
else if (dport == HSRP_PORT)
- hsrp_print((const u_char *)(up + 1), length);
- else if (ISPORT(LWRES_PORT))
- lwres_print((const u_char *)(up + 1), length);
- else if (ISPORT(LDP_PORT))
- ldp_print((const u_char *)(up + 1), length);
- else if (ISPORT(OLSR_PORT))
- olsr_print((const u_char *)(up + 1), length,
-#if INET6
+ hsrp_print(ndo, (const u_char *)(up + 1), length);
+ else if (IS_SRC_OR_DST_PORT(LWRES_PORT))
+ lwres_print(ndo, (const u_char *)(up + 1), length);
+ else if (IS_SRC_OR_DST_PORT(LDP_PORT))
+ ldp_print(ndo, (const u_char *)(up + 1), length);
+ else if (IS_SRC_OR_DST_PORT(OLSR_PORT))
+ olsr_print(ndo, (const u_char *)(up + 1), length,
(IP_V(ip) == 6) ? 1 : 0);
-#else
- 0);
-#endif
- else if (ISPORT(MPLS_LSP_PING_PORT))
- lspping_print((const u_char *)(up + 1), length);
+ else if (IS_SRC_OR_DST_PORT(MPLS_LSP_PING_PORT))
+ lspping_print(ndo, (const u_char *)(up + 1), length);
else if (dport == BFD_CONTROL_PORT ||
dport == BFD_ECHO_PORT )
- bfd_print((const u_char *)(up+1), length, dport);
- else if (ISPORT(LMP_PORT))
- lmp_print((const u_char *)(up + 1), length);
- else if (ISPORT(VQP_PORT))
- vqp_print((const u_char *)(up + 1), length);
- else if (ISPORT(SFLOW_PORT))
- sflow_print((const u_char *)(up + 1), length);
+ bfd_print(ndo, (const u_char *)(up+1), length, dport);
+ else if (IS_SRC_OR_DST_PORT(LMP_PORT))
+ lmp_print(ndo, (const u_char *)(up + 1), length);
+ else if (IS_SRC_OR_DST_PORT(VQP_PORT))
+ vqp_print(ndo, (const u_char *)(up + 1), length);
+ else if (IS_SRC_OR_DST_PORT(SFLOW_PORT))
+ sflow_print(ndo, (const u_char *)(up + 1), length);
else if (dport == LWAPP_CONTROL_PORT)
- lwapp_control_print((const u_char *)(up + 1), length, 1);
+ lwapp_control_print(ndo, (const u_char *)(up + 1), length, 1);
else if (sport == LWAPP_CONTROL_PORT)
- lwapp_control_print((const u_char *)(up + 1), length, 0);
- else if (ISPORT(LWAPP_DATA_PORT))
- lwapp_data_print((const u_char *)(up + 1), length);
- else if (ISPORT(SIP_PORT))
- sip_print((const u_char *)(up + 1), length);
- else if (ISPORT(SYSLOG_PORT))
- syslog_print((const u_char *)(up + 1), length);
- else if (ISPORT(OTV_PORT))
- otv_print((const u_char *)(up + 1), length);
+ lwapp_control_print(ndo, (const u_char *)(up + 1), length, 0);
+ else if (IS_SRC_OR_DST_PORT(LWAPP_DATA_PORT))
+ lwapp_data_print(ndo, (const u_char *)(up + 1), length);
+ else if (IS_SRC_OR_DST_PORT(SIP_PORT))
+ sip_print(ndo, (const u_char *)(up + 1), length);
+ else if (IS_SRC_OR_DST_PORT(SYSLOG_PORT))
+ syslog_print(ndo, (const u_char *)(up + 1), length);
+ else if (IS_SRC_OR_DST_PORT(OTV_PORT))
+ otv_print(ndo, (const u_char *)(up + 1), length);
+ else if (IS_SRC_OR_DST_PORT(VXLAN_PORT))
+ vxlan_print(ndo, (const u_char *)(up + 1), length);
+ else if (IS_SRC_OR_DST_PORT(GENEVE_PORT))
+ geneve_print(ndo, (const u_char *)(up + 1), length);
+ else if (IS_SRC_OR_DST_PORT(LISP_CONTROL_PORT))
+ lisp_print(ndo, (const u_char *)(up + 1), length);
+ else if (IS_SRC_OR_DST_PORT(VXLAN_GPE_PORT))
+ vxlan_gpe_print(ndo, (const u_char *)(up + 1), length);
+ else if (ND_TTEST(((const struct LAP *)cp)->type) &&
+ ((const struct LAP *)cp)->type == lapDDP &&
+ (atalk_port(sport) || atalk_port(dport))) {
+ if (ndo->ndo_vflag)
+ ND_PRINT((ndo, "kip "));
+ llap_print(ndo, cp, length);
+ } else {
+ if (ulen > length)
+ ND_PRINT((ndo, "UDP, bad length %u > %u",
+ ulen, length));
+ else
+ ND_PRINT((ndo, "UDP, length %u", ulen));
+ }
+ } else {
+ if (ulen > length)
+ ND_PRINT((ndo, "UDP, bad length %u > %u",
+ ulen, length));
else
- (void)printf("UDP, length %u",
- (u_int32_t)(ulen - sizeof(*up)));
-#undef ISPORT
- } else
- (void)printf("UDP, length %u", (u_int32_t)(ulen - sizeof(*up)));
+ ND_PRINT((ndo, "UDP, length %u", ulen));
+ }
+ return;
+
+trunc:
+ ND_PRINT((ndo, "%s", udp_tstr));
}
@@ -691,3 +723,6 @@ udp_print(register const u_char *bp, u_int length,
* c-basic-offset: 8
* End:
*/
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-udp-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-usb.c b/freebsd/contrib/tcpdump/print-usb.c
index 393b66b5..06e4dc4a 100644
--- a/freebsd/contrib/tcpdump/print-usb.c
+++ b/freebsd/contrib/tcpdump/print-usb.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright 2009 Bert Vermeulen <bert@biot.com>
*
@@ -21,22 +24,22 @@
*
*/
+/* \summary: USB printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include <pcap.h>
-#include <stdio.h>
-#include <string.h>
-
-#include "interface.h"
+#include "netdissect.h"
#if defined(HAVE_PCAP_USB_H) && defined(DLT_USB_LINUX)
#include <pcap/usb.h>
+static const char tstr[] = "[|usb]";
+
/* returns direction: 1=inbound 2=outbound -1=invalid */
static int
get_direction(int transfer_type, int event_type)
@@ -83,49 +86,49 @@ get_direction(int transfer_type, int event_type)
}
static void
-usb_header_print(const pcap_usb_header *uh)
+usb_header_print(netdissect_options *ndo, const pcap_usb_header *uh)
{
int direction;
switch(uh->transfer_type)
{
case URB_ISOCHRONOUS:
- printf("ISOCHRONOUS");
+ ND_PRINT((ndo, "ISOCHRONOUS"));
break;
case URB_INTERRUPT:
- printf("INTERRUPT");
+ ND_PRINT((ndo, "INTERRUPT"));
break;
case URB_CONTROL:
- printf("CONTROL");
+ ND_PRINT((ndo, "CONTROL"));
break;
case URB_BULK:
- printf("BULK");
+ ND_PRINT((ndo, "BULK"));
break;
default:
- printf(" ?");
+ ND_PRINT((ndo, " ?"));
}
switch(uh->event_type)
{
case URB_SUBMIT:
- printf(" SUBMIT");
+ ND_PRINT((ndo, " SUBMIT"));
break;
case URB_COMPLETE:
- printf(" COMPLETE");
+ ND_PRINT((ndo, " COMPLETE"));
break;
case URB_ERROR:
- printf(" ERROR");
+ ND_PRINT((ndo, " ERROR"));
break;
default:
- printf(" ?");
+ ND_PRINT((ndo, " ?"));
}
direction = get_direction(uh->transfer_type, uh->event_type);
if(direction == 1)
- printf(" from");
+ ND_PRINT((ndo, " from"));
else if(direction == 2)
- printf(" to");
- printf(" %d:%d:%d", uh->bus_id, uh->device_address, uh->endpoint_number & 0x7f);
+ ND_PRINT((ndo, " to"));
+ ND_PRINT((ndo, " %d:%d:%d", uh->bus_id, uh->device_address, uh->endpoint_number & 0x7f));
}
/*
@@ -137,14 +140,15 @@ usb_header_print(const pcap_usb_header *uh)
* is the number of bytes actually captured.
*/
u_int
-usb_linux_48_byte_print(const struct pcap_pkthdr *h, register const u_char *p)
+usb_linux_48_byte_print(netdissect_options *ndo, const struct pcap_pkthdr *h,
+ register const u_char *p)
{
if (h->caplen < sizeof(pcap_usb_header)) {
- printf("[|usb]");
+ ND_PRINT((ndo, "%s", tstr));
return(sizeof(pcap_usb_header));
}
- usb_header_print((const pcap_usb_header *) p);
+ usb_header_print(ndo, (const pcap_usb_header *) p);
return(sizeof(pcap_usb_header));
}
@@ -159,14 +163,15 @@ usb_linux_48_byte_print(const struct pcap_pkthdr *h, register const u_char *p)
* is the number of bytes actually captured.
*/
u_int
-usb_linux_64_byte_print(const struct pcap_pkthdr *h, register const u_char *p)
+usb_linux_64_byte_print(netdissect_options *ndo, const struct pcap_pkthdr *h,
+ register const u_char *p)
{
if (h->caplen < sizeof(pcap_usb_header_mmapped)) {
- printf("[|usb]");
+ ND_PRINT((ndo, "%s", tstr));
return(sizeof(pcap_usb_header_mmapped));
}
- usb_header_print((const pcap_usb_header *) p);
+ usb_header_print(ndo, (const pcap_usb_header *) p);
return(sizeof(pcap_usb_header_mmapped));
}
@@ -174,3 +179,6 @@ usb_linux_64_byte_print(const struct pcap_pkthdr *h, register const u_char *p)
#endif /* defined(HAVE_PCAP_USB_H) && defined(DLT_USB_LINUX) */
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-usb-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-vjc.c b/freebsd/contrib/tcpdump/print-vjc.c
index 05f3d3ea..1319efb3 100644
--- a/freebsd/contrib/tcpdump/print-vjc.c
+++ b/freebsd/contrib/tcpdump/print-vjc.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
@@ -21,23 +24,17 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
+/* \summary: PPP Van Jacobson compression printer */
+
+/* specification: RFC 1144 */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-vjc.c,v 1.15 2004-03-25 03:31:17 mcr Exp $ (LBL)";
-#endif
-
-#include <tcpdump-stdinc.h>
-
-#include <pcap.h>
-#include <stdio.h>
-
-#include "interface.h"
-#include "addrtoname.h"
+#include <netdissect-stdinc.h>
+#include "netdissect.h"
#include "slcompress.h"
#include "ppp.h"
@@ -82,40 +79,50 @@ static const char rcsid[] _U_ =
* We therefore leave "proto" - which is the PPP protocol type - in place,
* *not* marked as unused, for now, so that GCC warnings about the
* unused argument remind us that we should fix this some day.
+ *
+ * XXX - also, it fetches the TCP checksum field in COMPRESSED_TCP
+ * packets directly, rather than with EXTRACT_16BITS(); RFC 1144 says
+ * it's "the unmodified TCP checksum", which would imply that it's
+ * big-endian, but perhaps, on the platform where this was developed,
+ * the packets were munged by the networking stack before being handed
+ * to the packet capture mechanism.
*/
int
-vjc_print(register const char *bp, u_short proto _U_)
+vjc_print(netdissect_options *ndo, register const char *bp, u_short proto _U_)
{
int i;
switch (bp[0] & 0xf0) {
case TYPE_IP:
- if (eflag)
- printf("(vjc type=IP) ");
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, "(vjc type=IP) "));
return PPP_IP;
case TYPE_UNCOMPRESSED_TCP:
- if (eflag)
- printf("(vjc type=raw TCP) ");
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, "(vjc type=raw TCP) "));
return PPP_IP;
case TYPE_COMPRESSED_TCP:
- if (eflag)
- printf("(vjc type=compressed TCP) ");
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, "(vjc type=compressed TCP) "));
for (i = 0; i < 8; i++) {
if (bp[1] & (0x80 >> i))
- printf("%c", "?CI?SAWU"[i]);
+ ND_PRINT((ndo, "%c", "?CI?SAWU"[i]));
}
if (bp[1])
- printf(" ");
- printf("C=0x%02x ", bp[2]);
- printf("sum=0x%04x ", *(u_short *)&bp[3]);
+ ND_PRINT((ndo, " "));
+ ND_PRINT((ndo, "C=0x%02x ", bp[2]));
+ ND_PRINT((ndo, "sum=0x%04x ", *(const u_short *)&bp[3]));
return -1;
case TYPE_ERROR:
- if (eflag)
- printf("(vjc type=error) ");
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, "(vjc type=error) "));
return -1;
default:
- if (eflag)
- printf("(vjc type=0x%02x) ", bp[0] & 0xf0);
+ if (ndo->ndo_eflag)
+ ND_PRINT((ndo, "(vjc type=0x%02x) ", bp[0] & 0xf0));
return -1;
}
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-vjc-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-vqp.c b/freebsd/contrib/tcpdump/print-vqp.c
index 4dcc385c..aafaaf79 100644
--- a/freebsd/contrib/tcpdump/print-vqp.c
+++ b/freebsd/contrib/tcpdump/print-vqp.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1998-2006 The TCPDUMP project
*
@@ -14,27 +17,18 @@
* LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE.
*
- * support for the Cisco prop. VQP Protocol
- *
* Original code by Carles Kishimoto <Carles.Kishimoto@bsc.es>
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-vqp.c,v 1.3 2006-08-19 06:51:13 guy Exp $";
-#endif
+/* \summary: Cisco VLAN Query Protocol (VQP) printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
#include "addrtoname.h"
@@ -54,16 +48,16 @@ static const char rcsid[] _U_ =
*/
struct vqp_common_header_t {
- u_int8_t version;
- u_int8_t msg_type;
- u_int8_t error_code;
- u_int8_t nitems;
- u_int8_t sequence[4];
+ uint8_t version;
+ uint8_t msg_type;
+ uint8_t error_code;
+ uint8_t nitems;
+ uint8_t sequence[4];
};
struct vqp_obj_tlv_t {
- u_int8_t obj_type[4];
- u_int8_t obj_length[2];
+ uint8_t obj_type[4];
+ uint8_t obj_length[2];
};
#define VQP_OBJ_REQ_JOIN_PORT 0x01
@@ -108,52 +102,52 @@ static const struct tok vqp_obj_values[] = {
};
void
-vqp_print(register const u_char *pptr, register u_int len)
+vqp_print(netdissect_options *ndo, register const u_char *pptr, register u_int len)
{
const struct vqp_common_header_t *vqp_common_header;
const struct vqp_obj_tlv_t *vqp_obj_tlv;
const u_char *tptr;
- u_int16_t vqp_obj_len;
- u_int32_t vqp_obj_type;
+ uint16_t vqp_obj_len;
+ uint32_t vqp_obj_type;
int tlen;
- u_int8_t nitems;
+ uint8_t nitems;
tptr=pptr;
tlen = len;
vqp_common_header = (const struct vqp_common_header_t *)pptr;
- TCHECK(*vqp_common_header);
+ ND_TCHECK(*vqp_common_header);
/*
* Sanity checking of the header.
*/
if (VQP_EXTRACT_VERSION(vqp_common_header->version) != VQP_VERSION) {
- printf("VQP version %u packet not supported",
- VQP_EXTRACT_VERSION(vqp_common_header->version));
+ ND_PRINT((ndo, "VQP version %u packet not supported",
+ VQP_EXTRACT_VERSION(vqp_common_header->version)));
return;
}
/* in non-verbose mode just lets print the basic Message Type */
- if (vflag < 1) {
- printf("VQPv%u %s Message, error-code %s (%u), length %u",
+ if (ndo->ndo_vflag < 1) {
+ ND_PRINT((ndo, "VQPv%u %s Message, error-code %s (%u), length %u",
VQP_EXTRACT_VERSION(vqp_common_header->version),
tok2str(vqp_msg_type_values, "unknown (%u)",vqp_common_header->msg_type),
tok2str(vqp_error_code_values, "unknown (%u)",vqp_common_header->error_code),
vqp_common_header->error_code,
- len);
+ len));
return;
}
-
+
/* ok they seem to want to know everything - lets fully decode it */
nitems = vqp_common_header->nitems;
- printf("\n\tVQPv%u, %s Message, error-code %s (%u), seq 0x%08x, items %u, length %u",
+ ND_PRINT((ndo, "\n\tVQPv%u, %s Message, error-code %s (%u), seq 0x%08x, items %u, length %u",
VQP_EXTRACT_VERSION(vqp_common_header->version),
tok2str(vqp_msg_type_values, "unknown (%u)",vqp_common_header->msg_type),
tok2str(vqp_error_code_values, "unknown (%u)",vqp_common_header->error_code),
vqp_common_header->error_code,
EXTRACT_32BITS(&vqp_common_header->sequence),
nitems,
- len);
+ len));
/* skip VQP Common header */
tptr+=sizeof(const struct vqp_common_header_t);
@@ -167,9 +161,9 @@ vqp_print(register const u_char *pptr, register u_int len)
tptr+=sizeof(struct vqp_obj_tlv_t);
tlen-=sizeof(struct vqp_obj_tlv_t);
- printf("\n\t %s Object (0x%08x), length %u, value: ",
+ ND_PRINT((ndo, "\n\t %s Object (0x%08x), length %u, value: ",
tok2str(vqp_obj_values, "Unknown", vqp_obj_type),
- vqp_obj_type, vqp_obj_len);
+ vqp_obj_type, vqp_obj_len));
/* basic sanity check */
if (vqp_obj_type == 0 || vqp_obj_len ==0) {
@@ -177,28 +171,27 @@ vqp_print(register const u_char *pptr, register u_int len)
}
/* did we capture enough for fully decoding the object ? */
- if (!TTEST2(*tptr, vqp_obj_len))
- goto trunc;
+ ND_TCHECK2(*tptr, vqp_obj_len);
switch(vqp_obj_type) {
case VQP_OBJ_IP_ADDRESS:
- printf("%s (0x%08x)", ipaddr_string(tptr), EXTRACT_32BITS(tptr));
+ ND_PRINT((ndo, "%s (0x%08x)", ipaddr_string(ndo, tptr), EXTRACT_32BITS(tptr)));
break;
/* those objects have similar semantics - fall through */
case VQP_OBJ_PORT_NAME:
case VQP_OBJ_VLAN_NAME:
case VQP_OBJ_VTP_DOMAIN:
case VQP_OBJ_ETHERNET_PKT:
- safeputs((const char *)tptr, vqp_obj_len);
+ safeputs(ndo, tptr, vqp_obj_len);
break;
/* those objects have similar semantics - fall through */
case VQP_OBJ_MAC_ADDRESS:
case VQP_OBJ_MAC_NULL:
- printf("%s", etheraddr_string(tptr));
+ ND_PRINT((ndo, "%s", etheraddr_string(ndo, tptr)));
break;
default:
- if (vflag <= 1)
- print_unknown_data(tptr, "\n\t ", vqp_obj_len);
+ if (ndo->ndo_vflag <= 1)
+ print_unknown_data(ndo,tptr, "\n\t ", vqp_obj_len);
break;
}
tptr += vqp_obj_len;
@@ -207,5 +200,8 @@ vqp_print(register const u_char *pptr, register u_int len)
}
return;
trunc:
- printf("\n\t[|VQP]");
+ ND_PRINT((ndo, "\n\t[|VQP]"));
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-vqp-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-vrrp.c b/freebsd/contrib/tcpdump/print-vrrp.c
index dcc7dfaa..d08b3b70 100644
--- a/freebsd/contrib/tcpdump/print-vrrp.c
+++ b/freebsd/contrib/tcpdump/print-vrrp.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 2000 William C. Fenner.
* All rights reserved.
@@ -25,26 +28,23 @@
* FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-vrrp.c,v 1.10 2005-05-06 07:56:54 guy Exp $";
-#endif
+/* \summary: Virtual Router Redundancy Protocol (VRRP) printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
-
-#include <stdio.h>
-#include <stdlib.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
#include "addrtoname.h"
+#include "ip.h"
+#include "ipproto.h"
/*
- * RFC 2338:
+ * RFC 2338 (VRRP v2):
+ *
* 0 1 2 3
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
@@ -64,6 +64,27 @@ static const char rcsid[] _U_ =
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Authentication Data (2) |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *
+ *
+ * RFC 5798 (VRRP v3):
+ *
+ * 0 1 2 3
+ * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | IPv4 Fields or IPv6 Fields |
+ * ... ...
+ * | |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * |Version| Type | Virtual Rtr ID| Priority |Count IPvX Addr|
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * |(rsvd) | Max Adver Int | Checksum |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | |
+ * + +
+ * | IPvX Address(es) |
+ * + +
+ * | |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
/* Type */
@@ -87,63 +108,84 @@ static const struct tok auth2str[] = {
};
void
-vrrp_print(register const u_char *bp, register u_int len, int ttl)
+vrrp_print(netdissect_options *ndo,
+ register const u_char *bp, register u_int len,
+ register const u_char *bp2, int ttl)
{
- int version, type, auth_type;
+ int version, type, auth_type = VRRP_AUTH_NONE; /* keep compiler happy */
const char *type_s;
- TCHECK(bp[0]);
+ ND_TCHECK(bp[0]);
version = (bp[0] & 0xf0) >> 4;
type = bp[0] & 0x0f;
type_s = tok2str(type2str, "unknown type (%u)", type);
- printf("VRRPv%u, %s", version, type_s);
+ ND_PRINT((ndo, "VRRPv%u, %s", version, type_s));
if (ttl != 255)
- printf(", (ttl %u)", ttl);
- if (version != 2 || type != VRRP_TYPE_ADVERTISEMENT)
+ ND_PRINT((ndo, ", (ttl %u)", ttl));
+ if (version < 2 || version > 3 || type != VRRP_TYPE_ADVERTISEMENT)
return;
- TCHECK(bp[2]);
- printf(", vrid %u, prio %u", bp[1], bp[2]);
- TCHECK(bp[5]);
- auth_type = bp[4];
- printf(", authtype %s", tok2str(auth2str, NULL, auth_type));
- printf(", intvl %us, length %u", bp[5],len);
- if (vflag) {
+ ND_TCHECK(bp[2]);
+ ND_PRINT((ndo, ", vrid %u, prio %u", bp[1], bp[2]));
+ ND_TCHECK(bp[5]);
+
+ if (version == 2) {
+ auth_type = bp[4];
+ ND_PRINT((ndo, ", authtype %s", tok2str(auth2str, NULL, auth_type)));
+ ND_PRINT((ndo, ", intvl %us, length %u", bp[5], len));
+ } else { /* version == 3 */
+ uint16_t intvl = (bp[4] & 0x0f) << 8 | bp[5];
+ ND_PRINT((ndo, ", intvl %ucs, length %u", intvl, len));
+ }
+
+ if (ndo->ndo_vflag) {
int naddrs = bp[3];
int i;
char c;
- if (TTEST2(bp[0], len)) {
+ if (version == 2 && ND_TTEST2(bp[0], len)) {
struct cksum_vec vec[1];
vec[0].ptr = bp;
vec[0].len = len;
if (in_cksum(vec, 1))
- printf(", (bad vrrp cksum %x)",
- EXTRACT_16BITS(&bp[6]));
+ ND_PRINT((ndo, ", (bad vrrp cksum %x)",
+ EXTRACT_16BITS(&bp[6])));
+ }
+
+ if (version == 3 && ND_TTEST2(bp[0], len)) {
+ uint16_t cksum = nextproto4_cksum(ndo, (const struct ip *)bp2, bp,
+ len, len, IPPROTO_VRRP);
+ if (cksum)
+ ND_PRINT((ndo, ", (bad vrrp cksum %x)",
+ EXTRACT_16BITS(&bp[6])));
}
- printf(", addrs");
+
+ ND_PRINT((ndo, ", addrs"));
if (naddrs > 1)
- printf("(%d)", naddrs);
- printf(":");
+ ND_PRINT((ndo, "(%d)", naddrs));
+ ND_PRINT((ndo, ":"));
c = ' ';
bp += 8;
for (i = 0; i < naddrs; i++) {
- TCHECK(bp[3]);
- printf("%c%s", c, ipaddr_string(bp));
+ ND_TCHECK(bp[3]);
+ ND_PRINT((ndo, "%c%s", c, ipaddr_string(ndo, bp)));
c = ',';
bp += 4;
}
- if (auth_type == VRRP_AUTH_SIMPLE) { /* simple text password */
- TCHECK(bp[7]);
- printf(" auth \"");
- if (fn_printn(bp, 8, snapend)) {
- printf("\"");
+ if (version == 2 && auth_type == VRRP_AUTH_SIMPLE) { /* simple text password */
+ ND_TCHECK(bp[7]);
+ ND_PRINT((ndo, " auth \""));
+ if (fn_printn(ndo, bp, 8, ndo->ndo_snapend)) {
+ ND_PRINT((ndo, "\""));
goto trunc;
}
- printf("\"");
+ ND_PRINT((ndo, "\""));
}
}
return;
trunc:
- printf("[|vrrp]");
+ ND_PRINT((ndo, "[|vrrp]"));
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-vrrp-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-vtp.c b/freebsd/contrib/tcpdump/print-vtp.c
index 47afa101..4b27b68f 100644
--- a/freebsd/contrib/tcpdump/print-vtp.c
+++ b/freebsd/contrib/tcpdump/print-vtp.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1998-2007 The TCPDUMP project
*
@@ -14,29 +17,25 @@
* LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE.
*
- * VLAN TRUNKING PROTOCOL (VTP)
- *
* Reference documentation:
- * http://www.cisco.com/en/US/tech/tk389/tk689/technologies_tech_note09186a0080094c52.shtml
- * http://www.cisco.com/warp/public/473/21.html
+ * http://www.cisco.com/en/US/tech/tk389/tk689/technologies_tech_note09186a0080094c52.shtml
+ * http://www.cisco.com/warp/public/473/21.html
* http://www.cisco.com/univercd/cc/td/doc/product/lan/trsrb/frames.htm
*
* Original code ode by Carles Kishimoto <carles.kishimoto@gmail.com>
*/
+/* \summary: Cisco VLAN Trunking Protocol (VTP) printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include <stdio.h>
-#include <string.h>
-
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
-#include "extract.h"
-#include "nlpid.h"
+#include "extract.h"
#define VTP_HEADER_LEN 36
#define VTP_DOMAIN_NAME_LEN 32
@@ -50,16 +49,16 @@
#define VTP_JOIN_MESSAGE 0x04
struct vtp_vlan_ {
- u_int8_t len;
- u_int8_t status;
- u_int8_t type;
- u_int8_t name_len;
- u_int16_t vlanid;
- u_int16_t mtu;
- u_int32_t index;
+ uint8_t len;
+ uint8_t status;
+ uint8_t type;
+ uint8_t name_len;
+ uint16_t vlanid;
+ uint16_t mtu;
+ uint32_t index;
};
-static struct tok vtp_message_type_values[] = {
+static const struct tok vtp_message_type_values[] = {
{ VTP_SUMMARY_ADV, "Summary advertisement"},
{ VTP_SUBSET_ADV, "Subset advertisement"},
{ VTP_ADV_REQUEST, "Advertisement request"},
@@ -67,7 +66,7 @@ static struct tok vtp_message_type_values[] = {
{ 0, NULL }
};
-static struct tok vtp_header_values[] = {
+static const struct tok vtp_header_values[] = {
{ 0x01, "Followers"}, /* On Summary advertisement, 3rd byte is Followers */
{ 0x02, "Seq number"}, /* On Subset advertisement, 3rd byte is Sequence number */
{ 0x03, "Rsvd"}, /* On Adver. requests 3rd byte is Rsvd */
@@ -75,7 +74,7 @@ static struct tok vtp_header_values[] = {
{ 0, NULL }
};
-static struct tok vtp_vlan_type_values[] = {
+static const struct tok vtp_vlan_type_values[] = {
{ 0x01, "Ethernet"},
{ 0x02, "FDDI"},
{ 0x03, "TrCRF"},
@@ -84,7 +83,7 @@ static struct tok vtp_vlan_type_values[] = {
{ 0, NULL }
};
-static struct tok vtp_vlan_status[] = {
+static const struct tok vtp_vlan_status[] = {
{ 0x00, "Operational"},
{ 0x01, "Suspended"},
{ 0, NULL }
@@ -101,7 +100,7 @@ static struct tok vtp_vlan_status[] = {
#define VTP_VLAN_STE_HOP_COUNT 0x09
#define VTP_VLAN_BACKUP_CRF_MODE 0x0A
-static struct tok vtp_vlan_tlv_values[] = {
+static const struct tok vtp_vlan_tlv_values[] = {
{ VTP_VLAN_SOURCE_ROUTING_RING_NUMBER, "Source-Routing Ring Number TLV"},
{ VTP_VLAN_SOURCE_ROUTING_BRIDGE_NUMBER, "Source-Routing Bridge Number TLV"},
{ VTP_VLAN_STP_TYPE, "STP type TLV"},
@@ -115,7 +114,7 @@ static struct tok vtp_vlan_tlv_values[] = {
{ 0, NULL }
};
-static struct tok vtp_stp_type_values[] = {
+static const struct tok vtp_stp_type_values[] = {
{ 1, "SRT"},
{ 2, "SRB"},
{ 3, "Auto"},
@@ -123,37 +122,43 @@ static struct tok vtp_stp_type_values[] = {
};
void
-vtp_print (const u_char *pptr, u_int length)
+vtp_print (netdissect_options *ndo,
+ const u_char *pptr, u_int length)
{
- int type, len, tlv_len, tlv_value;
+ int type, len, tlv_len, tlv_value, mgmtd_len;
const u_char *tptr;
const struct vtp_vlan_ *vtp_vlan;
if (length < VTP_HEADER_LEN)
goto trunc;
- tptr = pptr;
+ tptr = pptr;
- if (!TTEST2(*tptr, VTP_HEADER_LEN))
- goto trunc;
+ ND_TCHECK2(*tptr, VTP_HEADER_LEN);
type = *(tptr+1);
- printf("VTPv%u, Message %s (0x%02x), length %u",
- *tptr,
+ ND_PRINT((ndo, "VTPv%u, Message %s (0x%02x), length %u",
+ *tptr,
tok2str(vtp_message_type_values,"Unknown message type", type),
- *(tptr+1),
- length);
+ type,
+ length));
/* In non-verbose mode, just print version and message type */
- if (vflag < 1) {
+ if (ndo->ndo_vflag < 1) {
return;
}
/* verbose mode print all fields */
- printf("\n\tDomain name: %s, %s: %u",
- (tptr+4),
- tok2str(vtp_header_values,"Unknown",*(tptr+1)),
- *(tptr+2));
+ ND_PRINT((ndo, "\n\tDomain name: "));
+ mgmtd_len = *(tptr + 3);
+ if (mgmtd_len < 1 || mgmtd_len > 32) {
+ ND_PRINT((ndo, " [invalid MgmtD Len %d]", mgmtd_len));
+ return;
+ }
+ fn_printzp(ndo, tptr + 4, mgmtd_len, NULL);
+ ND_PRINT((ndo, ", %s: %u",
+ tok2str(vtp_header_values, "Unknown", type),
+ *(tptr+2)));
tptr += VTP_HEADER_LEN;
@@ -166,9 +171,9 @@ vtp_print (const u_char *pptr, u_int length)
*
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Version | Code | Followers | MmgtD Len |
+ * | Version | Code | Followers | MgmtD Len |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Management Domain Name |
+ * | Management Domain Name (zero-padded to 32 bytes) |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Configuration revision number |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
@@ -178,23 +183,26 @@ vtp_print (const u_char *pptr, u_int length)
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | MD5 digest (16 bytes) |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- *
+ *
*/
- printf("\n\t Config Rev %x, Updater %s",
+ ND_TCHECK2(*tptr, 8);
+ ND_PRINT((ndo, "\n\t Config Rev %x, Updater %s",
EXTRACT_32BITS(tptr),
- ipaddr_string(tptr+4));
- tptr += 8;
- printf(", Timestamp 0x%08x 0x%08x 0x%08x",
+ ipaddr_string(ndo, tptr+4)));
+ tptr += 8;
+ ND_TCHECK2(*tptr, VTP_UPDATE_TIMESTAMP_LEN);
+ ND_PRINT((ndo, ", Timestamp 0x%08x 0x%08x 0x%08x",
EXTRACT_32BITS(tptr),
EXTRACT_32BITS(tptr + 4),
- EXTRACT_32BITS(tptr + 8));
+ EXTRACT_32BITS(tptr + 8)));
tptr += VTP_UPDATE_TIMESTAMP_LEN;
- printf(", MD5 digest: %08x%08x%08x%08x",
+ ND_TCHECK2(*tptr, VTP_MD5_DIGEST_LEN);
+ ND_PRINT((ndo, ", MD5 digest: %08x%08x%08x%08x",
EXTRACT_32BITS(tptr),
EXTRACT_32BITS(tptr + 4),
EXTRACT_32BITS(tptr + 8),
- EXTRACT_32BITS(tptr + 12));
+ EXTRACT_32BITS(tptr + 12)));
tptr += VTP_MD5_DIGEST_LEN;
break;
@@ -205,9 +213,9 @@ vtp_print (const u_char *pptr, u_int length)
*
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Version | Code | Seq number | MmgtD Len |
+ * | Version | Code | Seq number | MgmtD Len |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Management Domain Name |
+ * | Management Domain Name (zero-padded to 32 bytes) |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Configuration revision number |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
@@ -217,12 +225,12 @@ vtp_print (const u_char *pptr, u_int length)
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | VLAN info field N |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- *
+ *
*/
- printf(", Config Rev %x", EXTRACT_32BITS(tptr));
+ ND_PRINT((ndo, ", Config Rev %x", EXTRACT_32BITS(tptr)));
- /*
+ /*
* VLAN INFORMATION
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
@@ -244,17 +252,17 @@ vtp_print (const u_char *pptr, u_int length)
if (len == 0)
break;
- if (!TTEST2(*tptr, len))
- goto trunc;
+ ND_TCHECK2(*tptr, len);
- vtp_vlan = (struct vtp_vlan_*)tptr;
- printf("\n\tVLAN info status %s, type %s, VLAN-id %u, MTU %u, SAID 0x%08x, Name %s",
+ vtp_vlan = (const struct vtp_vlan_*)tptr;
+ ND_TCHECK(*vtp_vlan);
+ ND_PRINT((ndo, "\n\tVLAN info status %s, type %s, VLAN-id %u, MTU %u, SAID 0x%08x, Name ",
tok2str(vtp_vlan_status,"Unknown",vtp_vlan->status),
tok2str(vtp_vlan_type_values,"Unknown",vtp_vlan->type),
EXTRACT_16BITS(&vtp_vlan->vlanid),
EXTRACT_16BITS(&vtp_vlan->mtu),
- EXTRACT_32BITS(&vtp_vlan->index),
- (tptr + VTP_VLAN_INFO_OFFSET));
+ EXTRACT_32BITS(&vtp_vlan->index)));
+ fn_printzp(ndo, tptr + VTP_VLAN_INFO_OFFSET, vtp_vlan->name_len, NULL);
/*
* Vlan names are aligned to 32-bit boundaries.
@@ -266,16 +274,16 @@ vtp_print (const u_char *pptr, u_int length)
while (len > 0) {
- /*
+ /*
* Cisco specs says 2 bytes for type + 2 bytes for length, take only 1
- * See: http://www.cisco.com/univercd/cc/td/doc/product/lan/trsrb/frames.htm
+ * See: http://www.cisco.com/univercd/cc/td/doc/product/lan/trsrb/frames.htm
*/
type = *tptr;
tlv_len = *(tptr+1);
- printf("\n\t\t%s (0x%04x) TLV",
+ ND_PRINT((ndo, "\n\t\t%s (0x%04x) TLV",
tok2str(vtp_vlan_tlv_values, "Unknown", type),
- type);
+ type));
/*
* infinite loop check
@@ -284,38 +292,37 @@ vtp_print (const u_char *pptr, u_int length)
return;
}
- if (!TTEST2(*tptr, tlv_len*2 +2))
- goto trunc;
+ ND_TCHECK2(*tptr, tlv_len * 2 +2);
tlv_value = EXTRACT_16BITS(tptr+2);
switch (type) {
case VTP_VLAN_STE_HOP_COUNT:
- printf(", %u", tlv_value);
+ ND_PRINT((ndo, ", %u", tlv_value));
break;
case VTP_VLAN_PRUNING:
- printf(", %s (%u)",
+ ND_PRINT((ndo, ", %s (%u)",
tlv_value == 1 ? "Enabled" : "Disabled",
- tlv_value);
+ tlv_value));
break;
case VTP_VLAN_STP_TYPE:
- printf(", %s (%u)",
+ ND_PRINT((ndo, ", %s (%u)",
tok2str(vtp_stp_type_values, "Unknown", tlv_value),
- tlv_value);
+ tlv_value));
break;
case VTP_VLAN_BRIDGE_TYPE:
- printf(", %s (%u)",
+ ND_PRINT((ndo, ", %s (%u)",
tlv_value == 1 ? "SRB" : "SRT",
- tlv_value);
+ tlv_value));
break;
case VTP_VLAN_BACKUP_CRF_MODE:
- printf(", %s (%u)",
+ ND_PRINT((ndo, ", %s (%u)",
tlv_value == 1 ? "Backup" : "Not backup",
- tlv_value);
+ tlv_value));
break;
/*
@@ -329,7 +336,7 @@ vtp_print (const u_char *pptr, u_int length)
case VTP_VLAN_TRANS_BRIDGED_VLAN:
case VTP_VLAN_ARP_HOP_COUNT:
default:
- print_unknown_data(tptr, "\n\t\t ", 2 + tlv_len*2);
+ print_unknown_data(ndo, tptr, "\n\t\t ", 2 + tlv_len*2);
break;
}
len -= 2 + tlv_len*2;
@@ -345,16 +352,17 @@ vtp_print (const u_char *pptr, u_int length)
*
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Version | Code | Reserved | MmgtD Len |
+ * | Version | Code | Reserved | MgmtD Len |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Management Domain Name |
+ * | Management Domain Name (zero-padded to 32 bytes) |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Start value |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*
*/
- printf("\n\tStart value: %u", EXTRACT_32BITS(tptr));
+ ND_TCHECK2(*tptr, 4);
+ ND_PRINT((ndo, "\n\tStart value: %u", EXTRACT_32BITS(tptr)));
break;
case VTP_JOIN_MESSAGE:
@@ -369,7 +377,7 @@ vtp_print (const u_char *pptr, u_int length)
return;
trunc:
- printf("[|vtp]");
+ ND_PRINT((ndo, "[|vtp]"));
}
/*
@@ -378,3 +386,6 @@ vtp_print (const u_char *pptr, u_int length)
* c-basic-offset: 4
* End:
*/
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-vtp-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-vxlan-gpe.c b/freebsd/contrib/tcpdump/print-vxlan-gpe.c
new file mode 100644
index 00000000..7f16aa29
--- /dev/null
+++ b/freebsd/contrib/tcpdump/print-vxlan-gpe.c
@@ -0,0 +1,121 @@
+#include <machine/rtems-bsd-user-space.h>
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
+/* Copyright (c) 2015, bugyo
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT OWNER 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: Generic Protocol Extension for VXLAN (VXLAN GPE) printer */
+
+/* specification: draft-ietf-nvo3-vxlan-gpe-01 */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <netdissect-stdinc.h>
+
+#include "netdissect.h"
+#include "extract.h"
+
+static const char tstr[] = " [|VXLAN-GPE]";
+static const struct tok vxlan_gpe_flags [] = {
+ { 0x08, "I" },
+ { 0x04, "P" },
+ { 0x01, "O" },
+ { 0, NULL }
+};
+
+#define VXLAN_GPE_HDR_LEN 8
+
+/*
+ * VXLAN GPE header, draft-ietf-nvo3-vxlan-gpe-01
+ * Generic Protocol Extension for VXLAN
+ *
+ * 0 1 2 3
+ * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * |R|R|Ver|I|P|R|O| Reserved |Next Protocol |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | VXLAN Network Identifier (VNI) | Reserved |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+
+void
+vxlan_gpe_print(netdissect_options *ndo, const u_char *bp, u_int len)
+{
+ uint8_t flags;
+ uint8_t next_protocol;
+ uint32_t vni;
+
+ if (len < VXLAN_GPE_HDR_LEN)
+ goto trunc;
+
+ ND_TCHECK2(*bp, VXLAN_GPE_HDR_LEN);
+
+ flags = *bp;
+ bp += 3;
+
+ next_protocol = *bp;
+ bp += 1;
+
+ vni = EXTRACT_24BITS(bp);
+ bp += 4;
+
+ ND_PRINT((ndo, "VXLAN-GPE, "));
+ ND_PRINT((ndo, "flags [%s], ",
+ bittok2str_nosep(vxlan_gpe_flags, "none", flags)));
+ ND_PRINT((ndo, "vni %u", vni));
+ ND_PRINT((ndo, ndo->ndo_vflag ? "\n " : ": "));
+
+ switch (next_protocol) {
+ case 0x1:
+ ip_print(ndo, bp, len - 8);
+ break;
+ case 0x2:
+ ip6_print(ndo, bp, len - 8);
+ break;
+ case 0x3:
+ ether_print(ndo, bp, len - 8, ndo->ndo_snapend - bp, NULL, NULL);
+ break;
+ case 0x4:
+ nsh_print(ndo, bp, len - 8);
+ break;
+ case 0x5:
+ mpls_print(ndo, bp, len - 8);
+ break;
+ default:
+ ND_PRINT((ndo, "ERROR: unknown-next-protocol"));
+ return;
+ }
+
+ return;
+
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+}
+
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-vxlan-gpe-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-vxlan.c b/freebsd/contrib/tcpdump/print-vxlan.c
index 41ad613c..9e576dc0 100644
--- a/freebsd/contrib/tcpdump/print-vxlan.c
+++ b/freebsd/contrib/tcpdump/print-vxlan.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code
@@ -15,23 +18,27 @@
* Original code by Francesco Fondelli (francesco dot fondelli, gmail dot com)
*/
+/* \summary: Virtual eXtensible Local Area Network (VXLAN) printer */
+
+/* specification: RFC 7348 */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
-#include "addrtoname.h"
-#include "udp.h"
+static const char tstr[] = " [|VXLAN]";
+
+#define VXLAN_HDR_LEN 8
/*
- * VXLAN header, draft-mahalingam-dutt-dcops-vxlan-03
+ * VXLAN header, RFC7348
+ * Virtual eXtensible Local Area Network (VXLAN): A Framework
+ * for Overlaying Virtualized Layer 2 Networks over Layer 3 Networks
*
* 0 1 2 3
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
@@ -39,19 +46,19 @@
* |R|R|R|R|I|R|R|R| Reserved |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | VXLAN Network Identifier (VNI) | Reserved |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
void
-vxlan_print(const u_char *bp, u_int len)
+vxlan_print(netdissect_options *ndo, const u_char *bp, u_int len)
{
- u_int8_t flags;
- u_int32_t vni;
-
- if (len < 8) {
- printf("[|VXLAN]");
- return;
- }
+ uint8_t flags;
+ uint32_t vni;
+
+ if (len < VXLAN_HDR_LEN)
+ goto trunc;
+
+ ND_TCHECK2(*bp, VXLAN_HDR_LEN);
flags = *bp;
bp += 4;
@@ -59,18 +66,17 @@ vxlan_print(const u_char *bp, u_int len)
vni = EXTRACT_24BITS(bp);
bp += 4;
- printf("VXLAN, ");
+ ND_PRINT((ndo, "VXLAN, "));
+ ND_PRINT((ndo, "flags [%s] (0x%02x), ", flags & 0x08 ? "I" : ".", flags));
+ ND_PRINT((ndo, "vni %u\n", vni));
- fputs("flags [", stdout);
- if (flags & 0x08)
- fputs("I", stdout);
- else
- fputs(".", stdout);
- fputs("] ", stdout);
+ ether_print(ndo, bp, len - VXLAN_HDR_LEN, ndo->ndo_snapend - bp, NULL, NULL);
- printf("(0x%02x), ", flags);
- printf("vni %u\n", vni);
-
- ether_print(gndo, bp, len - 8, len - 8, NULL, NULL);
return;
+
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-vxlan-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-wb.c b/freebsd/contrib/tcpdump/print-wb.c
index 1bcf4b65..716a974b 100644
--- a/freebsd/contrib/tcpdump/print-wb.c
+++ b/freebsd/contrib/tcpdump/print-wb.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1993, 1994, 1995, 1996
* The Regents of the University of California. All rights reserved.
@@ -21,23 +24,20 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-wb.c,v 1.33 2004-03-24 04:06:28 guy Exp $ (LBL)";
-#endif
+/* \summary: White Board printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
-
-#include <stdio.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "extract.h"
+static const char tstr[] = "[|wb]";
+
/* XXX need to add byte-swapping macros! */
/* XXX - you mean like the ones in "extract.h"? */
@@ -54,17 +54,17 @@ static const char rcsid[] _U_ =
#define DOP_ALIGN 4
#define DOP_ROUNDUP(x) ((((int)(x)) + (DOP_ALIGN - 1)) & ~(DOP_ALIGN - 1))
#define DOP_NEXT(d)\
- ((struct dophdr *)((u_char *)(d) + \
- DOP_ROUNDUP(EXTRACT_16BITS(&(d)->dh_len) + sizeof(*(d)))))
+ ((const struct dophdr *)((const u_char *)(d) + \
+ DOP_ROUNDUP(EXTRACT_16BITS(&(d)->dh_len) + sizeof(*(d)))))
/*
* Format of the whiteboard packet header.
* The transport level header.
*/
struct pkt_hdr {
- u_int32_t ph_src; /* site id of source */
- u_int32_t ph_ts; /* time stamp (for skew computation) */
- u_int16_t ph_version; /* version number */
+ uint32_t ph_src; /* site id of source */
+ uint32_t ph_ts; /* time stamp (for skew computation) */
+ uint16_t ph_version; /* version number */
u_char ph_type; /* message type */
u_char ph_flags; /* message flags */
};
@@ -87,13 +87,13 @@ struct pkt_hdr {
#define PF_VIS 0x02 /* only visible ops wanted */
struct PageID {
- u_int32_t p_sid; /* session id of initiator */
- u_int32_t p_uid; /* page number */
+ uint32_t p_sid; /* session id of initiator */
+ uint32_t p_uid; /* page number */
};
struct dophdr {
- u_int32_t dh_ts; /* sender's timestamp */
- u_int16_t dh_len; /* body length */
+ uint32_t dh_ts; /* sender's timestamp */
+ uint16_t dh_len; /* body length */
u_char dh_flags;
u_char dh_type; /* body type */
/* body follows */
@@ -122,8 +122,8 @@ struct dophdr {
*/
struct pkt_dop {
struct PageID pd_page; /* page that operations apply to */
- u_int32_t pd_sseq; /* start sequence number */
- u_int32_t pd_eseq; /* end sequence number */
+ uint32_t pd_sseq; /* start sequence number */
+ uint32_t pd_eseq; /* end sequence number */
/* drawing ops follow */
};
@@ -131,31 +131,31 @@ struct pkt_dop {
* A repair request.
*/
struct pkt_rreq {
- u_int32_t pr_id; /* source id of drawops to be repaired */
+ uint32_t pr_id; /* source id of drawops to be repaired */
struct PageID pr_page; /* page of drawops */
- u_int32_t pr_sseq; /* start seqno */
- u_int32_t pr_eseq; /* end seqno */
+ uint32_t pr_sseq; /* start seqno */
+ uint32_t pr_eseq; /* end seqno */
};
/*
* A repair reply.
*/
struct pkt_rrep {
- u_int32_t pr_id; /* original site id of ops */
+ uint32_t pr_id; /* original site id of ops */
struct pkt_dop pr_dop;
/* drawing ops follow */
};
struct id_off {
- u_int32_t id;
- u_int32_t off;
+ uint32_t id;
+ uint32_t off;
};
struct pgstate {
- u_int32_t slot;
+ uint32_t slot;
struct PageID page;
- u_int16_t nid;
- u_int16_t rsvd;
+ uint16_t nid;
+ uint16_t rsvd;
/* seqptr's */
};
@@ -163,7 +163,7 @@ struct pgstate {
* An announcement packet.
*/
struct pkt_id {
- u_int32_t pi_mslot;
+ uint32_t pi_mslot;
struct PageID pi_mpage; /* current page */
struct pgstate pi_ps;
/* seqptr's */
@@ -172,17 +172,18 @@ struct pkt_id {
struct pkt_preq {
struct PageID pp_page;
- u_int32_t pp_low;
- u_int32_t pp_high;
+ uint32_t pp_low;
+ uint32_t pp_high;
};
struct pkt_prep {
- u_int32_t pp_n; /* size of pageid array */
+ uint32_t pp_n; /* size of pageid array */
/* pgstate's follow */
};
static int
-wb_id(const struct pkt_id *id, u_int len)
+wb_id(netdissect_options *ndo,
+ const struct pkt_id *id, u_int len)
{
int i;
const char *cp;
@@ -190,107 +191,110 @@ wb_id(const struct pkt_id *id, u_int len)
char c;
int nid;
- printf(" wb-id:");
- if (len < sizeof(*id) || (u_char *)(id + 1) > snapend)
+ ND_PRINT((ndo, " wb-id:"));
+ if (len < sizeof(*id) || !ND_TTEST(*id))
return (-1);
len -= sizeof(*id);
- printf(" %u/%s:%u (max %u/%s:%u) ",
+ ND_PRINT((ndo, " %u/%s:%u (max %u/%s:%u) ",
EXTRACT_32BITS(&id->pi_ps.slot),
- ipaddr_string(&id->pi_ps.page.p_sid),
+ ipaddr_string(ndo, &id->pi_ps.page.p_sid),
EXTRACT_32BITS(&id->pi_ps.page.p_uid),
EXTRACT_32BITS(&id->pi_mslot),
- ipaddr_string(&id->pi_mpage.p_sid),
- EXTRACT_32BITS(&id->pi_mpage.p_uid));
+ ipaddr_string(ndo, &id->pi_mpage.p_sid),
+ EXTRACT_32BITS(&id->pi_mpage.p_uid)));
nid = EXTRACT_16BITS(&id->pi_ps.nid);
len -= sizeof(*io) * nid;
- io = (struct id_off *)(id + 1);
- cp = (char *)(io + nid);
- if ((u_char *)cp + len <= snapend) {
- putchar('"');
- (void)fn_print((u_char *)cp, (u_char *)cp + len);
- putchar('"');
+ io = (const struct id_off *)(id + 1);
+ cp = (const char *)(io + nid);
+ if (ND_TTEST2(cp, len)) {
+ ND_PRINT((ndo, "\""));
+ fn_print(ndo, (const u_char *)cp, (const u_char *)cp + len);
+ ND_PRINT((ndo, "\""));
}
c = '<';
- for (i = 0; i < nid && (u_char *)(io + 1) <= snapend; ++io, ++i) {
- printf("%c%s:%u",
- c, ipaddr_string(&io->id), EXTRACT_32BITS(&io->off));
+ for (i = 0; i < nid && ND_TTEST(*io); ++io, ++i) {
+ ND_PRINT((ndo, "%c%s:%u",
+ c, ipaddr_string(ndo, &io->id), EXTRACT_32BITS(&io->off)));
c = ',';
}
if (i >= nid) {
- printf(">");
+ ND_PRINT((ndo, ">"));
return (0);
}
return (-1);
}
static int
-wb_rreq(const struct pkt_rreq *rreq, u_int len)
+wb_rreq(netdissect_options *ndo,
+ const struct pkt_rreq *rreq, u_int len)
{
- printf(" wb-rreq:");
- if (len < sizeof(*rreq) || (u_char *)(rreq + 1) > snapend)
+ ND_PRINT((ndo, " wb-rreq:"));
+ if (len < sizeof(*rreq) || !ND_TTEST(*rreq))
return (-1);
- printf(" please repair %s %s:%u<%u:%u>",
- ipaddr_string(&rreq->pr_id),
- ipaddr_string(&rreq->pr_page.p_sid),
+ ND_PRINT((ndo, " please repair %s %s:%u<%u:%u>",
+ ipaddr_string(ndo, &rreq->pr_id),
+ ipaddr_string(ndo, &rreq->pr_page.p_sid),
EXTRACT_32BITS(&rreq->pr_page.p_uid),
EXTRACT_32BITS(&rreq->pr_sseq),
- EXTRACT_32BITS(&rreq->pr_eseq));
+ EXTRACT_32BITS(&rreq->pr_eseq)));
return (0);
}
static int
-wb_preq(const struct pkt_preq *preq, u_int len)
+wb_preq(netdissect_options *ndo,
+ const struct pkt_preq *preq, u_int len)
{
- printf(" wb-preq:");
- if (len < sizeof(*preq) || (u_char *)(preq + 1) > snapend)
+ ND_PRINT((ndo, " wb-preq:"));
+ if (len < sizeof(*preq) || !ND_TTEST(*preq))
return (-1);
- printf(" need %u/%s:%u",
+ ND_PRINT((ndo, " need %u/%s:%u",
EXTRACT_32BITS(&preq->pp_low),
- ipaddr_string(&preq->pp_page.p_sid),
- EXTRACT_32BITS(&preq->pp_page.p_uid));
+ ipaddr_string(ndo, &preq->pp_page.p_sid),
+ EXTRACT_32BITS(&preq->pp_page.p_uid)));
return (0);
}
static int
-wb_prep(const struct pkt_prep *prep, u_int len)
+wb_prep(netdissect_options *ndo,
+ const struct pkt_prep *prep, u_int len)
{
int n;
const struct pgstate *ps;
- const u_char *ep = snapend;
+ const u_char *ep = ndo->ndo_snapend;
- printf(" wb-prep:");
+ ND_PRINT((ndo, " wb-prep:"));
if (len < sizeof(*prep)) {
return (-1);
}
n = EXTRACT_32BITS(&prep->pp_n);
ps = (const struct pgstate *)(prep + 1);
- while (--n >= 0 && (u_char *)(ps + 1) <= ep) {
+ while (--n >= 0 && ND_TTEST(*ps)) {
const struct id_off *io, *ie;
char c = '<';
- printf(" %u/%s:%u",
+ ND_PRINT((ndo, " %u/%s:%u",
EXTRACT_32BITS(&ps->slot),
- ipaddr_string(&ps->page.p_sid),
- EXTRACT_32BITS(&ps->page.p_uid));
- io = (struct id_off *)(ps + 1);
- for (ie = io + ps->nid; io < ie && (u_char *)(io + 1) <= ep; ++io) {
- printf("%c%s:%u", c, ipaddr_string(&io->id),
- EXTRACT_32BITS(&io->off));
+ ipaddr_string(ndo, &ps->page.p_sid),
+ EXTRACT_32BITS(&ps->page.p_uid)));
+ io = (const struct id_off *)(ps + 1);
+ for (ie = io + ps->nid; io < ie && ND_TTEST(*io); ++io) {
+ ND_PRINT((ndo, "%c%s:%u", c, ipaddr_string(ndo, &io->id),
+ EXTRACT_32BITS(&io->off)));
c = ',';
}
- printf(">");
- ps = (struct pgstate *)io;
+ ND_PRINT((ndo, ">"));
+ ps = (const struct pgstate *)io;
}
- return ((u_char *)ps <= ep? 0 : -1);
+ return ((const u_char *)ps <= ep? 0 : -1);
}
-const char *dopstr[] = {
+static const char *dopstr[] = {
"dop-0!",
"dop-1!",
"RECT",
@@ -310,21 +314,30 @@ const char *dopstr[] = {
};
static int
-wb_dops(const struct dophdr *dh, u_int32_t ss, u_int32_t es)
+wb_dops(netdissect_options *ndo, const struct pkt_dop *dop,
+ uint32_t ss, uint32_t es)
{
- printf(" <");
+ const struct dophdr *dh = (const struct dophdr *)((const u_char *)dop + sizeof(*dop));
+
+ ND_PRINT((ndo, " <"));
for ( ; ss <= es; ++ss) {
- register int t = dh->dh_type;
+ int t;
+
+ if (!ND_TTEST(*dh)) {
+ ND_PRINT((ndo, "%s", tstr));
+ break;
+ }
+ t = dh->dh_type;
if (t > DT_MAXTYPE)
- printf(" dop-%d!", t);
+ ND_PRINT((ndo, " dop-%d!", t));
else {
- printf(" %s", dopstr[t]);
+ ND_PRINT((ndo, " %s", dopstr[t]));
if (t == DT_SKIP || t == DT_HOLE) {
- u_int32_t ts = EXTRACT_32BITS(&dh->dh_ts);
- printf("%d", ts - ss + 1);
+ uint32_t ts = EXTRACT_32BITS(&dh->dh_ts);
+ ND_PRINT((ndo, "%d", ts - ss + 1));
if (ss > ts || ts > es) {
- printf("[|]");
+ ND_PRINT((ndo, "[|]"));
if (ts < ss)
return (0);
}
@@ -332,55 +345,53 @@ wb_dops(const struct dophdr *dh, u_int32_t ss, u_int32_t es)
}
}
dh = DOP_NEXT(dh);
- if ((u_char *)dh > snapend) {
- printf("[|wb]");
- break;
- }
}
- printf(" >");
+ ND_PRINT((ndo, " >"));
return (0);
}
static int
-wb_rrep(const struct pkt_rrep *rrep, u_int len)
+wb_rrep(netdissect_options *ndo,
+ const struct pkt_rrep *rrep, u_int len)
{
const struct pkt_dop *dop = &rrep->pr_dop;
- printf(" wb-rrep:");
- if (len < sizeof(*rrep) || (u_char *)(rrep + 1) > snapend)
+ ND_PRINT((ndo, " wb-rrep:"));
+ if (len < sizeof(*rrep) || !ND_TTEST(*rrep))
return (-1);
len -= sizeof(*rrep);
- printf(" for %s %s:%u<%u:%u>",
- ipaddr_string(&rrep->pr_id),
- ipaddr_string(&dop->pd_page.p_sid),
+ ND_PRINT((ndo, " for %s %s:%u<%u:%u>",
+ ipaddr_string(ndo, &rrep->pr_id),
+ ipaddr_string(ndo, &dop->pd_page.p_sid),
EXTRACT_32BITS(&dop->pd_page.p_uid),
EXTRACT_32BITS(&dop->pd_sseq),
- EXTRACT_32BITS(&dop->pd_eseq));
+ EXTRACT_32BITS(&dop->pd_eseq)));
- if (vflag)
- return (wb_dops((const struct dophdr *)(dop + 1),
+ if (ndo->ndo_vflag)
+ return (wb_dops(ndo, dop,
EXTRACT_32BITS(&dop->pd_sseq),
EXTRACT_32BITS(&dop->pd_eseq)));
return (0);
}
static int
-wb_drawop(const struct pkt_dop *dop, u_int len)
+wb_drawop(netdissect_options *ndo,
+ const struct pkt_dop *dop, u_int len)
{
- printf(" wb-dop:");
- if (len < sizeof(*dop) || (u_char *)(dop + 1) > snapend)
+ ND_PRINT((ndo, " wb-dop:"));
+ if (len < sizeof(*dop) || !ND_TTEST(*dop))
return (-1);
len -= sizeof(*dop);
- printf(" %s:%u<%u:%u>",
- ipaddr_string(&dop->pd_page.p_sid),
+ ND_PRINT((ndo, " %s:%u<%u:%u>",
+ ipaddr_string(ndo, &dop->pd_page.p_sid),
EXTRACT_32BITS(&dop->pd_page.p_uid),
EXTRACT_32BITS(&dop->pd_sseq),
- EXTRACT_32BITS(&dop->pd_eseq));
+ EXTRACT_32BITS(&dop->pd_eseq)));
- if (vflag)
- return (wb_dops((const struct dophdr *)(dop + 1),
+ if (ndo->ndo_vflag)
+ return (wb_dops(ndo, dop,
EXTRACT_32BITS(&dop->pd_sseq),
EXTRACT_32BITS(&dop->pd_eseq)));
return (0);
@@ -390,57 +401,61 @@ wb_drawop(const struct pkt_dop *dop, u_int len)
* Print whiteboard multicast packets.
*/
void
-wb_print(register const void *hdr, register u_int len)
+wb_print(netdissect_options *ndo,
+ register const void *hdr, register u_int len)
{
register const struct pkt_hdr *ph;
ph = (const struct pkt_hdr *)hdr;
- if (len < sizeof(*ph) || (u_char *)(ph + 1) > snapend) {
- printf("[|wb]");
+ if (len < sizeof(*ph) || !ND_TTEST(*ph)) {
+ ND_PRINT((ndo, "%s", tstr));
return;
}
len -= sizeof(*ph);
if (ph->ph_flags)
- printf("*");
+ ND_PRINT((ndo, "*"));
switch (ph->ph_type) {
case PT_KILL:
- printf(" wb-kill");
+ ND_PRINT((ndo, " wb-kill"));
return;
case PT_ID:
- if (wb_id((struct pkt_id *)(ph + 1), len) >= 0)
+ if (wb_id(ndo, (const struct pkt_id *)(ph + 1), len) >= 0)
return;
break;
case PT_RREQ:
- if (wb_rreq((struct pkt_rreq *)(ph + 1), len) >= 0)
+ if (wb_rreq(ndo, (const struct pkt_rreq *)(ph + 1), len) >= 0)
return;
break;
case PT_RREP:
- if (wb_rrep((struct pkt_rrep *)(ph + 1), len) >= 0)
+ if (wb_rrep(ndo, (const struct pkt_rrep *)(ph + 1), len) >= 0)
return;
break;
case PT_DRAWOP:
- if (wb_drawop((struct pkt_dop *)(ph + 1), len) >= 0)
+ if (wb_drawop(ndo, (const struct pkt_dop *)(ph + 1), len) >= 0)
return;
break;
case PT_PREQ:
- if (wb_preq((struct pkt_preq *)(ph + 1), len) >= 0)
+ if (wb_preq(ndo, (const struct pkt_preq *)(ph + 1), len) >= 0)
return;
break;
case PT_PREP:
- if (wb_prep((struct pkt_prep *)(ph + 1), len) >= 0)
+ if (wb_prep(ndo, (const struct pkt_prep *)(ph + 1), len) >= 0)
return;
break;
default:
- printf(" wb-%d!", ph->ph_type);
+ ND_PRINT((ndo, " wb-%d!", ph->ph_type));
return;
}
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-wb-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-zephyr.c b/freebsd/contrib/tcpdump/print-zephyr.c
index 7ed72118..f76cdfa4 100644
--- a/freebsd/contrib/tcpdump/print-zephyr.c
+++ b/freebsd/contrib/tcpdump/print-zephyr.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Decode and print Zephyr packets.
*
@@ -22,41 +25,38 @@
* PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-zephyr.c,v 1.10 2007-08-09 18:47:27 hannes Exp $";
-#endif
+/* \summary: Zephyr printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
-#include "interface.h"
+#include "netdissect.h"
struct z_packet {
- char *version;
+ const char *version;
int numfields;
int kind;
- char *uid;
+ const char *uid;
int port;
int auth;
int authlen;
- char *authdata;
- char *class;
- char *inst;
- char *opcode;
- char *sender;
+ const char *authdata;
+ const char *class;
+ const char *inst;
+ const char *opcode;
+ const char *sender;
const char *recipient;
- char *format;
+ const char *format;
int cksum;
int multi;
- char *multi_uid;
+ const char *multi_uid;
/* Other fields follow here.. */
};
@@ -72,7 +72,7 @@ enum z_packet_type {
Z_PACKET_STAT
};
-static struct tok z_types[] = {
+static const struct tok z_types[] = {
{ Z_PACKET_UNSAFE, "unsafe" },
{ Z_PACKET_UNACKED, "unacked" },
{ Z_PACKET_ACKED, "acked" },
@@ -84,32 +84,32 @@ static struct tok z_types[] = {
{ Z_PACKET_STAT, "stat" }
};
-char z_buf[256];
+static char z_buf[256];
-static char *
-parse_field(char **pptr, int *len)
+static const char *
+parse_field(netdissect_options *ndo, const char **pptr, int *len)
{
- char *s;
+ const char *s;
if (*len <= 0 || !pptr || !*pptr)
return NULL;
- if (*pptr > (char *) snapend)
+ if (*pptr > (const char *) ndo->ndo_snapend)
return NULL;
s = *pptr;
- while (*pptr <= (char *) snapend && *len >= 0 && **pptr) {
+ while (*pptr <= (const char *) ndo->ndo_snapend && *len >= 0 && **pptr) {
(*pptr)++;
(*len)--;
}
(*pptr)++;
(*len)--;
- if (*len < 0 || *pptr > (char *) snapend)
+ if (*len < 0 || *pptr > (const char *) ndo->ndo_snapend)
return NULL;
return s;
}
static const char *
-z_triple(char *class, char *inst, const char *recipient)
+z_triple(const char *class, const char *inst, const char *recipient)
{
if (!*recipient)
recipient = "*";
@@ -119,27 +119,29 @@ z_triple(char *class, char *inst, const char *recipient)
}
static const char *
-str_to_lower(char *string)
+str_to_lower(const char *string)
{
+ char *zb_string;
+
strncpy(z_buf, string, sizeof(z_buf));
z_buf[sizeof(z_buf)-1] = '\0';
- string = z_buf;
- while (*string) {
- *string = tolower((unsigned char)(*string));
- string++;
+ zb_string = z_buf;
+ while (*zb_string) {
+ *zb_string = tolower((unsigned char)(*zb_string));
+ zb_string++;
}
return z_buf;
}
void
-zephyr_print(const u_char *cp, int length)
+zephyr_print(netdissect_options *ndo, const u_char *cp, int length)
{
struct z_packet z;
- char *parse = (char *) cp;
+ const char *parse = (const char *) cp;
int parselen = length;
- char *s;
+ const char *s;
int lose = 0;
/* squelch compiler warnings */
@@ -152,7 +154,7 @@ zephyr_print(const u_char *cp, int length)
z.recipient = 0;
#define PARSE_STRING \
- s = parse_field(&parse, &parselen); \
+ s = parse_field(ndo, &parse, &parselen); \
if (!s) lose = 1;
#define PARSE_FIELD_INT(field) \
@@ -186,38 +188,38 @@ zephyr_print(const u_char *cp, int length)
PARSE_FIELD_STR(z.multi_uid);
if (lose) {
- printf(" [|zephyr] (%d)", length);
+ ND_PRINT((ndo, " [|zephyr] (%d)", length));
return;
}
- printf(" zephyr");
+ ND_PRINT((ndo, " zephyr"));
if (strncmp(z.version+4, "0.2", 3)) {
- printf(" v%s", z.version+4);
+ ND_PRINT((ndo, " v%s", z.version+4));
return;
}
- printf(" %s", tok2str(z_types, "type %d", z.kind));
+ ND_PRINT((ndo, " %s", tok2str(z_types, "type %d", z.kind)));
if (z.kind == Z_PACKET_SERVACK) {
/* Initialization to silence warnings */
- char *ackdata = NULL;
+ const char *ackdata = NULL;
PARSE_FIELD_STR(ackdata);
if (!lose && strcmp(ackdata, "SENT"))
- printf("/%s", str_to_lower(ackdata));
+ ND_PRINT((ndo, "/%s", str_to_lower(ackdata)));
}
- if (*z.sender) printf(" %s", z.sender);
+ if (*z.sender) ND_PRINT((ndo, " %s", z.sender));
if (!strcmp(z.class, "USER_LOCATE")) {
if (!strcmp(z.opcode, "USER_HIDE"))
- printf(" hide");
+ ND_PRINT((ndo, " hide"));
else if (!strcmp(z.opcode, "USER_UNHIDE"))
- printf(" unhide");
+ ND_PRINT((ndo, " unhide"));
else
- printf(" locate %s", z.inst);
+ ND_PRINT((ndo, " locate %s", z.inst));
return;
}
if (!strcmp(z.class, "ZEPHYR_ADMIN")) {
- printf(" zephyr-admin %s", str_to_lower(z.opcode));
+ ND_PRINT((ndo, " zephyr-admin %s", str_to_lower(z.opcode)));
return;
}
@@ -227,79 +229,79 @@ zephyr_print(const u_char *cp, int length)
!strcmp(z.opcode, "SUBSCRIBE_NODEFS") ||
!strcmp(z.opcode, "UNSUBSCRIBE")) {
- printf(" %ssub%s", strcmp(z.opcode, "SUBSCRIBE") ? "un" : "",
+ ND_PRINT((ndo, " %ssub%s", strcmp(z.opcode, "SUBSCRIBE") ? "un" : "",
strcmp(z.opcode, "SUBSCRIBE_NODEFS") ? "" :
- "-nodefs");
+ "-nodefs"));
if (z.kind != Z_PACKET_SERVACK) {
/* Initialization to silence warnings */
- char *c = NULL, *i = NULL, *r = NULL;
+ const char *c = NULL, *i = NULL, *r = NULL;
PARSE_FIELD_STR(c);
PARSE_FIELD_STR(i);
PARSE_FIELD_STR(r);
- if (!lose) printf(" %s", z_triple(c, i, r));
+ if (!lose) ND_PRINT((ndo, " %s", z_triple(c, i, r)));
}
return;
}
if (!strcmp(z.opcode, "GIMME")) {
- printf(" ret");
+ ND_PRINT((ndo, " ret"));
return;
}
if (!strcmp(z.opcode, "GIMMEDEFS")) {
- printf(" gimme-defs");
+ ND_PRINT((ndo, " gimme-defs"));
return;
}
if (!strcmp(z.opcode, "CLEARSUB")) {
- printf(" clear-subs");
+ ND_PRINT((ndo, " clear-subs"));
return;
}
- printf(" %s", str_to_lower(z.opcode));
+ ND_PRINT((ndo, " %s", str_to_lower(z.opcode)));
return;
}
if (!strcmp(z.inst, "HM")) {
- printf(" %s", str_to_lower(z.opcode));
+ ND_PRINT((ndo, " %s", str_to_lower(z.opcode)));
return;
}
if (!strcmp(z.inst, "REALM")) {
if (!strcmp(z.opcode, "ADD_SUBSCRIBE"))
- printf(" realm add-subs");
+ ND_PRINT((ndo, " realm add-subs"));
if (!strcmp(z.opcode, "REQ_SUBSCRIBE"))
- printf(" realm req-subs");
+ ND_PRINT((ndo, " realm req-subs"));
if (!strcmp(z.opcode, "RLM_SUBSCRIBE"))
- printf(" realm rlm-sub");
+ ND_PRINT((ndo, " realm rlm-sub"));
if (!strcmp(z.opcode, "RLM_UNSUBSCRIBE"))
- printf(" realm rlm-unsub");
+ ND_PRINT((ndo, " realm rlm-unsub"));
return;
}
}
if (!strcmp(z.class, "HM_CTL")) {
- printf(" hm_ctl %s", str_to_lower(z.inst));
- printf(" %s", str_to_lower(z.opcode));
+ ND_PRINT((ndo, " hm_ctl %s", str_to_lower(z.inst)));
+ ND_PRINT((ndo, " %s", str_to_lower(z.opcode)));
return;
}
if (!strcmp(z.class, "HM_STAT")) {
if (!strcmp(z.inst, "HMST_CLIENT") && !strcmp(z.opcode, "GIMMESTATS")) {
- printf(" get-client-stats");
+ ND_PRINT((ndo, " get-client-stats"));
return;
}
}
if (!strcmp(z.class, "WG_CTL")) {
- printf(" wg_ctl %s", str_to_lower(z.inst));
- printf(" %s", str_to_lower(z.opcode));
+ ND_PRINT((ndo, " wg_ctl %s", str_to_lower(z.inst)));
+ ND_PRINT((ndo, " %s", str_to_lower(z.opcode)));
return;
}
if (!strcmp(z.class, "LOGIN")) {
if (!strcmp(z.opcode, "USER_FLUSH")) {
- printf(" flush_locs");
+ ND_PRINT((ndo, " flush_locs"));
return;
}
@@ -309,7 +311,7 @@ zephyr_print(const u_char *cp, int length)
!strcmp(z.opcode, "REALM-ANNOUNCED") ||
!strcmp(z.opcode, "NET-VISIBLE") ||
!strcmp(z.opcode, "NET-ANNOUNCED")) {
- printf(" set-exposure %s", str_to_lower(z.opcode));
+ ND_PRINT((ndo, " set-exposure %s", str_to_lower(z.opcode)));
return;
}
}
@@ -317,8 +319,10 @@ zephyr_print(const u_char *cp, int length)
if (!*z.recipient)
z.recipient = "*";
- printf(" to %s", z_triple(z.class, z.inst, z.recipient));
+ ND_PRINT((ndo, " to %s", z_triple(z.class, z.inst, z.recipient)));
if (*z.opcode)
- printf(" op %s", z.opcode);
- return;
+ ND_PRINT((ndo, " op %s", z.opcode));
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-zephyr-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print-zeromq.c b/freebsd/contrib/tcpdump/print-zeromq.c
index ffd90bc1..20b76f49 100644
--- a/freebsd/contrib/tcpdump/print-zeromq.c
+++ b/freebsd/contrib/tcpdump/print-zeromq.c
@@ -1,9 +1,9 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
- * This file implements decoding of ZeroMQ network protocol(s).
- *
- *
* Copyright (c) 2013 The TCPDUMP project
* All rights reserved.
*
@@ -30,17 +30,19 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
+/* \summary: ZeroMQ Message Transport Protocol (ZMTP) printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
-
-#include <stdio.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
+static const char tstr[] = " [|zmtp1]";
+
/* Maximum number of ZMTP/1.0 frame body bytes (without the flags) to dump in
* hex and ASCII under a single "-v" flag.
*/
@@ -77,42 +79,39 @@
*/
static const u_char *
-zmtp1_print_frame(const u_char *cp, const u_char *ep) {
- u_int64_t body_len_declared, body_len_captured, header_len;
- u_int8_t flags;
+zmtp1_print_frame(netdissect_options *ndo, const u_char *cp, const u_char *ep)
+{
+ uint64_t body_len_declared, body_len_captured, header_len;
+ uint8_t flags;
- printf("\n\t");
- TCHECK2(*cp, 1); /* length/0xFF */
+ ND_PRINT((ndo, "\n\t"));
+ ND_TCHECK2(*cp, 1); /* length/0xFF */
if (cp[0] != 0xFF) {
header_len = 1; /* length */
body_len_declared = cp[0];
- if (body_len_declared == 0)
- return cp + header_len; /* skip to next frame */
- printf(" frame flags+body (8-bit) length %"PRIu8"", cp[0]);
- TCHECK2(*cp, header_len + 1); /* length, flags */
- flags = cp[1];
+ ND_PRINT((ndo, " frame flags+body (8-bit) length %" PRIu64, body_len_declared));
} else {
header_len = 1 + 8; /* 0xFF, length */
- printf(" frame flags+body (64-bit) length");
- TCHECK2(*cp, header_len); /* 0xFF, length */
+ ND_PRINT((ndo, " frame flags+body (64-bit) length"));
+ ND_TCHECK2(*cp, header_len); /* 0xFF, length */
body_len_declared = EXTRACT_64BITS(cp + 1);
- if (body_len_declared == 0)
- return cp + header_len; /* skip to next frame */
- printf(" %"PRIu64"", body_len_declared);
- TCHECK2(*cp, header_len + 1); /* 0xFF, length, flags */
- flags = cp[9];
+ ND_PRINT((ndo, " %" PRIu64, body_len_declared));
}
+ if (body_len_declared == 0)
+ return cp + header_len; /* skip to the next frame */
+ ND_TCHECK2(*cp, header_len + 1); /* ..., flags */
+ flags = cp[header_len];
body_len_captured = ep - cp - header_len;
if (body_len_declared > body_len_captured)
- printf(" (%"PRIu64" captured)", body_len_captured);
- printf(", flags 0x%02"PRIx8"", flags);
+ ND_PRINT((ndo, " (%" PRIu64 " captured)", body_len_captured));
+ ND_PRINT((ndo, ", flags 0x%02x", flags));
- if (vflag) {
- u_int64_t body_len_printed = MIN(body_len_captured, body_len_declared);
+ if (ndo->ndo_vflag) {
+ uint64_t body_len_printed = min(body_len_captured, body_len_declared);
- printf(" (%s|%s|%s|%s|%s|%s|%s|%s)",
+ ND_PRINT((ndo, " (%s|%s|%s|%s|%s|%s|%s|%s)",
flags & 0x80 ? "MBZ" : "-",
flags & 0x40 ? "MBZ" : "-",
flags & 0x20 ? "MBZ" : "-",
@@ -120,31 +119,110 @@ zmtp1_print_frame(const u_char *cp, const u_char *ep) {
flags & 0x08 ? "MBZ" : "-",
flags & 0x04 ? "MBZ" : "-",
flags & 0x02 ? "MBZ" : "-",
- flags & 0x01 ? "MORE" : "-");
+ flags & 0x01 ? "MORE" : "-"));
- if (vflag == 1)
- body_len_printed = MIN(VBYTES + 1, body_len_printed);
+ if (ndo->ndo_vflag == 1)
+ body_len_printed = min(VBYTES + 1, body_len_printed);
if (body_len_printed > 1) {
- printf(", first %"PRIu64" byte(s) of body:", body_len_printed - 1);
- hex_and_ascii_print("\n\t ", cp + header_len + 1, body_len_printed - 1);
- printf("\n");
+ ND_PRINT((ndo, ", first %" PRIu64 " byte(s) of body:", body_len_printed - 1));
+ hex_and_ascii_print(ndo, "\n\t ", cp + header_len + 1, body_len_printed - 1);
+ ND_PRINT((ndo, "\n"));
}
}
- TCHECK2(*cp, header_len + body_len_declared); /* Next frame within the buffer ? */
- return cp + header_len + body_len_declared;
+ /*
+ * Do not advance cp by the sum of header_len and body_len_declared
+ * before each offset has successfully passed ND_TCHECK2() as the
+ * sum can roll over (9 + 0xfffffffffffffff7 = 0) and cause an
+ * infinite loop.
+ */
+ cp += header_len;
+ ND_TCHECK2(*cp, body_len_declared); /* Next frame within the buffer ? */
+ return cp + body_len_declared;
trunc:
- printf(" [|zmtp1]");
+ ND_PRINT((ndo, "%s", tstr));
return ep;
}
void
-zmtp1_print(const u_char *cp, u_int len) {
- const u_char *ep = MIN(snapend, cp + len);
+zmtp1_print(netdissect_options *ndo, const u_char *cp, u_int len)
+{
+ const u_char *ep = min(ndo->ndo_snapend, cp + len);
- printf(": ZMTP/1.0");
+ ND_PRINT((ndo, ": ZMTP/1.0"));
while (cp < ep)
- cp = zmtp1_print_frame(cp, ep);
+ cp = zmtp1_print_frame(ndo, cp, ep);
}
+/* The functions below decode a ZeroMQ datagram, supposedly stored in the "Data"
+ * field of an ODATA/RDATA [E]PGM packet. An excerpt from zmq_pgm(7) man page
+ * follows.
+ *
+ * In order for late joining consumers to be able to identify message
+ * boundaries, each PGM datagram payload starts with a 16-bit unsigned integer
+ * in network byte order specifying either the offset of the first message frame
+ * in the datagram or containing the value 0xFFFF if the datagram contains
+ * solely an intermediate part of a larger message.
+ *
+ * Note that offset specifies where the first message begins rather than the
+ * first message part. Thus, if there are trailing message parts at the
+ * beginning of the packet the offset ignores them and points to first initial
+ * message part in the packet.
+ */
+
+static const u_char *
+zmtp1_print_intermediate_part(netdissect_options *ndo, const u_char *cp, const u_int len)
+{
+ u_int frame_offset;
+ uint64_t remaining_len;
+
+ ND_TCHECK2(*cp, 2);
+ frame_offset = EXTRACT_16BITS(cp);
+ ND_PRINT((ndo, "\n\t frame offset 0x%04x", frame_offset));
+ cp += 2;
+ remaining_len = ndo->ndo_snapend - cp; /* without the frame length */
+
+ if (frame_offset == 0xFFFF)
+ frame_offset = len - 2; /* always within the declared length */
+ else if (2 + frame_offset > len) {
+ ND_PRINT((ndo, " (exceeds datagram declared length)"));
+ goto trunc;
+ }
+
+ /* offset within declared length of the datagram */
+ if (frame_offset) {
+ ND_PRINT((ndo, "\n\t frame intermediate part, %u bytes", frame_offset));
+ if (frame_offset > remaining_len)
+ ND_PRINT((ndo, " (%"PRIu64" captured)", remaining_len));
+ if (ndo->ndo_vflag) {
+ uint64_t len_printed = min(frame_offset, remaining_len);
+
+ if (ndo->ndo_vflag == 1)
+ len_printed = min(VBYTES, len_printed);
+ if (len_printed > 1) {
+ ND_PRINT((ndo, ", first %"PRIu64" byte(s):", len_printed));
+ hex_and_ascii_print(ndo, "\n\t ", cp, len_printed);
+ ND_PRINT((ndo, "\n"));
+ }
+ }
+ }
+ return cp + frame_offset;
+
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return cp + len;
+}
+
+void
+zmtp1_print_datagram(netdissect_options *ndo, const u_char *cp, const u_int len)
+{
+ const u_char *ep = min(ndo->ndo_snapend, cp + len);
+
+ cp = zmtp1_print_intermediate_part(ndo, cp, len);
+ while (cp < ep)
+ cp = zmtp1_print_frame(ndo, cp, ep);
+}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-zeromq-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print.c b/freebsd/contrib/tcpdump/print.c
new file mode 100644
index 00000000..c76b30f7
--- /dev/null
+++ b/freebsd/contrib/tcpdump/print.c
@@ -0,0 +1,492 @@
+#include <machine/rtems-bsd-user-space.h>
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
+/*
+ * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2000
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code distributions
+ * retain the above copyright notice and this paragraph in its entirety, (2)
+ * distributions including binary code include the above copyright notice and
+ * this paragraph in its entirety in the documentation or other materials
+ * provided with the distribution, and (3) all advertising materials mentioning
+ * features or use of this software display the following acknowledgement:
+ * ``This product includes software developed by the University of California,
+ * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
+ * the University 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 ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * Support for splitting captures into multiple files with a maximum
+ * file size:
+ *
+ * Copyright (c) 2001
+ * Seth Webster <swebster@sst.ll.mit.edu>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+
+#include <netdissect-stdinc.h>
+
+#include "netdissect.h"
+#include "addrtoname.h"
+#include "print.h"
+
+struct printer {
+ if_printer f;
+ int type;
+};
+
+static const struct printer printers[] = {
+ { ether_if_print, DLT_EN10MB },
+#ifdef DLT_IPNET
+ { ipnet_if_print, DLT_IPNET },
+#endif
+#ifdef DLT_IEEE802_15_4
+ { ieee802_15_4_if_print, DLT_IEEE802_15_4 },
+#endif
+#ifdef DLT_IEEE802_15_4_NOFCS
+ { ieee802_15_4_if_print, DLT_IEEE802_15_4_NOFCS },
+#endif
+#ifdef DLT_PPI
+ { ppi_if_print, DLT_PPI },
+#endif
+#ifdef DLT_NETANALYZER
+ { netanalyzer_if_print, DLT_NETANALYZER },
+#endif
+#ifdef DLT_NETANALYZER_TRANSPARENT
+ { netanalyzer_transparent_if_print, DLT_NETANALYZER_TRANSPARENT },
+#endif
+#if defined(DLT_NFLOG) && defined(HAVE_PCAP_NFLOG_H)
+ { nflog_if_print, DLT_NFLOG},
+#endif
+#ifdef DLT_CIP
+ { cip_if_print, DLT_CIP },
+#endif
+#ifdef DLT_ATM_CLIP
+ { cip_if_print, DLT_ATM_CLIP },
+#endif
+#ifdef DLT_IP_OVER_FC
+ { ipfc_if_print, DLT_IP_OVER_FC },
+#endif
+ { null_if_print, DLT_NULL },
+#ifdef DLT_LOOP
+ { null_if_print, DLT_LOOP },
+#endif
+#ifdef DLT_APPLE_IP_OVER_IEEE1394
+ { ap1394_if_print, DLT_APPLE_IP_OVER_IEEE1394 },
+#endif
+#if defined(DLT_BLUETOOTH_HCI_H4_WITH_PHDR) && defined(HAVE_PCAP_BLUETOOTH_H)
+ { bt_if_print, DLT_BLUETOOTH_HCI_H4_WITH_PHDR},
+#endif
+#ifdef DLT_LANE8023
+ { lane_if_print, DLT_LANE8023 },
+#endif
+ { arcnet_if_print, DLT_ARCNET },
+#ifdef DLT_ARCNET_LINUX
+ { arcnet_linux_if_print, DLT_ARCNET_LINUX },
+#endif
+ { raw_if_print, DLT_RAW },
+#ifdef DLT_IPV4
+ { raw_if_print, DLT_IPV4 },
+#endif
+#ifdef DLT_IPV6
+ { raw_if_print, DLT_IPV6 },
+#endif
+#ifdef HAVE_PCAP_USB_H
+#ifdef DLT_USB_LINUX
+ { usb_linux_48_byte_print, DLT_USB_LINUX},
+#endif /* DLT_USB_LINUX */
+#ifdef DLT_USB_LINUX_MMAPPED
+ { usb_linux_64_byte_print, DLT_USB_LINUX_MMAPPED},
+#endif /* DLT_USB_LINUX_MMAPPED */
+#endif /* HAVE_PCAP_USB_H */
+#ifdef DLT_SYMANTEC_FIREWALL
+ { symantec_if_print, DLT_SYMANTEC_FIREWALL },
+#endif
+#ifdef DLT_C_HDLC
+ { chdlc_if_print, DLT_C_HDLC },
+#endif
+#ifdef DLT_HDLC
+ { chdlc_if_print, DLT_HDLC },
+#endif
+#ifdef DLT_PPP_ETHER
+ { pppoe_if_print, DLT_PPP_ETHER },
+#endif
+#if defined(DLT_PFLOG) && defined(HAVE_NET_IF_PFLOG_H)
+ { pflog_if_print, DLT_PFLOG },
+#endif
+ { token_if_print, DLT_IEEE802 },
+ { fddi_if_print, DLT_FDDI },
+#ifdef DLT_LINUX_SLL
+ { sll_if_print, DLT_LINUX_SLL },
+#endif
+#ifdef DLT_FR
+ { fr_if_print, DLT_FR },
+#endif
+#ifdef DLT_FRELAY
+ { fr_if_print, DLT_FRELAY },
+#endif
+#ifdef DLT_MFR
+ { mfr_if_print, DLT_MFR },
+#endif
+ { atm_if_print, DLT_ATM_RFC1483 },
+#ifdef DLT_SUNATM
+ { sunatm_if_print, DLT_SUNATM },
+#endif
+#ifdef DLT_ENC
+ { enc_if_print, DLT_ENC },
+#endif
+ { sl_if_print, DLT_SLIP },
+#ifdef DLT_SLIP_BSDOS
+ { sl_bsdos_if_print, DLT_SLIP_BSDOS },
+#endif
+#ifdef DLT_LTALK
+ { ltalk_if_print, DLT_LTALK },
+#endif
+#ifdef DLT_JUNIPER_ATM1
+ { juniper_atm1_print, DLT_JUNIPER_ATM1 },
+#endif
+#ifdef DLT_JUNIPER_ATM2
+ { juniper_atm2_print, DLT_JUNIPER_ATM2 },
+#endif
+#ifdef DLT_JUNIPER_MFR
+ { juniper_mfr_print, DLT_JUNIPER_MFR },
+#endif
+#ifdef DLT_JUNIPER_MLFR
+ { juniper_mlfr_print, DLT_JUNIPER_MLFR },
+#endif
+#ifdef DLT_JUNIPER_MLPPP
+ { juniper_mlppp_print, DLT_JUNIPER_MLPPP },
+#endif
+#ifdef DLT_JUNIPER_PPPOE
+ { juniper_pppoe_print, DLT_JUNIPER_PPPOE },
+#endif
+#ifdef DLT_JUNIPER_PPPOE_ATM
+ { juniper_pppoe_atm_print, DLT_JUNIPER_PPPOE_ATM },
+#endif
+#ifdef DLT_JUNIPER_GGSN
+ { juniper_ggsn_print, DLT_JUNIPER_GGSN },
+#endif
+#ifdef DLT_JUNIPER_ES
+ { juniper_es_print, DLT_JUNIPER_ES },
+#endif
+#ifdef DLT_JUNIPER_MONITOR
+ { juniper_monitor_print, DLT_JUNIPER_MONITOR },
+#endif
+#ifdef DLT_JUNIPER_SERVICES
+ { juniper_services_print, DLT_JUNIPER_SERVICES },
+#endif
+#ifdef DLT_JUNIPER_ETHER
+ { juniper_ether_print, DLT_JUNIPER_ETHER },
+#endif
+#ifdef DLT_JUNIPER_PPP
+ { juniper_ppp_print, DLT_JUNIPER_PPP },
+#endif
+#ifdef DLT_JUNIPER_FRELAY
+ { juniper_frelay_print, DLT_JUNIPER_FRELAY },
+#endif
+#ifdef DLT_JUNIPER_CHDLC
+ { juniper_chdlc_print, DLT_JUNIPER_CHDLC },
+#endif
+#ifdef DLT_PKTAP
+ { pktap_if_print, DLT_PKTAP },
+#endif
+#ifdef DLT_IEEE802_11_RADIO
+ { ieee802_11_radio_if_print, DLT_IEEE802_11_RADIO },
+#endif
+#ifdef DLT_IEEE802_11
+ { ieee802_11_if_print, DLT_IEEE802_11},
+#endif
+#ifdef DLT_IEEE802_11_RADIO_AVS
+ { ieee802_11_radio_avs_if_print, DLT_IEEE802_11_RADIO_AVS },
+#endif
+#ifdef DLT_PRISM_HEADER
+ { prism_if_print, DLT_PRISM_HEADER },
+#endif
+ { ppp_if_print, DLT_PPP },
+#ifdef DLT_PPP_WITHDIRECTION
+ { ppp_if_print, DLT_PPP_WITHDIRECTION },
+#endif
+#ifdef DLT_PPP_BSDOS
+ { ppp_bsdos_if_print, DLT_PPP_BSDOS },
+#endif
+#ifdef DLT_PPP_SERIAL
+ { ppp_hdlc_if_print, DLT_PPP_SERIAL },
+#endif
+ { NULL, 0 },
+};
+
+static void ndo_default_print(netdissect_options *ndo, const u_char *bp,
+ u_int length);
+
+static void ndo_error(netdissect_options *ndo, const char *fmt, ...)
+ __attribute__((noreturn))
+#ifdef __ATTRIBUTE___FORMAT_OK
+ __attribute__((format (printf, 2, 3)))
+#endif /* __ATTRIBUTE___FORMAT_OK */
+ ;
+static void ndo_warning(netdissect_options *ndo, const char *fmt, ...)
+#ifdef __ATTRIBUTE___FORMAT_OK
+ __attribute__((format (printf, 2, 3)))
+#endif /* __ATTRIBUTE___FORMAT_OK */
+ ;
+
+static int ndo_printf(netdissect_options *ndo, const char *fmt, ...)
+#ifdef __ATTRIBUTE___FORMAT_OK
+ __attribute ((format (printf, 2, 3)))
+#endif /* __ATTRIBUTE___FORMAT_OK */
+ ;
+
+void
+init_print(netdissect_options *ndo, uint32_t localnet, uint32_t mask,
+ uint32_t timezone_offset)
+{
+
+ thiszone = timezone_offset;
+ init_addrtoname(ndo, localnet, mask);
+ init_checksum();
+}
+
+if_printer
+lookup_printer(int type)
+{
+ const struct printer *p;
+
+ for (p = printers; p->f; ++p)
+ if (type == p->type)
+ return p->f;
+
+#if defined(DLT_USER2) && defined(DLT_PKTAP)
+ /*
+ * Apple incorrectly chose to use DLT_USER2 for their PKTAP
+ * header.
+ *
+ * We map DLT_PKTAP, whether it's DLT_USER2 as it is on Darwin-
+ * based OSes or the same value as LINKTYPE_PKTAP as it is on
+ * other OSes, to LINKTYPE_PKTAP, so files written with
+ * this version of libpcap for a DLT_PKTAP capture have a link-
+ * layer header type of LINKTYPE_PKTAP.
+ *
+ * However, files written on OS X Mavericks for a DLT_PKTAP
+ * capture have a link-layer header type of LINKTYPE_USER2.
+ * If we don't have a printer for DLT_USER2, and type is
+ * DLT_USER2, we look up the printer for DLT_PKTAP and use
+ * that.
+ */
+ if (type == DLT_USER2) {
+ for (p = printers; p->f; ++p)
+ if (DLT_PKTAP == p->type)
+ return p->f;
+ }
+#endif
+
+ return NULL;
+ /* NOTREACHED */
+}
+
+int
+has_printer(int type)
+{
+ return (lookup_printer(type) != NULL);
+}
+
+if_printer
+get_if_printer(netdissect_options *ndo, int type)
+{
+ const char *dltname;
+ if_printer printer;
+
+ printer = lookup_printer(type);
+ if (printer == NULL) {
+ dltname = pcap_datalink_val_to_name(type);
+ if (dltname != NULL)
+ (*ndo->ndo_error)(ndo,
+ "packet printing is not supported for link type %s: use -w",
+ dltname);
+ else
+ (*ndo->ndo_error)(ndo,
+ "packet printing is not supported for link type %d: use -w", type);
+ }
+ return printer;
+}
+
+void
+pretty_print_packet(netdissect_options *ndo, const struct pcap_pkthdr *h,
+ const u_char *sp, u_int packets_captured)
+{
+ u_int hdrlen;
+
+ if(ndo->ndo_packet_number)
+ ND_PRINT((ndo, "%5u ", packets_captured));
+
+ ts_print(ndo, &h->ts);
+
+ /*
+ * Some printers want to check that they're not walking off the
+ * end of the packet.
+ * Rather than pass it all the way down, we set this member
+ * of the netdissect_options structure.
+ */
+ ndo->ndo_snapend = sp + h->caplen;
+
+ hdrlen = (ndo->ndo_if_printer)(ndo, h, sp);
+
+ /*
+ * Restore the original snapend, as a printer might have
+ * changed it.
+ */
+ ndo->ndo_snapend = sp + h->caplen;
+ if (ndo->ndo_Xflag) {
+ /*
+ * Print the raw packet data in hex and ASCII.
+ */
+ if (ndo->ndo_Xflag > 1) {
+ /*
+ * Include the link-layer header.
+ */
+ hex_and_ascii_print(ndo, "\n\t", sp, h->caplen);
+ } else {
+ /*
+ * Don't include the link-layer header - and if
+ * we have nothing past the link-layer header,
+ * print nothing.
+ */
+ if (h->caplen > hdrlen)
+ hex_and_ascii_print(ndo, "\n\t", sp + hdrlen,
+ h->caplen - hdrlen);
+ }
+ } else if (ndo->ndo_xflag) {
+ /*
+ * Print the raw packet data in hex.
+ */
+ if (ndo->ndo_xflag > 1) {
+ /*
+ * Include the link-layer header.
+ */
+ hex_print(ndo, "\n\t", sp, h->caplen);
+ } else {
+ /*
+ * Don't include the link-layer header - and if
+ * we have nothing past the link-layer header,
+ * print nothing.
+ */
+ if (h->caplen > hdrlen)
+ hex_print(ndo, "\n\t", sp + hdrlen,
+ h->caplen - hdrlen);
+ }
+ } else if (ndo->ndo_Aflag) {
+ /*
+ * Print the raw packet data in ASCII.
+ */
+ if (ndo->ndo_Aflag > 1) {
+ /*
+ * Include the link-layer header.
+ */
+ ascii_print(ndo, sp, h->caplen);
+ } else {
+ /*
+ * Don't include the link-layer header - and if
+ * we have nothing past the link-layer header,
+ * print nothing.
+ */
+ if (h->caplen > hdrlen)
+ ascii_print(ndo, sp + hdrlen, h->caplen - hdrlen);
+ }
+ }
+
+ ND_PRINT((ndo, "\n"));
+}
+
+/*
+ * By default, print the specified data out in hex and ASCII.
+ */
+static void
+ndo_default_print(netdissect_options *ndo, const u_char *bp, u_int length)
+{
+ hex_and_ascii_print(ndo, "\n\t", bp, length); /* pass on lf and indentation string */
+}
+
+/* VARARGS */
+static void
+ndo_error(netdissect_options *ndo, const char *fmt, ...)
+{
+ va_list ap;
+
+ if(ndo->program_name)
+ (void)fprintf(stderr, "%s: ", ndo->program_name);
+ va_start(ap, fmt);
+ (void)vfprintf(stderr, fmt, ap);
+ va_end(ap);
+ if (*fmt) {
+ fmt += strlen(fmt);
+ if (fmt[-1] != '\n')
+ (void)fputc('\n', stderr);
+ }
+ nd_cleanup();
+ exit(1);
+ /* NOTREACHED */
+}
+
+/* VARARGS */
+static void
+ndo_warning(netdissect_options *ndo, const char *fmt, ...)
+{
+ va_list ap;
+
+ if(ndo->program_name)
+ (void)fprintf(stderr, "%s: ", ndo->program_name);
+ (void)fprintf(stderr, "WARNING: ");
+ va_start(ap, fmt);
+ (void)vfprintf(stderr, fmt, ap);
+ va_end(ap);
+ if (*fmt) {
+ fmt += strlen(fmt);
+ if (fmt[-1] != '\n')
+ (void)fputc('\n', stderr);
+ }
+}
+
+static int
+ndo_printf(netdissect_options *ndo, const char *fmt, ...)
+{
+ va_list args;
+ int ret;
+
+ va_start(args, fmt);
+ ret = vfprintf(stdout, fmt, args);
+ va_end(args);
+
+ if (ret < 0)
+ ndo_error(ndo, "Unable to write output: %s", pcap_strerror(errno));
+ return (ret);
+}
+
+void
+ndo_set_function_pointers(netdissect_options *ndo)
+{
+ ndo->ndo_default_print=ndo_default_print;
+ ndo->ndo_printf=ndo_printf;
+ ndo->ndo_error=ndo_error;
+ ndo->ndo_warning=ndo_warning;
+}
+/*
+ * Local Variables:
+ * c-style: whitesmith
+ * c-basic-offset: 8
+ * End:
+ */
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-print-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/print.h b/freebsd/contrib/tcpdump/print.h
new file mode 100644
index 00000000..9632694e
--- /dev/null
+++ b/freebsd/contrib/tcpdump/print.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2000
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code distributions
+ * retain the above copyright notice and this paragraph in its entirety, (2)
+ * distributions including binary code include the above copyright notice and
+ * this paragraph in its entirety in the documentation or other materials
+ * provided with the distribution, and (3) all advertising materials mentioning
+ * features or use of this software display the following acknowledgement:
+ * ``This product includes software developed by the University of California,
+ * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
+ * the University 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 ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * Support for splitting captures into multiple files with a maximum
+ * file size:
+ *
+ * Copyright (c) 2001
+ * Seth Webster <swebster@sst.ll.mit.edu>
+ */
+
+#ifndef print_h
+#define print_h
+
+void init_print(netdissect_options *ndo, uint32_t localnet, uint32_t mask,
+ uint32_t timezone_offset);
+
+int has_printer(int type);
+
+if_printer get_if_printer(netdissect_options *ndo, int type);
+
+void pretty_print_packet(netdissect_options *ndo,
+ const struct pcap_pkthdr *h, const u_char *sp,
+ u_int packets_captured);
+
+void ndo_set_function_pointers(netdissect_options *ndo);
+
+#endif /* print_h */
diff --git a/freebsd/contrib/tcpdump/route6d.h b/freebsd/contrib/tcpdump/route6d.h
deleted file mode 100644
index 53953fdb..00000000
--- a/freebsd/contrib/tcpdump/route6d.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (C) 1995, 1996, 1997 and 1998 WIDE Project.
- * All rights reserved.
- *
- * 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.
- */
-/*
- * $Header: /tcpdump/master/tcpdump/route6d.h,v 1.5 2002-12-11 07:14:10 guy Exp $
- */
-
-#define RIP6_VERSION 1
-
-#define RIP6_REQUEST 1
-#define RIP6_RESPONSE 2
-
-struct netinfo6 {
- struct in6_addr rip6_dest;
- u_int16_t rip6_tag;
- u_int8_t rip6_plen;
- u_int8_t rip6_metric;
-};
-
-struct rip6 {
- u_int8_t rip6_cmd;
- u_int8_t rip6_vers;
- u_int8_t rip6_res1[2];
- union {
- struct netinfo6 ru6_nets[1];
- char ru6_tracefile[1];
- } rip6un;
-#define rip6_nets rip6un.ru6_nets
-#define rip6_tracefile rip6un.ru6_tracefile
-};
-
-#define HOPCNT_INFINITY6 16
-#define MAXRTE 24
-#define NEXTHOP_METRIC 0xff
-
-#ifndef DEBUG
-#define SUPPLY_INTERVAL6 30
-#define RIP_LIFETIME 180
-#define RIP_HOLDDOWN 120
-#define RIP_TRIG_INTERVAL6 5
-#define RIP_TRIG_INTERVAL6_MIN 1
-#else
-/* only for debugging; can not wait for 30sec to appear a bug */
-#define SUPPLY_INTERVAL6 10
-#define RIP_LIFETIME 60
-#define RIP_HOLDDOWN 40
-#define RIP_TRIG_INTERVAL6 5
-#define RIP_TRIG_INTERVAL6_MIN 1
-#endif
-
-#define RIP6_PORT 521
-#define RIP6_DEST "ff02::9"
diff --git a/freebsd/contrib/tcpdump/rpc_auth.h b/freebsd/contrib/tcpdump/rpc_auth.h
index 0e5a1c12..21f78598 100644
--- a/freebsd/contrib/tcpdump/rpc_auth.h
+++ b/freebsd/contrib/tcpdump/rpc_auth.h
@@ -1,4 +1,3 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/rpc_auth.h,v 1.2 2005-04-27 21:43:48 guy Exp $ (LBL) */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
* unrestricted use provided that this legend is included on all tape
@@ -29,8 +28,7 @@
*
* from: @(#)auth.h 1.17 88/02/08 SMI
* from: @(#)auth.h 2.3 88/08/07 4.0 RPCSRC
- * $FreeBSD$
- * FreeBSD: src/include/rpc/auth.h,v 1.14.2.1 1999/08/29 14:39:02 peter Exp
+ * $FreeBSD: projects/clang400-import/contrib/tcpdump/rpc_auth.h 276788 2015-01-07 19:55:18Z delphij $
*/
/*
@@ -67,8 +65,8 @@ enum sunrpc_auth_stat {
* Authentication info. Opaque to client.
*/
struct sunrpc_opaque_auth {
- u_int32_t oa_flavor; /* flavor of auth */
- u_int32_t oa_len; /* length of opaque body */
+ uint32_t oa_flavor; /* flavor of auth */
+ uint32_t oa_len; /* length of opaque body */
/* zero or more bytes of body */
};
diff --git a/freebsd/contrib/tcpdump/rpc_msg.h b/freebsd/contrib/tcpdump/rpc_msg.h
index 9c2770c2..ab0fe886 100644
--- a/freebsd/contrib/tcpdump/rpc_msg.h
+++ b/freebsd/contrib/tcpdump/rpc_msg.h
@@ -1,4 +1,3 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/rpc_msg.h,v 1.2 2005-04-27 21:43:48 guy Exp $ (LBL) */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
* unrestricted use provided that this legend is included on all tape
@@ -29,8 +28,7 @@
*
* from: @(#)rpc_msg.h 1.7 86/07/16 SMI
* from: @(#)rpc_msg.h 2.1 88/07/29 4.0 RPCSRC
- * $FreeBSD$
- * FreeBSD: src/include/rpc/rpc_msg.h,v 1.11.2.1 1999/08/29 14:39:07 peter Exp
+ * $FreeBSD: projects/clang400-import/contrib/tcpdump/rpc_msg.h 276788 2015-01-07 19:55:18Z delphij $
*/
/*
@@ -40,7 +38,7 @@
* Copyright (C) 1984, Sun Microsystems, Inc.
*/
-#define SUNRPC_MSG_VERSION ((u_int32_t) 2)
+#define SUNRPC_MSG_VERSION ((uint32_t) 2)
/*
* Bottom up definition of an rpc message.
@@ -80,13 +78,13 @@ enum sunrpc_reject_stat {
* Reply to an rpc request that was rejected by the server.
*/
struct sunrpc_rejected_reply {
- u_int32_t rj_stat; /* enum reject_stat */
+ uint32_t rj_stat; /* enum reject_stat */
union {
struct {
- u_int32_t low;
- u_int32_t high;
+ uint32_t low;
+ uint32_t high;
} RJ_versions;
- u_int32_t RJ_why; /* enum auth_stat - why authentication did not work */
+ uint32_t RJ_why; /* enum auth_stat - why authentication did not work */
} ru;
#define rj_vers ru.RJ_versions
#define rj_why ru.RJ_why
@@ -96,7 +94,7 @@ struct sunrpc_rejected_reply {
* Body of a reply to an rpc request.
*/
struct sunrpc_reply_body {
- u_int32_t rp_stat; /* enum reply_stat */
+ uint32_t rp_stat; /* enum reply_stat */
struct sunrpc_rejected_reply rp_reject; /* if rejected */
};
@@ -104,10 +102,10 @@ struct sunrpc_reply_body {
* Body of an rpc request call.
*/
struct sunrpc_call_body {
- u_int32_t cb_rpcvers; /* must be equal to two */
- u_int32_t cb_prog;
- u_int32_t cb_vers;
- u_int32_t cb_proc;
+ uint32_t cb_rpcvers; /* must be equal to two */
+ uint32_t cb_prog;
+ uint32_t cb_vers;
+ uint32_t cb_proc;
struct sunrpc_opaque_auth cb_cred;
/* followed by opaque verifier */
};
@@ -116,8 +114,8 @@ struct sunrpc_call_body {
* The rpc message
*/
struct sunrpc_msg {
- u_int32_t rm_xid;
- u_int32_t rm_direction; /* enum msg_type */
+ uint32_t rm_xid;
+ uint32_t rm_direction; /* enum msg_type */
union {
struct sunrpc_call_body RM_cmb;
struct sunrpc_reply_body RM_rmb;
diff --git a/freebsd/contrib/tcpdump/rpl.h b/freebsd/contrib/tcpdump/rpl.h
new file mode 100644
index 00000000..5ad074b4
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rpl.h
@@ -0,0 +1,174 @@
+#ifndef _RPL_H_
+
+/*
+ * NOTE: the contents of this file are an interpretation of RFC6550.
+ * no copyright is asserted on this file, as it transcribes
+ * a public specification.
+ *
+ */
+
+/*
+ * DIO: Updated to RFC6550, as published in 2012: section 6. (page 30)
+ */
+
+#define ND_RPL_MESSAGE 155 /* 0x9B */
+
+enum ND_RPL_CODE {
+ ND_RPL_DAG_IS=0x00,
+ ND_RPL_DAG_IO=0x01,
+ ND_RPL_DAO =0x02,
+ ND_RPL_DAO_ACK=0x03,
+ ND_RPL_SEC_DAG_IS = 0x80,
+ ND_RPL_SEC_DAG_IO = 0x81,
+ ND_RPL_SEC_DAG = 0x82,
+ ND_RPL_SEC_DAG_ACK= 0x83,
+ ND_RPL_SEC_CONSIST= 0x8A
+};
+
+enum ND_RPL_DIO_FLAGS {
+ ND_RPL_DIO_GROUNDED = 0x80,
+ ND_RPL_DIO_DATRIG = 0x40,
+ ND_RPL_DIO_DASUPPORT= 0x20,
+ ND_RPL_DIO_RES4 = 0x10,
+ ND_RPL_DIO_RES3 = 0x08,
+ ND_RPL_DIO_PRF_MASK = 0x07 /* 3-bit preference */
+};
+
+#define DAGID_LEN 16
+
+/* section 6 of draft-ietf-roll-rpl-19 */
+struct nd_rpl_security {
+ uint8_t rpl_sec_t_reserved; /* bit 7 is T-bit */
+ uint8_t rpl_sec_algo;
+ uint16_t rpl_sec_kim_lvl_flags; /* bit 15/14, KIM */
+ /* bit 10-8, LVL, bit 7-0 flags */
+ uint32_t rpl_sec_counter;
+#if 0
+ uint8_t rpl_sec_ki[0]; /* depends upon kim */
+#endif
+};
+
+/* section 6.2.1, DODAG Information Solication (DIS_IS) */
+struct nd_rpl_dis_is {
+ uint8_t rpl_dis_flags;
+ uint8_t rpl_dis_reserved;
+#if 0
+ uint8_t rpl_dis_options[0];
+#endif
+};
+
+/* section 6.3.1, DODAG Information Object (DIO) */
+struct nd_rpl_dio {
+ uint8_t rpl_instanceid;
+ uint8_t rpl_version;
+ uint16_t rpl_dagrank;
+ uint8_t rpl_mopprf; /* bit 7=G, 5-3=MOP, 2-0=PRF */
+ uint8_t rpl_dtsn; /* Dest. Advertisement Trigger Sequence Number */
+ uint8_t rpl_flags; /* no flags defined yet */
+ uint8_t rpl_resv1;
+ uint8_t rpl_dagid[DAGID_LEN];
+};
+#define RPL_DIO_GROUND_FLAG 0x80
+#define RPL_DIO_MOP_SHIFT 3
+#define RPL_DIO_MOP_MASK (7 << RPL_DIO_MOP_SHIFT)
+#define RPL_DIO_PRF_SHIFT 0
+#define RPL_DIO_PRF_MASK (7 << RPL_DIO_PRF_SHIFT)
+#define RPL_DIO_GROUNDED(X) ((X)&RPL_DIO_GROUND_FLAG)
+#define RPL_DIO_MOP(X) (enum RPL_DIO_MOP)(((X)&RPL_DIO_MOP_MASK) >> RPL_DIO_MOP_SHIFT)
+#define RPL_DIO_PRF(X) (((X)&RPL_DIO_PRF_MASK) >> RPL_DIO_PRF_SHIFT)
+
+enum RPL_DIO_MOP {
+ RPL_DIO_NONSTORING= 0x0,
+ RPL_DIO_STORING = 0x1,
+ RPL_DIO_NONSTORING_MULTICAST = 0x2,
+ RPL_DIO_STORING_MULTICAST = 0x3
+};
+
+enum RPL_SUBOPT {
+ RPL_OPT_PAD0 = 0,
+ RPL_OPT_PADN = 1,
+ RPL_DIO_METRICS = 2,
+ RPL_DIO_ROUTINGINFO = 3,
+ RPL_DIO_CONFIG = 4,
+ RPL_DAO_RPLTARGET = 5,
+ RPL_DAO_TRANSITINFO = 6,
+ RPL_DIO_DESTPREFIX = 8,
+ RPL_DAO_RPLTARGET_DESC=9
+};
+
+struct rpl_dio_genoption {
+ uint8_t rpl_dio_type;
+ uint8_t rpl_dio_len; /* suboption length, not including type/len */
+};
+#define RPL_DIO_GENOPTION_LEN 2
+
+#define RPL_DIO_LIFETIME_INFINITE 0xffffffff
+#define RPL_DIO_LIFETIME_DISCONNECT 0
+
+struct rpl_dio_destprefix {
+ uint8_t rpl_dio_type;
+ uint8_t rpl_dio_len;
+ uint8_t rpl_dio_prefixlen; /* in bits */
+ uint8_t rpl_dio_prf; /* flags, including Route Preference */
+ uint32_t rpl_dio_prefixlifetime; /* in seconds */
+#if 0
+ uint8_t rpl_dio_prefix[0]; /* variable number of bytes */
+#endif
+};
+
+/* section 6.4.1, DODAG Information Object (DIO) */
+struct nd_rpl_dao {
+ uint8_t rpl_instanceid;
+ uint8_t rpl_flags; /* bit 7=K, 6=D */
+ uint8_t rpl_resv;
+ uint8_t rpl_daoseq;
+ uint8_t rpl_dagid[DAGID_LEN]; /* present when D set. */
+};
+#define ND_RPL_DAO_MIN_LEN 4 /* length without DAGID */
+
+/* indicates if this DAO is to be acK'ed */
+#define RPL_DAO_K_SHIFT 7
+#define RPL_DAO_K_MASK (1 << RPL_DAO_K_SHIFT)
+#define RPL_DAO_K(X) (((X)&RPL_DAO_K_MASK) >> RPL_DAO_K_SHIFT)
+
+/* indicates if the DAGID is present */
+#define RPL_DAO_D_SHIFT 6
+#define RPL_DAO_D_MASK (1 << RPL_DAO_D_SHIFT)
+#define RPL_DAO_D(X) (((X)&RPL_DAO_D_MASK) >> RPL_DAO_D_SHIFT)
+
+struct rpl_dao_target {
+ uint8_t rpl_dao_type;
+ uint8_t rpl_dao_len;
+ uint8_t rpl_dao_flags; /* unused */
+ uint8_t rpl_dao_prefixlen; /* in bits */
+#if 0
+ uint8_t rpl_dao_prefix[0]; /* variable number of bytes */
+#endif
+};
+
+/* section 6.5.1, Destination Advertisement Object Acknowledgement (DAO-ACK) */
+struct nd_rpl_daoack {
+ uint8_t rpl_instanceid;
+ uint8_t rpl_flags; /* bit 7=D */
+ uint8_t rpl_daoseq;
+ uint8_t rpl_status;
+ uint8_t rpl_dagid[DAGID_LEN]; /* present when D set. */
+};
+#define ND_RPL_DAOACK_MIN_LEN 4 /* length without DAGID */
+/* indicates if the DAGID is present */
+#define RPL_DAOACK_D_SHIFT 7
+#define RPL_DAOACK_D_MASK (1 << RPL_DAOACK_D_SHIFT)
+#define RPL_DAOACK_D(X) (((X)&RPL_DAOACK_D_MASK) >> RPL_DAOACK_D_SHIFT)
+
+
+
+#define _RPL_H_
+#endif /* _RPL_H_ */
+
+/*
+ * Local Variables:
+ * c-basic-offset:4
+ * c-style: whitesmith
+ * End:
+ */
+
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-addrtoname-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-addrtoname-data.h
new file mode 100644
index 00000000..85cfdc3c
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-addrtoname-data.h
@@ -0,0 +1,17 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* addrtoname.c */
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct hnamemem hnametable[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct hnamemem tporttable[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct hnamemem uporttable[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct hnamemem eprototable[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct hnamemem dnaddrtable[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct hnamemem ipxsaptable[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct h6namemem h6nametable[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct enamemem enametable[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct enamemem nsaptable[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct enamemem bytestringtable[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct protoidmem protoidtable[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static uint32_t f_netmask);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static uint32_t f_localnet);
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-addrtostr-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-addrtostr-data.h
new file mode 100644
index 00000000..48fc04ee
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-addrtostr-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* addrtostr.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-af-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-af-data.h
new file mode 100644
index 00000000..45c012a6
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-af-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* af.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-ascii_strcasecmp-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-ascii_strcasecmp-data.h
new file mode 100644
index 00000000..f17b395b
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-ascii_strcasecmp-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* ascii_strcasecmp.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-bpf_dump-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-bpf_dump-data.h
new file mode 100644
index 00000000..9027b60a
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-bpf_dump-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* bpf_dump.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-checksum-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-checksum-data.h
new file mode 100644
index 00000000..6a263370
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-checksum-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* checksum.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-cpack-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-cpack-data.h
new file mode 100644
index 00000000..bba59255
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-cpack-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* cpack.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-data.h
new file mode 100644
index 00000000..d021ae99
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-data.h
@@ -0,0 +1,173 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+/* addrtoname.c */
+/* addrtostr.c */
+/* af.c */
+/* ascii_strcasecmp.c */
+/* bpf_dump.c */
+/* checksum.c */
+/* cpack.c */
+/* gmpls.c */
+/* gmt2local.c */
+/* in_cksum.c */
+/* ipproto.c */
+/* l2vpn.c */
+/* machdep.c */
+/* netdissect.c */
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, extern int nd_smi_module_loaded);
+/* nlpid.c */
+/* oui.c */
+/* parsenfsfh.c */
+/* print-802_11.c */
+/* print-802_15_4.c */
+/* print-ah.c */
+/* print-ahcp.c */
+/* print-aodv.c */
+/* print-aoe.c */
+/* print-ap1394.c */
+/* print-arcnet.c */
+/* print-arp.c */
+/* print-ascii.c */
+/* print-atalk.c */
+/* print-atm.c */
+/* print-babel.c */
+/* print-beep.c */
+/* print-bfd.c */
+/* print-bgp.c */
+/* print-bootp.c */
+/* print-bt.c */
+/* print.c */
+/* print-calm-fast.c */
+/* print-carp.c */
+/* print-cdp.c */
+/* print-cfm.c */
+/* print-chdlc.c */
+/* print-cip.c */
+/* print-cnfp.c */
+/* print-dccp.c */
+/* print-decnet.c */
+/* print-dhcp6.c */
+/* print-domain.c */
+/* print-dtp.c */
+/* print-dvmrp.c */
+/* print-eap.c */
+/* print-egp.c */
+/* print-eigrp.c */
+/* print-enc.c */
+/* print-esp.c */
+/* print-ether.c */
+/* print-fddi.c */
+/* print-forces.c */
+/* print-frag6.c */
+/* print-fr.c */
+/* print-ftp.c */
+/* print-geneve.c */
+/* print-geonet.c */
+/* print-gre.c */
+/* print-hncp.c */
+/* print-hsrp.c */
+/* print-http.c */
+/* print-icmp6.c */
+/* print-icmp.c */
+/* print-igmp.c */
+/* print-igrp.c */
+/* print-ip6.c */
+/* print-ip6opts.c */
+/* print-ip.c */
+/* print-ipcomp.c */
+/* print-ipfc.c */
+/* print-ipnet.c */
+/* print-ipx.c */
+/* print-isakmp.c */
+/* print-isoclns.c */
+/* print-juniper.c */
+/* print-krb.c */
+/* print-l2tp.c */
+/* print-lane.c */
+/* print-ldp.c */
+/* print-lisp.c */
+/* print-llc.c */
+/* print-lldp.c */
+/* print-lmp.c */
+/* print-loopback.c */
+/* print-lspping.c */
+/* print-lwapp.c */
+/* print-lwres.c */
+/* print-m3ua.c */
+/* print-medsa.c */
+/* print-mobile.c */
+/* print-mobility.c */
+/* print-mpcp.c */
+/* print-mpls.c */
+/* print-mptcp.c */
+/* print-msdp.c */
+/* print-msnlb.c */
+/* print-nfs.c */
+/* print-nsh.c */
+/* print-ntp.c */
+/* print-null.c */
+/* print-olsr.c */
+/* print-openflow-1.0.c */
+/* print-openflow.c */
+/* print-ospf6.c */
+/* print-ospf.c */
+/* print-otv.c */
+/* print-pflog.c */
+/* print-pfsync.c */
+/* print-pgm.c */
+/* print-pim.c */
+/* print-pktap.c */
+/* print-ppi.c */
+/* print-ppp.c */
+/* print-pppoe.c */
+/* print-pptp.c */
+/* print-radius.c */
+/* print-raw.c */
+/* print-resp.c */
+/* print-rip.c */
+/* print-ripng.c */
+/* print-rpki-rtr.c */
+/* print-rrcp.c */
+/* print-rsvp.c */
+/* print-rt6.c */
+/* print-rtsp.c */
+/* print-rx.c */
+/* print-sctp.c */
+/* print-sflow.c */
+/* print-sip.c */
+/* print-sl.c */
+/* print-sll.c */
+/* print-slow.c */
+/* print-smb.c */
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, extern u_char const *startbuf);
+/* print-smtp.c */
+/* print-snmp.c */
+/* print-stp.c */
+/* print-sunatm.c */
+/* print-symantec.c */
+/* print-syslog.c */
+/* print-tcp.c */
+/* print-telnet.c */
+/* print-tftp.c */
+/* print-timed.c */
+/* print-tipc.c */
+/* print-token.c */
+/* print-udld.c */
+/* print-udp.c */
+/* print-usb.c */
+/* print-vjc.c */
+/* print-vqp.c */
+/* print-vrrp.c */
+/* print-vtp.c */
+/* print-vxlan.c */
+/* print-vxlan-gpe.c */
+/* print-wb.c */
+/* print-zephyr.c */
+/* print-zeromq.c */
+/* setsignal.c */
+/* signature.c */
+/* smbutil.c */
+/* tcpdump.c */
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, extern char *program_name);
+/* util-print.c */
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, extern int32_t thiszone);
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-gmpls-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-gmpls-data.h
new file mode 100644
index 00000000..cf92135e
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-gmpls-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* gmpls.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-gmt2local-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-gmt2local-data.h
new file mode 100644
index 00000000..e02efd01
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-gmt2local-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* gmt2local.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-in_cksum-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-in_cksum-data.h
new file mode 100644
index 00000000..171d2146
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-in_cksum-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* in_cksum.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-ipproto-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-ipproto-data.h
new file mode 100644
index 00000000..b19c39b3
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-ipproto-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* ipproto.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-l2vpn-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-l2vpn-data.h
new file mode 100644
index 00000000..3c1f80c2
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-l2vpn-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* l2vpn.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-machdep-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-machdep-data.h
new file mode 100644
index 00000000..ebb13549
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-machdep-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* machdep.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-namespace.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-namespace.h
new file mode 100644
index 00000000..956a76d7
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-namespace.h
@@ -0,0 +1,462 @@
+/* generated by userspace-header-gen.py */
+/* addrtoname.c */
+#define ieee8021q_tci_string _bsd_tcpdump_ieee8021q_tci_string
+#define newh6namemem _bsd_tcpdump_newh6namemem
+#define newhnamemem _bsd_tcpdump_newhnamemem
+#define dnaddr_string _bsd_tcpdump_dnaddr_string
+#define init_addrtoname _bsd_tcpdump_init_addrtoname
+#define ipxsap_string _bsd_tcpdump_ipxsap_string
+#define udpport_string _bsd_tcpdump_udpport_string
+#define tcpport_string _bsd_tcpdump_tcpport_string
+#define isonsap_string _bsd_tcpdump_isonsap_string
+#define protoid_string _bsd_tcpdump_protoid_string
+#define etherproto_string _bsd_tcpdump_etherproto_string
+#define linkaddr_string _bsd_tcpdump_linkaddr_string
+#define le64addr_string _bsd_tcpdump_le64addr_string
+#define etheraddr_string _bsd_tcpdump_etheraddr_string
+#define getname6 _bsd_tcpdump_getname6
+#define getname _bsd_tcpdump_getname
+#define intoa _bsd_tcpdump_intoa
+/* addrtostr.c */
+#define addrtostr6 _bsd_tcpdump_addrtostr6
+#define addrtostr _bsd_tcpdump_addrtostr
+/* af.c */
+/* ascii_strcasecmp.c */
+#define ascii_strncasecmp _bsd_tcpdump_ascii_strncasecmp
+#define ascii_strcasecmp _bsd_tcpdump_ascii_strcasecmp
+/* bpf_dump.c */
+#define bpf_dump _bsd_tcpdump_bpf_dump
+/* checksum.c */
+#define create_osi_cksum _bsd_tcpdump_create_osi_cksum
+#define init_checksum _bsd_tcpdump_init_checksum
+#define verify_crc10_cksum _bsd_tcpdump_verify_crc10_cksum
+/* cpack.c */
+#define cpack_uint8 _bsd_tcpdump_cpack_uint8
+#define cpack_uint16 _bsd_tcpdump_cpack_uint16
+#define cpack_uint32 _bsd_tcpdump_cpack_uint32
+#define cpack_uint64 _bsd_tcpdump_cpack_uint64
+#define cpack_init _bsd_tcpdump_cpack_init
+#define cpack_advance _bsd_tcpdump_cpack_advance
+#define cpack_align_and_reserve _bsd_tcpdump_cpack_align_and_reserve
+#define cpack_next_boundary _bsd_tcpdump_cpack_next_boundary
+/* gmpls.c */
+/* gmt2local.c */
+#define gmt2local _bsd_tcpdump_gmt2local
+/* in_cksum.c */
+#define in_cksum_shouldbe _bsd_tcpdump_in_cksum_shouldbe
+#define in_cksum _bsd_tcpdump_in_cksum
+/* ipproto.c */
+/* l2vpn.c */
+/* machdep.c */
+#define abort_on_misalignment _bsd_tcpdump_abort_on_misalignment
+/* netdissect.c */
+#define nd_smi_module_loaded _bsd_tcpdump_nd_smi_module_loaded
+#define nd_smi_version_string _bsd_tcpdump_nd_smi_version_string
+#define nd_load_smi_module _bsd_tcpdump_nd_load_smi_module
+#define nd_have_smi_support _bsd_tcpdump_nd_have_smi_support
+#define nd_cleanup _bsd_tcpdump_nd_cleanup
+#define nd_init _bsd_tcpdump_nd_init
+/* nlpid.c */
+/* oui.c */
+/* parsenfsfh.c */
+#define Parse_fh _bsd_tcpdump_Parse_fh
+/* print-802_11.c */
+#define ieee802_11_radio_avs_if_print _bsd_tcpdump_ieee802_11_radio_avs_if_print
+#define ieee802_11_radio_if_print _bsd_tcpdump_ieee802_11_radio_if_print
+#define prism_if_print _bsd_tcpdump_prism_if_print
+#define ieee802_11_if_print _bsd_tcpdump_ieee802_11_if_print
+/* print-802_15_4.c */
+#define ieee802_15_4_if_print _bsd_tcpdump_ieee802_15_4_if_print
+/* print-ah.c */
+#define ah_print _bsd_tcpdump_ah_print
+/* print-ahcp.c */
+#define ahcp_print _bsd_tcpdump_ahcp_print
+/* print-aodv.c */
+#define aodv_print _bsd_tcpdump_aodv_print
+/* print-aoe.c */
+#define aoe_print _bsd_tcpdump_aoe_print
+/* print-ap1394.c */
+#define ap1394_if_print _bsd_tcpdump_ap1394_if_print
+/* print-arcnet.c */
+#define arcnet_linux_if_print _bsd_tcpdump_arcnet_linux_if_print
+#define arcnet_if_print _bsd_tcpdump_arcnet_if_print
+/* print-arp.c */
+#define arp_print _bsd_tcpdump_arp_print
+/* print-ascii.c */
+#define hex_print _bsd_tcpdump_hex_print
+#define hex_print_with_offset _bsd_tcpdump_hex_print_with_offset
+#define hex_and_ascii_print _bsd_tcpdump_hex_and_ascii_print
+#define hex_and_ascii_print_with_offset _bsd_tcpdump_hex_and_ascii_print_with_offset
+#define ascii_print _bsd_tcpdump_ascii_print
+/* print-atalk.c */
+#define aarp_print _bsd_tcpdump_aarp_print
+#define atalk_print _bsd_tcpdump_atalk_print
+#define llap_print _bsd_tcpdump_llap_print
+#define ltalk_if_print _bsd_tcpdump_ltalk_if_print
+/* print-atm.c */
+#define oam_print _bsd_tcpdump_oam_print
+#define atm_print _bsd_tcpdump_atm_print
+#define atm_if_print _bsd_tcpdump_atm_if_print
+/* print-babel.c */
+#define babel_print _bsd_tcpdump_babel_print
+/* print-beep.c */
+#define beep_print _bsd_tcpdump_beep_print
+/* print-bfd.c */
+#define bfd_print _bsd_tcpdump_bfd_print
+/* print-bgp.c */
+#define bgp_print _bsd_tcpdump_bgp_print
+#define decode_prefix6 _bsd_tcpdump_decode_prefix6
+#define bgp_vpn_rd_print _bsd_tcpdump_bgp_vpn_rd_print
+#define decode_prefix4 _bsd_tcpdump_decode_prefix4
+/* print-bootp.c */
+#define bootp_print _bsd_tcpdump_bootp_print
+/* print-bt.c */
+/* print.c */
+#define ndo_set_function_pointers _bsd_tcpdump_ndo_set_function_pointers
+#define pretty_print_packet _bsd_tcpdump_pretty_print_packet
+#define get_if_printer _bsd_tcpdump_get_if_printer
+#define has_printer _bsd_tcpdump_has_printer
+#define lookup_printer _bsd_tcpdump_lookup_printer
+#define init_print _bsd_tcpdump_init_print
+/* print-calm-fast.c */
+#define calm_fast_print _bsd_tcpdump_calm_fast_print
+/* print-carp.c */
+#define carp_print _bsd_tcpdump_carp_print
+/* print-cdp.c */
+#define cdp_print _bsd_tcpdump_cdp_print
+/* print-cfm.c */
+#define cfm_print _bsd_tcpdump_cfm_print
+/* print-chdlc.c */
+#define chdlc_print _bsd_tcpdump_chdlc_print
+#define chdlc_if_print _bsd_tcpdump_chdlc_if_print
+/* print-cip.c */
+#define cip_if_print _bsd_tcpdump_cip_if_print
+/* print-cnfp.c */
+#define cnfp_print _bsd_tcpdump_cnfp_print
+/* print-dccp.c */
+#define dccp_print _bsd_tcpdump_dccp_print
+/* print-decnet.c */
+#define dnname_string _bsd_tcpdump_dnname_string
+#define dnnum_string _bsd_tcpdump_dnnum_string
+#define decnet_print _bsd_tcpdump_decnet_print
+/* print-dhcp6.c */
+#define dhcp6_print _bsd_tcpdump_dhcp6_print
+/* print-domain.c */
+#define ns_print _bsd_tcpdump_ns_print
+#define ns_nprint _bsd_tcpdump_ns_nprint
+/* print-dtp.c */
+#define dtp_print _bsd_tcpdump_dtp_print
+/* print-dvmrp.c */
+#define dvmrp_print _bsd_tcpdump_dvmrp_print
+/* print-eap.c */
+#define eap_print _bsd_tcpdump_eap_print
+/* print-egp.c */
+#define egp_print _bsd_tcpdump_egp_print
+/* print-eigrp.c */
+#define eigrp_print _bsd_tcpdump_eigrp_print
+/* print-enc.c */
+#define enc_if_print _bsd_tcpdump_enc_if_print
+/* print-esp.c */
+#define esp_print _bsd_tcpdump_esp_print
+/* print-ether.c */
+#define ethertype_print _bsd_tcpdump_ethertype_print
+#define netanalyzer_transparent_if_print _bsd_tcpdump_netanalyzer_transparent_if_print
+#define netanalyzer_if_print _bsd_tcpdump_netanalyzer_if_print
+#define ether_if_print _bsd_tcpdump_ether_if_print
+#define ether_print _bsd_tcpdump_ether_print
+/* print-fddi.c */
+#define fddi_if_print _bsd_tcpdump_fddi_if_print
+#define fddi_print _bsd_tcpdump_fddi_print
+/* print-forces.c */
+#define forces_print _bsd_tcpdump_forces_print
+/* print-frag6.c */
+#define frag6_print _bsd_tcpdump_frag6_print
+/* print-fr.c */
+#define q933_print _bsd_tcpdump_q933_print
+#define mfr_print _bsd_tcpdump_mfr_print
+#define mfr_if_print _bsd_tcpdump_mfr_if_print
+#define fr_print _bsd_tcpdump_fr_print
+#define fr_if_print _bsd_tcpdump_fr_if_print
+#define q922_string _bsd_tcpdump_q922_string
+/* print-ftp.c */
+#define ftp_print _bsd_tcpdump_ftp_print
+/* print-geneve.c */
+#define geneve_print _bsd_tcpdump_geneve_print
+/* print-geonet.c */
+#define geonet_print _bsd_tcpdump_geonet_print
+/* print-gre.c */
+#define gre_print _bsd_tcpdump_gre_print
+/* print-hncp.c */
+#define hncp_print _bsd_tcpdump_hncp_print
+/* print-hsrp.c */
+#define hsrp_print _bsd_tcpdump_hsrp_print
+/* print-http.c */
+#define http_print _bsd_tcpdump_http_print
+/* print-icmp6.c */
+#define icmp6_print _bsd_tcpdump_icmp6_print
+/* print-icmp.c */
+#define icmp_print _bsd_tcpdump_icmp_print
+#define icmp_tstamp_print _bsd_tcpdump_icmp_tstamp_print
+/* print-igmp.c */
+#define igmp_print _bsd_tcpdump_igmp_print
+/* print-igrp.c */
+#define igrp_print _bsd_tcpdump_igrp_print
+/* print-ip6.c */
+#define ip6_print _bsd_tcpdump_ip6_print
+#define nextproto6_cksum _bsd_tcpdump_nextproto6_cksum
+/* print-ip6opts.c */
+#define dstopt_print _bsd_tcpdump_dstopt_print
+#define hbhopt_print _bsd_tcpdump_hbhopt_print
+/* print-ip.c */
+#define ipN_print _bsd_tcpdump_ipN_print
+#define ip_print _bsd_tcpdump_ip_print
+#define ip_print_inner _bsd_tcpdump_ip_print_inner
+#define nextproto4_cksum _bsd_tcpdump_nextproto4_cksum
+/* print-ipcomp.c */
+#define ipcomp_print _bsd_tcpdump_ipcomp_print
+/* print-ipfc.c */
+#define ipfc_if_print _bsd_tcpdump_ipfc_if_print
+/* print-ipnet.c */
+#define ipnet_if_print _bsd_tcpdump_ipnet_if_print
+/* print-ipx.c */
+#define ipx_print _bsd_tcpdump_ipx_print
+/* print-isakmp.c */
+#define isakmp_rfc3948_print _bsd_tcpdump_isakmp_rfc3948_print
+#define isakmp_print _bsd_tcpdump_isakmp_print
+/* print-isoclns.c */
+#define isoclns_print _bsd_tcpdump_isoclns_print
+/* print-juniper.c */
+#define juniper_atm2_print _bsd_tcpdump_juniper_atm2_print
+#define juniper_atm1_print _bsd_tcpdump_juniper_atm1_print
+#define juniper_mlfr_print _bsd_tcpdump_juniper_mlfr_print
+#define juniper_mfr_print _bsd_tcpdump_juniper_mfr_print
+#define juniper_mlppp_print _bsd_tcpdump_juniper_mlppp_print
+#define juniper_pppoe_atm_print _bsd_tcpdump_juniper_pppoe_atm_print
+#define juniper_chdlc_print _bsd_tcpdump_juniper_chdlc_print
+#define juniper_frelay_print _bsd_tcpdump_juniper_frelay_print
+#define juniper_ppp_print _bsd_tcpdump_juniper_ppp_print
+#define juniper_ether_print _bsd_tcpdump_juniper_ether_print
+#define juniper_pppoe_print _bsd_tcpdump_juniper_pppoe_print
+#define juniper_services_print _bsd_tcpdump_juniper_services_print
+#define juniper_monitor_print _bsd_tcpdump_juniper_monitor_print
+#define juniper_es_print _bsd_tcpdump_juniper_es_print
+#define juniper_ggsn_print _bsd_tcpdump_juniper_ggsn_print
+/* print-krb.c */
+#define krb_print _bsd_tcpdump_krb_print
+/* print-l2tp.c */
+#define l2tp_print _bsd_tcpdump_l2tp_print
+/* print-lane.c */
+#define lane_if_print _bsd_tcpdump_lane_if_print
+#define lane_print _bsd_tcpdump_lane_print
+/* print-ldp.c */
+#define ldp_print _bsd_tcpdump_ldp_print
+/* print-lisp.c */
+#define lisp_print _bsd_tcpdump_lisp_print
+/* print-llc.c */
+#define snap_print _bsd_tcpdump_snap_print
+#define llc_print _bsd_tcpdump_llc_print
+/* print-lldp.c */
+#define lldp_print _bsd_tcpdump_lldp_print
+/* print-lmp.c */
+#define lmp_print _bsd_tcpdump_lmp_print
+/* print-loopback.c */
+#define loopback_print _bsd_tcpdump_loopback_print
+/* print-lspping.c */
+#define lspping_print _bsd_tcpdump_lspping_print
+/* print-lwapp.c */
+#define lwapp_data_print _bsd_tcpdump_lwapp_data_print
+#define lwapp_control_print _bsd_tcpdump_lwapp_control_print
+/* print-lwres.c */
+#define lwres_print _bsd_tcpdump_lwres_print
+/* print-m3ua.c */
+#define m3ua_print _bsd_tcpdump_m3ua_print
+/* print-medsa.c */
+#define medsa_print _bsd_tcpdump_medsa_print
+/* print-mobile.c */
+#define mobile_print _bsd_tcpdump_mobile_print
+/* print-mobility.c */
+#define mobility_print _bsd_tcpdump_mobility_print
+/* print-mpcp.c */
+#define mpcp_print _bsd_tcpdump_mpcp_print
+/* print-mpls.c */
+#define mpls_print _bsd_tcpdump_mpls_print
+/* print-mptcp.c */
+#define mptcp_print _bsd_tcpdump_mptcp_print
+/* print-msdp.c */
+#define msdp_print _bsd_tcpdump_msdp_print
+/* print-msnlb.c */
+#define msnlb_print _bsd_tcpdump_msnlb_print
+/* print-nfs.c */
+#define nfsreq_print_noaddr _bsd_tcpdump_nfsreq_print_noaddr
+#define nfsreply_print_noaddr _bsd_tcpdump_nfsreply_print_noaddr
+#define nfsreply_print _bsd_tcpdump_nfsreply_print
+/* print-nsh.c */
+#define nsh_print _bsd_tcpdump_nsh_print
+/* print-ntp.c */
+#define ntp_print _bsd_tcpdump_ntp_print
+/* print-null.c */
+#define null_if_print _bsd_tcpdump_null_if_print
+/* print-olsr.c */
+#define olsr_print _bsd_tcpdump_olsr_print
+/* print-openflow-1.0.c */
+#define of10_header_body_print _bsd_tcpdump_of10_header_body_print
+/* print-openflow.c */
+#define openflow_print _bsd_tcpdump_openflow_print
+#define of_vendor_name _bsd_tcpdump_of_vendor_name
+/* print-ospf6.c */
+#define ospf6_print _bsd_tcpdump_ospf6_print
+/* print-ospf.c */
+#define ospf_print _bsd_tcpdump_ospf_print
+#define ospf_print_te_lsa _bsd_tcpdump_ospf_print_te_lsa
+#define ospf_print_grace_lsa _bsd_tcpdump_ospf_print_grace_lsa
+/* print-otv.c */
+#define otv_print _bsd_tcpdump_otv_print
+/* print-pflog.c */
+#define pflog_if_print _bsd_tcpdump_pflog_if_print
+/* print-pfsync.c */
+#define pfsync_ip_print _bsd_tcpdump_pfsync_ip_print
+/* print-pgm.c */
+#define pgm_print _bsd_tcpdump_pgm_print
+/* print-pim.c */
+#define pim_print _bsd_tcpdump_pim_print
+#define cisco_autorp_print _bsd_tcpdump_cisco_autorp_print
+#define pimv1_print _bsd_tcpdump_pimv1_print
+/* print-pktap.c */
+#define pktap_if_print _bsd_tcpdump_pktap_if_print
+/* print-ppi.c */
+#define ppi_if_print _bsd_tcpdump_ppi_if_print
+/* print-ppp.c */
+#define ppp_bsdos_if_print _bsd_tcpdump_ppp_bsdos_if_print
+#define ppp_hdlc_if_print _bsd_tcpdump_ppp_hdlc_if_print
+#define ppp_if_print _bsd_tcpdump_ppp_if_print
+#define ppp_print _bsd_tcpdump_ppp_print
+/* print-pppoe.c */
+#define pppoe_print _bsd_tcpdump_pppoe_print
+#define pppoe_if_print _bsd_tcpdump_pppoe_if_print
+/* print-pptp.c */
+#define pptp_print _bsd_tcpdump_pptp_print
+/* print-radius.c */
+#define radius_print _bsd_tcpdump_radius_print
+/* print-raw.c */
+#define raw_if_print _bsd_tcpdump_raw_if_print
+/* print-resp.c */
+#define resp_print _bsd_tcpdump_resp_print
+/* print-rip.c */
+#define rip_print _bsd_tcpdump_rip_print
+/* print-ripng.c */
+#define ripng_print _bsd_tcpdump_ripng_print
+/* print-rpki-rtr.c */
+#define rpki_rtr_print _bsd_tcpdump_rpki_rtr_print
+/* print-rrcp.c */
+#define rrcp_print _bsd_tcpdump_rrcp_print
+/* print-rsvp.c */
+#define rsvp_print _bsd_tcpdump_rsvp_print
+/* print-rt6.c */
+#define rt6_print _bsd_tcpdump_rt6_print
+/* print-rtsp.c */
+#define rtsp_print _bsd_tcpdump_rtsp_print
+/* print-rx.c */
+#define rx_print _bsd_tcpdump_rx_print
+/* print-sctp.c */
+#define sctp_print _bsd_tcpdump_sctp_print
+/* print-sflow.c */
+#define sflow_print _bsd_tcpdump_sflow_print
+/* print-sip.c */
+#define sip_print _bsd_tcpdump_sip_print
+/* print-sl.c */
+#define sl_bsdos_if_print _bsd_tcpdump_sl_bsdos_if_print
+#define sl_if_print _bsd_tcpdump_sl_if_print
+/* print-sll.c */
+#define sll_if_print _bsd_tcpdump_sll_if_print
+/* print-slow.c */
+#define slow_print _bsd_tcpdump_slow_print
+/* print-smb.c */
+#define startbuf _bsd_tcpdump_startbuf
+#define ipx_netbios_print _bsd_tcpdump_ipx_netbios_print
+#define netbeui_print _bsd_tcpdump_netbeui_print
+#define nbt_udp138_print _bsd_tcpdump_nbt_udp138_print
+#define smb_tcp_print _bsd_tcpdump_smb_tcp_print
+#define nbt_udp137_print _bsd_tcpdump_nbt_udp137_print
+#define nbt_tcp_print _bsd_tcpdump_nbt_tcp_print
+/* print-smtp.c */
+#define smtp_print _bsd_tcpdump_smtp_print
+/* print-snmp.c */
+#define snmp_print _bsd_tcpdump_snmp_print
+/* print-stp.c */
+#define stp_print _bsd_tcpdump_stp_print
+/* print-sunatm.c */
+#define sunatm_if_print _bsd_tcpdump_sunatm_if_print
+/* print-symantec.c */
+#define symantec_if_print _bsd_tcpdump_symantec_if_print
+/* print-syslog.c */
+#define syslog_print _bsd_tcpdump_syslog_print
+/* print-tcp.c */
+#define tcp_print _bsd_tcpdump_tcp_print
+/* print-telnet.c */
+#define telnet_print _bsd_tcpdump_telnet_print
+/* print-tftp.c */
+#define tftp_print _bsd_tcpdump_tftp_print
+/* print-timed.c */
+#define timed_print _bsd_tcpdump_timed_print
+/* print-tipc.c */
+#define tipc_print _bsd_tcpdump_tipc_print
+/* print-token.c */
+#define token_if_print _bsd_tcpdump_token_if_print
+#define token_print _bsd_tcpdump_token_print
+/* print-udld.c */
+#define udld_print _bsd_tcpdump_udld_print
+/* print-udp.c */
+#define udp_print _bsd_tcpdump_udp_print
+/* print-usb.c */
+/* print-vjc.c */
+#define vjc_print _bsd_tcpdump_vjc_print
+/* print-vqp.c */
+#define vqp_print _bsd_tcpdump_vqp_print
+/* print-vrrp.c */
+#define vrrp_print _bsd_tcpdump_vrrp_print
+/* print-vtp.c */
+#define vtp_print _bsd_tcpdump_vtp_print
+/* print-vxlan.c */
+#define vxlan_print _bsd_tcpdump_vxlan_print
+/* print-vxlan-gpe.c */
+#define vxlan_gpe_print _bsd_tcpdump_vxlan_gpe_print
+/* print-wb.c */
+#define wb_print _bsd_tcpdump_wb_print
+/* print-zephyr.c */
+#define zephyr_print _bsd_tcpdump_zephyr_print
+/* print-zeromq.c */
+#define zmtp1_print_datagram _bsd_tcpdump_zmtp1_print_datagram
+#define zmtp1_print _bsd_tcpdump_zmtp1_print
+/* setsignal.c */
+#define setsignal _bsd_tcpdump_setsignal
+/* signature.c */
+#define signature_verify _bsd_tcpdump_signature_verify
+/* smbutil.c */
+#define nt_errstr _bsd_tcpdump_nt_errstr
+#define smb_errstr _bsd_tcpdump_smb_errstr
+#define smb_fdata _bsd_tcpdump_smb_fdata
+#define smb_print_data _bsd_tcpdump_smb_print_data
+/* tcpdump.c */
+#define program_name _bsd_tcpdump_program_name
+#define requestinfo _bsd_tcpdump_requestinfo
+/* util-print.c */
+#define thiszone _bsd_tcpdump_thiszone
+#define safeputchar _bsd_tcpdump_safeputchar
+#define safeputs _bsd_tcpdump_safeputs
+#define txtproto_print _bsd_tcpdump_txtproto_print
+#define mask62plen _bsd_tcpdump_mask62plen
+#define mask2plen _bsd_tcpdump_mask2plen
+#define tok2strary_internal _bsd_tcpdump_tok2strary_internal
+#define bittok2str _bsd_tcpdump_bittok2str
+#define bittok2str_nosep _bsd_tcpdump_bittok2str_nosep
+#define tok2str _bsd_tcpdump_tok2str
+#define tok2strbuf _bsd_tcpdump_tok2strbuf
+#define print_unknown_data _bsd_tcpdump_print_unknown_data
+#define signed_relts_print _bsd_tcpdump_signed_relts_print
+#define unsigned_relts_print _bsd_tcpdump_unsigned_relts_print
+#define ts_print _bsd_tcpdump_ts_print
+#define fn_printzp _bsd_tcpdump_fn_printzp
+#define fn_printn _bsd_tcpdump_fn_printn
+#define fn_printztn _bsd_tcpdump_fn_printztn
+#define fn_print _bsd_tcpdump_fn_print
+#define fn_print_char _bsd_tcpdump_fn_print_char
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-netdissect-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-netdissect-data.h
new file mode 100644
index 00000000..0e550fca
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-netdissect-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* netdissect.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-nlpid-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-nlpid-data.h
new file mode 100644
index 00000000..95043d98
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-nlpid-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* nlpid.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-oui-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-oui-data.h
new file mode 100644
index 00000000..1318f667
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-oui-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* oui.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-parsenfsfh-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-parsenfsfh-data.h
new file mode 100644
index 00000000..412db2c4
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-parsenfsfh-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* parsenfsfh.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-802_11-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-802_11-data.h
new file mode 100644
index 00000000..a9f3e626
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-802_11-data.h
@@ -0,0 +1,7 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-802_11.c */
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *auth_alg_text[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *status_text[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *reason_text[]);
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-802_15_4-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-802_15_4-data.h
new file mode 100644
index 00000000..1c0899db
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-802_15_4-data.h
@@ -0,0 +1,5 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-802_15_4.c */
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *ftypes[]);
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ah-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ah-data.h
new file mode 100644
index 00000000..680bbe30
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ah-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-ah.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ahcp-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ahcp-data.h
new file mode 100644
index 00000000..4943da0f
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ahcp-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-ahcp.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-aodv-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-aodv-data.h
new file mode 100644
index 00000000..2d293bca
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-aodv-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-aodv.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-aoe-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-aoe-data.h
new file mode 100644
index 00000000..5942b7f7
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-aoe-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-aoe.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ap1394-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ap1394-data.h
new file mode 100644
index 00000000..9cd8d59f
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ap1394-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-ap1394.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-arcnet-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-arcnet-data.h
new file mode 100644
index 00000000..cd54c2a6
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-arcnet-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-arcnet.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-arp-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-arp-data.h
new file mode 100644
index 00000000..344bb187
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-arp-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-arp.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ascii-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ascii-data.h
new file mode 100644
index 00000000..0146fc3a
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ascii-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-ascii.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-atalk-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-atalk-data.h
new file mode 100644
index 00000000..415484ba
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-atalk-data.h
@@ -0,0 +1,5 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-atalk.c */
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct hnamemem hnametable[]);
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-atm-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-atm-data.h
new file mode 100644
index 00000000..c2c7c625
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-atm-data.h
@@ -0,0 +1,5 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-atm.c */
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct tok const *oam_functype_values[]);
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-babel-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-babel-data.h
new file mode 100644
index 00000000..4cb52478
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-babel-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-babel.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-beep-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-beep-data.h
new file mode 100644
index 00000000..106cf2ca
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-beep-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-beep.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-bfd-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-bfd-data.h
new file mode 100644
index 00000000..e63926e1
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-bfd-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-bfd.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-bgp-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-bgp-data.h
new file mode 100644
index 00000000..2c5323a8
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-bgp-data.h
@@ -0,0 +1,5 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-bgp.c */
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char astostr[]);
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-bootp-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-bootp-data.h
new file mode 100644
index 00000000..db4377b1
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-bootp-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-bootp.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-bt-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-bt-data.h
new file mode 100644
index 00000000..10980924
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-bt-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-bt.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-calm-fast-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-calm-fast-data.h
new file mode 100644
index 00000000..00be757c
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-calm-fast-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-calm-fast.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-carp-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-carp-data.h
new file mode 100644
index 00000000..7f5a3b06
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-carp-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-carp.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-cdp-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-cdp-data.h
new file mode 100644
index 00000000..e9aaca1d
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-cdp-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-cdp.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-cfm-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-cfm-data.h
new file mode 100644
index 00000000..17c5ac64
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-cfm-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-cfm.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-chdlc-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-chdlc-data.h
new file mode 100644
index 00000000..b0aca111
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-chdlc-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-chdlc.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-cip-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-cip-data.h
new file mode 100644
index 00000000..c496d1a2
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-cip-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-cip.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-cnfp-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-cnfp-data.h
new file mode 100644
index 00000000..65b9ea4e
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-cnfp-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-cnfp.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-data.h
new file mode 100644
index 00000000..5f6557fc
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-dccp-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-dccp-data.h
new file mode 100644
index 00000000..d730569a
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-dccp-data.h
@@ -0,0 +1,6 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-dccp.c */
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *dccp_reset_codes[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *dccp_feature_nums[]);
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-decnet-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-decnet-data.h
new file mode 100644
index 00000000..87433d8a
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-decnet-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-decnet.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-dhcp6-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-dhcp6-data.h
new file mode 100644
index 00000000..363a450e
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-dhcp6-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-dhcp6.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-domain-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-domain-data.h
new file mode 100644
index 00000000..6f37a933
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-domain-data.h
@@ -0,0 +1,6 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-domain.c */
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *ns_ops[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *ns_resp[]);
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-dtp-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-dtp-data.h
new file mode 100644
index 00000000..673d7f0e
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-dtp-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-dtp.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-dvmrp-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-dvmrp-data.h
new file mode 100644
index 00000000..1ea6e8ee
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-dvmrp-data.h
@@ -0,0 +1,5 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-dvmrp.c */
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static uint32_t target_level);
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-eap-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-eap-data.h
new file mode 100644
index 00000000..2970840c
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-eap-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-eap.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-egp-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-egp-data.h
new file mode 100644
index 00000000..44372751
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-egp-data.h
@@ -0,0 +1,9 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-egp.c */
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *egp_acquire_codes[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *egp_acquire_status[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *egp_reach_codes[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *egp_status_updown[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *egp_reasons[]);
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-eigrp-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-eigrp-data.h
new file mode 100644
index 00000000..d025bde0
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-eigrp-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-eigrp.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-enc-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-enc-data.h
new file mode 100644
index 00000000..b8595793
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-enc-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-enc.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-esp-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-esp-data.h
new file mode 100644
index 00000000..31c88dbf
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-esp-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-esp.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ether-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ether-data.h
new file mode 100644
index 00000000..e4569103
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ether-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-ether.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-fddi-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-fddi-data.h
new file mode 100644
index 00000000..d0d1ec15
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-fddi-data.h
@@ -0,0 +1,5 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-fddi.c */
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static int fddi_bitswap);
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-forces-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-forces-data.h
new file mode 100644
index 00000000..8994a9e5
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-forces-data.h
@@ -0,0 +1,5 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-forces.c */
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char ind_buf[]);
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-fr-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-fr-data.h
new file mode 100644
index 00000000..d9c68411
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-fr-data.h
@@ -0,0 +1,5 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-fr.c */
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct tok const *fr_q933_ie_codesets[]);
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-frag6-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-frag6-data.h
new file mode 100644
index 00000000..19b152c1
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-frag6-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-frag6.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ftp-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ftp-data.h
new file mode 100644
index 00000000..bd60fad6
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ftp-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-ftp.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-geneve-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-geneve-data.h
new file mode 100644
index 00000000..1b82950a
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-geneve-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-geneve.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-geonet-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-geonet-data.h
new file mode 100644
index 00000000..208f1e1c
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-geonet-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-geonet.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-gre-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-gre-data.h
new file mode 100644
index 00000000..12e9b635
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-gre-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-gre.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-hncp-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-hncp-data.h
new file mode 100644
index 00000000..9f2c9dbc
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-hncp-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-hncp.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-hsrp-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-hsrp-data.h
new file mode 100644
index 00000000..ee431e92
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-hsrp-data.h
@@ -0,0 +1,5 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-hsrp.c */
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *op_code_str[]);
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-http-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-http-data.h
new file mode 100644
index 00000000..894ac0f5
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-http-data.h
@@ -0,0 +1,5 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-http.c */
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *httpcmds[]);
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-icmp-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-icmp-data.h
new file mode 100644
index 00000000..9c5d5fbb
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-icmp-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-icmp.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-icmp6-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-icmp6-data.h
new file mode 100644
index 00000000..42fff37d
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-icmp6-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-icmp6.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-igmp-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-igmp-data.h
new file mode 100644
index 00000000..f85fa55b
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-igmp-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-igmp.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-igrp-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-igrp-data.h
new file mode 100644
index 00000000..686a7af6
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-igrp-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-igrp.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ip-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ip-data.h
new file mode 100644
index 00000000..b231f4f1
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ip-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-ip.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ip6-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ip6-data.h
new file mode 100644
index 00000000..84dedca3
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ip6-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-ip6.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ip6opts-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ip6opts-data.h
new file mode 100644
index 00000000..1e210f4a
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ip6opts-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-ip6opts.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ipcomp-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ipcomp-data.h
new file mode 100644
index 00000000..4f13eb36
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ipcomp-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-ipcomp.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ipfc-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ipfc-data.h
new file mode 100644
index 00000000..5496cf6a
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ipfc-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-ipfc.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ipnet-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ipnet-data.h
new file mode 100644
index 00000000..bbf0d867
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ipnet-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-ipnet.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ipx-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ipx-data.h
new file mode 100644
index 00000000..1e69b950
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ipx-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-ipx.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-isakmp-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-isakmp-data.h
new file mode 100644
index 00000000..4aa898a0
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-isakmp-data.h
@@ -0,0 +1,19 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-isakmp.c */
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static int ninitiator);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct cookiecache cookiecache[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *protoidstr[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *npstr[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static u_char const *(*npfunc[])(netdissect_options *, u_char , struct isakmp_gen const *, u_int , u_char const *, uint32_t , uint32_t , uint32_t , int ));
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *etypestr[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *ikev1_p_map[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *ikev2_t_type_map[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *ah_p_map[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *prf_p_map[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *integ_p_map[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *esn_p_map[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *dh_p_map[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *esp_p_map[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *ipcomp_p_map[]);
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-isoclns-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-isoclns-data.h
new file mode 100644
index 00000000..9d18d340
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-isoclns-data.h
@@ -0,0 +1,5 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-isoclns.c */
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct tok const *clnp_option_rfd_error_class[]);
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-juniper-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-juniper-data.h
new file mode 100644
index 00000000..e3a62b36
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-juniper-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-juniper.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-krb-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-krb-data.h
new file mode 100644
index 00000000..3842b41c
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-krb-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-krb.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-l2tp-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-l2tp-data.h
new file mode 100644
index 00000000..f91fbc85
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-l2tp-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-l2tp.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-lane-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-lane-data.h
new file mode 100644
index 00000000..ed43dd66
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-lane-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-lane.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ldp-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ldp-data.h
new file mode 100644
index 00000000..7e8c0c4b
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ldp-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-ldp.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-lisp-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-lisp-data.h
new file mode 100644
index 00000000..5e703a76
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-lisp-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-lisp.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-llc-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-llc-data.h
new file mode 100644
index 00000000..3295e02f
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-llc-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-llc.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-lldp-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-lldp-data.h
new file mode 100644
index 00000000..cf59366a
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-lldp-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-lldp.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-lmp-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-lmp-data.h
new file mode 100644
index 00000000..4ed5fc3b
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-lmp-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-lmp.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-loopback-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-loopback-data.h
new file mode 100644
index 00000000..dd3833d7
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-loopback-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-loopback.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-lspping-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-lspping-data.h
new file mode 100644
index 00000000..4d626b5d
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-lspping-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-lspping.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-lwapp-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-lwapp-data.h
new file mode 100644
index 00000000..e23d652a
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-lwapp-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-lwapp.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-lwres-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-lwres-data.h
new file mode 100644
index 00000000..6df9c567
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-lwres-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-lwres.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-m3ua-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-m3ua-data.h
new file mode 100644
index 00000000..7a9651d1
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-m3ua-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-m3ua.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-medsa-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-medsa-data.h
new file mode 100644
index 00000000..cab01850
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-medsa-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-medsa.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-mobile-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-mobile-data.h
new file mode 100644
index 00000000..b492a302
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-mobile-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-mobile.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-mobility-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-mobility-data.h
new file mode 100644
index 00000000..a39a8176
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-mobility-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-mobility.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-mpcp-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-mpcp-data.h
new file mode 100644
index 00000000..ce98b36e
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-mpcp-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-mpcp.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-mpls-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-mpls-data.h
new file mode 100644
index 00000000..94456f34
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-mpls-data.h
@@ -0,0 +1,5 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-mpls.c */
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *mpls_labelname[]);
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-mptcp-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-mptcp-data.h
new file mode 100644
index 00000000..eca42642
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-mptcp-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-mptcp.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-msdp-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-msdp-data.h
new file mode 100644
index 00000000..cefe8855
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-msdp-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-msdp.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-msnlb-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-msnlb-data.h
new file mode 100644
index 00000000..f26fd0ea
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-msnlb-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-msnlb.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-nfs-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-nfs-data.h
new file mode 100644
index 00000000..5e611d31
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-nfs-data.h
@@ -0,0 +1,9 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-nfs.c */
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static uint32_t nfsv3_procid[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static int nfserr);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct xid_map_entry xid_map[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static int xid_map_next);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static int xid_map_hint);
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-nsh-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-nsh-data.h
new file mode 100644
index 00000000..e9abab8c
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-nsh-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-nsh.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ntp-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ntp-data.h
new file mode 100644
index 00000000..b017b76b
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ntp-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-ntp.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-null-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-null-data.h
new file mode 100644
index 00000000..0d3621ba
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-null-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-null.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-olsr-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-olsr-data.h
new file mode 100644
index 00000000..5673481c
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-olsr-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-olsr.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-openflow-1.0-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-openflow-1.0-data.h
new file mode 100644
index 00000000..6db8e001
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-openflow-1.0-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-openflow-1.0.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-openflow-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-openflow-data.h
new file mode 100644
index 00000000..92d57eff
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-openflow-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-openflow.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ospf-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ospf-data.h
new file mode 100644
index 00000000..853b5a9d
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ospf-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-ospf.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ospf6-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ospf6-data.h
new file mode 100644
index 00000000..3c2ed4ba
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ospf6-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-ospf6.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-otv-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-otv-data.h
new file mode 100644
index 00000000..a947c6b7
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-otv-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-otv.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-pflog-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-pflog-data.h
new file mode 100644
index 00000000..77bba9f5
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-pflog-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-pflog.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-pfsync-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-pfsync-data.h
new file mode 100644
index 00000000..bfd6e61e
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-pfsync-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-pfsync.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-pgm-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-pgm-data.h
new file mode 100644
index 00000000..5e69e17f
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-pgm-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-pgm.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-pim-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-pim-data.h
new file mode 100644
index 00000000..c19c1b5d
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-pim-data.h
@@ -0,0 +1,5 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-pim.c */
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static int pimv2_addr_len);
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-pktap-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-pktap-data.h
new file mode 100644
index 00000000..1ae5b914
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-pktap-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-pktap.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ppi-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ppi-data.h
new file mode 100644
index 00000000..c2fe2cbd
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ppi-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-ppi.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ppp-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ppp-data.h
new file mode 100644
index 00000000..d4c854af
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ppp-data.h
@@ -0,0 +1,5 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-ppp.c */
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *lcpconfopts[]);
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-pppoe-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-pppoe-data.h
new file mode 100644
index 00000000..c2768e10
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-pppoe-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-pppoe.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-pptp-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-pptp-data.h
new file mode 100644
index 00000000..3f9aab88
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-pptp-data.h
@@ -0,0 +1,5 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-pptp.c */
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *pptp_message_type_string[]);
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-radius-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-radius-data.h
new file mode 100644
index 00000000..3d47dc1b
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-radius-data.h
@@ -0,0 +1,20 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-radius.c */
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *serv_type[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *frm_proto[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *frm_routing[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *frm_comp[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *login_serv[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *term_action[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *ingress_filters[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *nas_port_type[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *acct_status[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *acct_auth[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *acct_term[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *tunnel_type[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *tunnel_medium[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *arap_zone[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *prompt[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct attrtype attr_type[]);
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-raw-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-raw-data.h
new file mode 100644
index 00000000..ba6a137c
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-raw-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-raw.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-resp-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-resp-data.h
new file mode 100644
index 00000000..216c7bad
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-resp-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-resp.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-rip-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-rip-data.h
new file mode 100644
index 00000000..a136489a
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-rip-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-rip.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ripng-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ripng-data.h
new file mode 100644
index 00000000..06c6d7b5
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-ripng-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-ripng.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-rpki-rtr-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-rpki-rtr-data.h
new file mode 100644
index 00000000..ffbfaea1
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-rpki-rtr-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-rpki-rtr.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-rrcp-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-rrcp-data.h
new file mode 100644
index 00000000..77c67c57
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-rrcp-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-rrcp.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-rsvp-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-rsvp-data.h
new file mode 100644
index 00000000..169ac364
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-rsvp-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-rsvp.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-rt6-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-rt6-data.h
new file mode 100644
index 00000000..33f2f364
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-rt6-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-rt6.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-rtsp-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-rtsp-data.h
new file mode 100644
index 00000000..9d482d15
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-rtsp-data.h
@@ -0,0 +1,5 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-rtsp.c */
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *rtspcmds[]);
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-rx-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-rx-data.h
new file mode 100644
index 00000000..adb33632
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-rx-data.h
@@ -0,0 +1,8 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-rx.c */
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *voltype[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct rx_cache_entry rx_cache[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static int rx_cache_next);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static int rx_cache_hint);
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-sctp-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-sctp-data.h
new file mode 100644
index 00000000..31177227
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-sctp-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-sctp.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-sflow-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-sflow-data.h
new file mode 100644
index 00000000..b541caed
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-sflow-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-sflow.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-sip-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-sip-data.h
new file mode 100644
index 00000000..39f7aaa1
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-sip-data.h
@@ -0,0 +1,5 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-sip.c */
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *sipcmds[]);
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-sl-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-sl-data.h
new file mode 100644
index 00000000..099ebd96
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-sl-data.h
@@ -0,0 +1,6 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-sl.c */
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static u_int lastlen[][256]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static u_int lastconn);
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-sll-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-sll-data.h
new file mode 100644
index 00000000..1e483da3
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-sll-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-sll.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-slow-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-slow-data.h
new file mode 100644
index 00000000..a1090b05
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-slow-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-slow.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-smb-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-smb-data.h
new file mode 100644
index 00000000..8e3e328b
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-smb-data.h
@@ -0,0 +1,7 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-smb.c */
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static int request);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static int unicodestr);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct nbf_strings nbf_strings[]);
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-smtp-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-smtp-data.h
new file mode 100644
index 00000000..317d30f9
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-smtp-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-smtp.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-snmp-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-snmp-data.h
new file mode 100644
index 00000000..552285a7
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-snmp-data.h
@@ -0,0 +1,377 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-snmp.c */
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *Universal[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *Application[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *Context[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *Exceptions[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *Private[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *ErrorStatus[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *GenericTrap[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *Form[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj *objp);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _proteon_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ibm_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _cmu_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _unix_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _acc_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _twg_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _cayman_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _nysernet_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _cisco_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _nsc_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _hp_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _epilogue_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _utennessee_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _bbn_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _xylogics_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _unisys_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _canstar_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _wellfleet_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _trw_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _mit_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _eon_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _spartacus_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _excelan_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _spider_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _nsfnet_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _sytek_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _intergraph_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _interlan_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _vitalink_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ulana_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _nswc_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _santacruzoperation_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _xyplex_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _cray_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _bellnorthernresearch_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _dec_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _touch_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _networkresearchcorp_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _baylor_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _nmfeccllnl_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _sri_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _sun_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _3com_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _cmc_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _synoptics_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _cheyenne_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _prime_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _mcnc_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _chipcom_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _opticaldatasystems_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _gated_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _cabletron_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _apollo_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _desktalksystems_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ssds_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _castlerock_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _mips_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _tgv_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _silicongraphics_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ubc_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _merit_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _fibercom_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _apple_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _gandalf_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _dartmouth_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _davidsystems_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _reuter_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _cornell_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _tmac_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _locus_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _nasa_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _retix_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _boeing_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _att_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ungermannbass_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _digitalanalysis_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _hplanman_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _netlabs_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _icl_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _auspex_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _lannet_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ncd_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _raycom_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _pirellifocom_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _datability_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _networkappltech_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _link_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _nyu_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _rnd_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _intercon_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _learningtree_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _webstercomputer_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _frontier_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _nokia_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _allenbradley_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _cern_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _sigma_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _emergingtech_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _snmpresearch_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ohiostate_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ultra_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ccur_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _enterprises_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _snmpInPkts_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _snmpOutPkts_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _snmpInBadVersions_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _snmpInBadCommunityNames_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _snmpInBadCommunityUses_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _snmpInASNParseErrs_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _snmpInBadTypes_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _snmpInTooBigs_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _snmpInNoSuchNames_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _snmpInBadValues_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _snmpInReadOnlys_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _snmpInGenErrs_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _snmpInTotalReqVars_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _snmpInTotalSetVars_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _snmpInGetRequests_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _snmpInGetNexts_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _snmpInSetRequests_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _snmpInGetResponses_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _snmpInTraps_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _snmpOutTooBigs_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _snmpOutNoSuchNames_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _snmpOutBadValues_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _snmpOutReadOnlys_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _snmpOutGenErrs_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _snmpOutGetRequests_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _snmpOutGetNexts_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _snmpOutSetRequests_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _snmpOutGetResponses_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _snmpOutTraps_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _snmpEnableAuthTraps_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _egpNeighState_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _egpNeighAddr_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _egpNeighAs_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _egpNeighInMsgs_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _egpNeighInErrs_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _egpNeighOutMsgs_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _egpNeighOutErrs_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _egpNeighInErrMsgs_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _egpNeighOutErrMsgs_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _egpNeighStateUps_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _egpNeighStateDowns_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _egpNeighIntervalHello_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _egpNeighIntervalPoll_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _egpNeighMode_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _egpNeighEventTrigger_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _egpNeighEntry_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _egpInMsgs_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _egpInErrors_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _egpOutMsgs_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _egpOutErrors_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _egpNeighTable_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _egpAs_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _udpLocalAddress_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _udpLocalPort_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _udpEntry_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _udpInDatagrams_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _udpNoPorts_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _udpInErrors_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _udpOutDatagrams_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _udpTable_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _tcpConnState_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _tcpConnLocalAddress_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _tcpConnLocalPort_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _tcpConnRemAddress_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _tcpConnRemPort_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _tcpConnEntry_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _tcpRtoAlgorithm_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _tcpRtoMin_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _tcpRtoMax_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _tcpMaxConn_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _tcpActiveOpens_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _tcpPassiveOpens_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _tcpAttemptFails_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _tcpEstabResets_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _tcpCurrEstab_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _tcpInSegs_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _tcpOutSegs_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _tcpRetransSegs_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _tcpConnTable_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _tcpInErrs_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _tcpOutRsts_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _icmpInMsgs_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _icmpInErrors_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _icmpInDestUnreachs_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _icmpInTimeExcds_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _icmpInParmProbs_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _icmpInSrcQuenchs_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _icmpInRedirects_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _icmpInEchos_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _icmpInEchoReps_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _icmpInTimestamps_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _icmpInTimestampReps_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _icmpInAddrMasks_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _icmpInAddrMaskReps_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _icmpOutMsgs_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _icmpOutErrors_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _icmpOutDestUnreachs_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _icmpOutTimeExcds_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _icmpOutParmProbs_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _icmpOutSrcQuenchs_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _icmpOutRedirects_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _icmpOutEchos_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _icmpOutEchoReps_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _icmpOutTimestamps_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _icmpOutTimestampReps_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _icmpOutAddrMasks_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _icmpOutAddrMaskReps_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ipNetToMediaIfIndex_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ipNetToMediaPhysAddress_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ipNetToMediaNetAddress_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ipNetToMediaType_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ipNetToMediaEntry_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ipRouteDest_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ipRouteIfIndex_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ipRouteMetric1_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ipRouteMetric2_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ipRouteMetric3_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ipRouteMetric4_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ipRouteNextHop_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ipRouteType_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ipRouteProto_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ipRouteAge_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ipRouteMask_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ipRouteEntry_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ipAdEntAddr_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ipAdEntIfIndex_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ipAdEntNetMask_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ipAdEntBcastAddr_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ipAdEntReasmMaxSize_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ipAddrEntry_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ipForwarding_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ipDefaultTTL_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ipInReceives_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ipInHdrErrors_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ipInAddrErrors_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ipForwDatagrams_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ipInUnknownProtos_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ipInDiscards_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ipInDelivers_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ipOutRequests_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ipOutDiscards_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ipOutNoRoutes_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ipReasmTimeout_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ipReasmReqds_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ipReasmOKs_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ipReasmFails_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ipFragOKs_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ipFragFails_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ipFragCreates_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ipAddrTable_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ipRoutingTable_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ipNetToMediaTable_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _atIfIndex_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _atPhysAddress_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _atNetAddress_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _atEntry_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _atTable_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ifIndex_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ifDescr_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ifType_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ifMtu_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ifSpeed_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ifPhysAddress_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ifAdminStatus_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ifOperStatus_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ifLastChange_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ifInOctets_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ifInUcastPkts_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ifInNUcastPkts_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ifInDiscards_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ifInErrors_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ifInUnknownProtos_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ifOutOctets_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ifOutUcastPkts_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ifOutNUcastPkts_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ifOutDiscards_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ifOutErrors_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ifOutQLen_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ifSpecific_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ifEntry_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ifNumber_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ifTable_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _sysDescr_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _sysObjectID_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _sysUpTime_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _sysContact_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _sysName_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _sysLocation_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _sysServices_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _system_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _interfaces_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _at_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _ip_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _icmp_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _tcp_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _udp_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _egp_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _transmission_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _snmp_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _usmMIBCompliances_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _usmMIBGroups_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _usmUserEngineID_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _usmUserName_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _usmUserSecurityName_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _usmUserCloneFrom_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _usmUserAuthProtocol_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _usmUserAuthKeyChange_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _usmUserOwnAuthKeyChange_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _usmUserPrivProtocol_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _usmUserPrivKeyChange_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _usmUserOwnPrivKeyChange_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _usmUserPublic_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _usmUserStorageType_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _usmUserStatus_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _usmUserEntry_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _usmUserSpinLock_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _usmUserTable_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _usmStatsUnsupportedSecLevels_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _usmStatsNotInTimeWindows_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _usmStatsUnknownUserNames_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _usmStatsUnknownEngineIDs_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _usmStatsWrongDigests_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _usmStatsDecryptionErrors_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _usmStats_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _usmUser_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _usmMIBObjects_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _usmMIBConformance_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _snmpMPDMIBCompliances_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _snmpMPDMIBGroups_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _snmpUnknownSecurityModels_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _snmpInvalidMsgs_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _snmpUnknownPDUHandlers_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _snmpMPDStats_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _snmpMPDAdmin_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _snmpMPDMIBObjects_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _snmpMPDMIBConformance_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _snmpEngineID_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _snmpEngineBoots_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _snmpEngineTime_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _snmpEngineMaxMessageSize_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _snmpEngine_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _snmpFrameworkAdmin_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _snmpFrameworkMIBObjects_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _snmpFrameworkMIBConformance_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _snmpFrameworkMIB_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _snmpMPDMIB_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _snmpUsmMIB_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _snmpModules_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _mib_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _directory_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _mgmt_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _experimental_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _private_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _security_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _snmpV2_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _internet_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _dod_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _org_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj _iso_obj);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct obj *mibroot);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *SnmpVersion[]);
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-stp-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-stp-data.h
new file mode 100644
index 00000000..23b66267
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-stp-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-stp.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-sunatm-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-sunatm-data.h
new file mode 100644
index 00000000..b64f1fc3
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-sunatm-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-sunatm.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-symantec-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-symantec-data.h
new file mode 100644
index 00000000..55f8d1ee
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-symantec-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-symantec.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-syslog-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-syslog-data.h
new file mode 100644
index 00000000..9f1ca063
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-syslog-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-syslog.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-tcp-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-tcp-data.h
new file mode 100644
index 00000000..e0e60e32
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-tcp-data.h
@@ -0,0 +1,6 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-tcp.c */
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct tcp_seq_hash tcp_seq_hash4[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static struct tcp_seq_hash6 tcp_seq_hash6[]);
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-telnet-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-telnet-data.h
new file mode 100644
index 00000000..0f39acf8
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-telnet-data.h
@@ -0,0 +1,11 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-telnet.c */
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *telcmds[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *telopts[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *cmds[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *authcmd[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *authtype[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *enccmd[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *enctype[]);
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-tftp-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-tftp-data.h
new file mode 100644
index 00000000..57ea0595
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-tftp-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-tftp.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-timed-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-timed-data.h
new file mode 100644
index 00000000..b212b8ea
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-timed-data.h
@@ -0,0 +1,5 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-timed.c */
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *tsptype[]);
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-tipc-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-tipc-data.h
new file mode 100644
index 00000000..0ec9b395
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-tipc-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-tipc.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-token-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-token-data.h
new file mode 100644
index 00000000..bad0c9c8
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-token-data.h
@@ -0,0 +1,7 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-token.c */
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *broadcast_indicator[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *direction[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *largest_frame[]);
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-udld-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-udld-data.h
new file mode 100644
index 00000000..7fd27654
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-udld-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-udld.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-udp-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-udp-data.h
new file mode 100644
index 00000000..472a302c
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-udp-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-udp.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-usb-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-usb-data.h
new file mode 100644
index 00000000..72143c88
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-usb-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-usb.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-vjc-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-vjc-data.h
new file mode 100644
index 00000000..73c111e2
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-vjc-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-vjc.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-vqp-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-vqp-data.h
new file mode 100644
index 00000000..3fa24f7b
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-vqp-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-vqp.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-vrrp-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-vrrp-data.h
new file mode 100644
index 00000000..31ceab8d
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-vrrp-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-vrrp.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-vtp-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-vtp-data.h
new file mode 100644
index 00000000..b1cac76d
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-vtp-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-vtp.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-vxlan-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-vxlan-data.h
new file mode 100644
index 00000000..fe594157
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-vxlan-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-vxlan.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-vxlan-gpe-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-vxlan-gpe-data.h
new file mode 100644
index 00000000..4bba1862
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-vxlan-gpe-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-vxlan-gpe.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-wb-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-wb-data.h
new file mode 100644
index 00000000..d3b73134
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-wb-data.h
@@ -0,0 +1,5 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-wb.c */
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char const *dopstr[]);
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-zephyr-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-zephyr-data.h
new file mode 100644
index 00000000..57b037ba
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-zephyr-data.h
@@ -0,0 +1,5 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-zephyr.c */
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char z_buf[]);
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-zeromq-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-zeromq-data.h
new file mode 100644
index 00000000..d5a40993
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-print-zeromq-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* print-zeromq.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-setsignal-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-setsignal-data.h
new file mode 100644
index 00000000..ca91caf2
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-setsignal-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* setsignal.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-signature-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-signature-data.h
new file mode 100644
index 00000000..5cbcf18f
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-signature-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* signature.c */
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-smbutil-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-smbutil-data.h
new file mode 100644
index 00000000..a9ed9204
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-smbutil-data.h
@@ -0,0 +1,5 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* smbutil.c */
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static uint32_t stringlen);
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-tcpdump-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-tcpdump-data.h
new file mode 100644
index 00000000..3fcdc24f
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-tcpdump-data.h
@@ -0,0 +1,28 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* tcpdump.c */
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static int Bflag);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static int Cflag);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static int Cflag_count);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static int Dflag);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static int dflag);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static int Gflag);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static int Gflag_count);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static time_t Gflag_time);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static int Lflag);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static int Iflag);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static int Jflag);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static int jflag);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static int pflag);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static int Qflag);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static int Uflag);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static int Wflag);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static int WflagChars);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static char *zflag);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static int immediate_mode);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static int infodelay);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static int infoprint);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static u_int packets_captured);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static pcap_t *pd);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_tcpdump, static int supports_monitor_mode);
diff --git a/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-util-print-data.h b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-util-print-data.h
new file mode 100644
index 00000000..82a2b538
--- /dev/null
+++ b/freebsd/contrib/tcpdump/rtems-bsd-tcpdump-util-print-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-tcpdump-data.h"
+/* util-print.c */
diff --git a/freebsd/contrib/tcpdump/rx.h b/freebsd/contrib/tcpdump/rx.h
deleted file mode 100644
index b79dd30c..00000000
--- a/freebsd/contrib/tcpdump/rx.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright: (c) 2000 United States Government as represented by the
- * Secretary of the Navy. All rights reserved.
- *
- * 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. The names of the authors may not be used to endorse or promote
- * products derived from this software without specific prior
- * written permission.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-/*
- * Rx protocol format
- *
- * $Id: rx.h,v 1.8 2002-12-11 07:14:11 guy Exp $
- */
-
-#define FS_RX_PORT 7000
-#define CB_RX_PORT 7001
-#define PROT_RX_PORT 7002
-#define VLDB_RX_PORT 7003
-#define KAUTH_RX_PORT 7004
-#define VOL_RX_PORT 7005
-#define ERROR_RX_PORT 7006 /* Doesn't seem to be used */
-#define BOS_RX_PORT 7007
-
-#ifndef AFSNAMEMAX
-#define AFSNAMEMAX 256
-#endif
-
-#ifndef AFSOPAQUEMAX
-#define AFSOPAQUEMAX 1024
-#endif
-
-#define PRNAMEMAX 64
-#define VLNAMEMAX 65
-#define KANAMEMAX 64
-#define BOSNAMEMAX 256
-
-#define PRSFS_READ 1 /* Read files */
-#define PRSFS_WRITE 2 /* Write files */
-#define PRSFS_INSERT 4 /* Insert files into a directory */
-#define PRSFS_LOOKUP 8 /* Lookup files into a directory */
-#define PRSFS_DELETE 16 /* Delete files */
-#define PRSFS_LOCK 32 /* Lock files */
-#define PRSFS_ADMINISTER 64 /* Change ACL's */
-
-struct rx_header {
- u_int32_t epoch;
- u_int32_t cid;
- u_int32_t callNumber;
- u_int32_t seq;
- u_int32_t serial;
- u_int8_t type;
-#define RX_PACKET_TYPE_DATA 1
-#define RX_PACKET_TYPE_ACK 2
-#define RX_PACKET_TYPE_BUSY 3
-#define RX_PACKET_TYPE_ABORT 4
-#define RX_PACKET_TYPE_ACKALL 5
-#define RX_PACKET_TYPE_CHALLENGE 6
-#define RX_PACKET_TYPE_RESPONSE 7
-#define RX_PACKET_TYPE_DEBUG 8
-#define RX_PACKET_TYPE_PARAMS 9
-#define RX_PACKET_TYPE_VERSION 13
- u_int8_t flags;
-#define RX_CLIENT_INITIATED 1
-#define RX_REQUEST_ACK 2
-#define RX_LAST_PACKET 4
-#define RX_MORE_PACKETS 8
-#define RX_FREE_PACKET 16
-#define RX_SLOW_START_OK 32
-#define RX_JUMBO_PACKET 32
- u_int8_t userStatus;
- u_int8_t securityIndex;
- u_int16_t spare; /* How clever: even though the AFS */
- u_int16_t serviceId; /* header files indicate that the */
-}; /* serviceId is first, it's really */
- /* encoded _after_ the spare field */
- /* I wasted a day figuring that out! */
-
-#define NUM_RX_FLAGS 7
-
-#define RX_MAXACKS 255
-
-struct rx_ackPacket {
- u_int16_t bufferSpace; /* Number of packet buffers available */
- u_int16_t maxSkew; /* Max diff between ack'd packet and */
- /* highest packet received */
- u_int32_t firstPacket; /* The first packet in ack list */
- u_int32_t previousPacket; /* Previous packet recv'd (obsolete) */
- u_int32_t serial; /* # of packet that prompted the ack */
- u_int8_t reason; /* Reason for acknowledgement */
- u_int8_t nAcks; /* Number of acknowledgements */
- u_int8_t acks[RX_MAXACKS]; /* Up to RX_MAXACKS acknowledgements */
-};
-
-/*
- * Values for the acks array
- */
-
-#define RX_ACK_TYPE_NACK 0 /* Don't have this packet */
-#define RX_ACK_TYPE_ACK 1 /* I have this packet */
diff --git a/freebsd/contrib/tcpdump/sctpConstants.h b/freebsd/contrib/tcpdump/sctpConstants.h
deleted file mode 100644
index ac28a151..00000000
--- a/freebsd/contrib/tcpdump/sctpConstants.h
+++ /dev/null
@@ -1,571 +0,0 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/sctpConstants.h,v 1.4 2003-06-03 23:49:23 guy Exp $ (LBL) */
-
-/* SCTP reference Implementation Copyright (C) 1999 Cisco And Motorola
- *
- * 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 Cisco nor of Motorola may be used
- * to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
- *
- * This file is part of the SCTP reference Implementation
- *
- *
- * Please send any bug reports or fixes you make to one of the following email
- * addresses:
- *
- * rstewar1@email.mot.com
- * kmorneau@cisco.com
- * qxie1@email.mot.com
- *
- * Any bugs reported given to us we will try to fix... any fixes shared will
- * be incorperated into the next SCTP release.
- */
-
-
-#ifndef __sctpConstants_h__
-#define __sctpConstants_h__
-
-
- /* If you wish to use MD5 instead of SLA uncomment the line
- * below. Why you would like to do this:
- * a) There may be IPR on SHA-1, or so the FIP-180-1 page says,
- * b) MD5 is 3 times faster (has coded here).
- *
- * The disadvantage is, it is thought that MD5 has been
- * cracked... see RFC2104.
- */
-/*#define USE_MD5 1*/
-
-/* the SCTP protocol signature
- * this includes the version number
- * encoded in the last 4 bits of the
- * signature.
- */
-#define PROTO_SIGNATURE_A 0x30000000
-
-#define SCTP_VERSION_NUMBER 0x3
-
-#define MAX_TSN 0xffffffff
-#define MAX_SEQ 0xffff
-
-/* option:
- * If you comment out the following you will
- * receive the old behavior of obeying cwnd for
- * the fast retransmit algorithm. With this defined
- * a FR happens right away with-out waiting for the
- * flightsize to drop below the cwnd value (which
- * is reduced by the FR to 1/2 the inflight packets).
- */
-#define SCTP_IGNORE_CWND_ON_FR 1
-/* default max I can burst out after a fast retransmit */
-#define SCTP_DEF_MAX_BURST 4
-
-/* Packet transmit states in the sent
- * field in the SCTP_transmitOnQueue struct
- */
-#define SCTP_DATAGRAM_UNSENT 0
-#define SCTP_DATAGRAM_SENT 1
-#define SCTP_DATAGRAM_RESEND1 2 /* not used */
-#define SCTP_DATAGRAM_RESEND2 3 /* not used */
-#define SCTP_DATAGRAM_RESEND3 4 /* not used */
-#define SCTP_DATAGRAM_RESEND 5
-#define SCTP_DATAGRAM_ACKED 10010
-#define SCTP_DATAGRAM_INBOUND 10011
-#define SCTP_READY_TO_TRANSMIT 10012
-#define SCTP_DATAGRAM_MARKED 20010
-
-#define MAX_FSID 64 /* debug 5 ints used for cc dynamic tracking */
-
-/* The valid defines for all message
- * types know to SCTP. 0 is reserved
- */
-#define SCTP_MSGTYPE_MASK 0xff
-
-#define SCTP_DATA 0x00
-#define SCTP_INITIATION 0x01
-#define SCTP_INITIATION_ACK 0x02
-#define SCTP_SELECTIVE_ACK 0x03
-#define SCTP_HEARTBEAT_REQUEST 0x04
-#define SCTP_HEARTBEAT_ACK 0x05
-#define SCTP_ABORT_ASSOCIATION 0x06
-#define SCTP_SHUTDOWN 0x07
-#define SCTP_SHUTDOWN_ACK 0x08
-#define SCTP_OPERATION_ERR 0x09
-#define SCTP_COOKIE_ECHO 0x0a
-#define SCTP_COOKIE_ACK 0x0b
-#define SCTP_ECN_ECHO 0x0c
-#define SCTP_ECN_CWR 0x0d
-#define SCTP_SHUTDOWN_COMPLETE 0x0e
-#define SCTP_FORWARD_CUM_TSN 0xc0
-#define SCTP_RELIABLE_CNTL 0xc1
-#define SCTP_RELIABLE_CNTL_ACK 0xc2
-
-/* ABORT and SHUTDOWN COMPLETE FLAG */
-#define SCTP_HAD_NO_TCB 0x01
-
-/* Data Chuck Specific Flags */
-#define SCTP_DATA_FRAG_MASK 0x03
-#define SCTP_DATA_MIDDLE_FRAG 0x00
-#define SCTP_DATA_LAST_FRAG 0x01
-#define SCTP_DATA_FIRST_FRAG 0x02
-#define SCTP_DATA_NOT_FRAG 0x03
-#define SCTP_DATA_UNORDERED 0x04
-
-#define SCTP_CRC_ENABLE_BIT 0x01 /* lower bit of reserved */
-
-#define isSCTPControl(a) (a->chunkID != SCTP_DATA)
-#define isSCTPData(a) (a->chunkID == SCTP_DATA)
-
-/* sctp parameter types for init/init-ack */
-
-#define SCTP_IPV4_PARAM_TYPE 0x0005
-#define SCTP_IPV6_PARAM_TYPE 0x0006
-#define SCTP_RESPONDER_COOKIE 0x0007
-#define SCTP_UNRECOG_PARAM 0x0008
-#define SCTP_COOKIE_PRESERVE 0x0009
-#define SCTP_HOSTNAME_VIA_DNS 0x000b
-#define SCTP_RESTRICT_ADDR_TO 0x000c
-
-#define SCTP_ECN_I_CAN_DO_ECN 0x8000
-#define SCTP_OPERATION_SUCCEED 0x4001
-#define SCTP_ERROR_NOT_EXECUTED 0x4002
-
-#define SCTP_UNRELIABLE_STRM 0xc000
-#define SCTP_ADD_IP_ADDRESS 0xc001
-#define SCTP_DEL_IP_ADDRESS 0xc002
-#define SCTP_STRM_FLOW_LIMIT 0xc003
-#define SCTP_PARTIAL_CSUM 0xc004
-#define SCTP_ERROR_CAUSE_TLV 0xc005
-#define SCTP_MIT_STACK_NAME 0xc006
-#define SCTP_SETADDRESS_PRIMARY 0xc007
-
-/* bits for TOS field */
-#define SCTP_ECT_BIT 0x02
-#define SCTP_CE_BIT 0x01
-
-/* error codes */
-#define SCTP_OP_ERROR_NO_ERROR 0x0000
-#define SCTP_OP_ERROR_INV_STRM 0x0001
-#define SCTP_OP_ERROR_MISS_PARAM 0x0002
-#define SCTP_OP_ERROR_STALE_COOKIE 0x0003
-#define SCTP_OP_ERROR_NO_RESOURCE 0x0004
-#define SCTP_OP_ERROR_DNS_FAILED 0x0005
-#define SCTP_OP_ERROR_UNK_CHUNK 0x0006
-#define SCTP_OP_ERROR_INV_PARAM 0x0007
-#define SCTP_OP_ERROR_UNK_PARAM 0x0008
-#define SCTP_OP_ERROR_NO_USERD 0x0009
-#define SCTP_OP_ERROR_COOKIE_SHUT 0x000a
-#define SCTP_OP_ERROR_DELETE_LAST 0x000b
-#define SCTP_OP_ERROR_RESOURCE_SHORT 0x000c
-
-#define SCTP_MAX_ERROR_CAUSE 12
-
-/* empty error causes i.e. nothing but the cause
- * are SCTP_OP_ERROR_NO_RESOURCE, SCTP_OP_ERROR_INV_PARAM,
- * SCTP_OP_ERROR_COOKIE_SHUT.
- */
-
-/* parameter for Heart Beat */
-#define HEART_BEAT_PARAM 0x0001
-
-
-
-/* send options for SCTP
- */
-#define SCTP_ORDERED_DELIVERY 0x01
-#define SCTP_NON_ORDERED_DELIVERY 0x02
-#define SCTP_DO_CRC16 0x08
-#define SCTP_MY_ADDRESS_ONLY 0x10
-
-/* below turns off above */
-#define SCTP_FLEXIBLE_ADDRESS 0x20
-#define SCTP_NO_HEARTBEAT 0x40
-
-/* mask to get sticky */
-#define SCTP_STICKY_OPTIONS_MASK 0x0c
-
-/* MTU discovery flags */
-#define SCTP_DONT_FRAGMENT 0x0100
-#define SCTP_FRAGMENT_OK 0x0200
-
-
-/* SCTP state defines for internal state machine */
-#define SCTP_STATE_EMPTY 0x0000
-#define SCTP_STATE_INUSE 0x0001
-#define SCTP_STATE_COOKIE_WAIT 0x0002
-#define SCTP_STATE_COOKIE_SENT 0x0004
-#define SCTP_STATE_OPEN 0x0008
-#define SCTP_STATE_SHUTDOWN 0x0010
-#define SCTP_STATE_SHUTDOWN_RECV 0x0020
-#define SCTP_STATE_SHUTDOWN_ACK_SENT 0x0040
-#define SCTP_STATE_SHUTDOWN_PEND 0x0080
-#define SCTP_STATE_MASK 0x007f
-/* SCTP reachability state for each address */
-#define SCTP_ADDR_NOT_REACHABLE 1
-#define SCTP_ADDR_REACHABLE 2
-#define SCTP_ADDR_NOHB 4
-#define SCTP_ADDR_BEING_DELETED 8
-
-/* How long a cookie lives */
-#define SCTP_DEFAULT_COOKIE_LIFE 60 /* seconds */
-
-/* resource limit of streams */
-#define MAX_SCTP_STREAMS 2048
-
-
-/* guess at how big to make the TSN mapping array */
-#define SCTP_STARTING_MAPARRAY 10000
-
-/* Here we define the timer types used
- * by the implementation has
- * arguments in the set/get timer type calls.
- */
-#define SCTP_TIMER_INIT 0
-#define SCTP_TIMER_RECV 1
-#define SCTP_TIMER_SEND 2
-#define SCTP_TIMER_SHUTDOWN 3
-#define SCTP_TIMER_HEARTBEAT 4
-#define SCTP_TIMER_PMTU 5
-/* number of timer types in the base SCTP
- * structure used in the set/get and has
- * the base default.
- */
-#define SCTP_NUM_TMRS 6
-
-
-
-#define SCTP_IPV4_ADDRESS 2
-#define SCTP_IPV6_ADDRESS 4
-
-/* timer types */
-#define SctpTimerTypeNone 0
-#define SctpTimerTypeSend 1
-#define SctpTimerTypeInit 2
-#define SctpTimerTypeRecv 3
-#define SctpTimerTypeShutdown 4
-#define SctpTimerTypeHeartbeat 5
-#define SctpTimerTypeCookie 6
-#define SctpTimerTypeNewCookie 7
-#define SctpTimerTypePathMtuRaise 8
-#define SctpTimerTypeShutdownAck 9
-#define SctpTimerTypeRelReq 10
-
-/* Here are the timer directives given to the
- * user provided function
- */
-#define SCTP_TIMER_START 1
-#define SCTP_TIMER_STOP 2
-
-/* running flag states in timer structure */
-#define SCTP_TIMER_IDLE 0x0
-#define SCTP_TIMER_EXPIRED 0x1
-#define SCTP_TIMER_RUNNING 0x2
-
-
-/* number of simultaneous timers running */
-#define SCTP_MAX_NET_TIMERS 6 /* base of where net timers start */
-#define SCTP_NUMBER_TIMERS 12 /* allows up to 6 destinations */
-
-
-/* Of course we really don't collect stale cookies, being
- * folks of decerning taste. However we do count them, if
- * we get to many before the association comes up.. we
- * give up. Below is the constant that dictates when
- * we give it up...this is a implemenation dependant
- * treatment. In ours we do not ask for a extension of
- * time, but just retry this many times...
- */
-#define SCTP_MAX_STALE_COOKIES_I_COLLECT 10
-
-/* max number of TSN's dup'd that I will hold */
-#define SCTP_MAX_DUP_TSNS 20
-
-/* Here we define the types used when
- * setting the retry ammounts.
- */
-/* constants for type of set */
-#define SCTP_MAXATTEMPT_INIT 2
-#define SCTP_MAXATTEMPT_SEND 3
-
-/* Here we define the default timers and the
- * default number of attemts we make for
- * each respective side (send/init).
- */
-
-/* init timer def = 3sec */
-#define SCTP_INIT_SEC 3
-#define SCTP_INIT_NSEC 0
-
-/* send timer def = 3 seconds */
-#define SCTP_SEND_SEC 1
-#define SCTP_SEND_NSEC 0
-
-/* recv timer def = 200ms (in nsec) */
-#define SCTP_RECV_SEC 0
-#define SCTP_RECV_NSEC 200000000
-
-/* 30 seconds + RTO */
-#define SCTP_HB_SEC 30
-#define SCTP_HB_NSEC 0
-
-
-/* 300 ms */
-#define SCTP_SHUTDOWN_SEC 0
-#define SCTP_SHUTDOWN_NSEC 300000000
-
-#define SCTP_RTO_UPPER_BOUND 60000000 /* 60 sec in micro-second's */
-#define SCTP_RTO_UPPER_BOUND_SEC 60 /* for the init timer */
-#define SCTP_RTO_LOWER_BOUND 1000000 /* 1 sec in micro-sec's */
-
-#define SCTP_DEF_MAX_INIT 8
-#define SCTP_DEF_MAX_SEND 10
-
-#define SCTP_DEF_PMTU_RAISE 600 /* 10 Minutes between raise attempts */
-#define SCTP_DEF_PMTU_MIN 600
-
-#define SCTP_MSEC_IN_A_SEC 1000
-#define SCTP_USEC_IN_A_SEC 1000000
-#define SCTP_NSEC_IN_A_SEC 1000000000
-
-
-/* Events that SCTP will look for, these
- * are or'd together to declare what SCTP
- * wants. Each select mask/poll list should be
- * set for the fd, if the bit is on.
- */
-#define SCTP_EVENT_READ 0x000001
-#define SCTP_EVENT_WRITE 0x000002
-#define SCTP_EVENT_EXCEPT 0x000004
-
-/* The following constant is a value for this
- * particular implemenation. It is quite arbitrary and
- * is used to limit how much data will be queued up to
- * a sender, waiting for cwnd to be larger than flightSize.
- * All implementations will need this protection is some
- * way due to buffer size constraints.
- */
-
-#define SCTP_MAX_OUTSTANDING_DG 10000
-
-
-
-/* This constant (SCTP_MAX_READBUFFER) define
- * how big the read/write buffer is
- * when we enter the fd event notification
- * the buffer is put on the stack, so the bigger
- * it is the more stack you chew up, however it
- * has got to be big enough to handle the bigest
- * message this O/S will send you. In solaris
- * with sockets (not TLI) we end up at a value
- * of 64k. In TLI we could do partial reads to
- * get it all in with less hassel.. but we
- * write to sockets for generality.
- */
-#define SCTP_MAX_READBUFFER 65536
-#define SCTP_ADDRMAX 60
-
-/* amount peer is obligated to have in rwnd or
- * I will abort
- */
-#define SCTP_MIN_RWND 1500
-
-#define SCTP_WINDOW_MIN 1500 /* smallest rwnd can be */
-#define SCTP_WINDOW_MAX 1048576 /* biggest I can grow rwnd to
- * My playing around suggests a
- * value greater than 64k does not
- * do much, I guess via the kernel
- * limitations on the stream/socket.
- */
-
-#define SCTP_MAX_BUNDLE_UP 256 /* max number of chunks I can bundle */
-
-/* I can handle a 1meg re-assembly */
-#define SCTP_DEFAULT_MAXMSGREASM 1048576
-
-
-#define SCTP_DEFAULT_MAXWINDOW 32768 /* default rwnd size */
-#define SCTP_DEFAULT_MAXSEGMENT 1500 /* MTU size, this is the default
- * to which we set the smallestMTU
- * size to. This governs what is the
- * largest size we will use, of course
- * PMTU will raise this up to
- * the largest interface MTU or the
- * ceiling below if there is no
- * SIOCGIFMTU.
- */
-#ifdef LYNX
-#define DEFAULT_MTU_CEILING 1500 /* Since Lynx O/S is brain dead
- * in the way it handles the
- * raw IP socket, insisting
- * on makeing its own IP
- * header, we limit the growth
- * to that of the e-net size
- */
-#else
-#define DEFAULT_MTU_CEILING 2048 /* If no SIOCGIFMTU, highest value
- * to raise the PMTU to, i.e.
- * don't try to raise above this
- * value. Tune this per your
- * largest MTU interface if your
- * system does not support the
- * SIOCGIFMTU ioctl.
- */
-#endif
-#define SCTP_DEFAULT_MINSEGMENT 512 /* MTU size ... if no mtu disc */
-#define SCTP_HOW_MANY_SECRETS 2 /* how many secrets I keep */
-/* This is how long a secret lives, NOT how long a cookie lives */
-#define SCTP_HOW_LONG_COOKIE_LIVE 3600 /* how many seconds the current secret will live */
-
-#define SCTP_NUMBER_OF_SECRETS 8 /* or 8 * 4 = 32 octets */
-#define SCTP_SECRET_SIZE 32 /* number of octets in a 256 bits */
-
-#ifdef USE_MD5
-#define SCTP_SIGNATURE_SIZE 16 /* size of a MD5 signature */
-#else
-#define SCTP_SIGNATURE_SIZE 20 /* size of a SLA-1 signature */
-#endif
-/* Here are the notification constants
- * that the code and upper layer will get
- */
-
-/* association is up */
-#define SCTP_NOTIFY_ASSOC_UP 1
-
-/* association is down */
-#define SCTP_NOTIFY_ASSOC_DOWN 2
-
-/* interface on a association is down
- * and out of consideration for selection.
- */
-#define SCTP_NOTIFY_INTF_DOWN 3
-
-/* interface on a association is up
- * and now back in consideration for selection.
- */
-#define SCTP_NOTIFY_INTF_UP 4
-
-/* The given datagram cannot be delivered
- * to the peer, this will probably be followed
- * by a SCTP_NOTFIY_ASSOC_DOWN.
- */
-#define SCTP_NOTIFY_DG_FAIL 5
-
-/* Sent dg on non-open stream extreme code error!
- */
-#define SCTP_NOTIFY_STRDATA_ERR 6
-
-#define SCTP_NOTIFY_ASSOC_ABORTED 7
-
-/* The stream ones are not used yet, but could
- * be when a association opens.
- */
-#define SCTP_NOTIFY_PEER_OPENED_STR 8
-#define SCTP_NOTIFY_STREAM_OPENED_OK 9
-
-/* association sees a restart event */
-#define SCTP_NOTIFY_ASSOC_RESTART 10
-
-/* a user requested HB returned */
-#define SCTP_NOTIFY_HB_RESP 11
-
-/* a result from a REL-REQ */
-#define SCTP_NOTIFY_RELREQ_RESULT_OK 12
-#define SCTP_NOTIFY_RELREQ_RESULT_FAILED 13
-
-/* clock variance is 10ms or 10,000 us's */
-#define SCTP_CLOCK_GRAINULARITY 10000
-
-#define IP_HDR_SIZE 40 /* we use the size of a IP6 header here
- * this detracts a small amount for ipv4
- * but it simplifies the ipv6 addition
- */
-
-#define SCTP_NUM_FDS 3
-
-/* raw IP filedescriptor */
-#define SCTP_FD_IP 0
-/* raw ICMP filedescriptor */
-#define SCTP_FD_ICMP 1
-/* processes contact me for requests here */
-#define SCTP_REQUEST 2
-
-
-#define SCTP_DEAMON_PORT 9899
-
-/* Deamon registration message types/responses */
-#define DEAMON_REGISTER 0x01
-#define DEAMON_REGISTER_ACK 0x02
-#define DEAMON_DEREGISTER 0x03
-#define DEAMON_DEREGISTER_ACK 0x04
-#define DEAMON_CHECKADDR_LIST 0x05
-
-#define DEAMON_MAGIC_VER_LEN 0xff
-
-/* max times I will attempt to send a message to deamon */
-#define SCTP_MAX_ATTEMPTS_AT_DEAMON 5
-#define SCTP_TIMEOUT_IN_POLL_FOR_DEAMON 1500 /* 1.5 seconds */
-
-/* modular comparison */
-/* True if a > b (mod = M) */
-#define compare_with_wrap(a, b, M) ((a > b) && ((a - b) < (M >> 1))) || \
- ((b > a) && ((b - a) > (M >> 1)))
-
-#ifndef TIMEVAL_TO_TIMESPEC
-#define TIMEVAL_TO_TIMESPEC(tv, ts) \
-{ \
- (ts)->tv_sec = (tv)->tv_sec; \
- (ts)->tv_nsec = (tv)->tv_usec * 1000; \
-}
-#endif
-
-/* pegs */
-#define SCTP_NUMBER_OF_PEGS 21
-/* peg index's */
-#define SCTP_PEG_SACKS_SEEN 0
-#define SCTP_PEG_SACKS_SENT 1
-#define SCTP_PEG_TSNS_SENT 2
-#define SCTP_PEG_TSNS_RCVD 3
-#define SCTP_DATAGRAMS_SENT 4
-#define SCTP_DATAGRAMS_RCVD 5
-#define SCTP_RETRANTSN_SENT 6
-#define SCTP_DUPTSN_RECVD 7
-#define SCTP_HBR_RECV 8
-#define SCTP_HBA_RECV 9
-#define SCTP_HB_SENT 10
-#define SCTP_DATA_DG_SENT 11
-#define SCTP_DATA_DG_RECV 12
-#define SCTP_TMIT_TIMER 13
-#define SCTP_RECV_TIMER 14
-#define SCTP_HB_TIMER 15
-#define SCTP_FAST_RETRAN 16
-#define SCTP_PEG_TSNS_READ 17
-#define SCTP_NONE_LFT_TO 18
-#define SCTP_NONE_LFT_RWND 19
-#define SCTP_NONE_LFT_CWND 20
-
-
-
-#endif
-
diff --git a/freebsd/contrib/tcpdump/sctpHeader.h b/freebsd/contrib/tcpdump/sctpHeader.h
deleted file mode 100644
index 63f30b5d..00000000
--- a/freebsd/contrib/tcpdump/sctpHeader.h
+++ /dev/null
@@ -1,323 +0,0 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/sctpHeader.h,v 1.6 2002-12-11 07:14:11 guy Exp $ (LBL) */
-
-/* SCTP reference Implementation Copyright (C) 1999 Cisco And Motorola
- *
- * 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.
- *
- * 4. Neither the name of Cisco nor of Motorola may be used
- * to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
- *
- * This file is part of the SCTP reference Implementation
- *
- *
- * Please send any bug reports or fixes you make to one of the following email
- * addresses:
- *
- * rstewar1@email.mot.com
- * kmorneau@cisco.com
- * qxie1@email.mot.com
- *
- * Any bugs reported given to us we will try to fix... any fixes shared will
- * be incorperated into the next SCTP release.
- */
-
-
-#ifndef __sctpHeader_h__
-#define __sctpHeader_h__
-
-#include <sctpConstants.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* the sctp common header */
-
-#ifdef TRU64
- #define _64BITS 1
-#endif
-
-struct sctpHeader{
- u_int16_t source;
- u_int16_t destination;
- u_int32_t verificationTag;
- u_int32_t adler32;
-};
-
-/* various descriptor parsers */
-
-struct sctpChunkDesc{
- u_int8_t chunkID;
- u_int8_t chunkFlg;
- u_int16_t chunkLength;
-};
-
-struct sctpParamDesc{
- u_int16_t paramType;
- u_int16_t paramLength;
-};
-
-
-struct sctpRelChunkDesc{
- struct sctpChunkDesc chk;
- u_int32_t serialNumber;
-};
-
-struct sctpVendorSpecificParam {
- struct sctpParamDesc p; /* type must be 0xfffe */
- u_int32_t vendorId; /* vendor ID from RFC 1700 */
- u_int16_t vendorSpecificType;
- u_int16_t vendorSpecificLen;
-};
-
-
-/* Structures for the control parts */
-
-
-
-/* Sctp association init request/ack */
-
-/* this is used for init ack, too */
-struct sctpInitiation{
- u_int32_t initTag; /* tag of mine */
- u_int32_t rcvWindowCredit; /* rwnd */
- u_int16_t NumPreopenStreams; /* OS */
- u_int16_t MaxInboundStreams; /* MIS */
- u_int32_t initialTSN;
- /* optional param's follow in sctpParamDesc form */
-};
-
-struct sctpV4IpAddress{
- struct sctpParamDesc p; /* type is set to SCTP_IPV4_PARAM_TYPE, len=10 */
- u_int32_t ipAddress;
-};
-
-
-struct sctpV6IpAddress{
- struct sctpParamDesc p; /* type is set to SCTP_IPV6_PARAM_TYPE, len=22 */
- u_int8_t ipAddress[16];
-};
-
-struct sctpDNSName{
- struct sctpParamDesc param;
- u_int8_t name[1];
-};
-
-
-struct sctpCookiePreserve{
- struct sctpParamDesc p; /* type is set to SCTP_COOKIE_PRESERVE, len=8 */
- u_int32_t extraTime;
-};
-
-
-struct sctpTimeStamp{
- u_int32_t ts_sec;
- u_int32_t ts_usec;
-};
-
-/* wire structure of my cookie */
-struct cookieMessage{
- u_int32_t TieTag_curTag; /* copied from assoc if present */
- u_int32_t TieTag_hisTag; /* copied from assoc if present */
- int32_t cookieLife; /* life I will award this cookie */
- struct sctpTimeStamp timeEnteringState; /* the time I built cookie */
- struct sctpInitiation initAckISent; /* the INIT-ACK that I sent to my peer */
- u_int32_t addressWhereISent[4]; /* I make this 4 ints so I get 128bits for future */
- int32_t addrtype; /* address type */
- u_int16_t locScope; /* V6 local scope flag */
- u_int16_t siteScope; /* V6 site scope flag */
- /* at the end is tacked on the INIT chunk sent in
- * its entirety and of course our
- * signature.
- */
-};
-
-
-/* this guy is for use when
- * I have a initiate message gloming the
- * things together.
-
- */
-struct sctpUnifiedInit{
- struct sctpChunkDesc uh;
- struct sctpInitiation initm;
-};
-
-struct sctpSendableInit{
- struct sctpHeader mh;
- struct sctpUnifiedInit msg;
-};
-
-
-/* Selective Acknowledgement
- * has the following structure with
- * a optional ammount of trailing int's
- * on the last part (based on the numberOfDesc
- * field).
- */
-
-struct sctpSelectiveAck{
- u_int32_t highestConseqTSN;
- u_int32_t updatedRwnd;
- u_int16_t numberOfdesc;
- u_int16_t numDupTsns;
-};
-
-struct sctpSelectiveFrag{
- u_int16_t fragmentStart;
- u_int16_t fragmentEnd;
-};
-
-
-struct sctpUnifiedSack{
- struct sctpChunkDesc uh;
- struct sctpSelectiveAck sack;
-};
-
-/* for both RTT request/response the
- * following is sent
- */
-
-struct sctpHBrequest {
- u_int32_t time_value_1;
- u_int32_t time_value_2;
-};
-
-/* here is what I read and respond with to. */
-struct sctpHBunified{
- struct sctpChunkDesc hdr;
- struct sctpParamDesc hb;
-};
-
-
-/* here is what I send */
-struct sctpHBsender{
- struct sctpChunkDesc hdr;
- struct sctpParamDesc hb;
- struct sctpHBrequest rtt;
- int8_t addrFmt[SCTP_ADDRMAX];
- u_int16_t userreq;
-};
-
-
-
-/* for the abort and shutdown ACK
- * we must carry the init tag in the common header. Just the
- * common header is all that is needed with a chunk descriptor.
- */
-struct sctpUnifiedAbort{
- struct sctpChunkDesc uh;
-};
-
-struct sctpUnifiedAbortLight{
- struct sctpHeader mh;
- struct sctpChunkDesc uh;
-};
-
-struct sctpUnifiedAbortHeavy{
- struct sctpHeader mh;
- struct sctpChunkDesc uh;
- u_int16_t causeCode;
- u_int16_t causeLen;
-};
-
-/* For the graceful shutdown we must carry
- * the tag (in common header) and the highest consequitive acking value
- */
-struct sctpShutdown {
- u_int32_t TSN_Seen;
-};
-
-struct sctpUnifiedShutdown{
- struct sctpChunkDesc uh;
- struct sctpShutdown shut;
-};
-
-/* in the unified message we add the trailing
- * stream id since it is the only message
- * that is defined as a operation error.
- */
-struct sctpOpErrorCause{
- u_int16_t cause;
- u_int16_t causeLen;
-};
-
-struct sctpUnifiedOpError{
- struct sctpChunkDesc uh;
- struct sctpOpErrorCause c;
-};
-
-struct sctpUnifiedStreamError{
- struct sctpHeader mh;
- struct sctpChunkDesc uh;
- struct sctpOpErrorCause c;
- u_int16_t strmNum;
- u_int16_t reserved;
-};
-
-struct staleCookieMsg{
- struct sctpHeader mh;
- struct sctpChunkDesc uh;
- struct sctpOpErrorCause c;
- u_int32_t moretime;
-};
-
-/* the following is used in all sends
- * where nothing is needed except the
- * chunk/type i.e. shutdownAck Abort */
-
-struct sctpUnifiedSingleMsg{
- struct sctpHeader mh;
- struct sctpChunkDesc uh;
-};
-
-struct sctpDataPart{
- u_int32_t TSN;
- u_int16_t streamId;
- u_int16_t sequence;
- u_int32_t payloadtype;
-};
-
-struct sctpUnifiedDatagram{
- struct sctpChunkDesc uh;
- struct sctpDataPart dp;
-};
-
-struct sctpECN_echo{
- struct sctpChunkDesc uh;
- u_int32_t Lowest_TSN;
-};
-
-
-struct sctpCWR{
- struct sctpChunkDesc uh;
- u_int32_t TSN_reduced_at;
-};
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/freebsd/contrib/tcpdump/setsignal.c b/freebsd/contrib/tcpdump/setsignal.c
index 7a9d08e0..6d6fd92a 100644
--- a/freebsd/contrib/tcpdump/setsignal.c
+++ b/freebsd/contrib/tcpdump/setsignal.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1997
* The Regents of the University of California. All rights reserved.
@@ -21,16 +24,11 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/setsignal.c,v 1.11 2003-11-16 09:36:42 guy Exp $ (LBL)";
-#endif
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <signal.h>
#ifdef HAVE_SIGACTION
@@ -80,6 +78,10 @@ RETSIGTYPE
memset(&new, 0, sizeof(new));
new.sa_handler = func;
+#ifndef __rtems__
+ if (sig == SIGCHLD)
+ new.sa_flags = SA_RESTART;
+#endif /* __rtems__ */
if (sigaction(sig, &new, &old) < 0)
return (SIG_ERR);
return (old.sa_handler);
@@ -93,3 +95,6 @@ RETSIGTYPE
#endif
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-setsignal-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/setsignal.h b/freebsd/contrib/tcpdump/setsignal.h
index 984c3407..91a2048a 100644
--- a/freebsd/contrib/tcpdump/setsignal.h
+++ b/freebsd/contrib/tcpdump/setsignal.h
@@ -17,8 +17,6 @@
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * @(#) $Header: /tcpdump/master/tcpdump/setsignal.h,v 1.2 1999-10-07 23:47:13 mcr Exp $ (LBL)
*/
#ifndef setsignal_h
#define setsignal_h
diff --git a/freebsd/contrib/tcpdump/signature.c b/freebsd/contrib/tcpdump/signature.c
index 373b33a0..4a33d64a 100644
--- a/freebsd/contrib/tcpdump/signature.c
+++ b/freebsd/contrib/tcpdump/signature.c
@@ -1,6 +1,9 @@
#include <machine/rtems-bsd-user-space.h>
-
-/*
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
+/*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code
* distributions retain the above copyright notice and this paragraph
@@ -13,24 +16,20 @@
* FOR A PARTICULAR PURPOSE.
*
* Functions for signature and digest verification.
- *
+ *
* Original code by Hannes Gredler (hannes@juniper.net)
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/signature.c,v 1.2 2008-09-22 20:22:10 guy Exp $ (LBL)";
-#endif
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <string.h>
+#include <stdlib.h>
-#include "interface.h"
+#include "netdissect.h"
#include "signature.h"
#ifdef HAVE_LIBCRYPTO
@@ -40,6 +39,7 @@ static const char rcsid[] _U_ =
const struct tok signature_check_values[] = {
{ SIGNATURE_VALID, "valid"},
{ SIGNATURE_INVALID, "invalid"},
+ { CANT_ALLOCATE_COPY, "can't allocate memory"},
{ CANT_CHECK_SIGNATURE, "unchecked"},
{ 0, NULL }
};
@@ -50,9 +50,10 @@ const struct tok signature_check_values[] = {
* Compute a HMAC MD5 sum.
* Taken from rfc2104, Appendix.
*/
+USES_APPLE_DEPRECATED_API
static void
-signature_compute_hmac_md5(const u_int8_t *text, int text_len, unsigned char *key,
- unsigned int key_len, u_int8_t *digest)
+signature_compute_hmac_md5(const uint8_t *text, int text_len, unsigned char *key,
+ unsigned int key_len, uint8_t *digest)
{
MD5_CTX context;
unsigned char k_ipad[65]; /* inner padding - key XORd with ipad */
@@ -112,45 +113,102 @@ signature_compute_hmac_md5(const u_int8_t *text, int text_len, unsigned char *ke
MD5_Update(&context, digest, 16); /* then results of 1st hash */
MD5_Final(digest, &context); /* finish up 2nd pass */
}
-#endif
+USES_APPLE_RST
-#ifdef HAVE_LIBCRYPTO
/*
* Verify a cryptographic signature of the packet.
* Currently only MD5 is supported.
*/
int
-signature_verify (const u_char *pptr, u_int plen, u_char *sig_ptr)
+signature_verify(netdissect_options *ndo, const u_char *pptr, u_int plen,
+ const u_char *sig_ptr, void (*clear_rtn)(void *),
+ const void *clear_arg)
{
- u_int8_t rcvsig[16];
- u_int8_t sig[16];
+ uint8_t *packet_copy, *sig_copy;
+ uint8_t sig[16];
unsigned int i;
+ if (!ndo->ndo_sigsecret) {
+ return (CANT_CHECK_SIGNATURE);
+ }
+
/*
- * Save the signature before clearing it.
+ * Do we have all the packet data to be checked?
*/
- memcpy(rcvsig, sig_ptr, sizeof(rcvsig));
- memset(sig_ptr, 0, sizeof(rcvsig));
+ if (!ND_TTEST2(pptr, plen)) {
+ /* No. */
+ return (CANT_CHECK_SIGNATURE);
+ }
- if (!sigsecret) {
+ /*
+ * Do we have the entire signature to check?
+ */
+ if (!ND_TTEST2(sig_ptr, sizeof(sig))) {
+ /* No. */
+ return (CANT_CHECK_SIGNATURE);
+ }
+ if (sig_ptr + sizeof(sig) > pptr + plen) {
+ /* No. */
return (CANT_CHECK_SIGNATURE);
}
- signature_compute_hmac_md5(pptr, plen, (unsigned char *)sigsecret,
- strlen(sigsecret), sig);
+ /*
+ * Make a copy of the packet, so we don't overwrite the original.
+ */
+ packet_copy = malloc(plen);
+ if (packet_copy == NULL) {
+ return (CANT_ALLOCATE_COPY);
+ }
- if (memcmp(rcvsig, sig, sizeof(sig)) == 0) {
- return (SIGNATURE_VALID);
+ memcpy(packet_copy, pptr, plen);
- } else {
+ /*
+ * Clear the signature in the copy.
+ */
+ sig_copy = packet_copy + (sig_ptr - pptr);
+ memset(sig_copy, 0, sizeof(sig));
+
+ /*
+ * Clear anything else that needs to be cleared in the copy.
+ * Our caller is assumed to have vetted the clear_arg pointer.
+ */
+ (*clear_rtn)((void *)(packet_copy + ((const uint8_t *)clear_arg - pptr)));
+ /*
+ * Compute the signature.
+ */
+ signature_compute_hmac_md5(packet_copy, plen,
+ (unsigned char *)ndo->ndo_sigsecret,
+ strlen(ndo->ndo_sigsecret), sig);
+
+ /*
+ * Free the copy.
+ */
+ free(packet_copy);
+
+ /*
+ * Does the computed signature match the signature in the packet?
+ */
+ if (memcmp(sig_ptr, sig, sizeof(sig)) == 0) {
+ /* Yes. */
+ return (SIGNATURE_VALID);
+ } else {
+ /* No - print the computed signature. */
for (i = 0; i < sizeof(sig); ++i) {
- (void)printf("%02x", sig[i]);
+ ND_PRINT((ndo, "%02x", sig[i]));
}
return (SIGNATURE_INVALID);
}
}
+#else
+int
+signature_verify(netdissect_options *ndo _U_, const u_char *pptr _U_,
+ u_int plen _U_, const u_char *sig_ptr _U_,
+ void (*clear_rtn)(void *) _U_, const void *clear_arg _U_)
+{
+ return (CANT_CHECK_SIGNATURE);
+}
#endif
/*
@@ -159,3 +217,6 @@ signature_verify (const u_char *pptr, u_int plen, u_char *sig_ptr)
* c-basic-offset: 4
* End:
*/
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-signature-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/signature.h b/freebsd/contrib/tcpdump/signature.h
index e48b7229..239ee3e8 100644
--- a/freebsd/contrib/tcpdump/signature.h
+++ b/freebsd/contrib/tcpdump/signature.h
@@ -1,4 +1,4 @@
-/*
+/*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code
* distributions retain the above copyright notice and this paragraph
@@ -15,12 +15,15 @@
* Original code by Hannes Gredler (hannes@juniper.net)
*/
-/* @(#) $Header: /tcpdump/master/tcpdump/signature.h,v 1.1 2008-08-16 11:36:20 hannes Exp $ (LBL) */
+/* for netdissect_options */
+#include "netdissect.h"
/* signature checking result codes */
#define SIGNATURE_VALID 0
#define SIGNATURE_INVALID 1
-#define CANT_CHECK_SIGNATURE 2
+#define CANT_ALLOCATE_COPY 2
+#define CANT_CHECK_SIGNATURE 3
extern const struct tok signature_check_values[];
-extern int signature_verify (const u_char *, u_int, u_char *);
+extern int signature_verify(netdissect_options *, const u_char *, u_int,
+ const u_char *, void (*)(void *), const void *);
diff --git a/freebsd/contrib/tcpdump/slcompress.h b/freebsd/contrib/tcpdump/slcompress.h
index d10243a9..644c7559 100644
--- a/freebsd/contrib/tcpdump/slcompress.h
+++ b/freebsd/contrib/tcpdump/slcompress.h
@@ -1,8 +1,6 @@
/*
* Definitions for tcp compression routines.
*
- * @(#) $Header: /tcpdump/master/tcpdump/slcompress.h,v 1.2 2000-10-09 02:03:44 guy Exp $ (LBL)
- *
* Copyright (c) 1989, 1990, 1992, 1993 Regents of the University of
* California. All rights reserved.
*
diff --git a/freebsd/contrib/tcpdump/slip.h b/freebsd/contrib/tcpdump/slip.h
deleted file mode 100644
index aa6402c3..00000000
--- a/freebsd/contrib/tcpdump/slip.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Definitions that user level programs might need to know to interact
- * with serial line IP (slip) lines.
- *
- * @(#) $Header: /tcpdump/master/tcpdump/slip.h,v 1.1 2000-10-09 01:53:21 guy Exp $
- *
- * Copyright (c) 1990 Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley. The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-/*
- * definitions of the pseudo- link-level header attached to slip
- * packets grabbed by the packet filter (bpf) traffic monitor.
- */
-#define SLIP_HDRLEN 16
-
-#define SLX_DIR 0
-#define SLX_CHDR 1
-#define CHDR_LEN 15
-
-#define SLIPDIR_IN 0
-#define SLIPDIR_OUT 1
diff --git a/freebsd/contrib/tcpdump/sll.h b/freebsd/contrib/tcpdump/sll.h
deleted file mode 100644
index 0a34963a..00000000
--- a/freebsd/contrib/tcpdump/sll.h
+++ /dev/null
@@ -1,127 +0,0 @@
-/*-
- * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from the Stanford/CMU enet packet filter,
- * (net/enet.c) distributed as part of 4.3BSD, and code contributed
- * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence
- * Berkeley Laboratory.
- *
- * 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. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
- *
- * @(#) $Header: /tcpdump/master/tcpdump/sll.h,v 1.8 2008-05-30 01:37:41 guy Exp $ (LBL)
- */
-
-/*
- * For captures on Linux cooked sockets, we construct a fake header
- * that includes:
- *
- * a 2-byte "packet type" which is one of:
- *
- * LINUX_SLL_HOST packet was sent to us
- * LINUX_SLL_BROADCAST packet was broadcast
- * LINUX_SLL_MULTICAST packet was multicast
- * LINUX_SLL_OTHERHOST packet was sent to somebody else
- * LINUX_SLL_OUTGOING packet was sent *by* us;
- *
- * a 2-byte Ethernet protocol field;
- *
- * a 2-byte link-layer type;
- *
- * a 2-byte link-layer address length;
- *
- * an 8-byte source link-layer address, whose actual length is
- * specified by the previous value.
- *
- * All fields except for the link-layer address are in network byte order.
- *
- * DO NOT change the layout of this structure, or change any of the
- * LINUX_SLL_ values below. If you must change the link-layer header
- * for a "cooked" Linux capture, introduce a new DLT_ type (ask
- * "tcpdump-workers@lists.tcpdump.org" for one, so that you don't give it
- * a value that collides with a value already being used), and use the
- * new header in captures of that type, so that programs that can
- * handle DLT_LINUX_SLL captures will continue to handle them correctly
- * without any change, and so that capture files with different headers
- * can be told apart and programs that read them can dissect the
- * packets in them.
- *
- * This structure, and the #defines below, must be the same in the
- * libpcap and tcpdump versions of "sll.h".
- */
-
-/*
- * A DLT_LINUX_SLL fake link-layer header.
- */
-#define SLL_HDR_LEN 16 /* total header length */
-#define SLL_ADDRLEN 8 /* length of address field */
-
-struct sll_header {
- u_int16_t sll_pkttype; /* packet type */
- u_int16_t sll_hatype; /* link-layer address type */
- u_int16_t sll_halen; /* link-layer address length */
- u_int8_t sll_addr[SLL_ADDRLEN]; /* link-layer address */
- u_int16_t sll_protocol; /* protocol */
-};
-
-/*
- * The LINUX_SLL_ values for "sll_pkttype"; these correspond to the
- * PACKET_ values on Linux, but are defined here so that they're
- * available even on systems other than Linux, and so that they
- * don't change even if the PACKET_ values change.
- */
-#define LINUX_SLL_HOST 0
-#define LINUX_SLL_BROADCAST 1
-#define LINUX_SLL_MULTICAST 2
-#define LINUX_SLL_OTHERHOST 3
-#define LINUX_SLL_OUTGOING 4
-
-/*
- * The LINUX_SLL_ values for "sll_protocol"; these correspond to the
- * ETH_P_ values on Linux, but are defined here so that they're
- * available even on systems other than Linux. We assume, for now,
- * that the ETH_P_ values won't change in Linux; if they do, then:
- *
- * if we don't translate them in "pcap-linux.c", capture files
- * won't necessarily be readable if captured on a system that
- * defines ETH_P_ values that don't match these values;
- *
- * if we do translate them in "pcap-linux.c", that makes life
- * unpleasant for the BPF code generator, as the values you test
- * for in the kernel aren't the values that you test for when
- * reading a capture file, so the fixup code run on BPF programs
- * handed to the kernel ends up having to do more work.
- *
- * Add other values here as necessary, for handling packet types that
- * might show up on non-Ethernet, non-802.x networks. (Not all the ones
- * in the Linux "if_ether.h" will, I suspect, actually show up in
- * captures.)
- */
-#define LINUX_SLL_P_802_3 0x0001 /* Novell 802.3 frames without 802.2 LLC header */
-#define LINUX_SLL_P_802_2 0x0004 /* 802.2 frames (not D/I/X Ethernet) */
diff --git a/freebsd/contrib/tcpdump/smb.h b/freebsd/contrib/tcpdump/smb.h
index 8eeb303f..b521617f 100644
--- a/freebsd/contrib/tcpdump/smb.h
+++ b/freebsd/contrib/tcpdump/smb.h
@@ -1,4 +1,3 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/smb.h,v 1.9 2004-12-28 22:29:44 guy Exp $ (LBL) */
/*
* Copyright (C) Andrew Tridgell 1995-1999
*
@@ -7,7 +6,8 @@
* or later
*/
-#define SMBMIN(a,b) ((a)<(b)?(a):(b))
+/* for netdissect_options */
+#include "netdissect.h"
/* the complete */
#define SMBmkdir 0x00 /* create directory */
@@ -116,7 +116,7 @@
#define TRANSACT2_FINDNOTIFYNEXT 12
#define TRANSACT2_MKDIR 13
-#define PTR_DIFF(p1, p2) ((size_t)(((char *)(p1)) - (char *)(p2)))
+#define PTR_DIFF(p1, p2) ((size_t)(((const char *)(p1)) - (const char *)(p2)))
/* some protos */
-const u_char *smb_fdata(const u_char *, const char *, const u_char *, int);
+const u_char *smb_fdata(netdissect_options *, const u_char *, const char *, const u_char *, int);
diff --git a/freebsd/contrib/tcpdump/smbutil.c b/freebsd/contrib/tcpdump/smbutil.c
index e27f280b..fa29c839 100644
--- a/freebsd/contrib/tcpdump/smbutil.c
+++ b/freebsd/contrib/tcpdump/smbutil.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (C) Andrew Tridgell 1995-1999
*
@@ -12,31 +15,26 @@
#include "config.h"
#endif
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/smbutil.c,v 1.39 2007-07-15 19:07:39 guy Exp $";
-#endif
-
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
#include "smb.h"
-static u_int32_t stringlen;
+static uint32_t stringlen;
extern const u_char *startbuf;
/*
* interpret a 32 bit dos packed date/time to some parameters
*/
static void
-interpret_dos_date(u_int32_t date, struct tm *tp)
+interpret_dos_date(uint32_t date, struct tm *tp)
{
- u_int32_t p0, p1, p2, p3;
+ uint32_t p0, p1, p2, p3;
p0 = date & 0xFF;
p1 = ((date & 0xFF00) >> 8) & 0xFF;
@@ -56,7 +54,7 @@ interpret_dos_date(u_int32_t date, struct tm *tp)
* create a unix date from a dos date
*/
static time_t
-int_unix_date(u_int32_t dos_date)
+int_unix_date(uint32_t dos_date)
{
struct tm t;
@@ -78,7 +76,7 @@ int_unix_date(u_int32_t dos_date)
static time_t
make_unix_date(const u_char *date_ptr)
{
- u_int32_t dos_date = 0;
+ uint32_t dos_date = 0;
dos_date = EXTRACT_LE_32BITS(date_ptr);
@@ -92,7 +90,7 @@ make_unix_date(const u_char *date_ptr)
static time_t
make_unix_date2(const u_char *date_ptr)
{
- u_int32_t x, x2;
+ uint32_t x, x2;
x = EXTRACT_LE_32BITS(date_ptr);
x2 = ((x & 0xFFFF) << 16) | ((x & 0xFFFF0000) >> 16);
@@ -131,14 +129,15 @@ interpret_long_date(const u_char *p)
* we run past the end of the buffer
*/
static int
-name_interpret(const u_char *in, const u_char *maxbuf, char *out)
+name_interpret(netdissect_options *ndo,
+ const u_char *in, const u_char *maxbuf, char *out)
{
int ret;
int len;
if (in >= maxbuf)
return(-1); /* name goes past the end of the buffer */
- TCHECK2(*in, 1);
+ ND_TCHECK2(*in, 1);
len = (*in++) / 2;
*out=0;
@@ -147,7 +146,7 @@ name_interpret(const u_char *in, const u_char *maxbuf, char *out)
return(0);
while (len--) {
- TCHECK2(*in, 2);
+ ND_TCHECK2(*in, 2);
if (in + 1 >= maxbuf)
return(-1); /* name goes past the end of the buffer */
if (in[0] < 'A' || in[0] > 'P' || in[1] < 'A' || in[1] > 'P') {
@@ -171,7 +170,8 @@ trunc:
* find a pointer to a netbios name
*/
static const u_char *
-name_ptr(const u_char *buf, int ofs, const u_char *maxbuf)
+name_ptr(netdissect_options *ndo,
+ const u_char *buf, int ofs, const u_char *maxbuf)
{
const u_char *p;
u_char c;
@@ -179,15 +179,15 @@ name_ptr(const u_char *buf, int ofs, const u_char *maxbuf)
p = buf + ofs;
if (p >= maxbuf)
return(NULL); /* name goes past the end of the buffer */
- TCHECK2(*p, 1);
+ ND_TCHECK2(*p, 1);
c = *p;
/* XXX - this should use the same code that the DNS dissector does */
if ((c & 0xC0) == 0xC0) {
- u_int16_t l;
+ uint16_t l;
- TCHECK2(*p, 2);
+ ND_TCHECK2(*p, 2);
if ((p + 1) >= maxbuf)
return(NULL); /* name goes past the end of the buffer */
l = EXTRACT_16BITS(p) & 0x3FFF;
@@ -198,7 +198,7 @@ name_ptr(const u_char *buf, int ofs, const u_char *maxbuf)
p = buf + l;
if (p >= maxbuf)
return(NULL); /* name goes past the end of the buffer */
- TCHECK2(*p, 1);
+ ND_TCHECK2(*p, 1);
}
return(p);
@@ -210,13 +210,14 @@ trunc:
* extract a netbios name from a buf
*/
static int
-name_extract(const u_char *buf, int ofs, const u_char *maxbuf, char *name)
+name_extract(netdissect_options *ndo,
+ const u_char *buf, int ofs, const u_char *maxbuf, char *name)
{
- const u_char *p = name_ptr(buf, ofs, maxbuf);
+ const u_char *p = name_ptr(ndo, buf, ofs, maxbuf);
if (p == NULL)
return(-1); /* error (probably name going past end of buffer) */
name[0] = '\0';
- return(name_interpret(p, maxbuf, name));
+ return(name_interpret(ndo, p, maxbuf, name));
}
@@ -224,21 +225,22 @@ name_extract(const u_char *buf, int ofs, const u_char *maxbuf, char *name)
* return the total storage length of a mangled name
*/
static int
-name_len(const unsigned char *s, const unsigned char *maxbuf)
+name_len(netdissect_options *ndo,
+ const unsigned char *s, const unsigned char *maxbuf)
{
const unsigned char *s0 = s;
unsigned char c;
if (s >= maxbuf)
return(-1); /* name goes past the end of the buffer */
- TCHECK2(*s, 1);
+ ND_TCHECK2(*s, 1);
c = *s;
if ((c & 0xC0) == 0xC0)
return(2);
while (*s) {
if (s >= maxbuf)
return(-1); /* name goes past the end of the buffer */
- TCHECK2(*s, 1);
+ ND_TCHECK2(*s, 1);
s += (*s) + 1;
}
return(PTR_DIFF(s, s0) + 1);
@@ -248,11 +250,12 @@ trunc:
}
static void
-print_asc(const unsigned char *buf, int len)
+print_asc(netdissect_options *ndo,
+ const unsigned char *buf, int len)
{
int i;
for (i = 0; i < len; i++)
- safeputchar(buf[i]);
+ safeputchar(ndo, buf[i]);
}
static const char *
@@ -273,56 +276,57 @@ name_type_str(int name_type)
}
void
-print_data(const unsigned char *buf, int len)
+smb_print_data(netdissect_options *ndo, const unsigned char *buf, int len)
{
int i = 0;
if (len <= 0)
return;
- printf("[%03X] ", i);
+ ND_PRINT((ndo, "[%03X] ", i));
for (i = 0; i < len; /*nothing*/) {
- TCHECK(buf[i]);
- printf("%02X ", buf[i] & 0xff);
+ ND_TCHECK(buf[i]);
+ ND_PRINT((ndo, "%02X ", buf[i] & 0xff));
i++;
if (i%8 == 0)
- printf(" ");
+ ND_PRINT((ndo, " "));
if (i % 16 == 0) {
- print_asc(&buf[i - 16], 8);
- printf(" ");
- print_asc(&buf[i - 8], 8);
- printf("\n");
+ print_asc(ndo, &buf[i - 16], 8);
+ ND_PRINT((ndo, " "));
+ print_asc(ndo, &buf[i - 8], 8);
+ ND_PRINT((ndo, "\n"));
if (i < len)
- printf("[%03X] ", i);
+ ND_PRINT((ndo, "[%03X] ", i));
}
}
if (i % 16) {
int n;
n = 16 - (i % 16);
- printf(" ");
+ ND_PRINT((ndo, " "));
if (n>8)
- printf(" ");
+ ND_PRINT((ndo, " "));
while (n--)
- printf(" ");
+ ND_PRINT((ndo, " "));
- n = SMBMIN(8, i % 16);
- print_asc(&buf[i - (i % 16)], n);
- printf(" ");
+ n = min(8, i % 16);
+ print_asc(ndo, &buf[i - (i % 16)], n);
+ ND_PRINT((ndo, " "));
n = (i % 16) - n;
if (n > 0)
- print_asc(&buf[i - n], n);
- printf("\n");
+ print_asc(ndo, &buf[i - n], n);
+ ND_PRINT((ndo, "\n"));
}
return;
trunc:
- printf("\n");
- printf("WARNING: Short packet. Try increasing the snap length\n");
+ ND_PRINT((ndo, "\n"));
+ ND_PRINT((ndo, "WARNING: Short packet. Try increasing the snap length\n"));
}
static void
-write_bits(unsigned int val, const char *fmt)
+write_bits(netdissect_options *ndo,
+ unsigned int val, const char *fmt)
{
const char *p = fmt;
int i = 0;
@@ -330,20 +334,21 @@ write_bits(unsigned int val, const char *fmt)
while ((p = strchr(fmt, '|'))) {
size_t l = PTR_DIFF(p, fmt);
if (l && (val & (1 << i)))
- printf("%.*s ", (int)l, fmt);
+ ND_PRINT((ndo, "%.*s ", (int)l, fmt));
fmt = p + 1;
i++;
}
}
-/* convert a UCS2 string into iso-8859-1 string */
+/* convert a UCS-2 string into an ASCII string */
#define MAX_UNISTR_SIZE 1000
static const char *
-unistr(const u_char *s, u_int32_t *len, int use_unicode)
+unistr(netdissect_options *ndo,
+ const u_char *s, uint32_t *len, int use_unicode)
{
static char buf[MAX_UNISTR_SIZE+1];
size_t l = 0;
- u_int32_t strsize;
+ uint32_t strsize;
const u_char *sp;
if (use_unicode) {
@@ -351,7 +356,7 @@ unistr(const u_char *s, u_int32_t *len, int use_unicode)
* Skip padding that puts the string on an even boundary.
*/
if (((s - startbuf) % 2) != 0) {
- TCHECK(s[0]);
+ ND_TCHECK(s[0]);
s++;
}
}
@@ -363,7 +368,7 @@ unistr(const u_char *s, u_int32_t *len, int use_unicode)
sp = s;
if (!use_unicode) {
for (;;) {
- TCHECK(sp[0]);
+ ND_TCHECK(sp[0]);
*len += 1;
if (sp[0] == 0)
break;
@@ -372,7 +377,7 @@ unistr(const u_char *s, u_int32_t *len, int use_unicode)
strsize = *len - 1;
} else {
for (;;) {
- TCHECK2(sp[0], 2);
+ ND_TCHECK2(sp[0], 2);
*len += 2;
if (sp[0] == 0 && sp[1] == 0)
break;
@@ -388,10 +393,10 @@ unistr(const u_char *s, u_int32_t *len, int use_unicode)
}
if (!use_unicode) {
while (strsize != 0) {
- TCHECK(s[0]);
+ ND_TCHECK(s[0]);
if (l >= MAX_UNISTR_SIZE)
break;
- if (isprint(s[0]))
+ if (ND_ISPRINT(s[0]))
buf[l] = s[0];
else {
if (s[0] == 0)
@@ -404,10 +409,10 @@ unistr(const u_char *s, u_int32_t *len, int use_unicode)
}
} else {
while (strsize != 0) {
- TCHECK2(s[0], 2);
+ ND_TCHECK2(s[0], 2);
if (l >= MAX_UNISTR_SIZE)
break;
- if (s[1] == 0 && isprint(s[0])) {
+ if (s[1] == 0 && ND_ISPRINT(s[0])) {
/* It's a printable ASCII character */
buf[l] = s[0];
} else {
@@ -431,8 +436,9 @@ trunc:
}
static const u_char *
-smb_fdata1(const u_char *buf, const char *fmt, const u_char *maxbuf,
- int unicodestr)
+smb_fdata1(netdissect_options *ndo,
+ const u_char *buf, const char *fmt, const u_char *maxbuf,
+ int unicodestr)
{
int reverse = 0;
const char *attrib_fmt = "READONLY|HIDDEN|SYSTEM|VOLUME|DIR|ARCHIVE|";
@@ -440,15 +446,15 @@ smb_fdata1(const u_char *buf, const char *fmt, const u_char *maxbuf,
while (*fmt && buf<maxbuf) {
switch (*fmt) {
case 'a':
- TCHECK(buf[0]);
- write_bits(buf[0], attrib_fmt);
+ ND_TCHECK(buf[0]);
+ write_bits(ndo, buf[0], attrib_fmt);
buf++;
fmt++;
break;
case 'A':
- TCHECK2(buf[0], 2);
- write_bits(EXTRACT_LE_16BITS(buf), attrib_fmt);
+ ND_TCHECK2(buf[0], 2);
+ write_bits(ndo, EXTRACT_LE_16BITS(buf), attrib_fmt);
buf += 2;
fmt++;
break;
@@ -468,8 +474,8 @@ smb_fdata1(const u_char *buf, const char *fmt, const u_char *maxbuf,
strncpy(bitfmt, fmt, l);
bitfmt[l] = '\0';
fmt = p + 1;
- TCHECK(buf[0]);
- write_bits(buf[0], bitfmt);
+ ND_TCHECK(buf[0]);
+ write_bits(ndo, buf[0], bitfmt);
buf++;
break;
}
@@ -477,7 +483,7 @@ smb_fdata1(const u_char *buf, const char *fmt, const u_char *maxbuf,
case 'P':
{
int l = atoi(fmt + 1);
- TCHECK2(buf[0], l);
+ ND_TCHECK2(buf[0], l);
buf += l;
fmt++;
while (isdigit((unsigned char)*fmt))
@@ -491,9 +497,9 @@ smb_fdata1(const u_char *buf, const char *fmt, const u_char *maxbuf,
case 'b':
{
unsigned int x;
- TCHECK(buf[0]);
+ ND_TCHECK(buf[0]);
x = buf[0];
- printf("%u (0x%x)", x, x);
+ ND_PRINT((ndo, "%u (0x%x)", x, x));
buf += 1;
fmt++;
break;
@@ -501,10 +507,10 @@ smb_fdata1(const u_char *buf, const char *fmt, const u_char *maxbuf,
case 'd':
{
unsigned int x;
- TCHECK2(buf[0], 2);
+ ND_TCHECK2(buf[0], 2);
x = reverse ? EXTRACT_16BITS(buf) :
EXTRACT_LE_16BITS(buf);
- printf("%d (0x%x)", x, x);
+ ND_PRINT((ndo, "%d (0x%x)", x, x));
buf += 2;
fmt++;
break;
@@ -512,21 +518,21 @@ smb_fdata1(const u_char *buf, const char *fmt, const u_char *maxbuf,
case 'D':
{
unsigned int x;
- TCHECK2(buf[0], 4);
+ ND_TCHECK2(buf[0], 4);
x = reverse ? EXTRACT_32BITS(buf) :
EXTRACT_LE_32BITS(buf);
- printf("%d (0x%x)", x, x);
+ ND_PRINT((ndo, "%d (0x%x)", x, x));
buf += 4;
fmt++;
break;
}
case 'L':
{
- u_int64_t x;
- TCHECK2(buf[0], 8);
+ uint64_t x;
+ ND_TCHECK2(buf[0], 8);
x = reverse ? EXTRACT_64BITS(buf) :
EXTRACT_LE_64BITS(buf);
- printf("%" PRIu64 " (0x%" PRIx64 ")", x, x);
+ ND_PRINT((ndo, "%" PRIu64 " (0x%" PRIx64 ")", x, x));
buf += 8;
fmt++;
break;
@@ -534,15 +540,15 @@ smb_fdata1(const u_char *buf, const char *fmt, const u_char *maxbuf,
case 'M':
{
/* Weird mixed-endian length values in 64-bit locks */
- u_int32_t x1, x2;
- u_int64_t x;
- TCHECK2(buf[0], 8);
+ uint32_t x1, x2;
+ uint64_t x;
+ ND_TCHECK2(buf[0], 8);
x1 = reverse ? EXTRACT_32BITS(buf) :
EXTRACT_LE_32BITS(buf);
x2 = reverse ? EXTRACT_32BITS(buf + 4) :
EXTRACT_LE_32BITS(buf + 4);
- x = (((u_int64_t)x1) << 32) | x2;
- printf("%" PRIu64 " (0x%" PRIx64 ")", x, x);
+ x = (((uint64_t)x1) << 32) | x2;
+ ND_PRINT((ndo, "%" PRIu64 " (0x%" PRIx64 ")", x, x));
buf += 8;
fmt++;
break;
@@ -550,9 +556,9 @@ smb_fdata1(const u_char *buf, const char *fmt, const u_char *maxbuf,
case 'B':
{
unsigned int x;
- TCHECK(buf[0]);
+ ND_TCHECK(buf[0]);
x = buf[0];
- printf("0x%X", x);
+ ND_PRINT((ndo, "0x%X", x));
buf += 1;
fmt++;
break;
@@ -560,10 +566,10 @@ smb_fdata1(const u_char *buf, const char *fmt, const u_char *maxbuf,
case 'w':
{
unsigned int x;
- TCHECK2(buf[0], 2);
+ ND_TCHECK2(buf[0], 2);
x = reverse ? EXTRACT_16BITS(buf) :
EXTRACT_LE_16BITS(buf);
- printf("0x%X", x);
+ ND_PRINT((ndo, "0x%X", x));
buf += 2;
fmt++;
break;
@@ -571,10 +577,10 @@ smb_fdata1(const u_char *buf, const char *fmt, const u_char *maxbuf,
case 'W':
{
unsigned int x;
- TCHECK2(buf[0], 4);
+ ND_TCHECK2(buf[0], 4);
x = reverse ? EXTRACT_32BITS(buf) :
EXTRACT_LE_32BITS(buf);
- printf("0x%X", x);
+ ND_PRINT((ndo, "0x%X", x));
buf += 4;
fmt++;
break;
@@ -585,25 +591,25 @@ smb_fdata1(const u_char *buf, const char *fmt, const u_char *maxbuf,
switch (*fmt) {
case 'b':
- TCHECK(buf[0]);
+ ND_TCHECK(buf[0]);
stringlen = buf[0];
- printf("%u", stringlen);
+ ND_PRINT((ndo, "%u", stringlen));
buf += 1;
break;
case 'd':
- TCHECK2(buf[0], 2);
+ ND_TCHECK2(buf[0], 2);
stringlen = reverse ? EXTRACT_16BITS(buf) :
EXTRACT_LE_16BITS(buf);
- printf("%u", stringlen);
+ ND_PRINT((ndo, "%u", stringlen));
buf += 2;
break;
case 'D':
- TCHECK2(buf[0], 4);
+ ND_TCHECK2(buf[0], 4);
stringlen = reverse ? EXTRACT_32BITS(buf) :
EXTRACT_LE_32BITS(buf);
- printf("%u", stringlen);
+ ND_PRINT((ndo, "%u", stringlen));
buf += 4;
break;
}
@@ -615,13 +621,13 @@ smb_fdata1(const u_char *buf, const char *fmt, const u_char *maxbuf,
{
/*XXX unistr() */
const char *s;
- u_int32_t len;
+ uint32_t len;
len = 0;
- s = unistr(buf, &len, (*fmt == 'R') ? 0 : unicodestr);
+ s = unistr(ndo, buf, &len, (*fmt == 'R') ? 0 : unicodestr);
if (s == NULL)
goto trunc;
- printf("%s", s);
+ ND_PRINT((ndo, "%s", s));
buf += len;
fmt++;
break;
@@ -630,18 +636,18 @@ smb_fdata1(const u_char *buf, const char *fmt, const u_char *maxbuf,
case 'Y': /* like 'Z', but always ASCII */
{
const char *s;
- u_int32_t len;
+ uint32_t len;
- TCHECK(*buf);
+ ND_TCHECK(*buf);
if (*buf != 4 && *buf != 2) {
- printf("Error! ASCIIZ buffer of type %u", *buf);
+ ND_PRINT((ndo, "Error! ASCIIZ buffer of type %u", *buf));
return maxbuf; /* give up */
}
len = 0;
- s = unistr(buf + 1, &len, (*fmt == 'Y') ? 0 : unicodestr);
+ s = unistr(ndo, buf + 1, &len, (*fmt == 'Y') ? 0 : unicodestr);
if (s == NULL)
goto trunc;
- printf("%s", s);
+ ND_PRINT((ndo, "%s", s));
buf += len + 1;
fmt++;
break;
@@ -649,8 +655,8 @@ smb_fdata1(const u_char *buf, const char *fmt, const u_char *maxbuf,
case 's':
{
int l = atoi(fmt + 1);
- TCHECK2(*buf, l);
- printf("%-*.*s", l, l, buf);
+ ND_TCHECK2(*buf, l);
+ ND_PRINT((ndo, "%-*.*s", l, l, buf));
buf += l;
fmt++;
while (isdigit((unsigned char)*fmt))
@@ -659,8 +665,8 @@ smb_fdata1(const u_char *buf, const char *fmt, const u_char *maxbuf,
}
case 'c':
{
- TCHECK2(*buf, stringlen);
- printf("%-*.*s", (int)stringlen, (int)stringlen, buf);
+ ND_TCHECK2(*buf, stringlen);
+ ND_PRINT((ndo, "%-*.*s", (int)stringlen, (int)stringlen, buf));
buf += stringlen;
fmt++;
while (isdigit((unsigned char)*fmt))
@@ -670,10 +676,10 @@ smb_fdata1(const u_char *buf, const char *fmt, const u_char *maxbuf,
case 'C':
{
const char *s;
- s = unistr(buf, &stringlen, unicodestr);
+ s = unistr(ndo, buf, &stringlen, unicodestr);
if (s == NULL)
goto trunc;
- printf("%s", s);
+ ND_PRINT((ndo, "%s", s));
buf += stringlen;
fmt++;
break;
@@ -681,9 +687,9 @@ smb_fdata1(const u_char *buf, const char *fmt, const u_char *maxbuf,
case 'h':
{
int l = atoi(fmt + 1);
- TCHECK2(*buf, l);
+ ND_TCHECK2(*buf, l);
while (l--)
- printf("%02x", *buf++);
+ ND_PRINT((ndo, "%02x", *buf++));
fmt++;
while (isdigit((unsigned char)*fmt))
fmt++;
@@ -698,22 +704,22 @@ smb_fdata1(const u_char *buf, const char *fmt, const u_char *maxbuf,
switch (t) {
case 1:
- name_type = name_extract(startbuf, PTR_DIFF(buf, startbuf),
+ name_type = name_extract(ndo, startbuf, PTR_DIFF(buf, startbuf),
maxbuf, nbuf);
if (name_type < 0)
goto trunc;
- len = name_len(buf, maxbuf);
+ len = name_len(ndo, buf, maxbuf);
if (len < 0)
goto trunc;
buf += len;
- printf("%-15.15s NameType=0x%02X (%s)", nbuf, name_type,
- name_type_str(name_type));
+ ND_PRINT((ndo, "%-15.15s NameType=0x%02X (%s)", nbuf, name_type,
+ name_type_str(name_type)));
break;
case 2:
- TCHECK(buf[15]);
+ ND_TCHECK(buf[15]);
name_type = buf[15];
- printf("%-15.15s NameType=0x%02X (%s)", buf, name_type,
- name_type_str(name_type));
+ ND_PRINT((ndo, "%-15.15s NameType=0x%02X (%s)", buf, name_type,
+ name_type_str(name_type)));
buf += 16;
break;
}
@@ -727,11 +733,11 @@ smb_fdata1(const u_char *buf, const char *fmt, const u_char *maxbuf,
time_t t;
struct tm *lt;
const char *tstring;
- u_int32_t x;
+ uint32_t x;
switch (atoi(fmt + 1)) {
case 1:
- TCHECK2(buf[0], 4);
+ ND_TCHECK2(buf[0], 4);
x = EXTRACT_LE_32BITS(buf);
if (x == 0 || x == 0xFFFFFFFF)
t = 0;
@@ -740,7 +746,7 @@ smb_fdata1(const u_char *buf, const char *fmt, const u_char *maxbuf,
buf += 4;
break;
case 2:
- TCHECK2(buf[0], 4);
+ ND_TCHECK2(buf[0], 4);
x = EXTRACT_LE_32BITS(buf);
if (x == 0 || x == 0xFFFFFFFF)
t = 0;
@@ -749,7 +755,7 @@ smb_fdata1(const u_char *buf, const char *fmt, const u_char *maxbuf,
buf += 4;
break;
case 3:
- TCHECK2(buf[0], 8);
+ ND_TCHECK2(buf[0], 8);
t = interpret_long_date(buf);
buf += 8;
break;
@@ -765,33 +771,34 @@ smb_fdata1(const u_char *buf, const char *fmt, const u_char *maxbuf,
tstring = "(Can't convert time)\n";
} else
tstring = "NULL\n";
- printf("%s", tstring);
+ ND_PRINT((ndo, "%s", tstring));
fmt++;
while (isdigit((unsigned char)*fmt))
fmt++;
break;
}
default:
- putchar(*fmt);
+ ND_PRINT((ndo, "%c", *fmt));
fmt++;
break;
}
}
if (buf >= maxbuf && *fmt)
- printf("END OF BUFFER\n");
+ ND_PRINT((ndo, "END OF BUFFER\n"));
return(buf);
trunc:
- printf("\n");
- printf("WARNING: Short packet. Try increasing the snap length\n");
+ ND_PRINT((ndo, "\n"));
+ ND_PRINT((ndo, "WARNING: Short packet. Try increasing the snap length\n"));
return(NULL);
}
const u_char *
-smb_fdata(const u_char *buf, const char *fmt, const u_char *maxbuf,
- int unicodestr)
+smb_fdata(netdissect_options *ndo,
+ const u_char *buf, const char *fmt, const u_char *maxbuf,
+ int unicodestr)
{
static int depth = 0;
char s[128];
@@ -804,7 +811,7 @@ smb_fdata(const u_char *buf, const char *fmt, const u_char *maxbuf,
while (buf < maxbuf) {
const u_char *buf2;
depth++;
- buf2 = smb_fdata(buf, fmt, maxbuf, unicodestr);
+ buf2 = smb_fdata(ndo, buf, fmt, maxbuf, unicodestr);
depth--;
if (buf2 == NULL)
return(NULL);
@@ -843,22 +850,21 @@ smb_fdata(const u_char *buf, const char *fmt, const u_char *maxbuf,
strncpy(s, fmt, p - fmt);
s[p - fmt] = '\0';
fmt = p + 1;
- buf = smb_fdata1(buf, s, maxbuf, unicodestr);
+ buf = smb_fdata1(ndo, buf, s, maxbuf, unicodestr);
if (buf == NULL)
return(NULL);
break;
default:
- putchar(*fmt);
+ ND_PRINT((ndo, "%c", *fmt));
fmt++;
- fflush(stdout);
break;
}
}
if (!depth && buf < maxbuf) {
size_t len = PTR_DIFF(maxbuf, buf);
- printf("Data: (%lu bytes)\n", (unsigned long)len);
- print_data(buf, len);
+ ND_PRINT((ndo, "Data: (%lu bytes)\n", (unsigned long)len));
+ smb_print_data(ndo, buf, len);
return(buf + len);
}
return(buf);
@@ -1010,7 +1016,7 @@ smb_errstr(int class, int num)
}
typedef struct {
- u_int32_t code;
+ uint32_t code;
const char *name;
} nt_err_code_struct;
@@ -1874,7 +1880,7 @@ static const nt_err_code_struct nt_errors[] = {
* return an NT error string from a SMB buffer
*/
const char *
-nt_errstr(u_int32_t err)
+nt_errstr(uint32_t err)
{
static char ret[128];
int i;
@@ -1889,3 +1895,6 @@ nt_errstr(u_int32_t err)
snprintf(ret, sizeof(ret), "0x%08x", err);
return ret;
}
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-smbutil-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/strtoaddr.h b/freebsd/contrib/tcpdump/strtoaddr.h
new file mode 100644
index 00000000..8bd22c74
--- /dev/null
+++ b/freebsd/contrib/tcpdump/strtoaddr.h
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 1996,1999 by Internet Software Consortium.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/* Text string to address translation routines. */
+
+int strtoaddr(const char *src, void *dst);
+int strtoaddr6(const char *src, void *dst);
+
+
diff --git a/freebsd/contrib/tcpdump/tcp.h b/freebsd/contrib/tcpdump/tcp.h
index 92d505ae..912b5e82 100644
--- a/freebsd/contrib/tcpdump/tcp.h
+++ b/freebsd/contrib/tcpdump/tcp.h
@@ -1,4 +1,3 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/tcp.h,v 1.14 2007-12-09 00:30:47 guy Exp $ (LBL) */
/*
* Copyright (c) 1982, 1986, 1993
* The Regents of the University of California. All rights reserved.
@@ -34,22 +33,22 @@
* @(#)tcp.h 8.1 (Berkeley) 6/10/93
*/
-typedef u_int32_t tcp_seq;
+typedef uint32_t tcp_seq;
/*
* TCP header.
* Per RFC 793, September, 1981.
*/
struct tcphdr {
- u_int16_t th_sport; /* source port */
- u_int16_t th_dport; /* destination port */
+ uint16_t th_sport; /* source port */
+ uint16_t th_dport; /* destination port */
tcp_seq th_seq; /* sequence number */
tcp_seq th_ack; /* acknowledgement number */
- u_int8_t th_offx2; /* data offset, rsvd */
- u_int8_t th_flags;
- u_int16_t th_win; /* window */
- u_int16_t th_sum; /* checksum */
- u_int16_t th_urp; /* urgent pointer */
-};
+ uint8_t th_offx2; /* data offset, rsvd */
+ uint8_t th_flags;
+ uint16_t th_win; /* window */
+ uint16_t th_sum; /* checksum */
+ uint16_t th_urp; /* urgent pointer */
+} UNALIGNED;
#define TH_OFF(th) (((th)->th_offx2 & 0xf0) >> 4)
@@ -82,31 +81,80 @@ struct tcphdr {
#define TCPOPT_SIGNATURE 19 /* Keyed MD5 (rfc2385) */
#define TCPOLEN_SIGNATURE 18
#define TCP_SIGLEN 16 /* length of an option 19 digest */
-#define TCPOPT_AUTH 20 /* Enhanced AUTH option */
+#define TCPOPT_SCPS 20 /* SCPS-TP (CCSDS 714.0-B-2) */
#define TCPOPT_UTO 28 /* tcp user timeout (rfc5482) */
#define TCPOLEN_UTO 4
-
+#define TCPOPT_TCPAO 29 /* TCP authentication option (rfc5925) */
+#define TCPOPT_MPTCP 30 /* MPTCP options */
+#define TCPOPT_FASTOPEN 34 /* TCP Fast Open (rfc7413) */
+#define TCPOPT_EXPERIMENT2 254 /* experimental headers (rfc4727) */
#define TCPOPT_TSTAMP_HDR \
(TCPOPT_NOP<<24|TCPOPT_NOP<<16|TCPOPT_TIMESTAMP<<8|TCPOLEN_TIMESTAMP)
+#ifndef FTP_PORT
+#define FTP_PORT 21
+#endif
+#ifndef SSH_PORT
+#define SSH_PORT 22
+#endif
#ifndef TELNET_PORT
-#define TELNET_PORT 23
+#define TELNET_PORT 23
+#endif
+#ifndef SMTP_PORT
+#define SMTP_PORT 25
+#endif
+#ifndef NAMESERVER_PORT
+#define NAMESERVER_PORT 53
+#endif
+#ifndef HTTP_PORT
+#define HTTP_PORT 80
+#endif
+#ifndef NETBIOS_NS_PORT
+#define NETBIOS_NS_PORT 137 /* RFC 1001, RFC 1002 */
+#endif
+#ifndef NETBIOS_SSN_PORT
+#define NETBIOS_SSN_PORT 139 /* RFC 1001, RFC 1002 */
#endif
#ifndef BGP_PORT
-#define BGP_PORT 179
+#define BGP_PORT 179
+#endif
+#ifndef RPKI_RTR_PORT
+#define RPKI_RTR_PORT 323
+#endif
+#ifndef SMB_PORT
+#define SMB_PORT 445
+#endif
+#ifndef RTSP_PORT
+#define RTSP_PORT 554
+#endif
+#ifndef MSDP_PORT
+#define MSDP_PORT 639
+#endif
+#ifndef LDP_PORT
+#define LDP_PORT 646
#endif
-#define NETBIOS_SSN_PORT 139
#ifndef PPTP_PORT
-#define PPTP_PORT 1723
+#define PPTP_PORT 1723
#endif
-#define BEEP_PORT 10288
#ifndef NFS_PORT
-#define NFS_PORT 2049
+#define NFS_PORT 2049
#endif
-#define MSDP_PORT 639
-#define RPKI_RTR_PORT 323
-#define LDP_PORT 646
-#ifndef SMB_PORT
-#define SMB_PORT 445
+#ifndef OPENFLOW_PORT_OLD
+#define OPENFLOW_PORT_OLD 6633
+#endif
+#ifndef OPENFLOW_PORT_IANA
+#define OPENFLOW_PORT_IANA 6653
+#endif
+#ifndef HTTP_PORT_ALT
+#define HTTP_PORT_ALT 8080
+#endif
+#ifndef RTSP_PORT_ALT
+#define RTSP_PORT_ALT 8554
+#endif
+#ifndef BEEP_PORT
+#define BEEP_PORT 10288
+#endif
+#ifndef REDIS_PORT
+#define REDIS_PORT 6379
#endif
diff --git a/freebsd/contrib/tcpdump/tcpdump.c b/freebsd/contrib/tcpdump/tcpdump.c
index 6a74ef70..8090c23a 100644
--- a/freebsd/contrib/tcpdump/tcpdump.c
+++ b/freebsd/contrib/tcpdump/tcpdump.c
@@ -1,5 +1,9 @@
#include <machine/rtems-bsd-user-space.h>
-
+#ifdef __rtems__
+#define RTEMS_BSD_PROGRAM_NO_ERROR_WRAP
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
/*
* Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2000
* The Regents of the University of California. All rights reserved.
@@ -27,39 +31,16 @@
* Seth Webster <swebster@sst.ll.mit.edu>
*/
-#if 0
+#ifndef __rtems__
#ifndef lint
static const char copyright[] _U_ =
"@(#) Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2000\n\
The Regents of the University of California. All rights reserved.\n";
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.283 2008-09-25 21:45:50 guy Exp $ (LBL)";
-#endif
#endif
-
-/* $FreeBSD$ */
-
-#ifdef __rtems__
-#define HAVE_GETOPT_LONG
-#define __need_getopt_newlib
-#include <getopt.h>
-#define setpriority(a, b, c)
-#define RTEMS_BSD_PROGRAM_NO_OPEN_WRAP
-#define RTEMS_BSD_PROGRAM_NO_SOCKET_WRAP
-#define RTEMS_BSD_PROGRAM_NO_CLOSE_WRAP
-#define RTEMS_BSD_PROGRAM_NO_FOPEN_WRAP
-#define RTEMS_BSD_PROGRAM_NO_FCLOSE_WRAP
-#define RTEMS_BSD_PROGRAM_NO_MALLOC_WRAP
-#define RTEMS_BSD_PROGRAM_NO_CALLOC_WRAP
-#define RTEMS_BSD_PROGRAM_NO_REALLOC_WRAP
-#define RTEMS_BSD_PROGRAM_NO_FREE_WRAP
-#include <machine/rtems-bsd-program.h>
-#include <machine/rtems-bsd-commands.h>
-#include <rtems.h>
#endif /* __rtems__ */
/*
- * tcpdump - monitor tcp/ip traffic on an ethernet.
+ * tcpdump - dump traffic on a network
*
* First written in 1987 by Van Jacobson, Lawrence Berkeley Laboratory.
* Mercilessly hacked and occasionally improved since then via the
@@ -70,25 +51,32 @@ static const char rcsid[] _U_ =
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+/*
+ * Mac OS X may ship pcap.h from libpcap 0.6 with a libpcap based on
+ * 0.8. That means it has pcap_findalldevs() but the header doesn't
+ * define pcap_if_t, meaning that we can't actually *use* pcap_findalldevs().
+ */
+#ifdef HAVE_PCAP_FINDALLDEVS
+#ifndef HAVE_PCAP_IF_T
+#undef HAVE_PCAP_FINDALLDEVS
+#endif
+#endif
+
+#include <netdissect-stdinc.h>
-#ifdef WIN32
-#include "getopt.h"
-#include "w32_fzs.h"
-extern int strcasecmp (const char *__s1, const char *__s2);
-extern int SIZE_BUF;
-#define off_t long
-#define uint UINT
-#endif /* WIN32 */
+#include <sys/stat.h>
-#ifdef HAVE_SMI_H
-#include <smi.h>
+#ifdef HAVE_FCNTL_H
+#include <fcntl.h>
#endif
#ifdef HAVE_LIBCRYPTO
#include <openssl/crypto.h>
#endif
+#ifdef __rtems__
+#define __need_getopt_newlib
+#endif /* __rtems__ */
#ifdef HAVE_GETOPT_LONG
#include <getopt.h>
#else
@@ -98,37 +86,44 @@ extern int SIZE_BUF;
* to compile if <pcap.h> has already been included; including the headers
* in the opposite order works fine.
*/
-#ifdef __FreeBSD__
+#ifdef HAVE_CAPSICUM
#include <sys/capsicum.h>
#include <sys/sysctl.h>
+#include <sys/nv.h>
+#include <sys/ioccom.h>
+#include <net/bpf.h>
#include <libgen.h>
-#endif /* __FreeBSD__ */
#ifdef HAVE_CASPER
#include <libcasper.h>
#include <casper/cap_dns.h>
-#include <sys/nv.h>
-#include <sys/ioccom.h>
-#include <net/bpf.h>
-#include <fcntl.h>
#endif /* HAVE_CASPER */
+#endif /* HAVE_CAPSICUM */
#include <pcap.h>
#include <signal.h>
#include <stdio.h>
+#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
-#ifndef WIN32
+#ifndef _WIN32
#include <sys/wait.h>
#include <rtems/bsd/sys/resource.h>
#include <pwd.h>
#include <grp.h>
-#include <errno.h>
-#endif /* WIN32 */
+#endif /* _WIN32 */
-/* capabilities convinience library */
+/* capabilities convenience library */
+/* If a code depends on HAVE_LIBCAP_NG, it depends also on HAVE_CAP_NG_H.
+ * If HAVE_CAP_NG_H is not defined, undefine HAVE_LIBCAP_NG.
+ * Thus, the later tests are done only on HAVE_LIBCAP_NG.
+ */
+#ifdef HAVE_LIBCAP_NG
#ifdef HAVE_CAP_NG_H
#include <cap-ng.h>
+#else
+#undef HAVE_LIBCAP_NG
#endif /* HAVE_CAP_NG_H */
+#endif /* HAVE_LIBCAP_NG */
#include "netdissect.h"
#include "interface.h"
@@ -137,6 +132,17 @@ extern int SIZE_BUF;
#include "setsignal.h"
#include "gmt2local.h"
#include "pcap-missing.h"
+#include "ascii_strcasecmp.h"
+
+#include "print.h"
+#ifdef __rtems__
+#include <sys/sysctl.h>
+#include <machine/rtems-bsd-commands.h>
+#include <assert.h>
+#include <rtems.h>
+#include <rtems/linkersets.h>
+#define setpriority(a, b, c)
+#endif /* __rtems__ */
#ifndef PATH_MAX
#define PATH_MAX 1024
@@ -148,141 +154,81 @@ extern int SIZE_BUF;
#define SIGNAL_REQ_INFO SIGUSR1
#endif
-#ifdef __rtems__
+static int Bflag; /* buffer size */
+static int Cflag; /* rotate dump files after this many bytes */
+static int Cflag_count; /* Keep track of which file number we're writing */
+static int Dflag; /* list available devices and exit */
/*
- * Run the PCAP loop in a separate task and have the shell thread block on the
- * input.
+ * This is exported because, in some versions of libpcap, if libpcap
+ * is built with optimizer debugging code (which is *NOT* the default
+ * configuration!), the library *imports*(!) a variable named dflag,
+ * under the expectation that tcpdump is exporting it, to govern
+ * how much debugging information to print when optimizing
+ * the generated BPF code.
+ *
+ * This is a horrible hack; newer versions of libpcap don't import
+ * dflag but, instead, *if* built with optimizer debugging code,
+ * *export* a routine to set that flag.
*/
-typedef struct
-{
- volatile bool running;
- pcap_t *pd;
- int cnt;
- pcap_handler cb;
- u_char *ud;
- int ret;
-} rtems_pcap_loop_args;
-
-static void
-rtems_pcap_loop_thread (rtems_task_argument arg)
-{
- rtems_pcap_loop_args* pcap_loop_arg = (rtems_pcap_loop_args*) arg;
-
- pcap_loop_arg->ret = pcap_loop(pcap_loop_arg->pd,
- pcap_loop_arg->cnt,
- pcap_loop_arg->cb,
- pcap_loop_arg->ud);
-
- pcap_loop_arg->running = false;
-
- rtems_task_delete(RTEMS_SELF);
-}
-
-static int
-rtems_pcap_loop(pcap_t *pd, int cnt, pcap_handler cb, u_char *ud)
-{
- rtems_status_code sc;
- rtems_task_priority priority;
- rtems_name name;
- rtems_id id;
-
- rtems_pcap_loop_args pcap_loop_args;
-
- pcap_loop_args.running = true;
- pcap_loop_args.pd = pd;
- pcap_loop_args.cnt = cnt;
- pcap_loop_args.cb = cb;
- pcap_loop_args.ud = ud;
- pcap_loop_args.ret = 0;
-
- sc = rtems_task_set_priority (RTEMS_SELF, RTEMS_CURRENT_PRIORITY, &priority);
-
- if (sc != RTEMS_SUCCESSFUL) {
- fprintf(stderr, "error: cannot get current priority: %s\n",
- rtems_status_text (sc));
- return -1;
- }
-
- name = rtems_build_name('T', 'C', 'P', 'D');
-
- sc = rtems_task_create (name, priority, 8 * 1024,
- RTEMS_NO_FLOATING_POINT | RTEMS_LOCAL,
- RTEMS_PREEMPT | RTEMS_TIMESLICE | RTEMS_NO_ASR,
- &id);
-
- if (sc != RTEMS_SUCCESSFUL)
- {
- fprintf(stderr, "error: cannot create helper thread: %s\n",
- rtems_status_text (sc));
- return -1;
- }
-
- sc = rtems_task_start (id,
- rtems_pcap_loop_thread,
- &pcap_loop_args);
- if (sc != RTEMS_SUCCESSFUL)
- {
- fprintf(stderr, "error: cannot start helper thread: %s\n",
- rtems_status_text (sc));
- rtems_task_delete (id);
- return -1;
- }
-
- printf("Press ENTER to end\n");
-
- while (true)
- {
- int c = getchar ();
-
- if ((c == '\r') || (c == '\n') || (c == 'q') || (c == 'Q'))
- {
- pcap_breakloop(pd);
- while (true)
- {
- if (!pcap_loop_args.running)
- break;
- usleep(10000);
- }
- break;
- }
- }
-
- return pcap_loop_args.ret;
-}
-#define pcap_loop rtems_pcap_loop
+#ifdef __rtems__
+static
#endif /* __rtems__ */
-
-netdissect_options Gndo;
-netdissect_options *gndo = &Gndo;
-
-static int dflag; /* print filter code */
+int dflag; /* print filter code */
+static int Gflag; /* rotate dump files after this many seconds */
+static int Gflag_count; /* number of files created with Gflag rotation */
+static time_t Gflag_time; /* The last time_t the dump file was rotated. */
static int Lflag; /* list available data link types and exit */
+static int Iflag; /* rfmon (monitor) mode */
#ifdef HAVE_PCAP_SET_TSTAMP_TYPE
static int Jflag; /* list available time stamp types */
#endif
+static int jflag = -1; /* packet time stamp source */
+static int pflag; /* don't go promiscuous */
+#ifdef HAVE_PCAP_SETDIRECTION
+static int Qflag = -1; /* restrict captured packet by send/receive direction */
+#endif
+static int Uflag; /* "unbuffered" output of dump files */
+static int Wflag; /* recycle output files after this number of files */
+static int WflagChars;
static char *zflag = NULL; /* compress each savefile using a specified command (like gzip or bzip2) */
+static int immediate_mode;
static int infodelay;
static int infoprint;
char *program_name;
-int32_t thiszone; /* seconds offset from gmt to local time */
+#ifdef HAVE_CASPER
+cap_channel_t *capdns;
+#endif
/* Forwards */
+static void error(const char *, ...)
+ __attribute__((noreturn))
+#ifdef __ATTRIBUTE___FORMAT_OK
+ __attribute__((format (printf, 1, 2)))
+#endif /* __ATTRIBUTE___FORMAT_OK */
+ ;
+static void warning(const char *, ...)
+#ifdef __ATTRIBUTE___FORMAT_OK
+ __attribute__((format (printf, 1, 2)))
+#endif /* __ATTRIBUTE___FORMAT_OK */
+ ;
+static void exit_tcpdump(int) __attribute__((noreturn));
static RETSIGTYPE cleanup(int);
static RETSIGTYPE child_cleanup(int);
-static void usage(void) __attribute__((noreturn));
-static void show_dlts_and_exit(const char *device, pcap_t *pd) __attribute__((noreturn));
+static void print_version(void);
+static void print_usage(void);
+static void show_tstamp_types_and_exit(pcap_t *, const char *device) __attribute__((noreturn));
+static void show_dlts_and_exit(pcap_t *, const char *device) __attribute__((noreturn));
+#ifdef HAVE_PCAP_FINDALLDEVS
+static void show_devices_and_exit (void) __attribute__((noreturn));
+#endif
static void print_packet(u_char *, const struct pcap_pkthdr *, const u_char *);
-static void ndo_default_print(netdissect_options *, const u_char *, u_int);
static void dump_packet_and_trunc(u_char *, const struct pcap_pkthdr *, const u_char *);
static void dump_packet(u_char *, const struct pcap_pkthdr *, const u_char *);
static void droproot(const char *, const char *);
-static void ndo_error(netdissect_options *ndo, const char *fmt, ...)
- __attribute__ ((noreturn, format (printf, 2, 3)));
-static void ndo_warning(netdissect_options *ndo, const char *fmt, ...);
#ifdef SIGNAL_REQ_INFO
RETSIGTYPE requestinfo(int);
@@ -299,279 +245,157 @@ RETSIGTYPE requestinfo(int);
static void info(int);
static u_int packets_captured;
-struct printer {
- if_printer f;
- int type;
-};
-
-
-struct ndo_printer {
- if_ndo_printer f;
- int type;
-};
-
-
-static const struct printer printers[] = {
-#if !__rtems__
- { arcnet_if_print, DLT_ARCNET },
-#endif
-#ifdef DLT_ARCNET_LINUX
- { arcnet_linux_if_print, DLT_ARCNET_LINUX },
-#endif
-#if !__rtems__
- { token_if_print, DLT_IEEE802 },
-#endif
-#ifdef DLT_LANE8023
- { lane_if_print, DLT_LANE8023 },
-#endif
-#ifdef DLT_CIP
- { cip_if_print, DLT_CIP },
-#endif
-#ifdef DLT_ATM_CLIP
- { cip_if_print, DLT_ATM_CLIP },
-#endif
- { sl_if_print, DLT_SLIP },
-#ifdef DLT_SLIP_BSDOS
- { sl_bsdos_if_print, DLT_SLIP_BSDOS },
-#endif
- { ppp_if_print, DLT_PPP },
-#ifdef DLT_PPP_WITHDIRECTION
- { ppp_if_print, DLT_PPP_WITHDIRECTION },
-#endif
-#ifdef DLT_PPP_BSDOS
- { ppp_bsdos_if_print, DLT_PPP_BSDOS },
-#endif
-#if !__rtems__
- { fddi_if_print, DLT_FDDI },
-#endif
- { null_if_print, DLT_NULL },
-#ifdef DLT_LOOP
- { null_if_print, DLT_LOOP },
-#endif
- { raw_if_print, DLT_RAW },
-#if !__rtems__
- { atm_if_print, DLT_ATM_RFC1483 },
-#endif
-#ifdef DLT_C_HDLC
- { chdlc_if_print, DLT_C_HDLC },
-#endif
-#ifdef DLT_HDLC
- { chdlc_if_print, DLT_HDLC },
-#endif
-#ifdef DLT_PPP_SERIAL
- { ppp_hdlc_if_print, DLT_PPP_SERIAL },
-#endif
-#ifdef DLT_PPP_ETHER
- { pppoe_if_print, DLT_PPP_ETHER },
-#endif
-#ifdef DLT_LINUX_SLL
- { sll_if_print, DLT_LINUX_SLL },
-#endif
-#ifdef DLT_IEEE802_11
- { ieee802_11_if_print, DLT_IEEE802_11},
-#endif
-#ifdef DLT_LTALK
- { ltalk_if_print, DLT_LTALK },
-#endif
-#if defined(DLT_PFLOG) && defined(HAVE_NET_PFVAR_H)
- { pflog_if_print, DLT_PFLOG },
-#endif
-#ifdef DLT_FR
- { fr_if_print, DLT_FR },
-#endif
-#ifdef DLT_FRELAY
- { fr_if_print, DLT_FRELAY },
-#endif
-#ifdef DLT_SUNATM
- { sunatm_if_print, DLT_SUNATM },
-#endif
-#ifdef DLT_IP_OVER_FC
- { ipfc_if_print, DLT_IP_OVER_FC },
-#endif
-#ifdef DLT_PRISM_HEADER
- { prism_if_print, DLT_PRISM_HEADER },
-#endif
-#ifdef DLT_IEEE802_11_RADIO
- { ieee802_11_radio_if_print, DLT_IEEE802_11_RADIO },
-#endif
-#ifdef DLT_ENC
- { enc_if_print, DLT_ENC },
-#endif
-#ifdef DLT_SYMANTEC_FIREWALL
- { symantec_if_print, DLT_SYMANTEC_FIREWALL },
-#endif
-#ifdef DLT_APPLE_IP_OVER_IEEE1394
- { ap1394_if_print, DLT_APPLE_IP_OVER_IEEE1394 },
-#endif
-#ifdef DLT_IEEE802_11_RADIO_AVS
- { ieee802_11_radio_avs_if_print, DLT_IEEE802_11_RADIO_AVS },
-#endif
-#ifdef DLT_JUNIPER_ATM1
- { juniper_atm1_print, DLT_JUNIPER_ATM1 },
-#endif
-#ifdef DLT_JUNIPER_ATM2
- { juniper_atm2_print, DLT_JUNIPER_ATM2 },
-#endif
-#ifdef DLT_JUNIPER_MFR
- { juniper_mfr_print, DLT_JUNIPER_MFR },
-#endif
-#ifdef DLT_JUNIPER_MLFR
- { juniper_mlfr_print, DLT_JUNIPER_MLFR },
-#endif
-#ifdef DLT_JUNIPER_MLPPP
- { juniper_mlppp_print, DLT_JUNIPER_MLPPP },
-#endif
-#ifdef DLT_JUNIPER_PPPOE
- { juniper_pppoe_print, DLT_JUNIPER_PPPOE },
-#endif
-#ifdef DLT_JUNIPER_PPPOE_ATM
- { juniper_pppoe_atm_print, DLT_JUNIPER_PPPOE_ATM },
-#endif
-#ifdef DLT_JUNIPER_GGSN
- { juniper_ggsn_print, DLT_JUNIPER_GGSN },
-#endif
-#ifdef DLT_JUNIPER_ES
- { juniper_es_print, DLT_JUNIPER_ES },
-#endif
-#ifdef DLT_JUNIPER_MONITOR
- { juniper_monitor_print, DLT_JUNIPER_MONITOR },
-#endif
-#ifdef DLT_JUNIPER_SERVICES
- { juniper_services_print, DLT_JUNIPER_SERVICES },
-#endif
-#ifdef DLT_JUNIPER_ETHER
- { juniper_ether_print, DLT_JUNIPER_ETHER },
-#endif
-#ifdef DLT_JUNIPER_PPP
- { juniper_ppp_print, DLT_JUNIPER_PPP },
-#endif
-#ifdef DLT_JUNIPER_FRELAY
- { juniper_frelay_print, DLT_JUNIPER_FRELAY },
-#endif
-#ifdef DLT_JUNIPER_CHDLC
- { juniper_chdlc_print, DLT_JUNIPER_CHDLC },
-#endif
-#ifdef DLT_MFR
- { mfr_if_print, DLT_MFR },
-#endif
-#if defined(DLT_BLUETOOTH_HCI_H4_WITH_PHDR) && defined(HAVE_PCAP_BLUETOOTH_H)
- { bt_if_print, DLT_BLUETOOTH_HCI_H4_WITH_PHDR},
-#endif
-#ifdef HAVE_PCAP_USB_H
-#ifdef DLT_USB_LINUX
- { usb_linux_48_byte_print, DLT_USB_LINUX},
-#endif /* DLT_USB_LINUX */
-#ifdef DLT_USB_LINUX_MMAPPED
- { usb_linux_64_byte_print, DLT_USB_LINUX_MMAPPED},
-#endif /* DLT_USB_LINUX_MMAPPED */
-#endif /* HAVE_PCAP_USB_H */
-#ifdef DLT_IPV4
- { raw_if_print, DLT_IPV4 },
+#ifdef HAVE_PCAP_FINDALLDEVS
+static const struct tok status_flags[] = {
+#ifdef PCAP_IF_UP
+ { PCAP_IF_UP, "Up" },
#endif
-#ifdef DLT_IPV6
- { raw_if_print, DLT_IPV6 },
+#ifdef PCAP_IF_RUNNING
+ { PCAP_IF_RUNNING, "Running" },
#endif
- { NULL, 0 },
+ { PCAP_IF_LOOPBACK, "Loopback" },
+ { 0, NULL }
};
-
-static const struct ndo_printer ndo_printers[] = {
- { ether_if_print, DLT_EN10MB },
-#ifdef DLT_IPNET
- { ipnet_if_print, DLT_IPNET },
#endif
-#ifdef DLT_IEEE802_15_4
- { ieee802_15_4_if_print, DLT_IEEE802_15_4 },
-#endif
-#ifdef DLT_IEEE802_15_4_NOFCS
- { ieee802_15_4_if_print, DLT_IEEE802_15_4_NOFCS },
-#endif
-#ifdef DLT_PPI
- { ppi_if_print, DLT_PPI },
-#endif
-#ifdef DLT_NETANALYZER
- { netanalyzer_if_print, DLT_NETANALYZER },
-#endif
-#ifdef DLT_NETANALYZER_TRANSPARENT
- { netanalyzer_transparent_if_print, DLT_NETANALYZER_TRANSPARENT },
-#endif
- { NULL, 0 },
-};
-
-if_printer
-lookup_printer(int type)
-{
- const struct printer *p;
-
- for (p = printers; p->f; ++p)
- if (type == p->type)
- return p->f;
-
- return NULL;
- /* NOTREACHED */
-}
-
-if_ndo_printer
-lookup_ndo_printer(int type)
-{
- const struct ndo_printer *p;
-
- for (p = ndo_printers; p->f; ++p)
- if (type == p->type)
- return p->f;
-
- return NULL;
- /* NOTREACHED */
-}
static pcap_t *pd;
static int supports_monitor_mode;
-#ifdef __rtems__
+#ifndef __rtems__
+extern int optind;
+extern int opterr;
+extern char *optarg;
+#else /* __rtems__ */
#define optind getopt_data.optind
#define optarg getopt_data.optarg
#define opterr getopt_data.opterr
#define optopt getopt_data.optopt
-#define getopt(argc, argv, opt) getopt_r(argc, argv, "+" opt, &getopt_data)
-#else
-extern int optind;
-extern int opterr;
-extern char *optarg;
-#endif
-
-struct print_info {
- netdissect_options *ndo;
- union {
- if_printer printer;
- if_ndo_printer ndo_printer;
- } p;
- int ndo_type;
-};
+#define getopt_long(argc, argv, so, lo, i) \
+ getopt_long_r(argc, argv, so, lo, i, &getopt_data)
+#endif /* __rtems__ */
struct dump_info {
char *WFileName;
char *CurrentFileName;
pcap_t *pd;
pcap_dumper_t *p;
+#ifdef HAVE_CAPSICUM
+ int dirfd;
+#endif
};
+#if defined(HAVE_PCAP_SET_PARSER_DEBUG)
+/*
+ * We have pcap_set_parser_debug() in libpcap; declare it (it's not declared
+ * by any libpcap header, because it's a special hack, only available if
+ * libpcap was configured to include it, and only intended for use by
+ * libpcap developers trying to debug the parser for filter expressions).
+ */
+#ifdef _WIN32
+__declspec(dllimport)
+#else /* _WIN32 */
+extern
+#endif /* _WIN32 */
+void pcap_set_parser_debug(int);
+#elif defined(HAVE_PCAP_DEBUG) || defined(HAVE_YYDEBUG)
+/*
+ * We don't have pcap_set_parser_debug() in libpcap, but we do have
+ * pcap_debug or yydebug. Make a local version of pcap_set_parser_debug()
+ * to set the flag, and define HAVE_PCAP_SET_PARSER_DEBUG.
+ */
+static void
+pcap_set_parser_debug(int value)
+{
+#ifdef HAVE_PCAP_DEBUG
+ extern int pcap_debug;
+
+ pcap_debug = value;
+#else /* HAVE_PCAP_DEBUG */
+ extern int yydebug;
+
+ yydebug = value;
+#endif /* HAVE_PCAP_DEBUG */
+}
+
+#define HAVE_PCAP_SET_PARSER_DEBUG
+#endif
+
+#if defined(HAVE_PCAP_SET_OPTIMIZER_DEBUG)
+/*
+ * We have pcap_set_optimizer_debug() in libpcap; declare it (it's not declared
+ * by any libpcap header, because it's a special hack, only available if
+ * libpcap was configured to include it, and only intended for use by
+ * libpcap developers trying to debug the optimizer for filter expressions).
+ */
+#ifdef _WIN32
+__declspec(dllimport)
+#else /* _WIN32 */
+extern
+#endif /* _WIN32 */
+void pcap_set_optimizer_debug(int);
+#endif
+
+/* VARARGS */
+static void
+error(const char *fmt, ...)
+{
+ va_list ap;
+
+ (void)fprintf(stderr, "%s: ", program_name);
+ va_start(ap, fmt);
+ (void)vfprintf(stderr, fmt, ap);
+ va_end(ap);
+ if (*fmt) {
+ fmt += strlen(fmt);
+ if (fmt[-1] != '\n')
+ (void)fputc('\n', stderr);
+ }
+ exit_tcpdump(1);
+ /* NOTREACHED */
+}
+
+/* VARARGS */
+static void
+warning(const char *fmt, ...)
+{
+ va_list ap;
+
+ (void)fprintf(stderr, "%s: WARNING: ", program_name);
+ va_start(ap, fmt);
+ (void)vfprintf(stderr, fmt, ap);
+ va_end(ap);
+ if (*fmt) {
+ fmt += strlen(fmt);
+ if (fmt[-1] != '\n')
+ (void)fputc('\n', stderr);
+ }
+}
+
+static void
+exit_tcpdump(int status)
+{
+ nd_cleanup();
+ exit(status);
+}
+
#ifdef HAVE_PCAP_SET_TSTAMP_TYPE
static void
-show_tstamp_types_and_exit(const char *device, pcap_t *pd)
+show_tstamp_types_and_exit(pcap_t *pc, const char *device)
{
int n_tstamp_types;
int *tstamp_types = 0;
const char *tstamp_type_name;
int i;
- n_tstamp_types = pcap_list_tstamp_types(pd, &tstamp_types);
+ n_tstamp_types = pcap_list_tstamp_types(pc, &tstamp_types);
if (n_tstamp_types < 0)
- error("%s", pcap_geterr(pd));
+ error("%s", pcap_geterr(pc));
if (n_tstamp_types == 0) {
fprintf(stderr, "Time stamp type cannot be set for %s\n",
device);
- exit(0);
+ exit_tcpdump(0);
}
fprintf(stderr, "Time stamp types for %s (use option -j to set):\n",
device);
@@ -585,20 +409,20 @@ show_tstamp_types_and_exit(const char *device, pcap_t *pd)
}
}
pcap_free_tstamp_types(tstamp_types);
- exit(0);
+ exit_tcpdump(0);
}
#endif
static void
-show_dlts_and_exit(const char *device, pcap_t *pd)
+show_dlts_and_exit(pcap_t *pc, const char *device)
{
- int n_dlts;
+ int n_dlts, i;
int *dlts = 0;
const char *dlt_name;
- n_dlts = pcap_list_datalinks(pd, &dlts);
+ n_dlts = pcap_list_datalinks(pc, &dlts);
if (n_dlts < 0)
- error("%s", pcap_geterr(pd));
+ error("%s", pcap_geterr(pc));
else if (n_dlts == 0 || !dlts)
error("No data link types.");
@@ -618,41 +442,93 @@ show_dlts_and_exit(const char *device, pcap_t *pd)
(void) fprintf(stderr, "Data link types for %s (use option -y to set):\n",
device);
- while (--n_dlts >= 0) {
- dlt_name = pcap_datalink_val_to_name(dlts[n_dlts]);
+ for (i = 0; i < n_dlts; i++) {
+ dlt_name = pcap_datalink_val_to_name(dlts[i]);
if (dlt_name != NULL) {
(void) fprintf(stderr, " %s (%s)", dlt_name,
- pcap_datalink_val_to_description(dlts[n_dlts]));
+ pcap_datalink_val_to_description(dlts[i]));
/*
* OK, does tcpdump handle that type?
*/
- if (lookup_printer(dlts[n_dlts]) == NULL
- && lookup_ndo_printer(dlts[n_dlts]) == NULL)
+ if (!has_printer(dlts[i]))
(void) fprintf(stderr, " (printing not supported)");
fprintf(stderr, "\n");
} else {
(void) fprintf(stderr, " DLT %d (printing not supported)\n",
- dlts[n_dlts]);
+ dlts[i]);
}
}
#ifdef HAVE_PCAP_FREE_DATALINKS
pcap_free_datalinks(dlts);
#endif
- exit(0);
+ exit_tcpdump(0);
}
+#ifdef HAVE_PCAP_FINDALLDEVS
+static void
+show_devices_and_exit (void)
+{
+ pcap_if_t *dev, *devlist;
+ char ebuf[PCAP_ERRBUF_SIZE];
+ int i;
+
+ if (pcap_findalldevs(&devlist, ebuf) < 0)
+ error("%s", ebuf);
+ for (i = 0, dev = devlist; dev != NULL; i++, dev = dev->next) {
+ printf("%d.%s", i+1, dev->name);
+ if (dev->description != NULL)
+ printf(" (%s)", dev->description);
+ if (dev->flags != 0)
+ printf(" [%s]", bittok2str(status_flags, "none", dev->flags));
+ printf("\n");
+ }
+ pcap_freealldevs(devlist);
+ exit_tcpdump(0);
+}
+#endif /* HAVE_PCAP_FINDALLDEVS */
+
+/*
+ * Short options.
+ *
+ * Note that there we use all letters for short options except for g, k,
+ * o, and P, and those are used by other versions of tcpdump, and we should
+ * only use them for the same purposes that the other versions of tcpdump
+ * use them:
+ *
+ * OS X tcpdump uses -g to force non--v output for IP to be on one
+ * line, making it more "g"repable;
+ *
+ * OS X tcpdump uses -k to specify that packet comments in pcap-ng files
+ * should be printed;
+ *
+ * OpenBSD tcpdump uses -o to indicate that OS fingerprinting should be done
+ * for hosts sending TCP SYN packets;
+ *
+ * OS X tcpdump uses -P to indicate that -w should write pcap-ng rather
+ * than pcap files.
+ *
+ * OS X tcpdump also uses -Q to specify expressions that match packet
+ * metadata, including but not limited to the packet direction.
+ * The expression syntax is different from a simple "in|out|inout",
+ * and those expressions aren't accepted by OS X tcpdump, but the
+ * equivalents would be "in" = "dir=in", "out" = "dir=out", and
+ * "inout" = "dir=in or dir=out", and the parser could conceivably
+ * special-case "in", "out", and "inout" as expressions for backwards
+ * compatibility, so all is not (yet) lost.
+ */
+
/*
* Set up flags that might or might not be supported depending on the
* version of libpcap we're using.
*/
-#if defined(HAVE_PCAP_CREATE) || defined(WIN32)
+#if defined(HAVE_PCAP_CREATE) || defined(_WIN32)
#define B_FLAG "B:"
#define B_FLAG_USAGE " [ -B size ]"
-#else /* defined(HAVE_PCAP_CREATE) || defined(WIN32) */
+#else /* defined(HAVE_PCAP_CREATE) || defined(_WIN32) */
#define B_FLAG
#define B_FLAG_USAGE
-#endif /* defined(HAVE_PCAP_CREATE) || defined(WIN32) */
+#endif /* defined(HAVE_PCAP_CREATE) || defined(_WIN32) */
#ifdef HAVE_PCAP_CREATE
#define I_FLAG "I"
@@ -671,12 +547,6 @@ show_dlts_and_exit(const char *device, pcap_t *pd)
#endif /* PCAP_ERROR_TSTAMP_TYPE_NOTSUP */
#ifdef HAVE_PCAP_FINDALLDEVS
-#ifndef HAVE_PCAP_IF_T
-#undef HAVE_PCAP_FINDALLDEVS
-#endif
-#endif
-
-#ifdef HAVE_PCAP_FINDALLDEVS
#define D_FLAG "D"
#else
#define D_FLAG
@@ -688,7 +558,81 @@ show_dlts_and_exit(const char *device, pcap_t *pd)
#define U_FLAG
#endif
-#ifndef WIN32
+#ifdef HAVE_PCAP_SETDIRECTION
+#define Q_FLAG "Q:"
+#else
+#define Q_FLAG
+#endif
+
+#define SHORTOPTS "aAb" B_FLAG "c:C:d" D_FLAG "eE:fF:G:hHi:" I_FLAG j_FLAG J_FLAG "KlLm:M:nNOpq" Q_FLAG "r:s:StT:u" U_FLAG "vV:w:W:xXy:Yz:Z:#"
+
+/*
+ * Long options.
+ *
+ * We do not currently have long options corresponding to all short
+ * options; we should probably pick appropriate option names for them.
+ *
+ * However, the short options where the number of times the option is
+ * specified matters, such as -v and -d and -t, should probably not
+ * just map to a long option, as saying
+ *
+ * tcpdump --verbose --verbose
+ *
+ * doesn't make sense; it should be --verbosity={N} or something such
+ * as that.
+ *
+ * For long options with no corresponding short options, we define values
+ * outside the range of ASCII graphic characters, make that the last
+ * component of the entry for the long option, and have a case for that
+ * option in the switch statement.
+ */
+#define OPTION_VERSION 128
+#define OPTION_TSTAMP_PRECISION 129
+#define OPTION_IMMEDIATE_MODE 130
+
+static const struct option longopts[] = {
+#if defined(HAVE_PCAP_CREATE) || defined(_WIN32)
+ { "buffer-size", required_argument, NULL, 'B' },
+#endif
+ { "list-interfaces", no_argument, NULL, 'D' },
+ { "help", no_argument, NULL, 'h' },
+ { "interface", required_argument, NULL, 'i' },
+#ifdef HAVE_PCAP_CREATE
+ { "monitor-mode", no_argument, NULL, 'I' },
+#endif
+#ifdef HAVE_PCAP_SET_TSTAMP_TYPE
+ { "time-stamp-type", required_argument, NULL, 'j' },
+ { "list-time-stamp-types", no_argument, NULL, 'J' },
+#endif
+#ifdef HAVE_PCAP_SET_TSTAMP_PRECISION
+ { "time-stamp-precision", required_argument, NULL, OPTION_TSTAMP_PRECISION},
+#endif
+ { "dont-verify-checksums", no_argument, NULL, 'K' },
+ { "list-data-link-types", no_argument, NULL, 'L' },
+ { "no-optimize", no_argument, NULL, 'O' },
+ { "no-promiscuous-mode", no_argument, NULL, 'p' },
+#ifdef HAVE_PCAP_SETDIRECTION
+ { "direction", required_argument, NULL, 'Q' },
+#endif
+ { "snapshot-length", required_argument, NULL, 's' },
+ { "absolute-tcp-sequence-numbers", no_argument, NULL, 'S' },
+#ifdef HAVE_PCAP_DUMP_FLUSH
+ { "packet-buffered", no_argument, NULL, 'U' },
+#endif
+ { "linktype", required_argument, NULL, 'y' },
+#ifdef HAVE_PCAP_SET_IMMEDIATE_MODE
+ { "immediate-mode", no_argument, NULL, OPTION_IMMEDIATE_MODE },
+#endif
+#ifdef HAVE_PCAP_SET_PARSER_DEBUG
+ { "debug-filter-parser", no_argument, NULL, 'Y' },
+#endif
+ { "relinquish-privileges", required_argument, NULL, 'Z' },
+ { "number", no_argument, NULL, '#' },
+ { "version", no_argument, NULL, OPTION_VERSION },
+ { NULL, 0, NULL, 0 }
+};
+
+#ifndef _WIN32
/* Drop root privileges and chroot if necessary */
static void
droproot(const char *username, const char *chroot_dir)
@@ -696,52 +640,65 @@ droproot(const char *username, const char *chroot_dir)
struct passwd *pw = NULL;
if (chroot_dir && !username) {
- fprintf(stderr, "tcpdump: Chroot without dropping root is insecure\n");
- exit(1);
+ fprintf(stderr, "%s: Chroot without dropping root is insecure\n",
+ program_name);
+ exit_tcpdump(1);
}
pw = getpwnam(username);
if (pw) {
if (chroot_dir) {
if (chroot(chroot_dir) != 0 || chdir ("/") != 0) {
- fprintf(stderr, "tcpdump: Couldn't chroot/chdir to '%.64s': %s\n",
- chroot_dir, pcap_strerror(errno));
- exit(1);
+ fprintf(stderr, "%s: Couldn't chroot/chdir to '%.64s': %s\n",
+ program_name, chroot_dir, pcap_strerror(errno));
+ exit_tcpdump(1);
}
}
-#ifdef HAVE_CAP_NG_H
- int ret = capng_change_id(pw->pw_uid, pw->pw_gid, CAPNG_NO_FLAG);
- if (ret < 0) {
- printf("error : ret %d\n", ret);
+#ifdef HAVE_LIBCAP_NG
+ {
+ int ret = capng_change_id(pw->pw_uid, pw->pw_gid, CAPNG_NO_FLAG);
+ if (ret < 0) {
+ fprintf(stderr, "error : ret %d\n", ret);
+ } else {
+ fprintf(stderr, "dropped privs to %s\n", username);
+ }
}
- /* We don't need CAP_SETUID and CAP_SETGID */
- capng_update(CAPNG_DROP, CAPNG_EFFECTIVE, CAP_SETUID);
- capng_update(CAPNG_DROP, CAPNG_EFFECTIVE, CAP_SETUID);
- capng_update(CAPNG_DROP, CAPNG_PERMITTED, CAP_SETUID);
- capng_update(CAPNG_DROP, CAPNG_PERMITTED, CAP_SETUID);
- capng_apply(CAPNG_SELECT_BOTH);
-
#else
#ifndef __rtems__
if (initgroups(pw->pw_name, pw->pw_gid) != 0 ||
setgid(pw->pw_gid) != 0 || setuid(pw->pw_uid) != 0) {
- fprintf(stderr, "tcpdump: Couldn't change to '%.32s' uid=%lu gid=%lu: %s\n",
- username,
- (unsigned long)pw->pw_uid,
- (unsigned long)pw->pw_gid,
- pcap_strerror(errno));
- exit(1);
+ fprintf(stderr, "%s: Couldn't change to '%.32s' uid=%lu gid=%lu: %s\n",
+ program_name, username,
+ (unsigned long)pw->pw_uid,
+ (unsigned long)pw->pw_gid,
+ pcap_strerror(errno));
+ exit_tcpdump(1);
}
-#endif
-#endif /* HAVE_CAP_NG_H */
+ else {
+ fprintf(stderr, "dropped privs to %s\n", username);
+ }
+#endif /* __rtems__ */
+#endif /* HAVE_LIBCAP_NG */
}
else {
- fprintf(stderr, "tcpdump: Couldn't find user '%.32s'\n",
- username);
- exit(1);
+ fprintf(stderr, "%s: Couldn't find user '%.32s'\n",
+ program_name, username);
+ exit_tcpdump(1);
}
+#ifdef HAVE_LIBCAP_NG
+ /* We don't need CAP_SETUID, CAP_SETGID and CAP_SYS_CHROOT any more. */
+ capng_updatev(
+ CAPNG_DROP,
+ CAPNG_EFFECTIVE | CAPNG_PERMITTED,
+ CAP_SETUID,
+ CAP_SETGID,
+ CAP_SYS_CHROOT,
+ -1);
+ capng_apply(CAPNG_SELECT_BOTH);
+#endif /* HAVE_LIBCAP_NG */
+
}
-#endif /* WIN32 */
+#endif /* _WIN32 */
static int
getWflagChars(int x)
@@ -791,87 +748,549 @@ MakeFilename(char *buffer, char *orig_name, int cnt, int max_chars)
free(filename);
}
-static int tcpdump_printf(netdissect_options *ndo _U_,
- const char *fmt, ...)
+static char *
+get_next_file(FILE *VFile, char *ptr)
{
+ char *ret;
+
+ ret = fgets(ptr, PATH_MAX, VFile);
+ if (!ret)
+ return NULL;
- va_list args;
- int ret;
+ if (ptr[strlen(ptr) - 1] == '\n')
+ ptr[strlen(ptr) - 1] = '\0';
- va_start(args, fmt);
- ret=vfprintf(stdout, fmt, args);
- va_end(args);
+ return ret;
+}
- return ret;
+#ifdef HAVE_CASPER
+static cap_channel_t *
+capdns_setup(void)
+{
+ cap_channel_t *capcas, *capdnsloc;
+ const char *types[1];
+ int families[2];
+
+ capcas = cap_init();
+ if (capcas == NULL)
+ error("unable to create casper process");
+ capdnsloc = cap_service_open(capcas, "system.dns");
+ /* Casper capability no longer needed. */
+ cap_close(capcas);
+ if (capdnsloc == NULL)
+ error("unable to open system.dns service");
+ /* Limit system.dns to reverse DNS lookups. */
+ types[0] = "ADDR";
+ if (cap_dns_type_limit(capdnsloc, types, 1) < 0)
+ error("unable to limit access to system.dns service");
+ families[0] = AF_INET;
+ families[1] = AF_INET6;
+ if (cap_dns_family_limit(capdnsloc, families, 2) < 0)
+ error("unable to limit access to system.dns service");
+
+ return (capdnsloc);
}
+#endif /* HAVE_CASPER */
-static struct print_info
-get_print_info(int type)
+#ifdef HAVE_PCAP_SET_TSTAMP_PRECISION
+static int
+tstamp_precision_from_string(const char *precision)
{
- struct print_info printinfo;
-
- printinfo.ndo_type = 1;
- printinfo.ndo = gndo;
- printinfo.p.ndo_printer = lookup_ndo_printer(type);
- if (printinfo.p.ndo_printer == NULL) {
- printinfo.p.printer = lookup_printer(type);
- printinfo.ndo_type = 0;
- if (printinfo.p.printer == NULL) {
- gndo->ndo_dltname = pcap_datalink_val_to_name(type);
- if (gndo->ndo_dltname != NULL)
- error("packet printing is not supported for link type %s: use -w",
- gndo->ndo_dltname);
- else
- error("packet printing is not supported for link type %d: use -w", type);
+ if (strncmp(precision, "nano", strlen("nano")) == 0)
+ return PCAP_TSTAMP_PRECISION_NANO;
+
+ if (strncmp(precision, "micro", strlen("micro")) == 0)
+ return PCAP_TSTAMP_PRECISION_MICRO;
+
+ return -EINVAL;
+}
+
+static const char *
+tstamp_precision_to_string(int precision)
+{
+ switch (precision) {
+
+ case PCAP_TSTAMP_PRECISION_MICRO:
+ return "micro";
+
+ case PCAP_TSTAMP_PRECISION_NANO:
+ return "nano";
+
+ default:
+ return "unknown";
+ }
+}
+#endif
+
+#ifdef HAVE_CAPSICUM
+/*
+ * Ensure that, on a dump file's descriptor, we have all the rights
+ * necessary to make the standard I/O library work with an fdopen()ed
+ * FILE * from that descriptor.
+ *
+ * A long time ago, in a galaxy far far away, AT&T decided that, instead
+ * of providing separate APIs for getting and setting the FD_ flags on a
+ * descriptor, getting and setting the O_ flags on a descriptor, and
+ * locking files, they'd throw them all into a kitchen-sink fcntl() call
+ * along the lines of ioctl(), the fact that ioctl() operations are
+ * largely specific to particular character devices but fcntl() operations
+ * are either generic to all descriptors or generic to all descriptors for
+ * regular files nonwithstanding.
+ *
+ * The Capsicum people decided that fine-grained control of descriptor
+ * operations was required, so that you need to grant permission for
+ * reading, writing, seeking, and fcntl-ing. The latter, courtesy of
+ * AT&T's decision, means that "fcntl-ing" isn't a thing, but a motley
+ * collection of things, so there are *individual* fcntls for which
+ * permission needs to be granted.
+ *
+ * The FreeBSD standard I/O people implemented some optimizations that
+ * requires that the standard I/O routines be able to determine whether
+ * the descriptor for the FILE * is open append-only or not; as that
+ * descriptor could have come from an open() rather than an fopen(),
+ * that requires that it be able to do an F_GETFL fcntl() to read
+ * the O_ flags.
+ *
+ * Tcpdump uses ftell() to determine how much data has been written
+ * to a file in order to, when used with -C, determine when it's time
+ * to rotate capture files. ftell() therefore needs to do an lseek()
+ * to find out the file offset and must, thanks to the aforementioned
+ * optimization, also know whether the descriptor is open append-only
+ * or not.
+ *
+ * The net result of all the above is that we need to grant CAP_SEEK,
+ * CAP_WRITE, and CAP_FCNTL with the CAP_FCNTL_GETFL subcapability.
+ *
+ * Perhaps this is the universe's way of saying that either
+ *
+ * 1) there needs to be an fopenat() call and a pcap_dump_openat() call
+ * using it, so that Capsicum-capable tcpdump wouldn't need to do
+ * an fdopen()
+ *
+ * or
+ *
+ * 2) there needs to be a cap_fdopen() call in the FreeBSD standard
+ * I/O library that knows what rights are needed by the standard
+ * I/O library, based on the open mode, and assigns them, perhaps
+ * with an additional argument indicating, for example, whether
+ * seeking should be allowed, so that tcpdump doesn't need to know
+ * what the standard I/O library happens to require this week.
+ */
+static void
+set_dumper_capsicum_rights(pcap_dumper_t *p)
+{
+ int fd = fileno(pcap_dump_file(p));
+ cap_rights_t rights;
+
+ cap_rights_init(&rights, CAP_SEEK, CAP_WRITE, CAP_FCNTL);
+ if (cap_rights_limit(fd, &rights) < 0 && errno != ENOSYS) {
+ error("unable to limit dump descriptor");
+ }
+ if (cap_fcntls_limit(fd, CAP_FCNTL_GETFL) < 0 && errno != ENOSYS) {
+ error("unable to limit dump descriptor fcntls");
+ }
+}
+#endif
+
+/*
+ * Copy arg vector into a new buffer, concatenating arguments with spaces.
+ */
+static char *
+copy_argv(register char **argv)
+{
+ register char **p;
+ register u_int len = 0;
+ char *buf;
+ char *src, *dst;
+
+ p = argv;
+ if (*p == NULL)
+ return 0;
+
+ while (*p)
+ len += strlen(*p++) + 1;
+
+ buf = (char *)malloc(len);
+ if (buf == NULL)
+ error("copy_argv: malloc");
+
+ p = argv;
+ dst = buf;
+ while ((src = *p++) != NULL) {
+ while ((*dst++ = *src++) != '\0')
+ ;
+ dst[-1] = ' ';
+ }
+ dst[-1] = '\0';
+
+ return buf;
+}
+
+/*
+ * On Windows, we need to open the file in binary mode, so that
+ * we get all the bytes specified by the size we get from "fstat()".
+ * On UNIX, that's not necessary. O_BINARY is defined on Windows;
+ * we define it as 0 if it's not defined, so it does nothing.
+ */
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
+
+static char *
+read_infile(char *fname)
+{
+ register int i, fd, cc;
+ register char *cp;
+ struct stat buf;
+
+ fd = open(fname, O_RDONLY|O_BINARY);
+ if (fd < 0)
+ error("can't open %s: %s", fname, pcap_strerror(errno));
+
+ if (fstat(fd, &buf) < 0)
+ error("can't stat %s: %s", fname, pcap_strerror(errno));
+
+ cp = malloc((u_int)buf.st_size + 1);
+ if (cp == NULL)
+ error("malloc(%d) for %s: %s", (u_int)buf.st_size + 1,
+ fname, pcap_strerror(errno));
+ cc = read(fd, cp, (u_int)buf.st_size);
+ if (cc < 0)
+ error("read %s: %s", fname, pcap_strerror(errno));
+ if (cc != buf.st_size)
+ error("short read %s (%d != %d)", fname, cc, (int)buf.st_size);
+
+ close(fd);
+ /* replace "# comment" with spaces */
+ for (i = 0; i < cc; i++) {
+ if (cp[i] == '#')
+ while (i < cc && cp[i] != '\n')
+ cp[i++] = ' ';
+ }
+ cp[cc] = '\0';
+ return (cp);
+}
+
+#ifdef HAVE_PCAP_FINDALLDEVS
+static long
+parse_interface_number(const char *device)
+{
+ long devnum;
+ char *end;
+
+ devnum = strtol(device, &end, 10);
+ if (device != end && *end == '\0') {
+ /*
+ * It's all-numeric, but is it a valid number?
+ */
+ if (devnum <= 0) {
+ /*
+ * No, it's not an ordinal.
+ */
+ error("Invalid adapter index");
}
+ return (devnum);
+ } else {
+ /*
+ * It's not all-numeric; return -1, so our caller
+ * knows that.
+ */
+ return (-1);
}
- return (printinfo);
}
static char *
-get_next_file(FILE *VFile, char *ptr)
+find_interface_by_number(long devnum)
{
- char *ret;
+ pcap_if_t *dev, *devlist;
+ long i;
+ char ebuf[PCAP_ERRBUF_SIZE];
+ char *device;
- ret = fgets(ptr, PATH_MAX, VFile);
- if (!ret)
- return NULL;
+ if (pcap_findalldevs(&devlist, ebuf) < 0)
+ error("%s", ebuf);
+ /*
+ * Look for the devnum-th entry in the list of devices (1-based).
+ */
+ for (i = 0, dev = devlist; i < devnum-1 && dev != NULL;
+ i++, dev = dev->next)
+ ;
+ if (dev == NULL)
+ error("Invalid adapter index");
+ device = strdup(dev->name);
+ pcap_freealldevs(devlist);
+ return (device);
+}
+#endif
- if (ptr[strlen(ptr) - 1] == '\n')
- ptr[strlen(ptr) - 1] = '\0';
+static pcap_t *
+open_interface(const char *device, netdissect_options *ndo, char *ebuf)
+{
+ pcap_t *pc;
+#ifdef HAVE_PCAP_CREATE
+ int status;
+ char *cp;
+#endif
- return ret;
+#ifdef HAVE_PCAP_CREATE
+ pc = pcap_create(device, ebuf);
+ if (pc == NULL) {
+ /*
+ * If this failed with "No such device", that means
+ * the interface doesn't exist; return NULL, so that
+ * the caller can see whether the device name is
+ * actually an interface index.
+ */
+ if (strstr(ebuf, "No such device") != NULL)
+ return (NULL);
+ error("%s", ebuf);
+ }
+#ifdef HAVE_PCAP_SET_TSTAMP_TYPE
+ if (Jflag)
+ show_tstamp_types_and_exit(pc, device);
+#endif
+#ifdef HAVE_PCAP_SET_TSTAMP_PRECISION
+ status = pcap_set_tstamp_precision(pc, ndo->ndo_tstamp_precision);
+ if (status != 0)
+ error("%s: Can't set %ssecond time stamp precision: %s",
+ device,
+ tstamp_precision_to_string(ndo->ndo_tstamp_precision),
+ pcap_statustostr(status));
+#endif
+
+#ifdef HAVE_PCAP_SET_IMMEDIATE_MODE
+ if (immediate_mode) {
+ status = pcap_set_immediate_mode(pc, 1);
+ if (status != 0)
+ error("%s: Can't set immediate mode: %s",
+ device,
+ pcap_statustostr(status));
+ }
+#endif
+ /*
+ * Is this an interface that supports monitor mode?
+ */
+ if (pcap_can_set_rfmon(pc) == 1)
+ supports_monitor_mode = 1;
+ else
+ supports_monitor_mode = 0;
+ status = pcap_set_snaplen(pc, ndo->ndo_snaplen);
+ if (status != 0)
+ error("%s: Can't set snapshot length: %s",
+ device, pcap_statustostr(status));
+ status = pcap_set_promisc(pc, !pflag);
+ if (status != 0)
+ error("%s: Can't set promiscuous mode: %s",
+ device, pcap_statustostr(status));
+ if (Iflag) {
+ status = pcap_set_rfmon(pc, 1);
+ if (status != 0)
+ error("%s: Can't set monitor mode: %s",
+ device, pcap_statustostr(status));
+ }
+ status = pcap_set_timeout(pc, 1000);
+ if (status != 0)
+ error("%s: pcap_set_timeout failed: %s",
+ device, pcap_statustostr(status));
+ if (Bflag != 0) {
+ status = pcap_set_buffer_size(pc, Bflag);
+ if (status != 0)
+ error("%s: Can't set buffer size: %s",
+ device, pcap_statustostr(status));
+ }
+#ifdef HAVE_PCAP_SET_TSTAMP_TYPE
+ if (jflag != -1) {
+ status = pcap_set_tstamp_type(pc, jflag);
+ if (status < 0)
+ error("%s: Can't set time stamp type: %s",
+ device, pcap_statustostr(status));
+ }
+#endif
+ status = pcap_activate(pc);
+ if (status < 0) {
+ /*
+ * pcap_activate() failed.
+ */
+ cp = pcap_geterr(pc);
+ if (status == PCAP_ERROR)
+ error("%s", cp);
+ else if (status == PCAP_ERROR_NO_SUCH_DEVICE) {
+ /*
+ * Return an error for our caller to handle.
+ */
+ pcap_close(pc);
+ snprintf(ebuf, PCAP_ERRBUF_SIZE, "%s: %s\n(%s)",
+ device, pcap_statustostr(status), cp);
+ return (NULL);
+ } else if (status == PCAP_ERROR_PERM_DENIED && *cp != '\0')
+ error("%s: %s\n(%s)", device,
+ pcap_statustostr(status), cp);
+#ifdef __FreeBSD__
+ else if (status == PCAP_ERROR_RFMON_NOTSUP &&
+ strncmp(device, "wlan", 4) == 0) {
+ char parent[8], newdev[8];
+ char sysctl[32];
+ size_t s = sizeof(parent);
+
+ snprintf(sysctl, sizeof(sysctl),
+ "net.wlan.%d.%%parent", atoi(device + 4));
+ sysctlbyname(sysctl, parent, &s, NULL, 0);
+ strlcpy(newdev, device, sizeof(newdev));
+ /* Suggest a new wlan device. */
+ newdev[strlen(newdev)-1]++;
+ error("%s is not a monitor mode VAP\n"
+ "To create a new monitor mode VAP use:\n"
+ " ifconfig %s create wlandev %s wlanmode monitor\n"
+ "and use %s as the tcpdump interface",
+ device, newdev, parent, newdev);
+ }
+#endif
+ else
+ error("%s: %s", device,
+ pcap_statustostr(status));
+ } else if (status > 0) {
+ /*
+ * pcap_activate() succeeded, but it's warning us
+ * of a problem it had.
+ */
+ cp = pcap_geterr(pc);
+ if (status == PCAP_WARNING)
+ warning("%s", cp);
+ else if (status == PCAP_WARNING_PROMISC_NOTSUP &&
+ *cp != '\0')
+ warning("%s: %s\n(%s)", device,
+ pcap_statustostr(status), cp);
+ else
+ warning("%s: %s", device,
+ pcap_statustostr(status));
+ }
+#ifdef HAVE_PCAP_SETDIRECTION
+ if (Qflag != -1) {
+ status = pcap_setdirection(pc, Qflag);
+ if (status != 0)
+ error("%s: pcap_setdirection() failed: %s",
+ device, pcap_geterr(pc));
+ }
+#endif /* HAVE_PCAP_SETDIRECTION */
+#else /* HAVE_PCAP_CREATE */
+ *ebuf = '\0';
+ pc = pcap_open_live(device, ndo->ndo_snaplen, !pflag, 1000, ebuf);
+ if (pc == NULL) {
+ /*
+ * If this failed with "No such device", that means
+ * the interface doesn't exist; return NULL, so that
+ * the caller can see whether the device name is
+ * actually an interface index.
+ */
+ if (strstr(ebuf, "No such device") != NULL)
+ return (NULL);
+ error("%s", ebuf);
+ }
+ if (*ebuf)
+ warning("%s", ebuf);
+#endif /* HAVE_PCAP_CREATE */
+
+ return (pc);
}
#ifdef __rtems__
static int main(int argc, char **argv);
-int rtems_bsd_command_tcpdump(int argc, char *argv[])
+RTEMS_LINKER_RWSET(bsd_prog_tcpdump, char);
+
+int
+rtems_bsd_command_tcpdump(int argc, char *argv[])
{
int exit_code;
+ void *data_begin;
+ size_t data_size;
+
+ data_begin = RTEMS_LINKER_SET_BEGIN(bsd_prog_tcpdump);
+ data_size = RTEMS_LINKER_SET_SIZE(bsd_prog_tcpdump);
rtems_bsd_program_lock();
+ exit_code = rtems_bsd_program_call_main_with_data_restore("tcpdump",
+ main, argc, argv, data_begin, data_size);
+ rtems_bsd_program_unlock();
- dflag = 0;
- Lflag = 0;
-#ifdef HAVE_PCAP_SET_TSTAMP_TYPE
- Jflag = 0;
-#endif
- zflag = NULL;
- infodelay = 0;
- infoprint = 0;
- program_name = NULL;
- thiszone = 0;
- packets_captured = 0;
- pd = 0;
- supports_monitor_mode = 0;
+ return (exit_code);
+}
- exit_code = rtems_bsd_program_call_main("tcpdump", main, argc, argv);
+typedef struct {
+ FILE *in;
+ pcap_t *pd;
+ rtems_id master;
+} pcap_loop_context;
- rtems_bsd_program_unlock();
+static void
+pcap_loop_monitor(rtems_task_argument arg)
+{
+ pcap_loop_context *ctx;
+ FILE *in;
+ pcap_t *pd;
+ rtems_id master;
+ rtems_status_code sc;
+
+ ctx = (pcap_loop_context *)arg;
+ in = ctx->in;
+ pd = ctx->pd;
+ master = ctx->master;
+
+ sc = rtems_event_transient_send(master);
+ assert(sc == RTEMS_SUCCESSFUL);
+
+ while (true) {
+ int c;
+
+ c = fgetc(in);
+
+ if (c == '\r' || c == '\n' || c == 'q' || c == 'Q') {
+ pcap_breakloop(pd);
+ break;
+ }
+ }
+
+ rtems_task_delete(RTEMS_SELF);
+ assert(0);
+}
+
+static int
+pcap_loop_wrapper(pcap_t *pd, int cnt, pcap_handler cb, u_char *ud)
+{
+ rtems_status_code sc;
+ rtems_task_priority priority;
+ rtems_id id;
+ pcap_loop_context ctx;
+
+ sc = rtems_task_set_priority(RTEMS_SELF, RTEMS_CURRENT_PRIORITY,
+ &priority);
+ assert(sc == RTEMS_SUCCESSFUL);
+
+ sc = rtems_task_create(rtems_build_name('T', 'C', 'P', 'D'), priority,
+ RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES,
+ RTEMS_DEFAULT_ATTRIBUTES, &id);
+ if (sc != RTEMS_SUCCESSFUL) {
+ fprintf(stderr, "tcpdump: cannot create helper thread: %s\n",
+ rtems_status_text(sc));
+ return (-1);
+ }
+
+ fprintf(stdout, "tcpdump: press <ENTER> or 'q' or 'Q' to quit\n");
- return exit_code;
+ ctx.in = stdin;
+ ctx.pd = pd;
+ ctx.master = rtems_task_self();
+ sc = rtems_task_start(id, pcap_loop_monitor,
+ (rtems_task_argument)&ctx);
+ assert(sc == RTEMS_SUCCESSFUL);
+
+ sc = rtems_event_transient_receive(RTEMS_WAIT, RTEMS_NO_TIMEOUT);
+ assert(sc == RTEMS_SUCCESSFUL);
+
+ return (pcap_loop(pd, cnt, cb, ud));
}
+
+#define pcap_loop(pd, cnt, cb, ud) pcap_loop_wrapper(pd, cnt, cb, ud)
#endif /* __rtems__ */
int
#ifndef __rtems__
@@ -881,18 +1300,16 @@ main(int argc, char **argv)
#endif /* __rtems__ */
{
register int cnt, op, i;
- bpf_u_int32 localnet, netmask;
+ bpf_u_int32 localnet =0 , netmask = 0;
+ int timezone_offset = 0;
register char *cp, *infile, *cmdbuf, *device, *RFileName, *VFileName, *WFileName;
pcap_handler callback;
- int type;
int dlt;
- int new_dlt;
const char *dlt_name;
struct bpf_program fcode;
-#ifndef WIN32
+#ifndef _WIN32
RETSIGTYPE (*oldhandler)(int);
#endif
- struct print_info printinfo;
struct dump_info dumpinfo;
u_char *pcap_userdata;
char ebuf[PCAP_ERRBUF_SIZE];
@@ -902,28 +1319,35 @@ main(int argc, char **argv)
char *ret = NULL;
char *end;
#ifdef HAVE_PCAP_FINDALLDEVS
- pcap_if_t *devpointer;
- int devnum;
+ pcap_if_t *devlist;
+ long devnum;
#endif
int status;
FILE *VFile;
+#ifdef HAVE_CAPSICUM
+ cap_rights_t rights;
+ int cansandbox;
+#endif /* HAVE_CAPSICUM */
+ int Oflag = 1; /* run filter code optimizer */
+ int yflag_dlt = -1;
+ const char *yflag_dlt_name = NULL;
#ifdef __rtems__
struct getopt_data getopt_data;
memset(&getopt_data, 0, sizeof(getopt_data));
-#endif
-#ifdef WIN32
- if(wsockinit() != 0) return 1;
-#endif /* WIN32 */
+#endif /* __rtems__ */
+
+ netdissect_options Ndo;
+ netdissect_options *ndo = &Ndo;
+
+ /*
+ * Initialize the netdissect code.
+ */
+ if (nd_init(ebuf, sizeof ebuf) == -1)
+ error("%s", ebuf);
- jflag=-1; /* not set */
- gndo->ndo_Oflag=1;
- gndo->ndo_Rflag=1;
- gndo->ndo_dlt=-1;
- gndo->ndo_default_print=ndo_default_print;
- gndo->ndo_printf=tcpdump_printf;
- gndo->ndo_error=ndo_error;
- gndo->ndo_warning=ndo_warning;
- gndo->ndo_snaplen = DEFAULT_SNAPLEN;
+ memset(ndo, 0, sizeof(*ndo));
+ ndo_set_function_pointers(ndo);
+ ndo->ndo_snaplen = DEFAULT_SNAPLEN;
cnt = -1;
device = NULL;
@@ -934,19 +1358,27 @@ main(int argc, char **argv)
WFileName = NULL;
dlt = -1;
if ((cp = strrchr(argv[0], '/')) != NULL)
- program_name = cp + 1;
+ ndo->program_name = program_name = cp + 1;
else
- program_name = argv[0];
+ ndo->program_name = program_name = argv[0];
+#ifdef _WIN32
+ if (pcap_wsockinit() != 0)
+ error("Attempting to initialize Winsock failed");
+#endif /* _WIN32 */
+
+ /*
+ * On platforms where the CPU doesn't support unaligned loads,
+ * force unaligned accesses to abort with SIGBUS, rather than
+ * being fixed up (slowly) by the OS kernel; on those platforms,
+ * misaligned accesses are bugs, and we want tcpdump to crash so
+ * that the bugs are reported.
+ */
if (abort_on_misalignment(ebuf, sizeof(ebuf)) < 0)
error("%s", ebuf);
-#ifdef LIBSMI
- smiInit("tcpdump");
-#endif
-
while (
- (op = getopt(argc, argv, "aAb" B_FLAG "c:C:d" D_FLAG "eE:fF:G:hHi:" I_FLAG j_FLAG J_FLAG "KlLm:M:nNOpqr:Rs:StT:u" U_FLAG "V:vw:W:xXy:Yz:Z:")) != -1)
+ (op = getopt_long(argc, argv, SHORTOPTS, longopts, NULL)) != -1)
switch (op) {
case 'a':
@@ -954,20 +1386,20 @@ main(int argc, char **argv)
break;
case 'A':
- ++Aflag;
+ ++ndo->ndo_Aflag;
break;
case 'b':
- ++bflag;
+ ++ndo->ndo_bflag;
break;
-#if defined(HAVE_PCAP_CREATE) || defined(WIN32)
+#if defined(HAVE_PCAP_CREATE) || defined(_WIN32)
case 'B':
Bflag = atoi(optarg)*1024;
if (Bflag <= 0)
error("invalid packet buffer size %s", optarg);
break;
-#endif /* defined(HAVE_PCAP_CREATE) || defined(WIN32) */
+#endif /* defined(HAVE_PCAP_CREATE) || defined(_WIN32) */
case 'c':
cnt = atoi(optarg);
@@ -977,7 +1409,7 @@ main(int argc, char **argv)
case 'C':
Cflag = atoi(optarg) * 1000000;
- if (Cflag < 0)
+ if (Cflag <= 0)
error("invalid file size %s", optarg);
break;
@@ -985,39 +1417,27 @@ main(int argc, char **argv)
++dflag;
break;
-#ifdef HAVE_PCAP_FINDALLDEVS
case 'D':
- if (pcap_findalldevs(&devpointer, ebuf) < 0)
- error("%s", ebuf);
- else {
- for (i = 0; devpointer != 0; i++) {
- printf("%d.%s", i+1, devpointer->name);
- if (devpointer->description != NULL)
- printf(" (%s)", devpointer->description);
- printf("\n");
- devpointer = devpointer->next;
- }
- }
- return 0;
-#endif /* HAVE_PCAP_FINDALLDEVS */
+ Dflag++;
+ break;
case 'L':
Lflag++;
break;
case 'e':
- ++eflag;
+ ++ndo->ndo_eflag;
break;
case 'E':
#ifndef HAVE_LIBCRYPTO
warning("crypto code not compiled in");
#endif
- gndo->ndo_espsecret = optarg;
+ ndo->ndo_espsecret = optarg;
break;
case 'f':
- ++fflag;
+ ++ndo->ndo_fflag;
break;
case 'F':
@@ -1040,52 +1460,15 @@ main(int argc, char **argv)
break;
case 'h':
- usage();
+ print_usage();
+ exit_tcpdump(0);
break;
case 'H':
- ++Hflag;
+ ++ndo->ndo_Hflag;
break;
case 'i':
- if (optarg[0] == '0' && optarg[1] == 0)
- error("Invalid adapter index");
-
-#ifdef HAVE_PCAP_FINDALLDEVS
- /*
- * If the argument is a number, treat it as
- * an index into the list of adapters, as
- * printed by "tcpdump -D".
- *
- * This should be OK on UNIX systems, as interfaces
- * shouldn't have names that begin with digits.
- * It can be useful on Windows, where more than
- * one interface can have the same name.
- */
- devnum = strtol(optarg, &end, 10);
- if (optarg != end && *end == '\0') {
- if (devnum < 0)
- error("Invalid adapter index");
-
- if (pcap_findalldevs(&devpointer, ebuf) < 0)
- error("%s", ebuf);
- else {
- /*
- * Look for the devnum-th entry
- * in the list of devices
- * (1-based).
- */
- for (i = 0;
- i < devnum-1 && devpointer != NULL;
- i++, devpointer = devpointer->next)
- ;
- if (devpointer == NULL)
- error("Invalid adapter index");
- }
- device = devpointer->name;
- break;
- }
-#endif /* HAVE_PCAP_FINDALLDEVS */
device = optarg;
break;
@@ -1108,41 +1491,39 @@ main(int argc, char **argv)
#endif
case 'l':
-#ifdef WIN32
+#ifdef _WIN32
/*
* _IOLBF is the same as _IOFBF in Microsoft's C
* libraries; the only alternative they offer
* is _IONBF.
*
* XXX - this should really be checking for MSVC++,
- * not WIN32, if, for example, MinGW has its own
+ * not _WIN32, if, for example, MinGW has its own
* C library that is more UNIX-compatible.
*/
setvbuf(stdout, NULL, _IONBF, 0);
-#else /* WIN32 */
+#else /* _WIN32 */
#ifdef HAVE_SETLINEBUF
setlinebuf(stdout);
#else
setvbuf(stdout, NULL, _IOLBF, 0);
#endif
-#endif /* WIN32 */
+#endif /* _WIN32 */
break;
case 'K':
- ++Kflag;
+ ++ndo->ndo_Kflag;
break;
case 'm':
-#ifdef LIBSMI
- if (smiLoadModule(optarg) == 0) {
- error("could not load MIB module %s", optarg);
+ if (nd_have_smi_support()) {
+ if (nd_load_smi_module(optarg, ebuf, sizeof ebuf) == -1)
+ error("%s", ebuf);
+ } else {
+ (void)fprintf(stderr, "%s: ignoring option `-m %s' ",
+ program_name, optarg);
+ (void)fprintf(stderr, "(no libsmi support)\n");
}
- sflag = 1;
-#else
- (void)fprintf(stderr, "%s: ignoring option `-m %s' ",
- program_name, optarg);
- (void)fprintf(stderr, "(no libsmi support)\n");
-#endif
break;
case 'M':
@@ -1150,15 +1531,15 @@ main(int argc, char **argv)
#ifndef HAVE_LIBCRYPTO
warning("crypto code not compiled in");
#endif
- sigsecret = optarg;
+ ndo->ndo_sigsecret = optarg;
break;
case 'n':
- ++nflag;
+ ++ndo->ndo_nflag;
break;
case 'N':
- ++Nflag;
+ ++ndo->ndo_Nflag;
break;
case 'O':
@@ -1170,68 +1551,85 @@ main(int argc, char **argv)
break;
case 'q':
- ++qflag;
- ++suppress_default_print;
+ ++ndo->ndo_qflag;
+ ++ndo->ndo_suppress_default_print;
break;
- case 'r':
- RFileName = optarg;
+#ifdef HAVE_PCAP_SETDIRECTION
+ case 'Q':
+ if (ascii_strcasecmp(optarg, "in") == 0)
+ Qflag = PCAP_D_IN;
+ else if (ascii_strcasecmp(optarg, "out") == 0)
+ Qflag = PCAP_D_OUT;
+ else if (ascii_strcasecmp(optarg, "inout") == 0)
+ Qflag = PCAP_D_INOUT;
+ else
+ error("unknown capture direction `%s'", optarg);
break;
+#endif /* HAVE_PCAP_SETDIRECTION */
- case 'R':
- Rflag = 0;
+ case 'r':
+ RFileName = optarg;
break;
case 's':
- snaplen = strtol(optarg, &end, 0);
+ ndo->ndo_snaplen = strtol(optarg, &end, 0);
if (optarg == end || *end != '\0'
- || snaplen < 0 || snaplen > MAXIMUM_SNAPLEN)
+ || ndo->ndo_snaplen < 0 || ndo->ndo_snaplen > MAXIMUM_SNAPLEN)
error("invalid snaplen %s", optarg);
- else if (snaplen == 0)
- snaplen = MAXIMUM_SNAPLEN;
+ else if (ndo->ndo_snaplen == 0)
+ ndo->ndo_snaplen = MAXIMUM_SNAPLEN;
break;
case 'S':
- ++Sflag;
+ ++ndo->ndo_Sflag;
break;
case 't':
- ++tflag;
+ ++ndo->ndo_tflag;
break;
case 'T':
- if (strcasecmp(optarg, "vat") == 0)
- packettype = PT_VAT;
- else if (strcasecmp(optarg, "wb") == 0)
- packettype = PT_WB;
- else if (strcasecmp(optarg, "rpc") == 0)
- packettype = PT_RPC;
- else if (strcasecmp(optarg, "rtp") == 0)
- packettype = PT_RTP;
- else if (strcasecmp(optarg, "rtcp") == 0)
- packettype = PT_RTCP;
- else if (strcasecmp(optarg, "snmp") == 0)
- packettype = PT_SNMP;
- else if (strcasecmp(optarg, "cnfp") == 0)
- packettype = PT_CNFP;
- else if (strcasecmp(optarg, "tftp") == 0)
- packettype = PT_TFTP;
- else if (strcasecmp(optarg, "aodv") == 0)
- packettype = PT_AODV;
- else if (strcasecmp(optarg, "carp") == 0)
- packettype = PT_CARP;
- else if (strcasecmp(optarg, "radius") == 0)
- packettype = PT_RADIUS;
- else if (strcasecmp(optarg, "zmtp1") == 0)
- packettype = PT_ZMTP1;
- else if (strcasecmp(optarg, "vxlan") == 0)
- packettype = PT_VXLAN;
+ if (ascii_strcasecmp(optarg, "vat") == 0)
+ ndo->ndo_packettype = PT_VAT;
+ else if (ascii_strcasecmp(optarg, "wb") == 0)
+ ndo->ndo_packettype = PT_WB;
+ else if (ascii_strcasecmp(optarg, "rpc") == 0)
+ ndo->ndo_packettype = PT_RPC;
+ else if (ascii_strcasecmp(optarg, "rtp") == 0)
+ ndo->ndo_packettype = PT_RTP;
+ else if (ascii_strcasecmp(optarg, "rtcp") == 0)
+ ndo->ndo_packettype = PT_RTCP;
+ else if (ascii_strcasecmp(optarg, "snmp") == 0)
+ ndo->ndo_packettype = PT_SNMP;
+ else if (ascii_strcasecmp(optarg, "cnfp") == 0)
+ ndo->ndo_packettype = PT_CNFP;
+ else if (ascii_strcasecmp(optarg, "tftp") == 0)
+ ndo->ndo_packettype = PT_TFTP;
+ else if (ascii_strcasecmp(optarg, "aodv") == 0)
+ ndo->ndo_packettype = PT_AODV;
+ else if (ascii_strcasecmp(optarg, "carp") == 0)
+ ndo->ndo_packettype = PT_CARP;
+ else if (ascii_strcasecmp(optarg, "radius") == 0)
+ ndo->ndo_packettype = PT_RADIUS;
+ else if (ascii_strcasecmp(optarg, "zmtp1") == 0)
+ ndo->ndo_packettype = PT_ZMTP1;
+ else if (ascii_strcasecmp(optarg, "vxlan") == 0)
+ ndo->ndo_packettype = PT_VXLAN;
+ else if (ascii_strcasecmp(optarg, "pgm") == 0)
+ ndo->ndo_packettype = PT_PGM;
+ else if (ascii_strcasecmp(optarg, "pgm_zmtp1") == 0)
+ ndo->ndo_packettype = PT_PGM_ZMTP1;
+ else if (ascii_strcasecmp(optarg, "lmp") == 0)
+ ndo->ndo_packettype = PT_LMP;
+ else if (ascii_strcasecmp(optarg, "resp") == 0)
+ ndo->ndo_packettype = PT_RESP;
else
error("unknown packet type `%s'", optarg);
break;
case 'u':
- ++uflag;
+ ++ndo->ndo_uflag;
break;
#ifdef HAVE_PCAP_DUMP_FLUSH
@@ -1241,7 +1639,7 @@ main(int argc, char **argv)
#endif
case 'v':
- ++vflag;
+ ++ndo->ndo_vflag;
break;
case 'V':
@@ -1254,72 +1652,84 @@ main(int argc, char **argv)
case 'W':
Wflag = atoi(optarg);
- if (Wflag < 0)
+ if (Wflag <= 0)
error("invalid number of output files %s", optarg);
WflagChars = getWflagChars(Wflag);
break;
case 'x':
- ++xflag;
- ++suppress_default_print;
+ ++ndo->ndo_xflag;
+ ++ndo->ndo_suppress_default_print;
break;
case 'X':
- ++Xflag;
- ++suppress_default_print;
+ ++ndo->ndo_Xflag;
+ ++ndo->ndo_suppress_default_print;
break;
case 'y':
- gndo->ndo_dltname = optarg;
- gndo->ndo_dlt =
- pcap_datalink_name_to_val(gndo->ndo_dltname);
- if (gndo->ndo_dlt < 0)
- error("invalid data link type %s", gndo->ndo_dltname);
+ yflag_dlt_name = optarg;
+ yflag_dlt =
+ pcap_datalink_name_to_val(yflag_dlt_name);
+ if (yflag_dlt < 0)
+ error("invalid data link type %s", yflag_dlt_name);
break;
-#if defined(HAVE_PCAP_DEBUG) || defined(HAVE_YYDEBUG)
+#ifdef HAVE_PCAP_SET_PARSER_DEBUG
case 'Y':
{
/* Undocumented flag */
-#ifdef HAVE_PCAP_DEBUG
- extern int pcap_debug;
- pcap_debug = 1;
-#else
- extern int yydebug;
- yydebug = 1;
-#endif
+ pcap_set_parser_debug(1);
}
break;
#endif
case 'z':
- if (optarg) {
- zflag = strdup(optarg);
- } else {
- usage();
- /* NOTREACHED */
- }
+ zflag = optarg;
break;
case 'Z':
- if (optarg) {
- username = strdup(optarg);
- }
- else {
- usage();
- /* NOTREACHED */
- }
+ username = optarg;
+ break;
+
+ case '#':
+ ndo->ndo_packet_number = 1;
+ break;
+
+ case OPTION_VERSION:
+ print_version();
+ exit_tcpdump(0);
break;
+#ifdef HAVE_PCAP_SET_TSTAMP_PRECISION
+ case OPTION_TSTAMP_PRECISION:
+ ndo->ndo_tstamp_precision = tstamp_precision_from_string(optarg);
+ if (ndo->ndo_tstamp_precision < 0)
+ error("unsupported time stamp precision");
+ break;
+#endif
+
+#ifdef HAVE_PCAP_SET_IMMEDIATE_MODE
+ case OPTION_IMMEDIATE_MODE:
+ immediate_mode = 1;
+ break;
+#endif
+
default:
- usage();
+ print_usage();
+ exit_tcpdump(1);
/* NOTREACHED */
}
- switch (tflag) {
+#ifdef HAVE_PCAP_FINDALLDEVS
+ if (Dflag)
+ show_devices_and_exit();
+#endif
+
+ switch (ndo->ndo_tflag) {
case 0: /* Default */
case 4: /* Default + Date*/
- thiszone = gmt2local(0);
+ timezone_offset = gmt2local(0);
break;
case 1: /* No time stamp */
@@ -1333,12 +1743,23 @@ main(int argc, char **argv)
break;
}
- if (fflag != 0 && (VFileName != NULL || RFileName != NULL))
+ if (ndo->ndo_fflag != 0 && (VFileName != NULL || RFileName != NULL))
error("-f can not be used with -V or -r");
if (VFileName != NULL && RFileName != NULL)
error("-V and -r are mutually exclusive.");
+#ifdef HAVE_PCAP_SET_IMMEDIATE_MODE
+ /*
+ * If we're printing dissected packets to the standard output
+ * rather than saving raw packets to a file, and the standard
+ * output is a terminal, use immediate mode, as the user's
+ * probably expecting to see packets pop up immediately.
+ */
+ if (WFileName == NULL && isatty(1))
+ immediate_mode = 1;
+#endif
+
#ifdef WITH_CHROOT
/* if run as root, prepare for chrooting */
if (getuid() == 0 || geteuid() == 0) {
@@ -1367,7 +1788,7 @@ main(int argc, char **argv)
* In either case, we're reading a savefile, not doing
* a live capture.
*/
-#ifndef WIN32
+#ifndef _WIN32
/*
* We don't need network access, so relinquish any set-UID
* or set-GID privileges we have (if any).
@@ -1379,7 +1800,7 @@ main(int argc, char **argv)
*/
if (setgid(getgid()) != 0 || setuid(getuid()) != 0 )
fprintf(stderr, "Warning: setgid/setuid failed !\n");
-#endif /* WIN32 */
+#endif /* _WIN32 */
if (VFileName != NULL) {
if (VFileName[0] == '-' && VFileName[1] == '\0')
VFile = stdin;
@@ -1387,7 +1808,7 @@ main(int argc, char **argv)
VFile = fopen(VFileName, "r");
if (VFile == NULL)
- error("Unable to open file: %s\n", strerror(errno));
+ error("Unable to open file: %s\n", pcap_strerror(errno));
ret = get_next_file(VFile, VFileLine);
if (!ret)
@@ -1395,9 +1816,22 @@ main(int argc, char **argv)
RFileName = VFileLine;
}
+#ifdef HAVE_PCAP_SET_TSTAMP_PRECISION
+ pd = pcap_open_offline_with_tstamp_precision(RFileName,
+ ndo->ndo_tstamp_precision, ebuf);
+#else
pd = pcap_open_offline(RFileName, ebuf);
+#endif
+
if (pd == NULL)
error("%s", ebuf);
+#ifdef HAVE_CAPSICUM
+ cap_rights_init(&rights, CAP_READ);
+ if (cap_rights_limit(fileno(pcap_file(pd)), &rights) < 0 &&
+ errno != ENOSYS) {
+ error("unable to limit pcap descriptor");
+ }
+#endif
dlt = pcap_datalink(pd);
dlt_name = pcap_datalink_val_to_name(dlt);
if (dlt_name == NULL) {
@@ -1409,138 +1843,96 @@ main(int argc, char **argv)
RFileName, dlt_name,
pcap_datalink_val_to_description(dlt));
}
- localnet = 0;
- netmask = 0;
} else {
/*
* We're doing a live capture.
*/
if (device == NULL) {
+ /*
+ * No interface was specified. Pick one.
+ */
+#ifdef HAVE_PCAP_FINDALLDEVS
+ /*
+ * Find the list of interfaces, and pick
+ * the first interface.
+ */
+ if (pcap_findalldevs(&devlist, ebuf) >= 0 &&
+ devlist != NULL) {
+ device = strdup(devlist->name);
+ pcap_freealldevs(devlist);
+ }
+#else /* HAVE_PCAP_FINDALLDEVS */
+ /*
+ * Use whatever interface pcap_lookupdev()
+ * chooses.
+ */
device = pcap_lookupdev(ebuf);
+#endif
if (device == NULL)
error("%s", ebuf);
}
-#ifdef WIN32
- /*
- * Print a message to the standard error on Windows.
- * XXX - why do it here, with a different message?
- */
- if(strlen(device) == 1) //we assume that an ASCII string is always longer than 1 char
- { //a Unicode string has a \0 as second byte (so strlen() is 1)
- fprintf(stderr, "%s: listening on %ws\n", program_name, device);
- }
- else
- {
- fprintf(stderr, "%s: listening on %s\n", program_name, device);
- }
- fflush(stderr);
-#endif /* WIN32 */
-#ifdef HAVE_PCAP_CREATE
- pd = pcap_create(device, ebuf);
- if (pd == NULL)
- error("%s", ebuf);
-#ifdef HAVE_PCAP_SET_TSTAMP_TYPE
- if (Jflag)
- show_tstamp_types_and_exit(device, pd);
-#endif
/*
- * Is this an interface that supports monitor mode?
+ * Try to open the interface with the specified name.
*/
- if (pcap_can_set_rfmon(pd) == 1)
- supports_monitor_mode = 1;
- else
- supports_monitor_mode = 0;
- status = pcap_set_snaplen(pd, snaplen);
- if (status != 0)
- error("%s: Can't set snapshot length: %s",
- device, pcap_statustostr(status));
- status = pcap_set_promisc(pd, !pflag);
- if (status != 0)
- error("%s: Can't set promiscuous mode: %s",
- device, pcap_statustostr(status));
- if (Iflag) {
- status = pcap_set_rfmon(pd, 1);
- if (status != 0)
- error("%s: Can't set monitor mode: %s",
- device, pcap_statustostr(status));
- }
- status = pcap_set_timeout(pd, 1000);
- if (status != 0)
- error("%s: pcap_set_timeout failed: %s",
- device, pcap_statustostr(status));
- if (Bflag != 0) {
- status = pcap_set_buffer_size(pd, Bflag);
- if (status != 0)
- error("%s: Can't set buffer size: %s",
- device, pcap_statustostr(status));
- }
-#ifdef HAVE_PCAP_SET_TSTAMP_TYPE
- if (jflag != -1) {
- status = pcap_set_tstamp_type(pd, jflag);
- if (status < 0)
- error("%s: Can't set time stamp type: %s",
- device, pcap_statustostr(status));
- }
-#endif
- status = pcap_activate(pd);
- if (status < 0) {
+ pd = open_interface(device, ndo, ebuf);
+ if (pd == NULL) {
/*
- * pcap_activate() failed.
+ * That failed. If we can get a list of
+ * interfaces, and the interface name
+ * is purely numeric, try to use it as
+ * a 1-based index in the list of
+ * interfaces.
*/
- cp = pcap_geterr(pd);
- if (status == PCAP_ERROR)
- error("%s", cp);
- else if ((status == PCAP_ERROR_NO_SUCH_DEVICE ||
- status == PCAP_ERROR_PERM_DENIED) &&
- *cp != '\0')
- error("%s: %s\n(%s)", device,
- pcap_statustostr(status), cp);
- else
- error("%s: %s", device,
- pcap_statustostr(status));
- } else if (status > 0) {
+#ifdef HAVE_PCAP_FINDALLDEVS
+ devnum = parse_interface_number(device);
+ if (devnum == -1) {
+ /*
+ * It's not a number; just report
+ * the open error and fail.
+ */
+ error("%s", ebuf);
+ }
+
/*
- * pcap_activate() succeeded, but it's warning us
- * of a problem it had.
+ * OK, it's a number; try to find the
+ * interface with that index, and try
+ * to open it.
+ *
+ * find_interface_by_number() exits if it
+ * couldn't be found.
+ */
+ device = find_interface_by_number(devnum);
+ pd = open_interface(device, ndo, ebuf);
+ if (pd == NULL)
+ error("%s", ebuf);
+#else /* HAVE_PCAP_FINDALLDEVS */
+ /*
+ * We can't get a list of interfaces; just
+ * fail.
*/
- cp = pcap_geterr(pd);
- if (status == PCAP_WARNING)
- warning("%s", cp);
- else if (status == PCAP_WARNING_PROMISC_NOTSUP &&
- *cp != '\0')
- warning("%s: %s\n(%s)", device,
- pcap_statustostr(status), cp);
- else
- warning("%s: %s", device,
- pcap_statustostr(status));
- }
-#else
- *ebuf = '\0';
- pd = pcap_open_live(device, snaplen, !pflag, 1000, ebuf);
- if (pd == NULL)
error("%s", ebuf);
- else if (*ebuf)
- warning("%s", ebuf);
-#endif /* HAVE_PCAP_CREATE */
+#endif /* HAVE_PCAP_FINDALLDEVS */
+ }
+
/*
* Let user own process after socket has been opened.
*/
-#ifndef WIN32
+#ifndef _WIN32
if (setgid(getgid()) != 0 || setuid(getuid()) != 0)
fprintf(stderr, "Warning: setgid/setuid failed !\n");
-#endif /* WIN32 */
-#if !defined(HAVE_PCAP_CREATE) && defined(WIN32)
+#endif /* _WIN32 */
+#if !defined(HAVE_PCAP_CREATE) && defined(_WIN32)
if(Bflag != 0)
if(pcap_setbuff(pd, Bflag)==-1){
error("%s", pcap_geterr(pd));
}
-#endif /* !defined(HAVE_PCAP_CREATE) && defined(WIN32) */
+#endif /* !defined(HAVE_PCAP_CREATE) && defined(_WIN32) */
if (Lflag)
- show_dlts_and_exit(device, pd);
- if (gndo->ndo_dlt >= 0) {
+ show_dlts_and_exit(pd, device);
+ if (yflag_dlt >= 0) {
#ifdef HAVE_PCAP_SET_DATALINK
- if (pcap_set_datalink(pd, gndo->ndo_dlt) < 0)
+ if (pcap_set_datalink(pd, yflag_dlt) < 0)
error("%s", pcap_geterr(pd));
#else
/*
@@ -1548,57 +1940,67 @@ main(int argc, char **argv)
* data link type, so we only let them
* set it to what it already is.
*/
- if (gndo->ndo_dlt != pcap_datalink(pd)) {
+ if (yflag_dlt != pcap_datalink(pd)) {
error("%s is not one of the DLTs supported by this device\n",
- gndo->ndo_dltname);
+ yflag_dlt_name);
}
#endif
(void)fprintf(stderr, "%s: data link type %s\n",
- program_name, gndo->ndo_dltname);
+ program_name, yflag_dlt_name);
(void)fflush(stderr);
}
i = pcap_snapshot(pd);
- if (snaplen < i) {
- warning("snaplen raised from %d to %d", snaplen, i);
- snaplen = i;
- }
- if (pcap_lookupnet(device, &localnet, &netmask, ebuf) < 0) {
- localnet = 0;
- netmask = 0;
- warning("%s", ebuf);
+ if (ndo->ndo_snaplen < i) {
+ warning("snaplen raised from %d to %d", ndo->ndo_snaplen, i);
+ ndo->ndo_snaplen = i;
}
+ if(ndo->ndo_fflag != 0) {
+ if (pcap_lookupnet(device, &localnet, &netmask, ebuf) < 0) {
+ warning("foreign (-f) flag used but: %s", ebuf);
+ }
+ }
+
}
if (infile)
cmdbuf = read_infile(infile);
else
cmdbuf = copy_argv(&argv[optind]);
+#ifdef HAVE_PCAP_SET_OPTIMIZER_DEBUG
+ pcap_set_optimizer_debug(dflag);
+#endif
if (pcap_compile(pd, &fcode, cmdbuf, Oflag, netmask) < 0)
error("%s", pcap_geterr(pd));
if (dflag) {
bpf_dump(&fcode, dflag);
pcap_close(pd);
free(cmdbuf);
- exit(0);
+ pcap_freecode(&fcode);
+ exit_tcpdump(0);
}
- init_addrtoname(localnet, netmask);
- init_checksum();
-#ifndef WIN32
+#ifdef HAVE_CASPER
+ if (!ndo->ndo_nflag)
+ capdns = capdns_setup();
+#endif /* HAVE_CASPER */
+
+ init_print(ndo, localnet, netmask, timezone_offset);
+
+#ifndef _WIN32
(void)setsignal(SIGPIPE, cleanup);
(void)setsignal(SIGTERM, cleanup);
(void)setsignal(SIGINT, cleanup);
-#endif /* WIN32 */
+#endif /* _WIN32 */
#if defined(HAVE_FORK) || defined(HAVE_VFORK)
(void)setsignal(SIGCHLD, child_cleanup);
#endif
/* Cooperate with nohup(1) */
-#ifndef WIN32
+#ifndef _WIN32
if ((oldhandler = setsignal(SIGHUP, cleanup)) != SIG_DFL)
(void)setsignal(SIGHUP, oldhandler);
-#endif /* WIN32 */
+#endif /* _WIN32 */
-#ifndef WIN32
+#ifndef _WIN32
/*
* If a user name was specified with "-Z", attempt to switch to
* that user's UID. This would probably be used with sudo,
@@ -1617,36 +2019,44 @@ main(int argc, char **argv)
* savefile doesn't handle the general case.
*/
-#ifdef HAVE_CAP_NG_H
- /* We are running as root and we will be writing to savefile */
- if ((getuid() == 0 || geteuid() == 0) && WFileName) {
+ if (getuid() == 0 || geteuid() == 0) {
+#ifdef HAVE_LIBCAP_NG
+ /* Initialize capng */
+ capng_clear(CAPNG_SELECT_BOTH);
if (username) {
- /* Drop all capabilities from effective set */
- capng_clear(CAPNG_EFFECTIVE);
- /* Add capabilities we will need*/
- capng_update(CAPNG_ADD, CAPNG_PERMITTED, CAP_SETUID);
- capng_update(CAPNG_ADD, CAPNG_PERMITTED, CAP_SETGID);
- capng_update(CAPNG_ADD, CAPNG_PERMITTED, CAP_DAC_OVERRIDE);
-
- capng_update(CAPNG_ADD, CAPNG_EFFECTIVE, CAP_SETUID);
- capng_update(CAPNG_ADD, CAPNG_EFFECTIVE, CAP_SETGID);
- capng_update(CAPNG_ADD, CAPNG_EFFECTIVE, CAP_DAC_OVERRIDE);
-
- capng_apply(CAPNG_SELECT_BOTH);
+ capng_updatev(
+ CAPNG_ADD,
+ CAPNG_PERMITTED | CAPNG_EFFECTIVE,
+ CAP_SETUID,
+ CAP_SETGID,
+ -1);
+ }
+ if (chroot_dir) {
+ capng_update(
+ CAPNG_ADD,
+ CAPNG_PERMITTED | CAPNG_EFFECTIVE,
+ CAP_SYS_CHROOT
+ );
}
- }
-#endif /* HAVE_CAP_NG_H */
- if (getuid() == 0 || geteuid() == 0) {
+ if (WFileName) {
+ capng_update(
+ CAPNG_ADD,
+ CAPNG_PERMITTED | CAPNG_EFFECTIVE,
+ CAP_DAC_OVERRIDE
+ );
+ }
+ capng_apply(CAPNG_SELECT_BOTH);
+#endif /* HAVE_LIBCAP_NG */
if (username || chroot_dir)
droproot(username, chroot_dir);
}
-#endif /* WIN32 */
+#endif /* _WIN32 */
if (pcap_setfilter(pd, &fcode) < 0)
error("%s", pcap_geterr(pd));
-#ifdef HAVE_CASPER
+#ifdef HAVE_CAPSICUM
if (RFileName == NULL && VFileName == NULL) {
static const unsigned long cmds[] = { BIOCGSTATS, BIOCROTZBUF };
@@ -1681,15 +2091,51 @@ main(int argc, char **argv)
MakeFilename(dumpinfo.CurrentFileName, WFileName, 0, 0);
p = pcap_dump_open(pd, dumpinfo.CurrentFileName);
-#ifdef HAVE_CAP_NG_H
- /* Give up capabilities, clear Effective set */
- capng_clear(CAPNG_EFFECTIVE);
-#endif
+#ifdef HAVE_LIBCAP_NG
+ /* Give up CAP_DAC_OVERRIDE capability.
+ * Only allow it to be restored if the -C or -G flag have been
+ * set since we may need to create more files later on.
+ */
+ capng_update(
+ CAPNG_DROP,
+ (Cflag || Gflag ? 0 : CAPNG_PERMITTED)
+ | CAPNG_EFFECTIVE,
+ CAP_DAC_OVERRIDE
+ );
+ capng_apply(CAPNG_SELECT_BOTH);
+#endif /* HAVE_LIBCAP_NG */
if (p == NULL)
error("%s", pcap_geterr(pd));
+#ifdef HAVE_CAPSICUM
+ set_dumper_capsicum_rights(p);
+#endif
if (Cflag != 0 || Gflag != 0) {
- callback = dump_packet_and_trunc;
+#ifdef HAVE_CAPSICUM
+ dumpinfo.WFileName = strdup(basename(WFileName));
+ if (dumpinfo.WFileName == NULL) {
+ error("Unable to allocate memory for file %s",
+ WFileName);
+ }
+ dumpinfo.dirfd = open(dirname(WFileName),
+ O_DIRECTORY | O_RDONLY);
+ if (dumpinfo.dirfd < 0) {
+ error("unable to open directory %s",
+ dirname(WFileName));
+ }
+ cap_rights_init(&rights, CAP_CREATE, CAP_FCNTL,
+ CAP_FTRUNCATE, CAP_LOOKUP, CAP_SEEK, CAP_WRITE);
+ if (cap_rights_limit(dumpinfo.dirfd, &rights) < 0 &&
+ errno != ENOSYS) {
+ error("unable to limit directory rights");
+ }
+ if (cap_fcntls_limit(dumpinfo.dirfd, CAP_FCNTL_GETFL) < 0 &&
+ errno != ENOSYS) {
+ error("unable to limit dump descriptor fcntls");
+ }
+#else /* !HAVE_CAPSICUM */
dumpinfo.WFileName = WFileName;
+#endif
+ callback = dump_packet_and_trunc;
dumpinfo.pd = pd;
dumpinfo.p = p;
pcap_userdata = (u_char *)&dumpinfo;
@@ -1702,10 +2148,10 @@ main(int argc, char **argv)
pcap_dump_flush(p);
#endif
} else {
- type = pcap_datalink(pd);
- printinfo = get_print_info(type);
+ dlt = pcap_datalink(pd);
+ ndo->ndo_if_printer = get_if_printer(ndo, dlt);
callback = print_packet;
- pcap_userdata = (u_char *)&printinfo;
+ pcap_userdata = (u_char *)ndo;
}
#ifdef SIGNAL_REQ_INFO
@@ -1717,10 +2163,10 @@ main(int argc, char **argv)
(void)setsignal(SIGNAL_REQ_INFO, requestinfo);
#endif
- if (vflag > 0 && WFileName) {
+ if (ndo->ndo_vflag > 0 && WFileName) {
/*
* When capturing to a file, "-v" means tcpdump should,
- * every 10 secodns, "v"erbosely report the number of
+ * every 10 seconds, "v"erbosely report the number of
* packets captured.
*/
#ifdef USE_WIN32_MM_TIMER
@@ -1733,14 +2179,13 @@ main(int argc, char **argv)
#endif
}
-#ifndef WIN32
if (RFileName == NULL) {
/*
* Live capture (if -V was specified, we set RFileName
* to a file from the -V file). Print a message to
* the standard error on UN*X.
*/
- if (!vflag && !WFileName) {
+ if (!ndo->ndo_vflag && !WFileName) {
(void)fprintf(stderr,
"%s: verbose output suppressed, use -v or -vv for full protocol decode\n",
program_name);
@@ -1750,15 +2195,26 @@ main(int argc, char **argv)
dlt_name = pcap_datalink_val_to_name(dlt);
if (dlt_name == NULL) {
(void)fprintf(stderr, "listening on %s, link-type %u, capture size %u bytes\n",
- device, dlt, snaplen);
+ device, dlt, ndo->ndo_snaplen);
} else {
(void)fprintf(stderr, "listening on %s, link-type %s (%s), capture size %u bytes\n",
device, dlt_name,
- pcap_datalink_val_to_description(dlt), snaplen);
+ pcap_datalink_val_to_description(dlt), ndo->ndo_snaplen);
}
(void)fflush(stderr);
}
-#endif /* WIN32 */
+
+#ifdef HAVE_CAPSICUM
+ cansandbox = (VFileName == NULL && zflag == NULL);
+#ifdef HAVE_CASPER
+ cansandbox = (cansandbox && (ndo->ndo_nflag || capdns != NULL));
+#else
+ cansandbox = (cansandbox && ndo->ndo_nflag);
+#endif /* HAVE_CASPER */
+ if (cansandbox && cap_enter() < 0 && errno != ENOSYS)
+ error("unable to enter the capability mode");
+#endif /* HAVE_CAPSICUM */
+
do {
status = pcap_loop(pd, cnt, callback, pcap_userdata);
if (WFileName == NULL) {
@@ -1776,6 +2232,14 @@ main(int argc, char **argv)
}
(void)fflush(stdout);
}
+ if (status == -2) {
+ /*
+ * We got interrupted. If we are reading multiple
+ * files (via -V) set these so that we stop.
+ */
+ VFileName = NULL;
+ ret = NULL;
+ }
if (status == -1) {
/*
* Error. Report it.
@@ -1794,35 +2258,81 @@ main(int argc, char **argv)
if (VFileName != NULL) {
ret = get_next_file(VFile, VFileLine);
if (ret) {
+ int new_dlt;
+
RFileName = VFileLine;
pd = pcap_open_offline(RFileName, ebuf);
if (pd == NULL)
error("%s", ebuf);
+#ifdef HAVE_CAPSICUM
+ cap_rights_init(&rights, CAP_READ);
+ if (cap_rights_limit(fileno(pcap_file(pd)),
+ &rights) < 0 && errno != ENOSYS) {
+ error("unable to limit pcap descriptor");
+ }
+#endif
new_dlt = pcap_datalink(pd);
- if (WFileName && new_dlt != dlt)
- error("%s: new dlt does not match original", RFileName);
- printinfo = get_print_info(new_dlt);
- dlt_name = pcap_datalink_val_to_name(new_dlt);
+ if (new_dlt != dlt) {
+ /*
+ * The new file has a different
+ * link-layer header type from the
+ * previous one.
+ */
+ if (WFileName != NULL) {
+ /*
+ * We're writing raw packets
+ * that match the filter to
+ * a pcap file. pcap files
+ * don't support multiple
+ * different link-layer
+ * header types, so we fail
+ * here.
+ */
+ error("%s: new dlt does not match original", RFileName);
+ }
+
+ /*
+ * We're printing the decoded packets;
+ * switch to the new DLT.
+ *
+ * To do that, we need to change
+ * the printer, change the DLT name,
+ * and recompile the filter with
+ * the new DLT.
+ */
+ dlt = new_dlt;
+ ndo->ndo_if_printer = get_if_printer(ndo, dlt);
+ if (pcap_compile(pd, &fcode, cmdbuf, Oflag, netmask) < 0)
+ error("%s", pcap_geterr(pd));
+ }
+
+ /*
+ * Set the filter on the new file.
+ */
+ if (pcap_setfilter(pd, &fcode) < 0)
+ error("%s", pcap_geterr(pd));
+
+ /*
+ * Report the new file.
+ */
+ dlt_name = pcap_datalink_val_to_name(dlt);
if (dlt_name == NULL) {
fprintf(stderr, "reading from file %s, link-type %u\n",
- RFileName, new_dlt);
+ RFileName, dlt);
} else {
fprintf(stderr,
"reading from file %s, link-type %s (%s)\n",
- RFileName, dlt_name,
- pcap_datalink_val_to_description(new_dlt));
+ RFileName, dlt_name,
+ pcap_datalink_val_to_description(dlt));
}
- if (pcap_compile(pd, &fcode, cmdbuf, Oflag, netmask) < 0)
- error("%s", pcap_geterr(pd));
- if (pcap_setfilter(pd, &fcode) < 0)
- error("%s", pcap_geterr(pd));
}
}
}
while (ret != NULL);
free(cmdbuf);
- exit(status == -1 ? 1 : 0);
+ pcap_freecode(&fcode);
+ exit_tcpdump(status == -1 ? 1 : 0);
}
/* make a clean exit on interrupts */
@@ -1862,7 +2372,7 @@ cleanup(int signo _U_)
(void)fflush(stdout);
info(1);
}
- exit(0);
+ exit_tcpdump(0);
#endif
}
@@ -1881,14 +2391,14 @@ child_cleanup(int signo _U_)
static void
info(register int verbose)
{
- struct pcap_stat stat;
+ struct pcap_stat stats;
/*
* Older versions of libpcap didn't set ps_ifdrop on some
* platforms; initialize it to 0 to handle that.
*/
- stat.ps_ifdrop = 0;
- if (pcap_stats(pd, &stat) < 0) {
+ stats.ps_ifdrop = 0;
+ if (pcap_stats(pd, &stats) < 0) {
(void)fprintf(stderr, "pcap_stats: %s\n", pcap_geterr(pd));
infoprint = 0;
return;
@@ -1903,38 +2413,52 @@ info(register int verbose)
fputs(", ", stderr);
else
putc('\n', stderr);
- (void)fprintf(stderr, "%u packet%s received by filter", stat.ps_recv,
- PLURAL_SUFFIX(stat.ps_recv));
+ (void)fprintf(stderr, "%u packet%s received by filter", stats.ps_recv,
+ PLURAL_SUFFIX(stats.ps_recv));
if (!verbose)
fputs(", ", stderr);
else
putc('\n', stderr);
- (void)fprintf(stderr, "%u packet%s dropped by kernel", stat.ps_drop,
- PLURAL_SUFFIX(stat.ps_drop));
- if (stat.ps_ifdrop != 0) {
+ (void)fprintf(stderr, "%u packet%s dropped by kernel", stats.ps_drop,
+ PLURAL_SUFFIX(stats.ps_drop));
+ if (stats.ps_ifdrop != 0) {
if (!verbose)
fputs(", ", stderr);
else
putc('\n', stderr);
(void)fprintf(stderr, "%u packet%s dropped by interface\n",
- stat.ps_ifdrop, PLURAL_SUFFIX(stat.ps_ifdrop));
+ stats.ps_ifdrop, PLURAL_SUFFIX(stats.ps_ifdrop));
} else
putc('\n', stderr);
infoprint = 0;
}
#if defined(HAVE_FORK) || defined(HAVE_VFORK)
+#ifdef HAVE_FORK
+#define fork_subprocess() fork()
+#else
+#define fork_subprocess() vfork()
+#endif
static void
compress_savefile(const char *filename)
{
-# ifdef HAVE_FORK
- if (fork())
-# else
- if (vfork())
-# endif
+ pid_t child;
+
+ child = fork_subprocess();
+ if (child == -1) {
+ fprintf(stderr,
+ "compress_savefile: fork failed: %s\n",
+ pcap_strerror(errno));
+ return;
+ }
+ if (child != 0) {
+ /* Parent process. */
return;
+ }
+
/*
- * Set to lowest priority so that this doesn't disturb the capture
+ * Child process.
+ * Set to lowest priority so that this doesn't disturb the capture.
*/
#ifdef NZERO
setpriority(PRIO_PROCESS, 0, NZERO - 1);
@@ -1943,15 +2467,15 @@ compress_savefile(const char *filename)
#endif
if (execlp(zflag, zflag, filename, (char *)NULL) == -1)
fprintf(stderr,
- "compress_savefile:execlp(%s, %s): %s\n",
+ "compress_savefile: execlp(%s, %s) failed: %s\n",
zflag,
filename,
- strerror(errno));
-# ifdef HAVE_FORK
+ pcap_strerror(errno));
+#ifdef HAVE_FORK
exit(1);
-# else
+#else
_exit(1);
-# endif
+#endif
}
#else /* HAVE_FORK && HAVE_VFORK */
static void
@@ -1994,6 +2518,11 @@ dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *s
/* If the time is greater than the specified window, rotate */
if (t - Gflag_time >= Gflag) {
+#ifdef HAVE_CAPSICUM
+ FILE *fp;
+ int fd;
+#endif
+
/* Update the Gflag_time */
Gflag_time = t;
/* Update Gflag_count */
@@ -2016,7 +2545,8 @@ dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *s
if (Cflag == 0 && Wflag > 0 && Gflag_count >= Wflag) {
(void)fprintf(stderr, "Maximum file limit reached: %d\n",
Wflag);
- exit(0);
+ info(1);
+ exit_tcpdump(0);
/* NOTREACHED */
}
if (dump_info->CurrentFileName != NULL)
@@ -2026,6 +2556,13 @@ dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *s
if (dump_info->CurrentFileName == NULL)
error("dump_packet_and_trunc: malloc");
/*
+ * Gflag was set otherwise we wouldn't be here. Reset the count
+ * so multiple files would end with 1,2,3 in the filename.
+ * The counting is handled with the -C flow after this.
+ */
+ Cflag_count = 0;
+
+ /*
* This is always the first file in the Cflag
* rotation: e.g. 0
* We also don't need numbering if Cflag is not set.
@@ -2036,17 +2573,36 @@ dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *s
else
MakeFilename(dump_info->CurrentFileName, dump_info->WFileName, 0, 0);
-#ifdef HAVE_CAP_NG_H
+#ifdef HAVE_LIBCAP_NG
capng_update(CAPNG_ADD, CAPNG_EFFECTIVE, CAP_DAC_OVERRIDE);
- capng_apply(CAPNG_EFFECTIVE);
-#endif /* HAVE_CAP_NG_H */
+ capng_apply(CAPNG_SELECT_BOTH);
+#endif /* HAVE_LIBCAP_NG */
+#ifdef HAVE_CAPSICUM
+ fd = openat(dump_info->dirfd,
+ dump_info->CurrentFileName,
+ O_CREAT | O_WRONLY | O_TRUNC, 0644);
+ if (fd < 0) {
+ error("unable to open file %s",
+ dump_info->CurrentFileName);
+ }
+ fp = fdopen(fd, "w");
+ if (fp == NULL) {
+ error("unable to fdopen file %s",
+ dump_info->CurrentFileName);
+ }
+ dump_info->p = pcap_dump_fopen(dump_info->pd, fp);
+#else /* !HAVE_CAPSICUM */
dump_info->p = pcap_dump_open(dump_info->pd, dump_info->CurrentFileName);
-#ifdef HAVE_CAP_NG_H
+#endif
+#ifdef HAVE_LIBCAP_NG
capng_update(CAPNG_DROP, CAPNG_EFFECTIVE, CAP_DAC_OVERRIDE);
- capng_apply(CAPNG_EFFECTIVE);
-#endif /* HAVE_CAP_NG_H */
+ capng_apply(CAPNG_SELECT_BOTH);
+#endif /* HAVE_LIBCAP_NG */
if (dump_info->p == NULL)
error("%s", pcap_geterr(pd));
+#ifdef HAVE_CAPSICUM
+ set_dumper_capsicum_rights(dump_info->p);
+#endif
}
}
@@ -2055,32 +2611,70 @@ dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *s
* larger than Cflag - the last packet written to the
* file could put it over Cflag.
*/
- if (Cflag != 0 && pcap_dump_ftell(dump_info->p) > Cflag) {
- /*
- * Close the current file and open a new one.
- */
- pcap_dump_close(dump_info->p);
+ if (Cflag != 0) {
+ long size = pcap_dump_ftell(dump_info->p);
- /*
- * Compress the file we just closed, if the user asked for it
- */
- if (zflag != NULL)
- compress_savefile(dump_info->CurrentFileName);
+ if (size == -1)
+ error("ftell fails on output file");
+ if (size > Cflag) {
+#ifdef HAVE_CAPSICUM
+ FILE *fp;
+ int fd;
+#endif
+
+ /*
+ * Close the current file and open a new one.
+ */
+ pcap_dump_close(dump_info->p);
- Cflag_count++;
- if (Wflag > 0) {
- if (Cflag_count >= Wflag)
- Cflag_count = 0;
+ /*
+ * Compress the file we just closed, if the user
+ * asked for it.
+ */
+ if (zflag != NULL)
+ compress_savefile(dump_info->CurrentFileName);
+
+ Cflag_count++;
+ if (Wflag > 0) {
+ if (Cflag_count >= Wflag)
+ Cflag_count = 0;
+ }
+ if (dump_info->CurrentFileName != NULL)
+ free(dump_info->CurrentFileName);
+ dump_info->CurrentFileName = (char *)malloc(PATH_MAX + 1);
+ if (dump_info->CurrentFileName == NULL)
+ error("dump_packet_and_trunc: malloc");
+ MakeFilename(dump_info->CurrentFileName, dump_info->WFileName, Cflag_count, WflagChars);
+#ifdef HAVE_LIBCAP_NG
+ capng_update(CAPNG_ADD, CAPNG_EFFECTIVE, CAP_DAC_OVERRIDE);
+ capng_apply(CAPNG_SELECT_BOTH);
+#endif /* HAVE_LIBCAP_NG */
+#ifdef HAVE_CAPSICUM
+ fd = openat(dump_info->dirfd, dump_info->CurrentFileName,
+ O_CREAT | O_WRONLY | O_TRUNC, 0644);
+ if (fd < 0) {
+ error("unable to open file %s",
+ dump_info->CurrentFileName);
+ }
+ fp = fdopen(fd, "w");
+ if (fp == NULL) {
+ error("unable to fdopen file %s",
+ dump_info->CurrentFileName);
+ }
+ dump_info->p = pcap_dump_fopen(dump_info->pd, fp);
+#else /* !HAVE_CAPSICUM */
+ dump_info->p = pcap_dump_open(dump_info->pd, dump_info->CurrentFileName);
+#endif
+#ifdef HAVE_LIBCAP_NG
+ capng_update(CAPNG_DROP, CAPNG_EFFECTIVE, CAP_DAC_OVERRIDE);
+ capng_apply(CAPNG_SELECT_BOTH);
+#endif /* HAVE_LIBCAP_NG */
+ if (dump_info->p == NULL)
+ error("%s", pcap_geterr(pd));
+#ifdef HAVE_CAPSICUM
+ set_dumper_capsicum_rights(dump_info->p);
+#endif
}
- if (dump_info->CurrentFileName != NULL)
- free(dump_info->CurrentFileName);
- dump_info->CurrentFileName = (char *)malloc(PATH_MAX + 1);
- if (dump_info->CurrentFileName == NULL)
- error("dump_packet_and_trunc: malloc");
- MakeFilename(dump_info->CurrentFileName, dump_info->WFileName, Cflag_count, WflagChars);
- dump_info->p = pcap_dump_open(dump_info->pd, dump_info->CurrentFileName);
- if (dump_info->p == NULL)
- error("%s", pcap_geterr(pd));
}
pcap_dump((u_char *)dump_info->p, h, sp);
@@ -2115,95 +2709,18 @@ dump_packet(u_char *user, const struct pcap_pkthdr *h, const u_char *sp)
static void
print_packet(u_char *user, const struct pcap_pkthdr *h, const u_char *sp)
{
- struct print_info *print_info;
- u_int hdrlen;
-
++packets_captured;
++infodelay;
- ts_print(&h->ts);
- print_info = (struct print_info *)user;
-
- /*
- * Some printers want to check that they're not walking off the
- * end of the packet.
- * Rather than pass it all the way down, we set this global.
- */
- snapend = sp + h->caplen;
-
- if(print_info->ndo_type) {
- hdrlen = (*print_info->p.ndo_printer)(print_info->ndo, h, sp);
- } else {
- hdrlen = (*print_info->p.printer)(h, sp);
- }
-
- if (Xflag) {
- /*
- * Print the raw packet data in hex and ASCII.
- */
- if (Xflag > 1) {
- /*
- * Include the link-layer header.
- */
- hex_and_ascii_print("\n\t", sp, h->caplen);
- } else {
- /*
- * Don't include the link-layer header - and if
- * we have nothing past the link-layer header,
- * print nothing.
- */
- if (h->caplen > hdrlen)
- hex_and_ascii_print("\n\t", sp + hdrlen,
- h->caplen - hdrlen);
- }
- } else if (xflag) {
- /*
- * Print the raw packet data in hex.
- */
- if (xflag > 1) {
- /*
- * Include the link-layer header.
- */
- hex_print("\n\t", sp, h->caplen);
- } else {
- /*
- * Don't include the link-layer header - and if
- * we have nothing past the link-layer header,
- * print nothing.
- */
- if (h->caplen > hdrlen)
- hex_print("\n\t", sp + hdrlen,
- h->caplen - hdrlen);
- }
- } else if (Aflag) {
- /*
- * Print the raw packet data in ASCII.
- */
- if (Aflag > 1) {
- /*
- * Include the link-layer header.
- */
- ascii_print(sp, h->caplen);
- } else {
- /*
- * Don't include the link-layer header - and if
- * we have nothing past the link-layer header,
- * print nothing.
- */
- if (h->caplen > hdrlen)
- ascii_print(sp + hdrlen, h->caplen - hdrlen);
- }
- }
-
- putchar('\n');
+ pretty_print_packet((netdissect_options *)user, h, sp, packets_captured);
--infodelay;
if (infoprint)
info(0);
}
-#ifdef WIN32
+#ifdef _WIN32
/*
* XXX - there should really be libpcap calls to get the version
* number as a string (the string would be generated from #defines
@@ -2222,29 +2739,14 @@ print_packet(u_char *user, const struct pcap_pkthdr *h, const u_char *sp)
* version number of the Packet.dll code, to supply the
* "Wpcap_version" information on Windows.
*/
- char WDversion[]="current-cvs.tcpdump.org";
+ char WDversion[]="current-git.tcpdump.org";
#if !defined(HAVE_GENERATED_VERSION)
- char version[]="current-cvs.tcpdump.org";
+ char version[]="current-git.tcpdump.org";
#endif
- char pcap_version[]="current-cvs.tcpdump.org";
+ char pcap_version[]="current-git.tcpdump.org";
char Wpcap_version[]="3.1";
#endif
-/*
- * By default, print the specified data out in hex and ASCII.
- */
-static void
-ndo_default_print(netdissect_options *ndo _U_, const u_char *bp, u_int length)
-{
- hex_and_ascii_print("\n\t", bp, length); /* pass on lf and identation string */
-}
-
-void
-default_print(const u_char *bp, u_int length)
-{
- ndo_default_print(gndo, bp, length);
-}
-
#ifdef SIGNAL_REQ_INFO
RETSIGTYPE requestinfo(int signo _U_)
{
@@ -2262,103 +2764,99 @@ RETSIGTYPE requestinfo(int signo _U_)
void CALLBACK verbose_stats_dump (UINT timer_id _U_, UINT msg _U_, DWORD_PTR arg _U_,
DWORD_PTR dw1 _U_, DWORD_PTR dw2 _U_)
{
- struct pcap_stat stat;
-
- if (infodelay == 0 && pcap_stats(pd, &stat) >= 0)
+ if (infodelay == 0)
fprintf(stderr, "Got %u\r", packets_captured);
}
#elif defined(HAVE_ALARM)
static void verbose_stats_dump(int sig _U_)
{
- struct pcap_stat stat;
-
- if (infodelay == 0 && pcap_stats(pd, &stat) >= 0)
+ if (infodelay == 0)
fprintf(stderr, "Got %u\r", packets_captured);
alarm(1);
}
#endif
+USES_APPLE_DEPRECATED_API
static void
-usage(void)
+print_version(void)
{
#ifdef __rtems__
- #define version "RTEMS Version"
-#else
+#define version "RTEMS Version"
+#else /* __rtems__ */
extern char version[];
#endif /* __rtems__ */
#ifndef HAVE_PCAP_LIB_VERSION
-#if defined(WIN32) || defined(HAVE_PCAP_VERSION)
+#if defined(_WIN32) || defined(HAVE_PCAP_VERSION)
extern char pcap_version[];
-#else /* defined(WIN32) || defined(HAVE_PCAP_VERSION) */
+#else /* defined(_WIN32) || defined(HAVE_PCAP_VERSION) */
static char pcap_version[] = "unknown";
-#endif /* defined(WIN32) || defined(HAVE_PCAP_VERSION) */
+#endif /* defined(_WIN32) || defined(HAVE_PCAP_VERSION) */
#endif /* HAVE_PCAP_LIB_VERSION */
+ const char *smi_version_string;
#ifdef HAVE_PCAP_LIB_VERSION
-#ifdef WIN32
+#ifdef _WIN32
(void)fprintf(stderr, "%s version %s, based on tcpdump version %s\n", program_name, WDversion, version);
-#else /* WIN32 */
+#else /* _WIN32 */
(void)fprintf(stderr, "%s version %s\n", program_name, version);
-#endif /* WIN32 */
+#endif /* _WIN32 */
(void)fprintf(stderr, "%s\n",pcap_lib_version());
#else /* HAVE_PCAP_LIB_VERSION */
-#ifdef WIN32
+#ifdef _WIN32
(void)fprintf(stderr, "%s version %s, based on tcpdump version %s\n", program_name, WDversion, version);
(void)fprintf(stderr, "WinPcap version %s, based on libpcap version %s\n",Wpcap_version, pcap_version);
-#else /* WIN32 */
+#else /* _WIN32 */
(void)fprintf(stderr, "%s version %s\n", program_name, version);
(void)fprintf(stderr, "libpcap version %s\n", pcap_version);
-#endif /* WIN32 */
+#endif /* _WIN32 */
#endif /* HAVE_PCAP_LIB_VERSION */
+
+#if defined(HAVE_LIBCRYPTO) && defined(SSLEAY_VERSION)
+ (void)fprintf (stderr, "%s\n", SSLeay_version(SSLEAY_VERSION));
+#endif
+
+ smi_version_string = nd_smi_version_string();
+ if (smi_version_string != NULL)
+ (void)fprintf (stderr, "SMI-library: %s\n", smi_version_string);
+}
+USES_APPLE_RST
+
+static void
+print_usage(void)
+{
+ print_version();
(void)fprintf(stderr,
-"Usage: %s [-aAbd" D_FLAG "efhH" I_FLAG J_FLAG "KlLnNOpqRStu" U_FLAG "vxX]" B_FLAG_USAGE " [ -c count ]\n", program_name);
+"Usage: %s [-aAbd" D_FLAG "efhH" I_FLAG J_FLAG "KlLnNOpqStu" U_FLAG "vxX#]" B_FLAG_USAGE " [ -c count ]\n", program_name);
(void)fprintf(stderr,
"\t\t[ -C file_size ] [ -E algo:secret ] [ -F file ] [ -G seconds ]\n");
(void)fprintf(stderr,
-"\t\t[ -i interface ]" j_FLAG_USAGE " [ -M secret ]\n");
+"\t\t[ -i interface ]" j_FLAG_USAGE " [ -M secret ] [ --number ]\n");
+#ifdef HAVE_PCAP_SETDIRECTION
+ (void)fprintf(stderr,
+"\t\t[ -Q in|out|inout ]\n");
+#endif
+ (void)fprintf(stderr,
+"\t\t[ -r file ] [ -s snaplen ] ");
+#ifdef HAVE_PCAP_SET_TSTAMP_PRECISION
+ (void)fprintf(stderr, "[ --time-stamp-precision precision ]\n");
(void)fprintf(stderr,
-"\t\t[ -r file ] [ -s snaplen ] [ -T type ] [ -V file ] [ -w file ]\n");
+"\t\t");
+#endif
+#ifdef HAVE_PCAP_SET_IMMEDIATE_MODE
+ (void)fprintf(stderr, "[ --immediate-mode ] ");
+#endif
+ (void)fprintf(stderr, "[ -T type ] [ --version ] [ -V file ]\n");
(void)fprintf(stderr,
-"\t\t[ -W filecount ] [ -y datalinktype ] [ -z command ]\n");
+"\t\t[ -w file ] [ -W filecount ] [ -y datalinktype ] [ -z postrotate-command ]\n");
(void)fprintf(stderr,
"\t\t[ -Z user ] [ expression ]\n");
- exit(1);
-}
-
-
-
-/* VARARGS */
-static void
-ndo_error(netdissect_options *ndo _U_, const char *fmt, ...)
-{
- va_list ap;
-
- (void)fprintf(stderr, "%s: ", program_name);
- va_start(ap, fmt);
- (void)vfprintf(stderr, fmt, ap);
- va_end(ap);
- if (*fmt) {
- fmt += strlen(fmt);
- if (fmt[-1] != '\n')
- (void)fputc('\n', stderr);
- }
- exit(1);
- /* NOTREACHED */
-}
-
-/* VARARGS */
-static void
-ndo_warning(netdissect_options *ndo _U_, const char *fmt, ...)
-{
- va_list ap;
-
- (void)fprintf(stderr, "%s: WARNING: ", program_name);
- va_start(ap, fmt);
- (void)vfprintf(stderr, fmt, ap);
- va_end(ap);
- if (*fmt) {
- fmt += strlen(fmt);
- if (fmt[-1] != '\n')
- (void)fputc('\n', stderr);
- }
}
+/*
+ * Local Variables:
+ * c-style: whitesmith
+ * c-basic-offset: 8
+ * End:
+ */
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-tcpdump-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/telnet.h b/freebsd/contrib/tcpdump/telnet.h
deleted file mode 100644
index 33a07be9..00000000
--- a/freebsd/contrib/tcpdump/telnet.h
+++ /dev/null
@@ -1,348 +0,0 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/telnet.h,v 1.5 2007-08-29 02:31:44 mcr Exp $ (LBL) */
-
-/* NetBSD: telnet.h,v 1.9 2001/06/11 01:50:50 wiz Exp */
-
-/*
- * Copyright (c) 1983, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * 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. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
- *
- * @(#)telnet.h 8.2 (Berkeley) 12/15/93
- */
-
-#ifndef _ARPA_TELNET_H_
-#define _ARPA_TELNET_H_
-
-/*
- * Definitions for the TELNET protocol.
- */
-#define IAC 255 /* interpret as command: */
-#define DONT 254 /* you are not to use option */
-#define DO 253 /* please, you use option */
-#define WONT 252 /* I won't use option */
-#define WILL 251 /* I will use option */
-#define SB 250 /* interpret as subnegotiation */
-#define GA 249 /* you may reverse the line */
-#define EL 248 /* erase the current line */
-#define EC 247 /* erase the current character */
-#define AYT 246 /* are you there */
-#define AO 245 /* abort output--but let prog finish */
-#define IP 244 /* interrupt process--permanently */
-#define BREAK 243 /* break */
-#define DM 242 /* data mark--for connect. cleaning */
-#define NOP 241 /* nop */
-#define SE 240 /* end sub negotiation */
-#define EOR 239 /* end of record (transparent mode) */
-#define ABORT 238 /* Abort process */
-#define SUSP 237 /* Suspend process */
-#define xEOF 236 /* End of file: EOF is already used... */
-
-#define SYNCH 242 /* for telfunc calls */
-
-#ifdef TELCMDS
-const char *telcmds[] = {
- "EOF", "SUSP", "ABORT", "EOR",
- "SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", "EC",
- "EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC", 0,
-};
-#else
-extern char *telcmds[];
-#endif
-
-#define TELCMD_FIRST xEOF
-#define TELCMD_LAST IAC
-#define TELCMD_OK(x) ((unsigned int)(x) <= TELCMD_LAST && \
- (unsigned int)(x) >= TELCMD_FIRST)
-#define TELCMD(x) telcmds[(x)-TELCMD_FIRST]
-
-/* telnet options */
-#define TELOPT_BINARY 0 /* 8-bit data path */
-#define TELOPT_ECHO 1 /* echo */
-#define TELOPT_RCP 2 /* prepare to reconnect */
-#define TELOPT_SGA 3 /* suppress go ahead */
-#define TELOPT_NAMS 4 /* approximate message size */
-#define TELOPT_STATUS 5 /* give status */
-#define TELOPT_TM 6 /* timing mark */
-#define TELOPT_RCTE 7 /* remote controlled transmission and echo */
-#define TELOPT_NAOL 8 /* negotiate about output line width */
-#define TELOPT_NAOP 9 /* negotiate about output page size */
-#define TELOPT_NAOCRD 10 /* negotiate about CR disposition */
-#define TELOPT_NAOHTS 11 /* negotiate about horizontal tabstops */
-#define TELOPT_NAOHTD 12 /* negotiate about horizontal tab disposition */
-#define TELOPT_NAOFFD 13 /* negotiate about formfeed disposition */
-#define TELOPT_NAOVTS 14 /* negotiate about vertical tab stops */
-#define TELOPT_NAOVTD 15 /* negotiate about vertical tab disposition */
-#define TELOPT_NAOLFD 16 /* negotiate about output LF disposition */
-#define TELOPT_XASCII 17 /* extended ascic character set */
-#define TELOPT_LOGOUT 18 /* force logout */
-#define TELOPT_BM 19 /* byte macro */
-#define TELOPT_DET 20 /* data entry terminal */
-#define TELOPT_SUPDUP 21 /* supdup protocol */
-#define TELOPT_SUPDUPOUTPUT 22 /* supdup output */
-#define TELOPT_SNDLOC 23 /* send location */
-#define TELOPT_TTYPE 24 /* terminal type */
-#define TELOPT_EOR 25 /* end or record */
-#define TELOPT_TUID 26 /* TACACS user identification */
-#define TELOPT_OUTMRK 27 /* output marking */
-#define TELOPT_TTYLOC 28 /* terminal location number */
-#define TELOPT_3270REGIME 29 /* 3270 regime */
-#define TELOPT_X3PAD 30 /* X.3 PAD */
-#define TELOPT_NAWS 31 /* window size */
-#define TELOPT_TSPEED 32 /* terminal speed */
-#define TELOPT_LFLOW 33 /* remote flow control */
-#define TELOPT_LINEMODE 34 /* Linemode option */
-#define TELOPT_XDISPLOC 35 /* X Display Location */
-#define TELOPT_OLD_ENVIRON 36 /* Old - Environment variables */
-#define TELOPT_AUTHENTICATION 37/* Authenticate */
-#define TELOPT_ENCRYPT 38 /* Encryption option */
-#define TELOPT_NEW_ENVIRON 39 /* New - Environment variables */
-#define TELOPT_EXOPL 255 /* extended-options-list */
-
-
-#define NTELOPTS (1+TELOPT_NEW_ENVIRON)
-#ifdef TELOPTS
-const char *telopts[NTELOPTS+1] = {
- "BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD", "NAME",
- "STATUS", "TIMING MARK", "RCTE", "NAOL", "NAOP",
- "NAOCRD", "NAOHTS", "NAOHTD", "NAOFFD", "NAOVTS",
- "NAOVTD", "NAOLFD", "EXTEND ASCII", "LOGOUT", "BYTE MACRO",
- "DATA ENTRY TERMINAL", "SUPDUP", "SUPDUP OUTPUT",
- "SEND LOCATION", "TERMINAL TYPE", "END OF RECORD",
- "TACACS UID", "OUTPUT MARKING", "TTYLOC",
- "3270 REGIME", "X.3 PAD", "NAWS", "TSPEED", "LFLOW",
- "LINEMODE", "XDISPLOC", "OLD-ENVIRON", "AUTHENTICATION",
- "ENCRYPT", "NEW-ENVIRON",
- 0,
-};
-#define TELOPT_FIRST TELOPT_BINARY
-#define TELOPT_LAST TELOPT_NEW_ENVIRON
-#define TELOPT_OK(x) ((unsigned int)(x) <= TELOPT_LAST)
-#define TELOPT(x) telopts[(x)-TELOPT_FIRST]
-#endif
-
-/* sub-option qualifiers */
-#define TELQUAL_IS 0 /* option is... */
-#define TELQUAL_SEND 1 /* send option */
-#define TELQUAL_INFO 2 /* ENVIRON: informational version of IS */
-#define TELQUAL_REPLY 2 /* AUTHENTICATION: client version of IS */
-#define TELQUAL_NAME 3 /* AUTHENTICATION: client version of IS */
-
-#define LFLOW_OFF 0 /* Disable remote flow control */
-#define LFLOW_ON 1 /* Enable remote flow control */
-#define LFLOW_RESTART_ANY 2 /* Restart output on any char */
-#define LFLOW_RESTART_XON 3 /* Restart output only on XON */
-
-/*
- * LINEMODE suboptions
- */
-
-#define LM_MODE 1
-#define LM_FORWARDMASK 2
-#define LM_SLC 3
-
-#define MODE_EDIT 0x01
-#define MODE_TRAPSIG 0x02
-#define MODE_ACK 0x04
-#define MODE_SOFT_TAB 0x08
-#define MODE_LIT_ECHO 0x10
-
-#define MODE_MASK 0x1f
-
-/* Not part of protocol, but needed to simplify things... */
-#define MODE_FLOW 0x0100
-#define MODE_ECHO 0x0200
-#define MODE_INBIN 0x0400
-#define MODE_OUTBIN 0x0800
-#define MODE_FORCE 0x1000
-
-#define SLC_SYNCH 1
-#define SLC_BRK 2
-#define SLC_IP 3
-#define SLC_AO 4
-#define SLC_AYT 5
-#define SLC_EOR 6
-#define SLC_ABORT 7
-#define SLC_EOF 8
-#define SLC_SUSP 9
-#define SLC_EC 10
-#define SLC_EL 11
-#define SLC_EW 12
-#define SLC_RP 13
-#define SLC_LNEXT 14
-#define SLC_XON 15
-#define SLC_XOFF 16
-#define SLC_FORW1 17
-#define SLC_FORW2 18
-#define SLC_MCL 19
-#define SLC_MCR 20
-#define SLC_MCWL 21
-#define SLC_MCWR 22
-#define SLC_MCBOL 23
-#define SLC_MCEOL 24
-#define SLC_INSRT 25
-#define SLC_OVER 26
-#define SLC_ECR 27
-#define SLC_EWR 28
-#define SLC_EBOL 29
-#define SLC_EEOL 30
-
-#define NSLC 30
-
-/*
- * For backwards compatibility, we define SLC_NAMES to be the
- * list of names if SLC_NAMES is not defined.
- */
-#define SLC_NAMELIST "0", "SYNCH", "BRK", "IP", "AO", "AYT", "EOR", \
- "ABORT", "EOF", "SUSP", "EC", "EL", "EW", "RP", \
- "LNEXT", "XON", "XOFF", "FORW1", "FORW2", \
- "MCL", "MCR", "MCWL", "MCWR", "MCBOL", \
- "MCEOL", "INSRT", "OVER", "ECR", "EWR", \
- "EBOL", "EEOL", \
- 0,
-
-#ifdef SLC_NAMES
-const char *slc_names[] = {
- SLC_NAMELIST
-};
-#else
-extern char *slc_names[];
-#define SLC_NAMES SLC_NAMELIST
-#endif
-
-#define SLC_NAME_OK(x) ((unsigned int)(x) <= NSLC)
-#define SLC_NAME(x) slc_names[x]
-
-#define SLC_NOSUPPORT 0
-#define SLC_CANTCHANGE 1
-#define SLC_VARIABLE 2
-#define SLC_DEFAULT 3
-#define SLC_LEVELBITS 0x03
-
-#define SLC_FUNC 0
-#define SLC_FLAGS 1
-#define SLC_VALUE 2
-
-#define SLC_ACK 0x80
-#define SLC_FLUSHIN 0x40
-#define SLC_FLUSHOUT 0x20
-
-#define OLD_ENV_VAR 1
-#define OLD_ENV_VALUE 0
-#define NEW_ENV_VAR 0
-#define NEW_ENV_VALUE 1
-#define ENV_ESC 2
-#define ENV_USERVAR 3
-
-/*
- * AUTHENTICATION suboptions
- */
-
-/*
- * Who is authenticating who ...
- */
-#define AUTH_WHO_CLIENT 0 /* Client authenticating server */
-#define AUTH_WHO_SERVER 1 /* Server authenticating client */
-#define AUTH_WHO_MASK 1
-
-/*
- * amount of authentication done
- */
-#define AUTH_HOW_ONE_WAY 0
-#define AUTH_HOW_MUTUAL 2
-#define AUTH_HOW_MASK 2
-
-/*
- * should we be encrypting? (not yet formally standardized)
- */
-#define AUTH_ENCRYPT_OFF 0
-#define AUTH_ENCRYPT_ON 4
-#define AUTH_ENCRYPT_MASK 4
-
-#define AUTHTYPE_NULL 0
-#define AUTHTYPE_KERBEROS_V4 1
-#define AUTHTYPE_KERBEROS_V5 2
-#define AUTHTYPE_SPX 3
-#define AUTHTYPE_MINK 4
-#define AUTHTYPE_CNT 5
-
-#define AUTHTYPE_TEST 99
-
-#ifdef AUTH_NAMES
-const char *authtype_names[] = {
- "NULL", "KERBEROS_V4", "KERBEROS_V5", "SPX", "MINK", 0,
-};
-#else
-extern char *authtype_names[];
-#endif
-
-#define AUTHTYPE_NAME_OK(x) ((unsigned int)(x) < AUTHTYPE_CNT)
-#define AUTHTYPE_NAME(x) authtype_names[x]
-
-/*
- * ENCRYPTion suboptions
- */
-#define ENCRYPT_IS 0 /* I pick encryption type ... */
-#define ENCRYPT_SUPPORT 1 /* I support encryption types ... */
-#define ENCRYPT_REPLY 2 /* Initial setup response */
-#define ENCRYPT_START 3 /* Am starting to send encrypted */
-#define ENCRYPT_END 4 /* Am ending encrypted */
-#define ENCRYPT_REQSTART 5 /* Request you start encrypting */
-#define ENCRYPT_REQEND 6 /* Request you send encrypting */
-#define ENCRYPT_ENC_KEYID 7
-#define ENCRYPT_DEC_KEYID 8
-#define ENCRYPT_CNT 9
-
-#define ENCTYPE_ANY 0
-#define ENCTYPE_DES_CFB64 1
-#define ENCTYPE_DES_OFB64 2
-#define ENCTYPE_CNT 3
-
-#ifdef ENCRYPT_NAMES
-const char *encrypt_names[] = {
- "IS", "SUPPORT", "REPLY", "START", "END",
- "REQUEST-START", "REQUEST-END", "ENC-KEYID", "DEC-KEYID",
- 0,
-};
-const char *enctype_names[] = {
- "ANY", "DES_CFB64", "DES_OFB64", 0,
-};
-#else
-extern char *encrypt_names[];
-extern char *enctype_names[];
-#endif
-
-
-#define ENCRYPT_NAME_OK(x) ((unsigned int)(x) < ENCRYPT_CNT)
-#define ENCRYPT_NAME(x) encrypt_names[x]
-
-#define ENCTYPE_NAME_OK(x) ((unsigned int)(x) < ENCTYPE_CNT)
-#define ENCTYPE_NAME(x) enctype_names[x]
-
-#endif /* _ARPA_TELNET_H_ */
diff --git a/freebsd/contrib/tcpdump/tftp.h b/freebsd/contrib/tcpdump/tftp.h
deleted file mode 100644
index 6a092e0a..00000000
--- a/freebsd/contrib/tcpdump/tftp.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/tftp.h,v 1.2 2008-04-11 16:47:38 gianluca Exp $ (LBL) */
-/*
- * Copyright (c) 1983, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * 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. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
- *
- * @(#)tftp.h 8.1 (Berkeley) 6/2/93
- */
-
-#ifndef _TFTP_H_
-#define _TFTP_H_
-
-/*
- * Trivial File Transfer Protocol (IEN-133)
- */
-#define SEGSIZE 512 /* data segment size */
-
-/*
- * Packet types.
- */
-#define RRQ 01 /* read request */
-#define WRQ 02 /* write request */
-#define DATA 03 /* data packet */
-#define ACK 04 /* acknowledgement */
-#define TFTP_ERROR 05 /* error code */
-#define OACK 06 /* option acknowledgement */
-
-struct tftphdr {
- unsigned short th_opcode; /* packet type */
- union {
- unsigned short tu_block; /* block # */
- unsigned short tu_code; /* error code */
- char tu_stuff[1]; /* request packet stuff */
- } th_u;
- char th_data[1]; /* data or error string */
-};
-
-#define th_block th_u.tu_block
-#define th_code th_u.tu_code
-#define th_stuff th_u.tu_stuff
-#define th_msg th_data
-
-/*
- * Error codes.
- */
-#define EUNDEF 0 /* not defined */
-#define ENOTFOUND 1 /* file not found */
-#define EACCESS 2 /* access violation */
-#define ENOSPACE 3 /* disk full or allocation exceeded */
-#define EBADOP 4 /* illegal TFTP operation */
-#define EBADID 5 /* unknown transfer ID */
-#define EEXISTS 6 /* file already exists */
-#define ENOUSER 7 /* no such user */
-
-#endif /* !_TFTP_H_ */
diff --git a/freebsd/contrib/tcpdump/timed.h b/freebsd/contrib/tcpdump/timed.h
deleted file mode 100644
index f8d5a113..00000000
--- a/freebsd/contrib/tcpdump/timed.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/timed.h,v 1.6 2008-02-05 19:46:19 guy Exp $ (LBL) */
-/*
- * Copyright (c) 1983, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * 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. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
- *
- * @(#)timed.h 8.1 (Berkeley) 6/2/93
- */
-
-#ifndef _PROTOCOLS_TIMED_H_
-#define _PROTOCOLS_TIMED_H_
-
-/*
- * Time Synchronization Protocol
- */
-
-#define TSPVERSION 1
-#define ANYADDR NULL
-
-struct tsp_timeval {
- u_int32_t tv_sec;
- u_int32_t tv_usec;
-};
-
-struct tsp {
- u_int8_t tsp_type;
- u_int8_t tsp_vers;
- u_int16_t tsp_seq;
- union {
- struct tsp_timeval tspu_time;
- int8_t tspu_hopcnt;
- } tsp_u;
- int8_t tsp_name[256];
-};
-
-#define tsp_time tsp_u.tspu_time
-#define tsp_hopcnt tsp_u.tspu_hopcnt
-
-/*
- * Command types.
- */
-#define TSP_ANY 0 /* match any types */
-#define TSP_ADJTIME 1 /* send adjtime */
-#define TSP_ACK 2 /* generic acknowledgement */
-#define TSP_MASTERREQ 3 /* ask for master's name */
-#define TSP_MASTERACK 4 /* acknowledge master request */
-#define TSP_SETTIME 5 /* send network time */
-#define TSP_MASTERUP 6 /* inform slaves that master is up */
-#define TSP_SLAVEUP 7 /* slave is up but not polled */
-#define TSP_ELECTION 8 /* advance candidature for master */
-#define TSP_ACCEPT 9 /* support candidature of master */
-#define TSP_REFUSE 10 /* reject candidature of master */
-#define TSP_CONFLICT 11 /* two or more masters present */
-#define TSP_RESOLVE 12 /* masters' conflict resolution */
-#define TSP_QUIT 13 /* reject candidature if master is up */
-#define TSP_DATE 14 /* reset the time (date command) */
-#define TSP_DATEREQ 15 /* remote request to reset the time */
-#define TSP_DATEACK 16 /* acknowledge time setting */
-#define TSP_TRACEON 17 /* turn tracing on */
-#define TSP_TRACEOFF 18 /* turn tracing off */
-#define TSP_MSITE 19 /* find out master's site */
-#define TSP_MSITEREQ 20 /* remote master's site request */
-#define TSP_TEST 21 /* for testing election algo */
-#define TSP_SETDATE 22 /* New from date command */
-#define TSP_SETDATEREQ 23 /* New remote for above */
-#define TSP_LOOP 24 /* loop detection packet */
-
-#define TSPTYPENUMBER 25
-
-#endif /* !_TIMED_H_ */
diff --git a/freebsd/contrib/tcpdump/timeval-operations.h b/freebsd/contrib/tcpdump/timeval-operations.h
new file mode 100644
index 00000000..4f4e85c7
--- /dev/null
+++ b/freebsd/contrib/tcpdump/timeval-operations.h
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2015 The TCPDUMP project
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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
+ * COPYRIGHT HOLDER 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.
+ */
+
+#ifndef netdissect_timeval_operations_h
+#define netdissect_timeval_operations_h
+
+/* Operations on timevals. */
+
+#ifndef _MICRO_PER_SEC
+#define _MICRO_PER_SEC 1000000
+#endif
+
+#ifndef _NANO_PER_SEC
+#define _NANO_PER_SEC 1000000000
+#endif
+
+#define netdissect_timevalclear(tvp) ((tvp)->tv_sec = (tvp)->tv_usec = 0)
+
+#define netdissect_timevalisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
+
+#define netdissect_timevalcmp(tvp, uvp, cmp) \
+ (((tvp)->tv_sec == (uvp)->tv_sec) ? \
+ ((tvp)->tv_usec cmp (uvp)->tv_usec) : \
+ ((tvp)->tv_sec cmp (uvp)->tv_sec))
+
+#define netdissect_timevaladd(tvp, uvp, vvp, nano_prec) \
+ do { \
+ (vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec; \
+ (vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec; \
+ if (nano_prec) { \
+ if ((vvp)->tv_usec >= _NANO_PER_SEC) { \
+ (vvp)->tv_sec++; \
+ (vvp)->tv_usec -= _NANO_PER_SEC; \
+ } \
+ } else { \
+ if ((vvp)->tv_usec >= _MICRO_PER_SEC) { \
+ (vvp)->tv_sec++; \
+ (vvp)->tv_usec -= _MICRO_PER_SEC; \
+ } \
+ } \
+ } while (0)
+
+#define netdissect_timevalsub(tvp, uvp, vvp, nano_prec) \
+ do { \
+ (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \
+ (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \
+ if ((vvp)->tv_usec < 0) { \
+ (vvp)->tv_sec--; \
+ (vvp)->tv_usec += (nano_prec ? _NANO_PER_SEC : \
+ _MICRO_PER_SEC); \
+ } \
+ } while (0)
+
+#endif /* netdissect_timeval_operations_h */
diff --git a/freebsd/contrib/tcpdump/token.h b/freebsd/contrib/tcpdump/token.h
deleted file mode 100644
index 19524c6c..00000000
--- a/freebsd/contrib/tcpdump/token.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/token.h,v 1.6 2002-12-11 07:14:12 guy Exp $ (LBL) */
-/*
- * Copyright (c) 1998, Larry Lile
- * All rights reserved.
- *
- * 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 unmodified, 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#define TOKEN_HDRLEN 14
-#define TOKEN_RING_MAC_LEN 6
-#define ROUTING_SEGMENT_MAX 16
-#define IS_SOURCE_ROUTED(trp) ((trp)->token_shost[0] & 0x80)
-#define FRAME_TYPE(trp) (((trp)->token_fc & 0xC0) >> 6)
-#define TOKEN_FC_LLC 1
-
-#define BROADCAST(trp) ((EXTRACT_16BITS(&(trp)->token_rcf) & 0xE000) >> 13)
-#define RIF_LENGTH(trp) ((EXTRACT_16BITS(&(trp)->token_rcf) & 0x1f00) >> 8)
-#define DIRECTION(trp) ((EXTRACT_16BITS(&(trp)->token_rcf) & 0x0080) >> 7)
-#define LARGEST_FRAME(trp) ((EXTRACT_16BITS(&(trp)->token_rcf) & 0x0070) >> 4)
-#define RING_NUMBER(trp, x) ((EXTRACT_16BITS(&(trp)->token_rseg[x]) & 0xfff0) >> 4)
-#define BRIDGE_NUMBER(trp, x) ((EXTRACT_16BITS(&(trp)->token_rseg[x]) & 0x000f))
-#define SEGMENT_COUNT(trp) ((int)((RIF_LENGTH(trp) - 2) / 2))
-
-struct token_header {
- u_int8_t token_ac;
- u_int8_t token_fc;
- u_int8_t token_dhost[TOKEN_RING_MAC_LEN];
- u_int8_t token_shost[TOKEN_RING_MAC_LEN];
- u_int16_t token_rcf;
- u_int16_t token_rseg[ROUTING_SEGMENT_MAX];
-};
diff --git a/freebsd/contrib/tcpdump/udp.h b/freebsd/contrib/tcpdump/udp.h
index b07cdd43..409cc59e 100644
--- a/freebsd/contrib/tcpdump/udp.h
+++ b/freebsd/contrib/tcpdump/udp.h
@@ -1,4 +1,3 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/udp.h,v 1.13 2007-08-08 17:20:58 hannes Exp $ (LBL) */
/*
* Copyright (c) 1982, 1986, 1993
* The Regents of the University of California. All rights reserved.
@@ -39,58 +38,279 @@
* Per RFC 768, September, 1981.
*/
struct udphdr {
- u_int16_t uh_sport; /* source port */
- u_int16_t uh_dport; /* destination port */
- u_int16_t uh_ulen; /* udp length */
- u_int16_t uh_sum; /* udp checksum */
+ uint16_t uh_sport; /* source port */
+ uint16_t uh_dport; /* destination port */
+ uint16_t uh_ulen; /* udp length */
+ uint16_t uh_sum; /* udp checksum */
};
-#define TFTP_PORT 69 /*XXX*/
-#define KERBEROS_PORT 88 /*XXX*/
-#define SUNRPC_PORT 111 /*XXX*/
-#define SNMP_PORT 161 /*XXX*/
-#define NTP_PORT 123 /*XXX*/
-#define SNMPTRAP_PORT 162 /*XXX*/
-#define ISAKMP_PORT 500 /*XXX*/
-#define SYSLOG_PORT 514 /* rfc3164 */
-#define TIMED_PORT 525 /*XXX*/
-#define RIP_PORT 520 /*XXX*/
-#define LDP_PORT 646
-#define AODV_PORT 654 /*XXX*/
-#define OLSR_PORT 698 /* rfc3626 */
-#define KERBEROS_SEC_PORT 750 /*XXX*/
-#define L2TP_PORT 1701 /*XXX*/
-#define SIP_PORT 5060
-#define ISAKMP_PORT_NATT 4500 /* rfc3948 */
-#define ISAKMP_PORT_USER1 7500 /*XXX - nonstandard*/
-#define ISAKMP_PORT_USER2 8500 /*XXX - nonstandard*/
-#define RX_PORT_LOW 7000 /*XXX*/
-#define RX_PORT_HIGH 7009 /*XXX*/
-#define NETBIOS_NS_PORT 137
-#define NETBIOS_DGRAM_PORT 138
-#define CISCO_AUTORP_PORT 496 /*XXX*/
-#define RADIUS_PORT 1645
-#define RADIUS_NEW_PORT 1812
-#define RADIUS_ACCOUNTING_PORT 1646
-#define RADIUS_NEW_ACCOUNTING_PORT 1813
-#define HSRP_PORT 1985 /*XXX*/
-#define LMP_PORT 701 /* rfc4204 */
-#define LWRES_PORT 921
-#define VQP_PORT 1589
-#define ZEPHYR_SRV_PORT 2103
-#define ZEPHYR_CLT_PORT 2104
-#define MPLS_LSP_PING_PORT 3503 /* draft-ietf-mpls-lsp-ping-02.txt */
-#define BFD_CONTROL_PORT 3784 /* draft-katz-ward-bfd-v4v6-1hop-00.txt */
-#define BFD_ECHO_PORT 3785 /* draft-katz-ward-bfd-v4v6-1hop-00.txt */
-#define SFLOW_PORT 6343 /* http://www.sflow.org/developers/specifications.php */
-#define LWAPP_DATA_PORT 12222 /* draft-ohara-capwap-lwapp-04.txt */
-#define LWAPP_CONTROL_PORT 12223 /* draft-ohara-capwap-lwapp-04.txt */
-#define OTV_PORT 8472 /* draft-hasmit-otv-04 */
-
-#ifdef INET6
-#define RIPNG_PORT 521 /*XXX*/
-#define DHCP6_SERV_PORT 546 /*XXX*/
-#define DHCP6_CLI_PORT 547 /*XXX*/
-#define BABEL_PORT 6696
-#define BABEL_PORT_OLD 6697
+#ifndef NAMESERVER_PORT
+#define NAMESERVER_PORT 53
+#endif
+#ifndef TACACS_DB_PORT
+#define TACACS_DB_PORT 65 /*XXX*/
+#endif
+#ifndef ORACLE_SQLNET_PORT
+#define ORACLE_SQLNET_PORT 66 /*XXX*/
+#endif
+#ifndef BOOTPS_PORT
+#define BOOTPS_PORT 67 /* RFC951 */
+#endif
+#ifndef BOOTPC_PORT
+#define BOOTPC_PORT 68 /* RFC951 */
+#endif
+#ifndef TFTP_PORT
+#define TFTP_PORT 69 /*XXX*/
+#endif
+#ifndef KERBEROS_PORT
+#define KERBEROS_PORT 88 /*XXX*/
+#endif
+#ifndef SUNRPC_PORT
+#define SUNRPC_PORT 111 /*XXX*/
+#endif
+#ifndef NTP_PORT
+#define NTP_PORT 123 /*XXX*/
+#endif
+#ifndef NETBIOS_NS_PORT
+#define NETBIOS_NS_PORT 137 /* RFC 1001, RFC 1002 */
+#endif
+#ifndef NETBIOS_DGRAM_PORT
+#define NETBIOS_DGRAM_PORT 138 /* RFC 1001, RFC 1002 */
+#endif
+#ifndef NETBIOS_SSN_PORT
+#define NETBIOS_SSN_PORT 139 /* RFC 1001, RFC 1002 */
+#endif
+#ifndef SNMP_PORT
+#define SNMP_PORT 161 /*XXX*/
+#endif
+#ifndef SNMPTRAP_PORT
+#define SNMPTRAP_PORT 162 /*XXX*/
+#endif
+#ifndef BGP_PORT
+#define BGP_PORT 179 /*XXX*/
+#endif
+#ifndef APPLETALK_RTMP_PORT
+#define APPLETALK_RTMP_PORT 201 /*XXX*/
+#endif
+#ifndef APPLETALK_NB_PORT
+#define APPLETALK_NB_PORT 202 /*XXX*/
+#endif
+#ifndef APPLETALK_ECHO
+#define APPLETALK_ECHO 204 /*XXX*/
+#endif
+#ifndef APPLETALK_ZONE_INFO_PORT
+#define APPLETALK_ZONE_INFO_PORT 206 /*XXX*/
+#endif
+#ifndef LDAP_PORT
+#define LDAP_PORT 389 /*XXX*/
+#endif
+#ifndef HTTPS_PORT
+#define HTTPS_PORT 443 /*XXX*/
+#endif
+#ifndef MICROSOFT_DS_PORT
+#define MICROSOFT_DS_PORT 445 /*XXX*/
+#endif
+#ifndef KERBEROS5_PASSWD_PORT
+#define KERBEROS5_PASSWD_PORT 464 /* PER IANA */
+#endif
+#ifndef CISCO_AUTORP_PORT
+#define CISCO_AUTORP_PORT 496 /*XXX*/
+#endif
+#ifndef ISAKMP_PORT
+#define ISAKMP_PORT 500 /*XXX*/
+#endif
+#ifndef SYSLOG_PORT
+#define SYSLOG_PORT 514 /* rfc3164 */
+#endif
+#ifndef RIP_PORT
+#define RIP_PORT 520 /*XXX*/
+#endif
+#ifndef RIPNG_PORT
+#define RIPNG_PORT 521 /* RFC 2080 */
+#endif
+#ifndef TIMED_PORT
+#define TIMED_PORT 525 /*XXX*/
+#endif
+#ifndef KERBEROS_LOGIN_PORT
+#define KERBEROS_LOGIN_PORT 543 /*XXX*/
+#endif
+#ifndef KERBEROS_SHELL_PORT
+#define KERBEROS_SHELL_PORT 544 /*XXX*/
+#endif
+#ifndef DHCP6_SERV_PORT
+#define DHCP6_SERV_PORT 546 /*XXX*/
+#endif
+#ifndef DHCP6_CLI_PORT
+#define DHCP6_CLI_PORT 547 /*XXX*/
+#endif
+#ifndef LDAPS_PORT
+#define LDAPS_PORT 636 /*XXX - LDAP over TLS/SSL */
+#endif
+#ifndef LDP_PORT
+#define LDP_PORT 646
+#endif
+#ifndef DHCP_FAILOVER_PORT
+#define DHCP_FAILOVER_PORT 647 /*XXX*/
+#endif
+#ifndef AQDV_PORT
+#define AODV_PORT 654 /*XXX*/
+#endif
+#ifndef OLSR_PORT
+#define OLSR_PORT 698 /* rfc3626 */
+#endif
+#ifndef LMP_PORT
+#define LMP_PORT 701 /* rfc4204 */
+#endif
+#ifndef CISCO_TDP_PORT
+#define CISCO_TDP_PORT 711 /*XXX*/
+#endif
+#ifndef KERBEROS_ADM_PORT
+#define KERBEROS_ADM_PORT 749 /*XXX - Kerberos v5 */
+#endif
+#ifndef KERBEROS_SEC_PORT
+#define KERBEROS_SEC_PORT 750 /*XXX - Kerberos v4 */
+#endif
+#ifndef RSYNC_PORT
+#define RSYNC_PORT 873 /*XXX*/
+#endif
+#ifndef LWRES_PORT
+#define LWRES_PORT 921 /*XXX*/
+#endif
+#ifndef OPENSSL_PORT
+#define OPENSSL_PORT 1194 /*XXX*/
+#endif
+#ifndef LOTUS_NOTES_PORT
+#define LOTUS_NOTES_PORT 1352 /*XXX*/
+#endif
+#ifndef MS_SQL_SERVER_PORT
+#define MS_SQL_SERVER_PORT 1433 /*XXX*/
+#endif
+#ifndef MS_SQL_SERVER_MONITOR
+#define MS_SQL_SERVER_MONITOR 1434 /*XXX*/
+#endif
+#ifndef INGRESLOCK_PORT
+#define INGRESLOCK_PORT 1524 /*XXX*/
+#endif
+#ifndef VQP_PORT
+#define VQP_PORT 1589 /*XXX*/
+#endif
+#ifndef RADIUS_PORT
+#define RADIUS_PORT 1645 /*XXX*/
+#endif
+#ifndef RADIUS_ACCOUNTING_PORT
+#define RADIUS_ACCOUNTING_PORT 1646
+#endif
+#ifndef RADIUS_CISCO_COA_PORT
+#define RADIUS_CISCO_COA_PORT 1700
+#endif
+#ifndef L2TP_PORT
+#define L2TP_PORT 1701 /*XXX*/
+#endif
+#ifndef RADIUS_NEW_PORT
+#define RADIUS_NEW_PORT 1812 /*XXX*/
+#endif
+#ifndef RADIUS_NEW_ACCOUNTING_PORT
+#define RADIUS_NEW_ACCOUNTING_PORT 1813
+#endif
+#ifndef HSRP_PORT
+#define HSRP_PORT 1985 /*XXX*/
+#endif
+#ifndef NFS_DAEMON_PORT
+#define NFS_DAEMON_PORT 2049 /*XXX*/
+#endif
+#ifndef ZEPHYR_SRV_PORT
+#define ZEPHYR_SRV_PORT 2103 /*XXX*/
+#endif
+#ifndef ZEPHYR_CLI_PORT
+#define ZEPHYR_CLT_PORT 2104 /*XXX*/
+#endif
+#ifndef MYSQL_PORT
+#define MYSQL_PORT 3306 /*XXX*/
+#endif
+#ifndef MS_RDP_PORT
+#define MS_RDP_PORT 3389 /*XXX*/
+#endif
+#ifndef VAT_PORT
+#define VAT_PORT 3456 /*XXX*/
+#endif
+#ifndef MPLS_LSP_PING_PORT
+#define MPLS_LSP_PING_PORT 3503 /* draft-ietf-mpls-lsp-ping-02.txt */
+#endif
+#ifndef SUBVERSION_PORT
+#define SUBVERSION_PORT 3690 /*XXX*/
+#endif
+#ifndef BFD_CONTROL_PORT
+#define BFD_CONTROL_PORT 3784 /* RFC 5881 */
+#endif
+#ifndef BFD_ECHO_PORT
+#define BFD_ECHO_PORT 3785 /* RFC 5881 */
+#endif
+#ifndef RADIUS_COA_PORT
+#define RADIUS_COA_PORT 3799 /* RFC 5176 */
+#endif
+#ifndef NFS_LOCK_DAEMON_PORT
+#define NFS_LOCK_DAEMON_PORT 4045 /*XXX*/
+#endif
+#ifndef LISP_CONTROL_PORT
+#define LISP_CONTROL_PORT 4342 /* RFC 6830 */
+#endif
+#ifndef ISAKMP_PORT_NATT
+#define ISAKMP_PORT_NATT 4500 /* rfc3948 */
+#endif
+#ifndef WB_PORT
+#define WB_PORT 4567
+#endif
+#ifndef VXLAN_PORT
+#define VXLAN_PORT 4789 /* RFC 7348 */
+#endif
+#ifndef VXLAN_GPE_PORT
+#define VXLAN_GPE_PORT 4790 /* draft-ietf-nvo3-vxlan-gpe-01 */
+#endif
+#ifndef SIP_DS_PORT
+#define SIP_DS_PORT 5059 /*XXX*/
+#endif
+#ifndef SIP_PORT
+#define SIP_PORT 5060
+#endif
+#ifndef MULTICASTDNS_PORT
+#define MULTICASTDNS_PORT 5353 /* RFC 6762 */
+#endif
+#ifndef AHCP_PORT
+#define AHCP_PORT 5359 /* draft-chroboczek-ahcp-00 */
+#endif
+#ifndef GENEVE_PORT
+#define GENEVE_PORT 6081 /* draft-gross-geneve-02 */
+#endif
+#ifndef SFLOW_PORT
+#define SFLOW_PORT 6343 /* http://www.sflow.org/developers/specifications.php */
+#endif
+#ifndef BABEL_PORT
+#define BABEL_PORT 6696 /* RFC 6126 errata */
+#endif
+#ifndef BABEL_PORT_OLD
+#define BABEL_PORT_OLD 6697 /* RFC 6126 */
+#endif
+#ifndef RX_PORT_LOW
+#define RX_PORT_LOW 7000 /*XXX*/
+#endif
+#ifndef RX_PORT_HIGH
+#define RX_PORT_HIGH 7009 /*XXX*/
+#endif
+#ifndef ISAKMP_PORT_USER1
+#define ISAKMP_PORT_USER1 7500 /*XXX - nonstandard*/
+#endif
+#ifndef HNCP_PORT
+#define HNCP_PORT 8231 /* RFC 7788 */
+#endif
+#ifndef OTV_PORT
+#define OTV_PORT 8472 /* draft-hasmit-otv-04 */
+#endif
+#ifndef ISAKMP_PORT_USER2
+#define ISAKMP_PORT_USER2 8500 /*XXX - nonstandard*/
+#endif
+#ifndef LWAPP_DATA_PORT
+#define LWAPP_DATA_PORT 12222 /* RFC 5412 */
+#endif
+#ifndef LWAPP_CONTROL_PORT
+#define LWAPP_CONTROL_PORT 12223 /* RFC 5412 */
#endif
diff --git a/freebsd/contrib/tcpdump/util-print.c b/freebsd/contrib/tcpdump/util-print.c
new file mode 100644
index 00000000..63ca91a1
--- /dev/null
+++ b/freebsd/contrib/tcpdump/util-print.c
@@ -0,0 +1,946 @@
+#include <machine/rtems-bsd-user-space.h>
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#include "rtems-bsd-tcpdump-namespace.h"
+#endif /* __rtems__ */
+/*
+ * Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996, 1997
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code distributions
+ * retain the above copyright notice and this paragraph in its entirety, (2)
+ * distributions including binary code include the above copyright notice and
+ * this paragraph in its entirety in the documentation or other materials
+ * provided with the distribution, and (3) all advertising materials mentioning
+ * features or use of this software display the following acknowledgement:
+ * ``This product includes software developed by the University of California,
+ * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
+ * the University 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 ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+/*
+ * txtproto_print() derived from original code by Hannes Gredler
+ * (hannes@juniper.net):
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code
+ * distributions retain the above copyright notice and this paragraph
+ * in its entirety, and (2) distributions including binary code include
+ * the above copyright notice and this paragraph in its entirety in
+ * the documentation or other materials provided with the distribution.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND
+ * WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
+ * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <netdissect-stdinc.h>
+
+#include <sys/stat.h>
+
+#ifdef HAVE_FCNTL_H
+#include <fcntl.h>
+#endif
+#include <ctype.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "netdissect.h"
+#include "ascii_strcasecmp.h"
+#include "timeval-operations.h"
+
+int32_t thiszone; /* seconds offset from gmt to local time */
+/* invalid string to print '(invalid)' for malformed or corrupted packets */
+const char istr[] = " (invalid)";
+
+/*
+ * timestamp display buffer size, the biggest size of both formats is needed
+ * sizeof("0000000000.000000000") > sizeof("00:00:00.000000000")
+ */
+#define TS_BUF_SIZE sizeof("0000000000.000000000")
+
+#define TOKBUFSIZE 128
+
+/*
+ * Print out a character, filtering out the non-printable ones
+ */
+void
+fn_print_char(netdissect_options *ndo, u_char c)
+{
+ if (!ND_ISASCII(c)) {
+ c = ND_TOASCII(c);
+ ND_PRINT((ndo, "M-"));
+ }
+ if (!ND_ISPRINT(c)) {
+ c ^= 0x40; /* DEL to ?, others to alpha */
+ ND_PRINT((ndo, "^"));
+ }
+ ND_PRINT((ndo, "%c", c));
+}
+
+/*
+ * Print out a null-terminated filename (or other ascii string).
+ * If ep is NULL, assume no truncation check is needed.
+ * Return true if truncated.
+ * Stop at ep (if given) or before the null char, whichever is first.
+ */
+int
+fn_print(netdissect_options *ndo,
+ register const u_char *s, register const u_char *ep)
+{
+ register int ret;
+ register u_char c;
+
+ ret = 1; /* assume truncated */
+ while (ep == NULL || s < ep) {
+ c = *s++;
+ if (c == '\0') {
+ ret = 0;
+ break;
+ }
+ if (!ND_ISASCII(c)) {
+ c = ND_TOASCII(c);
+ ND_PRINT((ndo, "M-"));
+ }
+ if (!ND_ISPRINT(c)) {
+ c ^= 0x40; /* DEL to ?, others to alpha */
+ ND_PRINT((ndo, "^"));
+ }
+ ND_PRINT((ndo, "%c", c));
+ }
+ return(ret);
+}
+
+/*
+ * Print out a null-terminated filename (or other ascii string) from
+ * a fixed-length buffer.
+ * If ep is NULL, assume no truncation check is needed.
+ * Return the number of bytes of string processed, including the
+ * terminating null, if not truncated. Return 0 if truncated.
+ */
+u_int
+fn_printztn(netdissect_options *ndo,
+ register const u_char *s, register u_int n, register const u_char *ep)
+{
+ register u_int bytes;
+ register u_char c;
+
+ bytes = 0;
+ for (;;) {
+ if (n == 0 || (ep != NULL && s >= ep)) {
+ /*
+ * Truncated. This includes "no null before we
+ * got to the end of the fixed-length buffer".
+ *
+ * XXX - BOOTP says "null-terminated", which
+ * means the maximum length of the string, in
+ * bytes, is 1 less than the size of the buffer,
+ * as there must always be a terminating null.
+ */
+ bytes = 0;
+ break;
+ }
+
+ c = *s++;
+ bytes++;
+ n--;
+ if (c == '\0') {
+ /* End of string */
+ break;
+ }
+ if (!ND_ISASCII(c)) {
+ c = ND_TOASCII(c);
+ ND_PRINT((ndo, "M-"));
+ }
+ if (!ND_ISPRINT(c)) {
+ c ^= 0x40; /* DEL to ?, others to alpha */
+ ND_PRINT((ndo, "^"));
+ }
+ ND_PRINT((ndo, "%c", c));
+ }
+ return(bytes);
+}
+
+/*
+ * Print out a counted filename (or other ascii string).
+ * If ep is NULL, assume no truncation check is needed.
+ * Return true if truncated.
+ * Stop at ep (if given) or after n bytes, whichever is first.
+ */
+int
+fn_printn(netdissect_options *ndo,
+ register const u_char *s, register u_int n, register const u_char *ep)
+{
+ register u_char c;
+
+ while (n > 0 && (ep == NULL || s < ep)) {
+ n--;
+ c = *s++;
+ if (!ND_ISASCII(c)) {
+ c = ND_TOASCII(c);
+ ND_PRINT((ndo, "M-"));
+ }
+ if (!ND_ISPRINT(c)) {
+ c ^= 0x40; /* DEL to ?, others to alpha */
+ ND_PRINT((ndo, "^"));
+ }
+ ND_PRINT((ndo, "%c", c));
+ }
+ return (n == 0) ? 0 : 1;
+}
+
+/*
+ * Print out a null-padded filename (or other ascii string).
+ * If ep is NULL, assume no truncation check is needed.
+ * Return true if truncated.
+ * Stop at ep (if given) or after n bytes or before the null char,
+ * whichever is first.
+ */
+int
+fn_printzp(netdissect_options *ndo,
+ register const u_char *s, register u_int n,
+ register const u_char *ep)
+{
+ register int ret;
+ register u_char c;
+
+ ret = 1; /* assume truncated */
+ while (n > 0 && (ep == NULL || s < ep)) {
+ n--;
+ c = *s++;
+ if (c == '\0') {
+ ret = 0;
+ break;
+ }
+ if (!ND_ISASCII(c)) {
+ c = ND_TOASCII(c);
+ ND_PRINT((ndo, "M-"));
+ }
+ if (!ND_ISPRINT(c)) {
+ c ^= 0x40; /* DEL to ?, others to alpha */
+ ND_PRINT((ndo, "^"));
+ }
+ ND_PRINT((ndo, "%c", c));
+ }
+ return (n == 0) ? 0 : ret;
+}
+
+/*
+ * Format the timestamp
+ */
+static char *
+ts_format(netdissect_options *ndo
+#ifndef HAVE_PCAP_SET_TSTAMP_PRECISION
+_U_
+#endif
+, int sec, int usec, char *buf)
+{
+ const char *format;
+
+#ifdef HAVE_PCAP_SET_TSTAMP_PRECISION
+ switch (ndo->ndo_tstamp_precision) {
+
+ case PCAP_TSTAMP_PRECISION_MICRO:
+ format = "%02d:%02d:%02d.%06u";
+ break;
+
+ case PCAP_TSTAMP_PRECISION_NANO:
+ format = "%02d:%02d:%02d.%09u";
+ break;
+
+ default:
+ format = "%02d:%02d:%02d.{unknown}";
+ break;
+ }
+#else
+ format = "%02d:%02d:%02d.%06u";
+#endif
+
+ snprintf(buf, TS_BUF_SIZE, format,
+ sec / 3600, (sec % 3600) / 60, sec % 60, usec);
+
+ return buf;
+}
+
+/*
+ * Format the timestamp - Unix timeval style
+ */
+static char *
+ts_unix_format(netdissect_options *ndo
+#ifndef HAVE_PCAP_SET_TSTAMP_PRECISION
+_U_
+#endif
+, int sec, int usec, char *buf)
+{
+ const char *format;
+
+#ifdef HAVE_PCAP_SET_TSTAMP_PRECISION
+ switch (ndo->ndo_tstamp_precision) {
+
+ case PCAP_TSTAMP_PRECISION_MICRO:
+ format = "%u.%06u";
+ break;
+
+ case PCAP_TSTAMP_PRECISION_NANO:
+ format = "%u.%09u";
+ break;
+
+ default:
+ format = "%u.{unknown}";
+ break;
+ }
+#else
+ format = "%u.%06u";
+#endif
+
+ snprintf(buf, TS_BUF_SIZE, format,
+ (unsigned)sec, (unsigned)usec);
+
+ return buf;
+}
+
+/*
+ * Print the timestamp
+ */
+void
+ts_print(netdissect_options *ndo,
+ register const struct timeval *tvp)
+{
+ register int s;
+ struct tm *tm;
+ time_t Time;
+ char buf[TS_BUF_SIZE];
+ static struct timeval tv_ref;
+ struct timeval tv_result;
+ int negative_offset;
+ int nano_prec;
+
+ switch (ndo->ndo_tflag) {
+
+ case 0: /* Default */
+ s = (tvp->tv_sec + thiszone) % 86400;
+ ND_PRINT((ndo, "%s ", ts_format(ndo, s, tvp->tv_usec, buf)));
+ break;
+
+ case 1: /* No time stamp */
+ break;
+
+ case 2: /* Unix timeval style */
+ ND_PRINT((ndo, "%s ", ts_unix_format(ndo,
+ tvp->tv_sec, tvp->tv_usec, buf)));
+ break;
+
+ case 3: /* Microseconds/nanoseconds since previous packet */
+ case 5: /* Microseconds/nanoseconds since first packet */
+#ifdef HAVE_PCAP_SET_TSTAMP_PRECISION
+ switch (ndo->ndo_tstamp_precision) {
+ case PCAP_TSTAMP_PRECISION_MICRO:
+ nano_prec = 0;
+ break;
+ case PCAP_TSTAMP_PRECISION_NANO:
+ nano_prec = 1;
+ break;
+ default:
+ nano_prec = 0;
+ break;
+ }
+#else
+ nano_prec = 0;
+#endif
+ if (!(netdissect_timevalisset(&tv_ref)))
+ tv_ref = *tvp; /* set timestamp for first packet */
+
+ negative_offset = netdissect_timevalcmp(tvp, &tv_ref, <);
+ if (negative_offset)
+ netdissect_timevalsub(&tv_ref, tvp, &tv_result, nano_prec);
+ else
+ netdissect_timevalsub(tvp, &tv_ref, &tv_result, nano_prec);
+
+ ND_PRINT((ndo, (negative_offset ? "-" : " ")));
+
+ ND_PRINT((ndo, "%s ", ts_format(ndo,
+ tv_result.tv_sec, tv_result.tv_usec, buf)));
+
+ if (ndo->ndo_tflag == 3)
+ tv_ref = *tvp; /* set timestamp for previous packet */
+ break;
+
+ case 4: /* Default + Date */
+ s = (tvp->tv_sec + thiszone) % 86400;
+ Time = (tvp->tv_sec + thiszone) - s;
+ tm = gmtime (&Time);
+ if (!tm)
+ ND_PRINT((ndo, "Date fail "));
+ else
+ ND_PRINT((ndo, "%04d-%02d-%02d %s ",
+ tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday,
+ ts_format(ndo, s, tvp->tv_usec, buf)));
+ break;
+ }
+}
+
+/*
+ * Print an unsigned relative number of seconds (e.g. hold time, prune timer)
+ * in the form 5m1s. This does no truncation, so 32230861 seconds
+ * is represented as 1y1w1d1h1m1s.
+ */
+void
+unsigned_relts_print(netdissect_options *ndo,
+ uint32_t secs)
+{
+ static const char *lengths[] = {"y", "w", "d", "h", "m", "s"};
+ static const u_int seconds[] = {31536000, 604800, 86400, 3600, 60, 1};
+ const char **l = lengths;
+ const u_int *s = seconds;
+
+ if (secs == 0) {
+ ND_PRINT((ndo, "0s"));
+ return;
+ }
+ while (secs > 0) {
+ if (secs >= *s) {
+ ND_PRINT((ndo, "%d%s", secs / *s, *l));
+ secs -= (secs / *s) * *s;
+ }
+ s++;
+ l++;
+ }
+}
+
+/*
+ * Print a signed relative number of seconds (e.g. hold time, prune timer)
+ * in the form 5m1s. This does no truncation, so 32230861 seconds
+ * is represented as 1y1w1d1h1m1s.
+ */
+void
+signed_relts_print(netdissect_options *ndo,
+ int32_t secs)
+{
+ if (secs < 0) {
+ ND_PRINT((ndo, "-"));
+ if (secs == INT32_MIN) {
+ /*
+ * -2^31; you can't fit its absolute value into
+ * a 32-bit signed integer.
+ *
+ * Just directly pass said absolute value to
+ * unsigned_relts_print() directly.
+ *
+ * (XXX - does ISO C guarantee that -(-2^n),
+ * when calculated and cast to an n-bit unsigned
+ * integer type, will have the value 2^n?)
+ */
+ unsigned_relts_print(ndo, 2147483648U);
+ } else {
+ /*
+ * We now know -secs will fit into an int32_t;
+ * negate it and pass that to unsigned_relts_print().
+ */
+ unsigned_relts_print(ndo, -secs);
+ }
+ return;
+ }
+ unsigned_relts_print(ndo, secs);
+}
+
+/*
+ * this is a generic routine for printing unknown data;
+ * we pass on the linefeed plus indentation string to
+ * get a proper output - returns 0 on error
+ */
+
+int
+print_unknown_data(netdissect_options *ndo, const u_char *cp,const char *ident,int len)
+{
+ if (len < 0) {
+ ND_PRINT((ndo,"%sDissector error: print_unknown_data called with negative length",
+ ident));
+ return(0);
+ }
+ if (ndo->ndo_snapend - cp < len)
+ len = ndo->ndo_snapend - cp;
+ if (len < 0) {
+ ND_PRINT((ndo,"%sDissector error: print_unknown_data called with pointer past end of packet",
+ ident));
+ return(0);
+ }
+ hex_print(ndo, ident,cp,len);
+ return(1); /* everything is ok */
+}
+
+/*
+ * Convert a token value to a string; use "fmt" if not found.
+ */
+const char *
+tok2strbuf(register const struct tok *lp, register const char *fmt,
+ register u_int v, char *buf, size_t bufsize)
+{
+ if (lp != NULL) {
+ while (lp->s != NULL) {
+ if (lp->v == v)
+ return (lp->s);
+ ++lp;
+ }
+ }
+ if (fmt == NULL)
+ fmt = "#%d";
+
+ (void)snprintf(buf, bufsize, fmt, v);
+ return (const char *)buf;
+}
+
+/*
+ * Convert a token value to a string; use "fmt" if not found.
+ */
+const char *
+tok2str(register const struct tok *lp, register const char *fmt,
+ register u_int v)
+{
+ static char buf[4][TOKBUFSIZE];
+ static int idx = 0;
+ char *ret;
+
+ ret = buf[idx];
+ idx = (idx+1) & 3;
+ return tok2strbuf(lp, fmt, v, ret, sizeof(buf[0]));
+}
+
+/*
+ * Convert a bit token value to a string; use "fmt" if not found.
+ * this is useful for parsing bitfields, the output strings are seperated
+ * if the s field is positive.
+ */
+static char *
+bittok2str_internal(register const struct tok *lp, register const char *fmt,
+ register u_int v, const char *sep)
+{
+ static char buf[256]; /* our stringbuffer */
+ int buflen=0;
+ register u_int rotbit; /* this is the bit we rotate through all bitpositions */
+ register u_int tokval;
+ const char * sepstr = "";
+
+ while (lp != NULL && lp->s != NULL) {
+ tokval=lp->v; /* load our first value */
+ rotbit=1;
+ while (rotbit != 0) {
+ /*
+ * lets AND the rotating bit with our token value
+ * and see if we have got a match
+ */
+ if (tokval == (v&rotbit)) {
+ /* ok we have found something */
+ buflen+=snprintf(buf+buflen, sizeof(buf)-buflen, "%s%s",
+ sepstr, lp->s);
+ sepstr = sep;
+ break;
+ }
+ rotbit=rotbit<<1; /* no match - lets shift and try again */
+ }
+ lp++;
+ }
+
+ if (buflen == 0)
+ /* bummer - lets print the "unknown" message as advised in the fmt string if we got one */
+ (void)snprintf(buf, sizeof(buf), fmt == NULL ? "#%08x" : fmt, v);
+ return (buf);
+}
+
+/*
+ * Convert a bit token value to a string; use "fmt" if not found.
+ * this is useful for parsing bitfields, the output strings are not seperated.
+ */
+char *
+bittok2str_nosep(register const struct tok *lp, register const char *fmt,
+ register u_int v)
+{
+ return (bittok2str_internal(lp, fmt, v, ""));
+}
+
+/*
+ * Convert a bit token value to a string; use "fmt" if not found.
+ * this is useful for parsing bitfields, the output strings are comma seperated.
+ */
+char *
+bittok2str(register const struct tok *lp, register const char *fmt,
+ register u_int v)
+{
+ return (bittok2str_internal(lp, fmt, v, ", "));
+}
+
+/*
+ * Convert a value to a string using an array; the macro
+ * tok2strary() in <netdissect.h> is the public interface to
+ * this function and ensures that the second argument is
+ * correct for bounds-checking.
+ */
+const char *
+tok2strary_internal(register const char **lp, int n, register const char *fmt,
+ register int v)
+{
+ static char buf[TOKBUFSIZE];
+
+ if (v >= 0 && v < n && lp[v] != NULL)
+ return lp[v];
+ if (fmt == NULL)
+ fmt = "#%d";
+ (void)snprintf(buf, sizeof(buf), fmt, v);
+ return (buf);
+}
+
+/*
+ * Convert a 32-bit netmask to prefixlen if possible
+ * the function returns the prefix-len; if plen == -1
+ * then conversion was not possible;
+ */
+
+int
+mask2plen(uint32_t mask)
+{
+ uint32_t bitmasks[33] = {
+ 0x00000000,
+ 0x80000000, 0xc0000000, 0xe0000000, 0xf0000000,
+ 0xf8000000, 0xfc000000, 0xfe000000, 0xff000000,
+ 0xff800000, 0xffc00000, 0xffe00000, 0xfff00000,
+ 0xfff80000, 0xfffc0000, 0xfffe0000, 0xffff0000,
+ 0xffff8000, 0xffffc000, 0xffffe000, 0xfffff000,
+ 0xfffff800, 0xfffffc00, 0xfffffe00, 0xffffff00,
+ 0xffffff80, 0xffffffc0, 0xffffffe0, 0xfffffff0,
+ 0xfffffff8, 0xfffffffc, 0xfffffffe, 0xffffffff
+ };
+ int prefix_len = 32;
+
+ /* let's see if we can transform the mask into a prefixlen */
+ while (prefix_len >= 0) {
+ if (bitmasks[prefix_len] == mask)
+ break;
+ prefix_len--;
+ }
+ return (prefix_len);
+}
+
+int
+mask62plen(const u_char *mask)
+{
+ u_char bitmasks[9] = {
+ 0x00,
+ 0x80, 0xc0, 0xe0, 0xf0,
+ 0xf8, 0xfc, 0xfe, 0xff
+ };
+ int byte;
+ int cidr_len = 0;
+
+ for (byte = 0; byte < 16; byte++) {
+ u_int bits;
+
+ for (bits = 0; bits < (sizeof (bitmasks) / sizeof (bitmasks[0])); bits++) {
+ if (mask[byte] == bitmasks[bits]) {
+ cidr_len += bits;
+ break;
+ }
+ }
+
+ if (mask[byte] != 0xff)
+ break;
+ }
+ return (cidr_len);
+}
+
+/*
+ * Routine to print out information for text-based protocols such as FTP,
+ * HTTP, SMTP, RTSP, SIP, ....
+ */
+#define MAX_TOKEN 128
+
+/*
+ * Fetch a token from a packet, starting at the specified index,
+ * and return the length of the token.
+ *
+ * Returns 0 on error; yes, this is indistinguishable from an empty
+ * token, but an "empty token" isn't a valid token - it just means
+ * either a space character at the beginning of the line (this
+ * includes a blank line) or no more tokens remaining on the line.
+ */
+static int
+fetch_token(netdissect_options *ndo, const u_char *pptr, u_int idx, u_int len,
+ u_char *tbuf, size_t tbuflen)
+{
+ size_t toklen = 0;
+
+ for (; idx < len; idx++) {
+ if (!ND_TTEST(*(pptr + idx))) {
+ /* ran past end of captured data */
+ return (0);
+ }
+ if (!isascii(*(pptr + idx))) {
+ /* not an ASCII character */
+ return (0);
+ }
+ if (isspace(*(pptr + idx))) {
+ /* end of token */
+ break;
+ }
+ if (!isprint(*(pptr + idx))) {
+ /* not part of a command token or response code */
+ return (0);
+ }
+ if (toklen + 2 > tbuflen) {
+ /* no room for this character and terminating '\0' */
+ return (0);
+ }
+ tbuf[toklen] = *(pptr + idx);
+ toklen++;
+ }
+ if (toklen == 0) {
+ /* no token */
+ return (0);
+ }
+ tbuf[toklen] = '\0';
+
+ /*
+ * Skip past any white space after the token, until we see
+ * an end-of-line (CR or LF).
+ */
+ for (; idx < len; idx++) {
+ if (!ND_TTEST(*(pptr + idx))) {
+ /* ran past end of captured data */
+ break;
+ }
+ if (*(pptr + idx) == '\r' || *(pptr + idx) == '\n') {
+ /* end of line */
+ break;
+ }
+ if (!isascii(*(pptr + idx)) || !isprint(*(pptr + idx))) {
+ /* not a printable ASCII character */
+ break;
+ }
+ if (!isspace(*(pptr + idx))) {
+ /* beginning of next token */
+ break;
+ }
+ }
+ return (idx);
+}
+
+/*
+ * Scan a buffer looking for a line ending - LF or CR-LF.
+ * Return the index of the character after the line ending or 0 if
+ * we encounter a non-ASCII or non-printable character or don't find
+ * the line ending.
+ */
+static u_int
+print_txt_line(netdissect_options *ndo, const char *protoname,
+ const char *prefix, const u_char *pptr, u_int idx, u_int len)
+{
+ u_int startidx;
+ u_int linelen;
+
+ startidx = idx;
+ while (idx < len) {
+ ND_TCHECK(*(pptr+idx));
+ if (*(pptr+idx) == '\n') {
+ /*
+ * LF without CR; end of line.
+ * Skip the LF and print the line, with the
+ * exception of the LF.
+ */
+ linelen = idx - startidx;
+ idx++;
+ goto print;
+ } else if (*(pptr+idx) == '\r') {
+ /* CR - any LF? */
+ if ((idx+1) >= len) {
+ /* not in this packet */
+ return (0);
+ }
+ ND_TCHECK(*(pptr+idx+1));
+ if (*(pptr+idx+1) == '\n') {
+ /*
+ * CR-LF; end of line.
+ * Skip the CR-LF and print the line, with
+ * the exception of the CR-LF.
+ */
+ linelen = idx - startidx;
+ idx += 2;
+ goto print;
+ }
+
+ /*
+ * CR followed by something else; treat this
+ * as if it were binary data, and don't print
+ * it.
+ */
+ return (0);
+ } else if (!isascii(*(pptr+idx)) ||
+ (!isprint(*(pptr+idx)) && *(pptr+idx) != '\t')) {
+ /*
+ * Not a printable ASCII character and not a tab;
+ * treat this as if it were binary data, and
+ * don't print it.
+ */
+ return (0);
+ }
+ idx++;
+ }
+
+ /*
+ * All printable ASCII, but no line ending after that point
+ * in the buffer; treat this as if it were truncated.
+ */
+trunc:
+ linelen = idx - startidx;
+ ND_PRINT((ndo, "%s%.*s[!%s]", prefix, (int)linelen, pptr + startidx,
+ protoname));
+ return (0);
+
+print:
+ ND_PRINT((ndo, "%s%.*s", prefix, (int)linelen, pptr + startidx));
+ return (idx);
+}
+
+void
+txtproto_print(netdissect_options *ndo, const u_char *pptr, u_int len,
+ const char *protoname, const char **cmds, u_int flags)
+{
+ u_int idx, eol;
+ u_char token[MAX_TOKEN+1];
+ const char *cmd;
+ int is_reqresp = 0;
+ const char *pnp;
+
+ if (cmds != NULL) {
+ /*
+ * This protocol has more than just request and
+ * response lines; see whether this looks like a
+ * request or response.
+ */
+ idx = fetch_token(ndo, pptr, 0, len, token, sizeof(token));
+ if (idx != 0) {
+ /* Is this a valid request name? */
+ while ((cmd = *cmds++) != NULL) {
+ if (ascii_strcasecmp((const char *)token, cmd) == 0) {
+ /* Yes. */
+ is_reqresp = 1;
+ break;
+ }
+ }
+
+ /*
+ * No - is this a valid response code (3 digits)?
+ *
+ * Is this token the response code, or is the next
+ * token the response code?
+ */
+ if (flags & RESP_CODE_SECOND_TOKEN) {
+ /*
+ * Next token - get it.
+ */
+ idx = fetch_token(ndo, pptr, idx, len, token,
+ sizeof(token));
+ }
+ if (idx != 0) {
+ if (isdigit(token[0]) && isdigit(token[1]) &&
+ isdigit(token[2]) && token[3] == '\0') {
+ /* Yes. */
+ is_reqresp = 1;
+ }
+ }
+ }
+ } else {
+ /*
+ * This protocol has only request and response lines
+ * (e.g., FTP, where all the data goes over a
+ * different connection); assume the payload is
+ * a request or response.
+ */
+ is_reqresp = 1;
+ }
+
+ /* Capitalize the protocol name */
+ for (pnp = protoname; *pnp != '\0'; pnp++)
+ ND_PRINT((ndo, "%c", toupper((u_char)*pnp)));
+
+ if (is_reqresp) {
+ /*
+ * In non-verbose mode, just print the protocol, followed
+ * by the first line as the request or response info.
+ *
+ * In verbose mode, print lines as text until we run out
+ * of characters or see something that's not a
+ * printable-ASCII line.
+ */
+ if (ndo->ndo_vflag) {
+ /*
+ * We're going to print all the text lines in the
+ * request or response; just print the length
+ * on the first line of the output.
+ */
+ ND_PRINT((ndo, ", length: %u", len));
+ for (idx = 0;
+ idx < len && (eol = print_txt_line(ndo, protoname, "\n\t", pptr, idx, len)) != 0;
+ idx = eol)
+ ;
+ } else {
+ /*
+ * Just print the first text line.
+ */
+ print_txt_line(ndo, protoname, ": ", pptr, 0, len);
+ }
+ }
+}
+
+void
+safeputs(netdissect_options *ndo,
+ const u_char *s, const u_int maxlen)
+{
+ u_int idx = 0;
+
+ while (*s && idx < maxlen) {
+ safeputchar(ndo, *s);
+ idx++;
+ s++;
+ }
+}
+
+void
+safeputchar(netdissect_options *ndo,
+ const u_char c)
+{
+ ND_PRINT((ndo, (c < 0x80 && ND_ISPRINT(c)) ? "%c" : "\\0x%02x", c));
+}
+
+#ifdef LBL_ALIGN
+/*
+ * Some compilers try to optimize memcpy(), using the alignment constraint
+ * on the argument pointer type. by using this function, we try to avoid the
+ * optimization.
+ */
+void
+unaligned_memcpy(void *p, const void *q, size_t l)
+{
+ memcpy(p, q, l);
+}
+
+/* As with memcpy(), so with memcmp(). */
+int
+unaligned_memcmp(const void *p, const void *q, size_t l)
+{
+ return (memcmp(p, q, l));
+}
+#endif
+
+#ifdef __rtems__
+#include "rtems-bsd-tcpdump-util-print-data.h"
+#endif /* __rtems__ */
diff --git a/freebsd/contrib/tcpdump/util.c b/freebsd/contrib/tcpdump/util.c
deleted file mode 100644
index d50e1254..00000000
--- a/freebsd/contrib/tcpdump/util.c
+++ /dev/null
@@ -1,610 +0,0 @@
-#include <machine/rtems-bsd-user-space.h>
-
-/*
- * Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996, 1997
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that: (1) source code distributions
- * retain the above copyright notice and this paragraph in its entirety, (2)
- * distributions including binary code include the above copyright notice and
- * this paragraph in its entirety in the documentation or other materials
- * provided with the distribution, and (3) all advertising materials mentioning
- * features or use of this software display the following acknowledgement:
- * ``This product includes software developed by the University of California,
- * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
- * the University 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 ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/util.c,v 1.109 2007-01-29 09:59:42 hannes Exp $ (LBL)";
-#endif
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <tcpdump-stdinc.h>
-
-#include <sys/stat.h>
-
-#include <errno.h>
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-#include <pcap.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "interface.h"
-
-char * ts_format(register int, register int);
-
-/*
- * Print out a null-terminated filename (or other ascii string).
- * If ep is NULL, assume no truncation check is needed.
- * Return true if truncated.
- */
-int
-fn_print(register const u_char *s, register const u_char *ep)
-{
- register int ret;
- register u_char c;
-
- ret = 1; /* assume truncated */
- while (ep == NULL || s < ep) {
- c = *s++;
- if (c == '\0') {
- ret = 0;
- break;
- }
- if (!isascii(c)) {
- c = toascii(c);
- putchar('M');
- putchar('-');
- }
- if (!isprint(c)) {
- c ^= 0x40; /* DEL to ?, others to alpha */
- putchar('^');
- }
- putchar(c);
- }
- return(ret);
-}
-
-/*
- * Print out a counted filename (or other ascii string).
- * If ep is NULL, assume no truncation check is needed.
- * Return true if truncated.
- */
-int
-fn_printn(register const u_char *s, register u_int n,
- register const u_char *ep)
-{
- register u_char c;
-
- while (n > 0 && (ep == NULL || s < ep)) {
- n--;
- c = *s++;
- if (!isascii(c)) {
- c = toascii(c);
- putchar('M');
- putchar('-');
- }
- if (!isprint(c)) {
- c ^= 0x40; /* DEL to ?, others to alpha */
- putchar('^');
- }
- putchar(c);
- }
- return (n == 0) ? 0 : 1;
-}
-
-/*
- * Print out a null-padded filename (or other ascii string).
- * If ep is NULL, assume no truncation check is needed.
- * Return true if truncated.
- */
-int
-fn_printzp(register const u_char *s, register u_int n,
- register const u_char *ep)
-{
- register int ret;
- register u_char c;
-
- ret = 1; /* assume truncated */
- while (n > 0 && (ep == NULL || s < ep)) {
- n--;
- c = *s++;
- if (c == '\0') {
- ret = 0;
- break;
- }
- if (!isascii(c)) {
- c = toascii(c);
- putchar('M');
- putchar('-');
- }
- if (!isprint(c)) {
- c ^= 0x40; /* DEL to ?, others to alpha */
- putchar('^');
- }
- putchar(c);
- }
- return (n == 0) ? 0 : ret;
-}
-
-/*
- * Format the timestamp
- */
-char *
-ts_format(register int sec, register int usec)
-{
- static char buf[sizeof("00:00:00.000000")];
- (void)snprintf(buf, sizeof(buf), "%02d:%02d:%02d.%06u",
- sec / 3600, (sec % 3600) / 60, sec % 60, usec);
-
- return buf;
-}
-
-/*
- * Print the timestamp
- */
-void
-ts_print(register const struct timeval *tvp)
-{
- register int s;
- struct tm *tm;
- time_t Time;
- static unsigned b_sec;
- static unsigned b_usec;
- int d_usec;
- int d_sec;
-
- switch (tflag) {
-
- case 0: /* Default */
- s = (tvp->tv_sec + thiszone) % 86400;
- (void)printf("%s ", ts_format(s, tvp->tv_usec));
- break;
-
- case 1: /* No time stamp */
- break;
-
- case 2: /* Unix timeval style */
- (void)printf("%u.%06u ",
- (unsigned)tvp->tv_sec,
- (unsigned)tvp->tv_usec);
- break;
-
- case 3: /* Microseconds since previous packet */
- case 5: /* Microseconds since first packet */
- if (b_sec == 0) {
- /* init timestamp for first packet */
- b_usec = tvp->tv_usec;
- b_sec = tvp->tv_sec;
- }
-
- d_usec = tvp->tv_usec - b_usec;
- d_sec = tvp->tv_sec - b_sec;
-
- while (d_usec < 0) {
- d_usec += 1000000;
- d_sec--;
- }
-
- (void)printf("%s ", ts_format(d_sec, d_usec));
-
- if (tflag == 3) { /* set timestamp for last packet */
- b_sec = tvp->tv_sec;
- b_usec = tvp->tv_usec;
- }
- break;
-
- case 4: /* Default + Date*/
- s = (tvp->tv_sec + thiszone) % 86400;
- Time = (tvp->tv_sec + thiszone) - s;
- tm = gmtime (&Time);
- if (!tm)
- printf("Date fail ");
- else
- printf("%04d-%02d-%02d %s ",
- tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday,
- ts_format(s, tvp->tv_usec));
- break;
- }
-}
-
-/*
- * Print a relative number of seconds (e.g. hold time, prune timer)
- * in the form 5m1s. This does no truncation, so 32230861 seconds
- * is represented as 1y1w1d1h1m1s.
- */
-void
-relts_print(int secs)
-{
- static const char *lengths[] = {"y", "w", "d", "h", "m", "s"};
- static const int seconds[] = {31536000, 604800, 86400, 3600, 60, 1};
- const char **l = lengths;
- const int *s = seconds;
-
- if (secs == 0) {
- (void)printf("0s");
- return;
- }
- if (secs < 0) {
- (void)printf("-");
- secs = -secs;
- }
- while (secs > 0) {
- if (secs >= *s) {
- (void)printf("%d%s", secs / *s, *l);
- secs -= (secs / *s) * *s;
- }
- s++;
- l++;
- }
-}
-
-/*
- * this is a generic routine for printing unknown data;
- * we pass on the linefeed plus indentation string to
- * get a proper output - returns 0 on error
- */
-
-int
-print_unknown_data(const u_char *cp,const char *ident,int len)
-{
- if (len < 0) {
- printf("%sDissector error: print_unknown_data called with negative length",
- ident);
- return(0);
- }
- if (snapend - cp < len)
- len = snapend - cp;
- if (len < 0) {
- printf("%sDissector error: print_unknown_data called with pointer past end of packet",
- ident);
- return(0);
- }
- hex_print(ident,cp,len);
- return(1); /* everything is ok */
-}
-
-/*
- * Convert a token value to a string; use "fmt" if not found.
- */
-const char *
-tok2strbuf(register const struct tok *lp, register const char *fmt,
- register int v, char *buf, size_t bufsize)
-{
- if (lp != NULL) {
- while (lp->s != NULL) {
- if (lp->v == v)
- return (lp->s);
- ++lp;
- }
- }
- if (fmt == NULL)
- fmt = "#%d";
-
- (void)snprintf(buf, bufsize, fmt, v);
- return (const char *)buf;
-}
-
-/*
- * Convert a token value to a string; use "fmt" if not found.
- */
-const char *
-tok2str(register const struct tok *lp, register const char *fmt,
- register int v)
-{
- static char buf[4][128];
- static int idx = 0;
- char *ret;
-
- ret = buf[idx];
- idx = (idx+1) & 3;
- return tok2strbuf(lp, fmt, v, ret, sizeof(buf[0]));
-}
-
-/*
- * Convert a bit token value to a string; use "fmt" if not found.
- * this is useful for parsing bitfields, the output strings are seperated
- * if the s field is positive.
- */
-static char *
-bittok2str_internal(register const struct tok *lp, register const char *fmt,
- register int v, register int sep)
-{
- static char buf[256]; /* our stringbuffer */
- int buflen=0;
- register int rotbit; /* this is the bit we rotate through all bitpositions */
- register int tokval;
-
- while (lp != NULL && lp->s != NULL) {
- tokval=lp->v; /* load our first value */
- rotbit=1;
- while (rotbit != 0) {
- /*
- * lets AND the rotating bit with our token value
- * and see if we have got a match
- */
- if (tokval == (v&rotbit)) {
- /* ok we have found something */
- buflen+=snprintf(buf+buflen, sizeof(buf)-buflen, "%s%s",
- lp->s, sep ? ", " : "");
- break;
- }
- rotbit=rotbit<<1; /* no match - lets shift and try again */
- }
- lp++;
- }
-
- /* user didn't want string seperation - no need to cut off trailing seperators */
- if (!sep) {
- return (buf);
- }
-
- if (buflen != 0) { /* did we find anything */
- /* yep, set the the trailing zero 2 bytes before to eliminate the last comma & whitespace */
- buf[buflen-2] = '\0';
- return (buf);
- }
- else {
- /* bummer - lets print the "unknown" message as advised in the fmt string if we got one */
- if (fmt == NULL)
- fmt = "#%d";
- (void)snprintf(buf, sizeof(buf), fmt, v);
- return (buf);
- }
-}
-
-/*
- * Convert a bit token value to a string; use "fmt" if not found.
- * this is useful for parsing bitfields, the output strings are not seperated.
- */
-char *
-bittok2str_nosep(register const struct tok *lp, register const char *fmt,
- register int v)
-{
- return (bittok2str_internal(lp, fmt, v, 0));
-}
-
-/*
- * Convert a bit token value to a string; use "fmt" if not found.
- * this is useful for parsing bitfields, the output strings are comma seperated.
- */
-char *
-bittok2str(register const struct tok *lp, register const char *fmt,
- register int v)
-{
- return (bittok2str_internal(lp, fmt, v, 1));
-}
-
-/*
- * Convert a value to a string using an array; the macro
- * tok2strary() in <interface.h> is the public interface to
- * this function and ensures that the second argument is
- * correct for bounds-checking.
- */
-const char *
-tok2strary_internal(register const char **lp, int n, register const char *fmt,
- register int v)
-{
- static char buf[128];
-
- if (v >= 0 && v < n && lp[v] != NULL)
- return lp[v];
- if (fmt == NULL)
- fmt = "#%d";
- (void)snprintf(buf, sizeof(buf), fmt, v);
- return (buf);
-}
-
-/*
- * Convert a 32-bit netmask to prefixlen if possible
- * the function returns the prefix-len; if plen == -1
- * then conversion was not possible;
- */
-
-int
-mask2plen(u_int32_t mask)
-{
- u_int32_t bitmasks[33] = {
- 0x00000000,
- 0x80000000, 0xc0000000, 0xe0000000, 0xf0000000,
- 0xf8000000, 0xfc000000, 0xfe000000, 0xff000000,
- 0xff800000, 0xffc00000, 0xffe00000, 0xfff00000,
- 0xfff80000, 0xfffc0000, 0xfffe0000, 0xffff0000,
- 0xffff8000, 0xffffc000, 0xffffe000, 0xfffff000,
- 0xfffff800, 0xfffffc00, 0xfffffe00, 0xffffff00,
- 0xffffff80, 0xffffffc0, 0xffffffe0, 0xfffffff0,
- 0xfffffff8, 0xfffffffc, 0xfffffffe, 0xffffffff
- };
- int prefix_len = 32;
-
- /* let's see if we can transform the mask into a prefixlen */
- while (prefix_len >= 0) {
- if (bitmasks[prefix_len] == mask)
- break;
- prefix_len--;
- }
- return (prefix_len);
-}
-
-#ifdef INET6
-int
-mask62plen(const u_char *mask)
-{
- u_char bitmasks[9] = {
- 0x00,
- 0x80, 0xc0, 0xe0, 0xf0,
- 0xf8, 0xfc, 0xfe, 0xff
- };
- int byte;
- int cidr_len = 0;
-
- for (byte = 0; byte < 16; byte++) {
- u_int bits;
-
- for (bits = 0; bits < (sizeof (bitmasks) / sizeof (bitmasks[0])); bits++) {
- if (mask[byte] == bitmasks[bits]) {
- cidr_len += bits;
- break;
- }
- }
-
- if (mask[byte] != 0xff)
- break;
- }
- return (cidr_len);
-}
-#endif /* INET6 */
-
-/* VARARGS */
-void
-error(const char *fmt, ...)
-{
- va_list ap;
-
- (void)fprintf(stderr, "%s: ", program_name);
- va_start(ap, fmt);
- (void)vfprintf(stderr, fmt, ap);
- va_end(ap);
- if (*fmt) {
- fmt += strlen(fmt);
- if (fmt[-1] != '\n')
- (void)fputc('\n', stderr);
- }
- exit(1);
- /* NOTREACHED */
-}
-
-/* VARARGS */
-void
-warning(const char *fmt, ...)
-{
- va_list ap;
-
- (void)fprintf(stderr, "%s: WARNING: ", program_name);
- va_start(ap, fmt);
- (void)vfprintf(stderr, fmt, ap);
- va_end(ap);
- if (*fmt) {
- fmt += strlen(fmt);
- if (fmt[-1] != '\n')
- (void)fputc('\n', stderr);
- }
-}
-
-/*
- * Copy arg vector into a new buffer, concatenating arguments with spaces.
- */
-char *
-copy_argv(register char **argv)
-{
- register char **p;
- register u_int len = 0;
- char *buf;
- char *src, *dst;
-
- p = argv;
- if (*p == 0)
- return 0;
-
- while (*p)
- len += strlen(*p++) + 1;
-
- buf = (char *)malloc(len);
- if (buf == NULL)
- error("copy_argv: malloc");
-
- p = argv;
- dst = buf;
- while ((src = *p++) != NULL) {
- while ((*dst++ = *src++) != '\0')
- ;
- dst[-1] = ' ';
- }
- dst[-1] = '\0';
-
- return buf;
-}
-
-/*
- * On Windows, we need to open the file in binary mode, so that
- * we get all the bytes specified by the size we get from "fstat()".
- * On UNIX, that's not necessary. O_BINARY is defined on Windows;
- * we define it as 0 if it's not defined, so it does nothing.
- */
-#ifndef O_BINARY
-#define O_BINARY 0
-#endif
-
-char *
-read_infile(char *fname)
-{
- register int i, fd, cc;
- register char *cp;
- struct stat buf;
-
- fd = open(fname, O_RDONLY|O_BINARY);
- if (fd < 0)
- error("can't open %s: %s", fname, pcap_strerror(errno));
-
- if (fstat(fd, &buf) < 0)
- error("can't stat %s: %s", fname, pcap_strerror(errno));
-
- cp = malloc((u_int)buf.st_size + 1);
- if (cp == NULL)
- error("malloc(%d) for %s: %s", (u_int)buf.st_size + 1,
- fname, pcap_strerror(errno));
- cc = read(fd, cp, (u_int)buf.st_size);
- if (cc < 0)
- error("read %s: %s", fname, pcap_strerror(errno));
- if (cc != buf.st_size)
- error("short read %s (%d != %d)", fname, cc, (int)buf.st_size);
-
- close(fd);
- /* replace "# comment" with spaces */
- for (i = 0; i < cc; i++) {
- if (cp[i] == '#')
- while (i < cc && cp[i] != '\n')
- cp[i++] = ' ';
- }
- cp[cc] = '\0';
- return (cp);
-}
-
-void
-safeputs(const char *s, int maxlen)
-{
- int idx = 0;
-
- while (*s && idx < maxlen) {
- safeputchar(*s);
- idx++;
- s++;
- }
-}
-
-void
-safeputchar(int c)
-{
- unsigned char ch;
-
- ch = (unsigned char)(c & 0xff);
- if (ch < 0x80 && isprint(ch))
- printf("%c", ch);
- else
- printf("\\0x%02x", ch);
-}
diff --git a/freebsd/usr.sbin/tcpdump/tcpdump/config.h b/freebsd/usr.sbin/tcpdump/tcpdump/config.h
index 62fa3cd3..354a65db 100644
--- a/freebsd/usr.sbin/tcpdump/tcpdump/config.h
+++ b/freebsd/usr.sbin/tcpdump/tcpdump/config.h
@@ -3,107 +3,68 @@
/* config.h. Generated from config.h.in by configure. */
/* config.h.in. Generated from configure.in by autoheader. */
-/* "generated automatically" means DO NOT MAKE CHANGES TO config.h.in --
- * make them to acconfig.h and rerun autoheader */
-/* Define if you enable IPv6 support */
-/* See Makefile */
-/* #undef INET6 */
-
-/* Define if you enable support for the libsmi. */
-/* #undef LIBSMI */
-
-/* define if you have the addrinfo function. */
-#define HAVE_ADDRINFO 1
-
-/* define if you need to include missing/addrinfoh.h. */
-/* #undef NEED_ADDRINFO_H */
-
-/* define ifyou have the h_errno variable. */
-#define HAVE_H_ERRNO 1
-
-/* define if you have struct sockaddr_storage */
-#define HAVE_SOCKADDR_STORAGE 1
-
-/* define if you have both getipnodebyname() and getipnodebyaddr() */
-/* #undef USE_GETIPNODEBY */
-
-/* define if you have ether_ntohost() and it works */
-#define USE_ETHER_NTOHOST 1
-
-/* define if libpcap has pcap_version */
-/* #undef HAVE_PCAP_VERSION */
-
-/* define if libpcap has pcap_debug */
-/* #undef HAVE_PCAP_DEBUG */
-
-/* define if libpcap has yydebug */
-/* #undef HAVE_YYDEBUG */
-
-/* define if libpcap has pcap_list_datalinks() */
-#define HAVE_PCAP_LIST_DATALINKS 1
+/* define if you want to build the possibly-buggy SMB printer */
+#define ENABLE_SMB 1
-/* define if libpcap has pcap_set_datalink() */
-#define HAVE_PCAP_SET_DATALINK 1
-
-/* define if libpcap has pcap_datalink_name_to_val() */
-#define HAVE_PCAP_DATALINK_NAME_TO_VAL 1
-
-/* define if libpcap has pcap_datalink_val_to_description() */
-#define HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION 1
-
-/* define if libpcap has pcap_dump_ftell() */
-#define HAVE_PCAP_DUMP_FTELL 1
-
-/* define if you have getrpcbynumber() */
-#define HAVE_GETRPCBYNUMBER 1
+/* Define to 1 if you have the `alarm' function. */
+#define HAVE_ALARM 1
-/* Workaround for missing 64-bit formats */
-/* #undef PRId64 */
-/* #undef PRIo64 */
-/* #undef PRIx64 */
-/* #undef PRIu64 */
+/* Define to 1 if you have the `bpf_dump' function. */
+#define HAVE_BPF_DUMP 1
-/* Whether or not to include the possibly-buggy SMB printer */
-#define TCPDUMP_DO_SMB 1
+#ifndef __rtems__
+/* capsicum support available */
+#define HAVE_CAPSICUM 1
+#endif /* __rtems__ */
-/* Define if you have the dnet_htoa function. */
-/* #undef HAVE_DNET_HTOA */
+/* Casper library support available */
+/* See Makefile */
+/* #undef HAVE_CASPER */
-/* Define if you have a dnet_htoa declaration in <netdnet/dnetdb.h>. */
-/* #undef HAVE_NETDNET_DNETDB_H_DNET_HTOA */
+/* Define to 1 if you have the `cap_enter' function. */
+#define HAVE_CAP_ENTER 1
-/* define if should drop privileges by default */
-/* #undef WITH_USER */
+/* Define to 1 if you have the `cap_ioctls_limit' function. */
+#define HAVE_CAP_IOCTLS_LIMIT 1
-/* define if should chroot when dropping privileges */
-/* #undef WITH_CHROOT */
+/* Define to 1 if you have the <cap-ng.h> header file. */
+/* #undef HAVE_CAP_NG_H */
-/* Define to 1 if you have the `alarm' function. */
-#define HAVE_ALARM 1
-
-/* Define to 1 if you have the `bpf_dump' function. */
-#define HAVE_BPF_DUMP 1
+/* Define to 1 if you have the `cap_rights_limit' function. */
+#define HAVE_CAP_RIGHTS_LIMIT 1
/* Define to 1 if you have the declaration of `ether_ntohost', and to 0 if you
don't. */
#define HAVE_DECL_ETHER_NTOHOST 1
+/* define if you have the dnet_htoa function */
+/* #undef HAVE_DNET_HTOA */
+
/* Define to 1 if you have the `ether_ntohost' function. */
#define HAVE_ETHER_NTOHOST 1
+/* Define to 1 if you have the `EVP_CIPHER_CTX_new' function. */
+#define HAVE_EVP_CIPHER_CTX_NEW 1
+
/* Define to 1 if you have the <fcntl.h> header file. */
#define HAVE_FCNTL_H 1
/* Define to 1 if you have the `fork' function. */
#define HAVE_FORK 1
-/* Define to 1 if you have the `getnameinfo' function. */
-#define HAVE_GETNAMEINFO 1
+/* Define to 1 if you have the `getopt_long' function. */
+#define HAVE_GETOPT_LONG 1
+
+/* define if you have getrpcbynumber() */
+#define HAVE_GETRPCBYNUMBER 1
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
+/* Define to 1 if you have the `cap-ng' library (-lcap-ng). */
+/* #undef HAVE_LIBCAP_NG */
+
/* Define to 1 if you have the `crypto' library (-lcrypto). */
/* See Makefile */
/* #undef HAVE_LIBCRYPTO */
@@ -111,29 +72,40 @@
/* Define to 1 if you have the `rpc' library (-lrpc). */
/* #undef HAVE_LIBRPC */
-/* Define to 1 if you have the `smi' library (-lsmi). */
-/* #undef HAVE_LIBSMI */
-
/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
/* Define to 1 if you have the <netdnet/dnetdb.h> header file. */
/* #undef HAVE_NETDNET_DNETDB_H */
+/* define if you have a dnet_htoa declaration in <netdnet/dnetdb.h> */
+/* #undef HAVE_NETDNET_DNETDB_H_DNET_HTOA */
+
/* Define to 1 if you have the <netinet/ether.h> header file. */
/* #undef HAVE_NETINET_ETHER_H */
/* Define to 1 if you have the <netinet/if_ether.h> header file. */
#define HAVE_NETINET_IF_ETHER_H 1
+/* Define to 1 if you have the <net/if_pflog.h> header file. */
+/* See Makefile */
+/* #undef HAVE_NET_IF_PFLOG_H */
+
/* Define to 1 if you have the <net/pfvar.h> header file. */
/* See Makefile */
/* #undef HAVE_NET_PFVAR_H */
+/* Define to 1 if you have the `openat' function. */
+#define HAVE_OPENAT 1
+
/* Define to 1 if you have the <openssl/evp.h> header file. */
/* See Makefile */
/* #undef HAVE_OPENSSL_EVP_H 1 */
+/* define if the OS provides AF_INET6 and struct in6_addr */
+/* See Makefile */
+/* #undef HAVE_OS_IPV6_SUPPORT */
+
/* if there's an os_proto.h for this platform, to use additional prototypes */
/* #undef HAVE_OS_PROTO_H */
@@ -146,24 +118,66 @@
/* Define to 1 if you have the `pcap_create' function. */
#define HAVE_PCAP_CREATE 1
+/* define if libpcap has pcap_datalink_name_to_val() */
+#define HAVE_PCAP_DATALINK_NAME_TO_VAL 1
+
+/* define if libpcap has pcap_datalink_val_to_description() */
+#define HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION 1
+
+/* define if libpcap has pcap_debug */
+/* #undef HAVE_PCAP_DEBUG */
+
/* Define to 1 if you have the `pcap_dump_flush' function. */
#define HAVE_PCAP_DUMP_FLUSH 1
+/* define if libpcap has pcap_dump_ftell() */
+#define HAVE_PCAP_DUMP_FTELL 1
+
/* Define to 1 if you have the `pcap_findalldevs' function. */
#define HAVE_PCAP_FINDALLDEVS 1
+/* Define to 1 if you have the `pcap_free_datalinks' function. */
+#define HAVE_PCAP_FREE_DATALINKS 1
+
/* Define to 1 if the system has the type `pcap_if_t'. */
#define HAVE_PCAP_IF_T 1
/* Define to 1 if you have the `pcap_lib_version' function. */
#define HAVE_PCAP_LIB_VERSION 1
+/* define if libpcap has pcap_list_datalinks() */
+#define HAVE_PCAP_LIST_DATALINKS 1
+
+/* Define to 1 if you have the <pcap/nflog.h> header file. */
+/* #undef HAVE_PCAP_NFLOG_H */
+
+/* Define to 1 if you have the `pcap_setdirection' function. */
+#define HAVE_PCAP_SETDIRECTION 1
+
+/* Define to 1 if you have the `pcap_set_datalink' function. */
+#define HAVE_PCAP_SET_DATALINK 1
+
+/* Define to 1 if you have the `pcap_set_immediate_mode' function. */
+#define HAVE_PCAP_SET_IMMEDIATE_MODE 1
+
+/* Define to 1 if you have the `pcap_set_optimizer_debug' function. */
+/* #undef HAVE_PCAP_SET_OPTIMIZER_DEBUG */
+
+/* Define to 1 if you have the `pcap_set_parser_debug' function. */
+/* #undef HAVE_PCAP_SET_PARSER_DEBUG */
+
+/* Define to 1 if you have the `pcap_set_tstamp_precision' function. */
+#define HAVE_PCAP_SET_TSTAMP_PRECISION 1
+
/* Define to 1 if you have the `pcap_set_tstamp_type' function. */
#define HAVE_PCAP_SET_TSTAMP_TYPE 1
/* Define to 1 if you have the <pcap/usb.h> header file. */
/* #undef HAVE_PCAP_USB_H */
+/* define if libpcap has pcap_version */
+/* #undef HAVE_PCAP_VERSION */
+
/* Define to 1 if you have the `pfopen' function. */
/* #undef HAVE_PFOPEN */
@@ -182,9 +196,6 @@
/* Define to 1 if you have the `sigset' function. */
/* #undef HAVE_SIGSET */
-/* Define to 1 if you have the <smi.h> header file. */
-/* #undef HAVE_SMI_H */
-
/* Define to 1 if you have the `snprintf' function. */
#define HAVE_SNPRINTF 1
@@ -197,9 +208,6 @@
/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
-/* Define to 1 if you have the `strcasecmp' function. */
-#define HAVE_STRCASECMP 1
-
/* Define to 1 if you have the `strdup' function. */
#define HAVE_STRDUP 1
@@ -224,15 +232,15 @@
/* Define to 1 if the system has the type `struct ether_addr'. */
/* #undef HAVE_STRUCT_ETHER_ADDR */
-/* Define to 1 if you have the <sys/bitypes.h> header file. */
-/* #undef HAVE_SYS_BITYPES_H */
-
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
+/* Define to 1 if the system has the type `uintptr_t'. */
+#define HAVE_UINTPTR_T 1
+
/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
@@ -245,6 +253,9 @@
/* Define to 1 if you have the `vsnprintf' function. */
#define HAVE_VSNPRINTF 1
+/* define if libpcap has yydebug */
+/* #undef HAVE_YYDEBUG */
+
/* define if your compiler has __attribute__ */
#define HAVE___ATTRIBUTE__ 1
@@ -269,9 +280,24 @@
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME ""
+/* Define to the home page for this package. */
+#define PACKAGE_URL ""
+
/* Define to the version of this package. */
#define PACKAGE_VERSION ""
+/* define if the platform doesn't define PRId64 */
+/* #undef PRId64 */
+
+/* define if the platform doesn't define PRIo64 */
+/* #undef PRIo64 */
+
+/* define if the platform doesn't define PRIx64 */
+/* #undef PRIu64 */
+
+/* define if the platform doesn't define PRIu64 */
+/* #undef PRIx64 */
+
/* Define as the return type of signal handlers (`int' or `void'). */
#define RETSIGTYPE void
@@ -284,45 +310,100 @@
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
#define TIME_WITH_SYS_TIME 1
+/* define if you have ether_ntohost() and it works */
+#define USE_ETHER_NTOHOST 1
+
+/* Define if you enable support for libsmi */
+/* #undef USE_LIBSMI */
+
+/* define if should chroot when dropping privileges */
+/* #undef WITH_CHROOT */
+
+/* define if should drop privileges by default */
+/* #undef WITH_USER */
+
/* get BSD semantics on Irix */
/* #undef _BSD_SIGNALS */
-/* needed on HP-UX */
-/* #undef _HPUX_SOURCE */
-
/* define on AIX to get certain functions */
/* #undef _SUN */
+/* Define for Solaris 2.5.1 so the uint32_t typedef from <sys/synch.h>,
+ <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
+ #define below would cause a syntax error. */
+/* #undef _UINT32_T */
+
+/* Define for Solaris 2.5.1 so the uint64_t typedef from <sys/synch.h>,
+ <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
+ #define below would cause a syntax error. */
+/* #undef _UINT64_T */
+
+/* Define for Solaris 2.5.1 so the uint8_t typedef from <sys/synch.h>,
+ <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
+ #define below would cause a syntax error. */
+/* #undef _UINT8_T */
+
+/* define if your compiler allows __attribute__((format)) without a warning */
+#define __ATTRIBUTE___FORMAT_OK 1
+
/* define if your compiler allows __attribute__((format)) to be applied to
function pointers */
#define __ATTRIBUTE___FORMAT_OK_FOR_FUNCTION_POINTERS 1
+/* define if your compiler allows __attribute__((noreturn)) to be applied to
+ function pointers */
+#define __ATTRIBUTE___NORETURN_OK_FOR_FUNCTION_POINTERS 1
+
/* to handle Ultrix compilers that don't support const in prototypes */
/* #undef const */
/* Define as token for inline if inlining supported */
#define inline inline
-/* Define to `short' if int16_t not defined. */
+/* Define to the type of a signed integer type of width exactly 16 bits if
+ such a type exists and the standard includes do not define it. */
/* #undef int16_t */
-/* Define to `int' if int32_t not defined. */
+/* Define to the type of a signed integer type of width exactly 32 bits if
+ such a type exists and the standard includes do not define it. */
/* #undef int32_t */
-/* Define to `long long' if int64_t not defined. */
+/* Define to the type of a signed integer type of width exactly 64 bits if
+ such a type exists and the standard includes do not define it. */
/* #undef int64_t */
-/* Define to `signed char' if int8_t not defined. */
+/* Define to the type of a signed integer type of width exactly 8 bits if such
+ a type exists and the standard includes do not define it. */
/* #undef int8_t */
-/* Define to `unsigned short' if u_int16_t not defined. */
+/* Define to `uint16_t' if u_int16_t not defined. */
/* #undef u_int16_t */
-/* Define to `unsigned int' if u_int32_t not defined. */
+/* Define to `uint32_t' if u_int32_t not defined. */
/* #undef u_int32_t */
-/* Define to `unsigned long long' if u_int64_t not defined. */
+/* Define to `uint64_t' if u_int64_t not defined. */
/* #undef u_int64_t */
-/* Define to `unsigned char' if u_int8_t not defined. */
+/* Define to `uint8_t' if u_int8_t not defined. */
/* #undef u_int8_t */
+
+/* Define to the type of an unsigned integer type of width exactly 16 bits if
+ such a type exists and the standard includes do not define it. */
+/* #undef uint16_t */
+
+/* Define to the type of an unsigned integer type of width exactly 32 bits if
+ such a type exists and the standard includes do not define it. */
+/* #undef uint32_t */
+
+/* Define to the type of an unsigned integer type of width exactly 64 bits if
+ such a type exists and the standard includes do not define it. */
+/* #undef uint64_t */
+
+/* Define to the type of an unsigned integer type of width exactly 8 bits if
+ such a type exists and the standard includes do not define it. */
+/* #undef uint8_t */
+
+/* Define to the type of an unsigned integer type wide enough to hold a
+ pointer, if such a type exists, and if the system does not define it. */
+/* #undef uintptr_t */
diff --git a/libbsd.py b/libbsd.py
index be880210..471fb65d 100644
--- a/libbsd.py
+++ b/libbsd.py
@@ -3730,81 +3730,50 @@ def usr_sbin_tcpdump(mm):
mod.addUserSpaceHeaderFiles(
[
'contrib/tcpdump/addrtoname.h',
+ 'contrib/tcpdump/addrtostr.h',
'contrib/tcpdump/af.h',
'contrib/tcpdump/ah.h',
- 'contrib/tcpdump/aodv.h',
'contrib/tcpdump/appletalk.h',
- 'contrib/tcpdump/arcnet.h',
+ 'contrib/tcpdump/ascii_strcasecmp.h',
'contrib/tcpdump/atm.h',
- 'contrib/tcpdump/bgp.h',
- 'contrib/tcpdump/bootp.h',
'contrib/tcpdump/chdlc.h',
'contrib/tcpdump/cpack.h',
- 'contrib/tcpdump/dccp.h',
- 'contrib/tcpdump/decnet.h',
- 'contrib/tcpdump/decode_prefix.h',
- 'contrib/tcpdump/enc.h',
- 'contrib/tcpdump/esp.h',
'contrib/tcpdump/ether.h',
'contrib/tcpdump/ethertype.h',
'contrib/tcpdump/extract.h',
- 'contrib/tcpdump/fddi.h',
- 'contrib/tcpdump/forces.h',
'contrib/tcpdump/gmpls.h',
'contrib/tcpdump/gmt2local.h',
- 'contrib/tcpdump/icmp6.h',
- 'contrib/tcpdump/ieee802_11.h',
- 'contrib/tcpdump/ieee802_11_radio.h',
- 'contrib/tcpdump/igrp.h',
'contrib/tcpdump/interface.h',
- 'contrib/tcpdump/ip.h',
'contrib/tcpdump/ip6.h',
- 'contrib/tcpdump/ipfc.h',
- 'contrib/tcpdump/ipnet.h',
+ 'contrib/tcpdump/ip.h',
'contrib/tcpdump/ipproto.h',
- 'contrib/tcpdump/ipsec_doi.h',
- 'contrib/tcpdump/ipx.h',
- 'contrib/tcpdump/isakmp.h',
- 'contrib/tcpdump/l2tp.h',
'contrib/tcpdump/l2vpn.h',
- 'contrib/tcpdump/lane.h',
'contrib/tcpdump/llc.h',
'contrib/tcpdump/machdep.h',
'contrib/tcpdump/mib.h',
'contrib/tcpdump/mpls.h',
'contrib/tcpdump/nameser.h',
- 'contrib/tcpdump/netbios.h',
'contrib/tcpdump/netdissect.h',
+ 'contrib/tcpdump/netdissect-stdinc.h',
'contrib/tcpdump/nfs.h',
'contrib/tcpdump/nfsfh.h',
'contrib/tcpdump/nlpid.h',
- 'contrib/tcpdump/ntp.h',
- 'contrib/tcpdump/oakley.h',
+ 'contrib/tcpdump/openflow.h',
'contrib/tcpdump/ospf.h',
- 'contrib/tcpdump/ospf6.h',
'contrib/tcpdump/oui.h',
'contrib/tcpdump/pcap-missing.h',
- 'contrib/tcpdump/pmap_prot.h',
- 'contrib/tcpdump/ppi.h',
'contrib/tcpdump/ppp.h',
- 'contrib/tcpdump/route6d.h',
+ 'contrib/tcpdump/print.h',
'contrib/tcpdump/rpc_auth.h',
'contrib/tcpdump/rpc_msg.h',
- 'contrib/tcpdump/rx.h',
- 'contrib/tcpdump/sctpConstants.h',
- 'contrib/tcpdump/sctpHeader.h',
+ 'contrib/tcpdump/rpl.h',
'contrib/tcpdump/setsignal.h',
'contrib/tcpdump/signature.h',
'contrib/tcpdump/slcompress.h',
- 'contrib/tcpdump/slip.h',
- 'contrib/tcpdump/sll.h',
'contrib/tcpdump/smb.h',
+ 'contrib/tcpdump/strtoaddr.h',
'contrib/tcpdump/tcp.h',
- 'contrib/tcpdump/tcpdump-stdinc.h',
- 'contrib/tcpdump/telnet.h',
- 'contrib/tcpdump/tftp.h',
- 'contrib/tcpdump/timed.h',
- 'contrib/tcpdump/token.h',
+ 'contrib/tcpdump/timeval-operations.h',
'contrib/tcpdump/udp.h',
'usr.sbin/tcpdump/tcpdump/config.h',
]
@@ -3812,7 +3781,9 @@ def usr_sbin_tcpdump(mm):
mod.addUserSpaceSourceFiles(
[
'contrib/tcpdump/addrtoname.c',
+ 'contrib/tcpdump/addrtostr.c',
'contrib/tcpdump/af.c',
+ 'contrib/tcpdump/ascii_strcasecmp.c',
'contrib/tcpdump/bpf_dump.c',
'contrib/tcpdump/checksum.c',
'contrib/tcpdump/cpack.c',
@@ -3820,15 +3791,18 @@ def usr_sbin_tcpdump(mm):
'contrib/tcpdump/gmt2local.c',
'contrib/tcpdump/in_cksum.c',
'contrib/tcpdump/ipproto.c',
+ 'contrib/tcpdump/l2vpn.c',
'contrib/tcpdump/machdep.c',
+ 'contrib/tcpdump/netdissect.c',
'contrib/tcpdump/nlpid.c',
- 'contrib/tcpdump/l2vpn.c',
'contrib/tcpdump/oui.c',
'contrib/tcpdump/parsenfsfh.c',
'contrib/tcpdump/print-802_11.c',
'contrib/tcpdump/print-802_15_4.c',
'contrib/tcpdump/print-ah.c',
+ 'contrib/tcpdump/print-ahcp.c',
'contrib/tcpdump/print-aodv.c',
+ 'contrib/tcpdump/print-aoe.c',
'contrib/tcpdump/print-ap1394.c',
'contrib/tcpdump/print-arcnet.c',
'contrib/tcpdump/print-arp.c',
@@ -3841,6 +3815,8 @@ def usr_sbin_tcpdump(mm):
'contrib/tcpdump/print-bgp.c',
'contrib/tcpdump/print-bootp.c',
'contrib/tcpdump/print-bt.c',
+ 'contrib/tcpdump/print.c',
+ 'contrib/tcpdump/print-calm-fast.c',
'contrib/tcpdump/print-carp.c',
'contrib/tcpdump/print-cdp.c',
'contrib/tcpdump/print-cfm.c',
@@ -3861,17 +3837,22 @@ def usr_sbin_tcpdump(mm):
'contrib/tcpdump/print-ether.c',
'contrib/tcpdump/print-fddi.c',
'contrib/tcpdump/print-forces.c',
- 'contrib/tcpdump/print-fr.c',
'contrib/tcpdump/print-frag6.c',
+ 'contrib/tcpdump/print-fr.c',
+ 'contrib/tcpdump/print-ftp.c',
+ 'contrib/tcpdump/print-geneve.c',
+ 'contrib/tcpdump/print-geonet.c',
'contrib/tcpdump/print-gre.c',
+ 'contrib/tcpdump/print-hncp.c',
'contrib/tcpdump/print-hsrp.c',
- 'contrib/tcpdump/print-icmp.c',
+ 'contrib/tcpdump/print-http.c',
'contrib/tcpdump/print-icmp6.c',
+ 'contrib/tcpdump/print-icmp.c',
'contrib/tcpdump/print-igmp.c',
'contrib/tcpdump/print-igrp.c',
- 'contrib/tcpdump/print-ip.c',
'contrib/tcpdump/print-ip6.c',
'contrib/tcpdump/print-ip6opts.c',
+ 'contrib/tcpdump/print-ip.c',
'contrib/tcpdump/print-ipcomp.c',
'contrib/tcpdump/print-ipfc.c',
'contrib/tcpdump/print-ipnet.c',
@@ -3883,42 +3864,52 @@ def usr_sbin_tcpdump(mm):
'contrib/tcpdump/print-l2tp.c',
'contrib/tcpdump/print-lane.c',
'contrib/tcpdump/print-ldp.c',
+ 'contrib/tcpdump/print-lisp.c',
'contrib/tcpdump/print-llc.c',
'contrib/tcpdump/print-lldp.c',
'contrib/tcpdump/print-lmp.c',
+ 'contrib/tcpdump/print-loopback.c',
'contrib/tcpdump/print-lspping.c',
'contrib/tcpdump/print-lwapp.c',
'contrib/tcpdump/print-lwres.c',
+ 'contrib/tcpdump/print-m3ua.c',
+ 'contrib/tcpdump/print-medsa.c',
'contrib/tcpdump/print-mobile.c',
'contrib/tcpdump/print-mobility.c',
'contrib/tcpdump/print-mpcp.c',
'contrib/tcpdump/print-mpls.c',
+ 'contrib/tcpdump/print-mptcp.c',
'contrib/tcpdump/print-msdp.c',
'contrib/tcpdump/print-msnlb.c',
- 'contrib/tcpdump/print-netbios.c',
'contrib/tcpdump/print-nfs.c',
+ 'contrib/tcpdump/print-nsh.c',
'contrib/tcpdump/print-ntp.c',
'contrib/tcpdump/print-null.c',
'contrib/tcpdump/print-olsr.c',
- 'contrib/tcpdump/print-ospf.c',
+ 'contrib/tcpdump/print-openflow-1.0.c',
+ 'contrib/tcpdump/print-openflow.c',
'contrib/tcpdump/print-ospf6.c',
+ 'contrib/tcpdump/print-ospf.c',
'contrib/tcpdump/print-otv.c',
'contrib/tcpdump/print-pflog.c',
'contrib/tcpdump/print-pfsync.c',
'contrib/tcpdump/print-pgm.c',
'contrib/tcpdump/print-pim.c',
+ 'contrib/tcpdump/print-pktap.c',
'contrib/tcpdump/print-ppi.c',
'contrib/tcpdump/print-ppp.c',
'contrib/tcpdump/print-pppoe.c',
'contrib/tcpdump/print-pptp.c',
'contrib/tcpdump/print-radius.c',
'contrib/tcpdump/print-raw.c',
+ 'contrib/tcpdump/print-resp.c',
'contrib/tcpdump/print-rip.c',
'contrib/tcpdump/print-ripng.c',
'contrib/tcpdump/print-rpki-rtr.c',
'contrib/tcpdump/print-rrcp.c',
'contrib/tcpdump/print-rsvp.c',
'contrib/tcpdump/print-rt6.c',
+ 'contrib/tcpdump/print-rtsp.c',
'contrib/tcpdump/print-rx.c',
'contrib/tcpdump/print-sctp.c',
'contrib/tcpdump/print-sflow.c',
@@ -3927,10 +3918,10 @@ def usr_sbin_tcpdump(mm):
'contrib/tcpdump/print-sll.c',
'contrib/tcpdump/print-slow.c',
'contrib/tcpdump/print-smb.c',
+ 'contrib/tcpdump/print-smtp.c',
'contrib/tcpdump/print-snmp.c',
'contrib/tcpdump/print-stp.c',
'contrib/tcpdump/print-sunatm.c',
- #'contrib/tcpdump/print-sunrpc.c',
'contrib/tcpdump/print-symantec.c',
'contrib/tcpdump/print-syslog.c',
'contrib/tcpdump/print-tcp.c',
@@ -3947,6 +3938,7 @@ def usr_sbin_tcpdump(mm):
'contrib/tcpdump/print-vrrp.c',
'contrib/tcpdump/print-vtp.c',
'contrib/tcpdump/print-vxlan.c',
+ 'contrib/tcpdump/print-vxlan-gpe.c',
'contrib/tcpdump/print-wb.c',
'contrib/tcpdump/print-zephyr.c',
'contrib/tcpdump/print-zeromq.c',
@@ -3954,7 +3946,7 @@ def usr_sbin_tcpdump(mm):
'contrib/tcpdump/signature.c',
'contrib/tcpdump/smbutil.c',
'contrib/tcpdump/tcpdump.c',
- 'contrib/tcpdump/util.c',
+ 'contrib/tcpdump/util-print.c',
],
mm.generator['source'](['-D__FreeBSD__=1',
'-DINET6',
diff --git a/libbsd_waf.py b/libbsd_waf.py
index 4b01268a..c4669301 100644
--- a/libbsd_waf.py
+++ b/libbsd_waf.py
@@ -1404,7 +1404,9 @@ def build(bld):
libbsd_use += ["objs07"]
objs08_source = ['freebsd/contrib/tcpdump/addrtoname.c',
+ 'freebsd/contrib/tcpdump/addrtostr.c',
'freebsd/contrib/tcpdump/af.c',
+ 'freebsd/contrib/tcpdump/ascii_strcasecmp.c',
'freebsd/contrib/tcpdump/bpf_dump.c',
'freebsd/contrib/tcpdump/checksum.c',
'freebsd/contrib/tcpdump/cpack.c',
@@ -1414,13 +1416,16 @@ def build(bld):
'freebsd/contrib/tcpdump/ipproto.c',
'freebsd/contrib/tcpdump/l2vpn.c',
'freebsd/contrib/tcpdump/machdep.c',
+ 'freebsd/contrib/tcpdump/netdissect.c',
'freebsd/contrib/tcpdump/nlpid.c',
'freebsd/contrib/tcpdump/oui.c',
'freebsd/contrib/tcpdump/parsenfsfh.c',
'freebsd/contrib/tcpdump/print-802_11.c',
'freebsd/contrib/tcpdump/print-802_15_4.c',
'freebsd/contrib/tcpdump/print-ah.c',
+ 'freebsd/contrib/tcpdump/print-ahcp.c',
'freebsd/contrib/tcpdump/print-aodv.c',
+ 'freebsd/contrib/tcpdump/print-aoe.c',
'freebsd/contrib/tcpdump/print-ap1394.c',
'freebsd/contrib/tcpdump/print-arcnet.c',
'freebsd/contrib/tcpdump/print-arp.c',
@@ -1433,6 +1438,7 @@ def build(bld):
'freebsd/contrib/tcpdump/print-bgp.c',
'freebsd/contrib/tcpdump/print-bootp.c',
'freebsd/contrib/tcpdump/print-bt.c',
+ 'freebsd/contrib/tcpdump/print-calm-fast.c',
'freebsd/contrib/tcpdump/print-carp.c',
'freebsd/contrib/tcpdump/print-cdp.c',
'freebsd/contrib/tcpdump/print-cfm.c',
@@ -1455,8 +1461,13 @@ def build(bld):
'freebsd/contrib/tcpdump/print-forces.c',
'freebsd/contrib/tcpdump/print-fr.c',
'freebsd/contrib/tcpdump/print-frag6.c',
+ 'freebsd/contrib/tcpdump/print-ftp.c',
+ 'freebsd/contrib/tcpdump/print-geneve.c',
+ 'freebsd/contrib/tcpdump/print-geonet.c',
'freebsd/contrib/tcpdump/print-gre.c',
+ 'freebsd/contrib/tcpdump/print-hncp.c',
'freebsd/contrib/tcpdump/print-hsrp.c',
+ 'freebsd/contrib/tcpdump/print-http.c',
'freebsd/contrib/tcpdump/print-icmp.c',
'freebsd/contrib/tcpdump/print-icmp6.c',
'freebsd/contrib/tcpdump/print-igmp.c',
@@ -1475,23 +1486,30 @@ def build(bld):
'freebsd/contrib/tcpdump/print-l2tp.c',
'freebsd/contrib/tcpdump/print-lane.c',
'freebsd/contrib/tcpdump/print-ldp.c',
+ 'freebsd/contrib/tcpdump/print-lisp.c',
'freebsd/contrib/tcpdump/print-llc.c',
'freebsd/contrib/tcpdump/print-lldp.c',
'freebsd/contrib/tcpdump/print-lmp.c',
+ 'freebsd/contrib/tcpdump/print-loopback.c',
'freebsd/contrib/tcpdump/print-lspping.c',
'freebsd/contrib/tcpdump/print-lwapp.c',
'freebsd/contrib/tcpdump/print-lwres.c',
+ 'freebsd/contrib/tcpdump/print-m3ua.c',
+ 'freebsd/contrib/tcpdump/print-medsa.c',
'freebsd/contrib/tcpdump/print-mobile.c',
'freebsd/contrib/tcpdump/print-mobility.c',
'freebsd/contrib/tcpdump/print-mpcp.c',
'freebsd/contrib/tcpdump/print-mpls.c',
+ 'freebsd/contrib/tcpdump/print-mptcp.c',
'freebsd/contrib/tcpdump/print-msdp.c',
'freebsd/contrib/tcpdump/print-msnlb.c',
- 'freebsd/contrib/tcpdump/print-netbios.c',
'freebsd/contrib/tcpdump/print-nfs.c',
+ 'freebsd/contrib/tcpdump/print-nsh.c',
'freebsd/contrib/tcpdump/print-ntp.c',
'freebsd/contrib/tcpdump/print-null.c',
'freebsd/contrib/tcpdump/print-olsr.c',
+ 'freebsd/contrib/tcpdump/print-openflow-1.0.c',
+ 'freebsd/contrib/tcpdump/print-openflow.c',
'freebsd/contrib/tcpdump/print-ospf.c',
'freebsd/contrib/tcpdump/print-ospf6.c',
'freebsd/contrib/tcpdump/print-otv.c',
@@ -1499,18 +1517,21 @@ def build(bld):
'freebsd/contrib/tcpdump/print-pfsync.c',
'freebsd/contrib/tcpdump/print-pgm.c',
'freebsd/contrib/tcpdump/print-pim.c',
+ 'freebsd/contrib/tcpdump/print-pktap.c',
'freebsd/contrib/tcpdump/print-ppi.c',
'freebsd/contrib/tcpdump/print-ppp.c',
'freebsd/contrib/tcpdump/print-pppoe.c',
'freebsd/contrib/tcpdump/print-pptp.c',
'freebsd/contrib/tcpdump/print-radius.c',
'freebsd/contrib/tcpdump/print-raw.c',
+ 'freebsd/contrib/tcpdump/print-resp.c',
'freebsd/contrib/tcpdump/print-rip.c',
'freebsd/contrib/tcpdump/print-ripng.c',
'freebsd/contrib/tcpdump/print-rpki-rtr.c',
'freebsd/contrib/tcpdump/print-rrcp.c',
'freebsd/contrib/tcpdump/print-rsvp.c',
'freebsd/contrib/tcpdump/print-rt6.c',
+ 'freebsd/contrib/tcpdump/print-rtsp.c',
'freebsd/contrib/tcpdump/print-rx.c',
'freebsd/contrib/tcpdump/print-sctp.c',
'freebsd/contrib/tcpdump/print-sflow.c',
@@ -1519,6 +1540,7 @@ def build(bld):
'freebsd/contrib/tcpdump/print-sll.c',
'freebsd/contrib/tcpdump/print-slow.c',
'freebsd/contrib/tcpdump/print-smb.c',
+ 'freebsd/contrib/tcpdump/print-smtp.c',
'freebsd/contrib/tcpdump/print-snmp.c',
'freebsd/contrib/tcpdump/print-stp.c',
'freebsd/contrib/tcpdump/print-sunatm.c',
@@ -1537,15 +1559,17 @@ def build(bld):
'freebsd/contrib/tcpdump/print-vqp.c',
'freebsd/contrib/tcpdump/print-vrrp.c',
'freebsd/contrib/tcpdump/print-vtp.c',
+ 'freebsd/contrib/tcpdump/print-vxlan-gpe.c',
'freebsd/contrib/tcpdump/print-vxlan.c',
'freebsd/contrib/tcpdump/print-wb.c',
'freebsd/contrib/tcpdump/print-zephyr.c',
'freebsd/contrib/tcpdump/print-zeromq.c',
+ 'freebsd/contrib/tcpdump/print.c',
'freebsd/contrib/tcpdump/setsignal.c',
'freebsd/contrib/tcpdump/signature.c',
'freebsd/contrib/tcpdump/smbutil.c',
'freebsd/contrib/tcpdump/tcpdump.c',
- 'freebsd/contrib/tcpdump/util.c']
+ 'freebsd/contrib/tcpdump/util-print.c']
bld.objects(target = "objs08",
features = "c",
cflags = cflags,