/***
This file is part of systemd.
Copyright (C) 2014 Intel Corporation. All rights reserved.
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <stdbool.h>
#include <string.h>
#include "sd-ndisc.h"
#include "alloc-util.h"
#include "async.h"
#include "icmp6-util.h"
#include "in-addr-util.h"
#include "list.h"
#include "socket-util.h"
#include "string-util.h"
enum NDiscState {
};
struct NDiscPrefix {
unsigned n_ref;
};
struct sd_ndisc {
unsigned n_ref;
int event_priority;
int index;
int fd;
int nd_sent;
void *userdata;
};
#define log_ndisc(p, fmt, ...) log_internal(LOG_DEBUG, 0, __FILE__, __LINE__, __func__, "NDisc CLIENT: " fmt, ##__VA_ARGS__)
if (!prefix)
return NULL;
return NULL;
return NULL;
}
if (!prefix)
return -ENOMEM;
return 0;
}
void *userdata) {
return 0;
}
return 0;
}
if (mac_addr)
else
return 0;
}
int r;
if (event)
else {
if (r < 0)
return 0;
}
return 0;
}
return 0;
}
}
if (!nd)
return NULL;
return nd;
}
return 0;
}
if (!nd)
return NULL;
return NULL;
ndisc_init(nd);
return NULL;
}
if (!nd)
return -ENOMEM;
return 0;
}
return -ENOMSG;
return 0;
}
return -EADDRNOTAVAIL;
return 0;
}
int r;
if (r < 0)
return r;
continue;
}
return 0;
}
}
return -EADDRNOTAVAIL;
}
const struct nd_opt_prefix_info *prefix_opt) {
int r;
return -ENOMSG;
return 0;
if (in_addr_is_link_local(AF_INET6, (const union in_addr_union *) &prefix_opt->nd_opt_pi_prefix) > 0)
return 0;
if (lifetime_valid < lifetime_preferred)
return 0;
if (r < 0) {
if (r != -EADDRNOTAVAIL)
return r;
/* if router advertisment prefix valid timeout is zero, the timeout
callback will be called immediately to clean up the prefix */
if (r < 0)
return r;
} else {
}
}
if (r < 0)
return r;
return 0;
}
void *opt;
if (len < NDISC_OPT_LEN_UNITS) {
return -ENOMSG;
}
if (opt_hdr->nd_opt_len == 0)
return -ENOMSG;
switch (opt_hdr->nd_opt_type) {
case ND_OPT_MTU:
}
break;
opt_prefix = opt;
break;
}
}
if (len > 0)
return 0;
}
static int ndisc_router_advertisment_recv(sd_event_source *s, int fd, uint32_t revents, void *userdata) {
union {
} control = {};
.msg_namelen = sizeof(sa),
.msg_iovlen = 1,
.msg_control = &control,
.msg_controllen = sizeof(control),
};
unsigned lifetime;
assert(s);
if (r < 0)
return -errno;
else if (buflen < 0)
/* This really should not happen */
return -EIO;
if (!ra)
return -ENOMEM;
if (len < 0) {
return 0;
return -errno;
return 0;
} else if (msg.msg_namelen == 0)
log_ndisc(nd, "Received invalid source address size from ICMPv6 socket: %zu bytes", (size_t)msg.msg_namelen);
return 0;
} else
if (hops != 255) {
return 0;
}
break;
}
}
return 0;
}
return 0;
if (ra->nd_ra_code != 0)
return 0;
switch (pref) {
case ND_RA_FLAG_PREF_LOW:
case ND_RA_FLAG_PREF_HIGH:
break;
default:
break;
}
lifetime);
if (r < 0) {
return 0;
}
if (nd->router_callback)
return 0;
}
int r;
assert(s);
} else {
if (r < 0)
else {
}
next_timeout, 0,
if (r < 0) {
/* we cannot continue if we are unable to rearm the timer */
return 0;
}
if (r < 0)
return 0;
if (r < 0)
return 0;
}
return 0;
}
ndisc_init(nd);
return 0;
}
int r;
return -EBUSY;
return -EINVAL;
if (r < 0)
return r;
if (r < 0)
goto error;
if (r < 0)
goto error;
if (r < 0)
goto error;
0, 0, ndisc_router_solicitation_timeout, nd);
if (r < 0)
goto error;
if (r < 0)
goto error;
if (r < 0)
ndisc_init(nd);
else
return r;
}