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