Add the relative time to the frame tree, at the request of Manfred Young.
[obnox/wireshark/wip.git] / libpcap-0.4.HPUX.LBL.patch
1 diff -c ../libpcap-0.4/aclocal.m4 ./aclocal.m4
2 *** ../libpcap-0.4/aclocal.m4   Fri Jun 12 03:45:15 1998
3 --- ./aclocal.m4        Tue Jan  4 21:02:13 2000
4 ***************
5 *** 415,420 ****
6 --- 415,454 ----
7       fi])
8   
9   dnl
10 + dnl Checks to see if the dl_hp_ppa_info_t struct has the HP-UX 11.00
11 + dnl dl_module_id_1 member
12 + dnl
13 + dnl usage:
14 + dnl
15 + dnl   AC_LBL_HP_PPA_INFO_T_DL_MODULE_ID_1
16 + dnl
17 + dnl results:
18 + dnl
19 + dnl   HAVE_HP_PPA_INFO_T_DL_MODULE_ID_1 (defined)
20 + dnl
21 + dnl NOTE: any compile failure means we conclude that it doesn't have
22 + dnl that member, so if we don't have DLPI, don't have a <sys/dlpi_ext.h>
23 + dnl header, or have one that doesn't declare a dl_hp_ppa_info_t type,
24 + dnl we conclude it doesn't have that member (which is OK, as either we
25 + dnl won't be using code that would use that member, or we wouldn't
26 + dnl compile in any case).
27 + dnl
28 + AC_DEFUN(AC_LBL_HP_PPA_INFO_T_DL_MODULE_ID_1,
29 +     [AC_MSG_CHECKING(if dl_hp_ppa_info_t struct has dl_module_id_1 member)
30 +     AC_CACHE_VAL(ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1,
31 +       AC_TRY_COMPILE([
32 + #     include <sys/types.h>
33 + #     include <sys/dlpi.h>
34 + #     include <sys/dlpi_ext.h>],
35 +       [u_int i = sizeof(((dl_hp_ppa_info_t *)0)->dl_module_id_1)],
36 +       ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1=yes,
37 +       ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1=no))
38 +     AC_MSG_RESULT($ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1)
39 +     if test $ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1 = yes ; then
40 +           AC_DEFINE(HAVE_HP_PPA_INFO_T_DL_MODULE_ID_1)
41 +     fi])
42
43 + dnl
44   dnl Checks to see if -R is used
45   dnl
46   dnl usage:
47 diff -c ../libpcap-0.4/configure ./configure
48 *** ../libpcap-0.4/configure    Sat Jul 25 12:41:51 1998
49 --- ./configure Fri Jan 14 00:40:04 2000
50 ***************
51 *** 1702,1709 ****
52   
53       fi
54   
55   echo $ac_n "checking if unaligned accesses fail""... $ac_c" 1>&6
56 ! echo "configure:1707: checking if unaligned accesses fail" >&5
57       if eval "test \"`echo '$''{'ac_cv_lbl_unaligned_fail'+set}'`\" = set"; then
58     echo $ac_n "(cached) $ac_c" 1>&6
59   else
60 --- 1702,1745 ----
61   
62       fi
63   
64 + echo $ac_n "checking if dl_hp_ppa_info_t struct has dl_module_id_1 member""... $ac_c" 1>&6
65 + echo "configure:1707: checking if dl_hp_ppa_info_t struct has dl_module_id_1 member" >&5
66 +     if eval "test \"`echo '$''{'ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1'+set}'`\" = set"; then
67 +   echo $ac_n "(cached) $ac_c" 1>&6
68 + else
69 +   cat > conftest.$ac_ext <<EOF
70 + #line 1712 "configure"
71 + #include "confdefs.h"
72
73 + #     include <sys/types.h>
74 + #     include <sys/dlpi.h>
75 + #     include <sys/dlpi_ext.h>
76 + int main() {
77 + u_int i = sizeof(((dl_hp_ppa_info_t *)0)->dl_module_id_1)
78 + ; return 0; }
79 + EOF
80 + if { (eval echo configure:1722: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
81 +   rm -rf conftest*
82 +   ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1=yes
83 + else
84 +   echo "configure: failed program was:" >&5
85 +   cat conftest.$ac_ext >&5
86 +   rm -rf conftest*
87 +   ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1=no
88 + fi
89 + rm -f conftest*
90 + fi
91
92 +     echo "$ac_t""$ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1" 1>&6
93 +     if test $ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1 = yes ; then
94 +           cat >> confdefs.h <<\EOF
95 + #define HAVE_HP_PPA_INFO_T_DL_MODULE_ID_1 1
96 + EOF
97
98 +     fi
99
100   echo $ac_n "checking if unaligned accesses fail""... $ac_c" 1>&6
101 ! echo "configure:1743: checking if unaligned accesses fail" >&5
102       if eval "test \"`echo '$''{'ac_cv_lbl_unaligned_fail'+set}'`\" = set"; then
103     echo $ac_n "(cached) $ac_c" 1>&6
104   else
105 ***************
106 *** 1799,1805 ****
107   # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
108   # ./install, which can be erroneously created by make from ./install.sh.
109   echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
110 ! echo "configure:1803: checking for a BSD compatible install" >&5
111   if test -z "$INSTALL"; then
112   if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
113     echo $ac_n "(cached) $ac_c" 1>&6
114 --- 1835,1841 ----
115   # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
116   # ./install, which can be erroneously created by make from ./install.sh.
117   echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
118 ! echo "configure:1839: checking for a BSD compatible install" >&5
119   if test -z "$INSTALL"; then
120   if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
121     echo $ac_n "(cached) $ac_c" 1>&6
122 diff -c ../libpcap-0.4/configure.in ./configure.in
123 *** ../libpcap-0.4/configure.in Sun Jul 27 22:16:22 1997
124 --- ./configure.in      Tue Jan  4 21:02:13 2000
125 ***************
126 *** 154,159 ****
127 --- 154,161 ----
128   
129   AC_LBL_SOCKADDR_SA_LEN
130   
131 + AC_LBL_HP_PPA_INFO_T_DL_MODULE_ID_1
132
133   AC_LBL_UNALIGNED_ACCESS
134   
135   if test "${srcdir}" = "." ; then
136 diff -c ../libpcap-0.4/pcap-dlpi.c ./pcap-dlpi.c
137 *** ../libpcap-0.4/pcap-dlpi.c  Wed Oct 15 21:59:34 1997
138 --- ./pcap-dlpi.c       Sat Aug 12 23:57:13 2000
139 ***************
140 *** 246,255 ****
141         }
142         memset(p, 0, sizeof(*p));
143   
144         /*
145 !       ** Determine device and ppa
146         */
147 !       cp = strpbrk(device, "0123456789");
148         if (cp == NULL) {
149                 sprintf(ebuf, "%s missing unit number", device);
150                 goto bad;
151 --- 246,266 ----
152         }
153         memset(p, 0, sizeof(*p));
154   
155 + #ifdef HAVE_DEV_DLPI
156         /*
157 !       ** Remove any "/dev/" on the front of the device.
158         */
159 !       cp = strrchr(device, '/');
160 !       if (cp == NULL)
161 !               cp = device;
162 !       else
163 !               cp++;
164 !       strcpy(dname, cp);
165
166 !       /*
167 !        * Split the name into a device type and a unit number.
168 !        */
169 !       cp = strpbrk(dname, "0123456789");
170         if (cp == NULL) {
171                 sprintf(ebuf, "%s missing unit number", device);
172                 goto bad;
173 ***************
174 *** 259,281 ****
175                 sprintf(ebuf, "%s bad unit number", device);
176                 goto bad;
177         }
178   
179 !       if (*device == '/')
180 !               strcpy(dname, device);
181 !       else
182 !               sprintf(dname, "%s/%s", PCAP_DEV_PREFIX, device);
183 ! #ifdef HAVE_DEV_DLPI
184 !       /* Map network device to /dev/dlpi unit */
185         cp = "/dev/dlpi";
186         if ((p->fd = open(cp, O_RDWR)) < 0) {
187                 sprintf(ebuf, "%s: %s", cp, pcap_strerror(errno));
188                 goto bad;
189         }
190 !       /* Map network interface to /dev/dlpi unit */
191         ppa = get_dlpi_ppa(p->fd, dname, ppa, ebuf);
192         if (ppa < 0)
193                 goto bad;
194   #else
195         /* Try device without unit number */
196         strcpy(dname2, dname);
197         cp = strchr(dname, *cp);
198 --- 270,321 ----
199                 sprintf(ebuf, "%s bad unit number", device);
200                 goto bad;
201         }
202 +       *cp = '\0';
203   
204 !       /*
205 !        * Use "/dev/dlpi" as the device.
206 !        *
207 !        * XXX - HP's DLPI Programmer's Guide for HP-UX 11.00 says that
208 !        * the "dl_mjr_num" field is for the "major number of interface
209 !        * driver"; that's the major of "/dev/dlpi" on the system on
210 !        * which I tried this, but there may be DLPI devices that
211 !        * use a different driver, in which case we may need to
212 !        * search "/dev" for the appropriate device with that major
213 !        * device number, rather than hardwiring "/dev/dlpi".
214 !        */
215         cp = "/dev/dlpi";
216         if ((p->fd = open(cp, O_RDWR)) < 0) {
217                 sprintf(ebuf, "%s: %s", cp, pcap_strerror(errno));
218                 goto bad;
219         }
220
221 !       /*
222 !        * Get a table of all PPAs for that device, and search that
223 !        * table for the specified device type name and unit number.
224 !        */
225         ppa = get_dlpi_ppa(p->fd, dname, ppa, ebuf);
226         if (ppa < 0)
227                 goto bad;
228   #else
229 +       /*
230 +       ** Determine device and ppa
231 +       */
232 +       cp = strpbrk(device, "0123456789");
233 +       if (cp == NULL) {
234 +               sprintf(ebuf, "%s missing unit number", device);
235 +               goto bad;
236 +       }
237 +       ppa = strtol(cp, &eos, 10);
238 +       if (*eos != '\0') {
239 +               sprintf(ebuf, "%s bad unit number", device);
240 +               goto bad;
241 +       }
242
243 +       if (*device == '/')
244 +               strcpy(dname, device);
245 +       else
246 +               sprintf(dname, "%s/%s", PCAP_DEV_PREFIX, device);
247
248         /* Try device without unit number */
249         strcpy(dname2, dname);
250         cp = strchr(dname, *cp);
251 ***************
252 *** 391,397 ****
253                 break;
254   
255         default:
256 !               sprintf(ebuf, "unknown mac type 0x%lu", infop->dl_mac_type);
257                 goto bad;
258         }
259   
260 --- 431,438 ----
261                 break;
262   
263         default:
264 !               sprintf(ebuf, "unknown mac type 0x%lu",
265 !                   (unsigned long)infop->dl_mac_type);
266                 goto bad;
267         }
268   
269 ***************
270 *** 709,737 ****
271   
272   #ifdef DL_HP_PPA_ACK_OBS
273   /*
274 !  * Under HP-UX 10, we can ask for the ppa
275    */
276   
277   
278 ! /* Determine ppa number that specifies ifname */
279   static int
280   get_dlpi_ppa(register int fd, register const char *device, register int unit,
281       register char *ebuf)
282   {
283         register dl_hp_ppa_ack_t *ap;
284 !       register dl_hp_ppa_info_t *ip;
285         register int i;
286         register u_long majdev;
287 -       dl_hp_ppa_req_t req;
288         struct stat statbuf;
289         bpf_u_int32 buf[MAXDLBUF];
290   
291 -       if (stat(device, &statbuf) < 0) {
292 -               sprintf(ebuf, "stat: %s: %s", device, pcap_strerror(errno));
293 -               return (-1);
294 -       }
295 -       majdev = major(statbuf.st_rdev);
296
297         memset((char *)&req, 0, sizeof(req));
298         req.dl_primitive = DL_HP_PPA_REQ;
299   
300 --- 750,806 ----
301   
302   #ifdef DL_HP_PPA_ACK_OBS
303   /*
304 !  * Under HP-UX 10 and HP-UX 11, we can ask for the ppa
305    */
306   
307   
308 ! /*
309 !  * Determine ppa number that specifies ifname.
310 !  *
311 !  * If the "dl_hp_ppa_info_t" doesn't have a "dl_module_id_1" member,
312 !  * the code that's used here is the old code for HP-UX 10.x.
313 !  *
314 !  * However, HP-UX 10.20, at least, appears to have such a member
315 !  * in its "dl_hp_ppa_info_t" structure, so the new code is used.
316 !  * The new code didn't work on an old 10.20 system on which Rick
317 !  * Jones of HP tried it, but with later patches installed, it
318 !  * worked - it appears that the older system had those members but
319 !  * didn't put anything in them, so, if the search by name fails, we
320 !  * do the old search.
321 !  *
322 !  * Rick suggests that making sure your system is "up on the latest
323 !  * lancommon/DLPI/driver patches" is probably a good idea; it'd fix
324 !  * that problem, as well as allowing libpcap to see packets sent
325 !  * from the system on which the libpcap application is being run.
326 !  * (On 10.20, in addition to getting the latest patches, you need
327 !  * to turn the kernel "lanc_outbound_promisc_flag" flag on with ADB;
328 !  * a posting to "comp.sys.hp.hpux" at
329 !  *
330 !  *    http://www.deja.com/[ST_rn=ps]/getdoc.xp?AN=558092266
331 !  *
332 !  * says that, to see the machine's outgoing traffic, you'd need to
333 !  * apply the right patches to your system, and also set that variable
334 !  * with:
335 !  
336 ! echo 'lanc_outbound_promisc_flag/W1' | /usr/bin/adb -w /stand/vmunix /dev/kmem
337
338 !  * which could be put in, for example, "/sbin/init.d/lan".
339 !  *
340 !  * Setting the variable is not necessary on HP-UX 11.x.
341 !  */
342   static int
343   get_dlpi_ppa(register int fd, register const char *device, register int unit,
344       register char *ebuf)
345   {
346         register dl_hp_ppa_ack_t *ap;
347 !       register dl_hp_ppa_info_t *ipstart, *ip;
348         register int i;
349 +       char dname[100];
350         register u_long majdev;
351         struct stat statbuf;
352 +       dl_hp_ppa_req_t req;
353         bpf_u_int32 buf[MAXDLBUF];
354   
355         memset((char *)&req, 0, sizeof(req));
356         req.dl_primitive = DL_HP_PPA_REQ;
357   
358 ***************
359 *** 741,760 ****
360                 return (-1);
361   
362         ap = (dl_hp_ppa_ack_t *)buf;
363 !       ip = (dl_hp_ppa_info_t *)((u_char *)ap + ap->dl_offset);
364   
365 !         for(i = 0; i < ap->dl_count; i++) {
366 !                 if (ip->dl_mjr_num == majdev && ip->dl_instance_num == unit)
367 !                         break;
368   
369 !                 ip = (dl_hp_ppa_info_t *)((u_char *)ip + ip->dl_next_offset);
370 !         }
371           if (i == ap->dl_count) {
372 !                 sprintf(ebuf, "can't find PPA for %s", device);
373                 return (-1);
374           }
375           if (ip->dl_hdw_state == HDW_DEAD) {
376 !                 sprintf(ebuf, "%s: hardware state: DOWN\n", device);
377                 return (-1);
378           }
379           return ((int)ip->dl_ppa);
380 --- 810,887 ----
381                 return (-1);
382   
383         ap = (dl_hp_ppa_ack_t *)buf;
384 !       ipstart = (dl_hp_ppa_info_t *)((u_char *)ap + ap->dl_offset);
385 !       ip = ipstart;
386   
387 ! #ifdef HAVE_HP_PPA_INFO_T_DL_MODULE_ID_1
388 !       /*
389 !        * The "dl_hp_ppa_info_t" structure has a "dl_module_id_1"
390 !        * member that should, in theory, contain the part of the
391 !        * name for the device that comes before the unit number,
392 !        * and should also have a "dl_module_id_2" member that may
393 !        * contain an alternate name (e.g., I think Ethernet devices
394 !        * have both "lan", for "lanN", and "snap", for "snapN", with
395 !        * the former being for Ethernet packets and the latter being
396 !        * for 802.3/802.2 packets).
397 !        *
398 !        * Search for the device that has the specified name and
399 !        * instance number.
400 !        */
401 !       for (i = 0; i < ap->dl_count; i++) {
402 !               if ((strcmp(ip->dl_module_id_1, device) == 0 ||
403 !                    strcmp(ip->dl_module_id_2, device) == 0) &&
404 !                   ip->dl_instance_num == unit)
405 !                       break;
406   
407 !               ip = (dl_hp_ppa_info_t *)((u_char *)ipstart + ip->dl_next_offset);
408 !       }
409 ! #else
410 !       /*
411 !        * We don't have that member, so the search is impossible; make it
412 !        * look as if the search failed.
413 !        */
414 !       i = ap->dl_count;
415 ! #endif
416
417 !       if (i == ap->dl_count) {
418 !               /*
419 !                * Well, we didn't, or can't, find the device by name.
420 !                *
421 !                * HP-UX 10.20, whilst it has "dl_module_id_1" and
422 !                * "dl_module_id_2" fields in the "dl_hp_ppa_info_t",
423 !                * doesn't seem to fill them in unless the system is
424 !                * at a reasonably up-to-date patch level.
425 !                *
426 !                * Older HP-UX 10.x systems might not have those fields
427 !                * at all.
428 !                *
429 !                * Therefore, we'll search for the entry with the major
430 !                * device number of a device with the name "/dev/<dev><unit>",
431 !                * if such a device exists, as the old code did.
432 !                */
433 !               sprintf(dname, "/dev/%s%d", device, unit);
434 !               if (stat(dname, &statbuf) < 0) {
435 !                       sprintf(ebuf, "stat: %s: %s", dname, pcap_strerror(errno));
436 !                       return (-1);
437 !               }
438 !               majdev = major(statbuf.st_rdev);
439
440 !               ip = ipstart;
441
442 !               for (i = 0; i < ap->dl_count; i++) {
443 !                       if (ip->dl_mjr_num == majdev &&
444 !                           ip->dl_instance_num == unit)
445 !                               break;
446
447 !                       ip = (dl_hp_ppa_info_t *)((u_char *)ipstart + ip->dl_next_offset);
448 !               }
449 !       }
450           if (i == ap->dl_count) {
451 !                 sprintf(ebuf, "can't find /dev/dlpi PPA for %s%d", device, unit);
452                 return (-1);
453           }
454           if (ip->dl_hdw_state == HDW_DEAD) {
455 !                 sprintf(ebuf, "%s%d: hardware state: DOWN\n", device, unit);
456                 return (-1);
457           }
458           return ((int)ip->dl_ppa);
459 ***************
460 *** 783,789 ****
461         register int kd;
462         void *addr;
463         struct ifnet ifnet;
464 !       char if_name[sizeof(ifnet.if_name)], tifname[32];
465   
466         cp = strrchr(ifname, '/');
467         if (cp != NULL)
468 --- 910,916 ----
469         register int kd;
470         void *addr;
471         struct ifnet ifnet;
472 !       char if_name[sizeof(ifnet.if_name) + 1];
473   
474         cp = strrchr(ifname, '/');
475         if (cp != NULL)
476 ***************
477 *** 811,823 ****
478                 if (dlpi_kread(kd, (off_t)addr,
479                     &ifnet, sizeof(ifnet), ebuf) < 0 ||
480                     dlpi_kread(kd, (off_t)ifnet.if_name,
481 !                   if_name, sizeof(if_name), ebuf) < 0) {
482                         (void)close(kd);
483                         return (-1);
484                 }
485 !               sprintf(tifname, "%.*s%d",
486 !                   (int)sizeof(if_name), if_name, ifnet.if_unit);
487 !               if (strcmp(tifname, ifname) == 0)
488                         return (ifnet.if_index);
489         }
490   
491 --- 938,949 ----
492                 if (dlpi_kread(kd, (off_t)addr,
493                     &ifnet, sizeof(ifnet), ebuf) < 0 ||
494                     dlpi_kread(kd, (off_t)ifnet.if_name,
495 !                   if_name, sizeof(ifnet.if_name), ebuf) < 0) {
496                         (void)close(kd);
497                         return (-1);
498                 }
499 !               if_name[sizeof(ifnet.if_name)] = '\0';
500 !               if (strcmp(if_name, ifname) == 0 && ifnet.if_unit == unit)
501                         return (ifnet.if_index);
502         }
503