Lines Matching +full:message +full:- +full:handling +full:- +full:unit
24 * <List-tcpdump-workers@subscriptions.pizzolato.net>,
29 * Packet capture routine for DLPI under SunOS 5, HP-UX 9/10/11, and AIX.
33 * - The DLIOCRAW ioctl() is specific to SunOS.
35 * - There is a bug in bufmod(7) such that setting the snapshot
38 * - It might be desirable to use pfmod(7) to filter packets in the
41 * - An older version of the HP-UX DLPI Programmer's Guide, which
45 * http://docs.hp.com/hpux/onlinedocs/B2355-90093/B2355-90093.html
49 * http://h21007.www2.hp.com/dspp/files/unprotected/Drivers/Docs/Refs/B2355-90093.pdf
53 * - The HP-UX 10.x, 11.0, and 11i v1.6 version of the HP-UX DLPI
57 * http://docs.hp.com/en/B2355-90139/index.html
59 * - The HP-UX 11i v2 version of the HP-UX DLPI Programmer's Guide
62 * http://docs.hp.com/en/B2355-90871/index.html
64 * - All of the HP documents describe raw-mode services, which are
65 * what we use if DL_HP_RAWDLS is defined. XXX - we use __hpux
66 * in some places to test for HP-UX, but use DL_HP_RAWDLS in
67 * other places; do we support any versions of HP-UX without
110 #include "pcap-int.h"
114 #include "os-proto.h"
119 * HP-UX has a /dev/dlpi device; you open it and set the PPA of the actual
195 cc = p->cc; in pcap_read_dlpi()
197 data.buf = (char *)p->buffer + p->offset; in pcap_read_dlpi()
198 data.maxlen = p->bufsize; in pcap_read_dlpi()
204 if (p->break_loop) { in pcap_read_dlpi()
206 * Yes - clear the flag that indicates in pcap_read_dlpi()
207 * that it has, and return -2 to in pcap_read_dlpi()
211 p->break_loop = 0; in pcap_read_dlpi()
212 return (-2); in pcap_read_dlpi()
215 * XXX - check for the DLPI primitive, which in pcap_read_dlpi()
216 * would be DL_HP_RAWDATA_IND on HP-UX in pcap_read_dlpi()
222 if (getmsg(p->fd, &ctl, &data, &flags) < 0) { in pcap_read_dlpi()
233 pcapint_fmt_errmsg_for_errno(p->errbuf, in pcap_read_dlpi()
234 sizeof(p->errbuf), errno, "getmsg"); in pcap_read_dlpi()
235 return (-1); in pcap_read_dlpi()
239 bp = (u_char *)p->buffer + p->offset; in pcap_read_dlpi()
241 bp = p->bp; in pcap_read_dlpi()
250 struct pcap_dlpi *pd = p->priv; in pcap_inject_dlpi()
255 ret = write(p->fd, buf, size); in pcap_inject_dlpi()
256 if (ret == -1) { in pcap_inject_dlpi()
257 pcapint_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE, in pcap_inject_dlpi()
259 return (-1); in pcap_inject_dlpi()
262 if (pd->send_fd < 0) { in pcap_inject_dlpi()
263 snprintf(p->errbuf, PCAP_ERRBUF_SIZE, in pcap_inject_dlpi()
265 return (-1); in pcap_inject_dlpi()
267 ret = dlrawdatareq(pd->send_fd, buf, size); in pcap_inject_dlpi()
268 if (ret == -1) { in pcap_inject_dlpi()
269 pcapint_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE, in pcap_inject_dlpi()
271 return (-1); in pcap_inject_dlpi()
274 * putmsg() returns either 0 or -1; it doesn't indicate how in pcap_inject_dlpi()
283 * XXX - this is a pain, because you might have to extract in pcap_inject_dlpi()
285 * request. That would be dependent on the link-layer type. in pcap_inject_dlpi()
294 * and leave it up to somebody with a DLPI-based system lacking in pcap_inject_dlpi()
297 * send it to us - but should not send us code that assumes in pcap_inject_dlpi()
298 * Ethernet; if the code doesn't work on non-Ethernet interfaces, in pcap_inject_dlpi()
299 * it should check "p->linktype" and reject the send request if in pcap_inject_dlpi()
302 pcapint_strlcpy(p->errbuf, "send: Not supported on this version of this OS", in pcap_inject_dlpi()
304 ret = -1; in pcap_inject_dlpi()
329 struct pcap_dlpi *pd = p->priv; in pcap_cleanup_dlpi()
331 if (pd->send_fd >= 0) { in pcap_cleanup_dlpi()
332 close(pd->send_fd); in pcap_cleanup_dlpi()
333 pd->send_fd = -1; in pcap_cleanup_dlpi()
347 u_int unit; in open_dlpi_device() local
363 * Split the device name into a device type name and a unit number; in open_dlpi_device()
364 * chop off the unit number, so "dname" is just a device type name. in open_dlpi_device()
366 cp = split_dname(dname, &unit, errbuf); in open_dlpi_device()
369 * split_dname() has filled in the error message. in open_dlpi_device()
378 * XXX - HP's DLPI Programmer's Guide for HP-UX 11.00 says that in open_dlpi_device()
391 "Attempt to open %s failed with %s - root privilege may be required", in open_dlpi_device()
403 * table for the specified device type name and unit number. in open_dlpi_device()
405 status = get_dlpi_ppa(fd, dname, unit, ppa, errbuf); in open_dlpi_device()
424 * Get the unit number, and a pointer to the end of the device in open_dlpi_device()
430 * split_dname() has filled in the error message. in open_dlpi_device()
436 * Make a copy of the device pathname, and then remove the unit in open_dlpi_device()
442 /* Try device without unit number */ in open_dlpi_device()
448 "Attempt to open %s failed with %s - root privilege may be required", in open_dlpi_device()
460 /* Try again with unit number */ in open_dlpi_device()
466 * We provide an error message even in open_dlpi_device()
469 * the app can show the message if the in open_dlpi_device()
481 * other than Solaris - you just *can't* in open_dlpi_device()
494 "Attempt to open %s failed with %s - root privilege may be required", in open_dlpi_device()
507 /* XXX Assume unit zero */ in open_dlpi_device()
518 struct pcap_dlpi *pd = p->priv;
536 p->fd = open_dlpi_device(p->opt.device, &ppa, p->errbuf);
537 if (p->fd < 0) {
538 status = p->fd;
544 * XXX - HP-UX 10.20 and 11.xx don't appear to support sending and
545 * receiving packets on the same descriptor - you need separate
548 * If the open fails, we just leave -1 in "pd->send_fd" and reject
549 * attempts to send packets, just as if, in pcap-bpf.c, we fail
554 pd->send_fd = open("/dev/dlpi", O_RDWR);
560 if (dlinforeq(p->fd, p->errbuf) < 0 ||
561 dlinfoack(p->fd, (char *)buf, p->errbuf) < 0) {
565 infop = &(MAKE_DL_PRIMITIVES(buf))->info_ack;
567 if (infop->dl_mac_type == DL_IPATM)
570 if (infop->dl_provider_style == DL_STYLE2) {
571 retv = dl_doattach(p->fd, ppa, p->errbuf);
577 if (pd->send_fd >= 0) {
578 retv = dl_doattach(pd->send_fd, ppa, p->errbuf);
587 if (p->opt.rfmon) {
601 dlpassive(p->fd, p->errbuf);
604 ** Bind (defer if using HP-UX 9 or HP-UX 10.20 or later, totally
613 ** However, we seem to get DL_BADADDR - "DLSAP addr in improper
614 ** format or invalid" - errors if we use 1537 on the "tr0"
623 ** work; perhaps that's considered an invalid LLC SAP value - I
627 if ((dlbindreq(p->fd, 1537, p->errbuf) < 0 &&
628 dlbindreq(p->fd, 2, p->errbuf) < 0) ||
629 dlbindack(p->fd, (char *)buf, p->errbuf, NULL) < 0) {
635 ** HP-UX 10.0x and 10.1x.
637 if (dl_dohpuxbind(p->fd, p->errbuf) < 0) {
641 if (pd->send_fd >= 0) {
643 ** XXX - if this fails, just close send_fd and
644 ** set it to -1, so that you can't send but can
647 if (dl_dohpuxbind(pd->send_fd, p->errbuf) < 0) {
652 #else /* neither AIX nor HP-UX */
654 ** Not Sinix, and neither AIX nor HP-UX - Solaris, and any other
657 if (dlbindreq(p->fd, 0, p->errbuf) < 0 ||
658 dlbindack(p->fd, (char *)buf, p->errbuf, NULL) < 0) {
662 #endif /* AIX vs. HP-UX vs. other */
663 #endif /* !HP-UX 9 and !HP-UX 10.20 or later and !SINIX */
673 if (p->snapshot <= 0 || p->snapshot > MAXIMUM_SNAPLEN)
674 p->snapshot = MAXIMUM_SNAPLEN;
684 if (strioctl(p->fd, A_PROMISCON_REQ, 0, NULL) < 0) {
686 pcapint_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
692 if (p->opt.promisc) {
708 ** HP-UX or SINIX) (Not necessary on send FD)
718 ** when using HP-UX, when not doing SunATM on Solaris, and never
723 /* HP-UX - only do this when not in promiscuous mode */
724 if (!p->opt.promisc) {
726 /* Solaris - don't do this on SunATM devices */
729 /* Everything else (except for SINIX) - always do this */
734 if (p->opt.promisc) {
754 ** HP-UX 9, and HP-UX 10.20 or later, must bind after setting
758 if (dl_dohpuxbind(p->fd, p->errbuf) < 0) {
764 ** binding it anyway, just to keep the HP-UX 9/10.20 or later
767 if (pd->send_fd >= 0) {
769 ** XXX - if this fails, just close send_fd and
770 ** set it to -1, so that you can't send but can
773 if (dl_dohpuxbind(pd->send_fd, p->errbuf) < 0) {
782 ** XXX - get SAP length and address length as well, for use
785 if (dlinforeq(p->fd, p->errbuf) < 0 ||
786 dlinfoack(p->fd, (char *)buf, p->errbuf) < 0) {
791 infop = &(MAKE_DL_PRIMITIVES(buf))->info_ack;
792 if (pcap_process_mactype(p, infop->dl_mac_type) != 0) {
799 ** This is a non standard SunOS hack to get the full raw link-layer
802 if (strioctl(p->fd, DLIOCRAW, 0, NULL) < 0) {
804 pcapint_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
811 ss = p->snapshot;
825 snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
843 if (ioctl(p->fd, I_FLUSH, FLUSHR) != 0) {
845 pcapint_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
859 * "p->fd" is an FD for a STREAMS device, so "select()" and
862 p->selectable_fd = p->fd;
864 p->read_op = pcap_read_dlpi;
865 p->inject_op = pcap_inject_dlpi;
866 p->setfilter_op = pcapint_install_bpf_program; /* no kernel filtering */
867 p->setdirection_op = NULL; /* Not implemented.*/
868 p->set_datalink_op = NULL; /* can't change data link type */
869 p->getnonblock_op = pcapint_getnonblock_fd;
870 p->setnonblock_op = pcapint_setnonblock_fd;
871 p->stats_op = pcap_stats_dlpi;
872 p->cleanup_op = pcap_cleanup_dlpi;
881 * Split a device name into a device type name and a unit number;
882 * return the a pointer to the beginning of the unit number, which
883 * is the end of the device type name, and set "*unitp" to the unit
886 * Returns NULL on error, and fills "ebuf" with an error message.
893 long unit; local
898 cp = device + strlen(device) - 1;
900 snprintf(ebuf, PCAP_ERRBUF_SIZE, "%s missing unit number",
905 /* Digits at end of string are unit number */
906 while (cp-1 >= device && *(cp-1) >= '0' && *(cp-1) <= '9')
907 cp--;
910 unit = strtol(cp, &eos, 10);
912 snprintf(ebuf, PCAP_ERRBUF_SIZE, "%s bad unit number", device);
915 if (errno == ERANGE || unit > INT_MAX) {
916 snprintf(ebuf, PCAP_ERRBUF_SIZE, "%s unit number too large",
920 if (unit < 0) {
921 snprintf(ebuf, PCAP_ERRBUF_SIZE, "%s unit number is negative",
925 *unitp = (u_int)unit;
956 * XXX - we start at 22 because we used to use only 22, but
965 return (-1);
976 return (-1);
991 return (-1);
1010 if (send_request(p->fd, (char *)&req, sizeof(req), "promiscon",
1011 p->errbuf) < 0)
1013 err = dlokack(p->fd, "promiscon" STRINGIFY(level), (char *)buf,
1014 p->errbuf, &uerror);
1017 snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
1018 "Attempt to set promiscuous mode failed with %s - root privilege may be required",
1044 * Error - was it PCAP_ERROR_NO_SUCH_DEVICE?
1084 * XXX - on Solaris, can we do what the dladm command does,
1107 char pad[516]; /* XXX - must be at least 513; is 516
1118 get_if_flags) == -1)
1119 return (-1); /* failure */
1140 return (-1);
1145 * XXX - is there a notion of "up" and "running"?
1150 return (-1);
1171 return (-1);
1204 switch (dlp->dl_primitive) {
1216 switch (dlp->error_ack.dl_errno) {
1220 *uerror = dlp->error_ack.dl_unix_errno;
1222 dlp->error_ack.dl_unix_errno,
1224 if (dlp->error_ack.dl_unix_errno == EPERM ||
1225 dlp->error_ack.dl_unix_errno == EACCES)
1235 dlstrerror(errmsgbuf, sizeof (errmsgbuf), dlp->error_ack.dl_errno));
1236 if (dlp->error_ack.dl_errno == DL_BADPPA)
1238 else if (dlp->error_ack.dl_errno == DL_ACCESS)
1247 what, dlprim(dlprimbuf, sizeof (dlprimbuf), dlp->dl_primitive));
1282 * unit numbers.
1288 * the PPA is just the unit number.
1290 return ("Specified PPA (device unit) was invalid");
1330 return ("Previous data unit could not be delivered");
1342 return ("Other streams for PPA in post-attached");
1345 return ("Automatic handling XID&TEST not supported");
1348 return ("Automatic handling of XID not supported");
1351 return ("Automatic handling of TEST not supported");
1354 return ("Automatic handling of XID response");
1357 return ("Automatic handling of TEST response");
1469 /* XXX - what if neither of these are defined? */
1539 long buf[MAXDLBUF]; /* XXX - char? */
1545 dlp->dl_primitive = DL_HP_RAWDATA_REQ;
1550 * address pointed to by the control part of the message.
1551 * I think that's what raw mode means - you just send the raw
1596 * Under HP-UX 10 and HP-UX 11, we can ask for the ppa
1604 * the code that's used here is the old code for HP-UX 10.x.
1606 * However, HP-UX 10.20, at least, appears to have such a member
1610 * worked - it appears that the older system had those members but
1628 echo 'lanc_outbound_promisc_flag/W1' | /usr/bin/adb -w /stand/vmunix /dev/kmem
1632 * Setting the variable is not necessary on HP-UX 11.x.
1635 get_dlpi_ppa(register int fd, register const char *device, register u_int unit, argument
1668 * This causes libpcap applications to fail on a system with HP-APA
1681 if (ctl.len == -1) {
1688 if (dlp->dl_primitive != DL_HP_PPA_ACK) {
1691 (bpf_u_int32)dlp->dl_primitive);
1703 if ((ppa_data_buf = (char *)malloc(dlp->dl_length)) == NULL) {
1708 ctl.maxlen = dlp->dl_length;
1718 if (ctl.len == -1) {
1723 if ((u_int)ctl.len < dlp->dl_length) {
1726 ctl.len, (unsigned long)dlp->dl_length);
1739 * name for the device that comes before the unit number,
1749 for (i = 0; i < ap->dl_count; i++) {
1750 if ((strcmp((const char *)ip->dl_module_id_1, device) == 0 ||
1751 strcmp((const char *)ip->dl_module_id_2, device) == 0) &&
1752 ip->dl_instance_num == unit)
1755 ip = (dl_hp_ppa_info_t *)((u_char *)ipstart + ip->dl_next_offset);
1762 i = ap->dl_count;
1765 if (i == ap->dl_count) {
1769 * HP-UX 10.20, whilst it has "dl_module_id_1" and
1772 * at a reasonably up-to-date patch level.
1774 * Older HP-UX 10.x systems might not have those fields
1778 * device number of a device with the name "/dev/<dev><unit>",
1781 snprintf(dname, sizeof(dname), "/dev/%s%u", device, unit);
1791 for (i = 0; i < ap->dl_count; i++) {
1792 if (ip->dl_mjr_num == majdev &&
1793 ip->dl_instance_num == unit)
1796 ip = (dl_hp_ppa_info_t *)((u_char *)ipstart + ip->dl_next_offset);
1799 if (i == ap->dl_count) {
1801 "can't find /dev/dlpi PPA for %s%u", device, unit);
1804 if (ip->dl_hdw_state == HDW_DEAD) {
1806 "%s%d: hardware state: DOWN\n", device, unit);
1810 *ppa = ip->dl_ppa;
1818 * Under HP-UX 9, there is no good way to determine the ppa.
1827 static char path_vmunix[] = "/hp-ux";
1831 get_dlpi_ppa(register int fd, register const char *ifname, register u_int unit, argument
1874 if (strcmp(if_name, ifname) == 0 && ifnet.if_unit == unit) {
1893 return (-1);
1899 return (-1);
1903 return (-1);
1922 pd = p->priv;
1923 pd->send_fd = -1; /* it hasn't been opened yet */
1926 p->activate_op = pcap_activate_dlpi;