chiark / gitweb /
magic: Introduce LABEL_NAK
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 25 Jul 2013 17:30:50 +0000 (18:30 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 25 Jul 2013 17:30:50 +0000 (18:30 +0100)
Replace ad-hoc comments on the message number of NAK packets with an
explicit #define.  No functional change.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
magic.h
site.c
udp.c

diff --git a/magic.h b/magic.h
index 5ac1e3467c3d76a25a1ff9f1eafaa54ac4983c60..c2503a0c19ca30d2e09cd68cec32dcbd12f7bd8d 100644 (file)
--- a/magic.h
+++ b/magic.h
@@ -3,6 +3,7 @@
 #ifndef magic_h
 #define magic_h
 
 #ifndef magic_h
 #define magic_h
 
+#define LABEL_NAK  0x00000000
 #define LABEL_MSG0 0x00020200
 #define LABEL_MSG1 0x01010101
 #define LABEL_MSG2 0x02020202
 #define LABEL_MSG0 0x00020200
 #define LABEL_MSG1 0x01010101
 #define LABEL_MSG2 0x02020202
diff --git a/site.c b/site.c
index f1a03179603f4f9b402b5d10b0986b7c6af98722..a6fa9dafc2b13955b728932056fde6ea52f2ec3b 100644 (file)
--- a/site.c
+++ b/site.c
@@ -1286,7 +1286,7 @@ static bool_t site_incoming(void *sst, struct buffer_if *buf,
        uint32_t msgtype=ntohl(get_uint32(buf->start+8));
        if (msgtype!=LABEL_MSG0) dump_packet(st,buf,source,True);
        switch (msgtype) {
        uint32_t msgtype=ntohl(get_uint32(buf->start+8));
        if (msgtype!=LABEL_MSG0) dump_packet(st,buf,source,True);
        switch (msgtype) {
-       case 0: /* NAK */
+       case LABEL_NAK:
            /* If the source is our current peer then initiate a key setup,
               because our peer's forgotten the key */
            if (get_uint32(buf->start+4)==st->current.remote_session_id) {
            /* If the source is our current peer then initiate a key setup,
               because our peer's forgotten the key */
            if (get_uint32(buf->start+4)==st->current.remote_session_id) {
diff --git a/udp.c b/udp.c
index bbf8c64163dbd8815001493c90a12d8f8cac30c9..77be5b1786f7868ad3691b24be8fa35c3936695d 100644 (file)
--- a/udp.c
+++ b/udp.c
@@ -21,6 +21,7 @@
 #include "util.h"
 #include "unaligned.h"
 #include "ipaddr.h"
 #include "util.h"
 #include "unaligned.h"
 #include "ipaddr.h"
+#include "magic.h"
 
 static beforepoll_fn udp_beforepoll;
 static afterpoll_fn udp_afterpoll;
 
 static beforepoll_fn udp_beforepoll;
 static afterpoll_fn udp_afterpoll;
@@ -140,7 +141,7 @@ static void udp_afterpoll(void *state, struct pollfd *fds, int nfds)
                    buffer_init(st->rbuf,0);
                    buf_append_uint32(st->rbuf,dest);
                    buf_append_uint32(st->rbuf,source);
                    buffer_init(st->rbuf,0);
                    buf_append_uint32(st->rbuf,dest);
                    buf_append_uint32(st->rbuf,source);
-                   buf_append_uint32(st->rbuf,0); /* NAK is msg type 0 */
+                   buf_append_uint32(st->rbuf,LABEL_NAK);
                    sendto(st->fd, st->rbuf->start, st->rbuf->size, 0,
                           (struct sockaddr *)&from, sizeof(from));
                    BUF_FREE(st->rbuf);
                    sendto(st->fd, st->rbuf->start, st->rbuf->size, 0,
                           (struct sockaddr *)&from, sizeof(from));
                    BUF_FREE(st->rbuf);