- }
- splx(s);
-}
-
-/*
- * Open routine, called to initialize newly created tcb fields.
- */
-tcp_open(tp, mode)
- register struct tcb *tp;
- int mode;
-{
- register struct ucb *up = tp->t_ucb;
-COUNT(TCP_OPEN);
-
- /*
- * Link in tcb queue and make
- * initialize empty reassembly queue.
- */
- tp->tcb_next = tcb.tcb_next;
- tcb.tcb_next->tcb_prev = tp;
- tp->tcb_prev = (struct tcb *)&tcb;
- tcb.tcb_next = tp;
- tp->t_rcv_next = tp->t_rcv_prev = (struct th *)tp;
-
- /*
- * Initialize sequence numbers and
- * round trip retransmit timer.
- * (Other fields were init'd to zero when tcb allocated.)
- */
- 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;
-
- /*
- * Set timeout for open.
- * SHOULD THIS BE A HIGHER LEVEL FUNCTION!?! THINK SO.
- */
- if (up->uc_timeo)
- tp->t_init = up->uc_timeo;
- else if (mode == ACTIVE)
- tp->t_init = T_INIT;
- /* else
- tp->t_init = 0; */
- up->uc_timeo = 0; /* ### */
-}
-
-/*
- * Internal close of a connection, shutting down the tcb.
- */
-tcp_close(tp, state)
- register struct tcb *tp;
- short state;
-{
- register struct ucb *up = tp->t_ucb;
- register struct th *t;
- register struct mbuf *m;
-COUNT(TCP_CLOSE);
-
- /*
- * Cancel all timers.
- * SHOULD LOOP HERE !?!
- */
- tp->t_init = tp->t_rexmt = tp->t_rexmttl = tp->t_persist =
- tp->t_finack = 0;
-
- /*
- * Remque the tcb
- */
- tp->tcb_prev->tcb_next = tp->tcb_next;
- tp->tcb_next->tcb_prev = tp->tcb_prev;
-
- /*
- * Discard all buffers...
- *
- * SHOULD COUNT EACH RESOURCE TO 0 AND PANIC IF CONFUSED
- */
- for (t = tp->t_rcv_next; t != (struct th *)tp; t = t->t_next)
- m_freem(dtom(t));
- if (up->uc_rbuf != NULL) {
- m_freem(up->uc_rbuf);
- up->uc_rbuf = NULL;
- }
- up->uc_rcc = 0;
- if (up->uc_sbuf != NULL) {
- m_freem(up->uc_sbuf);
- up->uc_sbuf = NULL;
- }
- up->uc_ssize = 0;
- for (m = tp->t_rcv_unack; m != NULL; m = m->m_act) {
- m_freem(m);
- tp->t_rcv_unack = NULL;
- }
-
- /*
- * Free tcp send template.
- */
- if (up->uc_template) {
- m_free(dtom(up->uc_template));
- up->uc_template = 0;
- }
-
- /*
- * Free the tcb
- * WOULD THIS BETTER BE DONE AT USER CLOSE?
- */
- wmemfree((caddr_t)tp, 1024);
- up->uc_tcb = NULL;