summaryrefslogtreecommitdiffstats
path: root/sys/netinet/tcp_usrreq.c
diff options
context:
space:
mode:
authorbz <bz@FreeBSD.org>2011-04-30 11:21:29 +0000
committerbz <bz@FreeBSD.org>2011-04-30 11:21:29 +0000
commited602831238c2905aa44f0297078f3e72c88b717 (patch)
tree323517c1065faea8844fb601613c16c72f091e61 /sys/netinet/tcp_usrreq.c
parentad795d2c5d13224f9b5bfefa5f6896ff66db16a0 (diff)
downloadFreeBSD-src-ed602831238c2905aa44f0297078f3e72c88b717.zip
FreeBSD-src-ed602831238c2905aa44f0297078f3e72c88b717.tar.gz
Make the TCP code compile without INET. Sort #includes and add #ifdef INETs.
Add some comments at #endifs given more nestedness. To make the compiler happy, some default initializations were added in accordance with the style on the files. Reviewed by: gnn Sponsored by: The FreeBSD Foundation Sponsored by: iXsystems MFC after: 4 days
Diffstat (limited to 'sys/netinet/tcp_usrreq.c')
-rw-r--r--sys/netinet/tcp_usrreq.c52
1 files changed, 39 insertions, 13 deletions
diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c
index 6acf9da..318fe27 100644
--- a/sys/netinet/tcp_usrreq.c
+++ b/sys/netinet/tcp_usrreq.c
@@ -64,17 +64,13 @@ __FBSDID("$FreeBSD$");
#include <netinet/cc.h>
#include <netinet/in.h>
-#include <netinet/in_systm.h>
-#ifdef INET6
-#include <netinet/ip6.h>
-#endif
#include <netinet/in_pcb.h>
-#ifdef INET6
-#include <netinet6/in6_pcb.h>
-#endif
+#include <netinet/in_systm.h>
#include <netinet/in_var.h>
#include <netinet/ip_var.h>
#ifdef INET6
+#include <netinet/ip6.h>
+#include <netinet6/in6_pcb.h>
#include <netinet6/ip6_var.h>
#include <netinet6/scope6_var.h>
#endif
@@ -92,8 +88,10 @@ __FBSDID("$FreeBSD$");
* TCP protocol interface to socket abstraction.
*/
static int tcp_attach(struct socket *);
+#ifdef INET
static int tcp_connect(struct tcpcb *, struct sockaddr *,
struct thread *td);
+#endif /* INET */
#ifdef INET6
static int tcp6_connect(struct tcpcb *, struct sockaddr *,
struct thread *td);
@@ -229,6 +227,7 @@ tcp_usr_detach(struct socket *so)
INP_INFO_WUNLOCK(&V_tcbinfo);
}
+#ifdef INET
/*
* Give the socket an address.
*/
@@ -270,6 +269,7 @@ out:
return (error);
}
+#endif /* INET */
#ifdef INET6
static int
@@ -304,6 +304,7 @@ tcp6_usr_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
TCPDEBUG1();
inp->inp_vflag &= ~INP_IPV4;
inp->inp_vflag |= INP_IPV6;
+#ifdef INET
if ((inp->inp_flags & IN6P_IPV6_V6ONLY) == 0) {
if (IN6_IS_ADDR_UNSPECIFIED(&sin6p->sin6_addr))
inp->inp_vflag |= INP_IPV4;
@@ -318,6 +319,7 @@ tcp6_usr_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
goto out;
}
}
+#endif
error = in6_pcbbind(inp, nam, td->td_ucred);
out:
TCPDEBUG2(PRU_BIND);
@@ -327,6 +329,7 @@ out:
}
#endif /* INET6 */
+#ifdef INET
/*
* Prepare to accept connections.
*/
@@ -365,6 +368,7 @@ out:
INP_INFO_WUNLOCK(&V_tcbinfo);
return (error);
}
+#endif /* INET */
#ifdef INET6
static int
@@ -407,6 +411,7 @@ out:
}
#endif /* INET6 */
+#ifdef INET
/*
* Initiate connection to peer.
* Create a template for use in transmissions on this connection.
@@ -454,6 +459,7 @@ out:
INP_INFO_WUNLOCK(&V_tcbinfo);
return (error);
}
+#endif /* INET */
#ifdef INET6
static int
@@ -486,6 +492,7 @@ tcp6_usr_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
}
tp = intotcpcb(inp);
TCPDEBUG1();
+#ifdef INET
if (IN6_IS_ADDR_V4MAPPED(&sin6p->sin6_addr)) {
struct sockaddr_in sin;
@@ -505,6 +512,7 @@ tcp6_usr_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
error = tcp_output_connect(so, nam);
goto out;
}
+#endif
inp->inp_vflag &= ~INP_IPV4;
inp->inp_vflag |= INP_IPV6;
inp->inp_inc.inc_flags |= INC_ISIPV6;
@@ -559,6 +567,7 @@ out:
return (error);
}
+#ifdef INET
/*
* Accept a connection. Essentially all the work is done at higher levels;
* just return the address of the peer, storing through addr.
@@ -610,6 +619,7 @@ out:
*nam = in_sockaddr(port, &addr);
return error;
}
+#endif /* INET */
#ifdef INET6
static int
@@ -799,9 +809,13 @@ tcp_usr_send(struct socket *so, int flags, struct mbuf *m,
#ifdef INET6
if (isipv6)
error = tcp6_connect(tp, nam, td);
- else
#endif /* INET6 */
- error = tcp_connect(tp, nam, td);
+#if defined(INET6) && defined(INET)
+ else
+#endif
+#ifdef INET
+ error = tcp_connect(tp, nam, td);
+#endif
if (error)
goto out;
tp->snd_wnd = TTCP_CLIENT_SND_WND;
@@ -859,9 +873,13 @@ tcp_usr_send(struct socket *so, int flags, struct mbuf *m,
#ifdef INET6
if (isipv6)
error = tcp6_connect(tp, nam, td);
- else
#endif /* INET6 */
- error = tcp_connect(tp, nam, td);
+#if defined(INET6) && defined(INET)
+ else
+#endif
+#ifdef INET
+ error = tcp_connect(tp, nam, td);
+#endif
if (error)
goto out;
tp->snd_wnd = TTCP_CLIENT_SND_WND;
@@ -1005,6 +1023,7 @@ out:
return (error);
}
+#ifdef INET
struct pr_usrreqs tcp_usrreqs = {
.pru_abort = tcp_usr_abort,
.pru_accept = tcp_usr_accept,
@@ -1024,6 +1043,7 @@ struct pr_usrreqs tcp_usrreqs = {
.pru_sosetlabel = in_pcbsosetlabel,
.pru_close = tcp_usr_close,
};
+#endif /* INET */
#ifdef INET6
struct pr_usrreqs tcp6_usrreqs = {
@@ -1047,6 +1067,7 @@ struct pr_usrreqs tcp6_usrreqs = {
};
#endif /* INET6 */
+#ifdef INET
/*
* Common subroutine to open a TCP connection to remote host specified
* by struct sockaddr_in in mbuf *nam. Call in_pcbbind to assign a local
@@ -1109,6 +1130,7 @@ tcp_connect(struct tcpcb *tp, struct sockaddr *nam, struct thread *td)
return 0;
}
+#endif /* INET */
#ifdef INET6
static int
@@ -1257,11 +1279,15 @@ tcp_ctloutput(struct socket *so, struct sockopt *sopt)
if (inp->inp_vflag & INP_IPV6PROTO) {
INP_WUNLOCK(inp);
error = ip6_ctloutput(so, sopt);
- } else {
+ }
#endif /* INET6 */
+#if defined(INET6) && defined(INET)
+ else
+#endif
+#ifdef INET
+ {
INP_WUNLOCK(inp);
error = ip_ctloutput(so, sopt);
-#ifdef INET6
}
#endif
return (error);
OpenPOWER on IntegriCloud