*
* @APPLE_LICENSE_HEADER_START@
*
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License"). You may not use this file except in compliance with the
- * License. Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
*
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ *
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#include <netinet/in.h>
#include <netinet/ip_mroute.h>
+#include <net/if_dl.h>
+
#define SA(p) ((struct sockaddr *)(p))
struct route_cb route_cb;
struct sockaddr *, struct sockaddr *));
static void rtable_init __P((void **));
+__private_extern__ u_long route_generation = 0;
+extern int use_routegenid;
+
+
static void
rtable_init(table)
void **table;
splx(s);
}
ro->ro_rt = rtalloc1(&ro->ro_dst, 1, ignore);
+ if (ro->ro_rt)
+ ro->ro_rt->generation_id = route_generation;
}
/*
{
/*
* find the tree for that address family
+ * Note: in the case of igmp packets, there might not be an rnh
*/
register struct radix_node_head *rnh =
rt_tables[rt_key(rt)->sa_family];
- if (rt == 0 || rnh == 0)
+ if (rt == 0)
panic("rtfree");
/*
* and there is a close function defined, call the close function
*/
rt->rt_refcnt--;
- if(rnh->rnh_close && rt->rt_refcnt == 0) {
+ if(rnh && rnh->rnh_close && rt->rt_refcnt == 0) {
rnh->rnh_close((struct radix_node *)rt, rnh);
}
ifaref(ifa);
rt->rt_ifa = ifa;
rt->rt_ifp = ifa->ifa_ifp;
-#ifdef __APPLE__
- rt->rt_dlt = ifa->ifa_dlt; /* dl_tag */
-#endif
+
/* XXX mtu manipulation will be done in rnh_addaddr -- itojun */
rn = rnh->rnh_addaddr((caddr_t)ndst, (caddr_t)netmask,
int dlen = ROUNDUP(dst->sa_len), glen = ROUNDUP(gate->sa_len);
register struct rtentry *rt = rt0;
struct radix_node_head *rnh = rt_tables[dst->sa_family];
-
+ extern void kdp_set_gateway_mac (void *gatewaymac);
/*
* A host route with the destination equal to the gateway
* will interfere with keeping LLINFO in the routing
rt->rt_gwroute = 0;
return EDQUOT; /* failure */
}
+ /* Tell the kernel debugger about the new default gateway */
+ if ((AF_INET == rt->rt_gateway->sa_family) &&
+ rt->rt_gwroute && rt->rt_gwroute->rt_gateway &&
+ (AF_LINK == rt->rt_gwroute->rt_gateway->sa_family)) {
+ kdp_set_gateway_mac(((struct sockaddr_dl *)rt0->rt_gwroute->rt_gateway)->sdl_data);
+ }
}
/*
* notify any listenning routing agents of the change
*/
rt_newaddrmsg(cmd, ifa, error, nrt);
+ if (use_routegenid)
+ route_generation++;
if (rt->rt_refcnt <= 0) {
rt->rt_refcnt++; /* need a 1->0 transition to free */
rtfree(rt);
* we are adding.
*/
rt->rt_ifp = ifa->ifa_ifp;
-#ifdef __APPLE__
- rt->rt_dlt = ifa->ifa_dlt; /* dl_tag */
-#endif
rt->rt_rmx.rmx_mtu = ifa->ifa_ifp->if_mtu; /*XXX*/
/*
* Now ask the protocol to check if it needs
* notify any listenning routing agents of the change
*/
rt_newaddrmsg(cmd, ifa, error, nrt);
+ if (use_routegenid)
+ route_generation++;
}
return (error);
}