tcpwr.c,v

来自「TCP-IP红宝书源代码」· C,V 代码 · 共 87 行

C,V
87
字号
head	1.2;
access;
symbols;
locks
	dls:1.2; strict;
comment	@ * @;


1.2
date	97.09.21.19.30.11;	author dls;	state Dist;
branches;
next	1.1;

1.1
date	94.01.14.04.11.50;	author dls;	state v2e1;
branches;
next	;


desc
@@


1.2
log
@pre-3e code
@
text
@/* tcpwr.c - tcpwr */

#include <conf.h>
#include <kernel.h>
#include <proc.h>
#include <network.h>

/*------------------------------------------------------------------------
 *  tcpwr  -  write urgent and normal data to TCP buffers
 *------------------------------------------------------------------------
 */
int tcpwr(pdev, pch, len, isurg)
struct	devsw	*pdev;
char		*pch;
int		len;
Bool		isurg;
{
	struct	tcb	*ptcb = (struct tcb *)pdev->dvioblk;
	int		state = ptcb->tcb_state;
	int		sboff, tocopy;

	if (state != TCPS_ESTABLISHED && state != TCPS_CLOSEWAIT)
		return SYSERR;
	tocopy = tcpgetspace(ptcb, len);	/* acquires tcb_mutex	*/
	if (tocopy <= 0)
		return tocopy;
	sboff = (ptcb->tcb_sbstart+ptcb->tcb_sbcount) % ptcb->tcb_sbsize;
	if (isurg) {
		ptcb->tcb_supseq = ptcb->tcb_snext + len - 1;
		ptcb->tcb_flags |= TCBF_SUPOK;
	}
	while (tocopy--) {
		ptcb->tcb_sndbuf[sboff] = *pch++;
		++ptcb->tcb_sbcount;
		if (++sboff >= ptcb->tcb_sbsize)
			sboff = 0;
	}
	ptcb->tcb_flags |= TCBF_NEEDOUT;
	tcpwakeup(WRITERS, ptcb);
	signal(ptcb->tcb_mutex);

	if (isurg || ptcb->tcb_snext == ptcb->tcb_suna)
		tcpkick(ptcb);
	return len;
}
@


1.1
log
@Initial revision
@
text
@d28 4
a31 2
	if (isurg)
		len = tcpwurg(ptcb, sboff, len);
@

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?