Itojun did part of the BSD zlib fix.
[obnox/wireshark/wip.git] / README.hpux
1 The Software Porting And Archive Centre for HP-UX, at
2
3         http://hpux.csc.liv.ac.uk/
4
5 (and with mirrors in various countries, listed on the Centre's home
6 page) has ported versions, in both source and binary form, for Ethereal,
7 as well as for the "libpcap", GLib, GTK+, "zlib", and CMU SNMP libraries
8 that it uses.
9
10 The changes they've made appear largely to be compile option changes; if
11 you've downloaded the source to the latest version of Ethereal (the
12 version on the Centre's site may not necessarily be the latest version),
13 it should be able to compile, perhaps with those changes.
14
15 They appear to have used HP-UX's "cc" compiler, with the options "-Ae
16 -O"; there's a comment "Add -Dhpux_9 if building under 9.X".  It may
17 also build with GCC.
18
19 If you want to use Ethereal to capture packets, you will have to install
20 "libpcap"; the INSTALL file for "libpcap" has several comments about
21 HP-UX, which you should read if you're going to install and use
22 "libpcap" on HP-UX.
23
24 Another note, from a mail message to the "ethereal-users" list:
25
26   Date: Wed, 22 Dec 1999 09:05:47 -0600 (EST)
27   From: Gerald Combs <gerald@zing.org>
28   To: Lothar Seitter <lothar.seitter@arcormail.de>
29   cc: ethereal-users@zing.org
30   Subject: Re: [ethereal-users] permission problem with capturing
31
32   On Wed, 22 Dec 1999, Lothar Seitter wrote:
33
34   > running 'ethereal' under HP-UX 11 with root permission and
35   > /dev/lan0 set to 777, I always get the message:
36   > "There are no network interfaces that can be opened.
37   > Please to make sure you have sufficient permission to 
38   > capture packets."
39   > 
40   > I start ethereal with 'etheral -i lan0' and lan0 is definitely
41   > the lan interface.
42   > 
43   > What am I missing???
44
45   You may need to reference the card's DLPI device directly.  We were having
46   trouble getting Ethereal to capture on an HP-UX 10.20 machine here.  I
47   found an article on Deja News that says:
48
49   "To access a particular interface, you would say "tcpdump -i /dev/dlpiN"
50   where N is the PPA of the interface you wish to use. You get the PPA by
51   looking at the output of lanscan. On 10.20, it is the same value as the
52   NMID. On 11.X, it is the Card Instance number."
53
54   This didn't help in our case, but it might in yours.  The full article is
55   at http://x34.deja.com/[ST_rn=ps]/getdoc.xp?AN=549366486 .
56
57   Another article by the same author mentions that experimental versions of
58   libpcap and tcpdump are available at
59   ftp://ftp.cup.hp.com/dist/networking/tools/ .  The article itself is at
60   http://x34.deja.com/[ST_rn=ps]/getdoc.xp?AN=558665378 .
61
62 The first of those articles also says:
63
64   BTW, before you have to make a follow-up post, you will find that
65   unless you have the latest lan common/DLPI/driver patches installed,
66   you will _not_ see the system's own outbound traffic.
67
68 It appears that a consequence of the fact that HP-UX's DLPI doesn't work
69 like Solaris's, in that, on Solaris, to get at the device "hme0", say,
70 "libpcap" has to open "/dev/hme" and then tell it to use the 0th
71 interface, whilst on HP-UX you have to go through "/dev/dlpi", you won't
72 get a list of interfaces in the dialog box for "Capture:Start" - you'll
73 have to do through the aforementioned song and dance to find the PPA of
74 the interface you want to use, and supply the "dlpiN" name by hand (I
75 think you can omit the "/dev/" in both tcpdump and Ethereal).
76
77 Here is a patch to "pcap-dlpi.c" in libpcap that, at least on HP-UX
78 11.X, allows the name of the network interface, rather than the "dlpiN"
79 name, to be specified to tcpdump and Ethereal.  It has not been tried on
80 HP-UX 10.20; it fixes one bug that could have caused the code in vanilla
81 libpcap not to correctly find the PPA for an interface on HP-UX 10.20,
82 but HP-UX 10.20's DLPI doesn't supply, in the data returned by a
83 DL_HP_PPA_REQ request, network interface names, so, on systems without
84 the network interface names in that data, the code continues to check
85 the major device number.
86
87 On HP-UX 11.00, the patch allows a network interface to be specified by
88 name as an argument to tcpdump, rather than requiring that you specify a
89 "dlpiN" name (and it should work equally well with Ethereal).
90
91 If you try this code on HP-UX 10.20, and it doesn't let you specify the
92 interface by name, please send mail to ethereal-dev@zing.org, so that we
93 know that it didn't work - we'll probably send you debugging patches in
94 the hopes of being able to make it work on 10.20 as well.
95
96 Here's the patch (to vanilla libpcap 0.4; it patches "configure",
97 "aclocal.m4", and "configure.in", to make the configure script check
98 whether your version of HP-UX supplies the interface names in the reply
99 to a DL_HP_PPA_REQ request, and "pcap-dlpi.c"):
100
101 *** ../libpcap-0.4/configure    Sat Jul 25 12:41:51 1998
102 --- configure   Fri Jan 14 00:40:04 2000
103 ***************
104 *** 1702,1709 ****
105   
106       fi
107   
108   echo $ac_n "checking if unaligned accesses fail""... $ac_c" 1>&6
109 ! echo "configure:1707: checking if unaligned accesses fail" >&5
110       if eval "test \"`echo '$''{'ac_cv_lbl_unaligned_fail'+set}'`\" = set"; then
111     echo $ac_n "(cached) $ac_c" 1>&6
112   else
113 --- 1702,1745 ----
114   
115       fi
116   
117 + echo $ac_n "checking if dl_hp_ppa_info_t struct has dl_module_id_1 member""... $ac_c" 1>&6
118 + echo "configure:1707: checking if dl_hp_ppa_info_t struct has dl_module_id_1 member" >&5
119 +     if eval "test \"`echo '$''{'ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1'+set}'`\" = set"; then
120 +   echo $ac_n "(cached) $ac_c" 1>&6
121 + else
122 +   cat > conftest.$ac_ext <<EOF
123 + #line 1712 "configure"
124 + #include "confdefs.h"
125
126 + #     include <sys/types.h>
127 + #     include <sys/dlpi.h>
128 + #     include <sys/dlpi_ext.h>
129 + int main() {
130 + u_int i = sizeof(((dl_hp_ppa_info_t *)0)->dl_module_id_1)
131 + ; return 0; }
132 + EOF
133 + if { (eval echo configure:1722: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
134 +   rm -rf conftest*
135 +   ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1=yes
136 + else
137 +   echo "configure: failed program was:" >&5
138 +   cat conftest.$ac_ext >&5
139 +   rm -rf conftest*
140 +   ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1=no
141 + fi
142 + rm -f conftest*
143 + fi
144
145 +     echo "$ac_t""$ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1" 1>&6
146 +     if test $ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1 = yes ; then
147 +           cat >> confdefs.h <<\EOF
148 + #define HAVE_HP_PPA_INFO_T_DL_MODULE_ID_1 1
149 + EOF
150
151 +     fi
152
153   echo $ac_n "checking if unaligned accesses fail""... $ac_c" 1>&6
154 ! echo "configure:1743: checking if unaligned accesses fail" >&5
155       if eval "test \"`echo '$''{'ac_cv_lbl_unaligned_fail'+set}'`\" = set"; then
156     echo $ac_n "(cached) $ac_c" 1>&6
157   else
158 ***************
159 *** 1799,1805 ****
160   # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
161   # ./install, which can be erroneously created by make from ./install.sh.
162   echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
163 ! echo "configure:1803: checking for a BSD compatible install" >&5
164   if test -z "$INSTALL"; then
165   if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
166     echo $ac_n "(cached) $ac_c" 1>&6
167 --- 1835,1841 ----
168   # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
169   # ./install, which can be erroneously created by make from ./install.sh.
170   echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
171 ! echo "configure:1839: checking for a BSD compatible install" >&5
172   if test -z "$INSTALL"; then
173   if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
174     echo $ac_n "(cached) $ac_c" 1>&6
175
176
177 *** ../libpcap-0.4/aclocal.m4   Fri Jun 12 03:45:15 1998
178 --- aclocal.m4  Tue Jan  4 21:02:13 2000
179 ***************
180 *** 415,420 ****
181 --- 415,454 ----
182       fi])
183   
184   dnl
185 + dnl Checks to see if the dl_hp_ppa_info_t struct has the HP-UX 11.00
186 + dnl dl_module_id_1 member
187 + dnl
188 + dnl usage:
189 + dnl
190 + dnl   AC_LBL_HP_PPA_INFO_T_DL_MODULE_ID_1
191 + dnl
192 + dnl results:
193 + dnl
194 + dnl   HAVE_HP_PPA_INFO_T_DL_MODULE_ID_1 (defined)
195 + dnl
196 + dnl NOTE: any compile failure means we conclude that it doesn't have
197 + dnl that member, so if we don't have DLPI, don't have a <sys/dlpi_ext.h>
198 + dnl header, or have one that doesn't declare a dl_hp_ppa_info_t type,
199 + dnl we conclude it doesn't have that member (which is OK, as either we
200 + dnl won't be using code that would use that member, or we wouldn't
201 + dnl compile in any case).
202 + dnl
203 + AC_DEFUN(AC_LBL_HP_PPA_INFO_T_DL_MODULE_ID_1,
204 +     [AC_MSG_CHECKING(if dl_hp_ppa_info_t struct has dl_module_id_1 member)
205 +     AC_CACHE_VAL(ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1,
206 +       AC_TRY_COMPILE([
207 + #     include <sys/types.h>
208 + #     include <sys/dlpi.h>
209 + #     include <sys/dlpi_ext.h>],
210 +       [u_int i = sizeof(((dl_hp_ppa_info_t *)0)->dl_module_id_1)],
211 +       ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1=yes,
212 +       ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1=no))
213 +     AC_MSG_RESULT($ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1)
214 +     if test $ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1 = yes ; then
215 +           AC_DEFINE(HAVE_HP_PPA_INFO_T_DL_MODULE_ID_1)
216 +     fi])
217
218 + dnl
219   dnl Checks to see if -R is used
220   dnl
221   dnl usage:
222
223
224 *** ../libpcap-0.4/configure.in Sun Jul 27 22:16:22 1997
225 --- configure.in        Tue Jan  4 21:02:13 2000
226 ***************
227 *** 154,159 ****
228 --- 154,161 ----
229   
230   AC_LBL_SOCKADDR_SA_LEN
231   
232 + AC_LBL_HP_PPA_INFO_T_DL_MODULE_ID_1
233
234   AC_LBL_UNALIGNED_ACCESS
235   
236   if test "${srcdir}" = "." ; then
237
238 *** ../libpcap-0.4/pcap-dlpi.c  Wed Oct 15 21:59:34 1997
239 --- pcap-dlpi.c Tue Jan  4 21:02:13 2000
240 ***************
241 *** 246,255 ****
242         }
243         memset(p, 0, sizeof(*p));
244   
245         /*
246 !       ** Determine device and ppa
247         */
248 !       cp = strpbrk(device, "0123456789");
249         if (cp == NULL) {
250                 sprintf(ebuf, "%s missing unit number", device);
251                 goto bad;
252 --- 246,266 ----
253         }
254         memset(p, 0, sizeof(*p));
255   
256 + #ifdef HAVE_DEV_DLPI
257         /*
258 !       ** Remove any "/dev/" on the front of the device.
259         */
260 !       cp = strrchr(device, '/');
261 !       if (cp == NULL)
262 !               cp = device;
263 !       else
264 !               cp++;
265 !       strcpy(dname, cp);
266
267 !       /*
268 !        * Split the name into a device type and a unit number.
269 !        */
270 !       cp = strpbrk(dname, "0123456789");
271         if (cp == NULL) {
272                 sprintf(ebuf, "%s missing unit number", device);
273                 goto bad;
274 ***************
275 *** 259,281 ****
276                 sprintf(ebuf, "%s bad unit number", device);
277                 goto bad;
278         }
279   
280 !       if (*device == '/')
281 !               strcpy(dname, device);
282 !       else
283 !               sprintf(dname, "%s/%s", PCAP_DEV_PREFIX, device);
284 ! #ifdef HAVE_DEV_DLPI
285 !       /* Map network device to /dev/dlpi unit */
286         cp = "/dev/dlpi";
287         if ((p->fd = open(cp, O_RDWR)) < 0) {
288                 sprintf(ebuf, "%s: %s", cp, pcap_strerror(errno));
289                 goto bad;
290         }
291 !       /* Map network interface to /dev/dlpi unit */
292         ppa = get_dlpi_ppa(p->fd, dname, ppa, ebuf);
293         if (ppa < 0)
294                 goto bad;
295   #else
296         /* Try device without unit number */
297         strcpy(dname2, dname);
298         cp = strchr(dname, *cp);
299 --- 270,331 ----
300                 sprintf(ebuf, "%s bad unit number", device);
301                 goto bad;
302         }
303 +       *cp = '\0';
304   
305 !       /*
306 !        * Use "/dev/dlpi" as the device.
307 !        *
308 !        * XXX - HP's DLPI Programmer's Guide for HP-UX 11.00 says that
309 !        * the "dl_mjr_num" field is for the "major number of interface
310 !        * driver"; that's the major of "/dev/dlpi" on the system on
311 !        * which I tried this, but there may be DLPI devices that
312 !        * use a different driver, in which case we may need to
313 !        * search "/dev" for the appropriate device with that major
314 !        * device number, rather than hardwiring "/dev/dlpi".
315 !        *
316 !        * I'm assuming that the code that was used for HP-UX 10.x
317 !        * is valid, and therefore that, in 10.x, DLPIable devices have
318 !        * "/dev" entries corresponding to them and that their
319 !        * major device number is what appears in the "dl_hp_ppa_info_t"
320 !        * structure for that device.  We can search by name in 11.x
321 !        * (and we may have to, as it's not clear that DLPIable devices
322 !        * will have those sorts of "/dev" entries), but we can't in
323 !        * 10.x, as 10.x doesn't have the "dl_module_id_1" and
324 !        * "dl_module_id_2" members in the "dl_hp_ppa_info_t" structure.
325 !        */
326         cp = "/dev/dlpi";
327         if ((p->fd = open(cp, O_RDWR)) < 0) {
328                 sprintf(ebuf, "%s: %s", cp, pcap_strerror(errno));
329                 goto bad;
330         }
331
332 !       /*
333 !        * Get a table of all PPAs for that device, and search that
334 !        * table for the specified device type name and unit number.
335 !        */
336         ppa = get_dlpi_ppa(p->fd, dname, ppa, ebuf);
337         if (ppa < 0)
338                 goto bad;
339   #else
340 +       /*
341 +       ** Determine device and ppa
342 +       */
343 +       cp = strpbrk(device, "0123456789");
344 +       if (cp == NULL) {
345 +               sprintf(ebuf, "%s missing unit number", device);
346 +               goto bad;
347 +       }
348 +       ppa = strtol(cp, &eos, 10);
349 +       if (*eos != '\0') {
350 +               sprintf(ebuf, "%s bad unit number", device);
351 +               goto bad;
352 +       }
353
354 +       if (*device == '/')
355 +               strcpy(dname, device);
356 +       else
357 +               sprintf(dname, "%s/%s", PCAP_DEV_PREFIX, device);
358
359         /* Try device without unit number */
360         strcpy(dname2, dname);
361         cp = strchr(dname, *cp);
362 ***************
363 *** 391,397 ****
364                 break;
365   
366         default:
367 !               sprintf(ebuf, "unknown mac type 0x%lu", infop->dl_mac_type);
368                 goto bad;
369         }
370   
371 --- 441,448 ----
372                 break;
373   
374         default:
375 !               sprintf(ebuf, "unknown mac type 0x%lu",
376 !                   (unsigned long)infop->dl_mac_type);
377                 goto bad;
378         }
379   
380 ***************
381 *** 709,715 ****
382   
383   #ifdef DL_HP_PPA_ACK_OBS
384   /*
385 !  * Under HP-UX 10, we can ask for the ppa
386    */
387   
388   
389 --- 760,766 ----
390   
391   #ifdef DL_HP_PPA_ACK_OBS
392   /*
393 !  * Under HP-UX 10 and HP-UX 11, we can ask for the ppa
394    */
395   
396   
397 ***************
398 *** 719,736 ****
399       register char *ebuf)
400   {
401         register dl_hp_ppa_ack_t *ap;
402 !       register dl_hp_ppa_info_t *ip;
403         register int i;
404         register u_long majdev;
405 -       dl_hp_ppa_req_t req;
406         struct stat statbuf;
407         bpf_u_int32 buf[MAXDLBUF];
408   
409 !       if (stat(device, &statbuf) < 0) {
410 !               sprintf(ebuf, "stat: %s: %s", device, pcap_strerror(errno));
411                 return (-1);
412         }
413         majdev = major(statbuf.st_rdev);
414   
415         memset((char *)&req, 0, sizeof(req));
416         req.dl_primitive = DL_HP_PPA_REQ;
417 --- 770,800 ----
418       register char *ebuf)
419   {
420         register dl_hp_ppa_ack_t *ap;
421 !       register dl_hp_ppa_info_t *ipstart, *ip;
422         register int i;
423 + #ifndef HAVE_HP_PPA_INFO_T_DL_MODULE_ID_1
424 +       char dname[100];
425         register u_long majdev;
426         struct stat statbuf;
427 + #endif
428 +       dl_hp_ppa_req_t req;
429         bpf_u_int32 buf[MAXDLBUF];
430   
431 ! #ifndef HAVE_HP_PPA_INFO_T_DL_MODULE_ID_1
432 !       /*
433 !        * HP-UX 10 doesn't put the interface name in the
434 !        * "dl_hp_ppa_info_t" structure, so we have to
435 !        * try to get the major device number for the device
436 !        * corresponding to the device and unit name provided to
437 !        * us, and search for the entry with that major device number.
438 !        */
439 !       sprintf(dname, "/dev/%s%d", device, unit);
440 !       if (stat(dname, &statbuf) < 0) {
441 !               sprintf(ebuf, "stat: %s: %s", dname, pcap_strerror(errno));
442                 return (-1);
443         }
444         majdev = major(statbuf.st_rdev);
445 + #endif
446   
447         memset((char *)&req, 0, sizeof(req));
448         req.dl_primitive = DL_HP_PPA_REQ;
449 ***************
450 *** 741,760 ****
451                 return (-1);
452   
453         ap = (dl_hp_ppa_ack_t *)buf;
454 !       ip = (dl_hp_ppa_info_t *)((u_char *)ap + ap->dl_offset);
455   
456           for(i = 0; i < ap->dl_count; i++) {
457 !                 if (ip->dl_mjr_num == majdev && ip->dl_instance_num == unit)
458                           break;
459   
460 !                 ip = (dl_hp_ppa_info_t *)((u_char *)ip + ip->dl_next_offset);
461           }
462           if (i == ap->dl_count) {
463 !                 sprintf(ebuf, "can't find PPA for %s", device);
464                 return (-1);
465           }
466           if (ip->dl_hdw_state == HDW_DEAD) {
467 !                 sprintf(ebuf, "%s: hardware state: DOWN\n", device);
468                 return (-1);
469           }
470           return ((int)ip->dl_ppa);
471 --- 805,831 ----
472                 return (-1);
473   
474         ap = (dl_hp_ppa_ack_t *)buf;
475 !       ipstart = (dl_hp_ppa_info_t *)((u_char *)ap + ap->dl_offset);
476 !       ip = ipstart;
477   
478           for(i = 0; i < ap->dl_count; i++) {
479 ! #ifdef HAVE_HP_PPA_INFO_T_DL_MODULE_ID_1
480 !               if ((strcmp(ip->dl_module_id_1, device) == 0 ||
481 !                    strcmp(ip->dl_module_id_2, device) == 0) &&
482 ! #else
483 !                 if (ip->dl_mjr_num == majdev &&
484 ! #endif
485 !                   ip->dl_instance_num == unit)
486                           break;
487   
488 !                 ip = (dl_hp_ppa_info_t *)((u_char *)ipstart + ip->dl_next_offset);
489           }
490           if (i == ap->dl_count) {
491 !                 sprintf(ebuf, "can't find PPA for %s%d", device, unit);
492                 return (-1);
493           }
494           if (ip->dl_hdw_state == HDW_DEAD) {
495 !                 sprintf(ebuf, "%s%d: hardware state: DOWN\n", device, unit);
496                 return (-1);
497           }
498           return ((int)ip->dl_ppa);
499 ***************
500 *** 783,789 ****
501         register int kd;
502         void *addr;
503         struct ifnet ifnet;
504 !       char if_name[sizeof(ifnet.if_name)], tifname[32];
505   
506         cp = strrchr(ifname, '/');
507         if (cp != NULL)
508 --- 854,860 ----
509         register int kd;
510         void *addr;
511         struct ifnet ifnet;
512 !       char if_name[sizeof(ifnet.if_name) + 1];
513   
514         cp = strrchr(ifname, '/');
515         if (cp != NULL)
516 ***************
517 *** 811,823 ****
518                 if (dlpi_kread(kd, (off_t)addr,
519                     &ifnet, sizeof(ifnet), ebuf) < 0 ||
520                     dlpi_kread(kd, (off_t)ifnet.if_name,
521 !                   if_name, sizeof(if_name), ebuf) < 0) {
522                         (void)close(kd);
523                         return (-1);
524                 }
525 !               sprintf(tifname, "%.*s%d",
526 !                   (int)sizeof(if_name), if_name, ifnet.if_unit);
527 !               if (strcmp(tifname, ifname) == 0)
528                         return (ifnet.if_index);
529         }
530   
531 --- 882,893 ----
532                 if (dlpi_kread(kd, (off_t)addr,
533                     &ifnet, sizeof(ifnet), ebuf) < 0 ||
534                     dlpi_kread(kd, (off_t)ifnet.if_name,
535 !                   if_name, sizeof(ifnet.if_name), ebuf) < 0) {
536                         (void)close(kd);
537                         return (-1);
538                 }
539 !               if_name[sizeof(ifnet.if_name)] = '\0';
540 !               if (strcmp(if_name, ifname) == 0 && ifnet.if_unit == unit)
541                         return (ifnet.if_index);
542         }
543