mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-24 22:13:52 +01:00
Merge pull request #10500 from miri64/gnrc_netif_hdr/enh/conv-netif-getter
gnrc_netif_hdr: provide convenience function to get netif pointer from netif header.
This commit is contained in:
commit
6551d8aac0
@ -26,6 +26,7 @@
|
||||
|
||||
#include "net/gnrc/pkt.h"
|
||||
#include "net/gnrc/pktbuf.h"
|
||||
#include "net/gnrc/netif.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -212,6 +213,23 @@ static inline void gnrc_netif_hdr_set_dst_addr(gnrc_netif_hdr_t *hdr, uint8_t *a
|
||||
*/
|
||||
gnrc_pktsnip_t *gnrc_netif_hdr_build(uint8_t *src, uint8_t src_len, uint8_t *dst, uint8_t dst_len);
|
||||
|
||||
/**
|
||||
* @brief Convenience function to get the corresponding interface struct for
|
||||
* a given interface header
|
||||
*
|
||||
* @pre `hdr != NULL`
|
||||
*
|
||||
* @param[in] hdr Header to read interface from.
|
||||
*
|
||||
* @return The @ref gnrc_netif_t representation of the interface on success
|
||||
* @return NULL, on error.
|
||||
*/
|
||||
static inline gnrc_netif_t *gnrc_netif_hdr_get_netif(const gnrc_netif_hdr_t *hdr)
|
||||
{
|
||||
assert(hdr != NULL);
|
||||
return gnrc_netif_get_by_pid(hdr->if_pid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Outputs a generic interface header to stdout.
|
||||
*
|
||||
|
||||
@ -49,8 +49,7 @@ static size_t _fit(const gnrc_pktsnip_t *orig_pkt)
|
||||
sizeof(ipv6_hdr_t);
|
||||
|
||||
if (netif_hdr) {
|
||||
gnrc_netif_hdr_t *data = netif_hdr->data;
|
||||
gnrc_netif_t *netif = gnrc_netif_get_by_pid(data->if_pid);
|
||||
gnrc_netif_t *netif = gnrc_netif_hdr_get_netif(netif_hdr->data);
|
||||
|
||||
pkt_len -= netif_hdr->size;
|
||||
DEBUG("gnrc_icmpv6_error: fitting to MTU of iface %u (%u)\n",
|
||||
|
||||
@ -639,7 +639,7 @@ static void _send(gnrc_pktsnip_t *pkt, bool prep_hdr)
|
||||
* higher layers wants to provide flags to the interface ) */
|
||||
const gnrc_netif_hdr_t *netif_hdr = pkt->data;
|
||||
|
||||
netif = gnrc_netif_get_by_pid(((gnrc_netif_hdr_t *)pkt->data)->if_pid);
|
||||
netif = gnrc_netif_hdr_get_netif(pkt->data);
|
||||
/* discard broadcast and multicast flags because those could be
|
||||
* potentially wrong (dst is later checked to assure that multicast is
|
||||
* set if dst is a multicast address) */
|
||||
|
||||
@ -246,7 +246,6 @@ static inline bool _add_uncompr_disp(gnrc_pktsnip_t *pkt)
|
||||
|
||||
static void _send(gnrc_pktsnip_t *pkt)
|
||||
{
|
||||
gnrc_netif_hdr_t *hdr;
|
||||
gnrc_pktsnip_t *tmp;
|
||||
gnrc_netif_t *netif;
|
||||
/* datagram_size: pure IPv6 packet without 6LoWPAN dispatches or compression */
|
||||
@ -272,8 +271,7 @@ static void _send(gnrc_pktsnip_t *pkt)
|
||||
return;
|
||||
}
|
||||
pkt = tmp;
|
||||
hdr = pkt->data;
|
||||
netif = gnrc_netif_get_by_pid(hdr->if_pid);
|
||||
netif = gnrc_netif_hdr_get_netif(pkt->data);
|
||||
datagram_size = gnrc_pkt_len(pkt->next);
|
||||
|
||||
if (netif == NULL) {
|
||||
|
||||
@ -1011,7 +1011,7 @@ void gnrc_sixlowpan_iphc_send(gnrc_pktsnip_t *pkt, void *ctx, unsigned page)
|
||||
dispatch->next = pkt->next;
|
||||
pkt->next = dispatch;
|
||||
|
||||
gnrc_netif_t *netif = gnrc_netif_get_by_pid(netif_hdr->if_pid);
|
||||
gnrc_netif_t *netif = gnrc_netif_hdr_get_netif(netif_hdr);
|
||||
assert(netif != NULL);
|
||||
gnrc_sixlowpan_multiplex_by_size(pkt, orig_datagram_size, netif, page);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user