be more friendly with INET-less build.
XXX we need to do more to do a working INET-less build
This commit is contained in:
parent
d839a91f5f
commit
a7e15e4935
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: tcp_input.c,v 1.118 2000/10/17 02:57:02 thorpej Exp $ */
|
||||
/* $NetBSD: tcp_input.c,v 1.119 2000/10/17 03:06:42 itojun Exp $ */
|
||||
|
||||
/*
|
||||
%%% portions-copyright-nrl-95
|
||||
|
@ -617,6 +617,7 @@ tcp_input(m, va_alist)
|
|||
ip6 = NULL;
|
||||
#endif
|
||||
switch (ip->ip_v) {
|
||||
#ifdef INET
|
||||
case 4:
|
||||
af = AF_INET;
|
||||
iphlen = sizeof(struct ip);
|
||||
|
@ -657,6 +658,7 @@ tcp_input(m, va_alist)
|
|||
len = ip->ip_len;
|
||||
tlen = len - toff;
|
||||
break;
|
||||
#endif
|
||||
#ifdef INET6
|
||||
case 6:
|
||||
ip = NULL;
|
||||
|
@ -747,9 +749,11 @@ tcp_input(m, va_alist)
|
|||
return;
|
||||
}
|
||||
switch (af) {
|
||||
#ifdef INET
|
||||
case AF_INET:
|
||||
ip = mtod(m, struct ip *);
|
||||
break;
|
||||
#endif
|
||||
#ifdef INET6
|
||||
case AF_INET6:
|
||||
ip6 = mtod(m, struct ip6_hdr *);
|
||||
|
@ -800,6 +804,7 @@ findpcb:
|
|||
in6p = NULL;
|
||||
#endif
|
||||
switch (af) {
|
||||
#ifdef INET
|
||||
case AF_INET:
|
||||
inp = in_pcblookup_connect(&tcbtable, ip->ip_src, th->th_sport,
|
||||
ip->ip_dst, th->th_dport);
|
||||
|
@ -877,6 +882,7 @@ findpcb:
|
|||
#endif
|
||||
#endif /*IPSEC*/
|
||||
break;
|
||||
#endif /*INET*/
|
||||
#if defined(INET6) && !defined(TCP6)
|
||||
case AF_INET6:
|
||||
{
|
||||
|
@ -943,6 +949,7 @@ findpcb:
|
|||
* Checksum extended TCP header and data.
|
||||
*/
|
||||
switch (af) {
|
||||
#ifdef INET
|
||||
case AF_INET:
|
||||
#ifndef PULLDOWN_TEST
|
||||
{
|
||||
|
@ -963,6 +970,7 @@ findpcb:
|
|||
}
|
||||
#endif
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef INET6
|
||||
case AF_INET6:
|
||||
|
@ -1000,6 +1008,7 @@ findpcb:
|
|||
bzero(&src, sizeof(src));
|
||||
bzero(&dst, sizeof(dst));
|
||||
switch (af) {
|
||||
#ifdef INET
|
||||
case AF_INET:
|
||||
src.sin.sin_len = sizeof(struct sockaddr_in);
|
||||
src.sin.sin_family = AF_INET;
|
||||
|
@ -1011,6 +1020,7 @@ findpcb:
|
|||
dst.sin.sin_addr = ip->ip_dst;
|
||||
dst.sin.sin_port = th->th_dport;
|
||||
break;
|
||||
#endif
|
||||
#ifdef INET6
|
||||
case AF_INET6:
|
||||
src.sin6.sin6_len = sizeof(struct sockaddr_in6);
|
||||
|
@ -1064,9 +1074,11 @@ findpcb:
|
|||
struct ip *sip;
|
||||
sip = mtod(tcp_saveti, struct ip *);
|
||||
switch (af) {
|
||||
#ifdef INET
|
||||
case AF_INET:
|
||||
sip->ip_v = 4;
|
||||
break;
|
||||
#endif
|
||||
#ifdef INET6
|
||||
case AF_INET6:
|
||||
sip->ip_v = 6;
|
||||
|
@ -1121,10 +1133,12 @@ findpcb:
|
|||
in6p = NULL;
|
||||
#endif
|
||||
switch (so->so_proto->pr_domain->dom_family) {
|
||||
#ifdef INET
|
||||
case AF_INET:
|
||||
inp = sotoinpcb(so);
|
||||
tp = intotcpcb(inp);
|
||||
break;
|
||||
#endif
|
||||
#ifdef INET6
|
||||
case AF_INET6:
|
||||
in6p = sotoin6pcb(so);
|
||||
|
@ -1159,9 +1173,11 @@ findpcb:
|
|||
int i;
|
||||
|
||||
switch (af) {
|
||||
#ifdef INET
|
||||
case AF_INET:
|
||||
i = in_hosteq(ip->ip_src, ip->ip_dst);
|
||||
break;
|
||||
#endif
|
||||
#ifdef INET6
|
||||
case AF_INET6:
|
||||
i = IN6_ARE_ADDR_EQUAL(&ip6->ip6_src, &ip6->ip6_dst);
|
||||
|
@ -2166,9 +2182,11 @@ dropwithreset:
|
|||
struct ip *sip;
|
||||
sip = mtod(m, struct ip *);
|
||||
switch (af) {
|
||||
#ifdef INET
|
||||
case AF_INET:
|
||||
sip->ip_v = 4;
|
||||
break;
|
||||
#endif
|
||||
#ifdef INET6
|
||||
case AF_INET6:
|
||||
sip->ip_v = 6;
|
||||
|
@ -2905,9 +2923,11 @@ syn_cache_get(src, dst, th, hlen, tlen, so, m)
|
|||
goto resetandabort;
|
||||
|
||||
switch (so->so_proto->pr_domain->dom_family) {
|
||||
#ifdef INET
|
||||
case AF_INET:
|
||||
inp = sotoinpcb(so);
|
||||
break;
|
||||
#endif
|
||||
#ifdef INET6
|
||||
case AF_INET6:
|
||||
in6p = sotoin6pcb(so);
|
||||
|
@ -2925,6 +2945,7 @@ syn_cache_get(src, dst, th, hlen, tlen, so, m)
|
|||
}
|
||||
}
|
||||
switch (src->sa_family) {
|
||||
#ifdef INET
|
||||
case AF_INET:
|
||||
if (inp) {
|
||||
inp->inp_laddr = ((struct sockaddr_in *)dst)->sin_addr;
|
||||
|
@ -2949,6 +2970,7 @@ syn_cache_get(src, dst, th, hlen, tlen, so, m)
|
|||
}
|
||||
#endif
|
||||
break;
|
||||
#endif
|
||||
#ifdef INET6
|
||||
case AF_INET6:
|
||||
if (in6p) {
|
||||
|
@ -3242,13 +3264,18 @@ syn_cache_add(src, dst, th, hlen, so, m, optp, optlen, oi)
|
|||
if (win > TCP_MAXWIN)
|
||||
win = TCP_MAXWIN;
|
||||
|
||||
if (src->sa_family == AF_INET) {
|
||||
switch (src->sa_family) {
|
||||
#ifdef INET
|
||||
case AF_INET:
|
||||
/*
|
||||
* Remember the IP options, if any.
|
||||
*/
|
||||
ipopts = ip_srcroute();
|
||||
} else
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
ipopts = NULL;
|
||||
}
|
||||
|
||||
if (optp) {
|
||||
tb.t_flags = tcp_do_rfc1323 ? (TF_REQ_SCALE|TF_REQ_TSTMP) : 0;
|
||||
|
@ -3491,11 +3518,13 @@ syn_cache_respond(sc, m)
|
|||
* ip_len to be in host order, for convenience.
|
||||
*/
|
||||
switch (sc->sc_src.sa.sa_family) {
|
||||
#ifdef INET
|
||||
case AF_INET:
|
||||
ip->ip_len = tlen;
|
||||
ip->ip_ttl = ip_defttl;
|
||||
/* XXX tos? */
|
||||
break;
|
||||
#endif
|
||||
#ifdef INET6
|
||||
case AF_INET6:
|
||||
ip6->ip6_vfc &= ~IPV6_VERSION_MASK;
|
||||
|
@ -3508,11 +3537,13 @@ syn_cache_respond(sc, m)
|
|||
}
|
||||
|
||||
switch (sc->sc_src.sa.sa_family) {
|
||||
#ifdef INET
|
||||
case AF_INET:
|
||||
error = ip_output(m, sc->sc_ipopts, ro,
|
||||
(ip_mtudisc ? IP_MTUDISC : 0),
|
||||
NULL);
|
||||
break;
|
||||
#endif
|
||||
#ifdef INET6
|
||||
case AF_INET6:
|
||||
ip6->ip6_hlim = in6_selecthlim(NULL,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: tcp_output.c,v 1.59 2000/10/17 02:57:02 thorpej Exp $ */
|
||||
/* $NetBSD: tcp_output.c,v 1.60 2000/10/17 03:06:43 itojun Exp $ */
|
||||
|
||||
/*
|
||||
%%% portions-copyright-nrl-95
|
||||
|
@ -174,7 +174,9 @@ tcp_segsize(tp, txsegsizep, rxsegsizep)
|
|||
struct tcpcb *tp;
|
||||
int *txsegsizep, *rxsegsizep;
|
||||
{
|
||||
#ifdef INET
|
||||
struct inpcb *inp = tp->t_inpcb;
|
||||
#endif
|
||||
#ifdef INET6
|
||||
struct in6pcb *in6p = tp->t_in6pcb;
|
||||
#endif
|
||||
|
@ -183,10 +185,16 @@ tcp_segsize(tp, txsegsizep, rxsegsizep)
|
|||
int size;
|
||||
int iphlen;
|
||||
|
||||
#ifdef DIAGNOSTIC
|
||||
if (tp->t_inpcb && tp->t_in6pcb)
|
||||
panic("tcp_segsize: both t_inpcb and t_in6pcb are set");
|
||||
#endif
|
||||
switch (tp->t_family) {
|
||||
#ifdef INET
|
||||
case AF_INET:
|
||||
iphlen = sizeof(struct ip);
|
||||
break;
|
||||
#endif
|
||||
#ifdef INET6
|
||||
case AF_INET6:
|
||||
iphlen = sizeof(struct ip6_hdr);
|
||||
|
@ -197,14 +205,15 @@ tcp_segsize(tp, txsegsizep, rxsegsizep)
|
|||
goto out;
|
||||
}
|
||||
|
||||
rt = NULL;
|
||||
#ifdef INET
|
||||
if (inp)
|
||||
rt = in_pcbrtentry(inp);
|
||||
#endif
|
||||
#if defined(INET6) && !defined(TCP6)
|
||||
else if (in6p)
|
||||
if (in6p)
|
||||
rt = in6_pcbrtentry(in6p);
|
||||
#endif
|
||||
else
|
||||
rt = NULL;
|
||||
if (rt == NULL) {
|
||||
size = tcp_mssdflt;
|
||||
goto out;
|
||||
|
@ -215,19 +224,26 @@ tcp_segsize(tp, txsegsizep, rxsegsizep)
|
|||
size = tcp_mssdflt;
|
||||
if (rt->rt_rmx.rmx_mtu != 0)
|
||||
size = rt->rt_rmx.rmx_mtu - iphlen - sizeof(struct tcphdr);
|
||||
else if (ip_mtudisc || ifp->if_flags & IFF_LOOPBACK)
|
||||
else if (ifp->if_flags & IFF_LOOPBACK)
|
||||
size = ifp->if_mtu - iphlen - sizeof(struct tcphdr);
|
||||
#ifdef INET
|
||||
else if (ip_mtudisc)
|
||||
size = ifp->if_mtu - iphlen - sizeof(struct tcphdr);
|
||||
else if (inp && in_localaddr(inp->inp_faddr))
|
||||
size = ifp->if_mtu - iphlen - sizeof(struct tcphdr);
|
||||
#endif
|
||||
#ifdef INET6
|
||||
else if (in6p) {
|
||||
#ifdef INET
|
||||
if (IN6_IS_ADDR_V4MAPPED(&in6p->in6p_faddr)) {
|
||||
/* mapped addr case */
|
||||
struct in_addr d;
|
||||
bcopy(&in6p->in6p_faddr.s6_addr32[3], &d, sizeof(d));
|
||||
if (in_localaddr(d))
|
||||
size = ifp->if_mtu - iphlen - sizeof(struct tcphdr);
|
||||
} else {
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
if (in6_localaddr(&in6p->in6p_faddr))
|
||||
size = ifp->if_mtu - iphlen - sizeof(struct tcphdr);
|
||||
}
|
||||
|
@ -238,20 +254,24 @@ tcp_segsize(tp, txsegsizep, rxsegsizep)
|
|||
* XXX tp->t_ourmss should have the right size, but without this code
|
||||
* fragmentation will occur... need more investigation
|
||||
*/
|
||||
#ifdef INET
|
||||
if (inp) {
|
||||
#ifdef IPSEC
|
||||
size -= ipsec4_hdrsiz_tcp(tp);
|
||||
#endif
|
||||
size -= ip_optlen(inp);
|
||||
}
|
||||
#endif
|
||||
#ifdef INET6
|
||||
else if (in6p && tp->t_family == AF_INET) {
|
||||
#ifdef INET
|
||||
if (in6p && tp->t_family == AF_INET) {
|
||||
#ifdef IPSEC
|
||||
size -= ipsec4_hdrsiz_tcp(tp);
|
||||
#endif
|
||||
/* XXX size -= ip_optlen(in6p); */
|
||||
}
|
||||
else if (in6p && tp->t_family == AF_INET6) {
|
||||
} else
|
||||
#endif
|
||||
if (in6p && tp->t_family == AF_INET6) {
|
||||
#if defined(IPSEC) && !defined(TCP6)
|
||||
size -= ipsec6_hdrsiz_tcp(tp);
|
||||
#endif
|
||||
|
@ -315,6 +335,10 @@ tcp_output(tp)
|
|||
int af; /* address family on the wire */
|
||||
int iphdrlen;
|
||||
|
||||
#ifdef DIAGNOSTIC
|
||||
if (tp->t_inpcb && tp->t_in6pcb)
|
||||
panic("tcp_output: both t_inpcb and t_in6pcb are set");
|
||||
#endif
|
||||
so = NULL;
|
||||
ro = NULL;
|
||||
if (tp->t_inpcb) {
|
||||
|
@ -329,6 +353,7 @@ tcp_output(tp)
|
|||
#endif
|
||||
|
||||
switch (af = tp->t_family) {
|
||||
#ifdef INET
|
||||
case AF_INET:
|
||||
if (tp->t_inpcb)
|
||||
break;
|
||||
|
@ -338,6 +363,7 @@ tcp_output(tp)
|
|||
break;
|
||||
#endif
|
||||
return EINVAL;
|
||||
#endif
|
||||
#ifdef INET6
|
||||
case AF_INET6:
|
||||
if (tp->t_in6pcb)
|
||||
|
@ -578,9 +604,11 @@ send:
|
|||
*/
|
||||
optlen = 0;
|
||||
switch (af) {
|
||||
#ifdef INET
|
||||
case AF_INET:
|
||||
iphdrlen = sizeof(struct ip) + sizeof(struct tcphdr);
|
||||
break;
|
||||
#endif
|
||||
#ifdef INET6
|
||||
case AF_INET6:
|
||||
iphdrlen = sizeof(struct ip6_hdr) + sizeof(struct tcphdr);
|
||||
|
@ -594,14 +622,15 @@ send:
|
|||
if (flags & TH_SYN) {
|
||||
struct rtentry *rt;
|
||||
|
||||
rt = NULL;
|
||||
#ifdef INET
|
||||
if (tp->t_inpcb)
|
||||
rt = in_pcbrtentry(tp->t_inpcb);
|
||||
#endif
|
||||
#if defined(INET6) && !defined(TCP6)
|
||||
else if (tp->t_in6pcb)
|
||||
if (tp->t_in6pcb)
|
||||
rt = in6_pcbrtentry(tp->t_in6pcb);
|
||||
#endif
|
||||
else
|
||||
rt = NULL;
|
||||
|
||||
tp->snd_nxt = tp->iss;
|
||||
tp->t_ourmss = tcp_mss_to_advertise(rt != NULL ?
|
||||
|
@ -744,6 +773,7 @@ send:
|
|||
}
|
||||
m->m_pkthdr.rcvif = (struct ifnet *)0;
|
||||
switch (af) {
|
||||
#ifdef INET
|
||||
case AF_INET:
|
||||
ip = mtod(m, struct ip *);
|
||||
#ifdef INET6
|
||||
|
@ -751,6 +781,7 @@ send:
|
|||
#endif
|
||||
th = (struct tcphdr *)(ip + 1);
|
||||
break;
|
||||
#endif
|
||||
#ifdef INET6
|
||||
case AF_INET6:
|
||||
ip = NULL;
|
||||
|
@ -827,6 +858,7 @@ send:
|
|||
* checksum extended header and data.
|
||||
*/
|
||||
switch (af) {
|
||||
#ifdef INET
|
||||
case AF_INET:
|
||||
{
|
||||
struct ipovly *ipov = (struct ipovly *)ip;
|
||||
|
@ -838,6 +870,7 @@ send:
|
|||
th->th_sum = in_cksum(m, (int)(hdrlen + len));
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
#ifdef INET6
|
||||
case AF_INET6:
|
||||
/* equals to hdrlen + len */
|
||||
|
@ -910,9 +943,11 @@ send:
|
|||
struct ip *sip;
|
||||
sip = mtod(m, struct ip *);
|
||||
switch (af) {
|
||||
#ifdef INET
|
||||
case AF_INET:
|
||||
sip->ip_v = 4;
|
||||
break;
|
||||
#endif
|
||||
#ifdef INET6
|
||||
case AF_INET6:
|
||||
sip->ip_v = 6;
|
||||
|
@ -931,6 +966,7 @@ send:
|
|||
m->m_pkthdr.len = hdrlen + len;
|
||||
|
||||
switch (af) {
|
||||
#ifdef INET
|
||||
case AF_INET:
|
||||
ip->ip_len = m->m_pkthdr.len;
|
||||
if (tp->t_inpcb) {
|
||||
|
@ -944,6 +980,7 @@ send:
|
|||
}
|
||||
#endif
|
||||
break;
|
||||
#endif
|
||||
#ifdef INET6
|
||||
case AF_INET6:
|
||||
ip6->ip6_nxt = IPPROTO_TCP;
|
||||
|
@ -968,6 +1005,7 @@ send:
|
|||
#endif /*IPSEC*/
|
||||
|
||||
switch (af) {
|
||||
#ifdef INET
|
||||
case AF_INET:
|
||||
{
|
||||
struct mbuf *opts;
|
||||
|
@ -982,6 +1020,7 @@ send:
|
|||
0);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
#ifdef INET6
|
||||
case AF_INET6:
|
||||
{
|
||||
|
@ -1003,10 +1042,12 @@ send:
|
|||
if (error) {
|
||||
out:
|
||||
if (error == ENOBUFS) {
|
||||
#ifdef INET
|
||||
if (tp->t_inpcb)
|
||||
tcp_quench(tp->t_inpcb, 0);
|
||||
#endif
|
||||
#ifdef INET6
|
||||
else if (tp->t_in6pcb)
|
||||
if (tp->t_in6pcb)
|
||||
tcp6_quench(tp->t_in6pcb, 0);
|
||||
#endif
|
||||
return (0);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: tcp_subr.c,v 1.95 2000/10/17 02:57:02 thorpej Exp $ */
|
||||
/* $NetBSD: tcp_subr.c,v 1.96 2000/10/17 03:06:43 itojun Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
|
||||
|
@ -382,10 +382,16 @@ tcp_respond(tp, template, m, th0, ack, seq, flags)
|
|||
struct tcphdr *th;
|
||||
|
||||
if (tp != NULL && (flags & TH_RST) == 0) {
|
||||
#ifdef DIAGNOSTIC
|
||||
if (tp->t_inpcb && tp->t_in6pcb)
|
||||
panic("tcp_respond: both t_inpcb and t_in6pcb are set");
|
||||
#endif
|
||||
#ifdef INET
|
||||
if (tp->t_inpcb)
|
||||
win = sbspace(&tp->t_inpcb->inp_socket->so_rcv);
|
||||
#endif
|
||||
#ifdef INET6
|
||||
else if (tp->t_in6pcb)
|
||||
if (tp->t_in6pcb)
|
||||
win = sbspace(&tp->t_in6pcb->in6p_socket->so_rcv);
|
||||
#endif
|
||||
}
|
||||
|
@ -575,6 +581,7 @@ tcp_respond(tp, template, m, th0, ack, seq, flags)
|
|||
th->th_urp = 0;
|
||||
|
||||
switch (family) {
|
||||
#ifdef INET
|
||||
case AF_INET:
|
||||
{
|
||||
struct ipovly *ipov = (struct ipovly *)ip;
|
||||
|
@ -587,6 +594,7 @@ tcp_respond(tp, template, m, th0, ack, seq, flags)
|
|||
ip->ip_ttl = ip_defttl;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
#ifdef INET6
|
||||
case AF_INET6:
|
||||
{
|
||||
|
@ -657,11 +665,13 @@ tcp_respond(tp, template, m, th0, ack, seq, flags)
|
|||
ro = NULL;
|
||||
|
||||
switch (family) {
|
||||
#ifdef INET
|
||||
case AF_INET:
|
||||
error = ip_output(m, NULL, ro,
|
||||
(ip_mtudisc ? IP_MTUDISC : 0),
|
||||
NULL);
|
||||
break;
|
||||
#endif
|
||||
#ifdef INET6
|
||||
case AF_INET6:
|
||||
error = ip6_output(m, NULL, (struct route_in6 *)ro, 0, NULL,
|
||||
|
@ -772,10 +782,16 @@ tcp_drop(tp, errno)
|
|||
{
|
||||
struct socket *so;
|
||||
|
||||
#ifdef DIAGNOSTIC
|
||||
if (tp->t_inpcb && tp->t_in6pcb)
|
||||
panic("tcp_drop: both t_inpcb and t_in6pcb are set");
|
||||
#endif
|
||||
#ifdef INET
|
||||
if (tp->t_inpcb)
|
||||
so = tp->t_inpcb->inp_socket;
|
||||
#endif
|
||||
#ifdef INET6
|
||||
else if (tp->t_in6pcb)
|
||||
if (tp->t_in6pcb)
|
||||
so = tp->t_in6pcb->in6p_socket;
|
||||
#endif
|
||||
else
|
||||
|
@ -1145,6 +1161,7 @@ tcp6_ctlinput(cmd, sa, d)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef INET
|
||||
/* assumes that ip header and tcp header are contiguous on mbuf */
|
||||
void *
|
||||
tcp_ctlinput(cmd, sa, v)
|
||||
|
@ -1216,6 +1233,7 @@ tcp_quench(inp, errno)
|
|||
if (tp)
|
||||
tp->snd_cwnd = tp->t_segsz;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(INET6) && !defined(TCP6)
|
||||
void
|
||||
|
@ -1405,16 +1423,22 @@ tcp_mss_from_peer(tp, offer)
|
|||
u_long bufsize;
|
||||
int mss;
|
||||
|
||||
#ifdef DIAGNOSTIC
|
||||
if (tp->t_inpcb && tp->t_in6pcb)
|
||||
panic("tcp_mss_from_peer: both t_inpcb and t_in6pcb are set");
|
||||
#endif
|
||||
so = NULL;
|
||||
rt = NULL;
|
||||
#ifdef INET
|
||||
if (tp->t_inpcb) {
|
||||
so = tp->t_inpcb->inp_socket;
|
||||
#if defined(RTV_SPIPE) || defined(RTV_SSTHRESH)
|
||||
rt = in_pcbrtentry(tp->t_inpcb);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
#ifdef INET6
|
||||
else if (tp->t_in6pcb) {
|
||||
if (tp->t_in6pcb) {
|
||||
so = tp->t_in6pcb->in6p_socket;
|
||||
#if defined(RTV_SPIPE) || defined(RTV_SSTHRESH)
|
||||
#ifdef TCP6
|
||||
|
@ -1436,10 +1460,12 @@ tcp_mss_from_peer(tp, offer)
|
|||
mss = max(mss, 32); /* sanity */
|
||||
tp->t_peermss = mss;
|
||||
mss -= tcp_optlen(tp);
|
||||
#ifdef INET
|
||||
if (tp->t_inpcb)
|
||||
mss -= ip_optlen(tp->t_inpcb);
|
||||
#endif
|
||||
#ifdef INET6
|
||||
else if (tp->t_in6pcb)
|
||||
if (tp->t_in6pcb)
|
||||
mss -= ip6_optlen(tp->t_in6pcb);
|
||||
#endif
|
||||
|
||||
|
@ -1491,16 +1517,22 @@ tcp_established(tp)
|
|||
#endif
|
||||
u_long bufsize;
|
||||
|
||||
#ifdef DIAGNOSTIC
|
||||
if (tp->t_inpcb && tp->t_in6pcb)
|
||||
panic("tcp_established: both t_inpcb and t_in6pcb are set");
|
||||
#endif
|
||||
so = NULL;
|
||||
rt = NULL;
|
||||
#ifdef INET
|
||||
if (tp->t_inpcb) {
|
||||
so = tp->t_inpcb->inp_socket;
|
||||
#if defined(RTV_RPIPE)
|
||||
rt = in_pcbrtentry(tp->t_inpcb);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
#ifdef INET6
|
||||
else if (tp->t_in6pcb) {
|
||||
if (tp->t_in6pcb) {
|
||||
so = tp->t_in6pcb->in6p_socket;
|
||||
#if defined(RTV_RPIPE)
|
||||
#ifdef TCP6
|
||||
|
@ -1542,10 +1574,16 @@ tcp_rmx_rtt(tp)
|
|||
struct rtentry *rt = NULL;
|
||||
int rtt;
|
||||
|
||||
#ifdef DIAGNOSTIC
|
||||
if (tp->t_inpcb && tp->t_in6pcb)
|
||||
panic("tcp_rmx_rtt: both t_inpcb and t_in6pcb are set");
|
||||
#endif
|
||||
#ifdef INET
|
||||
if (tp->t_inpcb)
|
||||
rt = in_pcbrtentry(tp->t_inpcb);
|
||||
#endif
|
||||
#ifdef INET6
|
||||
else if (tp->t_in6pcb) {
|
||||
if (tp->t_in6pcb) {
|
||||
#ifdef TCP6
|
||||
rt = NULL;
|
||||
#else
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: tcp_timer.c,v 1.46 2000/03/30 13:25:10 augustss Exp $ */
|
||||
/* $NetBSD: tcp_timer.c,v 1.47 2000/10/17 03:06:44 itojun Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
|
||||
|
@ -299,6 +299,11 @@ tcp_timers(tp, timer)
|
|||
{
|
||||
short rto;
|
||||
|
||||
#ifdef DIAGNOSTIC
|
||||
if (tp->t_inpcb && tp->t_in6pcb)
|
||||
panic("tcp_timers: both t_inpcb and t_in6pcb are set");
|
||||
#endif
|
||||
|
||||
switch (timer) {
|
||||
|
||||
/*
|
||||
|
@ -347,10 +352,12 @@ tcp_timers(tp, timer)
|
|||
if (ip_mtudisc && tp->t_rxtshift > TCP_MAXRXTSHIFT / 6) {
|
||||
struct rtentry *rt = NULL;
|
||||
|
||||
#ifdef INET
|
||||
if (tp->t_inpcb)
|
||||
rt = in_pcbrtentry(tp->t_inpcb);
|
||||
#endif
|
||||
#ifdef INET6
|
||||
else if (tp->t_in6pcb)
|
||||
if (tp->t_in6pcb)
|
||||
rt = in6_pcbrtentry(tp->t_in6pcb);
|
||||
#endif
|
||||
|
||||
|
@ -366,10 +373,12 @@ tcp_timers(tp, timer)
|
|||
* retransmit times until then.
|
||||
*/
|
||||
if (tp->t_rxtshift > TCP_MAXRXTSHIFT / 4) {
|
||||
#ifdef INET
|
||||
if (tp->t_inpcb)
|
||||
in_losing(tp->t_inpcb);
|
||||
#endif
|
||||
#ifdef INET6
|
||||
else if (tp->t_in6pcb)
|
||||
if (tp->t_in6pcb)
|
||||
in6_losing(tp->t_in6pcb);
|
||||
#endif
|
||||
tp->t_rttvar += (tp->t_srtt >> TCP_RTT_SHIFT);
|
||||
|
@ -463,10 +472,12 @@ tcp_timers(tp, timer)
|
|||
tcpstat.tcps_keeptimeo++;
|
||||
if (TCPS_HAVEESTABLISHED(tp->t_state) == 0)
|
||||
goto dropit;
|
||||
#ifdef INET
|
||||
if (tp->t_inpcb)
|
||||
so = tp->t_inpcb->inp_socket;
|
||||
#endif
|
||||
#ifdef INET6
|
||||
else if (tp->t_in6pcb)
|
||||
if (tp->t_in6pcb)
|
||||
so = tp->t_in6pcb->in6p_socket;
|
||||
#endif
|
||||
if (so->so_options & SO_KEEPALIVE &&
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: tcp_usrreq.c,v 1.55 2000/10/06 10:21:06 enami Exp $ */
|
||||
/* $NetBSD: tcp_usrreq.c,v 1.56 2000/10/17 03:06:44 itojun Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
|
||||
|
@ -187,9 +187,11 @@ tcp_usrreq(so, req, m, nam, control, p)
|
|||
|
||||
if (req == PRU_CONTROL) {
|
||||
switch (family) {
|
||||
#ifdef INET
|
||||
case PF_INET:
|
||||
return (in_control(so, (long)m, (caddr_t)nam,
|
||||
(struct ifnet *)control, p));
|
||||
#endif
|
||||
#ifdef INET6
|
||||
case PF_INET6:
|
||||
return (in6_control(so, (long)m, (caddr_t)nam,
|
||||
|
@ -202,10 +204,12 @@ tcp_usrreq(so, req, m, nam, control, p)
|
|||
|
||||
if (req == PRU_PURGEIF) {
|
||||
switch (family) {
|
||||
#ifdef INET
|
||||
case PF_INET:
|
||||
in_purgeif((struct ifnet *)control);
|
||||
in_pcbpurgeif(&tcbtable, (struct ifnet *)control);
|
||||
break;
|
||||
#endif
|
||||
#ifdef INET6
|
||||
case PF_INET6:
|
||||
in6_purgeif((struct ifnet *)control);
|
||||
|
@ -220,12 +224,14 @@ tcp_usrreq(so, req, m, nam, control, p)
|
|||
|
||||
s = splsoftnet();
|
||||
switch (family) {
|
||||
#ifdef INET
|
||||
case PF_INET:
|
||||
inp = sotoinpcb(so);
|
||||
#ifdef INET6
|
||||
in6p = NULL;
|
||||
#endif
|
||||
break;
|
||||
#endif
|
||||
#ifdef INET6
|
||||
case PF_INET6:
|
||||
inp = NULL;
|
||||
|
@ -238,6 +244,8 @@ tcp_usrreq(so, req, m, nam, control, p)
|
|||
}
|
||||
|
||||
#ifdef DIAGNOSTIC
|
||||
if (inp && in6p)
|
||||
panic("tcp_usrreq: both inp and in6p set to non-NULL");
|
||||
if (req != PRU_SEND && req != PRU_SENDOOB && control)
|
||||
panic("tcp_usrreq: unexpected control mbuf");
|
||||
#endif
|
||||
|
@ -255,6 +263,7 @@ tcp_usrreq(so, req, m, nam, control, p)
|
|||
error = EINVAL;
|
||||
goto release;
|
||||
}
|
||||
#ifdef INET
|
||||
if (inp) {
|
||||
tp = intotcpcb(inp);
|
||||
/* WHAT IF TP IS 0? */
|
||||
|
@ -263,8 +272,9 @@ tcp_usrreq(so, req, m, nam, control, p)
|
|||
#endif
|
||||
ostate = tp->t_state;
|
||||
}
|
||||
#endif
|
||||
#ifdef INET6
|
||||
else if (in6p) {
|
||||
if (in6p) {
|
||||
tp = in6totcpcb(in6p);
|
||||
/* WHAT IF TP IS 0? */
|
||||
#ifdef KPROF
|
||||
|
@ -312,9 +322,11 @@ tcp_usrreq(so, req, m, nam, control, p)
|
|||
*/
|
||||
case PRU_BIND:
|
||||
switch (family) {
|
||||
#ifdef INET
|
||||
case PF_INET:
|
||||
error = in_pcbbind(inp, nam, p);
|
||||
break;
|
||||
#endif
|
||||
#ifdef INET6
|
||||
case PF_INET6:
|
||||
error = in6_pcbbind(in6p, nam, p);
|
||||
|
@ -330,14 +342,16 @@ tcp_usrreq(so, req, m, nam, control, p)
|
|||
* Prepare to accept connections.
|
||||
*/
|
||||
case PRU_LISTEN:
|
||||
#ifdef INET
|
||||
if (inp && inp->inp_lport == 0) {
|
||||
error = in_pcbbind(inp, (struct mbuf *)0,
|
||||
(struct proc *)0);
|
||||
if (error)
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
#ifdef INET6
|
||||
else if (in6p && in6p->in6p_lport == 0) {
|
||||
if (in6p && in6p->in6p_lport == 0) {
|
||||
error = in6_pcbbind(in6p, (struct mbuf *)0,
|
||||
(struct proc *)0);
|
||||
if (error)
|
||||
|
@ -355,6 +369,7 @@ tcp_usrreq(so, req, m, nam, control, p)
|
|||
* Send initial segment on connection.
|
||||
*/
|
||||
case PRU_CONNECT:
|
||||
#ifdef INET
|
||||
if (inp) {
|
||||
if (inp->inp_lport == 0) {
|
||||
error = in_pcbbind(inp, (struct mbuf *)0,
|
||||
|
@ -364,8 +379,9 @@ tcp_usrreq(so, req, m, nam, control, p)
|
|||
}
|
||||
error = in_pcbconnect(inp, nam);
|
||||
}
|
||||
#endif
|
||||
#ifdef INET6
|
||||
else if (in6p) {
|
||||
if (in6p) {
|
||||
if (in6p->in6p_lport == 0) {
|
||||
error = in6_pcbbind(in6p, (struct mbuf *)0,
|
||||
(struct proc *)0);
|
||||
|
@ -382,10 +398,12 @@ tcp_usrreq(so, req, m, nam, control, p)
|
|||
break;
|
||||
tp->t_template = tcp_template(tp);
|
||||
if (tp->t_template == 0) {
|
||||
#ifdef INET
|
||||
if (inp)
|
||||
in_pcbdisconnect(inp);
|
||||
#endif
|
||||
#ifdef INET6
|
||||
else if (in6p)
|
||||
if (in6p)
|
||||
in6_pcbdisconnect(in6p);
|
||||
#endif
|
||||
error = ENOBUFS;
|
||||
|
@ -432,10 +450,12 @@ tcp_usrreq(so, req, m, nam, control, p)
|
|||
* of the peer, storing through addr.
|
||||
*/
|
||||
case PRU_ACCEPT:
|
||||
#ifdef INET
|
||||
if (inp)
|
||||
in_setpeeraddr(inp, nam);
|
||||
#endif
|
||||
#ifdef INET6
|
||||
else if (in6p)
|
||||
if (in6p)
|
||||
in6_setpeeraddr(in6p, nam);
|
||||
#endif
|
||||
break;
|
||||
|
@ -532,19 +552,23 @@ tcp_usrreq(so, req, m, nam, control, p)
|
|||
break;
|
||||
|
||||
case PRU_SOCKADDR:
|
||||
#ifdef INET
|
||||
if (inp)
|
||||
in_setsockaddr(inp, nam);
|
||||
#endif
|
||||
#ifdef INET6
|
||||
else if (in6p)
|
||||
if (in6p)
|
||||
in6_setsockaddr(in6p, nam);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case PRU_PEERADDR:
|
||||
#ifdef INET
|
||||
if (inp)
|
||||
in_setpeeraddr(inp, nam);
|
||||
#endif
|
||||
#ifdef INET6
|
||||
else if (in6p)
|
||||
if (in6p)
|
||||
in6_setpeeraddr(in6p, nam);
|
||||
#endif
|
||||
break;
|
||||
|
@ -590,12 +614,14 @@ tcp_ctloutput(op, so, level, optname, mp)
|
|||
|
||||
s = splsoftnet();
|
||||
switch (family) {
|
||||
#ifdef INET
|
||||
case PF_INET:
|
||||
inp = sotoinpcb(so);
|
||||
#ifdef INET6
|
||||
in6p = NULL;
|
||||
#endif
|
||||
break;
|
||||
#endif
|
||||
#ifdef INET6
|
||||
case PF_INET6:
|
||||
inp = NULL;
|
||||
|
@ -619,9 +645,11 @@ tcp_ctloutput(op, so, level, optname, mp)
|
|||
}
|
||||
if (level != IPPROTO_TCP) {
|
||||
switch (family) {
|
||||
#ifdef INET
|
||||
case PF_INET:
|
||||
error = ip_ctloutput(op, so, level, optname, mp);
|
||||
break;
|
||||
#endif
|
||||
#ifdef INET6
|
||||
case PF_INET6:
|
||||
error = ip6_ctloutput(op, so, level, optname, mp);
|
||||
|
@ -726,6 +754,7 @@ tcp_attach(so)
|
|||
return (error);
|
||||
}
|
||||
switch (family) {
|
||||
#ifdef INET
|
||||
case PF_INET:
|
||||
error = in_pcballoc(so, &tcbtable);
|
||||
if (error)
|
||||
|
@ -735,6 +764,7 @@ tcp_attach(so)
|
|||
in6p = NULL;
|
||||
#endif
|
||||
break;
|
||||
#endif
|
||||
#ifdef INET6
|
||||
case PF_INET6:
|
||||
error = in6_pcballoc(so, &tcb6);
|
||||
|
@ -748,6 +778,7 @@ tcp_attach(so)
|
|||
return EAFNOSUPPORT;
|
||||
}
|
||||
#ifdef IPSEC
|
||||
#ifdef INET
|
||||
if (inp) {
|
||||
error = ipsec_init_policy(so, &inp->inp_sp);
|
||||
if (error != 0) {
|
||||
|
@ -755,8 +786,9 @@ tcp_attach(so)
|
|||
return (error);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef INET6
|
||||
else if (in6p) {
|
||||
if (in6p) {
|
||||
error = ipsec_init_policy(so, &in6p->in6p_sp);
|
||||
if (error != 0) {
|
||||
in6_pcbdetach(in6p);
|
||||
|
@ -778,10 +810,12 @@ tcp_attach(so)
|
|||
int nofd = so->so_state & SS_NOFDREF; /* XXX */
|
||||
|
||||
so->so_state &= ~SS_NOFDREF; /* don't free the socket yet */
|
||||
#ifdef INET
|
||||
if (inp)
|
||||
in_pcbdetach(inp);
|
||||
#endif
|
||||
#ifdef INET6
|
||||
else if (in6p)
|
||||
if (in6p)
|
||||
in6_pcbdetach(in6p);
|
||||
#endif
|
||||
so->so_state |= nofd;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: udp_usrreq.c,v 1.71 2000/08/30 15:04:45 itojun Exp $ */
|
||||
/* $NetBSD: udp_usrreq.c,v 1.72 2000/10/17 03:06:44 itojun Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
|
||||
|
@ -131,10 +131,12 @@ int udpcksum = 1;
|
|||
int udpcksum = 0; /* XXX */
|
||||
#endif
|
||||
|
||||
#ifdef INET
|
||||
static void udp4_sendup __P((struct mbuf *, int, struct sockaddr *,
|
||||
struct socket *));
|
||||
static int udp4_realinput __P((struct sockaddr_in *, struct sockaddr_in *,
|
||||
struct mbuf *, int));
|
||||
#endif
|
||||
#ifdef INET6
|
||||
static void udp6_sendup __P((struct mbuf *, int, struct sockaddr *,
|
||||
struct socket *));
|
||||
|
@ -143,7 +145,9 @@ static int in6_mcmatch __P((struct in6pcb *, struct in6_addr *,
|
|||
static int udp6_realinput __P((int, struct sockaddr_in6 *,
|
||||
struct sockaddr_in6 *, struct mbuf *, int));
|
||||
#endif
|
||||
#ifdef INET
|
||||
static void udp_notify __P((struct inpcb *, int));
|
||||
#endif
|
||||
|
||||
#ifndef UDBHASHSIZE
|
||||
#define UDBHASHSIZE 128
|
||||
|
@ -154,10 +158,13 @@ void
|
|||
udp_init()
|
||||
{
|
||||
|
||||
#ifdef INET
|
||||
in_pcbinit(&udbtable, udbhashsize, udbhashsize);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef UDP6
|
||||
#ifdef INET
|
||||
void
|
||||
#if __STDC__
|
||||
udp_input(struct mbuf *m, ...)
|
||||
|
@ -310,6 +317,7 @@ bad:
|
|||
if (m)
|
||||
m_freem(m);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef INET6
|
||||
int
|
||||
|
@ -420,6 +428,7 @@ bad:
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef INET
|
||||
static void
|
||||
udp4_sendup(m, off, src, so)
|
||||
struct mbuf *m;
|
||||
|
@ -474,6 +483,7 @@ udp4_sendup(m, off, src, so)
|
|||
sorwakeup(so);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef INET6
|
||||
static void
|
||||
|
@ -520,6 +530,7 @@ udp6_sendup(m, off, src, so)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef INET
|
||||
static int
|
||||
udp4_realinput(src, dst, m, off)
|
||||
struct sockaddr_in *src;
|
||||
|
@ -656,6 +667,7 @@ udp4_realinput(src, dst, m, off)
|
|||
bad:
|
||||
return rcvcnt;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef INET6
|
||||
static int
|
||||
|
@ -1127,6 +1139,7 @@ bad:
|
|||
}
|
||||
#endif /*UDP6*/
|
||||
|
||||
#ifdef INET
|
||||
/*
|
||||
* Notify a udp user of an asynchronous error;
|
||||
* just wake up so that he can collect error status.
|
||||
|
@ -1462,3 +1475,4 @@ udp_sysctl(name, namelen, oldp, oldlenp, newp, newlen)
|
|||
}
|
||||
/* NOTREACHED */
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue