Plan 9 from Bell Labs’s /usr/web/sources/extra/9hist/port/tcpif.c

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


## diffname port/tcpif.c 1991/0424
## diff -e /dev/null /n/bootesdump/1991/0424/sys/src/9/port/tcpif.c
0a
#include	"u.h"
#include	"lib.h"
#include	"mem.h"
#include	"dat.h"
#include	"fns.h"
#include	"errno.h"
#include 	"arp.h"
#include 	"ipdat.h"

extern int tcpdbg;
#define DPRINT	if(tcpdbg) print

void
state_upcall(Ipconv *s, char oldstate, char newstate)
{
	Block *bp;
	int len;
	char *ptr = 0;

	SET(len);

	DPRINT("state_upcall: %s -> %s err %d\n", 
	      tcpstate[oldstate], tcpstate[newstate], s->err);

	if(oldstate == newstate)
		return;

	switch(newstate) {
	case CLOSED:
		s->psrc = 0;
		s->pdst = 0;
		s->dst = 0;
	case CLOSE_WAIT:		/* Remote closes */
		if(s->readq == 0)
			break;
		if(s->err) {
			ptr = errstrtab[s->err];
			len = strlen(ptr)+1;
			bp = allocb(len);
		}
		else
			bp = allocb(0);

		if(bp) {
			if(ptr) {
				strcpy((char *)bp->wptr, ptr);
				bp->wptr += len;
			}
			bp->flags |= S_DELIM;
			bp->type = M_HANGUP;
			PUTNEXT(s->readq, bp);
		}
	}
}

void
open_tcp(Ipconv *s, int mode, ushort window, char tos)
{
	Tcpctl *tcb = &s->tcpctl;

	if(tcb->state != CLOSED)
		return;

	init_tcpctl(s);

	tcb->window = tcb->rcv.wnd = window;
	tcb->tos = tos;

	switch(mode){
	case TCP_PASSIVE:
		tcb->flags |= CLONE;
		setstate(s, LISTEN);
		break;
	case TCP_ACTIVE:
		/* Send SYN, go into SYN_SENT state */
		tcb->flags |= ACTIVE;
		qlock(tcb);
		send_syn(tcb);
		setstate(s, SYN_SENT);
		tcp_output(s);
		qunlock(tcb);
		break;
	}
}
.
## diffname port/tcpif.c 1991/1014
## diff -e /n/bootesdump/1991/0424/sys/src/9/port/tcpif.c /n/bootesdump/1991/1014/sys/src/9/port/tcpif.c
57c
tcpstart(Ipconv *s, int mode, ushort window, char tos)
.
## diffname port/tcpif.c 1991/1120
## diff -e /n/bootesdump/1991/1014/sys/src/9/port/tcpif.c /n/bootesdump/1991/1120/sys/src/9/port/tcpif.c
44,52c
		bp->flags |= S_DELIM;
		bp->type = M_HANGUP;
		PUTNEXT(s->readq, bp);
		break;
.
39a
			strcpy((char *)bp->wptr, errstrtab[s->err]);
			bp->wptr += len;
.
37,38c
			len = strlen(errstrtab[s->err]);
.
35a

.
20,21d
18d
## diffname port/tcpif.c 1991/1126
## diff -e /n/bootesdump/1991/1120/sys/src/9/port/tcpif.c /n/bootesdump/1991/1126/sys/src/9/port/tcpif.c
29a
		/* NO break */
.
## diffname port/tcpif.c 1991/12171
## diff -e /n/bootesdump/1991/1126/sys/src/9/port/tcpif.c /n/bootesdump/1991/12171/sys/src/9/port/tcpif.c
74c
		setstate(s, Syn_sent);
.
67c
		setstate(s, Listen);
.
56c
	if(tcb->state != Closed)
.
31c
	case Close_wait:		/* Remote closes */
.
26c
	case Closed:
.
## diffname port/tcpif.c 1992/0111
## diff -e /n/bootesdump/1991/12171/sys/src/9/port/tcpif.c /n/bootesdump/1992/0111/sys/src/9/port/tcpif.c
38c
			strcpy((char *)bp->wptr, s->err);
.
36c
			len = strlen(s->err);
