54#if UIP_MAX_ROUTES != 0
56#if ORCHESTRA_UNICAST_SENDER_BASED && ORCHESTRA_COLLISION_FREE_HASH
57#define UNICAST_SLOT_SHARED_FLAG ((ORCHESTRA_UNICAST_PERIOD < (ORCHESTRA_MAX_HASH + 1)) ? LINK_OPTION_SHARED : 0)
59#define UNICAST_SLOT_SHARED_FLAG LINK_OPTION_SHARED
62static uint16_t slotframe_handle = 0;
63static uint16_t local_channel_offset;
68get_node_timeslot(
const linkaddr_t *
addr)
70 if(
addr != NULL && ORCHESTRA_UNICAST_PERIOD > 0) {
71 return ORCHESTRA_LINKADDR_HASH(
addr) % ORCHESTRA_UNICAST_PERIOD;
78get_node_channel_offset(
const linkaddr_t *
addr)
80 if(
addr != NULL && ORCHESTRA_UNICAST_MAX_CHANNEL_OFFSET >= ORCHESTRA_UNICAST_MIN_CHANNEL_OFFSET) {
81 return ORCHESTRA_LINKADDR_HASH(
addr) % (ORCHESTRA_UNICAST_MAX_CHANNEL_OFFSET - ORCHESTRA_UNICAST_MIN_CHANNEL_OFFSET + 1)
82 + ORCHESTRA_UNICAST_MIN_CHANNEL_OFFSET;
89neighbor_has_uc_link(
const linkaddr_t *linkaddr)
95 if(!ORCHESTRA_UNICAST_SENDER_BASED) {
101 if(
linkaddr_cmp(&orchestra_parent_linkaddr, linkaddr)) {
103 return orchestra_parent_knows_us ? 1 : 0;
106 if(nbr_table_get_from_lladdr(nbr_routes, (linkaddr_t *)linkaddr) != NULL) {
116add_uc_link(
const linkaddr_t *linkaddr)
118 if(linkaddr != NULL) {
119 uint16_t timeslot = get_node_timeslot(linkaddr);
120 uint8_t link_options = ORCHESTRA_UNICAST_SENDER_BASED ? LINK_OPTION_RX : LINK_OPTION_TX | UNICAST_SLOT_SHARED_FLAG;
124 link_options |= ORCHESTRA_UNICAST_SENDER_BASED ? LINK_OPTION_TX | UNICAST_SLOT_SHARED_FLAG: LINK_OPTION_RX;
133 timeslot, local_channel_offset, 1);
138remove_uc_link(
const linkaddr_t *linkaddr)
143 if(linkaddr == NULL) {
147 timeslot = get_node_timeslot(linkaddr);
152 if(!ORCHESTRA_UNICAST_SENDER_BASED) {
159 if(timeslot == get_node_timeslot(&orchestra_parent_linkaddr)) {
165 nbr_table_item_t *item = nbr_table_head(nbr_routes);
166 while(item != NULL) {
167 linkaddr_t *
addr = nbr_table_get_lladdr(nbr_routes, item);
168 if(timeslot == get_node_timeslot(
addr)) {
172 item = nbr_table_next(nbr_routes, item);
178 uint8_t link_options = ORCHESTRA_UNICAST_SENDER_BASED ? LINK_OPTION_TX | UNICAST_SLOT_SHARED_FLAG: LINK_OPTION_RX;
180 timeslot, local_channel_offset, 1);
188child_added(
const linkaddr_t *linkaddr)
190 add_uc_link(linkaddr);
194child_removed(
const linkaddr_t *linkaddr)
196 remove_uc_link(linkaddr);
200select_packet(uint16_t *slotframe, uint16_t *timeslot, uint16_t *channel_offset)
203 const linkaddr_t *dest = packetbuf_addr(PACKETBUF_ADDR_RECEIVER);
204 if(packetbuf_attr(PACKETBUF_ATTR_FRAME_TYPE) == FRAME802154_DATAFRAME
205 && !orchestra_is_root_schedule_active(dest)
206 && neighbor_has_uc_link(dest)) {
207 if(slotframe != NULL) {
208 *slotframe = slotframe_handle;
210 if(timeslot != NULL) {
211 *timeslot = ORCHESTRA_UNICAST_SENDER_BASED ? get_node_timeslot(&
linkaddr_node_addr) : get_node_timeslot(dest);
214 if(channel_offset != NULL) {
215 *channel_offset = get_node_channel_offset(dest);
228 if(new_addr != NULL) {
233 remove_uc_link(old_addr);
234 add_uc_link(new_addr);
239init(uint16_t sf_handle)
244 slotframe_handle = sf_handle;
245 local_channel_offset = get_node_channel_offset(local_addr);
248 timeslot = get_node_timeslot(local_addr);
250 ORCHESTRA_UNICAST_SENDER_BASED ? LINK_OPTION_TX | UNICAST_SLOT_SHARED_FLAG: LINK_OPTION_RX,
251 LINK_TYPE_NORMAL, &tsch_broadcast_address,
252 timeslot, local_channel_offset, 1);
255struct orchestra_rule unicast_per_neighbor_rpl_storing = {
263 "unicast per neighbor storing",
264 ORCHESTRA_UNICAST_PERIOD,
linkaddr_t linkaddr_node_addr
The link-layer address of the node.
void linkaddr_copy(linkaddr_t *dest, const linkaddr_t *src)
Copy a link-layer address.
bool linkaddr_cmp(const linkaddr_t *addr1, const linkaddr_t *addr2)
Compare two link-layer addresses.
const linkaddr_t linkaddr_null
The null link-layer address.
struct tsch_link * tsch_schedule_add_link(struct tsch_slotframe *slotframe, uint8_t link_options, enum link_type link_type, const linkaddr_t *address, uint16_t timeslot, uint16_t channel_offset, uint8_t do_remove)
Adds a link to a slotframe.
struct tsch_link * tsch_schedule_get_link_by_offsets(struct tsch_slotframe *slotframe, uint16_t timeslot, uint16_t channel_offset)
Looks within a slotframe for a link with a given timeslot and channel offset.
void tsch_queue_free_packets_to(const linkaddr_t *addr)
Flush packets to a specific address.
struct tsch_slotframe * tsch_schedule_add_slotframe(uint16_t handle, uint16_t size)
Creates and adds a new slotframe.
linkaddr_t * tsch_queue_get_nbr_address(const struct tsch_neighbor *n)
Get the address of a neighbor.
int tsch_schedule_remove_link(struct tsch_slotframe *slotframe, struct tsch_link *l)
Removes a link.
Header file for the Packet buffer (packetbuf) management.
Routing driver header file.
An IEEE 802.15.4-2015 TSCH link (also called cell or slot)
TSCH neighbor information.
802.15.4e slotframe (contains links)
Header file for routing table manipulation.
static uip_ds6_addr_t * addr
Pointer to a nbr cache entry.