From 7834ae7d8154227117712ca9e587e43ab5ddf8e2 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 21 Sep 2019 16:41:12 +0100 Subject: [PATCH] site: Provide NAK reasons mentioning names and unpick failure Signed-off-by: Ian Jackson --- secnet.h | 3 +++ site.c | 11 ++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/secnet.h b/secnet.h index 95bda99..7da7c2d 100644 --- a/secnet.h +++ b/secnet.h @@ -467,6 +467,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 57ccb1d..3796889 100644 --- a/site.c +++ b/site.c @@ -1830,11 +1830,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.30.2