Only allow abreviated SID's in route announcements

This commit is contained in:
Jeremy Lakeman 2012-10-10 15:23:19 +10:30
parent 4b2b8f1783
commit 4658251ebe
3 changed files with 9 additions and 5 deletions

View File

@ -522,7 +522,7 @@ int overlay_address_parse(struct decode_context *context, struct overlay_buffer
}
// we must assume that we wont be able to understand the rest of the packet
if (code<=0x0f)
if (code<=0x0f || context->abbreviations_only)
return WHYF("Unsupported abbreviation code %d", code);
return find_subscr_buffer(context, b, -1, SID_SIZE,1,subscriber);

View File

@ -108,6 +108,7 @@ struct broadcast{
};
struct decode_context{
int abbreviations_only;
int invalid_addresses;
struct overlay_frame *please_explain;
};

View File

@ -65,7 +65,8 @@ int add_advertisement(struct subscriber *subscriber, void *context){
if (subscriber->node){
overlay_node *n=subscriber->node;
// never send the full sid in an advertisement
subscriber->send_full=0;
if (overlay_address_append(e,subscriber) ||
ob_append_byte(e,n->best_link_score) ||
ob_append_byte(e,n->observations[n->best_observation].gateways_en_route)){
@ -181,7 +182,9 @@ int overlay_route_add_advertisements(overlay_interface *interface, struct overla
int overlay_route_saw_advertisements(int i, struct overlay_frame *f, struct decode_context *context, time_ms_t now)
{
IN();
while(f->payload->position < f->payload->sizeLimit)
context->abbreviations_only=1;
// minimum record length is (address code, 3 byte sid, score, gateways)
while(f->payload->position +6 <= f->payload->sizeLimit)
{
struct subscriber *subscriber;
context->invalid_addresses=0;
@ -216,6 +219,6 @@ int overlay_route_saw_advertisements(int i, struct overlay_frame *f, struct deco
score,gateways_en_route);
}
RETURN(0);;
context->abbreviations_only=0;
RETURN(0);
}