ipfcons.c,v
来自「TCP-IP红宝书源代码」· C,V 代码 · 共 86 行
C,V
86 行
head 1.1;
access;
symbols;
locks
dls:1.1; strict;
comment @ * @;
1.1
date 97.09.21.19.27.09; author dls; state Dist;
branches;
next ;
desc
@@
1.1
log
@pre-3e code
@
text
@/* ipfcons.c - ipfcons */
#include <conf.h>
#include <kernel.h>
#include <network.h>
/*------------------------------------------------------------------------
* ipfcons - construct a single packet from an IP fragment queue
*------------------------------------------------------------------------
*/
struct ep *ipfcons(iq)
struct ipfq *iq;
{
struct ep *pep, *peptmp;
struct ip *pip;
int off, seq;
pep = (struct ep *)getbuf(Net.lrgpool);
if (pep == (struct ep *)SYSERR) {
while (peptmp = (struct ep *)deq(iq->ipf_q)) {
IpReasmFails++;
freebuf(peptmp);
}
freeq(iq->ipf_q);
iq->ipf_state = IPFF_FREE;
return 0;
}
/* copy the Ether and IP headers */
peptmp = (struct ep *)deq(iq->ipf_q);
pip = (struct ip *)peptmp->ep_data;
off = IP_HLEN(pip);
seq = 0;
blkcopy(pep, peptmp, EP_HLEN+off);
/* copy the data */
while (peptmp != 0) {
int dlen, doff;
pip = (struct ip *)peptmp->ep_data;
doff = IP_HLEN(pip) + seq
- ((pip->ip_fragoff&IP_FRAGOFF)<<3);
dlen = pip->ip_len - doff;
blkcopy(pep->ep_data+off, peptmp->ep_data+doff, dlen);
off += dlen;
seq += dlen;
freebuf(peptmp);
peptmp = (struct ep *)deq(iq->ipf_q);
}
/* fix the large packet header */
pip = (struct ip *)pep->ep_data;
pip->ip_len = off;
pip->ip_fragoff = 0;
/* release resources */
freeq(iq->ipf_q);
iq->ipf_state = IPFF_FREE;
IpReasmOKs++;
return pep;
}
@
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?