[SECNET PATCH 14/14] site: Provide NAK reasons mentioning names and unpick failure

Ian Jackson ijackson at chiark.greenend.org.uk
Sat Sep 21 17:07:59 BST 2019


Signed-off-by: Ian Jackson <ijackson at chiark.greenend.org.uk>
---
 secnet.h |  3 +++
 site.c   | 11 ++++++++---
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/secnet.h b/secnet.h
index 6cd277e..c813e1b 100644
--- a/secnet.h
+++ b/secnet.h
@@ -452,6 +452,9 @@ typedef struct comm_clientinfo *comm_clientinfo_fn(void *state, dict_t*,
 
 enum {
     comm_notify_whynot_general,
+    comm_notify_whynot_unpick,
+    comm_notify_whynot_name_local,
+    comm_notify_whynot_name_remote,
 };
 
 /* Return True if the packet was processed, and shouldn't be passed to
diff --git a/site.c b/site.c
index 568b18d..710c394 100644
--- a/site.c
+++ b/site.c
@@ -1778,11 +1778,16 @@ static bool_t named_for_us(struct site *st, const struct buffer_if *buf_in,
     buffer_readonly_clone(buf,buf_in);
 
     if (!unpick_msg(st,type,buf,m)) {
+	priomsg_update_fixed(whynot, comm_notify_whynot_unpick, "malformed");
 	return False;
     }
-#define NAME_MATCHES(lr)			\
-    if (!name_matches(&m->lr, st->lr##name)) {	\
-        return False;				\
+#define NAME_MATCHES(lr)						\
+    if (!name_matches(&m->lr, st->lr##name)) {				\
+	if (priomsg_update_fixed(whynot, comm_notify_whynot_name_##lr,	\
+                                 "unknown " #lr " name: ")) {		\
+            truncmsg_add_packet_string(&whynot->m, m->lr.len, m->lr.name); \
+        }								\
+        return False;							\
     }
     NAME_MATCHES(remote);
     NAME_MATCHES(local );
-- 
2.11.0




More information about the sgo-software-discuss mailing list