void rr_input(int len, struct icmp6_router_renum *rr, struct in6_pktinfo *pi, struct sockaddr_in6 *from, struct in6_addr *dst) { u_char ntopbuf[2][INET6_ADDRSTRLEN], ifnamebuf[IFNAMSIZ]; syslog(LOG_DEBUG, "<%s> RR received from %s to %s on %s", __FUNCTION__, inet_ntop(AF_INET6, &from->sin6_addr, ntopbuf[0], INET6_ADDRSTRLEN), inet_ntop(AF_INET6, &dst, ntopbuf[1], INET6_ADDRSTRLEN), if_indextoname(pi->ipi6_ifindex, ifnamebuf)); rr_rcvifindex = pi->ipi6_ifindex; /* TODO: some consistency check. */ switch (rr->rr_code) { case ICMP6_ROUTER_RENUMBERING_COMMAND: rr_command_input(len, rr, &from->sin6_addr, dst); /* TODO: send reply msg */ break; case ICMP6_ROUTER_RENUMBERING_RESULT: /* RESULT will be processed by rrenumd */ break; case ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET: /* TODO: sequence number reset */ break; default: syslog(LOG_ERR, "<%s> received unknown code %d", __FUNCTION__, rr->rr_code); break; } return; }
void rr_input(int len, struct icmp6_router_renum *rr, struct in6_pktinfo *pi, struct sockaddr_in6 *from, struct in6_addr *dst) { char ntopbuf[2][INET6_ADDRSTRLEN], ifnamebuf[IFNAMSIZ]; syslog(LOG_DEBUG, "<%s> RR received from %s to %s on %s", __func__, inet_ntop(AF_INET6, &from->sin6_addr, ntopbuf[0], INET6_ADDRSTRLEN), inet_ntop(AF_INET6, &dst, ntopbuf[1], INET6_ADDRSTRLEN), if_indextoname(pi->ipi6_ifindex, ifnamebuf)); /* packet validation based on Section 4.1 of RFC2894 */ if (len < sizeof(struct icmp6_router_renum)) { syslog(LOG_NOTICE, "<%s>: RR short message (size %d) from %s to %s on %s", __func__, len, inet_ntop(AF_INET6, &from->sin6_addr, ntopbuf[0], INET6_ADDRSTRLEN), inet_ntop(AF_INET6, &dst, ntopbuf[1], INET6_ADDRSTRLEN), if_indextoname(pi->ipi6_ifindex, ifnamebuf)); return; } /* * If the IPv6 destination address is neither an All Routers multicast * address [AARCH] nor one of the receiving router's unicast addresses, * the message MUST be discarded and SHOULD be logged to network * management. * We rely on the kernel input routine for unicast addresses, and thus * check multicast destinations only. */ if (IN6_IS_ADDR_MULTICAST(&pi->ipi6_addr) && !IN6_ARE_ADDR_EQUAL(&in6a_site_allrouters, &pi->ipi6_addr)) { syslog(LOG_NOTICE, "<%s>: RR message with invalid destination (%s) " "from %s on %s", __func__, inet_ntop(AF_INET6, &dst, ntopbuf[0], INET6_ADDRSTRLEN), inet_ntop(AF_INET6, &from->sin6_addr, ntopbuf[1], INET6_ADDRSTRLEN), if_indextoname(pi->ipi6_ifindex, ifnamebuf)); return; } rr_rcvifindex = pi->ipi6_ifindex; switch (rr->rr_code) { case ICMP6_ROUTER_RENUMBERING_COMMAND: rr_command_input(len, rr, &from->sin6_addr, dst); /* TODO: send reply msg */ break; case ICMP6_ROUTER_RENUMBERING_RESULT: /* RESULT will be processed by rrenumd */ break; case ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET: /* TODO: sequence number reset */ break; default: syslog(LOG_ERR, "<%s> received unknown code %d", __func__, rr->rr_code); break; } return; }