xref: /haiku/src/tests/system/network/if_nameindex.c (revision 1e60bdeab63fa7a57bc9a55b032052e95a18bd2c)
1 #include <stdlib.h>
2 #include <stdio.h>
3 #include <net/if.h>
4 
5 
6 int main(int argc, char* argv[])
7 {
8 	struct if_nameindex* ifs;
9 	int i;
10 
11 	ifs = if_nameindex();
12 	if (ifs == NULL) {
13   		perror("if_nameindex");
14   		exit(EXIT_FAILURE);
15 	}
16 
17 	for (i = 0; ifs[i].if_index != 0 || ifs[i].if_name != NULL; i++) {
18 		printf("%d %s\n", ifs[i].if_index, ifs[i].if_name);
19 	}
20 
21 	return EXIT_SUCCESS;
22 }
23