ethwrite.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.26.05;	author dls;	state Dist;
branches;
next	;


desc
@@


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

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

#include <ospf.h>

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

	etptr = (struct etblk *)devptr->dvioblk;
	if (len > EP_MAXLEN) {
		nif[etptr->etintf].ni_odiscard++;
		freebuf(pep);
		return SYSERR;
	}
	/* subtract the local header */
	len -= (int)&pep->ep_eh - (int)pep;
	if (len < EP_MINLEN)
		len = EP_MINLEN;
	blkcopy(pep->ep_src, etptr->etpaddr, EP_ALEN);
	pep->ep_len = len;
	pep->ep_type = hs2net(pep->ep_type);

#ifdef	DEBUG
	if (pep->ep_type == EPT_IP)
	{
		struct ip *pip = (struct ip *)pep->ep_data;
		if (pip->ip_proto == IPT_OSPF) {
			struct ospf *po = (struct ospf *)pip->ip_data;
			if (po->ospf_type != T_HELLO) {
				kprintf("ethwrite(%X, %d)\n", pep, len);
				pdump(pep);
			}
		}
	}
#endif	DEBUG
	if (enq(etptr->etoutq, pep, 0) < 0) {
		nif[etptr->etintf].ni_odiscard++;
		freebuf(pep);
		return SYSERR;
	}
	ethwstrt(etptr);
	return OK;
}
@

⌨️ 快捷键说明

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