summaryrefslogtreecommitdiff
path: root/lib/libpcap
AgeCommit message (Collapse)Author
2020-09-12Fix byte order handling for DLT_LOOP linkskn
Fixing filters on DLT_LOOP revealed that we treat DLT_NULL, DLT_ENC and DLT_LOOP the same way even though DLT_LOOP stores the AF value in network not byte order like the rest. This amends the missing conversion which ought to land with the recent commit exposing the byte order mismatch: revision 1.53 date: 2020/07/21 22:44:55; author: dlg; state: Exp; lines: +2 -2; DLT_LOOP does have a link header, so tell pcap-filter so it can use it. ... debugged with and ok kn@ Discussed with bluhm who reported src/regress/sys/netinet6/rip6cksum/ failing on i386 after above commit. The comment in this commit is taken from libpcap upstream as is modulo additional file-save related byte-order handling which we don't seem to do. OK bluhm
2020-08-03crank the major cos grammar.c has grown.David Gwynne
pointed out by tb@, who also provided the diff. maybe someone should/could add a Symbols.list here? ok tb@ deraadt@
2020-08-03add "sample NUM" so you can ask to capture 1/NUM packets from a filter.David Gwynne
the use of the sample keyword matches similar config in other products. NUM can be a number between 2 and 1048576, and is used to divide 0x100000000 into a threshold that is then compared against a randomly generated number produced by a load of BPF_RND. having sampling as part of the grammar means you can write things like "icmp or sample 128". this lets you capture all icmp traffic and a sample of the rest of the traffic. ok jmatthew@ kn@ tb@
2020-08-03add support for handling loads from BPF_RND.David Gwynne
this adds "rnd" and "random" as keywords in the grammar, and handles them as an arithmetic operator. the decoder recognises the load, so tcpdump can print it as 'ld #random'. most of the handling is copied from the "len"/"length" keywoard handling that generates and decodes a load of the actual wire length of the packet. ok jmatthew@ tb@ kn@
2020-07-21DLT_LOOP does have a link header, so tell pcap-filter so it can use it.David Gwynne
matthieu@ reported that asking tcpdump to look at ip or ip6 traffic on a wg(4) interface caused all packets to be captured. this is because pcap assumes that if your link type doesn't have a link header then it is always ip or ip6 (which is weird anyway) and captures everything. there was already code to generate a filter for the DLT_LOOP link header, it was just bypassed cos earlier code said that there wasn't one. debugged with and ok kn@
2020-05-29from edgar pettijohn: correct return type in pcap_open_live.3;Jason McIntyre
ok djm
2020-05-27add support for pcap_breakloop when reading packets from files.David Gwynne
djm pulled support in for pcap_breakloop on the bpf side of things, this makes it work when reading files too. from Caspar Schutijser lteo@ seems keen ok djm@
2019-12-17Fix bogus ".It .Cm"Jeremie Courreges-Anglas
2019-11-28Fix typo in comment in struct pcap_pkthdrakoshibe
2019-09-25the mentioned .Fn functions are in a another file, so .Xr themTheo de Raadt
ok jmc
2019-09-25pcap-filter now section 5: adjust XrJason McIntyre
2019-09-25mdoc version of pcap-filter;Jason McIntyre
conversion suggested by deraadt, as well as renaming from section 7 to section 5; ok deraadt
2019-09-03pcap-filter(3) is not a function, it is a language description. It wasTheo de Raadt
mostly cobbled together from a pre-mandoc tcpdump manual page, and desperately needs some loving. First step is to name it right. Discussed with jmc
2019-08-30there is no pcap(3) function, "man pcap" returns an incorrect result.Theo de Raadt
this page should be called by one of the functions, so i chose the first one: pcap_open_live(3)
2019-07-19add "slow" to the list of ethernet protocol names.David Gwynne
this allows "tcpdump ether proto slow", which makes looking at lacp frames a bit easier.
2019-06-28When system calls indicate an error they return -1, not some arbitraryTheo de Raadt
value < 0. errno is only updated in this case. Change all (most?) callers of syscalls to follow this better, and let's see if this strictness helps us in the future.
2018-12-13further document pcap_dump; from jan staryJason McIntyre
text tweaked and ok djm
2018-12-12some pcap_setdirection details; from jan staryJason McIntyre
ok djm
2018-12-09add basic MPLS filtering supportdenis
OK claudio@ jca@
2018-11-10unbreak VLAN filteringdenis
OK dlg@
2018-11-09fix a typodenis
OK jca@ (from a long time ago...)
2018-06-03Sync manual with the const changes introduced in pcap.h rev 1.20.Theo Buehler
2018-06-03Change some libpcap functions which use pointers as arguments andStuart Henderson
returns to const pointers: - the prefix argument to pcap_perror(); - the return value of pcap_strerror(); - the filter expression argument to pcap_compile() and pcap_compile_nopcap(); - the BPF filter program argument to bpf_image(). Matches changes made earlier in tcpdump.org's version of libpcap. From Guy Harris, ok tb@, been through a bulk ports build.
2018-04-26Convert a format string variable to a static const char[] to reduce warningsPhilip Guenther
ok tb@ millert@ krw@
2018-04-05Import pcap_set_immediate_mode() from mainline libpcap which allows aLawrence Teo
libpcap-based program to process packets as soon as they arrive. feedback from jasper@ ok jca@ (a long time ago)
2018-02-06recognise DLT_PPP_SERIAL.David Gwynne
shlib version doesnt need a bump before no new symbols were added or removed. part of a larger diff that was ok sthen@
2018-02-03Simple USBPcap parser for tcpdump(8). Raw dumps can be nicely analysedMartin Pieuchot
in wireshark. ok deraadt@, dlg@
2018-01-01Fix wrong ETHERTYPE_IPV6denis
OK jca@ kettenis@ job@
2017-07-09use working boilerplate for yacc/lex instead of homemade rules.Marc Espie
okay millert@ (forgot the obvious scanner.l tweak in my diff)
2017-04-27Remove the "volatile" attribute from bpf_error(). The "volatile"Todd C. Miller
attribute is an obsolete way of saying "noreturn". clang doesn't recognize it and the function is already marked __dead so it is superfluous anyway.
2017-04-19Switch base tools from /dev/bpf0 to /dev/bpf. Now that /dev/bpf has beenMartin Natano
around for two releases, it should be safe to do so. ok bluhm deraadt sthen tb yasuoka
2016-12-02add "lldp" to the ether protocol name db.David Gwynne
this lets me go "tcpdump ether proto lldp" to easily read lldp packets off the wire without other noise getting in the way. ok deraadt@ jca@ sthen@
2016-11-29Stop exporting the eproto_db array, export a pointer to it instead.Jeremie Courreges-Anglas
tcpdump directly uses eproto_db even though it is not part of the libpcap API. This means that we can't freely add members to this array, else ld.so complains about size mismatches. Keep the data in a static array instead and make it usable by tcpdump through a pointer whose size won't change in the future. A minor bump is enough here for ld.so to stop complaining. While here, mark _eproto_db and llc_db as const, as they are meant to be. Suggested by and ok deraadt@
2016-11-20Extend the DLT_OPENFLOW header to include the switch datapath id.Reyk Floeter
OK rzalamena@
2016-11-16Add new DLT_OPENFLOW link-type to allow using tcpdump to debug switch(4),Reyk Floeter
eg. tcpdump -y openflow -i switch0 Includes a minor bump for libpcap. Feedback and OK rzalamena@
2016-10-17Add missing argument names for pcap_offline_filter.Lawrence Teo
2016-05-08Use /dev/bpf0 instead of /dev/bpf (without loop though), as suggested byMartin Natano
sthen@. to make remote upgrades without media less painful. ok tb@
2016-05-03Move to /dev/bpf; ok lteoMartin Natano
2016-04-06bad spell of whether...Jason McIntyre
2016-04-06add two functions from libpcap-1.7.4 which are required by at least gopacketJasper Lievisse Adriaanse
ok lteo@ "go for it" dlg@
2016-04-05Move more fcntl(,F_GETFL,0) -> fcntl(,F_GETFL).Kenneth R Westerback
No functional change. ok guenther@
2016-04-02refactor bpf_filter a bit.David Gwynne
the code was confusing around how it dealt with packets in mbufs vs plain memory buffers with a lenght. this renames bpf_filter to _bpf_filter, and changes it so the packet memory is referred to by an opaque pointer, and callers have to provide a set of operations to extra values from that opaque pointer. bpf_filter is now provided as a wrapper around _bpf_filter. it provides a set of operators that work on a straight buffer with a lenght. this also adds a bpf_mfilter function which takes an mbuf instead of a buffer, and it provides explicit operations for extracting values from mbufs. if we want to use bpf filters against other data structures (usb or scsi packets maybe?) we are able to provide functions for extracting payloads from them and use _bpf_filter as is. ok canacar@
2016-03-30for some time now mandoc has not required MLINKS to functionJason McIntyre
correctly - logically complete that now by removing MLINKS from base; authors need only to ensure there is an entry in NAME for any function/ util being added. MLINKS will still work, and remain for perl to ease upgrades; ok nicm (curses) bcook (ssl) ok schwarze, who provided a lot of feedback and assistance ok tb natano jung
2016-02-05Use the correct structure size when allocating the array for nodes.Can Erkin Acar
ok tb@ millert@
2015-12-22remove NULL-checks before free()mmcc
2015-11-17Remove register keyword.mmcc
ok deraadt@
2015-11-17memory.h -> string.hmmcc
ok deraadt@
2015-11-15update NAME; ok schwarzeJason McIntyre
2015-10-24Cast isxdigit()'s argument to unsigned char.mmcc
ok guenther@
2015-10-24Cast ctype function arguments to unsigned char.mmcc
ok guenther@