-
-struct tcpcb *
-tcp_newtcpcb(inp)
- struct inpcb *inp;
-{
- struct mbuf *m = m_getclr(0);
- register struct tcpcb *tp;
-COUNT(TCP_NEWTCPCB);
-
- if (m == 0)
- return (0);
- tp = mtod(m, struct tcpcb *);
-
- /*
- * Make empty reassembly queue.
- */
- tp->seg_next = tp->seg_prev = (struct tcpiphdr *)tp;
-
- /*
- * Initialize sequence numbers and round trip retransmit timer.
- */
- tp->t_xmtime = T_REXMT;
- tp->snd_end = tp->seq_fin = tp->snd_nxt = tp->snd_hi = tp->snd_una =
- tp->iss = tcp_iss;
- tp->snd_off = tp->iss + 1;
- tcp_iss += (ISSINCR >> 1) + 1;
-
- /*
- * Hook to inpcb.
- */
- tp->t_inpcb = inp;
- inp->inp_ppcb = (caddr_t)tp;
- return (tp);
-}
-
-tcp_disconnect(tp)
- register struct tcpcb *tp;
-{
- register struct tcpiphdr *t;
-
-COUNT(TCP_DISCONNECT);
- tcp_tcancel(tp);
- t = tp->seg_next;
- for (; t != (struct tcpiphdr *)tp; t = (struct tcpiphdr *)t->ti_next)
- m_freem(dtom(t));
- tcp_drainunack(tp);
- if (tp->t_template) {
- (void) m_free(dtom(tp->t_template));
- tp->t_template = 0;
- }
- in_pcbfree(tp->t_inpcb);
- (void) m_free(dtom(tp));
-}
-
-tcp_abort(tp)
- register struct tcpcb *tp;
-{
-
-COUNT(TCP_ABORT);
- switch (tp->t_state) {
-
- case SYN_RCVD:
- case ESTAB:
- case FIN_W1:
- case FIN_W2:
- case CLOSE_WAIT:
- tp->tc_flags |= TC_SND_RST;
- tcp_sndnull(tp);
- }
- soisdisconnected(tp->t_inpcb->inp_socket);
- tcp_disconnect(tp);
-}
-
-/*
- * Send data queue headed by m0 into the protocol.
- */
-tcp_usrsend(tp, m0)
- register struct tcpcb *tp;
- struct mbuf *m0;
-{
- register struct socket *so = tp->t_inpcb->inp_socket;
-COUNT(TCP_USRSEND);
-
- sbappend(&so->so_snd, m0);
- if (tp->t_options & TO_EOL)
- tp->snd_end = tp->snd_off + so->so_snd.sb_cc;
- if (tp->t_options & TO_URG) {
- tp->snd_urp = tp->snd_off + so->so_snd.sb_cc + 1;
- tp->tc_flags |= TC_SND_URG;
- }
- (void) tcp_send(tp);
-}
-
-/*ARGSUSED*/
-tcp_sense(m)
- struct mbuf *m;
-{
-
-COUNT(TCP_SENSE);
- return (EOPNOTSUPP);
-}
-
-tcp_drop(tp, errno)
- struct tcpcb *tp;
- int errno;
-{
- struct socket *so = tp->t_inpcb->inp_socket;
-
-COUNT(TCP_ERROR);
- so->so_error = errno;
- sorwakeup(so);
- sowwakeup(so);
- tcp_disconnect(tp);
-}
-
-tcp_drain()
-{
- register struct inpcb *ip;
-
-COUNT(TCP_DRAIN);
- for (ip = tcb.inp_next; ip != &tcb; ip = ip->inp_next)
- tcp_drainunack(intotcpcb(ip));
-}
-
-tcp_drainunack(tp)
- register struct tcpcb *tp;
-{
- register struct mbuf *m;
-
-COUNT(TCP_DRAINUNACK);
- for (m = tp->seg_unack; m; m = m->m_act)
- m_freem(m);
- tp->seg_unack = 0;
-}
-
-tcp_ctlinput(m)
- struct mbuf *m;
-{
-
-COUNT(TCP_CTLINPUT);
- m_freem(m);
-}