]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Allow arp_open to be called publically.
authorRoy Marples <roy@marples.name>
Fri, 29 Apr 2016 22:42:48 +0000 (22:42 +0000)
committerRoy Marples <roy@marples.name>
Fri, 29 Apr 2016 22:42:48 +0000 (22:42 +0000)
arp.c
arp.h

diff --git a/arp.c b/arp.c
index 5dec96b29e5b726bdc572ab5b8ee077bafaba5df..20fcd7ae9bcf12109b067e96d157942d0865b539 100644 (file)
--- a/arp.c
+++ b/arp.c
@@ -172,8 +172,13 @@ arp_packet(void *arg)
                            memcmp(hw_s, ifn->hwaddr, ifn->hwlen) == 0)
                                break;
                }
-               if (ifn)
+               if (ifn) {
+#if 0
+                       logger(ifp->ctx, LOG_DEBUG,
+                           "%s: ignoring ARP from self", ifp->name);
+#endif
                        continue;
+               }
                /* Copy out the HW and IP addresses */
                memcpy(&arm.sha, hw_s, ar.ar_hln);
                memcpy(&arm.sip.s_addr, hw_s + ar.ar_hln, ar.ar_pln);
@@ -188,7 +193,7 @@ arp_packet(void *arg)
        }
 }
 
-static void
+int
 arp_open(struct interface *ifp)
 {
        struct iarp_state *state;
@@ -199,10 +204,11 @@ arp_open(struct interface *ifp)
                if (state->fd == -1) {
                        logger(ifp->ctx, LOG_ERR, "%s: %s: %m",
                            __func__, ifp->name);
-                       return;
+                       return -1;
                }
                eloop_event_add(ifp->ctx->eloop, state->fd, arp_packet, ifp);
        }
+       return state->fd;
 }
 
 static void
@@ -246,7 +252,11 @@ void
 arp_announce(struct arp_state *astate)
 {
 
-       arp_open(astate->iface);
+       if (arp_open(astate->iface) == -1) {
+               logger(astate->iface->ctx, LOG_ERR,
+                   "%s: %s: %m", __func__, astate->iface->name);
+               return;
+       }
        astate->claims = 0;
        arp_announce1(astate);
 }
@@ -290,7 +300,11 @@ void
 arp_probe(struct arp_state *astate)
 {
 
-       arp_open(astate->iface);
+       if (arp_open(astate->iface) == -1) {
+               logger(astate->iface->ctx, LOG_ERR,
+                   "%s: %s: %m", __func__, astate->iface->name);
+               return;
+       }
        astate->probes = 0;
        logger(astate->iface->ctx, LOG_DEBUG, "%s: probing for %s",
            astate->iface->name, inet_ntoa(astate->addr));
diff --git a/arp.h b/arp.h
index c63cc7309332a7dd9147d0587549bf7374e8f3dd..b9636662992d928221ba49fa58d2920a66aafdba 100644 (file)
--- a/arp.h
+++ b/arp.h
@@ -77,6 +77,7 @@ struct iarp_state {
        ((const struct iarp_state *)(ifp)->if_data[IF_DATA_ARP])
 
 #ifdef INET
+int arp_open(struct interface *);
 ssize_t arp_request(const struct interface *, in_addr_t, in_addr_t);
 void arp_report_conflicted(const struct arp_state *, const struct arp_msg *);
 void arp_announce(struct arp_state *);