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
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
15 + dnl AC_LBL_HP_PPA_INFO_T_DL_MODULE_ID_1
19 + dnl HAVE_HP_PPA_INFO_T_DL_MODULE_ID_1 (defined)
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).
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,
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)
44 dnl Checks to see if -R is used
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
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
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
69 + cat > conftest.$ac_ext <<EOF
70 + #line 1712 "configure"
71 + #include "confdefs.h"
73 + # include <sys/types.h>
74 + # include <sys/dlpi.h>
75 + # include <sys/dlpi_ext.h>
77 + u_int i = sizeof(((dl_hp_ppa_info_t *)0)->dl_module_id_1)
80 + if { (eval echo configure:1722: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
82 + ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1=yes
84 + echo "configure: failed program was:" >&5
85 + cat conftest.$ac_ext >&5
87 + ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1=no
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
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
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
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
129 AC_LBL_SOCKADDR_SA_LEN
131 + AC_LBL_HP_PPA_INFO_T_DL_MODULE_ID_1
133 AC_LBL_UNALIGNED_ACCESS
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
142 memset(p, 0, sizeof(*p));
145 ! ** Determine device and ppa
147 ! cp = strpbrk(device, "0123456789");
149 sprintf(ebuf, "%s missing unit number", device);
153 memset(p, 0, sizeof(*p));
155 + #ifdef HAVE_DEV_DLPI
157 ! ** Remove any "/dev/" on the front of the device.
159 ! cp = strrchr(device, '/');
167 ! * Split the name into a device type and a unit number.
169 ! cp = strpbrk(dname, "0123456789");
171 sprintf(ebuf, "%s missing unit number", device);
175 sprintf(ebuf, "%s bad unit number", device);
179 ! if (*device == '/')
180 ! strcpy(dname, device);
182 ! sprintf(dname, "%s/%s", PCAP_DEV_PREFIX, device);
183 ! #ifdef HAVE_DEV_DLPI
184 ! /* Map network device to /dev/dlpi unit */
186 if ((p->fd = open(cp, O_RDWR)) < 0) {
187 sprintf(ebuf, "%s: %s", cp, pcap_strerror(errno));
190 ! /* Map network interface to /dev/dlpi unit */
191 ppa = get_dlpi_ppa(p->fd, dname, ppa, ebuf);
195 /* Try device without unit number */
196 strcpy(dname2, dname);
197 cp = strchr(dname, *cp);
199 sprintf(ebuf, "%s bad unit number", device);
205 ! * Use "/dev/dlpi" as the device.
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".
216 if ((p->fd = open(cp, O_RDWR)) < 0) {
217 sprintf(ebuf, "%s: %s", cp, pcap_strerror(errno));
222 ! * Get a table of all PPAs for that device, and search that
223 ! * table for the specified device type name and unit number.
225 ppa = get_dlpi_ppa(p->fd, dname, ppa, ebuf);
230 + ** Determine device and ppa
232 + cp = strpbrk(device, "0123456789");
234 + sprintf(ebuf, "%s missing unit number", device);
237 + ppa = strtol(cp, &eos, 10);
238 + if (*eos != '\0') {
239 + sprintf(ebuf, "%s bad unit number", device);
243 + if (*device == '/')
244 + strcpy(dname, device);
246 + sprintf(dname, "%s/%s", PCAP_DEV_PREFIX, device);
248 /* Try device without unit number */
249 strcpy(dname2, dname);
250 cp = strchr(dname, *cp);
256 ! sprintf(ebuf, "unknown mac type 0x%lu", infop->dl_mac_type);
264 ! sprintf(ebuf, "unknown mac type 0x%lu",
265 ! (unsigned long)infop->dl_mac_type);
272 #ifdef DL_HP_PPA_ACK_OBS
274 ! * Under HP-UX 10, we can ask for the ppa
278 ! /* Determine ppa number that specifies ifname */
280 get_dlpi_ppa(register int fd, register const char *device, register int unit,
283 register dl_hp_ppa_ack_t *ap;
284 ! register dl_hp_ppa_info_t *ip;
286 register u_long majdev;
287 - dl_hp_ppa_req_t req;
289 bpf_u_int32 buf[MAXDLBUF];
291 - if (stat(device, &statbuf) < 0) {
292 - sprintf(ebuf, "stat: %s: %s", device, pcap_strerror(errno));
295 - majdev = major(statbuf.st_rdev);
297 memset((char *)&req, 0, sizeof(req));
298 req.dl_primitive = DL_HP_PPA_REQ;
302 #ifdef DL_HP_PPA_ACK_OBS
304 ! * Under HP-UX 10 and HP-UX 11, we can ask for the ppa
309 ! * Determine ppa number that specifies ifname.
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.
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.
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
330 ! * http://www.deja.com/[ST_rn=ps]/getdoc.xp?AN=558092266
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
336 ! echo 'lanc_outbound_promisc_flag/W1' | /usr/bin/adb -w /stand/vmunix /dev/kmem
338 ! * which could be put in, for example, "/sbin/init.d/lan".
340 ! * Setting the variable is not necessary on HP-UX 11.x.
343 get_dlpi_ppa(register int fd, register const char *device, register int unit,
346 register dl_hp_ppa_ack_t *ap;
347 ! register dl_hp_ppa_info_t *ipstart, *ip;
350 register u_long majdev;
352 + dl_hp_ppa_req_t req;
353 bpf_u_int32 buf[MAXDLBUF];
355 memset((char *)&req, 0, sizeof(req));
356 req.dl_primitive = DL_HP_PPA_REQ;
362 ap = (dl_hp_ppa_ack_t *)buf;
363 ! ip = (dl_hp_ppa_info_t *)((u_char *)ap + ap->dl_offset);
365 ! for(i = 0; i < ap->dl_count; i++) {
366 ! if (ip->dl_mjr_num == majdev && ip->dl_instance_num == unit)
369 ! ip = (dl_hp_ppa_info_t *)((u_char *)ip + ip->dl_next_offset);
371 if (i == ap->dl_count) {
372 ! sprintf(ebuf, "can't find PPA for %s", device);
375 if (ip->dl_hdw_state == HDW_DEAD) {
376 ! sprintf(ebuf, "%s: hardware state: DOWN\n", device);
379 return ((int)ip->dl_ppa);
383 ap = (dl_hp_ppa_ack_t *)buf;
384 ! ipstart = (dl_hp_ppa_info_t *)((u_char *)ap + ap->dl_offset);
387 ! #ifdef HAVE_HP_PPA_INFO_T_DL_MODULE_ID_1
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).
398 ! * Search for the device that has the specified name and
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)
407 ! ip = (dl_hp_ppa_info_t *)((u_char *)ipstart + ip->dl_next_offset);
411 ! * We don't have that member, so the search is impossible; make it
412 ! * look as if the search failed.
417 ! if (i == ap->dl_count) {
419 ! * Well, we didn't, or can't, find the device by name.
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.
426 ! * Older HP-UX 10.x systems might not have those fields
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.
433 ! sprintf(dname, "/dev/%s%d", device, unit);
434 ! if (stat(dname, &statbuf) < 0) {
435 ! sprintf(ebuf, "stat: %s: %s", dname, pcap_strerror(errno));
438 ! majdev = major(statbuf.st_rdev);
442 ! for (i = 0; i < ap->dl_count; i++) {
443 ! if (ip->dl_mjr_num == majdev &&
444 ! ip->dl_instance_num == unit)
447 ! ip = (dl_hp_ppa_info_t *)((u_char *)ipstart + ip->dl_next_offset);
450 if (i == ap->dl_count) {
451 ! sprintf(ebuf, "can't find /dev/dlpi PPA for %s%d", device, unit);
454 if (ip->dl_hdw_state == HDW_DEAD) {
455 ! sprintf(ebuf, "%s%d: hardware state: DOWN\n", device, unit);
458 return ((int)ip->dl_ppa);
464 ! char if_name[sizeof(ifnet.if_name)], tifname[32];
466 cp = strrchr(ifname, '/');
472 ! char if_name[sizeof(ifnet.if_name) + 1];
474 cp = strrchr(ifname, '/');
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) {
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);
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) {
499 ! if_name[sizeof(ifnet.if_name)] = '\0';
500 ! if (strcmp(if_name, ifname) == 0 && ifnet.if_unit == unit)
501 return (ifnet.if_index);