summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRenato Botelho <renato@netgate.com>2017-02-23 06:37:07 -0300
committerRenato Botelho <renato@netgate.com>2017-02-23 06:37:07 -0300
commit4ef888db25896b2295f521c736ef04aa2e5e64ec (patch)
tree3fcc00dda536bd32ae85bc09f21be4081d32bad5
parent272ffd7c3e4e5e27910eb918e2e36556f2a8ec3a (diff)
parentaf015c5bcac0e333adeec07eff0698bad3b91e95 (diff)
downloadFreeBSD-src-4ef888db25896b2295f521c736ef04aa2e5e64ec.zip
FreeBSD-src-4ef888db25896b2295f521c736ef04aa2e5e64ec.tar.gz
Merge remote-tracking branch 'origin/stable/11' into devel-11
-rw-r--r--ObsoleteFiles.inc7
-rw-r--r--bin/ls/print.c8
-rw-r--r--bin/pwd/pwd.12
-rw-r--r--bin/sh/sh.12
-rw-r--r--contrib/compiler-rt/lib/asan/asan_malloc_linux.cc18
-rw-r--r--contrib/compiler-rt/lib/asan/asan_malloc_win.cc5
-rw-r--r--contrib/compiler-rt/lib/lsan/lsan_interceptors.cc54
-rw-r--r--contrib/compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h6
-rw-r--r--contrib/elftoolchain/libelftc/elftc_bfd_find_target.34
-rw-r--r--contrib/elftoolchain/libelftc/elftc_reloc_type_str.c31
-rw-r--r--contrib/elftoolchain/libelftc/libelftc_bfdtarget.c32
-rw-r--r--contrib/libarchive/NEWS7
-rw-r--r--contrib/libarchive/cpio/cpio.c1
-rw-r--r--contrib/libarchive/libarchive/archive_acl.c1619
-rw-r--r--contrib/libarchive/libarchive/archive_acl_private.h22
-rw-r--r--contrib/libarchive/libarchive/archive_entry.c114
-rw-r--r--contrib/libarchive/libarchive/archive_entry.h68
-rw-r--r--contrib/libarchive/libarchive/archive_entry_acl.3324
-rw-r--r--contrib/libarchive/libarchive/archive_entry_locale.h10
-rw-r--r--contrib/libarchive/libarchive/archive_entry_strmode.c2
-rw-r--r--contrib/libarchive/libarchive/archive_match.c12
-rw-r--r--contrib/libarchive/libarchive/archive_platform.h19
-rw-r--r--contrib/libarchive/libarchive/archive_random.c2
-rw-r--r--contrib/libarchive/libarchive/archive_rb.c2
-rw-r--r--contrib/libarchive/libarchive/archive_read_disk.36
-rw-r--r--contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c738
-rw-r--r--contrib/libarchive/libarchive/archive_read_disk_posix.c6
-rw-r--r--contrib/libarchive/libarchive/archive_read_open_filename.c20
-rw-r--r--contrib/libarchive/libarchive/archive_read_support_filter_lz4.c11
-rw-r--r--contrib/libarchive/libarchive/archive_read_support_filter_lzop.c2
-rw-r--r--contrib/libarchive/libarchive/archive_read_support_filter_program.c2
-rw-r--r--contrib/libarchive/libarchive/archive_read_support_format_7zip.c10
-rw-r--r--contrib/libarchive/libarchive/archive_read_support_format_cab.c2
-rw-r--r--contrib/libarchive/libarchive/archive_read_support_format_cpio.c11
-rw-r--r--contrib/libarchive/libarchive/archive_read_support_format_iso9660.c40
-rw-r--r--contrib/libarchive/libarchive/archive_read_support_format_lha.c5
-rw-r--r--contrib/libarchive/libarchive/archive_read_support_format_mtree.c15
-rw-r--r--contrib/libarchive/libarchive/archive_read_support_format_rar.c2
-rw-r--r--contrib/libarchive/libarchive/archive_read_support_format_tar.c162
-rw-r--r--contrib/libarchive/libarchive/archive_read_support_format_warc.c230
-rw-r--r--contrib/libarchive/libarchive/archive_read_support_format_xar.c18
-rw-r--r--contrib/libarchive/libarchive/archive_read_support_format_zip.c80
-rw-r--r--contrib/libarchive/libarchive/archive_string.c26
-rw-r--r--contrib/libarchive/libarchive/archive_string.h4
-rw-r--r--contrib/libarchive/libarchive/archive_string_composition.h2
-rw-r--r--contrib/libarchive/libarchive/archive_write.c2
-rw-r--r--contrib/libarchive/libarchive/archive_write_add_filter_program.c1
-rw-r--r--contrib/libarchive/libarchive/archive_write_add_filter_xz.c2
-rw-r--r--contrib/libarchive/libarchive/archive_write_disk_acl.c456
-rw-r--r--contrib/libarchive/libarchive/archive_write_disk_posix.c62
-rw-r--r--contrib/libarchive/libarchive/archive_write_open.311
-rw-r--r--contrib/libarchive/libarchive/archive_write_set_format_7zip.c2
-rw-r--r--contrib/libarchive/libarchive/archive_write_set_format_gnutar.c8
-rw-r--r--contrib/libarchive/libarchive/archive_write_set_format_iso9660.c34
-rw-r--r--contrib/libarchive/libarchive/archive_write_set_format_pax.c178
-rw-r--r--contrib/libarchive/libarchive/archive_write_set_format_warc.c2
-rw-r--r--contrib/libarchive/libarchive/archive_write_set_format_xar.c15
-rw-r--r--contrib/libarchive/libarchive/archive_write_set_format_zip.c10
-rw-r--r--contrib/libarchive/libarchive/libarchive-formats.54
-rw-r--r--contrib/libarchive/libarchive/tar.511
-rw-r--r--contrib/libarchive/libarchive/test/main.c134
-rw-r--r--contrib/libarchive/libarchive/test/test.h43
-rw-r--r--contrib/libarchive/libarchive/test/test_acl_nfs4.c126
-rw-r--r--contrib/libarchive/libarchive/test/test_acl_pax.c364
-rw-r--r--contrib/libarchive/libarchive/test/test_acl_pax_nfs4.tar.uu129
-rw-r--r--contrib/libarchive/libarchive/test/test_acl_pax_posix1e.tar.uu (renamed from contrib/libarchive/libarchive/test/test_acl_pax.tar.uu)2
-rw-r--r--contrib/libarchive/libarchive/test/test_acl_platform_nfs4.c (renamed from contrib/libarchive/libarchive/test/test_acl_freebsd_nfs4.c)474
-rw-r--r--contrib/libarchive/libarchive/test/test_acl_platform_posix1e.c (renamed from contrib/libarchive/libarchive/test/test_acl_freebsd_posix1e.c)431
-rw-r--r--contrib/libarchive/libarchive/test/test_acl_posix1e.c144
-rw-r--r--contrib/libarchive/libarchive/test/test_acl_text.c473
-rw-r--r--contrib/libarchive/libarchive/test/test_archive_read_add_passphrase.c2
-rw-r--r--contrib/libarchive/libarchive/test/test_archive_string.c24
-rw-r--r--contrib/libarchive/libarchive/test/test_compat_gtar.c2
-rw-r--r--contrib/libarchive/libarchive/test/test_compat_solaris_tar_acl.c297
-rw-r--r--contrib/libarchive/libarchive/test/test_compat_solaris_tar_acl.tar.uu220
-rw-r--r--contrib/libarchive/libarchive/test/test_compat_star_acl.c321
-rw-r--r--contrib/libarchive/libarchive/test/test_compat_star_acl_nfs4.tar.uu231
-rw-r--r--contrib/libarchive/libarchive/test/test_compat_star_acl_posix1e.c215
-rw-r--r--contrib/libarchive/libarchive/test/test_compat_uudecode.c2
-rw-r--r--contrib/libarchive/libarchive/test/test_fuzz.c4
-rw-r--r--contrib/libarchive/libarchive/test/test_read_disk_directory_traversals.c12
-rw-r--r--contrib/libarchive/libarchive/test/test_read_filter_lzop.c9
-rw-r--r--contrib/libarchive/libarchive/test/test_read_filter_lzop_multiple_parts.c8
-rw-r--r--contrib/libarchive/libarchive/test/test_read_format_7zip.c2
-rw-r--r--contrib/libarchive/libarchive/test/test_read_format_cpio_afio.c2
-rw-r--r--contrib/libarchive/libarchive/test/test_read_format_isorr_bz2.c2
-rw-r--r--contrib/libarchive/libarchive/test/test_read_format_zip.c5
-rw-r--r--contrib/libarchive/libarchive/test/test_read_format_zip_comment_stored.c2
-rw-r--r--contrib/libarchive/libarchive/test/test_read_format_zip_filename.c2
-rw-r--r--contrib/libarchive/libarchive/test/test_read_format_zip_mac_metadata.c2
-rw-r--r--contrib/libarchive/libarchive/test/test_read_format_zip_malformed.c1
-rw-r--r--contrib/libarchive/libarchive/test/test_read_format_zip_nested.c2
-rw-r--r--contrib/libarchive/libarchive/test/test_read_format_zip_padded.c2
-rw-r--r--contrib/libarchive/libarchive/test/test_read_format_zip_sfx.c2
-rw-r--r--contrib/libarchive/libarchive/test/test_read_format_zip_traditional_encryption_data.c4
-rw-r--r--contrib/libarchive/libarchive/test/test_read_format_zip_winzip_aes.c2
-rw-r--r--contrib/libarchive/libarchive/test/test_read_format_zip_winzip_aes_large.c2
-rw-r--r--contrib/libarchive/libarchive/test/test_read_pax_schily_xattr.c70
-rw-r--r--contrib/libarchive/libarchive/test/test_read_pax_schily_xattr.tar.uu231
-rw-r--r--contrib/libarchive/libarchive/test/test_sparse_basic.c2
-rw-r--r--contrib/libarchive/libarchive/test/test_write_disk_secure746.c3
-rw-r--r--contrib/libarchive/libarchive/test/test_write_filter_lz4.c2
-rw-r--r--contrib/libarchive/libarchive/test/test_write_filter_lzop.c6
-rw-r--r--contrib/libarchive/libarchive/test/test_write_format_iso9660.c2
-rw-r--r--contrib/libarchive/libarchive/test/test_write_format_iso9660_zisofs.c2
-rw-r--r--contrib/libarchive/libarchive/test/test_write_format_zip_large.c1
-rw-r--r--contrib/libarchive/libarchive/test/test_write_format_zip_zip64.c2
-rw-r--r--contrib/libarchive/libarchive/xxhash.c5
-rw-r--r--contrib/libarchive/tar/test/test_option_uid_uname.c8
-rw-r--r--contrib/libarchive/tar/util.c1
-rw-r--r--contrib/llvm/tools/lld/ELF/EhFrame.cpp5
-rwxr-xr-xcontrib/netbsd-tests/crypto/libcrypto/t_libcrypto.sh4
-rwxr-xr-xcontrib/netbsd-tests/crypto/libcrypto/t_pubkey.sh8
-rw-r--r--contrib/netbsd-tests/dev/audio/h_pad.c10
-rw-r--r--contrib/netbsd-tests/dev/audio/t_pad_output.bz2.uue2069
-rw-r--r--contrib/netbsd-tests/dev/cgd/t_cgd_3des.c913
-rw-r--r--contrib/netbsd-tests/dev/cgd/t_cgd_aes.c3606
-rw-r--r--contrib/netbsd-tests/dev/cgd/t_cgd_blowfish.c2341
-rwxr-xr-xcontrib/netbsd-tests/fs/ffs/ffs_common.sh4
-rw-r--r--contrib/netbsd-tests/fs/fifofs/t_fifo.c3
-rwxr-xr-xcontrib/netbsd-tests/fs/psshfs/t_psshfs.sh23
-rw-r--r--contrib/netbsd-tests/fs/puffs/t_basic.c6
-rw-r--r--contrib/netbsd-tests/fs/vfs/t_vnops.c100
-rw-r--r--contrib/netbsd-tests/h_macros.h4
-rw-r--r--contrib/netbsd-tests/kernel/msg.h136
-rw-r--r--contrib/netbsd-tests/kernel/t_mqueue.c3
-rw-r--r--contrib/netbsd-tests/kernel/t_ptrace.c208
-rw-r--r--contrib/netbsd-tests/kernel/t_ptrace_wait.c5082
-rw-r--r--contrib/netbsd-tests/kernel/t_ptrace_wait.h431
-rw-r--r--contrib/netbsd-tests/kernel/t_ptrace_wait3.c30
-rw-r--r--contrib/netbsd-tests/kernel/t_ptrace_wait4.c30
-rw-r--r--contrib/netbsd-tests/kernel/t_ptrace_wait6.c30
-rw-r--r--contrib/netbsd-tests/kernel/t_ptrace_waitid.c30
-rw-r--r--contrib/netbsd-tests/kernel/t_ptrace_waitpid.c30
-rw-r--r--contrib/netbsd-tests/lib/libc/arch/sparc64/exec_prot_support.c7
-rw-r--r--contrib/netbsd-tests/lib/libc/arch/sparc64/return_one.S11
-rw-r--r--contrib/netbsd-tests/lib/libc/db/h_db.c77
-rwxr-xr-xcontrib/netbsd-tests/lib/libc/db/t_db.sh313
-rw-r--r--contrib/netbsd-tests/lib/libc/gen/t_dir.c36
-rw-r--r--contrib/netbsd-tests/lib/libc/gen/t_floatunditf.c5
-rw-r--r--contrib/netbsd-tests/lib/libc/gen/t_fnmatch.c5
-rw-r--r--contrib/netbsd-tests/lib/libc/rpc/t_rpc.c24
-rw-r--r--contrib/netbsd-tests/lib/libc/string/t_memcpy.c6
-rw-r--r--contrib/netbsd-tests/lib/libc/string/t_memmem.c2
-rw-r--r--contrib/netbsd-tests/lib/libc/sync/cpp_atomic_ops_linkable.cc16
-rw-r--r--contrib/netbsd-tests/lib/libc/sys/t_clock_nanosleep.c63
-rw-r--r--contrib/netbsd-tests/lib/libc/sys/t_getrusage.c4
-rw-r--r--contrib/netbsd-tests/lib/libc/sys/t_wait_noproc.c345
-rw-r--r--contrib/netbsd-tests/lib/libc/sys/t_wait_noproc_wnohang.c30
-rw-r--r--contrib/netbsd-tests/lib/libm/t_casinh.c81
-rw-r--r--contrib/netbsd-tests/lib/libm/t_fe_round.c124
-rw-r--r--contrib/netbsd-tests/lib/libm/t_ilogb.c130
-rw-r--r--contrib/netbsd-tests/lib/libm/t_ldexp.c12
-rw-r--r--contrib/netbsd-tests/lib/libm/t_precision.c8
-rw-r--r--contrib/netbsd-tests/lib/libpthread/h_common.h6
-rw-r--r--contrib/netbsd-tests/lib/libpthread/t_mutex.c198
-rw-r--r--contrib/netbsd-tests/lib/libpthread/t_timedmutex.c30
-rw-r--r--contrib/netbsd-tests/lib/librumpclient/h_execthr.c68
-rwxr-xr-xcontrib/netbsd-tests/lib/librumphijack/t_tcpip.sh7
-rw-r--r--contrib/netbsd-tests/lib/libusbhid/t_usbhid.c7
-rwxr-xr-xcontrib/netbsd-tests/net/arp/t_arp.sh127
-rwxr-xr-xcontrib/netbsd-tests/net/arp/t_dad.sh100
-rwxr-xr-xcontrib/netbsd-tests/net/icmp/t_icmp6_redirect.sh65
-rwxr-xr-xcontrib/netbsd-tests/net/icmp/t_icmp_redirect.sh100
-rw-r--r--contrib/netbsd-tests/net/if/t_compat.c4
-rwxr-xr-xcontrib/netbsd-tests/net/if/t_ifconfig.sh22
-rwxr-xr-xcontrib/netbsd-tests/net/if_bridge/t_bridge.sh103
-rwxr-xr-xcontrib/netbsd-tests/net/if_gif/t_gif.sh35
-rwxr-xr-xcontrib/netbsd-tests/net/if_pppoe/t_pppoe.sh265
-rwxr-xr-xcontrib/netbsd-tests/net/if_tap/t_tap.sh50
-rwxr-xr-xcontrib/netbsd-tests/net/mcast/t_mcast.sh18
-rwxr-xr-xcontrib/netbsd-tests/net/ndp/t_dad.sh156
-rwxr-xr-xcontrib/netbsd-tests/net/ndp/t_ndp.sh100
-rwxr-xr-xcontrib/netbsd-tests/net/ndp/t_ra.sh607
-rwxr-xr-xcontrib/netbsd-tests/net/net/t_forwarding.sh125
-rwxr-xr-xcontrib/netbsd-tests/net/net/t_ipaddress.sh129
-rwxr-xr-xcontrib/netbsd-tests/net/net/t_ipv6_lifetime.sh48
-rwxr-xr-xcontrib/netbsd-tests/net/net/t_ipv6address.sh103
-rwxr-xr-xcontrib/netbsd-tests/net/net/t_mtudisc.sh192
-rwxr-xr-xcontrib/netbsd-tests/net/net/t_mtudisc6.sh179
-rwxr-xr-xcontrib/netbsd-tests/net/net/t_ping6_opts.sh380
-rwxr-xr-xcontrib/netbsd-tests/net/net_common.sh314
-rwxr-xr-xcontrib/netbsd-tests/net/route/t_change.sh4
-rwxr-xr-xcontrib/netbsd-tests/net/route/t_flags.sh116
-rwxr-xr-xcontrib/netbsd-tests/net/route/t_flags6.sh88
-rwxr-xr-xcontrib/netbsd-tests/net/route/t_route.sh78
-rw-r--r--contrib/netbsd-tests/rump/modautoload/t_modautoload.c3
-rw-r--r--contrib/netbsd-tests/rump/rumpkern/t_lwproc.c3
-rw-r--r--contrib/netbsd-tests/sys/net/t_print.c14
-rwxr-xr-xcontrib/netbsd-tests/usr.bin/config/t_config.sh62
-rwxr-xr-xcontrib/netbsd-tests/usr.bin/netpgpverify/t_netpgpverify.sh536
-rw-r--r--contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_anon_union.c16
-rw-r--r--contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_union_cast.c18
-rw-r--r--contrib/openresolv/Makefile15
-rw-r--r--contrib/openresolv/configure23
-rw-r--r--contrib/openresolv/libc.in2
-rw-r--r--contrib/openresolv/pdns_recursor.in10
-rw-r--r--contrib/openresolv/resolvconf.8.in17
-rw-r--r--contrib/openresolv/resolvconf.conf.5.in12
-rw-r--r--contrib/openresolv/resolvconf.in65
-rw-r--r--contrib/tcpdump/.cvsignore12
-rw-r--r--contrib/tcpdump/CHANGES190
-rw-r--r--contrib/tcpdump/CONTRIBUTING103
-rw-r--r--contrib/tcpdump/CREDITS7
-rw-r--r--contrib/tcpdump/INSTALL.txt103
-rw-r--r--contrib/tcpdump/Makefile.in68
-rw-r--r--contrib/tcpdump/PLATFORMS9
l---------contrib/tcpdump/README1
-rw-r--r--contrib/tcpdump/VERSION2
-rw-r--r--contrib/tcpdump/addrtoname.c246
-rw-r--r--contrib/tcpdump/addrtoname.h32
-rw-r--r--contrib/tcpdump/addrtostr.c (renamed from contrib/tcpdump/missing/inet_ntop.c)96
-rw-r--r--contrib/tcpdump/addrtostr.h (renamed from contrib/tcpdump/missing/inet_pton.c)17
-rw-r--r--contrib/tcpdump/af.c5
-rw-r--r--contrib/tcpdump/af.h6
-rw-r--r--contrib/tcpdump/ascii_strcasecmp.c105
-rw-r--r--contrib/tcpdump/ascii_strcasecmp.h33
-rw-r--r--contrib/tcpdump/atmuni31.h85
-rw-r--r--contrib/tcpdump/bpf_dump.c5
-rw-r--r--contrib/tcpdump/checksum.c13
-rw-r--r--contrib/tcpdump/config.h.in39
-rwxr-xr-xcontrib/tcpdump/configure1169
-rw-r--r--contrib/tcpdump/configure.in419
-rw-r--r--contrib/tcpdump/cpack.c19
-rw-r--r--contrib/tcpdump/cpack.h10
-rw-r--r--contrib/tcpdump/ether.h11
-rw-r--r--contrib/tcpdump/ethertype.h4
-rw-r--r--contrib/tcpdump/extract.h31
-rw-r--r--contrib/tcpdump/getopt_long.h2
-rw-r--r--contrib/tcpdump/gmpls.c5
-rw-r--r--contrib/tcpdump/gmt2local.c3
-rw-r--r--contrib/tcpdump/in_cksum.c13
-rw-r--r--contrib/tcpdump/interface.h150
-rw-r--r--contrib/tcpdump/ip.h44
-rw-r--r--contrib/tcpdump/ip6.h7
-rw-r--r--contrib/tcpdump/ipproto.c5
-rw-r--r--contrib/tcpdump/ipproto.h3
-rw-r--r--contrib/tcpdump/l2vpn.c101
-rw-r--r--contrib/tcpdump/l2vpn.h1
-rw-r--r--contrib/tcpdump/lbl/os-solaris2.h1
-rw-r--r--contrib/tcpdump/lbl/os-sunos4.h2
-rw-r--r--contrib/tcpdump/lbl/os-ultrix4.h1
-rw-r--r--contrib/tcpdump/machdep.c2
-rw-r--r--contrib/tcpdump/machdep.h4
-rw-r--r--contrib/tcpdump/mib.h2
-rw-r--r--contrib/tcpdump/missing/addrinfo.h117
-rw-r--r--contrib/tcpdump/missing/datalinks.c2
-rw-r--r--contrib/tcpdump/missing/dlnames.c5
-rw-r--r--contrib/tcpdump/missing/getnameinfo.c276
-rw-r--r--contrib/tcpdump/missing/inet_aton.c53
-rw-r--r--contrib/tcpdump/missing/snprintf.c2
-rw-r--r--contrib/tcpdump/missing/strdup.c2
-rw-r--r--contrib/tcpdump/missing/strlcat.c6
-rw-r--r--contrib/tcpdump/missing/strlcpy.c6
-rw-r--r--contrib/tcpdump/missing/strsep.c6
-rw-r--r--contrib/tcpdump/nameser.h14
-rw-r--r--contrib/tcpdump/netdissect-stdinc.h (renamed from contrib/tcpdump/tcpdump-stdinc.h)88
-rw-r--r--contrib/tcpdump/netdissect.c146
-rw-r--r--contrib/tcpdump/netdissect.h599
-rw-r--r--contrib/tcpdump/nfs.h1
-rw-r--r--contrib/tcpdump/nfsfh.h4
-rw-r--r--contrib/tcpdump/nlpid.c5
-rw-r--r--contrib/tcpdump/oui.c6
-rw-r--r--contrib/tcpdump/oui.h47
-rw-r--r--contrib/tcpdump/parsenfsfh.c243
-rw-r--r--contrib/tcpdump/pcap-missing.h15
-rw-r--r--contrib/tcpdump/ppp.h2
-rw-r--r--contrib/tcpdump/print-802_11.c1773
-rw-r--r--contrib/tcpdump/print-802_15_4.c13
-rw-r--r--contrib/tcpdump/print-ah.c20
-rw-r--r--contrib/tcpdump/print-ahcp.c84
-rw-r--r--contrib/tcpdump/print-aodv.c69
-rw-r--r--contrib/tcpdump/print-aoe.c56
-rw-r--r--contrib/tcpdump/print-ap1394.c30
-rw-r--r--contrib/tcpdump/print-arcnet.c7
-rw-r--r--contrib/tcpdump/print-arp.c25
-rw-r--r--contrib/tcpdump/print-ascii.c7
-rw-r--r--contrib/tcpdump/print-atalk.c63
-rw-r--r--contrib/tcpdump/print-atm.c152
-rw-r--r--contrib/tcpdump/print-babel.c187
-rw-r--r--contrib/tcpdump/print-beep.c9
-rw-r--r--contrib/tcpdump/print-bfd.c186
-rw-r--r--contrib/tcpdump/print-bgp.c499
-rw-r--r--contrib/tcpdump/print-bootp.c31
-rw-r--r--contrib/tcpdump/print-bt.c7
-rw-r--r--contrib/tcpdump/print-calm-fast.c29
-rw-r--r--contrib/tcpdump/print-carp.c7
-rw-r--r--contrib/tcpdump/print-cdp.c21
-rw-r--r--contrib/tcpdump/print-cfm.c340
-rw-r--r--contrib/tcpdump/print-chdlc.c11
-rw-r--r--contrib/tcpdump/print-cip.c47
-rw-r--r--contrib/tcpdump/print-cnfp.c7
-rw-r--r--contrib/tcpdump/print-dccp.c48
-rw-r--r--contrib/tcpdump/print-decnet.c134
-rw-r--r--contrib/tcpdump/print-dhcp6.c126
-rw-r--r--contrib/tcpdump/print-domain.c26
-rw-r--r--contrib/tcpdump/print-dtp.c36
-rw-r--r--contrib/tcpdump/print-dvmrp.c9
-rw-r--r--contrib/tcpdump/print-eap.c12
-rw-r--r--contrib/tcpdump/print-egp.c36
-rw-r--r--contrib/tcpdump/print-eigrp.c7
-rw-r--r--contrib/tcpdump/print-enc.c9
-rw-r--r--contrib/tcpdump/print-esp.c152
-rw-r--r--contrib/tcpdump/print-ether.c180
-rw-r--r--contrib/tcpdump/print-fddi.c62
-rw-r--r--contrib/tcpdump/print-forces.c126
-rw-r--r--contrib/tcpdump/print-fr.c447
-rw-r--r--contrib/tcpdump/print-frag6.c10
-rw-r--r--contrib/tcpdump/print-ftp.c7
-rw-r--r--contrib/tcpdump/print-geneve.c48
-rw-r--r--contrib/tcpdump/print-geonet.c29
-rw-r--r--contrib/tcpdump/print-gre.c102
-rw-r--r--contrib/tcpdump/print-hncp.c855
-rw-r--r--contrib/tcpdump/print-hsrp.c13
-rw-r--r--contrib/tcpdump/print-http.c9
-rw-r--r--contrib/tcpdump/print-icmp.c43
-rw-r--r--contrib/tcpdump/print-icmp6.c203
-rw-r--r--contrib/tcpdump/print-igmp.c15
-rw-r--r--contrib/tcpdump/print-igrp.c25
-rw-r--r--contrib/tcpdump/print-ip.c138
-rw-r--r--contrib/tcpdump/print-ip6.c189
-rw-r--r--contrib/tcpdump/print-ip6opts.c13
-rw-r--r--contrib/tcpdump/print-ipcomp.c60
-rw-r--r--contrib/tcpdump/print-ipfc.c58
-rw-r--r--contrib/tcpdump/print-ipnet.c13
-rw-r--r--contrib/tcpdump/print-ipx.c28
-rw-r--r--contrib/tcpdump/print-isakmp.c464
-rw-r--r--contrib/tcpdump/print-isoclns.c510
-rw-r--r--contrib/tcpdump/print-juniper.c39
-rw-r--r--contrib/tcpdump/print-krb.c11
-rw-r--r--contrib/tcpdump/print-l2tp.c73
-rw-r--r--contrib/tcpdump/print-lane.c11
-rw-r--r--contrib/tcpdump/print-ldp.c27
-rw-r--r--contrib/tcpdump/print-lisp.c449
-rw-r--r--contrib/tcpdump/print-llc.c246
-rw-r--r--contrib/tcpdump/print-lldp.c58
-rw-r--r--contrib/tcpdump/print-lmp.c23
-rw-r--r--contrib/tcpdump/print-loopback.c36
-rw-r--r--contrib/tcpdump/print-lspping.c641
-rw-r--r--contrib/tcpdump/print-lwapp.c11
-rw-r--r--contrib/tcpdump/print-lwres.c41
-rw-r--r--contrib/tcpdump/print-m3ua.c32
-rw-r--r--contrib/tcpdump/print-medsa.c196
-rw-r--r--contrib/tcpdump/print-mobile.c11
-rw-r--r--contrib/tcpdump/print-mobility.c62
-rw-r--r--contrib/tcpdump/print-mpcp.c9
-rw-r--r--contrib/tcpdump/print-mpls.c27
-rw-r--r--contrib/tcpdump/print-mptcp.c31
-rw-r--r--contrib/tcpdump/print-msdp.c7
-rw-r--r--contrib/tcpdump/print-msnlb.c9
-rw-r--r--contrib/tcpdump/print-nflog.c13
-rw-r--r--contrib/tcpdump/print-nfs.c136
-rw-r--r--contrib/tcpdump/print-nsh.c185
-rw-r--r--contrib/tcpdump/print-ntp.c32
-rw-r--r--contrib/tcpdump/print-null.c11
-rw-r--r--contrib/tcpdump/print-olsr.c184
-rw-r--r--contrib/tcpdump/print-openflow-1.0.c178
-rw-r--r--contrib/tcpdump/print-openflow.c16
-rw-r--r--contrib/tcpdump/print-ospf.c148
-rw-r--r--contrib/tcpdump/print-ospf6.c65
-rw-r--r--contrib/tcpdump/print-otv.c41
-rw-r--r--contrib/tcpdump/print-pflog.c10
-rw-r--r--contrib/tcpdump/print-pfsync.c19
-rw-r--r--contrib/tcpdump/print-pgm.c288
-rw-r--r--contrib/tcpdump/print-pim.c132
-rw-r--r--contrib/tcpdump/print-pktap.c28
-rw-r--r--contrib/tcpdump/print-ppi.c54
-rw-r--r--contrib/tcpdump/print-ppp.c24
-rw-r--r--contrib/tcpdump/print-pppoe.c17
-rw-r--r--contrib/tcpdump/print-pptp.c39
-rw-r--r--contrib/tcpdump/print-radius.c56
-rw-r--r--contrib/tcpdump/print-raw.c7
-rw-r--r--contrib/tcpdump/print-resp.c538
-rw-r--r--contrib/tcpdump/print-rip.c37
-rw-r--r--contrib/tcpdump/print-ripng.c12
-rw-r--r--contrib/tcpdump/print-rpki-rtr.c53
-rw-r--r--contrib/tcpdump/print-rrcp.c71
-rw-r--r--contrib/tcpdump/print-rsvp.c173
-rw-r--r--contrib/tcpdump/print-rt6.c32
-rw-r--r--contrib/tcpdump/print-rtsp.c9
-rw-r--r--contrib/tcpdump/print-rx.c131
-rw-r--r--contrib/tcpdump/print-sctp.c217
-rw-r--r--contrib/tcpdump/print-sflow.c68
-rw-r--r--contrib/tcpdump/print-sip.c7
-rw-r--r--contrib/tcpdump/print-sl.c33
-rw-r--r--contrib/tcpdump/print-sll.c38
-rw-r--r--contrib/tcpdump/print-slow.c274
-rw-r--r--contrib/tcpdump/print-smb.c37
-rw-r--r--contrib/tcpdump/print-smtp.c4
-rw-r--r--contrib/tcpdump/print-snmp.c346
-rw-r--r--contrib/tcpdump/print-stp.c110
-rw-r--r--contrib/tcpdump/print-sunatm.c7
-rw-r--r--contrib/tcpdump/print-sunrpc.c25
-rw-r--r--contrib/tcpdump/print-symantec.c17
-rw-r--r--contrib/tcpdump/print-syslog.c7
-rw-r--r--contrib/tcpdump/print-tcp.c281
-rw-r--r--contrib/tcpdump/print-telnet.c21
-rw-r--r--contrib/tcpdump/print-tftp.c93
-rw-r--r--contrib/tcpdump/print-timed.c15
-rw-r--r--contrib/tcpdump/print-tipc.c30
-rw-r--r--contrib/tcpdump/print-token.c46
-rw-r--r--contrib/tcpdump/print-udld.c71
-rw-r--r--contrib/tcpdump/print-udp.c324
-rw-r--r--contrib/tcpdump/print-usb.c7
-rw-r--r--contrib/tcpdump/print-vjc.c18
-rw-r--r--contrib/tcpdump/print-vqp.c9
-rw-r--r--contrib/tcpdump/print-vrrp.c9
-rw-r--r--contrib/tcpdump/print-vtp.c50
-rw-r--r--contrib/tcpdump/print-vxlan-gpe.c113
-rw-r--r--contrib/tcpdump/print-vxlan.c28
-rw-r--r--contrib/tcpdump/print-wb.c35
-rw-r--r--contrib/tcpdump/print-zephyr.c59
-rw-r--r--contrib/tcpdump/print-zeromq.c35
-rw-r--r--contrib/tcpdump/print.c484
-rw-r--r--contrib/tcpdump/print.h44
-rw-r--r--contrib/tcpdump/rpc_auth.h3
-rw-r--r--contrib/tcpdump/rpc_msg.h3
-rw-r--r--contrib/tcpdump/rpl.h8
-rw-r--r--contrib/tcpdump/setsignal.c2
-rw-r--r--contrib/tcpdump/signature.c88
-rw-r--r--contrib/tcpdump/signature.h6
-rw-r--r--contrib/tcpdump/smb.h2
-rw-r--r--contrib/tcpdump/smbutil.c10
-rw-r--r--contrib/tcpdump/strcasecmp.c88
-rw-r--r--contrib/tcpdump/strtoaddr.c239
-rw-r--r--contrib/tcpdump/strtoaddr.h23
-rw-r--r--contrib/tcpdump/tcp.h70
-rw-r--r--contrib/tcpdump/tcpdump.1.in31
-rw-r--r--contrib/tcpdump/tcpdump.c1835
-rw-r--r--contrib/tcpdump/timeval-operations.h78
-rw-r--r--contrib/tcpdump/udp.h325
-rw-r--r--contrib/tcpdump/util-print.c (renamed from contrib/tcpdump/util.c)380
-rw-r--r--contrib/tcpdump/vfprintf.c2
-rw-r--r--contrib/zlib/ChangeLog55
-rw-r--r--contrib/zlib/README6
-rw-r--r--contrib/zlib/adler32.c21
-rw-r--r--contrib/zlib/compress.c42
-rw-r--r--contrib/zlib/contrib/README.contrib4
-rw-r--r--contrib/zlib/crc32.c41
-rw-r--r--contrib/zlib/deflate.c802
-rw-r--r--contrib/zlib/deflate.h35
-rw-r--r--contrib/zlib/gzguts.h23
-rw-r--r--contrib/zlib/gzlib.c31
-rw-r--r--contrib/zlib/gzread.c156
-rw-r--r--contrib/zlib/gzwrite.c332
-rw-r--r--contrib/zlib/infback.c4
-rw-r--r--contrib/zlib/inffast.c85
-rw-r--r--contrib/zlib/inflate.c123
-rw-r--r--contrib/zlib/inflate.h11
-rw-r--r--contrib/zlib/inftrees.c26
-rw-r--r--contrib/zlib/test/example.c17
-rw-r--r--contrib/zlib/test/infcover.c18
-rw-r--r--contrib/zlib/test/minigzip.c12
-rw-r--r--contrib/zlib/trees.c99
-rw-r--r--contrib/zlib/uncompr.c98
-rw-r--r--contrib/zlib/zconf.h41
-rw-r--r--contrib/zlib/zconf.h.in41
-rw-r--r--contrib/zlib/zlib.372
-rw-r--r--contrib/zlib/zlib.h452
-rw-r--r--contrib/zlib/zlib.map177
-rw-r--r--contrib/zlib/zutil.c49
-rw-r--r--contrib/zlib/zutil.h52
-rw-r--r--crypto/openssh/auth.c4
-rw-r--r--etc/mtree/BSD.tests.dist4
-rw-r--r--etc/mtree/BSD.var.dist2
-rw-r--r--gnu/usr.bin/gdb/Makefile.inc22
-rw-r--r--gnu/usr.bin/gdb/gdbserver/Makefile2
-rw-r--r--include/stdlib.h2
-rw-r--r--lib/csu/aarch64/Makefile6
-rw-r--r--lib/csu/amd64/Makefile6
-rw-r--r--lib/csu/arm/Makefile6
-rw-r--r--lib/csu/i386/Makefile6
-rw-r--r--lib/csu/mips/Makefile6
-rw-r--r--lib/csu/powerpc/Makefile6
-rw-r--r--lib/csu/powerpc64/Makefile6
-rw-r--r--lib/csu/riscv/Makefile6
-rw-r--r--lib/csu/sparc64/Makefile5
-rw-r--r--lib/libalias/libalias/Makefile2
-rw-r--r--lib/libalias/modules/Makefile2
-rw-r--r--lib/libalias/modules/Makefile.inc2
-rw-r--r--lib/libarchive/Makefile2
-rw-r--r--lib/libarchive/config_freebsd.h1
-rw-r--r--lib/libarchive/tests/Makefile12
-rw-r--r--lib/libauditd/Makefile2
-rw-r--r--lib/libbegemot/Makefile2
-rw-r--r--lib/libblocksruntime/Makefile2
-rw-r--r--lib/libbluetooth/Makefile2
-rw-r--r--lib/libbsm/Makefile2
-rw-r--r--lib/libbsnmp/libbsnmp/Makefile2
-rw-r--r--lib/libbz2/Makefile2
-rw-r--r--lib/libc++/Makefile6
-rw-r--r--lib/libc/db/hash/hash_page.c13
-rw-r--r--lib/libc/stdlib/hcreate.38
-rw-r--r--lib/libc/sys/recv.255
-rw-r--r--lib/libc/tests/db/Makefile2
-rw-r--r--lib/libc/tests/gen/Makefile12
-rw-r--r--lib/libc/tests/stdio/printbasic_test.c22
-rw-r--r--lib/libc/tests/stdio/printfloat_test.c19
-rw-r--r--lib/libc/tests/sys/Makefile4
-rw-r--r--lib/libc/x86/sys/Makefile.inc4
-rw-r--r--lib/libc/x86/sys/__vdso_gettc.c8
-rw-r--r--lib/libc_nonshared/Makefile6
-rw-r--r--lib/libcam/Makefile7
-rw-r--r--lib/libcom_err/Makefile2
-rw-r--r--lib/libcompat/Makefile2
-rw-r--r--lib/libcrypt/Makefile10
-rw-r--r--lib/libcxxrt/Makefile2
-rw-r--r--lib/libdevdctl/tests/Makefile2
-rw-r--r--lib/libdwarf/Makefile2
-rw-r--r--lib/libedit/Makefile9
-rw-r--r--lib/libedit/TEST/rl1.c4
-rw-r--r--lib/libedit/TEST/tc1.c16
-rw-r--r--lib/libedit/TEST/wtc1.c9
-rw-r--r--lib/libedit/chared.c42
-rw-r--r--lib/libedit/chared.h29
-rw-r--r--lib/libedit/chartype.c35
-rw-r--r--lib/libedit/chartype.h25
-rw-r--r--lib/libedit/common.c120
-rw-r--r--lib/libedit/config.h10
-rw-r--r--lib/libedit/edit/readline/readline.h14
-rw-r--r--lib/libedit/editline.364
-rw-r--r--lib/libedit/el.c33
-rw-r--r--lib/libedit/el.h16
-rw-r--r--lib/libedit/eln.c53
-rw-r--r--lib/libedit/emacs.c49
-rw-r--r--lib/libedit/filecomplete.c25
-rw-r--r--lib/libedit/hist.c6
-rw-r--r--lib/libedit/hist.h6
-rw-r--r--lib/libedit/histedit.h17
-rw-r--r--lib/libedit/history.c41
-rw-r--r--lib/libedit/keymacro.c26
-rw-r--r--lib/libedit/makelist12
-rw-r--r--lib/libedit/map.c33
-rw-r--r--lib/libedit/parse.c17
-rw-r--r--lib/libedit/prompt.c4
-rw-r--r--lib/libedit/prompt.h6
-rw-r--r--lib/libedit/read.c120
-rw-r--r--lib/libedit/read.h6
-rw-r--r--lib/libedit/readline.c63
-rw-r--r--lib/libedit/refresh.c70
-rw-r--r--lib/libedit/refresh.h6
-rw-r--r--lib/libedit/search.c34
-rw-r--r--lib/libedit/search.h8
-rw-r--r--lib/libedit/sig.c13
-rw-r--r--lib/libedit/sig.h4
-rw-r--r--lib/libedit/sys.h24
-rw-r--r--lib/libedit/terminal.c80
-rw-r--r--lib/libedit/terminal.h8
-rw-r--r--lib/libedit/tokenizer.c11
-rw-r--r--lib/libedit/tty.c36
-rw-r--r--lib/libedit/tty.h7
-rw-r--r--lib/libedit/vi.c130
-rw-r--r--lib/libelf/Makefile2
-rw-r--r--lib/libevent/Makefile2
-rw-r--r--lib/libexecinfo/Makefile2
-rw-r--r--lib/libexpat/Makefile2
-rw-r--r--lib/libgssapi/Makefile2
-rw-r--r--lib/libiconv_modules/Makefile.inc4
-rw-r--r--lib/libiconv_modules/mapper_parallel/Makefile2
-rw-r--r--lib/libkiconv/Makefile2
-rw-r--r--lib/libldns/Makefile2
-rw-r--r--lib/liblzma/Makefile6
-rw-r--r--lib/libmagic/Makefile2
-rw-r--r--lib/libmd/Makefile8
-rw-r--r--lib/libmilter/Makefile2
-rw-r--r--lib/libmp/Makefile4
-rw-r--r--lib/libnetbsd/glob.h39
-rw-r--r--lib/libnetbsd/pthread.h36
-rw-r--r--lib/libnetbsd/sha1.h3
-rw-r--r--lib/libnetbsd/sha2.h1
-rw-r--r--lib/libnetbsd/sys/event.h42
-rw-r--r--lib/libnetbsd/sys/types.h37
-rw-r--r--lib/libnetbsd/sys/wait.h37
-rw-r--r--lib/libnetbsd/util.h7
-rw-r--r--lib/libngatm/Makefile4
-rw-r--r--lib/libnv/Makefile4
-rw-r--r--lib/libopie/Makefile2
-rw-r--r--lib/libpam/libpam/Makefile2
-rw-r--r--lib/libpam/modules/Makefile.inc4
-rw-r--r--lib/libpam/modules/pam_passwdqc/Makefile2
-rw-r--r--lib/libpam/modules/pam_ssh/Makefile2
-rw-r--r--lib/libpam/static_libpam/Makefile4
-rw-r--r--lib/libpcap/Makefile2
-rw-r--r--lib/libpe/Makefile2
-rw-r--r--lib/libproc/Makefile6
-rw-r--r--lib/libprocstat/zfs/Makefile22
-rw-r--r--lib/librpcsec_gss/Makefile6
-rw-r--r--lib/librpcsvc/Makefile2
-rw-r--r--lib/librt/Makefile4
-rw-r--r--lib/libsbuf/Makefile2
-rw-r--r--lib/libsm/Makefile2
-rw-r--r--lib/libsmb/Makefile2
-rw-r--r--lib/libsmdb/Makefile2
-rw-r--r--lib/libsmutil/Makefile2
-rw-r--r--lib/libsqlite3/Makefile2
-rw-r--r--lib/libstdthreads/Makefile2
-rw-r--r--lib/libsysdecode/Makefile4
-rw-r--r--lib/libsysdecode/mktables2
-rw-r--r--lib/libtelnet/Makefile2
-rw-r--r--lib/libthr/Makefile12
-rw-r--r--lib/libthr/support/Makefile.inc12
-rw-r--r--lib/libthr/tests/Makefile1
-rw-r--r--lib/libthread_db/Makefile2
-rw-r--r--lib/libufs/Makefile2
-rw-r--r--lib/libulog/Makefile2
-rw-r--r--lib/libunbound/Makefile4
-rw-r--r--lib/libutil/Makefile2
-rw-r--r--lib/libypclnt/Makefile6
-rw-r--r--lib/libz/Symbol.map11
-rw-r--r--lib/libz/Versions.def3
-rw-r--r--lib/libz/zlib.pc2
-rw-r--r--lib/msun/tests/Makefile7
-rw-r--r--lib/msun/tests/fmaxmin_test.c3
-rw-r--r--lib/ncurses/config.mk12
-rw-r--r--lib/ncurses/form/Makefile2
-rw-r--r--lib/ncurses/formw/Makefile2
-rw-r--r--lib/ncurses/menu/Makefile2
-rw-r--r--lib/ncurses/menuw/Makefile2
-rw-r--r--lib/ncurses/ncurses/Makefile2
-rw-r--r--lib/ncurses/ncursesw/Makefile4
-rw-r--r--lib/ncurses/panel/Makefile2
-rw-r--r--lib/ncurses/panelw/Makefile2
-rw-r--r--libexec/rtld-elf/rtld.c20
-rw-r--r--sbin/fsck_ffs/fsck_ffs.884
-rw-r--r--sbin/fsck_ffs/main.c2
-rw-r--r--sbin/kldload/kldload.c59
-rw-r--r--sbin/resolvconf/Makefile4
-rw-r--r--share/man/man4/alc.42
-rw-r--r--share/man/man4/unix.481
-rw-r--r--sys/amd64/linux/linux_dummy.c49
-rw-r--r--sys/amd64/linux/linux_proto.h205
-rw-r--r--sys/amd64/linux/linux_syscall.h35
-rw-r--r--sys/amd64/linux/linux_syscalls.c37
-rw-r--r--sys/amd64/linux/linux_sysent.c45
-rw-r--r--sys/amd64/linux/linux_systrace_args.c884
-rw-r--r--sys/amd64/linux/syscalls.master111
-rw-r--r--sys/amd64/linux32/linux32_dummy.c37
-rw-r--r--sys/amd64/linux32/linux32_proto.h299
-rw-r--r--sys/amd64/linux32/linux32_syscall.h40
-rw-r--r--sys/amd64/linux32/linux32_syscalls.c40
-rw-r--r--sys/amd64/linux32/linux32_sysent.c48
-rw-r--r--sys/amd64/linux32/linux32_systrace_args.c1260
-rw-r--r--sys/amd64/linux32/syscalls.master124
-rw-r--r--sys/arm/arm/pmap-v6.c272
-rw-r--r--sys/arm/include/_types.h2
-rw-r--r--sys/arm/include/counter.h18
-rw-r--r--sys/arm/include/pcpu.h17
-rw-r--r--sys/arm64/include/_types.h2
-rw-r--r--sys/arm64/include/counter.h20
-rw-r--r--sys/cam/ctl/ctl.c3
-rw-r--r--sys/cam/ctl/ctl_backend_ramdisk.c4
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c2
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c17
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c4
-rw-r--r--sys/cddl/dev/dtrace/x86/dis_tables.c691
-rw-r--r--sys/cddl/dev/dtrace/x86/dis_tables.h1
-rw-r--r--sys/compat/freebsd32/freebsd32_misc.c3
-rw-r--r--sys/compat/linux/linux_socket.c62
-rw-r--r--sys/compat/linux/linux_socket.h123
-rw-r--r--sys/dev/alc/if_alc.c7
-rw-r--r--sys/dev/alc/if_alcreg.h1
-rw-r--r--sys/dev/bxe/bxe.c6
-rw-r--r--sys/dev/e1000/if_em.c2
-rw-r--r--sys/dev/hyperv/include/hyperv.h12
-rw-r--r--sys/dev/hyperv/netvsc/hn_nvs.c14
-rw-r--r--sys/dev/hyperv/netvsc/hn_nvs.h1
-rw-r--r--sys/dev/hyperv/netvsc/if_hn.c202
-rw-r--r--sys/dev/hyperv/netvsc/if_hnreg.h11
-rw-r--r--sys/dev/hyperv/netvsc/if_hnvar.h7
-rw-r--r--sys/dev/hyperv/utilities/vmbus_timesync.c5
-rw-r--r--sys/dev/hyperv/vmbus/amd64/hyperv_machdep.c18
-rw-r--r--sys/dev/hyperv/vmbus/hyperv.c15
-rw-r--r--sys/dev/hyperv/vmbus/vmbus_et.c17
-rw-r--r--sys/dev/isp/isp.c15
-rw-r--r--sys/dev/iwi/if_iwi.c59
-rw-r--r--sys/dev/pci/pci.c5
-rw-r--r--sys/dev/usb/controller/ehci_imx.c21
-rw-r--r--sys/dev/vt/vt_core.c1
-rw-r--r--sys/fs/devfs/devfs_devs.c5
-rw-r--r--sys/fs/nfsserver/nfs_nfsdkrpc.c20
-rw-r--r--sys/geom/part/g_part_gpt.c7
-rw-r--r--sys/i386/i386/pmap.c12
-rw-r--r--sys/i386/include/pcpu.h10
-rw-r--r--sys/i386/linux/linux_dummy.c39
-rw-r--r--sys/i386/linux/linux_proto.h299
-rw-r--r--sys/i386/linux/linux_syscall.h40
-rw-r--r--sys/i386/linux/linux_syscalls.c40
-rw-r--r--sys/i386/linux/linux_sysent.c48
-rw-r--r--sys/i386/linux/linux_systrace_args.c1260
-rw-r--r--sys/i386/linux/syscalls.master123
-rw-r--r--sys/kern/kern_lockf.c4
-rw-r--r--sys/kern/subr_sfbuf.c1
-rw-r--r--sys/kern/subr_witness.c13
-rw-r--r--sys/kern/sys_socket.c2
-rw-r--r--sys/kern/uipc_socket.c2
-rw-r--r--sys/mips/include/_types.h2
-rw-r--r--sys/modules/ath/Makefile34
-rw-r--r--sys/net/if.c8
-rw-r--r--sys/net/if_var.h5
-rw-r--r--sys/netinet/udp_usrreq.c8
-rw-r--r--sys/netpfil/ipfw/dn_heap.h2
-rw-r--r--sys/powerpc/include/_types.h2
-rw-r--r--sys/riscv/include/_types.h2
-rw-r--r--sys/rpc/svc.c42
-rw-r--r--sys/rpc/svc.h6
-rw-r--r--sys/sparc64/include/_types.h2
-rw-r--r--sys/sys/elf_generic.h1
-rw-r--r--sys/sys/socket.h1
-rw-r--r--sys/sys/syscallsubr.h2
-rw-r--r--sys/sys/types.h4
-rw-r--r--sys/vm/vm_mmap.c81
-rw-r--r--sys/x86/include/_types.h2
-rw-r--r--tests/sys/geom/class/gate/1_test.sh63
-rw-r--r--tests/sys/geom/class/gate/2_test.sh48
-rw-r--r--tests/sys/geom/class/gate/3_test.sh49
-rw-r--r--tests/sys/geom/class/gate/Makefile10
-rwxr-xr-xtests/sys/geom/class/gate/conf.sh8
-rwxr-xr-xtests/sys/geom/class/gate/ggate_test.sh207
-rw-r--r--usr.bin/atm/sscop/Makefile2
-rw-r--r--usr.bin/awk/Makefile4
-rw-r--r--usr.bin/bc/bc.12
-rw-r--r--usr.bin/bluetooth/Makefile.inc2
-rw-r--r--usr.bin/bsdcat/Makefile6
-rw-r--r--usr.bin/ctlstat/ctlstat.88
-rw-r--r--usr.bin/cut/tests/Makefile1
-rwxr-xr-xusr.bin/cut/tests/cut2_test.sh51
-rw-r--r--usr.bin/env/env.12
-rw-r--r--usr.bin/expand/expand.12
-rw-r--r--usr.bin/ipcrm/ipcrm.19
-rw-r--r--usr.bin/mail/mail.12
-rw-r--r--usr.bin/mkimg/mkimg.12
-rw-r--r--usr.bin/mkuzip/mkuzip.86
-rw-r--r--usr.bin/mt/mt.110
-rw-r--r--usr.bin/perror/perror.18
-rw-r--r--usr.bin/revoke/revoke.18
-rw-r--r--usr.bin/sdiff/sdiff.12
-rw-r--r--usr.bin/sed/tests/Makefile5
-rw-r--r--usr.bin/svn/Makefile.inc48
-rw-r--r--usr.bin/svn/svn/Makefile8
-rw-r--r--usr.bin/svn/svnadmin/Makefile8
-rw-r--r--usr.bin/svn/svnbench/Makefile8
-rw-r--r--usr.bin/svn/svndumpfilter/Makefile8
-rw-r--r--usr.bin/svn/svnfsfs/Makefile8
-rw-r--r--usr.bin/svn/svnlook/Makefile8
-rw-r--r--usr.bin/svn/svnmucc/Makefile8
-rw-r--r--usr.bin/svn/svnrdump/Makefile8
-rw-r--r--usr.bin/svn/svnserve/Makefile8
-rw-r--r--usr.bin/svn/svnsync/Makefile8
-rw-r--r--usr.bin/svn/svnversion/Makefile8
-rw-r--r--usr.bin/timeout/timeout.111
-rw-r--r--usr.bin/units/units.118
-rw-r--r--usr.bin/unzip/unzip.12
-rw-r--r--usr.bin/uuencode/uuencode.12
-rw-r--r--usr.bin/whois/whois.12
-rw-r--r--usr.sbin/arp/arp.c114
-rw-r--r--usr.sbin/bhyve/virtio.h2
-rwxr-xr-xusr.sbin/bsdinstall/scripts/auto6
-rw-r--r--usr.sbin/ctladm/ctladm.84
-rw-r--r--usr.sbin/kldxref/ef.c4
-rw-r--r--usr.sbin/ndp/ndp.c80
-rw-r--r--usr.sbin/syslogd/syslogd.c14
-rw-r--r--usr.sbin/tcpdump/tcpdump/Makefile35
-rw-r--r--usr.sbin/tcpdump/tcpdump/config.h43
-rw-r--r--usr.sbin/vidcontrol/vidcontrol.c44
764 files changed, 49621 insertions, 16994 deletions
diff --git a/ObsoleteFiles.inc b/ObsoleteFiles.inc
index 30ed470..70b4a34 100644
--- a/ObsoleteFiles.inc
+++ b/ObsoleteFiles.inc
@@ -38,6 +38,13 @@
# xargs -n1 | sort | uniq -d;
# done
+# 20170214: Four files from ggate tests consolidated into one
+OLD_FILES+=usr/tests/sys/geom/class/gate/1_test
+OLD_FILES+=usr/tests/sys/geom/class/gate/2_test
+OLD_FILES+=usr/tests/sys/geom/class/gate/3_test
+OLD_FILES+=usr/tests/sys/geom/class/gate/conf.sh
+# 20170211: libarchive ACL pax test renamed to test_acl_pax_posix1e.tar.uu
+OLD_FILES+=usr/tests/lib/libarchive/test_acl_pax.tar.uu
# 20170103: libbsnmptools.so made into an INTERNALLIB
OLD_FILES+=usr/lib/libbsnmptools.a
OLD_FILES+=usr/lib/libbsnmptools_p.a
diff --git a/bin/ls/print.c b/bin/ls/print.c
index 7fe73a6..12ca802 100644
--- a/bin/ls/print.c
+++ b/bin/ls/print.c
@@ -259,12 +259,12 @@ printlong(const DISPLAY *dp)
np = p->fts_pointer;
xo_attr("value", "%03o", (int) sp->st_mode & ALLPERMS);
if (f_numericonly) {
- xo_emit("{t:mode/%s}{e:mode_octal/%03o} {t:links/%*u} {td:user/%-*s}{e:user/%ju} {td:group/%-*s}{e:group/%ju} ",
- buf, (int) sp->st_mode & ALLPERMS, dp->s_nlink, sp->st_nlink,
+ xo_emit("{t:mode/%s}{e:mode_octal/%03o} {t:links/%*ju} {td:user/%-*s}{e:user/%ju} {td:group/%-*s}{e:group/%ju} ",
+ buf, (int) sp->st_mode & ALLPERMS, dp->s_nlink, (uintmax_t)sp->st_nlink,
dp->s_user, np->user, (uintmax_t)sp->st_uid, dp->s_group, np->group, (uintmax_t)sp->st_gid);
} else {
- xo_emit("{t:mode/%s}{e:mode_octal/%03o} {t:links/%*u} {t:user/%-*s} {t:group/%-*s} ",
- buf, (int) sp->st_mode & ALLPERMS, dp->s_nlink, sp->st_nlink,
+ xo_emit("{t:mode/%s}{e:mode_octal/%03o} {t:links/%*ju} {t:user/%-*s} {t:group/%-*s} ",
+ buf, (int) sp->st_mode & ALLPERMS, dp->s_nlink, (uintmax_t)sp->st_nlink,
dp->s_user, np->user, dp->s_group, np->group);
}
if (S_ISBLK(sp->st_mode))
diff --git a/bin/pwd/pwd.1 b/bin/pwd/pwd.1
index 967e40e..964308d 100644
--- a/bin/pwd/pwd.1
+++ b/bin/pwd/pwd.1
@@ -87,7 +87,7 @@ utility conforms to
.St -p1003.1-2001 .
.Sh HISTORY
The
-.Nm
+.Nm
command appeared in
.At v5 .
.Sh BUGS
diff --git a/bin/sh/sh.1 b/bin/sh/sh.1
index 20a9dbf..a0e1026 100644
--- a/bin/sh/sh.1
+++ b/bin/sh/sh.1
@@ -1033,7 +1033,7 @@ The syntax of the
command is:
.Bd -unfilled -offset indent -compact
.Ic case Ar word Ic in
-.Ar pattern Ns Li ) Ar list Li ;;
+.Ar pattern Ns ) Ar list Li ;;
.Ar ...
.Ic esac
.Ed
diff --git a/contrib/compiler-rt/lib/asan/asan_malloc_linux.cc b/contrib/compiler-rt/lib/asan/asan_malloc_linux.cc
index 162abd2..40b7281 100644
--- a/contrib/compiler-rt/lib/asan/asan_malloc_linux.cc
+++ b/contrib/compiler-rt/lib/asan/asan_malloc_linux.cc
@@ -50,12 +50,14 @@ INTERCEPTOR(void, free, void *ptr) {
asan_free(ptr, &stack, FROM_MALLOC);
}
+#if SANITIZER_INTERCEPT_CFREE
INTERCEPTOR(void, cfree, void *ptr) {
GET_STACK_TRACE_FREE;
if (UNLIKELY(IsInDlsymAllocPool(ptr)))
return;
asan_free(ptr, &stack, FROM_MALLOC);
}
+#endif // SANITIZER_INTERCEPT_CFREE
INTERCEPTOR(void*, malloc, uptr size) {
if (UNLIKELY(!asan_inited))
@@ -85,22 +87,24 @@ INTERCEPTOR(void*, realloc, void *ptr, uptr size) {
return asan_realloc(ptr, size, &stack);
}
+#if SANITIZER_INTERCEPT_MEMALIGN
INTERCEPTOR(void*, memalign, uptr boundary, uptr size) {
GET_STACK_TRACE_MALLOC;
return asan_memalign(boundary, size, &stack, FROM_MALLOC);
}
-INTERCEPTOR(void*, aligned_alloc, uptr boundary, uptr size) {
- GET_STACK_TRACE_MALLOC;
- return asan_memalign(boundary, size, &stack, FROM_MALLOC);
-}
-
INTERCEPTOR(void*, __libc_memalign, uptr boundary, uptr size) {
GET_STACK_TRACE_MALLOC;
void *res = asan_memalign(boundary, size, &stack, FROM_MALLOC);
DTLS_on_libc_memalign(res, size);
return res;
}
+#endif // SANITIZER_INTERCEPT_MEMALIGN
+
+INTERCEPTOR(void*, aligned_alloc, uptr boundary, uptr size) {
+ GET_STACK_TRACE_MALLOC;
+ return asan_memalign(boundary, size, &stack, FROM_MALLOC);
+}
INTERCEPTOR(uptr, malloc_usable_size, void *ptr) {
GET_CURRENT_PC_BP_SP;
@@ -108,6 +112,7 @@ INTERCEPTOR(uptr, malloc_usable_size, void *ptr) {
return asan_malloc_usable_size(ptr, pc, bp);
}
+#if SANITIZER_INTERCEPT_MALLOPT_AND_MALLINFO
// We avoid including malloc.h for portability reasons.
// man mallinfo says the fields are "long", but the implementation uses int.
// It doesn't matter much -- we just need to make sure that the libc's mallinfo
@@ -125,6 +130,7 @@ INTERCEPTOR(struct fake_mallinfo, mallinfo, void) {
INTERCEPTOR(int, mallopt, int cmd, int value) {
return -1;
}
+#endif // SANITIZER_INTERCEPT_MALLOPT_AND_MALLINFO
INTERCEPTOR(int, posix_memalign, void **memptr, uptr alignment, uptr size) {
GET_STACK_TRACE_MALLOC;
@@ -137,10 +143,12 @@ INTERCEPTOR(void*, valloc, uptr size) {
return asan_valloc(size, &stack);
}
+#if SANITIZER_INTERCEPT_PVALLOC
INTERCEPTOR(void*, pvalloc, uptr size) {
GET_STACK_TRACE_MALLOC;
return asan_pvalloc(size, &stack);
}
+#endif // SANITIZER_INTERCEPT_PVALLOC
INTERCEPTOR(void, malloc_stats, void) {
__asan_print_accumulated_stats();
diff --git a/contrib/compiler-rt/lib/asan/asan_malloc_win.cc b/contrib/compiler-rt/lib/asan/asan_malloc_win.cc
index 4a233df..f879ecb 100644
--- a/contrib/compiler-rt/lib/asan/asan_malloc_win.cc
+++ b/contrib/compiler-rt/lib/asan/asan_malloc_win.cc
@@ -56,11 +56,6 @@ void _free_base(void *ptr) {
}
ALLOCATION_FUNCTION_ATTRIBUTE
-void cfree(void *ptr) {
- CHECK(!"cfree() should not be used on Windows");
-}
-
-ALLOCATION_FUNCTION_ATTRIBUTE
void *malloc(size_t size) {
GET_STACK_TRACE_MALLOC;
return asan_malloc(size, &stack);
diff --git a/contrib/compiler-rt/lib/lsan/lsan_interceptors.cc b/contrib/compiler-rt/lib/lsan/lsan_interceptors.cc
index 28f1786..1219017 100644
--- a/contrib/compiler-rt/lib/lsan/lsan_interceptors.cc
+++ b/contrib/compiler-rt/lib/lsan/lsan_interceptors.cc
@@ -19,6 +19,7 @@
#include "sanitizer_common/sanitizer_flags.h"
#include "sanitizer_common/sanitizer_internal_defs.h"
#include "sanitizer_common/sanitizer_linux.h"
+#include "sanitizer_common/sanitizer_platform_interceptors.h"
#include "sanitizer_common/sanitizer_platform_limits_posix.h"
#include "sanitizer_common/sanitizer_tls_get_addr.h"
#include "lsan.h"
@@ -86,11 +87,26 @@ INTERCEPTOR(void*, realloc, void *q, uptr size) {
return Reallocate(stack, q, size, 1);
}
+#if SANITIZER_INTERCEPT_MEMALIGN
INTERCEPTOR(void*, memalign, uptr alignment, uptr size) {
ENSURE_LSAN_INITED;
GET_STACK_TRACE_MALLOC;
return Allocate(stack, size, alignment, kAlwaysClearMemory);
}
+#define LSAN_MAYBE_INTERCEPT_MEMALIGN INTERCEPT_FUNCTION(memalign)
+
+INTERCEPTOR(void *, __libc_memalign, uptr alignment, uptr size) {
+ ENSURE_LSAN_INITED;
+ GET_STACK_TRACE_MALLOC;
+ void *res = Allocate(stack, size, alignment, kAlwaysClearMemory);
+ DTLS_on_libc_memalign(res, size);
+ return res;
+}
+#define LSAN_MAYBE_INTERCEPT___LIBC_MEMALIGN INTERCEPT_FUNCTION(__libc_memalign)
+#else
+#define LSAN_MAYBE_INTERCEPT_MEMALIGN
+#define LSAN_MAYBE_INTERCEPT___LIBC_MEMALIGN
+#endif // SANITIZER_INTERCEPT_MEMALIGN
INTERCEPTOR(void*, aligned_alloc, uptr alignment, uptr size) {
ENSURE_LSAN_INITED;
@@ -106,14 +122,6 @@ INTERCEPTOR(int, posix_memalign, void **memptr, uptr alignment, uptr size) {
return 0;
}
-INTERCEPTOR(void *, __libc_memalign, uptr alignment, uptr size) {
- ENSURE_LSAN_INITED;
- GET_STACK_TRACE_MALLOC;
- void *res = Allocate(stack, size, alignment, kAlwaysClearMemory);
- DTLS_on_libc_memalign(res, size);
- return res;
-}
-
INTERCEPTOR(void*, valloc, uptr size) {
ENSURE_LSAN_INITED;
GET_STACK_TRACE_MALLOC;
@@ -127,6 +135,7 @@ INTERCEPTOR(uptr, malloc_usable_size, void *ptr) {
return GetMallocUsableSize(ptr);
}
+#if SANITIZER_INTERCEPT_MALLOPT_AND_MALLINFO
struct fake_mallinfo {
int x[10];
};
@@ -136,11 +145,18 @@ INTERCEPTOR(struct fake_mallinfo, mallinfo, void) {
internal_memset(&res, 0, sizeof(res));
return res;
}
+#define LSAN_MAYBE_INTERCEPT_MALLINFO INTERCEPT_FUNCTION(mallinfo)
INTERCEPTOR(int, mallopt, int cmd, int value) {
return -1;
}
+#define LSAN_MAYBE_INTERCEPT_MALLOPT INTERCEPT_FUNCTION(mallopt)
+#else
+#define LSAN_MAYBE_INTERCEPT_MALLINFO
+#define LSAN_MAYBE_INTERCEPT_MALLOPT
+#endif // SANITIZER_INTERCEPT_MALLOPT_AND_MALLINFO
+#if SANITIZER_INTERCEPT_PVALLOC
INTERCEPTOR(void*, pvalloc, uptr size) {
ENSURE_LSAN_INITED;
GET_STACK_TRACE_MALLOC;
@@ -152,8 +168,17 @@ INTERCEPTOR(void*, pvalloc, uptr size) {
}
return Allocate(stack, size, GetPageSizeCached(), kAlwaysClearMemory);
}
+#define LSAN_MAYBE_INTERCEPT_PVALLOC INTERCEPT_FUNCTION(pvalloc)
+#else
+#define LSAN_MAYBE_INTERCEPT_PVALLOC
+#endif // SANITIZER_INTERCEPT_PVALLOC
+#if SANITIZER_INTERCEPT_CFREE
INTERCEPTOR(void, cfree, void *p) ALIAS(WRAPPER_NAME(free));
+#define LSAN_MAYBE_INTERCEPT_CFREE INTERCEPT_FUNCTION(cfree)
+#else
+#define LSAN_MAYBE_INTERCEPT_CFREE
+#endif // SANITIZER_INTERCEPT_CFREE
#define OPERATOR_NEW_BODY \
ENSURE_LSAN_INITED; \
@@ -277,17 +302,18 @@ namespace __lsan {
void InitializeInterceptors() {
INTERCEPT_FUNCTION(malloc);
INTERCEPT_FUNCTION(free);
- INTERCEPT_FUNCTION(cfree);
+ LSAN_MAYBE_INTERCEPT_CFREE;
INTERCEPT_FUNCTION(calloc);
INTERCEPT_FUNCTION(realloc);
- INTERCEPT_FUNCTION(memalign);
+ LSAN_MAYBE_INTERCEPT_MEMALIGN;
+ LSAN_MAYBE_INTERCEPT___LIBC_MEMALIGN;
+ INTERCEPT_FUNCTION(aligned_alloc);
INTERCEPT_FUNCTION(posix_memalign);
- INTERCEPT_FUNCTION(__libc_memalign);
INTERCEPT_FUNCTION(valloc);
- INTERCEPT_FUNCTION(pvalloc);
+ LSAN_MAYBE_INTERCEPT_PVALLOC;
INTERCEPT_FUNCTION(malloc_usable_size);
- INTERCEPT_FUNCTION(mallinfo);
- INTERCEPT_FUNCTION(mallopt);
+ LSAN_MAYBE_INTERCEPT_MALLINFO;
+ LSAN_MAYBE_INTERCEPT_MALLOPT;
INTERCEPT_FUNCTION(pthread_create);
INTERCEPT_FUNCTION(pthread_join);
diff --git a/contrib/compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h b/contrib/compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h
index a4afc0f..aa8beb9 100644
--- a/contrib/compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h
+++ b/contrib/compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h
@@ -318,4 +318,10 @@
#define SANITIZER_INTERCEPT___XSTAT64 SI_LINUX_NOT_ANDROID
#define SANITIZER_INTERCEPT___LXSTAT SANITIZER_INTERCEPT___XSTAT
#define SANITIZER_INTERCEPT___LXSTAT64 SI_LINUX_NOT_ANDROID
+
+#define SANITIZER_INTERCEPT_MALLOPT_AND_MALLINFO (!SI_FREEBSD && !SI_MAC)
+#define SANITIZER_INTERCEPT_MEMALIGN (!SI_FREEBSD && !SI_MAC)
+#define SANITIZER_INTERCEPT_PVALLOC (!SI_FREEBSD && !SI_MAC)
+#define SANITIZER_INTERCEPT_CFREE (!SI_FREEBSD && !SI_MAC)
+
#endif // #ifndef SANITIZER_PLATFORM_INTERCEPTORS_H
diff --git a/contrib/elftoolchain/libelftc/elftc_bfd_find_target.3 b/contrib/elftoolchain/libelftc/elftc_bfd_find_target.3
index 2e4dbaa..a287339 100644
--- a/contrib/elftoolchain/libelftc/elftc_bfd_find_target.3
+++ b/contrib/elftoolchain/libelftc/elftc_bfd_find_target.3
@@ -82,6 +82,8 @@ Known descriptor names and their properties include:
.It Li elf32-shbig-linux Ta ELF Ta MSB Ta 32
.It Li elf32-shl-linux Ta ELF Ta LSB Ta 32
.It Li elf32-sparc Ta ELF Ta MSB Ta 32
+.It Li elf32-tradbigmips Ta ELF Ta MSB Ta 32
+.It Li elf32-tradlittlemips Ta ELF Ta LSB Ta 32
.It Li elf64-alpha Ta ELF Ta LSB Ta 64
.It Li elf64-alpha-freebsd Ta ELF Ta LSB Ta 64
.It Li elf64-big Ta ELF Ta MSB Ta 64
@@ -101,6 +103,8 @@ Known descriptor names and their properties include:
.It Li elf64-sh64-linux Ta ELF Ta LSB Ta 64
.It Li elf64-sparc Ta ELF Ta MSB Ta 64
.It Li elf64-sparc-freebsd Ta ELF Ta MSB Ta 64
+.It Li elf64-tradbigmips Ta ELF Ta MSB Ta 64
+.It Li elf64-tradlittlemips Ta ELF Ta LSB Ta 64
.It Li elf64-x86-64 Ta ELF Ta LSB Ta 64
.It Li elf64-x86-64-freebsd Ta ELF Ta LSB Ta 64
.It Li ihex Ta IHEX Ta - Ta -
diff --git a/contrib/elftoolchain/libelftc/elftc_reloc_type_str.c b/contrib/elftoolchain/libelftc/elftc_reloc_type_str.c
index 14bcb53..fdad9a6 100644
--- a/contrib/elftoolchain/libelftc/elftc_reloc_type_str.c
+++ b/contrib/elftoolchain/libelftc/elftc_reloc_type_str.c
@@ -664,6 +664,37 @@ elftc_reloc_type_str(unsigned int mach, unsigned int type)
case 48: return "R_RISCV_GPREL_S";
}
break;
+ case EM_S390:
+ switch (type) {
+ case 0: return "R_390_NONE";
+ case 1: return "R_390_8";
+ case 2: return "R_390_12";
+ case 3: return "R_390_16";
+ case 4: return "R_390_32";
+ case 5: return "R_390_PC32";
+ case 6: return "R_390_GOT12";
+ case 7: return "R_390_GOT32";
+ case 8: return "R_390_PLT32";
+ case 9: return "R_390_COPY";
+ case 10: return "R_390_GLOB_DAT";
+ case 11: return "R_390_JMP_SLOT";
+ case 12: return "R_390_RELATIVE";
+ case 13: return "R_390_GOTOFF";
+ case 14: return "R_390_GOTPC";
+ case 15: return "R_390_GOT16";
+ case 16: return "R_390_PC16";
+ case 17: return "R_390_PC16DBL";
+ case 18: return "R_390_PLT16DBL";
+ case 19: return "R_390_PC32DBL";
+ case 20: return "R_390_PLT32DBL";
+ case 21: return "R_390_GOTPCDBL";
+ case 22: return "R_390_64";
+ case 23: return "R_390_PC64";
+ case 24: return "R_390_GOT64";
+ case 25: return "R_390_PLT64";
+ case 26: return "R_390_GOTENT";
+ }
+ break;
case EM_SPARC:
case EM_SPARCV9:
switch(type) {
diff --git a/contrib/elftoolchain/libelftc/libelftc_bfdtarget.c b/contrib/elftoolchain/libelftc/libelftc_bfdtarget.c
index d87d4d8..43b9480 100644
--- a/contrib/elftoolchain/libelftc/libelftc_bfdtarget.c
+++ b/contrib/elftoolchain/libelftc/libelftc_bfdtarget.c
@@ -195,6 +195,22 @@ struct _Elftc_Bfd_Target _libelftc_targets[] = {
},
{
+ .bt_name = "elf32-tradbigmips",
+ .bt_type = ETF_ELF,
+ .bt_byteorder = ELFDATA2MSB,
+ .bt_elfclass = ELFCLASS32,
+ .bt_machine = EM_MIPS,
+ },
+
+ {
+ .bt_name = "elf32-tradlittlemips",
+ .bt_type = ETF_ELF,
+ .bt_byteorder = ELFDATA2LSB,
+ .bt_elfclass = ELFCLASS32,
+ .bt_machine = EM_MIPS,
+ },
+
+ {
.bt_name = "elf64-alpha",
.bt_type = ETF_ELF,
.bt_byteorder = ELFDATA2LSB,
@@ -351,6 +367,22 @@ struct _Elftc_Bfd_Target _libelftc_targets[] = {
},
{
+ .bt_name = "elf64-tradbigmips",
+ .bt_type = ETF_ELF,
+ .bt_byteorder = ELFDATA2MSB,
+ .bt_elfclass = ELFCLASS64,
+ .bt_machine = EM_MIPS,
+ },
+
+ {
+ .bt_name = "elf64-tradlittlemips",
+ .bt_type = ETF_ELF,
+ .bt_byteorder = ELFDATA2LSB,
+ .bt_elfclass = ELFCLASS64,
+ .bt_machine = EM_MIPS,
+ },
+
+ {
.bt_name = "elf64-x86-64",
.bt_type = ETF_ELF,
.bt_byteorder = ELFDATA2LSB,
diff --git a/contrib/libarchive/NEWS b/contrib/libarchive/NEWS
index 6f16b88..7b5c31f 100644
--- a/contrib/libarchive/NEWS
+++ b/contrib/libarchive/NEWS
@@ -1,3 +1,10 @@
+Jan 29, 2017: Limited NFSv4 ACL support for Mac OS (Darwin)
+
+Jan 10, 2017: POSIX.1e and NFSv4 ACL support for Solaris and derivates
+
+Dec 27, 2016: NFSv4 ACL read and write support for pax
+ Deprecated functions: archive_entry_acl_text(), archive_entry_acl_text_w()
+
Oct 26, 2016: Remove liblzmadec support
Oct 23, 2016: libarchive 3.2.2 released
diff --git a/contrib/libarchive/cpio/cpio.c b/contrib/libarchive/cpio/cpio.c
index a7a747a..30c9ad3 100644
--- a/contrib/libarchive/cpio/cpio.c
+++ b/contrib/libarchive/cpio/cpio.c
@@ -703,6 +703,7 @@ file_to_archive(struct cpio *cpio, const char *srcpath)
lafe_warnc(0, "%s",
archive_error_string(cpio->archive_read_disk));
if (r <= ARCHIVE_FAILED) {
+ archive_entry_free(entry);
cpio->return_value = 1;
return (r);
}
diff --git a/contrib/libarchive/libarchive/archive_acl.c b/contrib/libarchive/libarchive/archive_acl.c
index 3653d6f..b8b6b63 100644
--- a/contrib/libarchive/libarchive/archive_acl.c
+++ b/contrib/libarchive/libarchive/archive_acl.c
@@ -1,5 +1,6 @@
/*-
* Copyright (c) 2003-2010 Tim Kientzle
+ * Copyright (c) 2016 Martin Matuska
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -55,25 +56,77 @@ static struct archive_acl_entry *acl_new_entry(struct archive_acl *acl,
static int archive_acl_add_entry_len_l(struct archive_acl *acl,
int type, int permset, int tag, int id, const char *name,
size_t len, struct archive_string_conv *sc);
+static int archive_acl_text_want_type(struct archive_acl *acl, int flags);
+static ssize_t archive_acl_text_len(struct archive_acl *acl, int want_type,
+ int flags, int wide, struct archive *a,
+ struct archive_string_conv *sc);
static int isint_w(const wchar_t *start, const wchar_t *end, int *result);
static int ismode_w(const wchar_t *start, const wchar_t *end, int *result);
+static int is_nfs4_flags_w(const wchar_t *start, const wchar_t *end,
+ int *result);
+static int is_nfs4_perms_w(const wchar_t *start, const wchar_t *end,
+ int *result);
static void next_field_w(const wchar_t **wp, const wchar_t **start,
const wchar_t **end, wchar_t *sep);
-static int prefix_w(const wchar_t *start, const wchar_t *end,
- const wchar_t *test);
-static void append_entry_w(wchar_t **wp, const wchar_t *prefix, int tag,
- const wchar_t *wname, int perm, int id);
+static void append_entry_w(wchar_t **wp, const wchar_t *prefix, int type,
+ int tag, int flags, const wchar_t *wname, int perm, int id);
static void append_id_w(wchar_t **wp, int id);
static int isint(const char *start, const char *end, int *result);
static int ismode(const char *start, const char *end, int *result);
+static int is_nfs4_flags(const char *start, const char *end,
+ int *result);
+static int is_nfs4_perms(const char *start, const char *end,
+ int *result);
static void next_field(const char **p, const char **start,
const char **end, char *sep);
-static int prefix_c(const char *start, const char *end,
- const char *test);
-static void append_entry(char **p, const char *prefix, int tag,
- const char *name, int perm, int id);
+static void append_entry(char **p, const char *prefix, int type,
+ int tag, int flags, const char *name, int perm, int id);
static void append_id(char **p, int id);
+static const struct {
+ const int perm;
+ const char c;
+ const wchar_t wc;
+} nfsv4_acl_perm_map[] = {
+ { ARCHIVE_ENTRY_ACL_READ_DATA | ARCHIVE_ENTRY_ACL_LIST_DIRECTORY, 'r',
+ L'r' },
+ { ARCHIVE_ENTRY_ACL_WRITE_DATA | ARCHIVE_ENTRY_ACL_ADD_FILE, 'w',
+ L'w' },
+ { ARCHIVE_ENTRY_ACL_EXECUTE, 'x', L'x' },
+ { ARCHIVE_ENTRY_ACL_APPEND_DATA | ARCHIVE_ENTRY_ACL_ADD_SUBDIRECTORY,
+ 'p', L'p' },
+ { ARCHIVE_ENTRY_ACL_DELETE, 'd', L'd' },
+ { ARCHIVE_ENTRY_ACL_DELETE_CHILD, 'D', L'D' },
+ { ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES, 'a', L'a' },
+ { ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES, 'A', L'A' },
+ { ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS, 'R', L'R' },
+ { ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS, 'W', L'W' },
+ { ARCHIVE_ENTRY_ACL_READ_ACL, 'c', L'c' },
+ { ARCHIVE_ENTRY_ACL_WRITE_ACL, 'C', L'C' },
+ { ARCHIVE_ENTRY_ACL_WRITE_OWNER, 'o', L'o' },
+ { ARCHIVE_ENTRY_ACL_SYNCHRONIZE, 's', L's' }
+};
+
+static const int nfsv4_acl_perm_map_size = (int)(sizeof(nfsv4_acl_perm_map) /
+ sizeof(nfsv4_acl_perm_map[0]));
+
+static const struct {
+ const int perm;
+ const char c;
+ const wchar_t wc;
+} nfsv4_acl_flag_map[] = {
+ { ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT, 'f', L'f' },
+ { ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT, 'd', L'd' },
+ { ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY, 'i', L'i' },
+ { ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT, 'n', L'n' },
+ { ARCHIVE_ENTRY_ACL_ENTRY_SUCCESSFUL_ACCESS, 'S', L'S' },
+ { ARCHIVE_ENTRY_ACL_ENTRY_FAILED_ACCESS, 'F', L'F' },
+ { ARCHIVE_ENTRY_ACL_ENTRY_INHERITED, 'I', L'I' }
+};
+
+static const int nfsv4_acl_flag_map_size = (int)(sizeof(nfsv4_acl_flag_map) /
+ sizeof(nfsv4_acl_flag_map[0]));
+
void
archive_acl_clear(struct archive_acl *acl)
{
@@ -340,6 +393,15 @@ archive_acl_count(struct archive_acl *acl, int want_type)
}
/*
+ * Return a bitmask of stored ACL types in an ACL list
+ */
+int
+archive_acl_types(struct archive_acl *acl)
+{
+ return (acl->acl_types);
+}
+
+/*
* Prepare for reading entries from the ACL data. Returns a count
* of entries matching "want_type", or zero if there are no
* non-extended ACL entries of that type.
@@ -375,8 +437,8 @@ archive_acl_reset(struct archive_acl *acl, int want_type)
* standard permissions and include them in the returned list.
*/
int
-archive_acl_next(struct archive *a, struct archive_acl *acl, int want_type, int *type,
- int *permset, int *tag, int *id, const char **name)
+archive_acl_next(struct archive *a, struct archive_acl *acl, int want_type,
+ int *type, int *permset, int *tag, int *id, const char **name)
{
*name = NULL;
*id = -1;
@@ -441,130 +503,273 @@ archive_acl_next(struct archive *a, struct archive_acl *acl, int want_type, int
}
/*
- * Generate a text version of the ACL. The flags parameter controls
- * the style of the generated ACL.
+ * Determine what type of ACL do we want
*/
-const wchar_t *
-archive_acl_text_w(struct archive *a, struct archive_acl *acl, int flags)
+static int
+archive_acl_text_want_type(struct archive_acl *acl, int flags)
{
- int count;
- size_t length;
- const wchar_t *wname;
- const wchar_t *prefix;
- wchar_t separator;
- struct archive_acl_entry *ap;
- int id, r;
- wchar_t *wp;
+ int want_type;
- if (acl->acl_text_w != NULL) {
- free (acl->acl_text_w);
- acl->acl_text_w = NULL;
+ /* Check if ACL is NFSv4 */
+ if ((acl->acl_types & ARCHIVE_ENTRY_ACL_TYPE_NFS4) != 0) {
+ /* NFSv4 should never mix with POSIX.1e */
+ if ((acl->acl_types & ARCHIVE_ENTRY_ACL_TYPE_POSIX1E) != 0)
+ return (0);
+ else
+ return (ARCHIVE_ENTRY_ACL_TYPE_NFS4);
}
- separator = L',';
+ /* Now deal with POSIX.1e ACLs */
+
+ want_type = 0;
+ if ((flags & ARCHIVE_ENTRY_ACL_TYPE_ACCESS) != 0)
+ want_type |= ARCHIVE_ENTRY_ACL_TYPE_ACCESS;
+ if ((flags & ARCHIVE_ENTRY_ACL_TYPE_DEFAULT) != 0)
+ want_type |= ARCHIVE_ENTRY_ACL_TYPE_DEFAULT;
+
+ /* By default we want both access and default ACLs */
+ if (want_type == 0)
+ return (ARCHIVE_ENTRY_ACL_TYPE_POSIX1E);
+
+ return (want_type);
+}
+
+/*
+ * Calculate ACL text string length
+ */
+static ssize_t
+archive_acl_text_len(struct archive_acl *acl, int want_type, int flags,
+ int wide, struct archive *a, struct archive_string_conv *sc) {
+ struct archive_acl_entry *ap;
+ const char *name;
+ const wchar_t *wname;
+ int count, idlen, tmp, r;
+ ssize_t length;
+ size_t len;
+
count = 0;
length = 0;
- ap = acl->acl_head;
- while (ap != NULL) {
- if ((ap->type & flags) != 0) {
- count++;
- if ((flags & ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT) &&
- (ap->type & ARCHIVE_ENTRY_ACL_TYPE_DEFAULT))
- length += 8; /* "default:" */
- length += 5; /* tag name */
- length += 1; /* colon */
- r = archive_mstring_get_wcs(a, &ap->name, &wname);
- if (r == 0 && wname != NULL)
- length += wcslen(wname);
- else if (r < 0 && errno == ENOMEM)
- return (NULL);
- else
- length += sizeof(uid_t) * 3 + 1;
- length ++; /* colon */
+ for (ap = acl->acl_head; ap != NULL; ap = ap->next) {
+ if ((ap->type & want_type) == 0)
+ continue;
+ /*
+ * Filemode-mapping ACL entries are stored exclusively in
+ * ap->mode so they should not be in the list
+ */
+ if ((ap->type == ARCHIVE_ENTRY_ACL_TYPE_ACCESS)
+ && (ap->tag == ARCHIVE_ENTRY_ACL_USER_OBJ
+ || ap->tag == ARCHIVE_ENTRY_ACL_GROUP_OBJ
+ || ap->tag == ARCHIVE_ENTRY_ACL_OTHER))
+ continue;
+ count++;
+ if ((want_type & ARCHIVE_ENTRY_ACL_TYPE_DEFAULT) != 0
+ && (ap->type & ARCHIVE_ENTRY_ACL_TYPE_DEFAULT) != 0)
+ length += 8; /* "default:" */
+ switch (ap->tag) {
+ case ARCHIVE_ENTRY_ACL_USER_OBJ:
+ if (want_type == ARCHIVE_ENTRY_ACL_TYPE_NFS4) {
+ length += 6; /* "owner@" */
+ break;
+ }
+ /* FALLTHROUGH */
+ case ARCHIVE_ENTRY_ACL_USER:
+ case ARCHIVE_ENTRY_ACL_MASK:
+ length += 4; /* "user", "mask" */
+ break;
+ case ARCHIVE_ENTRY_ACL_GROUP_OBJ:
+ if (want_type == ARCHIVE_ENTRY_ACL_TYPE_NFS4) {
+ length += 6; /* "group@" */
+ break;
+ }
+ /* FALLTHROUGH */
+ case ARCHIVE_ENTRY_ACL_GROUP:
+ case ARCHIVE_ENTRY_ACL_OTHER:
+ length += 5; /* "group", "other" */
+ break;
+ case ARCHIVE_ENTRY_ACL_EVERYONE:
+ length += 9; /* "everyone@" */
+ break;
+ }
+ length += 1; /* colon after tag */
+ if (ap->tag == ARCHIVE_ENTRY_ACL_USER ||
+ ap->tag == ARCHIVE_ENTRY_ACL_GROUP) {
+ if (wide) {
+ r = archive_mstring_get_wcs(a, &ap->name,
+ &wname);
+ if (r == 0 && wname != NULL)
+ length += wcslen(wname);
+ else if (r < 0 && errno == ENOMEM)
+ return (0);
+ else
+ length += sizeof(uid_t) * 3 + 1;
+ } else {
+ r = archive_mstring_get_mbs_l(&ap->name, &name,
+ &len, sc);
+ if (r != 0)
+ return (0);
+ if (len > 0 && name != NULL)
+ length += len;
+ else
+ length += sizeof(uid_t) * 3 + 1;
+ }
+ length += 1; /* colon after user or group name */
+ } else if (want_type != ARCHIVE_ENTRY_ACL_TYPE_NFS4)
+ length += 1; /* 2nd colon empty user,group or other */
+
+ if (((flags & ARCHIVE_ENTRY_ACL_STYLE_SOLARIS) != 0)
+ && ((want_type & ARCHIVE_ENTRY_ACL_TYPE_POSIX1E) != 0)
+ && (ap->tag == ARCHIVE_ENTRY_ACL_OTHER
+ || ap->tag == ARCHIVE_ENTRY_ACL_MASK)) {
+ /* Solaris has no colon after other: and mask: */
+ length = length - 1;
+ }
+
+ if (want_type == ARCHIVE_ENTRY_ACL_TYPE_NFS4) {
+ /* rwxpdDaARWcCos:fdinSFI:deny */
+ length += 27;
+ if ((ap->type & ARCHIVE_ENTRY_ACL_TYPE_DENY) == 0)
+ length += 1; /* allow, alarm, audit */
+ } else
length += 3; /* rwx */
+
+ if ((ap->tag == ARCHIVE_ENTRY_ACL_USER ||
+ ap->tag == ARCHIVE_ENTRY_ACL_GROUP) &&
+ (flags & ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID) != 0) {
length += 1; /* colon */
- length += max(sizeof(uid_t), sizeof(gid_t)) * 3 + 1;
- length ++; /* newline */
+ /* ID digit count */
+ idlen = 1;
+ tmp = ap->id;
+ while (tmp > 9) {
+ tmp = tmp / 10;
+ idlen++;
+ }
+ length += idlen;
}
- ap = ap->next;
+ length ++; /* entry separator */
}
- if (count > 0 && ((flags & ARCHIVE_ENTRY_ACL_TYPE_ACCESS) != 0)) {
- length += 10; /* "user::rwx\n" */
- length += 11; /* "group::rwx\n" */
- length += 11; /* "other::rwx\n" */
- }
+ /* Add filemode-mapping access entries to the length */
+ if ((want_type & ARCHIVE_ENTRY_ACL_TYPE_ACCESS) != 0) {
+ if ((flags & ARCHIVE_ENTRY_ACL_STYLE_SOLARIS) != 0) {
+ /* "user::rwx\ngroup::rwx\nother:rwx\n" */
+ length += 31;
+ } else {
+ /* "user::rwx\ngroup::rwx\nother::rwx\n" */
+ length += 32;
+ }
+ } else if (count == 0)
+ return (0);
+
+ /* The terminating character is included in count */
+ return (length);
+}
+
+/*
+ * Generate a wide text version of the ACL. The flags parameter controls
+ * the type and style of the generated ACL.
+ */
+wchar_t *
+archive_acl_to_text_w(struct archive_acl *acl, ssize_t *text_len, int flags,
+ struct archive *a)
+{
+ int count;
+ ssize_t length;
+ size_t len;
+ const wchar_t *wname;
+ const wchar_t *prefix;
+ wchar_t separator;
+ struct archive_acl_entry *ap;
+ int id, r, want_type;
+ wchar_t *wp, *ws;
- if (count == 0)
+ want_type = archive_acl_text_want_type(acl, flags);
+
+ /* Both NFSv4 and POSIX.1 types found */
+ if (want_type == 0)
return (NULL);
+ if (want_type == ARCHIVE_ENTRY_ACL_TYPE_POSIX1E)
+ flags |= ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT;
+
+ length = archive_acl_text_len(acl, want_type, flags, 1, a, NULL);
+
+ if (length == 0)
+ return (NULL);
+
+ if (flags & ARCHIVE_ENTRY_ACL_STYLE_SEPARATOR_COMMA)
+ separator = L',';
+ else
+ separator = L'\n';
+
/* Now, allocate the string and actually populate it. */
- wp = acl->acl_text_w = (wchar_t *)malloc(length * sizeof(wchar_t));
- if (wp == NULL)
+ wp = ws = (wchar_t *)malloc(length * sizeof(wchar_t));
+ if (wp == NULL) {
+ if (errno == ENOMEM)
+ __archive_errx(1, "No memory");
return (NULL);
+ }
count = 0;
- if ((flags & ARCHIVE_ENTRY_ACL_TYPE_ACCESS) != 0) {
- append_entry_w(&wp, NULL, ARCHIVE_ENTRY_ACL_USER_OBJ, NULL,
+
+ if ((want_type & ARCHIVE_ENTRY_ACL_TYPE_ACCESS) != 0) {
+ append_entry_w(&wp, NULL, ARCHIVE_ENTRY_ACL_TYPE_ACCESS,
+ ARCHIVE_ENTRY_ACL_USER_OBJ, flags, NULL,
acl->mode & 0700, -1);
- *wp++ = ',';
- append_entry_w(&wp, NULL, ARCHIVE_ENTRY_ACL_GROUP_OBJ, NULL,
+ *wp++ = separator;
+ append_entry_w(&wp, NULL, ARCHIVE_ENTRY_ACL_TYPE_ACCESS,
+ ARCHIVE_ENTRY_ACL_GROUP_OBJ, flags, NULL,
acl->mode & 0070, -1);
- *wp++ = ',';
- append_entry_w(&wp, NULL, ARCHIVE_ENTRY_ACL_OTHER, NULL,
+ *wp++ = separator;
+ append_entry_w(&wp, NULL, ARCHIVE_ENTRY_ACL_TYPE_ACCESS,
+ ARCHIVE_ENTRY_ACL_OTHER, flags, NULL,
acl->mode & 0007, -1);
count += 3;
-
- ap = acl->acl_head;
- while (ap != NULL) {
- if ((ap->type & ARCHIVE_ENTRY_ACL_TYPE_ACCESS) != 0) {
- r = archive_mstring_get_wcs(a, &ap->name, &wname);
- if (r == 0) {
- *wp++ = separator;
- if (flags & ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID)
- id = ap->id;
- else
- id = -1;
- append_entry_w(&wp, NULL, ap->tag, wname,
- ap->permset, id);
- count++;
- } else if (r < 0 && errno == ENOMEM)
- return (NULL);
- }
- ap = ap->next;
- }
}
-
- if ((flags & ARCHIVE_ENTRY_ACL_TYPE_DEFAULT) != 0) {
- if (flags & ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT)
+ for (ap = acl->acl_head; ap != NULL; ap = ap->next) {
+ if ((ap->type & want_type) == 0)
+ continue;
+ /*
+ * Filemode-mapping ACL entries are stored exclusively in
+ * ap->mode so they should not be in the list
+ */
+ if ((ap->type == ARCHIVE_ENTRY_ACL_TYPE_ACCESS)
+ && (ap->tag == ARCHIVE_ENTRY_ACL_USER_OBJ
+ || ap->tag == ARCHIVE_ENTRY_ACL_GROUP_OBJ
+ || ap->tag == ARCHIVE_ENTRY_ACL_OTHER))
+ continue;
+ if (ap->type == ARCHIVE_ENTRY_ACL_TYPE_DEFAULT &&
+ (flags & ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT) != 0)
prefix = L"default:";
else
prefix = NULL;
- ap = acl->acl_head;
- count = 0;
- while (ap != NULL) {
- if ((ap->type & ARCHIVE_ENTRY_ACL_TYPE_DEFAULT) != 0) {
- r = archive_mstring_get_wcs(a, &ap->name, &wname);
- if (r == 0) {
- if (count > 0)
- *wp++ = separator;
- if (flags & ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID)
- id = ap->id;
- else
- id = -1;
- append_entry_w(&wp, prefix, ap->tag,
- wname, ap->permset, id);
- count ++;
- } else if (r < 0 && errno == ENOMEM)
- return (NULL);
- }
- ap = ap->next;
- }
+ r = archive_mstring_get_wcs(a, &ap->name, &wname);
+ if (r == 0) {
+ if (count > 0)
+ *wp++ = separator;
+ if (flags & ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID)
+ id = ap->id;
+ else
+ id = -1;
+ append_entry_w(&wp, prefix, ap->type, ap->tag, flags,
+ wname, ap->permset, id);
+ count++;
+ } else if (r < 0 && errno == ENOMEM)
+ return (NULL);
}
- return (acl->acl_text_w);
-}
+ /* Add terminating character */
+ *wp++ = L'\0';
+
+ len = wcslen(ws);
+ if ((ssize_t)len > (length - 1))
+ __archive_errx(1, "Buffer overrun");
+
+ if (text_len != NULL)
+ *text_len = len;
+
+ return (ws);
+}
static void
append_id_w(wchar_t **wp, int id)
@@ -577,9 +782,11 @@ append_id_w(wchar_t **wp, int id)
}
static void
-append_entry_w(wchar_t **wp, const wchar_t *prefix, int tag,
- const wchar_t *wname, int perm, int id)
+append_entry_w(wchar_t **wp, const wchar_t *prefix, int type,
+ int tag, int flags, const wchar_t *wname, int perm, int id)
{
+ int i;
+
if (prefix != NULL) {
wcscpy(*wp, prefix);
*wp += wcslen(*wp);
@@ -588,6 +795,10 @@ append_entry_w(wchar_t **wp, const wchar_t *prefix, int tag,
case ARCHIVE_ENTRY_ACL_USER_OBJ:
wname = NULL;
id = -1;
+ if ((type & ARCHIVE_ENTRY_ACL_TYPE_NFS4) != 0) {
+ wcscpy(*wp, L"owner@");
+ break;
+ }
/* FALLTHROUGH */
case ARCHIVE_ENTRY_ACL_USER:
wcscpy(*wp, L"user");
@@ -595,6 +806,10 @@ append_entry_w(wchar_t **wp, const wchar_t *prefix, int tag,
case ARCHIVE_ENTRY_ACL_GROUP_OBJ:
wname = NULL;
id = -1;
+ if ((type & ARCHIVE_ENTRY_ACL_TYPE_NFS4) != 0) {
+ wcscpy(*wp, L"group@");
+ break;
+ }
/* FALLTHROUGH */
case ARCHIVE_ENTRY_ACL_GROUP:
wcscpy(*wp, L"group");
@@ -609,154 +824,184 @@ append_entry_w(wchar_t **wp, const wchar_t *prefix, int tag,
wname = NULL;
id = -1;
break;
+ case ARCHIVE_ENTRY_ACL_EVERYONE:
+ wcscpy(*wp, L"everyone@");
+ wname = NULL;
+ id = -1;
+ break;
}
*wp += wcslen(*wp);
*(*wp)++ = L':';
- if (wname != NULL) {
- wcscpy(*wp, wname);
+ if (((type & ARCHIVE_ENTRY_ACL_TYPE_POSIX1E) != 0) ||
+ tag == ARCHIVE_ENTRY_ACL_USER ||
+ tag == ARCHIVE_ENTRY_ACL_GROUP) {
+ if (wname != NULL) {
+ wcscpy(*wp, wname);
+ *wp += wcslen(*wp);
+ } else if (tag == ARCHIVE_ENTRY_ACL_USER
+ || tag == ARCHIVE_ENTRY_ACL_GROUP) {
+ append_id_w(wp, id);
+ if ((type & ARCHIVE_ENTRY_ACL_TYPE_NFS4) == 0)
+ id = -1;
+ }
+ /* Solaris style has no second colon after other and mask */
+ if (((flags & ARCHIVE_ENTRY_ACL_STYLE_SOLARIS) == 0)
+ || (tag != ARCHIVE_ENTRY_ACL_OTHER
+ && tag != ARCHIVE_ENTRY_ACL_MASK))
+ *(*wp)++ = L':';
+ }
+ if ((type & ARCHIVE_ENTRY_ACL_TYPE_POSIX1E) != 0) {
+ /* POSIX.1e ACL perms */
+ *(*wp)++ = (perm & 0444) ? L'r' : L'-';
+ *(*wp)++ = (perm & 0222) ? L'w' : L'-';
+ *(*wp)++ = (perm & 0111) ? L'x' : L'-';
+ } else {
+ /* NFSv4 ACL perms */
+ for (i = 0; i < nfsv4_acl_perm_map_size; i++) {
+ if (perm & nfsv4_acl_perm_map[i].perm)
+ *(*wp)++ = nfsv4_acl_perm_map[i].wc;
+ else if ((flags & ARCHIVE_ENTRY_ACL_STYLE_COMPACT) == 0)
+ *(*wp)++ = L'-';
+ }
+ *(*wp)++ = L':';
+ for (i = 0; i < nfsv4_acl_flag_map_size; i++) {
+ if (perm & nfsv4_acl_flag_map[i].perm)
+ *(*wp)++ = nfsv4_acl_flag_map[i].wc;
+ else if ((flags & ARCHIVE_ENTRY_ACL_STYLE_COMPACT) == 0)
+ *(*wp)++ = L'-';
+ }
+ *(*wp)++ = L':';
+ switch (type) {
+ case ARCHIVE_ENTRY_ACL_TYPE_ALLOW:
+ wcscpy(*wp, L"allow");
+ break;
+ case ARCHIVE_ENTRY_ACL_TYPE_DENY:
+ wcscpy(*wp, L"deny");
+ break;
+ case ARCHIVE_ENTRY_ACL_TYPE_AUDIT:
+ wcscpy(*wp, L"audit");
+ break;
+ case ARCHIVE_ENTRY_ACL_TYPE_ALARM:
+ wcscpy(*wp, L"alarm");
+ break;
+ default:
+ break;
+ }
*wp += wcslen(*wp);
- } else if (tag == ARCHIVE_ENTRY_ACL_USER
- || tag == ARCHIVE_ENTRY_ACL_GROUP) {
- append_id_w(wp, id);
- id = -1;
}
- *(*wp)++ = L':';
- *(*wp)++ = (perm & 0444) ? L'r' : L'-';
- *(*wp)++ = (perm & 0222) ? L'w' : L'-';
- *(*wp)++ = (perm & 0111) ? L'x' : L'-';
if (id != -1) {
*(*wp)++ = L':';
append_id_w(wp, id);
}
- **wp = L'\0';
}
-int
-archive_acl_text_l(struct archive_acl *acl, int flags,
- const char **acl_text, size_t *acl_text_len,
+/*
+ * Generate a text version of the ACL. The flags parameter controls
+ * the type and style of the generated ACL.
+ */
+char *
+archive_acl_to_text_l(struct archive_acl *acl, ssize_t *text_len, int flags,
struct archive_string_conv *sc)
{
int count;
- size_t length;
+ ssize_t length;
+ size_t len;
const char *name;
const char *prefix;
char separator;
struct archive_acl_entry *ap;
- size_t len;
- int id, r;
- char *p;
+ int id, r, want_type;
+ char *p, *s;
- if (acl->acl_text != NULL) {
- free (acl->acl_text);
- acl->acl_text = NULL;
- }
+ want_type = archive_acl_text_want_type(acl, flags);
- *acl_text = NULL;
- if (acl_text_len != NULL)
- *acl_text_len = 0;
- separator = ',';
- count = 0;
- length = 0;
- ap = acl->acl_head;
- while (ap != NULL) {
- if ((ap->type & flags) != 0) {
- count++;
- if ((flags & ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT) &&
- (ap->type & ARCHIVE_ENTRY_ACL_TYPE_DEFAULT))
- length += 8; /* "default:" */
- length += 5; /* tag name */
- length += 1; /* colon */
- r = archive_mstring_get_mbs_l(
- &ap->name, &name, &len, sc);
- if (r != 0)
- return (-1);
- if (len > 0 && name != NULL)
- length += len;
- else
- length += sizeof(uid_t) * 3 + 1;
- length ++; /* colon */
- length += 3; /* rwx */
- length += 1; /* colon */
- length += max(sizeof(uid_t), sizeof(gid_t)) * 3 + 1;
- length ++; /* newline */
- }
- ap = ap->next;
- }
+ /* Both NFSv4 and POSIX.1 types found */
+ if (want_type == 0)
+ return (NULL);
- if (count > 0 && ((flags & ARCHIVE_ENTRY_ACL_TYPE_ACCESS) != 0)) {
- length += 10; /* "user::rwx\n" */
- length += 11; /* "group::rwx\n" */
- length += 11; /* "other::rwx\n" */
- }
+ if (want_type == ARCHIVE_ENTRY_ACL_TYPE_POSIX1E)
+ flags |= ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT;
- if (count == 0)
- return (0);
+ length = archive_acl_text_len(acl, want_type, flags, 0, NULL, sc);
+
+ if (length == 0)
+ return (NULL);
+
+ if (flags & ARCHIVE_ENTRY_ACL_STYLE_SEPARATOR_COMMA)
+ separator = ',';
+ else
+ separator = '\n';
/* Now, allocate the string and actually populate it. */
- p = acl->acl_text = (char *)malloc(length);
- if (p == NULL)
- return (-1);
+ p = s = (char *)malloc(length * sizeof(char));
+ if (p == NULL) {
+ if (errno == ENOMEM)
+ __archive_errx(1, "No memory");
+ return (NULL);
+ }
count = 0;
- if ((flags & ARCHIVE_ENTRY_ACL_TYPE_ACCESS) != 0) {
- append_entry(&p, NULL, ARCHIVE_ENTRY_ACL_USER_OBJ, NULL,
+
+ if ((want_type & ARCHIVE_ENTRY_ACL_TYPE_ACCESS) != 0) {
+ append_entry(&p, NULL, ARCHIVE_ENTRY_ACL_TYPE_ACCESS,
+ ARCHIVE_ENTRY_ACL_USER_OBJ, flags, NULL,
acl->mode & 0700, -1);
- *p++ = ',';
- append_entry(&p, NULL, ARCHIVE_ENTRY_ACL_GROUP_OBJ, NULL,
+ *p++ = separator;
+ append_entry(&p, NULL, ARCHIVE_ENTRY_ACL_TYPE_ACCESS,
+ ARCHIVE_ENTRY_ACL_GROUP_OBJ, flags, NULL,
acl->mode & 0070, -1);
- *p++ = ',';
- append_entry(&p, NULL, ARCHIVE_ENTRY_ACL_OTHER, NULL,
+ *p++ = separator;
+ append_entry(&p, NULL, ARCHIVE_ENTRY_ACL_TYPE_ACCESS,
+ ARCHIVE_ENTRY_ACL_OTHER, flags, NULL,
acl->mode & 0007, -1);
count += 3;
-
- for (ap = acl->acl_head; ap != NULL; ap = ap->next) {
- if ((ap->type & ARCHIVE_ENTRY_ACL_TYPE_ACCESS) == 0)
- continue;
- r = archive_mstring_get_mbs_l(
- &ap->name, &name, &len, sc);
- if (r != 0)
- return (-1);
- *p++ = separator;
- if (name == NULL || (flags & ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID)) {
- id = ap->id;
- } else {
- id = -1;
- }
- append_entry(&p, NULL, ap->tag, name,
- ap->permset, id);
- count++;
- }
}
-
- if ((flags & ARCHIVE_ENTRY_ACL_TYPE_DEFAULT) != 0) {
- if (flags & ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT)
+ for (ap = acl->acl_head; ap != NULL; ap = ap->next) {
+ if ((ap->type & want_type) == 0)
+ continue;
+ /*
+ * Filemode-mapping ACL entries are stored exclusively in
+ * ap->mode so they should not be in the list
+ */
+ if ((ap->type == ARCHIVE_ENTRY_ACL_TYPE_ACCESS)
+ && (ap->tag == ARCHIVE_ENTRY_ACL_USER_OBJ
+ || ap->tag == ARCHIVE_ENTRY_ACL_GROUP_OBJ
+ || ap->tag == ARCHIVE_ENTRY_ACL_OTHER))
+ continue;
+ if (ap->type == ARCHIVE_ENTRY_ACL_TYPE_DEFAULT &&
+ (flags & ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT) != 0)
prefix = "default:";
else
prefix = NULL;
- count = 0;
- for (ap = acl->acl_head; ap != NULL; ap = ap->next) {
- if ((ap->type & ARCHIVE_ENTRY_ACL_TYPE_DEFAULT) == 0)
- continue;
- r = archive_mstring_get_mbs_l(
- &ap->name, &name, &len, sc);
- if (r != 0)
- return (-1);
- if (count > 0)
- *p++ = separator;
- if (flags & ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID)
- id = ap->id;
- else
- id = -1;
- append_entry(&p, prefix, ap->tag,
- name, ap->permset, id);
- count ++;
+ r = archive_mstring_get_mbs_l(
+ &ap->name, &name, &len, sc);
+ if (r != 0)
+ return (NULL);
+ if (count > 0)
+ *p++ = separator;
+ if (name == NULL ||
+ (flags & ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID)) {
+ id = ap->id;
+ } else {
+ id = -1;
}
+ append_entry(&p, prefix, ap->type, ap->tag, flags, name,
+ ap->permset, id);
+ count++;
}
- *acl_text = acl->acl_text;
- if (acl_text_len != NULL)
- *acl_text_len = strlen(acl->acl_text);
- return (0);
+ /* Add terminating character */
+ *p++ = '\0';
+
+ len = strlen(s);
+
+ if ((ssize_t)len > (length - 1))
+ __archive_errx(1, "Buffer overrun");
+
+ if (text_len != NULL)
+ *text_len = len;
+
+ return (s);
}
static void
@@ -770,9 +1015,11 @@ append_id(char **p, int id)
}
static void
-append_entry(char **p, const char *prefix, int tag,
- const char *name, int perm, int id)
+append_entry(char **p, const char *prefix, int type,
+ int tag, int flags, const char *name, int perm, int id)
{
+ int i;
+
if (prefix != NULL) {
strcpy(*p, prefix);
*p += strlen(*p);
@@ -781,6 +1028,10 @@ append_entry(char **p, const char *prefix, int tag,
case ARCHIVE_ENTRY_ACL_USER_OBJ:
name = NULL;
id = -1;
+ if ((type & ARCHIVE_ENTRY_ACL_TYPE_NFS4) != 0) {
+ strcpy(*p, "owner@");
+ break;
+ }
/* FALLTHROUGH */
case ARCHIVE_ENTRY_ACL_USER:
strcpy(*p, "user");
@@ -788,6 +1039,10 @@ append_entry(char **p, const char *prefix, int tag,
case ARCHIVE_ENTRY_ACL_GROUP_OBJ:
name = NULL;
id = -1;
+ if ((type & ARCHIVE_ENTRY_ACL_TYPE_NFS4) != 0) {
+ strcpy(*p, "group@");
+ break;
+ }
/* FALLTHROUGH */
case ARCHIVE_ENTRY_ACL_GROUP:
strcpy(*p, "group");
@@ -802,48 +1057,120 @@ append_entry(char **p, const char *prefix, int tag,
name = NULL;
id = -1;
break;
+ case ARCHIVE_ENTRY_ACL_EVERYONE:
+ strcpy(*p, "everyone@");
+ name = NULL;
+ id = -1;
+ break;
}
*p += strlen(*p);
*(*p)++ = ':';
- if (name != NULL) {
- strcpy(*p, name);
+ if (((type & ARCHIVE_ENTRY_ACL_TYPE_POSIX1E) != 0) ||
+ tag == ARCHIVE_ENTRY_ACL_USER ||
+ tag == ARCHIVE_ENTRY_ACL_GROUP) {
+ if (name != NULL) {
+ strcpy(*p, name);
+ *p += strlen(*p);
+ } else if (tag == ARCHIVE_ENTRY_ACL_USER
+ || tag == ARCHIVE_ENTRY_ACL_GROUP) {
+ append_id(p, id);
+ if ((type & ARCHIVE_ENTRY_ACL_TYPE_NFS4) == 0)
+ id = -1;
+ }
+ /* Solaris style has no second colon after other and mask */
+ if (((flags & ARCHIVE_ENTRY_ACL_STYLE_SOLARIS) == 0)
+ || (tag != ARCHIVE_ENTRY_ACL_OTHER
+ && tag != ARCHIVE_ENTRY_ACL_MASK))
+ *(*p)++ = ':';
+ }
+ if ((type & ARCHIVE_ENTRY_ACL_TYPE_POSIX1E) != 0) {
+ /* POSIX.1e ACL perms */
+ *(*p)++ = (perm & 0444) ? 'r' : '-';
+ *(*p)++ = (perm & 0222) ? 'w' : '-';
+ *(*p)++ = (perm & 0111) ? 'x' : '-';
+ } else {
+ /* NFSv4 ACL perms */
+ for (i = 0; i < nfsv4_acl_perm_map_size; i++) {
+ if (perm & nfsv4_acl_perm_map[i].perm)
+ *(*p)++ = nfsv4_acl_perm_map[i].c;
+ else if ((flags & ARCHIVE_ENTRY_ACL_STYLE_COMPACT) == 0)
+ *(*p)++ = '-';
+ }
+ *(*p)++ = ':';
+ for (i = 0; i < nfsv4_acl_flag_map_size; i++) {
+ if (perm & nfsv4_acl_flag_map[i].perm)
+ *(*p)++ = nfsv4_acl_flag_map[i].c;
+ else if ((flags & ARCHIVE_ENTRY_ACL_STYLE_COMPACT) == 0)
+ *(*p)++ = '-';
+ }
+ *(*p)++ = ':';
+ switch (type) {
+ case ARCHIVE_ENTRY_ACL_TYPE_ALLOW:
+ strcpy(*p, "allow");
+ break;
+ case ARCHIVE_ENTRY_ACL_TYPE_DENY:
+ strcpy(*p, "deny");
+ break;
+ case ARCHIVE_ENTRY_ACL_TYPE_AUDIT:
+ strcpy(*p, "audit");
+ break;
+ case ARCHIVE_ENTRY_ACL_TYPE_ALARM:
+ strcpy(*p, "alarm");
+ break;
+ }
*p += strlen(*p);
- } else if (tag == ARCHIVE_ENTRY_ACL_USER
- || tag == ARCHIVE_ENTRY_ACL_GROUP) {
- append_id(p, id);
- id = -1;
}
- *(*p)++ = ':';
- *(*p)++ = (perm & 0444) ? 'r' : '-';
- *(*p)++ = (perm & 0222) ? 'w' : '-';
- *(*p)++ = (perm & 0111) ? 'x' : '-';
if (id != -1) {
*(*p)++ = ':';
append_id(p, id);
}
- **p = '\0';
}
/*
- * Parse a textual ACL. This automatically recognizes and supports
- * extensions described above. The 'type' argument is used to
- * indicate the type that should be used for any entries not
- * explicitly marked as "default:".
+ * Parse a wide ACL text string.
+ *
+ * The want_type argument may be one of the following:
+ * ARCHIVE_ENTRY_ACL_TYPE_ACCESS - text is a POSIX.1e ACL of type ACCESS
+ * ARCHIVE_ENTRY_ACL_TYPE_DEFAULT - text is a POSIX.1e ACL of type DEFAULT
+ * ARCHIVE_ENTRY_ACL_TYPE_NFS4 - text is as a NFSv4 ACL
+ *
+ * POSIX.1e ACL entries prefixed with "default:" are treated as
+ * ARCHIVE_ENTRY_ACL_TYPE_DEFAULT unless type is ARCHIVE_ENTRY_ACL_TYPE_NFS4
*/
int
-archive_acl_parse_w(struct archive_acl *acl,
- const wchar_t *text, int default_type)
+archive_acl_from_text_w(struct archive_acl *acl, const wchar_t *text,
+ int want_type)
{
struct {
const wchar_t *start;
const wchar_t *end;
- } field[4], name;
+ } field[6], name;
+
+ const wchar_t *s, *st;
- int fields, n;
- int type, tag, permset, id;
+ int numfields, fields, n, r, sol, ret;
+ int type, types, tag, permset, id;
+ size_t len;
wchar_t sep;
- while (text != NULL && *text != L'\0') {
+ ret = ARCHIVE_OK;
+ types = 0;
+
+ switch (want_type) {
+ case ARCHIVE_ENTRY_ACL_TYPE_POSIX1E:
+ want_type = ARCHIVE_ENTRY_ACL_TYPE_ACCESS;
+ case ARCHIVE_ENTRY_ACL_TYPE_ACCESS:
+ case ARCHIVE_ENTRY_ACL_TYPE_DEFAULT:
+ numfields = 5;
+ break;
+ case ARCHIVE_ENTRY_ACL_TYPE_NFS4:
+ numfields = 6;
+ break;
+ default:
+ return (ARCHIVE_FATAL);
+ }
+
+ while (text != NULL && *text != L'\0') {
/*
* Parse the fields out of the next entry,
* advance 'text' to start of next entry.
@@ -852,7 +1179,7 @@ archive_acl_parse_w(struct archive_acl *acl,
do {
const wchar_t *start, *end;
next_field_w(&text, &start, &end, &sep);
- if (fields < 4) {
+ if (fields < numfields) {
field[fields].start = start;
field[fields].end = end;
}
@@ -860,78 +1187,210 @@ archive_acl_parse_w(struct archive_acl *acl,
} while (sep == L':');
/* Set remaining fields to blank. */
- for (n = fields; n < 4; ++n)
+ for (n = fields; n < numfields; ++n)
field[n].start = field[n].end = NULL;
- /* Check for a numeric ID in field 1 or 3. */
- id = -1;
- isint_w(field[1].start, field[1].end, &id);
- /* Field 3 is optional. */
- if (id == -1 && fields > 3)
- isint_w(field[3].start, field[3].end, &id);
-
- /*
- * Solaris extension: "defaultuser::rwx" is the
- * default ACL corresponding to "user::rwx", etc.
- */
- if (field[0].end - field[0].start > 7
- && wmemcmp(field[0].start, L"default", 7) == 0) {
- type = ARCHIVE_ENTRY_ACL_TYPE_DEFAULT;
- field[0].start += 7;
- } else
- type = default_type;
+ if (field[0].start != NULL && *(field[0].start) == L'#') {
+ /* Comment, skip entry */
+ continue;
+ }
+ n = 0;
+ sol = 0;
+ id = -1;
+ permset = 0;
name.start = name.end = NULL;
- if (prefix_w(field[0].start, field[0].end, L"user")) {
- if (!ismode_w(field[2].start, field[2].end, &permset))
- return (ARCHIVE_WARN);
- if (id != -1 || field[1].start < field[1].end) {
- tag = ARCHIVE_ENTRY_ACL_USER;
- name = field[1];
+
+ if (want_type != ARCHIVE_ENTRY_ACL_TYPE_NFS4) {
+ /* POSIX.1e ACLs */
+ /*
+ * Default keyword "default:user::rwx"
+ * if found, we have one more field
+ *
+ * We also support old Solaris extension:
+ * "defaultuser::rwx" is the default ACL corresponding
+ * to "user::rwx", etc. valid only for first field
+ */
+ s = field[0].start;
+ len = field[0].end - field[0].start;
+ if (*s == L'd' && (len == 1 || (len >= 7
+ && wmemcmp((s + 1), L"efault", 6) == 0))) {
+ type = ARCHIVE_ENTRY_ACL_TYPE_DEFAULT;
+ if (len > 7)
+ field[0].start += 7;
+ else
+ n = 1;
} else
- tag = ARCHIVE_ENTRY_ACL_USER_OBJ;
- } else if (prefix_w(field[0].start, field[0].end, L"group")) {
- if (!ismode_w(field[2].start, field[2].end, &permset))
- return (ARCHIVE_WARN);
- if (id != -1 || field[1].start < field[1].end) {
- tag = ARCHIVE_ENTRY_ACL_GROUP;
+ type = want_type;
+
+ /* Check for a numeric ID in field n+1 or n+3. */
+ isint_w(field[n + 1].start, field[n + 1].end, &id);
+ /* Field n+3 is optional. */
+ if (id == -1 && fields > n+3)
+ isint_w(field[n + 3].start, field[n + 3].end,
+ &id);
+
+ tag = 0;
+ s = field[n].start;
+ st = field[n].start + 1;
+ len = field[n].end - field[n].start;
+
+ switch (*s) {
+ case L'u':
+ if (len == 1 || (len == 4
+ && wmemcmp(st, L"ser", 3) == 0))
+ tag = ARCHIVE_ENTRY_ACL_USER_OBJ;
+ break;
+ case L'g':
+ if (len == 1 || (len == 5
+ && wmemcmp(st, L"roup", 4) == 0))
+ tag = ARCHIVE_ENTRY_ACL_GROUP_OBJ;
+ break;
+ case L'o':
+ if (len == 1 || (len == 5
+ && wmemcmp(st, L"ther", 4) == 0))
+ tag = ARCHIVE_ENTRY_ACL_OTHER;
+ break;
+ case L'm':
+ if (len == 1 || (len == 4
+ && wmemcmp(st, L"ask", 3) == 0))
+ tag = ARCHIVE_ENTRY_ACL_MASK;
+ break;
+ default:
+ break;
+ }
+
+ switch (tag) {
+ case ARCHIVE_ENTRY_ACL_OTHER:
+ case ARCHIVE_ENTRY_ACL_MASK:
+ if (fields == (n + 2)
+ && field[n + 1].start < field[n + 1].end
+ && ismode_w(field[n + 1].start,
+ field[n + 1].end, &permset)) {
+ /* This is Solaris-style "other:rwx" */
+ sol = 1;
+ } else if (fields == (n + 3) &&
+ field[n + 1].start < field[n + 1].end) {
+ /* Invalid mask or other field */
+ ret = ARCHIVE_WARN;
+ continue;
+ }
+ break;
+ case ARCHIVE_ENTRY_ACL_USER_OBJ:
+ case ARCHIVE_ENTRY_ACL_GROUP_OBJ:
+ if (id != -1 ||
+ field[n + 1].start < field[n + 1].end) {
+ name = field[n + 1];
+ if (tag == ARCHIVE_ENTRY_ACL_USER_OBJ)
+ tag = ARCHIVE_ENTRY_ACL_USER;
+ else
+ tag = ARCHIVE_ENTRY_ACL_GROUP;
+ }
+ break;
+ default:
+ /* Invalid tag, skip entry */
+ ret = ARCHIVE_WARN;
+ continue;
+ }
+
+ /*
+ * Without "default:" we expect mode in field 2
+ * Exception: Solaris other and mask fields
+ */
+ if (permset == 0 && !ismode_w(field[n + 2 - sol].start,
+ field[n + 2 - sol].end, &permset)) {
+ /* Invalid mode, skip entry */
+ ret = ARCHIVE_WARN;
+ continue;
+ }
+ } else {
+ /* NFS4 ACLs */
+ s = field[0].start;
+ len = field[0].end - field[0].start;
+ tag = 0;
+
+ switch (len) {
+ case 4:
+ if (wmemcmp(s, L"user", 4) == 0)
+ tag = ARCHIVE_ENTRY_ACL_USER;
+ break;
+ case 5:
+ if (wmemcmp(s, L"group", 5) == 0)
+ tag = ARCHIVE_ENTRY_ACL_GROUP;
+ break;
+ case 6:
+ if (wmemcmp(s, L"owner@", 6) == 0)
+ tag = ARCHIVE_ENTRY_ACL_USER_OBJ;
+ else if (wmemcmp(s, L"group@", len) == 0)
+ tag = ARCHIVE_ENTRY_ACL_GROUP_OBJ;
+ break;
+ case 9:
+ if (wmemcmp(s, L"everyone@", 9) == 0)
+ tag = ARCHIVE_ENTRY_ACL_EVERYONE;
+ default:
+ break;
+ }
+
+ if (tag == 0) {
+ /* Invalid tag, skip entry */
+ ret = ARCHIVE_WARN;
+ continue;
+ } else if (tag == ARCHIVE_ENTRY_ACL_USER ||
+ tag == ARCHIVE_ENTRY_ACL_GROUP) {
+ n = 1;
name = field[1];
+ isint_w(name.start, name.end, &id);
} else
- tag = ARCHIVE_ENTRY_ACL_GROUP_OBJ;
- } else if (prefix_w(field[0].start, field[0].end, L"other")) {
- if (fields == 2
- && field[1].start < field[1].end
- && ismode_w(field[1].start, field[1].end, &permset)) {
- /* This is Solaris-style "other:rwx" */
- } else if (fields == 3
- && field[1].start == field[1].end
- && field[2].start < field[2].end
- && ismode_w(field[2].start, field[2].end, &permset)) {
- /* This is FreeBSD-style "other::rwx" */
- } else
- return (ARCHIVE_WARN);
- tag = ARCHIVE_ENTRY_ACL_OTHER;
- } else if (prefix_w(field[0].start, field[0].end, L"mask")) {
- if (fields == 2
- && field[1].start < field[1].end
- && ismode_w(field[1].start, field[1].end, &permset)) {
- /* This is Solaris-style "mask:rwx" */
- } else if (fields == 3
- && field[1].start == field[1].end
- && field[2].start < field[2].end
- && ismode_w(field[2].start, field[2].end, &permset)) {
- /* This is FreeBSD-style "mask::rwx" */
- } else
- return (ARCHIVE_WARN);
- tag = ARCHIVE_ENTRY_ACL_MASK;
- } else
- return (ARCHIVE_WARN);
+ n = 0;
+
+ if (!is_nfs4_perms_w(field[1 + n].start,
+ field[1 + n].end, &permset)) {
+ /* Invalid NFSv4 perms, skip entry */
+ ret = ARCHIVE_WARN;
+ continue;
+ }
+ if (!is_nfs4_flags_w(field[2 + n].start,
+ field[2 + n].end, &permset)) {
+ /* Invalid NFSv4 flags, skip entry */
+ ret = ARCHIVE_WARN;
+ continue;
+ }
+ s = field[3 + n].start;
+ len = field[3 + n].end - field[3 + n].start;
+ type = 0;
+ if (len == 4) {
+ if (wmemcmp(s, L"deny", 4) == 0)
+ type = ARCHIVE_ENTRY_ACL_TYPE_DENY;
+ } else if (len == 5) {
+ if (wmemcmp(s, L"allow", 5) == 0)
+ type = ARCHIVE_ENTRY_ACL_TYPE_ALLOW;
+ else if (wmemcmp(s, L"audit", 5) == 0)
+ type = ARCHIVE_ENTRY_ACL_TYPE_AUDIT;
+ else if (wmemcmp(s, L"alarm", 5) == 0)
+ type = ARCHIVE_ENTRY_ACL_TYPE_ALARM;
+ }
+ if (type == 0) {
+ /* Invalid entry type, skip entry */
+ ret = ARCHIVE_WARN;
+ continue;
+ }
+ isint_w(field[4 + n].start, field[4 + n].end, &id);
+ }
/* Add entry to the internal list. */
- archive_acl_add_entry_w_len(acl, type, permset,
+ r = archive_acl_add_entry_w_len(acl, type, permset,
tag, id, name.start, name.end - name.start);
+ if (r < ARCHIVE_WARN)
+ return (r);
+ if (r != ARCHIVE_OK)
+ ret = ARCHIVE_WARN;
+ types |= type;
}
- return (ARCHIVE_OK);
+
+ /* Reset ACL */
+ archive_acl_reset(acl, types);
+
+ return (ret);
}
/*
@@ -977,16 +1436,122 @@ ismode_w(const wchar_t *start, const wchar_t *end, int *permset)
*permset = 0;
while (p < end) {
switch (*p++) {
- case 'r': case 'R':
+ case L'r': case L'R':
*permset |= ARCHIVE_ENTRY_ACL_READ;
break;
- case 'w': case 'W':
+ case L'w': case L'W':
*permset |= ARCHIVE_ENTRY_ACL_WRITE;
break;
- case 'x': case 'X':
+ case L'x': case L'X':
*permset |= ARCHIVE_ENTRY_ACL_EXECUTE;
break;
- case '-':
+ case L'-':
+ break;
+ default:
+ return (0);
+ }
+ }
+ return (1);
+}
+
+/*
+ * Parse a string as a NFS4 ACL permission field.
+ * Returns true if the string is non-empty and consists only of NFS4 ACL
+ * permission characters, false otherwise
+ */
+static int
+is_nfs4_perms_w(const wchar_t *start, const wchar_t *end, int *permset)
+{
+ const wchar_t *p = start;
+
+ while (p < end) {
+ switch (*p++) {
+ case L'r':
+ *permset |= ARCHIVE_ENTRY_ACL_READ_DATA;
+ break;
+ case L'w':
+ *permset |= ARCHIVE_ENTRY_ACL_WRITE_DATA;
+ break;
+ case L'x':
+ *permset |= ARCHIVE_ENTRY_ACL_EXECUTE;
+ break;
+ case L'p':
+ *permset |= ARCHIVE_ENTRY_ACL_APPEND_DATA;
+ break;
+ case L'D':
+ *permset |= ARCHIVE_ENTRY_ACL_DELETE_CHILD;
+ break;
+ case L'd':
+ *permset |= ARCHIVE_ENTRY_ACL_DELETE;
+ break;
+ case L'a':
+ *permset |= ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES;
+ break;
+ case L'A':
+ *permset |= ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES;
+ break;
+ case L'R':
+ *permset |= ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS;
+ break;
+ case L'W':
+ *permset |= ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS;
+ break;
+ case L'c':
+ *permset |= ARCHIVE_ENTRY_ACL_READ_ACL;
+ break;
+ case L'C':
+ *permset |= ARCHIVE_ENTRY_ACL_WRITE_ACL;
+ break;
+ case L'o':
+ *permset |= ARCHIVE_ENTRY_ACL_WRITE_OWNER;
+ break;
+ case L's':
+ *permset |= ARCHIVE_ENTRY_ACL_SYNCHRONIZE;
+ break;
+ case L'-':
+ break;
+ default:
+ return(0);
+ }
+ }
+ return (1);
+}
+
+/*
+ * Parse a string as a NFS4 ACL flags field.
+ * Returns true if the string is non-empty and consists only of NFS4 ACL
+ * flag characters, false otherwise
+ */
+static int
+is_nfs4_flags_w(const wchar_t *start, const wchar_t *end, int *permset)
+{
+ const wchar_t *p = start;
+
+ while (p < end) {
+ switch(*p++) {
+ case L'f':
+ *permset |= ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT;
+ break;
+ case L'd':
+ *permset |= ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT;
+ break;
+ case L'i':
+ *permset |= ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY;
+ break;
+ case L'n':
+ *permset |=
+ ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT;
+ break;
+ case L'S':
+ *permset |= ARCHIVE_ENTRY_ACL_ENTRY_SUCCESSFUL_ACCESS;
+ break;
+ case L'F':
+ *permset |= ARCHIVE_ENTRY_ACL_ENTRY_FAILED_ACCESS;
+ break;
+ case L'I':
+ *permset |= ARCHIVE_ENTRY_ACL_ENTRY_INHERITED;
+ break;
+ case L'-':
break;
default:
return (0);
@@ -1033,46 +1598,48 @@ next_field_w(const wchar_t **wp, const wchar_t **start,
}
/*
- * Return true if the characters [start...end) are a prefix of 'test'.
- * This makes it easy to handle the obvious abbreviations: 'u' for 'user', etc.
- */
-static int
-prefix_w(const wchar_t *start, const wchar_t *end, const wchar_t *test)
-{
- if (start == end)
- return (0);
-
- if (*start++ != *test++)
- return (0);
-
- while (start < end && *start++ == *test++)
- ;
-
- if (start < end)
- return (0);
-
- return (1);
-}
-
-/*
- * Parse a textual ACL. This automatically recognizes and supports
- * extensions described above. The 'type' argument is used to
- * indicate the type that should be used for any entries not
- * explicitly marked as "default:".
+ * Parse an ACL text string.
+ *
+ * The want_type argument may be one of the following:
+ * ARCHIVE_ENTRY_ACL_TYPE_ACCESS - text is a POSIX.1e ACL of type ACCESS
+ * ARCHIVE_ENTRY_ACL_TYPE_DEFAULT - text is a POSIX.1e ACL of type DEFAULT
+ * ARCHIVE_ENTRY_ACL_TYPE_NFS4 - text is as a NFSv4 ACL
+ *
+ * POSIX.1e ACL entries prefixed with "default:" are treated as
+ * ARCHIVE_ENTRY_ACL_TYPE_DEFAULT unless type is ARCHIVE_ENTRY_ACL_TYPE_NFS4
*/
int
-archive_acl_parse_l(struct archive_acl *acl,
- const char *text, int default_type, struct archive_string_conv *sc)
+archive_acl_from_text_l(struct archive_acl *acl, const char *text,
+ int want_type, struct archive_string_conv *sc)
{
struct {
const char *start;
const char *end;
- } field[4], name;
+ } field[6], name;
- int fields, n, r, ret = ARCHIVE_OK;
- int type, tag, permset, id;
+ const char *s, *st;
+ int numfields, fields, n, r, sol, ret;
+ int type, types, tag, permset, id;
+ size_t len;
char sep;
+ switch (want_type) {
+ case ARCHIVE_ENTRY_ACL_TYPE_POSIX1E:
+ want_type = ARCHIVE_ENTRY_ACL_TYPE_ACCESS;
+ case ARCHIVE_ENTRY_ACL_TYPE_ACCESS:
+ case ARCHIVE_ENTRY_ACL_TYPE_DEFAULT:
+ numfields = 5;
+ break;
+ case ARCHIVE_ENTRY_ACL_TYPE_NFS4:
+ numfields = 6;
+ break;
+ default:
+ return (ARCHIVE_FATAL);
+ }
+
+ ret = ARCHIVE_OK;
+ types = 0;
+
while (text != NULL && *text != '\0') {
/*
* Parse the fields out of the next entry,
@@ -1082,7 +1649,7 @@ archive_acl_parse_l(struct archive_acl *acl,
do {
const char *start, *end;
next_field(&text, &start, &end, &sep);
- if (fields < 4) {
+ if (fields < numfields) {
field[fields].start = start;
field[fields].end = end;
}
@@ -1090,72 +1657,197 @@ archive_acl_parse_l(struct archive_acl *acl,
} while (sep == ':');
/* Set remaining fields to blank. */
- for (n = fields; n < 4; ++n)
+ for (n = fields; n < numfields; ++n)
field[n].start = field[n].end = NULL;
- /* Check for a numeric ID in field 1 or 3. */
- id = -1;
- isint(field[1].start, field[1].end, &id);
- /* Field 3 is optional. */
- if (id == -1 && fields > 3)
- isint(field[3].start, field[3].end, &id);
-
- /*
- * Solaris extension: "defaultuser::rwx" is the
- * default ACL corresponding to "user::rwx", etc.
- */
- if (field[0].end - field[0].start > 7
- && memcmp(field[0].start, "default", 7) == 0) {
- type = ARCHIVE_ENTRY_ACL_TYPE_DEFAULT;
- field[0].start += 7;
- } else
- type = default_type;
+ if (field[0].start != NULL && *(field[0].start) == '#') {
+ /* Comment, skip entry */
+ continue;
+ }
+ n = 0;
+ sol = 0;
+ id = -1;
+ permset = 0;
name.start = name.end = NULL;
- if (prefix_c(field[0].start, field[0].end, "user")) {
- if (!ismode(field[2].start, field[2].end, &permset))
- return (ARCHIVE_WARN);
- if (id != -1 || field[1].start < field[1].end) {
- tag = ARCHIVE_ENTRY_ACL_USER;
- name = field[1];
+
+ if (want_type != ARCHIVE_ENTRY_ACL_TYPE_NFS4) {
+ /* POSIX.1e ACLs */
+ /*
+ * Default keyword "default:user::rwx"
+ * if found, we have one more field
+ *
+ * We also support old Solaris extension:
+ * "defaultuser::rwx" is the default ACL corresponding
+ * to "user::rwx", etc. valid only for first field
+ */
+ s = field[0].start;
+ len = field[0].end - field[0].start;
+ if (*s == 'd' && (len == 1 || (len >= 7
+ && memcmp((s + 1), "efault", 6) == 0))) {
+ type = ARCHIVE_ENTRY_ACL_TYPE_DEFAULT;
+ if (len > 7)
+ field[0].start += 7;
+ else
+ n = 1;
} else
- tag = ARCHIVE_ENTRY_ACL_USER_OBJ;
- } else if (prefix_c(field[0].start, field[0].end, "group")) {
- if (!ismode(field[2].start, field[2].end, &permset))
- return (ARCHIVE_WARN);
- if (id != -1 || field[1].start < field[1].end) {
- tag = ARCHIVE_ENTRY_ACL_GROUP;
+ type = want_type;
+
+ /* Check for a numeric ID in field n+1 or n+3. */
+ isint(field[n + 1].start, field[n + 1].end, &id);
+ /* Field n+3 is optional. */
+ if (id == -1 && fields > (n + 3))
+ isint(field[n + 3].start, field[n + 3].end,
+ &id);
+
+ tag = 0;
+ s = field[n].start;
+ st = field[n].start + 1;
+ len = field[n].end - field[n].start;
+
+ switch (*s) {
+ case 'u':
+ if (len == 1 || (len == 4
+ && memcmp(st, "ser", 3) == 0))
+ tag = ARCHIVE_ENTRY_ACL_USER_OBJ;
+ break;
+ case 'g':
+ if (len == 1 || (len == 5
+ && memcmp(st, "roup", 4) == 0))
+ tag = ARCHIVE_ENTRY_ACL_GROUP_OBJ;
+ break;
+ case 'o':
+ if (len == 1 || (len == 5
+ && memcmp(st, "ther", 4) == 0))
+ tag = ARCHIVE_ENTRY_ACL_OTHER;
+ break;
+ case 'm':
+ if (len == 1 || (len == 4
+ && memcmp(st, "ask", 3) == 0))
+ tag = ARCHIVE_ENTRY_ACL_MASK;
+ break;
+ default:
+ break;
+ }
+
+ switch (tag) {
+ case ARCHIVE_ENTRY_ACL_OTHER:
+ case ARCHIVE_ENTRY_ACL_MASK:
+ if (fields == (n + 2)
+ && field[n + 1].start < field[n + 1].end
+ && ismode(field[n + 1].start,
+ field[n + 1].end, &permset)) {
+ /* This is Solaris-style "other:rwx" */
+ sol = 1;
+ } else if (fields == (n + 3) &&
+ field[n + 1].start < field[n + 1].end) {
+ /* Invalid mask or other field */
+ ret = ARCHIVE_WARN;
+ continue;
+ }
+ break;
+ case ARCHIVE_ENTRY_ACL_USER_OBJ:
+ case ARCHIVE_ENTRY_ACL_GROUP_OBJ:
+ if (id != -1 ||
+ field[n + 1].start < field[n + 1].end) {
+ name = field[n + 1];
+ if (tag == ARCHIVE_ENTRY_ACL_USER_OBJ)
+ tag = ARCHIVE_ENTRY_ACL_USER;
+ else
+ tag = ARCHIVE_ENTRY_ACL_GROUP;
+ }
+ break;
+ default:
+ /* Invalid tag, skip entry */
+ ret = ARCHIVE_WARN;
+ continue;
+ }
+
+ /*
+ * Without "default:" we expect mode in field 3
+ * Exception: Solaris other and mask fields
+ */
+ if (permset == 0 && !ismode(field[n + 2 - sol].start,
+ field[n + 2 - sol].end, &permset)) {
+ /* Invalid mode, skip entry */
+ ret = ARCHIVE_WARN;
+ continue;
+ }
+ } else {
+ /* NFS4 ACLs */
+ s = field[0].start;
+ len = field[0].end - field[0].start;
+ tag = 0;
+
+ switch (len) {
+ case 4:
+ if (memcmp(s, "user", 4) == 0)
+ tag = ARCHIVE_ENTRY_ACL_USER;
+ break;
+ case 5:
+ if (memcmp(s, "group", 5) == 0)
+ tag = ARCHIVE_ENTRY_ACL_GROUP;
+ break;
+ case 6:
+ if (memcmp(s, "owner@", 6) == 0)
+ tag = ARCHIVE_ENTRY_ACL_USER_OBJ;
+ else if (memcmp(s, "group@", 6) == 0)
+ tag = ARCHIVE_ENTRY_ACL_GROUP_OBJ;
+ break;
+ case 9:
+ if (memcmp(s, "everyone@", 9) == 0)
+ tag = ARCHIVE_ENTRY_ACL_EVERYONE;
+ break;
+ default:
+ break;
+ }
+
+ if (tag == 0) {
+ /* Invalid tag, skip entry */
+ ret = ARCHIVE_WARN;
+ continue;
+ } else if (tag == ARCHIVE_ENTRY_ACL_USER ||
+ tag == ARCHIVE_ENTRY_ACL_GROUP) {
+ n = 1;
name = field[1];
+ isint(name.start, name.end, &id);
} else
- tag = ARCHIVE_ENTRY_ACL_GROUP_OBJ;
- } else if (prefix_c(field[0].start, field[0].end, "other")) {
- if (fields == 2
- && field[1].start < field[1].end
- && ismode(field[1].start, field[1].end, &permset)) {
- /* This is Solaris-style "other:rwx" */
- } else if (fields == 3
- && field[1].start == field[1].end
- && field[2].start < field[2].end
- && ismode(field[2].start, field[2].end, &permset)) {
- /* This is FreeBSD-style "other::rwx" */
- } else
- return (ARCHIVE_WARN);
- tag = ARCHIVE_ENTRY_ACL_OTHER;
- } else if (prefix_c(field[0].start, field[0].end, "mask")) {
- if (fields == 2
- && field[1].start < field[1].end
- && ismode(field[1].start, field[1].end, &permset)) {
- /* This is Solaris-style "mask:rwx" */
- } else if (fields == 3
- && field[1].start == field[1].end
- && field[2].start < field[2].end
- && ismode(field[2].start, field[2].end, &permset)) {
- /* This is FreeBSD-style "mask::rwx" */
- } else
- return (ARCHIVE_WARN);
- tag = ARCHIVE_ENTRY_ACL_MASK;
- } else
- return (ARCHIVE_WARN);
+ n = 0;
+
+ if (!is_nfs4_perms(field[1 + n].start,
+ field[1 + n].end, &permset)) {
+ /* Invalid NFSv4 perms, skip entry */
+ ret = ARCHIVE_WARN;
+ continue;
+ }
+ if (!is_nfs4_flags(field[2 + n].start,
+ field[2 + n].end, &permset)) {
+ /* Invalid NFSv4 flags, skip entry */
+ ret = ARCHIVE_WARN;
+ continue;
+ }
+ s = field[3 + n].start;
+ len = field[3 + n].end - field[3 + n].start;
+ type = 0;
+ if (len == 4) {
+ if (memcmp(s, "deny", 4) == 0)
+ type = ARCHIVE_ENTRY_ACL_TYPE_DENY;
+ } else if (len == 5) {
+ if (memcmp(s, "allow", 5) == 0)
+ type = ARCHIVE_ENTRY_ACL_TYPE_ALLOW;
+ else if (memcmp(s, "audit", 5) == 0)
+ type = ARCHIVE_ENTRY_ACL_TYPE_AUDIT;
+ else if (memcmp(s, "alarm", 5) == 0)
+ type = ARCHIVE_ENTRY_ACL_TYPE_ALARM;
+ }
+ if (type == 0) {
+ /* Invalid entry type, skip entry */
+ ret = ARCHIVE_WARN;
+ continue;
+ }
+ isint(field[4 + n].start, field[4 + n].end,
+ &id);
+ }
/* Add entry to the internal list. */
r = archive_acl_add_entry_len_l(acl, type, permset,
@@ -1164,7 +1856,12 @@ archive_acl_parse_l(struct archive_acl *acl,
return (r);
if (r != ARCHIVE_OK)
ret = ARCHIVE_WARN;
+ types |= type;
}
+
+ /* Reset ACL */
+ archive_acl_reset(acl, types);
+
return (ret);
}
@@ -1230,6 +1927,112 @@ ismode(const char *start, const char *end, int *permset)
}
/*
+ * Parse a string as a NFS4 ACL permission field.
+ * Returns true if the string is non-empty and consists only of NFS4 ACL
+ * permission characters, false otherwise
+ */
+static int
+is_nfs4_perms(const char *start, const char *end, int *permset)
+{
+ const char *p = start;
+
+ while (p < end) {
+ switch (*p++) {
+ case 'r':
+ *permset |= ARCHIVE_ENTRY_ACL_READ_DATA;
+ break;
+ case 'w':
+ *permset |= ARCHIVE_ENTRY_ACL_WRITE_DATA;
+ break;
+ case 'x':
+ *permset |= ARCHIVE_ENTRY_ACL_EXECUTE;
+ break;
+ case 'p':
+ *permset |= ARCHIVE_ENTRY_ACL_APPEND_DATA;
+ break;
+ case 'D':
+ *permset |= ARCHIVE_ENTRY_ACL_DELETE_CHILD;
+ break;
+ case 'd':
+ *permset |= ARCHIVE_ENTRY_ACL_DELETE;
+ break;
+ case 'a':
+ *permset |= ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES;
+ break;
+ case 'A':
+ *permset |= ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES;
+ break;
+ case 'R':
+ *permset |= ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS;
+ break;
+ case 'W':
+ *permset |= ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS;
+ break;
+ case 'c':
+ *permset |= ARCHIVE_ENTRY_ACL_READ_ACL;
+ break;
+ case 'C':
+ *permset |= ARCHIVE_ENTRY_ACL_WRITE_ACL;
+ break;
+ case 'o':
+ *permset |= ARCHIVE_ENTRY_ACL_WRITE_OWNER;
+ break;
+ case 's':
+ *permset |= ARCHIVE_ENTRY_ACL_SYNCHRONIZE;
+ break;
+ case '-':
+ break;
+ default:
+ return(0);
+ }
+ }
+ return (1);
+}
+
+/*
+ * Parse a string as a NFS4 ACL flags field.
+ * Returns true if the string is non-empty and consists only of NFS4 ACL
+ * flag characters, false otherwise
+ */
+static int
+is_nfs4_flags(const char *start, const char *end, int *permset)
+{
+ const char *p = start;
+
+ while (p < end) {
+ switch(*p++) {
+ case 'f':
+ *permset |= ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT;
+ break;
+ case 'd':
+ *permset |= ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT;
+ break;
+ case 'i':
+ *permset |= ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY;
+ break;
+ case 'n':
+ *permset |=
+ ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT;
+ break;
+ case 'S':
+ *permset |= ARCHIVE_ENTRY_ACL_ENTRY_SUCCESSFUL_ACCESS;
+ break;
+ case 'F':
+ *permset |= ARCHIVE_ENTRY_ACL_ENTRY_FAILED_ACCESS;
+ break;
+ case 'I':
+ *permset |= ARCHIVE_ENTRY_ACL_ENTRY_INHERITED;
+ break;
+ case '-':
+ break;
+ default:
+ return (0);
+ }
+ }
+ return (1);
+}
+
+/*
* Match "[:whitespace:]*(.*)[:whitespace:]*[:,\n]". *wp is updated
* to point to just after the separator. *start points to the first
* character of the matched text and *end just after the last
@@ -1264,25 +2067,3 @@ next_field(const char **p, const char **start,
if (**p != '\0')
(*p)++;
}
-
-/*
- * Return true if the characters [start...end) are a prefix of 'test'.
- * This makes it easy to handle the obvious abbreviations: 'u' for 'user', etc.
- */
-static int
-prefix_c(const char *start, const char *end, const char *test)
-{
- if (start == end)
- return (0);
-
- if (*start++ != *test++)
- return (0);
-
- while (start < end && *start++ == *test++)
- ;
-
- if (start < end)
- return (0);
-
- return (1);
-}
diff --git a/contrib/libarchive/libarchive/archive_acl_private.h b/contrib/libarchive/libarchive/archive_acl_private.h
index 1421adb..ef0b023 100644
--- a/contrib/libarchive/libarchive/archive_acl_private.h
+++ b/contrib/libarchive/libarchive/archive_acl_private.h
@@ -56,6 +56,7 @@ struct archive_acl {
void archive_acl_clear(struct archive_acl *);
void archive_acl_copy(struct archive_acl *, struct archive_acl *);
int archive_acl_count(struct archive_acl *, int);
+int archive_acl_types(struct archive_acl *);
int archive_acl_reset(struct archive_acl *, int);
int archive_acl_next(struct archive *, struct archive_acl *, int,
int *, int *, int *, int *, const char **);
@@ -66,22 +67,17 @@ int archive_acl_add_entry_w_len(struct archive_acl *,
int archive_acl_add_entry_len(struct archive_acl *,
int, int, int, int, const char *, size_t);
-const wchar_t *archive_acl_text_w(struct archive *, struct archive_acl *, int);
-int archive_acl_text_l(struct archive_acl *, int, const char **, size_t *,
+wchar_t *archive_acl_to_text_w(struct archive_acl *, ssize_t *, int,
+ struct archive *);
+char *archive_acl_to_text_l(struct archive_acl *, ssize_t *, int,
struct archive_string_conv *);
/*
- * Private ACL parser. This is private because it handles some
- * very weird formats that clients should not be messing with.
- * Clients should only deal with their platform-native formats.
- * Because of the need to support many formats cleanly, new arguments
- * are likely to get added on a regular basis. Clients who try to use
- * this interface are likely to be surprised when it changes.
+ * ACL text parser.
*/
-int archive_acl_parse_w(struct archive_acl *,
- const wchar_t *, int /* type */);
-int archive_acl_parse_l(struct archive_acl *,
- const char *, int /* type */,
- struct archive_string_conv *);
+int archive_acl_from_text_w(struct archive_acl *, const wchar_t * /* wtext */,
+ int /* type */);
+int archive_acl_from_text_l(struct archive_acl *, const char * /* text */,
+ int /* type */, struct archive_string_conv *);
#endif /* ARCHIVE_ENTRY_PRIVATE_H_INCLUDED */
diff --git a/contrib/libarchive/libarchive/archive_entry.c b/contrib/libarchive/libarchive/archive_entry.c
index f240025..556c402 100644
--- a/contrib/libarchive/libarchive/archive_entry.c
+++ b/contrib/libarchive/libarchive/archive_entry.c
@@ -1,5 +1,6 @@
/*-
* Copyright (c) 2003-2007 Tim Kientzle
+ * Copyright (c) 2016 Martin Matuska
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -1446,7 +1447,7 @@ archive_entry_acl_add_entry_w(struct archive_entry *entry,
int
archive_entry_acl_types(struct archive_entry *entry)
{
- return ((&entry->acl)->acl_types);
+ return (archive_acl_types(&entry->acl));
}
/*
@@ -1486,34 +1487,121 @@ archive_entry_acl_next(struct archive_entry *entry, int want_type, int *type,
}
/*
- * Generate a text version of the ACL. The flags parameter controls
+ * Generate a text version of the ACL. The flags parameter controls
* the style of the generated ACL.
*/
+wchar_t *
+archive_entry_acl_to_text_w(struct archive_entry *entry, ssize_t *len,
+ int flags)
+{
+ return (archive_acl_to_text_w(&entry->acl, len, flags,
+ entry->archive));
+}
+
+char *
+archive_entry_acl_to_text(struct archive_entry *entry, ssize_t *len,
+ int flags)
+{
+ return (archive_acl_to_text_l(&entry->acl, len, flags, NULL));
+}
+
+char *
+_archive_entry_acl_to_text_l(struct archive_entry *entry, ssize_t *len,
+ int flags, struct archive_string_conv *sc)
+{
+ return (archive_acl_to_text_l(&entry->acl, len, flags, sc));
+}
+
+/*
+ * ACL text parser.
+ */
+int
+archive_entry_acl_from_text_w(struct archive_entry *entry,
+ const wchar_t *wtext, int type)
+{
+ return (archive_acl_from_text_w(&entry->acl, wtext, type));
+}
+
+int
+archive_entry_acl_from_text(struct archive_entry *entry,
+ const char *text, int type)
+{
+ return (archive_acl_from_text_l(&entry->acl, text, type, NULL));
+}
+
+int
+_archive_entry_acl_from_text_l(struct archive_entry *entry, const char *text,
+ int type, struct archive_string_conv *sc)
+{
+ return (archive_acl_from_text_l(&entry->acl, text, type, sc));
+}
+
+/* Deprecated */
+static int
+archive_entry_acl_text_compat(int *flags)
+{
+ if ((*flags & ARCHIVE_ENTRY_ACL_TYPE_POSIX1E) == 0)
+ return (1);
+
+ /* ABI compat with old ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID */
+ if ((*flags & OLD_ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID) != 0)
+ *flags |= ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID;
+
+ /* ABI compat with old ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT */
+ if ((*flags & OLD_ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT) != 0)
+ *flags |= ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT;
+
+ *flags |= ARCHIVE_ENTRY_ACL_STYLE_SEPARATOR_COMMA;
+
+ return (0);
+}
+
+/* Deprecated */
const wchar_t *
archive_entry_acl_text_w(struct archive_entry *entry, int flags)
{
- const wchar_t *r;
- r = archive_acl_text_w(entry->archive, &entry->acl, flags);
- if (r == NULL && errno == ENOMEM)
- __archive_errx(1, "No memory");
- return (r);
+ if (entry->acl.acl_text_w != NULL) {
+ free(entry->acl.acl_text_w);
+ entry->acl.acl_text_w = NULL;
+ }
+ if (archive_entry_acl_text_compat(&flags) == 0)
+ entry->acl.acl_text_w = archive_acl_to_text_w(&entry->acl,
+ NULL, flags, entry->archive);
+ return (entry->acl.acl_text_w);
}
+/* Deprecated */
const char *
archive_entry_acl_text(struct archive_entry *entry, int flags)
{
- const char *p;
- if (archive_acl_text_l(&entry->acl, flags, &p, NULL, NULL) != 0
- && errno == ENOMEM)
- __archive_errx(1, "No memory");
- return (p);
+ if (entry->acl.acl_text != NULL) {
+ free(entry->acl.acl_text);
+ entry->acl.acl_text = NULL;
+ }
+ if (archive_entry_acl_text_compat(&flags) == 0)
+ entry->acl.acl_text = archive_acl_to_text_l(&entry->acl, NULL,
+ flags, NULL);
+
+ return (entry->acl.acl_text);
}
+/* Deprecated */
int
_archive_entry_acl_text_l(struct archive_entry *entry, int flags,
const char **acl_text, size_t *len, struct archive_string_conv *sc)
{
- return (archive_acl_text_l(&entry->acl, flags, acl_text, len, sc));
+ if (entry->acl.acl_text != NULL) {
+ free(entry->acl.acl_text);
+ entry->acl.acl_text = NULL;
+ }
+
+ if (archive_entry_acl_text_compat(&flags) == 0)
+ entry->acl.acl_text = archive_acl_to_text_l(&entry->acl,
+ (ssize_t *)len, flags, sc);
+
+ *acl_text = entry->acl.acl_text;
+
+ return (0);
}
/*
diff --git a/contrib/libarchive/libarchive/archive_entry.h b/contrib/libarchive/libarchive/archive_entry.h
index 27c473e..40d6afb 100644
--- a/contrib/libarchive/libarchive/archive_entry.h
+++ b/contrib/libarchive/libarchive/archive_entry.h
@@ -1,5 +1,6 @@
/*-
* Copyright (c) 2003-2008 Tim Kientzle
+ * Copyright (c) 2016 Martin Matuska
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -104,6 +105,12 @@ typedef int64_t la_int64_t;
# define __LA_DECL
#endif
+#if defined(__GNUC__) && __GNUC__ >= 3 && __GNUC_MINOR__ >= 1
+# define __LA_DEPRECATED __attribute__((deprecated))
+#else
+# define __LA_DEPRECATED
+#endif
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -420,6 +427,7 @@ __LA_DECL void archive_entry_copy_mac_metadata(struct archive_entry *, const voi
/*
* Inheritance values (NFS4 ACLs only); included in permset.
*/
+#define ARCHIVE_ENTRY_ACL_ENTRY_INHERITED 0x01000000
#define ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT 0x02000000
#define ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT 0x04000000
#define ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT 0x08000000
@@ -433,15 +441,16 @@ __LA_DECL void archive_entry_copy_mac_metadata(struct archive_entry *, const voi
| ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT \
| ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY \
| ARCHIVE_ENTRY_ACL_ENTRY_SUCCESSFUL_ACCESS \
- | ARCHIVE_ENTRY_ACL_ENTRY_FAILED_ACCESS)
+ | ARCHIVE_ENTRY_ACL_ENTRY_FAILED_ACCESS \
+ | ARCHIVE_ENTRY_ACL_ENTRY_INHERITED)
/* We need to be able to specify combinations of these. */
-#define ARCHIVE_ENTRY_ACL_TYPE_ACCESS 256 /* POSIX.1e only */
-#define ARCHIVE_ENTRY_ACL_TYPE_DEFAULT 512 /* POSIX.1e only */
-#define ARCHIVE_ENTRY_ACL_TYPE_ALLOW 1024 /* NFS4 only */
-#define ARCHIVE_ENTRY_ACL_TYPE_DENY 2048 /* NFS4 only */
-#define ARCHIVE_ENTRY_ACL_TYPE_AUDIT 4096 /* NFS4 only */
-#define ARCHIVE_ENTRY_ACL_TYPE_ALARM 8192 /* NFS4 only */
+#define ARCHIVE_ENTRY_ACL_TYPE_ACCESS 0x00000100 /* POSIX.1e only */
+#define ARCHIVE_ENTRY_ACL_TYPE_DEFAULT 0x00000200 /* POSIX.1e only */
+#define ARCHIVE_ENTRY_ACL_TYPE_ALLOW 0x00000400 /* NFS4 only */
+#define ARCHIVE_ENTRY_ACL_TYPE_DENY 0x00000800 /* NFS4 only */
+#define ARCHIVE_ENTRY_ACL_TYPE_AUDIT 0x00001000 /* NFS4 only */
+#define ARCHIVE_ENTRY_ACL_TYPE_ALARM 0x00002000 /* NFS4 only */
#define ARCHIVE_ENTRY_ACL_TYPE_POSIX1E (ARCHIVE_ENTRY_ACL_TYPE_ACCESS \
| ARCHIVE_ENTRY_ACL_TYPE_DEFAULT)
#define ARCHIVE_ENTRY_ACL_TYPE_NFS4 (ARCHIVE_ENTRY_ACL_TYPE_ALLOW \
@@ -492,21 +501,48 @@ __LA_DECL int archive_entry_acl_next_w(struct archive_entry *, int /* want_type
* Construct a text-format ACL. The flags argument is a bitmask that
* can include any of the following:
*
+ * Flags only for archive entries with POSIX.1e ACL:
* ARCHIVE_ENTRY_ACL_TYPE_ACCESS - Include POSIX.1e "access" entries.
* ARCHIVE_ENTRY_ACL_TYPE_DEFAULT - Include POSIX.1e "default" entries.
- * ARCHIVE_ENTRY_ACL_TYPE_NFS4 - Include NFS4 entries.
- * ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID - Include extra numeric ID field in
- * each ACL entry. ('star' introduced this for POSIX.1e, this flag
- * also applies to NFS4.)
* ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT - Include "default:" before each
- * default ACL entry, as used in old Solaris ACLs.
+ * default ACL entry.
+ * ARCHIVE_ENTRY_ACL_STYLE_SOLARIS - Output only one colon after "other" and
+ * "mask" entries.
+ *
+ * Flags only for archive entries with NFSv4 ACL:
+ * ARCHIVE_ENTRY_ACL_STYLE_COMPACT - Do not output the minus character for
+ * unset permissions and flags in NFSv4 ACL permission and flag fields
+ *
+ * Flags for for archive entries with POSIX.1e ACL or NFSv4 ACL:
+ * ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID - Include extra numeric ID field in
+ * each ACL entry.
+ * ARCHIVE_ENTRY_ACL_STYLE_SEPARATOR_COMMA - Separate entries with comma
+ * instead of newline.
*/
-#define ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID 1024
-#define ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT 2048
+#define ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID 0x00000001
+#define ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT 0x00000002
+#define ARCHIVE_ENTRY_ACL_STYLE_SOLARIS 0x00000004
+#define ARCHIVE_ENTRY_ACL_STYLE_SEPARATOR_COMMA 0x00000008
+#define ARCHIVE_ENTRY_ACL_STYLE_COMPACT 0x00000010
+
+__LA_DECL wchar_t *archive_entry_acl_to_text_w(struct archive_entry *,
+ ssize_t * /* len */, int /* flags */);
+__LA_DECL char *archive_entry_acl_to_text(struct archive_entry *,
+ ssize_t * /* len */, int /* flags */);
+__LA_DECL int archive_entry_acl_from_text_w(struct archive_entry *,
+ const wchar_t * /* wtext */, int /* type */);
+__LA_DECL int archive_entry_acl_from_text(struct archive_entry *,
+ const char * /* text */, int /* type */);
+
+/* Deprecated constants */
+#define OLD_ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID 1024
+#define OLD_ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT 2048
+
+/* Deprecated functions */
__LA_DECL const wchar_t *archive_entry_acl_text_w(struct archive_entry *,
- int /* flags */);
+ int /* flags */) __LA_DEPRECATED;
__LA_DECL const char *archive_entry_acl_text(struct archive_entry *,
- int /* flags */);
+ int /* flags */) __LA_DEPRECATED;
/* Return bitmask of ACL types in an archive entry */
__LA_DECL int archive_entry_acl_types(struct archive_entry *);
diff --git a/contrib/libarchive/libarchive/archive_entry_acl.3 b/contrib/libarchive/libarchive/archive_entry_acl.3
index e85c4de..c5115f7 100644
--- a/contrib/libarchive/libarchive/archive_entry_acl.3
+++ b/contrib/libarchive/libarchive/archive_entry_acl.3
@@ -1,4 +1,5 @@
.\" Copyright (c) 2010 Joerg Sonnenberger
+.\" Copyright (c) 2016 Martin Matuska
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
@@ -22,7 +23,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd February 2, 2012
+.Dd February 15, 2017
.Dt ARCHIVE_ENTRY_ACL 3
.Os
.Sh NAME
@@ -30,10 +31,13 @@
.Nm archive_entry_acl_add_entry_w ,
.Nm archive_entry_acl_clear ,
.Nm archive_entry_acl_count ,
+.Nm archive_entry_acl_from_text ,
+.Nm archive_entry_acl_from_text_w,
.Nm archive_entry_acl_next ,
.Nm archive_entry_acl_next_w ,
.Nm archive_entry_acl_reset ,
-.Nm archive_entry_acl_text_w ,
+.Nm archive_entry_acl_to_text ,
+.Nm archive_entry_acl_to_text_w ,
.Nm archive_entry_acl_types
.Nd functions for manipulating Access Control Lists in archive entry descriptions
.Sh LIBRARY
@@ -63,6 +67,18 @@ Streaming Archive Library (libarchive, -larchive)
.Ft int
.Fn archive_entry_acl_count "struct archive_entry *a" "int type"
.Ft int
+.Fo archive_entry_acl_from_text
+.Fa "struct archive_entry *a"
+.Fa "const char *text"
+.Fa "int type"
+.Fc
+.Ft int
+.Fo archive_entry_acl_from_text_w
+.Fa "struct archive_entry *a"
+.Fa "const wchar_t *text"
+.Fa "int type"
+.Fc
+.Ft int
.Fo archive_entry_acl_next
.Fa "struct archive_entry *a"
.Fa "int type"
@@ -84,33 +100,48 @@ Streaming Archive Library (libarchive, -larchive)
.Fc
.Ft int
.Fn archive_entry_acl_reset "struct archive_entry *a" "int type"
-.Ft const wchar_t *
-.Fn archive_entry_acl_text_w "struct archive_entry *a" "int flags"
+.Ft char *
+.Fo archive_entry_acl_to_text
+.Fa "struct archive_entry *a"
+.Fa "ssize_t *len_p"
+.Fa "int flags"
+.Fc
+.Ft wchar_t *
+.Fo archive_entry_acl_to_text_w
+.Fa "struct archive_entry *a"
+.Fa "ssize_t *len_p"
+.Fa "int flags"
+.Fc
.Ft int
.Fn archive_entry_acl_types "struct archive_entry *a"
.\" enum?
.Sh DESCRIPTION
-An
-.Dq Access Control List
-is a generalisation of the classic Unix permission system.
+The
+.Dq Access Control Lists (ACLs)
+extend the standard Unix perssion model.
The ACL interface of
.Nm libarchive
-is derived from the POSIX.1e draft, but restricted to simplify dealing
-with practical implementations in various Operating Systems and archive formats.
-.Pp
-An ACL consists of a number of independent entries.
+supports both POSIX.1e and NFSv4 style ACLs. Use of ACLs is restricted by
+various levels of ACL support in operating systems, file systems and archive
+formats.
+.Ss POSIX.1e Access Control Lists
+A POSIX.1e ACL consists of a number of independent entries.
Each entry specifies the permission set as bitmask of basic permissions.
-Valid permissions are:
+Valid permissions in the
+.Fa permset
+are:
.Bl -tag -offset indent -compact -width "ARCHIVE_ENTRY_ACL_EXECUTE"
-.It Dv ARCHIVE_ENTRY_ACL_EXECUTE
-.It Dv ARCHIVE_ENTRY_ACL_WRITE
-.It Dv ARCHIVE_ENTRY_ACL_READ
+.It Dv ARCHIVE_ENTRY_ACL_READ ( Sy r )
+.It Dv ARCHIVE_ENTRY_ACL_WRITE ( Sy w )
+.It Dv ARCHIVE_ENTRY_ACL_EXECUTE ( Sy x )
.El
The permissions correspond to the normal Unix permissions.
.Pp
-The tag specifies the principal to which the permission applies.
+The
+.Fa tag
+specifies the principal to which the permission applies.
Valid values are:
-.Bl -tag -offset indent -compact -width "ARCHIVE_ENTRY_ACL_GROUP_OBJ"
+.Bl -hang -offset indent -compact -width "ARCHIVE_ENTRY_ACL_GROUP_OBJ"
.It Dv ARCHIVE_ENTRY_ACL_USER
The user specified by the name field.
.It Dv ARCHIVE_ENTRY_ACL_USER_OBJ
@@ -122,8 +153,9 @@ The group who owns the file.
.It Dv ARCHIVE_ENTRY_ACL_MASK
The maximum permissions to be obtained via group permissions.
.It Dv ARCHIVE_ENTRY_ACL_OTHER
-Any principal who doesn't have a user or group entry.
+Any principal who is not file owner or a member of the owning group.
.El
+.Pp
The principals
.Dv ARCHIVE_ENTRY_ACL_USER_OBJ ,
.Dv ARCHIVE_ENTRY_ACL_GROUP_OBJ
@@ -132,19 +164,123 @@ and
are equivalent to user, group and other in the classic Unix permission
model and specify non-extended ACL entries.
.Pp
-All files have an access ACL
+All files with have an access ACL
.Pq Dv ARCHIVE_ENTRY_ACL_TYPE_ACCESS .
This specifies the permissions required for access to the file itself.
Directories have an additional ACL
.Pq Dv ARCHIVE_ENTRY_ACL_TYPE_DEFAULT ,
which controls the initial access ACL for newly created directory entries.
+.Ss NFSv4 Access Control Lists
+A NFSv4 ACL consists of multiple individual entries called Access Control
+Entries (ACEs).
+.Pp
+There are four possible types of a NFSv4 ACE:
+.Bl -hang -offset indent -compact -width "ARCHIVE_ENTRY_ACL_TYE_ALLOW"
+.It Dv ARCHIVE_ENTRY_ACL_TYPE_ALLOW
+Allow principal to perform actions requiring given permissions.
+.It Dv ARCHIVE_ENTRY_ACL_TYPE_DENY
+Prevent principal from performing actions requiring given permissions.
+.It Dv ARCHIVE_ENTRY_ACL_TYPE_AUDIT
+Log access attempts by principal which require given permissions.
+.It Dv ARCHIVE_ENTRY_ACL_TYPE_ALARM
+Trigger a system alarm on access attempts by principal which require given
+permissions.
+.El
+.Pp
+The
+.Fa tag
+specifies the principal to which the permission applies.
+Valid values are:
+.Bl -hang -offset indent -compact -width "ARCHIVE_ENTRY_ACL_GROUP_OBJ"
+.It Dv ARCHIVE_ENTRY_ACL_USER
+The user specified by the name field.
+.It Dv ARCHIVE_ENTRY_ACL_USER_OBJ
+The owner of the file.
+.It Dv ARCHIVE_ENTRY_ACL_GROUP
+The group specied by the name field.
+.It Dv ARCHIVE_ENTRY_ACL_GROUP_OBJ
+The group who owns the file.
+.It Dv ARCHIVE_ENTRY_ACL_EVERYONE
+Any principal who is not file owner or a member of the owning group.
+.El
+.Pp
+Entries with the
+.Dv ARCHIVE_ENTRY_ACL_USER
+or
+.Dv ARCHIVE_ENTRY_ACL_GROUP
+tag store the user and group name in the
+.Fa name
+string and optionally the user or group ID in the
+.Fa qualifier
+integer.
+.Pp
+NFSv4 ACE permissions and flags are stored in the same
+.Fa permset
+bitfield. Some permissions share the same constant and permission character but
+have different effect on directories than on files. The following ACE
+permissions are supported:
+.Bl -tag -offset indent -compact -width ARCHIV
+.It Dv ARCHIVE_ENTRY_ACL_READ_DATA ( Sy r )
+Read data (file).
+.It Dv ARCHIVE_ENTRY_ACL_LIST_DIRECTORY ( Sy r )
+List entries (directory).
+.It ARCHIVE_ENTRY_ACL_WRITE_DATA ( Sy w )
+Write data (file).
+.It ARCHIVE_ENTRY_ACL_ADD_FILE ( Sy w )
+Create files (directory).
+.It Dv ARCHIVE_ENTRY_ACL_EXECUTE ( Sy x )
+Execute file or change into a directory.
+.It Dv ARCHIVE_ENTRY_ACL_APPEND_DATA ( Sy p )
+Append data (file).
+.It Dv ARCHIVE_ENTRY_ACL_ADD_SUBDIRECTORY ( Sy p )
+Create subdirectories (directory).
+.It Dv ARCHIVE_ENTRY_ACL_DELETE_CHILD ( Sy D )
+Remove files and subdirectories inside a directory.
+.It Dv ARCHIVE_ENTRY_ACL_DELETE ( Sy d )
+Remove file or directory.
+.It Dv ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES ( Sy a )
+Read file or directory attributes.
+.It Dv ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES ( Sy A )
+Write file or directory attributes.
+.It Dv ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS ( Sy R )
+Read named file or directory attributes.
+.It Dv ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS ( Sy W )
+Write named file or directory attributes.
+.It Dv ARCHIVE_ENTRY_ACL_READ_ACL ( Sy c )
+Read file or directory ACL.
+.It Dv ARCHIVE_ENTRY_ACL_WRITE_ACL ( Sy C )
+Write file or directory ACL.
+.It Dv ARCHIVE_ENTRY_ACL_WRITE_OWNER ( Sy o )
+Change owner of a file or directory.
+.It Dv ARCHIVE_ENTRY_ACL_SYNCHRONIZE ( Sy s )
+Use synchronous I/O.
+.El
.Pp
+The following NFSv4 ACL inheritance flags are supported:
+.Bl -tag -offset indent -compact -width ARCHIV
+.It Dv ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT ( Sy f )
+Inherit parent directory ACE to files.
+.It Dv ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT ( Sy d )
+Inherit parent directory ACE to subdirectories.
+.It Dv ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY ( Sy i )
+Only inherit, do not apply the permission on the directory itself.
+.It Dv ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT ( Sy n )
+Do not propagate inherit flags. Only first-level entries inherit ACLs.
+.It Dv ARCHIVE_ENTRY_ACL_ENTRY_SUCCESSFUL_ACCESS ( Sy S )
+Trigger alarm or audit on succesful access.
+.It Dv ARCHIVE_ENTRY_ACL_ENTRY_FAILED_ACCESS ( Sy F )
+Trigger alarm or audit on failed access.
+.It Dv ARCHIVE_ENTRY_ACL_ENTRY_INHERITED ( Sy I )
+Mark that ACE was inherited.
+.El
+.Ss Functions
.Fn archive_entry_acl_add_entry
and
.Fn archive_entry_acl_add_entry_w
add a single ACL entry.
For the access ACL and non-extended principals, the classic Unix permissions
-are updated.
+are updated. An archive enry cannot contain both POSIX.1e and NFSv4 ACL
+entries.
.Pp
.Fn archive_entry_acl_clear
removes all ACL entries and resets the enumeration pointer.
@@ -153,14 +289,58 @@ removes all ACL entries and resets the enumeration pointer.
counts the ACL entries that have the given type mask.
.Fa type
can be the bitwise-or of
-.Dv ARCHIVE_ENTRY_ACL_TYPE_ACCESS
-and
-.Dv ARCHIVE_ENTRY_ACL_TYPE_DEFAULT .
-If
+.Bl -tag -offset indent -compact -width "ARCHIVE_ENTRY_ACL_TYPE_DEFAULT"
+.It Dv ARCHIVE_ENTRY_ACL_TYPE_ACCESS
+.It Dv ARCHIVE_ENTRY_ACL_TYPE_DEFAULT
+.El
+for POSIX.1e ACLs and
+.Bl -tag -offset indent -compact -width "ARCHIVE_ENTRY_ACL_TYPE_ALLOW"
+.It Dv ARCHIVE_ENTRY_ACL_TYPE_ALLOW
+.It Dv ARCHIVE_ENTRY_ACL_TYPE_DENY
+.It Dv ARCHIVE_ENTRY_ACL_TYPE_AUDIT
+.It Dv ARCHIVE_ENTRY_ACL_TYPE_ALARM
+.El
+for NFSv4 ACLs. For POSIX.1e ACLs if
.Dv ARCHIVE_ENTRY_ACL_TYPE_ACCESS
is included and at least one extended ACL entry is found,
the three non-extened ACLs are added.
.Pp
+.Fn archive_entry_acl_from_text
+and
+.Fn archive_entry_acl_from_text_w
+add new
+.Pq or merge with existing
+ACL entries from
+.Pq wide
+text. The argument
+.Fa type
+may take one of the following values:
+.Bl -tag -offset indent -compact -width "ARCHIVE_ENTRY_ACL_TYPE_DEFAULT"
+.It Dv ARCHIVE_ENTRY_ACL_TYPE_ACCESS
+.It Dv ARCHIVE_ENTRY_ACL_TYPE_DEFAULT
+.It Dv ARCHIVE_ENTRY_ACL_TYPE_NFS4
+.El
+Supports all formats that can be created with
+.Fn archive_entry_acl_to_text
+or respective
+.Fn archive_entry_acl_to_text_w .
+Existing ACL entries are preserved. To get a clean new ACL from text
+.Fn archive_entry_acl_clear
+must be called first. Entries prefixed with
+.Dq default:
+are treated as
+.Dv ARCHIVE_ENTRY_ACL_TYPE_DEFAULT
+unless
+.Fa type
+is
+.Dv ARCHIVE_ENTRY_ACL_TYPE_NFS4 .
+Invalid entries, non-parseable ACL entries and entries beginning with
+the
+.Sq #
+character
+.Pq comments
+are skipped.
+.Pp
.Fn archive_entry_acl_next
and
.Fn archive_entry_acl_next_w
@@ -182,19 +362,57 @@ or set using
Otherwise, the function returns the same value as
.Fn archive_entry_acl_count .
.Pp
-.Fn archive_entry_acl_text_w
-converts the ACL entries for the given type mask into a wide string.
-In addition to the normal type flags,
-.Dv ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID
+.Fn archive_entry_acl_to_text
and
-.Dv ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT
-can be specified to further customize the result.
-The returned long string is valid until the next call to
-.Fn archive_entry_acl_clear ,
-.Fn archive_entry_acl_add_entry ,
-.Fn archive_entry_acl_add_entry_w
+.Fn archive_entry_acl_to_text_w
+convert the ACL entries for the given type into a
+.Pq wide
+string of ACL entries separated by newline. If the the pointer
+.Fa len_p
+is not NULL, then the function shall return the length of the string
+.Pq not including the NULL terminator
+in the location pointed to by
+.Fa len_p .
+The
+.Fa flag
+argument is a bitwise-or.
+.Pp
+The following flags are effective only on POSIX.1e ACL:
+.Bl -tag -offset indent -compact -width ARCHIV
+.It Dv ARCHIVE_ENTRY_ACL_TYPE_ACCESS
+Output access ACLs.
+.It Dv ARCHIVE_ENTRY_ACL_TYPE_DEFAULT
+Output POSIX.1e default ACLs.
+.It Dv ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT
+Prefix each default ACL entry with the word
+.Dq default: .
+.It Dv ARCHIVE_ENTRY_ACL_STYLE_SOLARIS
+The mask and other ACLs don not contain a double colon.
+.El
+.Pp
+The following flags are effecive only on NFSv4 ACL:
+.Bl -tag -offset indent -compact -width ARCHIV
+.It Dv ARCHIVE_ENTRY_ACL_STYLE_COMPACT
+Do not output minus characters for unset permissions and flags in NFSv4 ACL
+permission and flag fields.
+.El
+.Pp
+The following flags are effective on both POSIX.1e and NFSv4 ACL:
+.Bl -tag -offset indent -compact -width ARCHIV
+.It Dv ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID
+Add an additional colon-separated field containing the user or group id.
+.It Dv ARCHIVE_ENTRY_ACL_STYLE_SEPARATOR_COMMA
+Separate ACL entries with comma instead of newline.
+.El
+.Pp
+If the archive entry contains NFSv4 ACLs, all types of NFSv4 ACLs are returned.
+It the entry contains POSIX.1e ACLs and none of the flags
+.Dv ARCHIVE_ENTRY_ACL_TYPE_ACCESS
or
-.Fn archive_entry_acl_text_w .
+.Dv ARCHIVE_ENTRY_ACL_TYPE_DEFAULT
+are specified, both access and default entries are returned and default entries
+are prefixed with
+.Dq default: .
.Pp
.Fn archive_entry_acl_types
get ACL entry types contained in an archive entry's ACL. As POSIX.1e and NFSv4
@@ -205,11 +423,20 @@ an ACL already contains POSIX.1e or NFSv4 ACL entries.
and
.Fn archive_entry_acl_reset
returns the number of ACL entries that match the given type mask.
-If the type mask includes
+For POSIX.1e ACLS if the type mask includes
.Dv ARCHIVE_ENTRY_ACL_TYPE_ACCESS
and at least one extended ACL entry exists, the three classic Unix
permissions are counted.
.Pp
+.Fn archive_entry_acl_from_text
+and
+.Fn archive_entry_acl_from_text_w
+return
+.Dv ARCHIVE_OK
+if all entries were successfully parsed and
+.Dv ARCHIVE_WARN
+if one or more entries were invalid or non-parseable.
+.Pp
.Fn archive_entry_acl_next
and
.Fn archive_entry_acl_next_w
@@ -224,23 +451,16 @@ if
.Fn archive_entry_acl_reset
has not been called first.
.Pp
-.Fn archive_entry_text_w
-returns a wide string representation of the ACL entrise matching the
-given type mask.
-The returned long string is valid until the next call to
-.Fn archive_entry_acl_clear ,
-.Fn archive_entry_acl_add_entry ,
-.Fn archive_entry_acl_add_entry_w
-or
-.Fn archive_entry_acl_text_w .
+.Fn archive_entry_acl_to_text
+returns a string representing the ACL entries matching the given type and
+flags on success or NULL on error.
+.Pp
+.Fn archive_entry_acl_to_text_w
+returns a wide string representing the ACL entries matching the given type
+and flags on success or NULL on error.
.Pp
.Fn archive_entry_acl_types
returns a bitmask of ACL entry types or 0 if archive entry has no ACL entries.
.Sh SEE ALSO
-.Xr archive_entry 3
-.Xr libarchive 3 ,
-.Sh BUGS
-.Dv ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID
-and
-.Dv ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT
-are not documented.
+.Xr archive_entry 3 ,
+.Xr libarchive 3
diff --git a/contrib/libarchive/libarchive/archive_entry_locale.h b/contrib/libarchive/libarchive/archive_entry_locale.h
index 02e024a..44550c5 100644
--- a/contrib/libarchive/libarchive/archive_entry_locale.h
+++ b/contrib/libarchive/libarchive/archive_entry_locale.h
@@ -63,9 +63,13 @@ int _archive_entry_uname_l(struct archive_entry *,
const char **, size_t *, struct archive_string_conv *);
#define archive_entry_acl_text_l _archive_entry_acl_text_l
int _archive_entry_acl_text_l(struct archive_entry *, int,
- const char **, size_t *, struct archive_string_conv *);
-
-
+const char **, size_t *, struct archive_string_conv *) __LA_DEPRECATED;
+#define archive_entry_acl_to_text_l _archive_entry_acl_to_text_l
+char *_archive_entry_acl_to_text_l(struct archive_entry *, ssize_t *, int,
+ struct archive_string_conv *);
+#define archive_entry_acl_from_text_l _archive_entry_acl_from_text_l
+int _archive_entry_acl_from_text_l(struct archive_entry *, const char* text,
+ int type, struct archive_string_conv *);
#define archive_entry_copy_gname_l _archive_entry_copy_gname_l
int _archive_entry_copy_gname_l(struct archive_entry *,
const char *, size_t, struct archive_string_conv *);
diff --git a/contrib/libarchive/libarchive/archive_entry_strmode.c b/contrib/libarchive/libarchive/archive_entry_strmode.c
index 8d7006a..d80a7d4 100644
--- a/contrib/libarchive/libarchive/archive_entry_strmode.c
+++ b/contrib/libarchive/libarchive/archive_entry_strmode.c
@@ -80,7 +80,7 @@ archive_entry_strmode(struct archive_entry *entry)
if (mode & 0001) bp[9] = 't';
else bp[9] = 'T';
}
- if (archive_entry_acl_count(entry, ARCHIVE_ENTRY_ACL_TYPE_ACCESS))
+ if (archive_entry_acl_types(entry) != 0)
bp[10] = '+';
return (bp);
diff --git a/contrib/libarchive/libarchive/archive_match.c b/contrib/libarchive/libarchive/archive_match.c
index 0719cbd..be72066 100644
--- a/contrib/libarchive/libarchive/archive_match.c
+++ b/contrib/libarchive/libarchive/archive_match.c
@@ -471,7 +471,7 @@ archive_match_path_excluded(struct archive *_a,
}
/*
- * Utilty functions to get statistic information for inclusion patterns.
+ * Utility functions to get statistic information for inclusion patterns.
*/
int
archive_match_path_unmatched_inclusions(struct archive *_a)
@@ -1270,7 +1270,7 @@ set_timefilter_pathname_wcs(struct archive_match *a, int timetype,
#endif /* _WIN32 && !__CYGWIN__ */
/*
- * Call back funtions for archive_rb.
+ * Call back functions for archive_rb.
*/
static int
cmp_node_mbs(const struct archive_rb_node *n1,
@@ -1405,7 +1405,7 @@ add_entry(struct archive_match *a, int flag,
&(a->exclusion_tree), pathname);
/*
- * We always overwrite comparison condision.
+ * We always overwrite comparison condition.
* If you do not want to overwrite it, you should not
* call archive_match_exclude_entry(). We cannot know
* what behavior you really expect since overwriting
@@ -1481,7 +1481,7 @@ time_excluded(struct archive_match *a, struct archive_entry *entry)
if (nsec == a->older_ctime_nsec &&
(a->older_ctime_filter & ARCHIVE_MATCH_EQUAL)
== 0)
- return (1); /* Eeual, skip it. */
+ return (1); /* Equal, skip it. */
}
}
if (a->newer_mtime_filter) {
@@ -1513,7 +1513,7 @@ time_excluded(struct archive_match *a, struct archive_entry *entry)
}
}
- /* If there is no excluson list, include the file. */
+ /* If there is no exclusion list, include the file. */
if (a->exclusion_entry_list.count == 0)
return (0);
@@ -1700,7 +1700,7 @@ add_owner_id(struct archive_match *a, struct id_array *ids, int64_t id)
break;
}
- /* Add oowner id. */
+ /* Add owner id. */
if (i == ids->count)
ids->ids[ids->count++] = id;
else if (ids->ids[i] != id) {
diff --git a/contrib/libarchive/libarchive/archive_platform.h b/contrib/libarchive/libarchive/archive_platform.h
index 76816c4..31383db 100644
--- a/contrib/libarchive/libarchive/archive_platform.h
+++ b/contrib/libarchive/libarchive/archive_platform.h
@@ -147,8 +147,25 @@
* acl_set_file(), and ACL_USER, we assume it has the rest of the
* POSIX.1e draft functions used in archive_read_extract.c.
*/
-#if HAVE_SYS_ACL_H && HAVE_ACL_CREATE_ENTRY && HAVE_ACL_INIT && HAVE_ACL_SET_FILE && HAVE_ACL_USER
+#if HAVE_SYS_ACL_H && HAVE_ACL_CREATE_ENTRY && HAVE_ACL_INIT && HAVE_ACL_SET_FILE
+#if HAVE_ACL_USER
#define HAVE_POSIX_ACL 1
+#elif HAVE_ACL_TYPE_EXTENDED
+#define HAVE_DARWIN_ACL 1
+#endif
+#endif
+
+/*
+ * If this platform has <sys/acl.h>, acl_get(), facl_get(), acl_set(),
+ * facl_set() and types aclent_t and ace_t it uses Solaris-style ACL functions
+ */
+#if HAVE_SYS_ACL_H && HAVE_ACL_GET && HAVE_FACL_GET && HAVE_ACL_SET && HAVE_FACL_SET && HAVE_ACLENT_T && HAVE_ACE_T
+#define HAVE_SUN_ACL 1
+#endif
+
+/* Define if platform supports NFSv4 ACLs */
+#if (HAVE_POSIX_ACL && HAVE_ACL_TYPE_NFS4) || HAVE_SUN_ACL || HAVE_DARWIN_ACL
+#define HAVE_NFS4_ACL 1
#endif
/*
diff --git a/contrib/libarchive/libarchive/archive_random.c b/contrib/libarchive/libarchive/archive_random.c
index a20b9b1..357f973 100644
--- a/contrib/libarchive/libarchive/archive_random.c
+++ b/contrib/libarchive/libarchive/archive_random.c
@@ -80,7 +80,7 @@ archive_random(void *buf, size_t nbytes)
success = CryptAcquireContext(&hProv, NULL, NULL, PROV_RSA_FULL,
CRYPT_VERIFYCONTEXT);
- if (!success && GetLastError() == NTE_BAD_KEYSET) {
+ if (!success && GetLastError() == (DWORD)NTE_BAD_KEYSET) {
success = CryptAcquireContext(&hProv, NULL, NULL,
PROV_RSA_FULL, CRYPT_NEWKEYSET);
}
diff --git a/contrib/libarchive/libarchive/archive_rb.c b/contrib/libarchive/libarchive/archive_rb.c
index 5b5da20..cf58ac3 100644
--- a/contrib/libarchive/libarchive/archive_rb.c
+++ b/contrib/libarchive/libarchive/archive_rb.c
@@ -312,7 +312,7 @@ __archive_rb_tree_insert_rebalance(struct archive_rb_tree *rbt,
father = RB_FATHER(self);
if (RB_BLACK_P(father)) {
/*
- * If our greatgrandpa is black, we're done.
+ * If our great-grandpa is black, we're done.
*/
return;
}
diff --git a/contrib/libarchive/libarchive/archive_read_disk.3 b/contrib/libarchive/libarchive/archive_read_disk.3
index 525dc59..2a5c130 100644
--- a/contrib/libarchive/libarchive/archive_read_disk.3
+++ b/contrib/libarchive/libarchive/archive_read_disk.3
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd February 2, 2012
+.Dd December 30, 2016
.Dt ARCHIVE_READ_DISK 3
.Os
.Sh NAME
@@ -54,9 +54,9 @@ Streaming Archive Library (libarchive, -larchive)
.Fn archive_read_disk_set_symlink_physical "struct archive *"
.Ft int
.Fn archive_read_disk_set_symlink_hybrid "struct archive *"
-.Ft int
+.Ft const char *
.Fn archive_read_disk_gname "struct archive *" "gid_t"
-.Ft int
+.Ft const char *
.Fn archive_read_disk_uname "struct archive *" "uid_t"
.Ft int
.Fo archive_read_disk_set_gname_lookup
diff --git a/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c b/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c
index e9fb8ba..ef6875f 100644
--- a/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c
+++ b/contrib/libarchive/libarchive/archive_read_disk_entry_from_file.c
@@ -1,6 +1,7 @@
/*-
* Copyright (c) 2003-2009 Tim Kientzle
* Copyright (c) 2010-2012 Michihiro NAKAJIMA
+ * Copyright (c) 2016 Martin Matuska
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -37,6 +38,11 @@ __FBSDID("$FreeBSD$");
#ifdef HAVE_SYS_ACL_H
#include <sys/acl.h>
#endif
+#ifdef HAVE_DARWIN_ACL
+#include <membership.h>
+#include <grp.h>
+#include <pwd.h>
+#endif
#ifdef HAVE_SYS_EXTATTR_H
#include <sys/extattr.h>
#endif
@@ -117,6 +123,15 @@ __FBSDID("$FreeBSD$");
#define ACL_GET_PERM acl_get_perm_np
#endif
+/* NFSv4 platform ACL type */
+#if HAVE_SUN_ACL
+#define ARCHIVE_PLATFORM_ACL_TYPE_NFS4 ACE_T
+#elif HAVE_DARWIN_ACL
+#define ARCHIVE_PLATFORM_ACL_TYPE_NFS4 ACL_TYPE_EXTENDED
+#elif HAVE_ACL_TYPE_NFS4
+#define ARCHIVE_PLATFORM_ACL_TYPE_NFS4 ACL_TYPE_NFS4
+#endif
+
static int setup_acls(struct archive_read_disk *,
struct archive_entry *, int *fd);
static int setup_mac_metadata(struct archive_read_disk *,
@@ -404,17 +419,38 @@ setup_mac_metadata(struct archive_read_disk *a,
}
#endif
+#if HAVE_DARWIN_ACL
+static int translate_guid(struct archive *, acl_entry_t,
+ int *, int *, const char **);
+
+static void add_trivial_nfs4_acl(struct archive_entry *);
+#endif
-#ifdef HAVE_POSIX_ACL
+#if HAVE_SUN_ACL
+static int
+sun_acl_is_trivial(acl_t *, mode_t, int *trivialp);
+#endif
+
+#if HAVE_POSIX_ACL || HAVE_NFS4_ACL
static int translate_acl(struct archive_read_disk *a,
- struct archive_entry *entry, acl_t acl, int archive_entry_acl_type);
+ struct archive_entry *entry,
+#if HAVE_SUN_ACL
+ acl_t *acl,
+#else
+ acl_t acl,
+#endif
+ int archive_entry_acl_type);
static int
setup_acls(struct archive_read_disk *a,
struct archive_entry *entry, int *fd)
{
const char *accpath;
- acl_t acl;
+#if HAVE_SUN_ACL
+ acl_t *acl;
+#else
+ acl_t acl;
+#endif
int r;
accpath = archive_entry_sourcepath(entry);
@@ -439,17 +475,20 @@ setup_acls(struct archive_read_disk *a,
acl = NULL;
-#ifdef ACL_TYPE_NFS4
- /* Try NFS4 ACL first. */
+#if HAVE_NFS4_ACL
+ /* Try NFSv4 ACL first. */
if (*fd >= 0)
-#if HAVE_ACL_GET_FD_NP
- acl = acl_get_fd_np(*fd, ACL_TYPE_NFS4);
+#if HAVE_SUN_ACL
+ /* Solaris reads both POSIX.1e and NFSv4 ACL here */
+ facl_get(*fd, 0, &acl);
+#elif HAVE_ACL_GET_FD_NP
+ acl = acl_get_fd_np(*fd, ARCHIVE_PLATFORM_ACL_TYPE_NFS4);
#else
acl = acl_get_fd(*fd);
#endif
#if HAVE_ACL_GET_LINK_NP
else if (!a->follow_symlinks)
- acl = acl_get_link_np(accpath, ACL_TYPE_NFS4);
+ acl = acl_get_link_np(accpath, ARCHIVE_PLATFORM_ACL_TYPE_NFS4);
#else
else if ((!a->follow_symlinks)
&& (archive_entry_filetype(entry) == AE_IFLNK))
@@ -458,12 +497,24 @@ setup_acls(struct archive_read_disk *a,
acl = NULL;
#endif
else
- acl = acl_get_file(accpath, ACL_TYPE_NFS4);
+#if HAVE_SUN_ACL
+ /* Solaris reads both POSIX.1e and NFSv4 ACLs here */
+ acl_get(accpath, 0, &acl);
+#else
+ acl = acl_get_file(accpath, ARCHIVE_PLATFORM_ACL_TYPE_NFS4);
+#endif
-#if HAVE_ACL_IS_TRIVIAL_NP
- if (acl != NULL && acl_is_trivial_np(acl, &r) == 0) {
- /* Ignore "trivial" ACLs that just mirror the file mode. */
- if (r) {
+
+#if HAVE_ACL_IS_TRIVIAL_NP || HAVE_SUN_ACL
+ /* Ignore "trivial" ACLs that just mirror the file mode. */
+ if (acl != NULL) {
+#if HAVE_SUN_ACL
+ if (sun_acl_is_trivial(acl, archive_entry_mode(entry),
+ &r) == 0 && r == 1)
+#elif HAVE_ACL_IS_TRIVIAL_NP
+ if (acl_is_trivial_np(acl, &r) == 0 && r == 1)
+#endif
+ {
acl_free(acl);
acl = NULL;
/*
@@ -473,17 +524,35 @@ setup_acls(struct archive_read_disk *a,
return (ARCHIVE_OK);
}
}
-#endif
+#endif /* HAVE_ACL_IS_TRIVIAL_NP || HAVE_SUN_ACL */
if (acl != NULL) {
r = translate_acl(a, entry, acl, ARCHIVE_ENTRY_ACL_TYPE_NFS4);
acl_free(acl);
if (r != ARCHIVE_OK) {
archive_set_error(&a->archive, errno,
+#if HAVE_SUN_ACL
+ "Couldn't translate ACLs: %s", accpath);
+#else
"Couldn't translate NFSv4 ACLs: %s", accpath);
+#endif
}
+#if HAVE_DARWIN_ACL
+ /*
+ * Because Mac OS doesn't support owner@, group@ and everyone@
+ * ACLs we need to add NFSv4 ACLs mirroring the file mode to
+ * the archive entry. Otherwise extraction on non-Mac platforms
+ * would lead to an invalid file mode.
+ */
+ if (archive_entry_acl_count(entry,
+ ARCHIVE_ENTRY_ACL_TYPE_NFS4) > 0)
+ add_trivial_nfs4_acl(entry);
+#endif
return (r);
}
-#endif /* ACL_TYPE_NFS4 */
+#endif /* HAVE_NFS4_ACL */
+
+#if HAVE_POSIX_ACL
+ /* This code path is skipped on MacOS and Solaris */
/* Retrieve access ACL from file. */
if (*fd >= 0)
@@ -512,8 +581,7 @@ setup_acls(struct archive_read_disk *a,
#endif
if (acl != NULL) {
- r = translate_acl(a, entry, acl,
- ARCHIVE_ENTRY_ACL_TYPE_ACCESS);
+ r = translate_acl(a, entry, acl, ARCHIVE_ENTRY_ACL_TYPE_ACCESS);
acl_free(acl);
acl = NULL;
if (r != ARCHIVE_OK) {
@@ -525,6 +593,11 @@ setup_acls(struct archive_read_disk *a,
/* Only directories can have default ACLs. */
if (S_ISDIR(archive_entry_mode(entry))) {
+#if HAVE_ACL_GET_FD_NP
+ if (*fd >= 0)
+ acl = acl_get_fd_np(*fd, ACL_TYPE_DEFAULT);
+ else
+#endif
acl = acl_get_file(accpath, ACL_TYPE_DEFAULT);
if (acl != NULL) {
r = translate_acl(a, entry, acl,
@@ -538,68 +611,560 @@ setup_acls(struct archive_read_disk *a,
}
}
}
+#endif /* HAVE_POSIX_ACL */
return (ARCHIVE_OK);
}
/*
- * Translate system ACL into libarchive internal structure.
+ * Translate system ACL permissions into libarchive internal structure
*/
-
-static struct {
- int archive_perm;
- int platform_perm;
+static const struct {
+ const int archive_perm;
+ const int platform_perm;
} acl_perm_map[] = {
- {ARCHIVE_ENTRY_ACL_EXECUTE, ACL_EXECUTE},
- {ARCHIVE_ENTRY_ACL_WRITE, ACL_WRITE},
- {ARCHIVE_ENTRY_ACL_READ, ACL_READ},
-#ifdef ACL_TYPE_NFS4
- {ARCHIVE_ENTRY_ACL_READ_DATA, ACL_READ_DATA},
- {ARCHIVE_ENTRY_ACL_LIST_DIRECTORY, ACL_LIST_DIRECTORY},
- {ARCHIVE_ENTRY_ACL_WRITE_DATA, ACL_WRITE_DATA},
- {ARCHIVE_ENTRY_ACL_ADD_FILE, ACL_ADD_FILE},
- {ARCHIVE_ENTRY_ACL_APPEND_DATA, ACL_APPEND_DATA},
- {ARCHIVE_ENTRY_ACL_ADD_SUBDIRECTORY, ACL_ADD_SUBDIRECTORY},
- {ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS, ACL_READ_NAMED_ATTRS},
- {ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS, ACL_WRITE_NAMED_ATTRS},
- {ARCHIVE_ENTRY_ACL_DELETE_CHILD, ACL_DELETE_CHILD},
- {ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES, ACL_READ_ATTRIBUTES},
- {ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES, ACL_WRITE_ATTRIBUTES},
- {ARCHIVE_ENTRY_ACL_DELETE, ACL_DELETE},
- {ARCHIVE_ENTRY_ACL_READ_ACL, ACL_READ_ACL},
- {ARCHIVE_ENTRY_ACL_WRITE_ACL, ACL_WRITE_ACL},
- {ARCHIVE_ENTRY_ACL_WRITE_OWNER, ACL_WRITE_OWNER},
- {ARCHIVE_ENTRY_ACL_SYNCHRONIZE, ACL_SYNCHRONIZE}
+#if HAVE_SUN_ACL /* Solaris NFSv4 ACL permissions */
+ {ARCHIVE_ENTRY_ACL_EXECUTE, ACE_EXECUTE},
+ {ARCHIVE_ENTRY_ACL_READ_DATA, ACE_READ_DATA},
+ {ARCHIVE_ENTRY_ACL_LIST_DIRECTORY, ACE_LIST_DIRECTORY},
+ {ARCHIVE_ENTRY_ACL_WRITE_DATA, ACE_WRITE_DATA},
+ {ARCHIVE_ENTRY_ACL_ADD_FILE, ACE_ADD_FILE},
+ {ARCHIVE_ENTRY_ACL_APPEND_DATA, ACE_APPEND_DATA},
+ {ARCHIVE_ENTRY_ACL_ADD_SUBDIRECTORY, ACE_ADD_SUBDIRECTORY},
+ {ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS, ACE_READ_NAMED_ATTRS},
+ {ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS, ACE_WRITE_NAMED_ATTRS},
+ {ARCHIVE_ENTRY_ACL_DELETE_CHILD, ACE_DELETE_CHILD},
+ {ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES, ACE_READ_ATTRIBUTES},
+ {ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES, ACE_WRITE_ATTRIBUTES},
+ {ARCHIVE_ENTRY_ACL_DELETE, ACE_DELETE},
+ {ARCHIVE_ENTRY_ACL_READ_ACL, ACE_READ_ACL},
+ {ARCHIVE_ENTRY_ACL_WRITE_ACL, ACE_WRITE_ACL},
+ {ARCHIVE_ENTRY_ACL_WRITE_OWNER, ACE_WRITE_OWNER},
+ {ARCHIVE_ENTRY_ACL_SYNCHRONIZE, ACE_SYNCHRONIZE}
+#elif HAVE_DARWIN_ACL /* MacOS ACL permissions */
+ {ARCHIVE_ENTRY_ACL_READ_DATA, ACL_READ_DATA},
+ {ARCHIVE_ENTRY_ACL_LIST_DIRECTORY, ACL_LIST_DIRECTORY},
+ {ARCHIVE_ENTRY_ACL_WRITE_DATA, ACL_WRITE_DATA},
+ {ARCHIVE_ENTRY_ACL_ADD_FILE, ACL_ADD_FILE},
+ {ARCHIVE_ENTRY_ACL_EXECUTE, ACL_EXECUTE},
+ {ARCHIVE_ENTRY_ACL_DELETE, ACL_DELETE},
+ {ARCHIVE_ENTRY_ACL_APPEND_DATA, ACL_APPEND_DATA},
+ {ARCHIVE_ENTRY_ACL_ADD_SUBDIRECTORY, ACL_ADD_SUBDIRECTORY},
+ {ARCHIVE_ENTRY_ACL_DELETE_CHILD, ACL_DELETE_CHILD},
+ {ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES, ACL_READ_ATTRIBUTES},
+ {ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES, ACL_WRITE_ATTRIBUTES},
+ {ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS, ACL_READ_EXTATTRIBUTES},
+ {ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS, ACL_WRITE_EXTATTRIBUTES},
+ {ARCHIVE_ENTRY_ACL_READ_ACL, ACL_READ_SECURITY},
+ {ARCHIVE_ENTRY_ACL_WRITE_ACL, ACL_WRITE_SECURITY},
+ {ARCHIVE_ENTRY_ACL_WRITE_OWNER, ACL_CHANGE_OWNER},
+ {ARCHIVE_ENTRY_ACL_SYNCHRONIZE, ACL_SYNCHRONIZE}
+#else /* POSIX.1e ACL permissions */
+ {ARCHIVE_ENTRY_ACL_EXECUTE, ACL_EXECUTE},
+ {ARCHIVE_ENTRY_ACL_WRITE, ACL_WRITE},
+ {ARCHIVE_ENTRY_ACL_READ, ACL_READ},
+#if HAVE_ACL_TYPE_NFS4 /* FreeBSD NFSv4 ACL permissions */
+ {ARCHIVE_ENTRY_ACL_READ_DATA, ACL_READ_DATA},
+ {ARCHIVE_ENTRY_ACL_LIST_DIRECTORY, ACL_LIST_DIRECTORY},
+ {ARCHIVE_ENTRY_ACL_WRITE_DATA, ACL_WRITE_DATA},
+ {ARCHIVE_ENTRY_ACL_ADD_FILE, ACL_ADD_FILE},
+ {ARCHIVE_ENTRY_ACL_APPEND_DATA, ACL_APPEND_DATA},
+ {ARCHIVE_ENTRY_ACL_ADD_SUBDIRECTORY, ACL_ADD_SUBDIRECTORY},
+ {ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS, ACL_READ_NAMED_ATTRS},
+ {ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS, ACL_WRITE_NAMED_ATTRS},
+ {ARCHIVE_ENTRY_ACL_DELETE_CHILD, ACL_DELETE_CHILD},
+ {ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES, ACL_READ_ATTRIBUTES},
+ {ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES, ACL_WRITE_ATTRIBUTES},
+ {ARCHIVE_ENTRY_ACL_DELETE, ACL_DELETE},
+ {ARCHIVE_ENTRY_ACL_READ_ACL, ACL_READ_ACL},
+ {ARCHIVE_ENTRY_ACL_WRITE_ACL, ACL_WRITE_ACL},
+ {ARCHIVE_ENTRY_ACL_WRITE_OWNER, ACL_WRITE_OWNER},
+ {ARCHIVE_ENTRY_ACL_SYNCHRONIZE, ACL_SYNCHRONIZE}
#endif
+#endif /* !HAVE_SUN_ACL && !HAVE_DARWIN_ACL */
};
-#ifdef ACL_TYPE_NFS4
-static struct {
- int archive_inherit;
- int platform_inherit;
+#if HAVE_NFS4_ACL
+/*
+ * Translate system NFSv4 inheritance flags into libarchive internal structure
+ */
+static const struct {
+ const int archive_inherit;
+ const int platform_inherit;
} acl_inherit_map[] = {
- {ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT, ACL_ENTRY_FILE_INHERIT},
+#if HAVE_SUN_ACL /* Solaris ACL inheritance flags */
+ {ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT, ACE_FILE_INHERIT_ACE},
+ {ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT, ACE_DIRECTORY_INHERIT_ACE},
+ {ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT, ACE_NO_PROPAGATE_INHERIT_ACE},
+ {ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY, ACE_INHERIT_ONLY_ACE},
+ {ARCHIVE_ENTRY_ACL_ENTRY_SUCCESSFUL_ACCESS, ACE_SUCCESSFUL_ACCESS_ACE_FLAG},
+ {ARCHIVE_ENTRY_ACL_ENTRY_FAILED_ACCESS, ACE_FAILED_ACCESS_ACE_FLAG},
+ {ARCHIVE_ENTRY_ACL_ENTRY_INHERITED, ACE_INHERITED_ACE}
+#elif HAVE_DARWIN_ACL /* MacOS NFSv4 inheritance flags */
+ {ARCHIVE_ENTRY_ACL_ENTRY_INHERITED, ACL_ENTRY_INHERITED},
+ {ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT, ACL_ENTRY_FILE_INHERIT},
+ {ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT, ACL_ENTRY_DIRECTORY_INHERIT},
+ {ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT, ACL_ENTRY_LIMIT_INHERIT},
+ {ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY, ACL_ENTRY_ONLY_INHERIT}
+#else /* FreeBSD NFSv4 ACL inheritance flags */
+ {ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT, ACL_ENTRY_FILE_INHERIT},
{ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT, ACL_ENTRY_DIRECTORY_INHERIT},
{ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT, ACL_ENTRY_NO_PROPAGATE_INHERIT},
- {ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY, ACL_ENTRY_INHERIT_ONLY}
+ {ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY, ACL_ENTRY_INHERIT_ONLY},
+ {ARCHIVE_ENTRY_ACL_ENTRY_SUCCESSFUL_ACCESS, ACL_ENTRY_SUCCESSFUL_ACCESS},
+ {ARCHIVE_ENTRY_ACL_ENTRY_FAILED_ACCESS, ACL_ENTRY_FAILED_ACCESS},
+ {ARCHIVE_ENTRY_ACL_ENTRY_INHERITED, ACL_ENTRY_INHERITED}
+#endif /* !HAVE_SUN_ACL && !HAVE_DARWIN_ACL */
};
-#endif
+#endif /* HAVE_NFS4_ACL */
+
+#if HAVE_DARWIN_ACL
+static int translate_guid(struct archive *a, acl_entry_t acl_entry,
+ int *ae_id, int *ae_tag, const char **ae_name)
+{
+ void *q;
+ uid_t ugid;
+ int r, idtype;
+ struct passwd *pwd;
+ struct group *grp;
+
+ q = acl_get_qualifier(acl_entry);
+ if (q == NULL)
+ return (1);
+ r = mbr_uuid_to_id((const unsigned char *)q, &ugid, &idtype);
+ if (r != 0) {
+ acl_free(q);
+ return (1);
+ }
+ if (idtype == ID_TYPE_UID) {
+ *ae_tag = ARCHIVE_ENTRY_ACL_USER;
+ pwd = getpwuuid(q);
+ if (pwd == NULL) {
+ *ae_id = ugid;
+ *ae_name = NULL;
+ } else {
+ *ae_id = pwd->pw_uid;
+ *ae_name = archive_read_disk_uname(a, *ae_id);
+ }
+ } else if (idtype == ID_TYPE_GID) {
+ *ae_tag = ARCHIVE_ENTRY_ACL_GROUP;
+ grp = getgruuid(q);
+ if (grp == NULL) {
+ *ae_id = ugid;
+ *ae_name = NULL;
+ } else {
+ *ae_id = grp->gr_gid;
+ *ae_name = archive_read_disk_gname(a, *ae_id);
+ }
+ } else
+ r = 1;
+
+ acl_free(q);
+ return (r);
+}
+
+/*
+ * Add trivial NFSv4 ACL entries from mode
+ */
+static void
+add_trivial_nfs4_acl(struct archive_entry *entry)
+{
+ mode_t mode;
+ int i;
+ const int rperm = ARCHIVE_ENTRY_ACL_READ_DATA;
+ const int wperm = ARCHIVE_ENTRY_ACL_WRITE_DATA |
+ ARCHIVE_ENTRY_ACL_APPEND_DATA;
+ const int eperm = ARCHIVE_ENTRY_ACL_EXECUTE;
+ const int pubset = ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES |
+ ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS |
+ ARCHIVE_ENTRY_ACL_READ_ACL |
+ ARCHIVE_ENTRY_ACL_SYNCHRONIZE;
+ const int ownset = pubset | ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES |
+ ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS |
+ ARCHIVE_ENTRY_ACL_WRITE_ACL |
+ ARCHIVE_ENTRY_ACL_WRITE_OWNER;
+
+ struct {
+ const int type;
+ const int tag;
+ int permset;
+ } tacl_entry[] = {
+ {ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_USER_OBJ, 0},
+ {ARCHIVE_ENTRY_ACL_TYPE_DENY, ARCHIVE_ENTRY_ACL_USER_OBJ, 0},
+ {ARCHIVE_ENTRY_ACL_TYPE_DENY, ARCHIVE_ENTRY_ACL_GROUP_OBJ, 0},
+ {ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_USER_OBJ, ownset},
+ {ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_GROUP_OBJ, pubset},
+ {ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_EVERYONE, pubset}
+ };
+
+ mode = archive_entry_mode(entry);
+
+ /* Permissions for everyone@ */
+ if (mode & 0004)
+ tacl_entry[5].permset |= rperm;
+ if (mode & 0002)
+ tacl_entry[5].permset |= wperm;
+ if (mode & 0001)
+ tacl_entry[5].permset |= eperm;
+
+ /* Permissions for group@ */
+ if (mode & 0040)
+ tacl_entry[4].permset |= rperm;
+ else if (mode & 0004)
+ tacl_entry[2].permset |= rperm;
+ if (mode & 0020)
+ tacl_entry[4].permset |= wperm;
+ else if (mode & 0002)
+ tacl_entry[2].permset |= wperm;
+ if (mode & 0010)
+ tacl_entry[4].permset |= eperm;
+ else if (mode & 0001)
+ tacl_entry[2].permset |= eperm;
+
+ /* Permissions for owner@ */
+ if (mode & 0400) {
+ tacl_entry[3].permset |= rperm;
+ if (!(mode & 0040) && (mode & 0004))
+ tacl_entry[0].permset |= rperm;
+ } else if ((mode & 0040) || (mode & 0004))
+ tacl_entry[1].permset |= rperm;
+ if (mode & 0200) {
+ tacl_entry[3].permset |= wperm;
+ if (!(mode & 0020) && (mode & 0002))
+ tacl_entry[0].permset |= wperm;
+ } else if ((mode & 0020) || (mode & 0002))
+ tacl_entry[1].permset |= wperm;
+ if (mode & 0100) {
+ tacl_entry[3].permset |= eperm;
+ if (!(mode & 0010) && (mode & 0001))
+ tacl_entry[0].permset |= eperm;
+ } else if ((mode & 0010) || (mode & 0001))
+ tacl_entry[1].permset |= eperm;
+
+ for (i = 0; i < 6; i++) {
+ if (tacl_entry[i].permset != 0) {
+ archive_entry_acl_add_entry(entry,
+ tacl_entry[i].type, tacl_entry[i].permset,
+ tacl_entry[i].tag, -1, NULL);
+ }
+ }
+
+ return;
+}
+#elif HAVE_SUN_ACL
+/*
+ * Check if acl is trivial
+ * This is a FreeBSD acl_is_trivial_np() implementation for Solaris
+ */
+static int
+sun_acl_is_trivial(acl_t *acl, mode_t mode, int *trivialp)
+{
+ int i, p;
+ const uint32_t rperm = ACE_READ_DATA;
+ const uint32_t wperm = ACE_WRITE_DATA | ACE_APPEND_DATA;
+ const uint32_t eperm = ACE_EXECUTE;
+ const uint32_t pubset = ACE_READ_ATTRIBUTES | ACE_READ_NAMED_ATTRS |
+ ACE_READ_ACL | ACE_SYNCHRONIZE;
+ const uint32_t ownset = pubset | ACE_WRITE_ATTRIBUTES |
+ ACE_WRITE_NAMED_ATTRS | ACE_WRITE_ACL | ACE_WRITE_OWNER;
+
+ ace_t *ace;
+ ace_t tace[6];
+
+ if (acl == NULL || trivialp == NULL)
+ return (-1);
+
+ *trivialp = 0;
+
+ /* ACL_IS_TRIVIAL flag must be set for both POSIX.1e and NFSv4 ACLs */
+ if ((acl->acl_flags & ACL_IS_TRIVIAL) == 0)
+ return (0);
+
+ /*
+ * POSIX.1e ACLs marked with ACL_IS_TRIVIAL are compatible with
+ * FreeBSD acl_is_trivial_np(). On Solaris they have 4 entries,
+ * including mask.
+ */
+ if (acl->acl_type == ACLENT_T) {
+ if (acl->acl_cnt == 4)
+ *trivialp = 1;
+ return (0);
+ }
+
+ if (acl->acl_type != ACE_T || acl->acl_entry_size != sizeof(ace_t))
+ return (-1);
+
+ /*
+ * Continue with checking NFSv4 ACLs
+ *
+ * Create list of trivial ace's to be compared
+ */
+
+ /* owner@ allow pre */
+ tace[0].a_flags = ACE_OWNER;
+ tace[0].a_type = ACE_ACCESS_ALLOWED_ACE_TYPE;
+ tace[0].a_access_mask = 0;
+
+ /* owner@ deny */
+ tace[1].a_flags = ACE_OWNER;
+ tace[1].a_type = ACE_ACCESS_DENIED_ACE_TYPE;
+ tace[1].a_access_mask = 0;
+
+ /* group@ deny */
+ tace[2].a_flags = ACE_GROUP | ACE_IDENTIFIER_GROUP;
+ tace[2].a_type = ACE_ACCESS_DENIED_ACE_TYPE;
+ tace[2].a_access_mask = 0;
+
+ /* owner@ allow */
+ tace[3].a_flags = ACE_OWNER;
+ tace[3].a_type = ACE_ACCESS_ALLOWED_ACE_TYPE;
+ tace[3].a_access_mask = ownset;
+
+ /* group@ allow */
+ tace[4].a_flags = ACE_GROUP | ACE_IDENTIFIER_GROUP;
+ tace[4].a_type = ACE_ACCESS_ALLOWED_ACE_TYPE;
+ tace[4].a_access_mask = pubset;
+
+ /* everyone@ allow */
+ tace[5].a_flags = ACE_EVERYONE;
+ tace[5].a_type = ACE_ACCESS_ALLOWED_ACE_TYPE;
+ tace[5].a_access_mask = pubset;
+
+ /* Permissions for everyone@ */
+ if (mode & 0004)
+ tace[5].a_access_mask |= rperm;
+ if (mode & 0002)
+ tace[5].a_access_mask |= wperm;
+ if (mode & 0001)
+ tace[5].a_access_mask |= eperm;
+
+ /* Permissions for group@ */
+ if (mode & 0040)
+ tace[4].a_access_mask |= rperm;
+ else if (mode & 0004)
+ tace[2].a_access_mask |= rperm;
+ if (mode & 0020)
+ tace[4].a_access_mask |= wperm;
+ else if (mode & 0002)
+ tace[2].a_access_mask |= wperm;
+ if (mode & 0010)
+ tace[4].a_access_mask |= eperm;
+ else if (mode & 0001)
+ tace[2].a_access_mask |= eperm;
+
+ /* Permissions for owner@ */
+ if (mode & 0400) {
+ tace[3].a_access_mask |= rperm;
+ if (!(mode & 0040) && (mode & 0004))
+ tace[0].a_access_mask |= rperm;
+ } else if ((mode & 0040) || (mode & 0004))
+ tace[1].a_access_mask |= rperm;
+ if (mode & 0200) {
+ tace[3].a_access_mask |= wperm;
+ if (!(mode & 0020) && (mode & 0002))
+ tace[0].a_access_mask |= wperm;
+ } else if ((mode & 0020) || (mode & 0002))
+ tace[1].a_access_mask |= wperm;
+ if (mode & 0100) {
+ tace[3].a_access_mask |= eperm;
+ if (!(mode & 0010) && (mode & 0001))
+ tace[0].a_access_mask |= eperm;
+ } else if ((mode & 0010) || (mode & 0001))
+ tace[1].a_access_mask |= eperm;
+
+ /* Check if the acl count matches */
+ p = 3;
+ for (i = 0; i < 3; i++) {
+ if (tace[i].a_access_mask != 0)
+ p++;
+ }
+ if (acl->acl_cnt != p)
+ return (0);
+
+ p = 0;
+ for (i = 0; i < 6; i++) {
+ if (tace[i].a_access_mask != 0) {
+ ace = &((ace_t *)acl->acl_aclp)[p];
+ /*
+ * Illumos added ACE_DELETE_CHILD to write perms for
+ * directories. We have to check against that, too.
+ */
+ if (ace->a_flags != tace[i].a_flags ||
+ ace->a_type != tace[i].a_type ||
+ (ace->a_access_mask != tace[i].a_access_mask &&
+ ((acl->acl_flags & ACL_IS_DIR) == 0 ||
+ (tace[i].a_access_mask & wperm) == 0 ||
+ ace->a_access_mask !=
+ (tace[i].a_access_mask | ACE_DELETE_CHILD))))
+ return (0);
+ p++;
+ }
+ }
+
+ *trivialp = 1;
+ return (0);
+}
+#endif /* HAVE_SUN_ACL */
+
+#if HAVE_SUN_ACL
+/*
+ * Translate Solaris POSIX.1e and NFSv4 ACLs into libarchive internal ACL
+ */
+static int
+translate_acl(struct archive_read_disk *a,
+ struct archive_entry *entry, acl_t *acl, int default_entry_acl_type)
+{
+ int e, i;
+ int ae_id, ae_tag, ae_perm;
+ int entry_acl_type;
+ const char *ae_name;
+ aclent_t *aclent;
+ ace_t *ace;
+
+ (void)default_entry_acl_type;
+
+ if (acl->acl_cnt <= 0)
+ return (ARCHIVE_OK);
+
+ for (e = 0; e < acl->acl_cnt; e++) {
+ ae_name = NULL;
+ ae_tag = 0;
+ ae_perm = 0;
+
+ if (acl->acl_type == ACE_T) {
+ ace = &((ace_t *)acl->acl_aclp)[e];
+ ae_id = ace->a_who;
+
+ switch(ace->a_type) {
+ case ACE_ACCESS_ALLOWED_ACE_TYPE:
+ entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_ALLOW;
+ break;
+ case ACE_ACCESS_DENIED_ACE_TYPE:
+ entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_DENY;
+ break;
+ case ACE_SYSTEM_AUDIT_ACE_TYPE:
+ entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_ACCESS;
+ break;
+ case ACE_SYSTEM_ALARM_ACE_TYPE:
+ entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_ALARM;
+ break;
+ default:
+ /* Unknown entry type, skip */
+ continue;
+ }
+
+ if ((ace->a_flags & ACE_OWNER) != 0)
+ ae_tag = ARCHIVE_ENTRY_ACL_USER_OBJ;
+ else if ((ace->a_flags & ACE_GROUP) != 0)
+ ae_tag = ARCHIVE_ENTRY_ACL_GROUP_OBJ;
+ else if ((ace->a_flags & ACE_EVERYONE) != 0)
+ ae_tag = ARCHIVE_ENTRY_ACL_EVERYONE;
+ else if ((ace->a_flags & ACE_IDENTIFIER_GROUP) != 0) {
+ ae_tag = ARCHIVE_ENTRY_ACL_GROUP;
+ ae_name = archive_read_disk_gname(&a->archive,
+ ae_id);
+ } else {
+ ae_tag = ARCHIVE_ENTRY_ACL_USER;
+ ae_name = archive_read_disk_uname(&a->archive,
+ ae_id);
+ }
+
+ for (i = 0; i < (int)(sizeof(acl_inherit_map) /
+ sizeof(acl_inherit_map[0])); ++i) {
+ if ((ace->a_flags &
+ acl_inherit_map[i].platform_inherit) != 0)
+ ae_perm |=
+ acl_inherit_map[i].archive_inherit;
+ }
+
+ for (i = 0; i < (int)(sizeof(acl_perm_map) /
+ sizeof(acl_perm_map[0])); ++i) {
+ if ((ace->a_access_mask &
+ acl_perm_map[i].platform_perm) != 0)
+ ae_perm |=
+ acl_perm_map[i].archive_perm;
+ }
+ } else {
+ aclent = &((aclent_t *)acl->acl_aclp)[e];
+ if ((aclent->a_type & ACL_DEFAULT) != 0)
+ entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_DEFAULT;
+ else
+ entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_ACCESS;
+ ae_id = aclent->a_id;
+
+ switch(aclent->a_type) {
+ case DEF_USER:
+ case USER:
+ ae_name = archive_read_disk_uname(&a->archive,
+ ae_id);
+ ae_tag = ARCHIVE_ENTRY_ACL_USER;
+ break;
+ case DEF_GROUP:
+ case GROUP:
+ ae_name = archive_read_disk_gname(&a->archive,
+ ae_id);
+ ae_tag = ARCHIVE_ENTRY_ACL_GROUP;
+ break;
+ case DEF_CLASS_OBJ:
+ case CLASS_OBJ:
+ ae_tag = ARCHIVE_ENTRY_ACL_MASK;
+ break;
+ case DEF_USER_OBJ:
+ case USER_OBJ:
+ ae_tag = ARCHIVE_ENTRY_ACL_USER_OBJ;
+ break;
+ case DEF_GROUP_OBJ:
+ case GROUP_OBJ:
+ ae_tag = ARCHIVE_ENTRY_ACL_GROUP_OBJ;
+ break;
+ case DEF_OTHER_OBJ:
+ case OTHER_OBJ:
+ ae_tag = ARCHIVE_ENTRY_ACL_OTHER;
+ break;
+ default:
+ /* Unknown tag type, skip */
+ continue;
+ }
+
+ if ((aclent->a_perm & 1) != 0)
+ ae_perm |= ARCHIVE_ENTRY_ACL_EXECUTE;
+ if ((aclent->a_perm & 2) != 0)
+ ae_perm |= ARCHIVE_ENTRY_ACL_WRITE;
+ if ((aclent->a_perm & 4) != 0)
+ ae_perm |= ARCHIVE_ENTRY_ACL_READ;
+ } /* default_entry_acl_type != ARCHIVE_ENTRY_ACL_TYPE_NFS4 */
+
+ archive_entry_acl_add_entry(entry, entry_acl_type,
+ ae_perm, ae_tag, ae_id, ae_name);
+ }
+ return (ARCHIVE_OK);
+}
+#else /* !HAVE_SUN_ACL */
+/*
+ * Translate POSIX.1e (Linux), FreeBSD (both POSIX.1e and NFSv4) and
+ * MacOS (NFSv4 only) ACLs into libarchive internal structure
+ */
static int
translate_acl(struct archive_read_disk *a,
struct archive_entry *entry, acl_t acl, int default_entry_acl_type)
{
acl_tag_t acl_tag;
-#ifdef ACL_TYPE_NFS4
+#if HAVE_ACL_TYPE_NFS4
acl_entry_type_t acl_type;
- acl_flagset_t acl_flagset;
int brand;
#endif
+#if HAVE_ACL_TYPE_NFS4 || HAVE_DARWIN_ACL
+ acl_flagset_t acl_flagset;
+#endif
acl_entry_t acl_entry;
acl_permset_t acl_permset;
int i, entry_acl_type;
int r, s, ae_id, ae_tag, ae_perm;
+#if !HAVE_DARWIN_ACL
+ void *q;
+#endif
const char *ae_name;
-#ifdef ACL_TYPE_NFS4
+#if HAVE_ACL_TYPE_NFS4
// FreeBSD "brands" ACLs as POSIX.1e or NFSv4
// Make sure the "brand" on this ACL is consistent
// with the default_entry_acl_type bits provided.
@@ -634,14 +1199,19 @@ translate_acl(struct archive_read_disk *a,
}
#endif
-
s = acl_get_entry(acl, ACL_FIRST_ENTRY, &acl_entry);
if (s == -1) {
archive_set_error(&a->archive, errno,
"Failed to get first ACL entry");
return (ARCHIVE_WARN);
}
- while (s == 1) {
+
+#if HAVE_DARWIN_ACL
+ while (s == 0)
+#else /* FreeBSD, Linux */
+ while (s == 1)
+#endif
+ {
ae_id = -1;
ae_name = NULL;
ae_perm = 0;
@@ -652,14 +1222,25 @@ translate_acl(struct archive_read_disk *a,
return (ARCHIVE_WARN);
}
switch (acl_tag) {
+#if !HAVE_DARWIN_ACL /* FreeBSD, Linux */
case ACL_USER:
- ae_id = (int)*(uid_t *)acl_get_qualifier(acl_entry);
- ae_name = archive_read_disk_uname(&a->archive, ae_id);
+ q = acl_get_qualifier(acl_entry);
+ if (q != NULL) {
+ ae_id = (int)*(uid_t *)q;
+ acl_free(q);
+ ae_name = archive_read_disk_uname(&a->archive,
+ ae_id);
+ }
ae_tag = ARCHIVE_ENTRY_ACL_USER;
break;
case ACL_GROUP:
- ae_id = (int)*(gid_t *)acl_get_qualifier(acl_entry);
- ae_name = archive_read_disk_gname(&a->archive, ae_id);
+ q = acl_get_qualifier(acl_entry);
+ if (q != NULL) {
+ ae_id = (int)*(gid_t *)q;
+ acl_free(q);
+ ae_name = archive_read_disk_gname(&a->archive,
+ ae_id);
+ }
ae_tag = ARCHIVE_ENTRY_ACL_GROUP;
break;
case ACL_MASK:
@@ -674,21 +1255,44 @@ translate_acl(struct archive_read_disk *a,
case ACL_OTHER:
ae_tag = ARCHIVE_ENTRY_ACL_OTHER;
break;
-#ifdef ACL_TYPE_NFS4
+#if HAVE_ACL_TYPE_NFS4
case ACL_EVERYONE:
ae_tag = ARCHIVE_ENTRY_ACL_EVERYONE;
break;
#endif
+#else /* HAVE_DARWIN_ACL */
+ case ACL_EXTENDED_ALLOW:
+ entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_ALLOW;
+ r = translate_guid(&a->archive, acl_entry, &ae_id,
+ &ae_tag, &ae_name);
+ break;
+ case ACL_EXTENDED_DENY:
+ entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_DENY;
+ r = translate_guid(&a->archive, acl_entry, &ae_id,
+ &ae_tag, &ae_name);
+ break;
+#endif /* HAVE_DARWIN_ACL */
default:
/* Skip types that libarchive can't support. */
s = acl_get_entry(acl, ACL_NEXT_ENTRY, &acl_entry);
continue;
}
+#if HAVE_DARWIN_ACL
+ /* Skip if translate_guid() above failed */
+ if (r != 0) {
+ s = acl_get_entry(acl, ACL_NEXT_ENTRY, &acl_entry);
+ continue;
+ }
+#endif
+
+#if !HAVE_DARWIN_ACL
// XXX acl_type maps to allow/deny/audit/YYYY bits
entry_acl_type = default_entry_acl_type;
-#ifdef ACL_TYPE_NFS4
+#endif
+#if HAVE_ACL_TYPE_NFS4 || HAVE_DARWIN_ACL
if (default_entry_acl_type & ARCHIVE_ENTRY_ACL_TYPE_NFS4) {
+#if HAVE_ACL_TYPE_NFS4
/*
* acl_get_entry_type_np() fails with non-NFSv4 ACLs
*/
@@ -715,6 +1319,7 @@ translate_acl(struct archive_read_disk *a,
"Invalid NFSv4 ACL entry type");
return (ARCHIVE_WARN);
}
+#endif /* HAVE_ACL_TYPE_NFS4 */
/*
* Libarchive stores "flag" (NFSv4 inheritance bits)
@@ -727,7 +1332,7 @@ translate_acl(struct archive_read_disk *a,
"Failed to get flagset from a NFSv4 ACL entry");
return (ARCHIVE_WARN);
}
- for (i = 0; i < (int)(sizeof(acl_inherit_map) / sizeof(acl_inherit_map[0])); ++i) {
+ for (i = 0; i < (int)(sizeof(acl_inherit_map) / sizeof(acl_inherit_map[0])); ++i) {
r = acl_get_flag_np(acl_flagset,
acl_inherit_map[i].platform_inherit);
if (r == -1) {
@@ -737,9 +1342,9 @@ translate_acl(struct archive_read_disk *a,
return (ARCHIVE_WARN);
} else if (r)
ae_perm |= acl_inherit_map[i].archive_inherit;
- }
+ }
}
-#endif
+#endif /* HAVE_ACL_TYPE_NFS4 || HAVE_DARWIN_ACL */
if (acl_get_permset(acl_entry, &acl_permset) != 0) {
archive_set_error(&a->archive, errno,
@@ -765,15 +1370,18 @@ translate_acl(struct archive_read_disk *a,
ae_id, ae_name);
s = acl_get_entry(acl, ACL_NEXT_ENTRY, &acl_entry);
+#if !HAVE_DARWIN_ACL
if (s == -1) {
archive_set_error(&a->archive, errno,
"Failed to get next ACL entry");
return (ARCHIVE_WARN);
}
+#endif
}
return (ARCHIVE_OK);
}
-#else
+#endif /* !HAVE_SUN_ACL */
+#else /* !HAVE_POSIX_ACL && !HAVE_NFS4_ACL */
static int
setup_acls(struct archive_read_disk *a,
struct archive_entry *entry, int *fd)
@@ -783,7 +1391,7 @@ setup_acls(struct archive_read_disk *a,
(void)fd; /* UNUSED */
return (ARCHIVE_OK);
}
-#endif
+#endif /* !HAVE_POSIX_ACL && !HAVE_NFS4_ACL */
#if (HAVE_FGETXATTR && HAVE_FLISTXATTR && HAVE_LISTXATTR && \
HAVE_LLISTXATTR && HAVE_GETXATTR && HAVE_LGETXATTR) || \
diff --git a/contrib/libarchive/libarchive/archive_read_disk_posix.c b/contrib/libarchive/libarchive/archive_read_disk_posix.c
index bc7fad1..b893704 100644
--- a/contrib/libarchive/libarchive/archive_read_disk_posix.c
+++ b/contrib/libarchive/libarchive/archive_read_disk_posix.c
@@ -675,7 +675,7 @@ setup_suitable_read_buffer(struct archive_read_disk *a)
asize = cf->min_xfer_size;
/* Increase a buffer size up to 64K bytes in
- * a proper incremant size. */
+ * a proper increment size. */
while (asize < 1024*64)
asize += incr;
/* Take a margin to adjust to the filesystem
@@ -1656,7 +1656,7 @@ setup_current_filesystem(struct archive_read_disk *a)
archive_set_error(&a->archive, errno, "statvfs failed");
return (ARCHIVE_FAILED);
} else if (xr == 1) {
- /* Usuall come here unless NetBSD supports _PC_REC_XFER_ALIGN
+ /* Usually come here unless NetBSD supports _PC_REC_XFER_ALIGN
* for pathconf() function. */
t->current_filesystem->xfer_align = sfs.f_frsize;
t->current_filesystem->max_xfer_size = -1;
@@ -1944,7 +1944,7 @@ setup_current_filesystem(struct archive_read_disk *a)
if (nm == -1)
# endif /* _PC_NAME_MAX */
/*
- * Some sysmtes (HP-UX or others?) incorrectly defined
+ * Some systems (HP-UX or others?) incorrectly defined
* NAME_MAX macro to be a smaller value.
*/
# if defined(NAME_MAX) && NAME_MAX >= 255
diff --git a/contrib/libarchive/libarchive/archive_read_open_filename.c b/contrib/libarchive/libarchive/archive_read_open_filename.c
index b2d52aa..64b0179 100644
--- a/contrib/libarchive/libarchive/archive_read_open_filename.c
+++ b/contrib/libarchive/libarchive/archive_read_open_filename.c
@@ -222,7 +222,7 @@ file_open(struct archive *a, void *client_data)
void *buffer;
const char *filename = NULL;
const wchar_t *wfilename = NULL;
- int fd;
+ int fd = -1;
int is_disk_like = 0;
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
off_t mediasize = 0; /* FreeBSD-specific, so off_t okay here. */
@@ -277,7 +277,7 @@ file_open(struct archive *a, void *client_data)
#else
archive_set_error(a, ARCHIVE_ERRNO_MISC,
"Unexpedted operation in archive_read_open_filename");
- return (ARCHIVE_FATAL);
+ goto fail;
#endif
}
if (fstat(fd, &st) != 0) {
@@ -287,7 +287,7 @@ file_open(struct archive *a, void *client_data)
else
archive_set_error(a, errno, "Can't stat '%s'",
filename);
- return (ARCHIVE_FATAL);
+ goto fail;
}
/*
@@ -356,11 +356,9 @@ file_open(struct archive *a, void *client_data)
mine->block_size = new_block_size;
}
buffer = malloc(mine->block_size);
- if (mine == NULL || buffer == NULL) {
+ if (buffer == NULL) {
archive_set_error(a, ENOMEM, "No memory");
- free(mine);
- free(buffer);
- return (ARCHIVE_FATAL);
+ goto fail;
}
mine->buffer = buffer;
mine->fd = fd;
@@ -372,6 +370,14 @@ file_open(struct archive *a, void *client_data)
mine->use_lseek = 1;
return (ARCHIVE_OK);
+fail:
+ /*
+ * Don't close file descriptors not opened or ones pointing referring
+ * to `FNT_STDIN`.
+ */
+ if (fd != -1 && fd != 0)
+ close(fd);
+ return (ARCHIVE_FATAL);
}
static ssize_t
diff --git a/contrib/libarchive/libarchive/archive_read_support_filter_lz4.c b/contrib/libarchive/libarchive/archive_read_support_filter_lz4.c
index 37b2f59..663e2d3 100644
--- a/contrib/libarchive/libarchive/archive_read_support_filter_lz4.c
+++ b/contrib/libarchive/libarchive/archive_read_support_filter_lz4.c
@@ -180,7 +180,7 @@ lz4_reader_bid(struct archive_read_filter_bidder *self,
return (0);
bits_checked += 8;
BD = buffer[5];
- /* A block maximum size shuld be more than 3. */
+ /* A block maximum size should be more than 3. */
if (((BD & 0x70) >> 4) < 4)
return (0);
/* Reserved bits must be "0". */
@@ -417,7 +417,7 @@ lz4_filter_read_descriptor(struct archive_read_filter *self)
/* Reserved bits must be zero. */
if (bd & 0x8f)
goto malformed_error;
- /* Get a maxinum block size. */
+ /* Get a maximum block size. */
switch (read_buf[1] >> 4) {
case 4: /* 64 KB */
state->flags.block_maximum_size = 64 * 1024;
@@ -627,7 +627,7 @@ lz4_filter_read_default_stream(struct archive_read_filter *self, const void **p)
if (state->stage == SELECT_STREAM) {
state->stage = READ_DEFAULT_STREAM;
- /* First, read a desciprtor. */
+ /* First, read a descriptor. */
if((ret = lz4_filter_read_descriptor(self)) != ARCHIVE_OK)
return (ret);
state->stage = READ_DEFAULT_BLOCK;
@@ -706,6 +706,11 @@ lz4_filter_read_legacy_stream(struct archive_read_filter *self, const void **p)
/* Make sure we have a whole block. */
read_buf = __archive_read_filter_ahead(self->upstream,
4 + compressed, NULL);
+ if (read_buf == NULL) {
+ archive_set_error(&(self->archive->archive),
+ ARCHIVE_ERRNO_MISC, "truncated lz4 input");
+ return (ARCHIVE_FATAL);
+ }
ret = LZ4_decompress_safe(read_buf + 4, state->out_block,
compressed, (int)state->out_block_size);
if (ret < 0) {
diff --git a/contrib/libarchive/libarchive/archive_read_support_filter_lzop.c b/contrib/libarchive/libarchive/archive_read_support_filter_lzop.c
index 44ac9964..a1c392f 100644
--- a/contrib/libarchive/libarchive/archive_read_support_filter_lzop.c
+++ b/contrib/libarchive/libarchive/archive_read_support_filter_lzop.c
@@ -436,7 +436,7 @@ lzop_filter_read(struct archive_read_filter *self, const void **p)
}
/*
- * Drive lzo uncompresison.
+ * Drive lzo uncompression.
*/
out_size = (lzo_uint)state->uncompressed_size;
r = lzo1x_decompress_safe(b, (lzo_uint)state->compressed_size,
diff --git a/contrib/libarchive/libarchive/archive_read_support_filter_program.c b/contrib/libarchive/libarchive/archive_read_support_filter_program.c
index 66dc2f4..b8bf128 100644
--- a/contrib/libarchive/libarchive/archive_read_support_filter_program.c
+++ b/contrib/libarchive/libarchive/archive_read_support_filter_program.c
@@ -430,6 +430,7 @@ __archive_read_program(struct archive_read_filter *self, const char *cmd)
&state->child_stdout);
if (child == -1) {
free(state->out_buf);
+ archive_string_free(&state->description);
free(state);
archive_set_error(&self->archive->archive, EINVAL,
"Can't initialize filter; unable to run program \"%s\"",
@@ -441,6 +442,7 @@ __archive_read_program(struct archive_read_filter *self, const char *cmd)
if (state->child == NULL) {
child_stop(self, state);
free(state->out_buf);
+ archive_string_free(&state->description);
free(state);
archive_set_error(&self->archive->archive, EINVAL,
"Can't initialize filter; unable to run program \"%s\"",
diff --git a/contrib/libarchive/libarchive/archive_read_support_format_7zip.c b/contrib/libarchive/libarchive/archive_read_support_format_7zip.c
index f8d52fb..3387eaf 100644
--- a/contrib/libarchive/libarchive/archive_read_support_format_7zip.c
+++ b/contrib/libarchive/libarchive/archive_read_support_format_7zip.c
@@ -552,7 +552,7 @@ skip_sfx(struct archive_read *a, ssize_t bytes_avail)
/*
* If bytes_avail > SFX_MIN_ADDR we do not have to call
* __archive_read_seek() at this time since we have
- * alredy had enough data.
+ * already had enough data.
*/
if (bytes_avail > SFX_MIN_ADDR)
__archive_read_consume(a, SFX_MIN_ADDR);
@@ -760,7 +760,7 @@ archive_read_format_7zip_read_header(struct archive_read *a,
symsize += size;
}
if (symsize == 0) {
- /* If there is no synname, handle it as a regular
+ /* If there is no symname, handle it as a regular
* file. */
zip_entry->mode &= ~AE_IFMT;
zip_entry->mode |= AE_IFREG;
@@ -3288,7 +3288,7 @@ read_stream(struct archive_read *a, const void **buff, size_t size,
return (r);
/*
- * Skip the bytes we alrady has skipped in skip_stream().
+ * Skip the bytes we already has skipped in skip_stream().
*/
while (skip_bytes) {
ssize_t skipped;
@@ -3506,7 +3506,7 @@ setup_decode_folder(struct archive_read *a, struct _7z_folder *folder,
return (ARCHIVE_FATAL);
}
- /* Allocate memory for the decorded data of a sub
+ /* Allocate memory for the decoded data of a sub
* stream. */
b[i] = malloc((size_t)zip->folder_outbytes_remaining);
if (b[i] == NULL) {
@@ -3591,7 +3591,7 @@ skip_stream(struct archive_read *a, size_t skip_bytes)
if (zip->folder_index == 0) {
/*
* Optimization for a list mode.
- * Avoid unncecessary decoding operations.
+ * Avoid unnecessary decoding operations.
*/
zip->si.ci.folders[zip->entry->folderIndex].skipped_bytes
+= skip_bytes;
diff --git a/contrib/libarchive/libarchive/archive_read_support_format_cab.c b/contrib/libarchive/libarchive/archive_read_support_format_cab.c
index 2bdc1e2..e2f8c6b 100644
--- a/contrib/libarchive/libarchive/archive_read_support_format_cab.c
+++ b/contrib/libarchive/libarchive/archive_read_support_format_cab.c
@@ -1495,6 +1495,8 @@ cab_read_ahead_cfdata_deflate(struct archive_read *a, ssize_t *avail)
/* Cut out a tow-byte MSZIP signature(0x43, 0x4b). */
if (mszip > 0) {
+ if (bytes_avail <= 0)
+ goto nomszip;
if (bytes_avail <= mszip) {
if (mszip == 2) {
if (cab->stream.next_in[0] != 0x43)
diff --git a/contrib/libarchive/libarchive/archive_read_support_format_cpio.c b/contrib/libarchive/libarchive/archive_read_support_format_cpio.c
index 2a5a829..43e6ff9 100644
--- a/contrib/libarchive/libarchive/archive_read_support_format_cpio.c
+++ b/contrib/libarchive/libarchive/archive_read_support_format_cpio.c
@@ -356,7 +356,7 @@ archive_read_format_cpio_read_header(struct archive_read *a,
struct archive_entry *entry)
{
struct cpio *cpio;
- const void *h;
+ const void *h, *hl;
struct archive_string_conv *sconv;
size_t namelength;
size_t name_pad;
@@ -406,11 +406,11 @@ archive_read_format_cpio_read_header(struct archive_read *a,
"Rejecting malformed cpio archive: symlink contents exceed 1 megabyte");
return (ARCHIVE_FATAL);
}
- h = __archive_read_ahead(a,
+ hl = __archive_read_ahead(a,
(size_t)cpio->entry_bytes_remaining, NULL);
- if (h == NULL)
+ if (hl == NULL)
return (ARCHIVE_FATAL);
- if (archive_entry_copy_symlink_l(entry, (const char *)h,
+ if (archive_entry_copy_symlink_l(entry, (const char *)hl,
(size_t)cpio->entry_bytes_remaining, sconv) != 0) {
if (errno == ENOMEM) {
archive_set_error(&a->archive, ENOMEM,
@@ -434,7 +434,8 @@ archive_read_format_cpio_read_header(struct archive_read *a,
* header. XXX */
/* Compare name to "TRAILER!!!" to test for end-of-archive. */
- if (namelength == 11 && strcmp((const char *)h, "TRAILER!!!") == 0) {
+ if (namelength == 11 && strncmp((const char *)h, "TRAILER!!!",
+ 11) == 0) {
/* TODO: Store file location of start of block. */
archive_clear_error(&a->archive);
return (ARCHIVE_EOF);
diff --git a/contrib/libarchive/libarchive/archive_read_support_format_iso9660.c b/contrib/libarchive/libarchive/archive_read_support_format_iso9660.c
index 3807abd..ebbfc2f 100644
--- a/contrib/libarchive/libarchive/archive_read_support_format_iso9660.c
+++ b/contrib/libarchive/libarchive/archive_read_support_format_iso9660.c
@@ -322,7 +322,7 @@ struct iso9660 {
struct archive_string pathname;
char seenRockridge; /* Set true if RR extensions are used. */
- char seenSUSP; /* Set true if SUSP is beging used. */
+ char seenSUSP; /* Set true if SUSP is being used. */
char seenJoliet;
unsigned char suspOffset;
@@ -374,7 +374,7 @@ struct iso9660 {
size_t utf16be_path_len;
unsigned char *utf16be_previous_path;
size_t utf16be_previous_path_len;
- /* Null buufer used in bidder to improve its performance. */
+ /* Null buffer used in bidder to improve its performance. */
unsigned char null[2048];
};
@@ -1199,7 +1199,7 @@ archive_read_format_iso9660_read_header(struct archive_read *a,
archive_string_conversion_from_charset(
&(a->archive), "UTF-16BE", 1);
if (iso9660->sconv_utf16be == NULL)
- /* Coundn't allocate memory */
+ /* Couldn't allocate memory */
return (ARCHIVE_FATAL);
}
if (iso9660->utf16be_path == NULL) {
@@ -1864,7 +1864,7 @@ parse_file_info(struct archive_read *a, struct file_info *parent,
if ((file->utf16be_name = malloc(name_len)) == NULL) {
archive_set_error(&a->archive, ENOMEM,
"No memory for file name");
- return (NULL);
+ goto fail;
}
memcpy(file->utf16be_name, p, name_len);
file->utf16be_bytes = name_len;
@@ -1943,10 +1943,8 @@ parse_file_info(struct archive_read *a, struct file_info *parent,
file->symlink_continues = 0;
rr_start += iso9660->suspOffset;
r = parse_rockridge(a, file, rr_start, rr_end);
- if (r != ARCHIVE_OK) {
- free(file);
- return (NULL);
- }
+ if (r != ARCHIVE_OK)
+ goto fail;
/*
* A file size of symbolic link files in ISO images
* made by makefs is not zero and its location is
@@ -1990,7 +1988,7 @@ parse_file_info(struct archive_read *a, struct file_info *parent,
archive_set_error(&a->archive,
ARCHIVE_ERRNO_MISC,
"Invalid Rockridge RE");
- return (NULL);
+ goto fail;
}
/*
* Sanity check: file does not have "CL" extension.
@@ -1999,7 +1997,7 @@ parse_file_info(struct archive_read *a, struct file_info *parent,
archive_set_error(&a->archive,
ARCHIVE_ERRNO_MISC,
"Invalid Rockridge RE and CL");
- return (NULL);
+ goto fail;
}
/*
* Sanity check: The file type must be a directory.
@@ -2008,7 +2006,7 @@ parse_file_info(struct archive_read *a, struct file_info *parent,
archive_set_error(&a->archive,
ARCHIVE_ERRNO_MISC,
"Invalid Rockridge RE");
- return (NULL);
+ goto fail;
}
} else if (parent != NULL && parent->rr_moved)
file->rr_moved_has_re_only = 0;
@@ -2022,7 +2020,7 @@ parse_file_info(struct archive_read *a, struct file_info *parent,
archive_set_error(&a->archive,
ARCHIVE_ERRNO_MISC,
"Invalid Rockridge CL");
- return (NULL);
+ goto fail;
}
/*
* Sanity check: The file type must be a regular file.
@@ -2031,7 +2029,7 @@ parse_file_info(struct archive_read *a, struct file_info *parent,
archive_set_error(&a->archive,
ARCHIVE_ERRNO_MISC,
"Invalid Rockridge CL");
- return (NULL);
+ goto fail;
}
parent->subdirs++;
/* Overwrite an offset and a number of this "CL" entry
@@ -2049,7 +2047,7 @@ parse_file_info(struct archive_read *a, struct file_info *parent,
archive_set_error(&a->archive,
ARCHIVE_ERRNO_MISC,
"Invalid Rockridge CL");
- return (NULL);
+ goto fail;
}
}
if (file->cl_offset == file->offset ||
@@ -2057,7 +2055,7 @@ parse_file_info(struct archive_read *a, struct file_info *parent,
archive_set_error(&a->archive,
ARCHIVE_ERRNO_MISC,
"Invalid Rockridge CL");
- return (NULL);
+ goto fail;
}
}
}
@@ -2088,6 +2086,10 @@ parse_file_info(struct archive_read *a, struct file_info *parent,
#endif
register_file(iso9660, file);
return (file);
+fail:
+ archive_string_free(&file->name);
+ free(file);
+ return (NULL);
}
static int
@@ -2407,7 +2409,7 @@ read_CE(struct archive_read *a, struct iso9660 *iso9660)
return (ARCHIVE_FATAL);
} while (heap->cnt &&
heap->reqs[0].offset == iso9660->current_position);
- /* NOTE: Do not move this consume's code to fron of
+ /* NOTE: Do not move this consume's code to front of
* do-while loop. Registration of nested CE extension
* might cause error because of current position. */
__archive_read_consume(a, step);
@@ -2729,7 +2731,7 @@ next_cache_entry(struct archive_read *a, struct iso9660 *iso9660,
if (file == NULL) {
/*
* If directory entries all which are descendant of
- * rr_moved are stil remaning, expose their.
+ * rr_moved are still remaining, expose their.
*/
if (iso9660->re_files.first != NULL &&
iso9660->rr_moved != NULL &&
@@ -2852,7 +2854,7 @@ next_cache_entry(struct archive_read *a, struct iso9660 *iso9660,
empty_files.last = &empty_files.first;
/* Collect files which has the same file serial number.
* Peek pending_files so that file which number is different
- * is not put bak. */
+ * is not put back. */
while (iso9660->pending_files.used > 0 &&
(iso9660->pending_files.files[0]->number == -1 ||
iso9660->pending_files.files[0]->number == number)) {
@@ -2860,7 +2862,7 @@ next_cache_entry(struct archive_read *a, struct iso9660 *iso9660,
/* This file has the same offset
* but it's wrong offset which empty files
* and symlink files have.
- * NOTE: This wrong offse was recorded by
+ * NOTE: This wrong offset was recorded by
* old mkisofs utility. If ISO images is
* created by latest mkisofs, this does not
* happen.
diff --git a/contrib/libarchive/libarchive/archive_read_support_format_lha.c b/contrib/libarchive/libarchive/archive_read_support_format_lha.c
index a7f1d8d..d77a7c2 100644
--- a/contrib/libarchive/libarchive/archive_read_support_format_lha.c
+++ b/contrib/libarchive/libarchive/archive_read_support_format_lha.c
@@ -924,6 +924,9 @@ lha_read_file_header_1(struct archive_read *a, struct lha *lha)
/* Get a real compressed file size. */
lha->compsize -= extdsize - 2;
+ if (lha->compsize < 0)
+ goto invalid; /* Invalid compressed file size */
+
if (sum_calculated != headersum) {
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
"LHa header sum error");
@@ -1711,7 +1714,7 @@ lha_crc16(uint16_t crc, const void *pp, size_t len)
*/
for (;len >= 8; len -= 8) {
/* This if statement expects compiler optimization will
- * remove the stament which will not be executed. */
+ * remove the statement which will not be executed. */
#undef bswap16
#if defined(_MSC_VER) && _MSC_VER >= 1400 /* Visual Studio */
# define bswap16(x) _byteswap_ushort(x)
diff --git a/contrib/libarchive/libarchive/archive_read_support_format_mtree.c b/contrib/libarchive/libarchive/archive_read_support_format_mtree.c
index 02c1251..eb695f8 100644
--- a/contrib/libarchive/libarchive/archive_read_support_format_mtree.c
+++ b/contrib/libarchive/libarchive/archive_read_support_format_mtree.c
@@ -715,13 +715,13 @@ detect_form(struct archive_read *a, int *is_form_d)
}
} else
break;
- } else if (strncmp(p, "/set", 4) == 0) {
+ } else if (len > 4 && strncmp(p, "/set", 4) == 0) {
if (bid_keyword_list(p+4, len-4, 0, 0) <= 0)
break;
/* This line continues. */
if (p[len-nl-1] == '\\')
multiline = 2;
- } else if (strncmp(p, "/unset", 6) == 0) {
+ } else if (len > 6 && strncmp(p, "/unset", 6) == 0) {
if (bid_keyword_list(p+6, len-6, 1, 0) <= 0)
break;
/* This line continues. */
@@ -1019,11 +1019,11 @@ read_mtree(struct archive_read *a, struct mtree *mtree)
if (*p != '/') {
r = process_add_entry(a, mtree, &global, p, len,
&last_entry, is_form_d);
- } else if (strncmp(p, "/set", 4) == 0) {
+ } else if (len > 4 && strncmp(p, "/set", 4) == 0) {
if (p[4] != ' ' && p[4] != '\t')
break;
r = process_global_set(a, &global, p);
- } else if (strncmp(p, "/unset", 6) == 0) {
+ } else if (len > 6 && strncmp(p, "/unset", 6) == 0) {
if (p[6] != ' ' && p[6] != '\t')
break;
r = process_global_unset(a, &global, p);
@@ -1608,8 +1608,11 @@ parse_keyword(struct archive_read *a, struct mtree *mtree,
if (*val == '.') {
++val;
ns = (long)mtree_atol10(&val);
- } else
- ns = 0;
+ if (ns < 0)
+ ns = 0;
+ else if (ns > 999999999)
+ ns = 999999999;
+ }
if (m > my_time_t_max)
m = my_time_t_max;
else if (m < my_time_t_min)
diff --git a/contrib/libarchive/libarchive/archive_read_support_format_rar.c b/contrib/libarchive/libarchive/archive_read_support_format_rar.c
index 9c9f6f1..1e9849f 100644
--- a/contrib/libarchive/libarchive/archive_read_support_format_rar.c
+++ b/contrib/libarchive/libarchive/archive_read_support_format_rar.c
@@ -906,7 +906,7 @@ archive_read_format_rar_read_header(struct archive_read *a,
sizeof(rar->reserved2));
}
- /* Main header is password encrytped, so we cannot read any
+ /* Main header is password encrypted, so we cannot read any
file names or any other info about files from the header. */
if (rar->main_flags & MHD_PASSWORD)
{
diff --git a/contrib/libarchive/libarchive/archive_read_support_format_tar.c b/contrib/libarchive/libarchive/archive_read_support_format_tar.c
index 4f69c6e..446d005 100644
--- a/contrib/libarchive/libarchive/archive_read_support_format_tar.c
+++ b/contrib/libarchive/libarchive/archive_read_support_format_tar.c
@@ -1,6 +1,7 @@
/*-
* Copyright (c) 2003-2007 Tim Kientzle
* Copyright (c) 2011-2012 Michihiro NAKAJIMA
+ * Copyright (c) 2016 Martin Matuska
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -203,9 +204,14 @@ static int archive_read_format_tar_read_header(struct archive_read *,
struct archive_entry *);
static int checksum(struct archive_read *, const void *);
static int pax_attribute(struct archive_read *, struct tar *,
- struct archive_entry *, const char *key, const char *value);
+ struct archive_entry *, const char *key, const char *value,
+ size_t value_length);
+static int pax_attribute_acl(struct archive_read *, struct tar *,
+ struct archive_entry *, const char *, int);
+static int pax_attribute_xattr(struct archive_entry *, const char *,
+ const char *);
static int pax_header(struct archive_read *, struct tar *,
- struct archive_entry *, char *attr);
+ struct archive_entry *, struct archive_string *);
static void pax_time(const char *, int64_t *sec, long *nanos);
static ssize_t readline(struct archive_read *, struct tar *, const char **,
ssize_t limit, size_t *);
@@ -938,7 +944,7 @@ header_Solaris_ACL(struct archive_read *a, struct tar *tar,
{
const struct archive_entry_header_ustar *header;
size_t size;
- int err;
+ int err, acl_type;
int64_t type;
char *acl, *p;
@@ -983,11 +989,12 @@ header_Solaris_ACL(struct archive_read *a, struct tar *tar,
switch ((int)type & ~0777777) {
case 01000000:
/* POSIX.1e ACL */
+ acl_type = ARCHIVE_ENTRY_ACL_TYPE_ACCESS;
break;
case 03000000:
- archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
- "Solaris NFSv4 ACLs not supported");
- return (ARCHIVE_WARN);
+ /* NFSv4 ACL */
+ acl_type = ARCHIVE_ENTRY_ACL_TYPE_NFS4;
+ break;
default:
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
"Malformed Solaris ACL attribute (unsupported type %o)",
@@ -1016,8 +1023,8 @@ header_Solaris_ACL(struct archive_read *a, struct tar *tar,
return (ARCHIVE_FATAL);
}
archive_strncpy(&(tar->localname), acl, p - acl);
- err = archive_acl_parse_l(archive_entry_acl(entry),
- tar->localname.s, ARCHIVE_ENTRY_ACL_TYPE_ACCESS, tar->sconv_acl);
+ err = archive_acl_from_text_l(archive_entry_acl(entry),
+ tar->localname.s, acl_type, tar->sconv_acl);
if (err != ARCHIVE_OK) {
if (errno == ENOMEM) {
archive_set_error(&a->archive, ENOMEM,
@@ -1478,7 +1485,7 @@ header_pax_extensions(struct archive_read *a, struct tar *tar,
* and then skip any fields in the standard header that were
* defined in the pax header.
*/
- err2 = pax_header(a, tar, entry, tar->pax_header.s);
+ err2 = pax_header(a, tar, entry, &tar->pax_header);
err = err_combine(err, err2);
tar->entry_padding = 0x1ff & (-tar->entry_bytes_remaining);
return (err);
@@ -1559,16 +1566,17 @@ header_ustar(struct archive_read *a, struct tar *tar,
*/
static int
pax_header(struct archive_read *a, struct tar *tar,
- struct archive_entry *entry, char *attr)
+ struct archive_entry *entry, struct archive_string *in_as)
{
- size_t attr_length, l, line_length;
+ size_t attr_length, l, line_length, value_length;
char *p;
char *key, *value;
struct archive_string *as;
struct archive_string_conv *sconv;
int err, err2;
+ char *attr = in_as->s;
- attr_length = strlen(attr);
+ attr_length = in_as->length;
tar->pax_hdrcharset_binary = 0;
archive_string_empty(&(tar->entry_gname));
archive_string_empty(&(tar->entry_linkpath));
@@ -1633,11 +1641,13 @@ pax_header(struct archive_read *a, struct tar *tar,
}
*p = '\0';
- /* Identify null-terminated 'value' portion. */
value = p + 1;
+ /* Some values may be binary data */
+ value_length = attr + line_length - 1 - value;
+
/* Identify this attribute and set it in the entry. */
- err2 = pax_attribute(a, tar, entry, key, value);
+ err2 = pax_attribute(a, tar, entry, key, value, value_length);
if (err2 == ARCHIVE_FATAL)
return (err2);
err = err_combine(err, err2);
@@ -1758,6 +1768,66 @@ pax_attribute_xattr(struct archive_entry *entry,
return 0;
}
+static int
+pax_attribute_schily_xattr(struct archive_entry *entry,
+ const char *name, const char *value, size_t value_length)
+{
+ if (strlen(name) < 14 || (memcmp(name, "SCHILY.xattr.", 13)) != 0)
+ return 1;
+
+ name += 13;
+
+ archive_entry_xattr_add_entry(entry, name, value, value_length);
+
+ return 0;
+}
+
+static int
+pax_attribute_acl(struct archive_read *a, struct tar *tar,
+ struct archive_entry *entry, const char *value, int type)
+{
+ int r;
+ const char* errstr;
+
+ switch (type) {
+ case ARCHIVE_ENTRY_ACL_TYPE_ACCESS:
+ errstr = "SCHILY.acl.access";
+ break;
+ case ARCHIVE_ENTRY_ACL_TYPE_DEFAULT:
+ errstr = "SCHILY.acl.default";
+ break;
+ case ARCHIVE_ENTRY_ACL_TYPE_NFS4:
+ errstr = "SCHILY.acl.ace";
+ break;
+ default:
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "Unknown ACL type: %d", type);
+ return(ARCHIVE_FATAL);
+ }
+
+ if (tar->sconv_acl == NULL) {
+ tar->sconv_acl =
+ archive_string_conversion_from_charset(
+ &(a->archive), "UTF-8", 1);
+ if (tar->sconv_acl == NULL)
+ return (ARCHIVE_FATAL);
+ }
+
+ r = archive_acl_from_text_l(archive_entry_acl(entry), value, type,
+ tar->sconv_acl);
+ if (r != ARCHIVE_OK) {
+ if (r == ARCHIVE_FATAL) {
+ archive_set_error(&a->archive, ENOMEM,
+ "%s %s", "Can't allocate memory for ",
+ errstr);
+ return (r);
+ }
+ archive_set_error(&a->archive,
+ ARCHIVE_ERRNO_MISC, "%s %s", "Parse error: ", errstr);
+ }
+ return (r);
+}
+
/*
* Parse a single key=value attribute. key/value pointers are
* assumed to point into reasonably long-lived storage.
@@ -1773,7 +1843,7 @@ pax_attribute_xattr(struct archive_entry *entry,
*/
static int
pax_attribute(struct archive_read *a, struct tar *tar,
- struct archive_entry *entry, const char *key, const char *value)
+ struct archive_entry *entry, const char *key, const char *value, size_t value_length)
{
int64_t s;
long n;
@@ -1876,53 +1946,20 @@ pax_attribute(struct archive_read *a, struct tar *tar,
case 'S':
/* We support some keys used by the "star" archiver */
if (strcmp(key, "SCHILY.acl.access") == 0) {
- if (tar->sconv_acl == NULL) {
- tar->sconv_acl =
- archive_string_conversion_from_charset(
- &(a->archive), "UTF-8", 1);
- if (tar->sconv_acl == NULL)
- return (ARCHIVE_FATAL);
- }
-
- r = archive_acl_parse_l(archive_entry_acl(entry),
- value, ARCHIVE_ENTRY_ACL_TYPE_ACCESS,
- tar->sconv_acl);
- if (r != ARCHIVE_OK) {
- err = r;
- if (err == ARCHIVE_FATAL) {
- archive_set_error(&a->archive, ENOMEM,
- "Can't allocate memory for "
- "SCHILY.acl.access");
- return (err);
- }
- archive_set_error(&a->archive,
- ARCHIVE_ERRNO_MISC,
- "Parse error: SCHILY.acl.access");
- }
+ r = pax_attribute_acl(a, tar, entry, value,
+ ARCHIVE_ENTRY_ACL_TYPE_ACCESS);
+ if (r == ARCHIVE_FATAL)
+ return (r);
} else if (strcmp(key, "SCHILY.acl.default") == 0) {
- if (tar->sconv_acl == NULL) {
- tar->sconv_acl =
- archive_string_conversion_from_charset(
- &(a->archive), "UTF-8", 1);
- if (tar->sconv_acl == NULL)
- return (ARCHIVE_FATAL);
- }
-
- r = archive_acl_parse_l(archive_entry_acl(entry),
- value, ARCHIVE_ENTRY_ACL_TYPE_DEFAULT,
- tar->sconv_acl);
- if (r != ARCHIVE_OK) {
- err = r;
- if (err == ARCHIVE_FATAL) {
- archive_set_error(&a->archive, ENOMEM,
- "Can't allocate memory for "
- "SCHILY.acl.default");
- return (err);
- }
- archive_set_error(&a->archive,
- ARCHIVE_ERRNO_MISC,
- "Parse error: SCHILY.acl.default");
- }
+ r = pax_attribute_acl(a, tar, entry, value,
+ ARCHIVE_ENTRY_ACL_TYPE_DEFAULT);
+ if (r == ARCHIVE_FATAL)
+ return (r);
+ } else if (strcmp(key, "SCHILY.acl.ace") == 0) {
+ r = pax_attribute_acl(a, tar, entry, value,
+ ARCHIVE_ENTRY_ACL_TYPE_NFS4);
+ if (r == ARCHIVE_FATAL)
+ return (r);
} else if (strcmp(key, "SCHILY.devmajor") == 0) {
archive_entry_set_rdevmajor(entry,
(dev_t)tar_atol10(value, strlen(value)));
@@ -1943,6 +1980,9 @@ pax_attribute(struct archive_read *a, struct tar *tar,
} else if (strcmp(key, "SCHILY.realsize") == 0) {
tar->realsize = tar_atol10(value, strlen(value));
archive_entry_set_size(entry, tar->realsize);
+ } else if (strncmp(key, "SCHILY.xattr.", 13) == 0) {
+ pax_attribute_schily_xattr(entry, key, value,
+ value_length);
} else if (strcmp(key, "SUN.holesdata") == 0) {
/* A Solaris extension for sparse. */
r = solaris_sparse_parse(a, tar, entry, value);
diff --git a/contrib/libarchive/libarchive/archive_read_support_format_warc.c b/contrib/libarchive/libarchive/archive_read_support_format_warc.c
index a287fc2..5e22438 100644
--- a/contrib/libarchive/libarchive/archive_read_support_format_warc.c
+++ b/contrib/libarchive/libarchive/archive_read_support_format_warc.c
@@ -88,7 +88,7 @@ typedef enum {
WT_RVIS,
/* conversion, unsupported */
WT_CONV,
- /* continutation, unsupported at the moment */
+ /* continuation, unsupported at the moment */
WT_CONT,
/* invalid type */
LAST_WT
@@ -134,8 +134,8 @@ static ssize_t _warc_rdlen(const char *buf, size_t bsz);
static time_t _warc_rdrtm(const char *buf, size_t bsz);
static time_t _warc_rdmtm(const char *buf, size_t bsz);
static const char *_warc_find_eoh(const char *buf, size_t bsz);
+static const char *_warc_find_eol(const char *buf, size_t bsz);
-
int
archive_read_support_format_warc(struct archive *_a)
{
@@ -198,8 +198,8 @@ _warc_bid(struct archive_read *a, int best_bid)
/* otherwise snarf the record's version number */
ver = _warc_rdver(hdr, nrd);
- if (ver == 0U || ver > 10000U) {
- /* oh oh oh, best not to wager ... */
+ if (ver < 1200U || ver > 10000U) {
+ /* we only support WARC 0.12 to 1.0 */
return -1;
}
@@ -254,23 +254,32 @@ start_over:
&a->archive, ARCHIVE_ERRNO_MISC,
"Bad record header");
return (ARCHIVE_FATAL);
- } else if ((ver = _warc_rdver(buf, eoh - buf)) > 10000U) {
- /* nawww, I wish they promised backward compatibility
- * anyhoo, in their infinite wisdom the 28500 guys might
- * come up with something we can't possibly handle so
- * best end things here */
+ }
+ ver = _warc_rdver(buf, eoh - buf);
+ /* we currently support WARC 0.12 to 1.0 */
+ if (ver == 0U) {
archive_set_error(
&a->archive, ARCHIVE_ERRNO_MISC,
- "Unsupported record version");
+ "Invalid record version");
return (ARCHIVE_FATAL);
- } else if ((cntlen = _warc_rdlen(buf, eoh - buf)) < 0) {
+ } else if (ver < 1200U || ver > 10000U) {
+ archive_set_error(
+ &a->archive, ARCHIVE_ERRNO_MISC,
+ "Unsupported record version: %u.%u",
+ ver / 10000, (ver % 10000) / 100);
+ return (ARCHIVE_FATAL);
+ }
+ cntlen = _warc_rdlen(buf, eoh - buf);
+ if (cntlen < 0) {
/* nightmare! the specs say content-length is mandatory
* so I don't feel overly bad stopping the reader here */
archive_set_error(
&a->archive, EINVAL,
"Bad content length");
return (ARCHIVE_FATAL);
- } else if ((rtime = _warc_rdrtm(buf, eoh - buf)) == (time_t)-1) {
+ }
+ rtime = _warc_rdrtm(buf, eoh - buf);
+ if (rtime == (time_t)-1) {
/* record time is mandatory as per WARC/1.0,
* so just barf here, fast and loud */
archive_set_error(
@@ -284,7 +293,7 @@ start_over:
if (ver != w->pver) {
/* stringify this entry's version */
archive_string_sprintf(&w->sver,
- "WARC/%u.%u", ver / 10000, ver % 10000);
+ "WARC/%u.%u", ver / 10000, (ver % 10000) / 100);
/* remember the version */
w->pver = ver;
}
@@ -534,7 +543,7 @@ xstrpisotime(const char *s, char **endptr)
/* as a courtesy to our callers, and since this is a non-standard
* routine, we skip leading whitespace */
- while (isspace((unsigned char)*s))
+ while (isblank((unsigned char)*s))
++s;
/* read year */
@@ -562,7 +571,7 @@ xstrpisotime(const char *s, char **endptr)
goto out;
}
- /* massage TM to fulfill some of POSIX' contraints */
+ /* massage TM to fulfill some of POSIX' constraints */
tm.tm_year -= 1900;
tm.tm_mon--;
@@ -577,51 +586,41 @@ out:
}
static unsigned int
-_warc_rdver(const char buf[10], size_t bsz)
+_warc_rdver(const char *buf, size_t bsz)
{
static const char magic[] = "WARC/";
- unsigned int ver;
-
- (void)bsz; /* UNUSED */
+ unsigned int ver = 0U;
+ unsigned int end = 0U;
- if (memcmp(buf, magic, sizeof(magic) - 1U) != 0) {
- /* nope */
- return 99999U;
+ if (bsz < 12 || memcmp(buf, magic, sizeof(magic) - 1U) != 0) {
+ /* buffer too small or invalid magic */
+ return ver;
}
/* looks good so far, read the version number for a laugh */
buf += sizeof(magic) - 1U;
- /* most common case gets a quick-check here */
- if (memcmp(buf, "1.0\r\n", 5U) == 0) {
- ver = 10000U;
- } else {
- switch (*buf) {
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- if (buf[1U] == '.') {
- char *on;
-
- /* set up major version */
- ver = (buf[0U] - '0') * 10000U;
- /* minor version, anyone? */
- ver += (strtol(buf + 2U, &on, 10)) * 100U;
- /* don't parse anything else */
- if (on > buf + 2U) {
- break;
- }
- }
- /* FALLTHROUGH */
- case '9':
- default:
- /* just make the version ridiculously high */
- ver = 999999U;
- break;
+
+ if (isdigit(buf[0U]) && (buf[1U] == '.') && isdigit(buf[2U])) {
+ /* we support a maximum of 2 digits in the minor version */
+ if (isdigit(buf[3U]))
+ end = 1U;
+ /* set up major version */
+ ver = (buf[0U] - '0') * 10000U;
+ /* set up minor version */
+ if (end == 1U) {
+ ver += (buf[2U] - '0') * 1000U;
+ ver += (buf[3U] - '0') * 100U;
+ } else
+ ver += (buf[2U] - '0') * 100U;
+ /*
+ * WARC below version 0.12 has a space-separated header
+ * WARC 0.12 and above terminates the version with a CRLF
+ */
+ if (ver >= 1200U) {
+ if (memcmp(buf + 3U + end, "\r\n", 2U) != 0)
+ ver = 0U;
+ } else if (ver < 1200U) {
+ if (!isblank(*(buf + 3U + end)))
+ ver = 0U;
}
}
return ver;
@@ -631,34 +630,27 @@ static unsigned int
_warc_rdtyp(const char *buf, size_t bsz)
{
static const char _key[] = "\r\nWARC-Type:";
- const char *const eob = buf + bsz;
- const char *val;
+ const char *val, *eol;
if ((val = xmemmem(buf, bsz, _key, sizeof(_key) - 1U)) == NULL) {
/* no bother */
return WT_NONE;
}
- /* overread whitespace */
val += sizeof(_key) - 1U;
- while (val < eob && isspace((unsigned char)*val))
+ if ((eol = _warc_find_eol(val, buf + bsz - val)) == NULL) {
+ /* no end of line */
+ return WT_NONE;
+ }
+
+ /* overread whitespace */
+ while (val < eol && isblank((unsigned char)*val))
++val;
- if (val + 8U > eob) {
- ;
- } else if (memcmp(val, "resource", 8U) == 0) {
- return WT_RSRC;
- } else if (memcmp(val, "warcinfo", 8U) == 0) {
- return WT_INFO;
- } else if (memcmp(val, "metadata", 8U) == 0) {
- return WT_META;
- } else if (memcmp(val, "request", 7U) == 0) {
- return WT_REQ;
- } else if (memcmp(val, "response", 8U) == 0) {
- return WT_RSP;
- } else if (memcmp(val, "conversi", 8U) == 0) {
- return WT_CONV;
- } else if (memcmp(val, "continua", 8U) == 0) {
- return WT_CONT;
+ if (val + 8U == eol) {
+ if (memcmp(val, "resource", 8U) == 0)
+ return WT_RSRC;
+ else if (memcmp(val, "response", 8U) == 0)
+ return WT_RSP;
}
return WT_NONE;
}
@@ -667,10 +659,7 @@ static warc_string_t
_warc_rduri(const char *buf, size_t bsz)
{
static const char _key[] = "\r\nWARC-Target-URI:";
- const char *const eob = buf + bsz;
- const char *val;
- const char *uri;
- const char *eol;
+ const char *val, *uri, *eol, *p;
warc_string_t res = {0U, NULL};
if ((val = xmemmem(buf, bsz, _key, sizeof(_key) - 1U)) == NULL) {
@@ -679,25 +668,32 @@ _warc_rduri(const char *buf, size_t bsz)
}
/* overread whitespace */
val += sizeof(_key) - 1U;
- while (val < eob && isspace((unsigned char)*val))
+ if ((eol = _warc_find_eol(val, buf + bsz - val)) == NULL) {
+ /* no end of line */
+ return res;
+ }
+
+ while (val < eol && isblank((unsigned char)*val))
++val;
/* overread URL designators */
- if ((uri = xmemmem(val, eob - val, "://", 3U)) == NULL) {
+ if ((uri = xmemmem(val, eol - val, "://", 3U)) == NULL) {
/* not touching that! */
return res;
- } else if ((eol = memchr(uri, '\n', eob - uri)) == NULL) {
- /* no end of line? :O */
- return res;
}
- /* massage uri to point to after :// */
+ /* spaces inside uri are not allowed, CRLF should follow */
+ for (p = val; p < eol; p++) {
+ if (isspace(*p))
+ return res;
+ }
+
+ /* there must be at least space for ftp */
+ if (uri < (val + 3U))
+ return res;
+
+ /* move uri to point to after :// */
uri += 3U;
- /* also massage eol to point to the first whitespace
- * after the last non-whitespace character before
- * the end of the line */
- while (eol > uri && isspace((unsigned char)eol[-1]))
- --eol;
/* now then, inspect the URI */
if (memcmp(val, "file", 4U) == 0) {
@@ -720,7 +716,7 @@ static ssize_t
_warc_rdlen(const char *buf, size_t bsz)
{
static const char _key[] = "\r\nContent-Length:";
- const char *val;
+ const char *val, *eol;
char *on = NULL;
long int len;
@@ -728,14 +724,24 @@ _warc_rdlen(const char *buf, size_t bsz)
/* no bother */
return -1;
}
-
- /* strtol kindly overreads whitespace for us, so use that */
val += sizeof(_key) - 1U;
+ if ((eol = _warc_find_eol(val, buf + bsz - val)) == NULL) {
+ /* no end of line */
+ return -1;
+ }
+
+ /* skip leading whitespace */
+ while (val < eol && isblank(*val))
+ val++;
+ /* there must be at least one digit */
+ if (!isdigit(*val))
+ return -1;
len = strtol(val, &on, 10);
- if (on == NULL || !isspace((unsigned char)*on)) {
- /* hm, can we trust that number? Best not. */
+ if (on != eol) {
+ /* line must end here */
return -1;
}
+
return (size_t)len;
}
@@ -743,7 +749,7 @@ static time_t
_warc_rdrtm(const char *buf, size_t bsz)
{
static const char _key[] = "\r\nWARC-Date:";
- const char *val;
+ const char *val, *eol;
char *on = NULL;
time_t res;
@@ -751,13 +757,17 @@ _warc_rdrtm(const char *buf, size_t bsz)
/* no bother */
return (time_t)-1;
}
+ val += sizeof(_key) - 1U;
+ if ((eol = _warc_find_eol(val, buf + bsz - val)) == NULL ) {
+ /* no end of line */
+ return -1;
+ }
/* xstrpisotime() kindly overreads whitespace for us, so use that */
- val += sizeof(_key) - 1U;
res = xstrpisotime(val, &on);
- if (on == NULL || !isspace((unsigned char)*on)) {
- /* hm, can we trust that number? Best not. */
- return (time_t)-1;
+ if (on != eol) {
+ /* line must end here */
+ return -1;
}
return res;
}
@@ -766,7 +776,7 @@ static time_t
_warc_rdmtm(const char *buf, size_t bsz)
{
static const char _key[] = "\r\nLast-Modified:";
- const char *val;
+ const char *val, *eol;
char *on = NULL;
time_t res;
@@ -774,13 +784,17 @@ _warc_rdmtm(const char *buf, size_t bsz)
/* no bother */
return (time_t)-1;
}
+ val += sizeof(_key) - 1U;
+ if ((eol = _warc_find_eol(val, buf + bsz - val)) == NULL ) {
+ /* no end of line */
+ return -1;
+ }
/* xstrpisotime() kindly overreads whitespace for us, so use that */
- val += sizeof(_key) - 1U;
res = xstrpisotime(val, &on);
- if (on == NULL || !isspace((unsigned char)*on)) {
- /* hm, can we trust that number? Best not. */
- return (time_t)-1;
+ if (on != eol) {
+ /* line must end here */
+ return -1;
}
return res;
}
@@ -797,4 +811,12 @@ _warc_find_eoh(const char *buf, size_t bsz)
return hit;
}
+static const char*
+_warc_find_eol(const char *buf, size_t bsz)
+{
+ static const char _marker[] = "\r\n";
+ const char *hit = xmemmem(buf, bsz, _marker, sizeof(_marker) - 1U);
+
+ return hit;
+}
/* archive_read_support_format_warc.c ends here */
diff --git a/contrib/libarchive/libarchive/archive_read_support_format_xar.c b/contrib/libarchive/libarchive/archive_read_support_format_xar.c
index 47ed064..7a22beb 100644
--- a/contrib/libarchive/libarchive/archive_read_support_format_xar.c
+++ b/contrib/libarchive/libarchive/archive_read_support_format_xar.c
@@ -394,6 +394,7 @@ static void checksum_update(struct archive_read *, const void *,
size_t, const void *, size_t);
static int checksum_final(struct archive_read *, const void *,
size_t, const void *, size_t);
+static void checksum_cleanup(struct archive_read *);
static int decompression_init(struct archive_read *, enum enctype);
static int decompress(struct archive_read *, const void **,
size_t *, const void *, size_t *);
@@ -923,6 +924,7 @@ xar_cleanup(struct archive_read *a)
int r;
xar = (struct xar *)(a->format->data);
+ checksum_cleanup(a);
r = decompression_cleanup(a);
hdlink = xar->hdlink_list;
while (hdlink != NULL) {
@@ -933,6 +935,7 @@ xar_cleanup(struct archive_read *a)
}
for (i = 0; i < xar->file_queue.used; i++)
file_free(xar->file_queue.files[i]);
+ free(xar->file_queue.files);
while (xar->unknowntags != NULL) {
struct unknown_tag *tag;
@@ -1719,6 +1722,16 @@ decompression_cleanup(struct archive_read *a)
}
static void
+checksum_cleanup(struct archive_read *a) {
+ struct xar *xar;
+
+ xar = (struct xar *)(a->format->data);
+
+ _checksum_final(&(xar->a_sumwrk), NULL, 0);
+ _checksum_final(&(xar->e_sumwrk), NULL, 0);
+}
+
+static void
xmlattr_cleanup(struct xmlattr_list *list)
{
struct xmlattr *attr, *next;
@@ -3047,7 +3060,7 @@ xml2_read_cb(void *context, char *buffer, int len)
struct xar *xar;
const void *d;
size_t outbytes;
- size_t used;
+ size_t used = 0;
int r;
a = (struct archive_read *)context;
@@ -3171,6 +3184,9 @@ expat_xmlattr_setup(struct archive_read *a,
value = strdup(atts[1]);
if (attr == NULL || name == NULL || value == NULL) {
archive_set_error(&a->archive, ENOMEM, "Out of memory");
+ free(attr);
+ free(name);
+ free(value);
return (ARCHIVE_FATAL);
}
attr->name = name;
diff --git a/contrib/libarchive/libarchive/archive_read_support_format_zip.c b/contrib/libarchive/libarchive/archive_read_support_format_zip.c
index 1aa7445..10dc14d 100644
--- a/contrib/libarchive/libarchive/archive_read_support_format_zip.c
+++ b/contrib/libarchive/libarchive/archive_read_support_format_zip.c
@@ -199,7 +199,7 @@ struct zip {
struct trad_enc_ctx tctx;
char tctx_valid;
- /* WinZip AES decyption. */
+ /* WinZip AES decryption. */
/* Contexts used for AES decryption. */
archive_crypto_ctx cctx;
char cctx_valid;
@@ -242,7 +242,7 @@ trad_enc_update_keys(struct trad_enc_ctx *ctx, uint8_t c)
}
static uint8_t
-trad_enc_decypt_byte(struct trad_enc_ctx *ctx)
+trad_enc_decrypt_byte(struct trad_enc_ctx *ctx)
{
unsigned temp = ctx->keys[2] | 2;
return (uint8_t)((temp * (temp ^ 1)) >> 8) & 0xff;
@@ -257,7 +257,7 @@ trad_enc_decrypt_update(struct trad_enc_ctx *ctx, const uint8_t *in,
max = (unsigned)((in_len < out_len)? in_len: out_len);
for (i = 0; i < max; i++) {
- uint8_t t = in[i] ^ trad_enc_decypt_byte(ctx);
+ uint8_t t = in[i] ^ trad_enc_decrypt_byte(ctx);
out[i] = t;
trad_enc_update_keys(ctx, t);
}
@@ -452,26 +452,38 @@ process_extra(struct archive_read *a, const char *p, size_t extra_length, struct
/* Zip64 extended information extra field. */
zip_entry->flags |= LA_USED_ZIP64;
if (zip_entry->uncompressed_size == 0xffffffff) {
- if (datasize < 8)
- break;
- zip_entry->uncompressed_size =
- archive_le64dec(p + offset);
+ uint64_t t = 0;
+ if (datasize < 8
+ || (t = archive_le64dec(p + offset)) > INT64_MAX) {
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+ "Malformed 64-bit uncompressed size");
+ return ARCHIVE_FAILED;
+ }
+ zip_entry->uncompressed_size = t;
offset += 8;
datasize -= 8;
}
if (zip_entry->compressed_size == 0xffffffff) {
- if (datasize < 8)
- break;
- zip_entry->compressed_size =
- archive_le64dec(p + offset);
+ uint64_t t = 0;
+ if (datasize < 8
+ || (t = archive_le64dec(p + offset)) > INT64_MAX) {
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+ "Malformed 64-bit compressed size");
+ return ARCHIVE_FAILED;
+ }
+ zip_entry->compressed_size = t;
offset += 8;
datasize -= 8;
}
if (zip_entry->local_header_offset == 0xffffffff) {
- if (datasize < 8)
- break;
- zip_entry->local_header_offset =
- archive_le64dec(p + offset);
+ uint64_t t = 0;
+ if (datasize < 8
+ || (t = archive_le64dec(p + offset)) > INT64_MAX) {
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+ "Malformed 64-bit local header offset");
+ return ARCHIVE_FAILED;
+ }
+ zip_entry->local_header_offset = t;
offset += 8;
datasize -= 8;
}
@@ -710,7 +722,7 @@ process_extra(struct archive_read *a, const char *p, size_t extra_length, struct
break;
}
case 0x9901:
- /* WinZIp AES extra data field. */
+ /* WinZip AES extra data field. */
if (p[offset + 2] == 'A' && p[offset + 3] == 'E') {
/* Vendor version. */
zip_entry->aes_extra.vendor =
@@ -905,6 +917,7 @@ zip_read_local_file_header(struct archive_read *a, struct archive_entry *entry,
archive_wstrcat(&s, wp);
archive_wstrappend_wchar(&s, L'/');
archive_entry_copy_pathname_w(entry, s.s);
+ archive_wstring_free(&s);
}
} else {
cp = archive_entry_pathname(entry);
@@ -915,6 +928,7 @@ zip_read_local_file_header(struct archive_read *a, struct archive_entry *entry,
archive_strcat(&s, cp);
archive_strappend_char(&s, '/');
archive_entry_set_pathname(entry, s.s);
+ archive_string_free(&s);
}
}
}
@@ -1154,11 +1168,18 @@ zip_read_data_none(struct archive_read *a, const void **_buff,
|| (zip->hctx_valid
&& zip->entry->aes_extra.vendor == AES_VENDOR_AE_2))) {
if (zip->entry->flags & LA_USED_ZIP64) {
+ uint64_t compressed, uncompressed;
zip->entry->crc32 = archive_le32dec(p + 4);
- zip->entry->compressed_size =
- archive_le64dec(p + 8);
- zip->entry->uncompressed_size =
- archive_le64dec(p + 16);
+ compressed = archive_le64dec(p + 8);
+ uncompressed = archive_le64dec(p + 16);
+ if (compressed > INT64_MAX || uncompressed > INT64_MAX) {
+ archive_set_error(&a->archive,
+ ARCHIVE_ERRNO_FILE_FORMAT,
+ "Overflow of 64-bit file sizes");
+ return ARCHIVE_FAILED;
+ }
+ zip->entry->compressed_size = compressed;
+ zip->entry->uncompressed_size = uncompressed;
zip->unconsumed = 24;
} else {
zip->entry->crc32 = archive_le32dec(p + 4);
@@ -1435,9 +1456,18 @@ zip_read_data_deflate(struct archive_read *a, const void **buff,
zip->unconsumed = 4;
}
if (zip->entry->flags & LA_USED_ZIP64) {
+ uint64_t compressed, uncompressed;
zip->entry->crc32 = archive_le32dec(p);
- zip->entry->compressed_size = archive_le64dec(p + 4);
- zip->entry->uncompressed_size = archive_le64dec(p + 12);
+ compressed = archive_le64dec(p + 4);
+ uncompressed = archive_le64dec(p + 12);
+ if (compressed > INT64_MAX || uncompressed > INT64_MAX) {
+ archive_set_error(&a->archive,
+ ARCHIVE_ERRNO_FILE_FORMAT,
+ "Overflow of 64-bit file sizes");
+ return ARCHIVE_FAILED;
+ }
+ zip->entry->compressed_size = compressed;
+ zip->entry->uncompressed_size = uncompressed;
zip->unconsumed += 20;
} else {
zip->entry->crc32 = archive_le32dec(p);
@@ -1518,7 +1548,7 @@ read_decryption_header(struct archive_read *a)
case 0x6720:/* Blowfish */
case 0x6721:/* Twofish */
case 0x6801:/* RC4 */
- /* Suuported encryption algorithm. */
+ /* Supported encryption algorithm. */
break;
default:
archive_set_error(&a->archive,
@@ -1627,7 +1657,7 @@ read_decryption_header(struct archive_read *a)
__archive_read_consume(a, 4);
/*return (ARCHIVE_OK);
- * This is not fully implemnted yet.*/
+ * This is not fully implemented yet.*/
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
"Encrypted file is unsupported");
return (ARCHIVE_FAILED);
@@ -1709,7 +1739,7 @@ init_traditional_PKWARE_decryption(struct archive_read *a)
}
/*
- * Initialize ctx for Traditional PKWARE Decyption.
+ * Initialize ctx for Traditional PKWARE Decryption.
*/
r = trad_enc_init(&zip->tctx, passphrase, strlen(passphrase),
p, ENC_HEADER_SIZE, &crcchk);
diff --git a/contrib/libarchive/libarchive/archive_string.c b/contrib/libarchive/libarchive/archive_string.c
index cf10f09..f738c54 100644
--- a/contrib/libarchive/libarchive/archive_string.c
+++ b/contrib/libarchive/libarchive/archive_string.c
@@ -219,6 +219,12 @@ archive_wstring_append(struct archive_wstring *as, const wchar_t *p, size_t s)
return (as);
}
+struct archive_string *
+archive_array_append(struct archive_string *as, const char *p, size_t s)
+{
+ return archive_string_append(as, p, s);
+}
+
void
archive_string_concat(struct archive_string *dest, struct archive_string *src)
{
@@ -597,7 +603,7 @@ archive_wstring_append_from_mbs(struct archive_wstring *dest,
wcs = dest->s + dest->length;
/*
* We cannot use mbsrtowcs/mbstowcs here because those may convert
- * extra MBS when strlen(p) > len and one wide character consis of
+ * extra MBS when strlen(p) > len and one wide character consists of
* multi bytes.
*/
while (*mbs && mbs_length > 0) {
@@ -1248,7 +1254,7 @@ create_sconv_object(const char *fc, const char *tc,
sc->cd = iconv_open(tc, fc);
if (sc->cd == (iconv_t)-1 && (sc->flag & SCONV_BEST_EFFORT)) {
/*
- * Unfortunaly, all of iconv implements do support
+ * Unfortunately, all of iconv implements do support
* "CP932" character-set, so we should use "SJIS"
* instead if iconv_open failed.
*/
@@ -1261,7 +1267,7 @@ create_sconv_object(const char *fc, const char *tc,
/*
* archive_mstring on Windows directly convert multi-bytes
* into archive_wstring in order not to depend on locale
- * so that you can do a I18N programing. This will be
+ * so that you can do a I18N programming. This will be
* used only in archive_mstring_copy_mbs_len_l so far.
*/
if (flag & SCONV_FROM_CHARSET) {
@@ -1726,7 +1732,7 @@ archive_string_conversion_from_charset(struct archive *a, const char *charset,
* in tar or zip files. But mbstowcs/wcstombs(CRT) usually use CP_ACP
* unless you use setlocale(LC_ALL, ".OCP")(specify CP_OEMCP).
* So we should make a string conversion between CP_ACP and CP_OEMCP
- * for compatibillty.
+ * for compatibility.
*/
#if defined(_WIN32) && !defined(__CYGWIN__)
struct archive_string_conv *
@@ -2220,7 +2226,7 @@ best_effort_strncat_in_locale(struct archive_string *as, const void *_p,
/*
* If a character is ASCII, this just copies it. If not, this
- * assigns '?' charater instead but in UTF-8 locale this assigns
+ * assigns '?' character instead but in UTF-8 locale this assigns
* byte sequence 0xEF 0xBD 0xBD, which are code point U+FFFD,
* a Replacement Character in Unicode.
*/
@@ -2554,7 +2560,7 @@ utf16_to_unicode(uint32_t *pwc, const char *s, size_t n, int be)
/*
* Surrogate pair values(0xd800 through 0xdfff) are only
- * used by UTF-16, so, after above culculation, the code
+ * used by UTF-16, so, after above calculation, the code
* must not be surrogate values, and Unicode has no codes
* larger than 0x10ffff. Thus, those are not legal Unicode
* values.
@@ -2903,7 +2909,7 @@ get_nfc(uint32_t uc, uint32_t uc2)
/*
* Normalize UTF-8/UTF-16BE characters to Form C and copy the result.
*
- * TODO: Convert composition exclusions,which are never converted
+ * TODO: Convert composition exclusions, which are never converted
* from NFC,NFD,NFKC and NFKD, to Form C.
*/
static int
@@ -3437,7 +3443,7 @@ strncat_from_utf8_libarchive2(struct archive_string *as,
}
/*
- * As libarchie 2.x, translates the UTF-8 characters into
+ * As libarchive 2.x, translates the UTF-8 characters into
* wide-characters in the assumption that WCS is Unicode.
*/
if (n < 0) {
@@ -3947,7 +3953,7 @@ archive_mstring_get_mbs_l(struct archive_mstring *aes,
#if defined(_WIN32) && !defined(__CYGWIN__)
/*
- * Internationalization programing on Windows must use Wide
+ * Internationalization programming on Windows must use Wide
* characters because Windows platform cannot make locale UTF-8.
*/
if (sc != NULL && (aes->aes_set & AES_SET_WCS) != 0) {
@@ -4079,7 +4085,7 @@ archive_mstring_copy_mbs_len_l(struct archive_mstring *aes,
archive_string_empty(&(aes->aes_utf8));
#if defined(_WIN32) && !defined(__CYGWIN__)
/*
- * Internationalization programing on Windows must use Wide
+ * Internationalization programming on Windows must use Wide
* characters because Windows platform cannot make locale UTF-8.
*/
if (sc == NULL) {
diff --git a/contrib/libarchive/libarchive/archive_string.h b/contrib/libarchive/libarchive/archive_string.h
index 60ebf0e..f5953d0 100644
--- a/contrib/libarchive/libarchive/archive_string.h
+++ b/contrib/libarchive/libarchive/archive_string.h
@@ -81,6 +81,10 @@ archive_strappend_char(struct archive_string *, char);
struct archive_wstring *
archive_wstrappend_wchar(struct archive_wstring *, wchar_t);
+/* Append a raw array to an archive_string, resizing as necessary */
+struct archive_string *
+archive_array_append(struct archive_string *, const char *, size_t);
+
/* Convert a Unicode string to current locale and append the result. */
/* Returns -1 if conversion fails. */
int
diff --git a/contrib/libarchive/libarchive/archive_string_composition.h b/contrib/libarchive/libarchive/archive_string_composition.h
index be41e33..8902ac1 100644
--- a/contrib/libarchive/libarchive/archive_string_composition.h
+++ b/contrib/libarchive/libarchive/archive_string_composition.h
@@ -1009,7 +1009,7 @@ static const char u_decomposable_blocks[0x1D2+1] = {
(((uc) > 0x1D244)?0:\
ccc_val[ccc_val_index[ccc_index[(uc)>>8]][((uc)>>4)&0x0F]][(uc)&0x0F])
-/* The table of the value of Canonical Cimbining Class */
+/* The table of the value of Canonical Combining Class */
static const unsigned char ccc_val[][16] = {
/* idx=0: XXXX0 - XXXXF */
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
diff --git a/contrib/libarchive/libarchive/archive_write.c b/contrib/libarchive/libarchive/archive_write.c
index f5a9f61..e441dbe 100644
--- a/contrib/libarchive/libarchive/archive_write.c
+++ b/contrib/libarchive/libarchive/archive_write.c
@@ -231,7 +231,7 @@ __archive_write_filter(struct archive_write_filter *f,
if (length == 0)
return(ARCHIVE_OK);
if (f->write == NULL)
- /* If unset, a fatal error has already ocuured, so this filter
+ /* If unset, a fatal error has already occurred, so this filter
* didn't open. We cannot write anything. */
return(ARCHIVE_FATAL);
r = (f->write)(f, buff, length);
diff --git a/contrib/libarchive/libarchive/archive_write_add_filter_program.c b/contrib/libarchive/libarchive/archive_write_add_filter_program.c
index 31a1b6f..55b5e8e 100644
--- a/contrib/libarchive/libarchive/archive_write_add_filter_program.c
+++ b/contrib/libarchive/libarchive/archive_write_add_filter_program.c
@@ -200,6 +200,7 @@ __archive_write_program_free(struct archive_write_program_data *data)
if (data->child)
CloseHandle(data->child);
#endif
+ free(data->program_name);
free(data->child_buf);
free(data);
}
diff --git a/contrib/libarchive/libarchive/archive_write_add_filter_xz.c b/contrib/libarchive/libarchive/archive_write_add_filter_xz.c
index 46a6c38..b0f25a6 100644
--- a/contrib/libarchive/libarchive/archive_write_add_filter_xz.c
+++ b/contrib/libarchive/libarchive/archive_write_add_filter_xz.c
@@ -233,7 +233,7 @@ archive_compressor_xz_init_stream(struct archive_write_filter *f,
if (f->code == ARCHIVE_FILTER_XZ) {
#ifdef HAVE_LZMA_STREAM_ENCODER_MT
if (data->threads != 1) {
- bzero(&mt_options, sizeof(mt_options));
+ memset(&mt_options, 0, sizeof(mt_options));
mt_options.threads = data->threads;
mt_options.timeout = 300;
mt_options.filters = data->lzmafilters;
diff --git a/contrib/libarchive/libarchive/archive_write_disk_acl.c b/contrib/libarchive/libarchive/archive_write_disk_acl.c
index e47384a..144ab7e 100644
--- a/contrib/libarchive/libarchive/archive_write_disk_acl.c
+++ b/contrib/libarchive/libarchive/archive_write_disk_acl.c
@@ -34,6 +34,9 @@ __FBSDID("$FreeBSD: head/lib/libarchive/archive_write_disk.c 201159 2009-12-29 0
#define _ACL_PRIVATE /* For debugging */
#include <sys/acl.h>
#endif
+#if HAVE_DARWIN_ACL
+#include <membership.h>
+#endif
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif
@@ -43,7 +46,7 @@ __FBSDID("$FreeBSD: head/lib/libarchive/archive_write_disk.c 201159 2009-12-29 0
#include "archive_acl_private.h"
#include "archive_write_disk_private.h"
-#ifndef HAVE_POSIX_ACL
+#if !HAVE_POSIX_ACL && !HAVE_NFS4_ACL
/* Default empty function body to satisfy mainline code. */
int
archive_write_disk_set_acls(struct archive *a, int fd, const char *name,
@@ -56,47 +59,111 @@ archive_write_disk_set_acls(struct archive *a, int fd, const char *name,
return (ARCHIVE_OK);
}
-#else
+#else /* HAVE_POSIX_ACL || HAVE_NFS4_ACL */
+
+#if HAVE_SUN_ACL
+#define ARCHIVE_PLATFORM_ACL_TYPE_NFS4 ACE_T
+#elif HAVE_DARWIN_ACL
+#define ARCHIVE_PLATFORM_ACL_TYPE_NFS4 ACL_TYPE_EXTENDED
+#elif HAVE_ACL_TYPE_NFS4
+#define ARCHIVE_PLATFORM_ACL_TYPE_NFS4 ACL_TYPE_NFS4
+#endif
static int set_acl(struct archive *, int fd, const char *,
struct archive_acl *,
acl_type_t, int archive_entry_acl_type, const char *tn);
-/*
- * XXX TODO: What about ACL types other than ACCESS and DEFAULT?
- */
int
archive_write_disk_set_acls(struct archive *a, int fd, const char *name,
struct archive_acl *abstract_acl)
{
- int ret;
+ int ret = ARCHIVE_OK;
- if (archive_acl_count(abstract_acl, ARCHIVE_ENTRY_ACL_TYPE_POSIX1E) > 0) {
- ret = set_acl(a, fd, name, abstract_acl, ACL_TYPE_ACCESS,
- ARCHIVE_ENTRY_ACL_TYPE_ACCESS, "access");
- if (ret != ARCHIVE_OK)
- return (ret);
- ret = set_acl(a, fd, name, abstract_acl, ACL_TYPE_DEFAULT,
- ARCHIVE_ENTRY_ACL_TYPE_DEFAULT, "default");
+#if !HAVE_DARWIN_ACL
+ if ((archive_acl_types(abstract_acl)
+ & ARCHIVE_ENTRY_ACL_TYPE_POSIX1E) != 0) {
+#if HAVE_SUN_ACL
+ /* Solaris writes POSIX.1e access and default ACLs together */
+ ret = set_acl(a, fd, name, abstract_acl, ACLENT_T,
+ ARCHIVE_ENTRY_ACL_TYPE_POSIX1E, "posix1e");
+#else /* HAVE_POSIX_ACL */
+ if ((archive_acl_types(abstract_acl)
+ & ARCHIVE_ENTRY_ACL_TYPE_ACCESS) != 0) {
+ ret = set_acl(a, fd, name, abstract_acl,
+ ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_TYPE_ACCESS,
+ "access");
+ if (ret != ARCHIVE_OK)
+ return (ret);
+ }
+ if ((archive_acl_types(abstract_acl)
+ & ARCHIVE_ENTRY_ACL_TYPE_DEFAULT) != 0)
+ ret = set_acl(a, fd, name, abstract_acl,
+ ACL_TYPE_DEFAULT, ARCHIVE_ENTRY_ACL_TYPE_DEFAULT,
+ "default");
+#endif /* !HAVE_SUN_ACL */
+ /* Simultaneous POSIX.1e and NFSv4 is not supported */
return (ret);
-#ifdef ACL_TYPE_NFS4
- } else if (archive_acl_count(abstract_acl, ARCHIVE_ENTRY_ACL_TYPE_NFS4) > 0) {
- ret = set_acl(a, fd, name, abstract_acl, ACL_TYPE_NFS4,
+ }
+#endif /* !HAVE_DARWIN_ACL */
+#if HAVE_NFS4_ACL
+ if ((archive_acl_types(abstract_acl) &
+ ARCHIVE_ENTRY_ACL_TYPE_NFS4) != 0) {
+ ret = set_acl(a, fd, name, abstract_acl,
+ ARCHIVE_PLATFORM_ACL_TYPE_NFS4,
ARCHIVE_ENTRY_ACL_TYPE_NFS4, "nfs4");
- return (ret);
-#endif
- } else
- return ARCHIVE_OK;
+ }
+#endif /* HAVE_NFS4_ACL */
+ return (ret);
}
-static struct {
- int archive_perm;
- int platform_perm;
+/*
+ * Translate system ACL permissions into libarchive internal structure
+ */
+static const struct {
+ const int archive_perm;
+ const int platform_perm;
} acl_perm_map[] = {
+#if HAVE_SUN_ACL /* Solaris NFSv4 ACL permissions */
+ {ARCHIVE_ENTRY_ACL_EXECUTE, ACE_EXECUTE},
+ {ARCHIVE_ENTRY_ACL_READ_DATA, ACE_READ_DATA},
+ {ARCHIVE_ENTRY_ACL_LIST_DIRECTORY, ACE_LIST_DIRECTORY},
+ {ARCHIVE_ENTRY_ACL_WRITE_DATA, ACE_WRITE_DATA},
+ {ARCHIVE_ENTRY_ACL_ADD_FILE, ACE_ADD_FILE},
+ {ARCHIVE_ENTRY_ACL_APPEND_DATA, ACE_APPEND_DATA},
+ {ARCHIVE_ENTRY_ACL_ADD_SUBDIRECTORY, ACE_ADD_SUBDIRECTORY},
+ {ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS, ACE_READ_NAMED_ATTRS},
+ {ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS, ACE_WRITE_NAMED_ATTRS},
+ {ARCHIVE_ENTRY_ACL_DELETE_CHILD, ACE_DELETE_CHILD},
+ {ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES, ACE_READ_ATTRIBUTES},
+ {ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES, ACE_WRITE_ATTRIBUTES},
+ {ARCHIVE_ENTRY_ACL_DELETE, ACE_DELETE},
+ {ARCHIVE_ENTRY_ACL_READ_ACL, ACE_READ_ACL},
+ {ARCHIVE_ENTRY_ACL_WRITE_ACL, ACE_WRITE_ACL},
+ {ARCHIVE_ENTRY_ACL_WRITE_OWNER, ACE_WRITE_OWNER},
+ {ARCHIVE_ENTRY_ACL_SYNCHRONIZE, ACE_SYNCHRONIZE}
+#elif HAVE_DARWIN_ACL /* MacOS ACL permissions */
+ {ARCHIVE_ENTRY_ACL_READ_DATA, ACL_READ_DATA},
+ {ARCHIVE_ENTRY_ACL_LIST_DIRECTORY, ACL_LIST_DIRECTORY},
+ {ARCHIVE_ENTRY_ACL_WRITE_DATA, ACL_WRITE_DATA},
+ {ARCHIVE_ENTRY_ACL_ADD_FILE, ACL_ADD_FILE},
+ {ARCHIVE_ENTRY_ACL_EXECUTE, ACL_EXECUTE},
+ {ARCHIVE_ENTRY_ACL_DELETE, ACL_DELETE},
+ {ARCHIVE_ENTRY_ACL_APPEND_DATA, ACL_APPEND_DATA},
+ {ARCHIVE_ENTRY_ACL_ADD_SUBDIRECTORY, ACL_ADD_SUBDIRECTORY},
+ {ARCHIVE_ENTRY_ACL_DELETE_CHILD, ACL_DELETE_CHILD},
+ {ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES, ACL_READ_ATTRIBUTES},
+ {ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES, ACL_WRITE_ATTRIBUTES},
+ {ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS, ACL_READ_EXTATTRIBUTES},
+ {ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS, ACL_WRITE_EXTATTRIBUTES},
+ {ARCHIVE_ENTRY_ACL_READ_ACL, ACL_READ_SECURITY},
+ {ARCHIVE_ENTRY_ACL_WRITE_ACL, ACL_WRITE_SECURITY},
+ {ARCHIVE_ENTRY_ACL_WRITE_OWNER, ACL_CHANGE_OWNER},
+ {ARCHIVE_ENTRY_ACL_SYNCHRONIZE, ACL_SYNCHRONIZE}
+#else /* POSIX.1e ACL permissions */
{ARCHIVE_ENTRY_ACL_EXECUTE, ACL_EXECUTE},
{ARCHIVE_ENTRY_ACL_WRITE, ACL_WRITE},
{ARCHIVE_ENTRY_ACL_READ, ACL_READ},
-#ifdef ACL_TYPE_NFS4
+#if HAVE_ACL_TYPE_NFS4 /* FreeBSD NFSv4 ACL permissions */
{ARCHIVE_ENTRY_ACL_READ_DATA, ACL_READ_DATA},
{ARCHIVE_ENTRY_ACL_LIST_DIRECTORY, ACL_LIST_DIRECTORY},
{ARCHIVE_ENTRY_ACL_WRITE_DATA, ACL_WRITE_DATA},
@@ -114,34 +181,69 @@ static struct {
{ARCHIVE_ENTRY_ACL_WRITE_OWNER, ACL_WRITE_OWNER},
{ARCHIVE_ENTRY_ACL_SYNCHRONIZE, ACL_SYNCHRONIZE}
#endif
+#endif /* !HAVE_SUN_ACL && !HAVE_DARWIN_ACL */
};
-#ifdef ACL_TYPE_NFS4
-static struct {
- int archive_inherit;
- int platform_inherit;
+#if HAVE_NFS4_ACL
+/*
+ * Translate system NFSv4 inheritance flags into libarchive internal structure
+ */
+static const struct {
+ const int archive_inherit;
+ const int platform_inherit;
} acl_inherit_map[] = {
+#if HAVE_SUN_ACL /* Solaris NFSv4 inheritance flags */
+ {ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT, ACE_FILE_INHERIT_ACE},
+ {ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT, ACE_DIRECTORY_INHERIT_ACE},
+ {ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT, ACE_NO_PROPAGATE_INHERIT_ACE},
+ {ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY, ACE_INHERIT_ONLY_ACE},
+ {ARCHIVE_ENTRY_ACL_ENTRY_SUCCESSFUL_ACCESS, ACE_SUCCESSFUL_ACCESS_ACE_FLAG},
+ {ARCHIVE_ENTRY_ACL_ENTRY_FAILED_ACCESS, ACE_FAILED_ACCESS_ACE_FLAG},
+ {ARCHIVE_ENTRY_ACL_ENTRY_INHERITED, ACE_INHERITED_ACE}
+#elif HAVE_DARWIN_ACL /* MacOS NFSv4 inheritance flags */
+ {ARCHIVE_ENTRY_ACL_ENTRY_INHERITED, ACL_ENTRY_INHERITED},
+ {ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT, ACL_ENTRY_FILE_INHERIT},
+ {ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT, ACL_ENTRY_DIRECTORY_INHERIT},
+ {ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT, ACL_ENTRY_LIMIT_INHERIT},
+ {ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY, ACL_ENTRY_ONLY_INHERIT}
+#else /* FreeBSD NFSv4 ACL inheritance flags */
{ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT, ACL_ENTRY_FILE_INHERIT},
{ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT, ACL_ENTRY_DIRECTORY_INHERIT},
{ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT, ACL_ENTRY_NO_PROPAGATE_INHERIT},
- {ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY, ACL_ENTRY_INHERIT_ONLY}
+ {ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY, ACL_ENTRY_INHERIT_ONLY},
+ {ARCHIVE_ENTRY_ACL_ENTRY_SUCCESSFUL_ACCESS, ACL_ENTRY_SUCCESSFUL_ACCESS},
+ {ARCHIVE_ENTRY_ACL_ENTRY_FAILED_ACCESS, ACL_ENTRY_FAILED_ACCESS},
+ {ARCHIVE_ENTRY_ACL_ENTRY_INHERITED, ACL_ENTRY_INHERITED}
+#endif /* !HAVE_SUN_ACL && !HAVE_DARWIN_ACL */
};
-#endif
+#endif /* HAVE_NFS4_ACL */
static int
set_acl(struct archive *a, int fd, const char *name,
struct archive_acl *abstract_acl,
acl_type_t acl_type, int ae_requested_type, const char *tname)
{
+#if HAVE_SUN_ACL
+ aclent_t *aclent;
+ ace_t *ace;
+ int e, r;
+ acl_t *acl;
+#else
acl_t acl;
acl_entry_t acl_entry;
acl_permset_t acl_permset;
-#ifdef ACL_TYPE_NFS4
+#if HAVE_ACL_TYPE_NFS4 || HAVE_DARWIN_ACL
acl_flagset_t acl_flagset;
- int r;
+#endif
+#endif /* HAVE_SUN_ACL */
+#if HAVE_ACL_TYPE_NFS4
+ int r;
#endif
int ret;
int ae_type, ae_permset, ae_tag, ae_id;
+#if HAVE_DARWIN_ACL
+ uuid_t ae_uuid;
+#endif
uid_t ae_uid;
gid_t ae_gid;
const char *ae_name;
@@ -152,32 +254,165 @@ set_acl(struct archive *a, int fd, const char *name,
entries = archive_acl_reset(abstract_acl, ae_requested_type);
if (entries == 0)
return (ARCHIVE_OK);
+
+#if HAVE_SUN_ACL
+ acl = NULL;
+ acl = malloc(sizeof(acl_t));
+ if (acl == NULL) {
+ archive_set_error(a, ARCHIVE_ERRNO_MISC,
+ "Invalid ACL type");
+ return (ARCHIVE_FAILED);
+ }
+ if (acl_type == ACE_T)
+ acl->acl_entry_size = sizeof(ace_t);
+ else if (acl_type == ACLENT_T)
+ acl->acl_entry_size = sizeof(aclent_t);
+ else {
+ archive_set_error(a, ARCHIVE_ERRNO_MISC,
+ "Invalid ACL type");
+ acl_free(acl);
+ return (ARCHIVE_FAILED);
+ }
+ acl->acl_type = acl_type;
+ acl->acl_cnt = entries;
+
+ acl->acl_aclp = malloc(entries * acl->acl_entry_size);
+ if (acl->acl_aclp == NULL) {
+ archive_set_error(a, errno,
+ "Can't allocate memory for acl buffer");
+ acl_free(acl);
+ return (ARCHIVE_FAILED);
+ }
+#else /* !HAVE_SUN_ACL */
acl = acl_init(entries);
if (acl == (acl_t)NULL) {
archive_set_error(a, errno,
"Failed to initialize ACL working storage");
return (ARCHIVE_FAILED);
}
+#endif /* !HAVE_SUN_ACL */
+#if HAVE_SUN_ACL
+ e = 0;
+#endif
while (archive_acl_next(a, abstract_acl, ae_requested_type, &ae_type,
&ae_permset, &ae_tag, &ae_id, &ae_name) == ARCHIVE_OK) {
+#if HAVE_SUN_ACL
+ ace = NULL;
+ aclent = NULL;
+ if (acl->acl_type == ACE_T) {
+ ace = &((ace_t *)acl->acl_aclp)[e];
+ ace->a_who = -1;
+ ace->a_access_mask = 0;
+ ace->a_flags = 0;
+ } else {
+ aclent = &((aclent_t *)acl->acl_aclp)[e];
+ aclent->a_id = -1;
+ aclent->a_type = 0;
+ aclent->a_perm = 0;
+ }
+#else /* !HAVE_SUN_ACL */
+#if HAVE_DARWIN_ACL
+ /*
+ * Mac OS doesn't support NFSv4 ACLs for
+ * owner@, group@ and everyone@.
+ * We skip any of these ACLs found.
+ */
+ if (ae_tag == ARCHIVE_ENTRY_ACL_USER_OBJ ||
+ ae_tag == ARCHIVE_ENTRY_ACL_GROUP_OBJ ||
+ ae_tag == ARCHIVE_ENTRY_ACL_EVERYONE)
+ continue;
+#endif
if (acl_create_entry(&acl, &acl_entry) != 0) {
archive_set_error(a, errno,
"Failed to create a new ACL entry");
ret = ARCHIVE_FAILED;
goto exit_free;
}
-
+#endif /* !HAVE_SUN_ACL */
+#if HAVE_DARWIN_ACL
+ switch (ae_type) {
+ case ARCHIVE_ENTRY_ACL_TYPE_ALLOW:
+ acl_set_tag_type(acl_entry, ACL_EXTENDED_ALLOW);
+ break;
+ case ARCHIVE_ENTRY_ACL_TYPE_DENY:
+ acl_set_tag_type(acl_entry, ACL_EXTENDED_DENY);
+ break;
+ default:
+ /* We don't support any other types on MacOS */
+ continue;
+ }
+#endif
switch (ae_tag) {
+#if HAVE_SUN_ACL
case ARCHIVE_ENTRY_ACL_USER:
- acl_set_tag_type(acl_entry, ACL_USER);
ae_uid = archive_write_disk_uid(a, ae_name, ae_id);
+ if (acl->acl_type == ACE_T)
+ ace->a_who = ae_uid;
+ else {
+ aclent->a_id = ae_uid;
+ aclent->a_type |= USER;
+ }
+ break;
+ case ARCHIVE_ENTRY_ACL_GROUP:
+ ae_gid = archive_write_disk_gid(a, ae_name, ae_id);
+ if (acl->acl_type == ACE_T) {
+ ace->a_who = ae_gid;
+ ace->a_flags |= ACE_IDENTIFIER_GROUP;
+ } else {
+ aclent->a_id = ae_gid;
+ aclent->a_type |= GROUP;
+ }
+ break;
+ case ARCHIVE_ENTRY_ACL_USER_OBJ:
+ if (acl->acl_type == ACE_T)
+ ace->a_flags |= ACE_OWNER;
+ else
+ aclent->a_type |= USER_OBJ;
+ break;
+ case ARCHIVE_ENTRY_ACL_GROUP_OBJ:
+ if (acl->acl_type == ACE_T) {
+ ace->a_flags |= ACE_GROUP;
+ ace->a_flags |= ACE_IDENTIFIER_GROUP;
+ } else
+ aclent->a_type |= GROUP_OBJ;
+ break;
+ case ARCHIVE_ENTRY_ACL_MASK:
+ aclent->a_type |= CLASS_OBJ;
+ break;
+ case ARCHIVE_ENTRY_ACL_OTHER:
+ aclent->a_type |= OTHER_OBJ;
+ break;
+ case ARCHIVE_ENTRY_ACL_EVERYONE:
+ ace->a_flags |= ACE_EVERYONE;
+ break;
+#else /* !HAVE_SUN_ACL */
+ case ARCHIVE_ENTRY_ACL_USER:
+ ae_uid = archive_write_disk_uid(a, ae_name, ae_id);
+#if !HAVE_DARWIN_ACL /* FreeBSD, Linux */
+ acl_set_tag_type(acl_entry, ACL_USER);
acl_set_qualifier(acl_entry, &ae_uid);
+#else /* MacOS */
+ if (mbr_identifier_to_uuid(ID_TYPE_UID, &ae_uid,
+ sizeof(uid_t), ae_uuid) != 0)
+ continue;
+ if (acl_set_qualifier(acl_entry, &ae_uuid) != 0)
+ continue;
+#endif /* HAVE_DARWIN_ACL */
break;
case ARCHIVE_ENTRY_ACL_GROUP:
- acl_set_tag_type(acl_entry, ACL_GROUP);
ae_gid = archive_write_disk_gid(a, ae_name, ae_id);
+#if !HAVE_DARWIN_ACL /* FreeBSD, Linux */
+ acl_set_tag_type(acl_entry, ACL_GROUP);
acl_set_qualifier(acl_entry, &ae_gid);
+#else /* MacOS */
+ if (mbr_identifier_to_uuid(ID_TYPE_GID, &ae_gid,
+ sizeof(gid_t), ae_uuid) != 0)
+ continue;
+ if (acl_set_qualifier(acl_entry, &ae_uuid) != 0)
+ continue;
+#endif /* HAVE_DARWIN_ACL */
break;
+#if !HAVE_DARWIN_ACL /* FreeBSD, Linux */
case ARCHIVE_ENTRY_ACL_USER_OBJ:
acl_set_tag_type(acl_entry, ACL_USER_OBJ);
break;
@@ -190,11 +425,13 @@ set_acl(struct archive *a, int fd, const char *name,
case ARCHIVE_ENTRY_ACL_OTHER:
acl_set_tag_type(acl_entry, ACL_OTHER);
break;
-#ifdef ACL_TYPE_NFS4
+#if HAVE_ACL_TYPE_NFS4 /* FreeBSD only */
case ARCHIVE_ENTRY_ACL_EVERYONE:
acl_set_tag_type(acl_entry, ACL_EVERYONE);
break;
#endif
+#endif /* !HAVE_DARWIN_ACL */
+#endif /* !HAVE_SUN_ACL */
default:
archive_set_error(a, ARCHIVE_ERRNO_MISC,
"Unknown ACL tag");
@@ -202,9 +439,45 @@ set_acl(struct archive *a, int fd, const char *name,
goto exit_free;
}
-#ifdef ACL_TYPE_NFS4
+#if HAVE_ACL_TYPE_NFS4 || HAVE_SUN_ACL
r = 0;
switch (ae_type) {
+#if HAVE_SUN_ACL
+ case ARCHIVE_ENTRY_ACL_TYPE_ALLOW:
+ if (ace != NULL)
+ ace->a_type = ACE_ACCESS_ALLOWED_ACE_TYPE;
+ else
+ r = -1;
+ break;
+ case ARCHIVE_ENTRY_ACL_TYPE_DENY:
+ if (ace != NULL)
+ ace->a_type = ACE_ACCESS_DENIED_ACE_TYPE;
+ else
+ r = -1;
+ break;
+ case ARCHIVE_ENTRY_ACL_TYPE_AUDIT:
+ if (ace != NULL)
+ ace->a_type = ACE_SYSTEM_AUDIT_ACE_TYPE;
+ else
+ r = -1;
+ break;
+ case ARCHIVE_ENTRY_ACL_TYPE_ALARM:
+ if (ace != NULL)
+ ace->a_type = ACE_SYSTEM_ALARM_ACE_TYPE;
+ else
+ r = -1;
+ break;
+ case ARCHIVE_ENTRY_ACL_TYPE_ACCESS:
+ if (aclent == NULL)
+ r = -1;
+ break;
+ case ARCHIVE_ENTRY_ACL_TYPE_DEFAULT:
+ if (aclent != NULL)
+ aclent->a_type |= ACL_DEFAULT;
+ else
+ r = -1;
+ break;
+#else /* !HAVE_SUN_ACL */
case ARCHIVE_ENTRY_ACL_TYPE_ALLOW:
r = acl_set_entry_type_np(acl_entry, ACL_ENTRY_TYPE_ALLOW);
break;
@@ -221,20 +494,35 @@ set_acl(struct archive *a, int fd, const char *name,
case ARCHIVE_ENTRY_ACL_TYPE_DEFAULT:
// These don't translate directly into the system ACL.
break;
+#endif /* !HAVE_SUN_ACL */
default:
archive_set_error(a, ARCHIVE_ERRNO_MISC,
"Unknown ACL entry type");
ret = ARCHIVE_FAILED;
goto exit_free;
}
+
if (r != 0) {
+#if HAVE_SUN_ACL
+ errno = EINVAL;
+#endif
archive_set_error(a, errno,
"Failed to set ACL entry type");
ret = ARCHIVE_FAILED;
goto exit_free;
}
-#endif
+#endif /* HAVE_ACL_TYPE_NFS4 || HAVE_SUN_ACL */
+#if HAVE_SUN_ACL
+ if (acl->acl_type == ACLENT_T) {
+ if (ae_permset & ARCHIVE_ENTRY_ACL_EXECUTE)
+ aclent->a_perm |= 1;
+ if (ae_permset & ARCHIVE_ENTRY_ACL_WRITE)
+ aclent->a_perm |= 2;
+ if (ae_permset & ARCHIVE_ENTRY_ACL_READ)
+ aclent->a_perm |= 4;
+ } else
+#else
if (acl_get_permset(acl_entry, &acl_permset) != 0) {
archive_set_error(a, errno,
"Failed to get ACL permission set");
@@ -247,9 +535,13 @@ set_acl(struct archive *a, int fd, const char *name,
ret = ARCHIVE_FAILED;
goto exit_free;
}
-
+#endif /* !HAVE_SUN_ACL */
for (i = 0; i < (int)(sizeof(acl_perm_map) / sizeof(acl_perm_map[0])); ++i) {
- if (ae_permset & acl_perm_map[i].archive_perm)
+ if (ae_permset & acl_perm_map[i].archive_perm) {
+#if HAVE_SUN_ACL
+ ace->a_access_mask |=
+ acl_perm_map[i].platform_perm;
+#else
if (acl_add_perm(acl_permset,
acl_perm_map[i].platform_perm) != 0) {
archive_set_error(a, errno,
@@ -257,10 +549,20 @@ set_acl(struct archive *a, int fd, const char *name,
ret = ARCHIVE_FAILED;
goto exit_free;
}
+#endif
+ }
}
-#ifdef ACL_TYPE_NFS4
- if (acl_type == ACL_TYPE_NFS4) {
+#if HAVE_NFS4_ACL
+#if HAVE_SUN_ACL
+ if (acl_type == ACE_T)
+#elif HAVE_DARWIN_ACL
+ if (acl_type == ACL_TYPE_EXTENDED)
+#else /* FreeBSD */
+ if (acl_type == ACL_TYPE_NFS4)
+#endif
+ {
+#if HAVE_POSIX_ACL || HAVE_DARWIN_ACL
/*
* acl_get_flagset_np() fails with non-NFSv4 ACLs
*/
@@ -276,8 +578,13 @@ set_acl(struct archive *a, int fd, const char *name,
ret = ARCHIVE_FAILED;
goto exit_free;
}
- for (i = 0; i < (int)(sizeof(acl_inherit_map) / sizeof(acl_inherit_map[0])); ++i) {
+#endif /* HAVE_POSIX_ACL || HAVE_DARWIN_ACL */
+ for (i = 0; i < (int)(sizeof(acl_inherit_map) /sizeof(acl_inherit_map[0])); ++i) {
if (ae_permset & acl_inherit_map[i].archive_inherit) {
+#if HAVE_SUN_ACL
+ ace->a_flags |=
+ acl_inherit_map[i].platform_inherit;
+#else /* !HAVE_SUN_ACL */
if (acl_add_flag_np(acl_flagset,
acl_inherit_map[i].platform_inherit) != 0) {
archive_set_error(a, errno,
@@ -285,38 +592,63 @@ set_acl(struct archive *a, int fd, const char *name,
ret = ARCHIVE_FAILED;
goto exit_free;
}
+#endif /* HAVE_SUN_ACL */
}
}
}
+#endif /* HAVE_NFS4_ACL */
+#if HAVE_SUN_ACL
+ e++;
#endif
}
+#if HAVE_ACL_SET_FD_NP || HAVE_ACL_SET_FD || HAVE_SUN_ACL
/* Try restoring the ACL through 'fd' if we can. */
-#if HAVE_ACL_SET_FD
- if (fd >= 0 && acl_type == ACL_TYPE_ACCESS && acl_set_fd(fd, acl) == 0)
- ret = ARCHIVE_OK;
- else
-#else
-#if HAVE_ACL_SET_FD_NP
- if (fd >= 0 && acl_set_fd_np(fd, acl, acl_type) == 0)
- ret = ARCHIVE_OK;
- else
+#if HAVE_SUN_ACL || HAVE_ACL_SET_FD_NP
+ if (fd >= 0)
+#else /* !HAVE_SUN_ACL && !HAVE_ACL_SET_FD_NP */
+ if (fd >= 0 && acl_type == ACL_TYPE_ACCESS)
#endif
+ {
+#if HAVE_SUN_ACL
+ if (facl_set(fd, acl) == 0)
+#elif HAVE_ACL_SET_FD_NP
+ if (acl_set_fd_np(fd, acl, acl_type) == 0)
+#else /* !HAVE_SUN_ACL && !HAVE_ACL_SET_FD_NP */
+ if (acl_set_fd(fd, acl) == 0)
#endif
-#if HAVE_ACL_SET_LINK_NP
- if (acl_set_link_np(name, acl_type, acl) != 0) {
- archive_set_error(a, errno, "Failed to set %s acl", tname);
- ret = ARCHIVE_WARN;
- }
+ ret = ARCHIVE_OK;
+ else {
+ if (errno == EOPNOTSUPP) {
+ /* Filesystem doesn't support ACLs */
+ ret = ARCHIVE_OK;
+ } else {
+ archive_set_error(a, errno,
+ "Failed to set %s acl on fd", tname);
+ }
+ }
+ } else
+#endif /* HAVE_ACL_SET_FD_NP || HAVE_ACL_SET_FD || HAVE_SUN_ACL */
+#if HAVE_SUN_ACL
+ if (acl_set(name, acl) != 0)
+#elif HAVE_ACL_SET_LINK_NP
+ if (acl_set_link_np(name, acl_type, acl) != 0)
#else
/* TODO: Skip this if 'name' is a symlink. */
- if (acl_set_file(name, acl_type, acl) != 0) {
- archive_set_error(a, errno, "Failed to set %s acl", tname);
- ret = ARCHIVE_WARN;
- }
+ if (acl_set_file(name, acl_type, acl) != 0)
#endif
+ {
+ if (errno == EOPNOTSUPP) {
+ /* Filesystem doesn't support ACLs */
+ ret = ARCHIVE_OK;
+ } else {
+ archive_set_error(a, errno, "Failed to set %s acl",
+ tname);
+ ret = ARCHIVE_WARN;
+ }
+ }
exit_free:
acl_free(acl);
return (ret);
}
-#endif
+#endif /* HAVE_POSIX_ACL || HAVE_NFS4_ACL */
diff --git a/contrib/libarchive/libarchive/archive_write_disk_posix.c b/contrib/libarchive/libarchive/archive_write_disk_posix.c
index c05059a..a799524 100644
--- a/contrib/libarchive/libarchive/archive_write_disk_posix.c
+++ b/contrib/libarchive/libarchive/archive_write_disk_posix.c
@@ -110,6 +110,18 @@ __FBSDID("$FreeBSD$");
#include <sys/fcntl1.h>
#endif
+/*
+ * Macro to cast st_mtime and time_t to an int64 so that 2 numbers can reliably be compared.
+ *
+ * It assumes that the input is an integer type of no more than 64 bits.
+ * If the number is less than zero, t must be a signed type, so it fits in
+ * int64_t. Otherwise, it's a nonnegative value so we can cast it to uint64_t
+ * without loss. But it could be a large unsigned value, so we have to clip it
+ * to INT64_MAX.*
+ */
+#define to_int64_time(t) \
+ ((t) < 0 ? (int64_t)(t) : (uint64_t)(t) > (uint64_t)INT64_MAX ? INT64_MAX : (int64_t)(t))
+
#if __APPLE__
#include <TargetConditionals.h>
#if TARGET_OS_MAC && !TARGET_OS_EMBEDDED && HAVE_QUARANTINE_H
@@ -308,7 +320,7 @@ struct archive_write_disk {
#define MAXIMUM_DIR_MODE 0775
/*
- * Maxinum uncompressed size of a decmpfs block.
+ * Maximum uncompressed size of a decmpfs block.
*/
#define MAX_DECMPFS_BLOCK_SIZE (64 * 1024)
/*
@@ -323,7 +335,7 @@ struct archive_write_disk {
#define RSRC_F_SIZE 50 /* Size of Resource fork footer. */
/* Size to write compressed data to resource fork. */
#define COMPRESSED_W_SIZE (64 * 1024)
-/* decmpfs difinitions. */
+/* decmpfs definitions. */
#define MAX_DECMPFS_XATTR_SIZE 3802
#ifndef DECMPFS_XATTR_NAME
#define DECMPFS_XATTR_NAME "com.apple.decmpfs"
@@ -632,9 +644,9 @@ _archive_write_disk_header(struct archive *_a, struct archive_entry *entry)
/*
* NOTE: UF_COMPRESSED is ignored even if the filesystem
* supports HFS+ Compression because the file should
- * have at least an extended attriute "com.apple.decmpfs"
+ * have at least an extended attribute "com.apple.decmpfs"
* before the flag is set to indicate that the file have
- * been compressed. If hte filesystem does not support
+ * been compressed. If the filesystem does not support
* HFS+ Compression the system call will fail.
*/
if (a->fd < 0 || fchflags(a->fd, UF_COMPRESSED) != 0)
@@ -1247,7 +1259,7 @@ hfs_drive_compressor(struct archive_write_disk *a, const char *buff,
ret = hfs_write_compressed_data(a, bytes_used + rsrc_size);
a->compressed_buffer_remaining = a->compressed_buffer_size;
- /* If the compressed size is not enouph smaller than
+ /* If the compressed size is not enough smaller than
* the uncompressed size. cancel HFS+ compression.
* TODO: study a behavior of ditto utility and improve
* the condition to fall back into no HFS+ compression. */
@@ -1352,7 +1364,7 @@ hfs_write_decmpfs_block(struct archive_write_disk *a, const char *buff,
(uint32_t *)(a->resource_fork + RSRC_H_SIZE);
/* Set the block count to the resource fork. */
archive_le32enc(a->decmpfs_block_info++, block_count);
- /* Get the position where we are goint to set compressed
+ /* Get the position where we are going to set compressed
* data. */
a->compressed_rsrc_position =
RSRC_H_SIZE + 4 + (block_count * 8);
@@ -1425,7 +1437,7 @@ hfs_write_data_block(struct archive_write_disk *a, const char *buff,
bytes_to_write = size;
/* Seek if necessary to the specified offset. */
if (a->offset < a->fd_offset) {
- /* Can't support backword move. */
+ /* Can't support backward move. */
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
"Seek failed");
return (ARCHIVE_FATAL);
@@ -1690,10 +1702,25 @@ _archive_write_disk_finish_entry(struct archive *_a)
* ACLs that prevent attribute changes (including time).
*/
if (a->todo & TODO_ACLS) {
- int r2 = archive_write_disk_set_acls(&a->archive, a->fd,
- archive_entry_pathname(a->entry),
- archive_entry_acl(a->entry));
+ int r2;
+#ifdef HAVE_DARWIN_ACL
+ /*
+ * On Mac OS, platform ACLs are stored also in mac_metadata by
+ * the operating system. If mac_metadata is present it takes
+ * precedence and we skip extracting libarchive NFSv4 ACLs
+ */
+ const void *metadata;
+ size_t metadata_size;
+ metadata = archive_entry_mac_metadata(a->entry, &metadata_size);
+ if (metadata == NULL || metadata_size == 0) {
+#endif
+ r2 = archive_write_disk_set_acls(&a->archive, a->fd,
+ archive_entry_pathname(a->entry),
+ archive_entry_acl(a->entry));
if (r2 < ret) ret = r2;
+#ifdef HAVE_DARWIN_ACL
+ }
+#endif
}
finish_metadata:
@@ -2065,6 +2092,7 @@ create_filesystem_object(struct archive_write_disk *a)
archive_set_error(&a->archive, error_number, "%s",
error_string.s);
free(linkname_copy);
+ archive_string_free(&error_string);
/*
* EPERM is more appropriate than error_number for our
* callers
@@ -2077,6 +2105,7 @@ create_filesystem_object(struct archive_write_disk *a)
archive_set_error(&a->archive, error_number, "%s",
error_string.s);
free(linkname_copy);
+ archive_string_free(&error_string);
/*
* EPERM is more appropriate than error_number for our
* callers
@@ -2084,6 +2113,7 @@ create_filesystem_object(struct archive_write_disk *a)
return (EPERM);
}
free(linkname_copy);
+ archive_string_free(&error_string);
r = link(linkname, a->name) ? errno : 0;
/*
* New cpio and pax formats allow hardlink entries
@@ -2252,8 +2282,12 @@ _archive_write_disk_close(struct archive *_a)
if (p->fixup & TODO_MODE_BASE)
chmod(p->name, p->mode);
if (p->fixup & TODO_ACLS)
- archive_write_disk_set_acls(&a->archive,
- -1, p->name, &p->acl);
+#ifdef HAVE_DARWIN_ACL
+ if (p->mac_metadata == NULL ||
+ p->mac_metadata_size == 0)
+#endif
+ archive_write_disk_set_acls(&a->archive,
+ -1, p->name, &p->acl);
if (p->fixup & TODO_FFLAGS)
set_fflags_platform(a, -1, p->name,
p->mode, p->fflags_set, 0);
@@ -4125,10 +4159,10 @@ older(struct stat *st, struct archive_entry *entry)
{
/* First, test the seconds and return if we have a definite answer. */
/* Definitely older. */
- if (st->st_mtime < archive_entry_mtime(entry))
+ if (to_int64_time(st->st_mtime) < to_int64_time(archive_entry_mtime(entry)))
return (1);
/* Definitely younger. */
- if (st->st_mtime > archive_entry_mtime(entry))
+ if (to_int64_time(st->st_mtime) > to_int64_time(archive_entry_mtime(entry)))
return (0);
/* If this platform supports fractional seconds, try those. */
#if HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC
diff --git a/contrib/libarchive/libarchive/archive_write_open.3 b/contrib/libarchive/libarchive/archive_write_open.3
index a52959b..457873e 100644
--- a/contrib/libarchive/libarchive/archive_write_open.3
+++ b/contrib/libarchive/libarchive/archive_write_open.3
@@ -66,6 +66,7 @@ Freeze the settings, open the archive, and prepare for writing entries.
This is the most generic form of this function, which accepts
pointers to three callback functions which will be invoked by
the compression layer to write the constructed archive.
+This does not alter the default archive padding.
.It Fn archive_write_open_fd
A convenience form of
.Fn archive_write_open
@@ -123,12 +124,21 @@ is currently in use.
You should be careful to ensure that this variable
remains allocated until after the archive is
closed.
+This function will disable padding unless you
+have specifically set the block size.
.El
More information about the
.Va struct archive
object and the overall design of the library can be found in the
.Xr libarchive 3
overview.
+.Pp
+Note that the convenience forms above vary in how
+they block the output.
+See
+.Xr archive_write_blocksize 3
+if you need to control the block size used for writes
+or the end-of-file padding behavior.
.\"
.Sh CLIENT CALLBACKS
To use this library, you will need to define and register
@@ -226,6 +236,7 @@ functions.
.Xr tar 1 ,
.Xr libarchive 3 ,
.Xr archive_write 3 ,
+.Xr archive_write_blocksize 3 ,
.Xr archive_write_filter 3 ,
.Xr archive_write_format 3 ,
.Xr archive_write_new 3 ,
diff --git a/contrib/libarchive/libarchive/archive_write_set_format_7zip.c b/contrib/libarchive/libarchive/archive_write_set_format_7zip.c
index abd521a..41ed74d 100644
--- a/contrib/libarchive/libarchive/archive_write_set_format_7zip.c
+++ b/contrib/libarchive/libarchive/archive_write_set_format_7zip.c
@@ -1358,7 +1358,7 @@ make_header(struct archive_write *a, uint64_t offset, uint64_t pack_size,
if (r < 0)
return (r);
- /* Write Nume size. */
+ /* Write Name size. */
r = enc_uint64(a, zip->total_bytes_entry_name+1);
if (r < 0)
return (r);
diff --git a/contrib/libarchive/libarchive/archive_write_set_format_gnutar.c b/contrib/libarchive/libarchive/archive_write_set_format_gnutar.c
index a9c4123..2d858c9 100644
--- a/contrib/libarchive/libarchive/archive_write_set_format_gnutar.c
+++ b/contrib/libarchive/libarchive/archive_write_set_format_gnutar.c
@@ -478,15 +478,15 @@ archive_write_gnutar_header(struct archive_write *a,
archive_entry_set_pathname(temp, "././@LongLink");
archive_entry_set_size(temp, length);
ret = archive_format_gnutar_header(a, buff, temp, 'K');
+ archive_entry_free(temp);
if (ret < ARCHIVE_WARN)
goto exit_write_header;
ret = __archive_write_output(a, buff, 512);
- if(ret < ARCHIVE_WARN)
+ if (ret < ARCHIVE_WARN)
goto exit_write_header;
- archive_entry_free(temp);
/* Write name and trailing null byte. */
ret = __archive_write_output(a, gnutar->linkname, length);
- if(ret < ARCHIVE_WARN)
+ if (ret < ARCHIVE_WARN)
goto exit_write_header;
/* Pad to 512 bytes */
ret = __archive_write_nulls(a, 0x1ff & (-(ssize_t)length));
@@ -508,12 +508,12 @@ archive_write_gnutar_header(struct archive_write *a,
archive_entry_set_pathname(temp, "././@LongLink");
archive_entry_set_size(temp, length);
ret = archive_format_gnutar_header(a, buff, temp, 'L');
+ archive_entry_free(temp);
if (ret < ARCHIVE_WARN)
goto exit_write_header;
ret = __archive_write_output(a, buff, 512);
if(ret < ARCHIVE_WARN)
goto exit_write_header;
- archive_entry_free(temp);
/* Write pathname + trailing null byte. */
ret = __archive_write_output(a, pathname, length);
if(ret < ARCHIVE_WARN)
diff --git a/contrib/libarchive/libarchive/archive_write_set_format_iso9660.c b/contrib/libarchive/libarchive/archive_write_set_format_iso9660.c
index bf69c3e..4e91097 100644
--- a/contrib/libarchive/libarchive/archive_write_set_format_iso9660.c
+++ b/contrib/libarchive/libarchive/archive_write_set_format_iso9660.c
@@ -161,7 +161,7 @@ struct isofile {
/* Used for managing struct isofile list. */
struct isofile *allnext;
struct isofile *datanext;
- /* Used for managing a hardlined struct isofile list. */
+ /* Used for managing a hardlinked struct isofile list. */
struct isofile *hlnext;
struct isofile *hardlink_target;
@@ -528,7 +528,7 @@ struct iso_option {
* - allow more then 8 depths of directory trees;
* - disable a version number to a File Name;
* - disable a forced period to the tail of a File Name;
- * - the maxinum length of files and directories is raised to 193.
+ * - the maximum length of files and directories is raised to 193.
* if rockridge option is disabled, raised to 207.
*/
unsigned int iso_level:3;
@@ -626,7 +626,7 @@ struct iso_option {
* : NOTE Our rockridge=useful option does not set a zero
* : to uid and gid, you should use application
* : option such as --gid,--gname,--uid and --uname
- * : badtar options instead.
+ * : bsdtar options instead.
* Type : boolean/string
* Default: Enabled as rockridge=useful
* COMPAT : mkisofs -r / -R
@@ -660,7 +660,7 @@ struct iso_option {
* : for making zisofs.
* : When the file size is less than one Logical Block
* : size, that file will not zisofs'ed since it does
- * : reduece an ISO-image size.
+ * : reduce an ISO-image size.
* :
* : When you specify option 'boot=<boot-image>', that
* : 'boot-image' file won't be converted to zisofs file.
@@ -703,7 +703,7 @@ struct iso9660 {
} all_file_list;
/* A list of struct isofile entries which have its
- * contents and are not a directory, a hardlined file
+ * contents and are not a directory, a hardlinked file
* and a symlink file. */
struct {
struct isofile *first;
@@ -1907,9 +1907,9 @@ iso9660_close(struct archive_write *a)
iso9660->primary.rootent);
if (ret < 0)
return (ret);
- /* Make sure we have UTF-16BE convertors.
- * if there is no file entry, convertors are still
- * uninitilized. */
+ /* Make sure we have UTF-16BE converters.
+ * if there is no file entry, converters are still
+ * uninitialized. */
if (iso9660->sconv_to_utf16be == NULL) {
iso9660->sconv_to_utf16be =
archive_string_conversion_to_charset(
@@ -2524,7 +2524,8 @@ get_tmfromtime(struct tm *tm, time_t *t)
tzset();
localtime_r(t, tm);
#elif HAVE__LOCALTIME64_S
- _localtime64_s(tm, t);
+ __time64_t tmp_t = (__time64_t) *t; //time_t may be shorter than 64 bits
+ _localtime64_s(tm, &tmp_t);
#else
memcpy(tm, localtime(t), sizeof(*tm));
#endif
@@ -2553,7 +2554,7 @@ set_date_time(unsigned char *p, time_t t)
static void
set_date_time_null(unsigned char *p)
{
- memset(p, '0', 16);
+ memset(p, (int)'0', 16);
p[16] = 0;
}
@@ -2959,7 +2960,7 @@ set_directory_record_rr(unsigned char *bp, int dr_len,
gid = archive_entry_gid(file->entry);
if (iso9660->opt.rr == OPT_RR_USEFUL) {
/*
- * This action is simular mkisofs -r option
+ * This action is similar to mkisofs -r option
* but our rockridge=useful option does not
* set a zero to uid and gid.
*/
@@ -3108,7 +3109,7 @@ set_directory_record_rr(unsigned char *bp, int dr_len,
/*
* flg len
* +----+----+
- * | 02 | 00 | CURREENT component.
+ * | 02 | 00 | CURRENT component.
* +----+----+ (".")
*/
if (nc != NULL) {
@@ -3947,7 +3948,7 @@ write_VD(struct archive_write *a, struct vdd *vdd)
"Abstract File", 0, D_CHAR);
if (r != ARCHIVE_OK)
return (r);
- /* Bibliongraphic File Identifier */
+ /* Bibliographic File Identifier */
r = set_file_identifier(bp, 777, 813, vdc, a, vdd,
&(iso9660->bibliographic_file_identifier),
"Bibliongraphic File", 0, D_CHAR);
@@ -4073,7 +4074,8 @@ write_information_block(struct archive_write *a)
memset(info.s, 0, info_size);
opt = 0;
#if defined(HAVE__CTIME64_S)
- _ctime64_s(buf, sizeof(buf), &(iso9660->birth_time));
+ __time64_t iso9660_birth_time_tmp = (__time64_t) iso9660->birth_time; //time_t may be shorter than 64 bits
+ _ctime64_s(buf, sizeof(buf), &(iso9660_birth_time_tmp));
#elif defined(HAVE_CTIME_R)
ctime_r(&(iso9660->birth_time), buf);
#else
@@ -6135,7 +6137,7 @@ isoent_gen_iso9660_identifier(struct archive_write *a, struct isoent *isoent,
off = ffmax - extlen;
if (off == 0) {
/* A dot('.') character
- * does't place to the first
+ * doesn't place to the first
* byte of identifier. */
off ++;
extlen --;
@@ -7149,7 +7151,7 @@ isoent_create_boot_catalog(struct archive_write *a, struct isoent *rootent)
iso9660->el_torito.catalog = isoent;
/*
- * Get a boot medai type.
+ * Get a boot media type.
*/
switch (iso9660->opt.boot_type) {
default:
diff --git a/contrib/libarchive/libarchive/archive_write_set_format_pax.c b/contrib/libarchive/libarchive/archive_write_set_format_pax.c
index 786eec4..da4fe97 100644
--- a/contrib/libarchive/libarchive/archive_write_set_format_pax.c
+++ b/contrib/libarchive/libarchive/archive_write_set_format_pax.c
@@ -1,6 +1,7 @@
/*-
* Copyright (c) 2003-2007 Tim Kientzle
* Copyright (c) 2010-2012 Michihiro NAKAJIMA
+ * Copyright (c) 2016 Martin Matuska
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -61,15 +62,24 @@ struct pax {
struct sparse_block *sparse_tail;
struct archive_string_conv *sconv_utf8;
int opt_binary;
+
+ unsigned flags;
+#define WRITE_SCHILY_XATTR (1 << 0)
+#define WRITE_LIBARCHIVE_XATTR (1 << 1)
};
static void add_pax_attr(struct archive_string *, const char *key,
const char *value);
+static void add_pax_attr_binary(struct archive_string *,
+ const char *key,
+ const char *value, size_t value_len);
static void add_pax_attr_int(struct archive_string *,
const char *key, int64_t value);
static void add_pax_attr_time(struct archive_string *,
const char *key, int64_t sec,
unsigned long nanos);
+static int add_pax_acl(struct archive_write *,
+ struct archive_entry *, struct pax *, int);
static ssize_t archive_write_pax_data(struct archive_write *,
const void *, size_t);
static int archive_write_pax_close(struct archive_write *);
@@ -133,6 +143,8 @@ archive_write_set_format_pax(struct archive *_a)
"Can't allocate pax data");
return (ARCHIVE_FATAL);
}
+ pax->flags = WRITE_LIBARCHIVE_XATTR | WRITE_SCHILY_XATTR;
+
a->format_data = pax;
a->format_name = "pax";
a->format_options = archive_write_pax_options;
@@ -272,6 +284,17 @@ add_pax_attr_int(struct archive_string *as, const char *key, int64_t value)
static void
add_pax_attr(struct archive_string *as, const char *key, const char *value)
{
+ add_pax_attr_binary(as, key, value, strlen(value));
+}
+
+/*
+ * Add a key/value attribute to the pax header. This function handles
+ * binary values.
+ */
+static void
+add_pax_attr_binary(struct archive_string *as, const char *key,
+ const char *value, size_t value_len)
+{
int digits, i, len, next_ten;
char tmp[1 + 3 * sizeof(int)]; /* < 3 base-10 digits per byte */
@@ -279,7 +302,7 @@ add_pax_attr(struct archive_string *as, const char *key, const char *value)
* PAX attributes have the following layout:
* <len> <space> <key> <=> <value> <nl>
*/
- len = 1 + (int)strlen(key) + 1 + (int)strlen(value) + 1;
+ len = 1 + (int)strlen(key) + 1 + (int)value_len + 1;
/*
* The <len> field includes the length of the <len> field, so
@@ -310,21 +333,47 @@ add_pax_attr(struct archive_string *as, const char *key, const char *value)
archive_strappend_char(as, ' ');
archive_strcat(as, key);
archive_strappend_char(as, '=');
- archive_strcat(as, value);
+ archive_array_append(as, value, value_len);
archive_strappend_char(as, '\n');
}
+static void
+archive_write_pax_header_xattr(struct pax *pax, const char *encoded_name,
+ const void *value, size_t value_len)
+{
+ struct archive_string s;
+ char *encoded_value;
+
+ if (pax->flags & WRITE_LIBARCHIVE_XATTR) {
+ encoded_value = base64_encode((const char *)value, value_len);
+
+ if (encoded_name != NULL && encoded_value != NULL) {
+ archive_string_init(&s);
+ archive_strcpy(&s, "LIBARCHIVE.xattr.");
+ archive_strcat(&s, encoded_name);
+ add_pax_attr(&(pax->pax_header), s.s, encoded_value);
+ archive_string_free(&s);
+ }
+ free(encoded_value);
+ }
+ if (pax->flags & WRITE_SCHILY_XATTR) {
+ archive_string_init(&s);
+ archive_strcpy(&s, "SCHILY.xattr.");
+ archive_strcat(&s, encoded_name);
+ add_pax_attr_binary(&(pax->pax_header), s.s, value, value_len);
+ archive_string_free(&s);
+ }
+}
+
static int
archive_write_pax_header_xattrs(struct archive_write *a,
struct pax *pax, struct archive_entry *entry)
{
- struct archive_string s;
int i = archive_entry_xattr_reset(entry);
while (i--) {
const char *name;
const void *value;
- char *encoded_value;
char *url_encoded_name = NULL, *encoded_name = NULL;
size_t size;
int r;
@@ -345,16 +394,9 @@ archive_write_pax_header_xattrs(struct archive_write *a,
}
}
- encoded_value = base64_encode((const char *)value, size);
+ archive_write_pax_header_xattr(pax, encoded_name,
+ value, size);
- if (encoded_name != NULL && encoded_value != NULL) {
- archive_string_init(&s);
- archive_strcpy(&s, "LIBARCHIVE.xattr.");
- archive_strcat(&s, encoded_name);
- add_pax_attr(&(pax->pax_header), s.s, encoded_value);
- archive_string_free(&s);
- }
- free(encoded_value);
}
return (ARCHIVE_OK);
}
@@ -449,6 +491,45 @@ get_entry_symlink(struct archive_write *a, struct archive_entry *entry,
return (ARCHIVE_OK);
}
+/* Add ACL to pax header */
+static int
+add_pax_acl(struct archive_write *a,
+ struct archive_entry *entry, struct pax *pax, int flags)
+{
+ char *p;
+ const char *attr;
+ int acl_types;
+
+ acl_types = archive_entry_acl_types(entry);
+
+ if ((acl_types & ARCHIVE_ENTRY_ACL_TYPE_NFS4) != 0)
+ attr = "SCHILY.acl.ace";
+ else if ((flags & ARCHIVE_ENTRY_ACL_TYPE_ACCESS) != 0)
+ attr = "SCHILY.acl.access";
+ else if ((flags & ARCHIVE_ENTRY_ACL_TYPE_DEFAULT) != 0)
+ attr = "SCHILY.acl.default";
+ else
+ return (ARCHIVE_FATAL);
+
+ p = archive_entry_acl_to_text_l(entry, NULL, flags, pax->sconv_utf8);
+ if (p == NULL) {
+ if (errno == ENOMEM) {
+ archive_set_error(&a->archive, ENOMEM, "%s %s",
+ "Can't allocate memory for ", attr);
+ return (ARCHIVE_FATAL);
+ }
+ archive_set_error(&a->archive,
+ ARCHIVE_ERRNO_FILE_FORMAT, "%s %s %s",
+ "Can't translate ", attr, " to UTF-8");
+ return(ARCHIVE_WARN);
+ } else if (*p != '\0') {
+ add_pax_attr(&(pax->pax_header),
+ attr, p);
+ free(p);
+ }
+ return(ARCHIVE_OK);
+}
+
/*
* TODO: Consider adding 'comment' and 'charset' fields to
* archive_entry so that clients can specify them. Also, consider
@@ -465,6 +546,7 @@ archive_write_pax_header(struct archive_write *a,
const char *p;
const char *suffix;
int need_extension, r, ret;
+ int acl_types;
int sparse_count;
uint64_t sparse_total, real_size;
struct pax *pax;
@@ -1016,16 +1098,6 @@ archive_write_pax_header(struct archive_write *a,
if (!need_extension && p != NULL && *p != '\0')
need_extension = 1;
- /* If there are non-trivial ACL entries, we need an extension. */
- if (!need_extension && archive_entry_acl_count(entry_original,
- ARCHIVE_ENTRY_ACL_TYPE_ACCESS) > 0)
- need_extension = 1;
-
- /* If there are non-trivial ACL entries, we need an extension. */
- if (!need_extension && archive_entry_acl_count(entry_original,
- ARCHIVE_ENTRY_ACL_TYPE_DEFAULT) > 0)
- need_extension = 1;
-
/* If there are extended attributes, we need an extension */
if (!need_extension && archive_entry_xattr_count(entry_original) > 0)
need_extension = 1;
@@ -1034,6 +1106,12 @@ archive_write_pax_header(struct archive_write *a,
if (!need_extension && sparse_count > 0)
need_extension = 1;
+ acl_types = archive_entry_acl_types(entry_original);
+
+ /* If there are any ACL entries, we need an extension */
+ if (!need_extension && acl_types != 0)
+ need_extension = 1;
+
/*
* Libarchive used to include these in extended headers for
* restricted pax format, but that confused people who
@@ -1085,43 +1163,29 @@ archive_write_pax_header(struct archive_write *a,
add_pax_attr(&(pax->pax_header), "SCHILY.fflags", p);
/* I use star-compatible ACL attributes. */
- r = archive_entry_acl_text_l(entry_original,
- ARCHIVE_ENTRY_ACL_TYPE_ACCESS |
- ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID,
- &p, NULL, pax->sconv_utf8);
- if (r != 0) {
- if (errno == ENOMEM) {
- archive_set_error(&a->archive, ENOMEM,
- "Can't allocate memory for "
- "ACL.access");
+ if ((acl_types & ARCHIVE_ENTRY_ACL_TYPE_NFS4) != 0) {
+ ret = add_pax_acl(a, entry_original, pax,
+ ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID |
+ ARCHIVE_ENTRY_ACL_STYLE_SEPARATOR_COMMA |
+ ARCHIVE_ENTRY_ACL_STYLE_COMPACT);
+ if (ret == ARCHIVE_FATAL)
return (ARCHIVE_FATAL);
- }
- archive_set_error(&a->archive,
- ARCHIVE_ERRNO_FILE_FORMAT,
- "Can't translate ACL.access to UTF-8");
- ret = ARCHIVE_WARN;
- } else if (p != NULL && *p != '\0') {
- add_pax_attr(&(pax->pax_header),
- "SCHILY.acl.access", p);
}
- r = archive_entry_acl_text_l(entry_original,
- ARCHIVE_ENTRY_ACL_TYPE_DEFAULT |
- ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID,
- &p, NULL, pax->sconv_utf8);
- if (r != 0) {
- if (errno == ENOMEM) {
- archive_set_error(&a->archive, ENOMEM,
- "Can't allocate memory for "
- "ACL.default");
+ if (acl_types & ARCHIVE_ENTRY_ACL_TYPE_ACCESS) {
+ ret = add_pax_acl(a, entry_original, pax,
+ ARCHIVE_ENTRY_ACL_TYPE_ACCESS |
+ ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID |
+ ARCHIVE_ENTRY_ACL_STYLE_SEPARATOR_COMMA);
+ if (ret == ARCHIVE_FATAL)
+ return (ARCHIVE_FATAL);
+ }
+ if (acl_types & ARCHIVE_ENTRY_ACL_TYPE_DEFAULT) {
+ ret = add_pax_acl(a, entry_original, pax,
+ ARCHIVE_ENTRY_ACL_TYPE_DEFAULT |
+ ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID |
+ ARCHIVE_ENTRY_ACL_STYLE_SEPARATOR_COMMA);
+ if (ret == ARCHIVE_FATAL)
return (ARCHIVE_FATAL);
- }
- archive_set_error(&a->archive,
- ARCHIVE_ERRNO_FILE_FORMAT,
- "Can't translate ACL.default to UTF-8");
- ret = ARCHIVE_WARN;
- } else if (p != NULL && *p != '\0') {
- add_pax_attr(&(pax->pax_header),
- "SCHILY.acl.default", p);
}
/* We use GNU-tar-compatible sparse attributes. */
diff --git a/contrib/libarchive/libarchive/archive_write_set_format_warc.c b/contrib/libarchive/libarchive/archive_write_set_format_warc.c
index ea66929..8b6daf9 100644
--- a/contrib/libarchive/libarchive/archive_write_set_format_warc.c
+++ b/contrib/libarchive/libarchive/archive_write_set_format_warc.c
@@ -79,7 +79,7 @@ typedef enum {
WT_RVIS,
/* conversion, unsupported */
WT_CONV,
- /* continutation, unsupported at the moment */
+ /* continuation, unsupported at the moment */
WT_CONT,
/* invalid type */
LAST_WT
diff --git a/contrib/libarchive/libarchive/archive_write_set_format_xar.c b/contrib/libarchive/libarchive/archive_write_set_format_xar.c
index da6daac..495f0d4 100644
--- a/contrib/libarchive/libarchive/archive_write_set_format_xar.c
+++ b/contrib/libarchive/libarchive/archive_write_set_format_xar.c
@@ -63,7 +63,7 @@ __FBSDID("$FreeBSD$");
* - When writing an XML element <link type="<file-type>">, <file-type>
* which is a file type a symbolic link is referencing is always marked
* as "broken". Xar utility uses stat(2) to get the file type, but, in
- * libarcive format writer, we should not use it; if it is needed, we
+ * libarchive format writer, we should not use it; if it is needed, we
* should get about it at archive_read_disk.c.
* - It is possible to appear both <flags> and <ext2> elements.
* Xar utility generates <flags> on BSD platform and <ext2> on Linux
@@ -1227,7 +1227,7 @@ make_file_entry(struct archive_write *a, xmlTextWriterPtr writer,
case AE_IFLNK:
/*
* xar utility has checked a file type, which
- * a symblic-link file has referenced.
+ * a symbolic-link file has referenced.
* For example:
* <link type="directory">../ref/</link>
* The symlink target file is "../ref/" and its
@@ -1237,8 +1237,8 @@ make_file_entry(struct archive_write *a, xmlTextWriterPtr writer,
* The symlink target file is "../f" and its
* file type is a regular file.
*
- * But our implemention cannot do it, and then we
- * always record that a attribute "type" is "borken",
+ * But our implementation cannot do it, and then we
+ * always record that a attribute "type" is "broken",
* for example:
* <link type="broken">foo/bar</link>
* It means "foo/bar" is not reachable.
@@ -1544,7 +1544,7 @@ make_toc(struct archive_write *a)
}
/*
- * Start recoding TOC
+ * Start recording TOC
*/
r = xmlTextWriterStartElement(writer, BAD_CAST("xar"));
if (r < 0) {
@@ -1961,6 +1961,7 @@ file_free(struct file *file)
archive_string_free(&(file->basename));
archive_string_free(&(file->symlink));
archive_string_free(&(file->script));
+ archive_entry_free(file->entry);
free(file);
}
@@ -2484,7 +2485,7 @@ file_connect_hardlink_files(struct xar *xar)
archive_entry_set_nlink(target->entry, hl->nlink);
if (hl->nlink > 1)
/* It means this file is a hardlink
- * targe itself. */
+ * target itself. */
target->hardlink_target = target;
for (nf = target->hlnext;
nf != NULL; nf = nf->hlnext) {
@@ -2913,7 +2914,7 @@ compression_init_encoder_xz(struct archive *a,
*strm = lzma_init_data;
#ifdef HAVE_LZMA_STREAM_ENCODER_MT
if (threads > 1) {
- bzero(&mt_options, sizeof(mt_options));
+ memset(&mt_options, 0, sizeof(mt_options));
mt_options.threads = threads;
mt_options.timeout = 300;
mt_options.filters = lzmafilters;
diff --git a/contrib/libarchive/libarchive/archive_write_set_format_zip.c b/contrib/libarchive/libarchive/archive_write_set_format_zip.c
index a69ce20..38a9abf 100644
--- a/contrib/libarchive/libarchive/archive_write_set_format_zip.c
+++ b/contrib/libarchive/libarchive/archive_write_set_format_zip.c
@@ -878,7 +878,7 @@ archive_write_zip_header(struct archive_write *a, struct archive_entry *entry)
|| zip->entry_encryption == ENCRYPTION_WINZIP_AES256)) {
memcpy(e, "\001\231\007\000\001\000AE", 8);
- /* AES vendoer version AE-2 does not store a CRC.
+ /* AES vendor version AE-2 does not store a CRC.
* WinZip 11 uses AE-1, which does store the CRC,
* but it does not store the CRC when the file size
* is less than 20 bytes. So we simulate what
@@ -1013,7 +1013,7 @@ archive_write_zip_data(struct archive_write *a, const void *buff, size_t s)
if (zip->entry_flags & ZIP_ENTRY_FLAG_ENCRYPTED) {
switch (zip->entry_encryption) {
case ENCRYPTION_TRADITIONAL:
- /* Initialize traditoinal PKWARE encryption context. */
+ /* Initialize traditional PKWARE encryption context. */
if (!zip->tctx_valid) {
ret = init_traditional_pkware_encryption(a);
if (ret != ARCHIVE_OK)
@@ -1499,7 +1499,7 @@ trad_enc_update_keys(struct trad_enc_ctx *ctx, uint8_t c)
}
static uint8_t
-trad_enc_decypt_byte(struct trad_enc_ctx *ctx)
+trad_enc_decrypt_byte(struct trad_enc_ctx *ctx)
{
unsigned temp = ctx->keys[2] | 2;
return (uint8_t)((temp * (temp ^ 1)) >> 8) & 0xff;
@@ -1515,7 +1515,7 @@ trad_enc_encrypt_update(struct trad_enc_ctx *ctx, const uint8_t *in,
for (i = 0; i < max; i++) {
uint8_t t = in[i];
- out[i] = t ^ trad_enc_decypt_byte(ctx);
+ out[i] = t ^ trad_enc_decrypt_byte(ctx);
trad_enc_update_keys(ctx, t);
}
return i;
@@ -1626,7 +1626,7 @@ init_winzip_aes_encryption(struct archive_write *a)
return (ARCHIVE_FAILED);
}
- /* Set a passowrd verification value after the 'salt'. */
+ /* Set a password verification value after the 'salt'. */
salt[salt_len] = derived_key[key_len * 2];
salt[salt_len + 1] = derived_key[key_len * 2 + 1];
diff --git a/contrib/libarchive/libarchive/libarchive-formats.5 b/contrib/libarchive/libarchive/libarchive-formats.5
index 9cec760..62359dd 100644
--- a/contrib/libarchive/libarchive/libarchive-formats.5
+++ b/contrib/libarchive/libarchive/libarchive-formats.5
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd March 18, 2012
+.Dd December 27, 2016
.Dt LIBARCHIVE-FORMATS 5
.Os
.Sh NAME
@@ -191,8 +191,6 @@ and device numbers.
.It Solaris extensions
Libarchive recognizes ACL and extended attribute records written
by Solaris tar.
-Currently, libarchive only has support for old-style ACLs; the
-newer NFSv4 ACLs are recognized but discarded.
.El
.Pp
The first tar program appeared in Seventh Edition Unix in 1979.
diff --git a/contrib/libarchive/libarchive/tar.5 b/contrib/libarchive/libarchive/tar.5
index 6e6f0c0..30b837dc 100644
--- a/contrib/libarchive/libarchive/tar.5
+++ b/contrib/libarchive/libarchive/tar.5
@@ -1,4 +1,5 @@
.\" Copyright (c) 2003-2009 Tim Kientzle
+.\" Copyright (c) 2016 Martin Matuska
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
@@ -24,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd December 23, 2011
+.Dd December 27, 2016
.Dt TAR 5
.Os
.Sh NAME
@@ -440,11 +441,11 @@ archives to store files much larger than the historic 8GB limit.
Vendor-specific attributes used by Joerg Schilling's
.Nm star
implementation.
-.It Cm SCHILY.acl.access , Cm SCHILY.acl.default
-Stores the access and default ACLs as textual strings in a format
+.It Cm SCHILY.acl.access , Cm SCHILY.acl.default, Cm SCHILY.acl.ace
+Stores the access, default and NFSv4 ACLs as textual strings in a format
that is an extension of the format specified by POSIX.1e draft 17.
-In particular, each user or group access specification can include a fourth
-colon-separated field with the numeric UID or GID.
+In particular, each user or group access specification can include
+an additional colon-separated field with the numeric UID or GID.
This allows ACLs to be restored on systems that may not have complete
user or group information available (such as when NIS/YP or LDAP services
are temporarily unavailable).
diff --git a/contrib/libarchive/libarchive/test/main.c b/contrib/libarchive/libarchive/test/main.c
index 4f3cdac..d75f1ab 100644
--- a/contrib/libarchive/libarchive/test/main.c
+++ b/contrib/libarchive/libarchive/test/main.c
@@ -216,6 +216,12 @@ invalid_parameter_handler(const wchar_t * expression,
unsigned int line, uintptr_t pReserved)
{
/* nop */
+ // Silence unused-parameter compiler warnings.
+ (void)expression;
+ (void)function;
+ (void)file;
+ (void)line;
+ (void)pReserved;
}
#endif
@@ -1412,6 +1418,8 @@ assertion_file_mode(const char *file, int line, const char *pathname, int expect
failure_start(file, line, "assertFileMode not yet implemented for Windows");
(void)mode; /* UNUSED */
(void)r; /* UNUSED */
+ (void)pathname; /* UNUSED */
+ (void)expected_mode; /* UNUSED */
#else
{
struct stat st;
@@ -2421,6 +2429,132 @@ extract_reference_files(const char **names)
extract_reference_file(*names++);
}
+/* Set ACLs */
+void
+archive_test_set_acls(struct archive_entry *ae,
+ struct archive_test_acl_t *acls, int n)
+{
+ int i;
+
+ archive_entry_acl_clear(ae);
+ for (i = 0; i < n; i++) {
+ failure("type=%#010x, permset=%#010x, tag=%d, qual=%d name=%s",
+ acls[i].type, acls[i].permset, acls[i].tag,
+ acls[i].qual, acls[i].name);
+ assertEqualInt(ARCHIVE_OK,
+ archive_entry_acl_add_entry(ae,
+ acls[i].type, acls[i].permset, acls[i].tag,
+ acls[i].qual, acls[i].name));
+ }
+}
+
+static int
+archive_test_acl_match(struct archive_test_acl_t *acl, int type, int permset,
+ int tag, int qual, const char *name)
+{
+ if (type != acl->type)
+ return (0);
+ if (permset != acl->permset)
+ return (0);
+ if (tag != acl->tag)
+ return (0);
+ if (tag == ARCHIVE_ENTRY_ACL_USER_OBJ)
+ return (1);
+ if (tag == ARCHIVE_ENTRY_ACL_GROUP_OBJ)
+ return (1);
+ if (tag == ARCHIVE_ENTRY_ACL_EVERYONE)
+ return (1);
+ if (tag == ARCHIVE_ENTRY_ACL_OTHER)
+ return (1);
+ if (qual != acl->qual)
+ return (0);
+ if (name == NULL) {
+ if (acl->name == NULL || acl->name[0] == '\0')
+ return (1);
+ return (0);
+ }
+ if (acl->name == NULL) {
+ if (name[0] == '\0')
+ return (1);
+ return (0);
+ }
+ return (0 == strcmp(name, acl->name));
+}
+
+/* Compare ACLs */
+void
+archive_test_compare_acls(struct archive_entry *ae,
+ struct archive_test_acl_t *acls, int cnt, int want_type, int mode)
+{
+ int *marker;
+ int i, r, n;
+ int type, permset, tag, qual;
+ int matched;
+ const char *name;
+
+ n = 0;
+ marker = malloc(sizeof(marker[0]) * cnt);
+
+ for (i = 0; i < cnt; i++) {
+ if ((acls[i].type & want_type) != 0) {
+ marker[n] = i;
+ n++;
+ }
+ }
+
+ failure("No ACL's to compare, type mask: %d", want_type);
+ assert(n > 0);
+ if (n == 0)
+ return;
+
+ while (0 == (r = archive_entry_acl_next(ae, want_type,
+ &type, &permset, &tag, &qual, &name))) {
+ for (i = 0, matched = 0; i < n && !matched; i++) {
+ if (archive_test_acl_match(&acls[marker[i]], type,
+ permset, tag, qual, name)) {
+ /* We found a match; remove it. */
+ marker[i] = marker[n - 1];
+ n--;
+ matched = 1;
+ }
+ }
+ if (type == ARCHIVE_ENTRY_ACL_TYPE_ACCESS
+ && tag == ARCHIVE_ENTRY_ACL_USER_OBJ) {
+ if (!matched) printf("No match for user_obj perm\n");
+ failure("USER_OBJ permset (%02o) != user mode (%02o)",
+ permset, 07 & (mode >> 6));
+ assert((permset << 6) == (mode & 0700));
+ } else if (type == ARCHIVE_ENTRY_ACL_TYPE_ACCESS
+ && tag == ARCHIVE_ENTRY_ACL_GROUP_OBJ) {
+ if (!matched) printf("No match for group_obj perm\n");
+ failure("GROUP_OBJ permset %02o != group mode %02o",
+ permset, 07 & (mode >> 3));
+ assert((permset << 3) == (mode & 0070));
+ } else if (type == ARCHIVE_ENTRY_ACL_TYPE_ACCESS
+ && tag == ARCHIVE_ENTRY_ACL_OTHER) {
+ if (!matched) printf("No match for other perm\n");
+ failure("OTHER permset (%02o) != other mode (%02o)",
+ permset, mode & 07);
+ assert((permset << 0) == (mode & 0007));
+ } else {
+ failure("Could not find match for ACL "
+ "(type=%#010x,permset=%#010x,tag=%d,qual=%d,"
+ "name=``%s'')", type, permset, tag, qual, name);
+ assert(matched == 1);
+ }
+ }
+ assertEqualInt(ARCHIVE_EOF, r);
+ if ((want_type & ARCHIVE_ENTRY_ACL_TYPE_ACCESS) != 0)
+ assert((mode_t)(mode & 0777) == (archive_entry_mode(ae)
+ & 0777));
+ failure("Could not find match for ACL "
+ "(type=%#010x,permset=%#010x,tag=%d,qual=%d,name=``%s'')",
+ acls[marker[0]].type, acls[marker[0]].permset,
+ acls[marker[0]].tag, acls[marker[0]].qual, acls[marker[0]].name);
+ assert(n == 0); /* Number of ACLs not matched should == 0 */
+ free(marker);
+}
+
/*
*
* TEST management
diff --git a/contrib/libarchive/libarchive/test/test.h b/contrib/libarchive/libarchive/test/test.h
index f7ec59f..dc3f590 100644
--- a/contrib/libarchive/libarchive/test/test.h
+++ b/contrib/libarchive/libarchive/test/test.h
@@ -121,6 +121,32 @@
#endif
/*
+ * If this platform has <sys/acl.h>, acl_create(), acl_init(),
+ * acl_set_file(), and ACL_USER, we assume it has the rest of the
+ * POSIX.1e draft functions used in archive_read_extract.c.
+ */
+#if HAVE_SYS_ACL_H && HAVE_ACL_CREATE_ENTRY && HAVE_ACL_INIT && HAVE_ACL_SET_FILE
+#if HAVE_ACL_USER
+#define HAVE_POSIX_ACL 1
+#elif HAVE_ACL_TYPE_EXTENDED
+#define HAVE_DARWIN_ACL 1
+#endif
+#endif
+
+/*
+ * If this platform has <sys/acl.h>, acl_get(), facl_get(), acl_set(),
+ * facl_set() and types aclent_t and ace_t it uses Solaris-style ACL functions
+ */
+#if HAVE_SYS_ACL_H && HAVE_ACL_GET && HAVE_FACL_GET && HAVE_ACL_SET && HAVE_FACL_SET && HAVE_ACLENT_T && HAVE_ACE_T
+#define HAVE_SUN_ACL 1
+#endif
+
+/* Define if platform supports NFSv4 ACLs */
+#if (HAVE_POSIX_ACL && HAVE_ACL_TYPE_NFS4) || HAVE_SUN_ACL || HAVE_DARWIN_ACL
+#define HAVE_NFS4_ACL 1
+#endif
+
+/*
* Redefine DEFINE_TEST for use in defining the test functions.
*/
#undef DEFINE_TEST
@@ -346,6 +372,23 @@ extern const char *testworkdir;
#include "archive.h"
#include "archive_entry.h"
+/* ACL structure */
+struct archive_test_acl_t {
+ int type; /* Type of ACL */
+ int permset; /* Permissions for this class of users. */
+ int tag; /* Owner, User, Owning group, group, other, etc. */
+ int qual; /* GID or UID of user/group, depending on tag. */
+ const char *name; /* Name of user/group, depending on tag. */
+};
+
+/* Set ACLs */
+void archive_test_set_acls(struct archive_entry *, struct archive_test_acl_t *,
+ int);
+
+/* Compare ACLs */
+void archive_test_compare_acls(struct archive_entry *,
+ struct archive_test_acl_t *, int, int, int);
+
/* Special customized read-from-memory interface. */
int read_open_memory(struct archive *, const void *, size_t, size_t);
/* _minimal version exercises a slightly different set of libarchive APIs. */
diff --git a/contrib/libarchive/libarchive/test/test_acl_nfs4.c b/contrib/libarchive/libarchive/test/test_acl_nfs4.c
index c8f5937..f4e66f5 100644
--- a/contrib/libarchive/libarchive/test/test_acl_nfs4.c
+++ b/contrib/libarchive/libarchive/test/test_acl_nfs4.c
@@ -33,15 +33,7 @@ __FBSDID("$FreeBSD$");
* filesystems support ACLs or not.
*/
-struct acl_t {
- int type; /* Type of entry: "allow" or "deny" */
- int permset; /* Permissions for this class of users. */
- int tag; /* Owner, User, Owning group, group, everyone, etc. */
- int qual; /* GID or UID of user/group, depending on tag. */
- const char *name; /* Name of user/group, depending on tag. */
-};
-
-static struct acl_t acls1[] = {
+static struct archive_test_acl_t acls1[] = {
{ ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_EXECUTE,
ARCHIVE_ENTRY_ACL_USER_OBJ, -1, "" },
{ ARCHIVE_ENTRY_ACL_TYPE_DENY, ARCHIVE_ENTRY_ACL_READ_DATA,
@@ -52,7 +44,7 @@ static struct acl_t acls1[] = {
ARCHIVE_ENTRY_ACL_EVERYONE, -1, "" },
};
-static struct acl_t acls2[] = {
+static struct archive_test_acl_t acls2[] = {
/* An entry for each type. */
{ ARCHIVE_ENTRY_ACL_TYPE_ALLOW, 0,
ARCHIVE_ENTRY_ACL_USER, 108, "user108" },
@@ -136,7 +128,7 @@ static struct acl_t acls2[] = {
* Entries that should be rejected when we attempt to set them
* on an ACL that already has NFS4 entries.
*/
-static struct acl_t acls_bad[] = {
+static struct archive_test_acl_t acls_bad[] = {
/* POSIX.1e ACL types */
{ ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_EXECUTE,
ARCHIVE_ENTRY_ACL_USER, 78, "" },
@@ -156,95 +148,6 @@ static struct acl_t acls_bad[] = {
ARCHIVE_ENTRY_ACL_EVERYONE, -1, "" },
};
-static void
-set_acls(struct archive_entry *ae, struct acl_t *acls, int n)
-{
- int i;
-
- archive_entry_acl_clear(ae);
- for (i = 0; i < n; i++) {
- failure("type=%d, permset=%d, tag=%d, qual=%d name=%s",
- acls[i].type, acls[i].permset, acls[i].tag,
- acls[i].qual, acls[i].name);
- assertEqualInt(ARCHIVE_OK,
- archive_entry_acl_add_entry(ae,
- acls[i].type, acls[i].permset, acls[i].tag,
- acls[i].qual, acls[i].name));
- }
-}
-
-static int
-acl_match(struct acl_t *acl, int type, int permset, int tag, int qual,
- const char *name)
-{
- if (acl == NULL)
- return (0);
- if (type != acl->type)
- return (0);
- if (permset != acl->permset)
- return (0);
- if (tag != acl->tag)
- return (0);
- if (tag == ARCHIVE_ENTRY_ACL_USER_OBJ)
- return (1);
- if (tag == ARCHIVE_ENTRY_ACL_GROUP_OBJ)
- return (1);
- if (tag == ARCHIVE_ENTRY_ACL_EVERYONE)
- return (1);
- if (qual != acl->qual)
- return (0);
- if (name == NULL) {
- if (acl->name == NULL || acl->name[0] == '\0')
- return (1);
- return (0);
- }
- if (acl->name == NULL) {
- if (name[0] == '\0')
- return (1);
- return (0);
- }
- return (0 == strcmp(name, acl->name));
-}
-
-static void
-compare_acls(struct archive_entry *ae, struct acl_t *acls, int n)
-{
- int *marker = malloc(sizeof(marker[0]) * n);
- int i;
- int r;
- int type, permset, tag, qual;
- int matched;
- const char *name;
-
- for (i = 0; i < n; i++)
- marker[i] = i;
-
- while (0 == (r = archive_entry_acl_next(ae,
- ARCHIVE_ENTRY_ACL_TYPE_NFS4,
- &type, &permset, &tag, &qual, &name))) {
- for (i = 0, matched = 0; i < n && !matched; i++) {
- if (acl_match(&acls[marker[i]], type, permset,
- tag, qual, name)) {
- /* We found a match; remove it. */
- marker[i] = marker[n - 1];
- n--;
- matched = 1;
- }
- }
- failure("Could not find match for ACL "
- "(type=%d,permset=%d,tag=%d,qual=%d,name=``%s'')",
- type, permset, tag, qual, name);
- assertEqualInt(1, matched);
- }
- assertEqualInt(ARCHIVE_EOF, r);
- failure("Could not find match for ACL "
- "(type=%d,permset=%d,tag=%d,qual=%d,name=``%s'')",
- acls[marker[0]].type, acls[marker[0]].permset,
- acls[marker[0]].tag, acls[marker[0]].qual, acls[marker[0]].name);
- assertEqualInt(0, n); /* Number of ACLs not matched should == 0 */
- free(marker);
-}
-
DEFINE_TEST(test_acl_nfs4)
{
struct archive_entry *ae;
@@ -256,22 +159,31 @@ DEFINE_TEST(test_acl_nfs4)
archive_entry_set_mode(ae, S_IFREG | 0777);
/* Store and read back some basic ACL entries. */
- set_acls(ae, acls1, sizeof(acls1)/sizeof(acls1[0]));
+ archive_test_set_acls(ae, acls1, sizeof(acls1)/sizeof(acls1[0]));
+
+ /* Check that entry contains only NFSv4 types */
+ assert((archive_entry_acl_types(ae) &
+ ARCHIVE_ENTRY_ACL_TYPE_POSIX1E) == 0);
+ assert((archive_entry_acl_types(ae) &
+ ARCHIVE_ENTRY_ACL_TYPE_NFS4) != 0);
+
assertEqualInt(4,
archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_NFS4));
- compare_acls(ae, acls1, sizeof(acls1)/sizeof(acls1[0]));
+ archive_test_compare_acls(ae, acls1, sizeof(acls1)/sizeof(acls1[0]),
+ ARCHIVE_ENTRY_ACL_TYPE_NFS4, 0);
/* A more extensive set of ACLs. */
- set_acls(ae, acls2, sizeof(acls2)/sizeof(acls2[0]));
+ archive_test_set_acls(ae, acls2, sizeof(acls2)/sizeof(acls2[0]));
assertEqualInt(32,
archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_NFS4));
- compare_acls(ae, acls2, sizeof(acls2)/sizeof(acls2[0]));
+ archive_test_compare_acls(ae, acls2, sizeof(acls2)/sizeof(acls2[0]),
+ ARCHIVE_ENTRY_ACL_TYPE_NFS4, 0);
/*
* Check that clearing ACLs gets rid of them all by repeating
* the first test.
*/
- set_acls(ae, acls1, sizeof(acls1)/sizeof(acls1[0]));
+ archive_test_set_acls(ae, acls1, sizeof(acls1)/sizeof(acls1[0]));
failure("Basic ACLs shouldn't be stored as extended ACLs");
assertEqualInt(4,
archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_NFS4));
@@ -280,9 +192,9 @@ DEFINE_TEST(test_acl_nfs4)
* Different types of malformed ACL entries that should
* fail when added to existing NFS4 ACLs.
*/
- set_acls(ae, acls2, sizeof(acls2)/sizeof(acls2[0]));
+ archive_test_set_acls(ae, acls2, sizeof(acls2)/sizeof(acls2[0]));
for (i = 0; i < (int)(sizeof(acls_bad)/sizeof(acls_bad[0])); ++i) {
- struct acl_t *p = &acls_bad[i];
+ struct archive_test_acl_t *p = &acls_bad[i];
failure("Malformed ACL test #%d", i);
assertEqualInt(ARCHIVE_FAILED,
archive_entry_acl_add_entry(ae,
diff --git a/contrib/libarchive/libarchive/test/test_acl_pax.c b/contrib/libarchive/libarchive/test/test_acl_pax.c
index 5fcf61b..8dfa0e0 100644
--- a/contrib/libarchive/libarchive/test/test_acl_pax.c
+++ b/contrib/libarchive/libarchive/test/test_acl_pax.c
@@ -1,5 +1,6 @@
/*-
* Copyright (c) 2003-2007 Tim Kientzle
+ * Copyright (c) 2016 Martin Matuska
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -27,7 +28,7 @@ __FBSDID("$FreeBSD$");
/*
* Exercise the system-independent portion of the ACL support.
- * Check that pax archive can save and restore ACL data.
+ * Check that pax archive can save and restore POSIX.1e ACL data.
*
* This should work on all systems, regardless of whether local
* filesystems support ACLs or not.
@@ -35,15 +36,7 @@ __FBSDID("$FreeBSD$");
static unsigned char buff[16384];
-struct acl_t {
- int type; /* Type of ACL: "access" or "default" */
- int permset; /* Permissions for this class of users. */
- int tag; /* Owner, User, Owning group, group, other, etc. */
- int qual; /* GID or UID of user/group, depending on tag. */
- const char *name; /* Name of user/group, depending on tag. */
-};
-
-static struct acl_t acls0[] = {
+static struct archive_test_acl_t acls0[] = {
{ ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_EXECUTE,
ARCHIVE_ENTRY_ACL_USER_OBJ, 0, "" },
{ ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ,
@@ -52,7 +45,7 @@ static struct acl_t acls0[] = {
ARCHIVE_ENTRY_ACL_OTHER, 0, "" },
};
-static struct acl_t acls1[] = {
+static struct archive_test_acl_t acls1[] = {
{ ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_EXECUTE,
ARCHIVE_ENTRY_ACL_USER_OBJ, -1, "" },
{ ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ,
@@ -63,7 +56,7 @@ static struct acl_t acls1[] = {
ARCHIVE_ENTRY_ACL_OTHER, -1, "" },
};
-static struct acl_t acls2[] = {
+static struct archive_test_acl_t acls2[] = {
{ ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_EXECUTE | ARCHIVE_ENTRY_ACL_READ,
ARCHIVE_ENTRY_ACL_USER_OBJ, -1, "" },
{ ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ,
@@ -78,101 +71,149 @@ static struct acl_t acls2[] = {
ARCHIVE_ENTRY_ACL_OTHER, -1, "" },
};
-static void
-set_acls(struct archive_entry *ae, struct acl_t *acls, int n)
-{
- int i;
-
- archive_entry_acl_clear(ae);
- for (i = 0; i < n; i++) {
- archive_entry_acl_add_entry(ae,
- acls[i].type, acls[i].permset, acls[i].tag, acls[i].qual,
- acls[i].name);
- }
-}
+static struct archive_test_acl_t acls3[] = {
+ { ARCHIVE_ENTRY_ACL_TYPE_ALLOW,
+ ARCHIVE_ENTRY_ACL_READ_DATA |
+ ARCHIVE_ENTRY_ACL_WRITE_DATA |
+ ARCHIVE_ENTRY_ACL_EXECUTE |
+ ARCHIVE_ENTRY_ACL_APPEND_DATA |
+ ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES |
+ ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES |
+ ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS |
+ ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS |
+ ARCHIVE_ENTRY_ACL_READ_ACL |
+ ARCHIVE_ENTRY_ACL_WRITE_ACL |
+ ARCHIVE_ENTRY_ACL_WRITE_OWNER |
+ ARCHIVE_ENTRY_ACL_SYNCHRONIZE,
+ ARCHIVE_ENTRY_ACL_USER_OBJ, 0, "" },
+ { ARCHIVE_ENTRY_ACL_TYPE_ALLOW,
+ ARCHIVE_ENTRY_ACL_READ_DATA |
+ ARCHIVE_ENTRY_ACL_WRITE_DATA |
+ ARCHIVE_ENTRY_ACL_APPEND_DATA |
+ ARCHIVE_ENTRY_ACL_READ_ACL |
+ ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES |
+ ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS |
+ ARCHIVE_ENTRY_ACL_READ_ACL |
+ ARCHIVE_ENTRY_ACL_SYNCHRONIZE,
+ ARCHIVE_ENTRY_ACL_GROUP_OBJ, 0, "" },
+ { ARCHIVE_ENTRY_ACL_TYPE_ALLOW,
+ ARCHIVE_ENTRY_ACL_READ_DATA |
+ ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES |
+ ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS |
+ ARCHIVE_ENTRY_ACL_READ_ACL |
+ ARCHIVE_ENTRY_ACL_SYNCHRONIZE,
+ ARCHIVE_ENTRY_ACL_EVERYONE, 0, "" },
+};
-static int
-acl_match(struct acl_t *acl, int type, int permset, int tag, int qual, const char *name)
-{
- if (type != acl->type)
- return (0);
- if (permset != acl->permset)
- return (0);
- if (tag != acl->tag)
- return (0);
- if (tag == ARCHIVE_ENTRY_ACL_USER_OBJ)
- return (1);
- if (tag == ARCHIVE_ENTRY_ACL_GROUP_OBJ)
- return (1);
- if (tag == ARCHIVE_ENTRY_ACL_OTHER)
- return (1);
- if (qual != acl->qual)
- return (0);
- if (name == NULL)
- return (acl->name == NULL || acl->name[0] == '\0');
- if (acl->name == NULL)
- return (name == NULL || name[0] == '\0');
- return (0 == strcmp(name, acl->name));
-}
+static struct archive_test_acl_t acls4[] = {
+ { ARCHIVE_ENTRY_ACL_TYPE_ALLOW,
+ ARCHIVE_ENTRY_ACL_READ_DATA |
+ ARCHIVE_ENTRY_ACL_WRITE_DATA |
+ ARCHIVE_ENTRY_ACL_APPEND_DATA |
+ ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES |
+ ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES |
+ ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS |
+ ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS |
+ ARCHIVE_ENTRY_ACL_READ_ACL |
+ ARCHIVE_ENTRY_ACL_WRITE_ACL |
+ ARCHIVE_ENTRY_ACL_WRITE_OWNER |
+ ARCHIVE_ENTRY_ACL_SYNCHRONIZE,
+ ARCHIVE_ENTRY_ACL_USER_OBJ, 0, "" },
+ { ARCHIVE_ENTRY_ACL_TYPE_ALLOW,
+ ARCHIVE_ENTRY_ACL_READ_DATA |
+ ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES |
+ ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS |
+ ARCHIVE_ENTRY_ACL_READ_ACL |
+ ARCHIVE_ENTRY_ACL_SYNCHRONIZE |
+ ARCHIVE_ENTRY_ACL_ENTRY_INHERITED,
+ ARCHIVE_ENTRY_ACL_USER, 77, "user77" },
+ { ARCHIVE_ENTRY_ACL_TYPE_DENY,
+ ARCHIVE_ENTRY_ACL_READ_DATA |
+ ARCHIVE_ENTRY_ACL_WRITE_DATA |
+ ARCHIVE_ENTRY_ACL_EXECUTE,
+ ARCHIVE_ENTRY_ACL_USER, 78, "user78" },
+ { ARCHIVE_ENTRY_ACL_TYPE_ALLOW,
+ ARCHIVE_ENTRY_ACL_READ_DATA |
+ ARCHIVE_ENTRY_ACL_WRITE_DATA |
+ ARCHIVE_ENTRY_ACL_APPEND_DATA |
+ ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES |
+ ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS |
+ ARCHIVE_ENTRY_ACL_READ_ACL |
+ ARCHIVE_ENTRY_ACL_SYNCHRONIZE,
+ ARCHIVE_ENTRY_ACL_GROUP_OBJ, 0, "" },
+ { ARCHIVE_ENTRY_ACL_TYPE_DENY,
+ ARCHIVE_ENTRY_ACL_WRITE_DATA |
+ ARCHIVE_ENTRY_ACL_APPEND_DATA |
+ ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES |
+ ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS |
+ ARCHIVE_ENTRY_ACL_WRITE_ACL |
+ ARCHIVE_ENTRY_ACL_WRITE_OWNER,
+ ARCHIVE_ENTRY_ACL_GROUP, 78, "group78" },
+ { ARCHIVE_ENTRY_ACL_TYPE_ALLOW,
+ ARCHIVE_ENTRY_ACL_READ_DATA |
+ ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES |
+ ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS |
+ ARCHIVE_ENTRY_ACL_READ_ACL |
+ ARCHIVE_ENTRY_ACL_SYNCHRONIZE,
+ ARCHIVE_ENTRY_ACL_EVERYONE, 0, "" },
+};
-static void
-compare_acls(struct archive_entry *ae, struct acl_t *acls, int n, int mode)
-{
- int *marker = malloc(sizeof(marker[0]) * n);
- int i;
- int r;
- int type, permset, tag, qual;
- int matched;
- const char *name;
-
- for (i = 0; i < n; i++)
- marker[i] = i;
-
- while (0 == (r = archive_entry_acl_next(ae,
- ARCHIVE_ENTRY_ACL_TYPE_ACCESS,
- &type, &permset, &tag, &qual, &name))) {
- for (i = 0, matched = 0; i < n && !matched; i++) {
- if (acl_match(&acls[marker[i]], type, permset,
- tag, qual, name)) {
- /* We found a match; remove it. */
- marker[i] = marker[n - 1];
- n--;
- matched = 1;
- }
- }
- if (tag == ARCHIVE_ENTRY_ACL_USER_OBJ) {
- if (!matched) printf("No match for user_obj perm\n");
- failure("USER_OBJ permset (%02o) != user mode (%02o)",
- permset, 07 & (mode >> 6));
- assert((permset << 6) == (mode & 0700));
- } else if (tag == ARCHIVE_ENTRY_ACL_GROUP_OBJ) {
- if (!matched) printf("No match for group_obj perm\n");
- failure("GROUP_OBJ permset %02o != group mode %02o",
- permset, 07 & (mode >> 3));
- assert((permset << 3) == (mode & 0070));
- } else if (tag == ARCHIVE_ENTRY_ACL_OTHER) {
- if (!matched) printf("No match for other perm\n");
- failure("OTHER permset (%02o) != other mode (%02o)",
- permset, mode & 07);
- assert((permset << 0) == (mode & 0007));
- } else {
- failure("Could not find match for ACL "
- "(type=%d,permset=%d,tag=%d,qual=%d,name=``%s'')",
- type, permset, tag, qual, name);
- assert(matched == 1);
- }
- }
- assertEqualInt(ARCHIVE_EOF, r);
- assert((mode_t)(mode & 0777) == (archive_entry_mode(ae) & 0777));
- failure("Could not find match for ACL "
- "(type=%d,permset=%d,tag=%d,qual=%d,name=``%s'')",
- acls[marker[0]].type, acls[marker[0]].permset,
- acls[marker[0]].tag, acls[marker[0]].qual, acls[marker[0]].name);
- assert(n == 0); /* Number of ACLs not matched should == 0 */
- free(marker);
-}
+static struct archive_test_acl_t acls5[] = {
+ { ARCHIVE_ENTRY_ACL_TYPE_ALLOW,
+ ARCHIVE_ENTRY_ACL_READ_DATA |
+ ARCHIVE_ENTRY_ACL_WRITE_DATA |
+ ARCHIVE_ENTRY_ACL_EXECUTE |
+ ARCHIVE_ENTRY_ACL_APPEND_DATA |
+ ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES |
+ ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES |
+ ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS |
+ ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS |
+ ARCHIVE_ENTRY_ACL_READ_ACL |
+ ARCHIVE_ENTRY_ACL_WRITE_ACL |
+ ARCHIVE_ENTRY_ACL_WRITE_OWNER |
+ ARCHIVE_ENTRY_ACL_SYNCHRONIZE,
+ ARCHIVE_ENTRY_ACL_USER_OBJ, 0, "" },
+ { ARCHIVE_ENTRY_ACL_TYPE_ALLOW,
+ ARCHIVE_ENTRY_ACL_READ_DATA |
+ ARCHIVE_ENTRY_ACL_WRITE_DATA |
+ ARCHIVE_ENTRY_ACL_APPEND_DATA |
+ ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES |
+ ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS |
+ ARCHIVE_ENTRY_ACL_READ_ACL |
+ ARCHIVE_ENTRY_ACL_WRITE_OWNER |
+ ARCHIVE_ENTRY_ACL_SYNCHRONIZE,
+ ARCHIVE_ENTRY_ACL_USER, 77, "user77" },
+ { ARCHIVE_ENTRY_ACL_TYPE_AUDIT,
+ ARCHIVE_ENTRY_ACL_WRITE_DATA |
+ ARCHIVE_ENTRY_ACL_APPEND_DATA |
+ ARCHIVE_ENTRY_ACL_ENTRY_SUCCESSFUL_ACCESS,
+ ARCHIVE_ENTRY_ACL_USER, 77, "user77" },
+ { ARCHIVE_ENTRY_ACL_TYPE_ALLOW,
+ ARCHIVE_ENTRY_ACL_READ_DATA |
+ ARCHIVE_ENTRY_ACL_WRITE_DATA |
+ ARCHIVE_ENTRY_ACL_APPEND_DATA |
+ ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES |
+ ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS |
+ ARCHIVE_ENTRY_ACL_READ_ACL |
+ ARCHIVE_ENTRY_ACL_SYNCHRONIZE,
+ ARCHIVE_ENTRY_ACL_GROUP_OBJ, 0, "" },
+ { ARCHIVE_ENTRY_ACL_TYPE_ALARM,
+ ARCHIVE_ENTRY_ACL_READ_DATA |
+ ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES |
+ ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS |
+ ARCHIVE_ENTRY_ACL_READ_ACL |
+ ARCHIVE_ENTRY_ACL_ENTRY_FAILED_ACCESS,
+ ARCHIVE_ENTRY_ACL_GROUP, 78, "group78" },
+ { ARCHIVE_ENTRY_ACL_TYPE_ALLOW,
+ ARCHIVE_ENTRY_ACL_READ_DATA |
+ ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES |
+ ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS |
+ ARCHIVE_ENTRY_ACL_READ_ACL |
+ ARCHIVE_ENTRY_ACL_SYNCHRONIZE,
+ ARCHIVE_ENTRY_ACL_EVERYONE, 0, "" },
+};
-DEFINE_TEST(test_acl_pax)
+DEFINE_TEST(test_acl_pax_posix1e)
{
struct archive *a;
struct archive_entry *ae;
@@ -197,23 +238,23 @@ DEFINE_TEST(test_acl_pax)
archive_entry_set_mode(ae, S_IFREG | 0777);
/* Basic owner/owning group should just update mode bits. */
- set_acls(ae, acls0, sizeof(acls0)/sizeof(acls0[0]));
+ archive_test_set_acls(ae, acls0, sizeof(acls0)/sizeof(acls0[0]));
assertA(0 == archive_write_header(a, ae));
/* With any extended ACL entry, we should read back a full set. */
- set_acls(ae, acls1, sizeof(acls1)/sizeof(acls1[0]));
+ archive_test_set_acls(ae, acls1, sizeof(acls1)/sizeof(acls1[0]));
assertA(0 == archive_write_header(a, ae));
/* A more extensive set of ACLs. */
- set_acls(ae, acls2, sizeof(acls2)/sizeof(acls2[0]));
+ archive_test_set_acls(ae, acls2, sizeof(acls2)/sizeof(acls2[0]));
assertA(0 == archive_write_header(a, ae));
/*
* Check that clearing ACLs gets rid of them all by repeating
* the first test.
*/
- set_acls(ae, acls0, sizeof(acls0)/sizeof(acls0[0]));
+ archive_test_set_acls(ae, acls0, sizeof(acls0)/sizeof(acls0[0]));
assertA(0 == archive_write_header(a, ae));
archive_entry_free(ae);
@@ -227,13 +268,13 @@ DEFINE_TEST(test_acl_pax)
fclose(f);
/* Write out the reference data to a file for manual inspection. */
- extract_reference_file("test_acl_pax.tar");
- reference = slurpfile(&reference_size, "test_acl_pax.tar");
+ extract_reference_file("test_acl_pax_posix1e.tar");
+ reference = slurpfile(&reference_size, "test_acl_pax_posix1e.tar");
/* Assert that the generated data matches the built-in reference data.*/
- failure("Generated pax archive does not match reference; compare 'testout' to 'test_acl_pax.tar' reference file.");
+ failure("Generated pax archive does not match reference; compare 'testout' to 'test_acl_pax_posix1e.tar' reference file.");
assertEqualMem(buff, reference, reference_size);
- failure("Generated pax archive does not match reference; compare 'testout' to 'test_acl_pax.tar' reference file.");
+ failure("Generated pax archive does not match reference; compare 'testout' to 'test_acl_pax_posix1e.tar' reference file.");
assertEqualInt((int)used, reference_size);
free(reference);
@@ -255,15 +296,18 @@ DEFINE_TEST(test_acl_pax)
assertA(0 == archive_read_next_header(a, &ae));
failure("One extended ACL should flag all ACLs to be returned.");
assert(4 == archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS));
- compare_acls(ae, acls1, sizeof(acls1)/sizeof(acls1[0]), 0142);
+ archive_test_compare_acls(ae, acls1, sizeof(acls1)/sizeof(acls1[0]),
+ ARCHIVE_ENTRY_ACL_TYPE_ACCESS, 0142);
failure("Basic ACLs should set mode to 0142, not %04o",
archive_entry_mode(ae)&0777);
assert((archive_entry_mode(ae) & 0777) == 0142);
/* Third item has pretty extensive ACLs */
assertA(0 == archive_read_next_header(a, &ae));
- assertEqualInt(6, archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS));
- compare_acls(ae, acls2, sizeof(acls2)/sizeof(acls2[0]), 0543);
+ assertEqualInt(6, archive_entry_acl_reset(ae,
+ ARCHIVE_ENTRY_ACL_TYPE_ACCESS));
+ archive_test_compare_acls(ae, acls2, sizeof(acls2)/sizeof(acls2[0]),
+ ARCHIVE_ENTRY_ACL_TYPE_ACCESS, 0543);
failure("Basic ACLs should set mode to 0543, not %04o",
archive_entry_mode(ae)&0777);
assert((archive_entry_mode(ae) & 0777) == 0543);
@@ -280,3 +324,93 @@ DEFINE_TEST(test_acl_pax)
assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
assertEqualInt(ARCHIVE_OK, archive_read_free(a));
}
+
+DEFINE_TEST(test_acl_pax_nfs4)
+{
+ struct archive *a;
+ struct archive_entry *ae;
+ size_t used;
+ FILE *f;
+ void *reference;
+ size_t reference_size;
+
+ /* Write an archive to memory. */
+ assert(NULL != (a = archive_write_new()));
+ assertA(0 == archive_write_set_format_pax(a));
+ assertA(0 == archive_write_add_filter_none(a));
+ assertA(0 == archive_write_set_bytes_per_block(a, 1));
+ assertA(0 == archive_write_set_bytes_in_last_block(a, 1));
+ assertA(0 == archive_write_open_memory(a, buff, sizeof(buff), &used));
+
+ /* Write a series of files to the archive with different ACL info. */
+
+ /* Create a simple archive_entry. */
+ assert((ae = archive_entry_new()) != NULL);
+ archive_entry_set_pathname(ae, "file");
+ archive_entry_set_mode(ae, S_IFREG | 0777);
+
+ /* NFS4 ACLs mirroring 0754 file mode */
+ archive_test_set_acls(ae, acls3, sizeof(acls3)/sizeof(acls3[0]));
+ assertA(0 == archive_write_header(a, ae));
+
+ /* A more extensive set of NFS4 ACLs. */
+ archive_test_set_acls(ae, acls4, sizeof(acls4)/sizeof(acls4[0]));
+ assertA(0 == archive_write_header(a, ae));
+
+ /* Set with special (audit, alarm) NFS4 ACLs. */
+ archive_test_set_acls(ae, acls5, sizeof(acls5)/sizeof(acls5[0]));
+ assertA(0 == archive_write_header(a, ae));
+
+ archive_entry_free(ae);
+
+ /* Close out the archive. */
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
+ assertEqualInt(ARCHIVE_OK, archive_write_free(a));
+
+ /* Write out the data we generated to a file for manual inspection. */
+ assert(NULL != (f = fopen("testout", "wb")));
+ assertEqualInt(used, (size_t)fwrite(buff, 1, (unsigned int)used, f));
+ fclose(f);
+
+ /* Write out the reference data to a file for manual inspection. */
+ extract_reference_file("test_acl_pax_nfs4.tar");
+ reference = slurpfile(&reference_size, "test_acl_pax_nfs4.tar");
+
+ /* Assert that the generated data matches the built-in reference data.*/
+ failure("Generated pax archive does not match reference; compare 'testout' to 'test_acl_pax_nfs4.tar' reference file.");
+ assertEqualMem(buff, reference, reference_size);
+ failure("Generated pax archive does not match reference; compare 'testout' to 'test_acl_pax_nfs4.tar' reference file.");
+ assertEqualInt((int)used, reference_size);
+ free(reference);
+
+ /* Read back each entry and check that the ACL data is right. */
+ assert(NULL != (a = archive_read_new()));
+ assertA(0 == archive_read_support_format_all(a));
+ assertA(0 == archive_read_support_filter_all(a));
+ assertA(0 == archive_read_open_memory(a, buff, used));
+
+ /* First item has NFS4 ACLs mirroring file mode */
+ assertA(0 == archive_read_next_header(a, &ae));
+ assertEqualInt(3, archive_entry_acl_reset(ae,
+ ARCHIVE_ENTRY_ACL_TYPE_ALLOW));
+ archive_test_compare_acls(ae, acls3, sizeof(acls3)/sizeof(acls3[0]),
+ ARCHIVE_ENTRY_ACL_TYPE_ALLOW, 0);
+
+ /* Second item has has more fine-grained NFS4 ACLs */
+ assertA(0 == archive_read_next_header(a, &ae));
+ assertEqualInt(6, archive_entry_acl_reset(ae,
+ ARCHIVE_ENTRY_ACL_TYPE_NFS4));
+ archive_test_compare_acls(ae, acls4, sizeof(acls4)/sizeof(acls4[0]),
+ ARCHIVE_ENTRY_ACL_TYPE_NFS4, 0);
+
+ /* Third item has has audit and alarm NFS4 ACLs */
+ assertA(0 == archive_read_next_header(a, &ae));
+ assertEqualInt(6, archive_entry_acl_reset(ae,
+ ARCHIVE_ENTRY_ACL_TYPE_NFS4));
+ archive_test_compare_acls(ae, acls5, sizeof(acls5)/sizeof(acls5[0]),
+ ARCHIVE_ENTRY_ACL_TYPE_NFS4, 0);
+
+ /* Close the archive. */
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+ assertEqualInt(ARCHIVE_OK, archive_read_free(a));
+}
diff --git a/contrib/libarchive/libarchive/test/test_acl_pax_nfs4.tar.uu b/contrib/libarchive/libarchive/test/test_acl_pax_nfs4.tar.uu
new file mode 100644
index 0000000..ffc5cc2
--- /dev/null
+++ b/contrib/libarchive/libarchive/test/test_acl_pax_nfs4.tar.uu
@@ -0,0 +1,129 @@
+begin 644 test_acl_pax_nfs4.tar
+M4&%X2&5A9&5R+V9I;&4`````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````#`P,#<W-R``,#`P,#`P(``P,#`P,#`@`#`P,#`P,#`P,3,R
+M(#`P,#`P,#`P,#`P(#`Q,C`P,P`@>```````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````!U<W1A<@`P,```````
+M````````````````````````````````````````````````````````````
+M```````````````````P,#`P,#`@`#`P,#`P,"``````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M```````````````````````Y,"!30TA)3%DN86-L+F%C93UO=VYE<D`Z<G=X
+M<&%!4E=C0V]S.CIA;&QO=RQG<F]U<$`Z<G=P85)C<SHZ86QL;W<L979E<GEO
+M;F5`.G)A4F-S.CIA;&QO=PH`````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````````&9I;&4`````````
+M````````````````````````````````````````````````````````````
+M```````````````````````````````````````````````````````````P
+M,#`W-S<@`#`P,#`P,"``,#`P,#`P(``P,#`P,#`P,#`P,"`P,#`P,#`P,#`P
+M,"`P,3`P,C0`(#``````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````=7-T87(`,#``````````````````````
+M````````````````````````````````````````````````````````````
+M````,#`P,#`P(``P,#`P,#`@````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````4&%X2&5A9&5R+V9I;&4`````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````#`P,#<W-R``,#`P,#`P(``P,#`P,#`@`#`P,#`P
+M,#`P,C4V(#`P,#`P,#`P,#`P(#`Q,C`Q,@`@>```````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````````````!U<W1A<@`P
+M,```````````````````````````````````````````````````````````
+M```````````````````````````P,#`P,#`@`#`P,#`P,"``````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M```````````````````````````````Q-S0@4T-(24Q9+F%C;"YA8V4];W=N
+M97)`.G)W<&%!4E=C0V]S.CIA;&QO=RQU<V5R.G5S97(W-SIR85)C<SI).F%L
+M;&]W.C<W+'5S97(Z=7-E<C<X.G)W>#HZ9&5N>3HW."QG<F]U<$`Z<G=P85)C
+M<SHZ86QL;W<L9W)O=7`Z9W)O=7`W.#IW<$%70V\Z.F1E;GDZ-S@L979E<GEO
+M;F5`.G)A4F-S.CIA;&QO=PH`````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````````````````&9I;&4`
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M```````P,#`W-S<@`#`P,#`P,"``,#`P,#`P(``P,#`P,#`P,#`P,"`P,#`P
+M,#`P,#`P,"`P,3`P,C0`(#``````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````=7-T87(`,#``````````````
+M````````````````````````````````````````````````````````````
+M````````````,#`P,#`P(``P,#`P,#`@````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````4&%X2&5A9&5R+V9I;&4`````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````#`P,#<W-R``,#`P,#`P(``P,#`P,#`@
+M`#`P,#`P,#`P,C8R(#`P,#`P,#`P,#`P(#`Q,C`P-P`@>```````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````````````````````!U
+M<W1A<@`P,```````````````````````````````````````````````````
+M```````````````````````````````````P,#`P,#`@`#`P,#`P,"``````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M```````````````````````````````````````Q-S@@4T-(24Q9+F%C;"YA
+M8V4];W=N97)`.G)W>'!A05)78T-O<SHZ86QL;W<L=7-E<CIU<V5R-S<Z<G=P
+M85)C;W,Z.F%L;&]W.C<W+'5S97(Z=7-E<C<W.G=P.E,Z875D:70Z-S<L9W)O
+M=7!`.G)W<&%28W,Z.F%L;&]W+&=R;W5P.F=R;W5P-S@Z<F%28SI&.F%L87)M
+M.C<X+&5V97)Y;VYE0#IR85)C<SHZ86QL;W<*````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`&9I;&4`````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M```````````````P,#`W-S<@`#`P,#`P,"``,#`P,#`P(``P,#`P,#`P,#`P
+M,"`P,#`P,#`P,#`P,"`P,3`P,C0`(#``````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````=7-T87(`,#``````
+M````````````````````````````````````````````````````````````
+M````````````````````,#`P,#`P(``P,#`P,#`@````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+'````````````
+`
+end
diff --git a/contrib/libarchive/libarchive/test/test_acl_pax.tar.uu b/contrib/libarchive/libarchive/test/test_acl_pax_posix1e.tar.uu
index 58d7b62..46cf975 100644
--- a/contrib/libarchive/libarchive/test/test_acl_pax.tar.uu
+++ b/contrib/libarchive/libarchive/test/test_acl_pax_posix1e.tar.uu
@@ -1,4 +1,4 @@
-begin 644 test_acl_pax.tar
+begin 644 test_acl_pax_posix1e.tar
M9FEL90``````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M`````````````#`P,#$T,B``,#`P,#`P(``P,#`P,#`@`#`P,#`P,#`P,#`P
diff --git a/contrib/libarchive/libarchive/test/test_acl_freebsd_nfs4.c b/contrib/libarchive/libarchive/test/test_acl_platform_nfs4.c
index 89861d6..01c1dc5 100644
--- a/contrib/libarchive/libarchive/test/test_acl_freebsd_nfs4.c
+++ b/contrib/libarchive/libarchive/test/test_acl_platform_nfs4.c
@@ -1,5 +1,6 @@
/*-
* Copyright (c) 2003-2010 Tim Kientzle
+ * Copyright (c) 2017 Martin Matuska
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -25,10 +26,15 @@
#include "test.h"
__FBSDID("$FreeBSD$");
-#if defined(__FreeBSD__) && __FreeBSD__ >= 8
+#if HAVE_POSIX_ACL || HAVE_NFS4_ACL
#define _ACL_PRIVATE
#include <sys/acl.h>
+#if HAVE_DARWIN_ACL
+#include <membership.h>
+#endif
+#endif
+#if HAVE_NFS4_ACL
struct myacl_t {
int type;
int permset;
@@ -38,11 +44,12 @@ struct myacl_t {
};
static struct myacl_t acls_reg[] = {
+#if !HAVE_DARWIN_ACL
/* For this test, we need the file owner to be able to read and write the ACL. */
{ ARCHIVE_ENTRY_ACL_TYPE_ALLOW,
ARCHIVE_ENTRY_ACL_READ_DATA | ARCHIVE_ENTRY_ACL_READ_ACL | ARCHIVE_ENTRY_ACL_WRITE_ACL | ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS | ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES,
ARCHIVE_ENTRY_ACL_USER_OBJ, -1, ""},
-
+#endif
/* An entry for each type. */
{ ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_EXECUTE,
ARCHIVE_ENTRY_ACL_USER, 108, "user108" },
@@ -84,17 +91,53 @@ static struct myacl_t acls_reg[] = {
// ARCHIVE_ENTRY_ACL_USER_OBJ, -1, "" },
{ ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_EXECUTE,
ARCHIVE_ENTRY_ACL_GROUP, 136, "group136" },
+#if !HAVE_DARWIN_ACL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|
+ ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES |
+ ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS |
+ ARCHIVE_ENTRY_ACL_READ_ACL |
+ ARCHIVE_ENTRY_ACL_SYNCHRONIZE,
+ ARCHIVE_ENTRY_ACL_EVERYONE, -1, "" }
+#endif
};
+static const int acls_reg_cnt = (int)(sizeof(acls_reg)/sizeof(acls_reg[0]));
static struct myacl_t acls_dir[] = {
/* For this test, we need to be able to read and write the ACL. */
+#if !HAVE_DARWIN_ACL
{ ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_READ_DATA | ARCHIVE_ENTRY_ACL_READ_ACL,
ARCHIVE_ENTRY_ACL_USER_OBJ, -1, ""},
+#endif
/* An entry for each type. */
{ ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_LIST_DIRECTORY,
@@ -144,6 +187,9 @@ static struct myacl_t acls_dir[] = {
{ ARCHIVE_ENTRY_ACL_TYPE_ALLOW,
ARCHIVE_ENTRY_ACL_READ_DATA | ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY,
ARCHIVE_ENTRY_ACL_USER, 304, "user304" },
+ { ARCHIVE_ENTRY_ACL_TYPE_ALLOW,
+ ARCHIVE_ENTRY_ACL_READ_DATA | ARCHIVE_ENTRY_ACL_ENTRY_INHERITED,
+ ARCHIVE_ENTRY_ACL_USER, 305, "user305" },
#endif
#if 0
@@ -161,12 +207,47 @@ static struct myacl_t acls_dir[] = {
ARCHIVE_ENTRY_ACL_USER, 501, "user501" },
{ ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_LIST_DIRECTORY,
ARCHIVE_ENTRY_ACL_GROUP, 502, "group502" },
+#if !HAVE_DARWIN_ACL
{ ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_LIST_DIRECTORY,
ARCHIVE_ENTRY_ACL_GROUP_OBJ, -1, "" },
{ ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_LIST_DIRECTORY,
ARCHIVE_ENTRY_ACL_EVERYONE, -1, "" }
+#else /* MacOS - mode 0654 */
+ { ARCHIVE_ENTRY_ACL_TYPE_DENY, ARCHIVE_ENTRY_ACL_EXECUTE,
+ ARCHIVE_ENTRY_ACL_USER_OBJ, -1, "" },
+ { ARCHIVE_ENTRY_ACL_TYPE_ALLOW,
+ ARCHIVE_ENTRY_ACL_READ_DATA |
+ ARCHIVE_ENTRY_ACL_WRITE_DATA |
+ ARCHIVE_ENTRY_ACL_APPEND_DATA |
+ ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES |
+ ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES |
+ ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS |
+ ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS |
+ ARCHIVE_ENTRY_ACL_READ_ACL |
+ ARCHIVE_ENTRY_ACL_WRITE_ACL |
+ ARCHIVE_ENTRY_ACL_WRITE_OWNER |
+ ARCHIVE_ENTRY_ACL_SYNCHRONIZE,
+ ARCHIVE_ENTRY_ACL_USER_OBJ, -1, "" },
+ { ARCHIVE_ENTRY_ACL_TYPE_ALLOW,
+ ARCHIVE_ENTRY_ACL_READ_DATA |
+ ARCHIVE_ENTRY_ACL_EXECUTE |
+ ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES |
+ ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS |
+ ARCHIVE_ENTRY_ACL_READ_ACL |
+ ARCHIVE_ENTRY_ACL_SYNCHRONIZE,
+ ARCHIVE_ENTRY_ACL_GROUP_OBJ, -1, "" },
+ { ARCHIVE_ENTRY_ACL_TYPE_ALLOW,
+ ARCHIVE_ENTRY_ACL_READ_DATA |
+ ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES |
+ ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS |
+ ARCHIVE_ENTRY_ACL_READ_ACL |
+ ARCHIVE_ENTRY_ACL_SYNCHRONIZE,
+ ARCHIVE_ENTRY_ACL_EVERYONE, -1, "" }
+#endif
};
+static const int acls_dir_cnt = (int)(sizeof(acls_dir)/sizeof(acls_dir[0]));
+
static void
set_acls(struct archive_entry *ae, struct myacl_t *acls, int start, int end)
{
@@ -188,9 +269,50 @@ set_acls(struct archive_entry *ae, struct myacl_t *acls, int start, int end)
}
static int
+#ifdef HAVE_SUN_ACL
+acl_permset_to_bitmap(uint32_t a_access_mask)
+#else
acl_permset_to_bitmap(acl_permset_t opaque_ps)
+#endif
{
static struct { int machine; int portable; } perms[] = {
+#ifdef HAVE_SUN_ACL /* Solaris NFSv4 ACL permissions */
+ {ACE_EXECUTE, ARCHIVE_ENTRY_ACL_EXECUTE},
+ {ACE_READ_DATA, ARCHIVE_ENTRY_ACL_READ_DATA},
+ {ACE_LIST_DIRECTORY, ARCHIVE_ENTRY_ACL_LIST_DIRECTORY},
+ {ACE_WRITE_DATA, ARCHIVE_ENTRY_ACL_WRITE_DATA},
+ {ACE_ADD_FILE, ARCHIVE_ENTRY_ACL_ADD_FILE},
+ {ACE_APPEND_DATA, ARCHIVE_ENTRY_ACL_APPEND_DATA},
+ {ACE_ADD_SUBDIRECTORY, ARCHIVE_ENTRY_ACL_ADD_SUBDIRECTORY},
+ {ACE_READ_NAMED_ATTRS, ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS},
+ {ACE_WRITE_NAMED_ATTRS, ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS},
+ {ACE_DELETE_CHILD, ARCHIVE_ENTRY_ACL_DELETE_CHILD},
+ {ACE_READ_ATTRIBUTES, ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES},
+ {ACE_WRITE_ATTRIBUTES, ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES},
+ {ACE_DELETE, ARCHIVE_ENTRY_ACL_DELETE},
+ {ACE_READ_ACL, ARCHIVE_ENTRY_ACL_READ_ACL},
+ {ACE_WRITE_ACL, ARCHIVE_ENTRY_ACL_WRITE_ACL},
+ {ACE_WRITE_OWNER, ARCHIVE_ENTRY_ACL_WRITE_OWNER},
+ {ACE_SYNCHRONIZE, ARCHIVE_ENTRY_ACL_SYNCHRONIZE}
+#elif HAVE_DARWIN_ACL /* MacOS NFSv4 ACL permissions */
+ {ACL_READ_DATA, ARCHIVE_ENTRY_ACL_READ_DATA},
+ {ACL_LIST_DIRECTORY, ARCHIVE_ENTRY_ACL_LIST_DIRECTORY},
+ {ACL_WRITE_DATA, ARCHIVE_ENTRY_ACL_WRITE_DATA},
+ {ACL_ADD_FILE, ARCHIVE_ENTRY_ACL_ADD_FILE},
+ {ACL_EXECUTE, ARCHIVE_ENTRY_ACL_EXECUTE},
+ {ACL_DELETE, ARCHIVE_ENTRY_ACL_DELETE},
+ {ACL_APPEND_DATA, ARCHIVE_ENTRY_ACL_APPEND_DATA},
+ {ACL_ADD_SUBDIRECTORY, ARCHIVE_ENTRY_ACL_ADD_SUBDIRECTORY},
+ {ACL_DELETE_CHILD, ARCHIVE_ENTRY_ACL_DELETE_CHILD},
+ {ACL_READ_ATTRIBUTES, ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES},
+ {ACL_WRITE_ATTRIBUTES, ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES},
+ {ACL_READ_EXTATTRIBUTES, ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS},
+ {ACL_WRITE_EXTATTRIBUTES, ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS},
+ {ACL_READ_SECURITY, ARCHIVE_ENTRY_ACL_READ_ACL},
+ {ACL_WRITE_SECURITY, ARCHIVE_ENTRY_ACL_WRITE_ACL},
+ {ACL_CHANGE_OWNER, ARCHIVE_ENTRY_ACL_WRITE_OWNER},
+ {ACL_SYNCHRONIZE, ARCHIVE_ENTRY_ACL_SYNCHRONIZE},
+#else /* FreeBSD NFSv4 ACL permissions */
{ACL_EXECUTE, ARCHIVE_ENTRY_ACL_EXECUTE},
{ACL_WRITE, ARCHIVE_ENTRY_ACL_WRITE},
{ACL_READ, ARCHIVE_ENTRY_ACL_READ},
@@ -210,51 +332,201 @@ acl_permset_to_bitmap(acl_permset_t opaque_ps)
{ACL_WRITE_ACL, ARCHIVE_ENTRY_ACL_WRITE_ACL},
{ACL_WRITE_OWNER, ARCHIVE_ENTRY_ACL_WRITE_OWNER},
{ACL_SYNCHRONIZE, ARCHIVE_ENTRY_ACL_SYNCHRONIZE}
+#endif
};
int i, permset = 0;
for (i = 0; i < (int)(sizeof(perms)/sizeof(perms[0])); ++i)
+#if HAVE_SUN_ACL
+ if (a_access_mask & perms[i].machine)
+#else
if (acl_get_perm_np(opaque_ps, perms[i].machine))
+#endif
permset |= perms[i].portable;
return permset;
}
static int
+#if HAVE_SUN_ACL
+acl_flagset_to_bitmap(uint16_t a_flags)
+#else
acl_flagset_to_bitmap(acl_flagset_t opaque_fs)
+#endif
{
static struct { int machine; int portable; } flags[] = {
+#if HAVE_SUN_ACL /* Solaris NFSv4 ACL inheritance flags */
+ {ACE_FILE_INHERIT_ACE, ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT},
+ {ACE_DIRECTORY_INHERIT_ACE, ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT},
+ {ACE_NO_PROPAGATE_INHERIT_ACE, ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT},
+ {ACE_INHERIT_ONLY_ACE, ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY},
+ {ACE_SUCCESSFUL_ACCESS_ACE_FLAG, ARCHIVE_ENTRY_ACL_ENTRY_SUCCESSFUL_ACCESS},
+ {ACE_FAILED_ACCESS_ACE_FLAG, ARCHIVE_ENTRY_ACL_ENTRY_FAILED_ACCESS},
+ {ACE_INHERITED_ACE, ARCHIVE_ENTRY_ACL_ENTRY_INHERITED}
+#elif HAVE_DARWIN_ACL /* MacOS NFSv4 ACL inheritance flags */
+ {ACL_ENTRY_INHERITED, ARCHIVE_ENTRY_ACL_ENTRY_INHERITED},
+ {ACL_ENTRY_FILE_INHERIT, ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT},
+ {ACL_ENTRY_DIRECTORY_INHERIT, ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT},
+ {ACL_ENTRY_LIMIT_INHERIT, ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT},
+ {ACL_ENTRY_ONLY_INHERIT, ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY}
+#else /* FreeBSD NFSv4 ACL inheritance flags */
{ACL_ENTRY_FILE_INHERIT, ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT},
{ACL_ENTRY_DIRECTORY_INHERIT, ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT},
{ACL_ENTRY_NO_PROPAGATE_INHERIT, ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT},
+ {ACL_ENTRY_SUCCESSFUL_ACCESS, ARCHIVE_ENTRY_ACL_ENTRY_SUCCESSFUL_ACCESS},
+ {ACL_ENTRY_NO_PROPAGATE_INHERIT, ARCHIVE_ENTRY_ACL_ENTRY_FAILED_ACCESS},
{ACL_ENTRY_INHERIT_ONLY, ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY},
+#endif
};
int i, flagset = 0;
for (i = 0; i < (int)(sizeof(flags)/sizeof(flags[0])); ++i)
+#if HAVE_SUN_ACL
+ if (a_flags & flags[i].machine)
+#else
if (acl_get_flag_np(opaque_fs, flags[i].machine))
+#endif
flagset |= flags[i].portable;
return flagset;
}
static int
+#if HAVE_SUN_ACL
+acl_match(ace_t *ace, struct myacl_t *myacl)
+#else
acl_match(acl_entry_t aclent, struct myacl_t *myacl)
+#endif
{
+#if !HAVE_SUN_ACL
+#if HAVE_DARWIN_ACL
+ void *q;
+ uid_t ugid;
+ int r, idtype;
+#else
gid_t g, *gp;
uid_t u, *up;
+ acl_entry_type_t entry_type;
+#endif /* !HAVE_DARWIN_ACL */
acl_tag_t tag_type;
acl_permset_t opaque_ps;
acl_flagset_t opaque_fs;
+#endif /* !HAVE_SUN_ACL */
int perms;
+#if HAVE_SUN_ACL
+ perms = acl_permset_to_bitmap(ace->a_access_mask) | acl_flagset_to_bitmap(ace->a_flags);
+#else
acl_get_tag_type(aclent, &tag_type);
+#if !HAVE_DARWIN_ACL
+ acl_get_entry_type_np(aclent, &entry_type);
+#endif
/* translate the silly opaque permset to a bitmap */
acl_get_permset(aclent, &opaque_ps);
acl_get_flagset_np(aclent, &opaque_fs);
perms = acl_permset_to_bitmap(opaque_ps) | acl_flagset_to_bitmap(opaque_fs);
+#endif
if (perms != myacl->permset)
return (0);
+#if HAVE_SUN_ACL
+ switch (ace->a_type) {
+ case ACE_ACCESS_ALLOWED_ACE_TYPE:
+ if (myacl->type != ARCHIVE_ENTRY_ACL_TYPE_ALLOW)
+ return (0);
+ break;
+ case ACE_ACCESS_DENIED_ACE_TYPE:
+ if (myacl->type != ARCHIVE_ENTRY_ACL_TYPE_DENY)
+ return (0);
+ break;
+ case ACE_SYSTEM_AUDIT_ACE_TYPE:
+ if (myacl->type != ARCHIVE_ENTRY_ACL_TYPE_AUDIT)
+ return (0);
+ break;
+ case ACE_SYSTEM_ALARM_ACE_TYPE:
+ if (myacl->type != ARCHIVE_ENTRY_ACL_TYPE_ALARM)
+ return (0);
+ break;
+ default:
+ return (0);
+ }
+
+ if (ace->a_flags & ACE_OWNER) {
+ if (myacl->tag != ARCHIVE_ENTRY_ACL_USER_OBJ)
+ return (0);
+ } else if (ace->a_flags & ACE_GROUP) {
+ if (myacl->tag != ARCHIVE_ENTRY_ACL_GROUP_OBJ)
+ return (0);
+ } else if (ace->a_flags & ACE_EVERYONE) {
+ if (myacl->tag != ARCHIVE_ENTRY_ACL_EVERYONE)
+ return (0);
+ } else if (ace->a_flags & ACE_IDENTIFIER_GROUP) {
+ if (myacl->tag != ARCHIVE_ENTRY_ACL_GROUP)
+ return (0);
+ if ((gid_t)myacl->qual != ace->a_who)
+ return (0);
+ } else {
+ if (myacl->tag != ARCHIVE_ENTRY_ACL_USER)
+ return (0);
+ if ((uid_t)myacl->qual != ace->a_who)
+ return (0);
+ }
+#elif HAVE_DARWIN_ACL
+ r = 0;
+ switch (tag_type) {
+ case ACL_EXTENDED_ALLOW:
+ if (myacl->type != ARCHIVE_ENTRY_ACL_TYPE_ALLOW)
+ return (0);
+ break;
+ case ACL_EXTENDED_DENY:
+ if (myacl->type != ARCHIVE_ENTRY_ACL_TYPE_DENY)
+ return (0);
+ break;
+ default:
+ return (0);
+ }
+ q = acl_get_qualifier(aclent);
+ if (q == NULL)
+ return (0);
+ r = mbr_uuid_to_id((const unsigned char *)q, &ugid, &idtype);
+ acl_free(q);
+ if (r != 0)
+ return (0);
+ switch (idtype) {
+ case ID_TYPE_UID:
+ if (myacl->tag != ARCHIVE_ENTRY_ACL_USER)
+ return (0);
+ if ((uid_t)myacl->qual != ugid)
+ return (0);
+ break;
+ case ID_TYPE_GID:
+ if (myacl->tag != ARCHIVE_ENTRY_ACL_GROUP)
+ return (0);
+ if ((gid_t)myacl->qual != ugid)
+ return (0);
+ break;
+ default:
+ return (0);
+ }
+#else /* !HAVE_SUN_ACL && !HAVE_DARWIN_ACL */
+ switch (entry_type) {
+ case ACL_ENTRY_TYPE_ALLOW:
+ if (myacl->type != ARCHIVE_ENTRY_ACL_TYPE_ALLOW)
+ return (0);
+ break;
+ case ACL_ENTRY_TYPE_DENY:
+ if (myacl->type != ARCHIVE_ENTRY_ACL_TYPE_DENY)
+ return (0);
+ break;
+ case ACL_ENTRY_TYPE_AUDIT:
+ if (myacl->type != ARCHIVE_ENTRY_ACL_TYPE_AUDIT)
+ return (0);
+ case ACL_ENTRY_TYPE_ALARM:
+ if (myacl->type != ARCHIVE_ENTRY_ACL_TYPE_ALARM)
+ return (0);
+ default:
+ return (0);
+ }
+
switch (tag_type) {
case ACL_USER_OBJ:
if (myacl->tag != ARCHIVE_ENTRY_ACL_USER_OBJ) return (0);
@@ -287,17 +559,29 @@ acl_match(acl_entry_t aclent, struct myacl_t *myacl)
if (myacl->tag != ARCHIVE_ENTRY_ACL_EVERYONE) return (0);
break;
}
+#endif /* !HAVE_SUN_ACL && !HAVE_DARWIN_ACL */
return (1);
}
static void
-compare_acls(acl_t acl, struct myacl_t *myacls, const char *filename, int start, int end)
+compare_acls(
+#if HAVE_SUN_ACL
+ acl_t *acl,
+#else
+ acl_t acl,
+#endif
+ struct myacl_t *myacls, const char *filename, int start, int end)
{
int *marker;
- int entry_id = ACL_FIRST_ENTRY;
int matched;
int i, n;
+#if HAVE_SUN_ACL
+ int e;
+ ace_t *acl_entry;
+#else
+ int entry_id = ACL_FIRST_ENTRY;
acl_entry_t acl_entry;
+#endif
n = end - start;
marker = malloc(sizeof(marker[0]) * (n + 1));
@@ -313,10 +597,20 @@ compare_acls(acl_t acl, struct myacl_t *myacls, const char *filename, int start,
* Iterate over acls in system acl object, try to match each
* one with an item in the myacls array.
*/
- while (1 == acl_get_entry(acl, entry_id, &acl_entry)) {
+#if HAVE_SUN_ACL
+ for (e = 0; e < acl->acl_cnt; e++)
+#elif HAVE_DARWIN_ACL
+ while (0 == acl_get_entry(acl, entry_id, &acl_entry))
+#else
+ while (1 == acl_get_entry(acl, entry_id, &acl_entry))
+#endif
+ {
+#if HAVE_SUN_ACL
+ acl_entry = &((ace_t *)acl->acl_aclp)[e];
+#else
/* After the first time... */
entry_id = ACL_NEXT_ENTRY;
-
+#endif
/* Search for a matching entry (tag and qualifier) */
for (i = 0, matched = 0; i < n && !matched; i++) {
if (acl_match(acl_entry, &myacls[marker[i]])) {
@@ -327,14 +621,15 @@ compare_acls(acl_t acl, struct myacl_t *myacls, const char *filename, int start,
}
}
- failure("ACL entry on file %s that shouldn't be there", filename);
+ failure("ACL entry on file %s that shouldn't be there",
+ filename);
assert(matched == 1);
}
/* Dump entries in the myacls array that weren't in the system acl. */
for (i = 0; i < n; ++i) {
failure(" ACL entry %d missing from %s: "
- "type=%d,permset=%x,tag=%d,qual=%d,name=``%s''\n",
+ "type=%#010x,permset=%#010x,tag=%d,qual=%d,name=``%s''\n",
marker[i], filename,
myacls[marker[i]].type, myacls[marker[i]].permset,
myacls[marker[i]].tag, myacls[marker[i]].qual,
@@ -368,7 +663,8 @@ compare_entry_acls(struct archive_entry *ae, struct myacl_t *myacls, const char
* Iterate over acls in entry, try to match each
* one with an item in the myacls array.
*/
- assertEqualInt(n, archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_NFS4));
+ assertEqualInt(n, archive_entry_acl_reset(ae,
+ ARCHIVE_ENTRY_ACL_TYPE_NFS4));
while (ARCHIVE_OK == archive_entry_acl_next(ae,
ARCHIVE_ENTRY_ACL_TYPE_NFS4, &type, &permset, &tag, &qual, &name)) {
@@ -386,7 +682,7 @@ compare_entry_acls(struct archive_entry *ae, struct myacl_t *myacls, const char
}
failure("ACL entry on file that shouldn't be there: "
- "type=%d,permset=%x,tag=%d,qual=%d",
+ "type=%#010x,permset=%#010x,tag=%d,qual=%d",
type,permset,tag,qual);
assert(matched == 1);
}
@@ -394,7 +690,7 @@ compare_entry_acls(struct archive_entry *ae, struct myacl_t *myacls, const char
/* Dump entries in the myacls array that weren't in the system acl. */
for (i = 0; i < n; ++i) {
failure(" ACL entry %d missing from %s: "
- "type=%d,permset=%x,tag=%d,qual=%d,name=``%s''\n",
+ "type=%#010x,permset=%#010x,tag=%d,qual=%d,name=``%s''\n",
marker[i], filename,
myacls[marker[i]].type, myacls[marker[i]].permset,
myacls[marker[i]].tag, myacls[marker[i]].qual,
@@ -403,53 +699,109 @@ compare_entry_acls(struct archive_entry *ae, struct myacl_t *myacls, const char
}
free(marker);
}
-#endif
+#endif /* HAVE_NFS4_ACL */
/*
- * Verify ACL restore-to-disk. This test is FreeBSD-specific.
+ * Verify ACL restore-to-disk. This test is Platform-specific.
*/
-DEFINE_TEST(test_acl_freebsd_nfs4)
+DEFINE_TEST(test_acl_platform_nfs4)
{
-#if !defined(__FreeBSD__)
- skipping("FreeBSD-specific NFS4 ACL restore test");
-#elif __FreeBSD__ < 8
- skipping("NFS4 ACLs supported only on FreeBSD 8.0 and later");
+#if !HAVE_NFS4_ACL
+ skipping("NFS4 ACLs are not supported on this platform");
#else
char buff[64];
struct stat st;
struct archive *a;
struct archive_entry *ae;
int i, n;
+ char *func;
+#if HAVE_DARWIN_ACL /* On MacOS we skip trivial ACLs in some tests */
+ const int regcnt = acls_reg_cnt - 4;
+ const int dircnt = acls_dir_cnt - 4;
+#else
+ const int regcnt = acls_reg_cnt;
+ const int dircnt = acls_dir_cnt;
+#endif
+#if HAVE_SUN_ACL
+ acl_t *acl;
+#else /* !HAVE_SUN_ACL */
+#if HAVE_DARWIN_ACL
+ acl_entry_t aclent;
+ acl_permset_t permset;
+ const uid_t uid = 1000;
+ uuid_t uuid;
+#endif /* HAVE_DARWIN_ACL */
acl_t acl;
+#endif /* !HAVE_SUN_ACL */
/*
* First, do a quick manual set/read of ACL data to
* verify that the local filesystem does support ACLs.
* If it doesn't, we'll simply skip the remaining tests.
*/
+#if HAVE_POSIX_ACL && HAVE_ACL_TYPE_NFS4
acl = acl_from_text("owner@:rwxp::allow,group@:rwp:f:allow");
+ failure("acl_from_text(): errno = %d (%s)", errno, strerror(errno));
+ assert((void *)acl != NULL);
+#elif HAVE_DARWIN_ACL
+ acl = acl_init(1);
assert((void *)acl != NULL);
+ assertEqualInt(0, acl_create_entry(&acl, &aclent));
+ assertEqualInt(0, acl_set_tag_type(aclent, ACL_EXTENDED_ALLOW));
+ assertEqualInt(0, acl_get_permset(aclent, &permset));
+ assertEqualInt(0, acl_add_perm(permset, ACL_READ_DATA));
+ assertEqualInt(0, acl_add_perm(permset, ACL_WRITE_DATA));
+ assertEqualInt(0, acl_add_perm(permset, ACL_APPEND_DATA));
+ assertEqualInt(0, acl_add_perm(permset, ACL_EXECUTE));
+ assertEqualInt(0, acl_set_permset(aclent, permset));
+ assertEqualInt(0, mbr_identifier_to_uuid(ID_TYPE_UID, &uid,
+ sizeof(uid_t), uuid));
+ assertEqualInt(0, acl_set_qualifier(aclent, uuid));
+#endif
+
/* Create a test dir and try to set an ACL on it. */
if (!assertMakeDir("pretest", 0755)) {
+#if !HAVE_SUN_ACL
acl_free(acl);
+#endif
return;
}
+#if HAVE_SUN_ACL
+ func = "acl_get()";
+ n = acl_get("pretest", 0, &acl);
+#else
+ func = "acl_set_file()";
+#if HAVE_DARWIN_ACL
+ n = acl_set_file("pretest", ACL_TYPE_EXTENDED, acl);
+#else
n = acl_set_file("pretest", ACL_TYPE_NFS4, acl);
+#endif
acl_free(acl);
- if (n != 0 && errno == EOPNOTSUPP) {
- skipping("NFS4 ACL tests require that NFS4 ACLs"
- " be enabled on the filesystem");
- return;
+#endif
+ if (n != 0) {
+#if HAVE_SUN_ACL
+ if (errno == ENOSYS)
+#else
+ if (errno == EOPNOTSUPP || errno == EINVAL)
+#endif
+ {
+ skipping("NFS4 ACL is not supported on this filesystem");
+ return;
+ }
}
- if (n != 0 && errno == EINVAL) {
- skipping("This filesystem does not support NFS4 ACLs");
+ failure("%s: errno = %d (%s)", func, errno, strerror(errno));
+ assertEqualInt(0, n);
+
+#if HAVE_SUN_ACL
+ if (acl->acl_type != ACE_T) {
+ acl_free(acl);
+ skipping("NFS4 ACL is not supported on this filesystem");
return;
}
- failure("acl_set_file(): errno = %d (%s)",
- errno, strerror(errno));
- assertEqualInt(0, n);
+ acl_free(acl);
+#endif
/* Create a write-to-disk object. */
assert(NULL != (a = archive_write_disk_new()));
@@ -464,7 +816,7 @@ DEFINE_TEST(test_acl_freebsd_nfs4)
archive_entry_set_perm(ae, 0654);
archive_entry_set_mtime(ae, 123456, 7890);
archive_entry_set_size(ae, 0);
- set_acls(ae, acls_reg, 0, (int)(sizeof(acls_reg)/sizeof(acls_reg[0])));
+ set_acls(ae, acls_reg, 0, acls_reg_cnt);
/* Write the entry to disk, including ACLs. */
assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
@@ -474,10 +826,10 @@ DEFINE_TEST(test_acl_freebsd_nfs4)
archive_entry_set_filetype(ae, AE_IFDIR);
archive_entry_set_perm(ae, 0654);
archive_entry_set_mtime(ae, 123456, 7890);
- set_acls(ae, acls_dir, 0, (int)(sizeof(acls_dir)/sizeof(acls_dir[0])));
+ set_acls(ae, acls_dir, 0, acls_dir_cnt);
assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
- for (i = 0; i < (int)(sizeof(acls_dir)/sizeof(acls_dir[0])); ++i) {
+ for (i = 0; i < acls_dir_cnt; ++i) {
sprintf(buff, "dir%d", i);
archive_entry_set_pathname(ae, buff);
archive_entry_set_filetype(ae, AE_IFDIR);
@@ -496,28 +848,62 @@ DEFINE_TEST(test_acl_freebsd_nfs4)
/* Verify the data on disk. */
assertEqualInt(0, stat("testall", &st));
assertEqualInt(st.st_mtime, 123456);
+#if HAVE_SUN_ACL
+ n = acl_get("testall", 0, &acl);
+ failure("acl_get(): errno = %d (%s)", errno, strerror(errno));
+ assertEqualInt(0, n);
+#else
+#if HAVE_DARWIN_ACL
+ acl = acl_get_file("testall", ACL_TYPE_EXTENDED);
+#else
acl = acl_get_file("testall", ACL_TYPE_NFS4);
+#endif
+ failure("acl_get_file(): errno = %d (%s)", errno, strerror(errno));
assert(acl != (acl_t)NULL);
- compare_acls(acl, acls_reg, "testall", 0, (int)(sizeof(acls_reg)/sizeof(acls_reg[0])));
+#endif
+ compare_acls(acl, acls_reg, "testall", 0, regcnt);
acl_free(acl);
/* Verify single-permission dirs on disk. */
- for (i = 0; i < (int)(sizeof(acls_dir)/sizeof(acls_dir[0])); ++i) {
- sprintf(buff, "dir%d", i);
- assertEqualInt(0, stat(buff, &st));
- assertEqualInt(st.st_mtime, 123456 + i);
- acl = acl_get_file(buff, ACL_TYPE_NFS4);
- assert(acl != (acl_t)NULL);
- compare_acls(acl, acls_dir, buff, i, i + 1);
- acl_free(acl);
+ for (i = 0; i < dircnt; ++i) {
+ sprintf(buff, "dir%d", i);
+ assertEqualInt(0, stat(buff, &st));
+ assertEqualInt(st.st_mtime, 123456 + i);
+#if HAVE_SUN_ACL
+ n = acl_get(buff, 0, &acl);
+ failure("acl_get(): errno = %d (%s)", errno, strerror(errno));
+ assertEqualInt(0, n);
+#else
+#if HAVE_DARWIN_ACL
+ acl = acl_get_file(buff, ACL_TYPE_EXTENDED);
+#else
+ acl = acl_get_file(buff, ACL_TYPE_NFS4);
+#endif
+ failure("acl_get_file(): errno = %d (%s)", errno,
+ strerror(errno));
+ assert(acl != (acl_t)NULL);
+#endif
+ compare_acls(acl, acls_dir, buff, i, i + 1);
+ acl_free(acl);
}
/* Verify "dirall" on disk. */
assertEqualInt(0, stat("dirall", &st));
assertEqualInt(st.st_mtime, 123456);
+#if HAVE_SUN_ACL
+ n = acl_get("dirall", 0, &acl);
+ failure("acl_get(): errno = %d (%s)", errno, strerror(errno));
+ assertEqualInt(0, n);
+#else
+#if HAVE_DARWIN_ACL
+ acl = acl_get_file("dirall", ACL_TYPE_EXTENDED);
+#else
acl = acl_get_file("dirall", ACL_TYPE_NFS4);
+#endif
+ failure("acl_get_file(): errno = %d (%s)", errno, strerror(errno));
assert(acl != (acl_t)NULL);
- compare_acls(acl, acls_dir, "dirall", 0, (int)(sizeof(acls_dir)/sizeof(acls_dir[0])));
+#endif
+ compare_acls(acl, acls_dir, "dirall", 0, dircnt);
acl_free(acl);
/* Read and compare ACL via archive_read_disk */
@@ -528,7 +914,7 @@ DEFINE_TEST(test_acl_freebsd_nfs4)
archive_entry_set_pathname(ae, "testall");
assertEqualInt(ARCHIVE_OK,
archive_read_disk_entry_from_file(a, ae, -1, NULL));
- compare_entry_acls(ae, acls_reg, "testall", 0, (int)(sizeof(acls_reg)/sizeof(acls_reg[0])));
+ compare_entry_acls(ae, acls_reg, "testall", 0, acls_reg_cnt);
archive_entry_free(ae);
assertEqualInt(ARCHIVE_OK, archive_read_free(a));
@@ -539,9 +925,9 @@ DEFINE_TEST(test_acl_freebsd_nfs4)
assert(ae != NULL);
archive_entry_set_pathname(ae, "dirall");
assertEqualInt(ARCHIVE_OK,
- archive_read_disk_entry_from_file(a, ae, -1, NULL));
- compare_entry_acls(ae, acls_dir, "dirall", 0, (int)(sizeof(acls_dir)/sizeof(acls_dir[0])));
+ archive_read_disk_entry_from_file(a, ae, -1, NULL));
+ compare_entry_acls(ae, acls_dir, "dirall", 0, acls_dir_cnt);
archive_entry_free(ae);
assertEqualInt(ARCHIVE_OK, archive_read_free(a));
-#endif
+#endif /* HAVE_NFS4_ACL */
}
diff --git a/contrib/libarchive/libarchive/test/test_acl_freebsd_posix1e.c b/contrib/libarchive/libarchive/test/test_acl_platform_posix1e.c
index 2eb0a00..1d55a33 100644
--- a/contrib/libarchive/libarchive/test/test_acl_freebsd_posix1e.c
+++ b/contrib/libarchive/libarchive/test/test_acl_platform_posix1e.c
@@ -1,5 +1,6 @@
/*-
* Copyright (c) 2003-2008 Tim Kientzle
+ * Copyright (c) 2017 Martin Matuska
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -25,18 +26,16 @@
#include "test.h"
__FBSDID("$FreeBSD: head/lib/libarchive/test/test_acl_freebsd.c 189427 2009-03-06 04:21:23Z kientzle $");
-#if defined(__FreeBSD__) && __FreeBSD__ > 4
+#if HAVE_POSIX_ACL || HAVE_SUN_ACL
#include <sys/acl.h>
+#if HAVE_ACL_GET_PERM
+#include <acl/libacl.h>
+#define ACL_GET_PERM acl_get_perm
+#elif HAVE_ACL_GET_PERM_NP
+#define ACL_GET_PERM acl_get_perm_np
+#endif
-struct myacl_t {
- int type; /* Type of ACL: "access" or "default" */
- int permset; /* Permissions for this class of users. */
- int tag; /* Owner, User, Owning group, group, other, etc. */
- int qual; /* GID or UID of user/group, depending on tag. */
- const char *name; /* Name of user/group, depending on tag. */
-};
-
-static struct myacl_t acls2[] = {
+static struct archive_test_acl_t acls2[] = {
{ ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_EXECUTE | ARCHIVE_ENTRY_ACL_READ,
ARCHIVE_ENTRY_ACL_USER_OBJ, -1, "" },
{ ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ,
@@ -53,35 +52,37 @@ static struct myacl_t acls2[] = {
{ ARCHIVE_ENTRY_ACL_TYPE_ACCESS,
ARCHIVE_ENTRY_ACL_WRITE | ARCHIVE_ENTRY_ACL_READ | ARCHIVE_ENTRY_ACL_EXECUTE,
ARCHIVE_ENTRY_ACL_MASK, -1, "" },
- { 0, 0, 0, 0, NULL }
};
-static void
-set_acls(struct archive_entry *ae, struct myacl_t *acls)
-{
- int i;
-
- archive_entry_acl_clear(ae);
- for (i = 0; acls[i].name != NULL; i++) {
- archive_entry_acl_add_entry(ae,
- acls[i].type, acls[i].permset, acls[i].tag, acls[i].qual,
- acls[i].name);
- }
-}
-
static int
-acl_entry_get_perm(acl_entry_t aclent) {
+#if HAVE_SUN_ACL
+acl_entry_get_perm(aclent_t *aclent)
+#else
+acl_entry_get_perm(acl_entry_t aclent)
+#endif
+{
int permset = 0;
+#if HAVE_POSIX_ACL
acl_permset_t opaque_ps;
+#endif
+#if HAVE_SUN_ACL
+ if (aclent->a_perm & 1)
+ permset |= ARCHIVE_ENTRY_ACL_EXECUTE;
+ if (aclent->a_perm & 2)
+ permset |= ARCHIVE_ENTRY_ACL_WRITE;
+ if (aclent->a_perm & 4)
+ permset |= ARCHIVE_ENTRY_ACL_READ;
+#else
/* translate the silly opaque permset to a bitmap */
acl_get_permset(aclent, &opaque_ps);
- if (acl_get_perm_np(opaque_ps, ACL_EXECUTE))
+ if (ACL_GET_PERM(opaque_ps, ACL_EXECUTE))
permset |= ARCHIVE_ENTRY_ACL_EXECUTE;
- if (acl_get_perm_np(opaque_ps, ACL_WRITE))
+ if (ACL_GET_PERM(opaque_ps, ACL_WRITE))
permset |= ARCHIVE_ENTRY_ACL_WRITE;
- if (acl_get_perm_np(opaque_ps, ACL_READ))
+ if (ACL_GET_PERM(opaque_ps, ACL_READ))
permset |= ARCHIVE_ENTRY_ACL_READ;
+#endif
return permset;
}
@@ -127,45 +128,96 @@ acl_get_specific_entry(acl_t acl, acl_tag_t requested_tag_type, int requested_ta
#endif
static int
-acl_match(acl_entry_t aclent, struct myacl_t *myacl)
+#if HAVE_SUN_ACL
+acl_match(aclent_t *aclent, struct archive_test_acl_t *myacl)
+#else
+acl_match(acl_entry_t aclent, struct archive_test_acl_t *myacl)
+#endif
{
+#if HAVE_POSIX_ACL
gid_t g, *gp;
uid_t u, *up;
acl_tag_t tag_type;
+#endif
if (myacl->permset != acl_entry_get_perm(aclent))
return (0);
+#if HAVE_SUN_ACL
+ switch (aclent->a_type)
+#else
acl_get_tag_type(aclent, &tag_type);
- switch (tag_type) {
+ switch (tag_type)
+#endif
+ {
+#if HAVE_SUN_ACL
+ case DEF_USER_OBJ:
+ case USER_OBJ:
+#else
case ACL_USER_OBJ:
+#endif
if (myacl->tag != ARCHIVE_ENTRY_ACL_USER_OBJ) return (0);
break;
+#if HAVE_SUN_ACL
+ case DEF_USER:
+ case USER:
+#else
case ACL_USER:
+#endif
if (myacl->tag != ARCHIVE_ENTRY_ACL_USER)
return (0);
+#if HAVE_SUN_ACL
+ if ((uid_t)myacl->qual != aclent->a_id)
+ return (0);
+#else
up = acl_get_qualifier(aclent);
u = *up;
acl_free(up);
if ((uid_t)myacl->qual != u)
return (0);
+#endif
break;
+#if HAVE_SUN_ACL
+ case DEF_GROUP_OBJ:
+ case GROUP_OBJ:
+#else
case ACL_GROUP_OBJ:
+#endif
if (myacl->tag != ARCHIVE_ENTRY_ACL_GROUP_OBJ) return (0);
break;
+#if HAVE_SUN_ACL
+ case DEF_GROUP:
+ case GROUP:
+#else
case ACL_GROUP:
+#endif
if (myacl->tag != ARCHIVE_ENTRY_ACL_GROUP)
return (0);
+#if HAVE_SUN_ACL
+ if ((gid_t)myacl->qual != aclent->a_id)
+ return (0);
+#else
gp = acl_get_qualifier(aclent);
g = *gp;
acl_free(gp);
if ((gid_t)myacl->qual != g)
return (0);
+#endif
break;
+#if HAVE_SUN_ACL
+ case DEF_CLASS_OBJ:
+ case CLASS_OBJ:
+#else
case ACL_MASK:
+#endif
if (myacl->tag != ARCHIVE_ENTRY_ACL_MASK) return (0);
break;
+#if HAVE_SUN_ACL
+ case DEF_OTHER_OBJ:
+ case OTHER_OBJ:
+#else
case ACL_OTHER:
+#endif
if (myacl->tag != ARCHIVE_ENTRY_ACL_OTHER) return (0);
break;
}
@@ -173,33 +225,42 @@ acl_match(acl_entry_t aclent, struct myacl_t *myacl)
}
static void
-compare_acls(acl_t acl, struct myacl_t *myacls)
+#if HAVE_SUN_ACL
+compare_acls(acl_t *acl, struct archive_test_acl_t *myacls, int n)
+#else
+compare_acls(acl_t acl, struct archive_test_acl_t *myacls, int n)
+#endif
{
int *marker;
- int entry_id = ACL_FIRST_ENTRY;
int matched;
- int i, n;
+ int i;
+#if HAVE_SUN_ACL
+ int e;
+ aclent_t *acl_entry;
+#else
+ int entry_id = ACL_FIRST_ENTRY;
acl_entry_t acl_entry;
+#endif
/* Count ACL entries in myacls array and allocate an indirect array. */
- for (n = 0; myacls[n].name != NULL; ++n)
- continue;
- if (n) {
- marker = malloc(sizeof(marker[0]) * n);
- if (marker == NULL)
- return;
- for (i = 0; i < n; i++)
- marker[i] = i;
- } else
- marker = NULL;
+ marker = malloc(sizeof(marker[0]) * n);
+ if (marker == NULL)
+ return;
+ for (i = 0; i < n; i++)
+ marker[i] = i;
/*
* Iterate over acls in system acl object, try to match each
* one with an item in the myacls array.
*/
+#if HAVE_SUN_ACL
+ for(e = 0; e < acl->acl_cnt; e++) {
+ acl_entry = &((aclent_t *)acl->acl_aclp)[e];
+#else
while (1 == acl_get_entry(acl, entry_id, &acl_entry)) {
/* After the first time... */
entry_id = ACL_NEXT_ENTRY;
+#endif
/* Search for a matching entry (tag and qualifier) */
for (i = 0, matched = 0; i < n && !matched; i++) {
@@ -219,7 +280,7 @@ compare_acls(acl_t acl, struct myacl_t *myacls)
/* Dump entries in the myacls array that weren't in the system acl. */
for (i = 0; i < n; ++i) {
failure(" ACL entry missing from file: "
- "type=%d,permset=%d,tag=%d,qual=%d,name=``%s''\n",
+ "type=%#010x,permset=%#010x,tag=%d,qual=%d,name=``%s''\n",
myacls[marker[i]].type, myacls[marker[i]].permset,
myacls[marker[i]].tag, myacls[marker[i]].qual,
myacls[marker[i]].name);
@@ -232,30 +293,41 @@ compare_acls(acl_t acl, struct myacl_t *myacls)
/*
- * Verify ACL restore-to-disk. This test is FreeBSD-specific.
+ * Verify ACL restore-to-disk. This test is Platform-specific.
*/
-DEFINE_TEST(test_acl_freebsd_posix1e_restore)
+DEFINE_TEST(test_acl_platform_posix1e_restore)
{
-#if !defined(__FreeBSD__)
- skipping("FreeBSD-specific ACL restore test");
-#elif __FreeBSD__ < 5
- skipping("ACL restore supported only on FreeBSD 5.0 and later");
-#else
+#if !HAVE_SUN_ACL && !HAVE_POSIX_ACL
+ skipping("POSIX.1e ACLs are not supported on this platform");
+#else /* HAVE_SUN_ACL || HAVE_POSIX_ACL */
struct stat st;
struct archive *a;
struct archive_entry *ae;
int n, fd;
+ char *func;
+#if HAVE_SUN_ACL
+ acl_t *acl, *acl2;
+#else
acl_t acl;
+#endif
/*
* First, do a quick manual set/read of ACL data to
* verify that the local filesystem does support ACLs.
* If it doesn't, we'll simply skip the remaining tests.
*/
+#if HAVE_SUN_ACL
+ n = acl_fromtext("user::rwx,user:1:rw-,group::rwx,group:15:r-x,other:rwx,mask:rwx", &acl);
+ failure("acl_fromtext(): errno = %d (%s)", errno, strerror(errno));
+ assertEqualInt(0, n);
+#else
acl = acl_from_text("u::rwx,u:1:rw,g::rwx,g:15:rx,o::rwx,m::rwx");
+ failure("acl_from_text(): errno = %d (%s)", errno, strerror(errno));
assert((void *)acl != NULL);
- /* Create a test file and try to set an ACL on it. */
+#endif
+
+ /* Create a test file and try ACL on it. */
fd = open("pretest", O_WRONLY | O_CREAT | O_EXCL, 0777);
failure("Could not create test file?!");
if (!assert(fd >= 0)) {
@@ -263,21 +335,51 @@ DEFINE_TEST(test_acl_freebsd_posix1e_restore)
return;
}
- n = acl_set_fd(fd, acl);
- acl_free(acl);
- if (n != 0 && errno == EOPNOTSUPP) {
+#if HAVE_SUN_ACL
+ n = facl_get(fd, 0, &acl2);
+ if (n != 0) {
close(fd);
- skipping("ACL tests require that ACL support be enabled on the filesystem");
+ acl_free(acl);
+ }
+ if (errno == ENOSYS) {
+ skipping("POSIX.1e ACLs are not supported on this filesystem");
return;
}
- if (n != 0 && errno == EINVAL) {
- close(fd);
- skipping("This filesystem does not support POSIX.1e ACLs");
+ failure("facl_get(): errno = %d (%s)", errno, strerror(errno));
+ assertEqualInt(0, n);
+
+ if (acl2->acl_type != ACLENT_T) {
+ acl_free(acl2);
+ skipping("POSIX.1e ACLs are not supported on this filesystem");
return;
}
- failure("acl_set_fd(): errno = %d (%s)",
- errno, strerror(errno));
+ acl_free(acl2);
+
+ func = "facl_set()";
+ n = facl_set(fd, acl);
+#else
+ func = "acl_set_fd()";
+ n = acl_set_fd(fd, acl);
+#endif
+ acl_free(acl);
+ if (n != 0) {
+#if HAVE_SUN_ACL
+ if (errno == ENOSYS)
+#else
+ if (errno == EOPNOTSUPP || errno == EINVAL)
+#endif
+ {
+ close(fd);
+ skipping("POSIX.1e ACLs are not supported on this filesystem");
+ return;
+ }
+ }
+ failure("%s: errno = %d (%s)", func, errno, strerror(errno));
assertEqualInt(0, n);
+
+#if HAVE_SUN_ACL
+
+#endif
close(fd);
/* Create a write-to-disk object. */
@@ -291,7 +393,7 @@ DEFINE_TEST(test_acl_freebsd_posix1e_restore)
archive_entry_set_pathname(ae, "test0");
archive_entry_set_mtime(ae, 123456, 7890);
archive_entry_set_size(ae, 0);
- set_acls(ae, acls2);
+ archive_test_set_acls(ae, acls2, sizeof(acls2)/sizeof(acls2[0]));
assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
archive_entry_free(ae);
@@ -302,28 +404,38 @@ DEFINE_TEST(test_acl_freebsd_posix1e_restore)
/* Verify the data on disk. */
assertEqualInt(0, stat("test0", &st));
assertEqualInt(st.st_mtime, 123456);
+#if HAVE_SUN_ACL
+ n = acl_get("test0", 0, &acl);
+ failure("acl_get(): errno = %d (%s)", errno, strerror(errno));
+ assertEqualInt(0, n);
+#else
acl = acl_get_file("test0", ACL_TYPE_ACCESS);
+ failure("acl_get_file(): errno = %d (%s)", errno, strerror(errno));
assert(acl != (acl_t)NULL);
- compare_acls(acl, acls2);
- acl_free(acl);
#endif
+ compare_acls(acl, acls2, sizeof(acls2)/sizeof(acls2[0]));
+ acl_free(acl);
+#endif /* HAVE_SUN_ACL || HAVE_POSIX_ACL */
}
/*
- * Verify ACL reaed-from-disk. This test is FreeBSD-specific.
+ * Verify ACL read-from-disk. This test is Platform-specific.
*/
-DEFINE_TEST(test_acl_freebsd_posix1e_read)
+DEFINE_TEST(test_acl_platform_posix1e_read)
{
-#if !defined(__FreeBSD__)
- skipping("FreeBSD-specific ACL read test");
-#elif __FreeBSD__ < 5
- skipping("ACL read supported only on FreeBSD 5.0 and later");
+#if !HAVE_SUN_ACL && !HAVE_POSIX_ACL
+ skipping("POSIX.1e ACLs are not supported on this platform");
#else
struct archive *a;
struct archive_entry *ae;
- int n, fd;
- const char *acl1_text, *acl2_text;
- acl_t acl1, acl2;
+ int n, fd, flags, dflags;
+ char *func, *acl_text;
+ const char *acl1_text, *acl2_text, *acl3_text;
+#if HAVE_SUN_ACL
+ acl_t *acl, *acl1, *acl2, *acl3;
+#else
+ acl_t acl1, acl2, acl3;
+#endif
/*
* Manually construct a directory and two files with
@@ -332,30 +444,77 @@ DEFINE_TEST(test_acl_freebsd_posix1e_read)
*/
/* Create a test file f1 with acl1 */
- acl1_text = "user::rwx,group::rwx,other::rwx,user:1:rw-,group:15:r-x,mask::rwx";
+#if HAVE_SUN_ACL
+ acl1_text = "user::rwx,"
+ "group::rwx,"
+ "other:rwx,"
+ "user:1:rw-,"
+ "group:15:r-x,"
+ "mask:rwx";
+ n = acl_fromtext(acl1_text, &acl1);
+ failure("acl_fromtext(): errno = %d (%s)", errno, strerror(errno));
+ assertEqualInt(0, n);
+#else
+ acl1_text = "user::rwx\n"
+ "group::rwx\n"
+ "other::rwx\n"
+ "user:1:rw-\n"
+ "group:15:r-x\n"
+ "mask::rwx";
acl1 = acl_from_text(acl1_text);
+ failure("acl_from_text(): errno = %d (%s)", errno, strerror(errno));
assert((void *)acl1 != NULL);
+#endif
fd = open("f1", O_WRONLY | O_CREAT | O_EXCL, 0777);
failure("Could not create test file?!");
if (!assert(fd >= 0)) {
acl_free(acl1);
return;
}
- n = acl_set_fd(fd, acl1);
- acl_free(acl1);
- if (n != 0 && errno == EOPNOTSUPP) {
+#if HAVE_SUN_ACL
+ /* Check if Solaris filesystem supports POSIX.1e ACLs */
+ n = facl_get(fd, 0, &acl);
+ if (n != 0)
close(fd);
- skipping("ACL tests require that ACL support be enabled on the filesystem");
+ if (n != 0 && errno == ENOSYS) {
+ acl_free(acl1);
+ skipping("POSIX.1e ACLs are not supported on this filesystem");
return;
}
- if (n != 0 && errno == EINVAL) {
+ failure("facl_get(): errno = %d (%s)", errno, strerror(errno));
+ assertEqualInt(0, n);
+
+ if (acl->acl_type != ACLENT_T) {
+ acl_free(acl);
+ acl_free(acl1);
close(fd);
- skipping("This filesystem does not support POSIX.1e ACLs");
+ skipping("POSIX.1e ACLs are not supported on this filesystem");
return;
}
- failure("acl_set_fd(): errno = %d (%s)",
- errno, strerror(errno));
+
+ func = "facl_set()";
+ n = facl_set(fd, acl1);
+#else
+ func = "acl_set_fd()";
+ n = acl_set_fd(fd, acl1);
+#endif
+ acl_free(acl1);
+
+ if (n != 0) {
+#if HAVE_SUN_ACL
+ if (errno == ENOSYS)
+#else
+ if (errno == EOPNOTSUPP || errno == EINVAL)
+#endif
+ {
+ close(fd);
+ skipping("POSIX.1e ACLs are not supported on this filesystem");
+ return;
+ }
+ }
+ failure("%s: errno = %d (%s)", func, errno, strerror(errno));
assertEqualInt(0, n);
+
close(fd);
assertMakeDir("d", 0700);
@@ -371,48 +530,124 @@ DEFINE_TEST(test_acl_freebsd_posix1e_read)
* to read ACLs, resulting in reading the ACL from a like-named
* file in the wrong directory.
*/
- acl2_text = "user::rwx,group::rwx,other::---,user:1:r--,group:15:r--,mask::rwx";
+#if HAVE_SUN_ACL
+ acl2_text = "user::rwx,"
+ "group::rwx,"
+ "other:---,"
+ "user:1:r--,"
+ "group:15:r--,"
+ "mask:rwx";
+ n = acl_fromtext(acl2_text, &acl2);
+ failure("acl_fromtext(): errno = %d (%s)", errno, strerror(errno));
+ assertEqualInt(0, n);
+#else
+ acl2_text = "user::rwx\n"
+ "group::rwx\n"
+ "other::---\n"
+ "user:1:r--\n"
+ "group:15:r--\n"
+ "mask::rwx";
acl2 = acl_from_text(acl2_text);
+ failure("acl_from_text(): errno = %d (%s)", errno, strerror(errno));
assert((void *)acl2 != NULL);
+#endif
fd = open("d/f1", O_WRONLY | O_CREAT | O_EXCL, 0777);
failure("Could not create test file?!");
if (!assert(fd >= 0)) {
acl_free(acl2);
return;
}
+#if HAVE_SUN_ACL
+ func = "facl_set()";
+ n = facl_set(fd, acl2);
+#else
+ func = "acl_set_fd()";
n = acl_set_fd(fd, acl2);
+#endif
acl_free(acl2);
- if (n != 0 && errno == EOPNOTSUPP) {
+ if (n != 0)
close(fd);
- skipping("ACL tests require that ACL support be enabled on the filesystem");
- return;
- }
- if (n != 0 && errno == EINVAL) {
- close(fd);
- skipping("This filesystem does not support POSIX.1e ACLs");
- return;
- }
- failure("acl_set_fd(): errno = %d (%s)",
- errno, strerror(errno));
+ failure("%s: errno = %d (%s)", func, errno, strerror(errno));
assertEqualInt(0, n);
close(fd);
+ /* Create directory d2 with default ACLs */
+ assertMakeDir("d2", 0755);
+
+#if HAVE_SUN_ACL
+ acl3_text = "user::rwx,"
+ "group::r-x,"
+ "other:r-x,"
+ "user:2:r--,"
+ "group:16:-w-,"
+ "mask:rwx,"
+ "default:user::rwx,"
+ "default:user:1:r--,"
+ "default:group::r-x,"
+ "default:group:15:r--,"
+ "default:mask:rwx,"
+ "default:other:r-x";
+ n = acl_fromtext(acl3_text, &acl3);
+ failure("acl_fromtext(): errno = %d (%s)", errno, strerror(errno));
+ assertEqualInt(0, n);
+#else
+ acl3_text = "user::rwx\n"
+ "user:1:r--\n"
+ "group::r-x\n"
+ "group:15:r--\n"
+ "mask::rwx\n"
+ "other::r-x";
+ acl3 = acl_from_text(acl3_text);
+ failure("acl_from_text(): errno = %d (%s)", errno, strerror(errno));
+ assert((void *)acl3 != NULL);
+#endif
+
+#if HAVE_SUN_ACL
+ func = "acl_set()";
+ n = acl_set("d2", acl3);
+#else
+ func = "acl_set_file()";
+ n = acl_set_file("d2", ACL_TYPE_DEFAULT, acl3);
+#endif
+ acl_free(acl3);
+
+ failure("%s: errno = %d (%s)", func, errno, strerror(errno));
+ assertEqualInt(0, n);
+
/* Create a read-from-disk object. */
assert(NULL != (a = archive_read_disk_new()));
assertEqualIntA(a, ARCHIVE_OK, archive_read_disk_open(a, "."));
assert(NULL != (ae = archive_entry_new()));
+#if HAVE_SUN_ACL
+ flags = ARCHIVE_ENTRY_ACL_TYPE_POSIX1E
+ | ARCHIVE_ENTRY_ACL_STYLE_SEPARATOR_COMMA
+ | ARCHIVE_ENTRY_ACL_STYLE_SOLARIS;
+ dflags = flags;
+#else
+ flags = ARCHIVE_ENTRY_ACL_TYPE_ACCESS;
+ dflags = ARCHIVE_ENTRY_ACL_TYPE_DEFAULT;
+#endif
+
/* Walk the dir until we see both of the files */
while (ARCHIVE_OK == archive_read_next_header2(a, ae)) {
archive_read_disk_descend(a);
if (strcmp(archive_entry_pathname(ae), "./f1") == 0) {
- assertEqualString(archive_entry_acl_text(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS), acl1_text);
-
+ acl_text = archive_entry_acl_to_text(ae, NULL, flags);
+ assertEqualString(acl_text, acl1_text);
+ free(acl_text);
} else if (strcmp(archive_entry_pathname(ae), "./d/f1") == 0) {
- assertEqualString(archive_entry_acl_text(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS), acl2_text);
+ acl_text = archive_entry_acl_to_text(ae, NULL, flags);
+ assertEqualString(acl_text, acl2_text);
+ free(acl_text);
+ } else if (strcmp(archive_entry_pathname(ae), "./d2") == 0) {
+ acl_text = archive_entry_acl_to_text(ae, NULL, dflags);
+ assertEqualString(acl_text, acl3_text);
+ free(acl_text);
}
}
- archive_free(a);
+ archive_entry_free(ae);
+ assertEqualInt(ARCHIVE_OK, archive_free(a));
#endif
}
diff --git a/contrib/libarchive/libarchive/test/test_acl_posix1e.c b/contrib/libarchive/libarchive/test/test_acl_posix1e.c
index 9984d44..01167da 100644
--- a/contrib/libarchive/libarchive/test/test_acl_posix1e.c
+++ b/contrib/libarchive/libarchive/test/test_acl_posix1e.c
@@ -27,21 +27,14 @@ __FBSDID("$FreeBSD: src/lib/libarchive/test/test_acl_basic.c,v 1.6 2008/10/19 00
/*
* Exercise the system-independent portion of the ACL support.
- * Check that archive_entry objects can save and restore POSIX.1e-style ACL data.
+ * Check that archive_entry objects can save and restore POSIX.1e-style
+ * ACL data.
*
* This should work on all systems, regardless of whether local
* filesystems support ACLs or not.
*/
-struct acl_t {
- int type; /* Type of ACL: "access" or "default" */
- int permset; /* Permissions for this class of users. */
- int tag; /* Owner, User, Owning group, group, other, etc. */
- int qual; /* GID or UID of user/group, depending on tag. */
- const char *name; /* Name of user/group, depending on tag. */
-};
-
-static struct acl_t acls0[] = {
+static struct archive_test_acl_t acls0[] = {
{ ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_EXECUTE,
ARCHIVE_ENTRY_ACL_USER_OBJ, 0, "" },
{ ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ,
@@ -50,7 +43,7 @@ static struct acl_t acls0[] = {
ARCHIVE_ENTRY_ACL_OTHER, 0, "" },
};
-static struct acl_t acls1[] = {
+static struct archive_test_acl_t acls1[] = {
{ ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_EXECUTE,
ARCHIVE_ENTRY_ACL_USER_OBJ, -1, "" },
{ ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ,
@@ -61,7 +54,7 @@ static struct acl_t acls1[] = {
ARCHIVE_ENTRY_ACL_OTHER, -1, "" },
};
-static struct acl_t acls2[] = {
+static struct archive_test_acl_t acls2[] = {
{ ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_EXECUTE | ARCHIVE_ENTRY_ACL_READ,
ARCHIVE_ENTRY_ACL_USER_OBJ, -1, "" },
{ ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ,
@@ -80,7 +73,7 @@ static struct acl_t acls2[] = {
* NFS4 entry types; attempts to set these on top of POSIX.1e
* attributes should fail.
*/
-static struct acl_t acls_nfs4[] = {
+static struct archive_test_acl_t acls_nfs4[] = {
/* NFS4 types */
{ ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_READ,
ARCHIVE_ENTRY_ACL_USER, 78, "" },
@@ -104,106 +97,6 @@ static struct acl_t acls_nfs4[] = {
ARCHIVE_ENTRY_ACL_USER_OBJ, -1, "" },
};
-static void
-set_acls(struct archive_entry *ae, struct acl_t *acls, int n)
-{
- int i;
-
- archive_entry_acl_clear(ae);
- for (i = 0; i < n; i++) {
- archive_entry_acl_add_entry(ae,
- acls[i].type, acls[i].permset, acls[i].tag, acls[i].qual,
- acls[i].name);
- }
-}
-
-static int
-acl_match(struct acl_t *acl, int type, int permset, int tag, int qual, const char *name)
-{
- if (type != acl->type)
- return (0);
- if (permset != acl->permset)
- return (0);
- if (tag != acl->tag)
- return (0);
- if (tag == ARCHIVE_ENTRY_ACL_USER_OBJ)
- return (1);
- if (tag == ARCHIVE_ENTRY_ACL_GROUP_OBJ)
- return (1);
- if (tag == ARCHIVE_ENTRY_ACL_OTHER)
- return (1);
- if (qual != acl->qual)
- return (0);
- if (name == NULL) {
- if (acl->name == NULL || acl->name[0] == '\0')
- return (1);
- return (0);
- }
- if (acl->name == NULL) {
- if (name[0] == '\0')
- return (1);
- return (0);
- }
- return (0 == strcmp(name, acl->name));
-}
-
-static void
-compare_acls(struct archive_entry *ae, struct acl_t *acls, int n, int mode)
-{
- int *marker = malloc(sizeof(marker[0]) * n);
- int i;
- int r;
- int type, permset, tag, qual;
- int matched;
- const char *name;
-
- for (i = 0; i < n; i++)
- marker[i] = i;
-
- while (0 == (r = archive_entry_acl_next(ae,
- ARCHIVE_ENTRY_ACL_TYPE_ACCESS,
- &type, &permset, &tag, &qual, &name))) {
- for (i = 0, matched = 0; i < n && !matched; i++) {
- if (acl_match(&acls[marker[i]], type, permset,
- tag, qual, name)) {
- /* We found a match; remove it. */
- marker[i] = marker[n - 1];
- n--;
- matched = 1;
- }
- }
- if (tag == ARCHIVE_ENTRY_ACL_USER_OBJ) {
- if (!matched) printf("No match for user_obj perm\n");
- failure("USER_OBJ permset (%02o) != user mode (%02o)",
- permset, 07 & (mode >> 6));
- assert((permset << 6) == (mode & 0700));
- } else if (tag == ARCHIVE_ENTRY_ACL_GROUP_OBJ) {
- if (!matched) printf("No match for group_obj perm\n");
- failure("GROUP_OBJ permset %02o != group mode %02o",
- permset, 07 & (mode >> 3));
- assert((permset << 3) == (mode & 0070));
- } else if (tag == ARCHIVE_ENTRY_ACL_OTHER) {
- if (!matched) printf("No match for other perm\n");
- failure("OTHER permset (%02o) != other mode (%02o)",
- permset, mode & 07);
- assert((permset << 0) == (mode & 0007));
- } else {
- failure("Could not find match for ACL "
- "(type=%d,permset=%d,tag=%d,qual=%d,name=``%s'')",
- type, permset, tag, qual, name);
- assert(matched == 1);
- }
- }
- assertEqualInt(ARCHIVE_EOF, r);
- assert((mode_t)(mode & 0777) == (archive_entry_mode(ae) & 0777));
- failure("Could not find match for ACL "
- "(type=%d,permset=%d,tag=%d,qual=%d,name=``%s'')",
- acls[marker[0]].type, acls[marker[0]].permset,
- acls[marker[0]].tag, acls[marker[0]].qual, acls[marker[0]].name);
- assert(n == 0); /* Number of ACLs not matched should == 0 */
- free(marker);
-}
-
DEFINE_TEST(test_acl_posix1e)
{
struct archive_entry *ae;
@@ -223,7 +116,7 @@ DEFINE_TEST(test_acl_posix1e)
* triggering unnecessary extensions. It's better to identify
* trivial ACLs at the point they are being read from disk.
*/
- set_acls(ae, acls0, sizeof(acls0)/sizeof(acls0[0]));
+ archive_test_set_acls(ae, acls0, sizeof(acls0)/sizeof(acls0[0]));
failure("Basic ACLs shouldn't be stored as extended ACLs");
assert(0 == archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS));
failure("Basic ACLs should set mode to 0142, not %04o",
@@ -232,19 +125,28 @@ DEFINE_TEST(test_acl_posix1e)
/* With any extended ACL entry, we should read back a full set. */
- set_acls(ae, acls1, sizeof(acls1)/sizeof(acls1[0]));
+ archive_test_set_acls(ae, acls1, sizeof(acls1)/sizeof(acls1[0]));
failure("One extended ACL should flag all ACLs to be returned.");
+
+ /* Check that entry contains only POSIX.1e types */
+ assert((archive_entry_acl_types(ae) &
+ ARCHIVE_ENTRY_ACL_TYPE_NFS4) == 0);
+ assert((archive_entry_acl_types(ae) &
+ ARCHIVE_ENTRY_ACL_TYPE_POSIX1E) != 0);
+
assert(4 == archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS));
- compare_acls(ae, acls1, sizeof(acls1)/sizeof(acls1[0]), 0142);
+ archive_test_compare_acls(ae, acls1, sizeof(acls1)/sizeof(acls1[0]),
+ ARCHIVE_ENTRY_ACL_TYPE_ACCESS, 0142);
failure("Basic ACLs should set mode to 0142, not %04o",
archive_entry_mode(ae)&0777);
assert((archive_entry_mode(ae) & 0777) == 0142);
/* A more extensive set of ACLs. */
- set_acls(ae, acls2, sizeof(acls2)/sizeof(acls2[0]));
+ archive_test_set_acls(ae, acls2, sizeof(acls2)/sizeof(acls2[0]));
assertEqualInt(6, archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS));
- compare_acls(ae, acls2, sizeof(acls2)/sizeof(acls2[0]), 0543);
+ archive_test_compare_acls(ae, acls2, sizeof(acls2)/sizeof(acls2[0]),
+ ARCHIVE_ENTRY_ACL_TYPE_ACCESS, 0543);
failure("Basic ACLs should set mode to 0543, not %04o",
archive_entry_mode(ae)&0777);
assert((archive_entry_mode(ae) & 0777) == 0543);
@@ -253,7 +155,7 @@ DEFINE_TEST(test_acl_posix1e)
* Check that clearing ACLs gets rid of them all by repeating
* the first test.
*/
- set_acls(ae, acls0, sizeof(acls0)/sizeof(acls0[0]));
+ archive_test_set_acls(ae, acls0, sizeof(acls0)/sizeof(acls0[0]));
failure("Basic ACLs shouldn't be stored as extended ACLs");
assert(0 == archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS));
failure("Basic ACLs should set mode to 0142, not %04o",
@@ -264,9 +166,9 @@ DEFINE_TEST(test_acl_posix1e)
* Different types of malformed ACL entries that should
* fail when added to existing POSIX.1e ACLs.
*/
- set_acls(ae, acls2, sizeof(acls2)/sizeof(acls2[0]));
+ archive_test_set_acls(ae, acls2, sizeof(acls2)/sizeof(acls2[0]));
for (i = 0; i < (int)(sizeof(acls_nfs4)/sizeof(acls_nfs4[0])); ++i) {
- struct acl_t *p = &acls_nfs4[i];
+ struct archive_test_acl_t *p = &acls_nfs4[i];
failure("Malformed ACL test #%d", i);
assertEqualInt(ARCHIVE_FAILED,
archive_entry_acl_add_entry(ae,
diff --git a/contrib/libarchive/libarchive/test/test_acl_text.c b/contrib/libarchive/libarchive/test/test_acl_text.c
new file mode 100644
index 0000000..f3d2b10
--- /dev/null
+++ b/contrib/libarchive/libarchive/test/test_acl_text.c
@@ -0,0 +1,473 @@
+/*-
+ * Copyright (c) 2016 Martin Matuska
+ * 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 AUTHOR(S) ``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(S) 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.
+ */
+#include "test.h"
+__FBSDID("$FreeBSD$");
+
+/*
+ * Test converting ACLs to text, both wide and non-wide
+ *
+ * This should work on all systems, regardless of whether local
+ * filesystems support ACLs or not.
+ */
+
+static struct archive_test_acl_t acls0[] = {
+ { ARCHIVE_ENTRY_ACL_TYPE_ACCESS,
+ ARCHIVE_ENTRY_ACL_EXECUTE |
+ ARCHIVE_ENTRY_ACL_READ |
+ ARCHIVE_ENTRY_ACL_WRITE,
+ ARCHIVE_ENTRY_ACL_USER_OBJ, -1, "" },
+ { ARCHIVE_ENTRY_ACL_TYPE_ACCESS,
+ ARCHIVE_ENTRY_ACL_EXECUTE |
+ ARCHIVE_ENTRY_ACL_READ,
+ ARCHIVE_ENTRY_ACL_USER, 100, "user100" },
+ { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, 0,
+ ARCHIVE_ENTRY_ACL_USER, 1000, "user1000" },
+ { ARCHIVE_ENTRY_ACL_TYPE_ACCESS,
+ ARCHIVE_ENTRY_ACL_EXECUTE |
+ ARCHIVE_ENTRY_ACL_READ,
+ ARCHIVE_ENTRY_ACL_GROUP_OBJ, -1, "" },
+ { ARCHIVE_ENTRY_ACL_TYPE_ACCESS,
+ ARCHIVE_ENTRY_ACL_EXECUTE |
+ ARCHIVE_ENTRY_ACL_READ |
+ ARCHIVE_ENTRY_ACL_WRITE,
+ ARCHIVE_ENTRY_ACL_GROUP, 78, "group78" },
+ { ARCHIVE_ENTRY_ACL_TYPE_ACCESS,
+ ARCHIVE_ENTRY_ACL_READ |
+ ARCHIVE_ENTRY_ACL_EXECUTE,
+ ARCHIVE_ENTRY_ACL_OTHER, -1, "" },
+ { ARCHIVE_ENTRY_ACL_TYPE_DEFAULT,
+ ARCHIVE_ENTRY_ACL_EXECUTE |
+ ARCHIVE_ENTRY_ACL_READ,
+ ARCHIVE_ENTRY_ACL_USER_OBJ, -1, "" },
+ { ARCHIVE_ENTRY_ACL_TYPE_DEFAULT,
+ ARCHIVE_ENTRY_ACL_EXECUTE |
+ ARCHIVE_ENTRY_ACL_READ,
+ ARCHIVE_ENTRY_ACL_GROUP_OBJ, -1, "" },
+ { ARCHIVE_ENTRY_ACL_TYPE_DEFAULT, 0,
+ ARCHIVE_ENTRY_ACL_OTHER, -1, "" },
+ { ARCHIVE_ENTRY_ACL_TYPE_DEFAULT,
+ ARCHIVE_ENTRY_ACL_EXECUTE |
+ ARCHIVE_ENTRY_ACL_READ,
+ ARCHIVE_ENTRY_ACL_USER, 101, "user101"},
+ { ARCHIVE_ENTRY_ACL_TYPE_DEFAULT,
+ ARCHIVE_ENTRY_ACL_EXECUTE,
+ ARCHIVE_ENTRY_ACL_GROUP, 79, "group79" },
+};
+
+static struct archive_test_acl_t acls1[] = {
+ { ARCHIVE_ENTRY_ACL_TYPE_ALLOW,
+ ARCHIVE_ENTRY_ACL_READ_DATA |
+ ARCHIVE_ENTRY_ACL_WRITE_DATA |
+ ARCHIVE_ENTRY_ACL_APPEND_DATA |
+ ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES |
+ ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS |
+ ARCHIVE_ENTRY_ACL_READ_ACL |
+ ARCHIVE_ENTRY_ACL_WRITE_OWNER,
+ ARCHIVE_ENTRY_ACL_USER, 77, "user77" },
+ { ARCHIVE_ENTRY_ACL_TYPE_DENY,
+ ARCHIVE_ENTRY_ACL_WRITE_DATA |
+ ARCHIVE_ENTRY_ACL_APPEND_DATA |
+ ARCHIVE_ENTRY_ACL_DELETE_CHILD |
+ ARCHIVE_ENTRY_ACL_DELETE |
+ ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT |
+ ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT |
+ ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY |
+ ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT,
+ ARCHIVE_ENTRY_ACL_USER, 101, "user101" },
+ { ARCHIVE_ENTRY_ACL_TYPE_ALLOW,
+ ARCHIVE_ENTRY_ACL_READ_DATA |
+ ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES |
+ ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS |
+ ARCHIVE_ENTRY_ACL_READ_ACL |
+ ARCHIVE_ENTRY_ACL_ENTRY_INHERITED,
+ ARCHIVE_ENTRY_ACL_GROUP, 78, "group78" },
+ { ARCHIVE_ENTRY_ACL_TYPE_ALLOW,
+ ARCHIVE_ENTRY_ACL_READ_DATA |
+ ARCHIVE_ENTRY_ACL_WRITE_DATA |
+ ARCHIVE_ENTRY_ACL_EXECUTE |
+ ARCHIVE_ENTRY_ACL_APPEND_DATA |
+ ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES |
+ ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES |
+ ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS |
+ ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS |
+ ARCHIVE_ENTRY_ACL_READ_ACL |
+ ARCHIVE_ENTRY_ACL_WRITE_ACL |
+ ARCHIVE_ENTRY_ACL_WRITE_OWNER,
+ ARCHIVE_ENTRY_ACL_USER_OBJ, 0, "" },
+ { ARCHIVE_ENTRY_ACL_TYPE_ALLOW,
+ ARCHIVE_ENTRY_ACL_READ_DATA |
+ ARCHIVE_ENTRY_ACL_WRITE_DATA |
+ ARCHIVE_ENTRY_ACL_APPEND_DATA |
+ ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES |
+ ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS |
+ ARCHIVE_ENTRY_ACL_READ_ACL,
+ ARCHIVE_ENTRY_ACL_GROUP_OBJ, 0, "" },
+ { ARCHIVE_ENTRY_ACL_TYPE_ALLOW,
+ ARCHIVE_ENTRY_ACL_READ_DATA |
+ ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES |
+ ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS |
+ ARCHIVE_ENTRY_ACL_READ_ACL |
+ ARCHIVE_ENTRY_ACL_SYNCHRONIZE,
+ ARCHIVE_ENTRY_ACL_EVERYONE, 0, "" },
+};
+
+const char* acltext[] = {
+ "user::rwx\n"
+ "group::r-x\n"
+ "other::r-x\n"
+ "user:user100:r-x\n"
+ "user:user1000:---\n"
+ "group:group78:rwx\n"
+ "default:user::r-x\n"
+ "default:group::r-x\n"
+ "default:other::---\n"
+ "default:user:user101:r-x\n"
+ "default:group:group79:--x",
+
+ "user::rwx\n"
+ "group::r-x\n"
+ "other::r-x\n"
+ "user:user100:r-x:100\n"
+ "user:user1000:---:1000\n"
+ "group:group78:rwx:78\n"
+ "default:user::r-x\n"
+ "default:group::r-x\n"
+ "default:other::---\n"
+ "default:user:user101:r-x:101\n"
+ "default:group:group79:--x:79",
+
+ "u::rwx\n"
+ "g::r-x\n"
+ "o::r-x\n"
+ "u:user100:r-x:100\n"
+ "u:user1000:---:1000\n"
+ "g:group78:rwx:78\n"
+ "d:user::r-x\n"
+ "d:group::r-x\n"
+ "d:other::---\n"
+ "d:user:user101:r-x:101\n"
+ "d:group:group79:--x:79",
+
+ "user::rwx\n"
+ "group::r-x\n"
+ "other::r-x\n"
+ "user:user100:r-x\n"
+ "user:user1000:---\n"
+ "group:group78:rwx",
+
+ "user::rwx,"
+ "group::r-x,"
+ "other::r-x,"
+ "user:user100:r-x,"
+ "user:user1000:---,"
+ "group:group78:rwx",
+
+ "user::rwx\n"
+ "group::r-x\n"
+ "other::r-x\n"
+ "user:user100:r-x:100\n"
+ "user:user1000:---:1000\n"
+ "group:group78:rwx:78",
+
+ "user::r-x\n"
+ "group::r-x\n"
+ "other::---\n"
+ "user:user101:r-x\n"
+ "group:group79:--x",
+
+ "user::r-x\n"
+ "group::r-x\n"
+ "other::---\n"
+ "user:user101:r-x:101\n"
+ "group:group79:--x:79",
+
+ "default:user::r-x\n"
+ "default:group::r-x\n"
+ "default:other::---\n"
+ "default:user:user101:r-x\n"
+ "default:group:group79:--x",
+
+ "user:user77:rw-p--a-R-c-o-:-------:allow\n"
+ "user:user101:-w-pdD--------:fdin---:deny\n"
+ "group:group78:r-----a-R-c---:------I:allow\n"
+ "owner@:rwxp--aARWcCo-:-------:allow\n"
+ "group@:rw-p--a-R-c---:-------:allow\n"
+ "everyone@:r-----a-R-c--s:-------:allow",
+
+ "user:user77:rw-p--a-R-c-o-:-------:allow:77\n"
+ "user:user101:-w-pdD--------:fdin---:deny:101\n"
+ "group:group78:r-----a-R-c---:------I:allow:78\n"
+ "owner@:rwxp--aARWcCo-:-------:allow\n"
+ "group@:rw-p--a-R-c---:-------:allow\n"
+ "everyone@:r-----a-R-c--s:-------:allow",
+
+ "user:user77:rwpaRco::allow:77\n"
+ "user:user101:wpdD:fdin:deny:101\n"
+ "group:group78:raRc:I:allow:78\n"
+ "owner@:rwxpaARWcCo::allow\n"
+ "group@:rwpaRc::allow\n"
+ "everyone@:raRcs::allow"
+};
+
+static wchar_t *
+convert_s_to_ws(const char *s)
+{
+ size_t len;
+ wchar_t *ws = NULL;
+
+ if (s != NULL) {
+ len = strlen(s) + 1;
+ ws = malloc(len * sizeof(wchar_t));
+ assert(mbstowcs(ws, s, len) != (size_t)-1);
+ }
+
+ return (ws);
+}
+
+static void
+compare_acl_text(struct archive_entry *ae, int flags, const char *s)
+{
+ char *text;
+ wchar_t *wtext;
+ wchar_t *ws;
+ ssize_t slen;
+
+ ws = convert_s_to_ws(s);
+
+ text = archive_entry_acl_to_text(ae, &slen, flags);
+ assertEqualString(text, s);
+ if (text != NULL)
+ assertEqualInt(strlen(text), slen);
+ wtext = archive_entry_acl_to_text_w(ae, &slen, flags);
+ assertEqualWString(wtext, ws);
+ if (wtext != NULL) {
+ assertEqualInt(wcslen(wtext), slen);
+ }
+ free(text);
+ free(wtext);
+ free(ws);
+}
+
+DEFINE_TEST(test_acl_from_text)
+{
+ struct archive_entry *ae;
+ wchar_t *ws = NULL;
+
+ /* Create an empty archive_entry. */
+ assert((ae = archive_entry_new()) != NULL);
+
+ /* 1a. Read POSIX.1e access ACLs from text */
+ assertEqualInt(ARCHIVE_OK,
+ archive_entry_acl_from_text(ae, acltext[5],
+ ARCHIVE_ENTRY_ACL_TYPE_ACCESS));
+ archive_test_compare_acls(ae, acls0, sizeof(acls0)/sizeof(acls0[0]),
+ ARCHIVE_ENTRY_ACL_TYPE_ACCESS, 0755);
+ assertEqualInt(6, archive_entry_acl_reset(ae,
+ ARCHIVE_ENTRY_ACL_TYPE_ACCESS));
+
+ /* 1b. Now read POSIX.1e default ACLs and append them */
+ assertEqualInt(ARCHIVE_OK,
+ archive_entry_acl_from_text(ae, acltext[7],
+ ARCHIVE_ENTRY_ACL_TYPE_DEFAULT));
+ archive_test_compare_acls(ae, acls0, sizeof(acls0)/sizeof(acls0[0]),
+ ARCHIVE_ENTRY_ACL_TYPE_POSIX1E, 0755);
+ assertEqualInt(11, archive_entry_acl_reset(ae,
+ ARCHIVE_ENTRY_ACL_TYPE_POSIX1E));
+ archive_entry_acl_clear(ae);
+
+ /* 1a and 1b with wide strings */
+ ws = convert_s_to_ws(acltext[5]);
+
+ assertEqualInt(ARCHIVE_OK,
+ archive_entry_acl_from_text_w(ae, ws,
+ ARCHIVE_ENTRY_ACL_TYPE_ACCESS));
+ archive_test_compare_acls(ae, acls0, sizeof(acls0)/sizeof(acls0[0]),
+ ARCHIVE_ENTRY_ACL_TYPE_ACCESS, 0755);
+ assertEqualInt(6, archive_entry_acl_reset(ae,
+ ARCHIVE_ENTRY_ACL_TYPE_ACCESS));
+
+ free(ws);
+ ws = convert_s_to_ws(acltext[7]);
+
+ assertEqualInt(ARCHIVE_OK,
+ archive_entry_acl_from_text_w(ae, ws,
+ ARCHIVE_ENTRY_ACL_TYPE_DEFAULT));
+ archive_test_compare_acls(ae, acls0, sizeof(acls0)/sizeof(acls0[0]),
+ ARCHIVE_ENTRY_ACL_TYPE_POSIX1E, 0755);
+ assertEqualInt(11, archive_entry_acl_reset(ae,
+ ARCHIVE_ENTRY_ACL_TYPE_POSIX1E));
+ archive_entry_acl_clear(ae);
+
+ /* 2. Read POSIX.1e default ACLs from text */
+ assertEqualInt(ARCHIVE_OK,
+ archive_entry_acl_from_text(ae, acltext[7],
+ ARCHIVE_ENTRY_ACL_TYPE_DEFAULT));
+ archive_test_compare_acls(ae, acls0, sizeof(acls0)/sizeof(acls0[0]),
+ ARCHIVE_ENTRY_ACL_TYPE_DEFAULT, 0);
+ assertEqualInt(5, archive_entry_acl_reset(ae,
+ ARCHIVE_ENTRY_ACL_TYPE_DEFAULT));
+ archive_entry_acl_clear(ae);
+
+ /* ws is still acltext[7] */
+ assertEqualInt(ARCHIVE_OK,
+ archive_entry_acl_from_text_w(ae, ws,
+ ARCHIVE_ENTRY_ACL_TYPE_DEFAULT));
+ archive_test_compare_acls(ae, acls0, sizeof(acls0)/sizeof(acls0[0]),
+ ARCHIVE_ENTRY_ACL_TYPE_DEFAULT, 0);
+ assertEqualInt(5, archive_entry_acl_reset(ae,
+ ARCHIVE_ENTRY_ACL_TYPE_DEFAULT));
+ archive_entry_acl_clear(ae);
+
+ /* 3. Read POSIX.1e access and default ACLs from text */
+ assertEqualInt(ARCHIVE_OK,
+ archive_entry_acl_from_text(ae, acltext[1],
+ ARCHIVE_ENTRY_ACL_TYPE_POSIX1E));
+ archive_test_compare_acls(ae, acls0, sizeof(acls0)/sizeof(acls0[0]),
+ ARCHIVE_ENTRY_ACL_TYPE_POSIX1E, 0755);
+ assertEqualInt(11, archive_entry_acl_reset(ae,
+ ARCHIVE_ENTRY_ACL_TYPE_POSIX1E));
+ archive_entry_acl_clear(ae);
+
+ free(ws);
+ ws = convert_s_to_ws(acltext[1]);
+ assertEqualInt(ARCHIVE_OK,
+ archive_entry_acl_from_text_w(ae, ws,
+ ARCHIVE_ENTRY_ACL_TYPE_POSIX1E));
+ archive_test_compare_acls(ae, acls0, sizeof(acls0)/sizeof(acls0[0]),
+ ARCHIVE_ENTRY_ACL_TYPE_POSIX1E, 0755);
+ assertEqualInt(11, archive_entry_acl_reset(ae,
+ ARCHIVE_ENTRY_ACL_TYPE_POSIX1E));
+ archive_entry_acl_clear(ae);
+
+ /* 4. Read POSIX.1e access and default ACLs from text (short form) */
+ assertEqualInt(ARCHIVE_OK,
+ archive_entry_acl_from_text(ae, acltext[2],
+ ARCHIVE_ENTRY_ACL_TYPE_POSIX1E));
+ archive_test_compare_acls(ae, acls0, sizeof(acls0)/sizeof(acls0[0]),
+ ARCHIVE_ENTRY_ACL_TYPE_POSIX1E, 0755);
+ assertEqualInt(11, archive_entry_acl_reset(ae,
+ ARCHIVE_ENTRY_ACL_TYPE_POSIX1E));
+ archive_entry_acl_clear(ae);
+
+ free(ws);
+ ws = convert_s_to_ws(acltext[2]);
+ assertEqualInt(ARCHIVE_OK,
+ archive_entry_acl_from_text_w(ae, ws,
+ ARCHIVE_ENTRY_ACL_TYPE_POSIX1E));
+ archive_test_compare_acls(ae, acls0, sizeof(acls0)/sizeof(acls0[0]),
+ ARCHIVE_ENTRY_ACL_TYPE_POSIX1E, 0755);
+ assertEqualInt(11, archive_entry_acl_reset(ae,
+ ARCHIVE_ENTRY_ACL_TYPE_POSIX1E));
+ archive_entry_acl_clear(ae);
+
+ /* 5. Read NFSv4 ACLs from text */
+ assertEqualInt(ARCHIVE_OK,
+ archive_entry_acl_from_text(ae, acltext[10],
+ ARCHIVE_ENTRY_ACL_TYPE_NFS4));
+ archive_test_compare_acls(ae, acls1, sizeof(acls1)/sizeof(acls1[0]),
+ ARCHIVE_ENTRY_ACL_TYPE_NFS4, 0);
+ assertEqualInt(6, archive_entry_acl_reset(ae,
+ ARCHIVE_ENTRY_ACL_TYPE_NFS4));
+ archive_entry_acl_clear(ae);
+
+ free(ws);
+ ws = convert_s_to_ws(acltext[10]);
+
+ assertEqualInt(ARCHIVE_OK,
+ archive_entry_acl_from_text_w(ae, ws,
+ ARCHIVE_ENTRY_ACL_TYPE_NFS4));
+ archive_test_compare_acls(ae, acls1, sizeof(acls1)/sizeof(acls1[0]),
+ ARCHIVE_ENTRY_ACL_TYPE_NFS4, 0);
+ assertEqualInt(6, archive_entry_acl_reset(ae,
+ ARCHIVE_ENTRY_ACL_TYPE_NFS4));
+ archive_entry_acl_clear(ae);
+
+ free(ws);
+ archive_entry_free(ae);
+}
+
+DEFINE_TEST(test_acl_to_text)
+{
+ struct archive_entry *ae;
+
+ /* Create an empty archive_entry. */
+ assert((ae = archive_entry_new()) != NULL);
+
+ /* Write POSIX.1e ACLs */
+ archive_test_set_acls(ae, acls0, sizeof(acls0)/sizeof(acls0[0]));
+
+ /* No flags should give output like getfacl(1) on linux */
+ compare_acl_text(ae, 0, acltext[0]);
+
+ /* This should give the same output as previous test */
+ compare_acl_text(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS |
+ ARCHIVE_ENTRY_ACL_TYPE_DEFAULT, acltext[0]);
+
+ /* This should give the same output as previous two tests */
+ compare_acl_text(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS |
+ ARCHIVE_ENTRY_ACL_TYPE_DEFAULT |
+ ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT, acltext[0]);
+
+ /* POSIX.1e access and default ACLs with appended ID */
+ compare_acl_text(ae, ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID, acltext[1]);
+
+ /* POSIX.1e access acls only, like getfacl(1) on FreeBSD */
+ compare_acl_text(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS, acltext[3]);
+
+ /* POSIX.1e access acls separated with comma */
+ compare_acl_text(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS |
+ ARCHIVE_ENTRY_ACL_STYLE_SEPARATOR_COMMA,
+ acltext[4]);
+
+ /* POSIX.1e access acls with appended user or group ID */
+ compare_acl_text(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS |
+ ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID, acltext[5]);
+
+ /* POSIX.1e default acls */
+ compare_acl_text(ae, ARCHIVE_ENTRY_ACL_TYPE_DEFAULT, acltext[6]);
+
+ /* POSIX.1e default acls with appended user or group ID */
+ compare_acl_text(ae, ARCHIVE_ENTRY_ACL_TYPE_DEFAULT |
+ ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID, acltext[7]);
+
+ /* POSIX.1e default acls prefixed with default: */
+ compare_acl_text(ae, ARCHIVE_ENTRY_ACL_TYPE_DEFAULT |
+ ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT, acltext[8]);
+
+ /* Write NFSv4 ACLs */
+ archive_test_set_acls(ae, acls1, sizeof(acls1)/sizeof(acls1[0]));
+
+ /* NFSv4 ACLs like getfacl(1) on FreeBSD */
+ compare_acl_text(ae, 0, acltext[9]);
+
+ /* NFSv4 ACLs like "getfacl -i" on FreeBSD */
+ compare_acl_text(ae, ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID, acltext[10]);
+
+ /* NFSv4 ACLs like "getfacl -i" on FreeBSD with stripped minus chars */
+ compare_acl_text(ae, ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID |
+ ARCHIVE_ENTRY_ACL_STYLE_COMPACT, acltext[11]);
+
+ archive_entry_free(ae);
+}
diff --git a/contrib/libarchive/libarchive/test/test_archive_read_add_passphrase.c b/contrib/libarchive/libarchive/test/test_archive_read_add_passphrase.c
index 68dec10..0ce5a76 100644
--- a/contrib/libarchive/libarchive/test/test_archive_read_add_passphrase.c
+++ b/contrib/libarchive/libarchive/test/test_archive_read_add_passphrase.c
@@ -191,7 +191,7 @@ DEFINE_TEST(test_archive_read_add_passphrase_set_callback3)
/* Fist call, we should get "passCallBack" as a passphrase. */
assertEqualString("passCallBack", __archive_read_next_passphrase(ar));
__archive_read_reset_passphrase(ar);
- /* After reset passphrase, we should get "passCallBack"passphrase. */
+ /* After reset passphrase, we should get "passCallBack" passphrase. */
assertEqualString("passCallBack", __archive_read_next_passphrase(ar));
/* Second call, we should get NULL which means all the passphrases
* are passed already. */
diff --git a/contrib/libarchive/libarchive/test/test_archive_string.c b/contrib/libarchive/libarchive/test/test_archive_string.c
index 9e3f907..7fa743b 100644
--- a/contrib/libarchive/libarchive/test/test_archive_string.c
+++ b/contrib/libarchive/libarchive/test/test_archive_string.c
@@ -67,6 +67,8 @@ test_archive_string_ensure(void)
assert(&s == archive_string_ensure(&s, EXTENT + 1));
assertNonNULLString(0, 2 * EXTENT, s);
+
+ archive_string_free(&s);
}
static void
@@ -92,6 +94,8 @@ test_archive_strcat(void)
/* non-empty target, non-empty source */
assert(&s == archive_strcat(&s, "baz"));
assertExactString(8, EXTENT, "fubarbaz", s);
+
+ archive_string_free(&s);
}
static void
@@ -109,6 +113,8 @@ test_archive_strappend_char(void)
/* non-empty target */
archive_strappend_char(&s, 'Y');
assertExactString(2, EXTENT, "XY", s);
+
+ archive_string_free(&s);
}
/* archive_strnXXX() tests focus on length handling.
@@ -134,6 +140,8 @@ test_archive_strncat(void)
/* long read is ok too! */
assert(&s == archive_strncat(&s, "snafu", 8));
assertExactString(13, EXTENT, "snafubarsnafu", s);
+
+ archive_string_free(&s);
}
static void
@@ -155,6 +163,8 @@ test_archive_strncpy(void)
/* long read is ok too! */
assert(&s == archive_strncpy(&s, "snafu", 8));
assertExactString(5, EXTENT, "snafu", s);
+
+ archive_string_free(&s);
}
static void
@@ -176,6 +186,8 @@ test_archive_strcpy(void)
/* dirty target, empty source */
assert(&s == archive_strcpy(&s, ""));
assertExactString(0, EXTENT, "", s);
+
+ archive_string_free(&s);
}
static void
@@ -222,6 +234,11 @@ test_archive_string_concat(void)
archive_string_concat(&t, &s);
assertExactString(5, EXTENT, "snafu", s);
assertExactString(5, EXTENT, "snafu", t);
+
+ archive_string_free(&v);
+ archive_string_free(&u);
+ archive_string_free(&t);
+ archive_string_free(&s);
}
static void
@@ -274,6 +291,11 @@ test_archive_string_copy(void)
archive_string_copy(&t, &s);
assertExactString(5, EXTENT, "fubar", s);
assertExactString(5, EXTENT, "fubar", t);
+
+ archive_string_free(&v);
+ archive_string_free(&u);
+ archive_string_free(&t);
+ archive_string_free(&s);
}
static void
@@ -328,6 +350,8 @@ test_archive_string_sprintf(void)
archive_string_empty(&s);
archive_string_sprintf(&s, "%d", 1234567890);
assertExactString(10, 8 * EXTENT, "1234567890", s);
+
+ archive_string_free(&s);
}
DEFINE_TEST(test_archive_string)
diff --git a/contrib/libarchive/libarchive/test/test_compat_gtar.c b/contrib/libarchive/libarchive/test/test_compat_gtar.c
index b33e6ab..975b824 100644
--- a/contrib/libarchive/libarchive/test/test_compat_gtar.c
+++ b/contrib/libarchive/libarchive/test/test_compat_gtar.c
@@ -142,6 +142,8 @@ test_compat_gtar_2(void)
assertEqualInt(archive_filter_code(a, 0), ARCHIVE_FILTER_NONE);
assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_GNUTAR);
+ assertEqualInt(ARCHIVE_OK, archive_read_close(a));
+ assertEqualInt(ARCHIVE_OK, archive_read_free(a));
}
DEFINE_TEST(test_compat_gtar)
diff --git a/contrib/libarchive/libarchive/test/test_compat_solaris_tar_acl.c b/contrib/libarchive/libarchive/test/test_compat_solaris_tar_acl.c
index d4654d0..3d063c1 100644
--- a/contrib/libarchive/libarchive/test/test_compat_solaris_tar_acl.c
+++ b/contrib/libarchive/libarchive/test/test_compat_solaris_tar_acl.c
@@ -1,5 +1,6 @@
/*-
* Copyright (c) 2003-2009 Tim Kientzle
+ * Copyright (c) 2016 Martin Matuska
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -26,101 +27,239 @@
__FBSDID("$FreeBSD$");
/*
- * Exercise support for reading Solaris-style ACL data
- * from tar archives.
+ * Verify reading entries with POSIX.1e and NFSv4 ACLs from archives created
+ * with Solaris tar.
*
- * This should work on all systems, regardless of whether local
- * filesystems support ACLs or not.
+ * This should work on all systems, regardless of whether local filesystems
+ * support ACLs or not.
*/
+static struct archive_test_acl_t acls0[] = {
+ { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_WRITE |
+ ARCHIVE_ENTRY_ACL_READ,
+ ARCHIVE_ENTRY_ACL_USER_OBJ, -1, "" },
+ { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_EXECUTE,
+ ARCHIVE_ENTRY_ACL_USER, 71, "lp" },
+ { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ,
+ ARCHIVE_ENTRY_ACL_USER, 666, "666" },
+ { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_EXECUTE |
+ ARCHIVE_ENTRY_ACL_WRITE | ARCHIVE_ENTRY_ACL_READ,
+ ARCHIVE_ENTRY_ACL_USER, 1000, "1000" },
+ { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ,
+ ARCHIVE_ENTRY_ACL_GROUP_OBJ, -1, "" },
+ { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ,
+ ARCHIVE_ENTRY_ACL_MASK, -1, ""},
+ { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ,
+ ARCHIVE_ENTRY_ACL_OTHER, -1, "" },
+};
+
+static struct archive_test_acl_t acls1[] = {
+ { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_EXECUTE |
+ ARCHIVE_ENTRY_ACL_WRITE | ARCHIVE_ENTRY_ACL_READ,
+ ARCHIVE_ENTRY_ACL_USER_OBJ, -1, "" },
+ { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_EXECUTE |
+ ARCHIVE_ENTRY_ACL_WRITE | ARCHIVE_ENTRY_ACL_READ,
+ ARCHIVE_ENTRY_ACL_USER, 2, "bin" },
+ { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_EXECUTE |
+ ARCHIVE_ENTRY_ACL_READ,
+ ARCHIVE_ENTRY_ACL_GROUP_OBJ, -1, "" },
+ { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_EXECUTE |
+ ARCHIVE_ENTRY_ACL_READ,
+ ARCHIVE_ENTRY_ACL_GROUP, 3, "sys" },
+ { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_EXECUTE |
+ ARCHIVE_ENTRY_ACL_READ,
+ ARCHIVE_ENTRY_ACL_MASK, -1, ""},
+ { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, 0,
+ ARCHIVE_ENTRY_ACL_OTHER, -1, "" },
+};
+
+static struct archive_test_acl_t acls2[] = {
+ { ARCHIVE_ENTRY_ACL_TYPE_DEFAULT, ARCHIVE_ENTRY_ACL_EXECUTE |
+ ARCHIVE_ENTRY_ACL_WRITE | ARCHIVE_ENTRY_ACL_READ,
+ ARCHIVE_ENTRY_ACL_USER_OBJ, -1 ,"" },
+ { ARCHIVE_ENTRY_ACL_TYPE_DEFAULT, ARCHIVE_ENTRY_ACL_EXECUTE |
+ ARCHIVE_ENTRY_ACL_WRITE | ARCHIVE_ENTRY_ACL_READ,
+ ARCHIVE_ENTRY_ACL_USER, 2, "bin" },
+ { ARCHIVE_ENTRY_ACL_TYPE_DEFAULT, ARCHIVE_ENTRY_ACL_EXECUTE |
+ ARCHIVE_ENTRY_ACL_READ,
+ ARCHIVE_ENTRY_ACL_GROUP_OBJ, -1, "" },
+ { ARCHIVE_ENTRY_ACL_TYPE_DEFAULT, ARCHIVE_ENTRY_ACL_EXECUTE |
+ ARCHIVE_ENTRY_ACL_READ,
+ ARCHIVE_ENTRY_ACL_GROUP, 3, "sys" },
+ { ARCHIVE_ENTRY_ACL_TYPE_DEFAULT, ARCHIVE_ENTRY_ACL_EXECUTE |
+ ARCHIVE_ENTRY_ACL_WRITE | ARCHIVE_ENTRY_ACL_READ,
+ ARCHIVE_ENTRY_ACL_MASK, -1, ""},
+ { ARCHIVE_ENTRY_ACL_TYPE_DEFAULT, 0,
+ ARCHIVE_ENTRY_ACL_OTHER, -1, "" },
+};
+
+static struct archive_test_acl_t acls3[] = {
+ { ARCHIVE_ENTRY_ACL_TYPE_DENY,
+ ARCHIVE_ENTRY_ACL_EXECUTE |
+ ARCHIVE_ENTRY_ACL_READ_DATA |
+ ARCHIVE_ENTRY_ACL_WRITE_DATA |
+ ARCHIVE_ENTRY_ACL_APPEND_DATA |
+ ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES |
+ ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES |
+ ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS |
+ ARCH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ACL_USER_OBJ, 0, "" },
+ { ARCHIVE_ENTRY_ACL_TYPE_ALLOW,
+ ARCHIVE_ENTRY_ACL_READ_DATA |
+ ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES |
+ ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS |
+ ARCHIVE_ENTRY_ACL_READ_ACL |
+ ARCHIVE_ENTRY_ACL_SYNCHRONIZE,
+ ARCHIVE_ENTRY_ACL_GROUP_OBJ, 0, "" },
+ { ARCHIVE_ENTRY_ACL_TYPE_ALLOW,
+ ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES |
+ ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS |
+ ARCHIVE_ENTRY_ACL_READ_ACL |
+ ARCHIVE_ENTRY_ACL_SYNCHRONIZE,
+ ARCHIVE_ENTRY_ACL_EVERYONE, 0, "" },
+};
+
+static struct archive_test_acl_t acls4[] = {
+ { ARCHIVE_ENTRY_ACL_TYPE_ALLOW,
+ ARCHIVE_ENTRY_ACL_EXECUTE |
+ ARCHIVE_ENTRY_ACL_READ_DATA |
+ ARCHIVE_ENTRY_ACL_WRITE_DATA |
+ ARCHIVE_ENTRY_ACL_APPEND_DATA |
+ ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES |
+ ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES |
+ ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS |
+ ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS |
+ ARCHIVE_ENTRY_ACL_READ_ACL |
+ ARCHIVE_ENTRY_ACL_WRITE_ACL |
+ ARCHIVE_ENTRY_ACL_WRITE_OWNER |
+ ARCHIVE_ENTRY_ACL_SYNCHRONIZE |
+ ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT |
+ ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT |
+ ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY,
+ ARCHIVE_ENTRY_ACL_USER, 1100, "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ROUP_OBJ, 0, "" },
+ { ARCHIVE_ENTRY_ACL_TYPE_ALLOW,
+ ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES |
+ ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS |
+ ARCHIVE_ENTRY_ACL_READ_ACL |
+ ARCHIVE_ENTRY_ACL_SYNCHRONIZE,
+ ARCHIVE_ENTRY_ACL_EVERYONE, 0, "" },
+};
+
DEFINE_TEST(test_compat_solaris_tar_acl)
{
+ char name[] = "test_compat_solaris_tar_acl.tar";
struct archive *a;
struct archive_entry *ae;
- const char *reference1 = "test_compat_solaris_tar_acl.tar";
- int type, permset, tag, qual;
- const char *name;
- /* Sample file generated on Solaris 10 */
- extract_reference_file(reference1);
+ /* Read archive file */
assert(NULL != (a = archive_read_new()));
- assertA(0 == archive_read_support_format_all(a));
- assertA(0 == archive_read_support_filter_all(a));
- assertA(0 == archive_read_open_filename(a, reference1, 512));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+ extract_reference_file(name);
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, name,
+ 10240));
- /* Archive has 1 entry with some ACLs set on it. */
+ /* First item has access ACLs */
assertA(0 == archive_read_next_header(a, &ae));
+ failure("One extended ACL should flag all ACLs to be returned.");
+ assertEqualInt(7, archive_entry_acl_reset(ae,
+ ARCHIVE_ENTRY_ACL_TYPE_ACCESS));
+ archive_test_compare_acls(ae, acls0, sizeof(acls0)/sizeof(acls0[0]),
+ ARCHIVE_ENTRY_ACL_TYPE_ACCESS, 0644);
failure("Basic ACLs should set mode to 0644, not %04o",
archive_entry_mode(ae)&0777);
- assertEqualInt((archive_entry_mode(ae) & 0777), 0644);
- assertEqualInt(7, archive_entry_acl_reset(ae,
- ARCHIVE_ENTRY_ACL_TYPE_ACCESS));
- assertEqualInt(ARCHIVE_OK, archive_entry_acl_next(ae,
- ARCHIVE_ENTRY_ACL_TYPE_ACCESS,
- &type, &permset, &tag, &qual, &name));
- assertEqualInt(ARCHIVE_ENTRY_ACL_TYPE_ACCESS, type);
- assertEqualInt(006, permset);
- assertEqualInt(ARCHIVE_ENTRY_ACL_USER_OBJ, tag);
- assertEqualInt(-1, qual);
- assert(name == NULL);
-
- assertEqualInt(ARCHIVE_OK, archive_entry_acl_next(ae,
- ARCHIVE_ENTRY_ACL_TYPE_ACCESS,
- &type, &permset, &tag, &qual, &name));
- assertEqualInt(ARCHIVE_ENTRY_ACL_TYPE_ACCESS, type);
- assertEqualInt(004, permset);
- assertEqualInt(ARCHIVE_ENTRY_ACL_GROUP_OBJ, tag);
- assertEqualInt(-1, qual);
- assert(name == NULL);
+ assert((archive_entry_mode(ae) & 0777) == 0644);
- assertEqualInt(ARCHIVE_OK, archive_entry_acl_next(ae,
- ARCHIVE_ENTRY_ACL_TYPE_ACCESS,
- &type, &permset, &tag, &qual, &name));
- assertEqualInt(ARCHIVE_ENTRY_ACL_TYPE_ACCESS, type);
- assertEqualInt(004, permset);
- assertEqualInt(ARCHIVE_ENTRY_ACL_OTHER, tag);
- assertEqualInt(-1, qual);
- assert(name == NULL);
-
- assertEqualInt(ARCHIVE_OK, archive_entry_acl_next(ae,
- ARCHIVE_ENTRY_ACL_TYPE_ACCESS,
- &type, &permset, &tag, &qual, &name));
- assertEqualInt(ARCHIVE_ENTRY_ACL_TYPE_ACCESS, type);
- assertEqualInt(001, permset);
- assertEqualInt(ARCHIVE_ENTRY_ACL_USER, tag);
- assertEqualInt(71, qual);
- assertEqualString(name, "lp");
-
- assertEqualInt(ARCHIVE_OK, archive_entry_acl_next(ae,
- ARCHIVE_ENTRY_ACL_TYPE_ACCESS,
- &type, &permset, &tag, &qual, &name));
- assertEqualInt(ARCHIVE_ENTRY_ACL_TYPE_ACCESS, type);
- assertEqualInt(004, permset);
- assertEqualInt(ARCHIVE_ENTRY_ACL_USER, tag);
- assertEqualInt(666, qual);
- assertEqualString(name, "666");
-
- assertEqualInt(ARCHIVE_OK, archive_entry_acl_next(ae,
- ARCHIVE_ENTRY_ACL_TYPE_ACCESS,
- &type, &permset, &tag, &qual, &name));
- assertEqualInt(ARCHIVE_ENTRY_ACL_TYPE_ACCESS, type);
- assertEqualInt(007, permset);
- assertEqualInt(ARCHIVE_ENTRY_ACL_USER, tag);
- assertEqualInt(1000, qual);
- assertEqualString(name, "trasz");
+ /* Second item has default and access ACLs */
+ assertA(0 == archive_read_next_header(a, &ae));
+ assertEqualInt(6, archive_entry_acl_reset(ae,
+ ARCHIVE_ENTRY_ACL_TYPE_ACCESS));
+ archive_test_compare_acls(ae, acls1, sizeof(acls1)/sizeof(acls1[0]),
+ ARCHIVE_ENTRY_ACL_TYPE_ACCESS, 0750);
+ failure("Basic ACLs should set mode to 0750, not %04o",
+ archive_entry_mode(ae)&0777);
+ assert((archive_entry_mode(ae) & 0777) == 0750);
+ assertEqualInt(6, archive_entry_acl_reset(ae,
+ ARCHIVE_ENTRY_ACL_TYPE_DEFAULT));
+ archive_test_compare_acls(ae, acls2, sizeof(acls2)/sizeof(acls2[0]),
+ ARCHIVE_ENTRY_ACL_TYPE_DEFAULT, 0750);
- assertEqualInt(ARCHIVE_OK, archive_entry_acl_next(ae,
- ARCHIVE_ENTRY_ACL_TYPE_ACCESS,
- &type, &permset, &tag, &qual, &name));
- assertEqualInt(ARCHIVE_ENTRY_ACL_TYPE_ACCESS, type);
- assertEqualInt(004, permset);
- assertEqualInt(ARCHIVE_ENTRY_ACL_MASK, tag);
- assertEqualInt(-1, qual);
- assertEqualString(name, NULL);
+ /* Third item has NFS4 ACLs */
+ assertA(0 == archive_read_next_header(a, &ae));
+ assertEqualInt(6, archive_entry_acl_reset(ae,
+ ARCHIVE_ENTRY_ACL_TYPE_NFS4));
+ archive_test_compare_acls(ae, acls3, sizeof(acls3)/sizeof(acls3[0]),
+ ARCHIVE_ENTRY_ACL_TYPE_NFS4, 0);
- assertEqualInt(ARCHIVE_EOF, archive_entry_acl_next(ae,
- ARCHIVE_ENTRY_ACL_TYPE_ACCESS,
- &type, &permset, &tag, &qual, &name));
+ /* Fourth item has NFS4 ACLs and inheritance flags */
+ assertA(0 == archive_read_next_header(a, &ae));
+ assertEqualInt(5, archive_entry_acl_reset(ae,
+ ARCHIVE_ENTRY_ACL_TYPE_NFS4));
+ archive_test_compare_acls(ae, acls4, sizeof(acls4)/sizeof(acls0[4]),
+ ARCHIVE_ENTRY_ACL_TYPE_NFS4, 0);
/* Close the archive. */
assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
diff --git a/contrib/libarchive/libarchive/test/test_compat_solaris_tar_acl.tar.uu b/contrib/libarchive/libarchive/test/test_compat_solaris_tar_acl.tar.uu
index 229b335..028dd61 100644
--- a/contrib/libarchive/libarchive/test/test_compat_solaris_tar_acl.tar.uu
+++ b/contrib/libarchive/libarchive/test/test_compat_solaris_tar_acl.tar.uu
@@ -1,61 +1,163 @@
-$FreeBSD$
-begin 644 test_acl_solaris.tar
-M9FEL92UW:71H+7!O<VEX+6%C;',`````````````````````````````````
-M````````````````````````````````````````````````````````````
-M`````````````#`P,#`V-#0`,#`P,3<U,``P,#`P,#`P`#`P,#`P,#`P,30T
-M`#$Q,3<T-C`T,34W`#`P,34Q-S8`00``````````````````````````````
-M````````````````````````````````````````````````````````````
-M``````````````````````````````````````````!U<W1A<@`P,'1R87-Z
-M````````````````````````````````````<F]O=```````````````````
-M```````````````````P,#`P,C$P`#`P,#`P,3``````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M```````````````````````Q,#`P,#`W`'5S97(Z.G)W+2QU<V5R.FQP.BTM
-M>#HW,2QU<V5R.C8V-CIR+2TZ-C8V+'5S97(Z=')A<WHZ<G=X.C$P,#`L9W)O
-M=7`Z.G(M+2QM87-K.G(M+2QO=&AE<CIR+2T``````````3````````/-@```
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````!%&8`````````&L`````,3`P,#`P-P!U
+begin 644 test_compat_solaris_tar_acl.tar
+M9FEL92UW:71H+7!O<VEX+6%C;',
+M
+M # P,# V-#0 ,# P,3<U, P,# P,# P # P,# P,# P,30S
+M #$Q,3<T-C T,34W # P,30Q,C$ 00
+M
+M !U<W1A<@ P,
+M <F]O=
+M P,# P-#$T # P,# P,#,
+M
+M
+M
+M Q,# P,# W '5S97(Z.G)W+2QU<V5R.FQP.BTM
+M>#HW,2QU<V5R.C8V-CIR+2TZ-C8V+'5S97(Z,3 P,#IR=W@Z,3 P,"QG<F]U
+M<#HZ<BTM+&UA<VLZ<BTM+&]T:&5R.G(M+0 # !
+M
+M
+M
+M
+M
+M
+M (Q@@( &L ,3 P,# P-P!U
M<V5R.CIR=RTL=7-E<CIL<#HM+7@Z-S$L=7-E<CHV-C8Z<BTM.C8V-BQU<V5R
-M.G1R87-Z.G)W>#HQ,#`P+&=R;W5P.CIR+2TL;6%S:SIR+69I;&4M=VET:"UP
-M;W-I>"UA8VQS````````````````````````````````````````````````
-M```````````````````````````````````````````````````````````P
-M,#`P-C0T`#`P,#$W-3``,#`P,#`P,``P,#`P,#`P,#`P,``Q,3$W-#8P-#$U
-M-P`P,#$U,30T`#``````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````=7-T87(`,#!T<F%S>@``````````````
-M`````````````````````')O;W0`````````````````````````````````
-M````,#`P,#(Q,``P,#`P,#$P````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-M````````````````````````````````````````````````````````````
-H````````````````````````````````````````````````````````
-`
+M.C$P,# Z<G=X.C$P,# L9W)O=7 Z.G(M+2QM87-K.G(M+69I;&4M=VET:"UP
+M;W-I>"UA8VQS
+M P
+M,# P-C0T # P,#$W-3 ,# P,# P, P,# P,# P,# P, Q,3$W-#8P-#$U
+M-P P,#$T,#<P #
+M
+M =7-T87( ,#
+M ')O;W0
+M ,# P,#0Q- P,# P,# S
+M
+M
+M
+M 9&ER+7=I=&@M<&]S:7@M86-L<R\
+M
+M # P,# W-3 ,# P,3<U, P,# P,# P # P,# P
+M,# P,S P #$S,#,V-3$R,C4T # P,30P,C, 00
+M
+M !U<W1A<@ P
+M, <F]O=
+M P,# P-#$T # P,# P,#,
+M
+M
+M
+M Q,# P,#$T '5S97(Z.G)W>"QU<V5R
+M.F)I;CIR=W@Z,BQG<F]U<#HZ<BUX+&=R;W5P.G-Y<SIR+7@Z,RQM87-K.G(M
+M>"QO=&AE<CHM+2TL9&5F875L='5S97(Z.G)W>"QD969A=6QT=7-E<CIB:6XZ
+M<G=X.C(L9&5F875L=&=R;W5P.CIR+7@L9&5F875L=&=R;W5P.G-Y<SIR+7@Z
+M,RQD969A=6QT;6%S:SIR=W@L9&5F875L=&]T:&5R.BTM+0 @ #C%
+M" @
+M
+M
+M
+M
+M
+M &1I<BUW
+M:71H+7!O<VEX+6%C;',O
+M
+M P,# P-S4P # P,#$W-3 ,# P,# P, P,# P,# P,# P, Q,S S
+M-C4Q,C(U- P,#$T,# T #4
+M
+M =7-T87( ,#
+M ')O;W0
+M ,#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M,#(
+M
+M
+M S,# P,# U '5S
+M97(Z,3$P,#IR=WAP+2UA05)78T-O<SIF9&DM+2TM.F%L;&]W.C$Q,# L9W)O
+M=7 Z861M.G(M+2TM+6$M4BUC+2US.F9D+2TM+2TZ86QL;W<Z-"QO=VYE<D Z
+M<G=X<"U$84%25V-#;W,Z+2TM+2TM+3IA;&QO=RQG<F]U<$ Z<BUX+2TM82U2
+M+6,M+7,Z+2TM+2TM+3IA;&QO=RQE=F5R>6]N94 Z+2TM+2TM82U2+6,M+7,Z
+M+2TM+2TM+3IA;&QO=P 4
+M
+M "HUP@( -, ,S P,# P-0!U<V5R.C$Q,# Z<G=X
+M<"TM84%25V-#;W,Z9F1I+2TM+3IA;&QO=SHQ,3 P+&=R;W5P.F%D;3IR+2TM
+M+2UA+5(M8RTM<SIF9"TM+2TM.F%L;&]W.C0L;W=N97) .G)W>' M1&%!4E=C
+M0V]S.BTM+2TM+2TZ86QL;W<L9W)O=7! .G(M>"TM+6$M4BUC+2US.BTM+2TM
+M+2TZ86QL;W<L979E<GEO;F5 .BTM+2TM+6$M4BUC+2US.BTM+2TM+2TZ86QL
+M;W< &1I<BUW:71H+6YF<W8T+6%C;',O
+M
+M P,# P-S4P # P,# P,# ,# P,# P, P,# P
+M,# P,# P, Q,S S-C4Q,S<S-0 P,#$T-3<W #4
+M
+M =7-T87(
+M,#!R;V]T ')O;W0
+M ,# P,#0Q- P,C P,# R
+M
+M
+M
+M
+M
+M
+M
+M
+M
+M
+M
+M
+M
+M
+M
+M
+M
+M
+M
+M
+M
+M
+M
+M
+M
+M
+-
+
end
diff --git a/contrib/libarchive/libarchive/test/test_compat_star_acl.c b/contrib/libarchive/libarchive/test/test_compat_star_acl.c
new file mode 100644
index 0000000..f2a78b2
--- /dev/null
+++ b/contrib/libarchive/libarchive/test/test_compat_star_acl.c
@@ -0,0 +1,321 @@
+/*-
+ * Copyright (c) 2003-2007 Tim Kientzle
+ * Copyright (c) 2016 Martin Matuska
+ * 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 AUTHOR(S) ``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(S) 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.
+ */
+#include "test.h"
+__FBSDID("$FreeBSD$");
+
+/*
+ * Verify reading entries with POSIX.1e and NFSv4 ACLs from archives created
+ * by star.
+ *
+ * This should work on all systems, regardless of whether local filesystems
+ * support ACLs or not.
+ */
+
+static struct archive_test_acl_t acls0[] = {
+ { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_EXECUTE,
+ ARCHIVE_ENTRY_ACL_USER_OBJ, -1, "" },
+ { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ,
+ ARCHIVE_ENTRY_ACL_USER, -1, "user77" },
+ { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ,
+ ARCHIVE_ENTRY_ACL_GROUP_OBJ, -1, "" },
+ { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ,
+ ARCHIVE_ENTRY_ACL_MASK, -1, ""},
+ { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_WRITE,
+ ARCHIVE_ENTRY_ACL_OTHER, -1, "" },
+};
+
+static struct archive_test_acl_t acls1[] = {
+ { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_EXECUTE | ARCHIVE_ENTRY_ACL_READ,
+ ARCHIVE_ENTRY_ACL_USER_OBJ, -1, "" },
+ { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ,
+ ARCHIVE_ENTRY_ACL_USER, -1, "user77" },
+ { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, 0,
+ ARCHIVE_ENTRY_ACL_USER, -1, "user78" },
+ { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ,
+ ARCHIVE_ENTRY_ACL_GROUP_OBJ, -1, "" },
+ { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, 0007,
+ ARCHIVE_ENTRY_ACL_GROUP, -1, "group78" },
+ { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, 0007,
+ ARCHIVE_ENTRY_ACL_MASK, -1, ""},
+ { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_WRITE | ARCHIVE_ENTRY_ACL_EXECUTE,
+ ARCHIVE_ENTRY_ACL_OTHER, -1, "" },
+};
+
+static struct archive_test_acl_t acls2[] = {
+ { ARCHIVE_ENTRY_ACL_TYPE_DEFAULT, ARCHIVE_ENTRY_ACL_EXECUTE,
+ ARCHIVE_ENTRY_ACL_USER_OBJ, -1 ,"" },
+ { ARCHIVE_ENTRY_ACL_TYPE_DEFAULT, ARCHIVE_ENTRY_ACL_READ,
+ ARCHIVE_ENTRY_ACL_USER, -1, "user77" },
+ { ARCHIVE_ENTRY_ACL_TYPE_DEFAULT, ARCHIVE_ENTRY_ACL_READ,
+ ARCHIVE_ENTRY_ACL_GROUP_OBJ, -1, "" },
+ { ARCHIVE_ENTRY_ACL_TYPE_DEFAULT, ARCHIVE_ENTRY_ACL_EXECUTE,
+ ARCHIVE_ENTRY_ACL_GROUP, -1, "group78" },
+ { ARCHIVE_ENTRY_ACL_TYPE_DEFAULT, ARCHIVE_ENTRY_ACL_READ | ARCHIVE_ENTRY_ACL_EXECUTE,
+ ARCHIVE_ENTRY_ACL_MASK, -1, ""},
+ { ARCHIVE_ENTRY_ACL_TYPE_DEFAULT, ARCHIVE_ENTRY_ACL_WRITE,
+ ARCHIVE_ENTRY_ACL_OTHER, -1, "" },
+};
+
+static struct archive_test_acl_t acls3[] = {
+ { ARCHIVE_ENTRY_ACL_TYPE_ALLOW,
+ ARCHIVE_ENTRY_ACL_READ_DATA |
+ ARCHIVE_ENTRY_ACL_WRITE_DATA |
+ ARCHIVE_ENTRY_ACL_EXECUTE |
+ ARCHIVE_ENTRY_ACL_APPEND_DATA |
+ ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES |
+ ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES |
+ ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS |
+ ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS |
+ ARCHIVE_ENTRY_ACL_READ_ACL |
+ ARCHIVE_ENTRY_ACL_WRITE_ACL |
+ ARCHIVE_ENTRY_ACL_WRITE_OWNER |
+ ARCHIVE_ENTRY_ACL_SYNCHRONIZE,
+ ARCHIVE_ENTRY_ACL_USER_OBJ, 0, "" },
+ { ARCHIVE_ENTRY_ACL_TYPE_ALLOW,
+ ARCHIVE_ENTRY_ACL_READ_DATA |
+ ARCHIVE_ENTRY_ACL_WRITE_DATA |
+ ARCHIVE_ENTRY_ACL_APPEND_DATA |
+ ARCHIVE_ENTRY_ACL_READ_ACL |
+ ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES |
+ ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS |
+ ARCHIVE_ENTRY_ACL_READ_ACL |
+ ARCHIVE_ENTRY_ACL_SYNCHRONIZE,
+ ARCHIVE_ENTRY_ACL_GROUP_OBJ, 0, "" },
+ { ARCHIVE_ENTRY_ACL_TYPE_ALLOW,
+ ARCHIVE_ENTRY_ACL_READ_DATA |
+ ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES |
+ ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS |
+ ARCHIVE_ENTRY_ACL_READ_ACL |
+ ARCHIVE_ENTRY_ACL_SYNCHRONIZE,
+ ARCHIVE_ENTRY_ACL_EVERYONE, 0, "" },
+};
+
+static struct archive_test_acl_t acls4[] = {
+ { ARCHIVE_ENTRY_ACL_TYPE_ALLOW,
+ ARCHIVE_ENTRY_ACL_READ_DATA |
+ ARCHIVE_ENTRY_ACL_WRITE_DATA |
+ ARCHIVE_ENTRY_ACL_APPEND_DATA |
+ ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES |
+ ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES |
+ ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS |
+ ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS |
+ ARCHIVE_ENTRY_ACL_READ_ACL |
+ ARCHIVE_ENTRY_ACL_WRITE_ACL |
+ ARCHIVE_ENTRY_ACL_WRITE_OWNER |
+ ARCHIVE_ENTRY_ACL_SYNCHRONIZE,
+ ARCHIVE_ENTRY_ACL_USER_OBJ, 0, "" },
+ { ARCHIVE_ENTRY_ACL_TYPE_ALLOW,
+ ARCHIVE_ENTRY_ACL_READ_DATA |
+ ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES |
+ ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS |
+ ARCHIVE_ENTRY_ACL_READ_ACL |
+ ARCHIVE_ENTRY_ACL_SYNCHRONIZE |
+ ARCHIVE_ENTRY_ACL_ENTRY_INHERITED,
+ ARCHIVE_ENTRY_ACL_USER, 77, "user77" },
+ { ARCHIVE_ENTRY_ACL_TYPE_DENY,
+ ARCHIVE_ENTRY_ACL_READ_DATA |
+ ARCHIVE_ENTRY_ACL_WRITE_DATA |
+ ARCHIVE_ENTRY_ACL_EXECUTE,
+ ARCHIVE_ENTRY_ACL_USER, 78, "user78" },
+ { ARCHIVE_ENTRY_ACL_TYPE_ALLOW,
+ ARCHIVE_ENTRY_ACL_READ_DATA |
+ ARCHIVE_ENTRY_ACL_WRITE_DATA |
+ ARCHIVE_ENTRY_ACL_APPEND_DATA |
+ ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES |
+ ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS |
+ ARCHIVE_ENTRY_ACL_READ_ACL |
+ ARCHIVE_ENTRY_ACL_SYNCHRONIZE,
+ ARCHIVE_ENTRY_ACL_GROUP_OBJ, 0, "" },
+ { ARCHIVE_ENTRY_ACL_TYPE_DENY,
+ ARCHIVE_ENTRY_ACL_WRITE_DATA |
+ ARCHIVE_ENTRY_ACL_APPEND_DATA |
+ ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES |
+ ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS |
+ ARCHIVE_ENTRY_ACL_WRITE_ACL |
+ ARCHIVE_ENTRY_ACL_WRITE_OWNER,
+ ARCHIVE_ENTRY_ACL_GROUP, 78, "group78" },
+ { ARCHIVE_ENTRY_ACL_TYPE_ALLOW,
+ ARCHIVE_ENTRY_ACL_READ_DATA |
+ ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES |
+ ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS |
+ ARCHIVE_ENTRY_ACL_READ_ACL |
+ ARCHIVE_ENTRY_ACL_SYNCHRONIZE,
+ ARCHIVE_ENTRY_ACL_EVERYONE, 0, "" },
+};
+
+static struct archive_test_acl_t acls5[] = {
+ { ARCHIVE_ENTRY_ACL_TYPE_ALLOW,
+ ARCHIVE_ENTRY_ACL_READ_DATA |
+ ARCHIVE_ENTRY_ACL_WRITE_DATA |
+ ARCHIVE_ENTRY_ACL_EXECUTE |
+ ARCHIVE_ENTRY_ACL_APPEND_DATA |
+ ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES |
+ ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES |
+ ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS |
+ ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS |
+ ARCHIVE_ENTRY_ACL_READ_ACL |
+ ARCHIVE_ENTRY_ACL_WRITE_ACL |
+ ARCHIVE_ENTRY_ACL_WRITE_OWNER |
+ ARCHIVE_ENTRY_ACL_SYNCHRONIZE,
+ ARCHIVE_ENTRY_ACL_USER_OBJ, 0, "" },
+ { ARCHIVE_ENTRY_ACL_TYPE_ALLOW,
+ ARCHIVE_ENTRY_ACL_READ_DATA |
+ ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES |
+ ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS |
+ ARCHIVE_ENTRY_ACL_READ_ACL |
+ ARCHIVE_ENTRY_ACL_SYNCHRONIZE |
+ ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT |
+ ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT,
+ ARCHIVE_ENTRY_ACL_USER, 77, "user77" },
+ { ARCHIVE_ENTRY_ACL_TYPE_ALLOW,
+ ARCHIVE_ENTRY_ACL_READ_DATA |
+ ARCHIVE_ENTRY_ACL_WRITE_DATA |
+ ARCHIVE_ENTRY_ACL_EXECUTE |
+ ARCHIVE_ENTRY_ACL_APPEND_DATA |
+ ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES |
+ ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES |
+ ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS |
+ ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS |
+ ARCHIVE_ENTRY_ACL_READ_ACL |
+ ARCHIVE_ENTRY_ACL_SYNCHRONIZE,
+ ARCHIVE_ENTRY_ACL_GROUP_OBJ, 0, "" },
+ { ARCHIVE_ENTRY_ACL_TYPE_DENY,
+ ARCHIVE_ENTRY_ACL_READ_DATA |
+ ARCHIVE_ENTRY_ACL_WRITE_DATA |
+ ARCHIVE_ENTRY_ACL_APPEND_DATA |
+ ARCHIVE_ENTRY_ACL_EXECUTE |
+ ARCHIVE_ENTRY_ACL_DELETE |
+ ARCHIVE_ENTRY_ACL_DELETE_CHILD |
+ ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES |
+ ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES |
+ ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS |
+ ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS |
+ ARCHIVE_ENTRY_ACL_READ_ACL |
+ ARCHIVE_ENTRY_ACL_WRITE_ACL |
+ ARCHIVE_ENTRY_ACL_WRITE_OWNER |
+ ARCHIVE_ENTRY_ACL_SYNCHRONIZE |
+ ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT |
+ ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT,
+ ARCHIVE_ENTRY_ACL_GROUP, 78, "group78" },
+ { ARCHIVE_ENTRY_ACL_TYPE_ALLOW,
+ ARCHIVE_ENTRY_ACL_READ_DATA |
+ ARCHIVE_ENTRY_ACL_EXECUTE |
+ ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES |
+ ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS |
+ ARCHIVE_ENTRY_ACL_READ_ACL |
+ ARCHIVE_ENTRY_ACL_SYNCHRONIZE,
+ ARCHIVE_ENTRY_ACL_EVERYONE, 0, "" },
+};
+
+DEFINE_TEST(test_compat_star_acl_posix1e)
+{
+ char name[] = "test_compat_star_acl_posix1e.tar";
+ struct archive *a;
+ struct archive_entry *ae;
+
+ /* Read archive file */
+ assert(NULL != (a = archive_read_new()));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+ extract_reference_file(name);
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, name,
+ 10240));
+
+ /* First item has a few ACLs */
+ assertA(0 == archive_read_next_header(a, &ae));
+ failure("One extended ACL should flag all ACLs to be returned.");
+ assertEqualInt(5, archive_entry_acl_reset(ae,
+ ARCHIVE_ENTRY_ACL_TYPE_ACCESS));
+ archive_test_compare_acls(ae, acls0, sizeof(acls0)/sizeof(acls0[0]),
+ ARCHIVE_ENTRY_ACL_TYPE_ACCESS, 0142);
+ failure("Basic ACLs should set mode to 0142, not %04o",
+ archive_entry_mode(ae)&0777);
+ assert((archive_entry_mode(ae) & 0777) == 0142);
+
+ /* Second item has pretty extensive ACLs */
+ assertA(0 == archive_read_next_header(a, &ae));
+ assertEqualInt(7, archive_entry_acl_reset(ae,
+ ARCHIVE_ENTRY_ACL_TYPE_ACCESS));
+ archive_test_compare_acls(ae, acls1, sizeof(acls1)/sizeof(acls1[0]),
+ ARCHIVE_ENTRY_ACL_TYPE_ACCESS, 0543);
+ failure("Basic ACLs should set mode to 0543, not %04o",
+ archive_entry_mode(ae)&0777);
+ assert((archive_entry_mode(ae) & 0777) == 0543);
+
+ /* Third item has default ACLs */
+ assertA(0 == archive_read_next_header(a, &ae));
+ assertEqualInt(6, archive_entry_acl_reset(ae,
+ ARCHIVE_ENTRY_ACL_TYPE_DEFAULT));
+ archive_test_compare_acls(ae, acls2, sizeof(acls2)/sizeof(acls2[0]),
+ ARCHIVE_ENTRY_ACL_TYPE_DEFAULT, 0142);
+ failure("Basic ACLs should set mode to 0142, not %04o",
+ archive_entry_mode(ae)&0777);
+ assert((archive_entry_mode(ae) & 0777) == 0142);
+
+ /* Close the archive. */
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+ assertEqualInt(ARCHIVE_OK, archive_read_free(a));
+}
+
+DEFINE_TEST(test_compat_star_acl_nfs4)
+{
+ char name[] = "test_compat_star_acl_nfs4.tar";
+ struct archive *a;
+ struct archive_entry *ae;
+
+ /* Read archive file */
+ assert(NULL != (a = archive_read_new()));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+ extract_reference_file(name);
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, name, 10240
+));
+
+ /* First item has NFS4 ACLs mirroring file mode */
+ assertA(0 == archive_read_next_header(a, &ae));
+ assertEqualInt(3, archive_entry_acl_reset(ae,
+ ARCHIVE_ENTRY_ACL_TYPE_ALLOW));
+ archive_test_compare_acls(ae, acls3, sizeof(acls3)/sizeof(acls3[0]),
+ ARCHIVE_ENTRY_ACL_TYPE_ALLOW, 0);
+
+ /* Second item has has fine-grained NFS4 ACLs */
+ assertA(0 == archive_read_next_header(a, &ae));
+ assertEqualInt(6, archive_entry_acl_reset(ae,
+ ARCHIVE_ENTRY_ACL_TYPE_NFS4));
+ archive_test_compare_acls(ae, acls4, sizeof(acls4)/sizeof(acls0[4]),
+ ARCHIVE_ENTRY_ACL_TYPE_NFS4, 0);
+
+ /* Third item has file and directory inheritance NFS4 ACLs */
+ assertA(0 == archive_read_next_header(a, &ae));
+ assertEqualInt(5, archive_entry_acl_reset(ae,
+ ARCHIVE_ENTRY_ACL_TYPE_NFS4));
+ archive_test_compare_acls(ae, acls5, sizeof(acls5)/sizeof(acls5[0]),
+ ARCHIVE_ENTRY_ACL_TYPE_NFS4, 0);
+
+ /* Close the archive. */
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+ assertEqualInt(ARCHIVE_OK, archive_read_free(a));
+}
diff --git a/contrib/libarchive/libarchive/test/test_compat_star_acl_nfs4.tar.uu b/contrib/libarchive/libarchive/test/test_compat_star_acl_nfs4.tar.uu
new file mode 100644
index 0000000..79b228e
--- /dev/null
+++ b/contrib/libarchive/libarchive/test/test_compat_star_acl_nfs4.tar.uu
@@ -0,0 +1,231 @@
+begin 644 test_compat_star_acl_nfs4.tar
+M+B\N+T!087A(96%D97(`````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````#`P,#`V,#`@,#`P,#`P,"`P,#`P,#`P(#`P,#`P,#`P,C<R
+M(#`P,#`P,#`P,#`P(#`P,38P-S0@9P``````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````!U<W1A<@`P,')O;W0`
+M````````````````````````````````````=VAE96P`````````````````
+M```````````````````P,#`P,#`P(#`P,#`P,#`@````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M```````````````````````````````````P,#`P,#`P,#`P,"`P,#`P,#`P
+M,#`P,"`````````````````U-R!30TA)3%DN<F5L96%S93US=&%R(#$N-2XS
+M("AA;60V-"UU;FMN;W=N+69R965B<V0Q,2XP*0HR-R!30TA)3%DN87)C:'1Y
+M<&4]97AU<W1A<@HT-R!30TA)3%DN=F]L:&1R+F1U;7!D871E/3$T-SDQ-C<W
+M,C<N,38W,C(U,C@Q"C(U(%-#2$E,62YV;VQH9'(N=F]L;F\],0HS,"!30TA)
+M3%DN=F]L:&1R+F)L;V-K<VEZ93TR,`H`````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````````"XO+B]`4&%X2&5A
+M9&5R````````````````````````````````````````````````````````
+M```````````````````````````````````````````````````````````P
+M,#`P-C`P(#`P,#`P,#`@,#`P,#`P,"`P,#`P,#`P,#,S-"`P,#`P,#`P,#`P
+M,"`P,#$V,3$T('@`````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````=7-T87(`,#!R;V]T````````````````
+M`````````````````````'=H965L````````````````````````````````
+M````,#`P,#`P,"`P,#`P,#`P(```````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````,#`P,#`P,#`P,#`@,#`P,#`P,#`P,#`@````````
+M````````,S`@871I;64],30W.3$Q.34U-"XP-#,U-#DP,#`*,S`@8W1I;64]
+M,30W.3$Q.3DQ,BXY,SDQ-C@P,#`*,S`@;71I;64],30W.3$Q.34U-"XP-#,U
+M-#DP,#`*,3,P(%-#2$E,62YA8VPN86-E/6]W;F5R0#IR=WAP+2UA05)78T-O
+M<SHM+2TM+2TM.F%L;&]W+&=R;W5P0#IR=RUP+2UA+5(M8RTM<SHM+2TM+2TM
+M.F%L;&]W+&5V97)Y;VYE0#IR+2TM+2UA+5(M8RTM<SHM+2TM+2TM.F%L;&]W
+M"@``````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````!F:6QE,0``````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````,#`P,#<V-"`P,#`P
+M,#`P(#`P,#`P,#`@,#`P,#`P,#`P,#`@,3,P,3(S,3$S,#(@,#`Q-#8S-B`P
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````'5S=&%R`#`P<F]O=```````````````````````````````
+M``````!W:&5E;````````````````````````````````````#`P,#`P,#`@
+M,#`P,#`P,"``````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````#$S,#$R,S$Q,S`R(#$S,#$R,S$R,#4P(````````````````"XO+B]`
+M4&%X2&5A9&5R````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M```````P,#`P-C`P(#`P,#`P,#`@,#`P,#`P,"`P,#`P,#`P,#4T,"`P,#`P
+M,#`P,#`P,"`P,#$V,3$S('@`````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````=7-T87(`,#!R;V]T````````
+M`````````````````````````````'=H965L````````````````````````
+M````````````,#`P,#`P,"`P,#`P,#`P(```````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````,#`P,#`P,#`P,#`@,#`P,#`P,#`P,#`@
+M````````````````,S`@871I;64],30W.3$Q.34U-2XR-C<P,3@P,#`*,S`@
+M8W1I;64],30W.3$V,34Y."XY,SDV-#8P,#`*,S`@;71I;64],30W.3$Q.34U
+M-2XR-C<P,3@P,#`*,C8R(%-#2$E,62YA8VPN86-E/75S97(Z=7-E<C<X.G)W
+M>"TM+2TM+2TM+2TM.BTM+2TM+2TZ9&5N>3HW."QG<F]U<#IG<F]U<#<X.BUW
+M+7`M+2U!+5<M0V\M.BTM+2TM+2TZ9&5N>3HW."QU<V5R.G5S97(W-SIR+2TM
+M+2UA+5(M8RTM<SHM+2TM+2U).F%L;&]W.C<W+&]W;F5R0#IR=RUP+2UA05)7
+M8T-O<SHM+2TM+2TM.F%L;&]W+&=R;W5P0#IR=RUP+2UA+5(M8RTM<SHM+2TM
+M+2TM.F%L;&]W+&5V97)Y;VYE0#IR+2TM+2UA+5(M8RTM<SHM+2TM+2TM.F%L
+M;&]W"@``````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````!F:6QE,@``````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````,#`P,#8V
+M-"`P,#`P,#`P(#`P,#`P,#`@,#`P,#`P,#`P,#`@,3,P,3(S,3$S,#,@,#`Q
+M-#8U-R`P````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````'5S=&%R`#`P<F]O=```````````````````````
+M``````````````!W:&5E;````````````````````````````````````#`P
+M,#`P,#`@,#`P,#`P,"``````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````#$S,#$R,S$Q,S`S(#$S,#$R-#,S,S<V(```````````````
+M`"XO+B]`4&%X2&5A9&5R````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M```````````````P,#`P-C`P(#`P,#`P,#`@,#`P,#`P,"`P,#`P,#`P,#0V
+M-2`P,#`P,#`P,#`P,"`P,#$V,3(Q('@`````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````=7-T87(`,#!R;V]T
+M`````````````````````````````````````'=H965L````````````````
+M````````````````````,#`P,#`P,"`P,#`P,#`P(```````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````,#`P,#`P,#`P,#`@,#`P,#`P
+M,#`P,#`@````````````````,S`@871I;64],30W.3$V-S0Y-2XV.#<X-C8P
+M,#`*,S`@8W1I;64],30W.3$V-S<R,RXT-#`X-C<P,#`*,S`@;71I;64],30W
+M.3$R,#8W."XT-#$U.#`P,#`*,C$Y(%-#2$E,62YA8VPN86-E/6=R;W5P.F=R
+M;W5P-S@Z<G=X<$1D84%25V-#;W,Z9F0M+2TM+3ID96YY.C<X+'5S97(Z=7-E
+M<C<W.G(M+2TM+6$M4BUC+2US.F9D+2TM+2TZ86QL;W<Z-S<L;W=N97)`.G)W
+M>'`M+6%!4E=C0V]S.BTM+2TM+2TZ86QL;W<L9W)O=7!`.G)W>'`M+6%!4E=C
+M+2US.BTM+2TM+2TZ86QL;W<L979E<GEO;F5`.G(M>"TM+6$M4BUC+2US.BTM
+M+2TM+2TZ86QL;W<*````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````````!D:7(Q+P``````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M,#`P,#<W-2`P,#`P,#`P(#`P,#`P,#`@,#`P,#`P,#`P,#`@,3,P,3(S,3,T
+M-#8@,#`Q-#8S,2`U````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````'5S=&%R`#`P<F]O=```````````````
+M``````````````````````!W:&5E;```````````````````````````````
+M`````#`P,#`P,#`@,#`P,#`P,"``````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````#$S,#$R-#0W,#`W(#$S,#$R-#0W,S4S(```````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+9````````````````````````````````````
+`
+end
diff --git a/contrib/libarchive/libarchive/test/test_compat_star_acl_posix1e.c b/contrib/libarchive/libarchive/test/test_compat_star_acl_posix1e.c
deleted file mode 100644
index 10bffd9..0000000
--- a/contrib/libarchive/libarchive/test/test_compat_star_acl_posix1e.c
+++ /dev/null
@@ -1,215 +0,0 @@
-/*-
- * Copyright (c) 2003-2007 Tim Kientzle
- * 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 AUTHOR(S) ``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(S) 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.
- */
-#include "test.h"
-__FBSDID("$FreeBSD$");
-
-/*
- * Verify reading entries with POSIX.1e ACLs from archives created by star
- *
- * This should work on all systems, regardless of whether local filesystems
- * support ACLs or not.
- */
-
-struct acl_t {
- int type; /* Type of ACL: "access" or "default" */
- int permset; /* Permissions for this class of users. */
- int tag; /* Owner, User, Owning group, group, other, etc. */
- const char *name; /* Name of user/group, depending on tag. */
-};
-
-static struct acl_t acls0[] = {
- { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_EXECUTE,
- ARCHIVE_ENTRY_ACL_USER_OBJ, "" },
- { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ,
- ARCHIVE_ENTRY_ACL_USER, "user77" },
- { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ,
- ARCHIVE_ENTRY_ACL_GROUP_OBJ, "" },
- { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ,
- ARCHIVE_ENTRY_ACL_MASK, ""},
- { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_WRITE,
- ARCHIVE_ENTRY_ACL_OTHER, "" },
-};
-
-static struct acl_t acls1[] = {
- { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_EXECUTE | ARCHIVE_ENTRY_ACL_READ,
- ARCHIVE_ENTRY_ACL_USER_OBJ, "" },
- { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ,
- ARCHIVE_ENTRY_ACL_USER, "user77" },
- { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, 0,
- ARCHIVE_ENTRY_ACL_USER, "user78" },
- { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ,
- ARCHIVE_ENTRY_ACL_GROUP_OBJ, "" },
- { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, 0007,
- ARCHIVE_ENTRY_ACL_GROUP, "group78" },
- { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, 0007,
- ARCHIVE_ENTRY_ACL_MASK, ""},
- { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_WRITE | ARCHIVE_ENTRY_ACL_EXECUTE,
- ARCHIVE_ENTRY_ACL_OTHER, "" },
-};
-
-static struct acl_t acls2[] = {
- { ARCHIVE_ENTRY_ACL_TYPE_DEFAULT, ARCHIVE_ENTRY_ACL_EXECUTE,
- ARCHIVE_ENTRY_ACL_USER_OBJ, "" },
- { ARCHIVE_ENTRY_ACL_TYPE_DEFAULT, ARCHIVE_ENTRY_ACL_READ,
- ARCHIVE_ENTRY_ACL_USER, "user77" },
- { ARCHIVE_ENTRY_ACL_TYPE_DEFAULT, ARCHIVE_ENTRY_ACL_READ,
- ARCHIVE_ENTRY_ACL_GROUP_OBJ, "" },
- { ARCHIVE_ENTRY_ACL_TYPE_DEFAULT, ARCHIVE_ENTRY_ACL_EXECUTE,
- ARCHIVE_ENTRY_ACL_GROUP, "group78" },
- { ARCHIVE_ENTRY_ACL_TYPE_DEFAULT, ARCHIVE_ENTRY_ACL_READ | ARCHIVE_ENTRY_ACL_EXECUTE,
- ARCHIVE_ENTRY_ACL_MASK, ""},
- { ARCHIVE_ENTRY_ACL_TYPE_DEFAULT, ARCHIVE_ENTRY_ACL_WRITE,
- ARCHIVE_ENTRY_ACL_OTHER, "" },
-};
-
-static int
-acl_match(struct acl_t *acl, int type, int permset, int tag, const char *name)
-{
- if (type != acl->type)
- return (0);
- if (permset != acl->permset)
- return (0);
- if (tag != acl->tag)
- return (0);
- if (tag == ARCHIVE_ENTRY_ACL_USER_OBJ)
- return (1);
- if (tag == ARCHIVE_ENTRY_ACL_GROUP_OBJ)
- return (1);
- if (tag == ARCHIVE_ENTRY_ACL_OTHER)
- return (1);
- if (tag == ARCHIVE_ENTRY_ACL_MASK)
- return (1);
- if (name == NULL)
- return (acl->name == NULL || acl->name[0] == '\0');
- if (acl->name == NULL)
- return (name == NULL || name[0] == '\0');
- return (0 == strcmp(name, acl->name));
-}
-
-static void
-compare_acls(struct archive_entry *ae, struct acl_t *acls, int n, int mode,
- int want_type)
-{
- int *marker = malloc(sizeof(marker[0]) * n);
- int i;
- int r;
- int type, permset, tag, qual;
- int matched;
- const char *name;
-
- for (i = 0; i < n; i++)
- marker[i] = i;
-
- while (0 == (r = archive_entry_acl_next(ae, want_type,
- &type, &permset, &tag, &qual, &name))) {
- for (i = 0, matched = 0; i < n && !matched; i++) {
- if (acl_match(&acls[marker[i]], type, permset,
- tag, name)) {
- /* We found a match; remove it. */
- marker[i] = marker[n - 1];
- n--;
- matched = 1;
- }
- }
- if (tag == ARCHIVE_ENTRY_ACL_USER_OBJ) {
- if (!matched) printf("No match for user_obj perm\n");
- if (want_type == ARCHIVE_ENTRY_ACL_TYPE_ACCESS) {
- failure("USER_OBJ permset (%02o) != user mode (%02o)",
- permset, 07 & (mode >> 6));
- assert((permset << 6) == (mode & 0700));
- }
- } else if (tag == ARCHIVE_ENTRY_ACL_GROUP_OBJ) {
- if (!matched) printf("No match for group_obj perm\n");
- if (want_type == ARCHIVE_ENTRY_ACL_TYPE_ACCESS) {
- failure("GROUP_OBJ permset %02o != group mode %02o",
- permset, 07 & (mode >> 3));
- assert((permset << 3) == (mode & 0070));
- }
- } else if (tag == ARCHIVE_ENTRY_ACL_OTHER) {
- if (!matched) printf("No match for other perm\n");
- if (want_type == ARCHIVE_ENTRY_ACL_TYPE_ACCESS) {
- failure("OTHER permset (%02o) != other mode (%02o)",
- permset, mode & 07);
- assert((permset << 0) == (mode & 0007));
- }
- } else if (tag != ARCHIVE_ENTRY_ACL_MASK) {
- failure("Could not find match for ACL "
- "(type=%d,permset=%d,tag=%d,name=``%s'')",
- type, permset, tag, name);
- assert(matched == 1);
- }
- }
- assertEqualInt(ARCHIVE_EOF, r);
- assert((mode_t)(mode & 0777) == (archive_entry_mode(ae) & 0777));
- failure("Could not find match for ACL "
- "(type=%d,permset=%d,tag=%d,name=``%s'')",
- acls[marker[0]].type, acls[marker[0]].permset,
- acls[marker[0]].tag, acls[marker[0]].name);
- assert(n == 0); /* Number of ACLs not matched should == 0 */
- free(marker);
-}
-
-DEFINE_TEST(test_compat_star_acl_posix1e)
-{
- char name[] = "test_compat_star_acl_posix1e.tar";
- struct archive *a;
- struct archive_entry *ae;
-
- /* Read archive file */
- assert(NULL != (a = archive_read_new()));
- assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
- assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
- extract_reference_file(name);
- assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, name, 10240));
-
- /* First item has a few ACLs */
- assertA(0 == archive_read_next_header(a, &ae));
- failure("One extended ACL should flag all ACLs to be returned.");
- assertEqualInt(5, archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS));
- compare_acls(ae, acls0, sizeof(acls0)/sizeof(acls0[0]), 0142, ARCHIVE_ENTRY_ACL_TYPE_ACCESS);
- failure("Basic ACLs should set mode to 0142, not %04o",
- archive_entry_mode(ae)&0777);
- assert((archive_entry_mode(ae) & 0777) == 0142);
-
- /* Second item has pretty extensive ACLs */
- assertA(0 == archive_read_next_header(a, &ae));
- assertEqualInt(7, archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS));
- compare_acls(ae, acls1, sizeof(acls1)/sizeof(acls1[0]), 0543, ARCHIVE_ENTRY_ACL_TYPE_ACCESS);
- failure("Basic ACLs should set mode to 0543, not %04o",
- archive_entry_mode(ae)&0777);
- assert((archive_entry_mode(ae) & 0777) == 0543);
-
- /* Third item has default ACLs */
- assertA(0 == archive_read_next_header(a, &ae));
- assertEqualInt(6, archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_DEFAULT));
- compare_acls(ae, acls2, sizeof(acls2)/sizeof(acls2[0]), 0142, ARCHIVE_ENTRY_ACL_TYPE_DEFAULT);
- failure("Basic ACLs should set mode to 0142, not %04o",
- archive_entry_mode(ae)&0777);
- assert((archive_entry_mode(ae) & 0777) == 0142);
-
- /* Close the archive. */
- assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
- assertEqualInt(ARCHIVE_OK, archive_read_free(a));
-}
diff --git a/contrib/libarchive/libarchive/test/test_compat_uudecode.c b/contrib/libarchive/libarchive/test/test_compat_uudecode.c
index 95b1c9a..cfb17c8 100644
--- a/contrib/libarchive/libarchive/test/test_compat_uudecode.c
+++ b/contrib/libarchive/libarchive/test/test_compat_uudecode.c
@@ -40,7 +40,7 @@ static char archive_data[] = {
};
/*
- * Compatibility: uudecode command ignores junk data placed ater the "end"
+ * Compatibility: uudecode command ignores junk data placed after the "end"
* marker.
*/
DEFINE_TEST(test_compat_uudecode)
diff --git a/contrib/libarchive/libarchive/test/test_fuzz.c b/contrib/libarchive/libarchive/test/test_fuzz.c
index b70a415a..e896f60 100644
--- a/contrib/libarchive/libarchive/test/test_fuzz.c
+++ b/contrib/libarchive/libarchive/test/test_fuzz.c
@@ -406,10 +406,12 @@ DEFINE_TEST(test_fuzz_tar)
"test_read_format_tar_empty_filename.tar",
NULL
};
+#if HAVE_LIBLZO2 && HAVE_LZO_LZO1X_H && HAVE_LZO_LZOCONF_H
static const char *fileset9[] = {
"test_compat_lzop_1.tar.lzo",
NULL
};
+#endif
static const struct files filesets[] = {
{0, fileset1}, /* Exercise bzip2 decompressor. */
{1, fileset1},
@@ -420,7 +422,9 @@ DEFINE_TEST(test_fuzz_tar)
{0, fileset6}, /* Exercise xz decompressor. */
{0, fileset7},
{0, fileset8},
+#if HAVE_LIBLZO2 && HAVE_LZO_LZO1X_H && HAVE_LZO_LZOCONF_H
{0, fileset9}, /* Exercise lzo decompressor. */
+#endif
{1, NULL}
};
test_fuzz(filesets);
diff --git a/contrib/libarchive/libarchive/test/test_read_disk_directory_traversals.c b/contrib/libarchive/libarchive/test/test_read_disk_directory_traversals.c
index 31eb76b..c9aca8f 100644
--- a/contrib/libarchive/libarchive/test/test_read_disk_directory_traversals.c
+++ b/contrib/libarchive/libarchive/test/test_read_disk_directory_traversals.c
@@ -1320,11 +1320,13 @@ test_callbacks(void)
assertUtimes("cb", 886622, 0, 886622, 0);
assert((ae = archive_entry_new()) != NULL);
- if (assert((a = archive_read_disk_new()) != NULL)) {
+ assert((a = archive_read_disk_new()) != NULL);
+ if (a == NULL) {
archive_entry_free(ae);
return;
}
- if (assert((m = archive_match_new()) != NULL)) {
+ assert((m = archive_match_new()) != NULL);
+ if (m == NULL) {
archive_entry_free(ae);
archive_read_free(a);
archive_match_free(m);
@@ -1377,6 +1379,10 @@ test_callbacks(void)
/* Close the disk object. */
assertEqualInt(ARCHIVE_OK, archive_read_close(a));
+ /* Reset name filter */
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_disk_set_matching(a, NULL, NULL, NULL));
+
/*
* Test2: Traversals with a metadata filter.
*/
@@ -1394,7 +1400,7 @@ test_callbacks(void)
while (file_count--) {
archive_entry_clear(ae);
assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header2(a, ae));
- failure("File 'cb/f1' should be exclueded");
+ failure("File 'cb/f1' should be excluded");
assert(strcmp(archive_entry_pathname(ae), "cb/f1") != 0);
if (strcmp(archive_entry_pathname(ae), "cb") == 0) {
assertEqualInt(archive_entry_filetype(ae), AE_IFDIR);
diff --git a/contrib/libarchive/libarchive/test/test_read_filter_lzop.c b/contrib/libarchive/libarchive/test/test_read_filter_lzop.c
index 86a5e6e..acce6a4 100644
--- a/contrib/libarchive/libarchive/test/test_read_filter_lzop.c
+++ b/contrib/libarchive/libarchive/test/test_read_filter_lzop.c
@@ -39,13 +39,16 @@ DEFINE_TEST(test_read_filter_lzop)
assert((a = archive_read_new()) != NULL);
r = archive_read_support_filter_lzop(a);
if (r != ARCHIVE_OK) {
- if (r == ARCHIVE_WARN && !canLzop()) {
+ if (!canLzop()) {
assertEqualInt(ARCHIVE_OK, archive_read_free(a));
skipping("lzop compression is not supported "
"on this platform");
- } else
+ return;
+ } else if (r != ARCHIVE_WARN) {
assertEqualIntA(a, ARCHIVE_OK, r);
- return;
+ assertEqualInt(ARCHIVE_OK, archive_read_free(a));
+ return;
+ }
}
assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
assertEqualIntA(a, ARCHIVE_OK,
diff --git a/contrib/libarchive/libarchive/test/test_read_filter_lzop_multiple_parts.c b/contrib/libarchive/libarchive/test/test_read_filter_lzop_multiple_parts.c
index 3b0febb..82eaf35 100644
--- a/contrib/libarchive/libarchive/test/test_read_filter_lzop_multiple_parts.c
+++ b/contrib/libarchive/libarchive/test/test_read_filter_lzop_multiple_parts.c
@@ -36,12 +36,16 @@ DEFINE_TEST(test_read_filter_lzop_multiple_parts)
assert((a = archive_read_new()) != NULL);
r = archive_read_support_filter_lzop(a);
if (r != ARCHIVE_OK) {
- if (r == ARCHIVE_WARN && !canLzop()) {
- assertEqualInt(ARCHIVE_OK, archive_read_free(a));
+ if (!canLzop()) {
skipping("lzop compression is not supported "
"on this platform");
+ } else if (r == ARCHIVE_WARN) {
+ skipping("lzop multiple parts decoding is not "
+ "supported via external program");
+
} else
assertEqualIntA(a, ARCHIVE_OK, r);
+ assertEqualInt(ARCHIVE_OK, archive_read_free(a));
return;
}
assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
diff --git a/contrib/libarchive/libarchive/test/test_read_format_7zip.c b/contrib/libarchive/libarchive/test/test_read_format_7zip.c
index 14447de..1d1e4c7 100644
--- a/contrib/libarchive/libarchive/test/test_read_format_7zip.c
+++ b/contrib/libarchive/libarchive/test/test_read_format_7zip.c
@@ -688,7 +688,7 @@ test_symname()
assertEqualInt(32, archive_read_data(a, buff, sizeof(buff)));
assertEqualMem(buff, "hellohellohello\nhellohellohello\n", 32);
- /* Verify symbolic-linke symlinkfile. */
+ /* Verify symbolic-link symlinkfile. */
assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
assertEqualInt((AE_IFLNK | 0755), archive_entry_mode(ae));
assertEqualString("symlinkfile", archive_entry_pathname(ae));
diff --git a/contrib/libarchive/libarchive/test/test_read_format_cpio_afio.c b/contrib/libarchive/libarchive/test/test_read_format_cpio_afio.c
index 16065eb..95d3171 100644
--- a/contrib/libarchive/libarchive/test/test_read_format_cpio_afio.c
+++ b/contrib/libarchive/libarchive/test/test_read_format_cpio_afio.c
@@ -27,7 +27,7 @@
__FBSDID("$FreeBSD$");
/*
-ecute the following to rebuild the data for this program:
+execute the following to rebuild the data for this program:
tail -n +33 test_read_format_cpio_afio.c | /bin/sh
# How to make a sample data.
diff --git a/contrib/libarchive/libarchive/test/test_read_format_isorr_bz2.c b/contrib/libarchive/libarchive/test/test_read_format_isorr_bz2.c
index 3cb30a4..bff385c 100644
--- a/contrib/libarchive/libarchive/test/test_read_format_isorr_bz2.c
+++ b/contrib/libarchive/libarchive/test/test_read_format_isorr_bz2.c
@@ -26,7 +26,7 @@
__FBSDID("$FreeBSD$");
/*
-PLEASE use old cdrtools; mkisofs verion is 2.01.
+PLEASE use old cdrtools; mkisofs version is 2.01.
This version mkisofs made wrong "SL" System Use Entry of RRIP.
Execute the following command to rebuild the data for this program:
diff --git a/contrib/libarchive/libarchive/test/test_read_format_zip.c b/contrib/libarchive/libarchive/test/test_read_format_zip.c
index 62a49ba..29b3fc2 100644
--- a/contrib/libarchive/libarchive/test/test_read_format_zip.c
+++ b/contrib/libarchive/libarchive/test/test_read_format_zip.c
@@ -126,6 +126,7 @@ test_basic(void)
assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
assertEqualIntA(a, ARCHIVE_OK, read_open_memory(a, p, s, 31));
verify_basic(a, 0);
+ free(p);
}
/*
@@ -195,6 +196,7 @@ test_info_zip_ux(void)
assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
assertEqualIntA(a, ARCHIVE_OK, read_open_memory(a, p, s, 108));
verify_info_zip_ux(a, 0);
+ free(p);
}
/*
@@ -258,6 +260,7 @@ test_extract_length_at_end(void)
assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
assertEqualIntA(a, ARCHIVE_OK, read_open_memory(a, p, s, 108));
verify_extract_length_at_end(a, 0);
+ free(p);
}
static void
@@ -294,6 +297,8 @@ test_symlink(void)
assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
assertEqualIntA(a, ARCHIVE_OK, archive_read_free(a));
+
+ free(p);
}
DEFINE_TEST(test_read_format_zip)
diff --git a/contrib/libarchive/libarchive/test/test_read_format_zip_comment_stored.c b/contrib/libarchive/libarchive/test/test_read_format_zip_comment_stored.c
index d2b935d..b92b288 100644
--- a/contrib/libarchive/libarchive/test/test_read_format_zip_comment_stored.c
+++ b/contrib/libarchive/libarchive/test/test_read_format_zip_comment_stored.c
@@ -63,6 +63,8 @@ verify(const char *refname)
assertEqualInt(archive_entry_is_encrypted(ae), 0);
assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
assertEqualIntA(a, ARCHIVE_OK, archive_read_free(a));
+
+ free(p);
}
DEFINE_TEST(test_read_format_zip_comment_stored)
diff --git a/contrib/libarchive/libarchive/test/test_read_format_zip_filename.c b/contrib/libarchive/libarchive/test/test_read_format_zip_filename.c
index 93ba09b..4dd2e8a 100644
--- a/contrib/libarchive/libarchive/test/test_read_format_zip_filename.c
+++ b/contrib/libarchive/libarchive/test/test_read_format_zip_filename.c
@@ -1116,7 +1116,7 @@ cleanup:
* - the filename of second file is stored in UTF-8.
*
* Whenever hdrcharset option is specified, we will correctly read the
- * filename of sencod file, which is stored in UTF-8.
+ * filename of second file, which is stored in UTF-8.
*/
DEFINE_TEST(test_read_format_zip_filename_KOI8R_UTF8_2)
diff --git a/contrib/libarchive/libarchive/test/test_read_format_zip_mac_metadata.c b/contrib/libarchive/libarchive/test/test_read_format_zip_mac_metadata.c
index 97aa427..99b7012 100644
--- a/contrib/libarchive/libarchive/test/test_read_format_zip_mac_metadata.c
+++ b/contrib/libarchive/libarchive/test/test_read_format_zip_mac_metadata.c
@@ -112,4 +112,6 @@ DEFINE_TEST(test_read_format_zip_mac_metadata)
assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
assertEqualIntA(a, ARCHIVE_OK, archive_read_free(a));
+
+ free(p);
}
diff --git a/contrib/libarchive/libarchive/test/test_read_format_zip_malformed.c b/contrib/libarchive/libarchive/test/test_read_format_zip_malformed.c
index 2327d91..e14a3f5 100644
--- a/contrib/libarchive/libarchive/test/test_read_format_zip_malformed.c
+++ b/contrib/libarchive/libarchive/test/test_read_format_zip_malformed.c
@@ -53,6 +53,7 @@ test_malformed1(void)
assertEqualIntA(a, ARCHIVE_OK, read_open_memory(a, p, s, 31));
assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
assertEqualIntA(a, ARCHIVE_OK, archive_read_free(a));
+ free(p);
}
DEFINE_TEST(test_read_format_zip_malformed)
diff --git a/contrib/libarchive/libarchive/test/test_read_format_zip_nested.c b/contrib/libarchive/libarchive/test/test_read_format_zip_nested.c
index 6830afb..5f6edf2 100644
--- a/contrib/libarchive/libarchive/test/test_read_format_zip_nested.c
+++ b/contrib/libarchive/libarchive/test/test_read_format_zip_nested.c
@@ -65,6 +65,8 @@ DEFINE_TEST(test_read_format_zip_nested)
assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
assertEqualIntA(a, ARCHIVE_OK, archive_read_free(a));
+ free(p);
+
/* Inspect inner Zip. */
assert((a = archive_read_new()) != NULL);
assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_zip(a));
diff --git a/contrib/libarchive/libarchive/test/test_read_format_zip_padded.c b/contrib/libarchive/libarchive/test/test_read_format_zip_padded.c
index dae88ab..2094eca 100644
--- a/contrib/libarchive/libarchive/test/test_read_format_zip_padded.c
+++ b/contrib/libarchive/libarchive/test/test_read_format_zip_padded.c
@@ -53,6 +53,8 @@ verify_padded_archive(const char *refname)
assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
assertEqualIntA(a, ARCHIVE_OK, archive_read_free(a));
+
+ free(p);
}
/*
diff --git a/contrib/libarchive/libarchive/test/test_read_format_zip_sfx.c b/contrib/libarchive/libarchive/test/test_read_format_zip_sfx.c
index d5992d3..dc76ef9 100644
--- a/contrib/libarchive/libarchive/test/test_read_format_zip_sfx.c
+++ b/contrib/libarchive/libarchive/test/test_read_format_zip_sfx.c
@@ -60,4 +60,6 @@ DEFINE_TEST(test_read_format_zip_sfx)
assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
assertEqualIntA(a, ARCHIVE_OK, archive_read_free(a));
+
+ free(p);
}
diff --git a/contrib/libarchive/libarchive/test/test_read_format_zip_traditional_encryption_data.c b/contrib/libarchive/libarchive/test/test_read_format_zip_traditional_encryption_data.c
index 2700be1..3052615 100644
--- a/contrib/libarchive/libarchive/test/test_read_format_zip_traditional_encryption_data.c
+++ b/contrib/libarchive/libarchive/test/test_read_format_zip_traditional_encryption_data.c
@@ -28,7 +28,7 @@ __FBSDID("$FreeBSD$");
DEFINE_TEST(test_read_format_zip_traditional_encryption_data)
{
- /* This file is password protected (Traditional PKWARE Enctypted).
+ /* This file is password protected (Traditional PKWARE Encrypted).
The headers are NOT encrypted. Password is "12345678". */
const char *refname =
"test_read_format_zip_traditional_encryption_data.zip";
@@ -36,7 +36,7 @@ DEFINE_TEST(test_read_format_zip_traditional_encryption_data)
struct archive *a;
char buff[512];
- /* Check if running system has cryptographic functionarity. */
+ /* Check if running system has cryptographic functionality. */
assert((a = archive_write_new()) != NULL);
assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_zip(a));
assertEqualIntA(a, ARCHIVE_OK, archive_write_add_filter_none(a));
diff --git a/contrib/libarchive/libarchive/test/test_read_format_zip_winzip_aes.c b/contrib/libarchive/libarchive/test/test_read_format_zip_winzip_aes.c
index 082337d..cc1e311 100644
--- a/contrib/libarchive/libarchive/test/test_read_format_zip_winzip_aes.c
+++ b/contrib/libarchive/libarchive/test/test_read_format_zip_winzip_aes.c
@@ -33,7 +33,7 @@ test_winzip_aes(const char *refname, int need_libz)
struct archive *a;
char buff[512];
- /* Check if running system has cryptographic functionarity. */
+ /* Check if running system has cryptographic functionality. */
assert((a = archive_write_new()) != NULL);
assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_zip(a));
assertEqualIntA(a, ARCHIVE_OK, archive_write_add_filter_none(a));
diff --git a/contrib/libarchive/libarchive/test/test_read_format_zip_winzip_aes_large.c b/contrib/libarchive/libarchive/test/test_read_format_zip_winzip_aes_large.c
index a40d5cf..6c40ae7 100644
--- a/contrib/libarchive/libarchive/test/test_read_format_zip_winzip_aes_large.c
+++ b/contrib/libarchive/libarchive/test/test_read_format_zip_winzip_aes_large.c
@@ -34,7 +34,7 @@ DEFINE_TEST(test_read_format_zip_winzip_aes256_large)
char buff[512];
- /* Check if running system has cryptographic functionarity. */
+ /* Check if running system has cryptographic functionality. */
assert((a = archive_write_new()) != NULL);
assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_zip(a));
assertEqualIntA(a, ARCHIVE_OK, archive_write_add_filter_none(a));
diff --git a/contrib/libarchive/libarchive/test/test_read_pax_schily_xattr.c b/contrib/libarchive/libarchive/test/test_read_pax_schily_xattr.c
new file mode 100644
index 0000000..7554f6d
--- /dev/null
+++ b/contrib/libarchive/libarchive/test/test_read_pax_schily_xattr.c
@@ -0,0 +1,70 @@
+/*-
+ * Copyright (c) 2016 IBM Corporation
+ * Copyright (c) 2003-2007 Tim Kientzle
+ *
+ * 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 AUTHOR(S) ``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(S) 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 test case's code has been derived from test_entry.c
+ */
+#include "test.h"
+
+DEFINE_TEST(test_schily_xattr_pax)
+{
+ struct archive *a;
+ struct archive_entry *ae;
+ const char *refname = "test_read_pax_schily_xattr.tar";
+ const char *xname; /* For xattr tests. */
+ const void *xval; /* For xattr tests. */
+ size_t xsize; /* For xattr tests. */
+ const char *string, *array;
+
+ assert((a = archive_read_new()) != NULL);
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+
+ extract_reference_file(refname);
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_open_filename(a, refname, 10240));
+
+ assertEqualInt(ARCHIVE_OK, archive_read_next_header(a, &ae));
+ assertEqualInt(2, archive_entry_xattr_count(ae));
+ assertEqualInt(2, archive_entry_xattr_reset(ae));
+
+ assertEqualInt(0, archive_entry_xattr_next(ae, &xname, &xval, &xsize));
+ assertEqualString(xname, "security.selinux");
+ string = "system_u:object_r:unlabeled_t:s0";
+ assertEqualString(xval, string);
+ /* the xattr's value also contains the terminating \0 */
+ assertEqualInt((int)xsize, strlen(string) + 1);
+
+ assertEqualInt(0, archive_entry_xattr_next(ae, &xname, &xval, &xsize));
+ assertEqualString(xname, "security.ima");
+ assertEqualInt((int)xsize, 265);
+ /* we only compare the first 12 bytes */
+ array = "\x03\x02\x04\xb0\xe9\xd6\x79\x01\x00\x2b\xad\x1e";
+ assertEqualMem(xval, array, 12);
+
+ /* Close the archive. */
+ assertEqualInt(ARCHIVE_OK, archive_read_close(a));
+ assertEqualInt(ARCHIVE_OK, archive_read_free(a));
+}
diff --git a/contrib/libarchive/libarchive/test/test_read_pax_schily_xattr.tar.uu b/contrib/libarchive/libarchive/test/test_read_pax_schily_xattr.tar.uu
new file mode 100644
index 0000000..52f7a8f
--- /dev/null
+++ b/contrib/libarchive/libarchive/test/test_read_pax_schily_xattr.tar.uu
@@ -0,0 +1,231 @@
+begin 644 test_schily_xattr_pax.tar
+M+B]087A(96%D97)S+C$U,C4O8V]N9F9I;&5S````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````#`P,#`V-#0`,#`P,#`P,``P,#`P,#`P`#`P,#`P,#`P-C0W
+M`#$R-S$R,C$P-3`V`#`Q,C4V-@`@>```````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````!U<W1A<@`P,```````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M```````````````````````S,"!A=&EM93TQ-#8R,S`Y,S8Y+C<Q-#DW-3DP
+M.0HS,"!C=&EM93TQ-#8R,S`Y,S8Y+C<W.#DW-C(Q,PHR.38@4T-(24Q9+GAA
+M='1R+G-E8W5R:71Y+FEM83T#`@2PZ=9Y`0`KK1Z%635)4!FT,I"<49LTXR`'
+M@42;2R:POQ9`JQA=+16.AY^<_[XK597$><QT!GLCT8_IF@@:/Z<?]<HQ0T7I
+MO&87D9-4,L'!GUG'K%=]KEPC<<)&@`J)'T89MBPB7],R(#&7"#>W6X5O?Y6:
+M9^':P2MZR[4)$@W<NV(VUT&(R0R-_S>?)B6GX0U@<,0M%6YNMO%OG+IS%/.<
+M,"A(N&S.F9]=!*5=\).X."2$GUGJ,0C:@+G#$M_E8UQP,LU-G(8IKW^K^<8*
+M*3_.N0'%8.^$8S$`D9XOF+DK<<)U34U'_"O5/2<N#T*!'!4Z73X-X4W!/LCF
+M/,721A`CQF:PGDD/"C8W(%-#2$E,62YX871T<BYS96-U<FET>2YS96QI;G5X
+M/7-Y<W1E;5]U.F]B:F5C=%]R.G5N;&%B96QE9%]T.G,P``H`````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````````"XO8V]N9F9I;&5S
+M````````````````````````````````````````````````````````````
+M```````````````````````````````````````````````````````````P
+M,#`P-C0T`#`P,#`P,#``,#`P,#`P,``P,#`P,#`P,#`T,0`Q,C<Q,C(Q,#4P
+M-@`P,3,P-S,`(#``````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````=7-T87(`,#!R;V]T````````````````
+M`````````````````````')O;W0`````````````````````````````````
+M````,#`P,#`P,``P,#`P,#`P````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````+V5T8R]D969A=6QT+VEM82UP;VQI8WDN:6YA8W1I=F4*````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+9````````````````````````````````````
+`
+end
diff --git a/contrib/libarchive/libarchive/test/test_sparse_basic.c b/contrib/libarchive/libarchive/test/test_sparse_basic.c
index 06f2c9d..9d45f0f 100644
--- a/contrib/libarchive/libarchive/test/test_sparse_basic.c
+++ b/contrib/libarchive/libarchive/test/test_sparse_basic.c
@@ -57,7 +57,7 @@ __FBSDID("$FreeBSD$");
/*
* NOTE: On FreeBSD and Solaris, this test needs ZFS.
- * You may should perfom this test as
+ * You may perform this test as
* 'TMPDIR=<a directory on the ZFS> libarchive_test'.
*/
diff --git a/contrib/libarchive/libarchive/test/test_write_disk_secure746.c b/contrib/libarchive/libarchive/test/test_write_disk_secure746.c
index 460aafe..5ce1fd9 100644
--- a/contrib/libarchive/libarchive/test/test_write_disk_secure746.c
+++ b/contrib/libarchive/libarchive/test/test_write_disk_secure746.c
@@ -72,6 +72,9 @@ DEFINE_TEST(test_write_disk_secure746a)
/* Verify that target file contents are unchanged. */
assertTextFileContents("unmodified", "../target/foo");
+
+ assertEqualIntA(a, ARCHIVE_FATAL, archive_write_close(a));
+ archive_write_free(a);
#endif
}
diff --git a/contrib/libarchive/libarchive/test/test_write_filter_lz4.c b/contrib/libarchive/libarchive/test/test_write_filter_lz4.c
index a043698..4f2135a 100644
--- a/contrib/libarchive/libarchive/test/test_write_filter_lz4.c
+++ b/contrib/libarchive/libarchive/test/test_write_filter_lz4.c
@@ -56,6 +56,7 @@ DEFINE_TEST(test_write_filter_lz4)
} else {
assertEqualInt(ARCHIVE_OK, r);
}
+ assertEqualInt(ARCHIVE_OK, archive_write_free(a));
buffsize = 2000000;
assert(NULL != (buff = (char *)malloc(buffsize)));
@@ -299,6 +300,7 @@ test_options(const char *options)
} else {
assertEqualInt(ARCHIVE_OK, r);
}
+ assertEqualInt(ARCHIVE_OK, archive_write_free(a));
buffsize = 2000000;
assert(NULL != (buff = (char *)malloc(buffsize)));
diff --git a/contrib/libarchive/libarchive/test/test_write_filter_lzop.c b/contrib/libarchive/libarchive/test/test_write_filter_lzop.c
index a32932c..92db7bf 100644
--- a/contrib/libarchive/libarchive/test/test_write_filter_lzop.c
+++ b/contrib/libarchive/libarchive/test/test_write_filter_lzop.c
@@ -43,12 +43,12 @@ DEFINE_TEST(test_write_filter_lzop)
assert((a = archive_write_new()) != NULL);
r = archive_write_add_filter_lzop(a);
+ assertEqualInt(ARCHIVE_OK, archive_write_free(a));
if (r != ARCHIVE_OK) {
if (canLzop() && r == ARCHIVE_WARN)
use_prog = 1;
else {
skipping("lzop writing not supported on this platform");
- assertEqualInt(ARCHIVE_OK, archive_write_free(a));
return;
}
}
@@ -92,7 +92,7 @@ DEFINE_TEST(test_write_filter_lzop)
assert((a = archive_read_new()) != NULL);
assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
r = archive_read_support_filter_lzop(a);
- if (r == ARCHIVE_WARN) {
+ if (r == ARCHIVE_WARN && !use_prog) {
skipping("Can't verify lzop writing by reading back;"
" lzop reading not fully supported on this platform");
} else {
@@ -212,7 +212,7 @@ DEFINE_TEST(test_write_filter_lzop)
assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
r = archive_read_support_filter_lzop(a);
- if (r == ARCHIVE_WARN) {
+ if (r == ARCHIVE_WARN && !use_prog) {
skipping("lzop reading not fully supported on this platform");
} else {
assertEqualIntA(a, ARCHIVE_OK,
diff --git a/contrib/libarchive/libarchive/test/test_write_format_iso9660.c b/contrib/libarchive/libarchive/test/test_write_format_iso9660.c
index ee6db6f..e4e98bb 100644
--- a/contrib/libarchive/libarchive/test/test_write_format_iso9660.c
+++ b/contrib/libarchive/libarchive/test/test_write_format_iso9660.c
@@ -719,7 +719,7 @@ DEFINE_TEST(test_write_format_iso9660)
assertEqualInt(5, archive_entry_ctime(ae));
assert(archive_entry_mtime_is_set(ae));
assertEqualInt(5, archive_entry_mtime(ae));
- /* Trim lngname to 64 characters. */
+ /* Trim longname to 64 characters. */
longname[64] = '\0';
assertEqualString(longname, archive_entry_pathname(ae));
assert((AE_IFREG | 0400) == archive_entry_mode(ae));
diff --git a/contrib/libarchive/libarchive/test/test_write_format_iso9660_zisofs.c b/contrib/libarchive/libarchive/test/test_write_format_iso9660_zisofs.c
index 136255b..2140ed8 100644
--- a/contrib/libarchive/libarchive/test/test_write_format_iso9660_zisofs.c
+++ b/contrib/libarchive/libarchive/test/test_write_format_iso9660_zisofs.c
@@ -25,7 +25,7 @@
#include "test.h"
/*
- * Check that a "zisofs" ISO 9660 imaeg is correctly created.
+ * Check that a "zisofs" ISO 9660 image is correctly created.
*/
static const unsigned char primary_id[] = {
diff --git a/contrib/libarchive/libarchive/test/test_write_format_zip_large.c b/contrib/libarchive/libarchive/test/test_write_format_zip_large.c
index d73dd62..88788b5 100644
--- a/contrib/libarchive/libarchive/test/test_write_format_zip_large.c
+++ b/contrib/libarchive/libarchive/test/test_write_format_zip_large.c
@@ -470,5 +470,6 @@ DEFINE_TEST(test_write_format_zip_large)
assertEqualMem(cd_start, "PK\001\002", 4);
fileblocks_free(fileblocks);
+ free(buff);
free(nulldata);
}
diff --git a/contrib/libarchive/libarchive/test/test_write_format_zip_zip64.c b/contrib/libarchive/libarchive/test/test_write_format_zip_zip64.c
index b83aeab..c5f00a2 100644
--- a/contrib/libarchive/libarchive/test/test_write_format_zip_zip64.c
+++ b/contrib/libarchive/libarchive/test/test_write_format_zip_zip64.c
@@ -49,6 +49,8 @@ verify_zip_filesize(uint64_t size, int expected)
archive_entry_set_size(ae, size);
assertEqualInt(expected, archive_write_header(a, ae));
+ archive_entry_free(ae);
+
/* Don't actually write 4GB! ;-) */
assertEqualIntA(a, ARCHIVE_OK, archive_write_free(a));
}
diff --git a/contrib/libarchive/libarchive/xxhash.c b/contrib/libarchive/libarchive/xxhash.c
index d7f8e96..6f5ba52 100644
--- a/contrib/libarchive/libarchive/xxhash.c
+++ b/contrib/libarchive/libarchive/xxhash.c
@@ -29,10 +29,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
You can contact the author at :
- xxHash source repository : http://code.google.com/p/xxhash/
*/
+#include "archive_platform.h"
+
#include <stdlib.h>
#include <string.h>
-#include "archive_platform.h"
#include "archive_xxhash.h"
#ifdef HAVE_LIBLZ4
@@ -60,7 +61,7 @@ You can contact the author at :
** By default, xxHash library provides endian-independent Hash values, based on little-endian convention.
** Results are therefore identical for little-endian and big-endian CPU.
** This comes at a performance cost for big-endian CPU, since some swapping is required to emulate little-endian format.
-** Should endian-independance be of no importance for your application, you may set the #define below to 1.
+** Should endian-independence be of no importance for your application, you may set the #define below to 1.
** It will improve speed for Big-endian CPU.
** This option has no impact on Little_Endian CPU.
*/
diff --git a/contrib/libarchive/tar/test/test_option_uid_uname.c b/contrib/libarchive/tar/test/test_option_uid_uname.c
index 0a8a9bb..80c0619 100644
--- a/contrib/libarchive/tar/test/test_option_uid_uname.c
+++ b/contrib/libarchive/tar/test/test_option_uid_uname.c
@@ -45,25 +45,25 @@ DEFINE_TEST(test_option_uid_uname)
/* Again with both --uid and --uname */
failure("Error invoking %s c", testprog);
assertEqualInt(0,
- systemf("%s cf archive2 --uid=17 --uname=foofoofoo --format=ustar file >stdout2.txt 2>stderr2.txt",
+ systemf("%s cf archive2 --uid=65123 --uname=foofoofoo --format=ustar file >stdout2.txt 2>stderr2.txt",
testprog));
assertEmptyFile("stdout2.txt");
assertEmptyFile("stderr2.txt");
data = slurpfile(&s, "archive2");
/* Should force uid and uname fields in ustar header. */
- assertEqualMem(data + 108, "000021 \0", 8);
+ assertEqualMem(data + 108, "177143 \0", 8);
assertEqualMem(data + 265, "foofoofoo\0", 10);
free(data);
/* Again with just --uid */
failure("Error invoking %s c", testprog);
assertEqualInt(0,
- systemf("%s cf archive3 --uid=17 --format=ustar file >stdout3.txt 2>stderr3.txt",
+ systemf("%s cf archive3 --uid=65123 --format=ustar file >stdout3.txt 2>stderr3.txt",
testprog));
assertEmptyFile("stdout3.txt");
assertEmptyFile("stderr3.txt");
data = slurpfile(&s, "archive3");
- assertEqualMem(data + 108, "000021 \0", 8);
+ assertEqualMem(data + 108, "177143 \0", 8);
/* Uname field in ustar header should be empty. */
assertEqualMem(data + 265, "\0", 1);
free(data);
diff --git a/contrib/libarchive/tar/util.c b/contrib/libarchive/tar/util.c
index f845600..84dc53f 100644
--- a/contrib/libarchive/tar/util.c
+++ b/contrib/libarchive/tar/util.c
@@ -140,6 +140,7 @@ safe_fprintf(FILE *f, const char *fmt, ...)
} else {
/* Leave fmtbuff pointing to the truncated
* string in fmtbuff_stack. */
+ fmtbuff = fmtbuff_stack;
length = sizeof(fmtbuff_stack) - 1;
break;
}
diff --git a/contrib/llvm/tools/lld/ELF/EhFrame.cpp b/contrib/llvm/tools/lld/ELF/EhFrame.cpp
index b130ac1..1f3d928 100644
--- a/contrib/llvm/tools/lld/ELF/EhFrame.cpp
+++ b/contrib/llvm/tools/lld/ELF/EhFrame.cpp
@@ -117,9 +117,8 @@ template <class ELFT> uint8_t getFdeEncoding(ArrayRef<uint8_t> D) {
StringRef Aug(reinterpret_cast<const char *>(D.begin()), AugEnd - D.begin());
D = D.slice(Aug.size() + 1);
- // Code alignment factor should always be 1 for .eh_frame.
- if (readByte(D) != 1)
- fatal("CIE code alignment must be 1");
+ // Skip code alignment factor.
+ skipLeb128(D);
// Skip data alignment factor.
skipLeb128(D);
diff --git a/contrib/netbsd-tests/crypto/libcrypto/t_libcrypto.sh b/contrib/netbsd-tests/crypto/libcrypto/t_libcrypto.sh
index aa7af27..f460cf5 100755
--- a/contrib/netbsd-tests/crypto/libcrypto/t_libcrypto.sh
+++ b/contrib/netbsd-tests/crypto/libcrypto/t_libcrypto.sh
@@ -1,4 +1,4 @@
-# $NetBSD: t_libcrypto.sh,v 1.3 2010/11/08 19:06:12 pooka Exp $
+# $NetBSD: t_libcrypto.sh,v 1.4 2016/10/13 09:25:37 martin Exp $
#
# Copyright (c) 2008, 2009, 2010 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -49,7 +49,7 @@ atf_test_case bn
bn_head()
{
atf_set "descr" "Checks BIGNUM library"
- atf_set "timeout" "300"
+ atf_set "timeout" "360"
}
bn_body()
{
diff --git a/contrib/netbsd-tests/crypto/libcrypto/t_pubkey.sh b/contrib/netbsd-tests/crypto/libcrypto/t_pubkey.sh
index 1453e75..eb8d0f5 100755
--- a/contrib/netbsd-tests/crypto/libcrypto/t_pubkey.sh
+++ b/contrib/netbsd-tests/crypto/libcrypto/t_pubkey.sh
@@ -1,4 +1,4 @@
-# $NetBSD: t_pubkey.sh,v 1.3 2011/06/09 05:25:21 spz Exp $
+# $NetBSD: t_pubkey.sh,v 1.4 2016/10/13 09:25:37 martin Exp $
#
# Copyright (c) 2008, 2009, 2010 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -49,7 +49,7 @@ atf_test_case rsa
rsa_head()
{
atf_set "descr" "Checks RSA"
- atf_set "timeout" "300"
+ atf_set "timeout" "420"
}
rsa_body()
{
@@ -60,7 +60,7 @@ atf_test_case ec
ec_head()
{
atf_set "descr" "Checks EC cipher"
- atf_set "timeout" "300"
+ atf_set "timeout" "480"
}
ec_body()
{
@@ -81,7 +81,7 @@ atf_test_case ecdsa
ecdsa_head()
{
atf_set "descr" "Checks ECDSA algorithm"
- atf_set "timeout" "300"
+ atf_set "timeout" "480"
}
ecdsa_body()
{
diff --git a/contrib/netbsd-tests/dev/audio/h_pad.c b/contrib/netbsd-tests/dev/audio/h_pad.c
index dd481ac..b760d04 100644
--- a/contrib/netbsd-tests/dev/audio/h_pad.c
+++ b/contrib/netbsd-tests/dev/audio/h_pad.c
@@ -1,4 +1,4 @@
-/* $NetBSD: h_pad.c,v 1.1 2010/08/04 13:15:15 pooka Exp $ */
+/* $NetBSD: h_pad.c,v 1.2 2016/10/15 07:08:06 nat Exp $ */
/*
* Copyright (c) 2010 Antti Kantee. All Rights Reserved.
@@ -56,14 +56,14 @@ main(int argc, char *argv[])
ssize_t n;
rump_init();
- audiofd = rump_sys_open("/dev/audio0", O_RDWR);
- if (audiofd == -1)
- err(1, "open audio");
-
padfd = rump_sys_open("/dev/pad0", O_RDONLY);
if (padfd == -1)
err(1, "open pad");
+ audiofd = rump_sys_open("/dev/audio0", O_RDWR);
+ if (audiofd == -1)
+ err(1, "open audio");
+
if ((n = rump_sys_write(audiofd, musa, sizeof(musa))) != sizeof(musa))
err(1, "write");
diff --git a/contrib/netbsd-tests/dev/audio/t_pad_output.bz2.uue b/contrib/netbsd-tests/dev/audio/t_pad_output.bz2.uue
index e0cbf52..969ad9c 100644
--- a/contrib/netbsd-tests/dev/audio/t_pad_output.bz2.uue
+++ b/contrib/netbsd-tests/dev/audio/t_pad_output.bz2.uue
@@ -1,1035 +1,1040 @@
begin 644 t_pad_output.bz2
-M0EIH.3%!629369%IQ#X`<IM_____________________________________
-M________X)OO)A21(@B``4"A15``"A2!1E]V5*%%*`!0JJ7"HT*HVT6^LZTT
-M13<F#E#=<'#>MT#FU'+1O7<;MT;NYNNYW<[N[OO;K>W7+>^Y[M;[LV]??=M]
-MYZ[MMMO>WO;6=W.KIOKNUF:EFEJVK5I"+:J;8:B5K1JJIJVUJV,K6IK5MJJ6
-M--%5FJLS55K158M5K:U5FU4RVMJ(K0BK-6Q0-L+6JVLJ6MK559M5556*M54J
-MJMIMFS-"U6LJRUBRJJRV;55::M6U[G=0JI5-4W66J=KVZ]LNW=]W=FW=S;YM
-MDO<]LW>Z[WW%E@WUOD-[G!SN<'=W$CD8@[K<FVD6>N<36:PVO=W;*I*E%4SC
-MV]XE)5!54*"@*JJMH)J0H*`4&V4`!11(``!4BJI27O>Z(]5()`22)**%4``I
-M0`!*B5`D(DB*5@:5``AH`"8F3"8`F0#3(Q,FF@#1H&(&C)H-#3330!ID,C`C
-M!-,F)IIA`TQ-,!,33$831@@R9&$T`!,`@TD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*%U/`\_3^%CA(UBF4Y#.[K;.\
+M-_/=\VU`)VV'2H&[\#FA>1%;Q_-V-L"(8N*I\G9K#EFV5"SO#Y=6"UFFI6+T
+M3G+?98@!?,N;SYNO-.T8M3+PL)2>9#)_:((%!7?$WL?Z+82G"_Z`=OG/?>X$
+M"&`^X.FC>[0?+XWG3LRP=J&B24*S8%_AM-Y>7>3POP4P"3^'QQ&\B%E96U-=
+M_\T+P!3FTZN)(:$?3(77,J!;MN[Q((..(R75&P._B_E)98!$.?H&V,<(NF#W
+MF7N*87EGT[@F`5/X:++MT"ZV@$,O+Q6/Q<!`KK(JEA&&H<WD=ITJD`(#*(Y"
+MLF&_<S+-.ZM8<$A2G`/IRP-/W_$]))$!B6;M.$@Q:U+5/T]*"+)+&[40F`\/
+M[D8+OS*]>I=\_Y(5TRD@`E6_MV&KS%1I_M<N1O)X)3`S0J'#-Z/<1+G.H2(F
+MB/?XCB'U0-84@>!!;Z,JUFJ07_E],9`K_8=._^^O$]@_T6;`9K+P7A[JFLEQ
+M(2)4E`Y;&DU,7U0]BB(@SF,#?$X"S:[ZWZ;?##S]/:.EM;R+\[!7)6`)*;Y)
+MO\9Q?9T)`@D,8&,8P,8))[<?/)JL`JR]5M$@RQ@1/.BAL7VWT+^WAAU?9.T%
+M">Y5(@3H#&,8P,PF(Z[H9MWSG1Z`MWE3#(#!(0Z[^<"%UJ_/$N7C^=F=5,B)
+9@#N8461T+A7W1J)TTW_Q=R13A0D`S39&D(#!
`
end
diff --git a/contrib/netbsd-tests/dev/cgd/t_cgd_3des.c b/contrib/netbsd-tests/dev/cgd/t_cgd_3des.c
new file mode 100644
index 0000000..91e81f4
--- /dev/null
+++ b/contrib/netbsd-tests/dev/cgd/t_cgd_3des.c
@@ -0,0 +1,913 @@
+/* $NetBSD: t_cgd_3des.c,v 1.1 2016/11/11 07:39:58 alnsn Exp $ */
+/*-
+ * Copyright (c) 2016 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Alexander Nasonov.
+ *
+ * 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 HOLDERS 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.
+ */
+
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <sys/sysctl.h>
+
+#include <atf-c.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <util.h>
+
+#include <dev/cgdvar.h>
+
+#include <rump/rump.h>
+#include <rump/rump_syscalls.h>
+
+#include "../../h_macros.h"
+
+#define SECSIZE 512
+
+struct testvec {
+ unsigned int blkno;
+ const uint8_t *ptxt; /* PlainText */
+ const uint8_t *ctxt; /* CipherText */
+};
+
+/*
+ * 192 bits CBC key, NUL terminated.
+ */
+static const char c3des_cbc_192_key[25] = {
+ 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, /* ABCDEFGH */
+ 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, /* IJKLMNOP */
+ 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, /* QRSTUVWX */
+ 0
+};
+
+static const uint8_t c3des_cbc_ptxt[SECSIZE] =
+ " abcdefghijklmnop"
+ " abcdefghijklmnop"
+ " abcdefghijklmnop"
+ " abcdefghijklmnop"
+ " abcdefghijklmnop"
+ " abcdefghijklmnop"
+ " abcdefghijklmnop"
+ " abcdefghijklmnop"
+ " abcdefghijklmnop"
+ " abcdefghijklmnop"
+ " abcdefghijklmnop"
+ " abcdefghijklmnop"
+ " abcdefghijklmnop"
+ " abcdefghijklmnop"
+ " abcdefghijklmnop"
+ " abcdefghijklmnop";
+
+/*
+ * IV method encblkno1, blkno 0.
+ */
+static const uint8_t c3des_cbc_192_encblkno1_vec0_ctxt[SECSIZE] = {
+ 0x19, 0x92, 0xc8, 0xce, 0xdf, 0xa3, 0x14, 0xef,
+ 0xff, 0x88, 0x9f, 0x01, 0xfa, 0x6f, 0xfa, 0xa6,
+ 0xdd, 0x2b, 0x43, 0x67, 0xfa, 0xce, 0x37, 0x95,
+ 0x73, 0x4d, 0x18, 0x33, 0x0c, 0x29, 0xb6, 0xbb,
+ 0x37, 0x77, 0x31, 0x74, 0xf6, 0x62, 0x03, 0xd2,
+ 0x78, 0x13, 0x55, 0xf6, 0x58, 0x49, 0xaf, 0x2a,
+ 0x15, 0x4c, 0xc2, 0x4a, 0x55, 0x99, 0x82, 0xb9,
+ 0xfb, 0x8b, 0x4f, 0x92, 0xe3, 0xbc, 0x9b, 0x09,
+ 0x42, 0x7b, 0x5f, 0x54, 0xed, 0xf0, 0xcb, 0x5d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x26, 0x76, 0x41, 0x28, 0x87, 0xf4, 0x51,
+ 0x14, 0x36, 0xad, 0x60, 0x8d, 0xe9, 0xe2, 0x9d,
+ 0x3c, 0xea, 0x09, 0x51, 0x3c, 0x81, 0xdf, 0x1a,
+ 0xc2, 0xc2, 0xf6, 0x45, 0xe1, 0x73, 0xac, 0xae,
+ 0x85, 0x74, 0x83, 0x8f, 0x56, 0x3c, 0x36, 0x1c,
+ 0xe0, 0x07, 0xc6, 0x6a, 0x48, 0xe4, 0x34, 0xe9,
+ 0x81, 0x53, 0xb7, 0x53, 0x95, 0xa7, 0x94, 0x21,
+ 0x7e, 0x32, 0x53, 0xda, 0x83, 0xd8, 0x57, 0x92,
+ 0xd1, 0x15, 0x45, 0x86, 0x40, 0xac, 0xf1, 0x6f,
+ 0x3c, 0x29, 0xef, 0x8d, 0x12, 0xe1, 0x9d, 0x04,
+ 0x17, 0x3a, 0xcc, 0xa6, 0xc5, 0xe4, 0x27, 0x41,
+ 0xcb, 0xfb, 0x5e, 0x77, 0x73, 0x5a, 0x2c, 0x03,
+ 0xe9, 0x2b, 0x76, 0x4e, 0x69, 0xea, 0xcb, 0xb3,
+};
+
+/*
+ * IV method encblkno1, blkno 2.
+ */
+static const uint8_t c3des_cbc_192_encblkno1_vec2_ctxt[SECSIZE] = {
+ 0x87, 0xb1, 0x3c, 0xd6, 0x60, 0xa0, 0x5a, 0x35,
+ 0xf7, 0xe1, 0x6b, 0x87, 0xa0, 0x90, 0x2f, 0xc7,
+ 0x8c, 0xed, 0x53, 0xda, 0x93, 0x32, 0x78, 0x5d,
+ 0x24, 0x23, 0x42, 0xdd, 0x93, 0x5b, 0x2e, 0x40,
+ 0xa1, 0xb1, 0x3b, 0xbb, 0xf0, 0x50, 0xb4, 0x61,
+ 0xea, 0x15, 0x37, 0xf3, 0x49, 0xe1, 0xa0, 0x32,
+ 0x88, 0x85, 0x81, 0xfd, 0xb7, 0x96, 0xd7, 0x9d,
+ 0xd7, 0x29, 0x4b, 0x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2a, 0x8c, 0x76, 0xc4, 0xed, 0x09, 0xe6, 0x00,
+ 0x28, 0xdb, 0x9b, 0x44, 0xb0, 0xb4, 0x7b, 0x57,
+ 0x3b, 0xb6, 0x4f, 0x0b, 0xff, 0xf2, 0xf5, 0x02,
+ 0x56, 0xcf, 0xd5, 0xbf, 0x71, 0xe6, 0x66, 0xf3,
+ 0x08, 0x8e, 0x8b, 0x15, 0x57, 0x07, 0x41, 0xa3,
+ 0x91, 0xc1, 0xe4, 0x64, 0x92, 0x89, 0xed, 0x22,
+ 0x88, 0x8f, 0x17, 0x91, 0xde, 0xea, 0x0c, 0xa6,
+ 0x86, 0x8e, 0x4c, 0xd9, 0x63, 0xc9, 0xe5, 0xdc,
+ 0xd6, 0xd3, 0x7b, 0x2b, 0x65, 0xfa, 0x36, 0x47,
+ 0x20, 0xa4, 0xe7, 0x0b, 0x52, 0xfa, 0xa6, 0xeb,
+ 0x1d, 0x20, 0xd0, 0x4b, 0xfd, 0x88, 0x8c, 0xbb,
+ 0x52, 0x9c, 0x2f, 0xb7, 0xba, 0x8b, 0xdd, 0x10,
+ 0x2d, 0x7d, 0x77, 0x79, 0x40, 0xa7, 0xed, 0xf9,
+ 0xbd, 0x2a, 0x55, 0x1f, 0x87, 0x1e, 0x3c, 0xfc,
+};
+
+const struct testvec c3des_cbc_192_1_vectors[] = {
+ {
+ .blkno = 0,
+ .ptxt = c3des_cbc_ptxt,
+ .ctxt = c3des_cbc_192_encblkno1_vec0_ctxt,
+ },
+ {
+ .blkno = 1,
+ .ptxt = c3des_cbc_ptxt,
+ .ctxt = c3des_cbc_192_encblkno1_vec1_ctxt,
+ },
+ {
+ .blkno = 2,
+ .ptxt = c3des_cbc_ptxt,
+ .ctxt = c3des_cbc_192_encblkno1_vec2_ctxt,
+ },
+ {
+ .blkno = 3,
+ .ptxt = c3des_cbc_ptxt,
+ .ctxt = c3des_cbc_192_encblkno1_vec3_ctxt,
+ },
+};
+
+/*
+ * IV method encblkno8, blkno 0.
+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0x72, 0xa6,
+ 0x38, 0x18, 0x8f, 0xb5, 0x54, 0xb3, 0x69, 0x63,
+ 0x6a, 0xdc, 0xb1, 0x5a, 0x12, 0x7a, 0x0b, 0xa3,
+};
+
+const struct testvec c3des_cbc_192_8_vectors[] = {
+ {
+ .blkno = 0,
+ .ptxt = c3des_cbc_ptxt,
+ .ctxt = c3des_cbc_192_encblkno8_vec0_ctxt,
+ },
+ {
+ .blkno = 1,
+ .ptxt = c3des_cbc_ptxt,
+ .ctxt = c3des_cbc_192_encblkno8_vec1_ctxt,
+ },
+ {
+ .blkno = 2,
+ .ptxt = c3des_cbc_ptxt,
+ .ctxt = c3des_cbc_192_encblkno8_vec2_ctxt,
+ },
+ {
+ .blkno = 3,
+ .ptxt = c3des_cbc_ptxt,
+ .ctxt = c3des_cbc_192_encblkno8_vec3_ctxt,
+ },
+};
+
+static int
+open_disk(const char *devpath, const char *imgpath, size_t size)
+{
+ int fd;
+
+ fd = open(imgpath, O_CREAT | O_RDWR | O_TRUNC, 0600);
+ if (fd < 0)
+ return -1;
+
+ if (ftruncate(fd, size) < 0)
+ goto fail;
+
+ if (rump_pub_etfs_register_withsize(devpath,
+ imgpath, RUMP_ETFS_BLK, 0, size) < 0) {
+ goto fail;
+ }
+
+ unlink(imgpath);
+ return fd;
+fail:
+ close(fd);
+ unlink(imgpath);
+ return -1;
+}
+
+static int
+open_cgd(int devno)
+{
+ char devpath[32];
+
+ sprintf(devpath, "/dev/rcgd%d%c", devno, getrawpartition() + 'a');
+
+ return rump_sys_open(devpath, O_RDWR, 0);
+}
+
+static int
+configure_cgd(int fd, const char *dkpath, const char *alg,
+ const char *ivmethod, const char *key, size_t keylen)
+{
+ struct cgd_ioctl ci;
+
+ memset(&ci, 0, sizeof(ci));
+ ci.ci_disk = dkpath;
+ ci.ci_alg = alg;
+ ci.ci_ivmethod = ivmethod;
+ ci.ci_keylen = 8 * keylen - 8; /* Exclude the NUL terminator. */
+ ci.ci_key = key;
+ ci.ci_blocksize = 64;
+
+ return rump_sys_ioctl(fd, CGDIOCSET, &ci);
+}
+
+static int
+unconfigure_cgd(int fd)
+{
+ struct cgd_ioctl ci;
+
+ return rump_sys_ioctl(fd, CGDIOCCLR, &ci);
+}
+
+static int
+write_testvec(int cgdfd, const struct testvec *tv)
+{
+
+ if (rump_sys_lseek(cgdfd, tv->blkno * SECSIZE, SEEK_SET) < 0)
+ return -1;
+
+ if (rump_sys_write(cgdfd, tv->ptxt, SECSIZE) != SECSIZE)
+ return -1;
+
+ return 0;
+}
+
+static int
+read_testvec(int cgdfd, const struct testvec *tv)
+{
+ char *buf;
+ int res = -1;
+
+ buf = malloc(SECSIZE);
+ if (buf == NULL)
+ return -1;
+
+ if (rump_sys_lseek(cgdfd, tv->blkno * SECSIZE, SEEK_SET) < 0)
+ goto fail;
+
+ if (rump_sys_read(cgdfd, buf, SECSIZE) != SECSIZE)
+ goto fail;
+
+ res = memcmp(buf, tv->ptxt, SECSIZE);
+fail:
+ free(buf);
+ return res;
+}
+
+static int
+check_testvec(int dkfd, const struct testvec *tv)
+{
+ char *buf;
+ int res = -1;
+
+ buf = malloc(SECSIZE);
+ if (buf == NULL)
+ return -1;
+
+ if (lseek(dkfd, tv->blkno * SECSIZE, SEEK_SET) < 0)
+ goto fail;
+
+ if (read(dkfd, buf, SECSIZE) != SECSIZE)
+ goto fail;
+
+ res = memcmp(buf, tv->ctxt, SECSIZE);
+fail:
+ free(buf);
+ return res;
+}
+
+ATF_TC(cgd_3des_cbc_192_encblkno1);
+ATF_TC_HEAD(cgd_3des_cbc_192_encblkno1, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Test 3des-cbc with 192 bits key, ivmethod encblkno1");
+}
+
+ATF_TC_BODY(cgd_3des_cbc_192_encblkno1, tc)
+{
+ const char imgpath[] = "3des-cbc-192-encblkno1.img";
+ const char *dkpath = "/dev/dk";
+ const size_t dksize = 4 * SECSIZE; /* Last blkno is 3. */
+ int dkfd, cgdfd;
+
+ rump_init();
+
+ RL(dkfd = open_disk(dkpath, imgpath, dksize));
+
+ RL(cgdfd = open_cgd(0));
+ RL(configure_cgd(cgdfd, dkpath, "3des-cbc", "encblkno1",
+ c3des_cbc_192_key, sizeof(c3des_cbc_192_key)));
+
+ ATF_CHECK_EQ(write_testvec(cgdfd, &c3des_cbc_192_1_vectors[0]), 0);
+ ATF_CHECK_EQ(write_testvec(cgdfd, &c3des_cbc_192_1_vectors[1]), 0);
+ ATF_CHECK_EQ(write_testvec(cgdfd, &c3des_cbc_192_1_vectors[2]), 0);
+ ATF_CHECK_EQ(write_testvec(cgdfd, &c3des_cbc_192_1_vectors[3]), 0);
+
+ RL(unconfigure_cgd(cgdfd));
+ RL(configure_cgd(cgdfd, dkpath, "3des-cbc", "encblkno1",
+ c3des_cbc_192_key, sizeof(c3des_cbc_192_key)));
+
+ ATF_CHECK_EQ(read_testvec(cgdfd, &c3des_cbc_192_1_vectors[0]), 0);
+ ATF_CHECK_EQ(read_testvec(cgdfd, &c3des_cbc_192_1_vectors[1]), 0);
+ ATF_CHECK_EQ(read_testvec(cgdfd, &c3des_cbc_192_1_vectors[2]), 0);
+ ATF_CHECK_EQ(read_testvec(cgdfd, &c3des_cbc_192_1_vectors[3]), 0);
+
+ RL(unconfigure_cgd(cgdfd));
+ RL(rump_sys_close(cgdfd));
+
+ ATF_CHECK_EQ(check_testvec(dkfd, &c3des_cbc_192_1_vectors[0]), 0);
+ ATF_CHECK_EQ(check_testvec(dkfd, &c3des_cbc_192_1_vectors[1]), 0);
+ ATF_CHECK_EQ(check_testvec(dkfd, &c3des_cbc_192_1_vectors[2]), 0);
+ ATF_CHECK_EQ(check_testvec(dkfd, &c3des_cbc_192_1_vectors[3]), 0);
+
+ RL(close(dkfd));
+}
+
+ATF_TC(cgd_3des_cbc_192_encblkno8);
+ATF_TC_HEAD(cgd_3des_cbc_192_encblkno8, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Test 3des-cbc with 192 bits key, ivmethod encblkno8");
+}
+
+ATF_TC_BODY(cgd_3des_cbc_192_encblkno8, tc)
+{
+ const char imgpath[] = "3des-cbc-192-encblkno8.img";
+ const char *dkpath = "/dev/dk";
+ const size_t dksize = 4 * SECSIZE; /* Last blkno is 3. */
+ int dkfd, cgdfd;
+
+ rump_init();
+
+ RL(dkfd = open_disk(dkpath, imgpath, dksize));
+
+ RL(cgdfd = open_cgd(0));
+ RL(configure_cgd(cgdfd, dkpath, "3des-cbc", "encblkno8",
+ c3des_cbc_192_key, sizeof(c3des_cbc_192_key)));
+
+ ATF_CHECK_EQ(write_testvec(cgdfd, &c3des_cbc_192_8_vectors[0]), 0);
+ ATF_CHECK_EQ(write_testvec(cgdfd, &c3des_cbc_192_8_vectors[1]), 0);
+ ATF_CHECK_EQ(write_testvec(cgdfd, &c3des_cbc_192_8_vectors[2]), 0);
+ ATF_CHECK_EQ(write_testvec(cgdfd, &c3des_cbc_192_8_vectors[3]), 0);
+
+ RL(unconfigure_cgd(cgdfd));
+ RL(configure_cgd(cgdfd, dkpath, "3des-cbc", "encblkno8",
+ c3des_cbc_192_key, sizeof(c3des_cbc_192_key)));
+
+ ATF_CHECK_EQ(read_testvec(cgdfd, &c3des_cbc_192_8_vectors[0]), 0);
+ ATF_CHECK_EQ(read_testvec(cgdfd, &c3des_cbc_192_8_vectors[1]), 0);
+ ATF_CHECK_EQ(read_testvec(cgdfd, &c3des_cbc_192_8_vectors[2]), 0);
+ ATF_CHECK_EQ(read_testvec(cgdfd, &c3des_cbc_192_8_vectors[3]), 0);
+
+ RL(unconfigure_cgd(cgdfd));
+ RL(rump_sys_close(cgdfd));
+
+ ATF_CHECK_EQ(check_testvec(dkfd, &c3des_cbc_192_8_vectors[0]), 0);
+ ATF_CHECK_EQ(check_testvec(dkfd, &c3des_cbc_192_8_vectors[1]), 0);
+ ATF_CHECK_EQ(check_testvec(dkfd, &c3des_cbc_192_8_vectors[2]), 0);
+ ATF_CHECK_EQ(check_testvec(dkfd, &c3des_cbc_192_8_vectors[3]), 0);
+
+ RL(close(dkfd));
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+
+ ATF_TP_ADD_TC(tp, cgd_3des_cbc_192_encblkno1);
+ ATF_TP_ADD_TC(tp, cgd_3des_cbc_192_encblkno8);
+
+ return atf_no_error();
+}
diff --git a/contrib/netbsd-tests/dev/cgd/t_cgd_aes.c b/contrib/netbsd-tests/dev/cgd/t_cgd_aes.c
new file mode 100644
index 0000000..9416333
--- /dev/null
+++ b/contrib/netbsd-tests/dev/cgd/t_cgd_aes.c
@@ -0,0 +1,3606 @@
+/* $NetBSD: t_cgd_aes.c,v 1.5 2016/12/11 00:23:44 alnsn Exp $ */
+/*-
+ * Copyright (c) 2016 The NetBSD Foundation, Inc.
+ * Copyright (c) 2007 The Institute of Electrical and Electronics Engineers, Inc
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Alexander Nasonov.
+ *
+ * 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 HOLDERS 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.
+ */
+
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <sys/sysctl.h>
+
+#include <atf-c.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <util.h>
+
+#include <dev/cgdvar.h>
+
+#include <rump/rump.h>
+#include <rump/rump_syscalls.h>
+
+#include "../../h_macros.h"
+
+#define SECSIZE 512
+
+struct testvec {
+ unsigned int blkno;
+ const uint8_t *ptxt; /* PlainText */
+ const uint8_t *ctxt; /* CipherText */
+};
+
+/*
+ * 128 bits CBC key, NUL terminated.
+ */
+static const char aes_cbc_128_key[17] = {
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* 01234567 */
+ 0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, /* 89ABCDEF */
+ 0
+};
+
+/*
+ * 192 bits CBC key, NUL terminated.
+ */
+static const char aes_cbc_192_key[25] = {
+ 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, /* ABCDEFGH */
+ 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, /* IJKLMNOP */
+ 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, /* QRSTUVWX */
+ 0
+};
+
+/*
+ * 256 bits CBC key, NUL terminated.
+ */
+static const char aes_cbc_256_key[33] = {
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* 01234567 */
+ 0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, /* 89ABCDEF */
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* 01234567 */
+ 0x38, 0x39, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, /* 89abcdef */
+ 0
+};
+
+static const uint8_t aes_cbc_ptxt[SECSIZE] =
+ " abcdefghijklmnop"
+ " abcdefghijklmnop"
+ " abcdefghijklmnop"
+ " abcdefghijklmnop"
+ " abcdefghijklmnop"
+ " abcdefghijklmnop"
+ " abcdefghijklmnop"
+ " abcdefghijklmnop"
+ " abcdefghijklmnop"
+ " abcdefghijklmnop"
+ " abcdefghijklmnop"
+ " abcdefghijklmnop"
+ " abcdefghijklmnop"
+ " abcdefghijklmnop"
+ " abcdefghijklmnop"
+ " abcdefghijklmnop";
+
+/*
+ * IV method encblkno1, blkno 0.
+ */
+static const uint8_t aes_cbc_128_encblkno1_vec0_ctxt[SECSIZE] = {
+ 0x1e, 0x95, 0x12, 0x15, 0xf6, 0xe0, 0xa7, 0x56,
+ 0x95, 0xa0, 0xa7, 0x35, 0x77, 0xf4, 0xdd, 0xdc,
+ 0x37, 0xc0, 0x28, 0x20, 0x00, 0x79, 0xa0, 0x35,
+ 0xe0, 0x83, 0x23, 0x95, 0x4e, 0xea, 0x8d, 0xa2,
+ 0x11, 0xbf, 0x9a, 0xd5, 0x21, 0x1e, 0x15, 0xb9,
+ 0xd1, 0x2e, 0xd2, 0xd9, 0xa5, 0xcc, 0x26, 0x75,
+ 0xba, 0x3e, 0x30, 0x11, 0xb2, 0x40, 0xdd, 0x1d,
+ 0x07, 0x3b, 0xe6, 0x00, 0xa7, 0x31, 0x9e, 0x58,
+ 0x41, 0xf3, 0x02, 0xf5, 0xad, 0x35, 0x79, 0x9a,
+ 0x9e, 0x03, 0xc8, 0x7a, 0x9d, 0x1d, 0x58, 0x9f,
+ 0x98, 0x67, 0xe2, 0x49, 0x81, 0x0c, 0x23, 0x90,
+ 0xd8, 0xc6, 0xf0, 0xc5, 0x73, 0x46, 0xd5, 0x14,
+ 0x1d, 0x78, 0x24,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 0x29, 0xe4, 0x3a, 0x56, 0x14, 0x20, 0x6f, 0x70,
+ 0x82, 0xea, 0x5d, 0xbc, 0x48, 0x89, 0x34, 0x69,
+ 0xdb, 0x4a, 0x06, 0xa7, 0xd6, 0xc7, 0xb7, 0x06,
+ 0x8e, 0x64, 0x21, 0x3e, 0xa6, 0x32, 0x61, 0x59,
+ 0x03, 0xea, 0xc3, 0x71, 0xf0, 0x26, 0x02, 0xe0,
+ 0x71, 0x95, 0x38, 0x11, 0x32, 0xe6, 0x3b, 0x25,
+ 0x53, 0x14, 0x24, 0x34, 0xe8, 0x8c, 0xa8, 0xef,
+ 0x52, 0xfe, 0x06, 0x2c, 0x20, 0x88, 0x4f, 0xa6,
+};
+
+/*
+ * IV method encblkno1, blkno 1.
+ */
+static const uint8_t aes_cbc_128_encblkno1_vec1_ctxt[SECSIZE] = {
+ 0x2f, 0x69, 0x3e, 0x95, 0x87, 0x91, 0x99, 0xd4,
+ 0xd9, 0x5d, 0xf2, 0x52, 0x32, 0x54, 0x2a, 0x80,
+ 0xa0, 0x77, 0x6e, 0x73, 0x15, 0xb4, 0xc9, 0x13,
+ 0x85, 0xed, 0x79, 0x9b, 0x84, 0x0a, 0x7e, 0xdb,
+ 0xee, 0x09, 0x78, 0x11, 0x28, 0xd5, 0x26, 0xec,
+ 0x1d, 0x52, 0xba, 0x33, 0x26, 0xeb, 0x91, 0xc6,
+ 0x4b, 0xf0, 0x38, 0xdf, 0x9f, 0x9d, 0x6c, 0xd8,
+ 0x49, 0x83, 0x88, 0xbe, 0x62, 0x2d, 0x5e, 0x88,
+ 0xc0, 0x35, 0xe4, 0xc3, 0xc9, 0x9f, 0x62, 0x59,
+ 0x16, 0xa7, 0x2e, 0xc0, 0xda, 0x3c, 0x2e, 0x10,
+ 0x53, 0xf0, 0x84, 0x27, 0x38, 0xd0, 0xf4, 0xb5,
+ 0x7c, 0x4a, 0x63, 0x04, 0x51, 0x22, 0xae, 0xf3,
+ 0xe7, 0x97, 0x53, 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16, 0xfb, 0xfc,
+ 0x13, 0xa7, 0xd1, 0xd8, 0xfd, 0x16, 0x39, 0x20,
+ 0xe0, 0xb2, 0xb4, 0xd5, 0x40, 0x93, 0x30, 0xf3,
+ 0xab, 0x88, 0xe3, 0xfb, 0xbe, 0xb8, 0x02, 0x3a,
+ 0x78, 0x2d, 0x56, 0x4b, 0x92, 0x5b, 0x0a, 0x8d,
+ 0x18, 0xa4, 0x5b, 0x11, 0x60, 0x0b, 0x45, 0xad,
+ 0x0b, 0x64, 0x96, 0x7d, 0x84, 0xf2, 0x20, 0xa8,
+ 0x95, 0x78, 0xb3, 0xb5, 0x98, 0x1f, 0xa7, 0x3e,
+ 0x30, 0x77, 0x43, 0xd2, 0x8c, 0x20, 0xc5, 0x5e,
+ 0x76, 0xcd, 0x2c, 0x7c, 0xfa, 0x34, 0x36, 0xda,
+ 0x39, 0x00, 0x2e, 0x69, 0x4a, 0xb3, 0x0f, 0x6f,
+};
+
+const struct testvec aes_cbc_128_1_vectors[] = {
+ {
+ .blkno = 0,
+ .ptxt = aes_cbc_ptxt,
+ .ctxt = aes_cbc_128_encblkno1_vec0_ctxt,
+ },
+ {
+ .blkno = 1,
+ .ptxt = aes_cbc_ptxt,
+ .ctxt = aes_cbc_128_encblkno1_vec1_ctxt,
+ },
+ {
+ .blkno = 2,
+ .ptxt = aes_cbc_ptxt,
+ .ctxt = aes_cbc_128_encblkno1_vec2_ctxt,
+ },
+ {
+ .blkno = 3,
+ .ptxt = aes_cbc_ptxt,
+ .ctxt = aes_cbc_128_encblkno1_vec3_ctxt,
+ },
+};
+
+/*
+ * IV method encblkno8, blkno 0.
+ */
+static const uint8_t aes_cbc_128_encblkno8_vec0_ctxt[SECSIZE] = {
+ 0xa6, 0x64, 0xef, 0x0f, 0xc4, 0x45, 0xcc, 0x5e,
+ 0xf8, 0x27, 0x42, 0x5e, 0xbd, 0x93, 0x99, 0xcd,
+ 0x79, 0xa8, 0x7d, 0x72, 0xc4, 0x02, 0x99, 0x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x84,
+ 0x48, 0x5f, 0xcd, 0xed, 0xce, 0x61, 0x6f, 0xa6,
+ 0x83, 0xa3, 0x34, 0xbe, 0xf2, 0x66, 0xf3, 0x09,
+ 0xf3, 0xd3, 0x97, 0xd4, 0xee, 0x66, 0x9a, 0x81,
+ 0x62, 0x84, 0x85, 0x7f, 0x79, 0x18, 0xd2, 0x82,
+ 0xd6, 0x96, 0x09, 0x61, 0x1e, 0x53, 0x97, 0x80,
+ 0x0a, 0x81, 0x4b, 0x93, 0xf0, 0x03, 0x65, 0x18,
+ 0x93, 0x5b, 0x60, 0x2f, 0xb5, 0xfe, 0x82, 0xaf,
+ 0x85, 0xb7, 0x79, 0x7c, 0xee, 0xad, 0xea, 0xfa,
+ 0x9b, 0xad, 0xca, 0x38, 0x21, 0x3d, 0x46, 0x8a,
+ 0x5b, 0xa7, 0x55, 0x3d, 0x88, 0x4a, 0x52, 0xdb,
+ 0xf2, 0x07, 0xed, 0xd6, 0x3c, 0x9f, 0x1b, 0x42,
+ 0xb4, 0x14, 0x12, 0xb7, 0x00, 0xfc, 0x6a, 0x79,
+ 0x61, 0x0b, 0x43, 0xaa, 0x44, 0x48, 0x30, 0x15,
+ 0x48, 0x76, 0x27, 0x32, 0x7a, 0x2e, 0x25, 0x6a,
+ 0x8c, 0x8c, 0x64, 0x67, 0x86, 0x54, 0x4a, 0x93,
+ 0x14, 0xfe, 0x81, 0xf5, 0xcf, 0x98, 0x92, 0xd3,
+ 0x92, 0xf5, 0x6a, 0x74, 0x28, 0x10, 0x6b, 0xd4,
+ 0x1d, 0x64, 0x7e, 0x05, 0x32, 0xba, 0xf7, 0x4c,
+ 0xe9, 0xa8, 0xa9, 0xc5, 0x35, 0x34, 0x26, 0x41,
+};
+
+/*
+ * IV method encblkno8, blkno 2.
+ */
+static const uint8_t aes_cbc_128_encblkno8_vec2_ctxt[SECSIZE] = {
+ 0x64, 0x7b, 0x62, 0x7a, 0xa6, 0xa9, 0xb3, 0x47,
+ 0xbc, 0x03,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no = 0,
+ .ptxt = aes_cbc_ptxt,
+ .ctxt = aes_cbc_128_encblkno8_vec0_ctxt,
+ },
+ {
+ .blkno = 1,
+ .ptxt = aes_cbc_ptxt,
+ .ctxt = aes_cbc_128_encblkno8_vec1_ctxt,
+ },
+ {
+ .blkno = 2,
+ .ptxt = aes_cbc_ptxt,
+ .ctxt = aes_cbc_128_encblkno8_vec2_ctxt,
+ },
+ {
+ .blkno = 3,
+ .ptxt = aes_cbc_ptxt,
+ .ctxt = aes_cbc_128_encblkno8_vec3_ctxt,
+ },
+};
+
+/*
+ * IV method encblkno1, blkno 0.
+ */
+static const uint8_t aes_cbc_192_encblkno1_vec0_ctxt[SECSIZE] = {
+ 0x7c, 0xc4, 0xec, 0x89, 0x7c, 0x13, 0xac, 0x99,
+ 0x49, 0xa9, 0x96, 0xe7, 0xb1, 0x1a, 0xd6, 0xb0,
+ 0xeb, 0x89, 0x27, 0x0f, 0x8b, 0x1b, 0xab, 0x8e,
+ 0x2c, 0xd4, 0x00, 0x66, 0x12, 0x3a, 0x9a, 0x03,
+ 0xc4, 0x49, 0xa4, 0xf0, 0xc1, 0x90, 0xf9, 0x38,
+ 0xb2, 0x5c, 0xa5, 0x0d, 0x1b, 0x60, 0x94, 0xf6,
+ 0x31, 0x4a, 0x72, 0xdb, 0xfc, 0xe1, 0x3c, 0xd6,
+ 0x9d, 0x03, 0x07, 0x45, 0xdb, 0xad, 0xdb, 0xb3,
+ 0x86, 0xfa, 0xce, 0x2c, 0xeb, 0xa2, 0xac, 0x05,
+ 0xd9, 0x52, 0xb8, 0xae, 0xa9, 0x91, 0x86, 0x4b,
+ 0xbb, 0xf8, 0x03, 0xb0, 0x6c, 0x40, 0xcc, 0xbf,
+ 0xa3, 0x76, 0x60, 0xf7, 0x29, 0x03, 0xe6, 0x44,
+ 0xcc, 0x2a, 0xe7, 0x74, 0x8e, 0x62, 0xfe, 0x99,
+ 0x6a, 0x6d, 0x04, 0x1b, 0xe7, 0xf7, 0x9f, 0x13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 0xc8, 0xcd, 0x2b,
+ 0x3e, 0xe8, 0x1b, 0x60, 0xe8, 0xea, 0xaf, 0x09,
+ 0xbb, 0xee, 0xce, 0xbc, 0xa0, 0x9b, 0x17, 0x90,
+ 0x42, 0x40, 0x18, 0x35, 0x2e, 0x17, 0xa0, 0x6e,
+ 0x43, 0xe7, 0xac, 0x89, 0x96, 0x3c, 0x16, 0xe0,
+ 0xdb, 0x09, 0x51, 0x4a, 0x45, 0x33, 0x63, 0xe9,
+ 0x4e, 0x3f, 0x32, 0x34, 0x36, 0x43, 0xd5, 0x0c,
+ 0x5a, 0x2e, 0x0e, 0x8b, 0x80, 0xb7, 0xf4, 0xe4,
+ 0x99, 0x9b, 0x05, 0xf5, 0xb2, 0xe4, 0x03, 0xe4,
+};
+
+const struct testvec aes_cbc_192_1_vectors[] = {
+ {
+ .blkno = 0,
+ .ptxt = aes_cbc_ptxt,
+ .ctxt = aes_cbc_192_encblkno1_vec0_ctxt,
+ },
+ {
+ .blkno = 1,
+ .ptxt = aes_cbc_ptxt,
+ .ctxt = aes_cbc_192_encblkno1_vec1_ctxt,
+ },
+ {
+ .blkno = 2,
+ .ptxt = aes_cbc_ptxt,
+ .ctxt = aes_cbc_192_encblkno1_vec2_ctxt,
+ },
+ {
+ .blkno = 3,
+ .ptxt = aes_cbc_ptxt,
+ .ctxt = aes_cbc_192_encblkno1_vec3_ctxt,
+ },
+};
+
+/*
+ * IV method encblkno8, blkno 0.
+ */
+static const uint8_t aes_cbc_192_encblkno8_vec0_ctxt[SECSIZE] = {
+ 0x87, 0x9c, 0x05, 0xd6, 0x25, 0xb9, 0xe0, 0xbe,
+ 0x78, 0x21, 0x85, 0x81, 0x8e, 0x2f, 0x13, 0x5e,
+ 0xf2, 0x73, 0x11, 0xfa, 0x73, 0x77, 0x93, 0x5e,
+ 0x71, 0x16, 0x98, 0x68, 0x6f, 0xe8, 0x22, 0x34,
+ 0xf5, 0x11, 0xfa, 0x61, 0xe6, 0x1a, 0xfb, 0x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, 0xd5,
+ 0x22, 0x5f, 0xce, 0x92, 0xeb, 0x82, 0x8e, 0x3e,
+ 0x4e, 0x99, 0x44, 0xa2, 0x9e, 0x78, 0x53, 0x89,
+ 0x4e, 0x45, 0x51, 0x41, 0x28, 0x91, 0xdb, 0x7e,
+ 0x8f, 0xac, 0xc2, 0xee, 0x09, 0xcb, 0xed, 0x04,
+ 0x7b, 0x37, 0xa1, 0x1d, 0x9c, 0x90, 0x19, 0xb1,
+ 0xdd, 0xc3, 0x22, 0xc8, 0x70, 0x07, 0x26, 0xce,
+ 0x4a, 0xc4, 0xde, 0xee, 0x87, 0xf3, 0x62, 0x69,
+ 0xed, 0xb2, 0x2d, 0x10, 0xc4, 0xfa, 0x86, 0x2e,
+ 0xd1, 0xb8, 0x58, 0xa3, 0xa4, 0x0b, 0x30, 0x87,
+ 0x23, 0x62, 0xed, 0xf3, 0x7b, 0x80, 0x7e, 0x4f,
+ 0xc2, 0xb3, 0xe8, 0xba, 0x25, 0x3e, 0xd3, 0x12,
+ 0x7e, 0x27, 0xd5, 0x72, 0x3b, 0x02, 0xf4, 0xfd,
+ 0x2f, 0x8b, 0xc2, 0x5f, 0x44, 0x40, 0x31, 0x88,
+ 0x73, 0x81, 0xa3, 0xcc, 0xc4, 0x78, 0x2b, 0xfc,
+ 0x41, 0x2e, 0xb2, 0xd0, 0xb4, 0x00, 0x29, 0xc1,
+ 0x46, 0xdf, 0xc1, 0xbd, 0x15, 0x59, 0xa3, 0x6a,
+ 0xc8, 0x2f, 0x29, 0x28, 0x12, 0x9b, 0x1e, 0xea,
+ 0x4e, 0xa9, 0x80, 0xa1, 0xb8, 0x89, 0x21, 0x3b,
+};
+
+const struct testvec aes_cbc_192_8_vectors[] = {
+ {
+ .blkno = 0,
+ .ptxt = aes_cbc_ptxt,
+ .ctxt = aes_cbc_192_encblkno8_vec0_ctxt,
+ },
+ {
+ .blkno = 1,
+ .ptxt = aes_cbc_ptxt,
+ .ctxt = aes_cbc_192_encblkno8_vec1_ctxt,
+ },
+ {
+ .blkno = 2,
+ .ptxt = aes_cbc_ptxt,
+ .ctxt = aes_cbc_192_encblkno8_vec2_ctxt,
+ },
+ {
+ .blkno = 3,
+ .ptxt = aes_cbc_ptxt,
+ .ctxt = aes_cbc_192_encblkno8_vec3_ctxt,
+ },
+};
+
+/*
+ * IV method encblkno1, blkno 0.
+ */
+static const uint8_t aes_cbc_256_encblkno1_vec0_ctxt[SECSIZE] = {
+ 0x1a, 0xa4, 0xe3, 0x09, 0x23, 0x2e, 0x91, 0x1b,
+ 0xa8, 0x3e, 0xda, 0x92, 0xb3, 0x22, 0xd2, 0xe8,
+ 0x8b, 0xed, 0x6c, 0xa7, 0x78, 0xe6, 0x32, 0x25,
+ 0xc4, 0x88, 0xd5, 0xb7, 0x6e, 0xef, 0xbf, 0x37,
+ 0x00, 0xd9, 0xb2, 0x55, 0x10, 0x4f, 0x7d, 0x84,
+ 0x3a, 0xae, 0xd2, 0xc6, 0x48, 0xdd, 0x3c, 0xd5,
+ 0x9b, 0xa7, 0xf8, 0xc2, 0xda, 0x6d, 0x14, 0xa2,
+ 0xdc, 0x54, 0x12, 0x8f, 0x1c, 0x22, 0x98, 0x6a,
+ 0xc0, 0x5f, 0x47, 0xa7, 0x78, 0xec, 0x79, 0x5d,
+ 0x04, 0xed, 0x5e, 0x20, 0x33, 0x53, 0x66, 0x40,
+ 0x83, 0x94, 0x5b, 0x34, 0x05, 0x25, 0x2e, 0x17,
+ 0xba, 0x23, 0x60, 0xb1, 0xd0, 0x27, 0xf0, 0x24,
+ 0xd2, 0x0b, 0xd3, 0xea, 0xa7, 0x13, 0x1e, 0xf9,
+ 0x56, 0xe1, 0xd4, 0xa2, 0x89, 0x5a, 0xaa, 0x42,
+ 0xa9, 0xd7, 0x85, 0x64, 0x9e, 0x44, 0x71, 0xa2,
+ 0xf9, 0xc3, 0xf4, 0x81, 0xbd, 0xa0, 0x40, 0xed,
+ 0x33, 0xeb, 0x09, 0x0f, 0x7f, 0x78, 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b2, 0xa0, 0x42, 0x73, 0xfb,
+ 0xc4, 0x24, 0xa7, 0x17, 0x8a, 0xc9, 0x6d, 0x34,
+ 0xe8, 0x7b, 0x51, 0x37, 0x32, 0x3f, 0xf8, 0x7e,
+ 0x92, 0xe4, 0x87, 0xd2, 0x89, 0x66, 0xb0, 0xf6,
+ 0xc2, 0xba, 0x2f, 0x42, 0x8f, 0x1d, 0x5d, 0x81,
+ 0xad, 0xfd, 0x00, 0xbc, 0xa9, 0x11, 0x96, 0xae,
+ 0x80, 0xf1, 0x27, 0xe0, 0xeb, 0x5b, 0x60, 0x39,
+};
+
+const struct testvec aes_cbc_256_1_vectors[] = {
+ {
+ .blkno = 0,
+ .ptxt = aes_cbc_ptxt,
+ .ctxt = aes_cbc_256_encblkno1_vec0_ctxt,
+ },
+ {
+ .blkno = 1,
+ .ptxt = aes_cbc_ptxt,
+ .ctxt = aes_cbc_256_encblkno1_vec1_ctxt,
+ },
+ {
+ .blkno = 2,
+ .ptxt = aes_cbc_ptxt,
+ .ctxt = aes_cbc_256_encblkno1_vec2_ctxt,
+ },
+ {
+ .blkno = 3,
+ .ptxt = aes_cbc_ptxt,
+ .ctxt = aes_cbc_256_encblkno1_vec3_ctxt,
+ },
+};
+
+/*
+ * IV method encblkno8, blkno 0.
+ */
+static const uint8_t aes_cbc_256_encblkno8_vec0_ctxt[SECSIZE] = {
+ 0xe5, 0x55, 0xd9, 0xae, 0xc0, 0x66, 0x2d, 0x2f,
+ 0x11, 0xb1, 0x27, 0xd2, 0xb2, 0x73, 0xe4, 0x0a,
+ 0x85, 0xb5, 0x3c, 0x79, 0x78, 0xd6, 0x35, 0x3d,
+ 0x46, 0xac, 0xa3, 0x81, 0x55, 0x76, 0x86, 0xfc,
+ 0x37, 0xa0, 0x95, 0xc2, 0x30, 0xc9, 0x19, 0xc2,
+ 0x5f, 0xb0, 0x13, 0xa2, 0xa8, 0xe1, 0xc7, 0xb7,
+ 0x61, 0x54, 0xd8, 0xe6, 0xca, 0x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 0x4a,
+ 0x4b, 0x0b, 0xdb, 0x57, 0x9b, 0xa9, 0x3e, 0xa8,
+ 0x99, 0x59, 0xa0, 0x12, 0xf3, 0xa5, 0xe4, 0x91,
+ 0xbb, 0xb9, 0x05, 0x8d, 0xcf, 0xb9, 0xcb, 0x36,
+ 0x97, 0xb2, 0x6a, 0x31, 0x8f, 0xcb, 0xf8, 0x5a,
+ 0x2f, 0x9e, 0xa1, 0xf9, 0x7a, 0xf4, 0x10, 0x0e,
+ 0xe7, 0x7f, 0x4c, 0xcb, 0xe3, 0x83, 0x17, 0x39,
+ 0x34, 0xef, 0x49, 0x35, 0x68, 0x50, 0x80, 0xf9,
+ 0xcd, 0x3a, 0x10, 0xf6, 0x71, 0x1a, 0x94, 0xc3,
+ 0xec, 0xb9, 0x36, 0x84, 0x36, 0xe7, 0x3f, 0x6f,
+ 0x9b, 0xa9, 0x2b, 0x5c, 0x96, 0x49, 0x26, 0xda,
+ 0xb3, 0x08, 0x3d, 0x5e, 0x9e, 0x59, 0xdf, 0x0f,
+ 0xfc, 0xbe, 0xa8, 0x0b, 0xbc, 0xaa, 0x32, 0xf0,
+ 0xa5, 0x21, 0x50, 0x15, 0x7e, 0x46, 0xb9, 0x76,
+ 0x09, 0x4e, 0x4b, 0x6f, 0x9f, 0xc7, 0x8c, 0x6d,
+ 0x80, 0x37, 0xf9, 0xaa, 0xd1, 0x5f, 0x12, 0xb9,
+ 0xb3, 0x15, 0xe4, 0x96, 0xa1, 0x01, 0xd5, 0xa0,
+};
+
+const struct testvec aes_cbc_256_8_vectors[] = {
+ {
+ .blkno = 0,
+ .ptxt = aes_cbc_ptxt,
+ .ctxt = aes_cbc_256_encblkno8_vec0_ctxt,
+ },
+ {
+ .blkno = 1,
+ .ptxt = aes_cbc_ptxt,
+ .ctxt = aes_cbc_256_encblkno8_vec1_ctxt,
+ },
+ {
+ .blkno = 2,
+ .ptxt = aes_cbc_ptxt,
+ .ctxt = aes_cbc_256_encblkno8_vec2_ctxt,
+ },
+ {
+ .blkno = 3,
+ .ptxt = aes_cbc_ptxt,
+ .ctxt = aes_cbc_256_encblkno8_vec3_ctxt,
+ },
+};
+
+/*
+ * 256 bits key from IEEE 1619/D16, NUL terminated.
+ */
+static const char aes_xts_256_key[33] = {
+ 0x27, 0x18, 0x28, 0x18, 0x28, 0x45, 0x90, 0x45,
+ 0x23, 0x53, 0x60, 0x28, 0x74, 0x71, 0x35, 0x26,
+ 0x31, 0x41, 0x59, 0x26, 0x53, 0x58, 0x97, 0x93,
+ 0x23, 0x84, 0x62, 0x64, 0x33, 0x83, 0x27, 0x95,
+ 0
+};
+
+/*
+ * 512 bits key from IEEE 1619/D16, NUL terminated.
+ */
+static const char aes_xts_512_key[65] = {
+ 0x27, 0x18, 0x28, 0x18, 0x28, 0x45, 0x90, 0x45,
+ 0x23, 0x53, 0x60, 0x28, 0x74, 0x71, 0x35, 0x26,
+ 0x62, 0x49, 0x77, 0x57, 0x24, 0x70, 0x93, 0x69,
+ 0x99, 0x59, 0x57, 0x49, 0x66, 0x96, 0x76, 0x27,
+ 0x31, 0x41, 0x59, 0x26, 0x53, 0x58, 0x97, 0x93,
+ 0x23, 0x84, 0x62, 0x64, 0x33, 0x83, 0x27, 0x95,
+ 0x02, 0x88, 0x41, 0x97, 0x16, 0x93, 0x99, 0x37,
+ 0x51, 0x05, 0x82, 0x09, 0x74, 0x94, 0x45, 0x92,
+ 0
+};
+
+/*
+ * Vector 4 from IEEE 1619/D16, blkno 0.
+ */
+static const uint8_t aes_xts_256_vec4_ptxt[SECSIZE] = {
+ 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, 0x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
+ {
+ .blkno = 0,
+ .ptxt = aes_xts_256_vec4_ptxt,
+ .ctxt = aes_xts_256_vec4_ctxt,
+ },
+ {
+ .blkno = 1,
+ .ptxt = aes_xts_256_vec5_ptxt,
+ .ctxt = aes_xts_256_vec5_ctxt,
+ },
+ {
+ .blkno = 2,
+ .ptxt = aes_xts_256_vec6_ptxt,
+ .ctxt = aes_xts_256_vec6_ctxt,
+ },
+ {
+ .blkno = 0xfd,
+ .ptxt = aes_xts_256_vec7_ptxt,
+ .ctxt = aes_xts_256_vec7_ctxt,
+ },
+ {
+ .blkno = 0xfe,
+ .ptxt = aes_xts_256_vec8_ptxt,
+ .ctxt = aes_xts_256_vec8_ctxt,
+ },
+ {
+ .blkno = 0xff,
+ .ptxt = aes_xts_256_vec9_ptxt,
+ .ctxt = aes_xts_256_vec9_ctxt,
+ },
+};
+
+/*
+ * Vector 10 from IEEE 1619/D16, blkno 0xff.
+ */
+static const uint8_t aes_xts_512_vec10_ptxt[SECSIZE] = {
+ 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, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
+ 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
+ 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
+ 0x58, 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29, 0xea, 0xed, 0xb4, 0xed,
+ 0x53, 0x76, 0x44, 0x1a, 0x77, 0xed, 0x43, 0x85,
+ 0x1a, 0xd7, 0x7f, 0x16, 0xf5, 0x41, 0xdf, 0xd2,
+ 0x69, 0xd5, 0x0d, 0x6a, 0x5f, 0x14, 0xfb, 0x0a,
+ 0xab, 0x1c, 0xbb, 0x4c, 0x15, 0x50, 0xbe, 0x97,
+ 0xf7, 0xab, 0x40, 0x66, 0x19, 0x3c, 0x4c, 0xaa,
+ 0x77, 0x3d, 0xad, 0x38, 0x01, 0x4b, 0xd2, 0x09,
+ 0x2f, 0xa7, 0x55, 0xc8, 0x24, 0xbb, 0x5e, 0x54,
+ 0xc4, 0xf3, 0x6f, 0xfd, 0xa9, 0xfc, 0xea, 0x70,
+ 0xb9, 0xc6, 0xe6, 0x93, 0xe1, 0x48, 0xc1, 0x51,
+};
+
+/*
+ * Vector 11 from IEEE 1619/D16, blkno 0xffff.
+ */
+static const uint8_t aes_xts_512_vec11_ptxt[SECSIZE] = {
+ 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, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
+ 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
+ 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0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4a, 0x27, 0x15,
+ 0x05, 0x52, 0x49, 0xcf, 0x3b, 0x47, 0x8d, 0xdd,
+ 0x47, 0x40, 0xde, 0x65, 0x4f, 0x75, 0xca, 0x68,
+ 0x6e, 0x0d, 0x73, 0x45, 0xc6, 0x9e, 0xd5, 0x0c,
+ 0xdc, 0x2a, 0x8b, 0x33, 0x2b, 0x1f, 0x88, 0x24,
+ 0x10, 0x8a, 0xc9, 0x37, 0xeb, 0x05, 0x05, 0x85,
+ 0x60, 0x8e, 0xe7, 0x34, 0x09, 0x7f, 0xc0, 0x90,
+ 0x54, 0xfb, 0xff, 0x89, 0xee, 0xae, 0xea, 0x79,
+ 0x1f, 0x4a, 0x7a, 0xb1, 0xf9, 0x86, 0x82, 0x94,
+ 0xa4, 0xf9, 0xe2, 0x7b, 0x42, 0xaf, 0x81, 0x00,
+ 0xcb, 0x9d, 0x59, 0xce, 0xf9, 0x64, 0x58, 0x03,
+};
+
+const struct testvec aes_xts_512_vectors[] = {
+ {
+ .blkno = 0xff,
+ .ptxt = aes_xts_512_vec10_ptxt,
+ .ctxt = aes_xts_512_vec10_ctxt,
+ },
+ {
+ .blkno = 0xffff,
+ .ptxt = aes_xts_512_vec11_ptxt,
+ .ctxt = aes_xts_512_vec11_ctxt,
+ },
+};
+
+static int
+open_disk(const char *devpath, const char *imgpath, size_t size)
+{
+ int fd;
+
+ fd = open(imgpath, O_CREAT | O_RDWR | O_TRUNC, 0600);
+ if (fd < 0)
+ return -1;
+
+ if (ftruncate(fd, size) < 0)
+ goto fail;
+
+ if (rump_pub_etfs_register_withsize(devpath,
+ imgpath, RUMP_ETFS_BLK, 0, size) < 0) {
+ goto fail;
+ }
+
+ unlink(imgpath);
+ return fd;
+fail:
+ close(fd);
+ unlink(imgpath);
+ return -1;
+}
+
+static int
+open_cgd(int devno)
+{
+ char devpath[32];
+
+ sprintf(devpath, "/dev/rcgd%d%c", devno, getrawpartition() + 'a');
+
+ return rump_sys_open(devpath, O_RDWR, 0);
+}
+
+static int
+configure_cgd(int fd, const char *dkpath, const char *alg,
+ const char *ivmethod, const char *key, size_t keylen)
+{
+ struct cgd_ioctl ci;
+
+ memset(&ci, 0, sizeof(ci));
+ ci.ci_disk = dkpath;
+ ci.ci_alg = alg;
+ ci.ci_ivmethod = ivmethod;
+ ci.ci_keylen = 8 * keylen - 8; /* Exclude the NUL terminator. */
+ ci.ci_key = key;
+ ci.ci_blocksize = 128;
+
+ return rump_sys_ioctl(fd, CGDIOCSET, &ci);
+}
+
+static int
+unconfigure_cgd(int fd)
+{
+ struct cgd_ioctl ci;
+
+ return rump_sys_ioctl(fd, CGDIOCCLR, &ci);
+}
+
+static int
+write_testvec(int cgdfd, const struct testvec *tv)
+{
+ ssize_t written;
+
+ if (rump_sys_lseek(cgdfd, tv->blkno * SECSIZE, SEEK_SET) < 0)
+ return -1;
+
+ written = rump_sys_write(cgdfd, tv->ptxt, SECSIZE);
+ if (written < 0)
+ return -1;
+ if (written != SECSIZE) {
+ errno = EDOM; /* Something distinct. */
+ return -1;
+ }
+
+ return 0;
+}
+
+static int
+read_testvec(int cgdfd, const struct testvec *tv)
+{
+ char *buf;
+ int res = -1;
+
+ buf = malloc(SECSIZE);
+ if (buf == NULL)
+ return -1;
+
+ if (rump_sys_lseek(cgdfd, tv->blkno * SECSIZE, SEEK_SET) < 0)
+ goto fail;
+
+ if (rump_sys_read(cgdfd, buf, SECSIZE) != SECSIZE)
+ goto fail;
+
+ res = memcmp(buf, tv->ptxt, SECSIZE);
+fail:
+ free(buf);
+ return res;
+}
+
+static int
+check_testvec(int dkfd, const struct testvec *tv)
+{
+ char *buf;
+ int res = -1;
+
+ buf = malloc(SECSIZE);
+ if (buf == NULL)
+ return -1;
+
+ if (lseek(dkfd, tv->blkno * SECSIZE, SEEK_SET) < 0)
+ goto fail;
+
+ if (read(dkfd, buf, SECSIZE) != SECSIZE)
+ goto fail;
+
+ res = memcmp(buf, tv->ctxt, SECSIZE);
+fail:
+ free(buf);
+ return res;
+}
+
+ATF_TC(cgd_aes_cbc_128_encblkno1);
+ATF_TC_HEAD(cgd_aes_cbc_128_encblkno1, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Test aes-cbc with 128 bits key, ivmethod encblkno1");
+}
+
+ATF_TC_BODY(cgd_aes_cbc_128_encblkno1, tc)
+{
+ const char imgpath[] = "aes-cbc-128-encblkno1.img";
+ const char *dkpath = "/dev/dk";
+ const size_t dksize = 4 * SECSIZE; /* Last blkno is 3. */
+ int dkfd, cgdfd;
+
+ rump_init();
+
+ RL(dkfd = open_disk(dkpath, imgpath, dksize));
+
+ RL(cgdfd = open_cgd(0));
+ RL(configure_cgd(cgdfd, dkpath, "aes-cbc", "encblkno1",
+ aes_cbc_128_key, sizeof(aes_cbc_128_key)));
+
+ CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_128_1_vectors[0]), -1);
+ CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_128_1_vectors[1]), -1);
+ CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_128_1_vectors[2]), -1);
+ CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_128_1_vectors[3]), -1);
+
+ RL(unconfigure_cgd(cgdfd));
+ RL(configure_cgd(cgdfd, dkpath, "aes-cbc", "encblkno1",
+ aes_cbc_128_key, sizeof(aes_cbc_128_key)));
+
+ ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_128_1_vectors[0]), 0);
+ ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_128_1_vectors[1]), 0);
+ ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_128_1_vectors[2]), 0);
+ ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_128_1_vectors[3]), 0);
+
+ RL(unconfigure_cgd(cgdfd));
+ RL(rump_sys_close(cgdfd));
+
+ ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_128_1_vectors[0]), 0);
+ ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_128_1_vectors[1]), 0);
+ ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_128_1_vectors[2]), 0);
+ ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_128_1_vectors[3]), 0);
+
+ RL(close(dkfd));
+}
+
+ATF_TC(cgd_aes_cbc_128_encblkno8);
+ATF_TC_HEAD(cgd_aes_cbc_128_encblkno8, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Test aes-cbc with 128 bits key, ivmethod encblkno8");
+}
+
+ATF_TC_BODY(cgd_aes_cbc_128_encblkno8, tc)
+{
+ const char imgpath[] = "aes-cbc-128-encblkno8.img";
+ const char *dkpath = "/dev/dk";
+ const size_t dksize = 4 * SECSIZE; /* Last blkno is 3. */
+ int dkfd, cgdfd;
+
+ rump_init();
+
+ RL(dkfd = open_disk(dkpath, imgpath, dksize));
+
+ RL(cgdfd = open_cgd(0));
+ RL(configure_cgd(cgdfd, dkpath, "aes-cbc", "encblkno8",
+ aes_cbc_128_key, sizeof(aes_cbc_128_key)));
+
+ CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_128_8_vectors[0]), -1);
+ CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_128_8_vectors[1]), -1);
+ CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_128_8_vectors[2]), -1);
+ CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_128_8_vectors[3]), -1);
+
+ RL(unconfigure_cgd(cgdfd));
+ RL(configure_cgd(cgdfd, dkpath, "aes-cbc", "encblkno8",
+ aes_cbc_128_key, sizeof(aes_cbc_128_key)));
+
+ ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_128_8_vectors[0]), 0);
+ ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_128_8_vectors[1]), 0);
+ ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_128_8_vectors[2]), 0);
+ ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_128_8_vectors[3]), 0);
+
+ RL(unconfigure_cgd(cgdfd));
+ RL(rump_sys_close(cgdfd));
+
+ ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_128_8_vectors[0]), 0);
+ ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_128_8_vectors[1]), 0);
+ ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_128_8_vectors[2]), 0);
+ ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_128_8_vectors[3]), 0);
+
+ RL(close(dkfd));
+}
+
+ATF_TC(cgd_aes_cbc_192_encblkno1);
+ATF_TC_HEAD(cgd_aes_cbc_192_encblkno1, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Test aes-cbc with 192 bits key, ivmethod encblkno1");
+}
+
+ATF_TC_BODY(cgd_aes_cbc_192_encblkno1, tc)
+{
+ const char imgpath[] = "aes-cbc-192-encblkno1.img";
+ const char *dkpath = "/dev/dk";
+ const size_t dksize = 4 * SECSIZE; /* Last blkno is 3. */
+ int dkfd, cgdfd;
+
+ rump_init();
+
+ RL(dkfd = open_disk(dkpath, imgpath, dksize));
+
+ RL(cgdfd = open_cgd(0));
+ RL(configure_cgd(cgdfd, dkpath, "aes-cbc", "encblkno1",
+ aes_cbc_192_key, sizeof(aes_cbc_192_key)));
+
+ CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_192_1_vectors[0]), -1);
+ CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_192_1_vectors[1]), -1);
+ CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_192_1_vectors[2]), -1);
+ CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_192_1_vectors[3]), -1);
+
+ RL(unconfigure_cgd(cgdfd));
+ RL(configure_cgd(cgdfd, dkpath, "aes-cbc", "encblkno1",
+ aes_cbc_192_key, sizeof(aes_cbc_192_key)));
+
+ ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_192_1_vectors[0]), 0);
+ ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_192_1_vectors[1]), 0);
+ ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_192_1_vectors[2]), 0);
+ ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_192_1_vectors[3]), 0);
+
+ RL(unconfigure_cgd(cgdfd));
+ RL(rump_sys_close(cgdfd));
+
+ ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_192_1_vectors[0]), 0);
+ ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_192_1_vectors[1]), 0);
+ ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_192_1_vectors[2]), 0);
+ ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_192_1_vectors[3]), 0);
+
+ RL(close(dkfd));
+}
+
+ATF_TC(cgd_aes_cbc_192_encblkno8);
+ATF_TC_HEAD(cgd_aes_cbc_192_encblkno8, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Test aes-cbc with 192 bits key, ivmethod encblkno8");
+}
+
+ATF_TC_BODY(cgd_aes_cbc_192_encblkno8, tc)
+{
+ const char imgpath[] = "aes-cbc-192-encblkno8.img";
+ const char *dkpath = "/dev/dk";
+ const size_t dksize = 4 * SECSIZE; /* Last blkno is 3. */
+ int dkfd, cgdfd;
+
+ rump_init();
+
+ RL(dkfd = open_disk(dkpath, imgpath, dksize));
+
+ RL(cgdfd = open_cgd(0));
+ RL(configure_cgd(cgdfd, dkpath, "aes-cbc", "encblkno8",
+ aes_cbc_192_key, sizeof(aes_cbc_192_key)));
+
+ CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_192_8_vectors[0]), -1);
+ CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_192_8_vectors[1]), -1);
+ CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_192_8_vectors[2]), -1);
+ CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_192_8_vectors[3]), -1);
+
+ RL(unconfigure_cgd(cgdfd));
+ RL(configure_cgd(cgdfd, dkpath, "aes-cbc", "encblkno8",
+ aes_cbc_192_key, sizeof(aes_cbc_192_key)));
+
+ ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_192_8_vectors[0]), 0);
+ ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_192_8_vectors[1]), 0);
+ ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_192_8_vectors[2]), 0);
+ ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_192_8_vectors[3]), 0);
+
+ RL(unconfigure_cgd(cgdfd));
+ RL(rump_sys_close(cgdfd));
+
+ ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_192_8_vectors[0]), 0);
+ ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_192_8_vectors[1]), 0);
+ ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_192_8_vectors[2]), 0);
+ ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_192_8_vectors[3]), 0);
+
+ RL(close(dkfd));
+}
+
+ATF_TC(cgd_aes_cbc_256_encblkno1);
+ATF_TC_HEAD(cgd_aes_cbc_256_encblkno1, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Test aes-cbc with 256 bits key, ivmethod encblkno1");
+}
+
+ATF_TC_BODY(cgd_aes_cbc_256_encblkno1, tc)
+{
+ const char imgpath[] = "aes-cbc-256-encblkno1.img";
+ const char *dkpath = "/dev/dk";
+ const size_t dksize = 4 * SECSIZE; /* Last blkno is 3. */
+ int dkfd, cgdfd;
+
+ rump_init();
+
+ RL(dkfd = open_disk(dkpath, imgpath, dksize));
+
+ RL(cgdfd = open_cgd(0));
+ RL(configure_cgd(cgdfd, dkpath, "aes-cbc", "encblkno1",
+ aes_cbc_256_key, sizeof(aes_cbc_256_key)));
+
+ CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_256_1_vectors[0]), -1);
+ CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_256_1_vectors[1]), -1);
+ CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_256_1_vectors[2]), -1);
+ CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_256_1_vectors[3]), -1);
+
+ RL(unconfigure_cgd(cgdfd));
+ RL(configure_cgd(cgdfd, dkpath, "aes-cbc", "encblkno1",
+ aes_cbc_256_key, sizeof(aes_cbc_256_key)));
+
+ ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_256_1_vectors[0]), 0);
+ ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_256_1_vectors[1]), 0);
+ ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_256_1_vectors[2]), 0);
+ ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_256_1_vectors[3]), 0);
+
+ RL(unconfigure_cgd(cgdfd));
+ RL(rump_sys_close(cgdfd));
+
+ ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_256_1_vectors[0]), 0);
+ ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_256_1_vectors[1]), 0);
+ ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_256_1_vectors[2]), 0);
+ ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_256_1_vectors[3]), 0);
+
+ RL(close(dkfd));
+}
+
+ATF_TC(cgd_aes_cbc_256_encblkno8);
+ATF_TC_HEAD(cgd_aes_cbc_256_encblkno8, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Test aes-cbc with 256 bits key, ivmethod encblkno8");
+}
+
+ATF_TC_BODY(cgd_aes_cbc_256_encblkno8, tc)
+{
+ const char imgpath[] = "aes-cbc-256-encblkno8.img";
+ const char *dkpath = "/dev/dk";
+ const size_t dksize = 4 * SECSIZE; /* Last blkno is 3. */
+ int dkfd, cgdfd;
+
+ rump_init();
+
+ RL(dkfd = open_disk(dkpath, imgpath, dksize));
+
+ RL(cgdfd = open_cgd(0));
+ RL(configure_cgd(cgdfd, dkpath, "aes-cbc", "encblkno8",
+ aes_cbc_256_key, sizeof(aes_cbc_256_key)));
+
+ CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_256_8_vectors[0]), -1);
+ CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_256_8_vectors[1]), -1);
+ CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_256_8_vectors[2]), -1);
+ CHECK_LIBC(write_testvec(cgdfd, &aes_cbc_256_8_vectors[3]), -1);
+
+ RL(unconfigure_cgd(cgdfd));
+ RL(configure_cgd(cgdfd, dkpath, "aes-cbc", "encblkno8",
+ aes_cbc_256_key, sizeof(aes_cbc_256_key)));
+
+ ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_256_8_vectors[0]), 0);
+ ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_256_8_vectors[1]), 0);
+ ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_256_8_vectors[2]), 0);
+ ATF_CHECK_EQ(read_testvec(cgdfd, &aes_cbc_256_8_vectors[3]), 0);
+
+ RL(unconfigure_cgd(cgdfd));
+ RL(rump_sys_close(cgdfd));
+
+ ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_256_8_vectors[0]), 0);
+ ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_256_8_vectors[1]), 0);
+ ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_256_8_vectors[2]), 0);
+ ATF_CHECK_EQ(check_testvec(dkfd, &aes_cbc_256_8_vectors[3]), 0);
+
+ RL(close(dkfd));
+}
+
+ATF_TC(cgd_aes_xts_256);
+ATF_TC_HEAD(cgd_aes_xts_256, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Test aes-xts with 256 bits key");
+}
+
+ATF_TC_BODY(cgd_aes_xts_256, tc)
+{
+ const char imgpath[] = "aes-xts-256.img";
+ const char *dkpath = "/dev/dk";
+ const size_t dksize = 256 * SECSIZE; /* Last blkno is 0xff. */
+ int dkfd, cgdfd;
+
+ rump_init();
+
+ RL(dkfd = open_disk(dkpath, imgpath, dksize));
+
+ RL(cgdfd = open_cgd(0));
+ RL(configure_cgd(cgdfd, dkpath, "aes-xts", "encblkno1",
+ aes_xts_256_key, sizeof(aes_xts_256_key)));
+
+ CHECK_LIBC(write_testvec(cgdfd, &aes_xts_256_vectors[0]), -1);
+ CHECK_LIBC(write_testvec(cgdfd, &aes_xts_256_vectors[1]), -1);
+ CHECK_LIBC(write_testvec(cgdfd, &aes_xts_256_vectors[2]), -1);
+ CHECK_LIBC(write_testvec(cgdfd, &aes_xts_256_vectors[3]), -1);
+ CHECK_LIBC(write_testvec(cgdfd, &aes_xts_256_vectors[4]), -1);
+ CHECK_LIBC(write_testvec(cgdfd, &aes_xts_256_vectors[5]), -1);
+
+ RL(unconfigure_cgd(cgdfd));
+ RL(configure_cgd(cgdfd, dkpath, "aes-xts", "encblkno1",
+ aes_xts_256_key, sizeof(aes_xts_256_key)));
+
+ ATF_CHECK_EQ(read_testvec(cgdfd, &aes_xts_256_vectors[0]), 0);
+ ATF_CHECK_EQ(read_testvec(cgdfd, &aes_xts_256_vectors[1]), 0);
+ ATF_CHECK_EQ(read_testvec(cgdfd, &aes_xts_256_vectors[2]), 0);
+ ATF_CHECK_EQ(read_testvec(cgdfd, &aes_xts_256_vectors[3]), 0);
+ ATF_CHECK_EQ(read_testvec(cgdfd, &aes_xts_256_vectors[4]), 0);
+ ATF_CHECK_EQ(read_testvec(cgdfd, &aes_xts_256_vectors[5]), 0);
+
+ RL(unconfigure_cgd(cgdfd));
+ RL(rump_sys_close(cgdfd));
+
+ ATF_CHECK_EQ(check_testvec(dkfd, &aes_xts_256_vectors[0]), 0);
+ ATF_CHECK_EQ(check_testvec(dkfd, &aes_xts_256_vectors[1]), 0);
+ ATF_CHECK_EQ(check_testvec(dkfd, &aes_xts_256_vectors[2]), 0);
+ ATF_CHECK_EQ(check_testvec(dkfd, &aes_xts_256_vectors[3]), 0);
+ ATF_CHECK_EQ(check_testvec(dkfd, &aes_xts_256_vectors[4]), 0);
+ ATF_CHECK_EQ(check_testvec(dkfd, &aes_xts_256_vectors[5]), 0);
+
+ RL(close(dkfd));
+}
+
+ATF_TC(cgd_aes_xts_512);
+ATF_TC_HEAD(cgd_aes_xts_512, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Test aes-xts with 512 bits key");
+}
+
+ATF_TC_BODY(cgd_aes_xts_512, tc)
+{
+ const char imgpath[] = "aes-xts-512.img";
+ const char *dkpath = "/dev/dk";
+ const size_t dksize = 65536 * SECSIZE; /* Last blkno is 0xffff. */
+ int dkfd, cgdfd;
+
+ rump_init();
+
+ RL(dkfd = open_disk(dkpath, imgpath, dksize));
+
+ RL(cgdfd = open_cgd(0));
+ RL(configure_cgd(cgdfd, dkpath, "aes-xts", "encblkno1",
+ aes_xts_512_key, sizeof(aes_xts_512_key)));
+
+ CHECK_LIBC(write_testvec(cgdfd, &aes_xts_512_vectors[0]), -1);
+ CHECK_LIBC(write_testvec(cgdfd, &aes_xts_512_vectors[1]), -1);
+
+ RL(unconfigure_cgd(cgdfd));
+ RL(configure_cgd(cgdfd, dkpath, "aes-xts", "encblkno1",
+ aes_xts_512_key, sizeof(aes_xts_512_key)));
+
+ ATF_CHECK_EQ(read_testvec(cgdfd, &aes_xts_512_vectors[0]), 0);
+ ATF_CHECK_EQ(read_testvec(cgdfd, &aes_xts_512_vectors[1]), 0);
+
+ RL(unconfigure_cgd(cgdfd));
+ RL(rump_sys_close(cgdfd));
+
+ ATF_CHECK_EQ(check_testvec(dkfd, &aes_xts_512_vectors[0]), 0);
+ ATF_CHECK_EQ(check_testvec(dkfd, &aes_xts_512_vectors[1]), 0);
+
+ RL(close(dkfd));
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+
+ ATF_TP_ADD_TC(tp, cgd_aes_cbc_128_encblkno1);
+ ATF_TP_ADD_TC(tp, cgd_aes_cbc_128_encblkno8);
+ ATF_TP_ADD_TC(tp, cgd_aes_cbc_192_encblkno1);
+ ATF_TP_ADD_TC(tp, cgd_aes_cbc_192_encblkno8);
+ ATF_TP_ADD_TC(tp, cgd_aes_cbc_256_encblkno1);
+ ATF_TP_ADD_TC(tp, cgd_aes_cbc_256_encblkno8);
+ ATF_TP_ADD_TC(tp, cgd_aes_xts_256);
+ ATF_TP_ADD_TC(tp, cgd_aes_xts_512);
+
+ return atf_no_error();
+}
diff --git a/contrib/netbsd-tests/dev/cgd/t_cgd_blowfish.c b/contrib/netbsd-tests/dev/cgd/t_cgd_blowfish.c
new file mode 100644
index 0000000..958ebac
--- /dev/null
+++ b/contrib/netbsd-tests/dev/cgd/t_cgd_blowfish.c
@@ -0,0 +1,2341 @@
+/* $NetBSD: t_cgd_blowfish.c,v 1.1 2016/11/10 23:44:36 alnsn Exp $ */
+/*-
+ * Copyright (c) 2016 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Alexander Nasonov.
+ *
+ * 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 HOLDERS 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.
+ */
+
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <sys/sysctl.h>
+
+#include <atf-c.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <util.h>
+
+#include <dev/cgdvar.h>
+
+#include <rump/rump.h>
+#include <rump/rump_syscalls.h>
+
+#include "../../h_macros.h"
+
+#define SECSIZE 512
+
+struct testvec {
+ unsigned int blkno;
+ const uint8_t *ptxt; /* PlainText */
+ const uint8_t *ctxt; /* CipherText */
+};
+
+/*
+ * 128 bits Blowfish key, NUL terminated.
+ */
+static const char bf_cbc_128_key[17] = {
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* 01234567 */
+ 0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, /* 89ABCDEF */
+ 0
+};
+
+/*
+ * 256 bits Blowfish key, NUL terminated.
+ */
+static const char bf_cbc_256_key[33] = {
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* 01234567 */
+ 0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, /* 89ABCDEF */
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* 01234567 */
+ 0x38, 0x39, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, /* 89abcdef */
+ 0
+};
+
+/*
+ * 448 bits Blowfish key, NUL terminated.
+ */
+static const char bf_cbc_448_key[57] = {
+ 0x3a, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, /* :ABCDEFG */
+ 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, /* HIJKLMNO */
+ 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, /* PQRSTUVW */
+ 0x58, 0x59, 0x5a, 0x7e, 0x3a, 0x61, 0x62, 0x63, /* XYZ~:abc */
+ 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, /* defghijk */
+ 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, /* lmnopqrs */
+ 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x23, /* tuvwxyz# */
+ 0
+};
+
+static const uint8_t bf_cbc_ptxt[SECSIZE] =
+ " abcdefghijklmnop"
+ " abcdefghijklmnop"
+ " abcdefghijklmnop"
+ " abcdefghijklmnop"
+ " abcdefghijklmnop"
+ " abcdefghijklmnop"
+ " abcdefghijklmnop"
+ " abcdefghijklmnop"
+ " abcdefghijklmnop"
+ " abcdefghijklmnop"
+ " abcdefghijklmnop"
+ " abcdefghijklmnop"
+ " abcdefghijklmnop"
+ " abcdefghijklmnop"
+ " abcdefghijklmnop"
+ " abcdefghijklmnop";
+
+/*
+ * IV method encblkno1, blkno 0.
+ */
+static const uint8_t bf_cbc_128_encblkno1_vec0_ctxt[SECSIZE] = {
+ 0x78, 0x53, 0x43, 0x2a, 0x08, 0xe7, 0x84, 0x3f,
+ 0xb7, 0x61, 0x9c, 0x17, 0x81, 0xbe, 0x38, 0xb9,
+ 0x65, 0x51, 0x68, 0xa2, 0x29, 0xd7, 0x45, 0xc9,
+ 0xee, 0x0e, 0x9d, 0xe1, 0x69, 0xc6, 0x81, 0x81,
+ 0xf3, 0x93, 0xa6, 0x62, 0xc9, 0x05, 0x2c, 0x1b,
+ 0x0e, 0x05, 0xca, 0xbe, 0x12, 0x25, 0x37, 0xd8,
+ 0x98, 0x66, 0xa2, 0xd3, 0xd0, 0x8a, 0x89, 0x57,
+ 0x44, 0x91, 0x1e, 0xe9, 0x07, 0x03, 0x5c, 0xa6,
+ 0xb8, 0x30, 0xf1, 0xc7, 0x8c, 0x66, 0x05, 0xb0,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, 0xd3, 0xa0,
+ 0x32, 0x42, 0xac, 0xa6, 0x90, 0x0b, 0xc0, 0xe4,
+ 0x91, 0x45, 0x85, 0x27, 0xb9, 0x48, 0x2a, 0x88,
+ 0x0a, 0xbf, 0xf6, 0x2d, 0xef, 0x4d, 0x1b, 0x64,
+ 0x49, 0x23, 0x47, 0x30, 0x29, 0x25, 0xb2, 0xc9,
+ 0xaf, 0xcd, 0xae, 0x56, 0x43, 0x28, 0xcf, 0x81,
+ 0x95, 0xa7, 0x3e, 0x51, 0x5b, 0x3b, 0xf7, 0x87,
+ 0x13, 0xc6, 0xee, 0x50, 0x2f, 0x78, 0xdd, 0xcf,
+ 0x63, 0xef, 0x15, 0xb9, 0x4f, 0x21, 0x27, 0x5e,
+ 0x94, 0x78, 0xad, 0xcd, 0x9b, 0x3d, 0xf2, 0xdb,
+ 0xed, 0xf2, 0xa2, 0x39, 0xca, 0xa3, 0xa8, 0x2e,
+ 0x68, 0xd5, 0xc3, 0xcf, 0x71, 0xec, 0x92, 0xdc,
+ 0xce, 0xe7, 0x7d, 0x2b, 0xf7, 0xbc, 0xe9, 0x2b,
+ 0x2e, 0xae, 0xaf, 0x0b, 0x92, 0x72, 0xac, 0x6e,
+ 0x49, 0xe1, 0xb3, 0x1f, 0xe5, 0x43, 0x2f, 0xa7,
+};
+
+const struct testvec bf_cbc_128_1_vectors[] = {
+ {
+ .blkno = 0,
+ .ptxt = bf_cbc_ptxt,
+ .ctxt = bf_cbc_128_encblkno1_vec0_ctxt,
+ },
+ {
+ .blkno = 1,
+ .ptxt = bf_cbc_ptxt,
+ .ctxt = bf_cbc_128_encblkno1_vec1_ctxt,
+ },
+ {
+ .blkno = 2,
+ .ptxt = bf_cbc_ptxt,
+ .ctxt = bf_cbc_128_encblkno1_vec2_ctxt,
+ },
+ {
+ .blkno = 3,
+ .ptxt = bf_cbc_ptxt,
+ .ctxt = bf_cbc_128_encblkno1_vec3_ctxt,
+ },
+};
+
+/*
+ * IV method encblkno8, blkno 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x28, 0xe0, 0x6f,
+};
+
+/*
+ * IV method encblkno8, blkno 1.
+ */
+static const uint8_t bf_cbc_128_encblkno8_vec1_ctxt[SECSIZE] = {
+ 0x7d, 0x95, 0x5a, 0x66, 0x23, 0x98, 0xa8, 0xbe,
+ 0x53, 0x63, 0x0d, 0x46, 0x4e, 0x38, 0x1b, 0x1d,
+ 0x36, 0xdd, 0x2a, 0x57, 0x3c, 0x17, 0x01, 0xba,
+ 0x4e, 0xf8, 0xaa, 0x22, 0x74, 0x05, 0xa2, 0x40,
+ 0xd0, 0x30, 0x61, 0x6c, 0x65, 0x5e, 0xfb, 0x21,
+ 0x63, 0xef, 0x62, 0x01, 0x74, 0x15, 0xf6, 0x87,
+ 0x92, 0xc1, 0x4e, 0x46, 0xdd, 0x76, 0xdb, 0x8b,
+ 0x20, 0x44, 0xc4, 0xfa, 0x7c, 0xd2, 0x07, 0x32,
+ 0x11, 0xeb, 0x5b, 0x38, 0x44, 0x32, 0xa1, 0xe7,
+ 0xcb, 0xa6, 0x1a, 0x12, 0xb9, 0x53, 0x13, 0x6f,
+ 0xc2, 0x0e, 0x6a, 0x77, 0x8b, 0x96, 0x14, 0x0a,
+ 0x23, 0x48, 0x65, 0xa5, 0xcd, 0x39, 0x38, 0x03,
+ 0xc8, 0x3a, 0x98, 0x69, 0x3d, 0x14, 0xae, 0xad,
+ 0x54, 0x57, 0xf6, 0x5a, 0xdd, 0x46, 0x4c, 0x3a,
+ 0x68, 0xa8, 0xb7, 0x57, 0xdd, 0x1e, 0x66, 0x0e,
+ 0xc2, 0x4c, 0x17, 0xba, 0xa4, 0x7e, 0x83, 0x45,
+ 0xc6, 0xf2, 0x34, 0x3b, 0x4e, 0xab, 0x67, 0x0c,
+ 0x73, 0xbf, 0x87, 0x7e, 0x93, 0x2b, 0x14, 0x33,
+ 0xd6, 0x24, 0x8d, 0xc7, 0x90, 0x11, 0xd2, 0x38,
+ 0xe6, 0xe0, 0x39, 0x1f, 0x00, 0x74, 0x40, 0x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, 0x2e, 0x57, 0xa1, 0x21, 0xe2,
+};
+
+/*
+ * IV method encblkno8, blkno 2.
+ */
+static const uint8_t bf_cbc_128_encblkno8_vec2_ctxt[SECSIZE] = {
+ 0x28, 0x0c, 0x49, 0x08, 0x84, 0xcb, 0xba, 0x4a,
+ 0xa5, 0xb6, 0x12, 0x4c, 0x14, 0x11, 0x1f, 0x88,
+ 0x57, 0x78, 0x1e, 0x51, 0x7c, 0x9d, 0xba, 0x31,
+ 0x80, 0x14, 0xeb, 0x4a, 0x98, 0x8a, 0xb5, 0x4d,
+ 0xc5, 0xbd, 0xd2, 0x48, 0x1e, 0x19, 0x43, 0x54,
+ 0x48, 0x1d, 0x24, 0x76, 0x7d, 0xd8, 0xcc, 0xe9,
+ 0xd9, 0x7b, 0xa9, 0xdf, 0xe3, 0x65, 0x85, 0x10,
+ 0xb8, 0x11, 0xce, 0xa3, 0x07, 0x4d, 0x87, 0x3f,
+ 0x95, 0xfb, 0xa5, 0x06, 0xa4, 0x37, 0xb0, 0x89,
+ 0x03, 0xa9, 0xef, 0x62, 0x98, 0xd3, 0x85, 0xe8,
+ 0xb3, 0x21, 0xab, 0xe9, 0xdc, 0x03, 0x2a, 0x20,
+ 0xf7, 0xb1, 0xa4, 0x7a, 0xd5, 0xdc, 0x61, 0x2e,
+ 0x15, 0x81, 0x3e, 0xcf, 0x8d, 0x8d, 0x54, 0x19,
+ 0x70, 0xde, 0xa9, 0x57, 0x93, 0x87, 0xc7, 0x16,
+ 0x06, 0x25, 0xf3, 0x93, 0x8f, 0x73, 0x92, 0x29,
+ 0x1e, 0xcd, 0x5a, 0x9d, 0x8f, 0x8d, 0x44, 0x15,
+ 0x8d, 0x92, 0x44, 0x95, 0x7a, 0x5e, 0x1b, 0xfd,
+ 0x31, 0xa5, 0x8c, 0x22, 0x89, 0xbb, 0x91, 0x15,
+ 0xad, 0x0a, 0x73, 0x94, 0x65, 0xae, 0xca, 0xfc,
+ 0x7e, 0xae, 0x85, 0x45, 0xe7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x55, 0x1a,
+ 0x67, 0xcb, 0xec, 0x2c, 0x2e, 0x2e, 0x74, 0xed,
+ 0xfc, 0x85, 0x53, 0x01, 0x87, 0xa7, 0xa0, 0x1f,
+};
+
+const struct testvec bf_cbc_128_8_vectors[] = {
+ {
+ .blkno = 0,
+ .ptxt = bf_cbc_ptxt,
+ .ctxt = bf_cbc_128_encblkno8_vec0_ctxt,
+ },
+ {
+ .blkno = 1,
+ .ptxt = bf_cbc_ptxt,
+ .ctxt = bf_cbc_128_encblkno8_vec1_ctxt,
+ },
+ {
+ .blkno = 2,
+ .ptxt = bf_cbc_ptxt,
+ .ctxt = bf_cbc_128_encblkno8_vec2_ctxt,
+ },
+ {
+ .blkno = 3,
+ .ptxt = bf_cbc_ptxt,
+ .ctxt = bf_cbc_128_encblkno8_vec3_ctxt,
+ },
+};
+
+/*
+ * IV method encblkno1, blkno 0.
+ */
+static const uint8_t bf_cbc_256_encblkno1_vec0_ctxt[SECSIZE] = {
+ 0x14, 0xec, 0xa9, 0xa0, 0x51, 0x9f, 0x5e, 0xb5,
+ 0x81, 0x6f, 0xa2, 0xbf, 0x5e, 0xf7, 0x91, 0xad,
+ 0xc5, 0x1a, 0x7e, 0xe6, 0x7a, 0x82, 0x4a, 0xba,
+ 0x54, 0x60, 0xcb, 0xc3, 0x2f, 0x69, 0x5c, 0xd9,
+ 0x1e, 0x58, 0xa1, 0x88, 0xa1, 0xe5, 0xa8, 0x52,
+ 0xdf, 0xf3, 0x8d, 0x5e, 0x2f, 0x81, 0x54, 0xab,
+ 0x67, 0xb5, 0x05, 0x63, 0x20, 0x10, 0x98, 0xf5,
+ 0xa5, 0xc3, 0x9e, 0x6d, 0x80, 0x4d, 0xb6, 0x82,
+ 0x80, 0x5e, 0xb3, 0xc5, 0xd8, 0x77, 0x94, 0xa0,
+ 0xb8, 0x67, 0xb8, 0x2d, 0x9b, 0x11, 0x3c, 0x24,
+ 0xbd, 0xb7, 0x0b, 0x1d, 0xeb, 0x1d, 0x6c,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c, 0xaf, 0x88, 0xdb, 0xb5, 0x1e, 0xb1,
+ 0xae, 0x17, 0x5f, 0x29, 0x8d, 0x1c, 0x0a, 0x5c,
+ 0xb9, 0xa7, 0x59, 0x8b, 0x91, 0x41, 0xee, 0x89,
+ 0xe1, 0x0e, 0x7e, 0x0a, 0xee, 0xbc, 0x35, 0xab,
+ 0xf1, 0x5a, 0x58, 0x03, 0xa2, 0xcf, 0x33, 0xa3,
+ 0x74, 0x82, 0xd3, 0xa0, 0x32, 0xfc, 0x3b, 0x9c,
+ 0xdf, 0xc0, 0x3a, 0x76, 0xe1, 0xea, 0xf0, 0x6d,
+ 0xc8, 0xe7, 0x97, 0xec, 0x03, 0xc1, 0x72, 0x94,
+ 0xe5, 0xc4, 0x04, 0x2a, 0x38, 0xb4, 0xef, 0x47,
+ 0x1d, 0xf9, 0xb8, 0x0a, 0xa9, 0x45, 0xc1, 0x63,
+ 0xf8, 0x32, 0xdb, 0x5d, 0xb1, 0xa2, 0x80, 0x8c,
+ 0x23, 0xd3, 0x60, 0xfb, 0xf8, 0x84, 0x57, 0x8b,
+};
+
+const struct testvec bf_cbc_256_1_vectors[] = {
+ {
+ .blkno = 0,
+ .ptxt = bf_cbc_ptxt,
+ .ctxt = bf_cbc_256_encblkno1_vec0_ctxt,
+ },
+ {
+ .blkno = 1,
+ .ptxt = bf_cbc_ptxt,
+ .ctxt = bf_cbc_256_encblkno1_vec1_ctxt,
+ },
+ {
+ .blkno = 2,
+ .ptxt = bf_cbc_ptxt,
+ .ctxt = bf_cbc_256_encblkno1_vec2_ctxt,
+ },
+ {
+ .blkno = 3,
+ .ptxt = bf_cbc_ptxt,
+ .ctxt = bf_cbc_256_encblkno1_vec3_ctxt,
+ },
+};
+
+/*
+ * IV method encblkno8, blkno 0.
+ */
+static const uint8_t bf_cbc_256_encblkno8_vec0_ctxt[SECSIZE] = {
+ 0x90, 0x3d, 0xd2, 0xc0, 0xd3, 0x75, 0xe8, 0x04,
+ 0x34, 0x66, 0x76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7, 0xe8, 0x2a, 0x81, 0x82,
+};
+
+const struct testvec bf_cbc_256_8_vectors[] = {
+ {
+ .blkno = 0,
+ .ptxt = bf_cbc_ptxt,
+ .ctxt = bf_cbc_256_encblkno8_vec0_ctxt,
+ },
+ {
+ .blkno = 1,
+ .ptxt = bf_cbc_ptxt,
+ .ctxt = bf_cbc_256_encblkno8_vec1_ctxt,
+ },
+ {
+ .blkno = 2,
+ .ptxt = bf_cbc_ptxt,
+ .ctxt = bf_cbc_256_encblkno8_vec2_ctxt,
+ },
+ {
+ .blkno = 3,
+ .ptxt = bf_cbc_ptxt,
+ .ctxt = bf_cbc_256_encblkno8_vec3_ctxt,
+ },
+};
+
+/*
+ * IV method encblkno1, blkno 0.
+ */
+static const uint8_t bf_cbc_448_encblkno1_vec0_ctxt[SECSIZE] = {
+ 0xb0, 0x1b, 0x43, 0xc9, 0x84, 0x53, 0x51, 0x72,
+ 0x1f, 0x93, 0x62, 0x94, 0x13, 0x1f, 0xe3, 0xc1,
+ 0x30, 0xee, 0xc4, 0x35, 0x98, 0xb8, 0x11, 0x9b,
+ 0xd1, 0x23, 0xfa, 0x2d, 0xc1, 0xe6, 0xf3, 0x8f,
+ 0x8b, 0x05, 0x8d, 0xc5, 0x1d, 0xc3, 0x29, 0x1a,
+ 0xff, 0x08, 0xb0, 0x97, 0x88, 0x50, 0x8f, 0x41,
+ 0x66, 0xc6, 0x70, 0x37, 0xca, 0xb2, 0xcd, 0x91,
+ 0x89, 0x41, 0x1b, 0x42, 0xce, 0x02, 0xec, 0xe8,
+ 0x9b, 0xf3, 0x50, 0x95, 0x5f, 0xba, 0xda, 0xd5,
+ 0x0c, 0x2f, 0x29, 0x2a, 0x14, 0x96, 0x4a, 0x60,
+ 0x04, 0x43, 0x62, 0x80, 0x89, 0xcf, 0xfd, 0xb6,
+ 0xc7, 0x2d, 0xb2, 0xac, 0xce, 0x51, 0xf5, 0xd1,
+ 0xcd, 0x41, 0x59, 0x8b, 0xf5, 0x02, 0x2d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21, 0xaa, 0xe1, 0x96, 0x0e, 0xa9, 0x22,
+ 0xe7, 0x2c, 0xb8, 0x5e, 0x8f, 0xc6, 0x2d, 0xbd,
+ 0x99, 0x25, 0x33, 0xb8, 0x47, 0x99, 0x8d, 0xf5,
+ 0x22, 0x08, 0x9b, 0xd5, 0xad, 0x83, 0x67, 0xec,
+ 0x05, 0x89, 0xda, 0xd6, 0xe4, 0xe2, 0xd5, 0xef,
+ 0x7f, 0x61, 0x1e, 0x03, 0x81, 0x03, 0xb1, 0x98,
+ 0x5a, 0x29, 0x69, 0x13, 0xb2, 0xe6, 0xe1, 0x2c,
+ 0x66, 0x88, 0x39, 0x90, 0xf9, 0xae, 0x5d, 0x71,
+ 0xfe, 0x07, 0x30, 0x7d, 0xba, 0xa9, 0x37, 0xb5,
+ 0xff, 0x2c, 0xa9, 0xe6, 0x95, 0x48, 0xb2, 0xc8,
+};
+
+const struct testvec bf_cbc_448_1_vectors[] = {
+ {
+ .blkno = 0,
+ .ptxt = bf_cbc_ptxt,
+ .ctxt = bf_cbc_448_encblkno1_vec0_ctxt,
+ },
+ {
+ .blkno = 1,
+ .ptxt = bf_cbc_ptxt,
+ .ctxt = bf_cbc_448_encblkno1_vec1_ctxt,
+ },
+ {
+ .blkno = 2,
+ .ptxt = bf_cbc_ptxt,
+ .ctxt = bf_cbc_448_encblkno1_vec2_ctxt,
+ },
+ {
+ .blkno = 3,
+ .ptxt = bf_cbc_ptxt,
+ .ctxt = bf_cbc_448_encblkno1_vec3_ctxt,
+ },
+};
+
+/*
+ * IV method encblkno8, blkno 0.
+ */
+static const uint8_t bf_cbc_448_encblkno8_vec0_ctxt[SECSIZE] = {
+ 0x91, 0xb4, 0x8f, 0x78, 0x34, 0xbe, 0x03, 0xe9,
+ 0x4b, 0xca, 0xf4, 0xfa, 0x27, 0x99, 0xa0, 0xd0,
+ 0xa0, 0x85, 0xf9, 0xca, 0xcc, 0x2e, 0x0d, 0x41,
+ 0x91, 0xdb, 0xf9, 0x71,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bf_cbc_448_encblkno8_vec0_ctxt,
+ },
+ {
+ .blkno = 1,
+ .ptxt = bf_cbc_ptxt,
+ .ctxt = bf_cbc_448_encblkno8_vec1_ctxt,
+ },
+ {
+ .blkno = 2,
+ .ptxt = bf_cbc_ptxt,
+ .ctxt = bf_cbc_448_encblkno8_vec2_ctxt,
+ },
+ {
+ .blkno = 3,
+ .ptxt = bf_cbc_ptxt,
+ .ctxt = bf_cbc_448_encblkno8_vec3_ctxt,
+ },
+};
+
+static int
+open_disk(const char *devpath, const char *imgpath, size_t size)
+{
+ int fd;
+
+ fd = open(imgpath, O_CREAT | O_RDWR | O_TRUNC, 0600);
+ if (fd < 0)
+ return -1;
+
+ if (ftruncate(fd, size) < 0)
+ goto fail;
+
+ if (rump_pub_etfs_register_withsize(devpath,
+ imgpath, RUMP_ETFS_BLK, 0, size) < 0) {
+ goto fail;
+ }
+
+ unlink(imgpath);
+ return fd;
+fail:
+ close(fd);
+ unlink(imgpath);
+ return -1;
+}
+
+static int
+open_cgd(int devno)
+{
+ char devpath[32];
+
+ sprintf(devpath, "/dev/rcgd%d%c", devno, getrawpartition() + 'a');
+
+ return rump_sys_open(devpath, O_RDWR, 0);
+}
+
+static int
+configure_cgd(int fd, const char *dkpath, const char *alg,
+ const char *ivmethod, const char *key, size_t keylen)
+{
+ struct cgd_ioctl ci;
+
+ memset(&ci, 0, sizeof(ci));
+ ci.ci_disk = dkpath;
+ ci.ci_alg = alg;
+ ci.ci_ivmethod = ivmethod;
+ ci.ci_keylen = 8 * keylen - 8; /* Exclude the NUL terminator. */
+ ci.ci_key = key;
+ ci.ci_blocksize = 64;
+
+ return rump_sys_ioctl(fd, CGDIOCSET, &ci);
+}
+
+static int
+unconfigure_cgd(int fd)
+{
+ struct cgd_ioctl ci;
+
+ return rump_sys_ioctl(fd, CGDIOCCLR, &ci);
+}
+
+static int
+write_testvec(int cgdfd, const struct testvec *tv)
+{
+
+ if (rump_sys_lseek(cgdfd, tv->blkno * SECSIZE, SEEK_SET) < 0)
+ return -1;
+
+ if (rump_sys_write(cgdfd, tv->ptxt, SECSIZE) != SECSIZE)
+ return -1;
+
+ return 0;
+}
+
+static int
+read_testvec(int cgdfd, const struct testvec *tv)
+{
+ char *buf;
+ int res = -1;
+
+ buf = malloc(SECSIZE);
+ if (buf == NULL)
+ return -1;
+
+ if (rump_sys_lseek(cgdfd, tv->blkno * SECSIZE, SEEK_SET) < 0)
+ goto fail;
+
+ if (rump_sys_read(cgdfd, buf, SECSIZE) != SECSIZE)
+ goto fail;
+
+ res = memcmp(buf, tv->ptxt, SECSIZE);
+fail:
+ free(buf);
+ return res;
+}
+
+static int
+check_testvec(int dkfd, const struct testvec *tv)
+{
+ char *buf;
+ int res = -1;
+
+ buf = malloc(SECSIZE);
+ if (buf == NULL)
+ return -1;
+
+ if (lseek(dkfd, tv->blkno * SECSIZE, SEEK_SET) < 0)
+ goto fail;
+
+ if (read(dkfd, buf, SECSIZE) != SECSIZE)
+ goto fail;
+
+ res = memcmp(buf, tv->ctxt, SECSIZE);
+fail:
+ free(buf);
+ return res;
+}
+
+ATF_TC(cgd_bf_cbc_128_encblkno1);
+ATF_TC_HEAD(cgd_bf_cbc_128_encblkno1, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Test blowfish-cbc with 128 bits key, ivmethod encblkno1");
+}
+
+ATF_TC_BODY(cgd_bf_cbc_128_encblkno1, tc)
+{
+ const char imgpath[] = "blowfish-cbc-128-encblkno1.img";
+ const char *dkpath = "/dev/dk";
+ const size_t dksize = 4 * SECSIZE; /* Last blkno is 3. */
+ int dkfd, cgdfd;
+
+ rump_init();
+
+ RL(dkfd = open_disk(dkpath, imgpath, dksize));
+
+ RL(cgdfd = open_cgd(0));
+ RL(configure_cgd(cgdfd, dkpath, "blowfish-cbc", "encblkno1",
+ bf_cbc_128_key, sizeof(bf_cbc_128_key)));
+
+ ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_128_1_vectors[0]), 0);
+ ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_128_1_vectors[1]), 0);
+ ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_128_1_vectors[2]), 0);
+ ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_128_1_vectors[3]), 0);
+
+ RL(unconfigure_cgd(cgdfd));
+ RL(configure_cgd(cgdfd, dkpath, "blowfish-cbc", "encblkno1",
+ bf_cbc_128_key, sizeof(bf_cbc_128_key)));
+
+ ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_128_1_vectors[0]), 0);
+ ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_128_1_vectors[1]), 0);
+ ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_128_1_vectors[2]), 0);
+ ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_128_1_vectors[3]), 0);
+
+ RL(unconfigure_cgd(cgdfd));
+ RL(rump_sys_close(cgdfd));
+
+ ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_128_1_vectors[0]), 0);
+ ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_128_1_vectors[1]), 0);
+ ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_128_1_vectors[2]), 0);
+ ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_128_1_vectors[3]), 0);
+
+ RL(close(dkfd));
+}
+
+ATF_TC(cgd_bf_cbc_128_encblkno8);
+ATF_TC_HEAD(cgd_bf_cbc_128_encblkno8, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Test blowfish-cbc with 128 bits key, ivmethod encblkno8");
+}
+
+ATF_TC_BODY(cgd_bf_cbc_128_encblkno8, tc)
+{
+ const char imgpath[] = "blowfish-cbc-128-encblkno8.img";
+ const char *dkpath = "/dev/dk";
+ const size_t dksize = 4 * SECSIZE; /* Last blkno is 3. */
+ int dkfd, cgdfd;
+
+ rump_init();
+
+ RL(dkfd = open_disk(dkpath, imgpath, dksize));
+
+ RL(cgdfd = open_cgd(0));
+ RL(configure_cgd(cgdfd, dkpath, "blowfish-cbc", "encblkno8",
+ bf_cbc_128_key, sizeof(bf_cbc_128_key)));
+
+ ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_128_8_vectors[0]), 0);
+ ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_128_8_vectors[1]), 0);
+ ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_128_8_vectors[2]), 0);
+ ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_128_8_vectors[3]), 0);
+
+ RL(unconfigure_cgd(cgdfd));
+ RL(configure_cgd(cgdfd, dkpath, "blowfish-cbc", "encblkno8",
+ bf_cbc_128_key, sizeof(bf_cbc_128_key)));
+
+ ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_128_8_vectors[0]), 0);
+ ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_128_8_vectors[1]), 0);
+ ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_128_8_vectors[2]), 0);
+ ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_128_8_vectors[3]), 0);
+
+ RL(unconfigure_cgd(cgdfd));
+ RL(rump_sys_close(cgdfd));
+
+ ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_128_8_vectors[0]), 0);
+ ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_128_8_vectors[1]), 0);
+ ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_128_8_vectors[2]), 0);
+ ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_128_8_vectors[3]), 0);
+
+ RL(close(dkfd));
+}
+
+ATF_TC(cgd_bf_cbc_256_encblkno1);
+ATF_TC_HEAD(cgd_bf_cbc_256_encblkno1, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Test blowfish-cbc with 256 bits key, ivmethod encblkno1");
+}
+
+ATF_TC_BODY(cgd_bf_cbc_256_encblkno1, tc)
+{
+ const char imgpath[] = "blowfish-cbc-256-encblkno1.img";
+ const char *dkpath = "/dev/dk";
+ const size_t dksize = 4 * SECSIZE; /* Last blkno is 3. */
+ int dkfd, cgdfd;
+
+ rump_init();
+
+ RL(dkfd = open_disk(dkpath, imgpath, dksize));
+
+ RL(cgdfd = open_cgd(0));
+ RL(configure_cgd(cgdfd, dkpath, "blowfish-cbc", "encblkno1",
+ bf_cbc_256_key, sizeof(bf_cbc_256_key)));
+
+ ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_256_1_vectors[0]), 0);
+ ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_256_1_vectors[1]), 0);
+ ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_256_1_vectors[2]), 0);
+ ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_256_1_vectors[3]), 0);
+
+ RL(unconfigure_cgd(cgdfd));
+ RL(configure_cgd(cgdfd, dkpath, "blowfish-cbc", "encblkno1",
+ bf_cbc_256_key, sizeof(bf_cbc_256_key)));
+
+ ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_256_1_vectors[0]), 0);
+ ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_256_1_vectors[1]), 0);
+ ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_256_1_vectors[2]), 0);
+ ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_256_1_vectors[3]), 0);
+
+ RL(unconfigure_cgd(cgdfd));
+ RL(rump_sys_close(cgdfd));
+
+ ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_256_1_vectors[0]), 0);
+ ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_256_1_vectors[1]), 0);
+ ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_256_1_vectors[2]), 0);
+ ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_256_1_vectors[3]), 0);
+
+ RL(close(dkfd));
+}
+
+ATF_TC(cgd_bf_cbc_256_encblkno8);
+ATF_TC_HEAD(cgd_bf_cbc_256_encblkno8, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Test blowfish-cbc with 256 bits key, ivmethod encblkno8");
+}
+
+ATF_TC_BODY(cgd_bf_cbc_256_encblkno8, tc)
+{
+ const char imgpath[] = "blowfish-cbc-256-encblkno8.img";
+ const char *dkpath = "/dev/dk";
+ const size_t dksize = 4 * SECSIZE; /* Last blkno is 3. */
+ int dkfd, cgdfd;
+
+ rump_init();
+
+ RL(dkfd = open_disk(dkpath, imgpath, dksize));
+
+ RL(cgdfd = open_cgd(0));
+ RL(configure_cgd(cgdfd, dkpath, "blowfish-cbc", "encblkno8",
+ bf_cbc_256_key, sizeof(bf_cbc_256_key)));
+
+ ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_256_8_vectors[0]), 0);
+ ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_256_8_vectors[1]), 0);
+ ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_256_8_vectors[2]), 0);
+ ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_256_8_vectors[3]), 0);
+
+ RL(unconfigure_cgd(cgdfd));
+ RL(configure_cgd(cgdfd, dkpath, "blowfish-cbc", "encblkno8",
+ bf_cbc_256_key, sizeof(bf_cbc_256_key)));
+
+ ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_256_8_vectors[0]), 0);
+ ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_256_8_vectors[1]), 0);
+ ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_256_8_vectors[2]), 0);
+ ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_256_8_vectors[3]), 0);
+
+ RL(unconfigure_cgd(cgdfd));
+ RL(rump_sys_close(cgdfd));
+
+ ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_256_8_vectors[0]), 0);
+ ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_256_8_vectors[1]), 0);
+ ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_256_8_vectors[2]), 0);
+ ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_256_8_vectors[3]), 0);
+
+ RL(close(dkfd));
+}
+
+ATF_TC(cgd_bf_cbc_448_encblkno1);
+ATF_TC_HEAD(cgd_bf_cbc_448_encblkno1, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Test blowfish-cbc with 448 bits key, ivmethod encblkno1");
+}
+
+ATF_TC_BODY(cgd_bf_cbc_448_encblkno1, tc)
+{
+ const char imgpath[] = "blowfish-cbc-448-encblkno1.img";
+ const char *dkpath = "/dev/dk";
+ const size_t dksize = 4 * SECSIZE; /* Last blkno is 3. */
+ int dkfd, cgdfd;
+
+ rump_init();
+
+ RL(dkfd = open_disk(dkpath, imgpath, dksize));
+
+ RL(cgdfd = open_cgd(0));
+ RL(configure_cgd(cgdfd, dkpath, "blowfish-cbc", "encblkno1",
+ bf_cbc_448_key, sizeof(bf_cbc_448_key)));
+
+ ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_448_1_vectors[0]), 0);
+ ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_448_1_vectors[1]), 0);
+ ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_448_1_vectors[2]), 0);
+ ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_448_1_vectors[3]), 0);
+
+ RL(unconfigure_cgd(cgdfd));
+ RL(configure_cgd(cgdfd, dkpath, "blowfish-cbc", "encblkno1",
+ bf_cbc_448_key, sizeof(bf_cbc_448_key)));
+
+ ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_448_1_vectors[0]), 0);
+ ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_448_1_vectors[1]), 0);
+ ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_448_1_vectors[2]), 0);
+ ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_448_1_vectors[3]), 0);
+
+ RL(unconfigure_cgd(cgdfd));
+ RL(rump_sys_close(cgdfd));
+
+ ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_448_1_vectors[0]), 0);
+ ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_448_1_vectors[1]), 0);
+ ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_448_1_vectors[2]), 0);
+ ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_448_1_vectors[3]), 0);
+
+ RL(close(dkfd));
+}
+
+ATF_TC(cgd_bf_cbc_448_encblkno8);
+ATF_TC_HEAD(cgd_bf_cbc_448_encblkno8, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Test blowfish-cbc with 448 bits key, ivmethod encblkno8");
+}
+
+ATF_TC_BODY(cgd_bf_cbc_448_encblkno8, tc)
+{
+ const char imgpath[] = "blowfish-cbc-448-encblkno8.img";
+ const char *dkpath = "/dev/dk";
+ const size_t dksize = 4 * SECSIZE; /* Last blkno is 3. */
+ int dkfd, cgdfd;
+
+ rump_init();
+
+ RL(dkfd = open_disk(dkpath, imgpath, dksize));
+
+ RL(cgdfd = open_cgd(0));
+ RL(configure_cgd(cgdfd, dkpath, "blowfish-cbc", "encblkno8",
+ bf_cbc_448_key, sizeof(bf_cbc_448_key)));
+
+ ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_448_8_vectors[0]), 0);
+ ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_448_8_vectors[1]), 0);
+ ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_448_8_vectors[2]), 0);
+ ATF_CHECK_EQ(write_testvec(cgdfd, &bf_cbc_448_8_vectors[3]), 0);
+
+ RL(unconfigure_cgd(cgdfd));
+ RL(configure_cgd(cgdfd, dkpath, "blowfish-cbc", "encblkno8",
+ bf_cbc_448_key, sizeof(bf_cbc_448_key)));
+
+ ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_448_8_vectors[0]), 0);
+ ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_448_8_vectors[1]), 0);
+ ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_448_8_vectors[2]), 0);
+ ATF_CHECK_EQ(read_testvec(cgdfd, &bf_cbc_448_8_vectors[3]), 0);
+
+ RL(unconfigure_cgd(cgdfd));
+ RL(rump_sys_close(cgdfd));
+
+ ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_448_8_vectors[0]), 0);
+ ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_448_8_vectors[1]), 0);
+ ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_448_8_vectors[2]), 0);
+ ATF_CHECK_EQ(check_testvec(dkfd, &bf_cbc_448_8_vectors[3]), 0);
+
+ RL(close(dkfd));
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+
+ ATF_TP_ADD_TC(tp, cgd_bf_cbc_128_encblkno1);
+ ATF_TP_ADD_TC(tp, cgd_bf_cbc_128_encblkno8);
+ ATF_TP_ADD_TC(tp, cgd_bf_cbc_256_encblkno1);
+ ATF_TP_ADD_TC(tp, cgd_bf_cbc_256_encblkno8);
+ ATF_TP_ADD_TC(tp, cgd_bf_cbc_448_encblkno1);
+ ATF_TP_ADD_TC(tp, cgd_bf_cbc_448_encblkno8);
+
+ return atf_no_error();
+}
diff --git a/contrib/netbsd-tests/fs/ffs/ffs_common.sh b/contrib/netbsd-tests/fs/ffs/ffs_common.sh
index eaf7142..ee94a15 100755
--- a/contrib/netbsd-tests/fs/ffs/ffs_common.sh
+++ b/contrib/netbsd-tests/fs/ffs/ffs_common.sh
@@ -1,4 +1,4 @@
-# $NetBSD: ffs_common.sh,v 1.2 2013/07/29 13:15:24 skrll Exp $
+# $NetBSD: ffs_common.sh,v 1.3 2016/10/08 13:23:53 gson Exp $
create_ffs()
{
@@ -45,7 +45,7 @@ test_case()
eval "${name}_head() { \
atf_set "descr" "${descr}"
- atf_set "timeout" "60"
+ atf_set "timeout" "120"
}"
eval "${name}_body() { \
RUMP_SOCKETS_LIST=\${RUMP_SOCKET}; \
diff --git a/contrib/netbsd-tests/fs/fifofs/t_fifo.c b/contrib/netbsd-tests/fs/fifofs/t_fifo.c
index c4a2060..4b37bb8 100644
--- a/contrib/netbsd-tests/fs/fifofs/t_fifo.c
+++ b/contrib/netbsd-tests/fs/fifofs/t_fifo.c
@@ -1,9 +1,10 @@
/* Test case written by Bharat Joshi */
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_fifo.c,v 1.1 2011/12/21 00:17:07 christos Exp $");
+__RCSID("$NetBSD: t_fifo.c,v 1.2 2017/01/10 22:36:29 christos Exp $");
#include <sys/types.h>
#include <sys/wait.h>
+#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/contrib/netbsd-tests/fs/psshfs/t_psshfs.sh b/contrib/netbsd-tests/fs/psshfs/t_psshfs.sh
index 241d46d..4d8fede 100755
--- a/contrib/netbsd-tests/fs/psshfs/t_psshfs.sh
+++ b/contrib/netbsd-tests/fs/psshfs/t_psshfs.sh
@@ -1,4 +1,4 @@
-# $NetBSD: t_psshfs.sh,v 1.7 2013/03/16 07:54:04 jmmv Exp $
+# $NetBSD: t_psshfs.sh,v 1.8 2016/09/05 08:53:57 christos Exp $
#
# Copyright (c) 2007, 2008 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -262,6 +262,26 @@ setattr_cache_cleanup() {
stop_ssh
}
+atf_test_case read_empty_file cleanup
+read_empty_file_head() {
+ atf_set "descr" "Checks whether an empty file can be read"
+ # This test is supposed to make sure psshfs does not hang
+ # when reading from an empty file, hence the timeout.
+ atf_set "timeout" 8
+}
+read_empty_file_body() {
+ require_puffs
+ start_ssh
+ atf_check mkdir root mnt
+ atf_check -x ': > root/empty'
+ mount_psshfs root mnt
+ atf_check cat mnt/empty
+}
+read_empty_file_cleanup() {
+ umount mnt
+ stop_ssh
+}
+
# -------------------------------------------------------------------------
# Initialization.
# -------------------------------------------------------------------------
@@ -271,4 +291,5 @@ atf_init_test_cases() {
atf_add_test_case pwd
atf_add_test_case ls
#atf_add_test_case setattr_cache
+ atf_add_test_case read_empty_file
}
diff --git a/contrib/netbsd-tests/fs/puffs/t_basic.c b/contrib/netbsd-tests/fs/puffs/t_basic.c
index ce5e4ea..735108d 100644
--- a/contrib/netbsd-tests/fs/puffs/t_basic.c
+++ b/contrib/netbsd-tests/fs/puffs/t_basic.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_basic.c,v 1.12 2013/10/19 17:45:00 christos Exp $ */
+/* $NetBSD: t_basic.c,v 1.13 2016/12/01 14:49:04 hannken Exp $ */
#include <sys/types.h>
#include <sys/mount.h>
@@ -286,7 +286,7 @@ ATF_TC_BODY(inactive_reclaim, tc)
rump_sys_close(fd);
syncbar(FSTEST_MNTNAME);
- ATF_REQUIRE_EQ(pargs->pta_vn_toserv_ops[PUFFS_VN_INACTIVE], 1);
+ ATF_REQUIRE(pargs->pta_vn_toserv_ops[PUFFS_VN_INACTIVE] > 0);
ATF_REQUIRE_EQ(pargs->pta_vn_toserv_ops[PUFFS_VN_RECLAIM], 1);
FSTEST_EXIT();
@@ -383,7 +383,7 @@ ATF_TC_BODY(unlink_accessible, tc)
syncbar(FSTEST_MNTNAME);
ATF_REQUIRE_EQ(pargs->pta_vn_toserv_ops[PUFFS_VN_RECLAIM], 1);
- ATF_REQUIRE_EQ(pargs->pta_vn_toserv_ops[PUFFS_VN_INACTIVE], ianow+1);
+ ATF_REQUIRE(pargs->pta_vn_toserv_ops[PUFFS_VN_INACTIVE] > ianow);
ATF_REQUIRE_STREQ(buf, MAGICSTR);
diff --git a/contrib/netbsd-tests/fs/vfs/t_vnops.c b/contrib/netbsd-tests/fs/vfs/t_vnops.c
index 08203dd..978fadb 100644
--- a/contrib/netbsd-tests/fs/vfs/t_vnops.c
+++ b/contrib/netbsd-tests/fs/vfs/t_vnops.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_vnops.c,v 1.55 2016/01/28 10:10:09 martin Exp $ */
+/* $NetBSD: t_vnops.c,v 1.58 2016/08/29 02:31:46 kre Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -28,6 +28,7 @@
#include <sys/stat.h>
#include <sys/statvfs.h>
+#include <sys/time.h>
#include <assert.h>
#include <atf-c.h>
@@ -55,10 +56,10 @@
atf_tc_skip("symlinks not supported by file system")
static char *
-md(char *buf, const char *base, const char *tail)
+md(char *buf, size_t buflen, const char *base, const char *tail)
{
- sprintf(buf, "%s/%s", base, tail);
+ snprintf(buf, buflen, "%s/%s", base, tail);
return buf;
}
@@ -69,11 +70,11 @@ lookup_simple(const atf_tc_t *tc, const char *mountpath)
struct stat sb1, sb2;
strcpy(final, mountpath);
- sprintf(pb, "%s/../%s", mountpath, basename(final));
+ snprintf(pb, sizeof(pb), "%s/../%s", mountpath, basename(final));
if (rump_sys_stat(pb, &sb1) == -1)
atf_tc_fail_errno("stat 1");
- sprintf(pb, "%s/./../%s", mountpath, basename(final));
+ snprintf(pb, sizeof(pb), "%s/./../%s", mountpath, basename(final));
if (rump_sys_stat(pb, &sb2) == -1)
atf_tc_fail_errno("stat 2");
@@ -85,22 +86,38 @@ lookup_complex(const atf_tc_t *tc, const char *mountpath)
{
char pb[MAXPATHLEN];
struct stat sb1, sb2;
+ struct timespec atplus1, onesec;
USES_DIRS;
- if (FSTYPE_UDF(tc))
- atf_tc_expect_fail("PR kern/49033");
-
- sprintf(pb, "%s/dir", mountpath);
+ snprintf(pb, sizeof(pb), "%s/dir", mountpath);
if (rump_sys_mkdir(pb, 0777) == -1)
atf_tc_fail_errno("mkdir");
if (rump_sys_stat(pb, &sb1) == -1)
atf_tc_fail_errno("stat 1");
- sprintf(pb, "%s/./dir/../././dir/.", mountpath);
+ snprintf(pb, sizeof(pb), "%s/./dir/../././dir/.", mountpath);
if (rump_sys_stat(pb, &sb2) == -1)
atf_tc_fail_errno("stat 2");
+ /*
+ * The lookup is permitted to modify the access time of
+ * any directories searched - such a directory is the
+ * subject of this test. Any difference should cause
+ * the 2nd lookup atime tp be >= the first, if it is ==, all is
+ * OK (atime is not required to be modified by the search, or
+ * both references may happen within the came clock tick), if the
+ * 2nd lookup atime is > the first, but not "too much" greater,
+ * just set it back, so the memcmp just below succeeds
+ * (assuming all else is OK).
+ */
+ onesec.tv_sec = 1;
+ onesec.tv_nsec = 0;
+ timespecadd(&sb1.st_atimespec, &onesec, &atplus1);
+ if (timespeccmp(&sb2.st_atimespec, &sb1.st_atimespec, >) &&
+ timespeccmp(&sb2.st_atimespec, &atplus1, <))
+ sb2.st_atimespec = sb1.st_atimespec;
+
if (memcmp(&sb1, &sb2, sizeof(sb1)) != 0) {
printf("what\tsb1\t\tsb2\n");
@@ -133,9 +150,6 @@ lookup_complex(const atf_tc_t *tc, const char *mountpath)
atf_tc_fail("stat results differ, see ouput for more details");
}
- if (FSTYPE_UDF(tc))
- atf_tc_fail("random failure of PR kern/49033 "
- "did not happen this time");
}
static void
@@ -147,7 +161,7 @@ dir_simple(const atf_tc_t *tc, const char *mountpath)
USES_DIRS;
/* check we can create directories */
- sprintf(pb, "%s/dir", mountpath);
+ snprintf(pb, sizeof(pb), "%s/dir", mountpath);
if (rump_sys_mkdir(pb, 0777) == -1)
atf_tc_fail_errno("mkdir");
if (rump_sys_stat(pb, &sb) == -1)
@@ -169,11 +183,11 @@ dir_notempty(const atf_tc_t *tc, const char *mountpath)
USES_DIRS;
/* check we can create directories */
- sprintf(pb, "%s/dir", mountpath);
+ snprintf(pb, sizeof(pb), "%s/dir", mountpath);
if (rump_sys_mkdir(pb, 0777) == -1)
atf_tc_fail_errno("mkdir");
- sprintf(pb2, "%s/dir/file", mountpath);
+ snprintf(pb2, sizeof(pb2), "%s/dir/file", mountpath);
fd = rump_sys_open(pb2, O_RDWR | O_CREAT, 0777);
if (fd == -1)
atf_tc_fail_errno("create file");
@@ -205,9 +219,9 @@ dir_rmdirdotdot(const atf_tc_t *tc, const char *mp)
RL(rump_sys_mkdir("subtest", 0777));
RL(rump_sys_chdir("subtest"));
- md(pb, mp, "test/subtest");
+ md(pb, sizeof(pb), mp, "test/subtest");
RL(rump_sys_rmdir(pb));
- md(pb, mp, "test");
+ md(pb, sizeof(pb), mp, "test");
RL(rump_sys_rmdir(pb));
if (FSTYPE_NFS(tc))
@@ -225,7 +239,7 @@ checkfile(const char *path, struct stat *refp)
struct stat sb;
static int n = 1;
- md(buf, path, "file");
+ md(buf, sizeof(buf), path, "file");
if (rump_sys_stat(buf, &sb) == -1)
atf_tc_fail_errno("cannot stat file %d (%s)", n, buf);
if (memcmp(&sb, refp, sizeof(sb)) != 0)
@@ -244,18 +258,18 @@ rename_dir(const atf_tc_t *tc, const char *mp)
USES_DIRS;
- md(pb1, mp, "dir1");
+ md(pb1, sizeof(pb1), mp, "dir1");
if (rump_sys_mkdir(pb1, 0777) == -1)
atf_tc_fail_errno("mkdir 1");
- md(pb2, mp, "dir2");
+ md(pb2, sizeof(pb2), mp, "dir2");
if (rump_sys_mkdir(pb2, 0777) == -1)
atf_tc_fail_errno("mkdir 2");
- md(pb2, mp, "dir2/subdir");
+ md(pb2, sizeof(pb2), mp, "dir2/subdir");
if (rump_sys_mkdir(pb2, 0777) == -1)
atf_tc_fail_errno("mkdir 3");
- md(pb3, mp, "dir1/file");
+ md(pb3, sizeof(pb3), mp, "dir1/file");
if (rump_sys_mknod(pb3, S_IFREG | 0777, -1) == -1)
atf_tc_fail_errno("create file");
if (rump_sys_stat(pb3, &ref) == -1)
@@ -266,13 +280,13 @@ rename_dir(const atf_tc_t *tc, const char *mp)
*/
/* rename within directory */
- md(pb3, mp, "dir3");
+ md(pb3, sizeof(pb3), mp, "dir3");
if (rump_sys_rename(pb1, pb3) == -1)
atf_tc_fail_errno("rename 1");
checkfile(pb3, &ref);
/* rename directory onto itself (two ways, should fail) */
- md(pb1, mp, "dir3/.");
+ md(pb1, sizeof(pb1), mp, "dir3/.");
if (rump_sys_rename(pb1, pb3) != -1 || errno != EINVAL)
atf_tc_fail_errno("rename 2");
if (rump_sys_rename(pb3, pb1) != -1 || errno != EISDIR)
@@ -281,13 +295,13 @@ rename_dir(const atf_tc_t *tc, const char *mp)
checkfile(pb3, &ref);
/* rename father of directory into directory */
- md(pb1, mp, "dir2/dir");
- md(pb2, mp, "dir2");
+ md(pb1, sizeof(pb1), mp, "dir2/dir");
+ md(pb2, sizeof(pb2), mp, "dir2");
if (rump_sys_rename(pb2, pb1) != -1 || errno != EINVAL)
atf_tc_fail_errno("rename 4");
/* same for grandfather */
- md(pb1, mp, "dir2/subdir/dir2");
+ md(pb1, sizeof(pb1), mp, "dir2/subdir/dir2");
if (rump_sys_rename(pb2, pb1) != -1 || errno != EINVAL)
atf_tc_fail("rename 5");
@@ -298,29 +312,29 @@ rename_dir(const atf_tc_t *tc, const char *mp)
atf_tc_fail("rename 6");
/* cross-directory rename */
- md(pb1, mp, "dir3");
- md(pb2, mp, "dir2/somedir");
+ md(pb1, sizeof(pb1), mp, "dir3");
+ md(pb2, sizeof(pb2), mp, "dir2/somedir");
if (rump_sys_rename(pb1, pb2) == -1)
atf_tc_fail_errno("rename 7");
checkfile(pb2, &ref);
/* move to parent directory */
- md(pb1, mp, "dir2/somedir/../../dir3");
+ md(pb1, sizeof(pb1), mp, "dir2/somedir/../../dir3");
if (rump_sys_rename(pb2, pb1) == -1)
atf_tc_fail_errno("rename 8");
- md(pb1, mp, "dir2/../dir3");
+ md(pb1, sizeof(pb1), mp, "dir2/../dir3");
checkfile(pb1, &ref);
/* atomic cross-directory rename */
- md(pb3, mp, "dir2/subdir");
+ md(pb3, sizeof(pb3), mp, "dir2/subdir");
if (rump_sys_rename(pb1, pb3) == -1)
atf_tc_fail_errno("rename 9");
checkfile(pb3, &ref);
/* rename directory over an empty directory */
- md(pb1, mp, "parent");
- md(pb2, mp, "parent/dir1");
- md(pb3, mp, "parent/dir2");
+ md(pb1, sizeof(pb1), mp, "parent");
+ md(pb2, sizeof(pb2), mp, "parent/dir1");
+ md(pb3, sizeof(pb3), mp, "parent/dir2");
RL(rump_sys_mkdir(pb1, 0777));
RL(rump_sys_mkdir(pb2, 0777));
RL(rump_sys_mkdir(pb3, 0777));
@@ -467,15 +481,15 @@ create_many(const atf_tc_t *tc, const char *mp)
for (i = 0; i < nfiles; i++) {
int fd;
- sprintf(buf, TESTFN "%d", i);
+ snprintf(buf, sizeof(buf), TESTFN "%d", i);
RL(fd = rump_sys_open(buf, O_RDWR|O_CREAT|O_EXCL, 0666));
RL(rump_sys_close(fd));
}
/* wipe them out */
for (i = 0; i < nfiles; i++) {
- sprintf(buf, TESTFN "%d", i);
- RL(rump_sys_unlink(buf));
+ snprintf(buf, sizeof(buf), TESTFN "%d", i);
+ RLF(rump_sys_unlink(buf), "%s", buf);
}
#undef TESTFN
@@ -499,12 +513,12 @@ create_nonalphanum(const atf_tc_t *tc, const char *mp)
for (i = 0; i < 256; i++) {
int fd;
- sprintf(buf, "%c", i);
+ snprintf(buf, sizeof(buf), "%c", i);
fd = rump_sys_open(buf, O_RDWR|O_CREAT|O_EXCL, 0666);
if (fd == -1)
continue;
- RL(rump_sys_close(fd));
- RL(rump_sys_unlink(buf));
+ RLF(rump_sys_close(fd), "%d", fd);
+ RLF(rump_sys_unlink(buf), "%s", buf);
}
printf("\n");
@@ -632,7 +646,7 @@ symlink_len(const atf_tc_t *tc, const char *mp, size_t len)
USES_SYMLINKS;
- RL(rump_sys_chdir(mp));
+ RLF(rump_sys_chdir(mp), "%s", mp);
buf = malloc(len + 1);
ATF_REQUIRE(buf);
diff --git a/contrib/netbsd-tests/h_macros.h b/contrib/netbsd-tests/h_macros.h
index 29b4e99..dd730c9 100644
--- a/contrib/netbsd-tests/h_macros.h
+++ b/contrib/netbsd-tests/h_macros.h
@@ -1,4 +1,4 @@
-/* $NetBSD: h_macros.h,v 1.12 2016/08/04 11:49:07 jakllsch Exp $ */
+/* $NetBSD: h_macros.h,v 1.13 2016/08/20 15:49:08 christos Exp $ */
/*-
* Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -45,6 +45,8 @@
ATF_CHECK_MSG((x) != (v), "%s: %s", #x, strerror(errno))
#define RL(x) REQUIRE_LIBC(x, -1)
+#define RLF(x, fmt, arg) \
+ ATF_CHECK_MSG((x) != -1, "%s [" fmt "]: %s", #x, arg, strerror(errno))
#define RZ(x) \
do { \
int RZ_rv = x; \
diff --git a/contrib/netbsd-tests/kernel/msg.h b/contrib/netbsd-tests/kernel/msg.h
new file mode 100644
index 0000000..547400e
--- /dev/null
+++ b/contrib/netbsd-tests/kernel/msg.h
@@ -0,0 +1,136 @@
+/* $NetBSD: msg.h,v 1.1 2016/12/05 20:10:10 christos Exp $ */
+
+/*-
+ * Copyright (c) 2016 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christos Zoulas.
+ *
+ * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 msg_fds {
+ int pfd[2];
+ int cfd[2];
+};
+
+#define CLOSEFD(fd) do { \
+ if (fd != -1) { \
+ close(fd); \
+ fd = -1; \
+ } \
+} while (/*CONSTCOND*/ 0)
+
+static int
+msg_open(struct msg_fds *fds)
+{
+ if (pipe(fds->pfd) == -1)
+ return -1;
+ if (pipe(fds->cfd) == -1) {
+ close(fds->pfd[0]);
+ close(fds->pfd[1]);
+ return -1;
+ }
+ return 0;
+}
+
+static void
+msg_close(struct msg_fds *fds)
+{
+ CLOSEFD(fds->pfd[0]);
+ CLOSEFD(fds->pfd[1]);
+ CLOSEFD(fds->cfd[0]);
+ CLOSEFD(fds->cfd[1]);
+}
+
+static int
+msg_write_child(const char *info, struct msg_fds *fds, void *msg, size_t len)
+{
+ ssize_t rv;
+ CLOSEFD(fds->cfd[1]);
+ CLOSEFD(fds->pfd[0]);
+
+ printf("Send %s\n", info);
+ rv = write(fds->pfd[1], msg, len);
+ if (rv != (ssize_t)len)
+ return 1;
+// printf("Wait %s\n", info);
+ rv = read(fds->cfd[0], msg, len);
+ if (rv != (ssize_t)len)
+ return 1;
+ return 0;
+}
+
+static int
+msg_write_parent(const char *info, struct msg_fds *fds, void *msg, size_t len)
+{
+ ssize_t rv;
+ CLOSEFD(fds->pfd[1]);
+ CLOSEFD(fds->cfd[0]);
+
+ printf("Send %s\n", info);
+ rv = write(fds->cfd[1], msg, len);
+ if (rv != (ssize_t)len)
+ return 1;
+// printf("Wait %s\n", info);
+ rv = read(fds->pfd[0], msg, len);
+ if (rv != (ssize_t)len)
+ return 1;
+ return 0;
+}
+
+static int
+msg_read_parent(const char *info, struct msg_fds *fds, void *msg, size_t len)
+{
+ ssize_t rv;
+ CLOSEFD(fds->pfd[1]);
+ CLOSEFD(fds->cfd[0]);
+
+ printf("Wait %s\n", info);
+ rv = read(fds->pfd[0], msg, len);
+ if (rv != (ssize_t)len)
+ return 1;
+// printf("Send %s\n", info);
+ rv = write(fds->cfd[1], msg, len);
+ if (rv != (ssize_t)len)
+ return 1;
+ return 0;
+}
+
+static int
+msg_read_child(const char *info, struct msg_fds *fds, void *msg, size_t len)
+{
+ ssize_t rv;
+ CLOSEFD(fds->cfd[1]);
+ CLOSEFD(fds->pfd[0]);
+
+ printf("Wait %s\n", info);
+ rv = read(fds->cfd[0], msg, len);
+ if (rv != (ssize_t)len)
+ return 1;
+// printf("Send %s\n", info);
+ rv = write(fds->pfd[1], msg, len);
+ if (rv != (ssize_t)len)
+ return 1;
+ return 0;
+}
diff --git a/contrib/netbsd-tests/kernel/t_mqueue.c b/contrib/netbsd-tests/kernel/t_mqueue.c
index aa98d91..485269f 100644
--- a/contrib/netbsd-tests/kernel/t_mqueue.c
+++ b/contrib/netbsd-tests/kernel/t_mqueue.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_mqueue.c,v 1.4 2014/03/02 19:56:48 jmmv Exp $ */
+/* $NetBSD: t_mqueue.c,v 1.5 2017/01/10 22:10:22 christos Exp $ */
/*
* Test for POSIX message queue priority handling.
@@ -14,6 +14,7 @@
#endif
#include <atf-c.h>
+#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/contrib/netbsd-tests/kernel/t_ptrace.c b/contrib/netbsd-tests/kernel/t_ptrace.c
new file mode 100644
index 0000000..074a953
--- /dev/null
+++ b/contrib/netbsd-tests/kernel/t_ptrace.c
@@ -0,0 +1,208 @@
+/* $NetBSD: t_ptrace.c,v 1.17 2016/11/13 22:59:31 kamil Exp $ */
+
+/*-
+ * Copyright (c) 2016 The NetBSD Foundation, Inc.
+ * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+ */
+
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: t_ptrace.c,v 1.17 2016/11/13 22:59:31 kamil Exp $");
+
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/ptrace.h>
+#include <sys/stat.h>
+#include <sys/sysctl.h>
+#include <err.h>
+#include <errno.h>
+#include <unistd.h>
+
+#include <atf-c.h>
+
+#include "../h_macros.h"
+
+/*
+ * A child process cannot call atf functions and expect them to magically
+ * work like in the parent.
+ * The printf(3) messaging from a child will not work out of the box as well
+ * without estabilishing a communication protocol with its parent. To not
+ * overcomplicate the tests - do not log from a child and use err(3)/errx(3)
+ * wrapped with FORKEE_ASSERT()/FORKEE_ASSERTX() as that is guaranteed to work.
+ */
+#define FORKEE_ASSERTX(x) \
+do { \
+ int ret = (x); \
+ if (!ret) \
+ errx(EXIT_FAILURE, "%s:%d %s(): Assertion failed for: %s", \
+ __FILE__, __LINE__, __func__, #x); \
+} while (0)
+
+#define FORKEE_ASSERT(x) \
+do { \
+ int ret = (x); \
+ if (!ret) \
+ err(EXIT_FAILURE, "%s:%d %s(): Assertion failed for: %s", \
+ __FILE__, __LINE__, __func__, #x); \
+} while (0)
+
+ATF_TC(attach_pid0);
+ATF_TC_HEAD(attach_pid0, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Assert that a debugger cannot attach to PID 0");
+}
+
+ATF_TC_BODY(attach_pid0, tc)
+{
+ errno = 0;
+ ATF_REQUIRE_ERRNO(EPERM, ptrace(PT_ATTACH, 0, NULL, 0) == -1);
+}
+
+ATF_TC(attach_pid1);
+ATF_TC_HEAD(attach_pid1, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Assert that a debugger cannot attach to PID 1 (as non-root)");
+
+ atf_tc_set_md_var(tc, "require.user", "unprivileged");
+}
+
+ATF_TC_BODY(attach_pid1, tc)
+{
+ ATF_REQUIRE_ERRNO(EPERM, ptrace(PT_ATTACH, 1, NULL, 0) == -1);
+}
+
+ATF_TC(attach_pid1_securelevel);
+ATF_TC_HEAD(attach_pid1_securelevel, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Assert that a debugger cannot attach to PID 1 with "
+ "securelevel >= 1 (as root)");
+
+ atf_tc_set_md_var(tc, "require.user", "root");
+}
+
+ATF_TC_BODY(attach_pid1_securelevel, tc)
+{
+ int level;
+ size_t len = sizeof(level);
+
+ ATF_REQUIRE(sysctlbyname("kern.securelevel", &level, &len, NULL, 0)
+ != -1);
+
+ if (level < 1) {
+ atf_tc_skip("Test must be run with securelevel >= 1");
+ }
+
+ ATF_REQUIRE_ERRNO(EPERM, ptrace(PT_ATTACH, 1, NULL, 0) == -1);
+}
+
+ATF_TC(attach_self);
+ATF_TC_HEAD(attach_self, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Assert that a debugger cannot attach to self (as it's nonsense)");
+}
+
+ATF_TC_BODY(attach_self, tc)
+{
+ ATF_REQUIRE_ERRNO(EINVAL, ptrace(PT_ATTACH, getpid(), NULL, 0) == -1);
+}
+
+ATF_TC(attach_chroot);
+ATF_TC_HEAD(attach_chroot, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Assert that a debugger cannot trace another process unless the "
+ "process's root directory is at or below the tracing process's "
+ "root");
+
+ atf_tc_set_md_var(tc, "require.user", "root");
+}
+
+ATF_TC_BODY(attach_chroot, tc)
+{
+ char buf[PATH_MAX];
+ pid_t child;
+ int fds_toparent[2], fds_fromparent[2];
+ int rv;
+ uint8_t msg = 0xde; /* dummy message for IPC based on pipe(2) */
+
+ (void)memset(buf, '\0', sizeof(buf));
+ ATF_REQUIRE(getcwd(buf, sizeof(buf)) != NULL);
+ (void)strlcat(buf, "/dir", sizeof(buf));
+
+ ATF_REQUIRE(mkdir(buf, 0500) == 0);
+ ATF_REQUIRE(chdir(buf) == 0);
+
+ ATF_REQUIRE(pipe(fds_toparent) == 0);
+ ATF_REQUIRE(pipe(fds_fromparent) == 0);
+ child = atf_utils_fork();
+ if (child == 0) {
+ FORKEE_ASSERT(close(fds_toparent[0]) == 0);
+ FORKEE_ASSERT(close(fds_fromparent[1]) == 0);
+
+ FORKEE_ASSERT(chroot(buf) == 0);
+
+ rv = write(fds_toparent[1], &msg, sizeof(msg));
+ FORKEE_ASSERTX(rv == sizeof(msg));
+
+ ATF_REQUIRE_ERRNO(EPERM,
+ ptrace(PT_ATTACH, getppid(), NULL, 0) == -1);
+
+ rv = read(fds_fromparent[0], &msg, sizeof(msg));
+ FORKEE_ASSERTX(rv == sizeof(msg));
+
+ _exit(0);
+ }
+ ATF_REQUIRE(close(fds_toparent[1]) == 0);
+ ATF_REQUIRE(close(fds_fromparent[0]) == 0);
+
+ printf("Waiting for chrooting of the child PID %d", child);
+ rv = read(fds_toparent[0], &msg, sizeof(msg));
+ ATF_REQUIRE(rv == sizeof(msg));
+
+ printf("Child is ready, it will try to PT_ATTACH to parent\n");
+ rv = write(fds_fromparent[1], &msg, sizeof(msg));
+ ATF_REQUIRE(rv == sizeof(msg));
+
+ printf("fds_fromparent is no longer needed - close it\n");
+ ATF_REQUIRE(close(fds_fromparent[1]) == 0);
+
+ printf("fds_toparent is no longer needed - close it\n");
+ ATF_REQUIRE(close(fds_toparent[0]) == 0);
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+ setvbuf(stdout, NULL, _IONBF, 0);
+ setvbuf(stderr, NULL, _IONBF, 0);
+ ATF_TP_ADD_TC(tp, attach_pid0);
+ ATF_TP_ADD_TC(tp, attach_pid1);
+ ATF_TP_ADD_TC(tp, attach_pid1_securelevel);
+ ATF_TP_ADD_TC(tp, attach_self);
+ ATF_TP_ADD_TC(tp, attach_chroot);
+
+ return atf_no_error();
+}
diff --git a/contrib/netbsd-tests/kernel/t_ptrace_wait.c b/contrib/netbsd-tests/kernel/t_ptrace_wait.c
new file mode 100644
index 0000000..e502a03
--- /dev/null
+++ b/contrib/netbsd-tests/kernel/t_ptrace_wait.c
@@ -0,0 +1,5082 @@
+/* $NetBSD: t_ptrace_wait.c,v 1.53 2017/01/10 05:08:24 kamil Exp $ */
+
+/*-
+ * Copyright (c) 2016 The NetBSD Foundation, Inc.
+ * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+ */
+
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.53 2017/01/10 05:08:24 kamil Exp $");
+
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/ptrace.h>
+#include <sys/resource.h>
+#include <sys/stat.h>
+#include <sys/sysctl.h>
+#include <sys/wait.h>
+#include <machine/reg.h>
+#include <err.h>
+#include <errno.h>
+#include <signal.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <strings.h>
+#include <unistd.h>
+
+#include <atf-c.h>
+
+#include "../h_macros.h"
+
+#include "t_ptrace_wait.h"
+#include "msg.h"
+
+#define PARENT_TO_CHILD(info, fds, msg) \
+ ATF_REQUIRE(msg_write_child(info " to child " # fds, &fds, &msg, sizeof(msg)) == 0)
+
+#define CHILD_FROM_PARENT(info, fds, msg) \
+ FORKEE_ASSERT(msg_read_parent(info " from parent " # fds, &fds, &msg, sizeof(msg)) == 0)
+
+#define CHILD_TO_PARENT(info, fds, msg) \
+ FORKEE_ASSERT(msg_write_parent(info " to parent " # fds, &fds, &msg, sizeof(msg)) == 0)
+
+#define PARENT_FROM_CHILD(info, fds, msg) \
+ ATF_REQUIRE(msg_read_child(info " from parent " # fds, &fds, &msg, sizeof(msg)) == 0)
+
+ATF_TC(traceme1);
+ATF_TC_HEAD(traceme1, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify SIGSTOP followed by _exit(2) in a child");
+}
+
+ATF_TC_BODY(traceme1, tc)
+{
+ const int exitval = 5;
+ const int sigval = SIGSTOP;
+ pid_t child, wpid;
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+
+ printf("Before forking process PID=%d\n", getpid());
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+ printf("Before raising %s from child\n", strsignal(sigval));
+ FORKEE_ASSERT(raise(sigval) == 0);
+
+ printf("Before exiting of the child process\n");
+ _exit(exitval);
+ }
+ printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, sigval);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_exited(status, exitval);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+
+ATF_TC(traceme2);
+ATF_TC_HEAD(traceme2, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify SIGSTOP followed by _exit(2) in a child");
+}
+
+static int traceme2_caught = 0;
+
+static void
+traceme2_sighandler(int sig)
+{
+ FORKEE_ASSERT_EQ(sig, SIGINT);
+
+ ++traceme2_caught;
+}
+
+ATF_TC_BODY(traceme2, tc)
+{
+ const int exitval = 5;
+ const int sigval = SIGSTOP, sigsent = SIGINT;
+ pid_t child, wpid;
+ struct sigaction sa;
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+
+ printf("Before forking process PID=%d\n", getpid());
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+ sa.sa_handler = traceme2_sighandler;
+ sa.sa_flags = SA_SIGINFO;
+ sigemptyset(&sa.sa_mask);
+
+ FORKEE_ASSERT(sigaction(sigsent, &sa, NULL) != -1);
+
+ printf("Before raising %s from child\n", strsignal(sigval));
+ FORKEE_ASSERT(raise(sigval) == 0);
+
+ FORKEE_ASSERT_EQ(traceme2_caught, 1);
+
+ printf("Before exiting of the child process\n");
+ _exit(exitval);
+ }
+ printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, sigval);
+
+ printf("Before resuming the child process where it left off and with "
+ "signal %s to be sent\n", strsignal(sigsent));
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, sigsent) != -1);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_exited(status, exitval);
+
+ printf("Before calling %s() for the exited child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+
+ATF_TC(traceme3);
+ATF_TC_HEAD(traceme3, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify SIGSTOP followed by termination by a signal in a child");
+}
+
+ATF_TC_BODY(traceme3, tc)
+{
+ const int sigval = SIGSTOP, sigsent = SIGINT /* Without core-dump */;
+ pid_t child, wpid;
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+
+ printf("Before forking process PID=%d\n", getpid());
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+ printf("Before raising %s from child\n", strsignal(sigval));
+ FORKEE_ASSERT(raise(sigval) == 0);
+
+ /* NOTREACHED */
+ FORKEE_ASSERTX(0 &&
+ "Child should be terminated by a signal from its parent");
+ }
+ printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, sigval);
+
+ printf("Before resuming the child process where it left off and with "
+ "signal %s to be sent\n", strsignal(sigsent));
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, sigsent) != -1);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_signaled(status, sigsent, 0);
+
+ printf("Before calling %s() for the exited child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+
+ATF_TC(traceme4);
+ATF_TC_HEAD(traceme4, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify SIGSTOP followed by SIGCONT and _exit(2) in a child");
+}
+
+ATF_TC_BODY(traceme4, tc)
+{
+ const int exitval = 5;
+ const int sigval = SIGSTOP, sigsent = SIGCONT;
+ pid_t child, wpid;
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+
+ printf("Before forking process PID=%d\n", getpid());
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+ printf("Before raising %s from child\n", strsignal(sigval));
+ FORKEE_ASSERT(raise(sigval) == 0);
+
+ printf("Before raising %s from child\n", strsignal(sigsent));
+ FORKEE_ASSERT(raise(sigsent) == 0);
+
+ printf("Before exiting of the child process\n");
+ _exit(exitval);
+ }
+ printf("Parent process PID=%d, child's PID=%d\n", getpid(),child);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, sigval);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, sigsent);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_exited(status, exitval);
+
+ printf("Before calling %s() for the exited child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+
+#if defined(TWAIT_HAVE_PID)
+ATF_TC(attach1);
+ATF_TC_HEAD(attach1, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Assert that tracer sees process termination before the parent");
+}
+
+ATF_TC_BODY(attach1, tc)
+{
+ struct msg_fds parent_tracee, parent_tracer;
+ const int exitval_tracee = 5;
+ const int exitval_tracer = 10;
+ pid_t tracee, tracer, wpid;
+ uint8_t msg = 0xde; /* dummy message for IPC based on pipe(2) */
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+
+ printf("Spawn tracee\n");
+ ATF_REQUIRE(msg_open(&parent_tracee) == 0);
+ tracee = atf_utils_fork();
+ if (tracee == 0) {
+ // Wait for parent to let us exit
+ CHILD_FROM_PARENT("exit tracee", parent_tracee, msg);
+ _exit(exitval_tracee);
+ }
+
+ printf("Spawn debugger\n");
+ ATF_REQUIRE(msg_open(&parent_tracer) == 0);
+ tracer = atf_utils_fork();
+ if (tracer == 0) {
+ printf("Before calling PT_ATTACH from tracee %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_ATTACH, tracee, NULL, 0) != -1);
+
+ /* Wait for tracee and assert that it was stopped w/ SIGSTOP */
+ FORKEE_REQUIRE_SUCCESS(
+ wpid = TWAIT_GENERIC(tracee, &status, 0), tracee);
+
+ forkee_status_stopped(status, SIGSTOP);
+
+ /* Resume tracee with PT_CONTINUE */
+ FORKEE_ASSERT(ptrace(PT_CONTINUE, tracee, (void *)1, 0) != -1);
+
+ /* Inform parent that tracer has attached to tracee */
+ CHILD_TO_PARENT("tracer ready", parent_tracer, msg);
+
+ /* Wait for parent to tell use that tracee should have exited */
+ CHILD_FROM_PARENT("wait for tracee exit", parent_tracer, msg);
+
+ /* Wait for tracee and assert that it exited */
+ FORKEE_REQUIRE_SUCCESS(
+ wpid = TWAIT_GENERIC(tracee, &status, 0), tracee);
+
+ forkee_status_exited(status, exitval_tracee);
+ printf("Tracee %d exited with %d\n", tracee, exitval_tracee);
+
+ printf("Before exiting of the tracer process\n");
+ _exit(exitval_tracer);
+ }
+
+ printf("Wait for the tracer to attach to the tracee\n");
+ PARENT_FROM_CHILD("tracer ready", parent_tracer, msg);
+
+ printf("Resume the tracee and let it exit\n");
+ PARENT_TO_CHILD("exit tracee", parent_tracee, msg);
+
+ printf("Detect that tracee is zombie\n");
+ await_zombie(tracee);
+
+
+ printf("Assert that there is no status about tracee %d - "
+ "Tracer must detect zombie first - calling %s()\n", tracee,
+ TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(
+ wpid = TWAIT_GENERIC(tracee, &status, WNOHANG), 0);
+
+ printf("Tell the tracer child should have exited\n");
+ PARENT_TO_CHILD("wait for tracee exit", parent_tracer, msg);
+ printf("Wait for tracer to finish its job and exit - calling %s()\n",
+ TWAIT_FNAME);
+
+ printf("Wait from tracer child to complete waiting for tracee\n");
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(tracer, &status, 0),
+ tracer);
+
+ validate_status_exited(status, exitval_tracer);
+
+ printf("Wait for tracee to finish its job and exit - calling %s()\n",
+ TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(tracee, &status, WNOHANG),
+ tracee);
+
+ validate_status_exited(status, exitval_tracee);
+
+ msg_close(&parent_tracer);
+ msg_close(&parent_tracee);
+}
+#endif
+
+#if defined(TWAIT_HAVE_PID)
+ATF_TC(attach2);
+ATF_TC_HEAD(attach2, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Assert that any tracer sees process termination before its "
+ "parent");
+}
+
+ATF_TC_BODY(attach2, tc)
+{
+ struct msg_fds parent_tracer, parent_tracee;
+ const int exitval_tracee = 5;
+ const int exitval_tracer1 = 10, exitval_tracer2 = 20;
+ pid_t tracee, tracer, wpid;
+ uint8_t msg = 0xde; /* dummy message for IPC based on pipe(2) */
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+
+ printf("Spawn tracee\n");
+ ATF_REQUIRE(msg_open(&parent_tracee) == 0);
+ tracee = atf_utils_fork();
+ if (tracee == 0) {
+ /* Wait for message from the parent */
+ CHILD_FROM_PARENT("Message 1", parent_tracee, msg);
+ _exit(exitval_tracee);
+ }
+
+ printf("Spawn debugger\n");
+ ATF_REQUIRE(msg_open(&parent_tracer) == 0);
+ tracer = atf_utils_fork();
+ if (tracer == 0) {
+ /* Fork again and drop parent to reattach to PID 1 */
+ tracer = atf_utils_fork();
+ if (tracer != 0)
+ _exit(exitval_tracer1);
+
+ printf("Before calling PT_ATTACH from tracee %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_ATTACH, tracee, NULL, 0) != -1);
+
+ /* Wait for tracee and assert that it was stopped w/ SIGSTOP */
+ FORKEE_REQUIRE_SUCCESS(
+ wpid = TWAIT_GENERIC(tracee, &status, 0), tracee);
+
+ forkee_status_stopped(status, SIGSTOP);
+
+ /* Resume tracee with PT_CONTINUE */
+ FORKEE_ASSERT(ptrace(PT_CONTINUE, tracee, (void *)1, 0) != -1);
+
+ /* Inform parent that tracer has attached to tracee */
+ CHILD_TO_PARENT("Message 1", parent_tracer, msg);
+ CHILD_FROM_PARENT("Message 2", parent_tracer, msg);
+
+ /* Wait for tracee and assert that it exited */
+ FORKEE_REQUIRE_SUCCESS(
+ wpid = TWAIT_GENERIC(tracee, &status, 0), tracee);
+
+ forkee_status_exited(status, exitval_tracee);
+
+ printf("Before exiting of the tracer process\n");
+ _exit(exitval_tracer2);
+ }
+ printf("Wait for the tracer process (direct child) to exit calling "
+ "%s()\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(
+ wpid = TWAIT_GENERIC(tracer, &status, 0), tracer);
+
+ validate_status_exited(status, exitval_tracer1);
+
+ printf("Wait for the non-exited tracee process with %s()\n",
+ TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(
+ wpid = TWAIT_GENERIC(tracee, NULL, WNOHANG), 0);
+
+ printf("Wait for the tracer to attach to the tracee\n");
+ PARENT_FROM_CHILD("Message 1", parent_tracer, msg);
+ printf("Resume the tracee and let it exit\n");
+ PARENT_TO_CHILD("Message 1", parent_tracee, msg);
+
+ printf("Detect that tracee is zombie\n");
+ await_zombie(tracee);
+
+ printf("Assert that there is no status about tracee - "
+ "Tracer must detect zombie first - calling %s()\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(
+ wpid = TWAIT_GENERIC(tracee, &status, WNOHANG), 0);
+
+ printf("Resume the tracer and let it detect exited tracee\n");
+ PARENT_TO_CHILD("Message 2", parent_tracer, msg);
+
+ printf("Wait for tracee to finish its job and exit - calling %s()\n",
+ TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(tracee, &status, WNOHANG),
+ tracee);
+
+ validate_status_exited(status, exitval_tracee);
+
+ msg_close(&parent_tracer);
+ msg_close(&parent_tracee);
+
+}
+#endif
+
+ATF_TC(attach3);
+ATF_TC_HEAD(attach3, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Assert that tracer parent can PT_ATTACH to its child");
+}
+
+ATF_TC_BODY(attach3, tc)
+{
+ struct msg_fds parent_tracee;
+ const int exitval_tracee = 5;
+ pid_t tracee, wpid;
+ uint8_t msg = 0xde; /* dummy message for IPC based on pipe(2) */
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+
+ printf("Spawn tracee\n");
+ ATF_REQUIRE(msg_open(&parent_tracee) == 0);
+ tracee = atf_utils_fork();
+ if (tracee == 0) {
+ CHILD_FROM_PARENT("Message 1", parent_tracee, msg);
+ printf("Parent should now attach to tracee\n");
+
+ CHILD_FROM_PARENT("Message 2", parent_tracee, msg);
+ /* Wait for message from the parent */
+ _exit(exitval_tracee);
+ }
+ PARENT_TO_CHILD("Message 1", parent_tracee, msg);
+
+ printf("Before calling PT_ATTACH for tracee %d\n", tracee);
+ ATF_REQUIRE(ptrace(PT_ATTACH, tracee, NULL, 0) != -1);
+
+ printf("Wait for the stopped tracee process with %s()\n",
+ TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(
+ wpid = TWAIT_GENERIC(tracee, &status, 0), tracee);
+
+ validate_status_stopped(status, SIGSTOP);
+
+ printf("Resume tracee with PT_CONTINUE\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, tracee, (void *)1, 0) != -1);
+
+ printf("Let the tracee exit now\n");
+ PARENT_TO_CHILD("Message 2", parent_tracee, msg);
+
+ printf("Wait for tracee to exit with %s()\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(
+ wpid = TWAIT_GENERIC(tracee, &status, 0), tracee);
+
+ validate_status_exited(status, exitval_tracee);
+
+ printf("Before calling %s() for tracee\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD,
+ wpid = TWAIT_GENERIC(tracee, &status, 0));
+
+ msg_close(&parent_tracee);
+}
+
+ATF_TC(attach4);
+ATF_TC_HEAD(attach4, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Assert that tracer child can PT_ATTACH to its parent");
+}
+
+ATF_TC_BODY(attach4, tc)
+{
+ struct msg_fds parent_tracee;
+ const int exitval_tracer = 5;
+ pid_t tracer, wpid;
+ uint8_t msg = 0xde; /* dummy message for IPC based on pipe(2) */
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+
+ printf("Spawn tracer\n");
+ ATF_REQUIRE(msg_open(&parent_tracee) == 0);
+ tracer = atf_utils_fork();
+ if (tracer == 0) {
+
+ /* Wait for message from the parent */
+ CHILD_FROM_PARENT("Message 1", parent_tracee, msg);
+
+ printf("Attach to parent PID %d with PT_ATTACH from child\n",
+ getppid());
+ FORKEE_ASSERT(ptrace(PT_ATTACH, getppid(), NULL, 0) != -1);
+
+ printf("Wait for the stopped parent process with %s()\n",
+ TWAIT_FNAME);
+ FORKEE_REQUIRE_SUCCESS(
+ wpid = TWAIT_GENERIC(getppid(), &status, 0), getppid());
+
+ forkee_status_stopped(status, SIGSTOP);
+
+ printf("Resume parent with PT_DETACH\n");
+ FORKEE_ASSERT(ptrace(PT_DETACH, getppid(), (void *)1, 0)
+ != -1);
+
+ /* Tell parent we are ready */
+ CHILD_TO_PARENT("Message 1", parent_tracee, msg);
+
+ _exit(exitval_tracer);
+ }
+
+ printf("Wait for the tracer to become ready\n");
+ PARENT_TO_CHILD("Message 1", parent_tracee, msg);
+ printf("Allow the tracer to exit now\n");
+ PARENT_FROM_CHILD("Message 1", parent_tracee, msg);
+
+ printf("Wait for tracer to exit with %s()\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(
+ wpid = TWAIT_GENERIC(tracer, &status, 0), tracer);
+
+ validate_status_exited(status, exitval_tracer);
+
+ printf("Before calling %s() for tracer\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD,
+ wpid = TWAIT_GENERIC(tracer, &status, 0));
+
+ msg_close(&parent_tracee);
+}
+
+#if defined(TWAIT_HAVE_PID)
+ATF_TC(attach5);
+ATF_TC_HEAD(attach5, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Assert that tracer sees its parent when attached to tracer "
+ "(check getppid(2))");
+}
+
+ATF_TC_BODY(attach5, tc)
+{
+ struct msg_fds parent_tracer, parent_tracee;
+ const int exitval_tracee = 5;
+ const int exitval_tracer = 10;
+ pid_t parent, tracee, tracer, wpid;
+ uint8_t msg = 0xde; /* dummy message for IPC based on pipe(2) */
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+
+ printf("Spawn tracee\n");
+ ATF_REQUIRE(msg_open(&parent_tracer) == 0);
+ ATF_REQUIRE(msg_open(&parent_tracee) == 0);
+ tracee = atf_utils_fork();
+ if (tracee == 0) {
+ parent = getppid();
+
+ /* Emit message to the parent */
+ CHILD_TO_PARENT("tracee ready", parent_tracee, msg);
+ CHILD_FROM_PARENT("exit tracee", parent_tracee, msg);
+
+ FORKEE_ASSERT_EQ(parent, getppid());
+
+ _exit(exitval_tracee);
+ }
+ printf("Wait for child to record its parent identifier (pid)\n");
+ PARENT_FROM_CHILD("tracee ready", parent_tracee, msg);
+
+ printf("Spawn debugger\n");
+ tracer = atf_utils_fork();
+ if (tracer == 0) {
+ /* No IPC to communicate with the child */
+ printf("Before calling PT_ATTACH from tracee %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_ATTACH, tracee, NULL, 0) != -1);
+
+ /* Wait for tracee and assert that it was stopped w/ SIGSTOP */
+ FORKEE_REQUIRE_SUCCESS(
+ wpid = TWAIT_GENERIC(tracee, &status, 0), tracee);
+
+ forkee_status_stopped(status, SIGSTOP);
+
+ /* Resume tracee with PT_CONTINUE */
+ FORKEE_ASSERT(ptrace(PT_CONTINUE, tracee, (void *)1, 0) != -1);
+
+ /* Inform parent that tracer has attached to tracee */
+ CHILD_TO_PARENT("tracer ready", parent_tracer, msg);
+
+ /* Wait for parent to tell use that tracee should have exited */
+ CHILD_FROM_PARENT("wait for tracee exit", parent_tracer, msg);
+
+ /* Wait for tracee and assert that it exited */
+ FORKEE_REQUIRE_SUCCESS(
+ wpid = TWAIT_GENERIC(tracee, &status, 0), tracee);
+
+ forkee_status_exited(status, exitval_tracee);
+
+ printf("Before exiting of the tracer process\n");
+ _exit(exitval_tracer);
+ }
+
+ printf("Wait for the tracer to attach to the tracee\n");
+ PARENT_FROM_CHILD("tracer ready", parent_tracer, msg);
+
+ printf("Resume the tracee and let it exit\n");
+ PARENT_TO_CHILD("exit tracee", parent_tracee, msg);
+
+ printf("Detect that tracee is zombie\n");
+ await_zombie(tracee);
+
+ printf("Assert that there is no status about tracee - "
+ "Tracer must detect zombie first - calling %s()\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(
+ wpid = TWAIT_GENERIC(tracee, &status, WNOHANG), 0);
+
+ printf("Tell the tracer child should have exited\n");
+ PARENT_TO_CHILD("wait for tracee exit", parent_tracer, msg);
+
+ printf("Wait from tracer child to complete waiting for tracee\n");
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(tracer, &status, 0),
+ tracer);
+
+ validate_status_exited(status, exitval_tracer);
+
+ printf("Wait for tracee to finish its job and exit - calling %s()\n",
+ TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(tracee, &status, WNOHANG),
+ tracee);
+
+ validate_status_exited(status, exitval_tracee);
+
+ msg_close(&parent_tracer);
+ msg_close(&parent_tracee);
+}
+#endif
+
+#if defined(TWAIT_HAVE_PID)
+ATF_TC(attach6);
+ATF_TC_HEAD(attach6, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Assert that tracer sees its parent when attached to tracer "
+ "(check sysctl(7) and struct kinfo_proc2)");
+}
+
+ATF_TC_BODY(attach6, tc)
+{
+ struct msg_fds parent_tracee, parent_tracer;
+ const int exitval_tracee = 5;
+ const int exitval_tracer = 10;
+ pid_t parent, tracee, tracer, wpid;
+ uint8_t msg = 0xde; /* dummy message for IPC based on pipe(2) */
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+ int name[CTL_MAXNAME];
+ struct kinfo_proc2 kp;
+ size_t len = sizeof(kp);
+ unsigned int namelen;
+
+ printf("Spawn tracee\n");
+ ATF_REQUIRE(msg_open(&parent_tracee) == 0);
+ ATF_REQUIRE(msg_open(&parent_tracer) == 0);
+ tracee = atf_utils_fork();
+ if (tracee == 0) {
+ parent = getppid();
+
+ /* Emit message to the parent */
+ CHILD_TO_PARENT("Message 1", parent_tracee, msg);
+ CHILD_FROM_PARENT("Message 2", parent_tracee, msg);
+
+ namelen = 0;
+ name[namelen++] = CTL_KERN;
+ name[namelen++] = KERN_PROC2;
+ name[namelen++] = KERN_PROC_PID;
+ name[namelen++] = getpid();
+ name[namelen++] = len;
+ name[namelen++] = 1;
+
+ FORKEE_ASSERT(sysctl(name, namelen, &kp, &len, NULL, 0) == 0);
+ FORKEE_ASSERT_EQ(parent, kp.p_ppid);
+
+ _exit(exitval_tracee);
+ }
+
+ printf("Wait for child to record its parent identifier (pid)\n");
+ PARENT_FROM_CHILD("Message 1", parent_tracee, msg);
+
+ printf("Spawn debugger\n");
+ tracer = atf_utils_fork();
+ if (tracer == 0) {
+ /* No IPC to communicate with the child */
+ printf("Before calling PT_ATTACH from tracee %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_ATTACH, tracee, NULL, 0) != -1);
+
+ /* Wait for tracee and assert that it was stopped w/ SIGSTOP */
+ FORKEE_REQUIRE_SUCCESS(
+ wpid = TWAIT_GENERIC(tracee, &status, 0), tracee);
+
+ forkee_status_stopped(status, SIGSTOP);
+
+ /* Resume tracee with PT_CONTINUE */
+ FORKEE_ASSERT(ptrace(PT_CONTINUE, tracee, (void *)1, 0) != -1);
+
+ /* Inform parent that tracer has attached to tracee */
+ CHILD_TO_PARENT("Message 1", parent_tracer, msg);
+
+ CHILD_FROM_PARENT("Message 2", parent_tracer, msg);
+
+ /* Wait for tracee and assert that it exited */
+ FORKEE_REQUIRE_SUCCESS(
+ wpid = TWAIT_GENERIC(tracee, &status, 0), tracee);
+
+ forkee_status_exited(status, exitval_tracee);
+
+ printf("Before exiting of the tracer process\n");
+ _exit(exitval_tracer);
+ }
+
+ printf("Wait for the tracer to attach to the tracee\n");
+ PARENT_FROM_CHILD("Message 1", parent_tracer, msg);
+
+ printf("Resume the tracee and let it exit\n");
+ PARENT_TO_CHILD("Message 1", parent_tracee, msg);
+
+ printf("Detect that tracee is zombie\n");
+ await_zombie(tracee);
+
+ printf("Assert that there is no status about tracee - "
+ "Tracer must detect zombie first - calling %s()\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(
+ wpid = TWAIT_GENERIC(tracee, &status, WNOHANG), 0);
+
+ printf("Resume the tracer and let it detect exited tracee\n");
+ PARENT_TO_CHILD("Message 2", parent_tracer, msg);
+
+ printf("Wait for tracer to finish its job and exit - calling %s()\n",
+ TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(tracer, &status, 0),
+ tracer);
+
+ validate_status_exited(status, exitval_tracer);
+
+ printf("Wait for tracee to finish its job and exit - calling %s()\n",
+ TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(tracee, &status, WNOHANG),
+ tracee);
+
+ validate_status_exited(status, exitval_tracee);
+
+ msg_close(&parent_tracee);
+ msg_close(&parent_tracer);
+}
+#endif
+
+#if defined(TWAIT_HAVE_PID)
+ATF_TC(attach7);
+ATF_TC_HEAD(attach7, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Assert that tracer sees its parent when attached to tracer "
+ "(check /proc/curproc/status 3rd column)");
+}
+
+ATF_TC_BODY(attach7, tc)
+{
+ struct msg_fds parent_tracee, parent_tracer;
+ int rv;
+ const int exitval_tracee = 5;
+ const int exitval_tracer = 10;
+ pid_t parent, tracee, tracer, wpid;
+ uint8_t msg = 0xde; /* dummy message for IPC based on pipe(2) */
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+ FILE *fp;
+ struct stat st;
+ const char *fname = "/proc/curproc/status";
+ char s_executable[MAXPATHLEN];
+ int s_pid, s_ppid;
+ /*
+ * Format:
+ * EXECUTABLE PID PPID ...
+ */
+
+ ATF_REQUIRE((rv = stat(fname, &st)) == 0 || (errno == ENOENT));
+ if (rv != 0) {
+ atf_tc_skip("/proc/curproc/status not found");
+ }
+
+ printf("Spawn tracee\n");
+ ATF_REQUIRE(msg_open(&parent_tracee) == 0);
+ ATF_REQUIRE(msg_open(&parent_tracer) == 0);
+ tracee = atf_utils_fork();
+ if (tracee == 0) {
+ parent = getppid();
+
+ // Wait for parent to let us exit
+ CHILD_TO_PARENT("tracee ready", parent_tracee, msg);
+ CHILD_FROM_PARENT("tracee exit", parent_tracee, msg);
+
+ FORKEE_ASSERT((fp = fopen(fname, "r")) != NULL);
+ fscanf(fp, "%s %d %d", s_executable, &s_pid, &s_ppid);
+ FORKEE_ASSERT(fclose(fp) == 0);
+ FORKEE_ASSERT_EQ(parent, s_ppid);
+
+ _exit(exitval_tracee);
+ }
+
+ printf("Wait for child to record its parent identifier (pid)\n");
+ PARENT_FROM_CHILD("tracee ready", parent_tracee, msg);
+
+ printf("Spawn debugger\n");
+ tracer = atf_utils_fork();
+ if (tracer == 0) {
+ printf("Before calling PT_ATTACH from tracee %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_ATTACH, tracee, NULL, 0) != -1);
+
+ /* Wait for tracee and assert that it was stopped w/ SIGSTOP */
+ FORKEE_REQUIRE_SUCCESS(
+ wpid = TWAIT_GENERIC(tracee, &status, 0), tracee);
+
+ forkee_status_stopped(status, SIGSTOP);
+
+ /* Resume tracee with PT_CONTINUE */
+ FORKEE_ASSERT(ptrace(PT_CONTINUE, tracee, (void *)1, 0) != -1);
+
+ /* Inform parent that tracer has attached to tracee */
+ CHILD_TO_PARENT("tracer ready", parent_tracer, msg);
+
+ /* Wait for parent to tell use that tracee should have exited */
+ CHILD_FROM_PARENT("wait for tracee exit", parent_tracer, msg);
+
+ /* Wait for tracee and assert that it exited */
+ FORKEE_REQUIRE_SUCCESS(
+ wpid = TWAIT_GENERIC(tracee, &status, 0), tracee);
+
+ forkee_status_exited(status, exitval_tracee);
+
+ printf("Before exiting of the tracer process\n");
+ _exit(exitval_tracer);
+ }
+ printf("Wait for the tracer to attach to the tracee\n");
+ PARENT_FROM_CHILD("tracer ready", parent_tracer, msg);
+ printf("Resume the tracee and let it exit\n");
+ PARENT_TO_CHILD("tracee exit", parent_tracee, msg);
+
+ printf("Detect that tracee is zombie\n");
+ await_zombie(tracee);
+
+ printf("Assert that there is no status about tracee - "
+ "Tracer must detect zombie first - calling %s()\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(
+ wpid = TWAIT_GENERIC(tracee, &status, WNOHANG), 0);
+
+ printf("Resume the tracer and let it detect exited tracee\n");
+ PARENT_TO_CHILD("Message 2", parent_tracer, msg);
+
+ printf("Wait for tracer to finish its job and exit - calling %s()\n",
+ TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(tracer, &status, 0),
+ tracer);
+
+ validate_status_exited(status, exitval_tracer);
+
+ printf("Wait for tracee to finish its job and exit - calling %s()\n",
+ TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(tracee, &status, WNOHANG),
+ tracee);
+
+ validate_status_exited(status, exitval_tracee);
+
+ msg_close(&parent_tracee);
+ msg_close(&parent_tracer);
+}
+#endif
+
+ATF_TC(eventmask1);
+ATF_TC_HEAD(eventmask1, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify that empty EVENT_MASK is preserved");
+}
+
+ATF_TC_BODY(eventmask1, tc)
+{
+ const int exitval = 5;
+ const int sigval = SIGSTOP;
+ pid_t child, wpid;
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+ ptrace_event_t set_event, get_event;
+ const int len = sizeof(ptrace_event_t);
+
+ printf("Before forking process PID=%d\n", getpid());
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+ printf("Before raising %s from child\n", strsignal(sigval));
+ FORKEE_ASSERT(raise(sigval) == 0);
+
+ printf("Before exiting of the child process\n");
+ _exit(exitval);
+ }
+ printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, sigval);
+
+ set_event.pe_set_event = 0;
+ ATF_REQUIRE(ptrace(PT_SET_EVENT_MASK, child, &set_event, len) != -1);
+ ATF_REQUIRE(ptrace(PT_GET_EVENT_MASK, child, &get_event, len) != -1);
+ ATF_REQUIRE(memcmp(&set_event, &get_event, len) == 0);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_exited(status, exitval);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+
+ATF_TC(eventmask2);
+ATF_TC_HEAD(eventmask2, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify that PTRACE_FORK in EVENT_MASK is preserved");
+}
+
+ATF_TC_BODY(eventmask2, tc)
+{
+ const int exitval = 5;
+ const int sigval = SIGSTOP;
+ pid_t child, wpid;
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+ ptrace_event_t set_event, get_event;
+ const int len = sizeof(ptrace_event_t);
+
+ printf("Before forking process PID=%d\n", getpid());
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+ printf("Before raising %s from child\n", strsignal(sigval));
+ FORKEE_ASSERT(raise(sigval) == 0);
+
+ printf("Before exiting of the child process\n");
+ _exit(exitval);
+ }
+ printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, sigval);
+
+ set_event.pe_set_event = PTRACE_FORK;
+ ATF_REQUIRE(ptrace(PT_SET_EVENT_MASK, child, &set_event, len) != -1);
+ ATF_REQUIRE(ptrace(PT_GET_EVENT_MASK, child, &get_event, len) != -1);
+ ATF_REQUIRE(memcmp(&set_event, &get_event, len) == 0);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_exited(status, exitval);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+
+#if defined(TWAIT_HAVE_PID)
+ATF_TC(fork1);
+ATF_TC_HEAD(fork1, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify that fork(2) is intercepted by ptrace(2) with EVENT_MASK "
+ "set to PTRACE_FORK");
+}
+
+ATF_TC_BODY(fork1, tc)
+{
+ const int exitval = 5;
+ const int exitval2 = 15;
+ const int sigval = SIGSTOP;
+ pid_t child, child2, wpid;
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+ ptrace_state_t state;
+ const int slen = sizeof(state);
+ ptrace_event_t event;
+ const int elen = sizeof(event);
+
+ printf("Before forking process PID=%d\n", getpid());
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+ printf("Before raising %s from child\n", strsignal(sigval));
+ FORKEE_ASSERT(raise(sigval) == 0);
+
+ FORKEE_ASSERT((child2 = fork()) != 1);
+
+ if (child2 == 0)
+ _exit(exitval2);
+
+ FORKEE_REQUIRE_SUCCESS
+ (wpid = TWAIT_GENERIC(child2, &status, 0), child2);
+
+ forkee_status_exited(status, exitval2);
+
+ printf("Before exiting of the child process\n");
+ _exit(exitval);
+ }
+ printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, sigval);
+
+ printf("Enable PTRACE_FORK in EVENT_MASK for the child %d\n", child);
+ event.pe_set_event = PTRACE_FORK;
+ ATF_REQUIRE(ptrace(PT_SET_EVENT_MASK, child, &event, elen) != -1);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child %d\n", TWAIT_FNAME, child);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, SIGTRAP);
+
+ ATF_REQUIRE(ptrace(PT_GET_PROCESS_STATE, child, &state, slen) != -1);
+ ATF_REQUIRE_EQ(state.pe_report_event, PTRACE_FORK);
+
+ child2 = state.pe_other_pid;
+ printf("Reported PTRACE_FORK event with forkee %d\n", child2);
+
+ printf("Before calling %s() for the forkee %d of the child %d\n",
+ TWAIT_FNAME, child2, child);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child2, &status, 0),
+ child2);
+
+ validate_status_stopped(status, SIGTRAP);
+
+ ATF_REQUIRE(ptrace(PT_GET_PROCESS_STATE, child2, &state, slen) != -1);
+ ATF_REQUIRE_EQ(state.pe_report_event, PTRACE_FORK);
+ ATF_REQUIRE_EQ(state.pe_other_pid, child);
+
+ printf("Before resuming the forkee process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child2, (void *)1, 0) != -1);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the forkee - expected exited\n",
+ TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child2, &status, 0),
+ child2);
+
+ validate_status_exited(status, exitval2);
+
+ printf("Before calling %s() for the forkee - expected no process\n",
+ TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD,
+ wpid = TWAIT_GENERIC(child2, &status, 0));
+
+ printf("Before calling %s() for the child - expected stopped "
+ "SIGCHLD\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, SIGCHLD);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child - expected exited\n",
+ TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_exited(status, exitval);
+
+ printf("Before calling %s() for the child - expected no process\n",
+ TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+#endif
+
+ATF_TC(fork2);
+ATF_TC_HEAD(fork2, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify that fork(2) is not intercepted by ptrace(2) with empty "
+ "EVENT_MASK");
+}
+
+ATF_TC_BODY(fork2, tc)
+{
+ const int exitval = 5;
+ const int exitval2 = 15;
+ const int sigval = SIGSTOP;
+ pid_t child, child2, wpid;
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+ ptrace_event_t event;
+ const int elen = sizeof(event);
+
+ printf("Before forking process PID=%d\n", getpid());
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+ printf("Before raising %s from child\n", strsignal(sigval));
+ FORKEE_ASSERT(raise(sigval) == 0);
+
+ FORKEE_ASSERT((child2 = fork()) != 1);
+
+ if (child2 == 0)
+ _exit(exitval2);
+
+ FORKEE_REQUIRE_SUCCESS
+ (wpid = TWAIT_GENERIC(child2, &status, 0), child2);
+
+ forkee_status_exited(status, exitval2);
+
+ printf("Before exiting of the child process\n");
+ _exit(exitval);
+ }
+ printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, sigval);
+
+ printf("Set empty EVENT_MASK for the child %d\n", child);
+ event.pe_set_event = 0;
+ ATF_REQUIRE(ptrace(PT_SET_EVENT_MASK, child, &event, elen) != -1);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child - expected stopped "
+ "SIGCHLD\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, SIGCHLD);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child - expected exited\n",
+ TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_exited(status, exitval);
+
+ printf("Before calling %s() for the child - expected no process\n",
+ TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+
+#if defined(TWAIT_HAVE_PID)
+ATF_TC(vfork1);
+ATF_TC_HEAD(vfork1, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify that vfork(2) is intercepted by ptrace(2) with EVENT_MASK "
+ "set to PTRACE_VFORK");
+}
+
+ATF_TC_BODY(vfork1, tc)
+{
+ const int exitval = 5;
+ const int exitval2 = 15;
+ const int sigval = SIGSTOP;
+ pid_t child, child2, wpid;
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+ ptrace_state_t state;
+ const int slen = sizeof(state);
+ ptrace_event_t event;
+ const int elen = sizeof(event);
+
+ /*
+ * ptrace(2) command PT_SET_EVENT_MASK: option PTRACE_VFORK unsupported
+ */
+#ifndef PTRACE_VFORK
+#define PTRACE_VFORK 0
+#endif
+ atf_tc_expect_fail("PR kern/51630");
+
+ printf("Before forking process PID=%d\n", getpid());
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+ printf("Before raising %s from child\n", strsignal(sigval));
+ FORKEE_ASSERT(raise(sigval) == 0);
+
+ FORKEE_ASSERT((child2 = vfork()) != 1);
+
+ if (child2 == 0)
+ _exit(exitval2);
+
+ FORKEE_REQUIRE_SUCCESS
+ (wpid = TWAIT_GENERIC(child2, &status, 0), child2);
+
+ forkee_status_exited(status, exitval2);
+
+ printf("Before exiting of the child process\n");
+ _exit(exitval);
+ }
+ printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, sigval);
+
+ printf("Enable PTRACE_VFORK in EVENT_MASK for the child %d\n", child);
+ event.pe_set_event = PTRACE_VFORK;
+ ATF_REQUIRE(ptrace(PT_SET_EVENT_MASK, child, &event, elen) != -1);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child %d\n", TWAIT_FNAME, child);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, SIGTRAP);
+
+ ATF_REQUIRE(ptrace(PT_GET_PROCESS_STATE, child, &state, slen) != -1);
+ ATF_REQUIRE_EQ(state.pe_report_event, PTRACE_VFORK);
+
+ child2 = state.pe_other_pid;
+ printf("Reported PTRACE_VFORK event with forkee %d\n", child2);
+
+ printf("Before calling %s() for the forkee %d of the child %d\n",
+ TWAIT_FNAME, child2, child);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child2, &status, 0),
+ child2);
+
+ validate_status_stopped(status, SIGTRAP);
+
+ ATF_REQUIRE(ptrace(PT_GET_PROCESS_STATE, child2, &state, slen) != -1);
+ ATF_REQUIRE_EQ(state.pe_report_event, PTRACE_VFORK);
+ ATF_REQUIRE_EQ(state.pe_other_pid, child);
+
+ printf("Before resuming the forkee process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child2, (void *)1, 0) != -1);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the forkee - expected exited\n",
+ TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child2, &status, 0),
+ child2);
+
+ validate_status_exited(status, exitval2);
+
+ printf("Before calling %s() for the forkee - expected no process\n",
+ TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD,
+ wpid = TWAIT_GENERIC(child2, &status, 0));
+
+ printf("Before calling %s() for the child - expected stopped "
+ "SIGCHLD\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, SIGCHLD);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child - expected exited\n",
+ TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_exited(status, exitval);
+
+ printf("Before calling %s() for the child - expected no process\n",
+ TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+#endif
+
+ATF_TC(vfork2);
+ATF_TC_HEAD(vfork2, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify that vfork(2) is not intercepted by ptrace(2) with empty "
+ "EVENT_MASK");
+}
+
+ATF_TC_BODY(vfork2, tc)
+{
+ const int exitval = 5;
+ const int exitval2 = 15;
+ const int sigval = SIGSTOP;
+ pid_t child, child2, wpid;
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+ ptrace_event_t event;
+ const int elen = sizeof(event);
+
+ printf("Before forking process PID=%d\n", getpid());
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+ printf("Before raising %s from child\n", strsignal(sigval));
+ FORKEE_ASSERT(raise(sigval) == 0);
+
+ FORKEE_ASSERT((child2 = vfork()) != 1);
+
+ if (child2 == 0)
+ _exit(exitval2);
+
+ FORKEE_REQUIRE_SUCCESS
+ (wpid = TWAIT_GENERIC(child2, &status, 0), child2);
+
+ forkee_status_exited(status, exitval2);
+
+ printf("Before exiting of the child process\n");
+ _exit(exitval);
+ }
+ printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, sigval);
+
+ printf("Set empty EVENT_MASK for the child %d\n", child);
+ event.pe_set_event = 0;
+ ATF_REQUIRE(ptrace(PT_SET_EVENT_MASK, child, &event, elen) != -1);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child - expected stopped "
+ "SIGCHLD\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, SIGCHLD);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child - expected exited\n",
+ TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_exited(status, exitval);
+
+ printf("Before calling %s() for the child - expected no process\n",
+ TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+
+ATF_TC(io_read_d1);
+ATF_TC_HEAD(io_read_d1, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify PT_IO with PIOD_READ_D and len = sizeof(uint8_t)");
+}
+
+ATF_TC_BODY(io_read_d1, tc)
+{
+ const int exitval = 5;
+ const int sigval = SIGSTOP;
+ pid_t child, wpid;
+ uint8_t lookup_me = 0;
+ const uint8_t magic = 0xab;
+ struct ptrace_io_desc io = {
+ .piod_op = PIOD_READ_D,
+ .piod_offs = &lookup_me,
+ .piod_addr = &lookup_me,
+ .piod_len = sizeof(lookup_me)
+ };
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+
+ printf("Before forking process PID=%d\n", getpid());
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+ lookup_me = magic;
+
+ printf("Before raising %s from child\n", strsignal(sigval));
+ FORKEE_ASSERT(raise(sigval) == 0);
+
+ printf("Before exiting of the child process\n");
+ _exit(exitval);
+ }
+ printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, sigval);
+
+ printf("Read lookup_me from tracee (PID=%d) by tracer (PID=%d)\n",
+ child, getpid());
+ ATF_REQUIRE(ptrace(PT_IO, child, &io, 0) != -1);
+
+ ATF_REQUIRE_EQ_MSG(lookup_me, magic,
+ "got value %" PRIx8 " != expected %" PRIx8, lookup_me, magic);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_exited(status, exitval);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+
+ATF_TC(io_read_d2);
+ATF_TC_HEAD(io_read_d2, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify PT_IO with PIOD_READ_D and len = sizeof(uint16_t)");
+}
+
+ATF_TC_BODY(io_read_d2, tc)
+{
+ const int exitval = 5;
+ const int sigval = SIGSTOP;
+ pid_t child, wpid;
+ uint16_t lookup_me = 0;
+ const uint16_t magic = 0x1234;
+ struct ptrace_io_desc io = {
+ .piod_op = PIOD_READ_D,
+ .piod_offs = &lookup_me,
+ .piod_addr = &lookup_me,
+ .piod_len = sizeof(lookup_me)
+ };
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+
+ printf("Before forking process PID=%d\n", getpid());
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+ lookup_me = magic;
+
+ printf("Before raising %s from child\n", strsignal(sigval));
+ FORKEE_ASSERT(raise(sigval) == 0);
+
+ printf("Before exiting of the child process\n");
+ _exit(exitval);
+ }
+ printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, sigval);
+
+ printf("Read lookup_me from tracee (PID=%d) by tracer (PID=%d)\n",
+ child, getpid());
+ ATF_REQUIRE(ptrace(PT_IO, child, &io, 0) != -1);
+
+ ATF_REQUIRE_EQ_MSG(lookup_me, magic,
+ "got value %" PRIx16 " != expected %" PRIx16, lookup_me, magic);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_exited(status, exitval);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+
+ATF_TC(io_read_d3);
+ATF_TC_HEAD(io_read_d3, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify PT_IO with PIOD_READ_D and len = sizeof(uint32_t)");
+}
+
+ATF_TC_BODY(io_read_d3, tc)
+{
+ const int exitval = 5;
+ const int sigval = SIGSTOP;
+ pid_t child, wpid;
+ uint32_t lookup_me = 0;
+ const uint32_t magic = 0x1234abcd;
+ struct ptrace_io_desc io = {
+ .piod_op = PIOD_READ_D,
+ .piod_offs = &lookup_me,
+ .piod_addr = &lookup_me,
+ .piod_len = sizeof(lookup_me)
+ };
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+
+ printf("Before forking process PID=%d\n", getpid());
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+ lookup_me = magic;
+
+ printf("Before raising %s from child\n", strsignal(sigval));
+ FORKEE_ASSERT(raise(sigval) == 0);
+
+ printf("Before exiting of the child process\n");
+ _exit(exitval);
+ }
+ printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, sigval);
+
+ printf("Read lookup_me from tracee (PID=%d) by tracer (PID=%d)\n",
+ child, getpid());
+ ATF_REQUIRE(ptrace(PT_IO, child, &io, 0) != -1);
+
+ ATF_REQUIRE_EQ_MSG(lookup_me, magic,
+ "got value %" PRIx32 " != expected %" PRIx32, lookup_me, magic);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_exited(status, exitval);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+
+ATF_TC(io_read_d4);
+ATF_TC_HEAD(io_read_d4, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify PT_IO with PIOD_READ_D and len = sizeof(uint64_t)");
+}
+
+ATF_TC_BODY(io_read_d4, tc)
+{
+ const int exitval = 5;
+ const int sigval = SIGSTOP;
+ pid_t child, wpid;
+ uint64_t lookup_me = 0;
+ const uint64_t magic = 0x1234abcd9876dcfa;
+ struct ptrace_io_desc io = {
+ .piod_op = PIOD_READ_D,
+ .piod_offs = &lookup_me,
+ .piod_addr = &lookup_me,
+ .piod_len = sizeof(lookup_me)
+ };
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+
+ printf("Before forking process PID=%d\n", getpid());
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+ lookup_me = magic;
+
+ printf("Before raising %s from child\n", strsignal(sigval));
+ FORKEE_ASSERT(raise(sigval) == 0);
+
+ printf("Before exiting of the child process\n");
+ _exit(exitval);
+ }
+ printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, sigval);
+
+ printf("Read lookup_me from tracee (PID=%d) by tracer (PID=%d)\n",
+ child, getpid());
+ ATF_REQUIRE(ptrace(PT_IO, child, &io, 0) != -1);
+
+ ATF_REQUIRE_EQ_MSG(lookup_me, magic,
+ "got value %" PRIx64 " != expected %" PRIx64, lookup_me, magic);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_exited(status, exitval);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+
+ATF_TC(io_write_d1);
+ATF_TC_HEAD(io_write_d1, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify PT_IO with PIOD_WRITE_D and len = sizeof(uint8_t)");
+}
+
+ATF_TC_BODY(io_write_d1, tc)
+{
+ const int exitval = 5;
+ const int sigval = SIGSTOP;
+ pid_t child, wpid;
+ uint8_t lookup_me = 0;
+ const uint8_t magic = 0xab;
+ struct ptrace_io_desc io = {
+ .piod_op = PIOD_WRITE_D,
+ .piod_offs = &lookup_me,
+ .piod_addr = &lookup_me,
+ .piod_len = sizeof(lookup_me)
+ };
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+
+ printf("Before forking process PID=%d\n", getpid());
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+ printf("Before raising %s from child\n", strsignal(sigval));
+ FORKEE_ASSERT(raise(sigval) == 0);
+
+ FORKEE_ASSERT_EQ(lookup_me, magic);
+
+ printf("Before exiting of the child process\n");
+ _exit(exitval);
+ }
+ printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, sigval);
+
+ lookup_me = magic;
+
+ printf("Write new lookup_me to tracee (PID=%d) from tracer (PID=%d)\n",
+ child, getpid());
+ ATF_REQUIRE(ptrace(PT_IO, child, &io, 0) != -1);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_exited(status, exitval);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+
+ATF_TC(io_write_d2);
+ATF_TC_HEAD(io_write_d2, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify PT_IO with PIOD_WRITE_D and len = sizeof(uint16_t)");
+}
+
+ATF_TC_BODY(io_write_d2, tc)
+{
+ const int exitval = 5;
+ const int sigval = SIGSTOP;
+ pid_t child, wpid;
+ uint16_t lookup_me = 0;
+ const uint16_t magic = 0xab12;
+ struct ptrace_io_desc io = {
+ .piod_op = PIOD_WRITE_D,
+ .piod_offs = &lookup_me,
+ .piod_addr = &lookup_me,
+ .piod_len = sizeof(lookup_me)
+ };
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+
+ printf("Before forking process PID=%d\n", getpid());
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+ printf("Before raising %s from child\n", strsignal(sigval));
+ FORKEE_ASSERT(raise(sigval) == 0);
+
+ FORKEE_ASSERT_EQ(lookup_me, magic);
+
+ printf("Before exiting of the child process\n");
+ _exit(exitval);
+ }
+ printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, sigval);
+
+ lookup_me = magic;
+
+ printf("Write new lookup_me to tracee (PID=%d) from tracer (PID=%d)\n",
+ child, getpid());
+ ATF_REQUIRE(ptrace(PT_IO, child, &io, 0) != -1);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_exited(status, exitval);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+
+ATF_TC(io_write_d3);
+ATF_TC_HEAD(io_write_d3, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify PT_IO with PIOD_WRITE_D and len = sizeof(uint32_t)");
+}
+
+ATF_TC_BODY(io_write_d3, tc)
+{
+ const int exitval = 5;
+ const int sigval = SIGSTOP;
+ pid_t child, wpid;
+ uint32_t lookup_me = 0;
+ const uint32_t magic = 0xab127643;
+ struct ptrace_io_desc io = {
+ .piod_op = PIOD_WRITE_D,
+ .piod_offs = &lookup_me,
+ .piod_addr = &lookup_me,
+ .piod_len = sizeof(lookup_me)
+ };
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+
+ printf("Before forking process PID=%d\n", getpid());
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+ printf("Before raising %s from child\n", strsignal(sigval));
+ FORKEE_ASSERT(raise(sigval) == 0);
+
+ FORKEE_ASSERT_EQ(lookup_me, magic);
+
+ printf("Before exiting of the child process\n");
+ _exit(exitval);
+ }
+ printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, sigval);
+
+ lookup_me = magic;
+
+ printf("Write new lookup_me to tracee (PID=%d) from tracer (PID=%d)\n",
+ child, getpid());
+ ATF_REQUIRE(ptrace(PT_IO, child, &io, 0) != -1);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_exited(status, exitval);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+
+ATF_TC(io_write_d4);
+ATF_TC_HEAD(io_write_d4, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify PT_IO with PIOD_WRITE_D and len = sizeof(uint64_t)");
+}
+
+ATF_TC_BODY(io_write_d4, tc)
+{
+ const int exitval = 5;
+ const int sigval = SIGSTOP;
+ pid_t child, wpid;
+ uint64_t lookup_me = 0;
+ const uint64_t magic = 0xab12764376490123;
+ struct ptrace_io_desc io = {
+ .piod_op = PIOD_WRITE_D,
+ .piod_offs = &lookup_me,
+ .piod_addr = &lookup_me,
+ .piod_len = sizeof(lookup_me)
+ };
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+
+ printf("Before forking process PID=%d\n", getpid());
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+ printf("Before raising %s from child\n", strsignal(sigval));
+ FORKEE_ASSERT(raise(sigval) == 0);
+
+ FORKEE_ASSERT_EQ(lookup_me, magic);
+
+ printf("Before exiting of the child process\n");
+ _exit(exitval);
+ }
+ printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, sigval);
+
+ lookup_me = magic;
+
+ printf("Write new lookup_me to tracee (PID=%d) from tracer (PID=%d)\n",
+ child, getpid());
+ ATF_REQUIRE(ptrace(PT_IO, child, &io, 0) != -1);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_exited(status, exitval);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+
+ATF_TC(read_d1);
+ATF_TC_HEAD(read_d1, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify PT_READ_D called once");
+}
+
+ATF_TC_BODY(read_d1, tc)
+{
+ const int exitval = 5;
+ const int sigval = SIGSTOP;
+ pid_t child, wpid;
+ int lookup_me = 0;
+ const int magic = (int)random();
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+
+ printf("Before forking process PID=%d\n", getpid());
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+ lookup_me = magic;
+
+ printf("Before raising %s from child\n", strsignal(sigval));
+ FORKEE_ASSERT(raise(sigval) == 0);
+
+ printf("Before exiting of the child process\n");
+ _exit(exitval);
+ }
+ printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, sigval);
+
+ printf("Read new lookup_me from tracee (PID=%d) by tracer (PID=%d)\n",
+ child, getpid());
+ errno = 0;
+ lookup_me = ptrace(PT_READ_D, child, &lookup_me, 0);
+ ATF_REQUIRE_EQ(errno, 0);
+
+ ATF_REQUIRE_EQ_MSG(lookup_me, magic,
+ "got value %#x != expected %#x", lookup_me, magic);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_exited(status, exitval);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+
+ATF_TC(read_d2);
+ATF_TC_HEAD(read_d2, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify PT_READ_D called twice");
+}
+
+ATF_TC_BODY(read_d2, tc)
+{
+ const int exitval = 5;
+ const int sigval = SIGSTOP;
+ pid_t child, wpid;
+ int lookup_me1 = 0;
+ int lookup_me2 = 0;
+ const int magic1 = (int)random();
+ const int magic2 = (int)random();
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+
+ printf("Before forking process PID=%d\n", getpid());
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+ lookup_me1 = magic1;
+ lookup_me2 = magic2;
+
+ printf("Before raising %s from child\n", strsignal(sigval));
+ FORKEE_ASSERT(raise(sigval) == 0);
+
+ printf("Before exiting of the child process\n");
+ _exit(exitval);
+ }
+ printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, sigval);
+
+ printf("Read new lookup_me1 from tracee (PID=%d) by tracer (PID=%d)\n",
+ child, getpid());
+ errno = 0;
+ lookup_me1 = ptrace(PT_READ_D, child, &lookup_me1, 0);
+ ATF_REQUIRE_EQ(errno, 0);
+
+ ATF_REQUIRE_EQ_MSG(lookup_me1, magic1,
+ "got value %#x != expected %#x", lookup_me1, magic1);
+
+ printf("Read new lookup_me2 from tracee (PID=%d) by tracer (PID=%d)\n",
+ child, getpid());
+ errno = 0;
+ lookup_me2 = ptrace(PT_READ_D, child, &lookup_me2, 0);
+ ATF_REQUIRE_EQ(errno, 0);
+
+ ATF_REQUIRE_EQ_MSG(lookup_me2, magic2,
+ "got value %#x != expected %#x", lookup_me2, magic2);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_exited(status, exitval);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+
+ATF_TC(read_d3);
+ATF_TC_HEAD(read_d3, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify PT_READ_D called three times");
+}
+
+ATF_TC_BODY(read_d3, tc)
+{
+ const int exitval = 5;
+ const int sigval = SIGSTOP;
+ pid_t child, wpid;
+ int lookup_me1 = 0;
+ int lookup_me2 = 0;
+ int lookup_me3 = 0;
+ const int magic1 = (int)random();
+ const int magic2 = (int)random();
+ const int magic3 = (int)random();
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+
+ printf("Before forking process PID=%d\n", getpid());
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+ lookup_me1 = magic1;
+ lookup_me2 = magic2;
+ lookup_me3 = magic3;
+
+ printf("Before raising %s from child\n", strsignal(sigval));
+ FORKEE_ASSERT(raise(sigval) == 0);
+
+ printf("Before exiting of the child process\n");
+ _exit(exitval);
+ }
+ printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, sigval);
+
+ printf("Read new lookup_me1 from tracee (PID=%d) by tracer (PID=%d)\n",
+ child, getpid());
+ errno = 0;
+ lookup_me1 = ptrace(PT_READ_D, child, &lookup_me1, 0);
+ ATF_REQUIRE_EQ(errno, 0);
+
+ ATF_REQUIRE_EQ_MSG(lookup_me1, magic1,
+ "got value %#x != expected %#x", lookup_me1, magic1);
+
+ printf("Read new lookup_me2 from tracee (PID=%d) by tracer (PID=%d)\n",
+ child, getpid());
+ errno = 0;
+ lookup_me2 = ptrace(PT_READ_D, child, &lookup_me2, 0);
+ ATF_REQUIRE_EQ(errno, 0);
+
+ ATF_REQUIRE_EQ_MSG(lookup_me2, magic2,
+ "got value %#x != expected %#x", lookup_me2, magic2);
+
+ printf("Read new lookup_me3 from tracee (PID=%d) by tracer (PID=%d)\n",
+ child, getpid());
+ errno = 0;
+ lookup_me3 = ptrace(PT_READ_D, child, &lookup_me3, 0);
+ ATF_REQUIRE_EQ(errno, 0);
+
+ ATF_REQUIRE_EQ_MSG(lookup_me3, magic3,
+ "got value %#x != expected %#x", lookup_me3, magic3);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_exited(status, exitval);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+
+ATF_TC(read_d4);
+ATF_TC_HEAD(read_d4, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify PT_READ_D called four times");
+}
+
+ATF_TC_BODY(read_d4, tc)
+{
+ const int exitval = 5;
+ const int sigval = SIGSTOP;
+ pid_t child, wpid;
+ int lookup_me1 = 0;
+ int lookup_me2 = 0;
+ int lookup_me3 = 0;
+ int lookup_me4 = 0;
+ const int magic1 = (int)random();
+ const int magic2 = (int)random();
+ const int magic3 = (int)random();
+ const int magic4 = (int)random();
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+
+ printf("Before forking process PID=%d\n", getpid());
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+ lookup_me1 = magic1;
+ lookup_me2 = magic2;
+ lookup_me3 = magic3;
+ lookup_me4 = magic4;
+
+ printf("Before raising %s from child\n", strsignal(sigval));
+ FORKEE_ASSERT(raise(sigval) == 0);
+
+ printf("Before exiting of the child process\n");
+ _exit(exitval);
+ }
+ printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, sigval);
+
+ printf("Read new lookup_me1 from tracee (PID=%d) by tracer (PID=%d)\n",
+ child, getpid());
+ errno = 0;
+ lookup_me1 = ptrace(PT_READ_D, child, &lookup_me1, 0);
+ ATF_REQUIRE_EQ(errno, 0);
+
+ ATF_REQUIRE_EQ_MSG(lookup_me1, magic1,
+ "got value %#x != expected %#x", lookup_me1, magic1);
+
+ printf("Read new lookup_me2 from tracee (PID=%d) by tracer (PID=%d)\n",
+ child, getpid());
+ errno = 0;
+ lookup_me2 = ptrace(PT_READ_D, child, &lookup_me2, 0);
+ ATF_REQUIRE_EQ(errno, 0);
+
+ ATF_REQUIRE_EQ_MSG(lookup_me2, magic2,
+ "got value %#x != expected %#x", lookup_me2, magic2);
+
+ printf("Read new lookup_me3 from tracee (PID=%d) by tracer (PID=%d)\n",
+ child, getpid());
+ errno = 0;
+ lookup_me3 = ptrace(PT_READ_D, child, &lookup_me3, 0);
+ ATF_REQUIRE_EQ(errno, 0);
+
+ ATF_REQUIRE_EQ_MSG(lookup_me3, magic3,
+ "got value %#x != expected %#x", lookup_me3, magic3);
+
+ printf("Read new lookup_me4 from tracee (PID=%d) by tracer (PID=%d)\n",
+ child, getpid());
+ errno = 0;
+ lookup_me4 = ptrace(PT_READ_D, child, &lookup_me4, 0);
+ ATF_REQUIRE_EQ(errno, 0);
+
+ ATF_REQUIRE_EQ_MSG(lookup_me4, magic4,
+ "got value %#x != expected %#x", lookup_me4, magic4);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_exited(status, exitval);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+
+ATF_TC(write_d1);
+ATF_TC_HEAD(write_d1, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify PT_WRITE_D called once");
+}
+
+ATF_TC_BODY(write_d1, tc)
+{
+ const int exitval = 5;
+ const int sigval = SIGSTOP;
+ pid_t child, wpid;
+ int lookup_me = 0;
+ const int magic = (int)random();
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+
+ printf("Before forking process PID=%d\n", getpid());
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+ printf("Before raising %s from child\n", strsignal(sigval));
+ FORKEE_ASSERT(raise(sigval) == 0);
+
+ FORKEE_ASSERT_EQ(lookup_me, magic);
+
+ printf("Before exiting of the child process\n");
+ _exit(exitval);
+ }
+ printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, sigval);
+
+ printf("Write new lookup_me to tracee (PID=%d) from tracer (PID=%d)\n",
+ child, getpid());
+ ATF_REQUIRE(ptrace(PT_WRITE_D, child, &lookup_me, magic) != -1);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_exited(status, exitval);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+
+ATF_TC(write_d2);
+ATF_TC_HEAD(write_d2, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify PT_WRITE_D called twice");
+}
+
+ATF_TC_BODY(write_d2, tc)
+{
+ const int exitval = 5;
+ const int sigval = SIGSTOP;
+ pid_t child, wpid;
+ int lookup_me1 = 0;
+ int lookup_me2 = 0;
+ const int magic1 = (int)random();
+ const int magic2 = (int)random();
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+
+ printf("Before forking process PID=%d\n", getpid());
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+ printf("Before raising %s from child\n", strsignal(sigval));
+ FORKEE_ASSERT(raise(sigval) == 0);
+
+ FORKEE_ASSERT_EQ(lookup_me1, magic1);
+ FORKEE_ASSERT_EQ(lookup_me2, magic2);
+
+ printf("Before exiting of the child process\n");
+ _exit(exitval);
+ }
+ printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, sigval);
+
+ printf("Write new lookup_me1 to tracee (PID=%d) from tracer (PID=%d)\n",
+ child, getpid());
+ ATF_REQUIRE(ptrace(PT_WRITE_D, child, &lookup_me1, magic1) != -1);
+
+ printf("Write new lookup_me2 to tracee (PID=%d) from tracer (PID=%d)\n",
+ child, getpid());
+ ATF_REQUIRE(ptrace(PT_WRITE_D, child, &lookup_me2, magic2) != -1);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_exited(status, exitval);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+
+ATF_TC(write_d3);
+ATF_TC_HEAD(write_d3, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify PT_WRITE_D called three times");
+}
+
+ATF_TC_BODY(write_d3, tc)
+{
+ const int exitval = 5;
+ const int sigval = SIGSTOP;
+ pid_t child, wpid;
+ int lookup_me1 = 0;
+ int lookup_me2 = 0;
+ int lookup_me3 = 0;
+ const int magic1 = (int)random();
+ const int magic2 = (int)random();
+ const int magic3 = (int)random();
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+
+ printf("Before forking process PID=%d\n", getpid());
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+ printf("Before raising %s from child\n", strsignal(sigval));
+ FORKEE_ASSERT(raise(sigval) == 0);
+
+ FORKEE_ASSERT_EQ(lookup_me1, magic1);
+ FORKEE_ASSERT_EQ(lookup_me2, magic2);
+ FORKEE_ASSERT_EQ(lookup_me3, magic3);
+
+ printf("Before exiting of the child process\n");
+ _exit(exitval);
+ }
+ printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, sigval);
+
+ printf("Write new lookup_me1 to tracee (PID=%d) from tracer (PID=%d)\n",
+ child, getpid());
+ ATF_REQUIRE(ptrace(PT_WRITE_D, child, &lookup_me1, magic1) != -1);
+
+ printf("Write new lookup_me2 to tracee (PID=%d) from tracer (PID=%d)\n",
+ child, getpid());
+ ATF_REQUIRE(ptrace(PT_WRITE_D, child, &lookup_me2, magic2) != -1);
+
+ printf("Write new lookup_me3 to tracee (PID=%d) from tracer (PID=%d)\n",
+ child, getpid());
+ ATF_REQUIRE(ptrace(PT_WRITE_D, child, &lookup_me3, magic3) != -1);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_exited(status, exitval);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+
+ATF_TC(write_d4);
+ATF_TC_HEAD(write_d4, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify PT_WRITE_D called four times");
+}
+
+ATF_TC_BODY(write_d4, tc)
+{
+ const int exitval = 5;
+ const int sigval = SIGSTOP;
+ pid_t child, wpid;
+ int lookup_me1 = 0;
+ int lookup_me2 = 0;
+ int lookup_me3 = 0;
+ int lookup_me4 = 0;
+ const int magic1 = (int)random();
+ const int magic2 = (int)random();
+ const int magic3 = (int)random();
+ const int magic4 = (int)random();
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+
+ printf("Before forking process PID=%d\n", getpid());
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+ printf("Before raising %s from child\n", strsignal(sigval));
+ FORKEE_ASSERT(raise(sigval) == 0);
+
+ FORKEE_ASSERT_EQ(lookup_me1, magic1);
+ FORKEE_ASSERT_EQ(lookup_me2, magic2);
+ FORKEE_ASSERT_EQ(lookup_me3, magic3);
+ FORKEE_ASSERT_EQ(lookup_me4, magic4);
+
+ printf("Before exiting of the child process\n");
+ _exit(exitval);
+ }
+ printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, sigval);
+
+ printf("Write new lookup_me1 to tracee (PID=%d) from tracer (PID=%d)\n",
+ child, getpid());
+ ATF_REQUIRE(ptrace(PT_WRITE_D, child, &lookup_me1, magic1) != -1);
+
+ printf("Write new lookup_me2 to tracee (PID=%d) from tracer (PID=%d)\n",
+ child, getpid());
+ ATF_REQUIRE(ptrace(PT_WRITE_D, child, &lookup_me2, magic2) != -1);
+
+ printf("Write new lookup_me3 to tracee (PID=%d) from tracer (PID=%d)\n",
+ child, getpid());
+ ATF_REQUIRE(ptrace(PT_WRITE_D, child, &lookup_me3, magic3) != -1);
+
+ printf("Write new lookup_me4 to tracee (PID=%d) from tracer (PID=%d)\n",
+ child, getpid());
+ ATF_REQUIRE(ptrace(PT_WRITE_D, child, &lookup_me4, magic4) != -1);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_exited(status, exitval);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+
+ATF_TC(io_read_d_write_d_handshake1);
+ATF_TC_HEAD(io_read_d_write_d_handshake1, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify PT_IO with PIOD_READ_D and PIOD_WRITE_D handshake");
+}
+
+ATF_TC_BODY(io_read_d_write_d_handshake1, tc)
+{
+ const int exitval = 5;
+ const int sigval = SIGSTOP;
+ pid_t child, wpid;
+ uint8_t lookup_me_fromtracee = 0;
+ const uint8_t magic_fromtracee = (uint8_t)random();
+ uint8_t lookup_me_totracee = 0;
+ const uint8_t magic_totracee = (uint8_t)random();
+ struct ptrace_io_desc io_fromtracee = {
+ .piod_op = PIOD_READ_D,
+ .piod_offs = &lookup_me_fromtracee,
+ .piod_addr = &lookup_me_fromtracee,
+ .piod_len = sizeof(lookup_me_fromtracee)
+ };
+ struct ptrace_io_desc io_totracee = {
+ .piod_op = PIOD_WRITE_D,
+ .piod_offs = &lookup_me_totracee,
+ .piod_addr = &lookup_me_totracee,
+ .piod_len = sizeof(lookup_me_totracee)
+ };
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+
+ printf("Before forking process PID=%d\n", getpid());
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+ lookup_me_fromtracee = magic_fromtracee;
+
+ printf("Before raising %s from child\n", strsignal(sigval));
+ FORKEE_ASSERT(raise(sigval) == 0);
+
+ FORKEE_ASSERT_EQ(lookup_me_totracee, magic_totracee);
+
+ printf("Before exiting of the child process\n");
+ _exit(exitval);
+ }
+ printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, sigval);
+
+ printf("Read lookup_me_fromtracee PID=%d by tracer (PID=%d)\n",
+ child, getpid());
+ ATF_REQUIRE(ptrace(PT_IO, child, &io_fromtracee, 0) != -1);
+
+ ATF_REQUIRE_EQ_MSG(lookup_me_fromtracee, magic_fromtracee,
+ "got value %" PRIx8 " != expected %" PRIx8, lookup_me_fromtracee,
+ magic_fromtracee);
+
+ lookup_me_totracee = magic_totracee;
+
+ printf("Write lookup_me_totracee to PID=%d by tracer (PID=%d)\n",
+ child, getpid());
+ ATF_REQUIRE(ptrace(PT_IO, child, &io_totracee, 0) != -1);
+
+ ATF_REQUIRE_EQ_MSG(lookup_me_totracee, magic_totracee,
+ "got value %" PRIx8 " != expected %" PRIx8, lookup_me_totracee,
+ magic_totracee);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_exited(status, exitval);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+
+ATF_TC(io_read_d_write_d_handshake2);
+ATF_TC_HEAD(io_read_d_write_d_handshake2, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify PT_IO with PIOD_WRITE_D and PIOD_READ_D handshake");
+}
+
+ATF_TC_BODY(io_read_d_write_d_handshake2, tc)
+{
+ const int exitval = 5;
+ const int sigval = SIGSTOP;
+ pid_t child, wpid;
+ uint8_t lookup_me_fromtracee = 0;
+ const uint8_t magic_fromtracee = (uint8_t)random();
+ uint8_t lookup_me_totracee = 0;
+ const uint8_t magic_totracee = (uint8_t)random();
+ struct ptrace_io_desc io_fromtracee = {
+ .piod_op = PIOD_READ_D,
+ .piod_offs = &lookup_me_fromtracee,
+ .piod_addr = &lookup_me_fromtracee,
+ .piod_len = sizeof(lookup_me_fromtracee)
+ };
+ struct ptrace_io_desc io_totracee = {
+ .piod_op = PIOD_WRITE_D,
+ .piod_offs = &lookup_me_totracee,
+ .piod_addr = &lookup_me_totracee,
+ .piod_len = sizeof(lookup_me_totracee)
+ };
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+
+ printf("Before forking process PID=%d\n", getpid());
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+ lookup_me_fromtracee = magic_fromtracee;
+
+ printf("Before raising %s from child\n", strsignal(sigval));
+ FORKEE_ASSERT(raise(sigval) == 0);
+
+ FORKEE_ASSERT_EQ(lookup_me_totracee, magic_totracee);
+
+ printf("Before exiting of the child process\n");
+ _exit(exitval);
+ }
+ printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, sigval);
+
+ lookup_me_totracee = magic_totracee;
+
+ printf("Write lookup_me_totracee to PID=%d by tracer (PID=%d)\n",
+ child, getpid());
+ ATF_REQUIRE(ptrace(PT_IO, child, &io_totracee, 0) != -1);
+
+ ATF_REQUIRE_EQ_MSG(lookup_me_totracee, magic_totracee,
+ "got value %" PRIx8 " != expected %" PRIx8, lookup_me_totracee,
+ magic_totracee);
+
+ printf("Read lookup_me_fromtracee PID=%d by tracer (PID=%d)\n",
+ child, getpid());
+ ATF_REQUIRE(ptrace(PT_IO, child, &io_fromtracee, 0) != -1);
+
+ ATF_REQUIRE_EQ_MSG(lookup_me_fromtracee, magic_fromtracee,
+ "got value %" PRIx8 " != expected %" PRIx8, lookup_me_fromtracee,
+ magic_fromtracee);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_exited(status, exitval);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+
+ATF_TC(read_d_write_d_handshake1);
+ATF_TC_HEAD(read_d_write_d_handshake1, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify PT_READ_D with PT_WRITE_D handshake");
+}
+
+ATF_TC_BODY(read_d_write_d_handshake1, tc)
+{
+ const int exitval = 5;
+ const int sigval = SIGSTOP;
+ pid_t child, wpid;
+ int lookup_me_fromtracee = 0;
+ const int magic_fromtracee = (int)random();
+ int lookup_me_totracee = 0;
+ const int magic_totracee = (int)random();
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+
+ printf("Before forking process PID=%d\n", getpid());
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+ lookup_me_fromtracee = magic_fromtracee;
+
+ printf("Before raising %s from child\n", strsignal(sigval));
+ FORKEE_ASSERT(raise(sigval) == 0);
+
+ FORKEE_ASSERT_EQ(lookup_me_totracee, magic_totracee);
+
+ printf("Before exiting of the child process\n");
+ _exit(exitval);
+ }
+ printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, sigval);
+
+ printf("Read new lookup_me_fromtracee PID=%d by tracer (PID=%d)\n",
+ child, getpid());
+ errno = 0;
+ lookup_me_fromtracee =
+ ptrace(PT_READ_D, child, &lookup_me_fromtracee, 0);
+ ATF_REQUIRE_EQ(errno, 0);
+
+ ATF_REQUIRE_EQ_MSG(lookup_me_fromtracee, magic_fromtracee,
+ "got value %#x != expected %#x", lookup_me_fromtracee,
+ magic_fromtracee);
+
+ printf("Write new lookup_me_totracee to PID=%d from tracer (PID=%d)\n",
+ child, getpid());
+ ATF_REQUIRE
+ (ptrace(PT_WRITE_D, child, &lookup_me_totracee, magic_totracee)
+ != -1);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_exited(status, exitval);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+
+ATF_TC(read_d_write_d_handshake2);
+ATF_TC_HEAD(read_d_write_d_handshake2, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify PT_WRITE_D with PT_READ_D handshake");
+}
+
+ATF_TC_BODY(read_d_write_d_handshake2, tc)
+{
+ const int exitval = 5;
+ const int sigval = SIGSTOP;
+ pid_t child, wpid;
+ int lookup_me_fromtracee = 0;
+ const int magic_fromtracee = (int)random();
+ int lookup_me_totracee = 0;
+ const int magic_totracee = (int)random();
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+
+ printf("Before forking process PID=%d\n", getpid());
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+ lookup_me_fromtracee = magic_fromtracee;
+
+ printf("Before raising %s from child\n", strsignal(sigval));
+ FORKEE_ASSERT(raise(sigval) == 0);
+
+ FORKEE_ASSERT_EQ(lookup_me_totracee, magic_totracee);
+
+ printf("Before exiting of the child process\n");
+ _exit(exitval);
+ }
+ printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, sigval);
+
+ printf("Write new lookup_me_totracee to PID=%d from tracer (PID=%d)\n",
+ child, getpid());
+ ATF_REQUIRE
+ (ptrace(PT_WRITE_D, child, &lookup_me_totracee, magic_totracee)
+ != -1);
+
+ printf("Read new lookup_me_fromtracee PID=%d by tracer (PID=%d)\n",
+ child, getpid());
+ errno = 0;
+ lookup_me_fromtracee =
+ ptrace(PT_READ_D, child, &lookup_me_fromtracee, 0);
+ ATF_REQUIRE_EQ(errno, 0);
+
+ ATF_REQUIRE_EQ_MSG(lookup_me_fromtracee, magic_fromtracee,
+ "got value %#x != expected %#x", lookup_me_fromtracee,
+ magic_fromtracee);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_exited(status, exitval);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+
+/* These dummy functions are used to be copied with ptrace(2) calls */
+static int __used
+dummy_fn1(int a, int b, int c, int d)
+{
+
+ a *= 1;
+ b += 2;
+ c -= 3;
+ d /= 4;
+
+ return a + b * c - d;
+}
+
+static int __used
+dummy_fn2(int a, int b, int c, int d)
+{
+
+ a *= 4;
+ b += 3;
+ c -= 2;
+ d /= 1;
+
+ return a + b * c - d;
+}
+
+static int __used
+dummy_fn3(int a, int b, int c, int d)
+{
+
+ a *= 10;
+ b += 20;
+ c -= 30;
+ d /= 40;
+
+ return a + b * c - d;
+}
+
+static int __used
+dummy_fn4(int a, int b, int c, int d)
+{
+
+ a *= 40;
+ b += 30;
+ c -= 20;
+ d /= 10;
+
+ return a + b * c - d;
+}
+
+ATF_TC(io_read_i1);
+ATF_TC_HEAD(io_read_i1, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify PT_IO with PIOD_READ_I and len = sizeof(uint8_t)");
+}
+
+ATF_TC_BODY(io_read_i1, tc)
+{
+ const int exitval = 5;
+ const int sigval = SIGSTOP;
+ pid_t child, wpid;
+ uint8_t lookup_me = 0;
+ uint8_t magic;
+ memcpy(&magic, dummy_fn1, sizeof(magic));
+ struct ptrace_io_desc io = {
+ .piod_op = PIOD_READ_I,
+ .piod_offs = dummy_fn1,
+ .piod_addr = &lookup_me,
+ .piod_len = sizeof(lookup_me)
+ };
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+
+ printf("Before forking process PID=%d\n", getpid());
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+ printf("Before raising %s from child\n", strsignal(sigval));
+ FORKEE_ASSERT(raise(sigval) == 0);
+
+ printf("Before exiting of the child process\n");
+ _exit(exitval);
+ }
+ printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, sigval);
+
+ printf("Read lookup_me from tracee (PID=%d) by tracer (PID=%d)\n",
+ child, getpid());
+ ATF_REQUIRE(ptrace(PT_IO, child, &io, 0) != -1);
+
+ ATF_REQUIRE_EQ_MSG(lookup_me, magic,
+ "got value %" PRIx8 " != expected %" PRIx8, lookup_me, magic);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_exited(status, exitval);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+
+ATF_TC(io_read_i2);
+ATF_TC_HEAD(io_read_i2, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify PT_IO with PIOD_READ_I and len = sizeof(uint16_t)");
+}
+
+ATF_TC_BODY(io_read_i2, tc)
+{
+ const int exitval = 5;
+ const int sigval = SIGSTOP;
+ pid_t child, wpid;
+ uint16_t lookup_me = 0;
+ uint16_t magic;
+ memcpy(&magic, dummy_fn1, sizeof(magic));
+ struct ptrace_io_desc io = {
+ .piod_op = PIOD_READ_I,
+ .piod_offs = dummy_fn1,
+ .piod_addr = &lookup_me,
+ .piod_len = sizeof(lookup_me)
+ };
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+
+ printf("Before forking process PID=%d\n", getpid());
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+ printf("Before raising %s from child\n", strsignal(sigval));
+ FORKEE_ASSERT(raise(sigval) == 0);
+
+ printf("Before exiting of the child process\n");
+ _exit(exitval);
+ }
+ printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, sigval);
+
+ printf("Read lookup_me from tracee (PID=%d) by tracer (PID=%d)\n",
+ child, getpid());
+ ATF_REQUIRE(ptrace(PT_IO, child, &io, 0) != -1);
+
+ ATF_REQUIRE_EQ_MSG(lookup_me, magic,
+ "got value %" PRIx16 " != expected %" PRIx16, lookup_me, magic);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_exited(status, exitval);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+
+ATF_TC(io_read_i3);
+ATF_TC_HEAD(io_read_i3, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify PT_IO with PIOD_READ_I and len = sizeof(uint32_t)");
+}
+
+ATF_TC_BODY(io_read_i3, tc)
+{
+ const int exitval = 5;
+ const int sigval = SIGSTOP;
+ pid_t child, wpid;
+ uint32_t lookup_me = 0;
+ uint32_t magic;
+ memcpy(&magic, dummy_fn1, sizeof(magic));
+ struct ptrace_io_desc io = {
+ .piod_op = PIOD_READ_I,
+ .piod_offs = dummy_fn1,
+ .piod_addr = &lookup_me,
+ .piod_len = sizeof(lookup_me)
+ };
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+
+ printf("Before forking process PID=%d\n", getpid());
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+ printf("Before raising %s from child\n", strsignal(sigval));
+ FORKEE_ASSERT(raise(sigval) == 0);
+
+ printf("Before exiting of the child process\n");
+ _exit(exitval);
+ }
+ printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, sigval);
+
+ printf("Read lookup_me from tracee (PID=%d) by tracer (PID=%d)\n",
+ child, getpid());
+ ATF_REQUIRE(ptrace(PT_IO, child, &io, 0) != -1);
+
+ ATF_REQUIRE_EQ_MSG(lookup_me, magic,
+ "got value %" PRIx32 " != expected %" PRIx32, lookup_me, magic);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_exited(status, exitval);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+
+ATF_TC(io_read_i4);
+ATF_TC_HEAD(io_read_i4, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify PT_IO with PIOD_READ_I and len = sizeof(uint64_t)");
+}
+
+ATF_TC_BODY(io_read_i4, tc)
+{
+ const int exitval = 5;
+ const int sigval = SIGSTOP;
+ pid_t child, wpid;
+ uint64_t lookup_me = 0;
+ uint64_t magic;
+ memcpy(&magic, dummy_fn1, sizeof(magic));
+ struct ptrace_io_desc io = {
+ .piod_op = PIOD_READ_I,
+ .piod_offs = dummy_fn1,
+ .piod_addr = &lookup_me,
+ .piod_len = sizeof(lookup_me)
+ };
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+
+ printf("Before forking process PID=%d\n", getpid());
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+ printf("Before raising %s from child\n", strsignal(sigval));
+ FORKEE_ASSERT(raise(sigval) == 0);
+
+ printf("Before exiting of the child process\n");
+ _exit(exitval);
+ }
+ printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, sigval);
+
+ printf("Read lookup_me from tracee (PID=%d) by tracer (PID=%d)\n",
+ child, getpid());
+ ATF_REQUIRE(ptrace(PT_IO, child, &io, 0) != -1);
+
+ ATF_REQUIRE_EQ_MSG(lookup_me, magic,
+ "got value %" PRIx64 " != expected %" PRIx64, lookup_me, magic);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_exited(status, exitval);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+
+ATF_TC(read_i1);
+ATF_TC_HEAD(read_i1, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify PT_READ_I called once");
+}
+
+ATF_TC_BODY(read_i1, tc)
+{
+ const int exitval = 5;
+ const int sigval = SIGSTOP;
+ pid_t child, wpid;
+ int lookup_me = 0;
+ int magic;
+ memcpy(&magic, dummy_fn1, sizeof(magic));
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+
+ printf("Before forking process PID=%d\n", getpid());
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+ printf("Before raising %s from child\n", strsignal(sigval));
+ FORKEE_ASSERT(raise(sigval) == 0);
+
+ printf("Before exiting of the child process\n");
+ _exit(exitval);
+ }
+ printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, sigval);
+
+ printf("Read new lookup_me from tracee (PID=%d) by tracer (PID=%d)\n",
+ child, getpid());
+ errno = 0;
+ lookup_me = ptrace(PT_READ_I, child, dummy_fn1, 0);
+ ATF_REQUIRE_EQ(errno, 0);
+
+ ATF_REQUIRE_EQ_MSG(lookup_me, magic,
+ "got value %#x != expected %#x", lookup_me, magic);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_exited(status, exitval);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+
+ATF_TC(read_i2);
+ATF_TC_HEAD(read_i2, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify PT_READ_I called twice");
+}
+
+ATF_TC_BODY(read_i2, tc)
+{
+ const int exitval = 5;
+ const int sigval = SIGSTOP;
+ pid_t child, wpid;
+ int lookup_me1 = 0;
+ int lookup_me2 = 0;
+ int magic1;
+ int magic2;
+ memcpy(&magic1, dummy_fn1, sizeof(magic1));
+ memcpy(&magic2, dummy_fn2, sizeof(magic2));
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+
+ printf("Before forking process PID=%d\n", getpid());
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+ printf("Before raising %s from child\n", strsignal(sigval));
+ FORKEE_ASSERT(raise(sigval) == 0);
+
+ printf("Before exiting of the child process\n");
+ _exit(exitval);
+ }
+ printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, sigval);
+
+ printf("Read new lookup_me1 from tracee (PID=%d) by tracer (PID=%d)\n",
+ child, getpid());
+ errno = 0;
+ lookup_me1 = ptrace(PT_READ_I, child, dummy_fn1, 0);
+ ATF_REQUIRE_EQ(errno, 0);
+
+ ATF_REQUIRE_EQ_MSG(lookup_me1, magic1,
+ "got value %#x != expected %#x", lookup_me1, magic1);
+
+ printf("Read new lookup_me2 from tracee (PID=%d) by tracer (PID=%d)\n",
+ child, getpid());
+ errno = 0;
+ lookup_me2 = ptrace(PT_READ_I, child, dummy_fn2, 0);
+ ATF_REQUIRE_EQ(errno, 0);
+
+ ATF_REQUIRE_EQ_MSG(lookup_me2, magic2,
+ "got value %#x != expected %#x", lookup_me2, magic2);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_exited(status, exitval);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+
+ATF_TC(read_i3);
+ATF_TC_HEAD(read_i3, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify PT_READ_I called three times");
+}
+
+ATF_TC_BODY(read_i3, tc)
+{
+ const int exitval = 5;
+ const int sigval = SIGSTOP;
+ pid_t child, wpid;
+ int lookup_me1 = 0;
+ int lookup_me2 = 0;
+ int lookup_me3 = 0;
+ int magic1;
+ int magic2;
+ int magic3;
+ memcpy(&magic1, dummy_fn1, sizeof(magic1));
+ memcpy(&magic2, dummy_fn2, sizeof(magic2));
+ memcpy(&magic3, dummy_fn3, sizeof(magic3));
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+
+ printf("Before forking process PID=%d\n", getpid());
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+ printf("Before raising %s from child\n", strsignal(sigval));
+ FORKEE_ASSERT(raise(sigval) == 0);
+
+ printf("Before exiting of the child process\n");
+ _exit(exitval);
+ }
+ printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, sigval);
+
+ printf("Read new lookup_me1 from tracee (PID=%d) by tracer (PID=%d)\n",
+ child, getpid());
+ errno = 0;
+ lookup_me1 = ptrace(PT_READ_I, child, dummy_fn1, 0);
+ ATF_REQUIRE_EQ(errno, 0);
+
+ ATF_REQUIRE_EQ_MSG(lookup_me1, magic1,
+ "got value %#x != expected %#x", lookup_me1, magic1);
+
+ printf("Read new lookup_me2 from tracee (PID=%d) by tracer (PID=%d)\n",
+ child, getpid());
+ errno = 0;
+ lookup_me2 = ptrace(PT_READ_I, child, dummy_fn2, 0);
+ ATF_REQUIRE_EQ(errno, 0);
+
+ ATF_REQUIRE_EQ_MSG(lookup_me2, magic2,
+ "got value %#x != expected %#x", lookup_me2, magic2);
+
+ printf("Read new lookup_me3 from tracee (PID=%d) by tracer (PID=%d)\n",
+ child, getpid());
+ errno = 0;
+ lookup_me3 = ptrace(PT_READ_I, child, dummy_fn3, 0);
+ ATF_REQUIRE_EQ(errno, 0);
+
+ ATF_REQUIRE_EQ_MSG(lookup_me3, magic3,
+ "got value %#x != expected %#x", lookup_me3, magic3);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_exited(status, exitval);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+
+ATF_TC(read_i4);
+ATF_TC_HEAD(read_i4, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify PT_READ_I called four times");
+}
+
+ATF_TC_BODY(read_i4, tc)
+{
+ const int exitval = 5;
+ const int sigval = SIGSTOP;
+ pid_t child, wpid;
+ int lookup_me1 = 0;
+ int lookup_me2 = 0;
+ int lookup_me3 = 0;
+ int lookup_me4 = 0;
+ int magic1;
+ int magic2;
+ int magic3;
+ int magic4;
+ memcpy(&magic1, dummy_fn1, sizeof(magic1));
+ memcpy(&magic2, dummy_fn2, sizeof(magic2));
+ memcpy(&magic3, dummy_fn3, sizeof(magic3));
+ memcpy(&magic4, dummy_fn4, sizeof(magic4));
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+
+ printf("Before forking process PID=%d\n", getpid());
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+ printf("Before raising %s from child\n", strsignal(sigval));
+ FORKEE_ASSERT(raise(sigval) == 0);
+
+ printf("Before exiting of the child process\n");
+ _exit(exitval);
+ }
+ printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, sigval);
+
+ printf("Read new lookup_me1 from tracee (PID=%d) by tracer (PID=%d)\n",
+ child, getpid());
+ errno = 0;
+ lookup_me1 = ptrace(PT_READ_I, child, dummy_fn1, 0);
+ ATF_REQUIRE_EQ(errno, 0);
+
+ ATF_REQUIRE_EQ_MSG(lookup_me1, magic1,
+ "got value %#x != expected %#x", lookup_me1, magic1);
+
+ printf("Read new lookup_me2 from tracee (PID=%d) by tracer (PID=%d)\n",
+ child, getpid());
+ errno = 0;
+ lookup_me2 = ptrace(PT_READ_I, child, dummy_fn2, 0);
+ ATF_REQUIRE_EQ(errno, 0);
+
+ ATF_REQUIRE_EQ_MSG(lookup_me2, magic2,
+ "got value %#x != expected %#x", lookup_me2, magic2);
+
+ printf("Read new lookup_me3 from tracee (PID=%d) by tracer (PID=%d)\n",
+ child, getpid());
+ errno = 0;
+ lookup_me3 = ptrace(PT_READ_I, child, dummy_fn3, 0);
+ ATF_REQUIRE_EQ(errno, 0);
+
+ ATF_REQUIRE_EQ_MSG(lookup_me3, magic3,
+ "got value %#x != expected %#x", lookup_me3, magic3);
+
+ printf("Read new lookup_me4 from tracee (PID=%d) by tracer (PID=%d)\n",
+ child, getpid());
+ errno = 0;
+ lookup_me4 = ptrace(PT_READ_I, child, dummy_fn4, 0);
+ ATF_REQUIRE_EQ(errno, 0);
+
+ ATF_REQUIRE_EQ_MSG(lookup_me4, magic4,
+ "got value %#x != expected %#x", lookup_me4, magic4);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_exited(status, exitval);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+
+#if defined(HAVE_GPREGS)
+ATF_TC(regs1);
+ATF_TC_HEAD(regs1, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify plain PT_GETREGS call without further steps");
+}
+
+ATF_TC_BODY(regs1, tc)
+{
+ const int exitval = 5;
+ const int sigval = SIGSTOP;
+ pid_t child, wpid;
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+ struct reg r;
+
+ printf("Before forking process PID=%d\n", getpid());
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+ printf("Before raising %s from child\n", strsignal(sigval));
+ FORKEE_ASSERT(raise(sigval) == 0);
+
+ printf("Before exiting of the child process\n");
+ _exit(exitval);
+ }
+ printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, sigval);
+
+ printf("Call GETREGS for the child process\n");
+ ATF_REQUIRE(ptrace(PT_GETREGS, child, &r, 0) != -1);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_exited(status, exitval);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+#endif
+
+#if defined(HAVE_GPREGS)
+ATF_TC(regs2);
+ATF_TC_HEAD(regs2, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify plain PT_GETREGS call and retrieve PC");
+}
+
+ATF_TC_BODY(regs2, tc)
+{
+ const int exitval = 5;
+ const int sigval = SIGSTOP;
+ pid_t child, wpid;
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+ struct reg r;
+
+ printf("Before forking process PID=%d\n", getpid());
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+ printf("Before raising %s from child\n", strsignal(sigval));
+ FORKEE_ASSERT(raise(sigval) == 0);
+
+ printf("Before exiting of the child process\n");
+ _exit(exitval);
+ }
+ printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, sigval);
+
+ printf("Call GETREGS for the child process\n");
+ ATF_REQUIRE(ptrace(PT_GETREGS, child, &r, 0) != -1);
+
+ printf("Retrieved PC=%" PRIxREGISTER "\n", PTRACE_REG_PC(&r));
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_exited(status, exitval);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+#endif
+
+#if defined(HAVE_GPREGS)
+ATF_TC(regs3);
+ATF_TC_HEAD(regs3, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify plain PT_GETREGS call and retrieve SP");
+}
+
+ATF_TC_BODY(regs3, tc)
+{
+ const int exitval = 5;
+ const int sigval = SIGSTOP;
+ pid_t child, wpid;
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+ struct reg r;
+
+ printf("Before forking process PID=%d\n", getpid());
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+ printf("Before raising %s from child\n", strsignal(sigval));
+ FORKEE_ASSERT(raise(sigval) == 0);
+
+ printf("Before exiting of the child process\n");
+ _exit(exitval);
+ }
+ printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, sigval);
+
+ printf("Call GETREGS for the child process\n");
+ ATF_REQUIRE(ptrace(PT_GETREGS, child, &r, 0) != -1);
+
+ printf("Retrieved SP=%" PRIxREGISTER "\n", PTRACE_REG_SP(&r));
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_exited(status, exitval);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+#endif
+
+#if defined(HAVE_GPREGS)
+ATF_TC(regs4);
+ATF_TC_HEAD(regs4, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify plain PT_GETREGS call and retrieve INTRV");
+}
+
+ATF_TC_BODY(regs4, tc)
+{
+ const int exitval = 5;
+ const int sigval = SIGSTOP;
+ pid_t child, wpid;
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+ struct reg r;
+
+ printf("Before forking process PID=%d\n", getpid());
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+ printf("Before raising %s from child\n", strsignal(sigval));
+ FORKEE_ASSERT(raise(sigval) == 0);
+
+ printf("Before exiting of the child process\n");
+ _exit(exitval);
+ }
+ printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, sigval);
+
+ printf("Call GETREGS for the child process\n");
+ ATF_REQUIRE(ptrace(PT_GETREGS, child, &r, 0) != -1);
+
+ printf("Retrieved INTRV=%" PRIxREGISTER "\n", PTRACE_REG_INTRV(&r));
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_exited(status, exitval);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+#endif
+
+#if defined(HAVE_GPREGS)
+ATF_TC(regs5);
+ATF_TC_HEAD(regs5, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify PT_GETREGS and PT_SETREGS calls without changing regs");
+}
+
+ATF_TC_BODY(regs5, tc)
+{
+ const int exitval = 5;
+ const int sigval = SIGSTOP;
+ pid_t child, wpid;
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+ struct reg r;
+
+ printf("Before forking process PID=%d\n", getpid());
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+ printf("Before raising %s from child\n", strsignal(sigval));
+ FORKEE_ASSERT(raise(sigval) == 0);
+
+ printf("Before exiting of the child process\n");
+ _exit(exitval);
+ }
+ printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, sigval);
+
+ printf("Call GETREGS for the child process\n");
+ ATF_REQUIRE(ptrace(PT_GETREGS, child, &r, 0) != -1);
+
+ printf("Call SETREGS for the child process (without changed regs)\n");
+ ATF_REQUIRE(ptrace(PT_GETREGS, child, &r, 0) != -1);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_exited(status, exitval);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+#endif
+
+#if defined(HAVE_FPREGS)
+ATF_TC(fpregs1);
+ATF_TC_HEAD(fpregs1, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify plain PT_GETFPREGS call without further steps");
+}
+
+ATF_TC_BODY(fpregs1, tc)
+{
+ const int exitval = 5;
+ const int sigval = SIGSTOP;
+ pid_t child, wpid;
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+ struct fpreg r;
+
+ printf("Before forking process PID=%d\n", getpid());
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+ printf("Before raising %s from child\n", strsignal(sigval));
+ FORKEE_ASSERT(raise(sigval) == 0);
+
+ printf("Before exiting of the child process\n");
+ _exit(exitval);
+ }
+ printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, sigval);
+
+ printf("Call GETFPREGS for the child process\n");
+ ATF_REQUIRE(ptrace(PT_GETFPREGS, child, &r, 0) != -1);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_exited(status, exitval);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+#endif
+
+#if defined(HAVE_FPREGS)
+ATF_TC(fpregs2);
+ATF_TC_HEAD(fpregs2, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify PT_GETFPREGS and PT_SETFPREGS calls without changing "
+ "regs");
+}
+
+ATF_TC_BODY(fpregs2, tc)
+{
+ const int exitval = 5;
+ const int sigval = SIGSTOP;
+ pid_t child, wpid;
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+ struct fpreg r;
+
+ printf("Before forking process PID=%d\n", getpid());
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+ printf("Before raising %s from child\n", strsignal(sigval));
+ FORKEE_ASSERT(raise(sigval) == 0);
+
+ printf("Before exiting of the child process\n");
+ _exit(exitval);
+ }
+ printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, sigval);
+
+ printf("Call GETFPREGS for the child process\n");
+ ATF_REQUIRE(ptrace(PT_GETFPREGS, child, &r, 0) != -1);
+
+ printf("Call SETFPREGS for the child (without changed regs)\n");
+ ATF_REQUIRE(ptrace(PT_SETFPREGS, child, &r, 0) != -1);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_exited(status, exitval);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+#endif
+
+#if defined(PT_STEP)
+ATF_TC(step1);
+ATF_TC_HEAD(step1, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify single PT_STEP call");
+}
+
+ATF_TC_BODY(step1, tc)
+{
+ const int exitval = 5;
+ const int sigval = SIGSTOP;
+ pid_t child, wpid;
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+ int happy;
+
+ printf("Before forking process PID=%d\n", getpid());
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+ happy = check_happy(100);
+
+ printf("Before raising %s from child\n", strsignal(sigval));
+ FORKEE_ASSERT(raise(sigval) == 0);
+
+ FORKEE_ASSERT_EQ(happy, check_happy(100));
+
+ printf("Before exiting of the child process\n");
+ _exit(exitval);
+ }
+ printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, sigval);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent (use PT_STEP)\n");
+ ATF_REQUIRE(ptrace(PT_STEP, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, SIGTRAP);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_exited(status, exitval);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+#endif
+
+#if defined(PT_STEP)
+ATF_TC(step2);
+ATF_TC_HEAD(step2, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify PT_STEP called twice");
+}
+
+ATF_TC_BODY(step2, tc)
+{
+ const int exitval = 5;
+ const int sigval = SIGSTOP;
+ pid_t child, wpid;
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+ int happy;
+ int N = 2;
+
+ printf("Before forking process PID=%d\n", getpid());
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+ happy = check_happy(999);
+
+ printf("Before raising %s from child\n", strsignal(sigval));
+ FORKEE_ASSERT(raise(sigval) == 0);
+
+ FORKEE_ASSERT_EQ(happy, check_happy(999));
+
+ printf("Before exiting of the child process\n");
+ _exit(exitval);
+ }
+ printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, sigval);
+
+ while (N --> 0) {
+ printf("Before resuming the child process where it left off "
+ "and without signal to be sent (use PT_STEP)\n");
+ ATF_REQUIRE(ptrace(PT_STEP, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0),
+ child);
+
+ validate_status_stopped(status, SIGTRAP);
+ }
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_exited(status, exitval);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+#endif
+
+#if defined(PT_STEP)
+ATF_TC(step3);
+ATF_TC_HEAD(step3, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify PT_STEP called three times");
+}
+
+ATF_TC_BODY(step3, tc)
+{
+ const int exitval = 5;
+ const int sigval = SIGSTOP;
+ pid_t child, wpid;
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+ int happy;
+ int N = 3;
+
+ printf("Before forking process PID=%d\n", getpid());
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+ happy = check_happy(999);
+
+ printf("Before raising %s from child\n", strsignal(sigval));
+ FORKEE_ASSERT(raise(sigval) == 0);
+
+ FORKEE_ASSERT_EQ(happy, check_happy(999));
+
+ printf("Before exiting of the child process\n");
+ _exit(exitval);
+ }
+ printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, sigval);
+
+ while (N --> 0) {
+ printf("Before resuming the child process where it left off "
+ "and without signal to be sent (use PT_STEP)\n");
+ ATF_REQUIRE(ptrace(PT_STEP, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0),
+ child);
+
+ validate_status_stopped(status, SIGTRAP);
+ }
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_exited(status, exitval);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+#endif
+
+#if defined(PT_STEP)
+ATF_TC(step4);
+ATF_TC_HEAD(step4, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify PT_STEP called four times");
+}
+
+ATF_TC_BODY(step4, tc)
+{
+ const int exitval = 5;
+ const int sigval = SIGSTOP;
+ pid_t child, wpid;
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+ int happy;
+ int N = 4;
+
+ printf("Before forking process PID=%d\n", getpid());
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+ happy = check_happy(999);
+
+ printf("Before raising %s from child\n", strsignal(sigval));
+ FORKEE_ASSERT(raise(sigval) == 0);
+
+ FORKEE_ASSERT_EQ(happy, check_happy(999));
+
+ printf("Before exiting of the child process\n");
+ _exit(exitval);
+ }
+ printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, sigval);
+
+ while (N --> 0) {
+ printf("Before resuming the child process where it left off "
+ "and without signal to be sent (use PT_STEP)\n");
+ ATF_REQUIRE(ptrace(PT_STEP, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0),
+ child);
+
+ validate_status_stopped(status, SIGTRAP);
+ }
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_exited(status, exitval);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+#endif
+
+ATF_TC(kill1);
+ATF_TC_HEAD(kill1, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify that PT_CONTINUE with SIGKILL terminates child");
+}
+
+ATF_TC_BODY(kill1, tc)
+{
+ const int sigval = SIGSTOP, sigsent = SIGKILL;
+ pid_t child, wpid;
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+
+ printf("Before forking process PID=%d\n", getpid());
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+ printf("Before raising %s from child\n", strsignal(sigval));
+ FORKEE_ASSERT(raise(sigval) == 0);
+
+ /* NOTREACHED */
+ FORKEE_ASSERTX(0 &&
+ "Child should be terminated by a signal from its parent");
+ }
+ printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, sigval);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, sigsent) != -1);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_signaled(status, sigsent, 0);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+
+ATF_TC(kill2);
+ATF_TC_HEAD(kill2, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify that PT_KILL terminates child");
+}
+
+ATF_TC_BODY(kill2, tc)
+{
+ const int sigval = SIGSTOP;
+ pid_t child, wpid;
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+
+ printf("Before forking process PID=%d\n", getpid());
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+ printf("Before raising %s from child\n", strsignal(sigval));
+ FORKEE_ASSERT(raise(sigval) == 0);
+
+ /* NOTREACHED */
+ FORKEE_ASSERTX(0 &&
+ "Child should be terminated by a signal from its parent");
+ }
+ printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, sigval);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_KILL, child, (void*)1, 0) != -1);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_signaled(status, SIGKILL, 0);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+
+ATF_TC(lwpinfo1);
+ATF_TC_HEAD(lwpinfo1, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify basic LWPINFO call for single thread (PT_TRACE_ME)");
+}
+
+ATF_TC_BODY(lwpinfo1, tc)
+{
+ const int exitval = 5;
+ const int sigval = SIGSTOP;
+ pid_t child, wpid;
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+ struct ptrace_lwpinfo info = {0, 0};
+
+ printf("Before forking process PID=%d\n", getpid());
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+ printf("Before raising %s from child\n", strsignal(sigval));
+ FORKEE_ASSERT(raise(sigval) == 0);
+
+ printf("Before exiting of the child process\n");
+ _exit(exitval);
+ }
+ printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, sigval);
+
+ printf("Before calling ptrace(2) with PT_LWPINFO for child\n");
+ ATF_REQUIRE(ptrace(PT_LWPINFO, child, &info, sizeof(info)) != -1);
+
+ printf("Assert that there exists a thread\n");
+ ATF_REQUIRE(info.pl_lwpid > 0);
+
+ printf("Assert that lwp thread %d received event PL_EVENT_SIGNAL\n",
+ info.pl_lwpid);
+ ATF_REQUIRE_EQ_MSG(info.pl_event, PL_EVENT_SIGNAL,
+ "Received event %d != expected event %d",
+ info.pl_event, PL_EVENT_SIGNAL);
+
+ printf("Before calling ptrace(2) with PT_LWPINFO for child\n");
+ ATF_REQUIRE(ptrace(PT_LWPINFO, child, &info, sizeof(info)) != -1);
+
+ printf("Assert that there are no more lwp threads in child\n");
+ ATF_REQUIRE_EQ(info.pl_lwpid, 0);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_exited(status, exitval);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+
+#if defined(TWAIT_HAVE_PID)
+ATF_TC(lwpinfo2);
+ATF_TC_HEAD(lwpinfo2, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify basic LWPINFO call for single thread (PT_ATTACH from "
+ "tracer)");
+}
+
+ATF_TC_BODY(lwpinfo2, tc)
+{
+ struct msg_fds parent_tracee, parent_tracer;
+ const int exitval_tracee = 5;
+ const int exitval_tracer = 10;
+ pid_t tracee, tracer, wpid;
+ uint8_t msg = 0xde; /* dummy message for IPC based on pipe(2) */
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+ struct ptrace_lwpinfo info = {0, 0};
+
+ printf("Spawn tracee\n");
+ ATF_REQUIRE(msg_open(&parent_tracee) == 0);
+ ATF_REQUIRE(msg_open(&parent_tracer) == 0);
+ tracee = atf_utils_fork();
+ if (tracee == 0) {
+
+ /* Wait for message from the parent */
+ CHILD_TO_PARENT("tracee ready", parent_tracee, msg);
+ CHILD_FROM_PARENT("tracee exit", parent_tracee, msg);
+
+ _exit(exitval_tracee);
+ }
+ PARENT_FROM_CHILD("tracee ready", parent_tracee, msg);
+
+ printf("Spawn debugger\n");
+ tracer = atf_utils_fork();
+ if (tracer == 0) {
+ /* No IPC to communicate with the child */
+ printf("Before calling PT_ATTACH from tracee %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_ATTACH, tracee, NULL, 0) != -1);
+
+ /* Wait for tracee and assert that it was stopped w/ SIGSTOP */
+ FORKEE_REQUIRE_SUCCESS(
+ wpid = TWAIT_GENERIC(tracee, &status, 0), tracee);
+
+ forkee_status_stopped(status, SIGSTOP);
+
+ printf("Before calling ptrace(2) with PT_LWPINFO for child\n");
+ FORKEE_ASSERT(ptrace(PT_LWPINFO, tracee, &info, sizeof(info))
+ != -1);
+
+ printf("Assert that there exists a thread\n");
+ FORKEE_ASSERTX(info.pl_lwpid > 0);
+
+ printf("Assert that lwp thread %d received event "
+ "PL_EVENT_SIGNAL\n", info.pl_lwpid);
+ FORKEE_ASSERT_EQ(info.pl_event, PL_EVENT_SIGNAL);
+
+ printf("Before calling ptrace(2) with PT_LWPINFO for child\n");
+ FORKEE_ASSERT(ptrace(PT_LWPINFO, tracee, &info, sizeof(info))
+ != -1);
+
+ printf("Assert that there are no more lwp threads in child\n");
+ FORKEE_ASSERTX(info.pl_lwpid == 0);
+
+ /* Resume tracee with PT_CONTINUE */
+ FORKEE_ASSERT(ptrace(PT_CONTINUE, tracee, (void *)1, 0) != -1);
+
+ /* Inform parent that tracer has attached to tracee */
+ CHILD_TO_PARENT("tracer ready", parent_tracer, msg);
+ /* Wait for parent */
+ CHILD_FROM_PARENT("tracer wait", parent_tracer, msg);
+
+ /* Wait for tracee and assert that it exited */
+ FORKEE_REQUIRE_SUCCESS(
+ wpid = TWAIT_GENERIC(tracee, &status, 0), tracee);
+
+ forkee_status_exited(status, exitval_tracee);
+
+ printf("Before exiting of the tracer process\n");
+ _exit(exitval_tracer);
+ }
+
+ printf("Wait for the tracer to attach to the tracee\n");
+ PARENT_FROM_CHILD("tracer ready", parent_tracer, msg);
+
+ printf("Resume the tracee and let it exit\n");
+ PARENT_TO_CHILD("tracee exit", parent_tracee, msg);
+
+ printf("Detect that tracee is zombie\n");
+ await_zombie(tracee);
+
+ printf("Assert that there is no status about tracee - "
+ "Tracer must detect zombie first - calling %s()\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(
+ wpid = TWAIT_GENERIC(tracee, &status, WNOHANG), 0);
+
+ printf("Resume the tracer and let it detect exited tracee\n");
+ PARENT_TO_CHILD("tracer wait", parent_tracer, msg);
+
+ printf("Wait for tracer to finish its job and exit - calling %s()\n",
+ TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(tracer, &status, 0),
+ tracer);
+
+ validate_status_exited(status, exitval_tracer);
+
+ printf("Wait for tracee to finish its job and exit - calling %s()\n",
+ TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(tracee, &status, WNOHANG),
+ tracee);
+
+ validate_status_exited(status, exitval_tracee);
+
+ msg_close(&parent_tracer);
+ msg_close(&parent_tracee);
+}
+#endif
+
+ATF_TC(siginfo1);
+ATF_TC_HEAD(siginfo1, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify basic PT_GET_SIGINFO call for SIGTRAP from tracee");
+}
+
+ATF_TC_BODY(siginfo1, tc)
+{
+ const int exitval = 5;
+ const int sigval = SIGTRAP;
+ pid_t child, wpid;
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+ struct ptrace_siginfo info;
+ memset(&info, 0, sizeof(info));
+
+ printf("Before forking process PID=%d\n", getpid());
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+ printf("Before raising %s from child\n", strsignal(sigval));
+ FORKEE_ASSERT(raise(sigval) == 0);
+
+ printf("Before exiting of the child process\n");
+ _exit(exitval);
+ }
+ printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, sigval);
+
+ printf("Before calling ptrace(2) with PT_GET_SIGINFO for child\n");
+ ATF_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1);
+
+ printf("Signal traced to lwpid=%d\n", info.psi_lwpid);
+ printf("Signal properties: si_signo=%#x si_code=%#x si_errno=%#x\n",
+ info.psi_siginfo.si_signo, info.psi_siginfo.si_code,
+ info.psi_siginfo.si_errno);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_exited(status, exitval);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+
+ATF_TC(siginfo2);
+ATF_TC_HEAD(siginfo2, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify basic PT_GET_SIGINFO and PT_SET_SIGINFO calls without "
+ "modification of SIGINT from tracee");
+}
+
+static int siginfo2_caught = 0;
+
+static void
+siginfo2_sighandler(int sig)
+{
+ FORKEE_ASSERT_EQ(sig, SIGINT);
+
+ ++siginfo2_caught;
+}
+
+ATF_TC_BODY(siginfo2, tc)
+{
+ const int exitval = 5;
+ const int sigval = SIGINT;
+ pid_t child, wpid;
+ struct sigaction sa;
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+ struct ptrace_siginfo info;
+ memset(&info, 0, sizeof(info));
+
+ printf("Before forking process PID=%d\n", getpid());
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+ sa.sa_handler = siginfo2_sighandler;
+ sa.sa_flags = SA_SIGINFO;
+ sigemptyset(&sa.sa_mask);
+
+ FORKEE_ASSERT(sigaction(sigval, &sa, NULL) != -1);
+
+ printf("Before raising %s from child\n", strsignal(sigval));
+ FORKEE_ASSERT(raise(sigval) == 0);
+
+ FORKEE_ASSERT_EQ(siginfo2_caught, 1);
+
+ printf("Before exiting of the child process\n");
+ _exit(exitval);
+ }
+ printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, sigval);
+
+ printf("Before calling ptrace(2) with PT_GET_SIGINFO for child\n");
+ ATF_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1);
+
+ printf("Signal traced to lwpid=%d\n", info.psi_lwpid);
+ printf("Signal properties: si_signo=%#x si_code=%#x si_errno=%#x\n",
+ info.psi_siginfo.si_signo, info.psi_siginfo.si_code,
+ info.psi_siginfo.si_errno);
+
+ printf("Before calling ptrace(2) with PT_SET_SIGINFO for child\n");
+ ATF_REQUIRE(ptrace(PT_SET_SIGINFO, child, &info, sizeof(info)) != -1);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, sigval) != -1);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_exited(status, exitval);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+
+ATF_TC(siginfo3);
+ATF_TC_HEAD(siginfo3, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify basic PT_GET_SIGINFO and PT_SET_SIGINFO calls with "
+ "setting signal to new value");
+}
+
+static int siginfo3_caught = 0;
+
+static void
+siginfo3_sigaction(int sig, siginfo_t *info, void *ctx)
+{
+ FORKEE_ASSERT_EQ(sig, SIGTRAP);
+
+ FORKEE_ASSERT_EQ(info->si_signo, SIGTRAP);
+ FORKEE_ASSERT_EQ(info->si_code, TRAP_BRKPT);
+
+ ++siginfo3_caught;
+}
+
+ATF_TC_BODY(siginfo3, tc)
+{
+ const int exitval = 5;
+ const int sigval = SIGINT;
+ const int sigfaked = SIGTRAP;
+ const int sicodefaked = TRAP_BRKPT;
+ pid_t child, wpid;
+ struct sigaction sa;
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+ struct ptrace_siginfo info;
+ memset(&info, 0, sizeof(info));
+
+ printf("Before forking process PID=%d\n", getpid());
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+ sa.sa_sigaction = siginfo3_sigaction;
+ sa.sa_flags = SA_SIGINFO;
+ sigemptyset(&sa.sa_mask);
+
+ FORKEE_ASSERT(sigaction(sigfaked, &sa, NULL) != -1);
+
+ printf("Before raising %s from child\n", strsignal(sigval));
+ FORKEE_ASSERT(raise(sigval) == 0);
+
+ FORKEE_ASSERT_EQ(siginfo3_caught, 1);
+
+ printf("Before exiting of the child process\n");
+ _exit(exitval);
+ }
+ printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, sigval);
+
+ printf("Before calling ptrace(2) with PT_GET_SIGINFO for child\n");
+ ATF_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1);
+
+ printf("Signal traced to lwpid=%d\n", info.psi_lwpid);
+ printf("Signal properties: si_signo=%#x si_code=%#x si_errno=%#x\n",
+ info.psi_siginfo.si_signo, info.psi_siginfo.si_code,
+ info.psi_siginfo.si_errno);
+
+ printf("Before setting new faked signal to signo=%d si_code=%d\n",
+ sigfaked, sicodefaked);
+ info.psi_siginfo.si_signo = sigfaked;
+ info.psi_siginfo.si_code = sicodefaked;
+
+ printf("Before calling ptrace(2) with PT_SET_SIGINFO for child\n");
+ ATF_REQUIRE(ptrace(PT_SET_SIGINFO, child, &info, sizeof(info)) != -1);
+
+ printf("Before calling ptrace(2) with PT_GET_SIGINFO for child\n");
+ ATF_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1);
+
+ printf("Before checking siginfo_t\n");
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, sigfaked);
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_code, sicodefaked);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, sigfaked) != -1);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_exited(status, exitval);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+
+ATF_TC(siginfo4);
+ATF_TC_HEAD(siginfo4, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Detect SIGTRAP TRAP_EXEC from tracee");
+}
+
+ATF_TC_BODY(siginfo4, tc)
+{
+ const int sigval = SIGTRAP;
+ pid_t child, wpid;
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+
+ struct ptrace_siginfo info;
+ memset(&info, 0, sizeof(info));
+
+ printf("Before forking process PID=%d\n", getpid());
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+ printf("Before calling execve(2) from child\n");
+ execlp("/bin/echo", "/bin/echo", NULL);
+
+ FORKEE_ASSERT(0 && "Not reached");
+ }
+ printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, sigval);
+
+ printf("Before calling ptrace(2) with PT_GET_SIGINFO for child\n");
+ ATF_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1);
+
+ printf("Signal traced to lwpid=%d\n", info.psi_lwpid);
+ printf("Signal properties: si_signo=%#x si_code=%#x si_errno=%#x\n",
+ info.psi_siginfo.si_signo, info.psi_siginfo.si_code,
+ info.psi_siginfo.si_errno);
+
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, sigval);
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_code, TRAP_EXEC);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+
+#if defined(TWAIT_HAVE_PID)
+ATF_TC(siginfo5);
+ATF_TC_HEAD(siginfo5, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify that fork(2) is intercepted by ptrace(2) with EVENT_MASK "
+ "set to PTRACE_FORK and reports correct signal information");
+}
+
+ATF_TC_BODY(siginfo5, tc)
+{
+ const int exitval = 5;
+ const int exitval2 = 15;
+ const int sigval = SIGSTOP;
+ pid_t child, child2, wpid;
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+ ptrace_state_t state;
+ const int slen = sizeof(state);
+ ptrace_event_t event;
+ const int elen = sizeof(event);
+ struct ptrace_siginfo info;
+
+ memset(&info, 0, sizeof(info));
+
+ printf("Before forking process PID=%d\n", getpid());
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+ printf("Before raising %s from child\n", strsignal(sigval));
+ FORKEE_ASSERT(raise(sigval) == 0);
+
+ FORKEE_ASSERT((child2 = fork()) != 1);
+
+ if (child2 == 0)
+ _exit(exitval2);
+
+ FORKEE_REQUIRE_SUCCESS
+ (wpid = TWAIT_GENERIC(child2, &status, 0), child2);
+
+ forkee_status_exited(status, exitval2);
+
+ printf("Before exiting of the child process\n");
+ _exit(exitval);
+ }
+ printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, sigval);
+
+ printf("Before calling ptrace(2) with PT_GET_SIGINFO for child\n");
+ ATF_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1);
+
+ printf("Before checking siginfo_t\n");
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, sigval);
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_code, SI_LWP);
+
+ printf("Enable PTRACE_FORK in EVENT_MASK for the child %d\n", child);
+ event.pe_set_event = PTRACE_FORK;
+ ATF_REQUIRE(ptrace(PT_SET_EVENT_MASK, child, &event, elen) != -1);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child %d\n", TWAIT_FNAME, child);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, SIGTRAP);
+
+ printf("Before calling ptrace(2) with PT_GET_SIGINFO for child\n");
+ ATF_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1);
+
+ printf("Before checking siginfo_t\n");
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, SIGTRAP);
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_code, TRAP_CHLD);
+
+ ATF_REQUIRE(ptrace(PT_GET_PROCESS_STATE, child, &state, slen) != -1);
+ ATF_REQUIRE_EQ(state.pe_report_event, PTRACE_FORK);
+
+ child2 = state.pe_other_pid;
+ printf("Reported PTRACE_FORK event with forkee %d\n", child2);
+
+ printf("Before calling %s() for the forkee %d of the child %d\n",
+ TWAIT_FNAME, child2, child);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child2, &status, 0),
+ child2);
+
+ validate_status_stopped(status, SIGTRAP);
+
+ printf("Before calling ptrace(2) with PT_GET_SIGINFO for child\n");
+ ATF_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1);
+
+ printf("Before checking siginfo_t\n");
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, SIGTRAP);
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_code, TRAP_CHLD);
+
+ ATF_REQUIRE(ptrace(PT_GET_PROCESS_STATE, child2, &state, slen) != -1);
+ ATF_REQUIRE_EQ(state.pe_report_event, PTRACE_FORK);
+ ATF_REQUIRE_EQ(state.pe_other_pid, child);
+
+ printf("Before resuming the forkee process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child2, (void *)1, 0) != -1);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the forkee - expected exited\n",
+ TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child2, &status, 0),
+ child2);
+
+ validate_status_exited(status, exitval2);
+
+ printf("Before calling %s() for the forkee - expected no process\n",
+ TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD,
+ wpid = TWAIT_GENERIC(child2, &status, 0));
+
+ printf("Before calling %s() for the child - expected stopped "
+ "SIGCHLD\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, SIGCHLD);
+
+ printf("Before calling ptrace(2) with PT_GET_SIGINFO for child\n");
+ ATF_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1);
+
+ printf("Before checking siginfo_t\n");
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, SIGCHLD);
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_code, CLD_EXITED);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child - expected exited\n",
+ TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_exited(status, exitval);
+
+ printf("Before calling %s() for the child - expected no process\n",
+ TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+#endif
+
+#if defined(PT_STEP)
+ATF_TC(siginfo6);
+ATF_TC_HEAD(siginfo6, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify single PT_STEP call with signal information check");
+}
+
+ATF_TC_BODY(siginfo6, tc)
+{
+ const int exitval = 5;
+ const int sigval = SIGSTOP;
+ pid_t child, wpid;
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+ int happy;
+ struct ptrace_siginfo info;
+
+ memset(&info, 0, sizeof(info));
+
+ printf("Before forking process PID=%d\n", getpid());
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+ happy = check_happy(100);
+
+ printf("Before raising %s from child\n", strsignal(sigval));
+ FORKEE_ASSERT(raise(sigval) == 0);
+
+ FORKEE_ASSERT_EQ(happy, check_happy(100));
+
+ printf("Before exiting of the child process\n");
+ _exit(exitval);
+ }
+ printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, sigval);
+
+ printf("Before calling ptrace(2) with PT_GET_SIGINFO for child\n");
+ ATF_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1);
+
+ printf("Before checking siginfo_t\n");
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, sigval);
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_code, SI_LWP);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent (use PT_STEP)\n");
+ ATF_REQUIRE(ptrace(PT_STEP, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, SIGTRAP);
+
+ printf("Before calling ptrace(2) with PT_GET_SIGINFO for child\n");
+ ATF_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1);
+
+ printf("Before checking siginfo_t\n");
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, SIGTRAP);
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_code, TRAP_TRACE);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_exited(status, exitval);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+#endif
+
+ATF_TP_ADD_TCS(tp)
+{
+ setvbuf(stdout, NULL, _IONBF, 0);
+ setvbuf(stderr, NULL, _IONBF, 0);
+ ATF_TP_ADD_TC(tp, traceme1);
+ ATF_TP_ADD_TC(tp, traceme2);
+ ATF_TP_ADD_TC(tp, traceme3);
+ ATF_TP_ADD_TC(tp, traceme4);
+
+ ATF_TP_ADD_TC_HAVE_PID(tp, attach1);
+ ATF_TP_ADD_TC_HAVE_PID(tp, attach2);
+ ATF_TP_ADD_TC(tp, attach3);
+ ATF_TP_ADD_TC(tp, attach4);
+ ATF_TP_ADD_TC_HAVE_PID(tp, attach5);
+ ATF_TP_ADD_TC_HAVE_PID(tp, attach6);
+ ATF_TP_ADD_TC_HAVE_PID(tp, attach7);
+
+ ATF_TP_ADD_TC(tp, eventmask1);
+ ATF_TP_ADD_TC(tp, eventmask2);
+
+ ATF_TP_ADD_TC_HAVE_PID(tp, fork1);
+ ATF_TP_ADD_TC(tp, fork2);
+
+ ATF_TP_ADD_TC_HAVE_PID(tp, vfork1);
+ ATF_TP_ADD_TC(tp, vfork2);
+
+ ATF_TP_ADD_TC(tp, io_read_d1);
+ ATF_TP_ADD_TC(tp, io_read_d2);
+ ATF_TP_ADD_TC(tp, io_read_d3);
+ ATF_TP_ADD_TC(tp, io_read_d4);
+
+ ATF_TP_ADD_TC(tp, io_write_d1);
+ ATF_TP_ADD_TC(tp, io_write_d2);
+ ATF_TP_ADD_TC(tp, io_write_d3);
+ ATF_TP_ADD_TC(tp, io_write_d4);
+
+ ATF_TP_ADD_TC(tp, read_d1);
+ ATF_TP_ADD_TC(tp, read_d2);
+ ATF_TP_ADD_TC(tp, read_d3);
+ ATF_TP_ADD_TC(tp, read_d4);
+
+ ATF_TP_ADD_TC(tp, write_d1);
+ ATF_TP_ADD_TC(tp, write_d2);
+ ATF_TP_ADD_TC(tp, write_d3);
+ ATF_TP_ADD_TC(tp, write_d4);
+
+ ATF_TP_ADD_TC(tp, io_read_d_write_d_handshake1);
+ ATF_TP_ADD_TC(tp, io_read_d_write_d_handshake2);
+
+ ATF_TP_ADD_TC(tp, read_d_write_d_handshake1);
+ ATF_TP_ADD_TC(tp, read_d_write_d_handshake2);
+
+ ATF_TP_ADD_TC(tp, io_read_i1);
+ ATF_TP_ADD_TC(tp, io_read_i2);
+ ATF_TP_ADD_TC(tp, io_read_i3);
+ ATF_TP_ADD_TC(tp, io_read_i4);
+
+ ATF_TP_ADD_TC(tp, read_i1);
+ ATF_TP_ADD_TC(tp, read_i2);
+ ATF_TP_ADD_TC(tp, read_i3);
+ ATF_TP_ADD_TC(tp, read_i4);
+
+ ATF_TP_ADD_TC_HAVE_GPREGS(tp, regs1);
+ ATF_TP_ADD_TC_HAVE_GPREGS(tp, regs2);
+ ATF_TP_ADD_TC_HAVE_GPREGS(tp, regs3);
+ ATF_TP_ADD_TC_HAVE_GPREGS(tp, regs4);
+ ATF_TP_ADD_TC_HAVE_GPREGS(tp, regs5);
+
+ ATF_TP_ADD_TC_HAVE_FPREGS(tp, fpregs1);
+ ATF_TP_ADD_TC_HAVE_FPREGS(tp, fpregs2);
+
+ ATF_TP_ADD_TC_PT_STEP(tp, step1);
+ ATF_TP_ADD_TC_PT_STEP(tp, step2);
+ ATF_TP_ADD_TC_PT_STEP(tp, step3);
+ ATF_TP_ADD_TC_PT_STEP(tp, step4);
+
+ ATF_TP_ADD_TC(tp, kill1);
+ ATF_TP_ADD_TC(tp, kill2);
+
+ ATF_TP_ADD_TC(tp, lwpinfo1);
+ ATF_TP_ADD_TC_HAVE_PID(tp, lwpinfo2);
+
+ ATF_TP_ADD_TC(tp, siginfo1);
+ ATF_TP_ADD_TC(tp, siginfo2);
+ ATF_TP_ADD_TC(tp, siginfo3);
+ ATF_TP_ADD_TC(tp, siginfo4);
+ ATF_TP_ADD_TC_HAVE_PID(tp, siginfo5);
+ ATF_TP_ADD_TC_PT_STEP(tp, siginfo6);
+
+ return atf_no_error();
+}
diff --git a/contrib/netbsd-tests/kernel/t_ptrace_wait.h b/contrib/netbsd-tests/kernel/t_ptrace_wait.h
new file mode 100644
index 0000000..9c6921c
--- /dev/null
+++ b/contrib/netbsd-tests/kernel/t_ptrace_wait.h
@@ -0,0 +1,431 @@
+/* $NetBSD: t_ptrace_wait.h,v 1.7 2017/01/09 22:09:20 kamil Exp $ */
+
+/*-
+ * Copyright (c) 2016 The NetBSD Foundation, Inc.
+ * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+ */
+
+/* Detect plain wait(2) use-case */
+#if !defined(TWAIT_WAITPID) && \
+ !defined(TWAIT_WAITID) && \
+ !defined(TWAIT_WAIT3) && \
+ !defined(TWAIT_WAIT4) && \
+ !defined(TWAIT_WAIT6)
+#define TWAIT_WAIT
+#endif
+
+/*
+ * There are two classes of wait(2)-like functions:
+ * - wait4(2)-like accepting pid_t, optional options parameter, struct rusage*
+ * - wait6(2)-like accepting idtype_t, id_t, struct wrusage, mandatory options
+ *
+ * The TWAIT_FNAME value is to be used for convenience in debug messages.
+ *
+ * The TWAIT_GENERIC() macro is designed to reuse the same unmodified
+ * code with as many wait(2)-like functions as possible.
+ *
+ * In a common use-case wait4(2) and wait6(2)-like function can work the almost
+ * the same way, however there are few important differences:
+ * wait6(2) must specify P_PID for idtype to match wpid from wait4(2).
+ * To behave like wait4(2), wait6(2) the 'options' to wait must include
+ * WEXITED|WTRUNCATED.
+ *
+ * There are two helper macros (they purpose it to mach more than one
+ * wait(2)-like function):
+ * The TWAIT_HAVE_STATUS - specifies whether a function can retrieve
+ * status (as integer value).
+ * The TWAIT_HAVE_PID - specifies whether a function can request
+ * exact process identifier
+ * The TWAIT_HAVE_RUSAGE - specifies whether a function can request
+ * the struct rusage value
+ *
+ */
+
+#if defined(TWAIT_WAIT)
+# define TWAIT_FNAME "wait"
+# define TWAIT_WAIT4TYPE(a,b,c,d) wait((b))
+# define TWAIT_GENERIC(a,b,c) wait((b))
+# define TWAIT_HAVE_STATUS 1
+#elif defined(TWAIT_WAITPID)
+# define TWAIT_FNAME "waitpid"
+# define TWAIT_WAIT4TYPE(a,b,c,d) waitpid((a),(b),(c))
+# define TWAIT_GENERIC(a,b,c) waitpid((a),(b),(c))
+# define TWAIT_HAVE_PID 1
+# define TWAIT_HAVE_STATUS 1
+#elif defined(TWAIT_WAITID)
+# define TWAIT_FNAME "waitid"
+# define TWAIT_GENERIC(a,b,c) \
+ waitid(P_PID,(a),NULL,(c)|WEXITED|WTRAPPED)
+# define TWAIT_WAIT6TYPE(a,b,c,d,e,f) waitid((a),(b),(f),(d))
+# define TWAIT_HAVE_PID 1
+#elif defined(TWAIT_WAIT3)
+# define TWAIT_FNAME "wait3"
+# define TWAIT_WAIT4TYPE(a,b,c,d) wait3((b),(c),(d))
+# define TWAIT_GENERIC(a,b,c) wait3((b),(c),NULL)
+# define TWAIT_HAVE_STATUS 1
+# define TWAIT_HAVE_RUSAGE 1
+#elif defined(TWAIT_WAIT4)
+# define TWAIT_FNAME "wait4"
+# define TWAIT_WAIT4TYPE(a,b,c,d) wait4((a),(b),(c),(d))
+# define TWAIT_GENERIC(a,b,c) wait4((a),(b),(c),NULL)
+# define TWAIT_HAVE_PID 1
+# define TWAIT_HAVE_STATUS 1
+# define TWAIT_HAVE_RUSAGE 1
+#elif defined(TWAIT_WAIT6)
+# define TWAIT_FNAME "wait6"
+# define TWAIT_WAIT6TYPE(a,b,c,d,e,f) wait6((a),(b),(c),(d),(e),(f))
+# define TWAIT_GENERIC(a,b,c) \
+ wait6(P_PID,(a),(b),(c)|WEXITED|WTRAPPED,NULL,NULL)
+# define TWAIT_HAVE_PID 1
+# define TWAIT_HAVE_STATUS 1
+#endif
+
+/*
+ * There are 3 groups of tests:
+ * - TWAIT_GENERIC() (wait, wait2, waitpid, wait3, wait4, wait6)
+ * - TWAIT_WAIT4TYPE() (wait2, waitpid, wait3, wait4)
+ * - TWAIT_WAIT6TYPE() (waitid, wait6)
+ *
+ * Tests only in the above categories are allowed. However some tests are not
+ * possible in the context requested functionality to be verified, therefore
+ * there are helper macros:
+ * - TWAIT_HAVE_PID (wait2, waitpid, waitid, wait4, wait6)
+ * - TWAIT_HAVE_STATUS (wait, wait2, waitpid, wait3, wait4, wait6)
+ * - TWAIT_HAVE_RUSAGE (wait3, wait4)
+ * - TWAIT_HAVE_RETPID (wait, wait2, waitpid, wait3, wait4, wait6)
+ *
+ * If there is an intention to test e.g. wait6(2) specific features in the
+ * ptrace(2) context, find the most matching group and with #ifdefs reduce
+ * functionality of less featured than wait6(2) interface (TWAIT_WAIT6TYPE).
+ *
+ * For clarity never use negative preprocessor checks, like:
+ * #if !defined(TWAIT_WAIT4)
+ * always refer to checks for positive values.
+ */
+
+#define TEST_REQUIRE_EQ(x, y) \
+do { \
+ uintmax_t vx = (x); \
+ uintmax_t vy = (y); \
+ int ret = vx == vy; \
+ if (!ret) \
+ ATF_REQUIRE_EQ_MSG(vx, vy, "%s(%ju) == %s(%ju)", \
+ #x, vx, #y, vy); \
+} while (/*CONSTCOND*/0)
+
+/*
+ * A child process cannot call atf functions and expect them to magically
+ * work like in the parent.
+ * The printf(3) messaging from a child will not work out of the box as well
+ * without estabilishing a communication protocol with its parent. To not
+ * overcomplicate the tests - do not log from a child and use err(3)/errx(3)
+ * wrapped with FORKEE_ASSERT()/FORKEE_ASSERTX() as that is guaranteed to work.
+ */
+#define FORKEE_ASSERT_EQ(x, y) \
+do { \
+ uintmax_t vx = (x); \
+ uintmax_t vy = (y); \
+ int ret = vx == vy; \
+ if (!ret) \
+ errx(EXIT_FAILURE, "%s:%d %s(): Assertion failed for: " \
+ "%s(%ju) == %s(%ju)", __FILE__, __LINE__, __func__, \
+ #x, vx, #y, vy); \
+} while (/*CONSTCOND*/0)
+
+#define FORKEE_ASSERTX(x) \
+do { \
+ int ret = (x); \
+ if (!ret) \
+ errx(EXIT_FAILURE, "%s:%d %s(): Assertion failed for: %s",\
+ __FILE__, __LINE__, __func__, #x); \
+} while (/*CONSTCOND*/0)
+
+#define FORKEE_ASSERT(x) \
+do { \
+ int ret = (x); \
+ if (!ret) \
+ err(EXIT_FAILURE, "%s:%d %s(): Assertion failed for: %s",\
+ __FILE__, __LINE__, __func__, #x); \
+} while (/*CONSTCOND*/0)
+
+/*
+ * Simplify logic for functions using general purpose registers add HAVE_GPREGS
+ *
+ * For platforms that do not implement all needed calls for simplicity assume
+ * that they are unsupported at all.
+ */
+#if defined(PT_GETREGS) \
+ && defined(PT_SETREGS) \
+ && defined(PTRACE_REG_PC) \
+ && defined(PTRACE_REG_SET_PC) \
+ && defined(PTRACE_REG_SP) \
+ && defined(PTRACE_REG_INTRV)
+#define HAVE_GPREGS
+#endif
+
+/* Add guards for floating point registers */
+#if defined(PT_GETFPREGS) \
+ && defined(PT_SETFPREGS)
+#define HAVE_FPREGS
+#endif
+
+/* Add guards for cpu debug registers */
+#if defined(PT_GETDBREGS) \
+ && defined(PT_SETDBREGS)
+#define HAVE_DBREGS
+#endif
+
+/*
+ * If waitid(2) returns because one or more processes have a state change to
+ * report, 0 is returned. If an error is detected, a value of -1 is returned
+ * and errno is set to indicate the error. If WNOHANG is specified and there
+ * are no stopped, continued or exited children, 0 is returned.
+ */
+#if defined(TWAIT_WAITID)
+#define TWAIT_REQUIRE_SUCCESS(a,b) TEST_REQUIRE_EQ((a), 0)
+#define TWAIT_REQUIRE_FAILURE(a,b) ATF_REQUIRE_ERRNO((a),(b) == -1)
+#define FORKEE_REQUIRE_SUCCESS(a,b) FORKEE_ASSERT_EQ(a, 0)
+#define FORKEE_REQUIRE_FAILURE(a,b) \
+ FORKEE_ASSERTX(((a) == errno) && ((b) == -1))
+#else
+#define TWAIT_REQUIRE_SUCCESS(a,b) TEST_REQUIRE_EQ((a), (b))
+#define TWAIT_REQUIRE_FAILURE(a,b) ATF_REQUIRE_ERRNO((a),(b) == -1)
+#define FORKEE_REQUIRE_SUCCESS(a,b) FORKEE_ASSERT_EQ(a, b)
+#define FORKEE_REQUIRE_FAILURE(a,b) \
+ FORKEE_ASSERTX(((a) == errno) && ((b) == -1))
+#endif
+
+/*
+ * Helper tools to verify whether status reports exited value
+ */
+#if TWAIT_HAVE_STATUS
+static void __used
+validate_status_exited(int status, int expected)
+{
+ ATF_REQUIRE_MSG(WIFEXITED(status), "Reported !exited process");
+ ATF_REQUIRE_MSG(!WIFCONTINUED(status), "Reported continued process");
+ ATF_REQUIRE_MSG(!WIFSIGNALED(status), "Reported signaled process");
+ ATF_REQUIRE_MSG(!WIFSTOPPED(status), "Reported stopped process");
+
+ ATF_REQUIRE_EQ_MSG(WEXITSTATUS(status), expected,
+ "The process has exited with invalid value %d != %d",
+ WEXITSTATUS(status), expected);
+}
+
+static void __used
+forkee_status_exited(int status, int expected)
+{
+ FORKEE_ASSERTX(WIFEXITED(status));
+ FORKEE_ASSERTX(!WIFCONTINUED(status));
+ FORKEE_ASSERTX(!WIFSIGNALED(status));
+ FORKEE_ASSERTX(!WIFSTOPPED(status));
+
+ FORKEE_ASSERT_EQ(WEXITSTATUS(status), expected);
+}
+
+static void __used
+validate_status_continued(int status)
+{
+ ATF_REQUIRE_MSG(!WIFEXITED(status), "Reported exited process");
+ ATF_REQUIRE_MSG(WIFCONTINUED(status), "Reported !continued process");
+ ATF_REQUIRE_MSG(!WIFSIGNALED(status), "Reported signaled process");
+ ATF_REQUIRE_MSG(!WIFSTOPPED(status), "Reported stopped process");
+}
+
+static void __used
+forkee_status_continued(int status)
+{
+ FORKEE_ASSERTX(!WIFEXITED(status));
+ FORKEE_ASSERTX(WIFCONTINUED(status));
+ FORKEE_ASSERTX(!WIFSIGNALED(status));
+ FORKEE_ASSERTX(!WIFSTOPPED(status));
+}
+
+static void __used
+validate_status_signaled(int status, int expected_termsig, int expected_core)
+{
+ ATF_REQUIRE_MSG(!WIFEXITED(status), "Reported exited process");
+ ATF_REQUIRE_MSG(!WIFCONTINUED(status), "Reported continued process");
+ ATF_REQUIRE_MSG(WIFSIGNALED(status), "Reported !signaled process");
+ ATF_REQUIRE_MSG(!WIFSTOPPED(status), "Reported stopped process");
+
+ ATF_REQUIRE_EQ_MSG(WTERMSIG(status), expected_termsig,
+ "Unexpected signal received");
+
+ ATF_REQUIRE_EQ_MSG(WCOREDUMP(status), expected_core,
+ "Unexpectedly core file %s generated", expected_core ? "not" : "");
+}
+
+static void __used
+forkee_status_signaled(int status, int expected_termsig, int expected_core)
+{
+ FORKEE_ASSERTX(!WIFEXITED(status));
+ FORKEE_ASSERTX(!WIFCONTINUED(status));
+ FORKEE_ASSERTX(WIFSIGNALED(status));
+ FORKEE_ASSERTX(!WIFSTOPPED(status));
+
+ FORKEE_ASSERT_EQ(WTERMSIG(status), expected_termsig);
+ FORKEE_ASSERT_EQ(WCOREDUMP(status), expected_core);
+}
+
+static void __used
+validate_status_stopped(int status, int expected)
+{
+ ATF_REQUIRE_MSG(!WIFEXITED(status), "Reported exited process");
+ ATF_REQUIRE_MSG(!WIFCONTINUED(status), "Reported continued process");
+ ATF_REQUIRE_MSG(!WIFSIGNALED(status), "Reported signaled process");
+ ATF_REQUIRE_MSG(WIFSTOPPED(status), "Reported !stopped process");
+
+ char st[128], ex[128];
+ strlcpy(st, strsignal(WSTOPSIG(status)), sizeof(st));
+ strlcpy(ex, strsignal(expected), sizeof(ex));
+
+ ATF_REQUIRE_EQ_MSG(WSTOPSIG(status), expected,
+ "Unexpected stop signal received [%s] != [%s]", st, ex);
+}
+
+static void __used
+forkee_status_stopped(int status, int expected)
+{
+ FORKEE_ASSERTX(!WIFEXITED(status));
+ FORKEE_ASSERTX(!WIFCONTINUED(status));
+ FORKEE_ASSERTX(!WIFSIGNALED(status));
+ FORKEE_ASSERTX(WIFSTOPPED(status));
+
+ FORKEE_ASSERT_EQ(WSTOPSIG(status), expected);
+}
+#else
+#define validate_status_exited(a,b)
+#define forkee_status_exited(a,b)
+#define validate_status_continued(a,b)
+#define forkee_status_continued(a,b)
+#define validate_status_signaled(a,b,c)
+#define forkee_status_signaled(a,b,c)
+#define validate_status_stopped(a,b)
+#define forkee_status_stopped(a,b)
+#endif
+
+/* This function is currently designed to be run in the main/parent process */
+static void __used
+await_zombie(pid_t process)
+{
+ struct kinfo_proc2 p;
+ size_t len = sizeof(p);
+
+ const int name[] = {
+ [0] = CTL_KERN,
+ [1] = KERN_PROC2,
+ [2] = KERN_PROC_PID,
+ [3] = process,
+ [4] = sizeof(p),
+ [5] = 1
+ };
+
+ const size_t namelen = __arraycount(name);
+
+ /* Await the process becoming a zombie */
+ while(1) {
+ ATF_REQUIRE(sysctl(name, namelen, &p, &len, NULL, 0) == 0);
+
+ if (p.p_stat == LSZOMB)
+ break;
+
+ ATF_REQUIRE(usleep(1000) == 0);
+ }
+}
+
+/* Happy number sequence -- this function is used to just consume cpu cycles */
+#define HAPPY_NUMBER 1
+
+/* If n is not happy then its sequence ends in the cycle:
+ * 4, 16, 37, 58, 89, 145, 42, 20, 4, ... */
+#define SAD_NUMBER 4
+
+/* Calculate the sum of the squares of the digits of n */
+static unsigned __used
+dsum(unsigned n)
+{
+ unsigned sum, x;
+ for (sum = 0; n; n /= 10) {
+ x = n % 10;
+ sum += x * x;
+ }
+ return sum;
+}
+
+/*
+ * XXX: Disabled optimization is required to make tests for hardware assisted
+ * traps in .text functional
+ *
+ * Tested with GCC 5.4 on NetBSD 7.99.47 amd64
+ */
+static int __used
+#ifdef __clang__
+__attribute__((__optnone__))
+#else
+__attribute__((__optimize__("O0")))
+#endif
+check_happy(unsigned n)
+{
+ for (;;) {
+ unsigned total = dsum(n);
+
+ if (total == HAPPY_NUMBER)
+ return 1;
+ if (total == SAD_NUMBER)
+ return 0;
+
+ n = total;
+ }
+}
+
+#if defined(TWAIT_HAVE_PID)
+#define ATF_TP_ADD_TC_HAVE_PID(a,b) ATF_TP_ADD_TC(a,b)
+#else
+#define ATF_TP_ADD_TC_HAVE_PID(a,b)
+#endif
+
+#if defined(HAVE_GPREGS)
+#define ATF_TP_ADD_TC_HAVE_GPREGS(a,b) ATF_TP_ADD_TC(a,b)
+#else
+#define ATF_TP_ADD_TC_HAVE_GPREGS(a,b)
+#endif
+
+#if defined(HAVE_FPREGS)
+#define ATF_TP_ADD_TC_HAVE_FPREGS(a,b) ATF_TP_ADD_TC(a,b)
+#else
+#define ATF_TP_ADD_TC_HAVE_FPREGS(a,b)
+#endif
+
+#if defined(PT_STEP)
+#define ATF_TP_ADD_TC_PT_STEP(a,b) ATF_TP_ADD_TC(a,b)
+#else
+#define ATF_TP_ADD_TC_PT_STEP(a,b)
+#endif
+
+#if defined(__HAVE_PTRACE_WATCHPOINTS)
+#define ATF_TP_ADD_TC_HAVE_PTRACE_WATCHPOINTS(a,b) ATF_TP_ADD_TC(a,b)
+#else
+#define ATF_TP_ADD_TC_HAVE_PTRACE_WATCHPOINTS(a,b)
+#endif
diff --git a/contrib/netbsd-tests/kernel/t_ptrace_wait3.c b/contrib/netbsd-tests/kernel/t_ptrace_wait3.c
new file mode 100644
index 0000000..c136431
--- /dev/null
+++ b/contrib/netbsd-tests/kernel/t_ptrace_wait3.c
@@ -0,0 +1,30 @@
+/* $NetBSD: t_ptrace_wait3.c,v 1.1 2016/11/07 21:09:03 kamil Exp $ */
+
+/*-
+ * Copyright (c) 2016 The NetBSD Foundation, Inc.
+ * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 TWAIT_WAIT3
+#include "t_ptrace_wait.c"
diff --git a/contrib/netbsd-tests/kernel/t_ptrace_wait4.c b/contrib/netbsd-tests/kernel/t_ptrace_wait4.c
new file mode 100644
index 0000000..7ae771b
--- /dev/null
+++ b/contrib/netbsd-tests/kernel/t_ptrace_wait4.c
@@ -0,0 +1,30 @@
+/* $NetBSD: t_ptrace_wait4.c,v 1.1 2016/11/07 21:09:03 kamil Exp $ */
+
+/*-
+ * Copyright (c) 2016 The NetBSD Foundation, Inc.
+ * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 TWAIT_WAIT4
+#include "t_ptrace_wait.c"
diff --git a/contrib/netbsd-tests/kernel/t_ptrace_wait6.c b/contrib/netbsd-tests/kernel/t_ptrace_wait6.c
new file mode 100644
index 0000000..122cb1d
--- /dev/null
+++ b/contrib/netbsd-tests/kernel/t_ptrace_wait6.c
@@ -0,0 +1,30 @@
+/* $NetBSD: t_ptrace_wait6.c,v 1.1 2016/11/07 21:09:03 kamil Exp $ */
+
+/*-
+ * Copyright (c) 2016 The NetBSD Foundation, Inc.
+ * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 TWAIT_WAIT6
+#include "t_ptrace_wait.c"
diff --git a/contrib/netbsd-tests/kernel/t_ptrace_waitid.c b/contrib/netbsd-tests/kernel/t_ptrace_waitid.c
new file mode 100644
index 0000000..1c09be7
--- /dev/null
+++ b/contrib/netbsd-tests/kernel/t_ptrace_waitid.c
@@ -0,0 +1,30 @@
+/* $NetBSD: t_ptrace_waitid.c,v 1.1 2016/11/07 21:09:03 kamil Exp $ */
+
+/*-
+ * Copyright (c) 2016 The NetBSD Foundation, Inc.
+ * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 TWAIT_WAITID
+#include "t_ptrace_wait.c"
diff --git a/contrib/netbsd-tests/kernel/t_ptrace_waitpid.c b/contrib/netbsd-tests/kernel/t_ptrace_waitpid.c
new file mode 100644
index 0000000..c8f107d
--- /dev/null
+++ b/contrib/netbsd-tests/kernel/t_ptrace_waitpid.c
@@ -0,0 +1,30 @@
+/* $NetBSD: t_ptrace_waitpid.c,v 1.1 2016/11/07 21:09:03 kamil Exp $ */
+
+/*-
+ * Copyright (c) 2016 The NetBSD Foundation, Inc.
+ * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 TWAIT_WAITPID
+#include "t_ptrace_wait.c"
diff --git a/contrib/netbsd-tests/lib/libc/arch/sparc64/exec_prot_support.c b/contrib/netbsd-tests/lib/libc/arch/sparc64/exec_prot_support.c
index 474cfc7..8ca38b4 100644
--- a/contrib/netbsd-tests/lib/libc/arch/sparc64/exec_prot_support.c
+++ b/contrib/netbsd-tests/lib/libc/arch/sparc64/exec_prot_support.c
@@ -1,4 +1,4 @@
-/* $NetBSD: exec_prot_support.c,v 1.1 2011/07/18 23:16:10 jym Exp $ */
+/* $NetBSD: exec_prot_support.c,v 1.2 2016/12/31 11:51:20 martin Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -30,12 +30,13 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: exec_prot_support.c,v 1.1 2011/07/18 23:16:10 jym Exp $");
+__RCSID("$NetBSD: exec_prot_support.c,v 1.2 2016/12/31 11:51:20 martin Exp $");
#include "../../common/exec_prot.h"
int
exec_prot_support(void)
{
- return NOTIMPL;
+
+ return PERPAGE_XP;
}
diff --git a/contrib/netbsd-tests/lib/libc/arch/sparc64/return_one.S b/contrib/netbsd-tests/lib/libc/arch/sparc64/return_one.S
index 3495260..ec8bcdd 100644
--- a/contrib/netbsd-tests/lib/libc/arch/sparc64/return_one.S
+++ b/contrib/netbsd-tests/lib/libc/arch/sparc64/return_one.S
@@ -1,8 +1,11 @@
-/* $NetBSD: return_one.S,v 1.1 2011/07/18 23:16:10 jym Exp $ */
+/* $NetBSD: return_one.S,v 1.2 2016/12/31 11:51:20 martin Exp $ */
#include <machine/asm.h>
-.globl return_one, return_one_end;
+.global return_one_end
-return_one: return_one_end:
- nop
+ENTRY(return_one)
+return_one:
+ retl
+ mov 1, %o0
+return_one_end:
diff --git a/contrib/netbsd-tests/lib/libc/db/h_db.c b/contrib/netbsd-tests/lib/libc/db/h_db.c
index dfb1385..dd19a03 100644
--- a/contrib/netbsd-tests/lib/libc/db/h_db.c
+++ b/contrib/netbsd-tests/lib/libc/db/h_db.c
@@ -1,4 +1,4 @@
-/* $NetBSD: h_db.c,v 1.1 2011/01/07 15:05:58 pgoyette Exp $ */
+/* $NetBSD: h_db.c,v 1.3 2016/09/24 21:18:22 christos Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1992, 1993, 1994\
#if 0
static char sccsid[] = "@(#)dbtest.c 8.17 (Berkeley) 9/1/94";
#else
-__RCSID("$NetBSD: h_db.c,v 1.1 2011/01/07 15:05:58 pgoyette Exp $");
+__RCSID("$NetBSD: h_db.c,v 1.3 2016/09/24 21:18:22 christos Exp $");
#endif
#endif /* not lint */
@@ -57,12 +57,13 @@ __RCSID("$NetBSD: h_db.c,v 1.1 2011/01/07 15:05:58 pgoyette Exp $");
#include <unistd.h>
#include <err.h>
#include <db.h>
+#include "btree.h"
enum S { COMMAND, COMPARE, GET, PUT, REMOVE, SEQ, SEQFLAG, KEY, DATA };
static void compare(DBT *, DBT *);
static DBTYPE dbtype(const char *);
-static void dump(DB *, int);
+static void dump(DB *, int, int);
static void get(DB *, DBT *);
static void getdata(DB *, DBT *, DBT *);
static void put(DB *, DBT *, DBT *);
@@ -73,6 +74,9 @@ static void *rfile(char *, size_t *);
static void seq(DB *, DBT *);
static u_int setflags(char *);
static void *setinfo(DBTYPE, char *);
+#ifdef __NetBSD__
+static void unlinkpg(DB *);
+#endif
static void usage(void) __attribute__((__noreturn__));
static void *xcopy(void *, size_t);
static void chkcmd(enum S);
@@ -82,6 +86,9 @@ static void chkkey(enum S);
#ifdef STATISTICS
extern void __bt_stat(DB *);
#endif
+#ifdef __NetBSD__
+extern int __bt_relink(BTREE *, PAGE *);
+#endif
static DBTYPE type; /* Database type. */
static void *infop; /* Iflags. */
@@ -315,8 +322,16 @@ lkey: switch (command) {
}
break;
case 'o':
- dump(dbp, p[1] == 'r');
+ dump(dbp, p[1] == 'r', 0);
+ break;
+#ifdef __NetBSD__
+ case 'O':
+ dump(dbp, p[1] == 'r', 1);
break;
+ case 'u':
+ unlinkpg(dbp);
+ break;
+#endif
default:
errx(1, "line %zu: %s: unknown command character",
lineno, p);
@@ -483,17 +498,25 @@ seq(DB *dbp, DBT *kp)
}
static void
-dump(DB *dbp, int rev)
+dump(DB *dbp, int rev, int recurse)
{
DBT key, data;
int xflags, nflags;
if (rev) {
xflags = R_LAST;
+#ifdef __NetBSD__
+ nflags = recurse ? R_RPREV : R_PREV;
+#else
nflags = R_PREV;
+#endif
} else {
xflags = R_FIRST;
+#ifdef __NetBSD__
+ nflags = recurse ? R_RNEXT : R_NEXT;
+#else
nflags = R_NEXT;
+#endif
}
for (;; xflags = nflags)
switch (dbp->seq(dbp, &key, &data, xflags)) {
@@ -511,6 +534,42 @@ dump(DB *dbp, int rev)
done: return;
}
+#ifdef __NetBSD__
+void
+unlinkpg(DB *dbp)
+{
+ BTREE *t = dbp->internal;
+ PAGE *h = NULL;
+ pgno_t pg;
+
+ for (pg = P_ROOT; pg < t->bt_mp->npages;
+ mpool_put(t->bt_mp, h, 0), pg++) {
+ if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL)
+ break;
+ /* Look for a nonempty leaf page that has both left
+ * and right siblings. */
+ if (h->prevpg == P_INVALID || h->nextpg == P_INVALID)
+ continue;
+ if (NEXTINDEX(h) == 0)
+ continue;
+ if ((h->flags & (P_BLEAF | P_RLEAF)))
+ break;
+ }
+ if (h == NULL || pg == t->bt_mp->npages) {
+ errx(1, "%s: no appropriate page found", __func__);
+ return;
+ }
+ if (__bt_relink(t, h) != 0) {
+ perror("unlinkpg");
+ goto cleanup;
+ }
+ h->prevpg = P_INVALID;
+ h->nextpg = P_INVALID;
+cleanup:
+ mpool_put(t->bt_mp, h, MPOOL_DIRTY);
+}
+#endif
+
static u_int
setflags(char *s)
{
@@ -725,7 +784,11 @@ static void
usage(void)
{
(void)fprintf(stderr,
- "Usage: %s [-l] [-f file] [-i info] [-o file] type script\n",
- getprogname());
+#ifdef __NetBSD__
+ "Usage: %s [-lu] [-f file] [-i info] [-o file] [-O file] "
+#else
+ "Usage: %s [-l] [-f file] [-i info] [-o file] "
+#endif
+ "type script\n", getprogname());
exit(1);
}
diff --git a/contrib/netbsd-tests/lib/libc/db/t_db.sh b/contrib/netbsd-tests/lib/libc/db/t_db.sh
index eb6b8c9..6858e36 100755
--- a/contrib/netbsd-tests/lib/libc/db/t_db.sh
+++ b/contrib/netbsd-tests/lib/libc/db/t_db.sh
@@ -1,4 +1,4 @@
-# $NetBSD: t_db.sh,v 1.6 2015/11/18 18:35:35 christos Exp $
+# $NetBSD: t_db.sh,v 1.7 2016/09/24 20:12:33 christos Exp $
#
# Copyright (c) 2008 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -563,6 +563,7 @@ delete_recno_body()
h_repeated()
{
+ local type="$1"
TMPDIR="$(pwd)/db_dir"; export TMPDIR
mkdir ${TMPDIR}
@@ -581,7 +582,7 @@ h_repeated()
}
}' >in
- $(prog_db) btree in
+ $(prog_db) $type in
}
atf_test_case repeated_btree
@@ -641,11 +642,10 @@ duplicate_btree_body()
h_cursor_flags()
{
+ local type=$1
TMPDIR="$(pwd)/db_dir"; export TMPDIR
mkdir ${TMPDIR}
- type=$1
-
echo $SEVEN_SEVEN |
awk '{
for (i = 1; i <= 20; ++i)
@@ -784,6 +784,7 @@ h_byte_orders()
echo p
echo k$i
echo d$i
+ echo S
echo g
echo k$i
done >in
@@ -974,6 +975,298 @@ bsize_torture_body()
done
}
+atf_test_case btree_weird_page_split
+btree_weird_page_split_head()
+{
+ atf_set "descr" \
+ "Test for a weird page split condition where an insertion " \
+ "into index 0 of a page that would cause the new item to " \
+ "be the only item on the left page results in index 0 of " \
+ "the right page being erroneously skipped; this only " \
+ "happens with one particular key+data length for each page size."
+}
+btree_weird_page_split_body()
+{
+ for psize in 512 1024 2048 4096 8192; do
+ echo " page size $psize"
+ kdsizes=`awk 'BEGIN {
+ psize = '$psize'; hsize = int(psize/2);
+ for (kdsize = hsize-40; kdsize <= hsize; kdsize++) {
+ print kdsize;
+ }
+ }' /dev/null`
+
+ # Use a series of keylen+datalen values in the right
+ # neighborhood to find the one that triggers the bug.
+ # We could compute the exact size that triggers the
+ # bug but this additional fuzz may be useful.
+
+ # Insert keys in reverse order to maximize the chances
+ # for a split on index 0.
+
+ for kdsize in $kdsizes; do
+ awk 'BEGIN {
+ kdsize = '$kdsize';
+ for (i = 8; i-- > 0; ) {
+ s = sprintf("a%03d:%09d", i, kdsize);
+ for (j = 0; j < kdsize-20; j++) {
+ s = s "x";
+ }
+ printf("p\nka%03d\nd%s\n", i, s);
+ }
+ print "o";
+ }' /dev/null > in
+ sed -n 's/^d//p' in | sort > exp
+ atf_check -o file:exp \
+ "$(prog_db)" -i psize=$psize btree in
+ done
+ done
+}
+
+# Extremely tricky test attempting to replicate some unusual database
+# corruption seen in the field: pieces of the database becoming
+# inaccessible to random access, sequential access, or both. The
+# hypothesis is that at least some of these are triggered by the bug
+# in page splits on index 0 with a particular exact keylen+datalen.
+# (See Test 40.) For psize=4096, this size is exactly 2024.
+
+# The order of operations here relies on very specific knowledge of
+# the internals of the btree access method in order to place records
+# at specific offsets in a page and to create certain keys on internal
+# pages. The to-be-split page immediately prior to the bug-triggering
+# split has the following properties:
+#
+# * is not the leftmost leaf page
+# * key on the parent page is compares less than the key of the item
+# on index 0
+# * triggering record's key also compares greater than the key on the
+# parent page
+
+# Additionally, we prime the mpool LRU chain so that the head page on
+# the chain has the following properties:
+#
+# * record at index 0 is located where it will not get overwritten by
+# items written to the right-hand page during the split
+# * key of the record at index 0 compares less than the key of the
+# bug-triggering record
+
+# If the page-split bug exists, this test appears to create a database
+# where some records are inaccessible to a search, but still remain in
+# the file and are accessible by sequential traversal. At least one
+# record gets duplicated out of sequence.
+
+atf_test_case btree_tricky_page_split
+btree_tricky_page_split_head()
+{
+ atf_set "descr" \
+ "btree: no unsearchables due to page split on index 0"
+}
+btree_tricky_page_split_body()
+{
+ list=`(for i in a b c d; do
+ for j in 990 998 999; do
+ echo g ${i}${j} 1024
+ done
+ done;
+ echo g y997 2014
+ for i in y z; do
+ for j in 998 999; do
+ echo g ${i}${j} 1024
+ done
+ done)`
+ # Exact number for trigger condition accounts for newlines
+ # retained by dbtest with -ofile but not without; we use
+ # -ofile, so count newlines. keylen=5,datalen=5+2014 for
+ # psize=4096 here.
+ (cat - <<EOF
+p z999 1024
+p z998 1024
+p y999 1024
+p y990 1024
+p d999 1024
+p d990 1024
+p c999 1024
+p c990 1024
+p b999 1024
+p b990 1024
+p a999 1024
+p a990 1024
+p y998 1024
+r y990
+p d998 1024
+p d990 1024
+p c998 1024
+p c990 1024
+p b998 1024
+p b990 1024
+p a998 1024
+p a990 1024
+p y997 2014
+S
+o
+EOF
+ echo "$list") |
+ # awk script input:
+ # {p|g|r} key [datasize]
+ awk '/^[pgr]/{
+ printf("%s\nk%s\n", $1, $2);
+ }
+ /^p/{
+ s = $2;
+ for (i = 0; i < $3; i++) {
+ s = s "x";
+ }
+ printf("d%s\n", s);
+ }
+ !/^[pgr]/{
+ print $0;
+ }' > in
+ (echo "$list"; echo "$list") | awk '{
+ s = $2;
+ for (i = 0; i < $3; i++) {
+ s = s "x";
+ }
+ print s;
+ }' > exp
+ atf_check -o file:exp \
+ "$(prog_db)" -i psize=4096 btree in
+}
+
+# Begin FreeBSD
+if false; then
+# End FreeBSD
+atf_test_case btree_recursive_traversal
+btree_recursive_traversal_head()
+{
+ atf_set "descr" \
+ "btree: Test for recursive traversal successfully " \
+ "retrieving records that are inaccessible to normal " \
+ "sequential 'sibling-link' traversal. This works by " \
+ "unlinking a few leaf pages but leaving their parent " \
+ "links intact. To verify that the unlink actually makes " \
+ "records inaccessible, the test first uses 'o' to do a " \
+ "normal sequential traversal, followed by 'O' to do a " \
+ "recursive traversal."
+}
+btree_recursive_traversal_body()
+{
+ fill="abcdefghijklmnopqrstuvwxyzy"
+ script='{
+ for (i = 0; i < 20000; i++) {
+ printf("p\nkAA%05d\nd%05d%s\n", i, i, $0);
+ }
+ print "u";
+ print "u";
+ print "u";
+ print "u";
+ }'
+ (echo $fill | awk "$script"; echo o) > in1
+ echo $fill |
+ awk '{
+ for (i = 0; i < 20000; i++) {
+ if (i >= 5 && i <= 40)
+ continue;
+ printf("%05d%s\n", i, $0);
+ }
+ }' > exp1
+ atf_check -o file:exp1 \
+ "$(prog_db)" -i psize=512 btree in1
+ echo $fill |
+ awk '{
+ for (i = 0; i < 20000; i++) {
+ printf("%05d%s\n", i, $0);
+ }
+ }' > exp2
+ (echo $fill | awk "$script"; echo O) > in2
+ atf_check -o file:exp2 \
+ "$(prog_db)" -i psize=512 btree in2
+}
+# Begin FreeBSD
+fi
+# End FreeBSD
+
+atf_test_case btree_byteswap_unaligned_access_bksd
+btree_byteswap_unaligned_access_bksd_head()
+{
+ atf_set "descr" \
+ "btree: big key, small data, byteswap unaligned access"
+}
+btree_byteswap_unaligned_access_bksd_body()
+{
+ (echo foo; echo bar) |
+ awk '{
+ s = $0
+ for (i = 0; i < 488; i++) {
+ s = s "x";
+ }
+ printf("p\nk%s\ndx\n", s);
+ }' > in
+ for order in 1234 4321; do
+ atf_check \
+ "$(prog_db)" -o out -i psize=512,lorder=$order btree in
+ done
+}
+
+atf_test_case btree_byteswap_unaligned_access_skbd
+btree_byteswap_unaligned_access_skbd_head()
+{
+ atf_set "descr" \
+ "btree: small key, big data, byteswap unaligned access"
+}
+btree_byteswap_unaligned_access_skbd_body()
+{
+ # 484 = 512 - 20 (header) - 7 ("foo1234") - 1 (newline)
+ (echo foo1234; echo bar1234) |
+ awk '{
+ s = $0
+ for (i = 0; i < 484; i++) {
+ s = s "x";
+ }
+ printf("p\nk%s\nd%s\n", $0, s);
+ }' > in
+ for order in 1234 4321; do
+ atf_check \
+ "$(prog_db)" -o out -i psize=512,lorder=$order btree in
+ done
+}
+
+atf_test_case btree_known_byte_order
+btree_known_byte_order_head()
+{
+ atf_set "descr" \
+ "btree: small key, big data, known byte order"
+}
+btree_known_byte_order_body()
+{
+ local a="-i psize=512,lorder="
+
+ (echo foo1234; echo bar1234) |
+ awk '{
+ s = $0
+ for (i = 0; i < 484; i++) {
+ s = s "x";
+ }
+ printf("%s\n", s);
+ }' > exp
+ (echo foo1234; echo bar1234) |
+ awk '{
+ s = $0
+ for (i = 0; i < 484; i++) {
+ s = s "x";
+ }
+ printf("p\nk%s\nd%s\n", $0, s);
+ }' > in1
+ for order in 1234 4321; do
+ atf_check \
+ "$(prog_db)" -f out.$order $a$order btree in1
+ done
+ (echo g; echo kfoo1234; echo g; echo kbar1234) > in2
+ for order in 1234 4321; do
+ atf_check -o file:exp \
+ "$(prog_db)" -s -f out.$order $a$order btree in2
+ done
+}
+
atf_init_test_cases()
{
atf_add_test_case small_btree
@@ -1002,4 +1295,16 @@ atf_init_test_cases()
atf_add_test_case bsize_ffactor
atf_add_test_case four_char_hash
atf_add_test_case bsize_torture
+ atf_add_test_case btree_weird_page_split
+ atf_add_test_case btree_tricky_page_split
+ # Begin FreeBSD
+ if false; then
+ # End FreeBSD
+ atf_add_test_case btree_recursive_traversal
+ # Begin FreeBSD
+ fi
+ # End FreeBSD
+ atf_add_test_case btree_byteswap_unaligned_access_bksd
+ atf_add_test_case btree_byteswap_unaligned_access_skbd
+ atf_add_test_case btree_known_byte_order
}
diff --git a/contrib/netbsd-tests/lib/libc/gen/t_dir.c b/contrib/netbsd-tests/lib/libc/gen/t_dir.c
index c058738..362692f 100644
--- a/contrib/netbsd-tests/lib/libc/gen/t_dir.c
+++ b/contrib/netbsd-tests/lib/libc/gen/t_dir.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_dir.c,v 1.8 2017/01/11 07:26:17 christos Exp $ */
+/* $NetBSD: t_dir.c,v 1.10 2017/01/11 18:15:02 christos Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -75,33 +75,40 @@ ATF_TC_BODY(seekdir_basic, tc)
/* skip two for . and .. */
entry = readdir(dp);
+ ATF_REQUIRE_MSG(entry != NULL, "readdir[%s] failed: %s",
+ ".", strerror(errno));
+
entry = readdir(dp);
+ ATF_REQUIRE_MSG(entry != NULL, "readdir[%s] failed: %s",
+ "..", strerror(errno));
/* get first entry */
entry = readdir(dp);
+ ATF_REQUIRE_MSG(entry != NULL, "readdir[%s] failed: %s",
+ "first", strerror(errno));
+
here = telldir(dp);
- ATF_REQUIRE_MSG(here != -1,
- "telldir failed: %s", strerror(errno));
+ ATF_REQUIRE_MSG(here != -1, "telldir failed: %s", strerror(errno));
/* get second entry */
entry = readdir(dp);
-#ifdef __FreeBSD__
- ATF_REQUIRE_MSG(entry != NULL,
- "readdir failed: %s", strerror(errno));
-#endif
+ ATF_REQUIRE_MSG(entry != NULL, "readdir[%s] failed: %s",
+ "second", strerror(errno));
+
wasname = strdup(entry->d_name);
if (wasname == NULL)
atf_tc_fail("cannot allocate memory");
/* get third entry */
entry = readdir(dp);
+ ATF_REQUIRE_MSG(entry != NULL, "readdir[%s] failed: %s",
+ "third", strerror(errno));
/* try to return to the position after the first entry */
seekdir(dp, here);
entry = readdir(dp);
-
- if (entry == NULL)
- atf_tc_fail("entry 1 not found");
+ ATF_REQUIRE_MSG(entry != NULL, "readdir[%s] failed: %s",
+ "first[1]", strerror(errno));
if (strcmp(entry->d_name, wasname) != 0)
atf_tc_fail("1st seekdir found wrong name");
@@ -109,18 +116,17 @@ ATF_TC_BODY(seekdir_basic, tc)
seekdir(dp, here);
here = telldir(dp);
entry = readdir(dp);
-
- if (entry == NULL)
- atf_tc_fail("entry 2 not found");
+ ATF_REQUIRE_MSG(entry != NULL, "readdir[%s] failed: %s",
+ "second[1]", strerror(errno));
if (strcmp(entry->d_name, wasname) != 0)
atf_tc_fail("2nd seekdir found wrong name");
/* One more time, to make sure that telldir() doesn't affect result */
seekdir(dp, here);
entry = readdir(dp);
+ ATF_REQUIRE_MSG(entry != NULL, "readdir[%s] failed: %s",
+ "third[1]", strerror(errno));
- if (entry == NULL)
- atf_tc_fail("entry 3 not found");
if (strcmp(entry->d_name, wasname) != 0)
atf_tc_fail("3rd seekdir found wrong name");
diff --git a/contrib/netbsd-tests/lib/libc/gen/t_floatunditf.c b/contrib/netbsd-tests/lib/libc/gen/t_floatunditf.c
index ef372f7..c3417bb 100644
--- a/contrib/netbsd-tests/lib/libc/gen/t_floatunditf.c
+++ b/contrib/netbsd-tests/lib/libc/gen/t_floatunditf.c
@@ -119,6 +119,11 @@ ATF_TC_BODY(floatunditf, tc)
#else
size_t i;
+#if defined(__FreeBSD__) && defined(__i386__)
+ atf_tc_expect_fail("the floating point error on FreeBSD/i386 doesn't "
+ "match the expected floating point error on NetBSD");
+#endif
+
for (i = 0; i < __arraycount(testcases); ++i)
ATF_CHECK_MSG(
testcases[i].ld == (long double)testcases[i].u64,
diff --git a/contrib/netbsd-tests/lib/libc/gen/t_fnmatch.c b/contrib/netbsd-tests/lib/libc/gen/t_fnmatch.c
index c0064c3..69ee8d2 100644
--- a/contrib/netbsd-tests/lib/libc/gen/t_fnmatch.c
+++ b/contrib/netbsd-tests/lib/libc/gen/t_fnmatch.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_fnmatch.c,v 1.6 2014/10/12 22:33:41 christos Exp $ */
+/* $NetBSD: t_fnmatch.c,v 1.7 2016/10/31 05:08:53 dholland Exp $ */
/*-
* Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_fnmatch.c,v 1.6 2014/10/12 22:33:41 christos Exp $");
+__RCSID("$NetBSD: t_fnmatch.c,v 1.7 2016/10/31 05:08:53 dholland Exp $");
#include <atf-c.h>
#include <fnmatch.h>
@@ -166,6 +166,7 @@ ATF_TC_BODY(fnmatch_initialbracket, tc)
ATF_CHECK(fnmatch("[!]a-]", "b", 0) == 0);
ATF_CHECK(fnmatch("[]-_]", "^", 0) == 0); /* range: ']', '^', '_' */
ATF_CHECK(fnmatch("[!]-_]", "X", 0) == 0);
+ ATF_CHECK(fnmatch("[A-\\\\]", "[", 0) == 0);
ATF_CHECK(fnmatch("[a-z]/[a-z]", "a/b", 0) == 0);
ATF_CHECK(fnmatch("[*]/b", "*/b", 0) == 0);
ATF_CHECK(fnmatch("[?]/b", "?/b", 0) == 0);
diff --git a/contrib/netbsd-tests/lib/libc/rpc/t_rpc.c b/contrib/netbsd-tests/lib/libc/rpc/t_rpc.c
index 28a8763..bce3633 100644
--- a/contrib/netbsd-tests/lib/libc/rpc/t_rpc.c
+++ b/contrib/netbsd-tests/lib/libc/rpc/t_rpc.c
@@ -1,7 +1,7 @@
-/* $NetBSD: t_rpc.c,v 1.9 2015/11/27 13:59:40 christos Exp $ */
+/* $NetBSD: t_rpc.c,v 1.10 2016/08/27 14:36:22 christos Exp $ */
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_rpc.c,v 1.9 2015/11/27 13:59:40 christos Exp $");
+__RCSID("$NetBSD: t_rpc.c,v 1.10 2016/08/27 14:36:22 christos Exp $");
#include <sys/types.h>
#include <sys/socket.h>
@@ -21,7 +21,7 @@ __RCSID("$NetBSD: t_rpc.c,v 1.9 2015/11/27 13:59:40 christos Exp $");
#define SKIPX(ev, msg, ...) do { \
atf_tc_skip(msg, __VA_ARGS__); \
- return; \
+ return ev; \
} while(/*CONSTCOND*/0)
#ifdef __FreeBSD__
@@ -32,8 +32,8 @@ __RCSID("$NetBSD: t_rpc.c,v 1.9 2015/11/27 13:59:40 christos Exp $");
#endif
#else
-#define ERRX(ev, msg, ...) errx(ev, msg, __VA_ARGS__)
-#define SKIPX(ev, msg, ...) errx(ev, msg, __VA_ARGS__)
+#define ERRX(ev, msg, ...) errx(EXIT_FAILURE, msg, __VA_ARGS__)
+#define SKIPX(ev, msg, ...) errx(EXIT_FAILURE, msg, __VA_ARGS__)
#endif
#ifdef DEBUG
@@ -83,7 +83,7 @@ onehost(const char *host, const char *transp)
__rpc_control(CLCR_SET_RPCB_TIMEOUT, &tv);
if ((clnt = clnt_create(host, RPCBPROG, RPCBVERS, transp)) == NULL)
- SKIPX(EXIT_FAILURE, "clnt_create (%s)", clnt_spcreateerror(""));
+ SKIPX(, "clnt_create (%s)", clnt_spcreateerror(""));
tv.tv_sec = 1;
tv.tv_usec = 0;
@@ -95,7 +95,7 @@ onehost(const char *host, const char *transp)
if (clnt_call(clnt, RPCBPROC_NULL, xdr_void, NULL, xdr_void, NULL, tv)
!= RPC_SUCCESS)
#endif
- ERRX(EXIT_FAILURE, "clnt_call (%s)", clnt_sperror(clnt, ""));
+ ERRX(, "clnt_call (%s)", clnt_sperror(clnt, ""));
clnt_control(clnt, CLGET_SVC_ADDR, (char *) &addr);
reply(NULL, &addr, NULL);
}
@@ -117,13 +117,13 @@ server(struct svc_req *rqstp, SVCXPRT *transp)
switch (rqstp->rq_proc) {
case NULLPROC:
if (!svc_sendreply(transp, (xdrproc_t)xdr_void, NULL))
- ERRX(EXIT_FAILURE, "svc_sendreply failed %d", 0);
+ ERRX(, "svc_sendreply failed %d", 0);
return;
case PLUSONE:
break;
case DESTROY:
if (!svc_sendreply(transp, (xdrproc_t)xdr_void, NULL))
- ERRX(EXIT_FAILURE, "svc_sendreply failed %d", 0);
+ ERRX(, "svc_sendreply failed %d", 0);
svc_destroy(transp);
exit(0);
default:
@@ -138,7 +138,7 @@ server(struct svc_req *rqstp, SVCXPRT *transp)
DPRINTF("About to increment\n");
num++;
if (!svc_sendreply(transp, (xdrproc_t)xdr_int, (void *)&num))
- ERRX(EXIT_FAILURE, "svc_sendreply failed %d", 1);
+ ERRX(, "svc_sendreply failed %d", 1);
DPRINTF("Leaving server procedure.\n");
}
@@ -195,13 +195,9 @@ regtest(const char *hostname, const char *transp, const char *arg, int p)
svc_fdset_init(p ? SVC_FDSET_POLL : 0);
#endif
if (!svc_create(server, PROGNUM, VERSNUM, transp))
-#ifdef __NetBSD__
- ERRX(EXIT_FAILURE, "Cannot create server %d", num);
-#else
{
SKIPXI(EXIT_FAILURE, "Cannot create server %d", num);
}
-#endif
switch ((pid = fork())) {
case 0:
diff --git a/contrib/netbsd-tests/lib/libc/string/t_memcpy.c b/contrib/netbsd-tests/lib/libc/string/t_memcpy.c
index 5bbd924..64cdb29 100644
--- a/contrib/netbsd-tests/lib/libc/string/t_memcpy.c
+++ b/contrib/netbsd-tests/lib/libc/string/t_memcpy.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_memcpy.c,v 1.5 2013/03/17 02:23:31 christos Exp $ */
+/* $NetBSD: t_memcpy.c,v 1.6 2017/01/11 18:05:54 christos Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -108,12 +108,8 @@ ATF_TC_BODY(memcpy_basic, tc)
if (i != j)
runTest(start[i], start[j]);
MD5End(mc, result);
-#ifdef __NetBSD__
- ATF_REQUIRE_EQ(strcmp(result, goodResult), 0);
-#else
ATF_REQUIRE_EQ_MSG(strcmp(result, goodResult), 0, "%s != %s",
result, goodResult);
-#endif
}
ATF_TC(memccpy_simple);
diff --git a/contrib/netbsd-tests/lib/libc/string/t_memmem.c b/contrib/netbsd-tests/lib/libc/string/t_memmem.c
index 5807662..2f37788 100644
--- a/contrib/netbsd-tests/lib/libc/string/t_memmem.c
+++ b/contrib/netbsd-tests/lib/libc/string/t_memmem.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_memmem.c,v 1.2 2011/07/07 08:27:36 jruoho Exp $ */
+/* $NetBSD: t_memmem.c,v 1.3 2017/01/11 18:07:37 christos Exp $ */
/*-
* Copyright (c) 2005 The NetBSD Foundation, Inc.
diff --git a/contrib/netbsd-tests/lib/libc/sync/cpp_atomic_ops_linkable.cc b/contrib/netbsd-tests/lib/libc/sync/cpp_atomic_ops_linkable.cc
index 7426851..e7822b7 100644
--- a/contrib/netbsd-tests/lib/libc/sync/cpp_atomic_ops_linkable.cc
+++ b/contrib/netbsd-tests/lib/libc/sync/cpp_atomic_ops_linkable.cc
@@ -1,4 +1,4 @@
-/* $NetBSD: cpp_atomic_ops_linkable.cc,v 1.4 2016/02/27 18:50:39 joerg Exp $ */
+/* $NetBSD: cpp_atomic_ops_linkable.cc,v 1.5 2017/01/11 12:10:26 joerg Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -58,19 +58,13 @@ private:
volatile std::atomic<T> m_val;
};
-#if defined(__clang__) && defined(__sparc64__)
-#define NO_SHORT_ATOMICS
-#endif
-
int main(int argc, char **argv)
{
-#ifndef NO_SHORT_ATOMICS
ATest<char>();
ATest<signed char>();
ATest<unsigned char>();
ATest<short>();
ATest<unsigned short>();
-#endif
ATest<int>();
ATest<unsigned int>();
ATest<long>();
@@ -79,29 +73,23 @@ int main(int argc, char **argv)
ATest<long long>();
ATest<unsigned long long>();
#endif
-#ifndef NO_SHORT_ATOMICS
ATest<char16_t>();
-#endif
ATest<char32_t>();
ATest<wchar_t>();
-#ifndef NO_SHORT_ATOMICS
ATest<int_least8_t>();
ATest<uint_least8_t>();
ATest<int_least16_t>();
ATest<uint_least16_t>();
-#endif
ATest<int_least32_t>();
ATest<uint_least32_t>();
#ifdef __HAVE_ATOMIC64_OPS
ATest<int_least64_t>();
ATest<uint_least64_t>();
#endif
-#ifndef NO_SHORT_ATOMICS
ATest<int_fast8_t>();
ATest<uint_fast8_t>();
ATest<int_fast16_t>();
ATest<uint_fast16_t>();
-#endif
ATest<int_fast32_t>();
ATest<uint_fast32_t>();
#ifdef __HAVE_ATOMIC64_OPS
@@ -115,5 +103,5 @@ int main(int argc, char **argv)
#ifdef __HAVE_ATOMIC64_OPS
ATest<intmax_t>();
ATest<uintmax_t>();
-#endif /* NO_SHORT_ATOMICS */
+#endif
}
diff --git a/contrib/netbsd-tests/lib/libc/sys/t_clock_nanosleep.c b/contrib/netbsd-tests/lib/libc/sys/t_clock_nanosleep.c
new file mode 100644
index 0000000..8c1fd03
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libc/sys/t_clock_nanosleep.c
@@ -0,0 +1,63 @@
+/* $NetBSD: t_clock_nanosleep.c,v 1.1 2016/11/11 15:30:44 njoly Exp $ */
+
+/*-
+ * Copyright (c) 2016 The NetBSD Foundation, Inc.
+ * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+ */
+
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: t_clock_nanosleep.c,v 1.1 2016/11/11 15:30:44 njoly Exp $");
+
+#include <atf-c.h>
+#include <time.h>
+
+ATF_TC(clock_nanosleep_remain);
+ATF_TC_HEAD(clock_nanosleep_remain, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Check clock_nanosleep(2) remaining time");
+}
+
+ATF_TC_BODY(clock_nanosleep_remain, tc)
+{
+ struct timespec rqtp, rmtp;
+
+ rqtp.tv_sec = 0; rqtp.tv_nsec = 0;
+ rmtp.tv_sec = -1; rmtp.tv_nsec = -1;
+ ATF_REQUIRE(clock_nanosleep(CLOCK_REALTIME, 0, &rqtp, &rmtp) == 0);
+ ATF_CHECK(rmtp.tv_sec == 0 && rmtp.tv_nsec == 0);
+
+ ATF_REQUIRE(clock_gettime(CLOCK_REALTIME, &rqtp) == 0);
+ rmtp.tv_sec = -1; rmtp.tv_nsec = -1;
+ ATF_REQUIRE(clock_nanosleep(CLOCK_REALTIME, TIMER_ABSTIME, &rqtp, &rmtp) == 0);
+ ATF_CHECK(rmtp.tv_sec == -1 && rmtp.tv_nsec == -1);
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+
+ ATF_TP_ADD_TC(tp, clock_nanosleep_remain);
+
+ return atf_no_error();
+}
diff --git a/contrib/netbsd-tests/lib/libc/sys/t_getrusage.c b/contrib/netbsd-tests/lib/libc/sys/t_getrusage.c
index aa5c4d5..f4ee96b 100644
--- a/contrib/netbsd-tests/lib/libc/sys/t_getrusage.c
+++ b/contrib/netbsd-tests/lib/libc/sys/t_getrusage.c
@@ -56,6 +56,10 @@ sighandler(int signo)
/* Nothing. */
}
+#ifdef __FreeBSD__
+#define asm __asm
+#endif
+
static void
work(void)
{
diff --git a/contrib/netbsd-tests/lib/libc/sys/t_wait_noproc.c b/contrib/netbsd-tests/lib/libc/sys/t_wait_noproc.c
new file mode 100644
index 0000000..e5ddcbd
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libc/sys/t_wait_noproc.c
@@ -0,0 +1,345 @@
+/* $NetBSD: t_wait_noproc.c,v 1.5 2016/11/09 17:50:19 kamil Exp $ */
+
+/*-
+ * Copyright (c) 2016 The NetBSD Foundation, Inc.
+ * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+ */
+
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: t_wait_noproc.c,v 1.5 2016/11/09 17:50:19 kamil Exp $");
+
+#ifdef __FreeBSD__
+#include <sys/param.h> /* For NBBY -- it's in sys/types.h on NetBSD */
+#endif
+#include <sys/wait.h>
+#include <sys/resource.h>
+
+#include <errno.h>
+#include <stdio.h>
+
+#include <atf-c.h>
+
+#ifndef TWAIT_OPTION
+#define TWAIT_OPTION 0
+#endif
+
+#if TWAIT_OPTION == 0
+ATF_TC(wait);
+ATF_TC_HEAD(wait, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Test that wait(2) returns ECHILD for no child");
+}
+
+ATF_TC_BODY(wait, tc)
+{
+ ATF_REQUIRE_ERRNO(ECHILD, wait(NULL) == -1);
+}
+#endif
+
+ATF_TC(waitpid);
+ATF_TC_HEAD(waitpid, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Test that waitpid(2) returns ECHILD for WAIT_ANY and option %s",
+ ___STRING(TWAIT_OPTION));
+}
+
+ATF_TC_BODY(waitpid, tc)
+{
+ ATF_REQUIRE_ERRNO(ECHILD, waitpid(WAIT_ANY, NULL, TWAIT_OPTION) == -1);
+}
+
+ATF_TC(waitid);
+ATF_TC_HEAD(waitid, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Test that waitid(2) returns ECHILD for P_ALL and option %s",
+ ___STRING(TWAIT_OPTION));
+}
+
+ATF_TC_BODY(waitid, tc)
+{
+ ATF_REQUIRE_ERRNO(ECHILD,
+ waitid(P_ALL, 0, NULL,
+ WTRAPPED | WEXITED | TWAIT_OPTION) == -1);
+}
+
+ATF_TC(wait3);
+ATF_TC_HEAD(wait3, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Test that wait3(2) returns ECHILD for no child");
+}
+
+ATF_TC_BODY(wait3, tc)
+{
+ ATF_REQUIRE_ERRNO(ECHILD, wait3(NULL, TWAIT_OPTION, NULL) == -1);
+}
+
+ATF_TC(wait4);
+ATF_TC_HEAD(wait4, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Test that wait4(2) returns ECHILD for WAIT_ANY and option %s",
+ ___STRING(TWAIT_OPTION));
+}
+
+ATF_TC_BODY(wait4, tc)
+{
+ ATF_REQUIRE_ERRNO(ECHILD,
+ wait4(WAIT_ANY, NULL, TWAIT_OPTION, NULL) == -1);
+}
+
+ATF_TC(wait6);
+ATF_TC_HEAD(wait6, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Test that wait6(2) returns ECHILD for P_ALL and option %s",
+ ___STRING(TWAIT_OPTION));
+}
+
+ATF_TC_BODY(wait6, tc)
+{
+ ATF_REQUIRE_ERRNO(ECHILD,
+ wait6(P_ALL, 0, NULL,
+ WTRAPPED | WEXITED | TWAIT_OPTION, NULL, NULL) == -1);
+}
+
+/*
+ * Generator of valid combinations of options
+ * Usage: i = 0; while ((o = get_options_wait6(i++)) != -1) {}
+ */
+static int
+get_options6(size_t pos)
+{
+ int rv = 0;
+ size_t n;
+
+ /*
+ * waitid(2) must specify at least one of WEXITED, WUNTRACED,
+ * WSTOPPED, WTRAPPED or WCONTINUED. Single option WNOWAIT
+ * isn't valid.
+ */
+
+ const int matrix[] = {
+ WNOWAIT, /* First in order to blacklist it easily */
+ WEXITED,
+ WUNTRACED,
+ WSTOPPED, /* SUS compatibility, equal to WUNTRACED */
+ WTRAPPED,
+ WCONTINUED
+ };
+
+ const size_t M = (1 << __arraycount(matrix)) - 1;
+
+ /* Skip empty and sole WNOWAIT option */
+ pos+=2;
+
+ if (pos > M)
+ return -1;
+
+ for (n = 0; n < __arraycount(matrix); n++) {
+ if (pos & __BIT(n))
+ rv |= matrix[n];
+ }
+
+ return rv;
+}
+
+/*
+ * Generator of valid combinations of options
+ * Usage: i = 0; while ((o = get_options_wait4(i++)) != -1) {}
+ */
+static int
+get_options4(size_t pos)
+{
+ int rv = 0;
+ size_t n;
+
+ const int special[] = {
+ 0,
+#ifdef __NetBSD__
+ WALLSIG,
+ WALTSIG,
+ __WALL, /* Linux compatibility, equal to WALLSIG */
+ __WCLONE /* Linux compatibility, equal to WALTSIG */
+#endif
+ };
+
+ const int matrix[] = {
+ WNOWAIT,
+ WEXITED,
+ WUNTRACED,
+ WSTOPPED, /* SUS compatibility, equal to WUNTRACED */
+ WTRAPPED,
+ WCONTINUED
+ };
+
+ const size_t M = (1 << __arraycount(special)) - 1;
+
+ if (pos < __arraycount(special))
+ return special[pos];
+
+ pos -= __arraycount(special);
+
+ ++pos; /* Don't start with empty mask */
+
+ if (pos > M)
+ return -1;
+
+ for (n = 0; n < __arraycount(special); n++) {
+ if (pos & __BIT(n))
+ rv |= matrix[n];
+ }
+
+ return rv;
+}
+
+ATF_TC(waitpid_options);
+ATF_TC_HEAD(waitpid_options, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Test that waitpid(2) returns ECHILD for WAIT_ANY and valid "
+ "combination of options with%s WNOHANG",
+ TWAIT_OPTION == 0 ? "out" : "");
+}
+
+ATF_TC_BODY(waitpid_options, tc)
+{
+ size_t i = 0;
+ int o;
+
+ while((o = get_options4(i++)) != -1) {
+ printf("Testing waitpid(2) with options %x\n", o);
+
+ ATF_REQUIRE_ERRNO(ECHILD,
+ waitpid(WAIT_ANY, NULL, o | TWAIT_OPTION) == -1);
+ }
+}
+
+ATF_TC(waitid_options);
+ATF_TC_HEAD(waitid_options, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Test that waitid(2) returns ECHILD for P_ALL and valid "
+ "combination of options with%s WNOHANG",
+ TWAIT_OPTION == 0 ? "out" : "");
+}
+
+ATF_TC_BODY(waitid_options, tc)
+{
+ size_t i = 0;
+ int o;
+
+ while((o = get_options6(i++)) != -1) {
+ printf("Testing waitid(2) with options %x\n", o);
+
+ ATF_REQUIRE_ERRNO(ECHILD,
+ waitid(P_ALL, 0, NULL, o | TWAIT_OPTION) == -1);
+ }
+}
+
+ATF_TC(wait3_options);
+ATF_TC_HEAD(wait3_options, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Test that wait3(2) returns ECHILD for no child");
+}
+
+ATF_TC_BODY(wait3_options, tc)
+{
+ size_t i = 0;
+ int o;
+
+ while((o = get_options4(i++)) != -1) {
+ printf("Testing wait3(2) with options %x\n", o);
+
+ ATF_REQUIRE_ERRNO(ECHILD,
+ wait3(NULL, o | TWAIT_OPTION, NULL) == -1);
+ }
+}
+
+ATF_TC(wait4_options);
+ATF_TC_HEAD(wait4_options, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Test that wait4(2) returns ECHILD for WAIT_ANY and option %s",
+ ___STRING(TWAIT_OPTION));
+}
+
+ATF_TC_BODY(wait4_options, tc)
+{
+ size_t i = 0;
+ int o;
+
+ while((o = get_options4(i++)) != -1) {
+ printf("Testing wait4(2) with options %x\n", o);
+
+ ATF_REQUIRE_ERRNO(ECHILD,
+ wait4(WAIT_ANY, NULL, o | TWAIT_OPTION, NULL) == -1);
+ }
+}
+
+ATF_TC(wait6_options);
+ATF_TC_HEAD(wait6_options, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Test that wait6(2) returns ECHILD for P_ALL and option %s",
+ ___STRING(TWAIT_OPTION));
+}
+
+ATF_TC_BODY(wait6_options, tc)
+{
+ size_t i = 0;
+ int o;
+
+ while((o = get_options6(i++)) != -1) {
+ printf("Testing wait6(2) with options %x\n", o);
+
+ ATF_REQUIRE_ERRNO(ECHILD,
+ wait6(P_ALL, 0, NULL, o | TWAIT_OPTION, NULL, NULL) == -1);
+ }
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+
+#if TWAIT_OPTION == 0
+ ATF_TP_ADD_TC(tp, wait);
+#endif
+ ATF_TP_ADD_TC(tp, waitpid);
+ ATF_TP_ADD_TC(tp, waitid);
+ ATF_TP_ADD_TC(tp, wait3);
+ ATF_TP_ADD_TC(tp, wait4);
+ ATF_TP_ADD_TC(tp, wait6);
+
+ ATF_TP_ADD_TC(tp, waitpid_options);
+ ATF_TP_ADD_TC(tp, waitid_options);
+ ATF_TP_ADD_TC(tp, wait3_options);
+ ATF_TP_ADD_TC(tp, wait4_options);
+ ATF_TP_ADD_TC(tp, wait6_options);
+
+ return atf_no_error();
+}
diff --git a/contrib/netbsd-tests/lib/libc/sys/t_wait_noproc_wnohang.c b/contrib/netbsd-tests/lib/libc/sys/t_wait_noproc_wnohang.c
new file mode 100644
index 0000000..45a9998
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libc/sys/t_wait_noproc_wnohang.c
@@ -0,0 +1,30 @@
+/* $NetBSD: t_wait_noproc_wnohang.c,v 1.1 2016/11/06 15:03:30 kamil Exp $ */
+
+/*-
+ * Copyright (c) 2016 The NetBSD Foundation, Inc.
+ * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 TWAIT_OPTION WNOHANG
+#include "t_wait_noproc.c"
diff --git a/contrib/netbsd-tests/lib/libm/t_casinh.c b/contrib/netbsd-tests/lib/libm/t_casinh.c
new file mode 100644
index 0000000..f9f93c3
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libm/t_casinh.c
@@ -0,0 +1,81 @@
+/* $NetBSD: t_casinh.c,v 1.2 2016/09/20 17:19:28 christos Exp $ */
+
+/*
+ * Written by Maya Rashish
+ * Public domain.
+ *
+ * Testing special values of casinh
+ * Values from ISO/IEC 9899:201x G.6.2.2
+ */
+
+#include <atf-c.h>
+#include <complex.h>
+#include <math.h>
+
+#define RE(z) (((double *)(&z))[0])
+#define IM(z) (((double *)(&z))[1])
+
+static const struct {
+ double input_re;
+ double input_im;
+ double result_re;
+ double result_im;
+} values[] = {
+ { +0, +0, +0, +0},
+ { +5.032E3, +INFINITY, +INFINITY, +M_PI/2},
+ { +INFINITY, +5.023E3, +INFINITY, +0},
+ { +INFINITY, +INFINITY, +INFINITY, +M_PI/4},
+#ifdef __HAVE_NANF
+ { +INFINITY, +NAN, +INFINITY, +NAN},
+ { +5.032E3, +NAN, +NAN, +NAN}, /* + FE_INVALID optionally raised */
+ { +NAN, +0, +NAN, +0},
+ { +NAN, -5.023E3, +NAN, +NAN}, /* + FE_INVALID optionally raised */
+ { +NAN, +INFINITY, +INFINITY, +NAN}, /* sign of real part of result unspecified */
+ { +NAN, +NAN, +NAN, +NAN},
+#endif
+};
+
+#ifdef __HAVE_NANF
+#define both_nan(a,b) (isnan(a) && isnan(b))
+#else
+#define both_nan(a,b) 0
+#endif
+
+#define crude_equality(a,b) ((a == b) || both_nan(a,b))
+
+#define ATF_COMPLEX_EQUAL(a,b) do { \
+ complex double ci = casinh(a); \
+ ATF_CHECK_MSG(crude_equality(creal(ci),creal(b)) && \
+ crude_equality(cimag(ci), cimag(b)), \
+ "for casinh([%g,%g]) = [%g,%g] != [%g,%g]", \
+ creal(a), cimag(a), creal(ci), cimag(ci), creal(b), cimag(b)); \
+} while (0/*CONSTCOND*/)
+
+
+ATF_TC(casinh);
+ATF_TC_HEAD(casinh, tc)
+{
+ atf_tc_set_md_var(tc, "descr","Check casinh family - special values");
+}
+
+ATF_TC_BODY(casinh, tc)
+{
+ complex double input;
+ complex double result;
+ unsigned int i;
+ for (i = 0; i < __arraycount(values); i++) {
+ RE(input) = values[i].input_re;
+ IM(input) = values[i].input_im;
+ RE(result) = values[i].result_re;
+ IM(result) = values[i].result_im;
+ ATF_COMPLEX_EQUAL(input, result);
+ }
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+
+ ATF_TP_ADD_TC(tp, casinh);
+
+ return atf_no_error();
+}
diff --git a/contrib/netbsd-tests/lib/libm/t_fe_round.c b/contrib/netbsd-tests/lib/libm/t_fe_round.c
new file mode 100644
index 0000000..fe805b4
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libm/t_fe_round.c
@@ -0,0 +1,124 @@
+/*
+ * Written by Maya Rashish <maya@NetBSD.org>
+ * Public domain.
+ *
+ * Testing IEEE-754 rounding modes (and lrint)
+ */
+
+#include <atf-c.h>
+#include <fenv.h>
+#ifdef __HAVE_FENV
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+/*#pragma STDC FENV_ACCESS ON gcc?? */
+
+#define INT 9223L
+
+#define EPSILON 0.001
+
+static const struct {
+ int round_mode;
+ double input;
+ long int expected;
+} values[] = {
+ { FE_DOWNWARD, 3.7, 3},
+ { FE_DOWNWARD, -3.7, -4},
+ { FE_DOWNWARD, +0, 0},
+ { FE_DOWNWARD, -INT-0.01, -INT-1},
+ { FE_DOWNWARD, +INT-0.01, INT-1},
+ { FE_DOWNWARD, -INT+0.01, -INT},
+ { FE_DOWNWARD, +INT+0.01, INT},
+#if 0 /* cpu bugs? */
+ { FE_DOWNWARD, -0, -1},
+
+ { FE_UPWARD, +0, 1},
+#endif
+ { FE_UPWARD, -0, 0},
+ { FE_UPWARD, -123.7, -123},
+ { FE_UPWARD, 123.999, 124},
+ { FE_UPWARD, -INT-0.01, -INT},
+ { FE_UPWARD, +INT-0.01, INT},
+ { FE_UPWARD, -INT+0.01, -INT+1},
+ { FE_UPWARD, +INT+0.01, INT+1},
+
+ { FE_TOWARDZERO, 1.99, 1},
+ { FE_TOWARDZERO, -1.99, -1},
+ { FE_TOWARDZERO, 0.2, 0},
+ { FE_TOWARDZERO, INT+0.01, INT},
+ { FE_TOWARDZERO, INT-0.01, INT - 1},
+ { FE_TOWARDZERO, -INT+0.01, -INT + 1},
+ { FE_TOWARDZERO, +0, 0},
+ { FE_TOWARDZERO, -0, 0},
+
+ { FE_TONEAREST, -INT-0.01, -INT},
+ { FE_TONEAREST, +INT-0.01, INT},
+ { FE_TONEAREST, -INT+0.01, -INT},
+ { FE_TONEAREST, +INT+0.01, INT},
+ { FE_TONEAREST, -INT-0.501, -INT-1},
+ { FE_TONEAREST, +INT-0.501, INT-1},
+ { FE_TONEAREST, -INT+0.501, -INT+1},
+ { FE_TONEAREST, +INT+0.501, INT+1},
+ { FE_TONEAREST, +0, 0},
+ { FE_TONEAREST, -0, 0},
+};
+
+ATF_TC(fe_round);
+ATF_TC_HEAD(fe_round, tc)
+{
+ atf_tc_set_md_var(tc, "descr","Checking IEEE 754 rounding modes using lrint");
+}
+
+ATF_TC_BODY(fe_round, tc)
+{
+ long int received;
+
+ for (unsigned int i = 0; i < __arraycount(values); i++) {
+ fesetround(values[i].round_mode);
+
+ received = lrint(values[i].input);
+ ATF_CHECK_MSG(
+ (labs(received - values[i].expected) < EPSILON),
+ "lrint rounding wrong, difference too large\n"
+ "input: %f (index %d): got %ld, expected %ld\n",
+ values[i].input, i, received, values[i].expected);
+
+ /* Do we get the same rounding mode out? */
+ ATF_CHECK_MSG(
+ (fegetround() == values[i].round_mode),
+ "Didn't get the same rounding mode out!\n"
+ "(index %d) fed in %d rounding mode, got %d out\n",
+ i, fegetround(), values[i].round_mode);
+ }
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+
+ ATF_TP_ADD_TC(tp, fe_round);
+
+ return atf_no_error();
+}
+#else
+ATF_TC(t_nofe_round);
+
+ATF_TC_HEAD(t_nofe_round, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "dummy test case - no fenv.h support");
+}
+
+
+ATF_TC_BODY(t_nofe_round, tc)
+{
+ atf_tc_skip("no fenv.h support on this architecture");
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+ ATF_TP_ADD_TC(tp, t_nofe_round);
+ return atf_no_error();
+}
+
+#endif
diff --git a/contrib/netbsd-tests/lib/libm/t_ilogb.c b/contrib/netbsd-tests/lib/libm/t_ilogb.c
new file mode 100644
index 0000000..b3c2126
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libm/t_ilogb.c
@@ -0,0 +1,130 @@
+/* $NetBSD: t_ilogb.c,v 1.6 2016/08/26 08:01:55 christos Exp $ */
+
+/*-
+ * Copyright (c) 2016 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Maya Rashish.
+ *
+ * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 __FreeBSD__
+#include <limits.h>
+#endif
+#include <atf-c.h>
+#include <fenv.h>
+#include <math.h>
+
+#ifndef __HAVE_FENV
+
+# define ATF_CHECK_RAISED_INVALID
+# define ATF_CHECK_RAISED_NOTHING
+
+#else
+# define ATF_CHECK_RAISED_INVALID do { \
+ int r = fetestexcept(FE_ALL_EXCEPT); \
+ ATF_CHECK_MSG(r == FE_INVALID, "r=%#x != %#x\n", r, FE_INVALID); \
+ (void)feclearexcept(FE_ALL_EXCEPT); \
+} while (/*CONSTCOND*/0)
+
+# define ATF_CHECK_RAISED_NOTHING do { \
+ int r = fetestexcept(FE_ALL_EXCEPT); \
+ ATF_CHECK_MSG(r == 0, "r=%#x != 0\n", r); \
+ (void)feclearexcept(FE_ALL_EXCEPT); \
+} while (/*CONSTCOND*/0)
+#endif
+
+ATF_TC(ilogb);
+ATF_TC_HEAD(ilogb, tc)
+{
+ atf_tc_set_md_var(tc, "descr","Check ilogb family");
+}
+
+ATF_TC_BODY(ilogb, tc)
+{
+
+ ATF_CHECK(ilogbf(0) == FP_ILOGB0);
+ ATF_CHECK_RAISED_INVALID;
+ ATF_CHECK(ilogb(0) == FP_ILOGB0);
+ ATF_CHECK_RAISED_INVALID;
+#ifdef __HAVE_LONG_DOUBLE
+ ATF_CHECK(ilogbl(0) == FP_ILOGB0);
+ ATF_CHECK_RAISED_INVALID;
+#endif
+
+ ATF_CHECK(ilogbf(-0) == FP_ILOGB0);
+ ATF_CHECK_RAISED_INVALID;
+ ATF_CHECK(ilogb(-0) == FP_ILOGB0);
+ ATF_CHECK_RAISED_INVALID;
+#ifdef __HAVE_LONG_DOUBLE
+ ATF_CHECK(ilogbl(-0) == FP_ILOGB0);
+ ATF_CHECK_RAISED_INVALID;
+#endif
+
+ ATF_CHECK(ilogbf(INFINITY) == INT_MAX);
+ ATF_CHECK_RAISED_INVALID;
+ ATF_CHECK(ilogb(INFINITY) == INT_MAX);
+ ATF_CHECK_RAISED_INVALID;
+#ifdef __HAVE_LONG_DOUBLE
+ ATF_CHECK(ilogbl(INFINITY) == INT_MAX);
+ ATF_CHECK_RAISED_INVALID;
+#endif
+
+ ATF_CHECK(ilogbf(-INFINITY) == INT_MAX);
+ ATF_CHECK_RAISED_INVALID;
+ ATF_CHECK(ilogb(-INFINITY) == INT_MAX);
+ ATF_CHECK_RAISED_INVALID;
+#ifdef __HAVE_LONG_DOUBLE
+ ATF_CHECK(ilogbl(-INFINITY) == INT_MAX);
+ ATF_CHECK_RAISED_INVALID;
+#endif
+
+ ATF_CHECK(ilogbf(1024) == 10);
+ ATF_CHECK_RAISED_NOTHING;
+ ATF_CHECK(ilogb(1024) == 10);
+ ATF_CHECK_RAISED_NOTHING;
+#ifdef __HAVE_LONG_DOUBLE
+ ATF_CHECK(ilogbl(1024) == 10);
+ ATF_CHECK_RAISED_NOTHING;
+#endif
+
+#ifndef __vax__
+ ATF_CHECK(ilogbf(NAN) == FP_ILOGBNAN);
+ ATF_CHECK_RAISED_INVALID;
+ ATF_CHECK(ilogb(NAN) == FP_ILOGBNAN);
+ ATF_CHECK_RAISED_INVALID;
+#ifdef __HAVE_LONG_DOUBLE
+ ATF_CHECK(ilogbl(NAN) == FP_ILOGBNAN);
+ ATF_CHECK_RAISED_INVALID;
+#endif
+#endif
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+
+ ATF_TP_ADD_TC(tp, ilogb);
+
+ return atf_no_error();
+}
diff --git a/contrib/netbsd-tests/lib/libm/t_ldexp.c b/contrib/netbsd-tests/lib/libm/t_ldexp.c
index eaf8a4b..251f2ae 100644
--- a/contrib/netbsd-tests/lib/libm/t_ldexp.c
+++ b/contrib/netbsd-tests/lib/libm/t_ldexp.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_ldexp.c,v 1.14 2014/11/04 00:20:19 justin Exp $ */
+/* $NetBSD: t_ldexp.c,v 1.16 2016/08/25 00:32:31 maya Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_ldexp.c,v 1.14 2014/11/04 00:20:19 justin Exp $");
+__RCSID("$NetBSD: t_ldexp.c,v 1.16 2016/08/25 00:32:31 maya Exp $");
#include <sys/param.h>
@@ -96,10 +96,12 @@ struct ldexp_test ldexp_overflow[] = {
{ 1.0, 1023, 1, " inf" },
{ 1.0, -1022, 2046, " inf" },
{ 1.0, 1025, SKIP, " inf" },
+ { 2.0, INT_MAX,SKIP, " inf" },
{ -1.0, 1024, SKIP, " -inf" },
{ -1.0, 1023, 1, " -inf" },
{ -1.0, -1022, 2046, " -inf" },
{ -1.0, 1025, SKIP, " -inf" },
+ { -2.0, INT_MAX,SKIP, " -inf" },
{ 0, 0, 0, NULL }
};
@@ -170,10 +172,8 @@ run_test(struct ldexp_test *table)
v = ldexp(table->x, table->exp1);
- if (table->exp2 == SKIP)
- continue;
-
- v = ldexp(v, table->exp2);
+ if (table->exp2 != SKIP)
+ v = ldexp(v, table->exp2);
(void)snprintf(outbuf, sizeof(outbuf), FORMAT, v);
diff --git a/contrib/netbsd-tests/lib/libm/t_precision.c b/contrib/netbsd-tests/lib/libm/t_precision.c
index c01deba..df2d8a3 100644
--- a/contrib/netbsd-tests/lib/libm/t_precision.c
+++ b/contrib/netbsd-tests/lib/libm/t_precision.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_precision.c,v 1.2 2014/11/04 00:20:19 justin Exp $ */
+/* $NetBSD: t_precision.c,v 1.3 2016/08/27 10:07:05 christos Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_precision.c,v 1.2 2014/11/04 00:20:19 justin Exp $");
+__RCSID("$NetBSD: t_precision.c,v 1.3 2016/08/27 10:07:05 christos Exp $");
#include <atf-c.h>
@@ -45,7 +45,9 @@ ATF_TC_HEAD(t_precision, tc)
}
volatile double x = 1;
+#if __HAVE_LONG_DOUBLE
volatile long double y = 1;
+#endif
ATF_TC_BODY(t_precision, tc)
{
@@ -58,7 +60,7 @@ ATF_TC_BODY(t_precision, tc)
x += DBL_EPSILON;
ATF_CHECK(x == 2.0);
-#if !defined(__FreeBSD__) || !defined(__i386__)
+#if __HAVE_LONG_DOUBLE
y += LDBL_EPSILON;
ATF_CHECK(y != 1.0L);
y -= 1;
diff --git a/contrib/netbsd-tests/lib/libpthread/h_common.h b/contrib/netbsd-tests/lib/libpthread/h_common.h
index f4d03bc..2e8b0a1 100644
--- a/contrib/netbsd-tests/lib/libpthread/h_common.h
+++ b/contrib/netbsd-tests/lib/libpthread/h_common.h
@@ -9,4 +9,10 @@
ATF_REQUIRE_MSG(ret == 0, "%s: %s", #x, strerror(ret)); \
} while (0)
+#define PTHREAD_REQUIRE_STATUS(x, v) \
+ do { \
+ int ret = (x); \
+ ATF_REQUIRE_MSG(ret == (v), "%s: %s", #x, strerror(ret)); \
+ } while (0)
+
#endif // H_COMMON_H
diff --git a/contrib/netbsd-tests/lib/libpthread/t_mutex.c b/contrib/netbsd-tests/lib/libpthread/t_mutex.c
index 1fcd69e..b8d60e6 100644
--- a/contrib/netbsd-tests/lib/libpthread/t_mutex.c
+++ b/contrib/netbsd-tests/lib/libpthread/t_mutex.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_mutex.c,v 1.10 2016/07/31 13:01:29 christos Exp $ */
+/* $NetBSD: t_mutex.c,v 1.14 2016/10/31 23:51:20 christos Exp $ */
/*
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -29,12 +29,17 @@
#include <sys/cdefs.h>
__COPYRIGHT("@(#) Copyright (c) 2008\
The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: t_mutex.c,v 1.10 2016/07/31 13:01:29 christos Exp $");
+__RCSID("$NetBSD: t_mutex.c,v 1.14 2016/10/31 23:51:20 christos Exp $");
+#ifdef __FreeBSD__
+#include <sys/time.h> /* For timespecadd */
+#include <inttypes.h> /* For UINT16_MAX */
+#endif
#include <pthread.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
+#include <time.h>
#include <unistd.h>
#include <sys/sched.h>
#include <sys/param.h>
@@ -47,6 +52,31 @@ static pthread_mutex_t mutex;
static pthread_mutex_t static_mutex = PTHREAD_MUTEX_INITIALIZER;
static int global_x;
+#ifdef TIMEDMUTEX
+/* This code is used for verifying non-timed specific code */
+static struct timespec ts_lengthy = {
+ .tv_sec = UINT16_MAX,
+ .tv_nsec = 0
+};
+/* This code is used for verifying timed-only specific code */
+static struct timespec ts_shortlived = {
+ .tv_sec = 0,
+ .tv_nsec = 120
+};
+
+static int
+mutex_lock(pthread_mutex_t *m, const struct timespec *ts)
+{
+ struct timespec ts_wait;
+ ATF_REQUIRE(clock_gettime(CLOCK_REALTIME, &ts_wait) != -1);
+ timespecadd(&ts_wait, ts, &ts_wait);
+
+ return pthread_mutex_timedlock(m, &ts_wait);
+}
+#else
+#define mutex_lock(a, b) pthread_mutex_lock(a)
+#endif
+
static void *
mutex1_threadfunc(void *arg)
{
@@ -56,7 +86,7 @@ mutex1_threadfunc(void *arg)
param = arg;
printf("2: Locking mutex\n");
- pthread_mutex_lock(&mutex);
+ mutex_lock(&mutex, &ts_lengthy);
printf("2: Got mutex. *param = %d\n", *param);
ATF_REQUIRE_EQ(*param, 20);
(*param)++;
@@ -81,7 +111,7 @@ ATF_TC_BODY(mutex1, tc)
PTHREAD_REQUIRE(pthread_mutex_init(&mutex, NULL));
x = 1;
- PTHREAD_REQUIRE(pthread_mutex_lock(&mutex));
+ PTHREAD_REQUIRE(mutex_lock(&mutex, &ts_lengthy));
PTHREAD_REQUIRE(pthread_create(&new, NULL, mutex1_threadfunc, &x));
printf("1: Before changing the value.\n");
sleep(2);
@@ -92,7 +122,7 @@ ATF_TC_BODY(mutex1, tc)
printf("1: After releasing the mutex.\n");
PTHREAD_REQUIRE(pthread_join(new, &joinval));
- PTHREAD_REQUIRE(pthread_mutex_lock(&mutex));
+ PTHREAD_REQUIRE(mutex_lock(&mutex, &ts_lengthy));
printf("1: Thread joined. X was %d. Return value (int) was %d\n",
x, *(int *)joinval);
ATF_REQUIRE_EQ(x, 21);
@@ -108,7 +138,7 @@ mutex2_threadfunc(void *arg)
printf("2: Second thread (%p). Count is %ld\n", pthread_self(), count);
while (count--) {
- PTHREAD_REQUIRE(pthread_mutex_lock(&mutex));
+ PTHREAD_REQUIRE(mutex_lock(&mutex, &ts_lengthy));
global_x++;
PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex));
}
@@ -145,7 +175,7 @@ ATF_TC_BODY(mutex2, tc)
global_x = 0;
count = count2 = 10000000;
- PTHREAD_REQUIRE(pthread_mutex_lock(&mutex));
+ PTHREAD_REQUIRE(mutex_lock(&mutex, &ts_lengthy));
PTHREAD_REQUIRE(pthread_create(&new, NULL, mutex2_threadfunc, &count2));
printf("1: Thread %p\n", pthread_self());
@@ -153,14 +183,14 @@ ATF_TC_BODY(mutex2, tc)
PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex));
while (count--) {
- PTHREAD_REQUIRE(pthread_mutex_lock(&mutex));
+ PTHREAD_REQUIRE(mutex_lock(&mutex, &ts_lengthy));
global_x++;
PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex));
}
PTHREAD_REQUIRE(pthread_join(new, &joinval));
- PTHREAD_REQUIRE(pthread_mutex_lock(&mutex));
+ PTHREAD_REQUIRE(mutex_lock(&mutex, &ts_lengthy));
printf("1: Thread joined. X was %d. Return value (long) was %ld\n",
global_x, (long)joinval);
ATF_REQUIRE_EQ(global_x, 20000000);
@@ -184,7 +214,7 @@ mutex3_threadfunc(void *arg)
printf("2: Second thread (%p). Count is %ld\n", pthread_self(), count);
while (count--) {
- PTHREAD_REQUIRE(pthread_mutex_lock(&static_mutex));
+ PTHREAD_REQUIRE(mutex_lock(&static_mutex, &ts_lengthy));
global_x++;
PTHREAD_REQUIRE(pthread_mutex_unlock(&static_mutex));
}
@@ -220,7 +250,7 @@ ATF_TC_BODY(mutex3, tc)
global_x = 0;
count = count2 = 10000000;
- PTHREAD_REQUIRE(pthread_mutex_lock(&static_mutex));
+ PTHREAD_REQUIRE(mutex_lock(&static_mutex, &ts_lengthy));
PTHREAD_REQUIRE(pthread_create(&new, NULL, mutex3_threadfunc, &count2));
printf("1: Thread %p\n", pthread_self());
@@ -228,14 +258,14 @@ ATF_TC_BODY(mutex3, tc)
PTHREAD_REQUIRE(pthread_mutex_unlock(&static_mutex));
while (count--) {
- PTHREAD_REQUIRE(pthread_mutex_lock(&static_mutex));
+ PTHREAD_REQUIRE(mutex_lock(&static_mutex, &ts_lengthy));
global_x++;
PTHREAD_REQUIRE(pthread_mutex_unlock(&static_mutex));
}
PTHREAD_REQUIRE(pthread_join(new, &joinval));
- PTHREAD_REQUIRE(pthread_mutex_lock(&static_mutex));
+ PTHREAD_REQUIRE(mutex_lock(&static_mutex, &ts_lengthy));
printf("1: Thread joined. X was %d. Return value (long) was %ld\n",
global_x, (long)joinval);
ATF_REQUIRE_EQ(global_x, 20000000);
@@ -260,7 +290,7 @@ mutex4_threadfunc(void *arg)
param = arg;
printf("2: Locking mutex\n");
- PTHREAD_REQUIRE(pthread_mutex_lock(&mutex));
+ PTHREAD_REQUIRE(mutex_lock(&mutex, &ts_lengthy));
printf("2: Got mutex. *param = %d\n", *param);
(*param)++;
@@ -291,11 +321,11 @@ ATF_TC_BODY(mutex4, tc)
PTHREAD_REQUIRE(pthread_mutexattr_destroy(&mattr));
x = 1;
- PTHREAD_REQUIRE(pthread_mutex_lock(&mutex));
+ PTHREAD_REQUIRE(mutex_lock(&mutex, &ts_lengthy));
PTHREAD_REQUIRE(pthread_create(&new, NULL, mutex4_threadfunc, &x));
printf("1: Before recursively acquiring the mutex.\n");
- PTHREAD_REQUIRE(pthread_mutex_lock(&mutex));
+ PTHREAD_REQUIRE(mutex_lock(&mutex, &ts_lengthy));
printf("1: Before releasing the mutex once.\n");
sleep(2);
@@ -311,7 +341,7 @@ ATF_TC_BODY(mutex4, tc)
PTHREAD_REQUIRE(pthread_join(new, &joinval));
- PTHREAD_REQUIRE(pthread_mutex_lock(&mutex));
+ PTHREAD_REQUIRE(mutex_lock(&mutex, &ts_lengthy));
printf("1: Thread joined. X was %d. Return value (int) was %d\n",
x, *(int *)joinval);
ATF_REQUIRE_EQ(x, 21);
@@ -333,7 +363,7 @@ child_func(void* arg)
res = _sched_protect(-2);
ATF_REQUIRE_EQ_MSG(res, -1, "sched_protect returned %d", res);
ATF_REQUIRE_EQ(errno, ENOENT);
- PTHREAD_REQUIRE(pthread_mutex_lock(&mutex5));
+ PTHREAD_REQUIRE(mutex_lock(&mutex5, &ts_lengthy));
printf("child is owning resource\n");
res = _sched_protect(-2);
ATF_REQUIRE_EQ(res, max_fifo_prio);
@@ -376,7 +406,7 @@ ATF_TC_BODY(mutex5, tc)
max_fifo_prio));
PTHREAD_REQUIRE(pthread_mutex_init(&mutex5, &attr5));
- PTHREAD_REQUIRE(pthread_mutex_lock(&mutex5));
+ PTHREAD_REQUIRE(mutex_lock(&mutex5, &ts_lengthy));
printf("enter critical section for main\n");
PTHREAD_REQUIRE(pthread_create(&child, NULL, child_func, NULL));
printf("main starts to sleep\n");
@@ -414,7 +444,7 @@ high_prio(void* arg)
high_cnt = 0;
sleep(1);
}
- PTHREAD_REQUIRE(pthread_mutex_lock(&mutex6));
+ PTHREAD_REQUIRE(mutex_lock(&mutex6, &ts_lengthy));
if (start == 0) start = 2;
PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex6));
@@ -446,7 +476,7 @@ low_prio(void* arg)
low_cnt = 0;
sleep(1);
}
- PTHREAD_REQUIRE(pthread_mutex_lock(&mutex6));
+ PTHREAD_REQUIRE(mutex_lock(&mutex6, &ts_lengthy));
if (start == 0)
start = 1;
PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex6));
@@ -582,6 +612,123 @@ ATF_TC_BODY(mutexattr2, tc)
}
}
+#ifdef TIMEDMUTEX
+ATF_TC(timedmutex1);
+ATF_TC_HEAD(timedmutex1, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Checks timeout on selflock");
+}
+
+ATF_TC_BODY(timedmutex1, tc)
+{
+
+ printf("Timed mutex-test 1\n");
+
+ PTHREAD_REQUIRE(pthread_mutex_init(&mutex, NULL));
+
+ printf("Before acquiring mutex\n");
+ PTHREAD_REQUIRE(pthread_mutex_lock(&mutex));
+
+ printf("Before endeavor to reacquire timed-mutex (timeout expected)\n");
+ PTHREAD_REQUIRE_STATUS(mutex_lock(&mutex, &ts_shortlived),
+ ETIMEDOUT);
+
+ printf("Unlocking mutex\n");
+ PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex));
+}
+
+ATF_TC(timedmutex2);
+ATF_TC_HEAD(timedmutex2, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Checks timeout on selflock with timedlock");
+}
+
+ATF_TC_BODY(timedmutex2, tc)
+{
+
+ printf("Timed mutex-test 2\n");
+
+ PTHREAD_REQUIRE(pthread_mutex_init(&mutex, NULL));
+
+ printf("Before acquiring mutex with timedlock\n");
+ PTHREAD_REQUIRE(mutex_lock(&mutex, &ts_lengthy));
+
+ printf("Before endeavor to reacquire timed-mutex (timeout expected)\n");
+ PTHREAD_REQUIRE_STATUS(mutex_lock(&mutex, &ts_shortlived),
+ ETIMEDOUT);
+
+ printf("Unlocking mutex\n");
+ PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex));
+}
+
+ATF_TC(timedmutex3);
+ATF_TC_HEAD(timedmutex3, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Checks timeout on selflock in a new thread");
+}
+
+static void *
+timedmtx_thrdfunc(void *arg)
+{
+ printf("Before endeavor to reacquire timed-mutex (timeout expected)\n");
+ PTHREAD_REQUIRE_STATUS(mutex_lock(&mutex, &ts_shortlived),
+ ETIMEDOUT);
+
+ return NULL;
+}
+
+ATF_TC_BODY(timedmutex3, tc)
+{
+ pthread_t new;
+
+ printf("Timed mutex-test 3\n");
+
+ PTHREAD_REQUIRE(pthread_mutex_init(&mutex, NULL));
+
+ printf("Before acquiring mutex with timedlock\n");
+ PTHREAD_REQUIRE(pthread_mutex_lock(&mutex));
+
+ printf("Before creating new thread\n");
+ PTHREAD_REQUIRE(pthread_create(&new, NULL, timedmtx_thrdfunc, NULL));
+
+ printf("Before joining the mutex\n");
+ PTHREAD_REQUIRE(pthread_join(new, NULL));
+
+ printf("Unlocking mutex\n");
+ PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex));
+}
+
+ATF_TC(timedmutex4);
+ATF_TC_HEAD(timedmutex4, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Checks timeout on selflock with timedlock in a new thread");
+}
+
+ATF_TC_BODY(timedmutex4, tc)
+{
+ pthread_t new;
+
+ printf("Timed mutex-test 4\n");
+
+ PTHREAD_REQUIRE(pthread_mutex_init(&mutex, NULL));
+
+ printf("Before acquiring mutex with timedlock\n");
+ PTHREAD_REQUIRE(mutex_lock(&mutex, &ts_lengthy));
+
+ printf("Before creating new thread\n");
+ PTHREAD_REQUIRE(pthread_create(&new, NULL, timedmtx_thrdfunc, NULL));
+
+ printf("Before joining the mutex\n");
+ PTHREAD_REQUIRE(pthread_join(new, NULL));
+
+ printf("Unlocking mutex\n");
+ PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex));
+}
+#endif
+
ATF_TP_ADD_TCS(tp)
{
ATF_TP_ADD_TC(tp, mutex1);
@@ -594,6 +741,13 @@ ATF_TP_ADD_TCS(tp)
#endif
ATF_TP_ADD_TC(tp, mutexattr1);
ATF_TP_ADD_TC(tp, mutexattr2);
-
+
+#ifdef TIMEDMUTEX
+ ATF_TP_ADD_TC(tp, timedmutex1);
+ ATF_TP_ADD_TC(tp, timedmutex2);
+ ATF_TP_ADD_TC(tp, timedmutex3);
+ ATF_TP_ADD_TC(tp, timedmutex4);
+#endif
+
return atf_no_error();
}
diff --git a/contrib/netbsd-tests/lib/libpthread/t_timedmutex.c b/contrib/netbsd-tests/lib/libpthread/t_timedmutex.c
new file mode 100644
index 0000000..4f71acd
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libpthread/t_timedmutex.c
@@ -0,0 +1,30 @@
+/* $NetBSD: t_timedmutex.c,v 1.2 2016/10/31 16:21:23 christos Exp $ */
+
+/*
+ * Copyright (c) 2008 The NetBSD Foundation, Inc.
+ * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 TIMEDMUTEX
+#include "t_mutex.c"
diff --git a/contrib/netbsd-tests/lib/librumpclient/h_execthr.c b/contrib/netbsd-tests/lib/librumpclient/h_execthr.c
index f653fe6..c209375 100644
--- a/contrib/netbsd-tests/lib/librumpclient/h_execthr.c
+++ b/contrib/netbsd-tests/lib/librumpclient/h_execthr.c
@@ -1,4 +1,4 @@
-/* $NetBSD: h_execthr.c,v 1.3 2014/08/13 00:03:00 pooka Exp $ */
+/* $NetBSD: h_execthr.c,v 1.7 2016/11/24 00:37:29 dholland Exp $ */
/*
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -42,6 +42,14 @@
#include <rump/rumpclient.h>
#include <rump/rump_syscalls.h>
+//#define VERBOSE
+
+#ifdef VERBOSE
+#define SAY(...) printf(__VA_ARGS__)
+#else
+#define SAY(...)
+#endif
+
static int canreturn = 0;
/*
@@ -103,6 +111,7 @@ main(int argc, char *argv[], char *envp[])
else
execd = 0;
sprintf(nexec, "%d", execd+1);
+ SAY("execd: %d\n", execd);
if (rumpclient_init() == -1) {
if (execd)
@@ -111,33 +120,43 @@ main(int argc, char *argv[], char *envp[])
err(1, "init");
}
mypid = rump_sys_getpid();
+ SAY("rumpclient_init finished.\n");
if (execd) {
canreturn = 1;
- if (pthread_create(&pt, NULL,
- wrk, (void *)(uintptr_t)P2_0) != 0)
- errx(1, "exec pthread_create");
+ errno = pthread_create(&pt, NULL,
+ wrk, (void *)(uintptr_t)P2_0);
+ if (errno != 0)
+ err(1, "exec pthread_create");
+ SAY("startup pthread_create finished.\n");
i = 37;
rump_sys_write(P2_1, &i, sizeof(i));
pthread_join(pt, NULL);
+ SAY("startup pthread_join finished.\n");
n = rump_sys_read(P1_0, &i, sizeof(i));
if (n != -1 || errno != EBADF)
errx(1, "post-exec cloexec works");
+ SAY("startup rump_sys_read finished.\n");
getproc(mypid, &p);
+ SAY("startup getproc finished.\n");
if (p.p_nlwps != 2)
errx(1, "invalid nlwps: %lld", (long long)p.p_nlwps);
/* we passed? */
- if (execd > 10)
+ if (execd > 10) {
+ SAY("done.\n");
exit(0);
+ }
rump_sys_close(P2_0);
rump_sys_close(P2_1);
}
+ SAY("making pipes...\n");
+
if (rump_sys_pipe(p1) == -1)
err(1, "pipe1");
if (p1[0] != P1_0 || p1[1] != P1_1)
@@ -151,32 +170,47 @@ main(int argc, char *argv[], char *envp[])
if (rump_sys_fcntl(p1[1], F_SETFD, FD_CLOEXEC) == -1)
err(1, "cloexec");
- for (i = 0; i < NTHR; i++)
- if (pthread_create(&pt, NULL,
- wrk, (void *)(uintptr_t)p1[0]) != 0)
- errx(1, "pthread_create 1 %d", i);
+ SAY("making threads...\n");
+
+ for (i = 0; i < NTHR; i++) {
+ errno = pthread_create(&pt, NULL,
+ wrk, (void *)(uintptr_t)p1[0]);
+ if (errno != 0)
+ err(1, "pthread_create 1 %d", i);
+ }
+
+ for (i = 0; i < NTHR; i++) {
+ errno = pthread_create(&pt, NULL,
+ wrk, (void *)(uintptr_t)p2[0]);
+ if (errno != 0)
+ err(1, "pthread_create 2 %d", i);
+ }
- for (i = 0; i < NTHR; i++)
- if (pthread_create(&pt, NULL,
- wrk, (void *)(uintptr_t)p2[0]) != 0)
- errx(1, "pthread_create 2 %d", i);
+ SAY("waiting for threads to start...\n");
/* wait for all the threads to be enjoying themselves */
for (;;) {
getproc(mypid, &p);
+ SAY("getproc finished.\n");
if (p.p_nlwps == 2*NTHR + 2)
break;
usleep(10000);
}
+ SAY("making some more threads start...\n");
+
/*
* load up one more (big) set. these won't start executing, though,
* but we're interested in if they create blockage
*/
- for (i = 0; i < 3*NTHR; i++)
- if (pthread_create(&pt, NULL,
- wrk, (void *)(uintptr_t)p1[0]) != 0)
- errx(1, "pthread_create 1 %d", i);
+ for (i = 0; i < 3*NTHR; i++) {
+ errno = pthread_create(&pt, NULL,
+ wrk, (void *)(uintptr_t)p1[0]);
+ if (errno != 0)
+ err(1, "pthread_create 3 %d", i);
+ }
+
+ SAY("calling exec...\n");
/* then, we exec! */
execarg[0] = argv[0];
diff --git a/contrib/netbsd-tests/lib/librumphijack/t_tcpip.sh b/contrib/netbsd-tests/lib/librumphijack/t_tcpip.sh
index 718dfdc..411be33 100755
--- a/contrib/netbsd-tests/lib/librumphijack/t_tcpip.sh
+++ b/contrib/netbsd-tests/lib/librumphijack/t_tcpip.sh
@@ -1,4 +1,4 @@
-# $NetBSD: t_tcpip.sh,v 1.17 2016/08/11 21:29:44 kre Exp $
+# $NetBSD: t_tcpip.sh,v 1.18 2016/08/13 11:22:11 christos Exp $
#
# Copyright (c) 2011 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -25,7 +25,8 @@
# POSSIBILITY OF SUCH DAMAGE.
#
-rumpnetsrv='rump_server -lrumpnet -lrumpnet_net -lrumpnet_netinet -lrumpdev'
+rumpnetlibs="-lrumpnet -lrumpnet_net -lrumpnet_netinet6 -lrumpnet_netinet"
+rumpnetsrv="rump_server $rumpnetlibs -lrumpdev"
export RUMP_SERVER=unix://csock
atf_test_case http cleanup
@@ -37,7 +38,7 @@ http_head()
http_body()
{
- atf_check -s exit:0 ${rumpnetsrv} -lrumpnet_netinet6 ${RUMP_SERVER}
+ atf_check -s exit:0 ${rumpnetsrv} ${RUMP_SERVER}
# start bozo in daemon mode
atf_check -s exit:0 env LD_PRELOAD=/usr/lib/librumphijack.so \
diff --git a/contrib/netbsd-tests/lib/libusbhid/t_usbhid.c b/contrib/netbsd-tests/lib/libusbhid/t_usbhid.c
index f20652a..2766da2 100644
--- a/contrib/netbsd-tests/lib/libusbhid/t_usbhid.c
+++ b/contrib/netbsd-tests/lib/libusbhid/t_usbhid.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_usbhid.c,v 1.11 2016/01/07 16:10:49 jakllsch Exp $ */
+/* $NetBSD: t_usbhid.c,v 1.12 2016/08/17 12:10:42 jakllsch Exp $ */
/*
* Copyright (c) 2016 Jonathan A. Kollasch
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_usbhid.c,v 1.11 2016/01/07 16:10:49 jakllsch Exp $");
+__RCSID("$NetBSD: t_usbhid.c,v 1.12 2016/08/17 12:10:42 jakllsch Exp $");
#include <atf-c.h>
@@ -244,6 +244,9 @@ ATF_TC_BODY(check_hid_get_data, tc)
int32_t data;
uint32_t udat;
+ atf_tc_expect_fail("only the 32-bit opcode works, "
+ "8 and 16-bit is broken");
+
ATF_REQUIRE((hrd = hid_use_report_desc(
range_test_report_descriptor,
__arraycount(range_test_report_descriptor))) != NULL);
diff --git a/contrib/netbsd-tests/net/arp/t_arp.sh b/contrib/netbsd-tests/net/arp/t_arp.sh
index ab55eb3..04e2f70 100755
--- a/contrib/netbsd-tests/net/arp/t_arp.sh
+++ b/contrib/netbsd-tests/net/arp/t_arp.sh
@@ -1,4 +1,4 @@
-# $NetBSD: t_arp.sh,v 1.16 2016/06/21 05:04:16 ozaki-r Exp $
+# $NetBSD: t_arp.sh,v 1.22 2016/11/25 08:51:16 ozaki-r Exp $
#
# Copyright (c) 2015 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -25,10 +25,6 @@
# POSSIBILITY OF SUCH DAMAGE.
#
-inetserver="rump_server -lrumpnet -lrumpnet_net -lrumpnet_netinet -lrumpnet_shmif"
-inetserver="$inetserver -lrumpdev -lrumpnet_tap"
-HIJACKING="env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=sysctl=yes"
-
SOCKSRC=unix://commsock1
SOCKDST=unix://commsock2
IP4SRC=10.0.1.1
@@ -36,7 +32,7 @@ IP4DST=10.0.1.2
IP4DST_PROXYARP1=10.0.1.3
IP4DST_PROXYARP2=10.0.1.4
-DEBUG=false
+DEBUG=${DEBUG:-false}
TIMEOUT=1
atf_test_case arp_cache_expiration_5s cleanup
@@ -106,9 +102,9 @@ arp_static_head()
setup_dst_server()
{
+
+ rump_server_add_iface $SOCKDST shmif0 bus1
export RUMP_SERVER=$SOCKDST
- atf_check -s exit:0 rump.ifconfig shmif0 create
- atf_check -s exit:0 rump.ifconfig shmif0 linkstr bus1
atf_check -s exit:0 rump.ifconfig shmif0 inet $IP4DST/24
atf_check -s exit:0 rump.ifconfig shmif0 up
atf_check -s exit:0 rump.ifconfig -w 10
@@ -127,8 +123,7 @@ setup_src_server()
atf_check -s exit:0 -o ignore rump.sysctl -w net.inet.arp.keep=$keep
# Setup an interface
- atf_check -s exit:0 rump.ifconfig shmif0 create
- atf_check -s exit:0 rump.ifconfig shmif0 linkstr bus1
+ rump_server_add_iface $SOCKSRC shmif0 bus1
atf_check -s exit:0 rump.ifconfig shmif0 inet $IP4SRC/24
atf_check -s exit:0 rump.ifconfig shmif0 up
atf_check -s exit:0 rump.ifconfig -w 10
@@ -145,8 +140,8 @@ test_cache_expiration()
local arp_keep=$1
local bonus=2
- atf_check -s exit:0 ${inetserver} $SOCKSRC
- atf_check -s exit:0 ${inetserver} $SOCKDST
+ rump_server_start $SOCKSRC
+ rump_server_start $SOCKDST
setup_dst_server
setup_src_server $arp_keep
@@ -172,12 +167,16 @@ test_cache_expiration()
arp_cache_expiration_5s_body()
{
+
test_cache_expiration 5
+ rump_server_destroy_ifaces
}
arp_cache_expiration_10s_body()
{
+
test_cache_expiration 10
+ rump_server_destroy_ifaces
}
arp_command_body()
@@ -185,8 +184,8 @@ arp_command_body()
local arp_keep=5
local bonus=2
- atf_check -s exit:0 ${inetserver} $SOCKSRC
- atf_check -s exit:0 ${inetserver} $SOCKDST
+ rump_server_start $SOCKSRC
+ rump_server_start $SOCKDST
setup_dst_server
setup_src_server $arp_keep
@@ -257,7 +256,7 @@ arp_command_body()
$DEBUG && rump.arp -n -a
#atf_check -s not-exit:0 -e ignore rump.arp -n 10.0.1.10
- return 0
+ rump_server_destroy_ifaces
}
make_pkt_str_arpreq()
@@ -273,12 +272,12 @@ arp_garp_body()
{
local pkt=
- atf_check -s exit:0 ${inetserver} $SOCKSRC
+ rump_server_start $SOCKSRC
+
export RUMP_SERVER=$SOCKSRC
# Setup an interface
- atf_check -s exit:0 rump.ifconfig shmif0 create
- atf_check -s exit:0 rump.ifconfig shmif0 linkstr bus1
+ rump_server_add_iface $SOCKSRC shmif0 bus1
atf_check -s exit:0 rump.ifconfig shmif0 inet 10.0.0.1/24
atf_check -s exit:0 rump.ifconfig shmif0 inet 10.0.0.2/24 alias
atf_check -s exit:0 rump.ifconfig shmif0 up
@@ -304,6 +303,8 @@ arp_garp_body()
atf_check -s not-exit:0 -x "cat ./out |grep -q '$pkt'"
pkt=$(make_pkt_str_arpreq 10.0.0.4 10.0.0.4)
atf_check -s not-exit:0 -x "cat ./out |grep -q '$pkt'"
+
+ rump_server_destroy_ifaces
}
arp_cache_overwriting_body()
@@ -311,8 +312,8 @@ arp_cache_overwriting_body()
local arp_keep=5
local bonus=2
- atf_check -s exit:0 ${inetserver} $SOCKSRC
- atf_check -s exit:0 ${inetserver} $SOCKDST
+ rump_server_start $SOCKSRC
+ rump_server_start $SOCKDST
setup_dst_server
setup_src_server $arp_keep
@@ -341,7 +342,7 @@ arp_cache_overwriting_body()
atf_check -s exit:0 -o match:'b2:a0:20:00:00:ff' rump.arp -n 10.0.1.10
$DEBUG && rump.arp -n -a
- return 0
+ rump_server_destroy_ifaces
}
make_pkt_str_arprep()
@@ -363,36 +364,21 @@ make_pkt_str_garp()
echo $pkt
}
-extract_new_packets()
-{
- local old=./old
-
- if [ ! -f $old ]; then
- old=/dev/null
- fi
-
- shmif_dumpbus -p - bus1 2>/dev/null| \
- tcpdump -n -e -r - 2>/dev/null > ./new
- diff -u $old ./new |grep '^+' |cut -d '+' -f 2 > ./diff
- mv -f ./new ./old
- cat ./diff
-}
-
test_proxy_arp()
{
local arp_keep=5
local opts= title= flags=
local type=$1
- atf_check -s exit:0 ${inetserver} $SOCKSRC
- atf_check -s exit:0 ${inetserver} $SOCKDST
+ rump_server_start $SOCKSRC
+ rump_server_start $SOCKDST tap
setup_dst_server
setup_src_server $arp_keep
export RUMP_SERVER=$SOCKDST
atf_check -s exit:0 -o ignore rump.sysctl -w net.inet.ip.forwarding=1
- macaddr_dst=$(rump.ifconfig shmif0 |awk '/address/ {print $2;}')
+ macaddr_dst=$(get_macaddr $SOCKDST shmif0)
if [ "$type" = "pub" ]; then
opts="pub"
@@ -416,7 +402,7 @@ test_proxy_arp()
rump.ping -n -w 1 -c 1 $IP4DST_PROXYARP1
# Flushing
- extract_new_packets > ./out
+ extract_new_packets bus1 > ./out
# Set up proxy ARP entry
export RUMP_SERVER=$SOCKDST
@@ -435,7 +421,7 @@ test_proxy_arp()
rump.ping -n -w 1 -c 1 $IP4DST_PROXYARP1
fi
- extract_new_packets > ./out
+ extract_new_packets bus1 > ./out
$DEBUG && cat ./out
pkt1=$(make_pkt_str_arprep $IP4DST_PROXYARP1 $macaddr_dst)
@@ -461,7 +447,7 @@ test_proxy_arp()
atf_check -s not-exit:0 -o ignore -e ignore \
rump.ping -n -w 1 -c 1 $IP4DST_PROXYARP2
- extract_new_packets > ./out
+ extract_new_packets bus1 > ./out
$DEBUG && cat ./out
# ARP reply should be sent
@@ -482,12 +468,14 @@ arp_proxy_arp_pub_body()
{
test_proxy_arp pub
+ rump_server_destroy_ifaces
}
arp_proxy_arp_pubproxy_body()
{
test_proxy_arp pubproxy
+ rump_server_destroy_ifaces
}
arp_link_activation_body()
@@ -495,14 +483,14 @@ arp_link_activation_body()
local arp_keep=5
local bonus=2
- atf_check -s exit:0 ${inetserver} $SOCKSRC
- atf_check -s exit:0 ${inetserver} $SOCKDST
+ rump_server_start $SOCKSRC
+ rump_server_start $SOCKDST
setup_dst_server
setup_src_server $arp_keep
# flush old packets
- extract_new_packets > ./out
+ extract_new_packets bus1 > ./out
export RUMP_SERVER=$SOCKSRC
@@ -510,7 +498,7 @@ arp_link_activation_body()
b2:a1:00:00:00:01
atf_check -s exit:0 sleep 1
- extract_new_packets > ./out
+ extract_new_packets bus1 > ./out
$DEBUG && cat ./out
pkt=$(make_pkt_str_arpreq $IP4SRC $IP4SRC)
@@ -520,12 +508,14 @@ arp_link_activation_body()
b2:a1:00:00:00:02 active
atf_check -s exit:0 sleep 1
- extract_new_packets > ./out
+ extract_new_packets bus1 > ./out
$DEBUG && cat ./out
pkt=$(make_pkt_str_arpreq $IP4SRC $IP4SRC)
atf_check -s exit:0 -x \
"cat ./out |grep '$pkt' |grep -q 'b2:a1:00:00:00:02'"
+
+ rump_server_destroy_ifaces
}
arp_static_body()
@@ -533,14 +523,13 @@ arp_static_body()
local arp_keep=5
local macaddr_src=
- atf_check -s exit:0 ${inetserver} $SOCKSRC
- atf_check -s exit:0 ${inetserver} $SOCKDST
+ rump_server_start $SOCKSRC
+ rump_server_start $SOCKDST
setup_dst_server
setup_src_server $arp_keep
- export RUMP_SERVER=$SOCKSRC
- macaddr_src=$(rump.ifconfig shmif0 |awk '/address/ {print $2;}')
+ macaddr_src=$(get_macaddr $SOCKSRC shmif0)
# Set a (valid) static ARP entry for the src server
export RUMP_SERVER=$SOCKDST
@@ -551,37 +540,8 @@ arp_static_body()
# Test receiving an ARP request with the static ARP entry (as spa/sha)
export RUMP_SERVER=$SOCKSRC
atf_check -s exit:0 -o ignore rump.ping -n -w 1 -c 1 $IP4DST
-}
-cleanup()
-{
- env RUMP_SERVER=$SOCKSRC rump.halt
- env RUMP_SERVER=$SOCKDST rump.halt
-}
-
-dump_src()
-{
- export RUMP_SERVER=$SOCKSRC
- rump.netstat -nr
- rump.arp -n -a
- rump.ifconfig
- $HIJACKING dmesg
-}
-
-dump_dst()
-{
- export RUMP_SERVER=$SOCKDST
- rump.netstat -nr
- rump.arp -n -a
- rump.ifconfig
- $HIJACKING dmesg
-}
-
-dump()
-{
- dump_src
- dump_dst
- shmif_dumpbus -p - bus1 2>/dev/null| tcpdump -n -e -r -
+ rump_server_destroy_ifaces
}
arp_cache_expiration_5s_cleanup()
@@ -604,9 +564,8 @@ arp_command_cleanup()
arp_garp_cleanup()
{
- $DEBUG && dump_src
- $DEBUG && shmif_dumpbus -p - bus1 2>/dev/null| tcpdump -n -e -r -
- env RUMP_SERVER=$SOCKSRC rump.halt
+ $DEBUG && dump
+ cleanup
}
arp_cache_overwriting_cleanup()
diff --git a/contrib/netbsd-tests/net/arp/t_dad.sh b/contrib/netbsd-tests/net/arp/t_dad.sh
index aefcb0b..57a7d4b0 100755
--- a/contrib/netbsd-tests/net/arp/t_dad.sh
+++ b/contrib/netbsd-tests/net/arp/t_dad.sh
@@ -1,4 +1,4 @@
-# $NetBSD: t_dad.sh,v 1.7 2016/08/10 22:05:07 kre Exp $
+# $NetBSD: t_dad.sh,v 1.13 2016/11/25 08:51:16 ozaki-r Exp $
#
# Copyright (c) 2015 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -25,14 +25,10 @@
# POSSIBILITY OF SUCH DAMAGE.
#
-inetserver="rump_server -lrumpnet -lrumpnet_net -lrumpnet_netinet -lrumpnet_shmif"
-inetserver="${inetserver} -lrumpdev"
-HIJACKING="env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=sysctl=yes"
-
SOCKLOCAL=unix://commsock1
SOCKPEER=unix://commsock2
-DEBUG=false
+DEBUG=${DEBUG:-false}
atf_test_case dad_basic cleanup
atf_test_case dad_duplicated cleanup
@@ -54,10 +50,9 @@ setup_server()
local sock=$1
local ip=$2
- export RUMP_SERVER=$sock
+ rump_server_add_iface $sock shmif0 bus1
- atf_check -s exit:0 rump.ifconfig shmif0 create
- atf_check -s exit:0 rump.ifconfig shmif0 linkstr bus1
+ export RUMP_SERVER=$sock
atf_check -s exit:0 rump.ifconfig shmif0 inet $ip/24
atf_check -s exit:0 rump.ifconfig shmif0 up
atf_check -s exit:0 rump.ifconfig -w 10
@@ -74,30 +69,15 @@ make_pkt_str()
echo $pkt
}
-extract_new_packets()
-{
- local old=./old
-
- if [ ! -f $old ]; then
- old=/dev/null
- fi
-
- shmif_dumpbus -p - bus1 2>/dev/null| \
- tcpdump -n -e -r - 2>/dev/null > ./new
- diff -u $old ./new |grep '^+' |cut -d '+' -f 2 > ./diff
- mv -f ./new ./old
- cat ./diff
-}
-
dad_basic_body()
{
local pkt=
- atf_check -s exit:0 ${inetserver} $SOCKLOCAL
+ rump_server_start $SOCKLOCAL
+ rump_server_add_iface $SOCKLOCAL shmif0 bus1
+
export RUMP_SERVER=$SOCKLOCAL
- atf_check -s exit:0 rump.ifconfig shmif0 create
- atf_check -s exit:0 rump.ifconfig shmif0 linkstr bus1
atf_check -s exit:0 rump.ifconfig shmif0 inet 10.0.0.1/24
atf_check -s exit:0 rump.ifconfig shmif0 inet 10.0.0.2/24 alias
$DEBUG && rump.ifconfig shmif0
@@ -107,13 +87,13 @@ dad_basic_body()
$DEBUG && cat ./out
# The primary address doesn't start with tentative state
- atf_check -s not-exit:0 -x "cat ./out |grep 10.0.0.1 |grep -q tentative"
+ atf_check -s not-exit:0 -x "cat ./out |grep 10.0.0.1 |grep -iq tentative"
# The alias address starts with tentative state
# XXX we have no stable way to check this, so skip for now
- #atf_check -s exit:0 -x "cat ./out |grep 10.0.0.2 |grep -q tentative"
+ #atf_check -s exit:0 -x "cat ./out |grep 10.0.0.2 |grep -iq tentative"
atf_check -s exit:0 sleep 2
- extract_new_packets > ./out
+ extract_new_packets bus1 > ./out
$DEBUG && cat ./out
# Check DAD probe packets
@@ -127,14 +107,14 @@ dad_basic_body()
atf_check -s exit:0 rump.ifconfig -w 10
# Give a chance to send a DAD announce packet
atf_check -s exit:0 sleep 1
- extract_new_packets > ./out
+ extract_new_packets bus1 > ./out
$DEBUG && cat ./out
# Check the DAD announce packet
pkt=$(make_pkt_str 10.0.0.2 10.0.0.2)
atf_check -s exit:0 -x "cat ./out |grep -q '$pkt'"
# The alias address left tentative
- atf_check -s not-exit:0 -x "rump.ifconfig shmif0 |grep 10.0.0.2 |grep -q tentative"
+ atf_check -s not-exit:0 -x "rump.ifconfig shmif0 |grep 10.0.0.2 |grep -iq tentative"
#
# Add a new address on the fly
@@ -143,11 +123,11 @@ dad_basic_body()
# The new address starts with tentative state
# XXX we have no stable way to check this, so skip for now
- #atf_check -s exit:0 -x "rump.ifconfig shmif0 |grep 10.0.0.3 |grep -q tentative"
+ #atf_check -s exit:0 -x "rump.ifconfig shmif0 |grep 10.0.0.3 |grep -iq tentative"
# Check DAD probe packets
atf_check -s exit:0 sleep 2
- extract_new_packets > ./out
+ extract_new_packets bus1 > ./out
$DEBUG && cat ./out
pkt=$(make_pkt_str 10.0.0.3 0.0.0.0)
atf_check -s exit:0 -x "cat ./out |grep -q '$pkt'"
@@ -156,14 +136,16 @@ dad_basic_body()
atf_check -s exit:0 rump.ifconfig -w 10
# Give a chance to send a DAD announce packet
atf_check -s exit:0 sleep 1
- extract_new_packets > ./out
+ extract_new_packets bus1 > ./out
$DEBUG && cat ./out
# Check the DAD announce packet
pkt=$(make_pkt_str 10.0.0.3 10.0.0.3)
atf_check -s exit:0 -x "cat ./out |grep -q '$pkt'"
# The new address left tentative
- atf_check -s not-exit:0 -x "rump.ifconfig shmif0 |grep 10.0.0.3 |grep -q tentative"
+ atf_check -s not-exit:0 -x "rump.ifconfig shmif0 |grep 10.0.0.3 |grep -iq tentative"
+
+ rump_server_destroy_ifaces
}
dad_duplicated_body()
@@ -172,8 +154,8 @@ dad_duplicated_body()
local localip2=10.0.1.11
local peerip=10.0.1.2
- atf_check -s exit:0 ${inetserver} $SOCKLOCAL
- atf_check -s exit:0 ${inetserver} $SOCKPEER
+ rump_server_start $SOCKLOCAL
+ rump_server_start $SOCKPEER
setup_server $SOCKLOCAL $localip1
setup_server $SOCKPEER $peerip
@@ -181,7 +163,7 @@ dad_duplicated_body()
export RUMP_SERVER=$SOCKLOCAL
# The primary address isn't marked as duplicated
- atf_check -s not-exit:0 -x "rump.ifconfig shmif0 |grep $localip1 |grep -q duplicated"
+ atf_check -s not-exit:0 -x "rump.ifconfig shmif0 |grep $localip1 |grep -iq duplicated"
#
# Add a new address duplicated with the peer server
@@ -190,50 +172,20 @@ dad_duplicated_body()
atf_check -s exit:0 sleep 1
# The new address is marked as duplicated
- atf_check -s exit:0 -x "rump.ifconfig shmif0 |grep $peerip |grep -q duplicated"
+ atf_check -s exit:0 -x "rump.ifconfig shmif0 |grep $peerip |grep -iq duplicated"
# A unique address isn't marked as duplicated
atf_check -s exit:0 rump.ifconfig shmif0 inet $localip2 alias
atf_check -s exit:0 sleep 1
- atf_check -s not-exit:0 -x "rump.ifconfig shmif0 |grep $localip2 |grep -q duplicated"
-}
-
-cleanup()
-{
- env RUMP_SERVER=$SOCKLOCAL rump.halt
- env RUMP_SERVER=$SOCKPEER rump.halt
-}
-
-dump_local()
-{
- export RUMP_SERVER=$SOCKLOCAL
- rump.netstat -nr
- rump.arp -n -a
- rump.ifconfig
- $HIJACKING dmesg
-}
+ atf_check -s not-exit:0 -x "rump.ifconfig shmif0 |grep $localip2 |grep -iq duplicated"
-dump_peer()
-{
- export RUMP_SERVER=$SOCKPEER
- rump.netstat -nr
- rump.arp -n -a
- rump.ifconfig
- $HIJACKING dmesg
-}
-
-dump()
-{
- dump_local
- dump_peer
- shmif_dumpbus -p - bus1 2>/dev/null| tcpdump -n -e -r -
+ rump_server_destroy_ifaces
}
dad_basic_cleanup()
{
- $DEBUG && dump_local
- $DEBUG && shmif_dumpbus -p - bus1 2>/dev/null| tcpdump -n -e -r -
- env RUMP_SERVER=$SOCKLOCAL rump.halt
+ $DEBUG && dump
+ cleanup
}
dad_duplicated_cleanup()
diff --git a/contrib/netbsd-tests/net/icmp/t_icmp6_redirect.sh b/contrib/netbsd-tests/net/icmp/t_icmp6_redirect.sh
index c12017d..5dcdc9c 100755
--- a/contrib/netbsd-tests/net/icmp/t_icmp6_redirect.sh
+++ b/contrib/netbsd-tests/net/icmp/t_icmp6_redirect.sh
@@ -1,4 +1,4 @@
-# $NetBSD: t_icmp6_redirect.sh,v 1.2 2016/08/10 22:17:44 kre Exp $
+# $NetBSD: t_icmp6_redirect.sh,v 1.7 2016/11/25 08:51:16 ozaki-r Exp $
#
# Copyright (c) 2015 Internet Initiative Japan Inc.
# All rights reserved.
@@ -24,8 +24,6 @@
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
-netserver="rump_server -lrumpnet -lrumpnet_net -lrumpnet_shmif"
-netserver="${netserver} -lrumpnet_netinet -lrumpnet_netinet6 -lrumpdev"
SOCK_LOCAL=unix://commsock1
SOCK_PEER=unix://commsock2
@@ -44,50 +42,38 @@ IP6IF0_GW2=fc00:1::3
REDIRECT_TIMEOUT=5
-DEBUG=true
+DEBUG=${DEBUG:-true}
-get_lladdr()
-{
-
- export RUMP_SERVER=${1}
- rump.ifconfig ${2} inet6 | awk "/fe80/ {sub(/%$2/, \"\"); print \$2;}"
- unset RUMP_SERVER
-
- return 0
-}
+atf_test_case icmp6_redirect_basic cleanup
-atf_test_case basic cleanup
-
-basic_head()
+icmp6_redirect_basic_head()
{
atf_set "descr" "Test for the basically function of the ICMP6 redirect"
atf_set "require.progs" "rump_server rump.route rump.ping rump.ifconfig"
}
-basic_body()
+icmp6_redirect_basic_body()
{
local gw1_lladdr0=
local gw1_lladdr1=
local gw2_lladdr0=
- atf_check -s exit:0 ${netserver} ${SOCK_LOCAL}
- atf_check -s exit:0 ${netserver} ${SOCK_PEER}
- atf_check -s exit:0 ${netserver} ${SOCK_GW1}
- atf_check -s exit:0 ${netserver} ${SOCK_GW2}
+ rump_server_start $SOCK_LOCAL netinet6
+ rump_server_start $SOCK_PEER netinet6
+ rump_server_start $SOCK_GW1 netinet6
+ rump_server_start $SOCK_GW2 netinet6
#
# Setup
#
# Setup gateway #1 (real gateway)
export RUMP_SERVER=${SOCK_GW1}
- atf_check -s exit:0 rump.ifconfig shmif0 create
- atf_check -s exit:0 rump.ifconfig shmif0 linkstr ${BUS1}
+ rump_server_add_iface $SOCK_GW1 shmif0 $BUS1
+ rump_server_add_iface $SOCK_GW1 shmif1 $BUS2
+
atf_check -s exit:0 rump.ifconfig shmif0 inet6 ${IP6IF0_GW1}
atf_check -s exit:0 rump.ifconfig shmif0 up
-
- atf_check -s exit:0 rump.ifconfig shmif1 create
- atf_check -s exit:0 rump.ifconfig shmif1 linkstr ${BUS2}
atf_check -s exit:0 rump.ifconfig shmif1 inet6 ${IP6IF1_GW1}
atf_check -s exit:0 rump.ifconfig shmif1 up
@@ -95,13 +81,12 @@ basic_body()
net.inet6.ip6.forwarding=1
unset RUMP_SERVER
- gw1_lladdr0=`get_lladdr ${SOCK_GW1} shmif0`
- gw1_lladdr1=`get_lladdr ${SOCK_GW1} shmif1`
+ gw1_lladdr0=`get_linklocal_addr ${SOCK_GW1} shmif0`
+ gw1_lladdr1=`get_linklocal_addr ${SOCK_GW1} shmif1`
# Setup a peer behind gateway #1
export RUMP_SERVER=${SOCK_PEER}
- atf_check -s exit:0 rump.ifconfig shmif0 create
- atf_check -s exit:0 rump.ifconfig shmif0 linkstr ${BUS2}
+ rump_server_add_iface $SOCK_PEER shmif0 $BUS2
atf_check -s exit:0 rump.ifconfig shmif0 inet6 ${IP6IF0_PEER}
atf_check -s exit:0 rump.ifconfig shmif0 up
atf_check -s exit:0 -o ignore rump.route add \
@@ -110,8 +95,7 @@ basic_body()
# Setup gateway #2 (fake gateway)
export RUMP_SERVER=${SOCK_GW2}
- atf_check -s exit:0 rump.ifconfig shmif0 create
- atf_check -s exit:0 rump.ifconfig shmif0 linkstr ${BUS1}
+ rump_server_add_iface $SOCK_GW2 shmif0 $BUS1
atf_check -s exit:0 rump.ifconfig shmif0 inet6 ${IP6IF0_GW2}
atf_check -s exit:0 rump.ifconfig shmif0 up
@@ -121,11 +105,10 @@ basic_body()
net.inet6.ip6.forwarding=1
unset RUMP_SERVER
- gw2_lladdr0=`get_lladdr ${SOCK_GW2} shmif0`
+ gw2_lladdr0=`get_linklocal_addr ${SOCK_GW2} shmif0`
export RUMP_SERVER=${SOCK_LOCAL}
- atf_check -s exit:0 rump.ifconfig shmif0 create
- atf_check -s exit:0 rump.ifconfig shmif0 linkstr ${BUS1}
+ rump_server_add_iface $SOCK_LOCAL shmif0 $BUS1
atf_check -s exit:0 rump.ifconfig shmif0 inet6 ${IP6IF0_LOCAL}
atf_check -s exit:0 rump.ifconfig shmif0 up
@@ -152,20 +135,18 @@ basic_body()
atf_check -s exit:0 -o not-match:"gateway: ${gw1_lladdr0}" rump.route get \
-inet6 ${IP6IF0_PEER}
- unset RUMP_SERVER
+ rump_server_destroy_ifaces
}
-basic_cleanup()
+icmp6_redirect_basic_cleanup()
{
- env RUMP_SERVER=$SOCK_LOCAL rump.halt
- env RUMP_SERVER=$SOCK_PEER rump.halt
- env RUMP_SERVER=$SOCK_GW1 rump.halt
- env RUMP_SERVER=$SOCK_GW2 rump.halt
+ $DEBUG && dump
+ cleanup
}
atf_init_test_cases()
{
- atf_add_test_case basic
+ atf_add_test_case icmp6_redirect_basic
}
diff --git a/contrib/netbsd-tests/net/icmp/t_icmp_redirect.sh b/contrib/netbsd-tests/net/icmp/t_icmp_redirect.sh
index 730f2d2..6697216 100755
--- a/contrib/netbsd-tests/net/icmp/t_icmp_redirect.sh
+++ b/contrib/netbsd-tests/net/icmp/t_icmp_redirect.sh
@@ -1,4 +1,4 @@
-# $NetBSD: t_icmp_redirect.sh,v 1.3 2016/08/10 22:17:44 kre Exp $
+# $NetBSD: t_icmp_redirect.sh,v 1.6 2016/11/25 08:51:16 ozaki-r Exp $
#
# Copyright (c) 2015 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -27,8 +27,6 @@
# Most codes are derived from tests/net/route/t_flags.sh
-netserver=\
-"rump_server -lrumpnet -lrumpnet_net -lrumpnet_netinet -lrumpnet_shmif -lrumpdev"
SOCK_LOCAL=unix://commsock1
SOCK_PEER=unix://commsock2
SOCK_GW=unix://commsock3
@@ -36,7 +34,7 @@ BUS=bus1
BUS2=bus2
REDIRECT_TIMEOUT=5
-DEBUG=false
+DEBUG=${DEBUG:-false}
atf_test_case icmp_redirect_timeout cleanup
@@ -50,11 +48,10 @@ icmp_redirect_timeout_head()
setup_local()
{
- atf_check -s exit:0 ${netserver} ${SOCK_LOCAL}
+ rump_server_start $SOCK_LOCAL
+ rump_server_add_iface $SOCK_LOCAL shmif0 $BUS
export RUMP_SERVER=$SOCK_LOCAL
- atf_check -s exit:0 -o ignore rump.ifconfig shmif0 create
- atf_check -s exit:0 -o ignore rump.ifconfig shmif0 linkstr ${BUS}
atf_check -s exit:0 -o ignore rump.ifconfig shmif0 10.0.0.2/24
atf_check -s exit:0 -o ignore rump.ifconfig shmif0 up
@@ -68,11 +65,10 @@ setup_local()
setup_peer()
{
- atf_check -s exit:0 ${netserver} ${SOCK_PEER}
+ rump_server_start $SOCK_PEER
+ rump_server_add_iface $SOCK_PEER shmif0 $BUS
export RUMP_SERVER=$SOCK_PEER
- atf_check -s exit:0 -o ignore rump.ifconfig shmif0 create
- atf_check -s exit:0 -o ignore rump.ifconfig shmif0 linkstr ${BUS}
atf_check -s exit:0 -o ignore rump.ifconfig shmif0 10.0.0.1/24
atf_check -s exit:0 -o ignore rump.ifconfig shmif0 up
@@ -83,16 +79,14 @@ setup_peer()
setup_gw()
{
- atf_check -s exit:0 ${netserver} ${SOCK_GW}
+ rump_server_start $SOCK_GW
+ rump_server_add_iface $SOCK_GW shmif0 $BUS
+ rump_server_add_iface $SOCK_GW shmif1 $BUS2
export RUMP_SERVER=$SOCK_GW
- atf_check -s exit:0 -o ignore rump.ifconfig shmif0 create
- atf_check -s exit:0 -o ignore rump.ifconfig shmif0 linkstr ${BUS}
atf_check -s exit:0 -o ignore rump.ifconfig shmif0 10.0.0.254/24
atf_check -s exit:0 -o ignore rump.ifconfig shmif0 up
- atf_check -s exit:0 -o ignore rump.ifconfig shmif1 create
- atf_check -s exit:0 -o ignore rump.ifconfig shmif1 linkstr ${BUS2}
atf_check -s exit:0 -o ignore rump.ifconfig shmif1 10.0.2.1/24
atf_check -s exit:0 -o ignore rump.ifconfig shmif1 alias 10.0.2.2/24
atf_check -s exit:0 -o ignore rump.ifconfig shmif1 up
@@ -105,39 +99,6 @@ setup_gw()
$DEBUG && rump.netstat -rn -f inet
}
-teardown_gw()
-{
-
- env RUMP_SERVER=$SOCK_GW rump.halt
-}
-
-check_entry_flags()
-{
- local ip=$(echo $1 |sed 's/\./\\./g')
- local flags=$2
-
- atf_check -s exit:0 -o match:" $flags " -e ignore -x \
- "rump.netstat -rn -f inet | grep ^'$ip'"
-}
-
-check_entry_gw()
-{
- local ip=$(echo $1 |sed 's/\./\\./g')
- local gw=$2
-
- atf_check -s exit:0 -o match:" $gw " -e ignore -x \
- "rump.netstat -rn -f inet | grep ^'$ip'"
-}
-
-check_entry_fail()
-{
- local ip=$(echo $1 |sed 's/\./\\./g')
- local flags=$2 # Not used currently
-
- atf_check -s not-exit:0 -e ignore -x \
- "rump.netstat -rn -f inet | grep ^'$ip'"
-}
-
icmp_redirect_timeout_body()
{
@@ -159,7 +120,7 @@ icmp_redirect_timeout_body()
export RUMP_SERVER=$SOCK_PEER
atf_check -s exit:0 -o ignore rump.route add -net 10.0.2.0/24 10.0.0.254
# Up, Gateway, Static
- check_entry_flags 10.0.2/24 UGS
+ check_route_flags 10.0.2/24 UGS
#
# Setup the default gateway to the peer, 10.0.0.1
@@ -167,39 +128,25 @@ icmp_redirect_timeout_body()
export RUMP_SERVER=$SOCK_LOCAL
atf_check -s exit:0 -o ignore rump.route add default 10.0.0.1
# Up, Gateway, Static
- check_entry_flags default UGS
+ check_route_flags default UGS
# Try ping 10.0.2.1
atf_check -s exit:0 -o ignore rump.ping -n -w 1 -c 1 10.0.2.1
$DEBUG && rump.netstat -rn -f inet
# Up, Gateway, Host, Dynamic
- check_entry_flags 10.0.2.1 UGHD
- check_entry_gw 10.0.2.1 10.0.0.254
+ check_route_flags 10.0.2.1 UGHD
+ check_route_gw 10.0.2.1 10.0.0.254
atf_check -s exit:0 sleep $((REDIRECT_TIMEOUT + 2))
# The dynamic entry should be expired and removed
- check_entry_fail 10.0.2.1
+ check_route_no_entry 10.0.2.1
export RUMP_SERVER=$SOCK_PEER
$DEBUG && rump.netstat -rn -f inet
- teardown_gw
-}
-
-dump()
-{
-
- shmif_dumpbus -p - $BUS 2>/dev/null | tcpdump -n -e -r -
- gdb -ex bt /usr/bin/rump_server rump_server.core
-}
-
-cleanup()
-{
-
- env RUMP_SERVER=$SOCK_LOCAL rump.halt
- env RUMP_SERVER=$SOCK_PEER rump.halt
+ rump_server_destroy_ifaces
}
icmp_redirect_timeout_cleanup()
@@ -249,7 +196,7 @@ icmp_redirect_body()
export RUMP_SERVER=$SOCK_PEER
atf_check -s exit:0 -o ignore rump.route add -net 10.0.2.0/24 10.0.0.254
# Up, Gateway, Static
- check_entry_flags 10.0.2/24 UGS
+ check_route_flags 10.0.2/24 UGS
#
# Setup the default gateway to the peer, 10.0.0.1
@@ -257,7 +204,7 @@ icmp_redirect_body()
export RUMP_SERVER=$SOCK_LOCAL
atf_check -s exit:0 -o ignore rump.route add default 10.0.0.1
# Up, Gateway, Static
- check_entry_flags default UGS
+ check_route_flags default UGS
### ICMP redirects are NOT sent by the peer ###
@@ -274,7 +221,7 @@ icmp_redirect_body()
$DEBUG && rump.netstat -rn -f inet
# A direct route shouldn't be created
- check_entry_fail 10.0.2.1
+ check_route_no_entry 10.0.2.1
### ICMP redirects are sent by the peer ###
@@ -291,8 +238,8 @@ icmp_redirect_body()
$DEBUG && rump.netstat -rn -f inet
# Up, Gateway, Host, Dynamic
- check_entry_flags 10.0.2.1 UGHD
- check_entry_gw 10.0.2.1 10.0.0.254
+ check_route_flags 10.0.2.1 UGHD
+ check_route_gw 10.0.2.1 10.0.0.254
export RUMP_SERVER=$SOCK_PEER
$DEBUG && rump.netstat -rn -f inet
@@ -301,7 +248,7 @@ icmp_redirect_body()
# cleanup
export RUMP_SERVER=$SOCK_LOCAL
atf_check -s exit:0 -o ignore rump.route delete 10.0.2.1
- check_entry_fail 10.0.2.1
+ check_route_no_entry 10.0.2.1
### ICMP redirects are NOT sent by the peer (again) ###
@@ -318,10 +265,9 @@ icmp_redirect_body()
$DEBUG && rump.netstat -rn -f inet
# A direct route shouldn't be created
- check_entry_fail 10.0.2.1
-
+ check_route_no_entry 10.0.2.1
- teardown_gw
+ rump_server_destroy_ifaces
}
icmp_redirect_cleanup()
diff --git a/contrib/netbsd-tests/net/if/t_compat.c b/contrib/netbsd-tests/net/if/t_compat.c
index 4798034..9eb84a3 100644
--- a/contrib/netbsd-tests/net/if/t_compat.c
+++ b/contrib/netbsd-tests/net/if/t_compat.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_compat.c,v 1.1 2010/11/07 19:53:42 pooka Exp $ */
+/* $NetBSD: t_compat.c,v 1.4 2016/11/12 15:12:59 kre Exp $ */
#include <sys/socket.h>
#include <sys/ioctl.h>
@@ -65,6 +65,8 @@ ATF_TC_BODY(OOSIOCGIFBRDADDR, tc)
sprintf(ifreq.ifr_name, "shmif%d", ifnum);
netcfg_rump_if(ifreq.ifr_name, "1.7.64.10", "255.255.0.0");
+ atf_tc_expect_fail("PR kern/51610: rump does not include COMPAT_43");
+
/* query kernel for iface bcast */
RL(fd = rump_sys_socket(AF_INET, SOCK_DGRAM, 0));
RL(rump_sys_ioctl(fd, OOSIOCGIFBRDADDR, &ifreq));
diff --git a/contrib/netbsd-tests/net/if/t_ifconfig.sh b/contrib/netbsd-tests/net/if/t_ifconfig.sh
index e8c53e6..a610017 100755
--- a/contrib/netbsd-tests/net/if/t_ifconfig.sh
+++ b/contrib/netbsd-tests/net/if/t_ifconfig.sh
@@ -1,4 +1,4 @@
-# $NetBSD: t_ifconfig.sh,v 1.11 2016/08/10 22:30:02 kre Exp $
+# $NetBSD: t_ifconfig.sh,v 1.14 2016/10/01 22:15:04 kre Exp $
#
# Copyright (c) 2015 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -34,6 +34,9 @@ RUMP_FLAGS="${RUMP_FLAGS} -lrumpdev"
TIMEOUT=3
+anycast="[Aa][Nn][Yy][Cc][Aa][Ss][Tt]"
+deprecated="[Dd][Ee][Pp][Rr][Ee][Cc][Aa][Tt][Ee][Dd]"
+
atf_test_case ifconfig_create_destroy cleanup
ifconfig_create_destroy_head()
{
@@ -227,16 +230,17 @@ ifconfig_parameters_body()
rump.ifconfig shmif0
# down, up
atf_check -s exit:0 rump.ifconfig shmif0 down
- atf_check -s ignore -o ignore -e match:'down' rump.ping -c 1 \
+ atf_check -s not-exit:0 -o ignore -e ignore rump.ping -c 1 \
-w $TIMEOUT -n 192.168.0.2
atf_check -s exit:0 rump.ifconfig shmif0 up
+ atf_check -s exit:0 rump.ifconfig -w 10
atf_check -s exit:0 -o ignore rump.ping -c 1 -w $TIMEOUT -n 192.168.0.2
# alias
atf_check -s exit:0 rump.ifconfig shmif0 inet 192.168.1.1/24 alias
- atf_check -s exit:0 -o match:'alias 192.168.1.1' rump.ifconfig shmif0
+ atf_check -s exit:0 -o match:'192.168.1.1/24' rump.ifconfig shmif0
atf_check -s exit:0 rump.ifconfig shmif0 inet 192.168.1.1/24 -alias
- atf_check -s exit:0 -o not-match:'192.168.1.1' rump.ifconfig shmif0
+ atf_check -s exit:0 -o not-match:'192.168.1.1/24' rump.ifconfig shmif0
atf_check -s exit:0 rump.ifconfig shmif0 inet6 fc00::1
atf_check -s exit:0 rump.ifconfig shmif0 inet6 fc00::2
atf_check -s exit:0 -o match:'fc00::1' rump.ifconfig shmif0 inet6
@@ -290,22 +294,22 @@ ifconfig_parameters_body()
# anycast
atf_check -s exit:0 rump.ifconfig shmif0 inet6 fc00::2 anycast
- atf_check -s exit:0 -o match:'fc00::2.+anycast' rump.ifconfig shmif0 inet6
+ atf_check -s exit:0 -o match:"fc00::2.+$anycast" rump.ifconfig shmif0 inet6
# deprecated
atf_check -s exit:0 rump.ifconfig shmif0 inet6 fc00::3 deprecated
# Not deprecated immediately. Need to wait nd6_timer that does it is scheduled.
interval=$(sysctl -n net.inet6.icmp6.nd6_prune)
atf_check -s exit:0 sleep $((interval + 1))
- atf_check -s exit:0 -o match:'fc00::3.+deprecated' rump.ifconfig shmif0 inet6
+ atf_check -s exit:0 -o match:"fc00::3.+$deprecated" rump.ifconfig shmif0 inet6
atf_check -s exit:0 rump.ifconfig shmif0 inet6 fc00::3 -deprecated
- atf_check -s exit:0 -o not-match:'fc00::3.+deprecated' rump.ifconfig shmif0 inet6
+ atf_check -s exit:0 -o not-match:"fc00::3.+$deprecated" rump.ifconfig shmif0 inet6
# pltime
atf_check -s exit:0 rump.ifconfig shmif0 inet6 fc00::3 pltime 3
- atf_check -s exit:0 -o not-match:'fc00::3.+deprecated' rump.ifconfig shmif0 inet6
+ atf_check -s exit:0 -o not-match:"fc00::3.+$deprecated" rump.ifconfig shmif0 inet6
atf_check -s exit:0 sleep 5
- atf_check -s exit:0 -o match:'fc00::3.+deprecated' rump.ifconfig shmif0 inet6
+ atf_check -s exit:0 -o match:"fc00::3.+$deprecated" rump.ifconfig shmif0 inet6
# eui64
atf_check -s exit:0 rump.ifconfig shmif0 inet6 fc00:1::0 eui64
diff --git a/contrib/netbsd-tests/net/if_bridge/t_bridge.sh b/contrib/netbsd-tests/net/if_bridge/t_bridge.sh
index 769893d..25edb35 100755
--- a/contrib/netbsd-tests/net/if_bridge/t_bridge.sh
+++ b/contrib/netbsd-tests/net/if_bridge/t_bridge.sh
@@ -1,4 +1,4 @@
-# $NetBSD: t_bridge.sh,v 1.13 2016/08/10 22:37:07 kre Exp $
+# $NetBSD: t_bridge.sh,v 1.16 2016/11/25 08:51:16 ozaki-r Exp $
#
# Copyright (c) 2014 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -25,13 +25,6 @@
# POSSIBILITY OF SUCH DAMAGE.
#
-libs1="-lrumpnet -lrumpnet_net -lrumpnet_netinet"
-libs2="-lrumpnet_bridge -lrumpnet_shmif -lrumpdev"
-libs6="-lrumpnet_netinet6"
-
-inetserver="rump_server ${libs1} ${libs2}"
-inet6server="rump_server ${libs1} ${libs6} ${libs2}"
-
SOCK1=unix://commsock1
SOCK2=unix://commsock2
SOCK3=unix://commsock3
@@ -44,6 +37,7 @@ IPBR2=10.0.0.12
IP6BR1=fc00::11
IP6BR2=fc00::12
+DEBUG=${DEBUG:-false}
TIMEOUT=5
atf_test_case bridge_ipv4 cleanup
@@ -89,9 +83,8 @@ setup_endpoint()
bus=${3}
mode=${4}
+ rump_server_add_iface $sock shmif0 $bus
export RUMP_SERVER=${sock}
- atf_check -s exit:0 rump.ifconfig shmif0 create
- atf_check -s exit:0 rump.ifconfig shmif0 linkstr ${bus}
if [ $mode = "ipv6" ]; then
atf_check -s exit:0 rump.ifconfig shmif0 inet6 ${addr}
else
@@ -99,7 +92,7 @@ setup_endpoint()
fi
atf_check -s exit:0 rump.ifconfig shmif0 up
- rump.ifconfig shmif0
+ $DEBUG && rump.ifconfig shmif0
}
test_endpoint()
@@ -118,14 +111,6 @@ test_endpoint()
fi
}
-show_endpoint()
-{
- sock=${1}
-
- export RUMP_SERVER=${sock}
- rump.ifconfig -v shmif0
-}
-
test_setup()
{
test_endpoint $SOCK1 $IP1 bus1 ipv4
@@ -148,21 +133,20 @@ test_setup6()
setup_bridge_server()
{
+
+ rump_server_add_iface $SOCK2 shmif0 bus1
+ rump_server_add_iface $SOCK2 shmif1 bus2
export RUMP_SERVER=$SOCK2
- atf_check -s exit:0 rump.ifconfig shmif0 create
- atf_check -s exit:0 rump.ifconfig shmif0 linkstr bus1
atf_check -s exit:0 rump.ifconfig shmif0 up
-
- atf_check -s exit:0 rump.ifconfig shmif1 create
- atf_check -s exit:0 rump.ifconfig shmif1 linkstr bus2
atf_check -s exit:0 rump.ifconfig shmif1 up
}
setup()
{
- atf_check -s exit:0 ${inetserver} $SOCK1
- atf_check -s exit:0 ${inetserver} $SOCK2
- atf_check -s exit:0 ${inetserver} $SOCK3
+
+ rump_server_start $SOCK1 bridge
+ rump_server_start $SOCK2 bridge
+ rump_server_start $SOCK3 bridge
setup_endpoint $SOCK1 $IP1 bus1 ipv4
setup_endpoint $SOCK3 $IP2 bus2 ipv4
@@ -171,9 +155,10 @@ setup()
setup6()
{
- atf_check -s exit:0 ${inet6server} $SOCK1
- atf_check -s exit:0 ${inet6server} $SOCK2
- atf_check -s exit:0 ${inet6server} $SOCK3
+
+ rump_server_start $SOCK1 netinet6 bridge
+ rump_server_start $SOCK2 netinet6 bridge
+ rump_server_start $SOCK3 netinet6 bridge
setup_endpoint $SOCK1 $IP61 bus1 ipv6
setup_endpoint $SOCK3 $IP62 bus2 ipv6
@@ -244,19 +229,6 @@ test_setup_bridge()
unset LD_PRELOAD
}
-cleanup()
-{
- env RUMP_SERVER=$SOCK1 rump.halt
- env RUMP_SERVER=$SOCK2 rump.halt
- env RUMP_SERVER=$SOCK3 rump.halt
-}
-
-dump_bus()
-{
- /usr/bin/shmif_dumpbus -p - bus1 2>/dev/null| /usr/sbin/tcpdump -n -e -r -
- /usr/bin/shmif_dumpbus -p - bus2 2>/dev/null| /usr/sbin/tcpdump -n -e -r -
-}
-
down_up_interfaces()
{
export RUMP_SERVER=$SOCK1
@@ -360,11 +332,8 @@ test_brconfig_maxaddr()
addr1= addr3= n=
# Get MAC addresses of the endpoints.
- export RUMP_SERVER=$SOCK1
- addr1=$(rump.ifconfig shmif0 |awk '/address:/ { print $2;}')
- export RUMP_SERVER=$SOCK3
- addr3=$(rump.ifconfig shmif0 |awk '/address:/ { print $2;}')
- unset RUMP_SERVER
+ addr1=$(get_macaddr $SOCK1 shmif0)
+ addr3=$(get_macaddr $SOCK3 shmif0)
# Refill the MAC addresses of the endpoints.
export RUMP_SERVER=$SOCK1
@@ -422,6 +391,8 @@ bridge_ipv4_body()
teardown_bridge
test_ping_failure
+
+ rump_server_destroy_ifaces
}
bridge_ipv6_body()
@@ -438,6 +409,8 @@ bridge_ipv6_body()
teardown_bridge
test_ping6_failure
+
+ rump_server_destroy_ifaces
}
bridge_rtable_body()
@@ -448,16 +421,13 @@ bridge_rtable_body()
setup_bridge
# Get MAC addresses of the endpoints.
- export RUMP_SERVER=$SOCK1
- addr1=$(rump.ifconfig shmif0 |awk '/address:/ { print $2;}')
- export RUMP_SERVER=$SOCK3
- addr3=$(rump.ifconfig shmif0 |awk '/address:/ { print $2;}')
- unset RUMP_SERVER
+ addr1=$(get_macaddr $SOCK1 shmif0)
+ addr3=$(get_macaddr $SOCK3 shmif0)
# Confirm there is no MAC address caches.
export RUMP_SERVER=$SOCK2
export LD_PRELOAD=/usr/lib/librumphijack.so
- /sbin/brconfig bridge0
+ $DEBUG && /sbin/brconfig bridge0
atf_check -s exit:0 -o not-match:"$addr1" /sbin/brconfig bridge0
atf_check -s exit:0 -o not-match:"$addr3" /sbin/brconfig bridge0
unset LD_PRELOAD
@@ -470,7 +440,7 @@ bridge_rtable_body()
# Tests the addresses are in the cache.
export RUMP_SERVER=$SOCK2
export LD_PRELOAD=/usr/lib/librumphijack.so
- /sbin/brconfig bridge0
+ $DEBUG && /sbin/brconfig bridge0
atf_check -s exit:0 -o match:"$addr1 shmif0" /sbin/brconfig bridge0
atf_check -s exit:0 -o match:"$addr3 shmif1" /sbin/brconfig bridge0
@@ -487,7 +457,7 @@ bridge_rtable_body()
unset RUMP_SERVER
export RUMP_SERVER=$SOCK2
export LD_PRELOAD=/usr/lib/librumphijack.so
- /sbin/brconfig bridge0
+ $DEBUG && /sbin/brconfig bridge0
atf_check -s exit:0 -o match:"$addr1 shmif0" /sbin/brconfig bridge0
atf_check -s exit:0 -o match:"$addr3 shmif1" /sbin/brconfig bridge0
@@ -511,6 +481,8 @@ bridge_rtable_body()
# TODO: brconfig static/flushall/discover/learn
# TODO: cache expiration; it takes 5 minutes at least and we want to
# wait here so long. Should we have a sysctl to change the period?
+
+ rump_server_destroy_ifaces
}
bridge_member_ipv4_body()
@@ -531,6 +503,8 @@ bridge_member_ipv4_body()
teardown_bridge
test_ping_failure
+
+ rump_server_destroy_ifaces
}
bridge_member_ipv6_body()
@@ -550,35 +524,42 @@ bridge_member_ipv6_body()
teardown_bridge
test_ping6_failure
+
+ rump_server_destroy_ifaces
}
bridge_ipv4_cleanup()
{
- dump_bus
+
+ $DEBUG && dump
cleanup
}
bridge_ipv6_cleanup()
{
- dump_bus
+
+ $DEBUG && dump
cleanup
}
bridge_rtable_cleanup()
{
- dump_bus
+
+ $DEBUG && dump
cleanup
}
bridge_member_ipv4_cleanup()
{
- dump_bus
+
+ $DEBUG && dump
cleanup
}
bridge_member_ipv6_cleanup()
{
- dump_bus
+
+ $DEBUG && dump
cleanup
}
diff --git a/contrib/netbsd-tests/net/if_gif/t_gif.sh b/contrib/netbsd-tests/net/if_gif/t_gif.sh
index b804d7b..8690d78 100755
--- a/contrib/netbsd-tests/net/if_gif/t_gif.sh
+++ b/contrib/netbsd-tests/net/if_gif/t_gif.sh
@@ -1,4 +1,4 @@
-# $NetBSD: t_gif.sh,v 1.5 2016/08/10 08:29:20 ozaki-r Exp $
+# $NetBSD: t_gif.sh,v 1.9 2016/12/21 09:46:39 ozaki-r Exp $
#
# Copyright (c) 2015 Internet Initiative Japan Inc.
# All rights reserved.
@@ -25,10 +25,6 @@
# POSSIBILITY OF SUCH DAMAGE.
#
-server="rump_server -v -lrumpdev -lrumpnet -lrumpnet_net -lrumpnet_netinet \
- -lrumpnet_netinet6 -lrumpnet_shmif -lrumpnet_gif"
-HIJACKING="env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=sysctl=yes"
-
SOCK1=unix://commsock1 # for ROUTER1
SOCK2=unix://commsock2 # for ROUTER2
ROUTER1_LANIP=192.168.1.1
@@ -65,6 +61,7 @@ ROUTER2_GIFIP6_DUMMY=fc00:14::1
ROUTER2_GIFIP6_RECURSIVE1=fc00:104::1
ROUTER2_GIFIP6_RECURSIVE2=fc00:204::1
+DEBUG=${DEBUG:-true}
TIMEOUT=5
setup_router()
@@ -75,9 +72,10 @@ setup_router()
wan=${4}
wan_mode=${5}
+ rump_server_add_iface $sock shmif0 bus0
+ rump_server_add_iface $sock shmif1 bus1
+
export RUMP_SERVER=${sock}
- atf_check -s exit:0 rump.ifconfig shmif0 create
- atf_check -s exit:0 rump.ifconfig shmif0 linkstr bus0
if [ ${lan_mode} = "ipv6" ]; then
atf_check -s exit:0 rump.ifconfig shmif0 inet6 ${lan}
else
@@ -86,8 +84,6 @@ setup_router()
atf_check -s exit:0 rump.ifconfig shmif0 up
rump.ifconfig shmif0
- atf_check -s exit:0 rump.ifconfig shmif1 create
- atf_check -s exit:0 rump.ifconfig shmif1 linkstr bus1
if [ ${wan_mode} = "ipv6" ]; then
atf_check -s exit:0 rump.ifconfig shmif1 inet6 ${wan}
else
@@ -126,8 +122,8 @@ setup()
inner=${1}
outer=${2}
- atf_check -s exit:0 ${server} $SOCK1
- atf_check -s exit:0 ${server} $SOCK2
+ rump_server_start $SOCK1 netinet6 gif
+ rump_server_start $SOCK2 netinet6 gif
router1_lan=""
router1_lan_mode=""
@@ -482,18 +478,6 @@ teardown_recursive_tunnels()
atf_check -s exit:0 rump.ifconfig gif2 destroy
}
-cleanup()
-{
- env RUMP_SERVER=$SOCK1 rump.halt
- env RUMP_SERVER=$SOCK2 rump.halt
-}
-
-dump_bus()
-{
- /usr/bin/shmif_dumpbus -p - bus0 2>/dev/null| /usr/sbin/tcpdump -n -e -r -
- /usr/bin/shmif_dumpbus -p - bus1 2>/dev/null| /usr/sbin/tcpdump -n -e -r -
-}
-
test_ping_failure()
{
mode=$1
@@ -739,7 +723,7 @@ add_test()
inner=$3
outer=$4
- name="${category}${inner}over${outer}"
+ name="gif_${category}_${inner}over${outer}"
fulldesc="Does ${inner} over ${outer} if_gif ${desc}"
atf_test_case ${name} cleanup
@@ -751,9 +735,10 @@ add_test()
${category}_setup ${inner} ${outer}; \
${category}_test ${inner} ${outer}; \
${category}_teardown ${inner} ${outer}; \
+ rump_server_destroy_ifaces; \
}; \
${name}_cleanup() { \
- dump_bus; \
+ $DEBUG && dump; \
cleanup; \
}"
atf_add_test_case ${name}
diff --git a/contrib/netbsd-tests/net/if_pppoe/t_pppoe.sh b/contrib/netbsd-tests/net/if_pppoe/t_pppoe.sh
index 3199ca0..8d9d5c2 100755
--- a/contrib/netbsd-tests/net/if_pppoe/t_pppoe.sh
+++ b/contrib/netbsd-tests/net/if_pppoe/t_pppoe.sh
@@ -1,4 +1,4 @@
-# $NetBSD: t_pppoe.sh,v 1.2 2016/08/07 23:34:31 pgoyette Exp $
+# $NetBSD: t_pppoe.sh,v 1.16 2016/12/14 03:30:30 knakahara Exp $
#
# Copyright (c) 2016 Internet Initiative Japan Inc.
# All rights reserved.
@@ -28,6 +28,7 @@
server="rump_server -lrump -lrumpnet -lrumpnet_net -lrumpnet_netinet \
-lrumpnet_netinet6 -lrumpnet_shmif -lrumpdev \
-lrumpnet_pppoe"
+# pppoectl doesn't work with RUMPHIJACK=sysctl=yes
HIJACKING="env LD_PRELOAD=/usr/lib/librumphijack.so"
SERVER=unix://commsock1
@@ -35,17 +36,23 @@ CLIENT=unix://commsock2
SERVER_IP=10.3.3.1
CLIENT_IP=10.3.3.3
+SERVER_IP6=fc00::1
+CLIENT_IP6=fc00::3
AUTHNAME=foobar@baz.com
SECRET=oink
BUS=bus0
TIMEOUT=3
-WAITTIME=5
-DEBUG=false
-
-atf_test_case pap cleanup
+WAITTIME=10
+DEBUG=${DEBUG:-false}
setup()
{
+ inet=true
+
+ if [ $# -ne 0 ]; then
+ eval $@
+ fi
+
atf_check -s exit:0 ${server} $SERVER
atf_check -s exit:0 ${server} $CLIENT
@@ -55,7 +62,8 @@ setup()
atf_check -s exit:0 rump.ifconfig shmif0 up
atf_check -s exit:0 rump.ifconfig pppoe0 create
- atf_check -s exit:0 rump.ifconfig pppoe0 inet $SERVER_IP $CLIENT_IP down
+ $inet && atf_check -s exit:0 rump.ifconfig pppoe0 \
+ inet $SERVER_IP $CLIENT_IP down
atf_check -s exit:0 rump.ifconfig pppoe0 link0
$DEBUG && rump.ifconfig
@@ -70,22 +78,19 @@ setup()
atf_check -s exit:0 rump.ifconfig shmif0 up
atf_check -s exit:0 rump.ifconfig pppoe0 create
- atf_check -s exit:0 rump.ifconfig pppoe0 inet 0.0.0.0 0.0.0.1 down
+ $inet && atf_check -s exit:0 rump.ifconfig pppoe0 \
+ inet 0.0.0.0 0.0.0.1 down
atf_check -s exit:0 -x "$HIJACKING pppoectl -e shmif0 pppoe0"
unset RUMP_SERVER
}
+
cleanup()
{
env RUMP_SERVER=$SERVER rump.halt
env RUMP_SERVER=$CLIENT rump.halt
}
-pap_head()
-{
- atf_set "descr" "Does simple pap tests"
- atf_set "require.progs" "rump_server pppoectl"
-}
wait_for_session_established()
{
@@ -98,21 +103,50 @@ wait_for_session_established()
sleep 1
done
- if [ $dontfail != "dontfail" ]; then
+ if [ "$dontfail" != "dontfail" ]; then
atf_fail "Couldn't connect to the server for $n seconds."
fi
}
-pap_body()
+wait_for_disconnected()
+{
+ local dontfail=$1
+ local n=$WAITTIME
+
+ for i in $(seq $n); do
+ $HIJACKING pppoectl -d pppoe0 | grep -q "state = initial"
+ [ $? = 0 ] && return
+ # If PPPoE client is disconnected by PPPoE server and then
+ # the client kicks callout of pppoe_timeout(), the client
+ # state is changed to PPPOE_STATE_PADI_SENT while padi retrying.
+ $HIJACKING pppoectl -d pppoe0 | grep -q "state = PADI sent"
+ [ $? = 0 ] && return
+
+ sleep 1
+ done
+
+ if [ "$dontfail" != "dontfail" ]; then
+ atf_fail "Couldn't disconnect for $n seconds."
+ fi
+}
+
+run_test()
{
- local auth=pap
+ local auth=$1
setup
+ # As pppoe client doesn't support rechallenge yet.
+ local server_optparam=""
+ if [ $auth = "chap" ]; then
+ server_optparam="norechallenge"
+ fi
+
export RUMP_SERVER=$SERVER
local setup_serverparam="pppoectl pppoe0 hisauthproto=$auth \
'hisauthname=$AUTHNAME' \
'hisauthsecret=$SECRET' \
- 'myauthproto=none'"
+ 'myauthproto=none' \
+ $server_optparam"
atf_check -s exit:0 -x "$HIJACKING $setup_serverparam"
atf_check -s exit:0 rump.ifconfig pppoe0 up
unset RUMP_SERVER
@@ -130,8 +164,11 @@ pap_body()
unset RUMP_SERVER
# test for disconnection from server
- atf_check -s exit:0 -x "env RUMP_SERVER=$SERVER rump.ifconfig pppoe0 down"
+ export RUMP_SERVER=$SERVER
+ atf_check -s exit:0 rump.ifconfig pppoe0 down
+ wait_for_disconnected
export RUMP_SERVER=$CLIENT
+ wait_for_disconnected
atf_check -s not-exit:0 -o ignore -e ignore \
rump.ping -c 1 -w $TIMEOUT $SERVER_IP
atf_check -s exit:0 -o match:'PADI sent' -x "$HIJACKING pppoectl -d pppoe0"
@@ -145,15 +182,18 @@ pap_body()
unset RUMP_SERVER
# test for disconnection from client
- atf_check -s exit:0 -x "env RUMP_SERVER=$CLIENT rump.ifconfig pppoe0 down"
+ export RUMP_SERVER=$CLIENT
+ atf_check -s exit:0 -x rump.ifconfig pppoe0 down
+ wait_for_disconnected
export RUMP_SERVER=$SERVER
+ wait_for_disconnected
$DEBUG && $HIJACKING pppoectl -d pppoe0
atf_check -s not-exit:0 -o ignore -e ignore \
rump.ping -c 1 -w $TIMEOUT $CLIENT_IP
atf_check -s exit:0 -o match:'initial' -x "$HIJACKING pppoectl -d pppoe0"
unset RUMP_SERVER
- # test for recconecting
+ # test for reconnecting
export RUMP_SERVER=$CLIENT
atf_check -s exit:0 -x rump.ifconfig pppoe0 up
wait_for_session_established
@@ -162,6 +202,7 @@ pap_body()
unset RUMP_SERVER
export RUMP_SERVER=$SERVER
+ atf_check -s exit:0 rump.ifconfig -w 10
atf_check -s exit:0 -o ignore rump.ping -c 1 -w $TIMEOUT $CLIENT_IP
atf_check -s exit:0 -o match:'session' -x "$HIJACKING pppoectl -d pppoe0"
$DEBUG && HIJACKING pppoectl -d pppoe0
@@ -170,6 +211,7 @@ pap_body()
# test for invalid password
export RUMP_SERVER=$CLIENT
atf_check -s exit:0 rump.ifconfig pppoe0 down
+ wait_for_disconnected
local setup_clientparam="pppoectl pppoe0 myauthproto=$auth \
'myauthname=$AUTHNAME' \
'myauthsecret=invalidsecret' \
@@ -179,15 +221,196 @@ pap_body()
wait_for_session_established dontfail
atf_check -s not-exit:0 -o ignore -e ignore \
rump.ping -c 1 -w $TIMEOUT $SERVER_IP
+ atf_check -s exit:0 -o match:'DETACHED' rump.ifconfig pppoe0
+ unset RUMP_SERVER
+}
+
+atf_test_case pppoe_pap cleanup
+
+pppoe_pap_head()
+{
+ atf_set "descr" "Does simple pap tests"
+ atf_set "require.progs" "rump_server pppoectl"
+}
+
+pppoe_pap_body()
+{
+ run_test pap
+}
+
+pppoe_pap_cleanup()
+{
+ cleanup
+}
+
+atf_test_case pppoe_chap cleanup
+
+pppoe_chap_head()
+{
+ atf_set "descr" "Does simple chap tests"
+ atf_set "require.progs" "rump_server pppoectl"
+}
+
+pppoe_chap_body()
+{
+ run_test chap
+}
+
+pppoe_chap_cleanup()
+{
+ cleanup
+}
+
+run_test6()
+{
+ local auth=$1
+ setup "inet=false"
+
+ # As pppoe client doesn't support rechallenge yet.
+ local server_optparam=""
+ if [ $auth = "chap" ]; then
+ server_optparam="norechallenge"
+ fi
+
+ export RUMP_SERVER=$SERVER
+ local setup_serverparam="pppoectl pppoe0 hisauthproto=$auth \
+ 'hisauthname=$AUTHNAME' \
+ 'hisauthsecret=$SECRET' \
+ 'myauthproto=none' \
+ $server_optparam"
+ atf_check -s exit:0 -x "$HIJACKING $setup_serverparam"
+ atf_check -s exit:0 rump.ifconfig pppoe0 inet6 $SERVER_IP6/64 down
+ atf_check -s exit:0 rump.ifconfig pppoe0 up
+ unset RUMP_SERVER
+
+ export RUMP_SERVER=$CLIENT
+ local setup_clientparam="pppoectl pppoe0 myauthproto=$auth \
+ 'myauthname=$AUTHNAME' \
+ 'myauthsecret=$SECRET' \
+ 'hisauthproto=none'"
+ atf_check -s exit:0 -x "$HIJACKING $setup_clientparam"
+ atf_check -s exit:0 rump.ifconfig pppoe0 inet6 $CLIENT_IP6/64 down
+ atf_check -s exit:0 rump.ifconfig pppoe0 up
+ $DEBUG && rump.ifconfig
+ wait_for_session_established
+ atf_check -s exit:0 -o ignore rump.ifconfig -w 10
+ export RUMP_SERVER=$SERVER
+ atf_check -s exit:0 -o ignore rump.ifconfig -w 10
+ export RUMP_SERVER=$CLIENT
+ atf_check -s exit:0 -o ignore rump.ping6 -c 1 -X $TIMEOUT $SERVER_IP6
+ unset RUMP_SERVER
+
+ # test for disconnection from server
+ export RUMP_SERVER=$SERVER
+ session_id=`$HIJACKING pppoectl -d pppoe0 | grep state`
+ atf_check -s exit:0 rump.ifconfig pppoe0 down
+ wait_for_disconnected
+ export RUMP_SERVER=$CLIENT
+ wait_for_disconnected
+ atf_check -s not-exit:0 -o ignore -e ignore \
+ rump.ping6 -c 1 -X $TIMEOUT $SERVER_IP6
+ atf_check -s exit:0 -o not-match:"$session_id" -x "$HIJACKING pppoectl -d pppoe0"
+ unset RUMP_SERVER
+
+ # test for recoonecting
+ export RUMP_SERVER=$SERVER
+ atf_check -s exit:0 rump.ifconfig pppoe0 up
+ wait_for_session_established
+ atf_check -s exit:0 rump.ifconfig -w 10
+ $DEBUG && $HIJACKING pppoectl -d pppoe0
+ $DEBUG && rump.ifconfig pppoe0
+ export RUMP_SERVER=$CLIENT
+ atf_check -s exit:0 -o ignore rump.ifconfig -w 10
+ atf_check -s exit:0 -o ignore rump.ping6 -c 1 -X $TIMEOUT $SERVER_IP6
+ unset RUMP_SERVER
+
+ # test for disconnection from client
+ export RUMP_SERVER=$CLIENT
+ atf_check -s exit:0 rump.ifconfig pppoe0 down
+ wait_for_disconnected
+
+ export RUMP_SERVER=$SERVER
+ wait_for_disconnected
+ $DEBUG && $HIJACKING pppoectl -d pppoe0
+ atf_check -s not-exit:0 -o ignore -e ignore \
+ rump.ping6 -c 1 -X $TIMEOUT $CLIENT_IP6
atf_check -s exit:0 -o match:'initial' -x "$HIJACKING pppoectl -d pppoe0"
unset RUMP_SERVER
+
+ # test for reconnecting
+ export RUMP_SERVER=$CLIENT
+ atf_check -s exit:0 rump.ifconfig pppoe0 up
+ wait_for_session_established
+ atf_check -s exit:0 rump.ifconfig -w 10
+
+ $DEBUG && rump.ifconfig pppoe0
+ $DEBUG && $HIJACKING pppoectl -d pppoe0
+ unset RUMP_SERVER
+
+ export RUMP_SERVER=$SERVER
+ atf_check -s exit:0 rump.ifconfig -w 10
+ atf_check -s exit:0 -o ignore rump.ping6 -c 1 -X $TIMEOUT $CLIENT_IP6
+ atf_check -s exit:0 -o match:'session' -x "$HIJACKING pppoectl -d pppoe0"
+ $DEBUG && HIJACKING pppoectl -d pppoe0
+ unset RUMP_SERVER
+
+ # test for invalid password
+ export RUMP_SERVER=$CLIENT
+ atf_check -s exit:0 rump.ifconfig pppoe0 down
+ wait_for_disconnected
+ local setup_clientparam="pppoectl pppoe0 myauthproto=$auth \
+ 'myauthname=$AUTHNAME' \
+ 'myauthsecret=invalidsecret' \
+ 'hisauthproto=none'"
+ atf_check -s exit:0 -x "$HIJACKING $setup_clientparam"
+ atf_check -s exit:0 rump.ifconfig pppoe0 up
+ wait_for_session_established dontfail
+ atf_check -s not-exit:0 -o ignore -e ignore \
+ rump.ping6 -c 1 -X $TIMEOUT $SERVER_IP6
+ atf_check -s exit:0 -o match:'DETACHED' rump.ifconfig pppoe0
+ unset RUMP_SERVER
}
-pap_cleanup()
+atf_test_case pppoe6_pap cleanup
+
+pppoe6_pap_head()
+{
+ atf_set "descr" "Does simple pap using IPv6 tests"
+ atf_set "require.progs" "rump_server pppoectl"
+}
+
+pppoe6_pap_body()
+{
+ run_test6 pap
+}
+
+pppoe6_pap_cleanup()
+{
+ cleanup
+}
+
+atf_test_case pppoe6_chap cleanup
+
+pppoe6_chap_head()
+{
+ atf_set "descr" "Does simple chap using IPv6 tests"
+ atf_set "require.progs" "rump_server pppoectl"
+}
+
+pppoe6_chap_body()
+{
+ run_test6 chap
+}
+
+pppoe6_chap_cleanup()
{
cleanup
}
+
atf_init_test_cases()
{
- atf_add_test_case pap
+ atf_add_test_case pppoe_pap
+ atf_add_test_case pppoe_chap
+ atf_add_test_case pppoe6_pap
+ atf_add_test_case pppoe6_chap
}
diff --git a/contrib/netbsd-tests/net/if_tap/t_tap.sh b/contrib/netbsd-tests/net/if_tap/t_tap.sh
index 29efc20..4b1ce25 100755
--- a/contrib/netbsd-tests/net/if_tap/t_tap.sh
+++ b/contrib/netbsd-tests/net/if_tap/t_tap.sh
@@ -1,4 +1,4 @@
-# $NetBSD: t_tap.sh,v 1.3 2016/08/10 22:42:21 kre Exp $
+# $NetBSD: t_tap.sh,v 1.6 2016/11/25 08:51:16 ozaki-r Exp $
#
# Copyright (c) 2016 Internet Initiative Japan Inc.
# All rights reserved.
@@ -25,10 +25,6 @@
# POSSIBILITY OF SUCH DAMAGE.
#
-RUMP_FLAGS="-lrumpnet -lrumpnet_net -lrumpnet_netinet -lrumpnet_netinet6"
-RUMP_FLAGS="$RUMP_FLAGS -lrumpnet_shmif -lrumpnet_tap -lrumpnet_bridge -lrumpdev"
-HIJACKING="env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=sysctl=yes"
-
SOCK_LOCAL=unix://commsock1
SOCK_REMOTE=unix://commsock2
BUS=bus1
@@ -39,7 +35,7 @@ IP6_LOCAL=fc00::1
IP6_TAP=fc00::2
IP6_REMOTE=fc00::3
-DEBUG=false
+DEBUG=${DEBUG:-false}
TIMEOUT=1
atf_test_case tap_create_destroy cleanup
@@ -53,7 +49,7 @@ tap_create_destroy_head()
tap_create_destroy_body()
{
- atf_check -s exit:0 rump_server ${RUMP_FLAGS} ${SOCK_LOCAL}
+ rump_server_start $SOCK_LOCAL netinet6 tap
export RUMP_SERVER=${SOCK_LOCAL}
@@ -77,7 +73,8 @@ tap_create_destroy_body()
tap_create_destroy_cleanup()
{
- RUMP_SERVER=${SOCK_LOCAL} rump.halt
+ $DEBUG && dump
+ cleanup
}
atf_test_case tap_stand_alone cleanup
@@ -90,13 +87,14 @@ tap_create_destroy_head()
tap_stand_alone_body()
{
- atf_check -s exit:0 rump_server ${RUMP_FLAGS} ${SOCK_LOCAL}
- atf_check -s exit:0 rump_server ${RUMP_FLAGS} ${SOCK_REMOTE}
- export RUMP_SERVER=${SOCK_LOCAL}
+ rump_server_start $SOCK_LOCAL netinet6 tap
+ rump_server_start $SOCK_REMOTE netinet6 tap
- atf_check -s exit:0 rump.ifconfig shmif0 create
- atf_check -s exit:0 rump.ifconfig shmif0 linkstr $BUS
+ rump_server_add_iface $SOCK_LOCAL shmif0 $BUS
+ rump_server_add_iface $SOCK_REMOTE shmif0 $BUS
+
+ export RUMP_SERVER=${SOCK_LOCAL}
atf_check -s exit:0 rump.ifconfig shmif0 $IP4_LOCAL
atf_check -s exit:0 rump.ifconfig shmif0 inet6 $IP6_LOCAL
atf_check -s exit:0 rump.ifconfig shmif0 up
@@ -108,8 +106,6 @@ tap_stand_alone_body()
export RUMP_SERVER=${SOCK_REMOTE}
- atf_check -s exit:0 rump.ifconfig shmif0 create
- atf_check -s exit:0 rump.ifconfig shmif0 linkstr $BUS
atf_check -s exit:0 rump.ifconfig shmif0 $IP4_REMOTE
atf_check -s exit:0 rump.ifconfig shmif0 inet6 $IP6_REMOTE
atf_check -s exit:0 rump.ifconfig shmif0 up
@@ -124,13 +120,15 @@ tap_stand_alone_body()
# Cannot reach to an alone tap
atf_check -s not-exit:0 -o ignore -e ignore \
rump.ping6 -n -X $TIMEOUT -c 1 $IP6_TAP
+
+ rump_server_destroy_ifaces
}
tap_stand_alone_cleanup()
{
- RUMP_SERVER=${SOCK_LOCAL} rump.halt
- RUMP_SERVER=${SOCK_REMOTE} rump.halt
+ $DEBUG && dump
+ cleanup
}
atf_test_case tap_bridged cleanup
@@ -143,13 +141,15 @@ tap_bridged_head()
tap_bridged_body()
{
- atf_check -s exit:0 rump_server ${RUMP_FLAGS} ${SOCK_LOCAL}
- atf_check -s exit:0 rump_server ${RUMP_FLAGS} ${SOCK_REMOTE}
+
+ rump_server_start $SOCK_LOCAL netinet6 tap bridge
+ rump_server_start $SOCK_REMOTE netinet6 tap
+
+ rump_server_add_iface $SOCK_LOCAL shmif0 $BUS
+ rump_server_add_iface $SOCK_REMOTE shmif0 $BUS
export RUMP_SERVER=${SOCK_LOCAL}
- atf_check -s exit:0 rump.ifconfig shmif0 create
- atf_check -s exit:0 rump.ifconfig shmif0 linkstr $BUS
atf_check -s exit:0 rump.ifconfig shmif0 $IP4_LOCAL
atf_check -s exit:0 rump.ifconfig shmif0 inet6 $IP6_LOCAL
atf_check -s exit:0 rump.ifconfig shmif0 up
@@ -168,8 +168,6 @@ tap_bridged_body()
export RUMP_SERVER=${SOCK_REMOTE}
- atf_check -s exit:0 rump.ifconfig shmif0 create
- atf_check -s exit:0 rump.ifconfig shmif0 linkstr $BUS
atf_check -s exit:0 rump.ifconfig shmif0 $IP4_REMOTE
atf_check -s exit:0 rump.ifconfig shmif0 inet6 $IP6_REMOTE
atf_check -s exit:0 rump.ifconfig shmif0 up
@@ -180,13 +178,15 @@ tap_bridged_body()
atf_check -s exit:0 -o ignore rump.ping6 -n -X $TIMEOUT -c 1 $IP6_LOCAL
atf_check -s exit:0 -o ignore rump.ping6 -n -X $TIMEOUT -c 1 $IP6_TAP
+
+ rump_server_destroy_ifaces
}
tap_bridged_cleanup()
{
- RUMP_SERVER=${SOCK_LOCAL} rump.halt
- RUMP_SERVER=${SOCK_REMOTE} rump.halt
+ $DEBUG && dump
+ cleanup
}
atf_init_test_cases()
diff --git a/contrib/netbsd-tests/net/mcast/t_mcast.sh b/contrib/netbsd-tests/net/mcast/t_mcast.sh
index 67e13d4..aeb7000 100755
--- a/contrib/netbsd-tests/net/mcast/t_mcast.sh
+++ b/contrib/netbsd-tests/net/mcast/t_mcast.sh
@@ -1,4 +1,4 @@
-# $NetBSD: t_mcast.sh,v 1.2 2016/08/10 22:45:39 kre Exp $
+# $NetBSD: t_mcast.sh,v 1.4 2016/11/25 08:51:16 ozaki-r Exp $
#
# Copyright (c) 2015 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -25,12 +25,9 @@
# POSSIBILITY OF SUCH DAMAGE.
#
-netserver="rump_server -lrumpnet -lrumpnet_net"
-netserver="$netserver -lrumpnet_netinet -lrumpnet_netinet6 -lrumpnet_shmif"
-netserver="$netserver -lrumpdev"
export RUMP_SERVER=unix://commsock
-DEBUG=false
+DEBUG=${DEBUG:-false}
run_test()
{
@@ -38,9 +35,8 @@ run_test()
local opts="$2"
local mcast="$(atf_get_srcdir)/mcast"
- atf_check -s exit:0 ${netserver} ${RUMP_SERVER}
- atf_check -s exit:0 rump.ifconfig shmif0 create
- atf_check -s exit:0 rump.ifconfig shmif0 linkstr bus1
+ rump_server_start $RUMP_SERVER netinet6
+ rump_server_add_iface $RUMP_SERVER shmif0 bus1
atf_check -s exit:0 rump.ifconfig shmif0 10.0.0.2/24
atf_check -s exit:0 rump.ifconfig shmif0 inet6 fc00::2/64
atf_check -s exit:0 rump.ifconfig shmif0 up
@@ -79,11 +75,11 @@ add_test()
}; \
mcast_${name}_body() { \
run_test \"${name}\" \"${opts}\"; \
+ rump_server_destroy_ifaces; \
}; \
mcast_${name}_cleanup() { \
- ${DEBUG} && /usr/bin/shmif_dumpbus -p - bus1 2>/dev/null | \
- /usr/sbin/tcpdump -n -e -r -; \
- env RUMP_SERVER=unix://commsock rump.halt; \
+ ${DEBUG} && dump; \
+ cleanup; \
}"
atf_add_test_case "mcast_${name}"
}
diff --git a/contrib/netbsd-tests/net/ndp/t_dad.sh b/contrib/netbsd-tests/net/ndp/t_dad.sh
index 98b8ae0..50ec933 100755
--- a/contrib/netbsd-tests/net/ndp/t_dad.sh
+++ b/contrib/netbsd-tests/net/ndp/t_dad.sh
@@ -1,4 +1,4 @@
-# $NetBSD: t_dad.sh,v 1.5 2016/08/10 23:07:57 kre Exp $
+# $NetBSD: t_dad.sh,v 1.12 2016/11/25 08:51:17 ozaki-r Exp $
#
# Copyright (c) 2015 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -25,18 +25,16 @@
# POSSIBILITY OF SUCH DAMAGE.
#
-inetserver="rump_server -lrumpnet -lrumpnet_net -lrumpnet_netinet"
-inetserver="$inetserver -lrumpnet_netinet6 -lrumpnet_shmif"
-inetserver="$inetserver -lrumpdev"
-HIJACKING="env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=sysctl=yes"
-
SOCKLOCAL=unix://commsock1
SOCKPEER=unix://commsock2
-DEBUG=false
+DEBUG=${DEBUG:-false}
+
+duplicated="[Dd][Uu][Pp][Ll][Ii][Cc][Aa][Tt][Ee][Dd]"
atf_test_case dad_basic cleanup
atf_test_case dad_duplicated cleanup
+atf_test_case dad_count cleanup
dad_basic_head()
{
@@ -50,15 +48,20 @@ dad_duplicated_head()
atf_set "require.progs" "rump_server"
}
+dad_count_head()
+{
+ atf_set "descr" "Tests for IPv6 DAD count behavior"
+ atf_set "require.progs" "rump_server"
+}
+
setup_server()
{
local sock=$1
local ip=$2
- export RUMP_SERVER=$sock
+ rump_server_add_iface $sock shmif0 bus1
- atf_check -s exit:0 rump.ifconfig shmif0 create
- atf_check -s exit:0 rump.ifconfig shmif0 linkstr bus1
+ export RUMP_SERVER=$sock
atf_check -s exit:0 rump.ifconfig shmif0 inet6 $ip
atf_check -s exit:0 rump.ifconfig shmif0 up
atf_check -s exit:0 rump.ifconfig -w 10
@@ -76,21 +79,6 @@ make_ns_pkt_str()
echo $pkt
}
-extract_new_packets()
-{
- local old=./old
-
- if [ ! -f $old ]; then
- old=/dev/null
- fi
-
- shmif_dumpbus -p - bus1 2>/dev/null| \
- tcpdump -n -e -r - 2>/dev/null > ./new
- diff -u $old ./new |grep '^+' |cut -d '+' -f 2 > ./diff
- mv -f ./new ./old
- cat ./diff
-}
-
dad_basic_body()
{
local pkt=
@@ -98,11 +86,10 @@ dad_basic_body()
local localip2=fc00::2
local localip3=fc00::3
- atf_check -s exit:0 ${inetserver} $SOCKLOCAL
- export RUMP_SERVER=$SOCKLOCAL
+ rump_server_start $SOCKLOCAL netinet6
+ rump_server_add_iface $SOCKLOCAL shmif0 bus1
- atf_check -s exit:0 rump.ifconfig shmif0 create
- atf_check -s exit:0 rump.ifconfig shmif0 linkstr bus1
+ export RUMP_SERVER=$SOCKLOCAL
atf_check -s exit:0 rump.ifconfig shmif0 inet6 $localip1
atf_check -s exit:0 rump.ifconfig shmif0 inet6 $localip2
$DEBUG && rump.ifconfig shmif0
@@ -118,7 +105,7 @@ dad_basic_body()
#atf_check -s exit:0 -x "cat ./out |grep $localip2 |grep -q tentative"
atf_check -s exit:0 sleep 2
- extract_new_packets > ./out
+ extract_new_packets bus1 > ./out
$DEBUG && cat ./out
# Check DAD probe packets (Neighbor Solicitation Message)
@@ -130,7 +117,7 @@ dad_basic_body()
# Waiting for DAD complete
atf_check -s exit:0 rump.ifconfig -w 10
- extract_new_packets > ./out
+ extract_new_packets bus1 > ./out
$DEBUG && cat ./out
# IPv6 DAD doesn't announce (Neighbor Advertisement Message)
@@ -149,20 +136,22 @@ dad_basic_body()
# Check DAD probe packets (Neighbor Solicitation Message)
atf_check -s exit:0 sleep 2
- extract_new_packets > ./out
+ extract_new_packets bus1 > ./out
$DEBUG && cat ./out
pkt=$(make_ns_pkt_str 3 $localip3)
atf_check -s exit:0 -x "cat ./out |grep -q '$pkt'"
# Waiting for DAD complete
atf_check -s exit:0 rump.ifconfig -w 10
- extract_new_packets > ./out
+ extract_new_packets bus1 > ./out
$DEBUG && cat ./out
# IPv6 DAD doesn't announce (Neighbor Advertisement Message)
# The new address left tentative
atf_check -s not-exit:0 -x "rump.ifconfig shmif0 |grep $localip3 |grep -q tentative"
+
+ rump_server_destroy_ifaces
}
dad_duplicated_body()
@@ -171,8 +160,8 @@ dad_duplicated_body()
local localip2=fc00::11
local peerip=fc00::2
- atf_check -s exit:0 ${inetserver} $SOCKLOCAL
- atf_check -s exit:0 ${inetserver} $SOCKPEER
+ rump_server_start $SOCKLOCAL netinet6
+ rump_server_start $SOCKPEER netinet6
setup_server $SOCKLOCAL $localip1
setup_server $SOCKPEER $peerip
@@ -180,7 +169,8 @@ dad_duplicated_body()
export RUMP_SERVER=$SOCKLOCAL
# The primary address isn't marked as duplicated
- atf_check -s not-exit:0 -x "rump.ifconfig shmif0 |grep $localip1 |grep -q duplicated"
+ atf_check -s exit:0 -o not-match:"$localip1.+$duplicated" \
+ rump.ifconfig shmif0
#
# Add a new address duplicated with the peer server
@@ -189,52 +179,81 @@ dad_duplicated_body()
atf_check -s exit:0 sleep 1
# The new address is marked as duplicated
- atf_check -s exit:0 -x "rump.ifconfig shmif0 |grep $peerip |grep -q duplicated"
+ atf_check -s exit:0 -o match:"$peerip.+$duplicated" \
+ rump.ifconfig shmif0
# A unique address isn't marked as duplicated
atf_check -s exit:0 rump.ifconfig shmif0 inet6 $localip2
atf_check -s exit:0 sleep 1
- atf_check -s not-exit:0 -x "rump.ifconfig shmif0 |grep $localip2 |grep -q duplicated"
+ atf_check -s exit:0 -o not-match:"$localip2.+$duplicated" \
+ rump.ifconfig shmif0
+
+ rump_server_destroy_ifaces
}
-cleanup()
+dad_count_test()
{
- gdb -ex bt /usr/bin/rump_server rump_server.core
- gdb -ex bt /usr/sbin/arp arp.core
- env RUMP_SERVER=$SOCKLOCAL rump.halt
- env RUMP_SERVER=$SOCKPEER rump.halt
+ local pkt=
+ local count=$1
+ local id=$2
+ local target=$3
+
+ #
+ # Set DAD count to $count
+ #
+ atf_check -s exit:0 rump.sysctl -w -q net.inet6.ip6.dad_count=$count
+
+ # Add a new address
+ atf_check -s exit:0 rump.ifconfig shmif0 inet6 $target
+
+ # Waiting for DAD complete
+ atf_check -s exit:0 rump.ifconfig -w 20
+
+ # Check the number of DAD probe packets (Neighbor Solicitation Message)
+ atf_check -s exit:0 sleep 2
+ extract_new_packets bus1 > ./out
+ $DEBUG && cat ./out
+ pkt=$(make_ns_pkt_str $id $target)
+ atf_check -s exit:0 -o match:"$count" \
+ -x "cat ./out |grep '$pkt' | wc -l | tr -d ' '"
}
-dump_local()
+dad_count_body()
{
+ local localip1=fc00::1
+ local localip2=fc00::2
+
+ rump_server_start $SOCKLOCAL netinet6
+ rump_server_add_iface $SOCKLOCAL shmif0 bus1
+
export RUMP_SERVER=$SOCKLOCAL
- rump.netstat -nr
- rump.arp -n -a
- rump.ifconfig
- $HIJACKING dmesg
-}
-dump_peer()
-{
- export RUMP_SERVER=$SOCKPEER
- rump.netstat -nr
- rump.arp -n -a
- rump.ifconfig
- $HIJACKING dmesg
-}
+ # Check default value
+ atf_check -s exit:0 -o match:"1" rump.sysctl -n net.inet6.ip6.dad_count
-dump()
-{
- dump_local
- dump_peer
- shmif_dumpbus -p - bus1 2>/dev/null| tcpdump -n -e -r -
+ # Setup interface
+ atf_check -s exit:0 rump.ifconfig shmif0 up
+ atf_check -s exit:0 sleep 2
+ rump.ifconfig shmif0 > ./out
+ $DEBUG && cat ./out
+
+ #
+ # Set and test DAD count (count=1)
+ #
+ dad_count_test 1 1 $localip1
+
+ #
+ # Set and test DAD count (count=8)
+ #
+ dad_count_test 8 2 $localip2
+
+ rump_server_destroy_ifaces
}
dad_basic_cleanup()
{
- $DEBUG && dump_local
- $DEBUG && shmif_dumpbus -p - bus1 2>/dev/null| tcpdump -n -e -r -
- env RUMP_SERVER=$SOCKLOCAL rump.halt
+ $DEBUG && dump
+ cleanup
}
dad_duplicated_cleanup()
@@ -243,8 +262,15 @@ dad_duplicated_cleanup()
cleanup
}
+dad_count_cleanup()
+{
+ $DEBUG && dump
+ cleanup
+}
+
atf_init_test_cases()
{
atf_add_test_case dad_basic
atf_add_test_case dad_duplicated
+ atf_add_test_case dad_count
}
diff --git a/contrib/netbsd-tests/net/ndp/t_ndp.sh b/contrib/netbsd-tests/net/ndp/t_ndp.sh
index 4491981..aa96390 100755
--- a/contrib/netbsd-tests/net/ndp/t_ndp.sh
+++ b/contrib/netbsd-tests/net/ndp/t_ndp.sh
@@ -1,4 +1,4 @@
-# $NetBSD: t_ndp.sh,v 1.13 2016/08/10 23:07:57 kre Exp $
+# $NetBSD: t_ndp.sh,v 1.17 2016/11/25 08:51:17 ozaki-r Exp $
#
# Copyright (c) 2015 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -25,17 +25,12 @@
# POSSIBILITY OF SUCH DAMAGE.
#
-inetserver="rump_server -lrumpnet -lrumpnet_net -lrumpnet_netinet"
-inetserver="$inetserver -lrumpnet_netinet6 -lrumpnet_shmif"
-inetserver="$inetserver -lrumpdev"
-HIJACKING="env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=sysctl=yes"
-
SOCKSRC=unix://commsock1
SOCKDST=unix://commsock2
IP6SRC=fc00::1
IP6DST=fc00::2
-DEBUG=true
+DEBUG=${DEBUG:-true}
TIMEOUT=1
atf_test_case ndp_cache_expiration cleanup
@@ -78,9 +73,8 @@ setup_dst_server()
{
local assign_ip=$1
+ rump_server_add_iface $SOCKDST shmif0 bus1
export RUMP_SERVER=$SOCKDST
- atf_check -s exit:0 rump.ifconfig shmif0 create
- atf_check -s exit:0 rump.ifconfig shmif0 linkstr bus1
if [ "$assign_ip" != no ]; then
atf_check -s exit:0 rump.ifconfig shmif0 inet6 $IP6DST
fi
@@ -97,8 +91,7 @@ setup_src_server()
export RUMP_SERVER=$SOCKSRC
# Setup an interface
- atf_check -s exit:0 rump.ifconfig shmif0 create
- atf_check -s exit:0 rump.ifconfig shmif0 linkstr bus1
+ rump_server_add_iface $SOCKSRC shmif0 bus1
atf_check -s exit:0 rump.ifconfig shmif0 inet6 $IP6SRC
atf_check -s exit:0 rump.ifconfig shmif0 up
atf_check -s exit:0 rump.ifconfig -w 10
@@ -119,8 +112,9 @@ get_timeout()
ndp_cache_expiration_body()
{
- atf_check -s exit:0 ${inetserver} $SOCKSRC
- atf_check -s exit:0 ${inetserver} $SOCKDST
+
+ rump_server_start $SOCKSRC netinet6
+ rump_server_start $SOCKDST netinet6
setup_dst_server
setup_src_server
@@ -144,6 +138,8 @@ ndp_cache_expiration_body()
atf_check -s exit:0 -o match:'permanent' rump.ndp -n $IP6SRC
# Expired but remains until GC sweaps it (1 day)
atf_check -s exit:0 -o match:'(1d0h0m|23h59m)' rump.ndp -n $IP6DST
+
+ rump_server_destroy_ifaces
}
ifdown_dst_server()
@@ -155,8 +151,9 @@ ifdown_dst_server()
ndp_commands_body()
{
- atf_check -s exit:0 ${inetserver} $SOCKSRC
- atf_check -s exit:0 ${inetserver} $SOCKDST
+
+ rump_server_start $SOCKSRC netinet6
+ rump_server_start $SOCKDST netinet6
setup_dst_server
setup_src_server
@@ -217,13 +214,14 @@ ndp_commands_body()
$DEBUG && rump.ndp -n -a
atf_check -s exit:0 -o not-match:'permanent' rump.ndp -n fc00::10
- return 0
+ rump_server_destroy_ifaces
}
ndp_cache_overwriting_body()
{
- atf_check -s exit:0 ${inetserver} $SOCKSRC
- atf_check -s exit:0 ${inetserver} $SOCKDST
+
+ rump_server_start $SOCKSRC netinet6
+ rump_server_start $SOCKDST netinet6
setup_dst_server
setup_src_server
@@ -249,7 +247,7 @@ ndp_cache_overwriting_body()
#atf_check -s not-exit:0 -e ignore rump.ndp -s fc00::10 b2:a0:20:00:00:ff
#$DEBUG && rump.ndp -n -a
- return 0
+ rump_server_destroy_ifaces
}
get_n_caches()
@@ -261,8 +259,8 @@ get_n_caches()
ndp_neighborgcthresh_body()
{
- atf_check -s exit:0 ${inetserver} $SOCKSRC
- atf_check -s exit:0 ${inetserver} $SOCKDST
+ rump_server_start $SOCKSRC netinet6
+ rump_server_start $SOCKDST netinet6
setup_dst_server no
setup_src_server
@@ -311,7 +309,7 @@ ndp_neighborgcthresh_body()
atf_fail "Neighbor caches are not GC-ed"
fi
- return 0
+ rump_server_destroy_ifaces
}
make_pkt_str_na()
@@ -324,33 +322,18 @@ make_pkt_str_na()
echo $pkt
}
-extract_new_packets()
-{
- local old=./old
-
- if [ ! -f $old ]; then
- old=/dev/null
- fi
-
- shmif_dumpbus -p - bus1 2>/dev/null| \
- tcpdump -n -e -r - 2>/dev/null > ./new
- diff -u $old ./new |grep '^+' |cut -d '+' -f 2 > ./diff
- mv -f ./new ./old
- cat ./diff
-}
-
ndp_link_activation_body()
{
local linklocal=
- atf_check -s exit:0 ${inetserver} $SOCKSRC
- atf_check -s exit:0 ${inetserver} $SOCKDST
+ rump_server_start $SOCKSRC netinet6
+ rump_server_start $SOCKDST netinet6
setup_dst_server
setup_src_server
# flush old packets
- extract_new_packets > ./out
+ extract_new_packets bus1 > ./out
export RUMP_SERVER=$SOCKSRC
@@ -358,7 +341,7 @@ ndp_link_activation_body()
b2:a1:00:00:00:01
atf_check -s exit:0 sleep 1
- extract_new_packets > ./out
+ extract_new_packets bus1 > ./out
$DEBUG && cat ./out
linklocal=$(rump.ifconfig shmif0 |awk '/fe80/ {print $2;}' |awk -F % '{print $1;}')
@@ -371,7 +354,7 @@ ndp_link_activation_body()
b2:a1:00:00:00:02 active
atf_check -s exit:0 sleep 1
- extract_new_packets > ./out
+ extract_new_packets bus1 > ./out
$DEBUG && cat ./out
linklocal=$(rump.ifconfig shmif0 |awk '/fe80/ {print $2;}' |awk -F % '{print $1;}')
@@ -379,39 +362,8 @@ ndp_link_activation_body()
pkt=$(make_pkt_str_na $linklocal b2:a1:00:00:00:02)
atf_check -s exit:0 -x "cat ./out |grep -q '$pkt'"
-}
-cleanup()
-{
- env RUMP_SERVER=$SOCKSRC rump.halt
- env RUMP_SERVER=$SOCKDST rump.halt
-}
-
-dump_src()
-{
- export RUMP_SERVER=$SOCKSRC
- rump.netstat -nr
- rump.ndp -n -a
- rump.ifconfig
- $HIJACKING dmesg
-}
-
-dump_dst()
-{
- export RUMP_SERVER=$SOCKDST
- rump.netstat -nr
- rump.ndp -n -a
- rump.ifconfig
- $HIJACKING dmesg
-}
-
-dump()
-{
- dump_src
- dump_dst
- shmif_dumpbus -p - bus1 2>/dev/null| tcpdump -n -e -r -
- $DEBUG && gdb -ex bt /usr/bin/rump_server rump_server.core
- $DEBUG && gdb -ex bt /usr/sbin/rump.ndp rump.ndp.core
+ rump_server_destroy_ifaces
}
ndp_cache_expiration_cleanup()
diff --git a/contrib/netbsd-tests/net/ndp/t_ra.sh b/contrib/netbsd-tests/net/ndp/t_ra.sh
index cf81683..b234570 100755
--- a/contrib/netbsd-tests/net/ndp/t_ra.sh
+++ b/contrib/netbsd-tests/net/ndp/t_ra.sh
@@ -1,4 +1,4 @@
-# $NetBSD: t_ra.sh,v 1.3 2016/08/10 23:07:57 kre Exp $
+# $NetBSD: t_ra.sh,v 1.20 2017/01/11 03:15:44 ozaki-r Exp $
#
# Copyright (c) 2015 Internet Initiative Japan Inc.
# All rights reserved.
@@ -25,27 +25,49 @@
# POSSIBILITY OF SUCH DAMAGE.
#
-RUMPFLAGS="-lrumpnet -lrumpnet_net -lrumpnet_netinet -lrumpnet_netinet6"
-RUMPFLAGS="${RUMPFLAGS} -lrumpnet_shmif -lrumpdev"
-RUMPFLAGS="${RUMPFLAGS} -lrumpvfs -lrumpfs_ffs"
-
RUMPSRV=unix://r1
+RUMPSRV1_2=unix://r12
RUMPCLI=unix://r2
+RUMPSRV3=unix://r3
+RUMPSRV4=unix://r4
IP6SRV=fc00:1::1
+IP6SRV1_2=fc00:1::2
+IP6SRV_PREFIX=fc00:1:
IP6CLI=fc00:2::2
-PIDFILE=/var/run/rump.rtadvd.pid
+IP6SRV3=fc00:3::1
+IP6SRV3_PREFIX=fc00:3:
+IP6SRV4=fc00:4::1
+IP6SRV4_PREFIX=fc00:4:
+PIDFILE=./rump.rtadvd.pid
+PIDFILE1_2=./rump.rtadvd.pid12
+PIDFILE3=./rump.rtadvd.pid3
+PIDFILE4=./rump.rtadvd.pid4
CONFIG=./rtadvd.conf
-DEBUG=true
+WAITTIME=2
+DEBUG=${DEBUG:-true}
+
+init_server()
+{
+
+ export RUMP_SERVER=$1
+ atf_check -s exit:0 -o match:'0.->.1' rump.sysctl -w net.inet6.ip6.forwarding=1
+ export LD_PRELOAD=/usr/lib/librumphijack.so
+ atf_check -s exit:0 mkdir -p /rump/var/chroot/rtadvd
+ unset LD_PRELOAD
+ unset RUMP_SERVER
+}
setup_shmif0()
{
- local IP6ADDR=${1}
- shift
+ local sock=$1
+ local IP6ADDR=$2
+
+ rump_server_add_iface $sock shmif0 bus1
- atf_check -s exit:0 rump.ifconfig shmif0 create
- atf_check -s exit:0 rump.ifconfig shmif0 linkstr bus1
+ export RUMP_SERVER=$sock
atf_check -s exit:0 rump.ifconfig shmif0 inet6 ${IP6ADDR}
atf_check -s exit:0 rump.ifconfig shmif0 up
+ atf_check -s exit:0 rump.ifconfig -w 10
$DEBUG && rump.ifconfig
}
@@ -72,41 +94,81 @@ shmif0:\
_EOF
}
-atf_test_case basic cleanup
-basic_head()
+start_rtadvd()
+{
+ local sock=$1
+ local pidfile=$2
+
+ export RUMP_SERVER=$sock
+ atf_check -s exit:0 rump.rtadvd -c ${CONFIG} -p $pidfile shmif0
+ while [ ! -f $pidfile ]; do
+ sleep 0.2
+ done
+ unset RUMP_SERVER
+}
+
+check_entries()
+{
+ local cli=$1
+ local srv=$2
+ local addr_prefix=$3
+ local mac_srv= ll_srv=
+
+ ll_srv=$(get_linklocal_addr $srv shmif0)
+ mac_srv=$(get_macaddr $srv shmif0)
+
+ export RUMP_SERVER=$cli
+ $DEBUG && dump_entries
+ atf_check -s exit:0 -o match:'if=shmif0' rump.ndp -r
+ atf_check -s exit:0 -o match:'advertised' rump.ndp -p
+ atf_check -s exit:0 -o match:"${ll_srv}%shmif0 \(reachable\)" rump.ndp -p
+ atf_check -s exit:0 -o match:'linkmtu=1300' rump.ndp -n -i shmif0
+ atf_check -s exit:0 \
+ -o match:"$ll_srv%shmif0 +$mac_srv +shmif0 +(23h59m|1d0h0m)..s S R" \
+ rump.ndp -n -a
+ atf_check -s exit:0 -o match:$addr_prefix rump.ndp -n -a
+ atf_check -s exit:0 -o match:"$addr_prefix.+<AUTOCONF>" \
+ rump.ifconfig shmif0 inet6
+ unset RUMP_SERVER
+}
+
+dump_entries()
+{
+
+ echo ndp -n -a
+ rump.ndp -n -a
+ echo ndp -p
+ rump.ndp -p
+ echo ndp -r
+ rump.ndp -r
+}
+
+atf_test_case ra_basic cleanup
+ra_basic_head()
{
atf_set "descr" "Tests for basic functions of router advaertisement(RA)"
atf_set "require.progs" "rump_server rump.rtadvd rump.ndp rump.ifconfig"
}
-basic_body()
+ra_basic_body()
{
- atf_check -s exit:0 rump_server ${RUMPFLAGS} ${RUMPSRV}
- atf_check -s exit:0 rump_server ${RUMPFLAGS} ${RUMPCLI}
+ rump_server_fs_start $RUMPSRV netinet6
+ rump_server_start $RUMPCLI netinet6
- export RUMP_SERVER=${RUMPSRV}
- setup_shmif0 ${IP6SRV}
- atf_check -s exit:0 -o match:'0.->.1' rump.sysctl -w net.inet6.ip6.forwarding=1
- export LD_PRELOAD=/usr/lib/librumphijack.so
- atf_check -s exit:0 mkdir -p /rump/var/chroot/rtadvd
- unset LD_PRELOAD
- unset RUMP_SERVER
+ setup_shmif0 ${RUMPSRV} ${IP6SRV}
+ init_server $RUMPSRV
+ setup_shmif0 ${RUMPCLI} ${IP6CLI}
export RUMP_SERVER=${RUMPCLI}
- setup_shmif0 ${IP6CLI}
$DEBUG && rump.ndp -n -a
atf_check -s exit:0 -o match:'= 0' rump.sysctl net.inet6.ip6.accept_rtadv
unset RUMP_SERVER
create_rtadvdconfig
-
- export RUMP_SERVER=${RUMPSRV}
- atf_check -s exit:0 rump.rtadvd -c ${CONFIG} shmif0
- atf_check -s exit:0 sleep 3
- atf_check -s exit:0 -o ignore -e empty cat ${PIDFILE}
- unset RUMP_SERVER
+ start_rtadvd $RUMPSRV $PIDFILE
+ sleep $WAITTIME
export RUMP_SERVER=${RUMPCLI}
atf_check -s exit:0 -o empty rump.ndp -r
@@ -124,30 +186,482 @@ basic_body()
atf_check -s exit:0 -o match:'0.->.1' rump.sysctl -w net.inet6.ip6.accept_rtadv=1
unset RUMP_SERVER
- export RUMP_SERVER=${RUMPSRV}
- atf_check -s exit:0 rump.rtadvd -c ${CONFIG} shmif0
- atf_check -s exit:0 sleep 3
- atf_check -s exit:0 -o ignore -e empty cat ${PIDFILE}
+ start_rtadvd $RUMPSRV $PIDFILE
+ sleep $WAITTIME
+
+ check_entries $RUMPCLI $RUMPSRV $IP6SRV_PREFIX
+
+ atf_check -s exit:0 kill -TERM `cat ${PIDFILE}`
+ wait_term ${PIDFILE}
+
+ rump_server_destroy_ifaces
+}
+
+ra_basic_cleanup()
+{
+
+ if [ -f ${PIDFILE} ]; then
+ kill -TERM `cat ${PIDFILE}`
+ wait_term ${PIDFILE}
+ fi
+
+ $DEBUG && dump
+ cleanup
+}
+
+atf_test_case ra_flush_prefix_entries cleanup
+ra_flush_prefix_entries_head()
+{
+
+ atf_set "descr" "Tests for flushing prefixes (ndp -P)"
+ atf_set "require.progs" "rump_server rump.rtadvd rump.ndp rump.ifconfig"
+}
+
+ra_flush_prefix_entries_body()
+{
+
+ rump_server_fs_start $RUMPSRV netinet6
+ rump_server_start $RUMPCLI netinet6
+
+ setup_shmif0 ${RUMPSRV} ${IP6SRV}
+ setup_shmif0 ${RUMPCLI} ${IP6CLI}
+
+ init_server $RUMPSRV
+
+ create_rtadvdconfig
+
+ export RUMP_SERVER=${RUMPCLI}
+ atf_check -s exit:0 -o match:'0.->.1' rump.sysctl -w net.inet6.ip6.accept_rtadv=1
unset RUMP_SERVER
+ start_rtadvd $RUMPSRV $PIDFILE
+ sleep $WAITTIME
+
+ check_entries $RUMPCLI $RUMPSRV $IP6SRV_PREFIX
+
export RUMP_SERVER=${RUMPCLI}
- $DEBUG && rump.ndp -n -a
- $DEBUG && rump.ndp -r
+
+ # Terminate rtadvd to prevent new RA messages from coming
+ # Note that ifconfig down; kill -TERM doesn't work
+ kill -KILL `cat ${PIDFILE}`
+
+ # Flush all the entries in the prefix list
+ atf_check -s exit:0 rump.ndp -P
+
+ $DEBUG && dump_entries
atf_check -s exit:0 -o match:'if=shmif0' rump.ndp -r
- atf_check -s exit:0 -o match:'advertised' rump.ndp -p
+ atf_check -s exit:0 -o empty rump.ndp -p
atf_check -s exit:0 -o match:'linkmtu=1300' rump.ndp -n -i shmif0
- atf_check -s exit:0 -o match:'23h59m..s S R' rump.ndp -n -a
+ atf_check -s exit:0 -o match:'(23h59m|1d0h0m)..s S R' rump.ndp -n -a
+ atf_check -s exit:0 -o match:'fc00:1:' rump.ndp -n -a
+ atf_check -s exit:0 -o not-match:'fc00:1:' rump.ifconfig shmif0 inet6
+ unset RUMP_SERVER
+
+ rump_server_destroy_ifaces
+}
+
+ra_flush_prefix_entries_cleanup()
+{
+
+ $DEBUG && dump
+ cleanup
+}
+
+atf_test_case ra_flush_defrouter_entries cleanup
+ra_flush_defrouter_entries_head()
+{
+
+ atf_set "descr" "Tests for flushing default routers (ndp -R)"
+ atf_set "require.progs" "rump_server rump.rtadvd rump.ndp rump.ifconfig"
+}
+
+ra_flush_defrouter_entries_body()
+{
+
+ rump_server_fs_start $RUMPSRV netinet6
+ rump_server_start $RUMPCLI netinet6
+
+ setup_shmif0 ${RUMPSRV} ${IP6SRV}
+ setup_shmif0 ${RUMPCLI} ${IP6CLI}
+
+ init_server $RUMPSRV
+
+ create_rtadvdconfig
+
+ export RUMP_SERVER=${RUMPCLI}
+ atf_check -s exit:0 -o match:'0.->.1' rump.sysctl -w net.inet6.ip6.accept_rtadv=1
+ unset RUMP_SERVER
+
+ start_rtadvd $RUMPSRV $PIDFILE
+ sleep $WAITTIME
+
+ check_entries $RUMPCLI $RUMPSRV $IP6SRV_PREFIX
+
+ export RUMP_SERVER=${RUMPCLI}
+
+ # Terminate rtadvd to prevent new RA messages from coming
+ # Note that ifconfig down; kill -TERM doesn't work
+ kill -KILL `cat ${PIDFILE}`
+
+ # Flush all the entries in the default router list
+ atf_check -s exit:0 rump.ndp -R
+
+ $DEBUG && dump_entries
+ atf_check -s exit:0 -o empty rump.ndp -r
+ atf_check -s exit:0 -o match:'No advertising router' rump.ndp -p
+ atf_check -s exit:0 -o match:'linkmtu=1300' rump.ndp -n -i shmif0
+ atf_check -s exit:0 -o match:'(23h59m|1d0h0m)..s S R' rump.ndp -n -a
atf_check -s exit:0 -o match:'fc00:1:' rump.ndp -n -a
atf_check -s exit:0 -o match:'fc00:1:' rump.ifconfig shmif0 inet6
unset RUMP_SERVER
+ rump_server_destroy_ifaces
+}
+
+ra_flush_defrouter_entries_cleanup()
+{
+
+ $DEBUG && dump
+ cleanup
+}
+
+atf_test_case ra_delete_address cleanup
+ra_delete_address_head()
+{
+
+ atf_set "descr" "Tests for deleting auto-configured address"
+ atf_set "require.progs" "rump_server rump.rtadvd rump.ndp rump.ifconfig"
+}
+
+ra_delete_address_body()
+{
+
+ rump_server_fs_start $RUMPSRV netinet6
+ rump_server_start $RUMPCLI netinet6
+
+ setup_shmif0 ${RUMPSRV} ${IP6SRV}
+ setup_shmif0 ${RUMPCLI} ${IP6CLI}
+
+ init_server $RUMPSRV
+
+ create_rtadvdconfig
+
+ export RUMP_SERVER=${RUMPCLI}
+ atf_check -s exit:0 -o match:'0.->.1' rump.sysctl -w net.inet6.ip6.accept_rtadv=1
+ unset RUMP_SERVER
+
+ start_rtadvd $RUMPSRV $PIDFILE
+ sleep $WAITTIME
+
+ check_entries $RUMPCLI $RUMPSRV $IP6SRV_PREFIX
+
+ export RUMP_SERVER=${RUMPCLI}
+ $DEBUG && rump.ifconfig shmif0
+ atf_check -s exit:0 rump.ifconfig shmif0 inet6 \
+ $(rump.ifconfig shmif0 |awk '/AUTOCONF/ {print $2}') delete
+ unset RUMP_SERVER
+
atf_check -s exit:0 kill -TERM `cat ${PIDFILE}`
wait_term ${PIDFILE}
- return 0
+ rump_server_destroy_ifaces
+}
+
+ra_delete_address_cleanup()
+{
+
+ if [ -f ${PIDFILE} ]; then
+ kill -TERM `cat ${PIDFILE}`
+ wait_term ${PIDFILE}
+ fi
+
+ $DEBUG && dump
+ cleanup
+}
+
+atf_test_case ra_multiple_routers cleanup
+ra_multiple_routers_head()
+{
+
+ atf_set "descr" "Tests for multiple routers"
+ atf_set "require.progs" "rump_server rump.rtadvd rump.ndp rump.ifconfig"
+}
+
+ra_multiple_routers_body()
+{
+ local n=
+
+ rump_server_fs_start $RUMPSRV netinet6
+ rump_server_fs_start $RUMPSRV3 netinet6
+ rump_server_start $RUMPCLI netinet6
+
+ setup_shmif0 ${RUMPSRV} ${IP6SRV}
+ setup_shmif0 ${RUMPSRV3} ${IP6SRV3}
+ setup_shmif0 ${RUMPCLI} ${IP6CLI}
+
+ init_server $RUMPSRV
+ init_server $RUMPSRV3
+
+ create_rtadvdconfig
+
+ export RUMP_SERVER=${RUMPCLI}
+ atf_check -s exit:0 -o match:'0.->.1' rump.sysctl -w net.inet6.ip6.accept_rtadv=1
+ unset RUMP_SERVER
+
+ start_rtadvd $RUMPSRV $PIDFILE
+ start_rtadvd $RUMPSRV3 $PIDFILE3
+ sleep $WAITTIME
+
+ check_entries $RUMPCLI $RUMPSRV $IP6SRV_PREFIX
+ check_entries $RUMPCLI $RUMPSRV3 $IP6SRV3_PREFIX
+
+ export RUMP_SERVER=$RUMPCLI
+ # Two prefixes are advertised by differnt two routers
+ n=$(rump.ndp -p |grep 'advertised by' |wc -l)
+ atf_check_equal $n 2
+ unset RUMP_SERVER
+
+ atf_check -s exit:0 kill -TERM `cat ${PIDFILE}`
+ wait_term ${PIDFILE}
+ atf_check -s exit:0 kill -TERM `cat ${PIDFILE3}`
+ wait_term ${PIDFILE3}
+
+ rump_server_destroy_ifaces
+}
+
+ra_multiple_routers_cleanup()
+{
+
+ if [ -f ${PIDFILE} ]; then
+ kill -TERM `cat ${PIDFILE}`
+ wait_term ${PIDFILE}
+ fi
+ if [ -f ${PIDFILE3} ]; then
+ kill -TERM `cat ${PIDFILE3}`
+ wait_term ${PIDFILE3}
+ fi
+
+ $DEBUG && dump
+ cleanup
+}
+
+atf_test_case ra_multiple_routers_single_prefix cleanup
+ra_multiple_routers_single_prefix_head()
+{
+
+ atf_set "descr" "Tests for multiple routers with a single prefix"
+ atf_set "require.progs" "rump_server rump.rtadvd rump.ndp rump.ifconfig"
+}
+
+ra_multiple_routers_single_prefix_body()
+{
+ local n=
+
+ rump_server_fs_start $RUMPSRV netinet6
+ rump_server_fs_start $RUMPSRV1_2 netinet6
+ rump_server_start $RUMPCLI netinet6
+
+ setup_shmif0 ${RUMPSRV} ${IP6SRV}
+ setup_shmif0 ${RUMPSRV1_2} ${IP6SRV1_2}
+ setup_shmif0 ${RUMPCLI} ${IP6CLI}
+
+ init_server $RUMPSRV
+ init_server $RUMPSRV1_2
+
+ create_rtadvdconfig
+
+ export RUMP_SERVER=${RUMPCLI}
+ atf_check -s exit:0 -o match:'0.->.1' rump.sysctl -w net.inet6.ip6.accept_rtadv=1
+ unset RUMP_SERVER
+
+ start_rtadvd $RUMPSRV $PIDFILE
+ start_rtadvd $RUMPSRV1_2 $PIDFILE1_2
+ sleep $WAITTIME
+
+ check_entries $RUMPCLI $RUMPSRV $IP6SRV_PREFIX
+ check_entries $RUMPCLI $RUMPSRV1_2 $IP6SRV_PREFIX
+
+ export RUMP_SERVER=$RUMPCLI
+ # One prefix is advertised by differnt two routers
+ n=$(rump.ndp -p |grep 'advertised by' |wc -l)
+ atf_check_equal $n 1
+ unset RUMP_SERVER
+
+ atf_check -s exit:0 kill -TERM `cat ${PIDFILE}`
+ wait_term ${PIDFILE}
+ atf_check -s exit:0 kill -TERM `cat ${PIDFILE1_2}`
+ wait_term ${PIDFILE1_2}
+
+ rump_server_destroy_ifaces
+}
+
+ra_multiple_routers_single_prefix_cleanup()
+{
+
+ if [ -f ${PIDFILE} ]; then
+ kill -TERM `cat ${PIDFILE}`
+ wait_term ${PIDFILE}
+ fi
+ if [ -f ${PIDFILE1_2} ]; then
+ kill -TERM `cat ${PIDFILE1_2}`
+ wait_term ${PIDFILE1_2}
+ fi
+
+ $DEBUG && dump
+ cleanup
+}
+
+atf_test_case ra_multiple_routers_maxifprefixes cleanup
+ra_multiple_routers_maxifprefixes_head()
+{
+
+ atf_set "descr" "Tests for exceeding the number of maximum prefixes"
+ atf_set "require.progs" "rump_server rump.rtadvd rump.ndp rump.ifconfig"
+}
+
+ra_multiple_routers_maxifprefixes_body()
+{
+ local n=
+
+ rump_server_fs_start $RUMPSRV netinet6
+ rump_server_fs_start $RUMPSRV3 netinet6
+ rump_server_fs_start $RUMPSRV4 netinet6
+ rump_server_start $RUMPCLI netinet6
+
+ setup_shmif0 ${RUMPSRV} ${IP6SRV}
+ setup_shmif0 ${RUMPSRV3} ${IP6SRV3}
+ setup_shmif0 ${RUMPSRV4} ${IP6SRV4}
+ setup_shmif0 ${RUMPCLI} ${IP6CLI}
+
+ init_server $RUMPSRV
+ init_server $RUMPSRV3
+ init_server $RUMPSRV4
+
+ create_rtadvdconfig
+
+ export RUMP_SERVER=${RUMPCLI}
+ atf_check -s exit:0 -o match:'0.->.1' \
+ rump.sysctl -w net.inet6.ip6.accept_rtadv=1
+ # Limit the maximum number of prefix entries to 2
+ atf_check -s exit:0 -o match:'16.->.2' \
+ rump.sysctl -w net.inet6.ip6.maxifprefixes=2
+ unset RUMP_SERVER
+
+ start_rtadvd $RUMPSRV $PIDFILE
+ start_rtadvd $RUMPSRV3 $PIDFILE3
+ sleep $WAITTIME
+
+ check_entries $RUMPCLI $RUMPSRV $IP6SRV_PREFIX
+ check_entries $RUMPCLI $RUMPSRV3 $IP6SRV3_PREFIX
+
+ start_rtadvd $RUMPSRV4 $PIDFILE4
+ sleep $WAITTIME
+
+ export RUMP_SERVER=${RUMPCLI}
+ $DEBUG && dump_entries
+ # There should remain two prefixes
+ n=$(rump.ndp -p |grep 'advertised by' |wc -l)
+ atf_check_equal $n 2
+ # TODO check other conditions
+ unset RUMP_SERVER
+
+ atf_check -s exit:0 kill -TERM `cat ${PIDFILE}`
+ wait_term ${PIDFILE}
+ atf_check -s exit:0 kill -TERM `cat ${PIDFILE3}`
+ wait_term ${PIDFILE3}
+ atf_check -s exit:0 kill -TERM `cat ${PIDFILE4}`
+ wait_term ${PIDFILE4}
+
+ rump_server_destroy_ifaces
+}
+
+ra_multiple_routers_maxifprefixes_cleanup()
+{
+
+ if [ -f ${PIDFILE} ]; then
+ kill -TERM `cat ${PIDFILE}`
+ wait_term ${PIDFILE}
+ fi
+ if [ -f ${PIDFILE3} ]; then
+ kill -TERM `cat ${PIDFILE3}`
+ wait_term ${PIDFILE3}
+ fi
+ if [ -f ${PIDFILE4} ]; then
+ kill -TERM `cat ${PIDFILE4}`
+ wait_term ${PIDFILE4}
+ fi
+
+ $DEBUG && dump
+ cleanup
+}
+
+atf_test_case ra_temporary_address cleanup
+ra_temporary_address_head()
+{
+
+ atf_set "descr" "Tests for IPv6 temporary address"
+ atf_set "require.progs" "rump_server rump.rtadvd rump.ndp rump.ifconfig"
+}
+
+ra_temporary_address_body()
+{
+
+ rump_server_fs_start $RUMPSRV netinet6
+ rump_server_start $RUMPCLI netinet6
+
+ setup_shmif0 ${RUMPSRV} ${IP6SRV}
+ init_server $RUMPSRV
+
+ setup_shmif0 ${RUMPCLI} ${IP6CLI}
+ export RUMP_SERVER=${RUMPCLI}
+ $DEBUG && rump.ndp -n -a
+ atf_check -s exit:0 -o match:'= 0' \
+ rump.sysctl net.inet6.ip6.accept_rtadv
+ atf_check -s exit:0 -o match:'= 0' \
+ rump.sysctl net.inet6.ip6.use_tempaddr
+ unset RUMP_SERVER
+
+ create_rtadvdconfig
+ start_rtadvd $RUMPSRV $PIDFILE
+ sleep $WAITTIME
+
+ export RUMP_SERVER=${RUMPCLI}
+ atf_check -s exit:0 -o empty rump.ndp -r
+ atf_check -s exit:0 -o not-match:'advertised' rump.ndp -p
+ atf_check -s exit:0 -o match:'linkmtu=0' rump.ndp -n -i shmif0
+ atf_check -s exit:0 -o not-match:'S R' rump.ndp -n -a
+ atf_check -s exit:0 -o not-match:'fc00:1:' rump.ndp -n -a
+ atf_check -s exit:0 -o not-match:'fc00:1:' rump.ifconfig shmif0 inet6
+ unset RUMP_SERVER
+
+ atf_check -s exit:0 kill -TERM `cat ${PIDFILE}`
+ wait_term ${PIDFILE}
+
+ export RUMP_SERVER=${RUMPCLI}
+ atf_check -s exit:0 -o match:'0.->.1' \
+ rump.sysctl -w net.inet6.ip6.accept_rtadv=1
+ atf_check -s exit:0 -o match:'0.->.1' \
+ rump.sysctl -w net.inet6.ip6.use_tempaddr=1
+ unset RUMP_SERVER
+
+ start_rtadvd $RUMPSRV $PIDFILE
+ sleep $WAITTIME
+
+ check_entries $RUMPCLI $RUMPSRV $IP6SRV_PREFIX
+
+ # Check temporary address
+ export RUMP_SERVER=${RUMPCLI}
+ atf_check -s exit:0 -o match:"$IP6SRV_PREFIX.+<AUTOCONF,TEMPORARY>" \
+ rump.ifconfig shmif0 inet6
+ unset RUMP_SERVER
+
+ atf_check -s exit:0 kill -TERM `cat ${PIDFILE}`
+ wait_term ${PIDFILE}
+
+ rump_server_destroy_ifaces
}
-basic_cleanup()
+ra_temporary_address_cleanup()
{
if [ -f ${PIDFILE} ]; then
@@ -155,12 +669,19 @@ basic_cleanup()
wait_term ${PIDFILE}
fi
- env RUMP_SERVER=${RUMPSRV} rump.halt
- env RUMP_SERVER=${RUMPCLI} rump.halt
+ $DEBUG && dump
+ cleanup
}
atf_init_test_cases()
{
- atf_add_test_case basic
+ atf_add_test_case ra_basic
+ atf_add_test_case ra_flush_prefix_entries
+ atf_add_test_case ra_flush_defrouter_entries
+ atf_add_test_case ra_delete_address
+ atf_add_test_case ra_multiple_routers
+ atf_add_test_case ra_multiple_routers_single_prefix
+ atf_add_test_case ra_multiple_routers_maxifprefixes
+ atf_add_test_case ra_temporary_address
}
diff --git a/contrib/netbsd-tests/net/net/t_forwarding.sh b/contrib/netbsd-tests/net/net/t_forwarding.sh
index 9e96738..fc30530 100755
--- a/contrib/netbsd-tests/net/net/t_forwarding.sh
+++ b/contrib/netbsd-tests/net/net/t_forwarding.sh
@@ -1,4 +1,4 @@
-# $NetBSD: t_forwarding.sh,v 1.15 2016/08/10 21:33:52 kre Exp $
+# $NetBSD: t_forwarding.sh,v 1.19 2016/11/25 08:51:17 ozaki-r Exp $
#
# Copyright (c) 2015 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -25,9 +25,6 @@
# POSSIBILITY OF SUCH DAMAGE.
#
-inetserver="rump_server -lrumpnet -lrumpnet_net -lrumpnet_netinet -lrumpnet_shmif -lrumpdev"
-inet6server="rump_server -lrumpnet -lrumpnet_net -lrumpnet_netinet -lrumpnet_netinet6 -lrumpnet_shmif -lrumpdev"
-
SOCKSRC=unix://commsock1
SOCKFWD=unix://commsock2
SOCKDST=unix://commsock3
@@ -40,10 +37,9 @@ IP6SRC=fc00:0:0:1::2
IP6SRCGW=fc00:0:0:1::1
IP6DSTGW=fc00:0:0:2::1
IP6DST=fc00:0:0:2::2
-HTTPD_PID=httpd.pid
HTML_FILE=index.html
-DEBUG=false
+DEBUG=${DEBUG:-false}
TIMEOUT=5
atf_test_case ipforwarding_v4 cleanup
@@ -64,6 +60,18 @@ ipforwarding_v6_head()
atf_set "require.progs" "rump_server"
}
+ipforwarding_fastforward_v4_head()
+{
+ atf_set "descr" "Tests for IPv4 fastforward"
+ atf_set "require.progs" "rump_server"
+}
+
+ipforwarding_fastforward_v6_head()
+{
+ atf_set "descr" "Tests for IPv6 fastfoward"
+ atf_set "require.progs" "rump_server"
+}
+
ipforwarding_misc_head()
{
atf_set "descr" "Does IPv4 forwarding tests"
@@ -78,9 +86,9 @@ setup_endpoint()
mode=${4}
gw=${5}
+ rump_server_add_iface $sock shmif0 $bus
+
export RUMP_SERVER=${sock}
- atf_check -s exit:0 rump.ifconfig shmif0 create
- atf_check -s exit:0 rump.ifconfig shmif0 linkstr ${bus}
if [ $mode = "ipv6" ]; then
atf_check -s exit:0 rump.ifconfig shmif0 inet6 ${addr}
atf_check -s exit:0 -o ignore rump.route add -inet6 default ${gw}
@@ -116,12 +124,10 @@ setup_forwarder()
{
mode=${1}
- export RUMP_SERVER=$SOCKFWD
- atf_check -s exit:0 rump.ifconfig shmif0 create
- atf_check -s exit:0 rump.ifconfig shmif0 linkstr bus1
+ rump_server_add_iface $SOCKFWD shmif0 bus1
+ rump_server_add_iface $SOCKFWD shmif1 bus2
- atf_check -s exit:0 rump.ifconfig shmif1 create
- atf_check -s exit:0 rump.ifconfig shmif1 linkstr bus2
+ export RUMP_SERVER=$SOCKFWD
if [ $mode = "ipv6" ]; then
atf_check -s exit:0 rump.ifconfig shmif0 inet6 ${IP6SRCGW}
@@ -146,9 +152,9 @@ setup_forwarder()
setup()
{
- atf_check -s exit:0 ${inetserver} $SOCKSRC
- atf_check -s exit:0 ${inetserver} $SOCKFWD
- atf_check -s exit:0 ${inetserver} $SOCKDST
+ rump_server_start $SOCKSRC
+ rump_server_start $SOCKFWD
+ rump_server_start $SOCKDST
setup_endpoint $SOCKSRC $IP4SRC bus1 ipv4 $IP4SRCGW
setup_endpoint $SOCKDST $IP4DST bus2 ipv4 $IP4DSTGW
@@ -157,29 +163,15 @@ setup()
setup6()
{
- atf_check -s exit:0 ${inet6server} $SOCKSRC
- atf_check -s exit:0 ${inet6server} $SOCKFWD
- atf_check -s exit:0 ${inet6server} $SOCKDST
+ rump_server_start $SOCKSRC netinet6
+ rump_server_start $SOCKFWD netinet6
+ rump_server_start $SOCKDST netinet6
setup_endpoint $SOCKSRC $IP6SRC bus1 ipv6 $IP6SRCGW
setup_endpoint $SOCKDST $IP6DST bus2 ipv6 $IP6DSTGW
setup_forwarder ipv6
}
-setup_bozo()
-{
- local ip=$1
-
- export RUMP_SERVER=$SOCKDST
-
- touch $HTML_FILE
- # start bozo in daemon mode
- atf_check -s exit:0 env LD_PRELOAD=/usr/lib/librumphijack.so \
- /usr/libexec/httpd -P $HTTPD_PID -i $ip -b -s $(pwd)
-
- $DEBUG && rump.netstat -a
-}
-
test_http_get()
{
local ip=$1
@@ -270,15 +262,8 @@ teardown_icmp_bmcastecho()
teardown_interfaces()
{
- export RUMP_SERVER=$SOCKSRC
- atf_check -s exit:0 -o ignore rump.ifconfig shmif0 destroy
- export RUMP_SERVER=$SOCKFWD
- atf_check -s exit:0 -o ignore rump.ifconfig shmif0 destroy
- atf_check -s exit:0 -o ignore rump.ifconfig shmif1 destroy
-
- export RUMP_SERVER=$SOCKDST
- atf_check -s exit:0 -o ignore rump.ifconfig shmif0 destroy
+ rump_server_destroy_ifaces
}
test_setup_forwarding()
@@ -307,33 +292,6 @@ test_teardown_forwarding6()
rump.sysctl net.inet6.ip6.forwarding
}
-cleanup()
-{
- env RUMP_SERVER=$SOCKSRC rump.halt
- env RUMP_SERVER=$SOCKFWD rump.halt
- env RUMP_SERVER=$SOCKDST rump.halt
-}
-
-cleanup_bozo()
-{
-
- if [ -f $HTTPD_PID ]; then
- kill -9 "$(cat $HTTPD_PID)"
- rm -f $HTTPD_PID
- fi
- rm -f $HTML_FILE
-}
-
-dump()
-{
- env RUMP_SERVER=$SOCKSRC rump.netstat -nr
- env RUMP_SERVER=$SOCKFWD rump.netstat -nr
- env RUMP_SERVER=$SOCKDST rump.netstat -nr
-
- /usr/bin/shmif_dumpbus -p - bus1 2>/dev/null| /usr/sbin/tcpdump -n -e -r -
- /usr/bin/shmif_dumpbus -p - bus2 2>/dev/null| /usr/sbin/tcpdump -n -e -r -
-}
-
test_ping_failure()
{
export RUMP_SERVER=$SOCKSRC
@@ -481,7 +439,10 @@ ipforwarding_fastforward_v4_body()
setup_forwarding
test_setup_forwarding
- setup_bozo $IP4DST
+ touch $HTML_FILE
+ start_httpd $SOCKDST $IP4DST
+ $DEBUG && rump.netstat -a
+
test_http_get $IP4DST
teardown_interfaces
@@ -495,7 +456,10 @@ ipforwarding_fastforward_v6_body()
setup_forwarding6
test_setup_forwarding6
- setup_bozo $IP6DST
+ touch $HTML_FILE
+ start_httpd $SOCKDST $IP6DST
+ $DEBUG && rump.netstat -a
+
test_http_get "[$IP6DST]"
teardown_interfaces
@@ -513,7 +477,10 @@ ipforwarding_misc_body()
test_directed_broadcast
- setup_bozo $IP4DST
+ touch $HTML_FILE
+ start_httpd $SOCKDST $IP4DST
+ $DEBUG && rump.netstat -a
+
test_sysctl_ttl $IP4DST
teardown_interfaces
@@ -522,34 +489,34 @@ ipforwarding_misc_body()
ipforwarding_v4_cleanup()
{
- dump
+ $DEBUG && dump
cleanup
}
ipforwarding_v6_cleanup()
{
- dump
+ $DEBUG && dump
cleanup
}
ipforwarding_fastforward_v4_cleanup()
{
- dump
- cleanup_bozo
+ $DEBUG && dump
+ stop_httpd
cleanup
}
ipforwarding_fastforward_v6_cleanup()
{
- dump
- cleanup_bozo
+ $DEBUG && dump
+ stop_httpd
cleanup
}
ipforwarding_misc_cleanup()
{
- dump
- cleanup_bozo
+ $DEBUG && dump
+ stop_httpd
cleanup
}
diff --git a/contrib/netbsd-tests/net/net/t_ipaddress.sh b/contrib/netbsd-tests/net/net/t_ipaddress.sh
index a46f484..4cdd954 100755
--- a/contrib/netbsd-tests/net/net/t_ipaddress.sh
+++ b/contrib/netbsd-tests/net/net/t_ipaddress.sh
@@ -1,4 +1,4 @@
-# $NetBSD: t_ipaddress.sh,v 1.3 2016/08/10 21:33:52 kre Exp $
+# $NetBSD: t_ipaddress.sh,v 1.9 2016/12/15 02:43:56 ozaki-r Exp $
#
# Copyright (c) 2015 Internet Initiative Japan Inc.
# All rights reserved.
@@ -25,61 +25,37 @@
# POSSIBILITY OF SUCH DAMAGE.
#
-SERVER="rump_server -lrumpnet -lrumpnet_net -lrumpnet_netinet -lrumpnet_shmif -lrumpdev"
-SERVER6="$SERVER -lrumpnet_netinet6"
SOCK_LOCAL=unix://commsock1
BUS=bus
-DEBUG=false
-
-check_entry()
-{
- local ip=$(echo $1 |sed 's/\./\\./g')
- local word=$2
-
- atf_check -s exit:0 -o match:"$word" -e ignore -x \
- "rump.netstat -rn | grep ^'$ip'"
-}
-
-check_entry_fail()
-{
- local ip=$(echo $1 |sed 's/\./\\./g')
- local flags=$2 # Not used currently
-
- atf_check -s not-exit:0 -e ignore -x \
- "rump.netstat -rn | grep ^'$ip'"
-}
+DEBUG=${DEBUG:-false}
test_same_address()
{
local ip=10.0.0.1
local net=10.0.0/24
- atf_check -s exit:0 ${SERVER} ${SOCK_LOCAL}
+ rump_server_start $SOCK_LOCAL
+ rump_server_add_iface $SOCK_LOCAL shmif0 $BUS
+
export RUMP_SERVER=$SOCK_LOCAL
- atf_check -s exit:0 -o ignore rump.ifconfig shmif0 create
- atf_check -s exit:0 -o ignore rump.ifconfig shmif0 linkstr ${BUS}
atf_check -s exit:0 -o ignore rump.ifconfig shmif0 $ip/24
atf_check -s exit:0 -o ignore rump.ifconfig shmif0 up
atf_check -s exit:0 -o ignore rump.ifconfig -w 10
$DEBUG && rump.netstat -nr -f inet
- check_entry $ip UHl
- check_entry $ip lo0
- check_entry $ip 'link#2'
- check_entry $net U
- check_entry $net shmif0
- check_entry $net 'link#2'
+ check_route $ip 'link#2' UHl lo0
+ check_route $net 'link#2' UC shmif0
# Delete the address
atf_check -s exit:0 -o ignore rump.ifconfig shmif0 $ip delete
$DEBUG && rump.netstat -nr -f inet
- check_entry_fail $ip
- check_entry_fail $net
+ check_route_no_entry $ip
+ check_route_no_entry $net
# Assign the same address again
atf_check -s exit:0 -o ignore rump.ifconfig shmif0 $ip/24
@@ -87,20 +63,18 @@ test_same_address()
$DEBUG && rump.netstat -nr -f inet
- check_entry $ip UHl
- check_entry $ip lo0
- check_entry $ip 'link#2'
- check_entry $net U
- check_entry $net shmif0
- check_entry $net 'link#2'
+ check_route $ip 'link#2' UHl lo0
+ check_route $net 'link#2' UC shmif0
# Delete the address again
atf_check -s exit:0 -o ignore rump.ifconfig shmif0 $ip delete
$DEBUG && rump.netstat -nr -f inet
- check_entry_fail $ip
- check_entry_fail $net
+ check_route_no_entry $ip
+ check_route_no_entry $net
+
+ rump_server_destroy_ifaces
}
test_same_address6()
@@ -108,31 +82,27 @@ test_same_address6()
local ip=fc00::1
local net=fc00::/64
- atf_check -s exit:0 ${SERVER6} ${SOCK_LOCAL}
+ rump_server_start $SOCK_LOCAL netinet6
+ rump_server_add_iface $SOCK_LOCAL shmif0 $BUS
+
export RUMP_SERVER=$SOCK_LOCAL
- atf_check -s exit:0 -o ignore rump.ifconfig shmif0 create
- atf_check -s exit:0 -o ignore rump.ifconfig shmif0 linkstr ${BUS}
atf_check -s exit:0 -o ignore rump.ifconfig shmif0 inet6 $ip
atf_check -s exit:0 -o ignore rump.ifconfig shmif0 up
atf_check -s exit:0 -o ignore rump.ifconfig -w 10
$DEBUG && rump.netstat -nr -f inet6
- check_entry $ip UHl
- check_entry $ip lo0
- check_entry $ip 'link#2'
- check_entry $net U
- check_entry $net shmif0
- check_entry $net 'link#2'
+ check_route $ip 'link#2' UHl lo0
+ check_route $net 'link#2' UC shmif0
# Delete the address
atf_check -s exit:0 -o ignore rump.ifconfig shmif0 inet6 $ip delete
$DEBUG && rump.netstat -nr -f inet6
- check_entry_fail $ip
- check_entry_fail $net
+ check_route_no_entry $ip
+ check_route_no_entry $net
# Assign the same address again
atf_check -s exit:0 -o ignore rump.ifconfig shmif0 inet6 $ip
@@ -140,27 +110,58 @@ test_same_address6()
$DEBUG && rump.netstat -nr -f inet6
- check_entry $ip UHl
- check_entry $ip lo0
- check_entry $ip 'link#2'
- check_entry $net U
- check_entry $net shmif0
- check_entry $net 'link#2'
+ check_route $ip 'link#2' UHl lo0
+ check_route $net 'link#2' UC shmif0
# Delete the address again
atf_check -s exit:0 -o ignore rump.ifconfig shmif0 inet6 $ip delete
$DEBUG && rump.netstat -nr -f inet6
- check_entry_fail $ip
- check_entry_fail $net
+ check_route_no_entry $ip
+ check_route_no_entry $net
+
+ rump_server_destroy_ifaces
}
-cleanup()
+test_auto_linklocal()
{
- $DEBUG && shmif_dumpbus -p - $BUS 2>/dev/null | tcpdump -n -e -r -
- env RUMP_SERVER=$SOCK_LOCAL rump.halt
+ rump_server_start $SOCK_LOCAL netinet6
+ rump_server_add_iface $SOCK_LOCAL shmif0 $BUS
+
+ export RUMP_SERVER=$SOCK_LOCAL
+
+ #
+ # Test enabled auto linklocal
+ #
+
+ # Check default value
+ atf_check -s exit:0 -o match:"1" rump.sysctl -n net.inet6.ip6.auto_linklocal
+
+ atf_check -s exit:0 -o ignore rump.ifconfig shmif0 up
+ atf_check -s exit:0 -o ignore rump.ifconfig -w 10
+
+ $DEBUG && rump.netstat -nr -f inet
+
+ # IPv6 link-local address is set
+ atf_check -s exit:0 -o match:"inet6 fe80::" rump.ifconfig shmif0
+
+ #
+ # Test disabled auto linklocal
+ #
+ atf_check -s exit:0 -o ignore rump.sysctl -w -q net.inet6.ip6.auto_linklocal=0
+
+ rump_server_add_iface $SOCK_LOCAL shmif1 $BUS
+ atf_check -s exit:0 -o ignore rump.ifconfig shmif1 up
+ atf_check -s exit:0 -o ignore rump.ifconfig -w 10
+
+ $DEBUG && rump.netstat -nr -f inet
+
+ # IPv6 link-local address is not set
+ atf_check -s exit:0 -o not-match:"inet6 fe80::" rump.ifconfig shmif1
+
+ rump_server_destroy_ifaces
}
add_test()
@@ -177,6 +178,7 @@ add_test()
test_${name}; \
}; \
ipaddr_${name}_cleanup() { \
+ $DEBUG && dump; \
cleanup; \
}"
atf_add_test_case "ipaddr_${name}"
@@ -187,4 +189,5 @@ atf_init_test_cases()
add_test same_address "Assigning/deleting an IP address twice"
add_test same_address6 "Assigning/deleting an IPv6 address twice"
+ add_test auto_linklocal "Assigning an IPv6 link-local address automatically"
}
diff --git a/contrib/netbsd-tests/net/net/t_ipv6_lifetime.sh b/contrib/netbsd-tests/net/net/t_ipv6_lifetime.sh
index 5fb34d0..10e50fd 100755
--- a/contrib/netbsd-tests/net/net/t_ipv6_lifetime.sh
+++ b/contrib/netbsd-tests/net/net/t_ipv6_lifetime.sh
@@ -1,4 +1,4 @@
-# $NetBSD: t_ipv6_lifetime.sh,v 1.2 2016/08/10 21:33:52 kre Exp $
+# $NetBSD: t_ipv6_lifetime.sh,v 1.6 2016/11/25 08:51:17 ozaki-r Exp $
#
# Copyright (c) 2015 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -25,13 +25,12 @@
# POSSIBILITY OF SUCH DAMAGE.
#
-INET6SERVER="rump_server -lrumpnet -lrumpnet_net -lrumpnet_netinet -lrumpdev"
-INET6SERVER="$INET6SERVER -lrumpnet_netinet6 -lrumpnet_shmif"
-
SOCK=unix://sock
BUS=./bus
-DEBUG=false
+DEBUG=${DEBUG:-false}
+
+deprecated="[Dd][Ee][Pp][Rr][Ee][Cc][Aa][Tt][Ee][Dd]"
atf_test_case basic cleanup
@@ -47,11 +46,11 @@ basic_body()
local bonus=2
local ip="fc00::1"
- atf_check -s exit:0 ${INET6SERVER} $SOCK
+ rump_server_start $SOCK netinet6
+ rump_server_add_iface $SOCK shmif0 $BUS
+
export RUMP_SERVER=$SOCK
- atf_check -s exit:0 rump.ifconfig shmif0 create
- atf_check -s exit:0 rump.ifconfig shmif0 linkstr $BUS
atf_check -s exit:0 rump.ifconfig shmif0 up
# A normal IP address doesn't contain preferred/valid lifetime
@@ -69,7 +68,7 @@ basic_body()
atf_check -s exit:0 sleep $(($time + $bonus))
$DEBUG && rump.ifconfig -L shmif0
# Should remain but marked as deprecated
- atf_check -s exit:0 -o match:'deprecated' rump.ifconfig -L shmif0
+ atf_check -s exit:0 -o match:"$ip.+$deprecated" rump.ifconfig -L shmif0
atf_check -s exit:0 rump.ifconfig shmif0 inet6 $ip delete
# Setting only a valid lifetime (invalid)
@@ -87,38 +86,33 @@ basic_body()
# Shouldn't remain anymore
atf_check -s exit:0 -o not-match:"$ip" rump.ifconfig -L shmif0
+ # Setting both preferred and valid lifetimes (pltime > vltime)
+ atf_check -s not-exit:0 -e match:'Invalid argument' rump.ifconfig \
+ shmif0 inet6 $ip pltime $(($time * 2)) vltime $time
+
# Setting both preferred and valid lifetimes (pltime < vltime)
atf_check -s exit:0 rump.ifconfig shmif0 inet6 $ip \
pltime $time vltime $((time * 2))
$DEBUG && rump.ifconfig -L shmif0
atf_check -s exit:0 -o match:'pltime' rump.ifconfig -L shmif0
atf_check -s exit:0 -o match:'vltime' rump.ifconfig -L shmif0
+
+ if sysctl machdep.cpu_brand 2>/dev/null | grep QEMU >/dev/null 2>&1
+ then
+ atf_check -s exit:0 rump.ifconfig shmif0 inet6 $ip delete
+ atf_skip "unreliable under qemu, skip until PR kern/43997 fixed"
+ fi
+
atf_check -s exit:0 sleep $(($time + $bonus))
$DEBUG && rump.ifconfig -L shmif0
# Should remain but marked as deprecated
- atf_check -s exit:0 -o match:'deprecated' rump.ifconfig -L shmif0
+ atf_check -s exit:0 -o match:"$ip.+$deprecated" rump.ifconfig -L shmif0
atf_check -s exit:0 sleep $(($time + $bonus))
$DEBUG && rump.ifconfig -L shmif0
# Shouldn't remain anymore
atf_check -s exit:0 -o not-match:"$ip" rump.ifconfig -L shmif0
- # Setting both preferred and valid lifetimes (pltime > vltime)
- atf_check -s not-exit:0 -e match:'Invalid argument' rump.ifconfig \
- shmif0 inet6 $ip pltime $(($time * 2)) vltime $time
-
- return 0
-}
-
-cleanup()
-{
- env RUMP_SERVER=$SOCK rump.halt
-}
-
-dump()
-{
- env RUMP_SERVER=$SOCK rump.ifconfig
- env RUMP_SERVER=$SOCK rump.netstat -nr
- shmif_dumpbus -p - $BUS 2>/dev/null| tcpdump -n -e -r -
+ rump_server_destroy_ifaces
}
basic_cleanup()
diff --git a/contrib/netbsd-tests/net/net/t_ipv6address.sh b/contrib/netbsd-tests/net/net/t_ipv6address.sh
index 3448e86..539a16d 100755
--- a/contrib/netbsd-tests/net/net/t_ipv6address.sh
+++ b/contrib/netbsd-tests/net/net/t_ipv6address.sh
@@ -1,4 +1,4 @@
-# $NetBSD: t_ipv6address.sh,v 1.7 2016/08/10 21:33:52 kre Exp $
+# $NetBSD: t_ipv6address.sh,v 1.12 2016/12/14 02:50:42 ozaki-r Exp $
#
# Copyright (c) 2015 Internet Initiative Japan Inc.
# All rights reserved.
@@ -24,8 +24,9 @@
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
-SERVER="rump_server -lrumpnet -lrumpnet_net -lrumpnet_netinet -lrumpnet_shmif -lrumpdev"
-SERVER6="$SERVER -lrumpnet_netinet6"
+SERVER="rump_server -lrumpnet -lrumpnet_net -lrumpnet_netinet"
+SERVER="${SERVER} -lrumpnet_shmif -lrumpdev"
+SERVER6="${SERVER} -lrumpnet_netinet6"
SOCKSRC=unix://commsock1
SOCKFWD=unix://commsock2
@@ -40,7 +41,7 @@ BUS2=bus2
BUSSRC=bus_src
BUSDST=bus_dst
-DEBUG=true
+DEBUG=${DEBUG:-true}
TIMEOUT=3
atf_test_case linklocal cleanup
@@ -118,41 +119,41 @@ setup_route()
{
local tmp_rump_server=$RUMP_SERVER
- local src_if0_lladdr=`get_lladdr ${SOCKSRC} shmif0`
- local dst_if0_lladdr=`get_lladdr ${SOCKDST} shmif0`
- local fwd_if0_lladdr=`get_lladdr ${SOCKFWD} shmif0`
- local fwd_if1_lladdr=`get_lladdr ${SOCKFWD} shmif1`
+ local src_if0_lladdr=`get_linklocal_addr ${SOCKSRC} shmif0`
+ local dst_if0_lladdr=`get_linklocal_addr ${SOCKDST} shmif0`
+ local fwd_if0_lladdr=`get_linklocal_addr ${SOCKFWD} shmif0`
+ local fwd_if1_lladdr=`get_linklocal_addr ${SOCKFWD} shmif1`
export RUMP_SERVER=${SOCKSRC}
- atf_check -s ignore -o ignore -e ignore rump.route delete -inet6 default \
- ${fwd_if0_lladdr}%shmif0
- atf_check -s exit:0 -o match:"add net default:" rump.route add -inet6 default \
- ${fwd_if0_lladdr}%shmif0
+ atf_check -s ignore -o ignore -e ignore \
+ rump.route delete -inet6 default ${fwd_if0_lladdr}%shmif0
+ atf_check -s exit:0 -o match:"add net default:" \
+ rump.route add -inet6 default ${fwd_if0_lladdr}%shmif0
atf_check -s exit:0 rump.ifconfig shmif1 inet6 ${IP6SRC}
atf_check -s exit:0 -o ignore rump.ifconfig -w 10
$DEBUG && rump.netstat -rn -f inet6
unset RUMP_SERVER
export RUMP_SERVER=${SOCKDST}
- atf_check -s ignore -o ignore -e ignore rump.route delete -inet6 default \
- ${fwd_if1_lladdr}%shmif0
- atf_check -s exit:0 -o match:"add net default:" rump.route add -inet6 default \
- ${fwd_if1_lladdr}%shmif0
+ atf_check -s ignore -o ignore -e ignore \
+ rump.route delete -inet6 default ${fwd_if1_lladdr}%shmif0
+ atf_check -s exit:0 -o match:"add net default:" \
+ rump.route add -inet6 default ${fwd_if1_lladdr}%shmif0
atf_check -s exit:0 rump.ifconfig shmif1 inet6 ${IP6DST}
atf_check -s exit:0 -o ignore rump.ifconfig -w 10
$DEBUG && rump.netstat -rn -f inet6
unset RUMP_SERVER
export RUMP_SERVER=${SOCKFWD}
- atf_check -s ignore -o ignore -e ignore rump.route delete -inet6 ${IP6SRCNW} \
- ${src_if0_lladdr}%shmif0
- atf_check -s exit:0 -o match:"add net" rump.route add -inet6 ${IP6SRCNW} \
- ${src_if0_lladdr}%shmif0
-
- atf_check -s ignore -o ignore -e ignore rump.route delete -inet6 ${IP6DSTNW} \
- ${dst_if0_lladdr}%shmif1
- atf_check -s exit:0 -o match:"add net" rump.route add -inet6 ${IP6DSTNW} \
- ${dst_if0_lladdr}%shmif1
+ atf_check -s ignore -o ignore -e ignore \
+ rump.route delete -inet6 ${IP6SRCNW} ${src_if0_lladdr}%shmif0
+ atf_check -s exit:0 -o match:"add net" \
+ rump.route add -inet6 ${IP6SRCNW} ${src_if0_lladdr}%shmif0
+
+ atf_check -s ignore -o ignore -e ignore \
+ rump.route delete -inet6 ${IP6DSTNW} ${dst_if0_lladdr}%shmif1
+ atf_check -s exit:0 -o match:"add net" \
+ rump.route add -inet6 ${IP6DSTNW} ${dst_if0_lladdr}%shmif1
atf_check -s exit:0 -o ignore rump.ifconfig -w 10
$DEBUG && rump.netstat -rn -f inet6
unset RUMP_SERVER
@@ -197,17 +198,6 @@ cleanup_bus()
export RUMP_SERVER=$tmp_rump_server
}
-
-get_lladdr()
-{
- export RUMP_SERVER=${1}
- rump.ifconfig ${2} inet6 | grep "fe80" \
- | awk '{print $2}' | sed -e "s/%$2//g"
- unset RUMP_SERVER
-
- return 0
-}
-
cleanup_rump_servers()
{
@@ -221,11 +211,11 @@ dump_bus()
shmif_dumpbus -p - ${BUSSRC} 2>/dev/null| tcpdump -n -e -r -
shmif_dumpbus -p - ${BUSDST} 2>/dev/null| tcpdump -n -e -r -
- shmif_dumpbus -p - ${BUS1} 2>/dev/null| tcpdump -n -e -r -
- shmif_dumpbus -p - ${BUS2} 2>/dev/null| tcpdump -n -e -r -
+ shmif_dumpbus -p - ${BUS1} 2>/dev/null| tcpdump -n -e -r -
+ shmif_dumpbus -p - ${BUS2} 2>/dev/null| tcpdump -n -e -r -
}
-dump()
+_dump()
{
export RUMP_SERVER=${SOCKSRC}
@@ -242,19 +232,21 @@ dump()
linklocal_head()
{
- atf_set "descr" "Test for bassically function of the IPv6 linklocal address"
- atf_set "require.progs" "rump_server rump.route rump.ifconfig rump.ping6"
+ atf_set "descr" \
+ "Test for bassically function of the IPv6 linklocal address"
+ atf_set "require.progs" \
+ "rump_server rump.route rump.ifconfig rump.ping6"
}
linklocal_body()
{
setup
- local src_if0_lladdr=`get_lladdr ${SOCKSRC} shmif0`
- local src_if1_lladdr=`get_lladdr ${SOCKSRC} shmif1`
- local dst_if0_lladdr=`get_lladdr ${SOCKDST} shmif0`
- local fwd_if0_lladdr=`get_lladdr ${SOCKFWD} shmif0`
- local fwd_if1_lladdr=`get_lladdr ${SOCKFWD} shmif1`
+ local src_if0_lladdr=`get_linklocal_addr ${SOCKSRC} shmif0`
+ local src_if1_lladdr=`get_linklocal_addr ${SOCKSRC} shmif1`
+ local dst_if0_lladdr=`get_linklocal_addr ${SOCKDST} shmif0`
+ local fwd_if0_lladdr=`get_linklocal_addr ${SOCKFWD} shmif0`
+ local fwd_if1_lladdr=`get_linklocal_addr ${SOCKFWD} shmif1`
export RUMP_SERVER=${SOCKSRC}
$DEBUG && rump.ifconfig
@@ -271,7 +263,7 @@ linklocal_body()
atf_check -s ignore -o empty -e ignore \
-x "shmif_dumpbus -p - ${BUSSRC} | tcpdump -r - -n -p icmp6"
atf_check -s ignore -o not-empty -e ignore \
- -x "shmif_dumpbus -p - ${BUS1} | tcpdump -r - -n -p icmp6"
+ -x "shmif_dumpbus -p - ${BUS1} | tcpdump -r - -n -p icmp6"
cleanup_bus
@@ -279,7 +271,7 @@ linklocal_body()
rump.ping6 -c 1 -X $TIMEOUT -n -S ${src_if1_lladdr}%shmif1 \
${fwd_if0_lladdr}%shmif0
atf_check -s ignore -o not-match:"${src_if1_lladdr}" -e ignore \
- -x "shmif_dumpbus -p - ${BUS1} | tcpdump -r - -n -p icmp6"
+ -x "shmif_dumpbus -p - ${BUS1} | tcpdump -r - -n -p icmp6"
$DEBUG && shmif_dumpbus -p - ${BUS1} | tcpdump -r - -n -p icmp6
unset RUMP_SERVER
@@ -290,16 +282,16 @@ linklocal_body()
unset RUMP_SERVER
export RUMP_SERVER=${SOCKSRC}
- atf_check -s exit:0 -o match:"add net default:" rump.route add -inet6 default \
- ${fwd_if0_lladdr}%shmif0
+ atf_check -s exit:0 -o match:"add net default:" \
+ rump.route add -inet6 default ${fwd_if0_lladdr}%shmif0
atf_check -s exit:0 -o ignore rump.ifconfig -w 10
$DEBUG && rump.ifconfig shmif0
- $DEBUG && dump
+ $DEBUG && _dump
export RUMP_SERVER=${SOCKSRC}
atf_check -s exit:0 -o match:"0.0% packet loss" \
- rump.ping6 -c 1 -X $TIMEOUT -n -S ${src_if0_lladdr}%shmif0 ${IP6FWD0}
+ rump.ping6 -c 1 -X $TIMEOUT -n -S ${src_if0_lladdr}%shmif0 ${IP6FWD0}
unset RUMP_SERVER
export RUMP_SERVER=${SOCKFWD}
@@ -340,7 +332,7 @@ linklocal_body()
linklocal_cleanup()
{
- $DEBUG && dump
+ $DEBUG && _dump
$DEBUG && dump_bus
cleanup_rump_servers
}
@@ -348,7 +340,8 @@ linklocal_cleanup()
linklocal_ops_head()
{
- atf_set "descr" "Test for various operations to IPv6 linklocal addresses"
+ atf_set "descr" \
+ "Test for various operations to IPv6 linklocal addresses"
atf_set "require.progs" "rump_server rump.route rump.ndp"
}
@@ -358,7 +351,7 @@ linklocal_ops_body()
setup
- src_if0_lladdr=`get_lladdr ${SOCKSRC} shmif0`
+ src_if0_lladdr=`get_linklocal_addr ${SOCKSRC} shmif0`
export RUMP_SERVER=${SOCKSRC}
diff --git a/contrib/netbsd-tests/net/net/t_mtudisc.sh b/contrib/netbsd-tests/net/net/t_mtudisc.sh
new file mode 100755
index 0000000..a99d652
--- /dev/null
+++ b/contrib/netbsd-tests/net/net/t_mtudisc.sh
@@ -0,0 +1,192 @@
+# $NetBSD: t_mtudisc.sh,v 1.8 2016/12/21 01:16:18 ozaki-r Exp $
+#
+# Copyright (c) 2016 Internet Initiative Japan Inc.
+# 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+#
+
+SOCKLOCAL=unix://commsock1
+SOCKGATEWAY=unix://commsock2
+SOCKREMOTE=unix://commsock3
+HTML_FILE=index.html
+
+DEBUG=${DEBUG:-false}
+
+atf_test_case mtudisc_basic cleanup
+
+mtudisc_basic_head()
+{
+ atf_set "descr" "Tests for IPv4 Path MTU Dicorvery basic behavior"
+ atf_set "require.progs" "rump_server"
+}
+
+setup_server()
+{
+ local sock=$1
+ local if=$2
+ local bus=$3
+ local ip=$4
+
+ rump_server_add_iface $sock $if $bus
+
+ export RUMP_SERVER=$sock
+ atf_check -s exit:0 rump.ifconfig $if $ip
+ atf_check -s exit:0 rump.ifconfig $if up
+ atf_check -s exit:0 rump.ifconfig -w 10
+
+ $DEBUG && rump.ifconfig $if
+}
+
+prepare_download_file()
+{
+ local file=$1
+ local data="0123456789"
+
+ touch $file
+ for i in `seq 1 512`
+ do
+ echo $data >> $file
+ done
+}
+
+do_http_get()
+{
+ local ip=$1
+ local ret=$2
+ local timeout=5
+
+ # get the webpage
+ atf_check -s exit:$ret env LD_PRELOAD=/usr/lib/librumphijack.so \
+ ftp -q $timeout -o ./out http://$ip/$HTML_FILE
+}
+
+mtudisc_basic_body()
+{
+ local pkt=
+ local local_ip=10.0.0.2
+ local gateway_local_ip=10.0.0.1
+ local gateway_remote_ip=10.0.1.1
+ local remote_ip=10.0.1.2
+ local prefixlen=24
+
+ rump_server_start $SOCKLOCAL
+ rump_server_start $SOCKGATEWAY
+ rump_server_start $SOCKREMOTE
+
+ #
+ # Setup servers
+ #
+ # [local server] [gateway server] [remote server with httpd]
+ # | 10.0.0.2 10.0.0.1 | | 10.0.1.1 10.0.1.2 |
+ # shmif0(mtu=1500) ----- shmif1(mtu=1280) shmif0(mtu=1500) ----- shmif0(mtu=1500)
+ #
+
+ # Assign IP addresses
+ setup_server $SOCKLOCAL shmif0 bus1 $local_ip/$prefixlen
+ setup_server $SOCKGATEWAY shmif0 bus1 $gateway_local_ip/$prefixlen
+ setup_server $SOCKGATEWAY shmif1 bus2 $gateway_remote_ip/$prefixlen
+ setup_server $SOCKREMOTE shmif0 bus2 $remote_ip/$prefixlen
+
+ ### Setup gateway server
+ export RUMP_SERVER=$SOCKGATEWAY
+
+ # Set mtu of shmif0 to 1280
+ export RUMP_SERVER=$SOCKGATEWAY
+ atf_check -s exit:0 rump.ifconfig shmif0 mtu 1280
+
+ # Enable IPv4 forwarding
+ atf_check -s exit:0 rump.sysctl -w -q net.inet.ip.forwarding=1
+
+ ### Setup remote server
+ export RUMP_SERVER=$SOCKREMOTE
+
+ # Check default value
+ atf_check -s exit:0 -o match:"1" rump.sysctl -n net.inet.ip.mtudisc
+
+ # Start httpd daemon
+ prepare_download_file $HTML_FILE
+ start_httpd $SOCKREMOTE $remote_ip
+ $DEBUG && rump.netstat -a -f inet
+
+ # Teach the peer thar 10.0.0.2(local serer) is behind 10.0.1.1(gateway server)
+ atf_check -s exit:0 -o ignore rump.route add $local_ip/32 $gateway_remote_ip
+
+ ### Setup local server
+ export RUMP_SERVER=$SOCKLOCAL
+
+ # Teach the peer thar 10.0.1.2(remote serer) is behind 10.0.0.1(gateway server)
+ atf_check -s exit:0 -o ignore rump.route add $remote_ip/32 $gateway_local_ip
+
+ # Don't accept fragmented packets
+ atf_check -s exit:0 -o ignore rump.sysctl -w -q net.inet.ip.maxfragpackets=0
+
+ #
+ # Test disabled path mtu discorvery
+ #
+ export RUMP_SERVER=$SOCKREMOTE
+ atf_check -s exit:0 -o ignore rump.sysctl -w -q net.inet.ip.mtudisc=0
+
+ # Get the webpage (expect: failed)
+ export RUMP_SERVER=$SOCKLOCAL
+ do_http_get $remote_ip 1
+ $DEBUG && extract_new_packets bus2 > ./out
+ $DEBUG && cat ./out
+
+ # Check path mtu size on remote server
+ export RUMP_SERVER=$SOCKREMOTE
+ atf_check -s exit:0 \
+ -o match:"^10.0.0.2 +10.0.1.1 +UGHS +- +- +- +shmif0" \
+ rump.netstat -nr -f inet
+
+ #
+ # Test enabled path mtu discorvery
+ #
+ export RUMP_SERVER=$SOCKREMOTE
+ atf_check -s exit:0 -o ignore rump.sysctl -w -q net.inet.ip.mtudisc=1
+
+ # Get the webpage (expect: success)
+ export RUMP_SERVER=$SOCKLOCAL
+ do_http_get $remote_ip 0
+ $DEBUG && extract_new_packets bus2 > ./out
+ $DEBUG && cat ./out
+
+ # Check path mtu size on remote server
+ export RUMP_SERVER=$SOCKREMOTE
+ atf_check -s exit:0 \
+ -o match:"^10.0.0.2 +10.0.1.1 +UGHS +- +- +1280 +shmif0" \
+ rump.netstat -nr -f inet
+
+ rump_server_destroy_ifaces
+}
+
+mtudisc_basic_cleanup()
+{
+ $DEBUG && dump
+ stop_httpd
+ cleanup
+}
+
+atf_init_test_cases()
+{
+ atf_add_test_case mtudisc_basic
+}
diff --git a/contrib/netbsd-tests/net/net/t_mtudisc6.sh b/contrib/netbsd-tests/net/net/t_mtudisc6.sh
new file mode 100755
index 0000000..93bc12e
--- /dev/null
+++ b/contrib/netbsd-tests/net/net/t_mtudisc6.sh
@@ -0,0 +1,179 @@
+# $NetBSD: t_mtudisc6.sh,v 1.5 2016/11/25 08:51:17 ozaki-r Exp $
+#
+# Copyright (c) 2016 Internet Initiative Japan Inc.
+# 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+#
+
+SOCKLOCAL=unix://commsock1
+SOCKGATEWAY=unix://commsock2
+SOCKREMOTE=unix://commsock3
+HTML_FILE=index.html
+
+DEBUG=${DEBUG:-false}
+
+atf_test_case mtudisc6_basic cleanup
+
+mtudisc6_basic_head()
+{
+
+ atf_set "descr" "Tests for IPv6 Path MTU Dicorvery basic behavior"
+ atf_set "require.progs" "rump_server"
+}
+
+setup_server()
+{
+ local sock=$1
+ local if=$2
+ local bus=$3
+ local ip=$4
+
+ rump_server_add_iface $sock $if $bus
+
+ export RUMP_SERVER=$sock
+ atf_check -s exit:0 rump.ifconfig $if inet6 $ip
+ atf_check -s exit:0 rump.ifconfig $if up
+ atf_check -s exit:0 rump.ifconfig -w 10
+
+ $DEBUG && rump.ifconfig $if
+}
+
+prepare_download_file()
+{
+ local file=$1
+ local data="0123456789"
+
+ touch $file
+ for i in `seq 1 512`
+ do
+ echo $data >> $file
+ done
+}
+
+do_http_get()
+{
+ local ip=$1
+ local ret=$2
+ local timeout=5
+
+ # get the webpage
+ atf_check -s exit:$ret env LD_PRELOAD=/usr/lib/librumphijack.so \
+ ftp -q $timeout -o ./out "http://[$ip]/$HTML_FILE"
+}
+
+mtudisc6_basic_body()
+{
+ local pkt=
+ local local_ip=fc00:0:0:1::2
+ local gateway_local_ip=fc00:0:0:1::1
+ local gateway_remote_ip=fc00:0:0:2::1
+ local remote_ip=fc00:0:0:2::2
+ local prefixlen=64
+
+ rump_server_start $SOCKLOCAL netinet6
+ rump_server_start $SOCKGATEWAY netinet6
+ rump_server_start $SOCKREMOTE netinet6
+
+ #
+ # Setup servers
+ #
+ # [local server] [gateway server] [remote server]
+ # | | | |
+ # shmif0(1500) -- shmif1(1280) shmif0(1500) -- shmif0(1500)
+ #
+
+ # Assign IP addresses
+ setup_server $SOCKLOCAL shmif0 bus1 $local_ip/$prefixlen
+ setup_server $SOCKGATEWAY shmif0 bus1 $gateway_local_ip/$prefixlen
+ setup_server $SOCKGATEWAY shmif1 bus2 $gateway_remote_ip/$prefixlen
+ setup_server $SOCKREMOTE shmif0 bus2 $remote_ip/$prefixlen
+
+ ### Setup gateway server
+ export RUMP_SERVER=$SOCKGATEWAY
+
+ # Set MTU of shmif0 to 1280
+ export RUMP_SERVER=$SOCKGATEWAY
+ atf_check -s exit:0 rump.ifconfig shmif0 mtu 1280
+
+ # Enable IPv6 forwarding
+ atf_check -s exit:0 rump.sysctl -w -q net.inet6.ip6.forwarding=1
+
+ ### Setup remote server
+ export RUMP_SERVER=$SOCKREMOTE
+
+ # Start httpd daemon
+ prepare_download_file $HTML_FILE
+ start_httpd $SOCKREMOTE $remote_ip
+ $DEBUG && rump.netstat -a
+
+ # Teach the peer that local serer is behind gateway server
+ atf_check -s exit:0 -o ignore \
+ rump.route add -inet6 $local_ip/128 $gateway_remote_ip
+
+ # Check path MTU size on remote server
+ atf_check -s exit:0 \
+ -o match:"^$local_ip +$gateway_remote_ip +UGHS +- +- +- +shmif0" \
+ rump.netstat -nr -f inet6
+
+ ### Setup local server
+ export RUMP_SERVER=$SOCKLOCAL
+
+ # Teach the peer that remote serer is behind gateway server
+ atf_check -s exit:0 -o ignore \
+ rump.route add -inet6 $remote_ip/128 $gateway_local_ip
+
+ # Don't accept fragmented packets
+ atf_check -s exit:0 -o ignore \
+ rump.sysctl -w -q net.inet6.ip6.maxfragpackets=0
+
+ #
+ # Test enabled path MTU discorvery
+ #
+ # Get the webpage (expect: success)
+ export RUMP_SERVER=$SOCKLOCAL
+ do_http_get $remote_ip 0
+ $DEBUG && extract_new_packets bus2 > ./out
+ $DEBUG && cat ./out
+
+ # Check path MTU size on remote server
+ export RUMP_SERVER=$SOCKREMOTE
+ atf_check -s exit:0 \
+ -o match:"^$local_ip +$gateway_remote_ip +UGHS +- +- +1280 +shmif0" \
+ rump.netstat -nr -f inet6
+
+ rump_server_destroy_ifaces
+}
+
+mtudisc6_basic_cleanup()
+{
+
+ $DEBUG && dump
+ stop_httpd
+ cleanup
+}
+
+atf_init_test_cases()
+{
+
+ atf_add_test_case mtudisc6_basic
+}
diff --git a/contrib/netbsd-tests/net/net/t_ping6_opts.sh b/contrib/netbsd-tests/net/net/t_ping6_opts.sh
new file mode 100755
index 0000000..e2e774e
--- /dev/null
+++ b/contrib/netbsd-tests/net/net/t_ping6_opts.sh
@@ -0,0 +1,380 @@
+# $NetBSD: t_ping6_opts.sh,v 1.8 2016/11/25 08:51:17 ozaki-r Exp $
+#
+# Copyright (c) 2016 Internet Initiative Japan Inc.
+# 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+#
+
+SOCKSRC=unix://commsock1
+SOCKFWD=unix://commsock2
+SOCKDST=unix://commsock3
+IP6SRC=fc00:0:0:1::2
+IP6SRCGW=fc00:0:0:1::1
+IP6DSTGW=fc00:0:0:2::1
+IP6DST=fc00:0:0:2::2
+BUS_SRCGW=bus1
+BUS_DSTGW=bus2
+
+IP6SRC2=fc00:0:0:1::3
+IP6SRCGW2=fc00:0:0:1::254
+
+DEBUG=${DEBUG:-false}
+TIMEOUT=1
+
+#
+# Utility functions
+#
+setup_endpoint()
+{
+ local sock=${1}
+ local addr=${2}
+ local bus=${3}
+ local gw=${4}
+
+ rump_server_add_iface $sock shmif0 $bus
+
+ export RUMP_SERVER=${sock}
+ atf_check -s exit:0 rump.ifconfig shmif0 inet6 ${addr}
+ atf_check -s exit:0 -o ignore rump.route add -inet6 default ${gw}
+ atf_check -s exit:0 rump.ifconfig shmif0 up
+ atf_check -s exit:0 rump.ifconfig -w 10
+
+ if $DEBUG; then
+ rump.ifconfig shmif0
+ rump.netstat -nr
+ fi
+}
+
+setup_forwarder()
+{
+
+ rump_server_add_iface $SOCKFWD shmif0 $BUS_SRCGW
+ rump_server_add_iface $SOCKFWD shmif1 $BUS_DSTGW
+
+ export RUMP_SERVER=$SOCKFWD
+
+ atf_check -s exit:0 rump.ifconfig shmif0 inet6 ${IP6SRCGW}
+ atf_check -s exit:0 rump.ifconfig shmif1 inet6 ${IP6DSTGW}
+
+ atf_check -s exit:0 rump.ifconfig shmif0 up
+ atf_check -s exit:0 rump.ifconfig shmif1 up
+ atf_check -s exit:0 rump.ifconfig -w 10
+
+ if $DEBUG; then
+ rump.netstat -nr
+ rump.sysctl net.inet6.ip6.forwarding
+ fi
+}
+
+setup_forwarding6()
+{
+ export RUMP_SERVER=$SOCKFWD
+ atf_check -s exit:0 -o ignore rump.sysctl -w net.inet6.ip6.forwarding=1
+}
+
+setup6()
+{
+
+ rump_server_start $SOCKSRC netinet6
+ rump_server_start $SOCKFWD netinet6
+ rump_server_start $SOCKDST netinet6
+
+ setup_endpoint $SOCKSRC $IP6SRC $BUS_SRCGW $IP6SRCGW
+ setup_endpoint $SOCKDST $IP6DST $BUS_DSTGW $IP6DSTGW
+ setup_forwarder
+}
+
+check_echo_request_pkt()
+{
+ local pkt="$1 > $2: .+ echo request"
+
+ extract_new_packets $BUS_SRCGW > ./out
+ $DEBUG && echo $pkt
+ $DEBUG && cat ./out
+ atf_check -s exit:0 -o match:"$pkt" cat ./out
+}
+
+check_echo_request_pkt_with_macaddr()
+{
+ local pkt="$1 > $2, .+ $3 > $4: .+ echo request"
+
+ extract_new_packets $BUS_SRCGW > ./out
+ $DEBUG && echo $pkt
+ $DEBUG && cat ./out
+ atf_check -s exit:0 -o match:"$pkt" cat ./out
+}
+
+check_echo_request_pkt_with_macaddr_and_rthdr0()
+{
+ local pkt=
+
+ pkt="$1 > $2, .+ $3 > $4:"
+ pkt="$pkt srcrt \\(len=2, type=0, segleft=1, \\[0\\]$5\\)"
+ pkt="$pkt .+ echo request"
+
+ extract_new_packets $BUS_SRCGW > ./out
+ $DEBUG && echo $pkt
+ $DEBUG && cat ./out
+ atf_check -s exit:0 -o match:"$pkt" cat ./out
+}
+
+#
+# Tests
+#
+atf_test_case ping6_opts_sourceaddr cleanup
+ping6_opts_sourceaddr_head()
+{
+
+ atf_set "descr" "tests of ping6 -S option"
+ atf_set "require.progs" "rump_server"
+}
+
+ping6_opts_sourceaddr_body()
+{
+
+ setup6
+ setup_forwarding6
+
+ export RUMP_SERVER=$SOCKSRC
+ atf_check -s exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT $IP6DST
+ check_echo_request_pkt $IP6SRC $IP6DST
+
+ atf_check -s exit:0 rump.ifconfig shmif0 inet6 $IP6SRC2
+ atf_check -s exit:0 rump.ifconfig -w 10
+
+ atf_check -s exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT $IP6DST
+ check_echo_request_pkt $IP6SRC $IP6DST
+
+ # ping6 -S <sourceaddr>
+ atf_check -s exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT \
+ -S $IP6SRC $IP6DST
+ check_echo_request_pkt $IP6SRC $IP6DST
+
+ atf_check -s exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT \
+ -S $IP6SRC2 $IP6DST
+ check_echo_request_pkt $IP6SRC2 $IP6DST
+
+ rump_server_destroy_ifaces
+}
+
+ping6_opts_sourceaddr_cleanup()
+{
+
+ $DEBUG && dump
+ cleanup
+}
+
+atf_test_case ping6_opts_interface cleanup
+ping6_opts_interface_head()
+{
+
+ atf_set "descr" "tests of ping6 -I option"
+ atf_set "require.progs" "rump_server"
+}
+
+ping6_opts_interface_body()
+{
+ local shmif0_lladdr=
+ local shmif1_lladdr=
+ local gw_lladdr=
+
+ setup6
+ setup_forwarding6
+
+ shmif0_lladdr=$(get_linklocal_addr ${SOCKSRC} shmif0)
+ gw_lladdr=$(get_linklocal_addr ${SOCKFWD} shmif0)
+
+ export RUMP_SERVER=$SOCKSRC
+ atf_check -s exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT $gw_lladdr
+ check_echo_request_pkt $shmif0_lladdr $gw_lladdr
+
+ rump_server_add_iface $SOCKSRC shmif1 $BUS_SRCGW
+ atf_check -s exit:0 rump.ifconfig shmif1 up
+ atf_check -s exit:0 rump.ifconfig -w 10
+ shmif1_lladdr=$(get_linklocal_addr ${SOCKSRC} shmif1)
+
+ atf_check -s exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT $gw_lladdr
+ check_echo_request_pkt $shmif0_lladdr $gw_lladdr
+
+ # ping6 -I <interface>
+ atf_check -s exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT \
+ -I shmif0 $gw_lladdr
+ check_echo_request_pkt $shmif0_lladdr $gw_lladdr
+
+ atf_check -s exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT \
+ -I shmif1 $gw_lladdr
+ check_echo_request_pkt $shmif1_lladdr $gw_lladdr
+
+ rump_server_destroy_ifaces
+}
+
+ping6_opts_interface_cleanup()
+{
+
+ $DEBUG && dump
+ cleanup
+}
+
+atf_test_case ping6_opts_gateway cleanup
+ping6_opts_gateway_head()
+{
+
+ atf_set "descr" "tests of ping6 -g option"
+ atf_set "require.progs" "rump_server"
+}
+
+ping6_opts_gateway_body()
+{
+ local my_macaddr=
+ local gw_shmif0_macaddr=
+ local gw_shmif2_macaddr=
+
+ setup6
+ setup_forwarding6
+
+ my_macaddr=$(get_macaddr ${SOCKSRC} shmif0)
+ gw_shmif0_macaddr=$(get_macaddr ${SOCKFWD} shmif0)
+
+ export RUMP_SERVER=$SOCKSRC
+ atf_check -s exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT $IP6DST
+ check_echo_request_pkt_with_macaddr \
+ $my_macaddr $gw_shmif0_macaddr $IP6SRC $IP6DST
+
+ rump_server_add_iface $SOCKFWD shmif2 $BUS_SRCGW
+ export RUMP_SERVER=$SOCKFWD
+ atf_check -s exit:0 rump.ifconfig shmif2 inet6 $IP6SRCGW2
+ atf_check -s exit:0 rump.ifconfig -w 10
+ gw_shmif2_macaddr=$(get_macaddr ${SOCKFWD} shmif2)
+
+ export RUMP_SERVER=$SOCKSRC
+ atf_check -s exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT $IP6DST
+ check_echo_request_pkt_with_macaddr \
+ $my_macaddr $gw_shmif0_macaddr $IP6SRC $IP6DST
+
+ # ping6 -g <gateway>
+ atf_check -s exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT \
+ -g $IP6SRCGW $IP6DST
+ check_echo_request_pkt_with_macaddr \
+ $my_macaddr $gw_shmif0_macaddr $IP6SRC $IP6DST
+
+ atf_check -s exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT \
+ -g $IP6SRCGW2 $IP6DST
+ check_echo_request_pkt_with_macaddr \
+ $my_macaddr $gw_shmif2_macaddr $IP6SRC $IP6DST
+
+ rump_server_destroy_ifaces
+}
+
+ping6_opts_gateway_cleanup()
+{
+
+ $DEBUG && dump
+ cleanup
+}
+
+atf_test_case ping6_opts_hops cleanup
+ping6_opts_hops_head()
+{
+
+ atf_set "descr" "tests of ping6 hops (Type 0 Routing Header)"
+ atf_set "require.progs" "rump_server"
+}
+
+ping6_opts_hops_body()
+{
+ local my_macaddr=
+ local gw_shmif0_macaddr=
+ local gw_shmif2_macaddr=
+
+ setup6
+ setup_forwarding6
+
+ my_macaddr=$(get_macaddr ${SOCKSRC} shmif0)
+ gw_shmif0_macaddr=$(get_macaddr ${SOCKFWD} shmif0)
+
+ export RUMP_SERVER=$SOCKSRC
+ atf_check -s exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT $IP6DST
+ check_echo_request_pkt_with_macaddr \
+ $my_macaddr $gw_shmif0_macaddr $IP6SRC $IP6DST
+
+ rump_server_add_iface $SOCKFWD shmif2 $BUS_SRCGW
+ export RUMP_SERVER=$SOCKFWD
+ atf_check -s exit:0 rump.ifconfig shmif2 inet6 $IP6SRCGW2
+ atf_check -s exit:0 rump.ifconfig -w 10
+ gw_shmif2_macaddr=$(get_macaddr ${SOCKFWD} shmif2)
+
+ export RUMP_SERVER=$SOCKSRC
+ atf_check -s exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT $IP6DST
+ check_echo_request_pkt_with_macaddr \
+ $my_macaddr $gw_shmif0_macaddr $IP6SRC $IP6DST
+
+ # ping6 hops
+
+ # ping6 fails expectedly because the kernel doesn't support
+ # to receive packets with type 0 routing headers, but we can
+ # check whether a sent packet is correct.
+ atf_check -s not-exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT \
+ $IP6SRCGW $IP6DST
+ check_echo_request_pkt_with_macaddr_and_rthdr0 \
+ $my_macaddr $gw_shmif0_macaddr $IP6SRC $IP6SRCGW $IP6DST
+
+ atf_check -s not-exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT \
+ $IP6SRCGW2 $IP6DST
+ check_echo_request_pkt_with_macaddr_and_rthdr0 \
+ $my_macaddr $gw_shmif2_macaddr $IP6SRC $IP6SRCGW2 $IP6DST
+
+ # ping6 -g <gateway> hops
+ atf_check -s not-exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT \
+ -g $IP6SRCGW $IP6SRCGW $IP6DST
+ check_echo_request_pkt_with_macaddr_and_rthdr0 \
+ $my_macaddr $gw_shmif0_macaddr $IP6SRC $IP6SRCGW $IP6DST
+
+ atf_check -s not-exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT \
+ -g $IP6SRCGW2 $IP6SRCGW2 $IP6DST
+ check_echo_request_pkt_with_macaddr_and_rthdr0 \
+ $my_macaddr $gw_shmif2_macaddr $IP6SRC $IP6SRCGW2 $IP6DST
+
+ # ping6 -g <gateway> hops, but different nexthops (is it valid?)
+ atf_check -s not-exit:0 -o ignore rump.ping6 -n -c 1 -X $TIMEOUT \
+ -g $IP6SRCGW $IP6SRCGW2 $IP6DST
+ check_echo_request_pkt_with_macaddr_and_rthdr0 \
+ $my_macaddr $gw_shmif0_macaddr $IP6SRC $IP6SRCGW2 $IP6DST
+
+ rump_server_destroy_ifaces
+}
+
+ping6_opts_hops_cleanup()
+{
+
+ $DEBUG && dump
+ cleanup
+}
+
+atf_init_test_cases()
+{
+
+ atf_add_test_case ping6_opts_sourceaddr
+ atf_add_test_case ping6_opts_interface
+ atf_add_test_case ping6_opts_gateway
+ atf_add_test_case ping6_opts_hops
+}
diff --git a/contrib/netbsd-tests/net/net_common.sh b/contrib/netbsd-tests/net/net_common.sh
new file mode 100755
index 0000000..df21a88
--- /dev/null
+++ b/contrib/netbsd-tests/net/net_common.sh
@@ -0,0 +1,314 @@
+# $NetBSD: net_common.sh,v 1.11 2017/01/10 05:55:34 ozaki-r Exp $
+#
+# Copyright (c) 2016 Internet Initiative Japan Inc.
+# 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+#
+
+#
+# Common utility functions for tests/net
+#
+
+HIJACKING="env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=sysctl=yes"
+
+extract_new_packets()
+{
+ local bus=$1
+ local old=./.__old
+
+ if [ ! -f $old ]; then
+ old=/dev/null
+ fi
+
+ shmif_dumpbus -p - $bus 2>/dev/null| \
+ tcpdump -n -e -r - 2>/dev/null > ./.__new
+ diff -u $old ./.__new |grep '^+' |cut -d '+' -f 2 > ./.__diff
+ mv -f ./.__new ./.__old
+ cat ./.__diff
+}
+
+check_route()
+{
+ local target=$1
+ local gw=$2
+ local flags=${3:-\.\+}
+ local ifname=${4:-\.\+}
+
+ target=$(echo $target |sed 's/\./\\./g')
+ if [ "$gw" = "" ]; then
+ gw=".+"
+ else
+ gw=$(echo $gw |sed 's/\./\\./g')
+ fi
+
+ atf_check -s exit:0 -e ignore \
+ -o match:"^$target +$gw +$flags +- +- +.+ +$ifname" \
+ rump.netstat -rn
+}
+
+check_route_flags()
+{
+
+ check_route "$1" "" "$2" ""
+}
+
+check_route_gw()
+{
+
+ check_route "$1" "$2" "" ""
+}
+
+check_route_no_entry()
+{
+ local target=$(echo $1 |sed 's/\./\\./g')
+
+ atf_check -s exit:0 -e ignore -o not-match:"^$target" \
+ rump.netstat -rn
+}
+
+get_linklocal_addr()
+{
+
+ export RUMP_SERVER=${1}
+ rump.ifconfig ${2} inet6 |
+ awk "/fe80/ {sub(/%$2/, \"\"); sub(/\\/[0-9]*/, \"\"); print \$2;}"
+ unset RUMP_SERVER
+
+ return 0
+}
+
+get_macaddr()
+{
+
+ env RUMP_SERVER=${1} \
+ rump.ifconfig ${2} |awk '/address/ {print $2;}'
+}
+
+HTTPD_PID=./.__httpd.pid
+start_httpd()
+{
+ local sock=$1
+ local ip=$2
+ local backup=$RUMP_SERVER
+
+ export RUMP_SERVER=$sock
+
+ # start httpd in daemon mode
+ atf_check -s exit:0 env LD_PRELOAD=/usr/lib/librumphijack.so \
+ /usr/libexec/httpd -P $HTTPD_PID -i $ip -b -s $(pwd)
+
+ export RUMP_SERVER=$backup
+
+ sleep 3
+}
+
+stop_httpd()
+{
+
+ if [ -f $HTTPD_PID ]; then
+ kill -9 $(cat $HTTPD_PID)
+ rm -f $HTTPD_PID
+ sleep 1
+ fi
+}
+
+BASIC_LIBS="-lrumpnet -lrumpnet_net -lrumpnet_netinet \
+ -lrumpnet_shmif -lrumpdev"
+FS_LIBS="$BASIC_LIBS -lrumpvfs -lrumpfs_ffs"
+
+# We cannot keep variables between test phases, so need to store in files
+_rump_server_socks=./.__socks
+_rump_server_ifaces=./.__ifaces
+_rump_server_buses=./.__buses
+
+_rump_server_start_common()
+{
+ local sock=$1
+ local libs=
+
+ shift 1
+ libs="$*"
+
+ atf_check -s exit:0 rump_server $libs $sock
+
+ echo $sock >> $_rump_server_socks
+ $DEBUG && cat $_rump_server_socks
+}
+
+rump_server_start()
+{
+ local sock=$1
+ local _libs=
+ local libs="$BASIC_LIBS"
+
+ shift 1
+ _libs="$*"
+
+ for lib in $_libs; do
+ libs="$libs -lrumpnet_$lib"
+ done
+
+ _rump_server_start_common $sock $libs
+
+ return 0
+}
+
+rump_server_fs_start()
+{
+ local sock=$1
+ local _libs=
+ local libs="$FS_LIBS"
+
+ shift 1
+ _libs="$*"
+
+ for lib in $_libs; do
+ libs="$libs -lrumpnet_$lib"
+ done
+
+ _rump_server_start_common $sock $libs
+
+ return 0
+}
+
+rump_server_add_iface()
+{
+ local sock=$1
+ local ifname=$2
+ local bus=$3
+ local backup=$RUMP_SERVER
+
+ export RUMP_SERVER=$sock
+ atf_check -s exit:0 rump.ifconfig $ifname create
+ atf_check -s exit:0 rump.ifconfig $ifname linkstr $bus
+ export RUMP_SERVER=$backup
+
+ echo $sock $ifname >> $_rump_server_ifaces
+ $DEBUG && cat $_rump_server_ifaces
+
+ echo $bus >> $_rump_server_buses
+ cat $_rump_server_buses |sort -u >./.__tmp
+ mv -f ./.__tmp $_rump_server_buses
+ $DEBUG && cat $_rump_server_buses
+
+ return 0
+}
+
+rump_server_destroy_ifaces()
+{
+ local backup=$RUMP_SERVER
+
+ $DEBUG && cat $_rump_server_ifaces
+
+ # Try to dump states before destroying interfaces
+ for sock in $(cat $_rump_server_socks); do
+ export RUMP_SERVER=$sock
+ atf_check -s exit:0 -o ignore rump.ifconfig
+ atf_check -s exit:0 -o ignore rump.netstat -nr
+ # XXX still need hijacking
+ atf_check -s exit:0 -o ignore $HIJACKING rump.netstat -i -a
+ atf_check -s exit:0 -o ignore rump.arp -na
+ atf_check -s exit:0 -o ignore rump.ndp -na
+ atf_check -s exit:0 -o ignore $HIJACKING ifmcstat
+ done
+
+ # XXX using pipe doesn't work. See PR bin/51667
+ #cat $_rump_server_ifaces | while read sock ifname; do
+ while read sock ifname; do
+ export RUMP_SERVER=$sock
+ if rump.ifconfig -l |grep -q $ifname; then
+ atf_check -s exit:0 rump.ifconfig $ifname destroy
+ fi
+ atf_check -s exit:0 -o ignore rump.ifconfig
+ done < $_rump_server_ifaces
+ export RUMP_SERVER=$backup
+
+ return 0
+}
+
+rump_server_halt_servers()
+{
+ local backup=$RUMP_SERVER
+
+ $DEBUG && cat $_rump_server_socks
+ for sock in $(cat $_rump_server_socks); do
+ env RUMP_SERVER=$sock rump.halt
+ done
+ export RUMP_SERVER=$backup
+
+ return 0
+}
+
+rump_server_dump_servers()
+{
+ local backup=$RUMP_SERVER
+
+ $DEBUG && cat $_rump_server_socks
+ for sock in $(cat $_rump_server_socks); do
+ echo "### Dumping $sock"
+ export RUMP_SERVER=$sock
+ rump.ifconfig
+ rump.netstat -nr
+ # XXX still need hijacking
+ $HIJACKING rump.netstat -i -a
+ rump.arp -na
+ rump.ndp -na
+ $HIJACKING ifmcstat
+ $HIJACKING dmesg
+ done
+ export RUMP_SERVER=$backup
+
+ if [ -f rump_server.core ]; then
+ gdb -ex bt /usr/bin/rump_server rump_server.core
+ strings rump_server.core |grep panic
+ fi
+ return 0
+}
+
+rump_server_dump_buses()
+{
+
+ if [ ! -f $_rump_server_buses ]; then
+ return 0
+ fi
+
+ $DEBUG && cat $_rump_server_buses
+ for bus in $(cat $_rump_server_buses); do
+ echo "### Dumping $bus"
+ shmif_dumpbus -p - $bus 2>/dev/null| tcpdump -n -e -r -
+ done
+ return 0
+}
+
+cleanup()
+{
+
+ rump_server_halt_servers
+}
+
+dump()
+{
+
+ rump_server_dump_servers
+ rump_server_dump_buses
+}
diff --git a/contrib/netbsd-tests/net/route/t_change.sh b/contrib/netbsd-tests/net/route/t_change.sh
index 669c9f3..260cad0 100755
--- a/contrib/netbsd-tests/net/route/t_change.sh
+++ b/contrib/netbsd-tests/net/route/t_change.sh
@@ -1,4 +1,4 @@
-# $NetBSD: t_change.sh,v 1.8 2016/08/10 23:00:39 roy Exp $
+# $NetBSD: t_change.sh,v 1.9 2016/11/07 05:25:37 ozaki-r Exp $
#
# Copyright (c) 2011 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -30,7 +30,7 @@ netserver=\
-lrumpnet_netinet -lrumpnet_shmif"
export RUMP_SERVER=unix://commsock
-DEBUG=false
+DEBUG=${DEBUG:-false}
atf_test_case route_change_reject2blackhole cleanup
route_change_reject2blackhole_head()
diff --git a/contrib/netbsd-tests/net/route/t_flags.sh b/contrib/netbsd-tests/net/route/t_flags.sh
index 26625bb..457e3f5 100755
--- a/contrib/netbsd-tests/net/route/t_flags.sh
+++ b/contrib/netbsd-tests/net/route/t_flags.sh
@@ -1,4 +1,4 @@
-# $NetBSD: t_flags.sh,v 1.11 2016/08/10 23:00:39 roy Exp $
+# $NetBSD: t_flags.sh,v 1.15 2016/12/21 02:46:08 ozaki-r Exp $
#
# Copyright (c) 2015 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -25,27 +25,24 @@
# POSSIBILITY OF SUCH DAMAGE.
#
-netserver=\
-"rump_server -lrumpdev -lrumpnet -lrumpnet_net -lrumpnet_netinet \
- -lrumpnet_shmif"
SOCK_LOCAL=unix://commsock1
SOCK_PEER=unix://commsock2
SOCK_GW=unix://commsock3
BUS=bus1
BUS2=bus2
-DEBUG=false
+DEBUG=${DEBUG:-false}
setup_local()
{
- atf_check -s exit:0 ${netserver} ${SOCK_LOCAL}
+ rump_server_start $SOCK_LOCAL
+ rump_server_add_iface $SOCK_LOCAL shmif0 $BUS
export RUMP_SERVER=$SOCK_LOCAL
- atf_check -s exit:0 -o ignore rump.ifconfig shmif0 create
- atf_check -s exit:0 -o ignore rump.ifconfig shmif0 linkstr ${BUS}
atf_check -s exit:0 -o ignore rump.ifconfig shmif0 10.0.0.2/24
atf_check -s exit:0 -o ignore rump.ifconfig shmif0 up
+ atf_check -s exit:0 -o ignore rump.ifconfig -w 10
$DEBUG && rump.ifconfig
$DEBUG && rump.netstat -rn -f inet
@@ -54,13 +51,13 @@ setup_local()
setup_peer()
{
- atf_check -s exit:0 ${netserver} ${SOCK_PEER}
+ rump_server_start $SOCK_PEER
+ rump_server_add_iface $SOCK_PEER shmif0 $BUS
export RUMP_SERVER=$SOCK_PEER
- atf_check -s exit:0 -o ignore rump.ifconfig shmif0 create
- atf_check -s exit:0 -o ignore rump.ifconfig shmif0 linkstr ${BUS}
atf_check -s exit:0 -o ignore rump.ifconfig shmif0 10.0.0.1/24
atf_check -s exit:0 -o ignore rump.ifconfig shmif0 up
+ atf_check -s exit:0 -o ignore rump.ifconfig -w 10
$DEBUG && rump.ifconfig
$DEBUG && rump.netstat -rn -f inet
@@ -69,16 +66,14 @@ setup_peer()
setup_gw()
{
- atf_check -s exit:0 ${netserver} ${SOCK_GW}
+ rump_server_start $SOCK_GW
+ rump_server_add_iface $SOCK_GW shmif0 $BUS
+ rump_server_add_iface $SOCK_GW shmif1 $BUS2
export RUMP_SERVER=$SOCK_GW
- atf_check -s exit:0 -o ignore rump.ifconfig shmif0 create
- atf_check -s exit:0 -o ignore rump.ifconfig shmif0 linkstr ${BUS}
atf_check -s exit:0 -o ignore rump.ifconfig shmif0 10.0.0.254/24
atf_check -s exit:0 -o ignore rump.ifconfig shmif0 up
- atf_check -s exit:0 -o ignore rump.ifconfig shmif1 create
- atf_check -s exit:0 -o ignore rump.ifconfig shmif1 linkstr ${BUS2}
atf_check -s exit:0 -o ignore rump.ifconfig shmif1 10.0.2.1/24
atf_check -s exit:0 -o ignore rump.ifconfig shmif1 alias 10.0.2.2/24
atf_check -s exit:0 -o ignore rump.ifconfig shmif1 up
@@ -91,46 +86,13 @@ setup_gw()
$DEBUG && rump.netstat -rn -f inet
}
-teardown_gw()
-{
-
- env RUMP_SERVER=$SOCK_GW rump.halt
-}
-
-check_entry_flags()
-{
- local ip=$(echo $1 |sed 's/\./\\./g')
- local flags=$2
-
- atf_check -s exit:0 -o match:" $flags " -e ignore -x \
- "rump.netstat -rn -f inet | grep ^'$ip'"
-}
-
-check_entry_gw()
-{
- local ip=$(echo $1 |sed 's/\./\\./g')
- local gw=$2
-
- atf_check -s exit:0 -o match:" $gw " -e ignore -x \
- "rump.netstat -rn -f inet | grep ^'$ip'"
-}
-
-check_entry_fail()
-{
- ip=$(echo $1 |sed 's/\./\\./g')
- flags=$2 # Not used currently
-
- atf_check -s not-exit:0 -e ignore -x \
- "rump.netstat -rn -f inet | grep ^'$ip'"
-}
-
test_lo()
{
export RUMP_SERVER=$SOCK_LOCAL
# Up, Host, local
- check_entry_flags 127.0.0.1 UHl
+ check_route_flags 127.0.0.1 UHl
}
test_connected()
@@ -139,10 +101,10 @@ test_connected()
export RUMP_SERVER=$SOCK_LOCAL
# Up, Host, LLINFO, local
- check_entry_flags 10.0.0.2 UHl
+ check_route_flags 10.0.0.2 UHl
# Up, Cloning
- check_entry_flags 10.0.0/24 UC
+ check_route_flags 10.0.0/24 UC
}
test_default_gateway()
@@ -154,7 +116,7 @@ test_default_gateway()
$DEBUG && rump.netstat -rn -f inet
# Up, Gateway, Static
- check_entry_flags default UGS
+ check_route_flags default UGS
}
test_static()
@@ -167,14 +129,14 @@ test_static()
$DEBUG && rump.netstat -rn -f inet
# Up, Gateway, Host, Static
- check_entry_flags 10.0.1.1 UGHS
+ check_route_flags 10.0.1.1 UGHS
# Static route to network
atf_check -s exit:0 -o ignore rump.route add -net 10.0.2.0/24 10.0.0.1
$DEBUG && rump.netstat -rn -f inet
# Up, Gateway, Static
- check_entry_flags 10.0.2/24 UGS
+ check_route_flags 10.0.2/24 UGS
}
test_blackhole()
@@ -193,14 +155,14 @@ test_blackhole()
$DEBUG && rump.netstat -rn -f inet
# Up, Gateway, Blackhole, Static
- check_entry_flags 10.0.0/24 UGBS
+ check_route_flags 10.0.0/24 UGBS
atf_check -s not-exit:0 -o match:'100.0% packet loss' \
rump.ping -n -w 1 -c 1 10.0.0.1
$DEBUG && rump.netstat -rn -f inet
# Shouldn't be created
- check_entry_fail 10.0.0.1 UH
+ check_route_no_entry 10.0.0.1
}
test_reject()
@@ -215,14 +177,14 @@ test_reject()
$DEBUG && rump.netstat -rn -f inet
# Up, Gateway, Reject, Static
- check_entry_flags 10.0.0/24 UGRS
+ check_route_flags 10.0.0/24 UGRS
atf_check -s not-exit:0 -o ignore -e match:'No route to host' \
rump.ping -n -w 1 -c 1 10.0.0.1
$DEBUG && rump.netstat -rn -f inet
# Shouldn't be created
- check_entry_fail 10.0.0.1 UH
+ check_route_no_entry 10.0.0.1
# Gateway is lo0 (RTF_GATEWAY)
@@ -234,14 +196,14 @@ test_reject()
$DEBUG && rump.netstat -rn -f inet
# Up, Gateway, Reject, Static
- check_entry_flags 10.0.0/24 UGRS
+ check_route_flags 10.0.0/24 UGRS
atf_check -s not-exit:0 -o ignore -e match:'Network is unreachable' \
rump.ping -n -w 1 -c 1 10.0.0.1
$DEBUG && rump.netstat -rn -f inet
# Shouldn't be created
- check_entry_fail 10.0.0.1 UH
+ check_route_no_entry 10.0.0.1
# Gateway is lo0 (RTF_HOST)
@@ -253,7 +215,7 @@ test_reject()
$DEBUG && rump.netstat -rn -f inet
# Up, Host, Reject, Static
- check_entry_flags 10.0.0.1 UHRS
+ check_route_flags 10.0.0.1 UHRS
atf_check -s not-exit:0 -o ignore -e match:'No route to host' \
rump.ping -n -w 1 -c 1 10.0.0.1
@@ -278,7 +240,7 @@ test_icmp_redirect()
export RUMP_SERVER=$SOCK_PEER
atf_check -s exit:0 -o ignore rump.route add -net 10.0.2.0/24 10.0.0.254
# Up, Gateway, Static
- check_entry_flags 10.0.2/24 UGS
+ check_route_flags 10.0.2/24 UGS
#
# Setup the default gateway to the peer, 10.0.0.1
@@ -286,15 +248,15 @@ test_icmp_redirect()
export RUMP_SERVER=$SOCK_LOCAL
atf_check -s exit:0 -o ignore rump.route add default 10.0.0.1
# Up, Gateway, Static
- check_entry_flags default UGS
+ check_route_flags default UGS
# Try ping 10.0.2.1
atf_check -s exit:0 -o ignore rump.ping -n -w 1 -c 1 10.0.2.1
$DEBUG && rump.netstat -rn -f inet
# Up, Gateway, Host, Dynamic
- check_entry_flags 10.0.2.1 UGHD
- check_entry_gw 10.0.2.1 10.0.0.254
+ check_route_flags 10.0.2.1 UGHD
+ check_route_gw 10.0.2.1 10.0.0.254
export RUMP_SERVER=$SOCK_PEER
$DEBUG && rump.netstat -rn -f inet
@@ -307,18 +269,16 @@ test_icmp_redirect()
export RUMP_SERVER=$SOCK_LOCAL
atf_check -s exit:0 -o ignore rump.route add 10.0.2.2 10.0.0.1
# Up, Gateway, Host, Static
- check_entry_flags 10.0.2.2 UGHS
- check_entry_gw 10.0.2.2 10.0.0.1
+ check_route_flags 10.0.2.2 UGHS
+ check_route_gw 10.0.2.2 10.0.0.1
# Try ping 10.0.2.2
atf_check -s exit:0 -o ignore rump.ping -n -w 1 -c 1 10.0.2.2
$DEBUG && rump.netstat -rn -f inet
# Up, Gateway, Host, Modified, Static
- check_entry_flags 10.0.2.2 UGHMS
- check_entry_gw 10.0.2.2 10.0.0.254
-
- teardown_gw
+ check_route_flags 10.0.2.2 UGHMS
+ check_route_gw 10.0.2.2 10.0.0.254
}
test_announce()
@@ -332,19 +292,11 @@ test_announce()
$DEBUG && rump.netstat -rn -f inet
# Up, Gateway, Static, proxy
- check_entry_flags 10.0.0/24 UGSp
+ check_route_flags 10.0.0/24 UGSp
# TODO test its behavior
}
-cleanup()
-{
- $DEBUG && /usr/bin/shmif_dumpbus -p - $BUS 2>/dev/null | \
- /usr/sbin/tcpdump -n -e -r -
- env RUMP_SERVER=$SOCK_LOCAL rump.halt
- env RUMP_SERVER=$SOCK_PEER rump.halt
-}
-
add_test()
{
local name=$1
@@ -359,8 +311,10 @@ add_test()
setup_local; \
setup_peer; \
test_${name}; \
+ rump_server_destroy_ifaces; \
}; \
route_flags_${name}_cleanup() { \
+ $DEBUG && dump; \
cleanup; \
}"
atf_add_test_case "route_flags_${name}"
diff --git a/contrib/netbsd-tests/net/route/t_flags6.sh b/contrib/netbsd-tests/net/route/t_flags6.sh
index 20b800e..e570829 100755
--- a/contrib/netbsd-tests/net/route/t_flags6.sh
+++ b/contrib/netbsd-tests/net/route/t_flags6.sh
@@ -1,4 +1,4 @@
-# $NetBSD: t_flags6.sh,v 1.7 2016/08/10 23:00:39 roy Exp $
+# $NetBSD: t_flags6.sh,v 1.12 2016/12/21 02:46:08 ozaki-r Exp $
#
# Copyright (c) 2016 Internet Initiative Japan Inc.
# All rights reserved.
@@ -25,9 +25,6 @@
# POSSIBILITY OF SUCH DAMAGE.
#
-RUMP_OPTS="-lrumpdev -lrumpnet -lrumpnet_net"
-RUMP_OPTS="$RUMP_OPTS -lrumpnet_netinet -lrumpnet_netinet6"
-RUMP_OPTS="$RUMP_OPTS -lrumpnet_shmif"
SOCK_LOCAL=unix://commsock1
SOCK_PEER=unix://commsock2
SOCK_GW=unix://commsock3
@@ -37,18 +34,18 @@ BUS2=bus2
IP6_LOCAL=fc00::2
IP6_PEER=fc00::1
-DEBUG=false
+DEBUG=${DEBUG:-false}
setup_local()
{
- atf_check -s exit:0 rump_server ${RUMP_OPTS} ${SOCK_LOCAL}
+ rump_server_start $SOCK_LOCAL netinet6
+ rump_server_add_iface $SOCK_LOCAL shmif0 $BUS
export RUMP_SERVER=$SOCK_LOCAL
- atf_check -s exit:0 -o ignore rump.ifconfig shmif0 create
- atf_check -s exit:0 -o ignore rump.ifconfig shmif0 linkstr ${BUS}
atf_check -s exit:0 -o ignore rump.ifconfig shmif0 inet6 $IP6_LOCAL
atf_check -s exit:0 -o ignore rump.ifconfig shmif0 up
+ atf_check -s exit:0 -o ignore rump.ifconfig -w 10
$DEBUG && rump.ifconfig
$DEBUG && rump.netstat -rn -f inet6
@@ -57,55 +54,28 @@ setup_local()
setup_peer()
{
- atf_check -s exit:0 rump_server ${RUMP_OPTS} ${SOCK_PEER}
+ rump_server_start $SOCK_PEER netinet6
+ rump_server_add_iface $SOCK_PEER shmif0 $BUS
export RUMP_SERVER=$SOCK_PEER
- atf_check -s exit:0 -o ignore rump.ifconfig shmif0 create
- atf_check -s exit:0 -o ignore rump.ifconfig shmif0 linkstr ${BUS}
atf_check -s exit:0 -o ignore rump.ifconfig shmif0 inet6 $IP6_PEER
atf_check -s exit:0 -o ignore rump.ifconfig shmif0 up
+ atf_check -s exit:0 -o ignore rump.ifconfig -w 10
$DEBUG && rump.ifconfig
$DEBUG && rump.netstat -rn -f inet6
}
-check_entry_flags()
-{
- local ip=$(echo $1 |sed 's/\./\\./g')
- local flags=$2
-
- atf_check -s exit:0 -o match:" $flags " -e ignore -x \
- "rump.netstat -rn -f inet6 | grep ^'$ip'"
-}
-
-check_entry_gw()
-{
- local ip=$(echo $1 |sed 's/\./\\./g')
- local gw=$2
-
- atf_check -s exit:0 -o match:" $gw " -e ignore -x \
- "rump.netstat -rn -f inet6 | grep ^'$ip'"
-}
-
-check_entry_fail()
-{
- ip=$(echo $1 |sed 's/\./\\./g')
- flags=$2 # Not used currently
-
- atf_check -s not-exit:0 -e ignore -x \
- "rump.netstat -rn -f inet6 | grep ^'$ip'"
-}
-
test_lo6()
{
export RUMP_SERVER=$SOCK_LOCAL
# Up, Host, local
- check_entry_flags fe80::1 UHl
+ check_route_flags fe80::1 UHl
- # Up, Host
- check_entry_flags ::1 UH
+ # Up, Host, local
+ check_route_flags ::1 UHl
}
test_connected6()
@@ -114,10 +84,10 @@ test_connected6()
export RUMP_SERVER=$SOCK_LOCAL
# Up, Host, local
- check_entry_flags $IP6_LOCAL UHl
+ check_route_flags $IP6_LOCAL UHl
# Up, Connected
- check_entry_flags fc00::/64 UC
+ check_route_flags fc00::/64 UC
}
test_default_gateway6()
@@ -129,7 +99,7 @@ test_default_gateway6()
$DEBUG && rump.netstat -rn -f inet6
# Up, Gateway, Static
- check_entry_flags default UGS
+ check_route_flags default UGS
}
test_static6()
@@ -143,7 +113,7 @@ test_static6()
$DEBUG && rump.netstat -rn -f inet6
# Up, Gateway, Host, Static
- check_entry_flags fc00::1:1 UGHS
+ check_route_flags fc00::1:1 UGHS
# Static route to network
atf_check -s exit:0 -o ignore \
@@ -151,7 +121,7 @@ test_static6()
$DEBUG && rump.netstat -rn -f inet6
# Up, Gateway, Static
- check_entry_flags fc00::/24 UGS
+ check_route_flags fc00::/24 UGS
}
test_blackhole6()
@@ -171,14 +141,14 @@ test_blackhole6()
$DEBUG && rump.netstat -rn -f inet6
# Up, Gateway, Blackhole, Static
- check_entry_flags fc00::/64 UGBS
+ check_route_flags fc00::/64 UGBS
atf_check -s not-exit:0 -o match:'100.0% packet loss' \
rump.ping6 -n -X 1 -c 1 $IP6_PEER
$DEBUG && rump.netstat -rn -f inet6
# Shouldn't be created
- check_entry_fail $IP6_PEER UH
+ check_route_no_entry $IP6_PEER
}
test_reject6()
@@ -195,14 +165,14 @@ test_reject6()
$DEBUG && rump.netstat -rn -f inet6
# Up, Gateway, Reject, Static
- check_entry_flags fc00::/64 UGRS
+ check_route_flags fc00::/64 UGRS
atf_check -s not-exit:0 -o ignore -e match:'No route to host' \
rump.ping6 -n -X 1 -c 1 $IP6_PEER
$DEBUG && rump.netstat -rn -f inet6
# Shouldn't be created
- check_entry_fail $IP6_PEER UH
+ check_route_no_entry $IP6_PEER
# Gateway is lo0 (RTF_GATEWAY)
@@ -215,14 +185,14 @@ test_reject6()
$DEBUG && rump.netstat -rn -f inet6
# Up, Gateway, Reject, Static
- check_entry_flags fc00::/64 UGRS
+ check_route_flags fc00::/64 UGRS
atf_check -s not-exit:0 -o ignore -e match:'Network is unreachable' \
rump.ping6 -n -X 1 -c 1 $IP6_PEER
$DEBUG && rump.netstat -rn -f inet6
# Shouldn't be created
- check_entry_fail $IP6_PEER UH
+ check_route_no_entry $IP6_PEER
# Gateway is lo0 (RTF_HOST)
@@ -235,7 +205,7 @@ test_reject6()
$DEBUG && rump.netstat -rn -f inet6
# Up, Host, Reject, Static
- check_entry_flags fc00:: UHRS
+ check_route_flags fc00:: UHRS
atf_check -s not-exit:0 -o ignore -e match:'No route to host' \
rump.ping6 -n -X 1 -c 1 $IP6_PEER
@@ -257,19 +227,11 @@ test_announce6()
$DEBUG && rump.netstat -rn -f inet6
# Up, Gateway, Static, proxy
- check_entry_flags fc00::/64 UGSp
+ check_route_flags fc00::/64 UGSp
# TODO test its behavior
}
-cleanup()
-{
- $DEBUG && /usr/bin/shmif_dumpbus -p - $BUS 2>/dev/null | \
- /usr/sbin/tcpdump -n -e -r -
- env RUMP_SERVER=$SOCK_LOCAL rump.halt
- env RUMP_SERVER=$SOCK_PEER rump.halt
-}
-
add_test()
{
local name=$1
@@ -284,8 +246,10 @@ add_test()
setup_local; \
setup_peer; \
test_${name}; \
+ rump_server_destroy_ifaces; \
}; \
route_flags_${name}_cleanup() { \
+ $DEBUG && dump; \
cleanup; \
}"
atf_add_test_case "route_flags_${name}"
diff --git a/contrib/netbsd-tests/net/route/t_route.sh b/contrib/netbsd-tests/net/route/t_route.sh
index 37ede4ce..053f48f 100755
--- a/contrib/netbsd-tests/net/route/t_route.sh
+++ b/contrib/netbsd-tests/net/route/t_route.sh
@@ -1,4 +1,4 @@
-# $NetBSD: t_route.sh,v 1.7 2016/08/10 23:00:39 roy Exp $
+# $NetBSD: t_route.sh,v 1.10 2016/12/21 02:46:08 ozaki-r Exp $
#
# Copyright (c) 2016 Internet Initiative Japan Inc.
# All rights reserved.
@@ -25,9 +25,6 @@
# POSSIBILITY OF SUCH DAMAGE.
#
-RUMP_LIBS="-lrumpdev -lrumpnet -lrumpnet_net -lrumpnet_netinet -lrumpnet_shmif"
-RUMP_LIBS_IPV6="$RUMP_LIBS -lrumpnet_netinet6"
-
# non_subnet_gateway
SOCK_CLIENT=unix://commsock1
SOCK_GW=unix://commsock2
@@ -49,7 +46,7 @@ IP6DST=fc00:0:0:2::2
BUS_SRCGW=bus1
BUS_DSTGW=bus2
-DEBUG=false
+DEBUG=${DEBUG:-false}
TIMEOUT=1
PING_OPTS="-n -c 1 -w $TIMEOUT"
@@ -64,13 +61,11 @@ route_non_subnet_gateway_head()
route_non_subnet_gateway_body()
{
- atf_check -s exit:0 rump_server ${RUMP_LIBS} ${SOCK_CLIENT}
- atf_check -s exit:0 rump_server ${RUMP_LIBS} ${SOCK_GW}
+ rump_server_start $SOCK_CLIENT
+ rump_server_start $SOCK_GW
export RUMP_SERVER=${SOCK_GW}
-
- atf_check -s exit:0 rump.ifconfig shmif0 create
- atf_check -s exit:0 rump.ifconfig shmif0 linkstr $BUS
+ rump_server_add_iface $SOCK_GW shmif0 $BUS
atf_check -s exit:0 rump.ifconfig shmif0 192.168.0.1
atf_check -s exit:0 rump.ifconfig shmif0 up
@@ -81,11 +76,10 @@ route_non_subnet_gateway_body()
$DEBUG && rump.netstat -nr -f inet
export RUMP_SERVER=${SOCK_CLIENT}
-
- atf_check -s exit:0 rump.ifconfig shmif0 create
- atf_check -s exit:0 rump.ifconfig shmif0 linkstr $BUS
+ rump_server_add_iface $SOCK_CLIENT shmif0 $BUS
atf_check -s exit:0 rump.ifconfig shmif0 10.0.0.1/32
atf_check -s exit:0 rump.ifconfig shmif0 up
+ atf_check -s exit:0 rump.ifconfig -w 10
$DEBUG && rump.netstat -nr -f inet
@@ -104,15 +98,14 @@ route_non_subnet_gateway_body()
# Be reachable to the gateway
atf_check -s exit:0 -o ignore rump.ping $PING_OPTS 192.168.0.1
- unset RUMP_SERVER
+ rump_server_destroy_ifaces
}
route_non_subnet_gateway_cleanup()
{
- $DEBUG && shmif_dumpbus -p - $BUS 2>/dev/null | tcpdump -n -e -r -
- env RUMP_SERVER=$SOCK_CLIENT rump.halt
- env RUMP_SERVER=$SOCK_GW rump.halt
+ $DEBUG && dump
+ cleanup
}
atf_test_case route_command_get cleanup
@@ -140,8 +133,7 @@ setup_endpoint()
local gw=${5}
export RUMP_SERVER=${sock}
- atf_check -s exit:0 rump.ifconfig shmif0 create
- atf_check -s exit:0 rump.ifconfig shmif0 linkstr ${bus}
+ rump_server_add_iface $sock shmif0 $bus
if [ $mode = "ipv6" ]; then
atf_check -s exit:0 rump.ifconfig shmif0 inet6 ${addr}
atf_check -s exit:0 -o ignore rump.route add -inet6 default ${gw}
@@ -150,6 +142,7 @@ setup_endpoint()
atf_check -s exit:0 -o ignore rump.route add default ${gw}
fi
atf_check -s exit:0 rump.ifconfig shmif0 up
+ atf_check -s exit:0 rump.ifconfig -w 10
if $DEBUG; then
rump.ifconfig shmif0
@@ -161,13 +154,10 @@ setup_forwarder()
{
mode=${1}
- export RUMP_SERVER=$SOCKFWD
- atf_check -s exit:0 rump.ifconfig shmif0 create
- atf_check -s exit:0 rump.ifconfig shmif0 linkstr $BUS_SRCGW
-
- atf_check -s exit:0 rump.ifconfig shmif1 create
- atf_check -s exit:0 rump.ifconfig shmif1 linkstr $BUS_DSTGW
+ rump_server_add_iface $SOCKFWD shmif0 $BUS_SRCGW
+ rump_server_add_iface $SOCKFWD shmif1 $BUS_DSTGW
+ export RUMP_SERVER=$SOCKFWD
if [ $mode = "ipv6" ]; then
atf_check -s exit:0 rump.ifconfig shmif0 inet6 ${IP6SRCGW}
atf_check -s exit:0 rump.ifconfig shmif1 inet6 ${IP6DSTGW}
@@ -178,6 +168,7 @@ setup_forwarder()
atf_check -s exit:0 rump.ifconfig shmif0 up
atf_check -s exit:0 rump.ifconfig shmif1 up
+ atf_check -s exit:0 rump.ifconfig -w 10
if $DEBUG; then
rump.netstat -nr
@@ -204,9 +195,9 @@ setup_forwarding6()
setup()
{
- atf_check -s exit:0 rump_server $RUMP_LIBS $SOCKSRC
- atf_check -s exit:0 rump_server $RUMP_LIBS $SOCKFWD
- atf_check -s exit:0 rump_server $RUMP_LIBS $SOCKDST
+ rump_server_start $SOCKSRC
+ rump_server_start $SOCKFWD
+ rump_server_start $SOCKDST
setup_endpoint $SOCKSRC $IP4SRC $BUS_SRCGW ipv4 $IP4SRCGW
setup_endpoint $SOCKDST $IP4DST $BUS_DSTGW ipv4 $IP4DSTGW
@@ -216,9 +207,9 @@ setup()
setup6()
{
- atf_check -s exit:0 rump_server $RUMP_LIBS_IPV6 $SOCKSRC
- atf_check -s exit:0 rump_server $RUMP_LIBS_IPV6 $SOCKFWD
- atf_check -s exit:0 rump_server $RUMP_LIBS_IPV6 $SOCKDST
+ rump_server_start $SOCKSRC netinet6
+ rump_server_start $SOCKFWD netinet6
+ rump_server_start $SOCKDST netinet6
setup_endpoint $SOCKSRC $IP6SRC $BUS_SRCGW ipv6 $IP6SRCGW
setup_endpoint $SOCKDST $IP6DST $BUS_DSTGW ipv6 $IP6DSTGW
@@ -380,6 +371,7 @@ route_command_get_body()
setup
setup_forwarding
test_route_get
+ rump_server_destroy_ifaces
}
route_command_get6_body()
@@ -388,36 +380,20 @@ route_command_get6_body()
setup6
setup_forwarding6
test_route_get6
-}
-
-dump()
-{
-
- env RUMP_SERVER=$SOCKSRC rump.netstat -nr
- env RUMP_SERVER=$SOCKFWD rump.netstat -nr
- env RUMP_SERVER=$SOCKDST rump.netstat -nr
-
- shmif_dumpbus -p - bus1 2>/dev/null| tcpdump -n -e -r -
- shmif_dumpbus -p - bus2 2>/dev/null| tcpdump -n -e -r -
-}
-
-cleanup()
-{
-
- env RUMP_SERVER=$SOCKSRC rump.halt
- env RUMP_SERVER=$SOCKFWD rump.halt
- env RUMP_SERVER=$SOCKDST rump.halt
+ rump_server_destroy_ifaces
}
route_command_get_cleanup()
{
+
$DEBUG && dump
cleanup
}
route_command_get6_cleanup()
{
- dump
+
+ $DEBUG && dump
cleanup
}
diff --git a/contrib/netbsd-tests/rump/modautoload/t_modautoload.c b/contrib/netbsd-tests/rump/modautoload/t_modautoload.c
index b73e52a..2c21a90 100644
--- a/contrib/netbsd-tests/rump/modautoload/t_modautoload.c
+++ b/contrib/netbsd-tests/rump/modautoload/t_modautoload.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_modautoload.c,v 1.4 2015/12/27 08:21:44 pgoyette Exp $ */
+/* $NetBSD: t_modautoload.c,v 1.5 2016/09/14 03:19:11 ozaki-r Exp $ */
#include <sys/types.h>
#include <sys/mount.h>
@@ -46,6 +46,7 @@ mountkernfs(void)
atf_tc_fail_errno("mkdir /kern");
new_autoload = true;
+ old_len = sizeof(old_autoload);
new_len = sizeof(new_autoload);
error = sysctlbyname("kern.module.autoload",
&old_autoload, &old_len,
diff --git a/contrib/netbsd-tests/rump/rumpkern/t_lwproc.c b/contrib/netbsd-tests/rump/rumpkern/t_lwproc.c
index d4eee3a..6e78d02 100644
--- a/contrib/netbsd-tests/rump/rumpkern/t_lwproc.c
+++ b/contrib/netbsd-tests/rump/rumpkern/t_lwproc.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_lwproc.c,v 1.7 2015/01/21 15:19:01 pooka Exp $ */
+/* $NetBSD: t_lwproc.c,v 1.8 2017/01/10 22:36:29 christos Exp $ */
/*
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -29,6 +29,7 @@
#include <sys/types.h>
#include <sys/wait.h>
+#include <sys/stat.h>
#include <rump/rump.h>
#include <rump/rump_syscalls.h>
diff --git a/contrib/netbsd-tests/sys/net/t_print.c b/contrib/netbsd-tests/sys/net/t_print.c
index 0aaeb30..ff17895 100644
--- a/contrib/netbsd-tests/sys/net/t_print.c
+++ b/contrib/netbsd-tests/sys/net/t_print.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_print.c,v 1.1 2014/12/02 19:48:21 christos Exp $ */
+/* $NetBSD: t_print.c,v 1.2 2016/08/27 11:30:49 christos Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_print.c,v 1.1 2014/12/02 19:48:21 christos Exp $");
+__RCSID("$NetBSD: t_print.c,v 1.2 2016/08/27 11:30:49 christos Exp $");
#include "net/dl_print.c"
@@ -147,7 +147,10 @@ ATF_TC_BODY(sdl_print, tc)
memcpy(&sdl.sdl_addr, &tst[i].ia, sizeof(sdl.sdl_addr));
sdl.sdl_index = (uint16_t)i;
r = sdl_print(buf, l, &sdl);
- e = snprintf(res, l, "[%s]:%zu", tst[i].str, i);
+ if (i == 3)
+ e = snprintf(res, l, "link#%zu", i);
+ else
+ e = snprintf(res, l, "[%s]:%zu", tst[i].str, i);
ATF_REQUIRE_STREQ(buf, res);
ATF_REQUIRE_EQ(r, e);
}
@@ -157,7 +160,10 @@ ATF_TC_BODY(sdl_print, tc)
memcpy(&sdl.sdl_addr, &tst[i].ia, sizeof(sdl.sdl_addr));
sdl.sdl_index = (uint16_t)i;
r = sdl_print(buf, l, &sdl);
- e = snprintf(res, l, "[%s]:%zu", tst[i].str, i);
+ if (i == 3)
+ e = snprintf(res, l, "link#%zu", i);
+ else
+ e = snprintf(res, l, "[%s]:%zu", tst[i].str, i);
ATF_REQUIRE_STREQ(buf, res);
ATF_REQUIRE_EQ(r, e);
}
diff --git a/contrib/netbsd-tests/usr.bin/config/t_config.sh b/contrib/netbsd-tests/usr.bin/config/t_config.sh
index 8a8079c..55af069 100755
--- a/contrib/netbsd-tests/usr.bin/config/t_config.sh
+++ b/contrib/netbsd-tests/usr.bin/config/t_config.sh
@@ -1,4 +1,4 @@
-# $NetBSD: t_config.sh,v 1.7 2015/10/04 07:59:47 uebayasi Exp $
+# $NetBSD: t_config.sh,v 1.8 2016/08/27 12:08:14 christos Exp $
#
# Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -25,12 +25,32 @@
# POSSIBILITY OF SUCH DAMAGE.
#
+srcdir=..
+merge_backslash()
+{
+ sed '
+: again
+/\\$/ {
+ N
+ s/\\\n//
+ t again
+}
+' "$1"
+}
run_and_check_prep()
{
local name="${1}"; shift
- mkdir compile
- supportdir="$(atf_get_srcdir)/support"
+ mkdir -p compile
+ srcdir="$(atf_get_srcdir)"
+ if [ ! -d "${srcdir}/support" ]; then
+ srcdir="$(dirname "${srcdir}")"
+ if [ ! -d "${srcdir}/support" ]; then
+ atf_fail "bad source directory ${srcdir}"
+ exit 1
+ fi
+ fi
+ supportdir="${srcdir}/support"
local config_str
eval config_str=\$${name}_config_str
@@ -38,7 +58,7 @@ run_and_check_prep()
config="d_${name}"
printf "$config_str" >"${config}"
else
- config="$(atf_get_srcdir)/d_${name}"
+ config="${srcdir}/d_${name}"
fi
}
@@ -121,28 +141,28 @@ test_case deffs_redef fail "Checks that config doesn't allow a deffs to use" \
"the same name as a previous defflag/defparam"
# Selecting an undefined option.
-undefined_opt_config_str='
-include "../d_min"
+undefined_opt_config_str="
+include \"${srcdir}/d_min\"
options UNDEFINED
-'
+"
test_case undefined_opt pass \
"Checks that config allows a selection for an undefined options"
# Negating an undefined option.
-no_undefined_opt_config_str='
-include "../d_min"
+no_undefined_opt_config_str="
+include \"${srcdir}/d_min\"
no options UNDEFINED
-'
+"
no_undefined_opt_stderr='match:UNDEFINED'
test_case no_undefined_opt warn \
"Checks that config allows a negation for an undefined options"
# Attribute selection
test_case select pass "Attribute selection"
-select_config_str='
-include "../d_min"
+select_config_str="
+include \"${srcdir}/d_min\"
select c
-'
+"
check_select()
{
local f=Makefile
@@ -158,11 +178,11 @@ select_body() {
# Attribute negation
test_case no_select pass "Attribute negation"
-no_select_config_str='
-include "../d_min"
+no_select_config_str="
+include \"${srcdir}/d_min\"
select c
no select a
-'
+"
check_no_select()
{
local f=Makefile
@@ -181,10 +201,10 @@ no_select_body() {
# Device instance
test_case devi pass "Device instance"
-devi_config_str='
-include "../d_min"
+devi_config_str="
+include \"${srcdir}/d_min\"
d0 at root
-'
+"
check_devi()
{
local f=ioconf.c
@@ -226,9 +246,7 @@ check_min_makefile()
grep -q '^%' $f >tmp.template
grep -q '^MACHINE=regress$' $f &&
- grep -q '^PARAM=-DMAXUSERS=4$' $f &&
- grep -q '^all: regress$' $f &&
- grep -q '^regress:' $f &&
+ (merge_backslash $f | grep -q '^IDENT=[ ]*-DMAXUSERS="4"') &&
[ ! -s tmp.template ] &&
:
}
diff --git a/contrib/netbsd-tests/usr.bin/netpgpverify/t_netpgpverify.sh b/contrib/netbsd-tests/usr.bin/netpgpverify/t_netpgpverify.sh
index 9c19116..2d532c0 100755
--- a/contrib/netbsd-tests/usr.bin/netpgpverify/t_netpgpverify.sh
+++ b/contrib/netbsd-tests/usr.bin/netpgpverify/t_netpgpverify.sh
@@ -1,6 +1,6 @@
#! /bin/sh
-# $NetBSD: t_netpgpverify.sh,v 1.3 2016/06/01 06:39:11 agc Exp $
+# $NetBSD: t_netpgpverify.sh,v 1.4 2016/08/28 15:59:15 christos Exp $
#
# Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -525,7 +525,7 @@ StZtC+VbuN66pfHwsAIAAw==
EOF
uudecode << EOF
begin-base64 644 NetBSD-6.0_hashes.asc.gz
-H4sICAAAAAACA05ldEJTRC02LjBfaGFzaGVzLmFzYwDUvduOXceVpX3deoq87B8o
+H4sICLYIw1cCA05ldEJTRC02LjBfaGFzaGVzLmFzYwDUvduOXceVpX3deoq87B8o
y3E+NNDA7yqrXQZKsmHZQN8V4igTRYkCSVWV++n7G4tMcu9kZnJlSgW4SYsmM3fG
ihUz5pxjRMzDr37Fr3/86ne//+bmj7/74823v//dN1/99ubrr7799je/+0rf+9UX
/9ze/PV/3Hz7z7+xX/Drz39dN/vVy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dhvZ+toESINV2iZPpZeleVib08dj5n6hUQWd
-33+0Q4OlPJg7P33KVeHhpZjUAEOTjC9kp7j2FqWTSwdXJPeI3y434Umjfz5Xw1lH
-EhLdecvhNVr07rot0U020UDoWmSrwwFc55STjNTjCM3zB70pnHYKgDdrkAWua5Ws
-LayFo49hgqBVjVF5eTtq1jOTRrRgQFilwD8gCIPgYOfqE3zuHK0J+ynWHDLl2c9R
-ZtJ0m0CDHFrbFNx9F/gQFBHQP0966vwhXwqnWL/JImvnfq+2urQfbWj63sb9JLis
-pkQwHTfdy4GF4JSEjIqQkaWgcyn3sRTU6rvHbQOVKtaXqFzOUX4XDK4YXbygFEwg
-ifvt4maQC7R652KmfpNvXDysvX7Z+Ox6tZo88rIniTdHjV5ffR4328sJzzYiW3yD
-217BKis6VWA0DdJOa0ERRYHWHzTZy1HpLxacb80pPZOpWszdCHySpyStu2v/mz8+
-/OiTW1/8484nd/7x9a1Pvrj+zb+++mj/9Wvfzie/arz/849PHj6988k/frfv+/ft
-n+b9X9eu3bt7q394/aMPr/94/ZMP7352d918+Mn1648+++j6D5/1+Pzzrx9++PRx
-uX7nA/sw/fzw3sOH8/aX927cvxm++ua38XWJ1369/7ymm+17+3zkH279872fHvT/
-/PD0yYPHj2/PD8dP0f14/Z83H8Vvf7n+69fti099+MrcauXJi98/u/fs65++un0t
-3fn0zuN79397/uP1Gx9/6//VHzz51/ff/fbre3eex+tf57vPP19P//njV8+emtsf
-ffPvzx8+/Sp/8p9fyr9vxue3Pnlcn1376ZNwZz18/Ov2+Lt75e4HyTz95sHPn/34
-wN376P4Ht7/+bdz843n/+dPt2wfz/m/XP3n+2fPH33777G78/pfrT8ML+8O1L7/9
-/OdHPzz6an48b9775ofrf4xlvn3x+7M/1s+fPr3z+/e315f5h/fu/Oenj9uj6/9a
-T2/dvvVlvrke3L+brocvP/zl2qOPPrptHz68z/1Zuf3dneu/3/K32vfr26c37KPt
-yUf//vmfn74ov3/4/NPb9+6s8vXzf/rv73/Rfn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8wf/+fn8u+b8fntj3+pz679+HG4ux798uv2y7f3y70Pknn69cOfPv3h
+obt/68EHd776bdz843n/6ZPtm4fzwW/XP37+6fNfvvnm2b343c/Xn4YX9vtrX3zz
+2U+Pv3/85fxo3rz/9ffX/xjLfPPi92d/rJ8+eXr39+/urC/y9+/d/c+PH7XH1/+1
+nt6+c/uLfHM9fHAvXQ9ffPjztce3bt2xjx494P6s3Pn27vXfb/vb7bv1zdMb9vH2
+5Na/f/rnJy/K7x8+/+TO/burfPX8n/67B5+37x+/mA+++/Wzm9f+Yz//9tvf/C/x
+0U3/6ON79Yu7f3ypiPC5+f7bh09vvBf79a/uvffVk5+efGDufdp+/fDZD7999/TO
+i7r9/uzzX839G9duf5TN3X/a+3cf3Lz707I37j364vtfPv3xt3+t35W6Xe/6bfnx
+/V/e++3x7Yc/fPHj7Wc3Xnx076MH6+GjP8rPX975+doH//7i+bOP/p3vv7jR4s9P
+zQfun59tN756+tuzm7d+/DLdjvX6oxg+/Ohbc7/Gr/8I9cUq929/9MX12+3FXD9+
+cu36XXvj0zuPXPz9h9/6oz8++LLceTpvP/sgmE8e/7g9efLRk5u/vLiRf/rsl/DA
+3X04f/vpAz9/efrTN0/lc9972q+ZB1/f//zZjU9a/P73p4+/IF15+OT2rVuf3r31
+3Yzxu/7Tg3L/0xeP37t+3z76z40H9sObn3//6EF58Um7/ezu7XvX4h/3fnh+45O7
+5fP5xwfmgf3mvV8/uvZ/H33yXT/ZJLc+v3neFvn/qZKFEe79DQA=
====
EOF
gunzip NetBSD-6.0_hashes.asc.gz
@@ -6958,18 +6958,15 @@ YzFlNiBiZjcxIDg4NDUgNDE2YiA5NTIyIDc5ZGUgYjYxZSA0ODhlIGVlNzQgCgo=
EOF
uudecode << EOF
begin-base64 644 expected18
-R29vZCBzaWduYXR1cmUgZm9yIGdwZ3NpZ25lZC1hLmdwZyBtYWRlIFN1biBTZXAg
-IDkgMTc6NDM6MDEgMjAxMgpzaWduYXR1cmUgIDIwNDgvUlNB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
+dGVyYWwgZGF0YSAodGFnIDExKQo9PT09PT09PT09PT09CmIgYmluYXJ5L3RleHQK
+YiBsZW5ndGgKYyBzdHJpbmcKTCBtdGltZQp0ZXh0ClBST0c9cApTUkNTPXBhcnNl
+LmMKV0FSTlM9NQpNS01BTj1ubwpDUFBGTEFHUys9LWcgLU8wCkxERkxBR1MrPS1n
+IC1PMAoKLmluY2x1ZGUgPGJzZC5wcm9nLm1rPgoKdDogJHtQUk9HfQoJLi8ke1BS
+T0d9IGdwZ3NpZ25lZC1hLmdwZwo=
====
EOF
uudecode << EOF
@@ -7207,13 +7194,12 @@ IG5ldHBncHZlcmlmeQo=
====
EOF
atf_check -s eq:0 -o file:expected16 -e empty env TZ=US/Pacific netpgpverify -k pubring.gpg -c verify b.gpg
- atf_check -s eq:0 -o file:2.expected -e empty b2e < 2.in
- atf_check -s eq:0 -o file:expected18 -e empty env TZ=US/Pacific netpgpverify -c verify a.gpg
- atf_check -s eq:0 -o file:expected19 -e empty env TZ=US/Pacific netpgpverify -c verify NetBSD-6.0_RC2_hashes.asc
+ atf_check -s eq:0 -o file:expected18 -e empty env TZ=US/Pacific netpgpverify -k pubring.gpg -c verify a.gpg
+# atf_check -s eq:0 -o file:expected19 -e empty env TZ=US/Pacific netpgpverify -k pubring.gpg -c verify NetBSD-6.0_RC2_hashes.asc
atf_check -s eq:0 -o file:expected20 -e empty env TZ=US/Pacific netpgpverify -k pubring.gpg -c cat jj.asc
- atf_check -s eq:0 -o file:expected21 -e empty env TZ=US/Pacific netpgpverify < a.gpg
+ atf_check -s eq:0 -o file:expected21 -e empty env TZ=US/Pacific netpgpverify -k pubring.gpg < a.gpg
atf_check -s eq:0 -o file:expected22 -e empty env TZ=US/Pacific netpgpverify -k pubring.gpg < jj.asc
- atf_check -s eq:0 -o file:expected23 -e empty env TZ=US/Pacific netpgpverify < NetBSD-6.0_RC2_hashes.asc
+# atf_check -s eq:0 -o file:expected23 -e empty env TZ=US/Pacific netpgpverify < NetBSD-6.0_RC2_hashes.asc
atf_check -s eq:0 -o file:expected24 -e empty env TZ=US/Pacific netpgpverify -k pubring.gpg < b.gpg
#atf_check -s eq:0 -o file:expected25 -e empty netpgpverify NetBSD-6.0_RC1_hashes.gpg
#atf_check -s eq:0 -o file:expected26 -e empty netpgpverify < NetBSD-6.0_RC1_hashes.gpg
@@ -7225,7 +7211,7 @@ EOF
atf_check -s eq:0 -o file:expected32 -e empty env TZ=US/Pacific netpgpverify -k pubring.gpg b.gpg b.gpg b.gpg
atf_check -s eq:0 -o file:expected33 -e empty env TZ=US/Pacific netpgpverify -k pubring.gpg -c cat b.gpg jj.asc b.gpg
atf_check -s eq:0 -o file:expected34 -e empty env TZ=US/Pacific netpgpverify -k pubring.gpg det.sig
- atf_check -s eq:0 -o file:expected35 -e empty env TZ=US/Pacific netpgpverify -c cat -k pubring.gpg det.sig
+ atf_check -s eq:0 -o file:expected35 -e empty env TZ=US/Pacific netpgpverify -k pubring.gpg -c cat det.sig
#atf_check -s eq:0 -o file:expected46 -e empty netpgpverify -k problem-pubring.gpg NetBSD-6.0_hashes.asc
}
diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_anon_union.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_anon_union.c
new file mode 100644
index 0000000..508bcc9
--- /dev/null
+++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_anon_union.c
@@ -0,0 +1,16 @@
+/* struct with only anonymous members */
+
+struct foo {
+ union {
+ long loo;
+ double doo;
+ };
+};
+
+int
+main(void) {
+
+ struct foo *f = 0;
+ printf("%p\n", &f[1]);
+ return 0;
+}
diff --git a/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_union_cast.c b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_union_cast.c
new file mode 100644
index 0000000..31628b4
--- /dev/null
+++ b/contrib/netbsd-tests/usr.bin/xlint/lint1/d_c99_union_cast.c
@@ -0,0 +1,18 @@
+/* union cast */
+
+struct bar {
+ int a;
+ int b;
+};
+
+union foo {
+ struct bar *a;
+ int b;
+};
+
+void
+foo(void) {
+ struct bar *a;
+
+ ((union foo)a).a;
+}
diff --git a/contrib/openresolv/Makefile b/contrib/openresolv/Makefile
index dbc0673..095779b 100644
--- a/contrib/openresolv/Makefile
+++ b/contrib/openresolv/Makefile
@@ -37,6 +37,11 @@ SED_STATUSARG= -e 's:@STATUSARG@:${STATUSARG}:g'
DISTPREFIX?= ${PKG}-${VERSION}
DISTFILEGZ?= ${DISTPREFIX}.tar.gz
DISTFILE?= ${DISTPREFIX}.tar.xz
+DISTINFO= ${DISTFILE}.distinfo
+DISTINFOSIGN= ${DISTINFO}.asc
+CKSUM?= cksum -a SHA256
+PGP?= netpgp
+
FOSSILID?= current
.SUFFIXES: .in
@@ -53,7 +58,7 @@ clean:
rm -f ${TARGET}
distclean: clean
- rm -f config.mk ${DISTFILE}
+ rm -f config.mk ${DISTFILE} ${DISTINFO} ${DISTINFOSIGN}
installdirs:
@@ -83,3 +88,11 @@ dist:
fossil tarball --name ${DISTPREFIX} ${FOSSILID} ${DISTFILEGZ}
gunzip -c ${DISTFILEGZ} | xz >${DISTFILE}
rm ${DISTFILEGZ}
+
+distinfo: dist
+ rm -f ${DISTINFO} ${DISTINFOSIGN}
+ ${CKSUM} ${DISTFILE} >${DISTINFO}
+ #printf "SIZE (${DISTFILE}) = %s\n" $$(wc -c <${DISTFILE}) >>${DISTINFO}
+ ${PGP} --clearsign --output=${DISTINFOSIGN} ${DISTINFO}
+ chmod 644 ${DISTINFOSIGN}
+ ls -l ${DISTFILE} ${DISTINFO} ${DISTINFOSIGN}
diff --git a/contrib/openresolv/configure b/contrib/openresolv/configure
index b430b20..a890cf0 100644
--- a/contrib/openresolv/configure
+++ b/contrib/openresolv/configure
@@ -120,14 +120,21 @@ echo "Configuring openresolv for ... $OS"
rm -rf $CONFIG_MK
echo "# $OS" >$CONFIG_MK
-# On FreeBSD, /etc/init.d/foo status returns 0 if foo is not enabled
-# regardless of if it's not running.
-# So we force onestatus to work around this silly bug.
-if [ -z "$STATUSARG" ]; then
- case "$OS" in
- freebsd*) STATUSARG="onestatus";;
- esac
-fi
+case "$OS" in
+freebsd*)
+ # On FreeBSD, /etc/init.d/foo status returns 0 if foo is not enabled
+ # regardless of if it's not running.
+ # So we force onestatus to work around this silly bug.
+ if [ -z "$STATUSARG" ]; then
+ STATUSARG="onestatus"
+ fi
+ ;;
+linux*)
+ # cksum does't support -a and netpgp is rare
+ echo "CKSUM= sha256sum --tag" >>$CONFIG_MK
+ echo "PGP= gpg2" >>$CONFIG_MK
+ ;;
+esac
for x in SYSCONFDIR SBINDIR LIBEXECDIR VARDIR MANDIR RESTARTCMD RCDIR STATUSARG
do
diff --git a/contrib/openresolv/libc.in b/contrib/openresolv/libc.in
index 5145e53..3fd6046 100644
--- a/contrib/openresolv/libc.in
+++ b/contrib/openresolv/libc.in
@@ -216,7 +216,7 @@ fi
if $backup; then
if [ "$newconf" = "$signature$NL" ]; then
if [ -e "$resolv_conf.bak" ]; then
- newconf="$(cat "$resolv_conf.bak")"
+ newconf="$(cat "$resolv_conf.bak")$NL"
fi
elif [ -e "$resolv_conf" ]; then
read line <"$resolv_conf"
diff --git a/contrib/openresolv/pdns_recursor.in b/contrib/openresolv/pdns_recursor.in
index 2919e7d..ad2d922 100644
--- a/contrib/openresolv/pdns_recursor.in
+++ b/contrib/openresolv/pdns_recursor.in
@@ -34,7 +34,6 @@ NL="
"
: ${pdns_service:=pdns_recursor}
-: ${pdns_restart:=@RESTARTCMD ${pdns_service}@}
newzones=
@@ -68,5 +67,12 @@ if [ ! -f "$pdns_zones" ] || \
[ "$(cat "$pdns_zones")" != "$(printf %s "$newzones")" ]
then
printf %s "$newzones" >"$pdns_zones"
- eval $pdns_restart
+ if [ -n "$pdns_restart" ]; then
+ eval $pdns_restart
+ elif [ -n "$RESTARTCMD" ]; then
+ set -- ${pdns_service}
+ eval $RESTARTCMD
+ else
+ @SBINDIR@/resolvconf -r ${pdns_service}
+ fi
fi
diff --git a/contrib/openresolv/resolvconf.8.in b/contrib/openresolv/resolvconf.8.in
index 4fa5b4b..fa00582 100644
--- a/contrib/openresolv/resolvconf.8.in
+++ b/contrib/openresolv/resolvconf.8.in
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd May 7, 2016
+.Dd November 29, 2016
.Dt RESOLVCONF 8
.Os
.Sh NAME
@@ -45,6 +45,8 @@
.Fl il Ar pattern
.Nm
.Fl u
+.Nm
+.Fl Fl version
.Sh DESCRIPTION
.Nm
manages
@@ -106,7 +108,7 @@ See
.Xr resolvconf.conf 5
for how to configure
.Nm
-to use a local name server.
+to use a local name server and how to remove the private marking.
.Pp
.Nm
can mark an interfaces
@@ -126,7 +128,7 @@ on the
.Ar interface .
.Pp
Here are some options for the above commands:-
-.Bl -tag -width indent
+.Bl -tag -width pattern_opt
.It Fl f
Ignore non existent interfaces.
Only really useful for deleting interfaces.
@@ -146,7 +148,7 @@ as exclusive when adding, otherwise only use the latest exclusive interface.
.Pp
.Nm
has some more commands for general usage:-
-.Bl -tag -width indent
+.Bl -tag -width pattern_opt
.It Fl i Ar pattern
List the interfaces and protocols, optionally matching
.Ar pattern ,
@@ -168,12 +170,15 @@ to update all its subscribers.
.Nm
does not update the subscribers when adding a resolv.conf that matches
what it already has for that interface.
+.It Fl Fl version
+Echo the resolvconf version to
+.Em stdout .
.El
.Pp
.Nm
also has some commands designed to be used by it's subscribers and
system startup:-
-.Bl -tag -width indent
+.Bl -tag -width pattern_opt
.It Fl I
Initialise the state directory
.Pa @VARDIR@ .
@@ -223,7 +228,7 @@ Here are some suggested protocol tags to use for each
.Pa resolv.conf
file registered on an
.Ar interface Ns No :-
-.Bl -tag -width indent
+.Bl -tag -width pattern_opt
.It dhcp
Dynamic Host Configuration Protocol.
Initial versions of
diff --git a/contrib/openresolv/resolvconf.conf.5.in b/contrib/openresolv/resolvconf.conf.5.in
index 7b410ab..fcebd86 100644
--- a/contrib/openresolv/resolvconf.conf.5.in
+++ b/contrib/openresolv/resolvconf.conf.5.in
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd April 28, 2016
+.Dd December 29, 2016
.Dt RESOLVCONF.CONF 5
.Os
.Sh NAME
@@ -69,6 +69,11 @@ If unset, defaults to the following:-
These interfaces will be processed next, unless they have a metric.
If unset, defaults to the following:-
.D1 tap[0-9]* tun[0-9]* vpn vpn[0-9]* ppp[0-9]* ippp[0-9]*
+.It Sy inclusive_interfaces
+Ignore any exlcusive marking for these interfaces.
+This is handy when 3rd party integrations force the
+.Nm resolvconf -x
+option and you want to disable it easily.
.It Sy local_nameservers
If unset, defaults to the following:-
.D1 127.* 0.0.0.0 255.255.255.255 ::1
@@ -102,6 +107,11 @@ Requires a local nameserver other than libc.
This is equivalent to the
.Nm resolvconf -p
option.
+.It Sy public_interfaces
+Force these interface to be public, overriding the private marking.
+This is handy when 3rd party integrations force the
+.Nm resolvconf -p
+option and you want to disable it easily.
.It Sy replace
Is a space separated list of replacement keywords.
The syntax is this:
diff --git a/contrib/openresolv/resolvconf.in b/contrib/openresolv/resolvconf.in
index 3ac72f3..7353cfc 100644
--- a/contrib/openresolv/resolvconf.in
+++ b/contrib/openresolv/resolvconf.in
@@ -25,13 +25,19 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
RESOLVCONF="$0"
-OPENRESOLV_VERSION="3.8.1"
+OPENRESOLV_VERSION="3.9.0"
SYSCONFDIR=@SYSCONFDIR@
LIBEXECDIR=@LIBEXECDIR@
VARDIR=@VARDIR@
RCDIR=@RCDIR@
RESTARTCMD=@RESTARTCMD@
+if [ "$1" = "--version" ]; then
+ echo "openresolv $OPENRESOLV_VERSION"
+ echo "Copyright (c) 2007-2016 Roy Marples"
+ exit 0
+fi
+
# Disregard dhcpcd setting
unset interface_order state_dir
@@ -90,6 +96,7 @@ usage()
that match the specified pattern
-u Run updates from our current DNS information
+ --version Echo the ${RESOLVCONF##*/} version
Options:
-f Ignore non existent interfaces
@@ -129,6 +136,34 @@ strip_trailing_dots()
printf "\n"
}
+private_iface()
+{
+ local p
+
+ # Allow expansion
+ cd "$IFACEDIR"
+
+ # Public interfaces override private ones.
+ for p in $public_interfaces; do
+ case "$iface" in
+ "$p"|"$p":*) return 1;;
+ esac
+ done
+
+ if [ -e "$PRIVATEDIR/$iface" ]; then
+ return 0
+ fi
+
+ for p in $private_interfaces; do
+ case "$iface" in
+ "$p"|"$p":*) return 0;;
+ esac
+ done
+
+ # Not a private interface
+ return 1
+}
+
# Parse resolv.conf's and make variables
# for domain name servers, search name servers and global nameservers
parse_resolv()
@@ -144,20 +179,10 @@ parse_resolv()
if ${new}; then
iface="${line#\# resolv.conf from *}"
new=false
- if [ -e "$PRIVATEDIR/$iface" ]; then
+ if private_iface "$iface"; then
private=true
else
- # Allow expansion
- cd "$IFACEDIR"
private=false
- for p in $private_interfaces; do
- case "$iface" in
- "$p"|"$p":*)
- private=true
- break
- ;;
- esac
- done
fi
fi
;;
@@ -301,9 +326,9 @@ fi"
/usr/sbin/service \$1 restart;
fi"
elif [ -x /bin/sv ]; then
- RESTARTCMD="/bin/sv try-restart \$1"
+ RESTARTCMD="/bin/sv status \$1 >/dev/null 2>&1 && /bin/sv try-restart \$1"
elif [ -x /usr/bin/sv ]; then
- RESTARTCMD="/usr/bin/sv try-restart \$1"
+ RESTARTCMD="/usr/bin/sv status \$1 >/dev/null 2>&1 && /usr/bin/sv try-restart \$1"
elif [ -e /etc/arch-release -a -d /etc/rc.d ]; then
RCDIR=/etc/rc.d
RESTARTCMD="if [ -e /var/run/daemons/\$1 ]; then
@@ -378,6 +403,14 @@ list_resolv()
done
fi
excl=true
+ cd "$IFACEDIR"
+ for i in $inclusive_interfaces; do
+ if [ -f "$i" -a "$list" = "$i" ]; then
+ list=
+ excl=false
+ break
+ fi
+ done
;;
*)
excl=false
@@ -418,7 +451,6 @@ list_resolv()
cd "$IFACEDIR"
retval=1
- excl=true
for i in $(uniqify $list); do
# Only list interfaces which we really have
if ! [ -f "$i" ]; then
@@ -432,8 +464,7 @@ list_resolv()
if [ "$cmd" = i -o "$cmd" = "-i" ]; then
printf %s "$i "
else
- echo_resolv "$i"
- echo
+ echo_resolv "$i" && echo
fi
[ $? = 0 -a "$retval" = 1 ] && retval=0
done
diff --git a/contrib/tcpdump/.cvsignore b/contrib/tcpdump/.cvsignore
deleted file mode 100644
index 791f14c..0000000
--- a/contrib/tcpdump/.cvsignore
+++ /dev/null
@@ -1,12 +0,0 @@
-version.c
-Makefile
-Makefile-devel.in
-config.status
-config.log
-config.cache
-config.h
-.devel
-stamp-h
-stamp-h.in
-tcpdump
-autom4te.cache
diff --git a/contrib/tcpdump/CHANGES b/contrib/tcpdump/CHANGES
index 38769f2..7c4be17 100644
--- a/contrib/tcpdump/CHANGES
+++ b/contrib/tcpdump/CHANGES
@@ -1,3 +1,187 @@
+Wednesday January 18, 2017 devel.fx.lebail@orange.fr
+ Summary for 4.9.0 tcpdump release
+ General updates:
+ Improve separation frontend/backend (tcpdump/libnetdissect)
+ Don't require IPv6 library support in order to support IPv6 addresses
+ Introduce data types to use for integral values in packet structures
+ Fix display of timestamps with -tt, -ttt and -ttttt options
+ Fix some heap overflows found with American Fuzzy Lop by Hanno Boeck and others
+ (More information in the log with CVE-2016-* and CVE-2017-*)
+ Change the way protocols print link-layer addresses (Fix heap overflows
+ in CALM-FAST and GeoNetworking printers)
+ Pass correct caplen value to ether_print() and some other functions
+ Fix lookup_nsap() to match what isonsap_string() expects
+ Clean up relative time stamp printing (Fix an array overflow)
+ Fix some alignment issues with GCC on Solaris 10 SPARC
+ Add some ND_TTEST_/ND_TCHECK_ macros to simplify writing bounds checks
+ Add a fn_printztn() which returns the number of bytes processed
+ Add nd_init() and nd_cleanup() functions. Improve libsmi support
+ Add CONTRIBUTING file
+ Add a summary comment in all printers
+ Compile with more warning options in devel mode if supported (-Wcast-qual, ...)
+ Fix some leaks found by Valgrind/Memcheck
+ Fix a bunch of de-constifications
+ Squelch some Coverity warnings and some compiler warnings
+ Update Coverity and Travis-CI setup
+ Update Visual Studio files
+
+ Frontend:
+ Fix capsicum support to work with zerocopy buffers in bpf
+ Try opening interfaces by name first, then by name-as-index
+ Work around pcap_create() failures fetching time stamp type lists
+ Fix a segmentation fault with 'tcpdump -J'
+ Improve addrtostr6() bounds checking
+ Add exit_tcpdump() function
+ Don't drop CAP_SYS_CHROOT before chrooting
+ Fixes issue where statistics not reported when -G and -W options used
+
+ New printers supporting:
+ Generic Protocol Extension for VXLAN (VXLAN-GPE)
+ Home Networking Control Protocol (HNCP), RFCs 7787 and 7788
+ Locator/Identifier Separation Protocol (LISP), type 3 and type 4 packets
+ Marvell Extended Distributed Switch Architecture header (MEDSA)
+ Network Service Header (NSH)
+ REdis Serialization Protocol (RESP)
+
+ Updated printers:
+ 802.11: Beginnings of 11ac radiotap support
+ 802.11: Check the Protected bit for management frames
+ 802.11: Do bounds checking on last_presentp before dereferencing it (Fix a heap overflow)
+ 802.11: Fix the radiotap printer to handle the special bits correctly
+ 802.11: If we have the MCS field, it's 11n
+ 802.11: Only print unknown frame type or subtype messages once
+ 802.11: Radiotap dBm values get printed as dB; Update a test output accordingly
+ 802.11: Source and destination addresses were backwards
+ AH: Add a bounds check
+ AH: Report to our caller that dissection failed if a bounds check fails
+ AP1394: Print src > dst, not dst > src
+ ARP: Don't assume the target hardware address is <= 6 octets long (Fix a heap overflow)
+ ATALK: Add bounds and length checks (Fix heap overflows)
+ ATM: Add some bounds checks (Fix a heap overflow)
+ ATM: Fix an incorrect bounds check
+ BFD: Update specification from draft to RFC 5880
+ BFD: Update to print optional authentication field
+ BGP: Add decoding of ADD-PATH capability
+ BGP: Add support for the AIGP attribute (RFC7311)
+ BGP: Print LARGE_COMMUNITY Path Attribute
+ BGP: Update BGP numbers from IANA; Print minor values for FSM notification
+ BOOTP: Add a bounds check
+ Babel: Add decoder for source-specific extension
+ CDP: Filter out non-printable characters
+ CFM: Fixes to match the IEEE standard, additional bounds and length checks
+ CSLIP: Add more bounds checks (Fix a heap overflow)
+ ClassicalIPoATM: Add a bounds check on LLC+SNAP header (Fix a heap overflow)
+ DHCP: Fix MUDURL and TZ options
+ DHCPv6: Process MUDURL and TZ options
+ DHCPv6: Update Status Codes with RFCs/IANA names
+ DNS: Represent the "DNSSEC OK" bit as "DO" instead of "OK". Add a test case
+ DTP: Improve packet integrity checks
+ EGP: Fix bounds checks
+ ESP: Don't use OpenSSL_add_all_algorithms() in OpenSSL 1.1.0 or later
+ ESP: Handle OpenSSL 1.1.x
+ Ethernet: Add some bounds checking before calling isoclns_print (Fix a heap overflow)
+ Ethernet: Print the Length/Type field as length when needed
+ FDDI: Fix -e output for FDDI
+ FR: Add some packet-length checks and improve Q.933 printing (Fix heap overflows)
+ GRE: Add some bounds checks (Fix heap overflows)
+ Geneve: Fix error message with invalid option length; Update list option classes
+ HNCP: Fix incorrect time interval format. Fix handling of IPv4 prefixes
+ ICMP6: Fetch a 32-bit big-endian quantity with EXTRACT_32BITS()
+ ICMP6: dagid is always an IPv6 address, not an opaque 128-bit string
+ IGMP: Add a length check
+ IP: Add a bounds check (Fix a heap overflow)
+ IP: Check before fetching the protocol version (Fix a heap overflow)
+ IP: Don't try to dissect if IP version != 4 (Fix a heap overflow)
+ IP: Stop processing IPPROTO_ values once we hit IPPROTO_IPCOMP
+ IPComp: Check whether we have the CPI before we fetch it (Fix a heap overflow)
+ IPoFC: Fix -e output (IP-over-Fibre Channel)
+ IPv6: Don't overwrite the destination IPv6 address for routing headers
+ IPv6: Fix header printing
+ IPv6: Stop processing IPPROTO_ values once we hit IPPROTO_IPCOMP
+ ISAKMP: Clean up parsing of IKEv2 Security Associations
+ ISOCLNS/IS-IS: Add support for Purge Originator Identifier (RFC6232) and test cases
+ ISOCLNS/IS-IS: Don't overwrite packet data when checking the signature
+ ISOCLNS/IS-IS: Filter out non-printable characters
+ ISOCLNS/IS-IS: Fix segmentation faults
+ ISOCLNS/IS-IS: Have signature_verify() do the copying and clearing
+ ISOCLNS: Add some bounds checks
+ Juniper: Make sure a Juniper header TLV isn't bigger than what's left in the packet (Fix a heap overflow)
+ LLC/SNAP: With -e, print the LLC header before the SNAP header; without it, cut the SNAP header
+ LLC: Add a bounds check (Fix a heap overflow)
+ LLC: Clean up printing of LLC packets
+ LLC: Fix the printing of RFC 948-style IP packets
+ LLC: Skip the LLC and SNAP headers with -x for 802.11 and some other protocols
+ LLDP: Implement IANA OUI and LLDP MUD option
+ MPLS LSP ping: Update printing for RFC 4379, bug fixes, more bounds checks
+ MPLS: "length" is now the *remaining* packet length
+ MPLS: Add bounds and length checks (Fix a heap overflow)
+ NFS: Add a test that makes unaligned accesses
+ NFS: Don't assume the ONC RPC header is nicely aligned
+ NFS: Don't overflow the Opaque_Handle buffer (Fix a segmentation fault)
+ NFS: Don't run past the end of an NFSv3 file handle
+ OLSR: Add a test to cover a HNA sgw case
+ OLSR: Fix 'Advertised networks' count
+ OLSR: Fix printing of smart-gateway HNAs in IPv4
+ OSPF: Add a bounds check for the Hello packet options
+ OSPF: Do more bounds checking
+ OSPF: Fix a segmentation fault
+ OSPF: Fix printing 'ospf_topology_values' default
+ OTV: Add missing bounds checks
+ PGM: Print the formatted IP address, not the raw binary address, as a string
+ PIM: Add some bounds checking (Fix a heap overflow)
+ PIMv2: Fix checksumming of Register messages
+ PPI: Pass an adjusted struct pcap_pkthdr to the sub-printer
+ PPP: Add some bounds checks (Fix a heap overflow)
+ PPP: Report invalid PAP AACK/ANAK packets
+ Q.933: Add a missing bounds check
+ RADIUS: Add Value 13 "VLAN" to Tunnel-Type attribute
+ RADIUS: Filter out non-printable characters
+ RADIUS: Translate UDP/1700 as RADIUS
+ RESP: Do better checking of RESP packets
+ RPKI-RTR: Add a return value check for "fn_printn" call
+ RPKI-RTR: Remove printing when truncated condition already detected
+ RPL: Fix 'Consistency Check' control code
+ RPL: Fix suboption print
+ RSVP: An INTEGRITY object in a submessage covers only the submessage
+ RSVP: Fix an infinite loop; Add bounds and length checks
+ RSVP: Fix some if statements missing brackets
+ RSVP: Have signature_verify() do the copying and clearing
+ RTCP: Add some bounds checks
+ RTP: Add some bounds checks, fix two segmentation faults
+ SCTP: Do more bounds checking
+ SFLOW: Fix bounds checking
+ SLOW: Fix bugs, add checks
+ SMB: Before fetching the flags2 field, make sure we have it
+ SMB: Do bounds checks on NBNS resource types and resource data lengths
+ SNMP: Clean up the "have libsmi but no modules loaded" case
+ SNMP: Clean up the object abbreviation list and fix the code to match them
+ SNMP: Do bounds checks when printing character and octet strings
+ SNMP: Improve ASN.1 bounds checks
+ SNMP: More bounds and length checks
+ STP: Add a bunch of bounds checks, and fix some printing (Fix heap overflows)
+ STP: Filter out non-printable characters
+ TCP: Add bounds and length checks for packets with TCP option 20
+ TCP: Correct TCP option Kind value for TCP Auth and add SCPS-TP
+ TCP: Fix two bounds checks (Fix heap overflows)
+ TCP: Make sure we have the data offset field before fetching it (Fix a heap overflow)
+ TCP: Put TCP-AO option decoding right
+ TFTP: Don't use strchr() to scan packet data (Fix a heap overflow)
+ Telnet: Add some bounds checks
+ TokenRing: Fix -e output
+ UDLD: Fix an infinite loop
+ UDP: Add a bounds check (Fix a heap overflow)
+ UDP: Check against the packet length first
+ UDP: Don't do the DDP-over-UDP heuristic check up front
+ VAT: Add some bounds checks
+ VTP: Add a test on Mgmt Domain Name length
+ VTP: Add bounds checks and filter out non-printable characters
+ VXLAN: Add a bound check and a test case
+ ZeroMQ: Fix an infinite loop
+
+Tuesday April 14, 2015 guy@alum.mit.edu
+ Summary for 4.8.0 tcpdump release
+ Fix "-x" for Apple PKTAP and PPI packets
+
Friday April 10, 2015 guy@alum.mit.edu
Summary for 4.7.4 tcpdump release
RPKI to Router Protocol: Fix Segmentation Faults and other problems
@@ -464,10 +648,10 @@ Wed. November 12, 2003. mcr@sandelman.ottawa.on.ca. Summary for 3.8 release
Tuesday, February 25, 2003. fenner@research.att.com. 3.7.2 release
- Fixed infinite loop when parsing malformed isakmp packets.
+ Fixed infinite loop when parsing invalid isakmp packets.
(reported by iDefense; already fixed in CVS)
- Fixed infinite loop when parsing malformed BGP packets.
- Fixed buffer overflow with certain malformed NFS packets.
+ Fixed infinite loop when parsing invalid BGP packets.
+ Fixed buffer overflow with certain invalid NFS packets.
Pretty-print unprintable network names in 802.11 printer.
Handle truncated nbp (appletalk) packets.
Updated DHCPv6 printer to match draft-ietf-dhc-dhcpv6-22.txt
diff --git a/contrib/tcpdump/CONTRIBUTING b/contrib/tcpdump/CONTRIBUTING
new file mode 100644
index 0000000..5d3b46e
--- /dev/null
+++ b/contrib/tcpdump/CONTRIBUTING
@@ -0,0 +1,103 @@
+Some Information for Contributors
+---------------------------------
+You want to contribute to Tcpdump, Thanks!
+Please, read these lines.
+
+1) Fork the Tcpdump repository on GitHub from
+ https://github.com/the-tcpdump-group/tcpdump
+ (See https://help.github.com/articles/fork-a-repo/)
+
+2) Setup an optional Travis-CI build
+ You can setup a travis build for your fork. So, you can test your changes
+ on Linux and OSX before sending pull requests.
+ (See http://docs.travis-ci.com/user/getting-started/)
+
+3) Clone your repository
+ git clone https://github.com/<username>/tcpdump.git
+
+4) Do a 'touch .devel' in your working directory.
+ Currently, the effect is
+ a) add (via configure, in Makefile) some warnings options ( -Wall
+ -Wmissing-prototypes -Wstrict-prototypes, ...) to the compiler if it
+ supports these options,
+ b) have the Makefile support "make depend" and the configure script run it.
+
+5) Configure and build
+ ./configure && make -s && make check
+
+6) Add/update sample.pcap files
+ We use tests directory to do regression tests on the dissection of captured
+ packets, by running tcpdump against a savefile sample.pcap, created with -w
+ option and comparing the results with a text file sample.out giving the
+ expected results.
+
+ Any new/updated fields in a dissector must be present in a sample.pcap file
+ and the corresponding output file.
+
+ Configuration is set in tests/TESTLIST.
+ Each line in this file has the following format:
+ test-name sample.pcap sample.out tcpdump-options
+
+ the sample.out file can be build by:
+ (cd tests && ../tcpdump -n -r sample.pcap tcpdump-options > sample.out)
+
+ It is often useful to have test outputs with different verbosity levels
+ (none, -v, -vv, -vvv, etc.) depending on the code.
+
+7) Test with 'make check'
+ Don't send a pull request if 'make check' gives failed tests.
+
+8) Rebase your commits against upstream/master
+ (To keep linearity)
+
+9) Initiate and send a pull request
+ (See https://help.github.com/articles/using-pull-requests/)
+
+Some remarks
+------------
+a) A thorough reading of some other printers code is useful.
+
+b) Put the normative reference if any as comments (RFC, etc.).
+
+c) Put the format of packets/headers/options as comments.
+
+d) The printer may receive incomplete packet in the buffer, truncated at any
+ random position, for example by capturing with '-s size' option.
+ Thus use ND_TTEST, ND_TTEST2, ND_TCHECK or ND_TCHECK2 for bound checking.
+ For ND_TCHECK2:
+ Define : static const char tstr[] = " [|protocol]";
+ Define a label: trunc
+ Print with: ND_PRINT((ndo, "%s", tstr));
+ You can test the code via:
+ sudo ./tcpdump -s snaplen [-v][v][...] -i lo # in a terminal
+ sudo tcpreplay -i lo sample.pcap # in another terminal
+ You should try several values for snaplen to do various truncation.
+
+e) Do invalid packet checks in code: Think that your code can receive in input
+ not only a valid packet but any arbitrary random sequence of octets (packet
+ - built malformed originally by the sender or by a fuzz tester,
+ - became corrupted in transit).
+ Print with: ND_PRINT((ndo, "%s", istr)); /* to print " (invalid)" */
+
+f) Use 'struct tok' for indexed strings and print them with
+ tok2str() or bittok2str() (for flags).
+
+g) Avoid empty lines in output of printers.
+
+h) A commit message must have:
+ First line: Capitalized short summary in the imperative (70 chars or less)
+
+ Body: Detailed explanatory text, if necessary. Fold it to approximately
+ 72 characters. There must be an empty line separating the summary from
+ the body.
+
+i) Avoid non-ASCII characters in code and commit messages.
+
+j) Use the style of the modified sources.
+
+k) Don't mix declarations and code
+
+l) Don't use // for comments
+ Not all C compilers accept C++/C99 comments by default.
+
+m) Avoid trailing tabs/spaces
diff --git a/contrib/tcpdump/CREDITS b/contrib/tcpdump/CREDITS
index a21311a..5242967 100644
--- a/contrib/tcpdump/CREDITS
+++ b/contrib/tcpdump/CREDITS
@@ -20,11 +20,13 @@ Additional people who have contributed patches:
Andrea Bittau <a dot bittau at cs dot ucl dot ac dot uk>
Andrew Brown <atatat at atatdot dot net>
Andrew Church <andrew at users dot sourceforge dot net>
+ Andrew Darqui <andrew dot darqui at gmail dot com>
Andrew Hintz <adhintz at users dot sourceforge dot net>
Andrew Nording <andrew at nording dot ru>
Andrew Tridgell <tridge at linuxcare dot com>
Andy Heffernan <ahh at juniper dot net>
Anton Bernal <anton at juniper dot net>
+ Antonin Décimo <antonin dot decimo at gmail dot com>
Arkadiusz Miskiewicz <misiek at pld dot org dot pl>
Armando L. Caro Jr. <acaro at mail dot eecis dot udel dot edu>
Arnaldo Carvalho de Melo <acme at ghostprotocols dot net>
@@ -33,6 +35,7 @@ Additional people who have contributed patches:
Ben Byer <bushing at sourceforge dot net>
Ben Smithurst <ben at scientia dot demon dot co dot uk>
Bert Vermeulen <bert at biot dot com>
+ Bill Parker <wp02855 at gmail dot com>
Bjoern A. Zeeb <bzeeb at Zabbadoz dot NeT>
Bram <tcpdump at mail dot wizbit dot be>
Brent L. Bates <blbates at vigyan dot com>
@@ -95,6 +98,7 @@ Additional people who have contributed patches:
Jason R. Thorpe <thorpej at netbsd dot org>
Jefferson Ogata <jogata at nodc dot noaa dot gov>
Jeffrey Hutzelman <jhutz at cmu dot edu>
+ Jean-Raphaël Gaglione <jr dot gaglione at yahoo dot fr>
Jesper Peterson <jesper at endace dot com>
Jesse Gross <jesse at nicira dot com>
Jim Hutchins <jim at ca dot sandia dot gov>
@@ -119,7 +123,7 @@ Additional people who have contributed patches:
Larry Lile <lile at stdio dot com>
Lennert Buytenhek <buytenh at gnu dot org>
Loganaden Velvindron <logan at elandsys dot com>
- Longinus00 <Longinus00 at gmail dot com>
+ Daniel Lee <Longinus00 at gmail dot com>
Loris Degioanni <loris at netgroup-serv dot polito dot it>
Love Hörnquist-Åstrand <lha at stacken dot kth dot se>
Lucas C. Villa Real <lucasvr at us dot ibm dot com>
@@ -134,6 +138,7 @@ Additional people who have contributed patches:
Markus Schöpflin <schoepflin at sourceforge dot net>
Marshall Rose <mrose at dbc dot mtview dot ca dot us>
Martin Husemann <martin at netbsd dot org>
+ Matthieu Boutier <boutier at pps dot univ-paris-diderot dot fr>
Max Laier <max at love2party dot net>
Michael A. Meffie III <meffie at sourceforge dot net>
Michael Madore <mmadore at turbolinux dot com>
diff --git a/contrib/tcpdump/INSTALL.txt b/contrib/tcpdump/INSTALL.txt
index dcb52b8..f91d004 100644
--- a/contrib/tcpdump/INSTALL.txt
+++ b/contrib/tcpdump/INSTALL.txt
@@ -49,9 +49,10 @@ addrtoname.c - address to hostname routines
addrtoname.h - address to hostname definitions
ah.h - IPSEC Authentication Header definitions
appletalk.h - AppleTalk definitions
+ascii_strcasecmp.c - locale-independent case-independent string comparison
+ routines
atime.awk - TCP ack awk script
atm.h - ATM traffic type definitions
-atmuni31.h - ATM Q.2931 definitions
bpf_dump.c - BPF program printing routines, in case libpcap doesn't
have them
chdlc.h - Cisco HDLC definitions
@@ -100,100 +101,8 @@ pcap_dump_ftell.c - pcap_dump_ftell() implementation, in case libpcap
doesn't have it
pcap-missing.h - declarations of functions possibly missing from libpcap
ppp.h - Point to Point Protocol definitions
-print-802_11.c - IEEE 802.11 printer routines
-print-ap1394.c - Apple IP-over-IEEE 1394 printer routines
-print-ah.c - IPSEC Authentication Header printer routines
-print-aodv.c - AODV printer routines
-print-arcnet.c - ARCNET printer routines
-print-arp.c - Address Resolution Protocol printer routines
-print-ascii.c - ASCII packet dump routines
-print-atalk.c - AppleTalk printer routines
-print-atm.c - ATM printer routines
-print-beep.c - BEEP printer routines
-print-bgp.c - Border Gateway Protocol printer routines
-print-bootp.c - BOOTP and IPv4 DHCP printer routines
-print-bt.c - Bluetooth printer routines
-print-cdp.c - Cisco Discovery Protocol printer routines
-print-chdlc.c - Cisco HDLC printer routines
-print-cip.c - Classical-IP over ATM routines
-print-cnfp.c - Cisco NetFlow printer routines
-print-dccp.c - DCCP printer routines
-print-decnet.c - DECnet printer routines
-print-dhcp6.c - IPv6 DHCP printer routines
-print-domain.c - Domain Name System printer routines
-print-dvmrp.c - Distance Vector Multicast Routing Protocol printer routines
-print-eap.c - EAP printer routines
-print-enc.c - OpenBSD IPsec encapsulation BPF layer printer routines
-print-egp.c - External Gateway Protocol printer routines
-print-esp.c - IPSEC Encapsulating Security Payload printer routines
-print-ether.c - Ethernet printer routines
-print-fddi.c - Fiber Distributed Data Interface printer routines
-print-fr.c - Frame Relay printer routines
-print-frag6.c - IPv6 fragmentation header printer routines
-print-gre.c - Generic Routing Encapsulation printer routines
-print-hsrp.c - Cisco Hot Standby Router Protocol printer routines
-print-icmp.c - Internet Control Message Protocol printer routines
-print-icmp6.c - IPv6 Internet Control Message Protocol printer routines
-print-igmp.c - Internet Group Management Protocol printer routines
-print-igrp.c - Interior Gateway Routing Protocol printer routines
-print-ip.c - IP printer routines
-print-ip6.c - IPv6 printer routines
-print-ip6opts.c - IPv6 header option printer routines
-print-ipcomp.c - IP Payload Compression Protocol printer routines
-print-ipx.c - IPX printer routines
-print-isakmp.c - Internet Security Association and Key Management Protocol
-print-isoclns.c - ISO CLNS, ESIS, and ISIS printer routines
-print-krb.c - Kerberos printer routines
-print-l2tp.c - Layer Two Tunneling Protocol printer routines
-print-lane.c - ATM LANE printer routines
-print-llc.c - IEEE 802.2 LLC printer routines
-print-lspping.c - LSPPING printer routines
-print-lwres.c - Lightweight Resolver protocol printer routines
-print-mobile.c - IPv4 mobility printer routines
-print-mobility.c - IPv6 mobility printer routines
-print-mpls.c - Multi-Protocol Label Switching printer routines
-print-msdp.c - Multicast Source Discovery Protocol printer routines
-print-nfs.c - Network File System printer routines
-print-ntp.c - Network Time Protocol printer routines
-print-null.c - BSD loopback device printer routines
-print-ospf.c - Open Shortest Path First printer routines
-print-ospf6.c - IPv6 Open Shortest Path First printer routines
-print-pflog.c - OpenBSD packet filter log file printer routines
-print-pgm.c - Pragmatic General Multicast printer routines
-print-pim.c - Protocol Independent Multicast printer routines
-print-ppp.c - Point to Point Protocol printer routines
-print-pppoe.c - PPP-over-Ethernet printer routines
-print-pptp.c - Point-to-Point Tunnelling Protocol printer routines
-print-radius.c - Radius protocol printer routines
-print-raw.c - Raw IP printer routines
-print-rip.c - Routing Information Protocol printer routines
-print-ripng.c - IPv6 Routing Information Protocol printer routines
-print-rrcp.c - Realtek Remote Control Protocol routines
-print-rsvp.c - Resource reSerVation Protocol (RSVP) printer routines
-print-rt6.c - IPv6 routing header printer routines
-print-rx.c - AFS RX printer routines
-print-sctp.c - Stream Control Transmission Protocol printer routines
-print-sip.c - SIP printer routines
-print-sl.c - Compressed Serial Line Internet Protocol printer routines
-print-sll.c - Linux "cooked" capture printer routines
-print-slow.c - IEEE "slow protocol" (802.3ad) printer routines
-print-smb.c - SMB/CIFS printer routines
-print-snmp.c - Simple Network Management Protocol printer routines
-print-stp.c - IEEE 802.1d spanning tree protocol printer routines
-print-sunatm.c - SunATM DLPI capture printer routines
-print-sunrpc.c - Sun Remote Procedure Call printer routines
-print-symantec.c - Symantec Enterprise Firewall printer routines
-print-tcp.c - TCP printer routines
-print-telnet.c - Telnet option printer routines
-print-tftp.c - Trivial File Transfer Protocol printer routines
-print-timed.c - BSD time daemon protocol printer routines
-print-token.c - Token Ring printer routines
-print-udp.c - UDP printer routines
-print-usb.c - USB printer routines
-print-vjc.c - PPP Van Jacobson compression (RFC1144) printer routines
-print-vrrp.c - Virtual Router Redundancy Protocol
-print-wb.c - White Board printer routines
-print-zephyr.c - Zephyr printer routines
+print.c - Top-level routines for protocol printing
+print-*.c - The netdissect printers
rpc_auth.h - definitions for ONC RPC authentication
rpc_msg.h - definitions for ONC RPC messages
send-ack.awk - unidirectional tcp send/ack awk script
@@ -203,11 +112,11 @@ slcompress.h - SLIP/PPP Van Jacobson compression (RFC1144) definitions
smb.h - SMB/CIFS definitions
smbutil.c - SMB/CIFS utility routines
stime.awk - TCP send awk script
-strcasecmp.c - missing routine
tcp.h - TCP definitions
tcpdump.1 - manual entry
tcpdump.c - main program
+timeval-operations.h - timeval operations macros
udp.h - UDP definitions
-util.c - utility routines
+util-print.c - utility routines for protocol printers
vfprintf.c - emulation routine
win32 - headers and routines for building on Win32 systems
diff --git a/contrib/tcpdump/Makefile.in b/contrib/tcpdump/Makefile.in
index 1004a5d..c18d5ed 100644
--- a/contrib/tcpdump/Makefile.in
+++ b/contrib/tcpdump/Makefile.in
@@ -74,7 +74,9 @@ CSRC = setsignal.c tcpdump.c
LIBNETDISSECT_SRC=\
addrtoname.c \
+ addrtostr.c \
af.c \
+ ascii_strcasecmp.c \
checksum.c \
cpack.c \
gmpls.c \
@@ -86,6 +88,7 @@ LIBNETDISSECT_SRC=\
nlpid.c \
oui.c \
parsenfsfh.c \
+ print.c \
print-802_11.c \
print-802_15_4.c \
print-ah.c \
@@ -98,6 +101,7 @@ LIBNETDISSECT_SRC=\
print-ascii.c \
print-atalk.c \
print-atm.c \
+ print-babel.c \
print-beep.c \
print-bfd.c \
print-bgp.c \
@@ -112,6 +116,7 @@ LIBNETDISSECT_SRC=\
print-cnfp.c \
print-dccp.c \
print-decnet.c \
+ print-dhcp6.c \
print-domain.c \
print-dtp.c \
print-dvmrp.c \
@@ -124,17 +129,21 @@ LIBNETDISSECT_SRC=\
print-fddi.c \
print-forces.c \
print-fr.c \
+ print-frag6.c \
print-ftp.c \
print-geneve.c \
print-geonet.c \
print-gre.c \
+ print-hncp.c \
print-hsrp.c \
print-http.c \
print-icmp.c \
+ print-icmp6.c \
print-igmp.c \
print-igrp.c \
print-ip.c \
print-ip6.c \
+ print-ip6opts.c \
print-ipcomp.c \
print-ipfc.c \
print-ipnet.c \
@@ -146,6 +155,7 @@ LIBNETDISSECT_SRC=\
print-l2tp.c \
print-lane.c \
print-ldp.c \
+ print-lisp.c \
print-llc.c \
print-lldp.c \
print-lmp.c \
@@ -154,7 +164,9 @@ LIBNETDISSECT_SRC=\
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 \
@@ -162,12 +174,14 @@ LIBNETDISSECT_SRC=\
print-msnlb.c \
print-nflog.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-ospf.c \
+ print-ospf6.c \
print-otv.c \
print-pgm.c \
print-pim.c \
@@ -178,10 +192,13 @@ LIBNETDISSECT_SRC=\
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 \
@@ -211,11 +228,14 @@ LIBNETDISSECT_SRC=\
print-vrrp.c \
print-vtp.c \
print-vxlan.c \
+ print-vxlan-gpe.c \
print-wb.c \
print-zephyr.c \
print-zeromq.c \
+ netdissect.c \
signature.c \
- util.c
+ strtoaddr.c \
+ util-print.c
LOCALSRC = @LOCALSRC@
GENSRC = version.c
@@ -232,11 +252,12 @@ SRC = $(CSRC) $(GENSRC) $(LOCALSRC) $(LIBNETDISSECT_SRC)
OBJ = $(CSRC:.c=.o) $(GENSRC:.c=.o) $(LIBNETDISSECT_OBJ)
HDR = \
addrtoname.h \
+ addrtostr.h \
af.h \
ah.h \
appletalk.h \
+ ascii_strcasecmp.h \
atm.h \
- atmuni31.h \
chdlc.h \
cpack.h \
ether.h \
@@ -264,6 +285,7 @@ HDR = \
oui.h \
pcap-missing.h \
ppp.h \
+ print.h \
rpc_auth.h \
rpc_msg.h \
rpl.h \
@@ -271,14 +293,15 @@ HDR = \
signature.h \
slcompress.h \
smb.h \
+ strtoaddr.h \
tcp.h \
- tcpdump-stdinc.h \
+ netdissect-stdinc.h \
+ timeval-operations.h \
udp.h
TAGHDR = \
/usr/include/arpa/tftp.h \
/usr/include/net/if_arp.h \
- /usr/include/net/slip.h \
/usr/include/netinet/if_ether.h \
/usr/include/netinet/in.h \
/usr/include/netinet/ip_icmp.h \
@@ -292,11 +315,14 @@ CLEANFILES = $(PROG) $(OBJ) $(GENSRC)
EXTRA_DIST = \
CHANGES \
+ CONTRIBUTING \
CREDITS \
INSTALL.txt \
LICENSE \
Makefile.in \
Makefile-devel-adds \
+ PLATFORMS \
+ README \
README.md \
Readme.Win32 \
VERSION \
@@ -314,14 +340,9 @@ EXTRA_DIST = \
lbl/os-sunos4.h \
lbl/os-ultrix4.h \
makemib \
- missing/addrinfo.h \
missing/dlnames.c \
missing/datalinks.c \
- missing/getnameinfo.c \
missing/getopt_long.c \
- missing/inet_aton.c \
- missing/inet_ntop.c \
- missing/inet_pton.c \
missing/snprintf.c \
missing/strdup.c \
missing/strlcat.c \
@@ -330,27 +351,19 @@ EXTRA_DIST = \
mkdep \
packetdat.awk \
pcap_dump_ftell.c \
- print-babel.c \
- print-dhcp6.c \
- print-frag6.c \
- print-icmp6.c \
- print-ip6opts.c \
- print-mobility.c \
- print-ospf6.c \
print-pflog.c \
- print-ripng.c \
- print-rt6.c \
print-smb.c \
send-ack.awk \
smbutil.c \
stime.awk \
- strcasecmp.c \
tcpdump.1.in \
vfprintf.c \
- win32/Include/w32_fzs.h \
win32/prj/GNUmakefile \
win32/prj/WinDump.dsp \
- win32/prj/WinDump.dsw
+ win32/prj/WinDump.dsw \
+ win32/prj/WinDump.sln \
+ win32/prj/WinDump.vcproj \
+ win32/src/ether_ntohost.c
TEST_DIST= `find tests \( -name 'DIFF' -prune \) -o \( -name NEW -prune \) -o -type f \! -name '.*' \! -name '*~' -print`
@@ -362,23 +375,15 @@ $(PROG): $(OBJ) @V_PCAPDEP@
$(LIBNETDISSECT): $(LIBNETDISSECT_OBJ)
@rm -f $@
- $(AR) $(ARFLAGS) $@ $(LIBNETDISSECT_OBJ)
+ $(AR) cr $@ $(LIBNETDISSECT_OBJ)
$(RANLIB) $@
datalinks.o: $(srcdir)/missing/datalinks.c
$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/datalinks.c
dlnames.o: $(srcdir)/missing/dlnames.c
$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/dlnames.c
-getnameinfo.o: $(srcdir)/missing/getnameinfo.c
- $(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/getnameinfo.c
getopt_long.o: $(srcdir)/missing/getopt_long.c
$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/getopt_long.c
-inet_pton.o: $(srcdir)/missing/inet_pton.c
- $(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/inet_pton.c
-inet_ntop.o: $(srcdir)/missing/inet_ntop.c
- $(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/inet_ntop.c
-inet_aton.o: $(srcdir)/missing/inet_aton.c
- $(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/inet_aton.c
snprintf.o: $(srcdir)/missing/snprintf.c
$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/snprintf.c
strdup.o: $(srcdir)/missing/strdup.c
@@ -434,6 +439,9 @@ distclean:
check: tcpdump
(cd tests && ./TESTrun.sh)
+extags: $(TAGFILES)
+ ctags $(TAGFILES)
+
tags: $(TAGFILES)
ctags -wtd $(TAGFILES)
diff --git a/contrib/tcpdump/PLATFORMS b/contrib/tcpdump/PLATFORMS
new file mode 100644
index 0000000..ec85e59
--- /dev/null
+++ b/contrib/tcpdump/PLATFORMS
@@ -0,0 +1,9 @@
+== Tested platforms ==
+NetBSD 5.1/i386 (mcr - 2012/4/1)
+Debian Linux (squeeze/i386) (mcr - 2012/4/1)
+
+---
+RedHat Linux 6.1/i386 (assar)
+FreeBSD 2.2.8/i386 (itojun)
+
+
diff --git a/contrib/tcpdump/README b/contrib/tcpdump/README
new file mode 120000
index 0000000..42061c0
--- /dev/null
+++ b/contrib/tcpdump/README
@@ -0,0 +1 @@
+README.md \ No newline at end of file
diff --git a/contrib/tcpdump/VERSION b/contrib/tcpdump/VERSION
index b48b2de..6ed7776 100644
--- a/contrib/tcpdump/VERSION
+++ b/contrib/tcpdump/VERSION
@@ -1 +1 @@
-4.7.4
+4.9.0
diff --git a/contrib/tcpdump/addrtoname.c b/contrib/tcpdump/addrtoname.c
index 2befeae..85cbf7b 100644
--- a/contrib/tcpdump/addrtoname.c
+++ b/contrib/tcpdump/addrtoname.c
@@ -20,11 +20,8 @@
*
* Internet, ethernet, port, and protocol string to address
* and address to string conversion routines
- *
- * $FreeBSD$
*/
-#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -33,7 +30,8 @@
#include <libcasper.h>
#include <casper/cap_dns.h>
#endif /* HAVE_CASPER */
-#include <tcpdump-stdinc.h>
+
+#include <netdissect-stdinc.h>
#ifdef USE_ETHER_NTOHOST
#ifdef HAVE_NETINET_IF_ETHER_H
@@ -64,8 +62,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"
@@ -78,7 +78,7 @@ 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
@@ -96,7 +96,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
@@ -134,9 +134,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;
@@ -144,7 +143,6 @@ struct h6namemem {
};
static struct h6namemem h6nametable[HASHNAMESIZE];
-#endif /* INET6 */
struct enamemem {
u_short e_addr0;
@@ -214,7 +212,7 @@ extern cap_channel_t *capdns;
*
* 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
@@ -232,7 +230,7 @@ getname(netdissect_options *ndo, const u_char *ap)
{
register struct hostent *hp;
uint32_t addr;
- static struct hnamemem *p; /* static for longjmp() */
+ struct hnamemem *p;
memcpy(&addr, ap, sizeof(addr));
p = &hnametable[addr & (HASHNAMESIZE-1)];
@@ -241,7 +239,7 @@ getname(netdissect_options *ndo, const u_char *ap)
return (p->name);
}
p->addr = addr;
- p->nxt = newhnamemem();
+ p->nxt = newhnamemem(ndo);
/*
* Print names unless:
@@ -263,6 +261,9 @@ getname(netdissect_options *ndo, const u_char *ap)
char *dotp;
p->name = strdup(hp->h_name);
+ if (p->name == NULL)
+ (*ndo->ndo_error)(ndo,
+ "getname: strdup(hp->h_name)");
if (ndo->ndo_Nflag) {
/* Remove domain qualifications */
dotp = strchr(p->name, '.');
@@ -273,10 +274,11 @@ getname(netdissect_options *ndo, 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.
@@ -292,7 +294,7 @@ getname6(netdissect_options *ndo, const u_char *ap)
uint16_t d;
} addra;
} addr;
- static struct h6namemem *p; /* static for longjmp() */
+ struct h6namemem *p;
register const char *cp;
char ntop_buf[INET6_ADDRSTRLEN];
@@ -303,7 +305,7 @@ getname6(netdissect_options *ndo, const u_char *ap)
return (p->name);
}
p->addr = addr.addr;
- p->nxt = newh6namemem();
+ p->nxt = newh6namemem(ndo);
/*
* Do not print names if -n was given.
@@ -315,11 +317,15 @@ getname6(netdissect_options *ndo, const u_char *ap)
sizeof(addr), AF_INET6);
} else
#endif
- hp = gethostbyaddr((char *)&addr, sizeof(addr), AF_INET6);
+ hp = gethostbyaddr((char *)&addr, sizeof(addr),
+ AF_INET6);
if (hp) {
char *dotp;
p->name = strdup(hp->h_name);
+ if (p->name == NULL)
+ (*ndo->ndo_error)(ndo,
+ "getname6: strdup(hp->h_name)");
if (ndo->ndo_Nflag) {
/* Remove domain qualifications */
dotp = strchr(p->name, '.');
@@ -329,11 +335,12 @@ getname6(netdissect_options *ndo, 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";
@@ -341,7 +348,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;
@@ -363,7 +370,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;
}
@@ -374,7 +381,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;
@@ -406,12 +414,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;
}
@@ -419,14 +427,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];
@@ -439,22 +448,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;
}
@@ -462,7 +472,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;
@@ -482,7 +492,7 @@ 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;
}
@@ -496,21 +506,18 @@ etheraddr_string(netdissect_options *ndo, 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 (!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);
}
}
@@ -531,11 +538,13 @@ etheraddr_string(netdissect_options *ndo, register const u_char *ep)
} 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;
@@ -543,7 +552,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);
@@ -558,12 +567,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(netdissect_options *ndo, 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;
@@ -578,13 +590,13 @@ linkaddr_string(netdissect_options *ndo, const u_char *ep, const unsigned int ty
if (type == LINKADDR_FRELAY)
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) {
@@ -597,7 +609,7 @@ linkaddr_string(netdissect_options *ndo, const u_char *ep, const unsigned int ty
}
const char *
-etherproto_string(u_short port)
+etherproto_string(netdissect_options *ndo, u_short port)
{
register char *cp;
register struct hnamemem *tp;
@@ -609,7 +621,7 @@ etherproto_string(u_short port)
return (tp->name);
tp->addr = i;
- tp->nxt = newhnamemem();
+ tp->nxt = newhnamemem(ndo);
cp = buf;
NTOHS(port);
@@ -619,18 +631,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;
@@ -646,12 +660,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;
@@ -660,13 +677,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];
@@ -681,7 +698,7 @@ 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 uint32_t i = port;
@@ -692,15 +709,17 @@ 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 uint32_t i = port;
@@ -711,15 +730,17 @@ 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;
@@ -731,7 +752,7 @@ ipxsap_string(u_short port)
return (tp->name);
tp->addr = i;
- tp->nxt = newhnamemem();
+ tp->nxt = newhnamemem(ndo);
cp = buf;
NTOHS(port);
@@ -741,6 +762,8 @@ 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);
}
@@ -769,25 +792,44 @@ init_servarray(netdissect_options *ndo)
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)
-extern __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;
@@ -799,7 +841,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);
}
}
@@ -820,7 +862,7 @@ static const struct protoidlist {
* types.
*/
static void
-init_protoidarray(void)
+init_protoidarray(netdissect_options *ndo)
{
register int i;
register struct protoidmem *tp;
@@ -834,12 +876,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;
@@ -871,7 +916,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;
@@ -885,8 +930,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);
}
@@ -894,7 +942,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;
@@ -902,14 +950,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
@@ -1135,7 +1181,7 @@ static const struct tok ipxsap_db[] = {
};
static void
-init_ipxsaparray(void)
+init_ipxsaparray(netdissect_options *ndo)
{
register int i;
register struct hnamemem *table;
@@ -1147,7 +1193,7 @@ 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);
}
}
@@ -1170,11 +1216,11 @@ init_addrtoname(netdissect_options *ndo, uint32_t localnet, uint32_t mask)
*/
return;
- init_etherarray();
+ init_etherarray(ndo);
init_servarray(ndo);
- init_eprotoarray();
- init_protoidarray();
- init_ipxsaparray();
+ init_eprotoarray(ndo);
+ init_protoidarray(ndo);
+ init_ipxsaparray(ndo);
}
const char *
@@ -1182,24 +1228,24 @@ 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();
+ tp->nxt = newhnamemem(ndo);
if (ndo->ndo_nflag)
- tp->name = dnnum_string(dnaddr);
+ 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;
@@ -1209,17 +1255,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;
@@ -1229,13 +1274,12 @@ 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 *
diff --git a/contrib/tcpdump/addrtoname.h b/contrib/tcpdump/addrtoname.h
index b07d8b2..72e5ef1 100644
--- a/contrib/tcpdump/addrtoname.h
+++ b/contrib/tcpdump/addrtoname.h
@@ -19,6 +19,14 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
+/*
+ * 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,28 +40,22 @@ enum {
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(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 *isonsap_string(const u_char *, register u_int);
+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(const u_char *);
-extern const char *ipxsap_string(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 *);
-#ifdef INET6
extern const char *getname6(netdissect_options *, const u_char *);
-#endif
extern const char *intoa(uint32_t);
extern void init_addrtoname(netdissect_options *, uint32_t, uint32_t);
-extern struct hnamemem *newhnamemem(void);
-#ifdef INET6
-extern struct h6namemem *newh6namemem(void);
-#endif
+extern struct hnamemem *newhnamemem(netdissect_options *);
+extern struct h6namemem *newh6namemem(netdissect_options *);
extern const char * ieee8021q_tci_string(const uint16_t);
#define ipaddr_string(ndo, p) getname(ndo, (const u_char *)(p))
-#ifdef INET6
#define ip6addr_string(ndo, p) getname6(ndo, (const u_char *)(p))
-#endif
diff --git a/contrib/tcpdump/missing/inet_ntop.c b/contrib/tcpdump/addrtostr.c
index 8c6f7eb..fd331a3 100644
--- a/contrib/tcpdump/missing/inet_ntop.c
+++ b/contrib/tcpdump/addrtostr.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999 Kungliga Tekniska Hgskolan
+ * Copyright (c) 1999 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
@@ -17,7 +17,7 @@
* 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
- * Hgskolan and its contributors.
+ * 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
@@ -40,9 +40,11 @@
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
+#include "addrtostr.h"
#include <stdio.h>
+#include <string.h>
/*
*
@@ -56,13 +58,12 @@
#define INT16SZ 2 /* word size */
#endif
-static const char *
-inet_ntop_v4 (const void *src, char *dst, size_t size)
+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;
- struct in_addr *addr = (struct in_addr *)src;
- u_long a = ntohl(addr->s_addr);
const char *orig_dst = dst;
if (size < INET_ADDRSTRLEN) {
@@ -70,7 +71,7 @@ inet_ntop_v4 (const void *src, char *dst, size_t size)
return NULL;
}
for (i = 0; i < 4; ++i) {
- int n = (a >> (24 - i * 8)) & 0xFF;
+ int n = *srcaddr++;
int non_zerop = 0;
if (non_zerop || n / 100 > 0) {
@@ -91,12 +92,11 @@ inet_ntop_v4 (const void *src, char *dst, size_t size)
return orig_dst;
}
-#ifdef INET6
/*
* Convert IPv6 binary address into presentation (printable) format.
*/
-static const char *
-inet_ntop_v6 (const u_char *src, char *dst, size_t size)
+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
@@ -105,14 +105,16 @@ inet_ntop_v6 (const u_char *src, char *dst, size_t size)
* Keep this in mind if you think this function should have been coded
* to use pointer overlays. All the world's not a VAX.
*/
- char tmp [INET6_ADDRSTRLEN+1];
- char *tp;
+ 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;
+ int i;
/* Preprocess:
* Copy the input (bytewise) array into a wordwise array.
@@ -120,7 +122,7 @@ inet_ntop_v6 (const u_char *src, char *dst, size_t size)
*/
memset (words, 0, sizeof(words));
for (i = 0; i < IN6ADDRSZ; i++)
- words[i/2] |= (src[i] << ((1 - (i % 2)) << 3));
+ words[i/2] |= (srcaddr[i] << ((1 - (i % 2)) << 3));
best.len = 0;
best.base = -1;
@@ -148,7 +150,17 @@ inet_ntop_v6 (const u_char *src, char *dst, size_t size)
/* Format the result.
*/
- tp = tmp;
+ 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?
@@ -156,61 +168,47 @@ inet_ntop_v6 (const u_char *src, char *dst, size_t size)
if (best.base != -1 && i >= best.base && i < (best.base + best.len))
{
if (i == best.base)
- *tp++ = ':';
+ APPEND_CHAR(':');
continue;
}
/* Are we following an initial run of 0x00s or any real hex?
*/
if (i != 0)
- *tp++ = ':';
+ APPEND_CHAR(':');
/* Is this address an encapsulated IPv4?
*/
if (i == 6 && best.base == 0 &&
(best.len == 6 || (best.len == 5 && words[5] == 0xffff)))
{
- if (!inet_ntop_v4(src+12, tp, sizeof(tmp) - (tp - tmp)))
+ if (!addrtostr(srcaddr+12, dp, space_left))
{
errno = ENOSPC;
return (NULL);
}
- tp += strlen(tp);
+ added_space = strlen(dp);
+ dp += added_space;
+ space_left -= added_space;
break;
}
- tp += sprintf (tp, "%lx", words[i]);
+ 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))
- *tp++ = ':';
- *tp++ = '\0';
+ APPEND_CHAR(':');
+ APPEND_CHAR('\0');
- /* Check for overflow, copy, and we're done.
- */
- if ((size_t)(tp - tmp) > size)
- {
- errno = ENOSPC;
- return (NULL);
- }
- return strcpy (dst, tmp);
-}
-#endif /* INET6 */
-
-
-const char *
-inet_ntop(int af, const void *src, char *dst, size_t size)
-{
- switch (af) {
- case AF_INET :
- return inet_ntop_v4 (src, dst, size);
-#ifdef INET6
- case AF_INET6:
- return inet_ntop_v6 ((const u_char*)src, dst, size);
-#endif
- default :
- errno = EAFNOSUPPORT;
- return NULL;
- }
+ return (dst);
}
diff --git a/contrib/tcpdump/missing/inet_pton.c b/contrib/tcpdump/addrtostr.h
index 3466f42..2b95a16 100644
--- a/contrib/tcpdump/missing/inet_pton.c
+++ b/contrib/tcpdump/addrtostr.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999 Kungliga Tekniska H�gskolan
+ * Copyright (c) 1999 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
@@ -17,7 +17,7 @@
* 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.
+ * 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
@@ -36,14 +36,7 @@
* SUCH DAMAGE.
*/
-#include <tcpdump-stdinc.h>
+/* Address to printable string translation routines. */
-int
-inet_pton(int af, const char *src, void *dst)
-{
- if (af != AF_INET) {
- errno = EAFNOSUPPORT;
- return -1;
- }
- return inet_aton (src, dst);
-}
+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/contrib/tcpdump/af.c b/contrib/tcpdump/af.c
index bea6d97..539ede5 100644
--- a/contrib/tcpdump/af.c
+++ b/contrib/tcpdump/af.c
@@ -15,13 +15,12 @@
* Original code by Hannes Gredler (hannes@juniper.net)
*/
-#define NETDISSECT_REWORKED
#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[] = {
diff --git a/contrib/tcpdump/af.h b/contrib/tcpdump/af.h
index bbe1a16..1bde577 100644
--- a/contrib/tcpdump/af.h
+++ b/contrib/tcpdump/af.h
@@ -50,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/contrib/tcpdump/ascii_strcasecmp.c b/contrib/tcpdump/ascii_strcasecmp.c
new file mode 100644
index 0000000..b8decf1
--- /dev/null
+++ b/contrib/tcpdump/ascii_strcasecmp.c
@@ -0,0 +1,105 @@
+/*
+ * 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]);
+}
diff --git a/contrib/tcpdump/ascii_strcasecmp.h b/contrib/tcpdump/ascii_strcasecmp.h
new file mode 100644
index 0000000..7f8ddb9a
--- /dev/null
+++ b/contrib/tcpdump/ascii_strcasecmp.h
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ */
+
+#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);
+
+#endif /* netdissect_ascii_strcasecmp_h */
diff --git a/contrib/tcpdump/atmuni31.h b/contrib/tcpdump/atmuni31.h
deleted file mode 100644
index 0f85430..0000000
--- a/contrib/tcpdump/atmuni31.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * 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
diff --git a/contrib/tcpdump/bpf_dump.c b/contrib/tcpdump/bpf_dump.c
index 2ef8528..9bad38d 100644
--- a/contrib/tcpdump/bpf_dump.c
+++ b/contrib/tcpdump/bpf_dump.c
@@ -19,16 +19,15 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#define NETDISSECT_REWORKED
#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"
void
bpf_dump(const struct bpf_program *p, int option)
diff --git a/contrib/tcpdump/checksum.c b/contrib/tcpdump/checksum.c
index d8263c7..0829fbe 100644
--- a/contrib/tcpdump/checksum.c
+++ b/contrib/tcpdump/checksum.c
@@ -17,19 +17,18 @@
* Original code by Hannes Gredler (hannes@juniper.net)
*/
-#define NETDISSECT_REWORKED
#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:
@@ -146,17 +145,17 @@ create_osi_cksum (const uint8_t *pptr, int checksum_offset, int length)
uint32_t c0;
uint32_t c1;
uint16_t checksum;
- int index;
+ 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 {
diff --git a/contrib/tcpdump/config.h.in b/contrib/tcpdump/config.h.in
index c289f00..27ba4b10 100644
--- a/contrib/tcpdump/config.h.in
+++ b/contrib/tcpdump/config.h.in
@@ -1,7 +1,7 @@
/* config.h.in. Generated from configure.in by autoheader. */
-/* define if you have the addrinfo function */
-#undef HAVE_ADDRINFO
+/* define if you want to build the possibly-buggy SMB printer */
+#undef ENABLE_SMB
/* Define to 1 if you have the `alarm' function. */
#undef HAVE_ALARM
@@ -10,7 +10,7 @@
#undef HAVE_BPF_DUMP
/* capsicum support available */
-#undef HAVE_CASPER
+#undef HAVE_CAPSICUM
/* Define to 1 if you have the `cap_enter' function. */
#undef HAVE_CAP_ENTER
@@ -34,24 +34,21 @@
/* Define to 1 if you have the `ether_ntohost' function. */
#undef HAVE_ETHER_NTOHOST
+/* Define to 1 if you have the `EVP_CIPHER_CTX_new' function. */
+#undef HAVE_EVP_CIPHER_CTX_NEW
+
/* Define to 1 if you have the <fcntl.h> header file. */
#undef HAVE_FCNTL_H
/* Define to 1 if you have the `fork' function. */
#undef HAVE_FORK
-/* Define to 1 if you have the `getnameinfo' function. */
-#undef HAVE_GETNAMEINFO
-
/* Define to 1 if you have the `getopt_long' function. */
#undef HAVE_GETOPT_LONG
/* define if you have getrpcbynumber() */
#undef HAVE_GETRPCBYNUMBER
-/* define if you have the h_errno variable */
-#undef HAVE_H_ERRNO
-
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
@@ -79,6 +76,9 @@
/* Define to 1 if you have the <netinet/if_ether.h> header file. */
#undef HAVE_NETINET_IF_ETHER_H
+/* Define to 1 if you have the <net/if_pflog.h> header file. */
+#undef HAVE_NET_IF_PFLOG_H
+
/* Define to 1 if you have the <net/pfvar.h> header file. */
#undef HAVE_NET_PFVAR_H
@@ -88,6 +88,9 @@
/* Define to 1 if you have the <openssl/evp.h> header file. */
#undef HAVE_OPENSSL_EVP_H
+/* define if the OS provides AF_INET6 and struct in6_addr */
+#undef HAVE_OS_IPV6_SUPPORT
+
/* if there's an os_proto.h for this platform, to use additional prototypes */
#undef HAVE_OS_PROTO_H
@@ -142,6 +145,12 @@
/* Define to 1 if you have the `pcap_set_immediate_mode' function. */
#undef HAVE_PCAP_SET_IMMEDIATE_MODE
+/* 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. */
#undef HAVE_PCAP_SET_TSTAMP_PRECISION
@@ -184,9 +193,6 @@
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
-/* Define to 1 if you have the `strcasecmp' function. */
-#undef HAVE_STRCASECMP
-
/* Define to 1 if you have the `strdup' function. */
#undef HAVE_STRDUP
@@ -238,15 +244,9 @@
/* define if your compiler has __attribute__ */
#undef HAVE___ATTRIBUTE__
-/* Define if you enable IPv6 support */
-#undef INET6
-
/* if unaligned access fails */
#undef LBL_ALIGN
-/* define if you need to include missing/addrinfo.h */
-#undef NEED_ADDRINFO_H
-
/* Define to 1 if netinet/ether.h declares `ether_ntohost' */
#undef NETINET_ETHER_H_DECLARES_ETHER_NTOHOST
@@ -292,9 +292,6 @@
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
-/* define if you want to build the possibly-buggy SMB printer */
-#undef TCPDUMP_DO_SMB
-
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
#undef TIME_WITH_SYS_TIME
diff --git a/contrib/tcpdump/configure b/contrib/tcpdump/configure
index d10f2ac..03c69c5 100755
--- a/contrib/tcpdump/configure
+++ b/contrib/tcpdump/configure
@@ -704,7 +704,6 @@ enable_smb
with_user
with_chroot
with_sandbox_capsicum
-enable_ipv6
with_system_libpcap
with_crypto
with_cap_ng
@@ -1332,8 +1331,6 @@ Optional Features:
--disable-universal don't build universal on OS X
--enable-smb enable possibly-buggy SMB printer default=yes
--disable-smb disable possibly-buggy SMB printer
- --enable-ipv6 enable ipv6 (with ipv4) support
- --disable-ipv6 disable ipv6 support
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
@@ -1346,7 +1343,8 @@ Optional Packages:
--with-sandbox-capsicum use Capsicum security functions [default=yes, if
available]
--with-system-libpcap don't use local pcap library
- --with-crypto use OpenSSL libcrypto [default=yes, if available]
+ --with-crypto[=DIR] use OpenSSL/libressl libcrypto (located in directory
+ DIR, if specified) [default=yes, if available]
--with-cap-ng use libcap-ng [default=yes, if available]
Some influential environment variables:
@@ -3352,7 +3350,18 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -ffloat-store option" >&5
$as_echo_n "checking whether the compiler supports the -ffloat-store option... " >&6; }
save_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors -ffloat-store"
+ if expr "x-ffloat-store" : "x-W.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -ffloat-store"
+ elif expr "x-ffloat-store" : "x-f.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -ffloat-store"
+ elif expr "x-ffloat-store" : "x-m.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -ffloat-store"
+ else
+ CFLAGS="$CFLAGS -ffloat-store"
+ fi
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
@@ -4213,7 +4222,25 @@ fi
done
if test "$ac_cv_header_net_pfvar_h" = yes; then
- LOCALSRC="print-pflog.c $LOCALSRC"
+ for ac_header in net/if_pflog.h
+do :
+ ac_fn_c_check_header_compile "$LINENO" "net/if_pflog.h" "ac_cv_header_net_if_pflog_h" "#include <sys/types.h>
+ #include <sys/socket.h>
+ #include <net/if.h>
+ #include <net/pfvar.h>
+"
+if test "x$ac_cv_header_net_if_pflog_h" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_NET_IF_PFLOG_H 1
+_ACEOF
+
+fi
+
+done
+
+ if test "$ac_cv_header_net_if_pflog_h" = yes; then
+ LOCALSRC="print-pflog.c $LOCALSRC"
+ fi
fi
for ac_header in netinet/if_ether.h
do :
@@ -4474,7 +4501,7 @@ $as_echo "yes" >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: The SMB printer may have exploitable buffer overflows!!!" >&5
$as_echo "$as_me: WARNING: The SMB printer may have exploitable buffer overflows!!!" >&2;}
-$as_echo "#define TCPDUMP_DO_SMB 1" >>confdefs.h
+$as_echo "#define ENABLE_SMB 1" >>confdefs.h
LOCALSRC="print-smb.c smbutil.c $LOCALSRC"
;;
@@ -4566,7 +4593,7 @@ fi
$as_echo_n "checking whether to sandbox using capsicum... " >&6; }
if test "x$ac_lbl_capsicum_function_seen" = "xyes" -a "x$ac_lbl_capsicum_function_not_seen" != "xyes"; then
-$as_echo "#define HAVE_CASPER 1" >>confdefs.h
+$as_echo "#define HAVE_CAPSICUM 1" >>confdefs.h
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
@@ -4576,9 +4603,9 @@ $as_echo "no" >&6; }
fi
#
-# We must check this before checking whether to enable IPv6, because,
-# on some platforms (such as SunOS 5.x), the test program requires
-# the extra networking libraries.
+# We must check this before checking whether to check the OS's IPv6,
+# support because, on some platforms (such as SunOS 5.x), the test
+# program requires the extra networking libraries.
#
# Most operating systems have gethostbyname() in the default searched
@@ -4842,30 +4869,19 @@ fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable ipv6" >&5
-$as_echo_n "checking whether to enable ipv6... " >&6; }
-# Check whether --enable-ipv6 was given.
-if test "${enable_ipv6+set}" = set; then :
- enableval=$enable_ipv6; case "$enableval" in
-yes) { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
- LOCALSRC="print-ip6opts.c print-mobility.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c print-babel.c $LOCALSRC"
-
-$as_echo "#define INET6 1" >>confdefs.h
-
- ipv6=yes
- ;;
-*)
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
- ipv6=no
- ;;
- esac
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+#
+# Check whether AF_INET6 and struct in6_addr are defined.
+# If they aren't both defined, we don't have sufficient OS
+# support for IPv6, so we don't look for IPv6 support libraries,
+# and we define AF_INET6 and struct in6_addr ourselves.
+#
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the operating system supports IPv6" >&5
+$as_echo_n "checking whether the operating system supports IPv6... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
- /* AF_INET6 available check */
+
+/* AF_INET6 available check */
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
@@ -4882,21 +4898,23 @@ foo(struct in6_addr *addr)
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
- LOCALSRC="print-ip6opts.c print-mobility.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c print-babel.c $LOCALSRC"
-$as_echo "#define INET6 1" >>confdefs.h
+$as_echo "#define HAVE_OS_IPV6_SUPPORT 1" >>confdefs.h
+
+ ipv6=yes
- ipv6=yes
else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
- ipv6=no
+ ipv6=no
+
+
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-
ipv6type=unknown
ipv6lib=none
@@ -4917,8 +4935,7 @@ yes
_ACEOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
$EGREP "yes" >/dev/null 2>&1; then :
- ipv6type=$i;
- CFLAGS="-DINET6 $CFLAGS"
+ ipv6type=$i
fi
rm -f conftest*
@@ -4936,8 +4953,7 @@ if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
ipv6type=$i;
ipv6lib=inet6;
ipv6libdir=/usr/local/v6/lib;
- ipv6trylibc=yes;
- CFLAGS="-DINET6 $CFLAGS"
+ ipv6trylibc=yes
fi
rm -f conftest*
@@ -4952,8 +4968,7 @@ yes
_ACEOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
$EGREP "yes" >/dev/null 2>&1; then :
- ipv6type=$i;
- CFLAGS="-DINET6 $CFLAGS"
+ ipv6type=$i
fi
rm -f conftest*
@@ -4964,7 +4979,7 @@ rm -f conftest*
ipv6lib=inet6
ipv6libdir=/usr/inet6/lib
ipv6trylibc=yes;
- CFLAGS="-DINET6 -I/usr/inet6/include $CFLAGS"
+ CFLAGS="-I/usr/inet6/include $CFLAGS"
fi
;;
toshiba)
@@ -4979,8 +4994,7 @@ if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
$EGREP "yes" >/dev/null 2>&1; then :
ipv6type=$i;
ipv6lib=inet6;
- ipv6libdir=/usr/local/v6/lib;
- CFLAGS="-DINET6 $CFLAGS"
+ ipv6libdir=/usr/local/v6/lib
fi
rm -f conftest*
@@ -5015,8 +5029,7 @@ if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
$EGREP "yes" >/dev/null 2>&1; then :
ipv6type=$i;
ipv6lib=inet6;
- ipv6libdir=/usr/local/v6/lib;
- CFLAGS="-DINET6 $CFLAGS"
+ ipv6libdir=/usr/local/v6/lib
fi
rm -f conftest*
@@ -5046,239 +5059,6 @@ if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
fi
fi
-
-if test "$ipv6" = "yes"; then
- #
- # XXX - on Tru64 UNIX 5.1, there is no "getaddrinfo()"
- # function in libc; there are "ngetaddrinfo()" and
- # "ogetaddrinfo()" functions, and <netdb.h> #defines
- # "getaddrinfo" to be either "ngetaddrinfo" or
- # "ogetaddrinfo", depending on whether _SOCKADDR_LEN
- # or _XOPEN_SOURCE_EXTENDED are defined or not.
- #
- # So this test doesn't work on Tru64 5.1, and possibly
- # on other 5.x releases. This causes the configure
- # script to become confused, and results in libpcap
- # being unbuildable.
- #
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing getaddrinfo" >&5
-$as_echo_n "checking for library containing getaddrinfo... " >&6; }
-if ${ac_cv_search_getaddrinfo+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- ac_func_search_save_LIBS=$LIBS
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char getaddrinfo ();
-int
-main ()
-{
-return getaddrinfo ();
- ;
- return 0;
-}
-_ACEOF
-for ac_lib in '' socket; do
- if test -z "$ac_lib"; then
- ac_res="none required"
- else
- ac_res=-l$ac_lib
- LIBS="-l$ac_lib $ac_func_search_save_LIBS"
- fi
- if ac_fn_c_try_link "$LINENO"; then :
- ac_cv_search_getaddrinfo=$ac_res
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext
- if ${ac_cv_search_getaddrinfo+:} false; then :
- break
-fi
-done
-if ${ac_cv_search_getaddrinfo+:} false; then :
-
-else
- ac_cv_search_getaddrinfo=no
-fi
-rm conftest.$ac_ext
-LIBS=$ac_func_search_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_getaddrinfo" >&5
-$as_echo "$ac_cv_search_getaddrinfo" >&6; }
-ac_res=$ac_cv_search_getaddrinfo
-if test "$ac_res" != no; then :
- test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking getaddrinfo bug" >&5
-$as_echo_n "checking getaddrinfo bug... " >&6; }
- if ${td_cv_buggygetaddrinfo+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- if test "$cross_compiling" = yes; then :
- td_cv_buggygetaddrinfo=unknown
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-#include <sys/types.h>
-#include <netdb.h>
-#include <string.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-
-main()
-{
- int passive, gaierr, inet4 = 0, inet6 = 0;
- struct addrinfo hints, *ai, *aitop;
- char straddr[INET6_ADDRSTRLEN], strport[16];
-
- for (passive = 0; passive <= 1; passive++) {
- memset(&hints, 0, sizeof(hints));
- hints.ai_family = AF_UNSPEC;
- hints.ai_flags = passive ? AI_PASSIVE : 0;
- hints.ai_socktype = SOCK_STREAM;
- hints.ai_protocol = IPPROTO_TCP;
- if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
- (void)gai_strerror(gaierr);
- goto bad;
- }
- for (ai = aitop; ai; ai = ai->ai_next) {
- if (ai->ai_addr == NULL ||
- ai->ai_addrlen == 0 ||
- getnameinfo(ai->ai_addr, ai->ai_addrlen,
- straddr, sizeof(straddr), strport, sizeof(strport),
- NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
- goto bad;
- }
- switch (ai->ai_family) {
- case AF_INET:
- if (strcmp(strport, "54321") != 0) {
- goto bad;
- }
- if (passive) {
- if (strcmp(straddr, "0.0.0.0") != 0) {
- goto bad;
- }
- } else {
- if (strcmp(straddr, "127.0.0.1") != 0) {
- goto bad;
- }
- }
- inet4++;
- break;
- case AF_INET6:
- if (strcmp(strport, "54321") != 0) {
- goto bad;
- }
- if (passive) {
- if (strcmp(straddr, "::") != 0) {
- goto bad;
- }
- } else {
- if (strcmp(straddr, "::1") != 0) {
- goto bad;
- }
- }
- inet6++;
- break;
- case AF_UNSPEC:
- goto bad;
- break;
-#ifdef AF_UNIX
- case AF_UNIX:
-#else
-#ifdef AF_LOCAL
- case AF_LOCAL:
-#endif
-#endif
- default:
- /* another family support? */
- break;
- }
- }
- }
-
- /* supported family should be 2, unsupported family should be 0 */
- if (!(inet4 == 0 || inet4 == 2))
- goto bad;
- if (!(inet6 == 0 || inet6 == 2))
- goto bad;
-
- if (aitop)
- freeaddrinfo(aitop);
- exit(0);
-
- bad:
- if (aitop)
- freeaddrinfo(aitop);
- exit(1);
-}
-
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
- td_cv_buggygetaddrinfo=no
-else
- td_cv_buggygetaddrinfo=yes
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
- conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-fi
-
- if test "$td_cv_buggygetaddrinfo" = no; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: good" >&5
-$as_echo "good" >&6; }
- elif test "$td_cv_buggygetaddrinfo" = unknown; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: unknown (cross-compiling)" >&5
-$as_echo "unknown (cross-compiling)" >&6; }
- else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: buggy" >&5
-$as_echo "buggy" >&6; }
- fi
-
- if test "$td_cv_buggygetaddrinfo" = "yes"; then
- #
- # XXX - it doesn't appear that "ipv6type" can ever be
- # set to "linux". Should this be testing for
- # "linux-glibc", or for that *or* "linux-libinet6"?
- # If the latter, note that "linux-libinet6" is also
- # the type given to some non-Linux OSes.
- #
- if test "$ipv6type" != "linux"; then
- echo 'Fatal: You must get working getaddrinfo() function.'
- echo ' or you can specify "--disable-ipv6"'.
- exit 1
- else
- echo 'Warning: getaddrinfo() implementation on your system seems be buggy.'
- echo ' Better upgrade your system library to newest version'
- echo ' of GNU C library (aka glibc).'
- fi
- fi
-
-fi
-
- ac_fn_c_check_func "$LINENO" "getnameinfo" "ac_cv_func_getnameinfo"
-if test "x$ac_cv_func_getnameinfo" = xyes; then :
- $as_echo "#define HAVE_GETNAMEINFO 1" >>confdefs.h
-
-else
- case " $LIBOBJS " in
- *" getnameinfo.$ac_objext "* ) ;;
- *) LIBOBJS="$LIBOBJS getnameinfo.$ac_objext"
- ;;
-esac
-
-fi
-
-
-fi
-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for dnet_htoa declaration in netdnet/dnetdb.h" >&5
$as_echo_n "checking for dnet_htoa declaration in netdnet/dnetdb.h... " >&6; }
if ${td_cv_decl_netdnet_dnetdb_h_dnet_htoa+:} false; then :
@@ -5306,116 +5086,6 @@ $as_echo "#define HAVE_NETDNET_DNETDB_H_DNET_HTOA 1" >>confdefs.h
fi
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for addrinfo" >&5
-$as_echo_n "checking for addrinfo... " >&6; }
- if ${ac_cv_addrinfo+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-# include <netdb.h>
-int
-main ()
-{
-struct addrinfo a
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- ac_cv_addrinfo=yes
-else
- ac_cv_addrinfo=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_addrinfo" >&5
-$as_echo "$ac_cv_addrinfo" >&6; }
- if test $ac_cv_addrinfo = yes; then
-
-$as_echo "#define HAVE_ADDRINFO 1" >>confdefs.h
-
- else
-
-$as_echo "#define NEED_ADDRINFO_H 1" >>confdefs.h
-
- fi
-
-if test "$ac_cv_addrinfo" = no; then
- missing_includes=yes
-fi
-
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for NI_MAXSERV" >&5
-$as_echo_n "checking for NI_MAXSERV... " >&6; }
- if ${ac_cv_maxserv+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <netdb.h>
-#ifdef NI_MAXSERV
-yes
-#endif
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- $EGREP "yes" >/dev/null 2>&1; then :
- ac_cv_maxserv=yes
-else
- ac_cv_maxserv=no
-fi
-rm -f conftest*
-
-fi
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_maxserv" >&5
-$as_echo "$ac_cv_maxserv" >&6; }
- if test $ac_cv_maxserv != yes; then
- $as_echo "#define NEED_ADDRINFO_H 1" >>confdefs.h
-
- fi
-
-if test "$ac_cv_maxserv" = no; then
- missing_includes=yes
-fi
-
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for NI_NAMEREQD" >&5
-$as_echo_n "checking for NI_NAMEREQD... " >&6; }
- if ${ac_cv_namereqd+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <netdb.h>
-#ifdef NI_NOFQDN
-yes
-#endif
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- $EGREP "yes" >/dev/null 2>&1; then :
- ac_cv_namereqd=yes
-else
- ac_cv_namereqd=no
-fi
-rm -f conftest*
-
-fi
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_namereqd" >&5
-$as_echo "$ac_cv_namereqd" >&6; }
- if test $ac_cv_namereqd != yes; then
- $as_echo "#define NEED_ADDRINFO_H 1" >>confdefs.h
-
- fi
-
-if test "$ac_cv_namereqd" = no; then
- missing_includes=yes
-fi
-
ac_fn_c_check_func "$LINENO" "vfprintf" "ac_cv_func_vfprintf"
if test "x$ac_cv_func_vfprintf" = xyes; then :
$as_echo "#define HAVE_VFPRINTF 1" >>confdefs.h
@@ -5429,19 +5099,6 @@ esac
fi
-ac_fn_c_check_func "$LINENO" "strcasecmp" "ac_cv_func_strcasecmp"
-if test "x$ac_cv_func_strcasecmp" = xyes; then :
- $as_echo "#define HAVE_STRCASECMP 1" >>confdefs.h
-
-else
- case " $LIBOBJS " in
- *" strcasecmp.$ac_objext "* ) ;;
- *) LIBOBJS="$LIBOBJS strcasecmp.$ac_objext"
- ;;
-esac
-
-fi
-
ac_fn_c_check_func "$LINENO" "strlcat" "ac_cv_func_strlcat"
if test "x$ac_cv_func_strlcat" = xyes; then :
$as_echo "#define HAVE_STRLCAT 1" >>confdefs.h
@@ -5794,7 +5451,6 @@ fi
-
LBL_LIBS="$LIBS"
pfopen=/usr/examples/packetfilter/pfopen.c
if test -f $pfopen ; then
@@ -6163,114 +5819,6 @@ fi
# Check for these after AC_LBL_LIBPCAP, so we link with the appropriate
# libraries (e.g., "-lsocket -lnsl" on Solaris).
#
-# We don't use AC_REPLACE_FUNCS because that uses AC_CHECK_FUNCS which
-# use AC_CHECK_FUNC which doesn't let us specify the right #includes
-# to make this work on BSD/OS 4.x. BSD/OS 4.x ships with the BIND8
-# resolver, and the way it defines inet_{ntop,pton} is rather strange;
-# it does not ship with a libc symbol "inet_ntop()", it ships with
-# "_inet_ntop()", and has a #define macro in one of the system headers
-# to rename it.
-#
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for inet_ntop" >&5
-$as_echo_n "checking for inet_ntop... " >&6; }
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-int
-main ()
-{
-char src[4], dst[128];
-inet_ntop(AF_INET, src, dst, sizeof(dst));
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
- case " $LIBOBJS " in
- *" inet_ntop.$ac_objext "* ) ;;
- *) LIBOBJS="$LIBOBJS inet_ntop.$ac_objext"
- ;;
-esac
-
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for inet_pton" >&5
-$as_echo_n "checking for inet_pton... " >&6; }
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-int
-main ()
-{
-char src[128], dst[4];
-inet_pton(AF_INET, src, dst);
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
- case " $LIBOBJS " in
- *" inet_pton.$ac_objext "* ) ;;
- *) LIBOBJS="$LIBOBJS inet_pton.$ac_objext"
- ;;
-esac
-
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for inet_aton" >&5
-$as_echo_n "checking for inet_aton... " >&6; }
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <sys/types.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-int
-main ()
-{
-char src[128];
-struct in_addr dst;
-inet_aton(src, &dst);
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
- case " $LIBOBJS " in
- *" inet_aton.$ac_objext "* ) ;;
- *) LIBOBJS="$LIBOBJS inet_aton.$ac_objext"
- ;;
-esac
-
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-
-#
-# Check for these after AC_LBL_LIBPCAP, for the same reason.
-#
# You are in a twisty little maze of UN*Xes, all different.
# Some might not have ether_ntohost().
# Some might have it, but not declare it in any header file.
@@ -6488,44 +6036,6 @@ if test "x$ac_cv_lib_dlpi_dlpi_walk" = xyes; then :
fi
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking if sockaddr struct has sa_len member" >&5
-$as_echo_n "checking if sockaddr struct has sa_len member... " >&6; }
- if ${ac_cv_sockaddr_has_sa_len+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-# include <sys/types.h>
-# include <sys/socket.h>
-int
-main ()
-{
-u_int i = sizeof(((struct sockaddr *)0)->sa_len)
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- ac_cv_sockaddr_has_sa_len=yes
-else
- ac_cv_sockaddr_has_sa_len=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sockaddr_has_sa_len" >&5
-$as_echo "$ac_cv_sockaddr_has_sa_len" >&6; }
- if test $ac_cv_sockaddr_has_sa_len = yes ; then
- $as_echo "#define HAVE_SOCKADDR_SA_LEN 1" >>confdefs.h
-
- fi
-
-if test "$ac_cv_sockaddr_has_sa_len" = no; then
- missing_includes=yes
-fi
-
ac_fn_c_check_func "$LINENO" "pcap_list_datalinks" "ac_cv_func_pcap_list_datalinks"
if test "x$ac_cv_func_pcap_list_datalinks" = xyes; then :
@@ -6748,18 +6258,38 @@ $as_echo "#define HAVE_PCAP_VERSION 1" >>confdefs.h
$as_echo "no" >&6; }
fi
fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether pcap_debug is defined by libpcap" >&5
+
+#
+# Check for special debugging functions
+#
+for ac_func in pcap_set_parser_debug
+do :
+ ac_fn_c_check_func "$LINENO" "pcap_set_parser_debug" "ac_cv_func_pcap_set_parser_debug"
+if test "x$ac_cv_func_pcap_set_parser_debug" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_PCAP_SET_PARSER_DEBUG 1
+_ACEOF
+
+fi
+done
+
+if test "$ac_cv_func_pcap_set_parser_debug" = "no" ; then
+ #
+ # OK, we don't have pcap_set_parser_debug() to set the libpcap
+ # filter expression parser debug flag; can we directly set the
+ # flag?
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether pcap_debug is defined by libpcap" >&5
$as_echo_n "checking whether pcap_debug is defined by libpcap... " >&6; }
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
- extern int pcap_debug;
+ extern int pcap_debug;
- return pcap_debug;
+ return pcap_debug;
;
return 0;
@@ -6772,30 +6302,30 @@ else
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
-if test "$ac_lbl_cv_pcap_debug_defined" = yes ; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+ if test "$ac_lbl_cv_pcap_debug_defined" = yes ; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
$as_echo "#define HAVE_PCAP_DEBUG 1" >>confdefs.h
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
- #
- # OK, what about "yydebug"?
- #
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether yydebug is defined by libpcap" >&5
+ #
+ # OK, what about "yydebug"?
+ #
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether yydebug is defined by libpcap" >&5
$as_echo_n "checking whether yydebug is defined by libpcap... " >&6; }
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
- extern int yydebug;
+ extern int yydebug;
- return yydebug;
+ return yydebug;
;
return 0;
@@ -6808,17 +6338,29 @@ else
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
- if test "$ac_lbl_cv_yydebug_defined" = yes ; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+ if test "$ac_lbl_cv_yydebug_defined" = yes ; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
$as_echo "#define HAVE_YYDEBUG 1" >>confdefs.h
- else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
+ fi
fi
fi
+for ac_func in pcap_set_optimizer_debug
+do :
+ ac_fn_c_check_func "$LINENO" "pcap_set_optimizer_debug" "ac_cv_func_pcap_set_optimizer_debug"
+if test "x$ac_cv_func_pcap_set_optimizer_debug" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_PCAP_SET_OPTIMIZER_DEBUG 1
+_ACEOF
+
+fi
+done
+
ac_fn_c_check_func "$LINENO" "bpf_dump" "ac_cv_func_bpf_dump"
if test "x$ac_cv_func_bpf_dump" = xyes; then :
$as_echo "#define HAVE_BPF_DUMP 1" >>confdefs.h
@@ -7417,7 +6959,7 @@ savedcppflags="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $V_INCLS"
for ac_header in pcap/bluetooth.h
do :
- ac_fn_c_check_header_compile "$LINENO" "pcap/bluetooth.h" "ac_cv_header_pcap_bluetooth_h" "#include \"tcpdump-stdinc.h\"
+ ac_fn_c_check_header_compile "$LINENO" "pcap/bluetooth.h" "ac_cv_header_pcap_bluetooth_h" "#include \"netdissect-stdinc.h\"
"
if test "x$ac_cv_header_pcap_bluetooth_h" = xyes; then :
cat >>confdefs.h <<_ACEOF
@@ -7430,7 +6972,7 @@ done
for ac_header in pcap/nflog.h
do :
- ac_fn_c_check_header_compile "$LINENO" "pcap/nflog.h" "ac_cv_header_pcap_nflog_h" "#include \"tcpdump-stdinc.h\"
+ ac_fn_c_check_header_compile "$LINENO" "pcap/nflog.h" "ac_cv_header_pcap_nflog_h" "#include \"netdissect-stdinc.h\"
"
if test "x$ac_cv_header_pcap_nflog_h" = xyes; then :
cat >>confdefs.h <<_ACEOF
@@ -7443,7 +6985,7 @@ done
for ac_header in pcap/usb.h
do :
- ac_fn_c_check_header_compile "$LINENO" "pcap/usb.h" "ac_cv_header_pcap_usb_h" "#include \"tcpdump-stdinc.h\"
+ ac_fn_c_check_header_compile "$LINENO" "pcap/usb.h" "ac_cv_header_pcap_usb_h" "#include \"netdissect-stdinc.h\"
"
if test "x$ac_cv_header_pcap_usb_h" = xyes; then :
cat >>confdefs.h <<_ACEOF
@@ -7651,10 +7193,57 @@ rm -f os-proto.h
#
if test "$ac_lbl_cc_dont_try_gcc_dashW" != yes; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler fails when given an unknown warning option" >&5
+$as_echo_n "checking whether the compiler fails when given an unknown warning option... " >&6; }
+ save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS -Wxyzzy-this-will-never-succeed-xyzzy"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+return 0
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ #
+ # We're assuming this is clang, where
+ # -Werror=unknown-warning-option is the appropriate
+ # option to force the compiler to fail.
+ #
+ ac_lbl_unknown_warning_option_error="-Werror=unknown-warning-option"
+
+else
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ CFLAGS="$save_CFLAGS"
+
+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wall option" >&5
$as_echo_n "checking whether the compiler supports the -Wall option... " >&6; }
save_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors -Wall"
+ if expr "x-Wall" : "x-W.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wall"
+ elif expr "x-Wall" : "x-f.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -Wall"
+ elif expr "x-Wall" : "x-m.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -Wall"
+ else
+ CFLAGS="$CFLAGS -Wall"
+ fi
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
@@ -7686,7 +7275,18 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wmissing-prototypes option" >&5
$as_echo_n "checking whether the compiler supports the -Wmissing-prototypes option... " >&6; }
save_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors -Wmissing-prototypes"
+ if expr "x-Wmissing-prototypes" : "x-W.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wmissing-prototypes"
+ elif expr "x-Wmissing-prototypes" : "x-f.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -Wmissing-prototypes"
+ elif expr "x-Wmissing-prototypes" : "x-m.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -Wmissing-prototypes"
+ else
+ CFLAGS="$CFLAGS -Wmissing-prototypes"
+ fi
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
@@ -7718,7 +7318,18 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wstrict-prototypes option" >&5
$as_echo_n "checking whether the compiler supports the -Wstrict-prototypes option... " >&6; }
save_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors -Wstrict-prototypes"
+ if expr "x-Wstrict-prototypes" : "x-W.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wstrict-prototypes"
+ elif expr "x-Wstrict-prototypes" : "x-f.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -Wstrict-prototypes"
+ elif expr "x-Wstrict-prototypes" : "x-m.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -Wstrict-prototypes"
+ else
+ CFLAGS="$CFLAGS -Wstrict-prototypes"
+ fi
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
@@ -7750,7 +7361,18 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wwrite-strings option" >&5
$as_echo_n "checking whether the compiler supports the -Wwrite-strings option... " >&6; }
save_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors -Wwrite-strings"
+ if expr "x-Wwrite-strings" : "x-W.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wwrite-strings"
+ elif expr "x-Wwrite-strings" : "x-f.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -Wwrite-strings"
+ elif expr "x-Wwrite-strings" : "x-m.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -Wwrite-strings"
+ else
+ CFLAGS="$CFLAGS -Wwrite-strings"
+ fi
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
@@ -7782,7 +7404,18 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wpointer-arith option" >&5
$as_echo_n "checking whether the compiler supports the -Wpointer-arith option... " >&6; }
save_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors -Wpointer-arith"
+ if expr "x-Wpointer-arith" : "x-W.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wpointer-arith"
+ elif expr "x-Wpointer-arith" : "x-f.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -Wpointer-arith"
+ elif expr "x-Wpointer-arith" : "x-m.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -Wpointer-arith"
+ else
+ CFLAGS="$CFLAGS -Wpointer-arith"
+ fi
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
@@ -7811,10 +7444,279 @@ fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wcast-qual option" >&5
+$as_echo_n "checking whether the compiler supports the -Wcast-qual option... " >&6; }
+ save_CFLAGS="$CFLAGS"
+ if expr "x-Wcast-qual" : "x-W.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wcast-qual"
+ elif expr "x-Wcast-qual" : "x-f.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -Wcast-qual"
+ elif expr "x-Wcast-qual" : "x-m.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -Wcast-qual"
+ else
+ CFLAGS="$CFLAGS -Wcast-qual"
+ fi
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+return 0
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+ CFLAGS="$save_CFLAGS"
+ V_CCOPT="$V_CCOPT -Wcast-qual"
+
+else
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ CFLAGS="$save_CFLAGS"
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wshadow option" >&5
+$as_echo_n "checking whether the compiler supports the -Wshadow option... " >&6; }
+ save_CFLAGS="$CFLAGS"
+ if expr "x-Wshadow" : "x-W.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wshadow"
+ elif expr "x-Wshadow" : "x-f.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -Wshadow"
+ elif expr "x-Wshadow" : "x-m.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -Wshadow"
+ else
+ CFLAGS="$CFLAGS -Wshadow"
+ fi
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+return 0
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+ CFLAGS="$save_CFLAGS"
+ V_CCOPT="$V_CCOPT -Wshadow"
+
+else
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ CFLAGS="$save_CFLAGS"
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wdeclaration-after-statement option" >&5
+$as_echo_n "checking whether the compiler supports the -Wdeclaration-after-statement option... " >&6; }
+ save_CFLAGS="$CFLAGS"
+ if expr "x-Wdeclaration-after-statement" : "x-W.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wdeclaration-after-statement"
+ elif expr "x-Wdeclaration-after-statement" : "x-f.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -Wdeclaration-after-statement"
+ elif expr "x-Wdeclaration-after-statement" : "x-m.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -Wdeclaration-after-statement"
+ else
+ CFLAGS="$CFLAGS -Wdeclaration-after-statement"
+ fi
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+return 0
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+ CFLAGS="$save_CFLAGS"
+ V_CCOPT="$V_CCOPT -Wdeclaration-after-statement"
+
+else
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ CFLAGS="$save_CFLAGS"
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wpedantic option" >&5
+$as_echo_n "checking whether the compiler supports the -Wpedantic option... " >&6; }
+ save_CFLAGS="$CFLAGS"
+ if expr "x-Wpedantic" : "x-W.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wpedantic"
+ elif expr "x-Wpedantic" : "x-f.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -Wpedantic"
+ elif expr "x-Wpedantic" : "x-m.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -Wpedantic"
+ else
+ CFLAGS="$CFLAGS -Wpedantic"
+ fi
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+return 0
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+ CFLAGS="$save_CFLAGS"
+ V_CCOPT="$V_CCOPT -Wpedantic"
+
+else
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ CFLAGS="$save_CFLAGS"
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wold-style-definition option" >&5
+$as_echo_n "checking whether the compiler supports the -Wold-style-definition option... " >&6; }
+ save_CFLAGS="$CFLAGS"
+ if expr "x-Wold-style-definition" : "x-W.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wold-style-definition"
+ elif expr "x-Wold-style-definition" : "x-f.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -Wold-style-definition"
+ elif expr "x-Wold-style-definition" : "x-m.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -Wold-style-definition"
+ else
+ CFLAGS="$CFLAGS -Wold-style-definition"
+ fi
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+return 0
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+ CFLAGS="$save_CFLAGS"
+ V_CCOPT="$V_CCOPT -Wold-style-definition"
+
+else
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ CFLAGS="$save_CFLAGS"
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wused-but-marked-unused option" >&5
+$as_echo_n "checking whether the compiler supports the -Wused-but-marked-unused option... " >&6; }
+ save_CFLAGS="$CFLAGS"
+ if expr "x-Wused-but-marked-unused" : "x-W.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wused-but-marked-unused"
+ elif expr "x-Wused-but-marked-unused" : "x-f.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -Wused-but-marked-unused"
+ elif expr "x-Wused-but-marked-unused" : "x-m.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -Wused-but-marked-unused"
+ else
+ CFLAGS="$CFLAGS -Wused-but-marked-unused"
+ fi
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+return 0
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+ CFLAGS="$save_CFLAGS"
+ V_CCOPT="$V_CCOPT -Wused-but-marked-unused"
+
+else
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ CFLAGS="$save_CFLAGS"
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -W option" >&5
$as_echo_n "checking whether the compiler supports the -W option... " >&6; }
save_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors -W"
+ if expr "x-W" : "x-W.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -W"
+ elif expr "x-W" : "x-f.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -W"
+ elif expr "x-W" : "x-m.*" >/dev/null
+ then
+ CFLAGS="$CFLAGS -Werror -W"
+ else
+ CFLAGS="$CFLAGS -W"
+ fi
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
@@ -8092,45 +7994,9 @@ $as_echo "#define LBL_ALIGN 1" >>confdefs.h
fi
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for h_errno" >&5
-$as_echo_n "checking for h_errno... " >&6; }
- if ${ac_cv_var_h_errno+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-# include <sys/types.h>
-# include <netdb.h>
-int
-main ()
-{
-int foo = h_errno;
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- ac_cv_var_h_errno=yes
-else
- ac_cv_var_h_errno=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_var_h_errno" >&5
-$as_echo "$ac_cv_var_h_errno" >&6; }
- if test "$ac_cv_var_h_errno" = "yes"; then
-
-$as_echo "#define HAVE_H_ERRNO 1" >>confdefs.h
-
- fi
-
-
-# Check for OpenSSL libcrypto
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use OpenSSL libcrypto" >&5
-$as_echo_n "checking whether to use OpenSSL libcrypto... " >&6; }
+# Check for OpenSSL/libressl libcrypto
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use OpenSSL/libressl libcrypto" >&5
+$as_echo_n "checking whether to use OpenSSL/libressl libcrypto... " >&6; }
# Specify location for both includes and libraries.
want_libcrypto=ifavailable
@@ -8139,20 +8005,38 @@ if test "${with_crypto+set}" = set; then :
withval=$with_crypto;
if test $withval = no
then
+ # User doesn't want to link with libcrypto.
want_libcrypto=no
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
elif test $withval = yes
then
+ # User wants to link with libcrypto but hasn't specified
+ # a directory.
want_libcrypto=yes
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
+ else
+ # User wants to link with libcrypto and has specified
+ # a directory, so use the provided value.
+ want_libcrypto=yes
+ libcrypto_root=$withval
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes, using the version installed in $withval" >&5
+$as_echo "yes, using the version installed in $withval" >&6; }
+
+ #
+ # Put the subdirectories of the libcrypto root directory
+ # at the front of the header and library search path.
+ #
+ CFLAGS="-I$withval/include $CFLAGS"
+ LIBS="-L$withval/lib $LIBS"
fi
else
#
- # Use libcrypto if it's present, otherwise don't.
+ # Use libcrypto if it's present, otherwise don't; no directory
+ # was specified.
#
want_libcrypto=ifavailable
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes, if available" >&5
@@ -8161,7 +8045,19 @@ $as_echo "yes, if available" >&6; }
fi
if test "$want_libcrypto" != "no"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for DES_cbc_encrypt in -lcrypto" >&5
+ #
+ # Don't check for libcrypto unless we have its headers;
+ # Apple, bless their pointy little heads, apparently ship
+ # libcrypto as a library, but not the header files, in
+ # El Capitan, probably because they don't want you writing
+ # nasty portable code that could run on other UN*Xes, they
+ # want you writing code that uses their Shiny New Crypto
+ # Library and that only runs on OS X.
+ #
+ ac_fn_c_check_header_mongrel "$LINENO" "openssl/crypto.h" "ac_cv_header_openssl_crypto_h" "$ac_includes_default"
+if test "x$ac_cv_header_openssl_crypto_h" = xyes; then :
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for DES_cbc_encrypt in -lcrypto" >&5
$as_echo_n "checking for DES_cbc_encrypt in -lcrypto... " >&6; }
if ${ac_cv_lib_crypto_DES_cbc_encrypt+:} false; then :
$as_echo_n "(cached) " >&6
@@ -8206,7 +8102,8 @@ _ACEOF
fi
- for ac_header in openssl/evp.h
+ if test "$ac_cv_lib_crypto_DES_cbc_encrypt" = "yes"; then
+ for ac_header in openssl/evp.h
do :
ac_fn_c_check_header_mongrel "$LINENO" "openssl/evp.h" "ac_cv_header_openssl_evp_h" "$ac_includes_default"
if test "x$ac_cv_header_openssl_evp_h" = xyes; then :
@@ -8218,6 +8115,28 @@ fi
done
+ #
+ # OK, do we have EVP_CIPHER_CTX_new?
+ # If so, we use it to allocate an
+ # EVP_CIPHER_CTX, as EVP_CIPHER_CTX may be
+ # opaque; otherwise, we allocate it ourselves.
+ #
+ for ac_func in EVP_CIPHER_CTX_new
+do :
+ ac_fn_c_check_func "$LINENO" "EVP_CIPHER_CTX_new" "ac_cv_func_EVP_CIPHER_CTX_new"
+if test "x$ac_cv_func_EVP_CIPHER_CTX_new" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_EVP_CIPHER_CTX_NEW 1
+_ACEOF
+
+fi
+done
+
+ fi
+
+fi
+
+
fi
# Check for libcap-ng
diff --git a/contrib/tcpdump/configure.in b/contrib/tcpdump/configure.in
index b5ac48f..a78a126 100644
--- a/contrib/tcpdump/configure.in
+++ b/contrib/tcpdump/configure.in
@@ -37,7 +37,13 @@ AC_CHECK_HEADERS(net/pfvar.h, , , [#include <sys/types.h>
#include <sys/socket.h>
#include <net/if.h>])
if test "$ac_cv_header_net_pfvar_h" = yes; then
- LOCALSRC="print-pflog.c $LOCALSRC"
+ AC_CHECK_HEADERS(net/if_pflog.h, , , [#include <sys/types.h>
+ #include <sys/socket.h>
+ #include <net/if.h>
+ #include <net/pfvar.h>])
+ if test "$ac_cv_header_net_if_pflog_h" = yes; then
+ LOCALSRC="print-pflog.c $LOCALSRC"
+ fi
fi
AC_CHECK_HEADERS(netinet/if_ether.h, , , [#include <sys/types.h>
#include <sys/socket.h>])
@@ -169,7 +175,7 @@ AC_ARG_ENABLE(smb,
case "$enableval" in
yes) AC_MSG_RESULT(yes)
AC_WARN([The SMB printer may have exploitable buffer overflows!!!])
- AC_DEFINE(TCPDUMP_DO_SMB, 1,
+ AC_DEFINE(ENABLE_SMB, 1,
[define if you want to build the possibly-buggy SMB printer])
LOCALSRC="print-smb.c smbutil.c $LOCALSRC"
;;
@@ -222,39 +228,31 @@ if test ! -z "$with_sandbox-capsicum" && test "$with_sandbox-capsicum" != "no" ;
fi
AC_MSG_CHECKING([whether to sandbox using capsicum])
if test "x$ac_lbl_capsicum_function_seen" = "xyes" -a "x$ac_lbl_capsicum_function_not_seen" != "xyes"; then
- AC_DEFINE(HAVE_CASPER, 1, [casper support available])
+ AC_DEFINE(HAVE_CAPSICUM, 1, [capsicum support available])
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
fi
#
-# We must check this before checking whether to enable IPv6, because,
-# on some platforms (such as SunOS 5.x), the test program requires
-# the extra networking libraries.
+# We must check this before checking whether to check the OS's IPv6,
+# support because, on some platforms (such as SunOS 5.x), the test
+# program requires the extra networking libraries.
#
AC_LBL_LIBRARY_NET
-AC_MSG_CHECKING([whether to enable ipv6])
-AC_ARG_ENABLE(ipv6,
-[ --enable-ipv6 enable ipv6 (with ipv4) support
- --disable-ipv6 disable ipv6 support],
-[ case "$enableval" in
-yes) AC_MSG_RESULT(yes)
- LOCALSRC="print-ip6opts.c print-mobility.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c print-babel.c $LOCALSRC"
- AC_DEFINE(INET6, 1, [Define if you enable IPv6 support])
- ipv6=yes
- ;;
-*)
- AC_MSG_RESULT(no)
- ipv6=no
- ;;
- esac ],
-
- AC_COMPILE_IFELSE(
+#
+# Check whether AF_INET6 and struct in6_addr are defined.
+# If they aren't both defined, we don't have sufficient OS
+# support for IPv6, so we don't look for IPv6 support libraries,
+# and we define AF_INET6 and struct in6_addr ourselves.
+#
+AC_MSG_CHECKING([whether the operating system supports IPv6])
+AC_COMPILE_IFELSE(
[
AC_LANG_SOURCE(
- [[/* AF_INET6 available check */
+ [[
+/* AF_INET6 available check */
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
@@ -267,17 +265,19 @@ foo(struct in6_addr *addr)
#else
#error "AF_INET6 not defined"
#endif
- ]])
+ ]])
+ ],
+ [
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_OS_IPV6_SUPPORT, 1,
+ [define if the OS provides AF_INET6 and struct in6_addr])
+ ipv6=yes
],
-[ AC_MSG_RESULT(yes)
- LOCALSRC="print-ip6opts.c print-mobility.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c print-babel.c $LOCALSRC"
- AC_DEFINE(INET6, 1, [Define if you enable IPv6 support])
- ipv6=yes],
-[ AC_MSG_RESULT(no)
- ipv6=no],
-[ AC_MSG_RESULT(no)
- ipv6=no]
-))
+ [
+ AC_MSG_RESULT(no)
+ ipv6=no
+ ]
+)
ipv6type=unknown
ipv6lib=none
@@ -294,8 +294,7 @@ if test "$ipv6" = "yes"; then
#ifdef IPV6_INRIA_VERSION
yes
#endif],
- [ipv6type=$i;
- CFLAGS="-DINET6 $CFLAGS"])
+ [ipv6type=$i])
;;
kame)
dnl http://www.kame.net/
@@ -307,8 +306,7 @@ yes
[ipv6type=$i;
ipv6lib=inet6;
ipv6libdir=/usr/local/v6/lib;
- ipv6trylibc=yes;
- CFLAGS="-DINET6 $CFLAGS"])
+ ipv6trylibc=yes])
;;
linux-glibc)
dnl http://www.v6.linux.or.jp/
@@ -317,8 +315,7 @@ yes
#if defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1
yes
#endif],
- [ipv6type=$i;
- CFLAGS="-DINET6 $CFLAGS"])
+ [ipv6type=$i])
;;
linux-libinet6)
dnl http://www.v6.linux.or.jp/
@@ -331,7 +328,7 @@ yes
ipv6lib=inet6
ipv6libdir=/usr/inet6/lib
ipv6trylibc=yes;
- CFLAGS="-DINET6 -I/usr/inet6/include $CFLAGS"
+ CFLAGS="-I/usr/inet6/include $CFLAGS"
fi
;;
toshiba)
@@ -342,8 +339,7 @@ yes
#endif],
[ipv6type=$i;
ipv6lib=inet6;
- ipv6libdir=/usr/local/v6/lib;
- CFLAGS="-DINET6 $CFLAGS"])
+ ipv6libdir=/usr/local/v6/lib])
;;
v6d)
AC_EGREP_CPP(yes,
@@ -364,8 +360,7 @@ yes
#endif],
[ipv6type=$i;
ipv6lib=inet6;
- ipv6libdir=/usr/local/v6/lib;
- CFLAGS="-DINET6 $CFLAGS"])
+ ipv6libdir=/usr/local/v6/lib])
;;
esac
if test "$ipv6type" != "unknown"; then
@@ -391,151 +386,6 @@ if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
fi
fi
-
-if test "$ipv6" = "yes"; then
- #
- # XXX - on Tru64 UNIX 5.1, there is no "getaddrinfo()"
- # function in libc; there are "ngetaddrinfo()" and
- # "ogetaddrinfo()" functions, and <netdb.h> #defines
- # "getaddrinfo" to be either "ngetaddrinfo" or
- # "ogetaddrinfo", depending on whether _SOCKADDR_LEN
- # or _XOPEN_SOURCE_EXTENDED are defined or not.
- #
- # So this test doesn't work on Tru64 5.1, and possibly
- # on other 5.x releases. This causes the configure
- # script to become confused, and results in libpcap
- # being unbuildable.
- #
- AC_SEARCH_LIBS(getaddrinfo, socket, [dnl
- AC_MSG_CHECKING(getaddrinfo bug)
- AC_CACHE_VAL(td_cv_buggygetaddrinfo, [AC_TRY_RUN([
-#include <sys/types.h>
-#include <netdb.h>
-#include <string.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-
-main()
-{
- int passive, gaierr, inet4 = 0, inet6 = 0;
- struct addrinfo hints, *ai, *aitop;
- char straddr[INET6_ADDRSTRLEN], strport[16];
-
- for (passive = 0; passive <= 1; passive++) {
- memset(&hints, 0, sizeof(hints));
- hints.ai_family = AF_UNSPEC;
- hints.ai_flags = passive ? AI_PASSIVE : 0;
- hints.ai_socktype = SOCK_STREAM;
- hints.ai_protocol = IPPROTO_TCP;
- if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
- (void)gai_strerror(gaierr);
- goto bad;
- }
- for (ai = aitop; ai; ai = ai->ai_next) {
- if (ai->ai_addr == NULL ||
- ai->ai_addrlen == 0 ||
- getnameinfo(ai->ai_addr, ai->ai_addrlen,
- straddr, sizeof(straddr), strport, sizeof(strport),
- NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
- goto bad;
- }
- switch (ai->ai_family) {
- case AF_INET:
- if (strcmp(strport, "54321") != 0) {
- goto bad;
- }
- if (passive) {
- if (strcmp(straddr, "0.0.0.0") != 0) {
- goto bad;
- }
- } else {
- if (strcmp(straddr, "127.0.0.1") != 0) {
- goto bad;
- }
- }
- inet4++;
- break;
- case AF_INET6:
- if (strcmp(strport, "54321") != 0) {
- goto bad;
- }
- if (passive) {
- if (strcmp(straddr, "::") != 0) {
- goto bad;
- }
- } else {
- if (strcmp(straddr, "::1") != 0) {
- goto bad;
- }
- }
- inet6++;
- break;
- case AF_UNSPEC:
- goto bad;
- break;
-#ifdef AF_UNIX
- case AF_UNIX:
-#else
-#ifdef AF_LOCAL
- case AF_LOCAL:
-#endif
-#endif
- default:
- /* another family support? */
- break;
- }
- }
- }
-
- /* supported family should be 2, unsupported family should be 0 */
- if (!(inet4 == 0 || inet4 == 2))
- goto bad;
- if (!(inet6 == 0 || inet6 == 2))
- goto bad;
-
- if (aitop)
- freeaddrinfo(aitop);
- exit(0);
-
- bad:
- if (aitop)
- freeaddrinfo(aitop);
- exit(1);
-}
-],
- td_cv_buggygetaddrinfo=no,
- td_cv_buggygetaddrinfo=yes,
- td_cv_buggygetaddrinfo=unknown)])
- if test "$td_cv_buggygetaddrinfo" = no; then
- AC_MSG_RESULT(good)
- elif test "$td_cv_buggygetaddrinfo" = unknown; then
- AC_MSG_RESULT([unknown (cross-compiling)])
- else
- AC_MSG_RESULT(buggy)
- fi
-
- if test "$td_cv_buggygetaddrinfo" = "yes"; then
- #
- # XXX - it doesn't appear that "ipv6type" can ever be
- # set to "linux". Should this be testing for
- # "linux-glibc", or for that *or* "linux-libinet6"?
- # If the latter, note that "linux-libinet6" is also
- # the type given to some non-Linux OSes.
- #
- if test "$ipv6type" != "linux"; then
- echo 'Fatal: You must get working getaddrinfo() function.'
- echo ' or you can specify "--disable-ipv6"'.
- exit 1
- else
- echo 'Warning: getaddrinfo() implementation on your system seems be buggy.'
- echo ' Better upgrade your system library to newest version'
- echo ' of GNU C library (aka glibc).'
- fi
- fi
- ])
- AC_REPLACE_FUNCS(getnameinfo)
-fi
-
AC_CACHE_CHECK([for dnet_htoa declaration in netdnet/dnetdb.h],
[td_cv_decl_netdnet_dnetdb_h_dnet_htoa],
[AC_EGREP_HEADER(dnet_htoa, netdnet/dnetdb.h,
@@ -546,28 +396,7 @@ if test "$td_cv_decl_netdnet_dnetdb_h_dnet_htoa" = yes; then
[define if you have a dnet_htoa declaration in <netdnet/dnetdb.h>])
fi
-dnl
-dnl Checks for addrinfo structure
-AC_STRUCT_ADDRINFO(ac_cv_addrinfo)
-if test "$ac_cv_addrinfo" = no; then
- missing_includes=yes
-fi
-
-dnl
-dnl Checks for NI_MAXSERV
-AC_NI_MAXSERV(ac_cv_maxserv)
-if test "$ac_cv_maxserv" = no; then
- missing_includes=yes
-fi
-
-dnl
-dnl Checks for NI_NAMEREQD
-AC_NI_NAMEREQD(ac_cv_namereqd)
-if test "$ac_cv_namereqd" = no; then
- missing_includes=yes
-fi
-
-AC_REPLACE_FUNCS(vfprintf strcasecmp strlcat strlcpy strdup strsep getopt_long)
+AC_REPLACE_FUNCS(vfprintf strlcat strlcpy strdup strsep getopt_long)
AC_CHECK_FUNCS(fork vfork strftime)
AC_CHECK_FUNCS(setlinebuf alarm)
@@ -589,52 +418,12 @@ dnl Some platforms may need -lnsl for getrpcbynumber.
AC_SEARCH_LIBS(getrpcbynumber, nsl,
AC_DEFINE(HAVE_GETRPCBYNUMBER, 1, [define if you have getrpcbynumber()]))
-dnl AC_CHECK_LIB(z, uncompress)
-dnl AC_CHECK_HEADERS(zlib.h)
-
AC_LBL_LIBPCAP(V_PCAPDEP, V_INCLS)
#
# Check for these after AC_LBL_LIBPCAP, so we link with the appropriate
# libraries (e.g., "-lsocket -lnsl" on Solaris).
#
-# We don't use AC_REPLACE_FUNCS because that uses AC_CHECK_FUNCS which
-# use AC_CHECK_FUNC which doesn't let us specify the right #includes
-# to make this work on BSD/OS 4.x. BSD/OS 4.x ships with the BIND8
-# resolver, and the way it defines inet_{ntop,pton} is rather strange;
-# it does not ship with a libc symbol "inet_ntop()", it ships with
-# "_inet_ntop()", and has a #define macro in one of the system headers
-# to rename it.
-#
-dnl AC_TRY_COMPILE(inet_ntop inet_pton inet_aton)
-AC_MSG_CHECKING(for inet_ntop)
-AC_TRY_LINK([#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>], [char src[4], dst[128];
-inet_ntop(AF_INET, src, dst, sizeof(dst));],
- [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)
- AC_LIBOBJ(inet_ntop)])
-AC_MSG_CHECKING(for inet_pton)
-AC_TRY_LINK([#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>], [char src[128], dst[4];
-inet_pton(AF_INET, src, dst);],
- [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)
- AC_LIBOBJ(inet_pton)])
-AC_MSG_CHECKING(for inet_aton)
-AC_TRY_LINK([#include <sys/types.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>], [char src[128];
-struct in_addr dst;
-inet_aton(src, &dst);],
- [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)
- AC_LIBOBJ(inet_aton)])
-
-#
-# Check for these after AC_LBL_LIBPCAP, for the same reason.
-#
# You are in a twisty little maze of UN*Xes, all different.
# Some might not have ether_ntohost().
# Some might have it, but not declare it in any header file.
@@ -753,14 +542,6 @@ fi
# libdlpi is needed for Solaris 11 and later.
AC_CHECK_LIB(dlpi, dlpi_walk, LIBS="$LIBS -ldlpi" LDFLAGS="-L/lib $LDFLAGS", ,-L/lib)
-dnl portability macros for getaddrinfo/getnameinfo
-dnl
-dnl Check for sa_len
-AC_CHECK_SA_LEN(ac_cv_sockaddr_has_sa_len)
-if test "$ac_cv_sockaddr_has_sa_len" = no; then
- missing_includes=yes
-fi
-
dnl
dnl Check for "pcap_list_datalinks()", "pcap_set_datalink()",
dnl and "pcap_datalink_name_to_val()", and use substitute versions
@@ -860,39 +641,51 @@ if test $ac_cv_func_pcap_lib_version = "no" ; then
AC_MSG_RESULT(no)
fi
fi
-AC_MSG_CHECKING(whether pcap_debug is defined by libpcap)
-AC_TRY_LINK([],
- [
- extern int pcap_debug;
-
- return pcap_debug;
- ],
- ac_lbl_cv_pcap_debug_defined=yes,
- ac_lbl_cv_pcap_debug_defined=no)
-if test "$ac_lbl_cv_pcap_debug_defined" = yes ; then
- AC_MSG_RESULT(yes)
- AC_DEFINE(HAVE_PCAP_DEBUG, 1, [define if libpcap has pcap_debug])
-else
- AC_MSG_RESULT(no)
- #
- # OK, what about "yydebug"?
+
+#
+# Check for special debugging functions
+#
+AC_CHECK_FUNCS(pcap_set_parser_debug)
+if test "$ac_cv_func_pcap_set_parser_debug" = "no" ; then
#
- AC_MSG_CHECKING(whether yydebug is defined by libpcap)
+ # OK, we don't have pcap_set_parser_debug() to set the libpcap
+ # filter expression parser debug flag; can we directly set the
+ # flag?
+ AC_MSG_CHECKING(whether pcap_debug is defined by libpcap)
AC_TRY_LINK([],
[
- extern int yydebug;
+ extern int pcap_debug;
- return yydebug;
+ return pcap_debug;
],
- ac_lbl_cv_yydebug_defined=yes,
- ac_lbl_cv_yydebug_defined=no)
- if test "$ac_lbl_cv_yydebug_defined" = yes ; then
+ ac_lbl_cv_pcap_debug_defined=yes,
+ ac_lbl_cv_pcap_debug_defined=no)
+ if test "$ac_lbl_cv_pcap_debug_defined" = yes ; then
AC_MSG_RESULT(yes)
- AC_DEFINE(HAVE_YYDEBUG, 1, [define if libpcap has yydebug])
+ AC_DEFINE(HAVE_PCAP_DEBUG, 1, [define if libpcap has pcap_debug])
else
AC_MSG_RESULT(no)
+ #
+ # OK, what about "yydebug"?
+ #
+ AC_MSG_CHECKING(whether yydebug is defined by libpcap)
+ AC_TRY_LINK([],
+ [
+ extern int yydebug;
+
+ return yydebug;
+ ],
+ ac_lbl_cv_yydebug_defined=yes,
+ ac_lbl_cv_yydebug_defined=no)
+ if test "$ac_lbl_cv_yydebug_defined" = yes ; then
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_YYDEBUG, 1, [define if libpcap has yydebug])
+ else
+ AC_MSG_RESULT(no)
+ fi
fi
fi
+AC_CHECK_FUNCS(pcap_set_optimizer_debug)
AC_REPLACE_FUNCS(bpf_dump) dnl moved to libpcap in 0.6
V_GROUP=0
@@ -1071,9 +864,9 @@ fi
#
savedcppflags="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $V_INCLS"
-AC_CHECK_HEADERS(pcap/bluetooth.h,,,[#include "tcpdump-stdinc.h"])
-AC_CHECK_HEADERS(pcap/nflog.h,,,[#include "tcpdump-stdinc.h"])
-AC_CHECK_HEADERS(pcap/usb.h,,,[#include "tcpdump-stdinc.h"])
+AC_CHECK_HEADERS(pcap/bluetooth.h,,,[#include "netdissect-stdinc.h"])
+AC_CHECK_HEADERS(pcap/nflog.h,,,[#include "netdissect-stdinc.h"])
+AC_CHECK_HEADERS(pcap/usb.h,,,[#include "netdissect-stdinc.h"])
CPPFLAGS="$savedcppflags"
AC_PROG_RANLIB
@@ -1085,35 +878,71 @@ AC_LBL_SOCKADDR_SA_LEN
AC_LBL_UNALIGNED_ACCESS
-AC_VAR_H_ERRNO
-
-# Check for OpenSSL libcrypto
-AC_MSG_CHECKING(whether to use OpenSSL libcrypto)
+# Check for OpenSSL/libressl libcrypto
+AC_MSG_CHECKING(whether to use OpenSSL/libressl libcrypto)
# Specify location for both includes and libraries.
want_libcrypto=ifavailable
AC_ARG_WITH(crypto,
- AS_HELP_STRING([--with-crypto],
- [use OpenSSL libcrypto @<:@default=yes, if available@:>@]),
+ AS_HELP_STRING([--with-crypto]@<:@=DIR@:>@,
+ [use OpenSSL/libressl libcrypto (located in directory DIR, if specified) @<:@default=yes, if available@:>@]),
[
if test $withval = no
then
+ # User doesn't want to link with libcrypto.
want_libcrypto=no
AC_MSG_RESULT(no)
elif test $withval = yes
then
+ # User wants to link with libcrypto but hasn't specified
+ # a directory.
want_libcrypto=yes
AC_MSG_RESULT(yes)
+ else
+ # User wants to link with libcrypto and has specified
+ # a directory, so use the provided value.
+ want_libcrypto=yes
+ libcrypto_root=$withval
+ AC_MSG_RESULT([yes, using the version installed in $withval])
+
+ #
+ # Put the subdirectories of the libcrypto root directory
+ # at the front of the header and library search path.
+ #
+ CFLAGS="-I$withval/include $CFLAGS"
+ LIBS="-L$withval/lib $LIBS"
fi
],[
#
- # Use libcrypto if it's present, otherwise don't.
+ # Use libcrypto if it's present, otherwise don't; no directory
+ # was specified.
#
want_libcrypto=ifavailable
AC_MSG_RESULT([yes, if available])
])
if test "$want_libcrypto" != "no"; then
- AC_CHECK_LIB(crypto, DES_cbc_encrypt)
- AC_CHECK_HEADERS(openssl/evp.h)
+ #
+ # Don't check for libcrypto unless we have its headers;
+ # Apple, bless their pointy little heads, apparently ship
+ # libcrypto as a library, but not the header files, in
+ # El Capitan, probably because they don't want you writing
+ # nasty portable code that could run on other UN*Xes, they
+ # want you writing code that uses their Shiny New Crypto
+ # Library and that only runs on OS X.
+ #
+ AC_CHECK_HEADER(openssl/crypto.h,
+ [
+ AC_CHECK_LIB(crypto, DES_cbc_encrypt)
+ if test "$ac_cv_lib_crypto_DES_cbc_encrypt" = "yes"; then
+ AC_CHECK_HEADERS(openssl/evp.h)
+ #
+ # OK, do we have EVP_CIPHER_CTX_new?
+ # If so, we use it to allocate an
+ # EVP_CIPHER_CTX, as EVP_CIPHER_CTX may be
+ # opaque; otherwise, we allocate it ourselves.
+ #
+ AC_CHECK_FUNCS(EVP_CIPHER_CTX_new)
+ fi
+ ])
fi
# Check for libcap-ng
diff --git a/contrib/tcpdump/cpack.c b/contrib/tcpdump/cpack.c
index 16bfd15..e37d813 100644
--- a/contrib/tcpdump/cpack.c
+++ b/contrib/tcpdump/cpack.c
@@ -27,20 +27,19 @@
* OF SUCH DAMAGE.
*/
-#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <string.h>
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include "cpack.h"
#include "extract.h"
-uint8_t *
-cpack_next_boundary(uint8_t *buf, uint8_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;
@@ -54,10 +53,10 @@ cpack_next_boundary(uint8_t *buf, uint8_t *p, size_t alignment)
* wordsize bytes remain in the buffer after the boundary. Otherwise,
* return a pointer to the boundary.
*/
-uint8_t *
+const uint8_t *
cpack_align_and_reserve(struct cpack_state *cs, size_t wordsize)
{
- uint8_t *next;
+ const uint8_t *next;
/* Ensure alignment. */
next = cpack_next_boundary(cs->c_buf, cs->c_next, wordsize);
@@ -81,7 +80,7 @@ cpack_advance(struct cpack_state *cs, const size_t toskip)
}
int
-cpack_init(struct cpack_state *cs, uint8_t *buf, size_t buflen)
+cpack_init(struct cpack_state *cs, const uint8_t *buf, size_t buflen)
{
memset(cs, 0, sizeof(*cs));
@@ -96,7 +95,7 @@ cpack_init(struct cpack_state *cs, uint8_t *buf, size_t buflen)
int
cpack_uint64(struct cpack_state *cs, uint64_t *u)
{
- uint8_t *next;
+ const uint8_t *next;
if ((next = cpack_align_and_reserve(cs, sizeof(*u))) == NULL)
return -1;
@@ -112,7 +111,7 @@ cpack_uint64(struct cpack_state *cs, uint64_t *u)
int
cpack_uint32(struct cpack_state *cs, uint32_t *u)
{
- uint8_t *next;
+ const uint8_t *next;
if ((next = cpack_align_and_reserve(cs, sizeof(*u))) == NULL)
return -1;
@@ -128,7 +127,7 @@ cpack_uint32(struct cpack_state *cs, uint32_t *u)
int
cpack_uint16(struct cpack_state *cs, uint16_t *u)
{
- uint8_t *next;
+ const uint8_t *next;
if ((next = cpack_align_and_reserve(cs, sizeof(*u))) == NULL)
return -1;
diff --git a/contrib/tcpdump/cpack.h b/contrib/tcpdump/cpack.h
index a7eb6d6..3072e0c 100644
--- a/contrib/tcpdump/cpack.h
+++ b/contrib/tcpdump/cpack.h
@@ -31,20 +31,20 @@
#define _CPACK_H
struct cpack_state {
- uint8_t *c_buf;
- uint8_t *c_next;
+ const uint8_t *c_buf;
+ const uint8_t *c_next;
size_t c_len;
};
-int cpack_init(struct cpack_state *, uint8_t *, size_t);
+int cpack_init(struct cpack_state *, const uint8_t *, size_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 *);
-uint8_t *cpack_next_boundary(uint8_t *buf, uint8_t *p, size_t alignment);
-uint8_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), (uint8_t*)(__p))
#define cpack_int16(__s, __p) cpack_uint16((__s), (uint16_t*)(__p))
diff --git a/contrib/tcpdump/ether.h b/contrib/tcpdump/ether.h
index 58b92de5..6491678 100644
--- a/contrib/tcpdump/ether.h
+++ b/contrib/tcpdump/ether.h
@@ -41,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 {
uint8_t ether_dhost[ETHER_ADDR_LEN];
uint8_t ether_shost[ETHER_ADDR_LEN];
- uint16_t ether_type;
+ 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/contrib/tcpdump/ethertype.h b/contrib/tcpdump/ethertype.h
index e855221..2aa53a0 100644
--- a/contrib/tcpdump/ethertype.h
+++ b/contrib/tcpdump/ethertype.h
@@ -17,7 +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.
- * $FreeBSD$
*/
/*
@@ -197,5 +196,8 @@
#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/contrib/tcpdump/extract.h b/contrib/tcpdump/extract.h
index cb62ebd..23623c2 100644
--- a/contrib/tcpdump/extract.h
+++ b/contrib/tcpdump/extract.h
@@ -103,7 +103,7 @@ EXTRACT_32BITS(const void *p)
static inline uint64_t
EXTRACT_64BITS(const void *p)
{
- return ((uint64_t)(((uint64_t)ntohl(((const unaligned_uint32_t *)(p) + 0)->val)) << 32 | \
+ 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));
}
@@ -153,7 +153,7 @@ EXTRACT_32BITS(const void *p)
static inline uint64_t
EXTRACT_64BITS(const void *p)
{
- return ((uint64_t)(((uint64_t)ntohl(*((const uint32_t *)(p) + 0))) << 32 | \
+ return ((uint64_t)(((uint64_t)ntohl(*((const uint32_t *)(p) + 0))) << 32 |
((uint64_t)ntohl(*((const uint32_t *)(p) + 1))) << 0));
}
@@ -215,3 +215,30 @@ EXTRACT_64BITS(const void *p)
((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/contrib/tcpdump/getopt_long.h b/contrib/tcpdump/getopt_long.h
index fbb94e6..6eb7dfb 100644
--- a/contrib/tcpdump/getopt_long.h
+++ b/contrib/tcpdump/getopt_long.h
@@ -1,5 +1,5 @@
/* $NetBSD: getopt.h,v 1.4 2000/07/07 10:43:54 ad Exp $ */
-/* $FreeBSD$ */
+/* $FreeBSD: stable/11/contrib/tcpdump/getopt_long.h 276788 2015-01-07 19:55:18Z delphij $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
diff --git a/contrib/tcpdump/gmpls.c b/contrib/tcpdump/gmpls.c
index c9fd9bb..23515e9 100644
--- a/contrib/tcpdump/gmpls.c
+++ b/contrib/tcpdump/gmpls.c
@@ -13,14 +13,13 @@
* Original code by Hannes Gredler (hannes@juniper.net)
*/
-#define NETDISSECT_REWORKED
#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 */
diff --git a/contrib/tcpdump/gmt2local.c b/contrib/tcpdump/gmt2local.c
index 6958f66..d6cd93b 100644
--- a/contrib/tcpdump/gmt2local.c
+++ b/contrib/tcpdump/gmt2local.c
@@ -19,12 +19,11 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <stdio.h>
diff --git a/contrib/tcpdump/in_cksum.c b/contrib/tcpdump/in_cksum.c
index 171728a..e9bed22 100644
--- a/contrib/tcpdump/in_cksum.c
+++ b/contrib/tcpdump/in_cksum.c
@@ -35,14 +35,13 @@
* @(#)in_cksum.c 8.1 (Berkeley) 6/10/93
*/
-#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
# 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).
@@ -74,7 +73,7 @@ in_cksum(const struct cksum_vec *vec, int veclen)
for (; veclen != 0; vec++, veclen--) {
if (vec->len == 0)
continue;
- w = (const uint16_t *)(void *)vec->ptr;
+ w = (const uint16_t *)(const void *)vec->ptr;
if (mlen == -1) {
/*
* The first byte of this chunk is the continuation
@@ -86,18 +85,18 @@ in_cksum(const struct cksum_vec *vec, int veclen)
*/
s_util.c[1] = *(const uint8_t *)w;
sum += s_util.s;
- w = (const uint16_t *)(void *)((const uint8_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 uint8_t *)w;
- w = (const uint16_t *)(void *)((const uint8_t *)w + 1);
+ w = (const uint16_t *)(const void *)((const uint8_t *)w + 1);
mlen--;
byte_swapped = 1;
}
diff --git a/contrib/tcpdump/interface.h b/contrib/tcpdump/interface.h
index 59c1eef..46d338b 100644
--- a/contrib/tcpdump/interface.h
+++ b/contrib/tcpdump/interface.h
@@ -65,165 +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 */
-#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 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
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.
- *
- * 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 TTEST2(var, l) \
- ((uintptr_t)snapend - (l) <= (uintptr_t)snapend && \
- (uintptr_t)&(var) <= (uintptr_t)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 int mask2plen(uint32_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 void error(const char *, ...)
- __attribute__((noreturn))
-#ifdef __ATTRIBUTE___FORMAT_OK
- __attribute__((format (printf, 1, 2)))
-#endif /* __ATTRIBUTE___FORMAT_OK */
- ;
-extern void warning(const char *, ...)
-#ifdef __ATTRIBUTE___FORMAT_OK
- __attribute__((format (printf, 1, 2)))
-#endif /* __ATTRIBUTE___FORMAT_OK */
- ;
-
-extern char *read_infile(char *);
-extern char *copy_argv(char **);
-
-extern const char *dnname_string(u_short);
-extern const char *dnnum_string(u_short);
-
-/* 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);
-
-/* The printer routines. */
-
#include <pcap.h>
-extern char *smb_errstr(int, int);
-extern const char *nt_errstr(uint32_t);
-
-#ifdef INET6
-extern int mask62plen(const u_char *);
-#endif /*INET6*/
-
-struct cksum_vec {
- const uint8_t *ptr;
- int len;
-};
-extern uint16_t in_cksum(const struct cksum_vec *, int);
-extern uint16_t in_cksum_shouldbe(uint16_t, uint16_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
-
-extern void default_print(const u_char *, u_int);
-
-#endif
diff --git a/contrib/tcpdump/ip.h b/contrib/tcpdump/ip.h
index 72c8972..8179061 100644
--- a/contrib/tcpdump/ip.h
+++ b/contrib/tcpdump/ip.h
@@ -33,10 +33,8 @@
* @(#)ip.h 8.2 (Berkeley) 6/1/94
*/
-#ifndef TCPDUMP_IP_H
-#define TCPDUMP_IP_H
-
-#include "tcpdump-stdinc.h"
+#ifndef netdissect_ip_h
+#define netdissect_ip_h
/*
* Definitions for internet protocol version 4.
@@ -52,21 +50,21 @@
* against negative integers quite easily, and fail in subtle ways.
*/
struct ip {
- uint8_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)
- uint8_t ip_tos; /* type of service */
- uint16_t ip_len; /* total length */
- uint16_t ip_id; /* identification */
- uint16_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 */
- uint8_t ip_ttl; /* time to live */
- uint8_t ip_p; /* protocol */
- uint16_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 */
@@ -125,20 +123,20 @@ struct ip {
* Time stamp option structure.
*/
struct ip_timestamp {
- uint8_t ipt_code; /* IPOPT_TS */
- uint8_t ipt_len; /* size of structure (variable) */
- uint8_t ipt_ptr; /* index of current entry */
- uint8_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 {
- uint32_t ipt_time[1];
+ nd_uint32_t ipt_time[1];
struct ipt_ta {
- struct in_addr ipt_addr;
- uint32_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 */
@@ -163,4 +161,4 @@ struct ip_timestamp {
#define IPTTLDEC 1 /* subtracted when forwarding */
#define IP_MSS 576 /* default maximum segment size */
-#endif /* TCPDUMP_IP_H */
+#endif /* netdissect_ip_h */
diff --git a/contrib/tcpdump/ip6.h b/contrib/tcpdump/ip6.h
index 1ad9149..2ea1d0a 100644
--- a/contrib/tcpdump/ip6.h
+++ b/contrib/tcpdump/ip6.h
@@ -172,7 +172,11 @@ struct ip6_rthdr {
/* 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 {
uint8_t ip6r0_nxt; /* next header */
uint8_t ip6r0_len; /* length in units of 8 octets */
@@ -195,7 +199,4 @@ struct ip6_frag {
#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 uint8_t *, u_int, u_int, u_int);
-
#endif /* not _NETINET_IP6_H_ */
diff --git a/contrib/tcpdump/ipproto.c b/contrib/tcpdump/ipproto.c
index 8300d1a..a702acd 100644
--- a/contrib/tcpdump/ipproto.c
+++ b/contrib/tcpdump/ipproto.c
@@ -13,14 +13,13 @@
* Original code by Hannes Gredler (hannes@juniper.net)
*/
-#define NETDISSECT_REWORKED
#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[] = {
diff --git a/contrib/tcpdump/ipproto.h b/contrib/tcpdump/ipproto.h
index 87e2f15..dfc4f46 100644
--- a/contrib/tcpdump/ipproto.h
+++ b/contrib/tcpdump/ipproto.h
@@ -32,8 +32,7 @@
*
* 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: stable/11/contrib/tcpdump/ipproto.h 276788 2015-01-07 19:55:18Z delphij $
*/
extern const struct tok ipproto_values[];
diff --git a/contrib/tcpdump/l2vpn.c b/contrib/tcpdump/l2vpn.c
index 54037aa..3f3639f 100644
--- a/contrib/tcpdump/l2vpn.c
+++ b/contrib/tcpdump/l2vpn.c
@@ -13,42 +13,83 @@
* Original code by Hannes Gredler (hannes@juniper.net)
*/
-#define NETDISSECT_REWORKED
#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}
};
diff --git a/contrib/tcpdump/l2vpn.h b/contrib/tcpdump/l2vpn.h
index 151228f..d93abf1 100644
--- a/contrib/tcpdump/l2vpn.h
+++ b/contrib/tcpdump/l2vpn.h
@@ -14,3 +14,4 @@
*/
extern const struct tok l2vpn_encaps_values[];
+extern const struct tok mpls_pw_types_values[];
diff --git a/contrib/tcpdump/lbl/os-solaris2.h b/contrib/tcpdump/lbl/os-solaris2.h
index 9f94da9..aedba4e 100644
--- a/contrib/tcpdump/lbl/os-solaris2.h
+++ b/contrib/tcpdump/lbl/os-solaris2.h
@@ -25,4 +25,3 @@ int setlinebuf(FILE *);
#endif
char *strerror(int);
int snprintf(char *, size_t, const char *, ...);
-int strcasecmp(const char *, const char *);
diff --git a/contrib/tcpdump/lbl/os-sunos4.h b/contrib/tcpdump/lbl/os-sunos4.h
index b735857..0e63270 100644
--- a/contrib/tcpdump/lbl/os-sunos4.h
+++ b/contrib/tcpdump/lbl/os-sunos4.h
@@ -166,12 +166,10 @@ int sscanf(char *, const char *, ...);
int stat(const char *, struct stat *);
int statfs(char *, struct statfs *);
char *strerror(int);
-int strcasecmp(const char *, const char *);
#ifdef __STDC__
struct tm;
#endif
int strftime(char *, int, char *, struct tm *);
-int strncasecmp(const char *, const char *, int);
long strtol(const char *, char **, int);
void sync(void);
void syslog(int, const char *, ...);
diff --git a/contrib/tcpdump/lbl/os-ultrix4.h b/contrib/tcpdump/lbl/os-ultrix4.h
index fa1f770..891def2 100644
--- a/contrib/tcpdump/lbl/os-ultrix4.h
+++ b/contrib/tcpdump/lbl/os-ultrix4.h
@@ -34,4 +34,3 @@ int ioctl(int, int, caddr_t);
int pfopen(char *, int);
int setlinebuf(FILE *);
int socket(int, int, int);
-int strcasecmp(const char *, const char *);
diff --git a/contrib/tcpdump/machdep.c b/contrib/tcpdump/machdep.c
index 7b259ae..1f08616 100644
--- a/contrib/tcpdump/machdep.c
+++ b/contrib/tcpdump/machdep.c
@@ -29,7 +29,7 @@
* 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)
diff --git a/contrib/tcpdump/machdep.h b/contrib/tcpdump/machdep.h
index d1c7d4b..ba8ed38 100644
--- a/contrib/tcpdump/machdep.h
+++ b/contrib/tcpdump/machdep.h
@@ -18,8 +18,8 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#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/contrib/tcpdump/mib.h b/contrib/tcpdump/mib.h
index 92c6c2c..6c8e63c 100644
--- a/contrib/tcpdump/mib.h
+++ b/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/contrib/tcpdump/missing/addrinfo.h b/contrib/tcpdump/missing/addrinfo.h
deleted file mode 100644
index bf4bbf6..0000000
--- a/contrib/tcpdump/missing/addrinfo.h
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright (C) 1995, 1996, 1997, 1998, and 1999 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.
- */
-
-#ifndef HAVE_ADDRINFO
-
-/*
- * Error return codes from getaddrinfo()
- */
-#define EAI_ADDRFAMILY 1 /* address family for hostname not supported */
-#define EAI_AGAIN 2 /* temporary failure in name resolution */
-#define EAI_BADFLAGS 3 /* invalid value for ai_flags */
-#define EAI_FAIL 4 /* non-recoverable failure in name resolution */
-#define EAI_FAMILY 5 /* ai_family not supported */
-#define EAI_MEMORY 6 /* memory allocation failure */
-#define EAI_NODATA 7 /* no address associated with hostname */
-#define EAI_NONAME 8 /* hostname nor servname provided, or not known */
-#define EAI_SERVICE 9 /* servname not supported for ai_socktype */
-#define EAI_SOCKTYPE 10 /* ai_socktype not supported */
-#define EAI_SYSTEM 11 /* system error returned in errno */
-#define EAI_BADHINTS 12
-#define EAI_PROTOCOL 13
-#define EAI_MAX 14
-
-/* internal error */
-#define NETDB_INTERNAL -1 /* see errno */
-
-/*
- * Flag values for getaddrinfo()
- */
-#define AI_PASSIVE 0x00000001 /* get address to use bind() */
-#define AI_CANONNAME 0x00000002 /* fill ai_canonname */
-#define AI_NUMERICHOST 0x00000004 /* prevent name resolution */
-/* valid flags for addrinfo */
-#define AI_MASK (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST)
-
-#define AI_ALL 0x00000100 /* IPv6 and IPv4-mapped (with AI_V4MAPPED) */
-#define AI_V4MAPPED_CFG 0x00000200 /* accept IPv4-mapped if kernel supports */
-#define AI_ADDRCONFIG 0x00000400 /* only if any address is assigned */
-#define AI_V4MAPPED 0x00000800 /* accept IPv4-mapped IPv6 address */
-/* special recommended flags for getipnodebyname */
-#define AI_DEFAULT (AI_V4MAPPED_CFG | AI_ADDRCONFIG)
-
-struct addrinfo {
- int ai_flags; /* AI_PASSIVE, AI_CANONNAME */
- int ai_family; /* PF_xxx */
- int ai_socktype; /* SOCK_xxx */
- int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
- size_t ai_addrlen; /* length of ai_addr */
- char *ai_canonname; /* canonical name for hostname */
- struct sockaddr *ai_addr; /* binary address */
- struct addrinfo *ai_next; /* next structure in linked list */
-};
-
-extern void freeaddrinfo (struct addrinfo *);
-extern void freehostent (struct hostent *);
-extern int getnameinfo (const struct sockaddr *, size_t, char *,
- size_t, char *, size_t, int);
-extern struct hostent *getipnodebyaddr (const void *, size_t, int, int *);
-extern struct hostent *getipnodebyname (const char *, int, int, int *);
-extern int inet_pton (int, const char *, void *);
-extern const char *inet_ntop (int, const void *, char *, size_t);
-#endif /* HAVE_ADDRINFO */
-
-/*
- * Constants for getnameinfo()
- */
-#ifndef NI_MAXHOST
-#define NI_MAXHOST 1025
-#endif
-#ifndef NI_MAXSERV
-#define NI_MAXSERV 32
-#endif
-
-/*
- * Flag values for getnameinfo()
- */
-#ifndef NI_NOFQDN
-#define NI_NOFQDN 0x00000001
-#endif
-#ifndef NI_NUMERICHOST
-#define NI_NUMERICHOST 0x00000002
-#endif
-#ifndef NI_NAMEREQD
-#define NI_NAMEREQD 0x00000004
-#endif
-#ifndef NI_NUMERICSERV
-#define NI_NUMERICSERV 0x00000008
-#endif
-#ifndef NI_DGRAM
-#define NI_DGRAM 0x00000010
-#endif
diff --git a/contrib/tcpdump/missing/datalinks.c b/contrib/tcpdump/missing/datalinks.c
index e7d526b..4a7d6fe 100644
--- a/contrib/tcpdump/missing/datalinks.c
+++ b/contrib/tcpdump/missing/datalinks.c
@@ -35,7 +35,7 @@
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <pcap.h>
#include <stdlib.h>
diff --git a/contrib/tcpdump/missing/dlnames.c b/contrib/tcpdump/missing/dlnames.c
index a10cd39..16bfcf7 100644
--- a/contrib/tcpdump/missing/dlnames.c
+++ b/contrib/tcpdump/missing/dlnames.c
@@ -35,12 +35,13 @@
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <pcap.h>
#include <string.h>
#include "pcap-missing.h"
+#include "ascii_strcasecmp.h"
struct dlt_choice {
const char *name;
@@ -137,7 +138,7 @@ pcap_datalink_name_to_val(const char *name)
int i;
for (i = 0; dlt_choices[i].name != NULL; i++) {
- if (strcasecmp(dlt_choices[i].name + sizeof("DLT_") - 1,
+ if (ascii_strcasecmp(dlt_choices[i].name + sizeof("DLT_") - 1,
name) == 0)
return (dlt_choices[i].dlt);
}
diff --git a/contrib/tcpdump/missing/getnameinfo.c b/contrib/tcpdump/missing/getnameinfo.c
deleted file mode 100644
index 63aba73..0000000
--- a/contrib/tcpdump/missing/getnameinfo.c
+++ /dev/null
@@ -1,276 +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.
- */
-
-/*
- * Issues to be discussed:
- * - Thread safe-ness must be checked
- * - Return values. There seems to be no standard for return value (RFC2553)
- * but INRIA implementation returns EAI_xxx defined for getaddrinfo().
- * - RFC2553 says that we should raise error on short buffer. X/Open says
- * we need to truncate the result. We obey RFC2553 (and X/Open should be
- * modified).
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <net/if.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <arpa/nameser.h>
-#include <netdb.h>
-#include <resolv.h>
-#include <string.h>
-#include <stddef.h>
-#include <errno.h>
-
-#ifdef NEED_ADDRINFO_H
-#include "addrinfo.h"
-#endif
-
-#define SUCCESS 0
-#define ANY 0
-#define YES 1
-#define NO 0
-
-static struct afd {
- int a_af;
- int a_addrlen;
- int a_socklen;
- int a_off;
-} afdl [] = {
-#ifdef INET6
- {PF_INET6, sizeof(struct in6_addr), sizeof(struct sockaddr_in6),
- offsetof(struct sockaddr_in6, sin6_addr)},
-#endif
- {PF_INET, sizeof(struct in_addr), sizeof(struct sockaddr_in),
- offsetof(struct sockaddr_in, sin_addr)},
- {0, 0, 0},
-};
-
-struct sockinet {
- u_char si_len;
- u_char si_family;
- u_short si_port;
-};
-
-#define ENI_NOSOCKET 0
-#define ENI_NOSERVNAME 1
-#define ENI_NOHOSTNAME 2
-#define ENI_MEMORY 3
-#define ENI_SYSTEM 4
-#define ENI_FAMILY 5
-#define ENI_SALEN 6
-
-int
-getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
- const struct sockaddr *sa;
- size_t salen;
- char *host;
- size_t hostlen;
- char *serv;
- size_t servlen;
- int flags;
-{
- struct afd *afd;
- struct servent *sp;
- struct hostent *hp;
- u_short port;
- int family, i;
- char *addr, *p;
- uint32_t v4a;
- int h_error;
- char numserv[512];
- char numaddr[512];
-
- if (sa == NULL)
- return ENI_NOSOCKET;
-
-#ifdef HAVE_SA_LEN /*XXX*/
- if (sa->sa_len != salen)
- return ENI_SALEN;
-#endif
-
- family = sa->sa_family;
- for (i = 0; afdl[i].a_af; i++)
- if (afdl[i].a_af == family) {
- afd = &afdl[i];
- goto found;
- }
- return ENI_FAMILY;
-
- found:
- if (salen != afd->a_socklen)
- return ENI_SALEN;
-
- port = ((struct sockinet *)sa)->si_port; /* network byte order */
- addr = (char *)sa + afd->a_off;
-
- if (serv == NULL || servlen == 0) {
- /*
- * do nothing in this case.
- * in case you are wondering if "&&" is more correct than
- * "||" here: RFC2553 says that serv == NULL OR servlen == 0
- * means that the caller does not want the result.
- */
- } else {
- if (flags & NI_NUMERICSERV)
- sp = NULL;
- else {
- sp = getservbyport(port,
- (flags & NI_DGRAM) ? "udp" : "tcp");
- }
- if (sp) {
- if (strlen(sp->s_name) + 1 > servlen)
- return ENI_MEMORY;
- strcpy(serv, sp->s_name);
- } else {
- snprintf(numserv, sizeof(numserv), "%d", ntohs(port));
- if (strlen(numserv) + 1 > servlen)
- return ENI_MEMORY;
- strcpy(serv, numserv);
- }
- }
-
- switch (sa->sa_family) {
- case AF_INET:
- v4a = (uint32_t)
- ntohl(((struct sockaddr_in *)sa)->sin_addr.s_addr);
- if (IN_MULTICAST(v4a) || IN_EXPERIMENTAL(v4a))
- flags |= NI_NUMERICHOST;
- v4a >>= IN_CLASSA_NSHIFT;
- if (v4a == 0)
- flags |= NI_NUMERICHOST;
- break;
-#ifdef INET6
- case AF_INET6:
- {
- struct sockaddr_in6 *sin6;
- sin6 = (struct sockaddr_in6 *)sa;
- switch (sin6->sin6_addr.s6_addr[0]) {
- case 0x00:
- if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr))
- ;
- else if (IN6_IS_ADDR_LOOPBACK(&sin6->sin6_addr))
- ;
- else
- flags |= NI_NUMERICHOST;
- break;
- default:
- if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) {
- flags |= NI_NUMERICHOST;
- }
- else if (IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr))
- flags |= NI_NUMERICHOST;
- break;
- }
- }
- break;
-#endif
- }
- if (host == NULL || hostlen == 0) {
- /*
- * do nothing in this case.
- * in case you are wondering if "&&" is more correct than
- * "||" here: RFC2553 says that host == NULL OR hostlen == 0
- * means that the caller does not want the result.
- */
- } else if (flags & NI_NUMERICHOST) {
- /* NUMERICHOST and NAMEREQD conflicts with each other */
- if (flags & NI_NAMEREQD)
- return ENI_NOHOSTNAME;
- if (inet_ntop(afd->a_af, addr, numaddr, sizeof(numaddr))
- == NULL)
- return ENI_SYSTEM;
- if (strlen(numaddr) + 1 > hostlen)
- return ENI_MEMORY;
- strcpy(host, numaddr);
-#if defined(INET6) && defined(NI_WITHSCOPEID)
- if (afd->a_af == AF_INET6 &&
- (IN6_IS_ADDR_LINKLOCAL((struct in6_addr *)addr) ||
- IN6_IS_ADDR_MULTICAST((struct in6_addr *)addr)) &&
- ((struct sockaddr_in6 *)sa)->sin6_scope_id) {
-#ifndef ALWAYS_WITHSCOPE
- if (flags & NI_WITHSCOPEID)
-#endif /* !ALWAYS_WITHSCOPE */
- {
- char *ep = strchr(host, '\0');
- unsigned int ifindex =
- ((struct sockaddr_in6 *)sa)->sin6_scope_id;
-
- *ep = SCOPE_DELIMITER;
- if ((if_indextoname(ifindex, ep + 1)) == NULL)
- /* XXX what should we do? */
- strncpy(ep + 1, "???", 3);
- }
- }
-#endif /* INET6 */
- } else {
-#ifdef USE_GETIPNODEBY
- hp = getipnodebyaddr(addr, afd->a_addrlen, afd->a_af, &h_error);
-#else
- hp = gethostbyaddr(addr, afd->a_addrlen, afd->a_af);
-#ifdef HAVE_H_ERRNO
- h_error = h_errno;
-#else
- h_error = EINVAL;
-#endif
-#endif
-
- if (hp) {
- if (flags & NI_NOFQDN) {
- p = strchr(hp->h_name, '.');
- if (p) *p = '\0';
- }
- if (strlen(hp->h_name) + 1 > hostlen) {
-#ifdef USE_GETIPNODEBY
- freehostent(hp);
-#endif
- return ENI_MEMORY;
- }
- strcpy(host, hp->h_name);
-#ifdef USE_GETIPNODEBY
- freehostent(hp);
-#endif
- } else {
- if (flags & NI_NAMEREQD)
- return ENI_NOHOSTNAME;
- if (inet_ntop(afd->a_af, addr, numaddr, sizeof(numaddr))
- == NULL)
- return ENI_NOHOSTNAME;
- if (strlen(numaddr) + 1 > hostlen)
- return ENI_MEMORY;
- strcpy(host, numaddr);
- }
- }
- return SUCCESS;
-}
diff --git a/contrib/tcpdump/missing/inet_aton.c b/contrib/tcpdump/missing/inet_aton.c
deleted file mode 100644
index e85ad5f..0000000
--- a/contrib/tcpdump/missing/inet_aton.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 1995, 1996, 1997 Kungliga Tekniska Hgskolan
- * (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
- * Hgskolan 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.
- */
-
-#include <tcpdump-stdinc.h>
-
-/* Minimal implementation of inet_aton.
- * Cannot distinguish between failure and a local broadcast address. */
-
-#ifndef INADDR_NONE
-#define INADDR_NONE 0xffffffff
-#endif
-
-int
-inet_aton(const char *cp, struct in_addr *addr)
-{
- addr->s_addr = inet_addr(cp);
- return (addr->s_addr == INADDR_NONE) ? 0 : 1;
-}
diff --git a/contrib/tcpdump/missing/snprintf.c b/contrib/tcpdump/missing/snprintf.c
index 21d235d..921b74c 100644
--- a/contrib/tcpdump/missing/snprintf.c
+++ b/contrib/tcpdump/missing/snprintf.c
@@ -42,7 +42,7 @@
#include <ctype.h>
#include <sys/types.h>
-#include <interface.h>
+#include "netdissect.h"
enum format_flags {
minus_flag = 1,
diff --git a/contrib/tcpdump/missing/strdup.c b/contrib/tcpdump/missing/strdup.c
index 9fca752..9cbf35a 100644
--- a/contrib/tcpdump/missing/strdup.c
+++ b/contrib/tcpdump/missing/strdup.c
@@ -35,7 +35,7 @@
#include <stdlib.h>
#include <string.h>
-#include "interface.h"
+#include "netdissect.h"
char *
strdup(str)
diff --git a/contrib/tcpdump/missing/strlcat.c b/contrib/tcpdump/missing/strlcat.c
index 34f1af2..4054935 100644
--- a/contrib/tcpdump/missing/strlcat.c
+++ b/contrib/tcpdump/missing/strlcat.c
@@ -28,15 +28,15 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifdef HAVE_CONFIG_H
+#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <string.h>
-#include "interface.h"
+#include "netdissect.h"
/*
* Appends src to string dst of size siz (unlike strncat, siz is the
diff --git a/contrib/tcpdump/missing/strlcpy.c b/contrib/tcpdump/missing/strlcpy.c
index b0671eb..24dcca6 100644
--- a/contrib/tcpdump/missing/strlcpy.c
+++ b/contrib/tcpdump/missing/strlcpy.c
@@ -28,15 +28,15 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifdef HAVE_CONFIG_H
+#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <string.h>
-#include "interface.h"
+#include "netdissect.h"
/*
* Copy src to string dst of size siz. At most siz-1 characters
diff --git a/contrib/tcpdump/missing/strsep.c b/contrib/tcpdump/missing/strsep.c
index a1e6b30..2c17275 100644
--- a/contrib/tcpdump/missing/strsep.c
+++ b/contrib/tcpdump/missing/strsep.c
@@ -31,15 +31,15 @@
* SUCH DAMAGE.
*/
-#ifdef HAVE_CONFIG_H
+#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <string.h>
-#include "interface.h"
+#include "netdissect.h"
/*
* Get next token from string *stringp, where tokens are possibly-empty
diff --git a/contrib/tcpdump/nameser.h b/contrib/tcpdump/nameser.h
index 11e71ef..e075f09 100644
--- a/contrib/tcpdump/nameser.h
+++ b/contrib/tcpdump/nameser.h
@@ -71,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 */
diff --git a/contrib/tcpdump/tcpdump-stdinc.h b/contrib/tcpdump/netdissect-stdinc.h
index 32f8fc9..c7070f0 100644
--- a/contrib/tcpdump/tcpdump-stdinc.h
+++ b/contrib/tcpdump/netdissect-stdinc.h
@@ -32,28 +32,30 @@
/*
* Include the appropriate OS header files on Windows and various flavors
* of UNIX, include various non-OS header files on Windows, and define
- * various items as needed, to isolate most of tcpdump's platform
+ * 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
#include <errno.h>
-#ifdef WIN32
+#ifdef _WIN32
+
+/*
+ * Includes and definitions for Windows.
+ */
#include <stdint.h>
#include <stdio.h>
#include <winsock2.h>
#include <ws2tcpip.h>
-#include "bittypes.h" /* in wpcap's Win32/include */
#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 uint8_t
#define uint8_t unsigned char
@@ -133,6 +135,17 @@
#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
@@ -142,13 +155,6 @@
#define O_RDONLY _O_RDONLY
#endif /* _MSC_VER */
-/* 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);
-
/*
* With MSVC, for C, __inline is used to make a function an inline.
*/
@@ -156,6 +162,10 @@ extern int inet_aton (const char *cp, struct in_addr *addr);
#define inline __inline
#endif
+#ifdef AF_INET6
+#define HAVE_OS_IPV6_SUPPORT
+#endif
+
#ifndef INET6_ADDRSTRLEN
#define INET6_ADDRSTRLEN 46
#endif
@@ -171,12 +181,15 @@ 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>
@@ -198,7 +211,7 @@ typedef char* caddr_t;
#include <arpa/inet.h>
-#endif /* WIN32 */
+#endif /* _WIN32 */
#ifndef HAVE___ATTRIBUTE__
#define __attribute__(x)
@@ -241,7 +254,10 @@ typedef char* caddr_t;
#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"
@@ -253,6 +269,16 @@ typedef char* caddr_t;
#define FOPEN_WRITE_BIN FOPEN_WRITE_TXT
#endif
+/*
+ * 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
@@ -284,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
@@ -349,4 +401,4 @@ typedef char* caddr_t;
#define max(a,b) ((b)>(a)?(b):(a))
#endif
-#endif /* tcpdump_stdinc_h */
+#endif /* netdissect_stdinc_h */
diff --git a/contrib/tcpdump/netdissect.c b/contrib/tcpdump/netdissect.c
new file mode 100644
index 0000000..0215c83
--- /dev/null
+++ b/contrib/tcpdump/netdissect.c
@@ -0,0 +1,146 @@
+/*
+ * 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
+}
diff --git a/contrib/tcpdump/netdissect.h b/contrib/tcpdump/netdissect.h
index 0cd7c12..1d28c0b 100644
--- a/contrib/tcpdump/netdissect.h
+++ b/contrib/tcpdump/netdissect.h
@@ -34,11 +34,52 @@
#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, ...)
@@ -54,7 +95,7 @@ int vsnprintf (char *str, size_t sz, const char *format, va_list ap)
__attribute__((format (printf, 3, 0)))
#endif /* __ATTRIBUTE___FORMAT_OK */
;
-#endif /* !defined(HAVE_SNPRINTF) */
+#endif /* !defined(HAVE_VSNPRINTF) */
#ifndef HAVE_STRLCAT
extern size_t strlcat (char *, const char *, size_t);
@@ -76,7 +117,6 @@ struct tok {
const char *s; /* string */
};
-#define TOKBUFSIZE 128
extern const char *tok2strbuf(const struct tok *, const char *, u_int,
char *buf, size_t bufsize);
@@ -85,11 +125,27 @@ 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 */
@@ -97,69 +153,41 @@ 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_immediate; /* use immediate mode */
-
- 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 */
- int ndo_tstamp_precision; /* requested time stamp precision */
- 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);
-
- /* pointer to function to print ^T output */
- 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 *,
@@ -203,6 +231,7 @@ struct netdissect_options {
#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))
@@ -211,6 +240,9 @@ 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.
@@ -271,6 +303,11 @@ struct netdissect_options {
* http://www.kb.cert.org/vuls/id/162289
*/
+/*
+ * 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) \
@@ -291,9 +328,12 @@ struct netdissect_options {
#define ND_DEFAULTPRINT(ap, length) (*ndo->ndo_default_print)(ndo, ap, length)
extern void ts_print(netdissect_options *, const struct timeval *);
-extern void relts_print(netdissect_options *, int);
+extern void signed_relts_print(netdissect_options *, int32_t);
+extern void unsigned_relts_print(netdissect_options *, uint32_t);
+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 *);
@@ -305,11 +345,6 @@ extern int fn_printzp(netdissect_options *, const u_char *, u_int, const u_char
extern void txtproto_print(netdissect_options *, const u_char *, u_int,
const char *, const char **, u_int);
-#if 0
-extern char *read_infile(netdissect_options *, char *);
-extern char *copy_argv(netdissect_options *, char **);
-#endif
-
/*
* Locale-independent macros for testing character properties and
* stripping the 8th bit from characters. Assumed to be handed
@@ -352,286 +387,278 @@ extern int unaligned_memcmp(const void *, const void *, size_t);
#define PLURAL_SUFFIX(n) \
(((n) != 1) ? "s" : "")
-#if 0
-extern const char *dnname_string(netdissect_options *, u_short);
-extern const char *dnnum_string(netdissect_options *, u_short);
-#endif
-
-/* The printer routines. */
-
-#include <pcap.h>
-
-extern char *q922_string(netdissect_options *ndo, const u_char *, u_int);
-
-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 *);
+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 if_ndo_printer lookup_ndo_printer(int);
extern if_printer lookup_printer(int);
-extern void eap_print(netdissect_options *,const u_char *, u_int);
-extern int esp_print(netdissect_options *,
- const u_char *bp, const int length, const u_char *bp2,
- int *nhdr, int *padlen);
-extern void arp_print(netdissect_options *,const u_char *, u_int, u_int);
-extern void tipc_print(netdissect_options *, const u_char *, u_int, u_int);
-extern void msnlb_print(netdissect_options *, const u_char *);
-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 loopback_print(netdissect_options *, const u_char *, const u_int);
-extern void carp_print(netdissect_options *, const u_char *, u_int, int);
+/* 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;
-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);
+/*
+ * 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 int print_unknown_data(netdissect_options *,const u_char *, const char *,int);
-extern void ascii_print(netdissect_options *, const u_char *, u_int);
-extern void hex_print_with_offset(netdissect_options *, const char *ident, const u_char *cp,
- u_int, u_int);
-extern void hex_print(netdissect_options *,const char *ident, const u_char *cp,u_int);
-extern void hex_and_ascii_print_with_offset(netdissect_options *, const char *, const u_char *, u_int, u_int);
-extern void hex_and_ascii_print(netdissect_options *, const char *, const u_char *, u_int);
+/* The printer routines. */
+extern void aarp_print(netdissect_options *, const u_char *, u_int);
extern int ah_print(netdissect_options *, register const u_char *);
-extern void beep_print(netdissect_options *, const u_char *, u_int);
-extern void dtp_print(netdissect_options *, const u_char *, u_int);
-extern u_int cip_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
-extern int ipcomp_print(netdissect_options *, register const u_char *, int *);
-extern u_int ipfc_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
-extern void udld_print(netdissect_options *, const u_char *, u_int);
-extern void hsrp_print(netdissect_options *, const u_char *, u_int);
-extern void igrp_print(netdissect_options *, const u_char *, u_int);
-extern void msdp_print(netdissect_options *, const u_char *, u_int);
-extern u_int null_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
-extern void mobile_print(netdissect_options *, const u_char *, u_int);
-extern u_int ap1394_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
-extern u_int bt_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
-extern void lane_print(netdissect_options *, const u_char *, u_int, u_int);
-extern u_int lane_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
-extern void otv_print(netdissect_options *, const u_char *, u_int);
extern void ahcp_print(netdissect_options *, const u_char *, const u_int);
-extern void vxlan_print(netdissect_options *, const u_char *, u_int);
-extern u_int arcnet_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
-extern u_int arcnet_linux_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+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 gre_print(netdissect_options *, const u_char *, u_int);
-extern int vjc_print(netdissect_options *, register const char *, u_short);
-extern void ipN_print(netdissect_options *, const u_char *, u_int);
-extern u_int raw_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
-extern u_int usb_linux_48_byte_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
-extern u_int usb_linux_64_byte_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
-extern u_int symantec_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
-extern u_int chdlc_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+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 zmtp1_print(netdissect_options *, const u_char *, u_int);
-extern void zmtp1_print_datagram(netdissect_options *, const u_char *, const u_int);
-extern void ipx_print(netdissect_options *, const u_char *, u_int);
-extern void mpls_print(netdissect_options *, const u_char *, u_int);
-extern u_int pppoe_print(netdissect_options *, const u_char *, u_int);
-extern u_int pppoe_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
-extern void sunrpcrequest_print(netdissect_options *, const u_char *, u_int, const u_char *);
-extern u_int pflog_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
-extern u_int token_print(netdissect_options *, const u_char *, u_int, u_int);
-extern u_int token_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
-extern void vqp_print(netdissect_options *, register const u_char *, register u_int);
-extern void zephyr_print(netdissect_options *, const u_char *, int);
-extern void fddi_print(netdissect_options *, const u_char *, u_int, u_int);
-extern u_int fddi_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
-extern void mpcp_print(netdissect_options *, const u_char *, u_int);
-extern void rpki_rtr_print(netdissect_options *, const u_char *, u_int);
-extern u_int sll_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
-extern void dccp_print(netdissect_options *, const u_char *, 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 int snap_print(netdissect_options *, const u_char *, u_int, u_int, u_int);
-extern void eigrp_print(netdissect_options *, const u_char *, u_int);
-extern void stp_print(netdissect_options *, const u_char *, u_int);
-extern void l2tp_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 icmp_print(netdissect_options *, const u_char *, u_int, const u_char *, int);
-extern void openflow_print(netdissect_options *, const u_char *, const u_int);
-extern void telnet_print(netdissect_options *, const u_char *, u_int);
-extern void slow_print(netdissect_options *, const u_char *, u_int);
-extern void radius_print(netdissect_options *, const u_char *, u_int);
-extern void lmp_print(netdissect_options *, const u_char *, u_int);
-extern u_int fr_print(netdissect_options *, register const u_char *, u_int);
-extern u_int mfr_print(netdissect_options *, register const u_char *, u_int);
-extern u_int fr_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
-extern u_int mfr_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
-extern void q933_print(netdissect_options *, const u_char *, u_int);
-extern void igmp_print(netdissect_options *, const u_char *, u_int);
-extern void rip_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 pgm_print(netdissect_options *, const u_char *, u_int, const u_char *);
-extern void pptp_print(netdissect_options *, const u_char *);
-extern void ldp_print(netdissect_options *, const u_char *, u_int);
-extern void wb_print(netdissect_options *, const void *, u_int);
-extern int oam_print(netdissect_options *, const u_char *, u_int, u_int);
-extern void atm_print(netdissect_options *, u_int, u_int, u_int, const u_char *, u_int, u_int);
-extern u_int sunatm_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
-extern u_int atm_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
-extern void vtp_print(netdissect_options *, const u_char *, u_int);
-extern int mptcp_print(netdissect_options *, const u_char *, u_int, u_char);
-extern void ntp_print(netdissect_options *, 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 u_int enc_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
-extern u_int sl_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
-extern u_int sl_bsdos_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
-extern void tftp_print(netdissect_options *, const u_char *, u_int);
-extern void vrrp_print(netdissect_options *, const u_char *, u_int, const u_char *, int);
-extern void pimv1_print(netdissect_options *, const u_char *, u_int);
-extern void cisco_autorp_print(netdissect_options *, const u_char *, u_int);
-extern void pim_print(netdissect_options *, const u_char *, u_int, u_int);
-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 bootp_print(netdissect_options *, const u_char *, u_int);
-extern void sflow_print(netdissect_options *, const u_char *, u_int);
-extern void aodv_print(netdissect_options *, const u_char *, u_int, int);
-extern void sctp_print(netdissect_options *, const u_char *, const u_char *, u_int);
-extern char *bgp_vpn_rd_print (netdissect_options *, const u_char *);
-extern void bgp_print(netdissect_options *, const u_char *, int);
-extern void olsr_print(netdissect_options *, const u_char *, u_int, 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 void lspping_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 cdp_print(netdissect_options *, const u_char *, u_int, u_int);
-extern void atalk_print(netdissect_options *, const u_char *, u_int);
-extern u_int ltalk_if_print(netdissect_options *, const struct pcap_pkthdr *, 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 void aarp_print(netdissect_options *, const u_char *, u_int);
-extern u_int juniper_atm1_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
-extern u_int juniper_atm2_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
-extern u_int juniper_mfr_print(netdissect_options *, const struct pcap_pkthdr *, register const u_char *);
-extern u_int juniper_mlfr_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
-extern u_int juniper_mlppp_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
-extern u_int juniper_pppoe_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
-extern u_int juniper_pppoe_atm_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
-extern u_int juniper_ggsn_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
-extern u_int juniper_es_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
-extern u_int juniper_monitor_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
-extern u_int juniper_services_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
-extern u_int juniper_ether_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
-extern u_int juniper_ppp_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
-extern u_int juniper_frelay_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
-extern u_int juniper_chdlc_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
-extern void snmp_print(netdissect_options *, const u_char *, u_int);
-extern void rx_print(netdissect_options *, register const u_char *, int, int, int, u_char *);
-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 void sip_print(netdissect_options *, const u_char *, u_int);
-extern void syslog_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 cfm_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 smb_tcp_print(netdissect_options *, const u_char *, int);
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 print_data(netdissect_options *, const unsigned char *, int);
-extern void decnet_print(netdissect_options *, const u_char *, u_int, u_int);
-extern void tcp_print(netdissect_options *, const u_char *, u_int, 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_te_lsa(netdissect_options *, const uint8_t *, u_int);
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 ppp_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
-extern u_int ppp_hdlc_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
-extern u_int ppp_bsdos_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
-extern void lldp_print(netdissect_options *, 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 void timed_print(netdissect_options *, const u_char *);
-extern void m3ua_print(netdissect_options *, const u_char *, const u_int);
-extern void aoe_print(netdissect_options *, const u_char *, const u_int);
-extern void ftp_print(netdissect_options *, const u_char *, u_int);
-extern void http_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 void geneve_print(netdissect_options *, const u_char *, u_int);
-
-extern void pfsync_ip_print(netdissect_options *, const u_char *, u_int);
-
-/* stuff that has not yet been rototiled */
-
-#if 0
-extern void ascii_print(netdissect_options *,u_int);
-extern void default_print(netdissect_options *,const u_char *, u_int);
-extern char *smb_errstr(netdissect_options *,int, int);
-extern const char *nt_errstr(netdissect_options *, uint32_t);
-#endif
+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 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);
-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 nflog_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 *);
-extern u_int pktap_if_print(netdissect_options *,const struct pcap_pkthdr *, const u_char *);
-extern u_int ieee802_11_radio_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
-extern u_int ieee802_11_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
-extern u_int ieee802_11_radio_avs_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
-extern u_int prism_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
-
-extern void ip6_print(netdissect_options *,const u_char *, u_int);
-#ifdef INET6
-extern int frag6_print(netdissect_options *, const u_char *, const u_char *);
-extern int rt6_print(netdissect_options *, const u_char *, const u_char *);
-extern int hbhopt_print(netdissect_options *, const u_char *);
-extern int dstopt_print(netdissect_options *, const u_char *);
-extern void ripng_print(netdissect_options *, const u_char *, unsigned int);
-extern int mobility_print(netdissect_options *, const u_char *, const u_char *);
-extern void dhcp6_print(netdissect_options *, const u_char *, u_int);
-extern void ospf6_print(netdissect_options *, const u_char *, u_int);
-extern void babel_print(netdissect_options *, const u_char *, u_int);
-#endif /*INET6*/
+/* 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);
-#if 0
struct cksum_vec {
const uint8_t *ptr;
int len;
};
extern uint16_t in_cksum(const struct cksum_vec *, int);
extern uint16_t in_cksum_shouldbe(uint16_t, uint16_t);
-#endif
-extern int nextproto4_cksum(netdissect_options *ndo, const struct ip *, const uint8_t *, u_int, u_int, u_int);
-extern int decode_prefix4(netdissect_options *ndo, const u_char *, u_int, char *, u_int);
-#ifdef INET6
-extern int decode_prefix6(netdissect_options *ndo, const u_char *, u_int, char *, u_int);
-#endif
-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 void geonet_print(netdissect_options *ndo,const u_char *eth_hdr,const u_char *geo_pck, u_int len);
-extern void calm_fast_print(netdissect_options *ndo,const u_char *eth_hdr,const u_char *calm_pck, u_int len);
+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/contrib/tcpdump/nfs.h b/contrib/tcpdump/nfs.h
index a47c005..da7bc50 100644
--- a/contrib/tcpdump/nfs.h
+++ b/contrib/tcpdump/nfs.h
@@ -35,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
*/
diff --git a/contrib/tcpdump/nfsfh.h b/contrib/tcpdump/nfsfh.h
index fbc2355..5cf8fc4 100644
--- a/contrib/tcpdump/nfsfh.h
+++ b/contrib/tcpdump/nfsfh.h
@@ -37,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 $
*/
/*
@@ -65,4 +63,4 @@ typedef struct {
#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 *, uint32_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/contrib/tcpdump/nlpid.c b/contrib/tcpdump/nlpid.c
index 919e87d..4b44ee1 100644
--- a/contrib/tcpdump/nlpid.c
+++ b/contrib/tcpdump/nlpid.c
@@ -13,13 +13,12 @@
* Original code by Hannes Gredler (hannes@juniper.net)
*/
-#define NETDISSECT_REWORKED
#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[] = {
diff --git a/contrib/tcpdump/oui.c b/contrib/tcpdump/oui.c
index 2aea5ad..71425de 100644
--- a/contrib/tcpdump/oui.c
+++ b/contrib/tcpdump/oui.c
@@ -13,13 +13,12 @@
* Original code by Hannes Gredler (hannes@juniper.net)
*/
-#define NETDISSECT_REWORKED
#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 */
@@ -27,6 +26,7 @@
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" },
diff --git a/contrib/tcpdump/oui.h b/contrib/tcpdump/oui.h
index 4a983ec..a85f883 100644
--- a/contrib/tcpdump/oui.h
+++ b/contrib/tcpdump/oui.h
@@ -16,29 +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_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 */
+#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/contrib/tcpdump/parsenfsfh.c b/contrib/tcpdump/parsenfsfh.c
index 909a180..8f48e77 100644
--- a/contrib/tcpdump/parsenfsfh.c
+++ b/contrib/tcpdump/parsenfsfh.c
@@ -38,21 +38,18 @@
* Jeffrey C. Mogul
* Digital Equipment Corporation
* Western Research Laboratory
- *
- * $FreeBSD$
*/
-#define NETDISSECT_REWORKED
#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"
/*
@@ -105,10 +102,10 @@
((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(register const unsigned char *fh, int len _U_, my_fsid *fsidp,
+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) */
@@ -117,138 +114,146 @@ Parse_fh(register const unsigned char *fh, int len _U_, my_fsid *fsidp,
register const unsigned char *fhp = fh;
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 */
@@ -363,13 +368,13 @@ Parse_fh(register const unsigned char *fh, int len _U_, my_fsid *fsidp,
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 {
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;
@@ -380,7 +385,7 @@ Parse_fh(register const unsigned char *fh, int len _U_, my_fsid *fsidp,
/* Caller must save (and null-terminate?) this value */
if (fsnamep)
- *fsnamep = (char *)&(fhp[1]);
+ *fsnamep = (const char *)&(fhp[1]);
if (osnamep)
*osnamep = "VMS";
@@ -412,13 +417,14 @@ Parse_fh(register const unsigned char *fh, int len _U_, my_fsid *fsidp,
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;
@@ -445,11 +451,18 @@ Parse_fh(register const unsigned char *fh, int len _U_, my_fsid *fsidp,
* (3) followed by string of nulls
*/
static int
-is_UCX(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 (ND_ISPRINT(fhp[i])) {
if (seen_null)
diff --git a/contrib/tcpdump/pcap-missing.h b/contrib/tcpdump/pcap-missing.h
index d776810..92706b1 100644
--- a/contrib/tcpdump/pcap-missing.h
+++ b/contrib/tcpdump/pcap-missing.h
@@ -19,8 +19,8 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#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.
@@ -46,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/contrib/tcpdump/ppp.h b/contrib/tcpdump/ppp.h
index da4810a..9d53423 100644
--- a/contrib/tcpdump/ppp.h
+++ b/contrib/tcpdump/ppp.h
@@ -13,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 */
diff --git a/contrib/tcpdump/print-802_11.c b/contrib/tcpdump/print-802_11.c
index 88fbf40..3db98ea 100644
--- a/contrib/tcpdump/print-802_11.c
+++ b/contrib/tcpdump/print-802_11.c
@@ -20,16 +20,17 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#define NETDISSECT_REWORKED
+/* \summary: IEEE 802.11 printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <string.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "extract.h"
@@ -45,8 +46,11 @@
#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
@@ -166,15 +170,15 @@ static const struct tok ctrl_str[] = {
#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_PROTECTED(fc) ((fc) & 0x4000)
#define FC_ORDER(fc) ((fc) & 0x8000)
struct mgmt_header_t {
uint16_t fc;
uint16_t duration;
- uint8_t da[6];
- uint8_t sa[6];
- uint8_t bssid[6];
+ 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;
};
@@ -292,85 +296,90 @@ struct mgmt_body_t {
struct tim_t tim;
};
-struct ctrl_rts_t {
+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[6];
- uint8_t ta[6];
- uint8_t fcs[4];
+ 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_t {
+struct ctrl_cts_hdr_t {
uint16_t fc;
uint16_t duration;
- uint8_t ra[6];
- uint8_t fcs[4];
+ 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_t {
+struct ctrl_ack_hdr_t {
uint16_t fc;
uint16_t duration;
- uint8_t ra[6];
- uint8_t fcs[4];
+ 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_t {
+struct ctrl_ps_poll_hdr_t {
uint16_t fc;
uint16_t aid;
- uint8_t bssid[6];
- uint8_t ta[6];
- uint8_t fcs[4];
+ 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_t {
+struct ctrl_end_hdr_t {
uint16_t fc;
uint16_t duration;
- uint8_t ra[6];
- uint8_t bssid[6];
- uint8_t fcs[4];
+ 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_t {
+struct ctrl_end_ack_hdr_t {
uint16_t fc;
uint16_t duration;
- uint8_t ra[6];
- uint8_t bssid[6];
- uint8_t fcs[4];
+ 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_t {
+struct ctrl_ba_hdr_t {
uint16_t fc;
uint16_t duration;
- uint8_t ra[6];
- uint8_t fcs[4];
+ 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_t {
+struct ctrl_bar_hdr_t {
uint16_t fc;
uint16_t dur;
- uint8_t ra[6];
- uint8_t ta[6];
+ uint8_t ra[IEEE802_11_RA_LEN];
+ uint8_t ta[IEEE802_11_TA_LEN];
uint16_t ctl;
uint16_t seq;
- uint8_t fcs[4];
};
#define CTRL_BAR_HDRLEN (IEEE802_11_FC_LEN+IEEE802_11_DUR_LEN+\
@@ -390,310 +399,6 @@ struct meshcntl_t {
#define IV_PAD(iv) (((iv) >> 24) & 0x3F)
#define IV_KEYID(iv) (((iv) >> 30) & 0x03)
-/* $FreeBSD$ */
-/* 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_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_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
-
-/* 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
-
-static const char tstr[] = "[|802.11]";
-
-/* Radiotap state */
-/* This is used to save state when parsing/processing parameters */
-struct radiotap_state
-{
- uint32_t present;
-
- uint8_t rate;
-};
-
#define PRINT_SSID(p) \
if (p.ssid_present) { \
ND_PRINT((ndo, " (")); \
@@ -1283,7 +988,7 @@ wep_print(netdissect_options *ndo,
return 0;
iv = EXTRACT_LE_32BITS(p);
- ND_PRINT((ndo, "Data IV:%3x Pad %x KeyID %x", IV_IV(iv), IV_PAD(iv),
+ ND_PRINT((ndo, " IV:%3x Pad %x KeyID %x", IV_IV(iv), IV_PAD(iv),
IV_KEYID(iv)));
return 1;
@@ -1801,7 +1506,7 @@ handle_auth(netdissect_options *ndo,
static int
handle_deauth(netdissect_options *ndo,
- const struct mgmt_header_t *pmh, const u_char *p, u_int length)
+ const uint8_t *src, const u_char *p, u_int length)
{
struct mgmt_body_t pbody;
const char *reason = NULL;
@@ -1821,7 +1526,7 @@ handle_deauth(netdissect_options *ndo,
if (ndo->ndo_eflag) {
ND_PRINT((ndo, ": %s", reason));
} else {
- ND_PRINT((ndo, " (%s): %s", etheraddr_string(ndo, pmh->sa), reason));
+ ND_PRINT((ndo, " (%s): %s", etheraddr_string(ndo, src), reason));
}
return 1;
}
@@ -1886,7 +1591,7 @@ handle_deauth(netdissect_options *ndo,
static int
handle_action(netdissect_options *ndo,
- const struct mgmt_header_t *pmh, const u_char *p, u_int length)
+ const uint8_t *src, const u_char *p, u_int length)
{
if (!ND_TTEST2(*p, 2))
return 0;
@@ -1895,7 +1600,7 @@ handle_action(netdissect_options *ndo,
if (ndo->ndo_eflag) {
ND_PRINT((ndo, ": "));
} else {
- ND_PRINT((ndo, " (%s): ", etheraddr_string(ndo, pmh->sa)));
+ ND_PRINT((ndo, " (%s): ", etheraddr_string(ndo, src)));
}
switch (p[0]) {
case 0: ND_PRINT((ndo, "Spectrum Management Act#%d", p[1])); break;
@@ -1926,10 +1631,13 @@ handle_action(netdissect_options *ndo,
static int
mgmt_body_print(netdissect_options *ndo,
- uint16_t fc, const struct mgmt_header_t *pmh,
- const u_char *p, u_int length)
+ 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:
return handle_assoc_request(ndo, p, length);
@@ -1950,17 +1658,11 @@ mgmt_body_print(netdissect_options *ndo,
case ST_DISASSOC:
return handle_disassoc(ndo, p, length);
case ST_AUTH:
- if (!ND_TTEST2(*p, 3))
- return 0;
- if ((p[0] == 0 ) && (p[1] == 0) && (p[2] == 0)) {
- ND_PRINT((ndo, "Authentication (Shared-Key)-3 "));
- return wep_print(ndo, p);
- }
return handle_auth(ndo, p, length);
case ST_DEAUTH:
- return handle_deauth(ndo, pmh, p, length);
+ return handle_deauth(ndo, src, p, length);
case ST_ACTION:
- return handle_action(ndo, pmh, p, length);
+ return handle_action(ndo, src, p, length);
default:
return 1;
}
@@ -1985,68 +1687,64 @@ ctrl_body_print(netdissect_options *ndo,
return 0;
if (!ndo->ndo_eflag)
ND_PRINT((ndo, " RA:%s TA:%s CTL(%x) SEQ(%u) ",
- etheraddr_string(ndo, ((const struct ctrl_bar_t *)p)->ra),
- etheraddr_string(ndo, ((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))));
+ 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:
if (!ND_TTEST2(*p, CTRL_BA_HDRLEN))
return 0;
if (!ndo->ndo_eflag)
ND_PRINT((ndo, " RA:%s ",
- etheraddr_string(ndo, ((const struct ctrl_ba_t *)p)->ra)));
+ etheraddr_string(ndo, ((const struct ctrl_ba_hdr_t *)p)->ra)));
break;
case CTRL_PS_POLL:
if (!ND_TTEST2(*p, CTRL_PS_POLL_HDRLEN))
return 0;
ND_PRINT((ndo, " AID(%x)",
- EXTRACT_LE_16BITS(&(((const struct ctrl_ps_poll_t *)p)->aid))));
+ EXTRACT_LE_16BITS(&(((const struct ctrl_ps_poll_hdr_t *)p)->aid))));
break;
case CTRL_RTS:
if (!ND_TTEST2(*p, CTRL_RTS_HDRLEN))
return 0;
if (!ndo->ndo_eflag)
ND_PRINT((ndo, " TA:%s ",
- etheraddr_string(ndo, ((const struct ctrl_rts_t *)p)->ta)));
+ etheraddr_string(ndo, ((const struct ctrl_rts_hdr_t *)p)->ta)));
break;
case CTRL_CTS:
if (!ND_TTEST2(*p, CTRL_CTS_HDRLEN))
return 0;
if (!ndo->ndo_eflag)
ND_PRINT((ndo, " RA:%s ",
- etheraddr_string(ndo, ((const struct ctrl_cts_t *)p)->ra)));
+ etheraddr_string(ndo, ((const struct ctrl_cts_hdr_t *)p)->ra)));
break;
case CTRL_ACK:
if (!ND_TTEST2(*p, CTRL_ACK_HDRLEN))
return 0;
if (!ndo->ndo_eflag)
ND_PRINT((ndo, " RA:%s ",
- etheraddr_string(ndo, ((const struct ctrl_ack_t *)p)->ra)));
+ etheraddr_string(ndo, ((const struct ctrl_ack_hdr_t *)p)->ra)));
break;
case CTRL_CF_END:
if (!ND_TTEST2(*p, CTRL_END_HDRLEN))
return 0;
if (!ndo->ndo_eflag)
ND_PRINT((ndo, " RA:%s ",
- etheraddr_string(ndo, ((const struct ctrl_end_t *)p)->ra)));
+ etheraddr_string(ndo, ((const struct ctrl_end_hdr_t *)p)->ra)));
break;
case CTRL_END_ACK:
if (!ND_TTEST2(*p, CTRL_END_ACK_HDRLEN))
return 0;
if (!ndo->ndo_eflag)
ND_PRINT((ndo, " RA:%s ",
- etheraddr_string(ndo, ((const struct ctrl_end_ack_t *)p)->ra)));
+ etheraddr_string(ndo, ((const struct ctrl_end_ack_hdr_t *)p)->ra)));
break;
}
return 1;
}
/*
- * Print Header funcs
- */
-
-/*
* Data Frame - Address field contents
*
* To Ds | From DS | Addr 1 | Addr 2 | Addr 3 | Addr 4
@@ -2056,10 +1754,63 @@ ctrl_body_print(netdissect_options *ndo,
* 1 | 1 | RA | TA | DA | SA
*/
+/*
+ * Function to get source and destination MAC addresses for a data frame.
+ */
+static void
+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, const uint8_t **srcp,
- const uint8_t **dstp)
+data_header_print(netdissect_options *ndo, uint16_t fc, const u_char *p)
{
u_int subtype = FC_SUBTYPE(fc);
@@ -2086,42 +1837,18 @@ data_header_print(netdissect_options *ndo,
#define ADDR4 (p + 24)
if (!FC_TO_DS(fc) && !FC_FROM_DS(fc)) {
- if (srcp != NULL)
- *srcp = ADDR2;
- if (dstp != NULL)
- *dstp = ADDR1;
- if (!ndo->ndo_eflag)
- return;
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 (!ndo->ndo_eflag)
- return;
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 (!ndo->ndo_eflag)
- return;
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 (!ndo->ndo_eflag)
- return;
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)));
@@ -2134,77 +1861,60 @@ data_header_print(netdissect_options *ndo,
}
static void
-mgmt_header_print(netdissect_options *ndo,
- const u_char *p, const uint8_t **srcp, const uint8_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 (!ndo->ndo_eflag)
- return;
-
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(netdissect_options *ndo,
- uint16_t fc, const u_char *p, const uint8_t **srcp,
- const uint8_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 (!ndo->ndo_eflag)
- return;
-
switch (FC_SUBTYPE(fc)) {
case CTRL_BAR:
ND_PRINT((ndo, " RA:%s TA:%s CTL(%x) SEQ(%u) ",
- etheraddr_string(ndo, ((const struct ctrl_bar_t *)p)->ra),
- etheraddr_string(ndo, ((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))));
+ 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:
ND_PRINT((ndo, "RA:%s ",
- etheraddr_string(ndo, ((const struct ctrl_ba_t *)p)->ra)));
+ etheraddr_string(ndo, ((const struct ctrl_ba_hdr_t *)p)->ra)));
break;
case CTRL_PS_POLL:
ND_PRINT((ndo, "BSSID:%s TA:%s ",
- etheraddr_string(ndo, ((const struct ctrl_ps_poll_t *)p)->bssid),
- etheraddr_string(ndo, ((const struct ctrl_ps_poll_t *)p)->ta)));
+ 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:
ND_PRINT((ndo, "RA:%s TA:%s ",
- etheraddr_string(ndo, ((const struct ctrl_rts_t *)p)->ra),
- etheraddr_string(ndo, ((const struct ctrl_rts_t *)p)->ta)));
+ 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:
ND_PRINT((ndo, "RA:%s ",
- etheraddr_string(ndo, ((const struct ctrl_cts_t *)p)->ra)));
+ etheraddr_string(ndo, ((const struct ctrl_cts_hdr_t *)p)->ra)));
break;
case CTRL_ACK:
ND_PRINT((ndo, "RA:%s ",
- etheraddr_string(ndo, ((const struct ctrl_ack_t *)p)->ra)));
+ etheraddr_string(ndo, ((const struct ctrl_ack_hdr_t *)p)->ra)));
break;
case CTRL_CF_END:
ND_PRINT((ndo, "RA:%s BSSID:%s ",
- etheraddr_string(ndo, ((const struct ctrl_end_t *)p)->ra),
- etheraddr_string(ndo, ((const struct ctrl_end_t *)p)->bssid)));
+ 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:
ND_PRINT((ndo, "RA:%s BSSID:%s ",
- etheraddr_string(ndo, ((const struct ctrl_end_ack_t *)p)->ra),
- etheraddr_string(ndo, ((const struct ctrl_end_ack_t *)p)->bssid)));
+ 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:
- ND_PRINT((ndo, "(H) Unknown Ctrl Subtype"));
+ /* We shouldn't get here - we should already have quit */
break;
}
}
@@ -2220,8 +1930,12 @@ extract_header_length(netdissect_options *ndo,
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:
@@ -2235,6 +1949,7 @@ extract_header_length(netdissect_options *ndo,
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:
@@ -2243,7 +1958,7 @@ extract_header_length(netdissect_options *ndo,
len += 2;
return len;
default:
- ND_PRINT((ndo, "unknown IEEE802.11 frame type (%d)", FC_TYPE(fc)));
+ ND_PRINT((ndo, "unknown 802.11 frame type (%d)", FC_TYPE(fc)));
return 0;
}
}
@@ -2255,15 +1970,12 @@ 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(netdissect_options *ndo,
uint16_t fc, const u_char *p, u_int hdrlen,
- u_int meshdrlen, const uint8_t **srcp,
- const uint8_t **dstp)
+ u_int meshdrlen)
{
if (ndo->ndo_vflag) {
if (FC_MORE_DATA(fc))
@@ -2276,8 +1988,8 @@ ieee_802_11_hdr_print(netdissect_options *ndo,
ND_PRINT((ndo, "Retry "));
if (FC_ORDER(fc))
ND_PRINT((ndo, "Strictly Ordered "));
- if (FC_WEP(fc))
- ND_PRINT((ndo, "WEP Encrypted "));
+ if (FC_PROTECTED(fc))
+ ND_PRINT((ndo, "Protected "));
if (FC_TYPE(fc) != T_CTRL || FC_SUBTYPE(fc) != CTRL_PS_POLL)
ND_PRINT((ndo, "%dus ",
EXTRACT_LE_16BITS(
@@ -2301,19 +2013,15 @@ ieee_802_11_hdr_print(netdissect_options *ndo,
switch (FC_TYPE(fc)) {
case T_MGMT:
- mgmt_header_print(ndo, p, srcp, dstp);
+ mgmt_header_print(ndo, p);
break;
case T_CTRL:
- ctrl_header_print(ndo, fc, p, srcp, dstp);
+ ctrl_header_print(ndo, fc, p);
break;
case T_DATA:
- data_header_print(ndo, fc, p, srcp, dstp);
+ data_header_print(ndo, fc, p);
break;
default:
- ND_PRINT((ndo, "(header) unknown IEEE802.11 frame type (%d)",
- FC_TYPE(fc)));
- *srcp = NULL;
- *dstp = NULL;
break;
}
}
@@ -2322,6 +2030,8 @@ ieee_802_11_hdr_print(netdissect_options *ndo,
#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(netdissect_options *ndo,
const u_char *p, u_int length, u_int orig_caplen, int pad,
@@ -2329,8 +2039,8 @@ ieee802_11_print(netdissect_options *ndo,
{
uint16_t fc;
u_int caplen, hdrlen, meshdrlen;
- const uint8_t *src, *dst;
- u_short extracted_ethertype;
+ struct lladdr_info src, dst;
+ int llc_hdrlen;
caplen = orig_caplen;
/* Remove FCS, if present */
@@ -2353,6 +2063,10 @@ ieee802_11_print(netdissect_options *ndo,
fc = EXTRACT_LE_16BITS(p);
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 (ndo->ndo_Hflag && FC_TYPE(fc) == T_DATA &&
@@ -2362,13 +2076,13 @@ ieee802_11_print(netdissect_options *ndo,
} else
meshdrlen = 0;
-
if (caplen < hdrlen) {
ND_PRINT((ndo, "%s", tstr));
return hdrlen;
}
- ieee_802_11_hdr_print(ndo, 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.
@@ -2377,10 +2091,12 @@ ieee802_11_print(netdissect_options *ndo,
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(ndo, fc,
- (const struct mgmt_header_t *)(p - hdrlen), p, length)) {
+ 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;
}
@@ -2395,30 +2111,29 @@ ieee802_11_print(netdissect_options *ndo,
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 (FC_PROTECTED(fc)) {
+ ND_PRINT((ndo, "Data"));
if (!wep_print(ndo, p)) {
ND_PRINT((ndo, "%s", tstr));
return hdrlen;
}
- } else if (llc_print(ndo, p, length, caplen, dst, src,
- &extracted_ethertype) == 0) {
- /*
- * Some kinds of LLC packet we cannot
- * handle intelligently
- */
- if (!ndo->ndo_eflag)
- ieee_802_11_hdr_print(ndo, fc, p - hdrlen, hdrlen,
- meshdrlen, NULL, NULL);
- if (extracted_ethertype)
- ND_PRINT((ndo, "(LLC %s) ",
- etherproto_string(
- htons(extracted_ethertype))));
- if (!ndo->ndo_suppress_default_print)
- ND_DEFAULTPRINT(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:
- ND_PRINT((ndo, "unknown 802.11 frame type (%d)", FC_TYPE(fc)));
+ /* We shouldn't get here - we should already have quit */
break;
}
@@ -2438,6 +2153,349 @@ ieee802_11_if_print(netdissect_options *ndo,
return ieee802_11_print(ndo, p, h->len, h->caplen, 0, 0);
}
+
+/* $FreeBSD: stable/11/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 \
@@ -2464,30 +2522,41 @@ ieee802_11_if_print(netdissect_options *ndo,
static void
print_chaninfo(netdissect_options *ndo,
- int freq, int flags)
+ uint16_t freq, int flags, int presentflags)
{
ND_PRINT((ndo, "%u MHz", freq));
- 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 (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)
- 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"));
+ /*
+ * These apply to 11n.
+ */
if (flags & IEEE80211_CHAN_HT20)
ND_PRINT((ndo, " ht/20"));
else if (flags & IEEE80211_CHAN_HT40D)
@@ -2499,146 +2568,50 @@ print_chaninfo(netdissect_options *ndo,
static int
print_radiotap_field(netdissect_options *ndo,
- struct cpack_state *s, uint32_t bit, uint8_t *flags,
- struct radiotap_state *state, uint32_t presentflags)
+ struct cpack_state *s, uint32_t bit, uint8_t *flagsp,
+ uint32_t presentflags)
{
- union {
- int8_t i8;
- uint8_t u8;
- int16_t i16;
- uint16_t u16;
- uint32_t u32;
- uint64_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);
+ case IEEE80211_RADIOTAP_TSFT: {
+ uint64_t tsft;
+
+ rc = cpack_uint64(s, &tsft);
if (rc != 0)
- break;
- rc = cpack_uint8(s, &u4.u8);
+ goto trunc;
+ ND_PRINT((ndo, "%" PRIu64 "us tsft ", tsft));
break;
- case IEEE80211_RADIOTAP_MCS:
- rc = cpack_uint8(s, &u.u8);
- if (rc != 0)
- break;
- rc = cpack_uint8(s, &u2.u8);
- if (rc != 0)
- break;
- rc = cpack_uint8(s, &u3.u8);
- break;
- case IEEE80211_RADIOTAP_VENDOR_NAMESPACE: {
- uint8_t vns[3];
- uint16_t length;
- uint8_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.
- */
- ND_PRINT((ndo, "[bit %u] ", bit));
- return -1;
- }
-
- if (rc != 0) {
- ND_PRINT((ndo, "%s", tstr));
- 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(ndo, u.u16, u2.u16);
- break;
- case IEEE80211_RADIOTAP_FHSS:
- ND_PRINT((ndo, "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
@@ -2660,7 +2633,7 @@ print_radiotap_field(netdissect_options *ndo,
* 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
@@ -2677,60 +2650,173 @@ print_radiotap_field(netdissect_options *ndo,
* information from Flags, at least on
* FreeBSD?
*/
- ND_PRINT((ndo, "MCS %u ", u.u8 & 0x7f));
+ ND_PRINT((ndo, "MCS %u ", rate & 0x7f));
} else
- ND_PRINT((ndo, "%2.1f Mb/s ", .5 * u.u8));
+ ND_PRINT((ndo, "%2.1f Mb/s ", .5 * rate));
break;
- case IEEE80211_RADIOTAP_DBM_ANTSIGNAL:
- ND_PRINT((ndo, "%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:
- ND_PRINT((ndo, "%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:
- ND_PRINT((ndo, "%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:
- ND_PRINT((ndo, "%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:
- ND_PRINT((ndo, "%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:
- ND_PRINT((ndo, "%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:
- ND_PRINT((ndo, "%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:
- ND_PRINT((ndo, "%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)
- ND_PRINT((ndo, "cfp "));
- if (u.u8 & IEEE80211_RADIOTAP_F_SHORTPRE)
- ND_PRINT((ndo, "short preamble "));
- if (u.u8 & IEEE80211_RADIOTAP_F_WEP)
- ND_PRINT((ndo, "wep "));
- if (u.u8 & IEEE80211_RADIOTAP_F_FRAG)
- ND_PRINT((ndo, "fragmented "));
- if (u.u8 & IEEE80211_RADIOTAP_F_BADFCS)
- ND_PRINT((ndo, "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:
- ND_PRINT((ndo, "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:
- ND_PRINT((ndo, "%" 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(ndo, 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)",
@@ -2738,15 +2824,24 @@ print_radiotap_field(netdissect_options *ndo,
};
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
@@ -2754,9 +2849,9 @@ print_radiotap_field(netdissect_options *ndo,
*/
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
@@ -2776,126 +2871,398 @@ print_radiotap_field(netdissect_options *ndo,
* We have the rate.
* Print it.
*/
- ND_PRINT((ndo, "%.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.
*/
- ND_PRINT((ndo, "MCS %u ", u3.u8));
+ ND_PRINT((ndo, "MCS %u ", mcs_index));
}
}
- if (u.u8 & IEEE80211_RADIOTAP_MCS_BANDWIDTH_KNOWN) {
+ if (known & IEEE80211_RADIOTAP_MCS_BANDWIDTH_KNOWN) {
ND_PRINT((ndo, "%s ",
- bandwidth[u2.u8 & IEEE80211_RADIOTAP_MCS_BANDWIDTH_MASK]));
+ ht_bandwidth[flags & IEEE80211_RADIOTAP_MCS_BANDWIDTH_MASK]));
}
- if (u.u8 & IEEE80211_RADIOTAP_MCS_GUARD_INTERVAL_KNOWN) {
+ if (known & IEEE80211_RADIOTAP_MCS_GUARD_INTERVAL_KNOWN) {
ND_PRINT((ndo, "%s GI ",
- (u2.u8 & IEEE80211_RADIOTAP_MCS_SHORT_GI) ?
- "short" : "lon"));
+ (flags & IEEE80211_RADIOTAP_MCS_SHORT_GI) ?
+ "short" : "long"));
}
- if (u.u8 & IEEE80211_RADIOTAP_MCS_HT_FORMAT_KNOWN) {
+ if (known & IEEE80211_RADIOTAP_MCS_HT_FORMAT_KNOWN) {
ND_PRINT((ndo, "%s ",
- (u2.u8 & IEEE80211_RADIOTAP_MCS_HT_GREENFIELD) ?
+ (flags & IEEE80211_RADIOTAP_MCS_HT_GREENFIELD) ?
"greenfield" : "mixed"));
}
- if (u.u8 & IEEE80211_RADIOTAP_MCS_FEC_TYPE_KNOWN) {
+ if (known & IEEE80211_RADIOTAP_MCS_FEC_TYPE_KNOWN) {
ND_PRINT((ndo, "%s FEC ",
- (u2.u8 & IEEE80211_RADIOTAP_MCS_FEC_LDPC) ?
+ (flags & IEEE80211_RADIOTAP_MCS_FEC_LDPC) ?
"LDPC" : "BCC"));
}
- if (u.u8 & IEEE80211_RADIOTAP_MCS_STBC_KNOWN) {
+ if (known & IEEE80211_RADIOTAP_MCS_STBC_KNOWN) {
ND_PRINT((ndo, "RX-STBC%u ",
- (u2.u8 & IEEE80211_RADIOTAP_MCS_STBC_MASK) >> IEEE80211_RADIOTAP_MCS_STBC_SHIFT));
+ (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 (known & IEEE80211_RADIOTAP_VHT_BANDWIDTH_KNOWN) {
+ ND_PRINT((ndo, "%s ",
+ vht_bandwidth[bandwidth & IEEE80211_RADIOTAP_VHT_BANDWIDTH_MASK]));
+ }
+ 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(netdissect_options *ndo,
- 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;
- uint32_t present, next_present;
- uint32_t presentflags = 0;
- uint32_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;
u_int len;
uint8_t flags;
int pad;
u_int fcslen;
- struct radiotap_state state;
if (caplen < sizeof(*hdr)) {
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) {
ND_PRINT((ndo, "%s", tstr));
return caplen;
}
- cpack_init(&cpacker, (uint8_t *)hdr, len); /* align against header start */
+ 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;
+ (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)) {
+ 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))) {
+
+ case 0:
+ /*
+ * We're not changing namespaces.
+ * advance to the next 32 bits in the current
+ * namespace.
+ */
+ bit0 += 32;
+ break;
- for (present = EXTRACT_LE_32BITS(presentp); present;
- present = next_present) {
- /* clear the least significant bit that is set */
- next_present = present & (present - 1);
+ 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;
- /* extract the least significant bit that is set */
- bit = (enum ieee80211_radiotap_type)
- (bit0 + BITNO_32(present ^ next_present));
+ 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;
- if (print_radiotap_field(ndo, &cpacker, bit, &flags, &state, presentflags) != 0)
- goto out;
+ 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)
diff --git a/contrib/tcpdump/print-802_15_4.c b/contrib/tcpdump/print-802_15_4.c
index 26c28ee..6fe6d35 100644
--- a/contrib/tcpdump/print-802_15_4.c
+++ b/contrib/tcpdump/print-802_15_4.c
@@ -20,14 +20,15 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#define NETDISSECT_REWORKED
+/* \summary: IEEE 802.15.4 printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "extract.h"
@@ -112,7 +113,7 @@ ieee802_15_4_if_print(netdissect_options *ndo,
if (ndo->ndo_vflag)
ND_PRINT((ndo,"seq %02x ", seq));
if (hdrlen == -1) {
- ND_PRINT((ndo,"malformed! "));
+ ND_PRINT((ndo,"invalid! "));
return caplen;
}
@@ -139,7 +140,7 @@ ieee802_15_4_if_print(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;
}
@@ -165,7 +166,7 @@ ieee802_15_4_if_print(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;
}
diff --git a/contrib/tcpdump/print-ah.c b/contrib/tcpdump/print-ah.c
index 0badf48..bec6f88 100644
--- a/contrib/tcpdump/print-ah.c
+++ b/contrib/tcpdump/print-ah.c
@@ -21,40 +21,40 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#define NETDISSECT_REWORKED
+/* \summary: IPSEC Authentication Header printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include "ah.h"
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
int
ah_print(netdissect_options *ndo, register const u_char *bp)
{
register const struct ah *ah;
- register const u_char *ep;
int sumlen;
- uint32_t spi;
ah = (const struct ah *)bp;
- ep = ndo->ndo_snapend; /* 'ep' points to the end of available data. */
ND_TCHECK(*ah);
sumlen = ah->ah_len << 2;
- spi = EXTRACT_32BITS(&ah->ah_spi);
- ND_PRINT((ndo, "AH(spi=0x%08x", spi));
+ 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 (bp + sizeof(struct ah) + sumlen > ep)
- ND_PRINT((ndo, "[truncated]"));
+ if (!ND_TTEST2(*bp, sizeof(struct ah) + sumlen)) {
+ ND_PRINT((ndo, "[truncated]):"));
+ return -1;
+ }
ND_PRINT((ndo, "): "));
return sizeof(struct ah) + sumlen;
diff --git a/contrib/tcpdump/print-ahcp.c b/contrib/tcpdump/print-ahcp.c
index a9ae38a..067b506 100644
--- a/contrib/tcpdump/print-ahcp.c
+++ b/contrib/tcpdump/print-ahcp.c
@@ -1,8 +1,4 @@
/*
- * This module implements decoding of AHCP (Ad Hoc Configuration Protocol) based
- * on draft-chroboczek-ahcp-00 and source code of ahcpd-0.53.
- *
- *
* Copyright (c) 2013 The TCPDUMP project
* All rights reserved.
*
@@ -29,19 +25,21 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#define NETDISSECT_REWORKED
+/* \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 <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
#include "addrtoname.h"
static const char tstr[] = " [|ahcp]";
-static const char cstr[] = "(corrupt)";
#define AHCP_MAGIC_NUMBER 43
#define AHCP_VERSION_1 1
@@ -107,7 +105,7 @@ ahcp_time_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
char buf[BUFSIZE];
if (cp + 4 != ep)
- goto corrupt;
+ goto invalid;
ND_TCHECK2(*cp, 4);
t = EXTRACT_32BITS(cp);
if (NULL == (tm = gmtime(&t)))
@@ -118,8 +116,8 @@ ahcp_time_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
ND_PRINT((ndo, ": %s UTC", buf));
return 0;
-corrupt:
- ND_PRINT((ndo, ": %s", cstr));
+invalid:
+ ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*cp, ep - cp);
return 0;
trunc:
@@ -131,13 +129,13 @@ static int
ahcp_seconds_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
{
if (cp + 4 != ep)
- goto corrupt;
+ goto invalid;
ND_TCHECK2(*cp, 4);
ND_PRINT((ndo, ": %us", EXTRACT_32BITS(cp)));
return 0;
-corrupt:
- ND_PRINT((ndo, ": %s", cstr));
+invalid:
+ ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*cp, ep - cp);
return 0;
trunc:
@@ -152,20 +150,16 @@ ahcp_ipv6_addresses_print(netdissect_options *ndo, const u_char *cp, const u_cha
while (cp < ep) {
if (cp + 16 > ep)
- goto corrupt;
+ goto invalid;
ND_TCHECK2(*cp, 16);
-#ifdef INET6
ND_PRINT((ndo, "%s%s", sep, ip6addr_string(ndo, cp)));
-#else
- ND_PRINT((ndo, "%s(compiled w/o IPv6)", sep));
-#endif /* INET6 */
cp += 16;
sep = ", ";
}
return 0;
-corrupt:
- ND_PRINT((ndo, ": %s", cstr));
+invalid:
+ ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*cp, ep - cp);
return 0;
trunc:
@@ -180,7 +174,7 @@ ahcp_ipv4_addresses_print(netdissect_options *ndo, const u_char *cp, const u_cha
while (cp < ep) {
if (cp + 4 > ep)
- goto corrupt;
+ goto invalid;
ND_TCHECK2(*cp, 4);
ND_PRINT((ndo, "%s%s", sep, ipaddr_string(ndo, cp)));
cp += 4;
@@ -188,8 +182,8 @@ ahcp_ipv4_addresses_print(netdissect_options *ndo, const u_char *cp, const u_cha
}
return 0;
-corrupt:
- ND_PRINT((ndo, ": %s", cstr));
+invalid:
+ ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*cp, ep - cp);
return 0;
trunc:
@@ -204,20 +198,16 @@ ahcp_ipv6_prefixes_print(netdissect_options *ndo, const u_char *cp, const u_char
while (cp < ep) {
if (cp + 17 > ep)
- goto corrupt;
+ goto invalid;
ND_TCHECK2(*cp, 17);
-#ifdef INET6
ND_PRINT((ndo, "%s%s/%u", sep, ip6addr_string(ndo, cp), *(cp + 16)));
-#else
- ND_PRINT((ndo, "%s(compiled w/o IPv6)/%u", sep, *(cp + 16)));
-#endif /* INET6 */
cp += 17;
sep = ", ";
}
return 0;
-corrupt:
- ND_PRINT((ndo, ": %s", cstr));
+invalid:
+ ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*cp, ep - cp);
return 0;
trunc:
@@ -232,7 +222,7 @@ ahcp_ipv4_prefixes_print(netdissect_options *ndo, const u_char *cp, const u_char
while (cp < ep) {
if (cp + 5 > ep)
- goto corrupt;
+ goto invalid;
ND_TCHECK2(*cp, 5);
ND_PRINT((ndo, "%s%s/%u", sep, ipaddr_string(ndo, cp), *(cp + 4)));
cp += 5;
@@ -240,8 +230,8 @@ ahcp_ipv4_prefixes_print(netdissect_options *ndo, const u_char *cp, const u_char
}
return 0;
-corrupt:
- ND_PRINT((ndo, ": %s", cstr));
+invalid:
+ ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*cp, ep - cp);
return 0;
trunc:
@@ -283,12 +273,12 @@ ahcp1_options_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
continue;
/* Length */
if (cp + 1 > ep)
- goto corrupt;
+ goto invalid;
ND_TCHECK2(*cp, 1);
option_len = *cp;
cp += 1;
if (cp + option_len > ep)
- goto corrupt;
+ 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)
@@ -301,8 +291,8 @@ ahcp1_options_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
}
return;
-corrupt:
- ND_PRINT((ndo, " %s", cstr));
+invalid:
+ ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*cp, ep - cp);
return;
trunc:
@@ -316,7 +306,7 @@ ahcp1_body_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
uint16_t body_len;
if (cp + AHCP1_BODY_MIN_LEN > ep)
- goto corrupt;
+ goto invalid;
/* Type */
ND_TCHECK2(*cp, 1);
type = *cp;
@@ -337,7 +327,7 @@ ahcp1_body_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
ND_PRINT((ndo, ", Length %u", body_len));
}
if (cp + body_len > ep)
- goto corrupt;
+ goto invalid;
/* Options */
if (ndo->ndo_vflag >= 2)
@@ -346,8 +336,8 @@ ahcp1_body_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
ND_TCHECK2(*cp, body_len);
return;
-corrupt:
- ND_PRINT((ndo, " %s", cstr));
+invalid:
+ ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*cp, ep - cp);
return;
trunc:
@@ -362,11 +352,11 @@ ahcp_print(netdissect_options *ndo, const u_char *cp, const u_int len)
ND_PRINT((ndo, "AHCP"));
if (len < 2)
- goto corrupt;
+ goto invalid;
/* Magic */
ND_TCHECK2(*cp, 1);
if (*cp != AHCP_MAGIC_NUMBER)
- goto corrupt;
+ goto invalid;
cp += 1;
/* Version */
ND_TCHECK2(*cp, 1);
@@ -376,7 +366,7 @@ ahcp_print(netdissect_options *ndo, const u_char *cp, const u_int len)
case AHCP_VERSION_1: {
ND_PRINT((ndo, " Version 1"));
if (len < AHCP1_HEADER_FIX_LEN)
- goto corrupt;
+ goto invalid;
if (!ndo->ndo_vflag) {
ND_TCHECK2(*cp, AHCP1_HEADER_FIX_LEN - 2);
cp += AHCP1_HEADER_FIX_LEN - 2;
@@ -412,8 +402,8 @@ ahcp_print(netdissect_options *ndo, const u_char *cp, const u_int len)
}
return;
-corrupt:
- ND_PRINT((ndo, " %s", cstr));
+invalid:
+ ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*cp, ep - cp);
return;
trunc:
diff --git a/contrib/tcpdump/print-aodv.c b/contrib/tcpdump/print-aodv.c
index ef27eee..6cd0c9e 100644
--- a/contrib/tcpdump/print-aodv.c
+++ b/contrib/tcpdump/print-aodv.c
@@ -30,16 +30,17 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#define NETDISSECT_REWORKED
+/* \summary: Ad hoc On-Demand Distance Vector (AODV) Routing printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.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"
struct aodv_rreq {
@@ -53,7 +54,6 @@ struct aodv_rreq {
uint32_t rreq_oa; /* originator IPv4 address */
uint32_t rreq_os; /* originator sequence number */
};
-#ifdef INET6
struct aodv_rreq6 {
uint8_t rreq_type; /* AODV message type (1) */
uint8_t rreq_flags; /* various flags */
@@ -76,7 +76,6 @@ struct aodv_rreq6_draft_01 {
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 */
@@ -95,7 +94,6 @@ struct aodv_rrep {
uint32_t rrep_oa; /* originator IPv4 address */
uint32_t rrep_life; /* lifetime of this route */
};
-#ifdef INET6
struct aodv_rrep6 {
uint8_t rrep_type; /* AODV message type (2) */
uint8_t rrep_flags; /* various flags */
@@ -116,7 +114,6 @@ struct aodv_rrep6_draft_01 {
struct in6_addr rrep_oa; /* originator IPv6 address */
uint32_t rrep_life; /* lifetime of this route */
};
-#endif
#define RREP_REPAIR 0x80 /* repair (reserved for multicast */
#define RREP_ACK 0x40 /* acknowledgement required */
@@ -127,7 +124,6 @@ struct rerr_unreach {
uint32_t u_da; /* IPv4 address */
uint32_t u_ds; /* sequence number */
};
-#ifdef INET6
struct rerr_unreach6 {
struct in6_addr u_da; /* IPv6 address */
uint32_t u_ds; /* sequence number */
@@ -136,7 +132,6 @@ struct rerr_unreach6_draft_01 {
struct in6_addr u_da; /* IPv6 address */
uint32_t u_ds; /* sequence number */
};
-#endif
struct aodv_rerr {
uint8_t rerr_type; /* AODV message type (3 or 18) */
@@ -275,7 +270,7 @@ aodv_rerr(netdissect_options *ndo, const u_char *dat, u_int length)
ND_PRINT((ndo, " rerr %s [items %u] [%u]:",
ap->rerr_flags & RERR_NODELETE ? "[D]" : "",
ap->rerr_dc, length));
- dp = (struct rerr_unreach *)(dat + sizeof(*ap));
+ dp = (const struct rerr_unreach *)(dat + sizeof(*ap));
i = length - sizeof(*ap);
for (dc = ap->rerr_dc; dc != 0; dc--) {
ND_TCHECK(*dp);
@@ -293,13 +288,8 @@ trunc:
}
static void
-#ifdef INET6
aodv_v6_rreq(netdissect_options *ndo, const u_char *dat, u_int length)
-#else
-aodv_v6_rreq(netdissect_options *ndo, const u_char *dat _U_, u_int length)
-#endif
{
-#ifdef INET6
u_int i;
const struct aodv_rreq6 *ap = (const struct aodv_rreq6 *)dat;
@@ -326,19 +316,11 @@ aodv_v6_rreq(netdissect_options *ndo, const u_char *dat _U_, u_int length)
trunc:
ND_PRINT((ndo, " [|rreq"));
-#else
- ND_PRINT((ndo, " v6 rreq %u", length));
-#endif
}
static void
-#ifdef INET6
aodv_v6_rrep(netdissect_options *ndo, const u_char *dat, u_int length)
-#else
-aodv_v6_rrep(netdissect_options *ndo, const u_char *dat _U_, u_int length)
-#endif
{
-#ifdef INET6
u_int i;
const struct aodv_rrep6 *ap = (const struct aodv_rrep6 *)dat;
@@ -362,19 +344,11 @@ aodv_v6_rrep(netdissect_options *ndo, const u_char *dat _U_, u_int length)
trunc:
ND_PRINT((ndo, " [|rreq"));
-#else
- ND_PRINT((ndo, " rrep %u", length));
-#endif
}
static void
-#ifdef INET6
aodv_v6_rerr(netdissect_options *ndo, const u_char *dat, u_int length)
-#else
-aodv_v6_rerr(netdissect_options *ndo, const u_char *dat _U_, u_int length)
-#endif
{
-#ifdef INET6
u_int i, dc;
const struct aodv_rerr *ap = (const struct aodv_rerr *)dat;
const struct rerr_unreach6 *dp6;
@@ -385,7 +359,7 @@ aodv_v6_rerr(netdissect_options *ndo, const u_char *dat _U_, u_int length)
ND_PRINT((ndo, " rerr %s [items %u] [%u]:",
ap->rerr_flags & RERR_NODELETE ? "[D]" : "",
ap->rerr_dc, length));
- dp6 = (struct rerr_unreach6 *)(void *)(ap + 1);
+ dp6 = (const struct rerr_unreach6 *)(const void *)(ap + 1);
i = length - sizeof(*ap);
for (dc = ap->rerr_dc; dc != 0; dc--) {
ND_TCHECK(*dp6);
@@ -400,19 +374,11 @@ aodv_v6_rerr(netdissect_options *ndo, const u_char *dat _U_, u_int length)
trunc:
ND_PRINT((ndo, "[|rerr]"));
-#else
- ND_PRINT((ndo, " rerr %u", length));
-#endif
}
static void
-#ifdef INET6
aodv_v6_draft_01_rreq(netdissect_options *ndo, const u_char *dat, u_int length)
-#else
-aodv_v6_draft_01_rreq(netdissect_options *ndo, const u_char *dat _U_, u_int length)
-#endif
{
-#ifdef INET6
u_int i;
const struct aodv_rreq6_draft_01 *ap = (const struct aodv_rreq6_draft_01 *)dat;
@@ -439,19 +405,11 @@ aodv_v6_draft_01_rreq(netdissect_options *ndo, const u_char *dat _U_, u_int leng
trunc:
ND_PRINT((ndo, " [|rreq"));
-#else
- ND_PRINT((ndo, " rreq %u", length));
-#endif
}
static void
-#ifdef INET6
aodv_v6_draft_01_rrep(netdissect_options *ndo, const u_char *dat, u_int length)
-#else
-aodv_v6_draft_01_rrep(netdissect_options *ndo, const u_char *dat _U_, u_int length)
-#endif
{
-#ifdef INET6
u_int i;
const struct aodv_rrep6_draft_01 *ap = (const struct aodv_rrep6_draft_01 *)dat;
@@ -475,19 +433,11 @@ aodv_v6_draft_01_rrep(netdissect_options *ndo, const u_char *dat _U_, u_int leng
trunc:
ND_PRINT((ndo, " [|rreq"));
-#else
- ND_PRINT((ndo, " rrep %u", length));
-#endif
}
static void
-#ifdef INET6
aodv_v6_draft_01_rerr(netdissect_options *ndo, const u_char *dat, u_int length)
-#else
-aodv_v6_draft_01_rerr(netdissect_options *ndo, const u_char *dat _U_, u_int length)
-#endif
{
-#ifdef INET6
u_int i, dc;
const struct aodv_rerr *ap = (const struct aodv_rerr *)dat;
const struct rerr_unreach6_draft_01 *dp6;
@@ -498,7 +448,7 @@ aodv_v6_draft_01_rerr(netdissect_options *ndo, const u_char *dat _U_, u_int leng
ND_PRINT((ndo, " rerr %s [items %u] [%u]:",
ap->rerr_flags & RERR_NODELETE ? "[D]" : "",
ap->rerr_dc, length));
- dp6 = (struct rerr_unreach6_draft_01 *)(void *)(ap + 1);
+ 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);
@@ -513,9 +463,6 @@ aodv_v6_draft_01_rerr(netdissect_options *ndo, const u_char *dat _U_, u_int leng
trunc:
ND_PRINT((ndo, "[|rerr]"));
-#else
- ND_PRINT((ndo, " rerr %u", length));
-#endif
}
void
diff --git a/contrib/tcpdump/print-aoe.c b/contrib/tcpdump/print-aoe.c
index f8bc1fc..97e93df 100644
--- a/contrib/tcpdump/print-aoe.c
+++ b/contrib/tcpdump/print-aoe.c
@@ -1,8 +1,4 @@
/*
- * This module implements decoding of the ATA over Ethernet (AoE) protocol
- * according to the following specification:
- * http://support.coraid.com/documents/AoEr11.txt
- *
* Copyright (c) 2014 The TCPDUMP project
* All rights reserved.
*
@@ -29,20 +25,22 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#define NETDISSECT_REWORKED
+/* \summary: ATA over Ethernet (AoE) protocol printer */
+
+/* specification: http://brantleycoilecompany.com/AoEr11.pdf */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
#include "addrtoname.h"
#include "ether.h"
static const char tstr[] = " [|aoe]";
-static const char cstr[] = " (corrupt)";
#define AOE_V1 1
#define ATA_SECTOR_SIZE 512
@@ -148,7 +146,7 @@ aoev1_issue_print(netdissect_options *ndo,
const u_char *ep = cp + len;
if (len < AOEV1_ISSUE_ARG_LEN)
- goto corrupt;
+ goto invalid;
/* AFlags */
ND_TCHECK2(*cp, 1);
ND_PRINT((ndo, "\n\tAFlags: [%s]", bittok2str(aoev1_aflag_str, "none", *cp)));
@@ -197,8 +195,8 @@ aoev1_issue_print(netdissect_options *ndo,
ND_PRINT((ndo, "\n\tData: %u bytes", len - AOEV1_ISSUE_ARG_LEN));
return;
-corrupt:
- ND_PRINT((ndo, "%s", cstr));
+invalid:
+ ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*cp, ep - cp);
return;
trunc:
@@ -213,7 +211,7 @@ aoev1_query_print(netdissect_options *ndo,
uint16_t cslen;
if (len < AOEV1_QUERY_ARG_LEN)
- goto corrupt;
+ goto invalid;
/* Buffer Count */
ND_TCHECK2(*cp, 2);
ND_PRINT((ndo, "\n\tBuffer Count: %u", EXTRACT_16BITS(cp)));
@@ -236,7 +234,7 @@ aoev1_query_print(netdissect_options *ndo,
cslen = EXTRACT_16BITS(cp);
cp += 2;
if (cslen > AOEV1_MAX_CONFSTR_LEN || AOEV1_QUERY_ARG_LEN + cslen > len)
- goto corrupt;
+ goto invalid;
/* Config String */
ND_TCHECK2(*cp, cslen);
if (cslen) {
@@ -246,8 +244,8 @@ aoev1_query_print(netdissect_options *ndo,
}
return;
-corrupt:
- ND_PRINT((ndo, "%s", cstr));
+invalid:
+ ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*cp, ep - cp);
return;
trunc:
@@ -262,7 +260,7 @@ aoev1_mac_print(netdissect_options *ndo,
uint8_t dircount, i;
if (len < AOEV1_MAC_ARG_LEN)
- goto corrupt;
+ goto invalid;
/* Reserved */
ND_TCHECK2(*cp, 1);
cp += 1;
@@ -280,7 +278,7 @@ aoev1_mac_print(netdissect_options *ndo,
cp += 1;
ND_PRINT((ndo, ", Dir Count: %u", dircount));
if (AOEV1_MAC_ARG_LEN + dircount * 8 > len)
- goto corrupt;
+ goto invalid;
/* directives */
for (i = 0; i < dircount; i++) {
/* Reserved */
@@ -297,8 +295,8 @@ aoev1_mac_print(netdissect_options *ndo,
}
return;
-corrupt:
- ND_PRINT((ndo, "%s", cstr));
+invalid:
+ ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*cp, ep - cp);
return;
trunc:
@@ -313,7 +311,7 @@ aoev1_reserve_print(netdissect_options *ndo,
uint8_t nmacs, i;
if (len < AOEV1_RESERVE_ARG_LEN || (len - AOEV1_RESERVE_ARG_LEN) % ETHER_ADDR_LEN)
- goto corrupt;
+ goto invalid;
/* RCmd */
ND_TCHECK2(*cp, 1);
ND_PRINT((ndo, "\n\tRCmd: %s", tok2str(aoev1_rcmd_str, "Unknown (0x%02x)", *cp)));
@@ -324,7 +322,7 @@ aoev1_reserve_print(netdissect_options *ndo,
cp += 1;
ND_PRINT((ndo, ", NMacs: %u", nmacs));
if (AOEV1_RESERVE_ARG_LEN + nmacs * ETHER_ADDR_LEN != len)
- goto corrupt;
+ goto invalid;
/* addresses */
for (i = 0; i < nmacs; i++) {
ND_PRINT((ndo, "\n\tEthernet Address %u: %s", i, etheraddr_string(ndo, cp)));
@@ -332,8 +330,8 @@ aoev1_reserve_print(netdissect_options *ndo,
}
return;
-corrupt:
- ND_PRINT((ndo, "%s", cstr));
+invalid:
+ ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*cp, ep - cp);
return;
trunc:
@@ -350,7 +348,7 @@ aoev1_print(netdissect_options *ndo,
void (*cmd_decoder)(netdissect_options *, const u_char *, const u_int);
if (len < AOEV1_COMMON_HDR_LEN)
- goto corrupt;
+ goto invalid;
/* Flags */
flags = *cp & 0x0F;
ND_PRINT((ndo, ", Flags: [%s]", bittok2str(aoev1_flag_str, "none", flags)));
@@ -390,8 +388,8 @@ aoev1_print(netdissect_options *ndo,
cmd_decoder(ndo, cp, len - AOEV1_COMMON_HDR_LEN);
return;
-corrupt:
- ND_PRINT((ndo, "%s", cstr));
+invalid:
+ ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*cp, ep - cp);
return;
trunc:
@@ -408,7 +406,7 @@ aoe_print(netdissect_options *ndo,
ND_PRINT((ndo, "AoE length %u", len));
if (len < 1)
- goto corrupt;
+ goto invalid;
/* Ver/Flags */
ND_TCHECK2(*cp, 1);
ver = (*cp & 0xF0) >> 4;
@@ -422,8 +420,8 @@ aoe_print(netdissect_options *ndo,
}
return;
-corrupt:
- ND_PRINT((ndo, "%s", cstr));
+invalid:
+ ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*cp, ep - cp);
return;
trunc:
diff --git a/contrib/tcpdump/print-ap1394.c b/contrib/tcpdump/print-ap1394.c
index 3befe23..79401cb 100644
--- a/contrib/tcpdump/print-ap1394.c
+++ b/contrib/tcpdump/print-ap1394.c
@@ -19,14 +19,15 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#define NETDISSECT_REWORKED
+/* \summary: Apple IP-over-IEEE 1394 printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
#include "addrtoname.h"
#include "ethertype.h"
@@ -48,6 +49,12 @@ 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(netdissect_options *ndo, register const u_char *bp, u_int length)
{
@@ -57,8 +64,8 @@ ap1394_hdr_print(netdissect_options *ndo, register const u_char *bp, u_int lengt
fp = (const struct firewire_header *)bp;
ND_PRINT((ndo, "%s > %s",
- linkaddr_string(ndo, fp->firewire_dhost, LINKADDR_IEEE1394, FIREWIRE_EUI64_LEN),
- linkaddr_string(ndo, fp->firewire_shost, LINKADDR_IEEE1394, FIREWIRE_EUI64_LEN)));
+ fwaddr_string(ndo, fp->firewire_shost),
+ fwaddr_string(ndo, fp->firewire_dhost)));
firewire_type = EXTRACT_16BITS(&fp->firewire_type);
if (!ndo->ndo_qflag) {
@@ -83,8 +90,9 @@ ap1394_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_ch
{
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) {
ND_PRINT((ndo, "[|ap1394]"));
@@ -96,14 +104,18 @@ ap1394_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_ch
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(ndo, 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 (!ndo->ndo_eflag)
- ap1394_hdr_print(ndo, (u_char *)fp, length + FIREWIRE_HDRLEN);
+ ap1394_hdr_print(ndo, (const u_char *)fp, length + FIREWIRE_HDRLEN);
if (!ndo->ndo_suppress_default_print)
ND_DEFAULTPRINT(p, caplen);
diff --git a/contrib/tcpdump/print-arcnet.c b/contrib/tcpdump/print-arcnet.c
index 0ffb922..abc19b8 100644
--- a/contrib/tcpdump/print-arcnet.c
+++ b/contrib/tcpdump/print-arcnet.c
@@ -21,14 +21,15 @@
* From: NetBSD: print-arcnet.c,v 1.2 2000/04/24 13:02:28 itojun Exp
*/
-#define NETDISSECT_REWORKED
+/* \summary: Attached Resource Computer NETwork (ARCNET) printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
/*
diff --git a/contrib/tcpdump/print-arp.c b/contrib/tcpdump/print-arp.c
index 883099b..eff97c4 100644
--- a/contrib/tcpdump/print-arp.c
+++ b/contrib/tcpdump/print-arp.c
@@ -17,24 +17,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$
*/
-#define NETDISSECT_REWORKED
+/* \summary: Address Resolution Protocol (ARP) printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <string.h>
-#include "interface.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]";
@@ -178,7 +177,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,
@@ -359,7 +368,7 @@ arp_print(netdissect_options *ndo,
case ARPOP_REQUEST:
ND_PRINT((ndo, "who-has %s", ipaddr_string(ndo, TPA(ap))));
- if (memcmp((const char *)ezero, (const char *)THA(ap), HRD_LEN(ap)) != 0)
+ if (isnonzero((const u_char *)THA(ap), HRD_LEN(ap)))
ND_PRINT((ndo, " (%s)",
linkaddr_string(ndo, THA(ap), linkaddr, HRD_LEN(ap))));
ND_PRINT((ndo, " tell %s", ipaddr_string(ndo, SPA(ap))));
diff --git a/contrib/tcpdump/print-ascii.c b/contrib/tcpdump/print-ascii.c
index 3cefef3..4ef38a1 100644
--- a/contrib/tcpdump/print-ascii.c
+++ b/contrib/tcpdump/print-ascii.c
@@ -36,15 +36,16 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#define NETDISSECT_REWORKED
+/* \summary: ASCII packet dump 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"
#define ASCII_LINELENGTH 300
#define HEXDUMP_BYTES_PER_LINE 16
diff --git a/contrib/tcpdump/print-atalk.c b/contrib/tcpdump/print-atalk.c
index 7d210be..9d7d69d 100644
--- a/contrib/tcpdump/print-atalk.c
+++ b/contrib/tcpdump/print-atalk.c
@@ -17,26 +17,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.
- *
- * Format and print AppleTalk packets.
- *
- * $FreeBSD$
*/
-#define NETDISSECT_REWORKED
+/* \summary: AppleTalk 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 "extract.h" /* must come after interface.h */
+#include "extract.h"
#include "appletalk.h"
static const char tstr[] = "[|atalk]";
@@ -80,7 +77,14 @@ u_int
ltalk_if_print(netdissect_options *ndo,
const struct pcap_pkthdr *h, const u_char *p)
{
- return (llap_print(ndo, 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);
}
/*
@@ -100,6 +104,10 @@ llap_print(netdissect_options *ndo,
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);
@@ -111,6 +119,10 @@ llap_print(netdissect_options *ndo,
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;
ND_PRINT((ndo, "%s.%s",
ataddr_string(ndo, 0, lp->src), ddpskt_string(ndo, sdp->srcSkt)));
@@ -127,6 +139,10 @@ llap_print(netdissect_options *ndo,
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);
ND_PRINT((ndo, "%s.%s", ataddr_string(ndo, snet, dp->srcNode),
@@ -173,6 +189,10 @@ atalk_print(netdissect_options *ndo,
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);
ND_PRINT((ndo, "%s.%s", ataddr_string(ndo, snet, dp->srcNode),
@@ -196,6 +216,15 @@ aarp_print(netdissect_options *ndo,
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 )
@@ -382,7 +411,7 @@ nbp_print(netdissect_options *ndo,
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;
@@ -569,8 +598,11 @@ ataddr_string(netdissect_options *ndo,
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);
}
@@ -584,20 +616,25 @@ ataddr_string(netdissect_options *ndo,
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);
}
diff --git a/contrib/tcpdump/print-atm.c b/contrib/tcpdump/print-atm.c
index 8f1277b..596e406 100644
--- a/contrib/tcpdump/print-atm.c
+++ b/contrib/tcpdump/print-atm.c
@@ -17,24 +17,112 @@
* 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$
*/
-#define NETDISSECT_REWORKED
+/* \summary: Asynchronous Transfer Mode (ATM) printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
#include "addrtoname.h"
#include "atm.h"
-#include "atmuni31.h"
#include "llc.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
@@ -128,22 +216,20 @@ static const struct tok *oam_functype_values[16] = {
/*
* Print an RFC 1483 LLC-encapsulated ATM frame.
*/
-static void
+static u_int
atm_llc_print(netdissect_options *ndo,
const u_char *p, int length, int caplen)
{
- u_short extracted_ethertype;
-
- if (!llc_print(ndo, p, length, caplen, NULL, NULL,
- &extracted_ethertype)) {
- /* ether_type not known, print raw packet */
- if (extracted_ethertype) {
- ND_PRINT((ndo, "(LLC %s) ",
- etherproto_string(htons(extracted_ethertype))));
- }
+ 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);
}
/*
@@ -231,7 +317,7 @@ atm_if_print(netdissect_options *ndo,
caplen -= 20;
hdrlen += 20;
}
- atm_llc_print(ndo, p, length, caplen);
+ hdrlen += atm_llc_print(ndo, p, length, caplen);
return (hdrlen);
}
@@ -259,24 +345,18 @@ static const struct tok msgtype2str[] = {
static void
sig_print(netdissect_options *ndo,
- const u_char *p, int caplen)
+ const u_char *p)
{
uint32_t call_ref;
- if (caplen < PROTO_POS) {
- ND_PRINT((ndo, "%s", tstr));
- return;
- }
+ ND_TCHECK(p[PROTO_POS]);
if (p[PROTO_POS] == Q2931) {
/*
* protocol:Q.2931 for User to Network Interface
* (UNI 3.1) signalling
*/
ND_PRINT((ndo, "Q.2931"));
- if (caplen < MSG_TYPE_POS) {
- ND_PRINT((ndo, " %s", tstr));
- return;
- }
+ ND_TCHECK(p[MSG_TYPE_POS]);
ND_PRINT((ndo, ":%s ",
tok2str(msgtype2str, "msgtype#%d", p[MSG_TYPE_POS])));
@@ -292,6 +372,10 @@ sig_print(netdissect_options *ndo,
/* SCCOP with some unknown protocol atop it */
ND_PRINT((ndo, "SSCOP, proto %d ", p[PROTO_POS]));
}
+ return;
+
+trunc:
+ ND_PRINT((ndo, " %s", tstr));
}
/*
@@ -309,7 +393,7 @@ atm_print(netdissect_options *ndo,
switch (vci) {
case VCI_PPC:
- sig_print(ndo, p, caplen);
+ sig_print(ndo, p);
return;
case VCI_BCC:
@@ -362,7 +446,7 @@ struct oam_fm_ais_rdi_t {
uint8_t unused[28];
};
-int
+void
oam_print (netdissect_options *ndo,
const u_char *p, u_int length, u_int hec)
{
@@ -376,6 +460,7 @@ oam_print (netdissect_options *ndo,
} 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;
@@ -392,7 +477,7 @@ oam_print (netdissect_options *ndo,
clp, length));
if (!ndo->ndo_vflag) {
- return 1;
+ return;
}
ND_PRINT((ndo, "\n\tcell-type %s (%u)",
@@ -411,6 +496,7 @@ oam_print (netdissect_options *ndo,
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);
+ 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",
@@ -433,6 +519,7 @@ oam_print (netdissect_options *ndo,
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);
+ 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++) {
@@ -451,6 +538,7 @@ oam_print (netdissect_options *ndo,
}
/* 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);
@@ -459,5 +547,9 @@ oam_print (netdissect_options *ndo,
cksum,
cksum_shouldbe == 0 ? "" : "in"));
- return 1;
+ return;
+
+trunc:
+ ND_PRINT((ndo, "[|oam]"));
+ return;
}
diff --git a/contrib/tcpdump/print-babel.c b/contrib/tcpdump/print-babel.c
index 75cb32c..f8741d7 100644
--- a/contrib/tcpdump/print-babel.c
+++ b/contrib/tcpdump/print-babel.c
@@ -26,17 +26,18 @@
* SUCH DAMAGE.
*/
-#define NETDISSECT_REWORKED
+/* \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 "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "extract.h"
@@ -53,7 +54,7 @@ babel_print(netdissect_options *ndo,
ND_TCHECK2(*cp, 4);
if(cp[0] != 42) {
- ND_PRINT((ndo, " malformed header"));
+ ND_PRINT((ndo, " invalid header"));
return;
} else {
ND_PRINT((ndo, " %d", cp[1]));
@@ -89,6 +90,9 @@ babel_print(netdissect_options *ndo,
#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
@@ -123,11 +127,7 @@ format_prefix(netdissect_options *ndo, const u_char *prefix, unsigned char plen)
if(plen >= 96 && memcmp(prefix, v4prefix, 12) == 0)
snprintf(buf, 50, "%s/%u", ipaddr_string(ndo, prefix + 12), plen - 96);
else
-#ifdef INET6
snprintf(buf, 50, "%s/%u", ip6addr_string(ndo, prefix), plen);
-#else
- snprintf(buf, 50, "IPv6 addresses not supported");
-#endif
buf[49] = '\0';
return buf;
}
@@ -138,11 +138,7 @@ format_address(netdissect_options *ndo, const u_char *prefix)
if(memcmp(prefix, v4prefix, 12) == 0)
return ipaddr_string(ndo, prefix + 12);
else
-#ifdef INET6
return ip6addr_string(ndo, prefix);
-#else
- return "IPv6 addresses not supported";
-#endif
}
static const char *
@@ -284,10 +280,10 @@ subtlvs_print(netdissect_options *ndo,
continue;
}
if(cp == ep)
- goto corrupt;
+ goto invalid;
sublen = *cp++;
if(cp + sublen > ep)
- goto corrupt;
+ goto invalid;
switch(subtype) {
case MESSAGE_SUB_PADN:
@@ -305,19 +301,20 @@ subtlvs_print(netdissect_options *ndo,
ND_PRINT((ndo, "%s%s", sep, tok2str(diversity_str, "%u", *cp++)));
sep = "-";
}
- if(tlv_type != MESSAGE_UPDATE)
+ 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 corrupt;
+ goto invalid;
t1 = EXTRACT_32BITS(cp);
ND_PRINT((ndo, " %s", format_timestamp(t1)));
} else if(tlv_type == MESSAGE_IHU) {
if(sublen < 8)
- goto corrupt;
+ goto invalid;
t1 = EXTRACT_32BITS(cp);
ND_PRINT((ndo, " %s", format_timestamp(t1)));
t2 = EXTRACT_32BITS(cp + 4);
@@ -333,12 +330,12 @@ subtlvs_print(netdissect_options *ndo,
} /* while */
return;
- corrupt:
- ND_PRINT((ndo, " (corrupt)"));
+ 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(netdissect_options *ndo,
@@ -352,7 +349,7 @@ babel_print_v2(netdissect_options *ndo,
ND_TCHECK2(*cp, 4);
if (length < 4)
- goto corrupt;
+ goto invalid;
bodylen = EXTRACT_16BITS(cp + 2);
ND_PRINT((ndo, " (%u)", bodylen));
@@ -393,7 +390,7 @@ babel_print_v2(netdissect_options *ndo,
ND_PRINT((ndo, " ack-req"));
else {
ND_PRINT((ndo, "\n\tAcknowledgment Request "));
- if(len < 6) goto corrupt;
+ if(len < 6) goto invalid;
nonce = EXTRACT_16BITS(message + 4);
interval = EXTRACT_16BITS(message + 6);
ND_PRINT((ndo, "%04x %s", nonce, format_interval(interval)));
@@ -407,7 +404,7 @@ babel_print_v2(netdissect_options *ndo,
ND_PRINT((ndo, " ack"));
else {
ND_PRINT((ndo, "\n\tAcknowledgment "));
- if(len < 2) goto corrupt;
+ if(len < 2) goto invalid;
nonce = EXTRACT_16BITS(message + 2);
ND_PRINT((ndo, "%04x", nonce));
}
@@ -420,7 +417,7 @@ babel_print_v2(netdissect_options *ndo,
ND_PRINT((ndo, " hello"));
else {
ND_PRINT((ndo, "\n\tHello "));
- if(len < 6) goto corrupt;
+ if(len < 6) goto invalid;
seqno = EXTRACT_16BITS(message + 4);
interval = EXTRACT_16BITS(message + 6);
ND_PRINT((ndo, "seqno %u interval %s", seqno, format_interval(interval)));
@@ -439,7 +436,7 @@ babel_print_v2(netdissect_options *ndo,
u_char address[16];
int rc;
ND_PRINT((ndo, "\n\tIHU "));
- if(len < 6) goto corrupt;
+ 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);
@@ -459,7 +456,7 @@ babel_print_v2(netdissect_options *ndo,
ND_PRINT((ndo, " router-id"));
else {
ND_PRINT((ndo, "\n\tRouter Id"));
- if(len < 10) goto corrupt;
+ if(len < 10) goto invalid;
ND_PRINT((ndo, " %s", format_id(message + 4)));
}
}
@@ -472,9 +469,9 @@ babel_print_v2(netdissect_options *ndo,
int rc;
u_char nh[16];
ND_PRINT((ndo, "\n\tNext Hop"));
- if(len < 2) goto corrupt;
+ if(len < 2) goto invalid;
rc = network_address(message[2], message + 4, len - 2, nh);
- if(rc < 0) goto corrupt;
+ if(rc < 0) goto invalid;
ND_PRINT((ndo, " %s", format_address(ndo, nh)));
}
}
@@ -496,13 +493,13 @@ babel_print_v2(netdissect_options *ndo,
int rc;
u_char prefix[16];
ND_PRINT((ndo, "\n\tUpdate"));
- if(len < 10) goto corrupt;
+ 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);
@@ -532,11 +529,11 @@ babel_print_v2(netdissect_options *ndo,
int rc;
u_char prefix[16], plen;
ND_PRINT((ndo, "\n\tRequest "));
- if(len < 2) goto corrupt;
+ 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;
+ if(rc < 0) goto invalid;
ND_PRINT((ndo, "for %s",
message[2] == 0 ? "any" : format_prefix(ndo, prefix, plen)));
}
@@ -551,11 +548,11 @@ babel_print_v2(netdissect_options *ndo,
u_short seqno;
u_char prefix[16], plen;
ND_PRINT((ndo, "\n\tMH-Request "));
- if(len < 14) goto corrupt;
+ 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);
ND_PRINT((ndo, "(%u hops) for %s seqno %u id %s",
message[6], format_prefix(ndo, prefix, plen),
@@ -568,7 +565,7 @@ babel_print_v2(netdissect_options *ndo,
ND_PRINT((ndo, " tspc"));
else {
ND_PRINT((ndo, "\n\tTS/PC "));
- if(len < 6) goto corrupt;
+ if(len < 6) goto invalid;
ND_PRINT((ndo, "timestamp %u packetcounter %u", EXTRACT_32BITS (message + 4),
EXTRACT_16BITS(message + 2)));
}
@@ -579,13 +576,127 @@ babel_print_v2(netdissect_options *ndo,
else {
unsigned j;
ND_PRINT((ndo, "\n\tHMAC "));
- if(len < 18) goto corrupt;
+ 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++)
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 (!ndo->ndo_vflag)
ND_PRINT((ndo, " unknown"));
@@ -600,7 +711,7 @@ babel_print_v2(netdissect_options *ndo,
ND_PRINT((ndo, " %s", tstr));
return;
- corrupt:
- ND_PRINT((ndo, " (corrupt)"));
+ invalid:
+ ND_PRINT((ndo, "%s", istr));
return;
}
diff --git a/contrib/tcpdump/print-beep.c b/contrib/tcpdump/print-beep.c
index 7982feb..ed502b9 100644
--- a/contrib/tcpdump/print-beep.c
+++ b/contrib/tcpdump/print-beep.c
@@ -2,23 +2,24 @@
* 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
*
*/
-#define NETDISSECT_REWORKED
+/* \summary: Blocks Extensible Exchange Protocol (BEEP) printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <string.h>
-#include "interface.h"
+#include "netdissect.h"
/* Check for a string but not go beyond length
* Return TRUE on match, FALSE otherwise
diff --git a/contrib/tcpdump/print-bfd.c b/contrib/tcpdump/print-bfd.c
index f1c2ee8..ad0a406 100644
--- a/contrib/tcpdump/print-bfd.c
+++ b/contrib/tcpdump/print-bfd.c
@@ -13,14 +13,17 @@
* Original code by Hannes Gredler (hannes@juniper.net)
*/
-#define NETDISSECT_REWORKED
+/* \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 <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
#include "udp.h"
@@ -46,12 +49,12 @@
*/
/*
- * 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 |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
@@ -91,20 +94,37 @@ struct bfd_auth_header_t {
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" },
@@ -112,7 +132,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" },
@@ -127,14 +146,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 }
};
@@ -146,7 +165,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 }
};
@@ -158,12 +177,122 @@ 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(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;
uint8_t version = 0;
bfd_header = (const struct bfd_header_t *)pptr;
@@ -244,13 +373,8 @@ bfd_print(netdissect_options *ndo, register const u_char *pptr,
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;
- ND_TCHECK2(*bfd_auth_header, sizeof(const struct bfd_auth_header_t));
- ND_PRINT((ndo, "\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;
diff --git a/contrib/tcpdump/print-bgp.c b/contrib/tcpdump/print-bgp.c
index c617c3b..79afeab 100644
--- a/contrib/tcpdump/print-bgp.c
+++ b/contrib/tcpdump/print-bgp.c
@@ -30,17 +30,18 @@
* complete BGP support.
*/
-#define NETDISSECT_REWORKED
+/* \summary: Border Gateway Protocol (BGP) 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 "af.h"
@@ -121,18 +122,25 @@ 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 */
@@ -156,6 +164,13 @@ static const 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}
@@ -188,28 +203,37 @@ static const struct tok bgp_as_path_segment_close_values[] = {
#define BGP_OPT_AUTH 1
#define BGP_OPT_CAP 2
-
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 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}
};
@@ -279,6 +303,13 @@ static const struct tok bgp_notify_minor_update_values[] = {
{ 0, NULL}
};
+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" },
@@ -318,25 +349,34 @@ static const struct tok bgp_pmsi_flag_values[] = {
{ 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
@@ -390,7 +430,6 @@ static const 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
@@ -454,7 +493,14 @@ static const struct tok bgp_extd_comm_ospf_rtype_values[] = {
{ 0, NULL },
};
-#define TOKBUFSIZE 128
+/* ADD-PATH Send/Receive field values */
+static const struct tok bgp_add_path_recvsend[] = {
+ { 1, "Receive" },
+ { 2, "Send" },
+ { 3, "Both" },
+ { 0, NULL },
+};
+
static char astostr[20];
/*
@@ -503,7 +549,7 @@ decode_prefix4(netdissect_options *ndo,
((u_char *)&addr)[plenbytes - 1] &=
((0xff00 >> (plen % 8)) & 0xff);
}
- snprintf(buf, buflen, "%s/%d", getname(ndo, (u_char *)&addr), plen);
+ snprintf(buf, buflen, "%s/%d", ipaddr_string(ndo, &addr), plen);
return 1 + plenbytes;
trunc:
@@ -553,7 +599,7 @@ decode_labeled_prefix4(netdissect_options *ndo,
}
/* the label may get offsetted by 4 bits so lets shift it right */
snprintf(buf, buflen, "%s/%d, label:%u %s",
- getname(ndo, (u_char *)&addr),
+ ipaddr_string(ndo, &addr),
plen,
EXTRACT_24BITS(pptr+1)>>4,
((pptr[3]&1)==0) ? "(BOGUS: Bottom of Stack NOT set!)" : "(bottom)" );
@@ -586,12 +632,10 @@ bgp_vpn_ip_print(netdissect_options *ndo,
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 */
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;
@@ -662,7 +706,6 @@ trunc:
return (total_length);
}
-
/* RDs and RTs share the same semantics
* we use bgp_vpn_rd_print for
* printing route targets inside a NLRI */
@@ -775,7 +818,7 @@ decode_labeled_vpn_prefix4(netdissect_options *ndo,
/* 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(ndo, pptr+4),
- getname(ndo, (u_char *)&addr),
+ ipaddr_string(ndo, &addr),
plen,
EXTRACT_24BITS(pptr+1)>>4,
((pptr[3]&1)==0) ? "(BOGUS: Bottom of Stack NOT set!)" : "(bottom)" );
@@ -951,21 +994,21 @@ 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(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;
ND_TCHECK2(pptr[0], 2);
plen=EXTRACT_16BITS(pptr);
@@ -979,12 +1022,11 @@ decode_labeled_vpn_l2(netdissect_options *ndo,
/* assume AD-only with RD, BGPNH */
ND_TCHECK2(pptr[0],12);
buf[0]='\0';
- strlen=snprintf(buf, buflen, "RD: %s, BGPNH: %s",
- bgp_vpn_rd_print(ndo, pptr),
- /* need something like getname(ndo, ) here */
- getname(ndo, 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;
@@ -994,12 +1036,12 @@ decode_labeled_vpn_l2(netdissect_options *ndo,
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(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, 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;
@@ -1016,27 +1058,27 @@ decode_labeled_vpn_l2(netdissect_options *ndo,
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) {
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;
}
@@ -1054,7 +1096,6 @@ trunc:
return -2;
}
-#ifdef INET6
int
decode_prefix6(netdissect_options *ndo,
const u_char *pd, u_int itemlen, char *buf, u_int buflen)
@@ -1078,7 +1119,7 @@ decode_prefix6(netdissect_options *ndo,
addr.s6_addr[plenbytes - 1] &=
((0xff00 >> (plen % 8)) & 0xff);
}
- snprintf(buf, buflen, "%s/%d", getname6(ndo, (u_char *)&addr), plen);
+ snprintf(buf, buflen, "%s/%d", ip6addr_string(ndo, &addr), plen);
return 1 + plenbytes;
trunc:
@@ -1119,7 +1160,7 @@ decode_labeled_prefix6(netdissect_options *ndo,
}
/* the label may get offsetted by 4 bits so lets shift it right */
snprintf(buf, buflen, "%s/%d, label:%u %s",
- getname6(ndo, (u_char *)&addr),
+ ip6addr_string(ndo, &addr),
plen,
EXTRACT_24BITS(pptr+1)>>4,
((pptr[3]&1)==0) ? "(BOGUS: Bottom of Stack NOT set!)" : "(bottom)" );
@@ -1161,7 +1202,7 @@ decode_labeled_vpn_prefix6(netdissect_options *ndo,
/* 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(ndo, pptr+4),
- getname6(ndo, (u_char *)&addr),
+ ip6addr_string(ndo, &addr),
plen,
EXTRACT_24BITS(pptr+1)>>4,
((pptr[3]&1)==0) ? "(BOGUS: Bottom of Stack NOT set!)" : "(bottom)" );
@@ -1171,7 +1212,6 @@ decode_labeled_vpn_prefix6(netdissect_options *ndo,
trunc:
return -2;
}
-#endif
static int
decode_clnp_prefix(netdissect_options *ndo,
@@ -1194,7 +1234,7 @@ decode_clnp_prefix(netdissect_options *ndo,
((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;
@@ -1231,7 +1271,7 @@ decode_labeled_vpn_clnp_prefix(netdissect_options *ndo,
/* 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(ndo, pptr+4),
- isonsap_string(addr,(plen + 7) / 8),
+ isonsap_string(ndo, addr,(plen + 7) / 8),
plen,
EXTRACT_24BITS(pptr+1)>>4,
((pptr[3]&1)==0) ? "(BOGUS: Bottom of Stack NOT set!)" : "(bottom)" );
@@ -1315,7 +1355,6 @@ bgp_attr_print(netdissect_options *ndo,
u_int tlen;
const u_char *tptr;
char buf[MAXHOSTNAMELEN + 100];
- char tokbuf[TOKBUFSIZE];
int as_size;
tptr = pptr;
@@ -1327,14 +1366,12 @@ bgp_attr_print(netdissect_options *ndo,
ND_PRINT((ndo, "invalid len"));
else {
ND_TCHECK(*tptr);
- ND_PRINT((ndo, "%s", tok2strbuf(bgp_origin_values,
+ 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.
*/
@@ -1361,9 +1398,8 @@ bgp_attr_print(netdissect_options *ndo,
while (tptr < pptr + len) {
ND_TCHECK(tptr[0]);
- ND_PRINT((ndo, "%s", tok2strbuf(bgp_as_path_segment_open_values,
- "?", tptr[0],
- tokbuf, sizeof(tokbuf))));
+ ND_PRINT((ndo, "%s", tok2str(bgp_as_path_segment_open_values,
+ "?", tptr[0])));
for (i = 0; i < tptr[1] * as_size; i += as_size) {
ND_TCHECK2(tptr[2 + i], as_size);
ND_PRINT((ndo, "%s ",
@@ -1373,9 +1409,8 @@ bgp_attr_print(netdissect_options *ndo,
EXTRACT_32BITS(&tptr[2 + i]))));
}
ND_TCHECK(tptr[0]);
- ND_PRINT((ndo, "%s", tok2strbuf(bgp_as_path_segment_close_values,
- "?", tptr[0],
- tokbuf, sizeof(tokbuf))));
+ ND_PRINT((ndo, "%s", tok2str(bgp_as_path_segment_close_values,
+ "?", tptr[0])));
ND_TCHECK(tptr[1]);
tptr += 2 + tptr[1] * as_size;
}
@@ -1385,7 +1420,7 @@ bgp_attr_print(netdissect_options *ndo,
ND_PRINT((ndo, "invalid len"));
else {
ND_TCHECK2(tptr[0], 4);
- ND_PRINT((ndo, "%s", getname(ndo, tptr)));
+ ND_PRINT((ndo, "%s", ipaddr_string(ndo, tptr)));
}
break;
case BGPTYPE_MULTI_EXIT_DISC:
@@ -1415,11 +1450,11 @@ bgp_attr_print(netdissect_options *ndo,
if (len == 6) {
ND_PRINT((ndo, " AS #%s, origin %s",
as_printf(ndo, astostr, sizeof(astostr), EXTRACT_16BITS(tptr)),
- getname(ndo, tptr + 2)));
+ ipaddr_string(ndo, tptr + 2)));
} else {
ND_PRINT((ndo, " AS #%s, origin %s",
as_printf(ndo, astostr, sizeof(astostr),
- EXTRACT_32BITS(tptr)), getname(ndo, tptr + 4)));
+ EXTRACT_32BITS(tptr)), ipaddr_string(ndo, tptr + 4)));
}
break;
case BGPTYPE_AGGREGATOR4:
@@ -1430,7 +1465,7 @@ bgp_attr_print(netdissect_options *ndo,
ND_TCHECK2(tptr[0], 8);
ND_PRINT((ndo, " AS #%s, origin %s",
as_printf(ndo, astostr, sizeof(astostr), EXTRACT_32BITS(tptr)),
- getname(ndo, tptr + 4)));
+ ipaddr_string(ndo, tptr + 4)));
break;
case BGPTYPE_COMMUNITIES:
if (len % 4) {
@@ -1468,7 +1503,7 @@ bgp_attr_print(netdissect_options *ndo,
break;
}
ND_TCHECK2(tptr[0], 4);
- ND_PRINT((ndo, "%s",getname(ndo, tptr)));
+ ND_PRINT((ndo, "%s",ipaddr_string(ndo, tptr)));
break;
case BGPTYPE_CLUSTER_LIST:
if (len % 4) {
@@ -1478,7 +1513,7 @@ bgp_attr_print(netdissect_options *ndo,
while (tlen>0) {
ND_TCHECK2(tptr[0], 4);
ND_PRINT((ndo, "%s%s",
- getname(ndo, tptr),
+ ipaddr_string(ndo, tptr),
(tlen>4) ? ", " : ""));
tlen -=4;
tptr +=4;
@@ -1490,12 +1525,10 @@ bgp_attr_print(netdissect_options *ndo,
safi = tptr[2];
ND_PRINT((ndo, "\n\t AFI: %s (%u), %sSAFI: %s (%u)",
- tok2strbuf(af_values, "Unknown AFI", af,
- tokbuf, sizeof(tokbuf)),
+ 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)),
+ tok2str(bgp_safi_values, "Unknown SAFI", safi),
safi));
switch(af<<8 | safi) {
@@ -1509,7 +1542,6 @@ bgp_attr_print(netdissect_options *ndo,
case (AFNUM_INET<<8 | SAFNUM_VPNUNIMULTICAST):
case (AFNUM_INET<<8 | SAFNUM_MULTICAST_VPN):
case (AFNUM_INET<<8 | SAFNUM_MDT):
-#ifdef INET6
case (AFNUM_INET6<<8 | SAFNUM_UNICAST):
case (AFNUM_INET6<<8 | SAFNUM_MULTICAST):
case (AFNUM_INET6<<8 | SAFNUM_UNIMULTICAST):
@@ -1517,7 +1549,6 @@ bgp_attr_print(netdissect_options *ndo,
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):
@@ -1565,7 +1596,7 @@ bgp_attr_print(netdissect_options *ndo,
tlen = 0;
} else {
ND_TCHECK2(tptr[0], sizeof(struct in_addr));
- ND_PRINT((ndo, "%s",getname(ndo, tptr)));
+ ND_PRINT((ndo, "%s",ipaddr_string(ndo, tptr)));
tlen -= sizeof(struct in_addr);
tptr += sizeof(struct in_addr);
}
@@ -1580,12 +1611,11 @@ bgp_attr_print(netdissect_options *ndo,
ND_TCHECK2(tptr[0], sizeof(struct in_addr)+BGP_VPN_RD_LEN);
ND_PRINT((ndo, "RD: %s, %s",
bgp_vpn_rd_print(ndo, tptr),
- getname(ndo, tptr+BGP_VPN_RD_LEN)));
+ 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):
@@ -1595,7 +1625,7 @@ bgp_attr_print(netdissect_options *ndo,
tlen = 0;
} else {
ND_TCHECK2(tptr[0], sizeof(struct in6_addr));
- ND_PRINT((ndo, "%s", getname6(ndo, tptr)));
+ ND_PRINT((ndo, "%s", ip6addr_string(ndo, tptr)));
tlen -= sizeof(struct in6_addr);
tptr += sizeof(struct in6_addr);
}
@@ -1610,12 +1640,11 @@ bgp_attr_print(netdissect_options *ndo,
ND_TCHECK2(tptr[0], sizeof(struct in6_addr)+BGP_VPN_RD_LEN);
ND_PRINT((ndo, "RD: %s, %s",
bgp_vpn_rd_print(ndo, tptr),
- getname6(ndo, tptr+BGP_VPN_RD_LEN)));
+ 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):
@@ -1625,7 +1654,7 @@ bgp_attr_print(netdissect_options *ndo,
tlen = 0;
} else {
ND_TCHECK2(tptr[0], sizeof(struct in_addr));
- ND_PRINT((ndo, "%s", getname(ndo, tptr)));
+ ND_PRINT((ndo, "%s", ipaddr_string(ndo, tptr)));
tlen -= (sizeof(struct in_addr));
tptr += (sizeof(struct in_addr));
}
@@ -1634,7 +1663,7 @@ bgp_attr_print(netdissect_options *ndo,
case (AFNUM_NSAP<<8 | SAFNUM_MULTICAST):
case (AFNUM_NSAP<<8 | SAFNUM_UNIMULTICAST):
ND_TCHECK2(tptr[0], tlen);
- ND_PRINT((ndo, "%s", isonsap_string(tptr, tlen)));
+ ND_PRINT((ndo, "%s", isonsap_string(ndo, tptr, tlen)));
tptr += tlen;
tlen = 0;
break;
@@ -1649,15 +1678,13 @@ bgp_attr_print(netdissect_options *ndo,
ND_TCHECK2(tptr[0], tlen);
ND_PRINT((ndo, "RD: %s, %s",
bgp_vpn_rd_print(ndo, tptr),
- isonsap_string(tptr+BGP_VPN_RD_LEN,tlen-BGP_VPN_RD_LEN)));
+ 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)
- ND_PRINT((ndo, " = %s", getname(ndo, 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)
- ND_PRINT((ndo, " = %s", getname6(ndo, tptr+BGP_VPN_RD_LEN+3)));
-#endif
+ ND_PRINT((ndo, " = %s", ip6addr_string(ndo, tptr+BGP_VPN_RD_LEN+3)));
tptr += tlen;
tlen = 0;
}
@@ -1758,7 +1785,6 @@ bgp_attr_print(netdissect_options *ndo,
else
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):
@@ -1794,7 +1820,6 @@ bgp_attr_print(netdissect_options *ndo,
else
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):
@@ -1851,12 +1876,10 @@ bgp_attr_print(netdissect_options *ndo,
safi = tptr[2];
ND_PRINT((ndo, "\n\t AFI: %s (%u), %sSAFI: %s (%u)",
- tok2strbuf(af_values, "Unknown AFI", af,
- tokbuf, sizeof(tokbuf)),
+ 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)),
+ tok2str(bgp_safi_values, "Unknown SAFI", safi),
safi));
if (len == BGP_MP_NLRI_MINSIZE)
@@ -1901,7 +1924,6 @@ bgp_attr_print(netdissect_options *ndo,
else
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):
@@ -1937,7 +1959,6 @@ bgp_attr_print(netdissect_options *ndo,
else
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):
@@ -2017,9 +2038,9 @@ bgp_attr_print(netdissect_options *ndo,
extd_comm=EXTRACT_16BITS(tptr);
ND_PRINT((ndo, "\n\t %s (0x%04x), Flags [%s]",
- tok2strbuf(bgp_extd_comm_subtype_values,
+ 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)));
@@ -2031,14 +2052,14 @@ bgp_attr_print(netdissect_options *ndo,
ND_PRINT((ndo, ": %u:%u (= %s)",
EXTRACT_16BITS(tptr+2),
EXTRACT_32BITS(tptr+4),
- getname(ndo, 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:
ND_PRINT((ndo, ": %s:%u",
- getname(ndo, tptr+2),
+ ipaddr_string(ndo, tptr+2),
EXTRACT_16BITS(tptr+6)));
break;
case BGP_EXT_COM_RT_2:
@@ -2058,25 +2079,23 @@ bgp_attr_print(netdissect_options *ndo,
case BGP_EXT_COM_VPN_ORIGIN4:
case BGP_EXT_COM_OSPF_RID:
case BGP_EXT_COM_OSPF_RID2:
- ND_PRINT((ndo, "%s", getname(ndo, tptr+2)));
+ ND_PRINT((ndo, "%s", ipaddr_string(ndo, tptr+2)));
break;
case BGP_EXT_COM_OSPF_RTYPE:
case BGP_EXT_COM_OSPF_RTYPE2:
ND_PRINT((ndo, ": area:%s, router-type:%s, metric-type:%s%s",
- getname(ndo, tptr+2),
- tok2strbuf(bgp_extd_comm_ospf_rtype_values,
+ 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" : ""));
break;
case BGP_EXT_COM_L2INFO:
ND_PRINT((ndo, ": %s Control Flags [0x%02x]:MTU %u",
- tok2strbuf(l2vpn_encaps_values,
+ tok2str(l2vpn_encaps_values,
"unknown encaps",
- *(tptr+2),
- tokbuf, sizeof(tokbuf)),
+ *(tptr+2)),
*(tptr+3),
EXTRACT_16BITS(tptr+4)));
break;
@@ -2151,6 +2170,48 @@ bgp_attr_print(netdissect_options *ndo,
}
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:
ND_TCHECK2(tptr[0], 4);
if (len < 4)
@@ -2161,7 +2222,7 @@ bgp_attr_print(netdissect_options *ndo,
len -=4;
while (len) {
- u_int aflags, atype, alenlen, alen;
+ u_int aflags, alenlen, alen;
ND_TCHECK2(tptr[0], 2);
if (len < 2)
@@ -2179,9 +2240,8 @@ bgp_attr_print(netdissect_options *ndo,
len -= alenlen;
ND_PRINT((ndo, "\n\t %s (%u), length: %u",
- tok2strbuf(bgp_attr_values,
- "Unknown Attribute", atype,
- tokbuf, sizeof(tokbuf)),
+ tok2str(bgp_attr_values,
+ "Unknown Attribute", atype),
atype,
alen));
@@ -2203,7 +2263,23 @@ bgp_attr_print(netdissect_options *ndo,
}
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:
ND_TCHECK2(*pptr,len);
ND_PRINT((ndo, "\n\t no Attribute %u decoder", atype)); /* we have no decoder for the attribute */
@@ -2225,8 +2301,6 @@ static void
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;
@@ -2236,21 +2310,19 @@ bgp_capabilities_print(netdissect_options *ndo,
cap_len=opt[i+1];
tcap_len=cap_len;
ND_PRINT((ndo, "\n\t %s (%u), length: %u",
- tok2strbuf(bgp_capcode_values, "Unknown",
- cap_type, tokbuf, sizeof(tokbuf)),
+ tok2str(bgp_capcode_values, "Unknown",
+ cap_type),
cap_type,
cap_len));
ND_TCHECK2(opt[i+2], cap_len);
switch (cap_type) {
case BGP_CAPCODE_MP:
ND_PRINT((ndo, "\n\t\tAFI %s (%u), SAFI %s (%u)",
- tok2strbuf(af_values, "Unknown",
- EXTRACT_16BITS(opt+i+2),
- tokbuf, sizeof(tokbuf)),
+ 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)),
+ tok2str(bgp_safi_values, "Unknown",
+ opt[i+5]),
opt[i+5]));
break;
case BGP_CAPCODE_RESTART:
@@ -2261,13 +2333,11 @@ bgp_capabilities_print(netdissect_options *ndo,
cap_offset=4;
while(tcap_len>=4) {
ND_PRINT((ndo, "\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)),
+ 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" ));
tcap_len-=4;
@@ -2288,6 +2358,28 @@ bgp_capabilities_print(netdissect_options *ndo,
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:
ND_PRINT((ndo, "\n\t\tno decoder for Capability %u",
cap_type));
@@ -2314,7 +2406,6 @@ bgp_open_print(netdissect_options *ndo,
struct bgp_opt bgpopt;
const u_char *opt;
int i;
- char tokbuf[TOKBUFSIZE];
ND_TCHECK2(dat[0], BGP_OPEN_SIZE);
memcpy(&bgpo, dat, BGP_OPEN_SIZE);
@@ -2323,7 +2414,7 @@ bgp_open_print(netdissect_options *ndo,
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", getname(ndo, (u_char *)&bgpo.bgpo_id)));
+ 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 */
@@ -2344,9 +2435,8 @@ bgp_open_print(netdissect_options *ndo,
}
ND_PRINT((ndo, "\n\t Option %s (%u), length: %u",
- tok2strbuf(bgp_opt_values,"Unknown",
- bgpopt.bgpopt_type,
- tokbuf, sizeof(tokbuf)),
+ tok2str(bgp_opt_values,"Unknown",
+ bgpopt.bgpopt_type),
bgpopt.bgpopt_type,
bgpopt.bgpopt_len));
@@ -2380,11 +2470,6 @@ bgp_update_print(netdissect_options *ndo,
int withdrawn_routes_len;
int len;
int i;
- char tokbuf[TOKBUFSIZE];
-#ifndef INET6
- char buf[MAXHOSTNAMELEN + 100];
- int wpfx;
-#endif
ND_TCHECK2(dat[0], BGP_SIZE);
if (length < BGP_SIZE)
@@ -2409,36 +2494,9 @@ bgp_update_print(netdissect_options *ndo,
ND_TCHECK2(p[0], withdrawn_routes_len);
if (length < withdrawn_routes_len)
goto trunc;
-#ifdef INET6
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;
-
-
- ND_PRINT((ndo, "\n\t Withdrawn routes:"));
-
- while(withdrawn_routes_len > 0) {
- wpfx = decode_prefix4(ndo, p, withdrawn_routes_len, buf, sizeof(buf));
- if (wpfx == -1) {
- ND_PRINT((ndo, "\n\t (illegal prefix length)"));
- break;
- } else if (wpfx == -2)
- goto trunc;
- else if (wpfx == -3)
- goto trunc; /* bytes left, but not enough */
- else {
- ND_PRINT((ndo, "\n\t %s", buf));
- p += wpfx;
- length -= wpfx;
- withdrawn_routes_len -= wpfx;
- }
- }
-#endif
}
ND_TCHECK2(p[0], 2);
@@ -2481,9 +2539,8 @@ bgp_update_print(netdissect_options *ndo,
length -= alenlen;
ND_PRINT((ndo, "\n\t %s (%u), length: %u",
- tok2strbuf(bgp_attr_values, "Unknown Attribute",
- atype,
- tokbuf, sizeof(tokbuf)),
+ tok2str(bgp_attr_values, "Unknown Attribute",
+ atype),
atype,
alen));
@@ -2547,8 +2604,6 @@ bgp_notification_print(netdissect_options *ndo,
{
struct bgp_notification bgpn;
const u_char *tptr;
- char tokbuf[TOKBUFSIZE];
- char tokbuf2[TOKBUFSIZE];
ND_TCHECK2(dat[0], BGP_NOTIFICATION_SIZE);
memcpy(&bgpn, dat, BGP_NOTIFICATION_SIZE);
@@ -2558,39 +2613,46 @@ bgp_notification_print(netdissect_options *ndo,
return;
ND_PRINT((ndo, ", %s (%u)",
- tok2strbuf(bgp_notify_major_values, "Unknown Error",
- bgpn.bgpn_major, tokbuf, sizeof(tokbuf)),
+ tok2str(bgp_notify_major_values, "Unknown Error",
+ bgpn.bgpn_major),
bgpn.bgpn_major));
switch (bgpn.bgpn_major) {
case BGP_NOTIFY_MAJOR_MSG:
ND_PRINT((ndo, ", subcode %s (%u)",
- tok2strbuf(bgp_notify_minor_msg_values, "Unknown",
- bgpn.bgpn_minor, tokbuf, sizeof(tokbuf)),
+ tok2str(bgp_notify_minor_msg_values, "Unknown",
+ bgpn.bgpn_minor),
bgpn.bgpn_minor));
break;
case BGP_NOTIFY_MAJOR_OPEN:
ND_PRINT((ndo, ", subcode %s (%u)",
- tok2strbuf(bgp_notify_minor_open_values, "Unknown",
- bgpn.bgpn_minor, tokbuf, sizeof(tokbuf)),
+ tok2str(bgp_notify_minor_open_values, "Unknown",
+ bgpn.bgpn_minor),
bgpn.bgpn_minor));
break;
case BGP_NOTIFY_MAJOR_UPDATE:
ND_PRINT((ndo, ", subcode %s (%u)",
- tok2strbuf(bgp_notify_minor_update_values, "Unknown",
- bgpn.bgpn_minor, tokbuf, sizeof(tokbuf)),
+ 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:
ND_PRINT((ndo, " subcode %s (%u)",
- tok2strbuf(bgp_notify_minor_cap_values, "Unknown",
- bgpn.bgpn_minor, tokbuf, sizeof(tokbuf)),
+ tok2str(bgp_notify_minor_cap_values, "Unknown",
+ bgpn.bgpn_minor),
bgpn.bgpn_minor));
+ break;
case BGP_NOTIFY_MAJOR_CEASE:
ND_PRINT((ndo, ", subcode %s (%u)",
- tok2strbuf(bgp_notify_minor_cease_values, "Unknown",
- bgpn.bgpn_minor, tokbuf, sizeof(tokbuf)),
+ tok2str(bgp_notify_minor_cease_values, "Unknown",
+ bgpn.bgpn_minor),
bgpn.bgpn_minor));
/* draft-ietf-idr-cease-subcode-02 mentions optionally 7 bytes
@@ -2600,11 +2662,10 @@ bgp_notification_print(netdissect_options *ndo,
tptr = dat + BGP_NOTIFICATION_SIZE;
ND_TCHECK2(*tptr, 7);
ND_PRINT((ndo, ", AFI %s (%u), SAFI %s (%u), Max Prefixes: %u",
- tok2strbuf(af_values, "Unknown",
- EXTRACT_16BITS(tptr), tokbuf, sizeof(tokbuf)),
+ 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)));
}
@@ -2623,8 +2684,6 @@ 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];
ND_TCHECK2(pptr[0], BGP_ROUTE_REFRESH_SIZE);
@@ -2635,15 +2694,13 @@ bgp_route_refresh_print(netdissect_options *ndo,
bgp_route_refresh_header = (const struct bgp_route_refresh *)pptr;
ND_PRINT((ndo, "\n\t AFI %s (%u), SAFI %s (%u)",
- tok2strbuf(af_values,"Unknown",
+ 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)),
+ tok2str(bgp_safi_values,"Unknown",
+ bgp_route_refresh_header->safi),
bgp_route_refresh_header->safi));
if (ndo->ndo_vflag > 1) {
@@ -2661,13 +2718,11 @@ bgp_header_print(netdissect_options *ndo,
const u_char *dat, int length)
{
struct bgp bgp;
- char tokbuf[TOKBUFSIZE];
ND_TCHECK2(dat[0], BGP_SIZE);
memcpy(&bgp, dat, BGP_SIZE);
ND_PRINT((ndo, "\n\t%s Message (%u), length: %u",
- tok2strbuf(bgp_msg_values, "Unknown", bgp.bgp_type,
- tokbuf, sizeof(tokbuf)),
+ tok2str(bgp_msg_values, "Unknown", bgp.bgp_type),
bgp.bgp_type,
length));
@@ -2712,7 +2767,6 @@ bgp_print(netdissect_options *ndo,
};
struct bgp bgp;
uint16_t hlen;
- char tokbuf[TOKBUFSIZE];
ep = dat + length;
if (ndo->ndo_snapend < dat + length)
@@ -2761,10 +2815,9 @@ bgp_print(netdissect_options *ndo,
start = p;
} else {
ND_PRINT((ndo, "\n[|BGP %s]",
- tok2strbuf(bgp_msg_values,
+ tok2str(bgp_msg_values,
"Unknown Message Type",
- bgp.bgp_type,
- tokbuf, sizeof(tokbuf))));
+ bgp.bgp_type)));
break;
}
}
diff --git a/contrib/tcpdump/print-bootp.c b/contrib/tcpdump/print-bootp.c
index 0cbc121..fe798a0 100644
--- a/contrib/tcpdump/print-bootp.c
+++ b/contrib/tcpdump/print-bootp.c
@@ -17,22 +17,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.
- *
- * Format and print bootp packets.
- *
- * $FreeBSD$
*/
-#define NETDISSECT_REWORKED
+/* \summary: BOOTP and IPv4 DHCP printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <string.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "extract.h"
@@ -215,8 +212,9 @@ struct bootp {
#define TAG_CLIENT_GUID ((uint8_t) 97)
#define TAG_LDAP_URL ((uint8_t) 95)
#define TAG_6OVER4 ((uint8_t) 96)
-#define TAG_PRINTER_NAME ((uint8_t) 100)
-#define TAG_MDHCP_SERVER ((uint8_t) 101)
+/* 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)
@@ -224,6 +222,7 @@ struct bootp {
#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
@@ -294,6 +293,7 @@ bootp_print(netdissect_options *ndo,
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) {
ND_TCHECK2(bp->bp_chaddr[0], 6);
ND_PRINT((ndo, " from %s", etheraddr_string(ndo, bp->bp_chaddr)));
@@ -356,7 +356,8 @@ bootp_print(netdissect_options *ndo,
ND_TCHECK2(bp->bp_sname[0], 1); /* check first char only */
if (*bp->bp_sname) {
ND_PRINT((ndo, "\n\t sname \""));
- if (fn_print(ndo, bp->bp_sname, ndo->ndo_snapend)) {
+ 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;
@@ -366,7 +367,8 @@ bootp_print(netdissect_options *ndo,
ND_TCHECK2(bp->bp_file[0], 1); /* check first char only */
if (*bp->bp_file) {
ND_PRINT((ndo, "\n\t file \""));
- if (fn_print(ndo, bp->bp_file, ndo->ndo_snapend)) {
+ 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;
@@ -522,13 +524,14 @@ static const 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' */
+ { TAG_MUDURL, "aMUD-URL" },
{ 0, NULL }
};
/* 2-byte extended tags */
@@ -999,7 +1002,7 @@ rfc1048_print(netdissect_options *ndo,
break;
}
if (len < suboptlen) {
- ND_PRINT((ndo, "ERROR: malformed option"));
+ ND_PRINT((ndo, "ERROR: invalid option"));
bp += len;
len = 0;
break;
diff --git a/contrib/tcpdump/print-bt.c b/contrib/tcpdump/print-bt.c
index 128daad..b37f8fa 100644
--- a/contrib/tcpdump/print-bt.c
+++ b/contrib/tcpdump/print-bt.c
@@ -17,14 +17,15 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#define NETDISSECT_REWORKED
+/* \summary: Bluetooth printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
#if defined(DLT_BLUETOOTH_HCI_H4_WITH_PHDR) && defined(HAVE_PCAP_BLUETOOTH_H)
diff --git a/contrib/tcpdump/print-calm-fast.c b/contrib/tcpdump/print-calm-fast.c
index 5cc39f4..c9be008 100644
--- a/contrib/tcpdump/print-calm-fast.c
+++ b/contrib/tcpdump/print-calm-fast.c
@@ -15,14 +15,15 @@
* Original code by Ola Martin Lykkja (ola.lykkja@q-free.com)
*/
-#define NETDISSECT_REWORKED
+/* \summary: Communication access for land mobiles (CALM) printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
/*
@@ -36,19 +37,33 @@
* to the calm header of the packet.
*/
void
-calm_fast_print(netdissect_options *ndo, const u_char *eth, const u_char *bp, u_int length)
+calm_fast_print(netdissect_options *ndo, const u_char *bp, u_int length, const struct lladdr_info *src)
{
- int srcNwref = bp[0];
- int dstNwref = bp[1];
+ 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 src:%s; ", etheraddr_string(ndo, eth+6)));
+ 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;
}
diff --git a/contrib/tcpdump/print-carp.c b/contrib/tcpdump/print-carp.c
index 7b9f28c..c650d18 100644
--- a/contrib/tcpdump/print-carp.c
+++ b/contrib/tcpdump/print-carp.c
@@ -34,14 +34,15 @@
*
*/
-#define NETDISSECT_REWORKED
+/* \summary: Common Address Redundancy Protocol (CARP) printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h" /* for checksum structure and functions */
+#include "netdissect.h" /* for checksum structure and functions */
#include "extract.h"
void
diff --git a/contrib/tcpdump/print-cdp.c b/contrib/tcpdump/print-cdp.c
index 932f7bc..6f8f356 100644
--- a/contrib/tcpdump/print-cdp.c
+++ b/contrib/tcpdump/print-cdp.c
@@ -24,18 +24,19 @@
* http://www.cisco.com/univercd/cc/td/doc/product/lan/trsrb/frames.htm
*/
-#define NETDISSECT_REWORKED
+/* \summary: Cisco Discovery Protocol (CDP) printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.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"
static const char tstr[] = "[|cdp]";
@@ -170,9 +171,11 @@ cdp_print(netdissect_options *ndo,
ND_PRINT((ndo, "\n\t "));
for (i=0;i<len;i++) {
j = *(tptr+i);
- ND_PRINT((ndo, "%c", j));
- if (j == 0x0a) /* lets rework the version string to get a nice indentation */
- ND_PRINT((ndo, "\t "));
+ 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 */
@@ -278,11 +281,9 @@ cdp_print_addr(netdissect_options *ndo,
{
int pt, pl, al, num;
const u_char *endp = p + l;
-#ifdef INET6
static const u_char prot_ipv6[] = {
0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00, 0x86, 0xdd
};
-#endif
ND_TCHECK2(*p, 4);
if (p + 4 > endp)
@@ -317,7 +318,6 @@ cdp_print_addr(netdissect_options *ndo,
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) {
/*
@@ -334,7 +334,6 @@ cdp_print_addr(netdissect_options *ndo,
ND_PRINT((ndo, "IPv6 (%u) %s", num, ip6addr_string(ndo, p)));
p += al;
}
-#endif
else {
/*
* Generic case: just print raw data
diff --git a/contrib/tcpdump/print-cfm.c b/contrib/tcpdump/print-cfm.c
index a85eec0..43ad438 100644
--- a/contrib/tcpdump/print-cfm.c
+++ b/contrib/tcpdump/print-cfm.c
@@ -12,21 +12,20 @@
* 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)
*/
-#define NETDISSECT_REWORKED
+/* \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 "interface.h"
+#include "netdissect.h"
#include "extract.h"
#include "ether.h"
#include "addrtoname.h"
@@ -65,18 +64,15 @@ static const struct tok cfm_opcode_values[] = {
struct cfm_ccm_t {
uint8_t sequence[4];
uint8_t ma_epi[2];
- uint8_t md_nameformat;
- uint8_t md_namelength;
- uint8_t md_name[46]; /* md name and short ma name */
- uint8_t reserved_itu[16];
- uint8_t reserved[6];
+ 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
@@ -115,16 +111,13 @@ static const struct tok cfm_ma_nameformat_values[] = {
struct cfm_lbm_t {
uint8_t transaction_id[4];
- uint8_t reserved[4];
};
struct cfm_ltm_t {
uint8_t transaction_id[4];
- uint8_t egress_id[8];
uint8_t ttl;
uint8_t original_mac[ETHER_ADDR_LEN];
uint8_t target_mac[ETHER_ADDR_LEN];
- uint8_t reserved[3];
};
static const struct tok cfm_ltm_flag_values[] = {
@@ -134,11 +127,8 @@ static const struct tok cfm_ltm_flag_values[] = {
struct cfm_ltr_t {
uint8_t transaction_id[4];
- uint8_t last_egress_id[8];
- uint8_t next_egress_id[8];
uint8_t ttl;
uint8_t replay_action;
- uint8_t reserved[6];
};
static const struct tok cfm_ltr_flag_values[] = {
@@ -226,10 +216,10 @@ static const struct tok cfm_tlv_senderid_chassisid_values[] = {
static int
-cfm_mgmt_addr_print(netdissect_options *ndo,
- register const u_char *tptr)
+cfm_network_addr_print(netdissect_options *ndo,
+ register const u_char *tptr)
{
- u_int mgmt_addr_type;
+ u_int network_addr_type;
u_int hexdump = FALSE;
/*
@@ -237,24 +227,22 @@ cfm_mgmt_addr_print(netdissect_options *ndo,
* 802.1ab specifies that this field width
* is only once octet
*/
- mgmt_addr_type = *tptr;
- ND_PRINT((ndo, "\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:
ND_PRINT((ndo, ", %s", ipaddr_string(ndo, tptr + 1)));
break;
-#ifdef INET6
case AFNUM_INET6:
ND_PRINT((ndo, ", %s", ip6addr_string(ndo, tptr + 1)));
break;
-#endif
default:
hexdump = TRUE;
@@ -264,29 +252,19 @@ cfm_mgmt_addr_print(netdissect_options *ndo,
return hexdump;
}
-/*
- * The egress-ID string is a 16-Bit string plus a MAC address.
- */
-static const char *
-cfm_egress_id_string(netdissect_options *ndo, register const u_char *tptr)
-{
- static char egress_id_buffer[80];
-
- snprintf(egress_id_buffer, sizeof(egress_id_buffer),
- "MAC 0x%4x-%s",
- EXTRACT_16BITS(tptr),
- etheraddr_string(ndo, tptr+2));
-
- return egress_id_buffer;
-}
-
void
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 uint8_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;
@@ -299,6 +277,8 @@ cfm_print(netdissect_options *ndo,
tptr=pptr;
cfm_common_header = (const struct cfm_common_header_t *)pptr;
+ if (length < sizeof(*cfm_common_header))
+ goto tooshort;
ND_TCHECK(*cfm_common_header);
/*
@@ -328,9 +308,25 @@ cfm_print(netdissect_options *ndo,
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);
ND_PRINT((ndo, ", Flags [CCM Interval %u%s]",
@@ -353,55 +349,89 @@ cfm_print(netdissect_options *ndo,
EXTRACT_32BITS(msg_ptr.cfm_ccm->sequence),
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.
*/
- ND_PRINT((ndo, "\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));
+ 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;
+ }
- if (msg_ptr.cfm_ccm->md_nameformat != CFM_CCM_MD_FORMAT_NONE) {
+ md_name = namesp;
ND_PRINT((ndo, "\n\t MD Name: "));
- switch (msg_ptr.cfm_ccm->md_nameformat) {
+ switch (md_nameformat) {
case CFM_CCM_MD_FORMAT_DNS:
case CFM_CCM_MD_FORMAT_CHAR:
- safeputs(ndo, 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:
- ND_PRINT((ndo, "\n\t MAC %s", etheraddr_string(ndo,
- 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(ndo, 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;
-
+ 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));
+ 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) {
+ switch (ma_nameformat) {
case CFM_CCM_MA_FORMAT_CHAR:
- safeputs(ndo, ma_name, *ma_namelength);
+ safeputs(ndo, ma_name, ma_namelength);
break;
/* FIXME add printers for those MA formats - hexdump for now */
@@ -410,19 +440,26 @@ cfm_print(netdissect_options *ndo,
case CFM_CCM_MA_FORMAT_INT:
case CFM_CCM_MA_FORMAT_VPN:
default:
- print_unknown_data(ndo, 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);
ND_PRINT((ndo, ", Flags [%s]",
bittok2str(cfm_ltm_flag_values, "none", cfm_common_header->flags)));
- ND_PRINT((ndo, "\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(ndo, msg_ptr.cfm_ltm->egress_id),
msg_ptr.cfm_ltm->ttl));
ND_PRINT((ndo, "\n\t Original-MAC %s, Target-MAC %s",
@@ -432,16 +469,20 @@ cfm_print(netdissect_options *ndo,
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);
ND_PRINT((ndo, ", Flags [%s]",
bittok2str(cfm_ltr_flag_values, "none", cfm_common_header->flags)));
- ND_PRINT((ndo, "\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(ndo, msg_ptr.cfm_ltr->last_egress_id)));
-
- ND_PRINT((ndo, "\n\t Next-Egress-ID %s, ttl %u",
- cfm_egress_id_string(ndo, msg_ptr.cfm_ltr->next_egress_id),
msg_ptr.cfm_ltr->ttl));
ND_PRINT((ndo, "\n\t Replay-Action %s (%u)",
@@ -458,20 +499,11 @@ cfm_print(netdissect_options *ndo,
case CFM_OPCODE_LBR:
case CFM_OPCODE_LBM:
default:
- if (tlen > cfm_common_header->first_tlv_offset) {
- print_unknown_data(ndo, 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;
@@ -482,55 +514,59 @@ cfm_print(netdissect_options *ndo,
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 ? */
- ND_TCHECK2(*tptr, sizeof(struct cfm_tlv_header_t));
- cfm_tlv_len=EXTRACT_16BITS(&cfm_tlv_header->length);
- } else {
- cfm_tlv_len = 0;
- }
-
- ND_PRINT((ndo, "\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(ndo, 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) {
- ND_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:
+ 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));
break;
case CFM_TLV_INTERFACE_STATUS:
+ 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));
break;
case CFM_TLV_PRIVATE:
+ 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),
@@ -543,20 +579,26 @@ cfm_print(netdissect_options *ndo,
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;
+ cfm_tlv_len--;
ND_PRINT((ndo, "\n\t Chassis-ID Type %s (%u), Chassis-ID length %u",
tok2str(cfm_tlv_senderid_chassisid_values,
"Unknown",
@@ -564,13 +606,18 @@ cfm_print(netdissect_options *ndo,
chassis_id_type,
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:
ND_PRINT((ndo, "\n\t MAC %s", etheraddr_string(ndo, tptr + 1)));
break;
case CFM_CHASSIS_ID_NETWORK_ADDRESS:
- hexdump |= cfm_mgmt_addr_print(ndo, tptr);
+ hexdump |= cfm_network_addr_print(ndo, tptr);
break;
case CFM_CHASSIS_ID_INTERFACE_NAME: /* fall through */
@@ -585,32 +632,60 @@ cfm_print(netdissect_options *ndo,
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(ndo, 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
@@ -632,6 +707,11 @@ cfm_print(netdissect_options *ndo,
tlen-=cfm_tlv_len;
}
return;
+
+tooshort:
+ ND_PRINT((ndo, "\n\t\t packet is too short"));
+ return;
+
trunc:
ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
}
diff --git a/contrib/tcpdump/print-chdlc.c b/contrib/tcpdump/print-chdlc.c
index 3951ef7..450d286 100644
--- a/contrib/tcpdump/print-chdlc.c
+++ b/contrib/tcpdump/print-chdlc.c
@@ -19,14 +19,15 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#define NETDISSECT_REWORKED
+/* \summary: Cisco HDLC printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "ethertype.h"
#include "extract.h"
@@ -96,9 +97,9 @@ chdlc_print(netdissect_options *ndo, register const u_char *p, u_int length)
if (*(p+1) == 0x81 ||
*(p+1) == 0x82 ||
*(p+1) == 0x83)
- isoclns_print(ndo, p + 1, length - 1, length - 1);
+ isoclns_print(ndo, p + 1, length - 1, ndo->ndo_snapend - p - 1);
else
- isoclns_print(ndo, p, length, length);
+ isoclns_print(ndo, p, length, ndo->ndo_snapend - p);
break;
default:
if (!ndo->ndo_eflag)
diff --git a/contrib/tcpdump/print-cip.c b/contrib/tcpdump/print-cip.c
index 91abe08..a123b69 100644
--- a/contrib/tcpdump/print-cip.c
+++ b/contrib/tcpdump/print-cip.c
@@ -20,20 +20,19 @@
*
*/
-#define NETDISSECT_REWORKED
+/* \summary: Classical-IP over ATM printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <string.h>
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
-#define RFC1483LLC_LEN 8
-
static const unsigned char rfcllc[] = {
0xaa, /* DSAP: non-ISO */
0xaa, /* SSAP: non-ISO */
@@ -43,12 +42,12 @@ static const unsigned char rfcllc[] = {
0x00 };
static inline void
-cip_print(netdissect_options *ndo, int length)
+cip_print(netdissect_options *ndo, u_int length)
{
/*
* There is no MAC-layer header, so just print the length.
*/
- ND_PRINT((ndo, "%d: ", length));
+ ND_PRINT((ndo, "%u: ", length));
}
/*
@@ -62,40 +61,42 @@ cip_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char
{
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) {
- ND_PRINT((ndo, "[|cip]"));
- return (0);
- }
+ cmplen = sizeof(rfcllc);
+ if (cmplen > caplen)
+ cmplen = caplen;
+ if (cmplen > length)
+ cmplen = 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(ndo, p, length, caplen, NULL, NULL,
- &extracted_ethertype) == 0) {
- /* ether_type not known, print raw packet */
- if (!ndo->ndo_eflag)
- cip_print(ndo, length);
- if (extracted_ethertype) {
- ND_PRINT((ndo, "(LLC %s) ",
- etherproto_string(htons(extracted_ethertype))));
- }
+ 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.
*/
+ llc_hdrlen = 0;
ip_print(ndo, p, length);
}
- return (0);
+ return (llc_hdrlen);
}
diff --git a/contrib/tcpdump/print-cnfp.c b/contrib/tcpdump/print-cnfp.c
index d80d7fd..e3e9b6d 100644
--- a/contrib/tcpdump/print-cnfp.c
+++ b/contrib/tcpdump/print-cnfp.c
@@ -30,6 +30,8 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+/* \summary: Cisco NetFlow protocol printer */
+
/*
* Cisco NetFlow protocol
*
@@ -38,17 +40,16 @@
* http://www.cisco.com/c/en/us/td/docs/net_mgmt/netflow_collection_engine/3-6/user/guide/format.html#wp1005892
*/
-#define NETDISSECT_REWORKED
#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"
diff --git a/contrib/tcpdump/print-dccp.c b/contrib/tcpdump/print-dccp.c
index 45468b5..6e25264 100644
--- a/contrib/tcpdump/print-dccp.c
+++ b/contrib/tcpdump/print-dccp.c
@@ -7,23 +7,22 @@
* BSD-style license that accompanies tcpdump or the GNU GPL version 2
*/
-#define NETDISSECT_REWORKED
+/* \summary: Datagram Congestion Control Protocol (DCCP) 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"
-#ifdef INET6
#include "ip6.h"
-#endif
#include "ipproto.h"
/* RFC4340: Datagram Congestion Control Protocol (DCCP) */
@@ -201,17 +200,16 @@ static inline u_int dccp_csum_coverage(const struct dccp_hdr* dh, u_int len)
static int dccp_cksum(netdissect_options *ndo, const struct ip *ip,
const struct dccp_hdr *dh, u_int len)
{
- return nextproto4_cksum(ndo, ip, (const uint8_t *)(void *)dh, len,
+ 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 uint8_t *)(void *)dh, len,
+ 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(uint8_t code)
{
@@ -272,9 +270,7 @@ void dccp_print(netdissect_options *ndo, const u_char *bp, const u_char *data2,
{
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;
@@ -283,13 +279,11 @@ void dccp_print(netdissect_options *ndo, const u_char *bp, const u_char *data2,
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);
@@ -316,14 +310,11 @@ void dccp_print(netdissect_options *ndo, const u_char *bp, const u_char *data2,
dport = EXTRACT_16BITS(&dh->dccph_dport);
hlen = dh->dccph_doff * 4;
-#ifdef INET6
if (ip6) {
ND_PRINT((ndo, "%s.%d > %s.%d: ",
ip6addr_string(ndo, &ip6->ip6_src), sport,
ip6addr_string(ndo, &ip6->ip6_dst), dport));
- } else
-#endif /*INET6*/
- {
+ } else {
ND_PRINT((ndo, "%s.%d > %s.%d: ",
ipaddr_string(ndo, &ip->ip_src), sport,
ipaddr_string(ndo, &ip->ip_dst), dport));
@@ -353,10 +344,8 @@ void dccp_print(netdissect_options *ndo, const u_char *bp, const u_char *data2,
ND_PRINT((ndo, "cksum 0x%04x ", dccp_sum));
if (IP_V(ip) == 4)
sum = dccp_cksum(ndo, ip, dh, len);
-#ifdef INET6
else if (IP_V(ip) == 6)
- sum = dccp6_cksum(ip6, dh, len);
-#endif
+ sum = dccp6_cksum(ndo, ip6, dh, len);
if (sum != 0)
ND_PRINT((ndo, "(incorrect -> 0x%04x)",in_cksum_shouldbe(dccp_sum, sum)));
else
@@ -370,8 +359,8 @@ void dccp_print(netdissect_options *ndo, const u_char *bp, const u_char *data2,
dccph_type = DCCPH_TYPE(dh);
switch (dccph_type) {
case DCCP_PKT_REQUEST: {
- struct dccp_hdr_request *dhr =
- (struct dccp_hdr_request *)(bp + fixed_hdrlen);
+ 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!",
@@ -386,8 +375,8 @@ void dccp_print(netdissect_options *ndo, const u_char *bp, const u_char *data2,
break;
}
case DCCP_PKT_RESPONSE: {
- struct dccp_hdr_response *dhr =
- (struct dccp_hdr_response *)(bp + fixed_hdrlen);
+ 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!",
@@ -447,8 +436,8 @@ void dccp_print(netdissect_options *ndo, const u_char *bp, const u_char *data2,
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 + fixed_hdrlen);
+ 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!",
@@ -498,7 +487,6 @@ void dccp_print(netdissect_options *ndo, const u_char *bp, const u_char *data2,
/* process options */
if (hlen > fixed_hdrlen){
- const u_char *cp;
u_int optlen;
cp = bp + fixed_hdrlen;
ND_PRINT((ndo, " <"));
diff --git a/contrib/tcpdump/print-decnet.c b/contrib/tcpdump/print-decnet.c
index 5414ec2..88aa9e3 100644
--- a/contrib/tcpdump/print-decnet.c
+++ b/contrib/tcpdump/print-decnet.c
@@ -19,12 +19,13 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#define NETDISSECT_REWORKED
+/* \summary: DECnet printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
struct mbuf;
struct rtentry;
@@ -38,12 +39,12 @@ struct rtentry;
#include <string.h>
#include "extract.h"
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
static const char tstr[] = "[|decnet]";
-#ifndef WIN32
+#ifndef _WIN32
typedef uint8_t byte[1]; /* single byte field */
#else
/*
@@ -51,7 +52,7 @@ typedef uint8_t byte[1]; /* single byte field */
*/
typedef unsigned char Byte[1]; /* single byte field */
#define byte Byte
-#endif /* WIN32 */
+#endif /* _WIN32 */
typedef uint8_t word[2]; /* 2 byte field */
typedef uint8_t longword[4]; /* 4 bytes field */
@@ -325,7 +326,6 @@ union controlmsg
#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 */
@@ -491,9 +491,6 @@ static void print_i_info(netdissect_options *, int);
static int print_elist(const char *, u_int);
static int print_nsp(netdissect_options *, const u_char *, u_int);
static void print_reason(netdissect_options *, int);
-#ifdef PRINT_NSPDATA
-static void pdata(netdissect_options *, u_char *, u_int);
-#endif
#ifndef HAVE_NETDNET_DNETDB_H_DNET_HTOA
extern char *dnet_htoa(struct dn_naddr *);
@@ -586,7 +583,7 @@ decnet_print(netdissect_options *ndo,
break;
default:
ND_PRINT((ndo, "unknown message flags under mask"));
- ND_DEFAULTPRINT((u_char *)ap, min(length, caplen));
+ ND_DEFAULTPRINT((const u_char *)ap, min(length, caplen));
return;
}
@@ -617,11 +614,11 @@ print_decnet_ctlmsg(netdissect_options *ndo,
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) {
@@ -692,7 +689,7 @@ print_decnet_ctlmsg(netdissect_options *ndo,
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);
@@ -715,13 +712,13 @@ print_decnet_ctlmsg(netdissect_options *ndo,
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);
@@ -736,7 +733,7 @@ print_decnet_ctlmsg(netdissect_options *ndo,
default:
ND_PRINT((ndo, "unknown control message"));
- ND_DEFAULTPRINT((u_char *)rhp, min(length, caplen));
+ ND_DEFAULTPRINT((const u_char *)rhp, min(length, caplen));
ret = 1;
break;
}
@@ -855,7 +852,7 @@ static int
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))
@@ -874,11 +871,8 @@ print_nsp(netdissect_options *ndo,
case MFS_BOM+MFS_EOM:
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)
@@ -908,23 +902,13 @@ print_nsp(netdissect_options *ndo,
}
}
ND_PRINT((ndo, "seg %d ", ack & SGQ_MASK));
-#ifdef PRINT_NSPDATA
- if (nsplen > data_off) {
- dp = &(nspp[data_off]);
- ND_TCHECK2(*dp, nsplen - data_off);
- pdata(ndo, dp, nsplen - data_off);
- }
-#endif
}
break;
case MFS_ILS+MFS_INT:
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)
@@ -954,21 +938,14 @@ print_nsp(netdissect_options *ndo,
}
}
ND_PRINT((ndo, "seg %d ", ack & SGQ_MASK));
-#ifdef PRINT_NSPDATA
- if (nsplen > data_off) {
- dp = &(nspp[data_off]);
- ND_TCHECK2(*dp, nsplen - data_off);
- pdata(ndo, dp, nsplen - data_off);
- }
-#endif
}
break;
case MFS_ILS:
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;
@@ -1032,7 +1009,7 @@ print_nsp(netdissect_options *ndo,
case MFS_DACK:
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))
@@ -1057,7 +1034,7 @@ print_nsp(netdissect_options *ndo,
case MFS_IACK:
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))
@@ -1098,11 +1075,8 @@ print_nsp(netdissect_options *ndo,
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;
@@ -1120,9 +1094,6 @@ print_nsp(netdissect_options *ndo,
case COS_MESSAGE:
ND_PRINT((ndo, "msg "));
break;
- case COS_CRYPTSER:
- ND_PRINT((ndo, "crypt "));
- break;
}
switch (info & COI_MASK) {
case COI_32:
@@ -1139,24 +1110,14 @@ print_nsp(netdissect_options *ndo,
break;
}
ND_PRINT((ndo, "segsize %d ", segsize));
-#ifdef PRINT_NSPDATA
- if (nsplen > sizeof(struct cimsg)) {
- dp = &(nspp[sizeof(struct cimsg)]);
- ND_TCHECK2(*dp, nsplen - sizeof(struct cimsg));
- pdata(ndo, dp, nsplen - sizeof(struct cimsg));
- }
-#endif
}
break;
case MFS_CC:
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;
@@ -1175,9 +1136,6 @@ print_nsp(netdissect_options *ndo,
case COS_MESSAGE:
ND_PRINT((ndo, "msg "));
break;
- case COS_CRYPTSER:
- ND_PRINT((ndo, "crypt "));
- break;
}
switch (info & COI_MASK) {
case COI_32:
@@ -1196,25 +1154,15 @@ print_nsp(netdissect_options *ndo,
ND_PRINT((ndo, "segsize %d ", segsize));
if (optlen) {
ND_PRINT((ndo, "optlen %d ", optlen));
-#ifdef PRINT_NSPDATA
- if (optlen > nsplen - sizeof(struct ccmsg))
- goto trunc;
- dp = &(nspp[sizeof(struct ccmsg)]);
- ND_TCHECK2(*dp, optlen);
- pdata(ndo, dp, optlen);
-#endif
}
}
break;
case MFS_DI:
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;
@@ -1225,20 +1173,13 @@ print_nsp(netdissect_options *ndo,
print_reason(ndo, reason);
if (optlen) {
ND_PRINT((ndo, "optlen %d ", optlen));
-#ifdef PRINT_NSPDATA
- if (optlen > nsplen - sizeof(struct dimsg))
- goto trunc;
- dp = &(nspp[sizeof(struct dimsg)]);
- ND_TCHECK2(*dp, optlen);
- pdata(ndo, dp, optlen);
-#endif
}
}
break;
case MFS_DC:
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;
ND_TCHECK(*dcmp);
@@ -1296,7 +1237,7 @@ print_reason(netdissect_options *ndo,
}
const char *
-dnnum_string(u_short dnaddr)
+dnnum_string(netdissect_options *ndo, u_short dnaddr)
{
char *str;
size_t siz;
@@ -1305,13 +1246,13 @@ 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;
@@ -1323,23 +1264,8 @@ dnname_string(u_short dnaddr)
if(dnname != NULL)
return (strdup(dnname));
else
- return(dnnum_string(dnaddr));
+ return(dnnum_string(ndo, dnaddr));
#else
- return(dnnum_string(dnaddr)); /* punt */
+ return(dnnum_string(ndo, dnaddr)); /* punt */
#endif
}
-
-#ifdef PRINT_NSPDATA
-static void
-pdata(netdissect_options *ndo,
- u_char *dp, u_int maxlen)
-{
- char c;
- u_int x = maxlen;
-
- while (x-- > 0) {
- c = *dp++;
- safeputchar(ndo, c);
- }
-}
-#endif
diff --git a/contrib/tcpdump/print-dhcp6.c b/contrib/tcpdump/print-dhcp6.c
index 53b96ef..762d918 100644
--- a/contrib/tcpdump/print-dhcp6.c
+++ b/contrib/tcpdump/print-dhcp6.c
@@ -26,6 +26,9 @@
* 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:
@@ -40,17 +43,16 @@
* RFC6334: Dual-Stack Lite option,
*/
-#define NETDISSECT_REWORKED
#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"
@@ -103,8 +105,8 @@ static const struct tok dh6_msgtype_str[] = {
/* DHCP6 base packet format */
struct dhcp6 {
union {
- uint8_t m;
- uint32_t x;
+ nd_uint8_t m;
+ nd_uint32_t x;
} dh6_msgtypexid;
/* options follow */
};
@@ -114,10 +116,10 @@ struct dhcp6 {
/* DHCPv6 relay messages */
struct dhcp6_relay {
- uint8_t dh6relay_msgtype;
- uint8_t dh6relay_hcnt;
- uint8_t dh6relay_linkaddr[16]; /* XXX: badly aligned */
- uint8_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 */
};
@@ -192,6 +194,7 @@ struct dhcp6_relay {
# 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" },
@@ -242,27 +245,28 @@ static const struct tok dh6opt_str[] = {
{ 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" },
- { DH6OPT_STCODE_UNSPECFAIL, "unspec failure" },
- { DH6OPT_STCODE_NOADDRAVAIL, "no addresses" },
- { DH6OPT_STCODE_NOBINDING, "no binding" },
- { DH6OPT_STCODE_NOTONLINK, "not on-link" },
- { DH6OPT_STCODE_USEMULTICAST, "use multicast" },
- { DH6OPT_STCODE_NOPREFIXAVAIL, "no prefixes" },
- { DH6OPT_STCODE_UNKNOWNQUERYTYPE, "unknown query type" },
- { DH6OPT_STCODE_MALFORMEDQUERY, "malformed query" },
- { DH6OPT_STCODE_NOTCONFIGURED, "not configured" },
- { DH6OPT_STCODE_NOTALLOWED, "not allowed" },
+ { 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 {
- uint16_t dh6opt_type;
- uint16_t dh6opt_len;
+ nd_uint16_t dh6opt_type;
+ nd_uint16_t dh6opt_len;
/* type-dependent data follows */
};
@@ -293,13 +297,14 @@ dhcp6opt_print(netdissect_options *ndo,
while (cp < ep) {
if (ep < cp + sizeof(*dh6o))
goto trunc;
- dh6o = (struct dhcp6opt *)cp;
+ 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);
ND_PRINT((ndo, " (%s", tok2str(dh6opt_str, "opt_%u", opttype)));
+ ND_TCHECK2(*(cp + sizeof(*dh6o)), optlen);
switch (opttype) {
case DH6OPT_CLIENTID:
case DH6OPT_SERVERID:
@@ -308,7 +313,7 @@ dhcp6opt_print(netdissect_options *ndo,
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) {
@@ -360,7 +365,7 @@ dhcp6opt_print(netdissect_options *ndo,
ND_PRINT((ndo, " ?)"));
break;
}
- tp = (u_char *)(dh6o + 1);
+ 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]),
@@ -377,7 +382,7 @@ dhcp6opt_print(netdissect_options *ndo,
ND_PRINT((ndo, " ?)"));
break;
}
- tp = (u_char *)(dh6o + 1);
+ tp = (const u_char *)(dh6o + 1);
for (i = 0; i < optlen; i += 2) {
ND_PRINT((ndo, " %s",
tok2str(dh6opt_str, "opt_%u", EXTRACT_16BITS(&tp[i]))));
@@ -389,7 +394,7 @@ dhcp6opt_print(netdissect_options *ndo,
ND_PRINT((ndo, " ?)"));
break;
}
- tp = (u_char *)(dh6o + 1);
+ tp = (const u_char *)(dh6o + 1);
ND_PRINT((ndo, " %d)", *tp));
break;
case DH6OPT_ELAPSED_TIME:
@@ -397,12 +402,12 @@ dhcp6opt_print(netdissect_options *ndo,
ND_PRINT((ndo, " ?)"));
break;
}
- tp = (u_char *)(dh6o + 1);
+ tp = (const u_char *)(dh6o + 1);
ND_PRINT((ndo, " %d)", EXTRACT_16BITS(tp)));
break;
case DH6OPT_RELAY_MSG:
ND_PRINT((ndo, " ("));
- tp = (u_char *)(dh6o + 1);
+ tp = (const u_char *)(dh6o + 1);
dhcp6_print(ndo, tp, optlen);
ND_PRINT((ndo, ")"));
break;
@@ -411,7 +416,7 @@ dhcp6opt_print(netdissect_options *ndo,
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:
@@ -506,14 +511,14 @@ dhcp6opt_print(netdissect_options *ndo,
* Since we cannot predict the encoding, print hex dump
* at most 10 characters.
*/
- tp = (u_char *)(dh6o + 1);
+ tp = (const u_char *)(dh6o + 1);
ND_PRINT((ndo, " "));
for (i = 0; i < optlen && i < 10; i++)
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:
ND_PRINT((ndo, " for renew)"));
@@ -541,14 +546,14 @@ dhcp6opt_print(netdissect_options *ndo,
ND_PRINT((ndo, " ?)"));
break;
}
- tp = (u_char *)(dh6o + 1);
+ tp = (const u_char *)(dh6o + 1);
for (i = 0; i < optlen; i += 16)
ND_PRINT((ndo, " %s", ip6addr_string(ndo, &tp[i])));
ND_PRINT((ndo, ")"));
break;
case DH6OPT_SIP_SERVER_D:
case DH6OPT_DOMAIN_LIST:
- tp = (u_char *)(dh6o + 1);
+ 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)
@@ -561,7 +566,7 @@ dhcp6opt_print(netdissect_options *ndo,
ND_PRINT((ndo, " ?)"));
break;
}
- tp = (u_char *)(dh6o + 1);
+ tp = (const u_char *)(dh6o + 1);
ND_PRINT((ndo, " %s)", dhcp6stcode(EXTRACT_16BITS(&tp[0]))));
break;
case DH6OPT_IA_NA:
@@ -570,7 +575,7 @@ dhcp6opt_print(netdissect_options *ndo,
ND_PRINT((ndo, " ?)"));
break;
}
- tp = (u_char *)(dh6o + 1);
+ tp = (const u_char *)(dh6o + 1);
ND_PRINT((ndo, " IAID:%u T1:%u T2:%u",
EXTRACT_32BITS(&tp[0]),
EXTRACT_32BITS(&tp[4]),
@@ -586,7 +591,7 @@ dhcp6opt_print(netdissect_options *ndo,
ND_PRINT((ndo, " ?)"));
break;
}
- tp = (u_char *)(dh6o + 1);
+ tp = (const u_char *)(dh6o + 1);
ND_PRINT((ndo, " IAID:%u", EXTRACT_32BITS(tp)));
if (optlen > 4) {
/* there are sub-options */
@@ -599,7 +604,7 @@ dhcp6opt_print(netdissect_options *ndo,
ND_PRINT((ndo, " ?)"));
break;
}
- tp = (u_char *)(dh6o + 1);
+ 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]),
@@ -616,7 +621,7 @@ dhcp6opt_print(netdissect_options *ndo,
ND_PRINT((ndo, " ?)"));
break;
}
- tp = (u_char *)(dh6o + 1);
+ tp = (const u_char *)(dh6o + 1);
ND_PRINT((ndo, " %d)", EXTRACT_32BITS(tp)));
break;
case DH6OPT_REMOTE_ID:
@@ -624,7 +629,7 @@ dhcp6opt_print(netdissect_options *ndo,
ND_PRINT((ndo, " ?)"));
break;
}
- tp = (u_char *)(dh6o + 1);
+ tp = (const u_char *)(dh6o + 1);
ND_PRINT((ndo, " %d ", EXTRACT_32BITS(tp)));
/*
* Print hex dump first 10 characters.
@@ -638,7 +643,7 @@ dhcp6opt_print(netdissect_options *ndo,
ND_PRINT((ndo, " ?)"));
break;
}
- tp = (u_char *)(dh6o + 1);
+ tp = (const u_char *)(dh6o + 1);
switch (*tp) {
case 1:
ND_PRINT((ndo, " by-address"));
@@ -658,7 +663,7 @@ dhcp6opt_print(netdissect_options *ndo,
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(ndo, tp, tp + optlen);
@@ -670,7 +675,7 @@ dhcp6opt_print(netdissect_options *ndo,
ND_PRINT((ndo, " ?)"));
break;
}
- tp = (u_char *)(dh6o + 1);
+ tp = (const u_char *)(dh6o + 1);
ND_PRINT((ndo, " %s ", ip6addr_string(ndo, &tp[0])));
/*
* Print hex dump first 10 characters.
@@ -684,7 +689,7 @@ dhcp6opt_print(netdissect_options *ndo,
ND_PRINT((ndo, " ?)"));
break;
}
- tp = (u_char *)(dh6o + 1);
+ tp = (const u_char *)(dh6o + 1);
while (tp < cp + sizeof(*dh6o) + optlen - 4) {
subopt_code = EXTRACT_16BITS(tp);
tp += 2;
@@ -720,14 +725,14 @@ dhcp6opt_print(netdissect_options *ndo,
ND_PRINT((ndo, " ?)"));
break;
}
- tp = (u_char *)(dh6o + 1);
+ tp = (const u_char *)(dh6o + 1);
remain_len = optlen;
ND_PRINT((ndo, " "));
/* Encoding is described in section 3.1 of RFC 1035 */
while (remain_len && *tp) {
label_len = *tp++;
if (label_len < remain_len - 1) {
- ND_PRINT((ndo, "%.*s", label_len, tp));
+ (void)fn_printn(ndo, tp, label_len, NULL);
tp += label_len;
remain_len -= (label_len + 1);
if(*tp) ND_PRINT((ndo, "."));
@@ -738,6 +743,19 @@ dhcp6opt_print(netdissect_options *ndo,
}
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:
ND_PRINT((ndo, ")"));
break;
@@ -758,20 +776,20 @@ void
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;
ND_PRINT((ndo, "dhcp6"));
- ep = (u_char *)ndo->ndo_snapend;
+ ep = (const u_char *)ndo->ndo_snapend;
if (cp + length < ep)
ep = cp + length;
- dh6 = (struct dhcp6 *)cp;
- dh6relay = (struct dhcp6_relay *)cp;
+ 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);
@@ -786,7 +804,7 @@ dhcp6_print(netdissect_options *ndo,
if (dh6->dh6_msgtype != DH6_RELAY_FORW &&
dh6->dh6_msgtype != DH6_RELAY_REPLY) {
ND_PRINT((ndo, "xid=%x", EXTRACT_32BITS(&dh6->dh6_xid) & DH6_XIDMASK));
- extp = (u_char *)(dh6 + 1);
+ extp = (const u_char *)(dh6 + 1);
dhcp6opt_print(ndo, extp, ep);
} else { /* relay messages */
struct in6_addr addr6;
@@ -799,7 +817,7 @@ dhcp6_print(netdissect_options *ndo,
memcpy(&addr6, dh6relay->dh6relay_peeraddr, sizeof (addr6));
ND_PRINT((ndo, " peeraddr=%s", ip6addr_string(ndo, &addr6)));
- dhcp6opt_print(ndo, (u_char *)(dh6relay + 1), ep);
+ dhcp6opt_print(ndo, (const u_char *)(dh6relay + 1), ep);
}
/*(*/
ND_PRINT((ndo, ")"));
diff --git a/contrib/tcpdump/print-domain.c b/contrib/tcpdump/print-domain.c
index 4e2d378..d0b6996 100644
--- a/contrib/tcpdump/print-domain.c
+++ b/contrib/tcpdump/print-domain.c
@@ -17,24 +17,24 @@
* 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$
*/
-#define NETDISSECT_REWORKED
+/* \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 <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",
@@ -397,7 +397,7 @@ ns_rprint(netdissect_options *ndo,
} else if (ndo->ndo_vflag > 2) {
/* print ttl */
ND_PRINT((ndo, " ["));
- relts_print(ndo, EXTRACT_32BITS(cp));
+ unsigned_relts_print(ndo, EXTRACT_32BITS(cp));
ND_PRINT((ndo, "]"));
cp += 4;
} else {
@@ -483,17 +483,14 @@ ns_rprint(netdissect_options *ndo,
EXTRACT_16BITS(cp), EXTRACT_16BITS(cp + 2)));
break;
-#ifdef INET6
case T_AAAA:
{
- struct in6_addr addr;
char ntop_buf[INET6_ADDRSTRLEN];
if (!ND_TTEST2(*cp, sizeof(struct in6_addr)))
return(NULL);
- memcpy(&addr, cp, sizeof(struct in6_addr));
ND_PRINT((ndo, " %s",
- inet_ntop(AF_INET6, &addr, ntop_buf, sizeof(ntop_buf))));
+ addrtostr6(cp, ntop_buf, sizeof(ntop_buf))));
break;
}
@@ -517,7 +514,7 @@ ns_rprint(netdissect_options *ndo,
memset(&a, 0, sizeof(a));
memcpy(&a.s6_addr[pbyte], cp + 1, sizeof(a) - pbyte);
ND_PRINT((ndo, " %u %s", pbit,
- inet_ntop(AF_INET6, &a, ntop_buf, sizeof(ntop_buf))));
+ addrtostr6(&a, ntop_buf, sizeof(ntop_buf))));
}
if (pbit > 0) {
ND_PRINT((ndo, " "));
@@ -526,12 +523,11 @@ ns_rprint(netdissect_options *ndo,
}
break;
}
-#endif /*INET6*/
case T_OPT:
ND_PRINT((ndo, " UDPsize=%u", class));
if (opt_flags & 0x8000)
- ND_PRINT((ndo, " OK"));
+ ND_PRINT((ndo, " DO"));
break;
case T_UNSPECA: /* One long string */
@@ -668,7 +664,7 @@ ns_print(netdissect_options *ndo,
DNS_CD(np) ? "%" : ""));
/* any weirdness? */
- b2 = EXTRACT_16BITS(((u_short *)np)+1);
+ b2 = EXTRACT_16BITS(((const u_short *)np)+1);
if (b2 & 0x6cf)
ND_PRINT((ndo, " [b2&3=0x%x]", b2));
diff --git a/contrib/tcpdump/print-dtp.c b/contrib/tcpdump/print-dtp.c
index 5d84a77..1d8c66a 100644
--- a/contrib/tcpdump/print-dtp.c
+++ b/contrib/tcpdump/print-dtp.c
@@ -12,22 +12,23 @@
* 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>
*/
-#define NETDISSECT_REWORKED
+/* \summary: Dynamic Trunking Protocol (DTP) printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "extract.h"
+static const char tstr[] = " [|dtp]";
+
#define DTP_HEADER_LEN 1
#define DTP_DOMAIN_TLV 0x0001
#define DTP_STATUS_TLV 0x0002
@@ -71,30 +72,36 @@ dtp_print (netdissect_options *ndo, const u_char *pptr, u_int length)
while (tptr < (pptr+length)) {
ND_TCHECK2(*tptr, 4);
-
type = EXTRACT_16BITS(tptr);
len = EXTRACT_16BITS(tptr+2);
-
- /* infinite loop check */
- if (type == 0 || len == 0) {
+ /* XXX: should not be but sometimes it is, see the test captures */
+ if (type == 0)
return;
- }
-
ND_PRINT((ndo, "\n\t%s (0x%04x) TLV, length %u",
tok2str(dtp_tlv_values, "Unknown", type),
type, len));
+ /* infinite loop check */
+ if (len < 4)
+ goto invalid;
+ ND_TCHECK2(*tptr, len);
+
switch (type) {
case DTP_DOMAIN_TLV:
- ND_PRINT((ndo, ", %s", tptr+4));
+ ND_PRINT((ndo, ", "));
+ fn_printzp(ndo, tptr+4, len-4, pptr+length);
break;
case DTP_STATUS_TLV:
case DTP_DTP_TYPE_TLV:
+ if (len < 5)
+ goto invalid;
ND_PRINT((ndo, ", 0x%x", *(tptr+4)));
break;
case DTP_NEIGHBOR_TLV:
+ if (len < 10)
+ goto invalid;
ND_PRINT((ndo, ", %s", etheraddr_string(ndo, tptr+4)));
break;
@@ -106,8 +113,11 @@ dtp_print (netdissect_options *ndo, const u_char *pptr, u_int length)
return;
+ invalid:
+ ND_PRINT((ndo, "%s", istr));
+ return;
trunc:
- ND_PRINT((ndo, "[|dtp]"));
+ ND_PRINT((ndo, "%s", tstr));
}
/*
diff --git a/contrib/tcpdump/print-dvmrp.c b/contrib/tcpdump/print-dvmrp.c
index 96a0ee7..60f836e 100644
--- a/contrib/tcpdump/print-dvmrp.c
+++ b/contrib/tcpdump/print-dvmrp.c
@@ -19,14 +19,15 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#define NETDISSECT_REWORKED
+/* \summary: Distance Vector Multicast Routing Protocol printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
#include "addrtoname.h"
@@ -337,7 +338,7 @@ print_prune(netdissect_options *ndo,
ND_PRINT((ndo, " src %s grp %s", ipaddr_string(ndo, bp), ipaddr_string(ndo, bp + 4)));
bp += 8;
ND_PRINT((ndo, " timer "));
- relts_print(ndo, EXTRACT_32BITS(bp));
+ unsigned_relts_print(ndo, EXTRACT_32BITS(bp));
return (0);
trunc:
return (-1);
diff --git a/contrib/tcpdump/print-eap.c b/contrib/tcpdump/print-eap.c
index 0e2c2d3..125e1ee 100644
--- a/contrib/tcpdump/print-eap.c
+++ b/contrib/tcpdump/print-eap.c
@@ -16,19 +16,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.
- *
- * Format and print EAP packets.
- *
*/
-#define NETDISSECT_REWORKED
+/* \summary: Extensible Authentication Protocol (EAP) printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
#define EAP_FRAME_TYPE_PACKET 0
@@ -151,7 +149,7 @@ static const struct tok eap_aka_subtype_values[] = {
void
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;
diff --git a/contrib/tcpdump/print-egp.c b/contrib/tcpdump/print-egp.c
index 9c5c811..8fba9ce 100644
--- a/contrib/tcpdump/print-egp.c
+++ b/contrib/tcpdump/print-egp.c
@@ -18,14 +18,15 @@
* Initial contribution from Jeff Honig (jch@MITCHELL.CIT.CORNELL.EDU).
*/
-#define NETDISSECT_REWORKED
+/* \summary: Exterior Gateway Protocol (EGP) printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "extract.h"
@@ -128,7 +129,7 @@ static const char *egp_reasons[] = {
static void
egpnrprint(netdissect_options *ndo,
- register const struct egp_packet *egp)
+ register const struct egp_packet *egp, u_int length)
{
register const uint8_t *cp;
uint32_t addr;
@@ -152,12 +153,15 @@ egpnrprint(netdissect_options *ndo,
net = 0;
netlen = 0;
}
- cp = (uint8_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;
+ if (length < 4 - netlen)
+ goto trunc;
ND_TCHECK2(cp[0], 4 - netlen);
switch (netlen) {
@@ -171,8 +175,12 @@ egpnrprint(netdissect_options *ndo,
addr = (addr << 8) | *cp++;
}
addr |= net;
+ length -= 4 - netlen;
+ if (length < 1)
+ goto trunc;
ND_TCHECK2(cp[0], 1);
distances = *cp++;
+ length--;
ND_PRINT((ndo, " %s %s ",
gateways < (int)egp->egp_intgw ? "int" : "ext",
ipaddr_string(ndo, &addr)));
@@ -180,21 +188,33 @@ egpnrprint(netdissect_options *ndo,
comma = "";
ND_PRINT((ndo, "("));
while (--distances >= 0) {
+ 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 */
+ if (length < 1)
+ goto trunc;
ND_TCHECK2(cp[0], 1);
addr = (uint32_t)*cp++ << 24;
+ length--;
if (IN_CLASSB(addr)) {
+ if (length < 1)
+ goto trunc;
ND_TCHECK2(cp[0], 1);
addr |= (uint32_t)*cp++ << 16;
+ length--;
} else if (!IN_CLASSA(addr)) {
+ if (length < 2)
+ goto trunc;
ND_TCHECK2(cp[0], 2);
addr |= (uint32_t)*cp++ << 16;
addr |= (uint32_t)*cp++ << 8;
+ length -= 2;
}
ND_PRINT((ndo, " %s", ipaddr_string(ndo, &addr)));
}
@@ -215,8 +235,8 @@ egp_print(netdissect_options *ndo,
register int code;
register int type;
- egp = (struct egp_packet *)bp;
- if (!ND_TTEST2(*egp, length)) {
+ egp = (const struct egp_packet *)bp;
+ if (length < sizeof(*egp) || !ND_TTEST(*egp)) {
ND_PRINT((ndo, "[|egp]"));
return;
}
@@ -333,7 +353,7 @@ egp_print(netdissect_options *ndo,
egp->egp_intgw,
egp->egp_extgw));
if (ndo->ndo_vflag)
- egpnrprint(ndo, egp);
+ egpnrprint(ndo, egp, length);
break;
case EGPT_ERROR:
diff --git a/contrib/tcpdump/print-eigrp.c b/contrib/tcpdump/print-eigrp.c
index cab77ba..7e1ffb7 100644
--- a/contrib/tcpdump/print-eigrp.c
+++ b/contrib/tcpdump/print-eigrp.c
@@ -14,16 +14,17 @@
* FOR A PARTICULAR PURPOSE.
*/
-#define NETDISSECT_REWORKED
+/* \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 <string.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
#include "addrtoname.h"
diff --git a/contrib/tcpdump/print-enc.c b/contrib/tcpdump/print-enc.c
index 7bd8631..d791b3f 100644
--- a/contrib/tcpdump/print-enc.c
+++ b/contrib/tcpdump/print-enc.c
@@ -21,14 +21,15 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#define NETDISSECT_REWORKED
+/* \summary: OpenBSD IPsec encapsulation BPF layer printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
/* From $OpenBSD: if_enc.h,v 1.8 2001/06/25 05:14:00 angelos Exp $ */
@@ -98,7 +99,7 @@ enc_if_print(netdissect_options *ndo,
goto out;
}
- hdr = (struct enchdr *)p;
+ hdr = (const struct enchdr *)p;
flags = hdr->flags;
if (flags == 0)
ND_PRINT((ndo, "(unprotected): "));
diff --git a/contrib/tcpdump/print-esp.c b/contrib/tcpdump/print-esp.c
index 8e267d4..1115f36 100644
--- a/contrib/tcpdump/print-esp.c
+++ b/contrib/tcpdump/print-esp.c
@@ -21,12 +21,13 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#define NETDISSECT_REWORKED
+/* \summary: IPSEC Encapsulating Security Payload (ESP) printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <string.h>
#include <stdlib.h>
@@ -43,13 +44,14 @@
#endif
#endif
+#include "netdissect.h"
+#include "strtoaddr.h"
+#include "extract.h"
+
+#include "ascii_strcasecmp.h"
+
#include "ip.h"
-#ifdef INET6
#include "ip6.h"
-#endif
-
-#include "interface.h"
-#include "extract.h"
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -98,9 +100,7 @@ struct newesp {
#ifdef HAVE_LIBCRYPTO
union inaddr_u {
struct in_addr in4;
-#ifdef INET6
struct in6_addr in6;
-#endif
};
struct sa_list {
struct sa_list *next;
@@ -119,6 +119,32 @@ 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!
*/
@@ -126,12 +152,12 @@ 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;
@@ -159,12 +185,14 @@ 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;
@@ -332,8 +360,8 @@ espprint_decode_authalgo(netdissect_options *ndo,
}
*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;
@@ -427,22 +455,23 @@ static void esp_print_decode_onesecret(netdissect_options *ndo, char *line,
} 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)
@@ -450,14 +479,14 @@ 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;
}
@@ -477,17 +506,14 @@ static void esp_print_decode_onesecret(netdissect_options *ndo, char *line,
sa1.spi = spino;
-#ifdef INET6
- if (inet_pton(AF_INET6, spikey, &sa1.daddr.in6) == 1) {
+ if (strtoaddr6(spikey, &sa1.daddr.in6) == 1) {
sa1.daddr_version = 6;
- } else
-#endif
- if (inet_pton(AF_INET, spikey, &sa1.daddr.in4) == 1) {
- sa1.daddr_version = 4;
- } else {
- (*ndo->ndo_warning)(ndo, "print_esp: can not decode IP# %s\n", spikey);
- return;
- }
+ } 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) {
@@ -506,8 +532,14 @@ static void esp_print_decode_onesecret(netdissect_options *ndo, char *line,
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
@@ -564,21 +596,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;
-#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;
+ 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;
@@ -593,7 +623,7 @@ esp_print(netdissect_options *ndo,
/* 'ep' points to the end of available data. */
ep = ndo->ndo_snapend;
- if ((u_char *)(esp + 1) >= ep) {
+ if ((const u_char *)(esp + 1) >= ep) {
ND_PRINT((ndo, "[|ESP]"));
goto fail;
}
@@ -615,11 +645,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;
@@ -636,7 +665,6 @@ esp_print(netdissect_options *ndo,
}
}
break;
-#endif /*INET6*/
case 4:
/* nexthdr & padding are in the last fragment */
if (EXTRACT_16BITS(&ip->ip_off) & IP_MF)
@@ -675,21 +703,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;
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");
-
- 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);
diff --git a/contrib/tcpdump/print-ether.c b/contrib/tcpdump/print-ether.c
index b96620f..bbfd7e9 100644
--- a/contrib/tcpdump/print-ether.c
+++ b/contrib/tcpdump/print-ether.c
@@ -17,18 +17,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$
*/
-#define NETDISSECT_REWORKED
+/* \summary: Ethernet printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
#include "addrtoname.h"
#include "ethertype.h"
@@ -85,6 +84,7 @@ const struct tok ethertype_values[] = {
{ ETHERTYPE_GEONET, "GeoNet"},
{ ETHERTYPE_CALM_FAST, "CALM FAST"},
{ ETHERTYPE_AOE, "AoE" },
+ { ETHERTYPE_MEDSA, "MEDSA" },
{ 0, NULL}
};
@@ -93,7 +93,7 @@ ether_hdr_print(netdissect_options *ndo,
const u_char *bp, u_int length)
{
register const struct ether_header *ep;
- uint16_t ether_type;
+ uint16_t length_type;
ep = (const struct ether_header *)bp;
@@ -101,19 +101,21 @@ ether_hdr_print(netdissect_options *ndo,
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)
- ND_PRINT((ndo, ", 802.3"));
- else
- 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)
- ND_PRINT((ndo, ", 802.3"));
- else
- 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)));
}
ND_PRINT((ndo, ", length %u: ", length));
@@ -124,20 +126,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) {
@@ -149,55 +159,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(ndo, 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)
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) {
- uint16_t tag = EXTRACT_16BITS(p);
+ uint16_t tag = EXTRACT_16BITS(p);
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
@@ -208,53 +224,48 @@ recurse:
* there's an LLC header and payload.
*/
/* Try to print the LLC-layer header & higher layers */
- if (llc_print(ndo, 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)
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)
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.
@@ -272,16 +283,14 @@ netanalyzer_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h,
}
/* 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
@@ -302,9 +311,7 @@ netanalyzer_transparent_if_print(netdissect_options *ndo,
}
/* 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));
}
/*
@@ -317,7 +324,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) {
@@ -331,7 +339,7 @@ ethertype_print(netdissect_options *ndo,
case ETHERTYPE_ARP:
case ETHERTYPE_REVARP:
- arp_print(ndo, p, length, caplen);
+ arp_print(ndo, p, length, caplen);
return (1);
case ETHERTYPE_DN:
@@ -354,7 +362,11 @@ ethertype_print(netdissect_options *ndo,
return (1);
case ETHERTYPE_ISO:
- isoclns_print(ndo, p + 1, length - 1, length - 1);
+ 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:
@@ -369,7 +381,7 @@ 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:
@@ -415,17 +427,21 @@ ethertype_print(netdissect_options *ndo,
case ETHERTYPE_GEONET_OLD:
case ETHERTYPE_GEONET:
- geonet_print(ndo, p-14, p, length);
+ geonet_print(ndo, p, length, src);
return (1);
case ETHERTYPE_CALM_FAST:
- calm_fast_print(ndo, p-14, p, length);
+ 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:
diff --git a/contrib/tcpdump/print-fddi.c b/contrib/tcpdump/print-fddi.c
index 2b53c45..2780378 100644
--- a/contrib/tcpdump/print-fddi.c
+++ b/contrib/tcpdump/print-fddi.c
@@ -17,20 +17,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$
*/
-#define NETDISSECT_REWORKED
+/* \summary: Fiber Distributed Data Interface (FDDI) printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <string.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "ether.h"
@@ -86,9 +85,9 @@ struct fddi_header {
* 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
/*
@@ -261,17 +260,11 @@ fddi_hdr_print(netdissect_options *ndo,
srcname = etheraddr_string(ndo, fsrc);
dstname = etheraddr_string(ndo, fdst);
- if (ndo->ndo_vflag)
- ND_PRINT((ndo, "%02x %s %s %d: ",
- fddip->fddi_fc,
- srcname, dstname,
- length));
- else if (ndo->ndo_qflag)
- ND_PRINT((ndo, "%s %s %d: ", srcname, dstname, length));
- else {
+ if (!ndo->ndo_qflag)
print_fddi_fc(ndo, fddip->fddi_fc);
- ND_PRINT((ndo, "%s %s %d: ", srcname, dstname, length));
- }
+ ND_PRINT((ndo, "%s > %s, length %u: ",
+ srcname, dstname,
+ length));
}
static inline void
@@ -280,16 +273,17 @@ fddi_smt_print(netdissect_options *ndo, const u_char *p _U_, u_int length _U_)
ND_PRINT((ndo, "<SMT printer not yet implemented>"));
}
-void
+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) {
ND_PRINT((ndo, "[|fddi]"));
- return;
+ return (caplen);
}
/*
@@ -300,6 +294,11 @@ fddi_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen)
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;
p += FDDI_HDRLEN;
@@ -308,32 +307,29 @@ fddi_print(netdissect_options *ndo, 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(ndo, 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 (!ndo->ndo_eflag)
- fddi_hdr_print(ndo, fddip, length + FDDI_HDRLEN,
- ESRC(&ehdr), EDST(&ehdr));
- if (extracted_ethertype) {
- ND_PRINT((ndo, "(LLC %s) ",
- etherproto_string(htons(extracted_ethertype))));
- }
if (!ndo->ndo_suppress_default_print)
ND_DEFAULTPRINT(p, caplen);
+ llc_hdrlen = -llc_hdrlen;
}
- } else if ((fddip->fddi_fc & FDDIFC_CLFF) == FDDIFC_SMT)
+ } else if ((fddip->fddi_fc & FDDIFC_CLFF) == FDDIFC_SMT) {
fddi_smt_print(ndo, p, caplen);
- else {
+ llc_hdrlen = 0;
+ } else {
/* Some kinds of FDDI packet we cannot handle intelligently */
if (!ndo->ndo_eflag)
fddi_hdr_print(ndo, fddip, length + FDDI_HDRLEN, ESRC(&ehdr),
EDST(&ehdr));
if (!ndo->ndo_suppress_default_print)
ND_DEFAULTPRINT(p, caplen);
+ llc_hdrlen = 0;
}
+ return (FDDI_HDRLEN + llc_hdrlen);
}
/*
@@ -345,7 +341,5 @@ fddi_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen)
u_int
fddi_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, register const u_char *p)
{
- fddi_print(ndo, p, h->len, h->caplen);
-
- return (FDDI_HDRLEN);
+ return (fddi_print(ndo, p, h->len, h->caplen));
}
diff --git a/contrib/tcpdump/print-forces.c b/contrib/tcpdump/print-forces.c
index 6c02b25..de6c826 100644
--- a/contrib/tcpdump/print-forces.c
+++ b/contrib/tcpdump/print-forces.c
@@ -14,21 +14,21 @@
*
*/
-#define NETDISSECT_REWORKED
+/* \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 "interface.h"
+#include "netdissect.h"
#include "extract.h"
static const char tstr[] = "[|forces]";
-/*
- * RFC5810: Forwarding and Control Element Separation (ForCES) Protocol
- */
#define ForCES_VERS 1
#define ForCES_HDRL 24
#define ForCES_ALNL 4U
@@ -153,17 +153,17 @@ static const struct tok ForCES_TPs[] = {
* Structure of forces header, naked of TLVs.
*/
struct forcesh {
- uint8_t fm_vrsvd; /* version and reserved */
+ nd_uint8_t fm_vrsvd; /* version and reserved */
#define ForCES_V(forcesh) ((forcesh)->fm_vrsvd >> 4)
- uint8_t fm_tom; /* type of message */
- uint16_t fm_len; /* total length * 4 bytes */
+ 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))
- uint32_t fm_sid; /* Source ID */
+ nd_uint32_t fm_sid; /* Source ID */
#define ForCES_SID(forcesh) EXTRACT_32BITS(&(forcesh)->fm_sid)
- uint32_t fm_did; /* Destination ID */
+ nd_uint32_t fm_did; /* Destination ID */
#define ForCES_DID(forcesh) EXTRACT_32BITS(&(forcesh)->fm_did)
- uint8_t fm_cor[8]; /* correlator */
- uint32_t fm_flags; /* flags */
+ 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)
@@ -223,7 +223,7 @@ enum {
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),
+ B_OP_RTRCOMP = 1 << (F_OP_RTRCOMP - 1)
};
struct optlv_h {
@@ -243,8 +243,8 @@ static int invoptlv_print(netdissect_options *, register const u_char * pptr, re
#define OP_MIN_SIZ 8
struct pathdata_h {
- uint16_t pflags;
- uint16_t pIDcnt;
+ nd_uint16_t pflags;
+ nd_uint16_t pIDcnt;
};
#define B_FULLD 0x1
@@ -288,7 +288,7 @@ static inline const struct optlv_h *get_forces_optlv_h(uint16_t opt)
#define IND_CHR ' '
#define IND_PREF '\n'
#define IND_SUF 0x0
-char ind_buf[IND_SIZE];
+static char ind_buf[IND_SIZE];
static inline char *indent_pr(int indent, int nlpref)
{
@@ -376,30 +376,30 @@ static inline int ttlv_valid(uint16_t ttlv)
}
struct forces_ilv {
- uint32_t type;
- uint32_t length;
+ nd_uint32_t type;
+ nd_uint32_t length;
};
struct forces_tlv {
- uint16_t type;
- uint16_t length;
+ 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) ((struct forces_tlv *)((fhdr) + sizeof (struct forcesh)))
+#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) ((void*)(((char*)(tlvp)) + 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)), \
- (struct forces_tlv*)(((char*)(tlv)) \
+ (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) ((void*)(((char*)(ilvp)) + 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)), \
- (struct forces_ilv *)(((char*)(ilv)) \
+ (const struct forces_ilv *)(((const char*)(ilv)) \
+ F_ALN_LEN(EXTRACT_32BITS(&(ilv)->length))))
#define INVALID_RLEN 1
#define INVALID_STLN 2
@@ -452,8 +452,8 @@ static int asttlv_print(netdissect_options *, register const u_char * pptr, regi
uint16_t op_msk, int indent);
struct forces_lfbsh {
- uint32_t class;
- uint32_t instance;
+ nd_uint32_t class;
+ nd_uint32_t instance;
};
#define ASSNS_OPS (B_OP_REPORT)
@@ -546,9 +546,9 @@ chk_op_type(netdissect_options *ndo,
#define F_TABAPPEND 4
struct res_val {
- uint8_t result;
- uint8_t resv1;
- uint16_t resv2;
+ 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,
@@ -646,9 +646,9 @@ 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;
/*
@@ -684,9 +684,9 @@ 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);
+ register const u_char *tdp = (const u_char *) TLV_DATA(tlv);
uint16_t type;
/*
@@ -720,7 +720,7 @@ sdatailv_print(netdissect_options *ndo,
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) {
@@ -734,7 +734,7 @@ sdatailv_print(netdissect_options *ndo,
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);
+ register const u_char *tdp = (const u_char *) ILV_DATA(ilv);
ND_TCHECK(*ilv);
invilv = ilv_valid(ilv, rlen);
if (invilv) {
@@ -765,9 +765,9 @@ 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);
+ register const u_char *tdp = (const u_char *) TLV_DATA(tlv);
uint16_t type;
/*
@@ -794,10 +794,10 @@ 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;
+ const struct forces_tlv *kdtlv = (const struct forces_tlv *)dp;
uint32_t id;
char *ib = indent_pr(indent, 0);
uint16_t type, tll;
@@ -822,7 +822,7 @@ pkeyitlv_print(netdissect_options *ndo,
* go past the end of the containing TLV).
*/
tll = EXTRACT_16BITS(&kdtlv->length);
- dp = (u_char *) TLV_DATA(kdtlv);
+ dp = (const u_char *) TLV_DATA(kdtlv);
return fdatatlv_print(ndo, dp, tll, op_msk, indent);
trunc:
@@ -881,7 +881,7 @@ pdatacnt_print(netdissect_options *ndo,
}
if (op_msk & B_KEYIN) {
- struct forces_tlv *keytlv;
+ const struct forces_tlv *keytlv;
uint16_t tll;
if (len < PTH_DESC_SIZE) {
@@ -893,7 +893,7 @@ pdatacnt_print(netdissect_options *ndo,
/* skip keyid */
pptr += 4;
len -= 4;
- keytlv = (struct forces_tlv *)pptr;
+ keytlv = (const struct forces_tlv *)pptr;
/* skip header */
pptr += sizeof(struct forces_tlv);
len -= sizeof(struct forces_tlv);
@@ -916,7 +916,7 @@ pdatacnt_print(netdissect_options *ndo,
}
if (len) {
- const struct forces_tlv *pdtlv = (struct forces_tlv *)pptr;
+ const struct forces_tlv *pdtlv = (const struct forces_tlv *)pptr;
uint16_t type;
uint16_t tll;
int pad = 0;
@@ -992,7 +992,7 @@ 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;
@@ -1056,7 +1056,7 @@ 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;
+ const struct forces_tlv *pdtlv = (const struct forces_tlv *)pptr;
uint16_t type;
int tll;
u_int invtlv;
@@ -1074,7 +1074,7 @@ genoptlv_print(netdissect_options *ndo,
* 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)) {
ND_PRINT((ndo, "%s TLV type 0x%x len %d\n",
tok2str(ForCES_TLV_err, NULL, invtlv), type,
@@ -1102,7 +1102,7 @@ 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;
u_int invtlv;
uint16_t type;
@@ -1123,7 +1123,7 @@ recpdoptlv_print(netdissect_options *ndo,
*/
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 (ndo->ndo_vflag >= 3)
@@ -1171,7 +1171,7 @@ 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);
+ register const u_char *dp = (const u_char *) TLV_DATA(otlv);
uint16_t type;
int tll;
char *ib = indent_pr(indent, 0);
@@ -1349,7 +1349,7 @@ print_metailv(netdissect_options *ndo,
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
@@ -1378,7 +1378,7 @@ print_metatlv(netdissect_options *ndo,
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;
/*
@@ -1400,7 +1400,7 @@ print_metatlv(netdissect_options *ndo,
* length is large enough but not too large (it doesn't
* go past the end of the containing TLV).
*/
- print_metailv(ndo, (u_char *) ilv, 0, indent + 1);
+ print_metailv(ndo, (const u_char *) ilv, 0, indent + 1);
ilv = GO_NXT_ILV(ilv, rlen);
}
@@ -1415,7 +1415,7 @@ trunc:
static int
print_reddata(netdissect_options *ndo,
register const u_char * pptr, register u_int len,
- uint16_t op_msk _U_, int indent _U_)
+ uint16_t op_msk _U_, int indent)
{
u_int dlen;
char *ib = indent_pr(indent, 0);
@@ -1439,7 +1439,7 @@ 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;
u_int invtlv;
@@ -1471,10 +1471,10 @@ redirect_print(netdissect_options *ndo,
* go past the end of the containing TLV).
*/
if (EXTRACT_16BITS(&tlv->type) == F_TLV_METD) {
- print_metatlv(ndo, (u_char *) TLV_DATA(tlv),
+ 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(ndo, (u_char *) TLV_DATA(tlv),
+ print_reddata(ndo, (const u_char *) TLV_DATA(tlv),
EXTRACT_16BITS(&tlv->length), 0, indent);
} else {
ND_PRINT((ndo, "Unknown REDIRECT TLV 0x%x len %d\n",
@@ -1541,7 +1541,7 @@ lfbselect_print(netdissect_options *ndo,
EXTRACT_32BITS(&lfbs->instance)));
}
- otlv = (struct forces_tlv *)(lfbs + 1);
+ otlv = (const struct forces_tlv *)(lfbs + 1);
indent += 1;
while (rlen != 0) {
@@ -1563,7 +1563,7 @@ lfbselect_print(netdissect_options *ndo,
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, (u_char *)otlv, rlen, 0, indent);
+ invoptlv_print(ndo, (const u_char *)otlv, rlen, 0, indent);
}
otlv = GO_NXT_TLV(otlv, rlen);
}
@@ -1645,7 +1645,7 @@ forces_type_print(netdissect_options *ndo,
EXTRACT_16BITS(&tltlv->length),
EXTRACT_16BITS(&tltlv->length) - TLV_HDRL));
- rc = tops->print(ndo, (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;
diff --git a/contrib/tcpdump/print-fr.c b/contrib/tcpdump/print-fr.c
index b7bec4b..da7ee25 100644
--- a/contrib/tcpdump/print-fr.c
+++ b/contrib/tcpdump/print-fr.c
@@ -17,21 +17,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$
*/
-#define NETDISSECT_REWORKED
+/* \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 "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "ethertype.h"
#include "llc.h"
@@ -277,7 +276,8 @@ fr_print(netdissect_options *ndo,
if (ethertype_print(ndo, extracted_ethertype,
p+addr_len+ETHERTYPE_LEN,
length-addr_len-ETHERTYPE_LEN,
- length-addr_len-ETHERTYPE_LEN) == 0)
+ 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
@@ -329,11 +329,11 @@ fr_print(netdissect_options *ndo,
case NLPID_CLNP:
case NLPID_ESIS:
case NLPID_ISIS:
- isoclns_print(ndo, 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(ndo, 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 (!ndo->ndo_eflag)
fr_hdr_print(ndo, length + hdr_len, hdr_len,
@@ -599,6 +599,10 @@ frf15_print(netdissect_options *ndo,
{
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];
@@ -616,7 +620,10 @@ frf15_print(netdissect_options *ndo,
* model is end-to-end or interface based wether we want to print
* another Q.922 header
*/
+ return;
+trunc:
+ ND_PRINT((ndo, "[|frf.15]"));
}
/*
@@ -684,7 +691,11 @@ static const 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? */
@@ -695,7 +706,7 @@ static const struct tok fr_q933_msg_values[] = {
#define FR_LMI_CCITT_LINK_VERIFY_IE 0x53
#define FR_LMI_CCITT_PVC_STATUS_IE 0x57
-static const 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" },
@@ -717,14 +728,14 @@ static const struct tok fr_lmi_report_type_ie_values[] = {
{ 0, NULL }
};
-/* array of 16 codepages - currently we only support codepage 1,5 */
+/* 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,
@@ -737,20 +748,20 @@ static const struct tok *fr_q933_ie_codesets[] = {
NULL
};
-static int fr_q933_print_ie_codeset5(netdissect_options *ndo,
- 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)(netdissect_options *,
- 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 */
+/* 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,
@@ -763,121 +774,316 @@ static const 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(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 */
- ND_PRINT((ndo, "[|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 */
-
- if (p[2] == MSG_ANSI_LOCKING_SHIFT) {
- is_ansi = 1;
+ /*
+ * 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--;
}
- ND_PRINT((ndo, "%s", ndo->ndo_eflag ? "" : "Q.933, "));
+ /*
+ * 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;
+ }
+ }
+ }
/* printing out header part */
+ if (!ndo->ndo_eflag)
+ ND_PRINT((ndo, ", "));
ND_PRINT((ndo, "%s, codeset %u", is_ansi ? "ANSI" : "CCITT", codeset));
- if (p[0]) {
- ND_PRINT((ndo, ", Call Ref: 0x%02x", p[0]));
+ 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 (ndo->ndo_vflag) {
- ND_PRINT((ndo, ", %s (0x%02x), length %u",
- tok2str(fr_q933_msg_values,
- "unknown message", p[1]),
- p[1],
- length));
- } else {
- ND_PRINT((ndo, ", %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)) {
- ND_PRINT((ndo, "[|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 (ndo->ndo_vflag) { /* not bark if there is just a trailer */
- ND_PRINT((ndo, "\n[|q.933]"));
- } else {
- ND_PRINT((ndo, ", 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 (ndo->ndo_vflag) {
- ND_PRINT((ndo, "\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;
- }
- if (fr_q933_print_ie_codeset[codeset] != NULL) {
- ie_is_known = fr_q933_print_ie_codeset[codeset](ndo, ie_p, ptemp);
+ /* 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 (ndo->ndo_vflag >= 1 && !ie_is_known) {
- print_unknown_data(ndo, 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;
}
+ iecode = *p;
+ p++;
+ length--;
- /* do we want to see a hexdump of the IE ? */
- if (ndo->ndo_vflag> 1 && ie_is_known) {
- print_unknown_data(ndo, ptemp+2, "\n\t ", ie_p->ie_len);
+ /* 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 (!ndo->ndo_vflag) {
- ND_PRINT((ndo, ", 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(netdissect_options *ndo,
- 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 (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[2]),
- p[2]));
+ tok2str(fr_lmi_report_type_ie_values,"unknown",p[0]),
+ p[0]));
}
return 1;
@@ -887,7 +1093,11 @@ fr_q933_print_ie_codeset5(netdissect_options *ndo,
if (!ndo->ndo_vflag) {
ND_PRINT((ndo, ", "));
}
- ND_PRINT((ndo, "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 */
@@ -896,28 +1106,29 @@ fr_q933_print_ie_codeset5(netdissect_options *ndo,
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)) {
- ND_PRINT((ndo, "Invalid DLCI IE"));
+ 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);
}
ND_PRINT((ndo, "DLCI %u: status %s%s", dlci,
- p[ie_p->ie_len + 1] & 0x8 ? "New, " : "",
- p[ie_p->ie_len + 1] & 0x2 ? "Active" : "Inactive"));
+ p[ielength - 1] & 0x8 ? "New, " : "",
+ p[ielength - 1] & 0x2 ? "Active" : "Inactive"));
return 1;
}
diff --git a/contrib/tcpdump/print-frag6.c b/contrib/tcpdump/print-frag6.c
index 1290952..db4a98e 100644
--- a/contrib/tcpdump/print-frag6.c
+++ b/contrib/tcpdump/print-frag6.c
@@ -19,17 +19,16 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#define NETDISSECT_REWORKED
+/* \summary: IPv6 fragmentation header printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#ifdef INET6
-
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include "ip6.h"
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
int
@@ -68,4 +67,3 @@ trunc:
ND_PRINT((ndo, "[|frag]"));
return -1;
}
-#endif /* INET6 */
diff --git a/contrib/tcpdump/print-ftp.c b/contrib/tcpdump/print-ftp.c
index 5479042..a1dd607 100644
--- a/contrib/tcpdump/print-ftp.c
+++ b/contrib/tcpdump/print-ftp.c
@@ -11,16 +11,13 @@
* FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header$";
-#endif
+/* \summary: File Transfer Protocol (FTP) printer */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/contrib/tcpdump/print-geneve.c b/contrib/tcpdump/print-geneve.c
index 2187ab8..40402ab 100644
--- a/contrib/tcpdump/print-geneve.c
+++ b/contrib/tcpdump/print-geneve.c
@@ -15,19 +15,20 @@
* FOR A PARTICULAR PURPOSE.
*/
-#define NETDISSECT_REWORKED
+/* \summary: Generic Network Virtualization Encapsulation (Geneve) printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
#include "ethertype.h"
/*
- * Geneve header, draft-gross-geneve-02
+ * 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
@@ -77,12 +78,25 @@ static const struct tok geneve_flag_values[] = {
static const char *
format_opt_class(uint16_t opt_class)
{
- if (opt_class <= 0xff)
- return "Standard";
- else if (opt_class == 0xffff)
- return "Experimental";
- else
- return "Unknown";
+ 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
@@ -112,14 +126,14 @@ geneve_opts_print(netdissect_options *ndo, const u_char *bp, u_int len)
}
if (ndo->ndo_vflag > 1 && opt_len > 4) {
- uint32_t *print_data = (uint32_t *)(bp + 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(print_data)));
- print_data++;
+ ND_PRINT((ndo, " %08x", EXTRACT_32BITS(data)));
+ data++;
}
}
@@ -132,7 +146,7 @@ void
geneve_print(netdissect_options *ndo, const u_char *bp, u_int len)
{
uint8_t ver_opt;
- uint version;
+ u_int version;
uint8_t flags;
uint16_t prot;
uint32_t vni;
@@ -184,7 +198,7 @@ geneve_print(netdissect_options *ndo, const u_char *bp, u_int len)
if (len < opts_len) {
ND_PRINT((ndo, " truncated-geneve - %u bytes missing",
- len - opts_len));
+ opts_len - len));
return;
}
@@ -209,9 +223,9 @@ geneve_print(netdissect_options *ndo, const u_char *bp, u_int len)
else
ND_PRINT((ndo, "\n\t"));
- if (ethertype_print(ndo, prot, bp, len, len) == 0) {
+ if (ethertype_print(ndo, prot, bp, len, ndo->ndo_snapend - bp, NULL, NULL) == 0) {
if (prot == ETHERTYPE_TEB)
- ether_print(ndo, bp, len, len, NULL, NULL);
+ ether_print(ndo, bp, len, ndo->ndo_snapend - bp, NULL, NULL);
else
ND_PRINT((ndo, "geneve-proto-0x%x", prot));
}
diff --git a/contrib/tcpdump/print-geonet.c b/contrib/tcpdump/print-geonet.c
index edfb7f2..9da89bf 100644
--- a/contrib/tcpdump/print-geonet.c
+++ b/contrib/tcpdump/print-geonet.c
@@ -15,14 +15,15 @@
* Original code by Ola Martin Lykkja (ola.lykkja@q-free.com)
*/
-#define NETDISSECT_REWORKED
+/* \summary: ISO CALM FAST and ETSI GeoNetworking printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
#include "addrtoname.h"
@@ -85,6 +86,8 @@ print_long_pos_vector(netdissect_options *ndo,
{
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))
@@ -102,7 +105,8 @@ print_long_pos_vector(netdissect_options *ndo,
* to the geonet header of the packet.
*/
void
-geonet_print(netdissect_options *ndo, const u_char *eth, const u_char *bp, u_int length)
+geonet_print(netdissect_options *ndo, const u_char *bp, u_int length,
+ const struct lladdr_info *src)
{
int version;
int next_hdr;
@@ -114,13 +118,16 @@ geonet_print(netdissect_options *ndo, const u_char *eth, const u_char *bp, u_int
const char *hdr_type_txt = "Unknown";
int hdr_size = -1;
- ND_PRINT((ndo, "GeoNet src:%s; ", etheraddr_string(ndo, eth+6)));
+ 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 malformed;
-
- ND_TCHECK2(*bp, 7);
+ goto invalid;
+
+ ND_TCHECK2(*bp, 8);
version = bp[0] >> 4;
next_hdr = bp[0] & 0x0f;
hdr_type = bp[1] >> 4;
@@ -224,7 +231,7 @@ geonet_print(netdissect_options *ndo, const u_char *eth, const u_char *bp, u_int
/* Skip Extended headers */
if (hdr_size >= 0) {
if (length < (u_int)hdr_size)
- goto malformed;
+ goto invalid;
ND_TCHECK2(*bp, hdr_size);
length -= hdr_size;
bp += hdr_size;
@@ -234,7 +241,7 @@ geonet_print(netdissect_options *ndo, const u_char *eth, const u_char *bp, u_int
case 1:
case 2: /* BTP A/B */
if (length < 4)
- goto malformed;
+ goto invalid;
ND_TCHECK2(*bp, 4);
print_btp(ndo, bp);
length -= 4;
@@ -261,7 +268,7 @@ geonet_print(netdissect_options *ndo, const u_char *eth, const u_char *bp, u_int
ND_DEFAULTPRINT(bp, length);
return;
-malformed:
+invalid:
ND_PRINT((ndo, " Malformed (small) "));
/* XXX - print the remaining data as hex? */
return;
diff --git a/contrib/tcpdump/print-gre.c b/contrib/tcpdump/print-gre.c
index 4d7705f..505752a 100644
--- a/contrib/tcpdump/print-gre.c
+++ b/contrib/tcpdump/print-gre.c
@@ -31,21 +31,23 @@
* 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)
*/
-#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <string.h>
-#include "interface.h"
+#include "netdissect.h"
+#include "addrtostr.h"
#include "extract.h"
#include "ethertype.h"
@@ -78,19 +80,18 @@ static const struct tok gre_flag_values[] = {
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 void gre_sre_print(netdissect_options *, uint16_t, uint8_t, uint8_t, const u_char *, u_int);
-static void gre_sre_ip_print(netdissect_options *, uint8_t, uint8_t, const u_char *, u_int);
-static void gre_sre_asn_print(netdissect_options *, uint8_t, uint8_t, 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(netdissect_options *ndo, const u_char *bp, u_int length)
{
u_int len = length, vers;
- if (len < 2) {
- ND_PRINT((ndo, "%s", tstr));
- return;
- }
+ ND_TCHECK2(*bp, 2);
+ if (len < 2)
+ goto trunc;
vers = EXTRACT_16BITS(bp) & GRE_VERS_MASK;
ND_PRINT((ndo, "GREv%u",vers));
@@ -105,6 +106,11 @@ gre_print(netdissect_options *ndo, const u_char *bp, u_int length)
ND_PRINT((ndo, " ERROR: unknown-version"));
break;
}
+ return;
+
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
+ return;
}
static void
@@ -121,6 +127,7 @@ gre_print_0(netdissect_options *ndo, const u_char *bp, u_int length)
len -= 2;
bp += 2;
+ ND_TCHECK2(*bp, 2);
if (len < 2)
goto trunc;
prot = EXTRACT_16BITS(bp);
@@ -128,6 +135,7 @@ gre_print_0(netdissect_options *ndo, 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 (ndo->ndo_vflag)
@@ -135,6 +143,7 @@ gre_print_0(netdissect_options *ndo, const u_char *bp, u_int length)
bp += 2;
len -= 2;
+ ND_TCHECK2(*bp, 2);
if (len < 2)
goto trunc;
ND_PRINT((ndo, ", off 0x%x", EXTRACT_16BITS(bp)));
@@ -143,6 +152,7 @@ gre_print_0(netdissect_options *ndo, const u_char *bp, u_int length)
}
if (flags & GRE_KP) {
+ ND_TCHECK2(*bp, 4);
if (len < 4)
goto trunc;
ND_PRINT((ndo, ", key=0x%x", EXTRACT_32BITS(bp)));
@@ -151,6 +161,7 @@ gre_print_0(netdissect_options *ndo, const u_char *bp, u_int length)
}
if (flags & GRE_SP) {
+ ND_TCHECK2(*bp, 4);
if (len < 4)
goto trunc;
ND_PRINT((ndo, ", seq %u", EXTRACT_32BITS(bp)));
@@ -164,6 +175,7 @@ gre_print_0(netdissect_options *ndo, const u_char *bp, u_int length)
uint8_t sreoff;
uint8_t srelen;
+ ND_TCHECK2(*bp, 4);
if (len < 4)
goto trunc;
af = EXTRACT_16BITS(bp);
@@ -175,7 +187,8 @@ gre_print_0(netdissect_options *ndo, const u_char *bp, u_int length)
if (af == 0 && srelen == 0)
break;
- gre_sre_print(ndo, af, sreoff, srelen, bp, len);
+ if (!gre_sre_print(ndo, af, sreoff, srelen, bp, len))
+ goto trunc;
if (len < srelen)
goto trunc;
@@ -213,10 +226,10 @@ gre_print_0(netdissect_options *ndo, const u_char *bp, u_int length)
atalk_print(ndo, bp, len);
break;
case ETHERTYPE_GRE_ISO:
- isoclns_print(ndo, bp, len, len);
+ isoclns_print(ndo, bp, len, ndo->ndo_snapend - bp);
break;
case ETHERTYPE_TEB:
- ether_print(ndo, bp, len, len, NULL, NULL);
+ ether_print(ndo, bp, len, ndo->ndo_snapend - bp, NULL, NULL);
break;
default:
ND_PRINT((ndo, "gre-proto-0x%x", prot));
@@ -241,6 +254,7 @@ gre_print_1(netdissect_options *ndo, const u_char *bp, u_int length)
ND_PRINT((ndo, ", Flags [%s]",
bittok2str(gre_flag_values,"none",flags)));
+ ND_TCHECK2(*bp, 2);
if (len < 2)
goto trunc;
prot = EXTRACT_16BITS(bp);
@@ -251,6 +265,7 @@ gre_print_1(netdissect_options *ndo, const u_char *bp, u_int length)
if (flags & GRE_KP) {
uint32_t k;
+ ND_TCHECK2(*bp, 4);
if (len < 4)
goto trunc;
k = EXTRACT_32BITS(bp);
@@ -260,6 +275,7 @@ gre_print_1(netdissect_options *ndo, const u_char *bp, u_int length)
}
if (flags & GRE_SP) {
+ ND_TCHECK2(*bp, 4);
if (len < 4)
goto trunc;
ND_PRINT((ndo, ", seq %u", EXTRACT_32BITS(bp)));
@@ -268,6 +284,7 @@ gre_print_1(netdissect_options *ndo, const u_char *bp, u_int length)
}
if (flags & GRE_AP) {
+ ND_TCHECK2(*bp, 4);
if (len < 4)
goto trunc;
ND_PRINT((ndo, ", ack %u", EXTRACT_32BITS(bp)));
@@ -307,62 +324,68 @@ trunc:
ND_PRINT((ndo, "%s", tstr));
}
-static void
+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:
ND_PRINT((ndo, ", (rtaf=ip"));
- gre_sre_ip_print(ndo, sreoff, srelen, bp, len);
- ND_PRINT((ndo, ") "));
+ ret = gre_sre_ip_print(ndo, sreoff, srelen, bp, len);
+ ND_PRINT((ndo, ")"));
break;
case GRESRE_ASN:
ND_PRINT((ndo, ", (rtaf=asn"));
- gre_sre_asn_print(ndo, sreoff, srelen, bp, len);
- ND_PRINT((ndo, ") "));
+ ret = gre_sre_asn_print(ndo, sreoff, srelen, bp, len);
+ ND_PRINT((ndo, ")"));
break;
default:
- ND_PRINT((ndo, ", (rtaf=0x%x) ", af));
+ ND_PRINT((ndo, ", (rtaf=0x%x)", af));
+ ret = 1;
}
+ return (ret);
}
-static void
+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) {
ND_PRINT((ndo, ", badoffset=%u", sreoff));
- return;
+ return (1);
}
if (srelen & 3) {
ND_PRINT((ndo, ", badlength=%u", srelen));
- return;
+ return (1);
}
if (sreoff >= srelen) {
ND_PRINT((ndo, ", badoff/len=%u/%u", sreoff, srelen));
- return;
+ 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));
+ addrtostr(bp, buf, sizeof(buf));
ND_PRINT((ndo, " %s%s",
- ((bp - up) == sreoff) ? "*" : "",
- inet_ntoa(a)));
+ ((bp - up) == sreoff) ? "*" : "", buf));
bp += 4;
len -= 4;
srelen -= 4;
}
+ return (1);
}
-static void
+static int
gre_sre_asn_print(netdissect_options *ndo, uint8_t sreoff, uint8_t srelen,
const u_char *bp, u_int len)
{
@@ -370,20 +393,22 @@ gre_sre_asn_print(netdissect_options *ndo, uint8_t sreoff, uint8_t srelen,
if (sreoff & 1) {
ND_PRINT((ndo, ", badoffset=%u", sreoff));
- return;
+ return (1);
}
if (srelen & 1) {
ND_PRINT((ndo, ", badlength=%u", srelen));
- return;
+ return (1);
}
if (sreoff >= srelen) {
ND_PRINT((ndo, ", badoff/len=%u/%u", sreoff, srelen));
- return;
+ return (1);
}
- for (;;) {
- if (len < 2 || srelen == 0)
- return;
+ while (srelen != 0) {
+ if (!ND_TTEST2(*bp, 2))
+ return (0);
+ if (len < 2)
+ return (0);
ND_PRINT((ndo, " %s%x",
((bp - up) == sreoff) ? "*" : "",
@@ -393,4 +418,5 @@ gre_sre_asn_print(netdissect_options *ndo, uint8_t sreoff, uint8_t srelen,
len -= 2;
srelen -= 2;
}
+ return (1);
}
diff --git a/contrib/tcpdump/print-hncp.c b/contrib/tcpdump/print-hncp.c
new file mode 100644
index 0000000..87ee8bb
--- /dev/null
+++ b/contrib/tcpdump/print-hncp.c
@@ -0,0 +1,855 @@
+/*
+ * 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;
+}
diff --git a/contrib/tcpdump/print-hsrp.c b/contrib/tcpdump/print-hsrp.c
index 0e2420f..3514646 100644
--- a/contrib/tcpdump/print-hsrp.c
+++ b/contrib/tcpdump/print-hsrp.c
@@ -27,16 +27,17 @@
* SUCH DAMAGE.
*/
+/* \summary: Cisco Hot Standby Router Protocol (HSRP) printer */
+
/* Cisco Hot Standby Router Protocol (HSRP). */
-#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
/* HSRP op code types. */
@@ -94,7 +95,7 @@ struct hsrp {
void
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;
ND_TCHECK(hp->hsrp_version);
ND_PRINT((ndo, "HSRPv%d", hp->hsrp_version));
@@ -116,9 +117,9 @@ hsrp_print(netdissect_options *ndo, register const uint8_t *bp, register u_int l
ND_PRINT((ndo, "addr=%s", ipaddr_string(ndo, &hp->hsrp_virtaddr)));
if (ndo->ndo_vflag) {
ND_PRINT((ndo, " hellotime="));
- relts_print(ndo, hp->hsrp_hellotime);
+ unsigned_relts_print(ndo, hp->hsrp_hellotime);
ND_PRINT((ndo, " holdtime="));
- relts_print(ndo, hp->hsrp_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),
diff --git a/contrib/tcpdump/print-http.c b/contrib/tcpdump/print-http.c
index 49df174..0aec758 100644
--- a/contrib/tcpdump/print-http.c
+++ b/contrib/tcpdump/print-http.c
@@ -11,21 +11,18 @@
* FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header$";
-#endif
+/* \summary: Hypertext Transfer Protocol (HTTP) printer */
#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"
/*
diff --git a/contrib/tcpdump/print-icmp.c b/contrib/tcpdump/print-icmp.c
index a4d8275..17e7a75 100644
--- a/contrib/tcpdump/print-icmp.c
+++ b/contrib/tcpdump/print-icmp.c
@@ -17,23 +17,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$
*/
-#define NETDISSECT_REWORKED
+/* \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"
@@ -346,9 +345,9 @@ icmp_print(netdissect_options *ndo, const u_char *bp, u_int plen, const u_char *
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;
ND_TCHECK(dp->icmp_code);
@@ -380,7 +379,7 @@ icmp_print(netdissect_options *ndo, const u_char *bp, u_int plen, const u_char *
ND_TCHECK(dp->icmp_ip.ip_p);
oip = &dp->icmp_ip;
hlen = IP_HL(oip) * 4;
- ouh = (struct udphdr *)(((u_char *)oip) + hlen);
+ ouh = (const struct udphdr *)(((const u_char *)oip) + hlen);
ND_TCHECK(ouh->uh_dport);
dport = EXTRACT_16BITS(&ouh->uh_dport);
switch (oip->ip_p) {
@@ -389,14 +388,14 @@ icmp_print(netdissect_options *ndo, const u_char *bp, u_int plen, const u_char *
(void)snprintf(buf, sizeof(buf),
"%s tcp port %s unreachable",
ipaddr_string(ndo, &oip->ip_dst),
- tcpport_string(dport));
+ tcpport_string(ndo, dport));
break;
case IPPROTO_UDP:
(void)snprintf(buf, sizeof(buf),
"%s udp port %s unreachable",
ipaddr_string(ndo, &oip->ip_dst),
- udpport_string(dport));
+ udpport_string(ndo, dport));
break;
default:
@@ -411,7 +410,7 @@ icmp_print(netdissect_options *ndo, const u_char *bp, u_int plen, const u_char *
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),
@@ -452,7 +451,7 @@ icmp_print(netdissect_options *ndo, const u_char *bp, u_int plen, const u_char *
(void)snprintf(buf, sizeof(buf), "router advertisement");
cp = buf + strlen(buf);
- ihp = (struct ih_rdiscovery *)&dp->icmp_void;
+ ihp = (const struct ih_rdiscovery *)&dp->icmp_void;
ND_TCHECK(*ihp);
(void)strncpy(cp, " lifetime ", sizeof(buf) - (cp - buf));
cp = buf + strlen(buf);
@@ -482,7 +481,7 @@ icmp_print(netdissect_options *ndo, const u_char *bp, u_int plen, const u_char *
" [size %d]", size);
break;
}
- idp = (struct id_rdiscovery *)&dp->icmp_data;
+ idp = (const struct id_rdiscovery *)&dp->icmp_data;
while (num-- > 0) {
ND_TCHECK(*idp);
(void)snprintf(cp, sizeof(buf) - (cp - buf), " {%s %u}",
@@ -559,9 +558,9 @@ icmp_print(netdissect_options *ndo, const u_char *bp, u_int plen, const u_char *
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;
- struct cksum_vec vec[1];
+
if (ND_TTEST2(*bp, plen)) {
- vec[0].ptr = (const uint8_t *)(void *)dp;
+ vec[0].ptr = (const uint8_t *)(const void *)dp;
vec[0].len = plen;
sum = in_cksum(vec, 1);
if (sum != 0) {
@@ -580,7 +579,7 @@ icmp_print(netdissect_options *ndo, const u_char *bp, u_int plen, const u_char *
if (ndo->ndo_vflag >= 1 && ICMP_ERRTYPE(dp->icmp_type)) {
bp += 8;
ND_PRINT((ndo, "\n\t"));
- ip = (struct ip *)bp;
+ 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));
@@ -601,7 +600,7 @@ icmp_print(netdissect_options *ndo, const u_char *bp, u_int plen, const u_char *
* however not all implementations set the length field proper.
*/
if (!ext_dp->icmp_length) {
- vec[0].ptr = (const uint8_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;
@@ -621,7 +620,7 @@ icmp_print(netdissect_options *ndo, const u_char *bp, u_int plen, const u_char *
}
hlen = plen - ICMP_EXTD_MINLEN;
- vec[0].ptr = (const uint8_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;
ND_PRINT((ndo, ", checksum 0x%04x (%scorrect), length %u",
EXTRACT_16BITS(ext_dp->icmp_ext_checksum),
@@ -629,11 +628,11 @@ icmp_print(netdissect_options *ndo, const u_char *bp, u_int plen, const u_char *
hlen));
hlen -= 4; /* subtract common header size */
- obj_tptr = (uint8_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;
+ 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;
diff --git a/contrib/tcpdump/print-icmp6.c b/contrib/tcpdump/print-icmp6.c
index 81563e6..7fe639d 100644
--- a/contrib/tcpdump/print-icmp6.c
+++ b/contrib/tcpdump/print-icmp6.c
@@ -19,20 +19,20 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#define NETDISSECT_REWORKED
+/* \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"
@@ -284,13 +284,13 @@ struct nd_opt_hdr { /* Neighbor discovery option header */
#define ND_OPT_DNSSL 31
struct nd_opt_prefix_info { /* prefix information */
- uint8_t nd_opt_pi_type;
- uint8_t nd_opt_pi_len;
- uint8_t nd_opt_pi_prefix_len;
- uint8_t nd_opt_pi_flags_reserved;
- uint8_t nd_opt_pi_valid_time[4];
- uint8_t nd_opt_pi_preferred_time[4];
- uint8_t nd_opt_pi_reserved2[4];
+ 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;
};
@@ -622,14 +622,14 @@ print_lladdr(netdissect_options *ndo, const uint8_t *p, size_t 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 uint8_t *)(void *)icp, len, len,
+ return nextproto6_cksum(ndo, ip6, (const uint8_t *)(const void *)icp, len, len,
IPPROTO_ICMPV6);
}
-const struct tok rpl_mop_values[] = {
+static const struct tok rpl_mop_values[] = {
{ RPL_DIO_NONSTORING, "nonstoring"},
{ RPL_DIO_STORING, "storing"},
{ RPL_DIO_NONSTORING_MULTICAST, "nonstoring-multicast"},
@@ -637,7 +637,7 @@ const struct tok rpl_mop_values[] = {
{ 0, NULL},
};
-const struct tok rpl_subopt_values[] = {
+static const struct tok rpl_subopt_values[] = {
{ RPL_OPT_PAD0, "pad0"},
{ RPL_OPT_PADN, "padN"},
{ RPL_DIO_METRICS, "metrics"},
@@ -651,23 +651,6 @@ const struct tok rpl_subopt_values[] = {
};
static void
-rpl_format_dagid(char dagid_str[65], const u_char *dagid)
-{
- char *d = dagid_str;
- int i;
-
- for(i=0;i<16;i++) {
- if(isprint(dagid[i])) {
- *d++ = dagid[i];
- } else {
- snprintf(d,5,"0x%02x", dagid[i]); /* 4 + null char */
- d += 4;
- }
- }
- *d++ = '\0';
-}
-
-static void
rpl_dio_printopt(netdissect_options *ndo,
const struct rpl_dio_genoption *opt,
u_int length)
@@ -678,7 +661,7 @@ rpl_dio_printopt(netdissect_options *ndo,
ND_TCHECK(opt->rpl_dio_len);
while((opt->rpl_dio_type == RPL_OPT_PAD0 &&
- (u_char *)opt < ndo->ndo_snapend) ||
+ (const u_char *)opt < ndo->ndo_snapend) ||
ND_TTEST2(*opt,(opt->rpl_dio_len+2))) {
unsigned int optlen = opt->rpl_dio_len+2;
@@ -687,18 +670,18 @@ rpl_dio_printopt(netdissect_options *ndo,
ND_PRINT((ndo, " opt:pad0"));
} else {
ND_PRINT((ndo, " opt:%s len:%u ",
- tok2str(rpl_subopt_values, "%subopt:%u", opt->rpl_dio_type),
+ 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,
" ",
- ((uint8_t *)opt) + RPL_DIO_GENOPTION_LEN, /* content of DIO option */
+ ((const uint8_t *)opt) + RPL_DIO_GENOPTION_LEN, /* content of DIO option */
paylen);
}
}
- opt = (struct rpl_dio_genoption *)(((char *)opt) + optlen);
+ opt = (const struct rpl_dio_genoption *)(((const char *)opt) + optlen);
length -= optlen;
}
return;
@@ -711,11 +694,11 @@ static void
rpl_dio_print(netdissect_options *ndo,
const u_char *bp, u_int length)
{
- const struct nd_rpl_dio *dio = (struct nd_rpl_dio *)bp;
- char dagid_str[65];
+ const struct nd_rpl_dio *dio = (const struct nd_rpl_dio *)bp;
+ const char *dagid_str;
ND_TCHECK(*dio);
- rpl_format_dagid(dagid_str, dio->rpl_dagid);
+ 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,
@@ -727,7 +710,7 @@ rpl_dio_print(netdissect_options *ndo,
RPL_DIO_PRF(dio->rpl_mopprf)));
if(ndo->ndo_vflag > 1) {
- struct rpl_dio_genoption *opt = (struct rpl_dio_genoption *)&dio[1];
+ const struct rpl_dio_genoption *opt = (const struct rpl_dio_genoption *)&dio[1];
rpl_dio_printopt(ndo, opt, length);
}
return;
@@ -740,21 +723,20 @@ static void
rpl_dao_print(netdissect_options *ndo,
const u_char *bp, u_int length)
{
- const struct nd_rpl_dao *dao = (struct nd_rpl_dao *)bp;
- char dagid_str[65];
+ 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;
- strcpy(dagid_str,"<elided>");
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;
- rpl_format_dagid(dagid_str, dao->rpl_dagid);
+ dagid_str = ip6addr_string (ndo, dao->rpl_dagid);
bp += DAGID_LEN;
length -= DAGID_LEN;
}
@@ -768,7 +750,7 @@ rpl_dao_print(netdissect_options *ndo,
dao->rpl_flags));
if(ndo->ndo_vflag > 1) {
- const struct rpl_dio_genoption *opt = (struct rpl_dio_genoption *)bp;
+ const struct rpl_dio_genoption *opt = (const struct rpl_dio_genoption *)bp;
rpl_dio_printopt(ndo, opt, length);
}
return;
@@ -786,21 +768,20 @@ static void
rpl_daoack_print(netdissect_options *ndo,
const u_char *bp, u_int length)
{
- const struct nd_rpl_daoack *daoack = (struct nd_rpl_daoack *)bp;
- char dagid_str[65];
+ 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;
- strcpy(dagid_str,"<elided>");
bp += ND_RPL_DAOACK_MIN_LEN;
length -= ND_RPL_DAOACK_MIN_LEN;
if(RPL_DAOACK_D(daoack->rpl_flags)) {
- ND_TCHECK2(daoack->rpl_dagid, 16);
+ ND_TCHECK2(daoack->rpl_dagid, DAGID_LEN);
if (length < DAGID_LEN)
goto tooshort;
- rpl_format_dagid(dagid_str, daoack->rpl_dagid);
+ dagid_str = ip6addr_string (ndo, daoack->rpl_dagid);
bp += DAGID_LEN;
length -= DAGID_LEN;
}
@@ -813,7 +794,7 @@ rpl_daoack_print(netdissect_options *ndo,
/* no officially defined options for DAOACK, but print any we find */
if(ndo->ndo_vflag > 1) {
- const struct rpl_dio_genoption *opt = (struct rpl_dio_genoption *)bp;
+ const struct rpl_dio_genoption *opt = (const struct rpl_dio_genoption *)bp;
rpl_dio_printopt(ndo, opt, length);
}
return;
@@ -897,9 +878,9 @@ 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 = ndo->ndo_snapend;
@@ -910,7 +891,7 @@ icmp6_print(netdissect_options *ndo,
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)
ND_PRINT((ndo,"[bad icmp6 cksum 0x%04x -> 0x%04x!] ",
udp_sum,
@@ -949,7 +930,7 @@ icmp6_print(netdissect_options *ndo,
ip6addr_string(ndo, &oip->ip6_src)));
break;
case ICMP6_DST_UNREACH_NOPORT:
- if ((ouh = get_upperlayer(ndo, (u_char *)oip, &prot))
+ if ((ouh = get_upperlayer(ndo, (const u_char *)oip, &prot))
== NULL)
goto trunc;
@@ -958,12 +939,12 @@ icmp6_print(netdissect_options *ndo,
case IPPROTO_TCP:
ND_PRINT((ndo,", %s tcp port %s",
ip6addr_string(ndo, &oip->ip6_dst),
- tcpport_string(dport)));
+ tcpport_string(ndo, dport)));
break;
case IPPROTO_UDP:
ND_PRINT((ndo,", %s udp port %s",
ip6addr_string(ndo, &oip->ip6_dst),
- udpport_string(dport)));
+ udpport_string(ndo, dport)));
break;
default:
ND_PRINT((ndo,", %s protocol %d port %d unreachable",
@@ -1048,9 +1029,9 @@ icmp6_print(netdissect_options *ndo,
case ND_ROUTER_ADVERT:
#define RTADVLEN 16
if (ndo->ndo_vflag) {
- struct nd_router_advert *p;
+ const struct nd_router_advert *p;
- p = (struct nd_router_advert *)dp;
+ 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",
@@ -1067,8 +1048,8 @@ icmp6_print(netdissect_options *ndo,
break;
case ND_NEIGHBOR_SOLICIT:
{
- struct nd_neighbor_solicit *p;
- p = (struct nd_neighbor_solicit *)dp;
+ 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) {
@@ -1080,9 +1061,9 @@ icmp6_print(netdissect_options *ndo,
break;
case ND_NEIGHBOR_ADVERT:
{
- struct nd_neighbor_advert *p;
+ const struct nd_neighbor_advert *p;
- p = (struct nd_neighbor_advert *)dp;
+ 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)));
@@ -1099,12 +1080,12 @@ icmp6_print(netdissect_options *ndo,
}
break;
case ND_REDIRECT:
-#define RDR(i) ((struct nd_redirect *)(i))
+#define RDR(i) ((const struct nd_redirect *)(i))
ND_TCHECK(RDR(dp)->nd_rd_dst);
- ND_PRINT((ndo,", %s", getname6(ndo, (const u_char *)&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",
- getname6(ndo, (const u_char*)&RDR(dp)->nd_rd_target)));
+ ip6addr_string(ndo, &RDR(dp)->nd_rd_target)));
#define REDIRECTLEN 40
if (ndo->ndo_vflag) {
icmp6_opt_print(ndo, (const u_char *)dp + REDIRECTLEN,
@@ -1133,14 +1114,14 @@ icmp6_print(netdissect_options *ndo,
break;
case ICMP6_HADISCOV_REPLY:
if (ndo->ndo_vflag) {
- struct in6_addr *in6;
- u_char *cp;
+ 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 = (u_char *)dp + length;
- in6 = (struct in6_addr *)(dp + 1);
- for (; (u_char *)in6 < cp; in6++) {
+ 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)));
}
@@ -1182,7 +1163,7 @@ static const struct udphdr *
get_upperlayer(netdissect_options *ndo, const u_char *bp, u_int *prot)
{
const u_char *ep;
- const struct ip6_hdr *ip6 = (struct ip6_hdr *)bp;
+ const struct ip6_hdr *ip6 = (const struct ip6_hdr *)bp;
const struct udphdr *uh;
const struct ip6_hbh *hbh;
const struct ip6_frag *fragh;
@@ -1205,7 +1186,7 @@ get_upperlayer(netdissect_options *ndo, const u_char *bp, u_int *prot)
switch(nh) {
case IPPROTO_UDP:
case IPPROTO_TCP:
- uh = (struct udphdr *)bp;
+ uh = (const struct udphdr *)bp;
if (ND_TTEST(uh->uh_dport)) {
*prot = nh;
return(uh);
@@ -1217,7 +1198,7 @@ get_upperlayer(netdissect_options *ndo, const u_char *bp, u_int *prot)
case IPPROTO_HOPOPTS:
case IPPROTO_DSTOPTS:
case IPPROTO_ROUTING:
- hbh = (struct ip6_hbh *)bp;
+ hbh = (const struct ip6_hbh *)bp;
if (!ND_TTEST(hbh->ip6h_len))
return(NULL);
nh = hbh->ip6h_nxt;
@@ -1225,7 +1206,7 @@ get_upperlayer(netdissect_options *ndo, const u_char *bp, u_int *prot)
break;
case IPPROTO_FRAGMENT: /* this should be odd, but try anyway */
- fragh = (struct ip6_frag *)bp;
+ fragh = (const struct ip6_frag *)bp;
if (!ND_TTEST(fragh->ip6f_offlg))
return(NULL);
/* fragments with non-zero offset are meaningless */
@@ -1236,7 +1217,7 @@ get_upperlayer(netdissect_options *ndo, const u_char *bp, u_int *prot)
break;
case IPPROTO_AH:
- ah = (struct ah *)bp;
+ ah = (const struct ah *)bp;
if (!ND_TTEST(ah->ah_len))
return(NULL);
nh = ah->ah_nxt;
@@ -1264,18 +1245,19 @@ icmp6_opt_print(netdissect_options *ndo, 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 = 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)
@@ -1301,7 +1283,7 @@ icmp6_opt_print(netdissect_options *ndo, const u_char *bp, int resid)
print_lladdr(ndo, cp + 2, l);
break;
case ND_OPT_PREFIX_INFORMATION:
- opp = (struct nd_opt_prefix_info *)op;
+ 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),
@@ -1316,14 +1298,14 @@ icmp6_opt_print(netdissect_options *ndo, const u_char *bp, int resid)
/* xxx */
break;
case ND_OPT_MTU:
- opm = (struct nd_opt_mtu *)op;
+ 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" : "" ));
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;
ND_PRINT((ndo," lifetime %us,",
EXTRACT_32BITS(&oprd->nd_opt_rdnss_lifetime)));
@@ -1334,7 +1316,7 @@ icmp6_opt_print(netdissect_options *ndo, const u_char *bp, int resid)
}
break;
case ND_OPT_DNSSL:
- opds = (struct nd_opt_dnssl *)op;
+ 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 */
@@ -1346,22 +1328,22 @@ icmp6_opt_print(netdissect_options *ndo, const u_char *bp, int resid)
}
break;
case ND_OPT_ADVINTERVAL:
- opa = (struct nd_opt_advinterval *)op;
+ 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;
+ 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;
+ 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;
@@ -1407,13 +1389,13 @@ icmp6_opt_print(netdissect_options *ndo, const u_char *bp, int resid)
static void
mld6_print(netdissect_options *ndo, const u_char *bp)
{
- const 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 = ndo->ndo_snapend;
- if ((u_char *)mp + sizeof(*mp) > ep)
+ if ((const u_char *)mp + sizeof(*mp) > ep)
return;
ND_PRINT((ndo,"max resp delay: %d ", EXTRACT_16BITS(&mp->mld6_maxdelay)));
@@ -1423,7 +1405,7 @@ mld6_print(netdissect_options *ndo, const u_char *bp)
static void
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;
@@ -1481,7 +1463,7 @@ trunc:
static void
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;
@@ -1591,8 +1573,8 @@ icmp6_nodeinfo_print(netdissect_options *ndo, u_int icmp6len, const u_char *bp,
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) {
@@ -1605,7 +1587,7 @@ icmp6_nodeinfo_print(netdissect_options *ndo, u_int icmp6len, const u_char *bp,
ND_PRINT((ndo," node information query"));
ND_TCHECK2(*dp, sizeof(*ni6));
- ni6 = (struct icmp6_nodeinfo *)dp;
+ ni6 = (const struct icmp6_nodeinfo *)dp;
ND_PRINT((ndo," (")); /*)*/
switch (EXTRACT_16BITS(&ni6->ni_qtype)) {
case NI_QTYPE_NOOP:
@@ -1669,7 +1651,7 @@ icmp6_nodeinfo_print(netdissect_options *ndo, u_int icmp6len, const u_char *bp,
break;
}
ND_PRINT((ndo,", subject=%s",
- getname6(ndo, (const u_char *)(ni6 + 1))));
+ ip6addr_string(ndo, ni6 + 1)));
break;
case ICMP6_NI_SUBJ_FQDN:
ND_PRINT((ndo,", subject=DNS name"));
@@ -1697,7 +1679,7 @@ icmp6_nodeinfo_print(netdissect_options *ndo, u_int icmp6len, const u_char *bp,
break;
}
ND_PRINT((ndo,", subject=%s",
- getname(ndo, (const u_char *)(ni6 + 1))));
+ ipaddr_string(ndo, ni6 + 1)));
break;
default:
ND_PRINT((ndo,", unknown subject"));
@@ -1716,7 +1698,7 @@ icmp6_nodeinfo_print(netdissect_options *ndo, u_int icmp6len, const u_char *bp,
needcomma = 0;
- ni6 = (struct icmp6_nodeinfo *)dp;
+ ni6 = (const struct icmp6_nodeinfo *)dp;
ND_PRINT((ndo," node information reply"));
ND_PRINT((ndo," (")); /*)*/
switch (ni6->ni_code) {
@@ -1784,7 +1766,7 @@ icmp6_nodeinfo_print(netdissect_options *ndo, u_int icmp6len, const u_char *bp,
} else
dnsname_print(ndo, cp, ep);
if ((EXTRACT_16BITS(&ni6->ni_flags) & 0x01) != 0)
- ND_PRINT((ndo," [TTL=%u]", *(uint32_t *)(ni6 + 1)));
+ ND_PRINT((ndo," [TTL=%u]", EXTRACT_32BITS(ni6 + 1)));
break;
case NI_QTYPE_NODEADDR:
if (needcomma)
@@ -1794,7 +1776,7 @@ icmp6_nodeinfo_print(netdissect_options *ndo, u_int icmp6len, const u_char *bp,
while (i < siz) {
if (i + sizeof(struct in6_addr) + sizeof(int32_t) > siz)
break;
- ND_PRINT((ndo," %s", getname6(ndo, bp + i)));
+ ND_PRINT((ndo," %s", ip6addr_string(ndo, bp + i)));
i += sizeof(struct in6_addr);
ND_PRINT((ndo,"(%d)", (int32_t)EXTRACT_32BITS(bp + i)));
i += sizeof(int32_t);
@@ -1833,14 +1815,14 @@ icmp6_rrenum_print(netdissect_options *ndo, const u_char *bp, const u_char *ep)
{
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);
ND_TCHECK(rr6->rr_reserved);
@@ -1881,7 +1863,7 @@ icmp6_rrenum_print(netdissect_options *ndo, const u_char *bp, const u_char *ep)
}
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);
ND_TCHECK(match->rpm_prefix);
@@ -1903,7 +1885,7 @@ icmp6_rrenum_print(netdissect_options *ndo, const u_char *bp, const u_char *ep)
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)))
+ if (addrtostr6(&match->rpm_prefix, hbuf, sizeof(hbuf)))
ND_PRINT((ndo,",%s/%u", hbuf, match->rpm_matchlen));
else
ND_PRINT((ndo,",?/%u", match->rpm_matchlen));
@@ -1915,7 +1897,7 @@ icmp6_rrenum_print(netdissect_options *ndo, const u_char *bp, const u_char *ep)
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);
ND_TCHECK(use->rpu_prefix);
@@ -1946,8 +1928,7 @@ icmp6_rrenum_print(netdissect_options *ndo, const u_char *bp, const u_char *ep)
ND_PRINT((ndo,"pltime=%u,",
EXTRACT_32BITS(&use->rpu_pltime)));
}
- if (inet_ntop(AF_INET6, &use->rpu_prefix, hbuf,
- sizeof(hbuf)))
+ if (addrtostr6(&use->rpu_prefix, hbuf, sizeof(hbuf)))
ND_PRINT((ndo,"%s/%u/%u", hbuf, use->rpu_uselen,
use->rpu_keeplen));
else
@@ -1964,8 +1945,6 @@ trunc:
ND_PRINT((ndo,"[|icmp6]"));
}
-#endif /* INET6 */
-
/*
* Local Variables:
* c-style: whitesmith
diff --git a/contrib/tcpdump/print-igmp.c b/contrib/tcpdump/print-igmp.c
index e4808a7..0bb7f97 100644
--- a/contrib/tcpdump/print-igmp.c
+++ b/contrib/tcpdump/print-igmp.c
@@ -19,16 +19,17 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#define NETDISSECT_REWORKED
+/* \summary: Internet Group Management Protocol (IGMP) printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.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"
#ifndef IN_CLASSD
#define IN_CLASSD(i) (((int32_t)(i) & 0xf0000000) == 0xe0000000)
@@ -204,7 +205,7 @@ 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;
@@ -226,7 +227,7 @@ print_igmpv3_query(netdissect_options *ndo,
if (mrt < 600) {
ND_PRINT((ndo, "%.1fs", mrt * 0.1));
} else {
- relts_print(ndo, mrt / 10);
+ unsigned_relts_print(ndo, mrt / 10);
}
ND_PRINT((ndo, "]"));
}
@@ -327,7 +328,7 @@ igmp_print(netdissect_options *ndo,
break;
}
- if (ndo->ndo_vflag && ND_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;
diff --git a/contrib/tcpdump/print-igrp.c b/contrib/tcpdump/print-igrp.c
index fbb3134..b6eaf31 100644
--- a/contrib/tcpdump/print-igrp.c
+++ b/contrib/tcpdump/print-igrp.c
@@ -21,15 +21,16 @@
* Initial contribution from Francis Dupont (francis.dupont@inria.fr)
*/
-#define NETDISSECT_REWORKED
+/* \summary: Interior Gateway Routing Protocol (IGRP) printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
-#include "extract.h" /* must come after interface.h */
+#include "netdissect.h"
+#include "extract.h"
/* Cisco IGRP definitions */
@@ -65,7 +66,7 @@ struct igrprte {
#define IGRP_RTE_SIZE 14 /* don't believe sizeof ! */
static void
-igrp_entry_print(netdissect_options *ndo, register struct igrprte *igr,
+igrp_entry_print(netdissect_options *ndo, register const struct igrprte *igr,
register int is_interior, register int is_exterior)
{
register u_int delay, bandwidth;
@@ -103,12 +104,12 @@ static const struct tok op2str[] = {
void
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);
+ hdr = (const struct igrphdr *)bp;
+ cp = (const u_char *)(hdr + 1);
ND_PRINT((ndo, "igrp:"));
/* Header */
@@ -130,15 +131,15 @@ igrp_print(netdissect_options *ndo, register const u_char *bp, u_int length)
while (length >= IGRP_RTE_SIZE) {
if (nint > 0) {
ND_TCHECK2(*cp, IGRP_RTE_SIZE);
- igrp_entry_print(ndo, (struct igrprte *)cp, 1, 0);
+ igrp_entry_print(ndo, (const struct igrprte *)cp, 1, 0);
--nint;
} else if (nsys > 0) {
ND_TCHECK2(*cp, IGRP_RTE_SIZE);
- igrp_entry_print(ndo, (struct igrprte *)cp, 0, 0);
+ igrp_entry_print(ndo, (const struct igrprte *)cp, 0, 0);
--nsys;
} else if (next > 0) {
ND_TCHECK2(*cp, IGRP_RTE_SIZE);
- igrp_entry_print(ndo, (struct igrprte *)cp, 0, 1);
+ igrp_entry_print(ndo, (const struct igrprte *)cp, 0, 1);
--next;
} else {
ND_PRINT((ndo, " [extra bytes %d]", length));
diff --git a/contrib/tcpdump/print-ip.c b/contrib/tcpdump/print-ip.c
index edf0076..6071bb2 100644
--- a/contrib/tcpdump/print-ip.c
+++ b/contrib/tcpdump/print-ip.c
@@ -17,22 +17,21 @@
* 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$
*/
-#define NETDISSECT_REWORKED
+/* \summary: IP printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.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 "ipproto.h"
@@ -125,7 +124,7 @@ ip_finddst(netdissect_options *ndo,
}
}
trunc:
- UNALIGNED_MEMCPY(&retval, &ip->ip_dst.s_addr, sizeof(uint32_t));
+ UNALIGNED_MEMCPY(&retval, &ip->ip_dst, sizeof(uint32_t));
return retval;
}
@@ -150,9 +149,9 @@ nextproto4_cksum(netdissect_options *ndo,
ph.len = htons((uint16_t)len);
ph.mbz = 0;
ph.proto = next_proto;
- UNALIGNED_MEMCPY(&ph.src, &ip->ip_src.s_addr, sizeof(uint32_t));
+ UNALIGNED_MEMCPY(&ph.src, &ip->ip_src, sizeof(uint32_t));
if (IP_HL(ip) == 5)
- UNALIGNED_MEMCPY(&ph.dst, &ip->ip_dst.s_addr, sizeof(uint32_t));
+ UNALIGNED_MEMCPY(&ph.dst, &ip->ip_dst, sizeof(uint32_t));
else
ph.dst = ip_finddst(ndo, ip);
@@ -326,12 +325,15 @@ 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(ndo, ipds->cp);
if (ipds->advance <= 0)
@@ -356,14 +358,14 @@ again:
case IPPROTO_IPCOMP:
{
- int enh;
- ipds->advance = ipcomp_print(ndo, 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:
@@ -457,9 +459,7 @@ again:
break;
case IPPROTO_PIM:
- vec[0].ptr = ipds->cp;
- vec[0].len = ipds->len;
- pim_print(ndo, ipds->cp, ipds->len, in_cksum(vec, 1));
+ pim_print(ndo, ipds->cp, ipds->len, (const u_char *)ipds->ip);
break;
case IPPROTO_VRRP:
@@ -536,13 +536,14 @@ ip_print(netdissect_options *ndo,
ipds->ip = (const struct ip *)bp;
ND_TCHECK(ipds->ip->ip_vhl);
- if (IP_V(ipds->ip) != 4) { /* print version if != 4 */
+ if (IP_V(ipds->ip) != 4) { /* print version and fail if != 4 */
if (IP_V(ipds->ip) == 6)
ND_PRINT((ndo, "IP6, wrong link-layer encapsulation "));
else
ND_PRINT((ndo, "IP%u ", IP_V(ipds->ip)));
+ return;
}
- else if (!ndo->ndo_eflag)
+ if (!ndo->ndo_eflag)
ND_PRINT((ndo, "IP "));
ND_TCHECK(*ipds->ip);
@@ -590,17 +591,22 @@ ip_print(netdissect_options *ndo,
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:
- ND_PRINT((ndo, ",ECT(1)"));
- break;
- case 2:
- ND_PRINT((ndo, ",ECT(0)"));
- break;
- case 3:
- ND_PRINT((ndo, ",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)
@@ -623,12 +629,12 @@ ip_print(netdissect_options *ndo,
if ((hlen - sizeof(struct ip)) > 0) {
ND_PRINT((ndo, ", options ("));
- ip_optprint(ndo, (u_char *)(ipds->ip + 1), hlen - sizeof(struct ip));
+ ip_optprint(ndo, (const u_char *)(ipds->ip + 1), hlen - sizeof(struct ip));
ND_PRINT((ndo, ")"));
}
- if (!ndo->ndo_Kflag && (u_char *)ipds->ip + hlen <= ndo->ndo_snapend) {
- vec[0].ptr = (const uint8_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) {
@@ -657,22 +663,24 @@ ip_print(netdissect_options *ndo,
}
ip_print_demux(ndo, ipds);
} else {
- /* Ultra quiet now means that all this stuff should be suppressed */
- if (ndo->ndo_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) {
- 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)
- ND_PRINT((ndo, " %s", proto->p_name));
- else
- ND_PRINT((ndo, " ip-proto-%d", ipds->ip->ip_p));
- }
+ /*
+ * 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)
+ ND_PRINT((ndo, " %s", proto->p_name));
+ else
+ ND_PRINT((ndo, " ip-proto-%d", ipds->ip->ip_p));
}
return;
@@ -684,24 +692,28 @@ trunc:
void
ipN_print(netdissect_options *ndo, register const u_char *bp, register u_int length)
{
- struct ip hdr;
-
- if (length < 4) {
+ if (length < 1) {
ND_PRINT((ndo, "truncated-ip %d", length));
return;
}
- memcpy (&hdr, bp, 4);
- switch (IP_V(&hdr)) {
- case 4:
+
+ ND_TCHECK(*bp);
+ switch (*bp & 0xF0) {
+ case 0x40:
ip_print (ndo, bp, length);
- return;
- case 6:
+ break;
+ case 0x60:
ip6_print (ndo, bp, length);
- return;
+ break;
default:
- ND_PRINT((ndo, "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;
}
/*
diff --git a/contrib/tcpdump/print-ip6.c b/contrib/tcpdump/print-ip6.c
index 5318389..9f590f2 100644
--- a/contrib/tcpdump/print-ip6.c
+++ b/contrib/tcpdump/print-ip6.c
@@ -17,33 +17,151 @@
* 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$
*/
-#define NETDISSECT_REWORKED
+/* \summary: IPv6 printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <string.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "extract.h"
-#ifdef INET6
-
#include "ip6.h"
#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 uint8_t *data,
+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 {
@@ -58,7 +176,26 @@ nextproto6_cksum(const struct ip6_hdr *ip6, const uint8_t *data,
/* pseudo-header */
memset(&ph, 0, sizeof(ph));
UNALIGNED_MEMCPY(&ph.ph_src, &ip6->ip6_src, sizeof (struct in6_addr));
- UNALIGNED_MEMCPY(&ph.ph_dst, &ip6->ip6_dst, 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;
@@ -156,15 +293,19 @@ ip6_print(netdissect_options *ndo, const u_char *bp, u_int length)
switch (nh) {
case IPPROTO_HOPOPTS:
advance = hbhopt_print(ndo, cp);
+ if (advance < 0)
+ return;
nh = *cp;
break;
case IPPROTO_DSTOPTS:
advance = dstopt_print(ndo, cp);
+ if (advance < 0)
+ return;
nh = *cp;
break;
case IPPROTO_FRAGMENT:
advance = frag6_print(ndo, cp, (const u_char *)ip6);
- if (ndo->ndo_snapend <= cp + advance)
+ if (advance < 0 || ndo->ndo_snapend <= cp + advance)
return;
nh = *cp;
fragmented = 1;
@@ -173,9 +314,7 @@ 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
@@ -218,15 +357,19 @@ ip6_print(netdissect_options *ndo, const u_char *bp, u_int length)
}
case IPPROTO_IPCOMP:
{
- int enh;
- advance = ipcomp_print(ndo, 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(ndo, cp, len, nextproto6_cksum(ip6, cp, len, len,
- IPPROTO_PIM));
+ pim_print(ndo, cp, len, (const u_char *)ip6);
return;
case IPPROTO_OSPF:
@@ -267,13 +410,3 @@ ip6_print(netdissect_options *ndo, const u_char *bp, u_int length)
trunc:
ND_PRINT((ndo, "[|ip6]"));
}
-
-#else /* INET6 */
-
-void
-ip6_print(netdissect_options *ndo, const u_char *bp _U_, u_int length)
-{
- ND_PRINT((ndo, "IP6, length: %u (printing not supported)", length));
-}
-
-#endif /* INET6 */
diff --git a/contrib/tcpdump/print-ip6opts.c b/contrib/tcpdump/print-ip6opts.c
index 14ad42c..4c16d80 100644
--- a/contrib/tcpdump/print-ip6opts.c
+++ b/contrib/tcpdump/print-ip6opts.c
@@ -27,17 +27,17 @@
* SUCH DAMAGE.
*/
-#define NETDISSECT_REWORKED
+/* \summary: IPv6 header option printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#ifdef INET6
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include "ip6.h"
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "extract.h"
@@ -173,7 +173,7 @@ trunc:
int
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;
ND_TCHECK(dp->ip6h_len);
@@ -193,7 +193,7 @@ hbhopt_print(netdissect_options *ndo, register const u_char *bp)
int
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;
ND_TCHECK(dp->ip6d_len);
@@ -211,4 +211,3 @@ dstopt_print(netdissect_options *ndo, register const u_char *bp)
ND_PRINT((ndo, "[|DSTOPT]"));
return(-1);
}
-#endif /* INET6 */
diff --git a/contrib/tcpdump/print-ipcomp.c b/contrib/tcpdump/print-ipcomp.c
index 1ba687e..291caa9 100644
--- a/contrib/tcpdump/print-ipcomp.c
+++ b/contrib/tcpdump/print-ipcomp.c
@@ -19,12 +19,13 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#define NETDISSECT_REWORKED
+/* \summary: IP Payload Compression Protocol (IPComp) printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
struct ipcomp {
uint8_t comp_nxt; /* Next Header */
@@ -32,52 +33,37 @@ struct ipcomp {
uint16_t comp_cpi; /* Compression parameter index */
};
-#if defined(HAVE_LIBZ) && defined(HAVE_ZLIB_H)
-#include <zlib.h>
-#endif
-
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
-int
-ipcomp_print(netdissect_options *ndo, 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;
uint16_t cpi;
-#if defined(HAVE_LIBZ) && defined(HAVE_ZLIB_H)
- int advance;
-#endif
- 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 = ndo->ndo_snapend;
-
- if ((u_char *)(ipcomp + 1) >= ep - sizeof(struct ipcomp)) {
- ND_PRINT((ndo, "[|IPCOMP]"));
- goto fail;
- }
ND_PRINT((ndo, "IPComp(cpi=0x%04x)", cpi));
-#if defined(HAVE_LIBZ) && defined(HAVE_ZLIB_H)
- if (1)
- goto fail;
-
/*
- * 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;
- ND_PRINT((ndo, ": "));
- return advance;
-
-#endif
-fail:
- return -1;
+trunc:
+ ND_PRINT((ndo, "[|IPCOMP]"));
+ return;
}
diff --git a/contrib/tcpdump/print-ipfc.c b/contrib/tcpdump/print-ipfc.c
index 295ac0f..b8a08e9 100644
--- a/contrib/tcpdump/print-ipfc.c
+++ b/contrib/tcpdump/print-ipfc.c
@@ -19,24 +19,23 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#define NETDISSECT_REWORKED
+/* \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 <string.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "ether.h"
-/*
- * RFC 2625 IP-over-Fibre Channel.
- */
-
struct ipfc_header {
u_char ipfc_dhost[8];
u_char ipfc_shost[8];
@@ -72,21 +71,34 @@ ipfc_hdr_print(netdissect_options *ndo,
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.
*/
- ND_PRINT((ndo, "%s %s %d: ", srcname, dstname, length));
+ ND_PRINT((ndo, "%s > %s, length %u: ", srcname, dstname, length));
}
-static void
+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) {
ND_PRINT((ndo, "[|ipfc]"));
- return;
+ return (caplen);
}
/*
* Get the network addresses into a canonical form
@@ -96,28 +108,28 @@ ipfc_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen)
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;
p += IPFC_HDRLEN;
caplen -= IPFC_HDRLEN;
/* Try to print the LLC-layer header & higher layers */
- if (llc_print(ndo, 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 (!ndo->ndo_eflag)
- ipfc_hdr_print(ndo, ipfcp, length + IPFC_HDRLEN,
- ESRC(&ehdr), EDST(&ehdr));
- if (extracted_ethertype) {
- ND_PRINT((ndo, "(LLC %s) ",
- etherproto_string(htons(extracted_ethertype))));
- }
if (!ndo->ndo_suppress_default_print)
ND_DEFAULTPRINT(p, caplen);
+ llc_hdrlen = -llc_hdrlen;
}
+ return (IPFC_HDRLEN + llc_hdrlen);
}
/*
@@ -129,7 +141,5 @@ ipfc_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen)
u_int
ipfc_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, register const u_char *p)
{
- ipfc_print(ndo, p, h->len, h->caplen);
-
- return (IPFC_HDRLEN);
+ return (ipfc_print(ndo, p, h->len, h->caplen));
}
diff --git a/contrib/tcpdump/print-ipnet.c b/contrib/tcpdump/print-ipnet.c
index c4ff16a..f71c145 100644
--- a/contrib/tcpdump/print-ipnet.c
+++ b/contrib/tcpdump/print-ipnet.c
@@ -1,11 +1,12 @@
-#define NETDISSECT_REWORKED
+/* \summary: Solaris DLT_IPNET printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
typedef struct ipnet_hdr {
uint8_t iph_version;
@@ -55,7 +56,7 @@ ipnet_hdr_print(netdissect_options *ndo, const u_char *bp, u_int length)
static void
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]"));
@@ -67,7 +68,7 @@ ipnet_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen
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) {
@@ -82,7 +83,7 @@ ipnet_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen
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)
diff --git a/contrib/tcpdump/print-ipx.c b/contrib/tcpdump/print-ipx.c
index f076d02..d807a66 100644
--- a/contrib/tcpdump/print-ipx.c
+++ b/contrib/tcpdump/print-ipx.c
@@ -18,22 +18,20 @@
* 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$
*/
-#define NETDISSECT_REWORKED
+/* \summary: Novell IPX 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"
@@ -91,7 +89,7 @@ ipx_print(netdissect_options *ndo, const u_char *p, u_int length)
ND_TCHECK(ipx->length);
length = EXTRACT_16BITS(&ipx->length);
- ipx_decode(ndo, ipx, (u_char *)ipx + ipxSize, length - ipxSize);
+ ipx_decode(ndo, ipx, p + ipxSize, length - ipxSize);
return;
trunc:
ND_PRINT((ndo, "[|ipx %d]", length));
@@ -119,14 +117,14 @@ ipx_decode(netdissect_options *ndo, const struct ipxHdr *ipx, const u_char *data
ND_PRINT((ndo, "ipx-ncp %d", length));
break;
case IPX_SKT_SAP:
- ipx_sap_print(ndo, (u_short *)datap, length);
+ ipx_sap_print(ndo, (const u_short *)datap, length);
break;
case IPX_SKT_RIP:
- ipx_rip_print(ndo, (u_short *)datap, length);
+ ipx_rip_print(ndo, (const u_short *)datap, length);
break;
case IPX_SKT_NETBIOS:
ND_PRINT((ndo, "ipx-netbios %d", length));
-#ifdef TCPDUMP_DO_SMB
+#ifdef ENABLE_SMB
ipx_netbios_print(ndo, datap, length);
#endif
break;
@@ -135,7 +133,7 @@ ipx_decode(netdissect_options *ndo, const struct ipxHdr *ipx, const u_char *data
break;
case IPX_SKT_NWLINK_DGM:
ND_PRINT((ndo, "ipx-nwlink-dgm %d", length));
-#ifdef TCPDUMP_DO_SMB
+#ifdef ENABLE_SMB
ipx_netbios_print(ndo, datap, length);
#endif
break;
@@ -167,7 +165,7 @@ ipx_sap_print(netdissect_options *ndo, const u_short *ipx, u_int length)
ND_PRINT((ndo, "ipx-sap-nearest-req"));
ND_TCHECK(ipx[0]);
- ND_PRINT((ndo, " %s", ipxsap_string(htons(EXTRACT_16BITS(&ipx[0])))));
+ ND_PRINT((ndo, " %s", ipxsap_string(ndo, htons(EXTRACT_16BITS(&ipx[0])))));
break;
case 2:
@@ -179,14 +177,14 @@ ipx_sap_print(netdissect_options *ndo, const u_short *ipx, u_int length)
for (i = 0; i < 8 && length > 0; i++) {
ND_TCHECK(ipx[0]);
- ND_PRINT((ndo, " %s '", ipxsap_string(htons(EXTRACT_16BITS(&ipx[0])))));
- if (fn_printzp(ndo, (u_char *)&ipx[1], 48, ndo->ndo_snapend)) {
+ 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;
}
ND_TCHECK2(ipx[25], 10);
ND_PRINT((ndo, "' addr %s",
- ipxaddr_string(EXTRACT_32BITS(&ipx[25]), (u_char *)&ipx[27])));
+ ipxaddr_string(EXTRACT_32BITS(&ipx[25]), (const u_char *)&ipx[27])));
ipx += 32;
length -= 64;
}
diff --git a/contrib/tcpdump/print-isakmp.c b/contrib/tcpdump/print-isakmp.c
index bef0b45..3dfa171 100644
--- a/contrib/tcpdump/print-isakmp.c
+++ b/contrib/tcpdump/print-isakmp.c
@@ -28,7 +28,8 @@
*
*/
-#define NETDISSECT_REWORKED
+/* \summary: Internet Security Association and Key Management Protocol (ISAKMP) printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -40,18 +41,16 @@
#undef HAVE_LIBCRYPTO
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.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
/* refer to RFC 2408 */
@@ -355,7 +354,7 @@ enum ikev2_t_type {
IV2_T_PRF = 2,
IV2_T_INTEG= 3,
IV2_T_DH = 4,
- IV2_T_ESN = 5,
+ IV2_T_ESN = 5
};
/* 3.4. Key Exchange Payload */
@@ -375,7 +374,7 @@ enum ikev2_id_type {
ID_IPV6_ADDR=5,
ID_DER_ASN1_DN=9,
ID_DER_ASN1_GN=10,
- ID_KEY_ID=11,
+ ID_KEY_ID=11
};
struct ikev2_id {
struct isakmp_gen h;
@@ -439,7 +438,7 @@ struct ikev2_auth {
enum ikev2_auth_type {
IV2_RSA_SIG = 1,
IV2_SHARED = 2,
- IV2_DSS_SIG = 3,
+ IV2_DSS_SIG = 3
};
/* refer to RFC 2409 */
@@ -645,14 +644,12 @@ ikev1_print(netdissect_options *ndo,
const u_char *bp2, struct isakmp *base);
#define MAXINITIATORS 20
-int ninitiator = 0;
+static int ninitiator = 0;
union inaddr_u {
struct in_addr in4;
-#ifdef INET6
struct in6_addr in6;
-#endif
};
-struct {
+static struct {
cookie_t initiator;
u_int version;
union inaddr_u iaddr;
@@ -742,7 +739,7 @@ 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; \
}
@@ -753,7 +750,7 @@ static const char *etypestr[] = {
? npfunc[(x)] : NULL)
static int
-iszero(u_char *p, size_t l)
+iszero(const u_char *p, size_t l)
{
while (l--) {
if (*p++)
@@ -781,10 +778,8 @@ static void
cookie_record(cookie_t *in, const u_char *bp2)
{
int i;
- struct ip *ip;
-#ifdef INET6
- struct ip6_hdr *ip6;
-#endif
+ const struct ip *ip;
+ const struct ip6_hdr *ip6;
i = cookie_find(in);
if (0 <= i) {
@@ -792,21 +787,19 @@ 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:
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:
- ip6 = (struct ip6_hdr *)bp2;
+ 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;
}
@@ -819,12 +812,10 @@ cookie_record(cookie_t *in, const u_char *bp2)
static int
cookie_sidecheck(int i, const u_char *bp2, int initiator)
{
- struct ip *ip;
-#ifdef INET6
- struct ip6_hdr *ip6;
-#endif
+ const struct ip *ip;
+ const struct ip6_hdr *ip6;
- ip = (struct ip *)bp2;
+ ip = (const struct ip *)bp2;
switch (IP_V(ip)) {
case 4:
if (cookiecache[i].version != 4)
@@ -837,11 +828,10 @@ cookie_sidecheck(int i, const u_char *bp2, int initiator)
return 1;
}
break;
-#ifdef INET6
case 6:
if (cookiecache[i].version != 6)
return 0;
- ip6 = (struct ip6_hdr *)bp2;
+ 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;
@@ -850,7 +840,6 @@ cookie_sidecheck(int i, const u_char *bp2, int initiator)
return 1;
}
break;
-#endif /* INET6 */
default:
break;
}
@@ -859,18 +848,18 @@ cookie_sidecheck(int i, const u_char *bp2, int initiator)
}
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);
@@ -902,10 +891,10 @@ static int ike_show_somedata(netdissect_options *ndo,
}
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;
@@ -949,10 +938,10 @@ ikev1_attrmap_print(netdissect_options *ndo,
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)&p[2], 2);
+ rawprint(ndo, (const uint8_t *)&p[2], 2);
} else {
ND_PRINT((ndo,"len=%d value=", EXTRACT_16BITS(&p[2])));
- rawprint(ndo, (caddr_t)&p[4], EXTRACT_16BITS(&p[2]));
+ rawprint(ndo, (const uint8_t *)&p[4], EXTRACT_16BITS(&p[2]));
}
ND_PRINT((ndo,")"));
return p + totlen;
@@ -979,10 +968,10 @@ ikev1_attr_print(netdissect_options *ndo, const u_char *p, const u_char *ep)
if (p[0] & 0x80) {
ND_PRINT((ndo,"value="));
t = p[2];
- rawprint(ndo, (caddr_t)&p[2], 2);
+ rawprint(ndo, (const uint8_t *)&p[2], 2);
} else {
ND_PRINT((ndo,"len=%d value=", EXTRACT_16BITS(&p[2])));
- rawprint(ndo, (caddr_t)&p[4], EXTRACT_16BITS(&p[2]));
+ rawprint(ndo, (const uint8_t *)&p[4], EXTRACT_16BITS(&p[2]));
}
ND_PRINT((ndo,")"));
return p + totlen;
@@ -1003,7 +992,7 @@ ikev1_sa_print(netdissect_options *ndo, u_char tpay _U_,
ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_SA)));
- p = (struct ikev1_pl_sa *)ext;
+ p = (const struct ikev1_pl_sa *)ext;
ND_TCHECK(*p);
UNALIGNED_MEMCPY(&sa, ext, sizeof(sa));
doi = ntohl(sa.doi);
@@ -1011,7 +1000,7 @@ ikev1_sa_print(netdissect_options *ndo, u_char tpay _U_,
if (doi != 1) {
ND_PRINT((ndo," doi=%d", doi));
ND_PRINT((ndo," situation=%u", (uint32_t)ntohl(sa.sit)));
- return (u_char *)(p + 1);
+ return (const u_char *)(p + 1);
}
ND_PRINT((ndo," doi=ipsec"));
@@ -1028,7 +1017,7 @@ 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));
UNALIGNED_MEMCPY(&ident, ext + 1, sizeof(ident));
@@ -1036,7 +1025,7 @@ ikev1_sa_print(netdissect_options *ndo, u_char tpay _U_,
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,
@@ -1060,18 +1049,18 @@ 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);
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,
@@ -1227,7 +1216,7 @@ 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);
UNALIGNED_MEMCPY(&t, ext, sizeof(t));
@@ -1263,8 +1252,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,
@@ -1295,10 +1284,10 @@ ikev1_ke_print(netdissect_options *ndo, u_char tpay _U_,
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;
@@ -1326,11 +1315,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);
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;
@@ -1355,27 +1344,27 @@ 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);
- UNALIGNED_MEMCPY(&id, ext, sizeof(id));
- ND_PRINT((ndo," idtype=%s", STR_OR_ID(id.type, ipsecidtypestr)));
+ 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 = id.proto_id ? getprotobynumber(id.proto_id) : NULL;
+ 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", id.proto_id));
- ND_PRINT((ndo," port=%d", ntohs(id.port)));
+ 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));
@@ -1407,7 +1396,6 @@ ikev1_id_print(netdissect_options *ndo, u_char tpay _U_,
len = 0;
break;
}
-#ifdef INET6
case IPSECDOI_ID_IPV6_ADDR:
if (len < 16)
ND_PRINT((ndo," len=%d [bad: < 16]", len));
@@ -1421,7 +1409,7 @@ ikev1_id_print(netdissect_options *ndo, u_char tpay _U_,
if (len < 20)
ND_PRINT((ndo," len=%d [bad: < 20]", len));
else {
- mask = (u_char *)(data + sizeof(struct in6_addr));
+ mask = (const u_char *)(data + sizeof(struct in6_addr));
/*XXX*/
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),
@@ -1433,7 +1421,6 @@ ikev1_id_print(netdissect_options *ndo, u_char tpay _U_,
len = 0;
break;
}
-#endif /*INET6*/
case IPSECDOI_ID_IPV4_ADDR_RANGE:
if (len < 8)
ND_PRINT((ndo," len=%d [bad: < 8]", len));
@@ -1444,7 +1431,6 @@ ikev1_id_print(netdissect_options *ndo, u_char tpay _U_,
}
len = 0;
break;
-#ifdef INET6
case IPSECDOI_ID_IPV6_ADDR_RANGE:
if (len < 32)
ND_PRINT((ndo," len=%d [bad: < 32]", len));
@@ -1455,7 +1441,6 @@ ikev1_id_print(netdissect_options *ndo, u_char tpay _U_,
}
len = 0;
break;
-#endif /*INET6*/
case IPSECDOI_ID_DER_ASN1_DN:
case IPSECDOI_ID_DER_ASN1_GN:
case IPSECDOI_ID_KEY_ID:
@@ -1468,11 +1453,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;
@@ -1480,7 +1465,7 @@ 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 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_)
@@ -1495,17 +1480,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);
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;
@@ -1513,7 +1498,7 @@ 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 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_)
{
@@ -1527,17 +1512,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);
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;
@@ -1558,10 +1543,10 @@ ikev1_hash_print(netdissect_options *ndo, u_char tpay _U_,
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;
@@ -1582,10 +1567,10 @@ ikev1_sig_print(netdissect_options *ndo, u_char tpay _U_,
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;
@@ -1595,7 +1580,7 @@ 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_,
+ const u_char *ep,
uint32_t phase _U_, uint32_t doi _U_,
uint32_t proto _U_, int depth _U_)
{
@@ -1608,14 +1593,14 @@ ikev1_nonce_print(netdissect_options *ndo, u_char tpay _U_,
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;
@@ -1627,9 +1612,10 @@ ikev1_n_print(netdissect_options *ndo, u_char tpay _U_,
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;
+ const u_char *ep2;
uint32_t doi;
uint32_t proto;
static const char *notify_error_str[] = {
@@ -1680,7 +1666,7 @@ 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);
UNALIGNED_MEMCPY(&n, ext, sizeof(n));
doi = ntohl(n.doi);
@@ -1698,10 +1684,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"));
@@ -1718,12 +1704,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=("));
@@ -1744,7 +1730,7 @@ ikev1_n_print(netdissect_options *ndo, u_char tpay _U_,
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;
@@ -1756,7 +1742,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;
@@ -1777,7 +1763,7 @@ ikev1_d_print(netdissect_options *ndo, u_char tpay _U_,
ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_D)));
- p = (struct ikev1_pl_d *)ext;
+ p = (const struct ikev1_pl_d *)ext;
ND_TCHECK(*p);
UNALIGNED_MEMCPY(&d, ext, sizeof(d));
doi = ntohl(d.doi);
@@ -1792,11 +1778,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 = (uint8_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;
}
@@ -1822,10 +1808,10 @@ ikev1_vid_print(netdissect_options *ndo, u_char tpay _U_,
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;
@@ -1856,20 +1842,19 @@ ikev2_gen_print(netdissect_options *ndo, u_char tpay,
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, uint32_t phase _U_, uint32_t doi _U_,
- uint32_t proto _U_, int depth _U_)
+ const u_char *ep)
{
const struct ikev2_t *p;
struct ikev2_t t;
@@ -1880,7 +1865,7 @@ ikev2_t_print(netdissect_options *ndo, u_char tpay _U_, int pcount,
size_t nmap;
const u_char *ep2;
- p = (struct ikev2_t *)ext;
+ p = (const struct ikev2_t *)ext;
ND_TCHECK(*p);
UNALIGNED_MEMCPY(&t, ext, sizeof(t));
ikev2_pay_print(ndo, NPSTR(ISAKMP_NPTYPE_T), t.h.critical);
@@ -1919,15 +1904,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,
@@ -1945,34 +1930,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, uint32_t phase, uint32_t doi0,
- uint32_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);
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)));
@@ -1982,26 +2030,86 @@ trunc:
static const u_char *
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_int osa_length, const u_char *ep,
uint32_t phase _U_, uint32_t doi _U_,
- uint32_t proto _U_, int depth _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);
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;
@@ -2015,9 +2123,9 @@ ikev2_ke_print(netdissect_options *ndo, u_char tpay,
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);
UNALIGNED_MEMCPY(&ke, ext, sizeof(ke));
ikev2_pay_print(ndo, NPSTR(tpay), ke.h.critical);
@@ -2027,10 +2135,10 @@ ikev2_ke_print(netdissect_options *ndo, u_char tpay,
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;
@@ -2046,7 +2154,7 @@ ikev2_ID_print(netdissect_options *ndo, u_char tpay,
struct ikev2_id id;
int id_len, idtype_len, i;
unsigned int dumpascii, dumphex;
- unsigned char *typedata;
+ const unsigned char *typedata;
ND_TCHECK(*ext);
UNALIGNED_MEMCPY(&id, ext, sizeof(id));
@@ -2057,14 +2165,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:
@@ -2108,11 +2216,11 @@ 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;
@@ -2141,14 +2249,14 @@ ikev2_cr_print(netdissect_options *ndo, u_char tpay,
static const u_char *
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_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);
@@ -2161,14 +2269,14 @@ ikev2_auth_print(netdissect_options *ndo, u_char tpay,
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;
@@ -2177,7 +2285,7 @@ trunc:
static const u_char *
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_int item_len _U_, const u_char *ep,
uint32_t phase _U_, uint32_t doi _U_,
uint32_t proto _U_, int depth _U_)
{
@@ -2190,14 +2298,14 @@ ikev2_nonce_print(netdissect_options *ndo, u_char tpay,
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;
@@ -2207,17 +2315,18 @@ trunc:
static const u_char *
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_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 showspi, showdata, showsomedata;
const char *notify_name;
uint32_t type;
- p = (struct ikev2_n *)ext;
+ p = (const struct ikev2_n *)ext;
ND_TCHECK(*p);
UNALIGNED_MEMCPY(&n, ext, sizeof(n));
ikev2_pay_print(ndo, NPSTR(ISAKMP_NPTYPE_N), n.h.critical);
@@ -2384,11 +2493,11 @@ ikev2_n_print(netdissect_options *ndo, u_char tpay _U_,
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;
+ cp = (const u_char *)(p + 1) + n.spi_size;
if(3 < ndo->ndo_vflag) {
showdata = 1;
@@ -2396,7 +2505,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,")"));
@@ -2405,7 +2514,7 @@ ikev2_n_print(netdissect_options *ndo, u_char tpay _U_,
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;
@@ -2446,10 +2555,10 @@ ikev2_vid_print(netdissect_options *ndo, u_char tpay,
}
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;
@@ -2492,7 +2601,7 @@ ikev2_e_print(netdissect_options *ndo,
int depth)
{
struct isakmp_gen e;
- u_char *dat;
+ const u_char *dat;
volatile int dlen;
ND_TCHECK(*ext);
@@ -2504,11 +2613,11 @@ 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
@@ -2566,7 +2675,7 @@ ike_sub0_print(netdissect_options *ndo,
struct isakmp_gen e;
u_int item_len;
- cp = (u_char *)ext;
+ cp = (const u_char *)ext;
ND_TCHECK(*ext);
UNALIGNED_MEMCPY(&e, ext, sizeof(e));
@@ -2630,7 +2739,7 @@ ikev1_sub_print(netdissect_options *ndo,
}
np = e.np;
- ext = (struct isakmp_gen *)cp;
+ ext = (const struct isakmp_gen *)cp;
}
return cp;
trunc:
@@ -2668,7 +2777,7 @@ ikev1_print(netdissect_options *ndo,
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)
@@ -2707,7 +2816,7 @@ ikev1_print(netdissect_options *ndo,
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);
}
@@ -2722,7 +2831,7 @@ done:
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,
uint32_t phase, uint32_t doi, uint32_t proto, int depth)
{
@@ -2730,7 +2839,7 @@ ikev2_sub0_print(netdissect_options *ndo, struct isakmp *base,
struct isakmp_gen e;
u_int item_len;
- cp = (u_char *)ext;
+ cp = (const u_char *)ext;
ND_TCHECK(*ext);
UNALIGNED_MEMCPY(&e, ext, sizeof(e));
@@ -2744,13 +2853,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)) {
@@ -2758,7 +2861,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)));
@@ -2779,13 +2882,10 @@ ikev2_sub_print(netdissect_options *ndo,
{
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);
UNALIGNED_MEMCPY(&e, ext, sizeof(e));
@@ -2797,7 +2897,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--;
@@ -2808,7 +2908,7 @@ ikev2_sub_print(netdissect_options *ndo,
}
np = e.np;
- ext = (struct isakmp_gen *)cp;
+ ext = (const struct isakmp_gen *)cp;
}
return cp;
trunc:
@@ -2861,7 +2961,7 @@ ikev2_print(netdissect_options *ndo,
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);
}
@@ -2895,7 +2995,7 @@ 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;
}
@@ -2914,14 +3014,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,":"));
diff --git a/contrib/tcpdump/print-isoclns.c b/contrib/tcpdump/print-isoclns.c
index c3e7e87..d08085f 100644
--- a/contrib/tcpdump/print-isoclns.c
+++ b/contrib/tcpdump/print-isoclns.c
@@ -22,20 +22,19 @@
*
* Extensively modified by Hannes Gredler (hannes@juniper.net) for more
* complete IS-IS & CLNP support.
- *
- * $FreeBSD$
*/
-#define NETDISSECT_REWORKED
+/* \summary: ISO CLNS, ESIS, and ISIS printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <string.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "ether.h"
#include "nlpid.h"
@@ -44,6 +43,8 @@
#include "oui.h"
#include "signature.h"
+static const char tstr[] = " [|isis]";
+
/*
* IS-IS is defined in ISO 10589. Look there for protocol definitions.
*/
@@ -105,6 +106,7 @@ static const 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 */
@@ -154,6 +156,7 @@ static const 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"},
@@ -561,8 +564,8 @@ struct isis_tlv_ptp_adj {
uint8_t neighbor_extd_local_circuit_id[4];
};
-static void osi_print_cksum(netdissect_options *, const uint8_t *pptr, uint16_t checksum,
- u_int checksum_offset, u_int length);
+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);
@@ -666,8 +669,9 @@ 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(netdissect_options *ndo,
- const uint8_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 ? */
ND_PRINT((ndo, "|OSI"));
@@ -787,6 +791,18 @@ clnp_print(netdissect_options *ndo,
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);
+ }
+
/* FIXME further header sanity checking */
clnp_pdu_type = clnp_header->type & CLNP_PDU_TYPE_MASK;
@@ -794,22 +810,46 @@ clnp_print(netdissect_options *ndo,
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);
+ 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(source_address, source_address_length),
- isonsap_string(dest_address, dest_address_length),
+ 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));
return (1);
@@ -825,19 +865,24 @@ clnp_print(netdissect_options *ndo,
EXTRACT_16BITS(clnp_header->segment_length),
EXTRACT_16BITS(clnp_header->cksum)));
- osi_print_cksum(ndo, 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;
ND_PRINT((ndo, "\n\tFlags [%s]",
bittok2str(clnp_flag_values, "none", clnp_flags)));
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;
ND_TCHECK(*clnp_segment_header);
ND_PRINT((ndo, "\n\tData Unit ID: 0x%04x, Segment Offset: %u, Total PDU Length: %u",
@@ -853,19 +898,19 @@ clnp_print(netdissect_options *ndo,
u_int op, opli;
const uint8_t *tptr;
- ND_TCHECK2(*pptr, 2);
if (li < 2) {
ND_PRINT((ndo, ", bad opts/li"));
return (0);
}
+ ND_TCHECK2(*pptr, 2);
op = *pptr++;
opli = *pptr++;
li -= 2;
- ND_TCHECK2(*pptr, opli);
if (opli > li) {
ND_PRINT((ndo, ", opt (%d) too long", op));
return (0);
}
+ ND_TCHECK2(*pptr, opli);
li -= opli;
tptr = pptr;
tlen = opli;
@@ -875,11 +920,23 @@ clnp_print(netdissect_options *ndo,
op,
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:
+ 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)));
@@ -906,17 +963,25 @@ clnp_print(netdissect_options *ndo,
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:
+ if (tlen < 1) {
+ ND_PRINT((ndo, ", bad opt len"));
+ return (0);
+ }
ND_PRINT((ndo, "0x%1x", *tptr&0x0f));
break;
case CLNP_OPTION_QOS_MAINTENANCE:
+ 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)));
@@ -928,12 +993,20 @@ clnp_print(netdissect_options *ndo,
break;
case CLNP_OPTION_SECURITY:
+ 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)));
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;
ND_PRINT((ndo, "\n\t Class: %s Error (0x%01x), %s (0x%01x)",
@@ -1051,12 +1124,12 @@ esis_print(netdissect_options *ndo,
}
if (li > length) {
- ND_PRINT((ndo, " 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) {
- ND_PRINT((ndo, " length indicator < min PDU size %d:", li));
+ ND_PRINT((ndo, " length indicator %u < min PDU size:", li));
while (pptr < ndo->ndo_snapend)
ND_PRINT((ndo, "%02X", *pptr++));
return;
@@ -1080,7 +1153,8 @@ esis_print(netdissect_options *ndo,
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(ndo, pptr, EXTRACT_16BITS(esis_header->cksum), 7, li);
+ if (osi_print_cksum(ndo, pptr, EXTRACT_16BITS(esis_header->cksum), 7, li) == 0)
+ goto trunc;
ND_PRINT((ndo, ", holding time: %us, length indicator: %u",
EXTRACT_16BITS(esis_header->holdtime), li));
@@ -1112,7 +1186,7 @@ esis_print(netdissect_options *ndo,
dst = pptr;
pptr += dstl;
li -= dstl;
- ND_PRINT((ndo, "\n\t %s", isonsap_string(dst, dstl)));
+ ND_PRINT((ndo, "\n\t %s", isonsap_string(ndo, dst, dstl)));
ND_TCHECK(*pptr);
if (li < 1) {
@@ -1149,7 +1223,7 @@ esis_print(netdissect_options *ndo,
if (netal == 0)
ND_PRINT((ndo, "\n\t %s", etheraddr_string(ndo, snpa)));
else
- ND_PRINT((ndo, "\n\t %s", isonsap_string(neta, netal)));
+ ND_PRINT((ndo, "\n\t %s", isonsap_string(ndo, neta, netal)));
break;
}
@@ -1182,7 +1256,7 @@ esis_print(netdissect_options *ndo,
}
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--;
@@ -1204,7 +1278,7 @@ esis_print(netdissect_options *ndo,
ND_PRINT((ndo, ", bad ish/li"));
return;
}
- ND_PRINT((ndo, "\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;
@@ -1297,14 +1371,11 @@ isis_print_mcid(netdissect_options *ndo,
{
int i;
+ ND_TCHECK(*mcid);
ND_PRINT((ndo, "ID: %d, Name: ", mcid->format_id));
- for(i=0; i<32; i++)
- {
- ND_PRINT((ndo, "%c", mcid->name[i]));
- if(mcid->name[i] == '\0')
- break;
- }
+ if (fn_printzp(ndo, mcid->name, 32, ndo->ndo_snapend))
+ goto trunc;
ND_PRINT((ndo, "\n\t Lvl: %d", EXTRACT_16BITS(mcid->revision_lvl)));
@@ -1312,6 +1383,9 @@ isis_print_mcid(netdissect_options *ndo,
for(i=0;i<16;i++)
ND_PRINT((ndo, "%.2x ", mcid->digest[i]));
+
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
}
static int
@@ -1322,7 +1396,7 @@ isis_print_mt_port_cap_subtlv(netdissect_options *ndo,
const struct isis_subtlv_spb_mcid *subtlv_spb_mcid;
int i;
- while (len > 0)
+ while (len > 2)
{
stlv_type = *(tptr++);
stlv_len = *(tptr++);
@@ -1340,10 +1414,9 @@ isis_print_mt_port_cap_subtlv(netdissect_options *ndo,
{
case ISIS_SUBTLV_SPB_MCID:
{
- if (!ND_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;
ND_PRINT((ndo, "\n\t MCID: "));
isis_print_mcid(ndo, &(subtlv_spb_mcid->mcid));
@@ -1364,8 +1437,7 @@ isis_print_mt_port_cap_subtlv(netdissect_options *ndo,
case ISIS_SUBTLV_SPB_DIGEST:
{
- if (!ND_TTEST2(*(tptr), ISIS_SUBTLV_SPB_DIGEST_MIN_LEN))
- goto trunctlv;
+ ND_TCHECK2(*(tptr), ISIS_SUBTLV_SPB_DIGEST_MIN_LEN);
ND_PRINT((ndo, "\n\t RES: %d V: %d A: %d D: %d",
(*(tptr) >> 5), (((*tptr)>> 4) & 0x01),
@@ -1390,13 +1462,11 @@ isis_print_mt_port_cap_subtlv(netdissect_options *ndo,
case ISIS_SUBTLV_SPB_BVID:
{
- if (!ND_TTEST2(*(tptr), stlv_len))
- goto trunctlv;
+ ND_TCHECK2(*(tptr), stlv_len);
- while (len)
+ while (len >= ISIS_SUBTLV_SPB_BVID_MIN_LEN)
{
- if (!ND_TTEST2(*(tptr), ISIS_SUBTLV_SPB_BVID_MIN_LEN))
- goto trunctlv;
+ ND_TCHECK2(*(tptr), ISIS_SUBTLV_SPB_BVID_MIN_LEN);
ND_PRINT((ndo, "\n\t ECT: %08x",
EXTRACT_32BITS(tptr)));
@@ -1422,8 +1492,9 @@ isis_print_mt_port_cap_subtlv(netdissect_options *ndo,
return 0;
- trunctlv:
- ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
+ trunc:
+ ND_PRINT((ndo, "\n\t\t"));
+ ND_PRINT((ndo, "%s", tstr));
return(1);
}
@@ -1433,7 +1504,7 @@ isis_print_mt_capability_subtlv(netdissect_options *ndo,
{
int stlv_type, stlv_len, tmp;
- while (len > 0)
+ while (len > 2)
{
stlv_type = *(tptr++);
stlv_len = *(tptr++);
@@ -1450,8 +1521,7 @@ isis_print_mt_capability_subtlv(netdissect_options *ndo,
{
case ISIS_SUBTLV_SPB_INSTANCE:
- if (!ND_TTEST2(*(tptr), ISIS_SUBTLV_SPB_INSTANCE_MIN_LEN))
- goto trunctlv;
+ ND_TCHECK2(*tptr, ISIS_SUBTLV_SPB_INSTANCE_MIN_LEN);
ND_PRINT((ndo, "\n\t CIST Root-ID: %08x", EXTRACT_32BITS(tptr)));
tptr = tptr+4;
@@ -1476,8 +1546,7 @@ isis_print_mt_capability_subtlv(netdissect_options *ndo,
while (tmp)
{
- if (!ND_TTEST2(*(tptr), ISIS_SUBTLV_SPB_INSTANCE_VLAN_TUPLE_LEN))
- goto trunctlv;
+ ND_TCHECK2(*tptr, ISIS_SUBTLV_SPB_INSTANCE_VLAN_TUPLE_LEN);
ND_PRINT((ndo, "\n\t U:%d, M:%d, A:%d, RES:%d",
*(tptr) >> 7, (*(tptr) >> 6) & 0x01,
@@ -1502,8 +1571,7 @@ isis_print_mt_capability_subtlv(netdissect_options *ndo,
case ISIS_SUBTLV_SPBM_SI:
- if (!ND_TTEST2(*(tptr), 6))
- goto trunctlv;
+ ND_TCHECK2(*tptr, 8);
ND_PRINT((ndo, "\n\t BMAC: %08x", EXTRACT_32BITS(tptr)));
tptr = tptr+4;
@@ -1517,8 +1585,8 @@ isis_print_mt_capability_subtlv(netdissect_options *ndo,
len = len - 8;
stlv_len = stlv_len - 8;
- while (stlv_len)
- {
+ 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,
@@ -1538,8 +1606,9 @@ isis_print_mt_capability_subtlv(netdissect_options *ndo,
}
return 0;
- trunctlv:
- ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
+ trunc:
+ ND_PRINT((ndo, "\n\t\t"));
+ ND_PRINT((ndo, "%s", tstr));
return(1);
}
@@ -1662,13 +1731,12 @@ 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));
+ /* 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 (!ND_TTEST2(*tptr,subl))
- goto trunctlv;
+ ND_TCHECK2(*tptr,subl);
switch(subt) {
case ISIS_SUBTLV_EXTD_IP_REACH_MGMT_PREFIX_COLOR: /* fall through */
@@ -1697,8 +1765,9 @@ isis_print_ip_reach_subtlv(netdissect_options *ndo,
}
return(1);
-trunctlv:
- ND_PRINT((ndo, "%spacket exceeded snapshot", ident));
+trunc:
+ ND_PRINT((ndo, "%s", ident));
+ ND_PRINT((ndo, "%s", tstr));
return(0);
}
@@ -1723,8 +1792,7 @@ isis_print_is_reach_subtlv(netdissect_options *ndo,
ident, tok2str(isis_ext_is_reach_subtlv_values, "unknown", subt),
subt, subl));
- if (!ND_TTEST2(*tptr,subl))
- goto trunctlv;
+ ND_TCHECK2(*tptr, subl);
switch(subt) {
case ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP:
@@ -1769,6 +1837,7 @@ isis_print_is_reach_subtlv(netdissect_options *ndo,
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);
ND_PRINT((ndo, "%s Bandwidth constraint CT%u: %.3f Mbps",
ident,
@@ -1830,11 +1899,13 @@ isis_print_is_reach_subtlv(netdissect_options *ndo,
case GMPLS_PSC2:
case GMPLS_PSC3:
case GMPLS_PSC4:
+ ND_TCHECK2(*tptr, 6);
bw.i = EXTRACT_32BITS(tptr);
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);
ND_PRINT((ndo, "%s Min LSP Bandwidth: %.3f Mbps", ident, bw.f * 8 / 1000000));
ND_PRINT((ndo, "%s Indication %s", ident,
@@ -1857,12 +1928,10 @@ isis_print_is_reach_subtlv(netdissect_options *ndo,
}
return(1);
-trunctlv:
- ND_PRINT((ndo, "%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)
@@ -1901,7 +1970,7 @@ isis_print_ext_is_reach(netdissect_options *ndo,
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(ndo, tptr, subtlv_type, subtlv_len, ident_buffer))
return(0);
@@ -1950,11 +2019,7 @@ isis_print_extd_ip_reach(netdissect_options *ndo,
const uint8_t *tptr, const char *ident, uint16_t afi)
{
char ident_buffer[20];
-#ifdef INET6
uint8_t prefix[sizeof(struct in6_addr)]; /* shared copy buffer for IPv4 and IPv6 prefixes */
-#else
- uint8_t prefix[sizeof(struct in_addr)]; /* shared copy buffer for IPv4 prefixes */
-#endif
u_int metric, status_byte, bit_length, byte_length, sublen, processed, subtlvtype, subtlvlen;
if (!ND_TTEST2(*tptr, 4))
@@ -1975,7 +2040,6 @@ isis_print_extd_ip_reach(netdissect_options *ndo,
return (0);
}
processed++;
-#ifdef INET6
} else if (afi == AF_INET6) {
if (!ND_TTEST2(*tptr, 1)) /* fetch status & prefix_len byte */
return (0);
@@ -1988,7 +2052,6 @@ isis_print_extd_ip_reach(netdissect_options *ndo,
return (0);
}
processed+=2;
-#endif
} else
return (0); /* somebody is fooling us */
@@ -2006,13 +2069,11 @@ isis_print_extd_ip_reach(netdissect_options *ndo,
ident,
ipaddr_string(ndo, prefix),
bit_length));
-#ifdef INET6
- if (afi == AF_INET6)
+ else if (afi == AF_INET6)
ND_PRINT((ndo, "%sIPv6 prefix: %s/%u",
ident,
ip6addr_string(ndo, prefix),
bit_length));
-#endif
ND_PRINT((ndo, ", Distribution: %s, Metric: %u",
ISIS_MASK_TLV_EXTD_IP_UPDOWN(status_byte) ? "down" : "up",
@@ -2020,17 +2081,13 @@ isis_print_extd_ip_reach(netdissect_options *ndo,
if (afi == AF_INET && ISIS_MASK_TLV_EXTD_IP_SUBTLV(status_byte))
ND_PRINT((ndo, ", sub-TLVs present"));
-#ifdef INET6
- if (afi == AF_INET6)
+ 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
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
@@ -2047,7 +2104,7 @@ isis_print_extd_ip_reach(netdissect_options *ndo,
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(ndo, tptr, subtlvtype, subtlvlen, ident_buffer))
return(0);
@@ -2059,6 +2116,20 @@ isis_print_extd_ip_reach(netdissect_options *ndo,
}
/*
+ * 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.
*/
@@ -2071,7 +2142,7 @@ isis_print(netdissect_options *ndo,
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;
@@ -2096,7 +2167,7 @@ isis_print(netdissect_options *ndo,
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;
@@ -2174,6 +2245,7 @@ isis_print(netdissect_options *ndo,
case ISIS_PDU_L1_LAN_IIH:
case ISIS_PDU_L2_LAN_IIH:
+ 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",
@@ -2181,10 +2253,12 @@ isis_print(netdissect_options *ndo,
header_iih_lan->priority));
break;
case ISIS_PDU_PTP_IIH:
+ 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:
+ 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),
@@ -2192,10 +2266,12 @@ isis_print(netdissect_options *ndo,
break;
case ISIS_PDU_L1_CSNP:
case ISIS_PDU_L2_CSNP:
+ 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:
+ ND_TCHECK(*header_psnp);
ND_PRINT((ndo, ", src-id %s", isis_print_id(header_psnp->source_id, NODE_ID_LEN)));
break;
@@ -2235,13 +2311,13 @@ isis_print(netdissect_options *ndo,
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;
}
- ND_TCHECK(*header_iih_lan);
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),
@@ -2270,13 +2346,13 @@ isis_print(netdissect_options *ndo,
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;
}
- ND_TCHECK(*header_iih_ptp);
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),
@@ -2305,31 +2381,23 @@ isis_print(netdissect_options *ndo,
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;
}
- ND_TCHECK(*header_lsp);
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)));
-
- osi_print_cksum(ndo, (uint8_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;
-
+ if (osi_print_cksum(ndo, (const uint8_t *)header_lsp->lsp_id,
+ EXTRACT_16BITS(header_lsp->checksum),
+ 12, length-12) == 0)
+ goto trunc;
ND_PRINT((ndo, ", PDU length: %u, Flags: [ %s",
pdu_len,
@@ -2363,13 +2431,13 @@ isis_print(netdissect_options *ndo,
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;
}
- ND_TCHECK(*header_csnp);
ND_PRINT((ndo, "\n\t source-id: %s, PDU length: %u",
isis_print_id(header_csnp->source_id, NODE_ID_LEN),
pdu_len));
@@ -2395,13 +2463,13 @@ isis_print(netdissect_options *ndo,
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;
}
- ND_TCHECK(*header_psnp);
ND_PRINT((ndo, "\n\t source-id: %s, PDU length: %u",
isis_print_id(header_psnp->source_id, NODE_ID_LEN),
pdu_len));
@@ -2429,11 +2497,7 @@ isis_print(netdissect_options *ndo,
return (1);
}
- if (!ND_TTEST2(*pptr, 2)) {
- ND_PRINT((ndo, "\n\t\t packet exceeded snapshot (%ld) bytes",
- (long)(pptr - ndo->ndo_snapend)));
- return (1);
- }
+ ND_TCHECK2(*pptr, 2);
tlv_type = *pptr++;
tlv_len = *pptr++;
tmp =tlv_len; /* copy temporary len & pointer to packet data */
@@ -2451,32 +2515,29 @@ isis_print(netdissect_options *ndo,
tlv_type,
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 (!ND_TTEST2(*tptr, 1))
- goto trunctlv;
+ ND_TCHECK2(*tptr, 1);
alen = *tptr++;
while (tmp && alen < tmp) {
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 (!ND_TTEST2(*tptr, 1))
- goto trunctlv;
+ ND_TCHECK2(*tptr, 1);
alen = *tptr++;
}
break;
case ISIS_TLV_ISNEIGH:
while (tmp >= ETHER_ADDR_LEN) {
- if (!ND_TTEST2(*tptr, ETHER_ADDR_LEN))
- goto trunctlv;
+ 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;
@@ -2494,8 +2555,7 @@ isis_print(netdissect_options *ndo,
tmp --;
ND_PRINT((ndo, "\n\t LAN address length %u bytes ", lan_alen));
while (tmp >= lan_alen) {
- if (!ND_TTEST2(*tptr, lan_alen))
- goto trunctlv;
+ 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;
@@ -2541,16 +2601,14 @@ isis_print(netdissect_options *ndo,
}
break;
case ISIS_TLV_IS_REACH:
- if (!ND_TTEST2(*tptr,1)) /* check if there is one byte left to read out the virtual flag */
- goto trunctlv;
+ 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++)));
tlv_is_reach = (const struct isis_tlv_is_reach *)tptr;
while (tmp >= sizeof(struct isis_tlv_is_reach)) {
- if (!ND_TTEST(*tlv_is_reach))
- goto trunctlv;
+ 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);
@@ -2562,8 +2620,7 @@ isis_print(netdissect_options *ndo,
case ISIS_TLV_ESNEIGH:
tlv_es_reach = (const struct isis_tlv_es_reach *)tptr;
while (tmp >= sizeof(struct isis_tlv_es_reach)) {
- if (!ND_TTEST(*tlv_es_reach))
- goto trunctlv;
+ 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);
@@ -2606,7 +2663,6 @@ isis_print(netdissect_options *ndo,
}
break;
-#ifdef INET6
case ISIS_TLV_IP6_REACH:
while (tmp>0) {
ext_ip_len = isis_print_extd_ip_reach(ndo, tptr, "\n\t ", AF_INET6);
@@ -2636,8 +2692,7 @@ isis_print(netdissect_options *ndo,
case ISIS_TLV_IP6ADDR:
while (tmp>=sizeof(struct in6_addr)) {
- if (!ND_TTEST2(*tptr, sizeof(struct in6_addr)))
- goto trunctlv;
+ ND_TCHECK2(*tptr, sizeof(struct in6_addr));
ND_PRINT((ndo, "\n\t IPv6 interface address: %s",
ip6addr_string(ndo, tptr)));
@@ -2646,10 +2701,8 @@ isis_print(netdissect_options *ndo,
tmp -= sizeof(struct in6_addr);
}
break;
-#endif
case ISIS_TLV_AUTH:
- if (!ND_TTEST2(*tptr, 1))
- goto trunctlv;
+ ND_TCHECK2(*tptr, 1);
ND_PRINT((ndo, "\n\t %s: ",
tok2str(isis_subtlv_auth_values,
@@ -2658,36 +2711,29 @@ isis_print(netdissect_options *ndo,
switch (*tptr) {
case ISIS_SUBTLV_AUTH_SIMPLE:
- for(i=1;i<tlv_len;i++) {
- if (!ND_TTEST2(*(tptr + i), 1))
- goto trunctlv;
- ND_PRINT((ndo, "%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 (!ND_TTEST2(*(tptr + i), 1))
- goto trunctlv;
+ ND_TCHECK2(*(tptr + i), 1);
ND_PRINT((ndo, "%02x", *(tptr + i)));
}
if (tlv_len != ISIS_SUBTLV_AUTH_MD5_LEN+1)
- ND_PRINT((ndo, ", (malformed subTLV) "));
+ ND_PRINT((ndo, ", (invalid subTLV) "));
-#ifdef HAVE_LIBCRYPTO
- sigcheck = signature_verify(ndo, optr, length,
- (unsigned char *)tptr + 1);
-#else
- sigcheck = CANT_CHECK_SIGNATURE;
-#endif
+ 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));
ND_PRINT((ndo, "%u, password: ", key_id));
for(i=1 + sizeof(uint16_t);i<tlv_len;i++) {
- if (!ND_TTEST2(*(tptr + i), 1))
- goto trunctlv;
+ ND_TCHECK2(*(tptr + i), 1);
ND_PRINT((ndo, "%02x", *(tptr + i)));
}
break;
@@ -2702,32 +2748,26 @@ isis_print(netdissect_options *ndo,
case ISIS_TLV_PTP_ADJ:
tlv_ptp_adj = (const struct isis_tlv_ptp_adj *)tptr;
if(tmp>=1) {
- if (!ND_TTEST2(*tptr, 1))
- goto trunctlv;
+ ND_TCHECK2(*tptr, 1);
ND_PRINT((ndo, "\n\t Adjacency State: %s (%u)",
tok2str(isis_ptp_adjancey_values, "unknown", *tptr),
*tptr));
tmp--;
}
if(tmp>sizeof(tlv_ptp_adj->extd_local_circuit_id)) {
- if (!ND_TTEST2(tlv_ptp_adj->extd_local_circuit_id,
- sizeof(tlv_ptp_adj->extd_local_circuit_id)))
- goto trunctlv;
+ 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 (!ND_TTEST2(tlv_ptp_adj->neighbor_sysid, SYSTEM_ID_LEN))
- goto trunctlv;
+ 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 (!ND_TTEST2(tlv_ptp_adj->neighbor_extd_local_circuit_id,
- sizeof(tlv_ptp_adj->neighbor_extd_local_circuit_id)))
- goto trunctlv;
+ 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)));
}
@@ -2736,8 +2776,7 @@ isis_print(netdissect_options *ndo,
case ISIS_TLV_PROTOCOLS:
ND_PRINT((ndo, "\n\t NLPID(s): "));
while (tmp>0) {
- if (!ND_TTEST2(*(tptr), 1))
- goto trunctlv;
+ ND_TCHECK2(*(tptr), 1);
ND_PRINT((ndo, "%s (0x%02x)",
tok2str(nlpid_values,
"unknown",
@@ -2752,8 +2791,7 @@ isis_print(netdissect_options *ndo,
case ISIS_TLV_MT_PORT_CAP:
{
- if (!ND_TTEST2(*(tptr), 2))
- goto trunctlv;
+ ND_TCHECK2(*(tptr), 2);
ND_PRINT((ndo, "\n\t RES: %d, MTID(s): %d",
(EXTRACT_16BITS (tptr) >> 12),
@@ -2770,8 +2808,7 @@ isis_print(netdissect_options *ndo,
case ISIS_TLV_MT_CAPABILITY:
- if (!ND_TTEST2(*(tptr), 2))
- goto trunctlv;
+ ND_TCHECK2(*(tptr), 2);
ND_PRINT((ndo, "\n\t O: %d, RES: %d, MTID(s): %d",
(EXTRACT_16BITS(tptr) >> 15) & 0x01,
@@ -2787,15 +2824,13 @@ isis_print(netdissect_options *ndo,
break;
case ISIS_TLV_TE_ROUTER_ID:
- if (!ND_TTEST2(*pptr, sizeof(struct in_addr)))
- goto trunctlv;
+ 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 (!ND_TTEST2(*tptr, sizeof(struct in_addr)))
- goto trunctlv;
+ 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);
@@ -2804,49 +2839,40 @@ isis_print(netdissect_options *ndo,
case ISIS_TLV_HOSTNAME:
ND_PRINT((ndo, "\n\t Hostname: "));
- while (tmp>0) {
- if (!ND_TTEST2(*tptr, 1))
- goto trunctlv;
- ND_PRINT((ndo, "%c", *tptr++));
- tmp--;
- }
+ 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 (!ND_TTEST2(*tptr, NODE_ID_LEN))
- goto trunctlv;
+ 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 (!ND_TTEST2(*tptr, 1))
- goto trunctlv;
+ 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 (!ND_TTEST2(*tptr, sizeof(struct in_addr)))
- goto trunctlv;
+ 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 (!ND_TTEST2(*tptr, sizeof(struct in_addr)))
- goto trunctlv;
+ 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 (!ND_TTEST2(*tptr, 4))
- goto trunctlv;
+ ND_TCHECK2(*tptr, 4);
ND_PRINT((ndo, "\n\t Link-ID: 0x%08x", EXTRACT_32BITS(tptr)));
tptr+=4;
tmp-=4;
@@ -2856,18 +2882,14 @@ isis_print(netdissect_options *ndo,
case ISIS_TLV_LSP:
tlv_lsp = (const struct isis_tlv_lsp *)tptr;
while(tmp>=sizeof(struct isis_tlv_lsp)) {
- if (!ND_TTEST((tlv_lsp->lsp_id)[LSP_ID_LEN-1]))
- goto trunctlv;
+ 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)));
- if (!ND_TTEST2(tlv_lsp->sequence_number, 4))
- goto trunctlv;
+ ND_TCHECK2(tlv_lsp->sequence_number, 4);
ND_PRINT((ndo, ", seq: 0x%08x", EXTRACT_32BITS(tlv_lsp->sequence_number)));
- if (!ND_TTEST2(tlv_lsp->remaining_lifetime, 2))
- goto trunctlv;
+ ND_TCHECK2(tlv_lsp->remaining_lifetime, 2);
ND_PRINT((ndo, ", lifetime: %5ds", EXTRACT_16BITS(tlv_lsp->remaining_lifetime)));
- if (!ND_TTEST2(tlv_lsp->checksum, 2))
- goto trunctlv;
+ 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++;
@@ -2877,15 +2899,30 @@ isis_print(netdissect_options *ndo,
case ISIS_TLV_CHECKSUM:
if (tmp < ISIS_TLV_CHECKSUM_MINLEN)
break;
- if (!ND_TTEST2(*tptr, ISIS_TLV_CHECKSUM_MINLEN))
- goto trunctlv;
+ 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(ndo, 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:
@@ -2901,7 +2938,7 @@ isis_print(netdissect_options *ndo,
tptr+=mt_len;
tmp-=mt_len;
} else {
- ND_PRINT((ndo, "\n\t malformed MT-ID"));
+ ND_PRINT((ndo, "\n\t invalid MT-ID"));
break;
}
}
@@ -2911,8 +2948,7 @@ isis_print(netdissect_options *ndo,
/* first attempt to decode the flags */
if (tmp < ISIS_TLV_RESTART_SIGNALING_FLAGLEN)
break;
- if (!ND_TTEST2(*tptr, ISIS_TLV_RESTART_SIGNALING_FLAGLEN))
- goto trunctlv;
+ 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;
@@ -2924,8 +2960,7 @@ isis_print(netdissect_options *ndo,
if (tmp < ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN)
break;
- if (!ND_TTEST2(*tptr, ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN))
- goto trunctlv;
+ ND_TCHECK2(*tptr, ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN);
ND_PRINT((ndo, ", Remaining holding time %us", EXTRACT_16BITS(tptr)));
tptr+=ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN;
@@ -2933,8 +2968,7 @@ isis_print(netdissect_options *ndo,
/* is there an additional sysid field present ?*/
if (tmp == SYSTEM_ID_LEN) {
- if (!ND_TTEST2(*tptr, SYSTEM_ID_LEN))
- goto trunctlv;
+ ND_TCHECK2(*tptr, SYSTEM_ID_LEN);
ND_PRINT((ndo, ", for %s", isis_print_id(tptr,SYSTEM_ID_LEN)));
}
break;
@@ -2942,16 +2976,14 @@ isis_print(netdissect_options *ndo,
case ISIS_TLV_IDRP_INFO:
if (tmp < ISIS_TLV_IDRP_INFO_MINLEN)
break;
- if (!ND_TTEST2(*tptr, ISIS_TLV_IDRP_INFO_MINLEN))
- goto trunctlv;
+ 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)));
switch (*tptr++) {
case ISIS_SUBTLV_IDRP_ASN:
- if (!ND_TTEST2(*tptr, 2)) /* fetch AS number */
- goto trunctlv;
+ ND_TCHECK2(*tptr, 2); /* fetch AS number */
ND_PRINT((ndo, "AS Number: %u", EXTRACT_16BITS(tptr)));
break;
case ISIS_SUBTLV_IDRP_LOCAL:
@@ -2966,15 +2998,13 @@ isis_print(netdissect_options *ndo,
case ISIS_TLV_LSP_BUFFERSIZE:
if (tmp < ISIS_TLV_LSP_BUFFERSIZE_MINLEN)
break;
- if (!ND_TTEST2(*tptr, ISIS_TLV_LSP_BUFFERSIZE_MINLEN))
- goto trunctlv;
+ 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 (!ND_TTEST2(*tptr, SYSTEM_ID_LEN))
- goto trunctlv;
+ 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;
@@ -2984,16 +3014,14 @@ isis_print(netdissect_options *ndo,
case ISIS_TLV_PREFIX_NEIGH:
if (tmp < sizeof(struct isis_metric_block))
break;
- if (!ND_TTEST2(*tptr, sizeof(struct isis_metric_block)))
- goto trunctlv;
+ 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 (!ND_TTEST2(*tptr, 1))
- goto trunctlv;
+ ND_TCHECK2(*tptr, 1);
prefix_len=*tptr++; /* read out prefix length in semioctets*/
if (prefix_len < 2) {
ND_PRINT((ndo, "\n\t\tAddress: prefix length %u < 2", prefix_len));
@@ -3002,10 +3030,9 @@ isis_print(netdissect_options *ndo,
tmp--;
if (tmp < prefix_len/2)
break;
- if (!ND_TTEST2(*tptr, prefix_len / 2))
- goto trunctlv;
+ ND_TCHECK2(*tptr, prefix_len / 2);
ND_PRINT((ndo, "\n\t\tAddress: %s/%u",
- isonsap_string(tptr, prefix_len / 2), prefix_len * 4));
+ isonsap_string(ndo, tptr, prefix_len / 2), prefix_len * 4));
tptr+=prefix_len/2;
tmp-=prefix_len/2;
}
@@ -3014,16 +3041,14 @@ isis_print(netdissect_options *ndo,
case ISIS_TLV_IIH_SEQNR:
if (tmp < ISIS_TLV_IIH_SEQNR_MINLEN)
break;
- if (!ND_TTEST2(*tptr, ISIS_TLV_IIH_SEQNR_MINLEN)) /* check if four bytes are on the wire */
- goto trunctlv;
+ 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 (!ND_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);
ND_PRINT((ndo, "\n\t Vendor: %s (%u)",
tok2str(oui_values, "Unknown", vendor_id),
@@ -3068,18 +3093,18 @@ isis_print(netdissect_options *ndo,
return (1);
trunc:
- ND_PRINT((ndo, "[|isis]"));
+ ND_PRINT((ndo, "%s", tstr));
return (1);
trunctlv:
- ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
+ ND_PRINT((ndo, "\n\t\t"));
+ ND_PRINT((ndo, "%s", tstr));
return(1);
}
-static void
-osi_print_cksum(netdissect_options *ndo,
- const uint8_t *pptr, uint16_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)
{
uint16_t calculated_checksum;
@@ -3089,27 +3114,28 @@ osi_print_cksum(netdissect_options *ndo,
* or the base pointer is not sane
*/
if (!checksum
- || length > (u_int)ndo->ndo_snaplen
- || checksum_offset > (uint)ndo->ndo_snaplen
+ || length < 0
+ || checksum_offset < 0
+ || length > ndo->ndo_snaplen
+ || checksum_offset > ndo->ndo_snaplen
|| checksum_offset > length) {
- ND_PRINT((ndo, "(unverified)"));
+ ND_PRINT((ndo, " (unverified)"));
+ return 1;
} else {
- unsigned char *truncated = "trunc";
#if 0
printf("\nosi_print_cksum: %p %u %u %u\n", pptr, checksum_offset, length, ndo->ndo_snaplen);
- ND_TCHECK2(pptr, checksum_offset+length);
#endif
+ ND_TCHECK2(*pptr, length);
calculated_checksum = create_osi_cksum(pptr, checksum_offset, length);
if (checksum == calculated_checksum) {
ND_PRINT((ndo, " (correct)"));
} else {
- truncated = "incorrect";
-#if 0
- trunc:
-#endif
- ND_PRINT((ndo, " (%s should be 0x%04x)", truncated, calculated_checksum));
+ ND_PRINT((ndo, " (incorrect should be 0x%04x)", calculated_checksum));
}
+ return 1;
}
+trunc:
+ return 0;
}
/*
diff --git a/contrib/tcpdump/print-juniper.c b/contrib/tcpdump/print-juniper.c
index e4bb77c..83ac372 100644
--- a/contrib/tcpdump/print-juniper.c
+++ b/contrib/tcpdump/print-juniper.c
@@ -15,19 +15,22 @@
* Original code by Hannes Gredler (hannes@juniper.net)
*/
+/* \summary: DLT_JUNIPER_* printers */
+
#ifndef lint
#else
__RCSID("NetBSD: print-juniper.c,v 1.3 2007/07/25 06:31:32 dogcow Exp ");
#endif
-#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
+
+#include <string.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "extract.h"
#include "ppp.h"
@@ -89,7 +92,7 @@ enum {
};
/* 1 byte type and 1-byte length */
-#define JUNIPER_EXT_TLV_OVERHEAD 2
+#define JUNIPER_EXT_TLV_OVERHEAD 2U
static const struct tok jnx_ext_tlv_values[] = {
{ JUNIPER_EXT_TLV_IFD_IDX, "Device Interface Index" },
@@ -514,7 +517,7 @@ juniper_es_print(netdissect_options *ndo,
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:
@@ -583,7 +586,7 @@ juniper_monitor_print(netdissect_options *ndo,
return l2info.header_len;
p+=l2info.header_len;
- mh = (struct juniper_monitor_header *)p;
+ mh = (const struct juniper_monitor_header *)p;
if (ndo->ndo_eflag)
ND_PRINT((ndo, "service-id %u, iif %u, pkt-type %u: ",
@@ -617,7 +620,7 @@ juniper_services_print(netdissect_options *ndo,
return l2info.header_len;
p+=l2info.header_len;
- sh = (struct juniper_services_header *)p;
+ sh = (const struct juniper_services_header *)p;
if (ndo->ndo_eflag)
ND_PRINT((ndo, "service-id %u flags 0x%02x service-set-id 0x%04x iif %u: ",
@@ -743,7 +746,8 @@ juniper_pppoe_atm_print(netdissect_options *ndo,
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 */
ND_PRINT((ndo, "unknown ethertype 0x%04x", extracted_ethertype));
@@ -818,6 +822,7 @@ juniper_mfr_print(netdissect_options *ndo,
{
struct juniper_l2info_t l2info;
+ memset(&l2info, 0, sizeof(l2info));
l2info.pictype = DLT_JUNIPER_MFR;
if (juniper_parse_header(ndo, p, h, &l2info) == 0)
return l2info.header_len;
@@ -920,7 +925,7 @@ u_int
juniper_atm1_print(netdissect_options *ndo,
const struct pcap_pkthdr *h, register const u_char *p)
{
- uint16_t extracted_ethertype;
+ int llc_hdrlen;
struct juniper_l2info_t l2info;
@@ -938,8 +943,8 @@ juniper_atm1_print(netdissect_options *ndo,
if (EXTRACT_24BITS(p) == 0xfefe03 || /* NLPID encaps ? */
EXTRACT_24BITS(p) == 0xaaaa03) { /* SNAP encaps ? */
- if (llc_print(ndo, 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;
}
@@ -969,7 +974,7 @@ u_int
juniper_atm2_print(netdissect_options *ndo,
const struct pcap_pkthdr *h, register const u_char *p)
{
- uint16_t extracted_ethertype;
+ int llc_hdrlen;
struct juniper_l2info_t l2info;
@@ -987,8 +992,8 @@ juniper_atm2_print(netdissect_options *ndo,
if (EXTRACT_24BITS(p) == 0xfefe03 || /* NLPID encaps ? */
EXTRACT_24BITS(p) == 0xaaaa03) { /* SNAP encaps ? */
- if (llc_print(ndo, 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;
}
@@ -1033,10 +1038,8 @@ juniper_ppp_heuristic_guess(netdissect_options *ndo,
case PPP_PAP :
case PPP_CHAP :
case PPP_ML :
-#ifdef INET6
case PPP_IPV6 :
case PPP_IPV6CP :
-#endif
ppp_print(ndo, p, length);
break;
@@ -1200,9 +1203,11 @@ juniper_parse_header(netdissect_options *ndo,
tlv_len = *(tptr++);
tlv_value = 0;
- /* sanity check */
+ /* sanity checks */
if (tlv_type == 0 || tlv_len == 0)
break;
+ 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 ",
diff --git a/contrib/tcpdump/print-krb.c b/contrib/tcpdump/print-krb.c
index 2eebfa6..de69054 100644
--- a/contrib/tcpdump/print-krb.c
+++ b/contrib/tcpdump/print-krb.c
@@ -21,14 +21,15 @@
* Initial contribution from John Hawkinson (jhawk@mit.edu).
*/
-#define NETDISSECT_REWORKED
+/* \summary: Kerberos printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
static const char tstr[] = " [|kerberos]";
@@ -156,7 +157,7 @@ krb4_print(netdissect_options *ndo,
#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) >= ndo->ndo_snapend) {
ND_PRINT((ndo, "%s", tstr));
@@ -227,7 +228,7 @@ krb_print(netdissect_options *ndo,
{
register const struct krb *kp;
- kp = (struct krb *)dat;
+ kp = (const struct krb *)dat;
if (dat >= ndo->ndo_snapend) {
ND_PRINT((ndo, "%s", tstr));
diff --git a/contrib/tcpdump/print-l2tp.c b/contrib/tcpdump/print-l2tp.c
index 346dae9..42ae391 100644
--- a/contrib/tcpdump/print-l2tp.c
+++ b/contrib/tcpdump/print-l2tp.c
@@ -21,14 +21,15 @@
* L2TP support contributed by Motonori Shindo (mshindo@mshindo.net)
*/
-#define NETDISSECT_REWORKED
+/* \summary: Layer Two Tunneling Protocol (L2TP) printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
#define L2TP_FLAG_TYPE 0x8000 /* Type (0=Data, 1=Control) */
@@ -298,7 +299,7 @@ print_32bits_val(netdissect_options *ndo, const uint32_t *dat)
static void
l2tp_msgtype_print(netdissect_options *ndo, const u_char *dat)
{
- uint16_t *ptr = (uint16_t*)dat;
+ const uint16_t *ptr = (const uint16_t *)dat;
ND_PRINT((ndo, "%s", tok2str(l2tp_msgtype2str, "MSGTYPE-#%u",
EXTRACT_16BITS(ptr))));
@@ -307,7 +308,7 @@ l2tp_msgtype_print(netdissect_options *ndo, const u_char *dat)
static void
l2tp_result_code_print(netdissect_options *ndo, const u_char *dat, u_int length)
{
- uint16_t *ptr = (uint16_t *)dat;
+ const uint16_t *ptr = (const uint16_t *)dat;
ND_PRINT((ndo, "%u", EXTRACT_16BITS(ptr))); ptr++; /* Result Code */
if (length > 2) { /* Error Code (opt) */
@@ -315,7 +316,7 @@ l2tp_result_code_print(netdissect_options *ndo, const u_char *dat, u_int length)
}
if (length > 4) { /* Error Message (opt) */
ND_PRINT((ndo, " "));
- print_string(ndo, (u_char *)ptr, length - 4);
+ print_string(ndo, (const u_char *)ptr, length - 4);
}
}
@@ -329,7 +330,7 @@ l2tp_proto_ver_print(netdissect_options *ndo, const uint16_t *dat)
static void
l2tp_framing_cap_print(netdissect_options *ndo, const u_char *dat)
{
- uint32_t *ptr = (uint32_t *)dat;
+ const uint32_t *ptr = (const uint32_t *)dat;
if (EXTRACT_32BITS(ptr) & L2TP_FRAMING_CAP_ASYNC_MASK) {
ND_PRINT((ndo, "A"));
@@ -342,7 +343,7 @@ l2tp_framing_cap_print(netdissect_options *ndo, const u_char *dat)
static void
l2tp_bearer_cap_print(netdissect_options *ndo, const u_char *dat)
{
- uint32_t *ptr = (uint32_t *)dat;
+ const uint32_t *ptr = (const uint32_t *)dat;
if (EXTRACT_32BITS(ptr) & L2TP_BEARER_CAP_ANALOG_MASK) {
ND_PRINT((ndo, "A"));
@@ -355,7 +356,7 @@ l2tp_bearer_cap_print(netdissect_options *ndo, const u_char *dat)
static void
l2tp_q931_cc_print(netdissect_options *ndo, const u_char *dat, u_int length)
{
- print_16bits_val(ndo, (uint16_t *)dat);
+ print_16bits_val(ndo, (const uint16_t *)dat);
ND_PRINT((ndo, ", %02x", dat[2]));
if (length > 3) {
ND_PRINT((ndo, " "));
@@ -366,7 +367,7 @@ l2tp_q931_cc_print(netdissect_options *ndo, const u_char *dat, u_int length)
static void
l2tp_bearer_type_print(netdissect_options *ndo, const u_char *dat)
{
- uint32_t *ptr = (uint32_t *)dat;
+ const uint32_t *ptr = (const uint32_t *)dat;
if (EXTRACT_32BITS(ptr) & L2TP_BEARER_TYPE_ANALOG_MASK) {
ND_PRINT((ndo, "A"));
@@ -379,7 +380,7 @@ l2tp_bearer_type_print(netdissect_options *ndo, const u_char *dat)
static void
l2tp_framing_type_print(netdissect_options *ndo, const u_char *dat)
{
- uint32_t *ptr = (uint32_t *)dat;
+ const uint32_t *ptr = (const uint32_t *)dat;
if (EXTRACT_32BITS(ptr) & L2TP_FRAMING_TYPE_ASYNC_MASK) {
ND_PRINT((ndo, "A"));
@@ -398,7 +399,7 @@ l2tp_packet_proc_delay_print(netdissect_options *ndo)
static void
l2tp_proxy_auth_type_print(netdissect_options *ndo, const u_char *dat)
{
- uint16_t *ptr = (uint16_t *)dat;
+ const uint16_t *ptr = (const uint16_t *)dat;
ND_PRINT((ndo, "%s", tok2str(l2tp_authentype2str,
"AuthType-#%u", EXTRACT_16BITS(ptr))));
@@ -407,7 +408,7 @@ l2tp_proxy_auth_type_print(netdissect_options *ndo, const u_char *dat)
static void
l2tp_proxy_auth_id_print(netdissect_options *ndo, const u_char *dat)
{
- uint16_t *ptr = (uint16_t *)dat;
+ const uint16_t *ptr = (const uint16_t *)dat;
ND_PRINT((ndo, "%u", EXTRACT_16BITS(ptr) & L2TP_PROXY_AUTH_ID_MASK));
}
@@ -415,7 +416,7 @@ l2tp_proxy_auth_id_print(netdissect_options *ndo, const u_char *dat)
static void
l2tp_call_errors_print(netdissect_options *ndo, const u_char *dat)
{
- uint16_t *ptr = (uint16_t *)dat;
+ const uint16_t *ptr = (const uint16_t *)dat;
uint16_t val_h, val_l;
ptr++; /* skip "Reserved" */
@@ -448,7 +449,7 @@ l2tp_call_errors_print(netdissect_options *ndo, const u_char *dat)
static void
l2tp_accm_print(netdissect_options *ndo, const u_char *dat)
{
- uint16_t *ptr = (uint16_t *)dat;
+ const uint16_t *ptr = (const uint16_t *)dat;
uint16_t val_h, val_l;
ptr++; /* skip "Reserved" */
@@ -465,12 +466,12 @@ l2tp_accm_print(netdissect_options *ndo, const u_char *dat)
static void
l2tp_ppp_discon_cc_print(netdissect_options *ndo, const u_char *dat, u_int length)
{
- uint16_t *ptr = (uint16_t *)dat;
+ const uint16_t *ptr = (const uint16_t *)dat;
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", *((u_char *)ptr++))));
+ "Direction-#%u", *((const u_char *)ptr++))));
if (length > 5) {
ND_PRINT((ndo, " "));
@@ -482,7 +483,7 @@ static void
l2tp_avp_print(netdissect_options *ndo, const u_char *dat, int length)
{
u_int len;
- const uint16_t *ptr = (uint16_t *)dat;
+ const uint16_t *ptr = (const uint16_t *)dat;
uint16_t attr_type;
int hidden = FALSE;
@@ -523,7 +524,7 @@ l2tp_avp_print(netdissect_options *ndo, const u_char *dat, int length)
ND_PRINT((ndo, "VENDOR%04x:", EXTRACT_16BITS(ptr))); ptr++;
ND_PRINT((ndo, "ATTR%04x", EXTRACT_16BITS(ptr))); ptr++;
ND_PRINT((ndo, "("));
- print_octets(ndo, (u_char *)ptr, len-6);
+ print_octets(ndo, (const u_char *)ptr, len-6);
ND_PRINT((ndo, ")"));
} else {
/* IETF-defined Attributes */
@@ -536,22 +537,22 @@ l2tp_avp_print(netdissect_options *ndo, const u_char *dat, int length)
} else {
switch (attr_type) {
case L2TP_AVP_MSGTYPE:
- l2tp_msgtype_print(ndo, (u_char *)ptr);
+ l2tp_msgtype_print(ndo, (const u_char *)ptr);
break;
case L2TP_AVP_RESULT_CODE:
- l2tp_result_code_print(ndo, (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(ndo, ptr);
break;
case L2TP_AVP_FRAMING_CAP:
- l2tp_framing_cap_print(ndo, (u_char *)ptr);
+ l2tp_framing_cap_print(ndo, (const u_char *)ptr);
break;
case L2TP_AVP_BEARER_CAP:
- l2tp_bearer_cap_print(ndo, (u_char *)ptr);
+ l2tp_bearer_cap_print(ndo, (const u_char *)ptr);
break;
case L2TP_AVP_TIE_BREAKER:
- print_octets(ndo, (u_char *)ptr, 8);
+ print_octets(ndo, (const u_char *)ptr, 8);
break;
case L2TP_AVP_FIRM_VER:
case L2TP_AVP_ASSND_TUN_ID:
@@ -566,7 +567,7 @@ l2tp_avp_print(netdissect_options *ndo, 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(ndo, (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:
@@ -575,13 +576,13 @@ l2tp_avp_print(netdissect_options *ndo, 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(ndo, (u_char *)ptr, len-6);
+ print_octets(ndo, (const u_char *)ptr, len-6);
break;
case L2TP_AVP_Q931_CC:
- l2tp_q931_cc_print(ndo, (u_char *)ptr, len-6);
+ l2tp_q931_cc_print(ndo, (const u_char *)ptr, len-6);
break;
case L2TP_AVP_CHALLENGE_RESP:
- print_octets(ndo, (u_char *)ptr, 16);
+ print_octets(ndo, (const u_char *)ptr, 16);
break;
case L2TP_AVP_CALL_SER_NUM:
case L2TP_AVP_MINIMUM_BPS:
@@ -589,33 +590,33 @@ l2tp_avp_print(netdissect_options *ndo, 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(ndo, (uint32_t *)ptr);
+ print_32bits_val(ndo, (const uint32_t *)ptr);
break;
case L2TP_AVP_BEARER_TYPE:
- l2tp_bearer_type_print(ndo, (u_char *)ptr);
+ l2tp_bearer_type_print(ndo, (const u_char *)ptr);
break;
case L2TP_AVP_FRAMING_TYPE:
- l2tp_framing_type_print(ndo, (u_char *)ptr);
+ l2tp_framing_type_print(ndo, (const u_char *)ptr);
break;
case L2TP_AVP_PACKET_PROC_DELAY:
l2tp_packet_proc_delay_print(ndo);
break;
case L2TP_AVP_PROXY_AUTH_TYPE:
- l2tp_proxy_auth_type_print(ndo, (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(ndo, (u_char *)ptr);
+ l2tp_proxy_auth_id_print(ndo, (const u_char *)ptr);
break;
case L2TP_AVP_CALL_ERRORS:
- l2tp_call_errors_print(ndo, (u_char *)ptr);
+ l2tp_call_errors_print(ndo, (const u_char *)ptr);
break;
case L2TP_AVP_ACCM:
- l2tp_accm_print(ndo, (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(ndo, (u_char *)ptr, len-6);
+ l2tp_ppp_discon_cc_print(ndo, (const u_char *)ptr, len-6);
break;
default:
break;
diff --git a/contrib/tcpdump/print-lane.c b/contrib/tcpdump/print-lane.c
index c1e0b2e..ba52084 100644
--- a/contrib/tcpdump/print-lane.c
+++ b/contrib/tcpdump/print-lane.c
@@ -20,14 +20,15 @@
*
*/
-#define NETDISSECT_REWORKED
+/* \summary: ATM LANE printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
#include "ether.h"
@@ -82,14 +83,14 @@ lane_hdr_print(netdissect_options *ndo, const u_char *bp)
void
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)) {
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.
diff --git a/contrib/tcpdump/print-ldp.c b/contrib/tcpdump/print-ldp.c
index 3f741d1..40c9d8c 100644
--- a/contrib/tcpdump/print-ldp.c
+++ b/contrib/tcpdump/print-ldp.c
@@ -14,14 +14,15 @@
* and Steinar Haug (sthaug@nethelp.no)
*/
-#define NETDISSECT_REWORKED
+/* \summary: Label Distribution Protocol (LDP) printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
#include "addrtoname.h"
@@ -284,12 +285,10 @@ ldp_tlv_print(netdissect_options *ndo,
TLV_TCHECK(4);
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);
ND_PRINT((ndo, "\n\t IPv6 Transport Address: %s", ip6addr_string(ndo, tptr)));
break;
-#endif
case LDP_TLV_CONFIG_SEQ_NUMBER:
TLV_TCHECK(4);
ND_PRINT((ndo, "\n\t Sequence Number: %u", EXTRACT_32BITS(tptr)));
@@ -311,7 +310,6 @@ ldp_tlv_print(netdissect_options *ndo,
tptr+=sizeof(struct in_addr);
}
break;
-#ifdef INET6
case AFNUM_INET6:
while(tlv_tlen >= sizeof(struct in6_addr)) {
ND_TCHECK2(*tptr, sizeof(struct in6_addr));
@@ -320,7 +318,6 @@ ldp_tlv_print(netdissect_options *ndo,
tptr+=sizeof(struct in6_addr);
}
break;
-#endif
default:
/* unknown AF */
break;
@@ -365,7 +362,6 @@ ldp_tlv_print(netdissect_options *ndo,
else
ND_PRINT((ndo, ": IPv4 prefix %s", buf));
}
-#ifdef INET6
else if (af == AFNUM_INET6) {
i=decode_prefix6(ndo, tptr, tlv_tlen, buf, sizeof(buf));
if (i == -2)
@@ -377,7 +373,6 @@ ldp_tlv_print(netdissect_options *ndo,
else
ND_PRINT((ndo, ": IPv6 prefix %s", buf));
}
-#endif
else
ND_PRINT((ndo, ": Address family %u prefix", af));
break;
@@ -385,16 +380,20 @@ ldp_tlv_print(netdissect_options *ndo,
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) {
ND_PRINT((ndo, ": %s, %scontrol word, group-ID %u, VC-info-length: %u",
- tok2str(l2vpn_encaps_values, "Unknown", EXTRACT_16BITS(tptr)&0x7fff),
+ tok2str(mpls_pw_types_values, "Unknown", EXTRACT_16BITS(tptr)&0x7fff),
EXTRACT_16BITS(tptr)&0x8000 ? "" : "no ",
EXTRACT_32BITS(tptr+3),
vc_info_len));
@@ -404,7 +403,7 @@ ldp_tlv_print(netdissect_options *ndo,
/* Make sure we have the VC ID as well */
TLV_TCHECK(11);
ND_PRINT((ndo, ": %s, %scontrol word, group-ID %u, VC-ID %u, VC-info-length: %u",
- tok2str(l2vpn_encaps_values, "Unknown", EXTRACT_16BITS(tptr)&0x7fff),
+ tok2str(mpls_pw_types_values, "Unknown", EXTRACT_16BITS(tptr)&0x7fff),
EXTRACT_16BITS(tptr)&0x8000 ? "" : "no ",
EXTRACT_32BITS(tptr+3),
EXTRACT_32BITS(tptr+7),
diff --git a/contrib/tcpdump/print-lisp.c b/contrib/tcpdump/print-lisp.c
new file mode 100644
index 0000000..47afe50
--- /dev/null
+++ b/contrib/tcpdump/print-lisp.c
@@ -0,0 +1,449 @@
+/*
+ * 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)));
+}
+
diff --git a/contrib/tcpdump/print-llc.c b/contrib/tcpdump/print-llc.c
index 78b8631..6bdf599 100644
--- a/contrib/tcpdump/print-llc.c
+++ b/contrib/tcpdump/print-llc.c
@@ -20,20 +20,19 @@
*
* Code by Matt Thomas, Digital Equipment Corporation
* with an awful lot of hacking by Jeffrey Mogul, DECWRL
- *
- * $FreeBSD$
*/
-#define NETDISSECT_REWORKED
+/* \summary: IEEE 802.2 LLC printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.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"
#include "llc.h"
#include "ethertype.h"
@@ -140,23 +139,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(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen,
- const u_char *esrc, const u_char *edst, u_short *extracted_ethertype)
+ const struct lladdr_info *src, const struct lladdr_info *dst)
{
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 || length < 3) {
+ if (caplen < 3) {
ND_PRINT((ndo, "[|llc]"));
- ND_DEFAULTPRINT((u_char *)p, caplen);
- return (1);
+ 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;
@@ -174,15 +181,21 @@ llc_print(netdissect_options *ndo, 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 || length < 4) {
+ if (caplen < 4) {
ND_PRINT((ndo, "[|llc]"));
- ND_DEFAULTPRINT((u_char *)p, caplen);
- return (1);
+ 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);
}
/*
@@ -190,6 +203,7 @@ llc_print(netdissect_options *ndo, 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) {
@@ -212,7 +226,7 @@ llc_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen,
ND_PRINT((ndo, "IPX 802.3: "));
ipx_print(ndo, p, length);
- return (1);
+ return (0); /* no LLC header */
}
dsap = dsap_field & ~LLC_IG;
@@ -234,21 +248,47 @@ llc_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen,
}
}
+ /*
+ * 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(ndo, p+3, length-3);
- return (1);
+ stp_print(ndo, p, length);
+ return (hdrlen);
}
if (ssap == LLCSAP_IP && dsap == LLCSAP_IP &&
control == LLC_UI) {
- if (caplen < 4 || length < 4) {
- ND_PRINT((ndo, "[|llc]"));
- ND_DEFAULTPRINT((u_char *)p, caplen);
- return (1);
- }
- ip_print(ndo, 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 &&
@@ -257,17 +297,15 @@ llc_print(netdissect_options *ndo, 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 (ndo->ndo_eflag)
ND_PRINT((ndo, "IPX 802.2: "));
- ipx_print(ndo, 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)) {
/*
@@ -280,58 +318,35 @@ llc_print(netdissect_options *ndo, 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;
- } else {
- p += 4;
- length -= 4;
- }
netbeui_print(ndo, control, p, length);
- return (1);
+ return (hdrlen);
}
#endif
if (ssap == LLCSAP_ISONS && dsap == LLCSAP_ISONS
&& control == LLC_UI) {
- isoclns_print(ndo, 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(ndo, p+3, length-3, caplen-3, 2);
- if (ret)
- return (ret);
+ isoclns_print(ndo, p, length, caplen);
+ return (hdrlen);
}
if (!ndo->ndo_eflag) {
if (ssap == dsap) {
- if (esrc == NULL || edst == NULL)
+ if (src == NULL || dst == NULL)
ND_PRINT((ndo, "%s ", tok2str(llc_values, "Unknown DSAP 0x%02x", dsap)));
else
ND_PRINT((ndo, "%s > %s %s ",
- etheraddr_string(ndo, esrc),
- etheraddr_string(ndo, edst),
+ (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)
+ 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)));
else
ND_PRINT((ndo, "%s %s > %s %s ",
- etheraddr_string(ndo, esrc),
+ (src->addr_string)(ndo, src->addr),
tok2str(llc_values, "Unknown SSAP 0x%02x", ssap),
- etheraddr_string(ndo, edst),
+ (dst->addr_string)(ndo, dst->addr),
tok2str(llc_values, "Unknown DSAP 0x%02x", dsap)));
}
}
@@ -340,13 +355,31 @@ llc_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen,
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 + 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) {
- ND_PRINT((ndo, ": %02x %02x", p[1], p[2]));
+ 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 {
@@ -355,20 +388,38 @@ llc_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen,
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 {
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));
}
}
- 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(netdissect_options *ndo, 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)
{
uint32_t orgcode;
register u_short et;
@@ -381,21 +432,17 @@ snap_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen,
et = EXTRACT_16BITS(p + 3);
if (ndo->ndo_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;
- }
- }
- ND_PRINT((ndo, "oui %s (0x%06x), %s %s (0x%04x): ",
+ /*
+ * 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;
@@ -410,7 +457,7 @@ snap_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen,
* Cisco hardware; the protocol ID is
* an Ethernet protocol type.
*/
- ret = ethertype_print(ndo, et, p, length, caplen);
+ ret = ethertype_print(ndo, et, p, length, caplen, src, dst);
if (ret)
return (ret);
break;
@@ -425,7 +472,7 @@ snap_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen,
* but used 0x000000 and an Ethernet
* packet type for AARP packets.
*/
- ret = ethertype_print(ndo, et, p, length, caplen);
+ ret = ethertype_print(ndo, et, p, length, caplen, src, dst);
if (ret)
return (ret);
}
@@ -524,6 +571,33 @@ snap_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen,
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:
diff --git a/contrib/tcpdump/print-lldp.c b/contrib/tcpdump/print-lldp.c
index ce3c093..730b36f 100644
--- a/contrib/tcpdump/print-lldp.c
+++ b/contrib/tcpdump/print-lldp.c
@@ -12,23 +12,22 @@
* 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>
*/
-#define NETDISSECT_REWORKED
+/* \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 "interface.h"
+#include "netdissect.h"
#include "extract.h"
#include "addrtoname.h"
#include "af.h"
@@ -602,6 +601,14 @@ static const struct tok lldp_evb_mode_values[]={
#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)
@@ -915,6 +922,40 @@ 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.
*/
@@ -1279,15 +1320,15 @@ lldp_network_addr_print(netdissect_options *ndo, const u_char *tptr, u_int len)
case AFNUM_INET:
if (len < 4)
return NULL;
+ /* 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;
@@ -1574,6 +1615,9 @@ lldp_print(netdissect_options *ndo,
case OUI_IEEE_8023_PRIVATE:
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(ndo, tptr, tlv_len);
break;
diff --git a/contrib/tcpdump/print-lmp.c b/contrib/tcpdump/print-lmp.c
index 904dd71..1c7710c 100644
--- a/contrib/tcpdump/print-lmp.c
+++ b/contrib/tcpdump/print-lmp.c
@@ -10,21 +10,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
*/
-#define NETDISSECT_REWORKED
+/* \summary: Link Management Protocol (LMP) printer */
+
+/* specification: RFC 4204 */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
#include "addrtoname.h"
#include "gmpls.h"
@@ -459,14 +460,12 @@ lmp_print(netdissect_options *ndo,
ipaddr_string(ndo, obj_tptr),
EXTRACT_32BITS(obj_tptr)));
break;
-#ifdef INET6
case LMP_CTYPE_IPV6_LOC:
case LMP_CTYPE_IPV6_RMT:
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:
ND_PRINT((ndo, "\n\t Link ID: %u (0x%08x)",
@@ -551,9 +550,7 @@ lmp_print(netdissect_options *ndo,
EXTRACT_32BITS(obj_tptr+8)));
break;
-#ifdef INET6
case LMP_CTYPE_IPV6:
-#endif
case LMP_CTYPE_UNMD:
default:
hexdump=TRUE;
@@ -620,9 +617,7 @@ lmp_print(netdissect_options *ndo,
}
break;
-#ifdef INET6
case LMP_CTYPE_IPV6:
-#endif
default:
hexdump=TRUE;
}
@@ -709,9 +704,7 @@ lmp_print(netdissect_options *ndo,
offset+=8;
}
break;
-#ifdef INET6
case LMP_CTYPE_IPV6:
-#endif
default:
hexdump=TRUE;
}
@@ -729,9 +722,7 @@ lmp_print(netdissect_options *ndo,
offset+=4;
}
break;
-#ifdef INET6
case LMP_CTYPE_IPV6:
-#endif
default:
hexdump=TRUE;
}
@@ -851,7 +842,7 @@ lmp_print(netdissect_options *ndo,
default:
hexdump = TRUE;
- };
+ }
break;
diff --git a/contrib/tcpdump/print-loopback.c b/contrib/tcpdump/print-loopback.c
index 9a74ae6..10f6931 100644
--- a/contrib/tcpdump/print-loopback.c
+++ b/contrib/tcpdump/print-loopback.c
@@ -1,9 +1,4 @@
/*
- * This module implements decoding of the Loopback Protocol, originally
- * defined as the Configuration Testing Protocol. It is based on the following
- * specification:
- * http://www.mit.edu/people/jhawk/ctp.pdf
- *
* Copyright (c) 2014 The TCPDUMP project
* All rights reserved.
*
@@ -30,20 +25,25 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#define NETDISSECT_REWORKED
+/* \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 <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
#include "ether.h"
#include "addrtoname.h"
static const char tstr[] = " [|loopback]";
-static const char cstr[] = " (corrupt)";
#define LOOPBACK_REPLY 1
#define LOOPBACK_FWDDATA 2
@@ -61,7 +61,7 @@ loopback_message_print(netdissect_options *ndo, const u_char *cp, const u_int le
uint16_t function;
if (len < 2)
- goto corrupt;
+ goto invalid;
/* function */
ND_TCHECK2(*cp, 2);
function = EXTRACT_LE_16BITS(cp);
@@ -71,7 +71,7 @@ loopback_message_print(netdissect_options *ndo, const u_char *cp, const u_int le
switch (function) {
case LOOPBACK_REPLY:
if (len < 4)
- goto corrupt;
+ goto invalid;
/* receipt number */
ND_TCHECK2(*cp, 2);
ND_PRINT((ndo, ", receipt number %u", EXTRACT_LE_16BITS(cp)));
@@ -82,7 +82,7 @@ loopback_message_print(netdissect_options *ndo, const u_char *cp, const u_int le
break;
case LOOPBACK_FWDDATA:
if (len < 8)
- goto corrupt;
+ goto invalid;
/* forwarding address */
ND_TCHECK2(*cp, ETHER_ADDR_LEN);
ND_PRINT((ndo, ", forwarding address %s", etheraddr_string(ndo, cp)));
@@ -97,8 +97,8 @@ loopback_message_print(netdissect_options *ndo, const u_char *cp, const u_int le
}
return;
-corrupt:
- ND_PRINT((ndo, "%s", cstr));
+invalid:
+ ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*cp, ep - cp);
return;
trunc:
@@ -113,7 +113,7 @@ loopback_print(netdissect_options *ndo, const u_char *cp, const u_int len)
ND_PRINT((ndo, "Loopback"));
if (len < 2)
- goto corrupt;
+ goto invalid;
/* skipCount */
ND_TCHECK2(*cp, 2);
skipCount = EXTRACT_LE_16BITS(cp);
@@ -122,12 +122,12 @@ loopback_print(netdissect_options *ndo, const u_char *cp, const u_int len)
if (skipCount % 8)
ND_PRINT((ndo, " (bogus)"));
if (skipCount > len - 2)
- goto corrupt;
+ goto invalid;
loopback_message_print(ndo, cp + skipCount, len - 2 - skipCount);
return;
-corrupt:
- ND_PRINT((ndo, "%s", cstr));
+invalid:
+ ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*cp, ep - cp);
return;
trunc:
diff --git a/contrib/tcpdump/print-lspping.c b/contrib/tcpdump/print-lspping.c
index 888adfa..4d260db 100644
--- a/contrib/tcpdump/print-lspping.c
+++ b/contrib/tcpdump/print-lspping.c
@@ -13,20 +13,23 @@
* Original code by Hannes Gredler (hannes@juniper.net)
*/
-#define NETDISSECT_REWORKED
+/* \summary: MPLS LSP PING printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
#include "addrtoname.h"
#include "l2vpn.h"
#include "oui.h"
+/* RFC 4349 */
+
/*
* LSPPING common header
*
@@ -57,7 +60,7 @@
struct lspping_common_header {
uint8_t version[2];
- uint8_t reserved[2];
+ uint8_t global_flags[2];
uint8_t msg_type;
uint8_t reply_mode;
uint8_t return_code;
@@ -100,6 +103,7 @@ 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"},
};
@@ -126,9 +130,12 @@ struct lspping_tlv_header {
#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 */
@@ -148,17 +155,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"},
@@ -169,8 +181,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}
@@ -208,44 +220,6 @@ struct lspping_tlv_targetfec_subtlv_ldp_ipv6_t {
};
/*
- * 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 {
- uint8_t sender_id [4];
- 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
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Sender identifier |
- * | (16 octets) |
- * | |
- * | |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | IPv6 prefix |
- * | (16 octets) |
- * | |
- * | |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Prefix Length | Must Be Zero |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- */
-struct lspping_tlv_targetfec_subtlv_bgp_ipv6_t {
- uint8_t sender_id [16];
- uint8_t prefix [16];
- uint8_t prefix_len;
-};
-
-/*
* 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
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
@@ -350,7 +324,7 @@ 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 |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
@@ -358,8 +332,8 @@ struct lspping_tlv_targetfec_subtlv_l3vpn_ipv6_t {
*/
struct lspping_tlv_targetfec_subtlv_l2vpn_endpt_t {
uint8_t rd [8];
- uint8_t sender_ce_id [2];
- uint8_t receiver_ce_id [2];
+ uint8_t sender_ve_id [2];
+ uint8_t receiver_ve_id [2];
uint8_t encapsulation[2];
};
@@ -368,15 +342,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 {
+struct lspping_tlv_targetfec_subtlv_fec_128_pw_old {
uint8_t remote_pe_address [4];
- uint8_t vc_id [4];
- uint8_t encapsulation[2];
+ uint8_t pw_id [4];
+ uint8_t pw_type[2];
};
/*
@@ -386,16 +360,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_l2vpn_vcid_t {
+struct lspping_tlv_targetfec_subtlv_fec_128_pw {
uint8_t sender_pe_address [4];
uint8_t remote_pe_address [4];
- uint8_t vc_id [4];
- uint8_t encapsulation[2];
+ 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_bgp_ipv6_t {
+ uint8_t prefix [16];
+ uint8_t prefix_len;
};
/*
@@ -408,7 +411,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) .
@@ -423,10 +426,25 @@ 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 {
uint8_t mtu [2];
uint8_t address_type;
- uint8_t res;
+ 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];
};
@@ -434,25 +452,35 @@ struct lspping_tlv_downstream_map_ipv4_t {
struct lspping_tlv_downstream_map_ipv6_t {
uint8_t mtu [2];
uint8_t address_type;
- uint8_t res;
+ 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 {
- uint8_t hash_key_type;
+ 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}
};
@@ -464,14 +492,17 @@ lspping_print(netdissect_options *ndo,
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;
+ 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;
@@ -483,14 +514,16 @@ lspping_print(netdissect_options *ndo,
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;
+ if (len < sizeof(const struct lspping_common_header))
+ goto tooshort;
ND_TCHECK(*lspping_com_header);
/*
@@ -565,7 +598,10 @@ lspping_print(netdissect_options *ndo,
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 ? */
ND_TCHECK2(*tptr, sizeof(struct lspping_tlv_header));
@@ -574,15 +610,6 @@ lspping_print(netdissect_options *ndo,
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) {
- ND_PRINT((ndo, "\n\t ERROR: TLV %u bogus size %u",lspping_tlv_type,lspping_tlv_len));
- return;
- }
-
ND_PRINT((ndo, "\n\t %s TLV (%u), length: %u",
tok2str(lspping_tlv_values,
"Unknown",
@@ -590,19 +617,34 @@ lspping_print(netdissect_options *ndo,
lspping_tlv_type,
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 ? */
- ND_TCHECK2(*tptr, lspping_tlv_len);
+ 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 ? */
- ND_TCHECK2(*tptr, sizeof(struct lspping_tlv_header));
+ ND_TCHECK2(*tlv_tptr, sizeof(struct lspping_tlv_header));
subtlv_hexdump=FALSE;
lspping_subtlv_header = (const struct lspping_tlv_header *)tlv_tptr;
@@ -610,8 +652,15 @@ lspping_print(netdissect_options *ndo,
lspping_subtlv_len=EXTRACT_16BITS(lspping_subtlv_header->length);
subtlv_tptr=tlv_tptr+sizeof(struct lspping_tlv_header);
- if (lspping_subtlv_len == 0)
- break;
+ /* 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,
@@ -623,132 +672,185 @@ lspping_print(netdissect_options *ndo,
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;
- 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));
+ /* 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;
- 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));
+ /* 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;
- ND_PRINT((ndo, "\n\t %s/%u, sender-id %s",
- ipaddr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv4->prefix),
- subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv4->prefix_len,
- ipaddr_string(ndo, 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;
- ND_PRINT((ndo, "\n\t %s/%u, sender-id %s",
- ip6addr_string(ndo, subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv6->prefix),
- subtlv_ptr.lspping_tlv_targetfec_subtlv_bgp_ipv6->prefix_len,
- ip6addr_string(ndo, 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;
- 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)));
+ /* 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;
- 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)));
+ /* 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;
- 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));
+ /* 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;
- 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));
+ /* 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;
- ND_PRINT((ndo, "\n\t RD: %s, Sender CE-ID: %u, Receiver CE-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_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;
- ND_PRINT((ndo, "\n\t Remote PE: %s" \
- "\n\t VC-ID: 0x%08x, Encapsulation 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->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;
- ND_PRINT((ndo, "\n\t Sender PE: %s, Remote PE: %s" \
- "\n\t VC-ID: 0x%08x, Encapsulation 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->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:
@@ -761,30 +863,58 @@ lspping_print(netdissect_options *ndo,
"\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 address-type
- * lets recast the tlv_tptr and move on */
+ * 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. */
- 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;
ND_PRINT((ndo, "\n\t MTU: %u, Address-Type: %s (%u)",
- EXTRACT_16BITS(tlv_ptr.lspping_tlv_downstream_map_ipv4->mtu),
+ 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:
+ /* 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(ndo, tlv_ptr.lspping_tlv_downstream_map_ipv4->downstream_ip),
@@ -792,8 +922,37 @@ lspping_print(netdissect_options *ndo,
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:
+ 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(ndo, tlv_ptr.lspping_tlv_downstream_map_ipv6->downstream_ip),
@@ -801,14 +960,24 @@ lspping_print(netdissect_options *ndo,
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:
+ 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(ndo, 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:
@@ -816,37 +985,55 @@ lspping_print(netdissect_options *ndo,
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 */
-
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);
- ND_TCHECK2(*tptr, LSPPING_TLV_BFD_DISCRIMINATOR_LEN);
- ND_PRINT((ndo, "\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:
{
uint32_t vendor_id;
- 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));
+ 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;
@@ -864,6 +1051,7 @@ lspping_print(netdissect_options *ndo,
break;
}
/* do we want to see an additionally tlv hexdump ? */
+ 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);
@@ -872,14 +1060,21 @@ lspping_print(netdissect_options *ndo,
/* 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:
ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
+ return;
}
/*
* Local Variables:
diff --git a/contrib/tcpdump/print-lwapp.c b/contrib/tcpdump/print-lwapp.c
index 5b8683f..bab3219 100644
--- a/contrib/tcpdump/print-lwapp.c
+++ b/contrib/tcpdump/print-lwapp.c
@@ -12,19 +12,20 @@
* LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE.
*
- * Support for the Light Weight Access Point Protocol as per RFC 5412
- *
* Original code by Carles Kishimoto <carles.kishimoto@gmail.com>
*/
-#define NETDISSECT_REWORKED
+/* \summary: Light Weight Access Point Protocol (LWAPP) printer */
+
+/* specification: RFC 5412 */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
#include "addrtoname.h"
diff --git a/contrib/tcpdump/print-lwres.c b/contrib/tcpdump/print-lwres.c
index d78c9a9..ae35280 100644
--- a/contrib/tcpdump/print-lwres.c
+++ b/contrib/tcpdump/print-lwres.c
@@ -27,21 +27,22 @@
* SUCH DAMAGE.
*/
-#define NETDISSECT_REWORKED
+/* \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 uint32_t lwres_uint32_t;
@@ -250,7 +251,7 @@ lwres_printbinlen(netdissect_options *ndo,
static int
lwres_printaddr(netdissect_options *ndo,
- lwres_addr_t *ap)
+ const lwres_addr_t *ap)
{
uint16_t l;
const char *p;
@@ -269,14 +270,12 @@ lwres_printaddr(netdissect_options *ndo,
ND_PRINT((ndo, " %s", ipaddr_string(ndo, p)));
p += sizeof(struct in_addr);
break;
-#ifdef INET6
case 2: /* IPv6 */
if (l < 16)
return -1;
ND_PRINT((ndo, " %s", ip6addr_string(ndo, p)));
p += sizeof(struct in6_addr);
break;
-#endif
default:
ND_PRINT((ndo, " %u/", EXTRACT_32BITS(&ap->family)));
for (i = 0; i < l; i++)
@@ -343,9 +342,9 @@ lwres_print(netdissect_options *ndo,
/*
* queries
*/
- lwres_gabnrequest_t *gabn;
- lwres_gnbarequest_t *gnba;
- lwres_grbnrequest_t *grbn;
+ const lwres_gabnrequest_t *gabn;
+ const lwres_gnbarequest_t *gnba;
+ const lwres_grbnrequest_t *grbn;
uint32_t l;
gabn = NULL;
@@ -356,7 +355,7 @@ lwres_print(netdissect_options *ndo,
case LWRES_OPCODE_NOOP:
break;
case LWRES_OPCODE_GETADDRSBYNAME:
- gabn = (lwres_gabnrequest_t *)(np + 1);
+ gabn = (const lwres_gabnrequest_t *)(np + 1);
ND_TCHECK(gabn->namelen);
/* XXX gabn points to packed struct */
s = (const char *)&gabn->namelen +
@@ -390,7 +389,7 @@ lwres_print(netdissect_options *ndo,
s += advance;
break;
case LWRES_OPCODE_GETNAMEBYADDR:
- gnba = (lwres_gnbarequest_t *)(np + 1);
+ gnba = (const lwres_gnbarequest_t *)(np + 1);
ND_TCHECK(gnba->addr);
/* BIND910: not used */
@@ -408,7 +407,7 @@ lwres_print(netdissect_options *ndo,
break;
case LWRES_OPCODE_GETRDATABYNAME:
/* XXX no trace, not tested */
- grbn = (lwres_grbnrequest_t *)(np + 1);
+ grbn = (const lwres_grbnrequest_t *)(np + 1);
ND_TCHECK(grbn->namelen);
/* BIND910: not used */
@@ -442,9 +441,9 @@ lwres_print(netdissect_options *ndo,
/*
* responses
*/
- lwres_gabnresponse_t *gabn;
- lwres_gnbaresponse_t *gnba;
- lwres_grbnresponse_t *grbn;
+ const lwres_gabnresponse_t *gabn;
+ const lwres_gnbaresponse_t *gnba;
+ const lwres_grbnresponse_t *grbn;
uint32_t l, na;
uint32_t i;
@@ -456,7 +455,7 @@ lwres_print(netdissect_options *ndo,
case LWRES_OPCODE_NOOP:
break;
case LWRES_OPCODE_GETADDRSBYNAME:
- gabn = (lwres_gabnresponse_t *)(np + 1);
+ gabn = (const lwres_gabnresponse_t *)(np + 1);
ND_TCHECK(gabn->realnamelen);
/* XXX gabn points to packed struct */
s = (const char *)&gabn->realnamelen +
@@ -489,14 +488,14 @@ lwres_print(netdissect_options *ndo,
/* addrs */
na = EXTRACT_16BITS(&gabn->naddrs);
for (i = 0; i < na; i++) {
- advance = lwres_printaddr(ndo, (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);
+ gnba = (const lwres_gnbaresponse_t *)(np + 1);
ND_TCHECK(gnba->realnamelen);
/* XXX gnba points to packed struct */
s = (const char *)&gnba->realnamelen +
@@ -527,7 +526,7 @@ lwres_print(netdissect_options *ndo,
break;
case LWRES_OPCODE_GETRDATABYNAME:
/* XXX no trace, not tested */
- grbn = (lwres_grbnresponse_t *)(np + 1);
+ grbn = (const lwres_grbnresponse_t *)(np + 1);
ND_TCHECK(grbn->nsigs);
/* BIND910: not used */
@@ -543,7 +542,7 @@ lwres_print(netdissect_options *ndo,
EXTRACT_16BITS(&grbn->rdclass))));
}
ND_PRINT((ndo, " TTL "));
- relts_print(ndo, EXTRACT_32BITS(&grbn->ttl));
+ unsigned_relts_print(ndo, EXTRACT_32BITS(&grbn->ttl));
ND_PRINT((ndo, " %u/%u", EXTRACT_16BITS(&grbn->nrdatas),
EXTRACT_16BITS(&grbn->nsigs)));
diff --git a/contrib/tcpdump/print-m3ua.c b/contrib/tcpdump/print-m3ua.c
index 33f8777..1f974b2 100644
--- a/contrib/tcpdump/print-m3ua.c
+++ b/contrib/tcpdump/print-m3ua.c
@@ -22,20 +22,20 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#define NETDISSECT_REWORKED
+/* \summary: Message Transfer Part 3 (MTP3) User Adaptation Layer (M3UA) printer */
+
+/* RFC 4666 */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
static const char tstr[] = " [|m3ua]";
-static const char cstr[] = " (corrupt)";
-
-/* RFC 4666 */
#define M3UA_REL_1_0 1
@@ -218,7 +218,7 @@ tag_value_print(netdissect_options *ndo,
case M3UA_PARAM_CORR_ID:
/* buf and size don't include the header */
if (size < 4)
- goto corrupt;
+ goto invalid;
ND_TCHECK2(*buf, size);
ND_PRINT((ndo, "0x%08x", EXTRACT_32BITS(buf)));
break;
@@ -229,8 +229,8 @@ tag_value_print(netdissect_options *ndo,
}
return;
-corrupt:
- ND_PRINT((ndo, "%s", cstr));
+invalid:
+ ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*buf, size);
return;
trunc:
@@ -259,7 +259,7 @@ m3ua_tags_print(netdissect_options *ndo,
while (p < buf + size) {
if (p + sizeof(struct m3ua_param_header) > buf + size)
- goto corrupt;
+ goto invalid;
ND_TCHECK2(*p, sizeof(struct m3ua_param_header));
/* Parameter Tag */
hdr_tag = EXTRACT_16BITS(p);
@@ -267,7 +267,7 @@ m3ua_tags_print(netdissect_options *ndo,
/* Parameter Length */
hdr_len = EXTRACT_16BITS(p + 2);
if (hdr_len < sizeof(struct m3ua_param_header))
- goto corrupt;
+ goto invalid;
/* Parameter Value */
align = (p + hdr_len - buf) % 4;
align = align ? 4 - align : 0;
@@ -277,8 +277,8 @@ m3ua_tags_print(netdissect_options *ndo,
}
return;
-corrupt:
- ND_PRINT((ndo, "%s", cstr));
+invalid:
+ ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*buf, size);
return;
trunc:
@@ -305,7 +305,7 @@ m3ua_print(netdissect_options *ndo,
/* size includes the header */
if (size < sizeof(struct m3ua_common_header))
- goto corrupt;
+ goto invalid;
ND_TCHECK(*hdr);
if (hdr->v != M3UA_REL_1_0)
return;
@@ -329,8 +329,8 @@ m3ua_print(netdissect_options *ndo,
m3ua_tags_print(ndo, buf + sizeof(struct m3ua_common_header), EXTRACT_32BITS(&hdr->len) - sizeof(struct m3ua_common_header));
return;
-corrupt:
- ND_PRINT((ndo, "%s", cstr));
+invalid:
+ ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*buf, size);
return;
trunc:
diff --git a/contrib/tcpdump/print-medsa.c b/contrib/tcpdump/print-medsa.c
new file mode 100644
index 0000000..4895fd9
--- /dev/null
+++ b/contrib/tcpdump/print-medsa.c
@@ -0,0 +1,196 @@
+/*
+ * 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:
+ */
+
diff --git a/contrib/tcpdump/print-mobile.c b/contrib/tcpdump/print-mobile.c
index df412ee..6d31648 100644
--- a/contrib/tcpdump/print-mobile.c
+++ b/contrib/tcpdump/print-mobile.c
@@ -36,16 +36,17 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#define NETDISSECT_REWORKED
+/* \summary: IPv4 mobility printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.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)
@@ -94,7 +95,7 @@ mobile_print(netdissect_options *ndo, const u_char *bp, u_int length)
ND_PRINT((ndo, "> %s ", ipaddr_string(ndo, &mob->odst)));
ND_PRINT((ndo, "(oproto=%d)", proto>>8));
}
- vec[0].ptr = (const uint8_t *)(void *)mob;
+ vec[0].ptr = (const uint8_t *)(const void *)mob;
vec[0].len = osp ? 12 : 8;
if (in_cksum(vec, 1)!=0) {
ND_PRINT((ndo, " (bad checksum %d)", crc));
diff --git a/contrib/tcpdump/print-mobility.c b/contrib/tcpdump/print-mobility.c
index b6fa61e..71cc85b 100644
--- a/contrib/tcpdump/print-mobility.c
+++ b/contrib/tcpdump/print-mobility.c
@@ -27,18 +27,20 @@
* SUCH DAMAGE.
*/
-#define NETDISSECT_REWORKED
+/* \summary: IPv6 mobility printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#ifdef INET6
-#include <tcpdump-stdinc.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 {
@@ -71,6 +73,18 @@ struct ip6_mobility {
#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 */
@@ -82,11 +96,6 @@ static const unsigned ip6m_hdrlen[IP6M_MAX + 1] = {
IP6M_MINLEN + 16, /* IP6M_BINDING_ERROR */
};
-/* XXX: unused */
-#define IP6MOPT_BU_MINLEN 10
-#define IP6MOPT_BA_MINLEN 13
-#define IP6MOPT_BR_MINLEN 2
-
/* Mobility Header Options */
#define IP6MOPT_MINLEN 2
#define IP6MOPT_PAD1 0x0 /* Pad1 */
@@ -100,7 +109,7 @@ static const unsigned ip6m_hdrlen[IP6M_MAX + 1] = {
#define IP6MOPT_AUTH 0x5 /* Binding Authorization Data */
#define IP6MOPT_AUTH_MINLEN 12
-static void
+static int
mobility_opt_print(netdissect_options *ndo,
const u_char *bp, const unsigned len)
{
@@ -174,10 +183,10 @@ mobility_opt_print(netdissect_options *ndo,
break;
}
}
- return;
+ return 0;
trunc:
- ND_PRINT((ndo, "[trunc] "));
+ return 1;
}
/*
@@ -192,7 +201,7 @@ mobility_print(netdissect_options *ndo,
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 = ndo->ndo_snapend;
@@ -223,17 +232,15 @@ mobility_print(netdissect_options *ndo,
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:
- ND_PRINT((ndo, "mobility: BRR"));
hlen = IP6M_MINLEN;
break;
case IP6M_HOME_TEST_INIT:
case IP6M_CAREOF_TEST_INIT:
- ND_PRINT((ndo, "mobility: %soTI",
- type == IP6M_HOME_TEST_INIT ? "H" : "C"));
hlen = IP6M_MINLEN;
- if (ndo->ndo_vflag) {
+ 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",
@@ -244,12 +251,10 @@ mobility_print(netdissect_options *ndo,
break;
case IP6M_HOME_TEST:
case IP6M_CAREOF_TEST:
- ND_PRINT((ndo, "mobility: %soT",
- type == IP6M_HOME_TEST ? "H" : "C"));
ND_TCHECK(mh->ip6m_data16[0]);
ND_PRINT((ndo, " nonce id=0x%x", EXTRACT_16BITS(&mh->ip6m_data16[0])));
hlen = IP6M_MINLEN;
- if (ndo->ndo_vflag) {
+ if (ndo->ndo_vflag) {
ND_TCHECK2(*mh, hlen + 8);
ND_PRINT((ndo, " %s Init Cookie=%08x:%08x",
type == IP6M_HOME_TEST ? "Home" : "Care-of",
@@ -257,7 +262,7 @@ mobility_print(netdissect_options *ndo,
EXTRACT_32BITS(&bp[hlen + 4])));
}
hlen += 8;
- if (ndo->ndo_vflag) {
+ if (ndo->ndo_vflag) {
ND_TCHECK2(*mh, hlen + 8);
ND_PRINT((ndo, " %s Keygen Token=%08x:%08x",
type == IP6M_HOME_TEST ? "Home" : "Care-of",
@@ -267,7 +272,6 @@ mobility_print(netdissect_options *ndo,
hlen += 8;
break;
case IP6M_BINDING_UPDATE:
- ND_PRINT((ndo, "mobility: BU"));
ND_TCHECK(mh->ip6m_data16[0]);
ND_PRINT((ndo, " seq#=%u", EXTRACT_16BITS(&mh->ip6m_data16[0])));
hlen = IP6M_MINLEN;
@@ -292,7 +296,6 @@ mobility_print(netdissect_options *ndo,
hlen += 2;
break;
case IP6M_BINDING_ACK:
- ND_PRINT((ndo, "mobility: BA"));
ND_TCHECK(mh->ip6m_data8[0]);
ND_PRINT((ndo, " status=%u", mh->ip6m_data8[0]));
if (mh->ip6m_data8[1] & 0x80)
@@ -308,7 +311,6 @@ mobility_print(netdissect_options *ndo,
hlen += 2;
break;
case IP6M_BINDING_ERROR:
- ND_PRINT((ndo, "mobility: BE"));
ND_TCHECK(mh->ip6m_data8[0]);
ND_PRINT((ndo, " status=%u", mh->ip6m_data8[0]));
/* Reserved */
@@ -318,17 +320,17 @@ mobility_print(netdissect_options *ndo,
hlen += 16;
break;
default:
- ND_PRINT((ndo, "mobility: type-#%u len=%u", type, mh->ip6m_len));
+ ND_PRINT((ndo, " len=%u", mh->ip6m_len));
return(mhlen);
break;
}
- if (ndo->ndo_vflag)
- mobility_opt_print(ndo, &bp[hlen], mhlen - hlen);
+ if (ndo->ndo_vflag)
+ if (mobility_opt_print(ndo, &bp[hlen], mhlen - hlen))
+ goto trunc;;
return(mhlen);
trunc:
- ND_PRINT((ndo, "[|MOBILITY]"));
+ ND_PRINT((ndo, "%s", tstr));
return(mhlen);
}
-#endif /* INET6 */
diff --git a/contrib/tcpdump/print-mpcp.c b/contrib/tcpdump/print-mpcp.c
index 9da3582..1b9a5d7 100644
--- a/contrib/tcpdump/print-mpcp.c
+++ b/contrib/tcpdump/print-mpcp.c
@@ -12,19 +12,18 @@
* 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)
*/
-#define NETDISSECT_REWORKED
+/* \summary: IEEE 802.3ah Multi-Point Control Protocol (MPCP) printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
#define MPCP_TIMESTAMP_LEN 4
diff --git a/contrib/tcpdump/print-mpls.c b/contrib/tcpdump/print-mpls.c
index bc34d50..ba42233 100644
--- a/contrib/tcpdump/print-mpls.c
+++ b/contrib/tcpdump/print-mpls.c
@@ -26,15 +26,16 @@
* SUCH DAMAGE.
*/
-#define NETDISSECT_REWORKED
+/* \summary: Multi-Protocol Label Switching (MPLS) printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.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,6 +68,10 @@ mpls_print(netdissect_options *ndo, const u_char *bp, u_int length)
ND_PRINT((ndo, "MPLS"));
do {
ND_TCHECK2(*p, sizeof(label_entry));
+ if (length < sizeof(label_entry)) {
+ ND_PRINT((ndo, "[|MPLS], length %u", length));
+ return;
+ }
label_entry = EXTRACT_32BITS(p);
ND_PRINT((ndo, "%s(label %u",
(label_stack_depth && ndo->ndo_vflag) ? "\n\t" : " ",
@@ -81,6 +86,7 @@ mpls_print(netdissect_options *ndo, const u_char *bp, u_int length)
ND_PRINT((ndo, ", ttl %u)", MPLS_TTL(label_entry)));
p += sizeof(label_entry);
+ length -= sizeof(label_entry);
} while (!MPLS_STACK(label_entry));
/*
@@ -123,6 +129,11 @@ mpls_print(netdissect_options *ndo, 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:
@@ -175,22 +186,22 @@ mpls_print(netdissect_options *ndo, const u_char *bp, u_int length)
*/
if (pt == PT_UNKNOWN) {
if (!ndo->ndo_suppress_default_print)
- ND_DEFAULTPRINT(p, length - (p - bp));
+ ND_DEFAULTPRINT(p, length);
return;
}
ND_PRINT((ndo, ndo->ndo_vflag ? "\n\t" : " "));
switch (pt) {
case PT_IPV4:
- ip_print(ndo, p, length - (p - bp));
+ ip_print(ndo, p, length);
break;
case PT_IPV6:
- ip6_print(ndo, p, length - (p - bp));
+ ip6_print(ndo, p, length);
break;
case PT_OSI:
- isoclns_print(ndo, p, length - (p - bp), length - (p - bp));
+ isoclns_print(ndo, p, length, length);
break;
default:
diff --git a/contrib/tcpdump/print-mptcp.c b/contrib/tcpdump/print-mptcp.c
index f85f1d2..e757ea4 100644
--- a/contrib/tcpdump/print-mptcp.c
+++ b/contrib/tcpdump/print-mptcp.c
@@ -32,14 +32,17 @@
* SUCH DAMAGE.
*/
-#define NETDISSECT_REWORKED
+/* \summary: Multipath TCP (MPTCP) printer */
+
+/* specification: RFC 6824 */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
#include "addrtoname.h"
@@ -173,7 +176,7 @@ static int
mp_capable_print(netdissect_options *ndo,
const u_char *opt, u_int opt_len, u_char flags)
{
- struct mp_capable *mpc = (struct mp_capable *) opt;
+ 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))
@@ -197,7 +200,7 @@ static int
mp_join_print(netdissect_options *ndo,
const u_char *opt, u_int opt_len, u_char flags)
{
- struct mp_join *mpj = (struct mp_join *) opt;
+ 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)) &&
@@ -233,7 +236,7 @@ mp_join_print(netdissect_options *ndo,
return 1;
}
-static u_int mp_dss_len(struct mp_dss *m, int csum)
+static u_int mp_dss_len(const struct mp_dss *m, int csum)
{
u_int len;
@@ -265,7 +268,7 @@ static int
mp_dss_print(netdissect_options *ndo,
const u_char *opt, u_int opt_len, u_char flags)
{
- struct mp_dss *mdss = (struct mp_dss *) opt;
+ 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)
@@ -310,7 +313,7 @@ static int
add_addr_print(netdissect_options *ndo,
const u_char *opt, u_int opt_len, u_char flags _U_)
{
- struct mp_add_addr *add_addr = (struct mp_add_addr *) opt;
+ 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) &&
@@ -325,9 +328,7 @@ add_addr_print(netdissect_options *ndo,
ND_PRINT((ndo, ":%u", EXTRACT_16BITS(add_addr->u.v4.port)));
break;
case 6:
-#ifdef INET6
ND_PRINT((ndo, " %s", ip6addr_string(ndo, add_addr->u.v6.addr)));
-#endif
if (opt_len == 22)
ND_PRINT((ndo, ":%u", EXTRACT_16BITS(add_addr->u.v6.port)));
break;
@@ -342,8 +343,8 @@ static int
remove_addr_print(netdissect_options *ndo,
const u_char *opt, u_int opt_len, u_char flags _U_)
{
- struct mp_remove_addr *remove_addr = (struct mp_remove_addr *) opt;
- uint8_t *addr_id = &remove_addr->addrs_id;
+ 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;
@@ -359,7 +360,7 @@ static int
mp_prio_print(netdissect_options *ndo,
const u_char *opt, u_int opt_len, u_char flags _U_)
{
- struct mp_prio *mpp = (struct mp_prio *) opt;
+ const struct mp_prio *mpp = (const struct mp_prio *) opt;
if (opt_len != 3 && opt_len != 4)
return 0;
@@ -415,13 +416,13 @@ int
mptcp_print(netdissect_options *ndo,
const u_char *cp, u_int len, u_char flags)
{
- struct mptcp_option *opt;
+ const struct mptcp_option *opt;
u_int subtype;
if (len < 3)
return 0;
- opt = (struct mptcp_option *) cp;
+ 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));
diff --git a/contrib/tcpdump/print-msdp.c b/contrib/tcpdump/print-msdp.c
index fb802b5..50bafb0 100644
--- a/contrib/tcpdump/print-msdp.c
+++ b/contrib/tcpdump/print-msdp.c
@@ -16,14 +16,15 @@
* FOR A PARTICULAR PURPOSE.
*/
-#define NETDISSECT_REWORKED
+/* \summary: Multicast Source Discovery Protocol (MSDP) printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "extract.h"
diff --git a/contrib/tcpdump/print-msnlb.c b/contrib/tcpdump/print-msnlb.c
index fcd0006..5264da4 100644
--- a/contrib/tcpdump/print-msnlb.c
+++ b/contrib/tcpdump/print-msnlb.c
@@ -26,14 +26,15 @@
* SUCH DAMAGE.
*/
-#define NETDISSECT_REWORKED
+/* \summary: MS Network Load Balancing's (NLB) heartbeat printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "extract.h"
@@ -51,7 +52,7 @@ 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,",
diff --git a/contrib/tcpdump/print-nflog.c b/contrib/tcpdump/print-nflog.c
index 95da4cb..41cbf78 100644
--- a/contrib/tcpdump/print-nflog.c
+++ b/contrib/tcpdump/print-nflog.c
@@ -25,23 +25,24 @@
* DAMAGE.
*/
-#define NETDISSECT_REWORKED
+/* \summary: DLT_NFLOG printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#if defined(DLT_NFLOG) && defined(HAVE_PCAP_NFLOG_H)
#include <pcap/nflog.h>
static const struct tok nflog_values[] = {
{ AF_INET, "IPv4" },
-#ifdef INET6
+#ifdef AF_INET6
{ AF_INET6, "IPv6" },
-#endif /*INET6*/
+#endif /*AF_INET6*/
{ 0, NULL }
};
@@ -81,7 +82,7 @@ nflog_if_print(netdissect_options *ndo,
return h_size;
}
- if (!(hdr->nflog_version) == 0) {
+ if (hdr->nflog_version != 0) {
ND_PRINT((ndo, "version %u (unknown)", hdr->nflog_version));
return h_size;
}
diff --git a/contrib/tcpdump/print-nfs.c b/contrib/tcpdump/print-nfs.c
index d08fd95..a71e068 100644
--- a/contrib/tcpdump/print-nfs.c
+++ b/contrib/tcpdump/print-nfs.c
@@ -17,21 +17,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$
*/
-#define NETDISSECT_REWORKED
+/* \summary: Network File System (NFS) 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"
@@ -39,9 +38,7 @@
#include "nfsfh.h"
#include "ip.h"
-#ifdef INET6
#include "ip6.h"
-#endif
#include "rpc_auth.h"
#include "rpc_msg.h"
@@ -57,7 +54,7 @@ static const uint32_t *parse_post_op_attr(netdissect_options *, const uint32_t *
/*
* Mapping of old NFS Version 2 RPC numbers to generic numbers.
*/
-uint32_t nfsv3_procid[NFS_NPROCS] = {
+static uint32_t nfsv3_procid[NFS_NPROCS] = {
NFSPROC_NULL,
NFSPROC_GETATTR,
NFSPROC_SETATTR,
@@ -205,33 +202,24 @@ static void
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;
+ 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;
+ ip6 = (const struct ip6_hdr *)bp;
strlcpy(srcaddr, ip6addr_string(ndo, &ip6->ip6_src),
sizeof(srcaddr));
strlcpy(dstaddr, ip6addr_string(ndo, &ip6->ip6_dst),
sizeof(dstaddr));
break;
-#endif
default:
strlcpy(srcaddr, "?", sizeof(srcaddr));
strlcpy(dstaddr, "?", sizeof(dstaddr));
@@ -436,7 +424,7 @@ parsereq(netdissect_options *ndo,
/*
* find the start of the req data (if we captured it)
*/
- dp = (uint32_t *)&rp->rm_call.cb_cred;
+ dp = (const uint32_t *)&rp->rm_call.cb_cred;
ND_TCHECK(dp[1]);
len = EXTRACT_32BITS(&dp[1]);
if (len < length) {
@@ -498,7 +486,7 @@ parsefn(netdissect_options *ndo,
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);
ND_PRINT((ndo, "\""));
@@ -665,12 +653,12 @@ nfsreq_print_noaddr(netdissect_options *ndo,
break;
case NFSPROC_SYMLINK:
- if ((dp = parsereq(ndo, rp, length)) != 0 &&
- (dp = parsefhn(ndo, dp, v3)) != 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)) == 0)
+ if (v3 && (dp = parse_sattr3(ndo, dp, &sa3)) == NULL)
break;
- if (parsefn(ndo, dp) == 0)
+ if (parsefn(ndo, dp) == NULL)
break;
if (v3 && ndo->ndo_vflag)
print_sattr3(ndo, &sa3, ndo->ndo_vflag);
@@ -679,12 +667,12 @@ nfsreq_print_noaddr(netdissect_options *ndo,
break;
case NFSPROC_MKNOD:
- if ((dp = parsereq(ndo, rp, length)) != 0 &&
- (dp = parsefhn(ndo, dp, v3)) != 0) {
+ 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(ndo, dp, &sa3)) == 0)
+ if ((dp = parse_sattr3(ndo, dp, &sa3)) == NULL)
break;
ND_PRINT((ndo, " %s", tok2str(type2str, "unk-ft %d", type)));
if (ndo->ndo_vflag && (type == NFCHR || type == NFBLK)) {
@@ -853,13 +841,8 @@ nfs_printfh(netdissect_options *ndo,
struct xid_map_entry {
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
uint32_t proc; /* call proc number (host order) */
uint32_t vers; /* program version (host order) */
};
@@ -872,32 +855,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(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 (!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);
}
@@ -913,13 +892,11 @@ xid_map_enter(netdissect_options *ndo,
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;
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);
@@ -935,13 +912,12 @@ xid_map_find(const struct sunrpc_msg *rp, const u_char *bp, uint32_t *proc,
{
int i;
struct xid_map_entry *xmep;
- uint32_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 {
@@ -958,7 +934,6 @@ xid_map_find(const struct sunrpc_msg *rp, const u_char *bp, uint32_t *proc,
cmp = 0;
}
break;
-#ifdef INET6
case 6:
if (UNALIGNED_MEMCMP(&ip6->ip6_src, &xmep->server,
sizeof(ip6->ip6_src)) != 0 ||
@@ -967,7 +942,6 @@ xid_map_find(const struct sunrpc_msg *rp, const u_char *bp, uint32_t *proc,
cmp = 0;
}
break;
-#endif
default:
cmp = 0;
break;
@@ -1041,7 +1015,7 @@ parserep(netdissect_options *ndo,
}
/* successful return */
ND_TCHECK2(*dp, sizeof(astat));
- return ((uint32_t *) (sizeof(astat) + ((char *)dp)));
+ return ((const uint32_t *) (sizeof(astat) + ((const char *)dp)));
trunc:
return (0);
}
@@ -1086,7 +1060,7 @@ parsefattr(netdissect_options *ndo,
if (v3) {
ND_TCHECK(fap->fa3_size);
ND_PRINT((ndo, " sz %" PRIu64,
- EXTRACT_64BITS((uint32_t *)&fap->fa3_size)));
+ EXTRACT_64BITS((const uint32_t *)&fap->fa3_size)));
} else {
ND_TCHECK(fap->fa2_size);
ND_PRINT((ndo, " sz %d", EXTRACT_32BITS(&fap->fa2_size)));
@@ -1101,9 +1075,9 @@ parsefattr(netdissect_options *ndo,
EXTRACT_32BITS(&fap->fa3_rdev.specdata1),
EXTRACT_32BITS(&fap->fa3_rdev.specdata2)));
ND_PRINT((ndo, " fsid %" PRIx64,
- EXTRACT_64BITS((uint32_t *)&fap->fa3_fsid)));
+ EXTRACT_64BITS((const uint32_t *)&fap->fa3_fsid)));
ND_PRINT((ndo, " fileid %" PRIx64,
- EXTRACT_64BITS((uint32_t *)&fap->fa3_fileid)));
+ 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)));
@@ -1131,7 +1105,7 @@ parsefattr(netdissect_options *ndo,
EXTRACT_32BITS(&fap->fa2_ctime.nfsv2_usec)));
}
}
- return ((const uint32_t *)((unsigned char *)dp +
+ return ((const uint32_t *)((const unsigned char *)dp +
(v3 ? NFSX_V3FATTR : NFSX_V2FATTR)));
trunc:
return (NULL);
@@ -1216,14 +1190,14 @@ parsestatfs(netdissect_options *ndo,
if (v3) {
ND_PRINT((ndo, " tbytes %" PRIu64 " fbytes %" PRIu64 " abytes %" PRIu64,
- EXTRACT_64BITS((uint32_t *)&sfsp->sf_tbytes),
- EXTRACT_64BITS((uint32_t *)&sfsp->sf_fbytes),
- EXTRACT_64BITS((uint32_t *)&sfsp->sf_abytes)));
+ 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((uint32_t *)&sfsp->sf_tfiles),
- EXTRACT_64BITS((uint32_t *)&sfsp->sf_ffiles),
- EXTRACT_64BITS((uint32_t *)&sfsp->sf_afiles),
+ 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 {
@@ -1370,7 +1344,7 @@ parsewccres(netdissect_options *ndo,
if (!(dp = parsestatus(ndo, dp, &er)))
return (0);
- return parse_wcc_data(ndo, dp, verbose) != 0;
+ return parse_wcc_data(ndo, dp, verbose) != NULL;
}
static const uint32_t *
@@ -1401,7 +1375,7 @@ static int
parsefsinfo(netdissect_options *ndo,
const uint32_t *dp)
{
- struct nfsv3_fsinfo *sfp;
+ const struct nfsv3_fsinfo *sfp;
int er;
if (!(dp = parsestatus(ndo, dp, &er)))
@@ -1413,7 +1387,7 @@ parsefsinfo(netdissect_options *ndo,
if (er)
return (1);
- sfp = (struct nfsv3_fsinfo *)dp;
+ 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),
@@ -1425,7 +1399,7 @@ parsefsinfo(netdissect_options *ndo,
ND_PRINT((ndo, " rtmult %u wtmult %u maxfsz %" PRIu64,
EXTRACT_32BITS(&sfp->fs_rtmult),
EXTRACT_32BITS(&sfp->fs_wtmult),
- EXTRACT_64BITS((uint32_t *)&sfp->fs_maxfilesize)));
+ 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)));
@@ -1440,7 +1414,7 @@ parsepathconf(netdissect_options *ndo,
const uint32_t *dp)
{
int er;
- struct nfsv3_pathconf *spp;
+ const struct nfsv3_pathconf *spp;
if (!(dp = parsestatus(ndo, dp, &er)))
return (0);
@@ -1451,7 +1425,7 @@ parsepathconf(netdissect_options *ndo,
if (er)
return (1);
- spp = (struct nfsv3_pathconf *)dp;
+ spp = (const struct nfsv3_pathconf *)dp;
ND_TCHECK(*spp);
ND_PRINT((ndo, " linkmax %u namemax %u %s %s %s %s",
@@ -1602,7 +1576,7 @@ interp_reply(netdissect_options *ndo,
if (!(dp = parserep(ndo, rp, length)))
break;
if (v3) {
- if (parsecreateopres(ndo, dp, ndo->ndo_vflag) != 0)
+ if (parsecreateopres(ndo, dp, ndo->ndo_vflag) != NULL)
return;
} else {
if (parsediropres(ndo, dp) != 0)
@@ -1614,10 +1588,10 @@ interp_reply(netdissect_options *ndo,
if (!(dp = parserep(ndo, rp, length)))
break;
if (v3) {
- if (parsecreateopres(ndo, dp, ndo->ndo_vflag) != 0)
+ if (parsecreateopres(ndo, dp, ndo->ndo_vflag) != NULL)
return;
} else {
- if (parsestatus(ndo, dp, &er) != 0)
+ if (parsestatus(ndo, dp, &er) != NULL)
return;
}
break;
@@ -1625,7 +1599,7 @@ interp_reply(netdissect_options *ndo,
case NFSPROC_MKNOD:
if (!(dp = parserep(ndo, rp, length)))
break;
- if (parsecreateopres(ndo, dp, ndo->ndo_vflag) != 0)
+ if (parsecreateopres(ndo, dp, ndo->ndo_vflag) != NULL)
return;
break;
@@ -1637,7 +1611,7 @@ interp_reply(netdissect_options *ndo,
if (parsewccres(ndo, dp, ndo->ndo_vflag))
return;
} else {
- if (parsestatus(ndo, dp, &er) != 0)
+ if (parsestatus(ndo, dp, &er) != NULL)
return;
}
break;
@@ -1658,7 +1632,7 @@ interp_reply(netdissect_options *ndo,
}
return;
} else {
- if (parsestatus(ndo, dp, &er) != 0)
+ if (parsestatus(ndo, dp, &er) != NULL)
return;
}
break;
@@ -1679,7 +1653,7 @@ interp_reply(netdissect_options *ndo,
return;
}
} else {
- if (parsestatus(ndo, dp, &er) != 0)
+ if (parsestatus(ndo, dp, &er) != NULL)
return;
}
break;
diff --git a/contrib/tcpdump/print-nsh.c b/contrib/tcpdump/print-nsh.c
new file mode 100644
index 0000000..abd722d
--- /dev/null
+++ b/contrib/tcpdump/print-nsh.c
@@ -0,0 +1,185 @@
+/* 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));
+}
+
diff --git a/contrib/tcpdump/print-ntp.c b/contrib/tcpdump/print-ntp.c
index 8603906..0689264 100644
--- a/contrib/tcpdump/print-ntp.c
+++ b/contrib/tcpdump/print-ntp.c
@@ -18,25 +18,23 @@
* 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$
*/
-#define NETDISSECT_REWORKED
+/* \summary: Network Time Protocol (NTP) printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#ifdef HAVE_STRFTIME
#include <time.h>
#endif
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "extract.h"
@@ -209,7 +207,7 @@ ntp_print(netdissect_options *ndo,
register const struct ntpdata *bp;
int mode, version, leapind;
- bp = (struct ntpdata *)cp;
+ bp = (const struct ntpdata *)cp;
ND_TCHECK(bp->status);
@@ -263,7 +261,7 @@ ntp_print(netdissect_options *ndo,
break;
case PRIM_REF:
- if (fn_printn(ndo, (u_char *)&(bp->refid), 4, ndo->ndo_snapend))
+ if (fn_printn(ndo, (const u_char *)&(bp->refid), 4, ndo->ndo_snapend))
goto trunc;
break;
@@ -329,12 +327,12 @@ p_sfix(netdissect_options *ndo,
{
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 */
+ 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));
}
@@ -347,15 +345,15 @@ p_ntp_time(netdissect_options *ndo,
register int32_t i;
register uint32_t uf;
register uint32_t f;
- register float ff;
+ 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 */
+ 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
@@ -384,7 +382,7 @@ p_ntp_delta(netdissect_options *ndo,
register uint32_t u, uf;
register uint32_t ou, ouf;
register uint32_t f;
- register float ff;
+ register double ff;
int signbit;
u = EXTRACT_32BITS(&lfp->int_part);
@@ -422,8 +420,8 @@ p_ntp_delta(netdissect_options *ndo,
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 */
+ 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));
}
diff --git a/contrib/tcpdump/print-null.c b/contrib/tcpdump/print-null.c
index d296089..14df5fd 100644
--- a/contrib/tcpdump/print-null.c
+++ b/contrib/tcpdump/print-null.c
@@ -17,20 +17,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$
*/
-#define NETDISSECT_REWORKED
+/* \summary: BSD loopback device printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <string.h>
-#include "interface.h"
+#include "netdissect.h"
#include "af.h"
/*
@@ -85,7 +84,7 @@ null_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char
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
diff --git a/contrib/tcpdump/print-olsr.c b/contrib/tcpdump/print-olsr.c
index b90eea1..e095ef7 100644
--- a/contrib/tcpdump/print-olsr.c
+++ b/contrib/tcpdump/print-olsr.c
@@ -13,20 +13,21 @@
* 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>
*/
-#define NETDISSECT_REWORKED
+/* \summary: Optimized Link State Routing Protocol (OLSR) printer */
+
+/* specification: RFC 3626 */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "extract.h"
@@ -135,6 +136,26 @@ struct olsr_hna6 {
};
+/** 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)
@@ -167,6 +188,37 @@ struct olsr_lq_neighbor6 {
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.
@@ -182,16 +234,16 @@ 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);
- ND_PRINT((ndo, "\n\t neighbor %s, link-quality %.2lf%%"
- ", neighbor-link-quality %.2lf%%",
+ 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)));
@@ -202,21 +254,20 @@ olsr_print_lq_neighbor4(netdissect_options *ndo,
return (0);
}
-#if INET6
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);
- ND_PRINT((ndo, "\n\t neighbor %s, link-quality %.2lf%%"
- ", neighbor-link-quality %.2lf%%",
+ 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)));
@@ -226,7 +277,6 @@ olsr_print_lq_neighbor6(netdissect_options *ndo,
}
return (0);
}
-#endif /* INET6 */
/*
* print a neighbor list.
@@ -284,7 +334,7 @@ olsr_print(netdissect_options *ndo,
ND_TCHECK2(*tptr, sizeof(struct olsr_common));
- ptr.common = (struct olsr_common *)tptr;
+ ptr.common = (const struct olsr_common *)tptr;
length = min(length, EXTRACT_16BITS(ptr.common->packet_len));
ND_PRINT((ndo, "OLSRv%i, seq 0x%04x, length %u",
@@ -304,17 +354,16 @@ olsr_print(netdissect_options *ndo,
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;
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))
@@ -327,7 +376,7 @@ olsr_print(netdissect_options *ndo,
}
ND_PRINT((ndo, "\n\t%s Message (%#04x), originator %s, ttl %u, hop %u"
- "\n\t vtime %.3lfs, msg-seq 0x%04x, length %u%s",
+ "\n\t vtime %.3fs, msg-seq 0x%04x, length %u%s",
tok2str(olsr_msg_values, "Unknown", msg_type),
msg_type, ip6addr_string(ndo, msgptr.v6->originator),
msgptr.v6->ttl,
@@ -343,9 +392,8 @@ olsr_print(netdissect_options *ndo,
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))
@@ -358,7 +406,7 @@ olsr_print(netdissect_options *ndo,
}
ND_PRINT((ndo, "\n\t%s Message (%#04x), originator %s, ttl %u, hop %u"
- "\n\t vtime %.3lfs, msg-seq 0x%04x, length %u%s",
+ "\n\t vtime %.3fs, msg-seq 0x%04x, length %u%s",
tok2str(olsr_msg_values, "Unknown", msg_type),
msg_type, ipaddr_string(ndo, msgptr.v4->originator),
msgptr.v4->ttl,
@@ -381,8 +429,8 @@ olsr_print(netdissect_options *ndo,
goto trunc;
ND_TCHECK2(*msg_data, sizeof(struct olsr_hello));
- ptr.hello = (struct olsr_hello *)msg_data;
- ND_PRINT((ndo, "\n\t hello-time %.3lfs, MPR willingness %u",
+ 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);
@@ -395,7 +443,7 @@ olsr_print(netdissect_options *ndo,
*/
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);
@@ -423,13 +471,10 @@ olsr_print(netdissect_options *ndo,
if (olsr_print_neighbor(ndo, msg_data, hello_len) == -1)
goto trunc;
} else {
-#if INET6
if (is_ipv6) {
if (olsr_print_lq_neighbor6(ndo, msg_data, hello_len) == -1)
goto trunc;
- } else
-#endif
- {
+ } else {
if (olsr_print_lq_neighbor4(ndo, msg_data, hello_len) == -1)
goto trunc;
}
@@ -446,7 +491,7 @@ olsr_print(netdissect_options *ndo,
goto trunc;
ND_TCHECK2(*msg_data, sizeof(struct olsr_tc));
- ptr.tc = (struct olsr_tc *)msg_data;
+ 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);
@@ -456,13 +501,10 @@ olsr_print(netdissect_options *ndo,
if (olsr_print_neighbor(ndo, msg_data, msg_tlen) == -1)
goto trunc;
} else {
-#if INET6
if (is_ipv6) {
if (olsr_print_lq_neighbor6(ndo, msg_data, msg_tlen) == -1)
goto trunc;
- } else
-#endif
- {
+ } else {
if (olsr_print_lq_neighbor4(ndo, msg_data, msg_tlen) == -1)
goto trunc;
}
@@ -473,21 +515,14 @@ olsr_print(netdissect_options *ndo,
{
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) {
ND_TCHECK2(*msg_data, addr_size);
-#if INET6
ND_PRINT((ndo, "\n\t interface address %s",
is_ipv6 ? ip6addr_string(ndo, msg_data) :
ipaddr_string(ndo, msg_data)));
-#else
- ND_PRINT((ndo, "\n\t interface address %s",
- ipaddr_string(ndo, msg_data)));
-#endif
msg_data += addr_size;
msg_tlen -= addr_size;
@@ -496,18 +531,19 @@ olsr_print(netdissect_options *ndo,
}
case OLSR_HNA_MSG:
- ND_PRINT((ndo, "\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;
ND_TCHECK2(*msg_data, sizeof(struct olsr_hna6));
- hna6 = (struct olsr_hna6 *)msg_data;
+ hna6 = (const struct olsr_hna6 *)msg_data;
ND_PRINT((ndo, "\n\t #%i: %s/%u",
i, ip6addr_string(ndo, hna6->network),
@@ -518,19 +554,57 @@ olsr_print(netdissect_options *ndo,
}
}
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)) {
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 */
- ND_PRINT((ndo, "%s%s/%u",
- col == 0 ? "\n\t " : ", ",
- ipaddr_string(ndo, 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);
@@ -601,12 +675,10 @@ olsr_print(netdissect_options *ndo,
ND_TCHECK2(*msg_data, addr_size + name_entry_len + name_entry_padding);
-#if INET6
if (is_ipv6)
ND_PRINT((ndo, ", address %s, name \"",
ip6addr_string(ndo, msg_data)));
else
-#endif
ND_PRINT((ndo, ", address %s, name \"",
ipaddr_string(ndo, msg_data)));
(void)fn_printn(ndo, msg_data + addr_size, name_entry_len, NULL);
diff --git a/contrib/tcpdump/print-openflow-1.0.c b/contrib/tcpdump/print-openflow-1.0.c
index a36c32f..ce95843 100644
--- a/contrib/tcpdump/print-openflow-1.0.c
+++ b/contrib/tcpdump/print-openflow-1.0.c
@@ -14,7 +14,7 @@
* * 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 malformed or truncated. This way it is possible
+ * 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.
*
@@ -56,14 +56,15 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#define NETDISSECT_REWORKED
+/* \summary: OpenFlow protocol version 1.0 printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
#include "addrtoname.h"
#include "ether.h"
@@ -73,7 +74,6 @@
#include "openflow.h"
static const char tstr[] = " [|openflow]";
-static const char cstr[] = " (corrupt)";
#define OFPT_HELLO 0x00
#define OFPT_ERROR 0x01
@@ -760,7 +760,7 @@ of10_bsn_message_print(netdissect_options *ndo,
uint32_t subtype;
if (len < 4)
- goto corrupt;
+ goto invalid;
/* subtype */
ND_TCHECK2(*cp, 4);
subtype = EXTRACT_32BITS(cp);
@@ -781,7 +781,7 @@ of10_bsn_message_print(netdissect_options *ndo,
*
*/
if (len != 12)
- goto corrupt;
+ goto invalid;
/* index */
ND_TCHECK2(*cp, 1);
ND_PRINT((ndo, ", index %u", *cp));
@@ -805,7 +805,7 @@ of10_bsn_message_print(netdissect_options *ndo,
*
*/
if (len != 12)
- goto corrupt;
+ goto invalid;
/* index */
ND_TCHECK2(*cp, 1);
ND_PRINT((ndo, ", index %u", *cp));
@@ -832,7 +832,7 @@ of10_bsn_message_print(netdissect_options *ndo,
*
*/
if (len != 8)
- goto corrupt;
+ goto invalid;
/* report_mirror_ports */
ND_TCHECK2(*cp, 1);
ND_PRINT((ndo, ", report_mirror_ports %s", tok2str(bsn_onoff_str, "bogus (%u)", *cp)));
@@ -855,7 +855,7 @@ of10_bsn_message_print(netdissect_options *ndo,
*
*/
if (len != 4)
- goto corrupt;
+ goto invalid;
break;
case BSN_VIRTUAL_PORT_REMOVE_REQUEST:
/*
@@ -869,7 +869,7 @@ of10_bsn_message_print(netdissect_options *ndo,
*
*/
if (len != 8)
- goto corrupt;
+ goto invalid;
/* vport_no */
ND_TCHECK2(*cp, 4);
ND_PRINT((ndo, ", vport_no %u", EXTRACT_32BITS(cp)));
@@ -889,7 +889,7 @@ of10_bsn_message_print(netdissect_options *ndo,
*
*/
if (len < 8)
- goto corrupt;
+ goto invalid;
/* service */
ND_TCHECK2(*cp, 4);
ND_PRINT((ndo, ", service %u", EXTRACT_32BITS(cp)));
@@ -936,7 +936,7 @@ of10_bsn_message_print(netdissect_options *ndo,
*
*/
if (len != 8)
- goto corrupt;
+ goto invalid;
/* status */
ND_TCHECK2(*cp, 4);
ND_PRINT((ndo, ", status 0x%08x", EXTRACT_32BITS(cp)));
@@ -948,8 +948,8 @@ of10_bsn_message_print(netdissect_options *ndo,
}
return cp;
-corrupt: /* skip the undersized data */
- ND_PRINT((ndo, "%s", cstr));
+invalid: /* skip the undersized data */
+ ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*cp0, len);
return cp0 + len;
trunc:
@@ -965,7 +965,7 @@ of10_bsn_actions_print(netdissect_options *ndo,
uint32_t subtype, vlan_tag;
if (len < 4)
- goto corrupt;
+ goto invalid;
/* subtype */
ND_TCHECK2(*cp, 4);
subtype = EXTRACT_32BITS(cp);
@@ -988,7 +988,7 @@ of10_bsn_actions_print(netdissect_options *ndo,
*
*/
if (len != 16)
- goto corrupt;
+ goto invalid;
/* dest_port */
ND_TCHECK2(*cp, 4);
ND_PRINT((ndo, ", dest_port %u", EXTRACT_32BITS(cp)));
@@ -1022,8 +1022,8 @@ of10_bsn_actions_print(netdissect_options *ndo,
return cp;
-corrupt:
- ND_PRINT((ndo, "%s", cstr));
+invalid:
+ ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*cp0, len);
return cp0 + len;
trunc:
@@ -1039,7 +1039,7 @@ of10_vendor_action_print(netdissect_options *ndo,
const u_char *(*decoder)(netdissect_options *, const u_char *, const u_char *, const u_int);
if (len < 4)
- goto corrupt;
+ goto invalid;
/* vendor */
ND_TCHECK2(*cp, 4);
vendor = EXTRACT_32BITS(cp);
@@ -1051,8 +1051,8 @@ of10_vendor_action_print(netdissect_options *ndo,
of10_data_print;
return decoder(ndo, cp, ep, len - 4);
-corrupt: /* skip the undersized data */
- ND_PRINT((ndo, "%s", cstr));
+invalid: /* skip the undersized data */
+ ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*cp, len);
return cp + len;
trunc:
@@ -1068,7 +1068,7 @@ of10_vendor_message_print(netdissect_options *ndo,
const u_char *(*decoder)(netdissect_options *, const u_char *, const u_char *, u_int);
if (len < 4)
- goto corrupt;
+ goto invalid;
/* vendor */
ND_TCHECK2(*cp, 4);
vendor = EXTRACT_32BITS(cp);
@@ -1080,8 +1080,8 @@ of10_vendor_message_print(netdissect_options *ndo,
of10_data_print;
return decoder(ndo, cp, ep, len - 4);
-corrupt: /* skip the undersized data */
- ND_PRINT((ndo, "%s", cstr));
+invalid: /* skip the undersized data */
+ ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*cp, len);
return cp + len;
trunc:
@@ -1097,7 +1097,7 @@ of10_vendor_data_print(netdissect_options *ndo,
uint32_t vendor;
if (len < 4)
- goto corrupt;
+ goto invalid;
/* vendor */
ND_TCHECK2(*cp, 4);
vendor = EXTRACT_32BITS(cp);
@@ -1106,8 +1106,8 @@ of10_vendor_data_print(netdissect_options *ndo,
/* data */
return of10_data_print(ndo, cp, ep, len - 4);
-corrupt: /* skip the undersized data */
- ND_PRINT((ndo, "%s", cstr));
+invalid: /* skip the undersized data */
+ ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*cp, len);
return cp + len;
trunc:
@@ -1147,7 +1147,7 @@ of10_phy_ports_print(netdissect_options *ndo,
while (len) {
if (len < OF_PHY_PORT_LEN)
- goto corrupt;
+ goto invalid;
/* port_no */
ND_TCHECK2(*cp, 2);
ND_PRINT((ndo, "\n\t port_no %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp))));
@@ -1203,8 +1203,8 @@ next_port:
} /* while */
return cp;
-corrupt: /* skip the undersized trailing data */
- ND_PRINT((ndo, "%s", cstr));
+invalid: /* skip the undersized trailing data */
+ ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*cp0, len0);
return cp0 + len0;
trunc:
@@ -1225,7 +1225,7 @@ of10_queue_props_print(netdissect_options *ndo,
u_char plen_bogus = 0, skip = 0;
if (len < OF_QUEUE_PROP_HEADER_LEN)
- goto corrupt;
+ goto invalid;
/* property */
ND_TCHECK2(*cp, 2);
property = EXTRACT_16BITS(cp);
@@ -1237,7 +1237,7 @@ of10_queue_props_print(netdissect_options *ndo,
cp += 2;
ND_PRINT((ndo, ", len %u", plen));
if (plen < OF_QUEUE_PROP_HEADER_LEN || plen > len)
- goto corrupt;
+ goto invalid;
/* pad */
ND_TCHECK2(*cp, 4);
cp += 4;
@@ -1279,8 +1279,8 @@ next_property:
} /* while */
return cp;
-corrupt: /* skip the rest of queue properties */
- ND_PRINT((ndo, "%s", cstr));
+invalid: /* skip the rest of queue properties */
+ ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*cp0, len0);
return cp0 + len0;
trunc:
@@ -1299,7 +1299,7 @@ of10_queues_print(netdissect_options *ndo,
while (len) {
if (len < OF_PACKET_QUEUE_LEN)
- goto corrupt;
+ goto invalid;
/* queue_id */
ND_TCHECK2(*cp, 4);
ND_PRINT((ndo, "\n\t queue_id %u", EXTRACT_32BITS(cp)));
@@ -1310,7 +1310,7 @@ of10_queues_print(netdissect_options *ndo,
cp += 2;
ND_PRINT((ndo, ", len %u", desclen));
if (desclen < OF_PACKET_QUEUE_LEN || desclen > len)
- goto corrupt;
+ goto invalid;
/* pad */
ND_TCHECK2(*cp, 2);
cp += 2;
@@ -1327,8 +1327,8 @@ next_queue:
} /* while */
return cp;
-corrupt: /* skip the rest of queues */
- ND_PRINT((ndo, "%s", cstr));
+invalid: /* skip the rest of queues */
+ ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*cp0, len0);
return cp0 + len0;
trunc:
@@ -1454,7 +1454,7 @@ of10_actions_print(netdissect_options *ndo,
u_char alen_bogus = 0, skip = 0;
if (len < OF_ACTION_HEADER_LEN)
- goto corrupt;
+ goto invalid;
/* type */
ND_TCHECK2(*cp, 2);
type = EXTRACT_16BITS(cp);
@@ -1467,7 +1467,7 @@ of10_actions_print(netdissect_options *ndo,
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 corrupt;
+ 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) {
@@ -1598,8 +1598,8 @@ next_action:
} /* while */
return cp;
-corrupt: /* skip the rest of actions */
- ND_PRINT((ndo, "%s", cstr));
+invalid: /* skip the rest of actions */
+ ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*cp0, len0);
return cp0 + len0;
trunc:
@@ -1766,12 +1766,12 @@ of10_stats_request_print(netdissect_options *ndo,
case OFPST_DESC:
case OFPST_TABLE:
if (len)
- goto corrupt;
+ goto invalid;
return cp;
case OFPST_FLOW:
case OFPST_AGGREGATE:
if (len != OF_FLOW_STATS_REQUEST_LEN)
- goto corrupt;
+ goto invalid;
/* match */
if (ep == (cp = of10_match_print(ndo, "\n\t ", cp, ep)))
return ep; /* end of snapshot */
@@ -1788,7 +1788,7 @@ of10_stats_request_print(netdissect_options *ndo,
return cp + 2;
case OFPST_PORT:
if (len != OF_PORT_STATS_REQUEST_LEN)
- goto corrupt;
+ goto invalid;
/* port_no */
ND_TCHECK2(*cp, 2);
ND_PRINT((ndo, "\n\t port_no %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp))));
@@ -1798,7 +1798,7 @@ of10_stats_request_print(netdissect_options *ndo,
return cp + 6;
case OFPST_QUEUE:
if (len != OF_QUEUE_STATS_REQUEST_LEN)
- goto corrupt;
+ goto invalid;
/* port_no */
ND_TCHECK2(*cp, 2);
ND_PRINT((ndo, "\n\t port_no %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp))));
@@ -1815,8 +1815,8 @@ of10_stats_request_print(netdissect_options *ndo,
}
return cp;
-corrupt: /* skip the message body */
- ND_PRINT((ndo, "%s", cstr));
+invalid: /* skip the message body */
+ ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*cp0, len0);
return cp0 + len0;
trunc:
@@ -1830,7 +1830,7 @@ 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 corrupt;
+ goto invalid;
/* mfr_desc */
ND_TCHECK2(*cp, DESC_STR_LEN);
ND_PRINT((ndo, "\n\t mfr_desc '"));
@@ -1862,8 +1862,8 @@ of10_desc_stats_reply_print(netdissect_options *ndo,
ND_PRINT((ndo, "'"));
return cp + DESC_STR_LEN;
-corrupt: /* skip the message body */
- ND_PRINT((ndo, "%s", cstr));
+invalid: /* skip the message body */
+ ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*cp, len);
return cp + len;
trunc:
@@ -1882,13 +1882,13 @@ of10_flow_stats_reply_print(netdissect_options *ndo,
while (len) {
if (len < OF_FLOW_STATS_LEN)
- goto corrupt;
+ 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 corrupt;
+ goto invalid;
cp += 2;
/* table_id */
ND_TCHECK2(*cp, 1);
@@ -1943,8 +1943,8 @@ of10_flow_stats_reply_print(netdissect_options *ndo,
} /* while */
return cp;
-corrupt: /* skip the rest of flow statistics entries */
- ND_PRINT((ndo, "%s", cstr));
+invalid: /* skip the rest of flow statistics entries */
+ ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*cp0, len0);
return cp0 + len0;
trunc:
@@ -1959,7 +1959,7 @@ of10_aggregate_stats_reply_print(netdissect_options *ndo,
const u_int len)
{
if (len != OF_AGGREGATE_STATS_REPLY_LEN)
- goto corrupt;
+ goto invalid;
/* packet_count */
ND_TCHECK2(*cp, 8);
ND_PRINT((ndo, "\n\t packet_count %" PRIu64, EXTRACT_64BITS(cp)));
@@ -1976,8 +1976,8 @@ of10_aggregate_stats_reply_print(netdissect_options *ndo,
ND_TCHECK2(*cp, 4);
return cp + 4;
-corrupt: /* skip the message body */
- ND_PRINT((ndo, "%s", cstr));
+invalid: /* skip the message body */
+ ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*cp, len);
return cp + len;
trunc:
@@ -1995,7 +1995,7 @@ of10_table_stats_reply_print(netdissect_options *ndo,
while (len) {
if (len < OF_TABLE_STATS_LEN)
- goto corrupt;
+ goto invalid;
/* table_id */
ND_TCHECK2(*cp, 1);
ND_PRINT((ndo, "\n\t table_id %s", tok2str(tableid_str, "%u", *cp)));
@@ -2035,8 +2035,8 @@ of10_table_stats_reply_print(netdissect_options *ndo,
} /* while */
return cp;
-corrupt: /* skip the undersized trailing data */
- ND_PRINT((ndo, "%s", cstr));
+invalid: /* skip the undersized trailing data */
+ ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*cp0, len0);
return cp0 + len0;
trunc:
@@ -2054,7 +2054,7 @@ of10_port_stats_reply_print(netdissect_options *ndo,
while (len) {
if (len < OF_PORT_STATS_LEN)
- goto corrupt;
+ goto invalid;
/* port_no */
ND_TCHECK2(*cp, 2);
ND_PRINT((ndo, "\n\t port_no %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp))));
@@ -2120,8 +2120,8 @@ next_port:
} /* while */
return cp;
-corrupt: /* skip the undersized trailing data */
- ND_PRINT((ndo, "%s", cstr));
+invalid: /* skip the undersized trailing data */
+ ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*cp0, len0);
return cp0 + len0;
trunc:
@@ -2139,7 +2139,7 @@ of10_queue_stats_reply_print(netdissect_options *ndo,
while (len) {
if (len < OF_QUEUE_STATS_LEN)
- goto corrupt;
+ goto invalid;
/* port_no */
ND_TCHECK2(*cp, 2);
ND_PRINT((ndo, "\n\t port_no %s", tok2str(ofpp_str, "%u", EXTRACT_16BITS(cp))));
@@ -2168,8 +2168,8 @@ of10_queue_stats_reply_print(netdissect_options *ndo,
} /* while */
return cp;
-corrupt: /* skip the undersized trailing data */
- ND_PRINT((ndo, "%s", cstr));
+invalid: /* skip the undersized trailing data */
+ ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*cp0, len0);
return cp0 + len0;
trunc:
@@ -2239,15 +2239,15 @@ of10_packet_out_print(netdissect_options *ndo,
actions_len = EXTRACT_16BITS(cp);
cp += 2;
if (actions_len > len - OF_PACKET_OUT_LEN)
- goto corrupt;
+ 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);
-corrupt: /* skip the rest of the message body */
- ND_PRINT((ndo, "%s", cstr));
+invalid: /* skip the rest of the message body */
+ ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*cp0, len0);
return cp0 + len0;
trunc:
@@ -2387,7 +2387,7 @@ of10_header_body_print(netdissect_options *ndo,
* 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
- * corrupt, proceed to the next message. */
+ * invalid, proceed to the next message. */
/* [OF10] Section 5.1 */
ND_PRINT((ndo, "\n\tversion 1.0, type %s, length %u, xid 0x%08x",
@@ -2399,14 +2399,14 @@ of10_header_body_print(netdissect_options *ndo,
case OFPT_BARRIER_REQUEST: /* [OF10] Section 5.3.7 */
case OFPT_BARRIER_REPLY: /* ibid */
if (len != OF_HEADER_LEN)
- goto corrupt;
+ 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 corrupt;
+ goto invalid;
if (ndo->ndo_vflag < 1)
goto next_message;
/* flags */
@@ -2419,13 +2419,13 @@ of10_header_body_print(netdissect_options *ndo,
return cp + 2;
case OFPT_PORT_MOD:
if (len != OF_PORT_MOD_LEN)
- goto corrupt;
+ 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 corrupt;
+ goto invalid;
if (ndo->ndo_vflag < 1)
goto next_message;
/* port */
@@ -2437,13 +2437,13 @@ of10_header_body_print(netdissect_options *ndo,
return cp + 2;
case OFPT_FLOW_REMOVED:
if (len != OF_FLOW_REMOVED_LEN)
- goto corrupt;
+ 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 corrupt;
+ goto invalid;
if (ndo->ndo_vflag < 1)
goto next_message;
/* reason */
@@ -2459,7 +2459,7 @@ of10_header_body_print(netdissect_options *ndo,
/* OpenFlow header, fixed-size message body and n * fixed-size data units. */
case OFPT_FEATURES_REPLY:
if (len < OF_SWITCH_FEATURES_LEN)
- goto corrupt;
+ goto invalid;
if (ndo->ndo_vflag < 1)
goto next_message;
return of10_features_reply_print(ndo, cp, ep, len);
@@ -2475,21 +2475,21 @@ of10_header_body_print(netdissect_options *ndo,
/* OpenFlow header, fixed-size message body and variable-size data. */
case OFPT_ERROR:
if (len < OF_ERROR_MSG_LEN)
- goto corrupt;
+ 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 corrupt;
+ 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 corrupt;
+ goto invalid;
if (ndo->ndo_vflag < 1)
goto next_message;
return of10_packet_in_print(ndo, cp, ep, len);
@@ -2499,7 +2499,7 @@ of10_header_body_print(netdissect_options *ndo,
/* c. OpenFlow header, fixed-size message body and variable-size data. */
case OFPT_STATS_REQUEST:
if (len < OF_STATS_REQUEST_LEN)
- goto corrupt;
+ goto invalid;
if (ndo->ndo_vflag < 1)
goto next_message;
return of10_stats_request_print(ndo, cp, ep, len);
@@ -2510,7 +2510,7 @@ of10_header_body_print(netdissect_options *ndo,
/* d. OpenFlow header, fixed-size message body and variable-size data. */
case OFPT_STATS_REPLY:
if (len < OF_STATS_REPLY_LEN)
- goto corrupt;
+ goto invalid;
if (ndo->ndo_vflag < 1)
goto next_message;
return of10_stats_reply_print(ndo, cp, ep, len);
@@ -2518,7 +2518,7 @@ of10_header_body_print(netdissect_options *ndo,
/* OpenFlow header and n * variable-size data units and variable-size data. */
case OFPT_PACKET_OUT:
if (len < OF_PACKET_OUT_LEN)
- goto corrupt;
+ goto invalid;
if (ndo->ndo_vflag < 1)
goto next_message;
return of10_packet_out_print(ndo, cp, ep, len);
@@ -2526,7 +2526,7 @@ of10_header_body_print(netdissect_options *ndo,
/* OpenFlow header, fixed-size message body and n * variable-size data units. */
case OFPT_FLOW_MOD:
if (len < OF_FLOW_MOD_LEN)
- goto corrupt;
+ goto invalid;
if (ndo->ndo_vflag < 1)
goto next_message;
return of10_flow_mod_print(ndo, cp, ep, len);
@@ -2534,7 +2534,7 @@ of10_header_body_print(netdissect_options *ndo,
/* 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 corrupt;
+ goto invalid;
if (ndo->ndo_vflag < 1)
goto next_message;
/* port */
@@ -2549,8 +2549,8 @@ of10_header_body_print(netdissect_options *ndo,
} /* switch (type) */
goto next_message;
-corrupt: /* skip the message body */
- ND_PRINT((ndo, "%s", cstr));
+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;
diff --git a/contrib/tcpdump/print-openflow.c b/contrib/tcpdump/print-openflow.c
index 8825ae3..043adc2 100644
--- a/contrib/tcpdump/print-openflow.c
+++ b/contrib/tcpdump/print-openflow.c
@@ -30,20 +30,20 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#define NETDISSECT_REWORKED
+/* \summary: version-independent OpenFlow printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
#include "openflow.h"
#include "oui.h"
static const char tstr[] = " [|openflow]";
-static const char cstr[] = " (corrupt)";
#define OF_VER_1_0 0x01
@@ -83,7 +83,7 @@ of_header_body_print(netdissect_options *ndo, const u_char *cp, const u_char *ep
uint32_t xid;
if (ep < cp + OF_HEADER_LEN)
- goto corrupt;
+ goto invalid;
/* version */
ND_TCHECK2(*cp, 1);
version = *cp;
@@ -107,7 +107,7 @@ of_header_body_print(netdissect_options *ndo, const u_char *cp, const u_char *ep
* segment. */
if (length < OF_HEADER_LEN) {
of_header_print(ndo, version, type, length, xid);
- goto corrupt;
+ goto invalid;
}
/* Decode known protocol versions further without printing the header (the
* type decoding is version-specific. */
@@ -120,8 +120,8 @@ of_header_body_print(netdissect_options *ndo, const u_char *cp, const u_char *ep
return cp + length - OF_HEADER_LEN; /* done with current message */
}
-corrupt: /* fail current packet */
- ND_PRINT((ndo, "%s", cstr));
+invalid: /* fail current packet */
+ ND_PRINT((ndo, "%s", istr));
ND_TCHECK2(*cp, ep - cp);
return ep;
trunc:
diff --git a/contrib/tcpdump/print-ospf.c b/contrib/tcpdump/print-ospf.c
index 3583417..db4231b 100644
--- a/contrib/tcpdump/print-ospf.c
+++ b/contrib/tcpdump/print-ospf.c
@@ -21,14 +21,15 @@
* OSPF support contributed by Jeffrey Honig (jch@mitchell.cit.cornell.edu)
*/
-#define NETDISSECT_REWORKED
+/* \summary: Open Shortest Path First (OSPF) printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "extract.h"
#include "gmpls.h"
@@ -314,6 +315,10 @@ ospf_print_te_lsa(netdissect_options *ndo,
tptr+=4;
tlv_length-=4;
+ /* 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,
@@ -322,10 +327,18 @@ ospf_print_te_lsa(netdissect_options *ndo,
ND_TCHECK2(*tptr, subtlv_length);
switch(subtlv_type) {
case LS_OPAQUE_TE_LINK_SUBTLV_ADMIN_GROUP:
+ 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:
+ 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)));
@@ -336,14 +349,26 @@ ospf_print_te_lsa(netdissect_options *ndo,
break;
case LS_OPAQUE_TE_LINK_SUBTLV_LOCAL_IP:
case LS_OPAQUE_TE_LINK_SUBTLV_REMOTE_IP:
+ 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);
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);
ND_PRINT((ndo, "\n\t\tTE-Class %u: %.3f Mbps",
@@ -352,9 +377,22 @@ ospf_print_te_lsa(netdissect_options *ndo,
}
break;
case LS_OPAQUE_TE_LINK_SUBTLV_BW_CONSTRAINTS:
+ 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));
+ 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);
@@ -364,14 +402,27 @@ ospf_print_te_lsa(netdissect_options *ndo,
}
break;
case LS_OPAQUE_TE_LINK_SUBTLV_TE_METRIC:
+ 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:
- ND_PRINT((ndo, ", %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:
+ 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:",
@@ -384,12 +435,20 @@ ospf_print_te_lsa(netdissect_options *ndo,
}
break;
case LS_OPAQUE_TE_LINK_SUBTLV_LINK_TYPE:
+ 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));
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)
ND_PRINT((ndo, "\n\t\t Shared risk group: "));
@@ -445,6 +504,9 @@ ospf_print_te_lsa(netdissect_options *ndo,
return 0;
trunc:
return -1;
+invalid:
+ ND_PRINT((ndo, "%s", istr));
+ return -1;
}
static int
@@ -506,16 +568,16 @@ trunc:
/* draft-ietf-ospf-mt-09 */
static const struct tok ospf_topology_values[] = {
- { 0, "default " },
- { 1, "multicast " },
- { 2, "management " },
+ { 0, "default" },
+ { 1, "multicast" },
+ { 2, "management" },
{ 0, NULL }
};
/*
* Print all the per-topology metrics.
*/
-static void
+static int
ospf_print_tos_metrics(netdissect_options *ndo,
const union un_tos *tos)
{
@@ -528,9 +590,10 @@ ospf_print_tos_metrics(netdissect_options *ndo,
/*
* All but the first metric contain a valid topology id.
*/
- while (toscount) {
- ND_PRINT((ndo, "\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)));
@@ -538,6 +601,9 @@ ospf_print_tos_metrics(netdissect_options *ndo,
tos++;
toscount--;
}
+ return 0;
+trunc:
+ return 1;
}
/*
@@ -559,11 +625,11 @@ ospf_print_lsa(netdissect_options *ndo,
register int ls_length;
const uint8_t *tptr;
- tptr = (uint8_t *)lsap->lsa_un.un_unknown; /* squelch compiler warnings */
+ 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 = (uint8_t *)lsap + ls_length;
+ ls_end = (const uint8_t *)lsap + ls_length;
ls_length -= sizeof(struct lsa_hdr);
switch (lsap->ls_hdr.ls_type) {
@@ -611,9 +677,10 @@ ospf_print_lsa(netdissect_options *ndo,
return (ls_end);
}
- ospf_print_tos_metrics(ndo, &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;
@@ -623,7 +690,7 @@ ospf_print_lsa(netdissect_options *ndo,
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) {
+ while ((const u_char *)ap < ls_end) {
ND_TCHECK(*ap);
ND_PRINT((ndo, "\n\t %s", ipaddr_string(ndo, ap)));
++ap;
@@ -636,14 +703,14 @@ ospf_print_lsa(netdissect_options *ndo,
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) {
+ while ((const u_char *)lp < ls_end) {
register uint32_t ul;
ND_TCHECK(*lp);
ul = EXTRACT_32BITS(lp);
topology = (ul & SLA_MASK_TOS) >> SLA_SHIFT_TOS;
- ND_PRINT((ndo, "\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));
++lp;
@@ -653,14 +720,14 @@ ospf_print_lsa(netdissect_options *ndo,
case LS_TYPE_SUM_ABR:
ND_TCHECK(lsap->lsa_un.un_sla.sla_tosmetric);
lp = lsap->lsa_un.un_sla.sla_tosmetric;
- while ((u_char *)lp < ls_end) {
+ while ((const u_char *)lp < ls_end) {
register uint32_t ul;
ND_TCHECK(*lp);
ul = EXTRACT_32BITS(lp);
topology = (ul & SLA_MASK_TOS) >> SLA_SHIFT_TOS;
- ND_PRINT((ndo, "\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));
++lp;
@@ -675,14 +742,14 @@ ospf_print_lsa(netdissect_options *ndo,
ND_TCHECK(lsap->lsa_un.un_sla.sla_tosmetric);
almp = lsap->lsa_un.un_asla.asla_metric;
- while ((u_char *)almp < ls_end) {
+ while ((const u_char *)almp < ls_end) {
register uint32_t ul;
ND_TCHECK(almp->asla_tosmetric);
ul = EXTRACT_32BITS(&almp->asla_tosmetric);
topology = ((ul & ASLA_MASK_TOS) >> ASLA_SHIFT_TOS);
- ND_PRINT((ndo, "\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)
@@ -705,7 +772,7 @@ ospf_print_lsa(netdissect_options *ndo,
case LS_TYPE_GROUP:
/* Multicast extensions as of 23 July 1991 */
mcp = lsap->lsa_un.un_mcla;
- while ((u_char *)mcp < ls_end) {
+ while ((const u_char *)mcp < ls_end) {
ND_TCHECK(mcp->mcla_vid);
switch (EXTRACT_32BITS(&mcp->mcla_vtype)) {
@@ -734,7 +801,7 @@ ospf_print_lsa(netdissect_options *ndo,
switch (*(&lsap->ls_hdr.un_lsa_id.opaque_field.opaque_type)) {
case LS_OPAQUE_TYPE_RI:
- tptr = (uint8_t *)(&lsap->lsa_un.un_ri_tlv.type);
+ tptr = (const uint8_t *)(&lsap->lsa_un.un_ri_tlv.type);
while (ls_length != 0) {
ND_TCHECK2(*tptr, 4);
@@ -782,14 +849,14 @@ ospf_print_lsa(netdissect_options *ndo,
break;
case LS_OPAQUE_TYPE_GRACE:
- if (ospf_print_grace_lsa(ndo, (uint8_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(ndo, (uint8_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);
}
@@ -797,7 +864,7 @@ ospf_print_lsa(netdissect_options *ndo,
default:
if (ndo->ndo_vflag <= 1) {
- if (!print_unknown_data(ndo, (uint8_t *)lsap->lsa_un.un_unknown,
+ if (!print_unknown_data(ndo, (const uint8_t *)lsap->lsa_un.un_unknown,
"\n\t ", ls_length))
return(ls_end);
}
@@ -807,7 +874,7 @@ ospf_print_lsa(netdissect_options *ndo,
/* do we want to see an additionally hexdump ? */
if (ndo->ndo_vflag> 1)
- if (!print_unknown_data(ndo, (uint8_t *)lsap->lsa_un.un_unknown,
+ if (!print_unknown_data(ndo, (const uint8_t *)lsap->lsa_un.un_unknown,
"\n\t ", ls_length)) {
return(ls_end);
}
@@ -845,8 +912,8 @@ ospf_decode_lls(netdissect_options *ndo,
/* 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];
@@ -929,6 +996,7 @@ ospf_decode_v2(netdissect_options *ndo,
break;
case OSPF_TYPE_HELLO:
+ ND_TCHECK(op->ospf_hello.hello_options);
ND_PRINT((ndo, "\n\tOptions [%s]",
bittok2str(ospf_option_values,"none",op->ospf_hello.hello_options)));
@@ -950,9 +1018,9 @@ ospf_decode_v2(netdissect_options *ndo,
ipaddr_string(ndo, &op->ospf_hello.hello_bdr)));
ap = op->ospf_hello.hello_neighbor;
- if ((u_char *)ap < dataend)
+ if ((const u_char *)ap < dataend)
ND_PRINT((ndo, "\n\t Neighbor List:"));
- while ((u_char *)ap < dataend) {
+ while ((const u_char *)ap < dataend) {
ND_TCHECK(*ap);
ND_PRINT((ndo, "\n\t %s", ipaddr_string(ndo, ap)));
++ap;
@@ -975,14 +1043,14 @@ ospf_decode_v2(netdissect_options *ndo,
/* Print all the LS adv's */
lshp = op->ospf_db.db_lshdr;
- while (((u_char *)lshp < dataend) && ospf_print_lshdr(ndo, lshp) != -1) {
+ 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) {
+ while ((const u_char *)lsrp < dataend) {
ND_TCHECK(*lsrp);
ND_PRINT((ndo, "\n\t Advertising Router: %s, %s LSA (%u)",
@@ -1047,7 +1115,7 @@ ospf_print(netdissect_options *ndo,
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 */
ND_TCHECK(op->ospf_authtype);
diff --git a/contrib/tcpdump/print-ospf6.c b/contrib/tcpdump/print-ospf6.c
index 49210bc..e8a9dc6 100644
--- a/contrib/tcpdump/print-ospf6.c
+++ b/contrib/tcpdump/print-ospf6.c
@@ -21,16 +21,17 @@
* OSPF support contributed by Jeffrey Honig (jch@mitchell.cit.cornell.edu)
*/
-#define NETDISSECT_REWORKED
+/* \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 <string.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "extract.h"
@@ -386,7 +387,7 @@ static int
ospf6_print_lshdr(netdissect_options *ndo,
register const struct lsa6_hdr *lshp, const u_char *dataend)
{
- if ((u_char *)(lshp + 1) > dataend)
+ if ((const u_char *)(lshp + 1) > dataend)
goto trunc;
ND_TCHECK(lshp->ls_type);
ND_TCHECK(lshp->ls_seq);
@@ -408,7 +409,7 @@ static int
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;
@@ -480,10 +481,10 @@ ospf6_print_lsa(netdissect_options *ndo,
* If it does, find the length of what follows the
* header.
*/
- if (length < sizeof(struct lsa6_hdr) || (u_char *)lsap + length > dataend)
+ if (length < sizeof(struct lsa6_hdr) || (const u_char *)lsap + length > dataend)
return (1);
lsa_length = length - sizeof(struct lsa6_hdr);
- tptr = (uint8_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:
@@ -569,7 +570,7 @@ ospf6_print_lsa(netdissect_options *ndo,
ND_PRINT((ndo, ", metric %u",
EXTRACT_32BITS(&lsap->lsa_un.un_inter_ap.inter_ap_metric) & SLA_MASK_METRIC));
- tptr = (uint8_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(ndo, tptr, lsa_length);
if (bytelen < 0)
@@ -591,8 +592,8 @@ ospf6_print_lsa(netdissect_options *ndo,
EXTRACT_32BITS(&lsap->lsa_un.un_asla.asla_metric) &
ASLA_MASK_METRIC));
- tptr = (uint8_t *)lsap->lsa_un.un_asla.asla_prefix;
- lsapp = (struct lsa6_prefix *)tptr;
+ 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;
@@ -600,9 +601,9 @@ ospf6_print_lsa(netdissect_options *ndo,
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);
@@ -616,9 +617,9 @@ ospf6_print_lsa(netdissect_options *ndo,
if (lsa_length < sizeof (uint32_t))
return (1);
lsa_length -= sizeof (uint32_t);
- ND_TCHECK(*(uint32_t *)tptr);
+ ND_TCHECK(*(const uint32_t *)tptr);
ND_PRINT((ndo, " tag %s",
- ipaddr_string(ndo, (uint32_t *)tptr)));
+ ipaddr_string(ndo, (const uint32_t *)tptr)));
tptr += sizeof(uint32_t);
}
@@ -626,9 +627,9 @@ ospf6_print_lsa(netdissect_options *ndo,
if (lsa_length < sizeof (uint32_t))
return (1);
lsa_length -= sizeof (uint32_t);
- ND_TCHECK(*(uint32_t *)tptr);
+ ND_TCHECK(*(const uint32_t *)tptr);
ND_PRINT((ndo, " RefLSID: %s",
- ipaddr_string(ndo, (uint32_t *)tptr)));
+ ipaddr_string(ndo, (const uint32_t *)tptr)));
tptr += sizeof(uint32_t);
}
break;
@@ -653,7 +654,7 @@ ospf6_print_lsa(netdissect_options *ndo,
ip6addr_string(ndo, &llsap->llsa_lladdr),
prefixes));
- tptr = (uint8_t *)llsap->llsa_prefix;
+ tptr = (const uint8_t *)llsap->llsa_prefix;
while (prefixes > 0) {
bytelen = ospf6_print_lsaprefix(ndo, tptr, lsa_length);
if (bytelen < 0)
@@ -681,7 +682,7 @@ ospf6_print_lsa(netdissect_options *ndo,
prefixes = EXTRACT_16BITS(&lsap->lsa_un.un_intra_ap.intra_ap_nprefix);
ND_PRINT((ndo, "\n\t Prefixes %d:", prefixes));
- tptr = (uint8_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(ndo, tptr, lsa_length);
if (bytelen < 0)
@@ -732,7 +733,7 @@ ospf6_decode_v3(netdissect_options *ndo,
switch (op->ospf6_type) {
case OSPF_TYPE_HELLO: {
- register const struct hello6 *hellop = (const struct hello6 *)((uint8_t *)op + OSPF6HDR_LEN);
+ 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",
@@ -756,7 +757,7 @@ ospf6_decode_v3(netdissect_options *ndo,
if (ndo->ndo_vflag > 1) {
ND_PRINT((ndo, "\n\t Neighbor List:"));
ap = hellop->hello_neighbor;
- while ((u_char *)ap < dataend) {
+ while ((const u_char *)ap < dataend) {
ND_TCHECK(*ap);
ND_PRINT((ndo, "\n\t %s", ipaddr_string(ndo, ap)));
++ap;
@@ -766,7 +767,7 @@ ospf6_decode_v3(netdissect_options *ndo,
}
case OSPF_TYPE_DD: {
- register const struct dd6 *ddp = (const struct dd6 *)((uint8_t *)op + OSPF6HDR_LEN);
+ 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]",
@@ -783,7 +784,7 @@ ospf6_decode_v3(netdissect_options *ndo,
if (ndo->ndo_vflag > 1) {
/* Print all the LS adv's */
lshp = ddp->db_lshdr;
- while ((u_char *)lshp < dataend) {
+ while ((const u_char *)lshp < dataend) {
if (ospf6_print_lshdr(ndo, lshp++, dataend))
goto trunc;
}
@@ -793,8 +794,8 @@ ospf6_decode_v3(netdissect_options *ndo,
case OSPF_TYPE_LS_REQ:
if (ndo->ndo_vflag > 1) {
- lsrp = (const struct lsr6 *)((uint8_t *)op + OSPF6HDR_LEN);
- while ((u_char *)lsrp < dataend) {
+ 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)));
@@ -807,15 +808,15 @@ ospf6_decode_v3(netdissect_options *ndo,
case OSPF_TYPE_LS_UPDATE:
if (ndo->ndo_vflag > 1) {
- register const struct lsu6 *lsup = (const struct lsu6 *)((uint8_t *)op + OSPF6HDR_LEN);
+ 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 ((u_char *)lsap < dataend && i--) {
+ 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));
}
}
@@ -823,8 +824,8 @@ ospf6_decode_v3(netdissect_options *ndo,
case OSPF_TYPE_LS_ACK:
if (ndo->ndo_vflag > 1) {
- lshp = (const struct lsa6_hdr *)((uint8_t *)op + OSPF6HDR_LEN);
- while ((u_char *)lshp < dataend) {
+ 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;
}
@@ -931,11 +932,11 @@ ospf6_decode_v3_trailer(netdissect_options *ndo,
int lls_dd = 0;
if (op->ospf6_type == OSPF_TYPE_HELLO) {
- const struct hello6 *hellop = (const struct hello6 *)((uint8_t *)op + OSPF6HDR_LEN);
+ 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 *)((uint8_t *)op + OSPF6HDR_LEN);
+ 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;
}
@@ -956,7 +957,7 @@ ospf6_print(netdissect_options *ndo,
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 */
diff --git a/contrib/tcpdump/print-otv.c b/contrib/tcpdump/print-otv.c
index 53a79de..5a82752 100644
--- a/contrib/tcpdump/print-otv.c
+++ b/contrib/tcpdump/print-otv.c
@@ -13,14 +13,17 @@
* Original code by Francesco Fondelli (francesco dot fondelli, gmail dot com)
*/
-#define NETDISSECT_REWORKED
+/* \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 "interface.h"
+#include "netdissect.h"
#include "extract.h"
/*
@@ -39,27 +42,31 @@ void
otv_print(netdissect_options *ndo, const u_char *bp, u_int len)
{
uint8_t flags;
- uint32_t overlay_id;
- uint32_t instance_id;
- if (len < 8) {
- ND_PRINT((ndo, "[|OTV]"));
- return;
- }
+ 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;
+ ND_TCHECK2(*bp, 3);
+ ND_PRINT((ndo, "instance %u\n", EXTRACT_24BITS(bp)));
+ bp += 3;
- ND_PRINT((ndo, "OTV, "));
- ND_PRINT((ndo, "flags [%s] (0x%02x), ", flags & 0x08 ? "I" : ".", flags));
- ND_PRINT((ndo, "overlay %u, ", overlay_id));
- ND_PRINT((ndo, "instance %u\n", instance_id));
+ /* Reserved */
+ ND_TCHECK(*bp);
+ bp += 1;
+
+ ether_print(ndo, bp, len - 8, ndo->ndo_snapend - bp, NULL, NULL);
+ return;
- ether_print(ndo, bp, len - 8, len - 8, NULL, NULL);
+trunc:
+ ND_PRINT((ndo, " [|OTV]"));
}
diff --git a/contrib/tcpdump/print-pflog.c b/contrib/tcpdump/print-pflog.c
index 72ae276..265efd3 100644
--- a/contrib/tcpdump/print-pflog.c
+++ b/contrib/tcpdump/print-pflog.c
@@ -19,7 +19,8 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#define NETDISSECT_REWORKED
+/* \summary: OpenBSD packet filter log file printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -33,9 +34,9 @@
#include <net/pfvar.h>
#include <net/if_pflog.h>
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
static const char tstr[] = "[|pflog]";
@@ -120,7 +121,7 @@ pflog_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h,
}
#define MIN_PFLOG_HDRLEN 45
- hdr = (struct pfloghdr *)p;
+ hdr = (const struct pfloghdr *)p;
if (hdr->length < MIN_PFLOG_HDRLEN) {
ND_PRINT((ndo, "[pflog: invalid header length!]"));
return (hdr->length); /* XXX: not really */
@@ -133,7 +134,6 @@ pflog_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h,
}
/* print what we know */
- hdr = (struct pfloghdr *)p;
ND_TCHECK(*hdr);
if (ndo->ndo_eflag)
pflog_print(ndo, hdr);
diff --git a/contrib/tcpdump/print-pfsync.c b/contrib/tcpdump/print-pfsync.c
index eb9aed8..6291333 100644
--- a/contrib/tcpdump/print-pfsync.c
+++ b/contrib/tcpdump/print-pfsync.c
@@ -33,17 +33,20 @@
#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>
-#include <net/pfvar.h> /* XXX */
+#include <net/pfvar.h>
#include <net/if_pfsync.h>
#define TCPSTATES
#include <netinet/tcp_fsm.h>
+#include <netdissect-stdinc.h>
#include <string.h>
+#include "netdissect.h"
#include "interface.h"
#include "addrtoname.h"
@@ -178,7 +181,7 @@ pfsync_print(netdissect_options *ndo, struct pfsync_header *hdr,
break;
}
- if (vflag)
+ if (ndo->ndo_vflag)
actions[subh->action].print(ndo, bp);
bp += alen;
@@ -234,7 +237,7 @@ pfsync_print_upd_c(netdissect_options *ndo, const void *bp)
ND_PRINT((ndo, "\n\tid: %016jx creatorid: %08x",
(uintmax_t)be64toh(u->id), ntohl(u->creatorid)));
- if (vflag > 2) {
+ if (ndo->ndo_vflag > 2) {
ND_PRINT((ndo, "\n\tTCP? :"));
print_src_dst(ndo, &u->src, &u->dst, IPPROTO_TCP);
}
@@ -343,7 +346,7 @@ print_src_dst(netdissect_options *ndo, const struct pfsync_state_peer *src,
else
ND_PRINT((ndo, " <BAD STATE LEVELS %u:%u>",
src->state, dst->state));
- if (vflag > 1) {
+ if (ndo->ndo_vflag > 1) {
ND_PRINT((ndo, "\n\t"));
print_seq(ndo, src);
if (src->wscale && dst->wscale)
@@ -417,7 +420,7 @@ print_state(netdissect_options *ndo, struct pfsync_state *s)
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);
@@ -446,7 +449,7 @@ print_state(netdissect_options *ndo, struct pfsync_state *s)
if (s->rule != ntohl(-1))
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));
diff --git a/contrib/tcpdump/print-pgm.c b/contrib/tcpdump/print-pgm.c
index 6a83425..6d5c01c 100644
--- a/contrib/tcpdump/print-pgm.c
+++ b/contrib/tcpdump/print-pgm.c
@@ -13,21 +13,21 @@
* Original code by Andy Heffernan (ahh@juniper.net)
*/
-#define NETDISSECT_REWORKED
+/* \summary: Pragmatic General Multicast (PGM) printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.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"
@@ -151,42 +151,26 @@ pgm_print(netdissect_options *ndo,
register const struct ip *ip;
register char ch;
uint16_t sport, dport;
- int addr_size;
- const void *nla;
- int nla_af;
-#ifdef INET6
+ u_int nla_afnum;
char nla_buf[INET6_ADDRSTRLEN];
register const struct ip6_hdr *ip6;
-#else
- char nla_buf[INET_ADDRSTRLEN];
-#endif
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) {
- ND_PRINT((ndo, "Can't handle IPv6"));
- return;
- }
-#endif /* INET6 */
ch = '\0';
if (!ND_TTEST(pgm->pgm_dport)) {
-#ifdef INET6
if (ip6) {
ND_PRINT((ndo, "%s > %s: [|pgm]",
ip6addr_string(ndo, &ip6->ip6_src),
ip6addr_string(ndo, &ip6->ip6_dst)));
return;
- } else
-#endif /* INET6 */
- {
+ } else {
ND_PRINT((ndo, "%s > %s: [|pgm]",
ipaddr_string(ndo, &ip->ip_src),
ipaddr_string(ndo, &ip->ip_dst)));
@@ -197,30 +181,27 @@ pgm_print(netdissect_options *ndo,
sport = EXTRACT_16BITS(&pgm->pgm_sport);
dport = EXTRACT_16BITS(&pgm->pgm_dport);
-#ifdef INET6
if (ip6) {
if (ip6->ip6_nxt == IPPROTO_PGM) {
ND_PRINT((ndo, "%s.%s > %s.%s: ",
ip6addr_string(ndo, &ip6->ip6_src),
- tcpport_string(sport),
+ tcpport_string(ndo, sport),
ip6addr_string(ndo, &ip6->ip6_dst),
- tcpport_string(dport)));
+ tcpport_string(ndo, dport)));
} else {
ND_PRINT((ndo, "%s > %s: ",
- tcpport_string(sport), tcpport_string(dport)));
+ tcpport_string(ndo, sport), tcpport_string(ndo, dport)));
}
- } else
-#endif /*INET6*/
- {
+ } else {
if (ip->ip_p == IPPROTO_PGM) {
ND_PRINT((ndo, "%s.%s > %s.%s: ",
ipaddr_string(ndo, &ip->ip_src),
- tcpport_string(sport),
+ tcpport_string(ndo, sport),
ipaddr_string(ndo, &ip->ip_dst),
- tcpport_string(dport)));
+ tcpport_string(ndo, dport)));
} else {
ND_PRINT((ndo, "%s > %s: ",
- tcpport_string(sport), tcpport_string(dport)));
+ tcpport_string(ndo, sport), tcpport_string(ndo, dport)));
}
}
@@ -240,32 +221,28 @@ pgm_print(netdissect_options *ndo,
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);
+ spm = (const struct pgm_spm *)(pgm + 1);
ND_TCHECK(*spm);
+ bp = (const u_char *) (spm + 1);
switch (EXTRACT_16BITS(&spm->pgms_nla_afi)) {
case AFNUM_INET:
- addr_size = sizeof(struct in_addr);
- nla_af = AF_INET;
+ ND_TCHECK2(*bp, sizeof(struct in_addr));
+ addrtostr(bp, nla_buf, sizeof(nla_buf));
+ bp += sizeof(struct in_addr);
break;
-#ifdef INET6
case AFNUM_INET6:
- addr_size = sizeof(struct in6_addr);
- nla_af = AF_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);
- ND_TCHECK2(*bp, addr_size);
- nla = bp;
- bp += addr_size;
- inet_ntop(nla_af, nla, nla_buf, sizeof(nla_buf));
ND_PRINT((ndo, "SPM seq %u trail %u lead %u nla %s",
EXTRACT_32BITS(&spm->pgms_seq),
EXTRACT_32BITS(&spm->pgms_trailseq),
@@ -275,44 +252,39 @@ pgm_print(netdissect_options *ndo,
}
case PGM_POLL: {
- struct pgm_poll *poll;
+ const struct pgm_poll *poll_msg;
- poll = (struct pgm_poll *)(pgm + 1);
- ND_TCHECK(*poll);
+ poll_msg = (const struct pgm_poll *)(pgm + 1);
+ ND_TCHECK(*poll_msg);
ND_PRINT((ndo, "POLL seq %u round %u",
- EXTRACT_32BITS(&poll->pgmp_seq),
- EXTRACT_16BITS(&poll->pgmp_round)));
- bp = (u_char *) (poll + 1);
+ 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;
+ const struct pgm_polr *polr;
uint32_t ivl, rnd, mask;
- polr = (struct pgm_polr *)(pgm + 1);
+ polr = (const struct pgm_polr *)(pgm + 1);
ND_TCHECK(*polr);
+ bp = (const u_char *) (polr + 1);
switch (EXTRACT_16BITS(&polr->pgmp_nla_afi)) {
case AFNUM_INET:
- addr_size = sizeof(struct in_addr);
- nla_af = AF_INET;
+ ND_TCHECK2(*bp, sizeof(struct in_addr));
+ addrtostr(bp, nla_buf, sizeof(nla_buf));
+ bp += sizeof(struct in_addr);
break;
-#ifdef INET6
case AFNUM_INET6:
- addr_size = sizeof(struct in6_addr);
- nla_af = AF_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);
- ND_TCHECK2(*bp, addr_size);
- nla = bp;
- bp += addr_size;
-
- inet_ntop(nla_af, nla, nla_buf, sizeof(nla_buf));
ND_TCHECK2(*bp, sizeof(uint32_t));
ivl = EXTRACT_32BITS(bp);
@@ -332,43 +304,38 @@ pgm_print(netdissect_options *ndo,
break;
}
case PGM_ODATA: {
- struct pgm_data *odata;
+ const struct pgm_data *odata;
- odata = (struct pgm_data *)(pgm + 1);
+ 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);
+ 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);
+ 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);
+ 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);
+ 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
@@ -376,53 +343,44 @@ pgm_print(netdissect_options *ndo,
*/
switch (EXTRACT_16BITS(&nak->pgmn_source_afi)) {
case AFNUM_INET:
- addr_size = sizeof(struct in_addr);
- source_af = AF_INET;
+ ND_TCHECK2(*bp, sizeof(struct in_addr));
+ addrtostr(bp, source_buf, sizeof(source_buf));
+ bp += sizeof(struct in_addr);
break;
-#ifdef INET6
case AFNUM_INET6:
- addr_size = sizeof(struct in6_addr);
- source_af = AF_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);
- ND_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 AFNUM_INET:
- addr_size = sizeof(struct in_addr);
- group_af = AF_INET;
+ ND_TCHECK2(*bp, sizeof(struct in_addr));
+ addrtostr(bp, group_buf, sizeof(group_buf));
+ bp += sizeof(struct in_addr);
break;
-#ifdef INET6
case AFNUM_INET6:
- addr_size = sizeof(struct in6_addr);
- group_af = AF_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(uint16_t));
- ND_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:
ND_PRINT((ndo, "NAK "));
@@ -442,13 +400,13 @@ pgm_print(netdissect_options *ndo,
}
case PGM_ACK: {
- struct pgm_ack *ack;
+ const struct pgm_ack *ack;
- ack = (struct pgm_ack *)(pgm + 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 = (u_char *) (ack + 1);
+ bp = (const u_char *) (ack + 1);
break;
}
@@ -601,33 +559,35 @@ pgm_print(netdissect_options *ndo,
case PGM_OPT_REDIRECT:
bp += 2;
- switch (EXTRACT_16BITS(bp)) {
+ nla_afnum = EXTRACT_16BITS(bp);
+ bp += (2 * sizeof(uint16_t));
+ switch (nla_afnum) {
case AFNUM_INET:
- addr_size = sizeof(struct in_addr);
- nla_af = AF_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 AFNUM_INET6:
- addr_size = sizeof(struct in6_addr);
- nla_af = AF_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(uint16_t));
- if (opt_len != 4 + addr_size) {
- ND_PRINT((ndo, "[Bad OPT_REDIRECT option, length %u != 4 + address size]", opt_len));
- return;
- }
- ND_TCHECK2(*bp, addr_size);
- nla = bp;
- bp += addr_size;
- inet_ntop(nla_af, nla, nla_buf, sizeof(nla_buf));
- ND_PRINT((ndo, " REDIRECT %s", (char *)nla));
- opts_len -= 4 + addr_size;
+ ND_PRINT((ndo, " REDIRECT %s", nla_buf));
break;
case PGM_OPT_PARITY_PRM:
@@ -732,66 +692,70 @@ pgm_print(netdissect_options *ndo,
bp += 2;
offset = EXTRACT_32BITS(bp);
bp += sizeof(uint32_t);
- switch (EXTRACT_16BITS(bp)) {
+ nla_afnum = EXTRACT_16BITS(bp);
+ bp += (2 * sizeof(uint16_t));
+ switch (nla_afnum) {
case AFNUM_INET:
- addr_size = sizeof(struct in_addr);
- nla_af = AF_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 AFNUM_INET6:
- addr_size = sizeof(struct in6_addr);
- nla_af = AF_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(uint16_t));
- if (opt_len != 12 + addr_size) {
- ND_PRINT((ndo, "[Bad OPT_PGMCC_DATA option, length %u != 12 + address size]", opt_len));
- return;
- }
- ND_TCHECK2(*bp, addr_size);
- nla = bp;
- bp += addr_size;
- inet_ntop(nla_af, nla, nla_buf, sizeof(nla_buf));
- ND_PRINT((ndo, " 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:
bp += 2;
offset = EXTRACT_32BITS(bp);
bp += sizeof(uint32_t);
- switch (EXTRACT_16BITS(bp)) {
+ nla_afnum = EXTRACT_16BITS(bp);
+ bp += (2 * sizeof(uint16_t));
+ switch (nla_afnum) {
case AFNUM_INET:
- addr_size = sizeof(struct in_addr);
- nla_af = AF_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 AFNUM_INET6:
- addr_size = sizeof(struct in6_addr);
- nla_af = AF_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(uint16_t));
- if (opt_len != 12 + addr_size) {
- ND_PRINT((ndo, "[Bad OPT_PGMCC_FEEDBACK option, length %u != 12 + address size]", opt_len));
- return;
- }
- ND_TCHECK2(*bp, addr_size);
- nla = bp;
- bp += addr_size;
- inet_ntop(nla_af, nla, nla_buf, sizeof(nla_buf));
- ND_PRINT((ndo, " PGMCC FEEDBACK %u %s", offset, (char*)nla));
- opts_len -= 16;
+ ND_PRINT((ndo, " PGMCC FEEDBACK %u %s", offset, nla_buf));
break;
default:
diff --git a/contrib/tcpdump/print-pim.c b/contrib/tcpdump/print-pim.c
index 6738e37..2552595 100644
--- a/contrib/tcpdump/print-pim.c
+++ b/contrib/tcpdump/print-pim.c
@@ -17,22 +17,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$
*/
-#define NETDISSECT_REWORKED
+/* \summary: Protocol Independent Multicast (PIM) printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.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
@@ -136,7 +137,7 @@ struct pim {
u_short pim_cksum; /* IP style check sum */
};
-static void pimv2_print(netdissect_options *, 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(netdissect_options *ndo,
@@ -154,7 +155,7 @@ pimv1_join_prune_print(netdissect_options *ndo,
hold = EXTRACT_16BITS(&bp[6]);
if (hold != 180) {
ND_PRINT((ndo, "Hold "));
- relts_print(ndo, hold);
+ unsigned_relts_print(ndo, hold);
}
ND_PRINT((ndo, "%s (%s/%d, %s", njoin ? "Join" : "Prune",
ipaddr_string(ndo, &bp[26]), bp[25] & 0x3f,
@@ -176,7 +177,7 @@ pimv1_join_prune_print(netdissect_options *ndo,
if (ndo->ndo_vflag > 1)
ND_PRINT((ndo, "\n"));
ND_PRINT((ndo, " Hold time: "));
- relts_print(ndo, EXTRACT_16BITS(&bp[6]));
+ unsigned_relts_print(ndo, EXTRACT_16BITS(&bp[6]));
if (ndo->ndo_vflag < 2)
return;
bp += 8;
@@ -261,7 +262,7 @@ pimv1_print(netdissect_options *ndo,
if (ndo->ndo_vflag) {
ND_TCHECK2(bp[10],2);
ND_PRINT((ndo, " (Hold-time "));
- relts_print(ndo, EXTRACT_16BITS(&bp[10]));
+ unsigned_relts_print(ndo, EXTRACT_16BITS(&bp[10]));
ND_PRINT((ndo, ")"));
}
break;
@@ -283,7 +284,7 @@ pimv1_print(netdissect_options *ndo,
if (EXTRACT_32BITS(&bp[12]) != 0xffffffff)
ND_PRINT((ndo, "/%s", ipaddr_string(ndo, &bp[12])));
ND_PRINT((ndo, " RP %s hold ", ipaddr_string(ndo, &bp[16])));
- relts_print(ndo, EXTRACT_16BITS(&bp[22]));
+ unsigned_relts_print(ndo, EXTRACT_16BITS(&bp[22]));
}
break;
case PIMV1_TYPE_ASSERT:
@@ -350,7 +351,7 @@ cisco_autorp_print(netdissect_options *ndo,
ND_PRINT((ndo, " Hold "));
hold = EXTRACT_16BITS(&bp[2]);
if (hold)
- relts_print(ndo, EXTRACT_16BITS(&bp[2]));
+ unsigned_relts_print(ndo, EXTRACT_16BITS(&bp[2]));
else
ND_PRINT((ndo, "FOREVER"));
@@ -417,10 +418,10 @@ trunc:
void
pim_print(netdissect_options *ndo,
- register const u_char *bp, register u_int len, u_int cksum)
+ 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 *)ndo->ndo_snapend;
if (bp >= ep)
@@ -442,7 +443,7 @@ pim_print(netdissect_options *ndo,
PIM_VER(pim->pim_typever),
len,
tok2str(pimv2_type_values,"Unknown Type",PIM_TYPE(pim->pim_typever))));
- pimv2_print(ndo, bp, len, cksum);
+ pimv2_print(ndo, bp, len, bp2);
}
break;
default:
@@ -536,12 +537,10 @@ pimv2_addr_print(netdissect_options *ndo,
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;
}
@@ -553,11 +552,9 @@ pimv2_addr_print(netdissect_options *ndo,
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;
@@ -574,12 +571,10 @@ pimv2_addr_print(netdissect_options *ndo,
if (!silent)
ND_PRINT((ndo, "%s", ipaddr_string(ndo, bp)));
}
-#ifdef INET6
else if (af == AF_INET6) {
if (!silent)
ND_PRINT((ndo, "%s", ip6addr_string(ndo, bp)));
}
-#endif
return hdrlen + len;
case pimv2_group:
case pimv2_source:
@@ -591,7 +586,6 @@ pimv2_addr_print(netdissect_options *ndo,
ND_PRINT((ndo, "/%u", bp[1]));
}
}
-#ifdef INET6
else if (af == AF_INET6) {
if (!silent) {
ND_PRINT((ndo, "%s", ip6addr_string(ndo, bp + 2)));
@@ -599,7 +593,6 @@ pimv2_addr_print(netdissect_options *ndo,
ND_PRINT((ndo, "/%u", bp[1]));
}
}
-#endif
if (bp[0] && !silent) {
if (at == pimv2_group) {
ND_PRINT((ndo, "(0x%02x)", bp[0]));
@@ -622,13 +615,50 @@ 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(netdissect_options *ndo,
- register const u_char *bp, register u_int len, u_int cksum)
+ 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 *)ndo->ndo_snapend;
if (bp >= ep)
@@ -644,7 +674,41 @@ pimv2_print(netdissect_options *ndo,
if (EXTRACT_16BITS(&pim->pim_cksum) == 0) {
ND_PRINT((ndo, "(unverified)"));
} else {
- ND_PRINT((ndo, "(%scorrect)", ND_TTEST2(bp[0], len) && cksum ? "in" : "" ));
+ 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)) {
@@ -665,7 +729,7 @@ pimv2_print(netdissect_options *ndo,
switch (otype) {
case PIMV2_HELLO_OPTION_HOLDTIME:
- relts_print(ndo, EXTRACT_16BITS(bp));
+ unsigned_relts_print(ndo, EXTRACT_16BITS(bp));
break;
case PIMV2_HELLO_OPTION_LANPRUNEDELAY:
@@ -706,7 +770,7 @@ pimv2_print(netdissect_options *ndo,
ND_PRINT((ndo, "v%d", *bp));
if (*(bp+1) != 0) {
ND_PRINT((ndo, ", interval "));
- relts_print(ndo, *(bp+1));
+ unsigned_relts_print(ndo, *(bp+1));
}
if (EXTRACT_16BITS(bp+2) != 0) {
ND_PRINT((ndo, " ?0x%04x?", EXTRACT_16BITS(bp+2)));
@@ -721,8 +785,6 @@ pimv2_print(netdissect_options *ndo,
if (ndo->ndo_vflag > 1) {
const u_char *ptr = bp;
while (ptr < (bp+olen)) {
- int advance;
-
ND_PRINT((ndo, "\n\t "));
advance = pimv2_addr_print(ndo, ptr, pimv2_unicast, 0);
if (advance < 0) {
@@ -748,7 +810,7 @@ pimv2_print(netdissect_options *ndo,
case PIMV2_TYPE_REGISTER:
{
- struct ip *ip;
+ const struct ip *ip;
ND_TCHECK2(*(bp + 4), PIMV2_REGISTER_FLAG_LEN);
@@ -759,7 +821,7 @@ pimv2_print(netdissect_options *ndo,
bp += 8; len -= 8;
/* encapsulated multicast packet */
- ip = (struct ip *)bp;
+ ip = (const struct ip *)bp;
switch (IP_V(ip)) {
case 0: /* Null header */
ND_PRINT((ndo, "IP-Null-header %s > %s",
@@ -870,7 +932,7 @@ pimv2_print(netdissect_options *ndo,
if (holdtime == 0xffff)
ND_PRINT((ndo, "infinite"));
else
- relts_print(ndo, holdtime);
+ unsigned_relts_print(ndo, holdtime);
}
bp += 4; len -= 4;
for (i = 0; i < ngroup; i++) {
@@ -974,7 +1036,7 @@ pimv2_print(netdissect_options *ndo,
goto bs_done;
}
ND_PRINT((ndo, ",holdtime="));
- relts_print(ndo, EXTRACT_16BITS(bp));
+ unsigned_relts_print(ndo, EXTRACT_16BITS(bp));
if (bp + 2 >= ep) {
ND_PRINT((ndo, "...)"));
goto bs_done;
@@ -1026,7 +1088,7 @@ pimv2_print(netdissect_options *ndo,
ND_PRINT((ndo, " prio=%d", bp[1]));
if (bp + 3 >= ep) break;
ND_PRINT((ndo, " holdtime="));
- relts_print(ndo, EXTRACT_16BITS(&bp[2]));
+ unsigned_relts_print(ndo, EXTRACT_16BITS(&bp[2]));
bp += 4;
/* Encoded-Unicast-RP-Address */
@@ -1072,7 +1134,7 @@ pimv2_print(netdissect_options *ndo,
bp += advance;
ND_TCHECK2(bp[0], 2);
ND_PRINT((ndo, " TUNR "));
- relts_print(ndo, EXTRACT_16BITS(bp));
+ unsigned_relts_print(ndo, EXTRACT_16BITS(bp));
break;
diff --git a/contrib/tcpdump/print-pktap.c b/contrib/tcpdump/print-pktap.c
index 46a187d..7144f3c 100644
--- a/contrib/tcpdump/print-pktap.c
+++ b/contrib/tcpdump/print-pktap.c
@@ -19,14 +19,15 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#define NETDISSECT_REWORKED
+/* \summary: Apple's DLT_PKTAP printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
#ifdef DLT_PKTAP
@@ -71,16 +72,18 @@ 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",
- pcap_datalink_val_to_name(dlt), dlt, hdrlen));
+ ND_PRINT((ndo,"DLT %s (%d) len %d",
+ (dltname != NULL ? dltname : "UNKNOWN"), dlt, hdrlen));
} 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));
@@ -99,15 +102,14 @@ pktap_if_print(netdissect_options *ndo,
uint32_t dlt, hdrlen, rectype;
u_int caplen = h->caplen;
u_int length = h->len;
- if_ndo_printer ndo_printer;
- if_printer printer;
- pktap_header_t *hdr;
+ 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 = (pktap_header_t *)p;
+ 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)) {
@@ -142,12 +144,10 @@ pktap_if_print(netdissect_options *ndo,
case PKT_REC_PACKET:
if ((printer = lookup_printer(dlt)) != NULL) {
- printer(h, p);
- } else if ((ndo_printer = lookup_ndo_printer(dlt)) != NULL) {
- ndo_printer(ndo, h, p);
+ hdrlen += printer(ndo, h, p);
} else {
if (!ndo->ndo_eflag)
- pktap_header_print(ndo, (u_char *)hdr,
+ pktap_header_print(ndo, (const u_char *)hdr,
length + hdrlen);
if (!ndo->ndo_suppress_default_print)
diff --git a/contrib/tcpdump/print-ppi.c b/contrib/tcpdump/print-ppi.c
index b403536..72cd1b8 100644
--- a/contrib/tcpdump/print-ppi.c
+++ b/contrib/tcpdump/print-ppi.c
@@ -1,14 +1,16 @@
/*
* Oracle
*/
-#define NETDISSECT_REWORKED
+
+/* \summary: Oracle DLT_PPI printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
typedef struct ppi_header {
@@ -28,49 +30,56 @@ ppi_header_print(netdissect_options *ndo, const u_char *bp, u_int length)
const ppi_header_t *hdr;
uint16_t len;
uint32_t dlt;
+ const char *dltname;
hdr = (const ppi_header_t *)bp;
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,
+ (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
+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;
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;
+ hdr = (const ppi_header_t *)p;
len = EXTRACT_LE_16BITS(&hdr->ppi_len);
- if (len < sizeof(ppi_header_t)) {
+ if (caplen < len) {
+ /*
+ * If we don't have the entire PPI header, don't
+ * bother.
+ */
ND_PRINT((ndo, "[|ppi]"));
- return;
+ return (caplen);
}
- if (caplen < len) {
+ if (len < sizeof(ppi_header_t)) {
ND_PRINT((ndo, "[|ppi]"));
- return;
+ return (len);
}
dlt = EXTRACT_LE_32BITS(&hdr->ppi_dlt);
@@ -82,16 +91,19 @@ ppi_print(netdissect_options *ndo,
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 + len);
+ ppi_header_print(ndo, (const u_char *)hdr, length + len);
if (!ndo->ndo_suppress_default_print)
ND_DEFAULTPRINT(p, caplen);
+ hdrlen = 0;
}
+ return (len + hdrlen);
}
/*
@@ -104,9 +116,7 @@ u_int
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));
}
/*
diff --git a/contrib/tcpdump/print-ppp.c b/contrib/tcpdump/print-ppp.c
index 7e4870d..ee8239c 100644
--- a/contrib/tcpdump/print-ppp.c
+++ b/contrib/tcpdump/print-ppp.c
@@ -20,10 +20,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
@@ -31,12 +31,11 @@
* o BAP support
*/
-#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#ifdef __bsdi__
#include <net/slcompress.h>
@@ -45,7 +44,7 @@
#include <stdlib.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
#include "addrtoname.h"
#include "ppp.h"
@@ -945,6 +944,9 @@ handle_pap(netdissect_options *ndo,
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;
ND_TCHECK(*p);
@@ -973,6 +975,13 @@ handle_pap(netdissect_options *ndo,
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;
ND_TCHECK(*p);
@@ -1672,6 +1681,11 @@ ppp_hdlc_if_print(netdissect_options *ndo,
return (chdlc_if_print(ndo, h, p));
default:
+ 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;
diff --git a/contrib/tcpdump/print-pppoe.c b/contrib/tcpdump/print-pppoe.c
index 1624c5e..23d9a23 100644
--- a/contrib/tcpdump/print-pppoe.c
+++ b/contrib/tcpdump/print-pppoe.c
@@ -21,15 +21,16 @@
* Original code by Greg Stark <gsstark@mit.edu>
*/
-#define NETDISSECT_REWORKED
+/* \summary: PPP-over-Ethernet (PPPoE) printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
-#include "extract.h" /* must come after interface.h */
+#include "netdissect.h"
+#include "extract.h"
/* Codes */
enum {
@@ -147,7 +148,7 @@ pppoe_print(netdissect_options *ndo, register const u_char *bp, u_int length)
/* 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;
@@ -157,14 +158,14 @@ pppoe_print(netdissect_options *ndo, register const u_char *bp, u_int length)
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) {
+ if (ascii_count > garbage_count) {
ND_PRINT((ndo, " [%s \"%*.*s\"]",
tok2str(pppoetag2str, "TAG-0x%x", tag_type),
(int)tag_str_len,
diff --git a/contrib/tcpdump/print-pptp.c b/contrib/tcpdump/print-pptp.c
index c77868d..a4d713d 100644
--- a/contrib/tcpdump/print-pptp.c
+++ b/contrib/tcpdump/print-pptp.c
@@ -21,14 +21,15 @@
* PPTP support contributed by Motonori Shindo (mshindo@mshindo.net)
*/
-#define NETDISSECT_REWORKED
+/* \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 "interface.h"
+#include "netdissect.h"
#include "extract.h"
static const char tstr[] = " [|pptp]";
@@ -518,7 +519,7 @@ static void
pptp_sccrq_print(netdissect_options *ndo,
const u_char *dat)
{
- struct pptp_msg_sccrq *ptr = (struct pptp_msg_sccrq *)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);
@@ -546,7 +547,7 @@ static void
pptp_sccrp_print(netdissect_options *ndo,
const u_char *dat)
{
- struct pptp_msg_sccrp *ptr = (struct pptp_msg_sccrp *)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);
@@ -577,7 +578,7 @@ static void
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;
ND_TCHECK(ptr->reason);
ND_PRINT((ndo, " REASON(%u", ptr->reason));
@@ -611,7 +612,7 @@ static void
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;
ND_TCHECK(ptr->result_code);
pptp_result_code_print(ndo, &ptr->result_code, PPTP_CTRL_MSG_TYPE_StopCCRP);
@@ -629,7 +630,7 @@ static void
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;
ND_TCHECK(ptr->id);
pptp_id_print(ndo, &ptr->id);
@@ -644,7 +645,7 @@ static void
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;
ND_TCHECK(ptr->id);
pptp_id_print(ndo, &ptr->id);
@@ -664,7 +665,7 @@ static void
pptp_ocrq_print(netdissect_options *ndo,
const u_char *dat)
{
- struct pptp_msg_ocrq *ptr = (struct pptp_msg_ocrq *)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);
@@ -700,7 +701,7 @@ static void
pptp_ocrp_print(netdissect_options *ndo,
const u_char *dat)
{
- struct pptp_msg_ocrp *ptr = (struct pptp_msg_ocrp *)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);
@@ -731,7 +732,7 @@ static void
pptp_icrq_print(netdissect_options *ndo,
const u_char *dat)
{
- struct pptp_msg_icrq *ptr = (struct pptp_msg_icrq *)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);
@@ -762,7 +763,7 @@ static void
pptp_icrp_print(netdissect_options *ndo,
const u_char *dat)
{
- struct pptp_msg_icrp *ptr = (struct pptp_msg_icrp *)dat;
+ 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);
@@ -788,7 +789,7 @@ static void
pptp_iccn_print(netdissect_options *ndo,
const u_char *dat)
{
- struct pptp_msg_iccn *ptr = (struct pptp_msg_iccn *)dat;
+ 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);
@@ -812,7 +813,7 @@ static void
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;
ND_TCHECK(ptr->call_id);
pptp_call_id_print(ndo, &ptr->call_id);
@@ -828,7 +829,7 @@ static void
pptp_cdn_print(netdissect_options *ndo,
const u_char *dat)
{
- struct pptp_msg_cdn *ptr = (struct pptp_msg_cdn *)dat;
+ 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);
@@ -852,7 +853,7 @@ static void
pptp_wen_print(netdissect_options *ndo,
const u_char *dat)
{
- struct pptp_msg_wen *ptr = (struct pptp_msg_wen *)dat;
+ 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);
@@ -880,7 +881,7 @@ static void
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;
ND_TCHECK(ptr->peer_call_id);
pptp_peer_call_id_print(ndo, &ptr->peer_call_id);
@@ -906,7 +907,7 @@ pptp_print(netdissect_options *ndo,
ND_PRINT((ndo, ": pptp"));
- hdr = (struct pptp_hdr *)dat;
+ hdr = (const struct pptp_hdr *)dat;
ND_TCHECK(hdr->length);
if (ndo->ndo_vflag) {
diff --git a/contrib/tcpdump/print-radius.c b/contrib/tcpdump/print-radius.c
index 5cf8ad2..eb48de5 100644
--- a/contrib/tcpdump/print-radius.c
+++ b/contrib/tcpdump/print-radius.c
@@ -19,6 +19,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:
*
@@ -37,6 +40,10 @@
* 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"
*
@@ -48,16 +55,15 @@
* TODO: Among other things to print ok MacIntosh and Vendor values
*/
-#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <string.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "extract.h"
#include "oui.h"
@@ -162,12 +168,12 @@ static const struct tok rfc4675_tagged[] = {
};
-static void print_attr_string(netdissect_options *, register u_char *, u_int, u_short );
-static void print_attr_num(netdissect_options *, register u_char *, u_int, u_short );
-static void print_vendor_attr(netdissect_options *, register u_char *, u_int, u_short );
-static void print_attr_address(netdissect_options *, register u_char *, u_int, u_short);
-static void print_attr_time(netdissect_options *, register u_char *, u_int, u_short);
-static void print_attr_strange(netdissect_options *, 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 { uint8_t code; /* Radius packet code */
@@ -331,6 +337,7 @@ static const char *tunnel_type[]={ NULL,
"GRE",
"DVS",
"IP-in-IP Tunneling",
+ "VLAN",
};
/* Tunnel-Medium-Type Attribute standard values */
@@ -365,11 +372,12 @@ 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)(netdissect_options *, 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 },
@@ -478,7 +486,7 @@ struct attrtype { const char *name; /* Attribute name */
/*****************************/
static void
print_attr_string(netdissect_options *ndo,
- register u_char *data, u_int length, u_short attr_code)
+ register const u_char *data, u_int length, u_short attr_code)
{
register u_int i;
@@ -533,7 +541,7 @@ print_attr_string(netdissect_options *ndo,
}
for (i=0; *data && i < length ; i++, data++)
- ND_PRINT((ndo, "%c", (*data < 32 || *data > 128) ? '.' : *data));
+ ND_PRINT((ndo, "%c", (*data < 32 || *data > 126) ? '.' : *data));
return;
@@ -546,7 +554,7 @@ print_attr_string(netdissect_options *ndo,
*/
static void
print_vendor_attr(netdissect_options *ndo,
- register u_char *data, u_int length, u_short attr_code _U_)
+ register const u_char *data, u_int length, u_short attr_code _U_)
{
u_int idx;
u_int vendor_id;
@@ -593,7 +601,7 @@ print_vendor_attr(netdissect_options *ndo,
vendor_type,
vendor_length));
for (idx = 0; idx < vendor_length ; idx++, data++)
- ND_PRINT((ndo, "%c", (*data < 32 || *data > 128) ? '.' : *data));
+ ND_PRINT((ndo, "%c", (*data < 32 || *data > 126) ? '.' : *data));
length-=vendor_length;
}
return;
@@ -611,7 +619,7 @@ print_vendor_attr(netdissect_options *ndo,
/******************************/
static void
print_attr_num(netdissect_options *ndo,
- register u_char *data, u_int length, u_short attr_code)
+ register const u_char *data, u_int length, u_short attr_code)
{
uint32_t timeout;
@@ -734,7 +742,7 @@ print_attr_num(netdissect_options *ndo,
/*****************************/
static void
print_attr_address(netdissect_options *ndo,
- register u_char *data, u_int length, u_short attr_code)
+ register const u_char *data, u_int length, u_short attr_code)
{
if (length != 4)
{
@@ -778,7 +786,7 @@ print_attr_address(netdissect_options *ndo,
/*************************************/
static void
print_attr_time(netdissect_options *ndo,
- register u_char *data, u_int length, u_short attr_code _U_)
+ register const u_char *data, u_int length, u_short attr_code _U_)
{
time_t attr_time;
char string[26];
@@ -811,7 +819,7 @@ print_attr_time(netdissect_options *ndo,
/***********************************/
static void
print_attr_strange(netdissect_options *ndo,
- register u_char *data, u_int length, u_short attr_code)
+ register const u_char *data, u_int length, u_short attr_code)
{
u_short len_data;
@@ -884,7 +892,7 @@ static void
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)
@@ -924,16 +932,16 @@ radius_attrs_print(netdissect_options *ndo,
{
if ( attr_type[rad_attr->type].print_func )
(*attr_type[rad_attr->type].print_func)(
- ndo, ((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 (ndo->ndo_vflag> 1)
- print_unknown_data(ndo, (u_char *)rad_attr+2, "\n\t ", (rad_attr->len)-2);
+ 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;
@@ -949,7 +957,7 @@ radius_print(netdissect_options *ndo,
u_int len, auth_idx;
ND_TCHECK2(*dat, MIN_RADIUS_LEN);
- rad = (struct radius_hdr *)dat;
+ rad = (const struct radius_hdr *)dat;
len = EXTRACT_16BITS(&rad->len);
if (len < MIN_RADIUS_LEN)
diff --git a/contrib/tcpdump/print-raw.c b/contrib/tcpdump/print-raw.c
index d20387c..463aa41 100644
--- a/contrib/tcpdump/print-raw.c
+++ b/contrib/tcpdump/print-raw.c
@@ -19,14 +19,15 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#define NETDISSECT_REWORKED
+/* \summary: Raw IP printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
/*
* The DLT_RAW packet has no header. It contains a raw IP packet.
diff --git a/contrib/tcpdump/print-resp.c b/contrib/tcpdump/print-resp.c
new file mode 100644
index 0000000..9d71e21
--- /dev/null
+++ b/contrib/tcpdump/print-resp.c
@@ -0,0 +1,538 @@
+/*
+ * 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);
+}
diff --git a/contrib/tcpdump/print-rip.c b/contrib/tcpdump/print-rip.c
index c1b036e..cf661d0 100644
--- a/contrib/tcpdump/print-rip.c
+++ b/contrib/tcpdump/print-rip.c
@@ -19,18 +19,19 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#define NETDISSECT_REWORKED
+/* \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 "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
-#include "extract.h" /* must come after interface.h */
+#include "extract.h"
#include "af.h"
@@ -102,14 +103,14 @@ rip_entry_print_v1(netdissect_options *ndo,
family = EXTRACT_16BITS(&ni->rip_family);
if (family != BSD_AFNUM_INET && family != 0) {
ND_PRINT((ndo, "\n\t AFI %s, ", tok2str(bsd_af_values, "Unknown (%u)", family)));
- print_unknown_data(ndo, (uint8_t *)&ni->rip_family, "\n\t ", RIP_ROUTELEN);
+ 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(ndo, (uint8_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) {
@@ -133,31 +134,31 @@ rip_entry_print_v2(netdissect_options *ndo,
if (family == 0xFFFF) { /* variable-sized authentication structures */
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;
ND_PRINT((ndo, "\n\t Simple Text Authentication data: "));
for (; i < RIP_AUTHLEN; p++, i++)
ND_PRINT((ndo, "%c", ND_ISPRINT(*p) ? *p : '.'));
} else if (auth_type == 3) {
ND_PRINT((ndo, "\n\t Auth header:"));
- ND_PRINT((ndo, " Packet Len %u,", EXTRACT_16BITS((uint8_t *)ni + 4)));
- ND_PRINT((ndo, " Key-ID %u,", *((uint8_t *)ni + 6)));
- ND_PRINT((ndo, " Auth Data Len %u,", *((uint8_t *)ni + 7)));
+ 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) {
ND_PRINT((ndo, "\n\t Auth trailer:"));
- print_unknown_data(ndo, (uint8_t *)&ni->rip_dest, "\n\t ", remaining);
+ print_unknown_data(ndo, (const uint8_t *)&ni->rip_dest, "\n\t ", remaining);
return remaining; /* AT spans till the packet end */
} else {
ND_PRINT((ndo, "\n\t Unknown (%u) Authentication data:",
EXTRACT_16BITS(&ni->rip_tag)));
- print_unknown_data(ndo, (uint8_t *)&ni->rip_dest, "\n\t ", remaining);
+ print_unknown_data(ndo, (const uint8_t *)&ni->rip_dest, "\n\t ", remaining);
}
} else if (family != BSD_AFNUM_INET && family != 0) {
ND_PRINT((ndo, "\n\t AFI %s", tok2str(bsd_af_values, "Unknown (%u)", family)));
- print_unknown_data(ndo, (uint8_t *)&ni->rip_tag, "\n\t ", RIP_ROUTELEN-2);
+ print_unknown_data(ndo, (const uint8_t *)&ni->rip_tag, "\n\t ", RIP_ROUTELEN-2);
} else { /* BSD_AFNUM_INET or AFI 0 */
ND_PRINT((ndo, "\n\t AFI %s, %15s/%-2d, tag 0x%04x, metric: %u, next-hop: ",
tok2str(bsd_af_values, "%u", family),
@@ -194,7 +195,7 @@ rip_print(netdissect_options *ndo,
}
i -= sizeof(*rp);
- rp = (struct rip *)dat;
+ rp = (const struct rip *)dat;
ND_PRINT((ndo, "%sRIPv%u",
(ndo->ndo_vflag >= 1) ? "\n\t" : "",
@@ -213,7 +214,7 @@ rip_print(netdissect_options *ndo,
*
* so perhaps we should just dump the packet, in hex.
*/
- print_unknown_data(ndo, (uint8_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*/
@@ -231,7 +232,7 @@ rip_print(netdissect_options *ndo,
case RIPCMD_RESPONSE:
j = length / sizeof(*ni);
ND_PRINT((ndo, ", routes: %u%s", j, rp->rip_vers == 2 ? " or less" : ""));
- ni = (struct rip_netinfo *)(rp + 1);
+ ni = (const struct rip_netinfo *)(rp + 1);
for (; i >= sizeof(*ni); ++ni) {
if (rp->rip_vers == 1)
{
@@ -256,14 +257,14 @@ rip_print(netdissect_options *ndo,
/* fall through */
default:
if (ndo->ndo_vflag <= 1) {
- if(!print_unknown_data(ndo, (uint8_t *)rp, "\n\t", length))
+ if(!print_unknown_data(ndo, (const uint8_t *)rp, "\n\t", length))
return;
}
break;
}
/* do we want to see an additionally hexdump ? */
if (ndo->ndo_vflag> 1) {
- if(!print_unknown_data(ndo, (uint8_t *)rp, "\n\t", length))
+ if(!print_unknown_data(ndo, (const uint8_t *)rp, "\n\t", length))
return;
}
}
diff --git a/contrib/tcpdump/print-ripng.c b/contrib/tcpdump/print-ripng.c
index 4bc900d..25e9bbc 100644
--- a/contrib/tcpdump/print-ripng.c
+++ b/contrib/tcpdump/print-ripng.c
@@ -19,16 +19,15 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#define NETDISSECT_REWORKED
+/* \summary: IPv6 Routing Information Protocol (RIPng) printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#ifdef INET6
-
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "extract.h"
@@ -109,7 +108,7 @@ rip6_entry_print(netdissect_options *ndo, register const struct netinfo6 *ni, in
void
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;
@@ -173,4 +172,3 @@ ripng_print(netdissect_options *ndo, const u_char *dat, unsigned int length)
if (rp->rip6_vers != RIP6_VERSION)
ND_PRINT((ndo, " [vers %d]", rp->rip6_vers));
}
-#endif /* INET6 */
diff --git a/contrib/tcpdump/print-rpki-rtr.c b/contrib/tcpdump/print-rpki-rtr.c
index 34e2057..77e29c7 100644
--- a/contrib/tcpdump/print-rpki-rtr.c
+++ b/contrib/tcpdump/print-rpki-rtr.c
@@ -12,24 +12,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)
*/
-#define NETDISSECT_REWORKED
+/* \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 <string.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
#include "addrtoname.h"
+static const char tstr[] = "[|RPKI-RTR]";
+
/*
* RPKI/Router PDU header
*
@@ -168,14 +171,14 @@ indent_string (u_int indent)
/*
* Print a single PDU.
*/
-static void
+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);
@@ -221,9 +224,9 @@ rpki_rtr_pdu_print (netdissect_options *ndo, const u_char *tptr, u_int indent)
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;
+ 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(ndo, pdu->prefix),
@@ -232,12 +235,11 @@ rpki_rtr_pdu_print (netdissect_options *ndo, const u_char *tptr, u_int indent)
}
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;
+ 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(ndo, pdu->prefix),
@@ -245,14 +247,13 @@ rpki_rtr_pdu_print (netdissect_options *ndo, const u_char *tptr, u_int indent)
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;
- 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;
@@ -272,7 +273,8 @@ rpki_rtr_pdu_print (netdissect_options *ndo, const u_char *tptr, u_int indent)
if (encapsulated_pdu_length &&
(encapsulated_pdu_length <= tlen)) {
ND_PRINT((ndo, "%s-----encapsulated PDU-----", indent_string(indent+4)));
- rpki_rtr_pdu_print(ndo, tptr, indent+2);
+ if (rpki_rtr_pdu_print(ndo, tptr, indent+2))
+ goto trunc;
}
tptr += encapsulated_pdu_length;
@@ -290,7 +292,8 @@ rpki_rtr_pdu_print (netdissect_options *ndo, const u_char *tptr, u_int indent)
ND_TCHECK2(*tptr, text_length);
if (text_length && (text_length <= tlen )) {
ND_PRINT((ndo, "%sError text: ", indent_string(indent+2)));
- fn_printn(ndo, tptr, text_length, ndo->ndo_snapend);
+ if (fn_printn(ndo, tptr, text_length, ndo->ndo_snapend))
+ goto trunc;
}
}
break;
@@ -307,11 +310,10 @@ rpki_rtr_pdu_print (netdissect_options *ndo, const u_char *tptr, u_int indent)
if (ndo->ndo_vflag > 1 || (ndo->ndo_vflag && hexdump)) {
print_unknown_data(ndo,tptr,"\n\t ", pdu_len);
}
- return;
+ return 0;
- trunc:
- ND_PRINT((ndo, "|trunc"));
- return;
+trunc:
+ return 1;
}
void
@@ -333,7 +335,7 @@ rpki_rtr_print(netdissect_options *ndo, register const u_char *pptr, register u_
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);
@@ -350,14 +352,15 @@ rpki_rtr_print(netdissect_options *ndo, register const u_char *pptr, register u_
/*
* Print the PDU.
*/
- rpki_rtr_pdu_print(ndo, tptr, 8);
+ if (rpki_rtr_pdu_print(ndo, tptr, 8))
+ goto trunc;
tlen -= pdu_len;
tptr += pdu_len;
}
return;
- trunc:
- ND_PRINT((ndo, "\n\t[|RPKI-RTR]"));
+trunc:
+ ND_PRINT((ndo, "\n\t%s", tstr));
}
/*
diff --git a/contrib/tcpdump/print-rrcp.c b/contrib/tcpdump/print-rrcp.c
index 2370d9c..936b3ea 100644
--- a/contrib/tcpdump/print-rrcp.c
+++ b/contrib/tcpdump/print-rrcp.c
@@ -21,14 +21,15 @@
* and Realtek Echo Protocol (RRCP-REP) packets.
*/
-#define NETDISSECT_REWORKED
+/* \summary: Realtek Remote Control Protocol (RRCP) printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "extract.h"
#include "ether.h"
@@ -72,56 +73,54 @@ 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;
uint8_t rrcp_proto;
uint8_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(ndo, ESRC(ep)),
- etheraddr_string(ndo, EDST(ep)),
- tok2strbuf(proto_values,"RRCP-0x%02x",rrcp_proto,proto_str,sizeof(proto_str)),
- ((*(rrcp + RRCP_OPCODE_ISREPLY_OFFSET)) & RRCP_ISREPLY) ? "reply" : "query"));
+ 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(ndo, 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)));
}
return;
diff --git a/contrib/tcpdump/print-rsvp.c b/contrib/tcpdump/print-rsvp.c
index 263ef3d..be3dfa3 100644
--- a/contrib/tcpdump/print-rsvp.c
+++ b/contrib/tcpdump/print-rsvp.c
@@ -15,14 +15,15 @@
* Original code by Hannes Gredler (hannes@juniper.net)
*/
-#define NETDISSECT_REWORKED
+/* \summary: Resource ReSerVation Protocol (RSVP) printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
#include "addrtoname.h"
#include "ethertype.h"
@@ -30,6 +31,8 @@
#include "af.h"
#include "signature.h"
+static const char tstr[] = " [|rsvp]";
+
/*
* RFC 2205 common header
*
@@ -82,7 +85,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
@@ -96,7 +99,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" },
@@ -497,6 +500,7 @@ rsvp_intserv_print(netdissect_options *ndo,
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 */
ND_PRINT((ndo, "\n\t Parameter ID: %s (%u), length: %u, Flags: [0x%02x]",
@@ -517,8 +521,10 @@ rsvp_intserv_print(netdissect_options *ndo,
* | IS hop cnt (32-bit unsigned integer) |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
- if (parameter_length == 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:
@@ -530,6 +536,7 @@ rsvp_intserv_print(netdissect_options *ndo,
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
if (parameter_length == 4) {
+ ND_TCHECK2(*(tptr + 4), 4);
bw.i = EXTRACT_32BITS(tptr+4);
ND_PRINT((ndo, "\n\t\tPath b/w estimate: %.10g Mbps", bw.f / 125000));
}
@@ -544,6 +551,7 @@ rsvp_intserv_print(netdissect_options *ndo,
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
if (parameter_length == 4) {
+ ND_TCHECK2(*(tptr + 4), 4);
ND_PRINT((ndo, "\n\t\tMinimum path latency: "));
if (EXTRACT_32BITS(tptr+4) == 0xffffffff)
ND_PRINT((ndo, "don't care"));
@@ -561,8 +569,10 @@ rsvp_intserv_print(netdissect_options *ndo,
* | Composed MTU (32-bit unsigned integer) |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
- if (parameter_length == 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:
/*
@@ -582,6 +592,7 @@ rsvp_intserv_print(netdissect_options *ndo,
*/
if (parameter_length == 20) {
+ ND_TCHECK2(*(tptr + 4), 20);
bw.i = EXTRACT_32BITS(tptr+4);
ND_PRINT((ndo, "\n\t\tToken Bucket Rate: %.10g Mbps", bw.f / 125000));
bw.i = EXTRACT_32BITS(tptr+8);
@@ -605,6 +616,7 @@ rsvp_intserv_print(netdissect_options *ndo,
*/
if (parameter_length == 8) {
+ ND_TCHECK2(*(tptr + 4), 8);
bw.i = EXTRACT_32BITS(tptr+4);
ND_PRINT((ndo, "\n\t\tRate: %.10g Mbps", bw.f / 125000));
ND_PRINT((ndo, "\n\t\tSlack Term: %u", EXTRACT_32BITS(tptr + 8)));
@@ -615,8 +627,10 @@ rsvp_intserv_print(netdissect_options *ndo,
case 134:
case 135:
case 136:
- if (parameter_length == 4)
+ if (parameter_length == 4) {
+ ND_TCHECK2(*(tptr + 4), 4);
ND_PRINT((ndo, "\n\t\tValue: %u", EXTRACT_32BITS(tptr + 4)));
+ }
break;
default:
@@ -624,20 +638,29 @@ rsvp_intserv_print(netdissect_options *ndo,
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;
+}
+
+/*
+ * 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
-#ifndef HAVE_LIBCRYPTO
-_U_
-#endif
-, u_int plen
-#ifndef HAVE_LIBCRYPTO
-_U_
-#endif
-, const u_char *tptr,
- const char *ident, u_int tlen)
+ 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;
@@ -723,7 +746,6 @@ _U_
obj_tlen-=8;
obj_tptr+=8;
break;
-#ifdef INET6
case RSVP_CTYPE_IPV6:
if (obj_tlen < 20)
return -1;
@@ -762,7 +784,6 @@ _U_
obj_tlen-=26;
obj_tptr+=26;
break;
-#endif
case RSVP_CTYPE_13: /* IPv4 p2mp LSP Tunnel */
if (obj_tlen < 12)
return -1;
@@ -802,7 +823,6 @@ _U_
obj_tlen-=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;
@@ -812,7 +832,6 @@ _U_
obj_tlen-=sizeof(struct in6_addr);
obj_tptr+=sizeof(struct in6_addr);
break;
-#endif
default:
hexdump=TRUE;
}
@@ -829,7 +848,6 @@ _U_
obj_tlen-=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;
@@ -839,7 +857,6 @@ _U_
obj_tlen-=sizeof(struct in6_addr);
obj_tptr+=sizeof(struct in6_addr);
break;
-#endif
default:
hexdump=TRUE;
}
@@ -914,7 +931,6 @@ _U_
obj_tlen-=8;
obj_tptr+=8;
break;
-#ifdef INET6
case RSVP_CTYPE_IPV6:
if (obj_tlen < 20)
return-1;
@@ -939,7 +955,6 @@ _U_
obj_tlen-=40;
obj_tptr+=40;
break;
-#endif
case RSVP_CTYPE_TUNNEL_IPV4:
if (obj_tlen < 8)
return-1;
@@ -1051,20 +1066,37 @@ _U_
switch(rsvp_obj_ctype) {
case RSVP_CTYPE_IPV4:
while(obj_tlen >= 4 ) {
+ 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 */
+ 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:
+ 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(ndo, obj_tptr+2),
@@ -1074,6 +1106,11 @@ _U_
*(obj_tptr + 7)))); /* rfc3209 says that this field is rsvd. */
break;
case RSVP_OBJ_XRO_LABEL:
+ 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",
@@ -1179,6 +1216,9 @@ _U_
tok2str(af_values, "Unknown", af), af,
subobj_len));
+ if(subobj_len == 0)
+ goto invalid;
+
switch(subobj_type) {
case RSVP_GEN_UNI_SUBOBJ_SOURCE_TNA_ADDRESS:
case RSVP_GEN_UNI_SUBOBJ_DESTINATION_TNA_ADDRESS:
@@ -1190,14 +1230,12 @@ _U_
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;
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 */
@@ -1271,7 +1309,6 @@ _U_
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)
@@ -1284,7 +1321,6 @@ _U_
obj_tptr+=20;
hexdump=TRUE; /* unless we have a TLV parser lets just hexdump */
break;
-#endif
default:
hexdump=TRUE;
}
@@ -1360,7 +1396,6 @@ _U_
obj_tlen-=8;
obj_tptr+=8;
break;
-#ifdef INET6
case RSVP_CTYPE_IPV6:
if (obj_tlen < 20)
return-1;
@@ -1405,7 +1440,6 @@ _U_
obj_tlen-=40;
obj_tptr+=40;
break;
-#endif
case RSVP_CTYPE_TUNNEL_IPV4:
if (obj_tlen < 8)
return-1;
@@ -1547,7 +1581,6 @@ _U_
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)
@@ -1574,7 +1607,6 @@ _U_
obj_tlen-=20;
obj_tptr+=20;
break;
-#endif
default:
hexdump=TRUE;
}
@@ -1664,12 +1696,10 @@ _U_
EXTRACT_32BITS(obj_ptr.rsvp_obj_integrity->digest+8),
EXTRACT_32BITS(obj_ptr.rsvp_obj_integrity->digest + 12)));
-#ifdef HAVE_LIBCRYPTO
- sigcheck = signature_verify(ndo, pptr, plen, (unsigned char *)obj_ptr.\
- rsvp_obj_integrity->digest);
-#else
- sigcheck = CANT_CHECK_SIGNATURE;
-#endif
+ 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);
@@ -1750,7 +1780,6 @@ _U_
obj_tlen-=4;
obj_tptr+=4;
break;
-#ifdef INET6
case RSVP_CTYPE_IPV6:
if (obj_tlen < 16)
return-1;
@@ -1760,7 +1789,6 @@ _U_
obj_tlen-=16;
obj_tptr+=16;
break;
-#endif
default:
hexdump=TRUE;
}
@@ -1788,8 +1816,12 @@ _U_
tlen-=rsvp_obj_len;
}
return 0;
+invalid:
+ ND_PRINT((ndo, "%s", istr));
+ return -1;
trunc:
- ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
+ ND_PRINT((ndo, "\n\t\t"));
+ ND_PRINT((ndo, "%s", tstr));
return -1;
}
@@ -1797,13 +1829,13 @@ void
rsvp_print(netdissect_options *ndo,
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;
+ 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;
+ rsvp_com_header = (const struct rsvp_common_header *)pptr;
ND_TCHECK(*rsvp_com_header);
/*
@@ -1837,12 +1869,6 @@ rsvp_print(netdissect_options *ndo,
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;
-
if (tlen < 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)));
@@ -1854,10 +1880,19 @@ rsvp_print(netdissect_options *ndo,
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;
+ 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);
/*
@@ -1868,7 +1903,8 @@ rsvp_print(netdissect_options *ndo,
RSVP_EXTRACT_VERSION(rsvp_com_header->version_flags)));
return;
}
- subtlen=EXTRACT_16BITS(rsvp_com_header->length);
+
+ 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),
@@ -1879,12 +1915,6 @@ rsvp_print(netdissect_options *ndo,
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;
-
if (subtlen < 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)));
@@ -1900,7 +1930,10 @@ rsvp_print(netdissect_options *ndo,
subtptr+=sizeof(const struct rsvp_common_header);
subtlen-=sizeof(const struct rsvp_common_header);
- if (rsvp_obj_print(ndo, 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);
@@ -1920,7 +1953,10 @@ rsvp_print(netdissect_options *ndo,
case RSVP_MSGTYPE_HELLO:
case RSVP_MSGTYPE_ACK:
case RSVP_MSGTYPE_SREFRESH:
- if (rsvp_obj_print(ndo, 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;
@@ -1931,5 +1967,6 @@ rsvp_print(netdissect_options *ndo,
return;
trunc:
- ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
+ ND_PRINT((ndo, "\n\t\t"));
+ ND_PRINT((ndo, "%s", tstr));
}
diff --git a/contrib/tcpdump/print-rt6.c b/contrib/tcpdump/print-rt6.c
index 3d5f9e3..35dbed9 100644
--- a/contrib/tcpdump/print-rt6.c
+++ b/contrib/tcpdump/print-rt6.c
@@ -19,20 +19,19 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#define NETDISSECT_REWORKED
+/* \summary: IPv6 routing header printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#ifdef INET6
-
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <string.h>
#include "ip6.h"
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "extract.h"
@@ -44,9 +43,8 @@ rt6_print(netdissect_options *ndo, register const u_char *bp, const u_char *bp2
register const u_char *ep;
int i, len;
register const struct in6_addr *addr;
- const struct in6_addr *last_addr = NULL;
- dp = (struct ip6_rthdr *)bp;
+ dp = (const struct ip6_rthdr *)bp;
len = dp->ip6r_len;
/* 'ep' points to the end of available data. */
@@ -59,15 +57,9 @@ rt6_print(netdissect_options *ndo, register const u_char *bp, const u_char *bp2
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;
ND_TCHECK(dp0->ip6r0_reserved);
if (dp0->ip6r0_reserved || ndo->ndo_vflag) {
@@ -80,21 +72,12 @@ rt6_print(netdissect_options *ndo, register const u_char *bp, const u_char *bp2
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;
ND_PRINT((ndo, ", [%d]%s", i, ip6addr_string(ndo, addr)));
- last_addr = addr;
addr++;
}
- /*
- * the destination address used in the pseudo-header is that of the final
- * destination : the last address of the routing header
- */
- if (last_addr != NULL) {
- struct ip6_hdr *ip6 = (struct ip6_hdr *)bp2;
- UNALIGNED_MEMCPY(&ip6->ip6_dst, last_addr, sizeof (struct in6_addr));
- }
/*(*/
ND_PRINT((ndo, ") "));
return((dp0->ip6r0_len + 1) << 3);
@@ -108,4 +91,3 @@ rt6_print(netdissect_options *ndo, register const u_char *bp, const u_char *bp2
ND_PRINT((ndo, "[|srcrt]"));
return -1;
}
-#endif /* INET6 */
diff --git a/contrib/tcpdump/print-rtsp.c b/contrib/tcpdump/print-rtsp.c
index d721b8d..54cc930 100644
--- a/contrib/tcpdump/print-rtsp.c
+++ b/contrib/tcpdump/print-rtsp.c
@@ -11,21 +11,18 @@
* FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] _U_ =
- "@(#) $Header$";
-#endif
+/* \summary: Real Time Streaming Protocol (RTSP) printer */
#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"
static const char *rtspcmds[] = {
diff --git a/contrib/tcpdump/print-rx.c b/contrib/tcpdump/print-rx.c
index 8a9babb..ea3a5e6 100644
--- a/contrib/tcpdump/print-rx.c
+++ b/contrib/tcpdump/print-rx.c
@@ -20,6 +20,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.
@@ -32,7 +35,6 @@
* Ken Hornstein <kenh@cmf.nrl.navy.mil>
*/
-#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -40,9 +42,9 @@
#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"
@@ -522,9 +524,9 @@ static int is_ubik(uint32_t);
void
rx_print(netdissect_options *ndo,
register const u_char *bp, int length, int sport, int dport,
- u_char *bp2)
+ const u_char *bp2)
{
- register struct rx_header *rxh;
+ register const struct rx_header *rxh;
int i;
int32_t opcode;
@@ -533,7 +535,7 @@ rx_print(netdissect_options *ndo,
return;
}
- rxh = (struct rx_header *) bp;
+ rxh = (const struct rx_header *) bp;
ND_PRINT((ndo, " rx %s", tok2str(rx_types, "type %d", rxh->type)));
@@ -689,8 +691,8 @@ rx_cache_insert(netdissect_options *ndo,
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));
@@ -709,8 +711,11 @@ rx_cache_find(const struct rx_header *rxh, const struct ip *ip, int sport,
{
int i;
struct rx_cache_entry *rxent;
- uint32_t clip = ip->ip_dst.s_addr;
- uint32_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 */
@@ -752,63 +757,63 @@ rx_cache_find(const struct rx_header *rxh, const struct ip *ip, int sport,
ND_PRINT((ndo, " fid %d/%d/%d", (int) n1, (int) n2, (int) n3)); \
}
-#define STROUT(MAX) { unsigned int i; \
+#define STROUT(MAX) { unsigned int _i; \
ND_TCHECK2(bp[0], sizeof(int32_t)); \
- i = EXTRACT_32BITS(bp); \
- if (i > (MAX)) \
+ _i = EXTRACT_32BITS(bp); \
+ if (_i > (MAX)) \
goto trunc; \
bp += sizeof(int32_t); \
ND_PRINT((ndo, " \"")); \
- if (fn_printn(ndo, bp, i, ndo->ndo_snapend)) \
+ if (fn_printn(ndo, bp, _i, ndo->ndo_snapend)) \
goto trunc; \
ND_PRINT((ndo, "\"")); \
- bp += ((i + sizeof(int32_t) - 1) / sizeof(int32_t)) * sizeof(int32_t); \
+ bp += ((_i + sizeof(int32_t) - 1) / sizeof(int32_t)) * sizeof(int32_t); \
}
-#define INTOUT() { int i; \
+#define INTOUT() { int _i; \
ND_TCHECK2(bp[0], sizeof(int32_t)); \
- i = (int) EXTRACT_32BITS(bp); \
+ _i = (int) EXTRACT_32BITS(bp); \
bp += sizeof(int32_t); \
- ND_PRINT((ndo, " %d", i)); \
+ ND_PRINT((ndo, " %d", _i)); \
}
-#define UINTOUT() { unsigned long i; \
+#define UINTOUT() { unsigned long _i; \
ND_TCHECK2(bp[0], sizeof(int32_t)); \
- i = EXTRACT_32BITS(bp); \
+ _i = EXTRACT_32BITS(bp); \
bp += sizeof(int32_t); \
- ND_PRINT((ndo, " %lu", i)); \
+ ND_PRINT((ndo, " %lu", _i)); \
}
-#define UINT64OUT() { uint64_t i; \
+#define UINT64OUT() { uint64_t _i; \
ND_TCHECK2(bp[0], sizeof(uint64_t)); \
- i = EXTRACT_64BITS(bp); \
+ _i = EXTRACT_64BITS(bp); \
bp += sizeof(uint64_t); \
- ND_PRINT((ndo, " %" PRIu64, i)); \
+ ND_PRINT((ndo, " %" PRIu64, _i)); \
}
-#define DATEOUT() { time_t t; struct tm *tm; char str[256]; \
+#define DATEOUT() { time_t _t; struct tm *tm; char str[256]; \
ND_TCHECK2(bp[0], sizeof(int32_t)); \
- t = (time_t) EXTRACT_32BITS(bp); \
+ _t = (time_t) EXTRACT_32BITS(bp); \
bp += sizeof(int32_t); \
- tm = localtime(&t); \
- strftime(str, 256, "%Y/%m/%d %T", tm); \
+ tm = localtime(&_t); \
+ strftime(str, 256, "%Y/%m/%d %H:%M:%S", tm); \
ND_PRINT((ndo, " %s", str)); \
}
-#define STOREATTROUT() { unsigned long mask, i; \
+#define STOREATTROUT() { unsigned long mask, _i; \
ND_TCHECK2(bp[0], (sizeof(int32_t)*6)); \
mask = EXTRACT_32BITS(bp); bp += sizeof(int32_t); \
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) 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)); \
+ _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) ND_PRINT((ndo, " fsync")); \
}
@@ -822,7 +827,7 @@ rx_cache_find(const struct rx_header *rxh, const struct ip *ip, int sport,
ND_PRINT((ndo, " %d.%d", epoch, counter)); \
}
-#define AFSUUIDOUT() {uint32_t temp; int i; \
+#define AFSUUIDOUT() {uint32_t temp; int _i; \
ND_TCHECK2(bp[0], 11*sizeof(uint32_t)); \
temp = EXTRACT_32BITS(bp); \
bp += sizeof(uint32_t); \
@@ -833,7 +838,7 @@ rx_cache_find(const struct rx_header *rxh, const struct ip *ip, int sport,
temp = EXTRACT_32BITS(bp); \
bp += sizeof(uint32_t); \
ND_PRINT((ndo, "%04x", temp)); \
- for (i = 0; i < 8; i++) { \
+ for (_i = 0; _i < 8; _i++) { \
temp = EXTRACT_32BITS(bp); \
bp += sizeof(uint32_t); \
ND_PRINT((ndo, "%02x", (unsigned char) temp)); \
@@ -951,7 +956,7 @@ fs_print(netdissect_options *ndo,
bp += sizeof(int32_t);
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(ndo, (u_char *) a, sizeof(a), (u_char *) a + i);
break;
@@ -1054,12 +1059,12 @@ 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
@@ -1084,7 +1089,7 @@ fs_reply_print(netdissect_options *ndo,
bp += sizeof(int32_t);
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(ndo, (u_char *) a, sizeof(a), (u_char *) a + i);
break;
@@ -1105,8 +1110,6 @@ fs_reply_print(netdissect_options *ndo,
;
}
} else if (rxh->type == RX_PACKET_TYPE_ABORT) {
- int i;
-
/*
* Otherwise, just print out the return code
*/
@@ -1299,12 +1302,12 @@ static void
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
@@ -1493,13 +1496,13 @@ static void
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
@@ -1700,13 +1703,13 @@ static void
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
@@ -1752,7 +1755,7 @@ vldb_reply_print(netdissect_options *ndo,
ND_TCHECK2(bp[0], sizeof(int32_t));
if (i < nservers)
ND_PRINT((ndo, " %s",
- intoa(((struct in_addr *) bp)->s_addr)));
+ intoa(((const struct in_addr *) bp)->s_addr)));
bp += sizeof(int32_t);
}
ND_PRINT((ndo, " partitions"));
@@ -1799,7 +1802,7 @@ vldb_reply_print(netdissect_options *ndo,
ND_TCHECK2(bp[0], sizeof(int32_t));
if (i < nservers)
ND_PRINT((ndo, " %s",
- intoa(((struct in_addr *) bp)->s_addr)));
+ intoa(((const struct in_addr *) bp)->s_addr)));
bp += sizeof(int32_t);
}
ND_PRINT((ndo, " partitions"));
@@ -1921,7 +1924,7 @@ kauth_print(netdissect_options *ndo,
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 */
@@ -1982,12 +1985,12 @@ static void
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
@@ -2236,12 +2239,12 @@ static void
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
@@ -2463,12 +2466,12 @@ static void
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
@@ -2632,12 +2635,12 @@ static void
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
@@ -2696,7 +2699,7 @@ static void
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;
uint32_t firstPacket;
@@ -2715,7 +2718,7 @@ rx_ack_print(netdissect_options *ndo,
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);
/*
diff --git a/contrib/tcpdump/print-sctp.c b/contrib/tcpdump/print-sctp.c
index 4b595f2..f625dce 100644
--- a/contrib/tcpdump/print-sctp.c
+++ b/contrib/tcpdump/print-sctp.c
@@ -33,20 +33,19 @@
* SUCH DAMAGE.
*/
-#define NETDISSECT_REWORKED
+/* \summary: Stream Control Transmission Protocol (SCTP) printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.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"
#include "ip.h"
-#ifdef INET6
#include "ip6.h"
-#endif
/* Definitions from:
*
@@ -496,48 +495,35 @@ void sctp_print(netdissect_options *ndo,
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) ndo->ndo_snapend)
- endPacketPtr = (const void *) ndo->ndo_snapend;
- ip = (struct ip *)bp2;
-#ifdef INET6
- if (IP_V(ip) == 6)
- ip6 = (const struct ip6_hdr *)bp2;
- else
- ip6 = NULL;
-#endif /*INET6*/
- ND_TCHECK(*sctpPktHdr);
-
if (sctpPacketLength < sizeof(struct sctpHeader))
{
ND_PRINT((ndo, "truncated-sctp - %ld bytes missing!",
- (long)sctpPacketLength-sizeof(struct sctpHeader)));
+ (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) {
ND_PRINT((ndo, "%s.%d > %s.%d: sctp",
ip6addr_string(ndo, &ip6->ip6_src),
@@ -545,7 +531,6 @@ void sctp_print(netdissect_options *ndo,
ip6addr_string(ndo, &ip6->ip6_dst),
destPort));
} else
-#endif /*INET6*/
{
ND_PRINT((ndo, "%s.%d > %s.%d: sctp",
ipaddr_string(ndo, &ip->ip_src),
@@ -563,40 +548,48 @@ void sctp_print(netdissect_options *ndo,
isforces = 1;
}
+ 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++)
{
- uint16_t chunkLength;
- const u_char *chunkEnd;
+ uint16_t chunkLength, chunkLengthRemaining;
uint16_t align;
+ 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)) {
- ND_PRINT((ndo, "%s%d) [Bad chunk length %u]", sep, chunkCount+1, chunkLength));
+ ND_PRINT((ndo, "%s%d) [Bad chunk length %u, < size of chunk descriptor]", sep, chunkCount+1, chunkLength));
break;
}
+ chunkLengthRemaining = chunkLength;
- ND_TCHECK2(*((uint8_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);
ND_PRINT((ndo, "%s%d) ", sep, chunkCount+1));
ND_PRINT((ndo, "[%s] ", tok2str(sctp_chunkid_str, "Unknown chunk type: 0x%x",
@@ -607,7 +600,6 @@ void sctp_print(netdissect_options *ndo,
{
const struct sctpDataPart *dataHdrPtr;
uint32_t ppid;
- const u_char *payloadPtr;
u_int payload_size;
if ((chunkDescPtr->chunkFlg & SCTP_DATA_UNORDERED)
@@ -632,7 +624,11 @@ void sctp_print(netdissect_options *ndo,
== SCTP_DATA_LAST_FRAG) )
ND_PRINT((ndo, " "));
- dataHdrPtr=(const struct sctpDataPart*)(chunkDescPtr+1);
+ 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)));
@@ -647,70 +643,92 @@ void sctp_print(netdissect_options *ndo,
(ppid == SCTP_PPID_FORCES_LP);
}
- payloadPtr = (const u_char *) (dataHdrPtr + 1);
- if (EXTRACT_16BITS(&chunkDescPtr->chunkLength) <
- sizeof(struct sctpDataPart) + sizeof(struct sctpChunkDesc) + 1) {
- ND_PRINT((ndo, "bogus chunk length %u]", EXTRACT_16BITS(&chunkDescPtr->chunkLength)));
+ 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;
}
- payload_size = EXTRACT_16BITS(&chunkDescPtr->chunkLength) -
- (sizeof(struct sctpDataPart) + sizeof(struct sctpChunkDesc));
-
if (isforces) {
- forces_print(ndo, payloadPtr, payload_size);
+ forces_print(ndo, bp, payload_size);
} else if (ndo->ndo_vflag >= 2) { /* if verbose output is specified */
/* at the command line */
switch (ppid) {
case SCTP_PPID_M3UA :
- m3ua_print(ndo, payloadPtr, payload_size);
+ m3ua_print(ndo, bp, payload_size);
break;
default:
ND_PRINT((ndo, "[Payload"));
if (!ndo->ndo_suppress_default_print) {
ND_PRINT((ndo, ":"));
- ND_DEFAULTPRINT(payloadPtr, payload_size);
+ ND_DEFAULTPRINT(bp, payload_size);
}
ND_PRINT((ndo, "]"));
break;
}
}
+ bp += payload_size;
+ sctpPacketLengthRemaining -= payload_size;
+ chunkLengthRemaining -= payload_size;
break;
}
case SCTP_INITIATION :
{
const struct sctpInitiation *init;
- init=(const struct sctpInitiation*)(chunkDescPtr+1);
+ 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( (init+1) < chunkEnd )
+#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;
- init=(const struct sctpInitiation*)(chunkDescPtr+1);
+ 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( (init+1) < chunkEnd )
+#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:
@@ -720,38 +738,77 @@ void sctp_print(netdissect_options *ndo,
int fragNo, tsnNo;
const u_char *dupTSN;
- sack=(const struct sctpSelectiveAck*)(chunkDescPtr+1);
+ 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++)
+ 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)));
-
+ }
/* print duplicate TSNs */
- for (dupTSN = (const u_char *)frag, tsnNo=0;
- (const void *) dupTSN < nextChunk && tsnNo<EXTRACT_16BITS(&sack->numDupTsns);
- dupTSN += 4, tsnNo++)
+ 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)));
-
+ EXTRACT_32BITS(dupTSN)));
+ }
+ break;
+ }
+ default :
+ {
+ bp += chunkLengthRemaining;
+ sctpPacketLengthRemaining -= chunkLengthRemaining;
+ chunkLengthRemaining = 0;
break;
}
}
- if (ndo->ndo_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;
diff --git a/contrib/tcpdump/print-sflow.c b/contrib/tcpdump/print-sflow.c
index 24112f4..37a41b5 100644
--- a/contrib/tcpdump/print-sflow.c
+++ b/contrib/tcpdump/print-sflow.c
@@ -12,21 +12,22 @@
* 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>
*/
-#define NETDISSECT_REWORKED
+/* \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 <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
#include "addrtoname.h"
@@ -304,8 +305,8 @@ print_sflow_counter_generic(netdissect_options *ndo,
if (len < sizeof(struct sflow_generic_counter_t))
return 1;
-
sflow_gen_counter = (const struct sflow_generic_counter_t *)pointer;
+ 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),
@@ -339,6 +340,9 @@ print_sflow_counter_generic(netdissect_options *ndo,
EXTRACT_32BITS(sflow_gen_counter->ifpromiscmode)));
return 0;
+
+trunc:
+ return 1;
}
static int
@@ -351,6 +355,7 @@ print_sflow_counter_ethernet(netdissect_options *ndo,
return 1;
sflow_eth_counter = (const struct sflow_ethernet_counter_t *)pointer;
+ 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),
@@ -369,6 +374,9 @@ print_sflow_counter_ethernet(netdissect_options *ndo,
EXTRACT_32BITS(sflow_eth_counter->symbol_errors)));
return 0;
+
+trunc:
+ return 1;
}
static int
@@ -388,6 +396,7 @@ print_sflow_counter_basevg(netdissect_options *ndo,
return 1;
sflow_100basevg_counter = (const struct sflow_100basevg_counter_t *)pointer;
+ 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)));
@@ -412,6 +421,9 @@ print_sflow_counter_basevg(netdissect_options *ndo,
EXTRACT_64BITS(sflow_100basevg_counter->hc_out_highpriority_octets)));
return 0;
+
+trunc:
+ return 1;
}
static int
@@ -424,6 +436,7 @@ print_sflow_counter_vlan(netdissect_options *ndo,
return 1;
sflow_vlan_counter = (const struct sflow_vlan_counter_t *)pointer;
+ 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),
@@ -434,6 +447,9 @@ print_sflow_counter_vlan(netdissect_options *ndo,
EXTRACT_32BITS(sflow_vlan_counter->discards)));
return 0;
+
+trunc:
+ return 1;
}
struct sflow_processor_counter_t {
@@ -454,6 +470,7 @@ print_sflow_counter_processor(netdissect_options *ndo,
return 1;
sflow_processor_counter = (const struct sflow_processor_counter_t *)pointer;
+ 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),
@@ -463,6 +480,9 @@ print_sflow_counter_processor(netdissect_options *ndo,
EXTRACT_64BITS(sflow_processor_counter->free_memory)));
return 0;
+
+trunc:
+ return 1;
}
static int
@@ -486,6 +506,7 @@ sflow_print_counter_records(netdissect_options *ndo,
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;
@@ -541,6 +562,9 @@ sflow_print_counter_records(netdissect_options *ndo,
}
return 0;
+
+trunc:
+ return 1;
}
static int
@@ -553,11 +577,11 @@ sflow_print_counter_sample(netdissect_options *ndo,
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);
@@ -574,6 +598,8 @@ sflow_print_counter_sample(netdissect_options *ndo,
len - sizeof(struct sflow_counter_sample_t),
nrecords);
+trunc:
+ return 1;
}
static int
@@ -588,6 +614,7 @@ sflow_print_expanded_counter_sample(netdissect_options *ndo,
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);
@@ -601,6 +628,8 @@ sflow_print_expanded_counter_sample(netdissect_options *ndo,
len - sizeof(struct sflow_expanded_counter_sample_t),
nrecords);
+trunc:
+ return 1;
}
static int
@@ -613,6 +642,7 @@ print_sflow_raw_packet(netdissect_options *ndo,
return 1;
sflow_flow_raw = (const struct sflow_expanded_flow_raw_t *)pointer;
+ 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),
@@ -624,6 +654,9 @@ print_sflow_raw_packet(netdissect_options *ndo,
assuming of course there is wnough data present to do so... */
return 0;
+
+trunc:
+ return 1;
}
static int
@@ -636,12 +669,16 @@ print_sflow_ethernet_frame(netdissect_options *ndo,
return 1;
sflow_ethernet_frame = (const struct sflow_ethernet_frame_t *)pointer;
+ ND_TCHECK(*sflow_ethernet_frame);
ND_PRINT((ndo, "\n\t frame len %u, type %u",
EXTRACT_32BITS(sflow_ethernet_frame->length),
EXTRACT_32BITS(sflow_ethernet_frame->type)));
return 0;
+
+trunc:
+ return 1;
}
static int
@@ -654,6 +691,7 @@ print_sflow_extended_switch_data(netdissect_options *ndo,
return 1;
sflow_extended_sw_data = (const struct sflow_extended_switch_data_t *)pointer;
+ 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),
@@ -661,6 +699,9 @@ print_sflow_extended_switch_data(netdissect_options *ndo,
EXTRACT_32BITS(sflow_extended_sw_data->dst_pri)));
return 0;
+
+trunc:
+ return 1;
}
static int
@@ -685,6 +726,7 @@ sflow_print_flow_records(netdissect_options *ndo,
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. */
@@ -747,6 +789,9 @@ sflow_print_flow_records(netdissect_options *ndo,
}
return 0;
+
+trunc:
+ return 1;
}
static int
@@ -762,7 +807,8 @@ sflow_print_flow_sample(netdissect_options *ndo,
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);
@@ -784,6 +830,8 @@ sflow_print_flow_sample(netdissect_options *ndo,
len - sizeof(struct sflow_flow_sample_t),
nrecords);
+trunc:
+ return 1;
}
static int
@@ -797,6 +845,7 @@ sflow_print_expanded_flow_sample(netdissect_options *ndo,
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);
@@ -813,6 +862,8 @@ sflow_print_expanded_flow_sample(netdissect_options *ndo,
len - sizeof(struct sflow_expanded_flow_sample_t),
nrecords);
+trunc:
+ return 1;
}
void
@@ -827,7 +878,6 @@ sflow_print(netdissect_options *ndo,
uint32_t sflow_sample_type, sflow_sample_len;
uint32_t nsamples;
-
tptr = pptr;
tlen = len;
sflow_datagram = (const struct sflow_datagram_t *)pptr;
diff --git a/contrib/tcpdump/print-sip.c b/contrib/tcpdump/print-sip.c
index d0fd349..8e308ed 100644
--- a/contrib/tcpdump/print-sip.c
+++ b/contrib/tcpdump/print-sip.c
@@ -15,14 +15,15 @@
* Guy Harris.
*/
-#define NETDISSECT_REWORKED
+/* \summary: Session Initiation Protocol (SIP) printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
static const char *sipcmds[] = {
diff --git a/contrib/tcpdump/print-sl.c b/contrib/tcpdump/print-sl.c
index 8d9eadc..3fd7e89 100644
--- a/contrib/tcpdump/print-sl.c
+++ b/contrib/tcpdump/print-sl.c
@@ -17,19 +17,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.
- *
- * $FreeBSD$
*/
-#define NETDISSECT_REWORKED
+/* \summary: Compressed Serial Line Internet Protocol printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
-#include "extract.h" /* must come after interface.h */
+#include "netdissect.h"
+#include "extract.h"
#include "ip.h"
#include "tcp.h"
@@ -69,19 +68,25 @@ sl_if_print(netdissect_options *ndo,
return (caplen);
}
+ caplen -= SLIP_HDRLEN;
length -= SLIP_HDRLEN;
- ip = (struct ip *)(p + SLIP_HDRLEN);
+ ip = (const struct ip *)(p + SLIP_HDRLEN);
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(ndo, (u_char *)ip, length);
+ ip_print(ndo, (const u_char *)ip, length);
break;
case 6:
- ip6_print(ndo, (u_char *)ip, length);
+ ip6_print(ndo, (const u_char *)ip, length);
break;
default:
ND_PRINT((ndo, "ip v%d", IP_V(ip)));
@@ -105,14 +110,14 @@ sl_bsdos_if_print(netdissect_options *ndo,
length -= SLIP_HDRLEN;
- ip = (struct ip *)(p + SLIP_HDRLEN);
+ ip = (const struct ip *)(p + SLIP_HDRLEN);
#ifdef notdef
if (ndo->ndo_eflag)
sliplink_print(ndo, p, ip, length);
#endif
- ip_print(ndo, (u_char *)ip, length);
+ ip_print(ndo, (const u_char *)ip, length);
return (SLIP_HDRLEN);
}
@@ -149,9 +154,9 @@ sliplink_print(netdissect_options *ndo,
* 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);
ND_PRINT((ndo, "utcp %d: ", lastconn));
break;
@@ -244,7 +249,7 @@ compressed_sl_print(netdissect_options *ndo,
* '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);
ND_PRINT((ndo, " %d (%ld)", lastlen[dir][lastconn], (long)(cp - chdr)));
}
diff --git a/contrib/tcpdump/print-sll.c b/contrib/tcpdump/print-sll.c
index 1f5f600..6148569 100644
--- a/contrib/tcpdump/print-sll.c
+++ b/contrib/tcpdump/print-sll.c
@@ -19,14 +19,15 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#define NETDISSECT_REWORKED
+/* \summary: Linux cooked sockets capture printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "ethertype.h"
#include "extract.h"
@@ -198,7 +199,8 @@ sll_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char
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) {
/*
@@ -221,6 +223,7 @@ sll_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char
length -= SLL_HDR_LEN;
caplen -= SLL_HDR_LEN;
p += SLL_HDR_LEN;
+ hdrlen = SLL_HDR_LEN;
ether_type = EXTRACT_16BITS(&sllp->sll_protocol);
@@ -247,23 +250,17 @@ recurse:
* 802.2.
* Try to print the LLC-layer header & higher layers.
*/
- if (llc_print(ndo, 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 (!ndo->ndo_eflag)
- sll_print(ndo, sllp, length + SLL_HDR_LEN);
- if (extracted_ethertype) {
- ND_PRINT((ndo, "(LLC %s) ",
- etherproto_string(htons(extracted_ethertype))));
- }
+ /* packet type not known, print raw packet */
if (!ndo->ndo_suppress_default_print)
ND_DEFAULTPRINT(p, caplen);
break;
@@ -273,9 +270,13 @@ recurse:
* 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 (SLL_HDR_LEN);
+ return (hdrlen + length);
}
if (ndo->ndo_eflag) {
uint16_t tag = EXTRACT_16BITS(p);
@@ -293,9 +294,10 @@ recurse:
p += 4;
length -= 4;
caplen -= 4;
+ hdrlen += 4;
goto recurse;
} else {
- if (ethertype_print(ndo, 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 (!ndo->ndo_eflag)
sll_print(ndo, sllp, length + SLL_HDR_LEN);
@@ -304,5 +306,5 @@ recurse:
}
}
- return (SLL_HDR_LEN);
+ return (hdrlen);
}
diff --git a/contrib/tcpdump/print-slow.c b/contrib/tcpdump/print-slow.c
index 2db3581..92d4a7b 100644
--- a/contrib/tcpdump/print-slow.c
+++ b/contrib/tcpdump/print-slow.c
@@ -18,24 +18,20 @@
* Original code by Hannes Gredler (hannes@juniper.net)
*/
-#define NETDISSECT_REWORKED
+/* \summary: IEEE "slow protocols" (802.3ad/802.3ah) printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.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 {
- uint8_t proto_subtype;
- uint8_t version;
-};
-
#define SLOW_PROTO_LACP 1
#define SLOW_PROTO_MARKER 2
#define SLOW_PROTO_OAM 3
@@ -185,21 +181,21 @@ struct tlv_header_t {
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}
};
@@ -242,35 +238,42 @@ struct lacp_marker_tlv_terminator_t {
uint8_t pad[50];
};
-static void slow_marker_lacp_print(netdissect_options *, register const u_char *, register u_int);
+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);
-const struct slow_common_header_t *slow_com_header;
-
void
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;
- ND_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) {
- ND_PRINT((ndo, "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) {
- ND_PRINT((ndo, "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;
@@ -286,15 +289,15 @@ slow_print(netdissect_options *ndo,
break;
}
- if (print_version) {
+ if (print_version == 1) {
ND_PRINT((ndo, "%sv%u, length %u",
- tok2str(slow_proto_values, "unknown (%u)",slow_com_header->proto_subtype),
- slow_com_header->version,
+ tok2str(slow_proto_values, "unknown (%u)", subtype),
+ *(pptr+1),
len));
} else {
/* some slow protos don't have a version number in the header */
ND_PRINT((ndo, "%s, length %u",
- tok2str(slow_proto_values, "unknown (%u)",slow_com_header->proto_subtype),
+ tok2str(slow_proto_values, "unknown (%u)", subtype),
len));
}
@@ -307,32 +310,45 @@ slow_print(netdissect_options *ndo,
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(ndo, 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(ndo, 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:
- ND_PRINT((ndo, "\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"));
}
static void
slow_marker_lacp_print(netdissect_options *ndo,
- register const u_char *tptr, register u_int tlen)
+ 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;
@@ -346,6 +362,9 @@ slow_marker_lacp_print(netdissect_options *ndo,
} 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 ? */
ND_TCHECK2(*tptr, sizeof(struct tlv_header_t));
tlv_header = (const struct tlv_header_t *)tptr;
@@ -354,30 +373,46 @@ slow_marker_lacp_print(netdissect_options *ndo,
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) {
- ND_PRINT((ndo, "\n\t-----trailing data-----"));
- print_unknown_data(ndo, tptr+sizeof(struct tlv_header_t), "\n\t ", tlen);
+ 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 ? */
ND_TCHECK2(*tptr, tlv_len);
- switch((slow_com_header->proto_subtype << 8) + tlv_header->type) {
+ tlv_tptr=tptr+sizeof(struct tlv_header_t);
+ tlv_tlen=tlv_len-sizeof(struct tlv_header_t);
+
+ 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;
ND_PRINT((ndo, "\n\t System %s, System Priority %u, Key %u" \
@@ -394,6 +429,13 @@ slow_marker_lacp_print(netdissect_options *ndo,
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;
ND_PRINT((ndo, "\n\t Max Delay %u",
@@ -402,6 +444,13 @@ slow_marker_lacp_print(netdissect_options *ndo,
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;
ND_PRINT((ndo, "\n\t Request System %s, Request Port %u, Request Transaction ID 0x%08x",
@@ -411,29 +460,13 @@ slow_marker_lacp_print(netdissect_options *ndo,
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 (ndo->ndo_vflag>1)
- ND_PRINT((ndo, " (=%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 */
- ND_TCHECK2(tlv_ptr.lacp_marker_tlv_terminator->pad[0],
- sizeof(tlv_ptr.lacp_marker_tlv_terminator->pad));
- }
-
- break;
-
default:
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 (ndo->ndo_vflag > 1) {
print_unknown_data(ndo, tptr+sizeof(struct tlv_header_t), "\n\t ",
@@ -444,6 +477,11 @@ slow_marker_lacp_print(netdissect_options *ndo,
tlen-=tlv_len;
}
return;
+
+tooshort:
+ ND_PRINT((ndo, "\n\t\t packet is too short"));
+ return;
+
trunc:
ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
}
@@ -477,7 +515,10 @@ slow_oam_print(netdissect_options *ndo,
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);
@@ -491,20 +532,36 @@ slow_oam_print(netdissect_options *ndo,
case SLOW_OAM_CODE_INFO:
while (tlen > 0) {
ptr.slow_oam_tlv_header = (const struct slow_oam_tlv_header_t *)tptr;
+ 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));
- 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) {
- ND_PRINT((ndo, "\n\t ERROR: illegal length - should be 0"));
- }
+ 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_LOCAL: /* identical format - fall through */
case SLOW_OAM_INFO_TYPE_REMOTE:
tlv.slow_oam_info = (const struct slow_oam_info_t *)tptr;
@@ -513,7 +570,8 @@ slow_oam_print(netdissect_options *ndo,
sizeof(struct slow_oam_info_t)) {
ND_PRINT((ndo, "\n\t ERROR: illegal length - should be %lu",
(unsigned long) sizeof(struct slow_oam_info_t)));
- return;
+ hexdump = TRUE;
+ goto badlength_code_info;
}
ND_PRINT((ndo, "\n\t OAM-Version %u, Revision %u",
@@ -546,11 +604,7 @@ slow_oam_print(netdissect_options *ndo,
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 (ndo->ndo_vflag > 1 || hexdump==TRUE) {
print_unknown_data(ndo, tptr, "\n\t ",
@@ -563,22 +617,47 @@ slow_oam_print(netdissect_options *ndo,
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;
+ 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));
- 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) {
- ND_PRINT((ndo, "\n\t ERROR: illegal length - should be 0"));
- }
+ 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_ERR_SYM_PER: /* identical format - fall through */
case SLOW_OAM_LINK_EVENT_ERR_FRM:
case SLOW_OAM_LINK_EVENT_ERR_FRM_PER:
@@ -589,7 +668,8 @@ slow_oam_print(netdissect_options *ndo,
sizeof(struct slow_oam_link_event_t)) {
ND_PRINT((ndo, "\n\t ERROR: illegal length - should be %lu",
(unsigned long) sizeof(struct slow_oam_link_event_t)));
- return;
+ hexdump = TRUE;
+ goto badlength_event_notif;
}
ND_PRINT((ndo, "\n\t Timestamp %u ms, Errored Window %" PRIu64
@@ -614,11 +694,7 @@ slow_oam_print(netdissect_options *ndo,
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 (ndo->ndo_vflag > 1 || hexdump==TRUE) {
print_unknown_data(ndo, tptr, "\n\t ",
@@ -632,13 +708,16 @@ slow_oam_print(netdissect_options *ndo,
case SLOW_OAM_CODE_LOOPBACK_CTRL:
tlv.slow_oam_loopbackctrl = (const struct slow_oam_loopbackctrl_t *)tptr;
+ 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 --;
+ tptr ++;
+ tlen --;
break;
/*
@@ -655,4 +734,11 @@ slow_oam_print(netdissect_options *ndo,
break;
}
return;
+
+tooshort:
+ ND_PRINT((ndo, "\n\t\t packet is too short"));
+ return;
+
+trunc:
+ ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
}
diff --git a/contrib/tcpdump/print-smb.c b/contrib/tcpdump/print-smb.c
index f5be9ff..723b9a0 100644
--- a/contrib/tcpdump/print-smb.c
+++ b/contrib/tcpdump/print-smb.c
@@ -6,16 +6,17 @@
* or later
*/
-#define NETDISSECT_REWORKED
+/* \summary: SMB/CIFS printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <string.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
#include "smb.h"
@@ -100,7 +101,7 @@ trans2_findfirst(netdissect_options *ndo,
smb_fdata(ndo, param, fmt, param + pcnt, unicodestr);
if (dcnt) {
ND_PRINT((ndo, "data:\n"));
- print_data(ndo, data, dcnt);
+ smb_print_data(ndo, data, dcnt);
}
}
@@ -135,7 +136,7 @@ trans2_qfsinfo(netdissect_options *ndo,
}
if (dcnt) {
ND_PRINT((ndo, "data:\n"));
- print_data(ndo, data, dcnt);
+ smb_print_data(ndo, data, dcnt);
}
return;
trunc:
@@ -416,7 +417,7 @@ print_negprot(netdissect_options *ndo,
smb_fdata(ndo, words + 1, f1, min(words + 1 + wct * 2, maxbuf),
unicodestr);
else
- print_data(ndo, words + 1, min(wct * 2, PTR_DIFF(maxbuf, words + 1)));
+ smb_print_data(ndo, words + 1, min(wct * 2, PTR_DIFF(maxbuf, words + 1)));
ND_TCHECK2(*data, 2);
bcc = EXTRACT_LE_16BITS(data);
@@ -426,7 +427,7 @@ print_negprot(netdissect_options *ndo,
smb_fdata(ndo, data + 2, f2, min(data + 2 + EXTRACT_LE_16BITS(data),
maxbuf), unicodestr);
else
- print_data(ndo, data + 2, min(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:
@@ -460,7 +461,7 @@ print_sesssetup(netdissect_options *ndo,
smb_fdata(ndo, words + 1, f1, min(words + 1 + wct * 2, maxbuf),
unicodestr);
else
- print_data(ndo, words + 1, min(wct * 2, PTR_DIFF(maxbuf, words + 1)));
+ smb_print_data(ndo, words + 1, min(wct * 2, PTR_DIFF(maxbuf, words + 1)));
ND_TCHECK2(*data, 2);
bcc = EXTRACT_LE_16BITS(data);
@@ -470,7 +471,7 @@ print_sesssetup(netdissect_options *ndo,
smb_fdata(ndo, data + 2, f2, min(data + 2 + EXTRACT_LE_16BITS(data),
maxbuf), unicodestr);
else
- print_data(ndo, data + 2, min(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:
@@ -510,7 +511,7 @@ print_lockingandx(netdissect_options *ndo,
smb_fdata(ndo, data + 2, f2, min(data + 2 + EXTRACT_LE_16BITS(data),
maxbuf), unicodestr);
else
- print_data(ndo, data + 2, min(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:
@@ -805,9 +806,6 @@ print_smb(netdissect_options *ndo,
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];
@@ -822,6 +820,11 @@ print_smb(netdissect_options *ndo,
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(ndo, buf, fmt_smbheader, buf + 33, unicodestr);
@@ -883,7 +886,7 @@ print_smb(netdissect_options *ndo,
} else {
if (bcc > 0) {
ND_PRINT((ndo, "smb_buf[]=\n"));
- print_data(ndo, data + 2, min(bcc, PTR_DIFF(maxbuf, data + 2)));
+ smb_print_data(ndo, data + 2, min(bcc, PTR_DIFF(maxbuf, data + 2)));
}
}
}
@@ -1164,10 +1167,12 @@ nbt_udp137_print(netdissect_options *ndo,
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(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);
ND_PRINT((ndo, "ResourceLength=%d\nResourceData=\n", rdlen));
p += 2;
@@ -1209,7 +1214,7 @@ nbt_udp137_print(netdissect_options *ndo,
p += 2;
}
} else {
- print_data(ndo, p, min(rdlen, length - (p - data)));
+ smb_print_data(ndo, p, min(rdlen, length - (p - data)));
p += rdlen;
}
}
@@ -1309,7 +1314,7 @@ out:
/*
print netbeui frames
*/
-struct nbf_strings {
+static struct nbf_strings {
const char *name;
const char *nonverbose;
const char *verbose;
diff --git a/contrib/tcpdump/print-smtp.c b/contrib/tcpdump/print-smtp.c
index fe0bbc2..0cdcf1d 100644
--- a/contrib/tcpdump/print-smtp.c
+++ b/contrib/tcpdump/print-smtp.c
@@ -11,11 +11,13 @@
* FOR A PARTICULAR PURPOSE.
*/
+/* \summary: Simple Mail Transfer Protocol (SMTP) printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/contrib/tcpdump/print-snmp.c b/contrib/tcpdump/print-snmp.c
index f550158..1b096dc 100644
--- a/contrib/tcpdump/print-snmp.c
+++ b/contrib/tcpdump/print-snmp.c
@@ -56,12 +56,13 @@
# @(#)snmp.awk.x 1.1 (LANL) 1/15/90
*/
-#define NETDISSECT_REWORKED
+/* \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>
@@ -70,7 +71,7 @@
#include <smi.h>
#endif
-#include "interface.h"
+#include "netdissect.h"
#undef OPAQUE /* defined in <wingdi.h> */
@@ -253,7 +254,7 @@ static 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) */
@@ -275,28 +276,46 @@ struct obj {
* Currently, this includes the prefixes for the Internet MIB, the
* private enterprises tree, and the experimental tree.
*/
+#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 }
};
/*
@@ -325,14 +344,11 @@ static const struct obj_abrev {
struct be {
uint32_t asnlen;
union {
- caddr_t raw;
+ const uint8_t *raw;
int32_t integer;
uint32_t uns;
const u_char *str;
- struct {
- uint32_t high;
- uint32_t low;
- } uns64;
+ uint64_t uns64;
} data;
u_short id;
u_char form, class; /* tag info */
@@ -446,13 +462,18 @@ asn1_parse(netdissect_options *ndo,
* 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) {
ND_PRINT((ndo, "[Xtagfield?]"));
return -1;
}
- ND_TCHECK(*p);
id = (id << 7) | (*p & ~ASN_BIT8);
+ len--;
+ hdr++;
+ p++;
+ ND_TCHECK(*p);
}
if (len < 1) {
ND_PRINT((ndo, "[Xtagfield?]"));
@@ -498,6 +519,7 @@ asn1_parse(netdissect_options *ndo,
ND_PRINT((ndo, "[id?%c/%s/%d]", *Form[form], Class[class].name, id));
return -1;
}
+ ND_TCHECK2(*p, elem->asnlen);
switch (form) {
case PRIMITIVE:
@@ -514,7 +536,10 @@ asn1_parse(netdissect_options *ndo,
elem->type = BE_INT;
data = 0;
- ND_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++)
@@ -525,7 +550,7 @@ asn1_parse(netdissect_options *ndo,
case OBJECTID:
elem->type = BE_OID;
- elem->data.raw = (caddr_t)p;
+ elem->data.raw = (const uint8_t *)p;
break;
case ASN_NULL:
@@ -535,7 +560,7 @@ asn1_parse(netdissect_options *ndo,
default:
elem->type = BE_OCTET;
- elem->data.raw = (caddr_t)p;
+ elem->data.raw = (const uint8_t *)p;
ND_PRINT((ndo, "[P/U/%s]", Class[class].Id[id]));
break;
}
@@ -545,14 +570,13 @@ asn1_parse(netdissect_options *ndo,
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 uint32_t data;
- ND_TCHECK2(*p, elem->asnlen);
elem->type = BE_UNS;
data = 0;
for (i = elem->asnlen; i-- > 0; p++)
@@ -562,23 +586,18 @@ asn1_parse(netdissect_options *ndo,
}
case COUNTER64: {
- register uint32_t high, low;
- ND_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;
+ elem->data.raw = (const uint8_t *)p;
ND_PRINT((ndo, "[P/A/%s]",
Class[class].Id[id]));
break;
@@ -606,9 +625,8 @@ asn1_parse(netdissect_options *ndo,
default:
ND_PRINT((ndo, "[P/%s/%s]", Class[class].name, Class[class].Id[id]));
- ND_TCHECK2(*p, elem->asnlen);
elem->type = BE_OCTET;
- elem->data.raw = (caddr_t)p;
+ elem->data.raw = (const uint8_t *)p;
break;
}
break;
@@ -619,12 +637,12 @@ asn1_parse(netdissect_options *ndo,
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;
+ elem->data.raw = (const uint8_t *)p;
ND_PRINT((ndo, "C/U/%s", Class[class].Id[id]));
break;
}
@@ -632,12 +650,12 @@ asn1_parse(netdissect_options *ndo,
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;
+ elem->data.raw = (const uint8_t *)p;
ND_PRINT((ndo, "C/%s/%s", Class[class].name, Class[class].Id[id]));
break;
}
@@ -652,6 +670,56 @@ trunc:
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;
+}
+
/*
* Display the ASN.1 object represented by the BE object.
* This used to be an integral part of asn1_parse() before the intermediate
@@ -661,33 +729,36 @@ static int
asn1_print(netdissect_options *ndo,
struct be *elem)
{
- u_char *p = (u_char *)elem->data.raw;
+ const u_char *p;
uint32_t asnlen = elem->asnlen;
uint32_t i;
switch (elem->type) {
case BE_OCTET:
- ND_TCHECK2(*p, asnlen);
- for (i = asnlen; i-- > 0; p++)
- ND_PRINT((ndo, "_%.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 (!ndo->ndo_sflag && !ndo->ndo_nflag && asnlen > 2) {
+ p = (const u_char *)elem->data.raw;
+ i = asnlen;
+ if (!ndo->ndo_nflag && asnlen > 2) {
const struct obj_abrev *a = &obj_abrev_list[0];
- size_t a_len = strlen(a->oid);
for (; a->node; a++) {
- ND_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);
+ i -= a->oid_len;
+ p += a->oid_len;
ND_PRINT((ndo, "%s", a->prefix));
first = 1;
break;
@@ -695,14 +766,15 @@ asn1_print(netdissect_options *ndo,
}
}
- for (; !ndo->ndo_sflag && i-- > 0; 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) {
@@ -731,69 +803,14 @@ asn1_print(netdissect_options *ndo,
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) {
- ND_PRINT((ndo, "%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?*/
- ND_PRINT((ndo, "%.f", d));
-#else
- ND_PRINT((ndo, "%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';
- }
- ND_PRINT((ndo, "%s", first));
+ 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;
- 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;
- }
+ case BE_STR:
+ if (asn1_print_string(ndo, elem) == -1)
+ return -1;
break;
- }
case BE_SEQ:
ND_PRINT((ndo, "Seq(%u)", elem->asnlen));
@@ -802,6 +819,7 @@ asn1_print(netdissect_options *ndo,
case BE_INETADDR:
if (asnlen != ASNLEN_INETADDR)
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++) {
ND_PRINT((ndo, (i == asnlen-1) ? "%u" : ".%u", *p));
@@ -895,12 +913,12 @@ 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;
+ 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; ndo->ndo_sflag && i-- > 0; p++) {
+ for (*oidlen = 0; i-- > 0; p++) {
ND_TCHECK(*p);
o = (o << ASN_SHIFT7) + (*p & ~ASN_BIT8);
if (*p & ASN_LONGLEN)
@@ -911,7 +929,7 @@ smi_decode_oid(netdissect_options *ndo,
* (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;
@@ -1029,6 +1047,10 @@ smi_print_variable(netdissect_options *ndo,
SmiNode *smiNode = NULL;
unsigned int i;
+ 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)
@@ -1053,7 +1075,7 @@ smi_print_variable(netdissect_options *ndo,
static int
smi_print_value(netdissect_options *ndo,
- SmiNode *smiNode, u_char pduid, struct be *elem)
+ SmiNode *smiNode, u_short pduid, struct be *elem)
{
unsigned int i, oid[128], oidlen;
SmiType *smiType;
@@ -1114,22 +1136,24 @@ smi_print_value(netdissect_options *ndo,
if (smiType->basetype == SMI_BASETYPE_BITS) {
/* print bit labels */
} else {
- smi_decode_oid(ndo, elem, oid,
- sizeof(oid)/sizeof(unsigned int),
- &oidlen);
- 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]));
+ 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;
@@ -1196,7 +1220,7 @@ smi_print_value(netdissect_options *ndo,
*/
static void
varbind_print(netdissect_options *ndo,
- u_char pduid, const u_char *np, u_int length)
+ u_short pduid, const u_char *np, u_int length)
{
struct be elem;
int count = 0, ind;
@@ -1217,7 +1241,7 @@ varbind_print(netdissect_options *ndo,
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;
@@ -1237,7 +1261,7 @@ varbind_print(netdissect_options *ndo,
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(ndo, np, length, &elem)) < 0)
@@ -1296,7 +1320,7 @@ 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(ndo, np, length, &elem)) < 0)
@@ -1319,7 +1343,7 @@ snmppdu_print(netdissect_options *ndo,
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) {
@@ -1331,7 +1355,7 @@ snmppdu_print(netdissect_options *ndo,
} else if (elem.data.integer != 0) {
char errbuf[20];
ND_PRINT((ndo, " %s", DECODE_ErrorStatus(elem.data.integer)));
- error = elem.data.integer;
+ error_status = elem.data.integer;
}
length -= count;
np += count;
@@ -1351,15 +1375,12 @@ snmppdu_print(netdissect_options *ndo,
else if (pduid == GETBULKREQ)
ND_PRINT((ndo, " M=%d", elem.data.integer));
else if (elem.data.integer != 0) {
- if (!error)
+ if (!error_status)
ND_PRINT((ndo, "[errorIndex(%d) w/o errorStatus]", elem.data.integer));
- else {
+ else
ND_PRINT((ndo, "@%d", elem.data.integer));
- error = elem.data.integer;
- }
- } else if (error) {
+ } else if (error_status) {
ND_PRINT((ndo, "[errorIndex==0]"));
- error = 0;
}
length -= count;
np += count;
@@ -1486,7 +1507,7 @@ pdu_print(netdissect_options *ndo,
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 ||
@@ -1529,7 +1550,7 @@ 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(ndo, np, length, &elem)) < 0)
@@ -1540,7 +1561,7 @@ scopedpdu_print(netdissect_options *ndo,
return;
}
length = elem.asnlen;
- np = (u_char *)elem.data.raw;
+ np = (const u_char *)elem.data.raw;
/* contextEngineID (OCTET STRING) */
if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
@@ -1553,10 +1574,9 @@ scopedpdu_print(netdissect_options *ndo,
length -= count;
np += count;
- ND_PRINT((ndo, "E= "));
- for (i = 0; i < (int)elem.asnlen; i++) {
- ND_PRINT((ndo, "0x%02X", elem.data.str[i]));
- }
+ ND_PRINT((ndo, "E="));
+ if (asn1_print_octets(ndo, &elem) == -1)
+ return;
ND_PRINT((ndo, " "));
/* contextName (OCTET STRING) */
@@ -1570,7 +1590,10 @@ scopedpdu_print(netdissect_options *ndo,
length -= count;
np += count;
- ND_PRINT((ndo, "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(ndo, np, length, version);
}
@@ -1595,10 +1618,14 @@ community_print(netdissect_options *ndo,
}
/* 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" */
- ND_PRINT((ndo, "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;
@@ -1624,7 +1651,7 @@ usm_print(netdissect_options *ndo,
return;
}
length = elem.asnlen;
- np = (u_char *)elem.data.raw;
+ np = (const u_char *)elem.data.raw;
/* msgAuthoritativeEngineID (OCTET STRING) */
if ((count = asn1_parse(ndo, np, length, &elem)) < 0)
@@ -1674,7 +1701,10 @@ usm_print(netdissect_options *ndo,
length -= count;
np += count;
- ND_PRINT((ndo, "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(ndo, np, length, &elem)) < 0)
@@ -1725,7 +1755,7 @@ v3msg_print(netdissect_options *ndo,
return;
}
length = elem.asnlen;
- np = (u_char *)elem.data.raw;
+ np = (const u_char *)elem.data.raw;
if (ndo->ndo_vflag) {
ND_PRINT((ndo, "{ "));
@@ -1864,7 +1894,7 @@ snmp_print(netdissect_options *ndo,
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(ndo, np, length, &elem)) < 0)
@@ -1883,7 +1913,7 @@ snmp_print(netdissect_options *ndo,
ND_PRINT((ndo, "{ %s ", SnmpVersion[elem.data.integer]));
break;
default:
- ND_PRINT((ndo, "[version = %d]", elem.data.integer));
+ ND_PRINT((ndo, "SNMP [version = %d]", elem.data.integer));
return;
}
version = elem.data.integer;
diff --git a/contrib/tcpdump/print-stp.c b/contrib/tcpdump/print-stp.c
index 93bb600..2f5c917 100644
--- a/contrib/tcpdump/print-stp.c
+++ b/contrib/tcpdump/print-stp.c
@@ -5,20 +5,20 @@
* 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>
*/
-#define NETDISSECT_REWORKED
+/* \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 <stdio.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
#define RSTP_EXTRACT_PORT_ROLE(x) (((x)&0x0C)>>2)
@@ -84,6 +84,8 @@ static const 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)
{
@@ -96,22 +98,25 @@ stp_print_bridge_id(const u_char *p)
return bridge_id_str;
}
-static void
+static int
stp_print_config_bpdu(netdissect_options *ndo, const struct stp_bpdu_ *stp_bpdu,
u_int length)
{
+ ND_TCHECK(stp_bpdu->flags);
ND_PRINT((ndo, ", Flags [%s]",
bittok2str(stp_bpdu_flag_values, "none", stp_bpdu->flags)));
+ 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));
/* in non-verbose mode just print the bridge-id */
if (!ndo->ndo_vflag) {
- return;
+ return 1;
}
+ 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,
@@ -129,6 +134,10 @@ stp_print_config_bpdu(netdissect_options *ndo, const struct stp_bpdu_ *stp_bpdu,
tok2str(rstp_obj_port_role_values, "Unknown",
RSTP_EXTRACT_PORT_ROLE(stp_bpdu->flags))));
}
+ return 1;
+
+trunc:
+ return 0;
}
/*
@@ -226,8 +235,7 @@ stp_print_config_bpdu(netdissect_options *ndo, const struct stp_bpdu_ *stp_bpdu,
#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
+static int
stp_print_mstp_bpdu(netdissect_options *ndo, const struct stp_bpdu_ *stp_bpdu,
u_int length)
{
@@ -245,22 +253,26 @@ stp_print_mstp_bpdu(netdissect_options *ndo, const struct stp_bpdu_ *stp_bpdu,
* in non-verbose mode just print the flags.
*/
if (!ndo->ndo_vflag) {
- return;
+ return 1;
}
ND_PRINT((ndo, "\n\tport-role %s, ",
tok2str(rstp_obj_port_role_values, "Unknown",
RSTP_EXTRACT_PORT_ROLE(stp_bpdu->flags))));
- ND_PRINT((ndo, "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)));
+ 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)));
- ND_PRINT((ndo, "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)));
+ 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,
@@ -268,30 +280,40 @@ stp_print_mstp_bpdu(netdissect_options *ndo, const struct stp_bpdu_ *stp_bpdu,
(float)EXTRACT_16BITS(&stp_bpdu->hello_time) / STP_TIME_BASE,
(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_PRINT((ndo, "MCID Name %s, rev %u, "
+ 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)));
- ND_PRINT((ndo, "CIST int-root-pathcost %u, ",
+ 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)));
+ 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)));
+ 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;
@@ -314,9 +336,13 @@ stp_print_mstp_bpdu(netdissect_options *ndo, const struct stp_bpdu_ *stp_bpdu,
offset += MST_BPDU_MSTI_LENGTH;
}
}
+ return 1;
+
+trunc:
+ return 0;
}
-static void
+static int
stp_print_spb_bpdu(netdissect_options *ndo, const struct stp_bpdu_ *stp_bpdu,
u_int offset)
{
@@ -326,13 +352,18 @@ stp_print_spb_bpdu(netdissect_options *ndo, const struct stp_bpdu_ *stp_bpdu,
* in non-verbose mode don't print anything.
*/
if (!ndo->ndo_vflag) {
- return;
+ return 1;
}
ptr = (const u_char *)stp_bpdu;
- ND_PRINT((ndo, "\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,
+ 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),
@@ -340,8 +371,8 @@ stp_print_spb_bpdu(netdissect_options *ndo, const struct stp_bpdu_ *stp_bpdu,
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, "
+ "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,
@@ -353,10 +384,14 @@ stp_print_spb_bpdu(netdissect_options *ndo, const struct stp_bpdu_ *stp_bpdu,
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));
+ 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;
}
/*
@@ -369,17 +404,19 @@ stp_print(netdissect_options *ndo, const u_char *p, u_int length)
u_int mstp_len;
u_int spb_len;
- stp_bpdu = (struct stp_bpdu_*)p;
+ 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)) {
ND_PRINT((ndo, "unknown STP version, length %u", length));
return;
}
+ ND_TCHECK(stp_bpdu->protocol_version);
ND_PRINT((ndo, "STP %s", tok2str(stp_proto_values, "Unknown STP protocol (0x%02x)",
stp_bpdu->protocol_version)));
@@ -393,6 +430,7 @@ stp_print(netdissect_options *ndo, const u_char *p, u_int length)
return;
}
+ ND_TCHECK(stp_bpdu->bpdu_type);
ND_PRINT((ndo, ", %s", tok2str(stp_bpdu_type_values, "Unknown BPDU Type (0x%02x)",
stp_bpdu->bpdu_type)));
@@ -401,7 +439,8 @@ stp_print(netdissect_options *ndo, const u_char *p, u_int length)
if (length < sizeof(struct stp_bpdu_) - 1) {
goto trunc;
}
- stp_print_config_bpdu(ndo, stp_bpdu, length);
+ if (!stp_print_config_bpdu(ndo, stp_bpdu, length))
+ goto trunc;
break;
case STP_BPDU_TYPE_RSTP:
@@ -409,25 +448,29 @@ stp_print(netdissect_options *ndo, const u_char *p, u_int length)
if (length < sizeof(struct stp_bpdu_)) {
goto trunc;
}
- stp_print_config_bpdu(ndo, 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;
}
- stp_print_mstp_bpdu(ndo, stp_bpdu, length);
+ if (!stp_print_mstp_bpdu(ndo, stp_bpdu, length))
+ goto trunc;
if (stp_bpdu->protocol_version == STP_PROTO_SPB)
{
@@ -438,7 +481,8 @@ stp_print(netdissect_options *ndo, const u_char *p, u_int length)
spb_len < SPB_BPDU_MIN_LEN) {
goto trunc;
}
- stp_print_spb_bpdu(ndo, stp_bpdu, (sizeof(struct stp_bpdu_) + mstp_len));
+ if (!stp_print_spb_bpdu(ndo, stp_bpdu, (sizeof(struct stp_bpdu_) + mstp_len)))
+ goto trunc;
}
}
break;
@@ -452,7 +496,7 @@ stp_print(netdissect_options *ndo, const u_char *p, u_int length)
}
return;
- trunc:
+trunc:
ND_PRINT((ndo, "[|stp %d]", length));
}
diff --git a/contrib/tcpdump/print-sunatm.c b/contrib/tcpdump/print-sunatm.c
index fc03d42..a587e50 100644
--- a/contrib/tcpdump/print-sunatm.c
+++ b/contrib/tcpdump/print-sunatm.c
@@ -30,17 +30,18 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#define NETDISSECT_REWORKED
+/* \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 "interface.h"
+#include "netdissect.h"
#include "extract.h"
#include "atm.h"
diff --git a/contrib/tcpdump/print-sunrpc.c b/contrib/tcpdump/print-sunrpc.c
index 6d98282..2c7f6c7 100644
--- a/contrib/tcpdump/print-sunrpc.c
+++ b/contrib/tcpdump/print-sunrpc.c
@@ -17,11 +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.
- *
- * $FreeBSD$
*/
-#define NETDISSECT_REWORKED
+/* \summary: Sun Remote Procedure Call printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -41,7 +40,7 @@
*/
#undef _XOPEN_SOURCE_EXTENDED
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#if defined(HAVE_GETRPCBYNUMBER) && defined(HAVE_RPC_RPC_H)
#include <rpc/rpc.h>
@@ -53,14 +52,12 @@
#include <stdio.h>
#include <string.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "extract.h"
#include "ip.h"
-#ifdef INET6
#include "ip6.h"
-#endif
#include "rpc_auth.h"
#include "rpc_msg.h"
@@ -95,7 +92,7 @@
*
* from: @(#)pmap_prot.h 1.14 88/02/08 SMI
* from: @(#)pmap_prot.h 2.1 88/07/29 4.0 RPCSRC
- * $FreeBSD$
+ * $FreeBSD: stable/11/contrib/tcpdump/print-sunrpc.c 276788 2015-01-07 19:55:18Z delphij $
*/
/*
@@ -173,13 +170,11 @@ sunrpcrequest_print(netdissect_options *ndo, register const u_char *bp,
{
register const struct sunrpc_msg *rp;
register const struct ip *ip;
-#ifdef INET6
register const struct ip6_hdr *ip6;
-#endif
uint32_t x;
char srcid[20], dstid[20]; /*fits 32bit*/
- rp = (struct sunrpc_msg *)bp;
+ rp = (const struct sunrpc_msg *)bp;
if (!ndo->ndo_nflag) {
snprintf(srcid, sizeof(srcid), "0x%x",
@@ -191,21 +186,19 @@ sunrpcrequest_print(netdissect_options *ndo, register const u_char *bp,
snprintf(dstid, sizeof(dstid), "0x%x", SUNRPC_PMAPPORT);
}
- switch (IP_V((struct ip *)bp2)) {
+ switch (IP_V((const struct ip *)bp2)) {
case 4:
- ip = (struct ip *)bp2;
+ ip = (const struct ip *)bp2;
ND_PRINT((ndo, "%s.%s > %s.%s: %d",
ipaddr_string(ndo, &ip->ip_src), srcid,
ipaddr_string(ndo, &ip->ip_dst), dstid, length));
break;
-#ifdef INET6
case 6:
- ip6 = (struct ip6_hdr *)bp2;
+ ip6 = (const struct ip6_hdr *)bp2;
ND_PRINT((ndo, "%s.%s > %s.%s: %d",
ip6addr_string(ndo, &ip6->ip6_src), srcid,
ip6addr_string(ndo, &ip6->ip6_dst), dstid, length));
break;
-#endif
default:
ND_PRINT((ndo, "%s.%s > %s.%s: %d", "?", srcid, "?", dstid, length));
break;
diff --git a/contrib/tcpdump/print-symantec.c b/contrib/tcpdump/print-symantec.c
index dcff2a6..9e9f8f3 100644
--- a/contrib/tcpdump/print-symantec.c
+++ b/contrib/tcpdump/print-symantec.c
@@ -19,14 +19,15 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#define NETDISSECT_REWORKED
+/* \summary: Symantec Enterprise Firewall printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
#include "ethertype.h"
@@ -75,7 +76,7 @@ symantec_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_
{
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)) {
@@ -88,7 +89,7 @@ symantec_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_
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);
@@ -96,14 +97,14 @@ symantec_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_
if (ether_type <= ETHERMTU) {
/* ether_type not known, print raw packet */
if (!ndo->ndo_eflag)
- symantec_hdr_print(ndo, (u_char *)sp, length + sizeof (struct symantec_header));
+ symantec_hdr_print(ndo, (const u_char *)sp, length + sizeof (struct symantec_header));
if (!ndo->ndo_suppress_default_print)
ND_DEFAULTPRINT(p, caplen);
- } else if (ethertype_print(ndo, ether_type, p, length, caplen) == 0) {
+ } else if (ethertype_print(ndo, ether_type, p, length, caplen, NULL, NULL) == 0) {
/* ether_type not known, print raw packet */
if (!ndo->ndo_eflag)
- symantec_hdr_print(ndo, (u_char *)sp, length + sizeof (struct symantec_header));
+ symantec_hdr_print(ndo, (const u_char *)sp, length + sizeof (struct symantec_header));
if (!ndo->ndo_suppress_default_print)
ND_DEFAULTPRINT(p, caplen);
diff --git a/contrib/tcpdump/print-syslog.c b/contrib/tcpdump/print-syslog.c
index 5e3cd4f..ff86676 100644
--- a/contrib/tcpdump/print-syslog.c
+++ b/contrib/tcpdump/print-syslog.c
@@ -14,14 +14,15 @@
* FOR A PARTICULAR PURPOSE.
*/
-#define NETDISSECT_REWORKED
+/* \summary: Syslog protocol printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
static const char tstr[] = "[|syslog]";
diff --git a/contrib/tcpdump/print-tcp.c b/contrib/tcpdump/print-tcp.c
index a5c7047..e0d0531 100644
--- a/contrib/tcpdump/print-tcp.c
+++ b/contrib/tcpdump/print-tcp.c
@@ -23,40 +23,37 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
+/* \summary: TCP printer */
+
#ifndef lint
#else
__RCSID("$NetBSD: print-tcp.c,v 1.8 2007/07/24 11:53:48 drochner Exp $");
#endif
-#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.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(netdissect_options *ndo,
const struct ip *ip, const struct tcphdr *tp,
@@ -64,6 +61,8 @@ static int tcp_verify_signature(netdissect_options *ndo,
#endif
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
@@ -81,7 +80,6 @@ struct tcp_seq_hash {
tcp_seq ack;
};
-#ifdef INET6
struct tha6 {
struct in6_addr src;
struct in6_addr dst;
@@ -94,7 +92,6 @@ struct tcp_seq_hash6 {
tcp_seq seq;
tcp_seq ack;
};
-#endif
#define TSEQ_HASHSIZE 919
@@ -102,9 +99,7 @@ struct tcp_seq_hash6 {
#define ZEROLENOPT(o) ((o) == TCPOPT_EOL || (o) == TCPOPT_NOP)
static struct tcp_seq_hash tcp_seq_hash4[TSEQ_HASHSIZE];
-#ifdef INET6
static struct tcp_seq_hash6 tcp_seq_hash6[TSEQ_HASHSIZE];
-#endif
static const struct tok tcp_flag_values[] = {
{ TH_FIN, "F" },
@@ -132,9 +127,11 @@ static const 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 }
};
@@ -149,6 +146,16 @@ tcp_cksum(netdissect_options *ndo,
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(netdissect_options *ndo,
register const u_char *bp, register u_int length,
@@ -164,18 +171,14 @@ tcp_print(netdissect_options *ndo,
u_int utoval;
uint16_t magic;
register int rev;
-#ifdef INET6
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 (!ND_TTEST(tp->th_dport)) {
ND_PRINT((ndo, "%s > %s: [|tcp]",
@@ -187,43 +190,40 @@ tcp_print(netdissect_options *ndo,
sport = EXTRACT_16BITS(&tp->th_sport);
dport = EXTRACT_16BITS(&tp->th_dport);
- hlen = TH_OFF(tp) * 4;
-
-#ifdef INET6
if (ip6) {
if (ip6->ip6_nxt == IPPROTO_TCP) {
ND_PRINT((ndo, "%s.%s > %s.%s: ",
ip6addr_string(ndo, &ip6->ip6_src),
- tcpport_string(sport),
+ tcpport_string(ndo, sport),
ip6addr_string(ndo, &ip6->ip6_dst),
- tcpport_string(dport)));
+ tcpport_string(ndo, dport)));
} else {
ND_PRINT((ndo, "%s > %s: ",
- tcpport_string(sport), tcpport_string(dport)));
+ tcpport_string(ndo, sport), tcpport_string(ndo, dport)));
}
- } else
-#endif /*INET6*/
- {
+ } else {
if (ip->ip_p == IPPROTO_TCP) {
ND_PRINT((ndo, "%s.%s > %s.%s: ",
ipaddr_string(ndo, &ip->ip_src),
- tcpport_string(sport),
+ tcpport_string(ndo, sport),
ipaddr_string(ndo, &ip->ip_dst),
- tcpport_string(dport)));
+ tcpport_string(ndo, dport)));
} else {
ND_PRINT((ndo, "%s > %s: ",
- tcpport_string(sport), tcpport_string(dport)));
+ tcpport_string(ndo, sport), tcpport_string(ndo, dport)));
}
}
+ ND_TCHECK(*tp);
+
+ hlen = TH_OFF(tp) * 4;
+
if (hlen < sizeof(*tp)) {
ND_PRINT((ndo, " tcp %d [bad hdr length %u - too short, < %lu]",
length - hlen, hlen, (unsigned long)sizeof(*tp)));
return;
}
- ND_TCHECK(*tp);
-
seq = EXTRACT_32BITS(&tp->th_seq);
ack = EXTRACT_32BITS(&tp->th_ack);
win = EXTRACT_16BITS(&tp->th_win);
@@ -249,11 +249,10 @@ tcp_print(netdissect_options *ndo,
* both directions).
*/
rev = 0;
-#ifdef INET6
if (ip6) {
register struct tcp_seq_hash6 *th;
struct tcp_seq_hash6 *tcp_seq_hash;
- const void *src, *dst;
+ const struct in6_addr *src, *dst;
struct tha6 tha;
tcp_seq_hash = tcp_seq_hash6;
@@ -287,7 +286,8 @@ tcp_print(netdissect_options *ndo,
th->nxt = (struct tcp_seq_hash6 *)
calloc(1, sizeof(*th));
if (th->nxt == NULL)
- error("tcp_print: calloc");
+ (*ndo->ndo_error)(ndo,
+ "tcp_print: calloc");
}
th->addr = tha;
if (rev)
@@ -304,30 +304,24 @@ tcp_print(netdissect_options *ndo,
thseq = th->seq;
thack = th->ack;
} else {
-#else /*INET6*/
- {
-#endif /*INET6*/
register struct tcp_seq_hash *th;
struct tcp_seq_hash *tcp_seq_hash;
- const void *src, *dst;
struct tha tha;
tcp_seq_hash = tcp_seq_hash4;
- src = &ip->ip_src;
- dst = &ip->ip_dst;
if (sport > dport)
rev = 1;
else if (sport == dport) {
- if (UNALIGNED_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) {
- UNALIGNED_MEMCPY(&tha.src, dst, sizeof ip->ip_dst);
- UNALIGNED_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 {
- UNALIGNED_MEMCPY(&tha.dst, dst, sizeof ip->ip_dst);
- UNALIGNED_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;
}
@@ -343,7 +337,8 @@ tcp_print(netdissect_options *ndo,
th->nxt = (struct tcp_seq_hash *)
calloc(1, sizeof(*th));
if (th->nxt == NULL)
- error("tcp_print: calloc");
+ (*ndo->ndo_error)(ndo,
+ "tcp_print: calloc");
}
th->addr = tha;
if (rev)
@@ -386,12 +381,9 @@ tcp_print(netdissect_options *ndo,
else
ND_PRINT((ndo, " (correct)"));
}
- }
-#ifdef INET6
- else if (IP_V(ip) == 6 && ip6->ip6_plen) {
+ } else if (IP_V(ip) == 6 && ip6->ip6_plen) {
if (ND_TTEST2(tp->th_sport, length)) {
- sum = nextproto6_cksum(ip6, (const uint8_t *)tp,
- length, length, IPPROTO_TCP);
+ sum = tcp6_cksum(ndo, ip6, tp, length);
tcp_sum = EXTRACT_16BITS(&tp->th_sum);
ND_PRINT((ndo, ", cksum 0x%04x", tcp_sum));
@@ -403,7 +395,6 @@ tcp_print(netdissect_options *ndo,
}
}
-#endif
}
length -= hlen;
@@ -474,7 +465,7 @@ tcp_print(netdissect_options *ndo,
case TCPOPT_SACK:
datalen = len - 2;
if (datalen % 8 != 0) {
- ND_PRINT((ndo, "malformed sack"));
+ ND_PRINT((ndo, " invalid sack"));
} else {
uint32_t s, e;
@@ -522,6 +513,7 @@ tcp_print(netdissect_options *ndo,
case TCPOPT_SIGNATURE:
datalen = TCP_SIGLEN;
LENCHECK(datalen);
+ ND_PRINT((ndo, " "));
#ifdef HAVE_LIBCRYPTO
switch (tcp_verify_signature(ndo, ip, tp,
bp + TH_OFF(tp) * 4, length, cp)) {
@@ -546,15 +538,35 @@ tcp_print(netdissect_options *ndo,
#endif
break;
- case TCPOPT_AUTH:
- ND_PRINT((ndo, "keyid %d", *cp++));
- datalen = len - 3;
- for (i = 0; i < datalen; ++i) {
- LENCHECK(i);
- ND_PRINT((ndo, "%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:
@@ -569,7 +581,7 @@ tcp_print(netdissect_options *ndo,
datalen = 2;
LENCHECK(datalen);
utoval = EXTRACT_16BITS(cp);
- ND_PRINT((ndo, "0x%x", utoval));
+ ND_PRINT((ndo, " 0x%x", utoval));
if (utoval & 0x0001)
utoval = (utoval >> 1) * 60;
else
@@ -584,6 +596,13 @@ tcp_print(netdissect_options *ndo,
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);
@@ -595,21 +614,8 @@ tcp_print(netdissect_options *ndo,
switch(magic) {
- case 0xf989:
- /* TCP Fast Open: RFC 7413 */
- if (datalen == 2) {
- /* Fast Open Cookie Request */
- ND_PRINT((ndo, "tfo cookiereq"));
- } else {
- /* Fast Open Cookie */
- if (datalen % 2 != 0 || datalen < 6 || datalen > 18) {
- ND_PRINT((ndo, "tfo malformed"));
- } else {
- ND_PRINT((ndo, "tfo cookie "));
- for (i = 2; i < datalen; ++i)
- ND_PRINT((ndo, "%02x", cp[i]));
- }
- }
+ case 0xf989: /* TCP Fast Open RFC 7413 */
+ print_tcp_fastopen_option(ndo, cp + 2, datalen - 2, TRUE);
break;
default:
@@ -624,7 +630,7 @@ tcp_print(netdissect_options *ndo,
if (datalen)
ND_PRINT((ndo, " 0x"));
for (i = 0; i < datalen; ++i) {
- LENCHECK(i);
+ LENCHECK(i + 1);
ND_PRINT((ndo, "%02x", cp[i]));
}
break;
@@ -669,58 +675,59 @@ tcp_print(netdissect_options *ndo,
case PT_ZMTP1:
zmtp1_print(ndo, bp, length);
break;
+ case PT_RESP:
+ resp_print(ndo, bp, length);
+ break;
}
return;
}
- if (sport == TELNET_PORT || dport == TELNET_PORT) {
+ if (IS_SRC_OR_DST_PORT(TELNET_PORT)) {
telnet_print(ndo, bp, length);
- } else if (sport == SMTP_PORT || dport == SMTP_PORT) {
+ } else if (IS_SRC_OR_DST_PORT(SMTP_PORT)) {
ND_PRINT((ndo, ": "));
smtp_print(ndo, bp, length);
- } else if (sport == BGP_PORT || dport == BGP_PORT)
+ } else if (IS_SRC_OR_DST_PORT(BGP_PORT))
bgp_print(ndo, bp, length);
- else if (sport == PPTP_PORT || dport == PPTP_PORT)
+ else if (IS_SRC_OR_DST_PORT(PPTP_PORT))
pptp_print(ndo, bp);
-#ifdef TCPDUMP_DO_SMB
- else if (sport == NETBIOS_SSN_PORT || dport == NETBIOS_SSN_PORT)
+ 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 (sport == SMB_PORT || dport == SMB_PORT)
+ else if (IS_SRC_OR_DST_PORT(SMB_PORT))
smb_tcp_print(ndo, bp, length);
#endif
- else if (sport == BEEP_PORT || dport == BEEP_PORT)
+ else if (IS_SRC_OR_DST_PORT(BEEP_PORT))
beep_print(ndo, bp, length);
- else if (sport == OPENFLOW_PORT_OLD || dport == OPENFLOW_PORT_OLD ||
- sport == OPENFLOW_PORT_IANA || dport == OPENFLOW_PORT_IANA)
+ 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 (sport == FTP_PORT || dport == FTP_PORT) {
+ else if (IS_SRC_OR_DST_PORT(FTP_PORT)) {
ND_PRINT((ndo, ": "));
ftp_print(ndo, bp, length);
- } else if (sport == HTTP_PORT || dport == HTTP_PORT ||
- sport == HTTP_PORT_ALT || dport == HTTP_PORT_ALT) {
+ } 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 (sport == RTSP_PORT || dport == RTSP_PORT ||
- sport == RTSP_PORT_ALT || dport == RTSP_PORT_ALT) {
+ } 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 &&
- (sport == NAMESERVER_PORT || dport == NAMESERVER_PORT ||
- sport == MULTICASTDNS_PORT || dport == MULTICASTDNS_PORT)) {
+ (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(ndo, bp + 2, length - 2, 0);
- } else if (sport == MSDP_PORT || dport == MSDP_PORT) {
+ } else if (IS_SRC_OR_DST_PORT(MSDP_PORT)) {
msdp_print(ndo, bp, length);
- } else if (sport == RPKI_RTR_PORT || dport == RPKI_RTR_PORT) {
+ } 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)) {
+ else if (length > 0 && (IS_SRC_OR_DST_PORT(LDP_PORT))) {
ldp_print(ndo, bp, length);
}
- else if ((sport == NFS_PORT || dport == NFS_PORT) &&
+ 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,
@@ -729,23 +736,23 @@ tcp_print(netdissect_options *ndo,
* to NFS print routines.
*/
uint32_t fraglen;
- register struct sunrpc_msg *rp;
+ register const struct sunrpc_msg *rp;
enum sunrpc_msg_type direction;
fraglen = EXTRACT_32BITS(bp) & 0x7FFFFFFF;
if (fraglen > (length) - 4)
fraglen = (length) - 4;
- rp = (struct sunrpc_msg *)(bp + 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, (u_char *)rp, fraglen, (u_char *)ip);
+ 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, (u_char *)rp, fraglen, (u_char *)ip);
+ nfsreply_print_noaddr(ndo, (const u_char *)rp, fraglen, (const u_char *)ip);
return;
}
}
@@ -790,13 +797,37 @@ print_tcp_rst_data(netdissect_options *ndo,
ND_PRINT((ndo, "+")); /* indicate we truncate */
}
ND_PRINT((ndo, " "));
- while (length-- && sp <= ndo->ndo_snapend) {
+ while (length-- && sp < ndo->ndo_snapend) {
c = *sp++;
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]));
+ }
+ }
+}
+
#ifdef HAVE_LIBCRYPTO
USES_APPLE_DEPRECATED_API
static int
@@ -809,11 +840,9 @@ tcp_verify_signature(netdissect_options *ndo,
char zero_proto = 0;
MD5_CTX ctx;
uint16_t savecsum, tlen;
-#ifdef INET6
- struct ip6_hdr *ip6;
+ const struct ip6_hdr *ip6;
uint32_t len32;
uint8_t nxt;
-#endif
if (data + length > ndo->ndo_snapend) {
ND_PRINT((ndo, "snaplen too short, "));
@@ -832,33 +861,27 @@ tcp_verify_signature(netdissect_options *ndo,
* 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
ND_PRINT((ndo, "IP version not 4 or 6, "));
-#else
- ND_PRINT((ndo, "IP version not 4, "));
-#endif
return (CANT_CHECK_SIGNATURE);
}
@@ -868,7 +891,7 @@ tcp_verify_signature(netdissect_options *ndo,
*/
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.
diff --git a/contrib/tcpdump/print-telnet.c b/contrib/tcpdump/print-telnet.c
index fa59b1f..a664034 100644
--- a/contrib/tcpdump/print-telnet.c
+++ b/contrib/tcpdump/print-telnet.c
@@ -45,16 +45,19 @@
* are preserved in all copies.
*/
-#define NETDISSECT_REWORKED
+/* \summary: Telnet option 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"
+
+static const char tstr[] = " [|telnet]";
#define TELCMDS
#define TELOPTS
@@ -88,7 +91,7 @@
#define SYNCH 242 /* for telfunc calls */
#ifdef TELCMDS
-const char *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,
@@ -149,7 +152,7 @@ extern char *telcmds[];
#define NTELOPTS (1+TELOPT_NEW_ENVIRON)
#ifdef TELOPTS
-const char *telopts[NTELOPTS+1] = {
+static const char *telopts[NTELOPTS+1] = {
"BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD", "NAME",
"STATUS", "TIMING MARK", "RCTE", "NAOL", "NAOP",
"NAOCRD", "NAOHTS", "NAOHTD", "NAOFFD", "NAOVTS",
@@ -434,6 +437,7 @@ telnet_parse(netdissect_options *ndo, const u_char *sp, u_int length, int print)
/* 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++;
@@ -494,7 +498,7 @@ done:
return sp - osp;
trunc:
- ND_PRINT((ndo, "[|telnet]"));
+ ND_PRINT((ndo, "%s", tstr));
pktend:
return -1;
#undef FETCH
@@ -509,6 +513,7 @@ telnet_print(netdissect_options *ndo, const u_char *sp, u_int length)
osp = sp;
+ ND_TCHECK(*sp);
while (length > 0 && *sp == IAC) {
/*
* Parse the Telnet command without printing it,
@@ -537,6 +542,7 @@ telnet_print(netdissect_options *ndo, const u_char *sp, u_int length)
sp += l;
length -= l;
+ ND_TCHECK(*sp);
}
if (!first) {
if (ndo->ndo_Xflag && 2 < ndo->ndo_vflag)
@@ -544,4 +550,7 @@ telnet_print(netdissect_options *ndo, const u_char *sp, u_int length)
else
ND_PRINT((ndo, "]"));
}
+ return;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
}
diff --git a/contrib/tcpdump/print-tftp.c b/contrib/tcpdump/print-tftp.c
index 9b88e74..69bc601 100644
--- a/contrib/tcpdump/print-tftp.c
+++ b/contrib/tcpdump/print-tftp.c
@@ -17,20 +17,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.
- *
- * Format and print trivial file transfer protocol packets.
*/
-#define NETDISSECT_REWORKED
+/* \summary: Trivial File Transfer Protocol (TFTP) printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <string.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
/*
@@ -110,7 +109,8 @@ tftp_print(netdissect_options *ndo,
register const struct tftphdr *tp;
register const char *cp;
register const u_char *p;
- register int opcode, i;
+ register int opcode;
+ u_int ui;
tp = (const struct tftphdr *)bp;
@@ -118,9 +118,12 @@ tftp_print(netdissect_options *ndo,
ND_PRINT((ndo, " %d", length));
/* Print tftp request type */
+ if (length < 2)
+ goto trunc;
ND_TCHECK(tp->th_opcode);
opcode = EXTRACT_16BITS(&tp->th_opcode);
cp = tok2str(op2str, "tftp-#%d", opcode);
+ length -= 2;
ND_PRINT((ndo, " %s", cp));
/* Bail if bogus opcode */
if (*cp == 't')
@@ -130,46 +133,80 @@ tftp_print(netdissect_options *ndo,
case RRQ:
case WRQ:
- case OACK:
- p = (u_char *)tp->th_stuff;
+ 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, " "));
- /* Print filename or first option */
- if (opcode != OACK)
- ND_PRINT((ndo, "\""));
- i = fn_print(ndo, p, ndo->ndo_snapend);
- if (opcode != OACK)
- ND_PRINT((ndo, "\""));
-
- /* 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') {
+ 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, " "));
- fn_print(ndo, p, ndo->ndo_snapend);
- }
+ ui = fn_printztn(ndo, p, length, ndo->ndo_snapend);
+ if (ui == 0)
+ goto trunc;
+ p += ui;
+ length -= ui;
}
+ break;
- if (i)
- goto trunc;
+ case OACK:
+ 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;
+ }
break;
case ACK:
case DATA:
+ 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 */
+ if (length < 2)
+ goto trunc; /* no error code */
ND_TCHECK(tp->th_code);
- ND_PRINT((ndo, " %s \"", tok2str(err2str, "tftp-err-#%d \"",
+ ND_PRINT((ndo, " %s", tok2str(err2str, "tftp-err-#%d \"",
EXTRACT_16BITS(&tp->th_code))));
+ length -= 2;
/* Print error message string */
- i = fn_print(ndo, (const u_char *)tp->th_data, ndo->ndo_snapend);
+ 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 (i)
+ if (ui == 0)
goto trunc;
break;
diff --git a/contrib/tcpdump/print-timed.c b/contrib/tcpdump/print-timed.c
index 5830bc7..6aa7a82 100644
--- a/contrib/tcpdump/print-timed.c
+++ b/contrib/tcpdump/print-timed.c
@@ -19,18 +19,21 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#define NETDISSECT_REWORKED
+/* \summary: BSD time daemon protocol printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.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 {
@@ -95,7 +98,7 @@ void
timed_print(netdissect_options *ndo,
register const u_char *bp)
{
- struct tsp *tsp = (struct tsp *)bp;
+ const struct tsp *tsp = (const struct tsp *)bp;
long sec, usec;
ND_TCHECK(tsp->tsp_type);
@@ -124,7 +127,7 @@ timed_print(netdissect_options *ndo,
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;
ND_PRINT((ndo, " time "));
if (sec < 0 && usec != 0) {
@@ -138,7 +141,7 @@ timed_print(netdissect_options *ndo,
}
ND_TCHECK(tsp->tsp_name);
ND_PRINT((ndo, " name "));
- if (fn_print(ndo, (u_char *)tsp->tsp_name, (u_char *)tsp->tsp_name + sizeof(tsp->tsp_name)))
+ if (fn_print(ndo, (const u_char *)tsp->tsp_name, (const u_char *)tsp->tsp_name + sizeof(tsp->tsp_name)))
goto trunc;
return;
diff --git a/contrib/tcpdump/print-tipc.c b/contrib/tcpdump/print-tipc.c
index b883fba..4d8848f 100644
--- a/contrib/tcpdump/print-tipc.c
+++ b/contrib/tcpdump/print-tipc.c
@@ -19,27 +19,27 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#define NETDISSECT_REWORKED
+/* \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 <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "ether.h"
#include "ethertype.h"
-#include "extract.h" /* must come after interface.h */
+#include "extract.h"
static const char tstr[] = "[|TIPC]";
-/*
- * 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
- */
-
#define TIPC_USER_LOW_IMPORTANCE 0
#define TIPC_USER_MEDIUM_IMPORTANCE 1
#define TIPC_USER_HIGH_IMPORTANCE 2
@@ -342,7 +342,7 @@ tipc_print(netdissect_options *ndo, const u_char *bp, u_int length _U_,
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);
@@ -355,11 +355,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);
+ 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:
@@ -367,7 +367,7 @@ 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;
}
diff --git a/contrib/tcpdump/print-token.c b/contrib/tcpdump/print-token.c
index af4780c..faffd4b 100644
--- a/contrib/tcpdump/print-token.c
+++ b/contrib/tcpdump/print-token.c
@@ -22,20 +22,19 @@
*
* Further tweaked to more closely resemble print-fddi.c
* Guy Harris <guy@alum.mit.edu>
- *
- * $FreeBSD$
*/
-#define NETDISSECT_REWORKED
+/* \summary: Token Ring printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <string.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
#include "addrtoname.h"
#include "ether.h"
@@ -115,14 +114,13 @@ token_hdr_print(netdissect_options *ndo,
srcname = etheraddr_string(ndo, fsrc);
dstname = etheraddr_string(ndo, fdst);
- if (ndo->ndo_vflag)
- ND_PRINT((ndo, "%02x %02x %s %s %d: ",
+ if (!ndo->ndo_qflag)
+ ND_PRINT((ndo, "%02x %02x ",
trp->token_ac,
- trp->token_fc,
- srcname, dstname,
- length));
- else
- ND_PRINT((ndo, "%s %s %d: ", srcname, dstname, length));
+ trp->token_fc));
+ ND_PRINT((ndo, "%s > %s, length %u: ",
+ srcname, dstname,
+ length));
}
static const char *broadcast_indicator[] = {
@@ -151,8 +149,9 @@ u_int
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;
@@ -205,6 +204,11 @@ token_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen
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;
@@ -213,20 +217,14 @@ token_print(netdissect_options *ndo, 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(ndo, p, length, caplen, ESRC(&ehdr), EDST(&ehdr),
- &extracted_ethertype) == 0) {
- /* ether_type not known, print raw packet */
- if (!ndo->ndo_eflag)
- token_hdr_print(ndo, trp,
- length + TOKEN_HDRLEN + route_len,
- ESRC(&ehdr), EDST(&ehdr));
- if (extracted_ethertype) {
- ND_PRINT((ndo, "(LLC %s) ",
- etherproto_string(htons(extracted_ethertype))));
- }
+ 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 */
diff --git a/contrib/tcpdump/print-udld.c b/contrib/tcpdump/print-udld.c
index 15e2bf6..02921d0 100644
--- a/contrib/tcpdump/print-udld.c
+++ b/contrib/tcpdump/print-udld.c
@@ -12,22 +12,24 @@
* 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>
*/
-#define NETDISSECT_REWORKED
+/* \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 "interface.h"
+#include "netdissect.h"
#include "extract.h"
+static const char tstr[] = " [|udld]";
+
#define UDLD_HEADER_LEN 4
#define UDLD_DEVICE_ID_TLV 0x0001
#define UDLD_PORT_ID_TLV 0x0002
@@ -63,9 +65,10 @@ static const struct tok udld_flags_values[] = {
};
/*
+ * 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
+ * 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 |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
@@ -73,6 +76,18 @@ static const struct tok udld_flags_values[] = {
* | ... |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*
+ * 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
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | TYPE | LENGTH |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | VALUE |
+ * | ... |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *
+ * LENGTH: Length in bytes of the Type, Length, and Value fields.
*/
#define UDLD_EXTRACT_VERSION(x) (((x)&0xe0)>>5)
@@ -115,35 +130,48 @@ udld_print (netdissect_options *ndo, const u_char *pptr, u_int length)
while (tptr < (pptr+length)) {
ND_TCHECK2(*tptr, 4);
-
type = EXTRACT_16BITS(tptr);
len = EXTRACT_16BITS(tptr+2);
- len -= 4;
- tptr += 4;
-
- /* infinite loop check */
- if (type == 0 || len == 0) {
- return;
- }
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 (len <= 4)
+ goto invalid;
+
+ len -= 4;
+ tptr += 4;
+
+ ND_TCHECK2(*tptr, len);
+
switch (type) {
case UDLD_DEVICE_ID_TLV:
case UDLD_PORT_ID_TLV:
- case UDLD_ECHO_TLV:
case UDLD_DEVICE_NAME_TLV:
- ND_PRINT((ndo, ", %s", tptr));
+ ND_PRINT((ndo, ", "));
+ fn_printzp(ndo, tptr, len, NULL);
+ break;
+
+ case UDLD_ECHO_TLV:
+ ND_PRINT((ndo, ", "));
+ (void)fn_printn(ndo, tptr, len, NULL);
break;
case UDLD_MESSAGE_INTERVAL_TLV:
case UDLD_TIMEOUT_INTERVAL_TLV:
+ if (len != 1)
+ goto invalid;
ND_PRINT((ndo, ", %us", (*tptr)));
break;
case UDLD_SEQ_NUMBER_TLV:
+ if (len != 4)
+ goto invalid;
ND_PRINT((ndo, ", %u", EXTRACT_32BITS(tptr)));
break;
@@ -155,8 +183,11 @@ udld_print (netdissect_options *ndo, const u_char *pptr, u_int length)
return;
- trunc:
- ND_PRINT((ndo, "[|udld]"));
+invalid:
+ ND_PRINT((ndo, "%s", istr));
+ return;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
}
/*
diff --git a/contrib/tcpdump/print-udp.c b/contrib/tcpdump/print-udp.c
index c9e6058..5a74ff2 100644
--- a/contrib/tcpdump/print-udp.c
+++ b/contrib/tcpdump/print-udp.c
@@ -17,18 +17,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$
*/
-#define NETDISSECT_REWORKED
+/* \summary: UDP printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "extract.h"
#include "appletalk.h"
@@ -36,16 +35,18 @@
#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"
+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 {
uint16_t rh_flags; /* T:2 P:1 CNT:5 PT:8 */
uint16_t rh_len; /* length of message (in words) */
@@ -99,16 +100,25 @@ static void
vat_print(netdissect_options *ndo, const void *hdr, register const struct udphdr *up)
{
/* vat/vt audio */
- u_int ts = *(uint16_t *)hdr;
+ u_int ts;
+
+ ND_TCHECK_16BITS((const u_int *)hdr);
+ ts = EXTRACT_16BITS(hdr);
if ((ts & 0xf060) != 0) {
/* probably vt */
+ 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 */
- uint32_t i0 = EXTRACT_32BITS(&((u_int *)hdr)[0]);
- uint32_t i1 = EXTRACT_32BITS(&((u_int *)hdr)[1]);
+ 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,
@@ -119,6 +129,9 @@ vat_print(netdissect_options *ndo, const void *hdr, register const struct udphdr
if (i0 & 0x3f000000)
ND_PRINT((ndo, " s%d", (i0 >> 24) & 0x3f));
}
+
+trunc:
+ ND_PRINT((ndo, "%s", vat_tstr));
}
static void
@@ -126,26 +139,30 @@ 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;
- uint32_t i0 = EXTRACT_32BITS(&((u_int *)hdr)[0]);
- uint32_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;
@@ -163,11 +180,13 @@ rtp_print(netdissect_options *ndo, const void *hdr, u_int len,
i0 & 0xffff,
i1));
if (ndo->ndo_vflag) {
- ND_PRINT((ndo, " %u", EXTRACT_32BITS(&((u_int *)hdr)[2])));
+ 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) {
ND_PRINT((ndo, " !opt"));
@@ -179,7 +198,8 @@ rtp_print(netdissect_options *ndo, const void *hdr, u_int len,
}
if (hasext) {
u_int i2, extlen;
- i2 = ip[0];
+ ND_TCHECK_32BITS(ip);
+ i2 = EXTRACT_32BITS(ip);
extlen = (i2 & 0xffff) + 1;
if (extlen > len) {
ND_PRINT((ndo, " !ext"));
@@ -187,53 +207,55 @@ rtp_print(netdissect_options *ndo, const void *hdr, u_int len,
}
ip += extlen;
}
+ ND_TCHECK_32BITS(ip);
if (contype == 0x1f) /*XXX H.261 */
- ND_PRINT((ndo, " 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(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;
uint16_t flags;
int cnt;
double ts, dts;
- if ((u_char *)(rh + 1) > ep) {
- ND_PRINT((ndo, " [|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);
+ sr = (const struct rtcp_sr *)(rh + 1);
ND_PRINT((ndo, " sr"));
if (len != cnt * sizeof(*rr) + sizeof(*sr) + sizeof(*rh))
ND_PRINT((ndo, " [%d]", len));
if (ndo->ndo_vflag)
ND_PRINT((ndo, " %u", EXTRACT_32BITS(&rh->rh_ssrc)));
- if ((u_char *)(sr + 1) > ep) {
- ND_PRINT((ndo, " [|rtcp]"));
- return (ep);
- }
+ 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);
ND_PRINT((ndo, " @%.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);
+ rr = (const struct rtcp_rr *)(sr + 1);
break;
case RTCP_PT_RR:
ND_PRINT((ndo, " rr"));
if (len != cnt * sizeof(*rr) + sizeof(*rh))
ND_PRINT((ndo, " [%d]", len));
- rr = (struct rtcp_rr *)(rh + 1);
+ rr = (const struct rtcp_rr *)(rh + 1);
if (ndo->ndo_vflag)
ND_PRINT((ndo, " %u", EXTRACT_32BITS(&rh->rh_ssrc)));
break;
@@ -257,10 +279,9 @@ rtcp_print(netdissect_options *ndo, const u_char *hdr, const u_char *ep)
if (cnt > 1)
ND_PRINT((ndo, " c%d", cnt));
while (--cnt >= 0) {
- if ((u_char *)(rr + 1) > ep) {
- ND_PRINT((ndo, " [|rtcp]"));
- return (ep);
- }
+ 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.;
@@ -271,29 +292,30 @@ rtcp_print(netdissect_options *ndo, const u_char *hdr, const u_char *ep)
EXTRACT_32BITS(&rr->rr_dv), ts, dts));
}
return (hdr + len);
+
+trunc:
+ ND_PRINT((ndo, "%s", rtcp_tstr));
+ return ep;
}
static int udp_cksum(netdissect_options *ndo, register const struct ip *ip,
register const struct udphdr *up,
register u_int len)
{
- return nextproto4_cksum(ndo, ip, (const uint8_t *)(void *)up, len, len,
+ 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 uint8_t *)(void *)up, len, len,
- IPPROTO_UDP);
+ return nextproto6_cksum(ndo, ip6, (const uint8_t *)(const void *)up, len, len,
+ IPPROTO_UDP);
}
-#endif
static void
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)
@@ -310,20 +332,18 @@ udpipaddr_print(netdissect_options *ndo, const struct ip *ip, int sport, int dpo
} else {
ND_PRINT((ndo, "%s.%s > %s.%s: ",
ip6addr_string(ndo, &ip6->ip6_src),
- udpport_string(sport),
+ udpport_string(ndo, sport),
ip6addr_string(ndo, &ip6->ip6_dst),
- udpport_string(dport)));
+ udpport_string(ndo, dport)));
}
} else {
if (sport != -1) {
ND_PRINT((ndo, "%s > %s: ",
- udpport_string(sport),
- udpport_string(dport)));
+ udpport_string(ndo, sport),
+ udpport_string(ndo, dport)));
}
}
- } else
-#endif /*INET6*/
- {
+ } else {
if (ip->ip_p == IPPROTO_UDP) {
if (sport == -1) {
ND_PRINT((ndo, "%s > %s: ",
@@ -332,15 +352,15 @@ udpipaddr_print(netdissect_options *ndo, const struct ip *ip, int sport, int dpo
} else {
ND_PRINT((ndo, "%s.%s > %s.%s: ",
ipaddr_string(ndo, &ip->ip_src),
- udpport_string(sport),
+ udpport_string(ndo, sport),
ipaddr_string(ndo, &ip->ip_dst),
- udpport_string(dport)));
+ udpport_string(ndo, dport)));
}
} else {
if (sport != -1) {
ND_PRINT((ndo, "%s > %s: ",
- udpport_string(sport),
- udpport_string(dport)));
+ udpport_string(ndo, sport),
+ udpport_string(ndo, dport)));
}
}
}
@@ -355,24 +375,19 @@ udp_print(netdissect_options *ndo, register const u_char *bp, u_int length,
register const u_char *cp;
register const u_char *ep = bp + length;
uint16_t sport, dport, ulen;
-#ifdef INET6
register const struct ip6_hdr *ip6;
-#endif
if (ep > ndo->ndo_snapend)
ep = ndo->ndo_snapend;
- up = (struct udphdr *)bp;
- ip = (struct ip *)bp2;
-#ifdef INET6
+ 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*/
if (!ND_TTEST(up->uh_dport)) {
udpipaddr_print(ndo, ip, -1, -1);
- ND_PRINT((ndo, "[|udp]"));
- return;
+ goto trunc;
}
sport = EXTRACT_16BITS(&up->uh_sport);
@@ -383,6 +398,10 @@ udp_print(netdissect_options *ndo, register const u_char *bp, u_int length,
ND_PRINT((ndo, "truncated-udp %d", length));
return;
}
+ if (!ND_TTEST(up->uh_ulen)) {
+ udpipaddr_print(ndo, ip, sport, dport);
+ goto trunc;
+ }
ulen = EXTRACT_16BITS(&up->uh_ulen);
if (ulen < sizeof(struct udphdr)) {
udpipaddr_print(ndo, ip, sport, dport);
@@ -394,43 +413,42 @@ udp_print(netdissect_options *ndo, register const u_char *bp, u_int length,
if (ulen < length)
length = ulen;
- cp = (u_char *)(up + 1);
+ cp = (const u_char *)(up + 1);
if (cp > ndo->ndo_snapend) {
udpipaddr_print(ndo, ip, sport, dport);
- ND_PRINT((ndo, "[|udp]"));
- return;
+ goto trunc;
}
if (ndo->ndo_packettype) {
- register struct sunrpc_msg *rp;
+ register const struct sunrpc_msg *rp;
enum sunrpc_msg_type direction;
switch (ndo->ndo_packettype) {
case PT_VAT:
udpipaddr_print(ndo, ip, sport, dport);
- vat_print(ndo, (void *)(up + 1), up);
+ vat_print(ndo, (const void *)(up + 1), up);
break;
case PT_WB:
udpipaddr_print(ndo, ip, sport, dport);
- wb_print(ndo, (void *)(up + 1), length);
+ 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);
if (direction == SUNRPC_CALL)
- sunrpcrequest_print(ndo, (u_char *)rp, length,
- (u_char *)ip);
+ sunrpcrequest_print(ndo, (const u_char *)rp, length,
+ (const u_char *)ip);
else
- nfsreply_print(ndo, (u_char *)rp, length,
- (u_char *)ip); /*XXX*/
+ nfsreply_print(ndo, (const u_char *)rp, length,
+ (const u_char *)ip); /*XXX*/
break;
case PT_RTP:
udpipaddr_print(ndo, ip, sport, dport);
- rtp_print(ndo, (void *)(up + 1), length, up);
+ rtp_print(ndo, (const void *)(up + 1), length, up);
break;
case PT_RTCP:
@@ -457,11 +475,7 @@ udp_print(netdissect_options *ndo, register const u_char *bp, u_int length,
case PT_AODV:
udpipaddr_print(ndo, ip, sport, dport);
aodv_print(ndo, (const u_char *)(up + 1), length,
-#ifdef INET6
ip6 != NULL);
-#else
- 0);
-#endif
break;
case PT_RADIUS:
@@ -489,39 +503,31 @@ udp_print(netdissect_options *ndo, register const u_char *bp, u_int length,
udpipaddr_print(ndo, ip, sport, dport);
if (!ndo->ndo_qflag) {
- register struct sunrpc_msg *rp;
+ register const struct sunrpc_msg *rp;
enum sunrpc_msg_type direction;
- rp = (struct sunrpc_msg *)(up + 1);
+ 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) {
ND_PRINT((ndo, "NFS request xid %u ", EXTRACT_32BITS(&rp->rm_xid)));
- nfsreq_print_noaddr(ndo, (u_char *)rp, length,
- (u_char *)ip);
+ nfsreq_print_noaddr(ndo, (const u_char *)rp, length,
+ (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, (u_char *)rp, length,
- (u_char *)ip);
+ 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 (ND_TTEST(((struct LAP *)cp)->type) &&
- ((struct LAP *)cp)->type == lapDDP &&
- (atalk_port(sport) || atalk_port(dport))) {
- if (ndo->ndo_vflag)
- ND_PRINT((ndo, "kip "));
- llap_print(ndo, cp, length);
- return;
- }
}
if (ndo->ndo_vflag && !ndo->ndo_Kflag && !fragmented) {
@@ -547,11 +553,10 @@ udp_print(netdissect_options *ndo, register const u_char *bp, u_int length,
ND_PRINT((ndo, "[udp sum ok] "));
}
}
-#ifdef INET6
else if (IP_V(ip) == 6 && ip6->ip6_plen) {
/* for IPv6, UDP checksum is mandatory */
if (ND_TTEST2(cp[0], length)) {
- sum = udp6_cksum(ip6, up, length + sizeof(struct udphdr));
+ sum = udp6_cksum(ndo, ip6, up, length + sizeof(struct udphdr));
udp_sum = EXTRACT_16BITS(&up->uh_sum);
if (sum != 0) {
@@ -562,55 +567,49 @@ udp_print(netdissect_options *ndo, register const u_char *bp, u_int length,
ND_PRINT((ndo, "[udp sum ok] "));
}
}
-#endif
}
if (!ndo->ndo_qflag) {
-#define ISPORT(p) (dport == (p) || sport == (p))
- if (ISPORT(NAMESERVER_PORT))
+ if (IS_SRC_OR_DST_PORT(NAMESERVER_PORT))
ns_print(ndo, (const u_char *)(up + 1), length, 0);
- else if (ISPORT(MULTICASTDNS_PORT))
+ else if (IS_SRC_OR_DST_PORT(MULTICASTDNS_PORT))
ns_print(ndo, (const u_char *)(up + 1), length, 1);
- else if (ISPORT(TIMED_PORT))
+ else if (IS_SRC_OR_DST_PORT(TIMED_PORT))
timed_print(ndo, (const u_char *)(up + 1));
- else if (ISPORT(TFTP_PORT))
+ else if (IS_SRC_OR_DST_PORT(TFTP_PORT))
tftp_print(ndo, (const u_char *)(up + 1), length);
- else if (ISPORT(BOOTPC_PORT) || ISPORT(BOOTPS_PORT))
+ 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 (ISPORT(RIP_PORT))
+ else if (IS_SRC_OR_DST_PORT(RIP_PORT))
rip_print(ndo, (const u_char *)(up + 1), length);
- else if (ISPORT(AODV_PORT))
+ else if (IS_SRC_OR_DST_PORT(AODV_PORT))
aodv_print(ndo, (const u_char *)(up + 1), length,
-#ifdef INET6
ip6 != NULL);
-#else
- 0);
-#endif
- else if (ISPORT(ISAKMP_PORT))
+ else if (IS_SRC_OR_DST_PORT(ISAKMP_PORT))
isakmp_print(ndo, (const u_char *)(up + 1), length, bp2);
- else if (ISPORT(ISAKMP_PORT_NATT))
+ 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))
+ 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))
+ 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 (ISPORT(NTP_PORT))
+ else if (IS_SRC_OR_DST_PORT(NTP_PORT))
ntp_print(ndo, (const u_char *)(up + 1), length);
- else if (ISPORT(KERBEROS_PORT) || ISPORT(KERBEROS_SEC_PORT))
+ 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 (ISPORT(L2TP_PORT))
+ else if (IS_SRC_OR_DST_PORT(L2TP_PORT))
l2tp_print(ndo, (const u_char *)(up + 1), length);
-#ifdef TCPDUMP_DO_SMB
- else if (ISPORT(NETBIOS_NS_PORT))
+#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 (ISPORT(NETBIOS_DGRAM_PORT))
+ else if (IS_SRC_OR_DST_PORT(NETBIOS_DGRAM_PORT))
nbt_udp138_print(ndo, (const u_char *)(up + 1), length);
#endif
else if (dport == VAT_PORT)
vat_print(ndo, (const void *)(up + 1), up);
- else if (ISPORT(ZEPHYR_SRV_PORT) || ISPORT(ZEPHYR_CLT_PORT))
+ 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
@@ -619,78 +618,84 @@ udp_print(netdissect_options *ndo, register const u_char *bp, u_int length,
else if ((sport >= RX_PORT_LOW && sport <= RX_PORT_HIGH) ||
(dport >= RX_PORT_LOW && dport <= RX_PORT_HIGH))
rx_print(ndo, (const void *)(up + 1), length, sport, dport,
- (u_char *) ip);
-#ifdef INET6
- else if (ISPORT(RIPNG_PORT))
+ (const u_char *) ip);
+ else if (IS_SRC_OR_DST_PORT(RIPNG_PORT))
ripng_print(ndo, (const u_char *)(up + 1), length);
- else if (ISPORT(DHCP6_SERV_PORT) || ISPORT(DHCP6_CLI_PORT))
+ 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 (ISPORT(AHCP_PORT))
+ else if (IS_SRC_OR_DST_PORT(AHCP_PORT))
ahcp_print(ndo, (const u_char *)(up + 1), length);
- else if (ISPORT(BABEL_PORT) || ISPORT(BABEL_PORT_OLD))
+ 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);
-#endif /*INET6*/
+ 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 == WB_PORT)
wb_print(ndo, (const void *)(up + 1), length);
- else if (ISPORT(CISCO_AUTORP_PORT))
+ else if (IS_SRC_OR_DST_PORT(CISCO_AUTORP_PORT))
cisco_autorp_print(ndo, (const void *)(up + 1), length);
- else if (ISPORT(RADIUS_PORT) ||
- ISPORT(RADIUS_NEW_PORT) ||
- ISPORT(RADIUS_ACCOUNTING_PORT) ||
- ISPORT(RADIUS_NEW_ACCOUNTING_PORT) ||
- ISPORT(RADIUS_COA_PORT) )
+ 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(ndo, (const u_char *)(up + 1), length);
- else if (ISPORT(LWRES_PORT))
+ else if (IS_SRC_OR_DST_PORT(LWRES_PORT))
lwres_print(ndo, (const u_char *)(up + 1), length);
- else if (ISPORT(LDP_PORT))
+ else if (IS_SRC_OR_DST_PORT(LDP_PORT))
ldp_print(ndo, (const u_char *)(up + 1), length);
- else if (ISPORT(OLSR_PORT))
+ else if (IS_SRC_OR_DST_PORT(OLSR_PORT))
olsr_print(ndo, (const u_char *)(up + 1), length,
-#if INET6
(IP_V(ip) == 6) ? 1 : 0);
-#else
- 0);
-#endif
- else if (ISPORT(MPLS_LSP_PING_PORT))
+ 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(ndo, (const u_char *)(up+1), length, dport);
- else if (ISPORT(LMP_PORT))
+ else if (IS_SRC_OR_DST_PORT(LMP_PORT))
lmp_print(ndo, (const u_char *)(up + 1), length);
- else if (ISPORT(VQP_PORT))
+ else if (IS_SRC_OR_DST_PORT(VQP_PORT))
vqp_print(ndo, (const u_char *)(up + 1), length);
- else if (ISPORT(SFLOW_PORT))
+ 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(ndo, (const u_char *)(up + 1), length, 1);
else if (sport == LWAPP_CONTROL_PORT)
lwapp_control_print(ndo, (const u_char *)(up + 1), length, 0);
- else if (ISPORT(LWAPP_DATA_PORT))
+ else if (IS_SRC_OR_DST_PORT(LWAPP_DATA_PORT))
lwapp_data_print(ndo, (const u_char *)(up + 1), length);
- else if (ISPORT(SIP_PORT))
+ else if (IS_SRC_OR_DST_PORT(SIP_PORT))
sip_print(ndo, (const u_char *)(up + 1), length);
- else if (ISPORT(SYSLOG_PORT))
+ else if (IS_SRC_OR_DST_PORT(SYSLOG_PORT))
syslog_print(ndo, (const u_char *)(up + 1), length);
- else if (ISPORT(OTV_PORT))
+ else if (IS_SRC_OR_DST_PORT(OTV_PORT))
otv_print(ndo, (const u_char *)(up + 1), length);
- else if (ISPORT(VXLAN_PORT))
+ else if (IS_SRC_OR_DST_PORT(VXLAN_PORT))
vxlan_print(ndo, (const u_char *)(up + 1), length);
- else if (ISPORT(GENEVE_PORT))
+ else if (IS_SRC_OR_DST_PORT(GENEVE_PORT))
geneve_print(ndo, (const u_char *)(up + 1), length);
- else {
+ 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));
}
-#undef ISPORT
} else {
if (ulen > length)
ND_PRINT((ndo, "UDP, bad length %u > %u",
@@ -698,6 +703,10 @@ udp_print(netdissect_options *ndo, register const u_char *bp, u_int length,
else
ND_PRINT((ndo, "UDP, length %u", ulen));
}
+ return;
+
+trunc:
+ ND_PRINT((ndo, "%s", udp_tstr));
}
@@ -707,4 +716,3 @@ udp_print(netdissect_options *ndo, register const u_char *bp, u_int length,
* c-basic-offset: 8
* End:
*/
-
diff --git a/contrib/tcpdump/print-usb.c b/contrib/tcpdump/print-usb.c
index 75f78fc..04eb4ef 100644
--- a/contrib/tcpdump/print-usb.c
+++ b/contrib/tcpdump/print-usb.c
@@ -19,14 +19,15 @@
*
*/
-#define NETDISSECT_REWORKED
+/* \summary: USB printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#if defined(HAVE_PCAP_USB_H) && defined(DLT_USB_LINUX)
diff --git a/contrib/tcpdump/print-vjc.c b/contrib/tcpdump/print-vjc.c
index 24f8a12..3287b9b 100644
--- a/contrib/tcpdump/print-vjc.c
+++ b/contrib/tcpdump/print-vjc.c
@@ -19,14 +19,17 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#define NETDISSECT_REWORKED
+/* \summary: PPP Van Jacobson compression printer */
+
+/* specification: RFC 1144 */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "slcompress.h"
#include "ppp.h"
@@ -71,6 +74,13 @@
* 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(netdissect_options *ndo, register const char *bp, u_short proto _U_)
@@ -96,7 +106,7 @@ vjc_print(netdissect_options *ndo, register const char *bp, u_short proto _U_)
if (bp[1])
ND_PRINT((ndo, " "));
ND_PRINT((ndo, "C=0x%02x ", bp[2]));
- ND_PRINT((ndo, "sum=0x%04x ", *(u_short *)&bp[3]));
+ ND_PRINT((ndo, "sum=0x%04x ", *(const u_short *)&bp[3]));
return -1;
case TYPE_ERROR:
if (ndo->ndo_eflag)
diff --git a/contrib/tcpdump/print-vqp.c b/contrib/tcpdump/print-vqp.c
index ce3572a..44a2193 100644
--- a/contrib/tcpdump/print-vqp.c
+++ b/contrib/tcpdump/print-vqp.c
@@ -12,19 +12,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>
*/
-#define NETDISSECT_REWORKED
+/* \summary: Cisco VLAN Query Protocol (VQP) printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
#include "addrtoname.h"
diff --git a/contrib/tcpdump/print-vrrp.c b/contrib/tcpdump/print-vrrp.c
index f739d1e..d8ba426 100644
--- a/contrib/tcpdump/print-vrrp.c
+++ b/contrib/tcpdump/print-vrrp.c
@@ -23,14 +23,15 @@
* FOR A PARTICULAR PURPOSE.
*/
-#define NETDISSECT_REWORKED
+/* \summary: Virtual Router Redundancy Protocol (VRRP) printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
#include "addrtoname.h"
@@ -147,7 +148,7 @@ vrrp_print(netdissect_options *ndo,
}
if (version == 3 && ND_TTEST2(bp[0], len)) {
- uint16_t cksum = nextproto4_cksum(ndo, (struct ip *)bp2, bp,
+ uint16_t cksum = nextproto4_cksum(ndo, (const struct ip *)bp2, bp,
len, len, IPPROTO_VRRP);
if (cksum)
ND_PRINT((ndo, ", (bad vrrp cksum %x)",
diff --git a/contrib/tcpdump/print-vtp.c b/contrib/tcpdump/print-vtp.c
index 9fe86e3..285beb9 100644
--- a/contrib/tcpdump/print-vtp.c
+++ b/contrib/tcpdump/print-vtp.c
@@ -12,8 +12,6 @@
* 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
@@ -22,14 +20,15 @@
* Original code ode by Carles Kishimoto <carles.kishimoto@gmail.com>
*/
-#define NETDISSECT_REWORKED
+/* \summary: Cisco VLAN Trunking Protocol (VTP) printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "extract.h"
@@ -121,7 +120,7 @@ void
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;
@@ -136,7 +135,7 @@ vtp_print (netdissect_options *ndo,
ND_PRINT((ndo, "VTPv%u, Message %s (0x%02x), length %u",
*tptr,
tok2str(vtp_message_type_values,"Unknown message type", type),
- *(tptr+1),
+ type,
length));
/* In non-verbose mode, just print version and message type */
@@ -145,9 +144,15 @@ vtp_print (netdissect_options *ndo,
}
/* verbose mode print all fields */
- ND_PRINT((ndo, "\n\tDomain name: %s, %s: %u",
- (tptr+4),
- tok2str(vtp_header_values,"Unknown",*(tptr+1)),
+ 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;
@@ -161,9 +166,9 @@ vtp_print (netdissect_options *ndo,
*
* 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 |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
@@ -176,15 +181,18 @@ vtp_print (netdissect_options *ndo,
*
*/
+ ND_TCHECK2(*tptr, 8);
ND_PRINT((ndo, "\n\t Config Rev %x, Updater %s",
EXTRACT_32BITS(tptr),
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)));
tptr += VTP_UPDATE_TIMESTAMP_LEN;
+ ND_TCHECK2(*tptr, VTP_MD5_DIGEST_LEN);
ND_PRINT((ndo, ", MD5 digest: %08x%08x%08x%08x",
EXTRACT_32BITS(tptr),
EXTRACT_32BITS(tptr + 4),
@@ -200,9 +208,9 @@ vtp_print (netdissect_options *ndo,
*
* 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 |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
@@ -241,14 +249,15 @@ vtp_print (netdissect_options *ndo,
ND_TCHECK2(*tptr, len);
- vtp_vlan = (struct vtp_vlan_*)tptr;
- ND_PRINT((ndo, "\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.
@@ -338,15 +347,16 @@ vtp_print (netdissect_options *ndo,
*
* 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 |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*
*/
+ ND_TCHECK2(*tptr, 4);
ND_PRINT((ndo, "\n\tStart value: %u", EXTRACT_32BITS(tptr)));
break;
diff --git a/contrib/tcpdump/print-vxlan-gpe.c b/contrib/tcpdump/print-vxlan-gpe.c
new file mode 100644
index 0000000..6d170de
--- /dev/null
+++ b/contrib/tcpdump/print-vxlan-gpe.c
@@ -0,0 +1,113 @@
+/* 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));
+}
+
diff --git a/contrib/tcpdump/print-vxlan.c b/contrib/tcpdump/print-vxlan.c
index c4de68d..0c2a82e 100644
--- a/contrib/tcpdump/print-vxlan.c
+++ b/contrib/tcpdump/print-vxlan.c
@@ -13,16 +13,23 @@
* Original code by Francesco Fondelli (francesco dot fondelli, gmail dot com)
*/
-#define NETDISSECT_REWORKED
+/* \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 "interface.h"
+#include "netdissect.h"
#include "extract.h"
+static const char tstr[] = " [|VXLAN]";
+
+#define VXLAN_HDR_LEN 8
+
/*
* VXLAN header, RFC7348
* Virtual eXtensible Local Area Network (VXLAN): A Framework
@@ -43,10 +50,10 @@ vxlan_print(netdissect_options *ndo, const u_char *bp, u_int len)
uint8_t flags;
uint32_t vni;
- if (len < 8) {
- ND_PRINT((ndo, "[|VXLAN]"));
- return;
- }
+ if (len < VXLAN_HDR_LEN)
+ goto trunc;
+
+ ND_TCHECK2(*bp, VXLAN_HDR_LEN);
flags = *bp;
bp += 4;
@@ -58,5 +65,10 @@ vxlan_print(netdissect_options *ndo, const u_char *bp, u_int len)
ND_PRINT((ndo, "flags [%s] (0x%02x), ", flags & 0x08 ? "I" : ".", flags));
ND_PRINT((ndo, "vni %u\n", vni));
- ether_print(ndo, bp, len - 8, len - 8, NULL, NULL);
+ ether_print(ndo, bp, len - VXLAN_HDR_LEN, ndo->ndo_snapend - bp, NULL, NULL);
+
+ return;
+
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
}
diff --git a/contrib/tcpdump/print-wb.c b/contrib/tcpdump/print-wb.c
index e10d532..88857d9 100644
--- a/contrib/tcpdump/print-wb.c
+++ b/contrib/tcpdump/print-wb.c
@@ -19,14 +19,15 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#define NETDISSECT_REWORKED
+/* \summary: White Board printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "extract.h"
@@ -48,8 +49,8 @@ static const char tstr[] = "[|wb]";
#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.
@@ -200,11 +201,11 @@ wb_id(netdissect_options *ndo,
nid = EXTRACT_16BITS(&id->pi_ps.nid);
len -= sizeof(*io) * nid;
- io = (struct id_off *)(id + 1);
- cp = (char *)(io + nid);
+ io = (const struct id_off *)(id + 1);
+ cp = (const char *)(io + nid);
if (ND_TTEST2(cp, len)) {
ND_PRINT((ndo, "\""));
- fn_print(ndo, (u_char *)cp, (u_char *)cp + len);
+ fn_print(ndo, (const u_char *)cp, (const u_char *)cp + len);
ND_PRINT((ndo, "\""));
}
@@ -275,16 +276,16 @@ wb_prep(netdissect_options *ndo,
EXTRACT_32BITS(&ps->slot),
ipaddr_string(ndo, &ps->page.p_sid),
EXTRACT_32BITS(&ps->page.p_uid)));
- io = (struct id_off *)(ps + 1);
+ 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 = ',';
}
ND_PRINT((ndo, ">"));
- ps = (struct pgstate *)io;
+ ps = (const struct pgstate *)io;
}
- return ((u_char *)ps <= ep? 0 : -1);
+ return ((const u_char *)ps <= ep? 0 : -1);
}
@@ -416,32 +417,32 @@ wb_print(netdissect_options *ndo,
return;
case PT_ID:
- if (wb_id(ndo, (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(ndo, (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(ndo, (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(ndo, (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(ndo, (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(ndo, (struct pkt_prep *)(ph + 1), len) >= 0)
+ if (wb_prep(ndo, (const struct pkt_prep *)(ph + 1), len) >= 0)
return;
break;
diff --git a/contrib/tcpdump/print-zephyr.c b/contrib/tcpdump/print-zephyr.c
index 8132c49..38b0cd0 100644
--- a/contrib/tcpdump/print-zephyr.c
+++ b/contrib/tcpdump/print-zephyr.c
@@ -20,37 +20,38 @@
* PURPOSE.
*/
-#define NETDISSECT_REWORKED
+/* \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.. */
};
@@ -80,30 +81,30 @@ static const struct tok z_types[] = {
static char z_buf[256];
-static char *
-parse_field(netdissect_options *ndo, 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 *) ndo->ndo_snapend)
+ if (*pptr > (const char *) ndo->ndo_snapend)
return NULL;
s = *pptr;
- while (*pptr <= (char *) ndo->ndo_snapend && *len >= 0 && **pptr) {
+ while (*pptr <= (const char *) ndo->ndo_snapend && *len >= 0 && **pptr) {
(*pptr)++;
(*len)--;
}
(*pptr)++;
(*len)--;
- if (*len < 0 || *pptr > (char *) ndo->ndo_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 = "*";
@@ -113,15 +114,17 @@ 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;
@@ -131,9 +134,9 @@ void
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 */
@@ -193,7 +196,7 @@ zephyr_print(netdissect_options *ndo, const u_char *cp, int length)
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"))
ND_PRINT((ndo, "/%s", str_to_lower(ackdata)));
@@ -226,7 +229,7 @@ zephyr_print(netdissect_options *ndo, const u_char *cp, int length)
"-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);
diff --git a/contrib/tcpdump/print-zeromq.c b/contrib/tcpdump/print-zeromq.c
index ba22c96..a23d98a 100644
--- a/contrib/tcpdump/print-zeromq.c
+++ b/contrib/tcpdump/print-zeromq.c
@@ -1,7 +1,4 @@
/*
- * This file implements decoding of ZeroMQ network protocol(s).
- *
- *
* Copyright (c) 2013 The TCPDUMP project
* All rights reserved.
*
@@ -28,14 +25,15 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#define NETDISSECT_REWORKED
+/* \summary: ZeroMQ Message Transport Protocol (ZMTP) printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "extract.h"
static const char tstr[] = " [|zmtp1]";
@@ -87,22 +85,18 @@ zmtp1_print_frame(netdissect_options *ndo, const u_char *cp, const u_char *ep)
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 */
- ND_PRINT((ndo, " frame flags+body (8-bit) length %u", cp[0]));
- ND_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 */
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 */
ND_PRINT((ndo, " %" PRIu64, body_len_declared));
- ND_TCHECK2(*cp, header_len + 1); /* 0xFF, length, flags */
- flags = cp[9];
}
+ 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)
@@ -131,8 +125,15 @@ zmtp1_print_frame(netdissect_options *ndo, const u_char *cp, const u_char *ep)
}
}
- ND_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:
ND_PRINT((ndo, "%s", tstr));
diff --git a/contrib/tcpdump/print.c b/contrib/tcpdump/print.c
new file mode 100644
index 0000000..41ca9ca
--- /dev/null
+++ b/contrib/tcpdump/print.c
@@ -0,0 +1,484 @@
+/*
+ * 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:
+ */
diff --git a/contrib/tcpdump/print.h b/contrib/tcpdump/print.h
new file mode 100644
index 0000000..9632694
--- /dev/null
+++ b/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/contrib/tcpdump/rpc_auth.h b/contrib/tcpdump/rpc_auth.h
index 6dabb49..2069090 100644
--- a/contrib/tcpdump/rpc_auth.h
+++ b/contrib/tcpdump/rpc_auth.h
@@ -28,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: stable/11/contrib/tcpdump/rpc_auth.h 276788 2015-01-07 19:55:18Z delphij $
*/
/*
diff --git a/contrib/tcpdump/rpc_msg.h b/contrib/tcpdump/rpc_msg.h
index 35a191c..d906563 100644
--- a/contrib/tcpdump/rpc_msg.h
+++ b/contrib/tcpdump/rpc_msg.h
@@ -28,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: stable/11/contrib/tcpdump/rpc_msg.h 276788 2015-01-07 19:55:18Z delphij $
*/
/*
diff --git a/contrib/tcpdump/rpl.h b/contrib/tcpdump/rpl.h
index c48784b..5ad074b 100644
--- a/contrib/tcpdump/rpl.h
+++ b/contrib/tcpdump/rpl.h
@@ -22,7 +22,7 @@ enum ND_RPL_CODE {
ND_RPL_SEC_DAG_IO = 0x81,
ND_RPL_SEC_DAG = 0x82,
ND_RPL_SEC_DAG_ACK= 0x83,
- ND_RPL_SEC_CONSIST= 0x84,
+ ND_RPL_SEC_CONSIST= 0x8A
};
enum ND_RPL_DIO_FLAGS {
@@ -31,7 +31,7 @@ enum ND_RPL_DIO_FLAGS {
ND_RPL_DIO_DASUPPORT= 0x20,
ND_RPL_DIO_RES4 = 0x10,
ND_RPL_DIO_RES3 = 0x08,
- ND_RPL_DIO_PRF_MASK = 0x07, /* 3-bit preference */
+ ND_RPL_DIO_PRF_MASK = 0x07 /* 3-bit preference */
};
#define DAGID_LEN 16
@@ -81,7 +81,7 @@ enum RPL_DIO_MOP {
RPL_DIO_NONSTORING= 0x0,
RPL_DIO_STORING = 0x1,
RPL_DIO_NONSTORING_MULTICAST = 0x2,
- RPL_DIO_STORING_MULTICAST = 0x3,
+ RPL_DIO_STORING_MULTICAST = 0x3
};
enum RPL_SUBOPT {
@@ -93,7 +93,7 @@ enum RPL_SUBOPT {
RPL_DAO_RPLTARGET = 5,
RPL_DAO_TRANSITINFO = 6,
RPL_DIO_DESTPREFIX = 8,
- RPL_DAO_RPLTARGET_DESC=9,
+ RPL_DAO_RPLTARGET_DESC=9
};
struct rpl_dio_genoption {
diff --git a/contrib/tcpdump/setsignal.c b/contrib/tcpdump/setsignal.c
index 1bcc032..4d93ceb 100644
--- a/contrib/tcpdump/setsignal.c
+++ b/contrib/tcpdump/setsignal.c
@@ -23,7 +23,7 @@
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
#include <signal.h>
#ifdef HAVE_SIGACTION
diff --git a/contrib/tcpdump/signature.c b/contrib/tcpdump/signature.c
index 324035f..1af798a 100644
--- a/contrib/tcpdump/signature.c
+++ b/contrib/tcpdump/signature.c
@@ -15,16 +15,16 @@
* Original code by Hannes Gredler (hannes@juniper.net)
*/
-#define NETDISSECT_REWORKED
#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
@@ -34,6 +34,7 @@
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 }
};
@@ -108,39 +109,86 @@ signature_compute_hmac_md5(const uint8_t *text, int text_len, unsigned char *key
MD5_Final(digest, &context); /* finish up 2nd pass */
}
USES_APPLE_RST
-#endif
-#ifdef HAVE_LIBCRYPTO
/*
* Verify a cryptographic signature of the packet.
* Currently only MD5 is supported.
*/
int
-signature_verify(netdissect_options *ndo,
- 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)
{
- uint8_t rcvsig[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 (!ndo->ndo_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);
+ }
+
+ /*
+ * 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);
+ }
+
+ memcpy(packet_copy, pptr, plen);
- signature_compute_hmac_md5(pptr, plen, (unsigned char *)ndo->ndo_sigsecret,
+ /*
+ * 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);
- if (memcmp(rcvsig, sig, sizeof(sig)) == 0) {
- return (SIGNATURE_VALID);
+ /*
+ * 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) {
ND_PRINT((ndo, "%02x", sig[i]));
}
@@ -148,6 +196,14 @@ signature_verify(netdissect_options *ndo,
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
/*
diff --git a/contrib/tcpdump/signature.h b/contrib/tcpdump/signature.h
index a052df8..239ee3e 100644
--- a/contrib/tcpdump/signature.h
+++ b/contrib/tcpdump/signature.h
@@ -21,7 +21,9 @@
/* 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(netdissect_options *, 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/contrib/tcpdump/smb.h b/contrib/tcpdump/smb.h
index 88eaa06..b521617 100644
--- a/contrib/tcpdump/smb.h
+++ b/contrib/tcpdump/smb.h
@@ -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(netdissect_options *, const u_char *, const char *, const u_char *, int);
diff --git a/contrib/tcpdump/smbutil.c b/contrib/tcpdump/smbutil.c
index 1c1742c..b38d73a 100644
--- a/contrib/tcpdump/smbutil.c
+++ b/contrib/tcpdump/smbutil.c
@@ -6,18 +6,17 @@
* or later
*/
-#define NETDISSECT_REWORKED
#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 "smb.h"
@@ -272,8 +271,7 @@ name_type_str(int name_type)
}
void
-print_data(netdissect_options *ndo,
- const unsigned char *buf, int len)
+smb_print_data(netdissect_options *ndo, const unsigned char *buf, int len)
{
int i = 0;
@@ -861,7 +859,7 @@ smb_fdata(netdissect_options *ndo,
if (!depth && buf < maxbuf) {
size_t len = PTR_DIFF(maxbuf, buf);
ND_PRINT((ndo, "Data: (%lu bytes)\n", (unsigned long)len));
- print_data(ndo, buf, len);
+ smb_print_data(ndo, buf, len);
return(buf + len);
}
return(buf);
diff --git a/contrib/tcpdump/strcasecmp.c b/contrib/tcpdump/strcasecmp.c
deleted file mode 100644
index 7ee4e38..0000000
--- a/contrib/tcpdump/strcasecmp.c
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * 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.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <tcpdump-stdinc.h>
-
-#include "interface.h"
-
-/*
- * This array is designed for mapping upper and lower case letter
- * together for a case independent comparison. The mappings are
- * based upon ascii character sequences.
- */
-static const u_char charmap[] = {
- '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007',
- '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017',
- '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027',
- '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037',
- '\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047',
- '\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057',
- '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067',
- '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077',
- '\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
- '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
- '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
- '\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137',
- '\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
- '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
- '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
- '\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177',
- '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207',
- '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217',
- '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227',
- '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237',
- '\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247',
- '\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257',
- '\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267',
- '\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277',
- '\300', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
- '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
- '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
- '\370', '\371', '\372', '\333', '\334', '\335', '\336', '\337',
- '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
- '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
- '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
- '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377',
-};
-
-int
-strcasecmp(s1, s2)
- const char *s1, *s2;
-{
- register const u_char *cm = charmap,
- *us1 = (u_char *)s1,
- *us2 = (u_char *)s2;
-
- while (cm[*us1] == cm[*us2++])
- if (*us1++ == '\0')
- return(0);
- return(cm[*us1] - cm[*--us2]);
-}
-
-int
-strncasecmp(s1, s2, n)
- const char *s1, *s2;
- register int n;
-{
- register const u_char *cm = charmap,
- *us1 = (u_char *)s1,
- *us2 = (u_char *)s2;
-
- while (--n >= 0 && cm[*us1] == cm[*us2++])
- if (*us1++ == '\0')
- return(0);
- return(n < 0 ? 0 : cm[*us1] - cm[*--us2]);
-}
diff --git a/contrib/tcpdump/strtoaddr.c b/contrib/tcpdump/strtoaddr.c
new file mode 100644
index 0000000..81a041f
--- /dev/null
+++ b/contrib/tcpdump/strtoaddr.c
@@ -0,0 +1,239 @@
+/*
+ * 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <netdissect-stdinc.h>
+#include <stddef.h>
+#include <string.h>
+
+#include "strtoaddr.h"
+
+#ifndef NS_INADDRSZ
+#define NS_INADDRSZ 4 /* IPv4 T_A */
+#endif
+
+#ifndef NS_IN6ADDRSZ
+#define NS_IN6ADDRSZ 16 /* IPv6 T_AAAA */
+#endif
+
+#ifndef NS_INT16SZ
+#define NS_INT16SZ 2 /* #/bytes of data in a uint16_t */
+#endif
+
+/*%
+ * WARNING: Don't even consider trying to compile this on a system where
+ * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX.
+ */
+
+#ifndef NS_IN6ADDRSZ
+#define NS_IN6ADDRSZ 16 /* IPv6 T_AAAA */
+#endif
+
+/* int
+ * strtoaddr(src, dst)
+ * convert presentation level IPv4 address to network order binary form.
+ * return:
+ * 1 if `src' is a valid input, else 0.
+ * notice:
+ * does not touch `dst' unless it's returning 1.
+ * author:
+ * Paul Vixie, 1996.
+ */
+int
+strtoaddr(const char *src, void *dst)
+{
+ uint32_t val;
+ u_int digit;
+ ptrdiff_t n;
+ unsigned char c;
+ u_int parts[4];
+ u_int *pp = parts;
+
+ c = *src;
+ for (;;) {
+ /*
+ * Collect number up to ``.''.
+ * Values are specified as for C:
+ * 0x=hex, 0=octal, isdigit=decimal.
+ */
+ if (!isdigit(c))
+ return (0);
+ val = 0;
+ if (c == '0') {
+ c = *++src;
+ if (c == 'x' || c == 'X')
+ return (0);
+ else if (isdigit(c) && c != '9')
+ return (0);
+ }
+ for (;;) {
+ if (isdigit(c)) {
+ digit = c - '0';
+ if (digit >= 10)
+ break;
+ val = (val * 10) + digit;
+ c = *++src;
+ } else
+ break;
+ }
+ if (c == '.') {
+ /*
+ * Internet format:
+ * a.b.c.d
+ * a.b.c (with c treated as 16 bits)
+ * a.b (with b treated as 24 bits)
+ * a (with a treated as 32 bits)
+ */
+ if (pp >= parts + 3)
+ return (0);
+ *pp++ = val;
+ c = *++src;
+ } else
+ break;
+ }
+ /*
+ * Check for trailing characters.
+ */
+ if (c != '\0' && !isspace(c))
+ return (0);
+ /*
+ * Find the number of parts specified.
+ * It must be 4; we only support dotted quads, we don't
+ * support shorthand.
+ */
+ n = pp - parts + 1;
+ if (n != 4)
+ return (0);
+ /*
+ * parts[0-2] were set to the first 3 parts of the address;
+ * val was set to the 4th part.
+ *
+ * Check if any part is bigger than 255.
+ */
+ if ((parts[0] | parts[1] | parts[2] | val) > 0xff)
+ return (0);
+ /*
+ * Add the other three parts to val.
+ */
+ val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8);
+ if (dst) {
+ val = htonl(val);
+ memcpy(dst, &val, NS_INADDRSZ);
+ }
+ return (1);
+}
+
+/* int
+ * strtoaddr6(src, dst)
+ * convert presentation level IPv6 address to network order binary form.
+ * return:
+ * 1 if `src' is a valid [RFC1884 2.2] address, else 0.
+ * notice:
+ * (1) does not touch `dst' unless it's returning 1.
+ * (2) :: in a full address is silently ignored.
+ * credit:
+ * inspired by Mark Andrews.
+ * author:
+ * Paul Vixie, 1996.
+ */
+int
+strtoaddr6(const char *src, void *dst)
+{
+ static const char xdigits_l[] = "0123456789abcdef",
+ xdigits_u[] = "0123456789ABCDEF";
+ u_char tmp[NS_IN6ADDRSZ], *tp, *endp, *colonp;
+ const char *xdigits, *curtok;
+ int ch, seen_xdigits;
+ u_int val;
+
+ memset((tp = tmp), '\0', NS_IN6ADDRSZ);
+ endp = tp + NS_IN6ADDRSZ;
+ colonp = NULL;
+ /* Leading :: requires some special handling. */
+ if (*src == ':')
+ if (*++src != ':')
+ return (0);
+ curtok = src;
+ seen_xdigits = 0;
+ val = 0;
+ while ((ch = *src++) != '\0') {
+ const char *pch;
+
+ if ((pch = strchr((xdigits = xdigits_l), ch)) == NULL)
+ pch = strchr((xdigits = xdigits_u), ch);
+ if (pch != NULL) {
+ val <<= 4;
+ val |= (int)(pch - xdigits);
+ if (++seen_xdigits > 4)
+ return (0);
+ continue;
+ }
+ if (ch == ':') {
+ curtok = src;
+ if (!seen_xdigits) {
+ if (colonp)
+ return (0);
+ colonp = tp;
+ continue;
+ } else if (*src == '\0')
+ return (0);
+ if (tp + NS_INT16SZ > endp)
+ return (0);
+ *tp++ = (u_char) (val >> 8) & 0xff;
+ *tp++ = (u_char) val & 0xff;
+ seen_xdigits = 0;
+ val = 0;
+ continue;
+ }
+ if (ch == '.' && ((tp + NS_INADDRSZ) <= endp) &&
+ strtoaddr(curtok, tp) > 0) {
+ tp += NS_INADDRSZ;
+ seen_xdigits = 0;
+ break; /*%< '\\0' was seen by strtoaddr(). */
+ }
+ return (0);
+ }
+ if (seen_xdigits) {
+ if (tp + NS_INT16SZ > endp)
+ return (0);
+ *tp++ = (u_char) (val >> 8) & 0xff;
+ *tp++ = (u_char) val & 0xff;
+ }
+ if (colonp != NULL) {
+ /*
+ * Since some memmove()'s erroneously fail to handle
+ * overlapping regions, we'll do the shift by hand.
+ */
+ const ptrdiff_t n = tp - colonp;
+ int i;
+
+ if (tp == endp)
+ return (0);
+ for (i = 1; i <= n; i++) {
+ endp[- i] = colonp[n - i];
+ colonp[n - i] = 0;
+ }
+ tp = endp;
+ }
+ if (tp != endp)
+ return (0);
+ memcpy(dst, tmp, NS_IN6ADDRSZ);
+ return (1);
+}
diff --git a/contrib/tcpdump/strtoaddr.h b/contrib/tcpdump/strtoaddr.h
new file mode 100644
index 0000000..8bd22c7
--- /dev/null
+++ b/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/contrib/tcpdump/tcp.h b/contrib/tcpdump/tcp.h
index c18d138..912b5e8 100644
--- a/contrib/tcpdump/tcp.h
+++ b/contrib/tcpdump/tcp.h
@@ -81,56 +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
-#define NETBIOS_SSN_PORT 139
-#ifndef OPENFLOW_PORT_OLD
-#define OPENFLOW_PORT_OLD 6633
+#ifndef RPKI_RTR_PORT
+#define RPKI_RTR_PORT 323
#endif
-#ifndef OPENFLOW_PORT_IANA
-#define OPENFLOW_PORT_IANA 6653
+#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
#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 HTTP_PORT
-#define HTTP_PORT 80
+#ifndef OPENFLOW_PORT_IANA
+#define OPENFLOW_PORT_IANA 6653
#endif
#ifndef HTTP_PORT_ALT
#define HTTP_PORT_ALT 8080
#endif
-#ifndef RTSP_PORT
-#define RTSP_PORT 554
-#endif
#ifndef RTSP_PORT_ALT
#define RTSP_PORT_ALT 8554
#endif
-#ifndef FTP_PORT
-#define FTP_PORT 21
+#ifndef BEEP_PORT
+#define BEEP_PORT 10288
+#endif
+#ifndef REDIS_PORT
+#define REDIS_PORT 6379
#endif
diff --git a/contrib/tcpdump/tcpdump.1.in b/contrib/tcpdump/tcpdump.1.in
index f9522cb..f04a579 100644
--- a/contrib/tcpdump/tcpdump.1.in
+++ b/contrib/tcpdump/tcpdump.1.in
@@ -20,14 +20,14 @@
.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
.\"
-.TH TCPDUMP 1 "11 July 2014"
+.TH TCPDUMP 1 "17 September 2015"
.SH NAME
tcpdump \- dump traffic on a network
.SH SYNOPSIS
.na
.B tcpdump
[
-.B \-AbdDefhHIJKlLnNOpqRStuUvxX#
+.B \-AbdDefhHIJKlLnNOpqStuUvxX#
] [
.B \-B
.I buffer_size
@@ -400,7 +400,7 @@ If the
flag is supported, an interface number as printed by that flag can be
used as the
.I interface
-argument.
+argument, if no interface on the system has that number as a name.
.TP
.B \-I
.PD 0
@@ -593,12 +593,6 @@ Quick (quiet?) output.
Print less protocol information so output
lines are shorter.
.TP
-.B \-R
-Assume ESP/AH packets to be based on old specification (RFC1825 to RFC1829).
-If specified, \fItcpdump\fP will not print replay prevention field.
-Since there is no protocol version field in ESP/AH specification,
-\fItcpdump\fP cannot deduce the version of ESP/AH protocol.
-.TP
.BI \-r " file"
Read packets from \fIfile\fR (which was created with the
.B \-w
@@ -618,7 +612,7 @@ Print absolute, rather than relative, TCP sequence numbers.
.BI \-\-snapshot\-length= snaplen
.PD
Snarf \fIsnaplen\fP bytes of data from each packet rather than the
-default of 65535 bytes.
+default of 262144 bytes.
Packets truncated because of a limited snapshot
are indicated in the output with ``[|\fIproto\fP]'', where \fIproto\fP
is the name of the protocol level at which the truncation has occurred.
@@ -630,7 +624,7 @@ lost.
You should limit \fIsnaplen\fP to the smallest number that will
capture the protocol information you're interested in.
Setting
-\fIsnaplen\fP to 0 sets it to the default of 65535,
+\fIsnaplen\fP to 0 sets it to the default of 262144,
for backwards compatibility with recent older versions of
.IR tcpdump .
.TP
@@ -644,6 +638,7 @@ Currently known types are
\fBlmp\fR (Link Management Protocol),
\fBpgm\fR (Pragmatic General Multicast),
\fBpgm_zmtp1\fR (ZMTP/1.0 inside PGM/EPGM),
+\fBresp\fR (REdis Serialization Protocol),
\fBradius\fR (RADIUS),
\fBrpc\fR (Remote Procedure Call),
\fBrtp\fR (Real-Time Applications protocol),
@@ -1882,11 +1877,15 @@ is the current clock time in the form
.fi
.RE
and is as accurate as the kernel's clock.
-The timestamp reflects the time the kernel first saw the packet.
-No attempt
-is made to account for the time lag between when the
-Ethernet interface removed the packet from the wire and when the kernel
-serviced the `new packet' interrupt.
+The timestamp reflects the time the kernel applied a time stamp to the packet.
+No attempt is made to account for the time lag between when the network
+interface finished receiving the packet from the network and when the
+kernel applied a time stamp to the packet; that time lag could include a
+delay between the time when the network interface finished receiving a
+packet from the network and the time when an interrupt was delivered to
+the kernel to get it to read the packet and a delay between the time
+when the kernel serviced the `new packet' interrupt and the time when it
+applied a time stamp to the packet.
.SH "SEE ALSO"
stty(1), pcap(3PCAP), bpf(4), nit(4P), pcap-savefile(@MAN_FILE_FORMATS@),
pcap-filter(@MAN_MISC_INFO@), pcap-tstamp(@MAN_MISC_INFO@)
diff --git a/contrib/tcpdump/tcpdump.c b/contrib/tcpdump/tcpdump.c
index 2bec0b8..202dce2 100644
--- a/contrib/tcpdump/tcpdump.c
+++ b/contrib/tcpdump/tcpdump.c
@@ -31,10 +31,8 @@ static const char copyright[] _U_ =
The Regents of the University of California. All rights reserved.\n";
#endif
-/* $FreeBSD$ */
-
/*
- * 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
@@ -56,18 +54,12 @@ The Regents of the University of California. All rights reserved.\n";
#endif
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#ifdef WIN32
-#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 USE_LIBSMI
-#include <smi.h>
+#ifdef HAVE_FCNTL_H
+#include <fcntl.h>
#endif
#ifdef HAVE_LIBCRYPTO
@@ -83,32 +75,31 @@ 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/capability.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 <sys/resource.h>
#include <pwd.h>
#include <grp.h>
-#endif /* WIN32 */
+#endif /* _WIN32 */
/* capabilities convenience library */
/* If a code depends on HAVE_LIBCAP_NG, it depends also on HAVE_CAP_NG_H.
@@ -130,6 +121,9 @@ extern int SIZE_BUF;
#include "setsignal.h"
#include "gmt2local.h"
#include "pcap-missing.h"
+#include "ascii_strcasecmp.h"
+
+#include "print.h"
#ifndef PATH_MAX
#define PATH_MAX 1024
@@ -141,19 +135,41 @@ extern int SIZE_BUF;
#define SIGNAL_REQ_INFO SIGUSR1
#endif
-netdissect_options Gndo;
-netdissect_options *gndo = &Gndo;
-
+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 */
-static int dflag; /* print filter code */
+/*
+ * 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.
+ */
+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
-int Qflag = -1; /* restrict captured packet by send/receive direction */
+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;
@@ -164,31 +180,33 @@ char *program_name;
cap_channel_t *capdns;
#endif
-int32_t thiszone; /* seconds offset from gmt to local time */
-
/* 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 print_version(void);
static void print_usage(void);
-static void show_dlts_and_exit(const char *device, pcap_t *pd) __attribute__((noreturn));
+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))
-#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 */
- ;
#ifdef SIGNAL_REQ_INFO
RETSIGTYPE requestinfo(int);
@@ -205,202 +223,7 @@ 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[] = {
- { NULL, 0 },
-};
-
-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
-#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_PFVAR_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 },
-};
-
+#ifdef HAVE_PCAP_FINDALLDEVS
static const struct tok status_flags[] = {
#ifdef PCAP_IF_UP
{ PCAP_IF_UP, "Up" },
@@ -411,57 +234,8 @@ static const struct tok status_flags[] = {
{ PCAP_IF_LOOPBACK, "Loopback" },
{ 0, NULL }
};
-
-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;
-
-#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 = ndo_printers; p->f; ++p)
- if (DLT_PKTAP == p->type)
- return p->f;
- }
#endif
- return NULL;
- /* NOTREACHED */
-}
-
static pcap_t *pd;
static int supports_monitor_mode;
@@ -470,42 +244,127 @@ extern int optind;
extern int opterr;
extern char *optarg;
-struct print_info {
- netdissect_options *ndo;
- union {
- if_printer printer;
- if_ndo_printer ndo_printer;
- } p;
- int ndo_type;
-};
-
struct dump_info {
char *WFileName;
char *CurrentFileName;
pcap_t *pd;
pcap_dumper_t *p;
-#ifdef __FreeBSD__
+#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);
@@ -519,20 +378,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.");
@@ -552,52 +411,49 @@ 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 *devpointer;
+ pcap_if_t *dev, *devlist;
char ebuf[PCAP_ERRBUF_SIZE];
int i;
- if (pcap_findalldevs(&devpointer, ebuf) < 0)
+ if (pcap_findalldevs(&devlist, ebuf) < 0)
error("%s", ebuf);
- else {
- for (i = 0; devpointer != NULL; i++) {
- printf("%d.%s", i+1, devpointer->name);
- if (devpointer->description != NULL)
- printf(" (%s)", devpointer->description);
- if (devpointer->flags != 0)
- printf(" [%s]", bittok2str(status_flags, "none", devpointer->flags));
- printf("\n");
- devpointer = devpointer->next;
- }
+ 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");
}
- exit(0);
+ pcap_freealldevs(devlist);
+ exit_tcpdump(0);
}
#endif /* HAVE_PCAP_FINDALLDEVS */
@@ -612,7 +468,7 @@ show_devices_and_exit (void)
* 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 tospecify that packet comments in pcap-ng files
+ * 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
@@ -635,13 +491,13 @@ show_devices_and_exit (void)
* 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"
@@ -677,7 +533,7 @@ show_devices_and_exit (void)
#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:Rs:StT:u" U_FLAG "vV:w:W:xXy:Yz:Z:#"
+#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.
@@ -704,7 +560,7 @@ show_devices_and_exit (void)
#define OPTION_IMMEDIATE_MODE 130
static const struct option longopts[] = {
-#if defined(HAVE_PCAP_CREATE) || defined(WIN32)
+#if defined(HAVE_PCAP_CREATE) || defined(_WIN32)
{ "buffer-size", required_argument, NULL, 'B' },
#endif
{ "list-interfaces", no_argument, NULL, 'D' },
@@ -736,7 +592,7 @@ static const struct option longopts[] = {
#ifdef HAVE_PCAP_SET_IMMEDIATE_MODE
{ "immediate-mode", no_argument, NULL, OPTION_IMMEDIATE_MODE },
#endif
-#if defined(HAVE_PCAP_DEBUG) || defined(HAVE_YYDEBUG)
+#ifdef HAVE_PCAP_SET_PARSER_DEBUG
{ "debug-filter-parser", no_argument, NULL, 'Y' },
#endif
{ "relinquish-privileges", required_argument, NULL, 'Z' },
@@ -745,7 +601,7 @@ static const struct option longopts[] = {
{ NULL, 0, NULL, 0 }
};
-#ifndef WIN32
+#ifndef _WIN32
/* Drop root privileges and chroot if necessary */
static void
droproot(const char *username, const char *chroot_dir)
@@ -753,36 +609,38 @@ 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_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);
+ {
+ 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);
+ }
}
#else
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);
}
else {
fprintf(stderr, "dropped privs to %s\n", username);
@@ -790,23 +648,24 @@ droproot(const char *username, const char *chroot_dir)
#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 and CAP_SETGID any more. */
+ /* 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)
@@ -856,43 +715,6 @@ MakeFilename(char *buffer, char *orig_name, int cnt, int max_chars)
free(filename);
}
-static int tcpdump_printf(netdissect_options *ndo _U_,
- const char *fmt, ...)
-{
-
- va_list args;
- int ret;
-
- va_start(args, fmt);
- ret=vfprintf(stdout, fmt, args);
- va_end(args);
-
- return ret;
-}
-
-static struct print_info
-get_print_info(int type)
-{
- 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);
- }
- }
- return (printinfo);
-}
-
static char *
get_next_file(FILE *VFile, char *ptr)
{
@@ -967,7 +789,7 @@ tstamp_precision_to_string(int precision)
}
#endif
-#ifdef __FreeBSD__
+#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
@@ -1037,22 +859,321 @@ set_dumper_capsicum_rights(pcap_dumper_t *p)
}
#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);
+ }
+}
+
+static char *
+find_interface_by_number(long devnum)
+{
+ pcap_if_t *dev, *devlist;
+ long i;
+ char ebuf[PCAP_ERRBUF_SIZE];
+ char *device;
+
+ 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
+
+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
+
+#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);
+}
+
int
main(int argc, char **argv)
{
register int cnt, op, i;
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];
@@ -1062,30 +1183,31 @@ 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 __FreeBSD__
+#ifdef HAVE_CAPSICUM
cap_rights_t rights;
-#endif /* !__FreeBSD__ */
int cansandbox;
+#endif /* HAVE_CAPSICUM */
+ int Oflag = 1; /* run filter code optimizer */
+ int yflag_dlt = -1;
+ const char *yflag_dlt_name = NULL;
-#ifdef WIN32
- if(wsockinit() != 0) return 1;
-#endif /* WIN32 */
-
- 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;
- gndo->ndo_immediate = 0;
+ netdissect_options Ndo;
+ netdissect_options *ndo = &Ndo;
+
+ /*
+ * Initialize the netdissect code.
+ */
+ if (nd_init(ebuf, sizeof ebuf) == -1)
+ error("%s", ebuf);
+
+ memset(ndo, 0, sizeof(*ndo));
+ ndo_set_function_pointers(ndo);
+ ndo->ndo_snaplen = DEFAULT_SNAPLEN;
cnt = -1;
device = NULL;
@@ -1096,9 +1218,14 @@ 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,
@@ -1110,10 +1237,6 @@ main(int argc, char **argv)
if (abort_on_misalignment(ebuf, sizeof(ebuf)) < 0)
error("%s", ebuf);
-#ifdef USE_LIBSMI
- smiInit("tcpdump");
-#endif
-
while (
(op = getopt_long(argc, argv, SHORTOPTS, longopts, NULL)) != -1)
switch (op) {
@@ -1123,20 +1246,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);
@@ -1146,7 +1269,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;
@@ -1163,18 +1286,18 @@ main(int argc, char **argv)
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':
@@ -1198,52 +1321,14 @@ main(int argc, char **argv)
case 'h':
print_usage();
- exit(0);
+ 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;
@@ -1266,41 +1351,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 USE_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':
@@ -1308,15 +1391,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':
@@ -1328,17 +1411,17 @@ main(int argc, char **argv)
break;
case 'q':
- ++qflag;
- ++suppress_default_print;
+ ++ndo->ndo_qflag;
+ ++ndo->ndo_suppress_default_print;
break;
#ifdef HAVE_PCAP_SETDIRECTION
case 'Q':
- if (strcasecmp(optarg, "in") == 0)
+ if (ascii_strcasecmp(optarg, "in") == 0)
Qflag = PCAP_D_IN;
- else if (strcasecmp(optarg, "out") == 0)
+ else if (ascii_strcasecmp(optarg, "out") == 0)
Qflag = PCAP_D_OUT;
- else if (strcasecmp(optarg, "inout") == 0)
+ else if (ascii_strcasecmp(optarg, "inout") == 0)
Qflag = PCAP_D_INOUT;
else
error("unknown capture direction `%s'", optarg);
@@ -1349,66 +1432,64 @@ main(int argc, char **argv)
RFileName = optarg;
break;
- case 'R':
- Rflag = 0;
- 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;
- else if (strcasecmp(optarg, "pgm") == 0)
- packettype = PT_PGM;
- else if (strcasecmp(optarg, "pgm_zmtp1") == 0)
- packettype = PT_PGM_ZMTP1;
- else if (strcasecmp(optarg, "lmp") == 0)
- packettype = PT_LMP;
+ 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
@@ -1418,7 +1499,7 @@ main(int argc, char **argv)
#endif
case 'v':
- ++vflag;
+ ++ndo->ndo_vflag;
break;
case 'V':
@@ -1431,77 +1512,71 @@ 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':
- zflag = strdup(optarg);
+ zflag = optarg;
break;
case 'Z':
- username = strdup(optarg);
+ username = optarg;
break;
case '#':
- gndo->ndo_packet_number = 1;
+ ndo->ndo_packet_number = 1;
break;
case OPTION_VERSION:
print_version();
- exit(0);
+ exit_tcpdump(0);
break;
#ifdef HAVE_PCAP_SET_TSTAMP_PRECISION
case OPTION_TSTAMP_PRECISION:
- gndo->ndo_tstamp_precision = tstamp_precision_from_string(optarg);
- if (gndo->ndo_tstamp_precision < 0)
+ 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:
- gndo->ndo_immediate = 1;
+ immediate_mode = 1;
break;
#endif
default:
print_usage();
- exit(1);
+ exit_tcpdump(1);
/* NOTREACHED */
}
@@ -1510,11 +1585,11 @@ main(int argc, char **argv)
show_devices_and_exit();
#endif
- switch (tflag) {
+ switch (ndo->ndo_tflag) {
case 0: /* Default */
case 4: /* Default + Date*/
- thiszone = gmt2local(0);
+ timezone_offset = gmt2local(0);
break;
case 1: /* No time stamp */
@@ -1528,7 +1603,7 @@ 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)
@@ -1542,7 +1617,7 @@ main(int argc, char **argv)
* probably expecting to see packets pop up immediately.
*/
if (WFileName == NULL && isatty(1))
- gndo->ndo_immediate = 1;
+ immediate_mode = 1;
#endif
#ifdef WITH_CHROOT
@@ -1573,7 +1648,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).
@@ -1585,7 +1660,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;
@@ -1593,7 +1668,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)
@@ -1603,14 +1678,14 @@ main(int argc, char **argv)
#ifdef HAVE_PCAP_SET_TSTAMP_PRECISION
pd = pcap_open_offline_with_tstamp_precision(RFileName,
- gndo->ndo_tstamp_precision, ebuf);
+ ndo->ndo_tstamp_precision, ebuf);
#else
pd = pcap_open_offline(RFileName, ebuf);
#endif
if (pd == NULL)
error("%s", ebuf);
-#ifdef HAVE_CASPER
+#ifdef HAVE_CAPSICUM
cap_rights_init(&rights, CAP_READ);
if (cap_rights_limit(fileno(pcap_file(pd)), &rights) < 0 &&
errno != ENOSYS) {
@@ -1633,178 +1708,91 @@ main(int argc, char **argv)
* 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
-#ifdef HAVE_PCAP_SET_TSTAMP_PRECISION
- status = pcap_set_tstamp_precision(pd, gndo->ndo_tstamp_precision);
- if (status != 0)
- error("%s: Can't set %ssecond time stamp precision: %s",
- device,
- tstamp_precision_to_string(gndo->ndo_tstamp_precision),
- pcap_statustostr(status));
-#endif
-#ifdef HAVE_PCAP_SET_IMMEDIATE_MODE
- if (gndo->ndo_immediate) {
- status = pcap_set_immediate_mode(pd, 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?
+ * 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);
-#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\nand use %s as the tcpdump "
- "interface", device, newdev, parent,
- newdev);
+#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);
}
-#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.
+ * 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));
- }
-#ifdef HAVE_PCAP_SETDIRECTION
- if (Qflag != -1) {
- status = pcap_setdirection(pd, Qflag);
- if (status != 0)
- error("%s: pcap_setdirection() failed: %s",
- device, pcap_geterr(pd));
- }
-#endif /* HAVE_PCAP_SETDIRECTION */
-#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
/*
@@ -1812,21 +1800,21 @@ 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 (ndo->ndo_snaplen < i) {
+ warning("snaplen raised from %d to %d", ndo->ndo_snaplen, i);
+ ndo->ndo_snaplen = i;
}
- if(fflag != 0) {
+ if(ndo->ndo_fflag != 0) {
if (pcap_lookupnet(device, &localnet, &netmask, ebuf) < 0) {
warning("foreign (-f) flag used but: %s", ebuf);
}
@@ -1838,38 +1826,41 @@ main(int argc, char **argv)
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);
}
#ifdef HAVE_CASPER
- if (!nflag)
+ if (!ndo->ndo_nflag)
capdns = capdns_setup();
#endif /* HAVE_CASPER */
- init_addrtoname(gndo, localnet, netmask);
- init_checksum();
+ init_print(ndo, localnet, netmask, timezone_offset);
-#ifndef WIN32
+#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,
@@ -1900,6 +1891,13 @@ main(int argc, char **argv)
CAP_SETGID,
-1);
}
+ if (chroot_dir) {
+ capng_update(
+ CAPNG_ADD,
+ CAPNG_PERMITTED | CAPNG_EFFECTIVE,
+ CAP_SYS_CHROOT
+ );
+ }
if (WFileName) {
capng_update(
@@ -1914,13 +1912,13 @@ main(int argc, char **argv)
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 };
+ static const unsigned long cmds[] = { BIOCGSTATS, BIOCROTZBUF };
/*
* The various libpcap devices use a combination of
@@ -1968,12 +1966,16 @@ main(int argc, char **argv)
#endif /* HAVE_LIBCAP_NG */
if (p == NULL)
error("%s", pcap_geterr(pd));
-#ifdef __FreeBSD__
+#ifdef HAVE_CAPSICUM
set_dumper_capsicum_rights(p);
#endif
if (Cflag != 0 || Gflag != 0) {
-#ifdef __FreeBSD__
+#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) {
@@ -1990,7 +1992,7 @@ main(int argc, char **argv)
errno != ENOSYS) {
error("unable to limit dump descriptor fcntls");
}
-#else /* !__FreeBSD__ */
+#else /* !HAVE_CAPSICUM */
dumpinfo.WFileName = WFileName;
#endif
callback = dump_packet_and_trunc;
@@ -2006,10 +2008,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
@@ -2021,10 +2023,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
@@ -2037,14 +2039,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);
@@ -2054,26 +2055,25 @@ 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 __FreeBSD__
+#ifdef HAVE_CAPSICUM
cansandbox = (VFileName == NULL && zflag == NULL);
#ifdef HAVE_CASPER
- cansandbox = (cansandbox && (nflag || capdns != NULL));
+ cansandbox = (cansandbox && (ndo->ndo_nflag || capdns != NULL));
#else
- cansandbox = (cansandbox && nflag);
-#endif
+ cansandbox = (cansandbox && ndo->ndo_nflag);
+#endif /* HAVE_CASPER */
if (cansandbox && cap_enter() < 0 && errno != ENOSYS)
error("unable to enter the capability mode");
-#endif /* __FreeBSD__ */
+#endif /* HAVE_CAPSICUM */
do {
status = pcap_loop(pd, cnt, callback, pcap_userdata);
@@ -2118,11 +2118,13 @@ 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_CASPER
+#ifdef HAVE_CAPSICUM
cap_rights_init(&rights, CAP_READ);
if (cap_rights_limit(fileno(pcap_file(pd)),
&rights) < 0 && errno != ENOSYS) {
@@ -2130,30 +2132,67 @@ main(int argc, char **argv)
}
#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 */
@@ -2193,7 +2232,7 @@ cleanup(int signo _U_)
(void)fflush(stdout);
info(1);
}
- exit(0);
+ exit_tcpdump(0);
#endif
}
@@ -2212,14 +2251,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;
@@ -2234,38 +2273,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);
@@ -2274,15 +2327,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
@@ -2325,7 +2378,7 @@ 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 __FreeBSD__
+#ifdef HAVE_CAPSICUM
FILE *fp;
int fd;
#endif
@@ -2352,7 +2405,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)
@@ -2383,7 +2437,7 @@ dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *s
capng_update(CAPNG_ADD, CAPNG_EFFECTIVE, CAP_DAC_OVERRIDE);
capng_apply(CAPNG_SELECT_BOTH);
#endif /* HAVE_LIBCAP_NG */
-#ifdef __FreeBSD__
+#ifdef HAVE_CAPSICUM
fd = openat(dump_info->dirfd,
dump_info->CurrentFileName,
O_CREAT | O_WRONLY | O_TRUNC, 0644);
@@ -2397,7 +2451,7 @@ dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *s
dump_info->CurrentFileName);
}
dump_info->p = pcap_dump_fopen(dump_info->pd, fp);
-#else /* !__FreeBSD__ */
+#else /* !HAVE_CAPSICUM */
dump_info->p = pcap_dump_open(dump_info->pd, dump_info->CurrentFileName);
#endif
#ifdef HAVE_LIBCAP_NG
@@ -2406,7 +2460,7 @@ dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *s
#endif /* HAVE_LIBCAP_NG */
if (dump_info->p == NULL)
error("%s", pcap_geterr(pd));
-#ifdef __FreeBSD__
+#ifdef HAVE_CAPSICUM
set_dumper_capsicum_rights(dump_info->p);
#endif
}
@@ -2423,7 +2477,7 @@ dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *s
if (size == -1)
error("ftell fails on output file");
if (size > Cflag) {
-#ifdef __FreeBSD__
+#ifdef HAVE_CAPSICUM
FILE *fp;
int fd;
#endif
@@ -2455,7 +2509,7 @@ dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *s
capng_update(CAPNG_ADD, CAPNG_EFFECTIVE, CAP_DAC_OVERRIDE);
capng_apply(CAPNG_SELECT_BOTH);
#endif /* HAVE_LIBCAP_NG */
-#ifdef __FreeBSD__
+#ifdef HAVE_CAPSICUM
fd = openat(dump_info->dirfd, dump_info->CurrentFileName,
O_CREAT | O_WRONLY | O_TRUNC, 0644);
if (fd < 0) {
@@ -2468,7 +2522,7 @@ dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *s
dump_info->CurrentFileName);
}
dump_info->p = pcap_dump_fopen(dump_info->pd, fp);
-#else /* !__FreeBSD__ */
+#else /* !HAVE_CAPSICUM */
dump_info->p = pcap_dump_open(dump_info->pd, dump_info->CurrentFileName);
#endif
#ifdef HAVE_LIBCAP_NG
@@ -2477,7 +2531,7 @@ dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *s
#endif /* HAVE_LIBCAP_NG */
if (dump_info->p == NULL)
error("%s", pcap_geterr(pd));
-#ifdef __FreeBSD__
+#ifdef HAVE_CAPSICUM
set_dumper_capsicum_rights(dump_info->p);
#endif
}
@@ -2515,107 +2569,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;
- netdissect_options *ndo;
-
++packets_captured;
++infodelay;
- print_info = (struct print_info *)user;
- ndo = print_info->ndo;
-
- 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;
-
- if(print_info->ndo_type) {
- hdrlen = (*print_info->p.ndo_printer)(print_info->ndo, h, sp);
- } else {
- hdrlen = (*print_info->p.printer)(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);
- }
- }
-
- 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
@@ -2642,21 +2607,6 @@ print_packet(u_char *user, const struct pcap_pkthdr *h, const u_char *sp)
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, const u_char *bp, u_int length)
-{
- hex_and_ascii_print(ndo, "\n\t", bp, length); /* pass on lf and indentation 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_)
{
@@ -2674,17 +2624,13 @@ 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);
}
@@ -2696,37 +2642,38 @@ print_version(void)
{
extern char version[];
#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
-#ifdef USE_LIBSMI
- (void)fprintf (stderr, "SMI-library: %s\n", smi_version_string);
-#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
@@ -2735,7 +2682,7 @@ 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,
@@ -2756,48 +2703,10 @@ print_usage(void)
#endif
(void)fprintf(stderr, "[ -T type ] [ --version ] [ -V file ]\n");
(void)fprintf(stderr,
-"\t\t[ -w file ] [ -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");
}
-
-
-
-/* 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
diff --git a/contrib/tcpdump/timeval-operations.h b/contrib/tcpdump/timeval-operations.h
new file mode 100644
index 0000000..4f4e85c
--- /dev/null
+++ b/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/contrib/tcpdump/udp.h b/contrib/tcpdump/udp.h
index 743ddfa..409cc59 100644
--- a/contrib/tcpdump/udp.h
+++ b/contrib/tcpdump/udp.h
@@ -44,60 +44,273 @@ struct udphdr {
uint16_t uh_sum; /* udp checksum */
};
-#define BOOTPS_PORT 67 /* RFC951 */
-#define BOOTPC_PORT 68 /* RFC951 */
-#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 RADIUS_COA_PORT 3799
-#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 VAT_PORT 3456
-#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 WB_PORT 4567
-#define SFLOW_PORT 6343 /* http://www.sflow.org/developers/specifications.php */
-#define LWAPP_DATA_PORT 12222 /* RFC 5412 */
-#define LWAPP_CONTROL_PORT 12223 /* RFC 5412 */
-#define OTV_PORT 8472 /* draft-hasmit-otv-04 */
-#define VXLAN_PORT 4789 /* RFC 7348 */
-#define GENEVE_PORT 6081 /* draft-gross-geneve-02 */
-
-#ifdef INET6
-#define RIPNG_PORT 521 /* RFC 2080 */
-#define DHCP6_SERV_PORT 546 /*XXX*/
-#define DHCP6_CLI_PORT 547 /*XXX*/
-#define AHCP_PORT 5359 /* draft-chroboczek-ahcp-00 */
-#define BABEL_PORT 6696 /* RFC 6126 errata */
-#define BABEL_PORT_OLD 6697 /* RFC 6126 */
+#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/contrib/tcpdump/util.c b/contrib/tcpdump/util-print.c
index b37f3d8..5db042a 100644
--- a/contrib/tcpdump/util.c
+++ b/contrib/tcpdump/util-print.c
@@ -35,29 +35,61 @@
* FOR A PARTICULAR PURPOSE.
*/
-#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#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 "interface.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,
@@ -87,9 +119,60 @@ fn_print(netdissect_options *ndo,
}
/*
+ * 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,
@@ -117,6 +200,8 @@ fn_printn(netdissect_options *ndo,
* 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,
@@ -155,9 +240,8 @@ ts_format(netdissect_options *ndo
#ifndef HAVE_PCAP_SET_TSTAMP_PRECISION
_U_
#endif
-, int sec, int usec)
+, int sec, int usec, char *buf)
{
- static char buf[sizeof("00:00:00.000000000")];
const char *format;
#ifdef HAVE_PCAP_SET_TSTAMP_PRECISION
@@ -172,20 +256,57 @@ _U_
break;
default:
- format = "%02d:%02d:%02d.{unknown precision}";
+ format = "%02d:%02d:%02d.{unknown}";
break;
}
#else
format = "%02d:%02d:%02d.%06u";
#endif
- snprintf(buf, sizeof(buf), format,
+ 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
@@ -195,52 +316,63 @@ ts_print(netdissect_options *ndo,
register int s;
struct tm *tm;
time_t Time;
- static unsigned b_sec;
- static unsigned b_usec;
- int d_usec;
- int d_sec;
+ 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)));
+ 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, "%u.%06u ",
- (unsigned)tvp->tv_sec,
- (unsigned)tvp->tv_usec));
+ ND_PRINT((ndo, "%s ", ts_unix_format(ndo,
+ tvp->tv_sec, tvp->tv_usec, buf)));
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;
- }
+ 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 */
- d_usec = tvp->tv_usec - b_usec;
- d_sec = tvp->tv_sec - b_sec;
+ 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);
- while (d_usec < 0) {
- d_usec += 1000000;
- d_sec--;
- }
+ ND_PRINT((ndo, (negative_offset ? "-" : " ")));
- ND_PRINT((ndo, "%s ", ts_format(ndo, d_sec, d_usec)));
+ ND_PRINT((ndo, "%s ", ts_format(ndo,
+ tv_result.tv_sec, tv_result.tv_usec, buf)));
- if (ndo->ndo_tflag == 3) { /* set timestamp for last packet */
- b_sec = tvp->tv_sec;
- b_usec = tvp->tv_usec;
- }
+ if (ndo->ndo_tflag == 3)
+ tv_ref = *tvp; /* set timestamp for previous packet */
break;
- case 4: /* Default + Date*/
+ case 4: /* Default + Date */
s = (tvp->tv_sec + thiszone) % 86400;
Time = (tvp->tv_sec + thiszone) - s;
tm = gmtime (&Time);
@@ -249,33 +381,29 @@ ts_print(netdissect_options *ndo,
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)));
+ ts_format(ndo, s, tvp->tv_usec, buf)));
break;
}
}
/*
- * Print a relative number of seconds (e.g. hold time, prune timer)
+ * 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
-relts_print(netdissect_options *ndo,
- int secs)
+unsigned_relts_print(netdissect_options *ndo,
+ uint32_t secs)
{
static const char *lengths[] = {"y", "w", "d", "h", "m", "s"};
- static const int seconds[] = {31536000, 604800, 86400, 3600, 60, 1};
+ static const u_int seconds[] = {31536000, 604800, 86400, 3600, 60, 1};
const char **l = lengths;
- const int *s = seconds;
+ const u_int *s = seconds;
if (secs == 0) {
ND_PRINT((ndo, "0s"));
return;
}
- if (secs < 0) {
- ND_PRINT((ndo, "-"));
- secs = -secs;
- }
while (secs > 0) {
if (secs >= *s) {
ND_PRINT((ndo, "%d%s", secs / *s, *l));
@@ -287,6 +415,42 @@ relts_print(netdissect_options *ndo,
}
/*
+ * 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
@@ -339,7 +503,7 @@ const char *
tok2str(register const struct tok *lp, register const char *fmt,
register u_int v)
{
- static char buf[4][128];
+ static char buf[4][TOKBUFSIZE];
static int idx = 0;
char *ret;
@@ -413,7 +577,7 @@ bittok2str(register const struct tok *lp, register const char *fmt,
/*
* Convert a value to a string using an array; the macro
- * tok2strary() in <interface.h> is the public interface to
+ * tok2strary() in <netdissect.h> is the public interface to
* this function and ensures that the second argument is
* correct for bounds-checking.
*/
@@ -421,7 +585,7 @@ const char *
tok2strary_internal(register const char **lp, int n, register const char *fmt,
register int v)
{
- static char buf[128];
+ static char buf[TOKBUFSIZE];
if (v >= 0 && v < n && lp[v] != NULL)
return lp[v];
@@ -462,7 +626,6 @@ mask2plen(uint32_t mask)
return (prefix_len);
}
-#ifdef INET6
int
mask62plen(const u_char *mask)
{
@@ -489,7 +652,6 @@ mask62plen(const u_char *mask)
}
return (cidr_len);
}
-#endif /* INET6 */
/*
* Routine to print out information for text-based protocols such as FTP,
@@ -663,7 +825,7 @@ txtproto_print(netdissect_options *ndo, const u_char *pptr, u_int len,
if (idx != 0) {
/* Is this a valid request name? */
while ((cmd = *cmds++) != NULL) {
- if (strcasecmp((const char *)token, cmd) == 0) {
+ if (ascii_strcasecmp((const char *)token, cmd) == 0) {
/* Yes. */
is_reqresp = 1;
break;
@@ -703,7 +865,7 @@ txtproto_print(netdissect_options *ndo, const u_char *pptr, u_int len,
/* Capitalize the protocol name */
for (pnp = protoname; *pnp != '\0'; pnp++)
- ND_PRINT((ndo, "%c", toupper(*pnp)));
+ ND_PRINT((ndo, "%c", toupper((u_char)*pnp)));
if (is_reqresp) {
/*
@@ -734,121 +896,6 @@ txtproto_print(netdissect_options *ndo, const u_char *pptr, u_int len,
}
}
-/* 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(netdissect_options *ndo,
const u_char *s, const u_int maxlen)
@@ -888,3 +935,4 @@ unaligned_memcmp(const void *p, const void *q, size_t l)
return (memcmp(p, q, l));
}
#endif
+
diff --git a/contrib/tcpdump/vfprintf.c b/contrib/tcpdump/vfprintf.c
index 6f3e15f..ae28bcf 100644
--- a/contrib/tcpdump/vfprintf.c
+++ b/contrib/tcpdump/vfprintf.c
@@ -30,7 +30,7 @@
#include <stdlib.h>
#include <unistd.h>
-#include "interface.h"
+#include "netdissect.h"
/*
* Stock 4.3 doesn't have vfprintf.
diff --git a/contrib/zlib/ChangeLog b/contrib/zlib/ChangeLog
index f22aaba..30199a6 100644
--- a/contrib/zlib/ChangeLog
+++ b/contrib/zlib/ChangeLog
@@ -1,10 +1,53 @@
ChangeLog file for zlib
+Changes in 1.2.11 (15 Jan 2017)
+- Fix deflate stored bug when pulling last block from window
+- Permit immediate deflateParams changes before any deflate input
+
+Changes in 1.2.10 (2 Jan 2017)
+- Avoid warnings on snprintf() return value
+- Fix bug in deflate_stored() for zero-length input
+- Fix bug in gzwrite.c that produced corrupt gzip files
+- Remove files to be installed before copying them in Makefile.in
+- Add warnings when compiling with assembler code
+
+Changes in 1.2.9 (31 Dec 2016)
+- Fix contrib/minizip to permit unzipping with desktop API [Zouzou]
+- Improve contrib/blast to return unused bytes
+- Assure that gzoffset() is correct when appending
+- Improve compress() and uncompress() to support large lengths
+- Fix bug in test/example.c where error code not saved
+- Remedy Coverity warning [Randers-Pehrson]
+- Improve speed of gzprintf() in transparent mode
+- Fix inflateInit2() bug when windowBits is 16 or 32
+- Change DEBUG macro to ZLIB_DEBUG
+- Avoid uninitialized access by gzclose_w()
+- Allow building zlib outside of the source directory
+- Fix bug that accepted invalid zlib header when windowBits is zero
+- Fix gzseek() problem on MinGW due to buggy _lseeki64 there
+- Loop on write() calls in gzwrite.c in case of non-blocking I/O
+- Add --warn (-w) option to ./configure for more compiler warnings
+- Reject a window size of 256 bytes if not using the zlib wrapper
+- Fix bug when level 0 used with Z_HUFFMAN or Z_RLE
+- Add --debug (-d) option to ./configure to define ZLIB_DEBUG
+- Fix bugs in creating a very large gzip header
+- Add uncompress2() function, which returns the input size used
+- Assure that deflateParams() will not switch functions mid-block
+- Dramatically speed up deflation for level 0 (storing)
+- Add gzfread(), duplicating the interface of fread()
+- Add gzfwrite(), duplicating the interface of fwrite()
+- Add deflateGetDictionary() function
+- Use snprintf() for later versions of Microsoft C
+- Fix *Init macros to use z_ prefix when requested
+- Replace as400 with os400 for OS/400 support [Monnerat]
+- Add crc32_z() and adler32_z() functions with size_t lengths
+- Update Visual Studio project files [AraHaan]
+
Changes in 1.2.8 (28 Apr 2013)
- Update contrib/minizip/iowin32.c for Windows RT [Vollant]
- Do not force Z_CONST for C++
-- Clean up contrib/vstudio [Ro]
+- Clean up contrib/vstudio [Roß]
- Correct spelling error in zlib.h
- Fix mixed line endings in contrib/vstudio
@@ -34,7 +77,7 @@ Changes in 1.2.7.1 (24 Mar 2013)
- Clean up the usage of z_const and respect const usage within zlib
- Clean up examples/gzlog.[ch] comparisons of different types
- Avoid shift equal to bits in type (caused endless loop)
-- Fix unintialized value bug in gzputc() introduced by const patches
+- Fix uninitialized value bug in gzputc() introduced by const patches
- Fix memory allocation error in examples/zran.c [Nor]
- Fix bug where gzopen(), gzclose() would write an empty file
- Fix bug in gzclose() when gzwrite() runs out of memory
@@ -194,7 +237,7 @@ Changes in 1.2.5.2 (17 Dec 2011)
- Add a transparent write mode to gzopen() when 'T' is in the mode
- Update python link in zlib man page
- Get inffixed.h and MAKEFIXED result to match
-- Add a ./config --solo option to make zlib subset with no libary use
+- Add a ./config --solo option to make zlib subset with no library use
- Add undocumented inflateResetKeep() function for CAB file decoding
- Add --cover option to ./configure for gcc coverage testing
- Add #define ZLIB_CONST option to use const in the z_stream interface
@@ -564,7 +607,7 @@ Changes in 1.2.3.1 (16 August 2006)
- Update make_vms.com [Zinser]
- Use -fPIC for shared build in configure [Teredesai, Nicholson]
- Use only major version number for libz.so on IRIX and OSF1 [Reinholdtsen]
-- Use fdopen() (not _fdopen()) for Interix in zutil.h [Bck]
+- Use fdopen() (not _fdopen()) for Interix in zutil.h [Bäck]
- Add some FAQ entries about the contrib directory
- Update the MVS question in the FAQ
- Avoid extraneous reads after EOF in gzio.c [Brown]
@@ -1178,7 +1221,7 @@ Changes in 1.0.6 (19 Jan 1998)
386 asm code replacing longest_match().
contrib/iostream/ by Kevin Ruland <kevin@rodin.wustl.edu>
A C++ I/O streams interface to the zlib gz* functions
- contrib/iostream2/ by Tyge Lvset <Tyge.Lovset@cmr.no>
+ contrib/iostream2/ by Tyge Løvset <Tyge.Lovset@cmr.no>
Another C++ I/O streams interface
contrib/untgz/ by "Pedro A. Aranda Guti\irrez" <paag@tid.es>
A very simple tar.gz file extractor using zlib
@@ -1267,7 +1310,7 @@ Changes in 1.0.1 (20 May 96) [1.0 skipped to avoid confusion]
- fix array overlay in deflate.c which sometimes caused bad compressed data
- fix inflate bug with empty stored block
- fix MSDOS medium model which was broken in 0.99
-- fix deflateParams() which could generated bad compressed data.
+- fix deflateParams() which could generate bad compressed data.
- Bytef is define'd instead of typedef'ed (work around Borland bug)
- added an INDEX file
- new makefiles for DJGPP (Makefile.dj2), 32-bit Borland (Makefile.b32),
diff --git a/contrib/zlib/README b/contrib/zlib/README
index 5ca9d12..51106de 100644
--- a/contrib/zlib/README
+++ b/contrib/zlib/README
@@ -1,6 +1,6 @@
ZLIB DATA COMPRESSION LIBRARY
-zlib 1.2.8 is a general purpose data compression library. All the code is
+zlib 1.2.11 is a general purpose data compression library. All the code is
thread safe. The data format used by the zlib library is described by RFCs
(Request for Comments) 1950 to 1952 in the files
http://tools.ietf.org/html/rfc1950 (zlib format), rfc1951 (deflate format) and
@@ -31,7 +31,7 @@ Mark Nelson <markn@ieee.org> wrote an article about zlib for the Jan. 1997
issue of Dr. Dobb's Journal; a copy of the article is available at
http://marknelson.us/1997/01/01/zlib-engine/ .
-The changes made in version 1.2.8 are documented in the file ChangeLog.
+The changes made in version 1.2.11 are documented in the file ChangeLog.
Unsupported third party contributions are provided in directory contrib/ .
@@ -84,7 +84,7 @@ Acknowledgments:
Copyright notice:
- (C) 1995-2013 Jean-loup Gailly and Mark Adler
+ (C) 1995-2017 Jean-loup Gailly and Mark Adler
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
diff --git a/contrib/zlib/adler32.c b/contrib/zlib/adler32.c
index a868f07..d0be438 100644
--- a/contrib/zlib/adler32.c
+++ b/contrib/zlib/adler32.c
@@ -1,5 +1,5 @@
/* adler32.c -- compute the Adler-32 checksum of a data stream
- * Copyright (C) 1995-2011 Mark Adler
+ * Copyright (C) 1995-2011, 2016 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -7,11 +7,9 @@
#include "zutil.h"
-#define local static
-
local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2));
-#define BASE 65521 /* largest prime smaller than 65536 */
+#define BASE 65521U /* largest prime smaller than 65536 */
#define NMAX 5552
/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
@@ -62,10 +60,10 @@ local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2));
#endif
/* ========================================================================= */
-uLong ZEXPORT adler32(adler, buf, len)
+uLong ZEXPORT adler32_z(adler, buf, len)
uLong adler;
const Bytef *buf;
- uInt len;
+ z_size_t len;
{
unsigned long sum2;
unsigned n;
@@ -133,6 +131,15 @@ uLong ZEXPORT adler32(adler, buf, len)
}
/* ========================================================================= */
+uLong ZEXPORT adler32(adler, buf, len)
+ uLong adler;
+ const Bytef *buf;
+ uInt len;
+{
+ return adler32_z(adler, buf, len);
+}
+
+/* ========================================================================= */
local uLong adler32_combine_(adler1, adler2, len2)
uLong adler1;
uLong adler2;
@@ -156,7 +163,7 @@ local uLong adler32_combine_(adler1, adler2, len2)
sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem;
if (sum1 >= BASE) sum1 -= BASE;
if (sum1 >= BASE) sum1 -= BASE;
- if (sum2 >= (BASE << 1)) sum2 -= (BASE << 1);
+ if (sum2 >= ((unsigned long)BASE << 1)) sum2 -= ((unsigned long)BASE << 1);
if (sum2 >= BASE) sum2 -= BASE;
return sum1 | (sum2 << 16);
}
diff --git a/contrib/zlib/compress.c b/contrib/zlib/compress.c
index 6e97626..e2db404 100644
--- a/contrib/zlib/compress.c
+++ b/contrib/zlib/compress.c
@@ -1,5 +1,5 @@
/* compress.c -- compress a memory buffer
- * Copyright (C) 1995-2005 Jean-loup Gailly.
+ * Copyright (C) 1995-2005, 2014, 2016 Jean-loup Gailly, Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -28,16 +28,11 @@ int ZEXPORT compress2 (dest, destLen, source, sourceLen, level)
{
z_stream stream;
int err;
+ const uInt max = (uInt)-1;
+ uLong left;
- stream.next_in = (z_const Bytef *)source;
- stream.avail_in = (uInt)sourceLen;
-#ifdef MAXSEG_64K
- /* Check for source > 64K on 16-bit machine: */
- if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;
-#endif
- stream.next_out = dest;
- stream.avail_out = (uInt)*destLen;
- if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;
+ left = *destLen;
+ *destLen = 0;
stream.zalloc = (alloc_func)0;
stream.zfree = (free_func)0;
@@ -46,15 +41,26 @@ int ZEXPORT compress2 (dest, destLen, source, sourceLen, level)
err = deflateInit(&stream, level);
if (err != Z_OK) return err;
- err = deflate(&stream, Z_FINISH);
- if (err != Z_STREAM_END) {
- deflateEnd(&stream);
- return err == Z_OK ? Z_BUF_ERROR : err;
- }
- *destLen = stream.total_out;
+ stream.next_out = dest;
+ stream.avail_out = 0;
+ stream.next_in = (z_const Bytef *)source;
+ stream.avail_in = 0;
+
+ do {
+ if (stream.avail_out == 0) {
+ stream.avail_out = left > (uLong)max ? max : (uInt)left;
+ left -= stream.avail_out;
+ }
+ if (stream.avail_in == 0) {
+ stream.avail_in = sourceLen > (uLong)max ? max : (uInt)sourceLen;
+ sourceLen -= stream.avail_in;
+ }
+ err = deflate(&stream, sourceLen ? Z_NO_FLUSH : Z_FINISH);
+ } while (err == Z_OK);
- err = deflateEnd(&stream);
- return err;
+ *destLen = stream.total_out;
+ deflateEnd(&stream);
+ return err == Z_STREAM_END ? Z_OK : err;
}
/* ===========================================================================
diff --git a/contrib/zlib/contrib/README.contrib b/contrib/zlib/contrib/README.contrib
index c66349b..a411d5c 100644
--- a/contrib/zlib/contrib/README.contrib
+++ b/contrib/zlib/contrib/README.contrib
@@ -38,7 +38,7 @@ inflate86/ by Chris Anderson <christop@charm.net>
iostream/ by Kevin Ruland <kevin@rodin.wustl.edu>
A C++ I/O streams interface to the zlib gz* functions
-iostream2/ by Tyge Lvset <Tyge.Lovset@cmr.no>
+iostream2/ by Tyge Løvset <Tyge.Lovset@cmr.no>
Another C++ I/O streams interface
iostream3/ by Ludwig Schwardt <schwardt@sun.ac.za>
@@ -58,7 +58,7 @@ masmx86/ by Gilles Vollant <info@winimage.com>
minizip/ by Gilles Vollant <info@winimage.com>
Mini zip and unzip based on zlib
Includes Zip64 support by Mathias Svensson <mathias@result42.com>
- See http://www.winimage.com/zLibDll/unzip.html
+ See http://www.winimage.com/zLibDll/minizip.html
pascal/ by Bob Dellaca <bobdl@xtra.co.nz> et al.
Support for Pascal
diff --git a/contrib/zlib/crc32.c b/contrib/zlib/crc32.c
index 979a719..9580440 100644
--- a/contrib/zlib/crc32.c
+++ b/contrib/zlib/crc32.c
@@ -1,5 +1,5 @@
/* crc32.c -- compute the CRC-32 of a data stream
- * Copyright (C) 1995-2006, 2010, 2011, 2012 Mark Adler
+ * Copyright (C) 1995-2006, 2010, 2011, 2012, 2016 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*
* Thanks to Rodney Brown <rbrown64@csc.com.au> for his contribution of faster
@@ -30,17 +30,15 @@
#include "zutil.h" /* for STDC and FAR definitions */
-#define local static
-
/* Definitions for doing the crc four data bytes at a time. */
#if !defined(NOBYFOUR) && defined(Z_U4)
# define BYFOUR
#endif
#ifdef BYFOUR
local unsigned long crc32_little OF((unsigned long,
- const unsigned char FAR *, unsigned));
+ const unsigned char FAR *, z_size_t));
local unsigned long crc32_big OF((unsigned long,
- const unsigned char FAR *, unsigned));
+ const unsigned char FAR *, z_size_t));
# define TBLS 8
#else
# define TBLS 1
@@ -201,10 +199,10 @@ const z_crc_t FAR * ZEXPORT get_crc_table()
#define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1
/* ========================================================================= */
-unsigned long ZEXPORT crc32(crc, buf, len)
+unsigned long ZEXPORT crc32_z(crc, buf, len)
unsigned long crc;
const unsigned char FAR *buf;
- uInt len;
+ z_size_t len;
{
if (buf == Z_NULL) return 0UL;
@@ -235,8 +233,29 @@ unsigned long ZEXPORT crc32(crc, buf, len)
return crc ^ 0xffffffffUL;
}
+/* ========================================================================= */
+unsigned long ZEXPORT crc32(crc, buf, len)
+ unsigned long crc;
+ const unsigned char FAR *buf;
+ uInt len;
+{
+ return crc32_z(crc, buf, len);
+}
+
#ifdef BYFOUR
+/*
+ This BYFOUR code accesses the passed unsigned char * buffer with a 32-bit
+ integer pointer type. This violates the strict aliasing rule, where a
+ compiler can assume, for optimization purposes, that two pointers to
+ fundamentally different types won't ever point to the same memory. This can
+ manifest as a problem only if one of the pointers is written to. This code
+ only reads from those pointers. So long as this code remains isolated in
+ this compilation unit, there won't be a problem. For this reason, this code
+ should not be copied and pasted into a compilation unit in which other code
+ writes to the buffer that is passed to these routines.
+ */
+
/* ========================================================================= */
#define DOLIT4 c ^= *buf4++; \
c = crc_table[3][c & 0xff] ^ crc_table[2][(c >> 8) & 0xff] ^ \
@@ -247,7 +266,7 @@ unsigned long ZEXPORT crc32(crc, buf, len)
local unsigned long crc32_little(crc, buf, len)
unsigned long crc;
const unsigned char FAR *buf;
- unsigned len;
+ z_size_t len;
{
register z_crc_t c;
register const z_crc_t FAR *buf4;
@@ -278,7 +297,7 @@ local unsigned long crc32_little(crc, buf, len)
}
/* ========================================================================= */
-#define DOBIG4 c ^= *++buf4; \
+#define DOBIG4 c ^= *buf4++; \
c = crc_table[4][c & 0xff] ^ crc_table[5][(c >> 8) & 0xff] ^ \
crc_table[6][(c >> 16) & 0xff] ^ crc_table[7][c >> 24]
#define DOBIG32 DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4
@@ -287,7 +306,7 @@ local unsigned long crc32_little(crc, buf, len)
local unsigned long crc32_big(crc, buf, len)
unsigned long crc;
const unsigned char FAR *buf;
- unsigned len;
+ z_size_t len;
{
register z_crc_t c;
register const z_crc_t FAR *buf4;
@@ -300,7 +319,6 @@ local unsigned long crc32_big(crc, buf, len)
}
buf4 = (const z_crc_t FAR *)(const void FAR *)buf;
- buf4--;
while (len >= 32) {
DOBIG32;
len -= 32;
@@ -309,7 +327,6 @@ local unsigned long crc32_big(crc, buf, len)
DOBIG4;
len -= 4;
}
- buf4++;
buf = (const unsigned char FAR *)buf4;
if (len) do {
diff --git a/contrib/zlib/deflate.c b/contrib/zlib/deflate.c
index 6969577..1ec7614 100644
--- a/contrib/zlib/deflate.c
+++ b/contrib/zlib/deflate.c
@@ -1,5 +1,5 @@
/* deflate.c -- compress data using the deflation algorithm
- * Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler
+ * Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -52,7 +52,7 @@
#include "deflate.h"
const char deflate_copyright[] =
- " deflate 1.2.8 Copyright 1995-2013 Jean-loup Gailly and Mark Adler ";
+ " deflate 1.2.11 Copyright 1995-2017 Jean-loup Gailly and Mark Adler ";
/*
If you use the zlib library in a product, an acknowledgment is welcome
in the documentation of your product. If for some reason you cannot
@@ -73,6 +73,8 @@ typedef enum {
typedef block_state (*compress_func) OF((deflate_state *s, int flush));
/* Compression function. Returns the block state after the call. */
+local int deflateStateCheck OF((z_streamp strm));
+local void slide_hash OF((deflate_state *s));
local void fill_window OF((deflate_state *s));
local block_state deflate_stored OF((deflate_state *s, int flush));
local block_state deflate_fast OF((deflate_state *s, int flush));
@@ -84,15 +86,16 @@ local block_state deflate_huff OF((deflate_state *s, int flush));
local void lm_init OF((deflate_state *s));
local void putShortMSB OF((deflate_state *s, uInt b));
local void flush_pending OF((z_streamp strm));
-local int read_buf OF((z_streamp strm, Bytef *buf, unsigned size));
+local unsigned read_buf OF((z_streamp strm, Bytef *buf, unsigned size));
#ifdef ASMV
+# pragma message("Assembler code may have bugs -- use at your own risk")
void match_init OF((void)); /* asm code initialization */
uInt longest_match OF((deflate_state *s, IPos cur_match));
#else
local uInt longest_match OF((deflate_state *s, IPos cur_match));
#endif
-#ifdef DEBUG
+#ifdef ZLIB_DEBUG
local void check_match OF((deflate_state *s, IPos start, IPos match,
int length));
#endif
@@ -148,21 +151,14 @@ local const config configuration_table[10] = {
* meaning.
*/
-#define EQUAL 0
-/* result of memcmp for equal strings */
-
-#ifndef NO_DUMMY_DECL
-struct static_tree_desc_s {int dummy;}; /* for buggy compilers */
-#endif
-
/* rank Z_BLOCK between Z_NO_FLUSH and Z_PARTIAL_FLUSH */
-#define RANK(f) (((f) << 1) - ((f) > 4 ? 9 : 0))
+#define RANK(f) (((f) * 2) - ((f) > 4 ? 9 : 0))
/* ===========================================================================
* Update a hash value with the given input byte
- * IN assertion: all calls to to UPDATE_HASH are made with consecutive
- * input characters, so that a running hash key can be computed from the
- * previous key instead of complete recalculation each time.
+ * IN assertion: all calls to UPDATE_HASH are made with consecutive input
+ * characters, so that a running hash key can be computed from the previous
+ * key instead of complete recalculation each time.
*/
#define UPDATE_HASH(s,h,c) (h = (((h)<<s->hash_shift) ^ (c)) & s->hash_mask)
@@ -173,9 +169,9 @@ struct static_tree_desc_s {int dummy;}; /* for buggy compilers */
* the previous length of the hash chain.
* If this file is compiled with -DFASTEST, the compression level is forced
* to 1, and no hash chains are maintained.
- * IN assertion: all calls to to INSERT_STRING are made with consecutive
- * input characters and the first MIN_MATCH bytes of str are valid
- * (except for the last MIN_MATCH-1 bytes of the input file).
+ * IN assertion: all calls to INSERT_STRING are made with consecutive input
+ * characters and the first MIN_MATCH bytes of str are valid (except for
+ * the last MIN_MATCH-1 bytes of the input file).
*/
#ifdef FASTEST
#define INSERT_STRING(s, str, match_head) \
@@ -197,6 +193,37 @@ struct static_tree_desc_s {int dummy;}; /* for buggy compilers */
s->head[s->hash_size-1] = NIL; \
zmemzero((Bytef *)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head));
+/* ===========================================================================
+ * Slide the hash table when sliding the window down (could be avoided with 32
+ * bit values at the expense of memory usage). We slide even when level == 0 to
+ * keep the hash table consistent if we switch back to level > 0 later.
+ */
+local void slide_hash(s)
+ deflate_state *s;
+{
+ unsigned n, m;
+ Posf *p;
+ uInt wsize = s->w_size;
+
+ n = s->hash_size;
+ p = &s->head[n];
+ do {
+ m = *--p;
+ *p = (Pos)(m >= wsize ? m - wsize : NIL);
+ } while (--n);
+ n = wsize;
+#ifndef FASTEST
+ p = &s->prev[n];
+ do {
+ m = *--p;
+ *p = (Pos)(m >= wsize ? m - wsize : NIL);
+ /* If n is not on any hash chain, prev[n] is garbage but
+ * its value will never be used.
+ */
+ } while (--n);
+#endif
+}
+
/* ========================================================================= */
int ZEXPORT deflateInit_(strm, level, version, stream_size)
z_streamp strm;
@@ -270,7 +297,7 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
#endif
if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != Z_DEFLATED ||
windowBits < 8 || windowBits > 15 || level < 0 || level > 9 ||
- strategy < 0 || strategy > Z_FIXED) {
+ strategy < 0 || strategy > Z_FIXED || (windowBits == 8 && wrap != 1)) {
return Z_STREAM_ERROR;
}
if (windowBits == 8) windowBits = 9; /* until 256-byte window bug fixed */
@@ -278,14 +305,15 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
if (s == Z_NULL) return Z_MEM_ERROR;
strm->state = (struct internal_state FAR *)s;
s->strm = strm;
+ s->status = INIT_STATE; /* to pass state test in deflateReset() */
s->wrap = wrap;
s->gzhead = Z_NULL;
- s->w_bits = windowBits;
+ s->w_bits = (uInt)windowBits;
s->w_size = 1 << s->w_bits;
s->w_mask = s->w_size - 1;
- s->hash_bits = memLevel + 7;
+ s->hash_bits = (uInt)memLevel + 7;
s->hash_size = 1 << s->hash_bits;
s->hash_mask = s->hash_size - 1;
s->hash_shift = ((s->hash_bits+MIN_MATCH-1)/MIN_MATCH);
@@ -319,6 +347,31 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
return deflateReset(strm);
}
+/* =========================================================================
+ * Check for a valid deflate stream state. Return 0 if ok, 1 if not.
+ */
+local int deflateStateCheck (strm)
+ z_streamp strm;
+{
+ deflate_state *s;
+ if (strm == Z_NULL ||
+ strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0)
+ return 1;
+ s = strm->state;
+ if (s == Z_NULL || s->strm != strm || (s->status != INIT_STATE &&
+#ifdef GZIP
+ s->status != GZIP_STATE &&
+#endif
+ s->status != EXTRA_STATE &&
+ s->status != NAME_STATE &&
+ s->status != COMMENT_STATE &&
+ s->status != HCRC_STATE &&
+ s->status != BUSY_STATE &&
+ s->status != FINISH_STATE))
+ return 1;
+ return 0;
+}
+
/* ========================================================================= */
int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength)
z_streamp strm;
@@ -331,7 +384,7 @@ int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength)
unsigned avail;
z_const unsigned char *next;
- if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL)
+ if (deflateStateCheck(strm) || dictionary == Z_NULL)
return Z_STREAM_ERROR;
s = strm->state;
wrap = s->wrap;
@@ -389,13 +442,34 @@ int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength)
}
/* ========================================================================= */
+int ZEXPORT deflateGetDictionary (strm, dictionary, dictLength)
+ z_streamp strm;
+ Bytef *dictionary;
+ uInt *dictLength;
+{
+ deflate_state *s;
+ uInt len;
+
+ if (deflateStateCheck(strm))
+ return Z_STREAM_ERROR;
+ s = strm->state;
+ len = s->strstart + s->lookahead;
+ if (len > s->w_size)
+ len = s->w_size;
+ if (dictionary != Z_NULL && len)
+ zmemcpy(dictionary, s->window + s->strstart + s->lookahead - len, len);
+ if (dictLength != Z_NULL)
+ *dictLength = len;
+ return Z_OK;
+}
+
+/* ========================================================================= */
int ZEXPORT deflateResetKeep (strm)
z_streamp strm;
{
deflate_state *s;
- if (strm == Z_NULL || strm->state == Z_NULL ||
- strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) {
+ if (deflateStateCheck(strm)) {
return Z_STREAM_ERROR;
}
@@ -410,7 +484,11 @@ int ZEXPORT deflateResetKeep (strm)
if (s->wrap < 0) {
s->wrap = -s->wrap; /* was made negative by deflate(..., Z_FINISH); */
}
- s->status = s->wrap ? INIT_STATE : BUSY_STATE;
+ s->status =
+#ifdef GZIP
+ s->wrap == 2 ? GZIP_STATE :
+#endif
+ s->wrap ? INIT_STATE : BUSY_STATE;
strm->adler =
#ifdef GZIP
s->wrap == 2 ? crc32(0L, Z_NULL, 0) :
@@ -440,8 +518,8 @@ int ZEXPORT deflateSetHeader (strm, head)
z_streamp strm;
gz_headerp head;
{
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
- if (strm->state->wrap != 2) return Z_STREAM_ERROR;
+ if (deflateStateCheck(strm) || strm->state->wrap != 2)
+ return Z_STREAM_ERROR;
strm->state->gzhead = head;
return Z_OK;
}
@@ -452,7 +530,7 @@ int ZEXPORT deflatePending (strm, pending, bits)
int *bits;
z_streamp strm;
{
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
+ if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
if (pending != Z_NULL)
*pending = strm->state->pending;
if (bits != Z_NULL)
@@ -469,7 +547,7 @@ int ZEXPORT deflatePrime (strm, bits, value)
deflate_state *s;
int put;
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
+ if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
s = strm->state;
if ((Bytef *)(s->d_buf) < s->pending_out + ((Buf_size + 7) >> 3))
return Z_BUF_ERROR;
@@ -494,9 +572,8 @@ int ZEXPORT deflateParams(strm, level, strategy)
{
deflate_state *s;
compress_func func;
- int err = Z_OK;
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
+ if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
s = strm->state;
#ifdef FASTEST
@@ -510,13 +587,22 @@ int ZEXPORT deflateParams(strm, level, strategy)
func = configuration_table[s->level].func;
if ((strategy != s->strategy || func != configuration_table[level].func) &&
- strm->total_in != 0) {
+ s->high_water) {
/* Flush the last buffer: */
- err = deflate(strm, Z_BLOCK);
- if (err == Z_BUF_ERROR && s->pending == 0)
- err = Z_OK;
+ int err = deflate(strm, Z_BLOCK);
+ if (err == Z_STREAM_ERROR)
+ return err;
+ if (strm->avail_out == 0)
+ return Z_BUF_ERROR;
}
if (s->level != level) {
+ if (s->level == 0 && s->matches != 0) {
+ if (s->matches == 1)
+ slide_hash(s);
+ else
+ CLEAR_HASH(s);
+ s->matches = 0;
+ }
s->level = level;
s->max_lazy_match = configuration_table[level].max_lazy;
s->good_match = configuration_table[level].good_length;
@@ -524,7 +610,7 @@ int ZEXPORT deflateParams(strm, level, strategy)
s->max_chain_length = configuration_table[level].max_chain;
}
s->strategy = strategy;
- return err;
+ return Z_OK;
}
/* ========================================================================= */
@@ -537,12 +623,12 @@ int ZEXPORT deflateTune(strm, good_length, max_lazy, nice_length, max_chain)
{
deflate_state *s;
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
+ if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
s = strm->state;
- s->good_match = good_length;
- s->max_lazy_match = max_lazy;
+ s->good_match = (uInt)good_length;
+ s->max_lazy_match = (uInt)max_lazy;
s->nice_match = nice_length;
- s->max_chain_length = max_chain;
+ s->max_chain_length = (uInt)max_chain;
return Z_OK;
}
@@ -569,14 +655,13 @@ uLong ZEXPORT deflateBound(strm, sourceLen)
{
deflate_state *s;
uLong complen, wraplen;
- Bytef *str;
/* conservative upper bound for compressed data */
complen = sourceLen +
((sourceLen + 7) >> 3) + ((sourceLen + 63) >> 6) + 5;
/* if can't get parameters, return conservative bound plus zlib wrapper */
- if (strm == Z_NULL || strm->state == Z_NULL)
+ if (deflateStateCheck(strm))
return complen + 6;
/* compute wrapper length */
@@ -588,9 +673,11 @@ uLong ZEXPORT deflateBound(strm, sourceLen)
case 1: /* zlib wrapper */
wraplen = 6 + (s->strstart ? 4 : 0);
break;
+#ifdef GZIP
case 2: /* gzip wrapper */
wraplen = 18;
if (s->gzhead != Z_NULL) { /* user-supplied gzip header */
+ Bytef *str;
if (s->gzhead->extra != Z_NULL)
wraplen += 2 + s->gzhead->extra_len;
str = s->gzhead->name;
@@ -607,6 +694,7 @@ uLong ZEXPORT deflateBound(strm, sourceLen)
wraplen += 2;
}
break;
+#endif
default: /* for compiler happiness */
wraplen = 6;
}
@@ -634,10 +722,10 @@ local void putShortMSB (s, b)
}
/* =========================================================================
- * Flush as much pending output as possible. All deflate() output goes
- * through this function so some applications may wish to modify it
- * to avoid allocating a large strm->next_out buffer and copying into it.
- * (See also read_buf()).
+ * Flush as much pending output as possible. All deflate() output, except for
+ * some deflate_stored() output, goes through this function so some
+ * applications may wish to modify it to avoid allocating a large
+ * strm->next_out buffer and copying into it. (See also read_buf()).
*/
local void flush_pending(strm)
z_streamp strm;
@@ -654,13 +742,23 @@ local void flush_pending(strm)
strm->next_out += len;
s->pending_out += len;
strm->total_out += len;
- strm->avail_out -= len;
- s->pending -= len;
+ strm->avail_out -= len;
+ s->pending -= len;
if (s->pending == 0) {
s->pending_out = s->pending_buf;
}
}
+/* ===========================================================================
+ * Update the header CRC with the bytes s->pending_buf[beg..s->pending - 1].
+ */
+#define HCRC_UPDATE(beg) \
+ do { \
+ if (s->gzhead->hcrc && s->pending > (beg)) \
+ strm->adler = crc32(strm->adler, s->pending_buf + (beg), \
+ s->pending - (beg)); \
+ } while (0)
+
/* ========================================================================= */
int ZEXPORT deflate (strm, flush)
z_streamp strm;
@@ -669,230 +767,229 @@ int ZEXPORT deflate (strm, flush)
int old_flush; /* value of flush param for previous deflate call */
deflate_state *s;
- if (strm == Z_NULL || strm->state == Z_NULL ||
- flush > Z_BLOCK || flush < 0) {
+ if (deflateStateCheck(strm) || flush > Z_BLOCK || flush < 0) {
return Z_STREAM_ERROR;
}
s = strm->state;
if (strm->next_out == Z_NULL ||
- (strm->next_in == Z_NULL && strm->avail_in != 0) ||
+ (strm->avail_in != 0 && strm->next_in == Z_NULL) ||
(s->status == FINISH_STATE && flush != Z_FINISH)) {
ERR_RETURN(strm, Z_STREAM_ERROR);
}
if (strm->avail_out == 0) ERR_RETURN(strm, Z_BUF_ERROR);
- s->strm = strm; /* just in case */
old_flush = s->last_flush;
s->last_flush = flush;
+ /* Flush as much pending output as possible */
+ if (s->pending != 0) {
+ flush_pending(strm);
+ if (strm->avail_out == 0) {
+ /* Since avail_out is 0, deflate will be called again with
+ * more output space, but possibly with both pending and
+ * avail_in equal to zero. There won't be anything to do,
+ * but this is not an error situation so make sure we
+ * return OK instead of BUF_ERROR at next call of deflate:
+ */
+ s->last_flush = -1;
+ return Z_OK;
+ }
+
+ /* Make sure there is something to do and avoid duplicate consecutive
+ * flushes. For repeated and useless calls with Z_FINISH, we keep
+ * returning Z_STREAM_END instead of Z_BUF_ERROR.
+ */
+ } else if (strm->avail_in == 0 && RANK(flush) <= RANK(old_flush) &&
+ flush != Z_FINISH) {
+ ERR_RETURN(strm, Z_BUF_ERROR);
+ }
+
+ /* User must not provide more input after the first FINISH: */
+ if (s->status == FINISH_STATE && strm->avail_in != 0) {
+ ERR_RETURN(strm, Z_BUF_ERROR);
+ }
+
/* Write the header */
if (s->status == INIT_STATE) {
-#ifdef GZIP
- if (s->wrap == 2) {
- strm->adler = crc32(0L, Z_NULL, 0);
- put_byte(s, 31);
- put_byte(s, 139);
- put_byte(s, 8);
- if (s->gzhead == Z_NULL) {
- put_byte(s, 0);
- put_byte(s, 0);
- put_byte(s, 0);
- put_byte(s, 0);
- put_byte(s, 0);
- put_byte(s, s->level == 9 ? 2 :
- (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ?
- 4 : 0));
- put_byte(s, OS_CODE);
- s->status = BUSY_STATE;
- }
- else {
- put_byte(s, (s->gzhead->text ? 1 : 0) +
- (s->gzhead->hcrc ? 2 : 0) +
- (s->gzhead->extra == Z_NULL ? 0 : 4) +
- (s->gzhead->name == Z_NULL ? 0 : 8) +
- (s->gzhead->comment == Z_NULL ? 0 : 16)
- );
- put_byte(s, (Byte)(s->gzhead->time & 0xff));
- put_byte(s, (Byte)((s->gzhead->time >> 8) & 0xff));
- put_byte(s, (Byte)((s->gzhead->time >> 16) & 0xff));
- put_byte(s, (Byte)((s->gzhead->time >> 24) & 0xff));
- put_byte(s, s->level == 9 ? 2 :
- (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ?
- 4 : 0));
- put_byte(s, s->gzhead->os & 0xff);
- if (s->gzhead->extra != Z_NULL) {
- put_byte(s, s->gzhead->extra_len & 0xff);
- put_byte(s, (s->gzhead->extra_len >> 8) & 0xff);
- }
- if (s->gzhead->hcrc)
- strm->adler = crc32(strm->adler, s->pending_buf,
- s->pending);
- s->gzindex = 0;
- s->status = EXTRA_STATE;
- }
- }
+ /* zlib header */
+ uInt header = (Z_DEFLATED + ((s->w_bits-8)<<4)) << 8;
+ uInt level_flags;
+
+ if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2)
+ level_flags = 0;
+ else if (s->level < 6)
+ level_flags = 1;
+ else if (s->level == 6)
+ level_flags = 2;
else
-#endif
- {
- uInt header = (Z_DEFLATED + ((s->w_bits-8)<<4)) << 8;
- uInt level_flags;
-
- if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2)
- level_flags = 0;
- else if (s->level < 6)
- level_flags = 1;
- else if (s->level == 6)
- level_flags = 2;
- else
- level_flags = 3;
- header |= (level_flags << 6);
- if (s->strstart != 0) header |= PRESET_DICT;
- header += 31 - (header % 31);
+ level_flags = 3;
+ header |= (level_flags << 6);
+ if (s->strstart != 0) header |= PRESET_DICT;
+ header += 31 - (header % 31);
+
+ putShortMSB(s, header);
+ /* Save the adler32 of the preset dictionary: */
+ if (s->strstart != 0) {
+ putShortMSB(s, (uInt)(strm->adler >> 16));
+ putShortMSB(s, (uInt)(strm->adler & 0xffff));
+ }
+ strm->adler = adler32(0L, Z_NULL, 0);
+ s->status = BUSY_STATE;
+
+ /* Compression must start with an empty pending buffer */
+ flush_pending(strm);
+ if (s->pending != 0) {
+ s->last_flush = -1;
+ return Z_OK;
+ }
+ }
+#ifdef GZIP
+ if (s->status == GZIP_STATE) {
+ /* gzip header */
+ strm->adler = crc32(0L, Z_NULL, 0);
+ put_byte(s, 31);
+ put_byte(s, 139);
+ put_byte(s, 8);
+ if (s->gzhead == Z_NULL) {
+ put_byte(s, 0);
+ put_byte(s, 0);
+ put_byte(s, 0);
+ put_byte(s, 0);
+ put_byte(s, 0);
+ put_byte(s, s->level == 9 ? 2 :
+ (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ?
+ 4 : 0));
+ put_byte(s, OS_CODE);
s->status = BUSY_STATE;
- putShortMSB(s, header);
- /* Save the adler32 of the preset dictionary: */
- if (s->strstart != 0) {
- putShortMSB(s, (uInt)(strm->adler >> 16));
- putShortMSB(s, (uInt)(strm->adler & 0xffff));
+ /* Compression must start with an empty pending buffer */
+ flush_pending(strm);
+ if (s->pending != 0) {
+ s->last_flush = -1;
+ return Z_OK;
+ }
+ }
+ else {
+ put_byte(s, (s->gzhead->text ? 1 : 0) +
+ (s->gzhead->hcrc ? 2 : 0) +
+ (s->gzhead->extra == Z_NULL ? 0 : 4) +
+ (s->gzhead->name == Z_NULL ? 0 : 8) +
+ (s->gzhead->comment == Z_NULL ? 0 : 16)
+ );
+ put_byte(s, (Byte)(s->gzhead->time & 0xff));
+ put_byte(s, (Byte)((s->gzhead->time >> 8) & 0xff));
+ put_byte(s, (Byte)((s->gzhead->time >> 16) & 0xff));
+ put_byte(s, (Byte)((s->gzhead->time >> 24) & 0xff));
+ put_byte(s, s->level == 9 ? 2 :
+ (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ?
+ 4 : 0));
+ put_byte(s, s->gzhead->os & 0xff);
+ if (s->gzhead->extra != Z_NULL) {
+ put_byte(s, s->gzhead->extra_len & 0xff);
+ put_byte(s, (s->gzhead->extra_len >> 8) & 0xff);
}
- strm->adler = adler32(0L, Z_NULL, 0);
+ if (s->gzhead->hcrc)
+ strm->adler = crc32(strm->adler, s->pending_buf,
+ s->pending);
+ s->gzindex = 0;
+ s->status = EXTRA_STATE;
}
}
-#ifdef GZIP
if (s->status == EXTRA_STATE) {
if (s->gzhead->extra != Z_NULL) {
- uInt beg = s->pending; /* start of bytes to update crc */
-
- while (s->gzindex < (s->gzhead->extra_len & 0xffff)) {
- if (s->pending == s->pending_buf_size) {
- if (s->gzhead->hcrc && s->pending > beg)
- strm->adler = crc32(strm->adler, s->pending_buf + beg,
- s->pending - beg);
- flush_pending(strm);
- beg = s->pending;
- if (s->pending == s->pending_buf_size)
- break;
+ ulg beg = s->pending; /* start of bytes to update crc */
+ uInt left = (s->gzhead->extra_len & 0xffff) - s->gzindex;
+ while (s->pending + left > s->pending_buf_size) {
+ uInt copy = s->pending_buf_size - s->pending;
+ zmemcpy(s->pending_buf + s->pending,
+ s->gzhead->extra + s->gzindex, copy);
+ s->pending = s->pending_buf_size;
+ HCRC_UPDATE(beg);
+ s->gzindex += copy;
+ flush_pending(strm);
+ if (s->pending != 0) {
+ s->last_flush = -1;
+ return Z_OK;
}
- put_byte(s, s->gzhead->extra[s->gzindex]);
- s->gzindex++;
- }
- if (s->gzhead->hcrc && s->pending > beg)
- strm->adler = crc32(strm->adler, s->pending_buf + beg,
- s->pending - beg);
- if (s->gzindex == s->gzhead->extra_len) {
- s->gzindex = 0;
- s->status = NAME_STATE;
+ beg = 0;
+ left -= copy;
}
+ zmemcpy(s->pending_buf + s->pending,
+ s->gzhead->extra + s->gzindex, left);
+ s->pending += left;
+ HCRC_UPDATE(beg);
+ s->gzindex = 0;
}
- else
- s->status = NAME_STATE;
+ s->status = NAME_STATE;
}
if (s->status == NAME_STATE) {
if (s->gzhead->name != Z_NULL) {
- uInt beg = s->pending; /* start of bytes to update crc */
+ ulg beg = s->pending; /* start of bytes to update crc */
int val;
-
do {
if (s->pending == s->pending_buf_size) {
- if (s->gzhead->hcrc && s->pending > beg)
- strm->adler = crc32(strm->adler, s->pending_buf + beg,
- s->pending - beg);
+ HCRC_UPDATE(beg);
flush_pending(strm);
- beg = s->pending;
- if (s->pending == s->pending_buf_size) {
- val = 1;
- break;
+ if (s->pending != 0) {
+ s->last_flush = -1;
+ return Z_OK;
}
+ beg = 0;
}
val = s->gzhead->name[s->gzindex++];
put_byte(s, val);
} while (val != 0);
- if (s->gzhead->hcrc && s->pending > beg)
- strm->adler = crc32(strm->adler, s->pending_buf + beg,
- s->pending - beg);
- if (val == 0) {
- s->gzindex = 0;
- s->status = COMMENT_STATE;
- }
+ HCRC_UPDATE(beg);
+ s->gzindex = 0;
}
- else
- s->status = COMMENT_STATE;
+ s->status = COMMENT_STATE;
}
if (s->status == COMMENT_STATE) {
if (s->gzhead->comment != Z_NULL) {
- uInt beg = s->pending; /* start of bytes to update crc */
+ ulg beg = s->pending; /* start of bytes to update crc */
int val;
-
do {
if (s->pending == s->pending_buf_size) {
- if (s->gzhead->hcrc && s->pending > beg)
- strm->adler = crc32(strm->adler, s->pending_buf + beg,
- s->pending - beg);
+ HCRC_UPDATE(beg);
flush_pending(strm);
- beg = s->pending;
- if (s->pending == s->pending_buf_size) {
- val = 1;
- break;
+ if (s->pending != 0) {
+ s->last_flush = -1;
+ return Z_OK;
}
+ beg = 0;
}
val = s->gzhead->comment[s->gzindex++];
put_byte(s, val);
} while (val != 0);
- if (s->gzhead->hcrc && s->pending > beg)
- strm->adler = crc32(strm->adler, s->pending_buf + beg,
- s->pending - beg);
- if (val == 0)
- s->status = HCRC_STATE;
+ HCRC_UPDATE(beg);
}
- else
- s->status = HCRC_STATE;
+ s->status = HCRC_STATE;
}
if (s->status == HCRC_STATE) {
if (s->gzhead->hcrc) {
- if (s->pending + 2 > s->pending_buf_size)
+ if (s->pending + 2 > s->pending_buf_size) {
flush_pending(strm);
- if (s->pending + 2 <= s->pending_buf_size) {
- put_byte(s, (Byte)(strm->adler & 0xff));
- put_byte(s, (Byte)((strm->adler >> 8) & 0xff));
- strm->adler = crc32(0L, Z_NULL, 0);
- s->status = BUSY_STATE;
+ if (s->pending != 0) {
+ s->last_flush = -1;
+ return Z_OK;
+ }
}
+ put_byte(s, (Byte)(strm->adler & 0xff));
+ put_byte(s, (Byte)((strm->adler >> 8) & 0xff));
+ strm->adler = crc32(0L, Z_NULL, 0);
}
- else
- s->status = BUSY_STATE;
- }
-#endif
+ s->status = BUSY_STATE;
- /* Flush as much pending output as possible */
- if (s->pending != 0) {
+ /* Compression must start with an empty pending buffer */
flush_pending(strm);
- if (strm->avail_out == 0) {
- /* Since avail_out is 0, deflate will be called again with
- * more output space, but possibly with both pending and
- * avail_in equal to zero. There won't be anything to do,
- * but this is not an error situation so make sure we
- * return OK instead of BUF_ERROR at next call of deflate:
- */
+ if (s->pending != 0) {
s->last_flush = -1;
return Z_OK;
}
-
- /* Make sure there is something to do and avoid duplicate consecutive
- * flushes. For repeated and useless calls with Z_FINISH, we keep
- * returning Z_STREAM_END instead of Z_BUF_ERROR.
- */
- } else if (strm->avail_in == 0 && RANK(flush) <= RANK(old_flush) &&
- flush != Z_FINISH) {
- ERR_RETURN(strm, Z_BUF_ERROR);
- }
-
- /* User must not provide more input after the first FINISH: */
- if (s->status == FINISH_STATE && strm->avail_in != 0) {
- ERR_RETURN(strm, Z_BUF_ERROR);
}
+#endif
/* Start a new block or continue the current one.
*/
@@ -900,9 +997,10 @@ int ZEXPORT deflate (strm, flush)
(flush != Z_NO_FLUSH && s->status != FINISH_STATE)) {
block_state bstate;
- bstate = s->strategy == Z_HUFFMAN_ONLY ? deflate_huff(s, flush) :
- (s->strategy == Z_RLE ? deflate_rle(s, flush) :
- (*(configuration_table[s->level].func))(s, flush));
+ bstate = s->level == 0 ? deflate_stored(s, flush) :
+ s->strategy == Z_HUFFMAN_ONLY ? deflate_huff(s, flush) :
+ s->strategy == Z_RLE ? deflate_rle(s, flush) :
+ (*(configuration_table[s->level].func))(s, flush);
if (bstate == finish_started || bstate == finish_done) {
s->status = FINISH_STATE;
@@ -944,7 +1042,6 @@ int ZEXPORT deflate (strm, flush)
}
}
}
- Assert(strm->avail_out > 0, "bug2");
if (flush != Z_FINISH) return Z_OK;
if (s->wrap <= 0) return Z_STREAM_END;
@@ -981,18 +1078,9 @@ int ZEXPORT deflateEnd (strm)
{
int status;
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
+ if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
status = strm->state->status;
- if (status != INIT_STATE &&
- status != EXTRA_STATE &&
- status != NAME_STATE &&
- status != COMMENT_STATE &&
- status != HCRC_STATE &&
- status != BUSY_STATE &&
- status != FINISH_STATE) {
- return Z_STREAM_ERROR;
- }
/* Deallocate in reverse order of allocations: */
TRY_FREE(strm, strm->state->pending_buf);
@@ -1023,7 +1111,7 @@ int ZEXPORT deflateCopy (dest, source)
ushf *overlay;
- if (source == Z_NULL || dest == Z_NULL || source->state == Z_NULL) {
+ if (deflateStateCheck(source) || dest == Z_NULL) {
return Z_STREAM_ERROR;
}
@@ -1073,7 +1161,7 @@ int ZEXPORT deflateCopy (dest, source)
* allocating a large strm->next_in buffer and copying from it.
* (See also flush_pending()).
*/
-local int read_buf(strm, buf, size)
+local unsigned read_buf(strm, buf, size)
z_streamp strm;
Bytef *buf;
unsigned size;
@@ -1097,7 +1185,7 @@ local int read_buf(strm, buf, size)
strm->next_in += len;
strm->total_in += len;
- return (int)len;
+ return len;
}
/* ===========================================================================
@@ -1151,9 +1239,9 @@ local uInt longest_match(s, cur_match)
{
unsigned chain_length = s->max_chain_length;/* max hash chain length */
register Bytef *scan = s->window + s->strstart; /* current string */
- register Bytef *match; /* matched string */
+ register Bytef *match; /* matched string */
register int len; /* length of current match */
- int best_len = s->prev_length; /* best match length so far */
+ int best_len = (int)s->prev_length; /* best match length so far */
int nice_match = s->nice_match; /* stop if match long enough */
IPos limit = s->strstart > (IPos)MAX_DIST(s) ?
s->strstart - (IPos)MAX_DIST(s) : NIL;
@@ -1188,7 +1276,7 @@ local uInt longest_match(s, cur_match)
/* Do not look for matches beyond the end of the input. This is necessary
* to make deflate deterministic.
*/
- if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead;
+ if ((uInt)nice_match > s->lookahead) nice_match = (int)s->lookahead;
Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead");
@@ -1349,7 +1437,11 @@ local uInt longest_match(s, cur_match)
#endif /* FASTEST */
-#ifdef DEBUG
+#ifdef ZLIB_DEBUG
+
+#define EQUAL 0
+/* result of memcmp for equal strings */
+
/* ===========================================================================
* Check that the match at match_start is indeed a match.
*/
@@ -1375,7 +1467,7 @@ local void check_match(s, start, match, length)
}
#else
# define check_match(s, start, match, length)
-#endif /* DEBUG */
+#endif /* ZLIB_DEBUG */
/* ===========================================================================
* Fill the window when the lookahead becomes insufficient.
@@ -1390,8 +1482,7 @@ local void check_match(s, start, match, length)
local void fill_window(s)
deflate_state *s;
{
- register unsigned n, m;
- register Posf *p;
+ unsigned n;
unsigned more; /* Amount of free space at the end of the window. */
uInt wsize = s->w_size;
@@ -1418,35 +1509,11 @@ local void fill_window(s)
*/
if (s->strstart >= wsize+MAX_DIST(s)) {
- zmemcpy(s->window, s->window+wsize, (unsigned)wsize);
+ zmemcpy(s->window, s->window+wsize, (unsigned)wsize - more);
s->match_start -= wsize;
s->strstart -= wsize; /* we now have strstart >= MAX_DIST */
s->block_start -= (long) wsize;
-
- /* Slide the hash table (could be avoided with 32 bit values
- at the expense of memory usage). We slide even when level == 0
- to keep the hash table consistent if we switch back to level > 0
- later. (Using level 0 permanently is not an optimal usage of
- zlib, so we don't care about this pathological case.)
- */
- n = s->hash_size;
- p = &s->head[n];
- do {
- m = *--p;
- *p = (Pos)(m >= wsize ? m-wsize : NIL);
- } while (--n);
-
- n = wsize;
-#ifndef FASTEST
- p = &s->prev[n];
- do {
- m = *--p;
- *p = (Pos)(m >= wsize ? m-wsize : NIL);
- /* If n is not on any hash chain, prev[n] is garbage but
- * its value will never be used.
- */
- } while (--n);
-#endif
+ slide_hash(s);
more += wsize;
}
if (s->strm->avail_in == 0) break;
@@ -1552,70 +1619,199 @@ local void fill_window(s)
if (s->strm->avail_out == 0) return (last) ? finish_started : need_more; \
}
+/* Maximum stored block length in deflate format (not including header). */
+#define MAX_STORED 65535
+
+/* Minimum of a and b. */
+#define MIN(a, b) ((a) > (b) ? (b) : (a))
+
/* ===========================================================================
* Copy without compression as much as possible from the input stream, return
* the current block state.
- * This function does not insert new strings in the dictionary since
- * uncompressible data is probably not useful. This function is used
- * only for the level=0 compression option.
- * NOTE: this function should be optimized to avoid extra copying from
- * window to pending_buf.
+ *
+ * In case deflateParams() is used to later switch to a non-zero compression
+ * level, s->matches (otherwise unused when storing) keeps track of the number
+ * of hash table slides to perform. If s->matches is 1, then one hash table
+ * slide will be done when switching. If s->matches is 2, the maximum value
+ * allowed here, then the hash table will be cleared, since two or more slides
+ * is the same as a clear.
+ *
+ * deflate_stored() is written to minimize the number of times an input byte is
+ * copied. It is most efficient with large input and output buffers, which
+ * maximizes the opportunites to have a single copy from next_in to next_out.
*/
local block_state deflate_stored(s, flush)
deflate_state *s;
int flush;
{
- /* Stored blocks are limited to 0xffff bytes, pending_buf is limited
- * to pending_buf_size, and each stored block has a 5 byte header:
+ /* Smallest worthy block size when not flushing or finishing. By default
+ * this is 32K. This can be as small as 507 bytes for memLevel == 1. For
+ * large input and output buffers, the stored block size will be larger.
*/
- ulg max_block_size = 0xffff;
- ulg max_start;
-
- if (max_block_size > s->pending_buf_size - 5) {
- max_block_size = s->pending_buf_size - 5;
- }
+ unsigned min_block = MIN(s->pending_buf_size - 5, s->w_size);
- /* Copy as much as possible from input to output: */
- for (;;) {
- /* Fill the window as much as possible: */
- if (s->lookahead <= 1) {
-
- Assert(s->strstart < s->w_size+MAX_DIST(s) ||
- s->block_start >= (long)s->w_size, "slide too late");
+ /* Copy as many min_block or larger stored blocks directly to next_out as
+ * possible. If flushing, copy the remaining available input to next_out as
+ * stored blocks, if there is enough space.
+ */
+ unsigned len, left, have, last = 0;
+ unsigned used = s->strm->avail_in;
+ do {
+ /* Set len to the maximum size block that we can copy directly with the
+ * available input data and output space. Set left to how much of that
+ * would be copied from what's left in the window.
+ */
+ len = MAX_STORED; /* maximum deflate stored block length */
+ have = (s->bi_valid + 42) >> 3; /* number of header bytes */
+ if (s->strm->avail_out < have) /* need room for header */
+ break;
+ /* maximum stored block length that will fit in avail_out: */
+ have = s->strm->avail_out - have;
+ left = s->strstart - s->block_start; /* bytes left in window */
+ if (len > (ulg)left + s->strm->avail_in)
+ len = left + s->strm->avail_in; /* limit len to the input */
+ if (len > have)
+ len = have; /* limit len to the output */
+
+ /* If the stored block would be less than min_block in length, or if
+ * unable to copy all of the available input when flushing, then try
+ * copying to the window and the pending buffer instead. Also don't
+ * write an empty block when flushing -- deflate() does that.
+ */
+ if (len < min_block && ((len == 0 && flush != Z_FINISH) ||
+ flush == Z_NO_FLUSH ||
+ len != left + s->strm->avail_in))
+ break;
- fill_window(s);
- if (s->lookahead == 0 && flush == Z_NO_FLUSH) return need_more;
+ /* Make a dummy stored block in pending to get the header bytes,
+ * including any pending bits. This also updates the debugging counts.
+ */
+ last = flush == Z_FINISH && len == left + s->strm->avail_in ? 1 : 0;
+ _tr_stored_block(s, (char *)0, 0L, last);
+
+ /* Replace the lengths in the dummy stored block with len. */
+ s->pending_buf[s->pending - 4] = len;
+ s->pending_buf[s->pending - 3] = len >> 8;
+ s->pending_buf[s->pending - 2] = ~len;
+ s->pending_buf[s->pending - 1] = ~len >> 8;
+
+ /* Write the stored block header bytes. */
+ flush_pending(s->strm);
+
+#ifdef ZLIB_DEBUG
+ /* Update debugging counts for the data about to be copied. */
+ s->compressed_len += len << 3;
+ s->bits_sent += len << 3;
+#endif
- if (s->lookahead == 0) break; /* flush the current block */
+ /* Copy uncompressed bytes from the window to next_out. */
+ if (left) {
+ if (left > len)
+ left = len;
+ zmemcpy(s->strm->next_out, s->window + s->block_start, left);
+ s->strm->next_out += left;
+ s->strm->avail_out -= left;
+ s->strm->total_out += left;
+ s->block_start += left;
+ len -= left;
}
- Assert(s->block_start >= 0L, "block gone");
-
- s->strstart += s->lookahead;
- s->lookahead = 0;
-
- /* Emit a stored block if pending_buf will be full: */
- max_start = s->block_start + max_block_size;
- if (s->strstart == 0 || (ulg)s->strstart >= max_start) {
- /* strstart == 0 is possible when wraparound on 16-bit machine */
- s->lookahead = (uInt)(s->strstart - max_start);
- s->strstart = (uInt)max_start;
- FLUSH_BLOCK(s, 0);
+
+ /* Copy uncompressed bytes directly from next_in to next_out, updating
+ * the check value.
+ */
+ if (len) {
+ read_buf(s->strm, s->strm->next_out, len);
+ s->strm->next_out += len;
+ s->strm->avail_out -= len;
+ s->strm->total_out += len;
}
- /* Flush if we may have to slide, otherwise block_start may become
- * negative and the data will be gone:
+ } while (last == 0);
+
+ /* Update the sliding window with the last s->w_size bytes of the copied
+ * data, or append all of the copied data to the existing window if less
+ * than s->w_size bytes were copied. Also update the number of bytes to
+ * insert in the hash tables, in the event that deflateParams() switches to
+ * a non-zero compression level.
+ */
+ used -= s->strm->avail_in; /* number of input bytes directly copied */
+ if (used) {
+ /* If any input was used, then no unused input remains in the window,
+ * therefore s->block_start == s->strstart.
*/
- if (s->strstart - (uInt)s->block_start >= MAX_DIST(s)) {
- FLUSH_BLOCK(s, 0);
+ if (used >= s->w_size) { /* supplant the previous history */
+ s->matches = 2; /* clear hash */
+ zmemcpy(s->window, s->strm->next_in - s->w_size, s->w_size);
+ s->strstart = s->w_size;
}
+ else {
+ if (s->window_size - s->strstart <= used) {
+ /* Slide the window down. */
+ s->strstart -= s->w_size;
+ zmemcpy(s->window, s->window + s->w_size, s->strstart);
+ if (s->matches < 2)
+ s->matches++; /* add a pending slide_hash() */
+ }
+ zmemcpy(s->window + s->strstart, s->strm->next_in - used, used);
+ s->strstart += used;
+ }
+ s->block_start = s->strstart;
+ s->insert += MIN(used, s->w_size - s->insert);
}
- s->insert = 0;
- if (flush == Z_FINISH) {
- FLUSH_BLOCK(s, 1);
+ if (s->high_water < s->strstart)
+ s->high_water = s->strstart;
+
+ /* If the last block was written to next_out, then done. */
+ if (last)
return finish_done;
+
+ /* If flushing and all input has been consumed, then done. */
+ if (flush != Z_NO_FLUSH && flush != Z_FINISH &&
+ s->strm->avail_in == 0 && (long)s->strstart == s->block_start)
+ return block_done;
+
+ /* Fill the window with any remaining input. */
+ have = s->window_size - s->strstart - 1;
+ if (s->strm->avail_in > have && s->block_start >= (long)s->w_size) {
+ /* Slide the window down. */
+ s->block_start -= s->w_size;
+ s->strstart -= s->w_size;
+ zmemcpy(s->window, s->window + s->w_size, s->strstart);
+ if (s->matches < 2)
+ s->matches++; /* add a pending slide_hash() */
+ have += s->w_size; /* more space now */
}
- if ((long)s->strstart > s->block_start)
- FLUSH_BLOCK(s, 0);
- return block_done;
+ if (have > s->strm->avail_in)
+ have = s->strm->avail_in;
+ if (have) {
+ read_buf(s->strm, s->window + s->strstart, have);
+ s->strstart += have;
+ }
+ if (s->high_water < s->strstart)
+ s->high_water = s->strstart;
+
+ /* There was not enough avail_out to write a complete worthy or flushed
+ * stored block to next_out. Write a stored block to pending instead, if we
+ * have enough input for a worthy block, or if flushing and there is enough
+ * room for the remaining input as a stored block in the pending buffer.
+ */
+ have = (s->bi_valid + 42) >> 3; /* number of header bytes */
+ /* maximum stored block length that will fit in pending: */
+ have = MIN(s->pending_buf_size - have, MAX_STORED);
+ min_block = MIN(have, s->w_size);
+ left = s->strstart - s->block_start;
+ if (left >= min_block ||
+ ((left || flush == Z_FINISH) && flush != Z_NO_FLUSH &&
+ s->strm->avail_in == 0 && left <= have)) {
+ len = MIN(left, have);
+ last = flush == Z_FINISH && s->strm->avail_in == 0 &&
+ len == left ? 1 : 0;
+ _tr_stored_block(s, (charf *)s->window + s->block_start, len, last);
+ s->block_start += len;
+ flush_pending(s->strm);
+ }
+
+ /* We've done all we can with the available input and output. */
+ return last ? finish_started : need_more;
}
/* ===========================================================================
@@ -1892,7 +2088,7 @@ local block_state deflate_rle(s, flush)
prev == *++scan && prev == *++scan &&
prev == *++scan && prev == *++scan &&
scan < strend);
- s->match_length = MAX_MATCH - (int)(strend - scan);
+ s->match_length = MAX_MATCH - (uInt)(strend - scan);
if (s->match_length > s->lookahead)
s->match_length = s->lookahead;
}
diff --git a/contrib/zlib/deflate.h b/contrib/zlib/deflate.h
index ce0299e..23ecdd3 100644
--- a/contrib/zlib/deflate.h
+++ b/contrib/zlib/deflate.h
@@ -1,5 +1,5 @@
/* deflate.h -- internal compression state
- * Copyright (C) 1995-2012 Jean-loup Gailly
+ * Copyright (C) 1995-2016 Jean-loup Gailly
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -51,13 +51,16 @@
#define Buf_size 16
/* size of bit buffer in bi_buf */
-#define INIT_STATE 42
-#define EXTRA_STATE 69
-#define NAME_STATE 73
-#define COMMENT_STATE 91
-#define HCRC_STATE 103
-#define BUSY_STATE 113
-#define FINISH_STATE 666
+#define INIT_STATE 42 /* zlib header -> BUSY_STATE */
+#ifdef GZIP
+# define GZIP_STATE 57 /* gzip header -> BUSY_STATE | EXTRA_STATE */
+#endif
+#define EXTRA_STATE 69 /* gzip extra block -> NAME_STATE */
+#define NAME_STATE 73 /* gzip file name -> COMMENT_STATE */
+#define COMMENT_STATE 91 /* gzip comment -> HCRC_STATE */
+#define HCRC_STATE 103 /* gzip header CRC -> BUSY_STATE */
+#define BUSY_STATE 113 /* deflate -> FINISH_STATE */
+#define FINISH_STATE 666 /* stream complete */
/* Stream status */
@@ -83,7 +86,7 @@ typedef struct static_tree_desc_s static_tree_desc;
typedef struct tree_desc_s {
ct_data *dyn_tree; /* the dynamic tree */
int max_code; /* largest code with non zero frequency */
- static_tree_desc *stat_desc; /* the corresponding static tree */
+ const static_tree_desc *stat_desc; /* the corresponding static tree */
} FAR tree_desc;
typedef ush Pos;
@@ -100,10 +103,10 @@ typedef struct internal_state {
Bytef *pending_buf; /* output still pending */
ulg pending_buf_size; /* size of pending_buf */
Bytef *pending_out; /* next pending byte to output to the stream */
- uInt pending; /* nb of bytes in the pending buffer */
+ ulg pending; /* nb of bytes in the pending buffer */
int wrap; /* bit 0 true for zlib, bit 1 true for gzip */
gz_headerp gzhead; /* gzip header information to write */
- uInt gzindex; /* where in extra, name, or comment */
+ ulg gzindex; /* where in extra, name, or comment */
Byte method; /* can only be DEFLATED */
int last_flush; /* value of flush param for previous deflate call */
@@ -249,7 +252,7 @@ typedef struct internal_state {
uInt matches; /* number of string matches in current block */
uInt insert; /* bytes at end of window left to insert */
-#ifdef DEBUG
+#ifdef ZLIB_DEBUG
ulg compressed_len; /* total bit length of compressed file mod 2^32 */
ulg bits_sent; /* bit length of compressed data sent mod 2^32 */
#endif
@@ -275,7 +278,7 @@ typedef struct internal_state {
/* Output a byte on the stream.
* IN assertion: there is enough room in pending_buf.
*/
-#define put_byte(s, c) {s->pending_buf[s->pending++] = (c);}
+#define put_byte(s, c) {s->pending_buf[s->pending++] = (Bytef)(c);}
#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1)
@@ -309,7 +312,7 @@ void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf,
* used.
*/
-#ifndef DEBUG
+#ifndef ZLIB_DEBUG
/* Inline versions of _tr_tally for speed: */
#if defined(GEN_TREES_H) || !defined(STDC)
@@ -328,8 +331,8 @@ void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf,
flush = (s->last_lit == s->lit_bufsize-1); \
}
# define _tr_tally_dist(s, distance, length, flush) \
- { uch len = (length); \
- ush dist = (distance); \
+ { uch len = (uch)(length); \
+ ush dist = (ush)(distance); \
s->d_buf[s->last_lit] = dist; \
s->l_buf[s->last_lit++] = len; \
dist--; \
diff --git a/contrib/zlib/gzguts.h b/contrib/zlib/gzguts.h
index d87659d..990a4d2 100644
--- a/contrib/zlib/gzguts.h
+++ b/contrib/zlib/gzguts.h
@@ -1,5 +1,5 @@
/* gzguts.h -- zlib internal header definitions for gz* operations
- * Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013 Mark Adler
+ * Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013, 2016 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -25,6 +25,10 @@
# include <stdlib.h>
# include <limits.h>
#endif
+
+#ifndef _POSIX_SOURCE
+# define _POSIX_SOURCE
+#endif
#include <fcntl.h>
#ifdef _WIN32
@@ -35,6 +39,10 @@
# include <io.h>
#endif
+#if defined(_WIN32) || defined(__CYGWIN__)
+# define WIDECHAR
+#endif
+
#ifdef WINAPI_FAMILY
# define open _open
# define read _read
@@ -95,18 +103,19 @@
# endif
#endif
-/* unlike snprintf (which is required in C99, yet still not supported by
- Microsoft more than a decade later!), _snprintf does not guarantee null
- termination of the result -- however this is only used in gzlib.c where
+/* unlike snprintf (which is required in C99), _snprintf does not guarantee
+ null termination of the result -- however this is only used in gzlib.c where
the result is assured to fit in the space provided */
-#ifdef _MSC_VER
+#if defined(_MSC_VER) && _MSC_VER < 1900
# define snprintf _snprintf
#endif
#ifndef local
# define local static
#endif
-/* compile with -Dlocal if your debugger can't find static symbols */
+/* since "static" is used to mean two completely different things in C, we
+ define "local" for the non-static meaning of "static", for readability
+ (compile with -Dlocal if your debugger can't find static symbols) */
/* gz* functions always use library allocation functions */
#ifndef STDC
@@ -170,7 +179,7 @@ typedef struct {
char *path; /* path or fd for error messages */
unsigned size; /* buffer size, zero if not allocated yet */
unsigned want; /* requested buffer size, default is GZBUFSIZE */
- unsigned char *in; /* input buffer */
+ unsigned char *in; /* input buffer (double-sized when writing) */
unsigned char *out; /* output buffer (double-sized when reading) */
int direct; /* 0 if processing gzip, 1 if transparent */
/* just for reading */
diff --git a/contrib/zlib/gzlib.c b/contrib/zlib/gzlib.c
index d8dbb7e..b4cb5e4 100644
--- a/contrib/zlib/gzlib.c
+++ b/contrib/zlib/gzlib.c
@@ -1,5 +1,5 @@
/* gzlib.c -- zlib functions common to reading and writing gzip files
- * Copyright (C) 2004, 2010, 2011, 2012, 2013 Mark Adler
+ * Copyright (C) 2004-2017 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -8,7 +8,7 @@
#include "gzguts.h"
#include "zutil.h"
-#if defined(_WIN32) && !defined(__BORLANDC__)
+#if defined(_WIN32) && !defined(__BORLANDC__) && !defined(__MINGW32__)
# define LSEEK _lseeki64
#else
#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0
@@ -97,7 +97,7 @@ local gzFile gz_open(path, fd, mode)
const char *mode;
{
gz_statep state;
- size_t len;
+ z_size_t len;
int oflag;
#ifdef O_CLOEXEC
int cloexec = 0;
@@ -191,10 +191,10 @@ local gzFile gz_open(path, fd, mode)
}
/* save the path name for error messages */
-#ifdef _WIN32
+#ifdef WIDECHAR
if (fd == -2) {
len = wcstombs(NULL, path, 0);
- if (len == (size_t)-1)
+ if (len == (z_size_t)-1)
len = 0;
}
else
@@ -205,7 +205,7 @@ local gzFile gz_open(path, fd, mode)
free(state);
return NULL;
}
-#ifdef _WIN32
+#ifdef WIDECHAR
if (fd == -2)
if (len)
wcstombs(state->path, path, len + 1);
@@ -214,7 +214,7 @@ local gzFile gz_open(path, fd, mode)
else
#endif
#if !defined(NO_snprintf) && !defined(NO_vsnprintf)
- snprintf(state->path, len + 1, "%s", (const char *)path);
+ (void)snprintf(state->path, len + 1, "%s", (const char *)path);
#else
strcpy(state->path, path);
#endif
@@ -242,7 +242,7 @@ local gzFile gz_open(path, fd, mode)
/* open the file with the appropriate flags (or just use fd) */
state->fd = fd > -1 ? fd : (
-#ifdef _WIN32
+#ifdef WIDECHAR
fd == -2 ? _wopen(path, oflag, 0666) :
#endif
open((const char *)path, oflag, 0666));
@@ -251,8 +251,10 @@ local gzFile gz_open(path, fd, mode)
free(state);
return NULL;
}
- if (state->mode == GZ_APPEND)
+ if (state->mode == GZ_APPEND) {
+ LSEEK(state->fd, 0, SEEK_END); /* so gzoffset() is correct */
state->mode = GZ_WRITE; /* simplify later checks */
+ }
/* save the current position for rewinding (only if reading) */
if (state->mode == GZ_READ) {
@@ -294,7 +296,7 @@ gzFile ZEXPORT gzdopen(fd, mode)
if (fd == -1 || (path = (char *)malloc(7 + 3 * sizeof(int))) == NULL)
return NULL;
#if !defined(NO_snprintf) && !defined(NO_vsnprintf)
- snprintf(path, 7 + 3 * sizeof(int), "<fd:%d>", fd); /* for debugging */
+ (void)snprintf(path, 7 + 3 * sizeof(int), "<fd:%d>", fd);
#else
sprintf(path, "<fd:%d>", fd); /* for debugging */
#endif
@@ -304,7 +306,7 @@ gzFile ZEXPORT gzdopen(fd, mode)
}
/* -- see zlib.h -- */
-#ifdef _WIN32
+#ifdef WIDECHAR
gzFile ZEXPORT gzopen_w(path, mode)
const wchar_t *path;
const char *mode;
@@ -332,6 +334,8 @@ int ZEXPORT gzbuffer(file, size)
return -1;
/* check and set requested size */
+ if ((size << 1) < size)
+ return -1; /* need to be able to double it */
if (size < 2)
size = 2; /* need two bytes to check magic header */
state->want = size;
@@ -607,14 +611,13 @@ void ZLIB_INTERNAL gz_error(state, err, msg)
return;
}
#if !defined(NO_snprintf) && !defined(NO_vsnprintf)
- snprintf(state->msg, strlen(state->path) + strlen(msg) + 3,
- "%s%s%s", state->path, ": ", msg);
+ (void)snprintf(state->msg, strlen(state->path) + strlen(msg) + 3,
+ "%s%s%s", state->path, ": ", msg);
#else
strcpy(state->msg, state->path);
strcat(state->msg, ": ");
strcat(state->msg, msg);
#endif
- return;
}
#ifndef INT_MAX
diff --git a/contrib/zlib/gzread.c b/contrib/zlib/gzread.c
index a8292ea..1ba184f 100644
--- a/contrib/zlib/gzread.c
+++ b/contrib/zlib/gzread.c
@@ -1,5 +1,5 @@
/* gzread.c -- zlib functions for reading gzip files
- * Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013 Mark Adler
+ * Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013, 2016 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -15,6 +15,7 @@ local int gz_look OF((gz_statep));
local int gz_decomp OF((gz_statep));
local int gz_fetch OF((gz_statep));
local int gz_skip OF((gz_statep, z_off64_t));
+local z_size_t gz_read OF((gz_statep, voidp, z_size_t));
/* Use read() to load a buffer -- return -1 on error, otherwise 0. Read from
state->fd, and update state->eof, state->err, and state->msg as appropriate.
@@ -27,13 +28,17 @@ local int gz_load(state, buf, len, have)
unsigned *have;
{
int ret;
+ unsigned get, max = ((unsigned)-1 >> 2) + 1;
*have = 0;
do {
- ret = read(state->fd, buf + *have, len - *have);
+ get = len - *have;
+ if (get > max)
+ get = max;
+ ret = read(state->fd, buf + *have, get);
if (ret <= 0)
break;
- *have += ret;
+ *have += (unsigned)ret;
} while (*have < len);
if (ret < 0) {
gz_error(state, Z_ERRNO, zstrerror());
@@ -97,10 +102,8 @@ local int gz_look(state)
state->in = (unsigned char *)malloc(state->want);
state->out = (unsigned char *)malloc(state->want << 1);
if (state->in == NULL || state->out == NULL) {
- if (state->out != NULL)
- free(state->out);
- if (state->in != NULL)
- free(state->in);
+ free(state->out);
+ free(state->in);
gz_error(state, Z_MEM_ERROR, "out of memory");
return -1;
}
@@ -287,33 +290,17 @@ local int gz_skip(state, len)
return 0;
}
-/* -- see zlib.h -- */
-int ZEXPORT gzread(file, buf, len)
- gzFile file;
+/* Read len bytes into buf from file, or less than len up to the end of the
+ input. Return the number of bytes read. If zero is returned, either the
+ end of file was reached, or there was an error. state->err must be
+ consulted in that case to determine which. */
+local z_size_t gz_read(state, buf, len)
+ gz_statep state;
voidp buf;
- unsigned len;
+ z_size_t len;
{
- unsigned got, n;
- gz_statep state;
- z_streamp strm;
-
- /* get internal structure */
- if (file == NULL)
- return -1;
- state = (gz_statep)file;
- strm = &(state->strm);
-
- /* check that we're reading and that there's no (serious) error */
- if (state->mode != GZ_READ ||
- (state->err != Z_OK && state->err != Z_BUF_ERROR))
- return -1;
-
- /* since an int is returned, make sure len fits in one, otherwise return
- with an error (this avoids the flaw in the interface) */
- if ((int)len < 0) {
- gz_error(state, Z_DATA_ERROR, "requested length does not fit in int");
- return -1;
- }
+ z_size_t got;
+ unsigned n;
/* if len is zero, avoid unnecessary operations */
if (len == 0)
@@ -323,32 +310,38 @@ int ZEXPORT gzread(file, buf, len)
if (state->seek) {
state->seek = 0;
if (gz_skip(state, state->skip) == -1)
- return -1;
+ return 0;
}
/* get len bytes to buf, or less than len if at the end */
got = 0;
do {
+ /* set n to the maximum amount of len that fits in an unsigned int */
+ n = -1;
+ if (n > len)
+ n = len;
+
/* first just try copying data from the output buffer */
if (state->x.have) {
- n = state->x.have > len ? len : state->x.have;
+ if (state->x.have < n)
+ n = state->x.have;
memcpy(buf, state->x.next, n);
state->x.next += n;
state->x.have -= n;
}
/* output buffer empty -- return if we're at the end of the input */
- else if (state->eof && strm->avail_in == 0) {
+ else if (state->eof && state->strm.avail_in == 0) {
state->past = 1; /* tried to read past end */
break;
}
/* need output data -- for small len or new stream load up our output
buffer */
- else if (state->how == LOOK || len < (state->size << 1)) {
+ else if (state->how == LOOK || n < (state->size << 1)) {
/* get more output, looking for header if required */
if (gz_fetch(state) == -1)
- return -1;
+ return 0;
continue; /* no progress yet -- go back to copy above */
/* the copy above assures that we will leave with space in the
output buffer, allowing at least one gzungetc() to succeed */
@@ -356,16 +349,16 @@ int ZEXPORT gzread(file, buf, len)
/* large len -- read directly into user buffer */
else if (state->how == COPY) { /* read directly */
- if (gz_load(state, (unsigned char *)buf, len, &n) == -1)
- return -1;
+ if (gz_load(state, (unsigned char *)buf, n, &n) == -1)
+ return 0;
}
/* large len -- decompress directly into user buffer */
else { /* state->how == GZIP */
- strm->avail_out = len;
- strm->next_out = (unsigned char *)buf;
+ state->strm.avail_out = n;
+ state->strm.next_out = (unsigned char *)buf;
if (gz_decomp(state) == -1)
- return -1;
+ return 0;
n = state->x.have;
state->x.have = 0;
}
@@ -377,8 +370,75 @@ int ZEXPORT gzread(file, buf, len)
state->x.pos += n;
} while (len);
- /* return number of bytes read into user buffer (will fit in int) */
- return (int)got;
+ /* return number of bytes read into user buffer */
+ return got;
+}
+
+/* -- see zlib.h -- */
+int ZEXPORT gzread(file, buf, len)
+ gzFile file;
+ voidp buf;
+ unsigned len;
+{
+ gz_statep state;
+
+ /* get internal structure */
+ if (file == NULL)
+ return -1;
+ state = (gz_statep)file;
+
+ /* check that we're reading and that there's no (serious) error */
+ if (state->mode != GZ_READ ||
+ (state->err != Z_OK && state->err != Z_BUF_ERROR))
+ return -1;
+
+ /* since an int is returned, make sure len fits in one, otherwise return
+ with an error (this avoids a flaw in the interface) */
+ if ((int)len < 0) {
+ gz_error(state, Z_STREAM_ERROR, "request does not fit in an int");
+ return -1;
+ }
+
+ /* read len or fewer bytes to buf */
+ len = gz_read(state, buf, len);
+
+ /* check for an error */
+ if (len == 0 && state->err != Z_OK && state->err != Z_BUF_ERROR)
+ return -1;
+
+ /* return the number of bytes read (this is assured to fit in an int) */
+ return (int)len;
+}
+
+/* -- see zlib.h -- */
+z_size_t ZEXPORT gzfread(buf, size, nitems, file)
+ voidp buf;
+ z_size_t size;
+ z_size_t nitems;
+ gzFile file;
+{
+ z_size_t len;
+ gz_statep state;
+
+ /* get internal structure */
+ if (file == NULL)
+ return 0;
+ state = (gz_statep)file;
+
+ /* check that we're reading and that there's no (serious) error */
+ if (state->mode != GZ_READ ||
+ (state->err != Z_OK && state->err != Z_BUF_ERROR))
+ return 0;
+
+ /* compute bytes to read -- error on overflow */
+ len = nitems * size;
+ if (size && len / size != nitems) {
+ gz_error(state, Z_STREAM_ERROR, "request does not fit in a size_t");
+ return 0;
+ }
+
+ /* read len or fewer bytes to buf, return the number of full items read */
+ return len ? gz_read(state, buf, len) / size : 0;
}
/* -- see zlib.h -- */
@@ -411,8 +471,8 @@ int ZEXPORT gzgetc(file)
return *(state->x.next)++;
}
- /* nothing there -- try gzread() */
- ret = gzread(file, buf, 1);
+ /* nothing there -- try gz_read() */
+ ret = gz_read(state, buf, 1);
return ret < 1 ? -1 : buf[0];
}
@@ -454,7 +514,7 @@ int ZEXPORT gzungetc(c, file)
if (state->x.have == 0) {
state->x.have = 1;
state->x.next = state->out + (state->size << 1) - 1;
- state->x.next[0] = c;
+ state->x.next[0] = (unsigned char)c;
state->x.pos--;
state->past = 0;
return c;
@@ -476,7 +536,7 @@ int ZEXPORT gzungetc(c, file)
}
state->x.have++;
state->x.next--;
- state->x.next[0] = c;
+ state->x.next[0] = (unsigned char)c;
state->x.pos--;
state->past = 0;
return c;
diff --git a/contrib/zlib/gzwrite.c b/contrib/zlib/gzwrite.c
index 99cb3c2..8b38834 100644
--- a/contrib/zlib/gzwrite.c
+++ b/contrib/zlib/gzwrite.c
@@ -1,5 +1,5 @@
/* gzwrite.c -- zlib functions for writing gzip files
- * Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013 Mark Adler
+ * Copyright (C) 2004-2017 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -12,17 +12,19 @@
local int gz_init OF((gz_statep));
local int gz_comp OF((gz_statep, int));
local int gz_zero OF((gz_statep, z_off64_t));
+local z_size_t gz_write OF((gz_statep, voidpc, z_size_t));
/* Initialize state for writing a gzip file. Mark initialization by setting
- state->size to non-zero. Return -1 on failure or 0 on success. */
+ state->size to non-zero. Return -1 on a memory allocation failure, or 0 on
+ success. */
local int gz_init(state)
gz_statep state;
{
int ret;
z_streamp strm = &(state->strm);
- /* allocate input buffer */
- state->in = (unsigned char *)malloc(state->want);
+ /* allocate input buffer (double size for gzprintf) */
+ state->in = (unsigned char *)malloc(state->want << 1);
if (state->in == NULL) {
gz_error(state, Z_MEM_ERROR, "out of memory");
return -1;
@@ -50,6 +52,7 @@ local int gz_init(state)
gz_error(state, Z_MEM_ERROR, "out of memory");
return -1;
}
+ strm->next_in = NULL;
}
/* mark state as initialized */
@@ -65,17 +68,17 @@ local int gz_init(state)
}
/* Compress whatever is at avail_in and next_in and write to the output file.
- Return -1 if there is an error writing to the output file, otherwise 0.
- flush is assumed to be a valid deflate() flush value. If flush is Z_FINISH,
- then the deflate() state is reset to start a new gzip stream. If gz->direct
- is true, then simply write to the output file without compressing, and
- ignore flush. */
+ Return -1 if there is an error writing to the output file or if gz_init()
+ fails to allocate memory, otherwise 0. flush is assumed to be a valid
+ deflate() flush value. If flush is Z_FINISH, then the deflate() state is
+ reset to start a new gzip stream. If gz->direct is true, then simply write
+ to the output file without compressing, and ignore flush. */
local int gz_comp(state, flush)
gz_statep state;
int flush;
{
- int ret, got;
- unsigned have;
+ int ret, writ;
+ unsigned have, put, max = ((unsigned)-1 >> 2) + 1;
z_streamp strm = &(state->strm);
/* allocate memory if this is the first time through */
@@ -84,12 +87,16 @@ local int gz_comp(state, flush)
/* write directly if requested */
if (state->direct) {
- got = write(state->fd, strm->next_in, strm->avail_in);
- if (got < 0 || (unsigned)got != strm->avail_in) {
- gz_error(state, Z_ERRNO, zstrerror());
- return -1;
+ while (strm->avail_in) {
+ put = strm->avail_in > max ? max : strm->avail_in;
+ writ = write(state->fd, strm->next_in, put);
+ if (writ < 0) {
+ gz_error(state, Z_ERRNO, zstrerror());
+ return -1;
+ }
+ strm->avail_in -= (unsigned)writ;
+ strm->next_in += writ;
}
- strm->avail_in = 0;
return 0;
}
@@ -100,17 +107,21 @@ local int gz_comp(state, flush)
doing Z_FINISH then don't write until we get to Z_STREAM_END */
if (strm->avail_out == 0 || (flush != Z_NO_FLUSH &&
(flush != Z_FINISH || ret == Z_STREAM_END))) {
- have = (unsigned)(strm->next_out - state->x.next);
- if (have && ((got = write(state->fd, state->x.next, have)) < 0 ||
- (unsigned)got != have)) {
- gz_error(state, Z_ERRNO, zstrerror());
- return -1;
+ while (strm->next_out > state->x.next) {
+ put = strm->next_out - state->x.next > (int)max ? max :
+ (unsigned)(strm->next_out - state->x.next);
+ writ = write(state->fd, state->x.next, put);
+ if (writ < 0) {
+ gz_error(state, Z_ERRNO, zstrerror());
+ return -1;
+ }
+ state->x.next += writ;
}
if (strm->avail_out == 0) {
strm->avail_out = state->size;
strm->next_out = state->out;
+ state->x.next = state->out;
}
- state->x.next = strm->next_out;
}
/* compress */
@@ -132,7 +143,8 @@ local int gz_comp(state, flush)
return 0;
}
-/* Compress len zeros to output. Return -1 on error, 0 on success. */
+/* Compress len zeros to output. Return -1 on a write error or memory
+ allocation failure by gz_comp(), or 0 on success. */
local int gz_zero(state, len)
gz_statep state;
z_off64_t len;
@@ -164,32 +176,14 @@ local int gz_zero(state, len)
return 0;
}
-/* -- see zlib.h -- */
-int ZEXPORT gzwrite(file, buf, len)
- gzFile file;
+/* Write len bytes from buf to file. Return the number of bytes written. If
+ the returned value is less than len, then there was an error. */
+local z_size_t gz_write(state, buf, len)
+ gz_statep state;
voidpc buf;
- unsigned len;
+ z_size_t len;
{
- unsigned put = len;
- gz_statep state;
- z_streamp strm;
-
- /* get internal structure */
- if (file == NULL)
- return 0;
- state = (gz_statep)file;
- strm = &(state->strm);
-
- /* check that we're writing and that there's no error */
- if (state->mode != GZ_WRITE || state->err != Z_OK)
- return 0;
-
- /* since an int is returned, make sure len fits in one, otherwise return
- with an error (this avoids the flaw in the interface) */
- if ((int)len < 0) {
- gz_error(state, Z_DATA_ERROR, "requested length does not fit in int");
- return 0;
- }
+ z_size_t put = len;
/* if len is zero, avoid unnecessary operations */
if (len == 0)
@@ -212,14 +206,15 @@ int ZEXPORT gzwrite(file, buf, len)
do {
unsigned have, copy;
- if (strm->avail_in == 0)
- strm->next_in = state->in;
- have = (unsigned)((strm->next_in + strm->avail_in) - state->in);
+ if (state->strm.avail_in == 0)
+ state->strm.next_in = state->in;
+ have = (unsigned)((state->strm.next_in + state->strm.avail_in) -
+ state->in);
copy = state->size - have;
if (copy > len)
copy = len;
memcpy(state->in + have, buf, copy);
- strm->avail_in += copy;
+ state->strm.avail_in += copy;
state->x.pos += copy;
buf = (const char *)buf + copy;
len -= copy;
@@ -229,19 +224,83 @@ int ZEXPORT gzwrite(file, buf, len)
}
else {
/* consume whatever's left in the input buffer */
- if (strm->avail_in && gz_comp(state, Z_NO_FLUSH) == -1)
+ if (state->strm.avail_in && gz_comp(state, Z_NO_FLUSH) == -1)
return 0;
/* directly compress user buffer to file */
- strm->avail_in = len;
- strm->next_in = (z_const Bytef *)buf;
- state->x.pos += len;
- if (gz_comp(state, Z_NO_FLUSH) == -1)
- return 0;
+ state->strm.next_in = (z_const Bytef *)buf;
+ do {
+ unsigned n = (unsigned)-1;
+ if (n > len)
+ n = len;
+ state->strm.avail_in = n;
+ state->x.pos += n;
+ if (gz_comp(state, Z_NO_FLUSH) == -1)
+ return 0;
+ len -= n;
+ } while (len);
+ }
+
+ /* input was all buffered or compressed */
+ return put;
+}
+
+/* -- see zlib.h -- */
+int ZEXPORT gzwrite(file, buf, len)
+ gzFile file;
+ voidpc buf;
+ unsigned len;
+{
+ gz_statep state;
+
+ /* get internal structure */
+ if (file == NULL)
+ return 0;
+ state = (gz_statep)file;
+
+ /* check that we're writing and that there's no error */
+ if (state->mode != GZ_WRITE || state->err != Z_OK)
+ return 0;
+
+ /* since an int is returned, make sure len fits in one, otherwise return
+ with an error (this avoids a flaw in the interface) */
+ if ((int)len < 0) {
+ gz_error(state, Z_DATA_ERROR, "requested length does not fit in int");
+ return 0;
+ }
+
+ /* write len bytes from buf (the return value will fit in an int) */
+ return (int)gz_write(state, buf, len);
+}
+
+/* -- see zlib.h -- */
+z_size_t ZEXPORT gzfwrite(buf, size, nitems, file)
+ voidpc buf;
+ z_size_t size;
+ z_size_t nitems;
+ gzFile file;
+{
+ z_size_t len;
+ gz_statep state;
+
+ /* get internal structure */
+ if (file == NULL)
+ return 0;
+ state = (gz_statep)file;
+
+ /* check that we're writing and that there's no error */
+ if (state->mode != GZ_WRITE || state->err != Z_OK)
+ return 0;
+
+ /* compute bytes to read -- error on overflow */
+ len = nitems * size;
+ if (size && len / size != nitems) {
+ gz_error(state, Z_STREAM_ERROR, "request does not fit in a size_t");
+ return 0;
}
- /* input was all buffered or compressed (put will fit in int) */
- return (int)put;
+ /* write len bytes to buf, return the number of full items written */
+ return len ? gz_write(state, buf, len) / size : 0;
}
/* -- see zlib.h -- */
@@ -278,7 +337,7 @@ int ZEXPORT gzputc(file, c)
strm->next_in = state->in;
have = (unsigned)((strm->next_in + strm->avail_in) - state->in);
if (have < state->size) {
- state->in[have] = c;
+ state->in[have] = (unsigned char)c;
strm->avail_in++;
state->x.pos++;
return c & 0xff;
@@ -286,8 +345,8 @@ int ZEXPORT gzputc(file, c)
}
/* no room in buffer or not initialized, use gz_write() */
- buf[0] = c;
- if (gzwrite(file, buf, 1) != 1)
+ buf[0] = (unsigned char)c;
+ if (gz_write(state, buf, 1) != 1)
return -1;
return c & 0xff;
}
@@ -298,11 +357,21 @@ int ZEXPORT gzputs(file, str)
const char *str;
{
int ret;
- unsigned len;
+ z_size_t len;
+ gz_statep state;
+
+ /* get internal structure */
+ if (file == NULL)
+ return -1;
+ state = (gz_statep)file;
+
+ /* check that we're writing and that there's no error */
+ if (state->mode != GZ_WRITE || state->err != Z_OK)
+ return -1;
/* write string */
- len = (unsigned)strlen(str);
- ret = gzwrite(file, str, len);
+ len = strlen(str);
+ ret = gz_write(state, str, len);
return ret == 0 && len != 0 ? -1 : ret;
}
@@ -312,63 +381,73 @@ int ZEXPORT gzputs(file, str)
/* -- see zlib.h -- */
int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va)
{
- int size, len;
+ int len;
+ unsigned left;
+ char *next;
gz_statep state;
z_streamp strm;
/* get internal structure */
if (file == NULL)
- return -1;
+ return Z_STREAM_ERROR;
state = (gz_statep)file;
strm = &(state->strm);
/* check that we're writing and that there's no error */
if (state->mode != GZ_WRITE || state->err != Z_OK)
- return 0;
+ return Z_STREAM_ERROR;
/* make sure we have some buffer space */
if (state->size == 0 && gz_init(state) == -1)
- return 0;
+ return state->err;
/* check for seek request */
if (state->seek) {
state->seek = 0;
if (gz_zero(state, state->skip) == -1)
- return 0;
+ return state->err;
}
- /* consume whatever's left in the input buffer */
- if (strm->avail_in && gz_comp(state, Z_NO_FLUSH) == -1)
- return 0;
-
- /* do the printf() into the input buffer, put length in len */
- size = (int)(state->size);
- state->in[size - 1] = 0;
+ /* do the printf() into the input buffer, put length in len -- the input
+ buffer is double-sized just for this function, so there is guaranteed to
+ be state->size bytes available after the current contents */
+ if (strm->avail_in == 0)
+ strm->next_in = state->in;
+ next = (char *)(state->in + (strm->next_in - state->in) + strm->avail_in);
+ next[state->size - 1] = 0;
#ifdef NO_vsnprintf
# ifdef HAS_vsprintf_void
- (void)vsprintf((char *)(state->in), format, va);
- for (len = 0; len < size; len++)
- if (state->in[len] == 0) break;
+ (void)vsprintf(next, format, va);
+ for (len = 0; len < state->size; len++)
+ if (next[len] == 0) break;
# else
- len = vsprintf((char *)(state->in), format, va);
+ len = vsprintf(next, format, va);
# endif
#else
# ifdef HAS_vsnprintf_void
- (void)vsnprintf((char *)(state->in), size, format, va);
- len = strlen((char *)(state->in));
+ (void)vsnprintf(next, state->size, format, va);
+ len = strlen(next);
# else
- len = vsnprintf((char *)(state->in), size, format, va);
+ len = vsnprintf(next, state->size, format, va);
# endif
#endif
/* check that printf() results fit in buffer */
- if (len <= 0 || len >= (int)size || state->in[size - 1] != 0)
+ if (len == 0 || (unsigned)len >= state->size || next[state->size - 1] != 0)
return 0;
- /* update buffer and position, defer compression until needed */
- strm->avail_in = (unsigned)len;
- strm->next_in = state->in;
+ /* update buffer and position, compress first half if past that */
+ strm->avail_in += (unsigned)len;
state->x.pos += len;
+ if (strm->avail_in >= state->size) {
+ left = strm->avail_in - state->size;
+ strm->avail_in = state->size;
+ if (gz_comp(state, Z_NO_FLUSH) == -1)
+ return state->err;
+ memcpy(state->in, state->in + state->size, left);
+ strm->next_in = state->in;
+ strm->avail_in = left;
+ }
return len;
}
@@ -393,73 +472,82 @@ int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
a11, a12, a13, a14, a15, a16, a17, a18, a19, a20;
{
- int size, len;
+ unsigned len, left;
+ char *next;
gz_statep state;
z_streamp strm;
/* get internal structure */
if (file == NULL)
- return -1;
+ return Z_STREAM_ERROR;
state = (gz_statep)file;
strm = &(state->strm);
/* check that can really pass pointer in ints */
if (sizeof(int) != sizeof(void *))
- return 0;
+ return Z_STREAM_ERROR;
/* check that we're writing and that there's no error */
if (state->mode != GZ_WRITE || state->err != Z_OK)
- return 0;
+ return Z_STREAM_ERROR;
/* make sure we have some buffer space */
if (state->size == 0 && gz_init(state) == -1)
- return 0;
+ return state->error;
/* check for seek request */
if (state->seek) {
state->seek = 0;
if (gz_zero(state, state->skip) == -1)
- return 0;
+ return state->error;
}
- /* consume whatever's left in the input buffer */
- if (strm->avail_in && gz_comp(state, Z_NO_FLUSH) == -1)
- return 0;
-
- /* do the printf() into the input buffer, put length in len */
- size = (int)(state->size);
- state->in[size - 1] = 0;
+ /* do the printf() into the input buffer, put length in len -- the input
+ buffer is double-sized just for this function, so there is guaranteed to
+ be state->size bytes available after the current contents */
+ if (strm->avail_in == 0)
+ strm->next_in = state->in;
+ next = (char *)(strm->next_in + strm->avail_in);
+ next[state->size - 1] = 0;
#ifdef NO_snprintf
# ifdef HAS_sprintf_void
- sprintf((char *)(state->in), format, a1, a2, a3, a4, a5, a6, a7, a8,
- a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
+ sprintf(next, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12,
+ a13, a14, a15, a16, a17, a18, a19, a20);
for (len = 0; len < size; len++)
- if (state->in[len] == 0) break;
+ if (next[len] == 0)
+ break;
# else
- len = sprintf((char *)(state->in), format, a1, a2, a3, a4, a5, a6, a7, a8,
- a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
+ len = sprintf(next, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11,
+ a12, a13, a14, a15, a16, a17, a18, a19, a20);
# endif
#else
# ifdef HAS_snprintf_void
- snprintf((char *)(state->in), size, format, a1, a2, a3, a4, a5, a6, a7, a8,
- a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
- len = strlen((char *)(state->in));
+ snprintf(next, state->size, format, a1, a2, a3, a4, a5, a6, a7, a8, a9,
+ a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
+ len = strlen(next);
# else
- len = snprintf((char *)(state->in), size, format, a1, a2, a3, a4, a5, a6,
- a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18,
- a19, a20);
+ len = snprintf(next, state->size, format, a1, a2, a3, a4, a5, a6, a7, a8,
+ a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
# endif
#endif
/* check that printf() results fit in buffer */
- if (len <= 0 || len >= (int)size || state->in[size - 1] != 0)
+ if (len == 0 || len >= state->size || next[state->size - 1] != 0)
return 0;
- /* update buffer and position, defer compression until needed */
- strm->avail_in = (unsigned)len;
- strm->next_in = state->in;
+ /* update buffer and position, compress first half if past that */
+ strm->avail_in += len;
state->x.pos += len;
- return len;
+ if (strm->avail_in >= state->size) {
+ left = strm->avail_in - state->size;
+ strm->avail_in = state->size;
+ if (gz_comp(state, Z_NO_FLUSH) == -1)
+ return state->err;
+ memcpy(state->in, state->in + state->size, left);
+ strm->next_in = state->in;
+ strm->avail_in = left;
+ }
+ return (int)len;
}
#endif
@@ -473,7 +561,7 @@ int ZEXPORT gzflush(file, flush)
/* get internal structure */
if (file == NULL)
- return -1;
+ return Z_STREAM_ERROR;
state = (gz_statep)file;
/* check that we're writing and that there's no error */
@@ -488,11 +576,11 @@ int ZEXPORT gzflush(file, flush)
if (state->seek) {
state->seek = 0;
if (gz_zero(state, state->skip) == -1)
- return -1;
+ return state->err;
}
/* compress remaining data with requested flush */
- gz_comp(state, flush);
+ (void)gz_comp(state, flush);
return state->err;
}
@@ -523,13 +611,13 @@ int ZEXPORT gzsetparams(file, level, strategy)
if (state->seek) {
state->seek = 0;
if (gz_zero(state, state->skip) == -1)
- return -1;
+ return state->err;
}
/* change compression parameters for subsequent input */
if (state->size) {
/* flush previous input with previous parameters before changing */
- if (strm->avail_in && gz_comp(state, Z_PARTIAL_FLUSH) == -1)
+ if (strm->avail_in && gz_comp(state, Z_BLOCK) == -1)
return state->err;
deflateParams(strm, level, strategy);
}
diff --git a/contrib/zlib/infback.c b/contrib/zlib/infback.c
index f3833c2..59679ec 100644
--- a/contrib/zlib/infback.c
+++ b/contrib/zlib/infback.c
@@ -1,5 +1,5 @@
/* infback.c -- inflate using a call-back interface
- * Copyright (C) 1995-2011 Mark Adler
+ * Copyright (C) 1995-2016 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -61,7 +61,7 @@ int stream_size;
Tracev((stderr, "inflate: allocated\n"));
strm->state = (struct internal_state FAR *)state;
state->dmax = 32768U;
- state->wbits = windowBits;
+ state->wbits = (uInt)windowBits;
state->wsize = 1U << windowBits;
state->window = window;
state->wnext = 0;
diff --git a/contrib/zlib/inffast.c b/contrib/zlib/inffast.c
index bda59ce..0dbd1db 100644
--- a/contrib/zlib/inffast.c
+++ b/contrib/zlib/inffast.c
@@ -1,5 +1,5 @@
/* inffast.c -- fast decoding
- * Copyright (C) 1995-2008, 2010, 2013 Mark Adler
+ * Copyright (C) 1995-2017 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -8,26 +8,9 @@
#include "inflate.h"
#include "inffast.h"
-#ifndef ASMINF
-
-/* Allow machine dependent optimization for post-increment or pre-increment.
- Based on testing to date,
- Pre-increment preferred for:
- - PowerPC G3 (Adler)
- - MIPS R5000 (Randers-Pehrson)
- Post-increment preferred for:
- - none
- No measurable difference:
- - Pentium III (Anderson)
- - M68060 (Nikl)
- */
-#ifdef POSTINC
-# define OFF 0
-# define PUP(a) *(a)++
+#ifdef ASMINF
+# pragma message("Assembler code may have bugs -- use at your own risk")
#else
-# define OFF 1
-# define PUP(a) *++(a)
-#endif
/*
Decode literal, length, and distance codes and write out the resulting
@@ -96,9 +79,9 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
/* copy state to local variables */
state = (struct inflate_state FAR *)strm->state;
- in = strm->next_in - OFF;
+ in = strm->next_in;
last = in + (strm->avail_in - 5);
- out = strm->next_out - OFF;
+ out = strm->next_out;
beg = out - (start - strm->avail_out);
end = out + (strm->avail_out - 257);
#ifdef INFLATE_STRICT
@@ -119,9 +102,9 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
input data or output space */
do {
if (bits < 15) {
- hold += (unsigned long)(PUP(in)) << bits;
+ hold += (unsigned long)(*in++) << bits;
bits += 8;
- hold += (unsigned long)(PUP(in)) << bits;
+ hold += (unsigned long)(*in++) << bits;
bits += 8;
}
here = lcode[hold & lmask];
@@ -134,14 +117,14 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
"inflate: literal '%c'\n" :
"inflate: literal 0x%02x\n", here.val));
- PUP(out) = (unsigned char)(here.val);
+ *out++ = (unsigned char)(here.val);
}
else if (op & 16) { /* length base */
len = (unsigned)(here.val);
op &= 15; /* number of extra bits */
if (op) {
if (bits < op) {
- hold += (unsigned long)(PUP(in)) << bits;
+ hold += (unsigned long)(*in++) << bits;
bits += 8;
}
len += (unsigned)hold & ((1U << op) - 1);
@@ -150,9 +133,9 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
}
Tracevv((stderr, "inflate: length %u\n", len));
if (bits < 15) {
- hold += (unsigned long)(PUP(in)) << bits;
+ hold += (unsigned long)(*in++) << bits;
bits += 8;
- hold += (unsigned long)(PUP(in)) << bits;
+ hold += (unsigned long)(*in++) << bits;
bits += 8;
}
here = dcode[hold & dmask];
@@ -165,10 +148,10 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
dist = (unsigned)(here.val);
op &= 15; /* number of extra bits */
if (bits < op) {
- hold += (unsigned long)(PUP(in)) << bits;
+ hold += (unsigned long)(*in++) << bits;
bits += 8;
if (bits < op) {
- hold += (unsigned long)(PUP(in)) << bits;
+ hold += (unsigned long)(*in++) << bits;
bits += 8;
}
}
@@ -196,30 +179,30 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
if (len <= op - whave) {
do {
- PUP(out) = 0;
+ *out++ = 0;
} while (--len);
continue;
}
len -= op - whave;
do {
- PUP(out) = 0;
+ *out++ = 0;
} while (--op > whave);
if (op == 0) {
from = out - dist;
do {
- PUP(out) = PUP(from);
+ *out++ = *from++;
} while (--len);
continue;
}
#endif
}
- from = window - OFF;
+ from = window;
if (wnext == 0) { /* very common case */
from += wsize - op;
if (op < len) { /* some from window */
len -= op;
do {
- PUP(out) = PUP(from);
+ *out++ = *from++;
} while (--op);
from = out - dist; /* rest from output */
}
@@ -230,14 +213,14 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
if (op < len) { /* some from end of window */
len -= op;
do {
- PUP(out) = PUP(from);
+ *out++ = *from++;
} while (--op);
- from = window - OFF;
+ from = window;
if (wnext < len) { /* some from start of window */
op = wnext;
len -= op;
do {
- PUP(out) = PUP(from);
+ *out++ = *from++;
} while (--op);
from = out - dist; /* rest from output */
}
@@ -248,35 +231,35 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
if (op < len) { /* some from window */
len -= op;
do {
- PUP(out) = PUP(from);
+ *out++ = *from++;
} while (--op);
from = out - dist; /* rest from output */
}
}
while (len > 2) {
- PUP(out) = PUP(from);
- PUP(out) = PUP(from);
- PUP(out) = PUP(from);
+ *out++ = *from++;
+ *out++ = *from++;
+ *out++ = *from++;
len -= 3;
}
if (len) {
- PUP(out) = PUP(from);
+ *out++ = *from++;
if (len > 1)
- PUP(out) = PUP(from);
+ *out++ = *from++;
}
}
else {
from = out - dist; /* copy direct from output */
do { /* minimum length is three */
- PUP(out) = PUP(from);
- PUP(out) = PUP(from);
- PUP(out) = PUP(from);
+ *out++ = *from++;
+ *out++ = *from++;
+ *out++ = *from++;
len -= 3;
} while (len > 2);
if (len) {
- PUP(out) = PUP(from);
+ *out++ = *from++;
if (len > 1)
- PUP(out) = PUP(from);
+ *out++ = *from++;
}
}
}
@@ -313,8 +296,8 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
hold &= (1U << bits) - 1;
/* update state and return */
- strm->next_in = in + OFF;
- strm->next_out = out + OFF;
+ strm->next_in = in;
+ strm->next_out = out;
strm->avail_in = (unsigned)(in < last ? 5 + (last - in) : 5 - (in - last));
strm->avail_out = (unsigned)(out < end ?
257 + (end - out) : 257 - (out - end));
diff --git a/contrib/zlib/inflate.c b/contrib/zlib/inflate.c
index b51a8a5..ac333e8 100644
--- a/contrib/zlib/inflate.c
+++ b/contrib/zlib/inflate.c
@@ -1,5 +1,5 @@
/* inflate.c -- zlib decompression
- * Copyright (C) 1995-2012 Mark Adler
+ * Copyright (C) 1995-2016 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -92,6 +92,7 @@
#endif
/* function prototypes */
+local int inflateStateCheck OF((z_streamp strm));
local void fixedtables OF((struct inflate_state FAR *state));
local int updatewindow OF((z_streamp strm, const unsigned char FAR *end,
unsigned copy));
@@ -101,12 +102,26 @@ local int updatewindow OF((z_streamp strm, const unsigned char FAR *end,
local unsigned syncsearch OF((unsigned FAR *have, const unsigned char FAR *buf,
unsigned len));
+local int inflateStateCheck(strm)
+z_streamp strm;
+{
+ struct inflate_state FAR *state;
+ if (strm == Z_NULL ||
+ strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0)
+ return 1;
+ state = (struct inflate_state FAR *)strm->state;
+ if (state == Z_NULL || state->strm != strm ||
+ state->mode < HEAD || state->mode > SYNC)
+ return 1;
+ return 0;
+}
+
int ZEXPORT inflateResetKeep(strm)
z_streamp strm;
{
struct inflate_state FAR *state;
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
+ if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
state = (struct inflate_state FAR *)strm->state;
strm->total_in = strm->total_out = state->total = 0;
strm->msg = Z_NULL;
@@ -131,7 +146,7 @@ z_streamp strm;
{
struct inflate_state FAR *state;
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
+ if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
state = (struct inflate_state FAR *)strm->state;
state->wsize = 0;
state->whave = 0;
@@ -147,7 +162,7 @@ int windowBits;
struct inflate_state FAR *state;
/* get the state */
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
+ if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
state = (struct inflate_state FAR *)strm->state;
/* extract wrap request from windowBits parameter */
@@ -156,7 +171,7 @@ int windowBits;
windowBits = -windowBits;
}
else {
- wrap = (windowBits >> 4) + 1;
+ wrap = (windowBits >> 4) + 5;
#ifdef GUNZIP
if (windowBits < 48)
windowBits &= 15;
@@ -210,7 +225,9 @@ int stream_size;
if (state == Z_NULL) return Z_MEM_ERROR;
Tracev((stderr, "inflate: allocated\n"));
strm->state = (struct internal_state FAR *)state;
+ state->strm = strm;
state->window = Z_NULL;
+ state->mode = HEAD; /* to pass state test in inflateReset2() */
ret = inflateReset2(strm, windowBits);
if (ret != Z_OK) {
ZFREE(strm, state);
@@ -234,17 +251,17 @@ int value;
{
struct inflate_state FAR *state;
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
+ if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
state = (struct inflate_state FAR *)strm->state;
if (bits < 0) {
state->hold = 0;
state->bits = 0;
return Z_OK;
}
- if (bits > 16 || state->bits + bits > 32) return Z_STREAM_ERROR;
+ if (bits > 16 || state->bits + (uInt)bits > 32) return Z_STREAM_ERROR;
value &= (1L << bits) - 1;
- state->hold += value << state->bits;
- state->bits += bits;
+ state->hold += (unsigned)value << state->bits;
+ state->bits += (uInt)bits;
return Z_OK;
}
@@ -625,7 +642,7 @@ int flush;
static const unsigned short order[19] = /* permutation of code lengths */
{16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
- if (strm == Z_NULL || strm->state == Z_NULL || strm->next_out == Z_NULL ||
+ if (inflateStateCheck(strm) || strm->next_out == Z_NULL ||
(strm->next_in == Z_NULL && strm->avail_in != 0))
return Z_STREAM_ERROR;
@@ -645,6 +662,8 @@ int flush;
NEEDBITS(16);
#ifdef GUNZIP
if ((state->wrap & 2) && hold == 0x8b1f) { /* gzip header */
+ if (state->wbits == 0)
+ state->wbits = 15;
state->check = crc32(0L, Z_NULL, 0);
CRC2(state->check, hold);
INITBITS();
@@ -672,7 +691,7 @@ int flush;
len = BITS(4) + 8;
if (state->wbits == 0)
state->wbits = len;
- else if (len > state->wbits) {
+ if (len > 15 || len > state->wbits) {
strm->msg = (char *)"invalid window size";
state->mode = BAD;
break;
@@ -699,14 +718,16 @@ int flush;
}
if (state->head != Z_NULL)
state->head->text = (int)((hold >> 8) & 1);
- if (state->flags & 0x0200) CRC2(state->check, hold);
+ if ((state->flags & 0x0200) && (state->wrap & 4))
+ CRC2(state->check, hold);
INITBITS();
state->mode = TIME;
case TIME:
NEEDBITS(32);
if (state->head != Z_NULL)
state->head->time = hold;
- if (state->flags & 0x0200) CRC4(state->check, hold);
+ if ((state->flags & 0x0200) && (state->wrap & 4))
+ CRC4(state->check, hold);
INITBITS();
state->mode = OS;
case OS:
@@ -715,7 +736,8 @@ int flush;
state->head->xflags = (int)(hold & 0xff);
state->head->os = (int)(hold >> 8);
}
- if (state->flags & 0x0200) CRC2(state->check, hold);
+ if ((state->flags & 0x0200) && (state->wrap & 4))
+ CRC2(state->check, hold);
INITBITS();
state->mode = EXLEN;
case EXLEN:
@@ -724,7 +746,8 @@ int flush;
state->length = (unsigned)(hold);
if (state->head != Z_NULL)
state->head->extra_len = (unsigned)hold;
- if (state->flags & 0x0200) CRC2(state->check, hold);
+ if ((state->flags & 0x0200) && (state->wrap & 4))
+ CRC2(state->check, hold);
INITBITS();
}
else if (state->head != Z_NULL)
@@ -742,7 +765,7 @@ int flush;
len + copy > state->head->extra_max ?
state->head->extra_max - len : copy);
}
- if (state->flags & 0x0200)
+ if ((state->flags & 0x0200) && (state->wrap & 4))
state->check = crc32(state->check, next, copy);
have -= copy;
next += copy;
@@ -761,9 +784,9 @@ int flush;
if (state->head != Z_NULL &&
state->head->name != Z_NULL &&
state->length < state->head->name_max)
- state->head->name[state->length++] = len;
+ state->head->name[state->length++] = (Bytef)len;
} while (len && copy < have);
- if (state->flags & 0x0200)
+ if ((state->flags & 0x0200) && (state->wrap & 4))
state->check = crc32(state->check, next, copy);
have -= copy;
next += copy;
@@ -782,9 +805,9 @@ int flush;
if (state->head != Z_NULL &&
state->head->comment != Z_NULL &&
state->length < state->head->comm_max)
- state->head->comment[state->length++] = len;
+ state->head->comment[state->length++] = (Bytef)len;
} while (len && copy < have);
- if (state->flags & 0x0200)
+ if ((state->flags & 0x0200) && (state->wrap & 4))
state->check = crc32(state->check, next, copy);
have -= copy;
next += copy;
@@ -796,7 +819,7 @@ int flush;
case HCRC:
if (state->flags & 0x0200) {
NEEDBITS(16);
- if (hold != (state->check & 0xffff)) {
+ if ((state->wrap & 4) && hold != (state->check & 0xffff)) {
strm->msg = (char *)"header crc mismatch";
state->mode = BAD;
break;
@@ -1177,11 +1200,11 @@ int flush;
out -= left;
strm->total_out += out;
state->total += out;
- if (out)
+ if ((state->wrap & 4) && out)
strm->adler = state->check =
UPDATE(state->check, put - out, out);
out = left;
- if ((
+ if ((state->wrap & 4) && (
#ifdef GUNZIP
state->flags ? hold :
#endif
@@ -1240,10 +1263,10 @@ int flush;
strm->total_in += in;
strm->total_out += out;
state->total += out;
- if (state->wrap && out)
+ if ((state->wrap & 4) && out)
strm->adler = state->check =
UPDATE(state->check, strm->next_out - out, out);
- strm->data_type = state->bits + (state->last ? 64 : 0) +
+ strm->data_type = (int)state->bits + (state->last ? 64 : 0) +
(state->mode == TYPE ? 128 : 0) +
(state->mode == LEN_ || state->mode == COPY_ ? 256 : 0);
if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK)
@@ -1255,7 +1278,7 @@ int ZEXPORT inflateEnd(strm)
z_streamp strm;
{
struct inflate_state FAR *state;
- if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)
+ if (inflateStateCheck(strm))
return Z_STREAM_ERROR;
state = (struct inflate_state FAR *)strm->state;
if (state->window != Z_NULL) ZFREE(strm, state->window);
@@ -1273,7 +1296,7 @@ uInt *dictLength;
struct inflate_state FAR *state;
/* check state */
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
+ if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
state = (struct inflate_state FAR *)strm->state;
/* copy dictionary */
@@ -1298,7 +1321,7 @@ uInt dictLength;
int ret;
/* check state */
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
+ if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
state = (struct inflate_state FAR *)strm->state;
if (state->wrap != 0 && state->mode != DICT)
return Z_STREAM_ERROR;
@@ -1330,7 +1353,7 @@ gz_headerp head;
struct inflate_state FAR *state;
/* check state */
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
+ if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
state = (struct inflate_state FAR *)strm->state;
if ((state->wrap & 2) == 0) return Z_STREAM_ERROR;
@@ -1383,7 +1406,7 @@ z_streamp strm;
struct inflate_state FAR *state;
/* check parameters */
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
+ if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
state = (struct inflate_state FAR *)strm->state;
if (strm->avail_in == 0 && state->bits < 8) return Z_BUF_ERROR;
@@ -1430,7 +1453,7 @@ z_streamp strm;
{
struct inflate_state FAR *state;
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
+ if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
state = (struct inflate_state FAR *)strm->state;
return state->mode == STORED && state->bits == 0;
}
@@ -1445,8 +1468,7 @@ z_streamp source;
unsigned wsize;
/* check input */
- if (dest == Z_NULL || source == Z_NULL || source->state == Z_NULL ||
- source->zalloc == (alloc_func)0 || source->zfree == (free_func)0)
+ if (inflateStateCheck(source) || dest == Z_NULL)
return Z_STREAM_ERROR;
state = (struct inflate_state FAR *)source->state;
@@ -1467,6 +1489,7 @@ z_streamp source;
/* copy state */
zmemcpy((voidpf)dest, (voidpf)source, sizeof(z_stream));
zmemcpy((voidpf)copy, (voidpf)state, sizeof(struct inflate_state));
+ copy->strm = dest;
if (state->lencode >= state->codes &&
state->lencode <= state->codes + ENOUGH - 1) {
copy->lencode = copy->codes + (state->lencode - state->codes);
@@ -1488,25 +1511,51 @@ int subvert;
{
struct inflate_state FAR *state;
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
+ if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
state = (struct inflate_state FAR *)strm->state;
- state->sane = !subvert;
#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
+ state->sane = !subvert;
return Z_OK;
#else
+ (void)subvert;
state->sane = 1;
return Z_DATA_ERROR;
#endif
}
+int ZEXPORT inflateValidate(strm, check)
+z_streamp strm;
+int check;
+{
+ struct inflate_state FAR *state;
+
+ if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
+ state = (struct inflate_state FAR *)strm->state;
+ if (check)
+ state->wrap |= 4;
+ else
+ state->wrap &= ~4;
+ return Z_OK;
+}
+
long ZEXPORT inflateMark(strm)
z_streamp strm;
{
struct inflate_state FAR *state;
- if (strm == Z_NULL || strm->state == Z_NULL) return -(1L << 16);
+ if (inflateStateCheck(strm))
+ return -(1L << 16);
state = (struct inflate_state FAR *)strm->state;
- return ((long)(state->back) << 16) +
+ return (long)(((unsigned long)((long)state->back)) << 16) +
(state->mode == COPY ? state->length :
(state->mode == MATCH ? state->was - state->length : 0));
}
+
+unsigned long ZEXPORT inflateCodesUsed(strm)
+z_streamp strm;
+{
+ struct inflate_state FAR *state;
+ if (inflateStateCheck(strm)) return (unsigned long)-1;
+ state = (struct inflate_state FAR *)strm->state;
+ return (unsigned long)(state->next - state->codes);
+}
diff --git a/contrib/zlib/inflate.h b/contrib/zlib/inflate.h
index 95f4986..a46cce6 100644
--- a/contrib/zlib/inflate.h
+++ b/contrib/zlib/inflate.h
@@ -1,5 +1,5 @@
/* inflate.h -- internal inflate state definition
- * Copyright (C) 1995-2009 Mark Adler
+ * Copyright (C) 1995-2016 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -18,7 +18,7 @@
/* Possible inflate modes between inflate() calls */
typedef enum {
- HEAD, /* i: waiting for magic header */
+ HEAD = 16180, /* i: waiting for magic header */
FLAGS, /* i: waiting for method and flags (gzip) */
TIME, /* i: waiting for modification time (gzip) */
OS, /* i: waiting for extra flags and operating system (gzip) */
@@ -77,11 +77,14 @@ typedef enum {
CHECK -> LENGTH -> DONE
*/
-/* state maintained between inflate() calls. Approximately 10K bytes. */
+/* State maintained between inflate() calls -- approximately 7K bytes, not
+ including the allocated sliding window, which is up to 32K bytes. */
struct inflate_state {
+ z_streamp strm; /* pointer back to this zlib stream */
inflate_mode mode; /* current inflate mode */
int last; /* true if processing last block */
- int wrap; /* bit 0 true for zlib, bit 1 true for gzip */
+ int wrap; /* bit 0 true for zlib, bit 1 true for gzip,
+ bit 2 true to validate check value */
int havedict; /* true if dictionary provided */
int flags; /* gzip header method and flags (0 if zlib) */
unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */
diff --git a/contrib/zlib/inftrees.c b/contrib/zlib/inftrees.c
index 44d89cf..2ea08fc 100644
--- a/contrib/zlib/inftrees.c
+++ b/contrib/zlib/inftrees.c
@@ -1,5 +1,5 @@
/* inftrees.c -- generate Huffman trees for efficient decoding
- * Copyright (C) 1995-2013 Mark Adler
+ * Copyright (C) 1995-2017 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -9,7 +9,7 @@
#define MAXBITS 15
const char inflate_copyright[] =
- " inflate 1.2.8 Copyright 1995-2013 Mark Adler ";
+ " inflate 1.2.11 Copyright 1995-2017 Mark Adler ";
/*
If you use the zlib library in a product, an acknowledgment is welcome
in the documentation of your product. If for some reason you cannot
@@ -54,7 +54,7 @@ unsigned short FAR *work;
code FAR *next; /* next available space in table */
const unsigned short FAR *base; /* base value table to use */
const unsigned short FAR *extra; /* extra bits table to use */
- int end; /* use base and extra for symbol > end */
+ unsigned match; /* use base and extra for symbol >= match */
unsigned short count[MAXBITS+1]; /* number of codes of each length */
unsigned short offs[MAXBITS+1]; /* offsets in table for each length */
static const unsigned short lbase[31] = { /* Length codes 257..285 base */
@@ -62,7 +62,7 @@ unsigned short FAR *work;
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
static const unsigned short lext[31] = { /* Length codes 257..285 extra */
16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
- 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78};
+ 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 77, 202};
static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
@@ -181,19 +181,17 @@ unsigned short FAR *work;
switch (type) {
case CODES:
base = extra = work; /* dummy value--not used */
- end = 19;
+ match = 20;
break;
case LENS:
base = lbase;
- base -= 257;
extra = lext;
- extra -= 257;
- end = 256;
+ match = 257;
break;
- default: /* DISTS */
+ default: /* DISTS */
base = dbase;
extra = dext;
- end = -1;
+ match = 0;
}
/* initialize state for loop */
@@ -216,13 +214,13 @@ unsigned short FAR *work;
for (;;) {
/* create table entry */
here.bits = (unsigned char)(len - drop);
- if ((int)(work[sym]) < end) {
+ if (work[sym] + 1U < match) {
here.op = (unsigned char)0;
here.val = work[sym];
}
- else if ((int)(work[sym]) > end) {
- here.op = (unsigned char)(extra[work[sym]]);
- here.val = base[work[sym]];
+ else if (work[sym] >= match) {
+ here.op = (unsigned char)(extra[work[sym] - match]);
+ here.val = base[work[sym] - match];
}
else {
here.op = (unsigned char)(32 + 64); /* end of block */
diff --git a/contrib/zlib/test/example.c b/contrib/zlib/test/example.c
index 138a699..eee17ce 100644
--- a/contrib/zlib/test/example.c
+++ b/contrib/zlib/test/example.c
@@ -1,5 +1,5 @@
/* example.c -- usage example of the zlib compression library
- * Copyright (C) 1995-2006, 2011 Jean-loup Gailly.
+ * Copyright (C) 1995-2006, 2011, 2016 Jean-loup Gailly
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -26,13 +26,13 @@
} \
}
-z_const char hello[] = "hello, hello!";
+static z_const char hello[] = "hello, hello!";
/* "hello world" would be more standard, but the repeated "hello"
* stresses the compression code better, sorry...
*/
-const char dictionary[] = "hello";
-uLong dictId; /* Adler32 value of the dictionary */
+static const char dictionary[] = "hello";
+static uLong dictId; /* Adler32 value of the dictionary */
void test_deflate OF((Byte *compr, uLong comprLen));
void test_inflate OF((Byte *compr, uLong comprLen,
@@ -59,13 +59,13 @@ void *myalloc(q, n, m)
void *q;
unsigned n, m;
{
- q = Z_NULL;
+ (void)q;
return calloc(n, m);
}
void myfree(void *q, void *p)
{
- q = Z_NULL;
+ (void)q;
free(p);
}
@@ -432,7 +432,7 @@ void test_sync(compr, comprLen, uncompr, uncomprLen)
d_stream.next_out = uncompr;
d_stream.avail_out = (uInt)uncomprLen;
- inflate(&d_stream, Z_NO_FLUSH);
+ err = inflate(&d_stream, Z_NO_FLUSH);
CHECK_ERR(err, "inflate");
d_stream.avail_in = (uInt)comprLen-2; /* read all compressed data */
@@ -573,7 +573,8 @@ int main(argc, argv)
}
#ifdef Z_SOLO
- argc = strlen(argv[0]);
+ (void)argc;
+ (void)argv;
#else
test_compress(compr, comprLen, uncompr, uncomprLen);
diff --git a/contrib/zlib/test/infcover.c b/contrib/zlib/test/infcover.c
index fe3d920..2be0164 100644
--- a/contrib/zlib/test/infcover.c
+++ b/contrib/zlib/test/infcover.c
@@ -1,5 +1,5 @@
/* infcover.c -- test zlib's inflate routines with full code coverage
- * Copyright (C) 2011 Mark Adler
+ * Copyright (C) 2011, 2016 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -237,14 +237,14 @@ local void mem_done(z_stream *strm, char *prefix)
/* Decode a hexadecimal string, set *len to length, in[] to the bytes. This
decodes liberally, in that hex digits can be adjacent, in which case two in
- a row writes a byte. Or they can delimited by any non-hex character, where
- the delimiters are ignored except when a single hex digit is followed by a
- delimiter in which case that single digit writes a byte. The returned
- data is allocated and must eventually be freed. NULL is returned if out of
- memory. If the length is not needed, then len can be NULL. */
+ a row writes a byte. Or they can be delimited by any non-hex character,
+ where the delimiters are ignored except when a single hex digit is followed
+ by a delimiter, where that single digit writes a byte. The returned data is
+ allocated and must eventually be freed. NULL is returned if out of memory.
+ If the length is not needed, then len can be NULL. */
local unsigned char *h2b(const char *hex, unsigned *len)
{
- unsigned char *in;
+ unsigned char *in, *re;
unsigned next, val;
in = malloc((strlen(hex) + 1) >> 1);
@@ -268,8 +268,8 @@ local unsigned char *h2b(const char *hex, unsigned *len)
} while (*hex++); /* go through the loop with the terminating null */
if (len != NULL)
*len = next;
- in = reallocf(in, next);
- return in;
+ re = realloc(in, next);
+ return re == NULL ? in : re;
}
/* generic inflate() run, where hex is the hexadecimal input data, what is the
diff --git a/contrib/zlib/test/minigzip.c b/contrib/zlib/test/minigzip.c
index b3025a4..e22fb08 100644
--- a/contrib/zlib/test/minigzip.c
+++ b/contrib/zlib/test/minigzip.c
@@ -1,5 +1,5 @@
/* minigzip.c -- simulate gzip using the zlib compression library
- * Copyright (C) 1995-2006, 2010, 2011 Jean-loup Gailly.
+ * Copyright (C) 1995-2006, 2010, 2011, 2016 Jean-loup Gailly
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -40,7 +40,7 @@
# define SET_BINARY_MODE(file)
#endif
-#ifdef _MSC_VER
+#if defined(_MSC_VER) && _MSC_VER < 1900
# define snprintf _snprintf
#endif
@@ -156,14 +156,14 @@ void *myalloc(q, n, m)
void *q;
unsigned n, m;
{
- q = Z_NULL;
+ (void)q;
return calloc(n, m);
}
void myfree(q, p)
void *q, *p;
{
- q = Z_NULL;
+ (void)q;
free(p);
}
@@ -333,7 +333,7 @@ const char *gzerror(gz, err)
#endif
-char *prog;
+static char *prog;
void error OF((const char *msg));
void gz_compress OF((FILE *in, gzFile out));
@@ -500,7 +500,7 @@ void file_uncompress(file)
char *infile, *outfile;
FILE *out;
gzFile in;
- size_t len = strlen(file);
+ unsigned len = strlen(file);
if (len + strlen(GZ_SUFFIX) >= sizeof(buf)) {
fprintf(stderr, "%s: filename too long\n", prog);
diff --git a/contrib/zlib/trees.c b/contrib/zlib/trees.c
index 1fd7759..50cf4b4 100644
--- a/contrib/zlib/trees.c
+++ b/contrib/zlib/trees.c
@@ -1,5 +1,5 @@
/* trees.c -- output deflated data using Huffman coding
- * Copyright (C) 1995-2012 Jean-loup Gailly
+ * Copyright (C) 1995-2017 Jean-loup Gailly
* detect_data_type() function provided freely by Cosmin Truta, 2006
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -36,7 +36,7 @@
#include "deflate.h"
-#ifdef DEBUG
+#ifdef ZLIB_DEBUG
# include <ctype.h>
#endif
@@ -122,13 +122,13 @@ struct static_tree_desc_s {
int max_length; /* max bit length for the codes */
};
-local static_tree_desc static_l_desc =
+local const static_tree_desc static_l_desc =
{static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS};
-local static_tree_desc static_d_desc =
+local const static_tree_desc static_d_desc =
{static_dtree, extra_dbits, 0, D_CODES, MAX_BITS};
-local static_tree_desc static_bl_desc =
+local const static_tree_desc static_bl_desc =
{(const ct_data *)0, extra_blbits, 0, BL_CODES, MAX_BL_BITS};
/* ===========================================================================
@@ -152,18 +152,16 @@ local int detect_data_type OF((deflate_state *s));
local unsigned bi_reverse OF((unsigned value, int length));
local void bi_windup OF((deflate_state *s));
local void bi_flush OF((deflate_state *s));
-local void copy_block OF((deflate_state *s, charf *buf, unsigned len,
- int header));
#ifdef GEN_TREES_H
local void gen_trees_header OF((void));
#endif
-#ifndef DEBUG
+#ifndef ZLIB_DEBUG
# define send_code(s, c, tree) send_bits(s, tree[c].Code, tree[c].Len)
/* Send a code of the given tree. c and tree must not have side effects */
-#else /* DEBUG */
+#else /* !ZLIB_DEBUG */
# define send_code(s, c, tree) \
{ if (z_verbose>2) fprintf(stderr,"\ncd %3d ",(c)); \
send_bits(s, tree[c].Code, tree[c].Len); }
@@ -182,7 +180,7 @@ local void gen_trees_header OF((void));
* Send a value on a given number of bits.
* IN assertion: length <= 16 and value fits in length bits.
*/
-#ifdef DEBUG
+#ifdef ZLIB_DEBUG
local void send_bits OF((deflate_state *s, int value, int length));
local void send_bits(s, value, length)
@@ -208,12 +206,12 @@ local void send_bits(s, value, length)
s->bi_valid += length;
}
}
-#else /* !DEBUG */
+#else /* !ZLIB_DEBUG */
#define send_bits(s, value, length) \
{ int len = length;\
if (s->bi_valid > (int)Buf_size - len) {\
- int val = value;\
+ int val = (int)value;\
s->bi_buf |= (ush)val << s->bi_valid;\
put_short(s, s->bi_buf);\
s->bi_buf = (ush)val >> (Buf_size - s->bi_valid);\
@@ -223,7 +221,7 @@ local void send_bits(s, value, length)
s->bi_valid += len;\
}\
}
-#endif /* DEBUG */
+#endif /* ZLIB_DEBUG */
/* the arguments must not have side effects */
@@ -317,7 +315,7 @@ local void tr_static_init()
* Genererate the file trees.h describing the static trees.
*/
#ifdef GEN_TREES_H
-# ifndef DEBUG
+# ifndef ZLIB_DEBUG
# include <stdio.h>
# endif
@@ -394,7 +392,7 @@ void ZLIB_INTERNAL _tr_init(s)
s->bi_buf = 0;
s->bi_valid = 0;
-#ifdef DEBUG
+#ifdef ZLIB_DEBUG
s->compressed_len = 0L;
s->bits_sent = 0L;
#endif
@@ -522,12 +520,12 @@ local void gen_bitlen(s, desc)
xbits = 0;
if (n >= base) xbits = extra[n-base];
f = tree[n].Freq;
- s->opt_len += (ulg)f * (bits + xbits);
- if (stree) s->static_len += (ulg)f * (stree[n].Len + xbits);
+ s->opt_len += (ulg)f * (unsigned)(bits + xbits);
+ if (stree) s->static_len += (ulg)f * (unsigned)(stree[n].Len + xbits);
}
if (overflow == 0) return;
- Trace((stderr,"\nbit length overflow\n"));
+ Tracev((stderr,"\nbit length overflow\n"));
/* This happens for example on obj2 and pic of the Calgary corpus */
/* Find the first bit length which could increase: */
@@ -554,9 +552,8 @@ local void gen_bitlen(s, desc)
m = s->heap[--h];
if (m > max_code) continue;
if ((unsigned) tree[m].Len != (unsigned) bits) {
- Trace((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits));
- s->opt_len += ((long)bits - (long)tree[m].Len)
- *(long)tree[m].Freq;
+ Tracev((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits));
+ s->opt_len += ((ulg)bits - tree[m].Len) * tree[m].Freq;
tree[m].Len = (ush)bits;
}
n--;
@@ -578,7 +575,7 @@ local void gen_codes (tree, max_code, bl_count)
ushf *bl_count; /* number of codes at each bit length */
{
ush next_code[MAX_BITS+1]; /* next code value for each bit length */
- ush code = 0; /* running code value */
+ unsigned code = 0; /* running code value */
int bits; /* bit index */
int n; /* code index */
@@ -586,7 +583,8 @@ local void gen_codes (tree, max_code, bl_count)
* without bit reversal.
*/
for (bits = 1; bits <= MAX_BITS; bits++) {
- next_code[bits] = code = (code + bl_count[bits-1]) << 1;
+ code = (code + bl_count[bits-1]) << 1;
+ next_code[bits] = (ush)code;
}
/* Check that the bit counts in bl_count are consistent. The last code
* must be all ones.
@@ -599,7 +597,7 @@ local void gen_codes (tree, max_code, bl_count)
int len = tree[n].Len;
if (len == 0) continue;
/* Now reverse the bits */
- tree[n].Code = bi_reverse(next_code[len]++, len);
+ tree[n].Code = (ush)bi_reverse(next_code[len]++, len);
Tracecv(tree != static_ltree, (stderr,"\nn %3d %c l %2d c %4x (%x) ",
n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len]-1));
@@ -821,7 +819,7 @@ local int build_bl_tree(s)
if (s->bl_tree[bl_order[max_blindex]].Len != 0) break;
}
/* Update opt_len to include the bit length tree and counts */
- s->opt_len += 3*(max_blindex+1) + 5+5+4;
+ s->opt_len += 3*((ulg)max_blindex+1) + 5+5+4;
Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld",
s->opt_len, s->static_len));
@@ -869,11 +867,17 @@ void ZLIB_INTERNAL _tr_stored_block(s, buf, stored_len, last)
int last; /* one if this is the last block for a file */
{
send_bits(s, (STORED_BLOCK<<1)+last, 3); /* send block type */
-#ifdef DEBUG
+ bi_windup(s); /* align on byte boundary */
+ put_short(s, (ush)stored_len);
+ put_short(s, (ush)~stored_len);
+ zmemcpy(s->pending_buf + s->pending, (Bytef *)buf, stored_len);
+ s->pending += stored_len;
+#ifdef ZLIB_DEBUG
s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L;
s->compressed_len += (stored_len + 4) << 3;
+ s->bits_sent += 2*16;
+ s->bits_sent += stored_len<<3;
#endif
- copy_block(s, buf, (unsigned)stored_len, 1); /* with header */
}
/* ===========================================================================
@@ -894,7 +898,7 @@ void ZLIB_INTERNAL _tr_align(s)
{
send_bits(s, STATIC_TREES<<1, 3);
send_code(s, END_BLOCK, static_ltree);
-#ifdef DEBUG
+#ifdef ZLIB_DEBUG
s->compressed_len += 10L; /* 3 for block type, 7 for EOB */
#endif
bi_flush(s);
@@ -902,7 +906,7 @@ void ZLIB_INTERNAL _tr_align(s)
/* ===========================================================================
* Determine the best encoding for the current block: dynamic trees, static
- * trees or store, and output the encoded block to the zip file.
+ * trees or store, and write out the encoded block.
*/
void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last)
deflate_state *s;
@@ -974,7 +978,7 @@ void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last)
send_bits(s, (STATIC_TREES<<1)+last, 3);
compress_block(s, (const ct_data *)static_ltree,
(const ct_data *)static_dtree);
-#ifdef DEBUG
+#ifdef ZLIB_DEBUG
s->compressed_len += 3 + s->static_len;
#endif
} else {
@@ -983,7 +987,7 @@ void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last)
max_blindex+1);
compress_block(s, (const ct_data *)s->dyn_ltree,
(const ct_data *)s->dyn_dtree);
-#ifdef DEBUG
+#ifdef ZLIB_DEBUG
s->compressed_len += 3 + s->opt_len;
#endif
}
@@ -995,7 +999,7 @@ void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last)
if (last) {
bi_windup(s);
-#ifdef DEBUG
+#ifdef ZLIB_DEBUG
s->compressed_len += 7; /* align on byte boundary */
#endif
}
@@ -1090,7 +1094,7 @@ local void compress_block(s, ltree, dtree)
send_code(s, code, dtree); /* send the distance code */
extra = extra_dbits[code];
if (extra != 0) {
- dist -= base_dist[code];
+ dist -= (unsigned)base_dist[code];
send_bits(s, dist, extra); /* send the extra distance bits */
}
} /* literal or match pair ? */
@@ -1193,34 +1197,7 @@ local void bi_windup(s)
}
s->bi_buf = 0;
s->bi_valid = 0;
-#ifdef DEBUG
+#ifdef ZLIB_DEBUG
s->bits_sent = (s->bits_sent+7) & ~7;
#endif
}
-
-/* ===========================================================================
- * Copy a stored block, storing first the length and its
- * one's complement if requested.
- */
-local void copy_block(s, buf, len, header)
- deflate_state *s;
- charf *buf; /* the input data */
- unsigned len; /* its length */
- int header; /* true if block header must be written */
-{
- bi_windup(s); /* align on byte boundary */
-
- if (header) {
- put_short(s, (ush)len);
- put_short(s, (ush)~len);
-#ifdef DEBUG
- s->bits_sent += 2*16;
-#endif
- }
-#ifdef DEBUG
- s->bits_sent += (ulg)len<<3;
-#endif
- while (len--) {
- put_byte(s, *buf++);
- }
-}
diff --git a/contrib/zlib/uncompr.c b/contrib/zlib/uncompr.c
index 242e949..f03a1a8 100644
--- a/contrib/zlib/uncompr.c
+++ b/contrib/zlib/uncompr.c
@@ -1,5 +1,5 @@
/* uncompr.c -- decompress a memory buffer
- * Copyright (C) 1995-2003, 2010 Jean-loup Gailly.
+ * Copyright (C) 1995-2003, 2010, 2014, 2016 Jean-loup Gailly, Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -9,51 +9,85 @@
#include "zlib.h"
/* ===========================================================================
- Decompresses the source buffer into the destination buffer. sourceLen is
- the byte length of the source buffer. Upon entry, destLen is the total
- size of the destination buffer, which must be large enough to hold the
- entire uncompressed data. (The size of the uncompressed data must have
- been saved previously by the compressor and transmitted to the decompressor
- by some mechanism outside the scope of this compression library.)
- Upon exit, destLen is the actual size of the compressed buffer.
-
- uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
- enough memory, Z_BUF_ERROR if there was not enough room in the output
- buffer, or Z_DATA_ERROR if the input data was corrupted.
+ Decompresses the source buffer into the destination buffer. *sourceLen is
+ the byte length of the source buffer. Upon entry, *destLen is the total size
+ of the destination buffer, which must be large enough to hold the entire
+ uncompressed data. (The size of the uncompressed data must have been saved
+ previously by the compressor and transmitted to the decompressor by some
+ mechanism outside the scope of this compression library.) Upon exit,
+ *destLen is the size of the decompressed data and *sourceLen is the number
+ of source bytes consumed. Upon return, source + *sourceLen points to the
+ first unused input byte.
+
+ uncompress returns Z_OK if success, Z_MEM_ERROR if there was not enough
+ memory, Z_BUF_ERROR if there was not enough room in the output buffer, or
+ Z_DATA_ERROR if the input data was corrupted, including if the input data is
+ an incomplete zlib stream.
*/
-int ZEXPORT uncompress (dest, destLen, source, sourceLen)
+int ZEXPORT uncompress2 (dest, destLen, source, sourceLen)
Bytef *dest;
uLongf *destLen;
const Bytef *source;
- uLong sourceLen;
+ uLong *sourceLen;
{
z_stream stream;
int err;
+ const uInt max = (uInt)-1;
+ uLong len, left;
+ Byte buf[1]; /* for detection of incomplete stream when *destLen == 0 */
- stream.next_in = (z_const Bytef *)source;
- stream.avail_in = (uInt)sourceLen;
- /* Check for source > 64K on 16-bit machine: */
- if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;
-
- stream.next_out = dest;
- stream.avail_out = (uInt)*destLen;
- if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;
+ len = *sourceLen;
+ if (*destLen) {
+ left = *destLen;
+ *destLen = 0;
+ }
+ else {
+ left = 1;
+ dest = buf;
+ }
+ stream.next_in = (z_const Bytef *)source;
+ stream.avail_in = 0;
stream.zalloc = (alloc_func)0;
stream.zfree = (free_func)0;
+ stream.opaque = (voidpf)0;
err = inflateInit(&stream);
if (err != Z_OK) return err;
- err = inflate(&stream, Z_FINISH);
- if (err != Z_STREAM_END) {
- inflateEnd(&stream);
- if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0))
- return Z_DATA_ERROR;
- return err;
- }
- *destLen = stream.total_out;
+ stream.next_out = dest;
+ stream.avail_out = 0;
- err = inflateEnd(&stream);
- return err;
+ do {
+ if (stream.avail_out == 0) {
+ stream.avail_out = left > (uLong)max ? max : (uInt)left;
+ left -= stream.avail_out;
+ }
+ if (stream.avail_in == 0) {
+ stream.avail_in = len > (uLong)max ? max : (uInt)len;
+ len -= stream.avail_in;
+ }
+ err = inflate(&stream, Z_NO_FLUSH);
+ } while (err == Z_OK);
+
+ *sourceLen -= len + stream.avail_in;
+ if (dest != buf)
+ *destLen = stream.total_out;
+ else if (stream.total_out && err == Z_BUF_ERROR)
+ left = 1;
+
+ inflateEnd(&stream);
+ return err == Z_STREAM_END ? Z_OK :
+ err == Z_NEED_DICT ? Z_DATA_ERROR :
+ err == Z_BUF_ERROR && left + stream.avail_out ? Z_DATA_ERROR :
+ err;
+}
+
+int ZEXPORT uncompress (dest, destLen, source, sourceLen)
+ Bytef *dest;
+ uLongf *destLen;
+ const Bytef *source;
+ uLong sourceLen;
+{
+ return uncompress2(dest, destLen, source, &sourceLen);
}
diff --git a/contrib/zlib/zconf.h b/contrib/zlib/zconf.h
index 13a2e1c..0654395 100644
--- a/contrib/zlib/zconf.h
+++ b/contrib/zlib/zconf.h
@@ -1,5 +1,5 @@
/* zconf.h -- configuration of the zlib compression library
- * Copyright (C) 1995-2013 Jean-loup Gailly.
+ * Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -17,7 +17,7 @@
#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */
# define Z_PREFIX_SET
-/* all linked symbols */
+/* all linked symbols and init macros */
# define _dist_code z__dist_code
# define _length_code z__length_code
# define _tr_align z__tr_align
@@ -29,6 +29,7 @@
# define adler32 z_adler32
# define adler32_combine z_adler32_combine
# define adler32_combine64 z_adler32_combine64
+# define adler32_z z_adler32_z
# ifndef Z_SOLO
# define compress z_compress
# define compress2 z_compress2
@@ -37,10 +38,14 @@
# define crc32 z_crc32
# define crc32_combine z_crc32_combine
# define crc32_combine64 z_crc32_combine64
+# define crc32_z z_crc32_z
# define deflate z_deflate
# define deflateBound z_deflateBound
# define deflateCopy z_deflateCopy
# define deflateEnd z_deflateEnd
+# define deflateGetDictionary z_deflateGetDictionary
+# define deflateInit z_deflateInit
+# define deflateInit2 z_deflateInit2
# define deflateInit2_ z_deflateInit2_
# define deflateInit_ z_deflateInit_
# define deflateParams z_deflateParams
@@ -67,6 +72,8 @@
# define gzeof z_gzeof
# define gzerror z_gzerror
# define gzflush z_gzflush
+# define gzfread z_gzfread
+# define gzfwrite z_gzfwrite
# define gzgetc z_gzgetc
# define gzgetc_ z_gzgetc_
# define gzgets z_gzgets
@@ -78,7 +85,6 @@
# define gzopen_w z_gzopen_w
# endif
# define gzprintf z_gzprintf
-# define gzvprintf z_gzvprintf
# define gzputc z_gzputc
# define gzputs z_gzputs
# define gzread z_gzread
@@ -89,32 +95,39 @@
# define gztell z_gztell
# define gztell64 z_gztell64
# define gzungetc z_gzungetc
+# define gzvprintf z_gzvprintf
# define gzwrite z_gzwrite
# endif
# define inflate z_inflate
# define inflateBack z_inflateBack
# define inflateBackEnd z_inflateBackEnd
+# define inflateBackInit z_inflateBackInit
# define inflateBackInit_ z_inflateBackInit_
+# define inflateCodesUsed z_inflateCodesUsed
# define inflateCopy z_inflateCopy
# define inflateEnd z_inflateEnd
+# define inflateGetDictionary z_inflateGetDictionary
# define inflateGetHeader z_inflateGetHeader
+# define inflateInit z_inflateInit
+# define inflateInit2 z_inflateInit2
# define inflateInit2_ z_inflateInit2_
# define inflateInit_ z_inflateInit_
# define inflateMark z_inflateMark
# define inflatePrime z_inflatePrime
# define inflateReset z_inflateReset
# define inflateReset2 z_inflateReset2
+# define inflateResetKeep z_inflateResetKeep
# define inflateSetDictionary z_inflateSetDictionary
-# define inflateGetDictionary z_inflateGetDictionary
# define inflateSync z_inflateSync
# define inflateSyncPoint z_inflateSyncPoint
# define inflateUndermine z_inflateUndermine
-# define inflateResetKeep z_inflateResetKeep
+# define inflateValidate z_inflateValidate
# define inflate_copyright z_inflate_copyright
# define inflate_fast z_inflate_fast
# define inflate_table z_inflate_table
# ifndef Z_SOLO
# define uncompress z_uncompress
+# define uncompress2 z_uncompress2
# endif
# define zError z_zError
# ifndef Z_SOLO
@@ -224,9 +237,19 @@
# define z_const
#endif
-/* Some Mac compilers merge all .h files incorrectly: */
-#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__)
-# define NO_DUMMY_DECL
+#ifdef Z_SOLO
+ typedef unsigned long z_size_t;
+#else
+# define z_longlong long long
+# if defined(NO_SIZE_T)
+ typedef unsigned NO_SIZE_T z_size_t;
+# elif defined(STDC)
+# include <stddef.h>
+ typedef size_t z_size_t;
+# else
+ typedef unsigned long z_size_t;
+# endif
+# undef z_longlong
#endif
/* Maximum value for memLevel in deflateInit2 */
@@ -256,7 +279,7 @@
Of course this will generally degrade compression (there's no free lunch).
The memory requirements for inflate are (in bytes) 1 << windowBits
- that is, 32K for windowBits=15 (default value) plus a few kilobytes
+ that is, 32K for windowBits=15 (default value) plus about 7 kilobytes
for small objects.
*/
diff --git a/contrib/zlib/zconf.h.in b/contrib/zlib/zconf.h.in
index 9987a77..5e1d68a 100644
--- a/contrib/zlib/zconf.h.in
+++ b/contrib/zlib/zconf.h.in
@@ -1,5 +1,5 @@
/* zconf.h -- configuration of the zlib compression library
- * Copyright (C) 1995-2013 Jean-loup Gailly.
+ * Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -17,7 +17,7 @@
#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */
# define Z_PREFIX_SET
-/* all linked symbols */
+/* all linked symbols and init macros */
# define _dist_code z__dist_code
# define _length_code z__length_code
# define _tr_align z__tr_align
@@ -29,6 +29,7 @@
# define adler32 z_adler32
# define adler32_combine z_adler32_combine
# define adler32_combine64 z_adler32_combine64
+# define adler32_z z_adler32_z
# ifndef Z_SOLO
# define compress z_compress
# define compress2 z_compress2
@@ -37,10 +38,14 @@
# define crc32 z_crc32
# define crc32_combine z_crc32_combine
# define crc32_combine64 z_crc32_combine64
+# define crc32_z z_crc32_z
# define deflate z_deflate
# define deflateBound z_deflateBound
# define deflateCopy z_deflateCopy
# define deflateEnd z_deflateEnd
+# define deflateGetDictionary z_deflateGetDictionary
+# define deflateInit z_deflateInit
+# define deflateInit2 z_deflateInit2
# define deflateInit2_ z_deflateInit2_
# define deflateInit_ z_deflateInit_
# define deflateParams z_deflateParams
@@ -67,6 +72,8 @@
# define gzeof z_gzeof
# define gzerror z_gzerror
# define gzflush z_gzflush
+# define gzfread z_gzfread
+# define gzfwrite z_gzfwrite
# define gzgetc z_gzgetc
# define gzgetc_ z_gzgetc_
# define gzgets z_gzgets
@@ -78,7 +85,6 @@
# define gzopen_w z_gzopen_w
# endif
# define gzprintf z_gzprintf
-# define gzvprintf z_gzvprintf
# define gzputc z_gzputc
# define gzputs z_gzputs
# define gzread z_gzread
@@ -89,32 +95,39 @@
# define gztell z_gztell
# define gztell64 z_gztell64
# define gzungetc z_gzungetc
+# define gzvprintf z_gzvprintf
# define gzwrite z_gzwrite
# endif
# define inflate z_inflate
# define inflateBack z_inflateBack
# define inflateBackEnd z_inflateBackEnd
+# define inflateBackInit z_inflateBackInit
# define inflateBackInit_ z_inflateBackInit_
+# define inflateCodesUsed z_inflateCodesUsed
# define inflateCopy z_inflateCopy
# define inflateEnd z_inflateEnd
+# define inflateGetDictionary z_inflateGetDictionary
# define inflateGetHeader z_inflateGetHeader
+# define inflateInit z_inflateInit
+# define inflateInit2 z_inflateInit2
# define inflateInit2_ z_inflateInit2_
# define inflateInit_ z_inflateInit_
# define inflateMark z_inflateMark
# define inflatePrime z_inflatePrime
# define inflateReset z_inflateReset
# define inflateReset2 z_inflateReset2
+# define inflateResetKeep z_inflateResetKeep
# define inflateSetDictionary z_inflateSetDictionary
-# define inflateGetDictionary z_inflateGetDictionary
# define inflateSync z_inflateSync
# define inflateSyncPoint z_inflateSyncPoint
# define inflateUndermine z_inflateUndermine
-# define inflateResetKeep z_inflateResetKeep
+# define inflateValidate z_inflateValidate
# define inflate_copyright z_inflate_copyright
# define inflate_fast z_inflate_fast
# define inflate_table z_inflate_table
# ifndef Z_SOLO
# define uncompress z_uncompress
+# define uncompress2 z_uncompress2
# endif
# define zError z_zError
# ifndef Z_SOLO
@@ -224,9 +237,19 @@
# define z_const
#endif
-/* Some Mac compilers merge all .h files incorrectly: */
-#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__)
-# define NO_DUMMY_DECL
+#ifdef Z_SOLO
+ typedef unsigned long z_size_t;
+#else
+# define z_longlong long long
+# if defined(NO_SIZE_T)
+ typedef unsigned NO_SIZE_T z_size_t;
+# elif defined(STDC)
+# include <stddef.h>
+ typedef size_t z_size_t;
+# else
+ typedef unsigned long z_size_t;
+# endif
+# undef z_longlong
#endif
/* Maximum value for memLevel in deflateInit2 */
@@ -256,7 +279,7 @@
Of course this will generally degrade compression (there's no free lunch).
The memory requirements for inflate are (in bytes) 1 << windowBits
- that is, 32K for windowBits=15 (default value) plus a few kilobytes
+ that is, 32K for windowBits=15 (default value) plus about 7 kilobytes
for small objects.
*/
diff --git a/contrib/zlib/zlib.3 b/contrib/zlib/zlib.3
index 0160e62..bda4eb0 100644
--- a/contrib/zlib/zlib.3
+++ b/contrib/zlib/zlib.3
@@ -1,4 +1,4 @@
-.TH ZLIB 3 "28 Apr 2013"
+.TH ZLIB 3 "15 Jan 2017"
.SH NAME
zlib \- compression/decompression library
.SH SYNOPSIS
@@ -48,32 +48,10 @@ Changes to this version are documented in the file
that accompanies the source.
.LP
.I zlib
-is available in Java using the java.util.zip package:
-.IP
-http://java.sun.com/developer/technicalArticles/Programming/compression/
-.LP
-A Perl interface to
-.IR zlib ,
-written by Paul Marquess (pmqs@cpan.org),
-is available at CPAN (Comprehensive Perl Archive Network) sites,
-including:
-.IP
-http://search.cpan.org/~pmqs/IO-Compress-Zlib/
-.LP
-A Python interface to
-.IR zlib ,
-written by A.M. Kuchling (amk@magnet.com),
-is available in Python 1.5 and later versions:
-.IP
-http://docs.python.org/library/zlib.html
-.LP
-.I zlib
-is built into
-.IR tcl:
-.IP
-http://wiki.tcl.tk/4610
+is built in to many languages and operating systems, including but not limited to
+Java, Python, .NET, PHP, Perl, Ruby, Swift, and Go.
.LP
-An experimental package to read and write files in .zip format,
+An experimental package to read and write files in the .zip format,
written on top of
.I zlib
by Gilles Vollant (info@winimage.com),
@@ -92,7 +70,9 @@ web site can be found at:
.IP
http://zlib.net/
.LP
-The data format used by the zlib library is described by RFC
+The data format used by the
+.I zlib
+library is described by RFC
(Request for Comments) 1950 to 1952 in the files:
.IP
http://tools.ietf.org/html/rfc1950 (for the zlib header and trailer format)
@@ -124,17 +104,35 @@ http://zlib.net/zlib_faq.html
before asking for help.
Send questions and/or comments to zlib@gzip.org,
or (for the Windows DLL version) to Gilles Vollant (info@winimage.com).
-.SH AUTHORS
-Version 1.2.8
-Copyright (C) 1995-2013 Jean-loup Gailly (jloup@gzip.org)
-and Mark Adler (madler@alumni.caltech.edu).
-.LP
-This software is provided "as-is,"
-without any express or implied warranty.
-In no event will the authors be held liable for any damages
+.SH AUTHORS AND LICENSE
+Version 1.2.11
+.LP
+Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler
+.LP
+This software is provided 'as-is', without any express or implied
+warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
-See the distribution directory with respect to requirements
-governing redistribution.
+.LP
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it
+freely, subject to the following restrictions:
+.LP
+.nr step 1 1
+.IP \n[step]. 3
+The origin of this software must not be misrepresented; you must not
+claim that you wrote the original software. If you use this software
+in a product, an acknowledgment in the product documentation would be
+appreciated but is not required.
+.IP \n+[step].
+Altered source versions must be plainly marked as such, and must not be
+misrepresented as being the original software.
+.IP \n+[step].
+This notice may not be removed or altered from any source distribution.
+.LP
+Jean-loup Gailly Mark Adler
+.br
+jloup@gzip.org madler@alumni.caltech.edu
+.LP
The deflate format used by
.I zlib
was defined by Phil Katz.
diff --git a/contrib/zlib/zlib.h b/contrib/zlib/zlib.h
index 3e0c767..f09cdaf 100644
--- a/contrib/zlib/zlib.h
+++ b/contrib/zlib/zlib.h
@@ -1,7 +1,7 @@
/* zlib.h -- interface of the 'zlib' general purpose compression library
- version 1.2.8, April 28th, 2013
+ version 1.2.11, January 15th, 2017
- Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler
+ Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -37,11 +37,11 @@
extern "C" {
#endif
-#define ZLIB_VERSION "1.2.8"
-#define ZLIB_VERNUM 0x1280
+#define ZLIB_VERSION "1.2.11"
+#define ZLIB_VERNUM 0x12b0
#define ZLIB_VER_MAJOR 1
#define ZLIB_VER_MINOR 2
-#define ZLIB_VER_REVISION 8
+#define ZLIB_VER_REVISION 11
#define ZLIB_VER_SUBREVISION 0
/*
@@ -65,7 +65,8 @@ extern "C" {
with "gz". The gzip format is different from the zlib format. gzip is a
gzip wrapper, documented in RFC 1952, wrapped around a deflate stream.
- This library can optionally read and write gzip streams in memory as well.
+ This library can optionally read and write gzip and raw deflate streams in
+ memory as well.
The zlib format was designed to be compact and fast for use in memory
and on communications channels. The gzip format was designed for single-
@@ -74,7 +75,7 @@ extern "C" {
The library does not install any signal handler. The decoder checks
the consistency of the compressed data, so the library should never crash
- even in case of corrupted input.
+ even in the case of corrupted input.
*/
typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size));
@@ -87,7 +88,7 @@ typedef struct z_stream_s {
uInt avail_in; /* number of bytes available at next_in */
uLong total_in; /* total number of input bytes read so far */
- Bytef *next_out; /* next output byte should be put there */
+ Bytef *next_out; /* next output byte will go here */
uInt avail_out; /* remaining free space at next_out */
uLong total_out; /* total number of bytes output so far */
@@ -98,8 +99,9 @@ typedef struct z_stream_s {
free_func zfree; /* used to free the internal state */
voidpf opaque; /* private data object passed to zalloc and zfree */
- int data_type; /* best guess about the data type: binary or text */
- uLong adler; /* adler32 value of the uncompressed data */
+ int data_type; /* best guess about the data type: binary or text
+ for deflate, or the decoding state for inflate */
+ uLong adler; /* Adler-32 or CRC-32 value of the uncompressed data */
uLong reserved; /* reserved for future use */
} z_stream;
@@ -142,7 +144,9 @@ typedef gz_header FAR *gz_headerp;
zalloc must return Z_NULL if there is not enough memory for the object.
If zlib is used in a multi-threaded application, zalloc and zfree must be
- thread safe.
+ thread safe. In that case, zlib is thread-safe. When zalloc and zfree are
+ Z_NULL on entry to the initialization function, they are set to internal
+ routines that use the standard library functions malloc() and free().
On 16-bit systems, the functions zalloc and zfree must be able to allocate
exactly 65536 bytes, but will not be required to allocate more than this if
@@ -155,7 +159,7 @@ typedef gz_header FAR *gz_headerp;
The fields total_in and total_out can be used for statistics or progress
reports. After compression, total_in holds the total size of the
- uncompressed data and may be saved for use in the decompressor (particularly
+ uncompressed data and may be saved for use by the decompressor (particularly
if the decompressor wants to decompress everything in a single step).
*/
@@ -200,7 +204,7 @@ typedef gz_header FAR *gz_headerp;
#define Z_TEXT 1
#define Z_ASCII Z_TEXT /* for compatibility with 1.2.2 and earlier */
#define Z_UNKNOWN 2
-/* Possible values of the data_type field (though see inflate()) */
+/* Possible values of the data_type field for deflate() */
#define Z_DEFLATED 8
/* The deflate compression method (the only one supported in this version) */
@@ -258,11 +262,11 @@ ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
enough room in the output buffer), next_in and avail_in are updated and
processing will resume at this point for the next call of deflate().
- - Provide more output starting at next_out and update next_out and avail_out
+ - Generate more output starting at next_out and update next_out and avail_out
accordingly. This action is forced if the parameter flush is non zero.
Forcing flush frequently degrades the compression ratio, so this parameter
- should be set only when necessary (in interactive applications). Some
- output may be provided even if flush is not set.
+ should be set only when necessary. Some output may be provided even if
+ flush is zero.
Before the call of deflate(), the application should ensure that at least
one of the actions is possible, by providing more input and/or consuming more
@@ -271,7 +275,9 @@ ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
output when it wants, for example when the output buffer is full (avail_out
== 0), or after each call of deflate(). If deflate returns Z_OK and with
zero avail_out, it must be called again after making room in the output
- buffer because there might be more output pending.
+ buffer because there might be more output pending. See deflatePending(),
+ which can be used if desired to determine whether or not there is more ouput
+ in that case.
Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to
decide how much data to accumulate before producing output, in order to
@@ -292,8 +298,8 @@ ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
input data so far will be available to the decompressor, as for Z_SYNC_FLUSH.
This completes the current deflate block and follows it with an empty fixed
codes block that is 10 bits long. This assures that enough bytes are output
- in order for the decompressor to finish the block before the empty fixed code
- block.
+ in order for the decompressor to finish the block before the empty fixed
+ codes block.
If flush is set to Z_BLOCK, a deflate block is completed and emitted, as
for Z_SYNC_FLUSH, but the output is not aligned on a byte boundary, and up to
@@ -319,34 +325,38 @@ ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
If the parameter flush is set to Z_FINISH, pending input is processed,
pending output is flushed and deflate returns with Z_STREAM_END if there was
- enough output space; if deflate returns with Z_OK, this function must be
- called again with Z_FINISH and more output space (updated avail_out) but no
- more input data, until it returns with Z_STREAM_END or an error. After
- deflate has returned Z_STREAM_END, the only possible operations on the stream
- are deflateReset or deflateEnd.
-
- Z_FINISH can be used immediately after deflateInit if all the compression
- is to be done in a single step. In this case, avail_out must be at least the
- value returned by deflateBound (see below). Then deflate is guaranteed to
- return Z_STREAM_END. If not enough output space is provided, deflate will
- not return Z_STREAM_END, and it must be called again as described above.
-
- deflate() sets strm->adler to the adler32 checksum of all input read
- so far (that is, total_in bytes).
+ enough output space. If deflate returns with Z_OK or Z_BUF_ERROR, this
+ function must be called again with Z_FINISH and more output space (updated
+ avail_out) but no more input data, until it returns with Z_STREAM_END or an
+ error. After deflate has returned Z_STREAM_END, the only possible operations
+ on the stream are deflateReset or deflateEnd.
+
+ Z_FINISH can be used in the first deflate call after deflateInit if all the
+ compression is to be done in a single step. In order to complete in one
+ call, avail_out must be at least the value returned by deflateBound (see
+ below). Then deflate is guaranteed to return Z_STREAM_END. If not enough
+ output space is provided, deflate will not return Z_STREAM_END, and it must
+ be called again as described above.
+
+ deflate() sets strm->adler to the Adler-32 checksum of all input read
+ so far (that is, total_in bytes). If a gzip stream is being generated, then
+ strm->adler will be the CRC-32 checksum of the input read so far. (See
+ deflateInit2 below.)
deflate() may update strm->data_type if it can make a good guess about
- the input data type (Z_BINARY or Z_TEXT). In doubt, the data is considered
- binary. This field is only for information purposes and does not affect the
- compression algorithm in any manner.
+ the input data type (Z_BINARY or Z_TEXT). If in doubt, the data is
+ considered binary. This field is only for information purposes and does not
+ affect the compression algorithm in any manner.
deflate() returns Z_OK if some progress has been made (more input
processed or more output produced), Z_STREAM_END if all input has been
consumed and all output has been produced (only when flush is set to
Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example
- if next_in or next_out was Z_NULL), Z_BUF_ERROR if no progress is possible
- (for example avail_in or avail_out was zero). Note that Z_BUF_ERROR is not
- fatal, and deflate() can be called again with more input and more output
- space to continue compressing.
+ if next_in or next_out was Z_NULL or the state was inadvertently written over
+ by the application), or Z_BUF_ERROR if no progress is possible (for example
+ avail_in or avail_out was zero). Note that Z_BUF_ERROR is not fatal, and
+ deflate() can be called again with more input and more output space to
+ continue compressing.
*/
@@ -369,23 +379,21 @@ ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm));
Initializes the internal stream state for decompression. The fields
next_in, avail_in, zalloc, zfree and opaque must be initialized before by
- the caller. If next_in is not Z_NULL and avail_in is large enough (the
- exact value depends on the compression method), inflateInit determines the
- compression method from the zlib header and allocates all data structures
- accordingly; otherwise the allocation will be deferred to the first call of
- inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to
- use default allocation functions.
+ the caller. In the current version of inflate, the provided input is not
+ read or consumed. The allocation of a sliding window will be deferred to
+ the first call of inflate (if the decompression does not complete on the
+ first call). If zalloc and zfree are set to Z_NULL, inflateInit updates
+ them to use default allocation functions.
inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough
memory, Z_VERSION_ERROR if the zlib library version is incompatible with the
version assumed by the caller, or Z_STREAM_ERROR if the parameters are
invalid, such as a null pointer to the structure. msg is set to null if
- there is no error message. inflateInit does not perform any decompression
- apart from possibly reading the zlib header if present: actual decompression
- will be done by inflate(). (So next_in and avail_in may be modified, but
- next_out and avail_out are unused and unchanged.) The current implementation
- of inflateInit() does not process any header information -- that is deferred
- until inflate() is called.
+ there is no error message. inflateInit does not perform any decompression.
+ Actual decompression will be done by inflate(). So next_in, and avail_in,
+ next_out, and avail_out are unused and unchanged. The current
+ implementation of inflateInit() does not process any header information --
+ that is deferred until inflate() is called.
*/
@@ -401,17 +409,20 @@ ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
- Decompress more input starting at next_in and update next_in and avail_in
accordingly. If not all input can be processed (because there is not
- enough room in the output buffer), next_in is updated and processing will
- resume at this point for the next call of inflate().
+ enough room in the output buffer), then next_in and avail_in are updated
+ accordingly, and processing will resume at this point for the next call of
+ inflate().
- - Provide more output starting at next_out and update next_out and avail_out
+ - Generate more output starting at next_out and update next_out and avail_out
accordingly. inflate() provides as much output as possible, until there is
no more input data or no more space in the output buffer (see below about
the flush parameter).
Before the call of inflate(), the application should ensure that at least
one of the actions is possible, by providing more input and/or consuming more
- output, and updating the next_* and avail_* values accordingly. The
+ output, and updating the next_* and avail_* values accordingly. If the
+ caller of inflate() does not provide both available input and available
+ output space, it is possible that there will be no progress made. The
application can consume the uncompressed output when it wants, for example
when the output buffer is full (avail_out == 0), or after each call of
inflate(). If inflate returns Z_OK and with zero avail_out, it must be
@@ -428,7 +439,7 @@ ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
gets to the end of that block, or when it runs out of data.
The Z_BLOCK option assists in appending to or combining deflate streams.
- Also to assist in this, on return inflate() will set strm->data_type to the
+ To assist in this, on return inflate() always sets strm->data_type to the
number of unused bits in the last byte taken from strm->next_in, plus 64 if
inflate() is currently decoding the last block in the deflate stream, plus
128 if inflate() returned immediately after decoding an end-of-block code or
@@ -454,7 +465,7 @@ ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
this case all pending input is processed and all pending output is flushed;
avail_out must be large enough to hold all of the uncompressed data for the
operation to complete. (The size of the uncompressed data may have been
- saved by the compressor for this purpose.) The use of Z_FINISH is not
+ saved by the compressor for this purpose.) The use of Z_FINISH is not
required to perform an inflation in one step. However it may be used to
inform inflate that a faster approach can be used for the single inflate()
call. Z_FINISH also informs inflate to not maintain a sliding window if the
@@ -476,32 +487,33 @@ ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
chosen by the compressor and returns Z_NEED_DICT; otherwise it sets
strm->adler to the Adler-32 checksum of all output produced so far (that is,
total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described
- below. At the end of the stream, inflate() checks that its computed adler32
+ below. At the end of the stream, inflate() checks that its computed Adler-32
checksum is equal to that saved by the compressor and returns Z_STREAM_END
only if the checksum is correct.
inflate() can decompress and check either zlib-wrapped or gzip-wrapped
deflate data. The header type is detected automatically, if requested when
initializing with inflateInit2(). Any information contained in the gzip
- header is not retained, so applications that need that information should
- instead use raw inflate, see inflateInit2() below, or inflateBack() and
- perform their own processing of the gzip header and trailer. When processing
+ header is not retained unless inflateGetHeader() is used. When processing
gzip-wrapped deflate data, strm->adler32 is set to the CRC-32 of the output
- producted so far. The CRC-32 is checked against the gzip trailer.
+ produced so far. The CRC-32 is checked against the gzip trailer, as is the
+ uncompressed length, modulo 2^32.
inflate() returns Z_OK if some progress has been made (more input processed
or more output produced), Z_STREAM_END if the end of the compressed data has
been reached and all uncompressed output has been produced, Z_NEED_DICT if a
preset dictionary is needed at this point, Z_DATA_ERROR if the input data was
corrupted (input stream not conforming to the zlib format or incorrect check
- value), Z_STREAM_ERROR if the stream structure was inconsistent (for example
- next_in or next_out was Z_NULL), Z_MEM_ERROR if there was not enough memory,
- Z_BUF_ERROR if no progress is possible or if there was not enough room in the
- output buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and
+ value, in which case strm->msg points to a string with a more specific
+ error), Z_STREAM_ERROR if the stream structure was inconsistent (for example
+ next_in or next_out was Z_NULL, or the state was inadvertently written over
+ by the application), Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR
+ if no progress was possible or if there was not enough room in the output
+ buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and
inflate() can be called again with more input and more output space to
continue decompressing. If Z_DATA_ERROR is returned, the application may
then call inflateSync() to look for a good compression block if a partial
- recovery of the data is desired.
+ recovery of the data is to be attempted.
*/
@@ -511,9 +523,8 @@ ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm));
This function discards any unprocessed input and does not flush any pending
output.
- inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state
- was inconsistent. In the error case, msg may be set but then points to a
- static string (which must not be deallocated).
+ inflateEnd returns Z_OK if success, or Z_STREAM_ERROR if the stream state
+ was inconsistent.
*/
@@ -544,16 +555,29 @@ ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,
compression at the expense of memory usage. The default value is 15 if
deflateInit is used instead.
+ For the current implementation of deflate(), a windowBits value of 8 (a
+ window size of 256 bytes) is not supported. As a result, a request for 8
+ will result in 9 (a 512-byte window). In that case, providing 8 to
+ inflateInit2() will result in an error when the zlib header with 9 is
+ checked against the initialization of inflate(). The remedy is to not use 8
+ with deflateInit2() with this initialization, or at least in that case use 9
+ with inflateInit2().
+
windowBits can also be -8..-15 for raw deflate. In this case, -windowBits
determines the window size. deflate() will then generate raw deflate data
- with no zlib header or trailer, and will not compute an adler32 check value.
+ with no zlib header or trailer, and will not compute a check value.
windowBits can also be greater than 15 for optional gzip encoding. Add
16 to windowBits to write a simple gzip header and trailer around the
compressed data instead of a zlib wrapper. The gzip header will have no
file name, no extra data, no comment, no modification time (set to zero), no
- header crc, and the operating system will be set to 255 (unknown). If a
- gzip stream is being written, strm->adler is a crc32 instead of an adler32.
+ header crc, and the operating system will be set to the appropriate value,
+ if the operating system was determined at compile time. If a gzip stream is
+ being written, strm->adler is a CRC-32 instead of an Adler-32.
+
+ For raw deflate or gzip encoding, a request for a 256-byte window is
+ rejected as invalid, since only the zlib header provides a means of
+ transmitting the window size to the decompressor.
The memLevel parameter specifies how much memory should be allocated
for the internal compression state. memLevel=1 uses minimum memory but is
@@ -614,12 +638,12 @@ ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,
addition, the current implementation of deflate will use at most the window
size minus 262 bytes of the provided dictionary.
- Upon return of this function, strm->adler is set to the adler32 value
+ Upon return of this function, strm->adler is set to the Adler-32 value
of the dictionary; the decompressor may later use this value to determine
- which dictionary has been used by the compressor. (The adler32 value
+ which dictionary has been used by the compressor. (The Adler-32 value
applies to the whole dictionary even if only a subset of the dictionary is
actually used by the compressor.) If a raw deflate was requested, then the
- adler32 value is not computed and strm->adler is not set.
+ Adler-32 value is not computed and strm->adler is not set.
deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a
parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is
@@ -628,6 +652,28 @@ ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,
not perform any compression: this will be done by deflate().
*/
+ZEXTERN int ZEXPORT deflateGetDictionary OF((z_streamp strm,
+ Bytef *dictionary,
+ uInt *dictLength));
+/*
+ Returns the sliding dictionary being maintained by deflate. dictLength is
+ set to the number of bytes in the dictionary, and that many bytes are copied
+ to dictionary. dictionary must have enough space, where 32768 bytes is
+ always enough. If deflateGetDictionary() is called with dictionary equal to
+ Z_NULL, then only the dictionary length is returned, and nothing is copied.
+ Similary, if dictLength is Z_NULL, then it is not set.
+
+ deflateGetDictionary() may return a length less than the window size, even
+ when more than the window size in input has been provided. It may return up
+ to 258 bytes less in that case, due to how zlib's implementation of deflate
+ manages the sliding window and lookahead for matches, where matches can be
+ up to 258 bytes long. If the application needs the last window-size bytes of
+ input, then that would need to be saved by the application outside of zlib.
+
+ deflateGetDictionary returns Z_OK on success, or Z_STREAM_ERROR if the
+ stream state is inconsistent.
+*/
+
ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest,
z_streamp source));
/*
@@ -648,10 +694,10 @@ ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest,
ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm));
/*
- This function is equivalent to deflateEnd followed by deflateInit,
- but does not free and reallocate all the internal compression state. The
- stream will keep the same compression level and any other attributes that
- may have been set by deflateInit2.
+ This function is equivalent to deflateEnd followed by deflateInit, but
+ does not free and reallocate the internal compression state. The stream
+ will leave the compression level and any other attributes that may have been
+ set unchanged.
deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
stream state was inconsistent (such as zalloc or state being Z_NULL).
@@ -662,20 +708,36 @@ ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm,
int strategy));
/*
Dynamically update the compression level and compression strategy. The
- interpretation of level and strategy is as in deflateInit2. This can be
+ interpretation of level and strategy is as in deflateInit2(). This can be
used to switch between compression and straight copy of the input data, or
to switch to a different kind of input data requiring a different strategy.
- If the compression level is changed, the input available so far is
- compressed with the old level (and may be flushed); the new level will take
- effect only at the next call of deflate().
-
- Before the call of deflateParams, the stream state must be set as for
- a call of deflate(), since the currently available input may have to be
- compressed and flushed. In particular, strm->avail_out must be non-zero.
-
- deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source
- stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR if
- strm->avail_out was zero.
+ If the compression approach (which is a function of the level) or the
+ strategy is changed, and if any input has been consumed in a previous
+ deflate() call, then the input available so far is compressed with the old
+ level and strategy using deflate(strm, Z_BLOCK). There are three approaches
+ for the compression levels 0, 1..3, and 4..9 respectively. The new level
+ and strategy will take effect at the next call of deflate().
+
+ If a deflate(strm, Z_BLOCK) is performed by deflateParams(), and it does
+ not have enough output space to complete, then the parameter change will not
+ take effect. In this case, deflateParams() can be called again with the
+ same parameters and more output space to try again.
+
+ In order to assure a change in the parameters on the first try, the
+ deflate stream should be flushed using deflate() with Z_BLOCK or other flush
+ request until strm.avail_out is not zero, before calling deflateParams().
+ Then no more input data should be provided before the deflateParams() call.
+ If this is done, the old level and strategy will be applied to the data
+ compressed before deflateParams(), and the new level and strategy will be
+ applied to the the data compressed after deflateParams().
+
+ deflateParams returns Z_OK on success, Z_STREAM_ERROR if the source stream
+ state was inconsistent or if a parameter was invalid, or Z_BUF_ERROR if
+ there was not enough output space to complete the compression of the
+ available input data before a change in the strategy or approach. Note that
+ in the case of a Z_BUF_ERROR, the parameters are not changed. A return
+ value of Z_BUF_ERROR is not fatal, in which case deflateParams() can be
+ retried with more output space.
*/
ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm,
@@ -793,7 +855,7 @@ ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,
is for use with other formats that use the deflate compressed data format
such as zip. Those formats provide their own check values. If a custom
format is developed using the raw deflate format for compressed data, it is
- recommended that a check value such as an adler32 or a crc32 be applied to
+ recommended that a check value such as an Adler-32 or a CRC-32 be applied to
the uncompressed data as is done in the zlib, gzip, and zip formats. For
most applications, the zlib format should be used as is. Note that comments
above on the use in deflateInit2() applies to the magnitude of windowBits.
@@ -802,7 +864,10 @@ ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,
32 to windowBits to enable zlib and gzip decoding with automatic header
detection, or add 16 to decode only the gzip format (the zlib format will
return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is a
- crc32 instead of an adler32.
+ CRC-32 instead of an Adler-32. Unlike the gunzip utility and gzread() (see
+ below), inflate() will not automatically decode concatenated gzip streams.
+ inflate() will return Z_STREAM_END at the end of the gzip stream. The state
+ would need to be reset to continue decoding a subsequent gzip stream.
inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
memory, Z_VERSION_ERROR if the zlib library version is incompatible with the
@@ -823,7 +888,7 @@ ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,
Initializes the decompression dictionary from the given uncompressed byte
sequence. This function must be called immediately after a call of inflate,
if that call returned Z_NEED_DICT. The dictionary chosen by the compressor
- can be determined from the adler32 value returned by that call of inflate.
+ can be determined from the Adler-32 value returned by that call of inflate.
The compressor and decompressor must use exactly the same dictionary (see
deflateSetDictionary). For raw inflate, this function can be called at any
time to set the dictionary. If the provided dictionary is smaller than the
@@ -834,7 +899,7 @@ ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,
inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a
parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is
inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the
- expected one (incorrect adler32 value). inflateSetDictionary does not
+ expected one (incorrect Adler-32 value). inflateSetDictionary does not
perform any decompression: this will be done by subsequent calls of
inflate().
*/
@@ -892,7 +957,7 @@ ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest,
ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm));
/*
This function is equivalent to inflateEnd followed by inflateInit,
- but does not free and reallocate all the internal decompression state. The
+ but does not free and reallocate the internal decompression state. The
stream will keep attributes that may have been set by inflateInit2.
inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
@@ -904,7 +969,9 @@ ZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm,
/*
This function is the same as inflateReset, but it also permits changing
the wrap and window size requests. The windowBits parameter is interpreted
- the same as it is for inflateInit2.
+ the same as it is for inflateInit2. If the window size is changed, then the
+ memory allocated for the window is freed, and the window will be reallocated
+ by inflate() if needed.
inflateReset2 returns Z_OK if success, or Z_STREAM_ERROR if the source
stream state was inconsistent (such as zalloc or state being Z_NULL), or if
@@ -956,7 +1023,7 @@ ZEXTERN long ZEXPORT inflateMark OF((z_streamp strm));
location in the input stream can be determined from avail_in and data_type
as noted in the description for the Z_BLOCK flush parameter for inflate.
- inflateMark returns the value noted above or -1 << 16 if the provided
+ inflateMark returns the value noted above, or -65536 if the provided
source stream state was inconsistent.
*/
@@ -1048,9 +1115,9 @@ ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm,
This routine would normally be used in a utility that reads zip or gzip
files and writes out uncompressed files. The utility would decode the
header and process the trailer on its own, hence this routine expects only
- the raw deflate stream to decompress. This is different from the normal
- behavior of inflate(), which expects either a zlib or gzip header and
- trailer around the deflate stream.
+ the raw deflate stream to decompress. This is different from the default
+ behavior of inflate(), which expects a zlib header and trailer around the
+ deflate stream.
inflateBack() uses two subroutines supplied by the caller that are then
called by inflateBack() for input and output. inflateBack() calls those
@@ -1059,12 +1126,12 @@ ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm,
parameters and return types are defined above in the in_func and out_func
typedefs. inflateBack() will call in(in_desc, &buf) which should return the
number of bytes of provided input, and a pointer to that input in buf. If
- there is no input available, in() must return zero--buf is ignored in that
- case--and inflateBack() will return a buffer error. inflateBack() will call
- out(out_desc, buf, len) to write the uncompressed data buf[0..len-1]. out()
- should return zero on success, or non-zero on failure. If out() returns
- non-zero, inflateBack() will return with an error. Neither in() nor out()
- are permitted to change the contents of the window provided to
+ there is no input available, in() must return zero -- buf is ignored in that
+ case -- and inflateBack() will return a buffer error. inflateBack() will
+ call out(out_desc, buf, len) to write the uncompressed data buf[0..len-1].
+ out() should return zero on success, or non-zero on failure. If out()
+ returns non-zero, inflateBack() will return with an error. Neither in() nor
+ out() are permitted to change the contents of the window provided to
inflateBackInit(), which is also the buffer that out() uses to write from.
The length written by out() will be at most the window size. Any non-zero
amount of input may be provided by in().
@@ -1092,7 +1159,7 @@ ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm,
using strm->next_in which will be Z_NULL only if in() returned an error. If
strm->next_in is not Z_NULL, then the Z_BUF_ERROR was due to out() returning
non-zero. (in() will always be called before out(), so strm->next_in is
- assured to be defined if out() returns non-zero.) Note that inflateBack()
+ assured to be defined if out() returns non-zero.) Note that inflateBack()
cannot return Z_OK.
*/
@@ -1114,7 +1181,7 @@ ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void));
7.6: size of z_off_t
Compiler, assembler, and debug options:
- 8: DEBUG
+ 8: ZLIB_DEBUG
9: ASMV or ASMINF -- use ASM code
10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention
11: 0 (reserved)
@@ -1164,7 +1231,8 @@ ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen,
the byte length of the source buffer. Upon entry, destLen is the total size
of the destination buffer, which must be at least the value returned by
compressBound(sourceLen). Upon exit, destLen is the actual size of the
- compressed buffer.
+ compressed data. compress() is equivalent to compress2() with a level
+ parameter of Z_DEFAULT_COMPRESSION.
compress returns Z_OK if success, Z_MEM_ERROR if there was not
enough memory, Z_BUF_ERROR if there was not enough room in the output
@@ -1180,7 +1248,7 @@ ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen,
length of the source buffer. Upon entry, destLen is the total size of the
destination buffer, which must be at least the value returned by
compressBound(sourceLen). Upon exit, destLen is the actual size of the
- compressed buffer.
+ compressed data.
compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
memory, Z_BUF_ERROR if there was not enough room in the output buffer,
@@ -1203,7 +1271,7 @@ ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen,
uncompressed data. (The size of the uncompressed data must have been saved
previously by the compressor and transmitted to the decompressor by some
mechanism outside the scope of this compression library.) Upon exit, destLen
- is the actual size of the uncompressed buffer.
+ is the actual size of the uncompressed data.
uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
enough memory, Z_BUF_ERROR if there was not enough room in the output
@@ -1212,6 +1280,14 @@ ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen,
buffer with the uncompressed data up to that point.
*/
+ZEXTERN int ZEXPORT uncompress2 OF((Bytef *dest, uLongf *destLen,
+ const Bytef *source, uLong *sourceLen));
+/*
+ Same as uncompress, except that sourceLen is a pointer, where the
+ length of the source is *sourceLen. On return, *sourceLen is the number of
+ source bytes consumed.
+*/
+
/* gzip file access functions */
/*
@@ -1290,10 +1366,9 @@ ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size));
default buffer size is 8192 bytes. This function must be called after
gzopen() or gzdopen(), and before any other calls that read or write the
file. The buffer memory allocation is always deferred to the first read or
- write. Two buffers are allocated, either both of the specified size when
- writing, or one of the specified size and the other twice that size when
- reading. A larger buffer size of, for example, 64K or 128K bytes will
- noticeably increase the speed of decompression (reading).
+ write. Three times that size in buffer space is allocated. A larger buffer
+ size of, for example, 64K or 128K bytes will noticeably increase the speed
+ of decompression (reading).
The new buffer size also affects the maximum length for gzprintf().
@@ -1304,10 +1379,12 @@ ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size));
ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy));
/*
Dynamically update the compression level or strategy. See the description
- of deflateInit2 for the meaning of these parameters.
+ of deflateInit2 for the meaning of these parameters. Previously provided
+ data is flushed before the parameter change.
- gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not
- opened for writing.
+ gzsetparams returns Z_OK if success, Z_STREAM_ERROR if the file was not
+ opened for writing, Z_ERRNO if there is an error writing the flushed data,
+ or Z_MEM_ERROR if there is a memory allocation error.
*/
ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len));
@@ -1335,7 +1412,35 @@ ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len));
case.
gzread returns the number of uncompressed bytes actually read, less than
- len for end of file, or -1 for error.
+ len for end of file, or -1 for error. If len is too large to fit in an int,
+ then nothing is read, -1 is returned, and the error state is set to
+ Z_STREAM_ERROR.
+*/
+
+ZEXTERN z_size_t ZEXPORT gzfread OF((voidp buf, z_size_t size, z_size_t nitems,
+ gzFile file));
+/*
+ Read up to nitems items of size size from file to buf, otherwise operating
+ as gzread() does. This duplicates the interface of stdio's fread(), with
+ size_t request and return types. If the library defines size_t, then
+ z_size_t is identical to size_t. If not, then z_size_t is an unsigned
+ integer type that can contain a pointer.
+
+ gzfread() returns the number of full items read of size size, or zero if
+ the end of the file was reached and a full item could not be read, or if
+ there was an error. gzerror() must be consulted if zero is returned in
+ order to determine if there was an error. If the multiplication of size and
+ nitems overflows, i.e. the product does not fit in a z_size_t, then nothing
+ is read, zero is returned, and the error state is set to Z_STREAM_ERROR.
+
+ In the event that the end of file is reached and only a partial item is
+ available at the end, i.e. the remaining uncompressed data length is not a
+ multiple of size, then the final partial item is nevetheless read into buf
+ and the end-of-file flag is set. The length of the partial item read is not
+ provided, but could be inferred from the result of gztell(). This behavior
+ is the same as the behavior of fread() implementations in common libraries,
+ but it prevents the direct use of gzfread() to read a concurrently written
+ file, reseting and retrying on end-of-file, when size is not 1.
*/
ZEXTERN int ZEXPORT gzwrite OF((gzFile file,
@@ -1346,19 +1451,33 @@ ZEXTERN int ZEXPORT gzwrite OF((gzFile file,
error.
*/
+ZEXTERN z_size_t ZEXPORT gzfwrite OF((voidpc buf, z_size_t size,
+ z_size_t nitems, gzFile file));
+/*
+ gzfwrite() writes nitems items of size size from buf to file, duplicating
+ the interface of stdio's fwrite(), with size_t request and return types. If
+ the library defines size_t, then z_size_t is identical to size_t. If not,
+ then z_size_t is an unsigned integer type that can contain a pointer.
+
+ gzfwrite() returns the number of full items written of size size, or zero
+ if there was an error. If the multiplication of size and nitems overflows,
+ i.e. the product does not fit in a z_size_t, then nothing is written, zero
+ is returned, and the error state is set to Z_STREAM_ERROR.
+*/
+
ZEXTERN int ZEXPORTVA gzprintf Z_ARG((gzFile file, const char *format, ...));
/*
Converts, formats, and writes the arguments to the compressed file under
control of the format string, as in fprintf. gzprintf returns the number of
- uncompressed bytes actually written, or 0 in case of error. The number of
- uncompressed bytes written is limited to 8191, or one less than the buffer
- size given to gzbuffer(). The caller should assure that this limit is not
- exceeded. If it is exceeded, then gzprintf() will return an error (0) with
- nothing written. In this case, there may also be a buffer overflow with
- unpredictable consequences, which is possible only if zlib was compiled with
- the insecure functions sprintf() or vsprintf() because the secure snprintf()
- or vsnprintf() functions were not available. This can be determined using
- zlibCompileFlags().
+ uncompressed bytes actually written, or a negative zlib error code in case
+ of error. The number of uncompressed bytes written is limited to 8191, or
+ one less than the buffer size given to gzbuffer(). The caller should assure
+ that this limit is not exceeded. If it is exceeded, then gzprintf() will
+ return an error (0) with nothing written. In this case, there may also be a
+ buffer overflow with unpredictable consequences, which is possible only if
+ zlib was compiled with the insecure functions sprintf() or vsprintf()
+ because the secure snprintf() or vsnprintf() functions were not available.
+ This can be determined using zlibCompileFlags().
*/
ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s));
@@ -1418,7 +1537,7 @@ ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush));
If the flush parameter is Z_FINISH, the remaining data is written and the
gzip stream is completed in the output. If gzwrite() is called again, a new
gzip stream will be started in the output. gzread() is able to read such
- concatented gzip streams.
+ concatenated gzip streams.
gzflush should be called only when strictly necessary because it will
degrade compression if called too often.
@@ -1572,7 +1691,7 @@ ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));
return the updated checksum. If buf is Z_NULL, this function returns the
required initial value for the checksum.
- An Adler-32 checksum is almost as reliable as a CRC32 but can be computed
+ An Adler-32 checksum is almost as reliable as a CRC-32 but can be computed
much faster.
Usage example:
@@ -1585,6 +1704,12 @@ ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));
if (adler != original_adler) error();
*/
+ZEXTERN uLong ZEXPORT adler32_z OF((uLong adler, const Bytef *buf,
+ z_size_t len));
+/*
+ Same as adler32(), but with a size_t length.
+*/
+
/*
ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2,
z_off_t len2));
@@ -1614,6 +1739,12 @@ ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len));
if (crc != original_crc) error();
*/
+ZEXTERN uLong ZEXPORT crc32_z OF((uLong adler, const Bytef *buf,
+ z_size_t len));
+/*
+ Same as crc32(), but with a size_t length.
+*/
+
/*
ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2));
@@ -1644,19 +1775,35 @@ ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits,
unsigned char FAR *window,
const char *version,
int stream_size));
-#define deflateInit(strm, level) \
- deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream))
-#define inflateInit(strm) \
- inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream))
-#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \
- deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\
- (strategy), ZLIB_VERSION, (int)sizeof(z_stream))
-#define inflateInit2(strm, windowBits) \
- inflateInit2_((strm), (windowBits), ZLIB_VERSION, \
- (int)sizeof(z_stream))
-#define inflateBackInit(strm, windowBits, window) \
- inflateBackInit_((strm), (windowBits), (window), \
- ZLIB_VERSION, (int)sizeof(z_stream))
+#ifdef Z_PREFIX_SET
+# define z_deflateInit(strm, level) \
+ deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream))
+# define z_inflateInit(strm) \
+ inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream))
+# define z_deflateInit2(strm, level, method, windowBits, memLevel, strategy) \
+ deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\
+ (strategy), ZLIB_VERSION, (int)sizeof(z_stream))
+# define z_inflateInit2(strm, windowBits) \
+ inflateInit2_((strm), (windowBits), ZLIB_VERSION, \
+ (int)sizeof(z_stream))
+# define z_inflateBackInit(strm, windowBits, window) \
+ inflateBackInit_((strm), (windowBits), (window), \
+ ZLIB_VERSION, (int)sizeof(z_stream))
+#else
+# define deflateInit(strm, level) \
+ deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream))
+# define inflateInit(strm) \
+ inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream))
+# define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \
+ deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\
+ (strategy), ZLIB_VERSION, (int)sizeof(z_stream))
+# define inflateInit2(strm, windowBits) \
+ inflateInit2_((strm), (windowBits), ZLIB_VERSION, \
+ (int)sizeof(z_stream))
+# define inflateBackInit(strm, windowBits, window) \
+ inflateBackInit_((strm), (windowBits), (window), \
+ ZLIB_VERSION, (int)sizeof(z_stream))
+#endif
#ifndef Z_SOLO
@@ -1676,10 +1823,10 @@ ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */
#ifdef Z_PREFIX_SET
# undef z_gzgetc
# define z_gzgetc(g) \
- ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : gzgetc(g))
+ ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : (gzgetc)(g))
#else
# define gzgetc(g) \
- ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : gzgetc(g))
+ ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : (gzgetc)(g))
#endif
/* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or
@@ -1737,19 +1884,16 @@ ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */
#endif /* !Z_SOLO */
-/* hack for buggy compilers */
-#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL)
- struct internal_state {int dummy;};
-#endif
-
/* undocumented functions */
ZEXTERN const char * ZEXPORT zError OF((int));
ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp));
ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table OF((void));
ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int));
+ZEXTERN int ZEXPORT inflateValidate OF((z_streamp, int));
+ZEXTERN unsigned long ZEXPORT inflateCodesUsed OF ((z_streamp));
ZEXTERN int ZEXPORT inflateResetKeep OF((z_streamp));
ZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp));
-#if defined(_WIN32) && !defined(Z_SOLO)
+#if (defined(_WIN32) || defined(__CYGWIN__)) && !defined(Z_SOLO)
ZEXTERN gzFile ZEXPORT gzopen_w OF((const wchar_t *path,
const char *mode));
#endif
diff --git a/contrib/zlib/zlib.map b/contrib/zlib/zlib.map
index 55c6647..40fa9db 100644
--- a/contrib/zlib/zlib.map
+++ b/contrib/zlib/zlib.map
@@ -1,83 +1,94 @@
-ZLIB_1.2.0 {
- global:
- compressBound;
- deflateBound;
- inflateBack;
- inflateBackEnd;
- inflateBackInit_;
- inflateCopy;
- local:
- deflate_copyright;
- inflate_copyright;
- inflate_fast;
- inflate_table;
- zcalloc;
- zcfree;
- z_errmsg;
- gz_error;
- gz_intmax;
- _*;
-};
-
-ZLIB_1.2.0.2 {
- gzclearerr;
- gzungetc;
- zlibCompileFlags;
-} ZLIB_1.2.0;
-
-ZLIB_1.2.0.8 {
- deflatePrime;
-} ZLIB_1.2.0.2;
-
-ZLIB_1.2.2 {
- adler32_combine;
- crc32_combine;
- deflateSetHeader;
- inflateGetHeader;
-} ZLIB_1.2.0.8;
-
-ZLIB_1.2.2.3 {
- deflateTune;
- gzdirect;
-} ZLIB_1.2.2;
-
-ZLIB_1.2.2.4 {
- inflatePrime;
-} ZLIB_1.2.2.3;
-
-ZLIB_1.2.3.3 {
- adler32_combine64;
- crc32_combine64;
- gzopen64;
- gzseek64;
- gztell64;
- inflateUndermine;
-} ZLIB_1.2.2.4;
-
-ZLIB_1.2.3.4 {
- inflateReset2;
- inflateMark;
-} ZLIB_1.2.3.3;
-
-ZLIB_1.2.3.5 {
- gzbuffer;
- gzoffset;
- gzoffset64;
- gzclose_r;
- gzclose_w;
-} ZLIB_1.2.3.4;
-
-ZLIB_1.2.5.1 {
- deflatePending;
-} ZLIB_1.2.3.5;
-
-ZLIB_1.2.5.2 {
- deflateResetKeep;
- gzgetc_;
- inflateResetKeep;
-} ZLIB_1.2.5.1;
-
-ZLIB_1.2.7.1 {
- inflateGetDictionary;
- gzvprintf;
-} ZLIB_1.2.5.2;
+ZLIB_1.2.0 {
+ global:
+ compressBound;
+ deflateBound;
+ inflateBack;
+ inflateBackEnd;
+ inflateBackInit_;
+ inflateCopy;
+ local:
+ deflate_copyright;
+ inflate_copyright;
+ inflate_fast;
+ inflate_table;
+ zcalloc;
+ zcfree;
+ z_errmsg;
+ gz_error;
+ gz_intmax;
+ _*;
+};
+
+ZLIB_1.2.0.2 {
+ gzclearerr;
+ gzungetc;
+ zlibCompileFlags;
+} ZLIB_1.2.0;
+
+ZLIB_1.2.0.8 {
+ deflatePrime;
+} ZLIB_1.2.0.2;
+
+ZLIB_1.2.2 {
+ adler32_combine;
+ crc32_combine;
+ deflateSetHeader;
+ inflateGetHeader;
+} ZLIB_1.2.0.8;
+
+ZLIB_1.2.2.3 {
+ deflateTune;
+ gzdirect;
+} ZLIB_1.2.2;
+
+ZLIB_1.2.2.4 {
+ inflatePrime;
+} ZLIB_1.2.2.3;
+
+ZLIB_1.2.3.3 {
+ adler32_combine64;
+ crc32_combine64;
+ gzopen64;
+ gzseek64;
+ gztell64;
+ inflateUndermine;
+} ZLIB_1.2.2.4;
+
+ZLIB_1.2.3.4 {
+ inflateReset2;
+ inflateMark;
+} ZLIB_1.2.3.3;
+
+ZLIB_1.2.3.5 {
+ gzbuffer;
+ gzoffset;
+ gzoffset64;
+ gzclose_r;
+ gzclose_w;
+} ZLIB_1.2.3.4;
+
+ZLIB_1.2.5.1 {
+ deflatePending;
+} ZLIB_1.2.3.5;
+
+ZLIB_1.2.5.2 {
+ deflateResetKeep;
+ gzgetc_;
+ inflateResetKeep;
+} ZLIB_1.2.5.1;
+
+ZLIB_1.2.7.1 {
+ inflateGetDictionary;
+ gzvprintf;
+} ZLIB_1.2.5.2;
+
+ZLIB_1.2.9 {
+ inflateCodesUsed;
+ inflateValidate;
+ uncompress2;
+ gzfread;
+ gzfwrite;
+ deflateGetDictionary;
+ adler32_z;
+ crc32_z;
+} ZLIB_1.2.7.1;
diff --git a/contrib/zlib/zutil.c b/contrib/zlib/zutil.c
index 23d2ebe..a76c6b0 100644
--- a/contrib/zlib/zutil.c
+++ b/contrib/zlib/zutil.c
@@ -1,5 +1,5 @@
/* zutil.c -- target dependent utility functions for the compression library
- * Copyright (C) 1995-2005, 2010, 2011, 2012 Jean-loup Gailly.
+ * Copyright (C) 1995-2017 Jean-loup Gailly
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -10,21 +10,18 @@
# include "gzguts.h"
#endif
-#ifndef NO_DUMMY_DECL
-struct internal_state {int dummy;}; /* for buggy compilers */
-#endif
-
z_const char * const z_errmsg[10] = {
-"need dictionary", /* Z_NEED_DICT 2 */
-"stream end", /* Z_STREAM_END 1 */
-"", /* Z_OK 0 */
-"file error", /* Z_ERRNO (-1) */
-"stream error", /* Z_STREAM_ERROR (-2) */
-"data error", /* Z_DATA_ERROR (-3) */
-"insufficient memory", /* Z_MEM_ERROR (-4) */
-"buffer error", /* Z_BUF_ERROR (-5) */
-"incompatible version",/* Z_VERSION_ERROR (-6) */
-""};
+ (z_const char *)"need dictionary", /* Z_NEED_DICT 2 */
+ (z_const char *)"stream end", /* Z_STREAM_END 1 */
+ (z_const char *)"", /* Z_OK 0 */
+ (z_const char *)"file error", /* Z_ERRNO (-1) */
+ (z_const char *)"stream error", /* Z_STREAM_ERROR (-2) */
+ (z_const char *)"data error", /* Z_DATA_ERROR (-3) */
+ (z_const char *)"insufficient memory", /* Z_MEM_ERROR (-4) */
+ (z_const char *)"buffer error", /* Z_BUF_ERROR (-5) */
+ (z_const char *)"incompatible version",/* Z_VERSION_ERROR (-6) */
+ (z_const char *)""
+};
const char * ZEXPORT zlibVersion()
@@ -61,7 +58,7 @@ uLong ZEXPORT zlibCompileFlags()
case 8: flags += 2 << 6; break;
default: flags += 3 << 6;
}
-#ifdef DEBUG
+#ifdef ZLIB_DEBUG
flags += 1 << 8;
#endif
#if defined(ASMV) || defined(ASMINF)
@@ -115,8 +112,8 @@ uLong ZEXPORT zlibCompileFlags()
return flags;
}
-#ifdef DEBUG
-
+#ifdef ZLIB_DEBUG
+#include <stdlib.h>
# ifndef verbose
# define verbose 0
# endif
@@ -219,9 +216,11 @@ local ptr_table table[MAX_PTR];
voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, unsigned items, unsigned size)
{
- voidpf buf = opaque; /* just to make some compilers happy */
+ voidpf buf;
ulg bsize = (ulg)items*size;
+ (void)opaque;
+
/* If we allocate less than 65520 bytes, we assume that farmalloc
* will return a usable pointer which doesn't have to be normalized.
*/
@@ -244,6 +243,9 @@ voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, unsigned items, unsigned size)
void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr)
{
int n;
+
+ (void)opaque;
+
if (*(ush*)&ptr != 0) { /* object < 64K */
farfree(ptr);
return;
@@ -259,7 +261,6 @@ void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr)
next_ptr--;
return;
}
- ptr = opaque; /* just to make some compilers happy */
Assert(0, "zcfree: ptr not found");
}
@@ -278,13 +279,13 @@ void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr)
voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, uInt items, uInt size)
{
- if (opaque) opaque = 0; /* to make compiler happy */
+ (void)opaque;
return _halloc((long)items, size);
}
void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr)
{
- if (opaque) opaque = 0; /* to make compiler happy */
+ (void)opaque;
_hfree(ptr);
}
@@ -306,7 +307,7 @@ voidpf ZLIB_INTERNAL zcalloc (opaque, items, size)
unsigned items;
unsigned size;
{
- if (opaque) items += size - size; /* make compiler happy */
+ (void)opaque;
return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) :
(voidpf)calloc(items, size);
}
@@ -315,8 +316,8 @@ void ZLIB_INTERNAL zcfree (opaque, ptr)
voidpf opaque;
voidpf ptr;
{
+ (void)opaque;
free(ptr);
- if (opaque) return; /* make compiler happy */
}
#endif /* MY_ZCALLOC */
diff --git a/contrib/zlib/zutil.h b/contrib/zlib/zutil.h
index 24ab06b..b079ea6 100644
--- a/contrib/zlib/zutil.h
+++ b/contrib/zlib/zutil.h
@@ -1,5 +1,5 @@
/* zutil.h -- internal interface and configuration of the compression library
- * Copyright (C) 1995-2013 Jean-loup Gailly.
+ * Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -36,7 +36,9 @@
#ifndef local
# define local static
#endif
-/* compile with -Dlocal if your debugger can't find static symbols */
+/* since "static" is used to mean two completely different things in C, we
+ define "local" for the non-static meaning of "static", for readability
+ (compile with -Dlocal if your debugger can't find static symbols) */
typedef unsigned char uch;
typedef uch FAR uchf;
@@ -98,28 +100,38 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
#endif
#ifdef AMIGA
-# define OS_CODE 0x01
+# define OS_CODE 1
#endif
#if defined(VAXC) || defined(VMS)
-# define OS_CODE 0x02
+# define OS_CODE 2
# define F_OPEN(name, mode) \
fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")
#endif
+#ifdef __370__
+# if __TARGET_LIB__ < 0x20000000
+# define OS_CODE 4
+# elif __TARGET_LIB__ < 0x40000000
+# define OS_CODE 11
+# else
+# define OS_CODE 8
+# endif
+#endif
+
#if defined(ATARI) || defined(atarist)
-# define OS_CODE 0x05
+# define OS_CODE 5
#endif
#ifdef OS2
-# define OS_CODE 0x06
+# define OS_CODE 6
# if defined(M_I86) && !defined(Z_SOLO)
# include <malloc.h>
# endif
#endif
#if defined(MACOS) || defined(TARGET_OS_MAC)
-# define OS_CODE 0x07
+# define OS_CODE 7
# ifndef Z_SOLO
# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
# include <unix.h> /* for fdopen */
@@ -131,18 +143,24 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
# endif
#endif
-#ifdef TOPS20
-# define OS_CODE 0x0a
+#ifdef __acorn
+# define OS_CODE 13
#endif
-#ifdef WIN32
-# ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */
-# define OS_CODE 0x0b
-# endif
+#if defined(WIN32) && !defined(__CYGWIN__)
+# define OS_CODE 10
+#endif
+
+#ifdef _BEOS_
+# define OS_CODE 16
+#endif
+
+#ifdef __TOS_OS400__
+# define OS_CODE 18
#endif
-#ifdef __50SERIES /* Prime/PRIMOS */
-# define OS_CODE 0x0f
+#ifdef __APPLE__
+# define OS_CODE 19
#endif
#if defined(_BEOS_) || defined(RISCOS)
@@ -177,7 +195,7 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
/* common defaults */
#ifndef OS_CODE
-# define OS_CODE 0x03 /* assume Unix */
+# define OS_CODE 3 /* assume Unix */
#endif
#ifndef F_OPEN
@@ -216,7 +234,7 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
#endif
/* Diagnostic functions */
-#ifdef DEBUG
+#ifdef ZLIB_DEBUG
# include <stdio.h>
extern int ZLIB_INTERNAL z_verbose;
extern void ZLIB_INTERNAL z_error OF((char *m));
diff --git a/crypto/openssh/auth.c b/crypto/openssh/auth.c
index 1259385..c5dac04 100644
--- a/crypto/openssh/auth.c
+++ b/crypto/openssh/auth.c
@@ -295,8 +295,8 @@ auth_log(Authctxt *authctxt, int authenticated, int partial,
authmsg = "Partial";
else {
authmsg = authenticated ? "Accepted" : "Failed";
- BLACKLIST_NOTIFY(authenticated ?
- BLACKLIST_AUTH_OK : BLACKLIST_AUTH_FAIL);
+ if (authenticated)
+ BLACKLIST_NOTIFY(BLACKLIST_AUTH_OK);
}
authlog("%s %s%s%s for %s%.100s from %.200s port %d %s%s%s",
diff --git a/etc/mtree/BSD.tests.dist b/etc/mtree/BSD.tests.dist
index 1f22bf9..ac2f305 100644
--- a/etc/mtree/BSD.tests.dist
+++ b/etc/mtree/BSD.tests.dist
@@ -582,8 +582,8 @@
..
..
..
- bsdcat
- ..
+ bsdcat
+ ..
calendar
..
cmp
diff --git a/etc/mtree/BSD.var.dist b/etc/mtree/BSD.var.dist
index e6dfa50..e522549 100644
--- a/etc/mtree/BSD.var.dist
+++ b/etc/mtree/BSD.var.dist
@@ -28,7 +28,7 @@
/set gname=wheel
backups
..
- cache mode=0755
+ cache mode=0755
..
crash
..
diff --git a/gnu/usr.bin/gdb/Makefile.inc b/gnu/usr.bin/gdb/Makefile.inc
index 34dc907..574425d 100644
--- a/gnu/usr.bin/gdb/Makefile.inc
+++ b/gnu/usr.bin/gdb/Makefile.inc
@@ -5,19 +5,17 @@ VENDOR= marcel
PACKAGE= gdb
-BMAKE_GDB= ${.CURDIR}/..
-BMAKE_ROOT= ${BMAKE_GDB}/..
+BMAKE_GDB= ${.CURDIR:H}
+BMAKE_ROOT= ${BMAKE_GDB:H}
BMAKE_BU= ${BMAKE_ROOT}/binutils
-CNTRB_ROOT= ${BMAKE_ROOT}/../../contrib
-CNTRB_BU= ${CNTRB_ROOT}/binutils
-CNTRB_GDB= ${CNTRB_ROOT}/gdb
-CNTRB_RL= ${CNTRB_ROOT}/libreadline
+CNTRB_BU= ${SRCTOP}/contrib/binutils
+CNTRB_GDB= ${SRCTOP}/contrib/gdb
+CNTRB_RL= ${SRCTOP}/contrib/libreadline
-OBJ_ROOT= ${.OBJDIR}/../..
-OBJ_BU= ${OBJ_ROOT}/binutils
-OBJ_GDB= ${OBJ_ROOT}/gdb
-OBJ_RL= ${OBJ_ROOT}/../lib/libreadline/readline
+OBJ_BU= ${OBJTOP}/gnu/usr.bin/binutils
+OBJ_GDB= ${OBJTOP}/gnu/usr.bin/gdb
+OBJ_RL= ${OBJTOP}/gnu/lib/libreadline/readline
# These assignments duplicate much of the functionality of
# MACHINE_CPUARCH, but there's no easy way to export make functions...
@@ -47,12 +45,12 @@ CFLAGS+= -I${CNTRB_GDB}/gdb/config
CFLAGS+= -I${CNTRB_BU}/include
CFLAGS+= -I${CNTRB_GDB}/include
CFLAGS+= -I${CNTRB_BU}/bfd
-CFLAGS+= -I${OBJ_RL}/..
+CFLAGS+= -I${OBJ_RL:H}
GENSRCS+= nm.h tm.h
.if defined(GDB_CROSS_DEBUGGER)
-CFLAGS+= -DCROSS_DEBUGGER -I${BMAKE_ROOT}/../..
+CFLAGS+= -DCROSS_DEBUGGER -I${BMAKE_ROOT:H:H}
GDB_SUFFIX= -${TARGET_ARCH}
MAN=
.endif
diff --git a/gnu/usr.bin/gdb/gdbserver/Makefile b/gnu/usr.bin/gdb/gdbserver/Makefile
index f5cfd4c..fa46e6d 100644
--- a/gnu/usr.bin/gdb/gdbserver/Makefile
+++ b/gnu/usr.bin/gdb/gdbserver/Makefile
@@ -3,7 +3,7 @@
# Not elf specific so don't install in /usr/libexec/elf
BINDIR=/usr/bin
-GDBDIR= ${.CURDIR}/../../../../contrib/gdb
+GDBDIR= ${SRCTOP}/contrib/gdb
.PATH: ${GDBDIR}/gdb/signals
.PATH: ${GDBDIR}/gdb/gdbserver
.PATH: ${GDBDIR}/gdb
diff --git a/include/stdlib.h b/include/stdlib.h
index 9771d01..1de702f 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -315,7 +315,7 @@ void srandomdev(void);
long long
strtonum(const char *, long long, long long, const char **);
-/* Deprecated interfaces, to be removed in FreeBSD 6.0. */
+/* Deprecated interfaces, to be removed. */
__int64_t
strtoq(const char *, char **, int);
__uint64_t
diff --git a/lib/csu/aarch64/Makefile b/lib/csu/aarch64/Makefile
index 9747619..cd04b54 100644
--- a/lib/csu/aarch64/Makefile
+++ b/lib/csu/aarch64/Makefile
@@ -1,12 +1,12 @@
# $FreeBSD$
-.PATH: ${.CURDIR}/../common
+.PATH: ${.CURDIR:H}/common
SRCS= crt1.c crti.S crtn.S
OBJS= ${SRCS:N*.h:R:S/$/.o/g}
OBJS+= Scrt1.o gcrt1.o
-CFLAGS+= -I${.CURDIR}/../common \
- -I${.CURDIR}/../../libc/include
+CFLAGS+= -I${.CURDIR:H}/common \
+ -I${SRCTOP}/lib/libc/include
FILES= ${OBJS}
FILESMODE= ${LIBMODE}
diff --git a/lib/csu/amd64/Makefile b/lib/csu/amd64/Makefile
index e9ca6b9..1c4b0ed 100644
--- a/lib/csu/amd64/Makefile
+++ b/lib/csu/amd64/Makefile
@@ -1,12 +1,12 @@
# $FreeBSD$
-.PATH: ${.CURDIR}/../common
+.PATH: ${.CURDIR:H}/common
SRCS= crt1.c crti.S crtn.S
OBJS= ${SRCS:N*.h:R:S/$/.o/g}
OBJS+= Scrt1.o gcrt1.o
-CFLAGS+= -I${.CURDIR}/../common \
- -I${.CURDIR}/../../libc/include
+CFLAGS+= -I${.CURDIR:H}/common \
+ -I${SRCTOP}/lib/libc/include
CFLAGS+= -fno-omit-frame-pointer
FILES= ${OBJS}
diff --git a/lib/csu/arm/Makefile b/lib/csu/arm/Makefile
index 1b3a6f8..c4cbce7 100644
--- a/lib/csu/arm/Makefile
+++ b/lib/csu/arm/Makefile
@@ -1,12 +1,12 @@
# $FreeBSD$
-.PATH: ${.CURDIR}/../common
+.PATH: ${.CURDIR:H}/common
SRCS= crt1.c crti.S crtn.S
OBJS= ${SRCS:N*.h:R:S/$/.o/g}
OBJS+= Scrt1.o gcrt1.o
-CFLAGS+= -I${.CURDIR}/../common \
- -I${.CURDIR}/../../libc/include
+CFLAGS+= -I${.CURDIR:H}/common \
+ -I${SRCTOP}/lib/libc/include
STATIC_CFLAGS+= -mlong-calls
FILES= ${OBJS}
diff --git a/lib/csu/i386/Makefile b/lib/csu/i386/Makefile
index d64f803..ca54614 100644
--- a/lib/csu/i386/Makefile
+++ b/lib/csu/i386/Makefile
@@ -1,12 +1,12 @@
# $FreeBSD$
-.PATH: ${.CURDIR}/../common
+.PATH: ${.CURDIR:H}/common
SRCS= crti.S crtn.S
OBJS= ${SRCS:N*.h:R:S/$/.o/g}
OBJS+= gcrt1.o crt1.o Scrt1.o
-CFLAGS+= -I${.CURDIR}/../common \
- -I${.CURDIR}/../../libc/include
+CFLAGS+= -I${.CURDIR:H}/common \
+ -I${SRCTOP}/lib/libc/include
FILES= ${OBJS}
FILESMODE= ${LIBMODE}
diff --git a/lib/csu/mips/Makefile b/lib/csu/mips/Makefile
index 9747619..cd04b54 100644
--- a/lib/csu/mips/Makefile
+++ b/lib/csu/mips/Makefile
@@ -1,12 +1,12 @@
# $FreeBSD$
-.PATH: ${.CURDIR}/../common
+.PATH: ${.CURDIR:H}/common
SRCS= crt1.c crti.S crtn.S
OBJS= ${SRCS:N*.h:R:S/$/.o/g}
OBJS+= Scrt1.o gcrt1.o
-CFLAGS+= -I${.CURDIR}/../common \
- -I${.CURDIR}/../../libc/include
+CFLAGS+= -I${.CURDIR:H}/common \
+ -I${SRCTOP}/lib/libc/include
FILES= ${OBJS}
FILESMODE= ${LIBMODE}
diff --git a/lib/csu/powerpc/Makefile b/lib/csu/powerpc/Makefile
index 9747619..cd04b54 100644
--- a/lib/csu/powerpc/Makefile
+++ b/lib/csu/powerpc/Makefile
@@ -1,12 +1,12 @@
# $FreeBSD$
-.PATH: ${.CURDIR}/../common
+.PATH: ${.CURDIR:H}/common
SRCS= crt1.c crti.S crtn.S
OBJS= ${SRCS:N*.h:R:S/$/.o/g}
OBJS+= Scrt1.o gcrt1.o
-CFLAGS+= -I${.CURDIR}/../common \
- -I${.CURDIR}/../../libc/include
+CFLAGS+= -I${.CURDIR:H}/common \
+ -I${SRCTOP}/lib/libc/include
FILES= ${OBJS}
FILESMODE= ${LIBMODE}
diff --git a/lib/csu/powerpc64/Makefile b/lib/csu/powerpc64/Makefile
index a97ef1e..104ab20 100644
--- a/lib/csu/powerpc64/Makefile
+++ b/lib/csu/powerpc64/Makefile
@@ -1,12 +1,12 @@
# $FreeBSD$
-.PATH: ${.CURDIR}/../common
+.PATH: ${.CURDIR:H}/common
SRCS= crt1.c crti.S crtn.S
OBJS= ${SRCS:N*.h:R:S/$/.o/g}
OBJS+= Scrt1.o gcrt1.o
-CFLAGS+= -I${.CURDIR}/../common \
- -I${.CURDIR}/../../libc/include \
+CFLAGS+= -I${.CURDIR:H}/common \
+ -I${SRCTOP}/lib/libc/include \
-mlongcall
# XXX: See the log for r232932 as to why the above -mlongcall is needed. Since
diff --git a/lib/csu/riscv/Makefile b/lib/csu/riscv/Makefile
index 9747619..cd04b54 100644
--- a/lib/csu/riscv/Makefile
+++ b/lib/csu/riscv/Makefile
@@ -1,12 +1,12 @@
# $FreeBSD$
-.PATH: ${.CURDIR}/../common
+.PATH: ${.CURDIR:H}/common
SRCS= crt1.c crti.S crtn.S
OBJS= ${SRCS:N*.h:R:S/$/.o/g}
OBJS+= Scrt1.o gcrt1.o
-CFLAGS+= -I${.CURDIR}/../common \
- -I${.CURDIR}/../../libc/include
+CFLAGS+= -I${.CURDIR:H}/common \
+ -I${SRCTOP}/lib/libc/include
FILES= ${OBJS}
FILESMODE= ${LIBMODE}
diff --git a/lib/csu/sparc64/Makefile b/lib/csu/sparc64/Makefile
index 0074cb9..874c377 100644
--- a/lib/csu/sparc64/Makefile
+++ b/lib/csu/sparc64/Makefile
@@ -1,11 +1,12 @@
# $FreeBSD$
-.PATH: ${.CURDIR}/../common
+.PATH: ${.CURDIR:H}/common
SRCS= crt1.c crti.S crtn.S
OBJS= ${SRCS:N*.h:R:S/$/.o/g}
OBJS+= Scrt1.o gcrt1.o
-CFLAGS+= -I${.CURDIR}/../common -I${.CURDIR}/../../libc/include
+CFLAGS+= -I${.CURDIR:H}/common \
+ -I${SRCTOP}/lib/libc/include
FILES= ${OBJS}
FILESMODE= ${LIBMODE}
diff --git a/lib/libalias/libalias/Makefile b/lib/libalias/libalias/Makefile
index feed9a8..60c59a3 100644
--- a/lib/libalias/libalias/Makefile
+++ b/lib/libalias/libalias/Makefile
@@ -1,6 +1,6 @@
# $FreeBSD$
-.PATH: ${.CURDIR}/../../../sys/netinet/libalias
+.PATH: ${SRCTOP}/sys/netinet/libalias
PACKAGE=lib${LIB}
LIB= alias
diff --git a/lib/libalias/modules/Makefile b/lib/libalias/modules/Makefile
index dc66ad2..24333ea6 100644
--- a/lib/libalias/modules/Makefile
+++ b/lib/libalias/modules/Makefile
@@ -1,6 +1,6 @@
# $FreeBSD$
-.include "${.CURDIR}/../../../sys/modules/libalias/modules/modules.inc"
+.include "${SRCTOP}/sys/modules/libalias/modules/modules.inc"
SUBDIR= ${MODULES}
diff --git a/lib/libalias/modules/Makefile.inc b/lib/libalias/modules/Makefile.inc
index 23df02d..730f374 100644
--- a/lib/libalias/modules/Makefile.inc
+++ b/lib/libalias/modules/Makefile.inc
@@ -1,6 +1,6 @@
# $FreeBSD$
-.PATH: ${.CURDIR}/../../../../sys/netinet/libalias
+.PATH: ${SRCTOP}/sys/netinet/libalias
SHLIBDIR?= /lib
LIB?= alias_${NAME}
diff --git a/lib/libarchive/Makefile b/lib/libarchive/Makefile
index ce390f8..a8f4874 100644
--- a/lib/libarchive/Makefile
+++ b/lib/libarchive/Makefile
@@ -2,7 +2,7 @@
.include <src.opts.mk>
PACKAGE=lib${LIB}
-_LIBARCHIVEDIR= ${.CURDIR}/../../contrib/libarchive
+_LIBARCHIVEDIR= ${SRCTOP}/contrib/libarchive
LIB= archive
diff --git a/lib/libarchive/config_freebsd.h b/lib/libarchive/config_freebsd.h
index eeb1076..4fb7b86 100644
--- a/lib/libarchive/config_freebsd.h
+++ b/lib/libarchive/config_freebsd.h
@@ -41,6 +41,7 @@
#define HAVE_ACL_SET_FILE 1
#define HAVE_ACL_SET_LINK_NP 1
#define HAVE_ACL_USER 1
+#define HAVE_ACL_TYPE_NFS4 1
#define HAVE_ARC4RANDOM_BUF 1
#define HAVE_EXTATTR_GET_FILE 1
#define HAVE_EXTATTR_LIST_FILE 1
diff --git a/lib/libarchive/tests/Makefile b/lib/libarchive/tests/Makefile
index b3ce0d4..14ab70c 100644
--- a/lib/libarchive/tests/Makefile
+++ b/lib/libarchive/tests/Makefile
@@ -20,11 +20,12 @@ CFLAGS+= -DHAVE_LIBLZMA=1 -DHAVE_LZMA_H=1
.PATH: ${_LIBARCHIVEDIR}/libarchive/test
TESTS_SRCS= \
- test_acl_freebsd_nfs4.c \
- test_acl_freebsd_posix1e.c \
test_acl_nfs4.c \
test_acl_pax.c \
+ test_acl_platform_nfs4.c \
+ test_acl_platform_posix1e.c \
test_acl_posix1e.c \
+ test_acl_text.c \
test_archive_api_feature.c \
test_archive_clear_error.c \
test_archive_cmdline.c \
@@ -73,7 +74,7 @@ TESTS_SRCS= \
test_compat_plexus_archiver_tar.c \
test_compat_solaris_tar_acl.c \
test_compat_solaris_pax_sparse.c \
- test_compat_star_acl_posix1e.c \
+ test_compat_star_acl.c \
test_compat_tar_hardlink.c \
test_compat_uudecode.c \
test_compat_uudecode_large.c \
@@ -315,9 +316,9 @@ list.h: ${TESTS_SRCS} Makefile
@mv ${.TARGET}.tmp ${.TARGET}
CLEANTESTS+= list.h list.h.tmp
-
${PACKAGE}FILES+= README
-${PACKAGE}FILES+= test_acl_pax.tar.uu
+${PACKAGE}FILES+= test_acl_pax_posix1e.tar.uu
+${PACKAGE}FILES+= test_acl_pax_nfs4.tar.uu
${PACKAGE}FILES+= test_archive_string_conversion.txt.Z.uu
${PACKAGE}FILES+= test_compat_bzip2_1.tbz.uu
${PACKAGE}FILES+= test_compat_bzip2_2.tbz.uu
@@ -354,6 +355,7 @@ ${PACKAGE}FILES+= test_compat_plexus_archiver_tar.tar.uu
${PACKAGE}FILES+= test_compat_solaris_pax_sparse_1.pax.Z.uu
${PACKAGE}FILES+= test_compat_solaris_pax_sparse_2.pax.Z.uu
${PACKAGE}FILES+= test_compat_solaris_tar_acl.tar.uu
+${PACKAGE}FILES+= test_compat_star_acl_nfs4.tar.uu
${PACKAGE}FILES+= test_compat_star_acl_posix1e.tar.uu
${PACKAGE}FILES+= test_compat_tar_hardlink_1.tar.uu
${PACKAGE}FILES+= test_compat_uudecode_large.tar.Z.uu
diff --git a/lib/libauditd/Makefile b/lib/libauditd/Makefile
index f8ed80a..2df9fa8 100644
--- a/lib/libauditd/Makefile
+++ b/lib/libauditd/Makefile
@@ -3,7 +3,7 @@
#
PACKAGE=lib${LIB}
-OPENBSMDIR= ${.CURDIR}/../../contrib/openbsm
+OPENBSMDIR= ${SRCTOP}/contrib/openbsm
_LIBAUDITDDIR= ${OPENBSMDIR}/libauditd
_LIBBSMDIR= ${OPENBSMDIR}/libbsm
diff --git a/lib/libbegemot/Makefile b/lib/libbegemot/Makefile
index d278385..c5d3bb8 100644
--- a/lib/libbegemot/Makefile
+++ b/lib/libbegemot/Makefile
@@ -1,6 +1,6 @@
# $FreeBSD$
-LIBBEGEMOT_DIR=${.CURDIR}/../../contrib/libbegemot
+LIBBEGEMOT_DIR=${SRCTOP}/contrib/libbegemot
PACKAGE=lib${LIB}
.PATH: ${LIBBEGEMOT_DIR}
diff --git a/lib/libblocksruntime/Makefile b/lib/libblocksruntime/Makefile
index 5933fb5..a7b04d8 100644
--- a/lib/libblocksruntime/Makefile
+++ b/lib/libblocksruntime/Makefile
@@ -6,7 +6,7 @@ SHLIB_MAJOR=0
CFLAGS+=-I${.CURDIR}
WARNS?= 2
-.PATH: ${.CURDIR}/../../contrib/compiler-rt/lib/BlocksRuntime
+.PATH: ${SRCTOP}/contrib/compiler-rt/lib/BlocksRuntime
INCS= Block.h Block_private.h
SRCS= data.c runtime.c
diff --git a/lib/libbluetooth/Makefile b/lib/libbluetooth/Makefile
index a8573ec..f6273ab 100644
--- a/lib/libbluetooth/Makefile
+++ b/lib/libbluetooth/Makefile
@@ -6,7 +6,7 @@ LIB= bluetooth
MAN= bluetooth.3
WARNS?= 2
-CFLAGS+= -I${.CURDIR} -I${.CURDIR}/../../sys
+CFLAGS+= -I${.CURDIR} -I${SRCTOP}/sys
SHLIB_MAJOR= 4
diff --git a/lib/libbsm/Makefile b/lib/libbsm/Makefile
index 4416227..e9bd28e 100644
--- a/lib/libbsm/Makefile
+++ b/lib/libbsm/Makefile
@@ -3,7 +3,7 @@
#
PACKAGE= lib${LIB}
-OPENBSMDIR= ${.CURDIR}/../../contrib/openbsm
+OPENBSMDIR= ${SRCTOP}/contrib/openbsm
_LIBBSMDIR= ${OPENBSMDIR}/libbsm
LIB= bsm
diff --git a/lib/libbsnmp/libbsnmp/Makefile b/lib/libbsnmp/libbsnmp/Makefile
index 67a17e1..fcca2ed 100644
--- a/lib/libbsnmp/libbsnmp/Makefile
+++ b/lib/libbsnmp/libbsnmp/Makefile
@@ -4,7 +4,7 @@
.include <src.opts.mk>
-CONTRIB= ${.CURDIR}/../../../contrib/bsnmp/lib
+CONTRIB= ${SRCTOP}/contrib/bsnmp/lib
.PATH: ${CONTRIB}
LIB= bsnmp
diff --git a/lib/libbz2/Makefile b/lib/libbz2/Makefile
index 93c724e..cbdb87c 100644
--- a/lib/libbz2/Makefile
+++ b/lib/libbz2/Makefile
@@ -1,7 +1,7 @@
# $FreeBSD$
PACKAGE= lib${LIB}
-BZ2DIR= ${.CURDIR}/../../contrib/bzip2
+BZ2DIR= ${SRCTOP}/contrib/bzip2
.PATH: ${BZ2DIR}
LIB= bz2
diff --git a/lib/libc++/Makefile b/lib/libc++/Makefile
index 1a50657..38b0ad2 100644
--- a/lib/libc++/Makefile
+++ b/lib/libc++/Makefile
@@ -3,9 +3,9 @@
.include <src.opts.mk>
PACKAGE= clibs
-_LIBCXXRTDIR= ${.CURDIR}/../../contrib/libcxxrt
-HDRDIR= ${.CURDIR}/../../contrib/libc++/include
-SRCDIR= ${.CURDIR}/../../contrib/libc++/src
+_LIBCXXRTDIR= ${SRCTOP}/contrib/libcxxrt
+HDRDIR= ${SRCTOP}/contrib/libc++/include
+SRCDIR= ${SRCTOP}/contrib/libc++/src
CXXINCLUDEDIR= ${INCLUDEDIR}/c++/v${SHLIB_MAJOR}
.if ${MACHINE_CPUARCH} == "arm"
STATIC_CXXFLAGS+= -mlong-calls
diff --git a/lib/libc/db/hash/hash_page.c b/lib/libc/db/hash/hash_page.c
index a2bb7cf..ec2d184 100644
--- a/lib/libc/db/hash/hash_page.c
+++ b/lib/libc/db/hash/hash_page.c
@@ -572,7 +572,9 @@ __get_page(HTAB *hashp, char *p, u_int32_t bucket, int is_bucket, int is_disk,
int
__put_page(HTAB *hashp, char *p, u_int32_t bucket, int is_bucket, int is_bitmap)
{
- int fd, page, size, wsize;
+ int fd, page, size;
+ ssize_t wsize;
+ char pbuf[MAX_BSIZE];
size = hashp->BSIZE;
if ((hashp->fp == -1) && open_temp(hashp))
@@ -582,15 +584,18 @@ __put_page(HTAB *hashp, char *p, u_int32_t bucket, int is_bucket, int is_bitmap)
if (hashp->LORDER != BYTE_ORDER) {
int i, max;
+ memcpy(pbuf, p, size);
if (is_bitmap) {
max = hashp->BSIZE >> 2; /* divide by 4 */
for (i = 0; i < max; i++)
- M_32_SWAP(((int *)p)[i]);
+ M_32_SWAP(((int *)pbuf)[i]);
} else {
- max = ((u_int16_t *)p)[0] + 2;
+ uint16_t *bp = (uint16_t *)(void *)pbuf;
+ max = bp[0] + 2;
for (i = 0; i <= max; i++)
- M_16_SWAP(((u_int16_t *)p)[i]);
+ M_16_SWAP(bp[i]);
}
+ p = pbuf;
}
if (is_bucket)
page = BUCKET_TO_PAGE(bucket);
diff --git a/lib/libc/stdlib/hcreate.3 b/lib/libc/stdlib/hcreate.3
index 5709157..260aa91 100644
--- a/lib/libc/stdlib/hcreate.3
+++ b/lib/libc/stdlib/hcreate.3
@@ -28,7 +28,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd December 26, 2015
+.Dd February 6, 2017
.Dt HCREATE 3
.Os
.Sh NAME
@@ -265,9 +265,9 @@ main(void)
.Ed
.Sh ERRORS
The
-.Fn hcreate
+.Fn hcreate ,
.Fn hcreate_r ,
-.Fn hsearch
+.Fn hsearch ,
and
.Fn hsearch_r
functions will fail if:
@@ -281,7 +281,7 @@ The
and
.Fn hsearch_r
functions will also fail if the action is
-.Dv SEARCH
+.Dv FIND
and the element is not found:
.Bl -tag -width Er
.It Bq Er ESRCH
diff --git a/lib/libc/sys/recv.2 b/lib/libc/sys/recv.2
index 4867ea7..36a8a9d 100644
--- a/lib/libc/sys/recv.2
+++ b/lib/libc/sys/recv.2
@@ -28,7 +28,7 @@
.\" @(#)recv.2 8.3 (Berkeley) 2/21/94
.\" $FreeBSD$
.\"
-.Dd January 29, 2016
+.Dd February 3, 2017
.Dt RECV 2
.Os
.Sh NAME
@@ -267,57 +267,10 @@ with no data buffer provided immediately after an
.Fn accept
system call.
.Pp
-Open file descriptors are now passed as ancillary data for
+With
.Dv AF_UNIX
-domain sockets, with
-.Fa cmsg_level
-set to
-.Dv SOL_SOCKET
-and
-.Fa cmsg_type
-set to
-.Dv SCM_RIGHTS .
-The close-on-exec flag on received descriptors is set according to the
-.Dv MSG_CMSG_CLOEXEC
-flag passed to
-.Fn recvmsg .
-.Pp
-Process credentials can also be passed as ancillary data for
-.Dv AF_UNIX
-domain sockets using a
-.Fa cmsg_type
-of
-.Dv SCM_CREDS .
-In this case,
-.Fa cmsg_data
-should be a structure of type
-.Fa cmsgcred ,
-which is defined in
-.In sys/socket.h
-as follows:
-.Bd -literal
-struct cmsgcred {
- pid_t cmcred_pid; /* PID of sending process */
- uid_t cmcred_uid; /* real UID of sending process */
- uid_t cmcred_euid; /* effective UID of sending process */
- gid_t cmcred_gid; /* real GID of sending process */
- short cmcred_ngroups; /* number or groups */
- gid_t cmcred_groups[CMGROUP_MAX]; /* groups */
-};
-.Ed
-.Pp
-If a sender supplies ancillary data with enough space for the above struct
-tagged as
-.Dv SCM_CREDS
-control message type to the
-.Fn sendmsg
-system call, then kernel will fill in the credential information of the
-sending process and deliver it to the receiver.
-Since receiver usually has no control over a sender, this method of retrieving
-credential information isn't reliable.
-For reliable retrieval of remote side credentials it is advised to use the
-.Dv LOCAL_CREDS
-socket option on the receiving socket.
+domain sockets, ancillary data can be used to pass file descriptors and
+process credentials.
See
.Xr unix 4
for details.
diff --git a/lib/libc/tests/db/Makefile b/lib/libc/tests/db/Makefile
index e9c76d2..132cfb3 100644
--- a/lib/libc/tests/db/Makefile
+++ b/lib/libc/tests/db/Makefile
@@ -13,6 +13,8 @@ NETBSD_ATF_TESTS_C+= db_hash_seq_test
NETBSD_ATF_TESTS_SH+= db_test
ATF_TESTS_SH_SED_db_test= -e 's,/bin/csh,/bin/cat,g'
+CFLAGS+= -I${SRCTOP}/lib/libc/db/btree
+
.include "../Makefile.netbsd-tests"
.include <bsd.test.mk>
diff --git a/lib/libc/tests/gen/Makefile b/lib/libc/tests/gen/Makefile
index 0830977..2ec336e 100644
--- a/lib/libc/tests/gen/Makefile
+++ b/lib/libc/tests/gen/Makefile
@@ -13,10 +13,20 @@ ATF_TESTS_C+= posix_spawn_test
ATF_TESTS_C+= wordexp_test
ATF_TESTS_C+= dlopen_empty_test
-# TODO: t_closefrom, t_cpuset, t_fmtcheck, t_randomid, t_sleep
+# TODO: t_closefrom, t_cpuset, t_fmtcheck, t_randomid,
# TODO: t_siginfo (fixes require further inspection)
# TODO: t_sethostname_test (consistently screws up the hostname)
+CFLAGS+= -DTEST_LONG_DOUBLE
+
+# Not sure why this isn't defined for all architectures, since most
+# have long double.
+.if ${MACHINE_CPUARCH} == "aarch64" || \
+ ${MACHINE_CPUARCH} == "amd64" || \
+ ${MACHINE_CPUARCH} == "i386"
+CFLAGS+= -D__HAVE_LONG_DOUBLE
+.endif
+
NETBSD_ATF_TESTS_C= alarm_test
NETBSD_ATF_TESTS_C+= assert_test
NETBSD_ATF_TESTS_C+= basedirname_test
diff --git a/lib/libc/tests/stdio/printbasic_test.c b/lib/libc/tests/stdio/printbasic_test.c
index 7f7c6cb..322e747 100644
--- a/lib/libc/tests/stdio/printbasic_test.c
+++ b/lib/libc/tests/stdio/printbasic_test.c
@@ -78,22 +78,19 @@ _testfmt(const char *result, const char *argstr, const char *fmt,...)
va_copy(ap2, ap);
smash_stack();
vsnprintf(s, sizeof(s), fmt, ap);
- if (strcmp(result, s) != 0) {
- atf_tc_fail(
- "printf(\"%s\", %s) ==> [%s], expected [%s]",
- fmt, argstr, s, result);
- }
+ ATF_CHECK_MSG(strcmp(result, s) == 0,
+ "printf(\"%s\", %s) ==> [%s], expected [%s]",
+ fmt, argstr, s, result);
smash_stack();
mbstowcs(ws, s, BUF - 1);
mbstowcs(wfmt, fmt, BUF - 1);
mbstowcs(wresult, result, BUF - 1);
vswprintf(ws, sizeof(ws) / sizeof(ws[0]), wfmt, ap2);
- if (wcscmp(wresult, ws) != 0) {
- atf_tc_fail(
- "wprintf(\"%ls\", %s) ==> [%ls], expected [%ls]",
- wfmt, argstr, ws, wresult);
- }
+ ATF_CHECK_MSG(wcscmp(wresult, ws) == 0,
+ "wprintf(\"%ls\", %s) ==> [%ls], expected [%ls]",
+ wfmt, argstr, ws, wresult);
+
va_end(ap);
va_end(ap2);
}
@@ -114,6 +111,11 @@ ATF_TC_BODY(int_within_limits, tc)
testfmt("-1", "%jd", (intmax_t)-1);
testfmt(S_UINT64MAX, "%ju", UINT64_MAX);
+ if (sizeof(ptrdiff_t) != sizeof(uintmax_t))
+ atf_tc_expect_fail("the %%t qualifier is broken on 32-bit "
+ "platforms where there's a mismatch between ptrdiff_t and "
+ "uintmax_t's type width; bug # 191674");
+
testfmt("-1", "%td", (ptrdiff_t)-1);
testfmt(S_SIZEMAX, "%tu", (size_t)-1);
diff --git a/lib/libc/tests/stdio/printfloat_test.c b/lib/libc/tests/stdio/printfloat_test.c
index 974374f..97629fb 100644
--- a/lib/libc/tests/stdio/printfloat_test.c
+++ b/lib/libc/tests/stdio/printfloat_test.c
@@ -70,22 +70,19 @@ _testfmt(const char *result, const char *argstr, const char *fmt,...)
va_copy(ap2, ap);
smash_stack();
vsnprintf(s, sizeof(s), fmt, ap);
- if (strcmp(result, s) != 0) {
- atf_tc_fail(
- "printf(\"%s\", %s) ==> [%s], expected [%s]",
- fmt, argstr, s, result);
- }
+ ATF_CHECK_MSG(strcmp(result, s) == 0,
+ "printf(\"%s\", %s) ==> [%s], expected [%s]",
+ fmt, argstr, s, result);
smash_stack();
mbstowcs(ws, s, BUF - 1);
mbstowcs(wfmt, fmt, BUF - 1);
mbstowcs(wresult, result, BUF - 1);
vswprintf(ws, sizeof(ws) / sizeof(ws[0]), wfmt, ap2);
- if (wcscmp(wresult, ws) != 0) {
- atf_tc_fail(
- "wprintf(\"%ls\", %s) ==> [%ls], expected [%ls]",
- wfmt, argstr, ws, wresult);
- }
+ ATF_CHECK_MSG(wcscmp(wresult, ws) == 0,
+ "wprintf(\"%ls\", %s) ==> [%ls], expected [%ls]",
+ wfmt, argstr, ws, wresult);
+
va_end(ap);
va_end(ap2);
}
@@ -318,7 +315,7 @@ ATF_TC_BODY(hexadecimal_floating_point, tc)
testfmt("0x1p-1074", "%a", 0x1p-1074);
testfmt("0x1.2345p-1024", "%a", 0x1.2345p-1024);
-#if (LDBL_MANT_DIG == 64) && !defined(__i386__)
+#if (LDBL_MANT_DIG == 64)
testfmt("0x1.921fb54442d18468p+1", "%La", 0x3.243f6a8885a308dp0L);
testfmt("0x1p-16445", "%La", 0x1p-16445L);
testfmt("0x1.30ecap-16381", "%La", 0x9.8765p-16384L);
diff --git a/lib/libc/tests/sys/Makefile b/lib/libc/tests/sys/Makefile
index 42427e8..64b20a8 100644
--- a/lib/libc/tests/sys/Makefile
+++ b/lib/libc/tests/sys/Makefile
@@ -61,8 +61,12 @@ NETBSD_ATF_TESTS_C+= ucontext_test
NETBSD_ATF_TESTS_C+= umask_test
NETBSD_ATF_TESTS_C+= unlink_test
NETBSD_ATF_TESTS_C+= wait_test
+NETBSD_ATF_TESTS_C+= wait_noproc_test
+NETBSD_ATF_TESTS_C+= wait_noproc_wnohang_test
NETBSD_ATF_TESTS_C+= write_test
+CSTD?= c99
+
LIBADD.getpid_test+= pthread
LIBADD.timer_create_test+= rt
diff --git a/lib/libc/x86/sys/Makefile.inc b/lib/libc/x86/sys/Makefile.inc
index c00a217..0e8026a 100644
--- a/lib/libc/x86/sys/Makefile.inc
+++ b/lib/libc/x86/sys/Makefile.inc
@@ -4,3 +4,7 @@
SRCS+= \
__vdso_gettc.c
+
+.if ${MACHINE_CPUARCH} == "amd64" && ${MK_HYPERV} != "no"
+CFLAGS+= -DWANT_HYPERV
+.endif
diff --git a/lib/libc/x86/sys/__vdso_gettc.c b/lib/libc/x86/sys/__vdso_gettc.c
index 723db6e..bf46a10 100644
--- a/lib/libc/x86/sys/__vdso_gettc.c
+++ b/lib/libc/x86/sys/__vdso_gettc.c
@@ -46,7 +46,7 @@ __FBSDID("$FreeBSD$");
#include <machine/cpufunc.h>
#include <machine/specialreg.h>
#include <dev/acpica/acpi_hpet.h>
-#ifdef __amd64__
+#ifdef WANT_HYPERV
#include <dev/hyperv/hyperv.h>
#endif
#include "libc_private.h"
@@ -158,7 +158,7 @@ __vdso_init_hpet(uint32_t u)
munmap((void *)new_map, PAGE_SIZE);
}
-#ifdef __amd64__
+#ifdef WANT_HYPERV
#define HYPERV_REFTSC_DEVPATH "/dev/" HYPERV_REFTSC_DEVNAME
@@ -217,7 +217,7 @@ __vdso_hyperv_tsc(struct hyperv_reftsc *tsc_ref, u_int *tc)
return (ENOSYS);
}
-#endif /* __amd64__ */
+#endif /* WANT_HYPERV */
#pragma weak __vdso_gettc
int
@@ -246,7 +246,7 @@ __vdso_gettc(const struct vdso_timehands *th, u_int *tc)
return (ENOSYS);
*tc = *(volatile uint32_t *)(map + HPET_MAIN_COUNTER);
return (0);
-#ifdef __amd64__
+#ifdef WANT_HYPERV
case VDSO_TH_ALGO_X86_HVTSC:
if (hyperv_ref_tsc == NULL)
__vdso_init_hyperv_tsc();
diff --git a/lib/libc_nonshared/Makefile b/lib/libc_nonshared/Makefile
index db4fb32..2618280 100644
--- a/lib/libc_nonshared/Makefile
+++ b/lib/libc_nonshared/Makefile
@@ -6,7 +6,7 @@
# bsd.lib.mk doesn't have an easy way to express that.
MK_PROFILE?=no
.include <src.opts.mk>
-NO_PIC=
+NO_PIC=
# -fpic on some platforms, -fPIC on others.
CFLAGS+=${PICFLAG} -DPIC -fvisibility=hidden
@@ -18,9 +18,9 @@ LIBC_NONSHARED_SRCS=
SRCS= __stub.c
.if ${MK_ICONV} == "yes"
-.PATH: ${.CURDIR}/../libc/iconv
+.PATH: ${SRCTOP}/lib/libc/iconv
.include "Makefile.iconv"
-CFLAGS+=-I${.CURDIR}/../libc/iconv
+CFLAGS+=-I${SRCTOP}/lib/libc/iconv
.endif
SRCS+= ${LIBC_NONSHARED_SRCS}
diff --git a/lib/libcam/Makefile b/lib/libcam/Makefile
index a4cae7a..37b3c4f 100644
--- a/lib/libcam/Makefile
+++ b/lib/libcam/Makefile
@@ -36,11 +36,10 @@ MLINKS+= cam.3 cam_open_device.3 \
cam_cdbparse.3 csio_encode_visit.3 \
cam_cdbparse.3 buff_encode_visit.3
-.PATH: ${.CURDIR}/../../sys/cam/scsi ${.CURDIR}/../../sys/cam/ata \
- ${.CURDIR}/../../sys/cam
+.PATH: ${SRCTOP}/sys/cam/scsi ${SRCTOP}/sys/cam/ata \
+ ${SRCTOP}/sys/cam
-SDIR= ${.CURDIR}/../../sys
-CFLAGS+= -I${.CURDIR} -I${SDIR}
+CFLAGS+= -I${.CURDIR} -I${SRCTOP}/sys
SHLIB_MAJOR= 7
diff --git a/lib/libcom_err/Makefile b/lib/libcom_err/Makefile
index b6f389f..ca65c09 100644
--- a/lib/libcom_err/Makefile
+++ b/lib/libcom_err/Makefile
@@ -5,7 +5,7 @@ LIB= com_err
SRCS= com_err.c error.c
INCS= ${COM_ERRDIR}/com_err.h ${COM_ERRDIR}/com_right.h
MAN= com_err.3
-COM_ERRDIR= ${.CURDIR}/../../contrib/com_err
+COM_ERRDIR= ${SRCTOP}/contrib/com_err
CFLAGS+= -I${COM_ERRDIR}
LDFLAGS= -Wl,--no-undefined
diff --git a/lib/libcompat/Makefile b/lib/libcompat/Makefile
index 0bd47df..4961b10 100644
--- a/lib/libcompat/Makefile
+++ b/lib/libcompat/Makefile
@@ -3,7 +3,7 @@
PACKAGE=lib${LIB}
LIB= compat
-CFLAGS+=-DLIBC_SCCS -DSYSLIBC_SCCS -I${.CURDIR}/../libc/locale
+CFLAGS+=-DLIBC_SCCS -DSYSLIBC_SCCS -I${SRCTOP}/lib/libc/locale
NO_PIC=
WARNS?= 0
diff --git a/lib/libcrypt/Makefile b/lib/libcrypt/Makefile
index 3b982a3..3d65b95 100644
--- a/lib/libcrypt/Makefile
+++ b/lib/libcrypt/Makefile
@@ -10,7 +10,7 @@ SHLIBDIR?= /lib
SHLIB_MAJOR= 5
LIB= crypt
-.PATH: ${.CURDIR}/../libmd ${.CURDIR}/../../sys/crypto/sha2
+.PATH: ${SRCTOP}/lib/libmd ${SRCTOP}/sys/crypto/sha2
SRCS= crypt.c misc.c \
crypt-md5.c md5c.c \
crypt-nthash.c md4c.c \
@@ -18,12 +18,12 @@ SRCS= crypt.c misc.c \
crypt-sha512.c sha512c.c
MAN= crypt.3
MLINKS= crypt.3 crypt_get_format.3 crypt.3 crypt_set_format.3
-CFLAGS+= -I${.CURDIR}/../libmd -I${.CURDIR}/../libutil \
- -I${.CURDIR}/../../sys/crypto/sha2
+CFLAGS+= -I${SRCTOP}/lib/libmd -I${SRCTOP}/lib/libutil \
+ -I${SRCTOP}/sys/crypto/sha2
# Pull in the strong crypto, if it is present.
-.if exists(${.CURDIR}/../../secure/lib/libcrypt) && ${MK_CRYPT} != "no"
-.PATH: ${.CURDIR}/../../secure/lib/libcrypt
+.if exists(${SRCTOP}/secure/lib/libcrypt) && ${MK_CRYPT} != "no"
+.PATH: ${SRCTOP}/secure/lib/libcrypt
SRCS+= crypt-des.c crypt-blowfish.c blowfish.c
CFLAGS+= -I${.CURDIR} -DHAS_DES -DHAS_BLOWFISH
.endif
diff --git a/lib/libcxxrt/Makefile b/lib/libcxxrt/Makefile
index f2efe8d..5332024 100644
--- a/lib/libcxxrt/Makefile
+++ b/lib/libcxxrt/Makefile
@@ -1,7 +1,7 @@
# $FreeBSD$
PACKAGE= clibs
-SRCDIR= ${.CURDIR}/../../contrib/libcxxrt
+SRCDIR= ${SRCTOP}/contrib/libcxxrt
SHLIB_MAJOR= 1
SHLIBDIR?= /lib
diff --git a/lib/libdevdctl/tests/Makefile b/lib/libdevdctl/tests/Makefile
index 3bbbd0d..ce256bb 100644
--- a/lib/libdevdctl/tests/Makefile
+++ b/lib/libdevdctl/tests/Makefile
@@ -2,7 +2,7 @@
TESTSDIR= ${TESTSBASE}/lib/libdevdctl
-.PATH: ${.CURDIR}/..
+.PATH: ${.CURDIR:H}
PLAIN_TESTS_CXX= libdevdctl_unittest
diff --git a/lib/libdwarf/Makefile b/lib/libdwarf/Makefile
index e2bb5a5..03f40cd 100644
--- a/lib/libdwarf/Makefile
+++ b/lib/libdwarf/Makefile
@@ -94,7 +94,7 @@ CLEANFILES= ${GENSRCS}
CLEANDIRS= sys
CFLAGS+= -I. -I${SRCDIR} -I${ELFTCDIR}/common -I${ELFTCDIR}/libelf
-sys/elf32.h sys/elf64.h sys/elf_common.h: ${.CURDIR}/../../sys/${.TARGET} .NOMETA
+sys/elf32.h sys/elf64.h sys/elf_common.h: ${SRCTOP}/sys/${.TARGET} .NOMETA
mkdir -p ${.OBJDIR}/sys
ln -sf ${.ALLSRC} ${.TARGET}
diff --git a/lib/libedit/Makefile b/lib/libedit/Makefile
index a75c9d2..81ba647 100644
--- a/lib/libedit/Makefile
+++ b/lib/libedit/Makefile
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.37 2009/01/18 12:17:49 lukem Exp $
+# $NetBSD: Makefile,v 1.56 2016/03/02 19:24:20 christos Exp $
# @(#)Makefile 8.1 (Berkeley) 6/4/93
# $FreeBSD$
@@ -7,7 +7,7 @@ LIB= edit
SHLIB_MAJOR= 7
SHLIBDIR?= /lib
-OSRCS= chared.c common.c el.c emacs.c fcns.c filecomplete.c help.c \
+OSRCS= chared.c common.c el.c eln.c emacs.c fcns.c filecomplete.c help.c \
hist.c keymacro.c map.c chartype.c \
parse.c prompt.c read.c refresh.c search.c sig.c terminal.c tty.c vi.c
@@ -35,12 +35,11 @@ CLEANFILES+= common.h editline.c emacs.h fcns.c fcns.h help.c help.h vi.h
INCS= histedit.h
-OSRCS+= eln.c
SRCS+= tokenizern.c historyn.c
CLEANFILES+= tokenizern.c historyn.c
CFLAGS+= -I. -I${.CURDIR} -I${.CURDIR}/edit -DWIDECHAR
-CFLAGS+= #-DDEBUG_TTY -DDEBUG_KEY -DDEBUG_READ -DDEBUG -DDEBUG_REFRESH
-CFLAGS+= #-DDEBUG_PASTE -DDEBUG_EDIT
+#CFLAGS+= -DDEBUG_TTY -DDEBUG_KEY -DDEBUG_READ -DDEBUG -DDEBUG_REFRESH
+#CFLAGS+= -DDEBUG_PASTE -DDEBUG_EDIT
WARNS?= 1
diff --git a/lib/libedit/TEST/rl1.c b/lib/libedit/TEST/rl1.c
index 79050cc..34befbe 100644
--- a/lib/libedit/TEST/rl1.c
+++ b/lib/libedit/TEST/rl1.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rl1.c,v 1.1 2010/09/16 20:08:51 christos Exp $ */
+/* $NetBSD: rl1.c,v 1.2 2016/02/29 00:54:19 christos Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
#include <sys/cdefs.h>
#if !defined(lint)
-__RCSID("$NetBSD: rl1.c,v 1.1 2010/09/16 20:08:51 christos Exp $");
+__RCSID("$NetBSD: rl1.c,v 1.2 2016/02/29 00:54:19 christos Exp $");
#endif /* not lint */
__FBSDID("$FreeBSD$");
diff --git a/lib/libedit/TEST/tc1.c b/lib/libedit/TEST/tc1.c
index 1969973..1dca813 100644
--- a/lib/libedit/TEST/tc1.c
+++ b/lib/libedit/TEST/tc1.c
@@ -1,4 +1,4 @@
-/* $NetBSD: tc1.c,v 1.6 2014/06/18 20:12:15 christos Exp $ */
+/* $NetBSD: tc1.c,v 1.7 2016/02/17 19:47:49 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1992, 1993\n\
#if 0
static char sccsid[] = "@(#)test.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: tc1.c,v 1.6 2014/06/18 20:12:15 christos Exp $");
+__RCSID("$NetBSD: tc1.c,v 1.7 2016/02/17 19:47:49 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
__FBSDID("$FreeBSD$");
@@ -50,15 +50,15 @@ __FBSDID("$FreeBSD$");
/*
* test.c: A little test program
*/
-#include <stdio.h>
-#include <string.h>
-#include <signal.h>
#include <sys/wait.h>
#include <ctype.h>
-#include <stdlib.h>
-#include <unistd.h>
#include <dirent.h>
#include <locale.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
#include "histedit.h"
@@ -158,7 +158,7 @@ main(int argc, char *argv[])
/* Add a user-defined function */
el_set(el, EL_ADDFN, "ed-complete", "Complete argument", complete);
- /* Bind tab to it */
+ /* Bind tab to it */
el_set(el, EL_BIND, "^I", "ed-complete", NULL);
/*
diff --git a/lib/libedit/TEST/wtc1.c b/lib/libedit/TEST/wtc1.c
index ec5574b..c4a2376 100644
--- a/lib/libedit/TEST/wtc1.c
+++ b/lib/libedit/TEST/wtc1.c
@@ -5,13 +5,16 @@ __FBSDID("$FreeBSD$");
#include <string.h>
#include <signal.h>
#include <sys/wait.h>
-#include <err.h>
#include <ctype.h>
-#include <stdlib.h>
-#include <unistd.h>
#include <dirent.h>
+#include <err.h>
#include <limits.h>
#include <locale.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
#include "../histedit.h"
diff --git a/lib/libedit/chared.c b/lib/libedit/chared.c
index 2b57051..9ec618e 100644
--- a/lib/libedit/chared.c
+++ b/lib/libedit/chared.c
@@ -1,4 +1,4 @@
-/* $NetBSD: chared.c,v 1.40 2014/06/18 18:12:28 christos Exp $ */
+/* $NetBSD: chared.c,v 1.49 2016/02/24 14:29:21 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)chared.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: chared.c,v 1.40 2014/06/18 18:12:28 christos Exp $");
+__RCSID("$NetBSD: chared.c,v 1.49 2016/02/24 14:29:21 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
#include <sys/cdefs.h>
@@ -46,8 +46,12 @@ __FBSDID("$FreeBSD$");
/*
* chared.c: Character editor utilities
*/
+#include <ctype.h>
#include <stdlib.h>
+#include <string.h>
+
#include "el.h"
+#include "common.h"
private void ch__clearmacro (EditLine *);
@@ -201,7 +205,7 @@ c_delbefore1(EditLine *el)
* Return if p is part of a word according to emacs
*/
protected int
-ce__isword(Int p)
+ce__isword(wint_t p)
{
return Isalnum(p) || Strchr(STR("*?_-.[]~="), p) != NULL;
}
@@ -211,7 +215,7 @@ ce__isword(Int p)
* Return if p is part of a word according to vi
*/
protected int
-cv__isword(Int p)
+cv__isword(wint_t p)
{
if (Isalnum(p) || p == '_')
return 1;
@@ -225,7 +229,7 @@ cv__isword(Int p)
* Return if p is part of a big word according to vi
*/
protected int
-cv__isWord(Int p)
+cv__isWord(wint_t p)
{
return !Isspace(p);
}
@@ -235,7 +239,7 @@ cv__isWord(Int p)
* Find the previous word
*/
protected Char *
-c__prev_word(Char *p, Char *low, int n, int (*wtest)(Int))
+c__prev_word(Char *p, Char *low, int n, int (*wtest)(wint_t))
{
p--;
@@ -259,7 +263,7 @@ c__prev_word(Char *p, Char *low, int n, int (*wtest)(Int))
* Find the next word
*/
protected Char *
-c__next_word(Char *p, Char *high, int n, int (*wtest)(Int))
+c__next_word(Char *p, Char *high, int n, int (*wtest)(wint_t))
{
while (n--) {
while ((p < high) && !(*wtest)(*p))
@@ -277,7 +281,7 @@ c__next_word(Char *p, Char *high, int n, int (*wtest)(Int))
* Find the next word vi style
*/
protected Char *
-cv_next_word(EditLine *el, Char *p, Char *high, int n, int (*wtest)(Int))
+cv_next_word(EditLine *el, Char *p, Char *high, int n, int (*wtest)(wint_t))
{
int test;
@@ -306,7 +310,7 @@ cv_next_word(EditLine *el, Char *p, Char *high, int n, int (*wtest)(Int))
* Find the previous word vi style
*/
protected Char *
-cv_prev_word(Char *p, Char *low, int n, int (*wtest)(Int))
+cv_prev_word(Char *p, Char *low, int n, int (*wtest)(wint_t))
{
int test;
@@ -370,7 +374,7 @@ cv_delfini(EditLine *el)
* Go to the end of this word according to vi
*/
protected Char *
-cv__endword(Char *p, Char *high, int n, int (*wtest)(Int))
+cv__endword(Char *p, Char *high, int n, int (*wtest)(wint_t))
{
int test;
@@ -524,7 +528,7 @@ ch_enlargebufs(EditLine *el, size_t addlen)
/* zero the newly added memory, leave old data in */
(void) memset(&newbuffer[sz], 0, (newsz - sz) * sizeof(*newbuffer));
-
+
oldbuf = el->el_line.buffer;
el->el_line.buffer = newbuffer;
@@ -573,7 +577,7 @@ ch_enlargebufs(EditLine *el, size_t addlen)
el->el_chared.c_redo.lim = newbuffer +
(el->el_chared.c_redo.lim - el->el_chared.c_redo.buf);
el->el_chared.c_redo.buf = newbuffer;
-
+
if (!hist_enlargebuf(el, sz, newsz))
return 0;
@@ -673,9 +677,9 @@ out:
protected int
c_gets(EditLine *el, Char *buf, const Char *prompt)
{
- Char ch;
+ wchar_t wch;
ssize_t len;
- Char *cp = el->el_line.buffer;
+ Char *cp = el->el_line.buffer, ch;
if (prompt) {
len = (ssize_t)Strlen(prompt);
@@ -690,26 +694,28 @@ c_gets(EditLine *el, Char *buf, const Char *prompt)
el->el_line.lastchar = cp + 1;
re_refresh(el);
- if (FUN(el,getc)(el, &ch) != 1) {
+ if (el_wgetc(el, &wch) != 1) {
ed_end_of_file(el, 0);
len = -1;
break;
}
+ ch = (Char)wch;
switch (ch) {
- case 0010: /* Delete and backspace */
+ case L'\b': /* Delete and backspace */
case 0177:
if (len == 0) {
len = -1;
break;
}
+ len--;
cp--;
continue;
case 0033: /* ESC */
- case '\r': /* Newline */
- case '\n':
+ case L'\r': /* Newline */
+ case L'\n':
buf[len] = ch;
break;
diff --git a/lib/libedit/chared.h b/lib/libedit/chared.h
index 909adac..458e671 100644
--- a/lib/libedit/chared.h
+++ b/lib/libedit/chared.h
@@ -1,4 +1,4 @@
-/* $NetBSD: chared.h,v 1.22 2014/06/18 18:12:28 christos Exp $ */
+/* $NetBSD: chared.h,v 1.27 2016/02/16 22:53:14 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -41,11 +41,6 @@
#ifndef _h_el_chared
#define _h_el_chared
-#include <ctype.h>
-#include <string.h>
-
-#include "histedit.h"
-
#define EL_MAXMACRO 10
/*
@@ -140,24 +135,18 @@ typedef struct el_chared_t {
#define MODE_REPLACE 1
#define MODE_REPLACE_1 2
-#include "common.h"
-#include "vi.h"
-#include "emacs.h"
-#include "search.h"
-#include "fcns.h"
-
-protected int cv__isword(Int);
-protected int cv__isWord(Int);
+protected int cv__isword(wint_t);
+protected int cv__isWord(wint_t);
protected void cv_delfini(EditLine *);
-protected Char *cv__endword(Char *, Char *, int, int (*)(Int));
-protected int ce__isword(Int);
+protected Char *cv__endword(Char *, Char *, int, int (*)(wint_t));
+protected int ce__isword(wint_t);
protected void cv_undo(EditLine *);
protected void cv_yank(EditLine *, const Char *, int);
-protected Char *cv_next_word(EditLine*, Char *, Char *, int, int (*)(Int));
-protected Char *cv_prev_word(Char *, Char *, int, int (*)(Int));
-protected Char *c__next_word(Char *, Char *, int, int (*)(Int));
-protected Char *c__prev_word(Char *, Char *, int, int (*)(Int));
+protected Char *cv_next_word(EditLine*, Char *, Char *, int, int (*)(wint_t));
+protected Char *cv_prev_word(Char *, Char *, int, int (*)(wint_t));
+protected Char *c__next_word(Char *, Char *, int, int (*)(wint_t));
+protected Char *c__prev_word(Char *, Char *, int, int (*)(wint_t));
protected void c_insert(EditLine *, int);
protected void c_delbefore(EditLine *, int);
protected void c_delbefore1(EditLine *);
diff --git a/lib/libedit/chartype.c b/lib/libedit/chartype.c
index c240c8c..9cb54ac 100644
--- a/lib/libedit/chartype.c
+++ b/lib/libedit/chartype.c
@@ -1,4 +1,4 @@
-/* $NetBSD: chartype.c,v 1.12 2015/02/22 02:16:19 christos Exp $ */
+/* $NetBSD: chartype.c,v 1.23 2016/02/28 23:02:24 christos Exp $ */
/*-
* Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -31,13 +31,16 @@
*/
#include "config.h"
#if !defined(lint) && !defined(SCCSID)
-__RCSID("$NetBSD: chartype.c,v 1.12 2015/02/22 02:16:19 christos Exp $");
+__RCSID("$NetBSD: chartype.c,v 1.23 2016/02/28 23:02:24 christos Exp $");
#endif /* not lint && not SCCSID */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#include "el.h"
+#include <ctype.h>
#include <stdlib.h>
+#include <string.h>
+
+#include "el.h"
#define CT_BUFSIZ ((size_t)1024)
@@ -68,7 +71,7 @@ ct_conv_wbuff_resize(ct_buffer_t *conv, size_t wsize)
{
void *p;
- if (wsize <= conv->wsize)
+ if (wsize <= conv->wsize)
return 0;
conv->wsize = wsize;
@@ -206,6 +209,28 @@ ct_encode_char(char *dst, size_t len, Char c)
}
return l;
}
+
+size_t
+ct_mbrtowc(wchar_t *wc, const char *s, size_t n)
+{
+ mbstate_t mbs;
+ /* This only works because UTF-8 is stateless */
+ memset(&mbs, 0, sizeof(mbs));
+ return mbrtowc(wc, s, n, &mbs);
+}
+
+#else
+
+size_t
+ct_mbrtowc(wchar_t *wc, const char *s, size_t n)
+ if (s == NULL)
+ return 0;
+ if (n == 0)
+ return (size_t)-2;
+ if (wc != NULL)
+ *wc = *s;
+ return *s != '\0';
+}
#endif
protected const Char *
@@ -329,7 +354,7 @@ ct_visual_char(Char *dst, size_t len, Char c)
return c > 0xffff ? 8 : 7;
#else
*dst++ = '\\';
-#define tooctaldigit(v) ((v) + '0')
+#define tooctaldigit(v) (Char)((v) + '0')
*dst++ = tooctaldigit(((unsigned int) c >> 6) & 0x7);
*dst++ = tooctaldigit(((unsigned int) c >> 3) & 0x7);
*dst++ = tooctaldigit(((unsigned int) c ) & 0x7);
diff --git a/lib/libedit/chartype.h b/lib/libedit/chartype.h
index 1445681..9f5e7e4 100644
--- a/lib/libedit/chartype.h
+++ b/lib/libedit/chartype.h
@@ -1,4 +1,4 @@
-/* $NetBSD: chartype.h,v 1.15 2015/05/17 13:14:41 christos Exp $ */
+/* $NetBSD: chartype.h,v 1.25 2016/03/07 00:05:20 christos Exp $ */
/*-
* Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -32,7 +32,6 @@
#define _h_chartype_f
-
#ifdef WIDECHAR
/* Ideally we should also test the value of the define to see if it
@@ -55,21 +54,19 @@
#warning Build environment does not support non-BMP characters
#endif
-#define ct_mbtowc mbtowc
-#define ct_mbtowc_reset mbtowc(0,0,(size_t)0)
+#define ct_wctob wctob
#define ct_wctomb wctomb
#define ct_wctomb_reset wctomb(0,0)
#define ct_wcstombs wcstombs
#define ct_mbstowcs mbstowcs
#define Char wchar_t
-#define Int wint_t
#define FUN(prefix,rest) prefix ## _w ## rest
#define FUNW(type) type ## _w
#define TYPE(type) type ## W
-#define FCHAR "%lc"
#define FSTR "%ls"
-#define STR(x) L ## x
+#define FSTARSTR "%.*ls"
+#define STR(x) L ## x
#define UC(c) c
#define Isalpha(x) iswalpha(x)
#define Isalnum(x) iswalnum(x)
@@ -110,21 +107,19 @@ Width(wchar_t c)
#else /* NARROW */
-#define ct_mbtowc error
-#define ct_mbtowc_reset
+#define ct_wctob(w) ((int)(w))
#define ct_wctomb error
-#define ct_wctomb_reset
+#define ct_wctomb_reset
#define ct_wcstombs(a, b, c) (strncpy(a, b, c), strlen(a))
#define ct_mbstowcs(a, b, c) (strncpy(a, b, c), strlen(a))
#define Char char
-#define Int int
#define FUN(prefix,rest) prefix ## _ ## rest
#define FUNW(type) type
#define TYPE(type) type
-#define FCHAR "%c"
#define FSTR "%s"
-#define STR(x) x
+#define FSTARSTR "%.*s"
+#define STR(x) x
#define UC(c) (unsigned char)(c)
#define Isalpha(x) isalpha((unsigned char)x)
@@ -213,7 +208,7 @@ protected size_t ct_enc_width(Char);
#define VISUAL_WIDTH_MAX ((size_t)8)
/* The terminal is thought of in terms of X columns by Y lines. In the cases
- * where a wide character takes up more than one column, the adjacent
+ * where a wide character takes up more than one column, the adjacent
* occupied column entries will contain this faux character. */
#define MB_FILL_CHAR ((Char)-1)
@@ -245,5 +240,7 @@ protected const Char *ct_visual_string(const Char *);
protected int ct_chr_class(Char c);
#endif
+size_t ct_mbrtowc(wchar_t *, const char *, size_t);
+
#endif /* _chartype_f */
diff --git a/lib/libedit/common.c b/lib/libedit/common.c
index fc09a9b..a2a9712 100644
--- a/lib/libedit/common.c
+++ b/lib/libedit/common.c
@@ -1,4 +1,4 @@
-/* $NetBSD: common.c,v 1.29 2012/03/24 20:08:43 christos Exp $ */
+/* $NetBSD: common.c,v 1.40 2016/03/02 19:24:20 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)common.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: common.c,v 1.29 2012/03/24 20:08:43 christos Exp $");
+__RCSID("$NetBSD: common.c,v 1.40 2016/03/02 19:24:20 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
#include <sys/cdefs.h>
@@ -46,7 +46,13 @@ __FBSDID("$FreeBSD$");
/*
* common.c: Common Editor functions
*/
+#include <ctype.h>
+#include <string.h>
+
#include "el.h"
+#include "common.h"
+#include "parse.h"
+#include "vi.h"
/* ed_end_of_file():
* Indicate end of file
@@ -54,7 +60,7 @@ __FBSDID("$FreeBSD$");
*/
protected el_action_t
/*ARGSUSED*/
-ed_end_of_file(EditLine *el, Int c __attribute__((__unused__)))
+ed_end_of_file(EditLine *el, wint_t c __attribute__((__unused__)))
{
re_goto_bottom(el);
@@ -68,7 +74,7 @@ ed_end_of_file(EditLine *el, Int c __attribute__((__unused__)))
* Insert a character [bound to all insert keys]
*/
protected el_action_t
-ed_insert(EditLine *el, Int c)
+ed_insert(EditLine *el, wint_t c)
{
int count = el->el_state.argument;
@@ -87,14 +93,14 @@ ed_insert(EditLine *el, Int c)
|| el->el_line.cursor >= el->el_line.lastchar)
c_insert(el, 1);
- *el->el_line.cursor++ = c;
+ *el->el_line.cursor++ = (Char)c;
re_fastaddc(el); /* fast refresh for one char. */
} else {
if (el->el_state.inputmode != MODE_REPLACE_1)
c_insert(el, el->el_state.argument);
while (count-- && el->el_line.cursor < el->el_line.lastchar)
- *el->el_line.cursor++ = c;
+ *el->el_line.cursor++ = (Char)c;
re_refresh(el);
}
@@ -111,7 +117,7 @@ ed_insert(EditLine *el, Int c)
*/
protected el_action_t
/*ARGSUSED*/
-ed_delete_prev_word(EditLine *el, Int c __attribute__((__unused__)))
+ed_delete_prev_word(EditLine *el, wint_t c __attribute__((__unused__)))
{
Char *cp, *p, *kp;
@@ -139,12 +145,13 @@ ed_delete_prev_word(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-ed_delete_next_char(EditLine *el, Int c __attribute__((__unused__)))
+ed_delete_next_char(EditLine *el, wint_t c __attribute__((__unused__)))
{
#ifdef DEBUG_EDIT
#define EL el->el_line
- (void) fprintf(el->el_errlfile,
- "\nD(b: %x(%s) c: %x(%s) last: %x(%s) limit: %x(%s)\n",
+ (void) fprintf(el->el_errfile,
+ "\nD(b: %p(" FSTR ") c: %p(" FSTR ") last: %p(" FSTR
+ ") limit: %p(" FSTR ")\n",
EL.buffer, EL.buffer, EL.cursor, EL.cursor, EL.lastchar,
EL.lastchar, EL.limit, EL.limit);
#endif
@@ -186,7 +193,7 @@ ed_delete_next_char(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-ed_kill_line(EditLine *el, Int c __attribute__((__unused__)))
+ed_kill_line(EditLine *el, wint_t c __attribute__((__unused__)))
{
Char *kp, *cp;
@@ -207,7 +214,7 @@ ed_kill_line(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-ed_move_to_end(EditLine *el, Int c __attribute__((__unused__)))
+ed_move_to_end(EditLine *el, wint_t c __attribute__((__unused__)))
{
el->el_line.cursor = el->el_line.lastchar;
@@ -230,7 +237,7 @@ ed_move_to_end(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-ed_move_to_beg(EditLine *el, Int c __attribute__((__unused__)))
+ed_move_to_beg(EditLine *el, wint_t c __attribute__((__unused__)))
{
el->el_line.cursor = el->el_line.buffer;
@@ -253,7 +260,7 @@ ed_move_to_beg(EditLine *el, Int c __attribute__((__unused__)))
* [^T] [^T]
*/
protected el_action_t
-ed_transpose_chars(EditLine *el, Int c)
+ed_transpose_chars(EditLine *el, wint_t c)
{
if (el->el_line.cursor < el->el_line.lastchar) {
@@ -266,7 +273,7 @@ ed_transpose_chars(EditLine *el, Int c)
/* must have at least two chars entered */
c = el->el_line.cursor[-2];
el->el_line.cursor[-2] = el->el_line.cursor[-1];
- el->el_line.cursor[-1] = c;
+ el->el_line.cursor[-1] = (Char)c;
return CC_REFRESH;
} else
return CC_ERROR;
@@ -279,7 +286,7 @@ ed_transpose_chars(EditLine *el, Int c)
*/
protected el_action_t
/*ARGSUSED*/
-ed_next_char(EditLine *el, Int c __attribute__((__unused__)))
+ed_next_char(EditLine *el, wint_t c __attribute__((__unused__)))
{
Char *lim = el->el_line.lastchar;
@@ -308,7 +315,7 @@ ed_next_char(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-ed_prev_word(EditLine *el, Int c __attribute__((__unused__)))
+ed_prev_word(EditLine *el, wint_t c __attribute__((__unused__)))
{
if (el->el_line.cursor == el->el_line.buffer)
@@ -334,7 +341,7 @@ ed_prev_word(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-ed_prev_char(EditLine *el, Int c __attribute__((__unused__)))
+ed_prev_char(EditLine *el, wint_t c __attribute__((__unused__)))
{
if (el->el_line.cursor > el->el_line.buffer) {
@@ -358,14 +365,12 @@ ed_prev_char(EditLine *el, Int c __attribute__((__unused__)))
* [^V] [^V]
*/
protected el_action_t
-ed_quoted_insert(EditLine *el, Int c)
+ed_quoted_insert(EditLine *el, wint_t c)
{
int num;
- Char tc;
tty_quotemode(el);
- num = FUN(el,getc)(el, &tc);
- c = tc;
+ num = el_wgetc(el, &c);
tty_noquotemode(el);
if (num == 1)
return ed_insert(el, c);
@@ -378,7 +383,7 @@ ed_quoted_insert(EditLine *el, Int c)
* Adds to argument or enters a digit
*/
protected el_action_t
-ed_digit(EditLine *el, Int c)
+ed_digit(EditLine *el, wint_t c)
{
if (!Isdigit(c))
@@ -406,7 +411,7 @@ ed_digit(EditLine *el, Int c)
* For ESC-n
*/
protected el_action_t
-ed_argument_digit(EditLine *el, Int c)
+ed_argument_digit(EditLine *el, wint_t c)
{
if (!Isdigit(c))
@@ -432,7 +437,7 @@ ed_argument_digit(EditLine *el, Int c)
protected el_action_t
/*ARGSUSED*/
ed_unassigned(EditLine *el __attribute__((__unused__)),
- Int c __attribute__((__unused__)))
+ wint_t c __attribute__((__unused__)))
{
return CC_ERROR;
@@ -449,8 +454,8 @@ ed_unassigned(EditLine *el __attribute__((__unused__)),
*/
protected el_action_t
/*ARGSUSED*/
-ed_tty_sigint(EditLine *el __attribute__((__unused__)),
- Int c __attribute__((__unused__)))
+ed_tty_sigint(EditLine *el __attribute__((__unused__)),
+ wint_t c __attribute__((__unused__)))
{
return CC_NORM;
@@ -463,8 +468,8 @@ ed_tty_sigint(EditLine *el __attribute__((__unused__)),
*/
protected el_action_t
/*ARGSUSED*/
-ed_tty_dsusp(EditLine *el __attribute__((__unused__)),
- Int c __attribute__((__unused__)))
+ed_tty_dsusp(EditLine *el __attribute__((__unused__)),
+ wint_t c __attribute__((__unused__)))
{
return CC_NORM;
@@ -477,8 +482,8 @@ ed_tty_dsusp(EditLine *el __attribute__((__unused__)),
*/
protected el_action_t
/*ARGSUSED*/
-ed_tty_flush_output(EditLine *el __attribute__((__unused__)),
- Int c __attribute__((__unused__)))
+ed_tty_flush_output(EditLine *el __attribute__((__unused__)),
+ wint_t c __attribute__((__unused__)))
{
return CC_NORM;
@@ -491,8 +496,8 @@ ed_tty_flush_output(EditLine *el __attribute__((__unused__)),
*/
protected el_action_t
/*ARGSUSED*/
-ed_tty_sigquit(EditLine *el __attribute__((__unused__)),
- Int c __attribute__((__unused__)))
+ed_tty_sigquit(EditLine *el __attribute__((__unused__)),
+ wint_t c __attribute__((__unused__)))
{
return CC_NORM;
@@ -505,8 +510,8 @@ ed_tty_sigquit(EditLine *el __attribute__((__unused__)),
*/
protected el_action_t
/*ARGSUSED*/
-ed_tty_sigtstp(EditLine *el __attribute__((__unused__)),
- Int c __attribute__((__unused__)))
+ed_tty_sigtstp(EditLine *el __attribute__((__unused__)),
+ wint_t c __attribute__((__unused__)))
{
return CC_NORM;
@@ -519,8 +524,8 @@ ed_tty_sigtstp(EditLine *el __attribute__((__unused__)),
*/
protected el_action_t
/*ARGSUSED*/
-ed_tty_stop_output(EditLine *el __attribute__((__unused__)),
- Int c __attribute__((__unused__)))
+ed_tty_stop_output(EditLine *el __attribute__((__unused__)),
+ wint_t c __attribute__((__unused__)))
{
return CC_NORM;
@@ -533,8 +538,8 @@ ed_tty_stop_output(EditLine *el __attribute__((__unused__)),
*/
protected el_action_t
/*ARGSUSED*/
-ed_tty_start_output(EditLine *el __attribute__((__unused__)),
- Int c __attribute__((__unused__)))
+ed_tty_start_output(EditLine *el __attribute__((__unused__)),
+ wint_t c __attribute__((__unused__)))
{
return CC_NORM;
@@ -547,7 +552,7 @@ ed_tty_start_output(EditLine *el __attribute__((__unused__)),
*/
protected el_action_t
/*ARGSUSED*/
-ed_newline(EditLine *el, Int c __attribute__((__unused__)))
+ed_newline(EditLine *el, wint_t c __attribute__((__unused__)))
{
re_goto_bottom(el);
@@ -563,7 +568,7 @@ ed_newline(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-ed_delete_prev_char(EditLine *el, Int c __attribute__((__unused__)))
+ed_delete_prev_char(EditLine *el, wint_t c __attribute__((__unused__)))
{
if (el->el_line.cursor <= el->el_line.buffer)
@@ -583,7 +588,7 @@ ed_delete_prev_char(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-ed_clear_screen(EditLine *el, Int c __attribute__((__unused__)))
+ed_clear_screen(EditLine *el, wint_t c __attribute__((__unused__)))
{
terminal_clear_screen(el); /* clear the whole real screen */
@@ -598,8 +603,8 @@ ed_clear_screen(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-ed_redisplay(EditLine *el __attribute__((__unused__)),
- Int c __attribute__((__unused__)))
+ed_redisplay(EditLine *el __attribute__((__unused__)),
+ wint_t c __attribute__((__unused__)))
{
return CC_REDISPLAY;
@@ -612,7 +617,7 @@ ed_redisplay(EditLine *el __attribute__((__unused__)),
*/
protected el_action_t
/*ARGSUSED*/
-ed_start_over(EditLine *el, Int c __attribute__((__unused__)))
+ed_start_over(EditLine *el, wint_t c __attribute__((__unused__)))
{
ch_reset(el, 0);
@@ -626,8 +631,8 @@ ed_start_over(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-ed_sequence_lead_in(EditLine *el __attribute__((__unused__)),
- Int c __attribute__((__unused__)))
+ed_sequence_lead_in(EditLine *el __attribute__((__unused__)),
+ wint_t c __attribute__((__unused__)))
{
return CC_NORM;
@@ -640,7 +645,7 @@ ed_sequence_lead_in(EditLine *el __attribute__((__unused__)),
*/
protected el_action_t
/*ARGSUSED*/
-ed_prev_history(EditLine *el, Int c __attribute__((__unused__)))
+ed_prev_history(EditLine *el, wint_t c __attribute__((__unused__)))
{
char beep = 0;
int sv_event = el->el_history.eventno;
@@ -660,7 +665,6 @@ ed_prev_history(EditLine *el, Int c __attribute__((__unused__)))
if (hist_get(el) == CC_ERROR) {
if (el->el_map.type == MAP_VI) {
el->el_history.eventno = sv_event;
-
}
beep = 1;
/* el->el_history.eventno was fixed by first call */
@@ -678,7 +682,7 @@ ed_prev_history(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-ed_next_history(EditLine *el, Int c __attribute__((__unused__)))
+ed_next_history(EditLine *el, wint_t c __attribute__((__unused__)))
{
el_action_t beep = CC_REFRESH, rval;
@@ -705,11 +709,11 @@ ed_next_history(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-ed_search_prev_history(EditLine *el, Int c __attribute__((__unused__)))
+ed_search_prev_history(EditLine *el, wint_t c __attribute__((__unused__)))
{
const Char *hp;
int h;
- bool_t found = 0;
+ int found = 0;
el->el_chared.c_vcmd.action = NOP;
el->el_chared.c_undo.len = -1;
@@ -748,7 +752,7 @@ ed_search_prev_history(EditLine *el, Int c __attribute__((__unused__)))
(el->el_line.lastchar - el->el_line.buffer)) ||
hp[el->el_line.lastchar - el->el_line.buffer]) &&
c_hmatch(el, hp)) {
- found++;
+ found = 1;
break;
}
h++;
@@ -773,11 +777,11 @@ ed_search_prev_history(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-ed_search_next_history(EditLine *el, Int c __attribute__((__unused__)))
+ed_search_next_history(EditLine *el, wint_t c __attribute__((__unused__)))
{
const Char *hp;
int h;
- bool_t found = 0;
+ int found = 0;
el->el_chared.c_vcmd.action = NOP;
el->el_chared.c_undo.len = -1;
@@ -827,7 +831,7 @@ ed_search_next_history(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-ed_prev_line(EditLine *el, Int c __attribute__((__unused__)))
+ed_prev_line(EditLine *el, wint_t c __attribute__((__unused__)))
{
Char *ptr;
int nchars = c_hpos(el);
@@ -870,7 +874,7 @@ ed_prev_line(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-ed_next_line(EditLine *el, Int c __attribute__((__unused__)))
+ed_next_line(EditLine *el, wint_t c __attribute__((__unused__)))
{
Char *ptr;
int nchars = c_hpos(el);
@@ -904,7 +908,7 @@ ed_next_line(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-ed_command(EditLine *el, Int c __attribute__((__unused__)))
+ed_command(EditLine *el, wint_t c __attribute__((__unused__)))
{
Char tmpbuf[EL_BUFSIZ];
int tmplen;
diff --git a/lib/libedit/config.h b/lib/libedit/config.h
index 526869f..ccc2855 100644
--- a/lib/libedit/config.h
+++ b/lib/libedit/config.h
@@ -21,8 +21,8 @@
/* Define to 1 if you have the <fcntl.h> header file. */
#define HAVE_FCNTL_H 1
-/* Define to 1 if you have the `fgetln' function. */
-#define HAVE_FGETLN 1
+/* Define to 1 if you have the `getline' function. */
+#define HAVE_GETLINE 1
/* Define to 1 if you have the `fork' function. */
#define HAVE_FORK 1
@@ -188,9 +188,6 @@
/* Define to 1 if you have the `vis' function. */
#define HAVE_VIS 1
-/* Define to 1 if you have the `wcsdup' function. */
-#define HAVE_WCSDUP 1
-
/* Define to 1 if `fork' works. */
#define HAVE_WORKING_FORK 1
@@ -257,6 +254,9 @@
/* Version number of package */
#define VERSION "3.0"
+/* Define to 1 if the system provides the SIZE_MAX constant */
+#define HAVE_SIZE_MAX 1
+
/* Define to 1 if you want wide-character code */
/* #undef WIDECHAR */
diff --git a/lib/libedit/edit/readline/readline.h b/lib/libedit/edit/readline/readline.h
index e25781b..34ded0f 100644
--- a/lib/libedit/edit/readline/readline.h
+++ b/lib/libedit/edit/readline/readline.h
@@ -1,4 +1,4 @@
-/* $NetBSD: readline.h,v 1.37 2015/06/02 15:36:45 christos Exp $ */
+/* $NetBSD: readline.h,v 1.39 2016/02/17 19:47:49 christos Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -55,7 +55,7 @@ typedef void *histdata_t;
typedef struct _hist_entry {
const char *line;
- histdata_t data;
+ histdata_t data;
} HIST_ENTRY;
typedef struct _keymap_entry {
@@ -89,7 +89,7 @@ typedef KEYMAP_ENTRY *Keymap;
#define RUBOUT 0x7f
#define ABORT_CHAR CTRL('G')
-#define RL_READLINE_VERSION 0x0402
+#define RL_READLINE_VERSION 0x0402
#define RL_PROMPT_START_IGNORE '\1'
#define RL_PROMPT_END_IGNORE '\2'
@@ -98,7 +98,7 @@ typedef KEYMAP_ENTRY *Keymap;
extern "C" {
#endif
extern const char *rl_library_version;
-extern int rl_readline_version;
+extern int rl_readline_version;
extern char *rl_readline_name;
extern FILE *rl_instream;
extern FILE *rl_outstream;
@@ -199,10 +199,10 @@ int rl_add_defun(const char *, rl_command_func_t *, int);
HISTORY_STATE *history_get_history_state(void);
void rl_get_screen_size(int *, int *);
void rl_set_screen_size(int, int);
-char *rl_filename_completion_function (const char *, int);
+char *rl_filename_completion_function (const char *, int);
int _rl_abort_internal(void);
int _rl_qsort_string_compare(char **, char **);
-char **rl_completion_matches(const char *, rl_compentry_func_t *);
+char **rl_completion_matches(const char *, rl_compentry_func_t *);
void rl_forced_update_display(void);
int rl_set_prompt(const char *);
int rl_on_new_line(void);
@@ -218,6 +218,8 @@ int rl_generic_bind(int, const char *, const char *, Keymap);
int rl_bind_key_in_map(int, rl_command_func_t *, Keymap);
void rl_cleanup_after_signal(void);
void rl_free_line_state(void);
+int rl_set_keyboard_input_timeout(int);
+
#ifdef __cplusplus
}
#endif
diff --git a/lib/libedit/editline.3 b/lib/libedit/editline.3
index 05ee76e..0234b0d 100644
--- a/lib/libedit/editline.3
+++ b/lib/libedit/editline.3
@@ -1,4 +1,4 @@
-.\" $NetBSD: editline.3,v 1.85 2015/11/03 21:36:59 christos Exp $
+.\" $NetBSD: editline.3,v 1.88 2016/02/25 14:59:22 wiz Exp $
.\"
.\" Copyright (c) 1997-2014 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -28,7 +28,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd November 3, 2015
+.Dd February 24, 2016
.Dt EDITLINE 3
.Os
.Sh NAME
@@ -72,7 +72,7 @@
.Nm tok_wreset ,
.Nm tok_line ,
.Nm tok_wline ,
-.Nm tok_str
+.Nm tok_str ,
.Nm tok_wstr
.Nd line editor, history and tokenization functions
.Sh LIBRARY
@@ -130,9 +130,9 @@
.Ft void
.Fn el_wdeletestr "EditLine *e" "int count"
.Ft History *
-.Fn history_init
+.Fn history_init void
.Ft HistoryW *
-.Fn history_winit
+.Fn history_winit void
.Ft void
.Fn history_end "History *h"
.Ft void
@@ -175,6 +175,16 @@ library (which needs the
library).
Programs should be linked with
.Fl ledit ltermcap .
+.Pp
+The
+.Nm
+library respects the
+.Ev LC_CTYPE
+locale set by the application program and never uses
+.Xr setlocale 3
+to change the locale.
+The only locales supported are UTF-8 and the default C or POSIX locale.
+If any other locale is set, behaviour is undefined.
.Sh LINE EDITING FUNCTIONS
The line editing functions use a common data structure,
.Fa EditLine ,
@@ -240,14 +250,42 @@ contains the error code that caused it.
The return value may not remain valid across calls to
.Fn el_gets
and must be copied if the data is to be retained.
+.It Fn el_wgetc
+Read a wide character from the tty, respecting the current locale,
+or from the input stream written by
+.Fn el_wpush
+and
+.Fn el_push
+if that is not empty, and store it in
+.Fa ch .
+If an invalid or incomplete character is found, it is discarded,
+.Va errno
+is set to
+.Er EILSEQ ,
+and the next character is read and stored in
+.Fa ch .
+Returns 1 if a valid character was read, 0 on end of file, or \-1 on
+.Xr read 2
+failure.
+In the latter case,
+.Va errno
+is set to indicate the error.
.It Fn el_getc
-Read a character from the tty.
-.Fa ch
-is modified to contain the character read.
-Returns the number of characters read if successful, \-1 otherwise,
-in which case
-.Dv errno
-can be inspected for the cause.
+Read a wide character as described for
+.Fn el_wgetc
+and return 0 on end of file or \-1 on failure.
+If the wide character can be represented as a single-byte character,
+convert it with
+.Xr wctob 3 ,
+store the result in
+.Fa ch ,
+and return 1; otherwise, set
+.Va errno
+to
+.Er ERANGE
+and return \-1.
+In the C or POSIX locale, this simply reads a byte, but for any other
+locale, including UTF-8, this is rarely useful.
.It Fn el_push
Pushes
.Fa str
@@ -746,7 +784,7 @@ to the last new element of the history.
.It Dv H_ENTER , Fa "const char *str"
Add
.Fa str
-as a new element to the history, and, if necessary,
+as a new element to the history and, if necessary,
removing the oldest entry to keep the list to the created size.
If
.Dv H_SETUNIQUE
diff --git a/lib/libedit/el.c b/lib/libedit/el.c
index 65bd86b..81020b1 100644
--- a/lib/libedit/el.c
+++ b/lib/libedit/el.c
@@ -1,4 +1,4 @@
-/* $NetBSD: el.c,v 1.74 2015/12/08 12:56:55 christos Exp $ */
+/* $NetBSD: el.c,v 1.83 2016/02/24 17:13:22 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)el.c 8.2 (Berkeley) 1/3/94";
#else
-__RCSID("$NetBSD: el.c,v 1.74 2015/12/08 12:56:55 christos Exp $");
+__RCSID("$NetBSD: el.c,v 1.83 2016/02/24 17:13:22 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
#include <sys/cdefs.h>
@@ -48,13 +48,17 @@ __FBSDID("$FreeBSD$");
*/
#include <sys/types.h>
#include <sys/param.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdarg.h>
#include <ctype.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <string.h>
+#ifdef WIDECHAR
#include <locale.h>
#include <langinfo.h>
+#endif
+
#include "el.h"
+#include "parse.h"
/* el_init():
* Initialize editline and set default parameters.
@@ -95,12 +99,10 @@ el_init_fd(const char *prog, FILE *fin, FILE *fout, FILE *ferr,
* Initialize all the modules. Order is important!!!
*/
el->el_flags = 0;
-#ifdef WIDECHAR
if (setlocale(LC_CTYPE, NULL) != NULL){
if (strcmp(nl_langinfo(CODESET), "UTF-8") == 0)
el->el_flags |= CHARSET_IS_UTF8;
}
-#endif
if (terminal_init(el) == -1) {
el_free(el->el_prog);
@@ -209,7 +211,7 @@ FUN(el,set)(EditLine *el, int op, ...)
el_pfunc_t p = va_arg(ap, el_pfunc_t);
int c = va_arg(ap, int);
- rv = prompt_set(el, p, c, op, 1);
+ rv = prompt_set(el, p, (Char)c, op, 1);
break;
}
@@ -308,7 +310,6 @@ FUN(el,set)(EditLine *el, int op, ...)
{
el_rfunc_t rc = va_arg(ap, el_rfunc_t);
rv = el_read_setfn(el, rc);
- el->el_flags &= ~NARROW_READ;
break;
}
@@ -437,7 +438,7 @@ FUN(el,get)(EditLine *el, int op, ...)
char *argv[20];
int i;
- for (i = 1; i < (int)__arraycount(argv); i++)
+ for (i = 1; i < (int)__arraycount(argv); i++)
if ((argv[i] = va_arg(ap, char *)) == NULL)
break;
@@ -514,6 +515,7 @@ el_source(EditLine *el, const char *fname)
{
FILE *fp;
size_t len;
+ ssize_t slen;
char *ptr;
char *path = NULL;
const Char *dptr;
@@ -550,15 +552,17 @@ el_source(EditLine *el, const char *fname)
return -1;
}
- while ((ptr = fgetln(fp, &len)) != NULL) {
+ ptr = NULL;
+ len = 0;
+ while ((slen = getline(&ptr, &len, fp)) != -1) {
if (*ptr == '\n')
continue; /* Empty line. */
+ if (slen > 0 && ptr[--slen] == '\n')
+ ptr[slen] = '\0';
+
dptr = ct_decode_string(ptr, &el->el_scratch);
if (!dptr)
continue;
- if (len > 0 && dptr[len - 1] == '\n')
- --len;
-
/* loop until first non-space char or EOL */
while (*dptr != '\0' && Isspace(*dptr))
dptr++;
@@ -567,6 +571,7 @@ el_source(EditLine *el, const char *fname)
if ((error = parse_line(el, dptr)) == -1)
break;
}
+ free(ptr);
el_free(path);
(void) fclose(fp);
diff --git a/lib/libedit/el.h b/lib/libedit/el.h
index ed3d2ef..d6b69fc 100644
--- a/lib/libedit/el.h
+++ b/lib/libedit/el.h
@@ -1,4 +1,4 @@
-/* $NetBSD: el.h,v 1.25 2011/07/29 23:44:44 christos Exp $ */
+/* $NetBSD: el.h,v 1.34 2016/02/24 17:13:22 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -49,8 +49,6 @@
#include "histedit.h"
#include "chartype.h"
-#include <stdio.h>
-#include <sys/types.h>
#define EL_BUFSIZ ((size_t)1024) /* Maximum line size */
@@ -59,11 +57,7 @@
#define EDIT_DISABLED 0x04
#define UNBUFFERED 0x08
#define CHARSET_IS_UTF8 0x10
-#define IGNORE_EXTCHARS 0x20 /* Ignore characters read > 0xff */
#define NARROW_HISTORY 0x40
-#define NARROW_READ 0x80
-
-typedef int bool_t; /* True or not */
typedef unsigned char el_action_t; /* Index to command array */
@@ -73,7 +67,7 @@ typedef struct coord_t { /* Position on the screen */
} coord_t;
typedef struct el_line_t {
- Char *buffer; /* Input line */
+ Char *buffer; /* Input line */
Char *cursor; /* Cursor position */
Char *lastchar; /* Last character */
const Char *limit; /* Max position */
@@ -88,7 +82,7 @@ typedef struct el_state_t {
int argument; /* Numeric argument */
int metanext; /* Is the next char a meta char */
el_action_t lastcmd; /* Previous command */
- el_action_t thiscmd; /* this command */
+ el_action_t thiscmd; /* this command */
Char thisch; /* char that generated it */
} el_state_t;
@@ -105,13 +99,11 @@ typedef struct el_state_t {
#include "terminal.h"
#include "refresh.h"
#include "chared.h"
-#include "common.h"
#include "search.h"
#include "hist.h"
+#include "fcns.h" /* el_func_t is needed for map.h */
#include "map.h"
-#include "parse.h"
#include "sig.h"
-#include "help.h"
#include "read.h"
struct editline {
diff --git a/lib/libedit/eln.c b/lib/libedit/eln.c
index 013aa3e..d35e742 100644
--- a/lib/libedit/eln.c
+++ b/lib/libedit/eln.c
@@ -1,4 +1,4 @@
-/* $NetBSD: eln.c,v 1.19 2015/05/18 15:07:04 christos Exp $ */
+/* $NetBSD: eln.c,v 1.28 2016/02/28 23:02:24 christos Exp $ */
/*-
* Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -12,13 +12,6 @@
* 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 NetBSD
- * Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
@@ -34,36 +27,40 @@
*/
#include "config.h"
#if !defined(lint) && !defined(SCCSID)
-__RCSID("$NetBSD: eln.c,v 1.19 2015/05/18 15:07:04 christos Exp $");
+__RCSID("$NetBSD: eln.c,v 1.28 2016/02/28 23:02:24 christos Exp $");
#endif /* not lint && not SCCSID */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#include "histedit.h"
-#include "el.h"
-#include "read.h"
+#include <errno.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
+#include "el.h"
+
public int
el_getc(EditLine *el, char *cp)
{
int num_read;
wchar_t wc = 0;
- if (!(el->el_flags & CHARSET_IS_UTF8))
- el->el_flags |= IGNORE_EXTCHARS;
- num_read = el_wgetc (el, &wc);
- if (!(el->el_flags & CHARSET_IS_UTF8))
- el->el_flags &= ~IGNORE_EXTCHARS;
-
- if (num_read > 0)
- *cp = (char)wc;
- return num_read;
+ num_read = el_wgetc(el, &wc);
+ *cp = '\0';
+ if (num_read <= 0)
+ return num_read;
+ num_read = ct_wctob(wc);
+ if (num_read == EOF) {
+ errno = ERANGE;
+ return -1;
+ } else {
+ *cp = (char)num_read;
+ return 1;
+ }
}
+#ifdef WIDECHAR
public void
el_push(EditLine *el, const char *str)
{
@@ -78,17 +75,15 @@ el_gets(EditLine *el, int *nread)
{
const wchar_t *tmp;
- if (!(el->el_flags & CHARSET_IS_UTF8))
- el->el_flags |= IGNORE_EXTCHARS;
tmp = el_wgets(el, nread);
if (tmp != NULL) {
+ int i;
size_t nwread = 0;
- for (int i = 0; i < *nread; i++)
+
+ for (i = 0; i < *nread; i++)
nwread += ct_enc_width(tmp[i]);
*nread = (int)nwread;
}
- if (!(el->el_flags & CHARSET_IS_UTF8))
- el->el_flags &= ~IGNORE_EXTCHARS;
return ct_encode_string(tmp, &el->el_lgcyconv);
}
@@ -233,7 +228,7 @@ el_set(EditLine *el, int op, ...)
ret = -1;
goto out;
}
- // XXX: The two strdup's leak
+ /* XXX: The two strdup's leak */
ret = map_addfunc(el, Strdup(wargv[0]), Strdup(wargv[1]),
func);
ct_free_argv(wargv);
@@ -247,10 +242,8 @@ el_set(EditLine *el, int op, ...)
break;
}
- /* XXX: do we need to change el_rfunc_t? */
case EL_GETCFN: /* el_rfunc_t */
ret = el_wset(el, op, va_arg(ap, el_rfunc_t));
- el->el_flags |= NARROW_READ;
break;
case EL_CLIENTDATA: /* void * */
@@ -344,7 +337,6 @@ el_get(EditLine *el, int op, ...)
break;
}
- /* XXX: do we need to change el_rfunc_t? */
case EL_GETCFN: /* el_rfunc_t */
ret = el_wget(el, op, va_arg(ap, el_rfunc_t *));
break;
@@ -399,3 +391,4 @@ el_insertstr(EditLine *el, const char *str)
{
return el_winsertstr(el, ct_decode_string(str, &el->el_lgcyconv));
}
+#endif /* WIDECHAR */
diff --git a/lib/libedit/emacs.c b/lib/libedit/emacs.c
index c1c30d6..6c86b9e 100644
--- a/lib/libedit/emacs.c
+++ b/lib/libedit/emacs.c
@@ -1,4 +1,4 @@
-/* $NetBSD: emacs.c,v 1.25 2011/07/29 15:16:33 christos Exp $ */
+/* $NetBSD: emacs.c,v 1.32 2016/02/16 22:53:14 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)emacs.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: emacs.c,v 1.25 2011/07/29 15:16:33 christos Exp $");
+__RCSID("$NetBSD: emacs.c,v 1.32 2016/02/16 22:53:14 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
#include <sys/cdefs.h>
@@ -46,7 +46,10 @@ __FBSDID("$FreeBSD$");
/*
* emacs.c: Emacs functions
*/
+#include <ctype.h>
+
#include "el.h"
+#include "emacs.h"
/* em_delete_or_list():
* Delete character under cursor or list completions if at end of line
@@ -54,7 +57,7 @@ __FBSDID("$FreeBSD$");
*/
protected el_action_t
/*ARGSUSED*/
-em_delete_or_list(EditLine *el, Int c)
+em_delete_or_list(EditLine *el, wint_t c)
{
if (el->el_line.cursor == el->el_line.lastchar) {
@@ -90,7 +93,7 @@ em_delete_or_list(EditLine *el, Int c)
*/
protected el_action_t
/*ARGSUSED*/
-em_delete_next_word(EditLine *el, Int c __attribute__((__unused__)))
+em_delete_next_word(EditLine *el, wint_t c __attribute__((__unused__)))
{
Char *cp, *p, *kp;
@@ -119,7 +122,7 @@ em_delete_next_word(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-em_yank(EditLine *el, Int c __attribute__((__unused__)))
+em_yank(EditLine *el, wint_t c __attribute__((__unused__)))
{
Char *kp, *cp;
@@ -155,7 +158,7 @@ em_yank(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-em_kill_line(EditLine *el, Int c __attribute__((__unused__)))
+em_kill_line(EditLine *el, wint_t c __attribute__((__unused__)))
{
Char *kp, *cp;
@@ -177,7 +180,7 @@ em_kill_line(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-em_kill_region(EditLine *el, Int c __attribute__((__unused__)))
+em_kill_region(EditLine *el, wint_t c __attribute__((__unused__)))
{
Char *kp, *cp;
@@ -210,7 +213,7 @@ em_kill_region(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-em_copy_region(EditLine *el, Int c __attribute__((__unused__)))
+em_copy_region(EditLine *el, wint_t c __attribute__((__unused__)))
{
Char *kp, *cp;
@@ -239,14 +242,14 @@ em_copy_region(EditLine *el, Int c __attribute__((__unused__)))
* Gosling emacs transpose chars [^T]
*/
protected el_action_t
-em_gosmacs_transpose(EditLine *el, Int c)
+em_gosmacs_transpose(EditLine *el, wint_t c)
{
if (el->el_line.cursor > &el->el_line.buffer[1]) {
/* must have at least two chars entered */
c = el->el_line.cursor[-2];
el->el_line.cursor[-2] = el->el_line.cursor[-1];
- el->el_line.cursor[-1] = c;
+ el->el_line.cursor[-1] = (Char)c;
return CC_REFRESH;
} else
return CC_ERROR;
@@ -259,7 +262,7 @@ em_gosmacs_transpose(EditLine *el, Int c)
*/
protected el_action_t
/*ARGSUSED*/
-em_next_word(EditLine *el, Int c __attribute__((__unused__)))
+em_next_word(EditLine *el, wint_t c __attribute__((__unused__)))
{
if (el->el_line.cursor == el->el_line.lastchar)
return CC_ERROR;
@@ -284,7 +287,7 @@ em_next_word(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-em_upper_case(EditLine *el, Int c __attribute__((__unused__)))
+em_upper_case(EditLine *el, wint_t c __attribute__((__unused__)))
{
Char *cp, *ep;
@@ -308,7 +311,7 @@ em_upper_case(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-em_capitol_case(EditLine *el, Int c __attribute__((__unused__)))
+em_capitol_case(EditLine *el, wint_t c __attribute__((__unused__)))
{
Char *cp, *ep;
@@ -340,7 +343,7 @@ em_capitol_case(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-em_lower_case(EditLine *el, Int c __attribute__((__unused__)))
+em_lower_case(EditLine *el, wint_t c __attribute__((__unused__)))
{
Char *cp, *ep;
@@ -364,7 +367,7 @@ em_lower_case(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-em_set_mark(EditLine *el, Int c __attribute__((__unused__)))
+em_set_mark(EditLine *el, wint_t c __attribute__((__unused__)))
{
el->el_chared.c_kill.mark = el->el_line.cursor;
@@ -378,7 +381,7 @@ em_set_mark(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-em_exchange_mark(EditLine *el, Int c __attribute__((__unused__)))
+em_exchange_mark(EditLine *el, wint_t c __attribute__((__unused__)))
{
Char *cp;
@@ -395,7 +398,7 @@ em_exchange_mark(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-em_universal_argument(EditLine *el, Int c __attribute__((__unused__)))
+em_universal_argument(EditLine *el, wint_t c __attribute__((__unused__)))
{ /* multiply current argument by 4 */
if (el->el_state.argument > 1000000)
@@ -412,7 +415,7 @@ em_universal_argument(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-em_meta_next(EditLine *el, Int c __attribute__((__unused__)))
+em_meta_next(EditLine *el, wint_t c __attribute__((__unused__)))
{
el->el_state.metanext = 1;
@@ -425,7 +428,7 @@ em_meta_next(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-em_toggle_overwrite(EditLine *el, Int c __attribute__((__unused__)))
+em_toggle_overwrite(EditLine *el, wint_t c __attribute__((__unused__)))
{
el->el_state.inputmode = (el->el_state.inputmode == MODE_INSERT) ?
@@ -439,7 +442,7 @@ em_toggle_overwrite(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-em_copy_prev_word(EditLine *el, Int c __attribute__((__unused__)))
+em_copy_prev_word(EditLine *el, wint_t c __attribute__((__unused__)))
{
Char *cp, *oldc, *dp;
@@ -466,7 +469,7 @@ em_copy_prev_word(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-em_inc_search_next(EditLine *el, Int c __attribute__((__unused__)))
+em_inc_search_next(EditLine *el, wint_t c __attribute__((__unused__)))
{
el->el_search.patlen = 0;
@@ -479,7 +482,7 @@ em_inc_search_next(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-em_inc_search_prev(EditLine *el, Int c __attribute__((__unused__)))
+em_inc_search_prev(EditLine *el, wint_t c __attribute__((__unused__)))
{
el->el_search.patlen = 0;
@@ -493,7 +496,7 @@ em_inc_search_prev(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-em_delete_prev_char(EditLine *el, Int c __attribute__((__unused__)))
+em_delete_prev_char(EditLine *el, wint_t c __attribute__((__unused__)))
{
if (el->el_line.cursor <= el->el_line.buffer)
diff --git a/lib/libedit/filecomplete.c b/lib/libedit/filecomplete.c
index 4527302..54bf7d9 100644
--- a/lib/libedit/filecomplete.c
+++ b/lib/libedit/filecomplete.c
@@ -1,4 +1,4 @@
-/* $NetBSD: filecomplete.c,v 1.34 2014/10/18 15:07:02 riz Exp $ */
+/* $NetBSD: filecomplete.c,v 1.40 2016/02/17 19:47:49 christos Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -31,27 +31,24 @@
#include "config.h"
#if !defined(lint) && !defined(SCCSID)
-__RCSID("$NetBSD: filecomplete.c,v 1.34 2014/10/18 15:07:02 riz Exp $");
+__RCSID("$NetBSD: filecomplete.c,v 1.40 2016/02/17 19:47:49 christos Exp $");
#endif /* not lint && not SCCSID */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/types.h>
#include <sys/stat.h>
-#include <stdio.h>
#include <dirent.h>
-#include <string.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <limits.h>
#include <pwd.h>
-#include <ctype.h>
+#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <unistd.h>
-#include <limits.h>
-#include <errno.h>
-#include <fcntl.h>
#include "el.h"
-#include "fcns.h" /* for EL_NUM_FCNS */
-#include "histedit.h"
#include "filecomplete.h"
static const Char break_chars[] = { ' ', '\t', '\n', '"', '\\', '\'', '`', '@',
@@ -100,9 +97,9 @@ fn_tilde_expand(const char *txt)
}
if (temp[0] == 0) {
#ifdef HAVE_GETPW_R_POSIX
- if (getpwuid_r(getuid(), &pwres, pwbuf, sizeof(pwbuf),
+ if (getpwuid_r(getuid(), &pwres, pwbuf, sizeof(pwbuf),
&pass) != 0)
- pass = NULL;
+ pass = NULL;
#elif HAVE_GETPW_R_DRAFT
pass = getpwuid_r(getuid(), &pwres, pwbuf, sizeof(pwbuf));
#else
@@ -484,7 +481,7 @@ fn_complete(EditLine *el,
cur_off - (int)len, cur_off);
} else
matches = NULL;
- if (!attempted_completion_function ||
+ if (!attempted_completion_function ||
(over != NULL && !*over && !matches))
matches = completion_matches(
ct_encode_string(dequoted_temp ? dequoted_temp : temp,
@@ -543,7 +540,7 @@ fn_complete(EditLine *el,
}
/* matches[1] through matches[i-1] are available */
matches_num = (size_t)(i - 1);
-
+
/* newline to get on next line from command line */
(void)fprintf(el->el_outfile, "\n");
diff --git a/lib/libedit/hist.c b/lib/libedit/hist.c
index 66cfd312..bcabe68 100644
--- a/lib/libedit/hist.c
+++ b/lib/libedit/hist.c
@@ -1,4 +1,4 @@
-/* $NetBSD: hist.c,v 1.20 2011/07/29 15:16:33 christos Exp $ */
+/* $NetBSD: hist.c,v 1.24 2016/02/16 22:53:14 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)hist.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: hist.c,v 1.20 2011/07/29 15:16:33 christos Exp $");
+__RCSID("$NetBSD: hist.c,v 1.24 2016/02/16 22:53:14 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
#include <sys/cdefs.h>
@@ -47,6 +47,8 @@ __FBSDID("$FreeBSD$");
* hist.c: History access functions
*/
#include <stdlib.h>
+#include <string.h>
+
#include "el.h"
/* hist_init():
diff --git a/lib/libedit/hist.h b/lib/libedit/hist.h
index 6ca6877..23b1e03 100644
--- a/lib/libedit/hist.h
+++ b/lib/libedit/hist.h
@@ -1,4 +1,4 @@
-/* $NetBSD: hist.h,v 1.15 2016/01/30 15:05:27 christos Exp $ */
+/* $NetBSD: hist.h,v 1.18 2016/02/17 19:47:49 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -41,8 +41,6 @@
#ifndef _h_el_hist
#define _h_el_hist
-#include "histedit.h"
-
typedef int (*hist_fun_t)(void *, TYPE(HistEvent) *, int, ...);
typedef struct el_history_t {
@@ -83,7 +81,7 @@ protected int hist_set(EditLine *, hist_fun_t, void *);
protected int hist_command(EditLine *, int, const Char **);
protected int hist_enlargebuf(EditLine *, size_t, size_t);
#ifdef WIDECHAR
-protected wchar_t *hist_convert(EditLine *, int, void *);
+protected wchar_t *hist_convert(EditLine *, int, void *);
#endif
#endif /* _h_el_hist */
diff --git a/lib/libedit/histedit.h b/lib/libedit/histedit.h
index bed186e..e5449ed 100644
--- a/lib/libedit/histedit.h
+++ b/lib/libedit/histedit.h
@@ -1,4 +1,4 @@
-/* $NetBSD: histedit.h,v 1.53 2014/06/18 18:12:28 christos Exp $ */
+/* $NetBSD: histedit.h,v 1.55 2016/02/17 19:47:49 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -130,7 +130,7 @@ unsigned char _el_fn_sh_complete(EditLine *, int);
* For operations that support set or set/get, the argument types listed are for
* the "set" operation. For "get", each listed type must be a pointer.
* E.g. EL_EDITMODE takes an int when set, but an int* when get.
- *
+ *
* Operations that only support "get" have the correct argument types listed.
*/
#define EL_PROMPT 0 /* , prompt_func); set/get */
@@ -143,7 +143,7 @@ unsigned char _el_fn_sh_complete(EditLine *, int);
#define EL_ECHOTC 7 /* , const Char *, ..., NULL); set */
#define EL_SETTY 8 /* , const Char *, ..., NULL); set */
#define EL_ADDFN 9 /* , const Char *, const Char, set */
- /* el_func_t); */
+ /* el_func_t); */
#define EL_HIST 10 /* , hist_fun_t, const void *); set */
#define EL_EDITMODE 11 /* , int); set/get */
#define EL_RPROMPT 12 /* , prompt_func); set/get */
@@ -251,21 +251,10 @@ int tok_str(Tokenizer *, const char *,
/*
* Begin Wide Character Support
*/
-#ifdef __linux__
-/* Apparently we need _GNU_SOURCE defined to get access to wcsdup on Linux */
-#ifndef _GNU_SOURCE
-#define _GNU_SOURCE
-#endif
-#endif
-
#include <wchar.h>
#include <wctype.h>
/*
- * Wide character versions
- */
-
-/*
* ==== Editing ====
*/
typedef struct lineinfow {
diff --git a/lib/libedit/history.c b/lib/libedit/history.c
index 6e225e9..d97a797 100644
--- a/lib/libedit/history.c
+++ b/lib/libedit/history.c
@@ -1,4 +1,4 @@
-/* $NetBSD: history.c,v 1.47 2014/05/11 01:05:17 christos Exp $ */
+/* $NetBSD: history.c,v 1.52 2016/02/17 19:47:49 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)history.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: history.c,v 1.47 2014/05/11 01:05:17 christos Exp $");
+__RCSID("$NetBSD: history.c,v 1.52 2016/02/17 19:47:49 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
#include <sys/cdefs.h>
@@ -46,11 +46,11 @@ __FBSDID("$FreeBSD$");
/*
* hist.c: TYPE(History) access functions
*/
-#include <string.h>
-#include <stdlib.h>
+#include <sys/stat.h>
#include <stdarg.h>
+#include <stdlib.h>
+#include <string.h>
#include <vis.h>
-#include <sys/stat.h>
static const char hist_cookie[] = "_HiStOrY_V2_\n";
@@ -439,7 +439,7 @@ history_def_del(void *p, TYPE(HistEvent) *ev __attribute__((__unused__)),
*/
/* ARGSUSED */
private void
-history_def_delete(history_t *h,
+history_def_delete(history_t *h,
TYPE(HistEvent) *ev __attribute__((__unused__)), hentry_t *hp)
{
HistEventPrivate *evp = (void *)&hp->ev;
@@ -734,7 +734,9 @@ history_load(TYPE(History) *h, const char *fname)
{
FILE *fp;
char *line;
- size_t sz, max_size;
+ size_t llen;
+ ssize_t sz;
+ size_t max_size;
char *ptr;
int i = -1;
TYPE(HistEvent) ev;
@@ -745,26 +747,23 @@ history_load(TYPE(History) *h, const char *fname)
if ((fp = fopen(fname, "r")) == NULL)
return i;
- if ((line = fgetln(fp, &sz)) == NULL)
+ line = NULL;
+ llen = 0;
+ if ((sz = getline(&line, &llen, fp)) == -1)
goto done;
- if (strncmp(line, hist_cookie, sz) != 0)
+ if (strncmp(line, hist_cookie, (size_t)sz) != 0)
goto done;
ptr = h_malloc((max_size = 1024) * sizeof(*ptr));
if (ptr == NULL)
goto done;
- for (i = 0; (line = fgetln(fp, &sz)) != NULL; i++) {
- char c = line[sz];
-
- if (sz != 0 && line[sz - 1] == '\n')
+ for (i = 0; (sz = getline(&line, &llen, fp)) != -1; i++) {
+ if (sz > 0 && line[sz - 1] == '\n')
line[--sz] = '\0';
- else
- line[sz] = '\0';
-
- if (max_size < sz) {
+ if (max_size < (size_t)sz) {
char *nptr;
- max_size = (sz + 1024) & (size_t)~1023;
+ max_size = ((size_t)sz + 1024) & (size_t)~1023;
nptr = h_realloc(ptr, max_size * sizeof(*ptr));
if (nptr == NULL) {
i = -1;
@@ -773,7 +772,6 @@ history_load(TYPE(History) *h, const char *fname)
ptr = nptr;
}
(void) strunvis(ptr, line);
- line[sz] = c;
if (HENTER(h, &ev, ct_decode_string(ptr, &conv)) == -1) {
i = -1;
goto oomem;
@@ -782,6 +780,7 @@ history_load(TYPE(History) *h, const char *fname)
oomem:
h_free(ptr);
done:
+ free(line);
(void) fclose(fp);
return i;
}
@@ -813,8 +812,8 @@ history_save_fp(TYPE(History) *h, FILE *fp)
retval != -1;
retval = HPREV(h, &ev), i++) {
str = ct_encode_string(ev.str, &conv);
- len = strlen(str) * 4;
- if (len >= max_size) {
+ len = strlen(str) * 4 + 1;
+ if (len > max_size) {
char *nptr;
max_size = (len + 1024) & (size_t)~1023;
nptr = h_realloc(ptr, max_size * sizeof(*ptr));
diff --git a/lib/libedit/keymacro.c b/lib/libedit/keymacro.c
index 1a1bdd5..e10ed7f 100644
--- a/lib/libedit/keymacro.c
+++ b/lib/libedit/keymacro.c
@@ -1,4 +1,4 @@
-/* $NetBSD: keymacro.c,v 1.7 2011/08/16 16:25:15 christos Exp $ */
+/* $NetBSD: keymacro.c,v 1.14 2016/02/24 14:25:38 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)key.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: keymacro.c,v 1.7 2011/08/16 16:25:15 christos Exp $");
+__RCSID("$NetBSD: keymacro.c,v 1.14 2016/02/24 14:25:38 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
#include <sys/cdefs.h>
@@ -65,8 +65,8 @@ __FBSDID("$FreeBSD$");
* 1) It is not possible to have one key that is a
* substr of another.
*/
-#include <string.h>
#include <stdlib.h>
+#include <string.h>
#include "el.h"
@@ -75,10 +75,10 @@ __FBSDID("$FreeBSD$");
* linked list of these node elements
*/
struct keymacro_node_t {
- Char ch; /* single character of key */
+ Char ch; /* single character of key */
int type; /* node type */
keymacro_value_t val; /* command code or pointer to str, */
- /* if this is a leaf */
+ /* if this is a leaf */
struct keymacro_node_t *next; /* ptr to next char of this key */
struct keymacro_node_t *sibling;/* ptr to another key with same prefix*/
};
@@ -87,7 +87,7 @@ private int node_trav(EditLine *, keymacro_node_t *, Char *,
keymacro_value_t *);
private int node__try(EditLine *, keymacro_node_t *, const Char *,
keymacro_value_t *, int);
-private keymacro_node_t *node__get(Int);
+private keymacro_node_t *node__get(wint_t);
private void node__free(keymacro_node_t *);
private void node__put(EditLine *, keymacro_node_t *);
private int node__delete(EditLine *, keymacro_node_t **,
@@ -277,21 +277,23 @@ keymacro_print(EditLine *el, const Char *key)
/* node_trav():
* recursively traverses node in tree until match or mismatch is
- * found. May read in more characters.
+ * found. May read in more characters.
*/
private int
node_trav(EditLine *el, keymacro_node_t *ptr, Char *ch, keymacro_value_t *val)
{
+ wchar_t wc;
if (ptr->ch == *ch) {
/* match found */
if (ptr->next) {
/* key not complete so get next char */
- if (FUN(el,getc)(el, ch) != 1) {/* if EOF or error */
+ if (el_wgetc(el, &wc) != 1) {/* if EOF or error */
val->cmd = ED_END_OF_FILE;
return XK_CMD;
/* PWP: Pretend we just read an end-of-file */
}
+ *ch = (Char)wc;
return node_trav(el, ptr->next, ch, val);
} else {
*val = ptr->val;
@@ -314,7 +316,7 @@ node_trav(EditLine *el, keymacro_node_t *ptr, Char *ch, keymacro_value_t *val)
/* node__try():
- * Find a node that matches *str or allocate a new one
+ * Find a node that matches *str or allocate a new one
*/
private int
node__try(EditLine *el, keymacro_node_t *ptr, const Char *str,
@@ -460,14 +462,14 @@ node__put(EditLine *el, keymacro_node_t *ptr)
* Returns pointer to a keymacro_node_t for ch.
*/
private keymacro_node_t *
-node__get(Int ch)
+node__get(wint_t ch)
{
keymacro_node_t *ptr;
ptr = el_malloc(sizeof(*ptr));
if (ptr == NULL)
return NULL;
- ptr->ch = ch;
+ ptr->ch = (Char)ch;
ptr->type = XK_NOD;
ptr->val.str = NULL;
ptr->next = NULL;
@@ -596,7 +598,7 @@ keymacro_kprint(EditLine *el, const Char *key, keymacro_value_t *val, int ntype)
case XK_STR:
case XK_EXE:
(void) keymacro__decode_str(val->str, unparsbuf,
- sizeof(unparsbuf),
+ sizeof(unparsbuf),
ntype == XK_STR ? "\"\"" : "[]");
(void) fprintf(el->el_outfile, fmt,
ct_encode_string(key, &el->el_scratch), unparsbuf);
diff --git a/lib/libedit/makelist b/lib/libedit/makelist
index ec3292f..4cb65bc 100644
--- a/lib/libedit/makelist
+++ b/lib/libedit/makelist
@@ -62,7 +62,7 @@ case $FLAG in
#include "${FILES}"
_EOF
;;
-
+
-h)
set - `echo $FILES | sed -e 's/\\./_/g'`
hdr="_h_`basename $1`"
@@ -79,7 +79,8 @@ _EOF
# XXX: need a space between name and prototype so that -fc and -fh
# parsing is much easier
#
- printf("protected el_action_t\t%s (EditLine *, Int);\n", name);
+ printf("protected el_action_t\t%s (EditLine *, wint_t);\n",
+ name);
}
}
END {
@@ -94,7 +95,7 @@ _EOF
BEGIN {
printf("/* Automatically generated file, do not edit */\n");
printf("#include \"config.h\"\n#include \"el.h\"\n");
- printf("#include \"chartype.h\"\n");
+ printf("#include \"help.h\"\n");
printf("private const struct el_bindings_t el_func_help[] = {\n");
low = "abcdefghijklmnopqrstuvwxyz_";
high = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_";
@@ -163,7 +164,7 @@ _EOF
END {
printf("#define\t%-30.30s\t%3d\n", "EL_NUM_FCNS", count);
- printf("typedef el_action_t (*el_func_t)(EditLine *, Int);");
+ printf("typedef el_action_t (*el_func_t)(EditLine *, wint_t);");
printf("\nprotected const el_func_t* func__get(void);\n");
printf("#endif /* _h_fcns_c */\n");
}'
@@ -176,6 +177,9 @@ _EOF
BEGIN {
printf("/* Automatically generated file, do not edit */\n");
printf("#include \"config.h\"\n#include \"el.h\"\n");
+ printf("#include \"common.h\"\n");
+ printf("#include \"emacs.h\"\n");
+ printf("#include \"vi.h\"\n");
printf("private const el_func_t el_func[] = {");
maxlen = 80;
needn = 1;
diff --git a/lib/libedit/map.c b/lib/libedit/map.c
index 03bb3d8..2d4475c 100644
--- a/lib/libedit/map.c
+++ b/lib/libedit/map.c
@@ -1,4 +1,4 @@
-/* $NetBSD: map.c,v 1.35 2015/05/14 10:44:15 christos Exp $ */
+/* $NetBSD: map.c,v 1.43 2016/02/17 19:47:49 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)map.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: map.c,v 1.35 2015/05/14 10:44:15 christos Exp $");
+__RCSID("$NetBSD: map.c,v 1.43 2016/02/17 19:47:49 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
#include <sys/cdefs.h>
@@ -46,11 +46,16 @@ __FBSDID("$FreeBSD$");
/*
* map.c: Editor function definitions
*/
+#include <ctype.h>
#include <stdlib.h>
+#include <string.h>
+
#include "el.h"
+#include "help.h"
+#include "parse.h"
private void map_print_key(EditLine *, el_action_t *, const Char *);
-private void map_print_some_keys(EditLine *, el_action_t *, Int, Int);
+private void map_print_some_keys(EditLine *, el_action_t *, wint_t, wint_t);
private void map_print_all_keys(EditLine *);
private void map_init_nls(EditLine *);
private void map_init_meta(EditLine *);
@@ -1144,19 +1149,19 @@ map_print_key(EditLine *el, el_action_t *map, const Char *in)
* Print keys from first to last
*/
private void
-map_print_some_keys(EditLine *el, el_action_t *map, Int first, Int last)
+map_print_some_keys(EditLine *el, el_action_t *map, wint_t first, wint_t last)
{
el_bindings_t *bp, *ep;
Char firstbuf[2], lastbuf[2];
char unparsbuf[EL_BUFSIZ], extrabuf[EL_BUFSIZ];
- firstbuf[0] = first;
+ firstbuf[0] = (Char)first;
firstbuf[1] = 0;
- lastbuf[0] = last;
+ lastbuf[0] = (Char)last;
lastbuf[1] = 0;
if (map[first] == ED_UNASSIGNED) {
if (first == last) {
- (void) keymacro__decode_str(firstbuf, unparsbuf,
+ (void) keymacro__decode_str(firstbuf, unparsbuf,
sizeof(unparsbuf), STRQQ);
(void) fprintf(el->el_outfile,
"%-15s-> is undefined\n", unparsbuf);
@@ -1167,14 +1172,14 @@ map_print_some_keys(EditLine *el, el_action_t *map, Int first, Int last)
for (bp = el->el_map.help; bp < ep; bp++) {
if (bp->func == map[first]) {
if (first == last) {
- (void) keymacro__decode_str(firstbuf, unparsbuf,
+ (void) keymacro__decode_str(firstbuf, unparsbuf,
sizeof(unparsbuf), STRQQ);
(void) fprintf(el->el_outfile, "%-15s-> " FSTR "\n",
unparsbuf, bp->name);
} else {
- (void) keymacro__decode_str(firstbuf, unparsbuf,
+ (void) keymacro__decode_str(firstbuf, unparsbuf,
sizeof(unparsbuf), STRQQ);
- (void) keymacro__decode_str(lastbuf, extrabuf,
+ (void) keymacro__decode_str(lastbuf, extrabuf,
sizeof(extrabuf), STRQQ);
(void) fprintf(el->el_outfile,
"%-4s to %-7s-> " FSTR "\n",
@@ -1185,14 +1190,14 @@ map_print_some_keys(EditLine *el, el_action_t *map, Int first, Int last)
}
#ifdef MAP_DEBUG
if (map == el->el_map.key) {
- (void) keymacro__decode_str(firstbuf, unparsbuf,
+ (void) keymacro__decode_str(firstbuf, unparsbuf,
sizeof(unparsbuf), STRQQ);
(void) fprintf(el->el_outfile,
"BUG!!! %s isn't bound to anything.\n", unparsbuf);
(void) fprintf(el->el_outfile, "el->el_map.key[%d] == %d\n",
first, el->el_map.key[first]);
} else {
- (void) keymacro__decode_str(firstbuf, unparsbuf,
+ (void) keymacro__decode_str(firstbuf, unparsbuf,
sizeof(unparsbuf), STRQQ);
(void) fprintf(el->el_outfile,
"BUG!!! %s isn't bound to anything.\n", unparsbuf);
@@ -1302,8 +1307,8 @@ map_bind(EditLine *el, int argc, const Char **argv)
return 0;
default:
(void) fprintf(el->el_errfile,
- "" FSTR ": Invalid switch `" FCHAR "'.\n",
- argv[0], (Int)p[1]);
+ "" FSTR ": Invalid switch `%lc'.\n",
+ argv[0], (wint_t)p[1]);
}
else
break;
diff --git a/lib/libedit/parse.c b/lib/libedit/parse.c
index 1c19cc7..1b7bdb4 100644
--- a/lib/libedit/parse.c
+++ b/lib/libedit/parse.c
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.c,v 1.27 2014/07/06 18:15:34 christos Exp $ */
+/* $NetBSD: parse.c,v 1.35 2016/02/17 19:47:49 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)parse.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: parse.c,v 1.27 2014/07/06 18:15:34 christos Exp $");
+__RCSID("$NetBSD: parse.c,v 1.35 2016/02/17 19:47:49 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
#include <sys/cdefs.h>
@@ -56,16 +56,19 @@ __FBSDID("$FreeBSD$");
* settc
* setty
*/
-#include "el.h"
#include <stdlib.h>
+#include <string.h>
+
+#include "el.h"
+#include "parse.h"
private const struct {
const Char *name;
int (*func)(EditLine *, int, const Char **);
} cmds[] = {
- { STR("bind"), map_bind },
+ { STR("bind"), map_bind },
{ STR("echotc"), terminal_echotc },
- { STR("edit"), el_editmode },
+ { STR("edit"), el_editmode },
{ STR("history"), hist_command },
{ STR("telltc"), terminal_telltc },
{ STR("settc"), terminal_settc },
@@ -141,7 +144,7 @@ protected int
parse__escape(const Char **ptr)
{
const Char *p;
- Int c;
+ wint_t c;
p = *ptr;
@@ -253,7 +256,7 @@ parse__string(Char *out, const Char *in)
case '^':
if ((n = parse__escape(&in)) == -1)
return NULL;
- *out++ = n;
+ *out++ = (Char)n;
break;
case 'M':
diff --git a/lib/libedit/prompt.c b/lib/libedit/prompt.c
index 3696d0c..afd75bd 100644
--- a/lib/libedit/prompt.c
+++ b/lib/libedit/prompt.c
@@ -1,4 +1,4 @@
-/* $NetBSD: prompt.c,v 1.20 2011/07/29 15:16:33 christos Exp $ */
+/* $NetBSD: prompt.c,v 1.23 2016/02/16 15:53:48 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)prompt.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: prompt.c,v 1.20 2011/07/29 15:16:33 christos Exp $");
+__RCSID("$NetBSD: prompt.c,v 1.23 2016/02/16 15:53:48 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
#include <sys/cdefs.h>
diff --git a/lib/libedit/prompt.h b/lib/libedit/prompt.h
index 260c818..5e14b76 100644
--- a/lib/libedit/prompt.h
+++ b/lib/libedit/prompt.h
@@ -1,4 +1,4 @@
-/* $NetBSD: prompt.h,v 1.10 2009/12/30 22:37:40 christos Exp $ */
+/* $NetBSD: prompt.h,v 1.13 2016/02/17 19:47:49 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -41,15 +41,13 @@
#ifndef _h_el_prompt
#define _h_el_prompt
-#include "histedit.h"
-
typedef Char *(*el_pfunc_t)(EditLine *);
typedef struct el_prompt_t {
el_pfunc_t p_func; /* Function to return the prompt */
coord_t p_pos; /* position in the line after prompt */
Char p_ignore; /* character to start/end literal */
- int p_wide;
+ int p_wide;
} el_prompt_t;
protected void prompt_print(EditLine *, int);
diff --git a/lib/libedit/read.c b/lib/libedit/read.c
index 9740599..66e266b 100644
--- a/lib/libedit/read.c
+++ b/lib/libedit/read.c
@@ -1,4 +1,4 @@
-/* $NetBSD: read.c,v 1.71 2014/07/06 18:15:34 christos Exp $ */
+/* $NetBSD: read.c,v 1.86 2016/03/02 19:24:20 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)read.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: read.c,v 1.71 2014/07/06 18:15:34 christos Exp $");
+__RCSID("$NetBSD: read.c,v 1.86 2016/03/02 19:24:20 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
#include <sys/cdefs.h>
@@ -47,18 +47,21 @@ __FBSDID("$FreeBSD$");
* read.c: Clean this junk up! This is horrible code.
* Terminal read functions
*/
+#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
-#include <unistd.h>
-#include <stdlib.h>
#include <limits.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
#include "el.h"
#define OKCMD -1 /* must be -1! */
private int read__fixio(int, int);
private int read_preread(EditLine *);
-private int read_char(EditLine *, Char *);
+private int read_char(EditLine *, wchar_t *);
private int read_getcmd(EditLine *, el_action_t *, Char *);
private void read_pop(c_macro_t *);
@@ -241,18 +244,21 @@ FUN(el,push)(EditLine *el, const Char *str)
private int
read_getcmd(EditLine *el, el_action_t *cmdnum, Char *ch)
{
+ static const Char meta = (Char)0x80;
el_action_t cmd;
+ wchar_t wc;
int num;
el->el_errno = 0;
do {
- if ((num = FUN(el,getc)(el, ch)) != 1) {/* if EOF or error */
+ if ((num = el_wgetc(el, &wc)) != 1) {/* if EOF or error */
el->el_errno = num == 0 ? 0 : errno;
return 0; /* not OKCMD */
}
+ *ch = (Char)wc;
#ifdef KANJI
- if ((*ch & 0200)) {
+ if ((*ch & meta)) {
el->el_state.metanext = 0;
cmd = CcViMap[' '];
break;
@@ -261,7 +267,7 @@ read_getcmd(EditLine *el, el_action_t *cmdnum, Char *ch)
if (el->el_state.metanext) {
el->el_state.metanext = 0;
- *ch |= 0200;
+ *ch |= meta;
}
#ifdef WIDECHAR
if (*ch >= N_KEYS)
@@ -296,29 +302,17 @@ read_getcmd(EditLine *el, el_action_t *cmdnum, Char *ch)
return OKCMD;
}
-#ifdef WIDECHAR
-/* utf8_islead():
- * Test whether a byte is a leading byte of a UTF-8 sequence.
- */
-private int
-utf8_islead(int c)
-{
- return c < 0x80 || /* single byte char */
- (c >= 0xc2 && c <= 0xf4); /* start of multibyte sequence */
-}
-#endif
-
/* read_char():
* Read a character from the tty.
*/
private int
-read_char(EditLine *el, Char *cp)
+read_char(EditLine *el, wchar_t *cp)
{
ssize_t num_read;
int tried = 0;
char cbuf[MB_LEN_MAX];
size_t cbp = 0;
- int bytes = 0;
+ int save_errno = errno;
again:
el->el_signal->sig_no = 0;
@@ -334,50 +328,59 @@ read_char(EditLine *el, Char *cp)
default:
break;
}
- if (!tried && read__fixio(el->el_infd, e) == 0)
+ if (!tried && read__fixio(el->el_infd, e) == 0) {
+ errno = save_errno;
tried = 1;
- else {
+ } else {
errno = e;
- *cp = '\0';
+ *cp = L'\0';
return -1;
}
}
/* Test for EOF */
if (num_read == 0) {
- errno = 0;
- *cp = '\0';
+ *cp = L'\0';
return 0;
}
-#ifdef WIDECHAR
- if (el->el_flags & CHARSET_IS_UTF8) {
- if (!utf8_islead((unsigned char)cbuf[0]))
- goto again; /* discard the byte we read and try again */
+ for (;;) {
+
++cbp;
- if ((bytes = ct_mbtowc(cp, cbuf, cbp)) == -1) {
- ct_mbtowc_reset;
- if (cbp >= MB_LEN_MAX) { /* "shouldn't happen" */
+ switch (ct_mbrtowc(cp, cbuf, cbp)) {
+ case (size_t)-1:
+ if (cbp > 1) {
+ /*
+ * Invalid sequence, discard all bytes
+ * except the last one.
+ */
+ cbuf[0] = cbuf[cbp - 1];
+ cbp = 0;
+ break;
+ } else {
+ /* Invalid byte, discard it. */
+ cbp = 0;
+ goto again;
+ }
+ case (size_t)-2:
+ /*
+ * We don't support other multibyte charsets.
+ * The second condition shouldn't happen
+ * and is here merely for additional safety.
+ */
+ if ((el->el_flags & CHARSET_IS_UTF8) == 0 ||
+ cbp >= MB_LEN_MAX) {
errno = EILSEQ;
- *cp = '\0';
+ *cp = L'\0';
return -1;
}
+ /* Incomplete sequence, read another byte. */
goto again;
+ default:
+ /* Valid character, process it. */
+ return 1;
}
- } else if (isascii((unsigned char)cbuf[0]) ||
- /* we don't support other multibyte charsets */
- ++cbp != 1 ||
- /* Try non-ASCII characters in a 8-bit character set */
- (bytes = ct_mbtowc(cp, cbuf, cbp)) != 1)
-#endif
- *cp = (unsigned char)cbuf[0];
-
- if ((el->el_flags & IGNORE_EXTCHARS) && bytes > 1) {
- cbp = 0; /* skip this character */
- goto again;
}
-
- return (int)num_read;
}
/* read_pop():
@@ -395,11 +398,11 @@ read_pop(c_macro_t *ma)
ma->offset = 0;
}
-/* el_getc():
- * Read a character
+/* el_wgetc():
+ * Read a wide character
*/
public int
-FUN(el,getc)(EditLine *el, Char *cp)
+el_wgetc(EditLine *el, wchar_t *cp)
{
int num_read;
c_macro_t *ma = &el->el_chared.c_macro;
@@ -441,12 +444,8 @@ FUN(el,getc)(EditLine *el, Char *cp)
num_read = (*el->el_read.read_char)(el, cp);
if (num_read < 0)
el->el_errno = errno;
-#ifdef WIDECHAR
- if (el->el_flags & NARROW_READ)
- *cp = *(char *)(void *)cp;
-#endif
#ifdef DEBUG_READ
- (void) fprintf(el->el_errfile, "Got it %c\n", *cp);
+ (void) fprintf(el->el_errfile, "Got it %lc\n", *cp);
#endif /* DEBUG_READ */
return num_read;
}
@@ -487,6 +486,7 @@ FUN(el,gets)(EditLine *el, int *nread)
int retval;
el_action_t cmdnum = 0;
int num; /* how many chars we have read at NL */
+ wchar_t wc;
Char ch, *cp;
int crlf = 0;
int nrb;
@@ -502,7 +502,8 @@ FUN(el,gets)(EditLine *el, int *nread)
size_t idx;
cp = el->el_line.buffer;
- while ((num = (*el->el_read.read_char)(el, cp)) == 1) {
+ while ((num = (*el->el_read.read_char)(el, &wc)) == 1) {
+ *cp = (Char)wc;
/* make sure there is space for next character */
if (cp + 1 >= el->el_line.limit) {
idx = (size_t)(cp - el->el_line.buffer);
@@ -554,7 +555,8 @@ FUN(el,gets)(EditLine *el, int *nread)
terminal__flush(el);
- while ((num = (*el->el_read.read_char)(el, cp)) == 1) {
+ while ((num = (*el->el_read.read_char)(el, &wc)) == 1) {
+ *cp = (Char)wc;
/* make sure there is space next character */
if (cp + 1 >= el->el_line.limit) {
idx = (size_t)(cp - el->el_line.buffer);
@@ -615,7 +617,7 @@ FUN(el,gets)(EditLine *el, int *nread)
break;
if (b->name)
(void) fprintf(el->el_errfile,
- "Executing %s\n", b->name);
+ "Executing " FSTR "\n", b->name);
else
(void) fprintf(el->el_errfile,
"Error command = %d\n", cmdnum);
diff --git a/lib/libedit/read.h b/lib/libedit/read.h
index fa2a611..bf43053 100644
--- a/lib/libedit/read.h
+++ b/lib/libedit/read.h
@@ -1,4 +1,4 @@
-/* $NetBSD: read.h,v 1.7 2009/12/30 22:37:40 christos Exp $ */
+/* $NetBSD: read.h,v 1.9 2016/02/24 17:13:22 christos Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -37,12 +37,12 @@
#ifndef _h_el_read
#define _h_el_read
-typedef int (*el_rfunc_t)(EditLine *, Char *);
+typedef int (*el_rfunc_t)(EditLine *, wchar_t *);
typedef struct el_read_t {
el_rfunc_t read_char; /* Function to read a character */
} el_read_t;
-
+
protected int read_init(EditLine *);
protected void read_prepare(EditLine *);
protected void read_finish(EditLine *);
diff --git a/lib/libedit/readline.c b/lib/libedit/readline.c
index caddb9f..00ea369 100644
--- a/lib/libedit/readline.c
+++ b/lib/libedit/readline.c
@@ -1,4 +1,4 @@
-/* $NetBSD: readline.c,v 1.117 2015/06/02 15:35:31 christos Exp $ */
+/* $NetBSD: readline.c,v 1.126 2016/02/24 17:13:22 christos Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -31,30 +31,29 @@
#include "config.h"
#if !defined(lint) && !defined(SCCSID)
-__RCSID("$NetBSD: readline.c,v 1.117 2015/06/02 15:35:31 christos Exp $");
+__RCSID("$NetBSD: readline.c,v 1.126 2016/02/24 17:13:22 christos Exp $");
#endif /* not lint && not SCCSID */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/types.h>
#include <sys/stat.h>
-#include <stdio.h>
-#include <dirent.h>
-#include <string.h>
-#include <pwd.h>
#include <ctype.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <limits.h>
+#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
+#include <limits.h>
+#include <pwd.h>
#include <setjmp.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
#include <vis.h>
#include "readline/readline.h"
#include "el.h"
-#include "fcns.h" /* for EL_NUM_FCNS */
-#include "histedit.h"
#include "filecomplete.h"
void rl_prep_terminal(int);
@@ -169,13 +168,13 @@ static jmp_buf topbuf;
static unsigned char _el_rl_complete(EditLine *, int);
static unsigned char _el_rl_tstp(EditLine *, int);
static char *_get_prompt(EditLine *);
-static int _getc_function(EditLine *, char *);
+static int _getc_function(EditLine *, wchar_t *);
static HIST_ENTRY *_move_history(int);
static int _history_expand_command(const char *, size_t, size_t,
char **);
static char *_rl_compat_sub(const char *, const char *,
const char *, int);
-static int _rl_event_read_char(EditLine *, char *);
+static int _rl_event_read_char(EditLine *, wchar_t *);
static void _rl_update_pos(void);
@@ -212,14 +211,14 @@ _move_history(int op)
*/
static int
/*ARGSUSED*/
-_getc_function(EditLine *el __attribute__((__unused__)), char *c)
+_getc_function(EditLine *el __attribute__((__unused__)), wchar_t *c)
{
int i;
i = (*rl_getc_function)(NULL);
if (i == -1)
return 0;
- *c = (char)i;
+ *c = (wchar_t)i;
return 1;
}
@@ -269,7 +268,7 @@ rl_set_prompt(const char *prompt)
if (!prompt)
prompt = "";
- if (rl_prompt != NULL && strcmp(rl_prompt, prompt) == 0)
+ if (rl_prompt != NULL && strcmp(rl_prompt, prompt) == 0)
return 0;
if (rl_prompt)
el_free(rl_prompt);
@@ -363,7 +362,7 @@ rl_initialize(void)
"ReadLine compatible suspend function",
_el_rl_tstp);
el_set(e, EL_BIND, "^Z", "rl_tstp", NULL);
-
+
/*
* Set some readline compatible key-bindings.
*/
@@ -2010,7 +2009,7 @@ rl_callback_read_char(void)
}
}
-void
+void
rl_callback_handler_install(const char *prompt, rl_vcpfunc_t *linefunc)
{
if (e == NULL) {
@@ -2019,9 +2018,9 @@ rl_callback_handler_install(const char *prompt, rl_vcpfunc_t *linefunc)
(void)rl_set_prompt(prompt);
rl_linefunc = linefunc;
el_set(e, EL_UNBUFFERED, 1);
-}
+}
-void
+void
rl_callback_handler_remove(void)
{
el_set(e, EL_UNBUFFERED, 0);
@@ -2102,12 +2101,14 @@ rl_stuff_char(int c)
}
static int
-_rl_event_read_char(EditLine *el, char *cp)
+_rl_event_read_char(EditLine *el, wchar_t *wc)
{
+ char ch;
int n;
ssize_t num_read = 0;
- *cp = '\0';
+ ch = '\0';
+ *wc = L'\0';
while (rl_event_hook) {
(*rl_event_hook)();
@@ -2116,7 +2117,7 @@ _rl_event_read_char(EditLine *el, char *cp)
if (ioctl(el->el_infd, FIONREAD, &n) < 0)
return -1;
if (n)
- num_read = read(el->el_infd, cp, (size_t)1);
+ num_read = read(el->el_infd, &ch, (size_t)1);
else
num_read = 0;
#elif defined(F_SETFL) && defined(O_NDELAY)
@@ -2124,12 +2125,12 @@ _rl_event_read_char(EditLine *el, char *cp)
return -1;
if (fcntl(el->el_infd, F_SETFL, n|O_NDELAY) < 0)
return -1;
- num_read = read(el->el_infd, cp, 1);
+ num_read = read(el->el_infd, &ch, 1);
if (fcntl(el->el_infd, F_SETFL, n))
return -1;
#else
/* not non-blocking, but what you gonna do? */
- num_read = read(el->el_infd, cp, 1);
+ num_read = read(el->el_infd, &ch, 1);
return -1;
#endif
@@ -2141,6 +2142,7 @@ _rl_event_read_char(EditLine *el, char *cp)
}
if (!rl_event_hook)
el_set(el, EL_GETCFN, EL_BUILTIN_GETCFN);
+ *wc = (wchar_t)ch;
return (int)num_read;
}
@@ -2203,7 +2205,7 @@ rl_completion_matches(const char *str, rl_compentry_func_t *fun)
}
qsort(&list[1], len - 1, sizeof(*list),
(int (*)(const void *, const void *)) strcmp);
- min = SIZE_T_MAX;
+ min = SIZE_MAX;
for (i = 1, a = list[i]; i < len - 1; i++, a = b) {
b = list[i + 1];
for (j = 0; a[j] && a[j] == b[j]; j++)
@@ -2221,7 +2223,7 @@ rl_completion_matches(const char *str, rl_compentry_func_t *fun)
list[0][min] = '\0';
}
return list;
-
+
out:
el_free(list);
return NULL;
@@ -2325,3 +2327,10 @@ void
rl_free_line_state(void)
{
}
+
+int
+/*ARGSUSED*/
+rl_set_keyboard_input_timeout(int u __attribute__((__unused__)))
+{
+ return 0;
+}
diff --git a/lib/libedit/refresh.c b/lib/libedit/refresh.c
index cd516f6..8f4b08e 100644
--- a/lib/libedit/refresh.c
+++ b/lib/libedit/refresh.c
@@ -1,4 +1,4 @@
-/* $NetBSD: refresh.c,v 1.37 2011/07/29 23:44:45 christos Exp $ */
+/* $NetBSD: refresh.c,v 1.45 2016/03/02 19:24:20 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)refresh.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: refresh.c,v 1.37 2011/07/29 23:44:45 christos Exp $");
+__RCSID("$NetBSD: refresh.c,v 1.45 2016/03/02 19:24:20 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
#include <sys/cdefs.h>
@@ -47,26 +47,25 @@ __FBSDID("$FreeBSD$");
* refresh.c: Lower level screen refreshing functions
*/
#include <stdio.h>
-#include <ctype.h>
-#include <unistd.h>
#include <string.h>
+#include <unistd.h>
#include "el.h"
private void re_nextline(EditLine *);
-private void re_addc(EditLine *, Int);
+private void re_addc(EditLine *, wint_t);
private void re_update_line(EditLine *, Char *, Char *, int);
private void re_insert (EditLine *, Char *, int, int, Char *, int);
private void re_delete(EditLine *, Char *, int, int, int);
-private void re_fastputc(EditLine *, Int);
+private void re_fastputc(EditLine *, wint_t);
private void re_clear_eol(EditLine *, int, int, int);
private void re__strncopy(Char *, Char *, size_t);
private void re__copy_and_pad(Char *, const Char *, size_t);
#ifdef DEBUG_REFRESH
-private void re_printstr(EditLine *, const char *, char *, char *);
+private void re_printstr(EditLine *, const char *, Char *, Char *);
#define __F el->el_errfile
-#define ELRE_ASSERT(a, b, c) do \
+#define ELRE_ASSERT(a, b, c) do \
if (/*CONSTCOND*/ a) { \
(void) fprintf b; \
c; \
@@ -78,7 +77,7 @@ private void re_printstr(EditLine *, const char *, char *, char *);
* Print a string on the debugging pty
*/
private void
-re_printstr(EditLine *el, const char *str, char *f, char *t)
+re_printstr(EditLine *el, const char *str, Char *f, Char *t)
{
ELRE_DEBUG(1, (__F, "%s:\"", str));
@@ -112,7 +111,7 @@ re_nextline(EditLine *el)
for(i = 1; i < lins; i++)
el->el_vdisplay[i - 1] = el->el_vdisplay[i];
- firstline[0] = '\0'; /* empty the string */
+ firstline[0] = '\0'; /* empty the string */
el->el_vdisplay[i - 1] = firstline;
} else
el->el_refresh.r_cursor.v++;
@@ -127,7 +126,7 @@ re_nextline(EditLine *el)
* Draw c, expanding tabs, control chars etc.
*/
private void
-re_addc(EditLine *el, Int c)
+re_addc(EditLine *el, wint_t c)
{
switch (ct_chr_class((Char)c)) {
case CHTYPE_TAB: /* expand the tab */
@@ -163,16 +162,16 @@ re_addc(EditLine *el, Int c)
* Draw the character given
*/
protected void
-re_putc(EditLine *el, Int c, int shift)
+re_putc(EditLine *el, wint_t c, int shift)
{
int i, w = Width(c);
- ELRE_DEBUG(1, (__F, "printing %5x '%c'\r\n", c, c));
+ ELRE_DEBUG(1, (__F, "printing %5x '%lc'\r\n", c, c));
while (shift && (el->el_refresh.r_cursor.h + w > el->el_terminal.t_size.h))
re_putc(el, ' ', 1);
el->el_vdisplay[el->el_refresh.r_cursor.v]
- [el->el_refresh.r_cursor.h] = c;
+ [el->el_refresh.r_cursor.h] = (Char)c;
/* assumes !shift is only used for single-column chars */
i = w;
while (--i > 0)
@@ -194,7 +193,7 @@ re_putc(EditLine *el, Int c, int shift)
/* re_refresh():
* draws the new virtual screen image from the current input
- * line, then goes line-by-line changing the real image to the new
+ * line, then goes line-by-line changing the real image to the new
* virtual image. The routine to re-draw a line can be replaced
* easily in hopes of a smarter one being placed there.
*/
@@ -208,7 +207,7 @@ re_refresh(EditLine *el)
size_t termsz;
#endif
- ELRE_DEBUG(1, (__F, "el->el_line.buffer = :%s:\r\n",
+ ELRE_DEBUG(1, (__F, "el->el_line.buffer = :" FSTR ":\r\n",
el->el_line.buffer));
/* reset the Drawing cursor */
@@ -296,7 +295,8 @@ re_refresh(EditLine *el)
ELRE_DEBUG(1, (__F,
"term.h=%d vcur.h=%d vcur.v=%d vdisplay[0]=\r\n:%80.80s:\r\n",
el->el_terminal.t_size.h, el->el_refresh.r_cursor.h,
- el->el_refresh.r_cursor.v, ct_encode_string(el->el_vdisplay[0])));
+ el->el_refresh.r_cursor.v, ct_encode_string(el->el_vdisplay[0],
+ &el->el_scratch)));
ELRE_DEBUG(1, (__F, "updating %d lines.\r\n", el->el_refresh.r_newcv));
for (i = 0; i <= el->el_refresh.r_newcv; i++) {
@@ -324,7 +324,7 @@ re_refresh(EditLine *el)
/* This Strlen should be safe even with MB_FILL_CHARs */
terminal_clear_EOL(el, (int) Strlen(el->el_display[i]));
#ifdef DEBUG_REFRESH
- terminal_overwrite(el, "C\b", (size_t)2);
+ terminal_overwrite(el, STR("C\b"), 2);
#endif /* DEBUG_REFRESH */
el->el_display[i][0] = '\0';
}
@@ -371,8 +371,9 @@ re_insert(EditLine *el __attribute__((__unused__)),
ELRE_DEBUG(1,
(__F, "re_insert() starting: %d at %d max %d, d == \"%s\"\n",
- num, dat, dlen, ct_encode_string(d)));
- ELRE_DEBUG(1, (__F, "s == \"%s\"\n", ct_encode_string(s)));
+ num, dat, dlen, ct_encode_string(d, &el->el_scratch)));
+ ELRE_DEBUG(1, (__F, "s == \"%s\"\n", ct_encode_string(s,
+ &el->el_scratch)));
/* open up the space for num chars */
if (num > 0) {
@@ -385,8 +386,9 @@ re_insert(EditLine *el __attribute__((__unused__)),
ELRE_DEBUG(1, (__F,
"re_insert() after insert: %d at %d max %d, d == \"%s\"\n",
- num, dat, dlen, ct_encode_string(d)));
- ELRE_DEBUG(1, (__F, "s == \"%s\"\n", ct_encode_string(s)));
+ num, dat, dlen, ct_encode_string(d, &el->el_scratch)));
+ ELRE_DEBUG(1, (__F, "s == \"%s\"\n", ct_encode_string(s,
+ &el->el_scratch)));
/* copy the characters */
for (a = d + dat; (a < d + dlen) && (num > 0); num--)
@@ -421,7 +423,7 @@ re_delete(EditLine *el __attribute__((__unused__)),
}
ELRE_DEBUG(1,
(__F, "re_delete() starting: %d at %d max %d, d == \"%s\"\n",
- num, dat, dlen, ct_encode_string(d)));
+ num, dat, dlen, ct_encode_string(d, &el->el_scratch)));
/* open up the space for num chars */
if (num > 0) {
@@ -433,7 +435,7 @@ re_delete(EditLine *el __attribute__((__unused__)),
}
ELRE_DEBUG(1,
(__F, "re_delete() after delete: %d at %d max %d, d == \"%s\"\n",
- num, dat, dlen, ct_encode_string(d)));
+ num, dat, dlen, ct_encode_string(d, &el->el_scratch)));
}
@@ -453,7 +455,7 @@ re__strncopy(Char *a, Char *b, size_t n)
* in order to make sure that we have cleared the previous contents of
* the line. fx and sx is the number of characters inserted or deleted
* in the first or second diff, diff is the difference between the
- * number of characters between the new and old line.
+ * number of characters between the new and old line.
*/
private void
re_clear_eol(EditLine *el, int fx, int sx, int diff)
@@ -691,9 +693,9 @@ re_update_line(EditLine *el, Char *old, Char *new, int i)
sx = (int)((nls - nse) - (ols - ose));
ELRE_DEBUG(1, (__F, "fx %d, sx %d\n", fx, sx));
- ELRE_DEBUG(1, (__F, "ofd %d, osb %d, ose %d, ols %d, oe %d\n",
+ ELRE_DEBUG(1, (__F, "ofd %td, osb %td, ose %td, ols %td, oe %td\n",
ofd - old, osb - old, ose - old, ols - old, oe - old));
- ELRE_DEBUG(1, (__F, "nfd %d, nsb %d, nse %d, nls %d, ne %d\n",
+ ELRE_DEBUG(1, (__F, "nfd %td, nsb %td, nse %td, nls %td, ne %td\n",
nfd - new, nsb - new, nse - new, nls - new, ne - new));
ELRE_DEBUG(1, (__F,
"xxx-xxx:\"00000000001111111111222222222233333333334\"\r\n"));
@@ -767,7 +769,7 @@ re_update_line(EditLine *el, Char *old, Char *new, int i)
if ((nsb != nfd) && fx > 0 &&
((p - old) + fx <= el->el_terminal.t_size.h)) {
ELRE_DEBUG(1,
- (__F, "first diff insert at %d...\r\n", nfd - new));
+ (__F, "first diff insert at %td...\r\n", nfd - new));
/*
* Move to the first char to insert, where the first diff is.
*/
@@ -806,7 +808,7 @@ re_update_line(EditLine *el, Char *old, Char *new, int i)
}
} else if (fx < 0) {
ELRE_DEBUG(1,
- (__F, "first diff delete at %d...\r\n", ofd - old));
+ (__F, "first diff delete at %td...\r\n", ofd - old));
/*
* move to the first char to delete where the first diff is
*/
@@ -853,7 +855,7 @@ re_update_line(EditLine *el, Char *old, Char *new, int i)
if (sx < 0 && (ose - old) + fx < el->el_terminal.t_size.h) {
ELRE_DEBUG(1, (__F,
- "second diff delete at %d...\r\n", (ose - old) + fx));
+ "second diff delete at %td...\r\n", (ose - old) + fx));
/*
* Check if we have stuff to delete
*/
@@ -891,7 +893,7 @@ re_update_line(EditLine *el, Char *old, Char *new, int i)
* if we have a first insert AND WE HAVEN'T ALREADY DONE IT...
*/
if ((nsb != nfd) && (osb - ofd) <= (nsb - nfd) && (fx == 0)) {
- ELRE_DEBUG(1, (__F, "late first diff insert at %d...\r\n",
+ ELRE_DEBUG(1, (__F, "late first diff insert at %td...\r\n",
nfd - new));
terminal_move_to_char(el, (int)(nfd - new));
@@ -1054,14 +1056,14 @@ re_refresh_cursor(EditLine *el)
* Add a character fast.
*/
private void
-re_fastputc(EditLine *el, Int c)
+re_fastputc(EditLine *el, wint_t c)
{
int w = Width((Char)c);
while (w > 1 && el->el_cursor.h + w > el->el_terminal.t_size.h)
re_fastputc(el, ' ');
terminal__putc(el, c);
- el->el_display[el->el_cursor.v][el->el_cursor.h++] = c;
+ el->el_display[el->el_cursor.v][el->el_cursor.h++] = (Char)c;
while (--w > 0)
el->el_display[el->el_cursor.v][el->el_cursor.h++]
= MB_FILL_CHAR;
@@ -1079,7 +1081,7 @@ re_fastputc(EditLine *el, Int c)
if (el->el_cursor.v + 1 >= el->el_terminal.t_size.v) {
int i, lins = el->el_terminal.t_size.v;
Char *firstline = el->el_display[0];
-
+
for(i = 1; i < lins; i++)
el->el_display[i - 1] = el->el_display[i];
diff --git a/lib/libedit/refresh.h b/lib/libedit/refresh.h
index 71a1587..b9c4b30 100644
--- a/lib/libedit/refresh.h
+++ b/lib/libedit/refresh.h
@@ -1,4 +1,4 @@
-/* $NetBSD: refresh.h,v 1.6 2009/12/30 22:37:40 christos Exp $ */
+/* $NetBSD: refresh.h,v 1.9 2016/02/16 15:53:48 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -41,15 +41,13 @@
#ifndef _h_el_refresh
#define _h_el_refresh
-#include "histedit.h"
-
typedef struct {
coord_t r_cursor; /* Refresh cursor position */
int r_oldcv; /* Vertical locations */
int r_newcv;
} el_refresh_t;
-protected void re_putc(EditLine *, Int, int);
+protected void re_putc(EditLine *, wint_t, int);
protected void re_clear_lines(EditLine *);
protected void re_clear_display(EditLine *);
protected void re_refresh(EditLine *);
diff --git a/lib/libedit/search.c b/lib/libedit/search.c
index df9999c..53ad6ef 100644
--- a/lib/libedit/search.c
+++ b/lib/libedit/search.c
@@ -1,4 +1,4 @@
-/* $NetBSD: search.c,v 1.31 2016/01/30 04:02:51 christos Exp $ */
+/* $NetBSD: search.c,v 1.39 2016/02/24 14:25:38 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)search.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: search.c,v 1.31 2016/01/30 04:02:51 christos Exp $");
+__RCSID("$NetBSD: search.c,v 1.39 2016/02/24 14:25:38 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
#include <sys/cdefs.h>
@@ -47,12 +47,15 @@ __FBSDID("$FreeBSD$");
* search.c: History and character search functions
*/
#include <stdlib.h>
+#include <string.h>
#if defined(REGEX)
#include <regex.h>
#elif defined(REGEXP)
#include <regexp.h>
#endif
+
#include "el.h"
+#include "common.h"
/*
* Adjust cursor in vi mode to include the character under it
@@ -211,8 +214,9 @@ ce_inc_search(EditLine *el, int dir)
STRbck[] = {'b', 'c', 'k', '\0'};
static Char pchar = ':';/* ':' = normal, '?' = failed */
static Char endcmd[2] = {'\0', '\0'};
- Char ch, *ocursor = el->el_line.cursor, oldpchar = pchar;
+ Char *ocursor = el->el_line.cursor, oldpchar = pchar, ch;
const Char *cp;
+ wchar_t wch;
el_action_t ret = CC_NORM;
@@ -251,9 +255,11 @@ ce_inc_search(EditLine *el, int dir)
*el->el_line.lastchar = '\0';
re_refresh(el);
- if (FUN(el,getc)(el, &ch) != 1)
+ if (el_wgetc(el, &wch) != 1)
return ed_end_of_file(el, 0);
+ ch = (Char)wch;
+
switch (el->el_map.current[(unsigned char) ch]) {
case ED_INSERT:
case ED_DIGIT:
@@ -347,14 +353,14 @@ ce_inc_search(EditLine *el, int dir)
/* Can't search if unmatched '[' */
for (cp = &el->el_search.patbuf[el->el_search.patlen-1],
- ch = ']';
+ ch = L']';
cp >= &el->el_search.patbuf[LEN];
cp--)
if (*cp == '[' || *cp == ']') {
ch = *cp;
break;
}
- if (el->el_search.patlen > LEN && ch != '[') {
+ if (el->el_search.patlen > LEN && ch != L'[') {
if (redo && newdir == dir) {
if (pchar == '?') { /* wrap around */
el->el_history.eventno =
@@ -569,7 +575,7 @@ ce_search_line(EditLine *el, int dir)
* Vi repeat search
*/
protected el_action_t
-cv_repeat_srch(EditLine *el, Int c)
+cv_repeat_srch(EditLine *el, wint_t c)
{
#ifdef SDEBUG
@@ -595,35 +601,33 @@ cv_repeat_srch(EditLine *el, Int c)
* Vi character search
*/
protected el_action_t
-cv_csearch(EditLine *el, int direction, Int ch, int count, int tflag)
+cv_csearch(EditLine *el, int direction, wint_t ch, int count, int tflag)
{
Char *cp;
if (ch == 0)
return CC_ERROR;
- if (ch == (Int)-1) {
- Char c;
- if (FUN(el,getc)(el, &c) != 1)
+ if (ch == (wint_t)-1) {
+ if (el_wgetc(el, &ch) != 1)
return ed_end_of_file(el, 0);
- ch = c;
}
/* Save for ';' and ',' commands */
- el->el_search.chacha = ch;
+ el->el_search.chacha = (Char)ch;
el->el_search.chadir = direction;
el->el_search.chatflg = (char)tflag;
cp = el->el_line.cursor;
while (count--) {
- if ((Int)*cp == ch)
+ if ((wint_t)*cp == ch)
cp += direction;
for (;;cp += direction) {
if (cp >= el->el_line.lastchar)
return CC_ERROR;
if (cp < el->el_line.buffer)
return CC_ERROR;
- if ((Int)*cp == ch)
+ if ((wint_t)*cp == ch)
break;
}
}
diff --git a/lib/libedit/search.h b/lib/libedit/search.h
index 02c8f5d..1e745bd 100644
--- a/lib/libedit/search.h
+++ b/lib/libedit/search.h
@@ -1,4 +1,4 @@
-/* $NetBSD: search.h,v 1.9 2009/12/30 22:37:40 christos Exp $ */
+/* $NetBSD: search.h,v 1.12 2016/02/16 15:53:48 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -41,8 +41,6 @@
#ifndef _h_el_search
#define _h_el_search
-#include "histedit.h"
-
typedef struct el_search_t {
Char *patbuf; /* The pattern buffer */
size_t patlen; /* Length of the pattern buffer */
@@ -61,7 +59,7 @@ protected void c_setpat(EditLine *);
protected el_action_t ce_inc_search(EditLine *, int);
protected el_action_t cv_search(EditLine *, int);
protected el_action_t ce_search_line(EditLine *, int);
-protected el_action_t cv_repeat_srch(EditLine *, Int);
-protected el_action_t cv_csearch(EditLine *, int, Int, int, int);
+protected el_action_t cv_repeat_srch(EditLine *, wint_t);
+protected el_action_t cv_csearch(EditLine *, int, wint_t, int, int);
#endif /* _h_el_search */
diff --git a/lib/libedit/sig.c b/lib/libedit/sig.c
index babec69..f37a12e 100644
--- a/lib/libedit/sig.c
+++ b/lib/libedit/sig.c
@@ -1,4 +1,4 @@
-/* $NetBSD: sig.c,v 1.17 2011/07/28 20:50:55 christos Exp $ */
+/* $NetBSD: sig.c,v 1.24 2016/02/16 19:08:41 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)sig.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: sig.c,v 1.17 2011/07/28 20:50:55 christos Exp $");
+__RCSID("$NetBSD: sig.c,v 1.24 2016/02/16 19:08:41 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
#include <sys/cdefs.h>
@@ -48,9 +48,12 @@ __FBSDID("$FreeBSD$");
* our policy is to trap all signals, set a good state
* and pass the ball to our caller.
*/
-#include "el.h"
+#include <errno.h>
#include <stdlib.h>
+#include "el.h"
+#include "common.h"
+
private EditLine *sel = NULL;
private const int sighdl[] = {
@@ -70,9 +73,10 @@ private void sig_handler(int);
private void
sig_handler(int signo)
{
- int i;
+ int i, save_errno;
sigset_t nset, oset;
+ save_errno = errno;
(void) sigemptyset(&nset);
(void) sigaddset(&nset, signo);
(void) sigprocmask(SIG_BLOCK, &nset, &oset);
@@ -106,6 +110,7 @@ sig_handler(int signo)
sigemptyset(&sel->el_signal->sig_action[i].sa_mask);
(void) sigprocmask(SIG_SETMASK, &oset, NULL);
(void) kill(0, signo);
+ errno = save_errno;
}
diff --git a/lib/libedit/sig.h b/lib/libedit/sig.h
index a096681..34ec1da 100644
--- a/lib/libedit/sig.h
+++ b/lib/libedit/sig.h
@@ -1,4 +1,4 @@
-/* $NetBSD: sig.h,v 1.8 2009/02/19 15:20:22 christos Exp $ */
+/* $NetBSD: sig.h,v 1.10 2016/02/16 15:53:48 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -43,8 +43,6 @@
#include <signal.h>
-#include "histedit.h"
-
/*
* Define here all the signals we are going to handle
* The _DO macro is used to iterate in the source code
diff --git a/lib/libedit/sys.h b/lib/libedit/sys.h
index d005ffd..3807c95 100644
--- a/lib/libedit/sys.h
+++ b/lib/libedit/sys.h
@@ -1,4 +1,4 @@
-/* $NetBSD: sys.h,v 1.17 2011/09/28 14:08:04 christos Exp $ */
+/* $NetBSD: sys.h,v 1.23 2016/02/17 19:47:49 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -58,7 +58,7 @@
# define __END_DECLS
# endif
#endif
-
+
#ifndef public
# define public /* Externally visible functions/variables */
#endif
@@ -88,14 +88,9 @@ size_t strlcat(char *dst, const char *src, size_t size);
size_t strlcpy(char *dst, const char *src, size_t size);
#endif
-#ifndef HAVE_FGETLN
-#define fgetln libedit_fgetln
-char *fgetln(FILE *fp, size_t *len);
-#endif
-
-#ifndef HAVE_WCSDUP
-#include <wchar.h>
-wchar_t *wcsdup(const wchar_t *);
+#ifndef HAVE_GETLINE
+#define getline libedit_getline
+ssize_t getline(char **line, size_t *len, FILE *fp);
#endif
#ifndef _DIAGASSERT
@@ -110,13 +105,18 @@ wchar_t *wcsdup(const wchar_t *);
typedef unsigned int u_int32_t;
#endif
-#ifndef SIZE_T_MAX
-#define SIZE_T_MAX ((size_t)-1)
+#ifndef HAVE_SIZE_MAX
+#define SIZE_MAX ((size_t)-1)
#endif
#define REGEX /* Use POSIX.2 regular expression functions */
#undef REGEXP /* Use UNIX V8 regular expression functions */
+#ifndef WIDECHAR
+#define setlocale(c, l) /*LINTED*/NULL
+#define nl_langinfo(i) ""
+#endif
+
#if defined(__sun)
extern int tgetent(char *, const char *);
extern int tgetflag(char *);
diff --git a/lib/libedit/terminal.c b/lib/libedit/terminal.c
index 0709d53..971b0f6 100644
--- a/lib/libedit/terminal.c
+++ b/lib/libedit/terminal.c
@@ -1,4 +1,4 @@
-/* $NetBSD: terminal.c,v 1.14 2012/05/30 18:21:14 christos Exp $ */
+/* $NetBSD: terminal.c,v 1.24 2016/03/22 01:38:17 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)term.c 8.2 (Berkeley) 4/30/95";
#else
-__RCSID("$NetBSD: terminal.c,v 1.14 2012/05/30 18:21:14 christos Exp $");
+__RCSID("$NetBSD: terminal.c,v 1.24 2016/03/22 01:38:17 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
#include <sys/cdefs.h>
@@ -48,12 +48,14 @@ __FBSDID("$FreeBSD$");
* We have to declare a static variable here, since the
* termcap putchar routine does not take an argument!
*/
-#include <stdio.h>
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <limits.h>
#include <signal.h>
-#include <string.h>
+#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <unistd.h>
-#include <limits.h>
#ifdef HAVE_TERMCAP_H
#include <termcap.h>
#endif
@@ -67,9 +69,6 @@ __FBSDID("$FreeBSD$");
#if defined(HAVE_TERM_H) && !defined(__sun) && !defined(HAVE_TERMCAP_H)
#include <term.h>
#endif
-
-#include <sys/types.h>
-#include <sys/ioctl.h>
#ifdef _REENTRANT
#include <pthread.h>
@@ -274,31 +273,45 @@ terminal_init(EditLine *el)
el->el_terminal.t_buf = el_malloc(TC_BUFSIZE *
sizeof(*el->el_terminal.t_buf));
if (el->el_terminal.t_buf == NULL)
- return -1;
+ goto fail1;
el->el_terminal.t_cap = el_malloc(TC_BUFSIZE *
sizeof(*el->el_terminal.t_cap));
if (el->el_terminal.t_cap == NULL)
- return -1;
+ goto fail2;
el->el_terminal.t_fkey = el_malloc(A_K_NKEYS *
sizeof(*el->el_terminal.t_fkey));
if (el->el_terminal.t_fkey == NULL)
- return -1;
+ goto fail3;
el->el_terminal.t_loc = 0;
el->el_terminal.t_str = el_malloc(T_str *
sizeof(*el->el_terminal.t_str));
if (el->el_terminal.t_str == NULL)
- return -1;
+ goto fail4;
(void) memset(el->el_terminal.t_str, 0, T_str *
sizeof(*el->el_terminal.t_str));
el->el_terminal.t_val = el_malloc(T_val *
sizeof(*el->el_terminal.t_val));
if (el->el_terminal.t_val == NULL)
- return -1;
+ goto fail5;
(void) memset(el->el_terminal.t_val, 0, T_val *
sizeof(*el->el_terminal.t_val));
(void) terminal_set(el, NULL);
terminal_init_arrow(el);
return 0;
+fail5:
+ free(el->el_terminal.t_str);
+ el->el_terminal.t_str = NULL;
+fail4:
+ free(el->el_terminal.t_fkey);
+ el->el_terminal.t_fkey = NULL;
+fail3:
+ free(el->el_terminal.t_cap);
+ el->el_terminal.t_cap = NULL;
+fail2:
+ free(el->el_terminal.t_buf);
+ el->el_terminal.t_buf = NULL;
+fail1:
+ return -1;
}
/* terminal_end():
@@ -367,7 +380,7 @@ terminal_alloc(EditLine *el, const struct termcapstr *t, const char *cap)
*/
tlen = 0;
for (tmp = tlist; tmp < &tlist[T_str]; tmp++)
- if (*tmp != NULL && *tmp != '\0' && *tmp != *str) {
+ if (*tmp != NULL && **tmp != '\0' && *tmp != *str) {
char *ptr;
for (ptr = *tmp; *ptr != '\0'; termbuf[tlen++] = *ptr++)
@@ -420,14 +433,14 @@ terminal_alloc_display(EditLine *el)
b = el_malloc(sizeof(*b) * (size_t)(c->v + 1));
if (b == NULL)
- return -1;
+ goto done;
for (i = 0; i < c->v; i++) {
b[i] = el_malloc(sizeof(**b) * (size_t)(c->h + 1));
if (b[i] == NULL) {
while (--i >= 0)
el_free(b[i]);
el_free(b);
- return -1;
+ goto done;
}
}
b[c->v] = NULL;
@@ -435,19 +448,22 @@ terminal_alloc_display(EditLine *el)
b = el_malloc(sizeof(*b) * (size_t)(c->v + 1));
if (b == NULL)
- return -1;
+ goto done;
for (i = 0; i < c->v; i++) {
b[i] = el_malloc(sizeof(**b) * (size_t)(c->h + 1));
if (b[i] == NULL) {
while (--i >= 0)
el_free(b[i]);
el_free(b);
- return -1;
+ goto done;
}
}
b[c->v] = NULL;
el->el_vdisplay = b;
return 0;
+done:
+ terminal_free_display(el);
+ return -1;
}
@@ -479,7 +495,7 @@ terminal_free_display(EditLine *el)
/* terminal_move_to_line():
* move to line <where> (first line == 0)
- * as efficiently as possible
+ * as efficiently as possible
*/
protected void
terminal_move_to_line(EditLine *el, int where)
@@ -492,8 +508,7 @@ terminal_move_to_line(EditLine *el, int where)
if (where > el->el_terminal.t_size.v) {
#ifdef DEBUG_SCREEN
(void) fprintf(el->el_errfile,
- "terminal_move_to_line: where is ridiculous: %d\r\n",
- where);
+ "%s: where is ridiculous: %d\r\n", __func__, where);
#endif /* DEBUG_SCREEN */
return;
}
@@ -559,8 +574,7 @@ mc_again:
if (where > el->el_terminal.t_size.h) {
#ifdef DEBUG_SCREEN
(void) fprintf(el->el_errfile,
- "terminal_move_to_char: where is riduculous: %d\r\n",
- where);
+ "%s: where is ridiculous: %d\r\n", __func__, where);
#endif /* DEBUG_SCREEN */
return;
}
@@ -596,7 +610,7 @@ mc_again:
i < (where & ~0x7);
i += 8)
terminal__putc(el,
- '\t');
+ '\t');
/* then tab over */
el->el_cursor.h = where & ~0x7;
}
@@ -654,7 +668,7 @@ terminal_overwrite(EditLine *el, const Char *cp, size_t n)
if (n > (size_t)el->el_terminal.t_size.h) {
#ifdef DEBUG_SCREEN
(void) fprintf(el->el_errfile,
- "terminal_overwrite: n is riduculous: %d\r\n", n);
+ "%s: n is ridiculous: %zu\r\n", __func__, n);
#endif /* DEBUG_SCREEN */
return;
}
@@ -710,7 +724,7 @@ terminal_deletechars(EditLine *el, int num)
if (num > el->el_terminal.t_size.h) {
#ifdef DEBUG_SCREEN
(void) fprintf(el->el_errfile,
- "terminal_deletechars: num is riduculous: %d\r\n", num);
+ "%s: num is ridiculous: %d\r\n", __func__, num);
#endif /* DEBUG_SCREEN */
return;
}
@@ -751,7 +765,7 @@ terminal_insertwrite(EditLine *el, Char *cp, int num)
if (num > el->el_terminal.t_size.h) {
#ifdef DEBUG_SCREEN
(void) fprintf(el->el_errfile,
- "StartInsert: num is riduculous: %d\r\n", num);
+ "%s: num is ridiculous: %d\r\n", __func__, num);
#endif /* DEBUG_SCREEN */
return;
}
@@ -1241,13 +1255,13 @@ terminal_tputs(EditLine *el, const char *cap, int affcnt)
* Add a character
*/
protected int
-terminal__putc(EditLine *el, Int c)
+terminal__putc(EditLine *el, wint_t c)
{
char buf[MB_LEN_MAX +1];
ssize_t i;
- if (c == (Int)MB_FILL_CHAR)
+ if (c == (wint_t)MB_FILL_CHAR)
return 0;
- i = ct_encode_char(buf, (size_t)MB_LEN_MAX, c);
+ i = ct_encode_char(buf, (size_t)MB_LEN_MAX, (Char)c);
if (i <= 0)
return (int)i;
buf[i] = '\0';
@@ -1268,10 +1282,10 @@ terminal__flush(EditLine *el)
* Write the given character out, in a human readable form
*/
protected void
-terminal_writec(EditLine *el, Int c)
+terminal_writec(EditLine *el, wint_t c)
{
Char visbuf[VISUAL_WIDTH_MAX +1];
- ssize_t vcnt = ct_visual_char(visbuf, VISUAL_WIDTH_MAX, c);
+ ssize_t vcnt = ct_visual_char(visbuf, VISUAL_WIDTH_MAX, (Char)c);
if (vcnt < 0)
vcnt = 0;
visbuf[vcnt] = '\0';
@@ -1285,7 +1299,7 @@ terminal_writec(EditLine *el, Int c)
*/
protected int
/*ARGSUSED*/
-terminal_telltc(EditLine *el, int argc __attribute__((__unused__)),
+terminal_telltc(EditLine *el, int argc __attribute__((__unused__)),
const Char **argv __attribute__((__unused__)))
{
const struct termcapstr *t;
diff --git a/lib/libedit/terminal.h b/lib/libedit/terminal.h
index f26f5e1..9c66c19 100644
--- a/lib/libedit/terminal.h
+++ b/lib/libedit/terminal.h
@@ -1,4 +1,4 @@
-/* $NetBSD: terminal.h,v 1.4 2012/03/24 20:09:30 christos Exp $ */
+/* $NetBSD: terminal.h,v 1.7 2016/02/16 15:53:48 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -41,8 +41,6 @@
#ifndef _h_el_terminal
#define _h_el_terminal
-#include "histedit.h"
-
typedef struct { /* Symbolic function key bindings */
const Char *name; /* name of the key */
int key; /* Index in termcap table */
@@ -105,8 +103,8 @@ protected int terminal_settc(EditLine *, int, const Char **);
protected int terminal_gettc(EditLine *, int, char **);
protected int terminal_telltc(EditLine *, int, const Char **);
protected int terminal_echotc(EditLine *, int, const Char **);
-protected void terminal_writec(EditLine *, Int);
-protected int terminal__putc(EditLine *, Int);
+protected void terminal_writec(EditLine *, wint_t);
+protected int terminal__putc(EditLine *, wint_t);
protected void terminal__flush(EditLine *);
/*
diff --git a/lib/libedit/tokenizer.c b/lib/libedit/tokenizer.c
index f5171c4..23f940f 100644
--- a/lib/libedit/tokenizer.c
+++ b/lib/libedit/tokenizer.c
@@ -1,4 +1,4 @@
-/* $NetBSD: tokenizer.c,v 1.22 2016/01/30 04:02:51 christos Exp $ */
+/* $NetBSD: tokenizer.c,v 1.24 2016/02/17 19:47:49 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)tokenizer.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: tokenizer.c,v 1.22 2016/01/30 04:02:51 christos Exp $");
+__RCSID("$NetBSD: tokenizer.c,v 1.24 2016/02/17 19:47:49 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
#include <sys/cdefs.h>
@@ -47,8 +47,9 @@ __FBSDID("$FreeBSD$");
/*
* tokenize.c: Bourne shell like tokenizer
*/
-#include <string.h>
#include <stdlib.h>
+#include <string.h>
+
#include "histedit.h"
#include "chartype.h"
@@ -415,8 +416,10 @@ FUN(tok,line)(TYPE(Tokenizer) *tok, const TYPE(LineInfo) *line,
Char **p;
tok->amax += AINCR;
p = tok_realloc(tok->argv, tok->amax * sizeof(*p));
- if (p == NULL)
+ if (p == NULL) {
+ tok->amax -= AINCR;
return -1;
+ }
tok->argv = p;
}
}
diff --git a/lib/libedit/tty.c b/lib/libedit/tty.c
index a508e43..971bfc6 100644
--- a/lib/libedit/tty.c
+++ b/lib/libedit/tty.c
@@ -1,4 +1,4 @@
-/* $NetBSD: tty.c,v 1.49 2015/12/08 16:53:27 gson Exp $ */
+/* $NetBSD: tty.c,v 1.59 2016/03/22 01:34:32 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)tty.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: tty.c,v 1.49 2015/12/08 16:53:27 gson Exp $");
+__RCSID("$NetBSD: tty.c,v 1.59 2016/03/22 01:34:32 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
#include <sys/cdefs.h>
@@ -48,11 +48,13 @@ __FBSDID("$FreeBSD$");
*/
#include <assert.h>
#include <errno.h>
-#include <unistd.h> /* for isatty */
-#include <strings.h> /* for ffs */
#include <stdlib.h> /* for abort */
+#include <string.h>
+#include <strings.h> /* for ffs */
+#include <unistd.h> /* for isatty */
+
#include "el.h"
-#include "tty.h"
+#include "parse.h"
typedef struct ttymodes_t {
const char *m_name;
@@ -61,7 +63,7 @@ typedef struct ttymodes_t {
} ttymodes_t;
typedef struct ttymap_t {
- Int nch, och; /* Internal and termio rep of chars */
+ wint_t nch, och; /* Internal and termio rep of chars */
el_action_t bind[3]; /* emacs, vi, and vi-cmd */
} ttymap_t;
@@ -157,7 +159,7 @@ private const ttymap_t tty_map[] = {
{C_LNEXT, VLNEXT,
{ED_QUOTED_INSERT, ED_QUOTED_INSERT, ED_UNASSIGNED}},
#endif /* VLNEXT */
- {(Int)-1, (Int)-1,
+ {(wint_t)-1, (wint_t)-1,
{ED_UNASSIGNED, ED_UNASSIGNED, ED_UNASSIGNED}}
};
@@ -501,6 +503,9 @@ tty_setup(EditLine *el)
if (el->el_flags & EDIT_DISABLED)
return 0;
+ if (el->el_tty.t_initialized)
+ return -1;
+
if (!isatty(el->el_outfd)) {
#ifdef DEBUG_TTY
(void) fprintf(el->el_errfile, "%s: isatty: %s\n", __func__,
@@ -560,6 +565,7 @@ tty_setup(EditLine *el)
tty__setchar(&el->el_tty.t_ed, el->el_tty.t_c[ED_IO]);
tty_bind_char(el, 1);
+ el->el_tty.t_initialized = 1;
return 0;
}
@@ -569,6 +575,7 @@ tty_init(EditLine *el)
el->el_tty.t_mode = EX_IO;
el->el_tty.t_vdisable = _POSIX_VDISABLE;
+ el->el_tty.t_initialized = 0;
(void) memcpy(el->el_tty.t_t, ttyperm, sizeof(ttyperm_t));
(void) memcpy(el->el_tty.t_c, ttychar, sizeof(ttychar_t));
return tty_setup(el);
@@ -585,6 +592,9 @@ tty_end(EditLine *el)
if (el->el_flags & EDIT_DISABLED)
return;
+ if (!el->el_tty.t_initialized)
+ return;
+
if (tty_setty(el, TCSAFLUSH, &el->el_tty.t_or) == -1) {
#ifdef DEBUG_TTY
(void) fprintf(el->el_errfile,
@@ -904,9 +914,9 @@ tty_bind_char(EditLine *el, int force)
dalt = NULL;
}
- for (tp = tty_map; tp->nch != (Int)-1; tp++) {
- new[0] = t_n[tp->nch];
- old[0] = t_o[tp->och];
+ for (tp = tty_map; tp->nch != (wint_t)-1; tp++) {
+ new[0] = (Char)t_n[tp->nch];
+ old[0] = (Char)t_o[tp->och];
if (new[0] == old[0] && !force)
continue;
/* Put the old default binding back, and set the new binding */
@@ -978,7 +988,7 @@ tty_update_char(EditLine *el, int mode, int c) {
/* tty_rawmode():
- * Set terminal into 1 character at a time mode.
+ * Set terminal into 1 character at a time mode.
*/
protected int
tty_rawmode(EditLine *el)
@@ -1176,8 +1186,8 @@ tty_stty(EditLine *el, int argc __attribute__((__unused__)), const Char **argv)
break;
default:
(void) fprintf(el->el_errfile,
- "%s: Unknown switch `" FCHAR "'.\n",
- name, (Int)argv[0][1]);
+ "%s: Unknown switch `%lc'.\n",
+ name, (wint_t)argv[0][1]);
return -1;
}
diff --git a/lib/libedit/tty.h b/lib/libedit/tty.h
index b1fc76e..9694393 100644
--- a/lib/libedit/tty.h
+++ b/lib/libedit/tty.h
@@ -1,4 +1,4 @@
-/* $NetBSD: tty.h,v 1.15 2014/05/19 19:54:12 christos Exp $ */
+/* $NetBSD: tty.h,v 1.19 2016/02/27 18:13:21 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -41,8 +41,6 @@
#ifndef _h_el_tty
#define _h_el_tty
-#include "sys.h"
-#include "histedit.h"
#include <termios.h>
#include <unistd.h>
@@ -475,8 +473,9 @@ typedef struct {
int t_tabs;
int t_eight;
speed_t t_speed;
- int t_mode;
+ unsigned char t_mode;
unsigned char t_vdisable;
+ unsigned char t_initialized;
} el_tty_t;
diff --git a/lib/libedit/vi.c b/lib/libedit/vi.c
index 6b0a775..02d7e29 100644
--- a/lib/libedit/vi.c
+++ b/lib/libedit/vi.c
@@ -1,4 +1,4 @@
-/* $NetBSD: vi.c,v 1.47 2015/10/21 21:45:30 christos Exp $ */
+/* $NetBSD: vi.c,v 1.55 2016/03/02 19:24:20 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -33,16 +33,11 @@
*/
#include "config.h"
-#include <stdlib.h>
-#include <unistd.h>
-#include <limits.h>
-#include <sys/wait.h>
-
#if !defined(lint) && !defined(SCCSID)
#if 0
static char sccsid[] = "@(#)vi.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: vi.c,v 1.47 2015/10/21 21:45:30 christos Exp $");
+__RCSID("$NetBSD: vi.c,v 1.55 2016/03/02 19:24:20 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
#include <sys/cdefs.h>
@@ -51,21 +46,31 @@ __FBSDID("$FreeBSD$");
/*
* vi.c: Vi mode commands.
*/
+#include <sys/wait.h>
+#include <ctype.h>
+#include <limits.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
#include "el.h"
+#include "common.h"
+#include "emacs.h"
+#include "vi.h"
-private el_action_t cv_action(EditLine *, Int);
-private el_action_t cv_paste(EditLine *, Int);
+private el_action_t cv_action(EditLine *, wint_t);
+private el_action_t cv_paste(EditLine *, wint_t);
/* cv_action():
* Handle vi actions.
*/
private el_action_t
-cv_action(EditLine *el, Int c)
+cv_action(EditLine *el, wint_t c)
{
if (el->el_chared.c_vcmd.action != NOP) {
/* 'cc', 'dd' and (possibly) friends */
- if (c != (Int)el->el_chared.c_vcmd.action)
+ if (c != (wint_t)el->el_chared.c_vcmd.action)
return CC_ERROR;
if (!(c & YANK))
@@ -92,7 +97,7 @@ cv_action(EditLine *el, Int c)
* Paste previous deletion before or after the cursor
*/
private el_action_t
-cv_paste(EditLine *el, Int c)
+cv_paste(EditLine *el, wint_t c)
{
c_kill_t *k = &el->el_chared.c_kill;
size_t len = (size_t)(k->last - k->buf);
@@ -100,7 +105,8 @@ cv_paste(EditLine *el, Int c)
if (k->buf == NULL || len == 0)
return CC_ERROR;
#ifdef DEBUG_PASTE
- (void) fprintf(el->el_errfile, "Paste: \"%.*s\"\n", (int)len, k->buf);
+ (void) fprintf(el->el_errfile, "Paste: \"" FSTARSTR "\"\n", (int)len,
+ k->buf);
#endif
cv_undo(el);
@@ -124,7 +130,7 @@ cv_paste(EditLine *el, Int c)
*/
protected el_action_t
/*ARGSUSED*/
-vi_paste_next(EditLine *el, Int c __attribute__((__unused__)))
+vi_paste_next(EditLine *el, wint_t c __attribute__((__unused__)))
{
return cv_paste(el, 0);
@@ -137,7 +143,7 @@ vi_paste_next(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-vi_paste_prev(EditLine *el, Int c __attribute__((__unused__)))
+vi_paste_prev(EditLine *el, wint_t c __attribute__((__unused__)))
{
return cv_paste(el, 1);
@@ -150,7 +156,7 @@ vi_paste_prev(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-vi_prev_big_word(EditLine *el, Int c __attribute__((__unused__)))
+vi_prev_big_word(EditLine *el, wint_t c __attribute__((__unused__)))
{
if (el->el_line.cursor == el->el_line.buffer)
@@ -175,7 +181,7 @@ vi_prev_big_word(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-vi_prev_word(EditLine *el, Int c __attribute__((__unused__)))
+vi_prev_word(EditLine *el, wint_t c __attribute__((__unused__)))
{
if (el->el_line.cursor == el->el_line.buffer)
@@ -200,7 +206,7 @@ vi_prev_word(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-vi_next_big_word(EditLine *el, Int c __attribute__((__unused__)))
+vi_next_big_word(EditLine *el, wint_t c __attribute__((__unused__)))
{
if (el->el_line.cursor >= el->el_line.lastchar - 1)
@@ -224,7 +230,7 @@ vi_next_big_word(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-vi_next_word(EditLine *el, Int c __attribute__((__unused__)))
+vi_next_word(EditLine *el, wint_t c __attribute__((__unused__)))
{
if (el->el_line.cursor >= el->el_line.lastchar - 1)
@@ -247,7 +253,7 @@ vi_next_word(EditLine *el, Int c __attribute__((__unused__)))
* [~]
*/
protected el_action_t
-vi_change_case(EditLine *el, Int c)
+vi_change_case(EditLine *el, wint_t c)
{
int i;
@@ -279,7 +285,7 @@ vi_change_case(EditLine *el, Int c)
*/
protected el_action_t
/*ARGSUSED*/
-vi_change_meta(EditLine *el, Int c __attribute__((__unused__)))
+vi_change_meta(EditLine *el, wint_t c __attribute__((__unused__)))
{
/*
@@ -296,7 +302,7 @@ vi_change_meta(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-vi_insert_at_bol(EditLine *el, Int c __attribute__((__unused__)))
+vi_insert_at_bol(EditLine *el, wint_t c __attribute__((__unused__)))
{
el->el_line.cursor = el->el_line.buffer;
@@ -312,7 +318,7 @@ vi_insert_at_bol(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-vi_replace_char(EditLine *el, Int c __attribute__((__unused__)))
+vi_replace_char(EditLine *el, wint_t c __attribute__((__unused__)))
{
if (el->el_line.cursor >= el->el_line.lastchar)
@@ -331,7 +337,7 @@ vi_replace_char(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-vi_replace_mode(EditLine *el, Int c __attribute__((__unused__)))
+vi_replace_mode(EditLine *el, wint_t c __attribute__((__unused__)))
{
el->el_map.current = el->el_map.key;
@@ -347,7 +353,7 @@ vi_replace_mode(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-vi_substitute_char(EditLine *el, Int c __attribute__((__unused__)))
+vi_substitute_char(EditLine *el, wint_t c __attribute__((__unused__)))
{
c_delafter(el, el->el_state.argument);
@@ -362,7 +368,7 @@ vi_substitute_char(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-vi_substitute_line(EditLine *el, Int c __attribute__((__unused__)))
+vi_substitute_line(EditLine *el, wint_t c __attribute__((__unused__)))
{
cv_undo(el);
@@ -380,7 +386,7 @@ vi_substitute_line(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-vi_change_to_eol(EditLine *el, Int c __attribute__((__unused__)))
+vi_change_to_eol(EditLine *el, wint_t c __attribute__((__unused__)))
{
cv_undo(el);
@@ -398,7 +404,7 @@ vi_change_to_eol(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-vi_insert(EditLine *el, Int c __attribute__((__unused__)))
+vi_insert(EditLine *el, wint_t c __attribute__((__unused__)))
{
el->el_map.current = el->el_map.key;
@@ -413,7 +419,7 @@ vi_insert(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-vi_add(EditLine *el, Int c __attribute__((__unused__)))
+vi_add(EditLine *el, wint_t c __attribute__((__unused__)))
{
int ret;
@@ -438,7 +444,7 @@ vi_add(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-vi_add_at_eol(EditLine *el, Int c __attribute__((__unused__)))
+vi_add_at_eol(EditLine *el, wint_t c __attribute__((__unused__)))
{
el->el_map.current = el->el_map.key;
@@ -454,7 +460,7 @@ vi_add_at_eol(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-vi_delete_meta(EditLine *el, Int c __attribute__((__unused__)))
+vi_delete_meta(EditLine *el, wint_t c __attribute__((__unused__)))
{
return cv_action(el, DELETE);
@@ -467,7 +473,7 @@ vi_delete_meta(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-vi_end_big_word(EditLine *el, Int c __attribute__((__unused__)))
+vi_end_big_word(EditLine *el, wint_t c __attribute__((__unused__)))
{
if (el->el_line.cursor == el->el_line.lastchar)
@@ -491,7 +497,7 @@ vi_end_big_word(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-vi_end_word(EditLine *el, Int c __attribute__((__unused__)))
+vi_end_word(EditLine *el, wint_t c __attribute__((__unused__)))
{
if (el->el_line.cursor == el->el_line.lastchar)
@@ -515,7 +521,7 @@ vi_end_word(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-vi_undo(EditLine *el, Int c __attribute__((__unused__)))
+vi_undo(EditLine *el, wint_t c __attribute__((__unused__)))
{
c_undo_t un = el->el_chared.c_undo;
@@ -542,7 +548,7 @@ vi_undo(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-vi_command_mode(EditLine *el, Int c __attribute__((__unused__)))
+vi_command_mode(EditLine *el, wint_t c __attribute__((__unused__)))
{
/* [Esc] cancels pending action */
@@ -566,7 +572,7 @@ vi_command_mode(EditLine *el, Int c __attribute__((__unused__)))
* [0]
*/
protected el_action_t
-vi_zero(EditLine *el, Int c)
+vi_zero(EditLine *el, wint_t c)
{
if (el->el_state.doingarg)
@@ -582,12 +588,12 @@ vi_zero(EditLine *el, Int c)
/* vi_delete_prev_char():
- * Vi move to previous character (backspace)
+ * Vi move to previous character (backspace)
* [^H] in insert mode only
*/
protected el_action_t
/*ARGSUSED*/
-vi_delete_prev_char(EditLine *el, Int c __attribute__((__unused__)))
+vi_delete_prev_char(EditLine *el, wint_t c __attribute__((__unused__)))
{
if (el->el_line.cursor <= el->el_line.buffer)
@@ -605,7 +611,7 @@ vi_delete_prev_char(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-vi_list_or_eof(EditLine *el, Int c)
+vi_list_or_eof(EditLine *el, wint_t c)
{
if (el->el_line.cursor == el->el_line.lastchar) {
@@ -642,7 +648,7 @@ vi_list_or_eof(EditLine *el, Int c)
*/
protected el_action_t
/*ARGSUSED*/
-vi_kill_line_prev(EditLine *el, Int c __attribute__((__unused__)))
+vi_kill_line_prev(EditLine *el, wint_t c __attribute__((__unused__)))
{
Char *kp, *cp;
@@ -663,7 +669,7 @@ vi_kill_line_prev(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-vi_search_prev(EditLine *el, Int c __attribute__((__unused__)))
+vi_search_prev(EditLine *el, wint_t c __attribute__((__unused__)))
{
return cv_search(el, ED_SEARCH_PREV_HISTORY);
@@ -676,7 +682,7 @@ vi_search_prev(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-vi_search_next(EditLine *el, Int c __attribute__((__unused__)))
+vi_search_next(EditLine *el, wint_t c __attribute__((__unused__)))
{
return cv_search(el, ED_SEARCH_NEXT_HISTORY);
@@ -689,7 +695,7 @@ vi_search_next(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-vi_repeat_search_next(EditLine *el, Int c __attribute__((__unused__)))
+vi_repeat_search_next(EditLine *el, wint_t c __attribute__((__unused__)))
{
if (el->el_search.patlen == 0)
@@ -705,7 +711,7 @@ vi_repeat_search_next(EditLine *el, Int c __attribute__((__unused__)))
*/
/*ARGSUSED*/
protected el_action_t
-vi_repeat_search_prev(EditLine *el, Int c __attribute__((__unused__)))
+vi_repeat_search_prev(EditLine *el, wint_t c __attribute__((__unused__)))
{
if (el->el_search.patlen == 0)
@@ -723,7 +729,7 @@ vi_repeat_search_prev(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-vi_next_char(EditLine *el, Int c __attribute__((__unused__)))
+vi_next_char(EditLine *el, wint_t c __attribute__((__unused__)))
{
return cv_csearch(el, CHAR_FWD, -1, el->el_state.argument, 0);
}
@@ -735,7 +741,7 @@ vi_next_char(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-vi_prev_char(EditLine *el, Int c __attribute__((__unused__)))
+vi_prev_char(EditLine *el, wint_t c __attribute__((__unused__)))
{
return cv_csearch(el, CHAR_BACK, -1, el->el_state.argument, 0);
}
@@ -747,7 +753,7 @@ vi_prev_char(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-vi_to_next_char(EditLine *el, Int c __attribute__((__unused__)))
+vi_to_next_char(EditLine *el, wint_t c __attribute__((__unused__)))
{
return cv_csearch(el, CHAR_FWD, -1, el->el_state.argument, 1);
}
@@ -759,7 +765,7 @@ vi_to_next_char(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-vi_to_prev_char(EditLine *el, Int c __attribute__((__unused__)))
+vi_to_prev_char(EditLine *el, wint_t c __attribute__((__unused__)))
{
return cv_csearch(el, CHAR_BACK, -1, el->el_state.argument, 1);
}
@@ -771,7 +777,7 @@ vi_to_prev_char(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-vi_repeat_next_char(EditLine *el, Int c __attribute__((__unused__)))
+vi_repeat_next_char(EditLine *el, wint_t c __attribute__((__unused__)))
{
return cv_csearch(el, el->el_search.chadir, el->el_search.chacha,
@@ -785,7 +791,7 @@ vi_repeat_next_char(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-vi_repeat_prev_char(EditLine *el, Int c __attribute__((__unused__)))
+vi_repeat_prev_char(EditLine *el, wint_t c __attribute__((__unused__)))
{
el_action_t r;
int dir = el->el_search.chadir;
@@ -803,7 +809,7 @@ vi_repeat_prev_char(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-vi_match(EditLine *el, Int c __attribute__((__unused__)))
+vi_match(EditLine *el, wint_t c __attribute__((__unused__)))
{
const Char match_chars[] = STR("()[]{}");
Char *cp;
@@ -850,7 +856,7 @@ vi_match(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-vi_undo_line(EditLine *el, Int c __attribute__((__unused__)))
+vi_undo_line(EditLine *el, wint_t c __attribute__((__unused__)))
{
cv_undo(el);
@@ -864,7 +870,7 @@ vi_undo_line(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-vi_to_column(EditLine *el, Int c __attribute__((__unused__)))
+vi_to_column(EditLine *el, wint_t c __attribute__((__unused__)))
{
el->el_line.cursor = el->el_line.buffer;
@@ -878,7 +884,7 @@ vi_to_column(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-vi_yank_end(EditLine *el, Int c __attribute__((__unused__)))
+vi_yank_end(EditLine *el, wint_t c __attribute__((__unused__)))
{
cv_yank(el, el->el_line.cursor,
@@ -892,7 +898,7 @@ vi_yank_end(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-vi_yank(EditLine *el, Int c __attribute__((__unused__)))
+vi_yank(EditLine *el, wint_t c __attribute__((__unused__)))
{
return cv_action(el, YANK);
@@ -904,7 +910,7 @@ vi_yank(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-vi_comment_out(EditLine *el, Int c __attribute__((__unused__)))
+vi_comment_out(EditLine *el, wint_t c __attribute__((__unused__)))
{
el->el_line.cursor = el->el_line.buffer;
@@ -922,7 +928,7 @@ vi_comment_out(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-vi_alias(EditLine *el, Int c __attribute__((__unused__)))
+vi_alias(EditLine *el, wint_t c __attribute__((__unused__)))
{
char alias_name[3];
const char *alias_text;
@@ -948,7 +954,7 @@ vi_alias(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-vi_to_history_line(EditLine *el, Int c __attribute__((__unused__)))
+vi_to_history_line(EditLine *el, wint_t c __attribute__((__unused__)))
{
int sv_event_no = el->el_history.eventno;
el_action_t rval;
@@ -974,7 +980,7 @@ vi_to_history_line(EditLine *el, Int c __attribute__((__unused__)))
el->el_history.eventno = 1;
if (hist_get(el) == CC_ERROR)
return CC_ERROR;
- el->el_history.eventno = 1 + el->el_history.ev.num
+ el->el_history.eventno = 1 + el->el_history.ev.num
- el->el_state.argument;
if (el->el_history.eventno < 0) {
el->el_history.eventno = sv_event_no;
@@ -993,7 +999,7 @@ vi_to_history_line(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-vi_histedit(EditLine *el, Int c __attribute__((__unused__)))
+vi_histedit(EditLine *el, wint_t c __attribute__((__unused__)))
{
int fd;
pid_t pid;
@@ -1077,7 +1083,7 @@ error:
*/
protected el_action_t
/*ARGSUSED*/
-vi_history_word(EditLine *el, Int c __attribute__((__unused__)))
+vi_history_word(EditLine *el, wint_t c __attribute__((__unused__)))
{
const Char *wp = HIST_FIRST(el);
const Char *wep, *wsp;
@@ -1127,7 +1133,7 @@ vi_history_word(EditLine *el, Int c __attribute__((__unused__)))
*/
protected el_action_t
/*ARGSUSED*/
-vi_redo(EditLine *el, Int c __attribute__((__unused__)))
+vi_redo(EditLine *el, wint_t c __attribute__((__unused__)))
{
c_redo_t *r = &el->el_chared.c_redo;
diff --git a/lib/libelf/Makefile b/lib/libelf/Makefile
index 55ce30b..5c1cb8c 100644
--- a/lib/libelf/Makefile
+++ b/lib/libelf/Makefile
@@ -82,7 +82,7 @@ CLEANFILES= ${GENSRCS}
CLEANDIRS= sys
CFLAGS+= -I. -I${SRCDIR} -I${ELFTCDIR}/common
-sys/elf32.h sys/elf64.h sys/elf_common.h: ${.CURDIR}/../../sys/${.TARGET} .NOMETA
+sys/elf32.h sys/elf64.h sys/elf_common.h: ${SRCTOP}/sys/${.TARGET} .NOMETA
mkdir -p ${.OBJDIR}/sys
ln -sf ${.ALLSRC} ${.TARGET}
diff --git a/lib/libevent/Makefile b/lib/libevent/Makefile
index d8cc572..4d692f3 100644
--- a/lib/libevent/Makefile
+++ b/lib/libevent/Makefile
@@ -1,7 +1,7 @@
# $FreeBSD$
PACKAGE=lib${LIB}
-.PATH: ${.CURDIR}/../../contrib/pf/libevent
+.PATH: ${SRCTOP}/contrib/pf/libevent
.include <src.opts.mk>
diff --git a/lib/libexecinfo/Makefile b/lib/libexecinfo/Makefile
index c444f7f..9086d18 100644
--- a/lib/libexecinfo/Makefile
+++ b/lib/libexecinfo/Makefile
@@ -1,7 +1,7 @@
# $FreeBSD$
PACKAGE=lib${LIB}
-LIBEXECINFO= ${.CURDIR}/../../contrib/libexecinfo
+LIBEXECINFO= ${SRCTOP}/contrib/libexecinfo
LIB= execinfo
SHLIB_MAJOR= 1
diff --git a/lib/libexpat/Makefile b/lib/libexpat/Makefile
index d0de3e0..20665c6 100644
--- a/lib/libexpat/Makefile
+++ b/lib/libexpat/Makefile
@@ -1,7 +1,7 @@
# $FreeBSD$
PACKAGE=lib${LIB}
-EXPAT= ${.CURDIR}/../../contrib/expat
+EXPAT= ${SRCTOP}/contrib/expat
LIB= bsdxml
SHLIBDIR?= /lib
diff --git a/lib/libgssapi/Makefile b/lib/libgssapi/Makefile
index a486101..052bf73 100644
--- a/lib/libgssapi/Makefile
+++ b/lib/libgssapi/Makefile
@@ -3,7 +3,7 @@
PACKAGE=lib${LIB}
LIB= gssapi
SHLIB_MAJOR= 10
-VERSION_DEF= ${.CURDIR}/../libc/Versions.def
+VERSION_DEF= ${SRCTOP}/lib/libc/Versions.def
SYMBOL_MAPS= ${.CURDIR}/Symbol.map
SRCS=
diff --git a/lib/libiconv_modules/Makefile.inc b/lib/libiconv_modules/Makefile.inc
index 51ae718..d424736 100644
--- a/lib/libiconv_modules/Makefile.inc
+++ b/lib/libiconv_modules/Makefile.inc
@@ -1,10 +1,10 @@
# $FreeBSD$
-.PATH: ${.CURDIR}/../../libc/iconv
+.PATH: ${SRCTOP}/lib/libc/iconv
SHLIB_MAJOR= 4
WARNS?= 6
-CFLAGS+= -I${.CURDIR}/../../libc/iconv
+CFLAGS+= -I${SRCTOP}/lib/libc/iconv
CFLAGS+= -Dbool=_Bool
diff --git a/lib/libiconv_modules/mapper_parallel/Makefile b/lib/libiconv_modules/mapper_parallel/Makefile
index b79c3ad..0008665 100644
--- a/lib/libiconv_modules/mapper_parallel/Makefile
+++ b/lib/libiconv_modules/mapper_parallel/Makefile
@@ -1,6 +1,6 @@
# $FreeBSD$
-.PATH: ${.CURDIR}/../mapper_serial
+.PATH: ${.CURDIR:H}/mapper_serial
SHLIB= mapper_parallel
SRCS+= citrus_mapper_serial.c
diff --git a/lib/libkiconv/Makefile b/lib/libkiconv/Makefile
index 5ada7db..44ec6c0 100644
--- a/lib/libkiconv/Makefile
+++ b/lib/libkiconv/Makefile
@@ -17,7 +17,7 @@ MLINKS+= kiconv.3 kiconv_add_xlat16_cspair.3 \
kiconv.3 kiconv_add_xlat16_cspairs.3 \
kiconv.3 kiconv_add_xlat16_table.3
-CFLAGS+= -I${.CURDIR}/../../sys
+CFLAGS+= -I${SRCTOP}/sys
WARNS?= 1
diff --git a/lib/libldns/Makefile b/lib/libldns/Makefile
index 14dc9f9..042b4e0 100644
--- a/lib/libldns/Makefile
+++ b/lib/libldns/Makefile
@@ -1,7 +1,7 @@
# $FreeBSD$
# Vendor sources and generated files
-LDNSDIR = ${.CURDIR}/../../contrib/ldns
+LDNSDIR = ${SRCTOP}/contrib/ldns
PACKAGE=lib${LIB}
.PATH: ${LDNSDIR} ${LDNSDIR}/compat
diff --git a/lib/liblzma/Makefile b/lib/liblzma/Makefile
index 62c2994..9dd7735 100644
--- a/lib/liblzma/Makefile
+++ b/lib/liblzma/Makefile
@@ -2,9 +2,9 @@
PACKAGE=lib${LIB}
LIB= lzma
-LZMADIR= ${.CURDIR}/../../contrib/xz/src/liblzma
+LZMADIR= ${SRCTOP}/contrib/xz/src/liblzma
-.PATH: ${LZMADIR}/../common
+.PATH: ${LZMADIR:H}/common
SRCS+= tuklib_physmem.c tuklib_cpucores.c
.PATH: ${LZMADIR}/api/lzma
@@ -145,7 +145,7 @@ CFLAGS+= -DHAVE_CONFIG_H \
-I${LZMADIR}/lzma \
-I${LZMADIR}/delta \
-I${LZMADIR}/simple \
- -I${LZMADIR}/../common
+ -I${LZMADIR:H}/common
LIBADD+= pthread
diff --git a/lib/libmagic/Makefile b/lib/libmagic/Makefile
index 302338c..65fdc75 100644
--- a/lib/libmagic/Makefile
+++ b/lib/libmagic/Makefile
@@ -2,7 +2,7 @@
# Copyright (c) David E. O'Brien, 2000-2004, 2006, 2009
PACKAGE=lib${LIB}
-CONTRDIR= ${.CURDIR}/../../contrib/file
+CONTRDIR= ${SRCTOP}/contrib/file
.PATH: ${CONTRDIR}/src
.PATH: ${CONTRDIR}/doc
diff --git a/lib/libmd/Makefile b/lib/libmd/Makefile
index bb50623..b556ea0 100644
--- a/lib/libmd/Makefile
+++ b/lib/libmd/Makefile
@@ -78,11 +78,11 @@ CLEANFILES+= md[245]hl.c md[245].ref md[245].3 mddriver \
# in which case:
# * macros are used to rename symbols to libcrypt internal names
# * no weak aliases are generated
-CFLAGS+= -I${.CURDIR} -I${.CURDIR}/../../sys/crypto/sha2
-CFLAGS+= -I${.CURDIR}/../../sys/crypto/skein
+CFLAGS+= -I${.CURDIR} -I${SRCTOP}/sys/crypto/sha2
+CFLAGS+= -I${SRCTOP}/sys/crypto/skein
CFLAGS+= -DWEAK_REFS
-.PATH: ${.CURDIR}/${MACHINE_ARCH} ${.CURDIR}/../../sys/crypto/sha2
-.PATH: ${.CURDIR}/../../sys/crypto/skein ${.CURDIR}/../../sys/crypto/skein/${MACHINE_ARCH}
+.PATH: ${.CURDIR}/${MACHINE_ARCH} ${SRCTOP}/sys/crypto/sha2
+.PATH: ${SRCTOP}/sys/crypto/skein ${SRCTOP}/sys/crypto/skein/${MACHINE_ARCH}
.if exists(${MACHINE_ARCH}/sha.S)
SRCS+= sha.S
diff --git a/lib/libmilter/Makefile b/lib/libmilter/Makefile
index 88a80b7..a8efe9c 100644
--- a/lib/libmilter/Makefile
+++ b/lib/libmilter/Makefile
@@ -3,7 +3,7 @@
.include <src.opts.mk>
PACKAGE=sendmail
-SENDMAIL_DIR=${.CURDIR}/../../contrib/sendmail
+SENDMAIL_DIR=${SRCTOP}/contrib/sendmail
.PATH: ${SENDMAIL_DIR}/libmilter ${SENDMAIL_DIR}/libsm
CFLAGS+=-I${SENDMAIL_DIR}/src -I${SENDMAIL_DIR}/include -I.
diff --git a/lib/libmp/Makefile b/lib/libmp/Makefile
index 8d8c527..16f96ab 100644
--- a/lib/libmp/Makefile
+++ b/lib/libmp/Makefile
@@ -10,9 +10,9 @@ MAN= libmp.3
INCS= mp.h
SRCS= mpasbn.c
-CFLAGS+= -I${.CURDIR}/../../crypto
+CFLAGS+= -I${SRCTOP}/crypto
-VERSION_DEF= ${.CURDIR}/../libc/Versions.def
+VERSION_DEF= ${SRCTOP}/lib/libc/Versions.def
SYMBOL_MAPS= ${.CURDIR}/Symbol.map
.if ${MK_TESTS} != "no"
diff --git a/lib/libnetbsd/glob.h b/lib/libnetbsd/glob.h
new file mode 100644
index 0000000..a42d823
--- /dev/null
+++ b/lib/libnetbsd/glob.h
@@ -0,0 +1,39 @@
+/*-
+ * Copyright (c) 2017 Dell, Inc.
+ * 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.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _LIBNETBSD_GLOB_H_
+#define _LIBNETBSD_GLOB_H_
+
+#include_next <glob.h>
+
+#ifndef __gl_stat_t
+#define __gl_stat_t struct stat
+#endif
+
+#endif
diff --git a/lib/libnetbsd/pthread.h b/lib/libnetbsd/pthread.h
new file mode 100644
index 0000000..f436574
--- /dev/null
+++ b/lib/libnetbsd/pthread.h
@@ -0,0 +1,36 @@
+/*-
+ * Copyright (c) 2017 Dell, Inc.
+ * 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.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _LIBNETBSD_PTHREAD_H_
+#define _LIBNETBSD_PTHREAD_H_
+
+#include_next <pthread.h>
+#include <pthread_np.h>
+
+#endif
diff --git a/lib/libnetbsd/sha1.h b/lib/libnetbsd/sha1.h
index 41280c5..9da870e 100644
--- a/lib/libnetbsd/sha1.h
+++ b/lib/libnetbsd/sha1.h
@@ -35,8 +35,11 @@
#include <sha.h>
+#define SHA1_CTX SHA_CTX
+
#define SHA1End SHA1_End
#define SHA1File SHA1_File
+#define SHA1Final SHA1_Final
#define SHA1Init SHA1_Init
#define SHA1Update SHA1_Update
diff --git a/lib/libnetbsd/sha2.h b/lib/libnetbsd/sha2.h
index b67691d..6329284 100644
--- a/lib/libnetbsd/sha2.h
+++ b/lib/libnetbsd/sha2.h
@@ -34,6 +34,7 @@
#define _SHA2_H_
#include <sha256.h>
+#include <sha384.h>
#include <sha512.h>
#endif /* _SHA2_H_ */
diff --git a/lib/libnetbsd/sys/event.h b/lib/libnetbsd/sys/event.h
new file mode 100644
index 0000000..88a363c
--- /dev/null
+++ b/lib/libnetbsd/sys/event.h
@@ -0,0 +1,42 @@
+/*-
+ * Copyright (c) 2017 Dell, Inc.
+ * 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 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.
+ *
+ * $FreeBSD$ *
+ */
+
+#ifndef _LIBNETBSD_SYS_EVENT_H_
+#define _LIBNETBSD_SYS_EVENT_H_
+
+/*
+ * kqueue on FreeBSD requires sys/event.h, which in turn uses uintptr_t
+ * (defined in sys/types.h), so in order to accomodate their requirements,
+ * pull in sys/types.h as part of event.h.
+ */
+#include <sys/types.h>
+
+#include_next <sys/event.h>
+
+#endif
diff --git a/lib/libnetbsd/sys/types.h b/lib/libnetbsd/sys/types.h
new file mode 100644
index 0000000..e14dd49
--- /dev/null
+++ b/lib/libnetbsd/sys/types.h
@@ -0,0 +1,37 @@
+/*-
+ * Copyright (c) 2017 Dell, Inc.
+ * 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 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.
+ *
+ * $FreeBSD$ *
+ */
+
+#ifndef _LIBNETBSD_SYS_TYPES_H_
+#define _LIBNETBSD_SYS_TYPES_H_
+
+#include_next <sys/types.h>
+
+#include <sys/param.h> /* For NBBY */
+
+#endif
diff --git a/lib/libnetbsd/sys/wait.h b/lib/libnetbsd/sys/wait.h
new file mode 100644
index 0000000..a936980
--- /dev/null
+++ b/lib/libnetbsd/sys/wait.h
@@ -0,0 +1,37 @@
+/*-
+ * Copyright (c) 2017 Dell, Inc.
+ * 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 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.
+ *
+ * $FreeBSD$ *
+ */
+
+#ifndef _LIBNETBSD_SYS_WAIT_H_
+#define _LIBNETBSD_SYS_WAIT_H_
+
+#include_next <sys/wait.h>
+
+#define wrusage __wrusage
+
+#endif
diff --git a/lib/libnetbsd/util.h b/lib/libnetbsd/util.h
index c7d32e1..99bc3ca 100644
--- a/lib/libnetbsd/util.h
+++ b/lib/libnetbsd/util.h
@@ -30,12 +30,13 @@
* SUCH DAMAGE.
*/
-#ifndef _UTIL_H_
-#define _UTIL_H_
+#ifndef _LIBNETBSD_UTIL_H_
+#define _LIBNETBSD_UTIL_H_
+#include <sys/types.h>
#include <libutil.h>
char *flags_to_string(u_long flags, const char *def);
int string_to_flags(char **stringp, u_long *setp, u_long *clrp);
-#endif /* _UTIL_H_ */
+#endif
diff --git a/lib/libngatm/Makefile b/lib/libngatm/Makefile
index 71f21d5..afda4fb 100644
--- a/lib/libngatm/Makefile
+++ b/lib/libngatm/Makefile
@@ -8,8 +8,8 @@ SHLIB_MAJOR= 4
MAN= libngatm.3 uniaddr.3 unifunc.3 unimsg.3 unisap.3 unistruct.3
# source of the library lives in contrib
-SDIR= ${.CURDIR}/../../sys
-CTRB= ${.CURDIR}/../../contrib/ngatm
+SDIR= ${SRCTOP}/sys
+CTRB= ${SRCTOP}/contrib/ngatm
LIBBASE= ${SDIR}/contrib/ngatm
CFLAGS+= -I${LIBBASE} -I${.OBJDIR} -I${CTRB}/libngatm
diff --git a/lib/libnv/Makefile b/lib/libnv/Makefile
index 4b2125b..4c1c283 100644
--- a/lib/libnv/Makefile
+++ b/lib/libnv/Makefile
@@ -8,8 +8,8 @@ SHLIBDIR?= /lib
LIB= nv
SHLIB_MAJOR= 0
-.PATH: ${.CURDIR}/../../sys/contrib/libnv ${.CURDIR}/../../sys/sys
-CFLAGS+=-I${.CURDIR}/../../sys -I${.CURDIR}
+.PATH: ${SRCTOP}/sys/contrib/libnv ${SRCTOP}/sys/sys
+CFLAGS+=-I${SRCTOP}/sys -I${.CURDIR}
SRCS= dnvlist.c
SRCS+= msgio.c
diff --git a/lib/libopie/Makefile b/lib/libopie/Makefile
index 367bbc6..4507d25 100644
--- a/lib/libopie/Makefile
+++ b/lib/libopie/Makefile
@@ -3,7 +3,7 @@
# $FreeBSD$
#
PACKAGE=lib${LIB}
-OPIE_DIST?= ${.CURDIR}/../../contrib/opie
+OPIE_DIST?= ${SRCTOP}/contrib/opie
DIST_DIR= ${OPIE_DIST}/${.CURDIR:T}
SHLIB_MAJOR= 8
diff --git a/lib/libpam/libpam/Makefile b/lib/libpam/libpam/Makefile
index 1e634b7..41863ad 100644
--- a/lib/libpam/libpam/Makefile
+++ b/lib/libpam/libpam/Makefile
@@ -36,7 +36,7 @@
# $FreeBSD$
PACKAGE=lib${LIB}
-OPENPAM= ${.CURDIR}/../../../contrib/openpam
+OPENPAM= ${SRCTOP}/contrib/openpam
.PATH: ${OPENPAM}/include ${OPENPAM}/lib/libpam ${OPENPAM}/doc/man
# static_libpam will build libpam.a
diff --git a/lib/libpam/modules/Makefile.inc b/lib/libpam/modules/Makefile.inc
index 899c3cb..87885c3 100644
--- a/lib/libpam/modules/Makefile.inc
+++ b/lib/libpam/modules/Makefile.inc
@@ -1,11 +1,11 @@
# $FreeBSD$
-PAMDIR= ${.CURDIR}/../../../../contrib/openpam
+PAMDIR= ${SRCTOP}/contrib/openpam
MK_INSTALLLIB= no
MK_PROFILE= no
-CFLAGS+= -I${PAMDIR}/include -I${.CURDIR}/../../libpam
+CFLAGS+= -I${PAMDIR}/include -I${SRCTOP}/lib/libpam
SHLIB_NAME?= ${LIB}.so.${SHLIB_MAJOR}
LIBADD+= pam
diff --git a/lib/libpam/modules/pam_passwdqc/Makefile b/lib/libpam/modules/pam_passwdqc/Makefile
index cd23642..2b10fdc 100644
--- a/lib/libpam/modules/pam_passwdqc/Makefile
+++ b/lib/libpam/modules/pam_passwdqc/Makefile
@@ -1,6 +1,6 @@
# $FreeBSD$
-SRCDIR= ${.CURDIR}/../../../../contrib/pam_modules/pam_passwdqc
+SRCDIR= ${SRCTOP}/contrib/pam_modules/pam_passwdqc
.PATH: ${SRCDIR}
LIB= pam_passwdqc
diff --git a/lib/libpam/modules/pam_ssh/Makefile b/lib/libpam/modules/pam_ssh/Makefile
index 8de1bdf..d2168b3 100644
--- a/lib/libpam/modules/pam_ssh/Makefile
+++ b/lib/libpam/modules/pam_ssh/Makefile
@@ -1,7 +1,7 @@
# PAM module for SSH
# $FreeBSD$
-SSHDIR= ${.CURDIR}/../../../../crypto/openssh
+SSHDIR= ${SRCTOP}/crypto/openssh
LIB= pam_ssh
MAN= pam_ssh.8
diff --git a/lib/libpam/static_libpam/Makefile b/lib/libpam/static_libpam/Makefile
index f7180e9..1aca191 100644
--- a/lib/libpam/static_libpam/Makefile
+++ b/lib/libpam/static_libpam/Makefile
@@ -35,7 +35,7 @@
#
# $FreeBSD$
-.PATH: ${.CURDIR}/../libpam
+.PATH: ${SRCTOP}/lib/libpam
# Only build the static library.
LIB= pam
@@ -66,4 +66,4 @@ CLEANFILES+= openpam_static.o \
openpam_static_modules.o: openpam_static.o ${STATIC_MODULES}
${LD} -o ${.TARGET} -r --whole-archive ${.ALLSRC}
-.include "${.CURDIR}/../libpam/Makefile"
+.include "${.CURDIR:H}/libpam/Makefile"
diff --git a/lib/libpcap/Makefile b/lib/libpcap/Makefile
index e7512e6..9b7ffe9 100644
--- a/lib/libpcap/Makefile
+++ b/lib/libpcap/Makefile
@@ -114,7 +114,7 @@ SHLIB_MAJOR= 8
#
# Magic to grab sources out of src/contrib
#
-PCAP_DISTDIR?=${.CURDIR}/../../contrib/libpcap
+PCAP_DISTDIR?=${SRCTOP}/contrib/libpcap
CFLAGS+=-I${PCAP_DISTDIR}
.PATH: ${PCAP_DISTDIR}
.PATH: ${PCAP_DISTDIR}/bpf/net
diff --git a/lib/libpe/Makefile b/lib/libpe/Makefile
index 877b331..29634e1 100644
--- a/lib/libpe/Makefile
+++ b/lib/libpe/Makefile
@@ -3,7 +3,7 @@
INTERNALLIB=
-ELFTCDIR= ${.CURDIR}/../../contrib/elftoolchain
+ELFTCDIR= ${SRCTOP}/contrib/elftoolchain
.PATH: ${ELFTCDIR}/libpe
diff --git a/lib/libproc/Makefile b/lib/libproc/Makefile
index 0372377..91646e3 100644
--- a/lib/libproc/Makefile
+++ b/lib/libproc/Makefile
@@ -29,9 +29,9 @@ LIBADD+= elf rtld_db util
.if ${MK_CDDL} != "no"
LIBADD+= ctf
IGNORE_PRAGMA= YES
-CFLAGS+= -I${.CURDIR}/../../cddl/contrib/opensolaris/lib/libctf/common \
- -I${.CURDIR}/../../sys/cddl/contrib/opensolaris/uts/common \
- -I${.CURDIR}/../../sys/cddl/compat/opensolaris
+CFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/lib/libctf/common \
+ -I${SRCTOP}/sys/cddl/contrib/opensolaris/uts/common \
+ -I${SRCTOP}/sys/cddl/compat/opensolaris
.else
CFLAGS+= -DNO_CTF
.endif
diff --git a/lib/libprocstat/zfs/Makefile b/lib/libprocstat/zfs/Makefile
index 9200f02..a58f298 100644
--- a/lib/libprocstat/zfs/Makefile
+++ b/lib/libprocstat/zfs/Makefile
@@ -1,21 +1,21 @@
# $FreeBSD$
-.PATH: ${.CURDIR}/..
+.PATH: ${.CURDIR:H}
SRCS= zfs.c
OBJS= zfs.o
WARNS?= 1
-CFLAGS+= -I${.CURDIR}/../../../sys/cddl/compat/opensolaris
-CFLAGS+= -I${.CURDIR}/../../../cddl/compat/opensolaris/include
-CFLAGS+= -I${.CURDIR}/../../../cddl/compat/opensolaris/lib/libumem
-CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libzpool/common
-CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/common/zfs
-CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common/fs/zfs
-CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common
-CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common/sys
-CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/head
-CFLAGS+= -I${.CURDIR}/..
+CFLAGS+= -I${SRCTOP}/sys/cddl/compat/opensolaris
+CFLAGS+= -I${SRCTOP}/cddl/compat/opensolaris/include
+CFLAGS+= -I${SRCTOP}/cddl/compat/opensolaris/lib/libumem
+CFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/lib/libzpool/common
+CFLAGS+= -I${SRCTOP}/sys/cddl/contrib/opensolaris/common/zfs
+CFLAGS+= -I${SRCTOP}/sys/cddl/contrib/opensolaris/uts/common/fs/zfs
+CFLAGS+= -I${SRCTOP}/sys/cddl/contrib/opensolaris/uts/common
+CFLAGS+= -I${SRCTOP}/sys/cddl/contrib/opensolaris/uts/common/sys
+CFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/head
+CFLAGS+= -I${.CURDIR:H}
CFLAGS+= -DNEED_SOLARIS_BOOLEAN
all: ${OBJS}
diff --git a/lib/librpcsec_gss/Makefile b/lib/librpcsec_gss/Makefile
index e59f1e5..7dccfc5 100644
--- a/lib/librpcsec_gss/Makefile
+++ b/lib/librpcsec_gss/Makefile
@@ -8,11 +8,11 @@ SRCS+= rpcsec_gss.c rpcsec_gss_prot.c rpcsec_gss_conf.c rpcsec_gss_misc.c \
LIBADD= gssapi
-VERSION_DEF= ${.CURDIR}/../libc/Versions.def
+VERSION_DEF= ${SRCTOP}/lib/libc/Versions.def
SYMBOL_MAPS= ${.CURDIR}/Symbol.map
-CFLAGS+= -I${.CURDIR}/../../include
-CFLAGS+= -I${.CURDIR}/../../libc_rpc
+CFLAGS+= -I${SRCTOP}/include
+CFLAGS+= -I${SRCTOP}/lib/libc_rpc
MK_PROFILE= no
MAN= rpcsec_gss.3
diff --git a/lib/librpcsvc/Makefile b/lib/librpcsvc/Makefile
index 1deda17..b491700 100644
--- a/lib/librpcsvc/Makefile
+++ b/lib/librpcsvc/Makefile
@@ -3,7 +3,7 @@
.include <src.opts.mk>
-.PATH: ${.CURDIR}/../../include/rpcsvc
+.PATH: ${SRCTOP}/include/rpcsvc
PACKAGE=lib${LIB}
LIB= rpcsvc
diff --git a/lib/librt/Makefile b/lib/librt/Makefile
index 560f2af..5417b9e 100644
--- a/lib/librt/Makefile
+++ b/lib/librt/Makefile
@@ -5,7 +5,7 @@
PACKAGE=lib${LIB}
LIB=rt
SHLIB_MAJOR= 1
-CFLAGS+=-I${.CURDIR}/../libc/include -I${.CURDIR}
+CFLAGS+=-I${SRCTOP}/lib/libc/include -I${.CURDIR}
.ifndef NO_THREAD_STACK_UNWIND
CFLAGS+=-fexceptions
.endif
@@ -18,7 +18,7 @@ SRCS+= aio.c mq.c sigev_thread.c timer.c
PRECIOUSLIB=
-VERSION_DEF=${.CURDIR}/../libc/Versions.def
+VERSION_DEF=${SRCTOP}/lib/libc/Versions.def
SYMBOL_MAPS=${.CURDIR}/Symbol.map
.if ${MK_TESTS} != "no"
diff --git a/lib/libsbuf/Makefile b/lib/libsbuf/Makefile
index ebf4a8d..3d8ea6f 100644
--- a/lib/libsbuf/Makefile
+++ b/lib/libsbuf/Makefile
@@ -10,6 +10,6 @@ SHLIB_MAJOR = 6
SYMBOL_MAPS= ${.CURDIR}/Symbol.map
VERSION_DEF= ${.CURDIR}/Version.def
-.PATH: ${.CURDIR}/../../sys/kern
+.PATH: ${SRCTOP}/sys/kern
.include <bsd.lib.mk>
diff --git a/lib/libsm/Makefile b/lib/libsm/Makefile
index 9840092..94af1b3 100644
--- a/lib/libsm/Makefile
+++ b/lib/libsm/Makefile
@@ -3,7 +3,7 @@
.include <src.opts.mk>
PACKAGE=sendmail
-SENDMAIL_DIR=${.CURDIR}/../../contrib/sendmail
+SENDMAIL_DIR=${SRCTOP}/contrib/sendmail
.PATH: ${SENDMAIL_DIR}/libsm
CFLAGS+=-I${SENDMAIL_DIR}/src -I${SENDMAIL_DIR}/include -I.
diff --git a/lib/libsmb/Makefile b/lib/libsmb/Makefile
index 6236a2e..519db5f 100644
--- a/lib/libsmb/Makefile
+++ b/lib/libsmb/Makefile
@@ -3,7 +3,7 @@
.include <src.opts.mk>
PACKAGE=lib${LIB}
-CONTRIBDIR= ${.CURDIR}/../../contrib/smbfs
+CONTRIBDIR= ${SRCTOP}/contrib/smbfs
.PATH: ${CONTRIBDIR}/lib/smb
LIB= smb
diff --git a/lib/libsmdb/Makefile b/lib/libsmdb/Makefile
index 3fbd116..b1957b9 100644
--- a/lib/libsmdb/Makefile
+++ b/lib/libsmdb/Makefile
@@ -1,7 +1,7 @@
# $FreeBSD$
PACKAGE=lib${LIB}
-SENDMAIL_DIR=${.CURDIR}/../../contrib/sendmail
+SENDMAIL_DIR=${SRCTOP}/contrib/sendmail
.PATH: ${SENDMAIL_DIR}/libsmdb
CFLAGS+=-I${SENDMAIL_DIR}/src -I${SENDMAIL_DIR}/include -I.
diff --git a/lib/libsmutil/Makefile b/lib/libsmutil/Makefile
index e1d908e..ff3f849 100644
--- a/lib/libsmutil/Makefile
+++ b/lib/libsmutil/Makefile
@@ -1,7 +1,7 @@
# $FreeBSD$
PACKAGE=lib${LIB}
-SENDMAIL_DIR=${.CURDIR}/../../contrib/sendmail
+SENDMAIL_DIR=${SRCTOP}/contrib/sendmail
.PATH: ${SENDMAIL_DIR}/libsmutil
CFLAGS+=-I${SENDMAIL_DIR}/src -I${SENDMAIL_DIR}/include -I.
diff --git a/lib/libsqlite3/Makefile b/lib/libsqlite3/Makefile
index 37a3a6e..5e0d17b 100644
--- a/lib/libsqlite3/Makefile
+++ b/lib/libsqlite3/Makefile
@@ -8,7 +8,7 @@ LIBADD+= pthread
SRCS= sqlite3.c
-SQLITE= ${.CURDIR}/../../contrib/sqlite3
+SQLITE= ${SRCTOP}/contrib/sqlite3
.PATH: ${SQLITE}
WARNS= 3
diff --git a/lib/libstdthreads/Makefile b/lib/libstdthreads/Makefile
index 3200d4e..de696c7 100644
--- a/lib/libstdthreads/Makefile
+++ b/lib/libstdthreads/Makefile
@@ -35,7 +35,7 @@ MLINKS= thrd_create.3 call_once.3 \
LIBADD= pthread
-VERSION_DEF= ${.CURDIR}/../libc/Versions.def
+VERSION_DEF= ${SRCTOP}/lib/libc/Versions.def
SYMBOL_MAPS= ${.CURDIR}/Symbol.map
.include <bsd.lib.mk>
diff --git a/lib/libsysdecode/Makefile b/lib/libsysdecode/Makefile
index 47ba9af..bde9460 100644
--- a/lib/libsysdecode/Makefile
+++ b/lib/libsysdecode/Makefile
@@ -9,8 +9,8 @@ SRCS= errno.c flags.c ioctl.c signal.c syscallnames.c utrace.c
INCS= sysdecode.h
CFLAGS+= -I${.OBJDIR}
-CFLAGS+= -I${.CURDIR}/../../sys
-CFLAGS+= -I${.CURDIR}/../../libexec/rtld-elf
+CFLAGS+= -I${SRCTOP}/sys
+CFLAGS+= -I${SRCTOP}/libexec/rtld-elf
MAN= sysdecode.3 \
sysdecode_abi_to_freebsd_errno.3 \
diff --git a/lib/libsysdecode/mktables b/lib/libsysdecode/mktables
index 563bd18..6c44a05 100644
--- a/lib/libsysdecode/mktables
+++ b/lib/libsysdecode/mktables
@@ -142,7 +142,7 @@ gen_table "seekwhence" "SEEK_[A-Z]+[[:space:]]+[0-9]+" "sys/
gen_table "fcntlcmd" "F_[A-Z0-9_]+[[:space:]]+[0-9]+[[:space:]]+" "sys/fcntl.h" "F_CANCEL|F_..LCK"
gen_table "mmapflags" "MAP_[A-Z_]+[[:space:]]+0x[0-9A-Fa-f]+" "sys/mman.h"
gen_table "rtpriofuncs" "RTP_[A-Z]+[[:space:]]+[0-9]+" "sys/rtprio.h"
-gen_table "msgflags" "MSG_[A-Z]+[[:space:]]+0x[0-9]+" "sys/socket.h" "MSG_SOCALLBCK"
+gen_table "msgflags" "MSG_[A-Z]+[[:space:]]+0x[0-9]+" "sys/socket.h" "MSG_SOCALLBCK|MSG_MORETOCOME"
gen_table "sigcode" "SI_[A-Z]+[[:space:]]+0(x[0-9abcdef]+)?" "sys/signal.h"
gen_table "umtxcvwaitflags" "CVWAIT_[A-Z_]+[[:space:]]+0x[0-9]+" "sys/umtx.h"
gen_table "umtxrwlockflags" "URWLOCK_PREFER_READER[[:space:]]+0x[0-9]+" "sys/umtx.h"
diff --git a/lib/libtelnet/Makefile b/lib/libtelnet/Makefile
index b5bba12..36c2dda 100644
--- a/lib/libtelnet/Makefile
+++ b/lib/libtelnet/Makefile
@@ -4,7 +4,7 @@
.include <src.opts.mk>
PACKAGE=lib${LIB}
-TELNETDIR= ${.CURDIR}/../../contrib/telnet
+TELNETDIR= ${SRCTOP}/contrib/telnet
.PATH: ${TELNETDIR}/libtelnet
LIB= telnet
diff --git a/lib/libthr/Makefile b/lib/libthr/Makefile
index 517a30f..5b3e3bf 100644
--- a/lib/libthr/Makefile
+++ b/lib/libthr/Makefile
@@ -18,13 +18,13 @@ LIB=thr
SHLIB_MAJOR= 3
WARNS?= 3
CFLAGS+=-DPTHREAD_KERNEL
-CFLAGS+=-I${.CURDIR}/../libc/include -I${.CURDIR}/thread \
- -I${.CURDIR}/../../include
+CFLAGS+=-I${SRCTOP}/lib/libc/include -I${.CURDIR}/thread \
+ -I${SRCTOP}/include
CFLAGS+=-I${.CURDIR}/arch/${MACHINE_CPUARCH}/include
CFLAGS+=-I${.CURDIR}/sys
-CFLAGS+=-I${.CURDIR}/../../libexec/rtld-elf
-CFLAGS+=-I${.CURDIR}/../../libexec/rtld-elf/${MACHINE_CPUARCH}
-CFLAGS+=-I${.CURDIR}/../libthread_db
+CFLAGS+=-I${SRCTOP}/libexec/rtld-elf
+CFLAGS+=-I${SRCTOP}/libexec/rtld-elf/${MACHINE_CPUARCH}
+CFLAGS+=-I${SRCTOP}/lib/libthread_db
CFLAGS+=-Winline
.ifndef NO_THREAD_UNWIND_STACK
@@ -34,7 +34,7 @@ CFLAGS+=-D_PTHREAD_FORCED_UNWIND
LDFLAGS+=-Wl,-znodelete
-VERSION_DEF=${.CURDIR}/../libc/Versions.def
+VERSION_DEF=${SRCTOP}/lib/libc/Versions.def
SYMBOL_MAPS=${.CURDIR}/pthread.map
MAN= libthr.3
diff --git a/lib/libthr/support/Makefile.inc b/lib/libthr/support/Makefile.inc
index 1814f8a..cd4d206 100644
--- a/lib/libthr/support/Makefile.inc
+++ b/lib/libthr/support/Makefile.inc
@@ -1,15 +1,15 @@
# $FreeBSD$
-.PATH: ${.CURDIR}/support ${.CURDIR}/../libc/gen ${.CURDIR}/../libc/string
+.PATH: ${.CURDIR}/support ${SRCTOP}/lib/libc/gen ${SRCTOP}/lib/libc/string
# libc must search machine_arch, then machine_cpuarch, but libthr has all its
# code implemented in machine_cpuarch. Cope.
-.if exists(${.CURDIR}/../libc/${MACHINE_ARCH}/sys)
-.PATH: ${.CURDIR}/../libc/${MACHINE_ARCH}/sys
-CFLAGS+= -I${.CURDIR}/../libc/${MACHINE_ARCH}
+.if exists(${SRCTOP}/lib/libc/${MACHINE_ARCH}/sys)
+.PATH: ${SRCTOP}/lib/libc/${MACHINE_ARCH}/sys
+CFLAGS+= -I${SRCTOP}/lib/libc/${MACHINE_ARCH}
.else
-.PATH: ${.CURDIR}/../libc/${MACHINE_CPUARCH}/sys
-CFLAGS+= -I${.CURDIR}/../libc/${MACHINE_CPUARCH}
+.PATH: ${SRCTOP}/lib/libc/${MACHINE_CPUARCH}/sys
+CFLAGS+= -I${SRCTOP}/lib/libc/${MACHINE_CPUARCH}
.endif
SYSCALLS= thr_new
diff --git a/lib/libthr/tests/Makefile b/lib/libthr/tests/Makefile
index 159cc3b..7e6617d 100644
--- a/lib/libthr/tests/Makefile
+++ b/lib/libthr/tests/Makefile
@@ -26,6 +26,7 @@ NETBSD_ATF_TESTS_C+= sleep_test
.if ${MACHINE} != "arm64" # ARM64TODO: Missing makecontext
NETBSD_ATF_TESTS_C+= swapcontext_test
.endif
+NETBSD_ATF_TESTS_C+= timedmutex_test
NETBSD_ATF_TESTS_SH= atexit_test
NETBSD_ATF_TESTS_SH+= cancel_test
diff --git a/lib/libthread_db/Makefile b/lib/libthread_db/Makefile
index dfd4516..1484b88 100644
--- a/lib/libthread_db/Makefile
+++ b/lib/libthread_db/Makefile
@@ -15,7 +15,7 @@ CFLAGS+=-I. -I${.CURDIR}
SYM_MAPS+=${.CURDIR}/Symbol.map
SYMBOL_MAPS=${SYM_MAPS}
-VERSION_DEF=${.CURDIR}/../libc/Versions.def
+VERSION_DEF=${SRCTOP}/lib/libc/Versions.def
# Unfortunately, clang gives an incorrect warning about alignment in
# arch/i386/libpthread_md.c, so turn that off for now.
diff --git a/lib/libufs/Makefile b/lib/libufs/Makefile
index 86fa4c9..c1948b3 100644
--- a/lib/libufs/Makefile
+++ b/lib/libufs/Makefile
@@ -18,7 +18,7 @@ MLINKS+= ufs_disk_close.3 ufs_disk_fillout.3
MLINKS+= ufs_disk_close.3 ufs_disk_fillout_blank.3
MLINKS+= ufs_disk_close.3 ufs_disk_write.3
-.PATH: ${.CURDIR}/../../sys/ufs/ffs
+.PATH: ${SRCTOP}/sys/ufs/ffs
WARNS?= 2
diff --git a/lib/libulog/Makefile b/lib/libulog/Makefile
index 434f3f6..7c793e9 100644
--- a/lib/libulog/Makefile
+++ b/lib/libulog/Makefile
@@ -22,7 +22,7 @@ MLINKS+=ulog_login.3 ulog_login_pseudo.3 \
LIBADD= md
-VERSION_DEF= ${.CURDIR}/../libc/Versions.def
+VERSION_DEF= ${SRCTOP}/lib/libc/Versions.def
SYMBOL_MAPS= ${.CURDIR}/Symbol.map
.if ${MK_INSTALLLIB} != "no"
diff --git a/lib/libunbound/Makefile b/lib/libunbound/Makefile
index a30bfc7..2e0e249 100644
--- a/lib/libunbound/Makefile
+++ b/lib/libunbound/Makefile
@@ -2,8 +2,8 @@
PACKAGE=lib${LIB}
# Vendor sources and generated files
-LDNSDIR= ${.CURDIR}/../../contrib/ldns
-UNBOUNDDIR= ${.CURDIR}/../../contrib/unbound
+LDNSDIR= ${SRCTOP}/contrib/ldns
+UNBOUNDDIR= ${SRCTOP}/contrib/unbound
# Hold my beer and watch this
.PATH: ${UNBOUNDDIR} ${UNBOUNDDIR}/cachedb ${UNBOUNDDIR}/dns64 ${UNBOUNDDIR}/iterator ${UNBOUNDDIR}/sldns ${UNBOUNDDIR}/libunbound ${UNBOUNDDIR}/services ${UNBOUNDDIR}/services/cache ${UNBOUNDDIR}/util ${UNBOUNDDIR}/util/data ${UNBOUNDDIR}/util/storage ${UNBOUNDDIR}/validator
diff --git a/lib/libutil/Makefile b/lib/libutil/Makefile
index 07412e0..aa0f25e 100644
--- a/lib/libutil/Makefile
+++ b/lib/libutil/Makefile
@@ -25,7 +25,7 @@ CFLAGS+= -DLIBC_SCCS
CFLAGS+= -DINET6
.endif
-CFLAGS+= -I${.CURDIR} -I${.CURDIR}/../libc/gen/
+CFLAGS+= -I${.CURDIR} -I${SRCTOP}/lib/libc/gen/
MAN+= expand_number.3 flopen.3 fparseln.3 hexdump.3 \
humanize_number.3 kinfo_getallproc.3 kinfo_getfile.3 \
diff --git a/lib/libypclnt/Makefile b/lib/libypclnt/Makefile
index 113a3cc..c043d63 100644
--- a/lib/libypclnt/Makefile
+++ b/lib/libypclnt/Makefile
@@ -24,9 +24,9 @@ GENSRCS=yp.h \
yppasswd_private_xdr.c
RPCGEN= RPCGEN_CPP=${CPP:Q} rpcgen -C
-RPCSRC= ${.CURDIR}/../../include/rpcsvc/yp.x
-RPCSRC_PW= ${.CURDIR}/../../include/rpcsvc/yppasswd.x
-RPCSRC_PRIV= ${.CURDIR}/../../usr.sbin/rpc.yppasswdd/yppasswd_private.x
+RPCSRC= ${SRCTOP}/include/rpcsvc/yp.x
+RPCSRC_PW= ${SRCTOP}/include/rpcsvc/yppasswd.x
+RPCSRC_PRIV= ${SRCTOP}/usr.sbin/rpc.yppasswdd/yppasswd_private.x
yp.h: ${RPCSRC}
${RPCGEN} -h -o ${.TARGET} ${RPCSRC}
diff --git a/lib/libz/Symbol.map b/lib/libz/Symbol.map
index 731ce0a..92b02b5 100644
--- a/lib/libz/Symbol.map
+++ b/lib/libz/Symbol.map
@@ -2,6 +2,17 @@
* $FreeBSD$
*/
+ZLIB_1.2.9 {
+ inflateCodesUsed;
+ inflateValidate;
+ uncompress2;
+ gzfread;
+ gzfwrite;
+ deflateGetDictionary;
+ adler32_z;
+ crc32_z;
+};
+
ZLIB_1.2.7.1 {
inflateGetDictionary;
gzvprintf;
diff --git a/lib/libz/Versions.def b/lib/libz/Versions.def
index 4651e77..d5f1816 100644
--- a/lib/libz/Versions.def
+++ b/lib/libz/Versions.def
@@ -9,6 +9,9 @@ ZLIB_1.2.7.0 {
ZLIB_1.2.7.1 {
} ZLIB_1.2.7.0;
+ZLIB_1.2.9 {
+} ZLIB_1.2.7.1;
+
FBSD_1.2 {
} ZLIB_1.2.4.0;
diff --git a/lib/libz/zlib.pc b/lib/libz/zlib.pc
index 63a214f..b9ad734 100644
--- a/lib/libz/zlib.pc
+++ b/lib/libz/zlib.pc
@@ -7,7 +7,7 @@ includedir=${prefix}/include
Name: zlib
Description: zlib compression library
-Version: 1.2.8
+Version: 1.2.10
Requires:
Libs: -L${libdir} -L${sharedlibdir} -lz
diff --git a/lib/msun/tests/Makefile b/lib/msun/tests/Makefile
index ad56873..a64747e 100644
--- a/lib/msun/tests/Makefile
+++ b/lib/msun/tests/Makefile
@@ -23,12 +23,15 @@ NETBSD_ATF_TESTS_C+= asin_test
NETBSD_ATF_TESTS_C+= atan_test
NETBSD_ATF_TESTS_C+= cbrt_test
NETBSD_ATF_TESTS_C+= ceil_test
+NETBSD_ATF_TESTS_C+= casinh_test
NETBSD_ATF_TESTS_C+= cos_test
NETBSD_ATF_TESTS_C+= cosh_test
NETBSD_ATF_TESTS_C+= erf_test
NETBSD_ATF_TESTS_C+= exp_test
NETBSD_ATF_TESTS_C+= fmod_test
+NETBSD_ATF_TESTS_C+= fe_round_test
NETBSD_ATF_TESTS_C+= infinity_test
+NETBSD_ATF_TESTS_C+= ilogb_test
NETBSD_ATF_TESTS_C+= ldexp_test
NETBSD_ATF_TESTS_C+= log_test
NETBSD_ATF_TESTS_C+= pow_test
@@ -53,7 +56,7 @@ TAP_TESTS_C+= exponential_test
TAP_TESTS_C+= fenv_test
TAP_TESTS_C+= fma_test
TAP_TESTS_C+= fmaxmin_test
-TAP_TESTS_C+= ilogb_test
+TAP_TESTS_C+= ilogb2_test
TAP_TESTS_C+= invtrig_test
TAP_TESTS_C+= invctrig_test
TAP_TESTS_C+= logarithm_test
@@ -77,6 +80,8 @@ CSTD= c99
IGNORE_PRAGMA=
+SRCS.ilogb2_test= ilogb_test.c
+
LIBADD+= m
# Copied from lib/msun/Makefile
diff --git a/lib/msun/tests/fmaxmin_test.c b/lib/msun/tests/fmaxmin_test.c
index 87adb95..24056b0 100644
--- a/lib/msun/tests/fmaxmin_test.c
+++ b/lib/msun/tests/fmaxmin_test.c
@@ -116,7 +116,8 @@ testall(int testnum, long double big, long double small)
/* Clang 3.8.0+ fails the invariants for testcase 6, 7, 10, and 11. */
#if defined(__clang__) && \
- (__clang_major__ >= 3 && __clang_minor__ >= 8 && __clang_patchlevel__ >= 0)
+ ((__clang_major__ > 3)) || \
+ ((__clang_major__ == 3 && __clang_minor__ >= 8))
#define affected_by_bug_208703
#endif
diff --git a/lib/ncurses/config.mk b/lib/ncurses/config.mk
index d01e17a..d15be86 100644
--- a/lib/ncurses/config.mk
+++ b/lib/ncurses/config.mk
@@ -2,25 +2,25 @@
# This Makefile is shared by libncurses, libform, libmenu, libpanel.
-NCURSES_DIR= ${.CURDIR}/../../../contrib/ncurses
+NCURSES_DIR= ${SRCTOP}/contrib/ncurses
.if defined(ENABLE_WIDEC)
LIB_SUFFIX= w
CFLAGS+= -D_XOPEN_SOURCE_EXTENDED -DENABLE_WIDEC
-NCURSES_CFG_H= ${.CURDIR}/../ncurses/ncurses_cfg.h
+NCURSES_CFG_H= ${.CURDIR:H}/ncurses/ncurses_cfg.h
.else
LIB_SUFFIX=
NCURSES_CFG_H= ${.CURDIR}/ncurses_cfg.h
.endif
CFLAGS+= -I.
-.if exists(${.OBJDIR}/../ncurses${LIB_SUFFIX})
-CFLAGS+= -I${.OBJDIR}/../ncurses${LIB_SUFFIX}
+.if exists(${.OBJDIR:H}/ncurses${LIB_SUFFIX})
+CFLAGS+= -I${.OBJDIR:H}/ncurses${LIB_SUFFIX}
.endif
-CFLAGS+= -I${.CURDIR}/../ncurses${LIB_SUFFIX}
+CFLAGS+= -I${.CURDIR:H}/ncurses${LIB_SUFFIX}
# for ${NCURSES_CFG_H}
-CFLAGS+= -I${.CURDIR}/../ncurses
+CFLAGS+= -I${.CURDIR:H}/ncurses
CFLAGS+= -I${NCURSES_DIR}/include
CFLAGS+= -I${NCURSES_DIR}/ncurses
diff --git a/lib/ncurses/form/Makefile b/lib/ncurses/form/Makefile
index beefb2c..eab5bbb 100644
--- a/lib/ncurses/form/Makefile
+++ b/lib/ncurses/form/Makefile
@@ -1,6 +1,6 @@
# $FreeBSD$
-.include "${.CURDIR}/../config.mk"
+.include "${.CURDIR:H}/config.mk"
SRCDIR= ${NCURSES_DIR}/form
diff --git a/lib/ncurses/formw/Makefile b/lib/ncurses/formw/Makefile
index 5488503..3ec7637 100644
--- a/lib/ncurses/formw/Makefile
+++ b/lib/ncurses/formw/Makefile
@@ -2,4 +2,4 @@
ENABLE_WIDEC=
-.include "${.CURDIR}/../form/Makefile"
+.include "${.CURDIR:H}/form/Makefile"
diff --git a/lib/ncurses/menu/Makefile b/lib/ncurses/menu/Makefile
index d3890de7..6536196 100644
--- a/lib/ncurses/menu/Makefile
+++ b/lib/ncurses/menu/Makefile
@@ -1,6 +1,6 @@
# $FreeBSD$
-.include "${.CURDIR}/../config.mk"
+.include "${.CURDIR:H}/config.mk"
SRCDIR= ${NCURSES_DIR}/menu
diff --git a/lib/ncurses/menuw/Makefile b/lib/ncurses/menuw/Makefile
index d5a100f..d6df563 100644
--- a/lib/ncurses/menuw/Makefile
+++ b/lib/ncurses/menuw/Makefile
@@ -2,4 +2,4 @@
ENABLE_WIDEC=
-.include "${.CURDIR}/../menu/Makefile"
+.include "${.CURDIR:H}/menu/Makefile"
diff --git a/lib/ncurses/ncurses/Makefile b/lib/ncurses/ncurses/Makefile
index f8649cc..d880ebb 100644
--- a/lib/ncurses/ncurses/Makefile
+++ b/lib/ncurses/ncurses/Makefile
@@ -10,7 +10,7 @@ MK_MAN=no
.include <src.opts.mk>
-.include "${.CURDIR}/../config.mk"
+.include "${.CURDIR:H}/config.mk"
LIB= ncurses${LIB_SUFFIX}
SHLIB_MAJOR= 8
diff --git a/lib/ncurses/ncursesw/Makefile b/lib/ncurses/ncursesw/Makefile
index 277c90b..5f6040e 100644
--- a/lib/ncurses/ncursesw/Makefile
+++ b/lib/ncurses/ncursesw/Makefile
@@ -2,6 +2,6 @@
ENABLE_WIDEC=
-.PATH: ${.CURDIR}/../ncurses
+.PATH: ${.CURDIR:H}/ncurses
-.include "${.CURDIR}/../ncurses/Makefile"
+.include "${.CURDIR:H}/ncurses/Makefile"
diff --git a/lib/ncurses/panel/Makefile b/lib/ncurses/panel/Makefile
index b075bcf..1993f5e 100644
--- a/lib/ncurses/panel/Makefile
+++ b/lib/ncurses/panel/Makefile
@@ -1,6 +1,6 @@
# $FreeBSD$
-.include "${.CURDIR}/../config.mk"
+.include "${.CURDIR:H}/config.mk"
SRCDIR= ${NCURSES_DIR}/panel
diff --git a/lib/ncurses/panelw/Makefile b/lib/ncurses/panelw/Makefile
index 7642e34..2585738 100644
--- a/lib/ncurses/panelw/Makefile
+++ b/lib/ncurses/panelw/Makefile
@@ -2,4 +2,4 @@
ENABLE_WIDEC=
-.include "${.CURDIR}/../panel/Makefile"
+.include "${.CURDIR:H}/panel/Makefile"
diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c
index f75bcad..4828ec6 100644
--- a/libexec/rtld-elf/rtld.c
+++ b/libexec/rtld-elf/rtld.c
@@ -3952,15 +3952,19 @@ symlook_default(SymLook *req, const Obj_Entry *refobj)
donelist_init(&donelist);
symlook_init_from_req(&req1, req);
- /* Look first in the referencing object if linked symbolically. */
- if (refobj->symbolic && !donelist_check(&donelist, refobj)) {
- res = symlook_obj(&req1, refobj);
- if (res == 0) {
- req->sym_out = req1.sym_out;
- req->defobj_out = req1.defobj_out;
- assert(req->defobj_out != NULL);
- }
+ /*
+ * Look first in the referencing object if linked symbolically,
+ * and similarly handle protected symbols.
+ */
+ res = symlook_obj(&req1, refobj);
+ if (res == 0 && (refobj->symbolic ||
+ ELF_ST_VISIBILITY(req1.sym_out->st_other) == STV_PROTECTED)) {
+ req->sym_out = req1.sym_out;
+ req->defobj_out = req1.defobj_out;
+ assert(req->defobj_out != NULL);
}
+ if (refobj->symbolic || req->defobj_out != NULL)
+ donelist_check(&donelist, refobj);
symlook_global(req, &donelist);
diff --git a/sbin/fsck_ffs/fsck_ffs.8 b/sbin/fsck_ffs/fsck_ffs.8
index f11b5d4..ac14650 100644
--- a/sbin/fsck_ffs/fsck_ffs.8
+++ b/sbin/fsck_ffs/fsck_ffs.8
@@ -29,7 +29,7 @@
.\" @(#)fsck.8 8.4 (Berkeley) 5/9/95
.\" $FreeBSD$
.\"
-.Dd October 5, 2016
+.Dd February 14, 2017
.Dt FSCK_FFS 8
.Os
.Sh NAME
@@ -38,7 +38,7 @@
.Nd file system consistency check and interactive repair
.Sh SYNOPSIS
.Nm
-.Op Fl BEFfnpRryZ
+.Op Fl BCdEFfnpRrSyZ
.Op Fl b Ar block
.Op Fl c Ar level
.Op Fl m Ar mode
@@ -149,45 +149,6 @@ If unexpected errors are found,
the file system is marked as needing a foreground check and
.Nm
exits without attempting any further cleaning.
-.It Fl E
-Clear unallocated blocks, notifying the underlying device that they
-are not used and that their contents may be discarded.
-This is useful for filesystems which have been mounted on systems
-without TRIM support, or with TRIM support disabled, as well as
-filesystems which have been copied from one device to another.
-.Pp
-See the
-.Fl E
-and
-.Fl t
-flags of
-.Xr newfs 8 ,
-and
-the
-.Fl t
-flag of
-.Xr tunefs 8 .
-.It Fl F
-Determine whether the file system needs to be cleaned immediately
-in foreground, or if its cleaning can be deferred to background.
-To be eligible for background cleaning it must have been running
-with soft updates, not have been marked as needing a foreground check,
-and be mounted and writable when the background check is to be done.
-If these conditions are met, then
-.Nm
-exits with a zero exit status.
-Otherwise it exits with a non-zero exit status.
-If the file system is clean,
-it will exit with a non-zero exit status so that the clean status
-of the file system can be verified and reported during the foreground
-checks.
-Note that when invoked with the
-.Fl F
-flag, no cleanups are done.
-The only thing that
-.Nm
-does is to determine whether a foreground or background
-check is needed and exit with an appropriate status code.
.It Fl b
Use the block specified immediately after the flag as
the super block for the file system.
@@ -243,6 +204,47 @@ first line of output from
This option implies the
.Fl f
flag.
+.It Fl d
+Enable debugging messages.
+.It Fl E
+Clear unallocated blocks, notifying the underlying device that they
+are not used and that their contents may be discarded.
+This is useful for filesystems which have been mounted on systems
+without TRIM support, or with TRIM support disabled, as well as
+filesystems which have been copied from one device to another.
+.Pp
+See the
+.Fl E
+and
+.Fl t
+flags of
+.Xr newfs 8 ,
+and
+the
+.Fl t
+flag of
+.Xr tunefs 8 .
+.It Fl F
+Determine whether the file system needs to be cleaned immediately
+in foreground, or if its cleaning can be deferred to background.
+To be eligible for background cleaning it must have been running
+with soft updates, not have been marked as needing a foreground check,
+and be mounted and writable when the background check is to be done.
+If these conditions are met, then
+.Nm
+exits with a zero exit status.
+Otherwise it exits with a non-zero exit status.
+If the file system is clean,
+it will exit with a non-zero exit status so that the clean status
+of the file system can be verified and reported during the foreground
+checks.
+Note that when invoked with the
+.Fl F
+flag, no cleanups are done.
+The only thing that
+.Nm
+does is to determine whether a foreground or background
+check is needed and exit with an appropriate status code.
.It Fl f
Force
.Nm
diff --git a/sbin/fsck_ffs/main.c b/sbin/fsck_ffs/main.c
index 3fde2db..8f0e1db 100644
--- a/sbin/fsck_ffs/main.c
+++ b/sbin/fsck_ffs/main.c
@@ -670,7 +670,7 @@ static void
usage(void)
{
(void) fprintf(stderr,
-"usage: %s [-BEFfnpry] [-b block] [-c level] [-m mode] filesystem ...\n",
+"usage: %s [-BCdEFfnpRrSyZ] [-b block] [-c level] [-m mode] filesystem ...\n",
getprogname());
exit(1);
}
diff --git a/sbin/kldload/kldload.c b/sbin/kldload/kldload.c
index fd75647..cd31c52 100644
--- a/sbin/kldload/kldload.c
+++ b/sbin/kldload/kldload.c
@@ -41,9 +41,6 @@ __FBSDID("$FreeBSD$");
#define PATHCTL "kern.module_path"
-static int path_check(const char *, int);
-static void usage(void);
-
/*
* Check to see if the requested module is specified as a filename with no
* path. If so and if a file by the same name exists in the module path,
@@ -52,43 +49,37 @@ static void usage(void);
static int
path_check(const char *kldname, int quiet)
{
- int mib[5], found;
- size_t miblen, pathlen;
- char kldpath[MAXPATHLEN];
char *path, *tmppath, *element;
struct stat sb;
+ int mib[5];
+ char kldpath[MAXPATHLEN];
+ size_t miblen, pathlen;
dev_t dev;
ino_t ino;
+ int found;
- if (strchr(kldname, '/') != NULL) {
+ if (strchr(kldname, '/') != NULL)
return (0);
- }
- if (strstr(kldname, ".ko") == NULL) {
+ if (strstr(kldname, ".ko") == NULL)
return (0);
- }
- if (stat(kldname, &sb) != 0) {
+ if (stat(kldname, &sb) != 0)
return (0);
- }
found = 0;
dev = sb.st_dev;
ino = sb.st_ino;
miblen = nitems(mib);
- if (sysctlnametomib(PATHCTL, mib, &miblen) != 0) {
+ if (sysctlnametomib(PATHCTL, mib, &miblen) != 0)
err(1, "sysctlnametomib(%s)", PATHCTL);
- }
- if (sysctl(mib, miblen, NULL, &pathlen, NULL, 0) == -1) {
+ if (sysctl(mib, miblen, NULL, &pathlen, NULL, 0) == -1)
err(1, "getting path: sysctl(%s) - size only", PATHCTL);
- }
path = malloc(pathlen + 1);
- if (path == NULL) {
+ if (path == NULL)
err(1, "allocating %lu bytes for the path",
(unsigned long)pathlen + 1);
- }
- if (sysctl(mib, miblen, path, &pathlen, NULL, 0) == -1) {
+ if (sysctl(mib, miblen, path, &pathlen, NULL, 0) == -1)
err(1, "getting path: sysctl(%s)", PATHCTL);
- }
tmppath = path;
while ((element = strsep(&tmppath, ";")) != NULL) {
@@ -97,39 +88,36 @@ path_check(const char *kldname, int quiet)
strlcat(kldpath, "/", MAXPATHLEN);
}
strlcat(kldpath, kldname, MAXPATHLEN);
-
- if (stat(kldpath, &sb) == -1) {
+
+ if (stat(kldpath, &sb) == -1)
continue;
- }
found = 1;
if (sb.st_dev != dev || sb.st_ino != ino) {
- if (!quiet) {
+ if (!quiet)
warnx("%s will be loaded from %s, not the "
"current directory", kldname, element);
- }
break;
- } else if (sb.st_dev == dev && sb.st_ino == ino) {
+ } else if (sb.st_dev == dev && sb.st_ino == ino)
break;
- }
}
free(path);
-
+
if (!found) {
- if (!quiet) {
+ if (!quiet)
warnx("%s is not in the module path", kldname);
- }
return (-1);
}
-
+
return (0);
}
static void
usage(void)
{
+
fprintf(stderr, "usage: kldload [-nqv] file ...\n");
exit(1);
}
@@ -138,17 +126,17 @@ int
main(int argc, char** argv)
{
int c;
+ int check_loaded;
int errors;
int fileid;
- int verbose;
int quiet;
- int check_loaded;
+ int verbose;
errors = 0;
verbose = 0;
quiet = 0;
check_loaded = 0;
-
+
while ((c = getopt(argc, argv, "nqv")) != -1) {
switch (c) {
case 'q':
@@ -204,9 +192,8 @@ main(int argc, char** argv)
printf("Loaded %s, id=%d\n", argv[0],
fileid);
}
- } else {
+ } else
errors++;
- }
argv++;
}
diff --git a/sbin/resolvconf/Makefile b/sbin/resolvconf/Makefile
index 355d72f..db33656 100644
--- a/sbin/resolvconf/Makefile
+++ b/sbin/resolvconf/Makefile
@@ -20,9 +20,6 @@ SBINDIR= /sbin
# We don't assume to restart the services in /sbin. So, though
# our service(8) is in /usr/sbin, we can use it, here.
-CMD1_WITH_ARG= \1 onestatus >/dev/null 2>\&1
-CMD2_WITH_ARG= \1 restart
-RESTARTCMD_WITH_ARG= /usr/sbin/service ${CMD1_WITH_ARG} \&\& /usr/sbin/service ${CMD2_WITH_ARG}
CMD1= \\$$1 onestatus >/dev/null 2>\&1
CMD2= \\$$1 restart
RESTARTCMD= "/usr/sbin/service ${CMD1} \&\& /usr/sbin/service ${CMD2}"
@@ -32,7 +29,6 @@ ${f}: ${f}.in
sed -e 's:@SYSCONFDIR@:${SYSCONFDIR}:g' \
-e 's:@LIBEXECDIR@:${FILESDIR}:g' \
-e 's:@VARDIR@:${VARDIR}:g' \
- -e 's:@RESTARTCMD \(.*\)@:${RESTARTCMD_WITH_ARG}:g' \
-e 's:@RESTARTCMD@:${RESTARTCMD}:g' \
-e 's:@RCDIR@:${RCDIR}:g' \
-e 's:@SBINDIR@:${SBINDIR}:g' \
diff --git a/share/man/man4/alc.4 b/share/man/man4/alc.4
index 9a2c9f4..6398f79 100644
--- a/share/man/man4/alc.4
+++ b/share/man/man4/alc.4
@@ -124,6 +124,8 @@ Atheros AR8172 PCI Express Fast Ethernet controller
Killer E2200 Gigabit Ethernet controller
.It
Killer E2400 Gigabit Ethernet controller
+.It
+Killer E2500 Gigabit Ethernet controller
.El
.Sh LOADER TUNABLES
Tunables can be set at the
diff --git a/share/man/man4/unix.4 b/share/man/man4/unix.4
index 93cd399..86b291e 100644
--- a/share/man/man4/unix.4
+++ b/share/man/man4/unix.4
@@ -28,7 +28,7 @@
.\" @(#)unix.4 8.1 (Berkeley) 6/9/93
.\" $FreeBSD$
.\"
-.Dd March 19, 2013
+.Dd February 3, 2017
.Dt UNIX 4
.Os
.Sh NAME
@@ -119,12 +119,12 @@ of a
or
.Xr sendto 2
must be writable.
-.Sh PASSING FILE DESCRIPTORS
+.Sh CONTROL MESSAGES
The
.Ux Ns -domain
sockets support the communication of
.Ux
-file descriptors through the use of the
+file descriptors and process credentials through the use of the
.Va msg_control
field in the
.Fa msg
@@ -132,13 +132,12 @@ argument to
.Xr sendmsg 2
and
.Xr recvmsg 2 .
-.Pp
-Any valid descriptor may be sent in a message.
-The file descriptor(s) to be passed are described using a
+The items to be passed are described using a
.Vt "struct cmsghdr"
that is defined in the include file
.In sys/socket.h .
-The type of the message is
+.Pp
+To send file descriptors, the type of the message is
.Dv SCM_RIGHTS ,
and the data portion of the messages is an array of integers
representing the file descriptors to be passed.
@@ -161,6 +160,39 @@ call.
Descriptors that are awaiting delivery, or that are
purposely not received, are automatically closed by the system
when the destination socket is closed.
+.Pp
+Credentials of the sending process can be transmitted explicitly using a
+control message of type
+.Dv SCM_CREDS
+with a data portion of type
+.Vt "struct cmsgcred" ,
+defined in
+.In sys/socket.h
+as follows:
+.Bd -literal
+struct cmsgcred {
+ pid_t cmcred_pid; /* PID of sending process */
+ uid_t cmcred_uid; /* real UID of sending process */
+ uid_t cmcred_euid; /* effective UID of sending process */
+ gid_t cmcred_gid; /* real GID of sending process */
+ short cmcred_ngroups; /* number of groups */
+ gid_t cmcred_groups[CMGROUP_MAX]; /* groups */
+};
+.Ed
+.Pp
+The sender should pass a zeroed buffer which will be filled in by the system.
+.Pp
+The group list is truncated to at most
+.Dv CMGROUP_MAX
+GIDs.
+.Pp
+The process ID
+.Fa cmcred_pid
+should not be looked up (such as via the
+.Dv KERN_PROC_PID
+sysctl) for making security decisions.
+The sending process could have exited and its process ID already been
+reused for a new process.
.Sh SOCKET OPTIONS
.Tn UNIX
domain sockets support a number of socket options which can be set with
@@ -176,7 +208,13 @@ or a
.Dv SOCK_STREAM
socket.
This option provides a mechanism for the receiver to
-receive the credentials of the process as a
+receive the credentials of the process calling
+.Xr write 2 ,
+.Xr send 2 ,
+.Xr sendto 2
+or
+.Xr sendmsg 2
+as a
.Xr recvmsg 2
control message.
The
@@ -201,6 +239,10 @@ struct sockcred {
};
.Ed
.Pp
+The current implementation truncates the group list to at most
+.Dv CMGROUP_MAX
+groups.
+.Pp
The
.Fn SOCKCREDSIZE
macro computes the size of the
@@ -221,7 +263,28 @@ On
and
.Dv SOCK_SEQPACKET
sockets credentials are passed only on the first read from a socket,
-then system clears the option on socket.
+then the system clears the option on the socket.
+.Pp
+This option and the above explicit
+.Vt "struct cmsgcred"
+both use the same value
+.Dv SCM_CREDS
+but incompatible control messages.
+If this option is enabled and the sender attached a
+.Dv SCM_CREDS
+control message with a
+.Vt "struct cmsgcred" ,
+it will be discarded and a
+.Vt "struct sockcred"
+will be included.
+.Pp
+Many setuid programs will
+.Xr write 2
+data at least partially controlled by the invoker,
+such as error messages.
+Therefore, a message accompanied by a particular
+.Fa sc_euid
+value should not be trusted as being from that user.
.It Dv LOCAL_CONNWAIT
Used with
.Dv SOCK_STREAM
diff --git a/sys/amd64/linux/linux_dummy.c b/sys/amd64/linux/linux_dummy.c
index 7989b52..efe18fd 100644
--- a/sys/amd64/linux/linux_dummy.c
+++ b/sys/amd64/linux/linux_dummy.c
@@ -82,41 +82,86 @@ DUMMY(mq_timedreceive);
DUMMY(mq_notify);
DUMMY(mq_getsetattr);
DUMMY(kexec_load);
+/* linux 2.6.11: */
DUMMY(add_key);
DUMMY(request_key);
DUMMY(keyctl);
+/* linux 2.6.13: */
DUMMY(ioprio_set);
DUMMY(ioprio_get);
DUMMY(inotify_init);
DUMMY(inotify_add_watch);
DUMMY(inotify_rm_watch);
+/* linux 2.6.16: */
DUMMY(migrate_pages);
DUMMY(unshare);
+/* linux 2.6.17: */
DUMMY(splice);
DUMMY(tee);
DUMMY(sync_file_range);
DUMMY(vmsplice);
+/* linux 2.6.18: */
DUMMY(move_pages);
+/* linux 2.6.22: */
DUMMY(signalfd);
-DUMMY(timerfd);
+DUMMY(timerfd_create);
+/* linux 2.6.25: */
DUMMY(timerfd_settime);
DUMMY(timerfd_gettime);
+/* linux 2.6.27: */
DUMMY(signalfd4);
DUMMY(inotify_init1);
+/* linux 2.6.30: */
DUMMY(preadv);
DUMMY(pwritev);
-DUMMY(rt_tsigqueueinfo);
+/* linux 2.6.31: */
+DUMMY(rt_tgsigqueueinfo);
DUMMY(perf_event_open);
+/* linux 2.6.38: */
DUMMY(fanotify_init);
DUMMY(fanotify_mark);
+/* linux 2.6.39: */
DUMMY(name_to_handle_at);
DUMMY(open_by_handle_at);
DUMMY(clock_adjtime);
+/* linux 3.0: */
DUMMY(setns);
+DUMMY(getcpu);
+/* linux 3.2: */
DUMMY(process_vm_readv);
DUMMY(process_vm_writev);
+/* linux 3.5: */
DUMMY(kcmp);
+/* linux 3.8: */
DUMMY(finit_module);
+DUMMY(sched_setattr);
+DUMMY(sched_getattr);
+/* linux 3.14: */
+DUMMY(renameat2);
+/* linux 3.15: */
+DUMMY(seccomp);
+DUMMY(getrandom);
+DUMMY(memfd_create);
+DUMMY(kexec_file_load);
+/* linux 3.18: */
+DUMMY(bpf);
+/* linux 3.19: */
+DUMMY(execveat);
+/* linux 4.2: */
+DUMMY(userfaultfd);
+/* linux 4.3: */
+DUMMY(membarrier);
+/* linux 4.4: */
+DUMMY(mlock2);
+/* linux 4.5: */
+DUMMY(copy_file_range);
+/* linux 4.6: */
+DUMMY(preadv2);
+DUMMY(pwritev2);
+/* linux 4.8: */
+DUMMY(pkey_mprotect);
+DUMMY(pkey_alloc);
+DUMMY(pkey_free);
#define DUMMY_XATTR(s) \
int \
diff --git a/sys/amd64/linux/linux_proto.h b/sys/amd64/linux/linux_proto.h
index 9af30c8..a4cdb41 100644
--- a/sys/amd64/linux/linux_proto.h
+++ b/sys/amd64/linux/linux_proto.h
@@ -3,7 +3,7 @@
*
* DO NOT EDIT-- this file is automatically generated.
* $FreeBSD$
- * created from FreeBSD: head/sys/amd64/linux/syscalls.master 302515 2016-07-10 08:15:50Z dchagin
+ * created from FreeBSD: head/sys/amd64/linux/syscalls.master 313284 2017-02-05 14:17:09Z dchagin
*/
#ifndef _LINUX_SYSPROTO_H_
@@ -1000,7 +1000,7 @@ struct linux_epoll_pwait_args {
struct linux_signalfd_args {
register_t dummy;
};
-struct linux_timerfd_args {
+struct linux_timerfd_create_args {
register_t dummy;
};
struct linux_eventfd_args {
@@ -1044,16 +1044,27 @@ struct linux_pipe2_args {
char flags_l_[PADL_(l_int)]; l_int flags; char flags_r_[PADR_(l_int)];
};
struct linux_inotify_init1_args {
- register_t dummy;
+ char flags_l_[PADL_(l_int)]; l_int flags; char flags_r_[PADR_(l_int)];
};
struct linux_preadv_args {
- register_t dummy;
+ char fd_l_[PADL_(l_ulong)]; l_ulong fd; char fd_r_[PADR_(l_ulong)];
+ char vec_l_[PADL_(struct iovec *)]; struct iovec * vec; char vec_r_[PADR_(struct iovec *)];
+ char vlen_l_[PADL_(l_ulong)]; l_ulong vlen; char vlen_r_[PADR_(l_ulong)];
+ char pos_l_l_[PADL_(l_ulong)]; l_ulong pos_l; char pos_l_r_[PADR_(l_ulong)];
+ char pos_h_l_[PADL_(l_ulong)]; l_ulong pos_h; char pos_h_r_[PADR_(l_ulong)];
};
struct linux_pwritev_args {
- register_t dummy;
-};
-struct linux_rt_tsigqueueinfo_args {
- register_t dummy;
+ char fd_l_[PADL_(l_ulong)]; l_ulong fd; char fd_r_[PADR_(l_ulong)];
+ char vec_l_[PADL_(struct iovec *)]; struct iovec * vec; char vec_r_[PADR_(struct iovec *)];
+ char vlen_l_[PADL_(l_ulong)]; l_ulong vlen; char vlen_r_[PADR_(l_ulong)];
+ char pos_l_l_[PADL_(l_ulong)]; l_ulong pos_l; char pos_l_r_[PADR_(l_ulong)];
+ char pos_h_l_[PADL_(l_ulong)]; l_ulong pos_h; char pos_h_r_[PADR_(l_ulong)];
+};
+struct linux_rt_tgsigqueueinfo_args {
+ char tgid_l_[PADL_(l_pid_t)]; l_pid_t tgid; char tgid_r_[PADR_(l_pid_t)];
+ char tid_l_[PADL_(l_pid_t)]; l_pid_t tid; char tid_r_[PADR_(l_pid_t)];
+ char sig_l_[PADL_(l_int)]; l_int sig; char sig_r_[PADR_(l_int)];
+ char uinfo_l_[PADL_(l_siginfo_t *)]; l_siginfo_t * uinfo; char uinfo_r_[PADR_(l_siginfo_t *)];
};
struct linux_perf_event_open_args {
register_t dummy;
@@ -1096,19 +1107,141 @@ struct linux_sendmmsg_args {
char flags_l_[PADL_(l_uint)]; l_uint flags; char flags_r_[PADR_(l_uint)];
};
struct linux_setns_args {
- register_t dummy;
+ char fd_l_[PADL_(l_int)]; l_int fd; char fd_r_[PADR_(l_int)];
+ char nstype_l_[PADL_(l_int)]; l_int nstype; char nstype_r_[PADR_(l_int)];
+};
+struct linux_getcpu_args {
+ char cpu_l_[PADL_(l_uint *)]; l_uint * cpu; char cpu_r_[PADR_(l_uint *)];
+ char node_l_[PADL_(l_uint *)]; l_uint * node; char node_r_[PADR_(l_uint *)];
+ char cache_l_[PADL_(void *)]; void * cache; char cache_r_[PADR_(void *)];
};
struct linux_process_vm_readv_args {
- register_t dummy;
+ char pid_l_[PADL_(l_pid_t)]; l_pid_t pid; char pid_r_[PADR_(l_pid_t)];
+ char lvec_l_[PADL_(const struct iovec *)]; const struct iovec * lvec; char lvec_r_[PADR_(const struct iovec *)];
+ char liovcnt_l_[PADL_(l_ulong)]; l_ulong liovcnt; char liovcnt_r_[PADR_(l_ulong)];
+ char rvec_l_[PADL_(const struct iovec *)]; const struct iovec * rvec; char rvec_r_[PADR_(const struct iovec *)];
+ char riovcnt_l_[PADL_(l_ulong)]; l_ulong riovcnt; char riovcnt_r_[PADR_(l_ulong)];
+ char flags_l_[PADL_(l_ulong)]; l_ulong flags; char flags_r_[PADR_(l_ulong)];
};
struct linux_process_vm_writev_args {
- register_t dummy;
+ char pid_l_[PADL_(l_pid_t)]; l_pid_t pid; char pid_r_[PADR_(l_pid_t)];
+ char lvec_l_[PADL_(const struct iovec *)]; const struct iovec * lvec; char lvec_r_[PADR_(const struct iovec *)];
+ char liovcnt_l_[PADL_(l_ulong)]; l_ulong liovcnt; char liovcnt_r_[PADR_(l_ulong)];
+ char rvec_l_[PADL_(const struct iovec *)]; const struct iovec * rvec; char rvec_r_[PADR_(const struct iovec *)];
+ char riovcnt_l_[PADL_(l_ulong)]; l_ulong riovcnt; char riovcnt_r_[PADR_(l_ulong)];
+ char flags_l_[PADL_(l_ulong)]; l_ulong flags; char flags_r_[PADR_(l_ulong)];
};
struct linux_kcmp_args {
- register_t dummy;
+ char pid1_l_[PADL_(l_pid_t)]; l_pid_t pid1; char pid1_r_[PADR_(l_pid_t)];
+ char pid2_l_[PADL_(l_pid_t)]; l_pid_t pid2; char pid2_r_[PADR_(l_pid_t)];
+ char type_l_[PADL_(l_int)]; l_int type; char type_r_[PADR_(l_int)];
+ char idx1_l_[PADL_(l_ulong)]; l_ulong idx1; char idx1_r_[PADR_(l_ulong)];
+ char idx_l_[PADL_(l_ulong)]; l_ulong idx; char idx_r_[PADR_(l_ulong)];
};
struct linux_finit_module_args {
- register_t dummy;
+ char fd_l_[PADL_(l_int)]; l_int fd; char fd_r_[PADR_(l_int)];
+ char uargs_l_[PADL_(const char *)]; const char * uargs; char uargs_r_[PADR_(const char *)];
+ char flags_l_[PADL_(l_int)]; l_int flags; char flags_r_[PADR_(l_int)];
+};
+struct linux_sched_setattr_args {
+ char pid_l_[PADL_(l_pid_t)]; l_pid_t pid; char pid_r_[PADR_(l_pid_t)];
+ char attr_l_[PADL_(void *)]; void * attr; char attr_r_[PADR_(void *)];
+ char flags_l_[PADL_(l_uint)]; l_uint flags; char flags_r_[PADR_(l_uint)];
+};
+struct linux_sched_getattr_args {
+ char pid_l_[PADL_(l_pid_t)]; l_pid_t pid; char pid_r_[PADR_(l_pid_t)];
+ char attr_l_[PADL_(void *)]; void * attr; char attr_r_[PADR_(void *)];
+ char size_l_[PADL_(l_uint)]; l_uint size; char size_r_[PADR_(l_uint)];
+ char flags_l_[PADL_(l_uint)]; l_uint flags; char flags_r_[PADR_(l_uint)];
+};
+struct linux_renameat2_args {
+ char oldfd_l_[PADL_(l_int)]; l_int oldfd; char oldfd_r_[PADR_(l_int)];
+ char oldname_l_[PADL_(const char *)]; const char * oldname; char oldname_r_[PADR_(const char *)];
+ char newfd_l_[PADL_(l_int)]; l_int newfd; char newfd_r_[PADR_(l_int)];
+ char newname_l_[PADL_(const char *)]; const char * newname; char newname_r_[PADR_(const char *)];
+ char flags_l_[PADL_(unsigned int)]; unsigned int flags; char flags_r_[PADR_(unsigned int)];
+};
+struct linux_seccomp_args {
+ char op_l_[PADL_(l_uint)]; l_uint op; char op_r_[PADR_(l_uint)];
+ char flags_l_[PADL_(l_uint)]; l_uint flags; char flags_r_[PADR_(l_uint)];
+ char uargs_l_[PADL_(const char *)]; const char * uargs; char uargs_r_[PADR_(const char *)];
+};
+struct linux_getrandom_args {
+ char buf_l_[PADL_(char *)]; char * buf; char buf_r_[PADR_(char *)];
+ char count_l_[PADL_(l_size_t)]; l_size_t count; char count_r_[PADR_(l_size_t)];
+ char flags_l_[PADL_(l_uint)]; l_uint flags; char flags_r_[PADR_(l_uint)];
+};
+struct linux_memfd_create_args {
+ char uname_ptr_l_[PADL_(const char *)]; const char * uname_ptr; char uname_ptr_r_[PADR_(const char *)];
+ char flags_l_[PADL_(l_uint)]; l_uint flags; char flags_r_[PADR_(l_uint)];
+};
+struct linux_kexec_file_load_args {
+ char kernel_fd_l_[PADL_(l_int)]; l_int kernel_fd; char kernel_fd_r_[PADR_(l_int)];
+ char initrd_fd_l_[PADL_(l_int)]; l_int initrd_fd; char initrd_fd_r_[PADR_(l_int)];
+ char cmdline_len_l_[PADL_(l_ulong)]; l_ulong cmdline_len; char cmdline_len_r_[PADR_(l_ulong)];
+ char cmdline_ptr_l_[PADL_(const char *)]; const char * cmdline_ptr; char cmdline_ptr_r_[PADR_(const char *)];
+ char flags_l_[PADL_(l_ulong)]; l_ulong flags; char flags_r_[PADR_(l_ulong)];
+};
+struct linux_bpf_args {
+ char cmd_l_[PADL_(l_int)]; l_int cmd; char cmd_r_[PADR_(l_int)];
+ char attr_l_[PADL_(void *)]; void * attr; char attr_r_[PADR_(void *)];
+ char size_l_[PADL_(l_uint)]; l_uint size; char size_r_[PADR_(l_uint)];
+};
+struct linux_execveat_args {
+ char dfd_l_[PADL_(l_int)]; l_int dfd; char dfd_r_[PADR_(l_int)];
+ char filename_l_[PADL_(const char *)]; const char * filename; char filename_r_[PADR_(const char *)];
+ char argv_l_[PADL_(const char **)]; const char ** argv; char argv_r_[PADR_(const char **)];
+ char envp_l_[PADL_(const char **)]; const char ** envp; char envp_r_[PADR_(const char **)];
+ char flags_l_[PADL_(l_int)]; l_int flags; char flags_r_[PADR_(l_int)];
+};
+struct linux_userfaultfd_args {
+ char flags_l_[PADL_(l_int)]; l_int flags; char flags_r_[PADR_(l_int)];
+};
+struct linux_membarrier_args {
+ char cmd_l_[PADL_(l_int)]; l_int cmd; char cmd_r_[PADR_(l_int)];
+ char flags_l_[PADL_(l_int)]; l_int flags; char flags_r_[PADR_(l_int)];
+};
+struct linux_mlock2_args {
+ char start_l_[PADL_(l_ulong)]; l_ulong start; char start_r_[PADR_(l_ulong)];
+ char len_l_[PADL_(l_size_t)]; l_size_t len; char len_r_[PADR_(l_size_t)];
+ char flags_l_[PADL_(l_int)]; l_int flags; char flags_r_[PADR_(l_int)];
+};
+struct linux_copy_file_range_args {
+ char fd_in_l_[PADL_(l_int)]; l_int fd_in; char fd_in_r_[PADR_(l_int)];
+ char off_in_l_[PADL_(l_loff_t *)]; l_loff_t * off_in; char off_in_r_[PADR_(l_loff_t *)];
+ char fd_out_l_[PADL_(l_int)]; l_int fd_out; char fd_out_r_[PADR_(l_int)];
+ char off_out_l_[PADL_(l_loff_t *)]; l_loff_t * off_out; char off_out_r_[PADR_(l_loff_t *)];
+ char len_l_[PADL_(l_size_t)]; l_size_t len; char len_r_[PADR_(l_size_t)];
+ char flags_l_[PADL_(l_uint)]; l_uint flags; char flags_r_[PADR_(l_uint)];
+};
+struct linux_preadv2_args {
+ char fd_l_[PADL_(l_ulong)]; l_ulong fd; char fd_r_[PADR_(l_ulong)];
+ char vec_l_[PADL_(const struct iovec *)]; const struct iovec * vec; char vec_r_[PADR_(const struct iovec *)];
+ char vlen_l_[PADL_(l_ulong)]; l_ulong vlen; char vlen_r_[PADR_(l_ulong)];
+ char pos_l_l_[PADL_(l_ulong)]; l_ulong pos_l; char pos_l_r_[PADR_(l_ulong)];
+ char pos_h_l_[PADL_(l_ulong)]; l_ulong pos_h; char pos_h_r_[PADR_(l_ulong)];
+ char flags_l_[PADL_(l_int)]; l_int flags; char flags_r_[PADR_(l_int)];
+};
+struct linux_pwritev2_args {
+ char fd_l_[PADL_(l_ulong)]; l_ulong fd; char fd_r_[PADR_(l_ulong)];
+ char vec_l_[PADL_(const struct iovec *)]; const struct iovec * vec; char vec_r_[PADR_(const struct iovec *)];
+ char vlen_l_[PADL_(l_ulong)]; l_ulong vlen; char vlen_r_[PADR_(l_ulong)];
+ char pos_l_l_[PADL_(l_ulong)]; l_ulong pos_l; char pos_l_r_[PADR_(l_ulong)];
+ char pos_h_l_[PADL_(l_ulong)]; l_ulong pos_h; char pos_h_r_[PADR_(l_ulong)];
+ char flags_l_[PADL_(l_int)]; l_int flags; char flags_r_[PADR_(l_int)];
+};
+struct linux_pkey_mprotect_args {
+ char start_l_[PADL_(l_ulong)]; l_ulong start; char start_r_[PADR_(l_ulong)];
+ char len_l_[PADL_(l_size_t)]; l_size_t len; char len_r_[PADR_(l_size_t)];
+ char prot_l_[PADL_(l_ulong)]; l_ulong prot; char prot_r_[PADR_(l_ulong)];
+ char pkey_l_[PADL_(l_int)]; l_int pkey; char pkey_r_[PADR_(l_int)];
+};
+struct linux_pkey_alloc_args {
+ char flags_l_[PADL_(l_ulong)]; l_ulong flags; char flags_r_[PADR_(l_ulong)];
+ char init_val_l_[PADL_(l_ulong)]; l_ulong init_val; char init_val_r_[PADR_(l_ulong)];
+};
+struct linux_pkey_free_args {
+ char pkey_l_[PADL_(l_int)]; l_int pkey; char pkey_r_[PADR_(l_int)];
};
#define nosys linux_nosys
int linux_open(struct thread *, struct linux_open_args *);
@@ -1339,7 +1472,7 @@ int linux_move_pages(struct thread *, struct linux_move_pages_args *);
int linux_utimensat(struct thread *, struct linux_utimensat_args *);
int linux_epoll_pwait(struct thread *, struct linux_epoll_pwait_args *);
int linux_signalfd(struct thread *, struct linux_signalfd_args *);
-int linux_timerfd(struct thread *, struct linux_timerfd_args *);
+int linux_timerfd_create(struct thread *, struct linux_timerfd_create_args *);
int linux_eventfd(struct thread *, struct linux_eventfd_args *);
int linux_fallocate(struct thread *, struct linux_fallocate_args *);
int linux_timerfd_settime(struct thread *, struct linux_timerfd_settime_args *);
@@ -1353,7 +1486,7 @@ int linux_pipe2(struct thread *, struct linux_pipe2_args *);
int linux_inotify_init1(struct thread *, struct linux_inotify_init1_args *);
int linux_preadv(struct thread *, struct linux_preadv_args *);
int linux_pwritev(struct thread *, struct linux_pwritev_args *);
-int linux_rt_tsigqueueinfo(struct thread *, struct linux_rt_tsigqueueinfo_args *);
+int linux_rt_tgsigqueueinfo(struct thread *, struct linux_rt_tgsigqueueinfo_args *);
int linux_perf_event_open(struct thread *, struct linux_perf_event_open_args *);
int linux_recvmmsg(struct thread *, struct linux_recvmmsg_args *);
int linux_fanotify_init(struct thread *, struct linux_fanotify_init_args *);
@@ -1365,10 +1498,29 @@ int linux_clock_adjtime(struct thread *, struct linux_clock_adjtime_args *);
int linux_syncfs(struct thread *, struct linux_syncfs_args *);
int linux_sendmmsg(struct thread *, struct linux_sendmmsg_args *);
int linux_setns(struct thread *, struct linux_setns_args *);
+int linux_getcpu(struct thread *, struct linux_getcpu_args *);
int linux_process_vm_readv(struct thread *, struct linux_process_vm_readv_args *);
int linux_process_vm_writev(struct thread *, struct linux_process_vm_writev_args *);
int linux_kcmp(struct thread *, struct linux_kcmp_args *);
int linux_finit_module(struct thread *, struct linux_finit_module_args *);
+int linux_sched_setattr(struct thread *, struct linux_sched_setattr_args *);
+int linux_sched_getattr(struct thread *, struct linux_sched_getattr_args *);
+int linux_renameat2(struct thread *, struct linux_renameat2_args *);
+int linux_seccomp(struct thread *, struct linux_seccomp_args *);
+int linux_getrandom(struct thread *, struct linux_getrandom_args *);
+int linux_memfd_create(struct thread *, struct linux_memfd_create_args *);
+int linux_kexec_file_load(struct thread *, struct linux_kexec_file_load_args *);
+int linux_bpf(struct thread *, struct linux_bpf_args *);
+int linux_execveat(struct thread *, struct linux_execveat_args *);
+int linux_userfaultfd(struct thread *, struct linux_userfaultfd_args *);
+int linux_membarrier(struct thread *, struct linux_membarrier_args *);
+int linux_mlock2(struct thread *, struct linux_mlock2_args *);
+int linux_copy_file_range(struct thread *, struct linux_copy_file_range_args *);
+int linux_preadv2(struct thread *, struct linux_preadv2_args *);
+int linux_pwritev2(struct thread *, struct linux_pwritev2_args *);
+int linux_pkey_mprotect(struct thread *, struct linux_pkey_mprotect_args *);
+int linux_pkey_alloc(struct thread *, struct linux_pkey_alloc_args *);
+int linux_pkey_free(struct thread *, struct linux_pkey_free_args *);
#ifdef COMPAT_43
@@ -1632,7 +1784,7 @@ int linux_finit_module(struct thread *, struct linux_finit_module_args *);
#define LINUX_SYS_AUE_linux_utimensat AUE_FUTIMESAT
#define LINUX_SYS_AUE_linux_epoll_pwait AUE_NULL
#define LINUX_SYS_AUE_linux_signalfd AUE_NULL
-#define LINUX_SYS_AUE_linux_timerfd AUE_NULL
+#define LINUX_SYS_AUE_linux_timerfd_create AUE_NULL
#define LINUX_SYS_AUE_linux_eventfd AUE_NULL
#define LINUX_SYS_AUE_linux_fallocate AUE_NULL
#define LINUX_SYS_AUE_linux_timerfd_settime AUE_NULL
@@ -1646,7 +1798,7 @@ int linux_finit_module(struct thread *, struct linux_finit_module_args *);
#define LINUX_SYS_AUE_linux_inotify_init1 AUE_NULL
#define LINUX_SYS_AUE_linux_preadv AUE_NULL
#define LINUX_SYS_AUE_linux_pwritev AUE_NULL
-#define LINUX_SYS_AUE_linux_rt_tsigqueueinfo AUE_NULL
+#define LINUX_SYS_AUE_linux_rt_tgsigqueueinfo AUE_NULL
#define LINUX_SYS_AUE_linux_perf_event_open AUE_NULL
#define LINUX_SYS_AUE_linux_recvmmsg AUE_NULL
#define LINUX_SYS_AUE_linux_fanotify_init AUE_NULL
@@ -1658,10 +1810,29 @@ int linux_finit_module(struct thread *, struct linux_finit_module_args *);
#define LINUX_SYS_AUE_linux_syncfs AUE_SYNC
#define LINUX_SYS_AUE_linux_sendmmsg AUE_NULL
#define LINUX_SYS_AUE_linux_setns AUE_NULL
+#define LINUX_SYS_AUE_linux_getcpu AUE_NULL
#define LINUX_SYS_AUE_linux_process_vm_readv AUE_NULL
#define LINUX_SYS_AUE_linux_process_vm_writev AUE_NULL
#define LINUX_SYS_AUE_linux_kcmp AUE_NULL
#define LINUX_SYS_AUE_linux_finit_module AUE_NULL
+#define LINUX_SYS_AUE_linux_sched_setattr AUE_NULL
+#define LINUX_SYS_AUE_linux_sched_getattr AUE_NULL
+#define LINUX_SYS_AUE_linux_renameat2 AUE_NULL
+#define LINUX_SYS_AUE_linux_seccomp AUE_NULL
+#define LINUX_SYS_AUE_linux_getrandom AUE_NULL
+#define LINUX_SYS_AUE_linux_memfd_create AUE_NULL
+#define LINUX_SYS_AUE_linux_kexec_file_load AUE_NULL
+#define LINUX_SYS_AUE_linux_bpf AUE_NULL
+#define LINUX_SYS_AUE_linux_execveat AUE_NULL
+#define LINUX_SYS_AUE_linux_userfaultfd AUE_NULL
+#define LINUX_SYS_AUE_linux_membarrier AUE_NULL
+#define LINUX_SYS_AUE_linux_mlock2 AUE_NULL
+#define LINUX_SYS_AUE_linux_copy_file_range AUE_NULL
+#define LINUX_SYS_AUE_linux_preadv2 AUE_NULL
+#define LINUX_SYS_AUE_linux_pwritev2 AUE_NULL
+#define LINUX_SYS_AUE_linux_pkey_mprotect AUE_NULL
+#define LINUX_SYS_AUE_linux_pkey_alloc AUE_NULL
+#define LINUX_SYS_AUE_linux_pkey_free AUE_NULL
#undef PAD_
#undef PADL_
diff --git a/sys/amd64/linux/linux_syscall.h b/sys/amd64/linux/linux_syscall.h
index 28cbf8b..05af0ac 100644
--- a/sys/amd64/linux/linux_syscall.h
+++ b/sys/amd64/linux/linux_syscall.h
@@ -3,7 +3,7 @@
*
* DO NOT EDIT-- this file is automatically generated.
* $FreeBSD$
- * created from FreeBSD: head/sys/amd64/linux/syscalls.master 302515 2016-07-10 08:15:50Z dchagin
+ * created from FreeBSD: head/sys/amd64/linux/syscalls.master 313284 2017-02-05 14:17:09Z dchagin
*/
#define LINUX_SYS_read 0
@@ -277,7 +277,7 @@
#define LINUX_SYS_linux_utimensat 280
#define LINUX_SYS_linux_epoll_pwait 281
#define LINUX_SYS_linux_signalfd 282
-#define LINUX_SYS_linux_timerfd 283
+#define LINUX_SYS_linux_timerfd_create 283
#define LINUX_SYS_linux_eventfd 284
#define LINUX_SYS_linux_fallocate 285
#define LINUX_SYS_linux_timerfd_settime 286
@@ -291,7 +291,7 @@
#define LINUX_SYS_linux_inotify_init1 294
#define LINUX_SYS_linux_preadv 295
#define LINUX_SYS_linux_pwritev 296
-#define LINUX_SYS_linux_rt_tsigqueueinfo 297
+#define LINUX_SYS_linux_rt_tgsigqueueinfo 297
#define LINUX_SYS_linux_perf_event_open 298
#define LINUX_SYS_linux_recvmmsg 299
#define LINUX_SYS_linux_fanotify_init 300
@@ -303,8 +303,27 @@
#define LINUX_SYS_linux_syncfs 306
#define LINUX_SYS_linux_sendmmsg 307
#define LINUX_SYS_linux_setns 308
-#define LINUX_SYS_linux_process_vm_readv 309
-#define LINUX_SYS_linux_process_vm_writev 310
-#define LINUX_SYS_linux_kcmp 311
-#define LINUX_SYS_linux_finit_module 312
-#define LINUX_SYS_MAXSYSCALL 314
+#define LINUX_SYS_linux_getcpu 309
+#define LINUX_SYS_linux_process_vm_readv 310
+#define LINUX_SYS_linux_process_vm_writev 311
+#define LINUX_SYS_linux_kcmp 312
+#define LINUX_SYS_linux_finit_module 313
+#define LINUX_SYS_linux_sched_setattr 314
+#define LINUX_SYS_linux_sched_getattr 315
+#define LINUX_SYS_linux_renameat2 316
+#define LINUX_SYS_linux_seccomp 317
+#define LINUX_SYS_linux_getrandom 318
+#define LINUX_SYS_linux_memfd_create 319
+#define LINUX_SYS_linux_kexec_file_load 320
+#define LINUX_SYS_linux_bpf 321
+#define LINUX_SYS_linux_execveat 322
+#define LINUX_SYS_linux_userfaultfd 323
+#define LINUX_SYS_linux_membarrier 324
+#define LINUX_SYS_linux_mlock2 325
+#define LINUX_SYS_linux_copy_file_range 326
+#define LINUX_SYS_linux_preadv2 327
+#define LINUX_SYS_linux_pwritev2 328
+#define LINUX_SYS_linux_pkey_mprotect 329
+#define LINUX_SYS_linux_pkey_alloc 330
+#define LINUX_SYS_linux_pkey_free 331
+#define LINUX_SYS_MAXSYSCALL 333
diff --git a/sys/amd64/linux/linux_syscalls.c b/sys/amd64/linux/linux_syscalls.c
index ccada20..4158729 100644
--- a/sys/amd64/linux/linux_syscalls.c
+++ b/sys/amd64/linux/linux_syscalls.c
@@ -3,7 +3,7 @@
*
* DO NOT EDIT-- this file is automatically generated.
* $FreeBSD$
- * created from FreeBSD: head/sys/amd64/linux/syscalls.master 302515 2016-07-10 08:15:50Z dchagin
+ * created from FreeBSD: head/sys/amd64/linux/syscalls.master 313284 2017-02-05 14:17:09Z dchagin
*/
const char *linux_syscallnames[] = {
@@ -217,7 +217,7 @@ const char *linux_syscallnames[] = {
"#206", /* 206 = linux_io_setup */
"#207", /* 207 = linux_io_destroy */
"#208", /* 208 = linux_io_getevents */
- "#209", /* 209 = inux_io_submit */
+ "#209", /* 209 = linux_io_submit */
"#210", /* 210 = linux_io_cancel */
"#211", /* 211 = linux_get_thread_area */
"linux_lookup_dcookie", /* 212 = linux_lookup_dcookie */
@@ -291,7 +291,7 @@ const char *linux_syscallnames[] = {
"linux_utimensat", /* 280 = linux_utimensat */
"linux_epoll_pwait", /* 281 = linux_epoll_pwait */
"linux_signalfd", /* 282 = linux_signalfd */
- "linux_timerfd", /* 283 = linux_timerfd */
+ "linux_timerfd_create", /* 283 = linux_timerfd_create */
"linux_eventfd", /* 284 = linux_eventfd */
"linux_fallocate", /* 285 = linux_fallocate */
"linux_timerfd_settime", /* 286 = linux_timerfd_settime */
@@ -305,7 +305,7 @@ const char *linux_syscallnames[] = {
"linux_inotify_init1", /* 294 = linux_inotify_init1 */
"linux_preadv", /* 295 = linux_preadv */
"linux_pwritev", /* 296 = linux_pwritev */
- "linux_rt_tsigqueueinfo", /* 297 = linux_rt_tsigqueueinfo */
+ "linux_rt_tgsigqueueinfo", /* 297 = linux_rt_tgsigqueueinfo */
"linux_perf_event_open", /* 298 = linux_perf_event_open */
"linux_recvmmsg", /* 299 = linux_recvmmsg */
"linux_fanotify_init", /* 300 = linux_fanotify_init */
@@ -317,9 +317,28 @@ const char *linux_syscallnames[] = {
"linux_syncfs", /* 306 = linux_syncfs */
"linux_sendmmsg", /* 307 = linux_sendmmsg */
"linux_setns", /* 308 = linux_setns */
- "linux_process_vm_readv", /* 309 = linux_process_vm_readv */
- "linux_process_vm_writev", /* 310 = linux_process_vm_writev */
- "linux_kcmp", /* 311 = linux_kcmp */
- "linux_finit_module", /* 312 = linux_finit_module */
- "#313", /* 313 = nosys */
+ "linux_getcpu", /* 309 = linux_getcpu */
+ "linux_process_vm_readv", /* 310 = linux_process_vm_readv */
+ "linux_process_vm_writev", /* 311 = linux_process_vm_writev */
+ "linux_kcmp", /* 312 = linux_kcmp */
+ "linux_finit_module", /* 313 = linux_finit_module */
+ "linux_sched_setattr", /* 314 = linux_sched_setattr */
+ "linux_sched_getattr", /* 315 = linux_sched_getattr */
+ "linux_renameat2", /* 316 = linux_renameat2 */
+ "linux_seccomp", /* 317 = linux_seccomp */
+ "linux_getrandom", /* 318 = linux_getrandom */
+ "linux_memfd_create", /* 319 = linux_memfd_create */
+ "linux_kexec_file_load", /* 320 = linux_kexec_file_load */
+ "linux_bpf", /* 321 = linux_bpf */
+ "linux_execveat", /* 322 = linux_execveat */
+ "linux_userfaultfd", /* 323 = linux_userfaultfd */
+ "linux_membarrier", /* 324 = linux_membarrier */
+ "linux_mlock2", /* 325 = linux_mlock2 */
+ "linux_copy_file_range", /* 326 = linux_copy_file_range */
+ "linux_preadv2", /* 327 = linux_preadv2 */
+ "linux_pwritev2", /* 328 = linux_pwritev2 */
+ "linux_pkey_mprotect", /* 329 = linux_pkey_mprotect */
+ "linux_pkey_alloc", /* 330 = linux_pkey_alloc */
+ "linux_pkey_free", /* 331 = linux_pkey_free */
+ "#332", /* 332 = nosys */
};
diff --git a/sys/amd64/linux/linux_sysent.c b/sys/amd64/linux/linux_sysent.c
index edf4fe6..f52fd83 100644
--- a/sys/amd64/linux/linux_sysent.c
+++ b/sys/amd64/linux/linux_sysent.c
@@ -3,7 +3,7 @@
*
* DO NOT EDIT-- this file is automatically generated.
* $FreeBSD$
- * created from FreeBSD: head/sys/amd64/linux/syscalls.master 302515 2016-07-10 08:15:50Z dchagin
+ * created from FreeBSD: head/sys/amd64/linux/syscalls.master 313284 2017-02-05 14:17:09Z dchagin
*/
#include <sys/param.h>
@@ -227,7 +227,7 @@ struct sysent linux_sysent[] = {
{ 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 206 = linux_io_setup */
{ 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 207 = linux_io_destroy */
{ 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 208 = linux_io_getevents */
- { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 209 = inux_io_submit */
+ { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 209 = linux_io_submit */
{ 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 210 = linux_io_cancel */
{ 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 211 = linux_get_thread_area */
{ 0, (sy_call_t *)linux_lookup_dcookie, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 212 = linux_lookup_dcookie */
@@ -301,7 +301,7 @@ struct sysent linux_sysent[] = {
{ AS(linux_utimensat_args), (sy_call_t *)linux_utimensat, AUE_FUTIMESAT, NULL, 0, 0, 0, SY_THR_STATIC }, /* 280 = linux_utimensat */
{ AS(linux_epoll_pwait_args), (sy_call_t *)linux_epoll_pwait, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 281 = linux_epoll_pwait */
{ 0, (sy_call_t *)linux_signalfd, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 282 = linux_signalfd */
- { 0, (sy_call_t *)linux_timerfd, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 283 = linux_timerfd */
+ { 0, (sy_call_t *)linux_timerfd_create, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 283 = linux_timerfd_create */
{ AS(linux_eventfd_args), (sy_call_t *)linux_eventfd, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 284 = linux_eventfd */
{ AS(linux_fallocate_args), (sy_call_t *)linux_fallocate, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 285 = linux_fallocate */
{ 0, (sy_call_t *)linux_timerfd_settime, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 286 = linux_timerfd_settime */
@@ -312,10 +312,10 @@ struct sysent linux_sysent[] = {
{ AS(linux_epoll_create1_args), (sy_call_t *)linux_epoll_create1, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 291 = linux_epoll_create1 */
{ AS(linux_dup3_args), (sy_call_t *)linux_dup3, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 292 = linux_dup3 */
{ AS(linux_pipe2_args), (sy_call_t *)linux_pipe2, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 293 = linux_pipe2 */
- { 0, (sy_call_t *)linux_inotify_init1, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 294 = linux_inotify_init1 */
- { 0, (sy_call_t *)linux_preadv, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 295 = linux_preadv */
- { 0, (sy_call_t *)linux_pwritev, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 296 = linux_pwritev */
- { 0, (sy_call_t *)linux_rt_tsigqueueinfo, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 297 = linux_rt_tsigqueueinfo */
+ { AS(linux_inotify_init1_args), (sy_call_t *)linux_inotify_init1, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 294 = linux_inotify_init1 */
+ { AS(linux_preadv_args), (sy_call_t *)linux_preadv, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 295 = linux_preadv */
+ { AS(linux_pwritev_args), (sy_call_t *)linux_pwritev, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 296 = linux_pwritev */
+ { AS(linux_rt_tgsigqueueinfo_args), (sy_call_t *)linux_rt_tgsigqueueinfo, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 297 = linux_rt_tgsigqueueinfo */
{ 0, (sy_call_t *)linux_perf_event_open, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 298 = linux_perf_event_open */
{ AS(linux_recvmmsg_args), (sy_call_t *)linux_recvmmsg, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 299 = linux_recvmmsg */
{ 0, (sy_call_t *)linux_fanotify_init, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 300 = linux_fanotify_init */
@@ -326,10 +326,29 @@ struct sysent linux_sysent[] = {
{ 0, (sy_call_t *)linux_clock_adjtime, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 305 = linux_clock_adjtime */
{ AS(linux_syncfs_args), (sy_call_t *)linux_syncfs, AUE_SYNC, NULL, 0, 0, 0, SY_THR_STATIC }, /* 306 = linux_syncfs */
{ AS(linux_sendmmsg_args), (sy_call_t *)linux_sendmmsg, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 307 = linux_sendmmsg */
- { 0, (sy_call_t *)linux_setns, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 308 = linux_setns */
- { 0, (sy_call_t *)linux_process_vm_readv, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 309 = linux_process_vm_readv */
- { 0, (sy_call_t *)linux_process_vm_writev, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 310 = linux_process_vm_writev */
- { 0, (sy_call_t *)linux_kcmp, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 311 = linux_kcmp */
- { 0, (sy_call_t *)linux_finit_module, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 312 = linux_finit_module */
- { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 313 = nosys */
+ { AS(linux_setns_args), (sy_call_t *)linux_setns, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 308 = linux_setns */
+ { AS(linux_getcpu_args), (sy_call_t *)linux_getcpu, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 309 = linux_getcpu */
+ { AS(linux_process_vm_readv_args), (sy_call_t *)linux_process_vm_readv, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 310 = linux_process_vm_readv */
+ { AS(linux_process_vm_writev_args), (sy_call_t *)linux_process_vm_writev, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 311 = linux_process_vm_writev */
+ { AS(linux_kcmp_args), (sy_call_t *)linux_kcmp, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 312 = linux_kcmp */
+ { AS(linux_finit_module_args), (sy_call_t *)linux_finit_module, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 313 = linux_finit_module */
+ { AS(linux_sched_setattr_args), (sy_call_t *)linux_sched_setattr, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 314 = linux_sched_setattr */
+ { AS(linux_sched_getattr_args), (sy_call_t *)linux_sched_getattr, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 315 = linux_sched_getattr */
+ { AS(linux_renameat2_args), (sy_call_t *)linux_renameat2, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 316 = linux_renameat2 */
+ { AS(linux_seccomp_args), (sy_call_t *)linux_seccomp, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 317 = linux_seccomp */
+ { AS(linux_getrandom_args), (sy_call_t *)linux_getrandom, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 318 = linux_getrandom */
+ { AS(linux_memfd_create_args), (sy_call_t *)linux_memfd_create, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 319 = linux_memfd_create */
+ { AS(linux_kexec_file_load_args), (sy_call_t *)linux_kexec_file_load, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 320 = linux_kexec_file_load */
+ { AS(linux_bpf_args), (sy_call_t *)linux_bpf, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 321 = linux_bpf */
+ { AS(linux_execveat_args), (sy_call_t *)linux_execveat, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 322 = linux_execveat */
+ { AS(linux_userfaultfd_args), (sy_call_t *)linux_userfaultfd, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 323 = linux_userfaultfd */
+ { AS(linux_membarrier_args), (sy_call_t *)linux_membarrier, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 324 = linux_membarrier */
+ { AS(linux_mlock2_args), (sy_call_t *)linux_mlock2, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 325 = linux_mlock2 */
+ { AS(linux_copy_file_range_args), (sy_call_t *)linux_copy_file_range, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 326 = linux_copy_file_range */
+ { AS(linux_preadv2_args), (sy_call_t *)linux_preadv2, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 327 = linux_preadv2 */
+ { AS(linux_pwritev2_args), (sy_call_t *)linux_pwritev2, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 328 = linux_pwritev2 */
+ { AS(linux_pkey_mprotect_args), (sy_call_t *)linux_pkey_mprotect, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 329 = linux_pkey_mprotect */
+ { AS(linux_pkey_alloc_args), (sy_call_t *)linux_pkey_alloc, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 330 = linux_pkey_alloc */
+ { AS(linux_pkey_free_args), (sy_call_t *)linux_pkey_free, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 331 = linux_pkey_free */
+ { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 332 = nosys */
};
diff --git a/sys/amd64/linux/linux_systrace_args.c b/sys/amd64/linux/linux_systrace_args.c
index db26824..2baaf60 100644
--- a/sys/amd64/linux/linux_systrace_args.c
+++ b/sys/amd64/linux/linux_systrace_args.c
@@ -2076,7 +2076,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args)
*n_args = 0;
break;
}
- /* linux_timerfd */
+ /* linux_timerfd_create */
case 283: {
*n_args = 0;
break;
@@ -2157,22 +2157,41 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args)
}
/* linux_inotify_init1 */
case 294: {
- *n_args = 0;
+ struct linux_inotify_init1_args *p = params;
+ iarg[0] = p->flags; /* l_int */
+ *n_args = 1;
break;
}
/* linux_preadv */
case 295: {
- *n_args = 0;
+ struct linux_preadv_args *p = params;
+ iarg[0] = p->fd; /* l_ulong */
+ uarg[1] = (intptr_t) p->vec; /* struct iovec * */
+ iarg[2] = p->vlen; /* l_ulong */
+ iarg[3] = p->pos_l; /* l_ulong */
+ iarg[4] = p->pos_h; /* l_ulong */
+ *n_args = 5;
break;
}
/* linux_pwritev */
case 296: {
- *n_args = 0;
+ struct linux_pwritev_args *p = params;
+ iarg[0] = p->fd; /* l_ulong */
+ uarg[1] = (intptr_t) p->vec; /* struct iovec * */
+ iarg[2] = p->vlen; /* l_ulong */
+ iarg[3] = p->pos_l; /* l_ulong */
+ iarg[4] = p->pos_h; /* l_ulong */
+ *n_args = 5;
break;
}
- /* linux_rt_tsigqueueinfo */
+ /* linux_rt_tgsigqueueinfo */
case 297: {
- *n_args = 0;
+ struct linux_rt_tgsigqueueinfo_args *p = params;
+ iarg[0] = p->tgid; /* l_pid_t */
+ iarg[1] = p->tid; /* l_pid_t */
+ iarg[2] = p->sig; /* l_int */
+ uarg[3] = (intptr_t) p->uinfo; /* l_siginfo_t * */
+ *n_args = 4;
break;
}
/* linux_perf_event_open */
@@ -2245,27 +2264,235 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args)
}
/* linux_setns */
case 308: {
- *n_args = 0;
+ struct linux_setns_args *p = params;
+ iarg[0] = p->fd; /* l_int */
+ iarg[1] = p->nstype; /* l_int */
+ *n_args = 2;
break;
}
- /* linux_process_vm_readv */
+ /* linux_getcpu */
case 309: {
- *n_args = 0;
+ struct linux_getcpu_args *p = params;
+ uarg[0] = (intptr_t) p->cpu; /* l_uint * */
+ uarg[1] = (intptr_t) p->node; /* l_uint * */
+ uarg[2] = (intptr_t) p->cache; /* void * */
+ *n_args = 3;
break;
}
- /* linux_process_vm_writev */
+ /* linux_process_vm_readv */
case 310: {
- *n_args = 0;
+ struct linux_process_vm_readv_args *p = params;
+ iarg[0] = p->pid; /* l_pid_t */
+ uarg[1] = (intptr_t) p->lvec; /* const struct iovec * */
+ iarg[2] = p->liovcnt; /* l_ulong */
+ uarg[3] = (intptr_t) p->rvec; /* const struct iovec * */
+ iarg[4] = p->riovcnt; /* l_ulong */
+ iarg[5] = p->flags; /* l_ulong */
+ *n_args = 6;
break;
}
- /* linux_kcmp */
+ /* linux_process_vm_writev */
case 311: {
- *n_args = 0;
+ struct linux_process_vm_writev_args *p = params;
+ iarg[0] = p->pid; /* l_pid_t */
+ uarg[1] = (intptr_t) p->lvec; /* const struct iovec * */
+ iarg[2] = p->liovcnt; /* l_ulong */
+ uarg[3] = (intptr_t) p->rvec; /* const struct iovec * */
+ iarg[4] = p->riovcnt; /* l_ulong */
+ iarg[5] = p->flags; /* l_ulong */
+ *n_args = 6;
break;
}
- /* linux_finit_module */
+ /* linux_kcmp */
case 312: {
- *n_args = 0;
+ struct linux_kcmp_args *p = params;
+ iarg[0] = p->pid1; /* l_pid_t */
+ iarg[1] = p->pid2; /* l_pid_t */
+ iarg[2] = p->type; /* l_int */
+ iarg[3] = p->idx1; /* l_ulong */
+ iarg[4] = p->idx; /* l_ulong */
+ *n_args = 5;
+ break;
+ }
+ /* linux_finit_module */
+ case 313: {
+ struct linux_finit_module_args *p = params;
+ iarg[0] = p->fd; /* l_int */
+ uarg[1] = (intptr_t) p->uargs; /* const char * */
+ iarg[2] = p->flags; /* l_int */
+ *n_args = 3;
+ break;
+ }
+ /* linux_sched_setattr */
+ case 314: {
+ struct linux_sched_setattr_args *p = params;
+ iarg[0] = p->pid; /* l_pid_t */
+ uarg[1] = (intptr_t) p->attr; /* void * */
+ iarg[2] = p->flags; /* l_uint */
+ *n_args = 3;
+ break;
+ }
+ /* linux_sched_getattr */
+ case 315: {
+ struct linux_sched_getattr_args *p = params;
+ iarg[0] = p->pid; /* l_pid_t */
+ uarg[1] = (intptr_t) p->attr; /* void * */
+ iarg[2] = p->size; /* l_uint */
+ iarg[3] = p->flags; /* l_uint */
+ *n_args = 4;
+ break;
+ }
+ /* linux_renameat2 */
+ case 316: {
+ struct linux_renameat2_args *p = params;
+ iarg[0] = p->oldfd; /* l_int */
+ uarg[1] = (intptr_t) p->oldname; /* const char * */
+ iarg[2] = p->newfd; /* l_int */
+ uarg[3] = (intptr_t) p->newname; /* const char * */
+ uarg[4] = p->flags; /* unsigned int */
+ *n_args = 5;
+ break;
+ }
+ /* linux_seccomp */
+ case 317: {
+ struct linux_seccomp_args *p = params;
+ iarg[0] = p->op; /* l_uint */
+ iarg[1] = p->flags; /* l_uint */
+ uarg[2] = (intptr_t) p->uargs; /* const char * */
+ *n_args = 3;
+ break;
+ }
+ /* linux_getrandom */
+ case 318: {
+ struct linux_getrandom_args *p = params;
+ uarg[0] = (intptr_t) p->buf; /* char * */
+ iarg[1] = p->count; /* l_size_t */
+ iarg[2] = p->flags; /* l_uint */
+ *n_args = 3;
+ break;
+ }
+ /* linux_memfd_create */
+ case 319: {
+ struct linux_memfd_create_args *p = params;
+ uarg[0] = (intptr_t) p->uname_ptr; /* const char * */
+ iarg[1] = p->flags; /* l_uint */
+ *n_args = 2;
+ break;
+ }
+ /* linux_kexec_file_load */
+ case 320: {
+ struct linux_kexec_file_load_args *p = params;
+ iarg[0] = p->kernel_fd; /* l_int */
+ iarg[1] = p->initrd_fd; /* l_int */
+ iarg[2] = p->cmdline_len; /* l_ulong */
+ uarg[3] = (intptr_t) p->cmdline_ptr; /* const char * */
+ iarg[4] = p->flags; /* l_ulong */
+ *n_args = 5;
+ break;
+ }
+ /* linux_bpf */
+ case 321: {
+ struct linux_bpf_args *p = params;
+ iarg[0] = p->cmd; /* l_int */
+ uarg[1] = (intptr_t) p->attr; /* void * */
+ iarg[2] = p->size; /* l_uint */
+ *n_args = 3;
+ break;
+ }
+ /* linux_execveat */
+ case 322: {
+ struct linux_execveat_args *p = params;
+ iarg[0] = p->dfd; /* l_int */
+ uarg[1] = (intptr_t) p->filename; /* const char * */
+ uarg[2] = (intptr_t) p->argv; /* const char ** */
+ uarg[3] = (intptr_t) p->envp; /* const char ** */
+ iarg[4] = p->flags; /* l_int */
+ *n_args = 5;
+ break;
+ }
+ /* linux_userfaultfd */
+ case 323: {
+ struct linux_userfaultfd_args *p = params;
+ iarg[0] = p->flags; /* l_int */
+ *n_args = 1;
+ break;
+ }
+ /* linux_membarrier */
+ case 324: {
+ struct linux_membarrier_args *p = params;
+ iarg[0] = p->cmd; /* l_int */
+ iarg[1] = p->flags; /* l_int */
+ *n_args = 2;
+ break;
+ }
+ /* linux_mlock2 */
+ case 325: {
+ struct linux_mlock2_args *p = params;
+ iarg[0] = p->start; /* l_ulong */
+ iarg[1] = p->len; /* l_size_t */
+ iarg[2] = p->flags; /* l_int */
+ *n_args = 3;
+ break;
+ }
+ /* linux_copy_file_range */
+ case 326: {
+ struct linux_copy_file_range_args *p = params;
+ iarg[0] = p->fd_in; /* l_int */
+ uarg[1] = (intptr_t) p->off_in; /* l_loff_t * */
+ iarg[2] = p->fd_out; /* l_int */
+ uarg[3] = (intptr_t) p->off_out; /* l_loff_t * */
+ iarg[4] = p->len; /* l_size_t */
+ iarg[5] = p->flags; /* l_uint */
+ *n_args = 6;
+ break;
+ }
+ /* linux_preadv2 */
+ case 327: {
+ struct linux_preadv2_args *p = params;
+ iarg[0] = p->fd; /* l_ulong */
+ uarg[1] = (intptr_t) p->vec; /* const struct iovec * */
+ iarg[2] = p->vlen; /* l_ulong */
+ iarg[3] = p->pos_l; /* l_ulong */
+ iarg[4] = p->pos_h; /* l_ulong */
+ iarg[5] = p->flags; /* l_int */
+ *n_args = 6;
+ break;
+ }
+ /* linux_pwritev2 */
+ case 328: {
+ struct linux_pwritev2_args *p = params;
+ iarg[0] = p->fd; /* l_ulong */
+ uarg[1] = (intptr_t) p->vec; /* const struct iovec * */
+ iarg[2] = p->vlen; /* l_ulong */
+ iarg[3] = p->pos_l; /* l_ulong */
+ iarg[4] = p->pos_h; /* l_ulong */
+ iarg[5] = p->flags; /* l_int */
+ *n_args = 6;
+ break;
+ }
+ /* linux_pkey_mprotect */
+ case 329: {
+ struct linux_pkey_mprotect_args *p = params;
+ iarg[0] = p->start; /* l_ulong */
+ iarg[1] = p->len; /* l_size_t */
+ iarg[2] = p->prot; /* l_ulong */
+ iarg[3] = p->pkey; /* l_int */
+ *n_args = 4;
+ break;
+ }
+ /* linux_pkey_alloc */
+ case 330: {
+ struct linux_pkey_alloc_args *p = params;
+ iarg[0] = p->flags; /* l_ulong */
+ iarg[1] = p->init_val; /* l_ulong */
+ *n_args = 2;
+ break;
+ }
+ /* linux_pkey_free */
+ case 331: {
+ struct linux_pkey_free_args *p = params;
+ iarg[0] = p->pkey; /* l_int */
+ *n_args = 1;
break;
}
default:
@@ -5415,7 +5642,7 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)
/* linux_signalfd */
case 282:
break;
- /* linux_timerfd */
+ /* linux_timerfd_create */
case 283:
break;
/* linux_eventfd */
@@ -5529,15 +5756,76 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)
break;
/* linux_inotify_init1 */
case 294:
+ switch(ndx) {
+ case 0:
+ p = "l_int";
+ break;
+ default:
+ break;
+ };
break;
/* linux_preadv */
case 295:
+ switch(ndx) {
+ case 0:
+ p = "l_ulong";
+ break;
+ case 1:
+ p = "userland struct iovec *";
+ break;
+ case 2:
+ p = "l_ulong";
+ break;
+ case 3:
+ p = "l_ulong";
+ break;
+ case 4:
+ p = "l_ulong";
+ break;
+ default:
+ break;
+ };
break;
/* linux_pwritev */
case 296:
+ switch(ndx) {
+ case 0:
+ p = "l_ulong";
+ break;
+ case 1:
+ p = "userland struct iovec *";
+ break;
+ case 2:
+ p = "l_ulong";
+ break;
+ case 3:
+ p = "l_ulong";
+ break;
+ case 4:
+ p = "l_ulong";
+ break;
+ default:
+ break;
+ };
break;
- /* linux_rt_tsigqueueinfo */
+ /* linux_rt_tgsigqueueinfo */
case 297:
+ switch(ndx) {
+ case 0:
+ p = "l_pid_t";
+ break;
+ case 1:
+ p = "l_pid_t";
+ break;
+ case 2:
+ p = "l_int";
+ break;
+ case 3:
+ p = "userland l_siginfo_t *";
+ break;
+ default:
+ break;
+ };
break;
/* linux_perf_event_open */
case 298:
@@ -5629,18 +5917,438 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)
break;
/* linux_setns */
case 308:
+ switch(ndx) {
+ case 0:
+ p = "l_int";
+ break;
+ case 1:
+ p = "l_int";
+ break;
+ default:
+ break;
+ };
break;
- /* linux_process_vm_readv */
+ /* linux_getcpu */
case 309:
+ switch(ndx) {
+ case 0:
+ p = "userland l_uint *";
+ break;
+ case 1:
+ p = "userland l_uint *";
+ break;
+ case 2:
+ p = "userland void *";
+ break;
+ default:
+ break;
+ };
break;
- /* linux_process_vm_writev */
+ /* linux_process_vm_readv */
case 310:
+ switch(ndx) {
+ case 0:
+ p = "l_pid_t";
+ break;
+ case 1:
+ p = "userland const struct iovec *";
+ break;
+ case 2:
+ p = "l_ulong";
+ break;
+ case 3:
+ p = "userland const struct iovec *";
+ break;
+ case 4:
+ p = "l_ulong";
+ break;
+ case 5:
+ p = "l_ulong";
+ break;
+ default:
+ break;
+ };
break;
- /* linux_kcmp */
+ /* linux_process_vm_writev */
case 311:
+ switch(ndx) {
+ case 0:
+ p = "l_pid_t";
+ break;
+ case 1:
+ p = "userland const struct iovec *";
+ break;
+ case 2:
+ p = "l_ulong";
+ break;
+ case 3:
+ p = "userland const struct iovec *";
+ break;
+ case 4:
+ p = "l_ulong";
+ break;
+ case 5:
+ p = "l_ulong";
+ break;
+ default:
+ break;
+ };
break;
- /* linux_finit_module */
+ /* linux_kcmp */
case 312:
+ switch(ndx) {
+ case 0:
+ p = "l_pid_t";
+ break;
+ case 1:
+ p = "l_pid_t";
+ break;
+ case 2:
+ p = "l_int";
+ break;
+ case 3:
+ p = "l_ulong";
+ break;
+ case 4:
+ p = "l_ulong";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_finit_module */
+ case 313:
+ switch(ndx) {
+ case 0:
+ p = "l_int";
+ break;
+ case 1:
+ p = "userland const char *";
+ break;
+ case 2:
+ p = "l_int";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_sched_setattr */
+ case 314:
+ switch(ndx) {
+ case 0:
+ p = "l_pid_t";
+ break;
+ case 1:
+ p = "userland void *";
+ break;
+ case 2:
+ p = "l_uint";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_sched_getattr */
+ case 315:
+ switch(ndx) {
+ case 0:
+ p = "l_pid_t";
+ break;
+ case 1:
+ p = "userland void *";
+ break;
+ case 2:
+ p = "l_uint";
+ break;
+ case 3:
+ p = "l_uint";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_renameat2 */
+ case 316:
+ switch(ndx) {
+ case 0:
+ p = "l_int";
+ break;
+ case 1:
+ p = "userland const char *";
+ break;
+ case 2:
+ p = "l_int";
+ break;
+ case 3:
+ p = "userland const char *";
+ break;
+ case 4:
+ p = "unsigned int";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_seccomp */
+ case 317:
+ switch(ndx) {
+ case 0:
+ p = "l_uint";
+ break;
+ case 1:
+ p = "l_uint";
+ break;
+ case 2:
+ p = "userland const char *";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_getrandom */
+ case 318:
+ switch(ndx) {
+ case 0:
+ p = "userland char *";
+ break;
+ case 1:
+ p = "l_size_t";
+ break;
+ case 2:
+ p = "l_uint";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_memfd_create */
+ case 319:
+ switch(ndx) {
+ case 0:
+ p = "userland const char *";
+ break;
+ case 1:
+ p = "l_uint";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_kexec_file_load */
+ case 320:
+ switch(ndx) {
+ case 0:
+ p = "l_int";
+ break;
+ case 1:
+ p = "l_int";
+ break;
+ case 2:
+ p = "l_ulong";
+ break;
+ case 3:
+ p = "userland const char *";
+ break;
+ case 4:
+ p = "l_ulong";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_bpf */
+ case 321:
+ switch(ndx) {
+ case 0:
+ p = "l_int";
+ break;
+ case 1:
+ p = "userland void *";
+ break;
+ case 2:
+ p = "l_uint";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_execveat */
+ case 322:
+ switch(ndx) {
+ case 0:
+ p = "l_int";
+ break;
+ case 1:
+ p = "userland const char *";
+ break;
+ case 2:
+ p = "userland const char **";
+ break;
+ case 3:
+ p = "userland const char **";
+ break;
+ case 4:
+ p = "l_int";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_userfaultfd */
+ case 323:
+ switch(ndx) {
+ case 0:
+ p = "l_int";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_membarrier */
+ case 324:
+ switch(ndx) {
+ case 0:
+ p = "l_int";
+ break;
+ case 1:
+ p = "l_int";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_mlock2 */
+ case 325:
+ switch(ndx) {
+ case 0:
+ p = "l_ulong";
+ break;
+ case 1:
+ p = "l_size_t";
+ break;
+ case 2:
+ p = "l_int";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_copy_file_range */
+ case 326:
+ switch(ndx) {
+ case 0:
+ p = "l_int";
+ break;
+ case 1:
+ p = "userland l_loff_t *";
+ break;
+ case 2:
+ p = "l_int";
+ break;
+ case 3:
+ p = "userland l_loff_t *";
+ break;
+ case 4:
+ p = "l_size_t";
+ break;
+ case 5:
+ p = "l_uint";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_preadv2 */
+ case 327:
+ switch(ndx) {
+ case 0:
+ p = "l_ulong";
+ break;
+ case 1:
+ p = "userland const struct iovec *";
+ break;
+ case 2:
+ p = "l_ulong";
+ break;
+ case 3:
+ p = "l_ulong";
+ break;
+ case 4:
+ p = "l_ulong";
+ break;
+ case 5:
+ p = "l_int";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_pwritev2 */
+ case 328:
+ switch(ndx) {
+ case 0:
+ p = "l_ulong";
+ break;
+ case 1:
+ p = "userland const struct iovec *";
+ break;
+ case 2:
+ p = "l_ulong";
+ break;
+ case 3:
+ p = "l_ulong";
+ break;
+ case 4:
+ p = "l_ulong";
+ break;
+ case 5:
+ p = "l_int";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_pkey_mprotect */
+ case 329:
+ switch(ndx) {
+ case 0:
+ p = "l_ulong";
+ break;
+ case 1:
+ p = "l_size_t";
+ break;
+ case 2:
+ p = "l_ulong";
+ break;
+ case 3:
+ p = "l_int";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_pkey_alloc */
+ case 330:
+ switch(ndx) {
+ case 0:
+ p = "l_ulong";
+ break;
+ case 1:
+ p = "l_ulong";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_pkey_free */
+ case 331:
+ switch(ndx) {
+ case 0:
+ p = "l_int";
+ break;
+ default:
+ break;
+ };
break;
default:
break;
@@ -6784,7 +7492,7 @@ systrace_return_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)
break;
/* linux_signalfd */
case 282:
- /* linux_timerfd */
+ /* linux_timerfd_create */
case 283:
/* linux_eventfd */
case 284:
@@ -6829,12 +7537,24 @@ systrace_return_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)
break;
/* linux_inotify_init1 */
case 294:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
/* linux_preadv */
case 295:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
/* linux_pwritev */
case 296:
- /* linux_rt_tsigqueueinfo */
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_rt_tgsigqueueinfo */
case 297:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
/* linux_perf_event_open */
case 298:
/* linux_recvmmsg */
@@ -6869,14 +7589,124 @@ systrace_return_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)
break;
/* linux_setns */
case 308:
- /* linux_process_vm_readv */
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_getcpu */
case 309:
- /* linux_process_vm_writev */
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_process_vm_readv */
case 310:
- /* linux_kcmp */
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_process_vm_writev */
case 311:
- /* linux_finit_module */
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_kcmp */
case 312:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_finit_module */
+ case 313:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_sched_setattr */
+ case 314:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_sched_getattr */
+ case 315:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_renameat2 */
+ case 316:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_seccomp */
+ case 317:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_getrandom */
+ case 318:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_memfd_create */
+ case 319:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_kexec_file_load */
+ case 320:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_bpf */
+ case 321:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_execveat */
+ case 322:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_userfaultfd */
+ case 323:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_membarrier */
+ case 324:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_mlock2 */
+ case 325:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_copy_file_range */
+ case 326:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_preadv2 */
+ case 327:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_pwritev2 */
+ case 328:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_pkey_mprotect */
+ case 329:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_pkey_alloc */
+ case 330:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_pkey_free */
+ case 331:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
default:
break;
};
diff --git a/sys/amd64/linux/syscalls.master b/sys/amd64/linux/syscalls.master
index d4544f8..291953b 100644
--- a/sys/amd64/linux/syscalls.master
+++ b/sys/amd64/linux/syscalls.master
@@ -11,18 +11,20 @@
; there is no audit event for the call at this time. For the
; case where the event exists, but we don't want auditing, the
; event should be #defined to AUE_NULL in audit_kevents.h.
-; type one of STD, OBSOL, UNIMPL
+; type one of STD, NOPROTO, UNIMPL
; name psuedo-prototype of syscall routine
; If one of the following alts is different, then all appear:
; altname name of system call if different
; alttag name of args struct tag if different from [o]`name'"_args"
; altrtyp return type if not int (bogus - syscalls always return int)
-; for UNIMPL/OBSOL, name continues with comments
+; for UNIMPL, name continues with comments
; types:
; STD always included
-; OBSOL obsolete, not included in system, only specifies name
; UNIMPL not implemented, placeholder only
+; NOPROTO same as STD except do not create structure or
+; function prototype in sys/sysproto.h. Does add a
+; definition to syscall.h besides adding a sysent.
#include <sys/param.h>
#include <sys/sysent.h>
@@ -369,7 +371,7 @@
206 AUE_NULL UNIMPL linux_io_setup
207 AUE_NULL UNIMPL linux_io_destroy
208 AUE_NULL UNIMPL linux_io_getevents
-209 AUE_NULL UNIMPL inux_io_submit
+209 AUE_NULL UNIMPL linux_io_submit
210 AUE_NULL UNIMPL linux_io_cancel
211 AUE_NULL UNIMPL linux_get_thread_area
212 AUE_NULL STD { int linux_lookup_dcookie(void); }
@@ -473,7 +475,7 @@
281 AUE_NULL STD { int linux_epoll_pwait(l_int epfd, struct epoll_event *events, \
l_int maxevents, l_int timeout, l_sigset_t *mask); }
282 AUE_NULL STD { int linux_signalfd(void); }
-283 AUE_NULL STD { int linux_timerfd(void); }
+283 AUE_NULL STD { int linux_timerfd_create(void); }
284 AUE_NULL STD { int linux_eventfd(l_uint initval); }
285 AUE_NULL STD { int linux_fallocate(l_int fd, l_int mode, \
l_loff_t offset, l_loff_t len); }
@@ -481,35 +483,114 @@
287 AUE_NULL STD { int linux_timerfd_gettime(void); }
288 AUE_ACCEPT STD { int linux_accept4(l_int s, l_uintptr_t addr, \
l_uintptr_t namelen, int flags); }
+; linux 2.6.27:
289 AUE_NULL STD { int linux_signalfd4(void); }
290 AUE_NULL STD { int linux_eventfd2(l_uint initval, l_int flags); }
291 AUE_NULL STD { int linux_epoll_create1(l_int flags); }
292 AUE_NULL STD { int linux_dup3(l_int oldfd, \
l_int newfd, l_int flags); }
293 AUE_NULL STD { int linux_pipe2(l_int *pipefds, l_int flags); }
-294 AUE_NULL STD { int linux_inotify_init1(void); }
-295 AUE_NULL STD { int linux_preadv(void); }
-296 AUE_NULL STD { int linux_pwritev(void); }
-297 AUE_NULL STD { int linux_rt_tsigqueueinfo(void); }
+294 AUE_NULL STD { int linux_inotify_init1(l_int flags); }
+; linux 2.6.30:
+295 AUE_NULL STD { int linux_preadv(l_ulong fd, \
+ struct iovec *vec, l_ulong vlen, \
+ l_ulong pos_l, l_ulong pos_h); }
+296 AUE_NULL STD { int linux_pwritev(l_ulong fd, \
+ struct iovec *vec, l_ulong vlen, \
+ l_ulong pos_l, l_ulong pos_h); }
+; linux 2.6.31:
+297 AUE_NULL STD { int linux_rt_tgsigqueueinfo(l_pid_t tgid, \
+ l_pid_t tid, l_int sig, l_siginfo_t *uinfo); }
298 AUE_NULL STD { int linux_perf_event_open(void); }
+; linux 2.6.33:
299 AUE_NULL STD { int linux_recvmmsg(l_int s, \
struct l_mmsghdr *msg, l_uint vlen, \
l_uint flags, struct l_timespec *timeout); }
+; linux 2.6.37:
300 AUE_NULL STD { int linux_fanotify_init(void); }
301 AUE_NULL STD { int linux_fanotify_mark(void); }
+; linux 2.6.36:
302 AUE_NULL STD { int linux_prlimit64(l_pid_t pid, l_uint resource, \
struct rlimit *new, struct rlimit *old); }
+; linux 2.6.39 (glibc 2.14):
303 AUE_NULL STD { int linux_name_to_handle_at(void); }
304 AUE_NULL STD { int linux_open_by_handle_at(void); }
305 AUE_NULL STD { int linux_clock_adjtime(void); }
306 AUE_SYNC STD { int linux_syncfs(l_int fd); }
+; linux 3.0 (glibc 2.14):
307 AUE_NULL STD { int linux_sendmmsg(l_int s, \
struct l_mmsghdr *msg, l_uint vlen, \
l_uint flags); }
-308 AUE_NULL STD { int linux_setns(void); }
-309 AUE_NULL STD { int linux_process_vm_readv(void); }
-310 AUE_NULL STD { int linux_process_vm_writev(void); }
-311 AUE_NULL STD { int linux_kcmp(void); }
-312 AUE_NULL STD { int linux_finit_module(void); }
+308 AUE_NULL STD { int linux_setns(l_int fd, l_int nstype); }
+; linux 2.6.19 (no glibc wrapper):
+309 AUE_NULL STD { int linux_getcpu(l_uint *cpu, l_uint *node, \
+ void *cache); }
+; linux 3.2 (glibc 2.15):
+310 AUE_NULL STD { int linux_process_vm_readv(l_pid_t pid, \
+ const struct iovec *lvec, l_ulong liovcnt, \
+ const struct iovec *rvec, l_ulong riovcnt, \
+ l_ulong flags); }
+311 AUE_NULL STD { int linux_process_vm_writev(l_pid_t pid, \
+ const struct iovec *lvec, l_ulong liovcnt, \
+ const struct iovec *rvec, l_ulong riovcnt, \
+ l_ulong flags); }
+; linux 3.5 (no glibc wrapper):
+312 AUE_NULL STD { int linux_kcmp(l_pid_t pid1, l_pid_t pid2, \
+ l_int type, l_ulong idx1, l_ulong idx); }
+; linux 3.8 (no glibc wrapper):
+313 AUE_NULL STD { int linux_finit_module(l_int fd, \
+ const char *uargs, l_int flags); }
+; linux 3.14:
+314 AUE_NULL STD { int linux_sched_setattr(l_pid_t pid, \
+ void *attr, l_uint flags); }
+315 AUE_NULL STD { int linux_sched_getattr(l_pid_t pid, \
+ void *attr, l_uint size, l_uint flags); }
+; linux 3.15:
+316 AUE_NULL STD { int linux_renameat2(l_int oldfd, \
+ const char *oldname, l_int newfd, \
+ const char *newname, unsigned int flags); }
+; linux 3.17:
+317 AUE_NULL STD { int linux_seccomp(l_uint op, l_uint flags, \
+ const char *uargs); }
+318 AUE_NULL STD { int linux_getrandom(char *buf, \
+ l_size_t count, l_uint flags); }
+319 AUE_NULL STD { int linux_memfd_create(const char *uname_ptr, \
+ l_uint flags); }
+320 AUE_NULL STD { int linux_kexec_file_load(l_int kernel_fd, \
+ l_int initrd_fd, l_ulong cmdline_len, \
+ const char *cmdline_ptr, l_ulong flags); }
+; linux 3.18:
+321 AUE_NULL STD { int linux_bpf(l_int cmd, void *attr, \
+ l_uint size); }
+; linux 3.19:
+322 AUE_NULL STD { int linux_execveat(l_int dfd, \
+ const char *filename, const char **argv, \
+ const char **envp, l_int flags); }
+; linux 4.2:
+323 AUE_NULL STD { int linux_userfaultfd(l_int flags); }
+; linux 4.3:
+324 AUE_NULL STD { int linux_membarrier(l_int cmd, l_int flags); }
+; linux 4.4:
+325 AUE_NULL STD { int linux_mlock2(l_ulong start, l_size_t len, \
+ l_int flags); }
+; linux 4.5:
+326 AUE_NULL STD { int linux_copy_file_range(l_int fd_in, \
+ l_loff_t *off_in, l_int fd_out, \
+ l_loff_t *off_out, l_size_t len, \
+ l_uint flags); }
+; linux 4.6:
+327 AUE_NULL STD { int linux_preadv2(l_ulong fd, \
+ const struct iovec *vec, l_ulong vlen, \
+ l_ulong pos_l, l_ulong pos_h, l_int flags); }
+328 AUE_NULL STD { int linux_pwritev2(l_ulong fd, \
+ const struct iovec *vec, l_ulong vlen, \
+ l_ulong pos_l, l_ulong pos_h, l_int flags); }
+; linux 4.8:
+329 AUE_NULL STD { int linux_pkey_mprotect(l_ulong start, \
+ l_size_t len, l_ulong prot, l_int pkey); }
+330 AUE_NULL STD { int linux_pkey_alloc(l_ulong flags, \
+ l_ulong init_val); }
+331 AUE_NULL STD { int linux_pkey_free(l_int pkey); }
+
; please, keep this line at the end.
-313 AUE_NULL UNIMPL nosys
+332 AUE_NULL UNIMPL nosys
diff --git a/sys/amd64/linux32/linux32_dummy.c b/sys/amd64/linux32/linux32_dummy.c
index 1104651..74e89a9 100644
--- a/sys/amd64/linux32/linux32_dummy.c
+++ b/sys/amd64/linux32/linux32_dummy.c
@@ -114,18 +114,51 @@ DUMMY(inotify_init1);
DUMMY(preadv);
DUMMY(pwritev);
/* linux 2.6.31: */
-DUMMY(rt_tsigqueueinfo);
+DUMMY(rt_tgsigqueueinfo);
DUMMY(perf_event_open);
/* linux 2.6.33: */
DUMMY(fanotify_init);
DUMMY(fanotify_mark);
-/* later: */
+/* linux 2.6.39: */
DUMMY(name_to_handle_at);
DUMMY(open_by_handle_at);
DUMMY(clock_adjtime);
+/* linux 3.0: */
DUMMY(setns);
+/* linux 3.2: */
DUMMY(process_vm_readv);
DUMMY(process_vm_writev);
+/* linux 3.5: */
+DUMMY(kcmp);
+/* linux 3.8: */
+DUMMY(finit_module);
+DUMMY(sched_setattr);
+DUMMY(sched_getattr);
+/* linux 3.14: */
+DUMMY(renameat2);
+/* linux 3.15: */
+DUMMY(seccomp);
+DUMMY(getrandom);
+DUMMY(memfd_create);
+/* linux 3.18: */
+DUMMY(bpf);
+/* linux 3.19: */
+DUMMY(execveat);
+/* linux 4.2: */
+DUMMY(userfaultfd);
+/* linux 4.3: */
+DUMMY(membarrier);
+/* linux 4.4: */
+DUMMY(mlock2);
+/* linux 4.5: */
+DUMMY(copy_file_range);
+/* linux 4.6: */
+DUMMY(preadv2);
+DUMMY(pwritev2);
+/* linux 4.8: */
+DUMMY(pkey_mprotect);
+DUMMY(pkey_alloc);
+DUMMY(pkey_free);
#define DUMMY_XATTR(s) \
int \
diff --git a/sys/amd64/linux32/linux32_proto.h b/sys/amd64/linux32/linux32_proto.h
index 35830ee..a22f17f 100644
--- a/sys/amd64/linux32/linux32_proto.h
+++ b/sys/amd64/linux32/linux32_proto.h
@@ -3,7 +3,7 @@
*
* DO NOT EDIT-- this file is automatically generated.
* $FreeBSD$
- * created from FreeBSD: head/sys/amd64/linux32/syscalls.master 302515 2016-07-10 08:15:50Z dchagin
+ * created from FreeBSD: head/sys/amd64/linux32/syscalls.master 313284 2017-02-05 14:17:09Z dchagin
*/
#ifndef _LINUX32_SYSPROTO_H_
@@ -1103,13 +1103,24 @@ struct linux_inotify_init1_args {
register_t dummy;
};
struct linux_preadv_args {
- register_t dummy;
+ char fd_l_[PADL_(l_ulong)]; l_ulong fd; char fd_r_[PADR_(l_ulong)];
+ char vec_l_[PADL_(struct iovec *)]; struct iovec * vec; char vec_r_[PADR_(struct iovec *)];
+ char vlen_l_[PADL_(l_ulong)]; l_ulong vlen; char vlen_r_[PADR_(l_ulong)];
+ char pos_l_l_[PADL_(l_ulong)]; l_ulong pos_l; char pos_l_r_[PADR_(l_ulong)];
+ char pos_h_l_[PADL_(l_ulong)]; l_ulong pos_h; char pos_h_r_[PADR_(l_ulong)];
};
struct linux_pwritev_args {
- register_t dummy;
-};
-struct linux_rt_tsigqueueinfo_args {
- register_t dummy;
+ char fd_l_[PADL_(l_ulong)]; l_ulong fd; char fd_r_[PADR_(l_ulong)];
+ char vec_l_[PADL_(struct iovec *)]; struct iovec * vec; char vec_r_[PADR_(struct iovec *)];
+ char vlen_l_[PADL_(l_ulong)]; l_ulong vlen; char vlen_r_[PADR_(l_ulong)];
+ char pos_l_l_[PADL_(l_ulong)]; l_ulong pos_l; char pos_l_r_[PADR_(l_ulong)];
+ char pos_h_l_[PADL_(l_ulong)]; l_ulong pos_h; char pos_h_r_[PADR_(l_ulong)];
+};
+struct linux_rt_tgsigqueueinfo_args {
+ char tgid_l_[PADL_(l_pid_t)]; l_pid_t tgid; char tgid_r_[PADR_(l_pid_t)];
+ char tid_l_[PADL_(l_pid_t)]; l_pid_t tid; char tid_r_[PADR_(l_pid_t)];
+ char sig_l_[PADL_(l_int)]; l_int sig; char sig_r_[PADR_(l_int)];
+ char uinfo_l_[PADL_(l_siginfo_t *)]; l_siginfo_t * uinfo; char uinfo_r_[PADR_(l_siginfo_t *)];
};
struct linux_perf_event_open_args {
register_t dummy;
@@ -1155,10 +1166,210 @@ struct linux_setns_args {
register_t dummy;
};
struct linux_process_vm_readv_args {
- register_t dummy;
+ char pid_l_[PADL_(l_pid_t)]; l_pid_t pid; char pid_r_[PADR_(l_pid_t)];
+ char lvec_l_[PADL_(const struct iovec *)]; const struct iovec * lvec; char lvec_r_[PADR_(const struct iovec *)];
+ char liovcnt_l_[PADL_(l_ulong)]; l_ulong liovcnt; char liovcnt_r_[PADR_(l_ulong)];
+ char rvec_l_[PADL_(const struct iovec *)]; const struct iovec * rvec; char rvec_r_[PADR_(const struct iovec *)];
+ char riovcnt_l_[PADL_(l_ulong)]; l_ulong riovcnt; char riovcnt_r_[PADR_(l_ulong)];
+ char flags_l_[PADL_(l_ulong)]; l_ulong flags; char flags_r_[PADR_(l_ulong)];
};
struct linux_process_vm_writev_args {
- register_t dummy;
+ char pid_l_[PADL_(l_pid_t)]; l_pid_t pid; char pid_r_[PADR_(l_pid_t)];
+ char lvec_l_[PADL_(const struct iovec *)]; const struct iovec * lvec; char lvec_r_[PADR_(const struct iovec *)];
+ char liovcnt_l_[PADL_(l_ulong)]; l_ulong liovcnt; char liovcnt_r_[PADR_(l_ulong)];
+ char rvec_l_[PADL_(const struct iovec *)]; const struct iovec * rvec; char rvec_r_[PADR_(const struct iovec *)];
+ char riovcnt_l_[PADL_(l_ulong)]; l_ulong riovcnt; char riovcnt_r_[PADR_(l_ulong)];
+ char flags_l_[PADL_(l_ulong)]; l_ulong flags; char flags_r_[PADR_(l_ulong)];
+};
+struct linux_kcmp_args {
+ char pid1_l_[PADL_(l_pid_t)]; l_pid_t pid1; char pid1_r_[PADR_(l_pid_t)];
+ char pid2_l_[PADL_(l_pid_t)]; l_pid_t pid2; char pid2_r_[PADR_(l_pid_t)];
+ char type_l_[PADL_(l_int)]; l_int type; char type_r_[PADR_(l_int)];
+ char idx1_l_[PADL_(l_ulong)]; l_ulong idx1; char idx1_r_[PADR_(l_ulong)];
+ char idx_l_[PADL_(l_ulong)]; l_ulong idx; char idx_r_[PADR_(l_ulong)];
+};
+struct linux_finit_module_args {
+ char fd_l_[PADL_(l_int)]; l_int fd; char fd_r_[PADR_(l_int)];
+ char uargs_l_[PADL_(const char *)]; const char * uargs; char uargs_r_[PADR_(const char *)];
+ char flags_l_[PADL_(l_int)]; l_int flags; char flags_r_[PADR_(l_int)];
+};
+struct linux_sched_setattr_args {
+ char pid_l_[PADL_(l_pid_t)]; l_pid_t pid; char pid_r_[PADR_(l_pid_t)];
+ char attr_l_[PADL_(void *)]; void * attr; char attr_r_[PADR_(void *)];
+ char flags_l_[PADL_(l_uint)]; l_uint flags; char flags_r_[PADR_(l_uint)];
+};
+struct linux_sched_getattr_args {
+ char pid_l_[PADL_(l_pid_t)]; l_pid_t pid; char pid_r_[PADR_(l_pid_t)];
+ char attr_l_[PADL_(void *)]; void * attr; char attr_r_[PADR_(void *)];
+ char size_l_[PADL_(l_uint)]; l_uint size; char size_r_[PADR_(l_uint)];
+ char flags_l_[PADL_(l_uint)]; l_uint flags; char flags_r_[PADR_(l_uint)];
+};
+struct linux_renameat2_args {
+ char oldfd_l_[PADL_(l_int)]; l_int oldfd; char oldfd_r_[PADR_(l_int)];
+ char oldname_l_[PADL_(const char *)]; const char * oldname; char oldname_r_[PADR_(const char *)];
+ char newfd_l_[PADL_(l_int)]; l_int newfd; char newfd_r_[PADR_(l_int)];
+ char newname_l_[PADL_(const char *)]; const char * newname; char newname_r_[PADR_(const char *)];
+ char flags_l_[PADL_(unsigned int)]; unsigned int flags; char flags_r_[PADR_(unsigned int)];
+};
+struct linux_seccomp_args {
+ char op_l_[PADL_(l_uint)]; l_uint op; char op_r_[PADR_(l_uint)];
+ char flags_l_[PADL_(l_uint)]; l_uint flags; char flags_r_[PADR_(l_uint)];
+ char uargs_l_[PADL_(const char *)]; const char * uargs; char uargs_r_[PADR_(const char *)];
+};
+struct linux_getrandom_args {
+ char buf_l_[PADL_(char *)]; char * buf; char buf_r_[PADR_(char *)];
+ char count_l_[PADL_(l_size_t)]; l_size_t count; char count_r_[PADR_(l_size_t)];
+ char flags_l_[PADL_(l_uint)]; l_uint flags; char flags_r_[PADR_(l_uint)];
+};
+struct linux_memfd_create_args {
+ char uname_ptr_l_[PADL_(const char *)]; const char * uname_ptr; char uname_ptr_r_[PADR_(const char *)];
+ char flags_l_[PADL_(l_uint)]; l_uint flags; char flags_r_[PADR_(l_uint)];
+};
+struct linux_bpf_args {
+ char cmd_l_[PADL_(l_int)]; l_int cmd; char cmd_r_[PADR_(l_int)];
+ char attr_l_[PADL_(void *)]; void * attr; char attr_r_[PADR_(void *)];
+ char size_l_[PADL_(l_uint)]; l_uint size; char size_r_[PADR_(l_uint)];
+};
+struct linux_execveat_args {
+ char dfd_l_[PADL_(l_int)]; l_int dfd; char dfd_r_[PADR_(l_int)];
+ char filename_l_[PADL_(const char *)]; const char * filename; char filename_r_[PADR_(const char *)];
+ char argv_l_[PADL_(const char **)]; const char ** argv; char argv_r_[PADR_(const char **)];
+ char envp_l_[PADL_(const char **)]; const char ** envp; char envp_r_[PADR_(const char **)];
+ char flags_l_[PADL_(l_int)]; l_int flags; char flags_r_[PADR_(l_int)];
+};
+struct linux_socket_args {
+ char domain_l_[PADL_(l_int)]; l_int domain; char domain_r_[PADR_(l_int)];
+ char type_l_[PADL_(l_int)]; l_int type; char type_r_[PADR_(l_int)];
+ char protocol_l_[PADL_(l_int)]; l_int protocol; char protocol_r_[PADR_(l_int)];
+};
+struct linux_socketpair_args {
+ char domain_l_[PADL_(l_int)]; l_int domain; char domain_r_[PADR_(l_int)];
+ char type_l_[PADL_(l_int)]; l_int type; char type_r_[PADR_(l_int)];
+ char protocol_l_[PADL_(l_int)]; l_int protocol; char protocol_r_[PADR_(l_int)];
+ char rsv_l_[PADL_(l_uintptr_t)]; l_uintptr_t rsv; char rsv_r_[PADR_(l_uintptr_t)];
+};
+struct linux_bind_args {
+ char s_l_[PADL_(l_int)]; l_int s; char s_r_[PADR_(l_int)];
+ char name_l_[PADL_(l_uintptr_t)]; l_uintptr_t name; char name_r_[PADR_(l_uintptr_t)];
+ char namelen_l_[PADL_(l_int)]; l_int namelen; char namelen_r_[PADR_(l_int)];
+};
+struct linux_connect_args {
+ char s_l_[PADL_(l_int)]; l_int s; char s_r_[PADR_(l_int)];
+ char name_l_[PADL_(l_uintptr_t)]; l_uintptr_t name; char name_r_[PADR_(l_uintptr_t)];
+ char namelen_l_[PADL_(l_int)]; l_int namelen; char namelen_r_[PADR_(l_int)];
+};
+struct linux_listen_args {
+ char s_l_[PADL_(l_int)]; l_int s; char s_r_[PADR_(l_int)];
+ char backlog_l_[PADL_(l_int)]; l_int backlog; char backlog_r_[PADR_(l_int)];
+};
+struct linux_accept4_args {
+ char s_l_[PADL_(l_int)]; l_int s; char s_r_[PADR_(l_int)];
+ char addr_l_[PADL_(l_uintptr_t)]; l_uintptr_t addr; char addr_r_[PADR_(l_uintptr_t)];
+ char namelen_l_[PADL_(l_uintptr_t)]; l_uintptr_t namelen; char namelen_r_[PADR_(l_uintptr_t)];
+ char flags_l_[PADL_(l_int)]; l_int flags; char flags_r_[PADR_(l_int)];
+};
+struct linux_getsockopt_args {
+ char s_l_[PADL_(l_int)]; l_int s; char s_r_[PADR_(l_int)];
+ char level_l_[PADL_(l_int)]; l_int level; char level_r_[PADR_(l_int)];
+ char optname_l_[PADL_(l_int)]; l_int optname; char optname_r_[PADR_(l_int)];
+ char optval_l_[PADL_(l_uintptr_t)]; l_uintptr_t optval; char optval_r_[PADR_(l_uintptr_t)];
+ char optlen_l_[PADL_(l_uintptr_t)]; l_uintptr_t optlen; char optlen_r_[PADR_(l_uintptr_t)];
+};
+struct linux_setsockopt_args {
+ char s_l_[PADL_(l_int)]; l_int s; char s_r_[PADR_(l_int)];
+ char level_l_[PADL_(l_int)]; l_int level; char level_r_[PADR_(l_int)];
+ char optname_l_[PADL_(l_int)]; l_int optname; char optname_r_[PADR_(l_int)];
+ char optval_l_[PADL_(l_uintptr_t)]; l_uintptr_t optval; char optval_r_[PADR_(l_uintptr_t)];
+ char optlen_l_[PADL_(l_int)]; l_int optlen; char optlen_r_[PADR_(l_int)];
+};
+struct linux_getsockname_args {
+ char s_l_[PADL_(l_int)]; l_int s; char s_r_[PADR_(l_int)];
+ char addr_l_[PADL_(l_uintptr_t)]; l_uintptr_t addr; char addr_r_[PADR_(l_uintptr_t)];
+ char namelen_l_[PADL_(l_uintptr_t)]; l_uintptr_t namelen; char namelen_r_[PADR_(l_uintptr_t)];
+};
+struct linux_getpeername_args {
+ char s_l_[PADL_(l_int)]; l_int s; char s_r_[PADR_(l_int)];
+ char addr_l_[PADL_(l_uintptr_t)]; l_uintptr_t addr; char addr_r_[PADR_(l_uintptr_t)];
+ char namelen_l_[PADL_(l_uintptr_t)]; l_uintptr_t namelen; char namelen_r_[PADR_(l_uintptr_t)];
+};
+struct linux_sendto_args {
+ char s_l_[PADL_(l_int)]; l_int s; char s_r_[PADR_(l_int)];
+ char msg_l_[PADL_(l_uintptr_t)]; l_uintptr_t msg; char msg_r_[PADR_(l_uintptr_t)];
+ char len_l_[PADL_(l_int)]; l_int len; char len_r_[PADR_(l_int)];
+ char flags_l_[PADL_(l_int)]; l_int flags; char flags_r_[PADR_(l_int)];
+ char to_l_[PADL_(l_uintptr_t)]; l_uintptr_t to; char to_r_[PADR_(l_uintptr_t)];
+ char tolen_l_[PADL_(l_int)]; l_int tolen; char tolen_r_[PADR_(l_int)];
+};
+struct linux_sendmsg_args {
+ char s_l_[PADL_(l_int)]; l_int s; char s_r_[PADR_(l_int)];
+ char msg_l_[PADL_(l_uintptr_t)]; l_uintptr_t msg; char msg_r_[PADR_(l_uintptr_t)];
+ char flags_l_[PADL_(l_int)]; l_int flags; char flags_r_[PADR_(l_int)];
+};
+struct linux_recvfrom_args {
+ char s_l_[PADL_(l_int)]; l_int s; char s_r_[PADR_(l_int)];
+ char buf_l_[PADL_(l_uintptr_t)]; l_uintptr_t buf; char buf_r_[PADR_(l_uintptr_t)];
+ char len_l_[PADL_(l_size_t)]; l_size_t len; char len_r_[PADR_(l_size_t)];
+ char flags_l_[PADL_(l_int)]; l_int flags; char flags_r_[PADR_(l_int)];
+ char from_l_[PADL_(l_uintptr_t)]; l_uintptr_t from; char from_r_[PADR_(l_uintptr_t)];
+ char fromlen_l_[PADL_(l_uintptr_t)]; l_uintptr_t fromlen; char fromlen_r_[PADR_(l_uintptr_t)];
+};
+struct linux_recvmsg_args {
+ char s_l_[PADL_(l_int)]; l_int s; char s_r_[PADR_(l_int)];
+ char msg_l_[PADL_(l_uintptr_t)]; l_uintptr_t msg; char msg_r_[PADR_(l_uintptr_t)];
+ char flags_l_[PADL_(l_int)]; l_int flags; char flags_r_[PADR_(l_int)];
+};
+struct linux_shutdown_args {
+ char s_l_[PADL_(l_int)]; l_int s; char s_r_[PADR_(l_int)];
+ char how_l_[PADL_(l_int)]; l_int how; char how_r_[PADR_(l_int)];
+};
+struct linux_userfaultfd_args {
+ char flags_l_[PADL_(l_int)]; l_int flags; char flags_r_[PADR_(l_int)];
+};
+struct linux_membarrier_args {
+ char cmd_l_[PADL_(l_int)]; l_int cmd; char cmd_r_[PADR_(l_int)];
+ char flags_l_[PADL_(l_int)]; l_int flags; char flags_r_[PADR_(l_int)];
+};
+struct linux_mlock2_args {
+ char start_l_[PADL_(l_ulong)]; l_ulong start; char start_r_[PADR_(l_ulong)];
+ char len_l_[PADL_(l_size_t)]; l_size_t len; char len_r_[PADR_(l_size_t)];
+ char flags_l_[PADL_(l_int)]; l_int flags; char flags_r_[PADR_(l_int)];
+};
+struct linux_copy_file_range_args {
+ char fd_in_l_[PADL_(l_int)]; l_int fd_in; char fd_in_r_[PADR_(l_int)];
+ char off_in_l_[PADL_(l_loff_t *)]; l_loff_t * off_in; char off_in_r_[PADR_(l_loff_t *)];
+ char fd_out_l_[PADL_(l_int)]; l_int fd_out; char fd_out_r_[PADR_(l_int)];
+ char off_out_l_[PADL_(l_loff_t *)]; l_loff_t * off_out; char off_out_r_[PADR_(l_loff_t *)];
+ char len_l_[PADL_(l_size_t)]; l_size_t len; char len_r_[PADR_(l_size_t)];
+ char flags_l_[PADL_(l_uint)]; l_uint flags; char flags_r_[PADR_(l_uint)];
+};
+struct linux_preadv2_args {
+ char fd_l_[PADL_(l_ulong)]; l_ulong fd; char fd_r_[PADR_(l_ulong)];
+ char vec_l_[PADL_(const struct iovec *)]; const struct iovec * vec; char vec_r_[PADR_(const struct iovec *)];
+ char vlen_l_[PADL_(l_ulong)]; l_ulong vlen; char vlen_r_[PADR_(l_ulong)];
+ char pos_l_l_[PADL_(l_ulong)]; l_ulong pos_l; char pos_l_r_[PADR_(l_ulong)];
+ char pos_h_l_[PADL_(l_ulong)]; l_ulong pos_h; char pos_h_r_[PADR_(l_ulong)];
+ char flags_l_[PADL_(l_int)]; l_int flags; char flags_r_[PADR_(l_int)];
+};
+struct linux_pwritev2_args {
+ char fd_l_[PADL_(l_ulong)]; l_ulong fd; char fd_r_[PADR_(l_ulong)];
+ char vec_l_[PADL_(const struct iovec *)]; const struct iovec * vec; char vec_r_[PADR_(const struct iovec *)];
+ char vlen_l_[PADL_(l_ulong)]; l_ulong vlen; char vlen_r_[PADR_(l_ulong)];
+ char pos_l_l_[PADL_(l_ulong)]; l_ulong pos_l; char pos_l_r_[PADR_(l_ulong)];
+ char pos_h_l_[PADL_(l_ulong)]; l_ulong pos_h; char pos_h_r_[PADR_(l_ulong)];
+ char flags_l_[PADL_(l_int)]; l_int flags; char flags_r_[PADR_(l_int)];
+};
+struct linux_pkey_mprotect_args {
+ char start_l_[PADL_(l_ulong)]; l_ulong start; char start_r_[PADR_(l_ulong)];
+ char len_l_[PADL_(l_size_t)]; l_size_t len; char len_r_[PADR_(l_size_t)];
+ char prot_l_[PADL_(l_ulong)]; l_ulong prot; char prot_r_[PADR_(l_ulong)];
+ char pkey_l_[PADL_(l_int)]; l_int pkey; char pkey_r_[PADR_(l_int)];
+};
+struct linux_pkey_alloc_args {
+ char flags_l_[PADL_(l_ulong)]; l_ulong flags; char flags_r_[PADR_(l_ulong)];
+ char init_val_l_[PADL_(l_ulong)]; l_ulong init_val; char init_val_r_[PADR_(l_ulong)];
+};
+struct linux_pkey_free_args {
+ char pkey_l_[PADL_(l_int)]; l_int pkey; char pkey_r_[PADR_(l_int)];
};
#define nosys linux_nosys
int linux_exit(struct thread *, struct linux_exit_args *);
@@ -1424,7 +1635,7 @@ int linux_pipe2(struct thread *, struct linux_pipe2_args *);
int linux_inotify_init1(struct thread *, struct linux_inotify_init1_args *);
int linux_preadv(struct thread *, struct linux_preadv_args *);
int linux_pwritev(struct thread *, struct linux_pwritev_args *);
-int linux_rt_tsigqueueinfo(struct thread *, struct linux_rt_tsigqueueinfo_args *);
+int linux_rt_tgsigqueueinfo(struct thread *, struct linux_rt_tgsigqueueinfo_args *);
int linux_perf_event_open(struct thread *, struct linux_perf_event_open_args *);
int linux_recvmmsg(struct thread *, struct linux_recvmmsg_args *);
int linux_fanotify_init(struct thread *, struct linux_fanotify_init_args *);
@@ -1438,6 +1649,40 @@ int linux_sendmmsg(struct thread *, struct linux_sendmmsg_args *);
int linux_setns(struct thread *, struct linux_setns_args *);
int linux_process_vm_readv(struct thread *, struct linux_process_vm_readv_args *);
int linux_process_vm_writev(struct thread *, struct linux_process_vm_writev_args *);
+int linux_kcmp(struct thread *, struct linux_kcmp_args *);
+int linux_finit_module(struct thread *, struct linux_finit_module_args *);
+int linux_sched_setattr(struct thread *, struct linux_sched_setattr_args *);
+int linux_sched_getattr(struct thread *, struct linux_sched_getattr_args *);
+int linux_renameat2(struct thread *, struct linux_renameat2_args *);
+int linux_seccomp(struct thread *, struct linux_seccomp_args *);
+int linux_getrandom(struct thread *, struct linux_getrandom_args *);
+int linux_memfd_create(struct thread *, struct linux_memfd_create_args *);
+int linux_bpf(struct thread *, struct linux_bpf_args *);
+int linux_execveat(struct thread *, struct linux_execveat_args *);
+int linux_socket(struct thread *, struct linux_socket_args *);
+int linux_socketpair(struct thread *, struct linux_socketpair_args *);
+int linux_bind(struct thread *, struct linux_bind_args *);
+int linux_connect(struct thread *, struct linux_connect_args *);
+int linux_listen(struct thread *, struct linux_listen_args *);
+int linux_accept4(struct thread *, struct linux_accept4_args *);
+int linux_getsockopt(struct thread *, struct linux_getsockopt_args *);
+int linux_setsockopt(struct thread *, struct linux_setsockopt_args *);
+int linux_getsockname(struct thread *, struct linux_getsockname_args *);
+int linux_getpeername(struct thread *, struct linux_getpeername_args *);
+int linux_sendto(struct thread *, struct linux_sendto_args *);
+int linux_sendmsg(struct thread *, struct linux_sendmsg_args *);
+int linux_recvfrom(struct thread *, struct linux_recvfrom_args *);
+int linux_recvmsg(struct thread *, struct linux_recvmsg_args *);
+int linux_shutdown(struct thread *, struct linux_shutdown_args *);
+int linux_userfaultfd(struct thread *, struct linux_userfaultfd_args *);
+int linux_membarrier(struct thread *, struct linux_membarrier_args *);
+int linux_mlock2(struct thread *, struct linux_mlock2_args *);
+int linux_copy_file_range(struct thread *, struct linux_copy_file_range_args *);
+int linux_preadv2(struct thread *, struct linux_preadv2_args *);
+int linux_pwritev2(struct thread *, struct linux_pwritev2_args *);
+int linux_pkey_mprotect(struct thread *, struct linux_pkey_mprotect_args *);
+int linux_pkey_alloc(struct thread *, struct linux_pkey_alloc_args *);
+int linux_pkey_free(struct thread *, struct linux_pkey_free_args *);
#ifdef COMPAT_43
@@ -1736,7 +1981,7 @@ int linux_process_vm_writev(struct thread *, struct linux_process_vm_writev_args
#define LINUX32_SYS_AUE_linux_inotify_init1 AUE_NULL
#define LINUX32_SYS_AUE_linux_preadv AUE_NULL
#define LINUX32_SYS_AUE_linux_pwritev AUE_NULL
-#define LINUX32_SYS_AUE_linux_rt_tsigqueueinfo AUE_NULL
+#define LINUX32_SYS_AUE_linux_rt_tgsigqueueinfo AUE_NULL
#define LINUX32_SYS_AUE_linux_perf_event_open AUE_NULL
#define LINUX32_SYS_AUE_linux_recvmmsg AUE_NULL
#define LINUX32_SYS_AUE_linux_fanotify_init AUE_NULL
@@ -1750,6 +1995,40 @@ int linux_process_vm_writev(struct thread *, struct linux_process_vm_writev_args
#define LINUX32_SYS_AUE_linux_setns AUE_NULL
#define LINUX32_SYS_AUE_linux_process_vm_readv AUE_NULL
#define LINUX32_SYS_AUE_linux_process_vm_writev AUE_NULL
+#define LINUX32_SYS_AUE_linux_kcmp AUE_NULL
+#define LINUX32_SYS_AUE_linux_finit_module AUE_NULL
+#define LINUX32_SYS_AUE_linux_sched_setattr AUE_NULL
+#define LINUX32_SYS_AUE_linux_sched_getattr AUE_NULL
+#define LINUX32_SYS_AUE_linux_renameat2 AUE_NULL
+#define LINUX32_SYS_AUE_linux_seccomp AUE_NULL
+#define LINUX32_SYS_AUE_linux_getrandom AUE_NULL
+#define LINUX32_SYS_AUE_linux_memfd_create AUE_NULL
+#define LINUX32_SYS_AUE_linux_bpf AUE_NULL
+#define LINUX32_SYS_AUE_linux_execveat AUE_NULL
+#define LINUX32_SYS_AUE_linux_socket AUE_SOCKET
+#define LINUX32_SYS_AUE_linux_socketpair AUE_SOCKETPAIR
+#define LINUX32_SYS_AUE_linux_bind AUE_BIND
+#define LINUX32_SYS_AUE_linux_connect AUE_CONNECT
+#define LINUX32_SYS_AUE_linux_listen AUE_LISTEN
+#define LINUX32_SYS_AUE_linux_accept4 AUE_ACCEPT
+#define LINUX32_SYS_AUE_linux_getsockopt AUE_GETSOCKOPT
+#define LINUX32_SYS_AUE_linux_setsockopt AUE_SETSOCKOPT
+#define LINUX32_SYS_AUE_linux_getsockname AUE_GETSOCKNAME
+#define LINUX32_SYS_AUE_linux_getpeername AUE_GETPEERNAME
+#define LINUX32_SYS_AUE_linux_sendto AUE_SENDTO
+#define LINUX32_SYS_AUE_linux_sendmsg AUE_SENDMSG
+#define LINUX32_SYS_AUE_linux_recvfrom AUE_RECVFROM
+#define LINUX32_SYS_AUE_linux_recvmsg AUE_RECVMSG
+#define LINUX32_SYS_AUE_linux_shutdown AUE_NULL
+#define LINUX32_SYS_AUE_linux_userfaultfd AUE_NULL
+#define LINUX32_SYS_AUE_linux_membarrier AUE_NULL
+#define LINUX32_SYS_AUE_linux_mlock2 AUE_NULL
+#define LINUX32_SYS_AUE_linux_copy_file_range AUE_NULL
+#define LINUX32_SYS_AUE_linux_preadv2 AUE_NULL
+#define LINUX32_SYS_AUE_linux_pwritev2 AUE_NULL
+#define LINUX32_SYS_AUE_linux_pkey_mprotect AUE_NULL
+#define LINUX32_SYS_AUE_linux_pkey_alloc AUE_NULL
+#define LINUX32_SYS_AUE_linux_pkey_free AUE_NULL
#undef PAD_
#undef PADL_
diff --git a/sys/amd64/linux32/linux32_syscall.h b/sys/amd64/linux32/linux32_syscall.h
index 862520a..bf653ed 100644
--- a/sys/amd64/linux32/linux32_syscall.h
+++ b/sys/amd64/linux32/linux32_syscall.h
@@ -3,7 +3,7 @@
*
* DO NOT EDIT-- this file is automatically generated.
* $FreeBSD$
- * created from FreeBSD: head/sys/amd64/linux32/syscalls.master 302515 2016-07-10 08:15:50Z dchagin
+ * created from FreeBSD: head/sys/amd64/linux32/syscalls.master 313284 2017-02-05 14:17:09Z dchagin
*/
#define LINUX32_SYS_linux_exit 1
@@ -307,7 +307,7 @@
#define LINUX32_SYS_linux_inotify_init1 332
#define LINUX32_SYS_linux_preadv 333
#define LINUX32_SYS_linux_pwritev 334
-#define LINUX32_SYS_linux_rt_tsigqueueinfo 335
+#define LINUX32_SYS_linux_rt_tgsigqueueinfo 335
#define LINUX32_SYS_linux_perf_event_open 336
#define LINUX32_SYS_linux_recvmmsg 337
#define LINUX32_SYS_linux_fanotify_init 338
@@ -321,4 +321,38 @@
#define LINUX32_SYS_linux_setns 346
#define LINUX32_SYS_linux_process_vm_readv 347
#define LINUX32_SYS_linux_process_vm_writev 348
-#define LINUX32_SYS_MAXSYSCALL 350
+#define LINUX32_SYS_linux_kcmp 349
+#define LINUX32_SYS_linux_finit_module 350
+#define LINUX32_SYS_linux_sched_setattr 351
+#define LINUX32_SYS_linux_sched_getattr 352
+#define LINUX32_SYS_linux_renameat2 353
+#define LINUX32_SYS_linux_seccomp 354
+#define LINUX32_SYS_linux_getrandom 355
+#define LINUX32_SYS_linux_memfd_create 356
+#define LINUX32_SYS_linux_bpf 357
+#define LINUX32_SYS_linux_execveat 358
+#define LINUX32_SYS_linux_socket 359
+#define LINUX32_SYS_linux_socketpair 360
+#define LINUX32_SYS_linux_bind 361
+#define LINUX32_SYS_linux_connect 362
+#define LINUX32_SYS_linux_listen 363
+#define LINUX32_SYS_linux_accept4 364
+#define LINUX32_SYS_linux_getsockopt 365
+#define LINUX32_SYS_linux_setsockopt 366
+#define LINUX32_SYS_linux_getsockname 367
+#define LINUX32_SYS_linux_getpeername 368
+#define LINUX32_SYS_linux_sendto 369
+#define LINUX32_SYS_linux_sendmsg 370
+#define LINUX32_SYS_linux_recvfrom 371
+#define LINUX32_SYS_linux_recvmsg 372
+#define LINUX32_SYS_linux_shutdown 373
+#define LINUX32_SYS_linux_userfaultfd 374
+#define LINUX32_SYS_linux_membarrier 375
+#define LINUX32_SYS_linux_mlock2 376
+#define LINUX32_SYS_linux_copy_file_range 377
+#define LINUX32_SYS_linux_preadv2 378
+#define LINUX32_SYS_linux_pwritev2 379
+#define LINUX32_SYS_linux_pkey_mprotect 380
+#define LINUX32_SYS_linux_pkey_alloc 381
+#define LINUX32_SYS_linux_pkey_free 382
+#define LINUX32_SYS_MAXSYSCALL 384
diff --git a/sys/amd64/linux32/linux32_syscalls.c b/sys/amd64/linux32/linux32_syscalls.c
index d05c4a0..fe18999 100644
--- a/sys/amd64/linux32/linux32_syscalls.c
+++ b/sys/amd64/linux32/linux32_syscalls.c
@@ -3,7 +3,7 @@
*
* DO NOT EDIT-- this file is automatically generated.
* $FreeBSD$
- * created from FreeBSD: head/sys/amd64/linux32/syscalls.master 302515 2016-07-10 08:15:50Z dchagin
+ * created from FreeBSD: head/sys/amd64/linux32/syscalls.master 313284 2017-02-05 14:17:09Z dchagin
*/
const char *linux32_syscallnames[] = {
@@ -343,7 +343,7 @@ const char *linux32_syscallnames[] = {
"linux_inotify_init1", /* 332 = linux_inotify_init1 */
"linux_preadv", /* 333 = linux_preadv */
"linux_pwritev", /* 334 = linux_pwritev */
- "linux_rt_tsigqueueinfo", /* 335 = linux_rt_tsigqueueinfo */
+ "linux_rt_tgsigqueueinfo", /* 335 = linux_rt_tgsigqueueinfo */
"linux_perf_event_open", /* 336 = linux_perf_event_open */
"linux_recvmmsg", /* 337 = linux_recvmmsg */
"linux_fanotify_init", /* 338 = linux_fanotify_init */
@@ -357,5 +357,39 @@ const char *linux32_syscallnames[] = {
"linux_setns", /* 346 = linux_setns */
"linux_process_vm_readv", /* 347 = linux_process_vm_readv */
"linux_process_vm_writev", /* 348 = linux_process_vm_writev */
- "#349", /* 349 = nosys */
+ "linux_kcmp", /* 349 = linux_kcmp */
+ "linux_finit_module", /* 350 = linux_finit_module */
+ "linux_sched_setattr", /* 351 = linux_sched_setattr */
+ "linux_sched_getattr", /* 352 = linux_sched_getattr */
+ "linux_renameat2", /* 353 = linux_renameat2 */
+ "linux_seccomp", /* 354 = linux_seccomp */
+ "linux_getrandom", /* 355 = linux_getrandom */
+ "linux_memfd_create", /* 356 = linux_memfd_create */
+ "linux_bpf", /* 357 = linux_bpf */
+ "linux_execveat", /* 358 = linux_execveat */
+ "linux_socket", /* 359 = linux_socket */
+ "linux_socketpair", /* 360 = linux_socketpair */
+ "linux_bind", /* 361 = linux_bind */
+ "linux_connect", /* 362 = linux_connect */
+ "linux_listen", /* 363 = linux_listen */
+ "linux_accept4", /* 364 = linux_accept4 */
+ "linux_getsockopt", /* 365 = linux_getsockopt */
+ "linux_setsockopt", /* 366 = linux_setsockopt */
+ "linux_getsockname", /* 367 = linux_getsockname */
+ "linux_getpeername", /* 368 = linux_getpeername */
+ "linux_sendto", /* 369 = linux_sendto */
+ "linux_sendmsg", /* 370 = linux_sendmsg */
+ "linux_recvfrom", /* 371 = linux_recvfrom */
+ "linux_recvmsg", /* 372 = linux_recvmsg */
+ "linux_shutdown", /* 373 = linux_shutdown */
+ "linux_userfaultfd", /* 374 = linux_userfaultfd */
+ "linux_membarrier", /* 375 = linux_membarrier */
+ "linux_mlock2", /* 376 = linux_mlock2 */
+ "linux_copy_file_range", /* 377 = linux_copy_file_range */
+ "linux_preadv2", /* 378 = linux_preadv2 */
+ "linux_pwritev2", /* 379 = linux_pwritev2 */
+ "linux_pkey_mprotect", /* 380 = linux_pkey_mprotect */
+ "linux_pkey_alloc", /* 381 = linux_pkey_alloc */
+ "linux_pkey_free", /* 382 = linux_pkey_free */
+ "#383", /* 383 = nosys */
};
diff --git a/sys/amd64/linux32/linux32_sysent.c b/sys/amd64/linux32/linux32_sysent.c
index 73ce67a..9f94ebf 100644
--- a/sys/amd64/linux32/linux32_sysent.c
+++ b/sys/amd64/linux32/linux32_sysent.c
@@ -3,7 +3,7 @@
*
* DO NOT EDIT-- this file is automatically generated.
* $FreeBSD$
- * created from FreeBSD: head/sys/amd64/linux32/syscalls.master 302515 2016-07-10 08:15:50Z dchagin
+ * created from FreeBSD: head/sys/amd64/linux32/syscalls.master 313284 2017-02-05 14:17:09Z dchagin
*/
#include "opt_compat.h"
@@ -352,9 +352,9 @@ struct sysent linux32_sysent[] = {
{ AS(linux_dup3_args), (sy_call_t *)linux_dup3, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 330 = linux_dup3 */
{ AS(linux_pipe2_args), (sy_call_t *)linux_pipe2, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 331 = linux_pipe2 */
{ 0, (sy_call_t *)linux_inotify_init1, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 332 = linux_inotify_init1 */
- { 0, (sy_call_t *)linux_preadv, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 333 = linux_preadv */
- { 0, (sy_call_t *)linux_pwritev, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 334 = linux_pwritev */
- { 0, (sy_call_t *)linux_rt_tsigqueueinfo, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 335 = linux_rt_tsigqueueinfo */
+ { AS(linux_preadv_args), (sy_call_t *)linux_preadv, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 333 = linux_preadv */
+ { AS(linux_pwritev_args), (sy_call_t *)linux_pwritev, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 334 = linux_pwritev */
+ { AS(linux_rt_tgsigqueueinfo_args), (sy_call_t *)linux_rt_tgsigqueueinfo, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 335 = linux_rt_tgsigqueueinfo */
{ 0, (sy_call_t *)linux_perf_event_open, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 336 = linux_perf_event_open */
{ AS(linux_recvmmsg_args), (sy_call_t *)linux_recvmmsg, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 337 = linux_recvmmsg */
{ 0, (sy_call_t *)linux_fanotify_init, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 338 = linux_fanotify_init */
@@ -366,7 +366,41 @@ struct sysent linux32_sysent[] = {
{ AS(linux_syncfs_args), (sy_call_t *)linux_syncfs, AUE_SYNC, NULL, 0, 0, 0, SY_THR_STATIC }, /* 344 = linux_syncfs */
{ AS(linux_sendmmsg_args), (sy_call_t *)linux_sendmmsg, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 345 = linux_sendmmsg */
{ 0, (sy_call_t *)linux_setns, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 346 = linux_setns */
- { 0, (sy_call_t *)linux_process_vm_readv, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 347 = linux_process_vm_readv */
- { 0, (sy_call_t *)linux_process_vm_writev, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 348 = linux_process_vm_writev */
- { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 349 = nosys */
+ { AS(linux_process_vm_readv_args), (sy_call_t *)linux_process_vm_readv, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 347 = linux_process_vm_readv */
+ { AS(linux_process_vm_writev_args), (sy_call_t *)linux_process_vm_writev, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 348 = linux_process_vm_writev */
+ { AS(linux_kcmp_args), (sy_call_t *)linux_kcmp, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 349 = linux_kcmp */
+ { AS(linux_finit_module_args), (sy_call_t *)linux_finit_module, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 350 = linux_finit_module */
+ { AS(linux_sched_setattr_args), (sy_call_t *)linux_sched_setattr, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 351 = linux_sched_setattr */
+ { AS(linux_sched_getattr_args), (sy_call_t *)linux_sched_getattr, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 352 = linux_sched_getattr */
+ { AS(linux_renameat2_args), (sy_call_t *)linux_renameat2, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 353 = linux_renameat2 */
+ { AS(linux_seccomp_args), (sy_call_t *)linux_seccomp, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 354 = linux_seccomp */
+ { AS(linux_getrandom_args), (sy_call_t *)linux_getrandom, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 355 = linux_getrandom */
+ { AS(linux_memfd_create_args), (sy_call_t *)linux_memfd_create, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 356 = linux_memfd_create */
+ { AS(linux_bpf_args), (sy_call_t *)linux_bpf, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 357 = linux_bpf */
+ { AS(linux_execveat_args), (sy_call_t *)linux_execveat, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 358 = linux_execveat */
+ { AS(linux_socket_args), (sy_call_t *)linux_socket, AUE_SOCKET, NULL, 0, 0, 0, SY_THR_STATIC }, /* 359 = linux_socket */
+ { AS(linux_socketpair_args), (sy_call_t *)linux_socketpair, AUE_SOCKETPAIR, NULL, 0, 0, 0, SY_THR_STATIC }, /* 360 = linux_socketpair */
+ { AS(linux_bind_args), (sy_call_t *)linux_bind, AUE_BIND, NULL, 0, 0, 0, SY_THR_STATIC }, /* 361 = linux_bind */
+ { AS(linux_connect_args), (sy_call_t *)linux_connect, AUE_CONNECT, NULL, 0, 0, 0, SY_THR_STATIC }, /* 362 = linux_connect */
+ { AS(linux_listen_args), (sy_call_t *)linux_listen, AUE_LISTEN, NULL, 0, 0, 0, SY_THR_STATIC }, /* 363 = linux_listen */
+ { AS(linux_accept4_args), (sy_call_t *)linux_accept4, AUE_ACCEPT, NULL, 0, 0, 0, SY_THR_STATIC }, /* 364 = linux_accept4 */
+ { AS(linux_getsockopt_args), (sy_call_t *)linux_getsockopt, AUE_GETSOCKOPT, NULL, 0, 0, 0, SY_THR_STATIC }, /* 365 = linux_getsockopt */
+ { AS(linux_setsockopt_args), (sy_call_t *)linux_setsockopt, AUE_SETSOCKOPT, NULL, 0, 0, 0, SY_THR_STATIC }, /* 366 = linux_setsockopt */
+ { AS(linux_getsockname_args), (sy_call_t *)linux_getsockname, AUE_GETSOCKNAME, NULL, 0, 0, 0, SY_THR_STATIC }, /* 367 = linux_getsockname */
+ { AS(linux_getpeername_args), (sy_call_t *)linux_getpeername, AUE_GETPEERNAME, NULL, 0, 0, 0, SY_THR_STATIC }, /* 368 = linux_getpeername */
+ { AS(linux_sendto_args), (sy_call_t *)linux_sendto, AUE_SENDTO, NULL, 0, 0, 0, SY_THR_STATIC }, /* 369 = linux_sendto */
+ { AS(linux_sendmsg_args), (sy_call_t *)linux_sendmsg, AUE_SENDMSG, NULL, 0, 0, 0, SY_THR_STATIC }, /* 370 = linux_sendmsg */
+ { AS(linux_recvfrom_args), (sy_call_t *)linux_recvfrom, AUE_RECVFROM, NULL, 0, 0, 0, SY_THR_STATIC }, /* 371 = linux_recvfrom */
+ { AS(linux_recvmsg_args), (sy_call_t *)linux_recvmsg, AUE_RECVMSG, NULL, 0, 0, 0, SY_THR_STATIC }, /* 372 = linux_recvmsg */
+ { AS(linux_shutdown_args), (sy_call_t *)linux_shutdown, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 373 = linux_shutdown */
+ { AS(linux_userfaultfd_args), (sy_call_t *)linux_userfaultfd, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 374 = linux_userfaultfd */
+ { AS(linux_membarrier_args), (sy_call_t *)linux_membarrier, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 375 = linux_membarrier */
+ { AS(linux_mlock2_args), (sy_call_t *)linux_mlock2, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 376 = linux_mlock2 */
+ { AS(linux_copy_file_range_args), (sy_call_t *)linux_copy_file_range, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 377 = linux_copy_file_range */
+ { AS(linux_preadv2_args), (sy_call_t *)linux_preadv2, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 378 = linux_preadv2 */
+ { AS(linux_pwritev2_args), (sy_call_t *)linux_pwritev2, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 379 = linux_pwritev2 */
+ { AS(linux_pkey_mprotect_args), (sy_call_t *)linux_pkey_mprotect, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 380 = linux_pkey_mprotect */
+ { AS(linux_pkey_alloc_args), (sy_call_t *)linux_pkey_alloc, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 381 = linux_pkey_alloc */
+ { AS(linux_pkey_free_args), (sy_call_t *)linux_pkey_free, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 382 = linux_pkey_free */
+ { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 383 = nosys */
};
diff --git a/sys/amd64/linux32/linux32_systrace_args.c b/sys/amd64/linux32/linux32_systrace_args.c
index f3bde85..2e4c2be 100644
--- a/sys/amd64/linux32/linux32_systrace_args.c
+++ b/sys/amd64/linux32/linux32_systrace_args.c
@@ -2263,17 +2263,34 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args)
}
/* linux_preadv */
case 333: {
- *n_args = 0;
+ struct linux_preadv_args *p = params;
+ iarg[0] = p->fd; /* l_ulong */
+ uarg[1] = (intptr_t) p->vec; /* struct iovec * */
+ iarg[2] = p->vlen; /* l_ulong */
+ iarg[3] = p->pos_l; /* l_ulong */
+ iarg[4] = p->pos_h; /* l_ulong */
+ *n_args = 5;
break;
}
/* linux_pwritev */
case 334: {
- *n_args = 0;
+ struct linux_pwritev_args *p = params;
+ iarg[0] = p->fd; /* l_ulong */
+ uarg[1] = (intptr_t) p->vec; /* struct iovec * */
+ iarg[2] = p->vlen; /* l_ulong */
+ iarg[3] = p->pos_l; /* l_ulong */
+ iarg[4] = p->pos_h; /* l_ulong */
+ *n_args = 5;
break;
}
- /* linux_rt_tsigqueueinfo */
+ /* linux_rt_tgsigqueueinfo */
case 335: {
- *n_args = 0;
+ struct linux_rt_tgsigqueueinfo_args *p = params;
+ iarg[0] = p->tgid; /* l_pid_t */
+ iarg[1] = p->tid; /* l_pid_t */
+ iarg[2] = p->sig; /* l_int */
+ uarg[3] = (intptr_t) p->uinfo; /* l_siginfo_t * */
+ *n_args = 4;
break;
}
/* linux_perf_event_open */
@@ -2351,12 +2368,352 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args)
}
/* linux_process_vm_readv */
case 347: {
- *n_args = 0;
+ struct linux_process_vm_readv_args *p = params;
+ iarg[0] = p->pid; /* l_pid_t */
+ uarg[1] = (intptr_t) p->lvec; /* const struct iovec * */
+ iarg[2] = p->liovcnt; /* l_ulong */
+ uarg[3] = (intptr_t) p->rvec; /* const struct iovec * */
+ iarg[4] = p->riovcnt; /* l_ulong */
+ iarg[5] = p->flags; /* l_ulong */
+ *n_args = 6;
break;
}
/* linux_process_vm_writev */
case 348: {
- *n_args = 0;
+ struct linux_process_vm_writev_args *p = params;
+ iarg[0] = p->pid; /* l_pid_t */
+ uarg[1] = (intptr_t) p->lvec; /* const struct iovec * */
+ iarg[2] = p->liovcnt; /* l_ulong */
+ uarg[3] = (intptr_t) p->rvec; /* const struct iovec * */
+ iarg[4] = p->riovcnt; /* l_ulong */
+ iarg[5] = p->flags; /* l_ulong */
+ *n_args = 6;
+ break;
+ }
+ /* linux_kcmp */
+ case 349: {
+ struct linux_kcmp_args *p = params;
+ iarg[0] = p->pid1; /* l_pid_t */
+ iarg[1] = p->pid2; /* l_pid_t */
+ iarg[2] = p->type; /* l_int */
+ iarg[3] = p->idx1; /* l_ulong */
+ iarg[4] = p->idx; /* l_ulong */
+ *n_args = 5;
+ break;
+ }
+ /* linux_finit_module */
+ case 350: {
+ struct linux_finit_module_args *p = params;
+ iarg[0] = p->fd; /* l_int */
+ uarg[1] = (intptr_t) p->uargs; /* const char * */
+ iarg[2] = p->flags; /* l_int */
+ *n_args = 3;
+ break;
+ }
+ /* linux_sched_setattr */
+ case 351: {
+ struct linux_sched_setattr_args *p = params;
+ iarg[0] = p->pid; /* l_pid_t */
+ uarg[1] = (intptr_t) p->attr; /* void * */
+ iarg[2] = p->flags; /* l_uint */
+ *n_args = 3;
+ break;
+ }
+ /* linux_sched_getattr */
+ case 352: {
+ struct linux_sched_getattr_args *p = params;
+ iarg[0] = p->pid; /* l_pid_t */
+ uarg[1] = (intptr_t) p->attr; /* void * */
+ iarg[2] = p->size; /* l_uint */
+ iarg[3] = p->flags; /* l_uint */
+ *n_args = 4;
+ break;
+ }
+ /* linux_renameat2 */
+ case 353: {
+ struct linux_renameat2_args *p = params;
+ iarg[0] = p->oldfd; /* l_int */
+ uarg[1] = (intptr_t) p->oldname; /* const char * */
+ iarg[2] = p->newfd; /* l_int */
+ uarg[3] = (intptr_t) p->newname; /* const char * */
+ uarg[4] = p->flags; /* unsigned int */
+ *n_args = 5;
+ break;
+ }
+ /* linux_seccomp */
+ case 354: {
+ struct linux_seccomp_args *p = params;
+ iarg[0] = p->op; /* l_uint */
+ iarg[1] = p->flags; /* l_uint */
+ uarg[2] = (intptr_t) p->uargs; /* const char * */
+ *n_args = 3;
+ break;
+ }
+ /* linux_getrandom */
+ case 355: {
+ struct linux_getrandom_args *p = params;
+ uarg[0] = (intptr_t) p->buf; /* char * */
+ iarg[1] = p->count; /* l_size_t */
+ iarg[2] = p->flags; /* l_uint */
+ *n_args = 3;
+ break;
+ }
+ /* linux_memfd_create */
+ case 356: {
+ struct linux_memfd_create_args *p = params;
+ uarg[0] = (intptr_t) p->uname_ptr; /* const char * */
+ iarg[1] = p->flags; /* l_uint */
+ *n_args = 2;
+ break;
+ }
+ /* linux_bpf */
+ case 357: {
+ struct linux_bpf_args *p = params;
+ iarg[0] = p->cmd; /* l_int */
+ uarg[1] = (intptr_t) p->attr; /* void * */
+ iarg[2] = p->size; /* l_uint */
+ *n_args = 3;
+ break;
+ }
+ /* linux_execveat */
+ case 358: {
+ struct linux_execveat_args *p = params;
+ iarg[0] = p->dfd; /* l_int */
+ uarg[1] = (intptr_t) p->filename; /* const char * */
+ uarg[2] = (intptr_t) p->argv; /* const char ** */
+ uarg[3] = (intptr_t) p->envp; /* const char ** */
+ iarg[4] = p->flags; /* l_int */
+ *n_args = 5;
+ break;
+ }
+ /* linux_socket */
+ case 359: {
+ struct linux_socket_args *p = params;
+ iarg[0] = p->domain; /* l_int */
+ iarg[1] = p->type; /* l_int */
+ iarg[2] = p->protocol; /* l_int */
+ *n_args = 3;
+ break;
+ }
+ /* linux_socketpair */
+ case 360: {
+ struct linux_socketpair_args *p = params;
+ iarg[0] = p->domain; /* l_int */
+ iarg[1] = p->type; /* l_int */
+ iarg[2] = p->protocol; /* l_int */
+ iarg[3] = p->rsv; /* l_uintptr_t */
+ *n_args = 4;
+ break;
+ }
+ /* linux_bind */
+ case 361: {
+ struct linux_bind_args *p = params;
+ iarg[0] = p->s; /* l_int */
+ iarg[1] = p->name; /* l_uintptr_t */
+ iarg[2] = p->namelen; /* l_int */
+ *n_args = 3;
+ break;
+ }
+ /* linux_connect */
+ case 362: {
+ struct linux_connect_args *p = params;
+ iarg[0] = p->s; /* l_int */
+ iarg[1] = p->name; /* l_uintptr_t */
+ iarg[2] = p->namelen; /* l_int */
+ *n_args = 3;
+ break;
+ }
+ /* linux_listen */
+ case 363: {
+ struct linux_listen_args *p = params;
+ iarg[0] = p->s; /* l_int */
+ iarg[1] = p->backlog; /* l_int */
+ *n_args = 2;
+ break;
+ }
+ /* linux_accept4 */
+ case 364: {
+ struct linux_accept4_args *p = params;
+ iarg[0] = p->s; /* l_int */
+ iarg[1] = p->addr; /* l_uintptr_t */
+ iarg[2] = p->namelen; /* l_uintptr_t */
+ iarg[3] = p->flags; /* l_int */
+ *n_args = 4;
+ break;
+ }
+ /* linux_getsockopt */
+ case 365: {
+ struct linux_getsockopt_args *p = params;
+ iarg[0] = p->s; /* l_int */
+ iarg[1] = p->level; /* l_int */
+ iarg[2] = p->optname; /* l_int */
+ iarg[3] = p->optval; /* l_uintptr_t */
+ iarg[4] = p->optlen; /* l_uintptr_t */
+ *n_args = 5;
+ break;
+ }
+ /* linux_setsockopt */
+ case 366: {
+ struct linux_setsockopt_args *p = params;
+ iarg[0] = p->s; /* l_int */
+ iarg[1] = p->level; /* l_int */
+ iarg[2] = p->optname; /* l_int */
+ iarg[3] = p->optval; /* l_uintptr_t */
+ iarg[4] = p->optlen; /* l_int */
+ *n_args = 5;
+ break;
+ }
+ /* linux_getsockname */
+ case 367: {
+ struct linux_getsockname_args *p = params;
+ iarg[0] = p->s; /* l_int */
+ iarg[1] = p->addr; /* l_uintptr_t */
+ iarg[2] = p->namelen; /* l_uintptr_t */
+ *n_args = 3;
+ break;
+ }
+ /* linux_getpeername */
+ case 368: {
+ struct linux_getpeername_args *p = params;
+ iarg[0] = p->s; /* l_int */
+ iarg[1] = p->addr; /* l_uintptr_t */
+ iarg[2] = p->namelen; /* l_uintptr_t */
+ *n_args = 3;
+ break;
+ }
+ /* linux_sendto */
+ case 369: {
+ struct linux_sendto_args *p = params;
+ iarg[0] = p->s; /* l_int */
+ iarg[1] = p->msg; /* l_uintptr_t */
+ iarg[2] = p->len; /* l_int */
+ iarg[3] = p->flags; /* l_int */
+ iarg[4] = p->to; /* l_uintptr_t */
+ iarg[5] = p->tolen; /* l_int */
+ *n_args = 6;
+ break;
+ }
+ /* linux_sendmsg */
+ case 370: {
+ struct linux_sendmsg_args *p = params;
+ iarg[0] = p->s; /* l_int */
+ iarg[1] = p->msg; /* l_uintptr_t */
+ iarg[2] = p->flags; /* l_int */
+ *n_args = 3;
+ break;
+ }
+ /* linux_recvfrom */
+ case 371: {
+ struct linux_recvfrom_args *p = params;
+ iarg[0] = p->s; /* l_int */
+ iarg[1] = p->buf; /* l_uintptr_t */
+ iarg[2] = p->len; /* l_size_t */
+ iarg[3] = p->flags; /* l_int */
+ iarg[4] = p->from; /* l_uintptr_t */
+ iarg[5] = p->fromlen; /* l_uintptr_t */
+ *n_args = 6;
+ break;
+ }
+ /* linux_recvmsg */
+ case 372: {
+ struct linux_recvmsg_args *p = params;
+ iarg[0] = p->s; /* l_int */
+ iarg[1] = p->msg; /* l_uintptr_t */
+ iarg[2] = p->flags; /* l_int */
+ *n_args = 3;
+ break;
+ }
+ /* linux_shutdown */
+ case 373: {
+ struct linux_shutdown_args *p = params;
+ iarg[0] = p->s; /* l_int */
+ iarg[1] = p->how; /* l_int */
+ *n_args = 2;
+ break;
+ }
+ /* linux_userfaultfd */
+ case 374: {
+ struct linux_userfaultfd_args *p = params;
+ iarg[0] = p->flags; /* l_int */
+ *n_args = 1;
+ break;
+ }
+ /* linux_membarrier */
+ case 375: {
+ struct linux_membarrier_args *p = params;
+ iarg[0] = p->cmd; /* l_int */
+ iarg[1] = p->flags; /* l_int */
+ *n_args = 2;
+ break;
+ }
+ /* linux_mlock2 */
+ case 376: {
+ struct linux_mlock2_args *p = params;
+ iarg[0] = p->start; /* l_ulong */
+ iarg[1] = p->len; /* l_size_t */
+ iarg[2] = p->flags; /* l_int */
+ *n_args = 3;
+ break;
+ }
+ /* linux_copy_file_range */
+ case 377: {
+ struct linux_copy_file_range_args *p = params;
+ iarg[0] = p->fd_in; /* l_int */
+ uarg[1] = (intptr_t) p->off_in; /* l_loff_t * */
+ iarg[2] = p->fd_out; /* l_int */
+ uarg[3] = (intptr_t) p->off_out; /* l_loff_t * */
+ iarg[4] = p->len; /* l_size_t */
+ iarg[5] = p->flags; /* l_uint */
+ *n_args = 6;
+ break;
+ }
+ /* linux_preadv2 */
+ case 378: {
+ struct linux_preadv2_args *p = params;
+ iarg[0] = p->fd; /* l_ulong */
+ uarg[1] = (intptr_t) p->vec; /* const struct iovec * */
+ iarg[2] = p->vlen; /* l_ulong */
+ iarg[3] = p->pos_l; /* l_ulong */
+ iarg[4] = p->pos_h; /* l_ulong */
+ iarg[5] = p->flags; /* l_int */
+ *n_args = 6;
+ break;
+ }
+ /* linux_pwritev2 */
+ case 379: {
+ struct linux_pwritev2_args *p = params;
+ iarg[0] = p->fd; /* l_ulong */
+ uarg[1] = (intptr_t) p->vec; /* const struct iovec * */
+ iarg[2] = p->vlen; /* l_ulong */
+ iarg[3] = p->pos_l; /* l_ulong */
+ iarg[4] = p->pos_h; /* l_ulong */
+ iarg[5] = p->flags; /* l_int */
+ *n_args = 6;
+ break;
+ }
+ /* linux_pkey_mprotect */
+ case 380: {
+ struct linux_pkey_mprotect_args *p = params;
+ iarg[0] = p->start; /* l_ulong */
+ iarg[1] = p->len; /* l_size_t */
+ iarg[2] = p->prot; /* l_ulong */
+ iarg[3] = p->pkey; /* l_int */
+ *n_args = 4;
+ break;
+ }
+ /* linux_pkey_alloc */
+ case 381: {
+ struct linux_pkey_alloc_args *p = params;
+ iarg[0] = p->flags; /* l_ulong */
+ iarg[1] = p->init_val; /* l_ulong */
+ *n_args = 2;
+ break;
+ }
+ /* linux_pkey_free */
+ case 382: {
+ struct linux_pkey_free_args *p = params;
+ iarg[0] = p->pkey; /* l_int */
+ *n_args = 1;
break;
}
default:
@@ -5737,12 +6094,66 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)
break;
/* linux_preadv */
case 333:
+ switch(ndx) {
+ case 0:
+ p = "l_ulong";
+ break;
+ case 1:
+ p = "userland struct iovec *";
+ break;
+ case 2:
+ p = "l_ulong";
+ break;
+ case 3:
+ p = "l_ulong";
+ break;
+ case 4:
+ p = "l_ulong";
+ break;
+ default:
+ break;
+ };
break;
/* linux_pwritev */
case 334:
+ switch(ndx) {
+ case 0:
+ p = "l_ulong";
+ break;
+ case 1:
+ p = "userland struct iovec *";
+ break;
+ case 2:
+ p = "l_ulong";
+ break;
+ case 3:
+ p = "l_ulong";
+ break;
+ case 4:
+ p = "l_ulong";
+ break;
+ default:
+ break;
+ };
break;
- /* linux_rt_tsigqueueinfo */
+ /* linux_rt_tgsigqueueinfo */
case 335:
+ switch(ndx) {
+ case 0:
+ p = "l_pid_t";
+ break;
+ case 1:
+ p = "l_pid_t";
+ break;
+ case 2:
+ p = "l_int";
+ break;
+ case 3:
+ p = "userland l_siginfo_t *";
+ break;
+ default:
+ break;
+ };
break;
/* linux_perf_event_open */
case 336:
@@ -5837,9 +6248,657 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)
break;
/* linux_process_vm_readv */
case 347:
+ switch(ndx) {
+ case 0:
+ p = "l_pid_t";
+ break;
+ case 1:
+ p = "userland const struct iovec *";
+ break;
+ case 2:
+ p = "l_ulong";
+ break;
+ case 3:
+ p = "userland const struct iovec *";
+ break;
+ case 4:
+ p = "l_ulong";
+ break;
+ case 5:
+ p = "l_ulong";
+ break;
+ default:
+ break;
+ };
break;
/* linux_process_vm_writev */
case 348:
+ switch(ndx) {
+ case 0:
+ p = "l_pid_t";
+ break;
+ case 1:
+ p = "userland const struct iovec *";
+ break;
+ case 2:
+ p = "l_ulong";
+ break;
+ case 3:
+ p = "userland const struct iovec *";
+ break;
+ case 4:
+ p = "l_ulong";
+ break;
+ case 5:
+ p = "l_ulong";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_kcmp */
+ case 349:
+ switch(ndx) {
+ case 0:
+ p = "l_pid_t";
+ break;
+ case 1:
+ p = "l_pid_t";
+ break;
+ case 2:
+ p = "l_int";
+ break;
+ case 3:
+ p = "l_ulong";
+ break;
+ case 4:
+ p = "l_ulong";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_finit_module */
+ case 350:
+ switch(ndx) {
+ case 0:
+ p = "l_int";
+ break;
+ case 1:
+ p = "userland const char *";
+ break;
+ case 2:
+ p = "l_int";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_sched_setattr */
+ case 351:
+ switch(ndx) {
+ case 0:
+ p = "l_pid_t";
+ break;
+ case 1:
+ p = "userland void *";
+ break;
+ case 2:
+ p = "l_uint";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_sched_getattr */
+ case 352:
+ switch(ndx) {
+ case 0:
+ p = "l_pid_t";
+ break;
+ case 1:
+ p = "userland void *";
+ break;
+ case 2:
+ p = "l_uint";
+ break;
+ case 3:
+ p = "l_uint";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_renameat2 */
+ case 353:
+ switch(ndx) {
+ case 0:
+ p = "l_int";
+ break;
+ case 1:
+ p = "userland const char *";
+ break;
+ case 2:
+ p = "l_int";
+ break;
+ case 3:
+ p = "userland const char *";
+ break;
+ case 4:
+ p = "unsigned int";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_seccomp */
+ case 354:
+ switch(ndx) {
+ case 0:
+ p = "l_uint";
+ break;
+ case 1:
+ p = "l_uint";
+ break;
+ case 2:
+ p = "userland const char *";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_getrandom */
+ case 355:
+ switch(ndx) {
+ case 0:
+ p = "userland char *";
+ break;
+ case 1:
+ p = "l_size_t";
+ break;
+ case 2:
+ p = "l_uint";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_memfd_create */
+ case 356:
+ switch(ndx) {
+ case 0:
+ p = "userland const char *";
+ break;
+ case 1:
+ p = "l_uint";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_bpf */
+ case 357:
+ switch(ndx) {
+ case 0:
+ p = "l_int";
+ break;
+ case 1:
+ p = "userland void *";
+ break;
+ case 2:
+ p = "l_uint";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_execveat */
+ case 358:
+ switch(ndx) {
+ case 0:
+ p = "l_int";
+ break;
+ case 1:
+ p = "userland const char *";
+ break;
+ case 2:
+ p = "userland const char **";
+ break;
+ case 3:
+ p = "userland const char **";
+ break;
+ case 4:
+ p = "l_int";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_socket */
+ case 359:
+ switch(ndx) {
+ case 0:
+ p = "l_int";
+ break;
+ case 1:
+ p = "l_int";
+ break;
+ case 2:
+ p = "l_int";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_socketpair */
+ case 360:
+ switch(ndx) {
+ case 0:
+ p = "l_int";
+ break;
+ case 1:
+ p = "l_int";
+ break;
+ case 2:
+ p = "l_int";
+ break;
+ case 3:
+ p = "l_uintptr_t";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_bind */
+ case 361:
+ switch(ndx) {
+ case 0:
+ p = "l_int";
+ break;
+ case 1:
+ p = "l_uintptr_t";
+ break;
+ case 2:
+ p = "l_int";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_connect */
+ case 362:
+ switch(ndx) {
+ case 0:
+ p = "l_int";
+ break;
+ case 1:
+ p = "l_uintptr_t";
+ break;
+ case 2:
+ p = "l_int";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_listen */
+ case 363:
+ switch(ndx) {
+ case 0:
+ p = "l_int";
+ break;
+ case 1:
+ p = "l_int";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_accept4 */
+ case 364:
+ switch(ndx) {
+ case 0:
+ p = "l_int";
+ break;
+ case 1:
+ p = "l_uintptr_t";
+ break;
+ case 2:
+ p = "l_uintptr_t";
+ break;
+ case 3:
+ p = "l_int";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_getsockopt */
+ case 365:
+ switch(ndx) {
+ case 0:
+ p = "l_int";
+ break;
+ case 1:
+ p = "l_int";
+ break;
+ case 2:
+ p = "l_int";
+ break;
+ case 3:
+ p = "l_uintptr_t";
+ break;
+ case 4:
+ p = "l_uintptr_t";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_setsockopt */
+ case 366:
+ switch(ndx) {
+ case 0:
+ p = "l_int";
+ break;
+ case 1:
+ p = "l_int";
+ break;
+ case 2:
+ p = "l_int";
+ break;
+ case 3:
+ p = "l_uintptr_t";
+ break;
+ case 4:
+ p = "l_int";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_getsockname */
+ case 367:
+ switch(ndx) {
+ case 0:
+ p = "l_int";
+ break;
+ case 1:
+ p = "l_uintptr_t";
+ break;
+ case 2:
+ p = "l_uintptr_t";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_getpeername */
+ case 368:
+ switch(ndx) {
+ case 0:
+ p = "l_int";
+ break;
+ case 1:
+ p = "l_uintptr_t";
+ break;
+ case 2:
+ p = "l_uintptr_t";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_sendto */
+ case 369:
+ switch(ndx) {
+ case 0:
+ p = "l_int";
+ break;
+ case 1:
+ p = "l_uintptr_t";
+ break;
+ case 2:
+ p = "l_int";
+ break;
+ case 3:
+ p = "l_int";
+ break;
+ case 4:
+ p = "l_uintptr_t";
+ break;
+ case 5:
+ p = "l_int";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_sendmsg */
+ case 370:
+ switch(ndx) {
+ case 0:
+ p = "l_int";
+ break;
+ case 1:
+ p = "l_uintptr_t";
+ break;
+ case 2:
+ p = "l_int";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_recvfrom */
+ case 371:
+ switch(ndx) {
+ case 0:
+ p = "l_int";
+ break;
+ case 1:
+ p = "l_uintptr_t";
+ break;
+ case 2:
+ p = "l_size_t";
+ break;
+ case 3:
+ p = "l_int";
+ break;
+ case 4:
+ p = "l_uintptr_t";
+ break;
+ case 5:
+ p = "l_uintptr_t";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_recvmsg */
+ case 372:
+ switch(ndx) {
+ case 0:
+ p = "l_int";
+ break;
+ case 1:
+ p = "l_uintptr_t";
+ break;
+ case 2:
+ p = "l_int";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_shutdown */
+ case 373:
+ switch(ndx) {
+ case 0:
+ p = "l_int";
+ break;
+ case 1:
+ p = "l_int";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_userfaultfd */
+ case 374:
+ switch(ndx) {
+ case 0:
+ p = "l_int";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_membarrier */
+ case 375:
+ switch(ndx) {
+ case 0:
+ p = "l_int";
+ break;
+ case 1:
+ p = "l_int";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_mlock2 */
+ case 376:
+ switch(ndx) {
+ case 0:
+ p = "l_ulong";
+ break;
+ case 1:
+ p = "l_size_t";
+ break;
+ case 2:
+ p = "l_int";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_copy_file_range */
+ case 377:
+ switch(ndx) {
+ case 0:
+ p = "l_int";
+ break;
+ case 1:
+ p = "userland l_loff_t *";
+ break;
+ case 2:
+ p = "l_int";
+ break;
+ case 3:
+ p = "userland l_loff_t *";
+ break;
+ case 4:
+ p = "l_size_t";
+ break;
+ case 5:
+ p = "l_uint";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_preadv2 */
+ case 378:
+ switch(ndx) {
+ case 0:
+ p = "l_ulong";
+ break;
+ case 1:
+ p = "userland const struct iovec *";
+ break;
+ case 2:
+ p = "l_ulong";
+ break;
+ case 3:
+ p = "l_ulong";
+ break;
+ case 4:
+ p = "l_ulong";
+ break;
+ case 5:
+ p = "l_int";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_pwritev2 */
+ case 379:
+ switch(ndx) {
+ case 0:
+ p = "l_ulong";
+ break;
+ case 1:
+ p = "userland const struct iovec *";
+ break;
+ case 2:
+ p = "l_ulong";
+ break;
+ case 3:
+ p = "l_ulong";
+ break;
+ case 4:
+ p = "l_ulong";
+ break;
+ case 5:
+ p = "l_int";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_pkey_mprotect */
+ case 380:
+ switch(ndx) {
+ case 0:
+ p = "l_ulong";
+ break;
+ case 1:
+ p = "l_size_t";
+ break;
+ case 2:
+ p = "l_ulong";
+ break;
+ case 3:
+ p = "l_int";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_pkey_alloc */
+ case 381:
+ switch(ndx) {
+ case 0:
+ p = "l_ulong";
+ break;
+ case 1:
+ p = "l_ulong";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_pkey_free */
+ case 382:
+ switch(ndx) {
+ case 0:
+ p = "l_int";
+ break;
+ default:
+ break;
+ };
break;
default:
break;
@@ -7109,10 +8168,19 @@ systrace_return_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)
case 332:
/* linux_preadv */
case 333:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
/* linux_pwritev */
case 334:
- /* linux_rt_tsigqueueinfo */
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_rt_tgsigqueueinfo */
case 335:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
/* linux_perf_event_open */
case 336:
/* linux_recvmmsg */
@@ -7149,8 +8217,184 @@ systrace_return_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)
case 346:
/* linux_process_vm_readv */
case 347:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
/* linux_process_vm_writev */
case 348:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_kcmp */
+ case 349:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_finit_module */
+ case 350:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_sched_setattr */
+ case 351:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_sched_getattr */
+ case 352:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_renameat2 */
+ case 353:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_seccomp */
+ case 354:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_getrandom */
+ case 355:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_memfd_create */
+ case 356:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_bpf */
+ case 357:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_execveat */
+ case 358:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_socket */
+ case 359:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_socketpair */
+ case 360:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_bind */
+ case 361:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_connect */
+ case 362:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_listen */
+ case 363:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_accept4 */
+ case 364:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_getsockopt */
+ case 365:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_setsockopt */
+ case 366:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_getsockname */
+ case 367:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_getpeername */
+ case 368:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_sendto */
+ case 369:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_sendmsg */
+ case 370:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_recvfrom */
+ case 371:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_recvmsg */
+ case 372:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_shutdown */
+ case 373:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_userfaultfd */
+ case 374:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_membarrier */
+ case 375:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_mlock2 */
+ case 376:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_copy_file_range */
+ case 377:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_preadv2 */
+ case 378:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_pwritev2 */
+ case 379:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_pkey_mprotect */
+ case 380:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_pkey_alloc */
+ case 381:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_pkey_free */
+ case 382:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
default:
break;
};
diff --git a/sys/amd64/linux32/syscalls.master b/sys/amd64/linux32/syscalls.master
index 20aa3c4..1c261f9 100644
--- a/sys/amd64/linux32/syscalls.master
+++ b/sys/amd64/linux32/syscalls.master
@@ -11,18 +11,20 @@
; there is no audit event for the call at this time. For the
; case where the event exists, but we don't want auditing, the
; event should be #defined to AUE_NULL in audit_kevents.h.
-; type one of STD, OBSOL, UNIMPL
+; type one of STD, NOPROTO, UNIMPL
; name psuedo-prototype of syscall routine
; If one of the following alts is different, then all appear:
; altname name of system call if different
; alttag name of args struct tag if different from [o]`name'"_args"
; altrtyp return type if not int (bogus - syscalls always return int)
-; for UNIMPL/OBSOL, name continues with comments
+; for UNIMPL, name continues with comments
; types:
; STD always included
-; OBSOL obsolete, not included in system, only specifies name
; UNIMPL not implemented, placeholder only
+; NOPROTO same as STD except do not create structure or
+; function prototype in sys/sysproto.h. Does add a
+; definition to syscall.h besides adding a sysent.
#include "opt_compat.h"
#include <sys/param.h>
@@ -553,10 +555,15 @@
331 AUE_NULL STD { int linux_pipe2(l_int *pipefds, l_int flags); }
332 AUE_NULL STD { int linux_inotify_init1(void); }
; linux 2.6.30:
-333 AUE_NULL STD { int linux_preadv(void); }
-334 AUE_NULL STD { int linux_pwritev(void); }
+333 AUE_NULL STD { int linux_preadv(l_ulong fd, \
+ struct iovec *vec, l_ulong vlen, \
+ l_ulong pos_l, l_ulong pos_h); }
+334 AUE_NULL STD { int linux_pwritev(l_ulong fd, \
+ struct iovec *vec, l_ulong vlen, \
+ l_ulong pos_l, l_ulong pos_h); }
; linux 2.6.31:
-335 AUE_NULL STD { int linux_rt_tsigqueueinfo(void); }
+335 AUE_NULL STD { int linux_rt_tgsigqueueinfo(l_pid_t tgid, \
+ l_pid_t tid, l_int sig, l_siginfo_t *uinfo); }
336 AUE_NULL STD { int linux_perf_event_open(void); }
; linux 2.6.33:
337 AUE_NULL STD { int linux_recvmmsg(l_int s, \
@@ -569,16 +576,113 @@
l_uint resource, \
struct rlimit *new, \
struct rlimit *old); }
-; later:
+; linux 2.6.39:
341 AUE_NULL STD { int linux_name_to_handle_at(void); }
342 AUE_NULL STD { int linux_open_by_handle_at(void); }
343 AUE_NULL STD { int linux_clock_adjtime(void); }
344 AUE_SYNC STD { int linux_syncfs(l_int fd); }
+; linux 3.0:
345 AUE_NULL STD { int linux_sendmmsg(l_int s, \
struct l_mmsghdr *msg, l_uint vlen, \
l_uint flags); }
346 AUE_NULL STD { int linux_setns(void); }
-347 AUE_NULL STD { int linux_process_vm_readv(void); }
-348 AUE_NULL STD { int linux_process_vm_writev(void); }
+; linux 3.2 (glibc 2.15):
+347 AUE_NULL STD { int linux_process_vm_readv(l_pid_t pid, \
+ const struct iovec *lvec, l_ulong liovcnt, \
+ const struct iovec *rvec, l_ulong riovcnt, \
+ l_ulong flags); }
+348 AUE_NULL STD { int linux_process_vm_writev(l_pid_t pid, \
+ const struct iovec *lvec, l_ulong liovcnt, \
+ const struct iovec *rvec, l_ulong riovcnt, \
+ l_ulong flags); }
+; linux 3.5 (no glibc wrapper):
+349 AUE_NULL STD { int linux_kcmp(l_pid_t pid1, l_pid_t pid2, \
+ l_int type, l_ulong idx1, l_ulong idx); }
+; linux 3.8 (no glibc wrapper):
+350 AUE_NULL STD { int linux_finit_module(l_int fd, \
+ const char *uargs, l_int flags); }
+; linux 3.14:
+351 AUE_NULL STD { int linux_sched_setattr(l_pid_t pid, \
+ void *attr, l_uint flags); }
+352 AUE_NULL STD { int linux_sched_getattr(l_pid_t pid, \
+ void *attr, l_uint size, l_uint flags); }
+; linux 3.15:
+353 AUE_NULL STD { int linux_renameat2(l_int oldfd, \
+ const char *oldname, l_int newfd, \
+ const char *newname, unsigned int flags); }
+; linux 3.17:
+354 AUE_NULL STD { int linux_seccomp(l_uint op, l_uint flags, \
+ const char *uargs); }
+355 AUE_NULL STD { int linux_getrandom(char *buf, \
+ l_size_t count, l_uint flags); }
+356 AUE_NULL STD { int linux_memfd_create(const char *uname_ptr, \
+ l_uint flags); }
+; linux 3.18:
+357 AUE_NULL STD { int linux_bpf(l_int cmd, void *attr, \
+ l_uint size); }
+; linux 3.19:
+358 AUE_NULL STD { int linux_execveat(l_int dfd, \
+ const char *filename, const char **argv, \
+ const char **envp, l_int flags); }
+; linux 4.3: sockets now direct system calls:
+359 AUE_SOCKET STD { int linux_socket(l_int domain, l_int type, \
+ l_int protocol); }
+360 AUE_SOCKETPAIR STD { int linux_socketpair(l_int domain, \
+ l_int type, l_int protocol, l_uintptr_t rsv); }
+361 AUE_BIND STD { int linux_bind(l_int s, l_uintptr_t name, \
+ l_int namelen); }
+362 AUE_CONNECT STD { int linux_connect(l_int s, l_uintptr_t name, \
+ l_int namelen); }
+363 AUE_LISTEN STD { int linux_listen(l_int s, l_int backlog); }
+364 AUE_ACCEPT STD { int linux_accept4(l_int s, l_uintptr_t addr, \
+ l_uintptr_t namelen, l_int flags); }
+365 AUE_GETSOCKOPT STD { int linux_getsockopt(l_int s, l_int level, \
+ l_int optname, l_uintptr_t optval, \
+ l_uintptr_t optlen); }
+366 AUE_SETSOCKOPT STD { int linux_setsockopt(l_int s, l_int level, \
+ l_int optname, l_uintptr_t optval, \
+ l_int optlen); }
+367 AUE_GETSOCKNAME STD { int linux_getsockname(l_int s, \
+ l_uintptr_t addr, l_uintptr_t namelen); }
+368 AUE_GETPEERNAME STD { int linux_getpeername(l_int s, \
+ l_uintptr_t addr, l_uintptr_t namelen); }
+369 AUE_SENDTO STD { int linux_sendto(l_int s, l_uintptr_t msg, \
+ l_int len, l_int flags, l_uintptr_t to, \
+ l_int tolen); }
+370 AUE_SENDMSG STD { int linux_sendmsg(l_int s, l_uintptr_t msg, \
+ l_int flags); }
+371 AUE_RECVFROM STD { int linux_recvfrom(l_int s, l_uintptr_t buf, \
+ l_size_t len, l_int flags, l_uintptr_t from, \
+ l_uintptr_t fromlen); }
+372 AUE_RECVMSG STD { int linux_recvmsg(l_int s, l_uintptr_t msg, \
+ l_int flags); }
+373 AUE_NULL STD { int linux_shutdown(l_int s, l_int how); }
+;
+; linux 4.2:
+374 AUE_NULL STD { int linux_userfaultfd(l_int flags); }
+; linux 4.3:
+375 AUE_NULL STD { int linux_membarrier(l_int cmd, l_int flags); }
+; linux 4.4:
+376 AUE_NULL STD { int linux_mlock2(l_ulong start, l_size_t len, \
+ l_int flags); }
+; linux 4.5:
+377 AUE_NULL STD { int linux_copy_file_range(l_int fd_in, \
+ l_loff_t *off_in, l_int fd_out, \
+ l_loff_t *off_out, l_size_t len, \
+ l_uint flags); }
+; linux 4.6:
+378 AUE_NULL STD { int linux_preadv2(l_ulong fd, \
+ const struct iovec *vec, l_ulong vlen, \
+ l_ulong pos_l, l_ulong pos_h, l_int flags); }
+379 AUE_NULL STD { int linux_pwritev2(l_ulong fd, \
+ const struct iovec *vec, l_ulong vlen, \
+ l_ulong pos_l, l_ulong pos_h, l_int flags); }
+; linux 4.8:
+380 AUE_NULL STD { int linux_pkey_mprotect(l_ulong start, \
+ l_size_t len, l_ulong prot, l_int pkey); }
+381 AUE_NULL STD { int linux_pkey_alloc(l_ulong flags, \
+ l_ulong init_val); }
+382 AUE_NULL STD { int linux_pkey_free(l_int pkey); }
+
; please, keep this line at the end.
-349 AUE_NULL UNIMPL nosys
+383 AUE_NULL UNIMPL nosys
diff --git a/sys/arm/arm/pmap-v6.c b/sys/arm/arm/pmap-v6.c
index 6eaab42..3a13e8a 100644
--- a/sys/arm/arm/pmap-v6.c
+++ b/sys/arm/arm/pmap-v6.c
@@ -110,11 +110,6 @@ __FBSDID("$FreeBSD$");
#include <sys/smp.h>
#include <sys/sched.h>
#include <sys/sysctl.h>
-#ifdef SMP
-#include <sys/smp.h>
-#else
-#include <sys/cpuset.h>
-#endif
#ifdef DDB
#include <ddb/ddb.h>
@@ -296,16 +291,6 @@ vm_paddr_t first_managed_pa;
/*
* All those kernel PT submaps that BSD is so fond of
*/
-struct sysmaps {
- struct mtx lock;
- pt2_entry_t *CMAP1;
- pt2_entry_t *CMAP2;
- pt2_entry_t *CMAP3;
- caddr_t CADDR1;
- caddr_t CADDR2;
- caddr_t CADDR3;
-};
-static struct sysmaps sysmaps_pcpu[MAXCPU];
static pt2_entry_t *CMAP3;
static caddr_t CADDR3;
caddr_t _tmppt = 0;
@@ -1135,8 +1120,7 @@ void
pmap_bootstrap(vm_offset_t firstaddr)
{
pt2_entry_t *unused __unused;
- struct sysmaps *sysmaps;
- u_int i;
+ struct pcpu *pc;
/*
* Initialize the kernel pmap (which is statically allocated).
@@ -1175,16 +1159,14 @@ pmap_bootstrap(vm_offset_t firstaddr)
/*
* Local CMAP1/CMAP2 are used for zeroing and copying pages.
- * Local CMAP3 is used for data cache cleaning.
+ * Local CMAP2 is also used for data cache cleaning.
* Global CMAP3 is used for the idle process page zeroing.
*/
- for (i = 0; i < MAXCPU; i++) {
- sysmaps = &sysmaps_pcpu[i];
- mtx_init(&sysmaps->lock, "SYSMAPS", NULL, MTX_DEF);
- SYSMAP(caddr_t, sysmaps->CMAP1, sysmaps->CADDR1, 1);
- SYSMAP(caddr_t, sysmaps->CMAP2, sysmaps->CADDR2, 1);
- SYSMAP(caddr_t, sysmaps->CMAP3, sysmaps->CADDR3, 1);
- }
+ pc = get_pcpu();
+ mtx_init(&pc->pc_cmap_lock, "SYSMAPS", NULL, MTX_DEF);
+ SYSMAP(caddr_t, pc->pc_cmap1_pte2p, pc->pc_cmap1_addr, 1);
+ SYSMAP(caddr_t, pc->pc_cmap2_pte2p, pc->pc_cmap2_addr, 1);
+ SYSMAP(vm_offset_t, pc->pc_qmap_pte2p, pc->pc_qmap_addr, 1);
SYSMAP(caddr_t, CMAP3, CADDR3, 1);
/*
@@ -1218,19 +1200,33 @@ pmap_bootstrap(vm_offset_t firstaddr)
}
static void
-pmap_init_qpages(void)
+pmap_init_reserved_pages(void)
{
struct pcpu *pc;
+ vm_offset_t pages;
int i;
CPU_FOREACH(i) {
pc = pcpu_find(i);
- pc->pc_qmap_addr = kva_alloc(PAGE_SIZE);
- if (pc->pc_qmap_addr == 0)
+ /*
+ * Skip if the mapping has already been initialized,
+ * i.e. this is the BSP.
+ */
+ if (pc->pc_cmap1_addr != 0)
+ continue;
+ mtx_init(&pc->pc_cmap_lock, "SYSMAPS", NULL, MTX_DEF);
+ pages = kva_alloc(PAGE_SIZE * 3);
+ if (pages == 0)
panic("%s: unable to allocate KVA", __func__);
+ pc->pc_cmap1_pte2p = pt2map_entry(pages);
+ pc->pc_cmap2_pte2p = pt2map_entry(pages + PAGE_SIZE);
+ pc->pc_qmap_pte2p = pt2map_entry(pages + (PAGE_SIZE * 2));
+ pc->pc_cmap1_addr = (caddr_t)pages;
+ pc->pc_cmap2_addr = (caddr_t)(pages + PAGE_SIZE);
+ pc->pc_qmap_addr = pages + (PAGE_SIZE * 2);
}
}
-SYSINIT(qpages_init, SI_SUB_CPU, SI_ORDER_ANY, pmap_init_qpages, NULL);
+SYSINIT(rpages_init, SI_SUB_CPU, SI_ORDER_ANY, pmap_init_reserved_pages, NULL);
/*
* The function can already be use in second initialization stage.
@@ -1581,8 +1577,9 @@ pagezero(void *page)
static __inline vm_paddr_t
pmap_pt2pg_zero(vm_page_t m)
{
+ pt2_entry_t *cmap2_pte2p;
vm_paddr_t pa;
- struct sysmaps *sysmaps;
+ struct pcpu *pc;
pa = VM_PAGE_TO_PHYS(m);
@@ -1591,20 +1588,27 @@ pmap_pt2pg_zero(vm_page_t m)
* to sync it even if the sync is only DSB.
*/
sched_pin();
- sysmaps = &sysmaps_pcpu[PCPU_GET(cpuid)];
- mtx_lock(&sysmaps->lock);
- if (pte2_load(sysmaps->CMAP2) != 0)
+ pc = get_pcpu();
+ cmap2_pte2p = pc->pc_cmap2_pte2p;
+ mtx_lock(&pc->pc_cmap_lock);
+ if (pte2_load(cmap2_pte2p) != 0)
panic("%s: CMAP2 busy", __func__);
- pte2_store(sysmaps->CMAP2, PTE2_KERN_NG(pa, PTE2_AP_KRW,
+ pte2_store(cmap2_pte2p, PTE2_KERN_NG(pa, PTE2_AP_KRW,
vm_page_pte2_attr(m)));
/* Even VM_ALLOC_ZERO request is only advisory. */
if ((m->flags & PG_ZERO) == 0)
- pagezero(sysmaps->CADDR2);
- pte2_sync_range((pt2_entry_t *)sysmaps->CADDR2, PAGE_SIZE);
- pte2_clear(sysmaps->CMAP2);
- tlb_flush((vm_offset_t)sysmaps->CADDR2);
+ pagezero(pc->pc_cmap2_addr);
+ pte2_sync_range((pt2_entry_t *)pc->pc_cmap2_addr, PAGE_SIZE);
+ pte2_clear(cmap2_pte2p);
+ tlb_flush((vm_offset_t)pc->pc_cmap2_addr);
+
+ /*
+ * Unpin the thread before releasing the lock. Otherwise the thread
+ * could be rescheduled while still bound to the current CPU, only
+ * to unpin itself immediately upon resuming execution.
+ */
sched_unpin();
- mtx_unlock(&sysmaps->lock);
+ mtx_unlock(&pc->pc_cmap_lock);
return (pa);
}
@@ -5643,9 +5647,10 @@ small_mappings:
void
pmap_page_set_memattr(vm_page_t m, vm_memattr_t ma)
{
- struct sysmaps *sysmaps;
+ pt2_entry_t *cmap2_pte2p;
vm_memattr_t oma;
vm_paddr_t pa;
+ struct pcpu *pc;
oma = m->md.pat_mode;
m->md.pat_mode = ma;
@@ -5672,17 +5677,18 @@ pmap_page_set_memattr(vm_page_t m, vm_memattr_t ma)
if (ma != oma) {
pa = VM_PAGE_TO_PHYS(m);
sched_pin();
- sysmaps = &sysmaps_pcpu[PCPU_GET(cpuid)];
- mtx_lock(&sysmaps->lock);
- if (*sysmaps->CMAP2)
+ pc = get_pcpu();
+ cmap2_pte2p = pc->pc_cmap2_pte2p;
+ mtx_lock(&pc->pc_cmap_lock);
+ if (pte2_load(cmap2_pte2p) != 0)
panic("%s: CMAP2 busy", __func__);
- pte2_store(sysmaps->CMAP2, PTE2_KERN_NG(pa, PTE2_AP_KRW,
+ pte2_store(cmap2_pte2p, PTE2_KERN_NG(pa, PTE2_AP_KRW,
vm_memattr_to_pte2(ma)));
- dcache_wbinv_poc((vm_offset_t)sysmaps->CADDR2, pa, PAGE_SIZE);
- pte2_clear(sysmaps->CMAP2);
- tlb_flush((vm_offset_t)sysmaps->CADDR2);
+ dcache_wbinv_poc((vm_offset_t)pc->pc_cmap2_addr, pa, PAGE_SIZE);
+ pte2_clear(cmap2_pte2p);
+ tlb_flush((vm_offset_t)pc->pc_cmap2_addr);
sched_unpin();
- mtx_unlock(&sysmaps->lock);
+ mtx_unlock(&pc->pc_cmap_lock);
}
}
@@ -5760,20 +5766,22 @@ pmap_page_exists_quick(pmap_t pmap, vm_page_t m)
void
pmap_zero_page(vm_page_t m)
{
- struct sysmaps *sysmaps;
+ pt2_entry_t *cmap2_pte2p;
+ struct pcpu *pc;
sched_pin();
- sysmaps = &sysmaps_pcpu[PCPU_GET(cpuid)];
- mtx_lock(&sysmaps->lock);
- if (pte2_load(sysmaps->CMAP2) != 0)
+ pc = get_pcpu();
+ cmap2_pte2p = pc->pc_cmap2_pte2p;
+ mtx_lock(&pc->pc_cmap_lock);
+ if (pte2_load(cmap2_pte2p) != 0)
panic("%s: CMAP2 busy", __func__);
- pte2_store(sysmaps->CMAP2, PTE2_KERN_NG(VM_PAGE_TO_PHYS(m), PTE2_AP_KRW,
+ pte2_store(cmap2_pte2p, PTE2_KERN_NG(VM_PAGE_TO_PHYS(m), PTE2_AP_KRW,
vm_page_pte2_attr(m)));
- pagezero(sysmaps->CADDR2);
- pte2_clear(sysmaps->CMAP2);
- tlb_flush((vm_offset_t)sysmaps->CADDR2);
+ pagezero(pc->pc_cmap2_addr);
+ pte2_clear(cmap2_pte2p);
+ tlb_flush((vm_offset_t)pc->pc_cmap2_addr);
sched_unpin();
- mtx_unlock(&sysmaps->lock);
+ mtx_unlock(&pc->pc_cmap_lock);
}
/*
@@ -5785,23 +5793,25 @@ pmap_zero_page(vm_page_t m)
void
pmap_zero_page_area(vm_page_t m, int off, int size)
{
- struct sysmaps *sysmaps;
+ pt2_entry_t *cmap2_pte2p;
+ struct pcpu *pc;
sched_pin();
- sysmaps = &sysmaps_pcpu[PCPU_GET(cpuid)];
- mtx_lock(&sysmaps->lock);
- if (pte2_load(sysmaps->CMAP2) != 0)
+ pc = get_pcpu();
+ cmap2_pte2p = pc->pc_cmap2_pte2p;
+ mtx_lock(&pc->pc_cmap_lock);
+ if (pte2_load(cmap2_pte2p) != 0)
panic("%s: CMAP2 busy", __func__);
- pte2_store(sysmaps->CMAP2, PTE2_KERN_NG(VM_PAGE_TO_PHYS(m), PTE2_AP_KRW,
+ pte2_store(cmap2_pte2p, PTE2_KERN_NG(VM_PAGE_TO_PHYS(m), PTE2_AP_KRW,
vm_page_pte2_attr(m)));
if (off == 0 && size == PAGE_SIZE)
- pagezero(sysmaps->CADDR2);
+ pagezero(pc->pc_cmap2_addr);
else
- bzero(sysmaps->CADDR2 + off, size);
- pte2_clear(sysmaps->CMAP2);
- tlb_flush((vm_offset_t)sysmaps->CADDR2);
+ bzero(pc->pc_cmap2_addr + off, size);
+ pte2_clear(cmap2_pte2p);
+ tlb_flush((vm_offset_t)pc->pc_cmap2_addr);
sched_unpin();
- mtx_unlock(&sysmaps->lock);
+ mtx_unlock(&pc->pc_cmap_lock);
}
/*
@@ -5834,26 +5844,29 @@ pmap_zero_page_idle(vm_page_t m)
void
pmap_copy_page(vm_page_t src, vm_page_t dst)
{
- struct sysmaps *sysmaps;
+ pt2_entry_t *cmap1_pte2p, *cmap2_pte2p;
+ struct pcpu *pc;
sched_pin();
- sysmaps = &sysmaps_pcpu[PCPU_GET(cpuid)];
- mtx_lock(&sysmaps->lock);
- if (pte2_load(sysmaps->CMAP1) != 0)
+ pc = get_pcpu();
+ cmap1_pte2p = pc->pc_cmap1_pte2p;
+ cmap2_pte2p = pc->pc_cmap2_pte2p;
+ mtx_lock(&pc->pc_cmap_lock);
+ if (pte2_load(cmap1_pte2p) != 0)
panic("%s: CMAP1 busy", __func__);
- if (pte2_load(sysmaps->CMAP2) != 0)
+ if (pte2_load(cmap2_pte2p) != 0)
panic("%s: CMAP2 busy", __func__);
- pte2_store(sysmaps->CMAP1, PTE2_KERN_NG(VM_PAGE_TO_PHYS(src),
+ pte2_store(cmap1_pte2p, PTE2_KERN_NG(VM_PAGE_TO_PHYS(src),
PTE2_AP_KR | PTE2_NM, vm_page_pte2_attr(src)));
- pte2_store(sysmaps->CMAP2, PTE2_KERN_NG(VM_PAGE_TO_PHYS(dst),
+ pte2_store(cmap2_pte2p, PTE2_KERN_NG(VM_PAGE_TO_PHYS(dst),
PTE2_AP_KRW, vm_page_pte2_attr(dst)));
- bcopy(sysmaps->CADDR1, sysmaps->CADDR2, PAGE_SIZE);
- pte2_clear(sysmaps->CMAP1);
- tlb_flush((vm_offset_t)sysmaps->CADDR1);
- pte2_clear(sysmaps->CMAP2);
- tlb_flush((vm_offset_t)sysmaps->CADDR2);
+ bcopy(pc->pc_cmap1_addr, pc->pc_cmap2_addr, PAGE_SIZE);
+ pte2_clear(cmap1_pte2p);
+ tlb_flush((vm_offset_t)pc->pc_cmap1_addr);
+ pte2_clear(cmap2_pte2p);
+ tlb_flush((vm_offset_t)pc->pc_cmap2_addr);
sched_unpin();
- mtx_unlock(&sysmaps->lock);
+ mtx_unlock(&pc->pc_cmap_lock);
}
int unmapped_buf_allowed = 1;
@@ -5862,18 +5875,21 @@ void
pmap_copy_pages(vm_page_t ma[], vm_offset_t a_offset, vm_page_t mb[],
vm_offset_t b_offset, int xfersize)
{
- struct sysmaps *sysmaps;
+ pt2_entry_t *cmap1_pte2p, *cmap2_pte2p;
vm_page_t a_pg, b_pg;
char *a_cp, *b_cp;
vm_offset_t a_pg_offset, b_pg_offset;
+ struct pcpu *pc;
int cnt;
sched_pin();
- sysmaps = &sysmaps_pcpu[PCPU_GET(cpuid)];
- mtx_lock(&sysmaps->lock);
- if (*sysmaps->CMAP1 != 0)
+ pc = get_pcpu();
+ cmap1_pte2p = pc->pc_cmap1_pte2p;
+ cmap2_pte2p = pc->pc_cmap2_pte2p;
+ mtx_lock(&pc->pc_cmap_lock);
+ if (pte2_load(cmap1_pte2p) != 0)
panic("pmap_copy_pages: CMAP1 busy");
- if (*sysmaps->CMAP2 != 0)
+ if (pte2_load(cmap2_pte2p) != 0)
panic("pmap_copy_pages: CMAP2 busy");
while (xfersize > 0) {
a_pg = ma[a_offset >> PAGE_SHIFT];
@@ -5882,58 +5898,58 @@ pmap_copy_pages(vm_page_t ma[], vm_offset_t a_offset, vm_page_t mb[],
b_pg = mb[b_offset >> PAGE_SHIFT];
b_pg_offset = b_offset & PAGE_MASK;
cnt = min(cnt, PAGE_SIZE - b_pg_offset);
- pte2_store(sysmaps->CMAP1, PTE2_KERN_NG(VM_PAGE_TO_PHYS(a_pg),
+ pte2_store(cmap1_pte2p, PTE2_KERN_NG(VM_PAGE_TO_PHYS(a_pg),
PTE2_AP_KR | PTE2_NM, vm_page_pte2_attr(a_pg)));
- tlb_flush_local((vm_offset_t)sysmaps->CADDR1);
- pte2_store(sysmaps->CMAP2, PTE2_KERN_NG(VM_PAGE_TO_PHYS(b_pg),
+ tlb_flush_local((vm_offset_t)pc->pc_cmap1_addr);
+ pte2_store(cmap2_pte2p, PTE2_KERN_NG(VM_PAGE_TO_PHYS(b_pg),
PTE2_AP_KRW, vm_page_pte2_attr(b_pg)));
- tlb_flush_local((vm_offset_t)sysmaps->CADDR2);
- a_cp = sysmaps->CADDR1 + a_pg_offset;
- b_cp = sysmaps->CADDR2 + b_pg_offset;
+ tlb_flush_local((vm_offset_t)pc->pc_cmap2_addr);
+ a_cp = pc->pc_cmap1_addr + a_pg_offset;
+ b_cp = pc->pc_cmap2_addr + b_pg_offset;
bcopy(a_cp, b_cp, cnt);
a_offset += cnt;
b_offset += cnt;
xfersize -= cnt;
}
- pte2_clear(sysmaps->CMAP1);
- tlb_flush((vm_offset_t)sysmaps->CADDR1);
- pte2_clear(sysmaps->CMAP2);
- tlb_flush((vm_offset_t)sysmaps->CADDR2);
+ pte2_clear(cmap1_pte2p);
+ tlb_flush((vm_offset_t)pc->pc_cmap1_addr);
+ pte2_clear(cmap2_pte2p);
+ tlb_flush((vm_offset_t)pc->pc_cmap2_addr);
sched_unpin();
- mtx_unlock(&sysmaps->lock);
+ mtx_unlock(&pc->pc_cmap_lock);
}
vm_offset_t
pmap_quick_enter_page(vm_page_t m)
{
+ struct pcpu *pc;
pt2_entry_t *pte2p;
- vm_offset_t qmap_addr;
critical_enter();
- qmap_addr = PCPU_GET(qmap_addr);
- pte2p = pt2map_entry(qmap_addr);
+ pc = get_pcpu();
+ pte2p = pc->pc_qmap_pte2p;
KASSERT(pte2_load(pte2p) == 0, ("%s: PTE2 busy", __func__));
pte2_store(pte2p, PTE2_KERN_NG(VM_PAGE_TO_PHYS(m), PTE2_AP_KRW,
vm_page_pte2_attr(m)));
- return (qmap_addr);
+ return (pc->pc_qmap_addr);
}
void
pmap_quick_remove_page(vm_offset_t addr)
{
+ struct pcpu *pc;
pt2_entry_t *pte2p;
- vm_offset_t qmap_addr;
- qmap_addr = PCPU_GET(qmap_addr);
- pte2p = pt2map_entry(qmap_addr);
+ pc = get_pcpu();
+ pte2p = pc->pc_qmap_pte2p;
- KASSERT(addr == qmap_addr, ("%s: invalid address", __func__));
+ KASSERT(addr == pc->pc_qmap_addr, ("%s: invalid address", __func__));
KASSERT(pte2_load(pte2p) != 0, ("%s: PTE2 not in use", __func__));
pte2_clear(pte2p);
- tlb_flush(qmap_addr);
+ tlb_flush(pc->pc_qmap_addr);
critical_exit();
}
@@ -6226,22 +6242,24 @@ pmap_set_pcb_pagedir(pmap_t pmap, struct pcb *pcb)
static void
pmap_dcache_wb_pou(vm_paddr_t pa, vm_size_t size, uint32_t attr)
{
- struct sysmaps *sysmaps;
+ pt2_entry_t *cmap2_pte2p;
+ struct pcpu *pc;
KASSERT(((pa & PAGE_MASK) + size) <= PAGE_SIZE,
("%s: not on single page", __func__));
sched_pin();
- sysmaps = &sysmaps_pcpu[PCPU_GET(cpuid)];
- mtx_lock(&sysmaps->lock);
- if (*sysmaps->CMAP3)
- panic("%s: CMAP3 busy", __func__);
- pte2_store(sysmaps->CMAP3, PTE2_KERN_NG(pa, PTE2_AP_KRW, attr));
- dcache_wb_pou((vm_offset_t)sysmaps->CADDR3 + (pa & PAGE_MASK), size);
- pte2_clear(sysmaps->CMAP3);
- tlb_flush((vm_offset_t)sysmaps->CADDR3);
+ pc = get_pcpu();
+ cmap2_pte2p = pc->pc_cmap2_pte2p;
+ mtx_lock(&pc->pc_cmap_lock);
+ if (pte2_load(cmap2_pte2p) != 0)
+ panic("%s: CMAP2 busy", __func__);
+ pte2_store(cmap2_pte2p, PTE2_KERN_NG(pa, PTE2_AP_KRW, attr));
+ dcache_wb_pou((vm_offset_t)pc->pc_cmap2_addr + (pa & PAGE_MASK), size);
+ pte2_clear(cmap2_pte2p);
+ tlb_flush((vm_offset_t)pc->pc_cmap2_addr);
sched_unpin();
- mtx_unlock(&sysmaps->lock);
+ mtx_unlock(&pc->pc_cmap_lock);
}
/*
@@ -6491,25 +6509,27 @@ pmap_fault(pmap_t pmap, vm_offset_t far, uint32_t fsr, int idx, bool usermode)
static void
pmap_zero_page_check(vm_page_t m)
{
+ pt2_entry_t *cmap2_pte2p;
uint32_t *p, *end;
- struct sysmaps *sysmaps;
+ struct pcpu *pc;
sched_pin();
- sysmaps = &sysmaps_pcpu[PCPU_GET(cpuid)];
- mtx_lock(&sysmaps->lock);
- if (pte2_load(sysmaps->CMAP2) != 0)
+ pc = get_pcpu();
+ cmap2_pte2p = pc->pc_cmap2_pte2p;
+ mtx_lock(&pc->pc_cmap_lock);
+ if (pte2_load(cmap2_pte2p) != 0)
panic("%s: CMAP2 busy", __func__);
- pte2_store(sysmaps->CMAP2, PTE2_KERN_NG(VM_PAGE_TO_PHYS(m), PTE2_AP_KRW,
+ pte2_store(cmap2_pte2p, PTE2_KERN_NG(VM_PAGE_TO_PHYS(m), PTE2_AP_KRW,
vm_page_pte2_attr(m)));
- end = (uint32_t*)(sysmaps->CADDR2 + PAGE_SIZE);
- for (p = (uint32_t*)sysmaps->CADDR2; p < end; p++)
+ end = (uint32_t*)(pc->pc_cmap2_addr + PAGE_SIZE);
+ for (p = (uint32_t*)pc->pc_cmap2_addr; p < end; p++)
if (*p != 0)
panic("%s: page %p not zero, va: %p", __func__, m,
- sysmaps->CADDR2);
- pte2_clear(sysmaps->CMAP2);
- tlb_flush((vm_offset_t)sysmaps->CADDR2);
+ pc->pc_cmap2_addr);
+ pte2_clear(cmap2_pte2p);
+ tlb_flush((vm_offset_t)pc->pc_cmap2_addr);
sched_unpin();
- mtx_unlock(&sysmaps->lock);
+ mtx_unlock(&pc->pc_cmap_lock);
}
int
diff --git a/sys/arm/include/_types.h b/sys/arm/include/_types.h
index b627963..204d8b3 100644
--- a/sys/arm/include/_types.h
+++ b/sys/arm/include/_types.h
@@ -100,9 +100,7 @@ typedef __uint32_t __uint_least32_t;
typedef __uint64_t __uint_least64_t;
typedef __uint32_t __u_register_t;
typedef __uint32_t __vm_offset_t;
-typedef __int64_t __vm_ooffset_t;
typedef __uint32_t __vm_paddr_t;
-typedef __uint64_t __vm_pindex_t;
typedef __uint32_t __vm_size_t;
typedef unsigned int ___wchar_t;
diff --git a/sys/arm/include/counter.h b/sys/arm/include/counter.h
index c4da91f..950516e 100644
--- a/sys/arm/include/counter.h
+++ b/sys/arm/include/counter.h
@@ -31,12 +31,9 @@
#include <sys/pcpu.h>
#include <machine/atomic.h>
-#ifdef INVARIANTS
-#include <sys/proc.h>
-#endif
-#define counter_enter() critical_enter()
-#define counter_exit() critical_exit()
+#define counter_enter() do {} while (0)
+#define counter_exit() do {} while (0)
#ifdef IN_SUBR_COUNTER_C
@@ -55,7 +52,7 @@ counter_u64_fetch_inline(uint64_t *p)
int i;
r = 0;
- for (i = 0; i < mp_ncpus; i++)
+ CPU_FOREACH(i)
r += counter_u64_read_one((uint64_t *)p, i);
return (r);
@@ -78,18 +75,13 @@ counter_u64_zero_inline(counter_u64_t c)
}
#endif
-#define counter_u64_add_protected(c, inc) do { \
- CRITICAL_ASSERT(curthread); \
- atomic_add_64((uint64_t *)zpcpu_get(c), (inc)); \
-} while (0)
+#define counter_u64_add_protected(c, inc) counter_u64_add(c, inc)
static inline void
counter_u64_add(counter_u64_t c, int64_t inc)
{
- counter_enter();
- counter_u64_add_protected(c, inc);
- counter_exit();
+ atomic_add_64((uint64_t *)zpcpu_get(c), inc);
}
#endif /* ! __MACHINE_COUNTER_H__ */
diff --git a/sys/arm/include/pcpu.h b/sys/arm/include/pcpu.h
index c9ebd5e..d3ae30b 100644
--- a/sys/arm/include/pcpu.h
+++ b/sys/arm/include/pcpu.h
@@ -34,6 +34,9 @@
#include <machine/cpuconf.h>
+#include <sys/_lock.h>
+#include <sys/_mutex.h>
+
#define ALT_STACK_SIZE 128
struct vmspace;
@@ -41,21 +44,25 @@ struct vmspace;
#endif /* _KERNEL */
#if __ARM_ARCH >= 6
+
#define PCPU_MD_FIELDS \
unsigned int pc_vfpsid; \
unsigned int pc_vfpmvfr0; \
unsigned int pc_vfpmvfr1; \
struct pmap *pc_curpmap; \
+ struct mtx pc_cmap_lock; \
+ void *pc_cmap1_pte2p; \
+ void *pc_cmap2_pte2p; \
+ caddr_t pc_cmap1_addr; \
+ caddr_t pc_cmap2_addr; \
vm_offset_t pc_qmap_addr; \
- void *pc_qmap_pte; \
+ void *pc_qmap_pte2p; \
unsigned int pc_dbreg[32]; \
int pc_dbreg_cmd; \
- char __pad[1]
+ char __pad[19]
#else
#define PCPU_MD_FIELDS \
- vm_offset_t qmap_addr; \
- void *pc_qmap_pte; \
- char __pad[149]
+ char __pad[157]
#endif
#ifdef _KERNEL
diff --git a/sys/arm64/include/_types.h b/sys/arm64/include/_types.h
index 8720ca8..f1d4af4 100644
--- a/sys/arm64/include/_types.h
+++ b/sys/arm64/include/_types.h
@@ -88,9 +88,7 @@ typedef __uint32_t __uint_least32_t;
typedef __uint64_t __uint_least64_t;
typedef __uint64_t __u_register_t;
typedef __uint64_t __vm_offset_t;
-typedef __int64_t __vm_ooffset_t;
typedef __uint64_t __vm_paddr_t;
-typedef __uint64_t __vm_pindex_t;
typedef __uint64_t __vm_size_t;
typedef unsigned int ___wchar_t;
diff --git a/sys/arm64/include/counter.h b/sys/arm64/include/counter.h
index 9d56cce..cfa521f 100644
--- a/sys/arm64/include/counter.h
+++ b/sys/arm64/include/counter.h
@@ -30,12 +30,10 @@
#define _MACHINE_COUNTER_H_
#include <sys/pcpu.h>
-#ifdef INVARIANTS
-#include <sys/proc.h>
-#endif
+#include <machine/atomic.h>
-#define counter_enter() critical_enter()
-#define counter_exit() critical_exit()
+#define counter_enter() do {} while (0)
+#define counter_exit() do {} while (0)
#ifdef IN_SUBR_COUNTER_C
static inline uint64_t
@@ -52,13 +50,12 @@ counter_u64_fetch_inline(uint64_t *p)
int i;
r = 0;
- for (i = 0; i < mp_ncpus; i++)
+ CPU_FOREACH(i)
r += counter_u64_read_one((uint64_t *)p, i);
return (r);
}
-/* XXXKIB might interrupt increment */
static void
counter_u64_zero_one_cpu(void *arg)
{
@@ -76,18 +73,13 @@ counter_u64_zero_inline(counter_u64_t c)
}
#endif
-#define counter_u64_add_protected(c, inc) do { \
- CRITICAL_ASSERT(curthread); \
- *(uint64_t *)zpcpu_get(c) += (inc); \
-} while (0)
+#define counter_u64_add_protected(c, inc) counter_u64_add(c, inc)
static inline void
counter_u64_add(counter_u64_t c, int64_t inc)
{
- counter_enter();
- counter_u64_add_protected(c, inc);
- counter_exit();
+ atomic_add_64((uint64_t *)zpcpu_get(c), inc);
}
#endif /* ! _MACHINE_COUNTER_H_ */
diff --git a/sys/cam/ctl/ctl.c b/sys/cam/ctl/ctl.c
index b80a7d8..e5ca93a 100644
--- a/sys/cam/ctl/ctl.c
+++ b/sys/cam/ctl/ctl.c
@@ -12402,6 +12402,9 @@ ctl_datamove(union ctl_io *io)
if (io->io_hdr.flags & CTL_FLAG_DELAY_DONE) {
io->io_hdr.flags &= ~CTL_FLAG_DELAY_DONE;
} else {
+ struct ctl_lun *lun;
+
+ lun = CTL_LUN(io);
if ((lun != NULL)
&& (lun->delay_info.datamove_delay > 0)) {
diff --git a/sys/cam/ctl/ctl_backend_ramdisk.c b/sys/cam/ctl/ctl_backend_ramdisk.c
index b743bc6..ba3fa1c 100644
--- a/sys/cam/ctl/ctl_backend_ramdisk.c
+++ b/sys/cam/ctl/ctl_backend_ramdisk.c
@@ -1120,8 +1120,10 @@ ctl_backend_ramdisk_create(struct ctl_be_ramdisk_softc *softc,
STAILQ_INIT(&be_lun->cont_queue);
sx_init(&be_lun->page_lock, "cram page lock");
- if (be_lun->cap_bytes == 0)
+ if (be_lun->cap_bytes == 0) {
+ be_lun->indir = 0;
be_lun->pages = malloc(be_lun->pblocksize, M_RAMDISK, M_WAITOK);
+ }
be_lun->zero_page = malloc(be_lun->pblocksize, M_RAMDISK,
M_WAITOK|M_ZERO);
mtx_init(&be_lun->queue_lock, "cram queue lock", NULL, MTX_DEF);
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
index 6e9a624..b80d565 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
@@ -711,7 +711,6 @@ typedef struct arc_stats {
kstat_named_t arcstat_l2_size;
kstat_named_t arcstat_l2_asize;
kstat_named_t arcstat_l2_hdr_size;
- kstat_named_t arcstat_l2_padding_needed;
kstat_named_t arcstat_l2_write_trylock_fail;
kstat_named_t arcstat_l2_write_passed_headroom;
kstat_named_t arcstat_l2_write_spa_mismatch;
@@ -809,7 +808,6 @@ static arc_stats_t arc_stats = {
{ "l2_size", KSTAT_DATA_UINT64 },
{ "l2_asize", KSTAT_DATA_UINT64 },
{ "l2_hdr_size", KSTAT_DATA_UINT64 },
- { "l2_padding_needed", KSTAT_DATA_UINT64 },
{ "l2_write_trylock_fail", KSTAT_DATA_UINT64 },
{ "l2_write_passed_headroom", KSTAT_DATA_UINT64 },
{ "l2_write_spa_mismatch", KSTAT_DATA_UINT64 },
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c
index 9eaa7d2..9ac5fc2 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c
@@ -1604,16 +1604,21 @@ zfsctl_snapshot_vptocnp(struct vop_vptocnp_args *ap)
}
if (sep == NULL) {
mutex_exit(&sdp->sd_lock);
- error = ENOENT;
+ error = SET_ERROR(ENOENT);
} else {
size_t len;
len = strlen(sep->se_name);
- *ap->a_buflen -= len;
- bcopy(sep->se_name, ap->a_buf + *ap->a_buflen, len);
- mutex_exit(&sdp->sd_lock);
- vref(dvp);
- *ap->a_vpp = dvp;
+ if (*ap->a_buflen < len) {
+ mutex_exit(&sdp->sd_lock);
+ error = SET_ERROR(ENOMEM);
+ } else {
+ *ap->a_buflen -= len;
+ bcopy(sep->se_name, ap->a_buf + *ap->a_buflen, len);
+ mutex_exit(&sdp->sd_lock);
+ vref(dvp);
+ *ap->a_vpp = dvp;
+ }
}
VN_RELE(dvp);
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
index aad7a12..7d68e58 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
@@ -5941,6 +5941,10 @@ zfs_vptocnp(struct vop_vptocnp_args *ap)
error = zfs_znode_parent_and_name(zp, &dzp, name);
if (error == 0) {
len = strlen(name);
+ if (*ap->a_buflen < len)
+ error = SET_ERROR(ENOMEM);
+ }
+ if (error == 0) {
*ap->a_buflen -= len;
bcopy(name, ap->a_buf + *ap->a_buflen, len);
*ap->a_vpp = ZTOV(dzp);
diff --git a/sys/cddl/dev/dtrace/x86/dis_tables.c b/sys/cddl/dev/dtrace/x86/dis_tables.c
index 184d4f7..d130b3a 100644
--- a/sys/cddl/dev/dtrace/x86/dis_tables.c
+++ b/sys/cddl/dev/dtrace/x86/dis_tables.c
@@ -21,7 +21,7 @@
*/
/*
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012, Joyent, Inc. All rights reserved.
+ * Copyright 2016 Joyent, Inc.
*/
/*
@@ -87,6 +87,8 @@ typedef struct instable {
uint_t it_always64:1; /* 64 bit when in 64 bit mode */
uint_t it_invalid32:1; /* invalid in IA32 */
uint_t it_stackop:1; /* push/pop stack operation */
+ uint_t it_vexwoxmm:1; /* VEX instructions that don't use XMM/YMM */
+ uint_t it_avxsuf:1; /* AVX suffix required */
} instable_t;
/*
@@ -219,6 +221,7 @@ enum {
VEX_NONE, /* VEX no operand */
VEX_MO, /* VEX mod_rm -> implicit reg */
VEX_RMrX, /* VEX VEX.vvvv, mod_rm -> mod_reg */
+ VEX_VRMrX, /* VEX mod_rm, VEX.vvvv -> mod_rm */
VEX_RRX, /* VEX VEX.vvvv, mod_reg -> mod_rm */
VEX_RMRX, /* VEX VEX.vvvv, mod_rm, imm8[7:4] -> mod_reg */
VEX_MX, /* VEX mod_rm -> mod_reg */
@@ -230,11 +233,16 @@ enum {
VEX_RR, /* VEX mod_rm -> mod_reg */
VEX_RRi, /* VEX mod_rm, imm8 -> mod_reg */
VEX_RM, /* VEX mod_reg -> mod_rm */
+ VEX_RIM, /* VEX mod_reg, imm8 -> mod_rm */
VEX_RRM, /* VEX VEX.vvvv, mod_reg -> mod_rm */
VEX_RMX, /* VEX VEX.vvvv, mod_rm -> mod_reg */
+ VEX_SbVM, /* VEX SIB, VEX.vvvv -> mod_rm */
VMx, /* vmcall/vmlaunch/vmresume/vmxoff */
VMxo, /* VMx instruction with optional prefix */
- SVM /* AMD SVM instructions */
+ SVM, /* AMD SVM instructions */
+ BLS, /* BLSR, BLSMSK, BLSI */
+ FMA, /* FMA instructions, all VEX_RMrX */
+ ADX /* ADX instructions, support REX.w, mod_rm->mod_reg */
};
/*
@@ -272,12 +280,14 @@ enum {
* IND - indirect to another to another table
* "T" - means to Terminate indirections (this is the final opcode)
* "S" - means "operand length suffix required"
+ * "Sa" - means AVX2 suffix (d/q) required
* "NS" - means "no suffix" which is the operand length suffix of the opcode
* "Z" - means instruction size arg required
* "u" - means the opcode is invalid in IA32 but valid in amd64
* "x" - means the opcode is invalid in amd64, but not IA32
* "y" - means the operand size is always 64 bits in 64 bit mode
* "p" - means push/pop stack operation
+ * "vr" - means VEX instruction that operates on normal registers, not fpu
*/
#if defined(DIS_TEXT) && defined(DIS_MEM)
@@ -290,11 +300,13 @@ enum {
#define TNSyp(name, amode) {TERM, amode, name, 0, 0, 0, 1, 0, 1}
#define TNSZ(name, amode, sz) {TERM, amode, name, 0, sz, 0, 0, 0, 0}
#define TNSZy(name, amode, sz) {TERM, amode, name, 0, sz, 0, 1, 0, 0}
+#define TNSZvr(name, amode, sz) {TERM, amode, name, 0, sz, 0, 0, 0, 0, 1}
#define TS(name, amode) {TERM, amode, name, 1, 0, 0, 0, 0, 0}
#define TSx(name, amode) {TERM, amode, name, 1, 0, 1, 0, 0, 0}
#define TSy(name, amode) {TERM, amode, name, 1, 0, 0, 1, 0, 0}
#define TSp(name, amode) {TERM, amode, name, 1, 0, 0, 0, 0, 1}
#define TSZ(name, amode, sz) {TERM, amode, name, 1, sz, 0, 0, 0, 0}
+#define TSaZ(name, amode, sz) {TERM, amode, name, 1, sz, 0, 0, 0, 0, 0, 1}
#define TSZx(name, amode, sz) {TERM, amode, name, 1, sz, 1, 0, 0, 0}
#define TSZy(name, amode, sz) {TERM, amode, name, 1, sz, 0, 1, 0, 0}
#define INVALID {TERM, UNKNOWN, "", 0, 0, 0, 0, 0}
@@ -308,11 +320,13 @@ enum {
#define TNSyp(name, amode) {TERM, amode, name, 0, 0, 1, 0, 1}
#define TNSZ(name, amode, sz) {TERM, amode, name, 0, 0, 0, 0, 0}
#define TNSZy(name, amode, sz) {TERM, amode, name, 0, 0, 1, 0, 0}
+#define TNSZvr(name, amode, sz) {TERM, amode, name, 0, 0, 0, 0, 0, 1}
#define TS(name, amode) {TERM, amode, name, 1, 0, 0, 0, 0}
#define TSx(name, amode) {TERM, amode, name, 1, 1, 0, 0, 0}
#define TSy(name, amode) {TERM, amode, name, 1, 0, 1, 0, 0}
#define TSp(name, amode) {TERM, amode, name, 1, 0, 0, 0, 1}
#define TSZ(name, amode, sz) {TERM, amode, name, 1, 0, 0, 0, 0}
+#define TSaZ(name, amode, sz) {TERM, amode, name, 1, 0, 0, 0, 0, 0, 1}
#define TSZx(name, amode, sz) {TERM, amode, name, 1, 1, 0, 0, 0}
#define TSZy(name, amode, sz) {TERM, amode, name, 1, 0, 1, 0, 0}
#define INVALID {TERM, UNKNOWN, "", 0, 0, 0, 0, 0}
@@ -326,11 +340,13 @@ enum {
#define TNSx(name, amode) {TERM, amode, 0, 1, 0, 0, 0}
#define TNSZ(name, amode, sz) {TERM, amode, sz, 0, 0, 0, 0}
#define TNSZy(name, amode, sz) {TERM, amode, sz, 0, 1, 0, 0}
+#define TNSZvr(name, amode, sz) {TERM, amode, sz, 0, 0, 0, 0, 1}
#define TS(name, amode) {TERM, amode, 0, 0, 0, 0, 0}
#define TSx(name, amode) {TERM, amode, 0, 1, 0, 0, 0}
#define TSy(name, amode) {TERM, amode, 0, 0, 1, 0, 0}
#define TSp(name, amode) {TERM, amode, 0, 0, 0, 0, 1}
#define TSZ(name, amode, sz) {TERM, amode, sz, 0, 0, 0, 0}
+#define TSaZ(name, amode, sz) {TERM, amode, sz, 0, 0, 0, 0, 0, 1}
#define TSZx(name, amode, sz) {TERM, amode, sz, 1, 0, 0, 0}
#define TSZy(name, amode, sz) {TERM, amode, sz, 0, 1, 0, 0}
#define INVALID {TERM, UNKNOWN, 0, 0, 0, 0, 0}
@@ -344,11 +360,13 @@ enum {
#define TNSx(name, amode) {TERM, amode, 1, 0, 0, 0}
#define TNSZ(name, amode, sz) {TERM, amode, 0, 0, 0, 0}
#define TNSZy(name, amode, sz) {TERM, amode, 0, 1, 0, 0}
+#define TNSZvr(name, amode, sz) {TERM, amode, 0, 0, 0, 0, 1}
#define TS(name, amode) {TERM, amode, 0, 0, 0, 0}
#define TSx(name, amode) {TERM, amode, 1, 0, 0, 0}
#define TSy(name, amode) {TERM, amode, 0, 1, 0, 0}
#define TSp(name, amode) {TERM, amode, 0, 0, 0, 1}
#define TSZ(name, amode, sz) {TERM, amode, 0, 0, 0, 0}
+#define TSaZ(name, amode, sz) {TERM, amode, 0, 0, 0, 0, 0, 1}
#define TSZx(name, amode, sz) {TERM, amode, 1, 0, 0, 0}
#define TSZy(name, amode, sz) {TERM, amode, 0, 1, 0, 0}
#define INVALID {TERM, UNKNOWN, 0, 0, 0, 0}
@@ -399,6 +417,12 @@ const char *const dis_addr64_mode12[16] = {
const char *const dis_scale_factor[4] = { ")", ",2)", ",4)", ",8)" };
/*
+ * decode for scale from VSIB byte, note that we always include the scale factor
+ * to match gas.
+ */
+const char *const dis_vscale_factor[4] = { ",1)", ",2)", ",4)", ",8)" };
+
+/*
* register decoding for normal references to registers (ie. not addressing)
*/
const char *const dis_REG8[16] = {
@@ -550,7 +574,7 @@ const instable_t dis_op0FC7[8] = {
const instable_t dis_op0FC7m3[8] = {
/* [0] */ INVALID, INVALID, INVALID, INVALID,
-/* [4] */ INVALID, INVALID, TNS("rdrand",MG9), INVALID,
+/* [4] */ INVALID, INVALID, TNS("rdrand",MG9), TNS("rdseed", MG9),
};
/*
@@ -669,7 +693,7 @@ const instable_t dis_opSIMDdata16[256] = {
/* [70] */ TNSZ("pshufd",XMMP,16), INVALID, INVALID, INVALID,
/* [74] */ TNSZ("pcmpeqb",XMM,16), TNSZ("pcmpeqw",XMM,16), TNSZ("pcmpeqd",XMM,16), INVALID,
/* [78] */ TNSZ("extrq",XMM2I,16), TNSZ("extrq",XMM,16), INVALID, INVALID,
-/* [7C] */ INVALID, INVALID, TNSZ("movd",XMM3MXS,4), TNSZ("movdqa",XMMS,16),
+/* [7C] */ TNSZ("haddpd",XMM,16), TNSZ("hsubpd",XMM,16), TNSZ("movd",XMM3MXS,4), TNSZ("movdqa",XMMS,16),
/* [80] */ INVALID, INVALID, INVALID, INVALID,
/* [84] */ INVALID, INVALID, INVALID, INVALID,
@@ -696,7 +720,7 @@ const instable_t dis_opSIMDdata16[256] = {
/* [C8] */ INVALID, INVALID, INVALID, INVALID,
/* [CC] */ INVALID, INVALID, INVALID, INVALID,
-/* [D0] */ INVALID, TNSZ("psrlw",XMM,16), TNSZ("psrld",XMM,16), TNSZ("psrlq",XMM,16),
+/* [D0] */ TNSZ("addsubpd",XMM,16),TNSZ("psrlw",XMM,16), TNSZ("psrld",XMM,16), TNSZ("psrlq",XMM,16),
/* [D4] */ TNSZ("paddq",XMM,16), TNSZ("pmullw",XMM,16), TNSZ("movq",XMMS,8), TNS("pmovmskb",XMMX3),
/* [D8] */ TNSZ("psubusb",XMM,16), TNSZ("psubusw",XMM,16), TNSZ("pminub",XMM,16), TNSZ("pand",XMM,16),
/* [DC] */ TNSZ("paddusb",XMM,16), TNSZ("paddusw",XMM,16), TNSZ("pmaxub",XMM,16), TNSZ("pandn",XMM,16),
@@ -803,7 +827,7 @@ const instable_t dis_opSIMDrepnz[256] = {
/* [08] */ INVALID, INVALID, INVALID, INVALID,
/* [0C] */ INVALID, INVALID, INVALID, INVALID,
-/* [10] */ TNSZ("movsd",XMM,8), TNSZ("movsd",XMMS,8), INVALID, INVALID,
+/* [10] */ TNSZ("movsd",XMM,8), TNSZ("movsd",XMMS,8), TNSZ("movddup",XMM,8), INVALID,
/* [14] */ INVALID, INVALID, INVALID, INVALID,
/* [18] */ INVALID, INVALID, INVALID, INVALID,
/* [1C] */ INVALID, INVALID, INVALID, INVALID,
@@ -836,7 +860,7 @@ const instable_t dis_opSIMDrepnz[256] = {
/* [70] */ TNSZ("pshuflw",XMMP,16),INVALID, INVALID, INVALID,
/* [74] */ INVALID, INVALID, INVALID, INVALID,
/* [78] */ TNSZ("insertq",XMMX2I,16),TNSZ("insertq",XMM,8),INVALID, INVALID,
-/* [7C] */ INVALID, INVALID, INVALID, INVALID,
+/* [7C] */ TNSZ("haddps",XMM,16), TNSZ("hsubps",XMM,16), INVALID, INVALID,
/* [80] */ INVALID, INVALID, INVALID, INVALID,
/* [84] */ INVALID, INVALID, INVALID, INVALID,
@@ -863,7 +887,7 @@ const instable_t dis_opSIMDrepnz[256] = {
/* [C8] */ INVALID, INVALID, INVALID, INVALID,
/* [CC] */ INVALID, INVALID, INVALID, INVALID,
-/* [D0] */ INVALID, INVALID, INVALID, INVALID,
+/* [D0] */ TNSZ("addsubps",XMM,16),INVALID, INVALID, INVALID,
/* [D4] */ INVALID, INVALID, TNS("movdq2q",XMMXM), INVALID,
/* [D8] */ INVALID, INVALID, INVALID, INVALID,
/* [DC] */ INVALID, INVALID, INVALID, INVALID,
@@ -873,7 +897,7 @@ const instable_t dis_opSIMDrepnz[256] = {
/* [E8] */ INVALID, INVALID, INVALID, INVALID,
/* [EC] */ INVALID, INVALID, INVALID, INVALID,
-/* [F0] */ INVALID, INVALID, INVALID, INVALID,
+/* [F0] */ TNS("lddqu",XMMM), INVALID, INVALID, INVALID,
/* [F4] */ INVALID, INVALID, INVALID, INVALID,
/* [F8] */ INVALID, INVALID, INVALID, INVALID,
/* [FC] */ INVALID, INVALID, INVALID, INVALID,
@@ -961,6 +985,251 @@ const instable_t dis_opAVXF20F[256] = {
/* [FC] */ INVALID, INVALID, INVALID, INVALID,
};
+const instable_t dis_opAVXF20F3A[256] = {
+/* [00] */ INVALID, INVALID, INVALID, INVALID,
+/* [04] */ INVALID, INVALID, INVALID, INVALID,
+/* [08] */ INVALID, INVALID, INVALID, INVALID,
+/* [0C] */ INVALID, INVALID, INVALID, INVALID,
+
+/* [10] */ INVALID, INVALID, INVALID, INVALID,
+/* [14] */ INVALID, INVALID, INVALID, INVALID,
+/* [18] */ INVALID, INVALID, INVALID, INVALID,
+/* [1C] */ INVALID, INVALID, INVALID, INVALID,
+
+/* [20] */ INVALID, INVALID, INVALID, INVALID,
+/* [24] */ INVALID, INVALID, INVALID, INVALID,
+/* [28] */ INVALID, INVALID, INVALID, INVALID,
+/* [2C] */ INVALID, INVALID, INVALID, INVALID,
+
+/* [30] */ INVALID, INVALID, INVALID, INVALID,
+/* [34] */ INVALID, INVALID, INVALID, INVALID,
+/* [38] */ INVALID, INVALID, INVALID, INVALID,
+/* [3C] */ INVALID, INVALID, INVALID, INVALID,
+
+/* [40] */ INVALID, INVALID, INVALID, INVALID,
+/* [44] */ INVALID, INVALID, INVALID, INVALID,
+/* [48] */ INVALID, INVALID, INVALID, INVALID,
+/* [4C] */ INVALID, INVALID, INVALID, INVALID,
+
+/* [50] */ INVALID, INVALID, INVALID, INVALID,
+/* [54] */ INVALID, INVALID, INVALID, INVALID,
+/* [58] */ INVALID, INVALID, INVALID, INVALID,
+/* [5C] */ INVALID, INVALID, INVALID, INVALID,
+
+/* [60] */ INVALID, INVALID, INVALID, INVALID,
+/* [64] */ INVALID, INVALID, INVALID, INVALID,
+/* [68] */ INVALID, INVALID, INVALID, INVALID,
+/* [6C] */ INVALID, INVALID, INVALID, INVALID,
+
+/* [70] */ INVALID, INVALID, INVALID, INVALID,
+/* [74] */ INVALID, INVALID, INVALID, INVALID,
+/* [78] */ INVALID, INVALID, INVALID, INVALID,
+/* [7C] */ INVALID, INVALID, INVALID, INVALID,
+
+/* [80] */ INVALID, INVALID, INVALID, INVALID,
+/* [84] */ INVALID, INVALID, INVALID, INVALID,
+/* [88] */ INVALID, INVALID, INVALID, INVALID,
+/* [0C] */ INVALID, INVALID, INVALID, INVALID,
+
+/* [90] */ INVALID, INVALID, INVALID, INVALID,
+/* [94] */ INVALID, INVALID, INVALID, INVALID,
+/* [98] */ INVALID, INVALID, INVALID, INVALID,
+/* [9C] */ INVALID, INVALID, INVALID, INVALID,
+
+/* [A0] */ INVALID, INVALID, INVALID, INVALID,
+/* [A4] */ INVALID, INVALID, INVALID, INVALID,
+/* [A8] */ INVALID, INVALID, INVALID, INVALID,
+/* [AC] */ INVALID, INVALID, INVALID, INVALID,
+
+/* [B0] */ INVALID, INVALID, INVALID, INVALID,
+/* [B4] */ INVALID, INVALID, INVALID, INVALID,
+/* [B8] */ INVALID, INVALID, INVALID, INVALID,
+/* [BC] */ INVALID, INVALID, INVALID, INVALID,
+
+/* [C0] */ INVALID, INVALID, INVALID, INVALID,
+/* [C4] */ INVALID, INVALID, INVALID, INVALID,
+/* [C8] */ INVALID, INVALID, INVALID, INVALID,
+/* [CC] */ INVALID, INVALID, INVALID, INVALID,
+
+/* [D0] */ INVALID, INVALID, INVALID, INVALID,
+/* [D4] */ INVALID, INVALID, INVALID, INVALID,
+/* [D8] */ INVALID, INVALID, INVALID, INVALID,
+/* [DC] */ INVALID, INVALID, INVALID, INVALID,
+
+/* [E0] */ INVALID, INVALID, INVALID, INVALID,
+/* [E4] */ INVALID, INVALID, INVALID, INVALID,
+/* [E8] */ INVALID, INVALID, INVALID, INVALID,
+/* [EC] */ INVALID, INVALID, INVALID, INVALID,
+
+/* [F0] */ TNSZvr("rorx",VEX_MXI,6),INVALID, INVALID, INVALID,
+/* [F4] */ INVALID, INVALID, INVALID, INVALID,
+/* [F8] */ INVALID, INVALID, INVALID, INVALID,
+/* [FC] */ INVALID, INVALID, INVALID, INVALID,
+};
+
+const instable_t dis_opAVXF20F38[256] = {
+/* [00] */ INVALID, INVALID, INVALID, INVALID,
+/* [04] */ INVALID, INVALID, INVALID, INVALID,
+/* [08] */ INVALID, INVALID, INVALID, INVALID,
+/* [0C] */ INVALID, INVALID, INVALID, INVALID,
+
+/* [10] */ INVALID, INVALID, INVALID, INVALID,
+/* [14] */ INVALID, INVALID, INVALID, INVALID,
+/* [18] */ INVALID, INVALID, INVALID, INVALID,
+/* [1C] */ INVALID, INVALID, INVALID, INVALID,
+
+/* [20] */ INVALID, INVALID, INVALID, INVALID,
+/* [24] */ INVALID, INVALID, INVALID, INVALID,
+/* [28] */ INVALID, INVALID, INVALID, INVALID,
+/* [2C] */ INVALID, INVALID, INVALID, INVALID,
+
+/* [30] */ INVALID, INVALID, INVALID, INVALID,
+/* [34] */ INVALID, INVALID, INVALID, INVALID,
+/* [38] */ INVALID, INVALID, INVALID, INVALID,
+/* [3C] */ INVALID, INVALID, INVALID, INVALID,
+
+/* [40] */ INVALID, INVALID, INVALID, INVALID,
+/* [44] */ INVALID, INVALID, INVALID, INVALID,
+/* [48] */ INVALID, INVALID, INVALID, INVALID,
+/* [4C] */ INVALID, INVALID, INVALID, INVALID,
+
+/* [50] */ INVALID, INVALID, INVALID, INVALID,
+/* [54] */ INVALID, INVALID, INVALID, INVALID,
+/* [58] */ INVALID, INVALID, INVALID, INVALID,
+/* [5C] */ INVALID, INVALID, INVALID, INVALID,
+
+/* [60] */ INVALID, INVALID, INVALID, INVALID,
+/* [64] */ INVALID, INVALID, INVALID, INVALID,
+/* [68] */ INVALID, INVALID, INVALID, INVALID,
+/* [6C] */ INVALID, INVALID, INVALID, INVALID,
+
+/* [70] */ INVALID, INVALID, INVALID, INVALID,
+/* [74] */ INVALID, INVALID, INVALID, INVALID,
+/* [78] */ INVALID, INVALID, INVALID, INVALID,
+/* [7C] */ INVALID, INVALID, INVALID, INVALID,
+
+/* [80] */ INVALID, INVALID, INVALID, INVALID,
+/* [84] */ INVALID, INVALID, INVALID, INVALID,
+/* [88] */ INVALID, INVALID, INVALID, INVALID,
+/* [0C] */ INVALID, INVALID, INVALID, INVALID,
+
+/* [90] */ INVALID, INVALID, INVALID, INVALID,
+/* [94] */ INVALID, INVALID, INVALID, INVALID,
+/* [98] */ INVALID, INVALID, INVALID, INVALID,
+/* [9C] */ INVALID, INVALID, INVALID, INVALID,
+
+/* [A0] */ INVALID, INVALID, INVALID, INVALID,
+/* [A4] */ INVALID, INVALID, INVALID, INVALID,
+/* [A8] */ INVALID, INVALID, INVALID, INVALID,
+/* [AC] */ INVALID, INVALID, INVALID, INVALID,
+
+/* [B0] */ INVALID, INVALID, INVALID, INVALID,
+/* [B4] */ INVALID, INVALID, INVALID, INVALID,
+/* [B8] */ INVALID, INVALID, INVALID, INVALID,
+/* [BC] */ INVALID, INVALID, INVALID, INVALID,
+
+/* [C0] */ INVALID, INVALID, INVALID, INVALID,
+/* [C4] */ INVALID, INVALID, INVALID, INVALID,
+/* [C8] */ INVALID, INVALID, INVALID, INVALID,
+/* [CC] */ INVALID, INVALID, INVALID, INVALID,
+
+/* [D0] */ INVALID, INVALID, INVALID, INVALID,
+/* [D4] */ INVALID, INVALID, INVALID, INVALID,
+/* [D8] */ INVALID, INVALID, INVALID, INVALID,
+/* [DC] */ INVALID, INVALID, INVALID, INVALID,
+
+/* [E0] */ INVALID, INVALID, INVALID, INVALID,
+/* [E4] */ INVALID, INVALID, INVALID, INVALID,
+/* [E8] */ INVALID, INVALID, INVALID, INVALID,
+/* [EC] */ INVALID, INVALID, INVALID, INVALID,
+
+/* [F0] */ INVALID, INVALID, INVALID, INVALID,
+/* [F4] */ INVALID, TNSZvr("pdep",VEX_RMrX,5),TNSZvr("mulx",VEX_RMrX,5),TNSZvr("shrx",VEX_VRMrX,5),
+/* [F8] */ INVALID, INVALID, INVALID, INVALID,
+/* [FC] */ INVALID, INVALID, INVALID, INVALID,
+};
+
+const instable_t dis_opAVXF30F38[256] = {
+/* [00] */ INVALID, INVALID, INVALID, INVALID,
+/* [04] */ INVALID, INVALID, INVALID, INVALID,
+/* [08] */ INVALID, INVALID, INVALID, INVALID,
+/* [0C] */ INVALID, INVALID, INVALID, INVALID,
+
+/* [10] */ INVALID, INVALID, INVALID, INVALID,
+/* [14] */ INVALID, INVALID, INVALID, INVALID,
+/* [18] */ INVALID, INVALID, INVALID, INVALID,
+/* [1C] */ INVALID, INVALID, INVALID, INVALID,
+
+/* [20] */ INVALID, INVALID, INVALID, INVALID,
+/* [24] */ INVALID, INVALID, INVALID, INVALID,
+/* [28] */ INVALID, INVALID, INVALID, INVALID,
+/* [2C] */ INVALID, INVALID, INVALID, INVALID,
+
+/* [30] */ INVALID, INVALID, INVALID, INVALID,
+/* [34] */ INVALID, INVALID, INVALID, INVALID,
+/* [38] */ INVALID, INVALID, INVALID, INVALID,
+/* [3C] */ INVALID, INVALID, INVALID, INVALID,
+
+/* [40] */ INVALID, INVALID, INVALID, INVALID,
+/* [44] */ INVALID, INVALID, INVALID, INVALID,
+/* [48] */ INVALID, INVALID, INVALID, INVALID,
+/* [4C] */ INVALID, INVALID, INVALID, INVALID,
+
+/* [50] */ INVALID, INVALID, INVALID, INVALID,
+/* [54] */ INVALID, INVALID, INVALID, INVALID,
+/* [58] */ INVALID, INVALID, INVALID, INVALID,
+/* [5C] */ INVALID, INVALID, INVALID, INVALID,
+
+/* [60] */ INVALID, INVALID, INVALID, INVALID,
+/* [64] */ INVALID, INVALID, INVALID, INVALID,
+/* [68] */ INVALID, INVALID, INVALID, INVALID,
+/* [6C] */ INVALID, INVALID, INVALID, INVALID,
+
+/* [70] */ INVALID, INVALID, INVALID, INVALID,
+/* [74] */ INVALID, INVALID, INVALID, INVALID,
+/* [78] */ INVALID, INVALID, INVALID, INVALID,
+/* [7C] */ INVALID, INVALID, INVALID, INVALID,
+
+/* [80] */ INVALID, INVALID, INVALID, INVALID,
+/* [84] */ INVALID, INVALID, INVALID, INVALID,
+/* [88] */ INVALID, INVALID, INVALID, INVALID,
+/* [0C] */ INVALID, INVALID, INVALID, INVALID,
+
+/* [90] */ INVALID, INVALID, INVALID, INVALID,
+/* [94] */ INVALID, INVALID, INVALID, INVALID,
+/* [98] */ INVALID, INVALID, INVALID, INVALID,
+/* [9C] */ INVALID, INVALID, INVALID, INVALID,
+
+/* [A0] */ INVALID, INVALID, INVALID, INVALID,
+/* [A4] */ INVALID, INVALID, INVALID, INVALID,
+/* [A8] */ INVALID, INVALID, INVALID, INVALID,
+/* [AC] */ INVALID, INVALID, INVALID, INVALID,
+
+/* [B0] */ INVALID, INVALID, INVALID, INVALID,
+/* [B4] */ INVALID, INVALID, INVALID, INVALID,
+/* [B8] */ INVALID, INVALID, INVALID, INVALID,
+/* [BC] */ INVALID, INVALID, INVALID, INVALID,
+
+/* [C0] */ INVALID, INVALID, INVALID, INVALID,
+/* [C4] */ INVALID, INVALID, INVALID, INVALID,
+/* [C8] */ INVALID, INVALID, INVALID, INVALID,
+/* [CC] */ INVALID, INVALID, INVALID, INVALID,
+
+/* [D0] */ INVALID, INVALID, INVALID, INVALID,
+/* [D4] */ INVALID, INVALID, INVALID, INVALID,
+/* [D8] */ INVALID, INVALID, INVALID, INVALID,
+/* [DC] */ INVALID, INVALID, INVALID, INVALID,
+
+/* [E0] */ INVALID, INVALID, INVALID, INVALID,
+/* [E4] */ INVALID, INVALID, INVALID, INVALID,
+/* [E8] */ INVALID, INVALID, INVALID, INVALID,
+/* [EC] */ INVALID, INVALID, INVALID, INVALID,
+
+/* [F0] */ INVALID, INVALID, INVALID, INVALID,
+/* [F4] */ INVALID, TNSZvr("pext",VEX_RMrX,5),INVALID, TNSZvr("sarx",VEX_VRMrX,5),
+/* [F8] */ INVALID, INVALID, INVALID, INVALID,
+/* [FC] */ INVALID, INVALID, INVALID, INVALID,
+};
/*
* Decode table for SIMD instructions with the repz (0xf3) prefix.
*/
@@ -970,8 +1239,8 @@ const instable_t dis_opSIMDrepz[256] = {
/* [08] */ INVALID, INVALID, INVALID, INVALID,
/* [0C] */ INVALID, INVALID, INVALID, INVALID,
-/* [10] */ TNSZ("movss",XMM,4), TNSZ("movss",XMMS,4), INVALID, INVALID,
-/* [14] */ INVALID, INVALID, INVALID, INVALID,
+/* [10] */ TNSZ("movss",XMM,4), TNSZ("movss",XMMS,4), TNSZ("movsldup",XMM,16),INVALID,
+/* [14] */ INVALID, INVALID, TNSZ("movshdup",XMM,16),INVALID,
/* [18] */ INVALID, INVALID, INVALID, INVALID,
/* [1C] */ INVALID, INVALID, INVALID, INVALID,
@@ -1023,7 +1292,7 @@ const instable_t dis_opSIMDrepz[256] = {
/* [B0] */ INVALID, INVALID, INVALID, INVALID,
/* [B4] */ INVALID, INVALID, INVALID, INVALID,
/* [B8] */ TS("popcnt",MRw), INVALID, INVALID, INVALID,
-/* [BC] */ INVALID, TS("lzcnt",MRw), INVALID, INVALID,
+/* [BC] */ TNSZ("tzcnt",MRw,5), TS("lzcnt",MRw), INVALID, INVALID,
/* [C0] */ INVALID, INVALID, TNSZ("cmpss",XMMP,4), INVALID,
/* [C4] */ INVALID, INVALID, INVALID, INVALID,
@@ -1141,6 +1410,15 @@ const instable_t dis_op0F38F1[2] = {
TS("movbe",MOVBE),
};
+/*
+ * The following table is used to distinguish between adox and adcx which share
+ * the same opcodes.
+ */
+const instable_t dis_op0F38F6[2] = {
+/* [00] */ TNS("adcx",ADX),
+ TNS("adox",ADX),
+};
+
const instable_t dis_op0F38[256] = {
/* [00] */ TNSZ("pshufb",XMM_66o,16),TNSZ("phaddw",XMM_66o,16),TNSZ("phaddd",XMM_66o,16),TNSZ("phaddsw",XMM_66o,16),
/* [04] */ TNSZ("pmaddubsw",XMM_66o,16),TNSZ("phsubw",XMM_66o,16), TNSZ("phsubd",XMM_66o,16),TNSZ("phsubsw",XMM_66o,16),
@@ -1204,8 +1482,8 @@ const instable_t dis_op0F38[256] = {
/* [C0] */ INVALID, INVALID, INVALID, INVALID,
/* [C4] */ INVALID, INVALID, INVALID, INVALID,
-/* [C8] */ INVALID, INVALID, INVALID, INVALID,
-/* [CC] */ INVALID, INVALID, INVALID, INVALID,
+/* [C8] */ TNSZ("sha1nexte",XMM,16),TNSZ("sha1msg1",XMM,16),TNSZ("sha1msg2",XMM,16),TNSZ("sha256rnds2",XMM,16),
+/* [CC] */ TNSZ("sha256msg1",XMM,16),TNSZ("sha256msg2",XMM,16),INVALID, INVALID,
/* [D0] */ INVALID, INVALID, INVALID, INVALID,
/* [D4] */ INVALID, INVALID, INVALID, INVALID,
@@ -1217,7 +1495,7 @@ const instable_t dis_op0F38[256] = {
/* [E8] */ INVALID, INVALID, INVALID, INVALID,
/* [EC] */ INVALID, INVALID, INVALID, INVALID,
/* [F0] */ IND(dis_op0F38F0), IND(dis_op0F38F1), INVALID, INVALID,
-/* [F4] */ INVALID, INVALID, INVALID, INVALID,
+/* [F4] */ INVALID, INVALID, IND(dis_op0F38F6), INVALID,
/* [F8] */ INVALID, INVALID, INVALID, INVALID,
/* [FC] */ INVALID, INVALID, INVALID, INVALID,
};
@@ -1229,7 +1507,7 @@ const instable_t dis_opAVX660F38[256] = {
/* [0C] */ TNSZ("vpermilps",VEX_RMrX,8),TNSZ("vpermilpd",VEX_RMrX,16),TNSZ("vtestps",VEX_RRI,8), TNSZ("vtestpd",VEX_RRI,16),
/* [10] */ INVALID, INVALID, INVALID, TNSZ("vcvtph2ps",VEX_MX,16),
-/* [14] */ INVALID, INVALID, INVALID, TNSZ("vptest",VEX_RRI,16),
+/* [14] */ INVALID, INVALID, TNSZ("vpermps",VEX_RMrX,16),TNSZ("vptest",VEX_RRI,16),
/* [18] */ TNSZ("vbroadcastss",VEX_MX,4),TNSZ("vbroadcastsd",VEX_MX,8),TNSZ("vbroadcastf128",VEX_MX,16),INVALID,
/* [1C] */ TNSZ("vpabsb",VEX_MX,16),TNSZ("vpabsw",VEX_MX,16),TNSZ("vpabsd",VEX_MX,16),INVALID,
@@ -1239,18 +1517,18 @@ const instable_t dis_opAVX660F38[256] = {
/* [2C] */ TNSZ("vmaskmovps",VEX_RMrX,8),TNSZ("vmaskmovpd",VEX_RMrX,16),TNSZ("vmaskmovps",VEX_RRM,8),TNSZ("vmaskmovpd",VEX_RRM,16),
/* [30] */ TNSZ("vpmovzxbw",VEX_MX,16),TNSZ("vpmovzxbd",VEX_MX,16),TNSZ("vpmovzxbq",VEX_MX,16),TNSZ("vpmovzxwd",VEX_MX,16),
-/* [34] */ TNSZ("vpmovzxwq",VEX_MX,16),TNSZ("vpmovzxdq",VEX_MX,16),INVALID, TNSZ("vpcmpgtq",VEX_RMrX,16),
+/* [34] */ TNSZ("vpmovzxwq",VEX_MX,16),TNSZ("vpmovzxdq",VEX_MX,16),TNSZ("vpermd",VEX_RMrX,16),TNSZ("vpcmpgtq",VEX_RMrX,16),
/* [38] */ TNSZ("vpminsb",VEX_RMrX,16),TNSZ("vpminsd",VEX_RMrX,16),TNSZ("vpminuw",VEX_RMrX,16),TNSZ("vpminud",VEX_RMrX,16),
/* [3C] */ TNSZ("vpmaxsb",VEX_RMrX,16),TNSZ("vpmaxsd",VEX_RMrX,16),TNSZ("vpmaxuw",VEX_RMrX,16),TNSZ("vpmaxud",VEX_RMrX,16),
/* [40] */ TNSZ("vpmulld",VEX_RMrX,16),TNSZ("vphminposuw",VEX_MX,16),INVALID, INVALID,
-/* [44] */ INVALID, INVALID, INVALID, INVALID,
+/* [44] */ INVALID, TSaZ("vpsrlv",VEX_RMrX,16),TNSZ("vpsravd",VEX_RMrX,16),TSaZ("vpsllv",VEX_RMrX,16),
/* [48] */ INVALID, INVALID, INVALID, INVALID,
/* [4C] */ INVALID, INVALID, INVALID, INVALID,
/* [50] */ INVALID, INVALID, INVALID, INVALID,
/* [54] */ INVALID, INVALID, INVALID, INVALID,
-/* [58] */ INVALID, INVALID, INVALID, INVALID,
+/* [58] */ TNSZ("vpbroadcastd",VEX_MX,16),TNSZ("vpbroadcastq",VEX_MX,16),TNSZ("vbroadcasti128",VEX_MX,16),INVALID,
/* [5C] */ INVALID, INVALID, INVALID, INVALID,
/* [60] */ INVALID, INVALID, INVALID, INVALID,
@@ -1260,28 +1538,28 @@ const instable_t dis_opAVX660F38[256] = {
/* [70] */ INVALID, INVALID, INVALID, INVALID,
/* [74] */ INVALID, INVALID, INVALID, INVALID,
-/* [78] */ INVALID, INVALID, INVALID, INVALID,
+/* [78] */ TNSZ("vpbroadcastb",VEX_MX,16),TNSZ("vpbroadcastw",VEX_MX,16),INVALID, INVALID,
/* [7C] */ INVALID, INVALID, INVALID, INVALID,
/* [80] */ INVALID, INVALID, INVALID, INVALID,
/* [84] */ INVALID, INVALID, INVALID, INVALID,
/* [88] */ INVALID, INVALID, INVALID, INVALID,
-/* [8C] */ INVALID, INVALID, INVALID, INVALID,
+/* [8C] */ TSaZ("vpmaskmov",VEX_RMrX,16),INVALID, TSaZ("vpmaskmov",VEX_RRM,16),INVALID,
-/* [90] */ INVALID, INVALID, INVALID, INVALID,
-/* [94] */ INVALID, INVALID, INVALID, INVALID,
-/* [98] */ INVALID, INVALID, INVALID, INVALID,
-/* [9C] */ INVALID, INVALID, INVALID, INVALID,
+/* [90] */ TNSZ("vpgatherd",VEX_SbVM,16),TNSZ("vpgatherq",VEX_SbVM,16),TNSZ("vgatherdp",VEX_SbVM,16),TNSZ("vgatherqp",VEX_SbVM,16),
+/* [94] */ INVALID, INVALID, TNSZ("vfmaddsub132p",FMA,16),TNSZ("vfmsubadd132p",FMA,16),
+/* [98] */ TNSZ("vfmadd132p",FMA,16),TNSZ("vfmadd132s",FMA,16),TNSZ("vfmsub132p",FMA,16),TNSZ("vfmsub132s",FMA,16),
+/* [9C] */ TNSZ("vfnmadd132p",FMA,16),TNSZ("vfnmadd132s",FMA,16),TNSZ("vfnmsub132p",FMA,16),TNSZ("vfnmsub132s",FMA,16),
/* [A0] */ INVALID, INVALID, INVALID, INVALID,
-/* [A4] */ INVALID, INVALID, INVALID, INVALID,
-/* [A8] */ INVALID, INVALID, INVALID, INVALID,
-/* [AC] */ INVALID, INVALID, INVALID, INVALID,
+/* [A4] */ INVALID, INVALID, TNSZ("vfmaddsub213p",FMA,16),TNSZ("vfmsubadd213p",FMA,16),
+/* [A8] */ TNSZ("vfmadd213p",FMA,16),TNSZ("vfmadd213s",FMA,16),TNSZ("vfmsub213p",FMA,16),TNSZ("vfmsub213s",FMA,16),
+/* [AC] */ TNSZ("vfnmadd213p",FMA,16),TNSZ("vfnmadd213s",FMA,16),TNSZ("vfnmsub213p",FMA,16),TNSZ("vfnmsub213s",FMA,16),
/* [B0] */ INVALID, INVALID, INVALID, INVALID,
-/* [B4] */ INVALID, INVALID, INVALID, INVALID,
-/* [B8] */ INVALID, INVALID, INVALID, INVALID,
-/* [BC] */ INVALID, INVALID, INVALID, INVALID,
+/* [B4] */ INVALID, INVALID, TNSZ("vfmaddsub231p",FMA,16),TNSZ("vfmsubadd231p",FMA,16),
+/* [B8] */ TNSZ("vfmadd231p",FMA,16),TNSZ("vfmadd231s",FMA,16),TNSZ("vfmsub231p",FMA,16),TNSZ("vfmsub231s",FMA,16),
+/* [BC] */ TNSZ("vfnmadd231p",FMA,16),TNSZ("vfnmadd231s",FMA,16),TNSZ("vfnmsub231p",FMA,16),TNSZ("vfnmsub231s",FMA,16),
/* [C0] */ INVALID, INVALID, INVALID, INVALID,
/* [C4] */ INVALID, INVALID, INVALID, INVALID,
@@ -1298,7 +1576,7 @@ const instable_t dis_opAVX660F38[256] = {
/* [E8] */ INVALID, INVALID, INVALID, INVALID,
/* [EC] */ INVALID, INVALID, INVALID, INVALID,
/* [F0] */ IND(dis_op0F38F0), IND(dis_op0F38F1), INVALID, INVALID,
-/* [F4] */ INVALID, INVALID, INVALID, INVALID,
+/* [F4] */ INVALID, INVALID, INVALID, TNSZvr("shlx",VEX_VRMrX,5),
/* [F8] */ INVALID, INVALID, INVALID, INVALID,
/* [FC] */ INVALID, INVALID, INVALID, INVALID,
};
@@ -1367,7 +1645,7 @@ const instable_t dis_op0F3A[256] = {
/* [C0] */ INVALID, INVALID, INVALID, INVALID,
/* [C4] */ INVALID, INVALID, INVALID, INVALID,
/* [C8] */ INVALID, INVALID, INVALID, INVALID,
-/* [CC] */ INVALID, INVALID, INVALID, INVALID,
+/* [CC] */ TNSZ("sha1rnds4",XMMP,16),INVALID, INVALID, INVALID,
/* [D0] */ INVALID, INVALID, INVALID, INVALID,
/* [D4] */ INVALID, INVALID, INVALID, INVALID,
@@ -1386,7 +1664,7 @@ const instable_t dis_op0F3A[256] = {
};
const instable_t dis_opAVX660F3A[256] = {
-/* [00] */ INVALID, INVALID, INVALID, INVALID,
+/* [00] */ TNSZ("vpermq",VEX_MXI,16),TNSZ("vpermpd",VEX_MXI,16),TNSZ("vpblendd",VEX_RMRX,16),INVALID,
/* [04] */ TNSZ("vpermilps",VEX_MXI,8),TNSZ("vpermilpd",VEX_MXI,16),TNSZ("vperm2f128",VEX_RMRX,16),INVALID,
/* [08] */ TNSZ("vroundps",VEX_MXI,16),TNSZ("vroundpd",VEX_MXI,16),TNSZ("vroundss",VEX_RMRX,16),TNSZ("vroundsd",VEX_RMRX,16),
/* [0C] */ TNSZ("vblendps",VEX_RMRX,16),TNSZ("vblendpd",VEX_RMRX,16),TNSZ("vpblendw",VEX_RMRX,16),TNSZ("vpalignr",VEX_RMRX,16),
@@ -1403,11 +1681,11 @@ const instable_t dis_opAVX660F3A[256] = {
/* [30] */ INVALID, INVALID, INVALID, INVALID,
/* [34] */ INVALID, INVALID, INVALID, INVALID,
-/* [38] */ INVALID, INVALID, INVALID, INVALID,
+/* [38] */ TNSZ("vinserti128",VEX_RMRX,16),TNSZ("vextracti128",VEX_RIM,16),INVALID, INVALID,
/* [3C] */ INVALID, INVALID, INVALID, INVALID,
/* [40] */ TNSZ("vdpps",VEX_RMRX,16),TNSZ("vdppd",VEX_RMRX,16),TNSZ("vmpsadbw",VEX_RMRX,16),INVALID,
-/* [44] */ TNSZ("vpclmulqdq",VEX_RMRX,16),INVALID, INVALID, INVALID,
+/* [44] */ TNSZ("vpclmulqdq",VEX_RMRX,16),INVALID, TNSZ("vperm2i128",VEX_RMRX,16),INVALID,
/* [48] */ INVALID, INVALID, TNSZ("vblendvps",VEX_RMRX,8), TNSZ("vblendvpd",VEX_RMRX,16),
/* [4C] */ TNSZ("vpblendvb",VEX_RMRX,16),INVALID, INVALID, INVALID,
@@ -1468,6 +1746,15 @@ const instable_t dis_opAVX660F3A[256] = {
};
/*
+ * Decode table for 0x0F0D which uses the first byte of the mod_rm to
+ * indicate a sub-code.
+ */
+const instable_t dis_op0F0D[8] = {
+/* [00] */ INVALID, TNS("prefetchw",PREF), TNS("prefetchwt1",PREF),INVALID,
+/* [04] */ INVALID, INVALID, INVALID, INVALID,
+};
+
+/*
* Decode table for 0x0F opcodes
*/
@@ -1476,7 +1763,7 @@ const instable_t dis_op0F[16][16] = {
/* [00] */ IND(dis_op0F00), IND(dis_op0F01), TNS("lar",MR), TNS("lsl",MR),
/* [04] */ INVALID, TNS("syscall",NORM), TNS("clts",NORM), TNS("sysret",NORM),
/* [08] */ TNS("invd",NORM), TNS("wbinvd",NORM), INVALID, TNS("ud2",NORM),
-/* [0C] */ INVALID, INVALID, INVALID, INVALID,
+/* [0C] */ INVALID, IND(dis_op0F0D), INVALID, INVALID,
}, {
/* [10] */ TNSZ("movups",XMMO,16), TNSZ("movups",XMMOS,16),TNSZ("movlps",XMMO,8), TNSZ("movlps",XMMOS,8),
/* [14] */ TNSZ("unpcklps",XMMO,16),TNSZ("unpckhps",XMMO,16),TNSZ("movhps",XMMOM,8),TNSZ("movhps",XMMOMS,8),
@@ -1631,8 +1918,8 @@ const instable_t dis_opAVX0F[16][16] = {
/* [E8] */ INVALID, INVALID, INVALID, INVALID,
/* [EC] */ INVALID, INVALID, INVALID, INVALID,
}, {
-/* [F0] */ INVALID, INVALID, INVALID, INVALID,
-/* [F4] */ INVALID, INVALID, INVALID, INVALID,
+/* [F0] */ INVALID, INVALID, TNSZvr("andn",VEX_RMrX,5),TNSZvr("bls",BLS,5),
+/* [F4] */ INVALID, TNSZvr("bzhi",VEX_VRMrX,5),INVALID, TNSZvr("bextr",VEX_VRMrX,5),
/* [F8] */ INVALID, INVALID, INVALID, INVALID,
/* [FC] */ INVALID, INVALID, INVALID, INVALID,
} };
@@ -1795,19 +2082,19 @@ const instable_t dis_opFP1n2[8][8] = {
/* [2,0] */ TNS("fiaddl",M), TNS("fimull",M), TNS("ficoml",M), TNS("ficompl",M),
/* [2,4] */ TNS("fisubl",M), TNS("fisubrl",M), TNS("fidivl",M), TNS("fidivrl",M),
}, {
-/* [3,0] */ TNS("fildl",M), INVALID, TNS("fistl",M), TNS("fistpl",M),
+/* [3,0] */ TNS("fildl",M), TNSZ("tisttpl",M,4), TNS("fistl",M), TNS("fistpl",M),
/* [3,4] */ INVALID, TNSZ("fldt",M,10), INVALID, TNSZ("fstpt",M,10),
}, {
/* [4,0] */ TNSZ("faddl",M,8), TNSZ("fmull",M,8), TNSZ("fcoml",M,8), TNSZ("fcompl",M,8),
/* [4,1] */ TNSZ("fsubl",M,8), TNSZ("fsubrl",M,8), TNSZ("fdivl",M,8), TNSZ("fdivrl",M,8),
}, {
-/* [5,0] */ TNSZ("fldl",M,8), INVALID, TNSZ("fstl",M,8), TNSZ("fstpl",M,8),
+/* [5,0] */ TNSZ("fldl",M,8), TNSZ("fisttpll",M,8), TNSZ("fstl",M,8), TNSZ("fstpl",M,8),
/* [5,4] */ TNSZ("frstor",M,108), INVALID, TNSZ("fnsave",M,108), TNSZ("fnstsw",M,2),
}, {
/* [6,0] */ TNSZ("fiadd",M,2), TNSZ("fimul",M,2), TNSZ("ficom",M,2), TNSZ("ficomp",M,2),
/* [6,4] */ TNSZ("fisub",M,2), TNSZ("fisubr",M,2), TNSZ("fidiv",M,2), TNSZ("fidivr",M,2),
}, {
-/* [7,0] */ TNSZ("fild",M,2), INVALID, TNSZ("fist",M,2), TNSZ("fistp",M,2),
+/* [7,0] */ TNSZ("fild",M,2), TNSZ("fisttp",M,2), TNSZ("fist",M,2), TNSZ("fistp",M,2),
/* [7,4] */ TNSZ("fbld",M,10), TNSZ("fildll",M,8), TNSZ("fbstp",M,10), TNSZ("fistpll",M,8),
} };
@@ -2039,6 +2326,80 @@ static int isize64[] = {1, 2, 4, 8};
#define YMM_OPND 9 /* "value" used to indicate a ymm reg */
/*
+ * The AVX2 gather instructions are a bit of a mess. While there's a pattern,
+ * there's not really a consistent scheme that we can use to know what the mode
+ * is supposed to be for a given type. Various instructions, like VPGATHERDD,
+ * always match the value of VEX_L. Other instructions like VPGATHERDQ, have
+ * some registers match VEX_L, but the VSIB is always XMM.
+ *
+ * The simplest way to deal with this is to just define a table based on the
+ * instruction opcodes, which are 0x90-0x93, so we subtract 0x90 to index into
+ * them.
+ *
+ * We further have to subdivide this based on the value of VEX_W and the value
+ * of VEX_L. The array is constructed to be indexed as:
+ * [opcode - 0x90][VEX_W][VEX_L].
+ */
+/* w = 0, 0x90 */
+typedef struct dis_gather_regs {
+ uint_t dgr_arg0; /* src reg */
+ uint_t dgr_arg1; /* vsib reg */
+ uint_t dgr_arg2; /* dst reg */
+ char *dgr_suffix; /* suffix to append */
+} dis_gather_regs_t;
+
+static dis_gather_regs_t dis_vgather[4][2][2] = {
+ {
+ /* op 0x90, W.0 */
+ {
+ { XMM_OPND, XMM_OPND, XMM_OPND, "d" },
+ { YMM_OPND, YMM_OPND, YMM_OPND, "d" }
+ },
+ /* op 0x90, W.1 */
+ {
+ { XMM_OPND, XMM_OPND, XMM_OPND, "q" },
+ { YMM_OPND, XMM_OPND, YMM_OPND, "q" }
+ }
+ },
+ {
+ /* op 0x91, W.0 */
+ {
+ { XMM_OPND, XMM_OPND, XMM_OPND, "d" },
+ { XMM_OPND, YMM_OPND, XMM_OPND, "d" },
+ },
+ /* op 0x91, W.1 */
+ {
+ { XMM_OPND, XMM_OPND, XMM_OPND, "q" },
+ { YMM_OPND, YMM_OPND, YMM_OPND, "q" },
+ }
+ },
+ {
+ /* op 0x92, W.0 */
+ {
+ { XMM_OPND, XMM_OPND, XMM_OPND, "s" },
+ { YMM_OPND, YMM_OPND, YMM_OPND, "s" }
+ },
+ /* op 0x92, W.1 */
+ {
+ { XMM_OPND, XMM_OPND, XMM_OPND, "d" },
+ { YMM_OPND, XMM_OPND, YMM_OPND, "d" }
+ }
+ },
+ {
+ /* op 0x93, W.0 */
+ {
+ { XMM_OPND, XMM_OPND, XMM_OPND, "s" },
+ { XMM_OPND, YMM_OPND, XMM_OPND, "s" }
+ },
+ /* op 0x93, W.1 */
+ {
+ { XMM_OPND, XMM_OPND, XMM_OPND, "d" },
+ { YMM_OPND, YMM_OPND, YMM_OPND, "d" }
+ }
+ }
+};
+
+/*
* Get the next byte and separate the op code into the high and low nibbles.
*/
static int
@@ -2409,16 +2770,29 @@ dtrace_get_operand(dis86_t *x, uint_t mode, uint_t r_m, int wbit, int opindex)
} else {
uint_t need_paren = 0;
char **regs;
+ char **bregs;
+ const char *const *sf;
if (x->d86_mode == SIZE32) /* NOTE this is not addr_size! */
regs = (char **)dis_REG32;
else
regs = (char **)dis_REG64;
+ if (x->d86_vsib != 0) {
+ if (wbit == YMM_OPND) /* NOTE this is not addr_size! */
+ bregs = (char **)dis_YMMREG;
+ else
+ bregs = (char **)dis_XMMREG;
+ sf = dis_vscale_factor;
+ } else {
+ bregs = regs;
+ sf = dis_scale_factor;
+ }
+
/*
* print the base (if any)
*/
if (base == EBP_REGNO && mode == 0) {
- if (index != ESP_REGNO) {
+ if (index != ESP_REGNO || x->d86_vsib != 0) {
(void) strlcat(opnd, "(", OPLEN);
need_paren = 1;
}
@@ -2431,10 +2805,10 @@ dtrace_get_operand(dis86_t *x, uint_t mode, uint_t r_m, int wbit, int opindex)
/*
* print the index (if any)
*/
- if (index != ESP_REGNO) {
+ if (index != ESP_REGNO || x->d86_vsib) {
(void) strlcat(opnd, ",", OPLEN);
- (void) strlcat(opnd, regs[index], OPLEN);
- (void) strlcat(opnd, dis_scale_factor[ss], OPLEN);
+ (void) strlcat(opnd, bregs[index], OPLEN);
+ (void) strlcat(opnd, sf[ss], OPLEN);
} else
if (need_paren)
(void) strlcat(opnd, ")", OPLEN);
@@ -2581,7 +2955,12 @@ dtrace_disx86(dis86_t *x, uint_t cpu_mode)
uint_t vex_B = 1;
uint_t vex_W = 0;
uint_t vex_L;
+ dis_gather_regs_t *vreg;
+#ifdef DIS_TEXT
+ /* Instruction name for BLS* family of instructions */
+ char *blsinstr;
+#endif
size_t off;
@@ -2605,6 +2984,7 @@ dtrace_disx86(dis86_t *x, uint_t cpu_mode)
x->d86_rex_prefix = 0;
x->d86_got_modrm = 0;
x->d86_memsize = 0;
+ x->d86_vsib = 0;
if (cpu_mode == SIZE16) {
opnd_size = SIZE16;
@@ -2802,6 +3182,10 @@ dtrace_disx86(dis86_t *x, uint_t cpu_mode)
dp = (instable_t *)
&dis_opAVXF30F
[(opcode1 << 4) | opcode2];
+ } else if (vex_m == VEX_m_0F38) {
+ dp = (instable_t *)
+ &dis_opAVXF30F38
+ [(opcode1 << 4) | opcode2];
} else {
goto error;
}
@@ -2811,6 +3195,14 @@ dtrace_disx86(dis86_t *x, uint_t cpu_mode)
dp = (instable_t *)
&dis_opAVXF20F
[(opcode1 << 4) | opcode2];
+ } else if (vex_m == VEX_m_0F3A) {
+ dp = (instable_t *)
+ &dis_opAVXF20F3A
+ [(opcode1 << 4) | opcode2];
+ } else if (vex_m == VEX_m_0F38) {
+ dp = (instable_t *)
+ &dis_opAVXF20F38
+ [(opcode1 << 4) | opcode2];
} else {
goto error;
}
@@ -2822,10 +3214,14 @@ dtrace_disx86(dis86_t *x, uint_t cpu_mode)
}
}
if (vex_prefix) {
- if (vex_L)
- wbit = YMM_OPND;
- else
- wbit = XMM_OPND;
+ if (dp->it_vexwoxmm) {
+ wbit = LONG_OPND;
+ } else {
+ if (vex_L)
+ wbit = YMM_OPND;
+ else
+ wbit = XMM_OPND;
+ }
}
/*
@@ -2894,6 +3290,8 @@ dtrace_disx86(dis86_t *x, uint_t cpu_mode)
goto error;
#endif
switch (dp->it_adrmode) {
+ case XMMP:
+ break;
case XMMP_66r:
case XMMPRM_66r:
case XMM3PM_66r:
@@ -2935,11 +3333,50 @@ dtrace_disx86(dis86_t *x, uint_t cpu_mode)
dp++;
}
}
+
+ /*
+ * The adx family of instructions (adcx and adox)
+ * continue the classic Intel tradition of abusing
+ * arbitrary prefixes without actually meaning the
+ * prefix bit. Therefore, if we find either the
+ * opnd_size_prefix or rep_prefix we end up zeroing it
+ * out after making our determination so as to ensure
+ * that we don't get confused and accidentally print
+ * repz prefixes and the like on these instructions.
+ *
+ * In addition, these instructions are actually much
+ * closer to AVX instructions in semantics. Importantly,
+ * they always default to having 32-bit operands.
+ * However, if the CPU is in 64-bit mode, then and only
+ * then, does it use REX.w promotes things to 64-bits
+ * and REX.r allows 64-bit mode to use register r8-r15.
+ */
+ if (dp->it_indirect == (instable_t *)dis_op0F38F6) {
+ dp = dp->it_indirect;
+ if (opnd_size_prefix == 0 &&
+ rep_prefix == 0xf3) {
+ /* It is adox */
+ dp++;
+ } else if (opnd_size_prefix != 0x66 &&
+ rep_prefix != 0) {
+ /* It isn't adcx */
+ goto error;
+ }
+ opnd_size_prefix = 0;
+ rep_prefix = 0;
+ opnd_size = SIZE32;
+ if (rex_prefix & REX_W)
+ opnd_size = SIZE64;
+ }
+
#ifdef DIS_TEXT
if (strcmp(dp->it_name, "INVALID") == 0)
goto error;
#endif
switch (dp->it_adrmode) {
+ case ADX:
+ case XMM:
+ break;
case RM_66r:
case XMM_66r:
case XMMM_66r:
@@ -3029,9 +3466,12 @@ dtrace_disx86(dis86_t *x, uint_t cpu_mode)
goto error;
/*
- * deal with MMX/SSE opcodes which are changed by prefixes
+ * Deal with MMX/SSE opcodes which are changed by prefixes. Note, we do
+ * need to include UNKNOWN below, as we may have instructions that
+ * actually have a prefix, but don't exist in any other form.
*/
switch (dp->it_adrmode) {
+ case UNKNOWN:
case MMO:
case MMOIMPL:
case MMO3P:
@@ -3220,7 +3660,10 @@ dtrace_disx86(dis86_t *x, uint_t cpu_mode)
if (strcmp(dp->it_name, "INVALID") == 0)
goto error;
(void) strlcat(x->d86_mnem, dp->it_name, OPLEN);
- if (dp->it_suffix) {
+ if (dp->it_avxsuf && dp->it_suffix) {
+ (void) strlcat(x->d86_mnem, vex_W != 0 ? "q" : "d",
+ OPLEN);
+ } else if (dp->it_suffix) {
char *types[] = {"", "w", "l", "q"};
if (opcode_bytes == 2 && opcode4 == 4) {
/* It's a cmovx.yy. Replace the suffix x */
@@ -3341,6 +3784,7 @@ dtrace_disx86(dis86_t *x, uint_t cpu_mode)
/* memory or register operand to register, with 'w' bit */
case MRw:
+ case ADX:
wbit = WBIT(opcode2);
STANDARD_MODRM(x, mode, reg, r_m, rex_prefix, wbit, 0);
break;
@@ -3640,6 +4084,18 @@ just_mem:
#endif
NOMEM;
break;
+ } else if (r_m == 2) {
+#ifdef DIS_TEXT
+ (void) strncpy(x->d86_mnem, "clac", OPLEN);
+#endif
+ NOMEM;
+ break;
+ } else if (r_m == 3) {
+#ifdef DIS_TEXT
+ (void) strncpy(x->d86_mnem, "stac", OPLEN);
+#endif
+ NOMEM;
+ break;
} else {
goto error;
}
@@ -4337,11 +4793,31 @@ xmmprm:
dtrace_get_operand(x, mode, r_m, wbit, 0);
break;
case VEX_RMrX:
+ case FMA:
/* ModR/M.reg := op(VEX.vvvv, ModR/M.r/m) */
x->d86_numopnds = 3;
dtrace_get_modrm(x, &mode, &reg, &r_m);
dtrace_vex_adjust(vex_byte1, mode, &reg, &r_m);
+ /*
+ * In classic Intel fashion, the opcodes for all of the FMA
+ * instructions all have two possible mnemonics which vary by
+ * one letter, which is selected based on the value of the wbit.
+ * When wbit is one, they have the 'd' suffix and when 'wbit' is
+ * 0, they have the 's' suffix. Otherwise, the FMA instructions
+ * are all a standard VEX_RMrX.
+ */
+#ifdef DIS_TEXT
+ if (dp->it_adrmode == FMA) {
+ size_t len = strlen(dp->it_name);
+ (void) strncpy(x->d86_mnem, dp->it_name, OPLEN);
+ if (len + 1 < OPLEN) {
+ (void) strncpy(x->d86_mnem + len,
+ vex_W != 0 ? "d" : "s", OPLEN - len);
+ }
+ }
+#endif
+
if (mode != REG_ONLY) {
if ((dp == &dis_opAVXF20F[0x10]) ||
(dp == &dis_opAVXF30F[0x10])) {
@@ -4380,6 +4856,53 @@ xmmprm:
break;
+ case VEX_VRMrX:
+ /* ModR/M.reg := op(MODR/M.r/m, VEX.vvvv) */
+ x->d86_numopnds = 3;
+ dtrace_get_modrm(x, &mode, &reg, &r_m);
+ dtrace_vex_adjust(vex_byte1, mode, &reg, &r_m);
+
+ dtrace_get_operand(x, REG_ONLY, reg, wbit, 2);
+ /*
+ * VEX prefix uses the 1's complement form to encode the
+ * XMM/YMM regs
+ */
+ dtrace_get_operand(x, REG_ONLY, (0xF - vex_v), wbit, 0);
+
+ dtrace_get_operand(x, mode, r_m, wbit, 1);
+ break;
+
+ case VEX_SbVM:
+ /* ModR/M.reg := op(MODR/M.r/m, VSIB, VEX.vvvv) */
+ x->d86_numopnds = 3;
+ x->d86_vsib = 1;
+
+ /*
+ * All instructions that use VSIB are currently a mess. See the
+ * comment around the dis_gather_regs_t structure definition.
+ */
+
+ vreg = &dis_vgather[opcode2][vex_W][vex_L];
+
+#ifdef DIS_TEXT
+ (void) strncpy(x->d86_mnem, dp->it_name, OPLEN);
+ (void) strlcat(x->d86_mnem + strlen(dp->it_name),
+ vreg->dgr_suffix, OPLEN - strlen(dp->it_name));
+#endif
+
+ dtrace_get_modrm(x, &mode, &reg, &r_m);
+ dtrace_vex_adjust(vex_byte1, mode, &reg, &r_m);
+
+ dtrace_get_operand(x, REG_ONLY, reg, vreg->dgr_arg2, 2);
+ /*
+ * VEX prefix uses the 1's complement form to encode the
+ * XMM/YMM regs
+ */
+ dtrace_get_operand(x, REG_ONLY, (0xF - vex_v), vreg->dgr_arg0,
+ 0);
+ dtrace_get_operand(x, mode, r_m, vreg->dgr_arg1, 1);
+ break;
+
case VEX_RRX:
/* ModR/M.rm := op(VEX.vvvv, ModR/M.reg) */
x->d86_numopnds = 3;
@@ -4469,9 +4992,17 @@ L_VEX_MX:
dtrace_get_operand(x, mode, r_m, wbit, 0);
} else if ((dp == &dis_opAVXF30F[0xE6]) ||
(dp == &dis_opAVX0F[0x5][0xA]) ||
- (dp == &dis_opAVX660F38[0x13])) {
+ (dp == &dis_opAVX660F38[0x13]) ||
+ (dp == &dis_opAVX660F38[0x18]) ||
+ (dp == &dis_opAVX660F38[0x19]) ||
+ (dp == &dis_opAVX660F38[0x58]) ||
+ (dp == &dis_opAVX660F38[0x78]) ||
+ (dp == &dis_opAVX660F38[0x79]) ||
+ (dp == &dis_opAVX660F38[0x59])) {
/* vcvtdq2pd <xmm>, <ymm> */
/* or vcvtps2pd <xmm>, <ymm> */
+ /* or vcvtph2ps <xmm>, <ymm> */
+ /* or vbroadcasts* <xmm>, <ymm> */
dtrace_get_operand(x, REG_ONLY, reg, wbit, 1);
dtrace_get_operand(x, mode, r_m, XMM_OPND, 0);
} else if (dp == &dis_opAVX660F[0x6E]) {
@@ -4618,6 +5149,18 @@ L_VEX_MX:
/* one byte immediate number */
dtrace_imm_opnd(x, wbit, 1, 0);
break;
+ case VEX_RIM:
+ /* ModR/M.rm := op(ModR/M.reg, imm) */
+ x->d86_numopnds = 3;
+
+ dtrace_get_modrm(x, &mode, &reg, &r_m);
+ dtrace_vex_adjust(vex_byte1, mode, &reg, &r_m);
+
+ dtrace_get_operand(x, mode, r_m, XMM_OPND, 2);
+ dtrace_get_operand(x, REG_ONLY, reg, wbit, 1);
+ /* one byte immediate number */
+ dtrace_imm_opnd(x, wbit, 1, 0);
+ break;
case VEX_RM:
/* ModR/M.rm := op(ModR/M.reg) */
@@ -4673,6 +5216,48 @@ L_VEX_RM:
(void) strncpy(x->d86_mnem, "vzeroall", OPLEN);
#endif
break;
+ case BLS: {
+
+ /*
+ * The BLS instructions are VEX instructions that are based on
+ * VEX.0F38.F3; however, they are considered special group 17
+ * and like everything else, they use the bits in 3-5 of the
+ * MOD R/M to determine the sub instruction. Unlike many others
+ * like the VMX instructions, these are valid both for memory
+ * and register forms.
+ */
+
+ dtrace_get_modrm(x, &mode, &reg, &r_m);
+ dtrace_vex_adjust(vex_byte1, mode, &reg, &r_m);
+
+ switch (reg) {
+ case 1:
+#ifdef DIS_TEXT
+ blsinstr = "blsr";
+#endif
+ break;
+ case 2:
+#ifdef DIS_TEXT
+ blsinstr = "blsmsk";
+#endif
+ break;
+ case 3:
+#ifdef DIS_TEXT
+ blsinstr = "blsi";
+#endif
+ break;
+ default:
+ goto error;
+ }
+
+ x->d86_numopnds = 2;
+#ifdef DIS_TEXT
+ (void) strncpy(x->d86_mnem, blsinstr, OPLEN);
+#endif
+ dtrace_get_operand(x, REG_ONLY, (0xF - vex_v), wbit, 1);
+ dtrace_get_operand(x, mode, r_m, wbit, 0);
+ break;
+ }
/* an invalid op code */
case AM:
case DM:
diff --git a/sys/cddl/dev/dtrace/x86/dis_tables.h b/sys/cddl/dev/dtrace/x86/dis_tables.h
index 758fc40..87b006c 100644
--- a/sys/cddl/dev/dtrace/x86/dis_tables.h
+++ b/sys/cddl/dev/dtrace/x86/dis_tables.h
@@ -81,6 +81,7 @@ typedef struct dis86 {
uint_t d86_opnd_size;
uint_t d86_addr_size;
uint_t d86_got_modrm;
+ uint_t d86_vsib; /* Has a VSIB */
struct d86opnd d86_opnd[4]; /* up to 4 operands */
int (*d86_check_func)(void *);
int (*d86_get_byte)(void *);
diff --git a/sys/compat/freebsd32/freebsd32_misc.c b/sys/compat/freebsd32/freebsd32_misc.c
index b491a85..34eb6d7 100644
--- a/sys/compat/freebsd32/freebsd32_misc.c
+++ b/sys/compat/freebsd32/freebsd32_misc.c
@@ -489,7 +489,8 @@ freebsd32_mmap(struct thread *td, struct freebsd32_mmap_args *uap)
#ifdef COMPAT_FREEBSD6
int
-freebsd6_freebsd32_mmap(struct thread *td, struct freebsd6_freebsd32_mmap_args *uap)
+freebsd6_freebsd32_mmap(struct thread *td,
+ struct freebsd6_freebsd32_mmap_args *uap)
{
struct freebsd32_mmap_args ap;
diff --git a/sys/compat/linux/linux_socket.c b/sys/compat/linux/linux_socket.c
index 680f3c0..7e65332 100644
--- a/sys/compat/linux/linux_socket.c
+++ b/sys/compat/linux/linux_socket.c
@@ -971,10 +971,10 @@ linux_socketpair(struct thread *td, struct linux_socketpair_args *args)
#if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32))
struct linux_send_args {
- int s;
- l_uintptr_t msg;
- int len;
- int flags;
+ register_t s;
+ register_t msg;
+ register_t len;
+ register_t flags;
};
static int
@@ -999,10 +999,10 @@ linux_send(struct thread *td, struct linux_send_args *args)
}
struct linux_recv_args {
- int s;
- l_uintptr_t msg;
- int len;
- int flags;
+ register_t s;
+ register_t msg;
+ register_t len;
+ register_t flags;
};
static int
@@ -1701,39 +1701,45 @@ linux_getsockopt(struct thread *td, struct linux_getsockopt_args *args)
#if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32))
/* Argument list sizes for linux_socketcall */
-
-#define LINUX_AL(x) ((x) * sizeof(l_ulong))
-
-static const unsigned char lxs_args[] = {
- LINUX_AL(0) /* unused*/, LINUX_AL(3) /* socket */,
- LINUX_AL(3) /* bind */, LINUX_AL(3) /* connect */,
- LINUX_AL(2) /* listen */, LINUX_AL(3) /* accept */,
- LINUX_AL(3) /* getsockname */, LINUX_AL(3) /* getpeername */,
- LINUX_AL(4) /* socketpair */, LINUX_AL(4) /* send */,
- LINUX_AL(4) /* recv */, LINUX_AL(6) /* sendto */,
- LINUX_AL(6) /* recvfrom */, LINUX_AL(2) /* shutdown */,
- LINUX_AL(5) /* setsockopt */, LINUX_AL(5) /* getsockopt */,
- LINUX_AL(3) /* sendmsg */, LINUX_AL(3) /* recvmsg */,
- LINUX_AL(4) /* accept4 */, LINUX_AL(5) /* recvmmsg */,
- LINUX_AL(4) /* sendmmsg */
+static const unsigned char lxs_args_cnt[] = {
+ 0 /* unused*/, 3 /* socket */,
+ 3 /* bind */, 3 /* connect */,
+ 2 /* listen */, 3 /* accept */,
+ 3 /* getsockname */, 3 /* getpeername */,
+ 4 /* socketpair */, 4 /* send */,
+ 4 /* recv */, 6 /* sendto */,
+ 6 /* recvfrom */, 2 /* shutdown */,
+ 5 /* setsockopt */, 5 /* getsockopt */,
+ 3 /* sendmsg */, 3 /* recvmsg */,
+ 4 /* accept4 */, 5 /* recvmmsg */,
+ 4 /* sendmmsg */
};
-
-#define LINUX_AL_SIZE (nitems(lxs_args) - 1)
+#define LINUX_ARGS_CNT (nitems(lxs_args_cnt) - 1)
+#define LINUX_ARG_SIZE(x) (lxs_args_cnt[x] * sizeof(l_ulong))
int
linux_socketcall(struct thread *td, struct linux_socketcall_args *args)
{
l_ulong a[6];
+#if defined(__amd64__) && defined(COMPAT_LINUX32)
+ register_t l_args[6];
+#endif
void *arg;
int error;
- if (args->what < LINUX_SOCKET || args->what > LINUX_AL_SIZE)
+ if (args->what < LINUX_SOCKET || args->what > LINUX_ARGS_CNT)
return (EINVAL);
- error = copyin(PTRIN(args->args), a, lxs_args[args->what]);
- if (error)
+ error = copyin(PTRIN(args->args), a, LINUX_ARG_SIZE(args->what));
+ if (error != 0)
return (error);
+#if defined(__amd64__) && defined(COMPAT_LINUX32)
+ for (int i = 0; i < lxs_args_cnt[args->what]; ++i)
+ l_args[i] = a[i];
+ arg = l_args;
+#else
arg = a;
+#endif
switch (args->what) {
case LINUX_SOCKET:
return (linux_socket(td, arg));
diff --git a/sys/compat/linux/linux_socket.h b/sys/compat/linux/linux_socket.h
index 63fae69..9aff965 100644
--- a/sys/compat/linux/linux_socket.h
+++ b/sys/compat/linux/linux_socket.h
@@ -142,131 +142,18 @@ struct l_ucred {
#if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32))
-struct linux_sendto_args {
- int s;
- l_uintptr_t msg;
- int len;
- int flags;
- l_uintptr_t to;
- int tolen;
-};
-
-struct linux_socket_args {
- int domain;
- int type;
- int protocol;
-};
-
-struct linux_bind_args {
- int s;
- l_uintptr_t name;
- int namelen;
-};
-
-struct linux_connect_args {
- int s;
- l_uintptr_t name;
- int namelen;
-};
-
-struct linux_listen_args {
- int s;
- int backlog;
-};
-
struct linux_accept_args {
- int s;
- l_uintptr_t addr;
- l_uintptr_t namelen;
-};
-
-struct linux_accept4_args {
- int s;
- l_uintptr_t addr;
- l_uintptr_t namelen;
- int flags;
-};
-
-struct linux_getsockname_args {
- int s;
- l_uintptr_t addr;
- l_uintptr_t namelen;
-};
-
-struct linux_getpeername_args {
- int s;
- l_uintptr_t addr;
- l_uintptr_t namelen;
+ register_t s;
+ register_t addr;
+ register_t namelen;
};
-struct linux_socketpair_args {
- int domain;
- int type;
- int protocol;
- l_uintptr_t rsv;
-};
-
-struct linux_recvfrom_args {
- int s;
- l_uintptr_t buf;
- int len;
- int flags;
- l_uintptr_t from;
- l_uintptr_t fromlen;
-};
-
-struct linux_sendmsg_args {
- int s;
- l_uintptr_t msg;
- int flags;
-};
-
-struct linux_recvmsg_args {
- int s;
- l_uintptr_t msg;
- int flags;
-};
-
-struct linux_shutdown_args {
- int s;
- int how;
-};
-
-struct linux_setsockopt_args {
- int s;
- int level;
- int optname;
- l_uintptr_t optval;
- int optlen;
-};
-
-struct linux_getsockopt_args {
- int s;
- int level;
- int optname;
- l_uintptr_t optval;
- l_uintptr_t optlen;
-};
-
-int linux_socket(struct thread *td, struct linux_socket_args *args);
-int linux_bind(struct thread *td, struct linux_bind_args *args);
-int linux_connect(struct thread *, struct linux_connect_args *);
-int linux_listen(struct thread *td, struct linux_listen_args *args);
int linux_accept(struct thread *td, struct linux_accept_args *args);
-int linux_accept4(struct thread *td, struct linux_accept4_args *args);
-int linux_getsockname(struct thread *td, struct linux_getsockname_args *args);
-int linux_getpeername(struct thread *td, struct linux_getpeername_args *args);
-int linux_socketpair(struct thread *td, struct linux_socketpair_args *args);
-int linux_sendto(struct thread *td, struct linux_sendto_args *args);
-int linux_recvfrom(struct thread *td, struct linux_recvfrom_args *args);
-int linux_sendmsg(struct thread *td, struct linux_sendmsg_args *args);
-int linux_recvmsg(struct thread *td, struct linux_recvmsg_args *args);
-int linux_shutdown(struct thread *td, struct linux_shutdown_args *args);
-int linux_setsockopt(struct thread *td, struct linux_setsockopt_args *args);
-int linux_getsockopt(struct thread *td, struct linux_getsockopt_args *args);
#endif /* __i386__ || (__amd64__ && COMPAT_LINUX32) */
+
+
/* Operations for socketcall */
#define LINUX_SOCKET 1
diff --git a/sys/dev/alc/if_alc.c b/sys/dev/alc/if_alc.c
index a943a40..ca7ae9d 100644
--- a/sys/dev/alc/if_alc.c
+++ b/sys/dev/alc/if_alc.c
@@ -123,6 +123,8 @@ static struct alc_ident alc_ident_table[] = {
"Killer E2200 Gigabit Ethernet" },
{ VENDORID_ATHEROS, DEVICEID_ATHEROS_E2400, 9 * 1024,
"Killer E2400 Gigabit Ethernet" },
+ { VENDORID_ATHEROS, DEVICEID_ATHEROS_E2500, 9 * 1024,
+ "Killer E2500 Gigabit Ethernet" },
{ 0, 0, 0, NULL}
};
@@ -1083,6 +1085,7 @@ alc_phy_down(struct alc_softc *sc)
case DEVICEID_ATHEROS_AR8161:
case DEVICEID_ATHEROS_E2200:
case DEVICEID_ATHEROS_E2400:
+ case DEVICEID_ATHEROS_E2500:
case DEVICEID_ATHEROS_AR8162:
case DEVICEID_ATHEROS_AR8171:
case DEVICEID_ATHEROS_AR8172:
@@ -1402,6 +1405,7 @@ alc_attach(device_t dev)
switch (sc->alc_ident->deviceid) {
case DEVICEID_ATHEROS_E2200:
case DEVICEID_ATHEROS_E2400:
+ case DEVICEID_ATHEROS_E2500:
sc->alc_flags |= ALC_FLAG_E2X00;
/* FALLTHROUGH */
case DEVICEID_ATHEROS_AR8161:
@@ -1480,7 +1484,8 @@ alc_attach(device_t dev)
if (alc_dma_burst[sc->alc_dma_wr_burst] > 1024)
sc->alc_dma_wr_burst = 3;
/*
- * Force maximum payload size to 128 bytes for E2200/E2400.
+ * Force maximum payload size to 128 bytes for
+ * E2200/E2400/E2500.
* Otherwise it triggers DMA write error.
*/
if ((sc->alc_flags & ALC_FLAG_E2X00) != 0)
diff --git a/sys/dev/alc/if_alcreg.h b/sys/dev/alc/if_alcreg.h
index ae63084..29d877d 100644
--- a/sys/dev/alc/if_alcreg.h
+++ b/sys/dev/alc/if_alcreg.h
@@ -50,6 +50,7 @@
#define DEVICEID_ATHEROS_AR8172 0x10A0
#define DEVICEID_ATHEROS_E2200 0xE091
#define DEVICEID_ATHEROS_E2400 0xE0A1
+#define DEVICEID_ATHEROS_E2500 0xE0B1
#define ATHEROS_AR8152_B_V10 0xC0
#define ATHEROS_AR8152_B_V11 0xC1
diff --git a/sys/dev/bxe/bxe.c b/sys/dev/bxe/bxe.c
index c5daac5..cae7a67 100644
--- a/sys/dev/bxe/bxe.c
+++ b/sys/dev/bxe/bxe.c
@@ -168,6 +168,12 @@ static struct bxe_device_type bxe_devs[] = {
},
{
BRCM_VENDORID,
+ CHIP_NUM_57840_2_20,
+ PCI_ANY_ID, PCI_ANY_ID,
+ "QLogic NetXtreme II BCM57840 2x20GbE"
+ },
+ {
+ BRCM_VENDORID,
CHIP_NUM_57840_MF,
PCI_ANY_ID, PCI_ANY_ID,
"QLogic NetXtreme II BCM57840 MF 10GbE"
diff --git a/sys/dev/e1000/if_em.c b/sys/dev/e1000/if_em.c
index 7e2690e..2a108d5 100644
--- a/sys/dev/e1000/if_em.c
+++ b/sys/dev/e1000/if_em.c
@@ -5114,7 +5114,7 @@ em_enable_intr(struct adapter *adapter)
u32 ims_mask = IMS_ENABLE_MASK;
if (hw->mac.type == e1000_82574) {
- E1000_WRITE_REG(hw, EM_EIAC, adapter->ims);
+ E1000_WRITE_REG(hw, EM_EIAC, EM_MSIX_MASK);
ims_mask |= adapter->ims;
}
E1000_WRITE_REG(hw, E1000_IMS, ims_mask);
diff --git a/sys/dev/hyperv/include/hyperv.h b/sys/dev/hyperv/include/hyperv.h
index 0eda9f0..f0161fc 100644
--- a/sys/dev/hyperv/include/hyperv.h
+++ b/sys/dev/hyperv/include/hyperv.h
@@ -79,9 +79,17 @@ struct hyperv_guid {
#define HYPERV_GUID_STRLEN 40
-int hyperv_guid2str(const struct hyperv_guid *, char *, size_t);
+typedef uint64_t (*hyperv_tc64_t)(void);
-extern u_int hyperv_features; /* CPUID_HV_MSR_ */
+int hyperv_guid2str(const struct hyperv_guid *, char *,
+ size_t);
+
+/*
+ * hyperv_tc64 could be NULL, if there were no suitable Hyper-V
+ * specific timecounter.
+ */
+extern hyperv_tc64_t hyperv_tc64;
+extern u_int hyperv_features; /* CPUID_HV_MSR_ */
#endif /* _KERNEL */
diff --git a/sys/dev/hyperv/netvsc/hn_nvs.c b/sys/dev/hyperv/netvsc/hn_nvs.c
index 3110b02..de023ea 100644
--- a/sys/dev/hyperv/netvsc/hn_nvs.c
+++ b/sys/dev/hyperv/netvsc/hn_nvs.c
@@ -500,6 +500,8 @@ hn_nvs_conf_ndis(struct hn_softc *sc, int mtu)
conf.nvs_type = HN_NVS_TYPE_NDIS_CONF;
conf.nvs_mtu = mtu;
conf.nvs_caps = HN_NVS_NDIS_CONF_VLAN;
+ if (sc->hn_nvs_ver >= HN_NVS_VERSION_5)
+ conf.nvs_caps |= HN_NVS_NDIS_CONF_SRIOV;
/* NOTE: No response. */
error = hn_nvs_req_send(sc, &conf, sizeof(conf));
@@ -719,3 +721,15 @@ hn_nvs_send_rndis_ctrl(struct vmbus_channel *chan,
return hn_nvs_send_rndis_sglist(chan, HN_NVS_RNDIS_MTYPE_CTRL,
sndc, gpa, gpa_cnt);
}
+
+void
+hn_nvs_set_datapath(struct hn_softc *sc, uint32_t path)
+{
+ struct hn_nvs_datapath dp;
+
+ memset(&dp, 0, sizeof(dp));
+ dp.nvs_type = HN_NVS_TYPE_SET_DATAPATH;
+ dp.nvs_active_path = path;
+
+ hn_nvs_req_send(sc, &dp, sizeof(dp));
+}
diff --git a/sys/dev/hyperv/netvsc/hn_nvs.h b/sys/dev/hyperv/netvsc/hn_nvs.h
index 49b03e0..f716abf 100644
--- a/sys/dev/hyperv/netvsc/hn_nvs.h
+++ b/sys/dev/hyperv/netvsc/hn_nvs.h
@@ -100,6 +100,7 @@ void hn_nvs_sent_xact(struct hn_nvs_sendctx *sndc,
int hn_nvs_send_rndis_ctrl(struct vmbus_channel *chan,
struct hn_nvs_sendctx *sndc, struct vmbus_gpa *gpa,
int gpa_cnt);
+void hn_nvs_set_datapath(struct hn_softc *sc, uint32_t path);
extern struct hn_nvs_sendctx hn_nvs_sendctx_none;
diff --git a/sys/dev/hyperv/netvsc/if_hn.c b/sys/dev/hyperv/netvsc/if_hn.c
index ae4d37d..d5061c5 100644
--- a/sys/dev/hyperv/netvsc/if_hn.c
+++ b/sys/dev/hyperv/netvsc/if_hn.c
@@ -77,6 +77,7 @@ __FBSDID("$FreeBSD$");
#include <sys/systm.h>
#include <sys/taskqueue.h>
#include <sys/buf_ring.h>
+#include <sys/eventhandler.h>
#include <machine/atomic.h>
#include <machine/in_cksum.h>
@@ -84,6 +85,7 @@ __FBSDID("$FreeBSD$");
#include <net/bpf.h>
#include <net/ethernet.h>
#include <net/if.h>
+#include <net/if_dl.h>
#include <net/if_media.h>
#include <net/if_types.h>
#include <net/if_var.h>
@@ -216,6 +218,11 @@ struct hn_rxinfo {
uint32_t hash_value;
};
+struct hn_update_vf {
+ struct hn_rx_ring *rxr;
+ struct ifnet *vf;
+};
+
#define HN_RXINFO_VLAN 0x0001
#define HN_RXINFO_CSUM 0x0002
#define HN_RXINFO_HASHINF 0x0004
@@ -294,8 +301,9 @@ static int hn_txagg_pkts_sysctl(SYSCTL_HANDLER_ARGS);
static int hn_txagg_pktmax_sysctl(SYSCTL_HANDLER_ARGS);
static int hn_txagg_align_sysctl(SYSCTL_HANDLER_ARGS);
static int hn_polling_sysctl(SYSCTL_HANDLER_ARGS);
+static int hn_vf_sysctl(SYSCTL_HANDLER_ARGS);
-static void hn_stop(struct hn_softc *);
+static void hn_stop(struct hn_softc *, bool);
static void hn_init_locked(struct hn_softc *);
static int hn_chan_attach(struct hn_softc *,
struct vmbus_channel *);
@@ -707,7 +715,8 @@ hn_rxfilter_config(struct hn_softc *sc)
HN_LOCK_ASSERT(sc);
- if (ifp->if_flags & IFF_PROMISC) {
+ if ((ifp->if_flags & IFF_PROMISC) ||
+ (sc->hn_flags & HN_FLAG_VF)) {
filter = NDIS_PACKET_TYPE_PROMISCUOUS;
} else {
filter = NDIS_PACKET_TYPE_DIRECTED;
@@ -896,6 +905,122 @@ hn_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr)
ifmr->ifm_active |= IFM_10G_T | IFM_FDX;
}
+static void
+hn_update_vf_task(void *arg, int pending __unused)
+{
+ struct hn_update_vf *uv = arg;
+
+ uv->rxr->hn_vf = uv->vf;
+}
+
+static void
+hn_update_vf(struct hn_softc *sc, struct ifnet *vf)
+{
+ struct hn_rx_ring *rxr;
+ struct hn_update_vf uv;
+ struct task task;
+ int i;
+
+ HN_LOCK_ASSERT(sc);
+
+ TASK_INIT(&task, 0, hn_update_vf_task, &uv);
+
+ for (i = 0; i < sc->hn_rx_ring_cnt; ++i) {
+ rxr = &sc->hn_rx_ring[i];
+
+ if (i < sc->hn_rx_ring_inuse) {
+ uv.rxr = rxr;
+ uv.vf = vf;
+ vmbus_chan_run_task(rxr->hn_chan, &task);
+ } else {
+ rxr->hn_vf = vf;
+ }
+ }
+}
+
+static void
+hn_set_vf(struct hn_softc *sc, struct ifnet *ifp, bool vf)
+{
+ struct ifnet *hn_ifp;
+
+ HN_LOCK(sc);
+
+ if (!(sc->hn_flags & HN_FLAG_SYNTH_ATTACHED))
+ goto out;
+
+ hn_ifp = sc->hn_ifp;
+
+ if (ifp == hn_ifp)
+ goto out;
+
+ if (ifp->if_alloctype != IFT_ETHER)
+ goto out;
+
+ /* Ignore lagg/vlan interfaces */
+ if (strcmp(ifp->if_dname, "lagg") == 0 ||
+ strcmp(ifp->if_dname, "vlan") == 0)
+ goto out;
+
+ if (bcmp(IF_LLADDR(ifp), IF_LLADDR(hn_ifp), ETHER_ADDR_LEN) != 0)
+ goto out;
+
+ /* Now we're sure 'ifp' is a real VF device. */
+ if (vf) {
+ if (sc->hn_flags & HN_FLAG_VF)
+ goto out;
+
+ sc->hn_flags |= HN_FLAG_VF;
+ hn_rxfilter_config(sc);
+ } else {
+ if (!(sc->hn_flags & HN_FLAG_VF))
+ goto out;
+
+ sc->hn_flags &= ~HN_FLAG_VF;
+ if (sc->hn_ifp->if_drv_flags & IFF_DRV_RUNNING)
+ hn_rxfilter_config(sc);
+ else
+ hn_set_rxfilter(sc, NDIS_PACKET_TYPE_NONE);
+ }
+
+ hn_nvs_set_datapath(sc,
+ vf ? HN_NVS_DATAPATH_VF : HN_NVS_DATAPATH_SYNTHETIC);
+
+ hn_update_vf(sc, vf ? ifp : NULL);
+
+ if (vf) {
+ hn_suspend_mgmt(sc);
+ sc->hn_link_flags &=
+ ~(HN_LINK_FLAG_LINKUP | HN_LINK_FLAG_NETCHG);
+ if_link_state_change(sc->hn_ifp, LINK_STATE_DOWN);
+ } else {
+ hn_resume_mgmt(sc);
+ }
+
+ devctl_notify("HYPERV_NIC_VF", if_name(hn_ifp),
+ vf ? "VF_UP" : "VF_DOWN", NULL);
+
+ if (bootverbose)
+ if_printf(hn_ifp, "Data path is switched %s %s\n",
+ vf ? "to" : "from", if_name(ifp));
+out:
+ HN_UNLOCK(sc);
+}
+
+static void
+hn_ifnet_event(void *arg, struct ifnet *ifp, int event)
+{
+ if (event != IFNET_EVENT_UP && event != IFNET_EVENT_DOWN)
+ return;
+
+ hn_set_vf(arg, ifp, event == IFNET_EVENT_UP);
+}
+
+static void
+hn_ifaddr_event(void *arg, struct ifnet *ifp)
+{
+ hn_set_vf(arg, ifp, ifp->if_flags & IFF_UP);
+}
+
/* {F8615163-DF3E-46c5-913F-F2D2F965ED0E} */
static const struct hyperv_guid g_net_vsc_device_type = {
.hv_guid = {0x63, 0x51, 0x61, 0xF8, 0x3E, 0xDF, 0xc5, 0x46,
@@ -1133,6 +1258,9 @@ hn_attach(device_t dev)
CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_MPSAFE, sc, 0,
hn_polling_sysctl, "I",
"Polling frequency: [100,1000000], 0 disable polling");
+ SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "vf",
+ CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, sc, 0,
+ hn_vf_sysctl, "A", "Virtual Function's name");
/*
* Setup the ifmedia, which has been initialized earlier.
@@ -1221,6 +1349,12 @@ hn_attach(device_t dev)
sc->hn_mgmt_taskq = sc->hn_mgmt_taskq0;
hn_update_link_status(sc);
+ sc->hn_ifnet_evthand = EVENTHANDLER_REGISTER(ifnet_event,
+ hn_ifnet_event, sc, EVENTHANDLER_PRI_ANY);
+
+ sc->hn_ifaddr_evthand = EVENTHANDLER_REGISTER(ifaddr_event,
+ hn_ifaddr_event, sc, EVENTHANDLER_PRI_ANY);
+
return (0);
failed:
if (sc->hn_flags & HN_FLAG_SYNTH_ATTACHED)
@@ -1235,6 +1369,11 @@ hn_detach(device_t dev)
struct hn_softc *sc = device_get_softc(dev);
struct ifnet *ifp = sc->hn_ifp;
+ if (sc->hn_ifaddr_evthand != NULL)
+ EVENTHANDLER_DEREGISTER(ifaddr_event, sc->hn_ifaddr_evthand);
+ if (sc->hn_ifnet_evthand != NULL)
+ EVENTHANDLER_DEREGISTER(ifnet_event, sc->hn_ifnet_evthand);
+
if (sc->hn_xact != NULL && vmbus_chan_is_revoked(sc->hn_prichan)) {
/*
* In case that the vmbus missed the orphan handler
@@ -1247,7 +1386,7 @@ hn_detach(device_t dev)
HN_LOCK(sc);
if (sc->hn_flags & HN_FLAG_SYNTH_ATTACHED) {
if (ifp->if_drv_flags & IFF_DRV_RUNNING)
- hn_stop(sc);
+ hn_stop(sc, true);
/*
* NOTE:
* hn_stop() only suspends data, so managment
@@ -2124,20 +2263,15 @@ static int
hn_rxpkt(struct hn_rx_ring *rxr, const void *data, int dlen,
const struct hn_rxinfo *info)
{
- struct ifnet *ifp = rxr->hn_ifp;
+ struct ifnet *ifp;
struct mbuf *m_new;
int size, do_lro = 0, do_csum = 1;
int hash_type;
- if (!(ifp->if_drv_flags & IFF_DRV_RUNNING))
- return (0);
+ /* If the VF is active, inject the packet through the VF */
+ ifp = rxr->hn_vf ? rxr->hn_vf : rxr->hn_ifp;
- /*
- * Bail out if packet contains more data than configured MTU.
- */
- if (dlen > (ifp->if_mtu + ETHER_HDR_LEN)) {
- return (0);
- } else if (dlen <= MHLEN) {
+ if (dlen <= MHLEN) {
m_new = m_gethdr(M_NOWAIT, MT_DATA);
if (m_new == NULL) {
if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1);
@@ -2447,7 +2581,7 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
}
} else {
if (ifp->if_drv_flags & IFF_DRV_RUNNING)
- hn_stop(sc);
+ hn_stop(sc, false);
}
sc->hn_if_flags = ifp->if_flags;
@@ -2537,7 +2671,7 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
}
static void
-hn_stop(struct hn_softc *sc)
+hn_stop(struct hn_softc *sc, bool detaching)
{
struct ifnet *ifp = sc->hn_ifp;
int i;
@@ -2558,6 +2692,13 @@ hn_stop(struct hn_softc *sc)
atomic_clear_int(&ifp->if_drv_flags, IFF_DRV_OACTIVE);
for (i = 0; i < sc->hn_tx_ring_inuse; ++i)
sc->hn_tx_ring[i].hn_oactive = 0;
+
+ /*
+ * If the VF is active, make sure the filter is not 0, even if
+ * the synthetic NIC is down.
+ */
+ if (!detaching && (sc->hn_flags & HN_FLAG_VF))
+ hn_rxfilter_config(sc);
}
static void
@@ -3088,6 +3229,22 @@ hn_rss_hash_sysctl(SYSCTL_HANDLER_ARGS)
}
static int
+hn_vf_sysctl(SYSCTL_HANDLER_ARGS)
+{
+ struct hn_softc *sc = arg1;
+ char vf_name[128];
+ struct ifnet *vf;
+
+ HN_LOCK(sc);
+ vf_name[0] = '\0';
+ vf = sc->hn_rx_ring[0].hn_vf;
+ if (vf != NULL)
+ snprintf(vf_name, sizeof(vf_name), "%s", if_name(vf));
+ HN_UNLOCK(sc);
+ return sysctl_handle_string(oidp, vf_name, sizeof(vf_name), req);
+}
+
+static int
hn_check_iplen(const struct mbuf *m, int hoff)
{
const struct ip *ip;
@@ -4323,6 +4480,7 @@ hn_chan_attach(struct hn_softc *sc, struct vmbus_channel *chan)
KASSERT((rxr->hn_rx_flags & HN_RX_FLAG_ATTACHED) == 0,
("RX ring %d already attached", idx));
rxr->hn_rx_flags |= HN_RX_FLAG_ATTACHED;
+ rxr->hn_chan = chan;
if (bootverbose) {
if_printf(sc->hn_ifp, "link RX ring %d to chan%u\n",
@@ -4901,7 +5059,8 @@ hn_suspend(struct hn_softc *sc)
/* Disable polling. */
hn_polling(sc, 0);
- if (sc->hn_ifp->if_drv_flags & IFF_DRV_RUNNING)
+ if ((sc->hn_ifp->if_drv_flags & IFF_DRV_RUNNING) ||
+ (sc->hn_flags & HN_FLAG_VF))
hn_suspend_data(sc);
hn_suspend_mgmt(sc);
}
@@ -4990,9 +5149,18 @@ static void
hn_resume(struct hn_softc *sc)
{
- if (sc->hn_ifp->if_drv_flags & IFF_DRV_RUNNING)
+ if ((sc->hn_ifp->if_drv_flags & IFF_DRV_RUNNING) ||
+ (sc->hn_flags & HN_FLAG_VF))
hn_resume_data(sc);
- hn_resume_mgmt(sc);
+
+ /*
+ * When the VF is activated, the synthetic interface is changed
+ * to DOWN in hn_set_vf(). Here, if the VF is still active, we
+ * don't call hn_resume_mgmt() until the VF is deactivated in
+ * hn_set_vf().
+ */
+ if (!(sc->hn_flags & HN_FLAG_VF))
+ hn_resume_mgmt(sc);
/*
* Re-enable polling if this interface is running and
diff --git a/sys/dev/hyperv/netvsc/if_hnreg.h b/sys/dev/hyperv/netvsc/if_hnreg.h
index a3b2b8b..a964b4f 100644
--- a/sys/dev/hyperv/netvsc/if_hnreg.h
+++ b/sys/dev/hyperv/netvsc/if_hnreg.h
@@ -133,6 +133,17 @@ struct hn_nvs_ndis_init {
} __packed;
CTASSERT(sizeof(struct hn_nvs_ndis_init) >= HN_NVS_REQSIZE_MIN);
+#define HN_NVS_DATAPATH_SYNTHETIC 0
+#define HN_NVS_DATAPATH_VF 1
+
+/* No response */
+struct hn_nvs_datapath {
+ uint32_t nvs_type; /* HN_NVS_TYPE_SET_DATAPATH */
+ uint32_t nvs_active_path;/* HN_NVS_DATAPATH_* */
+ uint32_t nvs_rsvd[6];
+} __packed;
+CTASSERT(sizeof(struct hn_nvs_datapath) >= HN_NVS_REQSIZE_MIN);
+
struct hn_nvs_rxbuf_conn {
uint32_t nvs_type; /* HN_NVS_TYPE_RXBUF_CONN */
uint32_t nvs_gpadl; /* RXBUF vmbus GPADL */
diff --git a/sys/dev/hyperv/netvsc/if_hnvar.h b/sys/dev/hyperv/netvsc/if_hnvar.h
index 38d7b6f..42b885e 100644
--- a/sys/dev/hyperv/netvsc/if_hnvar.h
+++ b/sys/dev/hyperv/netvsc/if_hnvar.h
@@ -59,6 +59,7 @@ struct hn_tx_ring;
struct hn_rx_ring {
struct ifnet *hn_ifp;
+ struct ifnet *hn_vf; /* SR-IOV VF */
struct hn_tx_ring *hn_txr;
void *hn_pktbuf;
int hn_pktbuf_len;
@@ -85,6 +86,8 @@ struct hn_rx_ring {
void *hn_br; /* TX/RX bufring */
struct hyperv_dma hn_br_dma;
+
+ struct vmbus_channel *hn_chan;
} __aligned(CACHE_LINE_SIZE);
#define HN_TRUST_HCSUM_IP 0x0001
@@ -232,6 +235,9 @@ struct hn_softc {
int hn_rss_ind_size;
uint32_t hn_rss_hash; /* NDIS_HASH_ */
struct ndis_rssprm_toeplitz hn_rss;
+
+ eventhandler_tag hn_ifaddr_evthand;
+ eventhandler_tag hn_ifnet_evthand;
};
#define HN_FLAG_RXBUF_CONNECTED 0x0001
@@ -242,6 +248,7 @@ struct hn_softc {
#define HN_FLAG_NO_SLEEPING 0x0020
#define HN_FLAG_RXBUF_REF 0x0040
#define HN_FLAG_CHIM_REF 0x0080
+#define HN_FLAG_VF 0x0100
#define HN_FLAG_ERRORS (HN_FLAG_RXBUF_REF | HN_FLAG_CHIM_REF)
diff --git a/sys/dev/hyperv/utilities/vmbus_timesync.c b/sys/dev/hyperv/utilities/vmbus_timesync.c
index 7610027..66b1e48 100644
--- a/sys/dev/hyperv/utilities/vmbus_timesync.c
+++ b/sys/dev/hyperv/utilities/vmbus_timesync.c
@@ -52,8 +52,7 @@ __FBSDID("$FreeBSD$");
VMBUS_ICVER_LE(VMBUS_IC_VERSION(4, 0), (sc)->ic_msgver)
#define VMBUS_TIMESYNC_DORTT(sc) \
- (VMBUS_TIMESYNC_MSGVER4((sc)) &&\
- (hyperv_features & CPUID_HV_MSR_TIME_REFCNT))
+ (VMBUS_TIMESYNC_MSGVER4((sc)) && hyperv_tc64 != NULL)
static int vmbus_timesync_probe(device_t);
static int vmbus_timesync_attach(device_t);
@@ -117,7 +116,7 @@ vmbus_timesync(struct vmbus_ic_softc *sc, uint64_t hvtime, uint64_t sent_tc,
uint64_t hv_ns, vm_ns, rtt = 0;
if (VMBUS_TIMESYNC_DORTT(sc))
- rtt = rdmsr(MSR_HV_TIME_REF_COUNT) - sent_tc;
+ rtt = hyperv_tc64() - sent_tc;
hv_ns = (hvtime - VMBUS_ICMSG_TS_BASE + rtt) * HYPERV_TIMER_NS_FACTOR;
nanotime(&vm_ts);
diff --git a/sys/dev/hyperv/vmbus/amd64/hyperv_machdep.c b/sys/dev/hyperv/vmbus/amd64/hyperv_machdep.c
index cb815bb..d1c1b83 100644
--- a/sys/dev/hyperv/vmbus/amd64/hyperv_machdep.c
+++ b/sys/dev/hyperv/vmbus/amd64/hyperv_machdep.c
@@ -133,8 +133,8 @@ hyperv_tsc_vdso_timehands(struct vdso_timehands *vdso_th,
}
#define HYPERV_TSC_TIMECOUNT(fence) \
-static u_int \
-hyperv_tsc_timecount_##fence(struct timecounter *tc) \
+static uint64_t \
+hyperv_tc64_tsc_##fence(void) \
{ \
struct hyperv_reftsc *tsc_ref = hyperv_ref_tsc.tsc_ref; \
uint32_t seq; \
@@ -162,6 +162,13 @@ hyperv_tsc_timecount_##fence(struct timecounter *tc) \
/* Fallback to the generic timecounter, i.e. rdmsr. */ \
return (rdmsr(MSR_HV_TIME_REF_COUNT)); \
} \
+ \
+static u_int \
+hyperv_tsc_timecount_##fence(struct timecounter *tc __unused) \
+{ \
+ \
+ return (hyperv_tc64_tsc_##fence()); \
+} \
struct __hack
HYPERV_TSC_TIMECOUNT(lfence);
@@ -170,6 +177,7 @@ HYPERV_TSC_TIMECOUNT(mfence);
static void
hyperv_tsc_tcinit(void *dummy __unused)
{
+ hyperv_tc64_t tc64 = NULL;
uint64_t val, orig;
if ((hyperv_features &
@@ -182,11 +190,13 @@ hyperv_tsc_tcinit(void *dummy __unused)
case CPU_VENDOR_AMD:
hyperv_tsc_timecounter.tc_get_timecount =
hyperv_tsc_timecount_mfence;
+ tc64 = hyperv_tc64_tsc_mfence;
break;
case CPU_VENDOR_INTEL:
hyperv_tsc_timecounter.tc_get_timecount =
hyperv_tsc_timecount_lfence;
+ tc64 = hyperv_tc64_tsc_lfence;
break;
default:
@@ -211,6 +221,10 @@ hyperv_tsc_tcinit(void *dummy __unused)
/* Register "enlightened" timecounter. */
tc_init(&hyperv_tsc_timecounter);
+ /* Install 64 bits timecounter method for other modules to use. */
+ KASSERT(tc64 != NULL, ("tc64 is not set"));
+ hyperv_tc64 = tc64;
+
/* Add device for mmap(2). */
make_dev(&hyperv_tsc_cdevsw, 0, UID_ROOT, GID_WHEEL, 0444,
HYPERV_REFTSC_DEVNAME);
diff --git a/sys/dev/hyperv/vmbus/hyperv.c b/sys/dev/hyperv/vmbus/hyperv.c
index 2df313b..144bff5 100644
--- a/sys/dev/hyperv/vmbus/hyperv.c
+++ b/sys/dev/hyperv/vmbus/hyperv.c
@@ -77,6 +77,8 @@ u_int hyperv_recommends;
static u_int hyperv_pm_features;
static u_int hyperv_features3;
+hyperv_tc64_t hyperv_tc64;
+
static struct timecounter hyperv_timecounter = {
.tc_get_timecount = hyperv_get_timecount,
.tc_poll_pps = NULL,
@@ -96,6 +98,13 @@ hyperv_get_timecount(struct timecounter *tc __unused)
return rdmsr(MSR_HV_TIME_REF_COUNT);
}
+static uint64_t
+hyperv_tc64_rdmsr(void)
+{
+
+ return (rdmsr(MSR_HV_TIME_REF_COUNT));
+}
+
uint64_t
hypercall_post_message(bus_addr_t msg_paddr)
{
@@ -232,6 +241,12 @@ hyperv_init(void *dummy __unused)
if (hyperv_features & CPUID_HV_MSR_TIME_REFCNT) {
/* Register Hyper-V timecounter */
tc_init(&hyperv_timecounter);
+
+ /*
+ * Install 64 bits timecounter method for other modules
+ * to use.
+ */
+ hyperv_tc64 = hyperv_tc64_rdmsr;
}
}
SYSINIT(hyperv_initialize, SI_SUB_HYPERVISOR, SI_ORDER_FIRST, hyperv_init,
diff --git a/sys/dev/hyperv/vmbus/vmbus_et.c b/sys/dev/hyperv/vmbus/vmbus_et.c
index feb639c..722e5bf 100644
--- a/sys/dev/hyperv/vmbus/vmbus_et.c
+++ b/sys/dev/hyperv/vmbus/vmbus_et.c
@@ -48,13 +48,10 @@ __FBSDID("$FreeBSD$");
MSR_HV_STIMER_CFG_SINT_MASK)
/*
- * Two additionally required features:
+ * Additionally required feature:
* - SynIC is needed for interrupt generation.
- * - Time reference counter is needed to set ABS reference count to
- * STIMER0_COUNT.
*/
-#define CPUID_HV_ET_MASK (CPUID_HV_MSR_TIME_REFCNT | \
- CPUID_HV_MSR_SYNIC | \
+#define CPUID_HV_ET_MASK (CPUID_HV_MSR_SYNIC | \
CPUID_HV_MSR_SYNTIMER)
static void vmbus_et_identify(driver_t *, device_t);
@@ -102,7 +99,7 @@ vmbus_et_start(struct eventtimer *et __unused, sbintime_t first,
{
uint64_t current;
- current = rdmsr(MSR_HV_TIME_REF_COUNT);
+ current = hyperv_tc64();
current += hyperv_sbintime2count(first);
wrmsr(MSR_HV_STIMER0_COUNT, current);
@@ -131,7 +128,8 @@ vmbus_et_identify(driver_t *driver, device_t parent)
{
if (device_get_unit(parent) != 0 ||
device_find_child(parent, VMBUS_ET_NAME, -1) != NULL ||
- (hyperv_features & CPUID_HV_ET_MASK) != CPUID_HV_ET_MASK)
+ (hyperv_features & CPUID_HV_ET_MASK) != CPUID_HV_ET_MASK ||
+ hyperv_tc64 == NULL)
return;
device_add_child(parent, VMBUS_ET_NAME, -1);
@@ -187,9 +185,8 @@ vmbus_et_attach(device_t dev)
vmbus_et.et_start = vmbus_et_start;
/*
- * Delay a bit to make sure that MSR_HV_TIME_REF_COUNT will
- * not return 0, since writing 0 to STIMER0_COUNT will disable
- * STIMER0.
+ * Delay a bit to make sure that hyperv_tc64 will not return 0,
+ * since writing 0 to STIMER0_COUNT will disable STIMER0.
*/
DELAY(100);
smp_rendezvous(NULL, vmbus_et_config, NULL, NULL);
diff --git a/sys/dev/isp/isp.c b/sys/dev/isp/isp.c
index e6ee8ca..62fbea3 100644
--- a/sys/dev/isp/isp.c
+++ b/sys/dev/isp/isp.c
@@ -4451,11 +4451,7 @@ isp_start(XS_T *xs)
if (XS_TAG_P(xs)) {
ttype = XS_TAG_TYPE(xs);
} else {
- if (XS_CDBP(xs)[0] == 0x3) {
- ttype = REQFLAG_HTAG;
- } else {
- ttype = REQFLAG_STAG;
- }
+ ttype = REQFLAG_STAG;
}
if (ttype == REQFLAG_OTAG) {
ttype = FCP_CMND_TASK_ATTR_ORDERED;
@@ -4479,14 +4475,7 @@ isp_start(XS_T *xs)
if (XS_TAG_P(xs)) {
((ispreqt2_t *)reqp)->req_flags = XS_TAG_TYPE(xs);
} else {
- /*
- * If we don't know what tag to use, use HEAD OF QUEUE
- * for Request Sense or Simple.
- */
- if (XS_CDBP(xs)[0] == 0x3) /* REQUEST SENSE */
- ((ispreqt2_t *)reqp)->req_flags = REQFLAG_HTAG;
- else
- ((ispreqt2_t *)reqp)->req_flags = REQFLAG_STAG;
+ ((ispreqt2_t *)reqp)->req_flags = REQFLAG_STAG;
}
} else {
sdparam *sdp = SDPARAM(isp, XS_CHANNEL(xs));
diff --git a/sys/dev/iwi/if_iwi.c b/sys/dev/iwi/if_iwi.c
index 88dfc48..f1116f6 100644
--- a/sys/dev/iwi/if_iwi.c
+++ b/sys/dev/iwi/if_iwi.c
@@ -130,6 +130,15 @@ static const struct iwi_ident iwi_ident_table[] = {
{ 0, 0, NULL }
};
+static const uint8_t def_chan_2ghz[] =
+ { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 };
+static const uint8_t def_chan_5ghz_band1[] =
+ { 36, 40, 44, 48, 52, 56, 60, 64 };
+static const uint8_t def_chan_5ghz_band2[] =
+ { 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140 };
+static const uint8_t def_chan_5ghz_band3[] =
+ { 149, 153, 157, 161, 165 };
+
static struct ieee80211vap *iwi_vap_create(struct ieee80211com *,
const char [IFNAMSIZ], int, enum ieee80211_opmode, int,
const uint8_t [IEEE80211_ADDR_LEN],
@@ -204,6 +213,9 @@ static void iwi_radio_off(void *, int);
static void iwi_sysctlattach(struct iwi_softc *);
static void iwi_led_event(struct iwi_softc *, int);
static void iwi_ledattach(struct iwi_softc *);
+static void iwi_collect_bands(struct ieee80211com *, uint8_t [], size_t);
+static void iwi_getradiocaps(struct ieee80211com *, int, int *,
+ struct ieee80211_channel []);
static int iwi_probe(device_t);
static int iwi_attach(device_t);
@@ -271,7 +283,6 @@ iwi_attach(device_t dev)
struct iwi_softc *sc = device_get_softc(dev);
struct ieee80211com *ic = &sc->sc_ic;
uint16_t val;
- uint8_t bands[IEEE80211_MODE_BYTES];
int i, error;
sc->sc_dev = dev;
@@ -374,12 +385,8 @@ iwi_attach(device_t dev)
ic->ic_macaddr[4] = val & 0xff;
ic->ic_macaddr[5] = val >> 8;
- memset(bands, 0, sizeof(bands));
- setbit(bands, IEEE80211_MODE_11B);
- setbit(bands, IEEE80211_MODE_11G);
- if (pci_get_device(dev) >= 0x4223)
- setbit(bands, IEEE80211_MODE_11A);
- ieee80211_init_channels(ic, NULL, bands);
+ iwi_getradiocaps(ic, IEEE80211_CHAN_MAX, &ic->ic_nchans,
+ ic->ic_channels);
ieee80211_ifattach(ic);
/* override default methods */
@@ -399,6 +406,7 @@ iwi_attach(device_t dev)
ic->ic_ioctl = iwi_ioctl;
ic->ic_transmit = iwi_transmit;
ic->ic_parent = iwi_parent;
+ ic->ic_getradiocaps = iwi_getradiocaps;
ieee80211_radiotap_attach(ic,
&sc->sc_txtap.wt_ihdr, sizeof(sc->sc_txtap),
@@ -3569,3 +3577,40 @@ iwi_scan_end(struct ieee80211com *ic)
iwi_cmd(sc, IWI_CMD_ABORT_SCAN, NULL, 0);
IWI_UNLOCK(sc);
}
+
+static void
+iwi_collect_bands(struct ieee80211com *ic, uint8_t bands[], size_t bands_sz)
+{
+ struct iwi_softc *sc = ic->ic_softc;
+ device_t dev = sc->sc_dev;
+
+ memset(bands, 0, bands_sz);
+ setbit(bands, IEEE80211_MODE_11B);
+ setbit(bands, IEEE80211_MODE_11G);
+ if (pci_get_device(dev) >= 0x4223)
+ setbit(bands, IEEE80211_MODE_11A);
+}
+
+static void
+iwi_getradiocaps(struct ieee80211com *ic,
+ int maxchans, int *nchans, struct ieee80211_channel chans[])
+{
+ uint8_t bands[IEEE80211_MODE_BYTES];
+
+ iwi_collect_bands(ic, bands, sizeof(bands));
+ *nchans = 0;
+ if (isset(bands, IEEE80211_MODE_11B) || isset(bands, IEEE80211_MODE_11G))
+ ieee80211_add_channel_list_2ghz(chans, maxchans, nchans,
+ def_chan_2ghz, nitems(def_chan_2ghz), bands, 0);
+ if (isset(bands, IEEE80211_MODE_11A)) {
+ ieee80211_add_channel_list_5ghz(chans, maxchans, nchans,
+ def_chan_5ghz_band1, nitems(def_chan_5ghz_band1),
+ bands, 0);
+ ieee80211_add_channel_list_5ghz(chans, maxchans, nchans,
+ def_chan_5ghz_band2, nitems(def_chan_5ghz_band2),
+ bands, 0);
+ ieee80211_add_channel_list_5ghz(chans, maxchans, nchans,
+ def_chan_5ghz_band3, nitems(def_chan_5ghz_band3),
+ bands, 0);
+ }
+}
diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c
index b35c057..c1888ca 100644
--- a/sys/dev/pci/pci.c
+++ b/sys/dev/pci/pci.c
@@ -281,13 +281,14 @@ static const struct pci_quirk pci_quirks[] = {
{ 0x43851002, PCI_QUIRK_UNMAP_REG, 0x14, 0 },
/*
- * Atheros AR8161/AR8162/E2200/E2400 Ethernet controllers have a
- * bug that MSI interrupt does not assert if PCIM_CMD_INTxDIS bit
+ * Atheros AR8161/AR8162/E2200/E2400/E2500 Ethernet controllers have
+ * a bug that MSI interrupt does not assert if PCIM_CMD_INTxDIS bit
* of the command register is set.
*/
{ 0x10911969, PCI_QUIRK_MSI_INTX_BUG, 0, 0 },
{ 0xE0911969, PCI_QUIRK_MSI_INTX_BUG, 0, 0 },
{ 0xE0A11969, PCI_QUIRK_MSI_INTX_BUG, 0, 0 },
+ { 0xE0B11969, PCI_QUIRK_MSI_INTX_BUG, 0, 0 },
{ 0x10901969, PCI_QUIRK_MSI_INTX_BUG, 0, 0 },
/*
diff --git a/sys/dev/usb/controller/ehci_imx.c b/sys/dev/usb/controller/ehci_imx.c
index 07f7310..df4d202 100644
--- a/sys/dev/usb/controller/ehci_imx.c
+++ b/sys/dev/usb/controller/ehci_imx.c
@@ -157,6 +157,18 @@ struct imx_ehci_softc {
struct resource *ehci_irq_res; /* EHCI core IRQ. */
};
+static void
+imx_ehci_post_reset(struct ehci_softc *ehci_softc)
+{
+ uint32_t usbmode;
+
+ /* Force HOST mode */
+ usbmode = EOREAD4(ehci_softc, EHCI_USBMODE_NOLPM);
+ usbmode &= ~EHCI_UM_CM;
+ usbmode |= EHCI_UM_CM_HOST;
+ EOWRITE4(ehci_softc, EHCI_USBMODE_NOLPM, usbmode);
+}
+
static int
imx_ehci_probe(device_t dev)
{
@@ -282,8 +294,13 @@ imx_ehci_attach(device_t dev)
esc->sc_id_vendor = USB_VENDOR_FREESCALE;
strlcpy(esc->sc_vendor, "Freescale", sizeof(esc->sc_vendor));
- /* Set flags that affect ehci_init() behavior. */
- esc->sc_flags |= EHCI_SCFLG_DONTRESET | EHCI_SCFLG_NORESTERM;
+ /*
+ * Set flags that affect ehci_init() behavior, and hook our post-reset
+ * code into the standard controller code.
+ */
+ esc->sc_flags |= EHCI_SCFLG_NORESTERM;
+ esc->sc_vendor_post_reset = imx_ehci_post_reset;
+
err = ehci_init(esc);
if (err != 0) {
device_printf(dev, "USB init failed, usb_err_t=%d\n",
diff --git a/sys/dev/vt/vt_core.c b/sys/dev/vt/vt_core.c
index e09e8a7..361f628 100644
--- a/sys/dev/vt/vt_core.c
+++ b/sys/dev/vt/vt_core.c
@@ -2359,6 +2359,7 @@ skip_thunk:
(void *)vd, vt_kbdevent, vd);
if (i >= 0) {
if (vd->vd_keyboard != -1) {
+ kbd = kbd_get_keyboard(vd->vd_keyboard);
vt_save_kbd_state(vd->vd_curwindow, kbd);
kbd_release(kbd, (void *)vd);
}
diff --git a/sys/fs/devfs/devfs_devs.c b/sys/fs/devfs/devfs_devs.c
index 6572639..e600ff1 100644
--- a/sys/fs/devfs/devfs_devs.c
+++ b/sys/fs/devfs/devfs_devs.c
@@ -208,7 +208,7 @@ devfs_newdirent(char *name, int namelen)
struct dirent d;
d.d_namlen = namelen;
- i = sizeof (*de) + GENERIC_DIRSIZ(&d);
+ i = sizeof(*de) + GENERIC_DIRSIZ(&d);
de = malloc(i, M_DEVFS3, M_WAITOK | M_ZERO);
de->de_dirent = (struct dirent *)(de + 1);
de->de_dirent->d_namlen = namelen;
@@ -246,7 +246,8 @@ devfs_parent_dirent(struct devfs_dirent *de)
}
struct devfs_dirent *
-devfs_vmkdir(struct devfs_mount *dmp, char *name, int namelen, struct devfs_dirent *dotdot, u_int inode)
+devfs_vmkdir(struct devfs_mount *dmp, char *name, int namelen,
+ struct devfs_dirent *dotdot, u_int inode)
{
struct devfs_dirent *dd;
struct devfs_dirent *de;
diff --git a/sys/fs/nfsserver/nfs_nfsdkrpc.c b/sys/fs/nfsserver/nfs_nfsdkrpc.c
index e5ad4ab..130d423 100644
--- a/sys/fs/nfsserver/nfs_nfsdkrpc.c
+++ b/sys/fs/nfsserver/nfs_nfsdkrpc.c
@@ -551,18 +551,16 @@ nfsrvd_init(int terminating)
nfsd_master_proc = NULL;
NFSD_UNLOCK();
nfsrv_freeallbackchannel_xprts();
- svcpool_destroy(nfsrvd_pool);
- nfsrvd_pool = NULL;
+ svcpool_close(nfsrvd_pool);
+ NFSD_LOCK();
+ } else {
+ NFSD_UNLOCK();
+ nfsrvd_pool = svcpool_create("nfsd",
+ SYSCTL_STATIC_CHILDREN(_vfs_nfsd));
+ nfsrvd_pool->sp_rcache = NULL;
+ nfsrvd_pool->sp_assign = fhanew_assign;
+ nfsrvd_pool->sp_done = fha_nd_complete;
NFSD_LOCK();
}
-
- NFSD_UNLOCK();
-
- nfsrvd_pool = svcpool_create("nfsd", SYSCTL_STATIC_CHILDREN(_vfs_nfsd));
- nfsrvd_pool->sp_rcache = NULL;
- nfsrvd_pool->sp_assign = fhanew_assign;
- nfsrvd_pool->sp_done = fha_nd_complete;
-
- NFSD_LOCK();
}
diff --git a/sys/geom/part/g_part_gpt.c b/sys/geom/part/g_part_gpt.c
index f9017ab..45d6ef8 100644
--- a/sys/geom/part/g_part_gpt.c
+++ b/sys/geom/part/g_part_gpt.c
@@ -687,10 +687,11 @@ g_part_gpt_destroy(struct g_part_table *basetable, struct g_part_parms *gpp)
table->hdr = NULL;
/*
- * Wipe the first 2 sectors to clear the partitioning. Wipe the last
- * sector only if it has valid secondary header.
+ * Wipe the first 2 sectors and last one to clear the partitioning.
+ * Wipe sectors only if they have valid metadata.
*/
- basetable->gpt_smhead |= 3;
+ if (table->state[GPT_ELT_PRIHDR] == GPT_STATE_OK)
+ basetable->gpt_smhead |= 3;
if (table->state[GPT_ELT_SECHDR] == GPT_STATE_OK &&
table->lba[GPT_ELT_SECHDR] == pp->mediasize / pp->sectorsize - 1)
basetable->gpt_smtail |= 1;
diff --git a/sys/i386/i386/pmap.c b/sys/i386/i386/pmap.c
index bdc310c..9a5ae8b 100644
--- a/sys/i386/i386/pmap.c
+++ b/sys/i386/i386/pmap.c
@@ -441,7 +441,7 @@ pmap_bootstrap(vm_paddr_t firstaddr)
* CMAP1/CMAP2 are used for zeroing and copying pages.
* CMAP3 is used for the idle process page zeroing.
*/
- pc = pcpu_find(curcpu);
+ pc = get_pcpu();
mtx_init(&pc->pc_cmap_lock, "SYSMAPS", NULL, MTX_DEF);
SYSMAP(caddr_t, pc->pc_cmap_pte1, pc->pc_cmap_addr1, 1)
SYSMAP(caddr_t, pc->pc_cmap_pte2, pc->pc_cmap_addr2, 1)
@@ -4253,7 +4253,7 @@ pmap_zero_page(vm_page_t m)
struct pcpu *pc;
sched_pin();
- pc = pcpu_find(curcpu);
+ pc = get_pcpu();
cmap_pte2 = pc->pc_cmap_pte2;
mtx_lock(&pc->pc_cmap_lock);
if (*cmap_pte2)
@@ -4286,7 +4286,7 @@ pmap_zero_page_area(vm_page_t m, int off, int size)
struct pcpu *pc;
sched_pin();
- pc = pcpu_find(curcpu);
+ pc = get_pcpu();
cmap_pte2 = pc->pc_cmap_pte2;
mtx_lock(&pc->pc_cmap_lock);
if (*cmap_pte2)
@@ -4337,7 +4337,7 @@ pmap_copy_page(vm_page_t src, vm_page_t dst)
struct pcpu *pc;
sched_pin();
- pc = pcpu_find(curcpu);
+ pc = get_pcpu();
cmap_pte1 = pc->pc_cmap_pte1;
cmap_pte2 = pc->pc_cmap_pte2;
mtx_lock(&pc->pc_cmap_lock);
@@ -4372,7 +4372,7 @@ pmap_copy_pages(vm_page_t ma[], vm_offset_t a_offset, vm_page_t mb[],
int cnt;
sched_pin();
- pc = pcpu_find(curcpu);
+ pc = get_pcpu();
cmap_pte1 = pc->pc_cmap_pte1;
cmap_pte2 = pc->pc_cmap_pte2;
mtx_lock(&pc->pc_cmap_lock);
@@ -5368,7 +5368,7 @@ pmap_flush_page(vm_page_t m)
useclflushopt = (cpu_stdext_feature & CPUID_STDEXT_CLFLUSHOPT) != 0;
if (useclflushopt || (cpu_feature & CPUID_CLFSH) != 0) {
sched_pin();
- pc = pcpu_find(curcpu);
+ pc = get_pcpu();
cmap_pte2 = pc->pc_cmap_pte2;
mtx_lock(&pc->pc_cmap_lock);
if (*cmap_pte2)
diff --git a/sys/i386/include/pcpu.h b/sys/i386/include/pcpu.h
index 3110f9f..1ec6f58 100644
--- a/sys/i386/include/pcpu.h
+++ b/sys/i386/include/pcpu.h
@@ -76,6 +76,7 @@
extern struct pcpu *pcpup;
+#define get_pcpu() (pcpup)
#define PCPU_GET(member) (pcpup->pc_ ## member)
#define PCPU_ADD(member, val) (pcpup->pc_ ## member += (val))
#define PCPU_INC(member) PCPU_ADD(member, 1)
@@ -196,6 +197,15 @@ extern struct pcpu *pcpup;
} \
} while (0)
+#define get_pcpu() __extension__ ({ \
+ struct pcpu *__pc; \
+ \
+ __asm __volatile("movl %%fs:%1,%0" \
+ : "=r" (__pc) \
+ : "m" (*(struct pcpu *)(__pcpu_offset(pc_prvspace)))); \
+ __pc; \
+})
+
#define PCPU_GET(member) __PCPU_GET(pc_ ## member)
#define PCPU_ADD(member, val) __PCPU_ADD(pc_ ## member, val)
#define PCPU_INC(member) __PCPU_INC(pc_ ## member)
diff --git a/sys/i386/linux/linux_dummy.c b/sys/i386/linux/linux_dummy.c
index fd73c9d..9aafeb3 100644
--- a/sys/i386/linux/linux_dummy.c
+++ b/sys/i386/linux/linux_dummy.c
@@ -109,19 +109,52 @@ DUMMY(inotify_init1);
/* linux 2.6.30: */
DUMMY(preadv);
DUMMY(pwritev);
-/* linux 2.6.31 */
-DUMMY(rt_tsigqueueinfo);
+/* linux 2.6.31: */
+DUMMY(rt_tgsigqueueinfo);
DUMMY(perf_event_open);
/* linux 2.6.33: */
DUMMY(fanotify_init);
DUMMY(fanotify_mark);
-/* later: */
+/* linux 2.6.39: */
DUMMY(name_to_handle_at);
DUMMY(open_by_handle_at);
DUMMY(clock_adjtime);
+/* linux 3.0: */
DUMMY(setns);
+/* linux 3.2: */
DUMMY(process_vm_readv);
DUMMY(process_vm_writev);
+/* linux 3.5: */
+DUMMY(kcmp);
+/* linux 3.8: */
+DUMMY(finit_module);
+DUMMY(sched_setattr);
+DUMMY(sched_getattr);
+/* linux 3.14: */
+DUMMY(renameat2);
+/* linux 3.15: */
+DUMMY(seccomp);
+DUMMY(getrandom);
+DUMMY(memfd_create);
+/* linux 3.18: */
+DUMMY(bpf);
+/* linux 3.19: */
+DUMMY(execveat);
+/* linux 4.2: */
+DUMMY(userfaultfd);
+/* linux 4.3: */
+DUMMY(membarrier);
+/* linux 4.4: */
+DUMMY(mlock2);
+/* linux 4.5: */
+DUMMY(copy_file_range);
+/* linux 4.6: */
+DUMMY(preadv2);
+DUMMY(pwritev2);
+/* linux 4.8: */
+DUMMY(pkey_mprotect);
+DUMMY(pkey_alloc);
+DUMMY(pkey_free);
#define DUMMY_XATTR(s) \
int \
diff --git a/sys/i386/linux/linux_proto.h b/sys/i386/linux/linux_proto.h
index 19b6881..96493d8 100644
--- a/sys/i386/linux/linux_proto.h
+++ b/sys/i386/linux/linux_proto.h
@@ -3,7 +3,7 @@
*
* DO NOT EDIT-- this file is automatically generated.
* $FreeBSD$
- * created from FreeBSD: head/sys/i386/linux/syscalls.master 302515 2016-07-10 08:15:50Z dchagin
+ * created from FreeBSD: head/sys/i386/linux/syscalls.master 313284 2017-02-05 14:17:09Z dchagin
*/
#ifndef _LINUX_SYSPROTO_H_
@@ -1121,13 +1121,24 @@ struct linux_inotify_init1_args {
register_t dummy;
};
struct linux_preadv_args {
- register_t dummy;
+ char fd_l_[PADL_(l_ulong)]; l_ulong fd; char fd_r_[PADR_(l_ulong)];
+ char vec_l_[PADL_(struct iovec *)]; struct iovec * vec; char vec_r_[PADR_(struct iovec *)];
+ char vlen_l_[PADL_(l_ulong)]; l_ulong vlen; char vlen_r_[PADR_(l_ulong)];
+ char pos_l_l_[PADL_(l_ulong)]; l_ulong pos_l; char pos_l_r_[PADR_(l_ulong)];
+ char pos_h_l_[PADL_(l_ulong)]; l_ulong pos_h; char pos_h_r_[PADR_(l_ulong)];
};
struct linux_pwritev_args {
- register_t dummy;
-};
-struct linux_rt_tsigqueueinfo_args {
- register_t dummy;
+ char fd_l_[PADL_(l_ulong)]; l_ulong fd; char fd_r_[PADR_(l_ulong)];
+ char vec_l_[PADL_(struct iovec *)]; struct iovec * vec; char vec_r_[PADR_(struct iovec *)];
+ char vlen_l_[PADL_(l_ulong)]; l_ulong vlen; char vlen_r_[PADR_(l_ulong)];
+ char pos_l_l_[PADL_(l_ulong)]; l_ulong pos_l; char pos_l_r_[PADR_(l_ulong)];
+ char pos_h_l_[PADL_(l_ulong)]; l_ulong pos_h; char pos_h_r_[PADR_(l_ulong)];
+};
+struct linux_rt_tgsigqueueinfo_args {
+ char tgid_l_[PADL_(l_pid_t)]; l_pid_t tgid; char tgid_r_[PADR_(l_pid_t)];
+ char tid_l_[PADL_(l_pid_t)]; l_pid_t tid; char tid_r_[PADR_(l_pid_t)];
+ char sig_l_[PADL_(l_int)]; l_int sig; char sig_r_[PADR_(l_int)];
+ char uinfo_l_[PADL_(l_siginfo_t *)]; l_siginfo_t * uinfo; char uinfo_r_[PADR_(l_siginfo_t *)];
};
struct linux_perf_event_open_args {
register_t dummy;
@@ -1173,10 +1184,210 @@ struct linux_setns_args {
register_t dummy;
};
struct linux_process_vm_readv_args {
- register_t dummy;
+ char pid_l_[PADL_(l_pid_t)]; l_pid_t pid; char pid_r_[PADR_(l_pid_t)];
+ char lvec_l_[PADL_(const struct iovec *)]; const struct iovec * lvec; char lvec_r_[PADR_(const struct iovec *)];
+ char liovcnt_l_[PADL_(l_ulong)]; l_ulong liovcnt; char liovcnt_r_[PADR_(l_ulong)];
+ char rvec_l_[PADL_(const struct iovec *)]; const struct iovec * rvec; char rvec_r_[PADR_(const struct iovec *)];
+ char riovcnt_l_[PADL_(l_ulong)]; l_ulong riovcnt; char riovcnt_r_[PADR_(l_ulong)];
+ char flags_l_[PADL_(l_ulong)]; l_ulong flags; char flags_r_[PADR_(l_ulong)];
};
struct linux_process_vm_writev_args {
- register_t dummy;
+ char pid_l_[PADL_(l_pid_t)]; l_pid_t pid; char pid_r_[PADR_(l_pid_t)];
+ char lvec_l_[PADL_(const struct iovec *)]; const struct iovec * lvec; char lvec_r_[PADR_(const struct iovec *)];
+ char liovcnt_l_[PADL_(l_ulong)]; l_ulong liovcnt; char liovcnt_r_[PADR_(l_ulong)];
+ char rvec_l_[PADL_(const struct iovec *)]; const struct iovec * rvec; char rvec_r_[PADR_(const struct iovec *)];
+ char riovcnt_l_[PADL_(l_ulong)]; l_ulong riovcnt; char riovcnt_r_[PADR_(l_ulong)];
+ char flags_l_[PADL_(l_ulong)]; l_ulong flags; char flags_r_[PADR_(l_ulong)];
+};
+struct linux_kcmp_args {
+ char pid1_l_[PADL_(l_pid_t)]; l_pid_t pid1; char pid1_r_[PADR_(l_pid_t)];
+ char pid2_l_[PADL_(l_pid_t)]; l_pid_t pid2; char pid2_r_[PADR_(l_pid_t)];
+ char type_l_[PADL_(l_int)]; l_int type; char type_r_[PADR_(l_int)];
+ char idx1_l_[PADL_(l_ulong)]; l_ulong idx1; char idx1_r_[PADR_(l_ulong)];
+ char idx_l_[PADL_(l_ulong)]; l_ulong idx; char idx_r_[PADR_(l_ulong)];
+};
+struct linux_finit_module_args {
+ char fd_l_[PADL_(l_int)]; l_int fd; char fd_r_[PADR_(l_int)];
+ char uargs_l_[PADL_(const char *)]; const char * uargs; char uargs_r_[PADR_(const char *)];
+ char flags_l_[PADL_(l_int)]; l_int flags; char flags_r_[PADR_(l_int)];
+};
+struct linux_sched_setattr_args {
+ char pid_l_[PADL_(l_pid_t)]; l_pid_t pid; char pid_r_[PADR_(l_pid_t)];
+ char attr_l_[PADL_(void *)]; void * attr; char attr_r_[PADR_(void *)];
+ char flags_l_[PADL_(l_uint)]; l_uint flags; char flags_r_[PADR_(l_uint)];
+};
+struct linux_sched_getattr_args {
+ char pid_l_[PADL_(l_pid_t)]; l_pid_t pid; char pid_r_[PADR_(l_pid_t)];
+ char attr_l_[PADL_(void *)]; void * attr; char attr_r_[PADR_(void *)];
+ char size_l_[PADL_(l_uint)]; l_uint size; char size_r_[PADR_(l_uint)];
+ char flags_l_[PADL_(l_uint)]; l_uint flags; char flags_r_[PADR_(l_uint)];
+};
+struct linux_renameat2_args {
+ char oldfd_l_[PADL_(l_int)]; l_int oldfd; char oldfd_r_[PADR_(l_int)];
+ char oldname_l_[PADL_(const char *)]; const char * oldname; char oldname_r_[PADR_(const char *)];
+ char newfd_l_[PADL_(l_int)]; l_int newfd; char newfd_r_[PADR_(l_int)];
+ char newname_l_[PADL_(const char *)]; const char * newname; char newname_r_[PADR_(const char *)];
+ char flags_l_[PADL_(unsigned int)]; unsigned int flags; char flags_r_[PADR_(unsigned int)];
+};
+struct linux_seccomp_args {
+ char op_l_[PADL_(l_uint)]; l_uint op; char op_r_[PADR_(l_uint)];
+ char flags_l_[PADL_(l_uint)]; l_uint flags; char flags_r_[PADR_(l_uint)];
+ char uargs_l_[PADL_(const char *)]; const char * uargs; char uargs_r_[PADR_(const char *)];
+};
+struct linux_getrandom_args {
+ char buf_l_[PADL_(char *)]; char * buf; char buf_r_[PADR_(char *)];
+ char count_l_[PADL_(l_size_t)]; l_size_t count; char count_r_[PADR_(l_size_t)];
+ char flags_l_[PADL_(l_uint)]; l_uint flags; char flags_r_[PADR_(l_uint)];
+};
+struct linux_memfd_create_args {
+ char uname_ptr_l_[PADL_(const char *)]; const char * uname_ptr; char uname_ptr_r_[PADR_(const char *)];
+ char flags_l_[PADL_(l_uint)]; l_uint flags; char flags_r_[PADR_(l_uint)];
+};
+struct linux_bpf_args {
+ char cmd_l_[PADL_(l_int)]; l_int cmd; char cmd_r_[PADR_(l_int)];
+ char attr_l_[PADL_(void *)]; void * attr; char attr_r_[PADR_(void *)];
+ char size_l_[PADL_(l_uint)]; l_uint size; char size_r_[PADR_(l_uint)];
+};
+struct linux_execveat_args {
+ char dfd_l_[PADL_(l_int)]; l_int dfd; char dfd_r_[PADR_(l_int)];
+ char filename_l_[PADL_(const char *)]; const char * filename; char filename_r_[PADR_(const char *)];
+ char argv_l_[PADL_(const char **)]; const char ** argv; char argv_r_[PADR_(const char **)];
+ char envp_l_[PADL_(const char **)]; const char ** envp; char envp_r_[PADR_(const char **)];
+ char flags_l_[PADL_(l_int)]; l_int flags; char flags_r_[PADR_(l_int)];
+};
+struct linux_socket_args {
+ char domain_l_[PADL_(l_int)]; l_int domain; char domain_r_[PADR_(l_int)];
+ char type_l_[PADL_(l_int)]; l_int type; char type_r_[PADR_(l_int)];
+ char protocol_l_[PADL_(l_int)]; l_int protocol; char protocol_r_[PADR_(l_int)];
+};
+struct linux_socketpair_args {
+ char domain_l_[PADL_(l_int)]; l_int domain; char domain_r_[PADR_(l_int)];
+ char type_l_[PADL_(l_int)]; l_int type; char type_r_[PADR_(l_int)];
+ char protocol_l_[PADL_(l_int)]; l_int protocol; char protocol_r_[PADR_(l_int)];
+ char rsv_l_[PADL_(l_uintptr_t)]; l_uintptr_t rsv; char rsv_r_[PADR_(l_uintptr_t)];
+};
+struct linux_bind_args {
+ char s_l_[PADL_(l_int)]; l_int s; char s_r_[PADR_(l_int)];
+ char name_l_[PADL_(l_uintptr_t)]; l_uintptr_t name; char name_r_[PADR_(l_uintptr_t)];
+ char namelen_l_[PADL_(l_int)]; l_int namelen; char namelen_r_[PADR_(l_int)];
+};
+struct linux_connect_args {
+ char s_l_[PADL_(l_int)]; l_int s; char s_r_[PADR_(l_int)];
+ char name_l_[PADL_(l_uintptr_t)]; l_uintptr_t name; char name_r_[PADR_(l_uintptr_t)];
+ char namelen_l_[PADL_(l_int)]; l_int namelen; char namelen_r_[PADR_(l_int)];
+};
+struct linux_listen_args {
+ char s_l_[PADL_(l_int)]; l_int s; char s_r_[PADR_(l_int)];
+ char backlog_l_[PADL_(l_int)]; l_int backlog; char backlog_r_[PADR_(l_int)];
+};
+struct linux_accept4_args {
+ char s_l_[PADL_(l_int)]; l_int s; char s_r_[PADR_(l_int)];
+ char addr_l_[PADL_(l_uintptr_t)]; l_uintptr_t addr; char addr_r_[PADR_(l_uintptr_t)];
+ char namelen_l_[PADL_(l_uintptr_t)]; l_uintptr_t namelen; char namelen_r_[PADR_(l_uintptr_t)];
+ char flags_l_[PADL_(l_int)]; l_int flags; char flags_r_[PADR_(l_int)];
+};
+struct linux_getsockopt_args {
+ char s_l_[PADL_(l_int)]; l_int s; char s_r_[PADR_(l_int)];
+ char level_l_[PADL_(l_int)]; l_int level; char level_r_[PADR_(l_int)];
+ char optname_l_[PADL_(l_int)]; l_int optname; char optname_r_[PADR_(l_int)];
+ char optval_l_[PADL_(l_uintptr_t)]; l_uintptr_t optval; char optval_r_[PADR_(l_uintptr_t)];
+ char optlen_l_[PADL_(l_uintptr_t)]; l_uintptr_t optlen; char optlen_r_[PADR_(l_uintptr_t)];
+};
+struct linux_setsockopt_args {
+ char s_l_[PADL_(l_int)]; l_int s; char s_r_[PADR_(l_int)];
+ char level_l_[PADL_(l_int)]; l_int level; char level_r_[PADR_(l_int)];
+ char optname_l_[PADL_(l_int)]; l_int optname; char optname_r_[PADR_(l_int)];
+ char optval_l_[PADL_(l_uintptr_t)]; l_uintptr_t optval; char optval_r_[PADR_(l_uintptr_t)];
+ char optlen_l_[PADL_(l_int)]; l_int optlen; char optlen_r_[PADR_(l_int)];
+};
+struct linux_getsockname_args {
+ char s_l_[PADL_(l_int)]; l_int s; char s_r_[PADR_(l_int)];
+ char addr_l_[PADL_(l_uintptr_t)]; l_uintptr_t addr; char addr_r_[PADR_(l_uintptr_t)];
+ char namelen_l_[PADL_(l_uintptr_t)]; l_uintptr_t namelen; char namelen_r_[PADR_(l_uintptr_t)];
+};
+struct linux_getpeername_args {
+ char s_l_[PADL_(l_int)]; l_int s; char s_r_[PADR_(l_int)];
+ char addr_l_[PADL_(l_uintptr_t)]; l_uintptr_t addr; char addr_r_[PADR_(l_uintptr_t)];
+ char namelen_l_[PADL_(l_uintptr_t)]; l_uintptr_t namelen; char namelen_r_[PADR_(l_uintptr_t)];
+};
+struct linux_sendto_args {
+ char s_l_[PADL_(l_int)]; l_int s; char s_r_[PADR_(l_int)];
+ char msg_l_[PADL_(l_uintptr_t)]; l_uintptr_t msg; char msg_r_[PADR_(l_uintptr_t)];
+ char len_l_[PADL_(l_int)]; l_int len; char len_r_[PADR_(l_int)];
+ char flags_l_[PADL_(l_int)]; l_int flags; char flags_r_[PADR_(l_int)];
+ char to_l_[PADL_(l_uintptr_t)]; l_uintptr_t to; char to_r_[PADR_(l_uintptr_t)];
+ char tolen_l_[PADL_(l_int)]; l_int tolen; char tolen_r_[PADR_(l_int)];
+};
+struct linux_sendmsg_args {
+ char s_l_[PADL_(l_int)]; l_int s; char s_r_[PADR_(l_int)];
+ char msg_l_[PADL_(l_uintptr_t)]; l_uintptr_t msg; char msg_r_[PADR_(l_uintptr_t)];
+ char flags_l_[PADL_(l_int)]; l_int flags; char flags_r_[PADR_(l_int)];
+};
+struct linux_recvfrom_args {
+ char s_l_[PADL_(l_int)]; l_int s; char s_r_[PADR_(l_int)];
+ char buf_l_[PADL_(l_uintptr_t)]; l_uintptr_t buf; char buf_r_[PADR_(l_uintptr_t)];
+ char len_l_[PADL_(l_size_t)]; l_size_t len; char len_r_[PADR_(l_size_t)];
+ char flags_l_[PADL_(l_int)]; l_int flags; char flags_r_[PADR_(l_int)];
+ char from_l_[PADL_(l_uintptr_t)]; l_uintptr_t from; char from_r_[PADR_(l_uintptr_t)];
+ char fromlen_l_[PADL_(l_uintptr_t)]; l_uintptr_t fromlen; char fromlen_r_[PADR_(l_uintptr_t)];
+};
+struct linux_recvmsg_args {
+ char s_l_[PADL_(l_int)]; l_int s; char s_r_[PADR_(l_int)];
+ char msg_l_[PADL_(l_uintptr_t)]; l_uintptr_t msg; char msg_r_[PADR_(l_uintptr_t)];
+ char flags_l_[PADL_(l_int)]; l_int flags; char flags_r_[PADR_(l_int)];
+};
+struct linux_shutdown_args {
+ char s_l_[PADL_(l_int)]; l_int s; char s_r_[PADR_(l_int)];
+ char how_l_[PADL_(l_int)]; l_int how; char how_r_[PADR_(l_int)];
+};
+struct linux_userfaultfd_args {
+ char flags_l_[PADL_(l_int)]; l_int flags; char flags_r_[PADR_(l_int)];
+};
+struct linux_membarrier_args {
+ char cmd_l_[PADL_(l_int)]; l_int cmd; char cmd_r_[PADR_(l_int)];
+ char flags_l_[PADL_(l_int)]; l_int flags; char flags_r_[PADR_(l_int)];
+};
+struct linux_mlock2_args {
+ char start_l_[PADL_(l_ulong)]; l_ulong start; char start_r_[PADR_(l_ulong)];
+ char len_l_[PADL_(l_size_t)]; l_size_t len; char len_r_[PADR_(l_size_t)];
+ char flags_l_[PADL_(l_int)]; l_int flags; char flags_r_[PADR_(l_int)];
+};
+struct linux_copy_file_range_args {
+ char fd_in_l_[PADL_(l_int)]; l_int fd_in; char fd_in_r_[PADR_(l_int)];
+ char off_in_l_[PADL_(l_loff_t *)]; l_loff_t * off_in; char off_in_r_[PADR_(l_loff_t *)];
+ char fd_out_l_[PADL_(l_int)]; l_int fd_out; char fd_out_r_[PADR_(l_int)];
+ char off_out_l_[PADL_(l_loff_t *)]; l_loff_t * off_out; char off_out_r_[PADR_(l_loff_t *)];
+ char len_l_[PADL_(l_size_t)]; l_size_t len; char len_r_[PADR_(l_size_t)];
+ char flags_l_[PADL_(l_uint)]; l_uint flags; char flags_r_[PADR_(l_uint)];
+};
+struct linux_preadv2_args {
+ char fd_l_[PADL_(l_ulong)]; l_ulong fd; char fd_r_[PADR_(l_ulong)];
+ char vec_l_[PADL_(const struct iovec *)]; const struct iovec * vec; char vec_r_[PADR_(const struct iovec *)];
+ char vlen_l_[PADL_(l_ulong)]; l_ulong vlen; char vlen_r_[PADR_(l_ulong)];
+ char pos_l_l_[PADL_(l_ulong)]; l_ulong pos_l; char pos_l_r_[PADR_(l_ulong)];
+ char pos_h_l_[PADL_(l_ulong)]; l_ulong pos_h; char pos_h_r_[PADR_(l_ulong)];
+ char flags_l_[PADL_(l_int)]; l_int flags; char flags_r_[PADR_(l_int)];
+};
+struct linux_pwritev2_args {
+ char fd_l_[PADL_(l_ulong)]; l_ulong fd; char fd_r_[PADR_(l_ulong)];
+ char vec_l_[PADL_(const struct iovec *)]; const struct iovec * vec; char vec_r_[PADR_(const struct iovec *)];
+ char vlen_l_[PADL_(l_ulong)]; l_ulong vlen; char vlen_r_[PADR_(l_ulong)];
+ char pos_l_l_[PADL_(l_ulong)]; l_ulong pos_l; char pos_l_r_[PADR_(l_ulong)];
+ char pos_h_l_[PADL_(l_ulong)]; l_ulong pos_h; char pos_h_r_[PADR_(l_ulong)];
+ char flags_l_[PADL_(l_int)]; l_int flags; char flags_r_[PADR_(l_int)];
+};
+struct linux_pkey_mprotect_args {
+ char start_l_[PADL_(l_ulong)]; l_ulong start; char start_r_[PADR_(l_ulong)];
+ char len_l_[PADL_(l_size_t)]; l_size_t len; char len_r_[PADR_(l_size_t)];
+ char prot_l_[PADL_(l_ulong)]; l_ulong prot; char prot_r_[PADR_(l_ulong)];
+ char pkey_l_[PADL_(l_int)]; l_int pkey; char pkey_r_[PADR_(l_int)];
+};
+struct linux_pkey_alloc_args {
+ char flags_l_[PADL_(l_ulong)]; l_ulong flags; char flags_r_[PADR_(l_ulong)];
+ char init_val_l_[PADL_(l_ulong)]; l_ulong init_val; char init_val_r_[PADR_(l_ulong)];
+};
+struct linux_pkey_free_args {
+ char pkey_l_[PADL_(l_int)]; l_int pkey; char pkey_r_[PADR_(l_int)];
};
#define nosys linux_nosys
int linux_exit(struct thread *, struct linux_exit_args *);
@@ -1444,7 +1655,7 @@ int linux_pipe2(struct thread *, struct linux_pipe2_args *);
int linux_inotify_init1(struct thread *, struct linux_inotify_init1_args *);
int linux_preadv(struct thread *, struct linux_preadv_args *);
int linux_pwritev(struct thread *, struct linux_pwritev_args *);
-int linux_rt_tsigqueueinfo(struct thread *, struct linux_rt_tsigqueueinfo_args *);
+int linux_rt_tgsigqueueinfo(struct thread *, struct linux_rt_tgsigqueueinfo_args *);
int linux_perf_event_open(struct thread *, struct linux_perf_event_open_args *);
int linux_recvmmsg(struct thread *, struct linux_recvmmsg_args *);
int linux_fanotify_init(struct thread *, struct linux_fanotify_init_args *);
@@ -1458,6 +1669,40 @@ int linux_sendmmsg(struct thread *, struct linux_sendmmsg_args *);
int linux_setns(struct thread *, struct linux_setns_args *);
int linux_process_vm_readv(struct thread *, struct linux_process_vm_readv_args *);
int linux_process_vm_writev(struct thread *, struct linux_process_vm_writev_args *);
+int linux_kcmp(struct thread *, struct linux_kcmp_args *);
+int linux_finit_module(struct thread *, struct linux_finit_module_args *);
+int linux_sched_setattr(struct thread *, struct linux_sched_setattr_args *);
+int linux_sched_getattr(struct thread *, struct linux_sched_getattr_args *);
+int linux_renameat2(struct thread *, struct linux_renameat2_args *);
+int linux_seccomp(struct thread *, struct linux_seccomp_args *);
+int linux_getrandom(struct thread *, struct linux_getrandom_args *);
+int linux_memfd_create(struct thread *, struct linux_memfd_create_args *);
+int linux_bpf(struct thread *, struct linux_bpf_args *);
+int linux_execveat(struct thread *, struct linux_execveat_args *);
+int linux_socket(struct thread *, struct linux_socket_args *);
+int linux_socketpair(struct thread *, struct linux_socketpair_args *);
+int linux_bind(struct thread *, struct linux_bind_args *);
+int linux_connect(struct thread *, struct linux_connect_args *);
+int linux_listen(struct thread *, struct linux_listen_args *);
+int linux_accept4(struct thread *, struct linux_accept4_args *);
+int linux_getsockopt(struct thread *, struct linux_getsockopt_args *);
+int linux_setsockopt(struct thread *, struct linux_setsockopt_args *);
+int linux_getsockname(struct thread *, struct linux_getsockname_args *);
+int linux_getpeername(struct thread *, struct linux_getpeername_args *);
+int linux_sendto(struct thread *, struct linux_sendto_args *);
+int linux_sendmsg(struct thread *, struct linux_sendmsg_args *);
+int linux_recvfrom(struct thread *, struct linux_recvfrom_args *);
+int linux_recvmsg(struct thread *, struct linux_recvmsg_args *);
+int linux_shutdown(struct thread *, struct linux_shutdown_args *);
+int linux_userfaultfd(struct thread *, struct linux_userfaultfd_args *);
+int linux_membarrier(struct thread *, struct linux_membarrier_args *);
+int linux_mlock2(struct thread *, struct linux_mlock2_args *);
+int linux_copy_file_range(struct thread *, struct linux_copy_file_range_args *);
+int linux_preadv2(struct thread *, struct linux_preadv2_args *);
+int linux_pwritev2(struct thread *, struct linux_pwritev2_args *);
+int linux_pkey_mprotect(struct thread *, struct linux_pkey_mprotect_args *);
+int linux_pkey_alloc(struct thread *, struct linux_pkey_alloc_args *);
+int linux_pkey_free(struct thread *, struct linux_pkey_free_args *);
#ifdef COMPAT_43
@@ -1758,7 +2003,7 @@ int linux_process_vm_writev(struct thread *, struct linux_process_vm_writev_args
#define LINUX_SYS_AUE_linux_inotify_init1 AUE_NULL
#define LINUX_SYS_AUE_linux_preadv AUE_NULL
#define LINUX_SYS_AUE_linux_pwritev AUE_NULL
-#define LINUX_SYS_AUE_linux_rt_tsigqueueinfo AUE_NULL
+#define LINUX_SYS_AUE_linux_rt_tgsigqueueinfo AUE_NULL
#define LINUX_SYS_AUE_linux_perf_event_open AUE_NULL
#define LINUX_SYS_AUE_linux_recvmmsg AUE_NULL
#define LINUX_SYS_AUE_linux_fanotify_init AUE_NULL
@@ -1772,6 +2017,40 @@ int linux_process_vm_writev(struct thread *, struct linux_process_vm_writev_args
#define LINUX_SYS_AUE_linux_setns AUE_NULL
#define LINUX_SYS_AUE_linux_process_vm_readv AUE_NULL
#define LINUX_SYS_AUE_linux_process_vm_writev AUE_NULL
+#define LINUX_SYS_AUE_linux_kcmp AUE_NULL
+#define LINUX_SYS_AUE_linux_finit_module AUE_NULL
+#define LINUX_SYS_AUE_linux_sched_setattr AUE_NULL
+#define LINUX_SYS_AUE_linux_sched_getattr AUE_NULL
+#define LINUX_SYS_AUE_linux_renameat2 AUE_NULL
+#define LINUX_SYS_AUE_linux_seccomp AUE_NULL
+#define LINUX_SYS_AUE_linux_getrandom AUE_NULL
+#define LINUX_SYS_AUE_linux_memfd_create AUE_NULL
+#define LINUX_SYS_AUE_linux_bpf AUE_NULL
+#define LINUX_SYS_AUE_linux_execveat AUE_NULL
+#define LINUX_SYS_AUE_linux_socket AUE_SOCKET
+#define LINUX_SYS_AUE_linux_socketpair AUE_SOCKETPAIR
+#define LINUX_SYS_AUE_linux_bind AUE_BIND
+#define LINUX_SYS_AUE_linux_connect AUE_CONNECT
+#define LINUX_SYS_AUE_linux_listen AUE_LISTEN
+#define LINUX_SYS_AUE_linux_accept4 AUE_ACCEPT
+#define LINUX_SYS_AUE_linux_getsockopt AUE_GETSOCKOPT
+#define LINUX_SYS_AUE_linux_setsockopt AUE_SETSOCKOPT
+#define LINUX_SYS_AUE_linux_getsockname AUE_GETSOCKNAME
+#define LINUX_SYS_AUE_linux_getpeername AUE_GETPEERNAME
+#define LINUX_SYS_AUE_linux_sendto AUE_SENDTO
+#define LINUX_SYS_AUE_linux_sendmsg AUE_SENDMSG
+#define LINUX_SYS_AUE_linux_recvfrom AUE_RECVFROM
+#define LINUX_SYS_AUE_linux_recvmsg AUE_RECVMSG
+#define LINUX_SYS_AUE_linux_shutdown AUE_NULL
+#define LINUX_SYS_AUE_linux_userfaultfd AUE_NULL
+#define LINUX_SYS_AUE_linux_membarrier AUE_NULL
+#define LINUX_SYS_AUE_linux_mlock2 AUE_NULL
+#define LINUX_SYS_AUE_linux_copy_file_range AUE_NULL
+#define LINUX_SYS_AUE_linux_preadv2 AUE_NULL
+#define LINUX_SYS_AUE_linux_pwritev2 AUE_NULL
+#define LINUX_SYS_AUE_linux_pkey_mprotect AUE_NULL
+#define LINUX_SYS_AUE_linux_pkey_alloc AUE_NULL
+#define LINUX_SYS_AUE_linux_pkey_free AUE_NULL
#undef PAD_
#undef PADL_
diff --git a/sys/i386/linux/linux_syscall.h b/sys/i386/linux/linux_syscall.h
index 3d2204f..10fd747 100644
--- a/sys/i386/linux/linux_syscall.h
+++ b/sys/i386/linux/linux_syscall.h
@@ -3,7 +3,7 @@
*
* DO NOT EDIT-- this file is automatically generated.
* $FreeBSD$
- * created from FreeBSD: head/sys/i386/linux/syscalls.master 302515 2016-07-10 08:15:50Z dchagin
+ * created from FreeBSD: head/sys/i386/linux/syscalls.master 313284 2017-02-05 14:17:09Z dchagin
*/
#define LINUX_SYS_linux_exit 1
@@ -314,7 +314,7 @@
#define LINUX_SYS_linux_inotify_init1 332
#define LINUX_SYS_linux_preadv 333
#define LINUX_SYS_linux_pwritev 334
-#define LINUX_SYS_linux_rt_tsigqueueinfo 335
+#define LINUX_SYS_linux_rt_tgsigqueueinfo 335
#define LINUX_SYS_linux_perf_event_open 336
#define LINUX_SYS_linux_recvmmsg 337
#define LINUX_SYS_linux_fanotify_init 338
@@ -328,4 +328,38 @@
#define LINUX_SYS_linux_setns 346
#define LINUX_SYS_linux_process_vm_readv 347
#define LINUX_SYS_linux_process_vm_writev 348
-#define LINUX_SYS_MAXSYSCALL 350
+#define LINUX_SYS_linux_kcmp 349
+#define LINUX_SYS_linux_finit_module 350
+#define LINUX_SYS_linux_sched_setattr 351
+#define LINUX_SYS_linux_sched_getattr 352
+#define LINUX_SYS_linux_renameat2 353
+#define LINUX_SYS_linux_seccomp 354
+#define LINUX_SYS_linux_getrandom 355
+#define LINUX_SYS_linux_memfd_create 356
+#define LINUX_SYS_linux_bpf 357
+#define LINUX_SYS_linux_execveat 358
+#define LINUX_SYS_linux_socket 359
+#define LINUX_SYS_linux_socketpair 360
+#define LINUX_SYS_linux_bind 361
+#define LINUX_SYS_linux_connect 362
+#define LINUX_SYS_linux_listen 363
+#define LINUX_SYS_linux_accept4 364
+#define LINUX_SYS_linux_getsockopt 365
+#define LINUX_SYS_linux_setsockopt 366
+#define LINUX_SYS_linux_getsockname 367
+#define LINUX_SYS_linux_getpeername 368
+#define LINUX_SYS_linux_sendto 369
+#define LINUX_SYS_linux_sendmsg 370
+#define LINUX_SYS_linux_recvfrom 371
+#define LINUX_SYS_linux_recvmsg 372
+#define LINUX_SYS_linux_shutdown 373
+#define LINUX_SYS_linux_userfaultfd 374
+#define LINUX_SYS_linux_membarrier 375
+#define LINUX_SYS_linux_mlock2 376
+#define LINUX_SYS_linux_copy_file_range 377
+#define LINUX_SYS_linux_preadv2 378
+#define LINUX_SYS_linux_pwritev2 379
+#define LINUX_SYS_linux_pkey_mprotect 380
+#define LINUX_SYS_linux_pkey_alloc 381
+#define LINUX_SYS_linux_pkey_free 382
+#define LINUX_SYS_MAXSYSCALL 384
diff --git a/sys/i386/linux/linux_syscalls.c b/sys/i386/linux/linux_syscalls.c
index fc695e4..a30858d 100644
--- a/sys/i386/linux/linux_syscalls.c
+++ b/sys/i386/linux/linux_syscalls.c
@@ -3,7 +3,7 @@
*
* DO NOT EDIT-- this file is automatically generated.
* $FreeBSD$
- * created from FreeBSD: head/sys/i386/linux/syscalls.master 302515 2016-07-10 08:15:50Z dchagin
+ * created from FreeBSD: head/sys/i386/linux/syscalls.master 313284 2017-02-05 14:17:09Z dchagin
*/
const char *linux_syscallnames[] = {
@@ -343,7 +343,7 @@ const char *linux_syscallnames[] = {
"linux_inotify_init1", /* 332 = linux_inotify_init1 */
"linux_preadv", /* 333 = linux_preadv */
"linux_pwritev", /* 334 = linux_pwritev */
- "linux_rt_tsigqueueinfo", /* 335 = linux_rt_tsigqueueinfo */
+ "linux_rt_tgsigqueueinfo", /* 335 = linux_rt_tgsigqueueinfo */
"linux_perf_event_open", /* 336 = linux_perf_event_open */
"linux_recvmmsg", /* 337 = linux_recvmmsg */
"linux_fanotify_init", /* 338 = linux_fanotify_init */
@@ -357,5 +357,39 @@ const char *linux_syscallnames[] = {
"linux_setns", /* 346 = linux_setns */
"linux_process_vm_readv", /* 347 = linux_process_vm_readv */
"linux_process_vm_writev", /* 348 = linux_process_vm_writev */
- "#349", /* 349 = nosys */
+ "linux_kcmp", /* 349 = linux_kcmp */
+ "linux_finit_module", /* 350 = linux_finit_module */
+ "linux_sched_setattr", /* 351 = linux_sched_setattr */
+ "linux_sched_getattr", /* 352 = linux_sched_getattr */
+ "linux_renameat2", /* 353 = linux_renameat2 */
+ "linux_seccomp", /* 354 = linux_seccomp */
+ "linux_getrandom", /* 355 = linux_getrandom */
+ "linux_memfd_create", /* 356 = linux_memfd_create */
+ "linux_bpf", /* 357 = linux_bpf */
+ "linux_execveat", /* 358 = linux_execveat */
+ "linux_socket", /* 359 = linux_socket */
+ "linux_socketpair", /* 360 = linux_socketpair */
+ "linux_bind", /* 361 = linux_bind */
+ "linux_connect", /* 362 = linux_connect */
+ "linux_listen", /* 363 = linux_listen */
+ "linux_accept4", /* 364 = linux_accept4 */
+ "linux_getsockopt", /* 365 = linux_getsockopt */
+ "linux_setsockopt", /* 366 = linux_setsockopt */
+ "linux_getsockname", /* 367 = linux_getsockname */
+ "linux_getpeername", /* 368 = linux_getpeername */
+ "linux_sendto", /* 369 = linux_sendto */
+ "linux_sendmsg", /* 370 = linux_sendmsg */
+ "linux_recvfrom", /* 371 = linux_recvfrom */
+ "linux_recvmsg", /* 372 = linux_recvmsg */
+ "linux_shutdown", /* 373 = linux_shutdown */
+ "linux_userfaultfd", /* 374 = linux_userfaultfd */
+ "linux_membarrier", /* 375 = linux_membarrier */
+ "linux_mlock2", /* 376 = linux_mlock2 */
+ "linux_copy_file_range", /* 377 = linux_copy_file_range */
+ "linux_preadv2", /* 378 = linux_preadv2 */
+ "linux_pwritev2", /* 379 = linux_pwritev2 */
+ "linux_pkey_mprotect", /* 380 = linux_pkey_mprotect */
+ "linux_pkey_alloc", /* 381 = linux_pkey_alloc */
+ "linux_pkey_free", /* 382 = linux_pkey_free */
+ "#383", /* 383 = nosys */
};
diff --git a/sys/i386/linux/linux_sysent.c b/sys/i386/linux/linux_sysent.c
index 10e3ac3..6b66a65 100644
--- a/sys/i386/linux/linux_sysent.c
+++ b/sys/i386/linux/linux_sysent.c
@@ -3,7 +3,7 @@
*
* DO NOT EDIT-- this file is automatically generated.
* $FreeBSD$
- * created from FreeBSD: head/sys/i386/linux/syscalls.master 302515 2016-07-10 08:15:50Z dchagin
+ * created from FreeBSD: head/sys/i386/linux/syscalls.master 313284 2017-02-05 14:17:09Z dchagin
*/
#include <sys/param.h>
@@ -351,9 +351,9 @@ struct sysent linux_sysent[] = {
{ AS(linux_dup3_args), (sy_call_t *)linux_dup3, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 330 = linux_dup3 */
{ AS(linux_pipe2_args), (sy_call_t *)linux_pipe2, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 331 = linux_pipe2 */
{ 0, (sy_call_t *)linux_inotify_init1, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 332 = linux_inotify_init1 */
- { 0, (sy_call_t *)linux_preadv, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 333 = linux_preadv */
- { 0, (sy_call_t *)linux_pwritev, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 334 = linux_pwritev */
- { 0, (sy_call_t *)linux_rt_tsigqueueinfo, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 335 = linux_rt_tsigqueueinfo */
+ { AS(linux_preadv_args), (sy_call_t *)linux_preadv, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 333 = linux_preadv */
+ { AS(linux_pwritev_args), (sy_call_t *)linux_pwritev, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 334 = linux_pwritev */
+ { AS(linux_rt_tgsigqueueinfo_args), (sy_call_t *)linux_rt_tgsigqueueinfo, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 335 = linux_rt_tgsigqueueinfo */
{ 0, (sy_call_t *)linux_perf_event_open, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 336 = linux_perf_event_open */
{ AS(linux_recvmmsg_args), (sy_call_t *)linux_recvmmsg, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 337 = linux_recvmmsg */
{ 0, (sy_call_t *)linux_fanotify_init, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 338 = linux_fanotify_init */
@@ -365,7 +365,41 @@ struct sysent linux_sysent[] = {
{ AS(linux_syncfs_args), (sy_call_t *)linux_syncfs, AUE_SYNC, NULL, 0, 0, 0, SY_THR_STATIC }, /* 344 = linux_syncfs */
{ AS(linux_sendmmsg_args), (sy_call_t *)linux_sendmmsg, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 345 = linux_sendmmsg */
{ 0, (sy_call_t *)linux_setns, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 346 = linux_setns */
- { 0, (sy_call_t *)linux_process_vm_readv, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 347 = linux_process_vm_readv */
- { 0, (sy_call_t *)linux_process_vm_writev, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 348 = linux_process_vm_writev */
- { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 349 = nosys */
+ { AS(linux_process_vm_readv_args), (sy_call_t *)linux_process_vm_readv, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 347 = linux_process_vm_readv */
+ { AS(linux_process_vm_writev_args), (sy_call_t *)linux_process_vm_writev, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 348 = linux_process_vm_writev */
+ { AS(linux_kcmp_args), (sy_call_t *)linux_kcmp, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 349 = linux_kcmp */
+ { AS(linux_finit_module_args), (sy_call_t *)linux_finit_module, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 350 = linux_finit_module */
+ { AS(linux_sched_setattr_args), (sy_call_t *)linux_sched_setattr, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 351 = linux_sched_setattr */
+ { AS(linux_sched_getattr_args), (sy_call_t *)linux_sched_getattr, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 352 = linux_sched_getattr */
+ { AS(linux_renameat2_args), (sy_call_t *)linux_renameat2, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 353 = linux_renameat2 */
+ { AS(linux_seccomp_args), (sy_call_t *)linux_seccomp, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 354 = linux_seccomp */
+ { AS(linux_getrandom_args), (sy_call_t *)linux_getrandom, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 355 = linux_getrandom */
+ { AS(linux_memfd_create_args), (sy_call_t *)linux_memfd_create, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 356 = linux_memfd_create */
+ { AS(linux_bpf_args), (sy_call_t *)linux_bpf, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 357 = linux_bpf */
+ { AS(linux_execveat_args), (sy_call_t *)linux_execveat, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 358 = linux_execveat */
+ { AS(linux_socket_args), (sy_call_t *)linux_socket, AUE_SOCKET, NULL, 0, 0, 0, SY_THR_STATIC }, /* 359 = linux_socket */
+ { AS(linux_socketpair_args), (sy_call_t *)linux_socketpair, AUE_SOCKETPAIR, NULL, 0, 0, 0, SY_THR_STATIC }, /* 360 = linux_socketpair */
+ { AS(linux_bind_args), (sy_call_t *)linux_bind, AUE_BIND, NULL, 0, 0, 0, SY_THR_STATIC }, /* 361 = linux_bind */
+ { AS(linux_connect_args), (sy_call_t *)linux_connect, AUE_CONNECT, NULL, 0, 0, 0, SY_THR_STATIC }, /* 362 = linux_connect */
+ { AS(linux_listen_args), (sy_call_t *)linux_listen, AUE_LISTEN, NULL, 0, 0, 0, SY_THR_STATIC }, /* 363 = linux_listen */
+ { AS(linux_accept4_args), (sy_call_t *)linux_accept4, AUE_ACCEPT, NULL, 0, 0, 0, SY_THR_STATIC }, /* 364 = linux_accept4 */
+ { AS(linux_getsockopt_args), (sy_call_t *)linux_getsockopt, AUE_GETSOCKOPT, NULL, 0, 0, 0, SY_THR_STATIC }, /* 365 = linux_getsockopt */
+ { AS(linux_setsockopt_args), (sy_call_t *)linux_setsockopt, AUE_SETSOCKOPT, NULL, 0, 0, 0, SY_THR_STATIC }, /* 366 = linux_setsockopt */
+ { AS(linux_getsockname_args), (sy_call_t *)linux_getsockname, AUE_GETSOCKNAME, NULL, 0, 0, 0, SY_THR_STATIC }, /* 367 = linux_getsockname */
+ { AS(linux_getpeername_args), (sy_call_t *)linux_getpeername, AUE_GETPEERNAME, NULL, 0, 0, 0, SY_THR_STATIC }, /* 368 = linux_getpeername */
+ { AS(linux_sendto_args), (sy_call_t *)linux_sendto, AUE_SENDTO, NULL, 0, 0, 0, SY_THR_STATIC }, /* 369 = linux_sendto */
+ { AS(linux_sendmsg_args), (sy_call_t *)linux_sendmsg, AUE_SENDMSG, NULL, 0, 0, 0, SY_THR_STATIC }, /* 370 = linux_sendmsg */
+ { AS(linux_recvfrom_args), (sy_call_t *)linux_recvfrom, AUE_RECVFROM, NULL, 0, 0, 0, SY_THR_STATIC }, /* 371 = linux_recvfrom */
+ { AS(linux_recvmsg_args), (sy_call_t *)linux_recvmsg, AUE_RECVMSG, NULL, 0, 0, 0, SY_THR_STATIC }, /* 372 = linux_recvmsg */
+ { AS(linux_shutdown_args), (sy_call_t *)linux_shutdown, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 373 = linux_shutdown */
+ { AS(linux_userfaultfd_args), (sy_call_t *)linux_userfaultfd, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 374 = linux_userfaultfd */
+ { AS(linux_membarrier_args), (sy_call_t *)linux_membarrier, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 375 = linux_membarrier */
+ { AS(linux_mlock2_args), (sy_call_t *)linux_mlock2, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 376 = linux_mlock2 */
+ { AS(linux_copy_file_range_args), (sy_call_t *)linux_copy_file_range, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 377 = linux_copy_file_range */
+ { AS(linux_preadv2_args), (sy_call_t *)linux_preadv2, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 378 = linux_preadv2 */
+ { AS(linux_pwritev2_args), (sy_call_t *)linux_pwritev2, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 379 = linux_pwritev2 */
+ { AS(linux_pkey_mprotect_args), (sy_call_t *)linux_pkey_mprotect, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 380 = linux_pkey_mprotect */
+ { AS(linux_pkey_alloc_args), (sy_call_t *)linux_pkey_alloc, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 381 = linux_pkey_alloc */
+ { AS(linux_pkey_free_args), (sy_call_t *)linux_pkey_free, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 382 = linux_pkey_free */
+ { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT }, /* 383 = nosys */
};
diff --git a/sys/i386/linux/linux_systrace_args.c b/sys/i386/linux/linux_systrace_args.c
index 0a0bf42..c829676 100644
--- a/sys/i386/linux/linux_systrace_args.c
+++ b/sys/i386/linux/linux_systrace_args.c
@@ -2339,17 +2339,34 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args)
}
/* linux_preadv */
case 333: {
- *n_args = 0;
+ struct linux_preadv_args *p = params;
+ iarg[0] = p->fd; /* l_ulong */
+ uarg[1] = (intptr_t) p->vec; /* struct iovec * */
+ iarg[2] = p->vlen; /* l_ulong */
+ iarg[3] = p->pos_l; /* l_ulong */
+ iarg[4] = p->pos_h; /* l_ulong */
+ *n_args = 5;
break;
}
/* linux_pwritev */
case 334: {
- *n_args = 0;
+ struct linux_pwritev_args *p = params;
+ iarg[0] = p->fd; /* l_ulong */
+ uarg[1] = (intptr_t) p->vec; /* struct iovec * */
+ iarg[2] = p->vlen; /* l_ulong */
+ iarg[3] = p->pos_l; /* l_ulong */
+ iarg[4] = p->pos_h; /* l_ulong */
+ *n_args = 5;
break;
}
- /* linux_rt_tsigqueueinfo */
+ /* linux_rt_tgsigqueueinfo */
case 335: {
- *n_args = 0;
+ struct linux_rt_tgsigqueueinfo_args *p = params;
+ iarg[0] = p->tgid; /* l_pid_t */
+ iarg[1] = p->tid; /* l_pid_t */
+ iarg[2] = p->sig; /* l_int */
+ uarg[3] = (intptr_t) p->uinfo; /* l_siginfo_t * */
+ *n_args = 4;
break;
}
/* linux_perf_event_open */
@@ -2427,12 +2444,352 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args)
}
/* linux_process_vm_readv */
case 347: {
- *n_args = 0;
+ struct linux_process_vm_readv_args *p = params;
+ iarg[0] = p->pid; /* l_pid_t */
+ uarg[1] = (intptr_t) p->lvec; /* const struct iovec * */
+ iarg[2] = p->liovcnt; /* l_ulong */
+ uarg[3] = (intptr_t) p->rvec; /* const struct iovec * */
+ iarg[4] = p->riovcnt; /* l_ulong */
+ iarg[5] = p->flags; /* l_ulong */
+ *n_args = 6;
break;
}
/* linux_process_vm_writev */
case 348: {
- *n_args = 0;
+ struct linux_process_vm_writev_args *p = params;
+ iarg[0] = p->pid; /* l_pid_t */
+ uarg[1] = (intptr_t) p->lvec; /* const struct iovec * */
+ iarg[2] = p->liovcnt; /* l_ulong */
+ uarg[3] = (intptr_t) p->rvec; /* const struct iovec * */
+ iarg[4] = p->riovcnt; /* l_ulong */
+ iarg[5] = p->flags; /* l_ulong */
+ *n_args = 6;
+ break;
+ }
+ /* linux_kcmp */
+ case 349: {
+ struct linux_kcmp_args *p = params;
+ iarg[0] = p->pid1; /* l_pid_t */
+ iarg[1] = p->pid2; /* l_pid_t */
+ iarg[2] = p->type; /* l_int */
+ iarg[3] = p->idx1; /* l_ulong */
+ iarg[4] = p->idx; /* l_ulong */
+ *n_args = 5;
+ break;
+ }
+ /* linux_finit_module */
+ case 350: {
+ struct linux_finit_module_args *p = params;
+ iarg[0] = p->fd; /* l_int */
+ uarg[1] = (intptr_t) p->uargs; /* const char * */
+ iarg[2] = p->flags; /* l_int */
+ *n_args = 3;
+ break;
+ }
+ /* linux_sched_setattr */
+ case 351: {
+ struct linux_sched_setattr_args *p = params;
+ iarg[0] = p->pid; /* l_pid_t */
+ uarg[1] = (intptr_t) p->attr; /* void * */
+ iarg[2] = p->flags; /* l_uint */
+ *n_args = 3;
+ break;
+ }
+ /* linux_sched_getattr */
+ case 352: {
+ struct linux_sched_getattr_args *p = params;
+ iarg[0] = p->pid; /* l_pid_t */
+ uarg[1] = (intptr_t) p->attr; /* void * */
+ iarg[2] = p->size; /* l_uint */
+ iarg[3] = p->flags; /* l_uint */
+ *n_args = 4;
+ break;
+ }
+ /* linux_renameat2 */
+ case 353: {
+ struct linux_renameat2_args *p = params;
+ iarg[0] = p->oldfd; /* l_int */
+ uarg[1] = (intptr_t) p->oldname; /* const char * */
+ iarg[2] = p->newfd; /* l_int */
+ uarg[3] = (intptr_t) p->newname; /* const char * */
+ uarg[4] = p->flags; /* unsigned int */
+ *n_args = 5;
+ break;
+ }
+ /* linux_seccomp */
+ case 354: {
+ struct linux_seccomp_args *p = params;
+ iarg[0] = p->op; /* l_uint */
+ iarg[1] = p->flags; /* l_uint */
+ uarg[2] = (intptr_t) p->uargs; /* const char * */
+ *n_args = 3;
+ break;
+ }
+ /* linux_getrandom */
+ case 355: {
+ struct linux_getrandom_args *p = params;
+ uarg[0] = (intptr_t) p->buf; /* char * */
+ iarg[1] = p->count; /* l_size_t */
+ iarg[2] = p->flags; /* l_uint */
+ *n_args = 3;
+ break;
+ }
+ /* linux_memfd_create */
+ case 356: {
+ struct linux_memfd_create_args *p = params;
+ uarg[0] = (intptr_t) p->uname_ptr; /* const char * */
+ iarg[1] = p->flags; /* l_uint */
+ *n_args = 2;
+ break;
+ }
+ /* linux_bpf */
+ case 357: {
+ struct linux_bpf_args *p = params;
+ iarg[0] = p->cmd; /* l_int */
+ uarg[1] = (intptr_t) p->attr; /* void * */
+ iarg[2] = p->size; /* l_uint */
+ *n_args = 3;
+ break;
+ }
+ /* linux_execveat */
+ case 358: {
+ struct linux_execveat_args *p = params;
+ iarg[0] = p->dfd; /* l_int */
+ uarg[1] = (intptr_t) p->filename; /* const char * */
+ uarg[2] = (intptr_t) p->argv; /* const char ** */
+ uarg[3] = (intptr_t) p->envp; /* const char ** */
+ iarg[4] = p->flags; /* l_int */
+ *n_args = 5;
+ break;
+ }
+ /* linux_socket */
+ case 359: {
+ struct linux_socket_args *p = params;
+ iarg[0] = p->domain; /* l_int */
+ iarg[1] = p->type; /* l_int */
+ iarg[2] = p->protocol; /* l_int */
+ *n_args = 3;
+ break;
+ }
+ /* linux_socketpair */
+ case 360: {
+ struct linux_socketpair_args *p = params;
+ iarg[0] = p->domain; /* l_int */
+ iarg[1] = p->type; /* l_int */
+ iarg[2] = p->protocol; /* l_int */
+ iarg[3] = p->rsv; /* l_uintptr_t */
+ *n_args = 4;
+ break;
+ }
+ /* linux_bind */
+ case 361: {
+ struct linux_bind_args *p = params;
+ iarg[0] = p->s; /* l_int */
+ iarg[1] = p->name; /* l_uintptr_t */
+ iarg[2] = p->namelen; /* l_int */
+ *n_args = 3;
+ break;
+ }
+ /* linux_connect */
+ case 362: {
+ struct linux_connect_args *p = params;
+ iarg[0] = p->s; /* l_int */
+ iarg[1] = p->name; /* l_uintptr_t */
+ iarg[2] = p->namelen; /* l_int */
+ *n_args = 3;
+ break;
+ }
+ /* linux_listen */
+ case 363: {
+ struct linux_listen_args *p = params;
+ iarg[0] = p->s; /* l_int */
+ iarg[1] = p->backlog; /* l_int */
+ *n_args = 2;
+ break;
+ }
+ /* linux_accept4 */
+ case 364: {
+ struct linux_accept4_args *p = params;
+ iarg[0] = p->s; /* l_int */
+ iarg[1] = p->addr; /* l_uintptr_t */
+ iarg[2] = p->namelen; /* l_uintptr_t */
+ iarg[3] = p->flags; /* l_int */
+ *n_args = 4;
+ break;
+ }
+ /* linux_getsockopt */
+ case 365: {
+ struct linux_getsockopt_args *p = params;
+ iarg[0] = p->s; /* l_int */
+ iarg[1] = p->level; /* l_int */
+ iarg[2] = p->optname; /* l_int */
+ iarg[3] = p->optval; /* l_uintptr_t */
+ iarg[4] = p->optlen; /* l_uintptr_t */
+ *n_args = 5;
+ break;
+ }
+ /* linux_setsockopt */
+ case 366: {
+ struct linux_setsockopt_args *p = params;
+ iarg[0] = p->s; /* l_int */
+ iarg[1] = p->level; /* l_int */
+ iarg[2] = p->optname; /* l_int */
+ iarg[3] = p->optval; /* l_uintptr_t */
+ iarg[4] = p->optlen; /* l_int */
+ *n_args = 5;
+ break;
+ }
+ /* linux_getsockname */
+ case 367: {
+ struct linux_getsockname_args *p = params;
+ iarg[0] = p->s; /* l_int */
+ iarg[1] = p->addr; /* l_uintptr_t */
+ iarg[2] = p->namelen; /* l_uintptr_t */
+ *n_args = 3;
+ break;
+ }
+ /* linux_getpeername */
+ case 368: {
+ struct linux_getpeername_args *p = params;
+ iarg[0] = p->s; /* l_int */
+ iarg[1] = p->addr; /* l_uintptr_t */
+ iarg[2] = p->namelen; /* l_uintptr_t */
+ *n_args = 3;
+ break;
+ }
+ /* linux_sendto */
+ case 369: {
+ struct linux_sendto_args *p = params;
+ iarg[0] = p->s; /* l_int */
+ iarg[1] = p->msg; /* l_uintptr_t */
+ iarg[2] = p->len; /* l_int */
+ iarg[3] = p->flags; /* l_int */
+ iarg[4] = p->to; /* l_uintptr_t */
+ iarg[5] = p->tolen; /* l_int */
+ *n_args = 6;
+ break;
+ }
+ /* linux_sendmsg */
+ case 370: {
+ struct linux_sendmsg_args *p = params;
+ iarg[0] = p->s; /* l_int */
+ iarg[1] = p->msg; /* l_uintptr_t */
+ iarg[2] = p->flags; /* l_int */
+ *n_args = 3;
+ break;
+ }
+ /* linux_recvfrom */
+ case 371: {
+ struct linux_recvfrom_args *p = params;
+ iarg[0] = p->s; /* l_int */
+ iarg[1] = p->buf; /* l_uintptr_t */
+ iarg[2] = p->len; /* l_size_t */
+ iarg[3] = p->flags; /* l_int */
+ iarg[4] = p->from; /* l_uintptr_t */
+ iarg[5] = p->fromlen; /* l_uintptr_t */
+ *n_args = 6;
+ break;
+ }
+ /* linux_recvmsg */
+ case 372: {
+ struct linux_recvmsg_args *p = params;
+ iarg[0] = p->s; /* l_int */
+ iarg[1] = p->msg; /* l_uintptr_t */
+ iarg[2] = p->flags; /* l_int */
+ *n_args = 3;
+ break;
+ }
+ /* linux_shutdown */
+ case 373: {
+ struct linux_shutdown_args *p = params;
+ iarg[0] = p->s; /* l_int */
+ iarg[1] = p->how; /* l_int */
+ *n_args = 2;
+ break;
+ }
+ /* linux_userfaultfd */
+ case 374: {
+ struct linux_userfaultfd_args *p = params;
+ iarg[0] = p->flags; /* l_int */
+ *n_args = 1;
+ break;
+ }
+ /* linux_membarrier */
+ case 375: {
+ struct linux_membarrier_args *p = params;
+ iarg[0] = p->cmd; /* l_int */
+ iarg[1] = p->flags; /* l_int */
+ *n_args = 2;
+ break;
+ }
+ /* linux_mlock2 */
+ case 376: {
+ struct linux_mlock2_args *p = params;
+ iarg[0] = p->start; /* l_ulong */
+ iarg[1] = p->len; /* l_size_t */
+ iarg[2] = p->flags; /* l_int */
+ *n_args = 3;
+ break;
+ }
+ /* linux_copy_file_range */
+ case 377: {
+ struct linux_copy_file_range_args *p = params;
+ iarg[0] = p->fd_in; /* l_int */
+ uarg[1] = (intptr_t) p->off_in; /* l_loff_t * */
+ iarg[2] = p->fd_out; /* l_int */
+ uarg[3] = (intptr_t) p->off_out; /* l_loff_t * */
+ iarg[4] = p->len; /* l_size_t */
+ iarg[5] = p->flags; /* l_uint */
+ *n_args = 6;
+ break;
+ }
+ /* linux_preadv2 */
+ case 378: {
+ struct linux_preadv2_args *p = params;
+ iarg[0] = p->fd; /* l_ulong */
+ uarg[1] = (intptr_t) p->vec; /* const struct iovec * */
+ iarg[2] = p->vlen; /* l_ulong */
+ iarg[3] = p->pos_l; /* l_ulong */
+ iarg[4] = p->pos_h; /* l_ulong */
+ iarg[5] = p->flags; /* l_int */
+ *n_args = 6;
+ break;
+ }
+ /* linux_pwritev2 */
+ case 379: {
+ struct linux_pwritev2_args *p = params;
+ iarg[0] = p->fd; /* l_ulong */
+ uarg[1] = (intptr_t) p->vec; /* const struct iovec * */
+ iarg[2] = p->vlen; /* l_ulong */
+ iarg[3] = p->pos_l; /* l_ulong */
+ iarg[4] = p->pos_h; /* l_ulong */
+ iarg[5] = p->flags; /* l_int */
+ *n_args = 6;
+ break;
+ }
+ /* linux_pkey_mprotect */
+ case 380: {
+ struct linux_pkey_mprotect_args *p = params;
+ iarg[0] = p->start; /* l_ulong */
+ iarg[1] = p->len; /* l_size_t */
+ iarg[2] = p->prot; /* l_ulong */
+ iarg[3] = p->pkey; /* l_int */
+ *n_args = 4;
+ break;
+ }
+ /* linux_pkey_alloc */
+ case 381: {
+ struct linux_pkey_alloc_args *p = params;
+ iarg[0] = p->flags; /* l_ulong */
+ iarg[1] = p->init_val; /* l_ulong */
+ *n_args = 2;
+ break;
+ }
+ /* linux_pkey_free */
+ case 382: {
+ struct linux_pkey_free_args *p = params;
+ iarg[0] = p->pkey; /* l_int */
+ *n_args = 1;
break;
}
default:
@@ -5968,12 +6325,66 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)
break;
/* linux_preadv */
case 333:
+ switch(ndx) {
+ case 0:
+ p = "l_ulong";
+ break;
+ case 1:
+ p = "userland struct iovec *";
+ break;
+ case 2:
+ p = "l_ulong";
+ break;
+ case 3:
+ p = "l_ulong";
+ break;
+ case 4:
+ p = "l_ulong";
+ break;
+ default:
+ break;
+ };
break;
/* linux_pwritev */
case 334:
+ switch(ndx) {
+ case 0:
+ p = "l_ulong";
+ break;
+ case 1:
+ p = "userland struct iovec *";
+ break;
+ case 2:
+ p = "l_ulong";
+ break;
+ case 3:
+ p = "l_ulong";
+ break;
+ case 4:
+ p = "l_ulong";
+ break;
+ default:
+ break;
+ };
break;
- /* linux_rt_tsigqueueinfo */
+ /* linux_rt_tgsigqueueinfo */
case 335:
+ switch(ndx) {
+ case 0:
+ p = "l_pid_t";
+ break;
+ case 1:
+ p = "l_pid_t";
+ break;
+ case 2:
+ p = "l_int";
+ break;
+ case 3:
+ p = "userland l_siginfo_t *";
+ break;
+ default:
+ break;
+ };
break;
/* linux_perf_event_open */
case 336:
@@ -6068,9 +6479,657 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)
break;
/* linux_process_vm_readv */
case 347:
+ switch(ndx) {
+ case 0:
+ p = "l_pid_t";
+ break;
+ case 1:
+ p = "userland const struct iovec *";
+ break;
+ case 2:
+ p = "l_ulong";
+ break;
+ case 3:
+ p = "userland const struct iovec *";
+ break;
+ case 4:
+ p = "l_ulong";
+ break;
+ case 5:
+ p = "l_ulong";
+ break;
+ default:
+ break;
+ };
break;
/* linux_process_vm_writev */
case 348:
+ switch(ndx) {
+ case 0:
+ p = "l_pid_t";
+ break;
+ case 1:
+ p = "userland const struct iovec *";
+ break;
+ case 2:
+ p = "l_ulong";
+ break;
+ case 3:
+ p = "userland const struct iovec *";
+ break;
+ case 4:
+ p = "l_ulong";
+ break;
+ case 5:
+ p = "l_ulong";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_kcmp */
+ case 349:
+ switch(ndx) {
+ case 0:
+ p = "l_pid_t";
+ break;
+ case 1:
+ p = "l_pid_t";
+ break;
+ case 2:
+ p = "l_int";
+ break;
+ case 3:
+ p = "l_ulong";
+ break;
+ case 4:
+ p = "l_ulong";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_finit_module */
+ case 350:
+ switch(ndx) {
+ case 0:
+ p = "l_int";
+ break;
+ case 1:
+ p = "userland const char *";
+ break;
+ case 2:
+ p = "l_int";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_sched_setattr */
+ case 351:
+ switch(ndx) {
+ case 0:
+ p = "l_pid_t";
+ break;
+ case 1:
+ p = "userland void *";
+ break;
+ case 2:
+ p = "l_uint";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_sched_getattr */
+ case 352:
+ switch(ndx) {
+ case 0:
+ p = "l_pid_t";
+ break;
+ case 1:
+ p = "userland void *";
+ break;
+ case 2:
+ p = "l_uint";
+ break;
+ case 3:
+ p = "l_uint";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_renameat2 */
+ case 353:
+ switch(ndx) {
+ case 0:
+ p = "l_int";
+ break;
+ case 1:
+ p = "userland const char *";
+ break;
+ case 2:
+ p = "l_int";
+ break;
+ case 3:
+ p = "userland const char *";
+ break;
+ case 4:
+ p = "unsigned int";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_seccomp */
+ case 354:
+ switch(ndx) {
+ case 0:
+ p = "l_uint";
+ break;
+ case 1:
+ p = "l_uint";
+ break;
+ case 2:
+ p = "userland const char *";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_getrandom */
+ case 355:
+ switch(ndx) {
+ case 0:
+ p = "userland char *";
+ break;
+ case 1:
+ p = "l_size_t";
+ break;
+ case 2:
+ p = "l_uint";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_memfd_create */
+ case 356:
+ switch(ndx) {
+ case 0:
+ p = "userland const char *";
+ break;
+ case 1:
+ p = "l_uint";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_bpf */
+ case 357:
+ switch(ndx) {
+ case 0:
+ p = "l_int";
+ break;
+ case 1:
+ p = "userland void *";
+ break;
+ case 2:
+ p = "l_uint";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_execveat */
+ case 358:
+ switch(ndx) {
+ case 0:
+ p = "l_int";
+ break;
+ case 1:
+ p = "userland const char *";
+ break;
+ case 2:
+ p = "userland const char **";
+ break;
+ case 3:
+ p = "userland const char **";
+ break;
+ case 4:
+ p = "l_int";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_socket */
+ case 359:
+ switch(ndx) {
+ case 0:
+ p = "l_int";
+ break;
+ case 1:
+ p = "l_int";
+ break;
+ case 2:
+ p = "l_int";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_socketpair */
+ case 360:
+ switch(ndx) {
+ case 0:
+ p = "l_int";
+ break;
+ case 1:
+ p = "l_int";
+ break;
+ case 2:
+ p = "l_int";
+ break;
+ case 3:
+ p = "l_uintptr_t";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_bind */
+ case 361:
+ switch(ndx) {
+ case 0:
+ p = "l_int";
+ break;
+ case 1:
+ p = "l_uintptr_t";
+ break;
+ case 2:
+ p = "l_int";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_connect */
+ case 362:
+ switch(ndx) {
+ case 0:
+ p = "l_int";
+ break;
+ case 1:
+ p = "l_uintptr_t";
+ break;
+ case 2:
+ p = "l_int";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_listen */
+ case 363:
+ switch(ndx) {
+ case 0:
+ p = "l_int";
+ break;
+ case 1:
+ p = "l_int";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_accept4 */
+ case 364:
+ switch(ndx) {
+ case 0:
+ p = "l_int";
+ break;
+ case 1:
+ p = "l_uintptr_t";
+ break;
+ case 2:
+ p = "l_uintptr_t";
+ break;
+ case 3:
+ p = "l_int";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_getsockopt */
+ case 365:
+ switch(ndx) {
+ case 0:
+ p = "l_int";
+ break;
+ case 1:
+ p = "l_int";
+ break;
+ case 2:
+ p = "l_int";
+ break;
+ case 3:
+ p = "l_uintptr_t";
+ break;
+ case 4:
+ p = "l_uintptr_t";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_setsockopt */
+ case 366:
+ switch(ndx) {
+ case 0:
+ p = "l_int";
+ break;
+ case 1:
+ p = "l_int";
+ break;
+ case 2:
+ p = "l_int";
+ break;
+ case 3:
+ p = "l_uintptr_t";
+ break;
+ case 4:
+ p = "l_int";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_getsockname */
+ case 367:
+ switch(ndx) {
+ case 0:
+ p = "l_int";
+ break;
+ case 1:
+ p = "l_uintptr_t";
+ break;
+ case 2:
+ p = "l_uintptr_t";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_getpeername */
+ case 368:
+ switch(ndx) {
+ case 0:
+ p = "l_int";
+ break;
+ case 1:
+ p = "l_uintptr_t";
+ break;
+ case 2:
+ p = "l_uintptr_t";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_sendto */
+ case 369:
+ switch(ndx) {
+ case 0:
+ p = "l_int";
+ break;
+ case 1:
+ p = "l_uintptr_t";
+ break;
+ case 2:
+ p = "l_int";
+ break;
+ case 3:
+ p = "l_int";
+ break;
+ case 4:
+ p = "l_uintptr_t";
+ break;
+ case 5:
+ p = "l_int";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_sendmsg */
+ case 370:
+ switch(ndx) {
+ case 0:
+ p = "l_int";
+ break;
+ case 1:
+ p = "l_uintptr_t";
+ break;
+ case 2:
+ p = "l_int";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_recvfrom */
+ case 371:
+ switch(ndx) {
+ case 0:
+ p = "l_int";
+ break;
+ case 1:
+ p = "l_uintptr_t";
+ break;
+ case 2:
+ p = "l_size_t";
+ break;
+ case 3:
+ p = "l_int";
+ break;
+ case 4:
+ p = "l_uintptr_t";
+ break;
+ case 5:
+ p = "l_uintptr_t";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_recvmsg */
+ case 372:
+ switch(ndx) {
+ case 0:
+ p = "l_int";
+ break;
+ case 1:
+ p = "l_uintptr_t";
+ break;
+ case 2:
+ p = "l_int";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_shutdown */
+ case 373:
+ switch(ndx) {
+ case 0:
+ p = "l_int";
+ break;
+ case 1:
+ p = "l_int";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_userfaultfd */
+ case 374:
+ switch(ndx) {
+ case 0:
+ p = "l_int";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_membarrier */
+ case 375:
+ switch(ndx) {
+ case 0:
+ p = "l_int";
+ break;
+ case 1:
+ p = "l_int";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_mlock2 */
+ case 376:
+ switch(ndx) {
+ case 0:
+ p = "l_ulong";
+ break;
+ case 1:
+ p = "l_size_t";
+ break;
+ case 2:
+ p = "l_int";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_copy_file_range */
+ case 377:
+ switch(ndx) {
+ case 0:
+ p = "l_int";
+ break;
+ case 1:
+ p = "userland l_loff_t *";
+ break;
+ case 2:
+ p = "l_int";
+ break;
+ case 3:
+ p = "userland l_loff_t *";
+ break;
+ case 4:
+ p = "l_size_t";
+ break;
+ case 5:
+ p = "l_uint";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_preadv2 */
+ case 378:
+ switch(ndx) {
+ case 0:
+ p = "l_ulong";
+ break;
+ case 1:
+ p = "userland const struct iovec *";
+ break;
+ case 2:
+ p = "l_ulong";
+ break;
+ case 3:
+ p = "l_ulong";
+ break;
+ case 4:
+ p = "l_ulong";
+ break;
+ case 5:
+ p = "l_int";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_pwritev2 */
+ case 379:
+ switch(ndx) {
+ case 0:
+ p = "l_ulong";
+ break;
+ case 1:
+ p = "userland const struct iovec *";
+ break;
+ case 2:
+ p = "l_ulong";
+ break;
+ case 3:
+ p = "l_ulong";
+ break;
+ case 4:
+ p = "l_ulong";
+ break;
+ case 5:
+ p = "l_int";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_pkey_mprotect */
+ case 380:
+ switch(ndx) {
+ case 0:
+ p = "l_ulong";
+ break;
+ case 1:
+ p = "l_size_t";
+ break;
+ case 2:
+ p = "l_ulong";
+ break;
+ case 3:
+ p = "l_int";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_pkey_alloc */
+ case 381:
+ switch(ndx) {
+ case 0:
+ p = "l_ulong";
+ break;
+ case 1:
+ p = "l_ulong";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* linux_pkey_free */
+ case 382:
+ switch(ndx) {
+ case 0:
+ p = "l_int";
+ break;
+ default:
+ break;
+ };
break;
default:
break;
@@ -7387,10 +8446,19 @@ systrace_return_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)
case 332:
/* linux_preadv */
case 333:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
/* linux_pwritev */
case 334:
- /* linux_rt_tsigqueueinfo */
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_rt_tgsigqueueinfo */
case 335:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
/* linux_perf_event_open */
case 336:
/* linux_recvmmsg */
@@ -7427,8 +8495,184 @@ systrace_return_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)
case 346:
/* linux_process_vm_readv */
case 347:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
/* linux_process_vm_writev */
case 348:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_kcmp */
+ case 349:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_finit_module */
+ case 350:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_sched_setattr */
+ case 351:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_sched_getattr */
+ case 352:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_renameat2 */
+ case 353:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_seccomp */
+ case 354:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_getrandom */
+ case 355:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_memfd_create */
+ case 356:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_bpf */
+ case 357:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_execveat */
+ case 358:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_socket */
+ case 359:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_socketpair */
+ case 360:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_bind */
+ case 361:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_connect */
+ case 362:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_listen */
+ case 363:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_accept4 */
+ case 364:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_getsockopt */
+ case 365:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_setsockopt */
+ case 366:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_getsockname */
+ case 367:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_getpeername */
+ case 368:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_sendto */
+ case 369:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_sendmsg */
+ case 370:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_recvfrom */
+ case 371:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_recvmsg */
+ case 372:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_shutdown */
+ case 373:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_userfaultfd */
+ case 374:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_membarrier */
+ case 375:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_mlock2 */
+ case 376:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_copy_file_range */
+ case 377:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_preadv2 */
+ case 378:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_pwritev2 */
+ case 379:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_pkey_mprotect */
+ case 380:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_pkey_alloc */
+ case 381:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
+ /* linux_pkey_free */
+ case 382:
+ if (ndx == 0 || ndx == 1)
+ p = "int";
+ break;
default:
break;
};
diff --git a/sys/i386/linux/syscalls.master b/sys/i386/linux/syscalls.master
index 5899adb..20aec5b 100644
--- a/sys/i386/linux/syscalls.master
+++ b/sys/i386/linux/syscalls.master
@@ -11,18 +11,20 @@
; there is no audit event for the call at this time. For the
; case where the event exists, but we don't want auditing, the
; event should be #defined to AUE_NULL in audit_kevents.h.
-; type one of STD, OBSOL, UNIMPL
+; type one of STD, NOPROTO, UNIMPL
; name psuedo-prototype of syscall routine
; If one of the following alts is different, then all appear:
; altname name of system call if different
; alttag name of args struct tag if different from [o]`name'"_args"
; altrtyp return type if not int (bogus - syscalls always return int)
-; for UNIMPL/OBSOL, name continues with comments
+; for UNIMPL, name continues with comments
; types:
; STD always included
-; OBSOL obsolete, not included in system, only specifies name
; UNIMPL not implemented, placeholder only
+; NOPROTO same as STD except do not create structure or
+; function prototype in sys/sysproto.h. Does add a
+; definition to syscall.h besides adding a sysent.
#include <sys/param.h>
#include <sys/sysent.h>
@@ -561,10 +563,15 @@
331 AUE_NULL STD { int linux_pipe2(l_int *pipefds, l_int flags); }
332 AUE_NULL STD { int linux_inotify_init1(void); }
; linux 2.6.30:
-333 AUE_NULL STD { int linux_preadv(void); }
-334 AUE_NULL STD { int linux_pwritev(void); }
+333 AUE_NULL STD { int linux_preadv(l_ulong fd, \
+ struct iovec *vec, l_ulong vlen, \
+ l_ulong pos_l, l_ulong pos_h); }
+334 AUE_NULL STD { int linux_pwritev(l_ulong fd, \
+ struct iovec *vec, l_ulong vlen, \
+ l_ulong pos_l, l_ulong pos_h); }
; linux 2.6.31:
-335 AUE_NULL STD { int linux_rt_tsigqueueinfo(void); }
+335 AUE_NULL STD { int linux_rt_tgsigqueueinfo(l_pid_t tgid, \
+ l_pid_t tid, l_int sig, l_siginfo_t *uinfo); }
336 AUE_NULL STD { int linux_perf_event_open(void); }
; linux 2.6.33:
337 AUE_NULL STD { int linux_recvmmsg(l_int s, \
@@ -577,16 +584,112 @@
l_uint resource, \
struct rlimit *new, \
struct rlimit *old); }
-; later:
+; linux 2.6.39:
341 AUE_NULL STD { int linux_name_to_handle_at(void); }
342 AUE_NULL STD { int linux_open_by_handle_at(void); }
343 AUE_NULL STD { int linux_clock_adjtime(void); }
344 AUE_SYNC STD { int linux_syncfs(l_int fd); }
+; linux 3.0:
345 AUE_NULL STD { int linux_sendmmsg(l_int s, \
struct l_mmsghdr *msg, l_uint vlen, \
l_uint flags); }
346 AUE_NULL STD { int linux_setns(void); }
-347 AUE_NULL STD { int linux_process_vm_readv(void); }
-348 AUE_NULL STD { int linux_process_vm_writev(void); }
+; linux 3.2 (glibc 2.15):
+347 AUE_NULL STD { int linux_process_vm_readv(l_pid_t pid, \
+ const struct iovec *lvec, l_ulong liovcnt, \
+ const struct iovec *rvec, l_ulong riovcnt, \
+ l_ulong flags); }
+348 AUE_NULL STD { int linux_process_vm_writev(l_pid_t pid, \
+ const struct iovec *lvec, l_ulong liovcnt, \
+ const struct iovec *rvec, l_ulong riovcnt, \
+ l_ulong flags); }
+; linux 3.5 (no glibc wrapper):
+349 AUE_NULL STD { int linux_kcmp(l_pid_t pid1, l_pid_t pid2, \
+ l_int type, l_ulong idx1, l_ulong idx); }
+; linux 3.8 (no glibc wrapper):
+350 AUE_NULL STD { int linux_finit_module(l_int fd, \
+ const char *uargs, l_int flags); }
+; linux 3.14:
+351 AUE_NULL STD { int linux_sched_setattr(l_pid_t pid, \
+ void *attr, l_uint flags); }
+352 AUE_NULL STD { int linux_sched_getattr(l_pid_t pid, \
+ void *attr, l_uint size, l_uint flags); }
+; linux 3.15:
+353 AUE_NULL STD { int linux_renameat2(l_int oldfd, \
+ const char *oldname, l_int newfd, \
+ const char *newname, unsigned int flags); }
+; linux 3.17:
+354 AUE_NULL STD { int linux_seccomp(l_uint op, l_uint flags, \
+ const char *uargs); }
+355 AUE_NULL STD { int linux_getrandom(char *buf, \
+ l_size_t count, l_uint flags); }
+356 AUE_NULL STD { int linux_memfd_create(const char *uname_ptr, \
+ l_uint flags); }
+; linux 3.18:
+357 AUE_NULL STD { int linux_bpf(l_int cmd, void *attr, \
+ l_uint size); }
+; linux 3.19:
+358 AUE_NULL STD { int linux_execveat(l_int dfd, \
+ const char *filename, const char **argv, \
+ const char **envp, l_int flags); }
+; linux 4.3: sockets now direct system calls:
+359 AUE_SOCKET STD { int linux_socket(l_int domain, l_int type, \
+ l_int protocol); }
+360 AUE_SOCKETPAIR STD { int linux_socketpair(l_int domain, \
+ l_int type, l_int protocol, l_uintptr_t rsv); }
+361 AUE_BIND STD { int linux_bind(l_int s, l_uintptr_t name, \
+ l_int namelen); }
+362 AUE_CONNECT STD { int linux_connect(l_int s, l_uintptr_t name, \
+ l_int namelen); }
+363 AUE_LISTEN STD { int linux_listen(l_int s, l_int backlog); }
+364 AUE_ACCEPT STD { int linux_accept4(l_int s, l_uintptr_t addr, \
+ l_uintptr_t namelen, l_int flags); }
+365 AUE_GETSOCKOPT STD { int linux_getsockopt(l_int s, l_int level, \
+ l_int optname, l_uintptr_t optval, \
+ l_uintptr_t optlen); }
+366 AUE_SETSOCKOPT STD { int linux_setsockopt(l_int s, l_int level, \
+ l_int optname, l_uintptr_t optval, \
+ l_int optlen); }
+367 AUE_GETSOCKNAME STD { int linux_getsockname(l_int s, \
+ l_uintptr_t addr, l_uintptr_t namelen); }
+368 AUE_GETPEERNAME STD { int linux_getpeername(l_int s, \
+ l_uintptr_t addr, l_uintptr_t namelen); }
+369 AUE_SENDTO STD { int linux_sendto(l_int s, l_uintptr_t msg, \
+ l_int len, l_int flags, l_uintptr_t to, \
+ l_int tolen); }
+370 AUE_SENDMSG STD { int linux_sendmsg(l_int s, l_uintptr_t msg, \
+ l_int flags); }
+371 AUE_RECVFROM STD { int linux_recvfrom(l_int s, l_uintptr_t buf, \
+ l_size_t len, l_int flags, l_uintptr_t from, \
+ l_uintptr_t fromlen); }
+372 AUE_RECVMSG STD { int linux_recvmsg(l_int s, l_uintptr_t msg, \
+ l_int flags); }
+373 AUE_NULL STD { int linux_shutdown(l_int s, l_int how); }
+; linux 4.2:
+374 AUE_NULL STD { int linux_userfaultfd(l_int flags); }
+; linux 4.3:
+375 AUE_NULL STD { int linux_membarrier(l_int cmd, l_int flags); }
+; linux 4.4:
+376 AUE_NULL STD { int linux_mlock2(l_ulong start, l_size_t len, \
+ l_int flags); }
+; linux 4.5:
+377 AUE_NULL STD { int linux_copy_file_range(l_int fd_in, \
+ l_loff_t *off_in, l_int fd_out, \
+ l_loff_t *off_out, l_size_t len, \
+ l_uint flags); }
+; linux 4.6:
+378 AUE_NULL STD { int linux_preadv2(l_ulong fd, \
+ const struct iovec *vec, l_ulong vlen, \
+ l_ulong pos_l, l_ulong pos_h, l_int flags); }
+379 AUE_NULL STD { int linux_pwritev2(l_ulong fd, \
+ const struct iovec *vec, l_ulong vlen, \
+ l_ulong pos_l, l_ulong pos_h, l_int flags); }
+; linux 4.8:
+380 AUE_NULL STD { int linux_pkey_mprotect(l_ulong start, \
+ l_size_t len, l_ulong prot, l_int pkey); }
+381 AUE_NULL STD { int linux_pkey_alloc(l_ulong flags, \
+ l_ulong init_val); }
+382 AUE_NULL STD { int linux_pkey_free(l_int pkey); }
+
; please, keep this line at the end.
-349 AUE_NULL UNIMPL nosys
+383 AUE_NULL UNIMPL nosys
diff --git a/sys/kern/kern_lockf.c b/sys/kern/kern_lockf.c
index c8a2345..fdffd83 100644
--- a/sys/kern/kern_lockf.c
+++ b/sys/kern/kern_lockf.c
@@ -689,7 +689,7 @@ retry_setlock:
break;
}
-#ifdef INVARIANTS
+#ifdef DIAGNOSTIC
/*
* Check for some can't happen stuff. In this case, the active
* lock list becoming disordered or containing mutually
@@ -917,7 +917,7 @@ lf_add_edge(struct lockf_entry *x, struct lockf_entry *y)
struct lockf_edge *e;
int error;
-#ifdef INVARIANTS
+#ifdef DIAGNOSTIC
LIST_FOREACH(e, &x->lf_outedges, le_outlink)
KASSERT(e->le_to != y, ("adding lock edge twice"));
#endif
diff --git a/sys/kern/subr_sfbuf.c b/sys/kern/subr_sfbuf.c
index 707ace2..fa1aa42 100644
--- a/sys/kern/subr_sfbuf.c
+++ b/sys/kern/subr_sfbuf.c
@@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$");
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/mutex.h>
+#include <sys/proc.h>
#include <sys/sf_buf.h>
#include <sys/smp.h>
#include <sys/sysctl.h>
diff --git a/sys/kern/subr_witness.c b/sys/kern/subr_witness.c
index ec33428..21eb2e7 100644
--- a/sys/kern/subr_witness.c
+++ b/sys/kern/subr_witness.c
@@ -1733,15 +1733,14 @@ witness_warn(int flags, struct lock_object *lock, const char *fmt, ...)
continue;
if (n == 0) {
va_start(ap, fmt);
- witness_voutput(fmt, ap);
+ vprintf(fmt, ap);
va_end(ap);
- witness_output(
- " with the following %slocks held:\n",
+ printf(" with the following %slocks held:\n",
(flags & WARN_SLEEPOK) != 0 ?
"non-sleepable " : "");
}
n++;
- witness_list_lock(lock1, witness_output);
+ witness_list_lock(lock1, printf);
}
/*
@@ -1766,11 +1765,11 @@ witness_warn(int flags, struct lock_object *lock, const char *fmt, ...)
return (0);
va_start(ap, fmt);
- witness_voutput(fmt, ap);
+ vprintf(fmt, ap);
va_end(ap);
- witness_output(" with the following %slocks held:\n",
+ printf(" with the following %slocks held:\n",
(flags & WARN_SLEEPOK) != 0 ? "non-sleepable " : "");
- n += witness_list_locks(&lock_list, witness_output);
+ n += witness_list_locks(&lock_list, printf);
} else
sched_unpin();
if (flags & WARN_PANIC && n)
diff --git a/sys/kern/sys_socket.c b/sys/kern/sys_socket.c
index 80c55dd..da5f8e8 100644
--- a/sys/kern/sys_socket.c
+++ b/sys/kern/sys_socket.c
@@ -604,6 +604,8 @@ retry:
if (td->td_ru.ru_msgrcv != ru_before)
job->msgrcv = 1;
} else {
+ if (!TAILQ_EMPTY(&sb->sb_aiojobq))
+ flags |= MSG_MORETOCOME;
uio.uio_rw = UIO_WRITE;
ru_before = td->td_ru.ru_msgsnd;
#ifdef MAC
diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c
index 8117418..3df1607 100644
--- a/sys/kern/uipc_socket.c
+++ b/sys/kern/uipc_socket.c
@@ -1182,6 +1182,7 @@ sosend_dgram(struct socket *so, struct sockaddr *addr, struct uio *uio,
(resid <= 0)) ?
PRUS_EOF :
/* If there is more to send set PRUS_MORETOCOME */
+ (flags & MSG_MORETOCOME) ||
(resid > 0 && space > 0) ? PRUS_MORETOCOME : 0,
top, addr, control, td);
if (dontroute) {
@@ -1368,6 +1369,7 @@ restart:
(resid <= 0)) ?
PRUS_EOF :
/* If there is more to send set PRUS_MORETOCOME. */
+ (flags & MSG_MORETOCOME) ||
(resid > 0 && space > 0) ? PRUS_MORETOCOME : 0,
top, addr, control, td);
if (dontroute) {
diff --git a/sys/mips/include/_types.h b/sys/mips/include/_types.h
index a05f01c..d37b1bc 100644
--- a/sys/mips/include/_types.h
+++ b/sys/mips/include/_types.h
@@ -143,8 +143,6 @@ typedef __uint64_t __vm_paddr_t;
typedef __uint32_t __vm_paddr_t;
#endif
-typedef __int64_t __vm_ooffset_t;
-typedef __uint64_t __vm_pindex_t;
typedef int ___wchar_t;
#define __WCHAR_MIN __INT_MIN /* min value for a wchar_t */
diff --git a/sys/modules/ath/Makefile b/sys/modules/ath/Makefile
index 332eb75..9bfc29c 100644
--- a/sys/modules/ath/Makefile
+++ b/sys/modules/ath/Makefile
@@ -31,8 +31,8 @@
ATH_RATE?= sample # tx rate control algorithm
-.PATH: ${.CURDIR}/../../dev/ath
-.PATH: ${.CURDIR}/../../dev/ath/ath_hal
+.PATH: ${SRCTOP}/sys/dev/ath
+.PATH: ${SRCTOP}/sys/dev/ath/ath_hal
KMOD= if_ath
SRCS= if_ath.c if_ath_alq.c if_ath_debug.c if_ath_keycache.c if_ath_sysctl.c
@@ -46,7 +46,7 @@ SRCS+= device_if.h bus_if.h pci_if.h opt_inet.h opt_ath.h opt_ah.h opt_wlan.h
#
# AR5210 support; these are first generation 11a-only devices.
#
-.PATH: ${.CURDIR}/../../dev/ath/ath_hal/ar5210
+.PATH: ${SRCTOP}/sys/dev/ath/ath_hal/ar5210
SRCS+= ah_eeprom_v1.c \
ar5210_attach.c ar5210_beacon.c ar5210_interrupts.c \
ar5210_keycache.c ar5210_misc.c ar5210_phy.c ar5210_power.c \
@@ -56,7 +56,7 @@ SRCS+= ah_eeprom_v1.c \
# AR5211 support; these are second generation 11b/g/a devices
# (but 11g was OFDM only and is not supported).
#
-.PATH: ${.CURDIR}/../../dev/ath/ath_hal/ar5211
+.PATH: ${SRCTOP}/sys/dev/ath/ath_hal/ar5211
SRCS+= ar5211_attach.c ar5211_beacon.c ar5211_interrupts.c \
ar5211_keycache.c ar5211_misc.c ar5211_phy.c ar5211_power.c \
ar5211_recv.c ar5211_reset.c ar5211_xmit.c
@@ -64,7 +64,7 @@ SRCS+= ar5211_attach.c ar5211_beacon.c ar5211_interrupts.c \
#
# AR5212 support; this covers all other pci/cardbus legacy parts.
#
-.PATH: ${.CURDIR}/../../dev/ath/ath_hal/ar5212
+.PATH: ${SRCTOP}/sys/dev/ath/ath_hal/ar5212
SRCS+= ar5212_ani.c ar5212_attach.c ar5212_beacon.c ar5212_eeprom.c \
ar5212_gpio.c ar5212_interrupts.c ar5212_keycache.c ar5212_misc.c \
ar5212_phy.c ar5212_power.c ar5212_recv.c ar5212_reset.c \
@@ -85,7 +85,7 @@ SRCS+= ar5413.c
# NB: 9160 depends on 5416 but 5416 does not require 9160
#
# + 5416 (Owl)
-.PATH: ${.CURDIR}/../../dev/ath/ath_hal/ar5416
+.PATH: ${SRCTOP}/sys/dev/ath/ath_hal/ar5416
SRCS+= ah_eeprom_v14.c ah_eeprom_v4k.c \
ar5416_ani.c ar5416_attach.c ar5416_beacon.c ar5416_btcoex.c \
ar5416_cal.c ar5416_cal_iq.c ar5416_cal_adcgain.c ar5416_cal_adcdc.c \
@@ -97,7 +97,7 @@ SRCS+= ah_eeprom_v14.c ah_eeprom_v4k.c \
SRCS+= ar2133.c
# + AR9160 (Sowl)
-.PATH: ${.CURDIR}/../../dev/ath/ath_hal/ar9001
+.PATH: ${SRCTOP}/sys/dev/ath/ath_hal/ar9001
SRCS+= ar9160_attach.c
# + AR9130 - (Sowl) - Embedded (AR913x SoC)
@@ -111,7 +111,7 @@ SRCS+= ar9130_attach.c ar9130_eeprom.c ar9130_phy.c
# AR9002 series chips
# + AR9220/AR9280 - Merlin
-.PATH: ${.CURDIR}/../../dev/ath/ath_hal/ar9002
+.PATH: ${SRCTOP}/sys/dev/ath/ath_hal/ar9002
SRCS+= ar9280.c ar9280_attach.c ar9280_olc.c
# + AR9285 - Kite
@@ -119,13 +119,13 @@ SRCS+= ar9285.c ar9285_reset.c ar9285_attach.c ar9285_cal.c ar9285_phy.c
SRCS+= ar9285_diversity.c ar9285_btcoex.c
# + AR9287 - Kiwi
-.PATH: ${.CURDIR}/../../dev/ath/ath_hal
+.PATH: ${SRCTOP}/sys/dev/ath/ath_hal
SRCS+= ah_eeprom_9287.c
-.PATH: ${.CURDIR}/../../dev/ath/ath_hal/ar9002
+.PATH: ${SRCTOP}/sys/dev/ath/ath_hal/ar9002
SRCS+= ar9287.c ar9287_reset.c ar9287_attach.c ar9287_cal.c ar9287_olc.c
# + AR9300 HAL
-.PATH: ${.CURDIR}/../../contrib/dev/ath/ath_hal/ar9300
+.PATH: ${SRCTOP}/sys/contrib/dev/ath/ath_hal/ar9300
SRCS+= ar9300_interrupts.c ar9300_radar.c ar9300_ani.c ar9300_keycache.c
SRCS+= ar9300_radio.c ar9300_xmit.c ar9300_attach.c ar9300_mci.c ar9300_stub.c
SRCS+= ar9300_xmit_ds.c ar9300_beacon.c ar9300_misc.c ar9300_recv.c
@@ -135,22 +135,22 @@ SRCS+= ar9300_power.c ar9300_timer.c ar9300_spectral.c
# NB: rate control is bound to the driver by symbol names so only pick one
.if ${ATH_RATE} == "sample"
-.PATH: ${.CURDIR}/../../dev/ath/ath_rate/sample
+.PATH: ${SRCTOP}/sys/dev/ath/ath_rate/sample
SRCS+= sample.c
.elif ${ATH_RATE} == "onoe"
-.PATH: ${.CURDIR}/../../dev/ath/ath_rate/onoe
+.PATH: ${SRCTOP}/sys/dev/ath/ath_rate/onoe
SRCS+= onoe.c
.elif ${ATH_RATE} == "amrr"
-.PATH: ${.CURDIR}/../../dev/ath/ath_rate/amrr
+.PATH: ${SRCTOP}/sys/dev/ath/ath_rate/amrr
SRCS+= amrr.c
.endif
# DFS
-.PATH: ${.CURDIR}/../../dev/ath/ath_dfs/null
+.PATH: ${SRCTOP}/sys/dev/ath/ath_dfs/null
SRCS+= dfs_null.c
-CFLAGS+= -I. -I${.CURDIR}/../../dev/ath -I${.CURDIR}/../../dev/ath/ath_hal
-CFLAGS+= -I. -I${.CURDIR}/../../contrib/dev/ath/ath_hal/
+CFLAGS+= -I. -I${SRCTOP}/sys/dev/ath -I${SRCTOP}/sys/dev/ath/ath_hal
+CFLAGS+= -I. -I${SRCTOP}/sys/contrib/dev/ath/ath_hal/
.if !defined(KERNBUILDDIR)
opt_ah.h:
diff --git a/sys/net/if.c b/sys/net/if.c
index fa55662..12f867c 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -2218,6 +2218,7 @@ void
if_down(struct ifnet *ifp)
{
+ EVENTHANDLER_INVOKE(ifnet_event, ifp, IFNET_EVENT_DOWN);
if_unroute(ifp, IFF_UP, AF_UNSPEC);
}
@@ -2230,6 +2231,7 @@ if_up(struct ifnet *ifp)
{
if_route(ifp, IFF_UP, AF_UNSPEC);
+ EVENTHANDLER_INVOKE(ifnet_event, ifp, IFNET_EVENT_UP);
}
/*
@@ -2300,7 +2302,7 @@ static int
ifhwioctl(u_long cmd, struct ifnet *ifp, caddr_t data, struct thread *td)
{
struct ifreq *ifr;
- int error = 0;
+ int error = 0, do_ifup = 0;
int new_flags, temp_flags;
size_t namelen, onamelen;
size_t descrlen;
@@ -2427,7 +2429,7 @@ ifhwioctl(u_long cmd, struct ifnet *ifp, caddr_t data, struct thread *td)
if_down(ifp);
} else if (new_flags & IFF_UP &&
(ifp->if_flags & IFF_UP) == 0) {
- if_up(ifp);
+ do_ifup = 1;
}
/* See if permanently promiscuous mode bit is about to flip */
if ((ifp->if_flags ^ new_flags) & IFF_PPROMISC) {
@@ -2446,6 +2448,8 @@ ifhwioctl(u_long cmd, struct ifnet *ifp, caddr_t data, struct thread *td)
if (ifp->if_ioctl) {
(void) (*ifp->if_ioctl)(ifp, cmd, data);
}
+ if (do_ifup)
+ if_up(ifp);
getmicrotime(&ifp->if_lastchange);
break;
diff --git a/sys/net/if_var.h b/sys/net/if_var.h
index 2298de5..89fc2d83 100644
--- a/sys/net/if_var.h
+++ b/sys/net/if_var.h
@@ -359,6 +359,11 @@ EVENTHANDLER_DECLARE(ifnet_departure_event, ifnet_departure_event_handler_t);
/* Interface link state change event */
typedef void (*ifnet_link_event_handler_t)(void *, struct ifnet *, int);
EVENTHANDLER_DECLARE(ifnet_link_event, ifnet_link_event_handler_t);
+/* Interface up/down event */
+#define IFNET_EVENT_UP 0
+#define IFNET_EVENT_DOWN 1
+typedef void (*ifnet_event_fn)(void *, struct ifnet *ifp, int event);
+EVENTHANDLER_DECLARE(ifnet_event, ifnet_event_fn);
#endif /* _SYS_EVENTHANDLER_H_ */
/*
diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c
index 76fc7fa..3bf5c6f 100644
--- a/sys/netinet/udp_usrreq.c
+++ b/sys/netinet/udp_usrreq.c
@@ -674,13 +674,13 @@ udp_input(struct mbuf **mp, int *offp, int proto)
INPLOOKUP_RLOCKPCB, ifp, m);
if (inp == NULL) {
if (udp_log_in_vain) {
- char buf[4*sizeof "123"];
+ char src[INET_ADDRSTRLEN];
+ char dst[INET_ADDRSTRLEN];
- strcpy(buf, inet_ntoa(ip->ip_dst));
log(LOG_INFO,
"Connection attempt to UDP %s:%d from %s:%d\n",
- buf, ntohs(uh->uh_dport), inet_ntoa(ip->ip_src),
- ntohs(uh->uh_sport));
+ inet_ntoa_r(ip->ip_dst, dst), ntohs(uh->uh_dport),
+ inet_ntoa_r(ip->ip_src, src), ntohs(uh->uh_sport));
}
UDPSTAT_INC(udps_noport);
if (m->m_flags & (M_BCAST | M_MCAST)) {
diff --git a/sys/netpfil/ipfw/dn_heap.h b/sys/netpfil/ipfw/dn_heap.h
index cb6e03e..bbc11c1 100644
--- a/sys/netpfil/ipfw/dn_heap.h
+++ b/sys/netpfil/ipfw/dn_heap.h
@@ -85,7 +85,7 @@ enum {
* HEAP_TOP() returns a pointer to the top element of the heap,
* but makes no checks on its existence (XXX should we change ?)
*
- * heap_extract() removes the entry at the top, returing the pointer.
+ * heap_extract() removes the entry at the top, returning the pointer.
* (the key should have been read before).
*
* heap_scan() invokes a callback on each entry of the heap.
diff --git a/sys/powerpc/include/_types.h b/sys/powerpc/include/_types.h
index 2c92afc..fc2285f 100644
--- a/sys/powerpc/include/_types.h
+++ b/sys/powerpc/include/_types.h
@@ -135,8 +135,6 @@ typedef __uint32_t __vm_paddr_t;
#endif
typedef __uint32_t __vm_size_t;
#endif
-typedef __int64_t __vm_ooffset_t;
-typedef __uint64_t __vm_pindex_t;
typedef int ___wchar_t;
#define __WCHAR_MIN __INT_MIN /* min value for a wchar_t */
diff --git a/sys/riscv/include/_types.h b/sys/riscv/include/_types.h
index 733d47c..29e3c6a 100644
--- a/sys/riscv/include/_types.h
+++ b/sys/riscv/include/_types.h
@@ -88,9 +88,7 @@ typedef __uint32_t __uint_least32_t;
typedef __uint64_t __uint_least64_t;
typedef __uint64_t __u_register_t;
typedef __uint64_t __vm_offset_t;
-typedef __int64_t __vm_ooffset_t;
typedef __uint64_t __vm_paddr_t;
-typedef __uint64_t __vm_pindex_t;
typedef __uint64_t __vm_size_t;
typedef int ___wchar_t;
diff --git a/sys/rpc/svc.c b/sys/rpc/svc.c
index ea0024b..5e5552d 100644
--- a/sys/rpc/svc.c
+++ b/sys/rpc/svc.c
@@ -75,6 +75,7 @@ static void svc_new_thread(SVCGROUP *grp);
static void xprt_unregister_locked(SVCXPRT *xprt);
static void svc_change_space_used(SVCPOOL *pool, long delta);
static bool_t svc_request_space_available(SVCPOOL *pool);
+static void svcpool_cleanup(SVCPOOL *pool);
/* *************** SVCXPRT related stuff **************** */
@@ -174,8 +175,12 @@ svcpool_create(const char *name, struct sysctl_oid_list *sysctl_base)
return pool;
}
-void
-svcpool_destroy(SVCPOOL *pool)
+/*
+ * Code common to svcpool_destroy() and svcpool_close(), which cleans up
+ * the pool data structures.
+ */
+static void
+svcpool_cleanup(SVCPOOL *pool)
{
SVCGROUP *grp;
SVCXPRT *xprt, *nxprt;
@@ -211,6 +216,15 @@ svcpool_destroy(SVCPOOL *pool)
mtx_lock(&pool->sp_lock);
}
mtx_unlock(&pool->sp_lock);
+}
+
+void
+svcpool_destroy(SVCPOOL *pool)
+{
+ SVCGROUP *grp;
+ int g;
+
+ svcpool_cleanup(pool);
for (g = 0; g < SVC_MAXGROUPS; g++) {
grp = &pool->sp_groups[g];
@@ -226,6 +240,30 @@ svcpool_destroy(SVCPOOL *pool)
}
/*
+ * Similar to svcpool_destroy(), except that it does not destroy the actual
+ * data structures. As such, "pool" may be used again.
+ */
+void
+svcpool_close(SVCPOOL *pool)
+{
+ SVCGROUP *grp;
+ int g;
+
+ svcpool_cleanup(pool);
+
+ /* Now, initialize the pool's state for a fresh svc_run() call. */
+ mtx_lock(&pool->sp_lock);
+ pool->sp_state = SVCPOOL_INIT;
+ mtx_unlock(&pool->sp_lock);
+ for (g = 0; g < SVC_MAXGROUPS; g++) {
+ grp = &pool->sp_groups[g];
+ mtx_lock(&grp->sg_lock);
+ grp->sg_state = SVCPOOL_ACTIVE;
+ mtx_unlock(&grp->sg_lock);
+ }
+}
+
+/*
* Sysctl handler to get the present thread count on a pool
*/
static int
diff --git a/sys/rpc/svc.h b/sys/rpc/svc.h
index 22322ba..dacf5d1 100644
--- a/sys/rpc/svc.h
+++ b/sys/rpc/svc.h
@@ -729,6 +729,12 @@ extern SVCPOOL* svcpool_create(const char *name,
extern void svcpool_destroy(SVCPOOL *pool);
/*
+ * Close a service pool. Similar to svcpool_destroy(), but it does not
+ * free the data structures. As such, the pool can be used again.
+ */
+extern void svcpool_close(SVCPOOL *pool);
+
+/*
* Transport independent svc_create routine.
*/
extern int svc_create(SVCPOOL *, void (*)(struct svc_req *, SVCXPRT *),
diff --git a/sys/sparc64/include/_types.h b/sys/sparc64/include/_types.h
index 62e2fe9..70b85d9 100644
--- a/sys/sparc64/include/_types.h
+++ b/sys/sparc64/include/_types.h
@@ -88,9 +88,7 @@ typedef __uint32_t __uint_least32_t;
typedef __uint64_t __uint_least64_t;
typedef __uint64_t __u_register_t;
typedef __uint64_t __vm_offset_t;
-typedef __int64_t __vm_ooffset_t;
typedef __uint64_t __vm_paddr_t;
-typedef __uint64_t __vm_pindex_t;
typedef __uint64_t __vm_size_t;
typedef int ___wchar_t;
diff --git a/sys/sys/elf_generic.h b/sys/sys/elf_generic.h
index 95a682f..5ff5242 100644
--- a/sys/sys/elf_generic.h
+++ b/sys/sys/elf_generic.h
@@ -84,5 +84,6 @@ __ElfType(Ssize);
#define ELF_ST_BIND __ELFN(ST_BIND)
#define ELF_ST_TYPE __ELFN(ST_TYPE)
#define ELF_ST_INFO __ELFN(ST_INFO)
+#define ELF_ST_VISIBILITY __ELFN(ST_VISIBILITY)
#endif /* !_SYS_ELF_GENERIC_H_ */
diff --git a/sys/sys/socket.h b/sys/sys/socket.h
index f23b5f6..d6459b1 100644
--- a/sys/sys/socket.h
+++ b/sys/sys/socket.h
@@ -435,6 +435,7 @@ struct msghdr {
#endif
#ifdef _KERNEL
#define MSG_SOCALLBCK 0x10000 /* for use by socket callbacks - soreceive (TCP) */
+#define MSG_MORETOCOME 0x100000 /* additional data pending */
#endif
/*
diff --git a/sys/sys/syscallsubr.h b/sys/sys/syscallsubr.h
index eff7aca..2af3f7b 100644
--- a/sys/sys/syscallsubr.h
+++ b/sys/sys/syscallsubr.h
@@ -145,8 +145,8 @@ int kern_mkfifoat(struct thread *td, int fd, char *path,
int kern_mknodat(struct thread *td, int fd, char *path,
enum uio_seg pathseg, int mode, int dev);
int kern_msgctl(struct thread *, int, int, struct msqid_ds *);
-int kern_msgsnd(struct thread *, int, const void *, size_t, int, long);
int kern_msgrcv(struct thread *, int, void *, size_t, long, int, long *);
+int kern_msgsnd(struct thread *, int, const void *, size_t, int, long);
int kern_nanosleep(struct thread *td, struct timespec *rqt,
struct timespec *rmt);
int kern_ogetdirentries(struct thread *td, struct ogetdirentries_args *uap,
diff --git a/sys/sys/types.h b/sys/sys/types.h
index 6e2c012..4945e81 100644
--- a/sys/sys/types.h
+++ b/sys/sys/types.h
@@ -250,9 +250,9 @@ typedef struct cap_rights cap_rights_t;
#endif
typedef __vm_offset_t vm_offset_t;
-typedef __vm_ooffset_t vm_ooffset_t;
+typedef __int64_t vm_ooffset_t;
typedef __vm_paddr_t vm_paddr_t;
-typedef __vm_pindex_t vm_pindex_t;
+typedef __uint64_t vm_pindex_t;
typedef __vm_size_t vm_size_t;
typedef __rman_res_t rman_res_t;
diff --git a/sys/vm/vm_mmap.c b/sys/vm/vm_mmap.c
index ca48df8..b33f064 100644
--- a/sys/vm/vm_mmap.c
+++ b/sys/vm/vm_mmap.c
@@ -106,14 +106,8 @@ struct sbrk_args {
};
#endif
-/*
- * MPSAFE
- */
-/* ARGSUSED */
int
-sys_sbrk(td, uap)
- struct thread *td;
- struct sbrk_args *uap;
+sys_sbrk(struct thread *td, struct sbrk_args *uap)
{
/* Not yet implemented */
return (EOPNOTSUPP);
@@ -125,14 +119,8 @@ struct sstk_args {
};
#endif
-/*
- * MPSAFE
- */
-/* ARGSUSED */
int
-sys_sstk(td, uap)
- struct thread *td;
- struct sstk_args *uap;
+sys_sstk(struct thread *td, struct sstk_args *uap)
{
/* Not yet implemented */
return (EOPNOTSUPP);
@@ -146,11 +134,9 @@ struct getpagesize_args {
#endif
int
-ogetpagesize(td, uap)
- struct thread *td;
- struct getpagesize_args *uap;
+ogetpagesize(struct thread *td, struct getpagesize_args *uap)
{
- /* MP SAFE */
+
td->td_retval[0] = PAGE_SIZE;
return (0);
}
@@ -182,9 +168,6 @@ struct mmap_args {
};
#endif
-/*
- * MPSAFE
- */
int
sys_mmap(td, uap)
struct thread *td;
@@ -458,9 +441,6 @@ struct msync_args {
int flags;
};
#endif
-/*
- * MPSAFE
- */
int
sys_msync(td, uap)
struct thread *td;
@@ -513,9 +493,6 @@ struct munmap_args {
size_t len;
};
#endif
-/*
- * MPSAFE
- */
int
sys_munmap(td, uap)
struct thread *td;
@@ -589,9 +566,6 @@ struct mprotect_args {
int prot;
};
#endif
-/*
- * MPSAFE
- */
int
sys_mprotect(td, uap)
struct thread *td;
@@ -631,13 +605,8 @@ struct minherit_args {
int inherit;
};
#endif
-/*
- * MPSAFE
- */
int
-sys_minherit(td, uap)
- struct thread *td;
- struct minherit_args *uap;
+sys_minherit(struct thread *td, struct minherit_args *uap)
{
vm_offset_t addr;
vm_size_t size, pageoff;
@@ -672,13 +641,8 @@ struct madvise_args {
};
#endif
-/*
- * MPSAFE
- */
int
-sys_madvise(td, uap)
- struct thread *td;
- struct madvise_args *uap;
+sys_madvise(struct thread *td, struct madvise_args *uap)
{
vm_offset_t start, end;
vm_map_t map;
@@ -730,13 +694,8 @@ struct mincore_args {
};
#endif
-/*
- * MPSAFE
- */
int
-sys_mincore(td, uap)
- struct thread *td;
- struct mincore_args *uap;
+sys_mincore(struct thread *td, struct mincore_args *uap)
{
vm_offset_t addr, first_addr;
vm_offset_t end, cend;
@@ -989,13 +948,8 @@ struct mlock_args {
size_t len;
};
#endif
-/*
- * MPSAFE
- */
int
-sys_mlock(td, uap)
- struct thread *td;
- struct mlock_args *uap;
+sys_mlock(struct thread *td, struct mlock_args *uap)
{
return (vm_mlock(td->td_proc, td->td_ucred, uap->addr, uap->len));
@@ -1061,13 +1015,8 @@ struct mlockall_args {
};
#endif
-/*
- * MPSAFE
- */
int
-sys_mlockall(td, uap)
- struct thread *td;
- struct mlockall_args *uap;
+sys_mlockall(struct thread *td, struct mlockall_args *uap)
{
vm_map_t map;
int error;
@@ -1138,13 +1087,8 @@ struct munlockall_args {
};
#endif
-/*
- * MPSAFE
- */
int
-sys_munlockall(td, uap)
- struct thread *td;
- struct munlockall_args *uap;
+sys_munlockall(struct thread *td, struct munlockall_args *uap)
{
vm_map_t map;
int error;
@@ -1179,9 +1123,6 @@ struct munlock_args {
size_t len;
};
#endif
-/*
- * MPSAFE
- */
int
sys_munlock(td, uap)
struct thread *td;
@@ -1332,8 +1273,6 @@ done:
/*
* vm_mmap_cdev()
*
- * MPSAFE
- *
* Helper function for vm_mmap. Perform sanity check specific for mmap
* operations on cdevs.
*/
diff --git a/sys/x86/include/_types.h b/sys/x86/include/_types.h
index e6d1f60..8aa0e2b 100644
--- a/sys/x86/include/_types.h
+++ b/sys/x86/include/_types.h
@@ -142,8 +142,6 @@ typedef __uint32_t __vm_paddr_t;
#endif
typedef __uint32_t __vm_size_t;
#endif
-typedef __int64_t __vm_ooffset_t;
-typedef __uint64_t __vm_pindex_t;
typedef int ___wchar_t;
#define __WCHAR_MIN __INT_MIN /* min value for a wchar_t */
diff --git a/tests/sys/geom/class/gate/1_test.sh b/tests/sys/geom/class/gate/1_test.sh
deleted file mode 100644
index ba573bb..0000000
--- a/tests/sys/geom/class/gate/1_test.sh
+++ /dev/null
@@ -1,63 +0,0 @@
-#!/bin/sh
-# $FreeBSD$
-
-. `dirname $0`/conf.sh
-
-echo '1..2'
-
-base=`basename $0`
-us=0
-while [ -c /dev/ggate${us} ]; do
- : $(( us += 1 ))
-done
-pidfile=ggated.$$.pid
-conf=`mktemp $base.XXXXXX` || exit 1
-port=33080
-
-work=$(attach_md -t malloc -s 1M)
-src=$(attach_md -t malloc -s 1M)
-
-test_cleanup()
-{
- ggatec destroy -f -u $us
- pkill -F $pidfile
- geom_test_cleanup
-}
-trap test_cleanup ABRT EXIT INT TERM
-
-dd if=/dev/random of=/dev/$work bs=1m count=1 conv=sync
-dd if=/dev/random of=/dev/$src bs=1m count=1 conv=sync
-src_checksum=$(md5 -q /dev/$src)
-
-echo "127.0.0.1 RW /dev/$work" > $conf
-
-if ! ggated -p $port -F $pidfile $conf; then
- echo 'ggated failed to start'
- echo 'Bail out!'
- exit 1
-fi
-sleep 1
-if ! ggatec create -p $port -u $us 127.0.0.1 /dev/$work; then
- echo 'ggatec create failed'
- echo 'Bail out!'
- exit 1
-fi
-sleep 1
-
-dd if=/dev/${src} of=/dev/ggate${us} bs=1m count=1
-sleep 1
-
-work_checksum=$(md5 -q /dev/$work)
-if [ "$work_checksum" != "$src_checksum" ]; then
- echo "not ok 1 - md5 checksums didn't match ($work_checksum != $src_checksum)"
- echo "not ok 2 # SKIP"
-else
- echo 'ok 1 - md5 checksum'
-
- ggate_checksum=$(md5 -q /dev/ggate${us})
- if [ "$ggate_checksum" != "$src_checksum" ]; then
- echo "not ok 2 - md5 checksums didn't match ($ggate_checksum != $src_checksum)"
- else
- echo 'ok 2 - md5 checksum'
- fi
-fi
diff --git a/tests/sys/geom/class/gate/2_test.sh b/tests/sys/geom/class/gate/2_test.sh
deleted file mode 100644
index be89acc..0000000
--- a/tests/sys/geom/class/gate/2_test.sh
+++ /dev/null
@@ -1,48 +0,0 @@
-#!/bin/sh
-# $FreeBSD$
-
-. `dirname $0`/conf.sh
-
-base=`basename $0`
-us=46
-work=`mktemp -u $base.XXXXXX` || exit 1
-src=`mktemp -u $base.XXXXXX` || exit 1
-
-test_cleanup()
-{
- ggatel destroy -f -u $us
- rm -f $work $src
-
- geom_test_cleanup
-}
-trap test_cleanup ABRT EXIT INT TERM
-
-dd if=/dev/random of=$work bs=1m count=1 conv=sync
-dd if=/dev/random of=$src bs=1m count=1 conv=sync
-
-if ! ggatel create -u $us $work; then
- echo 'ggatel create failed'
- echo 'Bail out!'
- exit 1
-fi
-
-dd if=${src} of=/dev/ggate${us} bs=1m count=1
-sleep 1
-
-echo '1..2'
-
-src_checksum=$(md5 -q $src)
-work_checksum=$(md5 -q $work)
-if [ "$work_checksum" != "$src_checksum" ]; then
- echo "not ok 1 - md5 checksums didn't match ($work_checksum != $src_checksum) # TODO: bug 204616"
- echo 'not ok 2 # SKIP'
-else
- echo 'ok 1 - md5 checksum'
-
- ggate_checksum=$(md5 -q /dev/ggate${us})
- if [ "$ggate_checksum" != "$src_checksum" ]; then
- echo "not ok 2 - md5 checksums didn't match ($ggate_checksum != $src_checksum)"
- else
- echo 'ok 2 - md5 checksum'
- fi
-fi
diff --git a/tests/sys/geom/class/gate/3_test.sh b/tests/sys/geom/class/gate/3_test.sh
deleted file mode 100644
index 3511df7..0000000
--- a/tests/sys/geom/class/gate/3_test.sh
+++ /dev/null
@@ -1,49 +0,0 @@
-#!/bin/sh
-# $FreeBSD$
-
-. `dirname $0`/conf.sh
-
-base=`basename $0`
-us=47
-
-test_cleanup()
-{
- ggatel destroy -f -u $us
-
- geom_test_cleanup
-}
-trap test_cleanup ABRT EXIT INT TERM
-
-work=$(attach_md -t malloc -s 1M)
-src=$(attach_md -t malloc -s 1M)
-
-dd if=/dev/random of=/dev/$work bs=1m count=1 conv=sync
-dd if=/dev/random of=/dev/$src bs=1m count=1 conv=sync
-src_checksum=$(md5 -q /dev/$src)
-
-if ! ggatel create -u $us /dev/$work; then
- echo 'ggatel create failed'
- echo 'Bail out!'
- exit 1
-fi
-
-sleep 1
-dd if=/dev/${src} of=/dev/ggate${us} bs=1m count=1 conv=sync
-sleep 1
-
-echo '1..2'
-
-work_checksum=$(md5 -q /dev/$work)
-if [ "$work_checksum" != "$src_checksum" ]; then
- echo "not ok 1 - md5 checksums didn't match ($work_checksum != $src_checksum)"
- echo 'not ok 2 # SKIP'
-else
- echo 'ok 1 - md5 checksum'
-
- ggate_checksum=$(md5 -q /dev/ggate${us})
- if [ "$ggate_checksum" != "$src_checksum" ]; then
- echo "not ok 2 - md5 checksums didn't match ($ggate_checksum != $src_checksum)"
- else
- echo 'ok 2 - md5 checksum'
- fi
-fi
diff --git a/tests/sys/geom/class/gate/Makefile b/tests/sys/geom/class/gate/Makefile
index c034bf0..417fa7d 100644
--- a/tests/sys/geom/class/gate/Makefile
+++ b/tests/sys/geom/class/gate/Makefile
@@ -4,14 +4,6 @@ PACKAGE= tests
TESTSDIR= ${TESTSBASE}/sys/geom/class/${.CURDIR:T}
-TAP_TESTS_SH+= 1_test
-TAP_TESTS_SH+= 2_test
-TAP_TESTS_SH+= 3_test
-
-${PACKAGE}FILES+= conf.sh
-
-.for t in ${TAP_TESTS_SH}
-TEST_METADATA.$t+= required_user="root"
-.endfor
+ATF_TESTS_SH+= ggate_test
.include <bsd.test.mk>
diff --git a/tests/sys/geom/class/gate/conf.sh b/tests/sys/geom/class/gate/conf.sh
deleted file mode 100755
index 7e22ce4..0000000
--- a/tests/sys/geom/class/gate/conf.sh
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/sh
-# $FreeBSD$
-
-name="$(mktemp -u gate.XXXXXX)"
-class="gate"
-base=`basename $0`
-
-. `dirname $0`/../geom_subr.sh
diff --git a/tests/sys/geom/class/gate/ggate_test.sh b/tests/sys/geom/class/gate/ggate_test.sh
new file mode 100755
index 0000000..162744d
--- /dev/null
+++ b/tests/sys/geom/class/gate/ggate_test.sh
@@ -0,0 +1,207 @@
+# $FreeBSD$
+
+PIDFILE=ggated.pid
+PLAINFILES=plainfiles
+PORT=33080
+CONF=gg.exports
+
+atf_test_case ggated cleanup
+ggated_head()
+{
+ atf_set "descr" "ggated can proxy geoms"
+ atf_set "require.progs" "ggatec ggated"
+ atf_set "require.user" "root"
+ atf_set "timeout" 60
+}
+
+ggated_body()
+{
+ us=$(alloc_ggate_dev)
+ work=$(alloc_md)
+ src=$(alloc_md)
+
+ atf_check -e ignore -o ignore \
+ dd if=/dev/random of=/dev/$work bs=1m count=1 conv=notrunc
+ atf_check -e ignore -o ignore \
+ dd if=/dev/random of=/dev/$src bs=1m count=1 conv=notrunc
+
+ echo $CONF >> $PLAINFILES
+ echo "127.0.0.1 RW /dev/$work" > $CONF
+
+ atf_check ggated -p $PORT -F $PIDFILE $CONF
+ atf_check ggatec create -p $PORT -u $us 127.0.0.1 /dev/$work
+
+ ggate_dev=/dev/ggate${us}
+
+ wait_for_ggate_device ${ggate_dev}
+
+ atf_check -e ignore -o ignore \
+ dd if=/dev/${src} of=${ggate_dev} bs=1m count=1 conv=notrunc
+
+ checksum /dev/$src /dev/$work
+}
+
+ggated_cleanup()
+{
+ common_cleanup
+}
+
+atf_test_case ggatel_file cleanup
+ggatel_file_head()
+{
+ atf_set "descr" "ggatel can proxy files"
+ atf_set "require.progs" "ggatel"
+ atf_set "require.user" "root"
+ atf_set "timeout" 15
+}
+
+ggatel_file_body()
+{
+ us=$(alloc_ggate_dev)
+
+ echo src work >> ${PLAINFILES}
+ dd if=/dev/random of=work bs=1m count=1
+ dd if=/dev/random of=src bs=1m count=1
+
+ atf_check ggatel create -u $us work
+
+ ggate_dev=/dev/ggate${us}
+
+ wait_for_ggate_device ${ggate_dev}
+
+ atf_check -e ignore -o ignore \
+ dd if=src of=${ggate_dev} bs=1m count=1 conv=notrunc
+
+ checksum src work
+}
+
+ggatel_file_cleanup()
+{
+ common_cleanup
+}
+
+atf_test_case ggatel_md cleanup
+ggatel_md_head()
+{
+ atf_set "descr" "ggatel can proxy files"
+ atf_set "require.progs" "ggatel"
+ atf_set "require.user" "root"
+ atf_set "timeout" 15
+}
+
+ggatel_md_body()
+{
+ us=$(alloc_ggate_dev)
+ work=$(alloc_md)
+ src=$(alloc_md)
+
+ atf_check -e ignore -o ignore \
+ dd if=/dev/random of=$work bs=1m count=1 conv=notrunc
+ atf_check -e ignore -o ignore \
+ dd if=/dev/random of=$src bs=1m count=1 conv=notrunc
+
+ atf_check ggatel create -u $us /dev/$work
+
+ ggate_dev=/dev/ggate${us}
+
+ wait_for_ggate_device ${ggate_dev}
+
+ atf_check -e ignore -o ignore \
+ dd if=/dev/$src of=${ggate_dev} bs=1m count=1 conv=notrunc
+
+ checksum /dev/$src /dev/$work
+}
+
+ggatel_md_cleanup()
+{
+ common_cleanup
+}
+
+atf_init_test_cases()
+{
+ atf_add_test_case ggated
+ atf_add_test_case ggatel_file
+ atf_add_test_case ggatel_md
+}
+
+alloc_ggate_dev()
+{
+ local us
+
+ us=0
+ while [ -c /dev/ggate${us} ]; do
+ : $(( us += 1 ))
+ done
+ echo ${us} > ggate.devs
+ echo ${us}
+}
+
+alloc_md()
+{
+ local md
+
+ md=$(mdconfig -a -t malloc -s 1M) || \
+ atf_fail "failed to allocate md device"
+ echo ${md} >> md.devs
+ echo ${md}
+}
+
+checksum()
+{
+ local src work
+ src=$1
+ work=$2
+
+ src_checksum=$(md5 -q $src)
+ work_checksum=$(md5 -q $work)
+
+ if [ "$work_checksum" != "$src_checksum" ]; then
+ atf_fail "work md5 checksum didn't match"
+ fi
+
+ ggate_checksum=$(md5 -q /dev/ggate${us})
+ if [ "$ggate_checksum" != "$src_checksum" ]; then
+ atf_fail "ggate md5 checksum didn't match"
+ fi
+}
+
+common_cleanup()
+{
+ if [ -f "ggate.devs" ]; then
+ while read test_ggate; do
+ ggatec destroy -f -u $test_ggate >/dev/null
+ done < ggate.devs
+ rm ggate.devs
+ fi
+
+ if [ -f "$PIDFILE" ]; then
+ pkill -F "$PIDFILE"
+ rm $PIDFILE
+ fi
+
+ if [ -f "PLAINFILES" ]; then
+ while read f; do
+ rm -f ${f}
+ done < ${PLAINFILES}
+ rm ${PLAINFILES}
+ fi
+
+ if [ -f "md.devs" ]; then
+ while read test_md; do
+ mdconfig -d -u $test_md 2>/dev/null
+ done < md.devs
+ rm md.devs
+ fi
+ true
+}
+
+# Bug 204616: ggatel(8) creates /dev/ggate* asynchronously if `ggatel create`
+# isn't called with `-v`.
+wait_for_ggate_device()
+{
+ ggate_device=$1
+
+ while [ ! -c $ggate_device ]; do
+ sleep 0.5
+ done
+}
diff --git a/usr.bin/atm/sscop/Makefile b/usr.bin/atm/sscop/Makefile
index cc688fd..4919867 100644
--- a/usr.bin/atm/sscop/Makefile
+++ b/usr.bin/atm/sscop/Makefile
@@ -1,6 +1,6 @@
# $FreeBSD$
-CONTRIB= ${.CURDIR}/../../../contrib/ngatm/sscop
+CONTRIB= ${SRCTOP}/contrib/ngatm/sscop
.PATH: ${CONTRIB}
diff --git a/usr.bin/awk/Makefile b/usr.bin/awk/Makefile
index f6c1baa..b246713 100644
--- a/usr.bin/awk/Makefile
+++ b/usr.bin/awk/Makefile
@@ -1,6 +1,6 @@
# $FreeBSD$
-AWKSRC= ${.CURDIR}/../../contrib/one-true-awk
+AWKSRC= ${SRCTOP}/contrib/one-true-awk
.PATH: ${AWKSRC}
PROG= awk
@@ -26,6 +26,6 @@ proctab.c: maketab
${BTOOLSPATH:U.}/maketab > proctab.c
build-tools: maketab
-maketab: ytab.h ${AWKSRC}/maketab.c ${BUILD_TOOLS_META}
+maketab: ytab.h maketab.c ${BUILD_TOOLS_META}
.include <bsd.prog.mk>
diff --git a/usr.bin/bc/bc.1 b/usr.bin/bc/bc.1
index a762832..09a5075 100644
--- a/usr.bin/bc/bc.1
+++ b/usr.bin/bc/bc.1
@@ -35,7 +35,7 @@
.\"
.\" @(#)bc.1 6.8 (Berkeley) 8/8/91
.\"
-.Dd November 21 2015
+.Dd November 21, 2015
.Dt BC 1
.Os
.Sh NAME
diff --git a/usr.bin/bluetooth/Makefile.inc b/usr.bin/bluetooth/Makefile.inc
index c0e05cf..363f1e6 100644
--- a/usr.bin/bluetooth/Makefile.inc
+++ b/usr.bin/bluetooth/Makefile.inc
@@ -1,4 +1,4 @@
# $FreeBSD$
-.include "${.CURDIR}/../../Makefile.inc"
+.include "${SRCTOP}/usr.bin/Makefile.inc"
diff --git a/usr.bin/bsdcat/Makefile b/usr.bin/bsdcat/Makefile
index c689ae4..11e31e6 100644
--- a/usr.bin/bsdcat/Makefile
+++ b/usr.bin/bsdcat/Makefile
@@ -2,10 +2,10 @@
.include <src.opts.mk>
-_LIBARCHIVEDIR= ${.CURDIR}/../../contrib/libarchive
-_LIBARCHIVECONFDIR= ${.CURDIR}/../../lib/libarchive
+_LIBARCHIVEDIR= ${SRCTOP}/contrib/libarchive
+_LIBARCHIVECONFDIR= ${SRCTOP}/lib/libarchive
-PROG= bsdcat
+PROG= bsdcat
BSDCAT_VERSION_STRING= 3.2.2
.PATH: ${_LIBARCHIVEDIR}/cat
diff --git a/usr.bin/ctlstat/ctlstat.8 b/usr.bin/ctlstat/ctlstat.8
index 038b8ca..28e6d6f 100644
--- a/usr.bin/ctlstat/ctlstat.8
+++ b/usr.bin/ctlstat/ctlstat.8
@@ -1,7 +1,7 @@
-.\"
+.\"
.\" Copyright (c) 2010 Silicon Graphics International Corp.
.\" All rights reserved.
-.\"
+.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
@@ -13,7 +13,7 @@
.\" ("Disclaimer") and any redistribution must be conditioned upon
.\" including a substantially similar Disclaimer requirement for further
.\" binary redistribution.
-.\"
+.\"
.\" NO WARRANTY
.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
.\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
@@ -26,7 +26,7 @@
.\" 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 DAMAGES.
-.\"
+.\"
.\" ctlstat utility man page.
.\"
.\" Author: Ken Merry <ken@FreeBSD.org>
diff --git a/usr.bin/cut/tests/Makefile b/usr.bin/cut/tests/Makefile
index 310994e..aaf15d4 100644
--- a/usr.bin/cut/tests/Makefile
+++ b/usr.bin/cut/tests/Makefile
@@ -2,6 +2,7 @@
PACKAGE= tests
+ATF_TESTS_SH+= cut2_test
NETBSD_ATF_TESTS_SH= cut_test
${PACKAGE}FILES= d_basic.out
diff --git a/usr.bin/cut/tests/cut2_test.sh b/usr.bin/cut/tests/cut2_test.sh
new file mode 100755
index 0000000..e5aaa9a
--- /dev/null
+++ b/usr.bin/cut/tests/cut2_test.sh
@@ -0,0 +1,51 @@
+#
+# Copyright (c) 2017 Dell EMC
+# 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 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$
+
+atf_test_case s_flag
+s_flag_head()
+{
+ atf_set "descr" "Check -s flag"
+}
+
+s_flag_body()
+{
+ cat >input<<EOF
+a,b,c,d
+b,c,d
+c,d
+d
+EOF
+ atf_check -o inline:'a\nb\nc\n' cut -d, -f 1 -s < input
+ atf_check -o inline:'d\n\n\n' cut -d, -f 4 -s < input
+ atf_check -o inline:'a,b,\nb,\n\n' cut -d 'c' -f 1 -s < input
+ atf_check -o empty cut -d'!' -f 1 -s < input
+}
+
+atf_init_test_cases()
+{
+ atf_add_test_case s_flag
+}
diff --git a/usr.bin/env/env.1 b/usr.bin/env/env.1
index 101f4eb..c999dd0 100644
--- a/usr.bin/env/env.1
+++ b/usr.bin/env/env.1
@@ -133,7 +133,7 @@ is specified,
prints out the names and values
of the variables in the environment, with one name/value pair per line.
.\"
-.Ss Details of Fl S Ss (split-string) processing
+.Ss Details of Fl S \&Ss (split-string) processing
The processing of the
.Fl S
option will split the given
diff --git a/usr.bin/expand/expand.1 b/usr.bin/expand/expand.1
index 2a5cb91..c9c687b 100644
--- a/usr.bin/expand/expand.1
+++ b/usr.bin/expand/expand.1
@@ -81,7 +81,7 @@ If the
.Fl a
option is given, then tabs are inserted whenever they would compress the
resultant file by replacing two or more characters.
-.It Fl t Sm Ar tab1 , tab2 , ... , tabn Sm
+.It Fl t \&Sm Ar tab1 , tab2 , ... , tabn \&Sm
Set tab stops at column positions
.Ar tab1 , tab2 , ... , tabn .
If only a single number is given, tab stops are set that number of
diff --git a/usr.bin/ipcrm/ipcrm.1 b/usr.bin/ipcrm/ipcrm.1
index f70eab6..28bf348 100644
--- a/usr.bin/ipcrm/ipcrm.1
+++ b/usr.bin/ipcrm/ipcrm.1
@@ -114,6 +114,9 @@ If the identifier or the key is -1, it will remove all these objects.
The wiping of all System V IPC objects was first implemented in
.Fx 6.4 No and 7.1.
.Sh AUTHORS
-The original author was Adam Glass.
-The wiping of all System V IPC objects was thought up by Callum
-Gibson and extended and implemented by Edwin Groothuis.
+The original author was
+.An Adam Glass .
+The wiping of all System V IPC objects was thought up by
+.An Callum Gibson
+and extended and implemented by
+.An Edwin Groothuis .
diff --git a/usr.bin/mail/mail.1 b/usr.bin/mail/mail.1
index 3c3a23e..5f747bc 100644
--- a/usr.bin/mail/mail.1
+++ b/usr.bin/mail/mail.1
@@ -1094,7 +1094,7 @@ Default is
.Va save .
.It Va searchheaders
If this option is set, then a message-list specifier in the form
-.Dq Li / Ns Ar x Ns Li : Ns Ar y
+.Dq Li / Ns Ar x Ns : Ns Ar y
will expand to all messages containing the substring
.Ar y
in the header field
diff --git a/usr.bin/mkimg/mkimg.1 b/usr.bin/mkimg/mkimg.1
index 856818a..c63ab68 100644
--- a/usr.bin/mkimg/mkimg.1
+++ b/usr.bin/mkimg/mkimg.1
@@ -253,7 +253,7 @@ Directory to put temporary files in; default is
.Sh EXAMPLES
To create a bootable disk image that is partitioned using the GPT scheme and
containing a root file system that was previously created using
-.Xr makefs
+.Xr makefs 8
and also containing a swap partition, run the
.Nm
utility as follows:
diff --git a/usr.bin/mkuzip/mkuzip.8 b/usr.bin/mkuzip/mkuzip.8
index f47764c..ec0732a 100644
--- a/usr.bin/mkuzip/mkuzip.8
+++ b/usr.bin/mkuzip/mkuzip.8
@@ -58,7 +58,7 @@ works in two phases:
An
.Ar infile
image is split into clusters; each cluster is compressed using
-.Xr zlib 3
+.Xr zlib 3
or
.Xr lzma 3 .
.It
@@ -72,7 +72,7 @@ The options are:
Name of the output file
.Ar outfile .
The default is to use the input name with the suffix
-.Pa .uzip
+.Pa .uzip
for the
.Xr zlib 3
compression or
@@ -174,8 +174,8 @@ to handle resulting images correctly.
.Sh SEE ALSO
.Xr gzip 1 ,
.Xr xz 1 ,
-.Xr zlib 3 ,
.Xr lzma 3 ,
+.Xr zlib 3 ,
.Xr geom 4 ,
.Xr geom_uzip 4 ,
.Xr md 4 ,
diff --git a/usr.bin/mt/mt.1 b/usr.bin/mt/mt.1
index 7af3d2b..e056485 100644
--- a/usr.bin/mt/mt.1
+++ b/usr.bin/mt/mt.1
@@ -273,12 +273,12 @@ status command, this will be the same XML output via
.Do
.Nm
status
-.Fl x
+.Fl x
.Dc
.El
.It Cm param
Display or set parameters.
-One of
+One of
.Fl l ,
.Fl s ,
or
@@ -293,7 +293,7 @@ To display a specific parameter, specify the parameter with
.It Fl p Ar name
Specify the parameter name to list (with
.Fl l )
-or set (with
+or set (with
.Fl s ) .
.It Fl q
Enable quiet mode for parameter listing.
@@ -361,11 +361,11 @@ The drive will verify the checksum before writing the block to tape.
.El
.It Cm locate
Set the tape drive's logical position.
-One of
+One of
.Fl b ,
.Fl e ,
.Fl f ,
-or
+or
.Fl s
must be specified to indicate the type of position.
If the partition number is specified, the drive will first relocate to the
diff --git a/usr.bin/perror/perror.1 b/usr.bin/perror/perror.1
index 6fa1664..8d9c5bd 100644
--- a/usr.bin/perror/perror.1
+++ b/usr.bin/perror/perror.1
@@ -1,8 +1,8 @@
-.\"
+.\"
.\" Copyright (c) 2009 Hudson River Trading LLC
.\" Written by: George V. Neville-Neil <gnn@FreeBSD.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:
@@ -11,7 +11,7 @@
.\" 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
@@ -23,7 +23,7 @@
.\" 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$
.\"
.Dd May 12, 2009
diff --git a/usr.bin/revoke/revoke.1 b/usr.bin/revoke/revoke.1
index 2ab52c3..822d13b 100644
--- a/usr.bin/revoke/revoke.1
+++ b/usr.bin/revoke/revoke.1
@@ -1,6 +1,6 @@
.\" Copyright (c) 2009 Ed Schouten <ed@FreeBSD.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:
@@ -9,7 +9,7 @@
.\" 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
@@ -21,7 +21,7 @@
.\" 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$
.\"
.Dd June 15, 2009
@@ -53,4 +53,4 @@ The
program first appeared in
.Fx 8.0 .
.Sh AUTHORS
-.An Ed Schouten Aq Mt ed@FreeBSD.org
+.An \&Ed Schouten Aq Mt ed@FreeBSD.org
diff --git a/usr.bin/sdiff/sdiff.1 b/usr.bin/sdiff/sdiff.1
index 16e340a..ef1e128 100644
--- a/usr.bin/sdiff/sdiff.1
+++ b/usr.bin/sdiff/sdiff.1
@@ -167,8 +167,6 @@ The default is
was written from scratch for the public domain by
.An Ray Lai Aq ray@cyth.net .
.Sh CAVEATS
-.Pp
Tabs are treated as anywhere from one to eight characters wide,
depending on the current column.
Terminals that treat tabs as eight characters wide will look best.
-
diff --git a/usr.bin/sed/tests/Makefile b/usr.bin/sed/tests/Makefile
index 0d017e1..c157af8 100644
--- a/usr.bin/sed/tests/Makefile
+++ b/usr.bin/sed/tests/Makefile
@@ -2,11 +2,15 @@
PACKAGE= tests
+NETBSD_ATF_TESTS_SH+= sed_test
TAP_TESTS_SH= legacy_test
TAP_TESTS_SH+= multi_test
TEST_METADATA.multi_test+= required_files="/usr/share/dict/words"
TAP_TESTS_SH+= inplace_race_test
+ATF_TESTS_SH_SED_sed_test+= -e 's,atf_expect_fail "PR bin/28126",,g'
+${PACKAGE}FILES+= d_c2048.in
+
${PACKAGE}FILES+= hanoi.sed
${PACKAGE}FILES+= math.sed
${PACKAGE}FILES+= regress.G.out
@@ -35,4 +39,5 @@ ${PACKAGE}FILES+= regress.y.out
SUBDIR= regress.multitest.out
+.include <netbsd-tests.test.mk>
.include <bsd.test.mk>
diff --git a/usr.bin/svn/Makefile.inc b/usr.bin/svn/Makefile.inc
index 7404de4..2650c4f 100644
--- a/usr.bin/svn/Makefile.inc
+++ b/usr.bin/svn/Makefile.inc
@@ -12,33 +12,31 @@ PACKAGE= svn
.if !defined(SVNDIR)
-SVNDIR= ${.CURDIR}/../../../contrib/subversion/subversion
-APRU= ${.CURDIR}/../../../contrib/apr-util
-APR= ${.CURDIR}/../../../contrib/apr
+SVNDIR= ${SRCTOP}/contrib/subversion/subversion
+APRU= ${SRCTOP}/contrib/apr-util
+APR= ${SRCTOP}/contrib/apr
WARNS?= 0 # definitely not warns friendly
-.if exists(${.CURDIR}/../../Makefile.inc)
-.include "${.CURDIR}/../../Makefile.inc"
-.endif
-
-LIBAPRDIR= ${.OBJDIR}/../lib/libapr
-LIBAPR_UTILDIR= ${.OBJDIR}/../lib/libapr_util
-LIBSERFDIR= ${.OBJDIR}/../lib/libserf
-
-LIBSVN_CLIENTDIR= ${.OBJDIR}/../lib/libsvn_client
-LIBSVN_DELTADIR= ${.OBJDIR}/../lib/libsvn_delta
-LIBSVN_DIFFDIR= ${.OBJDIR}/../lib/libsvn_diff
-LIBSVN_FSDIR= ${.OBJDIR}/../lib/libsvn_fs
-LIBSVN_FS_FSDIR= ${.OBJDIR}/../lib/libsvn_fs_fs
-LIBSVN_FS_UTILDIR= ${.OBJDIR}/../lib/libsvn_fs_util
-LIBSVN_FS_XDIR= ${.OBJDIR}/../lib/libsvn_fs_x
-LIBSVN_RADIR= ${.OBJDIR}/../lib/libsvn_ra
-LIBSVN_RA_LOCALDIR= ${.OBJDIR}/../lib/libsvn_ra_local
-LIBSVN_RA_SVNDIR= ${.OBJDIR}/../lib/libsvn_ra_svn
-LIBSVN_RA_SERFDIR= ${.OBJDIR}/../lib/libsvn_ra_serf
-LIBSVN_REPOSDIR= ${.OBJDIR}/../lib/libsvn_repos
-LIBSVN_SUBRDIR= ${.OBJDIR}/../lib/libsvn_subr
-LIBSVN_WCDIR= ${.OBJDIR}/../lib/libsvn_wc
+.sinclude "${.CURDIR:H:H}/Makefile.inc"
+
+LIBAPRDIR= ${.OBJDIR:H}/lib/libapr
+LIBAPR_UTILDIR= ${.OBJDIR:H}/lib/libapr_util
+LIBSERFDIR= ${.OBJDIR:H}/lib/libserf
+
+LIBSVN_CLIENTDIR= ${.OBJDIR:H}/lib/libsvn_client
+LIBSVN_DELTADIR= ${.OBJDIR:H}/lib/libsvn_delta
+LIBSVN_DIFFDIR= ${.OBJDIR:H}/lib/libsvn_diff
+LIBSVN_FSDIR= ${.OBJDIR:H}/lib/libsvn_fs
+LIBSVN_FS_FSDIR= ${.OBJDIR:H}/lib/libsvn_fs_fs
+LIBSVN_FS_UTILDIR= ${.OBJDIR:H}/lib/libsvn_fs_util
+LIBSVN_FS_XDIR= ${.OBJDIR:H}/lib/libsvn_fs_x
+LIBSVN_RADIR= ${.OBJDIR:H}/lib/libsvn_ra
+LIBSVN_RA_LOCALDIR= ${.OBJDIR:H}/lib/libsvn_ra_local
+LIBSVN_RA_SVNDIR= ${.OBJDIR:H}/lib/libsvn_ra_svn
+LIBSVN_RA_SERFDIR= ${.OBJDIR:H}/lib/libsvn_ra_serf
+LIBSVN_REPOSDIR= ${.OBJDIR:H}/lib/libsvn_repos
+LIBSVN_SUBRDIR= ${.OBJDIR:H}/lib/libsvn_subr
+LIBSVN_WCDIR= ${.OBJDIR:H}/lib/libsvn_wc
LIBAPR= ${LIBAPRDIR}/libapr.a
LIBAPR_UTIL= ${LIBAPR_UTILDIR}/libapr-util.a
diff --git a/usr.bin/svn/svn/Makefile b/usr.bin/svn/svn/Makefile
index 87d9df1..9591914 100644
--- a/usr.bin/svn/svn/Makefile
+++ b/usr.bin/svn/svn/Makefile
@@ -1,6 +1,6 @@
# $FreeBSD$
-.include "${.CURDIR}/../Makefile.inc"
+.include "${.CURDIR:H}/Makefile.inc"
.PATH: ${SVNDIR}/svn
@@ -17,11 +17,11 @@ SRCS= add-cmd.c auth-cmd.c blame-cmd.c cat-cmd.c changelist-cmd.c \
resolved-cmd.c revert-cmd.c status-cmd.c similarity.c status.c \
svn.c switch-cmd.c unlock-cmd.c update-cmd.c upgrade-cmd.c util.c
-CFLAGS+=-I${SVNDIR}/include -I${SVNDIR} -I${.CURDIR}/.. \
- -I${.CURDIR}/../lib/libapr \
+CFLAGS+=-I${SVNDIR}/include -I${SVNDIR} -I${.CURDIR:H} \
+ -I${.CURDIR:H}/lib/libapr \
-I${APR}/include/arch/unix \
-I${APR}/include \
- -I${.CURDIR}/../lib/libapr_util \
+ -I${.CURDIR:H}/lib/libapr_util \
-I${APRU}/include/private \
-I${APRU}/include
diff --git a/usr.bin/svn/svnadmin/Makefile b/usr.bin/svn/svnadmin/Makefile
index 9cda0f0..eab3b2c 100644
--- a/usr.bin/svn/svnadmin/Makefile
+++ b/usr.bin/svn/svnadmin/Makefile
@@ -2,7 +2,7 @@
MAN=
-.include "${.CURDIR}/../Makefile.inc"
+.include "${.CURDIR:H}/Makefile.inc"
.PATH: ${SVNDIR}/svnadmin
@@ -10,11 +10,11 @@ PROG= svn${SVNLITE}admin
SRCS= svnadmin.c
-CFLAGS+=-I${SVNDIR}/include -I${SVNDIR} -I${.CURDIR}/.. \
- -I${.CURDIR}/../lib/libapr \
+CFLAGS+=-I${SVNDIR}/include -I${SVNDIR} -I${.CURDIR:H} \
+ -I${.CURDIR:H}/lib/libapr \
-I${APR}/include/arch/unix \
-I${APR}/include \
- -I${.CURDIR}/../lib/libapr_util \
+ -I${.CURDIR:H}/lib/libapr_util \
-I${APRU}/include/private \
-I${APRU}/include
diff --git a/usr.bin/svn/svnbench/Makefile b/usr.bin/svn/svnbench/Makefile
index 8f54baf..8fe07d7 100644
--- a/usr.bin/svn/svnbench/Makefile
+++ b/usr.bin/svn/svnbench/Makefile
@@ -2,7 +2,7 @@
MAN=
-.include "${.CURDIR}/../Makefile.inc"
+.include "${.CURDIR:H}/Makefile.inc"
.PATH: ${SVNDIR}/svnbench
@@ -11,11 +11,11 @@ PROG= svn${SVNLITE}bench
SRCS= help-cmd.c notify.c null-blame-cmd.c null-export-cmd.c \
null-info-cmd.c null-list-cmd.c null-log-cmd.c svnbench.c util.c
-CFLAGS+=-I${SVNDIR}/include -I${SVNDIR} -I${.CURDIR}/.. \
- -I${.CURDIR}/../lib/libapr \
+CFLAGS+=-I${SVNDIR}/include -I${SVNDIR} -I${.CURDIR:H} \
+ -I${.CURDIR:H}/lib/libapr \
-I${APR}/include/arch/unix \
-I${APR}/include \
- -I${.CURDIR}/../lib/libapr_util \
+ -I${.CURDIR:H}/lib/libapr_util \
-I${APRU}/include/private \
-I${APRU}/include
diff --git a/usr.bin/svn/svndumpfilter/Makefile b/usr.bin/svn/svndumpfilter/Makefile
index 09bb541..ccb54eb 100644
--- a/usr.bin/svn/svndumpfilter/Makefile
+++ b/usr.bin/svn/svndumpfilter/Makefile
@@ -2,7 +2,7 @@
MAN=
-.include "${.CURDIR}/../Makefile.inc"
+.include "${.CURDIR:H}/Makefile.inc"
.PATH: ${SVNDIR}/svndumpfilter
@@ -10,11 +10,11 @@ PROG= svn${SVNLITE}dumpfilter
SRCS= svndumpfilter.c
-CFLAGS+=-I${SVNDIR}/include -I${SVNDIR} -I${.CURDIR}/.. \
- -I${.CURDIR}/../lib/libapr \
+CFLAGS+=-I${SVNDIR}/include -I${SVNDIR} -I${.CURDIR:H} \
+ -I${.CURDIR:H}/lib/libapr \
-I${APR}/include/arch/unix \
-I${APR}/include \
- -I${.CURDIR}/../lib/libapr_util \
+ -I${.CURDIR:H}/lib/libapr_util \
-I${APRU}/include/private \
-I${APRU}/include
diff --git a/usr.bin/svn/svnfsfs/Makefile b/usr.bin/svn/svnfsfs/Makefile
index 67be638..2a465b6 100644
--- a/usr.bin/svn/svnfsfs/Makefile
+++ b/usr.bin/svn/svnfsfs/Makefile
@@ -2,7 +2,7 @@
MAN=
-.include "${.CURDIR}/../Makefile.inc"
+.include "${.CURDIR:H}/Makefile.inc"
.PATH: ${SVNDIR}/svnfsfs
@@ -10,11 +10,11 @@ PROG= svn${SVNLITE}fsfs
SRCS= dump-index-cmd.c load-index-cmd.c stats-cmd.c svnfsfs.c
-CFLAGS+=-I${SVNDIR}/include -I${SVNDIR} -I${.CURDIR}/.. \
- -I${.CURDIR}/../lib/libapr \
+CFLAGS+=-I${SVNDIR}/include -I${SVNDIR} -I${.CURDIR:H} \
+ -I${.CURDIR:H}/lib/libapr \
-I${APR}/include/arch/unix \
-I${APR}/include \
- -I${.CURDIR}/../lib/libapr_util \
+ -I${.CURDIR:H}/lib/libapr_util \
-I${APRU}/include/private \
-I${APRU}/include
diff --git a/usr.bin/svn/svnlook/Makefile b/usr.bin/svn/svnlook/Makefile
index f024d50..b4c3929 100644
--- a/usr.bin/svn/svnlook/Makefile
+++ b/usr.bin/svn/svnlook/Makefile
@@ -2,7 +2,7 @@
MAN=
-.include "${.CURDIR}/../Makefile.inc"
+.include "${.CURDIR:H}/Makefile.inc"
.PATH: ${SVNDIR}/svnlook
@@ -10,11 +10,11 @@ PROG= svn${SVNLITE}look
SRCS= svnlook.c
-CFLAGS+=-I${SVNDIR}/include -I${SVNDIR} -I${.CURDIR}/.. \
- -I${.CURDIR}/../lib/libapr \
+CFLAGS+=-I${SVNDIR}/include -I${SVNDIR} -I${.CURDIR:H} \
+ -I${.CURDIR:H}/lib/libapr \
-I${APR}/include/arch/unix \
-I${APR}/include \
- -I${.CURDIR}/../lib/libapr_util \
+ -I${.CURDIR:H}/lib/libapr_util \
-I${APRU}/include/private \
-I${APRU}/include
diff --git a/usr.bin/svn/svnmucc/Makefile b/usr.bin/svn/svnmucc/Makefile
index 0815b30..f2bd597 100644
--- a/usr.bin/svn/svnmucc/Makefile
+++ b/usr.bin/svn/svnmucc/Makefile
@@ -2,7 +2,7 @@
MAN=
-.include "${.CURDIR}/../Makefile.inc"
+.include "${.CURDIR:H}/Makefile.inc"
.PATH: ${SVNDIR}/svnmucc
@@ -10,11 +10,11 @@ PROG= svn${SVNLITE}mucc
SRCS= svnmucc.c
-CFLAGS+=-I${SVNDIR}/include -I${SVNDIR} -I${.CURDIR}/.. \
- -I${.CURDIR}/../lib/libapr \
+CFLAGS+=-I${SVNDIR}/include -I${SVNDIR} -I${.CURDIR:H} \
+ -I${.CURDIR:H}/lib/libapr \
-I${APR}/include/arch/unix \
-I${APR}/include \
- -I${.CURDIR}/../lib/libapr_util \
+ -I${.CURDIR:H}/lib/libapr_util \
-I${APRU}/include/private \
-I${APRU}/include
diff --git a/usr.bin/svn/svnrdump/Makefile b/usr.bin/svn/svnrdump/Makefile
index a63ac62..f1dd5e7 100644
--- a/usr.bin/svn/svnrdump/Makefile
+++ b/usr.bin/svn/svnrdump/Makefile
@@ -2,7 +2,7 @@
MAN=
-.include "${.CURDIR}/../Makefile.inc"
+.include "${.CURDIR:H}/Makefile.inc"
.PATH: ${SVNDIR}/svnrdump
@@ -10,11 +10,11 @@ PROG= svn${SVNLITE}rdump
SRCS= dump_editor.c load_editor.c svnrdump.c util.c
-CFLAGS+=-I${SVNDIR}/include -I${SVNDIR} -I${.CURDIR}/.. \
- -I${.CURDIR}/../lib/libapr \
+CFLAGS+=-I${SVNDIR}/include -I${SVNDIR} -I${.CURDIR:H} \
+ -I${.CURDIR:H}/lib/libapr \
-I${APR}/include/arch/unix \
-I${APR}/include \
- -I${.CURDIR}/../lib/libapr_util \
+ -I${.CURDIR:H}/lib/libapr_util \
-I${APRU}/include/private \
-I${APRU}/include
diff --git a/usr.bin/svn/svnserve/Makefile b/usr.bin/svn/svnserve/Makefile
index 4b79cf4..5e2c79c 100644
--- a/usr.bin/svn/svnserve/Makefile
+++ b/usr.bin/svn/svnserve/Makefile
@@ -2,7 +2,7 @@
MAN=
-.include "${.CURDIR}/../Makefile.inc"
+.include "${.CURDIR:H}/Makefile.inc"
.PATH: ${SVNDIR}/svnserve
@@ -10,11 +10,11 @@ PROG= svn${SVNLITE}serve
SRCS= cyrus_auth.c log-escape.c logger.c serve.c svnserve.c winservice.c
-CFLAGS+=-I${SVNDIR}/include -I${SVNDIR} -I${.CURDIR}/.. \
- -I${.CURDIR}/../lib/libapr \
+CFLAGS+=-I${SVNDIR}/include -I${SVNDIR} -I${.CURDIR:H} \
+ -I${.CURDIR:H}/lib/libapr \
-I${APR}/include/arch/unix \
-I${APR}/include \
- -I${.CURDIR}/../lib/libapr_util \
+ -I${.CURDIR:H}/lib/libapr_util \
-I${APRU}/include/private \
-I${APRU}/include
diff --git a/usr.bin/svn/svnsync/Makefile b/usr.bin/svn/svnsync/Makefile
index dddd773..7867611 100644
--- a/usr.bin/svn/svnsync/Makefile
+++ b/usr.bin/svn/svnsync/Makefile
@@ -2,7 +2,7 @@
MAN=
-.include "${.CURDIR}/../Makefile.inc"
+.include "${.CURDIR:H}/Makefile.inc"
.PATH: ${SVNDIR}/svnsync
@@ -10,11 +10,11 @@ PROG= svn${SVNLITE}sync
SRCS= svnsync.c sync.c
-CFLAGS+=-I${SVNDIR}/include -I${SVNDIR} -I${.CURDIR}/.. \
- -I${.CURDIR}/../lib/libapr \
+CFLAGS+=-I${SVNDIR}/include -I${SVNDIR} -I${.CURDIR:H} \
+ -I${.CURDIR:H}/lib/libapr \
-I${APR}/include/arch/unix \
-I${APR}/include \
- -I${.CURDIR}/../lib/libapr_util \
+ -I${.CURDIR:H}/lib/libapr_util \
-I${APRU}/include/private \
-I${APRU}/include
diff --git a/usr.bin/svn/svnversion/Makefile b/usr.bin/svn/svnversion/Makefile
index de59168..29e5b33 100644
--- a/usr.bin/svn/svnversion/Makefile
+++ b/usr.bin/svn/svnversion/Makefile
@@ -2,7 +2,7 @@
MAN=
-.include "${.CURDIR}/../Makefile.inc"
+.include "${.CURDIR:H}/Makefile.inc"
.PATH: ${SVNDIR}/svnversion
@@ -10,11 +10,11 @@ PROG= svn${SVNLITE}version
SRCS= svnversion.c
-CFLAGS+=-I${SVNDIR}/include -I${SVNDIR} -I${.CURDIR}/.. \
- -I${.CURDIR}/../lib/libapr \
+CFLAGS+=-I${SVNDIR}/include -I${SVNDIR} -I${.CURDIR:H} \
+ -I${.CURDIR:H}/lib/libapr \
-I${APR}/include/arch/unix \
-I${APR}/include \
- -I${.CURDIR}/../lib/libapr_util \
+ -I${.CURDIR:H}/lib/libapr_util \
-I${APRU}/include/private \
-I${APRU}/include
diff --git a/usr.bin/timeout/timeout.1 b/usr.bin/timeout/timeout.1
index 70a9106..c9e838b 100644
--- a/usr.bin/timeout/timeout.1
+++ b/usr.bin/timeout/timeout.1
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd Oct 28, 2014
+.Dd February 17, 2017
.Dt TIMEOUT 1
.Os
.Sh NAME
@@ -127,3 +127,12 @@ the exit status return is 125.
.Sh SEE ALSO
.Xr kill 1 ,
.Xr signal 3
+.Sh HISTORY
+The
+.Nm
+command first appeared in
+.Fx 10.3 .
+.Sh AUTHORS
+.An Baptiste Daroussin Aq Mt bapt@FreeBSD.org
+and
+.An Vsevolod Stakhov Aq Mt vsevolod@FreeBSD.org
diff --git a/usr.bin/units/units.1 b/usr.bin/units/units.1
index f76e462..9ab76be 100644
--- a/usr.bin/units/units.1
+++ b/usr.bin/units/units.1
@@ -14,33 +14,33 @@
.Sh OPTIONS
The following options are available:
.Bl -tag -width indent
-.It Fl h No , Fl -help
+.It Fl h \&No , Fl -help
Show an overview of options
-.It Fl f Ar filename No , Fl -file Ar filename
+.It Fl f Ar filename \&No , Fl -file Ar filename
Specify the name of the units data file to load.
-.It Fl H Ar filename No , Fl -historyfile Ar filename
+.It Fl H Ar filename \&No , Fl -historyfile Ar filename
Ignored, for compatibility with GNU units.
.It Fl e , Fl -exponential
Behave as if -o '%6e' was typed.
-.It Fl q No , Fl -quiet
+.It Fl q \&No , Fl -quiet
Suppress prompting of the user for units and the display of statistics
about the number of units loaded.
-.It Fl U No , Fl -unitsfile
+.It Fl U \&No , Fl -unitsfile
If the default unit file exists prints its location.
If not, print
.Qo
Units data file not found
.Qc
-.It Fl t No , Fl -terse
+.It Fl t \&No , Fl -terse
Only print the result. This is used when calling
.Nm
from other programs for easy to parse results.
-.It Fl v No , Fl -verbose
+.It Fl v \&No , Fl -verbose
Print the units in the conversion output.
Be more verbose in general.
-.It Fl o Ar format No , Fl -output-format Ar format
+.It Fl o Ar format \&No , Fl -output-format Ar format
Select the output format string by which numbers are printed.
-.It Fl V No , Fl -version
+.It Fl V \&No , Fl -version
Print the version number, usage, and then exit.
.It Ar from-unit to-unit
Allow a single unit conversion to be done directly from the command
diff --git a/usr.bin/unzip/unzip.1 b/usr.bin/unzip/unzip.1
index 780321c..b7c2d85 100644
--- a/usr.bin/unzip/unzip.1
+++ b/usr.bin/unzip/unzip.1
@@ -171,7 +171,7 @@ The
utility is only able to process ZIP archives handled by
.Xr libarchive 3 .
Depending on the installed version of
-.Xr libarchive ,
+.Xr libarchive 3 ,
this may or may not include self-extracting archives.
.Sh SEE ALSO
.Xr libarchive 3
diff --git a/usr.bin/uuencode/uuencode.1 b/usr.bin/uuencode/uuencode.1
index 9ce7e05..366a6c7 100644
--- a/usr.bin/uuencode/uuencode.1
+++ b/usr.bin/uuencode/uuencode.1
@@ -40,7 +40,7 @@
.Sh SYNOPSIS
.Nm
.Op Fl m
-.Op Fl r
+.Op Fl r
.Op Fl o Ar output_file
.Op Ar file
.Ar name
diff --git a/usr.bin/whois/whois.1 b/usr.bin/whois/whois.1
index 0fe70a1..cda7295 100644
--- a/usr.bin/whois/whois.1
+++ b/usr.bin/whois/whois.1
@@ -206,7 +206,7 @@ The operands specified to
are treated independently and may be used
as queries on different whois servers.
.Sh ENVIRONMENT
-.Bl -tag
+.Bl -tag -width WHOIS_SERVER
.It Ev WHOIS_SERVER
The primary default whois server.
If this is unset,
diff --git a/usr.sbin/arp/arp.c b/usr.sbin/arp/arp.c
index eefde75..60079d4 100644
--- a/usr.sbin/arp/arp.c
+++ b/usr.sbin/arp/arp.c
@@ -48,7 +48,6 @@ __FBSDID("$FreeBSD$");
* arp - display, set, and delete arp table entries
*/
-
#include <sys/param.h>
#include <sys/file.h>
#include <sys/socket.h>
@@ -80,8 +79,8 @@ __FBSDID("$FreeBSD$");
#include <strings.h>
#include <unistd.h>
-typedef void (action_fn)(struct sockaddr_dl *sdl,
- struct sockaddr_in *s_in, struct rt_msghdr *rtm);
+typedef void (action_fn)(struct sockaddr_dl *sdl, struct sockaddr_in *s_in,
+ struct rt_msghdr *rtm);
static int search(u_long addr, action_fn *action);
static action_fn print_entry;
@@ -320,7 +319,7 @@ set(int argc, char **argv)
return (1);
doing_proxy = flags = expire_time = 0;
while (argc-- > 0) {
- if (strncmp(argv[0], "temp", 4) == 0) {
+ if (strcmp(argv[0], "temp") == 0) {
struct timespec tp;
int max_age;
size_t len = sizeof(max_age);
@@ -330,10 +329,10 @@ set(int argc, char **argv)
&max_age, &len, NULL, 0) != 0)
err(1, "sysctlbyname");
expire_time = tp.tv_sec + max_age;
- } else if (strncmp(argv[0], "pub", 3) == 0) {
+ } else if (strcmp(argv[0], "pub") == 0) {
flags |= RTF_ANNOUNCE;
doing_proxy = 1;
- if (argc && strncmp(argv[1], "only", 3) == 0) {
+ if (argc && strcmp(argv[1], "only") == 0) {
/*
* Compatibility: in pre FreeBSD 8 times
* the "only" keyword used to mean that
@@ -342,27 +341,28 @@ set(int argc, char **argv)
*/
argc--; argv++;
}
- } else if (strncmp(argv[0], "blackhole", 9) == 0) {
+ } else if (strcmp(argv[0], "blackhole") == 0) {
if (flags & RTF_REJECT) {
- printf("Choose one of blackhole or reject, not both.\n");
+ errx(1, "Choose one of blackhole or reject, "
+ "not both.");
}
flags |= RTF_BLACKHOLE;
- } else if (strncmp(argv[0], "reject", 6) == 0) {
+ } else if (strcmp(argv[0], "reject") == 0) {
if (flags & RTF_BLACKHOLE) {
- printf("Choose one of blackhole or reject, not both.\n");
+ errx(1, "Choose one of blackhole or reject, "
+ "not both.");
}
flags |= RTF_REJECT;
- } else if (strncmp(argv[0], "trail", 5) == 0) {
- /* XXX deprecated and undocumented feature */
- printf("%s: Sending trailers is no longer supported\n",
- host);
+ } else {
+ warnx("Invalid parameter '%s'", argv[0]);
+ usage();
}
argv++;
}
ea = (struct ether_addr *)LLADDR(&sdl_m);
if (doing_proxy && !strcmp(eaddr, "auto")) {
if (!get_ether_addr(dst->sin_addr.s_addr, ea)) {
- printf("no interface found for %s\n",
+ warnx("no interface found for %s",
inet_ntoa(dst->sin_addr));
return (1);
}
@@ -381,7 +381,7 @@ set(int argc, char **argv)
/*
* In the case a proxy-arp entry is being added for
- * a remote end point, the RTF_ANNOUNCE flag in the
+ * a remote end point, the RTF_ANNOUNCE flag in the
* RTM_GET command is an indication to the kernel
* routing code that the interface associated with
* the prefix route covering the local end of the
@@ -398,7 +398,7 @@ set(int argc, char **argv)
if ((sdl->sdl_family != AF_LINK) ||
(rtm->rtm_flags & RTF_GATEWAY) ||
!valid_type(sdl->sdl_type)) {
- printf("cannot intuit interface index and type for %s\n", host);
+ warnx("cannot intuit interface index and type for %s", host);
return (1);
}
sdl_m.sdl_type = sdl->sdl_type;
@@ -467,7 +467,7 @@ delete(char *host)
sdl = (struct sockaddr_dl *)(SA_SIZE(addr) + (char *)addr);
/*
- * With the new L2/L3 restructure, the route
+ * With the new L2/L3 restructure, the route
* returned is a prefix route. The important
* piece of information from the previous
* RTM_GET is the interface index. In the
@@ -486,7 +486,7 @@ delete(char *host)
* is a proxy-arp entry to remove.
*/
if (flags & RTF_ANNOUNCE) {
- fprintf(stderr, "delete: cannot locate %s\n",host);
+ warnx("delete: cannot locate %s", host);
return (1);
}
@@ -525,7 +525,7 @@ search(u_long addr, action_fn *action)
mib[5] = RTF_LLINFO;
#else
mib[5] = 0;
-#endif
+#endif
if (sysctl(mib, 6, NULL, &needed, NULL, 0) < 0)
err(1, "route-sysctl-estimate");
if (needed == 0) /* empty table */
@@ -575,7 +575,7 @@ print_entry(struct sockaddr_dl *sdl,
struct if_nameindex *p;
int seg;
- if (ifnameindex == NULL)
+ if (ifnameindex == NULL)
if ((ifnameindex = if_nameindex()) == NULL)
err(1, "cannot retrieve interface names");
@@ -597,7 +597,8 @@ print_entry(struct sockaddr_dl *sdl,
sdl->sdl_type == IFT_L2VLAN ||
sdl->sdl_type == IFT_BRIDGE) &&
sdl->sdl_alen == ETHER_ADDR_LEN)
- printf("%s", ether_ntoa((struct ether_addr *)LLADDR(sdl)));
+ printf("%s",
+ ether_ntoa((struct ether_addr *)LLADDR(sdl)));
else {
int n = sdl->sdl_nlen > 0 ? sdl->sdl_nlen + 1 : 0;
@@ -607,7 +608,7 @@ print_entry(struct sockaddr_dl *sdl,
printf("(incomplete)");
for (p = ifnameindex; p && ifnameindex->if_index &&
- ifnameindex->if_name; p++) {
+ ifnameindex->if_name; p++) {
if (p->if_index == sdl->sdl_index) {
printf(" on %s", p->if_name);
break;
@@ -629,31 +630,31 @@ print_entry(struct sockaddr_dl *sdl,
printf(" published");
switch(sdl->sdl_type) {
case IFT_ETHER:
- printf(" [ethernet]");
- break;
+ printf(" [ethernet]");
+ break;
case IFT_ISO88025:
- printf(" [token-ring]");
+ printf(" [token-ring]");
trld = SDL_ISO88025(sdl);
if (trld->trld_rcf != 0) {
printf(" rt=%x", ntohs(trld->trld_rcf));
for (seg = 0;
seg < ((TR_RCF_RIFLEN(trld->trld_rcf) - 2 ) / 2);
- seg++)
+ seg++)
printf(":%x", ntohs(*(trld->trld_route[seg])));
}
break;
case IFT_FDDI:
- printf(" [fddi]");
- break;
+ printf(" [fddi]");
+ break;
case IFT_ATM:
- printf(" [atm]");
- break;
+ printf(" [atm]");
+ break;
case IFT_L2VLAN:
printf(" [vlan]");
break;
case IFT_IEEE1394:
- printf(" [firewire]");
- break;
+ printf(" [firewire]");
+ break;
case IFT_BRIDGE:
printf(" [bridge]");
break;
@@ -662,8 +663,8 @@ print_entry(struct sockaddr_dl *sdl,
break;
default:
break;
- }
-
+ }
+
printf("\n");
}
@@ -688,13 +689,13 @@ static void
usage(void)
{
fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
- "usage: arp [-n] [-i interface] hostname",
- " arp [-n] [-i interface] -a",
- " arp -d hostname [pub]",
- " arp -d [-i interface] -a",
- " arp -s hostname ether_addr [temp] [reject | blackhole] [pub [only]]",
- " arp -S hostname ether_addr [temp] [reject | blackhole] [pub [only]]",
- " arp -f filename");
+ "usage: arp [-n] [-i interface] hostname",
+ " arp [-n] [-i interface] -a",
+ " arp -d hostname [pub]",
+ " arp -d [-i interface] -a",
+ " arp -s hostname ether_addr [temp] [reject | blackhole] [pub [only]]",
+ " arp -S hostname ether_addr [temp] [reject | blackhole] [pub [only]]",
+ " arp -f filename");
exit(1);
}
@@ -753,12 +754,12 @@ rtmsg(int cmd, struct sockaddr_in *dst, struct sockaddr_dl *sdl)
case RTM_GET:
rtm->rtm_addrs |= RTA_DST;
}
-#define NEXTADDR(w, s) \
- do { \
- if ((s) != NULL && rtm->rtm_addrs & (w)) { \
- bcopy((s), cp, sizeof(*(s))); \
- cp += SA_SIZE(s); \
- } \
+#define NEXTADDR(w, s) \
+ do { \
+ if ((s) != NULL && rtm->rtm_addrs & (w)) { \
+ bcopy((s), cp, sizeof(*(s))); \
+ cp += SA_SIZE(s); \
+ } \
} while (0)
NEXTADDR(RTA_DST, dst);
@@ -814,7 +815,7 @@ get_ether_addr(in_addr_t ipaddr, struct ether_addr *hwaddr)
}
#define NEXTIFR(i) \
- ((struct ifreq *)((char *)&(i)->ifr_addr \
+ ((struct ifreq *)((char *)&(i)->ifr_addr \
+ MAX((i)->ifr_addr.sa_len, sizeof((i)->ifr_addr))) )
/*
@@ -835,14 +836,10 @@ get_ether_addr(in_addr_t ipaddr, struct ether_addr *hwaddr)
if (ioctl(sock, SIOCGIFFLAGS, &ifreq) < 0)
continue;
if ((ifreq.ifr_flags &
- (IFF_UP|IFF_BROADCAST|IFF_POINTOPOINT|
- IFF_LOOPBACK|IFF_NOARP))
- != (IFF_UP|IFF_BROADCAST))
+ (IFF_UP|IFF_BROADCAST|IFF_POINTOPOINT|
+ IFF_LOOPBACK|IFF_NOARP)) != (IFF_UP|IFF_BROADCAST))
continue;
- /*
- * Get its netmask and check that it's on
- * the right subnet.
- */
+ /* Get its netmask and check that it's on the right subnet. */
if (ioctl(sock, SIOCGIFNETMASK, &ifreq) < 0)
continue;
mask = ((struct sockaddr_in *)
@@ -872,9 +869,8 @@ get_ether_addr(in_addr_t ipaddr, struct ether_addr *hwaddr)
*/
dla = (struct sockaddr_dl *) &ifr->ifr_addr;
memcpy(hwaddr, LLADDR(dla), dla->sdl_alen);
- printf("using interface %s for proxy with address ",
- ifp->ifr_name);
- printf("%s\n", ether_ntoa(hwaddr));
+ printf("using interface %s for proxy with address %s\n", ifp->ifr_name,
+ ether_ntoa(hwaddr));
retval = dla->sdl_alen;
done:
close(sock);
diff --git a/usr.sbin/bhyve/virtio.h b/usr.sbin/bhyve/virtio.h
index 0e96a1d..28eecc7 100644
--- a/usr.sbin/bhyve/virtio.h
+++ b/usr.sbin/bhyve/virtio.h
@@ -209,7 +209,7 @@ struct vring_used {
#define VIRTIO_VENDOR 0x1AF4
#define VIRTIO_DEV_NET 0x1000
#define VIRTIO_DEV_BLOCK 0x1001
-#define VIRTIO_DEV_RANDOM 0x1002
+#define VIRTIO_DEV_RANDOM 0x1005
/*
* PCI config space constants.
diff --git a/usr.sbin/bsdinstall/scripts/auto b/usr.sbin/bsdinstall/scripts/auto
index 0d9e195..e826f36 100755
--- a/usr.sbin/bsdinstall/scripts/auto
+++ b/usr.sbin/bsdinstall/scripts/auto
@@ -464,9 +464,11 @@ finalconfig() {
trap error SIGINT # SIGINT is bad again
bsdinstall config || error "Failed to save config"
+if [ -n "$DISTDIR_IS_UNIONFS" ]; then
+ umount -f $BSDINSTALL_DISTDIR
+fi
+
if [ ! -z "$BSDINSTALL_FETCHDEST" ]; then
- [ "$BSDINSTALL_FETCHDEST" != "$BSDINSTALL_DISTDIR" ] && \
- umount "$BSDINSTALL_DISTDIR"
rm -rf "$BSDINSTALL_FETCHDEST"
fi
diff --git a/usr.sbin/ctladm/ctladm.8 b/usr.sbin/ctladm/ctladm.8
index 479d880..551c137 100644
--- a/usr.sbin/ctladm/ctladm.8
+++ b/usr.sbin/ctladm/ctladm.8
@@ -888,8 +888,8 @@ client through the selection of appropriate commands and task attributes.
The default value is "restricted". It improves data integrity, but may
introduce some additional delays.
.It Va serseq
-Set to "on" to serialize conseсutive reads/writes.
-Set to "read" to serialize conseсutive reads.
+Set to "on" to serialize consecutive reads/writes.
+Set to "read" to serialize consecutive reads.
Set to "off" to allow them be issued in parallel.
Parallel issue of consecutive operations may confuse logic of the
backing file system, hurting performance; but it may improve performance
diff --git a/usr.sbin/kldxref/ef.c b/usr.sbin/kldxref/ef.c
index 88fbc34..d700b2a 100644
--- a/usr.sbin/kldxref/ef.c
+++ b/usr.sbin/kldxref/ef.c
@@ -47,7 +47,7 @@
#include "ef.h"
-#define MAXSEGS 2
+#define MAXSEGS 3
struct ef_file {
char* ef_name;
struct elf_file *ef_efile;
@@ -600,7 +600,7 @@ ef_open(const char *filename, struct elf_file *efile, int verbose)
filename);
break;
} else if (nsegs > MAXSEGS) {
- warnx("%s: too many sections", filename);
+ warnx("%s: too many segments", filename);
break;
}
ef->ef_nsegs = nsegs;
diff --git a/usr.sbin/ndp/ndp.c b/usr.sbin/ndp/ndp.c
index cf80149..95ee865 100644
--- a/usr.sbin/ndp/ndp.c
+++ b/usr.sbin/ndp/ndp.c
@@ -109,10 +109,11 @@
#include <unistd.h>
#include "gmt2local.h"
-#define NEXTADDR(w, s) \
- if (rtm->rtm_addrs & (w)) { \
- bcopy((char *)&s, cp, sizeof(s)); cp += SA_SIZE(&s);}
-
+#define NEXTADDR(w, s) \
+ if (rtm->rtm_addrs & (w)) { \
+ bcopy((char *)&s, cp, sizeof(s)); \
+ cp += SA_SIZE(&s); \
+ }
static pid_t pid;
static int nflag;
@@ -529,10 +530,10 @@ delete:
printf("cannot locate %s\n", host);
return (1);
}
- /*
- * need to reinit the field because it has rt_key
- * but we want the actual address
- */
+ /*
+ * need to reinit the field because it has rt_key
+ * but we want the actual address
+ */
NEXTADDR(RTA_DST, sin_m);
rtm->rtm_flags |= RTF_LLDATA;
if (rtmsg(RTM_DELETE) == 0) {
@@ -604,7 +605,8 @@ again:;
rtm = (struct rt_msghdr *)next;
sin = (struct sockaddr_in6 *)(rtm + 1);
- sdl = (struct sockaddr_dl *)((char *)sin + ALIGN(sin->sin6_len));
+ sdl = (struct sockaddr_dl *)((char *)sin +
+ ALIGN(sin->sin6_len));
/*
* Some OSes can produce a route that has the LINK flag but
@@ -724,7 +726,7 @@ again:;
isrouter ? "R" : "",
(rtm->rtm_flags & RTF_ANNOUNCE) ? "p" : "");
} else {
-#if 0 /* W and P are mystery even for us */
+#if 0 /* W and P are mystery even for us */
sin = (struct sockaddr_in6 *)
(sdl->sdl_len + (char *)sdl);
snprintf(flgbuf, sizeof(flgbuf), "%s%s%s%s",
@@ -855,7 +857,7 @@ rtmsg(int cmd)
rtm->rtm_inits = RTV_EXPIRE;
}
rtm->rtm_flags |= (RTF_HOST | RTF_STATIC | RTF_LLDATA);
-#if 0 /* we don't support ipv6addr/128 type proxying */
+#if 0 /* we don't support ipv6addr/128 type proxying */
if (rtm->rtm_flags & RTF_ANNOUNCE) {
rtm->rtm_flags &= ~RTF_HOST;
rtm->rtm_addrs |= RTA_NETMASK;
@@ -868,7 +870,7 @@ rtmsg(int cmd)
NEXTADDR(RTA_DST, sin_m);
NEXTADDR(RTA_GATEWAY, sdl_m);
-#if 0 /* we don't support ipv6addr/128 type proxying */
+#if 0 /* we don't support ipv6addr/128 type proxying */
memset(&so_mask.sin6_addr, 0xff, sizeof(so_mask.sin6_addr));
NEXTADDR(RTA_NETMASK, so_mask);
#endif
@@ -913,7 +915,7 @@ ifinfo(char *ifname, int argc, char **argv)
err(1, "ioctl(SIOCGIFINFO_IN6)");
/* NOTREACHED */
}
-#define ND nd.ndi
+#define ND nd.ndi
newflags = ND.flags;
for (i = 0; i < argc; i++) {
int clear = 0;
@@ -924,35 +926,33 @@ ifinfo(char *ifname, int argc, char **argv)
cp++;
}
-#define SETFLAG(s, f) \
- do {\
- if (strcmp(cp, (s)) == 0) {\
- if (clear)\
- newflags &= ~(f);\
- else\
- newflags |= (f);\
- }\
- } while (0)
+#define SETFLAG(s, f) do { \
+ if (strcmp(cp, (s)) == 0) { \
+ if (clear) \
+ newflags &= ~(f); \
+ else \
+ newflags |= (f); \
+ } \
+} while (0)
/*
* XXX: this macro is not 100% correct, in that it matches "nud" against
* "nudbogus". But we just let it go since this is minor.
*/
-#define SETVALUE(f, v) \
- do { \
- char *valptr; \
- unsigned long newval; \
- v = 0; /* unspecified */ \
- if (strncmp(cp, f, strlen(f)) == 0) { \
- valptr = strchr(cp, '='); \
- if (valptr == NULL) \
- err(1, "syntax error in %s field", (f)); \
- errno = 0; \
- newval = strtoul(++valptr, NULL, 0); \
- if (errno) \
- err(1, "syntax error in %s's value", (f)); \
- v = newval; \
- } \
- } while (0)
+#define SETVALUE(f, v) do { \
+ char *valptr; \
+ unsigned long newval; \
+ v = 0; /* unspecified */ \
+ if (strncmp(cp, f, strlen(f)) == 0) { \
+ valptr = strchr(cp, '='); \
+ if (valptr == NULL) \
+ err(1, "syntax error in %s field", (f)); \
+ errno = 0; \
+ newval = strtoul(++valptr, NULL, 0); \
+ if (errno) \
+ err(1, "syntax error in %s's value", (f)); \
+ v = newval; \
+ } \
+} while (0)
SETFLAG("disabled", ND6_IFF_IFDISABLED);
SETFLAG("nud", ND6_IFF_PERFORMNUD);
@@ -1021,7 +1021,7 @@ ifinfo(char *ifname, int argc, char **argv)
printf("%02x", rbuf[j]);
}
}
-#endif
+#endif /* IPV6CTL_USETEMPADDR */
if (ND.flags) {
printf("\nFlags: ");
#ifdef ND6_IFF_IFDISABLED
@@ -1314,7 +1314,7 @@ getdefif()
close(s);
}
-#endif
+#endif /* SIOCSDEFIFACE_IN6 */
static char *
sec2str(time_t total)
diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c
index b4cf938..7603be8 100644
--- a/usr.sbin/syslogd/syslogd.c
+++ b/usr.sbin/syslogd/syslogd.c
@@ -79,15 +79,15 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
-#include <sys/stat.h>
-#include <sys/wait.h>
-#include <sys/socket.h>
#include <sys/queue.h>
-#include <sys/uio.h>
-#include <sys/un.h>
-#include <sys/time.h>
#include <sys/resource.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
#include <sys/syslimits.h>
+#include <sys/time.h>
+#include <sys/uio.h>
+#include <sys/un.h>
+#include <sys/wait.h>
#include <sys/types.h>
#include <sys/mman.h>
@@ -2351,7 +2351,7 @@ markit(void)
/*
* fork off and become a daemon, but wait for the child to come online
- * before returing to the parent, or we get disk thrashing at boot etc.
+ * before returning to the parent, or we get disk thrashing at boot etc.
* Set a timer so we don't hang forever if it wedges.
*/
static int
diff --git a/usr.sbin/tcpdump/tcpdump/Makefile b/usr.sbin/tcpdump/tcpdump/Makefile
index ec585f4..6967a14 100644
--- a/usr.sbin/tcpdump/tcpdump/Makefile
+++ b/usr.sbin/tcpdump/tcpdump/Makefile
@@ -8,7 +8,9 @@ TCPDUMP_DISTDIR?= ${.CURDIR}/../../../contrib/tcpdump
PROG= tcpdump
SRCS= addrtoname.c \
+ addrtostr.c \
af.c \
+ ascii_strcasecmp.c \
checksum.c \
cpack.c \
gmpls.c \
@@ -17,9 +19,11 @@ SRCS= addrtoname.c \
ipproto.c \
l2vpn.c \
machdep.c \
+ netdissect.c \
nlpid.c \
oui.c \
parsenfsfh.c \
+ print.c \
print-802_11.c \
print-802_15_4.c \
print-ah.c \
@@ -32,6 +36,7 @@ SRCS= addrtoname.c \
print-ascii.c \
print-atalk.c \
print-atm.c \
+ print-babel.c \
print-beep.c \
print-bfd.c \
print-bgp.c \
@@ -46,6 +51,7 @@ SRCS= addrtoname.c \
print-cnfp.c \
print-dccp.c \
print-decnet.c \
+ print-dhcp6.c \
print-domain.c \
print-dtp.c \
print-dvmrp.c \
@@ -58,17 +64,21 @@ SRCS= addrtoname.c \
print-fddi.c \
print-forces.c \
print-fr.c \
+ print-frag6.c \
print-ftp.c \
print-geneve.c \
print-geonet.c \
print-gre.c \
+ print-hncp.c \
print-hsrp.c \
print-http.c \
print-icmp.c \
+ print-icmp6.c \
print-igmp.c \
print-igrp.c \
print-ip.c \
print-ip6.c \
+ print-ip6opts.c \
print-ipcomp.c \
print-ipfc.c \
print-ipnet.c \
@@ -80,6 +90,7 @@ SRCS= addrtoname.c \
print-l2tp.c \
print-lane.c \
print-ldp.c \
+ print-lisp.c \
print-llc.c \
print-lldp.c \
print-lmp.c \
@@ -88,19 +99,23 @@ SRCS= addrtoname.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.c \
print-openflow-1.0.c \
print-ospf.c \
+ print-ospf6.c \
print-otv.c \
print-pgm.c \
print-pim.c \
@@ -111,10 +126,13 @@ SRCS= addrtoname.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 \
@@ -144,14 +162,16 @@ SRCS= addrtoname.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 \
+ strtoaddr.c \
tcpdump.c \
- util.c \
+ util-print.c \
version.c
CLEANFILES+= version.c
@@ -160,16 +180,7 @@ CFLAGS+= -DHAVE_CONFIG_H
CFLAGS+= -D_U_="__attribute__((unused))"
.if ${MK_INET6_SUPPORT} != "no"
-SRCS+= print-babel.c \
- print-dhcp6.c \
- print-frag6.c \
- print-icmp6.c \
- print-ip6opts.c \
- print-mobility.c \
- print-ospf6.c \
- print-ripng.c \
- print-rt6.c
-CFLAGS+= -DINET6
+CFLAGS+= -DINET6 -DHAVE_OS_IPV6_SUPPORT
.endif
.if ${MACHINE_CPUARCH} != "i386"
CFLAGS+= -DLBL_ALIGN
@@ -190,7 +201,7 @@ CFLAGS+= -DHAVE_LIBCRYPTO -DHAVE_OPENSSL_EVP_H
.if ${MK_PF} != "no"
SRCS+= print-pflog.c \
print-pfsync.c
-CFLAGS+= -DHAVE_NET_PFVAR_H
+CFLAGS+= -DHAVE_NET_PFVAR_H -DHAVE_NET_IF_PFLOG_H
.endif
version.c: ${TCPDUMP_DISTDIR}/VERSION
diff --git a/usr.sbin/tcpdump/tcpdump/config.h b/usr.sbin/tcpdump/tcpdump/config.h
index 79a07e7..8980b31 100644
--- a/usr.sbin/tcpdump/tcpdump/config.h
+++ b/usr.sbin/tcpdump/tcpdump/config.h
@@ -4,8 +4,8 @@
/* config.h. Generated from config.h.in by configure. */
/* config.h.in. Generated from configure.in by autoheader. */
-/* define if you have the addrinfo function */
-#define HAVE_ADDRINFO 1
+/* define if you want to build the possibly-buggy SMB printer */
+#define ENABLE_SMB 1
/* Define to 1 if you have the `alarm' function. */
#define HAVE_ALARM 1
@@ -14,6 +14,9 @@
#define HAVE_BPF_DUMP 1
/* capsicum support available */
+#define HAVE_CAPSICUM 1
+
+/* Casper library support available */
/* See Makefile */
/* #undef HAVE_CASPER */
@@ -39,24 +42,21 @@
/* 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 if you have the h_errno variable */
-#define HAVE_H_ERRNO 1
-
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
@@ -85,6 +85,10 @@
/* 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 */
@@ -96,6 +100,10 @@
/* 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 */
@@ -150,6 +158,12 @@
/* 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
@@ -192,9 +206,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
@@ -246,16 +257,9 @@
/* define if your compiler has __attribute__ */
#define HAVE___ATTRIBUTE__ 1
-/* Define if you enable IPv6 support */
-/* See Makefile */
-/* #undef INET6 */
-
/* if unaligned access fails */
/* #undef LBL_ALIGN */
-/* define if you need to include missing/addrinfo.h */
-/* #undef NEED_ADDRINFO_H */
-
/* Define to 1 if netinet/ether.h declares `ether_ntohost' */
/* #undef NETINET_ETHER_H_DECLARES_ETHER_NTOHOST */
@@ -301,9 +305,6 @@
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
-/* define if you want to build the possibly-buggy SMB printer */
-#define TCPDUMP_DO_SMB 1
-
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
#define TIME_WITH_SYS_TIME 1
diff --git a/usr.sbin/vidcontrol/vidcontrol.c b/usr.sbin/vidcontrol/vidcontrol.c
index 1dba9cb..9807de81 100644
--- a/usr.sbin/vidcontrol/vidcontrol.c
+++ b/usr.sbin/vidcontrol/vidcontrol.c
@@ -393,11 +393,15 @@ load_vt4mappingtable(unsigned int nmappings, FILE *f)
if (nmappings == 0)
return (NULL);
- t = malloc(sizeof *t * nmappings);
+ if ((t = malloc(sizeof *t * nmappings)) == NULL) {
+ warn("malloc");
+ return (NULL);
+ }
if (fread(t, sizeof *t * nmappings, 1, f) != 1) {
- perror("mappings");
- exit(1);
+ warn("read mappings");
+ free(t);
+ return (NULL);
}
for (i = 0; i < nmappings; i++) {
@@ -422,7 +426,7 @@ load_default_vt4font(void)
}
}
-static int
+static void
load_vt4font(FILE *f)
{
struct vt4font_header fh;
@@ -431,13 +435,13 @@ load_vt4font(FILE *f)
unsigned int i;
if (fread(&fh, sizeof fh, 1, f) != 1) {
- perror("file_header");
- return (1);
+ warn("read file_header");
+ return;
}
if (memcmp(fh.magic, "VFNT0002", 8) != 0) {
- fprintf(stderr, "Bad magic\n");
- return (1);
+ warnx("bad magic in font file\n");
+ return;
}
for (i = 0; i < VFNT_MAPS; i++)
@@ -447,21 +451,26 @@ load_vt4font(FILE *f)
vfnt.height = fh.height;
glyphsize = howmany(vfnt.width, 8) * vfnt.height * vfnt.glyph_count;
- vfnt.glyphs = malloc(glyphsize);
+ if ((vfnt.glyphs = malloc(glyphsize)) == NULL) {
+ warn("malloc");
+ return;
+ }
if (fread(vfnt.glyphs, glyphsize, 1, f) != 1) {
- perror("glyphs");
- return (1);
+ warn("read glyphs");
+ free(vfnt.glyphs);
+ return;
}
for (i = 0; i < VFNT_MAPS; i++)
vfnt.map[i] = load_vt4mappingtable(vfnt.map_count[i], f);
- if (ioctl(STDIN_FILENO, PIO_VFONT, &vfnt) == -1) {
- perror("PIO_VFONT");
- return (1);
- }
- return (0);
+ if (ioctl(STDIN_FILENO, PIO_VFONT, &vfnt) == -1)
+ warn("PIO_VFONT");
+
+ for (i = 0; i < VFNT_MAPS; i++)
+ free(vfnt.map[i]);
+ free(vfnt.glyphs);
}
/*
@@ -511,8 +520,7 @@ load_font(const char *type, const char *filename)
}
if (vt4_mode) {
- if(load_vt4font(fd))
- warn("failed to load font \"%s\"", filename);
+ load_vt4font(fd);
fclose(fd);
return;
}
OpenPOWER on IntegriCloud