Skip to content

Commit

Permalink
Activated higher priority by traffic class CS6 for NS/NA and RPL, EAP…
Browse files Browse the repository at this point in the history
…OL/ DHCP Relay messages.
  • Loading branch information
Juha Heiuskanen committed Nov 20, 2020
1 parent afbe906 commit 2376208
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 2 deletions.
2 changes: 2 additions & 0 deletions source/6LoWPAN/ws/ws_bootstrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include "Common_Protocols/icmpv6.h"
#include "Common_Protocols/icmpv6_radv.h"
#include "Common_Protocols/ipv6_constants.h"
#include "Common_Protocols/ip.h"
#include "Service_Libs/Trickle/trickle.h"
#include "Service_Libs/fhss/channel_list.h"
#include "6LoWPAN/ws/ws_common_defines.h"
Expand Down Expand Up @@ -466,6 +467,7 @@ static bool ws_nud_message_build(protocol_interface_info_entry_t *cur, mac_neigh
}
buffer_t *buffer = icmpv6_build_ns(cur, ll_target, src_address_ptr, true, false, aro_ptr);
if (buffer) {
buffer->options.traffic_class = IP_DSCP_CS6 << IP_TCLASS_DSCP_SHIFT;
protocol_push(buffer);
return true;
}
Expand Down
3 changes: 3 additions & 0 deletions source/6LoWPAN/ws/ws_eapol_auth_relay.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "mac_api.h"
#include "mac_mcps.h"
#include "Common_Protocols/ipv6_constants.h"
#include "Common_Protocols/ip.h"
#include "socket_api.h"
#include "6LoWPAN/MAC/mac_helper.h"
#include "6LoWPAN/MAC/mpx_api.h"
Expand Down Expand Up @@ -80,6 +81,8 @@ int8_t ws_eapol_auth_relay_start(protocol_interface_info_entry_t *interface_ptr,
ns_dyn_mem_free(eapol_auth_relay);
return -1;
}
int16_t tc = IP_DSCP_CS6 << IP_TCLASS_DSCP_SHIFT;
socket_setsockopt(eapol_auth_relay->socket_id, SOCKET_IPPROTO_IPV6, SOCKET_IPV6_TCLASS, &tc, sizeof(tc));

ns_list_add_to_end(&eapol_auth_relay_list, eapol_auth_relay);

Expand Down
3 changes: 3 additions & 0 deletions source/6LoWPAN/ws/ws_eapol_relay.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "mac_api.h"
#include "mac_mcps.h"
#include "Common_Protocols/ipv6_constants.h"
#include "Common_Protocols/ip.h"
#include "socket_api.h"
#include "6LoWPAN/MAC/mac_helper.h"
#include "6LoWPAN/MAC/mpx_api.h"
Expand Down Expand Up @@ -89,6 +90,8 @@ int8_t ws_eapol_relay_start(protocol_interface_info_entry_t *interface_ptr, uint
ns_dyn_mem_free(eapol_relay);
return -1;
}
int16_t tc = IP_DSCP_CS6 << IP_TCLASS_DSCP_SHIFT;
socket_setsockopt(eapol_relay->socket_id, SOCKET_IPPROTO_IPV6, SOCKET_IPV6_TCLASS, &tc, sizeof(tc));

if (ws_eapol_pdu_cb_register(interface_ptr, &eapol_pdu_recv_cb_data) < 0) {
ns_dyn_mem_free(eapol_relay);
Expand Down
1 change: 1 addition & 0 deletions source/Common_Protocols/icmpv6.c
Original file line number Diff line number Diff line change
Expand Up @@ -1766,6 +1766,7 @@ buffer_t *icmpv6_build_na(protocol_interface_info_entry_t *cur, bool solicited,
tr_debug("Neighbour removed for negative response send");
return buffer_free(buf);
}
buf->options.traffic_class = IP_DSCP_CS6 << IP_TCLASS_DSCP_SHIFT;
buf->ack_receive_cb = ack_remove_neighbour_cb;
}

Expand Down
5 changes: 5 additions & 0 deletions source/RPL/rpl_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#include "NWK_INTERFACE/Include/protocol_stats.h"
#include "Common_Protocols/ipv6_constants.h"
#include "Common_Protocols/icmpv6.h"
#include "Common_Protocols/ip.h"
#include "ipv6_stack/protocol_ipv6.h"
#include "Service_Libs/etx/etx.h" /* slight ick */

