summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2015-02-16 15:10:05 +0100
committerTobias Klauser <tklauser@distanz.ch>2015-02-16 15:10:05 +0100
commit546fd8a2c668e9817f469d0139f936962492919a (patch)
tree502b89a71cbf2ced7bd4e7b1f73eae6ea1e1c4c3
parent49be96c51e2bff9caef0b453ece74b4fd4692766 (diff)
llmnr: Fix response packet byte order and name size
We need to return type, class, ttl and rdlength in network byte order. Also we need to pkt_put() 2 bytes in addition to the hostname length (length and NULL byte). Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
-rw-r--r--llmnr.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/llmnr.c b/llmnr.c
index c8cc123..3dde9e6 100644
--- a/llmnr.c
+++ b/llmnr.c
@@ -155,15 +155,15 @@ static void llmnr_respond(unsigned int ifindex, const struct llmnr_hdr *hdr,
* TODO: Implement message compression (RFC 1035,
* section 4.1.3)
*/
- memcpy(pkt_put(p, llmnr_hostname[0]), llmnr_hostname, llmnr_hostname[0] + 2);
+ memcpy(pkt_put(p, llmnr_hostname[0] + 2), llmnr_hostname, llmnr_hostname[0] + 2);
/* TYPE */
- pkt_put_u16(p, qtype);
+ pkt_put_u16(p, htons(qtype));
/* CLASS */
- pkt_put_u16(p, LLMNR_CLASS_IN);
+ pkt_put_u16(p, htons(LLMNR_CLASS_IN));
/* TTL */
- pkt_put_u32(p, LLMNR_TTL_DEFAULT);
+ pkt_put_u32(p, htonl(LLMNR_TTL_DEFAULT));
/* RDLENGTH */
- pkt_put_u16(p, addr_size);
+ pkt_put_u16(p, htons(addr_size));
/* RDATA */
memcpy(pkt_put(p, addr_size), addr, addr_size);
}