From: Mark Wooding Date: Sun, 30 Apr 2017 23:18:39 +0000 (+0100) Subject: site.c, magic.h, NOTES: Make early capabilities be dynamic. X-Git-Tag: v0.5.0~157 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=secnet.git;a=commitdiff_plain;h=5d903efd43518e7a4f12f7315b7cd133ac1563f1 site.c, magic.h, NOTES: Make early capabilities be dynamic. Replace the `CAPAB_EARLY' macro by a site member variable `st->early_capabilities'. The variable is always zero for now, like the old macro, so there's no functional change. Signed-off-by: Mark Wooding --- diff --git a/NOTES b/NOTES index e6957df..884ae30 100644 --- a/NOTES +++ b/NOTES @@ -229,8 +229,9 @@ of parameters for the same transform. Bit 31, if advertised by both ends, indicates that a mobile end gets priority in case of crossed MSG1. The remaining bits have not yet been assigned a purpose. -The mobile-end-gets-priority bit (31) is an `early' capability bit; all -others currently defined are late. +Whether a capability number is early depends on its meaning, rather than +being a static property of its number. That said, the mobile-end-gets +priority bit (31) is always sent as an `early' capability bit. MTU handling diff --git a/magic.h b/magic.h index fa171fd..15d8498 100644 --- a/magic.h +++ b/magic.h @@ -99,7 +99,6 @@ */ /* uses of the 32-bit capability bitmap */ -#define CAPAB_EARLY CAPAB_PRIORITY_MOBILE #define CAPAB_TRANSFORM_MASK 0x0000ffff #define CAPAB_PRIORITY_MOBILE 0x80000000 /* mobile site has MSG1 priority */ /* remaining bits are unused */ diff --git a/site.c b/site.c index 9e877c7..3b8f34d 100644 --- a/site.c +++ b/site.c @@ -318,6 +318,7 @@ struct site { struct hash_if *hash; uint32_t index; /* Index of this site */ + uint32_t early_capabilities; uint32_t local_capabilities; int32_t setup_retries; /* How many times to send setup packets */ int32_t setup_retry_interval; /* Initial timeout for setup packets */ @@ -626,7 +627,8 @@ static bool_t generate_msg(struct site *st, uint32_t type, cstring_t what) struct xinfoadd xia; append_string_xinfo_start(&st->buffer,&xia,st->localname); - if ((st->local_capabilities & CAPAB_EARLY) || (type != LABEL_MSG1)) { + if ((st->local_capabilities & st->early_capabilities) || + (type != LABEL_MSG1)) { buf_append_uint32(&st->buffer,st->local_capabilities); } if (type_is_msg34(type)) { @@ -904,7 +906,7 @@ static bool_t process_msg3(struct site *st, struct buffer_if *msg3, return False; } uint32_t capab_adv_late = m.remote_capabilities - & ~st->remote_capabilities & CAPAB_EARLY; + & ~st->remote_capabilities & st->early_capabilities; if (capab_adv_late) { slog(st,LOG_SEC,"msg3 impermissibly adds early capability flag(s)" " %#"PRIx32" (was %#"PRIx32", now %#"PRIx32")", @@ -2125,6 +2127,7 @@ static list_t *site_apply(closure_t *self, struct cloc loc, dict_t *context, assert(index_sequence < 0xffffffffUL); st->index = ++index_sequence; st->local_capabilities = 0; + st->early_capabilities = CAPAB_PRIORITY_MOBILE; st->netlink=find_cl_if(dict,"link",CL_NETLINK,True,"site",loc); #define GET_CLOSURE_LIST(dictkey,things,nthings,CL_TYPE) do{ \