Expand Down Expand Up @@ -1292,6 +1293,10 @@ void rpl_control_transmit(rpl_domain_t *domain, protocol_interface_info_entry_t
/* Others set "0", which means use interface default */
buf->options.hop_limit = addr_ipv6_scope(buf->dst_sa.address, cur) <= IPV6_SCOPE_LINK_LOCAL ? 255 : 0;

if (code == ICMPV6_CODE_RPL_DAO || code == ICMPV6_CODE_RPL_DAO_ACK || buf->dst_sa.address[0] != 0xff) {
//DAO and DAO ACK and unicast traffic with Higher priority
buf->options.traffic_class = IP_DSCP_CS6 << IP_TCLASS_DSCP_SHIFT;
}

if (dst == NULL && cur == NULL) {
rpl_control_transmit_all_interfaces(domain, buf);
Expand Down
2 changes: 2 additions & 0 deletions source/RPL/rpl_downward.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
#include "Common_Protocols/icmpv6.h"
#include "NWK_INTERFACE/Include/protocol.h"
#include "ipv6_stack/ipv6_routing_table.h"
#include "Common_Protocols/ip.h"

#include "net_rpl.h"
#include "RPL/rpl_protocol.h"
Expand Down Expand Up @@ -1874,6 +1875,7 @@ static bool rpl_instance_push_address_registration(protocol_interface_info_entry
if (!buf) {
return false;
}
buf->options.traffic_class = IP_DSCP_CS6 << IP_TCLASS_DSCP_SHIFT;
tr_info("Send ARO %s to %s", trace_ipv6(addr->address), trace_ipv6(neighbour->ll_address));
protocol_push(buf);
return true;
Expand Down
12 changes: 10 additions & 2 deletions source/libDHCPv6/dhcp_service_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@
#include "socket_api.h"
#include "net_interface.h"
#include "common_functions.h"

#include "libDHCPv6/libDHCPv6.h"
#include "NWK_INTERFACE/Include/protocol.h" // just for protocol_core_monotonic_time

#include "Common_Protocols/ip.h"
#include "dhcp_service_api.h"
#ifdef HAVE_DHCPV6
#define TRACE_GROUP "dhcp"
Expand Down Expand Up @@ -437,7 +438,7 @@ void recv_dhcp_relay_msg(void *cb_res)
uint8_t *ptr = msg_iov[1].iov_base;
uint8_t msg_type = *ptr;


int16_t tc = 0;
if (msg_type == DHCPV6_RELAY_FORWARD) {
tr_error("Drop not supported DHCPv6 forward at Agent");
goto cleanup;
Expand Down Expand Up @@ -497,7 +498,10 @@ void recv_dhcp_relay_msg(void *cb_res)
msg_iov[0].iov_len = 38;
msg_iov[1].iov_len = msg_len;
tr_debug("Forward Client msg to server");
tc = IP_DSCP_CS6 << IP_TCLASS_DSCP_SHIFT;

}
socket_setsockopt(sckt_data->socket_id, SOCKET_IPPROTO_IPV6, SOCKET_IPV6_TCLASS, &tc, sizeof(tc));
socket_sendmsg(sckt_data->socket_id, &msghdr, NS_MSG_LEGACY0);
cleanup:
ns_dyn_mem_free(msg_iov[1].iov_base);
Expand Down Expand Up @@ -845,6 +849,8 @@ void dhcp_service_send_message(msg_tr_t *msg_tr_ptr)

if (msg_tr_ptr->relay_start) {
//Build Relay Reply only server do this
int16_t tc = IP_DSCP_CS6 << IP_TCLASS_DSCP_SHIFT;
socket_setsockopt(msg_tr_ptr->socket, SOCKET_IPPROTO_IPV6, SOCKET_IPV6_TCLASS, &tc, sizeof(tc));
ns_iovec_t data_vector[2];
ns_msghdr_t msghdr;
memcpy(msg_tr_ptr->addr.address, msg_tr_ptr->relay_start + 2, 16);
Expand Down Expand Up @@ -872,6 +878,8 @@ void dhcp_service_send_message(msg_tr_t *msg_tr_ptr)
retval = socket_sendmsg(msg_tr_ptr->socket, &msghdr, NS_MSG_LEGACY0);

} else {
int16_t tc = 0;
socket_setsockopt(msg_tr_ptr->socket, SOCKET_IPPROTO_IPV6, SOCKET_IPV6_TCLASS, &tc, sizeof(tc));
retval = socket_sendto(msg_tr_ptr->socket, &msg_tr_ptr->addr, msg_tr_ptr->msg_ptr, msg_tr_ptr->msg_len);
}
if (retval != 0) {
Expand Down

0 comments on commit 2376208

Please sign in to comment.