]> git.ozlabs.org Git - ppp.git/blob - pppd/sys-str.c
*** empty log message ***
[ppp.git] / pppd / sys-str.c
1 /*
2  * sys-str.c - System-dependent procedures for setting up
3  * PPP interfaces on systems which use the STREAMS ppp interface.
4  *
5  * Copyright (c) 1989 Carnegie Mellon University.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms are permitted
9  * provided that the above copyright notice and this paragraph are
10  * duplicated in all such forms and that any documentation,
11  * advertising materials, and other materials related to such
12  * distribution and use acknowledge that the software was developed
13  * by Carnegie Mellon University.  The name of the
14  * University may not be used to endorse or promote products derived
15  * from this software without specific prior written permission.
16  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
17  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
18  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19  */
20
21 /*
22  * TODO:
23  */
24
25 #include <stdio.h>
26 #include <errno.h>
27 #include <syslog.h>
28 #include <fcntl.h>
29 #include <sys/ioctl.h>
30 #include <sys/types.h>
31 #include <sys/socket.h>
32 #include <sys/time.h>
33 #include <sys/stream.h>
34 #include <sys/stropts.h>
35
36 #include <net/if.h>
37 #include <net/route.h>
38 #include <net/if_arp.h>
39 #include <netinet/in.h>
40
41 #include "pppd.h"
42 #include "ppp.h"
43 #include <net/if_ppp.h>
44 #include <net/ppp_str.h>
45
46 #ifndef ifr_mtu
47 #define ifr_mtu         ifr_metric
48 #endif
49
50 #define MAXMODULES      10      /* max number of module names to save */
51 static struct   modlist {
52     char        modname[FMNAMESZ+1];
53 } str_modules[MAXMODULES];
54 static int      str_module_count = 0;
55 static int      pushed_ppp;
56
57 extern int hungup;              /* has the physical layer been disconnected? */
58 extern int kdebugflag;
59
60 #define PAI_FLAGS_B7_0          0x100
61 #define PAI_FLAGS_B7_1          0x200
62 #define PAI_FLAGS_PAR_EVEN      0x400
63 #define PAI_FLAGS_PAR_ODD       0x800
64 #define PAI_FLAGS_HIBITS        0xF00
65
66 /*
67  * ppp_available - check if this kernel supports PPP.
68  */
69 int
70 ppp_available()
71 {
72     int fd, ret;
73
74     fd = open("/dev/tty", O_RDONLY, 0);
75     if (fd < 0)
76         return 1;               /* can't find out - assume we have ppp */
77     ret = ioctl(fd, I_FIND, "pppasync") >= 0;
78     close(fd);
79     return ret;
80 }
81
82
83 /*
84  * establish_ppp - Turn the serial port into a ppp interface.
85  */
86 void
87 establish_ppp()
88 {
89     /* go through and save the name of all the modules, then pop em */
90     for (;;) { 
91         if (ioctl(fd, I_LOOK, str_modules[str_module_count].modname) < 0 ||
92             ioctl(fd, I_POP, 0) < 0)
93             break;
94         MAINDEBUG((LOG_DEBUG, "popped stream module : %s",
95                    str_modules[str_module_count].modname));
96         str_module_count++;
97     }
98
99     /* now push the async/fcs module */
100     if (ioctl(fd, I_PUSH, "pppasync") < 0) {
101         syslog(LOG_ERR, "ioctl(I_PUSH, ppp_async): %m");
102         die(1);
103     }
104     /* finally, push the ppp_if module that actually handles the */
105     /* network interface */ 
106     if (ioctl(fd, I_PUSH, "pppif") < 0) {
107         syslog(LOG_ERR, "ioctl(I_PUSH, ppp_if): %m");
108         die(1);
109     }
110     pushed_ppp = 1;
111     if (ioctl(fd, I_SETSIG, S_INPUT) < 0) {
112         syslog(LOG_ERR, "ioctl(I_SETSIG, S_INPUT): %m");
113         die(1);
114     }
115     /* read mode, message non-discard mode */
116     if (ioctl(fd, I_SRDOPT, RMSGN) < 0) {
117         syslog(LOG_ERR, "ioctl(I_SRDOPT, RMSGN): %m");
118         die(1);
119     }
120     /* Flush any waiting messages, or we'll never get SIGPOLL */
121     if (ioctl(fd, I_FLUSH, FLUSHRW) < 0) {
122         syslog(LOG_ERR, "ioctl(I_FLUSH, FLUSHRW): %m");
123         die(1);
124     }
125     /*
126      * Find out which interface we were given.
127      * (ppp_if handles this ioctl)
128      */
129     if (ioctl(fd, SIOCGETU, &ifunit) < 0) {
130         syslog(LOG_ERR, "ioctl(SIOCGETU): %m");
131         die(1);
132     }
133
134     /* Set debug flags in driver */
135     if (ioctl(fd, SIOCSIFDEBUG, &kdebugflag) < 0) {
136         syslog(LOG_ERR, "ioctl(SIOCSIFDEBUG): %m");
137     }
138 }
139
140 /*
141  * disestablish_ppp - Restore the serial port to normal operation.
142  * It attempts to reconstruct the stream with the previously popped
143  * modules.  This shouldn't call die() because it's called from die().
144  */
145 void
146 disestablish_ppp()
147 {
148     int flags;
149     char *s;
150
151     if (hungup) {
152         /* we can't push or pop modules after the stream has hung up */
153         str_module_count = 0;
154         return;
155     }
156
157     if (pushed_ppp) {
158         /*
159          * Check whether the link seems not to be 8-bit clean.
160          */
161         if (ioctl(fd, SIOCGIFDEBUG, (caddr_t) &flags) == 0) {
162             s = NULL;
163             switch (~flags & PAI_FLAGS_HIBITS) {
164             case PAI_FLAGS_B7_0:
165                 s = "bit 7 set to 1";
166                 break;
167             case PAI_FLAGS_B7_1:
168                 s = "bit 7 set to 0";
169                 break;
170             case PAI_FLAGS_PAR_EVEN:
171                 s = "odd parity";
172                 break;
173             case PAI_FLAGS_PAR_ODD:
174                 s = "even parity";
175                 break;
176             }
177             if (s != NULL) {
178                 syslog(LOG_WARNING, "Serial link is not 8-bit clean:");
179                 syslog(LOG_WARNING, "All received characters had %s", s);
180             }
181         }
182     }
183
184     while (ioctl(fd, I_POP, 0) == 0)    /* pop any we pushed */
185         ;
186     pushed_ppp = 0;
187   
188     for (; str_module_count > 0; str_module_count--) {
189         if (ioctl(fd, I_PUSH, str_modules[str_module_count-1].modname)) {
190             syslog(LOG_WARNING, "str_restore: couldn't push module %s: %m",
191                    str_modules[str_module_count-1].modname);
192         } else {
193             MAINDEBUG((LOG_INFO, "str_restore: pushed module %s",
194                        str_modules[str_module_count-1].modname));
195         }
196     }
197 }
198
199
200 /*
201  * output - Output PPP packet.
202  */
203 void
204 output(unit, p, len)
205     int unit;
206     u_char *p;
207     int len;
208 {
209     struct strbuf       str;
210
211     if (unit != 0)
212         MAINDEBUG((LOG_WARNING, "output: unit != 0!"));
213     if (debug)
214         log_packet(p, len, "sent ");
215
216     str.len = len;
217     str.buf = (caddr_t) p;
218     if(putmsg(fd, NULL, &str, 0) < 0) {
219         syslog(LOG_ERR, "putmsg: %m");
220         die(1);
221     }
222 }
223
224
225 /*
226  * read_packet - get a PPP packet from the serial device.
227  */
228 int
229 read_packet(buf)
230     u_char *buf;
231 {
232     struct strbuf str;
233     int len, i;
234
235     str.maxlen = MTU+DLLHEADERLEN;
236     str.buf = (caddr_t) buf;
237     i = 0;
238     len = getmsg(fd, NULL, &str, &i);
239     if (len < 0) {
240         if (errno == EAGAIN || errno == EWOULDBLOCK) {
241             return -1;
242         }
243         syslog(LOG_ERR, "getmsg(fd) %m");
244         die(1);
245     }
246     if (len) 
247         MAINDEBUG((LOG_DEBUG, "getmsg returned 0x%x",len));
248
249     if (str.len < 0) {
250         MAINDEBUG((LOG_DEBUG, "getmsg short return length %d", str.len));
251         return -1;
252     }
253
254     return str.len;
255 }
256
257
258 /*
259  * ppp_send_config - configure the transmit characteristics of
260  * the ppp interface.
261  */
262 void
263 ppp_send_config(unit, mtu, asyncmap, pcomp, accomp)
264     int unit, mtu;
265     u_long asyncmap;
266     int pcomp, accomp;
267 {
268     char c;
269     struct ifreq ifr;
270
271     strncpy(ifr.ifr_name, ifname, sizeof (ifr.ifr_name));
272     ifr.ifr_mtu = mtu;
273     if (ioctl(s, SIOCSIFMTU, (caddr_t) &ifr) < 0) {
274         syslog(LOG_ERR, "ioctl(SIOCSIFMTU): %m");
275         quit();
276     }
277
278     if(ioctl(fd, SIOCSIFASYNCMAP, (caddr_t) &asyncmap) < 0) {
279         syslog(LOG_ERR, "ioctl(SIOCSIFASYNCMAP): %m");
280         quit();
281     }
282
283     c = (pcomp? 1: 0);
284     if(ioctl(fd, SIOCSIFCOMPPROT, &c) < 0) {
285         syslog(LOG_ERR, "ioctl(SIOCSIFCOMPPROT): %m");
286         quit();
287     }
288
289     c = (accomp? 1: 0);
290     if(ioctl(fd, SIOCSIFCOMPAC, &c) < 0) {
291         syslog(LOG_ERR, "ioctl(SIOCSIFCOMPAC): %m");
292         quit();
293     }
294 }
295
296
297 /*
298  * ppp_set_xaccm - set the extended transmit ACCM for the interface.
299  */
300 void
301 ppp_set_xaccm(unit, accm)
302     int unit;
303     ext_accm accm;
304 {
305     if (ioctl(fd, SIOCSIFXASYNCMAP, accm) < 0 && errno != ENOTTY)
306         syslog(LOG_WARNING, "ioctl(set extended ACCM): %m");
307 }
308
309
310 /*
311  * ppp_recv_config - configure the receive-side characteristics of
312  * the ppp interface.
313  */
314 void
315 ppp_recv_config(unit, mru, asyncmap, pcomp, accomp)
316     int unit, mru;
317     u_long asyncmap;
318     int pcomp, accomp;
319 {
320     char c;
321
322     if (ioctl(fd, SIOCSIFMRU, &mru) < 0) {
323         syslog(LOG_ERR, "ioctl(SIOCSIFMRU): %m");
324     }
325
326     if (ioctl(fd, SIOCSIFRASYNCMAP, (caddr_t) &asyncmap) < 0) {
327         syslog(LOG_ERR, "ioctl(SIOCSIFRASYNCMAP): %m");
328     }
329
330     c = 2 + (pcomp? 1: 0);
331     if(ioctl(fd, SIOCSIFCOMPPROT, &c) < 0) {
332         syslog(LOG_ERR, "ioctl(SIOCSIFCOMPPROT): %m");
333     }
334
335     c = 2 + (accomp? 1: 0);
336     if (ioctl(fd, SIOCSIFCOMPAC, &c) < 0) {
337         syslog(LOG_ERR, "ioctl(SIOCSIFCOMPAC): %m");
338     }
339 }
340
341 /*
342  * sifvjcomp - config tcp header compression
343  */
344 int
345 sifvjcomp(u, vjcomp, cidcomp, maxcid)
346     int u, vjcomp, cidcomp, maxcid;
347 {
348     char x;
349
350     x = (vjcomp? 1: 0) + (cidcomp? 0: 2) + (maxcid << 4);
351     if (ioctl(fd, SIOCSIFVJCOMP, (caddr_t) &x) < 0) {
352         syslog(LOG_ERR, "ioctl(SIOCSIFVJCOMP): %m");
353         return 0;
354     }
355     return 1;
356 }
357
358 /*
359  * sifup - Config the interface up.
360  */
361 int
362 sifup(u)
363 {
364     struct ifreq ifr;
365
366     strncpy(ifr.ifr_name, ifname, sizeof (ifr.ifr_name));
367     if (ioctl(s, SIOCGIFFLAGS, (caddr_t) &ifr) < 0) {
368         syslog(LOG_ERR, "ioctl (SIOCGIFFLAGS): %m");
369         return 0;
370     }
371     ifr.ifr_flags |= IFF_UP;
372     if (ioctl(s, SIOCSIFFLAGS, (caddr_t) &ifr) < 0) {
373         syslog(LOG_ERR, "ioctl(SIOCSIFFLAGS): %m");
374         return 0;
375     }
376     return 1;
377 }
378
379 /*
380  * sifdown - Config the interface down.
381  */
382 int
383 sifdown(u)
384 {
385     struct ifreq ifr;
386     strncpy(ifr.ifr_name, ifname, sizeof (ifr.ifr_name));
387     if (ioctl(s, SIOCGIFFLAGS, (caddr_t) &ifr) < 0) {
388         syslog(LOG_ERR, "ioctl (SIOCGIFFLAGS): %m");
389         return 0;
390     }
391     ifr.ifr_flags &= ~IFF_UP;
392     if (ioctl(s, SIOCSIFFLAGS, (caddr_t) &ifr) < 0) {
393         syslog(LOG_ERR, "ioctl(SIOCSIFFLAGS): %m");
394         return 0;
395     }
396     return 1;
397 }
398
399 /*
400  * SET_SA_FAMILY - initialize a struct sockaddr, setting the sa_family field.
401  */
402 #define SET_SA_FAMILY(addr, family)             \
403     BZERO((char *) &(addr), sizeof(addr));      \
404     addr.sa_family = (family);
405
406 /*
407  * sifaddr - Config the interface IP addresses and netmask.
408  */
409 int
410 sifaddr(u, o, h, m)
411 {
412     int ret;
413     struct ifreq ifr;
414
415     ret = 1;
416     strncpy(ifr.ifr_name, ifname, sizeof (ifr.ifr_name));
417     SET_SA_FAMILY(ifr.ifr_addr, AF_INET);
418     ((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr.s_addr = o;
419     if (ioctl(s, SIOCSIFADDR, (caddr_t) &ifr) < 0) {
420         syslog(LOG_ERR, "ioctl(SIOCSIFADDR): %m");
421         ret = 0;
422     }
423     ((struct sockaddr_in *) &ifr.ifr_dstaddr)->sin_addr.s_addr = h;
424     if (ioctl(s, SIOCSIFDSTADDR, (caddr_t) &ifr) < 0) {
425         syslog(LOG_ERR, "ioctl(SIOCSIFDSTADDR): %m");
426         ret = 0;
427     }
428     if (m != 0) {
429         ((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr.s_addr = m;
430         syslog(LOG_INFO, "Setting interface mask to %s\n", ip_ntoa(m));
431         if (ioctl(s, SIOCSIFNETMASK, (caddr_t) &ifr) < 0) {
432             syslog(LOG_ERR, "ioctl(SIOCSIFNETMASK): %m");
433             ret = 0;
434         }
435     }
436     return ret;
437 }
438
439 /*
440  * cifaddr - Clear the interface IP addresses, and delete routes
441  * through the interface if possible.
442  */
443 int
444 cifaddr(u, o, h)
445 {
446     struct rtentry rt;
447
448     SET_SA_FAMILY(rt.rt_dst, AF_INET);
449     ((struct sockaddr_in *) &rt.rt_dst)->sin_addr.s_addr = h;
450     SET_SA_FAMILY(rt.rt_gateway, AF_INET);
451     ((struct sockaddr_in *) &rt.rt_gateway)->sin_addr.s_addr = o;
452     rt.rt_flags = RTF_HOST;
453     if (ioctl(s, SIOCDELRT, (caddr_t) &rt) < 0) {
454         syslog(LOG_ERR, "ioctl(SIOCDELRT): %m");
455         return 0;
456     }
457     return 1;
458 }
459
460 /*
461  * sifdefaultroute - assign a default route through the address given.
462  */
463 int
464 sifdefaultroute(u, g)
465 {
466     struct rtentry rt;
467
468     SET_SA_FAMILY(rt.rt_dst, AF_INET);
469     SET_SA_FAMILY(rt.rt_gateway, AF_INET);
470     ((struct sockaddr_in *) &rt.rt_gateway)->sin_addr.s_addr = g;
471     rt.rt_flags = RTF_GATEWAY;
472     if (ioctl(s, SIOCADDRT, &rt) < 0) {
473         syslog(LOG_ERR, "default route ioctl(SIOCADDRT): %m");
474         return 0;
475     }
476     return 1;
477 }
478
479 /*
480  * cifdefaultroute - delete a default route through the address given.
481  */
482 int
483 cifdefaultroute(u, g)
484 {
485     struct rtentry rt;
486
487     SET_SA_FAMILY(rt.rt_dst, AF_INET);
488     SET_SA_FAMILY(rt.rt_gateway, AF_INET);
489     ((struct sockaddr_in *) &rt.rt_gateway)->sin_addr.s_addr = g;
490     rt.rt_flags = RTF_GATEWAY;
491     if (ioctl(s, SIOCDELRT, &rt) < 0) {
492         syslog(LOG_ERR, "default route ioctl(SIOCDELRT): %m");
493         return 0;
494     }
495     return 1;
496 }
497
498 /*
499  * sifproxyarp - Make a proxy ARP entry for the peer.
500  */
501 int
502 sifproxyarp(unit, hisaddr)
503     int unit;
504     u_long hisaddr;
505 {
506     struct arpreq arpreq;
507
508     BZERO(&arpreq, sizeof(arpreq));
509
510     /*
511      * Get the hardware address of an interface on the same subnet
512      * as our local address.
513      */
514     if (!get_ether_addr(hisaddr, &arpreq.arp_ha)) {
515         syslog(LOG_WARNING, "Cannot determine ethernet address for proxy ARP");
516         return 0;
517     }
518
519     SET_SA_FAMILY(arpreq.arp_pa, AF_INET);
520     ((struct sockaddr_in *) &arpreq.arp_pa)->sin_addr.s_addr = hisaddr;
521     arpreq.arp_flags = ATF_PERM | ATF_PUBL;
522     if (ioctl(s, SIOCSARP, (caddr_t)&arpreq) < 0) {
523         syslog(LOG_ERR, "ioctl(SIOCSARP): %m");
524         return 0;
525     }
526
527     return 1;
528 }
529
530 /*
531  * cifproxyarp - Delete the proxy ARP entry for the peer.
532  */
533 int
534 cifproxyarp(unit, hisaddr)
535     int unit;
536     u_long hisaddr;
537 {
538     struct arpreq arpreq;
539
540     BZERO(&arpreq, sizeof(arpreq));
541     SET_SA_FAMILY(arpreq.arp_pa, AF_INET);
542     ((struct sockaddr_in *) &arpreq.arp_pa)->sin_addr.s_addr = hisaddr;
543     if (ioctl(s, SIOCDARP, (caddr_t)&arpreq) < 0) {
544         syslog(LOG_ERR, "ioctl(SIOCDARP): %m");
545         return 0;
546     }
547     return 1;
548 }
549
550 /*
551  * get_ether_addr - get the hardware address of an interface on the
552  * the same subnet as ipaddr.  Code borrowed from myetheraddr.c
553  * in the cslip-2.6 distribution, which is subject to the following
554  * copyright notice:
555  *
556  * Copyright (c) 1990, 1992 The Regents of the University of California.
557  * All rights reserved.
558  *
559  * Redistribution and use in source and binary forms, with or without
560  * modification, are permitted provided that: (1) source code distributions
561  * retain the above copyright notice and this paragraph in its entirety, (2)
562  * distributions including binary code include the above copyright notice and
563  * this paragraph in its entirety in the documentation or other materials
564  * provided with the distribution, and (3) all advertising materials mentioning
565  * features or use of this software display the following acknowledgement:
566  * ``This product includes software developed by the University of California,
567  * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
568  * the University nor the names of its contributors may be used to endorse
569  * or promote products derived from this software without specific prior
570  * written permission.
571  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
572  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
573  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
574  */
575
576 #include <fcntl.h>
577 #include <nlist.h>
578 #include <kvm.h>
579 #include <arpa/inet.h>
580
581 /* XXX SunOS 4.1 defines this and 3.5 doesn't... */
582 #ifdef _nlist_h
583 #define SUNOS4
584 #endif
585
586 #ifdef SUNOS4
587 #include <netinet/in_var.h>
588 #endif
589 #include <netinet/if_ether.h>
590
591 /* Cast a struct sockaddr to a structaddr_in */
592 #define SATOSIN(sa) ((struct sockaddr_in *)(sa))
593
594 /* Determine if "bits" is set in "flag" */
595 #define ALLSET(flag, bits) (((flag) & (bits)) == (bits))
596
597 static struct nlist nl[] = {
598 #define N_IFNET 0
599         { "_ifnet" },
600         0
601 };
602
603 static void kread();
604
605 int
606 get_ether_addr(ipaddr, hwaddr)
607     u_long ipaddr;
608     struct sockaddr *hwaddr;
609 {
610     register kvm_t *kd;
611     register struct ifnet *ifp;
612     register struct arpcom *ac;
613     struct arpcom arpcom;
614     struct in_addr *inp;
615 #ifdef SUNOS4
616     register struct ifaddr *ifa;
617     register struct in_ifaddr *in;
618     union {
619         struct ifaddr ifa;
620         struct in_ifaddr in;
621     } ifaddr;
622 #endif
623     u_long addr, mask;
624
625     /* Open kernel memory for reading */
626     kd = kvm_open(0, 0, 0, O_RDONLY, NULL);
627     if (kd == 0) {
628         syslog(LOG_ERR, "kvm_open: %m");
629         return 0;
630     }
631
632     /* Fetch namelist */
633     if (kvm_nlist(kd, nl) != 0) {
634         syslog(LOG_ERR, "kvm_nlist failed");
635         return 0;
636     }
637
638     ac = &arpcom;
639     ifp = &arpcom.ac_if;
640 #ifdef SUNOS4
641     ifa = &ifaddr.ifa;
642     in = &ifaddr.in;
643 #endif
644
645     if (kvm_read(kd, nl[N_IFNET].n_value, (char *)&addr, sizeof(addr))
646         != sizeof(addr)) {
647         syslog(LOG_ERR, "error reading ifnet addr");
648         return 0;
649     }
650     for ( ; addr; addr = (u_long)ifp->if_next) {
651         if (kvm_read(kd, addr, (char *)ac, sizeof(*ac)) != sizeof(*ac)) {
652             syslog(LOG_ERR, "error reading ifnet");
653             return 0;
654         }
655
656         /* Only look at configured, broadcast interfaces */
657         if (!ALLSET(ifp->if_flags, IFF_UP | IFF_BROADCAST))
658             continue;
659 #ifdef SUNOS4
660         /* This probably can't happen... */
661         if (ifp->if_addrlist == 0)
662             continue;
663 #endif
664
665         /* Get interface ip address */
666 #ifdef SUNOS4
667         if (kvm_read(kd, (u_long)ifp->if_addrlist, (char *)&ifaddr,
668                      sizeof(ifaddr)) != sizeof(ifaddr)) {
669             syslog(LOG_ERR, "error reading ifaddr");
670             return 0;
671         }
672         inp = &SATOSIN(&ifa->ifa_addr)->sin_addr;
673 #else
674         inp = &SATOSIN(&ifp->if_addr)->sin_addr;
675 #endif
676
677         /* Check if this interface on the right subnet */
678 #ifdef SUNOS4
679         mask = in->ia_subnetmask;
680 #else
681         mask = ifp->if_subnetmask;
682 #endif
683         if ((ipaddr & mask) != (inp->s_addr & mask))
684             continue;
685
686         /* Copy out the local ethernet address */
687         hwaddr->sa_family = AF_UNSPEC;
688         BCOPY((caddr_t) &arpcom.ac_enaddr, hwaddr->sa_data,
689               sizeof(arpcom.ac_enaddr));
690         return 1;               /* success! */
691     }
692
693     /* couldn't find one */
694     return 0;
695 }