Move calls to "dissector_add()" out of the register routines for TCP and
[obnox/wireshark/wip.git] / README.hpux
1 $Id: README.hpux,v 1.11 2000/04/04 21:07:33 guy Exp $
2
3 Contents:
4
5 1 - Building ethereal
6 2 - Building GTK+/GLib with HP's C compiler
7 3 - nettl support
8 4 - "libpcap" on HP-UX
9
10 1 - Building ethereal
11
12 The Software Porting And Archive Centre for HP-UX, at
13
14         http://hpux.csc.liv.ac.uk/
15
16 (and with mirrors in various countries, listed on the Centre's home
17 page) has ported versions, in both source and binary form, for Ethereal,
18 as well as for the "libpcap", GLib, GTK+, "zlib", and CMU SNMP libraries
19 that it uses.
20
21 The changes they've made appear largely to be compile option changes; if
22 you've downloaded the source to the latest version of Ethereal (the
23 version on the Centre's site may not necessarily be the latest version),
24 it should be able to compile, perhaps with those changes.
25
26 They appear to have used HP-UX's "cc" compiler, with the options "-Ae
27 -O"; there's a comment "Add -Dhpux_9 if building under 9.X".  It may
28 also build with GCC.
29
30 2 - Building GTK+/GLib with HP's C compiler
31
32 By default, HP's C compiler doesn't support "long long int" to provide
33 64-bit integral data types on 32-bit platforms; the "-Ae" flag must be
34 supplied to enable extensions such as that.
35
36 Ethereal's "configure" script automatically includes that flag if it
37 detects that the native compiler is being used on HP-UX; however, the
38 configure scripts for GTK+ and GLib don't do so, which means that 64-bit
39 integer support won't be enabled.
40
41 This may prevent some parts of Ethereal from compiling; in order to get
42 64-bit integer support in GTK+/GLib, edit all the Makefiles for GTK+ and
43 GLib, as generated by the GTK+ and GLib "configure" scripts, to add
44 "-Ae" to all "CFLAGS = " definitions found in those Makefiles.  (If a
45 Makefile lacks a "CFLAGS = " definition, there's no need to add a
46 definition that includes "-Ae".)
47
48 3 - nettl support
49
50 nettl is used on HP-UX to trace various streams based subsystems.  Ethereal
51 can read nettl files containing IP frames (NS_LS_IP subsystem) and LAPB
52 frames (SX25L2 subsystem).
53 It has been tested with files generated on HP-UX 9.04 and 10.20.
54
55 Use the following commands to generate a trace (cf. nettl(1M)):
56
57 # IP capture. 0x30000000 means PDU in and PDU out :
58 nettl -tn 0x30000000 -e NS_LS_IP -f tracefile
59 # X25 capture. You must specify an interface :
60 nettl -tn 0x30000000 -e SX25l2 -d /dev/x25_0 -f tracefile
61 # stop capture. subsystem is NS_LS_IP or SX25L2 :
62 nettl -tf -e subsystem
63
64 One may be able to specify "-tn pduin pduout" rather than
65 "-tn 0x30000000"; the nettl man page for HP-UX 10.30 implies that it
66 should work.
67
68 4 - "libpcap" on HP-UX
69
70 If you want to use Ethereal to capture packets, you will have to install
71 "libpcap"; the INSTALL file for "libpcap" has several comments about
72 HP-UX, which you should read if you're going to install and use
73 "libpcap" on HP-UX.
74
75 Note that packet-capture programs such as Ethereal/Tethereal or tcpdump
76 may, on HP-UX, not be able to see packets sent from the machine on which
77 they're running.  Some articles on Deja.com discussing this are:
78
79         http://www.deja.com/[ST_rn=ps]/getdoc.xp?AN=558092266
80
81 which says:
82
83   Newsgroups: comp.sys.hp.hpux 
84   Subject:  Re: Did someone made tcpdump working on 10.20 ?
85   Date: 12/08/1999
86   From: Lutz Jaenicke <jaenicke@emserv1.ee.TU-Berlin.DE>
87
88   In article <82ks5i$5vc$1@news1.dti.ne.jp>, mtsat <mtsat@iris.dti.ne.jp>
89   wrote:
90    >Hello,
91    >
92    >I downloaded and compiled tcpdump3.4 a couple of week ago. I tried to use
93    >it, but I can only see incoming data, never outgoing.
94    >Someone (raj) explained me that a patch was missing, and that this patch
95    >must me "patched" (poked) in order to see outbound data in promiscuous mode.
96    >Many things to do .... So the question is : did someone has already this
97    >"ready to use" PHNE_**** patch ?
98   
99    Two things:
100    1. You do need a late "LAN products cumulative patch" (e.g.  PHNE_18173
101   for   s700/10.20).
102    2. You must use
103 echo 'lanc_outbound_promisc_flag/W1' | /usr/bin/adb -w /stand/vmunix /dev/kmem
104      You can insert this e.g. into /sbin/init.d/lan
105   
106    Best regards,
107    Lutz
108
109 and
110
111         http://www.deja.com/[ST_rn=ps]/getdoc.xp?AN=586287166
112
113 which says:
114
115   Newsgroups: comp.sys.hp.hpux 
116   Subject: Re: tcpdump only shows incoming packets
117   Date: 02/15/2000
118   From: Rick Jones <foo@bar.baz.invalid>
119
120   Harald Skotnes <harald@cc.uit.no> wrote:
121   > I am running HPUX 11.0 on a C200 hanging on a 100Mb switch. I have
122   > compiled libpcap-0.4 an tcpdump-3.4 and it seems to work. But at a
123   > closer look I only get to see the incoming packets not the
124   > outgoing. I have tried tcpflow-0.12 which also uses libpcap and the
125   > same thing happens.  Could someone please give me a hint on how to
126   > get this right?
127   
128   Search/Read the archives ?-)
129   
130   What you are seeing is expected, un-patched, behaviour for an HP-UX
131   system.  On 11.00, you need to install the latest lancommon/DLPI
132   patches, and then the latest driver patch for the interface(s) in use. 
133   At that point, a miracle happens and you should start seeing outbound
134   traffic.
135
136 [That article also mentions the patch that appears below.]
137
138 and
139
140         http://www.deja.com/[ST_rn=ps]/getdoc.xp?AN=586494200
141
142 which says:
143
144   Newsgroups: comp.sys.hp.hpux
145   Subject: Re: tcpdump only shows incoming packets
146   Date: 02/16/2000
147   From: Harald Skotnes <harald@cc.uit.no>
148
149   Rick Jones wrote:
150   
151         ...
152
153   > What you are seeing is expected, un-patched, behaviour for an HP-UX
154   > system. On 11.00, you need to install the latest lancommon/DLPI
155   > patches, and then the latest driver patch for the interface(s) in
156   > use. At that point, a miracle happens and you should start seeing
157   > outbound traffic.
158   
159   Thanks a lot.  I have this problem on several machines running HPUX
160   10.20 and 11.00.  The machines where patched up before y2k so did not
161   know what to think.  Anyway I have now installed PHNE_19766,
162   PHNE_19826, PHNE_20008, PHNE_20735 on the C200 and now I can see the
163   outbound traffic too.  Thanks again.
164
165 Another posting:
166
167         http://www.deja.com/[ST_rn=ps]/getdoc.xp?AN=457744130
168
169 indicates that you need to install the optional STREAMS product to do
170 captures on HP-UX 9.x:
171
172   Newsgroups: comp.sys.hp.hpux
173   Subject:  Re: tcpdump HP/UX 9.x
174   Date: 03/22/1999
175   From: Rick Jones <foo@bar.baz>
176
177   Dave Barr (barr@cis.ohio-state.edu) wrote:
178   : Has anyone ported tcpdump (or something similar) to HP/UX 9.x?
179   
180   I'm reasonably confident that any port of tcpdump to 9.X would require
181   the (then optional) STREAMS product.  This would bring DLPI, which is
182   what one uses to access interfaces in promiscuous mode.
183   
184   I'm not sure that HP even sells the 9.X STREAMS product any longer,
185   since HP-UX 9.X is off the pricelist (well, maybe 9.10 for the old 68K
186   devices). 
187   
188   Your best bet is to be up on 10.20 or better if that is at all
189   possible.  If your hardware is supported by it, I'd go with HP-UX 11. 
190   If you want to see the system's own outbound traffic, you'll never get
191   that functionality on 9.X, but it might happen at some point for 10.20
192   and 11.X. 
193   
194   rick jones
195
196 (as per other messages cited here, the ability to see the system's own
197 outbound traffic did happen).
198
199 Another note, from a mail message to the "ethereal-users" list:
200
201   Date: Wed, 22 Dec 1999 09:05:47 -0600 (EST)
202   From: Gerald Combs <gerald@zing.org>
203   To: Lothar Seitter <lothar.seitter@arcormail.de>
204   cc: ethereal-users@zing.org
205   Subject: Re: [ethereal-users] permission problem with capturing
206
207   On Wed, 22 Dec 1999, Lothar Seitter wrote:
208
209   > running 'ethereal' under HP-UX 11 with root permission and
210   > /dev/lan0 set to 777, I always get the message:
211   > "There are no network interfaces that can be opened.
212   > Please to make sure you have sufficient permission to 
213   > capture packets."
214   > 
215   > I start ethereal with 'etheral -i lan0' and lan0 is definitely
216   > the lan interface.
217   > 
218   > What am I missing???
219
220   You may need to reference the card's DLPI device directly.  We were having
221   trouble getting Ethereal to capture on an HP-UX 10.20 machine here.  I
222   found an article on Deja News that says:
223
224   "To access a particular interface, you would say "tcpdump -i /dev/dlpiN"
225   where N is the PPA of the interface you wish to use. You get the PPA by
226   looking at the output of lanscan. On 10.20, it is the same value as the
227   NMID. On 11.X, it is the Card Instance number."
228
229   This didn't help in our case, but it might in yours.  The full article is
230   at http://x34.deja.com/[ST_rn=ps]/getdoc.xp?AN=549366486 .
231
232   Another article by the same author mentions that experimental versions of
233   libpcap and tcpdump are available at
234   ftp://ftp.cup.hp.com/dist/networking/tools/ .  The article itself is at
235   http://x34.deja.com/[ST_rn=ps]/getdoc.xp?AN=558665378 .
236
237 The first of those articles also says:
238
239   BTW, before you have to make a follow-up post, you will find that
240   unless you have the latest lan common/DLPI/driver patches installed,
241   you will _not_ see the system's own outbound traffic.
242
243 An additional note, from Jost Martin, for HP-UX 10.20:
244
245         Q: How do I get ethereral on HPUX to capture the _outgoing_ packets
246            of an interface
247         A: You need to get PHNE_20892,PHNE_20725 and PHCO_10947 (or
248            newer, this is as of 4.4.00) and its dependencies.  Then you can
249            enable the feature as descibed below:
250
251         Patch Name: PHNE_20892
252         Patch Description: s700 10.20 PCI 100Base-T cumulative patch
253                 To trace the outbound packets, please do the following
254                 to turn on a global promiscuous switch before running
255                 the promiscuous applications like snoop or tcpdump:
256
257                 adb -w /stand/vmunix /dev/mem
258                 lanc_outbound_promisc_flag/W 1
259                 (adb will echo the result showing that the flag has
260                 been changed)
261                 $quit
262         (Thanks for this part to HP-support, Ratingen)
263
264                 The attached hack does this and some security-related stuff
265         (thanks to hildeb@www.stahl.bau.tu-bs.de (Ralf Hildebrandt) who
266         posted the security-part some time ago)
267
268                  <<hack_ip_stack>> 
269
270                 (Don't switch IP-forwarding off, if you need it !)
271                 Install the hack as /sbin/init.d/hacl_ip_stack (adjust
272         permissions !) and make a sequencing-symlink
273         /sbin/rc2.d/S350hack_ip_stack pointing to this script. 
274                 Now all this is done on every reboot.
275
276 Here's the "hack_ip_stack" script:
277
278 -----------------------------------Cut Here-------------------------------------
279 #!/sbin/sh
280 #
281 # nettune:  hack kernel parms for safety
282
283 OKAY=0
284 ERROR=-1
285
286 # /usr/contrib/bin fuer nettune auf Pfad
287 PATH=/sbin:/usr/sbin:/usr/bin:/usr/contrib/bin
288 export PATH
289
290
291 ##########
292 #  main  #
293 ##########
294
295 case $1 in
296    start_msg)
297       print "Tune IP-Stack for security"
298       exit $OKAY
299       ;;
300
301    stop_msg)
302       print "This action is not applicable"
303       exit $OKAY
304       ;;
305
306    stop)
307       exit $OKAY
308       ;;
309
310    start)
311       ;;  # fall through
312
313    *)
314       print "USAGE: $0 {start_msg | stop_msg | start | stop}" >&2
315       exit $ERROR
316       ;;
317    esac
318
319 ###########
320 #  start  #
321 ###########
322
323 #
324 # tcp-Sequence-Numbers nicht mehr inkrementieren sondern random
325 # Syn-Flood-Protection an
326 # ip_forwarding aus
327 # Source-Routing aus
328 # Ausgehende Packets an ethereal/tcpdump etc.
329
330 /usr/contrib/bin/nettune -s tcp_random_seq 2 || exit $ERROR
331 /usr/contrib/bin/nettune -s hp_syn_protect 1 || exit $ERROR
332 /usr/contrib/bin/nettune -s ip_forwarding 0 || exit $ERROR
333 echo 'ip_block_source_routed/W1' | /usr/bin/adb -w /stand/vmunix /dev/kmem || exit $ERROR
334 echo 'lanc_outbound_promisc_flag/W 1' | adb -w /stand/vmunix /dev/mem  || exit $ERROR
335
336 exit $OKAY
337 -----------------------------------Cut Here-------------------------------------
338
339 It appears that a consequence of the fact that HP-UX's DLPI doesn't work
340 like Solaris's, in that, on Solaris, to get at the device "hme0", say,
341 "libpcap" has to open "/dev/hme" and then tell it to use the 0th
342 interface, whilst on HP-UX you have to go through "/dev/dlpi", you won't
343 get a list of interfaces in the dialog box for "Capture:Start" - you'll
344 have to do through the aforementioned song and dance to find the PPA of
345 the interface you want to use, and supply the "dlpiN" name by hand (I
346 think you can omit the "/dev/" in both tcpdump and Ethereal).
347
348 Here is a patch to "pcap-dlpi.c" in libpcap that, at least on HP-UX
349 11.X, allows the name of the network interface, rather than the "dlpiN"
350 name, to be specified to tcpdump and Ethereal.  It has not been tried on
351 HP-UX 10.20; it fixes one bug that could have caused the code in vanilla
352 libpcap not to correctly find the PPA for an interface on HP-UX 10.20,
353 but HP-UX 10.20's DLPI doesn't supply, in the data returned by a
354 DL_HP_PPA_REQ request, network interface names, so, on systems without
355 the network interface names in that data, the code continues to check
356 the major device number.
357
358 On HP-UX 11.00, the patch allows a network interface to be specified by
359 name as an argument to tcpdump, rather than requiring that you specify a
360 "dlpiN" name (and it should work equally well with Ethereal).
361
362 If you try this code on HP-UX 10.20, and it doesn't let you specify the
363 interface by name, please send mail to ethereal-dev@zing.org, so that we
364 know that it didn't work - we'll probably send you debugging patches in
365 the hopes of being able to make it work on 10.20 as well.
366
367 Here's the patch (to vanilla libpcap 0.4; it patches "configure",
368 "aclocal.m4", and "configure.in", to make the configure script check
369 whether your version of HP-UX supplies the interface names in the reply
370 to a DL_HP_PPA_REQ request, and "pcap-dlpi.c"):
371
372 *** ../libpcap-0.4/configure    Sat Jul 25 12:41:51 1998
373 --- configure   Fri Jan 14 00:40:04 2000
374 ***************
375 *** 1702,1709 ****
376   
377       fi
378   
379   echo $ac_n "checking if unaligned accesses fail""... $ac_c" 1>&6
380 ! echo "configure:1707: checking if unaligned accesses fail" >&5
381       if eval "test \"`echo '$''{'ac_cv_lbl_unaligned_fail'+set}'`\" = set"; then
382     echo $ac_n "(cached) $ac_c" 1>&6
383   else
384 --- 1702,1745 ----
385   
386       fi
387   
388 + echo $ac_n "checking if dl_hp_ppa_info_t struct has dl_module_id_1 member""... $ac_c" 1>&6
389 + echo "configure:1707: checking if dl_hp_ppa_info_t struct has dl_module_id_1 member" >&5
390 +     if eval "test \"`echo '$''{'ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1'+set}'`\" = set"; then
391 +   echo $ac_n "(cached) $ac_c" 1>&6
392 + else
393 +   cat > conftest.$ac_ext <<EOF
394 + #line 1712 "configure"
395 + #include "confdefs.h"
396
397 + #     include <sys/types.h>
398 + #     include <sys/dlpi.h>
399 + #     include <sys/dlpi_ext.h>
400 + int main() {
401 + u_int i = sizeof(((dl_hp_ppa_info_t *)0)->dl_module_id_1)
402 + ; return 0; }
403 + EOF
404 + if { (eval echo configure:1722: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
405 +   rm -rf conftest*
406 +   ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1=yes
407 + else
408 +   echo "configure: failed program was:" >&5
409 +   cat conftest.$ac_ext >&5
410 +   rm -rf conftest*
411 +   ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1=no
412 + fi
413 + rm -f conftest*
414 + fi
415
416 +     echo "$ac_t""$ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1" 1>&6
417 +     if test $ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1 = yes ; then
418 +           cat >> confdefs.h <<\EOF
419 + #define HAVE_HP_PPA_INFO_T_DL_MODULE_ID_1 1
420 + EOF
421
422 +     fi
423
424   echo $ac_n "checking if unaligned accesses fail""... $ac_c" 1>&6
425 ! echo "configure:1743: checking if unaligned accesses fail" >&5
426       if eval "test \"`echo '$''{'ac_cv_lbl_unaligned_fail'+set}'`\" = set"; then
427     echo $ac_n "(cached) $ac_c" 1>&6
428   else
429 ***************
430 *** 1799,1805 ****
431   # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
432   # ./install, which can be erroneously created by make from ./install.sh.
433   echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
434 ! echo "configure:1803: checking for a BSD compatible install" >&5
435   if test -z "$INSTALL"; then
436   if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
437     echo $ac_n "(cached) $ac_c" 1>&6
438 --- 1835,1841 ----
439   # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
440   # ./install, which can be erroneously created by make from ./install.sh.
441   echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
442 ! echo "configure:1839: checking for a BSD compatible install" >&5
443   if test -z "$INSTALL"; then
444   if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
445     echo $ac_n "(cached) $ac_c" 1>&6
446
447
448 *** ../libpcap-0.4/aclocal.m4   Fri Jun 12 03:45:15 1998
449 --- aclocal.m4  Tue Jan  4 21:02:13 2000
450 ***************
451 *** 415,420 ****
452 --- 415,454 ----
453       fi])
454   
455   dnl
456 + dnl Checks to see if the dl_hp_ppa_info_t struct has the HP-UX 11.00
457 + dnl dl_module_id_1 member
458 + dnl
459 + dnl usage:
460 + dnl
461 + dnl   AC_LBL_HP_PPA_INFO_T_DL_MODULE_ID_1
462 + dnl
463 + dnl results:
464 + dnl
465 + dnl   HAVE_HP_PPA_INFO_T_DL_MODULE_ID_1 (defined)
466 + dnl
467 + dnl NOTE: any compile failure means we conclude that it doesn't have
468 + dnl that member, so if we don't have DLPI, don't have a <sys/dlpi_ext.h>
469 + dnl header, or have one that doesn't declare a dl_hp_ppa_info_t type,
470 + dnl we conclude it doesn't have that member (which is OK, as either we
471 + dnl won't be using code that would use that member, or we wouldn't
472 + dnl compile in any case).
473 + dnl
474 + AC_DEFUN(AC_LBL_HP_PPA_INFO_T_DL_MODULE_ID_1,
475 +     [AC_MSG_CHECKING(if dl_hp_ppa_info_t struct has dl_module_id_1 member)
476 +     AC_CACHE_VAL(ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1,
477 +       AC_TRY_COMPILE([
478 + #     include <sys/types.h>
479 + #     include <sys/dlpi.h>
480 + #     include <sys/dlpi_ext.h>],
481 +       [u_int i = sizeof(((dl_hp_ppa_info_t *)0)->dl_module_id_1)],
482 +       ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1=yes,
483 +       ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1=no))
484 +     AC_MSG_RESULT($ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1)
485 +     if test $ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1 = yes ; then
486 +           AC_DEFINE(HAVE_HP_PPA_INFO_T_DL_MODULE_ID_1)
487 +     fi])
488
489 + dnl
490   dnl Checks to see if -R is used
491   dnl
492   dnl usage:
493
494
495 *** ../libpcap-0.4/configure.in Sun Jul 27 22:16:22 1997
496 --- configure.in        Tue Jan  4 21:02:13 2000
497 ***************
498 *** 154,159 ****
499 --- 154,161 ----
500   
501   AC_LBL_SOCKADDR_SA_LEN
502   
503 + AC_LBL_HP_PPA_INFO_T_DL_MODULE_ID_1
504
505   AC_LBL_UNALIGNED_ACCESS
506   
507   if test "${srcdir}" = "." ; then
508
509 *** ../libpcap-0.4/pcap-dlpi.c  Wed Oct 15 21:59:34 1997
510 --- pcap-dlpi.c Tue Jan  4 21:02:13 2000
511 ***************
512 *** 246,255 ****
513         }
514         memset(p, 0, sizeof(*p));
515   
516         /*
517 !       ** Determine device and ppa
518         */
519 !       cp = strpbrk(device, "0123456789");
520         if (cp == NULL) {
521                 sprintf(ebuf, "%s missing unit number", device);
522                 goto bad;
523 --- 246,266 ----
524         }
525         memset(p, 0, sizeof(*p));
526   
527 + #ifdef HAVE_DEV_DLPI
528         /*
529 !       ** Remove any "/dev/" on the front of the device.
530         */
531 !       cp = strrchr(device, '/');
532 !       if (cp == NULL)
533 !               cp = device;
534 !       else
535 !               cp++;
536 !       strcpy(dname, cp);
537
538 !       /*
539 !        * Split the name into a device type and a unit number.
540 !        */
541 !       cp = strpbrk(dname, "0123456789");
542         if (cp == NULL) {
543                 sprintf(ebuf, "%s missing unit number", device);
544                 goto bad;
545 ***************
546 *** 259,281 ****
547                 sprintf(ebuf, "%s bad unit number", device);
548                 goto bad;
549         }
550   
551 !       if (*device == '/')
552 !               strcpy(dname, device);
553 !       else
554 !               sprintf(dname, "%s/%s", PCAP_DEV_PREFIX, device);
555 ! #ifdef HAVE_DEV_DLPI
556 !       /* Map network device to /dev/dlpi unit */
557         cp = "/dev/dlpi";
558         if ((p->fd = open(cp, O_RDWR)) < 0) {
559                 sprintf(ebuf, "%s: %s", cp, pcap_strerror(errno));
560                 goto bad;
561         }
562 !       /* Map network interface to /dev/dlpi unit */
563         ppa = get_dlpi_ppa(p->fd, dname, ppa, ebuf);
564         if (ppa < 0)
565                 goto bad;
566   #else
567         /* Try device without unit number */
568         strcpy(dname2, dname);
569         cp = strchr(dname, *cp);
570 --- 270,331 ----
571                 sprintf(ebuf, "%s bad unit number", device);
572                 goto bad;
573         }
574 +       *cp = '\0';
575   
576 !       /*
577 !        * Use "/dev/dlpi" as the device.
578 !        *
579 !        * XXX - HP's DLPI Programmer's Guide for HP-UX 11.00 says that
580 !        * the "dl_mjr_num" field is for the "major number of interface
581 !        * driver"; that's the major of "/dev/dlpi" on the system on
582 !        * which I tried this, but there may be DLPI devices that
583 !        * use a different driver, in which case we may need to
584 !        * search "/dev" for the appropriate device with that major
585 !        * device number, rather than hardwiring "/dev/dlpi".
586 !        *
587 !        * I'm assuming that the code that was used for HP-UX 10.x
588 !        * is valid, and therefore that, in 10.x, DLPIable devices have
589 !        * "/dev" entries corresponding to them and that their
590 !        * major device number is what appears in the "dl_hp_ppa_info_t"
591 !        * structure for that device.  We can search by name in 11.x
592 !        * (and we may have to, as it's not clear that DLPIable devices
593 !        * will have those sorts of "/dev" entries), but we can't in
594 !        * 10.x, as 10.x doesn't have the "dl_module_id_1" and
595 !        * "dl_module_id_2" members in the "dl_hp_ppa_info_t" structure.
596 !        */
597         cp = "/dev/dlpi";
598         if ((p->fd = open(cp, O_RDWR)) < 0) {
599                 sprintf(ebuf, "%s: %s", cp, pcap_strerror(errno));
600                 goto bad;
601         }
602
603 !       /*
604 !        * Get a table of all PPAs for that device, and search that
605 !        * table for the specified device type name and unit number.
606 !        */
607         ppa = get_dlpi_ppa(p->fd, dname, ppa, ebuf);
608         if (ppa < 0)
609                 goto bad;
610   #else
611 +       /*
612 +       ** Determine device and ppa
613 +       */
614 +       cp = strpbrk(device, "0123456789");
615 +       if (cp == NULL) {
616 +               sprintf(ebuf, "%s missing unit number", device);
617 +               goto bad;
618 +       }
619 +       ppa = strtol(cp, &eos, 10);
620 +       if (*eos != '\0') {
621 +               sprintf(ebuf, "%s bad unit number", device);
622 +               goto bad;
623 +       }
624
625 +       if (*device == '/')
626 +               strcpy(dname, device);
627 +       else
628 +               sprintf(dname, "%s/%s", PCAP_DEV_PREFIX, device);
629
630         /* Try device without unit number */
631         strcpy(dname2, dname);
632         cp = strchr(dname, *cp);
633 ***************
634 *** 391,397 ****
635                 break;
636   
637         default:
638 !               sprintf(ebuf, "unknown mac type 0x%lu", infop->dl_mac_type);
639                 goto bad;
640         }
641   
642 --- 441,448 ----
643                 break;
644   
645         default:
646 !               sprintf(ebuf, "unknown mac type 0x%lu",
647 !                   (unsigned long)infop->dl_mac_type);
648                 goto bad;
649         }
650   
651 ***************
652 *** 709,715 ****
653   
654   #ifdef DL_HP_PPA_ACK_OBS
655   /*
656 !  * Under HP-UX 10, we can ask for the ppa
657    */
658   
659   
660 --- 760,766 ----
661   
662   #ifdef DL_HP_PPA_ACK_OBS
663   /*
664 !  * Under HP-UX 10 and HP-UX 11, we can ask for the ppa
665    */
666   
667   
668 ***************
669 *** 719,736 ****
670       register char *ebuf)
671   {
672         register dl_hp_ppa_ack_t *ap;
673 !       register dl_hp_ppa_info_t *ip;
674         register int i;
675         register u_long majdev;
676 -       dl_hp_ppa_req_t req;
677         struct stat statbuf;
678         bpf_u_int32 buf[MAXDLBUF];
679   
680 !       if (stat(device, &statbuf) < 0) {
681 !               sprintf(ebuf, "stat: %s: %s", device, pcap_strerror(errno));
682                 return (-1);
683         }
684         majdev = major(statbuf.st_rdev);
685   
686         memset((char *)&req, 0, sizeof(req));
687         req.dl_primitive = DL_HP_PPA_REQ;
688 --- 770,800 ----
689       register char *ebuf)
690   {
691         register dl_hp_ppa_ack_t *ap;
692 !       register dl_hp_ppa_info_t *ipstart, *ip;
693         register int i;
694 + #ifndef HAVE_HP_PPA_INFO_T_DL_MODULE_ID_1
695 +       char dname[100];
696         register u_long majdev;
697         struct stat statbuf;
698 + #endif
699 +       dl_hp_ppa_req_t req;
700         bpf_u_int32 buf[MAXDLBUF];
701   
702 ! #ifndef HAVE_HP_PPA_INFO_T_DL_MODULE_ID_1
703 !       /*
704 !        * HP-UX 10 doesn't put the interface name in the
705 !        * "dl_hp_ppa_info_t" structure, so we have to
706 !        * try to get the major device number for the device
707 !        * corresponding to the device and unit name provided to
708 !        * us, and search for the entry with that major device number.
709 !        */
710 !       sprintf(dname, "/dev/%s%d", device, unit);
711 !       if (stat(dname, &statbuf) < 0) {
712 !               sprintf(ebuf, "stat: %s: %s", dname, pcap_strerror(errno));
713                 return (-1);
714         }
715         majdev = major(statbuf.st_rdev);
716 + #endif
717   
718         memset((char *)&req, 0, sizeof(req));
719         req.dl_primitive = DL_HP_PPA_REQ;
720 ***************
721 *** 741,760 ****
722                 return (-1);
723   
724         ap = (dl_hp_ppa_ack_t *)buf;
725 !       ip = (dl_hp_ppa_info_t *)((u_char *)ap + ap->dl_offset);
726   
727           for(i = 0; i < ap->dl_count; i++) {
728 !                 if (ip->dl_mjr_num == majdev && ip->dl_instance_num == unit)
729                           break;
730   
731 !                 ip = (dl_hp_ppa_info_t *)((u_char *)ip + ip->dl_next_offset);
732           }
733           if (i == ap->dl_count) {
734 !                 sprintf(ebuf, "can't find PPA for %s", device);
735                 return (-1);
736           }
737           if (ip->dl_hdw_state == HDW_DEAD) {
738 !                 sprintf(ebuf, "%s: hardware state: DOWN\n", device);
739                 return (-1);
740           }
741           return ((int)ip->dl_ppa);
742 --- 805,831 ----
743                 return (-1);
744   
745         ap = (dl_hp_ppa_ack_t *)buf;
746 !       ipstart = (dl_hp_ppa_info_t *)((u_char *)ap + ap->dl_offset);
747 !       ip = ipstart;
748   
749           for(i = 0; i < ap->dl_count; i++) {
750 ! #ifdef HAVE_HP_PPA_INFO_T_DL_MODULE_ID_1
751 !               if ((strcmp(ip->dl_module_id_1, device) == 0 ||
752 !                    strcmp(ip->dl_module_id_2, device) == 0) &&
753 ! #else
754 !                 if (ip->dl_mjr_num == majdev &&
755 ! #endif
756 !                   ip->dl_instance_num == unit)
757                           break;
758   
759 !                 ip = (dl_hp_ppa_info_t *)((u_char *)ipstart + ip->dl_next_offset);
760           }
761           if (i == ap->dl_count) {
762 !                 sprintf(ebuf, "can't find PPA for %s%d", device, unit);
763                 return (-1);
764           }
765           if (ip->dl_hdw_state == HDW_DEAD) {
766 !                 sprintf(ebuf, "%s%d: hardware state: DOWN\n", device, unit);
767                 return (-1);
768           }
769           return ((int)ip->dl_ppa);
770 ***************
771 *** 783,789 ****
772         register int kd;
773         void *addr;
774         struct ifnet ifnet;
775 !       char if_name[sizeof(ifnet.if_name)], tifname[32];
776   
777         cp = strrchr(ifname, '/');
778         if (cp != NULL)
779 --- 854,860 ----
780         register int kd;
781         void *addr;
782         struct ifnet ifnet;
783 !       char if_name[sizeof(ifnet.if_name) + 1];
784   
785         cp = strrchr(ifname, '/');
786         if (cp != NULL)
787 ***************
788 *** 811,823 ****
789                 if (dlpi_kread(kd, (off_t)addr,
790                     &ifnet, sizeof(ifnet), ebuf) < 0 ||
791                     dlpi_kread(kd, (off_t)ifnet.if_name,
792 !                   if_name, sizeof(if_name), ebuf) < 0) {
793                         (void)close(kd);
794                         return (-1);
795                 }
796 !               sprintf(tifname, "%.*s%d",
797 !                   (int)sizeof(if_name), if_name, ifnet.if_unit);
798 !               if (strcmp(tifname, ifname) == 0)
799                         return (ifnet.if_index);
800         }
801   
802 --- 882,893 ----
803                 if (dlpi_kread(kd, (off_t)addr,
804                     &ifnet, sizeof(ifnet), ebuf) < 0 ||
805                     dlpi_kread(kd, (off_t)ifnet.if_name,
806 !                   if_name, sizeof(ifnet.if_name), ebuf) < 0) {
807                         (void)close(kd);
808                         return (-1);
809                 }
810 !               if_name[sizeof(ifnet.if_name)] = '\0';
811 !               if (strcmp(if_name, ifname) == 0 && ifnet.if_unit == unit)
812                         return (ifnet.if_index);
813         }
814   
815
816