Changeset 544
- Timestamp:
- 04/26/08 19:29:27 (3 weeks ago)
- Files:
-
- nano-RK/projects/SAMPL/app_pkt_handlers/neighbor_pkt.c (added)
- nano-RK/projects/SAMPL/app_pkt_handlers/neighbor_pkt.h (added)
- nano-RK/projects/SAMPL/app_pkt_handlers/stats_pkt.c (modified) (1 diff)
- nano-RK/projects/SAMPL/client/globals.h (modified) (1 diff)
- nano-RK/projects/SAMPL/client/main.c (modified) (3 diffs)
- nano-RK/projects/SAMPL/client/makefile (modified) (1 diff)
- nano-RK/projects/SAMPL/client/nrk_cfg.h (modified) (1 diff)
- nano-RK/src/net/route_table/route_table.c (modified) (9 diffs)
- nano-RK/src/net/route_table/route_table.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
nano-RK/projects/SAMPL/app_pkt_handlers/stats_pkt.c
r541 r544 89 89 uint8_t stats_pkt_add( STATS_PKT_T *p, uint8_t *buf, uint8_t index ) 90 90 { 91 if((index+1)*STATS_PKT_SIZE +STATS_PKT_SIZE>MAX_PKT_PAYLOAD ) return (index*STATS_PKT_SIZE+STATS_PKT_SIZE);91 if((index+1)*STATS_PKT_SIZE>MAX_PKT_PAYLOAD ) return (index*STATS_PKT_SIZE); 92 92 buf[index*STATS_PKT_SIZE]= p->mac_addr; 93 93 buf[index*STATS_PKT_SIZE+1]= (p->rx_pkts>>8)&0xff; nano-RK/projects/SAMPL/client/globals.h
r537 r544 10 10 uint8_t admin_debug_flag; 11 11 int8_t mobile_reserve; 12 uint16_t neighborlist_ttl; 12 13 13 14 nano-RK/projects/SAMPL/client/main.c
r537 r544 183 183 route_table_init(); 184 184 185 // 100 ms by default 185 // Default neighbor list TTL is 10 minutes 186 neighborlist_ttl=600; 187 188 // 100 ms by default 186 189 last_flood_check_rate = 100; 187 190 // Setup some default values … … 360 363 // Set the reply address for the gateway (mac=0) to last-hop with no ttl timeout 361 364 route_table_set( GATEWAY_MAC, ds_pkt.last_hop_mac, 0 ); 365 // Add neighbor, with timeout 366 route_table_set( ds_pkt.last_hop_mac, ds_pkt.last_hop_mac, neighborlist_ttl ); 367 // Insert RSSI from neighbor 368 route_table_value_set(ds_pkt.last_hop_mac, 0, ds_pkt.rssi ); 369 362 370 if(ds_pkt.ctrl_flags & ENCRYPT != 0) 363 371 { … … 385 393 // Upstream Packet to Aggregate 386 394 else if (ff_state == FLOOD_ACTIVE_STATE && upstream == 1) { 395 // Add neighbor, with timeout 396 route_table_set( us_pkt.last_hop_src_mac, us_pkt.last_hop_src_mac, neighborlist_ttl ); 397 // Insert RSSI from neighbor 398 route_table_value_set(us_pkt.last_hop_src_mac, 0, us_pkt.rssi ); 399 387 400 if ( us_pkt_in.seq_num == last_flood_seq_num && check_subnet( us_pkt_in.subnet_mac, my_subnet_mac)==1 ) { 388 401 if ((last_flood_ctrl & TREE_FILTER) != 0) { nano-RK/projects/SAMPL/client/makefile
r538 r544 32 32 SRC += ../app_pkt_handlers/stats_pkt.c 33 33 SRC += ../app_pkt_handlers/trace.c 34 SRC += ../app_pkt_handlers/neighbor_pkt.c 34 35 SRC += ../app_pkt_handlers/eeprom_data.c 35 36 SRC += ../app_pkt_handlers/control_pkt.c nano-RK/projects/SAMPL/client/nrk_cfg.h
r540 r544 46 46 #define NRK_MAX_RESOURCE_CNT 2 47 47 48 #define ROUTE_TABLE_SIZE 15 49 #define ROUTE_TABLE_VALUES 1 50 51 48 52 // 1 reserve for bmac 49 53 // 1 reserve for mobile nodes nano-RK/src/net/route_table/route_table.c
r428 r544 13 13 for(i=0; i<ROUTE_TABLE_SIZE; i++ ) 14 14 { 15 route_table[i]. valid=0;15 route_table[i].flags=0; 16 16 route_table[i].dst=0; 17 17 route_table[i].next_hop=0; … … 41 41 else 42 42 { 43 route_table[i]. valid=0;43 route_table[i].flags=0; 44 44 route_table[i].ttl=0; 45 45 route_table[i].dst=0; … … 63 63 route_table[i].next_hop=next_hop; 64 64 route_table[i].ttl=ttl; 65 route_table[i]. valid=1;65 route_table[i].flags|=VALID_MASK; 66 66 return NRK_OK; 67 67 } … … 73 73 route_table[found].next_hop=next_hop; 74 74 route_table[found].ttl=ttl; 75 route_table[found]. valid=1;75 route_table[found].flags|=VALID_MASK; 76 76 return NRK_OK; 77 77 } … … 86 86 if(route_table[i].dst==dst) 87 87 { 88 route_table[i]. valid=0;88 route_table[i].flags=0; 89 89 route_table[i].dst=0; 90 90 route_table[i].ttl=0; … … 103 103 for(i=0; i<ROUTE_TABLE_SIZE; i++ ) 104 104 { 105 if( route_table[i].valid==1&& route_table[i].dst==dst)105 if((route_table[i].flags & VALID_MASK)!=0 && route_table[i].dst==dst) 106 106 return (route_table[i].next_hop); 107 107 } … … 116 116 for(i=0; i<ROUTE_TABLE_SIZE; i++ ) 117 117 { 118 if( route_table[i].valid==1&& route_table[i].dst==dst )118 if((route_table[i].flags & VALID_MASK )!=0 && route_table[i].dst==dst ) 119 119 { 120 120 route_table[i].value[value_index]=value; … … 131 131 for(i=0; i<ROUTE_TABLE_SIZE; i++ ) 132 132 { 133 if( route_table[i].valid==1&& route_table[i].dst==dst!=0)133 if((route_table[i].flags & VALID_MASK) !=0 && route_table[i].dst==dst!=0) 134 134 { 135 135 return (route_table[i].value[value_index]); … … 139 139 } 140 140 141 // This function returns the next valid index including 142 // the entered value. 143 // 144 // For example if index 0 and 4 are valid 145 // route_table_get_next_valid_index(0) returns 0 146 // route_table_get_next_valid_index(1) returns 4 147 // route_table_get_next_valid_index(4) returns 4 148 // route_table_get_next_valid_index(5) returns -1 149 int8_t route_table_get_next_valid_index(uint8_t start_index) 150 { 151 uint8_t i; 152 if(start_index>=ROUTE_TABLE_VALUES ) return NRK_ERROR; 153 for(i=start_index; i<ROUTE_TABLE_SIZE; i++ ) 154 if((route_table[i].flags & VALID_MASK) !=0 ) 155 return i; 156 return NRK_ERROR; 157 } 141 158 159 uint16_t route_table_get_dst_by_index(int8_t index) 160 { 161 if(index>=ROUTE_TABLE_VALUES ) return 0; 162 return route_table[index].dst; 142 163 164 } nano-RK/src/net/route_table/route_table.h
r428 r544 14 14 #endif 15 15 16 #define VALID_MASK 0x01 17 #define EXTENDED_ADDRESS_MASK 0x02 18 19 16 20 typedef struct route_type { 17 21 uint16_t dst; 18 22 uint16_t next_hop; 19 23 uint16_t ttl; 20 int8_t valid;24 int8_t flags; 21 25 int8_t value[ROUTE_TABLE_VALUES]; 22 26 } route_table_t; … … 25 29 26 30 int8_t route_table_init(); 27 int8_t route_table_set( uint16_t dst, uint16_t next_hop, uint16_t ttl );31 int8_t route_table_set( uint16_t dst, uint16_t next_hop, uint16_t ttl); 28 32 int8_t route_table_clr( uint16_t dst); 29 33 uint16_t route_table_get( uint16_t dst); … … 33 37 int8_t route_table_value_get(uint16_t dst, uint8_t value_index); 34 38 39 // Use these functions to help do neighbor list tabulation 40 int8_t route_table_get_next_valid_index(uint8_t start_index); 41 uint16_t route_table_get_dst_by_index(int8_t index); 42 35 43 #endif
