Skip to content

Commit b2198b3

Browse files
Juha Heiskanenjuhhei01
authored andcommitted
MPX support Integrate
Integrated MPX support to Adaptation interface. Moved Data indication buffer allocate to Adatation interface that we can share code with MPX data indication. Updated 8-bit length to 16-bit to mac_helper_max_payload_size() and mac_helper_frame_overhead() Upadted and fixed unit test.
1 parent 2531c49 commit b2198b3

17 files changed

+457
-143
lines changed

source/6LoWPAN/Bootstraps/Generic/protocol_6lowpan.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
#endif
7070
#include "sw_mac.h"
7171
#include "6LoWPAN/MAC/mac_data_poll.h"
72+
#include "6LoWPAN/MAC/mpx_api.h"
7273
#include "6LoWPAN/lowpan_adaptation_interface.h"
7374
#include "6LoWPAN/Fragmentation/cipv6_fragmenter.h"
7475

source/6LoWPAN/Bootstraps/Generic/protocol_6lowpan_interface.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
#include "platform/arm_hal_interrupt.h"
6767
#include "common_functions.h"
6868
#include "mac_api.h"
69+
#include "6LoWPAN/MAC/mpx_api.h"
6970
#include "6LoWPAN/lowpan_adaptation_interface.h"
7071
#include "6LoWPAN/Fragmentation/cipv6_fragmenter.h"
7172
#include "libNET/src/net_load_balance_internal.h"

source/6LoWPAN/IPHC_Decode/6lowpan_iphc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ buffer_t *lowpan_down(buffer_t *buf)
169169
/* RFC 6282+4944 require that we limit compression to the first fragment.
170170
* This check is slightly conservative - always allow 4 for first-fragment header
171171
*/
172-
uint_fast8_t overhead = mac_helper_frame_overhead(cur, buf);
172+
uint_fast16_t overhead = mac_helper_frame_overhead(cur, buf);
173173
uint_fast16_t max_iphc_size = mac_helper_max_payload_size(cur, overhead) - mesh_size - 4;
174174

175175
buf = iphc_compress(&cur->lowpan_contexts, buf, max_iphc_size, stable_only);

