2 * Copyright (c) 1993, 1994, 1995, 1996, 1997
3 * The Regents of the University of California. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that: (1) source code distributions
7 * retain the above copyright notice and this paragraph in its entirety, (2)
8 * distributions including binary code include the above copyright notice and
9 * this paragraph in its entirety in the documentation or other materials
10 * provided with the distribution, and (3) all advertising materials mentioning
11 * features or use of this software display the following acknowledgement:
12 * ``This product includes software developed by the University of California,
13 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
14 * the University nor the names of its contributors may be used to endorse
15 * or promote products derived from this software without specific prior
17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21 * This code contributed by Atanu Ghosh (atanu@cs.ucl.ac.uk),
22 * University College London, and subsequently modified by
23 * Guy Harris (guy@alum.mit.edu), Mark Pizzolato
24 * <List-tcpdump-workers@subscriptions.pizzolato.net>,
25 * Mark C. Brown (mbrown@hp.com), and Sagun Shakya <Sagun.Shakya@Sun.COM>.
29 * Packet capture routine for DLPI under SunOS 5, HP-UX 10/11, and AIX.
33 * - The DLIOCRAW ioctl() is specific to SunOS.
35 * - It might be desirable to use pfmod(7) to filter packets in the
36 * kernel when possible.
38 * - An older version of the HP-UX DLPI Programmer's Guide, which
39 * I think was advertised as the 10.20 version, used to be available
42 * http://docs.hp.com/hpux/onlinedocs/B2355-90093/B2355-90093.html
44 * but is no longer available; it can still be found at
46 * http://h21007.www2.hp.com/dspp/files/unprotected/Drivers/Docs/Refs/B2355-90093.pdf
50 * - The HP-UX 10.x, 11.0, and 11i v1.6 version of the HP-UX DLPI
51 * Programmer's Guide, which I think was once advertised as the
52 * 11.00 version is available at
54 * http://docs.hp.com/en/B2355-90139/index.html
56 * - The HP-UX 11i v2 version of the HP-UX DLPI Programmer's Guide
59 * http://docs.hp.com/en/B2355-90871/index.html
61 * - All of the HP documents describe raw-mode services, which are
62 * what we use if DL_HP_RAWDLS is defined. XXX - we use __hpux
63 * in some places to test for HP-UX, but use DL_HP_RAWDLS in
64 * other places; do we support any versions of HP-UX without
70 #include <sys/types.h>
72 #ifdef HAVE_SYS_BUFMOD_H
73 #include <sys/bufmod.h>
76 #ifdef HAVE_SYS_DLPI_EXT_H
77 #include <sys/dlpi_ext.h>
82 #include <sys/stream.h>
83 #if defined(HAVE_SOLARIS) && defined(HAVE_SYS_BUFMOD_H)
84 #include <sys/systeminfo.h>
100 #ifdef HAVE_OS_PROTO_H
101 #include "os-proto.h"
106 * HP-UX has a /dev/dlpi device; you open it and set the PPA of the actual
107 * network device you want.
109 #define HAVE_DEV_DLPI
112 * AIX has a /dev/dlpi directory, with devices named after the interfaces
115 #define PCAP_DEV_PREFIX "/dev/dlpi"
116 #elif defined(HAVE_SOLARIS)
118 * Solaris has devices named after the interfaces underneath /dev.
120 #define PCAP_DEV_PREFIX "/dev"
123 #define MAXDLBUF 8192
126 static char *split_dname(char *, u_int
*, char *);
127 static int dl_doattach(int, int, char *);
129 static int dl_dohpuxbind(int, char *);
131 static int dlpromiscon(pcap_t
*, bpf_u_int32
);
132 static int dlbindreq(int, bpf_u_int32
, char *);
133 static int dlbindack(int, char *, char *, int *);
134 static int dlokack(int, const char *, char *, char *, int *);
135 static int dlinforeq(int, char *);
136 static int dlinfoack(int, char *, char *);
138 #ifdef HAVE_DL_PASSIVE_REQ_T
139 static void dlpassive(int, char *);
143 static int dlrawdatareq(int, const u_char
*, int);
145 static int recv_ack(int, int, const char *, char *, char *, int *);
146 static char *dlstrerror(char *, size_t, bpf_u_int32
);
147 static char *dlprim(char *, size_t, bpf_u_int32
);
148 static int send_request(int, char *, int, char *, char *);
150 static int get_dlpi_ppa(int, const char *, u_int
, u_int
*, char *);
154 * Cast a buffer to "union DL_primitives" without provoking warnings
157 #define MAKE_DL_PRIMITIVES(ptr) ((union DL_primitives *)(void *)(ptr))
160 pcap_read_dlpi(pcap_t
*p
, int cnt
, pcap_handler callback
, u_char
*user
)
165 bpf_u_int32 ctlbuf
[MAXDLBUF
];
166 struct strbuf ctl
= {
176 data
.buf
= (char *)p
->buffer
+ p
->offset
;
177 data
.maxlen
= p
->bufsize
;
181 * Has "pcap_breakloop()" been called?
185 * Yes - clear the flag that indicates
186 * that it has, and return -2 to
187 * indicate that we were told to
188 * break out of the loop.
194 * XXX - check for the DLPI primitive, which
195 * would be DL_HP_RAWDATA_IND on HP-UX
196 * if we're in raw mode?
198 ctl
.buf
= (char *)ctlbuf
;
199 ctl
.maxlen
= MAXDLBUF
;
201 if (getmsg(p
->fd
, &ctl
, &data
, &flags
) < 0) {
202 /* Don't choke when we get ptraced */
212 pcapint_fmt_errmsg_for_errno(p
->errbuf
,
213 sizeof(p
->errbuf
), errno
, "getmsg");
218 bp
= p
->buffer
+ p
->offset
;
222 return (pcap_process_pkts(p
, callback
, user
, cnt
, bp
, cc
));
226 pcap_inject_dlpi(pcap_t
*p
, const void *buf
, int size
)
229 struct pcap_dlpi
*pd
= p
->priv
;
233 #if defined(DLIOCRAW)
234 ret
= write(p
->fd
, buf
, size
);
236 pcapint_fmt_errmsg_for_errno(p
->errbuf
, PCAP_ERRBUF_SIZE
,
240 #elif defined(DL_HP_RAWDLS)
241 if (pd
->send_fd
< 0) {
242 snprintf(p
->errbuf
, PCAP_ERRBUF_SIZE
,
243 "send: Output FD couldn't be opened");
246 ret
= dlrawdatareq(pd
->send_fd
, buf
, size
);
248 pcapint_fmt_errmsg_for_errno(p
->errbuf
, PCAP_ERRBUF_SIZE
,
253 * putmsg() returns either 0 or -1; it doesn't indicate how
254 * many bytes were written (presumably they were all written
255 * or none of them were written). OpenBSD's pcap_inject()
256 * returns the number of bytes written, so, for API compatibility,
257 * we return the number of bytes we were told to write.
260 #else /* no raw mode */
262 * XXX - this is a pain, because you might have to extract
263 * the address from the packet and use it in a DL_UNITDATA_REQ
264 * request. That would be dependent on the link-layer type.
266 * I also don't know what SAP you'd have to bind the descriptor
267 * to, or whether you'd need separate "receive" and "send" FDs,
268 * nor do I know whether you'd need different bindings for
269 * D/I/X Ethernet and 802.3, or for {FDDI,Token Ring} plus
270 * 802.2 and {FDDI,Token Ring} plus 802.2 plus SNAP.
272 * So, for now, we just return a "you can't send" indication,
273 * and leave it up to somebody with a DLPI-based system lacking
274 * both DLIOCRAW and DL_HP_RAWDLS to supply code to implement
275 * packet transmission on that system. If they do, they should
276 * send it to us - but should not send us code that assumes
277 * Ethernet; if the code doesn't work on non-Ethernet interfaces,
278 * it should check "p->linktype" and reject the send request if
279 * it's anything other than DLT_EN10MB.
281 pcapint_strlcpy(p
->errbuf
, "send: Not supported on this version of this OS",
284 #endif /* raw mode */
289 #define DL_IPATM 0x12 /* ATM Classical IP interface */
297 #define A_GET_UNITS (('A'<<8)|118)
298 #endif /* A_GET_UNITS */
299 #ifndef A_PROMISCON_REQ
300 #define A_PROMISCON_REQ (('A'<<8)|121)
301 #endif /* A_PROMISCON_REQ */
302 #endif /* HAVE_SOLARIS */
305 pcap_cleanup_dlpi(pcap_t
*p
)
308 struct pcap_dlpi
*pd
= p
->priv
;
310 if (pd
->send_fd
>= 0) {
315 pcapint_cleanup_live_common(p
);
319 open_dlpi_device(const char *name
, u_int
*ppa
, char *errbuf
)
333 ** Remove any "/dev/" on the front of the device.
335 cp
= strrchr(name
, '/');
337 pcapint_strlcpy(dname
, name
, sizeof(dname
));
339 pcapint_strlcpy(dname
, cp
+ 1, sizeof(dname
));
342 * If this name has a colon followed by a number at
343 * the end, it's a logical interface. Those are just
344 * the way you assign multiple IP addresses to a real
345 * interface, so an entry for a logical interface should
346 * be treated like the entry for the real interface;
347 * we do that by stripping off the ":" and the number.
349 cp
= strchr(dname
, ':');
352 * We have a ":"; is it followed by a number?
355 while (PCAP_ISDIGIT(*cq
))
359 * All digits after the ":" until the end.
360 * Strip off the ":" and everything after
368 * Split the device name into a device type name and a unit number;
369 * chop off the unit number, so "dname" is just a device type name.
371 cp
= split_dname(dname
, &unit
, errbuf
);
374 * split_dname() has filled in the error message.
376 return (PCAP_ERROR_NO_SUCH_DEVICE
);
381 * Use "/dev/dlpi" as the device.
383 * XXX - HP's DLPI Programmer's Guide for HP-UX 11.00 says that
384 * the "dl_mjr_num" field is for the "major number of interface
385 * driver"; that's the major of "/dev/dlpi" on the system on
386 * which I tried this, but there may be DLPI devices that
387 * use a different driver, in which case we may need to
388 * search "/dev" for the appropriate device with that major
389 * device number, rather than hardwiring "/dev/dlpi".
392 if ((fd
= open(cp
, O_RDWR
)) < 0) {
393 if (errno
== EPERM
|| errno
== EACCES
) {
394 status
= PCAP_ERROR_PERM_DENIED
;
395 snprintf(errbuf
, PCAP_ERRBUF_SIZE
,
396 "Attempt to open %s failed with %s - root privilege may be required",
397 cp
, (errno
== EPERM
) ? "EPERM" : "EACCES");
400 pcapint_fmt_errmsg_for_errno(errbuf
, PCAP_ERRBUF_SIZE
,
401 errno
, "Attempt to open %s failed", cp
);
407 * Get a table of all PPAs for that device, and search that
408 * table for the specified device type name and unit number.
410 status
= get_dlpi_ppa(fd
, dname
, unit
, ppa
, errbuf
);
417 * If the device name begins with "/", assume it begins with
418 * the pathname of the directory containing the device to open;
419 * otherwise, concatenate the device directory name and the
423 pcapint_strlcpy(dname
, name
, sizeof(dname
));
425 snprintf(dname
, sizeof(dname
), "%s/%s", PCAP_DEV_PREFIX
,
429 * If this name has a colon followed by a number at
430 * the end, it's a logical interface. Those are just
431 * the way you assign multiple IP addresses to a real
432 * interface, so an entry for a logical interface should
433 * be treated like the entry for the real interface;
434 * we do that by stripping off the ":" and the number.
436 cp
= strchr(dname
, ':');
439 * We have a ":"; is it followed by a number?
442 while (PCAP_ISDIGIT(*cq
))
446 * All digits after the ":" until the end.
447 * Strip off the ":" and everything after
455 * Get the unit number, and a pointer to the end of the device
458 cp
= split_dname(dname
, ppa
, errbuf
);
461 * split_dname() has filled in the error message.
463 return (PCAP_ERROR_NO_SUCH_DEVICE
);
467 * Make a copy of the device pathname, and then remove the unit
468 * number from the device pathname.
470 pcapint_strlcpy(dname2
, dname
, sizeof(dname
));
473 /* Try device without unit number */
474 if ((fd
= open(dname
, O_RDWR
)) < 0) {
475 if (errno
!= ENOENT
) {
476 if (errno
== EPERM
|| errno
== EACCES
) {
477 status
= PCAP_ERROR_PERM_DENIED
;
478 snprintf(errbuf
, PCAP_ERRBUF_SIZE
,
479 "Attempt to open %s failed with %s - root privilege may be required",
481 (errno
== EPERM
) ? "EPERM" : "EACCES");
484 pcapint_fmt_errmsg_for_errno(errbuf
,
485 PCAP_ERRBUF_SIZE
, errno
,
486 "Attempt to open %s failed", dname
);
491 /* Try again with unit number */
492 if ((fd
= open(dname2
, O_RDWR
)) < 0) {
493 if (errno
== ENOENT
) {
494 status
= PCAP_ERROR_NO_SUCH_DEVICE
;
497 * We provide an error message even
498 * for this error, for diagnostic
499 * purposes (so that, for example,
500 * the app can show the message if the
503 * In it, we just report "No DLPI device
504 * found" with the device name, so people
505 * don't get confused and think, for example,
506 * that if they can't capture on "lo0"
507 * on Solaris prior to Solaris 11 the fix
508 * is to change libpcap (or the application
509 * that uses it) to look for something other
510 * than "/dev/lo0", as the fix is to use
511 * Solaris 11 or some operating system
512 * other than Solaris - you just *can't*
513 * capture on a loopback interface
514 * on Solaris prior to Solaris 11, the lack
515 * of a DLPI device for the loopback
516 * interface is just a symptom of that
519 snprintf(errbuf
, PCAP_ERRBUF_SIZE
,
520 "%s: No DLPI device found", name
);
522 if (errno
== EPERM
|| errno
== EACCES
) {
523 status
= PCAP_ERROR_PERM_DENIED
;
524 snprintf(errbuf
, PCAP_ERRBUF_SIZE
,
525 "Attempt to open %s failed with %s - root privilege may be required",
527 (errno
== EPERM
) ? "EPERM" : "EACCES");
530 pcapint_fmt_errmsg_for_errno(errbuf
,
531 PCAP_ERRBUF_SIZE
, errno
,
532 "Attempt to open %s failed",
538 /* XXX Assume unit zero */
546 pcap_activate_dlpi(pcap_t
*p
)
549 struct pcap_dlpi
*pd
= p
->priv
;
557 register dl_info_ack_t
*infop
;
558 #ifdef HAVE_SYS_BUFMOD_H
561 bpf_u_int32 buf
[MAXDLBUF
];
563 p
->fd
= open_dlpi_device(p
->opt
.device
, &ppa
, p
->errbuf
);
571 * XXX - HP-UX 10.20 and 11.xx don't appear to support sending and
572 * receiving packets on the same descriptor - you need separate
573 * descriptors for sending and receiving, bound to different SAPs.
575 * If the open fails, we just leave -1 in "pd->send_fd" and reject
576 * attempts to send packets, just as if, in pcap-bpf.c, we fail
577 * to open the BPF device for reading and writing, we just try
578 * to open it for reading only and, if that succeeds, just let
579 * the send attempts fail.
581 pd
->send_fd
= open("/dev/dlpi", O_RDWR
);
585 ** Attach if "style 2" provider
587 if (dlinforeq(p
->fd
, p
->errbuf
) < 0 ||
588 dlinfoack(p
->fd
, (char *)buf
, p
->errbuf
) < 0) {
592 infop
= &(MAKE_DL_PRIMITIVES(buf
))->info_ack
;
594 if (infop
->dl_mac_type
== DL_IPATM
)
597 if (infop
->dl_provider_style
== DL_STYLE2
) {
598 retv
= dl_doattach(p
->fd
, ppa
, p
->errbuf
);
604 if (pd
->send_fd
>= 0) {
605 retv
= dl_doattach(pd
->send_fd
, ppa
, p
->errbuf
);
616 * This device exists, but we don't support monitor mode
617 * any platforms that support DLPI.
619 status
= PCAP_ERROR_RFMON_NOTSUP
;
623 #ifdef HAVE_DL_PASSIVE_REQ_T
625 * Enable Passive mode to be able to capture on aggregated link.
626 * Not supported in all Solaris versions.
628 dlpassive(p
->fd
, p
->errbuf
);
636 ** According to IBM's AIX Support Line, the dl_sap value
637 ** should not be less than 0x600 (1536) for standard Ethernet.
638 ** However, we seem to get DL_BADADDR - "DLSAP addr in improper
639 ** format or invalid" - errors if we use 1537 on the "tr0"
640 ** device, which, given that its name starts with "tr" and that
641 ** it's IBM, probably means a Token Ring device. (Perhaps we
642 ** need to use 1537 on "/dev/dlpi/en" because that device is for
643 ** D/I/X Ethernet, the "SAP" is actually an Ethernet type, and
644 ** it rejects invalid Ethernet types.)
646 ** So if 1537 fails, we try 2, as Hyung Sik Yoon of IBM Korea
647 ** says that works on Token Ring (he says that 0 does *not*
648 ** work; perhaps that's considered an invalid LLC SAP value - I
649 ** assume the SAP value in a DLPI bind is an LLC SAP for network
650 ** types that use 802.2 LLC).
652 if ((dlbindreq(p
->fd
, 1537, p
->errbuf
) < 0 &&
653 dlbindreq(p
->fd
, 2, p
->errbuf
) < 0) ||
654 dlbindack(p
->fd
, (char *)buf
, p
->errbuf
, NULL
) < 0) {
658 #elif defined(HAVE_HPUX10_20_OR_LATER)
662 #else /* neither AIX nor HP-UX */
664 ** Neither AIX nor HP-UX - Solaris, and any other
667 if (dlbindreq(p
->fd
, 0, p
->errbuf
) < 0 ||
668 dlbindack(p
->fd
, (char *)buf
, p
->errbuf
, NULL
) < 0) {
672 #endif /* AIX vs. HP-UX vs. other */
675 * Turn a negative snapshot value (invalid), a snapshot value of
676 * 0 (unspecified), or a value bigger than the normal maximum
677 * value, into the maximum allowed value.
679 * If some application really *needs* a bigger snapshot
680 * length, we should just increase MAXIMUM_SNAPLEN.
682 if (p
->snapshot
<= 0 || p
->snapshot
> MAXIMUM_SNAPLEN
)
683 p
->snapshot
= MAXIMUM_SNAPLEN
;
688 ** Have to turn on some special ATM promiscuous mode
690 ** Do *NOT* turn regular promiscuous mode on; it doesn't
691 ** help, and may break things.
693 if (strioctl(p
->fd
, A_PROMISCON_REQ
, 0, NULL
) < 0) {
695 pcapint_fmt_errmsg_for_errno(p
->errbuf
, PCAP_ERRBUF_SIZE
,
696 errno
, "A_PROMISCON_REQ");
701 if (p
->opt
.promisc
) {
703 ** Enable promiscuous (not necessary on send FD)
705 retv
= dlpromiscon(p
, DL_PROMISC_PHYS
);
707 if (retv
== PCAP_ERROR_PERM_DENIED
)
708 status
= PCAP_ERROR_PROMISC_PERM_DENIED
;
715 ** Try to enable multicast (you would have thought
716 ** promiscuous would be sufficient). (Skip if using
717 ** HP-UX) (Not necessary on send FD)
720 retv
= dlpromiscon(p
, DL_PROMISC_MULTI
);
722 status
= PCAP_WARNING
;
726 ** Try to enable SAP promiscuity (when not in promiscuous mode
727 ** when using HP-UX, when not doing SunATM on Solaris)
728 ** (Not necessary on send FD)
731 /* HP-UX - only do this when not in promiscuous mode */
732 if (!p
->opt
.promisc
) {
733 #elif defined(HAVE_SOLARIS)
734 /* Solaris - don't do this on SunATM devices */
737 /* Everything else - always do this. */
740 retv
= dlpromiscon(p
, DL_PROMISC_SAP
);
742 if (p
->opt
.promisc
) {
744 * Not fatal, since the DL_PROMISC_PHYS mode
747 * Report it as a warning, however.
749 status
= PCAP_WARNING
;
761 ** HP-UX 10.20 or later must bind after setting
762 ** promiscuous options.
764 #if defined(HAVE_HPUX10_20_OR_LATER)
765 if (dl_dohpuxbind(p
->fd
, p
->errbuf
) < 0) {
770 ** We don't set promiscuous mode on the send FD, but we'll defer
771 ** binding it anyway, just to keep the HP-UX 10.20 or later
774 if (pd
->send_fd
>= 0) {
776 ** XXX - if this fails, just close send_fd and
777 ** set it to -1, so that you can't send but can
780 if (dl_dohpuxbind(pd
->send_fd
, p
->errbuf
) < 0) {
788 ** Determine link type
789 ** XXX - get SAP length and address length as well, for use
790 ** when sending packets.
792 if (dlinforeq(p
->fd
, p
->errbuf
) < 0 ||
793 dlinfoack(p
->fd
, (char *)buf
, p
->errbuf
) < 0) {
798 infop
= &(MAKE_DL_PRIMITIVES(buf
))->info_ack
;
799 if (pcap_process_mactype(p
, infop
->dl_mac_type
) != 0) {
806 ** This is a non standard SunOS hack to get the full raw link-layer
809 if (strioctl(p
->fd
, DLIOCRAW
, 0, NULL
) < 0) {
811 pcapint_fmt_errmsg_for_errno(p
->errbuf
, PCAP_ERRBUF_SIZE
,
817 #ifdef HAVE_SYS_BUFMOD_H
819 /* Push and configure bufmod. */
820 if (pcap_conf_bufmod(p
, ss
) != 0) {
827 ** As the last operation flush the read side.
829 if (ioctl(p
->fd
, I_FLUSH
, FLUSHR
) != 0) {
831 pcapint_fmt_errmsg_for_errno(p
->errbuf
, PCAP_ERRBUF_SIZE
,
836 /* Allocate data buffer. */
837 if (pcap_alloc_databuf(p
) != 0) {
845 * "p->fd" is an FD for a STREAMS device, so "select()" and
846 * "poll()" should work on it.
848 p
->selectable_fd
= p
->fd
;
850 p
->read_op
= pcap_read_dlpi
;
851 p
->inject_op
= pcap_inject_dlpi
;
852 p
->setfilter_op
= pcapint_install_bpf_program
; /* no kernel filtering */
853 p
->setdirection_op
= NULL
; /* Not implemented.*/
854 p
->set_datalink_op
= NULL
; /* can't change data link type */
855 p
->getnonblock_op
= pcapint_getnonblock_fd
;
856 p
->setnonblock_op
= pcapint_setnonblock_fd
;
857 p
->stats_op
= pcap_stats_dlpi
;
858 p
->cleanup_op
= pcap_cleanup_dlpi
;
862 pcap_cleanup_dlpi(p
);
867 * Split a device name into a device type name and a unit number;
868 * return the a pointer to the beginning of the unit number, which
869 * is the end of the device type name, and set "*unitp" to the unit
872 * Returns NULL on error, and fills "ebuf" with an error message.
875 split_dname(char *device
, u_int
*unitp
, char *ebuf
)
882 * Look for a number at the end of the device name string.
884 cp
= device
+ strlen(device
) - 1;
885 if (*cp
< '0' || *cp
> '9') {
886 snprintf(ebuf
, PCAP_ERRBUF_SIZE
, "%s missing unit number",
891 /* Digits at end of string are unit number */
892 while (cp
-1 >= device
&& *(cp
-1) >= '0' && *(cp
-1) <= '9')
896 unit
= strtol(cp
, &eos
, 10);
898 snprintf(ebuf
, PCAP_ERRBUF_SIZE
, "%s bad unit number", device
);
901 if (errno
== ERANGE
|| unit
> INT_MAX
) {
902 snprintf(ebuf
, PCAP_ERRBUF_SIZE
, "%s unit number too large",
907 snprintf(ebuf
, PCAP_ERRBUF_SIZE
, "%s unit number is negative",
911 *unitp
= (u_int
)unit
;
916 dl_doattach(int fd
, int ppa
, char *ebuf
)
919 bpf_u_int32 buf
[MAXDLBUF
];
922 req
.dl_primitive
= DL_ATTACH_REQ
;
924 if (send_request(fd
, (char *)&req
, sizeof(req
), "attach", ebuf
) < 0)
927 err
= dlokack(fd
, "attach", (char *)buf
, ebuf
, NULL
);
935 dl_dohpuxbind(int fd
, char *ebuf
)
939 bpf_u_int32 buf
[MAXDLBUF
];
942 * XXX - we start at 22 because we used to use only 22, but
943 * that was just because that was the value used in some
944 * sample code from HP. With what value *should* we start?
945 * Does it matter, given that we're enabling SAP promiscuity
950 if (dlbindreq(fd
, hpsap
, ebuf
) < 0)
952 if (dlbindack(fd
, (char *)buf
, ebuf
, &uerror
) >= 0)
955 * For any error other than a UNIX EBUSY, give up.
957 if (uerror
!= EBUSY
) {
959 * dlbindack() has already filled in ebuf for
966 * For EBUSY, try the next SAP value; that means that
967 * somebody else is using that SAP. Clear ebuf so
968 * that application doesn't report the "Device busy"
969 * error as a warning.
974 pcapint_strlcpy(ebuf
,
975 "All SAPs from 22 through 100 are in use",
984 #define STRINGIFY(n) #n
987 dlpromiscon(pcap_t
*p
, bpf_u_int32 level
)
989 dl_promiscon_req_t req
;
990 bpf_u_int32 buf
[MAXDLBUF
];
994 req
.dl_primitive
= DL_PROMISCON_REQ
;
995 req
.dl_level
= level
;
996 if (send_request(p
->fd
, (char *)&req
, sizeof(req
), "promiscon",
999 err
= dlokack(p
->fd
, "promiscon" STRINGIFY(level
), (char *)buf
,
1000 p
->errbuf
, &uerror
);
1002 if (err
== PCAP_ERROR_PERM_DENIED
) {
1003 snprintf(p
->errbuf
, PCAP_ERRBUF_SIZE
,
1004 "Attempt to set promiscuous mode failed with %s - root privilege may be required",
1005 (uerror
== EPERM
) ? "EPERM" : "EACCES");
1006 err
= PCAP_ERROR_PROMISC_PERM_DENIED
;
1014 * Not all interfaces are DLPI interfaces, and thus not all interfaces
1015 * can be opened with DLPI (for example, the loopback interface is not
1016 * a DLPI interface on Solaris prior to Solaris 11), so try to open
1017 * the specified interface; return 0 if we fail with PCAP_ERROR_NO_SUCH_DEVICE
1021 is_dlpi_interface(const char *name
)
1025 char errbuf
[PCAP_ERRBUF_SIZE
];
1027 fd
= open_dlpi_device(name
, &ppa
, errbuf
);
1030 * Error - was it PCAP_ERROR_NO_SUCH_DEVICE?
1032 if (fd
== PCAP_ERROR_NO_SUCH_DEVICE
) {
1034 * Yes, so we can't open this because it's
1035 * not a DLPI interface.
1040 * No, so, in the case where there's a single DLPI
1041 * device for all interfaces of this type ("style
1042 * 2" providers?), we don't know whether it's a DLPI
1043 * interface or not, as we didn't try an attach.
1044 * Say it is a DLPI device, so that the user can at
1045 * least try to open it and report the error (which
1046 * is probably "you don't have permission to open that
1047 * DLPI device"; reporting those interfaces means
1048 * users will ask "why am I getting a permissions error
1049 * when I try to capture" rather than "why am I not
1050 * seeing any interfaces", making the underlying problem
1064 get_if_flags(const char *name _U_
, bpf_u_int32
*flags _U_
, char *errbuf _U_
)
1067 * Nothing we can do other than mark loopback devices as "the
1068 * connected/disconnected status doesn't apply".
1070 * XXX - on Solaris, can we do what the dladm command does,
1071 * i.e. get a connected/disconnected indication from a kstat?
1072 * (Note that you can also get the link speed, and possibly
1073 * other information, from a kstat as well.)
1075 if (*flags
& PCAP_IF_LOOPBACK
) {
1077 * Loopback devices aren't wireless, and "connected"/
1078 * "disconnected" doesn't apply to them.
1080 *flags
|= PCAP_IF_CONNECTION_STATUS_NOT_APPLICABLE
;
1087 pcapint_platform_finddevs(pcap_if_list_t
*devlistp
, char *errbuf
)
1093 char pad
[516]; /* XXX - must be at least 513; is 516
1101 * Get the list of regular interfaces first.
1103 if (pcapint_findalldevs_interfaces(devlistp
, errbuf
, is_dlpi_interface
,
1104 get_if_flags
) == -1)
1105 return (-1); /* failure */
1109 * We may have to do special magic to get ATM devices.
1111 if ((fd
= open("/dev/ba", O_RDWR
)) < 0) {
1113 * We couldn't open the "ba" device.
1114 * For now, just give up; perhaps we should
1115 * return an error if the problem is neither
1116 * a "that device doesn't exist" error (ENOENT,
1117 * ENXIO, etc.) or a "you're not allowed to do
1118 * that" error (EPERM, EACCES).
1123 if (strioctl(fd
, A_GET_UNITS
, sizeof(buf
), (char *)&buf
) < 0) {
1124 pcapint_fmt_errmsg_for_errno(errbuf
, PCAP_ERRBUF_SIZE
,
1125 errno
, "A_GET_UNITS");
1128 for (i
= 0; i
< buf
.nunits
; i
++) {
1129 snprintf(baname
, sizeof baname
, "ba%u", i
);
1131 * XXX - is there a notion of "up" and "running"?
1132 * And is there a way to determine whether the
1133 * interface is plugged into a network?
1135 if (pcapint_add_dev(devlistp
, baname
, 0, NULL
, errbuf
) == NULL
)
1144 send_request(int fd
, char *ptr
, int len
, char *what
, char *ebuf
)
1154 if (putmsg(fd
, &ctl
, (struct strbuf
*) NULL
, flags
) < 0) {
1155 pcapint_fmt_errmsg_for_errno(ebuf
, PCAP_ERRBUF_SIZE
,
1156 errno
, "send_request: putmsg \"%s\"", what
);
1163 recv_ack(int fd
, int size
, const char *what
, char *bufp
, char *ebuf
, int *uerror
)
1165 union DL_primitives
*dlp
;
1168 char errmsgbuf
[PCAP_ERRBUF_SIZE
];
1172 * Clear out "*uerror", so it's only set for DL_ERROR_ACK/DL_SYSERR,
1173 * making that the only place where EBUSY is treated specially.
1178 ctl
.maxlen
= MAXDLBUF
;
1183 if (getmsg(fd
, &ctl
, (struct strbuf
*)NULL
, &flags
) < 0) {
1184 pcapint_fmt_errmsg_for_errno(ebuf
, PCAP_ERRBUF_SIZE
,
1185 errno
, "recv_ack: %s getmsg", what
);
1186 return (PCAP_ERROR
);
1189 dlp
= MAKE_DL_PRIMITIVES(ctl
.buf
);
1190 switch (dlp
->dl_primitive
) {
1195 #ifdef DL_HP_PPA_ACK
1202 switch (dlp
->error_ack
.dl_errno
) {
1206 *uerror
= dlp
->error_ack
.dl_unix_errno
;
1207 pcapint_fmt_errmsg_for_errno(ebuf
, PCAP_ERRBUF_SIZE
,
1208 dlp
->error_ack
.dl_unix_errno
,
1209 "recv_ack: %s: UNIX error", what
);
1210 if (dlp
->error_ack
.dl_unix_errno
== EPERM
||
1211 dlp
->error_ack
.dl_unix_errno
== EACCES
)
1212 return (PCAP_ERROR_PERM_DENIED
);
1217 * Neither EPERM nor EACCES.
1219 snprintf(ebuf
, PCAP_ERRBUF_SIZE
,
1220 "recv_ack: %s: %s", what
,
1221 dlstrerror(errmsgbuf
, sizeof (errmsgbuf
), dlp
->error_ack
.dl_errno
));
1222 if (dlp
->error_ack
.dl_errno
== DL_BADPPA
)
1223 return (PCAP_ERROR_NO_SUCH_DEVICE
);
1224 else if (dlp
->error_ack
.dl_errno
== DL_ACCESS
)
1225 return (PCAP_ERROR_PERM_DENIED
);
1228 return (PCAP_ERROR
);
1231 snprintf(ebuf
, PCAP_ERRBUF_SIZE
,
1232 "recv_ack: %s: Unexpected primitive ack %s",
1233 what
, dlprim(dlprimbuf
, sizeof (dlprimbuf
), dlp
->dl_primitive
));
1234 return (PCAP_ERROR
);
1237 if (ctl
.len
< size
) {
1238 snprintf(ebuf
, PCAP_ERRBUF_SIZE
,
1239 "recv_ack: %s: Ack too small (%d < %d)",
1240 what
, ctl
.len
, size
);
1241 return (PCAP_ERROR
);
1247 dlstrerror(char *errbuf
, size_t errbufsize
, bpf_u_int32 dl_errno
)
1252 return ("Improper permissions for request");
1255 return ("DLSAP addr in improper format or invalid");
1258 return ("Seq number not from outstand DL_CONN_IND");
1261 return ("User data exceeded provider limit");
1264 #ifdef HAVE_DEV_DLPI
1266 * With a single "/dev/dlpi" device used for all
1267 * DLPI providers, PPAs have nothing to do with
1270 return ("Specified PPA was invalid");
1273 * We have separate devices for separate devices;
1274 * the PPA is just the unit number.
1276 return ("Specified PPA (device unit) was invalid");
1280 return ("Primitive received not known by provider");
1282 case DL_BADQOSPARAM
:
1283 return ("QOS parameters contained invalid values");
1286 return ("QOS structure type is unknown/unsupported");
1289 return ("Bad LSAP selector");
1292 return ("Token used not an active stream");
1295 return ("Attempted second bind with dl_max_conind");
1298 return ("Physical link initialization failed");
1301 return ("Provider couldn't allocate alternate address");
1304 return ("Physical link not initialized");
1307 return ("Primitive issued in improper state");
1310 return ("UNIX system error occurred");
1312 case DL_UNSUPPORTED
:
1313 return ("Requested service not supplied by provider");
1315 case DL_UNDELIVERABLE
:
1316 return ("Previous data unit could not be delivered");
1318 case DL_NOTSUPPORTED
:
1319 return ("Primitive is known but not supported");
1322 return ("Limit exceeded");
1325 return ("Promiscuous mode not enabled");
1328 return ("Other streams for PPA in post-attached");
1331 return ("Automatic handling XID&TEST not supported");
1334 return ("Automatic handling of XID not supported");
1337 return ("Automatic handling of TEST not supported");
1340 return ("Automatic handling of XID response");
1343 return ("Automatic handling of TEST response");
1346 return ("Pending outstanding connect indications");
1349 snprintf(errbuf
, errbufsize
, "Error %02x", dl_errno
);
1355 dlprim(char *primbuf
, size_t primbufsize
, bpf_u_int32 prim
)
1360 return ("DL_INFO_REQ");
1363 return ("DL_INFO_ACK");
1366 return ("DL_ATTACH_REQ");
1369 return ("DL_DETACH_REQ");
1372 return ("DL_BIND_REQ");
1375 return ("DL_BIND_ACK");
1378 return ("DL_UNBIND_REQ");
1381 return ("DL_OK_ACK");
1384 return ("DL_ERROR_ACK");
1386 case DL_SUBS_BIND_REQ
:
1387 return ("DL_SUBS_BIND_REQ");
1389 case DL_SUBS_BIND_ACK
:
1390 return ("DL_SUBS_BIND_ACK");
1392 case DL_UNITDATA_REQ
:
1393 return ("DL_UNITDATA_REQ");
1395 case DL_UNITDATA_IND
:
1396 return ("DL_UNITDATA_IND");
1398 case DL_UDERROR_IND
:
1399 return ("DL_UDERROR_IND");
1402 return ("DL_UDQOS_REQ");
1404 case DL_CONNECT_REQ
:
1405 return ("DL_CONNECT_REQ");
1407 case DL_CONNECT_IND
:
1408 return ("DL_CONNECT_IND");
1410 case DL_CONNECT_RES
:
1411 return ("DL_CONNECT_RES");
1413 case DL_CONNECT_CON
:
1414 return ("DL_CONNECT_CON");
1417 return ("DL_TOKEN_REQ");
1420 return ("DL_TOKEN_ACK");
1422 case DL_DISCONNECT_REQ
:
1423 return ("DL_DISCONNECT_REQ");
1425 case DL_DISCONNECT_IND
:
1426 return ("DL_DISCONNECT_IND");
1429 return ("DL_RESET_REQ");
1432 return ("DL_RESET_IND");
1435 return ("DL_RESET_RES");
1438 return ("DL_RESET_CON");
1441 snprintf(primbuf
, primbufsize
, "unknown primitive 0x%x",
1448 dlbindreq(int fd
, bpf_u_int32 sap
, char *ebuf
)
1453 memset((char *)&req
, 0, sizeof(req
));
1454 req
.dl_primitive
= DL_BIND_REQ
;
1455 /* XXX - what if neither of these are defined? */
1456 #if defined(DL_HP_RAWDLS)
1457 req
.dl_max_conind
= 1; /* XXX magic number */
1458 req
.dl_service_mode
= DL_HP_RAWDLS
;
1459 #elif defined(DL_CLDLS)
1460 req
.dl_service_mode
= DL_CLDLS
;
1464 return (send_request(fd
, (char *)&req
, sizeof(req
), "bind", ebuf
));
1468 dlbindack(int fd
, char *bufp
, char *ebuf
, int *uerror
)
1471 return (recv_ack(fd
, DL_BIND_ACK_SIZE
, "bind", bufp
, ebuf
, uerror
));
1475 dlokack(int fd
, const char *what
, char *bufp
, char *ebuf
, int *uerror
)
1478 return (recv_ack(fd
, DL_OK_ACK_SIZE
, what
, bufp
, ebuf
, uerror
));
1483 dlinforeq(int fd
, char *ebuf
)
1487 req
.dl_primitive
= DL_INFO_REQ
;
1489 return (send_request(fd
, (char *)&req
, sizeof(req
), "info", ebuf
));
1493 dlinfoack(int fd
, char *bufp
, char *ebuf
)
1496 return (recv_ack(fd
, DL_INFO_ACK_SIZE
, "info", bufp
, ebuf
, NULL
));
1499 #ifdef HAVE_DL_PASSIVE_REQ_T
1501 * Enable DLPI passive mode. We do not care if this request fails, as this
1502 * indicates the underlying DLPI device does not support link aggregation.
1505 dlpassive(int fd
, char *ebuf
)
1507 dl_passive_req_t req
;
1508 bpf_u_int32 buf
[MAXDLBUF
];
1510 req
.dl_primitive
= DL_PASSIVE_REQ
;
1512 if (send_request(fd
, (char *)&req
, sizeof(req
), "dlpassive", ebuf
) == 0)
1513 (void) dlokack(fd
, "dlpassive", (char *)buf
, ebuf
, NULL
);
1519 * There's an ack *if* there's an error.
1522 dlrawdatareq(int fd
, const u_char
*datap
, int datalen
)
1524 struct strbuf ctl
, data
;
1525 long buf
[MAXDLBUF
]; /* XXX - char? */
1526 union DL_primitives
*dlp
;
1529 dlp
= MAKE_DL_PRIMITIVES(buf
);
1531 dlp
->dl_primitive
= DL_HP_RAWDATA_REQ
;
1532 dlen
= DL_HP_RAWDATA_REQ_SIZE
;
1535 * HP's documentation doesn't appear to show us supplying any
1536 * address pointed to by the control part of the message.
1537 * I think that's what raw mode means - you just send the raw
1538 * packet, you don't specify where to send it to, as that's
1539 * implied by the destination address.
1543 ctl
.buf
= (void *)buf
;
1547 data
.buf
= (void *)datap
;
1549 return (putmsg(fd
, &ctl
, &data
, 0));
1551 #endif /* DL_HP_RAWDLS */
1553 #ifdef DL_HP_PPA_REQ
1555 * Under HP-UX 10 and HP-UX 11, we can ask for the ppa
1560 * Determine ppa number that specifies ifname.
1562 * If the "dl_hp_ppa_info_t" doesn't have a "dl_module_id_1" member,
1563 * the code that's used here is the old code for HP-UX 10.x.
1565 * However, HP-UX 10.20, at least, appears to have such a member
1566 * in its "dl_hp_ppa_info_t" structure, so the new code is used.
1567 * The new code didn't work on an old 10.20 system on which Rick
1568 * Jones of HP tried it, but with later patches installed, it
1569 * worked - it appears that the older system had those members but
1570 * didn't put anything in them, so, if the search by name fails, we
1571 * do the old search.
1573 * Rick suggests that making sure your system is "up on the latest
1574 * lancommon/DLPI/driver patches" is probably a good idea; it'd fix
1575 * that problem, as well as allowing libpcap to see packets sent
1576 * from the system on which the libpcap application is being run.
1577 * (On 10.20, in addition to getting the latest patches, you need
1578 * to turn the kernel "lanc_outbound_promisc_flag" flag on with ADB;
1579 * a posting to "comp.sys.hp.hpux" at
1581 * http://www.deja.com/[ST_rn=ps]/getdoc.xp?AN=558092266
1583 * says that, to see the machine's outgoing traffic, you'd need to
1584 * apply the right patches to your system, and also set that variable
1587 echo 'lanc_outbound_promisc_flag/W1' | /usr/bin/adb -w /stand/vmunix /dev/kmem
1589 * which could be put in, for example, "/sbin/init.d/lan".
1591 * Setting the variable is not necessary on HP-UX 11.x.
1594 get_dlpi_ppa(register int fd
, register const char *device
, register u_int unit
,
1595 u_int
*ppa
, register char *ebuf
)
1597 register dl_hp_ppa_ack_t
*ap
;
1598 register dl_hp_ppa_info_t
*ipstart
, *ip
;
1601 register u_long majdev
;
1602 struct stat statbuf
;
1603 dl_hp_ppa_req_t req
;
1606 dl_hp_ppa_ack_t
*dlp
;
1610 memset((char *)&req
, 0, sizeof(req
));
1611 req
.dl_primitive
= DL_HP_PPA_REQ
;
1613 memset((char *)buf
, 0, sizeof(buf
));
1614 if (send_request(fd
, (char *)&req
, sizeof(req
), "hpppa", ebuf
) < 0)
1615 return (PCAP_ERROR
);
1617 ctl
.maxlen
= DL_HP_PPA_ACK_SIZE
;
1619 ctl
.buf
= (char *)buf
;
1623 * DLPI may return a big chunk of data for a DL_HP_PPA_REQ. The normal
1624 * recv_ack will fail because it set the maxlen to MAXDLBUF (8192)
1625 * which is NOT big enough for a DL_HP_PPA_REQ.
1627 * This causes libpcap applications to fail on a system with HP-APA
1630 * To figure out how big the returned data is, we first call getmsg
1631 * to get the small head and peek at the head to get the actual data
1632 * length, and then issue another getmsg to get the actual PPA data.
1634 /* get the head first */
1635 if (getmsg(fd
, &ctl
, (struct strbuf
*)NULL
, &flags
) < 0) {
1636 pcapint_fmt_errmsg_for_errno(ebuf
, PCAP_ERRBUF_SIZE
,
1637 errno
, "get_dlpi_ppa: hpppa getmsg");
1638 return (PCAP_ERROR
);
1640 if (ctl
.len
== -1) {
1641 snprintf(ebuf
, PCAP_ERRBUF_SIZE
,
1642 "get_dlpi_ppa: hpppa getmsg: control buffer has no data");
1643 return (PCAP_ERROR
);
1646 dlp
= (dl_hp_ppa_ack_t
*)ctl
.buf
;
1647 if (dlp
->dl_primitive
!= DL_HP_PPA_ACK
) {
1648 snprintf(ebuf
, PCAP_ERRBUF_SIZE
,
1649 "get_dlpi_ppa: hpppa unexpected primitive ack 0x%x",
1650 (bpf_u_int32
)dlp
->dl_primitive
);
1651 return (PCAP_ERROR
);
1654 if ((size_t)ctl
.len
< DL_HP_PPA_ACK_SIZE
) {
1655 snprintf(ebuf
, PCAP_ERRBUF_SIZE
,
1656 "get_dlpi_ppa: hpppa ack too small (%d < %lu)",
1657 ctl
.len
, (unsigned long)DL_HP_PPA_ACK_SIZE
);
1658 return (PCAP_ERROR
);
1661 /* allocate buffer */
1662 if ((ppa_data_buf
= (char *)malloc(dlp
->dl_length
)) == NULL
) {
1663 pcapint_fmt_errmsg_for_errno(ebuf
, PCAP_ERRBUF_SIZE
,
1664 errno
, "get_dlpi_ppa: hpppa malloc");
1665 return (PCAP_ERROR
);
1667 ctl
.maxlen
= dlp
->dl_length
;
1669 ctl
.buf
= (char *)ppa_data_buf
;
1671 if (getmsg(fd
, &ctl
, (struct strbuf
*)NULL
, &flags
) < 0) {
1672 pcapint_fmt_errmsg_for_errno(ebuf
, PCAP_ERRBUF_SIZE
,
1673 errno
, "get_dlpi_ppa: hpppa getmsg");
1675 return (PCAP_ERROR
);
1677 if (ctl
.len
== -1) {
1678 snprintf(ebuf
, PCAP_ERRBUF_SIZE
,
1679 "get_dlpi_ppa: hpppa getmsg: control buffer has no data");
1680 return (PCAP_ERROR
);
1682 if ((u_int
)ctl
.len
< dlp
->dl_length
) {
1683 snprintf(ebuf
, PCAP_ERRBUF_SIZE
,
1684 "get_dlpi_ppa: hpppa ack too small (%d < %lu)",
1685 ctl
.len
, (unsigned long)dlp
->dl_length
);
1687 return (PCAP_ERROR
);
1690 ap
= (dl_hp_ppa_ack_t
*)buf
;
1691 ipstart
= (dl_hp_ppa_info_t
*)ppa_data_buf
;
1694 #ifdef HAVE_DL_HP_PPA_INFO_T_DL_MODULE_ID_1
1696 * The "dl_hp_ppa_info_t" structure has a "dl_module_id_1"
1697 * member that should, in theory, contain the part of the
1698 * name for the device that comes before the unit number,
1699 * and should also have a "dl_module_id_2" member that may
1700 * contain an alternate name (e.g., I think Ethernet devices
1701 * have both "lan", for "lanN", and "snap", for "snapN", with
1702 * the former being for Ethernet packets and the latter being
1703 * for 802.3/802.2 packets).
1705 * Search for the device that has the specified name and
1708 for (i
= 0; i
< ap
->dl_count
; i
++) {
1709 if ((strcmp((const char *)ip
->dl_module_id_1
, device
) == 0 ||
1710 strcmp((const char *)ip
->dl_module_id_2
, device
) == 0) &&
1711 ip
->dl_instance_num
== unit
)
1714 ip
= (dl_hp_ppa_info_t
*)((u_char
*)ipstart
+ ip
->dl_next_offset
);
1718 * We don't have that member, so the search is impossible; make it
1719 * look as if the search failed.
1724 if (i
== ap
->dl_count
) {
1726 * Well, we didn't, or can't, find the device by name.
1728 * HP-UX 10.20, whilst it has "dl_module_id_1" and
1729 * "dl_module_id_2" fields in the "dl_hp_ppa_info_t",
1730 * doesn't seem to fill them in unless the system is
1731 * at a reasonably up-to-date patch level.
1733 * Older HP-UX 10.x systems might not have those fields
1736 * Therefore, we'll search for the entry with the major
1737 * device number of a device with the name "/dev/<dev><unit>",
1738 * if such a device exists, as the old code did.
1740 snprintf(dname
, sizeof(dname
), "/dev/%s%u", device
, unit
);
1741 if (stat(dname
, &statbuf
) < 0) {
1742 pcapint_fmt_errmsg_for_errno(ebuf
, PCAP_ERRBUF_SIZE
,
1743 errno
, "stat: %s", dname
);
1744 return (PCAP_ERROR
);
1746 majdev
= major(statbuf
.st_rdev
);
1750 for (i
= 0; i
< ap
->dl_count
; i
++) {
1751 if (ip
->dl_mjr_num
== majdev
&&
1752 ip
->dl_instance_num
== unit
)
1755 ip
= (dl_hp_ppa_info_t
*)((u_char
*)ipstart
+ ip
->dl_next_offset
);
1758 if (i
== ap
->dl_count
) {
1759 snprintf(ebuf
, PCAP_ERRBUF_SIZE
,
1760 "can't find /dev/dlpi PPA for %s%u", device
, unit
);
1761 return (PCAP_ERROR_NO_SUCH_DEVICE
);
1763 if (ip
->dl_hdw_state
== HDW_DEAD
) {
1764 snprintf(ebuf
, PCAP_ERRBUF_SIZE
,
1765 "%s%d: hardware state: DOWN\n", device
, unit
);
1767 return (PCAP_ERROR
);
1776 pcapint_create_interface(const char *device _U_
, char *ebuf
)
1780 struct pcap_dlpi
*pd
;
1783 p
= PCAP_CREATE_COMMON(ebuf
, struct pcap_dlpi
);
1789 pd
->send_fd
= -1; /* it hasn't been opened yet */
1792 p
->activate_op
= pcap_activate_dlpi
;
1797 * Libpcap version string.
1800 pcap_lib_version(void)
1802 return (PCAP_VERSION_STRING
);