mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-18 12:52:44 +01:00
[*]
* removed prefix information from abr_cache for now to save space
This commit is contained in:
parent
1cc8cf4c5a
commit
9bf13c2d56
@ -13,7 +13,6 @@ uint16_t abro_version;
|
||||
uint16_t get_next_abro_version();
|
||||
void init_edge_router_info(ipv6_addr_t *abr_addr);
|
||||
uint8_t abr_info_add_context(lowpan_context_t *context);
|
||||
uint8_t abr_info_add_prefix(plist_t *prefix);
|
||||
|
||||
uint16_t get_next_abro_version() {
|
||||
abro_version = serial_add16(abro_version, 1);
|
||||
@ -92,42 +91,24 @@ uint8_t abr_info_add_context(lowpan_context_t *context) {
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
uint8_t abr_info_add_prefix(plist_t *prefix) {
|
||||
if (prefix == NULL) return SIXLOWERROR_NULLPTR;
|
||||
if (abr_info->prefixes_num == OPT_PI_LIST_LEN) {
|
||||
return SIXLOWERROR_ARRAYFULL;
|
||||
}
|
||||
|
||||
uint16_t abro_version = get_next_abro_version();
|
||||
|
||||
abr_info->prefixes[abr_info->prefixes_num++] = prefix;
|
||||
abr_info->version = abro_version;
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
void init_edge_router_info(ipv6_addr_t *abr_addr) {
|
||||
uint16_t abro_version = get_next_abro_version();
|
||||
ipv6_addr_t prefix;
|
||||
plist_t *prefix_info;
|
||||
lowpan_context_t *context;
|
||||
|
||||
if (abr_info == NULL)
|
||||
abr_info = abr_update_cache(abro_version,abr_addr,NULL,0,NULL,0);
|
||||
abr_info = abr_update_cache(abro_version,abr_addr,NULL,0);
|
||||
else
|
||||
abr_info = abr_update_cache(
|
||||
abro_version,
|
||||
abr_addr,
|
||||
abr_info->contexts,
|
||||
abr_info->contexts_num,
|
||||
abr_info->prefixes,
|
||||
abr_info->prefixes_num
|
||||
abr_info->contexts_num
|
||||
);
|
||||
|
||||
ipv6_iface_add_addr(abr_addr,ADDR_STATE_PREFERRED,0,0,ADDR_TYPE_UNICAST);
|
||||
ipv6_set_prefix(&prefix, abr_addr);
|
||||
prefix_info = plist_add(&prefix, 64, OPT_PI_VLIFETIME_INFINITE,0,1,OPT_PI_FLAG_A);
|
||||
abr_info_add_prefix(prefix_info);
|
||||
plist_add(&prefix, 64, OPT_PI_VLIFETIME_INFINITE,0,1,OPT_PI_FLAG_A);
|
||||
|
||||
context = edge_define_context(0, &prefix, 64, 5); // has to be reset some time later
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include "sixlownd.h"
|
||||
#include "sixlowmac.h"
|
||||
#include "sixlowpan.h"
|
||||
#include "sixlowerror.h"
|
||||
#include "serialnumber.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -347,40 +348,22 @@ void init_rtr_adv(ipv6_addr_t *addr, uint8_t sllao, uint8_t mtu, uint8_t pi,
|
||||
}
|
||||
|
||||
if(pi == OPT_PI){
|
||||
plist_t *prefixes = NULL;
|
||||
int plist_len = 0;
|
||||
|
||||
if (msg_abr == NULL) {
|
||||
prefixes = plist;
|
||||
plist_len = OPT_PI_LIST_LEN;
|
||||
} else {
|
||||
plist_len = msg_abr->prefixes_num;
|
||||
prefixes = (plist_t*)calloc(plist_len, sizeof(plist_t));
|
||||
for (int i = 0; i < plist_len; i++) {
|
||||
prefixes[i] = *(msg_abr->prefixes[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/* set prefix option */
|
||||
for(int i=0;i<plist_len; i++){
|
||||
if(prefixes[i].inuse && prefixes[i].adv){
|
||||
for(int i=0;i<OPT_PI_LIST_LEN; i++){
|
||||
if(plist[i].inuse && plist[i].adv){
|
||||
opt_pi_buf = get_opt_pi_buf(ipv6_ext_hdr_len, opt_hdr_len);
|
||||
memcpy(&(opt_pi_buf->addr.uint8[0]), &(prefixes[i].addr.uint8[0]), 16);
|
||||
memcpy(&(opt_pi_buf->addr.uint8[0]), &(plist[i].addr.uint8[0]), 16);
|
||||
opt_pi_buf->type = OPT_PI_TYPE;
|
||||
opt_pi_buf->length = OPT_PI_LEN;
|
||||
opt_pi_buf->prefix_length = prefixes[i].length;
|
||||
opt_pi_buf->l_a_reserved1 = prefixes[i].l_a_reserved1;
|
||||
opt_pi_buf->val_ltime = HTONL(prefixes[i].val_ltime);
|
||||
opt_pi_buf->pref_ltime = HTONL(prefixes[i].pref_ltime);
|
||||
opt_pi_buf->prefix_length = plist[i].length;
|
||||
opt_pi_buf->l_a_reserved1 = plist[i].l_a_reserved1;
|
||||
opt_pi_buf->val_ltime = HTONL(plist[i].val_ltime);
|
||||
opt_pi_buf->pref_ltime = HTONL(plist[i].pref_ltime);
|
||||
opt_pi_buf->reserved2 = 0;
|
||||
packet_length += OPT_PI_HDR_LEN;
|
||||
opt_hdr_len += OPT_PI_HDR_LEN;
|
||||
}
|
||||
}
|
||||
|
||||
if (msg_abr != NULL && prefixes != NULL) {
|
||||
free(prefixes);
|
||||
}
|
||||
}
|
||||
|
||||
ipv6_buf->length = packet_length - IPV6_HDR_LEN;
|
||||
@ -538,7 +521,7 @@ void recv_rtr_adv(void){
|
||||
}
|
||||
|
||||
if (abro_found) {
|
||||
abr_update_cache(abro_version,&abro_addr,recvd_contexts,recvd_con_len,recvd_prefixes,recvd_pref_len);
|
||||
abr_update_cache(abro_version,&abro_addr,recvd_contexts,recvd_con_len);
|
||||
}
|
||||
mutex_unlock(&lowpan_context_mutex,0);
|
||||
|
||||
@ -1090,8 +1073,7 @@ static abr_cache_t *abr_get_oldest(){
|
||||
|
||||
abr_cache_t *abr_update_cache(
|
||||
uint16_t version, ipv6_addr_t *abr_addr,
|
||||
lowpan_context_t **contexts, uint8_t contexts_num,
|
||||
plist_t **prefixes, uint8_t prefixes_num){
|
||||
uint8_t *contexts, uint8_t contexts_num){
|
||||
abr_cache_t *abr = NULL;
|
||||
if (abr_count == ABR_CACHE_SIZE) {
|
||||
abr = abr_get_oldest();
|
||||
@ -1102,8 +1084,6 @@ abr_cache_t *abr_update_cache(
|
||||
memcpy(&abr->abr_addr, abr_addr, sizeof (ipv6_addr_t));
|
||||
memcpy(abr->contexts, contexts, contexts_num * sizeof (uint8_t));
|
||||
abr->contexts_num = contexts_num;
|
||||
memcpy(abr->prefixes, prefixes, prefixes_num * sizeof (lowpan_context_t*));
|
||||
abr->prefixes_num = prefixes_num;
|
||||
|
||||
return abr;
|
||||
}
|
||||
@ -1170,11 +1150,10 @@ void def_rtr_lst_rem(def_rtr_lst_t *entry){
|
||||
//------------------------------------------------------------------------------
|
||||
// prefix list functions
|
||||
|
||||
plist_t *plist_add(ipv6_addr_t *addr, uint8_t size, uint32_t val_ltime,
|
||||
int8_t plist_add(ipv6_addr_t *addr, uint8_t size, uint32_t val_ltime,
|
||||
uint32_t pref_ltime, uint8_t adv_opt, uint8_t l_a_reserved1){
|
||||
if(prefix_count == OPT_PI_LIST_LEN){
|
||||
printf("ERROR: prefix list full\n");
|
||||
return NULL;
|
||||
return SIXLOWERROR_ARRAYFULL;
|
||||
} else {
|
||||
plist[prefix_count].inuse = 1;
|
||||
plist[prefix_count].length = size;
|
||||
@ -1184,6 +1163,6 @@ plist_t *plist_add(ipv6_addr_t *addr, uint8_t size, uint32_t val_ltime,
|
||||
plist[prefix_count].pref_ltime = HTONL(pref_ltime);
|
||||
memcpy(&(plist[prefix_count].addr.uint8[0]), &(addr->uint8[0]), 16);
|
||||
|
||||
return &(plist[prefix_count++]);
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
||||
|
@ -190,8 +190,6 @@ typedef struct __attribute__((packed)) abr_cache_t {
|
||||
ipv6_addr_t abr_addr;
|
||||
uint8_t contexts[LOWPAN_CONTEXT_MAX];
|
||||
uint8_t contexts_num;
|
||||
plist_t *prefixes[OPT_PI_LIST_LEN];
|
||||
uint8_t prefixes_num;
|
||||
} abr_cache_t;
|
||||
|
||||
/* neighbor cache - rfc4861 5.1. */
|
||||
@ -218,7 +216,7 @@ void init_rtr_adv(ipv6_addr_t *addr, uint8_t sllao, uint8_t mtu, uint8_t pi,
|
||||
uint8_t sixco, uint8_t abro);
|
||||
uint8_t plist_search(ipv6_addr_t *addr);
|
||||
uint8_t plist_cmp(ipv6_addr_t *addr1, ipv6_addr_t *addr2);
|
||||
plist_t *plist_add(ipv6_addr_t *addr, uint8_t size, uint32_t val_ltime,
|
||||
int8_t plist_add(ipv6_addr_t *addr, uint8_t size, uint32_t val_ltime,
|
||||
uint32_t pref_ltime, uint8_t adv_opt, uint8_t l_a_reserved1);
|
||||
void set_llao(opt_stllao_t *sllao, uint8_t type, uint8_t length);
|
||||
abr_cache_t *abr_update_cache(
|
||||
|
Loading…
Reference in New Issue
Block a user