othwrite.c,v

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

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


1.1
date	97.09.21.19.27.59;	author dls;	state Dist;
branches;
next	;


desc
@@


1.1
log
@pre-3e code
@
text
@/* othwrite.c - othwrite */


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

#if Noth > 0

/*------------------------------------------------------------------------
 *  othwrite - write a single packet to the ethernet
 *------------------------------------------------------------------------
 */
int othwrite(devptr, pep, len)
struct	devsw	*devptr;
struct	ep	*pep;
int	len;
{
	STATWORD ps;
        struct	otblk	*otptr;
        struct	etblk	*etptr;

	if (len > EP_MAXLEN) {
		freebuf(pep);
		return SYSERR;
	}
	/* subtract the local header */
	len -= (int)&pep->ep_eh - (int)pep;

	if (len < EP_MINLEN)
		len = EP_MINLEN;

	otptr = (struct otblk *)devptr->dvioblk;
	blkcopy(pep->ep_src, otptr->ot_paddr, EP_ALEN);
	etptr = (struct etblk *)devtab[otptr->ot_pdev].dvioblk;

#ifdef	DEBUG
	if (pep->ep_type == EPT_IP)
	{
		struct ip *pip = (struct ip *)pep->ep_data;
		if (pip->ip_proto == IPT_TCP) {
			kprintf("othwrite(%X, %d)\n", pep, len);
			pdump(pep);
		}
	}
#endif	/* DEBUG */
	pep->ep_len = len;
	if (enq(etptr->etoutq, pep, 0) < 0) {
		freebuf(pep);
		return SYSERR;
	}
	ethwstrt(etptr);
	return OK;
}
#endif /* Noth > 0 */
@

⌨️ 快捷键说明

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