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

version 1.1.1.1, 2013/07/29 19:37:40 version 1.1.1.2, 2014/06/15 16:31:38
Line 1 Line 1
/* dnsmasq is Copyright (c) 2000-2013 Simon Kelley/* dnsmasq is Copyright (c) 2000-2014 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 39  static struct iovec iov; Line 39  static struct iovec iov;
 static u32 netlink_pid;  static u32 netlink_pid;
   
 static int nl_async(struct nlmsghdr *h);  static int nl_async(struct nlmsghdr *h);
 static void nl_newaddress(time_t now);  
   
 void netlink_init(void)  void netlink_init(void)
 {  {
Line 193  int iface_enumerate(int family, void *parm, int (*call Line 192  int iface_enumerate(int family, void *parm, int (*call
           {            {
             /* May be multicast arriving async */              /* May be multicast arriving async */
             if (nl_async(h))              if (nl_async(h))
              newaddr = 1;               {
                 newaddr = 1; 
                 enumerate_interfaces(1); /* reset */
               }
           }            }
         else if (h->nlmsg_type == NLMSG_DONE)          else if (h->nlmsg_type == NLMSG_DONE)
           {            {
             /* handle async new interface address arrivals, these have to be done              /* handle async new interface address arrivals, these have to be done
                after we complete as we're not re-entrant */                 after we complete as we're not re-entrant */
             if (newaddr)               if (newaddr) 
              nl_newaddress(dnsmasq_time());              newaddress(dnsmasq_time());
                                   
             return callback_ok;              return callback_ok;
           }            }
Line 215  int iface_enumerate(int family, void *parm, int (*call Line 217  int iface_enumerate(int family, void *parm, int (*call
                 if (ifa->ifa_family == AF_INET)                  if (ifa->ifa_family == AF_INET)
                   {                    {
                     struct in_addr netmask, addr, broadcast;                      struct in_addr netmask, addr, broadcast;
                                        char *label = NULL;
 
                     netmask.s_addr = htonl(0xffffffff << (32 - ifa->ifa_prefixlen));                      netmask.s_addr = htonl(0xffffffff << (32 - ifa->ifa_prefixlen));
                     addr.s_addr = 0;                      addr.s_addr = 0;
                     broadcast.s_addr = 0;                      broadcast.s_addr = 0;
Line 226  int iface_enumerate(int family, void *parm, int (*call Line 229  int iface_enumerate(int family, void *parm, int (*call
                           addr = *((struct in_addr *)(rta+1));                            addr = *((struct in_addr *)(rta+1));
                         else if (rta->rta_type == IFA_BROADCAST)                          else if (rta->rta_type == IFA_BROADCAST)
                           broadcast = *((struct in_addr *)(rta+1));                            broadcast = *((struct in_addr *)(rta+1));
                           else if (rta->rta_type == IFA_LABEL)
                             label = RTA_DATA(rta);
                                                   
                         rta = RTA_NEXT(rta, len1);                          rta = RTA_NEXT(rta, len1);
                       }                        }
                                           
                     if (addr.s_addr && callback_ok)                      if (addr.s_addr && callback_ok)
                      if (!((*callback)(addr, ifa->ifa_index, netmask, broadcast, parm)))                      if (!((*callback)(addr, ifa->ifa_index, label,  netmask, broadcast, parm)))
                         callback_ok = 0;                          callback_ok = 0;
                   }                    }
 #ifdef HAVE_IPV6  #ifdef HAVE_IPV6
Line 260  int iface_enumerate(int family, void *parm, int (*call Line 265  int iface_enumerate(int family, void *parm, int (*call
                     if (ifa->ifa_flags & IFA_F_DEPRECATED)                      if (ifa->ifa_flags & IFA_F_DEPRECATED)
                       flags |= IFACE_DEPRECATED;                        flags |= IFACE_DEPRECATED;
                                           
                       if (!(ifa->ifa_flags & IFA_F_TEMPORARY))
                         flags |= IFACE_PERMANENT;
                       
                     if (addrp && callback_ok)                      if (addrp && callback_ok)
                       if (!((*callback)(addrp, (int)(ifa->ifa_prefixlen), (int)(ifa->ifa_scope),                         if (!((*callback)(addrp, (int)(ifa->ifa_prefixlen), (int)(ifa->ifa_scope), 
                                         (int)(ifa->ifa_index), flags,                                           (int)(ifa->ifa_index), flags, 
Line 342  void netlink_multicast(time_t now) Line 350  void netlink_multicast(time_t now)
   fcntl(daemon->netlinkfd, F_SETFL, flags);    fcntl(daemon->netlinkfd, F_SETFL, flags);
       
   if (newaddr)     if (newaddr) 
    nl_newaddress(now);    newaddress(now);
 }  }
   
 static int nl_async(struct nlmsghdr *h)  static int nl_async(struct nlmsghdr *h)
Line 390  static int nl_async(struct nlmsghdr *h) Line 398  static int nl_async(struct nlmsghdr *h)
       
   return 0;    return 0;
 }  }
           
 static void nl_newaddress(time_t now)  
 {  
   if (option_bool(OPT_CLEVERBIND) || daemon->doing_dhcp6 || daemon->doing_ra)  
     enumerate_interfaces();  
     
   if (option_bool(OPT_CLEVERBIND))  
     create_bound_listeners(0);  
     
 #ifdef HAVE_DHCP6  
   if (daemon->doing_dhcp6 || daemon->doing_ra)  
     {  
       join_multicast(0);  
       dhcp_construct_contexts(now);  
     }  
     
   if (daemon->doing_dhcp6)  
     lease_find_interfaces(now);  
 #endif  
 }  
   
   
 #endif  #endif
   
               

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


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