SCCS-vsn: sys/netinet/tcp_input.c 1.87
SCCS-vsn: sys/netinet/tcp_subr.c 4.39
SCCS-vsn: sys/netinet/tcp_timer.c 4.30
SCCS-vsn: sys/netinet/tcp_usrreq.c 1.73
SCCS-vsn: sys/netinet/tcp_var.h 4.18
-/* tcp_input.c 1.86 83/01/08 */
+/* tcp_input.c 1.87 83/01/17 */
#include "../h/param.h"
#include "../h/systm.h"
#include "../h/param.h"
#include "../h/systm.h"
SEQ_GT(ti->ti_ack, tp->snd_max)))
goto dropwithreset;
if (tiflags & TH_RST) {
SEQ_GT(ti->ti_ack, tp->snd_max)))
goto dropwithreset;
if (tiflags & TH_RST) {
- if (tiflags & TH_ACK) {
- tcp_drop(tp, ECONNREFUSED);
- tp = 0;
- }
+ if (tiflags & TH_ACK)
+ tp = tcp_drop(tp, ECONNREFUSED);
goto drop;
}
if ((tiflags & TH_SYN) == 0)
goto drop;
}
if ((tiflags & TH_SYN) == 0)
* If data is received on a connection after the
* user processes are gone, then RST the other end.
*/
* If data is received on a connection after the
* user processes are gone, then RST the other end.
*/
- if (so->so_state & SS_NOFDREF && tp->t_state > TCPS_CLOSE_WAIT &&
+ if ((so->so_state & SS_NOFDREF) && tp->t_state > TCPS_CLOSE_WAIT &&
- tcp_close(tp);
- tp = 0;
if (tiflags&TH_RST) switch (tp->t_state) {
case TCPS_SYN_RECEIVED:
if (tiflags&TH_RST) switch (tp->t_state) {
case TCPS_SYN_RECEIVED:
- tcp_drop(tp, ECONNREFUSED);
- tp = 0;
+ tp = tcp_drop(tp, ECONNREFUSED);
goto drop;
case TCPS_ESTABLISHED:
case TCPS_FIN_WAIT_1:
case TCPS_FIN_WAIT_2:
case TCPS_CLOSE_WAIT:
goto drop;
case TCPS_ESTABLISHED:
case TCPS_FIN_WAIT_1:
case TCPS_FIN_WAIT_2:
case TCPS_CLOSE_WAIT:
- tcp_drop(tp, ECONNRESET);
- tp = 0;
+ tp = tcp_drop(tp, ECONNRESET);
goto drop;
case TCPS_CLOSING:
case TCPS_LAST_ACK:
case TCPS_TIME_WAIT:
goto drop;
case TCPS_CLOSING:
case TCPS_LAST_ACK:
case TCPS_TIME_WAIT:
- tcp_close(tp);
- tp = 0;
* error and we send an RST and drop the connection.
*/
if (tiflags & TH_SYN) {
* error and we send an RST and drop the connection.
*/
if (tiflags & TH_SYN) {
- tcp_drop(tp, ECONNRESET);
- tp = 0;
+ tp = tcp_drop(tp, ECONNRESET);
* and return.
*/
case TCPS_LAST_ACK:
* and return.
*/
case TCPS_LAST_ACK:
- if (ourfinisacked) {
- tcp_close(tp);
- tp = 0;
- }
+ if (ourfinisacked)
+ tp = tcp_close(tp);
-/* tcp_subr.c 4.38 83/01/04 */
+/* tcp_subr.c 4.39 83/01/17 */
#include "../h/param.h"
#include "../h/systm.h"
#include "../h/param.h"
#include "../h/systm.h"
* the specified error. If connection is synchronized,
* then send a RST to peer.
*/
* the specified error. If connection is synchronized,
* then send a RST to peer.
*/
+ register struct tcpcb *tp;
int errno;
{
struct socket *so = tp->t_inpcb->inp_socket;
int errno;
{
struct socket *so = tp->t_inpcb->inp_socket;
(void) tcp_output(tp);
}
so->so_error = errno;
(void) tcp_output(tp);
}
so->so_error = errno;
+ return (tcp_close(tp));
}
tcp_abort(inp)
struct inpcb *inp;
{
}
tcp_abort(inp)
struct inpcb *inp;
{
- tcp_close((struct tcpcb *)inp->inp_ppcb);
+ (void) tcp_close((struct tcpcb *)inp->inp_ppcb);
* discard internet protocol block
* wake up any sleepers
*/
* discard internet protocol block
* wake up any sleepers
*/
tcp_close(tp)
register struct tcpcb *tp;
{
tcp_close(tp)
register struct tcpcb *tp;
{
inp->inp_ppcb = 0;
soisdisconnected(so);
in_pcbdetach(inp);
inp->inp_ppcb = 0;
soisdisconnected(so);
in_pcbdetach(inp);
+ return ((struct tcpcb *)0);
-/* tcp_timer.c 4.29 83/01/04 */
+/* tcp_timer.c 4.30 83/01/17 */
#include "../h/param.h"
#include "../h/systm.h"
#include "../h/param.h"
#include "../h/systm.h"
/*
* TCP timer processing.
*/
/*
* TCP timer processing.
*/
tcp_timers(tp, timer)
register struct tcpcb *tp;
int timer;
tcp_timers(tp, timer)
register struct tcpcb *tp;
int timer;
* control block.
*/
case TCPT_2MSL:
* control block.
*/
case TCPT_2MSL:
- tcp_close(tp);
- return;
+ tp = tcp_close(tp);
+ break;
/*
* Retransmission timer went off. Message has not
/*
* Retransmission timer went off. Message has not
case TCPT_REXMT:
tp->t_rxtshift++;
if (tp->t_rxtshift > TCP_MAXRXTSHIFT) {
case TCPT_REXMT:
tp->t_rxtshift++;
if (tp->t_rxtshift > TCP_MAXRXTSHIFT) {
- tcp_drop(tp, ETIMEDOUT);
- return;
+ tp = tcp_drop(tp, ETIMEDOUT);
+ break;
}
TCPT_RANGESET(tp->t_timer[TCPT_REXMT],
(int)tp->t_srtt, TCPTV_MIN, TCPTV_MAX);
}
TCPT_RANGESET(tp->t_timer[TCPT_REXMT],
(int)tp->t_srtt, TCPTV_MIN, TCPTV_MAX);
tp->snd_nxt = tp->snd_una;
/* this only transmits one segment! */
(void) tcp_output(tp);
tp->snd_nxt = tp->snd_una;
/* this only transmits one segment! */
(void) tcp_output(tp);
/*
* Persistance timer into zero window.
/*
* Persistance timer into zero window.
tp->t_force = 1;
(void) tcp_output(tp);
tp->t_force = 0;
tp->t_force = 1;
(void) tcp_output(tp);
tp->t_force = 0;
/*
* Keep-alive timer went off; send something
/*
* Keep-alive timer went off; send something
} else
tp->t_idle = 0;
tp->t_timer[TCPT_KEEP] = TCPTV_KEEP;
} else
tp->t_idle = 0;
tp->t_timer[TCPT_KEEP] = TCPTV_KEEP;
- tcp_drop(tp, ETIMEDOUT);
- return;
+ tp = tcp_drop(tp, ETIMEDOUT);
+ break;
-/* tcp_usrreq.c 1.72 83/01/13 */
+/* tcp_usrreq.c 1.73 83/01/17 */
#include "../h/param.h"
#include "../h/systm.h"
#include "../h/param.h"
#include "../h/systm.h"
error = tcp_attach(so);
if (error)
break;
error = tcp_attach(so);
if (error)
break;
- if (so->so_options & SO_LINGER && so->so_linger == 0)
+ if ((so->so_options & SO_LINGER) && so->so_linger == 0)
so->so_linger = TCP_LINGERTIME;
tp = sototcpcb(so);
break;
so->so_linger = TCP_LINGERTIME;
tp = sototcpcb(so);
break;
*/
case PRU_DETACH:
if (tp->t_state > TCPS_LISTEN)
*/
case PRU_DETACH:
if (tp->t_state > TCPS_LISTEN)
- tcp_disconnect(tp);
- else {
- tcp_close(tp);
- tp = 0;
- }
+ tp = tcp_disconnect(tp);
+ else
+ tp = tcp_close(tp);
* SHOULD IMPLEMENT LATER PRU_CONNECT VIA REALLOC TCPCB.
*/
case PRU_DISCONNECT:
* SHOULD IMPLEMENT LATER PRU_CONNECT VIA REALLOC TCPCB.
*/
case PRU_DISCONNECT:
+ tp = tcp_disconnect(tp);
*/
case PRU_SHUTDOWN:
socantsendmore(so);
*/
case PRU_SHUTDOWN:
socantsendmore(so);
- tcp_usrclosed(tp);
- error = tcp_output(tp);
+ tp = tcp_usrclosed(tp);
+ if (tp)
+ error = tcp_output(tp);
* Abort the TCP.
*/
case PRU_ABORT:
* Abort the TCP.
*/
case PRU_ABORT:
- tcp_drop(tp, ECONNABORTED);
+ tp = tcp_drop(tp, ECONNABORTED);
break;
/* SOME AS YET UNIMPLEMENTED HOOKS */
break;
/* SOME AS YET UNIMPLEMENTED HOOKS */
* routine for tracing's sake.
*/
case PRU_SLOWTIMO:
* routine for tracing's sake.
*/
case PRU_SLOWTIMO:
- tcp_timers(tp, (int)nam);
+ tp = tcp_timers(tp, (int)nam);
req |= (int)nam << 8; /* for debug's sake */
break;
req |= (int)nam << 8; /* for debug's sake */
break;
* current input data; switch states based on user close, and
* send segment to peer (with FIN).
*/
* current input data; switch states based on user close, and
* send segment to peer (with FIN).
*/
+ register struct tcpcb *tp;
{
struct socket *so = tp->t_inpcb->inp_socket;
if (tp->t_state < TCPS_ESTABLISHED)
{
struct socket *so = tp->t_inpcb->inp_socket;
if (tp->t_state < TCPS_ESTABLISHED)
else if (so->so_linger == 0)
else if (so->so_linger == 0)
else {
soisdisconnecting(so);
sbflush(&so->so_rcv);
else {
soisdisconnecting(so);
sbflush(&so->so_rcv);
- tcp_usrclosed(tp);
- (void) tcp_output(tp);
+ tp = tcp_usrclosed(tp);
+ if (tp)
+ (void) tcp_output(tp);
* for peer to send FIN or not respond to keep-alives, etc.
* We can let the user exit from the close as soon as the FIN is acked.
*/
* for peer to send FIN or not respond to keep-alives, etc.
* We can let the user exit from the close as soon as the FIN is acked.
*/
+ register struct tcpcb *tp;
case TCPS_LISTEN:
case TCPS_SYN_SENT:
tp->t_state = TCPS_CLOSED;
case TCPS_LISTEN:
case TCPS_SYN_SENT:
tp->t_state = TCPS_CLOSED;
break;
case TCPS_SYN_RECEIVED:
break;
case TCPS_SYN_RECEIVED:
tp->t_state = TCPS_LAST_ACK;
break;
}
tp->t_state = TCPS_LAST_ACK;
break;
}
- if (tp->t_state >= TCPS_FIN_WAIT_2)
+ if (tp && tp->t_state >= TCPS_FIN_WAIT_2)
soisdisconnected(tp->t_inpcb->inp_socket);
soisdisconnected(tp->t_inpcb->inp_socket);
-/* tcp_var.h 4.17 82/12/20 */
+/* tcp_var.h 4.18 83/01/17 */
/*
* Kernel variables for tcp.
/*
* Kernel variables for tcp.
struct inpcb tcb; /* head of queue of active tcpcb's */
struct tcpstat tcpstat; /* tcp statistics */
struct tcpiphdr *tcp_template();
struct inpcb tcb; /* head of queue of active tcpcb's */
struct tcpstat tcpstat; /* tcp statistics */
struct tcpiphdr *tcp_template();
+struct tcpcb *tcp_close(), *tcp_drop();
+struct tcpcb *tcp_timers(), *tcp_disconnect(), *tcp_usrclosed();