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);
126 remove_uc_link(
const linkaddr_t *linkaddr)
131 if(linkaddr == NULL) {
135 timeslot = get_node_timeslot(linkaddr);
141 if(timeslot == get_node_timeslot(&orchestra_parent_linkaddr)) {
147 nbr_table_item_t *item = nbr_table_head(nbr_routes);
148 while(item != NULL) {
149 linkaddr_t *addr = nbr_table_get_lladdr(nbr_routes, item);
150 if(timeslot == get_node_timeslot(addr)) {
154 item = nbr_table_next(nbr_routes, item);
160 uint8_t link_options = ORCHESTRA_UNICAST_SENDER_BASED ? LINK_OPTION_TX | UNICAST_SLOT_SHARED_FLAG: LINK_OPTION_RX;
162 timeslot, local_channel_offset);
170 child_added(
const linkaddr_t *linkaddr)
172 add_uc_link(linkaddr);
176 child_removed(
const linkaddr_t *linkaddr)
178 remove_uc_link(linkaddr);
182 select_packet(uint16_t *slotframe, uint16_t *timeslot, uint16_t *channel_offset)
185 const linkaddr_t *dest = packetbuf_addr(PACKETBUF_ADDR_RECEIVER);
186 if(packetbuf_attr(PACKETBUF_ATTR_FRAME_TYPE) == FRAME802154_DATAFRAME
187 && neighbor_has_uc_link(dest)) {
188 if(slotframe != NULL) {
189 *slotframe = slotframe_handle;
191 if(timeslot != NULL) {
192 *timeslot = ORCHESTRA_UNICAST_SENDER_BASED ? get_node_timeslot(&
linkaddr_node_addr) : get_node_timeslot(dest);
195 if(channel_offset != NULL) {
196 *channel_offset = get_node_channel_offset(dest);
207 const linkaddr_t *old_addr = old != NULL ? &old->addr : NULL;
208 const linkaddr_t *new_addr =
new != NULL ? &
new->addr : NULL;
209 if(new_addr != NULL) {
214 remove_uc_link(old_addr);
215 add_uc_link(new_addr);
220 init(uint16_t sf_handle)
225 slotframe_handle = sf_handle;
226 local_channel_offset = get_node_channel_offset(local_addr);
229 timeslot = get_node_timeslot(local_addr);
231 ORCHESTRA_UNICAST_SENDER_BASED ? LINK_OPTION_TX | UNICAST_SLOT_SHARED_FLAG: LINK_OPTION_RX,
232 LINK_TYPE_NORMAL, &tsch_broadcast_address,
233 timeslot, local_channel_offset);
236 struct orchestra_rule unicast_per_neighbor_rpl_storing = {
242 "unicast per neighbor storing",
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.
Routing driver header file
int tsch_schedule_remove_link(struct tsch_slotframe *slotframe, struct tsch_link *l)
Removes a link.
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)
Adds a link to a slotframe.
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