ripmetric.c

来自「TCP-IP红宝书源代码」· C语言 代码 · 共 27 行

C
27 行
字号
/* ripmetric.c - ripmetric */

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

#ifdef	RIP
/*------------------------------------------------------------------------
 * ripmetric - compute the RIP metric for a route we advertise
 *------------------------------------------------------------------------
 */
int
ripmetric(struct route *prt, unsigned ifnum)
{
	/* only advertise the net route for our interfaces */

	if (prt->rt_ifnum == NI_LOCAL &&
			prt->rt_mask == ip_maskall)
		return SYSERR;

	if (prt->rt_ifnum == ifnum)
		return RIP_INFINITY;	/* poison reverse */
	/* else, add one to our cost */
	return prt->rt_metric + 1;
}
#endif	/* RIP */

⌨️ 快捷键说明

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