2 * Copyright (c) 1990,1991 Regents of The University of Michigan.
5 * $DragonFly: src/sys/netproto/atalk/at_control.c,v 1.3 2003/07/19 21:14:44 dillon Exp $
11 #include <sys/sockio.h>
12 #include <sys/malloc.h>
13 #include <sys/kernel.h>
14 #include <sys/socket.h>
16 #include <net/route.h>
17 #include <netinet/in.h>
19 #include <netinet/if_ether.h>
21 #include <netatalk/at.h>
22 #include <netatalk/at_var.h>
23 #include <netatalk/at_extern.h>
25 struct at_ifaddr *at_ifaddr;
27 static int aa_dorangeroute(struct ifaddr *ifa,
28 u_int first, u_int last, int cmd);
29 static int aa_addsingleroute(struct ifaddr *ifa,
30 struct at_addr *addr, struct at_addr *mask);
31 static int aa_delsingleroute(struct ifaddr *ifa,
32 struct at_addr *addr, struct at_addr *mask);
33 static int aa_dosingleroute(struct ifaddr *ifa, struct at_addr *addr,
34 struct at_addr *mask, int cmd, int flags);
35 static int at_scrub( struct ifnet *ifp, struct at_ifaddr *aa );
36 static int at_ifinit( struct ifnet *ifp, struct at_ifaddr *aa,
37 struct sockaddr_at *sat );
38 static int aa_claim_addr(struct ifaddr *ifa, struct sockaddr *gw);
40 # define sateqaddr(a,b) ((a)->sat_len == (b)->sat_len && \
41 (a)->sat_family == (b)->sat_family && \
42 (a)->sat_addr.s_net == (b)->sat_addr.s_net && \
43 (a)->sat_addr.s_node == (b)->sat_addr.s_node )
46 at_control(struct socket *so, u_long cmd, caddr_t data,
47 struct ifnet *ifp, struct proc *p )
49 struct ifreq *ifr = (struct ifreq *)data;
50 struct sockaddr_at *sat;
52 struct at_aliasreq *ifra = (struct at_aliasreq *)data;
53 struct at_ifaddr *aa0;
54 struct at_ifaddr *aa = 0;
55 struct ifaddr *ifa, *ifa0;
58 * If we have an ifp, then find the matching at_ifaddr if it exists
61 for ( aa = at_ifaddr; aa; aa = aa->aa_next ) {
62 if ( aa->aa_ifp == ifp ) break;
67 * In this first switch table we are basically getting ready for
68 * the second one, by getting the atalk-specific things set up
69 * so that they start to look more similar to other protocols etc.
76 * If we have an appletalk sockaddr, scan forward of where
77 * we are now on the at_ifaddr list to find one with a matching
78 * address on this interface.
79 * This may leave aa pointing to the first address on the
82 if ( ifra->ifra_addr.sat_family == AF_APPLETALK ) {
83 for ( ; aa; aa = aa->aa_next ) {
84 if ( aa->aa_ifp == ifp &&
85 sateqaddr( &aa->aa_addr, &ifra->ifra_addr )) {
91 * If we a retrying to delete an addres but didn't find such,
92 * then rewurn with an error
94 if ( cmd == SIOCDIFADDR && aa == 0 ) {
95 return( EADDRNOTAVAIL );
101 * If we are not superuser, then we don't get to do these ops.
106 sat = satosat( &ifr->ifr_addr );
107 nr = (struct netrange *)sat->sat_zero;
108 if ( nr->nr_phase == 1 ) {
110 * Look for a phase 1 address on this interface.
111 * This may leave aa pointing to the first address on the
114 for ( ; aa; aa = aa->aa_next ) {
115 if ( aa->aa_ifp == ifp &&
116 ( aa->aa_flags & AFA_PHASE2 ) == 0 ) {
120 } else { /* default to phase 2 */
122 * Look for a phase 2 address on this interface.
123 * This may leave aa pointing to the first address on the
126 for ( ; aa; aa = aa->aa_next ) {
127 if ( aa->aa_ifp == ifp && ( aa->aa_flags & AFA_PHASE2 )) {
134 panic( "at_control" );
137 * If we failed to find an existing at_ifaddr entry, then we
138 * allocate a fresh one.
140 if ( aa == (struct at_ifaddr *) 0 ) {
141 aa0 = malloc(sizeof(struct at_ifaddr), M_IFADDR, M_WAITOK);
142 bzero(aa0, sizeof(struct at_ifaddr));
143 if (( aa = at_ifaddr ) != NULL ) {
145 * Don't let the loopback be first, since the first
146 * address is the machine's default address for
148 * If it is, stick ourself in front, otherwise
149 * go to the back of the list.
151 if ( at_ifaddr->aa_ifp->if_flags & IFF_LOOPBACK ) {
153 aa->aa_next = at_ifaddr;
156 for ( ; aa->aa_next; aa = aa->aa_next )
164 * Don't Add a reference for the aa itself!
165 * I fell into this trap. IFAFREE tests for <=0
166 * not <= 1 like RTFREE
168 /* aa->aa_ifa.ifa_refcnt++; DON'T DO THIS!! */
172 * Find the end of the interface's addresses
173 * and link our new one on the end
175 ifa = (struct ifaddr *)aa;
176 TAILQ_INSERT_TAIL(&ifp->if_addrhead, ifa, ifa_link);
179 * Add a reference for the linking into the ifp_if_addrlist.
184 * As the at_ifaddr contains the actual sockaddrs,
185 * and the ifaddr itself, link them al together correctly.
187 ifa->ifa_addr = (struct sockaddr *)&aa->aa_addr;
188 ifa->ifa_dstaddr = (struct sockaddr *)&aa->aa_addr;
189 ifa->ifa_netmask = (struct sockaddr *)&aa->aa_netmask;
192 * Set/clear the phase 2 bit.
194 if ( nr->nr_phase == 1 ) {
195 aa->aa_flags &= ~AFA_PHASE2;
197 aa->aa_flags |= AFA_PHASE2;
201 * and link it all together
206 * If we DID find one then we clobber any routes dependent on it..
213 sat = satosat( &ifr->ifr_addr );
214 nr = (struct netrange *)sat->sat_zero;
215 if ( nr->nr_phase == 1 ) {
217 * If the request is specifying phase 1, then
218 * only look at a phase one address
220 for ( ; aa; aa = aa->aa_next ) {
221 if ( aa->aa_ifp == ifp &&
222 ( aa->aa_flags & AFA_PHASE2 ) == 0 ) {
230 for ( ; aa; aa = aa->aa_next ) {
231 if ( aa->aa_ifp == ifp && ( aa->aa_flags & AFA_PHASE2 )) {
237 if ( aa == (struct at_ifaddr *) 0 )
238 return( EADDRNOTAVAIL );
243 * By the time this switch is run we should be able to assume that
244 * the "aa" pointer is valid when needed.
250 * copy the contents of the sockaddr blindly.
252 sat = (struct sockaddr_at *)&ifr->ifr_addr;
256 * and do some cleanups
258 ((struct netrange *)&sat->sat_zero)->nr_phase
259 = (aa->aa_flags & AFA_PHASE2) ? 2 : 1;
260 ((struct netrange *)&sat->sat_zero)->nr_firstnet = aa->aa_firstnet;
261 ((struct netrange *)&sat->sat_zero)->nr_lastnet = aa->aa_lastnet;
265 return( at_ifinit( ifp, aa, (struct sockaddr_at *)&ifr->ifr_addr ));
268 if ( sateqaddr( &ifra->ifra_addr, &aa->aa_addr )) {
271 return( at_ifinit( ifp, aa, (struct sockaddr_at *)&ifr->ifr_addr ));
275 * scrub all routes.. didn't we just DO this? XXX yes, del it
280 * remove the ifaddr from the interface
282 ifa0 = (struct ifaddr *)aa;
283 TAILQ_REMOVE(&ifp->if_addrhead, ifa0, ifa_link);
286 * refs goes from 1->0 if no external refs. note..
287 * This will not free it ... looks for -1.
292 * Now remove the at_ifaddr from the parallel structure
293 * as well, or we'd be in deep trouble
296 if ( aa0 == ( aa = at_ifaddr )) {
297 at_ifaddr = aa->aa_next;
299 while ( aa->aa_next && ( aa->aa_next != aa0 )) {
304 * if we found it, remove it, otherwise we screwed up.
307 aa->aa_next = aa0->aa_next;
309 panic( "at_control" );
314 * Now dump the memory we were using.
315 * Decrement the reference count.
316 * This should probably be the last reference
317 * as the count will go from 0 to -1.
318 * (unless there is still a route referencing this)
324 if ( ifp == 0 || ifp->if_ioctl == 0 )
325 return( EOPNOTSUPP );
326 return( (*ifp->if_ioctl)( ifp, cmd, data ));
332 * Given an interface and an at_ifaddr (supposedly on that interface)
333 * remove any routes that depend on this.
334 * Why ifp is needed I'm not sure,
335 * as aa->at_ifaddr.ifa_ifp should be the same.
340 struct at_ifaddr *aa;
344 if ( aa->aa_flags & AFA_ROUTE ) {
345 if (ifp->if_flags & IFF_LOOPBACK) {
346 if ((error = aa_delsingleroute(&aa->aa_ifa,
347 &aa->aa_addr.sat_addr,
348 &aa->aa_netmask.sat_addr)) != 0) {
351 } else if (ifp->if_flags & IFF_POINTOPOINT) {
352 if ((error = rtinit( &aa->aa_ifa, RTM_DELETE, RTF_HOST)) != 0)
354 } else if (ifp->if_flags & IFF_BROADCAST) {
355 error = aa_dorangeroute(&aa->aa_ifa,
356 ntohs(aa->aa_firstnet),
357 ntohs(aa->aa_lastnet),
360 aa->aa_ifa.ifa_flags &= ~IFA_ROUTE;
361 aa->aa_flags &= ~AFA_ROUTE;
367 * given an at_ifaddr,a sockaddr_at and an ifp,
368 * bang them all together at high speed and see what happens
371 at_ifinit( ifp, aa, sat )
373 struct at_ifaddr *aa;
374 struct sockaddr_at *sat;
376 struct netrange nr, onr;
377 struct sockaddr_at oldaddr;
378 int s = splimp(), error = 0, i, j;
379 int netinc, nodeinc, nnets;
383 * save the old addresses in the at_ifaddr just in case we need them.
385 oldaddr = aa->aa_addr;
386 onr.nr_firstnet = aa->aa_firstnet;
387 onr.nr_lastnet = aa->aa_lastnet;
390 * take the address supplied as an argument, and add it to the
391 * at_ifnet (also given). Remember ing to update
392 * those parts of the at_ifaddr that need special processing
394 bzero( AA_SAT( aa ), sizeof( struct sockaddr_at ));
395 bcopy( sat->sat_zero, &nr, sizeof( struct netrange ));
396 bcopy( sat->sat_zero, AA_SAT( aa )->sat_zero, sizeof( struct netrange ));
397 nnets = ntohs( nr.nr_lastnet ) - ntohs( nr.nr_firstnet ) + 1;
398 aa->aa_firstnet = nr.nr_firstnet;
399 aa->aa_lastnet = nr.nr_lastnet;
403 printf("at_ifinit: %s: %u.%u range %u-%u phase %d\n",
405 ntohs(sat->sat_addr.s_net), sat->sat_addr.s_node,
406 ntohs(aa->aa_firstnet), ntohs(aa->aa_lastnet),
407 (aa->aa_flags & AFA_PHASE2) ? 2 : 1);
411 * We could eliminate the need for a second phase 1 probe (post
412 * autoconf) if we check whether we're resetting the node. Note
413 * that phase 1 probes use only nodes, not net.node pairs. Under
414 * phase 2, both the net and node must be the same.
416 if ( ifp->if_flags & IFF_LOOPBACK ) {
417 AA_SAT( aa )->sat_len = sat->sat_len;
418 AA_SAT( aa )->sat_family = AF_APPLETALK;
419 AA_SAT( aa )->sat_addr.s_net = sat->sat_addr.s_net;
420 AA_SAT( aa )->sat_addr.s_node = sat->sat_addr.s_node;
422 } else if ( fp->if_flags & IFF_POINTOPOINT) {
425 * we'd have to copy the dstaddr field over from the sat
426 * but it's not clear that it would contain the right info..
431 * We are a normal (probably ethernet) interface.
432 * apply the new address to the interface structures etc.
433 * We will probe this address on the net first, before
434 * applying it to ensure that it is free.. If it is not, then
435 * we will try a number of other randomly generated addresses
436 * in this net and then increment the net. etc.etc. until
437 * we find an unused address.
439 aa->aa_flags |= AFA_PROBING; /* if not loopback we Must probe? */
440 AA_SAT( aa )->sat_len = sizeof(struct sockaddr_at);
441 AA_SAT( aa )->sat_family = AF_APPLETALK;
442 if ( aa->aa_flags & AFA_PHASE2 ) {
443 if ( sat->sat_addr.s_net == ATADDR_ANYNET ) {
445 * If we are phase 2, and the net was not specified
446 * then we select a random net within the supplied netrange.
447 * XXX use /dev/random?
450 net = ntohs( nr.nr_firstnet ) + time_second % ( nnets - 1 );
452 net = ntohs( nr.nr_firstnet );
456 * if a net was supplied, then check that it is within
457 * the netrange. If it is not then replace the old values
458 * and return an error
460 if ( ntohs( sat->sat_addr.s_net ) < ntohs( nr.nr_firstnet ) ||
461 ntohs( sat->sat_addr.s_net ) > ntohs( nr.nr_lastnet )) {
462 aa->aa_addr = oldaddr;
463 aa->aa_firstnet = onr.nr_firstnet;
464 aa->aa_lastnet = onr.nr_lastnet;
469 * otherwise just use the new net number..
471 net = ntohs( sat->sat_addr.s_net );
475 * we must be phase one, so just use whatever we were given.
476 * I guess it really isn't going to be used... RIGHT?
478 net = ntohs( sat->sat_addr.s_net );
482 * set the node part of the address into the ifaddr.
483 * If it's not specified, be random about it...
484 * XXX use /dev/random?
486 if ( sat->sat_addr.s_node == ATADDR_ANYNODE ) {
487 AA_SAT( aa )->sat_addr.s_node = time_second;
489 AA_SAT( aa )->sat_addr.s_node = sat->sat_addr.s_node;
495 AA_SAT( aa )->sat_range.r_netrange.nr_phase
496 = ((aa->aa_flags & AFA_PHASE2) ? 2:1);
499 * step through the nets in the range
500 * starting at the (possibly random) start point.
502 for ( i = nnets, netinc = 1; i > 0; net = ntohs( nr.nr_firstnet ) +
503 (( net - ntohs( nr.nr_firstnet ) + netinc ) % nnets ), i-- ) {
504 AA_SAT( aa )->sat_addr.s_net = htons( net );
507 * using a rather strange stepping method,
508 * stagger through the possible node addresses
509 * Once again, starting at the (possibly random)
510 * initial node address.
512 for ( j = 0, nodeinc = time_second | 1; j < 256;
513 j++, AA_SAT( aa )->sat_addr.s_node += nodeinc ) {
514 if ( AA_SAT( aa )->sat_addr.s_node > 253 ||
515 AA_SAT( aa )->sat_addr.s_node < 1 ) {
521 * start off the probes as an asynchronous activity.
522 * though why wait 200mSec?
524 aa->aa_ch = timeout( aarpprobe, (caddr_t)ifp, hz / 5 );
525 if ( tsleep( aa, PCATCH, "at_ifinit", 0 )) {
527 * theoretically we shouldn't time out here
528 * so if we returned with an error..
530 printf( "at_ifinit: why did this happen?!\n" );
531 aa->aa_addr = oldaddr;
532 aa->aa_firstnet = onr.nr_firstnet;
533 aa->aa_lastnet = onr.nr_lastnet;
539 * The async activity should have woken us up.
540 * We need to see if it was successful in finding
541 * a free spot, or if we need to iterate to the next
544 if (( aa->aa_flags & AFA_PROBING ) == 0 ) {
550 * of course we need to break out through two loops...
552 if (( aa->aa_flags & AFA_PROBING ) == 0 ) {
555 /* reset node for next network */
556 AA_SAT( aa )->sat_addr.s_node = time_second;
560 * if we are still trying to probe, then we have finished all
561 * the possible addresses, so we need to give up
564 if ( aa->aa_flags & AFA_PROBING ) {
565 aa->aa_addr = oldaddr;
566 aa->aa_firstnet = onr.nr_firstnet;
567 aa->aa_lastnet = onr.nr_lastnet;
569 return( EADDRINUSE );
574 * Now that we have selected an address, we need to tell the interface
575 * about it, just in case it needs to adjust something.
577 if ( ifp->if_ioctl &&
578 ( error = (*ifp->if_ioctl)( ifp, SIOCSIFADDR, (caddr_t)aa ))) {
580 * of course this could mean that it objects violently
581 * so if it does, we back out again..
583 aa->aa_addr = oldaddr;
584 aa->aa_firstnet = onr.nr_firstnet;
585 aa->aa_lastnet = onr.nr_lastnet;
591 * set up the netmask part of the at_ifaddr
592 * and point the appropriate pointer in the ifaddr to it.
593 * probably pointless, but what the heck.. XXX
595 bzero(&aa->aa_netmask, sizeof(aa->aa_netmask));
596 aa->aa_netmask.sat_len = sizeof(struct sockaddr_at);
597 aa->aa_netmask.sat_family = AF_APPLETALK;
598 aa->aa_netmask.sat_addr.s_net = 0xffff;
599 aa->aa_netmask.sat_addr.s_node = 0;
600 aa->aa_ifa.ifa_netmask =(struct sockaddr *) &(aa->aa_netmask); /* XXX */
603 * Initialize broadcast (or remote p2p) address
605 bzero(&aa->aa_broadaddr, sizeof(aa->aa_broadaddr));
606 aa->aa_broadaddr.sat_len = sizeof(struct sockaddr_at);
607 aa->aa_broadaddr.sat_family = AF_APPLETALK;
609 aa->aa_ifa.ifa_metric = ifp->if_metric;
610 if (ifp->if_flags & IFF_BROADCAST) {
611 aa->aa_broadaddr.sat_addr.s_net = htons(0);
612 aa->aa_broadaddr.sat_addr.s_node = 0xff;
613 aa->aa_ifa.ifa_broadaddr = (struct sockaddr *) &aa->aa_broadaddr;
614 /* add the range of routes needed */
615 error = aa_dorangeroute(&aa->aa_ifa,
616 ntohs(aa->aa_firstnet), ntohs(aa->aa_lastnet), RTM_ADD );
618 else if (ifp->if_flags & IFF_POINTOPOINT) {
619 struct at_addr rtaddr, rtmask;
621 bzero(&rtaddr, sizeof(rtaddr));
622 bzero(&rtmask, sizeof(rtmask));
623 /* fill in the far end if we know it here XXX */
624 aa->aa_ifa.ifa_dstaddr = (struct sockaddr *) &aa->aa_dstaddr;
625 error = aa_addsingleroute(&aa->aa_ifa, &rtaddr, &rtmask);
627 else if ( ifp->if_flags & IFF_LOOPBACK ) {
628 struct at_addr rtaddr, rtmask;
630 bzero(&rtaddr, sizeof(rtaddr));
631 bzero(&rtmask, sizeof(rtmask));
632 rtaddr.s_net = AA_SAT( aa )->sat_addr.s_net;
633 rtaddr.s_node = AA_SAT( aa )->sat_addr.s_node;
634 rtmask.s_net = 0xffff;
635 rtmask.s_node = 0x0; /* XXX should not be so.. should be HOST route */
636 error = aa_addsingleroute(&aa->aa_ifa, &rtaddr, &rtmask);
641 * set the address of our "check if this addr is ours" routine.
643 aa->aa_ifa.ifa_claim_addr = aa_claim_addr;
646 * of course if we can't add these routes we back out, but it's getting
651 aa->aa_addr = oldaddr;
652 aa->aa_firstnet = onr.nr_firstnet;
653 aa->aa_lastnet = onr.nr_lastnet;
659 * note that the address has a route associated with it....
661 aa->aa_ifa.ifa_flags |= IFA_ROUTE;
662 aa->aa_flags |= AFA_ROUTE;
668 * check whether a given address is a broadcast address for us..
672 struct sockaddr_at *sat;
674 struct at_ifaddr *aa;
677 * If the node is not right, it can't be a broadcast
679 if ( sat->sat_addr.s_node != ATADDR_BCAST ) {
684 * If the node was right then if the net is right, it's a broadcast
686 if ( sat->sat_addr.s_net == ATADDR_ANYNET ) {
691 * failing that, if the net is one we have, it's a broadcast as well.
693 for ( aa = at_ifaddr; aa; aa = aa->aa_next ) {
694 if (( aa->aa_ifp->if_flags & IFF_BROADCAST )
695 && ( ntohs( sat->sat_addr.s_net ) >= ntohs( aa->aa_firstnet )
696 && ntohs( sat->sat_addr.s_net ) <= ntohs( aa->aa_lastnet ))) {
706 * Add a route for a range of networks from bot to top - 1.
709 * Split the range into two subranges such that the middle
710 * of the two ranges is the point where the highest bit of difference
711 * between the two addresses makes its transition.
712 * Each of the upper and lower ranges might not exist, or might be
713 * representable by 1 or more netmasks. In addition, if both
714 * ranges can be represented by the same netmask, then they can be merged
715 * by using the next higher netmask..
719 aa_dorangeroute(struct ifaddr *ifa, u_int bot, u_int top, int cmd)
727 * slight sanity check
729 if (bot > top) return (EINVAL);
734 * just start out with the lowest boundary
735 * and keep extending the mask till it's too big.
740 while ((( bot & ~mask1) >= bot)
741 && (( bot | mask1) <= top)) {
746 mask.s_net = htons(~mask1);
747 addr.s_net = htons(bot);
749 error = aa_addsingleroute(ifa,&addr,&mask);
755 error = aa_delsingleroute(ifa,&addr,&mask);
757 bot = (bot | mask1) + 1;
763 aa_addsingleroute(struct ifaddr *ifa,
764 struct at_addr *addr, struct at_addr *mask)
769 printf("aa_addsingleroute: %x.%x mask %x.%x ...\n",
770 ntohs(addr->s_net), addr->s_node,
771 ntohs(mask->s_net), mask->s_node);
774 error = aa_dosingleroute(ifa, addr, mask, RTM_ADD, RTF_UP);
776 printf("aa_addsingleroute: error %d\n", error);
781 aa_delsingleroute(struct ifaddr *ifa,
782 struct at_addr *addr, struct at_addr *mask)
786 error = aa_dosingleroute(ifa, addr, mask, RTM_DELETE, 0);
788 printf("aa_delsingleroute: error %d\n", error);
793 aa_dosingleroute(struct ifaddr *ifa,
794 struct at_addr *at_addr, struct at_addr *at_mask, int cmd, int flags)
796 struct sockaddr_at addr, mask;
798 bzero(&addr, sizeof(addr));
799 bzero(&mask, sizeof(mask));
800 addr.sat_family = AF_APPLETALK;
801 addr.sat_len = sizeof(struct sockaddr_at);
802 addr.sat_addr.s_net = at_addr->s_net;
803 addr.sat_addr.s_node = at_addr->s_node;
804 mask.sat_family = AF_APPLETALK;
805 mask.sat_len = sizeof(struct sockaddr_at);
806 mask.sat_addr.s_net = at_mask->s_net;
807 mask.sat_addr.s_node = at_mask->s_node;
810 return(rtrequest(cmd, (struct sockaddr *) &addr,
811 (flags & RTF_HOST)?(ifa->ifa_dstaddr):(ifa->ifa_addr),
812 (struct sockaddr *) &mask, flags, NULL));
820 struct at_ifaddr *aa;
824 while ( aa = at_ifaddr ) {
827 at_ifaddr = aa->aa_next;
828 if (( ifa = ifp->if_addrlist ) == (struct ifaddr *)aa ) {
829 ifp->if_addrlist = ifa->ifa_next;
831 while ( ifa->ifa_next &&
832 ( ifa->ifa_next != (struct ifaddr *)aa )) {
835 if ( ifa->ifa_next ) {
836 ifa->ifa_next = ((struct ifaddr *)aa)->ifa_next;
847 aa_claim_addr(struct ifaddr *ifa, struct sockaddr *gw0)
849 struct sockaddr_at *addr = (struct sockaddr_at *)ifa->ifa_addr;
850 struct sockaddr_at *gw = (struct sockaddr_at *)gw0;
852 switch (gw->sat_range.r_netrange.nr_phase) {
854 if(addr->sat_range.r_netrange.nr_phase == 1)
859 * if it's our net (including 0),
860 * or netranges are valid, and we are in the range,
863 if ((addr->sat_addr.s_net == gw->sat_addr.s_net)
864 || ((addr->sat_range.r_netrange.nr_lastnet)
865 && (ntohs(gw->sat_addr.s_net)
866 >= ntohs(addr->sat_range.r_netrange.nr_firstnet ))
867 && (ntohs(gw->sat_addr.s_net)
868 <= ntohs(addr->sat_range.r_netrange.nr_lastnet )))) {
873 printf("atalk: bad phase\n");