Subject: atalk patch
To: None <tech-net@netbsd.org>
From: Manuel Bouyer <bouyer@antioche.lip6.fr>
List: tech-net
Date: 07/20/1999 19:56:46
--17pEHd4RhPHOinZp
Content-Type: text/plain; charset=us-ascii

Hi,
unless there is serious complain, I'll commit the attached patch next
thursday. It's needed to get netatalk work properly on a network
with routers and blocks of addresses.
In initial discution about this, the only objection was that this add a
dependency to netatalk in net/if.c, which previsously did'nt have any.
Now there are also a dependency to INET6, so I think the argument is not
valid any more.

I have some idea to solve this problem on a more general basis (i.e. avoid
#ifdef FOO in ethersubr.h and other similar files as well) which should
allow us to load protocols as module (currently not possible because of
the entry needed in each network layer module).
I started playing with this, but it'll take a long time to have this done
rigth.

--
Manuel Bouyer, LIP6, Universite Paris VI.           Manuel.Bouyer@lip6.fr
--

--17pEHd4RhPHOinZp
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="atalk.patch"

Index: if.c
===================================================================
RCS file: /cvsroot/syssrc/sys/net/if.c,v
retrieving revision 1.48
diff -u -r1.48 if.c
--- if.c	1998/12/10 15:10:48	1.48
+++ if.c	1999/06/29 13:12:08
@@ -38,6 +38,7 @@
 #include "opt_compat_linux.h"
 #include "opt_compat_svr4.h"
 #include "opt_compat_43.h"
+#include "opt_atalk.h"
 
 #include <sys/param.h>
 #include <sys/mbuf.h>
@@ -53,6 +54,9 @@
 #include <net/if_dl.h>
 #include <net/if_types.h>
 #include <net/radix.h>
+#ifdef NETATALK
+#include <netatalk/at.h>
+#endif
 
 int	ifqmaxlen = IFQ_MAXLEN;
 void	if_slowtimo __P((void *arg));
@@ -211,6 +215,20 @@
 			if (ifa->ifa_addr->sa_family != af ||
 			    ifa->ifa_netmask == 0)
 				next: continue;
+#ifdef NETATALK
+			if (af == AF_APPLETALK) {
+				struct sockaddr_at *sat =
+				    (struct sockaddr_at *)addr;
+				struct sockaddr_at *sat_if = 
+				    (struct sockaddr_at *)ifa->ifa_addr;
+				struct netrange *nr =
+				    (struct netrange *) (sat_if->sat_zero);
+				if ((nr->nr_phase == 2)
+				    && (nr->nr_firstnet <= sat->sat_addr.s_net)
+				    && (nr->nr_lastnet >= sat->sat_addr.s_net))
+					return (ifa);
+			}
+#endif
 			cp = addr_data;
 			cp2 = ifa->ifa_addr->sa_data;
 			cp3 = ifa->ifa_netmask->sa_data;

--17pEHd4RhPHOinZp--