Set IP before starting NMRP loop
authorJoseph C. Lehner <joseph.c.lehner@gmail.com>
Sun, 13 Nov 2016 07:28:22 +0000 (08:28 +0100)
committerJoseph C. Lehner <joseph.c.lehner@gmail.com>
Sun, 13 Nov 2016 07:28:22 +0000 (08:28 +0100)
nmrp.c

diff --git a/nmrp.c b/nmrp.c
index c2e634aa7241cbac4e745911c97fc62c4ccdcfbf..1d7008255b1c9d9abc37699e668754e5ad55f2c2 100644 (file)
--- a/nmrp.c
+++ b/nmrp.c
@@ -490,6 +490,14 @@ int nmrp_do(struct nmrpd_args *args)
                        }
                        goto out;
                }
+       } else {
+               if (verbosity) {
+                       printf("Adding %s to interface %s.\n", args->ipaddr_intf, args->intf);
+               }
+
+               if (ethsock_ip_add(sock, intf_addr, ipconf.mask.s_addr, &gundo) != 0) {
+                       goto out;
+               }
        }
 
        if (ethsock_set_timeout(sock, args->rx_timeout)) {
@@ -583,12 +591,6 @@ int nmrp_do(struct nmrpd_args *args)
                                memcpy(arpmac, rx.eh.ether_shost, 6);
                                memcpy(&arpip, &ipconf.addr, sizeof(ipconf.addr));
 
-                               if (autoip) {
-                                       if (ethsock_ip_add(sock, intf_addr, ipconf.mask.s_addr, &gundo) != 0) {
-                                               goto out;
-                                       }
-                               }
-
                                if (ethsock_arp_add(sock, arpmac, &arpip) != 0) {
                                        goto out;
                                }