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

📄 rsvp_err.c

📁 radius协议源码÷The Radius Stack will connect to a Radius Server. This stack implementation is built upo
💻 C
📖 第 1 页 / 共 2 页
字号:
/* * @(#) $Id: rsvp_err.c,v 1.1.1.1 2000/05/08 22:51:24 wenqing Exp $ *//************************ rsvp_err.c  ******************************** *                                                                   * *     Routines to receive, process, and send PathErr, ResvErr, and  * *		Resv_Confirm messages.  			     * *                                                                   * *********************************************************************//****************************************************************************            RSVPD -- ReSerVation Protocol Daemon                USC Information Sciences Institute                Marina del Rey, California	    Current Version:  Steven Berson & Bob Braden, May 1996  Copyright (c) 1996 by the University of Southern California  All rights reserved.  Permission to use, copy, modify, and distribute this software and its  documentation in source and binary forms for any purpose and without  fee is hereby granted, provided that both the above copyright notice  and this permission notice appear in all copies, and that any  documentation, advertising materials, and other materials related to  such distribution and use acknowledge that the software was developed  in part by the University of Southern California, Information  Sciences Institute.  The name of the University may not be used to  endorse or promote products derived from this software without  specific prior written permission.  THE UNIVERSITY OF SOUTHERN CALIFORNIA makes no representations about  the suitability of this software for any purpose.  THIS SOFTWARE IS  PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,  INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  Other copyrights might apply to parts of this software and are so  noted when applicable.********************************************************************/#include "rsvp_daemon.h"extern int      errno;/*	External dcl's */Session		*locate_session(SESSION *);int		resv_refresh(Session *, int);void		api_PATH_ERR_upcall(struct packet *);void		api_RESV_ERR_upcall(struct packet *);int		demerge_flowspecs(FLOWSPEC *, FLOWSPEC *);int		Compare_Flowspecs(FLOWSPEC *, FLOWSPEC *);struct		packet *new_packet_area(packet_area *);Object_header *	copy_object(Object_header *);int		send_pkt_out_if(int, RSVP_HOP *, struct packet *);int		match_filt2star(FILTER_SPEC *, FiltSpecStar *);FiltSpecStar *	Get_FiltSpecStar(int);void		map2FiltStar(struct packet *, FiltSpecStar *);/* Forward dcl's */int		accept_path_err(int, struct packet *);int		accept_resv_err(int, struct packet *);int		accept_resv_conf(int, struct packet *);void		rsvp_path_err(int in_if, int, int, struct packet *);void		rsvp_resv_err(int, int, int, FiltSpecStar *, struct packet *);void		rsvp_resv_err1(int, int, int, FiltSpecStar *, struct packet *);void		rsvp_RSB_err(Session *, RSB *, int, int);void		Filtstar2map(FiltSpecStar *, struct packet *);PSB	*	resv_err_blockade(Session *destp, struct packet *);bitmap	*	resv_err_scope(Session *, SCOPE *);void		send_confirm(Session *, RSB *);void		update_BSB(Session *, PSB *, FLOWSPEC *);/* *   accept_path_err(): receives an RSVP PathErr msg and handles it. *		Can only come from network. */intaccept_path_err(	int in_if,	struct packet *pkt)	{	Session		*destp;	PSB		*sp;	SenderDesc	*sdscp = SenderDesc_of(pkt);	packet_map	*mapp = pkt->pkt_map;	FORCE_HOST_ORDER(pkt);	/*	 * If there is no session state, just ignore PathErr message.	 */	destp = locate_session(pkt->rsvp_sess);	if (!destp) {		log_event(LOGEV_ignore, "PATH-ERR", mapp->rsvp_session,							"No session");		return(0);	}             	/*	 *   For sender template in error, look up path state.  If none,	 *   ignore PathErr msg.	 */	sp = locate_PSB(destp, sdscp->rsvp_stempl, -1, NULL ); /* XXX ?? */	if (!sp) {		log_event(LOGEV_ignore, "PATH-ERR", mapp->rsvp_session,							"No sender");		return(0);	}	Incr_ifstats(sp->ps_in_if, rsvpstat_msgs_in[RSVP_PATH_ERR]);	/*      Check that INTEGRITY was included if it is required.	*/	if ((if_vec[in_if].if_flags&IF_FLAG_Intgrty) && 			pkt->pkt_map->rsvp_integrity == NULL)		return PKT_ERR_INTEGRITY;	/*   If phop address is zero (API), deliver path error to API,	 *   otherwise forward PathErr message.	 */	if (IsHopAPI(&sp->ps_phop)) {		api_PATH_ERR_upcall(pkt);	} else {		/* Ignore any NHOP object and remove any UDP encapsulation;		 * otherwise, forward the packet without change.		 */		pkt->pkt_map->rsvp_hop = NULL;		pkt->pkt_flags &= ~PKTFLG_USE_UDP;		send_pkt_out_if(sp->ps_in_if, &sp->ps_rsvp_phop, pkt);	}	return(0);}/* *  accept_resv_err(): Receives an RSVP ResvErr and handles it. * *		Can only come from network. */intaccept_resv_err(	int in_if,		/* (real) incoming interface */	struct packet *pkt)	{	packet_map	*mapp = pkt->pkt_map;	packet_area	 data;		/* To build output packet */	struct packet	*outpkt;	Session		*destp;	bitmap		*bitm_vecp = NULL; /* Ptr to vector of routes */	RSB		*rp;	PSB		*BSBp;	int		 N, rc;	style_t		 style = Style(pkt);	static RSVP_HOP hop;	FORCE_HOST_ORDER(pkt);	/*      Check that INTEGRITY was included if it is required.	*/	if (in_if >= 0 && (if_vec[in_if].if_flags&IF_FLAG_Intgrty) && 			pkt->pkt_map->rsvp_integrity == NULL)		return PKT_ERR_INTEGRITY;	/* 	If there is no path state for SESSION, drop the ResvErr	 *	message and return.	 */	destp = locate_session(pkt->rsvp_sess);	if (!destp) {		log_event(LOGEV_ignore, "RESV-ERR", mapp->rsvp_session,							"No sess");		return(0);	}	if (!Style_is_Shared(style) && pkt->rsvp_nflwd > 1)		return PKT_ERR_NUMFLOW;		/* XXX Could force nflwd = 1, free others */	/* XXX Need to increment stats for RESV_ERR... but may not know in_if	 */	if (in_if >= 0)		Incr_ifstats(in_if, rsvpstat_msgs_in[RSVP_RESV_ERR]);	/*	If the Error Code = 01 (Admission Control failure),	 *	do special processing of blockade state.	 */	if (errorspec_get_errcode(pkt->rsvp_errs) == RSVP_Err_ADMISSION) {		BSBp = resv_err_blockade(destp, pkt);		if (BSBp) {			if (in_if >= 0)				bmp_set(&(destp->d_r_incifs), in_if);			else				bmp_rst(&(destp->d_r_incifs));			resv_refresh(destp, 1);			bmp_rst(&(destp->d_r_incifs));		}	}	/*	 *	If scope is wildcard and there is a SCOPE object;	 *	compute vector of routing bitmaps parallel to SCOPE.	 */	if (Style_is_Wildcard(style) && (pkt->rsvp_scope)) {		bitm_vecp = resv_err_scope(destp, pkt->rsvp_scope);		if (bitm_vecp == NULL) {			Log_Mem_Full("ResvErr");			return(0);		}	}	/* Build output packet struct and copy appropriate entries from	 * input map.	 */	outpkt = new_packet_area(&data);	outpkt->pkt_map->rsvp_session = mapp->rsvp_session;	outpkt->pkt_map->rsvp_hop = &hop;	outpkt->pkt_map->rsvp_style = mapp->rsvp_style;	outpkt->pkt_map->rsvp_flags = mapp->rsvp_flags;	outpkt->pkt_map->rsvp_msgtype = RSVP_RESV_ERR;	outpkt->pkt_map->rsvp_errspec = mapp->rsvp_errspec;	outpkt->pkt_map->rsvp_UnkObjList = mapp->rsvp_UnkObjList;	spec_of(rflows(outpkt)) = spec_of(rflows(pkt));	switch(Obj_CType(mapp->rsvp_session)) {		case ctype_SESSION_ipv4:		case ctype_SESSION_ipv4GPI:			Init_Object(&hop,RSVP_HOP,RSVP_HOP_ipv4);			break;#ifdef	USE_IPV6		case ctype_SESSION_ipv6:		case ctype_SESSION_ipv6GPI:			Init_Object(&hop,RSVP_HOP,RSVP_HOP_ipv6);			break;#endif	/* USE_IPV6 */		default:			Init_Object(&hop,NULL,NULL);			break;	}	/*	 *	Execute the following for each RSB for this session	 *	whose OI difffers from in_if and whose Filter_spec_list	 *	has at least one filter spec in common with the	 *	FILTER_SPEC* in the ResvErr message.	 *	 *	1. Copy all matching filter specs into output ResvErr packet.	 */	for (rp = destp->d_RSB_list; rp ; rp = rp->rs_next) {		if (IF_UNICAST(rp->rs_OIf) == in_if)			continue;				if (Style_is_Wildcard(style))			outpkt->rsvp_nflwd = 1;		else {			int  i, j = 0;			for (i= 0; i< pkt->rsvp_nflwd; i++) {			    FILTER_SPEC *filtp = filter_of(FlowDesc_of(pkt, i));			    if (match_filt2star(filtp, rp->rs_filtstar)) {				if (j)					spec_of(FlowDesc_of(outpkt, j)) = NULL;				filter_of(FlowDesc_of(outpkt, j++)) = filtp;			    }			}			if (j == 0)				continue;	/* No matches */			outpkt->rsvp_nflwd = j;		}		/*		 *  2.	If Error Code = 01 and the InPlace flag is 1 and one		 *	or more of the BSBs found/created above has a Qb that		 *	is strictly greater than Flowspec in the RSB, then		 *	continue with the next matching RSB, if any.		 */		if ((errorspec_get_errcode(pkt->rsvp_errs)				== RSVP_Err_ADMISSION) && BSBp &&				(errorspec_get_errflags(pkt->rsvp_errs) &				ERROR_SPECF_InPlace)) {			rc = Compare_Flowspecs(BSBp->ps_BSB_Qb, rp->rs_spec);			if (rc == SPEC1_GTR)				continue;		}		/*		 *  3.  If NHOP in the RSB is the local API, then:		 *	-- If the FLOWSPEC in the ResvErr message is		 *	   strictly greater than the RSB FLOWSPEC, then		 *	   turn on the NotGuilty flag in the ERROR_SPEC.		 *	-- Deliver an error upcall to application and		 *	   continue with the next RSB.		 */		if (IsHopAPI(&rp->rs_nhop)) {			if (Compare_Flowspecs( spec_of(rflows(pkt)), 						rp->rs_spec) == SPEC1_GTR)				errorspec_set_errflags(outpkt->rsvp_errs,					errorspec_get_errcode(					outpkt->rsvp_errs)					| ERROR_SPECF_NotGuilty);			api_RESV_ERR_upcall(outpkt);			continue;		}		if (bitm_vecp) {			/*			 *	Forward wildcard-scope ResvErr			 */			char *cp;			int i, nscope = scope_count(pkt->rsvp_scope);			int size = Obj_datalen(pkt->rsvp_scope) / nscope;			outpkt->rsvp_scope = new_scope_obj(nscope,				Obj_CType(pkt->rsvp_scope));			cp = (char *) Obj_data(outpkt->rsvp_scope);			for (i = 0; i < nscope; i++)				if (bmp_tst(&(bitm_vecp[i]), rp->rs_OIf)) {					memcpy(cp,Obj_data(pkt->rsvp_scope)						+ i * size,size);					cp += size;				}			N =  cp - (char *) Obj_data(outpkt->rsvp_scope);			/*			 *	If scope list is empty, continue with the			 *	next RSB.			 */			if (N == 0)				continue;			Obj_Length(outpkt->rsvp_scope) = N;			free(outpkt->rsvp_scope);		}		/*	Send to the NHOP address specified by the RSB.		 *	Set PHOP object for outgoing interface.		 *	Include scope list if the style is wildcard.		 */		hop_if_assign(outpkt->rsvp_phop,&GET_IF(rp->rs_OIf),			rp->rs_OIf);		send_pkt_out_if(rp->rs_OIf, &rp->rs_rsvp_nhop, outpkt);	}	if (bitm_vecp)		free(bitm_vecp);	return(0);}/* *	accept_resv_conf():  Received reservation confirmation message. *		Forward and/or do confirmation upcall to applications */intaccept_resv_conf(int in_if, struct packet *pkt)	{	RSVP_HOP	dummy_Hop_Obj;	FORCE_HOST_ORDER(pkt);		Init_Object(&dummy_Hop_Obj, RSVP_HOP, RSVP_HOP_ipv4);	hop_confirm_assign(&dummy_Hop_Obj,pkt->rsvp_confrcvr);	/*	 *	If the (unicast) IP address found in the RESV_CONFIRM	 *	object in the ResvConf message matches an interface of the	 *	node, a confirmation upcall is made to the matching	 *	application.	 */	if (confirm_if(pkt->rsvp_confrcvr) > -1)		api_RESV_ERR_upcall(pkt);	/*	Otherwise, forward the ResvConf message to the IP address	 *	in its RESV_CONFIRM object.	 */	else		send_pkt_out_if(-1, &dummy_Hop_Obj, pkt);	return(0);}/*	Given ResvErr msg containing SCOPE object, use path state to  *	built vector of routing bitmaps paralleling SCOPE list. */bitmap *resv_err_scope(Session *destp, SCOPE *scope_inp)	{	PSB		*sp;	bitmap		*bmp;	int		 n, i;	n = scope_count(scope_inp) * sizeof(bitmap);

⌨️ 快捷键说明

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