| version 1.242.2.4, 2007/04/15 16:04:00 |
version 1.242.2.5, 2007/05/07 10:55:59 |
|
|
| struct in_ifaddr * |
struct in_ifaddr * |
| ip_rtaddr(struct in_addr dst) |
ip_rtaddr(struct in_addr dst) |
| { |
{ |
| if (!in_hosteq(dst, satocsin(rtcache_getdst(&ipforward_rt))->sin_addr)) |
struct rtentry *rt; |
| rtcache_free(&ipforward_rt); |
union { |
| else |
struct sockaddr dst; |
| rtcache_check(&ipforward_rt); |
struct sockaddr_in dst4; |
| |
} u; |
| if (ipforward_rt.ro_rt == NULL) { |
|
| struct sockaddr_in *sin = satosin(&ipforward_rt.ro_dst); |
sockaddr_in_init(&u.dst4, &dst, 0); |
| |
|
| sin->sin_family = AF_INET; |
if ((rt = rtcache_lookup(&ipforward_rt, &u.dst)) == NULL) |
| sin->sin_len = sizeof(*sin); |
return NULL; |
| sin->sin_addr = dst; |
|
| |
return ifatoia(rt->rt_ifa); |
| rtcache_init(&ipforward_rt); |
|
| if (ipforward_rt.ro_rt == NULL) |
|
| return NULL; |
|
| } |
|
| return ifatoia(ipforward_rt.ro_rt->rt_ifa); |
|
| } |
} |
| |
|
| /* |
/* |
| Line 1841 ip_forward(struct mbuf *m, int srcrt) |
|
| Line 1836 ip_forward(struct mbuf *m, int srcrt) |
|
| int error, type = 0, code = 0, destmtu = 0; |
int error, type = 0, code = 0, destmtu = 0; |
| struct mbuf *mcopy; |
struct mbuf *mcopy; |
| n_long dest; |
n_long dest; |
| |
union { |
| |
struct sockaddr dst; |
| |
struct sockaddr_in dst4; |
| |
} u; |
| |
|
| /* |
/* |
| * We are now in the output path. |
* We are now in the output path. |
| Line 1869 ip_forward(struct mbuf *m, int srcrt) |
|
| Line 1868 ip_forward(struct mbuf *m, int srcrt) |
|
| return; |
return; |
| } |
} |
| |
|
| if (!in_hosteq(ip->ip_dst, |
sockaddr_in_init(&u.dst4, &ip->ip_dst, 0); |
| satocsin(rtcache_getdst(&ipforward_rt))->sin_addr)) |
if ((rt = rtcache_lookup(&ipforward_rt, &u.dst)) == NULL) { |
| rtcache_free(&ipforward_rt); |
icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_NET, dest, 0); |
| else |
return; |
| rtcache_check(&ipforward_rt); |
|
| if (ipforward_rt.ro_rt == NULL) { |
|
| struct sockaddr_in *sin = satosin(&ipforward_rt.ro_dst); |
|
| |
|
| sin->sin_family = AF_INET; |
|
| sin->sin_len = sizeof(*sin); |
|
| sin->sin_addr = ip->ip_dst; |
|
| |
|
| rtcache_init(&ipforward_rt); |
|
| if (ipforward_rt.ro_rt == NULL) { |
|
| icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_NET, dest, 0); |
|
| return; |
|
| } |
|
| } |
} |
| rt = ipforward_rt.ro_rt; |
|
| |
|
| /* |
/* |
| * Save at most 68 bytes of the packet in case |
* Save at most 68 bytes of the packet in case |