?? output.c
字號:
/* output.c - routines for generating outgoing RIP messages *//* Copyright 1984 - 2001 Wind River Systems, Inc. */#include "copyright_wrs.h"/* * Copyright (c) 1983, 1988, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * @(#)output.c 8.2 (Berkeley) 4/28/95"; *//*modification history--------------------01m,22mar02,niq Merged from Synth view, tor3_x.synth branch, ver 01p01l,15oct01,rae merge from truestack ver 01n, base 01i (VIRTUAL_STACK etc.)01k,21nov00,spm fixed handling of interface for default route (SPR #62533)01j,10nov00,spm merged from version 01j of tor3_x branch (SPR #33692 fix)01i,11sep98,spm added option to disable gateway filtering and removed all references to bloated trace commands (SPR #22350)01h,01sep98,spm extended gateway filtering tests to handle classless netmasks and host-specific routes01g,26jul98,spm removed duplicate condition from test in supply routine; corrected stray pointer in ripBuildPacket call and added parameter needed for RIPv2 updates; removed compiler warnings01f,06oct97,gnn added sendHook functionality to sending01e,08may97,gnn fixed an authentication bug.01d,07apr97,gnn cleared up some of the more egregious warnings. added MIB-II interface and option support.01c,13mar97,gnn fixed a minor bug in the output routine01b,24feb97,gnn added rip version 2 functionality01a,26nov96,gnn created from BSD4.4 routed*//*DESCRIPTION*//* * Routing Table Management Daemon */#include "vxWorks.h"#include "logLib.h"#include "rip/defs.h"#include "rip/m2RipLib.h"#ifdef VIRTUAL_STACK#include "netinet/vsLib.h"#include "netinet/vsRip.h"#elseIMPORT int routedDebug;IMPORT BOOL ripFilterFlag;#endif/* * Apply the function "f" to all non-passive * interfaces. If the interface supports the * use of broadcasting use it, otherwise address * the output to the known router. */void toall(f, rtstate, skipif) int (*f)(); int rtstate; struct interface *skipif;{ register struct interface *ifp; register struct sockaddr *dst; register int flags;#ifndef VIRTUAL_STACK extern struct interface *ripIfNet;#endif for (ifp = ripIfNet; ifp; ifp = ifp->int_next) { if (ifp->int_flags & IFF_PASSIVE || ifp == skipif || (ifp->int_flags & IFF_UP) == 0) continue; dst = ifp->int_flags & IFF_BROADCAST ? &ifp->int_broadaddr : ifp->int_flags & IFF_POINTOPOINT ? &ifp->int_dstaddr : &ifp->int_addr; flags = ifp->int_flags & IFF_INTERFACE ? MSG_DONTROUTE : 0; if (f == supply) (*f)(dst, flags, ifp, rtstate, 0); else (*f)(dst, flags, ifp, rtstate); }}/* * Output a preformed packet. *//*ARGSUSED*/STATUS sndmsg(dst, flags, ifp, rtstate) struct sockaddr *dst; int flags; struct interface *ifp; int rtstate;{#ifndef VIRTUAL_STACK IMPORT RIP ripState;#endif (*afswitch[dst->sa_family].af_output)(ripState.s, flags, dst, sizeof (RIP_PKT)); if (routedDebug > 2) logMsg ("Transmitting RIP message.\n", 0, 0, 0, 0, 0, 0); return (OK);}/* * Supply dst with the contents of the routing tables. * If this won't fit in one packet, chop it up into several. */STATUS supply ( struct sockaddr *dst, int flags, register struct interface *ifp, int rtstate, int version ) {#ifndef VIRTUAL_STACK IMPORT RIP ripState;#endif register struct rt_entry *rt; register struct netinfo *pNetinfo = ripState.msg->rip_nets; register struct rthash *rh; struct rthash *base = hosthash; int doinghost = 1, size; int (*output)() = afswitch[dst->sa_family].af_output; int (*sendroute)() = afswitch[dst->sa_family].af_sendroute; int npackets = 0; struct interface* pIfp;#ifdef RIP_MD5 RIP2_AUTH_PKT_HDR * pAuthHdr; RIP_AUTH_KEY * pAuthKey;#endif /* RIP_MD5 */ ripState.msg->rip_cmd = RIPCMD_RESPONSE; if (ifp == NULL) pIfp = ripIfLookup(dst); else pIfp = ifp; if (pIfp == NULL) return (ERROR); /* * Check actual interface status before transmitting * The interface might have been disabled. */ if ((pIfp->int_flags & IFF_UP) == 0) return (ERROR); /* * Next, check the status from the MIB-II RIP group. If this * interface has been turned off then silently drop packets on it. */ if (pIfp->ifConf.rip2IfConfStatus != M2_rip2IfConfStatus_valid) return (ERROR); if (pIfp->ifConf.rip2IfConfSend == M2_rip2IfConfSend_doNotSend) return (ERROR); else if (pIfp->ifConf.rip2IfConfSend == M2_rip2IfConfSend_ripVersion1) ripState.msg->rip_vers = 1; else if ((pIfp->ifConf.rip2IfConfSend == M2_rip2IfConfSend_rip1Compatible) && version != 0) ripState.msg->rip_vers = version; else if ((pIfp->ifConf.rip2IfConfSend == M2_rip2IfConfSend_rip1Compatible) || (pIfp->ifConf.rip2IfConfSend == M2_rip2IfConfSend_ripVersion2)) ripState.msg->rip_vers = 2; else return (ERROR); memset(ripState.msg->rip_domain, 0, sizeof(ripState.msg->rip_domain)); /* * If we are doing authentication then properly fill in the first field. * */#ifdef RIP_MD5 if (pIfp->ifConf.rip2IfConfAuthType == M2_rip2IfConfAuthType_md5) { if (ripAuthKeyOut1MD5 (pIfp, pNetinfo, &pAuthHdr, &pAuthKey) == ERROR) return (ERROR); pNetinfo++; } else if (pIfp->ifConf.rip2IfConfAuthType == M2_rip2IfConfAuthType_simplePassword)#else if (pIfp->ifConf.rip2IfConfAuthType == M2_rip2IfConfAuthType_simplePassword)
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -