]>
git.ipfire.org Git - thirdparty/systemd.git/blob - ifconf.h
1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
6 #include <sys/socket.h>
9 This file is part of nss-myhostname.
11 Copyright 2008-2011 Lennart Poettering
13 nss-myhostname is free software; you can redistribute it and/or
14 modify it under the terms of the GNU Lesser General Public License
15 as published by the Free Software Foundation; either version 2.1 of
16 the License, or (at your option) any later version.
18 nss-myhostname is distributed in the hope that it will be useful,
19 but 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
24 License along with nss-myhostname; If not, see
25 <http://www.gnu.org/licenses/>.
29 #include <sys/types.h>
39 #define _public_ __attribute__ ((visibility("default")))
40 #define _hidden_ __attribute__ ((visibility("hidden")))
42 int ifconf_acquire_addresses(struct address
**_list
, unsigned *_n_list
) _hidden_
;
44 static inline size_t PROTO_ADDRESS_SIZE(int proto
) {
45 assert(proto
== AF_INET
|| proto
== AF_INET6
);
47 return proto
== AF_INET6
? 16 : 4;
50 static inline int address_compare(const void *_a
, const void *_b
) {
51 const struct address
*a
= _a
, *b
= _b
;
53 /* Order lowest scope first, IPv4 before IPv6, lowest interface index first */
55 if (a
->scope
< b
->scope
)
57 if (a
->scope
> b
->scope
)
60 if (a
->family
== AF_INET
&& b
->family
== AF_INET6
)
62 if (a
->family
== AF_INET6
&& b
->family
== AF_INET
)
65 if (a
->ifindex
< b
->ifindex
)
67 if (a
->ifindex
> b
->ifindex
)