pkg/nimble/netif: remove redundant netif ptr

This commit is contained in:
Hauke Petersen 2020-06-09 12:27:08 +02:00
parent 9270f31859
commit f024b4cd30

View File

@ -67,7 +67,7 @@ static char _stack[THREAD_STACKSIZE_DEFAULT];
static thread_t *_netif_thread;
/* keep the actual device state */
static gnrc_netif_t *_nimble_netif = NULL;
static gnrc_netif_t _netif;
static gnrc_nettype_t _nettype = NETTYPE;
/* keep a reference to the event callback */
@ -97,7 +97,7 @@ static void _netif_init(gnrc_netif_t *netif)
#if IS_USED(MODULE_GNRC_NETIF_6LO)
/* we disable fragmentation for this device, as the L2CAP layer takes care
* of this */
_nimble_netif->sixlo.max_frag_size = 0;
_netif.sixlo.max_frag_size = 0;
#endif /* IS_USED(MODULE_GNRC_NETIF_6LO) */
}
@ -190,7 +190,7 @@ static const gnrc_netif_ops_t _nimble_netif_ops = {
static inline int _netdev_init(netdev_t *dev)
{
_nimble_netif = dev->context;
(void)dev;
/* get our own address from the controller */
uint8_t tmp[6];
@ -198,7 +198,7 @@ static inline int _netdev_init(netdev_t *dev)
assert(res == 0);
(void)res;
bluetil_addr_swapped_cp(tmp, _nimble_netif->l2addr);
bluetil_addr_swapped_cp(tmp, _netif.l2addr);
return 0;
}
@ -211,7 +211,7 @@ static inline int _netdev_get(netdev_t *dev, netopt_t opt,
switch (opt) {
case NETOPT_ADDRESS:
assert(max_len >= BLE_ADDR_LEN);
memcpy(value, _nimble_netif->l2addr, BLE_ADDR_LEN);
memcpy(value, _netif.l2addr, BLE_ADDR_LEN);
res = BLE_ADDR_LEN;
break;
case NETOPT_ADDR_LEN:
@ -281,14 +281,14 @@ static void _on_data(nimble_netif_conn_t *conn, struct ble_l2cap_event *event)
/* allocate netif header */
gnrc_pktsnip_t *if_snip = gnrc_netif_hdr_build(conn->addr, BLE_ADDR_LEN,
_nimble_netif->l2addr,
_netif.l2addr,
BLE_ADDR_LEN);
if (if_snip == NULL) {
goto end;
}
/* we need to add the device PID to the netif header */
gnrc_netif_hdr_set_netif(if_snip->data, _nimble_netif);
gnrc_netif_hdr_set_netif(if_snip->data, &_netif);
/* allocate space in the pktbuf to store the packet */
gnrc_pktsnip_t *payload = gnrc_pktbuf_add(if_snip, NULL, rx_len, _nettype);
@ -513,7 +513,6 @@ static int _on_gap_slave_evt(struct ble_gap_event *event, void *arg)
return 0;
}
static gnrc_netif_t _netif;
void nimble_netif_init(void)
{
int res;
@ -617,7 +616,7 @@ int nimble_netif_accept(const uint8_t *ad, size_t ad_len,
adv_params, _on_gap_slave_evt, (void *)handle);
assert(res == 0);
_notify(handle, NIMBLE_NETIF_ACCEPTING, _nimble_netif->l2addr);
_notify(handle, NIMBLE_NETIF_ACCEPTING, _netif.l2addr);
return NIMBLE_NETIF_OK;
}
@ -633,7 +632,7 @@ int nimble_netif_accept_stop(void)
assert(res == 0);
(void)res;
nimble_netif_conn_free(handle, NULL);
_notify(handle, NIMBLE_NETIF_ACCEPT_STOP, _nimble_netif->l2addr);
_notify(handle, NIMBLE_NETIF_ACCEPT_STOP, _netif.l2addr);
return NIMBLE_NETIF_OK;
}