1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-18 12:52:44 +01:00

Add capability to set and get variable default hop limit

This commit is contained in:
Martin Lenders 2014-02-17 19:37:31 +01:00
parent 78b5f2ae5d
commit 470d8745e9
3 changed files with 29 additions and 3 deletions

View File

@ -116,6 +116,20 @@ int ipv6_send_packet(ipv6_hdr_t *packet);
*/
uint8_t ipv6_is_router(void);
/**
* @brief Sets the default hop limit to use with IPv6 packets.
*
* @param[in] hop_limit The hop limit to set the default hop limit to.
*/
void ipv6_set_default_hop_limit(uint8_t hop_limit);
/**
* @brief Gets the default hop limit that is used for IPv6 packets.
*
* @return The current default hop limit for IPv6 packets.
*/
uint8_t ipv6_get_default_hop_limit(void);
/**
* @brief Registers a handler thread for incoming IP packets.
*

View File

@ -256,7 +256,7 @@ void icmpv6_send_echo_request(ipv6_addr_t *destaddr, uint16_t id, uint16_t seq,
ipv6_buf->trafficclass_flowlabel = 0;
ipv6_buf->flowlabel = 0;
ipv6_buf->nextheader = IPV6_PROTO_NUM_ICMPV6;
ipv6_buf->hoplimit = 0xff;
ipv6_buf->hoplimit = ipv6_get_default_hop_limit();
memcpy(&ipv6_buf->destaddr, destaddr, sizeof(ipv6_addr_t));
ipv6_iface_get_best_src_addr(&ipv6_buf->srcaddr, &ipv6_buf->destaddr);
@ -295,7 +295,7 @@ void icmpv6_send_echo_reply(ipv6_addr_t *destaddr, uint16_t id, uint16_t seq, ch
ipv6_buf->trafficclass_flowlabel = 0;
ipv6_buf->flowlabel = 0;
ipv6_buf->nextheader = IPV6_PROTO_NUM_ICMPV6;
ipv6_buf->hoplimit = 0xff;
ipv6_buf->hoplimit = ipv6_get_default_hop_limit();
memcpy(&ipv6_buf->destaddr, destaddr, sizeof(ipv6_addr_t));
ipv6_iface_get_best_src_addr(&ipv6_buf->srcaddr, &ipv6_buf->destaddr);

View File

@ -56,6 +56,8 @@ int tcp_packet_handler_pid = 0;
int rpl_process_pid = 0;
ipv6_addr_t *(*ip_get_next_hop)(ipv6_addr_t *) = 0;
static uint8_t default_hop_limit = MULTIHOP_HOPLIMIT;
/* registered upper layer threads */
int sixlowip_reg[SIXLOWIP_MAX_REGISTERED];
@ -118,7 +120,7 @@ int ipv6_sendto(const ipv6_addr_t *dest, uint8_t next_header,
ipv6_buf->trafficclass_flowlabel = 0;
ipv6_buf->flowlabel = 0;
ipv6_buf->nextheader = next_header;
ipv6_buf->hoplimit = MULTIHOP_HOPLIMIT;
ipv6_buf->hoplimit = default_hop_limit;
ipv6_buf->length = payload_length;
memcpy(&(ipv6_buf->destaddr), dest, 16);
@ -146,6 +148,16 @@ int ipv6_sendto(const ipv6_addr_t *dest, uint8_t next_header,
return payload_length;
}
void ipv6_set_default_hop_limit(uint8_t hop_limit)
{
default_hop_limit = hop_limit;
}
uint8_t ipv6_get_default_hop_limit(void)
{
return default_hop_limit;
}
/* Register an upper layer thread */
uint8_t ipv6_register_packet_handler(int pid)
{