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

📄 input.c

📁 VXWORKS源代码
💻 C
📖 第 1 页 / 共 4 页
字号:
                    if (pErrorIfp->authHook(pErrorIfp->ifConf.                                                       rip2IfConfAuthKey,                                            rip) != OK)                        {                        pErrorIfp->ifStat.rip2IfStatRcvBadPackets++;                        return;                        }                    }                else                    {                    if (routedDebug)                        logMsg("Discarding unvalidated RIP version %d message.\n",                               rip->rip_vers, 0, 0, 0, 0, 0);                    pErrorIfp->ifStat.rip2IfStatRcvBadPackets++;                    return;                    }                }            }        else /* unknown auth type */            {            if (routedDebug)                logMsg("Discarding unvalidated RIP version %d message (Unknown auth type).\n",                       rip->rip_vers, 0, 0, 0, 0, 0);            pErrorIfp->ifStat.rip2IfStatRcvBadPackets++;            return;            }        /* Skip the first rip entry which was used for authentication */        pFirst = n = rip->rip_nets + 1;        }    if (size > RIP_MAX_PACKET)        {        if (routedDebug)            logMsg ("Packet too large from %s. (cmd %d)\n",                     (int)(*afswitch[from->sa_family].af_format)(from),                     rip->rip_cmd, 0, 0, 0, 0);        pErrorIfp->ifStat.rip2IfStatRcvBadPackets++;        return;        }    if (((size - 4) % 20) != 0)        {        if (routedDebug)            logMsg("Badly formed packet from %s. (cmd %d)\n",                    (int)(*afswitch[from->sa_family].af_format)(from),                    rip->rip_cmd, 0, 0, 0, 0);        pErrorIfp->ifStat.rip2IfStatRcvBadPackets++;        return;        }        /* Check that the unused RIP header field contains 0 if required. */    if (rip->rip_vers == 1)        {        if (rip->rip_domain[0] != 0 || rip->rip_domain[1] != 0)            {            pErrorIfp->ifStat.rip2IfStatRcvBadPackets++;            return ;            }        }    /*     * Process the received message. RIP responses will exit the switch     * statement so that triggered updates will be scheduled if necessary.     * All other commands must execute return statements within the switch     * to prevent that activity.     */    switch (rip->rip_cmd)        {        case RIPCMD_REQUEST:            /*             * Preserve port number before converting source address to             * canonical form for testing against local interface addresses.             */            ((struct sockaddr_in *)&gateway)->sin_port =                 ((struct sockaddr_in *)from)->sin_port;                        /* Ignore requests reflected from a local interface. */            (*afp->af_canon) (from);            ifp = ripIfWithAddr (from);            if (ifp)                return;            /* Restore the port number for requests from valid interfaces. */            ((struct sockaddr_in *)from)->sin_port =                 ((struct sockaddr_in *)&gateway)->sin_port;            /*             * Determine number of entries in message. If there are no             * entries, no response is given.             */            count = size - ((char *)n - (char *)rip);            if (count < sizeof (struct netinfo))                return;            for (; count > 0; n++)                {                if (count < sizeof (struct netinfo))                    break;                count -= sizeof (struct netinfo);                if (rip->rip_vers == 1)                    {                    if ( ((RIP2PKT *)n)->tag != 0)                        {                        pErrorIfp->ifStat.rip2IfStatRcvBadRoutes++;                        continue;                        }                    if ( ((RIP2PKT *)n)->subnet != 0)                        {                        pErrorIfp->ifStat.rip2IfStatRcvBadRoutes++;                        continue;                        }                    if ( ((RIP2PKT *)n)->gateway != 0)                        {                        pErrorIfp->ifStat.rip2IfStatRcvBadRoutes++;                        continue;                        }                    }                                n->rip_dst.sa_family = ntohs (osa (n->rip_dst)->sa_family);                n->rip_dst.sa_len = sizeof (n->rip_dst);                n->rip_metric = ntohl (n->rip_metric);                /*                  * Check for special case: the entire routing table is                 * sent if the message contains a single entry with a                  * family identifier of 0 (meaning unspecified: AF_UNSPEC)                  * and an infinite metric.                 */                if (n->rip_dst.sa_family == AF_UNSPEC &&                    (count != 0 || n != pFirst))                    {                    /*                     * Ignore entry with family of 0 if the message                      * contains multiple route entries.                     */                    pErrorIfp->ifStat.rip2IfStatRcvBadRoutes++;                    continue;                    }                if (n->rip_dst.sa_family == AF_UNSPEC &&                    n->rip_metric != HOPCNT_INFINITY)                    {                    /*                      * Ignore message with single entry and family of 0                      * if metric is finite.                      */                    pErrorIfp->ifStat.rip2IfStatRcvBadRoutes++;                    return;                    }                if (n->rip_dst.sa_family == AF_UNSPEC)                    {                    /*                      * Send the entire routing table, except for entries                     * learned from the interface which received the request.                     * Silent RIP processes will only respond to a query which                     * used a non-standard port. (RFC 1058, section 3.4.1).                     */                    if (ripState.supplier ||                        (*afp->af_portmatch)(from) == 0)                        {                        supply (from, 0, pErrorIfp, 0, rip->rip_vers);                        ripState.ripGlobal.rip2GlobalQueries++;                        }                    return;                    }                /*                  * Ignore entries with unsupported address families.                 * Currently, only entries with a family of AF_INET                  * are accepted.                 */                if (n->rip_dst.sa_family != AF_INET)                    {                    pErrorIfp->ifStat.rip2IfStatRcvBadRoutes++;                    continue;                    }                if (n->rip_dst.sa_family < AF_MAX &&                    afswitch[n->rip_dst.sa_family].af_hash)                    {                    rt = rtlookup(&n->rip_dst);                    /*                     * If the interface for the route is down, the                     * route is not reachable.                     */                    if (rt->rt_ifp && (rt->rt_ifp->int_flags & IFF_UP) == 0)                        rt = 0;                    }                else                    rt = 0;                n->rip_metric = rt == 0 ? HOPCNT_INFINITY :                    min(rt->rt_metric + 1, HOPCNT_INFINITY);                osa(n->rip_dst)->sa_family =                    htons(n->rip_dst.sa_family);                n->rip_metric = htonl(n->rip_metric);                changes++;                }            /*              * The RFC specification does not clearly define the desired             * behavior for the case where all entries in a request use              * an unknown family. Although the individual entries must             * be ignored, it seems as if a response containing unchanged              * metrics should be returned, but that behavior causes ANVL              * test 6.5 to fail. The following test avoids that problem.             */            if (changes)                {                /* Send a reply if at least one entry was recognized. */                rip->rip_cmd = RIPCMD_RESPONSE;                memmove(ripState.packet, rip, size);                (*afp->af_output)(ripState.s, 0, from, size);                ripState.ripGlobal.rip2GlobalQueries++;                }            return;                    case RIPCMD_TRACEON:        case RIPCMD_TRACEOFF:            /* Obsolete commands ignored by RIP. (RFC 1058, section 3.1) */            if (routedDebug)                logMsg ("Ignoring obsolete trace command from router %s.\n",                        (int)(*afswitch[from->sa_family].af_format)(from),                        0, 0, 0, 0, 0);            pErrorIfp->ifStat.rip2IfStatRcvBadPackets++;            return;                    case RIPCMD_RESPONSE:            /* Verify that the message used the required port. */            if ((*afp->af_portmatch)(from) == 0)                {                pErrorIfp->ifStat.rip2IfStatRcvBadPackets++;                return;                }            /*              * Check for reflected updates from the router's own interface.             * The test also eliminates updates from a directed broadcast             * address which is one of the illegal source addresses forbidden             * by the router requirements RFC.             */            (*afp->af_canon) (from);            ifp = ripIfWithAddr (from);            if (ifp)                {                /*                 * When a router receives an invalid update, it uses it to                  * track the status of a directly connected interface, but                  * the message is otherwise ignored.                 */                if (ifp->int_flags & IFF_PASSIVE)                    {                    if (routedDebug)                        logMsg ("bogus input (from passive interface, %s)\n",                             (int)(*afswitch[from->sa_family].af_format)(from),                                0, 0, 0, 0, 0);                    ifp->ifStat.rip2IfStatRcvBadPackets++;                    return;                    }                /*                  * Search for a route entry to the directly connected network                 * and reset the expiration timer if found. If no such route                 * is present or a non-interface route is detected, the                  * receiving interface was either recently added or restarted.                  * The addrouteforif routine will create a permanent interface                  * route and remove any overlapping (learned) route.                 */                rt = rtfind(from);                if (rt == 0 || (((rt->rt_state & RTS_INTERFACE) == 0) &&                    rt->rt_metric >= ifp->int_metric))                    addrouteforif(ifp);                else                    {                    rt->rt_timer = 0;                    /* Update age for IP group MIB. */                    if (rt->inKernel)                         ripRouteAgeUpdate (rt); 

⌨️ 快捷键说明

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