summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Franke <cfchris6@ts2server.com>2010-08-28 17:07:08 (GMT)
committerChristian Franke <cfchris6@ts2server.com>2010-08-28 17:07:08 (GMT)
commit6a2c876e08b5ed13b3b052b89e812a0afd66f61e (patch)
treed0b61c4d21905871ba31bb813284291fa8ca2fd1
parent20d9a87612fa60405e949793c7336bf7dd1a3825 (diff)
slight debug mode changes
-rw-r--r--Makefile4
-rw-r--r--src/replarp.c20
2 files changed, 13 insertions, 11 deletions
diff --git a/Makefile b/Makefile
index 9ed18e6..40356d9 100644
--- a/Makefile
+++ b/Makefile
@@ -4,6 +4,10 @@ DESTDIR := /
INSTALL := /usr/bin/install
PREFIX := /usr/local
+DEBUG := 0
+
+CFLAGS += -DDEBUG=$(DEBUG)
+
all: src/replarp
src/replarp: src/replarp.c
diff --git a/src/replarp.c b/src/replarp.c
index 301ae5e..44e4f56 100644
--- a/src/replarp.c
+++ b/src/replarp.c
@@ -50,6 +50,7 @@
#define debug_printf(a) printf(a)
#else
#define debug_printf(a)
+#define debug_print_hwaddr(a,b,c)
#endif
union ether_arp_ip {
@@ -93,7 +94,7 @@ static int addr_count = 0;
static void open_socket();
static void get_hwaddr();
#if DEBUG
-static void print_hwaddr(const char*, const uint8_t*, uint8_t);
+static void debug_print_hwaddr(const char*, const uint8_t*, uint8_t);
#endif
static void main_loop();
int main(int,char**);
@@ -153,7 +154,7 @@ static void get_hwaddr()
}
#if DEBUG
-static void print_hwaddr(const char*prompt,
+static void debug_print_hwaddr(const char*prompt,
const uint8_t*buffer,
uint8_t size)
{
@@ -211,12 +212,11 @@ static void main_loop()
continue;
debug_printf("Received ARP request.\n");
-#if DEBUG
- print_hwaddr("Src hw-addr is", recvbuffer.hdr_arp_sha, ETH_ALEN);
- print_hwaddr("Src protocol addr is",recvbuffer.hdr_arp_spa, IP_ALEN);
- print_hwaddr("Dest hw-addr is", recvbuffer.hdr_arp_tha, ETH_ALEN);
- print_hwaddr("Dest protocol addr is",recvbuffer.hdr_arp_tpa,IP_ALEN);
-#endif
+ debug_print_hwaddr("Src hw-addr is", recvbuffer.hdr_arp_sha, ETH_ALEN);
+ debug_print_hwaddr("Src protocol addr is",recvbuffer.hdr_arp_spa, IP_ALEN);
+ debug_print_hwaddr("Dest hw-addr is", recvbuffer.hdr_arp_tha, ETH_ALEN);
+ debug_print_hwaddr("Dest protocol addr is",recvbuffer.hdr_arp_tpa,IP_ALEN);
+
memcpy(sendbuffer.hdr_eth_dhost, recvbuffer.hdr_eth_shost, ETH_ALEN);
memcpy(sendbuffer.hdr_eth_shost, ifaddr, ETH_ALEN);
sendbuffer.hdr_eth_type = htons(ETHERTYPE_ARP);
@@ -264,9 +264,7 @@ int main(int argc, char **argv)
debug_printf("Getting hardware_address...");
get_hwaddr();
debug_printf("done.\n");
-#if DEBUG
- print_hwaddr("It is", ifaddr, ETH_ALEN);
-#endif
+ debug_print_hwaddr("It is", ifaddr, ETH_ALEN);
printf("Everything seems to be in order. Starting main loop.\n");
main_loop();