.
19c
	DPRINT("state_upcall: %s -> %s err %s\n", 
.
6c
#include	"../port/error.h"
.
## diffname port/tcpif.c 1992/0223
## diff -e /n/bootesdump/1992/0111/sys/src/9/port/tcpif.c /n/bootesdump/1992/0223/sys/src/9/port/tcpif.c
46c
		qlock(s);
		if(s->readq == 0)
			freeb(bp);
		else
			PUTNEXT(s->readq, bp);
		qunlock(s);
.
32,34d
## diffname port/tcpif.c 1992/0303
## diff -e /n/bootesdump/1992/0223/sys/src/9/port/tcpif.c /n/bootesdump/1992/0303/sys/src/9/port/tcpif.c
78a
		sleep(&tcb->syner, notsyner, tcb);
		if(tcb->state != Established && tcb->state != Syn_received)
			error(Etimedout);
.
52a
static int
notsyner(void *ic)
{
	return ((Tcpctl*)ic)->state != Syn_sent;
}
.
50a

	if(oldstate == Syn_sent)
		wakeup(&tcb->syner);
.
17a
	Tcpctl *tcb = &s->tcpctl;
.
## diffname port/tcpif.c 1992/0321
## diff -e /n/bootesdump/1992/0303/sys/src/9/port/tcpif.c /n/bootesdump/1992/0321/sys/src/9/port/tcpif.c
2c
#include	"../port/lib.h"
.
## diffname port/tcpif.c 1992/0322
## diff -e /n/bootesdump/1992/0321/sys/src/9/port/tcpif.c /n/bootesdump/1992/0322/sys/src/9/port/tcpif.c
86a
		poperror();
.
83a
		if(waserror()) {
			qunlock(tcb);
			nexterror();
		}
.
48a
		poperror();
.
44a
		if(waserror()) {
			qunlock(s);
			nexterror();
		}
.
## diffname port/tcpif.c 1992/0325
## diff -e /n/bootesdump/1992/0322/sys/src/9/port/tcpif.c /n/bootesdump/1992/0325/sys/src/9/port/tcpif.c
84a

.
66a

.
## diffname port/tcpif.c 1992/0416
## diff -e /n/bootesdump/1992/0325/sys/src/9/port/tcpif.c /n/bootesdump/1992/0416/sys/src/9/port/tcpif.c
49,51c
		if(s->readq == 0){
			if(newstate == Close_wait)
				putb(&tcb->rcvq, bp);
			else
				freeb(bp);
		} else
.
## diffname port/tcpif.c 1992/0529
## diff -e /n/bootesdump/1992/0416/sys/src/9/port/tcpif.c /n/bootesdump/1992/0529/sys/src/9/port/tcpif.c
74a
	char msg[NAMELEN+2];
.
## diffname port/tcpif.c 1992/0711
## diff -e /n/bootesdump/1992/0529/sys/src/9/port/tcpif.c /n/bootesdump/1992/0711/sys/src/9/port/tcpif.c
75d
## diffname port/tcpif.c 1992/0903
## diff -e /n/bootesdump/1992/0711/sys/src/9/port/tcpif.c /n/bootesdump/1992/0903/sys/src/9/port/tcpif.c
98,100c
		tcpsndsyn(tcb);
		tcpsetstate(s, Syn_sent);
		tcpoutput(s);
.
87c
		tcpsetstate(s, Listen);
.
49c
		if(s->readq == 0) {
.
31c

.
28c
		s->psrc = 0;		/* This connection is toast */
.
20,22d
17a
	Block *bp;
.
16d
14c
tcpxstate(Ipconv *s, char oldstate, char newstate)
.
## diffname port/tcpif.c 1992/0906
## diff -e /n/bootesdump/1992/0903/sys/src/9/port/tcpif.c /n/bootesdump/1992/0906/sys/src/9/port/tcpif.c
78c
	tcb->window = window;
	tcb->rcv.wnd = window;
.
72a
	tcb = &s->tcpctl;
.
71c
	Tcpctl *tcb;
.
22a
	tcb = &s->tcpctl;
.
18c
	Tcpctl *tcb;
.
## diffname port/tcpif.c 1992/1220
## diff -e /n/bootesdump/1992/0906/sys/src/9/port/tcpif.c /n/bootesdump/1992/1220/sys/src/9/port/tcpif.c
103c
		tsleep(&tcb->syner, notsyner, tcb, 120*1000);
.
## diffname port/tcpif.c 1993/0804 # deleted
## diff -e /n/bootesdump/1992/1220/sys/src/9/port/tcpif.c /n/fornaxdump/1993/0804/sys/src/brazil/port/tcpif.c
1,108d

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].