summaryrefslogtreecommitdiffstats
path: root/sys/netinet/tcp_usrreq.c
diff options
context:
space:
mode:
authorwollman <wollman@FreeBSD.org>1997-02-14 18:15:53 +0000
committerwollman <wollman@FreeBSD.org>1997-02-14 18:15:53 +0000
commit731964886006c63acb149497e458d29a68368332 (patch)
tree41d6953fc4c7a2929081f52e766fbc604285351b /sys/netinet/tcp_usrreq.c
parent936314fb4096f9ce1eb390ac682800ecdb6cdc5a (diff)
downloadFreeBSD-src-731964886006c63acb149497e458d29a68368332.zip
FreeBSD-src-731964886006c63acb149497e458d29a68368332.tar.gz
Fix the mechanism for choosing wehether to save the slow-start threshold
in the route. This allows us to remove the unconditional setting of the pipesize in the route, which should mean that SO_SNDBUF and SO_RCVBUF should actually work again. While we're at it: - Convert udp_usrreq from `mondo switch statement from Hell' to new-style. - Delete old TCP mondo switch statement from Hell, which had previously been diked out.
Diffstat (limited to 'sys/netinet/tcp_usrreq.c')
-rw-r--r--sys/netinet/tcp_usrreq.c317
1 files changed, 0 insertions, 317 deletions
diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c
index fdc4f12..6f02422 100644
--- a/sys/netinet/tcp_usrreq.c
+++ b/sys/netinet/tcp_usrreq.c
@@ -78,323 +78,6 @@ static struct tcpcb *
static struct tcpcb *
tcp_usrclosed __P((struct tcpcb *));
-#ifdef notdef
-/*
- * Process a TCP user request for TCP tb. If this is a send request
- * then m is the mbuf chain of send data. If this is a timer expiration
- * (called from the software clock routine), then timertype tells which timer.
- */
-/*ARGSUSED*/
-int
-tcp_usrreq(so, req, m, nam, control)
- struct socket *so;
- int req;
- struct mbuf *m, *nam, *control;
-{
- register struct inpcb *inp;
- register struct tcpcb *tp = 0;
- struct sockaddr_in *sinp;
- int s;
- int error = 0;
-#ifdef TCPDEBUG
- int ostate;
-#endif
-
- if (req == PRU_CONTROL)
- return (in_control(so, (u_long)m, (caddr_t)nam,
- (struct ifnet *)control));
- if (control && control->m_len) {
- m_freem(control);
- if (m)
- m_freem(m);
- return (EINVAL);
- }
-
- s = splnet();
- inp = sotoinpcb(so);
- /*
- * When a TCP is attached to a socket, then there will be
- * a (struct inpcb) pointed at by the socket, and this
- * structure will point at a subsidary (struct tcpcb).
- */
- if (inp == 0 && req != PRU_ATTACH) {
- splx(s);
-#if 0
- /*
- * The following corrects an mbuf leak under rare
- * circumstances, but has not been fully tested.
- */
- if (m && req != PRU_SENSE)
- m_freem(m);
-#else
- /* safer version of fix for mbuf leak */
- if (m && (req == PRU_SEND || req == PRU_SENDOOB))
- m_freem(m);
-#endif
- return (EINVAL); /* XXX */
- }
- if (inp) {
- tp = intotcpcb(inp);
- /* WHAT IF TP IS 0? */
-#ifdef KPROF
- tcp_acounts[tp->t_state][req]++;
-#endif
-#ifdef TCPDEBUG
- ostate = tp->t_state;
- } else
- ostate = 0;
-#else /* TCPDEBUG */
- }
-#endif /* TCPDEBUG */
-
- switch (req) {
-
- /*
- * TCP attaches to socket via PRU_ATTACH, reserving space,
- * and an internet control block.
- */
- case PRU_ATTACH:
- if (inp) {
- error = EISCONN;
- break;
- }
- error = tcp_attach(so);
- if (error)
- break;
- if ((so->so_options & SO_LINGER) && so->so_linger == 0)
- so->so_linger = TCP_LINGERTIME * hz;
- tp = sototcpcb(so);
- break;
-
- /*
- * PRU_DETACH detaches the TCP protocol from the socket.
- * If the protocol state is non-embryonic, then can't
- * do this directly: have to initiate a PRU_DISCONNECT,
- * which may finish later; embryonic TCB's can just
- * be discarded here.
- */
- case PRU_DETACH:
- if (tp->t_state > TCPS_LISTEN)
- tp = tcp_disconnect(tp);
- else
- tp = tcp_close(tp);
- break;
-
- /*
- * Give the socket an address.
- */
- case PRU_BIND:
- /*
- * Must check for multicast addresses and disallow binding
- * to them.
- */
- sinp = mtod(nam, struct sockaddr_in *);
- if (sinp->sin_family == AF_INET &&
- IN_MULTICAST(ntohl(sinp->sin_addr.s_addr))) {
- error = EAFNOSUPPORT;
- break;
- }
- error = in_pcbbind(inp, nam);
- if (error)
- break;
- break;
-
- /*
- * Prepare to accept connections.
- */
- case PRU_LISTEN:
- if (inp->inp_lport == 0)
- error = in_pcbbind(inp, NULL);
- if (error == 0)
- tp->t_state = TCPS_LISTEN;
- break;
-
- /*
- * Initiate connection to peer.
- * Create a template for use in transmissions on this connection.
- * Enter SYN_SENT state, and mark socket as connecting.
- * Start keep-alive timer, and seed output sequence space.
- * Send initial segment on connection.
- */
- case PRU_CONNECT:
- /*
- * Must disallow TCP ``connections'' to multicast addresses.
- */
- sinp = mtod(nam, struct sockaddr_in *);
- if (sinp->sin_family == AF_INET
- && IN_MULTICAST(ntohl(sinp->sin_addr.s_addr))) {
- error = EAFNOSUPPORT;
- break;
- }
-
- if ((error = tcp_connect(tp, nam)) != 0)
- break;
- error = tcp_output(tp);
- break;
-
- /*
- * Create a TCP connection between two sockets.
- */
- case PRU_CONNECT2:
- error = EOPNOTSUPP;
- break;
-
- /*
- * Initiate disconnect from peer.
- * If connection never passed embryonic stage, just drop;
- * else if don't need to let data drain, then can just drop anyways,
- * else have to begin TCP shutdown process: mark socket disconnecting,
- * drain unread data, state switch to reflect user close, and
- * send segment (e.g. FIN) to peer. Socket will be really disconnected
- * when peer sends FIN and acks ours.
- *
- * SHOULD IMPLEMENT LATER PRU_CONNECT VIA REALLOC TCPCB.
- */
- case PRU_DISCONNECT:
- tp = tcp_disconnect(tp);
- break;
-
- /*
- * Accept a connection. Essentially all the work is
- * done at higher levels; just return the address
- * of the peer, storing through addr.
- */
- case PRU_ACCEPT:
- in_setpeeraddr(inp, nam);
- break;
-
- /*
- * Mark the connection as being incapable of further output.
- */
- case PRU_SHUTDOWN:
- socantsendmore(so);
- tp = tcp_usrclosed(tp);
- if (tp)
- error = tcp_output(tp);
- break;
-
- /*
- * After a receive, possibly send window update to peer.
- */
- case PRU_RCVD:
- (void) tcp_output(tp);
- break;
-
- /*
- * Do a send by putting data in output queue and updating urgent
- * marker if URG set. Possibly send more data.
- */
- case PRU_SEND_EOF:
- case PRU_SEND:
- sbappend(&so->so_snd, m);
- if (nam && tp->t_state < TCPS_SYN_SENT) {
- /*
- * Do implied connect if not yet connected,
- * initialize window to default value, and
- * initialize maxseg/maxopd using peer's cached
- * MSS.
- */
- error = tcp_connect(tp, nam);
- if (error)
- break;
- tp->snd_wnd = TTCP_CLIENT_SND_WND;
- tcp_mss(tp, -1);
- }
-
- if (req == PRU_SEND_EOF) {
- /*
- * Close the send side of the connection after
- * the data is sent.
- */
- socantsendmore(so);
- tp = tcp_usrclosed(tp);
- }
- if (tp != NULL)
- error = tcp_output(tp);
- break;
-
- /*
- * Abort the TCP.
- */
- case PRU_ABORT:
- tp = tcp_drop(tp, ECONNABORTED);
- break;
-
- case PRU_SENSE:
- ((struct stat *) m)->st_blksize = so->so_snd.sb_hiwat;
- (void) splx(s);
- return (0);
-
- case PRU_RCVOOB:
- if ((so->so_oobmark == 0 &&
- (so->so_state & SS_RCVATMARK) == 0) ||
- so->so_options & SO_OOBINLINE ||
- tp->t_oobflags & TCPOOB_HADDATA) {
- error = EINVAL;
- break;
- }
- if ((tp->t_oobflags & TCPOOB_HAVEDATA) == 0) {
- error = EWOULDBLOCK;
- break;
- }
- m->m_len = 1;
- *mtod(m, caddr_t) = tp->t_iobc;
- if (((int)nam & MSG_PEEK) == 0)
- tp->t_oobflags ^= (TCPOOB_HAVEDATA | TCPOOB_HADDATA);
- break;
-
- case PRU_SENDOOB:
- if (sbspace(&so->so_snd) < -512) {
- m_freem(m);
- error = ENOBUFS;
- break;
- }
- /*
- * According to RFC961 (Assigned Protocols),
- * the urgent pointer points to the last octet
- * of urgent data. We continue, however,
- * to consider it to indicate the first octet
- * of data past the urgent section.
- * Otherwise, snd_up should be one lower.
- */
- sbappend(&so->so_snd, m);
- tp->snd_up = tp->snd_una + so->so_snd.sb_cc;
- tp->t_force = 1;
- error = tcp_output(tp);
- tp->t_force = 0;
- break;
-
- case PRU_SOCKADDR:
- in_setsockaddr(inp, nam);
- break;
-
- case PRU_PEERADDR:
- in_setpeeraddr(inp, nam);
- break;
-
- /*
- * TCP slow timer went off; going through this
- * routine for tracing's sake.
- */
- case PRU_SLOWTIMO:
- tp = tcp_timers(tp, (int)nam);
-#ifdef TCPDEBUG
- req |= (int)nam << 8; /* for debug's sake */
-#endif
- break;
-
- default:
- panic("tcp_usrreq");
- }
-#ifdef TCPDEBUG
- if (tp && (so->so_options & SO_DEBUG))
- tcp_trace(TA_USER, ostate, tp, (struct tcpiphdr *)0, req);
-#endif
- splx(s);
- return (error);
-}
-#endif
-
#ifdef TCPDEBUG
#define TCPDEBUG0 int ostate
#define TCPDEBUG1() ostate = tp ? tp->t_state : 0
OpenPOWER on IntegriCloud