Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a handler for ICMP Destination Unreachable #2544

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
[ICMPv6] Handle Destination Unreachable messages
Nodes was already able to send Destination Unreachable messages, but was
not able to parse them.

If DEBUG is true in `core/net/ipv6/uip-icmp6.c`, then a message is
printed on the serial line.
audeoudh committed Dec 5, 2018
commit bdb9130ecd86f50a800d76760ca2c0aacaf8ca1a
34 changes: 34 additions & 0 deletions core/net/ipv6/uip-icmp6.c
Original file line number Diff line number Diff line change
@@ -361,18 +361,52 @@ uip_icmp6_echo_reply_callback_rm(struct uip_icmp6_echo_reply_notification *n)
{
list_remove(echo_reply_callback_list, n);
}

/*---------------------------------------------------------------------------*/
static void
destination_unreachable_input(void)
{
PRINT6ADDR(&UIP_IP_BUF->srcipaddr);
PRINTF(": destination unreachable (");
switch(UIP_ICMP_BUF->icode) {
case ICMP6_DST_UNREACH_NOROUTE:
PRINTF("no route to destination");
break;
case ICMP6_DST_UNREACH_ADMIN:
PRINTF("communication with destination administratively prohibited");
break;
case ICMP6_DST_UNREACH_BEYONDSCOPE:
PRINTF("beyond scope of source address");
break;
case ICMP6_DST_UNREACH_ADDR:
PRINTF("address unreachable");
break;
case ICMP6_DST_UNREACH_NOPORT:
PRINTF("port unreachable");
break;
default:
printf("unknown reason code");
}
PRINTF(")\n");

return;
}

/*---------------------------------------------------------------------------*/
UIP_ICMP6_HANDLER(echo_request_handler, ICMP6_ECHO_REQUEST,
UIP_ICMP6_HANDLER_CODE_ANY, echo_request_input);
UIP_ICMP6_HANDLER(echo_reply_handler, ICMP6_ECHO_REPLY,
UIP_ICMP6_HANDLER_CODE_ANY, echo_reply_input);
UIP_ICMP6_HANDLER(destination_unreachable_handler, ICMP6_DST_UNREACH,
UIP_ICMP6_HANDLER_CODE_ANY, destination_unreachable_input);
/*---------------------------------------------------------------------------*/
void
uip_icmp6_init()
{
/* Register Echo Request and Reply handlers */
uip_icmp6_register_input_handler(&echo_request_handler);
uip_icmp6_register_input_handler(&echo_reply_handler);
uip_icmp6_register_input_handler(&destination_unreachable_handler);
}
/*---------------------------------------------------------------------------*/
/** @} */