chiark / gitweb /
site.c, magic.h, NOTES: Make early capabilities be dynamic.
authorMark Wooding <mdw@distorted.org.uk>
Sun, 30 Apr 2017 23:18:39 +0000 (00:18 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Wed, 25 Sep 2019 12:46:44 +0000 (13:46 +0100)
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 <mdw@distorted.org.uk>
NOTES
magic.h
site.c

diff --git a/NOTES b/NOTES
index e6957df1a39641ecb707de0c0ac463487732e407..884ae303860fa72824d50da21ab08f3a22e247fa 100644 (file)
--- 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 fa171fd704b46be9af18d32a02264645a4a977fd..15d84985299f79156344b0045b9f0600bd7dd42b 100644 (file)
--- 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 9e877c7fa3a542023efdd430c6d2ed19828021a2..3b8f34d47c8ff455a0d69bf931598093cacc6a25 100644 (file)
--- 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{           \