Lines Matching +full:static +full:- +full:address

4  * SPDX-License-Identifier: Apache-2.0
32 #define DEST_ADDR_OFFSET 5 /* Destination offset address*/
33 #define DEST_ADDR_TYPE_OFFSET 1 /* Destination address type */
35 #define DEST_ADDR_TYPE_MASK 0x0c /* Mask for destination address type */
37 #define DEST_ADDR_TYPE_SHORT 0x08 /* Short destination address type */
38 #define DEST_ADDR_TYPE_EXTENDED 0x0c /* Extended destination address type */
41 #define SHORT_ADDRESS_SIZE 2 /* Size of Short Mac Address */
42 #define EXTENDED_ADDRESS_SIZE 8 /* Size of Extended Mac Address */
44 /* Broadcast Short Address */
47 static uint8_t dev_pan_id[PAN_ID_SIZE]; /* Device Pan Id */
48 static uint8_t dev_short_addr[SHORT_ADDRESS_SIZE]; /* Device Short Address */
49 static uint8_t dev_ext_addr[EXTENDED_ADDRESS_SIZE]; /* Device Extended Address */
52 static const struct device *upipe_dev;
56 static bool received_dest_addr_matched(uint8_t *rx_buffer) in received_dest_addr_matched()
58 struct upipe_context *upipe = upipe_dev->data; in received_dest_addr_matched()
68 /* Check destination address */ in received_dest_addr_matched()
72 /* If not broadcast, check if length and address matches */ in received_dest_addr_matched()
76 (net_if_get_link_addr(upipe->iface)->len != in received_dest_addr_matched()
86 /* If not broadcast, check if length and address matches */ in received_dest_addr_matched()
87 if (net_if_get_link_addr(upipe->iface)->len != in received_dest_addr_matched()
104 static uint8_t *upipe_rx(uint8_t *buf, size_t *off) in upipe_rx()
113 upipe = upipe_dev->data; in upipe_rx()
114 if (!upipe->rx && *buf == UART_PIPE_RADIO_15_4_FRAME_TYPE) { in upipe_rx()
115 upipe->rx = true; in upipe_rx()
119 if (!upipe->rx_len) { in upipe_rx()
124 upipe->rx_len = *buf; in upipe_rx()
128 upipe->rx_buf[upipe->rx_off++] = *buf; in upipe_rx()
130 if (upipe->rx_len == upipe->rx_off) { in upipe_rx()
131 pkt = net_pkt_rx_alloc_with_buffer(upipe->iface, upipe->rx_len, in upipe_rx()
138 if (net_pkt_write(pkt, upipe->rx_buf, upipe->rx_len)) { in upipe_rx()
144 if (received_dest_addr_matched(pkt->buffer->data) == false) { in upipe_rx()
150 if (ieee802154_handle_ack(upipe->iface, pkt) == NET_OK) { in upipe_rx()
155 LOG_DBG("Caught a packet (%u)", upipe->rx_len); in upipe_rx()
156 if (net_recv_data(upipe->iface, pkt) < 0) { in upipe_rx()
165 upipe->rx = false; in upipe_rx()
166 upipe->rx_len = 0U; in upipe_rx()
167 upipe->rx_off = 0U; in upipe_rx()
175 static enum ieee802154_hw_caps upipe_get_capabilities(const struct device *dev) in upipe_get_capabilities()
180 static int upipe_cca(const struct device *dev) in upipe_cca()
182 struct upipe_context *upipe = dev->data; in upipe_cca()
184 if (upipe->stopped) { in upipe_cca()
185 return -EIO; in upipe_cca()
191 static int upipe_set_channel(const struct device *dev, uint16_t channel) in upipe_set_channel()
199 static int upipe_set_pan_id(const struct device *dev, uint16_t pan_id) in upipe_set_pan_id()
211 static int upipe_set_short_addr(const struct device *dev, uint16_t short_addr) in upipe_set_short_addr()
223 static int upipe_set_ieee_addr(const struct device *dev, in upipe_set_ieee_addr()
233 static int upipe_filter(const struct device *dev, in upipe_filter()
241 return -ENOTSUP; in upipe_filter()
245 return upipe_set_ieee_addr(dev, filter->ieee_addr); in upipe_filter()
247 return upipe_set_short_addr(dev, filter->short_addr); in upipe_filter()
249 return upipe_set_pan_id(dev, filter->pan_id); in upipe_filter()
252 return -ENOTSUP; in upipe_filter()
255 static int upipe_set_txpower(const struct device *dev, int16_t dbm) in upipe_set_txpower()
263 static int upipe_tx(const struct device *dev, in upipe_tx()
268 struct upipe_context *upipe = dev->data; in upipe_tx()
269 uint8_t *pkt_buf = frag->data; in upipe_tx()
270 uint8_t len = frag->len; in upipe_tx()
275 return -ENOTSUP; in upipe_tx()
280 if (upipe->stopped) { in upipe_tx()
281 return -EIO; in upipe_tx()
297 static int upipe_start(const struct device *dev) in upipe_start()
299 struct upipe_context *upipe = dev->data; in upipe_start()
301 if (!upipe->stopped) { in upipe_start()
302 return -EALREADY; in upipe_start()
305 upipe->stopped = false; in upipe_start()
310 static int upipe_stop(const struct device *dev) in upipe_stop()
312 struct upipe_context *upipe = dev->data; in upipe_stop()
314 if (upipe->stopped) { in upipe_stop()
315 return -EALREADY; in upipe_stop()
318 upipe->stopped = true; in upipe_stop()
323 /* driver-allocated attribute memory - constant across all driver instances */
327 static int upipe_attr_get(const struct device *dev, enum ieee802154_attr attr, in upipe_attr_get()
337 static int upipe_init(const struct device *dev) in upipe_init()
339 struct upipe_context *upipe = dev->data; in upipe_init()
343 uart_pipe_register(upipe->uart_pipe_buf, 1, upipe_rx); in upipe_init()
350 static inline uint8_t *get_mac(const struct device *dev) in get_mac()
352 struct upipe_context *upipe = dev->data; in get_mac()
354 upipe->mac_addr[0] = 0x00; in get_mac()
355 upipe->mac_addr[1] = 0x10; in get_mac()
356 upipe->mac_addr[2] = 0x20; in get_mac()
357 upipe->mac_addr[3] = 0x30; in get_mac()
360 sys_rand_get(&upipe->mac_addr[4], 4U); in get_mac()
362 upipe->mac_addr[4] = CONFIG_IEEE802154_UPIPE_MAC4; in get_mac()
363 upipe->mac_addr[5] = CONFIG_IEEE802154_UPIPE_MAC5; in get_mac()
364 upipe->mac_addr[6] = CONFIG_IEEE802154_UPIPE_MAC6; in get_mac()
365 upipe->mac_addr[7] = CONFIG_IEEE802154_UPIPE_MAC7; in get_mac()
368 return upipe->mac_addr; in get_mac()
371 static void upipe_iface_init(struct net_if *iface) in upipe_iface_init()
374 struct upipe_context *upipe = dev->data; in upipe_iface_init()
380 upipe->iface = iface; in upipe_iface_init()
385 static struct upipe_context upipe_context_data;
387 static const struct ieee802154_radio_api upipe_radio_api = {