source/6LoWPAN/MAC/mac_helper.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@ int8_t mac_helper_mac64_set(protocol_interface_info_entry_t *interface, const ui
684684
* Given a buffer, with address and security flags set, compute the maximum
685685
* MAC payload that could be put in that buffer.
686686
*/
687-
uint_fast16_t mac_helper_max_payload_size(protocol_interface_info_entry_t *cur, uint_fast8_t frame_overhead)
687+
uint_fast16_t mac_helper_max_payload_size(protocol_interface_info_entry_t *cur, uint_fast16_t frame_overhead)
688688
{
689689
uint16_t max;
690690

source/6LoWPAN/MAC/mac_helper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ bool mac_helper_write_our_addr(struct protocol_interface_info_entry *interface,
100100

101101
int8_t mac_helper_mac64_set(struct protocol_interface_info_entry *interface, const uint8_t *mac64);
102102

103-
uint_fast16_t mac_helper_max_payload_size(struct protocol_interface_info_entry *cur, uint_fast8_t frame_overhead);
103+
uint_fast16_t mac_helper_max_payload_size(struct protocol_interface_info_entry *cur, uint_fast16_t frame_overhead);
104104

105105
uint_fast8_t mac_helper_frame_overhead(struct protocol_interface_info_entry *cur, const struct buffer *buf);
106106

source/6LoWPAN/MAC/mac_response_handler.c

Lines changed: 2 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,9 @@
3131
#include "mac_mcps.h"
3232
#include "6LoWPAN/MAC/mac_data_poll.h"
3333
#include "6LoWPAN/MAC/mac_response_handler.h"
34+
#include "6LoWPAN/MAC/mpx_api.h"
3435
#include "6LoWPAN/lowpan_adaptation_interface.h"
3536

36-
static bool mac_data_is_broadcast_addr(const sockaddr_t *addr);
37-
3837
#define TRACE_GROUP "MRsH"
3938

4039

@@ -107,62 +106,10 @@ void mcps_data_confirm_handler( const mac_api_t* api, const mcps_data_conf_t *da
107106
lowpan_adaptation_interface_tx_confirm(info_entry, data);
108107
}
109108

110-
static bool mcps_data_indication_neighbor_validate(int8_t interface_id, const sockaddr_t *addr)
111-
{
112-
/* If MLE is enabled, we will talk if we have an MLE association */
113-
mle_neigh_table_entry_t *mle_entry = mle_class_get_by_link_address(interface_id, addr->address + 2, addr->addr_type);
114-
if (mle_entry && (mle_entry->handshakeReady || mle_entry->thread_commission)) {
115-
return true;
116-
}
117-
118-
/* Otherwise, we don't know them */
119-
return false;
120-
121-
}
122-
123109
void mcps_data_indication_handler( const mac_api_t* api, const mcps_data_ind_t *data_ind )
124110
{
125111
protocol_interface_info_entry_t *info_entry = protocol_stack_interface_info_get_by_id(api->parent_id);
126-
buffer_t *buf = buffer_get(data_ind->msduLength);
127-
if (!buf || !info_entry) {
128-
return;
129-
}
130-
uint8_t *ptr;
131-
buffer_data_add(buf, data_ind->msdu_ptr, data_ind->msduLength);
132-
//tr_debug("MAC Paylod size %u %s",data_ind->msduLength, trace_array(data_ind->msdu_ptr, 8));
133-
buf->options.lqi = data_ind->mpduLinkQuality;
134-
buf->options.dbm = data_ind->signal_dbm;
135-
buf->src_sa.addr_type = (addrtype_t)data_ind->SrcAddrMode;
136-
ptr = common_write_16_bit(data_ind->SrcPANId, buf->src_sa.address);
137-
memcpy(ptr, data_ind->SrcAddr, 8);
138-
buf->dst_sa.addr_type = (addrtype_t)data_ind->DstAddrMode;
139-
ptr = common_write_16_bit(data_ind->DstPANId, buf->dst_sa.address);
140-
memcpy(ptr, data_ind->DstAddr, 8);
141-
//Set Link spesific stuff to seperately
142-
buf->link_specific.ieee802_15_4.srcPanId = data_ind->SrcPANId;
143-
buf->link_specific.ieee802_15_4.dstPanId = data_ind->DstPANId;
144-
145-
if (mac_data_is_broadcast_addr(&buf->dst_sa)) {
146-
buf->options.ll_broadcast_rx = true;
147-
}
148-
buf->interface = info_entry;
149-
if (data_ind->Key.SecurityLevel) {
150-
buf->link_specific.ieee802_15_4.fc_security = true;
151-
152-
if (info_entry->mac_security_key_usage_update_cb) {
153-
info_entry->mac_security_key_usage_update_cb(info_entry, &data_ind->Key);
154-
}
155-
} else {
156-
buf->link_specific.ieee802_15_4.fc_security = false;
157-
if (mac_helper_default_security_level_get(info_entry) ||
158-
!mcps_data_indication_neighbor_validate(info_entry->id, &buf->src_sa)) {
159-
//SET By Pass
160-
buf->options.ll_security_bypass_rx = true;
161-
}
162-
}
163-
164-
buf->info = (buffer_info_t)(B_TO_IPV6_TXRX | B_FROM_MAC | B_DIR_UP);
165-
protocol_push(buf);
112+
lowpan_adaptation_interface_data_ind(info_entry, data_ind);
166113
}
167114

168115
void mcps_purge_confirm_handler( const mac_api_t* api, mcps_purge_conf_t *data )
@@ -306,9 +253,3 @@ void mlme_indication_handler( const mac_api_t* api, mlme_primitive id, const voi
306253
}
307254
}
308255

309-
bool mac_data_is_broadcast_addr(const sockaddr_t *addr)
310-
{
311-
return (addr->addr_type == ADDR_802_15_4_SHORT) &&
312-
(addr->address[2] == 0xFF && addr->address[3] == 0xFF);
313-
}
314-

source/6LoWPAN/Thread/thread_management_if.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
#include "Service_Libs/blacklist/blacklist.h"
7878
#include "6LoWPAN/MAC/mac_helper.h"
7979
#include "6LoWPAN/MAC/mac_pairwise_key.h"
80+
#include "6LoWPAN/MAC/mpx_api.h"
8081
#include "6LoWPAN/lowpan_adaptation_interface.h"
8182
#include "mac_common_defines.h"
8283
#include "mlme.h"

0 commit comments

Comments
 (0)