?? output.c
字號:
#endif /* RIP_MD5 */ { bzero((char *)pNetinfo, sizeof(RIP2PKT)); ((RIP2PKT *)pNetinfo)->family = RIP2_AUTH; ((RIP2PKT *)pNetinfo)->tag = M2_rip2IfConfAuthType_simplePassword; bcopy((char *)pIfp->ifConf.rip2IfConfAuthKey, (char *)pNetinfo + 4, RIP2_AUTH_LEN); pNetinfo++; } again: for (rh = base; rh < &base[ROUTEHASHSIZ]; rh++) for (rt = rh->rt_forw; rt != (struct rt_entry *)rh; rt = rt->rt_forw) { if (routedDebug > 1) logMsg ("Looking at IF %s, route to %d %d %d %d \n", (int)(rt->rt_ifp ? rt->rt_ifp->int_name : "?"), (u_char)rt->rt_dst.sa_data[2], (u_char)rt->rt_dst.sa_data[3], (u_char)rt->rt_dst.sa_data[4], (u_char)rt->rt_dst.sa_data[5], 0); /* * This calls the per interface send hook. The user may * add their own hook that allows them to decide on a route * by route basis what routes to add to the update. */ if (pIfp->sendHook != NULL) if (!pIfp->sendHook(rt)) continue; /* * When sending in response to a query, ifp is zero, disabling * this test. Otherwise, information is not sent on the network * from which it was received (simple split horizon). */ if (ifp && (rt->rt_ifp == ifp)) continue; /* * If the route's interface is down, then we don't really * want to advertise that route. Skip it */ if (rt->rt_ifp && (rt->rt_ifp->int_flags & IFF_UP) == 0) continue; /* * "External" routes are only created for a loopback interface and * are never sent. */ if (rt->rt_state & RTS_EXTERNAL) continue; /* * This test detects routes with the specified state. It limits * the contents of dynamic updates to route entries with * the RTS_CHANGED flag set. */ if (rtstate && (rt->rt_state & rtstate) == 0) continue; /* * This test implements the network-related border gateway * filtering specified by RFC 1058 as well as the restrictions * in section 3.3 of RFC 1723 needed for compatibility between * RIPv1 and RIPv2. It selects between the internally generated * routes sent to "distant" hosts (which are not directly * connected to the destination) and the (possibly classless) * route entries which are only sent to neighbors on the same * logical network. */ if (doinghost == 0 && rt->rt_state & RTS_SUBNET) { if (rt->rt_dst.sa_family != dst->sa_family) continue; if (ripFilterFlag) { /* * Perform border gateway filtering if enabled. The * restrictions are only needed if RIP-1 routers are * in use on the network. */ if ( (*sendroute)(rt, dst, pIfp) == 0) continue; } else { /* * Border gateway filtering is disabled. Internally * generated routes (which represent the network as * a whole) are never sent. All other classless routes * are included unconditionally. */ if (rt->rt_state & RTS_INTERNAL) continue; } } /* * Limit any host route to neighbors within the same logical * network. This test also handles some network routes that * appear to be host routes to a router because they use a * longer prefix than the receiving interface. These * restrictions are only necessary if border gateway filtering * is enabled to support an environment with mixed RIP-1 and * RIP-2 routers. */ if (doinghost == 1 && ripFilterFlag) { if (rt->rt_dst.sa_family != dst->sa_family) continue; if ((*sendroute)(rt, dst, pIfp) == 0) continue; } size = (char *)pNetinfo - ripState.packet;#ifdef RIP_MD5 if (pIfp->ifConf.rip2IfConfAuthType == M2_rip2IfConfAuthType_md5) { /* must save a trailing entry for the MD5 auth digest */ if (size > (MAXPACKETSIZE - (2 * sizeof(struct netinfo)))) { ripAuthKeyOut2MD5(ripState.msg, &size, pNetinfo, pAuthHdr, pAuthKey); if (routedDebug > 2) logMsg ("Transmitting RIP message.\n", 0, 0, 0, 0, 0, 0); (*output)(ripState.s, flags, dst, size); /* * If only sending to ourselves, * one packet is enough to monitor interface. */ if (ifp && (ifp->int_flags & (IFF_BROADCAST | IFF_POINTOPOINT | IFF_REMOTE)) == 0) return (ERROR); /* set pNetinfo to second entry because first is auth */ pNetinfo = (ripState.msg->rip_nets + sizeof(struct netinfo)); npackets++; } } else {#endif /* RIP_MD5 */ if (size > MAXPACKETSIZE - sizeof (struct netinfo)) { if (routedDebug > 2) logMsg ("Transmitting RIP message.\n", 0, 0, 0, 0, 0, 0); (*output)(ripState.s, flags, dst, size); /* * If only sending to ourselves, * one packet is enough to monitor interface. */ if (ifp && (ifp->int_flags & (IFF_BROADCAST | IFF_POINTOPOINT | IFF_REMOTE)) == 0) return (ERROR); if (pIfp->ifConf.rip2IfConfAuthType == M2_rip2IfConfAuthType_simplePassword) { /* set pNetinfo to second entry because first is auth */ pNetinfo = (ripState.msg->rip_nets + sizeof(struct netinfo)); } else { /* else set pNetinfo to the first entry */ pNetinfo = ripState.msg->rip_nets; } npackets++; }#ifdef RIP_MD5 }#endif /* RIP_MD5 */#define osa(x) ((struct osockaddr *)(&(x))) osa(pNetinfo->rip_dst)->sa_family = htons(rt->rt_dst.sa_family); ripBuildPacket((RIP2PKT *)pNetinfo, rt, pIfp, pIfp->ifConf.rip2IfConfSend); pNetinfo++; } if (doinghost) { doinghost = 0; base = nethash; goto again; } /* * If we have something to send or if someone explicitly * requested a dump of whatever we have, send the packet. * If we are doing a regular/triggered update and there is * nothing to send, skip the update */ if (pNetinfo != ripState.msg->rip_nets || version != 0) { size = (char *)pNetinfo - ripState.packet;#ifdef RIP_MD5 if (pIfp->ifConf.rip2IfConfAuthType == M2_rip2IfConfAuthType_md5) { ripAuthKeyOut2MD5(ripState.msg, &size, pNetinfo, pAuthHdr, pAuthKey); }#endif /* RIP_MD5 */ if (routedDebug > 2) logMsg ("Transmitting RIP message.\n", 0, 0, 0, 0, 0, 0); (*output)(ripState.s, flags, dst, size); } return (OK); }
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -