static uint32_t RIP_send_resp( uint32_t rip_vers, /* [IN] the rip version */ uint32_t onlyChangeF /* [IN] TRUE if only the changed routes are sent */ ) { /* Body */ RIP_CFG_STRUCT_PTR ripcfg = RTCS_getcfg(RIP); IP_CFG_STRUCT_PTR IP_cfg_ptr = RTCS_getcfg(IP); struct RIP_send_resp_struct testdata; testdata.nb_try = 0; testdata.nb_fail = 0; testdata.localhost = RTCS_IF_LOCALHOST_PRV; testdata.rip_vers = rip_vers; testdata.onlyChangeF = onlyChangeF; if (rip_vers == RIP_V1) testdata.ipdest = INADDR_BROADCAST; else testdata.ipdest = INADDR_RIP_GROUP; IPRADIX_walk(&IP_cfg_ptr->ROUTE_ROOT.NODE, RIP_send_resp_test, &testdata); /* test if the routes has been all advertized (nbFail==0 && nbTry > 0)*/ if (testdata.nb_fail) return (uint32_t)RTCS_ERROR; if (testdata.nb_try == 0) return RTCS_OK; /* clear the flags only if required */ if (ripcfg->RT_CHANGED_F == FALSE) return RTCS_OK; /* update the flag */ ripcfg->RT_CHANGED_F = FALSE; /* clear the flag in all changed route entries */ IPRADIX_walk(&IP_cfg_ptr->ROUTE_ROOT.NODE, RIP_send_resp_test2, NULL); return RTCS_OK; } /* Endbody */
boolean IGMP_is_member ( MC_MEMBER_PTR _PTR_ phead, /* [IN] head of MCB list */ IP_IF_PTR ipif, /* [IN] the incoming interface */ _ip_address multiaddr /* [IN] the multicast ip */ ) { /* Body */ IP_CFG_STRUCT_PTR IP_cfg_ptr = RTCS_getcfg(IP); struct IGMP_is_member_test_struct testdata; if (!*phead) { return FALSE; } /* Endif */ testdata.multiaddr = multiaddr; testdata.ipif = ipif; testdata.phead = phead; testdata.result = FALSE; /* ** Scan all directly connected networks, to have all the ip ** address of this interface */ IPRADIX_walk(&IP_cfg_ptr->ROUTE_ROOT.NODE, IGMP_is_member_test, &testdata); return testdata.result; } /* Endbody */
uint_32 ROUTE_remove ( IP_ROUTE_INDIRECT_PTR gate /* [IN] the route entry to remove */ ) { /* Body */ IP_CFG_STRUCT_PTR IP_cfg_ptr = RTCS_getcfg(IP); IP_ROUTE_FN_PTR fn; struct ROUTE_remove_struct testdata; fn = IP_cfg_ptr->ROUTE_FN; while (fn) { fn->REM_RT(gate); fn = fn->NEXT; } /* Endwhile */ testdata.gate = gate; testdata.network = INADDR_ANY; testdata.netmask = INADDR_ANY; testdata.found = FALSE; IPRADIX_walk(&IP_cfg_ptr->ROUTE_ROOT.NODE, ROUTE_remove_test, &testdata); if (testdata.found) { /* Start CR 1135 */ IP_route_remove_indirect(gate->GATEWAY, testdata.netmask, testdata.network, gate->FLAGS, gate->METRIC); /* End CR 1135 */ } /* Endif */ return RTCS_OK; } /* Endbody */
static uint32_t RIP_send_resp_ipif ( IP_IF_PTR ipif, /* [IN] the destination interface */ _ip_address ipdest, /* [IN] the destination ip address */ uint16_t portdst, /* [IN] the destination port */ uint32_t rip_vers,/* [IN] the rip version */ uint32_t onlyChangeF /* [IN] TRUE if only the changed routes are sent */ ) { /* Body */ IP_CFG_STRUCT_PTR IP_cfg_ptr = RTCS_getcfg(IP); struct RIP_send_resp_ipif_struct testdata; testdata.ipif = ipif; testdata.ipdest = ipdest; testdata.portdst = portdst; testdata.onlyChangeF = onlyChangeF; testdata.rip_vers = rip_vers; testdata.pkt = NULL; testdata.curs = NULL; IPRADIX_walk(&IP_cfg_ptr->ROUTE_ROOT.NODE, RIP_send_resp_ipif_test, &testdata); /* if the packet is empty, dont send it */ if (testdata.curs-testdata.pkt == sizeof(RIP_HEADER)){ _mem_free(testdata.pkt); } else { /* send the packet */ RIP_send_pkt(ipif, ipdest, portdst, testdata.pkt, testdata.curs - testdata.pkt); } /* Endif */ return RTCS_OK; } /* Endbody */
void RTCS_walk_route(void) { /* Body */ IP_CFG_STRUCT_PTR IP_cfg_ptr = RTCS_getcfg( IP ); struct ROUTE_get_struct testdata; testdata.netaddr = 0; testdata.netmask = 0; testdata.gate = NULL; IPRADIX_walk(&IP_cfg_ptr->ROUTE_ROOT.NODE, ROUTE_walk_test, &testdata); } /* Endbody */
static uint32_t RIP_send_req( void ) { /* Body */ IP_CFG_STRUCT_PTR IP_cfg_ptr = RTCS_getcfg(IP); struct RIP_send_req_struct testdata; testdata.localhost = RTCS_IF_LOCALHOST_PRV; IPRADIX_walk(&IP_cfg_ptr->ROUTE_ROOT.NODE, RIP_send_req_test, &testdata); return RTCS_OK; } /* Endbody */
_ip_address RTCS_get_route ( _ip_address netaddr, /* [IN] the network address */ _ip_address netmask /* [IN] the network mask */ ) { /* Body */ IP_CFG_STRUCT_PTR IP_cfg_ptr = RTCS_getcfg( IP ); struct ROUTE_get_struct testdata; testdata.netaddr = netaddr; testdata.netmask = netmask; testdata.gate = NULL; IPRADIX_walk(&IP_cfg_ptr->ROUTE_ROOT.NODE, ROUTE_get_test, &testdata); return testdata.gate->GATEWAY; } /* Endbody */