fb.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2019 Freie Universität Berlin
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
20 #ifndef NET_GNRC_SIXLOWPAN_FRAG_FB_H
21 #define NET_GNRC_SIXLOWPAN_FRAG_FB_H
22 
23 #include <stdbool.h>
24 #include <stdint.h>
25 
26 #include "msg.h"
27 #include "net/gnrc/pkt.h"
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
36 #define GNRC_SIXLOWPAN_FRAG_FB_SND_MSG (0x0225)
37 
41 typedef struct {
43  uint16_t datagram_size;
44  uint16_t tag;
45  uint16_t offset;
47 #ifdef MODULE_GNRC_SIXLOWPAN_FRAG_HINT
48 
53 #endif /* MODULE_GNRC_SIXLOWPAN_FRAG_HINT */
55 
56 #ifdef TEST_SUITES
57 
63 #endif
64 
72 
82 
88 uint16_t gnrc_sixlowpan_frag_fb_next_tag(void);
89 
90 #if defined(TEST_SUITES) && !defined(DOXYGEN)
91 #include "sched.h"
92 
93 /* can't include `net/sixlowpan.h` as this would create a cyclical include */
95 #endif
96 
108 {
109  msg_t msg;
110 
111  msg.content.ptr = fbuf;
113 #ifdef TEST_SUITES
114  return (msg_try_send(&msg, gnrc_sixlowpan_get_pid()) > 0);
115 #else
116  return (msg_send_to_self(&msg) != 0);
117 #endif
118 }
119 
120 #ifdef __cplusplus
121 }
122 #endif
123 
124 #endif /* NET_GNRC_SIXLOWPAN_FRAG_FB_H */
125 
kernel_pid_t
int16_t kernel_pid_t
Unique process identifier.
Definition: sched.h:125
msg_send_to_self
int msg_send_to_self(msg_t *m)
Send a message to the current thread.
gnrc_sixlowpan_get_pid
kernel_pid_t gnrc_sixlowpan_get_pid(void)
Returns the PID of the 6Lo thread.
gnrc_sixlowpan_frag_fb_send
static bool gnrc_sixlowpan_frag_fb_send(gnrc_sixlowpan_frag_fb_t *fbuf)
Sends a message to pass a further fragment down the network stack.
Definition: fb.h:107
gnrc_sixlowpan_frag_hint_t
A fragment size hint.
Definition: hint.h:33
msg_t::type
uint16_t type
Type field.
Definition: msg.h:188
gnrc_sixlowpan_frag_fb_t::tag
uint16_t tag
Tag used for the fragment.
Definition: fb.h:44
msg.h
Messaging API for inter process communication.
sched.h
Scheduler API definition.
msg_t::ptr
void * ptr
Pointer content field.
Definition: msg.h:190
msg_try_send
int msg_try_send(msg_t *m, kernel_pid_t target_pid)
Send a message (non-blocking).
gnrc_sixlowpan_frag_fb_next_tag
uint16_t gnrc_sixlowpan_frag_fb_next_tag(void)
Generate a new datagram tag for sending.
msg_t::content
union msg_t::@2 content
Content of the message.
pkt.h
General definitions for network packets and their helper functions.
gnrc_sixlowpan_frag_fb_t::pkt
gnrc_pktsnip_t * pkt
Pointer to the IPv6 packet to be fragmented.
Definition: fb.h:42
gnrc_sixlowpan_frag_fb_t::offset
uint16_t offset
Offset of the Nth fragment from the beginning of the payload datagram.
Definition: fb.h:45
gnrc_sixlowpan_frag_fb_t
6LoWPAN fragmentation buffer entry.
Definition: fb.h:41
gnrc_sixlowpan_frag_fb_t::datagram_size
uint16_t datagram_size
Length of just the (uncompressed) IPv6 packet to be fragmented.
Definition: fb.h:43
gnrc_sixlowpan_frag_fb_reset
void gnrc_sixlowpan_frag_fb_reset(void)
Reset fragmentation buffer.
gnrc_sixlowpan_frag_fb_get_by_tag
gnrc_sixlowpan_frag_fb_t * gnrc_sixlowpan_frag_fb_get_by_tag(uint16_t tag)
Get an existing fragmentation buffer entry by a given tag.
GNRC_SIXLOWPAN_FRAG_FB_SND_MSG
#define GNRC_SIXLOWPAN_FRAG_FB_SND_MSG
Message type for passing one 6LoWPAN fragment down the network stack.
Definition: fb.h:36
msg_t
Describes a message object which can be sent between threads.
Definition: msg.h:185
gnrc_pktsnip
Type to represent parts (either headers or payload) of a packet, called snips.
Definition: pkt.h:108
gnrc_sixlowpan_frag_fb_get
gnrc_sixlowpan_frag_fb_t * gnrc_sixlowpan_frag_fb_get(void)
Allocates a fragmentation buffer entry.