sd-icmp6-nd.c revision ed19c567e5fcdcec1a2b6dbac63787e001ad5d55
/***
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 <string.h>
#include <stdbool.h>
#include "socket-util.h"
#include "async.h"
#include "dhcp6-internal.h"
#include "sd-icmp6-nd.h"
#define ICMP6_MAX_ROUTER_SOLICITATIONS 3
enum icmp6_nd_state {
};
#define IP6_MIN_MTU (unsigned)1280
#define ICMP6_OPT_LEN_UNITS 8
typedef struct ICMP6Prefix ICMP6Prefix;
struct ICMP6Prefix {
unsigned n_ref;
};
struct sd_icmp6_nd {
unsigned n_ref;
enum icmp6_nd_state state;
int event_priority;
int index;
struct ether_addr mac_addr;
int fd;
int nd_sent;
void *userdata;
};
#define log_icmp6_nd(p, fmt, ...) log_internal(LOG_DEBUG, 0, __FILE__, __LINE__, __func__, "ICMPv6 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;
}
ICMP6Prefix *prefix, *p;
if (!nd)
return NULL;
return NULL;
}
return NULL;
}
if (!nd)
return -ENOMEM;
return 0;
}
return -ENOMSG;
return 0;
}
void *userdata) {
ICMP6Prefix *prefix, *p;
if (prefix->timeout_valid != s)
continue;
break;
}
return 0;
}
int r;
if (r < 0)
return r;
if (r < 0)
goto error;
nd->event_priority);
if (r < 0)
goto error;
"icmp6-prefix-timeout");
if (r < 0)
return r;
}
return -EADDRNOTAVAIL;
return 0;
}
addr_len) >= 0) {
return 0;
}
}
return -EADDRNOTAVAIL;
}
}
int r;
if (r < 0)
return r;
return 0;
}
if (!nd->expired_prefix)
return -EADDRNOTAVAIL;
return 0;
}
const struct nd_opt_prefix_info *prefix_opt) {
int r;
char time_string[FORMAT_TIMESPAN_MAX];
return -ENOMSG;
return 0;
if (r < 0 && 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 == -EADDRNOTAVAIL) {
r = icmp6_prefix_new(&prefix);
if (r < 0)
return r;
} else {
}
}
return r;
}
void *opt;
struct nd_opt_hdr *opt_hdr;
if (len < ICMP6_OPT_LEN_UNITS) {
return -ENOMSG;
}
struct nd_opt_mtu *opt_mtu;
struct nd_opt_prefix_info *opt_prefix;
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 icmp6_router_advertisment_recv(sd_event_source *s, int fd, uint32_t revents, void *userdata) {
int r, buflen = 0;
assert(s);
if (r < 0 || buflen <= 0)
if (!ra)
return -ENOMEM;
if (len < 0) {
return 0;
}
return 0;
if (ra->nd_ra_code != 0)
return 0;
if (r < 0) {
strerror(-r));
return 0;
}
}
return 0;
}
struct ether_addr unset = { };
int r;
assert(s);
} else {
if (r < 0)
else {
}
if (r < 0) {
icmp6_nd_notify(nd, r);
return 0;
}
next_timeout, 0,
if (r < 0) {
icmp6_nd_notify(nd, r);
return 0;
}
nd->event_priority);
if (r < 0) {
icmp6_nd_notify(nd, r);
return 0;
}
if (r < 0) {
icmp6_nd_notify(nd, r);
return 0;
}
}
return 0;
}
return 0;
}
int r;
return -EINVAL;
return -EINVAL;
if (r < 0)
return r;
if (r < 0)
goto error;
if (r < 0)
goto error;
if (r < 0)
goto error;
0, 0, icmp6_router_solicitation_timeout, nd);
if (r < 0)
goto error;
if (r < 0)
goto error;
if (r < 0)
else
return r;
}