version 1.236.4.1, 2007/09/23 21:36:35 |
version 1.240, 2006/12/15 21:18:53 |
|
|
/* XXX error stat??? */ |
/* XXX error stat??? */ |
error = EINVAL; |
error = EINVAL; |
DPRINTF(("ip_input: no SP, packet discarded\n"));/*XXX*/ |
DPRINTF(("ip_input: no SP, packet discarded\n"));/*XXX*/ |
|
goto bad; |
} |
} |
splx(s); |
splx(s); |
if (error) |
if (error) |
Line 1678 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 (!in_hosteq(dst, sin->sin_addr)) |
if (ipforward_rt.ro_rt) { |
rtcache_free(&ipforward_rt); |
RTFREE(ipforward_rt.ro_rt); |
else |
ipforward_rt.ro_rt = 0; |
rtcache_check(&ipforward_rt); |
} |
if (ipforward_rt.ro_rt == NULL) { |
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); |
rtcache_init(&ipforward_rt); |
|
if (ipforward_rt.ro_rt == NULL) |
|
return NULL; |
} |
} |
if (ipforward_rt.ro_rt == 0) |
|
return ((struct in_ifaddr *)0); |
|
return (ifatoia(ipforward_rt.ro_rt->rt_ifa)); |
return (ifatoia(ipforward_rt.ro_rt->rt_ifa)); |
} |
} |
|
|
Line 1727 ip_srcroute(void) |
|
Line 1728 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 1872 ip_forward(struct mbuf *m, int srcrt) |
|
Line 1873 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 (!in_hosteq(ip->ip_dst, sin->sin_addr)) |
!in_hosteq(ip->ip_dst, sin->sin_addr)) { |
rtcache_free(&ipforward_rt); |
if (ipforward_rt.ro_rt) { |
else |
RTFREE(ipforward_rt.ro_rt); |
rtcache_check(&ipforward_rt); |
ipforward_rt.ro_rt = 0; |
if (ipforward_rt.ro_rt == NULL) { |
} |
|
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); |
rtcache_init(&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; |
} |
} |
rt = ipforward_rt.ro_rt; |
|
} |
} |
|
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 |
Line 1934 ip_forward(struct mbuf *m, int srcrt) |
|
Line 1934 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 1977 ip_forward(struct mbuf *m, int srcrt) |
|
Line 1977 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 1986 ip_forward(struct mbuf *m, int srcrt) |
|
Line 1986 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; |