ref: 468c25eef8cfd6d979d050a742e680216a83220a
parent: 784dcf63f74b671ad56bd8dfc2a287c2a38fa1e2
author: mkf <mkf@cloud9p.org>
date: Sat Aug 3 05:09:46 EDT 2024
pkt: fix no packets being read (fragoffset seems to be 13bits
--- a/pkt.c
+++ b/pkt.c
@@ -39,9 +39,10 @@
pos += PKT_ID;
p->flags = pkt[pos];
- pos += PKT_FLAGS;
+ /* flags are just 3 bits, smaller than a byte */
p->fragoffset = get2(pkt + pos);
+ p->fragoffset &= 0x1FFF;
pos += PKT_FRAGOFFSET;
p->ttl = pkt[pos];
@@ -69,7 +70,7 @@
"\tversion: 0x%x\theaderlen: 0x%x\tdsfield: %b\n",
p.version, p.headerlen, p.dsfield);
- printf("\tlen: %d (%x)\tid: %x (%d)\n",
+ printf("\tlen: %d (%x)\tid: 0x%x (%d)\n",
p.len, p.len, p.id, p.id);
printf("\tttl: 0%x (%d)\tproto 0%x (%s)\tsum: 0x%x\n",
p.ttl, p.ttl, p.proto, pktTypeToStr(p.proto), p.sum);