ipfhcopy.c,v
来自「TCP-IP红宝书源代码」· C,V 代码 · 共 74 行
C,V
74 行
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
@/* ipfhcopy.c - ipfhcopy */
#include <conf.h>
#include <kernel.h>
#include <network.h>
/*------------------------------------------------------------------------
* ipfhcopy - copy the hardware, IP header, and options for a fragment
*------------------------------------------------------------------------
*/
int ipfhcopy(pepto, pepfrom, offindg)
struct ep *pepto, *pepfrom;
unsigned int offindg;
{
struct ip *pipfrom = (struct ip *)pepfrom->ep_data;
unsigned i, maxhlen, olen, otype;
unsigned hlen = (IP_MINHLEN<<2);
if (offindg == 0) {
blkcopy(pepto, pepfrom, EP_HLEN+IP_HLEN(pipfrom));
return IP_HLEN(pipfrom);
}
blkcopy(pepto, pepfrom, EP_HLEN+hlen);
/* copy options */
maxhlen = IP_HLEN(pipfrom);
i = hlen;
while (i < maxhlen) {
otype = pepfrom->ep_data[i];
olen = pepfrom->ep_data[++i];
if (otype & IPO_COPY) {
blkcopy(&pepto->ep_data[hlen],
pepfrom->ep_data[i-1], olen);
hlen += olen;
} else if (otype == IPO_NOP || otype == IPO_EOOP) {
pepto->ep_data[hlen++] = otype;
olen = 1;
}
i += olen-1;
if (otype == IPO_EOOP)
break;
}
/* pad to a multiple of 4 octets */
while (hlen % 4)
pepto->ep_data[hlen++] = IPO_NOP;
return hlen;
}
@
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?