mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
gnrc_ipv6: gnrc_icmpv6: use dispatch_receive helper function
This commit is contained in:
parent
72d177074b
commit
bd230d3b63
@ -57,7 +57,6 @@ void gnrc_icmpv6_demux(kernel_pid_t iface, gnrc_pktsnip_t *pkt)
|
|||||||
{
|
{
|
||||||
gnrc_pktsnip_t *icmpv6, *ipv6;
|
gnrc_pktsnip_t *icmpv6, *ipv6;
|
||||||
icmpv6_hdr_t *hdr;
|
icmpv6_hdr_t *hdr;
|
||||||
gnrc_netreg_entry_t *sendto;
|
|
||||||
|
|
||||||
icmpv6 = gnrc_pktsnip_search_type(pkt, GNRC_NETTYPE_ICMPV6);
|
icmpv6 = gnrc_pktsnip_search_type(pkt, GNRC_NETTYPE_ICMPV6);
|
||||||
|
|
||||||
@ -127,25 +126,10 @@ void gnrc_icmpv6_demux(kernel_pid_t iface, gnrc_pktsnip_t *pkt)
|
|||||||
|
|
||||||
/* ICMPv6-all will be send in gnrc_ipv6.c so only dispatch of subtypes is
|
/* ICMPv6-all will be send in gnrc_ipv6.c so only dispatch of subtypes is
|
||||||
* needed */
|
* needed */
|
||||||
|
if (!gnrc_netapi_dispatch_receive(GNRC_NETTYPE_ICMPV6, hdr->type, pkt)) {
|
||||||
sendto = gnrc_netreg_lookup(GNRC_NETTYPE_ICMPV6, hdr->type);
|
DEBUG("icmpv6: no one interested in type %d\n", hdr->type);
|
||||||
|
|
||||||
if (sendto == NULL) {
|
|
||||||
DEBUG("icmpv6: no receivers for ICMPv6 type %u\n", hdr->type);
|
|
||||||
/* don't release: IPv6 does this */
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* IPv6 might still do stuff to the packet, so no `- 1` */
|
|
||||||
gnrc_pktbuf_hold(pkt, gnrc_netreg_num(GNRC_NETTYPE_ICMPV6, hdr->type));
|
|
||||||
|
|
||||||
while (sendto != NULL) {
|
|
||||||
if (gnrc_netapi_receive(sendto->pid, pkt) < 1) {
|
|
||||||
DEBUG("icmpv6: unable to deliver packet\n");
|
|
||||||
gnrc_pktbuf_release(pkt);
|
gnrc_pktbuf_release(pkt);
|
||||||
}
|
}
|
||||||
sendto = gnrc_netreg_getnext(sendto);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gnrc_pktsnip_t *gnrc_icmpv6_build(gnrc_pktsnip_t *next, uint8_t type, uint8_t code,
|
gnrc_pktsnip_t *gnrc_icmpv6_build(gnrc_pktsnip_t *next, uint8_t type, uint8_t code,
|
||||||
|
@ -168,7 +168,6 @@ void gnrc_ipv6_demux(kernel_pid_t iface, gnrc_pktsnip_t *current, gnrc_pktsnip_t
|
|||||||
case PROTNUM_ICMPV6:
|
case PROTNUM_ICMPV6:
|
||||||
DEBUG("ipv6: handle ICMPv6 packet (nh = %u)\n", nh);
|
DEBUG("ipv6: handle ICMPv6 packet (nh = %u)\n", nh);
|
||||||
gnrc_icmpv6_demux(iface, pkt);
|
gnrc_icmpv6_demux(iface, pkt);
|
||||||
gnrc_pktbuf_release(pkt);
|
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
#ifdef MODULE_GNRC_IPV6_EXT
|
#ifdef MODULE_GNRC_IPV6_EXT
|
||||||
|
@ -117,13 +117,13 @@ void gnrc_ndp_nbr_sol_handle(kernel_pid_t iface, gnrc_pktsnip_t *pkt,
|
|||||||
(ipv6_addr_is_unspecified(&ipv6->src) &&
|
(ipv6_addr_is_unspecified(&ipv6->src) &&
|
||||||
ipv6_addr_is_solicited_node(&ipv6->dst))) {
|
ipv6_addr_is_solicited_node(&ipv6->dst))) {
|
||||||
DEBUG("ndp: neighbor solicitation was invalid.\n");
|
DEBUG("ndp: neighbor solicitation was invalid.\n");
|
||||||
/* ipv6 releases */
|
/* icmpv6 releases */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ((tgt = gnrc_ipv6_netif_find_addr(iface, &nbr_sol->tgt)) == NULL) {
|
if ((tgt = gnrc_ipv6_netif_find_addr(iface, &nbr_sol->tgt)) == NULL) {
|
||||||
DEBUG("ndp: Target address is not to interface %" PRIkernel_pid "\n",
|
DEBUG("ndp: Target address is not to interface %" PRIkernel_pid "\n",
|
||||||
iface);
|
iface);
|
||||||
/* ipv6 releases */
|
/* icmpv6 releases */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sicmpv6_size -= sizeof(ndp_nbr_sol_t);
|
sicmpv6_size -= sizeof(ndp_nbr_sol_t);
|
||||||
@ -228,14 +228,14 @@ void gnrc_ndp_nbr_adv_handle(kernel_pid_t iface, gnrc_pktsnip_t *pkt,
|
|||||||
(icmpv6_size < sizeof(ndp_nbr_adv_t)) ||
|
(icmpv6_size < sizeof(ndp_nbr_adv_t)) ||
|
||||||
ipv6_addr_is_multicast(&nbr_adv->tgt)) {
|
ipv6_addr_is_multicast(&nbr_adv->tgt)) {
|
||||||
DEBUG("ndp: neighbor advertisement was invalid.\n");
|
DEBUG("ndp: neighbor advertisement was invalid.\n");
|
||||||
/* ipv6 releases */
|
/* icmpv6 releases */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nc_entry == NULL) {
|
if (nc_entry == NULL) {
|
||||||
/* see https://tools.ietf.org/html/rfc4861#section-7.2.5 */
|
/* see https://tools.ietf.org/html/rfc4861#section-7.2.5 */
|
||||||
DEBUG("ndp: no neighbor cache entry found for advertisement's target\n");
|
DEBUG("ndp: no neighbor cache entry found for advertisement's target\n");
|
||||||
/* ipv6 releases */
|
/* icmpv6 releases */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -507,7 +507,7 @@ void gnrc_ndp_rtr_adv_handle(kernel_pid_t iface, gnrc_pktsnip_t *pkt, ipv6_hdr_t
|
|||||||
(ipv6->hl != 255) || (rtr_adv->code != 0) ||
|
(ipv6->hl != 255) || (rtr_adv->code != 0) ||
|
||||||
(icmpv6_size < sizeof(ndp_rtr_adv_t))) {
|
(icmpv6_size < sizeof(ndp_rtr_adv_t))) {
|
||||||
DEBUG("ndp: router advertisement was invalid\n");
|
DEBUG("ndp: router advertisement was invalid\n");
|
||||||
/* ipv6 releases */
|
/* icmpv6 releases */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* get source from default router list */
|
/* get source from default router list */
|
||||||
|
Loading…
Reference in New Issue
Block a user