Merge branch 'mac' of ssh://ukleos/home/git/ukleos into mac
This commit is contained in:
commit
e1734ff3d7
@ -1,6 +1,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <vtimer.h>
|
#include <vtimer.h>
|
||||||
#include <thread.h>
|
#include <thread.h>
|
||||||
|
#include <mutex.h>
|
||||||
#include "msg.h"
|
#include "msg.h"
|
||||||
#include "rpl.h"
|
#include "rpl.h"
|
||||||
#include "of0.h"
|
#include "of0.h"
|
||||||
@ -19,12 +20,28 @@ rpl_of_t *objective_functions[NUMBER_IMPLEMENTED_OFS];
|
|||||||
rpl_routing_entry_t routing_table[RPL_MAX_ROUTING_ENTRIES];
|
rpl_routing_entry_t routing_table[RPL_MAX_ROUTING_ENTRIES];
|
||||||
unsigned int rpl_process_pid;
|
unsigned int rpl_process_pid;
|
||||||
ipv6_addr_t my_address;
|
ipv6_addr_t my_address;
|
||||||
|
mutex_t rpl_send_mutex;
|
||||||
|
mutex_t rpl_recv_mutex;
|
||||||
|
//receive buffer without LL_HDR
|
||||||
|
uint8_t rpl_buffer[BUFFER_SIZE - LL_HDR_LEN];
|
||||||
|
//in send buffer we need space fpr LL_HDR
|
||||||
|
uint8_t rpl_send_buffer[BUFFER_SIZE];
|
||||||
|
|
||||||
msg_t msg_queue[RPL_PKT_RECV_BUF_SIZE];
|
msg_t msg_queue[RPL_PKT_RECV_BUF_SIZE];
|
||||||
|
//SEND BUFFERS
|
||||||
|
static struct ipv6_hdr_t* ipv6_send_buf;
|
||||||
|
static struct icmpv6_hdr_t* icmp_send_buf;
|
||||||
|
static struct rpl_dio_t *rpl_send_dio_buf;
|
||||||
|
static struct rpl_dis_t *rpl_send_dis_buf;
|
||||||
|
static struct rpl_dao_t *rpl_send_dao_buf;
|
||||||
|
static struct rpl_opt_dodag_conf_t * rpl_send_opt_dodag_conf_buf;
|
||||||
|
static struct rpl_opt_solicited_t * rpl_send_opt_solicited_buf;
|
||||||
|
static struct rpl_opt_target_t * rpl_send_opt_target_buf;
|
||||||
|
static struct rpl_opt_transit_t * rpl_send_opt_transit_buf;
|
||||||
|
|
||||||
|
//RECEIVE BUFFERS
|
||||||
//Unbenutzter dao_ack buffer auskommentiert, damit keine warnings erscheinen
|
//Unbenutzter dao_ack buffer auskommentiert, damit keine warnings erscheinen
|
||||||
static struct ipv6_hdr_t* ipv6_buf;
|
static struct ipv6_hdr_t* ipv6_buf;
|
||||||
static struct icmpv6_hdr_t* icmp_buf;
|
|
||||||
static struct rpl_dio_t *rpl_dio_buf;
|
static struct rpl_dio_t *rpl_dio_buf;
|
||||||
static struct rpl_dis_t *rpl_dis_buf;
|
static struct rpl_dis_t *rpl_dis_buf;
|
||||||
static struct rpl_dao_t *rpl_dao_buf;
|
static struct rpl_dao_t *rpl_dao_buf;
|
||||||
@ -35,38 +52,82 @@ static struct rpl_opt_solicited_t * rpl_opt_solicited_buf;
|
|||||||
static struct rpl_opt_target_t * rpl_opt_target_buf;
|
static struct rpl_opt_target_t * rpl_opt_target_buf;
|
||||||
static struct rpl_opt_transit_t * rpl_opt_transit_buf;
|
static struct rpl_opt_transit_t * rpl_opt_transit_buf;
|
||||||
|
|
||||||
|
// SEND BUFFERS
|
||||||
|
static struct ipv6_hdr_t * get_rpl_send_ipv6_buf(void){
|
||||||
|
return ((struct ipv6_hdr_t*)&(rpl_send_buffer[0]));
|
||||||
|
}
|
||||||
|
static uint8_t * get_rpl_send_payload_buf(uint8_t ext_len){
|
||||||
|
//return &(rpl_send_buffer[LLHDR_IPV6HDR_LEN + ext_len]);
|
||||||
|
return &(rpl_send_buffer[IPV6_HDR_LEN + ext_len]);
|
||||||
|
}
|
||||||
|
static struct icmpv6_hdr_t * get_rpl_send_icmpv6_buf(uint8_t ext_len){
|
||||||
|
//return ((struct icmpv6_hdr_t*)&(rpl_send_buffer[LLHDR_IPV6HDR_LEN + ext_len]));
|
||||||
|
return ((struct icmpv6_hdr_t*)&(rpl_send_buffer[IPV6_HDR_LEN + ext_len]));
|
||||||
|
}
|
||||||
|
static struct rpl_dio_t* get_rpl_send_dio_buf(){
|
||||||
|
//return ((struct rpl_dio_t*)&(rpl_send_buffer[LLHDR_ICMPV6HDR_LEN]));
|
||||||
|
return ((struct rpl_dio_t*)&(rpl_send_buffer[IPV6HDR_ICMPV6HDR_LEN]));
|
||||||
|
}
|
||||||
|
static struct rpl_dao_t* get_rpl_send_dao_buf(){
|
||||||
|
//return ((struct rpl_dao_t*)&(rpl_send_buffer[LLHDR_ICMPV6HDR_LEN]));
|
||||||
|
return ((struct rpl_dao_t*)&(rpl_send_buffer[IPV6HDR_ICMPV6HDR_LEN]));
|
||||||
|
}
|
||||||
|
static struct rpl_dis_t* get_rpl_send_dis_buf(){
|
||||||
|
//return ((struct rpl_dis_t*)&(rpl_send_buffer[LLHDR_ICMPV6HDR_LEN]));
|
||||||
|
return ((struct rpl_dis_t*)&(rpl_send_buffer[IPV6HDR_ICMPV6HDR_LEN]));
|
||||||
|
}
|
||||||
|
static struct rpl_opt_dodag_conf_t* get_rpl_send_opt_dodag_conf_buf(uint8_t rpl_msg_len){
|
||||||
|
//return ((struct rpl_opt_dodag_conf_t*)&(rpl_send_buffer[LLHDR_ICMPV6HDR_LEN + rpl_msg_len]));
|
||||||
|
return ((struct rpl_opt_dodag_conf_t*)&(rpl_send_buffer[IPV6HDR_ICMPV6HDR_LEN + rpl_msg_len]));
|
||||||
|
}
|
||||||
|
static struct rpl_opt_target_t* get_rpl_send_opt_target_buf(uint8_t rpl_msg_len){
|
||||||
|
//return ((struct rpl_opt_target_t*)&(rpl_send_buffer[LLHDR_ICMPV6HDR_LEN + rpl_msg_len]));
|
||||||
|
return ((struct rpl_opt_target_t*)&(rpl_send_buffer[IPV6HDR_ICMPV6HDR_LEN + rpl_msg_len]));
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct rpl_opt_transit_t* get_rpl_send_opt_transit_buf(uint8_t rpl_msg_len){
|
||||||
|
//return ((struct rpl_opt_transit_t*)&(rpl_send_buffer[LLHDR_ICMPV6HDR_LEN + rpl_msg_len]));
|
||||||
|
return ((struct rpl_opt_transit_t*)&(rpl_send_buffer[IPV6HDR_ICMPV6HDR_LEN + rpl_msg_len]));
|
||||||
|
}
|
||||||
|
|
||||||
|
//RECEIVE BUFFERS
|
||||||
|
static struct ipv6_hdr_t * get_rpl_ipv6_buf(void){
|
||||||
|
return ((struct ipv6_hdr_t*)&(rpl_buffer[0]));
|
||||||
|
}
|
||||||
|
//static struct icmpv6_hdr_t * get_rpl_icmpv6_buf(uint8_t ext_len){
|
||||||
|
// return ((struct icmpv6_hdr_t*)&(rpl_buffer[IPV6_HDR_LEN + ext_len]));
|
||||||
|
//}
|
||||||
static struct rpl_dio_t* get_rpl_dio_buf(){
|
static struct rpl_dio_t* get_rpl_dio_buf(){
|
||||||
return ((struct rpl_dio_t*)&(buffer[LLHDR_ICMPV6HDR_LEN]));
|
return ((struct rpl_dio_t*)&(rpl_buffer[IPV6HDR_ICMPV6HDR_LEN]));
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct rpl_dao_t* get_rpl_dao_buf(){
|
static struct rpl_dao_t* get_rpl_dao_buf(){
|
||||||
return ((struct rpl_dao_t*)&(buffer[LLHDR_ICMPV6HDR_LEN]));
|
return ((struct rpl_dao_t*)&(rpl_buffer[IPV6HDR_ICMPV6HDR_LEN]));
|
||||||
}
|
}
|
||||||
/*static struct rpl_dao_ack_t* get_rpl_dao_ack_buf(){
|
/*static struct rpl_dao_ack_t* get_rpl_dao_ack_buf(){
|
||||||
return ((struct rpl_dao_ack_t*)&(buffer[LLHDR_ICMPV6HDR_LEN]));
|
return ((struct rpl_dao_ack_t*)&(buffer[LLHDR_ICMPV6HDR_LEN]));
|
||||||
}*/
|
}*/
|
||||||
static struct rpl_dis_t* get_rpl_dis_buf(){
|
static struct rpl_dis_t* get_rpl_dis_buf(){
|
||||||
return ((struct rpl_dis_t*)&(buffer[LLHDR_ICMPV6HDR_LEN]));
|
return ((struct rpl_dis_t*)&(rpl_buffer[IPV6HDR_ICMPV6HDR_LEN]));
|
||||||
}
|
}
|
||||||
static struct rpl_opt_t* get_rpl_opt_buf(uint8_t rpl_msg_len){
|
static struct rpl_opt_t* get_rpl_opt_buf(uint8_t rpl_msg_len){
|
||||||
return ((struct rpl_opt_t*)&(buffer[LLHDR_ICMPV6HDR_LEN + rpl_msg_len]));
|
return ((struct rpl_opt_t*)&(rpl_buffer[IPV6HDR_ICMPV6HDR_LEN + rpl_msg_len]));
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct rpl_opt_dodag_conf_t* get_rpl_opt_dodag_conf_buf(uint8_t rpl_msg_len){
|
static struct rpl_opt_dodag_conf_t* get_rpl_opt_dodag_conf_buf(uint8_t rpl_msg_len){
|
||||||
return ((struct rpl_opt_dodag_conf_t*)&(buffer[LLHDR_ICMPV6HDR_LEN + rpl_msg_len]));
|
return ((struct rpl_opt_dodag_conf_t*)&(rpl_buffer[IPV6HDR_ICMPV6HDR_LEN + rpl_msg_len]));
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct rpl_opt_solicited_t* get_rpl_opt_solicited_buf(uint8_t rpl_msg_len){
|
static struct rpl_opt_solicited_t* get_rpl_opt_solicited_buf(uint8_t rpl_msg_len){
|
||||||
return ((struct rpl_opt_solicited_t*)&(buffer[LLHDR_ICMPV6HDR_LEN + rpl_msg_len]));
|
return ((struct rpl_opt_solicited_t*)&(rpl_buffer[IPV6HDR_ICMPV6HDR_LEN + rpl_msg_len]));
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct rpl_opt_target_t* get_rpl_opt_target_buf(uint8_t rpl_msg_len){
|
static struct rpl_opt_target_t* get_rpl_opt_target_buf(uint8_t rpl_msg_len){
|
||||||
return ((struct rpl_opt_target_t*)&(buffer[LLHDR_ICMPV6HDR_LEN + rpl_msg_len]));
|
return ((struct rpl_opt_target_t*)&(rpl_buffer[IPV6HDR_ICMPV6HDR_LEN + rpl_msg_len]));
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct rpl_opt_transit_t* get_rpl_opt_transit_buf(uint8_t rpl_msg_len){
|
static struct rpl_opt_transit_t* get_rpl_opt_transit_buf(uint8_t rpl_msg_len){
|
||||||
return ((struct rpl_opt_transit_t*)&(buffer[LLHDR_ICMPV6HDR_LEN + rpl_msg_len]));
|
return ((struct rpl_opt_transit_t*)&(rpl_buffer[IPV6HDR_ICMPV6HDR_LEN + rpl_msg_len]));
|
||||||
}
|
}
|
||||||
|
|
||||||
//Diese Funktion findet eine implementierte OF anhand des Objective Code Point
|
//Diese Funktion findet eine implementierte OF anhand des Objective Code Point
|
||||||
@ -81,6 +142,8 @@ rpl_of_t *rpl_get_of_for_ocp(uint16_t ocp){
|
|||||||
|
|
||||||
uint8_t rpl_init(transceiver_type_t trans, ipv6_addr_t *rpl_address){
|
uint8_t rpl_init(transceiver_type_t trans, ipv6_addr_t *rpl_address){
|
||||||
vtimer_init();
|
vtimer_init();
|
||||||
|
mutex_init(&rpl_send_mutex);
|
||||||
|
mutex_init(&rpl_recv_mutex);
|
||||||
if(rpl_address == NULL){
|
if(rpl_address == NULL){
|
||||||
return SIXLOWERROR_ADDRESS;
|
return SIXLOWERROR_ADDRESS;
|
||||||
}
|
}
|
||||||
@ -154,68 +217,73 @@ void rpl_init_root(){
|
|||||||
|
|
||||||
void send_DIO(ipv6_addr_t* destination){
|
void send_DIO(ipv6_addr_t* destination){
|
||||||
puts("\nSEND DIO");
|
puts("\nSEND DIO");
|
||||||
|
mutex_lock(&rpl_send_mutex);
|
||||||
rpl_dodag_t * mydodag;
|
rpl_dodag_t * mydodag;
|
||||||
icmp_buf = get_icmpv6_buf(ipv6_ext_hdr_len);
|
icmp_send_buf = get_rpl_send_icmpv6_buf(ipv6_ext_hdr_len);
|
||||||
|
|
||||||
mydodag = rpl_get_my_dodag();
|
mydodag = rpl_get_my_dodag();
|
||||||
if(mydodag == NULL){
|
if(mydodag == NULL){
|
||||||
printf("Error, trying to send DIO without being part of a dodag. This should not happen\n");
|
printf("Error, trying to send DIO without being part of a dodag. This should not happen\n");
|
||||||
|
mutex_unlock(&rpl_send_mutex, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
icmp_buf->type = ICMP_RPL_CONTROL;
|
icmp_send_buf->type = ICMP_RPL_CONTROL;
|
||||||
icmp_buf->code = ICMP_CODE_DIO;
|
icmp_send_buf->code = ICMP_CODE_DIO;
|
||||||
icmp_buf->checksum = ~icmpv6_csum(PROTO_NUM_ICMPV6);
|
icmp_send_buf->checksum = ~icmpv6_csum(PROTO_NUM_ICMPV6);
|
||||||
|
|
||||||
rpl_dio_buf = get_rpl_dio_buf();
|
rpl_send_dio_buf = get_rpl_send_dio_buf();
|
||||||
memset(rpl_dio_buf, 0, sizeof(*rpl_dio_buf));
|
memset(rpl_send_dio_buf, 0, sizeof(*rpl_send_dio_buf));
|
||||||
rpl_dio_buf->rpl_instanceid = mydodag->instance->id;
|
rpl_send_dio_buf->rpl_instanceid = mydodag->instance->id;
|
||||||
rpl_dio_buf->version_number = mydodag->version;
|
rpl_send_dio_buf->version_number = mydodag->version;
|
||||||
rpl_dio_buf->rank = mydodag->my_rank;
|
rpl_send_dio_buf->rank = mydodag->my_rank;
|
||||||
rpl_dio_buf->g_mop_prf = (mydodag->grounded << RPL_GROUNDED_SHIFT) | (mydodag->mop << RPL_MOP_SHIFT) | mydodag->prf;
|
rpl_send_dio_buf->g_mop_prf = (mydodag->grounded << RPL_GROUNDED_SHIFT) | (mydodag->mop << RPL_MOP_SHIFT) | mydodag->prf;
|
||||||
rpl_dio_buf->dtsn = mydodag->dtsn;
|
rpl_send_dio_buf->dtsn = mydodag->dtsn;
|
||||||
rpl_dio_buf->flags = 0;
|
rpl_send_dio_buf->flags = 0;
|
||||||
rpl_dio_buf->reserved = 0;
|
rpl_send_dio_buf->reserved = 0;
|
||||||
rpl_dio_buf->dodagid = mydodag->dodag_id;
|
rpl_send_dio_buf->dodagid = mydodag->dodag_id;
|
||||||
//printf("Send DIO with DODAGID: \n");
|
//printf("Send DIO with DODAGID: \n");
|
||||||
//ipv6_print_addr(&rpl_dio_buf->dodagid);
|
//ipv6_print_addr(&rpl_dio_buf->dodagid);
|
||||||
|
|
||||||
int opt_hdr_len = 0;
|
int opt_hdr_len = 0;
|
||||||
//DODAG Configuration Option!
|
//DODAG Configuration Option!
|
||||||
rpl_opt_dodag_conf_buf = get_rpl_opt_dodag_conf_buf(DIO_BASE_LEN);
|
rpl_send_opt_dodag_conf_buf = get_rpl_send_opt_dodag_conf_buf(DIO_BASE_LEN);
|
||||||
rpl_opt_dodag_conf_buf->type = RPL_OPT_DODAG_CONF;
|
rpl_send_opt_dodag_conf_buf->type = RPL_OPT_DODAG_CONF;
|
||||||
rpl_opt_dodag_conf_buf->length = RPL_OPT_DODAG_CONF_LEN;
|
rpl_send_opt_dodag_conf_buf->length = RPL_OPT_DODAG_CONF_LEN;
|
||||||
rpl_opt_dodag_conf_buf->flags_a_pcs = 0;
|
rpl_send_opt_dodag_conf_buf->flags_a_pcs = 0;
|
||||||
rpl_opt_dodag_conf_buf->DIOIntDoubl = mydodag->dio_interval_doubling;
|
rpl_send_opt_dodag_conf_buf->DIOIntDoubl = mydodag->dio_interval_doubling;
|
||||||
rpl_opt_dodag_conf_buf->DIOIntMin = mydodag->dio_min;
|
rpl_send_opt_dodag_conf_buf->DIOIntMin = mydodag->dio_min;
|
||||||
rpl_opt_dodag_conf_buf->DIORedun = mydodag->dio_redundancy;
|
rpl_send_opt_dodag_conf_buf->DIORedun = mydodag->dio_redundancy;
|
||||||
rpl_opt_dodag_conf_buf->MaxRankIncrease = mydodag->maxrankincrease;
|
rpl_send_opt_dodag_conf_buf->MaxRankIncrease = mydodag->maxrankincrease;
|
||||||
rpl_opt_dodag_conf_buf->MinHopRankIncrease = mydodag->minhoprankincrease;
|
rpl_send_opt_dodag_conf_buf->MinHopRankIncrease = mydodag->minhoprankincrease;
|
||||||
rpl_opt_dodag_conf_buf->ocp = mydodag->of->ocp;
|
rpl_send_opt_dodag_conf_buf->ocp = mydodag->of->ocp;
|
||||||
rpl_opt_dodag_conf_buf->reserved = 0;
|
rpl_send_opt_dodag_conf_buf->reserved = 0;
|
||||||
rpl_opt_dodag_conf_buf->default_lifetime = mydodag->default_lifetime;
|
rpl_send_opt_dodag_conf_buf->default_lifetime = mydodag->default_lifetime;
|
||||||
rpl_opt_dodag_conf_buf->lifetime_unit = mydodag->lifetime_unit;
|
rpl_send_opt_dodag_conf_buf->lifetime_unit = mydodag->lifetime_unit;
|
||||||
|
|
||||||
|
|
||||||
opt_hdr_len += RPL_OPT_LEN + RPL_OPT_DODAG_CONF_LEN;
|
opt_hdr_len += RPL_OPT_LEN + RPL_OPT_DODAG_CONF_LEN;
|
||||||
|
|
||||||
|
|
||||||
uint16_t plen = ICMPV6_HDR_LEN + DIO_BASE_LEN + opt_hdr_len;
|
uint16_t plen = ICMPV6_HDR_LEN + DIO_BASE_LEN + opt_hdr_len;
|
||||||
rpl_send(destination,(uint8_t*)icmp_buf, plen, PROTO_NUM_ICMPV6, NULL);
|
rpl_send(destination,(uint8_t*)icmp_send_buf, plen, PROTO_NUM_ICMPV6, NULL);
|
||||||
|
mutex_unlock(&rpl_send_mutex, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void send_DIS(ipv6_addr_t *destination){
|
void send_DIS(ipv6_addr_t *destination){
|
||||||
|
|
||||||
icmp_buf = get_icmpv6_buf(ipv6_ext_hdr_len);
|
mutex_lock(&rpl_send_mutex);
|
||||||
|
icmp_send_buf = get_rpl_send_icmpv6_buf(ipv6_ext_hdr_len);
|
||||||
|
|
||||||
icmp_buf->type = ICMP_RPL_CONTROL;
|
icmp_send_buf->type = ICMP_RPL_CONTROL;
|
||||||
icmp_buf->code = ICMP_CODE_DIO;
|
icmp_send_buf->code = ICMP_CODE_DIO;
|
||||||
icmp_buf->checksum = ~icmpv6_csum(PROTO_NUM_ICMPV6);
|
icmp_send_buf->checksum = ~icmpv6_csum(PROTO_NUM_ICMPV6);
|
||||||
|
|
||||||
rpl_dis_buf = get_rpl_dis_buf();
|
rpl_dis_buf = get_rpl_dis_buf();
|
||||||
|
|
||||||
uint16_t plen = ICMPV6_HDR_LEN + DIS_BASE_LEN;
|
uint16_t plen = ICMPV6_HDR_LEN + DIS_BASE_LEN;
|
||||||
rpl_send(destination,(uint8_t*)icmp_buf, plen, PROTO_NUM_ICMPV6, NULL);
|
rpl_send(destination,(uint8_t*)icmp_send_buf, plen, PROTO_NUM_ICMPV6, NULL);
|
||||||
|
mutex_unlock(&rpl_send_mutex, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -223,6 +291,7 @@ void send_DAO(ipv6_addr_t *destination, uint8_t lifetime){
|
|||||||
if(i_am_root){
|
if(i_am_root){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
mutex_lock(&rpl_send_mutex);
|
||||||
rpl_dodag_t * my_dodag;
|
rpl_dodag_t * my_dodag;
|
||||||
my_dodag = rpl_get_my_dodag();
|
my_dodag = rpl_get_my_dodag();
|
||||||
|
|
||||||
@ -232,61 +301,63 @@ void send_DAO(ipv6_addr_t *destination, uint8_t lifetime){
|
|||||||
printf("Sending DAO to\n");
|
printf("Sending DAO to\n");
|
||||||
ipv6_print_addr(destination);
|
ipv6_print_addr(destination);
|
||||||
|
|
||||||
icmp_buf = get_icmpv6_buf(ipv6_ext_hdr_len);
|
icmp_send_buf = get_rpl_send_icmpv6_buf(ipv6_ext_hdr_len);
|
||||||
|
|
||||||
icmp_buf->type = ICMP_RPL_CONTROL;
|
icmp_send_buf->type = ICMP_RPL_CONTROL;
|
||||||
icmp_buf->code = ICMP_CODE_DAO;
|
icmp_send_buf->code = ICMP_CODE_DAO;
|
||||||
icmp_buf->checksum = ~icmpv6_csum(PROTO_NUM_ICMPV6);
|
icmp_send_buf->checksum = ~icmpv6_csum(PROTO_NUM_ICMPV6);
|
||||||
|
|
||||||
if(my_dodag == NULL){
|
if(my_dodag == NULL){
|
||||||
|
mutex_unlock(&rpl_send_mutex, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
rpl_dao_buf = get_rpl_dao_buf();
|
rpl_send_dao_buf = get_rpl_send_dao_buf();
|
||||||
memset(rpl_dao_buf,0,sizeof(*rpl_dao_buf));
|
memset(rpl_send_dao_buf,0,sizeof(*rpl_send_dao_buf));
|
||||||
rpl_dao_buf->rpl_instanceid = my_dodag->instance->id;
|
rpl_send_dao_buf->rpl_instanceid = my_dodag->instance->id;
|
||||||
rpl_dao_buf->k_d_flags = 0x00;
|
rpl_send_dao_buf->k_d_flags = 0x00;
|
||||||
rpl_dao_buf->dao_sequence = my_dodag->dao_seq;
|
rpl_send_dao_buf->dao_sequence = my_dodag->dao_seq;
|
||||||
uint16_t opt_len = 0;
|
uint16_t opt_len = 0;
|
||||||
rpl_opt_target_buf = get_rpl_opt_target_buf(DAO_BASE_LEN);
|
rpl_send_opt_target_buf = get_rpl_send_opt_target_buf(DAO_BASE_LEN);
|
||||||
//Alle Ziele aus der Routing Tabelle als Target eintragen
|
//Alle Ziele aus der Routing Tabelle als Target eintragen
|
||||||
for(uint8_t i=0; i<RPL_MAX_ROUTING_ENTRIES;i++){
|
for(uint8_t i=0; i<RPL_MAX_ROUTING_ENTRIES;i++){
|
||||||
if(routing_table[i].used){
|
if(routing_table[i].used){
|
||||||
rpl_opt_target_buf->type=RPL_OPT_TARGET;
|
rpl_send_opt_target_buf->type=RPL_OPT_TARGET;
|
||||||
rpl_opt_target_buf->length=RPL_OPT_TARGET_LEN;
|
rpl_send_opt_target_buf->length=RPL_OPT_TARGET_LEN;
|
||||||
rpl_opt_target_buf->flags=0x00;
|
rpl_send_opt_target_buf->flags=0x00;
|
||||||
rpl_opt_target_buf->prefix_length= RPL_DODAG_ID_LEN;
|
rpl_send_opt_target_buf->prefix_length= RPL_DODAG_ID_LEN;
|
||||||
memcpy(&rpl_opt_target_buf->target,&routing_table[i].address,sizeof(ipv6_addr_t));
|
memcpy(&rpl_send_opt_target_buf->target,&routing_table[i].address,sizeof(ipv6_addr_t));
|
||||||
opt_len += RPL_OPT_TARGET_LEN +2;
|
opt_len += RPL_OPT_TARGET_LEN +2;
|
||||||
rpl_opt_transit_buf = get_rpl_opt_transit_buf(DAO_BASE_LEN + opt_len);
|
rpl_send_opt_transit_buf = get_rpl_send_opt_transit_buf(DAO_BASE_LEN + opt_len);
|
||||||
rpl_opt_transit_buf->type=RPL_OPT_TRANSIT;
|
rpl_send_opt_transit_buf->type=RPL_OPT_TRANSIT;
|
||||||
rpl_opt_transit_buf->length=RPL_OPT_TRANSIT_LEN;
|
rpl_send_opt_transit_buf->length=RPL_OPT_TRANSIT_LEN;
|
||||||
rpl_opt_transit_buf->e_flags=0x00;
|
rpl_send_opt_transit_buf->e_flags=0x00;
|
||||||
rpl_opt_transit_buf->path_control=0x00;//not used
|
rpl_send_opt_transit_buf->path_control=0x00;//not used
|
||||||
rpl_opt_transit_buf->path_sequence=0x00;//not used
|
rpl_send_opt_transit_buf->path_sequence=0x00;//not used
|
||||||
rpl_opt_transit_buf->path_lifetime=lifetime;
|
rpl_send_opt_transit_buf->path_lifetime=lifetime;
|
||||||
opt_len += RPL_OPT_TRANSIT_LEN +2;
|
opt_len += RPL_OPT_TRANSIT_LEN +2;
|
||||||
rpl_opt_target_buf = get_rpl_opt_target_buf(DAO_BASE_LEN + opt_len);
|
rpl_send_opt_target_buf = get_rpl_send_opt_target_buf(DAO_BASE_LEN + opt_len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Add own address
|
//Add own address
|
||||||
rpl_opt_target_buf->type=RPL_OPT_TARGET;
|
rpl_send_opt_target_buf->type=RPL_OPT_TARGET;
|
||||||
rpl_opt_target_buf->length=RPL_OPT_TARGET_LEN;
|
rpl_send_opt_target_buf->length=RPL_OPT_TARGET_LEN;
|
||||||
rpl_opt_target_buf->flags=0x00;
|
rpl_send_opt_target_buf->flags=0x00;
|
||||||
rpl_opt_target_buf->prefix_length= RPL_DODAG_ID_LEN;
|
rpl_send_opt_target_buf->prefix_length= RPL_DODAG_ID_LEN;
|
||||||
memcpy(&rpl_opt_target_buf->target,&my_address,sizeof(ipv6_addr_t));
|
memcpy(&rpl_send_opt_target_buf->target,&my_address,sizeof(ipv6_addr_t));
|
||||||
opt_len += RPL_OPT_TARGET_LEN +2;
|
opt_len += RPL_OPT_TARGET_LEN +2;
|
||||||
|
|
||||||
rpl_opt_transit_buf = get_rpl_opt_transit_buf(DAO_BASE_LEN + opt_len);
|
rpl_send_opt_transit_buf = get_rpl_send_opt_transit_buf(DAO_BASE_LEN + opt_len);
|
||||||
rpl_opt_transit_buf->type=RPL_OPT_TRANSIT;
|
rpl_send_opt_transit_buf->type=RPL_OPT_TRANSIT;
|
||||||
rpl_opt_transit_buf->length=RPL_OPT_TRANSIT_LEN;
|
rpl_send_opt_transit_buf->length=RPL_OPT_TRANSIT_LEN;
|
||||||
rpl_opt_transit_buf->e_flags=0x00;
|
rpl_send_opt_transit_buf->e_flags=0x00;
|
||||||
rpl_opt_transit_buf->path_control=0x00;
|
rpl_send_opt_transit_buf->path_control=0x00;
|
||||||
rpl_opt_transit_buf->path_sequence=0x00;
|
rpl_send_opt_transit_buf->path_sequence=0x00;
|
||||||
rpl_opt_transit_buf->path_lifetime=lifetime;
|
rpl_send_opt_transit_buf->path_lifetime=lifetime;
|
||||||
opt_len += RPL_OPT_TRANSIT_LEN +2;
|
opt_len += RPL_OPT_TRANSIT_LEN +2;
|
||||||
|
|
||||||
uint16_t plen = ICMPV6_HDR_LEN + DAO_BASE_LEN + opt_len;
|
uint16_t plen = ICMPV6_HDR_LEN + DAO_BASE_LEN + opt_len;
|
||||||
rpl_send(destination,(uint8_t*)icmp_buf, plen, PROTO_NUM_ICMPV6, NULL);
|
rpl_send(destination,(uint8_t*)icmp_send_buf, plen, PROTO_NUM_ICMPV6, NULL);
|
||||||
|
mutex_unlock(&rpl_send_mutex, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void rpl_process(void){
|
void rpl_process(void){
|
||||||
@ -296,26 +367,46 @@ void rpl_process(void){
|
|||||||
|
|
||||||
while(1){
|
while(1){
|
||||||
msg_receive(&m_recv);
|
msg_receive(&m_recv);
|
||||||
|
puts("Got a RPL Package");
|
||||||
uint8_t *code;
|
uint8_t *code;
|
||||||
code = ((uint8_t*)m_recv.content.ptr);
|
code = ((uint8_t*)m_recv.content.ptr);
|
||||||
//pakettypen unterscheiden
|
//pakettypen unterscheiden
|
||||||
|
ipv6_buf = get_ipv6_buf();
|
||||||
|
//mutex_lock(&rpl_recv_mutex);
|
||||||
|
//mutex_lock(&rpl_send_mutex);
|
||||||
|
memcpy(&rpl_buffer,ipv6_buf,ipv6_buf->length+IPV6_HDR_LEN);
|
||||||
switch(*code) {
|
switch(*code) {
|
||||||
case(ICMP_CODE_DIS):{
|
case(ICMP_CODE_DIS):{
|
||||||
recv_rpl_dis();
|
recv_rpl_dis();
|
||||||
|
puts("unlock after dis recv");
|
||||||
|
mutex_unlock(&rpl_recv_mutex, 0);
|
||||||
|
//mutex_unlock(&rpl_send_mutex, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case(ICMP_CODE_DIO):{
|
case(ICMP_CODE_DIO):{
|
||||||
recv_rpl_dio();
|
recv_rpl_dio();
|
||||||
|
puts("unlock after dio recv");
|
||||||
|
mutex_unlock(&rpl_recv_mutex, 0);
|
||||||
|
//mutex_unlock(&rpl_send_mutex, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case(ICMP_CODE_DAO):{
|
case(ICMP_CODE_DAO):{
|
||||||
recv_rpl_dao();
|
recv_rpl_dao();
|
||||||
|
puts("unlock after dao recv");
|
||||||
|
mutex_unlock(&rpl_recv_mutex, 0);
|
||||||
|
//mutex_unlock(&rpl_send_mutex, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case(ICMP_CODE_DAO_ACK):{
|
case(ICMP_CODE_DAO_ACK):{
|
||||||
|
puts("unlock after dao_ack recv");
|
||||||
|
mutex_unlock(&rpl_recv_mutex, 0);
|
||||||
|
//mutex_unlock(&rpl_send_mutex, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
mutex_unlock(&rpl_recv_mutex, 0);
|
||||||
|
//mutex_unlock(&rpl_send_mutex, 0);
|
||||||
|
puts("default unlock");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -323,13 +414,14 @@ void rpl_process(void){
|
|||||||
|
|
||||||
|
|
||||||
void recv_rpl_dio(void){
|
void recv_rpl_dio(void){
|
||||||
ipv6_buf = get_ipv6_buf();
|
ipv6_buf = get_rpl_ipv6_buf();
|
||||||
|
|
||||||
rpl_dio_buf = get_rpl_dio_buf();
|
rpl_dio_buf = get_rpl_dio_buf();
|
||||||
int len = DIO_BASE_LEN;
|
int len = DIO_BASE_LEN;
|
||||||
|
|
||||||
rpl_instance_t * dio_inst = rpl_get_instance(rpl_dio_buf->rpl_instanceid);
|
rpl_instance_t * dio_inst = rpl_get_instance(rpl_dio_buf->rpl_instanceid);
|
||||||
rpl_instance_t * my_inst = rpl_get_my_instance();
|
rpl_instance_t * my_inst = rpl_get_my_instance();
|
||||||
|
|
||||||
if(dio_inst == NULL){
|
if(dio_inst == NULL){
|
||||||
if(my_inst != NULL){
|
if(my_inst != NULL){
|
||||||
//Dieser Knoten ist schon Teil eines DODAGS -> kein beitritt zu anderer Instanz moeglich
|
//Dieser Knoten ist schon Teil eines DODAGS -> kein beitritt zu anderer Instanz moeglich
|
||||||
@ -362,7 +454,12 @@ void recv_rpl_dio(void){
|
|||||||
uint8_t has_dodag_conf_opt = 0;
|
uint8_t has_dodag_conf_opt = 0;
|
||||||
//So lange das Paket größer ist, als die DIO Größe + Größe der bisher verarbeiteten Optionen,
|
//So lange das Paket größer ist, als die DIO Größe + Größe der bisher verarbeiteten Optionen,
|
||||||
//sind noch weitere Optionen zu bearbeiten
|
//sind noch weitere Optionen zu bearbeiten
|
||||||
|
|
||||||
//dabei müssen wir jedoch von der ipv6_buf->length die Größe des ICMP Headers abziehen
|
//dabei müssen wir jedoch von der ipv6_buf->length die Größe des ICMP Headers abziehen
|
||||||
|
//weil get_rpl_opt_buf die Paketlänge OHNE ipv6 und icmpv6 header übergeben werden muss
|
||||||
|
//in ipv6_buf->length ist die IPV6_HDR_LEN nicht enthalten, also muss nur noch die ICMPV6_HDR_LEN
|
||||||
|
//abgezogen werden
|
||||||
|
|
||||||
while(len < (ipv6_buf->length - ICMPV6_HDR_LEN) ){
|
while(len < (ipv6_buf->length - ICMPV6_HDR_LEN) ){
|
||||||
rpl_opt_buf = get_rpl_opt_buf(len);
|
rpl_opt_buf = get_rpl_opt_buf(len);
|
||||||
switch(rpl_opt_buf->type){
|
switch(rpl_opt_buf->type){
|
||||||
@ -419,6 +516,7 @@ void recv_rpl_dio(void){
|
|||||||
rpl_dodag_t *my_dodag = rpl_get_my_dodag();
|
rpl_dodag_t *my_dodag = rpl_get_my_dodag();
|
||||||
if(my_dodag == NULL){
|
if(my_dodag == NULL){
|
||||||
if(!has_dodag_conf_opt){
|
if(!has_dodag_conf_opt){
|
||||||
|
puts("send DIS");
|
||||||
send_DIS(&ipv6_buf->srcaddr);
|
send_DIS(&ipv6_buf->srcaddr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -514,7 +612,7 @@ void recv_rpl_dis(void){
|
|||||||
if(my_dodag == NULL){
|
if(my_dodag == NULL){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ipv6_buf = get_ipv6_buf();
|
ipv6_buf = get_rpl_ipv6_buf();
|
||||||
rpl_dis_buf = get_rpl_dis_buf();
|
rpl_dis_buf = get_rpl_dis_buf();
|
||||||
int len = DIS_BASE_LEN;
|
int len = DIS_BASE_LEN;
|
||||||
while(len < (ipv6_buf->length - ICMPV6_HDR_LEN) ){
|
while(len < (ipv6_buf->length - ICMPV6_HDR_LEN) ){
|
||||||
@ -568,7 +666,7 @@ void recv_rpl_dao(void){
|
|||||||
printf("[Error] got DAO without beeing part of a Dodag\n");
|
printf("[Error] got DAO without beeing part of a Dodag\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ipv6_buf = get_ipv6_buf();
|
ipv6_buf = get_rpl_ipv6_buf();
|
||||||
rpl_dao_buf = get_rpl_dao_buf();
|
rpl_dao_buf = get_rpl_dao_buf();
|
||||||
int len = DAO_BASE_LEN;
|
int len = DAO_BASE_LEN;
|
||||||
uint8_t increment_seq = 0;
|
uint8_t increment_seq = 0;
|
||||||
@ -594,16 +692,17 @@ void recv_rpl_dao(void){
|
|||||||
printf("prefixes are not supported yet");
|
printf("prefixes are not supported yet");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
increment_seq = 1;
|
len += rpl_opt_target_buf->length +2;
|
||||||
len += rpl_opt_buf->length +2;
|
|
||||||
rpl_opt_transit_buf = get_rpl_opt_transit_buf(len);
|
rpl_opt_transit_buf = get_rpl_opt_transit_buf(len);
|
||||||
if(rpl_opt_transit_buf->type != RPL_OPT_TRANSIT){
|
if(rpl_opt_transit_buf->type != RPL_OPT_TRANSIT){
|
||||||
printf("[Error] - no Transit Inforamtion to Target Option\n");
|
printf("[Error] - no Transit Inforamtion to Target Option, type = %d\n", rpl_opt_transit_buf->type);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
len += rpl_opt_transit_buf->length +2;
|
len += rpl_opt_transit_buf->length +2;
|
||||||
//Die eigentliche Lebenszeit einer Route errechnet sich aus (Lifetime aus DAO) * (Lifetime Unit) Sekunden
|
//Die eigentliche Lebenszeit einer Route errechnet sich aus (Lifetime aus DAO) * (Lifetime Unit) Sekunden
|
||||||
rpl_add_routing_entry(&rpl_opt_target_buf->target, &ipv6_buf->srcaddr, rpl_opt_transit_buf->path_lifetime * my_dodag->lifetime_unit);
|
rpl_add_routing_entry(&rpl_opt_target_buf->target, &ipv6_buf->srcaddr, rpl_opt_transit_buf->path_lifetime * my_dodag->lifetime_unit);
|
||||||
|
printf("new route added\n");
|
||||||
|
increment_seq = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case(RPL_OPT_TRANSIT):{
|
case(RPL_OPT_TRANSIT):{
|
||||||
@ -626,46 +725,40 @@ void recv_rpl_dao(void){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void rpl_send(ipv6_addr_t *destination, uint8_t *payload, uint16_t p_len, uint8_t next_header, void *tcp_socket){
|
void rpl_send(ipv6_addr_t *destination, uint8_t *payload, uint16_t p_len, uint8_t next_header, void *tcp_socket){
|
||||||
printf("rpl_send gets called, packet length %d\n", p_len);
|
|
||||||
uint8_t *p_ptr;
|
uint8_t *p_ptr;
|
||||||
/*if (next_header == IPPROTO_TCP)
|
ipv6_send_buf = get_rpl_send_ipv6_buf();
|
||||||
{
|
p_ptr = get_rpl_send_payload_buf(ipv6_ext_hdr_len);
|
||||||
p_ptr = get_payload_buf_send(ipv6_ext_hdr_len);
|
|
||||||
ipv6_buf = get_ipv6_buf_send();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{*/
|
|
||||||
ipv6_buf = get_ipv6_buf();
|
|
||||||
p_ptr = get_payload_buf(ipv6_ext_hdr_len);
|
|
||||||
//}
|
|
||||||
icmp_buf = get_icmpv6_buf(ipv6_ext_hdr_len);
|
|
||||||
packet_length = 0;
|
packet_length = 0;
|
||||||
|
|
||||||
ipv6_buf->version_trafficclass = IPV6_VER;
|
ipv6_send_buf->version_trafficclass = IPV6_VER;
|
||||||
ipv6_buf->trafficclass_flowlabel = 0;
|
ipv6_send_buf->trafficclass_flowlabel = 0;
|
||||||
ipv6_buf->flowlabel = 0;
|
ipv6_send_buf->flowlabel = 0;
|
||||||
ipv6_buf->nextheader = next_header;
|
ipv6_send_buf->nextheader = next_header;
|
||||||
ipv6_buf->hoplimit = MULTIHOP_HOPLIMIT;
|
ipv6_send_buf->hoplimit = MULTIHOP_HOPLIMIT;
|
||||||
ipv6_buf->length = p_len;
|
ipv6_send_buf->length = p_len;
|
||||||
|
|
||||||
memcpy(&(ipv6_buf->destaddr), destination, 16);
|
memcpy(&(ipv6_send_buf->destaddr), destination, 16);
|
||||||
ipv6_get_saddr(&(ipv6_buf->srcaddr), &(ipv6_buf->destaddr));
|
ipv6_get_saddr(&(ipv6_send_buf->srcaddr), &(ipv6_send_buf->destaddr));
|
||||||
|
//memcpy(&(ipv6_send_buf->srcaddr), &my_address, 16);
|
||||||
|
ipv6_print_addr(&ipv6_send_buf->srcaddr);
|
||||||
|
|
||||||
memcpy(p_ptr,payload,p_len);
|
//Wenn das Paket in der rpl.c "zusammegebaut" wurde, wurde dafür ohnehin der rpl_send_buf verwendet.
|
||||||
|
//In diesem Fall muss also keine memcopy Aktion durchgeführt werden, da sich der payload bereits
|
||||||
|
//im richtigen Speicherbereich befindet.
|
||||||
|
if(p_ptr != payload){
|
||||||
|
memcpy(p_ptr,payload,p_len);
|
||||||
|
}
|
||||||
|
|
||||||
packet_length = IPV6_HDR_LEN + p_len;
|
packet_length = IPV6_HDR_LEN + p_len;
|
||||||
|
|
||||||
#ifdef MODULE_DESTINY
|
if(ipv6_prefix_mcast_match(&ipv6_send_buf->destaddr)){
|
||||||
if (next_header == IPPROTO_TCP) {
|
lowpan_init((ieee_802154_long_t*)&(ipv6_send_buf->destaddr.uint16[4]),(uint8_t*)ipv6_send_buf);
|
||||||
print_tcp_status(OUT_PACKET, ipv6_buf, (tcp_hdr_t *)(payload), (socket_t *)tcp_socket);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if(ipv6_prefix_mcast_match(&ipv6_buf->destaddr)){
|
|
||||||
lowpan_init((ieee_802154_long_t*)&(ipv6_buf->destaddr.uint16[4]),(uint8_t*)ipv6_buf);
|
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
puts("sending packet to");
|
||||||
|
ipv6_print_addr(&ipv6_send_buf->destaddr);
|
||||||
//find right next hop before sending
|
//find right next hop before sending
|
||||||
ipv6_addr_t *next_hop = rpl_get_next_hop(&ipv6_buf->destaddr);
|
ipv6_addr_t *next_hop = rpl_get_next_hop(&ipv6_send_buf->destaddr);
|
||||||
if(next_hop == NULL){
|
if(next_hop == NULL){
|
||||||
if(i_am_root){
|
if(i_am_root){
|
||||||
//oops... ich bin root und weiß nicht wohin mit dem paketn
|
//oops... ich bin root und weiß nicht wohin mit dem paketn
|
||||||
@ -681,7 +774,7 @@ void rpl_send(ipv6_addr_t *destination, uint8_t *payload, uint16_t p_len, uint8_
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lowpan_init((ieee_802154_long_t*)&(next_hop->uint16[4]),(uint8_t*)ipv6_buf);
|
lowpan_init((ieee_802154_long_t*)&(next_hop->uint16[4]),(uint8_t*)ipv6_send_buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -69,7 +69,7 @@
|
|||||||
#define DEFAULT_DIO_REDUNDANCY_CONSTANT 10
|
#define DEFAULT_DIO_REDUNDANCY_CONSTANT 10
|
||||||
#define DEFAULT_MIN_HOP_RANK_INCREASE 256
|
#define DEFAULT_MIN_HOP_RANK_INCREASE 256
|
||||||
//DAO_DELAY is in seconds
|
//DAO_DELAY is in seconds
|
||||||
#define DEFAULT_DAO_DELAY 1
|
#define DEFAULT_DAO_DELAY 3
|
||||||
#define RPL_DODAG_ID_LEN 16
|
#define RPL_DODAG_ID_LEN 16
|
||||||
|
|
||||||
//others
|
//others
|
||||||
|
|||||||
@ -75,10 +75,8 @@ void start_trickle(uint8_t DIOIntMin, uint8_t DIOIntDoubl, uint8_t DIORedundancy
|
|||||||
//Eigentlich laut Spezifikation erste Bestimmung von I wie auskommentiert:
|
//Eigentlich laut Spezifikation erste Bestimmung von I wie auskommentiert:
|
||||||
//I = Imin + ( rand() % ( (Imin << Imax) - Imin + 1 ) );
|
//I = Imin + ( rand() % ( (Imin << Imax) - Imin + 1 ) );
|
||||||
I = Imin + ( rand() % ( (4*Imin) - Imin + 1 ) );
|
I = Imin + ( rand() % ( (4*Imin) - Imin + 1 ) );
|
||||||
printf("STARTING TRICKLE WITH I = %u\n", I);
|
|
||||||
|
|
||||||
t = (I/2) + ( rand() % ( I - (I/2) + 1 ) );
|
t = (I/2) + ( rand() % ( I - (I/2) + 1 ) );
|
||||||
printf("STARTING TRICKLE WITH t = %u\n", t);
|
|
||||||
t_time = timex_set(0,t*1000);
|
t_time = timex_set(0,t*1000);
|
||||||
timex_normalize(&t_time);
|
timex_normalize(&t_time);
|
||||||
I_time = timex_set(0,I*1000);
|
I_time = timex_set(0,I*1000);
|
||||||
@ -101,12 +99,10 @@ void trickle_timer_over(void)
|
|||||||
ipv6_set_all_nds_mcast_addr(&mcast);
|
ipv6_set_all_nds_mcast_addr(&mcast);
|
||||||
while(1){
|
while(1){
|
||||||
thread_sleep();
|
thread_sleep();
|
||||||
puts("TRICKLE TIMER OVER");
|
|
||||||
//Laut RPL Spezifikation soll k=0 wie k= Unendlich behandelt werden, also immer gesendet werden
|
//Laut RPL Spezifikation soll k=0 wie k= Unendlich behandelt werden, also immer gesendet werden
|
||||||
if( (c < k) || (k == 0)){
|
if( (c < k) || (k == 0)){
|
||||||
send_DIO(&mcast);
|
send_DIO(&mcast);
|
||||||
}
|
}
|
||||||
puts("TRICKLE TIMER OVER 2");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,7 +116,6 @@ void trickle_interval_over(void){
|
|||||||
}
|
}
|
||||||
c=0;
|
c=0;
|
||||||
t = (I/2) + ( rand() % ( I - (I/2) + 1 ) );
|
t = (I/2) + ( rand() % ( I - (I/2) + 1 ) );
|
||||||
printf("TRICKLE new TIMER %u\n",t);
|
|
||||||
//start timer
|
//start timer
|
||||||
t_time = timex_set(0,t*1000);
|
t_time = timex_set(0,t*1000);
|
||||||
timex_normalize(&t_time);
|
timex_normalize(&t_time);
|
||||||
|
|||||||
@ -20,7 +20,7 @@ char radio_stack_buffer[RADIO_STACK_SIZE];
|
|||||||
msg_t msg_q[RADIO_RCV_BUF_SIZE];
|
msg_t msg_q[RADIO_RCV_BUF_SIZE];
|
||||||
uint8_t snd_buffer[RADIO_SND_BUF_SIZE][PAYLOAD_SIZE];
|
uint8_t snd_buffer[RADIO_SND_BUF_SIZE][PAYLOAD_SIZE];
|
||||||
|
|
||||||
uint8_t r_src_addr;
|
static uint8_t r_src_addr;
|
||||||
uint8_t buf[PAYLOAD_SIZE];
|
uint8_t buf[PAYLOAD_SIZE];
|
||||||
uint16_t packet_length;
|
uint16_t packet_length;
|
||||||
static uint8_t macdsn;
|
static uint8_t macdsn;
|
||||||
@ -150,7 +150,6 @@ void set_ieee802154_frame_values(ieee802154_frame_t *frame){
|
|||||||
|
|
||||||
void send_ieee802154_frame(ieee_802154_long_t *addr, uint8_t *payload,
|
void send_ieee802154_frame(ieee_802154_long_t *addr, uint8_t *payload,
|
||||||
uint8_t length, uint8_t mcast){
|
uint8_t length, uint8_t mcast){
|
||||||
puts("send_ieee802154_frame gets called");
|
|
||||||
uint16_t daddr;
|
uint16_t daddr;
|
||||||
r_src_addr = local_address;
|
r_src_addr = local_address;
|
||||||
mesg.type = SND_PKT;
|
mesg.type = SND_PKT;
|
||||||
|
|||||||
@ -78,7 +78,7 @@ void lowpan_init(ieee_802154_long_t *addr, uint8_t *data){
|
|||||||
mcast = 1;
|
mcast = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
lowpan_iphc_encoding(&laddr, ipv6_buf);
|
lowpan_iphc_encoding(&laddr, ipv6_buf, data);
|
||||||
data = &comp_buf[0];
|
data = &comp_buf[0];
|
||||||
packet_length = comp_len;
|
packet_length = comp_len;
|
||||||
|
|
||||||
@ -667,7 +667,7 @@ void lowpan_ipv6_set_dispatch(uint8_t *data){
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* draft-ietf-6lowpan-hc-13#section-3.1 */
|
/* draft-ietf-6lowpan-hc-13#section-3.1 */
|
||||||
void lowpan_iphc_encoding(ieee_802154_long_t *dest, ipv6_hdr_t *ipv6_buf_extra){
|
void lowpan_iphc_encoding(ieee_802154_long_t *dest, ipv6_hdr_t *ipv6_buf_extra, uint8_t * ptr){
|
||||||
ipv6_buf = ipv6_buf_extra;
|
ipv6_buf = ipv6_buf_extra;
|
||||||
|
|
||||||
uint16_t payload_length = ipv6_buf->length;
|
uint16_t payload_length = ipv6_buf->length;
|
||||||
@ -929,7 +929,7 @@ void lowpan_iphc_encoding(ieee_802154_long_t *dest, ipv6_hdr_t *ipv6_buf_extra){
|
|||||||
comp_buf[0] = lowpan_iphc[0];
|
comp_buf[0] = lowpan_iphc[0];
|
||||||
comp_buf[1] = lowpan_iphc[1];
|
comp_buf[1] = lowpan_iphc[1];
|
||||||
|
|
||||||
uint8_t *ptr;
|
/*uint8_t *ptr;
|
||||||
if (ipv6_buf->nextheader == IPPROTO_TCP)
|
if (ipv6_buf->nextheader == IPPROTO_TCP)
|
||||||
{
|
{
|
||||||
ptr = get_payload_buf_send(ipv6_ext_hdr_len);
|
ptr = get_payload_buf_send(ipv6_ext_hdr_len);
|
||||||
@ -938,8 +938,8 @@ void lowpan_iphc_encoding(ieee_802154_long_t *dest, ipv6_hdr_t *ipv6_buf_extra){
|
|||||||
{
|
{
|
||||||
ptr = get_payload_buf(ipv6_ext_hdr_len);
|
ptr = get_payload_buf(ipv6_ext_hdr_len);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
memcpy(&ipv6_hdr_fields[hdr_pos],ptr,ipv6_buf->length);
|
memcpy(&ipv6_hdr_fields[hdr_pos],&ptr[IPV6_HDR_LEN],ipv6_buf->length);
|
||||||
|
|
||||||
comp_len = 2 + hdr_pos + payload_length;
|
comp_len = 2 + hdr_pos + payload_length;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -68,7 +68,7 @@ void sixlowpan_adhoc_init(transceiver_type_t trans, ipv6_addr_t *prefix, uint8_t
|
|||||||
void lowpan_init(ieee_802154_long_t *addr, uint8_t *data);
|
void lowpan_init(ieee_802154_long_t *addr, uint8_t *data);
|
||||||
void lowpan_read(uint8_t *data, uint8_t length, ieee_802154_long_t *s_laddr,
|
void lowpan_read(uint8_t *data, uint8_t length, ieee_802154_long_t *s_laddr,
|
||||||
ieee_802154_long_t *d_laddr);
|
ieee_802154_long_t *d_laddr);
|
||||||
void lowpan_iphc_encoding(ieee_802154_long_t *dest, ipv6_hdr_t *ipv6_buf_extra);
|
void lowpan_iphc_encoding(ieee_802154_long_t *dest, ipv6_hdr_t *ipv6_buf_extra, uint8_t * ptr);
|
||||||
void lowpan_iphc_decoding(uint8_t *data, uint8_t length,
|
void lowpan_iphc_decoding(uint8_t *data, uint8_t length,
|
||||||
ieee_802154_long_t *s_laddr,
|
ieee_802154_long_t *s_laddr,
|
||||||
ieee_802154_long_t *d_laddr);
|
ieee_802154_long_t *d_laddr);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user