diff options
author | Tobias Klauser <tklauser@distanz.ch> | 2016-01-26 18:16:54 +0100 |
---|---|---|
committer | Tobias Klauser <tklauser@distanz.ch> | 2016-01-26 18:16:54 +0100 |
commit | d10b477ea22e9f542ab3fd662777db061d137108 (patch) | |
tree | 86de09e01a79c6573beb8849787d798fcadc61ee /proto_arp.c | |
parent | f6371fb6df916db984bdce57ddea15abe7f780be (diff) |
dissectors: arp: Simplify arp_print_addrs()
Simplify the code in arp_print_addrs() a bit.
This was actually intended as an amend to commit f6371fb6df91
("dissectors: arp: Print hardware & protocol addresses").
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Diffstat (limited to 'proto_arp.c')
-rw-r--r-- | proto_arp.c | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/proto_arp.c b/proto_arp.c index 9f2a4e0..3560cd1 100644 --- a/proto_arp.c +++ b/proto_arp.c @@ -51,14 +51,9 @@ enum addr_direct { static void arp_print_addrs(struct arphdr *arp, enum addr_direct addr_dir) { - char *dir = addr_dir == ADDR_SENDER ? "Sender" : "Target"; - bool has_eth; - bool has_ip4; + const char *dir = addr_dir == ADDR_SENDER ? "Sender" : "Target"; - has_eth = ntohs(arp->ar_hrd) == ARPHRD_ETHER; - has_ip4 = ntohs(arp->ar_pro) == ETH_P_IP; - - if (has_eth) { + if (ntohs(arp->ar_hrd) == ARPHRD_ETHER) { uint8_t *mac; mac = addr_dir == ADDR_SENDER ? &arp->ar_sha[0] : &arp->ar_tha[0]; @@ -67,7 +62,7 @@ static void arp_print_addrs(struct arphdr *arp, enum addr_direct addr_dir) dir, mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); } - if (has_ip4) { + if (ntohs(arp->ar_pro) == ETH_P_IP) { char ip_str[INET_ADDRSTRLEN]; uint32_t ip; |