1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
6 #include <sys/socket.h>
9 This file is part of systemd.
11 Copyright 2008-2011 Lennart Poettering
13 systemd is free software; you can redistribute it and/or modify it
14 under the terms of the GNU Lesser General Public License as published by
15 the Free Software Foundation; either version 2.1 of the License, or
16 (at your option) any later version.
18 systemd is distributed in the hope that it will be useful, but
19 WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 Lesser General Public License for more details.
23 You should have received a copy of the GNU Lesser General Public License
24 along with systemd; If not, see <http://www.gnu.org/licenses/>.
28 #include <sys/types.h>
38 #define _public_ __attribute__ ((visibility("default")))
39 #define _hidden_ __attribute__ ((visibility("hidden")))
41 int ifconf_acquire_addresses(struct address **_list, unsigned *_n_list) _hidden_;
43 static inline size_t PROTO_ADDRESS_SIZE(int proto) {
44 assert(proto == AF_INET || proto == AF_INET6);
46 return proto == AF_INET6 ? 16 : 4;
49 static inline int address_compare(const void *_a, const void *_b) {
50 const struct address *a = _a, *b = _b;
52 /* Order lowest scope first, IPv4 before IPv6, lowest interface index first */
54 if (a->scope < b->scope)
56 if (a->scope > b->scope)
59 if (a->family == AF_INET && b->family == AF_INET6)
61 if (a->family == AF_INET6 && b->family == AF_INET)
64 if (a->ifindex < b->ifindex)
66 if (a->ifindex > b->ifindex)