ipfjoin.c,v

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

C,V
72
字号
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
@/* ipfjoin.c - ipfjoin */

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

struct	ep	*ipfcons();

/*------------------------------------------------------------------------
 *  ipfjoin  -  join fragments, if all collected
 *------------------------------------------------------------------------
 */
struct ep *ipfjoin(iq)
struct	ipfq	*iq;
{
	struct	ep	*pep;
	struct	ip 	*pip = 0;
	int		off, packoff;

	if (iq->ipf_state == IPFF_BOGUS)
		return 0;
	/* see if we have the whole datagram */

	off = 0;
	while (pep=(struct ep *)seeq(iq->ipf_q)) {
		pip = (struct ip *)pep->ep_data;
		packoff =  (pip->ip_fragoff & IP_FRAGOFF)<<3;
		if (off < packoff) {
			while(seeq(iq->ipf_q))
				/*empty*/;
			return 0;
		}
		off = packoff + pip->ip_len - IP_HLEN(pip);
	}
	if (off > MAXLRGBUF) {		/* too big for us to handle */
		while (pep = (struct ep *)deq(iq->ipf_q))
			freebuf(pep);
		freeq(iq->ipf_q);
		iq->ipf_state = IPFF_FREE;
		return 0;
	}
	if (pip == 0 || (pip->ip_fragoff & IP_MF) == 0)
		return ipfcons(iq);

	return 0;
}
@

⌨️ 快捷键说明

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