Lines Matching +full:ext +full:- +full:address +full:- +full:match

4  * SPDX-License-Identifier: Apache-2.0
11 * All references to the spec refer to IEEE 802.15.4-2020.
79 if (!mpdu->mhr.fs->fc.ar) { in ieee802154_acknowledge()
89 if (ieee802154_create_ack_frame(iface, pkt, mpdu->mhr.fs->sequence)) { in ieee802154_acknowledge()
91 ieee802154_radio_tx(iface, IEEE802154_TX_MODE_DIRECT, pkt, pkt->buffer); in ieee802154_acknowledge()
109 struct ieee802154_fcf_seq *fs = (struct ieee802154_fcf_seq *)frag->data; in ieee802154_prepare_for_ack()
112 ctx->ack_seq = fs->sequence; in ieee802154_prepare_for_ack()
113 if (k_sem_count_get(&ctx->ack_lock) == 1U) { in ieee802154_prepare_for_ack()
114 k_sem_take(&ctx->ack_lock, K_NO_WAIT); in ieee802154_prepare_for_ack()
128 __ASSERT_NO_MSG(ctx->ack_seq == 0U); in ieee802154_handle_ack()
133 if (pkt->buffer->len == IEEE802154_ACK_PKT_LENGTH) { in ieee802154_handle_ack()
138 if (!fs || fs->fc.frame_type != IEEE802154_FRAME_TYPE_ACK || in ieee802154_handle_ack()
139 fs->sequence != ctx->ack_seq) { in ieee802154_handle_ack()
143 k_sem_give(&ctx->ack_lock); in ieee802154_handle_ack()
159 __ASSERT_NO_MSG(ctx->ack_seq == 0U); in ieee802154_wait_for_ack()
163 ret = k_sem_take(&ctx->ack_lock, K_MSEC(10)); in ieee802154_wait_for_ack()
165 /* no-op */ in ieee802154_wait_for_ack()
166 } else if (ret == -EAGAIN) { in ieee802154_wait_for_ack()
167 ret = -ETIME; in ieee802154_wait_for_ack()
170 ret = -EFAULT; in ieee802154_wait_for_ack()
173 ctx->ack_seq = 0U; in ieee802154_wait_for_ack()
210 /* No-op in case the driver has IEEE802154_HW_TX_RX_ACK capability. */ in ieee802154_radio_send()
214 * - CSMA/CA in case the driver has IEEE802154_HW_CSMA capability, in ieee802154_radio_send()
215 * - waiting for ACK in case the driver has IEEE802154_HW_TX_RX_ACK capability, in ieee802154_radio_send()
216 * - retransmission on ACK timeout in case the driver has in ieee802154_radio_send()
237 /* No-op in case the driver has IEEE802154_HW_TX_RX_ACK capability. */ in ieee802154_radio_send()
240 /* ACK received - transmission is successful. */ in ieee802154_radio_send()
244 remaining_attempts--; in ieee802154_radio_send()
247 return -EIO; in ieee802154_radio_send()
254 addr->type = NET_LINK_IEEE802154; in swap_and_set_pkt_ll_addr()
258 addr->len = IEEE802154_EXT_ADDR_LENGTH; in swap_and_set_pkt_ll_addr()
259 addr->addr = has_pan_id ? ll->plain.addr.ext_addr : ll->comp.addr.ext_addr; in swap_and_set_pkt_ll_addr()
263 addr->len = IEEE802154_SHORT_ADDR_LENGTH; in swap_and_set_pkt_ll_addr()
264 addr->addr = (uint8_t *)(has_pan_id ? &ll->plain.addr.short_addr in swap_and_set_pkt_ll_addr()
265 : &ll->comp.addr.short_addr); in swap_and_set_pkt_ll_addr()
270 addr->len = 0U; in swap_and_set_pkt_ll_addr()
271 addr->addr = NULL; in swap_and_set_pkt_ll_addr()
275 * so we must swap it. This is ok as the L2 address field points into the L2 in swap_and_set_pkt_ll_addr()
279 if (addr->len > 0) { in swap_and_set_pkt_ll_addr()
280 sys_mem_swap(addr->addr, addr->len); in swap_and_set_pkt_ll_addr()
285 * Filters the destination address of the frame.
291 struct ieee802154_address_field_plain *dst_plain = &mhr->dst_addr->plain; in ieee802154_check_dst_addr()
295 /* Apply filtering requirements from section 6.7.2 c)-e). For a)-b), in ieee802154_check_dst_addr()
299 if (mhr->fs->fc.dst_addr_mode == IEEE802154_ADDR_MODE_NONE) { in ieee802154_check_dst_addr()
300 if (mhr->fs->fc.frame_version < IEEE802154_VERSION_802154 && in ieee802154_check_dst_addr()
301 mhr->fs->fc.frame_type == IEEE802154_FRAME_TYPE_BEACON) { in ieee802154_check_dst_addr()
302 /* See IEEE 802.15.4-2015, section 7.3.1.1. */ in ieee802154_check_dst_addr()
311 k_sem_take(&ctx->ctx_lock, K_FOREVER); in ieee802154_check_dst_addr()
313 /* c) If a destination PAN ID is included in the frame, it shall match in ieee802154_check_dst_addr()
316 if (!(dst_plain->pan_id == IEEE802154_BROADCAST_PAN_ID || in ieee802154_check_dst_addr()
317 dst_plain->pan_id == sys_cpu_to_le16(ctx->pan_id))) { in ieee802154_check_dst_addr()
318 LOG_DBG("Frame PAN ID does not match!"); in ieee802154_check_dst_addr()
322 if (mhr->fs->fc.dst_addr_mode == IEEE802154_ADDR_MODE_SHORT) { in ieee802154_check_dst_addr()
323 /* d.1) A short destination address is included in the frame, in ieee802154_check_dst_addr()
325 * address. in ieee802154_check_dst_addr()
327 if (!(dst_plain->addr.short_addr == IEEE802154_BROADCAST_ADDRESS || in ieee802154_check_dst_addr()
328 dst_plain->addr.short_addr == sys_cpu_to_le16(ctx->short_addr))) { in ieee802154_check_dst_addr()
329 LOG_DBG("Frame dst address (short) does not match!"); in ieee802154_check_dst_addr()
333 } else if (mhr->fs->fc.dst_addr_mode == IEEE802154_ADDR_MODE_EXTENDED) { in ieee802154_check_dst_addr()
334 /* d.2) An extended destination address is included in the frame and in ieee802154_check_dst_addr()
337 if (memcmp(dst_plain->addr.ext_addr, ctx->ext_addr, in ieee802154_check_dst_addr()
339 LOG_DBG("Frame dst address (ext) does not match!"); in ieee802154_check_dst_addr()
343 /* TODO: d.3) The Destination Address field and the Destination PAN ID in ieee802154_check_dst_addr()
355 k_sem_give(&ctx->ctx_lock); in ieee802154_check_dst_addr()
361 const struct ieee802154_radio_api *radio = net_if_get_device(iface)->api; in ieee802154_recv()
368 /* The IEEE 802.15.4 stack assumes that drivers provide a single-fragment package. */ in ieee802154_recv()
369 __ASSERT_NO_MSG(pkt->buffer && pkt->buffer->frags == NULL); in ieee802154_recv()
375 /* validate LL destination address (when IEEE802154_HW_FILTER not available) */ in ieee802154_recv()
376 if (!(radio->get_capabilities(net_if_get_device(iface)) & IEEE802154_HW_FILTER) && in ieee802154_recv()
383 if (fs->fc.frame_type == IEEE802154_FRAME_TYPE_ACK) { in ieee802154_recv()
387 if (fs->fc.frame_type == IEEE802154_FRAME_TYPE_BEACON) { in ieee802154_recv()
401 if (fs->fc.frame_type == IEEE802154_FRAME_TYPE_MAC_COMMAND) { in ieee802154_recv()
414 if (fs->fc.dst_addr_mode == IEEE802154_ADDR_MODE_SHORT) { in ieee802154_recv()
418 short_dst_addr = fs->fc.pan_id_comp ? dst_addr->comp.addr.short_addr in ieee802154_recv()
419 : dst_addr->plain.addr.short_addr; in ieee802154_recv()
428 if (fs->fc.frame_type == IEEE802154_FRAME_TYPE_MAC_COMMAND) { in ieee802154_recv()
441 swap_and_set_pkt_ll_addr(net_pkt_lladdr_src(pkt), !fs->fc.pan_id_comp, in ieee802154_recv()
442 fs->fc.src_addr_mode, mpdu.mhr.src_addr); in ieee802154_recv()
444 swap_and_set_pkt_ll_addr(net_pkt_lladdr_dst(pkt), true, fs->fc.dst_addr_mode, in ieee802154_recv()
451 ll_hdr_len = (uint8_t *)mpdu.payload - net_pkt_data(pkt); in ieee802154_recv()
452 net_buf_pull(pkt->buffer, ll_hdr_len); in ieee802154_recv()
465 * MCPS-DATA.indication primitive, see section 8.3.3. in ieee802154_recv()
470 * Implements (part of) the MCPS-DATA.request/confirm primitives, see sections 8.3.2/3.
495 return -EINVAL; in ieee802154_send()
503 struct sockaddr_ll *dst_addr = (struct sockaddr_ll *)&context->remote; in ieee802154_send()
505 (struct sockaddr_ll_ptr *)&context->local; in ieee802154_send()
507 net_pkt_lladdr_dst(pkt)->addr = dst_addr->sll_addr; in ieee802154_send()
508 net_pkt_lladdr_dst(pkt)->len = dst_addr->sll_halen; in ieee802154_send()
509 net_pkt_lladdr_src(pkt)->addr = src_addr->sll_addr; in ieee802154_send()
510 net_pkt_lladdr_src(pkt)->len = src_addr->sll_halen; in ieee802154_send()
512 return -EINVAL; in ieee802154_send()
537 pkt_buf = pkt->buffer; in ieee802154_send()
549 net_buf_add_mem(frame_buf, pkt_buf->data, pkt_buf->len); in ieee802154_send()
550 pkt_buf = pkt_buf->frags; in ieee802154_send()
553 if (ll_hdr_len + pkt_buf->len + authtag_len > IEEE802154_MTU) { in ieee802154_send()
554 NET_ERR("Frame too long: %d", pkt_buf->len); in ieee802154_send()
555 return -EINVAL; in ieee802154_send()
557 net_buf_add_mem(frame_buf, pkt_buf->data, pkt_buf->len); in ieee802154_send()
558 pkt_buf = pkt_buf->frags; in ieee802154_send()
567 return -EINVAL; in ieee802154_send()
575 len += frame_buf->len; in ieee802154_send()
589 k_sem_take(&ctx->ctx_lock, K_FOREVER); in ieee802154_enable()
591 if (ctx->channel == IEEE802154_NO_CHANNEL) { in ieee802154_enable()
592 k_sem_give(&ctx->ctx_lock); in ieee802154_enable()
593 return -ENETDOWN; in ieee802154_enable()
596 k_sem_give(&ctx->ctx_lock); in ieee802154_enable()
612 return ctx->flags; in ieee802154_flags()
620 const uint8_t *eui64_be = net_if_get_link_addr(iface)->addr; in ieee802154_init()
625 k_sem_init(&ctx->ctx_lock, 1, 1); in ieee802154_init()
626 k_sem_init(&ctx->ack_lock, 0, 1); in ieee802154_init()
632 /* See section 6.7.1 - Transmission: "Each device shall initialize its data sequence number in ieee802154_init()
636 ctx->sequence = sys_rand32_get() & 0xFF; in ieee802154_init()
638 ctx->channel = IEEE802154_NO_CHANNEL; in ieee802154_init()
639 ctx->flags = NET_L2_MULTICAST; in ieee802154_init()
641 ctx->flags |= NET_L2_PROMISC_MODE; in ieee802154_init()
644 ctx->pan_id = IEEE802154_PAN_ID_NOT_ASSOCIATED; in ieee802154_init()
645 ctx->short_addr = IEEE802154_SHORT_ADDRESS_NOT_ASSOCIATED; in ieee802154_init()
646 ctx->coord_short_addr = IEEE802154_SHORT_ADDRESS_NOT_ASSOCIATED; in ieee802154_init()
647 sys_memcpy_swap(ctx->ext_addr, eui64_be, IEEE802154_EXT_ADDR_LENGTH); in ieee802154_init()
649 /* We switch to a link address store that we in ieee802154_init()
654 ctx->linkaddr.type = NET_LINK_IEEE802154; in ieee802154_init()
655 ctx->linkaddr.len = IEEE802154_EXT_ADDR_LENGTH; in ieee802154_init()
656 memcpy(ctx->linkaddr.addr, eui64_be, IEEE802154_EXT_ADDR_LENGTH); in ieee802154_init()
657 net_if_set_link_addr(iface, ctx->linkaddr.addr, ctx->linkaddr.len, ctx->linkaddr.type); in ieee802154_init()
668 if (ieee802154_security_init(&ctx->sec_ctx)) { in ieee802154_init()
669 NET_ERR("Initializing link-layer security failed"); in ieee802154_init()
673 sys_memcpy_swap(ctx->ext_addr, eui64_be, IEEE802154_EXT_ADDR_LENGTH); in ieee802154_init()
674 ieee802154_radio_filter_ieee_addr(iface, ctx->ext_addr); in ieee802154_init()
677 ctx->tx_power = tx_power; in ieee802154_init()