network-internal.c revision 09bee74d7a5f266b175baa19892fa84a9da51d7f
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright (C) 2013 Tom Gundersen <teg@jklm.no>
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 <fnmatch.h>
#include "strv.h"
#include "siphash24.h"
#include "libudev-private.h"
#include "network-internal.h"
#include "log.h"
#include "utf8.h"
#include "util.h"
#include "conf-parser.h"
#include "condition.h"
int r;
uint8_t *v;
/* fetch some persistent data unique (on this machine) to this device */
FOREACH_STRING(field, "ID_NET_NAME_ONBOARD", "ID_NET_NAME_SLOT", "ID_NET_NAME_PATH", "ID_NET_NAME_MAC") {
if (name)
break;
}
if (!name)
return -ENOENT;
sz = sizeof(sd_id128_t) + l;
/* fetch some persistent data unique to this machine */
r = sd_id128_get_machine((sd_id128_t*) v);
if (r < 0)
return r;
/* Let's hash the machine ID plus the device name. We
* use a fixed, but originally randomly created hash
* key here. */
return 0;
}
const char *match_path,
const char *match_driver,
const char *match_type,
const char *match_name,
const struct ether_addr *dev_mac,
const char *dev_path,
const char *dev_parent_driver,
const char *dev_driver,
const char *dev_type,
const char *dev_name) {
return 0;
return 0;
return 0;
return 0;
return 0;
return 0;
if (match_driver) {
return 0;
return 0;
}
return 0;
return 0;
return 1;
}
}
int config_parse_net_condition(const char *unit,
const char *filename,
unsigned line,
const char *section,
unsigned section_line,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
bool negate;
Condition *c;
_cleanup_free_ char *s = NULL;
if (negate)
rvalue++;
if (!s)
return log_oom();
if (!c)
return log_oom();
if (*ret)
*ret = c;
return 0;
}
int config_parse_ifname(const char *unit,
const char *filename,
unsigned line,
const char *section,
unsigned section_line,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
char **s = data;
char *n;
if (!n)
return log_oom();
"Interface name is not ASCII clean or is too long, ignoring assignment: %s", rvalue);
free(n);
return 0;
}
free(*s);
if (*n)
*s = n;
else {
free(n);
*s = NULL;
}
return 0;
}
int config_parse_ifalias(const char *unit,
const char *filename,
unsigned line,
const char *section,
unsigned section_line,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
char **s = data;
char *n;
if (!n)
return log_oom();
"Interface alias is not ASCII clean or is too long, ignoring assignment: %s", rvalue);
free(n);
return 0;
}
free(*s);
if (*n)
*s = n;
else {
free(n);
*s = NULL;
}
return 0;
}
int config_parse_hwaddr(const char *unit,
const char *filename,
unsigned line,
const char *section,
unsigned section_line,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
struct ether_addr *n;
int r;
if (!n)
return log_oom();
&n->ether_addr_octet[0],
&n->ether_addr_octet[1],
&n->ether_addr_octet[2],
&n->ether_addr_octet[3],
&n->ether_addr_octet[4],
&n->ether_addr_octet[5]);
if (r != 6) {
"Not a valid MAC address, ignoring assignment: %s", rvalue);
free(n);
return 0;
}
*hwaddr = n;
return 0;
}
int r;
/* IPv4 */
if (r > 0) {
/* succsefully parsed IPv4 address */
return -EINVAL;
} else if (r < 0)
return -errno;
else {
/* not an IPv4 address, so let's try IPv6 */
if (r > 0) {
/* successfully parsed IPv6 address */
return -EINVAL;
} else if (r < 0)
return -errno;
else
return -EINVAL;
}
return 0;
}
int r;
if (r < 0)
return r;
if (!modlist) {
return -ENOENT;
}
kmod_list_foreach(l, modlist) {
if (r == 0)
else {
strerror(-r));
}
}
return r;
}
unsigned i;
assert(f);
for (i = 0; i < size; i++)
fputs("\n", f);
}
struct in_addr *new_addresses;
int r;
if (!new_addresses)
return -ENOMEM;
else
if (!addr_str)
return -ENOMEM;
if (r <= 0)
continue;
size ++;
}
return 0;
}
struct in6_addr *new_addresses;
int r;
if (!new_addresses)
return -ENOMEM;
else
if (!addr_str)
return -ENOMEM;
if (r <= 0)
continue;
size++;
}
return 0;
}