📄 pcap.3
字号:
PPP without framing, and the packet begins with the PPP header..TP 5.B DLT_FDDIFDDI.TP 5.B DLT_ATM_RFC1483RFC 1483 LLC/SNAP-encapsulated ATM; the packet begins with an IEEE 802.2LLC header..TP 5.B DLT_RAWraw IP; the packet begins with an IP header..TP 5.B DLT_PPP_SERIALPPP in HDLC-like framing, as per RFC 1662, or Cisco PPP with HDLCframing, as per section 4.3.1 of RFC 1547; the first byte will be 0xFFfor PPP in HDLC-like framing, and will be 0x0F or 0x8F for Cisco PPPwith HDLC framing..TP 5.B DLT_PPP_ETHERPPPoE; the packet begins with a PPPoE header, as per RFC 2516..TP 5.B DLT_C_HDLCCisco PPP with HDLC framing, as per section 4.3.1 of RFC 1547..TP 5.B DLT_IEEE802_11IEEE 802.11 wireless LAN.TP 5.B DLT_FRELAYFrame Relay.TP 5.B DLT_LOOPOpenBSD loopback encapsulation; the link layer header is a 4-byte field, in.I networkbyte order, containing a PF_ value from OpenBSD's.B socket.hfor the network-layer protocol of the packet..IPNote that, if a ``savefile'' is being read, those PF_ values are.I notnecessarily those of the machine reading the capture file..TP 5.B DLT_LINUX_SLLLinux "cooked" capture encapsulation; the link layer header contains, inorder:.RS 10.LPa 2-byte "packet type", in network byte order, which is one of:.RS 5.TP 50packet was sent to us by somebody else.TP 51packet was broadcast by somebody else.TP 52packet was multicast, but not broadcast, by somebody else.TP 53packet was sent by somebody else to somebody else.TP 54packet was sent by us.RE.LPa 2-byte field, in network byte order, containing a Linux ARPHRD_ valuefor the link layer device type;.LPa 2-byte field, in network byte order, containing the length of thelink layer address of the sender of the packet (which could be 0);.LPan 8-byte field containing that number of bytes of the link layer header(if there are more than 8 bytes, only the first 8 are present);.LPa 2-byte field containing an Ethernet protocol type, in network byteorder, or containing 1 for Novell 802.3 frames without an 802.2 LLCheader or 4 for frames beginning with an 802.2 LLC header..RE.TP 5.B DLT_LTALKApple LocalTalk; the packet begins with an AppleTalk LLAP header..TP 5.B DLT_PFLOGOpenBSD pflog; the link layer header contains, in order:.RS 10.LPa 1-byte header length, in host byte order;.LPa 4-byte PF_ value, in host byte order;.LPa 2-byte action code, in network byte order, which is one of:.RS 5.TP 50passed.TP 51dropped.TP 52scrubbed.RE.LPa 2-byte reason code, in network byte order, which is one of:.RS 5.TP 50match.TP 51bad offset.TP 52fragment.TP 53short.TP 54normalize.TP 55memory.RE.LPa 16-character interface name;.LPa 16-character ruleset name (only meaningful if subrule is set);.LPa 4-byte rule number, in network byte order;.LPa 4-byte subrule number, in network byte order;.LPa 1-byte direction, in network byte order, which is one of:.RS 5.TP 50incoming or outgoing.TP 51incoming.TP 52outgoing.RE.RE.TP 5.B DLT_PRISM_HEADERPrism monitor mode information followed by an 802.11 header..TP 5.B DLT_IP_OVER_FCRFC 2625 IP-over-Fibre Channel, with the link-layer header being theNetwork_Header as described in that RFC..TP 5.B DLT_SUNATMSunATM devices; the link layer header contains, in order:.RS 10.LPa 1-byte flag field, containing a direction flag in the uppermost bit,which is set for packets transmitted by the machine and clear forpackets received by the machine, and a 4-byte traffic type in thelow-order 4 bits, which is one of:.RS 5.TP 50raw traffic.TP 51LANE traffic.TP 52LLC-encapsulated traffic.TP 53MARS traffic.TP 54IFMP traffic.TP 55ILMI traffic.TP 56Q.2931 traffic.RE.LPa 1-byte VPI value;.LPa 2-byte VCI field, in network byte order..RE.TP 5.B DLT_IEEE802_11_RADIOlink-layer information followed by an 802.11 header - seehttp://www.shaftnet.org/~pizza/software/capturefrm.txt for a descriptionof the link-layer information..TP 5.B DLT_ARCNET_LINUXARCNET, with no exception frames, reassembled packets rather than rawframes, and an extra 16-bit offset field between the destination hostand type bytes..TP 5.B DLT_LINUX_IRDALinux-IrDA packets, with a.B DLT_LINUX_SLLheader followed by the IrLAP header..TP 5.B DLT_LINUX_LAPDLAPD (Q.921) frames, with a.B DLT_LINUX_SLLheader captured via vISDN..RE.PP.B pcap_list_datalinks()is used to get a list of the supported data link types of the interfaceassociated with the pcap descriptor..B pcap_list_datalinks()allocates an array to hold the list and sets.IR *dlt_buf .The caller is responsible for freeing the array..B \-1is returned on failure;otherwise, the number of data link types in the array is returned..PP.B pcap_set_datalink()is used to set the current data link type of the pcap descriptorto the type specified by.IR dlt ..B \-1is returned on failure..PP.B pcap_datalink_name_to_val()translates a data link type name, which is a.B DLT_name with the.B DLT_removed, to the corresponding data link type value. The translationis case-insensitive. .B \-1is returned on failure..PP.B pcap_datalink_val_to_name()translates a data link type value to the corresponding data link typename. NULL is returned on failure..PP.B pcap_datalink_val_to_description()translates a data link type value to a short description of that datalink type. NULL is returned on failure..PP.B pcap_snapshot()returns the snapshot length specified when.B pcap_open_live()was called..PP.B pcap_is_swapped()returns true if the current ``savefile'' uses a different byte orderthan the current system..PP.B pcap_major_version()returns the major number of the file format of the savefile;.B pcap_minor_version()returns the minor number of the file format of the savefile. Theversion number is stored in the header of the savefile..PP.B pcap_file()returns the standard I/O stream of the ``savefile,'' if a ``savefile''was opened with.BR pcap_open_offline() ,or NULL, if a network device was opened with.BR pcap_open_live() ..PP.B pcap_stats()returns 0 and fills in a.B pcap_statstruct. The values represent packet statistics from the start of therun to the time of the call. If there is an error or the underlyingpacket capture doesn't support packet statistics, \-1 is returned andthe error text can be obtained with.B pcap_perror()or.BR pcap_geterr() ..B pcap_stats()is supported only on live captures, not on ``savefiles''; no statisticsare stored in ``savefiles'', so no statistics are available when readingfrom a ``savefile''..PP.B pcap_fileno()returns the file descriptor number from which captured packets are read,if a network device was opened with.BR pcap_open_live() ,or \-1, if a ``savefile'' was opened with.BR pcap_open_offline() ..PP.B pcap_get_selectable_fd()returns, on UNIX, a file descriptor number for a file descriptor onwhich one cando a.B select()or.B poll()to wait for it to be possible to read packets without blocking, if sucha descriptor exists, or \-1, if no such descriptor exists. Some networkdevices opened with.B pcap_open_live()do not support.B select()or.B poll()(for example, regular network devices on FreeBSD 4.3 and 4.4, and EndaceDAG devices), so \-1 is returned for those devices..PPNote that on most versions of most BSDs (including Mac OS X).B select()and.B poll()do not work correctly on BPF devices;.B pcap_get_selectable_fd()will return a file descriptor on most of those versions (the exceptionsbeing FreeBSD 4.3 and 4.4), a simple.B select()or.B poll()will not return even after a timeout specified in.B pcap_open_live()expires. To work around this, an application that uses.B select()or.B poll()to wait for packets to arrive must put the.B pcap_tin non-blocking mode, and must arrange that the.B select()or.B poll()have a timeout less than or equal to the timeout specified in.BR pcap_open_live() ,and must try to read packets after that timeout expires, regardless ofwhether.B select()or.B poll()indicated that the file descriptor for the.B pcap_tis ready to be read or not. (That workaround will not work in FreeBSD4.3 and later; however, in FreeBSD 4.6 and later,.B select()and.B poll()work correctly on BPF devices, so the workaround isn't necessary,although it does no harm.).PP.B pcap_get_selectable_fd()is not available on Windows..PP.B pcap_perror()prints the text of the last pcap library error on.BR stderr ,prefixed by.IR prefix ..PP.B pcap_geterr()returns the error text pertaining to the last pcap library error..BR NOTE :the pointer it returns will no longer point to a valid error messagestring after the.B pcap_tpassed to it is closed; you must use or copy the string before closingthe.BR pcap_t ..PP.B pcap_strerror()is provided in case.BR strerror (1)isn't available..PP.B pcap_lib_version()returns a pointer to a string giving information about the version ofthe libpcap library being used; note that it contains more informationthan just a version number..PP.B pcap_close()closes the files associated with.I pand deallocates resources..PP.B pcap_dump_file()returns the standard I/O stream of the ``savefile'' opened by.BR pcap_dump_open()..PP.B pcap_dump_flush()flushes the output buffer to the ``savefile,'' so that any packetswritten with.B pcap_dump()but not yet written to the ``savefile'' will be written..B \-1is returned on error, 0 on success..PP.B pcap_dump_ftell()returns the current file position for the ``savefile'', representing thenumber of bytes written by.B pcap_dump_open()and.BR pcap_dump() ..B \-1is returned on error..PP.B pcap_dump_close()closes the ``savefile.''.PP.SH SEE ALSOtcpdump(1), tcpslice(1).SH AUTHORSThe original authors are:.LPVan Jacobson,Craig Leres andSteven McCanne, all of theLawrence Berkeley National Laboratory, University of California, Berkeley, CA..LPThe current version is available from "The Tcpdump Group"'s Web site at.LP.RS.I http://www.tcpdump.org/.RE.SH BUGSPlease send problems, bugs, questions, desirable enhancements, etc. to:.LP.RStcpdump-workers@tcpdump.org.RE.LPPlease send source code contributions, etc. to:.LP.RSpatches@tcpdump.org.RE
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -