ethwrite.c,v
来自「TCP-IP红宝书源代码」· C,V 代码 · 共 76 行
C,V
76 行
head 1.1;
access;
symbols;
locks
dls:1.1; strict;
comment @ * @;
1.1
date 94.01.07.03.10.26; author dls; state Old;
branches;
next ;
desc
@@
1.1
log
@Initial revision
@
text
@/* ethwrite.c - ethwrite */
#include <conf.h>
#include <kernel.h>
#include <proc.h>
#include <network.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_IGMP) {
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 + -
显示快捷键?