From dca3fbc189503465d5720b487533c6a5a8e6996e Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Tue, 17 Feb 2015 17:42:33 +0100 Subject: llmnrd: Implement message compression for name Signed-off-by: Tobias Klauser --- llmnr.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/llmnr.c b/llmnr.c index a28a51e..92eb562 100644 --- a/llmnr.c +++ b/llmnr.c @@ -142,13 +142,14 @@ static void llmnr_respond(unsigned int ifindex, const struct llmnr_hdr *hdr, } else continue; - /* - * NAME - * - * TODO: Implement message compression (RFC 1035, - * section 4.1.3) - */ - memcpy(pkt_put(p, llmnr_hostname[0] + 2), llmnr_hostname, llmnr_hostname[0] + 2); + /* NAME */ + if (i == 0) + memcpy(pkt_put(p, llmnr_hostname[0] + 2), llmnr_hostname, llmnr_hostname[0] + 2); + else { + /* message compression (RFC 1035, section 4.1.3) */ + uint16_t ptr = 0xC000 | (sizeof(*hdr) + query_len); + pkt_put_u16(p, ntohs(ptr)); + } /* TYPE */ pkt_put_u16(p, htons(type)); /* CLASS */ -- cgit v1.2.3-54-g00ecf