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 62 static uint16_t slotframe_handle = 0;
63 static uint16_t local_channel_offset;
68 get_node_timeslot(
const linkaddr_t *
addr)
70 if(addr != NULL && ORCHESTRA_UNICAST_PERIOD > 0) {
71 return ORCHESTRA_LINKADDR_HASH(addr) % ORCHESTRA_UNICAST_PERIOD;
78 get_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;
89 neighbor_has_uc_link(
const linkaddr_t *linkaddr)
92 if((orchestra_parent_knows_us || !ORCHESTRA_UNICAST_SENDER_BASED)
96 if(nbr_table_get_from_lladdr(nbr_routes, (linkaddr_t *)linkaddr) != NULL) {
104 add_uc_link(
const linkaddr_t *linkaddr)
106 if(linkaddr != NULL) {
107 uint16_t timeslot = get_node_timeslot(linkaddr);
108 uint8_t link_options = ORCHESTRA_UNICAST_SENDER_BASED ? LINK_OPTION_RX : LINK_OPTION_TX | UNICAST_SLOT_SHARED_FLAG;
112 link_options |= ORCHESTRA_UNICAST_SENDER_BASED ? LINK_OPTION_TX | UNICAST_SLOT_SHARED_FLAG: LINK_OPTION_RX;
121 timeslot, local_channel_offset, 1);
126 remove_uc_link(
const linkaddr_t *linkaddr)
131 if(linkaddr == NULL) {
135 timeslot = get_node_timeslot(linkaddr);
140 if(!ORCHESTRA_UNICAST_SENDER_BASED) {
147 if(timeslot == get_node_timeslot(&orchestra_parent_linkaddr)) {
153 nbr_table_item_t *item = nbr_table_head(nbr_routes);
154 while(item != NULL) {
155 linkaddr_t *addr = nbr_table_get_lladdr(nbr_routes, item);
156 if(timeslot == get_node_timeslot(addr)) {
160 item = nbr_table_next(nbr_routes, item);
166 uint8_t link_options = ORCHESTRA_UNICAST_SENDER_BASED ? LINK_OPTION_TX | UNICAST_SLOT_SHARED_FLAG: LINK_OPTION_RX;
168 timeslot, local_channel_offset, 1);
176 child_added(
const linkaddr_t *linkaddr)
178 add_uc_link(linkaddr);
182 child_removed(
const linkaddr_t *linkaddr)
184 remove_uc_link(linkaddr);
188 select_packet(uint16_t *slotframe, uint16_t *timeslot, uint16_t *channel_offset)
191 const linkaddr_t *dest = packetbuf_addr(PACKETBUF_ADDR_RECEIVER);
192 if(packetbuf_attr(PACKETBUF_ATTR_FRAME_TYPE) == FRAME802154_DATAFRAME
193 && !orchestra_is_root_schedule_active(dest)
194 && neighbor_has_uc_link(dest)) {
195 if(slotframe != NULL) {
196 *slotframe = slotframe_handle;
198 if(timeslot != NULL) {
199 *timeslot = ORCHESTRA_UNICAST_SENDER_BASED ? get_node_timeslot(&
linkaddr_node_addr) : get_node_timeslot(dest);
202 if(channel_offset != NULL) {
203 *channel_offset = get_node_channel_offset(dest);
216 if(new_addr != NULL) {
221 remove_uc_link(old_addr);
222 add_uc_link(new_addr);
227 init(uint16_t sf_handle)
232 slotframe_handle = sf_handle;
233 local_channel_offset = get_node_channel_offset(local_addr);
236 timeslot = get_node_timeslot(local_addr);
238 ORCHESTRA_UNICAST_SENDER_BASED ? LINK_OPTION_TX | UNICAST_SLOT_SHARED_FLAG: LINK_OPTION_RX,
239 LINK_TYPE_NORMAL, &tsch_broadcast_address,
240 timeslot, local_channel_offset, 1);
243 struct orchestra_rule unicast_per_neighbor_rpl_storing = {
250 "unicast per neighbor storing",
251 ORCHESTRA_UNICAST_PERIOD,
static uip_ds6_addr_t * addr
Pointer to a nbr cache entry.
TSCH neighbor information.
802.15.4e slotframe (contains links)
struct tsch_slotframe * tsch_schedule_add_slotframe(uint16_t handle, uint16_t size)
Creates and adds a new slotframe.
const linkaddr_t linkaddr_null
The null link-layer address.
linkaddr_t linkaddr_node_addr
The link-layer address of the node.
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.
linkaddr_t * tsch_queue_get_nbr_address(const struct tsch_neighbor *n)
Get the address of a neighbor.
Routing driver header file
int tsch_schedule_remove_link(struct tsch_slotframe *slotframe, struct tsch_link *l)
Removes a link.
void linkaddr_copy(linkaddr_t *dest, const linkaddr_t *src)
Copy a link-layer address.
int linkaddr_cmp(const linkaddr_t *addr1, const linkaddr_t *addr2)
Compare two link-layer addresses.
struct tsch_link * tsch_schedule_get_link_by_timeslot(struct tsch_slotframe *slotframe, uint16_t timeslot, uint16_t channel_offset)
Looks within a slotframe for a link with a given timeslot.
Header file for routing table manipulation.
An IEEE 802.15.4-2015 TSCH link (also called cell or slot)
Header file for the Packet buffer (packetbuf) management
void tsch_queue_free_packets_to(const linkaddr_t *addr)
Flush packets to a specific address.