]> granicus.if.org Git - strace/blob - tests/ifindex.c
Update copyright headers
[strace] / tests / ifindex.c
1 /*
2  * Proxy wrappers for if_nametoindex.
3  *
4  * Copyright (c) 2017-2018 The strace developers.
5  * All rights reserved.
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  */
9
10 #include "tests.h"
11
12 #ifdef HAVE_IF_INDEXTONAME
13
14 # include <net/if.h>
15
16 unsigned int
17 ifindex_lo(void)
18 {
19         static unsigned int index;
20
21         if (!index)
22                 index = if_nametoindex("lo");
23
24         return index;
25 }
26
27 #else /* !HAVE_IF_INDEXTONAME */
28
29 unsigned int
30 ifindex_lo(void)
31 {
32         return 1;
33 }
34
35 #endif