"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/dbus.c" between
dnsmasq-2.80.tar.gz and dnsmasq-2.81.tar.xz

About: Dnsmasq is a lightweight caching DNS forwarder and DHCP server.

dbus.c  (dnsmasq-2.80):dbus.c  (dnsmasq-2.81.tar.xz)
/* dnsmasq is Copyright (c) 2000-2018 Simon Kelley /* dnsmasq is Copyright (c) 2000-2020 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
the Free Software Foundation; version 2 dated June, 1991, or the Free Software Foundation; version 2 dated June, 1991, or
(at your option) version 3 dated 29 June, 2007. (at your option) version 3 dated 29 June, 2007.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
skipping to change at line 187 skipping to change at line 187
{ {
dbus_message_iter_get_basic(&iter, &p[i]); dbus_message_iter_get_basic(&iter, &p[i]);
dbus_message_iter_next (&iter); dbus_message_iter_next (&iter);
if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_BYTE) if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_BYTE)
{ {
i++; i++;
break; break;
} }
} }
#ifndef HAVE_IPV6
my_syslog(LOG_WARNING, _("attempt to set an IPv6 server address via DBu
s - no IPv6 support"));
#else
if (i == sizeof(struct in6_addr)) if (i == sizeof(struct in6_addr))
{ {
memcpy(&addr.in6.sin6_addr, p, sizeof(struct in6_addr)); memcpy(&addr.in6.sin6_addr, p, sizeof(struct in6_addr));
#ifdef HAVE_SOCKADDR_SA_LEN #ifdef HAVE_SOCKADDR_SA_LEN
source_addr.in6.sin6_len = addr.in6.sin6_len = sizeof(struct socka ddr_in6); source_addr.in6.sin6_len = addr.in6.sin6_len = sizeof(struct socka ddr_in6);
#endif #endif
source_addr.in6.sin6_family = addr.in6.sin6_family = AF_INET6; source_addr.in6.sin6_family = addr.in6.sin6_family = AF_INET6;
addr.in6.sin6_port = htons(NAMESERVER_PORT); addr.in6.sin6_port = htons(NAMESERVER_PORT);
source_addr.in6.sin6_flowinfo = addr.in6.sin6_flowinfo = 0; source_addr.in6.sin6_flowinfo = addr.in6.sin6_flowinfo = 0;
source_addr.in6.sin6_scope_id = addr.in6.sin6_scope_id = 0; source_addr.in6.sin6_scope_id = addr.in6.sin6_scope_id = 0;
source_addr.in6.sin6_addr = in6addr_any; source_addr.in6.sin6_addr = in6addr_any;
source_addr.in6.sin6_port = htons(daemon->query_port); source_addr.in6.sin6_port = htons(daemon->query_port);
skip = 0; skip = 0;
} }
#endif
} }
else else
/* At the end */ /* At the end */
break; break;
/* process each domain */ /* process each domain */
do { do {
if (dbus_message_iter_get_arg_type(&iter) == DBUS_TYPE_STRING) if (dbus_message_iter_get_arg_type(&iter) == DBUS_TYPE_STRING)
{ {
dbus_message_iter_get_basic(&iter, &domain); dbus_message_iter_get_basic(&iter, &domain);
skipping to change at line 461 skipping to change at line 457
#ifdef HAVE_DHCP #ifdef HAVE_DHCP
static DBusMessage *dbus_add_lease(DBusMessage* message) static DBusMessage *dbus_add_lease(DBusMessage* message)
{ {
struct dhcp_lease *lease; struct dhcp_lease *lease;
const char *ipaddr, *hwaddr, *hostname, *tmp; const char *ipaddr, *hwaddr, *hostname, *tmp;
const unsigned char* clid; const unsigned char* clid;
int clid_len, hostname_len, hw_len, hw_type; int clid_len, hostname_len, hw_len, hw_type;
dbus_uint32_t expires, ia_id; dbus_uint32_t expires, ia_id;
dbus_bool_t is_temporary; dbus_bool_t is_temporary;
struct all_addr addr; union all_addr addr;
time_t now = dnsmasq_time(); time_t now = dnsmasq_time();
unsigned char dhcp_chaddr[DHCP_CHADDR_MAX]; unsigned char dhcp_chaddr[DHCP_CHADDR_MAX];
DBusMessageIter iter, array_iter; DBusMessageIter iter, array_iter;
if (!dbus_message_iter_init(message, &iter)) if (!dbus_message_iter_init(message, &iter))
return dbus_message_new_error(message, DBUS_ERROR_INVALID_ARGS, return dbus_message_new_error(message, DBUS_ERROR_INVALID_ARGS,
"Failed to initialize dbus message iter"); "Failed to initialize dbus message iter");
if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING) if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
return dbus_message_new_error(message, DBUS_ERROR_INVALID_ARGS, return dbus_message_new_error(message, DBUS_ERROR_INVALID_ARGS,
skipping to change at line 531 skipping to change at line 527
dbus_message_iter_get_basic(&iter, &ia_id); dbus_message_iter_get_basic(&iter, &ia_id);
dbus_message_iter_next(&iter); dbus_message_iter_next(&iter);
if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_BOOLEAN) if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_BOOLEAN)
return dbus_message_new_error(message, DBUS_ERROR_INVALID_ARGS, return dbus_message_new_error(message, DBUS_ERROR_INVALID_ARGS,
"Expected uint32 as sixth argument"); "Expected uint32 as sixth argument");
dbus_message_iter_get_basic(&iter, &is_temporary); dbus_message_iter_get_basic(&iter, &is_temporary);
if (inet_pton(AF_INET, ipaddr, &addr.addr.addr4)) if (inet_pton(AF_INET, ipaddr, &addr.addr4))
{ {
if (ia_id != 0 || is_temporary) if (ia_id != 0 || is_temporary)
return dbus_message_new_error(message, DBUS_ERROR_INVALID_ARGS, return dbus_message_new_error(message, DBUS_ERROR_INVALID_ARGS,
"ia_id and is_temporary must be zero for IP v4 lease"); "ia_id and is_temporary must be zero for IP v4 lease");
if (!(lease = lease_find_by_addr(addr.addr.addr4))) if (!(lease = lease_find_by_addr(addr.addr4)))
lease = lease4_allocate(addr.addr.addr4); lease = lease4_allocate(addr.addr4);
} }
#ifdef HAVE_DHCP6 #ifdef HAVE_DHCP6
else if (inet_pton(AF_INET6, ipaddr, &addr.addr.addr6)) else if (inet_pton(AF_INET6, ipaddr, &addr.addr6))
{ {
if (!(lease = lease6_find_by_addr(&addr.addr.addr6, 128, 0))) if (!(lease = lease6_find_by_addr(&addr.addr6, 128, 0)))
lease = lease6_allocate(&addr.addr.addr6, lease = lease6_allocate(&addr.addr6,
is_temporary ? LEASE_TA : LEASE_NA); is_temporary ? LEASE_TA : LEASE_NA);
lease_set_iaid(lease, ia_id); lease_set_iaid(lease, ia_id);
} }
#endif #endif
else else
return dbus_message_new_error_printf(message, DBUS_ERROR_INVALID_ARGS, return dbus_message_new_error_printf(message, DBUS_ERROR_INVALID_ARGS,
"Invalid IP address '%s'", ipaddr); "Invalid IP address '%s'", ipaddr);
hw_len = parse_hex((char*)hwaddr, dhcp_chaddr, DHCP_CHADDR_MAX, NULL, &hw_type ); hw_len = parse_hex((char*)hwaddr, dhcp_chaddr, DHCP_CHADDR_MAX, NULL, &hw_type );
if (hw_type == 0 && hw_len != 0) if (hw_type == 0 && hw_len != 0)
skipping to change at line 575 skipping to change at line 571
return NULL; return NULL;
} }
static DBusMessage *dbus_del_lease(DBusMessage* message) static DBusMessage *dbus_del_lease(DBusMessage* message)
{ {
struct dhcp_lease *lease; struct dhcp_lease *lease;
DBusMessageIter iter; DBusMessageIter iter;
const char *ipaddr; const char *ipaddr;
DBusMessage *reply; DBusMessage *reply;
struct all_addr addr; union all_addr addr;
dbus_bool_t ret = 1; dbus_bool_t ret = 1;
time_t now = dnsmasq_time(); time_t now = dnsmasq_time();
if (!dbus_message_iter_init(message, &iter)) if (!dbus_message_iter_init(message, &iter))
return dbus_message_new_error(message, DBUS_ERROR_INVALID_ARGS, return dbus_message_new_error(message, DBUS_ERROR_INVALID_ARGS,
"Failed to initialize dbus message iter"); "Failed to initialize dbus message iter");
if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING) if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
return dbus_message_new_error(message, DBUS_ERROR_INVALID_ARGS, return dbus_message_new_error(message, DBUS_ERROR_INVALID_ARGS,
"Expected string as first argument"); "Expected string as first argument");
dbus_message_iter_get_basic(&iter, &ipaddr); dbus_message_iter_get_basic(&iter, &ipaddr);
if (inet_pton(AF_INET, ipaddr, &addr.addr.addr4)) if (inet_pton(AF_INET, ipaddr, &addr.addr4))
lease = lease_find_by_addr(addr.addr.addr4); lease = lease_find_by_addr(addr.addr4);
#ifdef HAVE_DHCP6 #ifdef HAVE_DHCP6
else if (inet_pton(AF_INET6, ipaddr, &addr.addr.addr6)) else if (inet_pton(AF_INET6, ipaddr, &addr.addr6))
lease = lease6_find_by_addr(&addr.addr.addr6, 128, 0); lease = lease6_find_by_addr(&addr.addr6, 128, 0);
#endif #endif
else else
return dbus_message_new_error_printf(message, DBUS_ERROR_INVALID_ARGS, return dbus_message_new_error_printf(message, DBUS_ERROR_INVALID_ARGS,
"Invalid IP address '%s'", ipaddr); "Invalid IP address '%s'", ipaddr);
if (lease) if (lease)
{ {
lease_prune(lease, now); lease_prune(lease, now);
lease_update_file(now); lease_update_file(now);
lease_update_dns(0); lease_update_dns(0);
 End of changes. 11 change blocks. 
18 lines changed or deleted 13 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)