44 #if ROUTING_CONF_RPL_LITE 45 #include "net/routing/rpl-lite/rpl.h" 46 #elif ROUTING_CONF_RPL_CLASSIC 47 #include "net/routing/rpl-classic/rpl.h" 48 #include "net/routing/rpl-classic/rpl-private.h" 52 #define LOG_MODULE "Orchestra" 53 #define LOG_LEVEL LOG_LEVEL_MAC 56 static void orchestra_packet_received(
void);
57 static void orchestra_packet_sent(
int mac_status);
58 NETSTACK_SNIFFER(orchestra_sniffer, orchestra_packet_received, orchestra_packet_sent);
61 linkaddr_t orchestra_parent_linkaddr;
63 int orchestra_parent_knows_us = 0;
66 const struct orchestra_rule *all_rules[] = ORCHESTRA_RULES;
67 #define NUM_RULES (sizeof(all_rules) / sizeof(struct orchestra_rule *)) 71 orchestra_packet_received(
void)
76 orchestra_packet_sent(
int mac_status)
79 if(orchestra_parent_knows_us == 0
81 && packetbuf_attr(PACKETBUF_ATTR_NETWORK_ID) == UIP_PROTO_ICMP6
82 && packetbuf_attr(PACKETBUF_ATTR_CHANNEL) == (
ICMP6_RPL << 8 | RPL_CODE_DAO)) {
84 &&
linkaddr_cmp(&orchestra_parent_linkaddr, packetbuf_addr(PACKETBUF_ADDR_RECEIVER))) {
85 orchestra_parent_knows_us = 1;
91 orchestra_callback_child_added(
const linkaddr_t *
addr)
95 for(i = 0; i < NUM_RULES; i++) {
96 if(all_rules[i]->child_added != NULL) {
97 all_rules[i]->child_added(addr);
103 orchestra_callback_child_removed(
const linkaddr_t *addr)
107 for(i = 0; i < NUM_RULES; i++) {
108 if(all_rules[i]->child_removed != NULL) {
109 all_rules[i]->child_removed(addr);
115 orchestra_callback_packet_ready(
void)
119 uint16_t slotframe = 0xffff;
120 uint16_t timeslot = 0xffff;
124 uint16_t channel_offset = 0xffff;
125 int matched_rule = -1;
128 for(i = 0; i < NUM_RULES; i++) {
129 if(all_rules[i]->select_packet != NULL) {
130 if(all_rules[i]->select_packet(&slotframe, ×lot, &channel_offset)) {
137 #if TSCH_WITH_LINK_SELECTOR 138 packetbuf_set_attr(PACKETBUF_ATTR_TSCH_SLOTFRAME, slotframe);
139 packetbuf_set_attr(PACKETBUF_ATTR_TSCH_TIMESLOT, timeslot);
140 packetbuf_set_attr(PACKETBUF_ATTR_TSCH_CHANNEL_OFFSET, channel_offset);
156 orchestra_parent_knows_us = 0;
158 for(i = 0; i < NUM_RULES; i++) {
159 if(all_rules[i]->new_time_source != NULL) {
160 all_rules[i]->new_time_source(old,
new);
171 netstack_sniffer_add(&orchestra_sniffer);
174 for(i = 0; i < NUM_RULES; i++) {
175 LOG_INFO(
"Initializing rule %s (%u), size %d\n", all_rules[i]->name, i, all_rules[i]->slotframe_size);
176 if(all_rules[i]->init != NULL) {
177 all_rules[i]->init(i);
180 LOG_INFO(
"Initialization done\n");
Header file for ICMPv6 message and error handing (RFC 4443)
static uip_ds6_addr_t * addr
Pointer to a nbr cache entry.
TSCH neighbor information.
const linkaddr_t linkaddr_null
The null link-layer address.
The MAC layer transmission was OK.
Routing driver header file
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.
Header file for the Packet buffer (packetbuf) management
Header file for the logging system