003 File Manager
Current Path:
/usr/src/contrib/tcpdump
usr
/
src
/
contrib
/
tcpdump
/
📁
..
📄
CHANGES
(57.87 KB)
📄
CONTRIBUTING
(5.93 KB)
📄
CREDITS
(14.57 KB)
📄
INSTALL.txt
(5.25 KB)
📄
LICENSE
(873 B)
📄
Makefile-devel-adds
(614 B)
📄
Makefile.in
(9.96 KB)
📄
PLATFORMS
(567 B)
📄
README
(9.04 KB)
📄
README.md
(9.04 KB)
📄
VERSION
(6 B)
📄
addrtoname.c
(33.19 KB)
📄
addrtoname.h
(2.78 KB)
📄
addrtostr.c
(5.64 KB)
📄
addrtostr.h
(2.03 KB)
📄
af.c
(1.96 KB)
📄
af.h
(1.81 KB)
📄
ah.h
(2.34 KB)
📄
appletalk.h
(4.06 KB)
📄
ascii_strcasecmp.c
(3.5 KB)
📄
ascii_strcasecmp.h
(1.49 KB)
📄
atime.awk
(529 B)
📄
atm.h
(1.14 KB)
📄
bpf_dump.c
(1.9 KB)
📄
chdlc.h
(1.31 KB)
📄
checksum.c
(5.25 KB)
📄
config.guess
(43.17 KB)
📄
config.h.in
(11.19 KB)
📄
config.sub
(34.93 KB)
📄
configure
(255.88 KB)
📄
configure.ac
(25.05 KB)
📄
configure.in
(25.66 KB)
📄
cpack.c
(3.92 KB)
📄
cpack.h
(2.37 KB)
📄
ether.h
(2.34 KB)
📄
ethertype.h
(5.58 KB)
📄
extract.h
(11.48 KB)
📄
funcattrs.h
(4.42 KB)
📄
getopt_long.h
(2.52 KB)
📄
gmpls.c
(5.82 KB)
📄
gmpls.h
(1.38 KB)
📄
gmt2local.c
(2.01 KB)
📄
gmt2local.h
(1.21 KB)
📄
in_cksum.c
(6.44 KB)
📄
install-sh
(5.45 KB)
📄
interface.h
(2.29 KB)
📄
ip.h
(5.75 KB)
📄
ip6.h
(7.6 KB)
📄
ipproto.c
(16.49 KB)
📄
ipproto.h
(4.72 KB)
📄
l2vpn.c
(3.36 KB)
📄
l2vpn.h
(781 B)
📁
lbl
📄
llc.h
(3.72 KB)
📄
machdep.c
(2.58 KB)
📄
machdep.h
(1.24 KB)
📄
makemib
(6.41 KB)
📄
mib.h
(26.33 KB)
📁
missing
📄
mkdep
(2.43 KB)
📄
mpls.h
(1.93 KB)
📄
nameser.h
(10.8 KB)
📄
netdissect-stdinc.h
(9.93 KB)
📄
netdissect.c
(3.38 KB)
📄
netdissect.h
(30.13 KB)
📄
nfs.h
(13.37 KB)
📄
nfsfh.h
(2.57 KB)
📄
nlpid.c
(1.27 KB)
📄
nlpid.h
(1.3 KB)
📄
openflow.h
(2.14 KB)
📄
ospf.h
(10.21 KB)
📄
oui.c
(3.83 KB)
📄
oui.h
(4.06 KB)
📄
packetdat.awk
(1.39 KB)
📄
parsenfsfh.c
(12.87 KB)
📄
pcap-missing.h
(1.8 KB)
📄
pcap_dump_ftell.c
(1.29 KB)
📄
ppp.h
(3.07 KB)
📄
print-802_11.c
(91.47 KB)
📄
print-802_15_4.c
(5.5 KB)
📄
print-ah.c
(2.02 KB)
📄
print-ahcp.c
(10.73 KB)
📄
print-aodv.c
(15.98 KB)
📄
print-aoe.c
(11.13 KB)
📄
print-ap1394.c
(4 KB)
📄
print-arcnet.c
(8.83 KB)
📄
print-arp.c
(14.57 KB)
📄
print-ascii.c
(6.23 KB)
📄
print-atalk.c
(16.76 KB)
📄
print-atm.c
(16.81 KB)
📄
print-babel.c
(23.79 KB)
📄
print-beep.c
(1.71 KB)
📄
print-bfd.c
(16.5 KB)
📄
print-bgp.c
(99.77 KB)
📄
print-bootp.c
(30.07 KB)
📄
print-bt.c
(2.21 KB)
📄
print-calm-fast.c
(1.81 KB)
📄
print-carp.c
(2.43 KB)
📄
print-cdp.c
(11.16 KB)
📄
print-cfm.c
(24.19 KB)
📄
print-chdlc.c
(5.88 KB)
📄
print-cip.c
(2.5 KB)
📄
print-cnfp.c
(13.69 KB)
📄
print-dccp.c
(17.75 KB)
📄
print-decnet.c
(37.63 KB)
📄
print-dhcp6.c
(23.22 KB)
📄
print-domain.c
(18.44 KB)
📄
print-dtp.c
(3.03 KB)
📄
print-dvmrp.c
(8.98 KB)
📄
print-eap.c
(9.26 KB)
📄
print-egp.c
(8.69 KB)
📄
print-eigrp.c
(19.49 KB)
📄
print-enc.c
(4.2 KB)
📄
print-esp.c
(21.46 KB)
📄
print-ether.c
(12.91 KB)
📄
print-fddi.c
(10.51 KB)
📄
print-forces.c
(45.01 KB)
📄
print-fr.c
(31.99 KB)
📄
print-frag6.c
(2.36 KB)
📄
print-ftp.c
(973 B)
📄
print-geneve.c
(6.13 KB)
📄
print-geonet.c
(6.72 KB)
📄
print-gre.c
(9.72 KB)
📄
print-hncp.c
(26.39 KB)
📄
print-hsrp.c
(4.57 KB)
📄
print-http.c
(1.51 KB)
📄
print-icmp.c
(22.7 KB)
📄
print-icmp6.c
(59.81 KB)
📄
print-igmp.c
(10.05 KB)
📄
print-igrp.c
(4.64 KB)
📄
print-ip.c
(17.04 KB)
📄
print-ip6.c
(10.57 KB)
📄
print-ip6opts.c
(5.53 KB)
📄
print-ipcomp.c
(2.32 KB)
📄
print-ipfc.c
(4.41 KB)
📄
print-ipnet.c
(2.78 KB)
📄
print-ipx.c
(6.42 KB)
📄
print-isakmp.c
(81.72 KB)
📄
print-isoclns.c
(107.61 KB)
📄
print-juniper.c
(48.42 KB)
📄
print-krb.c
(6.26 KB)
📄
print-l2tp.c
(23.94 KB)
📄
print-lane.c
(3.04 KB)
📄
print-ldp.c
(24.35 KB)
📄
print-lisp.c
(15.23 KB)
📄
print-llc.c
(16.68 KB)
📄
print-lldp.c
(57.26 KB)
📄
print-lmp.c
(38.11 KB)
📄
print-loopback.c
(3.63 KB)
📄
print-lspping.c
(51.64 KB)
📄
print-lwapp.c
(13.01 KB)
📄
print-lwres.c
(14.08 KB)
📄
print-m3ua.c
(10.92 KB)
📄
print-medsa.c
(5.57 KB)
📄
print-mobile.c
(3.28 KB)
📄
print-mobility.c
(9.74 KB)
📄
print-mpcp.c
(7.87 KB)
📄
print-mpls.c
(5.31 KB)
📄
print-mptcp.c
(13.68 KB)
📄
print-msdp.c
(2.69 KB)
📄
print-msnlb.c
(2.39 KB)
📄
print-nflog.c
(4.4 KB)
📄
print-nfs.c
(42.84 KB)
📄
print-nsh.c
(5.39 KB)
📄
print-ntp.c
(13.34 KB)
📄
print-null.c
(4.01 KB)
📄
print-olsr.c
(23.42 KB)
📄
print-openflow-1.0.c
(76.63 KB)
📄
print-openflow.c
(4.77 KB)
📄
print-ospf.c
(39.49 KB)
📄
print-ospf6.c
(29.86 KB)
📄
print-otv.c
(2.1 KB)
📄
print-pflog.c
(4.86 KB)
📄
print-pfsync.c
(12.53 KB)
📄
print-pgm.c
(22.17 KB)
📄
print-pim.c
(32.59 KB)
📄
print-pktap.c
(5.18 KB)
📄
print-ppi.c
(2.68 KB)
📄
print-ppp.c
(46.16 KB)
📄
print-pppoe.c
(5.65 KB)
📄
print-pptp.c
(25.9 KB)
📄
print-radius.c
(35.1 KB)
📄
print-raw.c
(1.52 KB)
📄
print-resp.c
(16.5 KB)
📄
print-rip.c
(9.19 KB)
📄
print-ripng.c
(6 KB)
📄
print-rpki-rtr.c
(10.83 KB)
📄
print-rrcp.c
(4.56 KB)
📄
print-rsvp.c
(78.61 KB)
📄
print-rt6.c
(2.66 KB)
📄
print-rtsp.c
(1.16 KB)
📄
print-rx.c
(66.92 KB)
📄
print-sctp.c
(23.13 KB)
📄
print-sflow.c
(31.91 KB)
📄
print-sip.c
(1.29 KB)
📄
print-sl.c
(6.95 KB)
📄
print-sll.c
(9.2 KB)
📄
print-slow.c
(25.17 KB)
📄
print-smb.c
(43.19 KB)
📄
print-smtp.c
(983 B)
📄
print-snmp.c
(43.17 KB)
📄
print-stp.c
(17.18 KB)
📄
print-sunatm.c
(3.27 KB)
📄
print-sunrpc.c
(7.85 KB)
📄
print-symantec.c
(3.78 KB)
📄
print-syslog.c
(3.96 KB)
📄
print-tcp.c
(35.84 KB)
📄
print-telnet.c
(15.02 KB)
📄
print-tftp.c
(5.2 KB)
📄
print-timed.c
(4.74 KB)
📄
print-tipc.c
(11.53 KB)
📄
print-token.c
(7.96 KB)
📄
print-udld.c
(5.47 KB)
📄
print-udp.c
(21.28 KB)
📄
print-usb.c
(4.18 KB)
📄
print-vjc.c
(4.45 KB)
📄
print-vqp.c
(6.8 KB)
📄
print-vrrp.c
(6.37 KB)
📄
print-vtp.c
(13.56 KB)
📄
print-vxlan-gpe.c
(3.46 KB)
📄
print-vxlan.c
(2.21 KB)
📄
print-wb.c
(10.93 KB)
📄
print-zephyr.c
(8.03 KB)
📄
print-zeromq.c
(7.5 KB)
📄
print.c
(11.54 KB)
📄
print.h
(1.78 KB)
📄
rpc_auth.h
(2.77 KB)
📄
rpc_msg.h
(3.19 KB)
📄
rpl.h
(4.88 KB)
📄
send-ack.awk
(1.56 KB)
📄
setsignal.c
(3.27 KB)
📄
setsignal.h
(1.24 KB)
📄
signature.c
(5.58 KB)
📄
signature.h
(1.12 KB)
📄
slcompress.h
(3.55 KB)
📄
smb.h
(5.38 KB)
📄
smbutil.c
(63.88 KB)
📄
stime.awk
(567 B)
📄
strtoaddr.c
(5.34 KB)
📄
strtoaddr.h
(992 B)
📄
tcp.h
(5.02 KB)
📄
tcpdump.1.in
(60.82 KB)
📄
tcpdump.c
(69.76 KB)
📄
timeval-operations.h
(3.19 KB)
📄
udp.h
(8.25 KB)
📄
util-print.c
(23.75 KB)
📄
vfprintf.c
(1.62 KB)
Editing: print-l2tp.c
/* * Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution, and (3) all advertising materials mentioning * features or use of this software display the following acknowledgement: * ``This product includes software developed by the University of California, * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of * the University nor the names of its contributors may be used to endorse * or promote products derived from this software without specific prior * written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * L2TP support contributed by Motonori Shindo (mshindo@mshindo.net) */ /* \summary: Layer Two Tunneling Protocol (L2TP) printer */ /* specification: RFC 2661 */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include <netdissect-stdinc.h> #include "netdissect.h" #include "extract.h" #define L2TP_FLAG_TYPE 0x8000 /* Type (0=Data, 1=Control) */ #define L2TP_FLAG_LENGTH 0x4000 /* Length */ #define L2TP_FLAG_SEQUENCE 0x0800 /* Sequence */ #define L2TP_FLAG_OFFSET 0x0200 /* Offset */ #define L2TP_FLAG_PRIORITY 0x0100 /* Priority */ #define L2TP_VERSION_MASK 0x000f /* Version Mask */ #define L2TP_VERSION_L2F 0x0001 /* L2F */ #define L2TP_VERSION_L2TP 0x0002 /* L2TP */ #define L2TP_AVP_HDR_FLAG_MANDATORY 0x8000 /* Mandatory Flag */ #define L2TP_AVP_HDR_FLAG_HIDDEN 0x4000 /* Hidden Flag */ #define L2TP_AVP_HDR_LEN_MASK 0x03ff /* Length Mask */ #define L2TP_FRAMING_CAP_SYNC_MASK 0x00000001 /* Synchronous */ #define L2TP_FRAMING_CAP_ASYNC_MASK 0x00000002 /* Asynchronous */ #define L2TP_FRAMING_TYPE_SYNC_MASK 0x00000001 /* Synchronous */ #define L2TP_FRAMING_TYPE_ASYNC_MASK 0x00000002 /* Asynchronous */ #define L2TP_BEARER_CAP_DIGITAL_MASK 0x00000001 /* Digital */ #define L2TP_BEARER_CAP_ANALOG_MASK 0x00000002 /* Analog */ #define L2TP_BEARER_TYPE_DIGITAL_MASK 0x00000001 /* Digital */ #define L2TP_BEARER_TYPE_ANALOG_MASK 0x00000002 /* Analog */ /* Authen Type */ #define L2TP_AUTHEN_TYPE_RESERVED 0x0000 /* Reserved */ #define L2TP_AUTHEN_TYPE_TEXTUAL 0x0001 /* Textual username/password exchange */ #define L2TP_AUTHEN_TYPE_CHAP 0x0002 /* PPP CHAP */ #define L2TP_AUTHEN_TYPE_PAP 0x0003 /* PPP PAP */ #define L2TP_AUTHEN_TYPE_NO_AUTH 0x0004 /* No Authentication */ #define L2TP_AUTHEN_TYPE_MSCHAPv1 0x0005 /* MSCHAPv1 */ #define L2TP_PROXY_AUTH_ID_MASK 0x00ff static const char tstr[] = " [|l2tp]"; #define L2TP_MSGTYPE_SCCRQ 1 /* Start-Control-Connection-Request */ #define L2TP_MSGTYPE_SCCRP 2 /* Start-Control-Connection-Reply */ #define L2TP_MSGTYPE_SCCCN 3 /* Start-Control-Connection-Connected */ #define L2TP_MSGTYPE_STOPCCN 4 /* Stop-Control-Connection-Notification */ #define L2TP_MSGTYPE_HELLO 6 /* Hello */ #define L2TP_MSGTYPE_OCRQ 7 /* Outgoing-Call-Request */ #define L2TP_MSGTYPE_OCRP 8 /* Outgoing-Call-Reply */ #define L2TP_MSGTYPE_OCCN 9 /* Outgoing-Call-Connected */ #define L2TP_MSGTYPE_ICRQ 10 /* Incoming-Call-Request */ #define L2TP_MSGTYPE_ICRP 11 /* Incoming-Call-Reply */ #define L2TP_MSGTYPE_ICCN 12 /* Incoming-Call-Connected */ #define L2TP_MSGTYPE_CDN 14 /* Call-Disconnect-Notify */ #define L2TP_MSGTYPE_WEN 15 /* WAN-Error-Notify */ #define L2TP_MSGTYPE_SLI 16 /* Set-Link-Info */ static const struct tok l2tp_msgtype2str[] = { { L2TP_MSGTYPE_SCCRQ, "SCCRQ" }, { L2TP_MSGTYPE_SCCRP, "SCCRP" }, { L2TP_MSGTYPE_SCCCN, "SCCCN" }, { L2TP_MSGTYPE_STOPCCN, "StopCCN" }, { L2TP_MSGTYPE_HELLO, "HELLO" }, { L2TP_MSGTYPE_OCRQ, "OCRQ" }, { L2TP_MSGTYPE_OCRP, "OCRP" }, { L2TP_MSGTYPE_OCCN, "OCCN" }, { L2TP_MSGTYPE_ICRQ, "ICRQ" }, { L2TP_MSGTYPE_ICRP, "ICRP" }, { L2TP_MSGTYPE_ICCN, "ICCN" }, { L2TP_MSGTYPE_CDN, "CDN" }, { L2TP_MSGTYPE_WEN, "WEN" }, { L2TP_MSGTYPE_SLI, "SLI" }, { 0, NULL } }; #define L2TP_AVP_MSGTYPE 0 /* Message Type */ #define L2TP_AVP_RESULT_CODE 1 /* Result Code */ #define L2TP_AVP_PROTO_VER 2 /* Protocol Version */ #define L2TP_AVP_FRAMING_CAP 3 /* Framing Capabilities */ #define L2TP_AVP_BEARER_CAP 4 /* Bearer Capabilities */ #define L2TP_AVP_TIE_BREAKER 5 /* Tie Breaker */ #define L2TP_AVP_FIRM_VER 6 /* Firmware Revision */ #define L2TP_AVP_HOST_NAME 7 /* Host Name */ #define L2TP_AVP_VENDOR_NAME 8 /* Vendor Name */ #define L2TP_AVP_ASSND_TUN_ID 9 /* Assigned Tunnel ID */ #define L2TP_AVP_RECV_WIN_SIZE 10 /* Receive Window Size */ #define L2TP_AVP_CHALLENGE 11 /* Challenge */ #define L2TP_AVP_Q931_CC 12 /* Q.931 Cause Code */ #define L2TP_AVP_CHALLENGE_RESP 13 /* Challenge Response */ #define L2TP_AVP_ASSND_SESS_ID 14 /* Assigned Session ID */ #define L2TP_AVP_CALL_SER_NUM 15 /* Call Serial Number */ #define L2TP_AVP_MINIMUM_BPS 16 /* Minimum BPS */ #define L2TP_AVP_MAXIMUM_BPS 17 /* Maximum BPS */ #define L2TP_AVP_BEARER_TYPE 18 /* Bearer Type */ #define L2TP_AVP_FRAMING_TYPE 19 /* Framing Type */ #define L2TP_AVP_PACKET_PROC_DELAY 20 /* Packet Processing Delay (OBSOLETE) */ #define L2TP_AVP_CALLED_NUMBER 21 /* Called Number */ #define L2TP_AVP_CALLING_NUMBER 22 /* Calling Number */ #define L2TP_AVP_SUB_ADDRESS 23 /* Sub-Address */ #define L2TP_AVP_TX_CONN_SPEED 24 /* (Tx) Connect Speed */ #define L2TP_AVP_PHY_CHANNEL_ID 25 /* Physical Channel ID */ #define L2TP_AVP_INI_RECV_LCP 26 /* Initial Received LCP CONFREQ */ #define L2TP_AVP_LAST_SENT_LCP 27 /* Last Sent LCP CONFREQ */ #define L2TP_AVP_LAST_RECV_LCP 28 /* Last Received LCP CONFREQ */ #define L2TP_AVP_PROXY_AUTH_TYPE 29 /* Proxy Authen Type */ #define L2TP_AVP_PROXY_AUTH_NAME 30 /* Proxy Authen Name */ #define L2TP_AVP_PROXY_AUTH_CHAL 31 /* Proxy Authen Challenge */ #define L2TP_AVP_PROXY_AUTH_ID 32 /* Proxy Authen ID */ #define L2TP_AVP_PROXY_AUTH_RESP 33 /* Proxy Authen Response */ #define L2TP_AVP_CALL_ERRORS 34 /* Call Errors */ #define L2TP_AVP_ACCM 35 /* ACCM */ #define L2TP_AVP_RANDOM_VECTOR 36 /* Random Vector */ #define L2TP_AVP_PRIVATE_GRP_ID 37 /* Private Group ID */ #define L2TP_AVP_RX_CONN_SPEED 38 /* (Rx) Connect Speed */ #define L2TP_AVP_SEQ_REQUIRED 39 /* Sequencing Required */ #define L2TP_AVP_PPP_DISCON_CC 46 /* PPP Disconnect Cause Code - RFC 3145 */ static const struct tok l2tp_avp2str[] = { { L2TP_AVP_MSGTYPE, "MSGTYPE" }, { L2TP_AVP_RESULT_CODE, "RESULT_CODE" }, { L2TP_AVP_PROTO_VER, "PROTO_VER" }, { L2TP_AVP_FRAMING_CAP, "FRAMING_CAP" }, { L2TP_AVP_BEARER_CAP, "BEARER_CAP" }, { L2TP_AVP_TIE_BREAKER, "TIE_BREAKER" }, { L2TP_AVP_FIRM_VER, "FIRM_VER" }, { L2TP_AVP_HOST_NAME, "HOST_NAME" }, { L2TP_AVP_VENDOR_NAME, "VENDOR_NAME" }, { L2TP_AVP_ASSND_TUN_ID, "ASSND_TUN_ID" }, { L2TP_AVP_RECV_WIN_SIZE, "RECV_WIN_SIZE" }, { L2TP_AVP_CHALLENGE, "CHALLENGE" }, { L2TP_AVP_Q931_CC, "Q931_CC", }, { L2TP_AVP_CHALLENGE_RESP, "CHALLENGE_RESP" }, { L2TP_AVP_ASSND_SESS_ID, "ASSND_SESS_ID" }, { L2TP_AVP_CALL_SER_NUM, "CALL_SER_NUM" }, { L2TP_AVP_MINIMUM_BPS, "MINIMUM_BPS" }, { L2TP_AVP_MAXIMUM_BPS, "MAXIMUM_BPS" }, { L2TP_AVP_BEARER_TYPE, "BEARER_TYPE" }, { L2TP_AVP_FRAMING_TYPE, "FRAMING_TYPE" }, { L2TP_AVP_PACKET_PROC_DELAY, "PACKET_PROC_DELAY" }, { L2TP_AVP_CALLED_NUMBER, "CALLED_NUMBER" }, { L2TP_AVP_CALLING_NUMBER, "CALLING_NUMBER" }, { L2TP_AVP_SUB_ADDRESS, "SUB_ADDRESS" }, { L2TP_AVP_TX_CONN_SPEED, "TX_CONN_SPEED" }, { L2TP_AVP_PHY_CHANNEL_ID, "PHY_CHANNEL_ID" }, { L2TP_AVP_INI_RECV_LCP, "INI_RECV_LCP" }, { L2TP_AVP_LAST_SENT_LCP, "LAST_SENT_LCP" }, { L2TP_AVP_LAST_RECV_LCP, "LAST_RECV_LCP" }, { L2TP_AVP_PROXY_AUTH_TYPE, "PROXY_AUTH_TYPE" }, { L2TP_AVP_PROXY_AUTH_NAME, "PROXY_AUTH_NAME" }, { L2TP_AVP_PROXY_AUTH_CHAL, "PROXY_AUTH_CHAL" }, { L2TP_AVP_PROXY_AUTH_ID, "PROXY_AUTH_ID" }, { L2TP_AVP_PROXY_AUTH_RESP, "PROXY_AUTH_RESP" }, { L2TP_AVP_CALL_ERRORS, "CALL_ERRORS" }, { L2TP_AVP_ACCM, "ACCM" }, { L2TP_AVP_RANDOM_VECTOR, "RANDOM_VECTOR" }, { L2TP_AVP_PRIVATE_GRP_ID, "PRIVATE_GRP_ID" }, { L2TP_AVP_RX_CONN_SPEED, "RX_CONN_SPEED" }, { L2TP_AVP_SEQ_REQUIRED, "SEQ_REQUIRED" }, { L2TP_AVP_PPP_DISCON_CC, "PPP_DISCON_CC" }, { 0, NULL } }; static const struct tok l2tp_authentype2str[] = { { L2TP_AUTHEN_TYPE_RESERVED, "Reserved" }, { L2TP_AUTHEN_TYPE_TEXTUAL, "Textual" }, { L2TP_AUTHEN_TYPE_CHAP, "CHAP" }, { L2TP_AUTHEN_TYPE_PAP, "PAP" }, { L2TP_AUTHEN_TYPE_NO_AUTH, "No Auth" }, { L2TP_AUTHEN_TYPE_MSCHAPv1, "MS-CHAPv1" }, { 0, NULL } }; #define L2TP_PPP_DISCON_CC_DIRECTION_GLOBAL 0 #define L2TP_PPP_DISCON_CC_DIRECTION_AT_PEER 1 #define L2TP_PPP_DISCON_CC_DIRECTION_AT_LOCAL 2 static const struct tok l2tp_cc_direction2str[] = { { L2TP_PPP_DISCON_CC_DIRECTION_GLOBAL, "global error" }, { L2TP_PPP_DISCON_CC_DIRECTION_AT_PEER, "at peer" }, { L2TP_PPP_DISCON_CC_DIRECTION_AT_LOCAL,"at local" }, { 0, NULL } }; #if 0 static char *l2tp_result_code_StopCCN[] = { "Reserved", "General request to clear control connection", "General error--Error Code indicates the problem", "Control channel already exists", "Requester is not authorized to establish a control channel", "The protocol version of the requester is not supported", "Requester is being shut down", "Finite State Machine error" #define L2TP_MAX_RESULT_CODE_STOPCC_INDEX 8 }; #endif #if 0 static char *l2tp_result_code_CDN[] = { "Reserved", "Call disconnected due to loss of carrier", "Call disconnected for the reason indicated in error code", "Call disconnected for administrative reasons", "Call failed due to lack of appropriate facilities being " \ "available (temporary condition)", "Call failed due to lack of appropriate facilities being " \ "available (permanent condition)", "Invalid destination", "Call failed due to no carrier detected", "Call failed due to detection of a busy signal", "Call failed due to lack of a dial tone", "Call was not established within time allotted by LAC", "Call was connected but no appropriate framing was detected" #define L2TP_MAX_RESULT_CODE_CDN_INDEX 12 }; #endif #if 0 static char *l2tp_error_code_general[] = { "No general error", "No control connection exists yet for this LAC-LNS pair", "Length is wrong", "One of the field values was out of range or " \ "reserved field was non-zero" "Insufficient resources to handle this operation now", "The Session ID is invalid in this context", "A generic vendor-specific error occurred in the LAC", "Try another" #define L2TP_MAX_ERROR_CODE_GENERAL_INDEX 8 }; #endif /******************************/ /* generic print out routines */ /******************************/ static void print_string(netdissect_options *ndo, const u_char *dat, u_int length) { u_int i; for (i=0; i<length; i++) { ND_PRINT((ndo, "%c", *dat++)); } } static void print_octets(netdissect_options *ndo, const u_char *dat, u_int length) { u_int i; for (i=0; i<length; i++) { ND_PRINT((ndo, "%02x", *dat++)); } } static void print_16bits_val(netdissect_options *ndo, const uint8_t *dat) { ND_PRINT((ndo, "%u", EXTRACT_16BITS(dat))); } static void print_32bits_val(netdissect_options *ndo, const uint8_t *dat) { ND_PRINT((ndo, "%u", EXTRACT_32BITS(dat))); } /***********************************/ /* AVP-specific print out routines */ /***********************************/ static void l2tp_msgtype_print(netdissect_options *ndo, const u_char *dat, u_int length) { if (length < 2) { ND_PRINT((ndo, "AVP too short")); return; } ND_PRINT((ndo, "%s", tok2str(l2tp_msgtype2str, "MSGTYPE-#%u", EXTRACT_16BITS(dat)))); } static void l2tp_result_code_print(netdissect_options *ndo, const u_char *dat, u_int length) { /* Result Code */ if (length < 2) { ND_PRINT((ndo, "AVP too short")); return; } ND_PRINT((ndo, "%u", EXTRACT_16BITS(dat))); dat += 2; length -= 2; /* Error Code (opt) */ if (length == 0) return; if (length < 2) { ND_PRINT((ndo, " AVP too short")); return; } ND_PRINT((ndo, "/%u", EXTRACT_16BITS(dat))); dat += 2; length -= 2; /* Error Message (opt) */ if (length == 0) return; ND_PRINT((ndo, " ")); print_string(ndo, dat, length); } static void l2tp_proto_ver_print(netdissect_options *ndo, const u_char *dat, u_int length) { if (length < 2) { ND_PRINT((ndo, "AVP too short")); return; } ND_PRINT((ndo, "%u.%u", (EXTRACT_16BITS(dat) >> 8), (EXTRACT_16BITS(dat) & 0xff))); } static void l2tp_framing_cap_print(netdissect_options *ndo, const u_char *dat, u_int length) { if (length < 4) { ND_PRINT((ndo, "AVP too short")); return; } if (EXTRACT_32BITS(dat) & L2TP_FRAMING_CAP_ASYNC_MASK) { ND_PRINT((ndo, "A")); } if (EXTRACT_32BITS(dat) & L2TP_FRAMING_CAP_SYNC_MASK) { ND_PRINT((ndo, "S")); } } static void l2tp_bearer_cap_print(netdissect_options *ndo, const u_char *dat, u_int length) { if (length < 4) { ND_PRINT((ndo, "AVP too short")); return; } if (EXTRACT_32BITS(dat) & L2TP_BEARER_CAP_ANALOG_MASK) { ND_PRINT((ndo, "A")); } if (EXTRACT_32BITS(dat) & L2TP_BEARER_CAP_DIGITAL_MASK) { ND_PRINT((ndo, "D")); } } static void l2tp_q931_cc_print(netdissect_options *ndo, const u_char *dat, u_int length) { if (length < 3) { ND_PRINT((ndo, "AVP too short")); return; } print_16bits_val(ndo, dat); ND_PRINT((ndo, ", %02x", EXTRACT_8BITS(dat + 2))); dat += 3; length -= 3; if (length != 0) { ND_PRINT((ndo, " ")); print_string(ndo, dat, length); } } static void l2tp_bearer_type_print(netdissect_options *ndo, const u_char *dat, u_int length) { if (length < 4) { ND_PRINT((ndo, "AVP too short")); return; } if (EXTRACT_32BITS(dat) & L2TP_BEARER_TYPE_ANALOG_MASK) { ND_PRINT((ndo, "A")); } if (EXTRACT_32BITS(dat) & L2TP_BEARER_TYPE_DIGITAL_MASK) { ND_PRINT((ndo, "D")); } } static void l2tp_framing_type_print(netdissect_options *ndo, const u_char *dat, u_int length) { if (length < 4) { ND_PRINT((ndo, "AVP too short")); return; } if (EXTRACT_32BITS(dat) & L2TP_FRAMING_TYPE_ASYNC_MASK) { ND_PRINT((ndo, "A")); } if (EXTRACT_32BITS(dat) & L2TP_FRAMING_TYPE_SYNC_MASK) { ND_PRINT((ndo, "S")); } } static void l2tp_packet_proc_delay_print(netdissect_options *ndo) { ND_PRINT((ndo, "obsolete")); } static void l2tp_proxy_auth_type_print(netdissect_options *ndo, const u_char *dat, u_int length) { if (length < 2) { ND_PRINT((ndo, "AVP too short")); return; } ND_PRINT((ndo, "%s", tok2str(l2tp_authentype2str, "AuthType-#%u", EXTRACT_16BITS(dat)))); } static void l2tp_proxy_auth_id_print(netdissect_options *ndo, const u_char *dat, u_int length) { if (length < 2) { ND_PRINT((ndo, "AVP too short")); return; } ND_PRINT((ndo, "%u", EXTRACT_16BITS(dat) & L2TP_PROXY_AUTH_ID_MASK)); } static void l2tp_call_errors_print(netdissect_options *ndo, const u_char *dat, u_int length) { uint32_t val; if (length < 2) { ND_PRINT((ndo, "AVP too short")); return; } dat += 2; /* skip "Reserved" */ length -= 2; if (length < 4) { ND_PRINT((ndo, "AVP too short")); return; } val = EXTRACT_32BITS(dat); dat += 4; length -= 4; ND_PRINT((ndo, "CRCErr=%u ", val)); if (length < 4) { ND_PRINT((ndo, "AVP too short")); return; } val = EXTRACT_32BITS(dat); dat += 4; length -= 4; ND_PRINT((ndo, "FrameErr=%u ", val)); if (length < 4) { ND_PRINT((ndo, "AVP too short")); return; } val = EXTRACT_32BITS(dat); dat += 4; length -= 4; ND_PRINT((ndo, "HardOver=%u ", val)); if (length < 4) { ND_PRINT((ndo, "AVP too short")); return; } val = EXTRACT_32BITS(dat); dat += 4; length -= 4; ND_PRINT((ndo, "BufOver=%u ", val)); if (length < 4) { ND_PRINT((ndo, "AVP too short")); return; } val = EXTRACT_32BITS(dat); dat += 4; length -= 4; ND_PRINT((ndo, "Timeout=%u ", val)); if (length < 4) { ND_PRINT((ndo, "AVP too short")); return; } val = EXTRACT_32BITS(dat); dat += 4; length -= 4; ND_PRINT((ndo, "AlignErr=%u ", val)); } static void l2tp_accm_print(netdissect_options *ndo, const u_char *dat, u_int length) { uint32_t val; if (length < 2) { ND_PRINT((ndo, "AVP too short")); return; } dat += 2; /* skip "Reserved" */ length -= 2; if (length < 4) { ND_PRINT((ndo, "AVP too short")); return; } val = EXTRACT_32BITS(dat); dat += 4; length -= 4; ND_PRINT((ndo, "send=%08x ", val)); if (length < 4) { ND_PRINT((ndo, "AVP too short")); return; } val = EXTRACT_32BITS(dat); dat += 4; length -= 4; ND_PRINT((ndo, "recv=%08x ", val)); } static void l2tp_ppp_discon_cc_print(netdissect_options *ndo, const u_char *dat, u_int length) { if (length < 5) { ND_PRINT((ndo, "AVP too short")); return; } /* Disconnect Code */ ND_PRINT((ndo, "%04x, ", EXTRACT_16BITS(dat))); dat += 2; length -= 2; /* Control Protocol Number */ ND_PRINT((ndo, "%04x ", EXTRACT_16BITS(dat))); dat += 2; length -= 2; /* Direction */ ND_PRINT((ndo, "%s", tok2str(l2tp_cc_direction2str, "Direction-#%u", EXTRACT_8BITS(dat)))); dat++; length--; if (length != 0) { ND_PRINT((ndo, " ")); print_string(ndo, (const u_char *)dat, length); } } static u_int l2tp_avp_print(netdissect_options *ndo, const u_char *dat, u_int length) { u_int len; uint16_t attr_type; int hidden = FALSE; ND_PRINT((ndo, " ")); ND_TCHECK_16BITS(dat); /* Flags & Length */ len = EXTRACT_16BITS(dat) & L2TP_AVP_HDR_LEN_MASK; /* If it is not long enough to contain the header, we'll give up. */ if (len < 6) goto trunc; /* If it goes past the end of the remaining length of the packet, we'll give up. */ if (len > (u_int)length) goto trunc; /* If it goes past the end of the remaining length of the captured data, we'll give up. */ ND_TCHECK2(*dat, len); /* * After this point, we don't need to check whether we go past * the length of the captured data; however, we *do* need to * check whether we go past the end of the AVP. */ if (EXTRACT_16BITS(dat) & L2TP_AVP_HDR_FLAG_MANDATORY) { ND_PRINT((ndo, "*")); } if (EXTRACT_16BITS(dat) & L2TP_AVP_HDR_FLAG_HIDDEN) { hidden = TRUE; ND_PRINT((ndo, "?")); } dat += 2; if (EXTRACT_16BITS(dat)) { /* Vendor Specific Attribute */ ND_PRINT((ndo, "VENDOR%04x:", EXTRACT_16BITS(dat))); dat += 2; ND_PRINT((ndo, "ATTR%04x", EXTRACT_16BITS(dat))); dat += 2; ND_PRINT((ndo, "(")); print_octets(ndo, dat, len-6); ND_PRINT((ndo, ")")); } else { /* IETF-defined Attributes */ dat += 2; attr_type = EXTRACT_16BITS(dat); dat += 2; ND_PRINT((ndo, "%s", tok2str(l2tp_avp2str, "AVP-#%u", attr_type))); ND_PRINT((ndo, "(")); if (hidden) { ND_PRINT((ndo, "???")); } else { switch (attr_type) { case L2TP_AVP_MSGTYPE: l2tp_msgtype_print(ndo, dat, len-6); break; case L2TP_AVP_RESULT_CODE: l2tp_result_code_print(ndo, dat, len-6); break; case L2TP_AVP_PROTO_VER: l2tp_proto_ver_print(ndo, dat, len-6); break; case L2TP_AVP_FRAMING_CAP: l2tp_framing_cap_print(ndo, dat, len-6); break; case L2TP_AVP_BEARER_CAP: l2tp_bearer_cap_print(ndo, dat, len-6); break; case L2TP_AVP_TIE_BREAKER: if (len-6 < 8) { ND_PRINT((ndo, "AVP too short")); break; } print_octets(ndo, dat, 8); break; case L2TP_AVP_FIRM_VER: case L2TP_AVP_ASSND_TUN_ID: case L2TP_AVP_RECV_WIN_SIZE: case L2TP_AVP_ASSND_SESS_ID: if (len-6 < 2) { ND_PRINT((ndo, "AVP too short")); break; } print_16bits_val(ndo, dat); break; case L2TP_AVP_HOST_NAME: case L2TP_AVP_VENDOR_NAME: case L2TP_AVP_CALLING_NUMBER: case L2TP_AVP_CALLED_NUMBER: case L2TP_AVP_SUB_ADDRESS: case L2TP_AVP_PROXY_AUTH_NAME: case L2TP_AVP_PRIVATE_GRP_ID: print_string(ndo, dat, len-6); break; case L2TP_AVP_CHALLENGE: case L2TP_AVP_INI_RECV_LCP: case L2TP_AVP_LAST_SENT_LCP: case L2TP_AVP_LAST_RECV_LCP: case L2TP_AVP_PROXY_AUTH_CHAL: case L2TP_AVP_PROXY_AUTH_RESP: case L2TP_AVP_RANDOM_VECTOR: print_octets(ndo, dat, len-6); break; case L2TP_AVP_Q931_CC: l2tp_q931_cc_print(ndo, dat, len-6); break; case L2TP_AVP_CHALLENGE_RESP: if (len-6 < 16) { ND_PRINT((ndo, "AVP too short")); break; } print_octets(ndo, dat, 16); break; case L2TP_AVP_CALL_SER_NUM: case L2TP_AVP_MINIMUM_BPS: case L2TP_AVP_MAXIMUM_BPS: case L2TP_AVP_TX_CONN_SPEED: case L2TP_AVP_PHY_CHANNEL_ID: case L2TP_AVP_RX_CONN_SPEED: if (len-6 < 4) { ND_PRINT((ndo, "AVP too short")); break; } print_32bits_val(ndo, dat); break; case L2TP_AVP_BEARER_TYPE: l2tp_bearer_type_print(ndo, dat, len-6); break; case L2TP_AVP_FRAMING_TYPE: l2tp_framing_type_print(ndo, dat, len-6); 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, dat, len-6); break; case L2TP_AVP_PROXY_AUTH_ID: l2tp_proxy_auth_id_print(ndo, dat, len-6); break; case L2TP_AVP_CALL_ERRORS: l2tp_call_errors_print(ndo, dat, len-6); break; case L2TP_AVP_ACCM: l2tp_accm_print(ndo, dat, len-6); break; case L2TP_AVP_SEQ_REQUIRED: break; /* No Attribute Value */ case L2TP_AVP_PPP_DISCON_CC: l2tp_ppp_discon_cc_print(ndo, dat, len-6); break; default: break; } } ND_PRINT((ndo, ")")); } return (len); trunc: ND_PRINT((ndo, "|...")); return (0); } void l2tp_print(netdissect_options *ndo, const u_char *dat, u_int length) { const u_char *ptr = dat; u_int cnt = 0; /* total octets consumed */ uint16_t pad; int flag_t, flag_l, flag_s, flag_o; uint16_t l2tp_len; flag_t = flag_l = flag_s = flag_o = FALSE; ND_TCHECK2(*ptr, 2); /* Flags & Version */ if ((EXTRACT_16BITS(ptr) & L2TP_VERSION_MASK) == L2TP_VERSION_L2TP) { ND_PRINT((ndo, " l2tp:")); } else if ((EXTRACT_16BITS(ptr) & L2TP_VERSION_MASK) == L2TP_VERSION_L2F) { ND_PRINT((ndo, " l2f:")); return; /* nothing to do */ } else { ND_PRINT((ndo, " Unknown Version, neither L2F(1) nor L2TP(2)")); return; /* nothing we can do */ } ND_PRINT((ndo, "[")); if (EXTRACT_16BITS(ptr) & L2TP_FLAG_TYPE) { flag_t = TRUE; ND_PRINT((ndo, "T")); } if (EXTRACT_16BITS(ptr) & L2TP_FLAG_LENGTH) { flag_l = TRUE; ND_PRINT((ndo, "L")); } if (EXTRACT_16BITS(ptr) & L2TP_FLAG_SEQUENCE) { flag_s = TRUE; ND_PRINT((ndo, "S")); } if (EXTRACT_16BITS(ptr) & L2TP_FLAG_OFFSET) { flag_o = TRUE; ND_PRINT((ndo, "O")); } if (EXTRACT_16BITS(ptr) & L2TP_FLAG_PRIORITY) ND_PRINT((ndo, "P")); ND_PRINT((ndo, "]")); ptr += 2; cnt += 2; if (flag_l) { ND_TCHECK2(*ptr, 2); /* Length */ l2tp_len = EXTRACT_16BITS(ptr); ptr += 2; cnt += 2; } else { l2tp_len = 0; } ND_TCHECK2(*ptr, 2); /* Tunnel ID */ ND_PRINT((ndo, "(%u/", EXTRACT_16BITS(ptr))); ptr += 2; cnt += 2; ND_TCHECK2(*ptr, 2); /* Session ID */ ND_PRINT((ndo, "%u)", EXTRACT_16BITS(ptr))); ptr += 2; cnt += 2; if (flag_s) { ND_TCHECK2(*ptr, 2); /* Ns */ ND_PRINT((ndo, "Ns=%u,", EXTRACT_16BITS(ptr))); ptr += 2; cnt += 2; ND_TCHECK2(*ptr, 2); /* Nr */ ND_PRINT((ndo, "Nr=%u", EXTRACT_16BITS(ptr))); ptr += 2; cnt += 2; } if (flag_o) { ND_TCHECK2(*ptr, 2); /* Offset Size */ pad = EXTRACT_16BITS(ptr); ptr += (2 + pad); cnt += (2 + pad); } if (flag_l) { if (length < l2tp_len) { ND_PRINT((ndo, " Length %u larger than packet", l2tp_len)); return; } length = l2tp_len; } if (length < cnt) { ND_PRINT((ndo, " Length %u smaller than header length", length)); return; } if (flag_t) { if (!flag_l) { ND_PRINT((ndo, " No length")); return; } if (length - cnt == 0) { ND_PRINT((ndo, " ZLB")); } else { /* * Print AVPs. */ while (length - cnt != 0) { u_int avp_length; avp_length = l2tp_avp_print(ndo, ptr, length - cnt); if (avp_length == 0) { /* * Truncated. */ break; } cnt += avp_length; ptr += avp_length; } } } else { ND_PRINT((ndo, " {")); ppp_print(ndo, ptr, length - cnt); ND_PRINT((ndo, "}")); } return; trunc: ND_PRINT((ndo, "%s", tstr)); }
Upload File
Create Folder