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