aboutsummaryrefslogtreecommitdiff
path: root/pcap-dlpi.c
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix build error on HP-UX.Guy Harris2011-01-151-7/+9
|
* Treat either EPERM or EACCES as "no soup for you".Guy Harris2010-09-211-3/+4
|
* Return PCAP_ERROR_PROMISC_PERM_DENIED if you have permission to open theGuy Harris2010-09-211-37/+47
| | | | | | | | | | | | | DLPI device but don't have permission to put the interface in promiscuous mode; some systems using DLPI work that way. Change the libdlpi code to return a warning if you *are* using physical promiscuous mode and you fail to turn on SAP promiscuous mode, not if you *aren't* using physical promiscuous mode and you fail to turn on SAP promiscuous mode; that matches with the no-libdlpi code does, and matches what the comment says. Pull dlattachreq up into dl_doattach().
* Squelch warnings about type punning.Guy Harris2010-02-231-4/+10
|
* dlp->dl_length might be an unsigned long; cast it to unsigned long andGuy Harris2009-07-021-2/+2
| | | | | print it with %lu, so the code works regardless of whether it's an unsigned int or an unsigned long.
* From Albert Chin: the "ss" variable is defined only if bufmod isguy2008-12-021-2/+2
| | | | | | | | available, but is set unconditionally. In addition, we might as well just put all the code that handles bufmod inside a single #ifdef HAVE_SYS_BUFMOD_H/#endif pair; on Solaris, you always have bufmod, so the code would work, but it's cleaner that way.
* Turn close_op into cleanup_op; the routine that handles it can also beguy2008-04-141-12/+10
| | | | | | | | | | | | | | | | | | | | | | | used to clean up after a failed pcap_activate() call. Convert the existing close_op routines to cleanup_op routines, and use them to clean up; rename pcap_close_common() to pcap_cleanup_live_common(), and use it directly if there's no platform-dependent cleanup needed. That means we don't have to write the same cleanup code twice (and possibly forget stuff in the version done on a failed pcap_activate() call). Have the cleanup routines do whatever is necessary to indicate that cleanup has been done, and not do any particular cleaning up if it's already been done (i.e., don't free something if the pointer to it is null and null out the pointer once it's been freed, don't close an FD if it's -1 and set it to -1 once it's been closed, etc.). For device types/platforms where we don't support monitor mode, check for it and return PCAP_ERROR_RFMON_NOTSUP - but do so after we've checked whether we can open the device, so we return "no such device" or "permission denied" rather than "that device doesn't support monitor mode" if we can't open the device in the first place. Fix a comment.
* Catch another place where you could get told "no, you may not open thatguy2008-04-101-1/+3
| | | | device" and arrange that PCAP_ERROR_PERM_DENIED be returned.
* Fix an sprintf call.guy2008-04-091-2/+2
|
* Add some PCAP_WARNING return values for "success, but you might want toguy2008-04-091-20/+22
| | | | | | | | | | know that..."; currently, only pcap_activate() returns them, but we might want some more warning returns for some other calls, such as the ones that set filters. It's a little cleaner than "clear out the error message buffer and, if it's not empty after a successful return, it has a warning", and a little cleaner than spewing a warning to the standard error (as that might not be visible to the user if they're running a GUI application).
* Add an error for "you don't have permission to open that device", asguy2008-04-091-33/+64
| | | | | | | | | | | | | | | | | | | | | | | | | that often means "sorry, this platform requires you to run as root or to somehow tweak the system to give you capture privileges", and applications might want to explain that in a way that does a better job of letting the user know what they have to do. Try to return or PCAP_ERROR_PERM_DENIED for open errors, rather than just returning PCAP_ERROR, so that the application can, if it chooses, try to explain the error better (as those two errors are the ones that don't mean "there's probably some obscure OS or libpcap problem", but mean, instead, "you made an error" or "you need to get permission to capture"). Check for monitor mode *after* checking whether the device exists in the first place; a non-existent device doesn't support monitor mode, but that's because it doesn't, well, exist, and the latter would be a more meaningful error. Have pcap_open_live() supply an error message for return values other than PCAP_ERROR, PCAP_ERROR_NO_SUCH_DEVICE, and PCAP_ERROR_PERM_DENIED - those all supply error strings (PCAP_ERROR because it's for various OS problems that might require debugging, and the other two because there might be multiple causes).
* Fix some compile errors.guy2008-04-051-4/+4
|
* From Paolo Abeni and me: split pcap_open_live() into a "get a pcap_tguy2008-04-041-66/+71
| | | | | | | | | | | | | | | | handle" routine, an 'activate a pcap_t handle" routine, and some "set the properties of the pcap_t handle" routines, so that, for example, the buffer size can be set on a BPF device before the device is bound to an interface. Add additional routines to set monitor mode, and make at least an initial attempt at supporting that on Linux, *BSD, and Mac OS X 10.4 and 10.5. (Very much "initial" for Linux, which is a twisty little maze of wireless drivers, many different.) Have a "timeout" member of the pcap_md structure on all platforms, use that on Windows instead of the "timeout" member of the pcap_t structure, and get rid of the "timeout" member of that structure.
* Support for libdlpi, and for enabling "passive mode" on Solaris systemsguy2008-03-131-264/+44
| | | | that support it, from Sagun Shakya.
* As is done in the loop in pcap-bpf.c, check for non-positive values ofguy2008-02-021-2/+2
| | | | | "cnt", not for non-negative values, so a "cnt" of 0 is treated the same as a "cnt" of -1.
* From Sagun Shakya: update a comment.guy2008-01-301-3/+3
|
* Don't assume that p->fcode.bpf_insns remains unchanged while processingguy2007-12-051-4/+2
| | | | a bufferfull of packets - it could get changed in a callback routine.
* putmsg() returns 0 or -1, not the number of bytes written.guy2006-04-041-1/+9
|
* From Don Ebright: clean out *uerror in recv_ack() before doing anything,guy2005-08-131-9/+20
| | | | | | | | | | | so that it's not EBUSY if we didn't get an EBUSY in a DL_ERROR_ACK/DL_SYSERR reply, and our checks for EBUSY only catch that case. If we *did* get EBUSY on all the SAPs we tried, supply an error. Make "dl_dohpuxbind()" always return a value, so we don't fall off the end and return an error indication by accident.
* From Pawel Pokrywka: add support for requesting that only receivedguy2005-05-031-1/+2
| | | | | | | packets, only sent packets, or all packets be accepted, with an implementation for Linux. Add an implementation for BPF platforms that support BIOCSSEESENT.
* If we get EBUSY when binding to a SAP, clear out the error string we getguy2005-04-171-2/+5
| | | | from it, so that our caller doesn't treat it as a warning.
* Typo fix, from Mark C. Brown.guy2005-04-171-2/+2
|
* From Mark C. Brown: don't use hard-code values of 22 and 24 for the SAPguy2005-04-171-60/+116
| | | | | | on HP-UX, just keep trying different SAPs until we find one that doesn't return EBUSY, as attempting to use a SAP that some other descriptor is already bound to returns EBUSY.
* Update some comments.guy2005-04-081-7/+18
|
* Rename HAVE_HPUX10_20 to HAVE_HPUX10_20_OR_LATER, because it's alsoguy2005-04-081-7/+7
| | | | defined for 11.x.
* Add a "pcap_close_common()" routine which can be used as the closeguy2004-10-191-5/+2
| | | | | routine for some pcap-XXX.c files and can be called by the close routine in other pcap-XXX.c files.
* Do some error checking when extracting the unit number from a deviceguy2004-07-221-3/+20
| | | | name.
* (Try to) squelch some compiler warnings on HP-UX.guy2004-07-201-5/+5
|
* From Rick Jones:guy2004-07-201-10/+5
| | | | | | | | | | | fix a comment; fix references to the send-side file descriptor in "pcap_open_live()"; "dlrawdatareq()"s caller reports the error - we just return what "putmsg()" returns, so the caller knows whether there was an error.
* "sbh_drops" is cumulative, so we can't add it to the packet receiveguy2004-05-211-15/+13
| | | | | count; instead, we add the cumulative drop count to the cumulative receive count in the statistics we're returning.
* Add the dropped packet count to the received packet count, so that theguy2004-05-211-9/+22
| | | | | | | counts work similarly to the way they work in BPF and 2.4 and later Linux (and so that we don't run the risk of the dropped packet count being bigger than the received packet count, which can result in dropped packet percentages > 100).
* On non-HP-UX systems, if we fail to open "/dev/{if}" or "/dev/{if}N"guy2004-04-231-3/+23
| | | | | | | | | | because neither of them exist, just report that there was no DLPI device found for "{if}N", so people don't think that they need to fix libpcap (or the program using it) to look somewhere else for the device - the problem is probably that they're trying to capture on a loopback device and the lack of any DLPI device is just a symptom of the fact that the loopback device, at least on Solaris, appears not to support DLPI and thus isn't supported by libpcap....
* Having gone through the trouble of creating "dl_doattach()", we might asguy2004-04-071-5/+3
| | | | well use it....
* Small whitespace style cleanup.guy2004-04-031-2/+2
|
* Add support for sending packets on HP-UX if DL_HP_RAWDLS (for "rawguy2004-04-031-64/+160
| | | | mode") is defined.
* If we get EAGAIN, return 0, as we do with EAGAIN and EWOULDBLOCK onguy2004-04-031-2/+7
| | | | | other platforms, and as the man page says we do (in non-blocking mode, we return 0 if no packets are available).
* From Rick Jones: the DL_HP_PPA_ACK_OBS #defines are gone in HP-UX 11.23;guy2004-04-021-3/+3
| | | | check for DL_HP_PPA_REQ instead.
* Add support for sending packets; includes contributions from Markguy2004-03-231-1/+100
| | | | Pizzolato <List-tcpdump-workers@subscriptions.pizzolato.net>.
* For devices that we have some reason to believe are real live Ethernetguy2003-12-181-1/+25
| | | | | | | devices, offer DLT_DOCSIS as one of the choices of link-layer type, and support setting that type as meaning just "set libpcap's notion of the link-layer type to DLT_DOCSIS" without telling the driver to use DLT_DOCSIS.
* Add a "pcap_get_selectable_fd()" API to get an FD on which you can do aguy2003-11-211-1/+7
| | | | "select()" or "poll()" - or -1 if that won't work.
* Add "getnonblock" and "setnonblock" operations, and set the functionguy2003-11-201-1/+3
| | | | | | | pointers appropriately, rather than using #ifdefs and run-time checks. Get rid of declaration of non-existent "pcap_set_datalink_platform()" routine.
* Add _U_ to "rcsid[]" definitions, to eliminate "unused variable"guy2003-11-151-2/+2
| | | | warnings from newer versions of GCC.
* Add a "pcap_breakloop()" API to break out of the loop inguy2003-11-041-1/+33
| | | | "pcap_dispatch()" and "pcap_loop()".
* Add a "read" function pointer to the pcap_t structure, which handlesguy2003-07-251-3/+4
| | | | | | reading packets from a pcap_t, and make "pcap_read()" call it. That removes the last place where we have to check for a pcap_t that refers to a DAG card rather than a live capture, so get rid of the "is_dag" flag.
* Add a "set_datalink" function pointer to the pcap_t structure, whichhandlesguy2003-07-251-7/+2
| | | | | setting a filter for a pcap_t. Have "pcap_set_datalink()" call it, rather than explicitly calling "pcap_set_datalink_platform()".
* Add a "setfilter" function pointer to the pcap_t structure, whichguy2003-07-251-10/+2
| | | | | | | | handles setting a filter for a pcap_t. Have "pcap_setfilter()" call it, rather than being a per-platform function. The per-platform functions don't need to check for an offline capture any more, as they're not called for an offline capture (and the ones that just call "install_bpf_program()" don't need to exist at all).
* Add a "stats" function pointer to the pcap_t structure, which handlesguy2003-07-251-3/+4
| | | | | | getting statistics for a pcap_t. Have "pcap_stats()" call it, rather than being a per-platform function; have stats routines for non-live pcap_t's that return an error.
* Add a "close" function pointer to the pcap_t structure, which handlesguy2003-07-251-1/+17
| | | | | | | | | the platform-dependent part of closing a pcap_t (and the live-vs-savefile part as well, so that function must close the file descriptor and free up any buffers allocated). In the Digital UNIX support, add in a check for a memory allocation failure.
* According to the bufmod man page for Solaris 2.4 and 9 (meaning it'sguy2003-02-191-2/+2
| | | | | | | | | | probably true in all versions), "sbh_drops" is "the cumulative number of input messages that this instance of bufmod has dropped due to flow control or resource exhaustion." "Cumulative" presumably means "don't add it to the count of drops, as it's *already* a count since the capture started; just set the count of drops to the value". Do so.
* If we have bufmod, allocate a buffer big enough to hold the size ofguy2003-02-051-16/+33
| | | | | | | | | | chunk we ask bufmod to send upstream. Yes, uint_t is always 32 bits, at least as I read the Solaris 8 code. The chunk size is 8192, not 0, by default. Don't do the chunk size stuff if we don't have bufmod.