From: fendo Date: Tue, 26 Feb 2013 08:59:45 +0000 (+0100) Subject: Merge from master X-Git-Tag: 2.2.1-2sames3.8~8 X-Git-Url: http://git.sameswireless.fr/l2tpns.git/commitdiff_plain/df35f4d66fd01268fe4456994368b76a541acec4?hp=eecccf0b30d5ec19960633d1b62cf5f9936d1f16 Merge from master --- diff --git a/debian/changelog b/debian/changelog index 5dcfe00..5c63054 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +l2tpns (2.2.1-2sames3.7) unstable; urgency=low + + * Merge from master + * Fix Warning: dereferencing type-punned pointer will break strict... + * Fix: Tunnel creation does not work when the length of the hostname is odd. (revert fix: Add a uint16_t control buffer type, as a union) + + -- Fernando Alves Tue, 26 Feb 2013 09:07:16 +0100 + l2tpns (2.2.1-2sames3.6) unstable; urgency=low * Sames l2tpns version. diff --git a/l2tpns.c b/l2tpns.c index 34e4a7a..392668b 100644 --- a/l2tpns.c +++ b/l2tpns.c @@ -1844,10 +1844,10 @@ static void send_ipout(sessionidt s, uint8_t *buf, int len) static void control16(controlt * c, uint16_t avp, uint16_t val, uint8_t m) { uint16_t l = (m ? 0x8008 : 0x0008); - c->buf16[c->length/2 + 0] = htons(l); - c->buf16[c->length/2 + 1] = htons(0); - c->buf16[c->length/2 + 2] = htons(avp); - c->buf16[c->length/2 + 3] = htons(val); + *(uint16_t *) (c->buf + c->length + 0) = htons(l); + *(uint16_t *) (c->buf + c->length + 2) = htons(0); + *(uint16_t *) (c->buf + c->length + 4) = htons(avp); + *(uint16_t *) (c->buf + c->length + 6) = htons(val); c->length += 8; } @@ -1855,10 +1855,10 @@ static void control16(controlt * c, uint16_t avp, uint16_t val, uint8_t m) static void control32(controlt * c, uint16_t avp, uint32_t val, uint8_t m) { uint16_t l = (m ? 0x800A : 0x000A); - c->buf16[c->length/2 + 0] = htons(l); - c->buf16[c->length/2 + 1] = htons(0); - c->buf16[c->length/2 + 2] = htons(avp); - *(uint32_t *) &c->buf[c->length + 6] = htonl(val); + *(uint16_t *) (c->buf + c->length + 0) = htons(l); + *(uint16_t *) (c->buf + c->length + 2) = htons(0); + *(uint16_t *) (c->buf + c->length + 4) = htons(avp); + *(uint32_t *) (c->buf + c->length + 6) = htonl(val); c->length += 10; } @@ -1866,10 +1866,10 @@ static void control32(controlt * c, uint16_t avp, uint32_t val, uint8_t m) static void controls(controlt * c, uint16_t avp, char *val, uint8_t m) { uint16_t l = ((m ? 0x8000 : 0) + strlen(val) + 6); - c->buf16[c->length/2 + 0] = htons(l); - c->buf16[c->length/2 + 1] = htons(0); - c->buf16[c->length/2 + 2] = htons(avp); - memcpy(&c->buf[c->length + 6], val, strlen(val)); + *(uint16_t *) (c->buf + c->length + 0) = htons(l); + *(uint16_t *) (c->buf + c->length + 2) = htons(0); + *(uint16_t *) (c->buf + c->length + 4) = htons(avp); + memcpy(c->buf + c->length + 6, val, strlen(val)); c->length += 6 + strlen(val); } @@ -1877,10 +1877,10 @@ static void controls(controlt * c, uint16_t avp, char *val, uint8_t m) static void controlb(controlt * c, uint16_t avp, uint8_t *val, unsigned int len, uint8_t m) { uint16_t l = ((m ? 0x8000 : 0) + len + 6); - c->buf16[c->length/2 + 0] = htons(l); - c->buf16[c->length/2 + 1] = htons(0); - c->buf16[c->length/2 + 2] = htons(avp); - memcpy(&c->buf[c->length + 6], val, len); + *(uint16_t *) (c->buf + c->length + 0) = htons(l); + *(uint16_t *) (c->buf + c->length + 2) = htons(0); + *(uint16_t *) (c->buf + c->length + 4) = htons(avp); + memcpy(c->buf + c->length + 6, val, len); c->length += 6 + len; } @@ -1897,7 +1897,8 @@ static controlt *controlnew(uint16_t mtype) } assert(c); c->next = 0; - c->buf16[0] = htons(0xC802); // flags/ver + c->buf[0] = 0xC8; // flags + c->buf[1] = 0x02; // ver c->length = 12; control16(c, 0, mtype, 1); return c; @@ -1923,10 +1924,10 @@ static void controlnull(tunnelidt t) // add a control message to a tunnel, and send if within window static void controladd(controlt *c, sessionidt far, tunnelidt t) { - c->buf16[1] = htons(c->length); // length - c->buf16[2] = htons(tunnel[t].far); // tunnel - c->buf16[3] = htons(far); // session - c->buf16[4] = htons(tunnel[t].ns); // sequence + *(uint16_t *) (c->buf + 2) = htons(c->length); // length + *(uint16_t *) (c->buf + 4) = htons(tunnel[t].far); // tunnel + *(uint16_t *) (c->buf + 6) = htons(far); // session + *(uint16_t *) (c->buf + 8) = htons(tunnel[t].ns); // sequence tunnel[t].ns++; // advance sequence // link in message in to queue if (tunnel[t].controlc) diff --git a/l2tpns.h b/l2tpns.h index 0283842..fd7e0ba 100644 --- a/l2tpns.h +++ b/l2tpns.h @@ -252,10 +252,7 @@ typedef struct controls // control message { struct controls *next; // next in queue uint16_t length; // length - union { - uint8_t buf[MAXCONTROL]; - uint16_t buf16[MAXCONTROL/2]; - } __attribute__ ((__transparent_union__)); + uint8_t buf[MAXCONTROL]; } controlt;