handled some warnings

[sys/net/sixlowpan/sixlowip.c]
* pointer in ipv6_process() for PROTO_NUM_NONE out-commented
* val = 0 as initial value

[sys/net/sixlowpan/sixlowmac.c]
* included and initialized hwtimer

[sys/net/sixlowpan/sixlownd.c sys/net/sixlowpan/sixlownd.h]
* initialized abro_version in recv_rtr_adv()
* ARO state according to draft-6lowpan-hc-16
This commit is contained in:
mlenders 2011-06-22 11:49:29 +02:00
parent 6263e59867
commit 2c20f8fafd
4 changed files with 34 additions and 26 deletions

View File

@ -112,7 +112,7 @@ void ipv6_process(void){
} }
case(PROTO_NUM_NONE):{ case(PROTO_NUM_NONE):{
//printf("Packet with no Header following the IPv6 Header received\n"); //printf("Packet with no Header following the IPv6 Header received\n");
uint8_t *ptr = get_payload_buf(ipv6_ext_hdr_len); //uint8_t *ptr = get_payload_buf(ipv6_ext_hdr_len);
printf("hello\n"); printf("hello\n");
} }
default: default:
@ -243,7 +243,7 @@ void ipv6_get_saddr(ipv6_addr_t *src, ipv6_addr_t *dst){
} }
uint8_t ipv6_get_addr_match(ipv6_addr_t *src, ipv6_addr_t *dst){ uint8_t ipv6_get_addr_match(ipv6_addr_t *src, ipv6_addr_t *dst){
uint8_t val, xor; uint8_t val = 0, xor;
for(int i = 0; i < 16; i++){ for(int i = 0; i < 16; i++){
/* if bytes are equal add 8 */ /* if bytes are equal add 8 */
if(src->uint8[i] == dst->uint8[i]){ if(src->uint8[i] == dst->uint8[i]){

View File

@ -7,6 +7,7 @@
#include "sixlownd.h" #include "sixlownd.h"
#include "sixlowpan.h" #include "sixlowpan.h"
#include <ltc4150.h> #include <ltc4150.h>
#include <hwtimer.h>
#include "thread.h" #include "thread.h"
#include "msg.h" #include "msg.h"
#include "radio/radio.h" #include "radio/radio.h"
@ -192,6 +193,7 @@ void send_ieee802154_frame(ieee_802154_long_t *addr, uint8_t *payload,
void sixlowmac_init(transceiver_type_t type){ void sixlowmac_init(transceiver_type_t type){
int recv_pid = thread_create(radio_stack_buffer, RADIO_STACK_SIZE, int recv_pid = thread_create(radio_stack_buffer, RADIO_STACK_SIZE,
PRIORITY_MAIN-2, CREATE_STACKTEST, recv_ieee802154_frame , "radio"); PRIORITY_MAIN-2, CREATE_STACKTEST, recv_ieee802154_frame , "radio");
hwtimer_init();
transceiver_type = type; transceiver_type = type;
transceiver_init(transceiver_type); transceiver_init(transceiver_type);
transceiver_start(); transceiver_start();

View File

@ -390,7 +390,7 @@ void recv_rtr_adv(void){
int8_t trigger_ns = -1; int8_t trigger_ns = -1;
int8_t abro_found = 0; int8_t abro_found = 0;
int16_t abro_version; int16_t abro_version = 0; // later replaced, just to supress warnings
ipv6_addr_t abro_addr; ipv6_addr_t abro_addr;
lowpan_context_t *found_contexts[LOWPAN_CONTEXT_MAX]; lowpan_context_t *found_contexts[LOWPAN_CONTEXT_MAX];
@ -624,7 +624,7 @@ void recv_nbr_sol(void){
uint8_t send_na = 0; uint8_t send_na = 0;
uint8_t sllao_set = 0; uint8_t sllao_set = 0;
uint8_t aro_state; uint8_t aro_state = OPT_ARO_STATE_SUCCESS;
/* check whick options are set, we need that because an aro /* check whick options are set, we need that because an aro
* option condition is that a sllao option is set. thus that we don't * option condition is that a sllao option is set. thus that we don't
@ -714,11 +714,10 @@ void recv_nbr_sol(void){
nbr_entry = nbr_cache_search(&(ipv6_buf->srcaddr)); nbr_entry = nbr_cache_search(&(ipv6_buf->srcaddr));
if(nbr_entry == NULL){ if(nbr_entry == NULL){
/* create neighbor cache */ /* create neighbor cache */
nbr_cache_add(&ipv6_buf->srcaddr, aro_state = nbr_cache_add(&ipv6_buf->srcaddr,
&(opt_aro_buf->eui64),0, &(opt_aro_buf->eui64),0,
NBR_STATUS_STALE, NBR_CACHE_TYPE_TEN, NBR_STATUS_STALE, NBR_CACHE_TYPE_TEN,
opt_aro_buf->reg_ltime, NULL); opt_aro_buf->reg_ltime, NULL);
aro_state = 0;
} else { } else {
if(memcmp(&(nbr_entry->addr.uint16[4]), if(memcmp(&(nbr_entry->addr.uint16[4]),
&(opt_aro_buf->eui64.uint16[0]),8) == 0){ &(opt_aro_buf->eui64.uint16[0]),8) == 0){
@ -734,9 +733,10 @@ void recv_nbr_sol(void){
memcpy(&(nbr_entry->addr.uint8[0]), memcpy(&(nbr_entry->addr.uint8[0]),
&(ipv6_buf->srcaddr.uint8[0]),16); &(ipv6_buf->srcaddr.uint8[0]),16);
} }
aro_state = OPT_ARO_STATE_SUCCESS;
} else { } else {
// duplicate found // duplicate found
aro_state = 1; aro_state = OPT_ARO_STATE_DUP_ADDR;
} }
} }
} }
@ -989,12 +989,14 @@ nbr_cache_t * nbr_cache_search(ipv6_addr_t *ipaddr){
return NULL; return NULL;
} }
void nbr_cache_add(ipv6_addr_t *ipaddr, ieee_802154_long_t *laddr, uint8_t nbr_cache_add(ipv6_addr_t *ipaddr, ieee_802154_long_t *laddr,
uint8_t isrouter, uint8_t state, uint8_t type, uint8_t isrouter, uint8_t state, uint8_t type,
uint16_t ltime, ieee_802154_short_t *saddr){ uint16_t ltime, ieee_802154_short_t *saddr){
if(nbr_count == NBR_CACHE_SIZE){ if(nbr_count == NBR_CACHE_SIZE){
printf("ERROR: neighbor cache full\n"); printf("ERROR: neighbor cache full\n");
} else { return OPT_ARO_STATE_NBR_CACHE_FULL;
}
memcpy(&(nbr_cache[nbr_count].addr), ipaddr, 16); memcpy(&(nbr_cache[nbr_count].addr), ipaddr, 16);
memcpy(&(nbr_cache[nbr_count].laddr), laddr, 8); memcpy(&(nbr_cache[nbr_count].laddr), laddr, 8);
nbr_cache[nbr_count].isrouter = isrouter; nbr_cache[nbr_count].isrouter = isrouter;
@ -1007,7 +1009,8 @@ void nbr_cache_add(ipv6_addr_t *ipaddr, ieee_802154_long_t *laddr,
// nd_nbr_cache_rem_pid); // nd_nbr_cache_rem_pid);
nbr_count++; nbr_count++;
}
return OPT_ARO_STATE_SUCCESS;
} }
void nbr_cache_auto_rem(void){ void nbr_cache_auto_rem(void){

View File

@ -51,6 +51,9 @@
#define OPT_ARO_LEN 2 #define OPT_ARO_LEN 2
#define OPT_ARO_HDR_LEN 16 #define OPT_ARO_HDR_LEN 16
#define OPT_ARO_LTIME 300 // geeigneten wert finden #define OPT_ARO_LTIME 300 // geeigneten wert finden
#define OPT_ARO_STATE_SUCCESS 0
#define OPT_ARO_STATE_DUP_ADDR 1
#define OPT_ARO_STATE_NBR_CACHE_FULL 2
/* 6lowpan context option */ /* 6lowpan context option */
#define OPT_6CO_TYPE 32 #define OPT_6CO_TYPE 32
#define OPT_6CO_MIN_LEN 2 #define OPT_6CO_MIN_LEN 2
@ -221,7 +224,7 @@ abr_cache_t *abr_update_cache(
lowpan_context_t **contexts, uint8_t contexts_num, lowpan_context_t **contexts, uint8_t contexts_num,
plist_t **prefixes, uint8_t prefixes_num); plist_t **prefixes, uint8_t prefixes_num);
nbr_cache_t * nbr_cache_search(ipv6_addr_t *ipaddr); nbr_cache_t * nbr_cache_search(ipv6_addr_t *ipaddr);
void nbr_cache_add(ipv6_addr_t *ipaddr, ieee_802154_long_t *laddr, uint8_t nbr_cache_add(ipv6_addr_t *ipaddr, ieee_802154_long_t *laddr,
uint8_t isrouter, uint8_t state, uint8_t type, uint8_t isrouter, uint8_t state, uint8_t type,
uint16_t ltime, ieee_802154_short_t *saddr); uint16_t ltime, ieee_802154_short_t *saddr);
void nbr_cache_auto_rem(void); void nbr_cache_auto_rem(void);