ospfcheck.c,v

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

C,V
118
字号
head	1.3;
access;
symbols;
locks
	dls:1.3; strict;
comment	@ * @;


1.3
date	97.09.21.19.28.38;	author dls;	state Dist;
branches;
next	1.2;

1.2
date	94.02.06.18.20.52;	author dls;	state Works;
branches;
next	1.1;

1.1
date	94.01.18.20.50.51;	author dls;	state Old;
branches;
next	;


desc
@@


1.3
log
@pre-3e code
@
text
@/* ospfcheck.c - ospfcheck */

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

/*------------------------------------------------------------------------
 *  ospfcheck - check if a packet is a valid OSPF packet
 *------------------------------------------------------------------------
 */
int ospfcheck(pep)
struct	ep	*pep;
{
	struct	ip	*pip = (struct ip *)pep->ep_data;
	struct	ospf	*po = (struct ospf *)((char *)pip + IP_HLEN(pip));
	struct	ospf_if	*pif = &ospf_if[pep->ep_ifn];

	if (pif->if_state == IFS_DOWN)
		return FALSE;
	if (po->ospf_version != OSPF_VERSION)
		return FALSE;
	if (net2hs(po->ospf_authtype) != pif->if_area->ar_authtype)
		return FALSE;
	if (pif->if_area->ar_authtype &&
	    !blkequ(po->ospf_auth, pif->if_area->ar_auth, AUTHLEN))
		return FALSE;
	bzero(po->ospf_auth, AUTHLEN);
	if (cksum(po, net2hs(po->ospf_len)))
{
kprintf("checksum failed\n");
		return FALSE;
}
	return TRUE;
}
@


1.2
log
@*** empty log message ***
@
text
@a19 2
{
kprintf("CK ifstate DOWN\n");
a20 1
}
a21 2
{
kprintf("CK ospf_vers %d != %d\n", po->ospf_version, OSPF_VERSION);
d23 1
a23 4
}
	if (po->ospf_authtype != pif->if_area->ar_authtype)
{
kprintf("CK authtype %d != %d\n", po->ospf_authtype, pif->if_area->ar_authtype);
a24 1
}
a26 2
{
kprintf("CK au not zero & po->ospf_auth != ar_auth\n");
a27 1
}
d29 1
a29 1
	if (cksum(po, po->ospf_len>>1))
d31 1
a31 1
kprintf("cksum returns %x\n", cksum(po, po->ospf_len>>1));
@


1.1
log
@Initial revision
@
text
@d6 1
d16 2
d19 28
a46 1
	return OK;
@

⌨️ 快捷键说明

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