Lines Matching +full:ipmi +full:- +full:ipmb
39 #include <pcap-types.h>
67 #include "diag-control.h"
69 #include "thread-local.h"
72 #include "os-proto.h"
76 #include "pcap-dos.h"
79 #include "pcap-int.h"
84 #include "pcap-dag.h"
88 #include "pcap-septel.h"
92 #include "pcap-snf.h"
96 #include "pcap-tc.h"
100 #include "pcap-usb-linux.h"
104 #include "pcap-bt-linux.h"
108 #include "pcap-bt-monitor-linux.h"
112 #include "pcap-netfilter-linux.h"
116 #include "pcap-netmap.h"
120 #include "pcap-dbus.h"
124 #include "pcap-rdmasniff.h"
128 #include "pcap-dpdk.h"
132 #include "pcap-airpcap.h"
139 * The WSAStartup function typically leads to protocol-specific helper
146 * The WSACleanup function typically leads to protocol-specific helper
180 static int err = -1; in internal_wsockinit()
230 * The argument specifies whether we use the local code page or UTF-8
231 * for strings; on UN*X, we just assume UTF-8 in places where the encoding
233 * PCAP_CHAR_ENC_LOCAL and UTF-8 for PCAP_CHAR_ENC_UTF_8.
236 * being handed UTF-16 strings, because if the user calls this they're
238 * page strings or UTF-8 strings, so we don't need to allow UTF-16LE
241 * *trying* to pass the result of pcap_lookupdev() - which might be
242 * UTF-16LE on Windows, for ugly compatibility reasons - to pcap_create()
245 * Returns 0 on success, -1 on error.
248 int pcapint_utf_8_mode; /* Strings should be in UTF-8. */
264 /* Leave "UTF-8 mode" off. */ in pcap_init()
275 /* Turn on "UTF-8 mode". */ in pcap_init()
294 * UTF-8 mode flag, so we have to call a routine to set its in pcap_init()
295 * UTF-8 mode flag. in pcap_init()
311 if (internal_wsockinit(errbuf) == -1) { in pcap_init()
327 * Not explicitly exported via a header file - the right API to use
328 * is pcap_lib_version() - but some programs included it, so we
341 if (pcap->activated) { in pcap_set_not_initialized_message()
343 (void)snprintf(pcap->errbuf, sizeof(pcap->errbuf), in pcap_set_not_initialized_message()
348 (void)snprintf(pcap->errbuf, sizeof(pcap->errbuf), in pcap_set_not_initialized_message()
509 return (p->can_set_rfmon_op(p)); in pcap_can_set_rfmon()
535 if (p->tstamp_type_count == 0) { in pcap_list_tstamp_types()
543 pcapint_fmt_errmsg_for_errno(p->errbuf, sizeof(p->errbuf), in pcap_list_tstamp_types()
550 *tstamp_typesp = (int*)calloc(p->tstamp_type_count, in pcap_list_tstamp_types()
553 pcapint_fmt_errmsg_for_errno(p->errbuf, sizeof(p->errbuf), in pcap_list_tstamp_types()
557 (void)memcpy(*tstamp_typesp, p->tstamp_type_list, in pcap_list_tstamp_types()
558 sizeof(**tstamp_typesp) * p->tstamp_type_count); in pcap_list_tstamp_types()
559 return (p->tstamp_type_count); in pcap_list_tstamp_types()
581 * Default one-shot callback; overridden for capture types where the
590 *sp->hdr = *h; in pcapint_oneshot()
591 *sp->pkt = pkt; in pcapint_oneshot()
603 if (pcap_dispatch(p, 1, p->oneshot_callback, (u_char *)&s) <= 0) in pcap_next()
614 s.hdr = &p->pcap_header; in pcap_next_ex()
619 *pkt_header= &p->pcap_header; in pcap_next_ex()
621 if (p->rfile != NULL) { in pcap_next_ex()
625 status = pcapint_offline_read(p, 1, p->oneshot_callback, in pcap_next_ex()
630 * - 0: EOF in pcap_next_ex()
631 * - -1: error in pcap_next_ex()
632 * - >0: OK - result is number of packets read, so in pcap_next_ex()
637 * the timeout expired", so we map it to -2 so you can in pcap_next_ex()
643 return (-2); in pcap_next_ex()
650 * - 0: timeout in pcap_next_ex()
651 * - -1: error in pcap_next_ex()
652 * - -2: loop was broken out of with pcap_breakloop() in pcap_next_ex()
653 * - >0: OK, result is number of packets captured, so in pcap_next_ex()
659 return (p->read_op(p, 1, p->oneshot_callback, (u_char *)&s)); in pcap_next_ex()
717 * Returns -1 on error, 0 otherwise.
732 if (pcapint_platform_finddevs(&devlist, errbuf) == -1) { in pcap_findalldevs()
734 * Failed - free all of the entries we were given in pcap_findalldevs()
740 return (-1); in pcap_findalldevs()
744 * Ask each of the non-local-network-interface capture in pcap_findalldevs()
748 if (capture_source_types[i].findalldevs_op(&devlist, errbuf) == -1) { in pcap_findalldevs()
756 return (-1); in pcap_findalldevs()
781 * superior to interfaces that are up but not running, and non-loopback
811 if (!(dev->flags & PCAP_IF_RUNNING)) in get_figure_of_merit()
813 if (!(dev->flags & PCAP_IF_UP)) in get_figure_of_merit()
817 * Give non-wireless interfaces that aren't disconnected a better in get_figure_of_merit()
826 if (!(dev->flags & PCAP_IF_WIRELESS) && in get_figure_of_merit()
827 (dev->flags & PCAP_IF_CONNECTION_STATUS) == PCAP_IF_CONNECTION_STATUS_DISCONNECTED) in get_figure_of_merit()
831 * Sort loopback devices after non-loopback devices, *except* for in get_figure_of_merit()
834 if (dev->flags & PCAP_IF_LOOPBACK) in get_figure_of_merit()
841 if (strcmp(dev->name, "any") == 0) in get_figure_of_merit()
852 * XXX - on FreeBSDs that support it, should it get the sysctl named
857 * that the problem is really a driver bug - if it can find out that it's
883 * you're running on AIX - which I think is the only UN*X that doesn't
886 * library automatically pick up the other libraries when started -
888 * version of libpcap would have to use pcap-config with the --static
892 * -lnl.
950 * to get the description length - it's clamped
1000 "USB bus number %ld", busnum) == -1) {
1072 * address to its list of addresses if that address is non-null, and
1073 * return 0, otherwise return -1 and set errbuf to an error message.
1100 * Error - give up.
1102 return (-1);
1145 return (-1);
1148 curaddr->next = NULL;
1150 curaddr->addr = (struct sockaddr *)dup_sockaddr(addr, addr_size);
1151 if (curaddr->addr == NULL) {
1155 return (-1);
1158 curaddr->addr = NULL;
1161 curaddr->netmask = (struct sockaddr *)dup_sockaddr(netmask, netmask_size);
1162 if (curaddr->netmask == NULL) {
1165 if (curaddr->addr != NULL)
1166 free(curaddr->addr);
1168 return (-1);
1171 curaddr->netmask = NULL;
1174 curaddr->broadaddr = (struct sockaddr *)dup_sockaddr(broadaddr, broadaddr_size);
1175 if (curaddr->broadaddr == NULL) {
1178 if (curaddr->netmask != NULL)
1179 free(curaddr->netmask);
1180 if (curaddr->addr != NULL)
1181 free(curaddr->addr);
1183 return (-1);
1186 curaddr->broadaddr = NULL;
1189 curaddr->dstaddr = (struct sockaddr *)dup_sockaddr(dstaddr, dstaddr_size);
1190 if (curaddr->dstaddr == NULL) {
1193 if (curaddr->broadaddr != NULL)
1194 free(curaddr->broadaddr);
1195 if (curaddr->netmask != NULL)
1196 free(curaddr->netmask);
1197 if (curaddr->addr != NULL)
1198 free(curaddr->addr);
1200 return (-1);
1203 curaddr->dstaddr = NULL;
1208 for (prevaddr = curdev->addresses; prevaddr != NULL; prevaddr = nextaddr) {
1209 nextaddr = prevaddr->next;
1222 curdev->addresses = curaddr;
1228 prevaddr->next = curaddr;
1241 * return -1 and set errbuf to an error message.
1267 if ((*get_flags_func)(name, &flags, errbuf) == -1) {
1292 for (curdev = devlistp->beginning; curdev != NULL;
1293 curdev = curdev->next) {
1294 if (strcmp(name, curdev->name) == 0) {
1335 curdev->next = NULL;
1336 curdev->name = strdup(name);
1337 if (curdev->name == NULL) {
1347 curdev->description = NULL;
1352 curdev->description = strdup(description);
1353 if (curdev->description == NULL) {
1356 free(curdev->name);
1361 curdev->addresses = NULL; /* list starts out as empty */
1362 curdev->flags = flags;
1386 nextdev = devlistp->beginning;
1388 nextdev = prevdev->next;
1395 * Yes - we have to put the new entry after "prevdev".
1409 * Yes - we should put the new entry
1421 curdev->next = nextdev;
1424 * Insert after "prevdev" - unless "prevdev" is null,
1432 devlistp->beginning = curdev;
1434 prevdev->next = curdev;
1444 static const char any_descr[] = "Pseudo-device that captures on all interfaces";
1466 nextdev = curdev->next;
1471 for (curaddr = curdev->addresses; curaddr != NULL; curaddr = nextaddr) {
1472 nextaddr = curaddr->next;
1473 if (curaddr->addr)
1474 free(curaddr->addr);
1475 if (curaddr->netmask)
1476 free(curaddr->netmask);
1477 if (curaddr->broadaddr)
1478 free(curaddr->broadaddr);
1479 if (curaddr->dstaddr)
1480 free(curaddr->dstaddr);
1487 free(curdev->name);
1492 if (curdev->description != NULL)
1493 free(curdev->description);
1503 * pcap-npf.c has its own pcap_lookupdev(), for compatibility reasons, as
1507 * MS-DOS has its own pcap_lookupdev(), but that might be useful only
1525 * Windows - use the same size as the old WinPcap 3.1 code.
1526 * XXX - this is probably bigger than it needs to be.
1531 * UN*X - use the system's interface name size.
1532 * XXX - that might not be large enough for capture devices
1545 * it may return UTF-16 strings, for backwards-compatibility
1547 * for not-going-past-the-end-of-a-string reasons, and 2) we
1550 * In addition, it's not thread-safe, so we've marked it as
1559 if (pcap_findalldevs(&alldevs, errbuf) == -1)
1562 if (alldevs == NULL || (alldevs->flags & PCAP_IF_LOOPBACK)) {
1566 * are no non-loopback devices on the list. This means
1569 * XXX - why not return a loopback device? If we can't
1571 * on the list, there aren't any non-loopback devices,
1581 (void)pcapint_strlcpy(device, alldevs->name, sizeof(device));
1608 * The pseudo-device "any" listens on all interfaces and therefore
1609 * has the network address and -mask "0.0.0.0" therefore catching
1644 return (-1);
1655 * arguments to initialize its intermediate 2-member structure fully so
1656 * that Clang does not generate a -Wmissing-field-initializers warning
1657 * (which manifests only when it runs with -Werror). This workaround
1659 * problem. See also https://review.haiku-os.org/c/haiku/+/6369
1673 return (-1);
1676 *netp = sin4->sin_addr.s_addr;
1692 return (-1);
1695 *maskp = sin4->sin_addr.s_addr;
1706 return (-1);
1715 #include "pcap-rpcap.h"
1769 * If the parse fails, ebuf is set to an error string, and -1 is returned.
1796 * URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
1798 * hier-part = "//" authority path-abempty
1799 * / path-absolute
1800 * / path-rootless
1801 * / path-empty
1805 * userinfo = *( unreserved / pct-encoded / sub-delims / ":" )
1824 return (-1);
1831 * hier-part = "//" authority path-abempty, not
1832 * hier-part = path-absolute
1833 * hier-part = path-rootless
1834 * hier-part = path-empty
1849 return (-1);
1855 * XXX - check whether the purported scheme could be a scheme?
1862 scheme_len = colonp - source;
1867 return (-1);
1873 * Treat file: specially - take everything after file:// as
1882 return (-1);
1890 * interface with "rpcap://{device}"; we special-case
1894 * XXX - %-escaping?
1910 return (-1);
1927 return (-1);
1946 userinfo_len = atsignp - parsep;
1954 return (-1);
1980 * Is it an IP-literal?
1986 * bracket as the IP-Literal; we don't worry
1990 * URL with an IPv4 IP-Literal, of the sort
2001 "IP-literal in URL doesn't end with ]");
2005 return (-1);
2014 "Extra text after IP-literal in URL");
2018 return (-1);
2020 host_len = (bracketp - 1) - parsep;
2029 return (-1);
2047 return (-1);
2072 return (-1);
2097 return (-1);
2121 return (-1);
2150 return (-1);
2169 return (-1);
2199 &tmpport, &tmppath, errbuf) == -1) {
2203 return (-1);
2306 * A null device name is equivalent to the "any" device -
2319 * pairs of UTF-16LE device names and local code page
2324 * that opens devices, we'll get handed a UTF-16LE
2328 * looks as if it might be a UTF-16LE string and, if
2335 * string is UTF-16LE or not; "a" could either
2336 * be a one-character ASCII string or the first
2337 * character of a UTF-16LE string.
2340 * the string, if it's a 1-character ASCII
2377 * Try each of the non-local-network-interface capture
2402 p->opt.device = device_str;
2418 p->opt.device = device_str;
2430 p->opt.nonblock = nonblock;
2442 p->read_op = pcap_read_not_initialized;
2443 p->inject_op = pcap_inject_not_initialized;
2444 p->setfilter_op = pcap_setfilter_not_initialized;
2445 p->setdirection_op = pcap_setdirection_not_initialized;
2446 p->set_datalink_op = pcap_set_datalink_not_initialized;
2447 p->getnonblock_op = pcap_getnonblock_not_initialized;
2448 p->stats_op = pcap_stats_not_initialized;
2450 p->stats_ex_op = pcap_stats_ex_not_initialized;
2451 p->setbuff_op = pcap_setbuff_not_initialized;
2452 p->setmode_op = pcap_setmode_not_initialized;
2453 p->setmintocopy_op = pcap_setmintocopy_not_initialized;
2454 p->getevent_op = pcap_getevent_not_initialized;
2455 p->oid_get_request_op = pcap_oid_get_request_not_initialized;
2456 p->oid_set_request_op = pcap_oid_set_request_not_initialized;
2457 p->sendqueue_transmit_op = pcap_sendqueue_transmit_not_initialized;
2458 p->setuserbuffer_op = pcap_setuserbuffer_not_initialized;
2459 p->live_dump_op = pcap_live_dump_not_initialized;
2460 p->live_dump_ended_op = pcap_live_dump_ended_not_initialized;
2461 p->get_airpcap_handle_op = pcap_get_airpcap_handle_not_initialized;
2465 * Default cleanup operation - implementations can override
2469 p->cleanup_op = pcapint_cleanup_live_common;
2472 * In most cases, the standard one-shot callback can
2475 p->oneshot_callback = pcapint_oneshot;
2478 * Default breakloop operation - implementations can override
2482 p->breakloop_op = pcapint_breakloop_common;
2508 p->handle = INVALID_HANDLE_VALUE; /* not opened yet */
2510 p->fd = -1; /* not opened yet */
2512 p->selectable_fd = -1;
2513 p->required_select_timeout = NULL;
2524 p->priv = (void *)(chunk + private_offset);
2544 p->can_set_rfmon_op = pcap_cant_set_rfmon;
2547 * If pcap_setnonblock() is called on a not-yet-activated
2549 * on non-blocking mode when activated.
2551 p->setnonblock_op = pcap_setnonblock_unactivated;
2556 p->snapshot = 0; /* max packet size unspecified */
2557 p->opt.timeout = 0; /* no timeout specified */
2558 p->opt.buffer_size = 0; /* use the platform's default */
2559 p->opt.promisc = 0;
2560 p->opt.rfmon = 0;
2561 p->opt.immediate = 0;
2562 p->opt.tstamp_type = -1; /* default to not setting time stamp type */
2563 p->opt.tstamp_precision = PCAP_TSTAMP_PRECISION_MICRO;
2565 * Platform-dependent options.
2568 p->opt.protocol = 0;
2571 p->opt.nocapture_local = 0;
2577 p->bpf_codegen_flags = 0;
2585 if (p->activated) {
2586 snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "can't perform "
2588 return (-1);
2598 p->snapshot = snaplen;
2607 p->opt.promisc = promisc;
2616 p->opt.rfmon = rfmon;
2625 p->opt.timeout = timeout_ms;
2639 * to change now - it's an API.
2645 * If p->tstamp_type_count is 0, we only support PCAP_TSTAMP_HOST;
2648 if (p->tstamp_type_count == 0) {
2650 p->opt.tstamp_type = tstamp_type;
2657 for (i = 0; i < p->tstamp_type_count; i++) {
2658 if (p->tstamp_type_list[i] == (u_int)tstamp_type) {
2662 p->opt.tstamp_type = tstamp_type;
2679 p->opt.immediate = immediate;
2694 p->opt.buffer_size = buffer_size;
2708 * to change now - it's an API.
2714 * If p->tstamp_precision_count is 0, we only support setting
2720 if (p->tstamp_precision_count == 0) {
2722 p->opt.tstamp_precision = tstamp_precision;
2730 for (i = 0; i < p->tstamp_precision_count; i++) {
2731 if (p->tstamp_precision_list[i] == (u_int)tstamp_precision) {
2735 p->opt.tstamp_precision = tstamp_precision;
2750 return (p->opt.tstamp_precision);
2759 * Catch attempts to re-activate an already-activated
2767 status = p->activate_op(p);
2770 * If somebody requested non-blocking mode before
2773 if (p->opt.nonblock) {
2774 status = p->setnonblock_op(p, 1);
2780 p->cleanup_op(p);
2785 p->activated = 1;
2787 if (p->errbuf[0] == '\0') {
2794 snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "%s",
2819 * A null device name is equivalent to the "any" device -
2829 * Retrofit - we have to make older applications compatible with
2862 size_t len = strlen(device) - strlen(PCAP_SRC_IF_STRING) + 1;
2892 p->oldstyle = 1;
2901 * -Wformat-truncation.
2903 char trimbuf[PCAP_ERRBUF_SIZE - 5]; /* 2 bytes shorter */
2905 pcapint_strlcpy(trimbuf, p->errbuf, sizeof(trimbuf));
2907 PCAP_ERRBUF_SIZE - 3, trimbuf);
2915 if (p->errbuf[0] != '\0') {
2919 char trimbuf[PCAP_ERRBUF_SIZE - 8]; /* 2 bytes shorter */
2921 pcapint_strlcpy(trimbuf, p->errbuf, sizeof(trimbuf));
2924 PCAP_ERRBUF_SIZE - 6, trimbuf);
2946 p->opt.tstamp_precision = PCAP_TSTAMP_PRECISION_MICRO;
2954 return (p->read_op(p, cnt, callback, user));
2963 if (p->rfile != NULL) {
2974 n = p->read_op(p, cnt, callback, user);
2980 cnt -= n;
2993 p->breakloop_op(p);
2999 if (!p->activated)
3001 return (p->linktype);
3007 if (!p->activated)
3009 return (p->linktype_ext);
3015 if (!p->activated)
3017 if (p->dlt_count == 0) {
3026 pcapint_fmt_errmsg_for_errno(p->errbuf, sizeof(p->errbuf),
3030 **dlt_buffer = p->linktype;
3033 *dlt_buffer = (int*)calloc(p->dlt_count, sizeof(**dlt_buffer));
3035 pcapint_fmt_errmsg_for_errno(p->errbuf, sizeof(p->errbuf),
3039 (void)memcpy(*dlt_buffer, p->dlt_list,
3040 sizeof(**dlt_buffer) * p->dlt_count);
3041 return (p->dlt_count);
3071 if (p->dlt_count == 0 || p->set_datalink_op == NULL) {
3079 if (p->linktype != dlt)
3087 for (i = 0; i < p->dlt_count; i++)
3088 if (p->dlt_list[i] == (u_int)dlt)
3090 if (i >= p->dlt_count)
3092 if (p->dlt_count == 2 && p->dlt_list[0] == DLT_EN10MB &&
3096 * link-layer type it offers is DLT_EN10MB, and the only
3098 * we can't tell the driver to supply DOCSIS link-layer
3099 * headers - we're just pretending that's what we're
3102 * it's putting raw DOCSIS frames on the wire inside low-level
3105 p->linktype = dlt;
3108 if (p->set_datalink_op(p, dlt) == -1)
3109 return (-1);
3110 p->linktype = dlt;
3116 (void) snprintf(p->errbuf, sizeof(p->errbuf),
3120 (void) snprintf(p->errbuf, sizeof(p->errbuf),
3124 return (-1);
3209 return (cm[*us1] - cm[*--us2]);
3229 DLT_CHOICE(ATM_RFC1483, "RFC 1483 LLC-encapsulated ATM"),
3247 DLT_CHOICE(IP_OVER_FC, "RFC 2625 IP-over-Fibre Channel"),
3251 DLT_CHOICE(JUNIPER_MLPPP, "Juniper Multi-Link PPP"),
3252 DLT_CHOICE(JUNIPER_MLFR, "Juniper Multi-Link Frame Relay"),
3259 DLT_CHOICE(APPLE_IP_OVER_IEEE1394, "Apple IP-over-IEEE 1394"),
3260 DLT_CHOICE(MTP2_WITH_PHDR, "SS7 MTP2 with Pseudo-header"),
3273 DLT_CHOICE(GPF_T, "GPF-T"),
3274 DLT_CHOICE(GPF_F, "GPF-F"),
3277 DLT_CHOICE(ERF_POS, "Packet-over-SONET with Endace ERF header"),
3282 DLT_CHOICE(JUNIPER_CHDLC, "Juniper C-HDLC"),
3293 DLT_CHOICE(PPI, "Per-Packet Information"),
3297 DLT_CHOICE(SITA, "SITA pseudo-header"),
3299 DLT_CHOICE(RAIF1, "Ethernet with u10 Networks pseudo-header"),
3300 DLT_CHOICE(IPMB_KONTRON, "IPMB with Kontron pseudo-header"),
3302 DLT_CHOICE(BLUETOOTH_HCI_H4_WITH_PHDR, "Bluetooth HCI UART transport layer plus pseudo-header"),
3304 DLT_CHOICE(IPMB_LINUX, "IPMB with Linux/Pigeon Point pseudo-header"),
3305 DLT_CHOICE(IEEE802_15_4_NONASK_PHY, "IEEE 802.15.4 with non-ASK PHY data"),
3306 DLT_CHOICE(MPLS, "MPLS with label as link-layer header"),
3312 DLT_CHOICE(FC_2, "Fibre Channel FC-2"),
3313 DLT_CHOICE(FC_2_WITH_FRAME_DELIMS, "Fibre Channel FC-2 with frame delimiters"),
3315 DLT_CHOICE(CAN_SOCKETCAN, "CAN-bus with SocketCAN headers"),
3319 DLT_CHOICE(DBUS, "D-Bus"),
3323 DLT_CHOICE(DVB_CI, "DVB-CI"),
3328 DLT_CHOICE(NETANALYZER, "Ethernet with Hilscher netANALYZER pseudo-header"),
3329 …DLT_CHOICE(NETANALYZER_TRANSPARENT, "Ethernet with Hilscher netANALYZER pseudo-header and with pre…
3330 DLT_CHOICE(IPOIB, "RFC 4391 IP-over-Infiniband"),
3331 DLT_CHOICE(MPEG_2_TS, "MPEG-2 transport stream"),
3333 DLT_CHOICE(NFC_LLCP, "NFC LLCP PDUs with pseudo-header"),
3342 DLT_CHOICE(BLUETOOTH_LE_LL_WITH_PHDR, "Bluetooth Low Energy air interface with pseudo-header"),
3346 DLT_CHOICE(IPMI_HPM_2, "IPMI trace packets"),
3347 DLT_CHOICE(ZWAVE_R1_R2, "Z-Wave RF profile R1 and R2 packets"),
3348 DLT_CHOICE(ZWAVE_R3, "Z-Wave RF profile R3 packets"),
3358 DLT_CHOICE(DOCSIS31_XRA31, "Excentis XRA-31 DOCSIS 3.1 RF sniffer frames"),
3367 DLT_CHOICE(IEEE802_15_4_TAP, "IEEE 802.15.4 with pseudo-header"),
3371 DLT_CHOICE(Z_WAVE_SERIAL, "Z-Wave serial frames between host and chip"),
3373 DLT_CHOICE(ATSC_ALP, "ATSC Link-Layer Protocol packets"),
3386 return (-1);
3483 if (!p->activated)
3485 return (p->snapshot);
3491 if (!p->activated)
3493 return (p->swapped);
3499 if (!p->activated)
3501 return (p->version_major);
3507 if (!p->activated)
3509 return (p->version_minor);
3515 if (!p->activated)
3517 return (p->bufsize);
3523 return (p->rfile);
3530 if (p->handle != INVALID_HANDLE_VALUE) {
3532 * This is a bogus and now-deprecated API; we
3541 return ((int)(intptr_t)p->handle);
3550 return (p->fd);
3558 return (p->selectable_fd);
3564 return (p->required_select_timeout);
3571 fprintf(stderr, "%s: %s\n", prefix, p->errbuf);
3577 return (p->errbuf);
3585 ret = p->getnonblock_op(p);
3586 if (ret == -1) {
3588 * The get nonblock operation sets p->errbuf; this
3596 pcapint_strlcpy(errbuf, p->errbuf, PCAP_ERRBUF_SIZE);
3602 * Get the current non-blocking mode setting, under the assumption that
3603 * it's just the standard POSIX non-blocking flag.
3611 fdflags = fcntl(p->fd, F_GETFL, 0);
3612 if (fdflags == -1) {
3613 pcapint_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
3615 return (-1);
3629 ret = p->setnonblock_op(p, nonblock);
3630 if (ret == -1) {
3632 * The set nonblock operation sets p->errbuf; this
3640 pcapint_strlcpy(errbuf, p->errbuf, PCAP_ERRBUF_SIZE);
3647 * Set non-blocking mode, under the assumption that it's just the
3648 * standard POSIX non-blocking flag. (This can be called by the
3649 * per-platform non-blocking-mode routine if that routine also
3657 fdflags = fcntl(p->fd, F_GETFL, 0);
3658 if (fdflags == -1) {
3659 pcapint_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
3661 return (-1);
3667 if (fcntl(p->fd, F_SETFL, fdflags) == -1) {
3668 pcapint_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
3670 return (-1);
3740 * between those Unix-like OSes that implemented strerror() and those that
3742 * POSIX.1-2001, uniformly and that particular problem no longer exists. But
3743 * now they implement a few incompatible thread-safe variants of strerror(),
3758 * We have a GNU-style strerror_r(), which is *not* guaranteed to
3769 * - Hurd
3770 * - Linux with GNU libc
3771 * - Linux with uClibc-ng
3777 * We have a POSIX-style strerror_r(), which is guaranteed to fill
3781 * - AIX 7
3782 * - FreeBSD
3783 * - Haiku
3784 * - HP-UX 11
3785 * - illumos
3786 * - Linux with musl libc
3787 * - macOS
3788 * - NetBSD
3789 * - OpenBSD
3790 * - Solaris 10 & 11
3824 * and at least one thread-safe variant thereof, so this is a very
3825 * unlikely last-resort branch. Particular implementations of strerror()
3826 * may be thread-safe, but this is neither required nor guaranteed.
3835 return (p->setfilter_op(p, fp));
3847 if (p->setdirection_op == NULL) {
3848 snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
3850 return (-1);
3860 return (p->setdirection_op(p, d));
3866 snprintf(p->errbuf, sizeof(p->errbuf),
3868 return (-1);
3876 return (p->stats_op(p, ps));
3883 return (p->stats_ex_op(p, pcap_stat_size));
3889 return (p->setbuff_op(p, dim));
3895 return (p->setmode_op(p, mode));
3901 return (p->setmintocopy_op(p, size));
3907 return (p->getevent_op(p));
3913 return (p->oid_get_request_op(p, oid, data, lenp));
3919 return (p->oid_set_request_op(p, oid, data, lenp));
3934 tqueue->buffer = (char *)malloc(memsize);
3935 if (tqueue->buffer == NULL) {
3940 tqueue->maxlen = memsize;
3941 tqueue->len = 0;
3949 free(queue->buffer);
3956 if (queue->len + sizeof(struct pcap_pkthdr) + pkt_header->caplen > queue->maxlen){
3957 return (-1);
3961 memcpy(queue->buffer + queue->len, pkt_header, sizeof(struct pcap_pkthdr));
3962 queue->len += sizeof(struct pcap_pkthdr);
3965 memcpy(queue->buffer + queue->len, pkt_data, pkt_header->caplen);
3966 queue->len += pkt_header->caplen;
3974 return (p->sendqueue_transmit_op(p, queue, sync));
3980 return (p->setuserbuffer_op(p, size));
3986 return (p->live_dump_op(p, filename, maxsize, maxpacks));
3992 return (p->live_dump_ended_op(p, sync));
4000 handle = p->get_airpcap_handle_op(p);
4002 (void)snprintf(p->errbuf, sizeof(p->errbuf),
4011 * when we close a device - and we want that to happen even if the
4017 * XXX - not thread-safe.
4050 * That means that, after pcap_close() - which calls
4051 * the cleanup_op for the pcap_t - the pcap_t must
4075 pcapint_strlcpy(p->errbuf, "atexit failed", PCAP_ERRBUF_SIZE);
4086 p->next = pcaps_to_close;
4096 prevpc = pc, pc = pc->next) {
4105 pcaps_to_close = pc->next;
4110 prevpc->next = pc->next;
4120 p->break_loop = 1;
4127 if (p->opt.device != NULL) {
4128 free(p->opt.device);
4129 p->opt.device = NULL;
4131 if (p->buffer != NULL) {
4132 free(p->buffer);
4133 p->buffer = NULL;
4135 if (p->dlt_list != NULL) {
4136 free(p->dlt_list);
4137 p->dlt_list = NULL;
4138 p->dlt_count = 0;
4140 if (p->tstamp_type_list != NULL) {
4141 free(p->tstamp_type_list);
4142 p->tstamp_type_list = NULL;
4143 p->tstamp_type_count = 0;
4145 if (p->tstamp_precision_list != NULL) {
4146 free(p->tstamp_precision_list);
4147 p->tstamp_precision_list = NULL;
4148 p->tstamp_precision_count = 0;
4150 pcap_freecode(&p->fcode);
4152 if (p->fd >= 0) {
4153 close(p->fd);
4154 p->fd = -1;
4156 p->selectable_fd = -1;
4161 * API compatible with WinPcap's "send a packet" routine - returns -1
4164 * XXX - what if we get a short write?
4170 pcapint_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
4175 if (p->inject_op(p, buf, size) == -1)
4176 return (-1);
4181 * API compatible with OpenBSD's "send a packet" routine - returns -1 on
4192 pcapint_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
4198 pcapint_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
4203 return (p->inject_op(p, buf, (int)size));
4209 p->cleanup_op(p);
4215 * Currently Windows-only.
4225 // https://blog.rapid7.com/2010/08/23/exploiting-dll-hijacking-flaws/
4226 // https://blog.rapid7.com/2010/08/23/application-dll-load-hijacking/
4233 …chive.org/web/20110122175058/http://blog.metasploit.com/2010/08/exploiting-dll-hijacking-flaws.html
4240 * XXX - should this work in UTF-16LE rather than in the local
4292 * the packet doesn't pass and non-zero if the packet does pass.
4298 const struct bpf_insn *fcode = fp->bf_insns;
4301 return (pcapint_filter(fcode, pkt, h->len, h->caplen));
4309 snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
4318 snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
4320 return (-1);
4331 * get-packets loop in progress to break out *of*.
4340 snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
4342 return (-1);
4348 snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
4350 return (-1);
4356 snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
4358 return (-1);
4364 snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
4365 "The link-layer header type cannot be set on a pcap_open_dead pcap_t");
4366 return (-1);
4372 snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
4373 "A pcap_open_dead pcap_t does not have a non-blocking mode setting");
4374 return (-1);
4380 snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
4381 "A pcap_open_dead pcap_t does not have a non-blocking mode setting");
4382 return (-1);
4388 snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
4390 return (-1);
4397 snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
4405 snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
4407 return (-1);
4413 snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
4415 return (-1);
4421 snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
4423 return (-1);
4429 snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
4438 snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
4447 snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
4456 snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
4464 snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
4466 return (-1);
4473 snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
4475 return (-1);
4481 snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
4483 return (-1);
4524 p->snapshot = snaplen;
4525 p->linktype = linktype;
4526 p->opt.tstamp_precision = precision;
4527 p->can_set_rfmon_op = pcap_can_set_rfmon_dead;
4528 p->read_op = pcap_read_dead;
4529 p->inject_op = pcap_inject_dead;
4530 p->setfilter_op = pcap_setfilter_dead;
4531 p->setdirection_op = pcap_setdirection_dead;
4532 p->set_datalink_op = pcap_set_datalink_dead;
4533 p->getnonblock_op = pcap_getnonblock_dead;
4534 p->setnonblock_op = pcap_setnonblock_dead;
4535 p->stats_op = pcap_stats_dead;
4537 p->stats_ex_op = pcap_stats_ex_dead;
4538 p->setbuff_op = pcap_setbuff_dead;
4539 p->setmode_op = pcap_setmode_dead;
4540 p->setmintocopy_op = pcap_setmintocopy_dead;
4541 p->getevent_op = pcap_getevent_dead;
4542 p->oid_get_request_op = pcap_oid_get_request_dead;
4543 p->oid_set_request_op = pcap_oid_set_request_dead;
4544 p->sendqueue_transmit_op = pcap_sendqueue_transmit_dead;
4545 p->setuserbuffer_op = pcap_setuserbuffer_dead;
4546 p->live_dump_op = pcap_live_dump_dead;
4547 p->live_dump_ended_op = pcap_live_dump_ended_dead;
4548 p->get_airpcap_handle_op = pcap_get_airpcap_handle_dead;
4550 p->breakloop_op = pcap_breakloop_dead;
4551 p->cleanup_op = pcap_cleanup_dead;
4556 p->bpf_codegen_flags = 0;
4558 p->activated = 1;