Commit 1cd25e32 authored by jan.koester's avatar jan.koester
Browse files

test

parent a93bcf0c
Loading
Loading
Loading
Loading
+6 −4
Changes for src/ipv6auto.cpp: 6 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@

#include <arpa/inet.h>
#include <net/if.h>
#include <sys/ioctl.h>
#include <sys/random.h>
#include <sys/socket.h>
#include <unistd.h>
@@ -277,11 +278,12 @@ void Ipv6Auto::receiveAdvertisements(Iface &i, double now) {
void Ipv6Auto::dhcpStart(Iface &i, bool stateful, double now) {
    Dhcp6 &d = i.dhcp;
    if (d.state != Dhcp6::Off) dhcpStop(i, true);
    unsigned v[6];
    if (std::sscanf(readLine("/sys/class/net/" + i.name + "/address").c_str(), "%x:%x:%x:%x:%x:%x", &v[0], &v[1], &v[2],
                    &v[3], &v[4], &v[5]) == 6)
        for (int k = 0; k < 6; ++k) i.mac[k] = static_cast<uint8_t>(v[k]);
    int fd = socket(AF_INET6, SOCK_DGRAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0);
    // the MAC address (for the DUID) from the kernel: /sys/class/net shows
    // the interfaces of the namespace sysfs was mounted in, not the caller's
    ifreq ifr{};
    std::strncpy(ifr.ifr_name, i.name.c_str(), IFNAMSIZ - 1);
    if (fd >= 0 && ioctl(fd, SIOCGIFHWADDR, &ifr) == 0) std::memcpy(i.mac, ifr.ifr_hwaddr.sa_data, 6);
    int on = 1;
    sockaddr_in6 a{};
    a.sin6_family = AF_INET6;