diff options
author | Tobias Klauser <tklauser@distanz.ch> | 2015-02-17 17:42:33 +0100 |
---|---|---|
committer | Tobias Klauser <tklauser@distanz.ch> | 2015-02-17 17:42:33 +0100 |
commit | dca3fbc189503465d5720b487533c6a5a8e6996e (patch) | |
tree | e90ddd8669ce7c0514df4ed79eb609acfab8b1d9 | |
parent | d0905f3cfb7831fcd823dd55675b1ba50e147a1e (diff) |
llmnrd: Implement message compression for name
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
-rw-r--r-- | llmnr.c | 15 |
1 files changed, 8 insertions, 7 deletions
@@ -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 */ |