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