gnrc_sixlowpan_frag: encapsulate msg_send_to_self()
This makes it easier to access this functionality for test cases e.g. from the `main` thread.
This commit is contained in:
parent
d562af40e6
commit
931b179d14
@ -29,9 +29,10 @@
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "byteorder.h"
|
||||
#include "kernel_types.h"
|
||||
#include "msg.h"
|
||||
#include "net/gnrc/pkt.h"
|
||||
#include "net/gnrc/netif/hdr.h"
|
||||
#include "net/gnrc/sixlowpan/internal.h"
|
||||
#include "net/ieee802154.h"
|
||||
#include "net/sixlowpan.h"
|
||||
|
||||
@ -133,6 +134,29 @@ void gnrc_sixlowpan_frag_recv(gnrc_pktsnip_t *pkt, void *ctx, unsigned page);
|
||||
*/
|
||||
void gnrc_sixlowpan_frag_rbuf_gc(void);
|
||||
|
||||
/**
|
||||
* @brief Sends a message to pass a further fragment down the network stack
|
||||
*
|
||||
* @see GNRC_SIXLOWPAN_MSG_FRAG_SND
|
||||
*
|
||||
* @param[in] fragment_msg A @ref gnrc_sixlowpan_msg_frag_t object
|
||||
*
|
||||
* @return true, when the message was sent
|
||||
* @return false when sending the message failed.
|
||||
*/
|
||||
static inline bool gnrc_sixlowpan_frag_send_msg(gnrc_sixlowpan_msg_frag_t *fragment_msg)
|
||||
{
|
||||
msg_t msg;
|
||||
|
||||
msg.content.ptr = fragment_msg;
|
||||
msg.type = GNRC_SIXLOWPAN_MSG_FRAG_SND;
|
||||
#ifdef TEST_SUITES
|
||||
return (msg_try_send(&msg, gnrc_sixlowpan_get_pid()) > 0);
|
||||
#else
|
||||
return (msg_send_to_self(&msg) != 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(MODULE_GNRC_SIXLOWPAN_FRAG) || defined(DOXYGEN)
|
||||
/**
|
||||
* @brief Removes an entry from the reassembly buffer
|
||||
|
||||
@ -27,6 +27,14 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Returns the PID of the 6Lo thread
|
||||
*
|
||||
* @return The PID of the 6Lo thread on success
|
||||
* @return KERNEL_PID_UNDEF, when 6Lo thread was not started.
|
||||
*/
|
||||
kernel_pid_t gnrc_sixlowpan_get_pid(void);
|
||||
|
||||
/**
|
||||
* @brief Delegates a packet to the network layer
|
||||
*
|
||||
|
||||
@ -241,7 +241,6 @@ void gnrc_sixlowpan_frag_send(gnrc_pktsnip_t *pkt, void *ctx, unsigned page)
|
||||
/* payload_len: actual size of the packet vs
|
||||
* datagram_size: size of the uncompressed IPv6 packet */
|
||||
size_t payload_len = gnrc_pkt_len(fragment_msg->pkt->next);
|
||||
msg_t msg;
|
||||
|
||||
assert((fragment_msg->pkt == pkt) || (pkt == NULL));
|
||||
(void)page;
|
||||
@ -284,9 +283,7 @@ void gnrc_sixlowpan_frag_send(gnrc_pktsnip_t *pkt, void *ctx, unsigned page)
|
||||
goto error;
|
||||
}
|
||||
fragment_msg->offset += res;
|
||||
msg.type = GNRC_SIXLOWPAN_MSG_FRAG_SND,
|
||||
msg.content.ptr = fragment_msg;
|
||||
if (msg_send_to_self(&msg) == 0) {
|
||||
if (!gnrc_sixlowpan_frag_send_msg(fragment_msg)) {
|
||||
DEBUG("6lo frag: message queue full, can't issue next fragment "
|
||||
"sending\n");
|
||||
goto error;
|
||||
|
||||
@ -55,6 +55,11 @@ kernel_pid_t gnrc_sixlowpan_init(void)
|
||||
return _pid;
|
||||
}
|
||||
|
||||
kernel_pid_t gnrc_sixlowpan_get_pid(void)
|
||||
{
|
||||
return _pid;
|
||||
}
|
||||
|
||||
void gnrc_sixlowpan_dispatch_recv(gnrc_pktsnip_t *pkt, void *context,
|
||||
unsigned page)
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user