⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rrriputi.c

📁 用于嵌入式系统的TCP/IP协议栈及若干服务
💻 C
字号:
/**            Copyright (c) 1998-2001 by NETsilicon Inc.**  This software is copyrighted by and is the sole property of*  NETsilicon.  All rights, title, ownership, or other interests*  in the software remain the property of NETsilicon.  This*  software may only be used in accordance with the corresponding*  license agreement.  Any unauthorized use, duplication, transmission,*  distribution, or disclosure of this software is expressly forbidden.**  This Copyright notice may not be removed or modified without prior*  written consent of NETsilicon.**  NETsilicon, reserves the right to modify this software*  without notice.**  NETsilicon*  411 Waverley Oaks Road                  USA 781.647.1234*  Suite 227                               http://www.netsilicon.com*  Waltham, MA 02452                       AmericaSales@netsilicon.com***************************************************************************  $Name: Fusion 6.52 Fusion 6.51 $*  $Date: 2001/11/27 09:05:37 $*  $Source: M:/psisrc/routing/rip/rcs/rrriputi.c $*  $Revision: 1.13 $****************************************************************************  File Description: RIP utilities  ***************************************************************************/#include "ipport.h"#include "riproute.h"#include "rrtask.h"#include "fnsrip.h"#include "nerrno.h"#include "debug.h"/* node */extern RNODE *r_node;/*****************************************RipEnable:Enable RIP routing functions.*****************************************/int RipEnable(void){	int i,j;	rcirc_pt c;	ipna_pt		 loc_ipa;		/* make sure currently off */	if( r_node->rn_radmst != ROUTER_OFF ){		return(-1);	}	r_node->rn_radmst = ROUTER_ON;	/* send request & rsp on all talkers */	for(i = 0; i < CIRC_HASHES; i++){		for(c= (rcirc_pt)rip_circ_hash[i].dll_fwd;c;c= c->rc_fwd){						loc_ipa = c->rc_ipa;			/* foreach multi-home */			for(j = 0; j < MAX_IF_IPADD; j++, loc_ipa++){				if( j && !loc_ipa->ip_add){					break;				}				/* send update right away */				riptx(loc_ipa, c->rc_id, 0,(rripa)0,0,0);				/* send rip general request */				RipTxReq(loc_ipa,c->rc_id);			}		}	}	return(0);}/*****************************************RipDisable:disable RIP and delete all routes.*****************************************/int RipDisable(int no_st_ch){	int i,j;	rcirc_pt c;	ipna_pt		 loc_ipa;	/* make sure on */	if( r_node->rn_radmst == ROUTER_OFF ){		return(-1);	}	/* for each circuit */	for(i = 0; i < CIRC_HASHES; i++){		for(c= (rcirc_pt)rip_circ_hash[i].dll_fwd;c;c= c->rc_fwd){			loc_ipa = c->rc_ipa;			/* foreach multi-home */			for(j = 0; j < MAX_IF_IPADD; j++, loc_ipa++){				if(!loc_ipa->ip_add){					break;				}				/* send rip with infinite hop count */				riptx(loc_ipa, c->rc_id, 0,(rripa)0,0,1);			}			/* purge routes we learned */			RipPurgeRouteByCirc(c);		}	}	if(!no_st_ch){		r_node->rn_radmst = ROUTER_OFF;	}	return(0);}/***************************************ripTrigger:sets trigger for sending rip update.****************************************/void ripTrigger(void){	r_node->rn_trig = TRUE;}/*****************************************ripOfAlloc:alloc rip pdu with space for ip/udp infront.*****************************************/ibd_pt ripOfAlloc(int len){	ibd_pt rip_bd;	int alen = len + IP_HLEN + UDP_HLEN;	if( (rip_bd= (ibd_pt)ipOfAlloc(alen)) == 0){		return(0);	}	/* save space for headers */	rip_bd->ibd_buf = 		 (byte *)rip_bd->ibd_buf + IP_HLEN+UDP_HLEN;	return(rip_bd);}/******************************************ripUseTrustedNbr:enable/disable use of trusted neighbors*******************************************/void ripUseTrustedNbr(int use_it){	r_node->rn_dotrust = use_it;}/**********************************************ripAddTrustedNbr:add ip addr to trusted nbr list*********************************************/int ripAddTrustedNbr(rripa nbr){	if(r_node->rn_numtrust >= RIP_MAX_TRUST)		return(-1);	r_node->rn_trustnbr[r_node->rn_numtrust] = nbr;	r_node->rn_numtrust++;	r_node->rn_dotrust = 1;	return(0);}/*************************************************ripDelTrustedNbr:del ip addr from trusted nbr list*************************************************/void ripDelTrustedNbr(rripa nbr){	int i;	for(i = 0; i < r_node->rn_numtrust;i++){		if(r_node->rn_trustnbr[i] == nbr){			/* slide everything down */			for( ; i < r_node->rn_numtrust; i++){				r_node->rn_trustnbr[i] = 				        r_node->rn_trustnbr[i+1];			}			r_node->rn_numtrust--;			if(!r_node->rn_numtrust)				r_node->rn_dotrust = 0;			return;		}	}}/*********************************************ripIsTrusted:verify src addr of rip rsp is a trusted addr.if dotrust false, all are trusted.return 0 not trusted, 1 trusted*********************************************/int ripIsTrusted(rripa src){	int i;	if(!r_node->rn_dotrust)		return(1);	/* go thru trusted nbr list */	for(i = 0; i < r_node->rn_numtrust; i++){		if(r_node->rn_trustnbr[i] == src)			return(1);	}	return(0);}#ifdef SNMP/*********************************************getRn_rip2GlobalRouteChanges();SNMP function.*********************************************/int getRn_rip2GlobalRouteChanges(){	return( r_node->rn_rip2GlobalRouteChanges );}/*********************************************getRn_rip2GlobalQueries();SNMP function.*********************************************/int getRn_rip2GlobalQueries(){	return( r_node->rn_rip2GlobalQueries );}/*********************************************getRn_rip2Domain();SNMP function.*********************************************/int getRn_rip2Domain(){	return( r_node->rn_rdom );}/*********************************************setRn_rip2Domain();SNMP function.*********************************************/int setRn_rip2Domain(long kk){r_node->rn_rdom = (word)kk;return 0;}#endif /* SNMP */

⌨️ 快捷键说明

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