summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrediano Ziglio <fziglio@redhat.com>2016-07-27 17:13:42 +0100
committerFrediano Ziglio <fziglio@redhat.com>2016-07-27 17:13:42 +0100
commit48a1c146116f7695a8cb7e19d2155cca87156490 (patch)
tree683717d9dd13b516464a01bcdd4d92737251a449
parent965eb5a615fe0f7f2a2526fca8cd2ba230a6626d (diff)
use an IP macro to make easier to understand the constant ip used
-rw-r--r--tun.c2
-rw-r--r--utils.h2
2 files changed, 3 insertions, 1 deletions
diff --git a/tun.c b/tun.c
index 80c1441..f577ee0 100644
--- a/tun.c
+++ b/tun.c
@@ -243,7 +243,7 @@ handle_tun(void)
struct iphdr *ip = (struct iphdr *) pkt->data;
if (ip->version != IPVERSION)
continue;
- flow = &flows[ip->daddr == htonl(0xc0a87f00)];
+ flow = &flows[ip->daddr == htonl(IP(192,168,127,0))];
uint64_t curr_time = get_time_us();
uint64_t time_to_send;
diff --git a/utils.h b/utils.h
index bc16a6f..62805b4 100644
--- a/utils.h
+++ b/utils.h
@@ -4,6 +4,8 @@
#define MAX(a,b) ((a) > (b) ? (a) : (b))
#define MIN(a,b) ((a) < (b) ? (a) : (b))
+#define IP(a,b,c,d) ((a)*0x1000000u+(b)*0x10000u+(c)*0x100u+(d)*1u)
+
void set_nonblocking(int sock);
void set_nodelay(int fd);
void write_all(int fd, const void *buf, size_t buf_size);