Diff for /embedaddon/dnsmasq/src/helper.c between versions 1.1.1.2 and 1.1.1.3

version 1.1.1.2, 2014/06/15 16:31:38 version 1.1.1.3, 2016/11/02 09:57:01
Line 1 Line 1
/* dnsmasq is Copyright (c) 2000-2014 Simon Kelley/* dnsmasq is Copyright (c) 2000-2016 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 219  int create_helper(int event_fd, int err_fd, uid_t uid, Line 219  int create_helper(int event_fd, int err_fd, uid_t uid,
           action_str = "tftp";            action_str = "tftp";
           is6 = (data.flags != AF_INET);            is6 = (data.flags != AF_INET);
         }          }
      else      else if (data.action == ACTION_ARP)
         {
           action_str = "arp-add";
           is6 = (data.flags != AF_INET);
         }
        else if (data.action == ACTION_ARP_DEL)
         {
           action_str = "arp-del";
           is6 = (data.flags != AF_INET);
           data.action = ACTION_ARP;
         }
        else 
         continue;          continue;
   
                   
Line 289  int create_helper(int event_fd, int err_fd, uid_t uid, Line 300  int create_helper(int event_fd, int err_fd, uid_t uid,
           
       if (!is6)        if (!is6)
         inet_ntop(AF_INET, &data.addr, daemon->addrbuff, ADDRSTRLEN);          inet_ntop(AF_INET, &data.addr, daemon->addrbuff, ADDRSTRLEN);
#ifdef HAVE_DHCP6#ifdef HAVE_IPV6
       else        else
         inet_ntop(AF_INET6, &data.addr6, daemon->addrbuff, ADDRSTRLEN);          inet_ntop(AF_INET6, &data.addr6, daemon->addrbuff, ADDRSTRLEN);
 #endif  #endif
Line 321  int create_helper(int event_fd, int err_fd, uid_t uid, Line 332  int create_helper(int event_fd, int err_fd, uid_t uid,
                   lua_call(lua, 2, 0);  /* pass 2 values, expect 0 */                    lua_call(lua, 2, 0);  /* pass 2 values, expect 0 */
                 }                  }
             }              }
             else if (data.action == ACTION_ARP)
               {
                 lua_getglobal(lua, "arp"); 
                 if (lua_type(lua, -1) != LUA_TFUNCTION)
                   lua_pop(lua, 1); /* arp function optional */
                 else
                   {
                     lua_pushstring(lua, action_str); /* arg1 - action */
                     lua_newtable(lua);               /* arg2 - data table */
                     lua_pushstring(lua, daemon->addrbuff);
                     lua_setfield(lua, -2, "client_address");
                     lua_pushstring(lua, daemon->dhcp_buff);
                     lua_setfield(lua, -2, "mac_address");
                     lua_call(lua, 2, 0);  /* pass 2 values, expect 0 */
                   }
               }
           else            else
             {              {
               lua_getglobal(lua, "lease");     /* function to call */                lua_getglobal(lua, "lease");     /* function to call */
Line 478  int create_helper(int event_fd, int err_fd, uid_t uid, Line 505  int create_helper(int event_fd, int err_fd, uid_t uid,
           continue;            continue;
         }          }
               
      if (data.action != ACTION_TFTP)      if (data.action != ACTION_TFTP && data.action != ACTION_ARP)
         {          {
 #ifdef HAVE_DHCP6  #ifdef HAVE_DHCP6
           my_setenv("DNSMASQ_IAID", is6 ? daemon->dhcp_buff3 : NULL, &err);            my_setenv("DNSMASQ_IAID", is6 ? daemon->dhcp_buff3 : NULL, &err);
Line 550  int create_helper(int event_fd, int err_fd, uid_t uid, Line 577  int create_helper(int event_fd, int err_fd, uid_t uid,
           my_setenv("DNSMASQ_OLD_HOSTNAME", data.action == ACTION_OLD_HOSTNAME ? hostname : NULL, &err);            my_setenv("DNSMASQ_OLD_HOSTNAME", data.action == ACTION_OLD_HOSTNAME ? hostname : NULL, &err);
           if (data.action == ACTION_OLD_HOSTNAME)            if (data.action == ACTION_OLD_HOSTNAME)
             hostname = NULL;              hostname = NULL;
        }          
          my_setenv("DNSMASQ_LOG_DHCP", option_bool(OPT_LOG_OPTS) ? "1" : NULL, &err);
      my_setenv("DNSMASQ_LOG_DHCP", option_bool(OPT_LOG_OPTS) ? "1" : NULL, &err);    }
       
       /* we need to have the event_fd around if exec fails */        /* we need to have the event_fd around if exec fails */
       if ((i = fcntl(event_fd, F_GETFD)) != -1)        if ((i = fcntl(event_fd, F_GETFD)) != -1)
         fcntl(event_fd, F_SETFD, i | FD_CLOEXEC);          fcntl(event_fd, F_SETFD, i | FD_CLOEXEC);
Line 563  int create_helper(int event_fd, int err_fd, uid_t uid, Line 589  int create_helper(int event_fd, int err_fd, uid_t uid,
       if (err == 0)        if (err == 0)
         {          {
           execl(daemon->lease_change_command,             execl(daemon->lease_change_command, 
                p ? p+1 : daemon->lease_change_command,                p ? p+1 : daemon->lease_change_command, action_str, 
                action_str, is6 ? daemon->packet : daemon->dhcp_buff,                 (is6 && data.action != ACTION_ARP) ? daemon->packet : daemon->dhcp_buff, 
                 daemon->addrbuff, hostname, (char*)NULL);                  daemon->addrbuff, hostname, (char*)NULL);
           err = errno;            err = errno;
         }          }
Line 759  void queue_tftp(off_t file_len, char *filename, union  Line 785  void queue_tftp(off_t file_len, char *filename, union 
   bytes_in_buf = sizeof(struct script_data) +  filename_len;    bytes_in_buf = sizeof(struct script_data) +  filename_len;
 }  }
 #endif  #endif
   
   void queue_arp(int action, unsigned char *mac, int maclen, int family, struct all_addr *addr)
   {
     /* no script */
     if (daemon->helperfd == -1)
       return;
     
     buff_alloc(sizeof(struct script_data));
     memset(buf, 0, sizeof(struct script_data));
   
     buf->action = action;
     buf->hwaddr_len = maclen;
     buf->hwaddr_type =  ARPHRD_ETHER; 
     if ((buf->flags = family) == AF_INET)
       buf->addr = addr->addr.addr4;
   #ifdef HAVE_IPV6
     else
       buf->addr6 = addr->addr.addr6;
   #endif
     
     memcpy(buf->hwaddr, mac, maclen);
     
     bytes_in_buf = sizeof(struct script_data);
   }
   
 int helper_buf_empty(void)  int helper_buf_empty(void)
 {  {

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


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