저장 모드에서 RPL을 실행중인 경우, 노드에 연결된 경로를보고 경로의 nexthop이 끝점 addess와 같은지 확인하여 직접 연결된 노드를 알 수 있습니다.
#include "ipv6/uip-ds6-route.h"
static void
iterate_children(void)
{
uip_ds6_route_t *route;
/* Loop over routing entries */
route = uip_ds6_route_head();
while(route != NULL) {
const uip_ipaddr_t *address = &route->ipaddr;
const uip_ipaddr_t *nexthop = uip_ds6_route_nexthop(route);
if(uip_ipaddr_cmp(&address, &nexthop)) {
/* direct child: do somehting */
}
route = uip_ds6_route_next(route);
}
}
이, 특히 질문을 해결 같은 것을 사용하려면 :
static uint8_t
is_direct_child(uip_ipaddr_t *address)
{
uip_ds6_route_t *route;
route = uip_ds6_route_lookup(address);
if(route != NULL) {
const uip_ipaddr_t *nexthop = uip_ds6_route_nexthop(route);
if(uip_ipaddr_cmp(&address, &nexthop)) {
/* nexthop and the address are the same */
return 1;
}
}
return 0;
}
출처
2017-05-02 20:13:25
kfx
답변 해 주셔서 감사합니다. 아주 좋은 대답! 빠른 후속 질문 : is_direct_child에서 하위 IP 주소 또는 호스트 IP 주소를 보내야합니까? – Freddyny
주소'argument'는 자식의 IP 주소를 의미합니다. – kfx
나는 이해한다! 그래서 나는 is_direct_child를 다음과 같이 호출합니다 : is_direct_child (& from)'from은'uip_ipaddr_copy (& from, & UIP_IP_BUF-> srcipaddr);'와 같이 수신됩니다. 그러나,'uip_ds6_route_lookup (address)'에서 라우트를 전혀 찾을 수 없습니다. 'uip-ds6-route : fe80 :: c40c : 0 : 0 : 3에 대한 경로 찾기 '를 출력하면 다음 출력은'경로 없음 '입니다. @kfx가 왜 필요한지 생각해 볼 수 있습니까? – Freddyny