Diff for /embedaddon/dnsmasq/src/arp.c between versions 1.1.1.1 and 1.1.1.2

version 1.1.1.1, 2016/11/02 09:57:01 version 1.1.1.2, 2021/03/17 00:56:46
Line 1 Line 1
/* dnsmasq is Copyright (c) 2000-2016 Simon Kelley/* dnsmasq is Copyright (c) 2000-2021 Simon Kelley
   
    This program is free software; you can redistribute it and/or modify     This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by     it under the terms of the GNU General Public License as published by
Line 28  struct arp_record { Line 28  struct arp_record {
   unsigned short hwlen, status;    unsigned short hwlen, status;
   int family;    int family;
   unsigned char hwaddr[DHCP_CHADDR_MAX];     unsigned char hwaddr[DHCP_CHADDR_MAX]; 
  struct all_addr addr;  union all_addr addr;
   struct arp_record *next;    struct arp_record *next;
 };  };
   
Line 44  static int filter_mac(int family, char *addrp, char *m Line 44  static int filter_mac(int family, char *addrp, char *m
   if (maclen > DHCP_CHADDR_MAX)    if (maclen > DHCP_CHADDR_MAX)
     return 1;      return 1;
   
 #ifndef HAVE_IPV6  
   if (family != AF_INET)  
     return 1;  
 #endif  
   
   /* Look for existing entry */    /* Look for existing entry */
   for (arp = arps; arp; arp = arp->next)    for (arp = arps; arp; arp = arp->next)
     {      {
Line 57  static int filter_mac(int family, char *addrp, char *m Line 52  static int filter_mac(int family, char *addrp, char *m
               
       if (family == AF_INET)        if (family == AF_INET)
         {          {
          if (arp->addr.addr.addr4.s_addr != ((struct in_addr *)addrp)->s_addr)          if (arp->addr.addr4.s_addr != ((struct in_addr *)addrp)->s_addr)
             continue;              continue;
         }          }
 #ifdef HAVE_IPV6  
       else        else
         {          {
          if (!IN6_ARE_ADDR_EQUAL(&arp->addr.addr.addr6, (struct in6_addr *)addrp))          if (!IN6_ARE_ADDR_EQUAL(&arp->addr.addr6, (struct in6_addr *)addrp))
             continue;              continue;
         }          }
 #endif  
   
       if (arp->status == ARP_EMPTY)        if (arp->status == ARP_EMPTY)
         {          {
Line 102  static int filter_mac(int family, char *addrp, char *m Line 95  static int filter_mac(int family, char *addrp, char *m
       arp->family = family;        arp->family = family;
       memcpy(arp->hwaddr, mac, maclen);        memcpy(arp->hwaddr, mac, maclen);
       if (family == AF_INET)        if (family == AF_INET)
        arp->addr.addr.addr4.s_addr = ((struct in_addr *)addrp)->s_addr;        arp->addr.addr4.s_addr = ((struct in_addr *)addrp)->s_addr;
#ifdef HAVE_IPV6 
       else        else
        memcpy(&arp->addr.addr.addr6, addrp, IN6ADDRSZ);        memcpy(&arp->addr.addr6, addrp, IN6ADDRSZ);
#endif 
     }      }
       
   return 1;    return 1;
Line 133  int find_mac(union mysockaddr *addr, unsigned char *ma Line 124  int find_mac(union mysockaddr *addr, unsigned char *ma
             continue;              continue;
                           
           if (arp->family == AF_INET &&            if (arp->family == AF_INET &&
              arp->addr.addr.addr4.s_addr != addr->in.sin_addr.s_addr)              arp->addr.addr4.s_addr != addr->in.sin_addr.s_addr)
             continue;              continue;
                           
 #ifdef HAVE_IPV6  
           if (arp->family == AF_INET6 &&             if (arp->family == AF_INET6 && 
              !IN6_ARE_ADDR_EQUAL(&arp->addr.addr.addr6, &addr->in6.sin6_addr))              !IN6_ARE_ADDR_EQUAL(&arp->addr.addr6, &addr->in6.sin6_addr))
             continue;              continue;
 #endif  
                       
           /* Only accept positive entries unless in lazy mode. */            /* Only accept positive entries unless in lazy mode. */
           if (arp->status != ARP_EMPTY || lazy || updated)            if (arp->status != ARP_EMPTY || lazy || updated)
Line 202  int find_mac(union mysockaddr *addr, unsigned char *ma Line 191  int find_mac(union mysockaddr *addr, unsigned char *ma
       arp->hwlen = 0;        arp->hwlen = 0;
   
       if (addr->sa.sa_family == AF_INET)        if (addr->sa.sa_family == AF_INET)
        arp->addr.addr.addr4.s_addr = addr->in.sin_addr.s_addr;        arp->addr.addr4.s_addr = addr->in.sin_addr.s_addr;
#ifdef HAVE_IPV6 
       else        else
        memcpy(&arp->addr.addr.addr6, &addr->in6.sin6_addr, IN6ADDRSZ);        memcpy(&arp->addr.addr6, &addr->in6.sin6_addr, IN6ADDRSZ);
#endif 
     }      }
                       
    return 0;     return 0;

Removed from v.1.1.1.1  
changed lines
  Added in v.1.1.1.2


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>