version 1.231.2.1, 2006/10/22 06:07:28 |
version 1.231.2.2, 2006/12/10 07:19:10 |
Line 1679 ip_rtaddr(struct in_addr dst) |
|
Line 1679 ip_rtaddr(struct in_addr dst) |
|
|
|
sin = satosin(&ipforward_rt.ro_dst); |
sin = satosin(&ipforward_rt.ro_dst); |
|
|
if (ipforward_rt.ro_rt == 0 || !in_hosteq(dst, sin->sin_addr)) { |
if (ipforward_rt.ro_rt == NULL || !in_hosteq(dst, sin->sin_addr)) { |
if (ipforward_rt.ro_rt) { |
if (ipforward_rt.ro_rt != NULL) |
RTFREE(ipforward_rt.ro_rt); |
rtflush(&ipforward_rt); |
ipforward_rt.ro_rt = 0; |
|
} |
|
sin->sin_family = AF_INET; |
sin->sin_family = AF_INET; |
sin->sin_len = sizeof(*sin); |
sin->sin_len = sizeof(*sin); |
sin->sin_addr = dst; |
sin->sin_addr = dst; |
|
|
rtalloc(&ipforward_rt); |
rtalloc(&ipforward_rt); |
} |
} |
if (ipforward_rt.ro_rt == 0) |
if (ipforward_rt.ro_rt == NULL) |
return ((struct in_ifaddr *)0); |
return NULL; |
return (ifatoia(ipforward_rt.ro_rt->rt_ifa)); |
return ifatoia(ipforward_rt.ro_rt->rt_ifa); |
} |
} |
|
|
/* |
/* |
Line 1728 ip_srcroute(void) |
|
Line 1726 ip_srcroute(void) |
|
struct mbuf *m; |
struct mbuf *m; |
|
|
if (ip_nhops == 0) |
if (ip_nhops == 0) |
return ((struct mbuf *)0); |
return NULL; |
m = m_get(M_DONTWAIT, MT_SOOPTS); |
m = m_get(M_DONTWAIT, MT_SOOPTS); |
if (m == 0) |
if (m == 0) |
return ((struct mbuf *)0); |
return NULL; |
|
|
MCLAIM(m, &inetdomain.dom_mowner); |
MCLAIM(m, &inetdomain.dom_mowner); |
#define OPTSIZ (sizeof(ip_srcrt.nop) + sizeof(ip_srcrt.srcopt)) |
#define OPTSIZ (sizeof(ip_srcrt.nop) + sizeof(ip_srcrt.srcopt)) |
Line 1794 ip_srcroute(void) |
|
Line 1792 ip_srcroute(void) |
|
* XXX should be deleted; last arg currently ignored. |
* XXX should be deleted; last arg currently ignored. |
*/ |
*/ |
void |
void |
ip_stripoptions(struct mbuf *m, struct mbuf *mopt __unused) |
ip_stripoptions(struct mbuf *m, struct mbuf *mopt) |
{ |
{ |
int i; |
int i; |
struct ip *ip = mtod(m, struct ip *); |
struct ip *ip = mtod(m, struct ip *); |
Line 1873 ip_forward(struct mbuf *m, int srcrt) |
|
Line 1871 ip_forward(struct mbuf *m, int srcrt) |
|
} |
} |
|
|
sin = satosin(&ipforward_rt.ro_dst); |
sin = satosin(&ipforward_rt.ro_dst); |
if ((rt = ipforward_rt.ro_rt) == 0 || |
if ((rt = ipforward_rt.ro_rt) == NULL || |
!in_hosteq(ip->ip_dst, sin->sin_addr)) { |
!in_hosteq(ip->ip_dst, sin->sin_addr)) { |
if (ipforward_rt.ro_rt) { |
if (ipforward_rt.ro_rt != NULL) |
RTFREE(ipforward_rt.ro_rt); |
rtflush(&ipforward_rt); |
ipforward_rt.ro_rt = 0; |
|
} |
|
sin->sin_family = AF_INET; |
sin->sin_family = AF_INET; |
sin->sin_len = sizeof(struct sockaddr_in); |
sin->sin_len = sizeof(struct sockaddr_in); |
sin->sin_addr = ip->ip_dst; |
sin->sin_addr = ip->ip_dst; |
|
|
rtalloc(&ipforward_rt); |
rtalloc(&ipforward_rt); |
if (ipforward_rt.ro_rt == 0) { |
if (ipforward_rt.ro_rt == NULL) { |
icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_NET, dest, 0); |
icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_NET, dest, 0); |
return; |
return; |
} |
} |
Line 1935 ip_forward(struct mbuf *m, int srcrt) |
|
Line 1931 ip_forward(struct mbuf *m, int srcrt) |
|
} |
} |
} |
} |
|
|
error = ip_output(m, (struct mbuf *)0, &ipforward_rt, |
error = ip_output(m, NULL, &ipforward_rt, |
(IP_FORWARDING | (ip_directedbcast ? IP_ALLOWBROADCAST : 0)), |
(IP_FORWARDING | (ip_directedbcast ? IP_ALLOWBROADCAST : 0)), |
(struct ip_moptions *)NULL, (struct socket *)NULL); |
(struct ip_moptions *)NULL, (struct socket *)NULL); |
|
|
Line 1978 ip_forward(struct mbuf *m, int srcrt) |
|
Line 1974 ip_forward(struct mbuf *m, int srcrt) |
|
type = ICMP_UNREACH; |
type = ICMP_UNREACH; |
code = ICMP_UNREACH_NEEDFRAG; |
code = ICMP_UNREACH_NEEDFRAG; |
#if !defined(IPSEC) && !defined(FAST_IPSEC) |
#if !defined(IPSEC) && !defined(FAST_IPSEC) |
if (ipforward_rt.ro_rt) |
if (ipforward_rt.ro_rt != NULL) |
destmtu = ipforward_rt.ro_rt->rt_ifp->if_mtu; |
destmtu = ipforward_rt.ro_rt->rt_ifp->if_mtu; |
#else |
#else |
/* |
/* |
Line 1987 ip_forward(struct mbuf *m, int srcrt) |
|
Line 1983 ip_forward(struct mbuf *m, int srcrt) |
|
* tunnel MTU = if MTU - sizeof(IP) - ESP/AH hdrsiz |
* tunnel MTU = if MTU - sizeof(IP) - ESP/AH hdrsiz |
* XXX quickhack!!! |
* XXX quickhack!!! |
*/ |
*/ |
if (ipforward_rt.ro_rt) { |
if (ipforward_rt.ro_rt != NULL) { |
struct secpolicy *sp; |
struct secpolicy *sp; |
int ipsecerror; |
int ipsecerror; |
size_t ipsechdr; |
size_t ipsechdr; |