--- /dev/null
- SET(SRCS src/auth.c
- src/blockdata.c
- src/bpf.c
- src/cache.c
- src/conntrack.c
- src/dbus.c
- src/dhcp6.c
- src/dhcp.c
- src/dhcp-common.c
- src/dnsmasq.c
- src/dnssec.c
- src/domain.c
- src/forward.c
- src/helper.c
- src/inotify.c
- src/ipset.c
- src/lease.c
- src/log.c
- src/loop.c
- src/netlink.c
- src/network.c
- src/option.c
- src/outpacket.c
- src/poll.c
- src/radv.c
- src/rfc1035.c
- src/rfc2131.c
- src/rfc3315.c
- src/slaac.c
- src/tables.c
- src/tftp.c
- src/util.c
- )
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(dnsmasq C)
+
++SET(SRCS
++ src/arp.c
++ src/auth.c
++ src/blockdata.c
++ src/bpf.c
++ src/cache.c
++ src/conntrack.c
++ src/crypto.c
++ src/dbus.c
++ src/dhcp6.c
++ src/dhcp.c
++ src/dhcp-common.c
++ src/dnsmasq.c
++ src/dnssec.c
++ src/domain.c
++ src/edns0.c
++ src/forward.c
++ src/helper.c
++ src/inotify.c
++ src/ipset.c
++ src/lease.c
++ src/log.c
++ src/loop.c
++ src/netlink.c
++ src/network.c
++ src/option.c
++ src/outpacket.c
++ src/poll.c
++ src/radv.c
++ src/rfc1035.c
++ src/rfc2131.c
++ src/rfc3315.c
++ src/rrfilter.c
++ src/slaac.c
++ src/tables.c
++ src/tftp.c
++ src/util.c
++)
+
+SET(PACKAGE ${PROJECT_NAME})
+SET(PKGNAME ${PACKAGE})
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+SET(BINDIR "${PREFIX}/bin")
+
+IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+ SET(CMAKE_BUILD_TYPE "Release")
+ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+MESSAGE("Build type: ${CMAKE_BUILD_TYPE}")
+
+#INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(pkgs REQUIRED dbus-1)
+
+FOREACH(flag ${pkgs_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall -fPIE")
+SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
+SET(CMAKE_C_FLAGS_RELEASE "-O2")
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie")
+
+ADD_DEFINITIONS("-DPACKAGE=\"${PACKAGE}\"")
+ADD_DEFINITIONS("-DPACKAGE_NAME=\"${PKGNAME}\"")
+ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"")
+
+FIND_PROGRAM(UNAME NAMES uname)
+EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH")
+#IF("${ARCH}" STREQUAL "arm")
+# ADD_DEFINITIONS("-D_MMICHECK_ARM_CODE_")
+#ENDIF("${ARCH}" STREQUAL "arm")
+
+ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS})
+
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${BINDIR})
/* Mark these so we only match each at most once, to avoid tangled linked lists */
for (vendor = daemon->dhcp_vendors; vendor; vendor = vendor->next)
vendor->netid.next = &vendor->netid;
-
+
- save_counter(0);
+ reset_counter();
state.context = context;
state.interface = interface;
state.iface_name = iface_name;
void *opt;
struct dhcp_vendor *vendor;
- /* if not an encaplsulated relayed message, just do the stuff */
+ /* if not an encapsulated relayed message, just do the stuff */
if (msg_type != DHCP6RELAYFORW)
{
- /* if link_address != NULL if points to the link address field of the
+ /* if link_address != NULL if points to the link address field of the
innermost nested RELAYFORW message, which is where we find the
address of the network on which we can allocate an address.
- Recalculate the available contexts using that information.
+ Recalculate the available contexts using that information.
- link_address == NULL means there's no relay in use, so we try and find the client's
+ link_address == NULL means there's no relay in use, so we try and find the client's
MAC address from the local ND cache. */
-
+
if (!state->link_address)
- get_client_mac(client_addr, state->interface, state->mac, &state->mac_len, &state->mac_type);
+ get_client_mac(client_addr, state->interface, state->mac, &state->mac_len, &state->mac_type, now);
else
{
struct dhcp_context *c;
state->mac_len = opt6_len(opt) - 2;
memcpy(&state->mac[0], opt6_ptr(opt, 2), state->mac_len);
}
-
+
for (opt = opts; opt; opt = opt6_next(opt, end))
{
- if (opt6_ptr(opt, 0) + opt6_len(opt) >= end) {
- if (opt6_ptr(opt, 0) + opt6_len(opt) > end)
++ if (opt6_ptr(opt, 0) + opt6_len(opt) > end)
return 0;
- }
-
++
int o = new_opt6(opt6_type(opt));
if (opt6_type(opt) == OPTION6_RELAY_MSG)
{
if (option_bool(OPT_LOG_OPTS) && (opt = opt6_find(state->packet_options, state->end, OPTION6_VENDOR_CLASS, 4)))
my_syslog(MS_DHCP | LOG_INFO, _("%u vendor class: %u"), state->xid, opt6_uint(opt, 0, 4));
-
+
/* dhcp-match. If we have hex-and-wildcards, look for a left-anchored match.
- Otherwise assume the option is an array, and look for a matching element.
- If no data given, existence of the option is enough. This code handles
+ Otherwise assume the option is an array, and look for a matching element.
- If no data given, existance of the option is enough. This code handles
++ If no data given, existence of the option is enough. This code handles
V-I opts too. */
for (opt_cfg = daemon->dhcp_match6; opt_cfg; opt_cfg = opt_cfg->next)
{
if (have_config(config, CONFIG_DISABLE))
ignore = 1;
}
-
+ else if (state->clid &&
+ find_config(daemon->dhcp_conf, NULL, state->clid, state->clid_len, state->mac, state->mac_len, state->mac_type, NULL))
+ {
+ known_id.net = "known-othernet";
+ known_id.next = state->tags;
+ state->tags = &known_id;
+ }
+
#ifdef OPTION6_PREFIX_CLASS
/* OPTION_PREFIX_CLASS in ORO, send addresses in all prefix classes */
if (daemon->prefix_classes && (msg_type == DHCP6SOLICIT || msg_type == DHCP6REQUEST))
if (!ia_option)
{
- /* If we get a request with a IA_*A without addresses, treat it exactly like
+ /* If we get a request with an IA_*A without addresses, treat it exactly like
a SOLICT with rapid commit set. */
save_counter(start);
- goto request_no_address;
+ goto request_no_address;
}
o = build_ia(state, &t1cntr);
put_opt6_short(DHCP6NOBINDING);
put_opt6_string(_("no binding found"));
end_opt6(o1);
-
+
end_opt6(o);
}
-
+
}
- /* We must anwser with 'success' in global section anyway */
+ /* We must answer with 'success' in global section anyway */
o1 = new_opt6(OPTION6_STATUS_CODE);
put_opt6_short(DHCP6SUCCESS);
put_opt6_string(_("success"));
if (i >= opt6_len(oro) - 1)
continue;
}
-
+
if (opt_cfg->opt == OPTION6_REFRESH_TIME)
done_refresh = 1;
-
+
+ if (opt_cfg->opt == OPTION6_DNS_SERVER)
+ done_dns = 1;
-
++
if (opt_cfg->flags & DHOPT_ADDR6)
{
int len, j;
struct in6_addr *a;
-
- for (a = (struct in6_addr *)opt_cfg->val, len = opt_cfg->len, j = 0;
+
- if (opt_cfg->opt == OPTION6_DNS_SERVER)
- done_dns = 1;
-
+ for (a = (struct in6_addr *)opt_cfg->val, len = opt_cfg->len, j = 0;
j < opt_cfg->len; j += IN6ADDRSZ, a++)
if ((IN6_IS_ADDR_ULA_ZERO(a) && IN6_IS_ADDR_UNSPECIFIED(state->ula_addr)) ||
(IN6_IS_ADDR_LINK_LOCAL_ZERO(a) && IN6_IS_ADDR_UNSPECIFIED(state->ll_addr)))
{
struct dhcp_context *c;
unsigned int lease_time = 0xffffffff;
-
+
/* Find the smallest lease tie of all contexts,
- subjext to the RFC-4242 stipulation that this must not
- subject to the RFC-4242 stipulation that this must not
++ subject to the RFC-4242 stipulation that this must not
be less than 600. */
for (c = state->context; c; c = c->next)
if (c->lease_time < lease_time)
unsigned int ret = 0;
int i;
unsigned char *p = opt6_ptr(opt, offset);
-
+
for (i = 0; i < size; i++)
ret = (ret << 8) | *p++;
-
+
return ret;
-}
+}
- void relay_upstream6(struct dhcp_relay *relay, ssize_t sz, struct in6_addr *peer_address, u32 scope_id)
-void relay_upstream6(struct dhcp_relay *relay, ssize_t sz,
++void relay_upstream6(struct dhcp_relay *relay, ssize_t sz,
+ struct in6_addr *peer_address, u32 scope_id, time_t now)
{
/* ->local is same value for all relays on ->current chain */
-
+
struct all_addr from;
unsigned char *header;
unsigned char *inbuff = daemon->dhcp_packet.iov_base;
setsockopt(daemon->dhcp6fd, IPPROTO_IPV6, IPV6_MULTICAST_IF, &multicast_iface, sizeof(multicast_iface)) == -1)
my_syslog(MS_DHCP | LOG_ERR, _("Cannot multicast to DHCPv6 server without correct interface"));
}
-
+
- send_from(daemon->dhcp6fd, 0, daemon->outpacket.iov_base, save_counter(0), &to, &from, 0);
+ send_from(daemon->dhcp6fd, 0, daemon->outpacket.iov_base, save_counter(-1), &to, &from, 0);
-
+
if (option_bool(OPT_LOG_OPTS))
{
inet_ntop(AF_INET6, &relay->local, daemon->addrbuff, ADDRSTRLEN);
if (IN6_ARE_ADDR_EQUAL(&link, &relay->local.addr.addr6) &&
(!relay->interface || wildcard_match(relay->interface, arrival_interface)))
break;
-
+
- save_counter(0);
+ reset_counter();
if (relay)
{