Initial IBM OpenAFS 1.0 tree
[openafs.git] / src / WINNT / afsreg / test / getifinfo.c
1 /* Copyright (C) 1998 Transarc Corporation.  All rights reserved.
2  *
3  *
4
5 /* getifinfo.c retrives the IP configuration information for the machine.
6  * NT stores this information in different places depending on the type
7  * on interface.
8  */
9
10 #include <afs/param.h>
11 #include <afs/stds.h>
12
13 #include <stdlib.h>
14 #include <stddef.h>
15 #include <stdio.h>
16 #include <winsock2.h>
17
18 #include <WINNT/syscfg.h>
19
20
21
22 #define MAXIPADDRS 16
23 int rxi_numNetAddrs;
24 int addrs[MAXIPADDRS];
25 int masks[MAXIPADDRS];
26 int mtus[MAXIPADDRS];
27 int flags[MAXIPADDRS];
28
29 main(int ac, char **av)
30 {
31     int maxAddrs = 0;
32     int i;
33     char addrStr[32];
34     struct in_addr ina;
35
36     rxi_numNetAddrs = MAXIPADDRS;
37
38     if ((maxAddrs = syscfg_GetIFInfo(&rxi_numNetAddrs,
39                                      addrs, masks, mtus, flags)) < 0) {
40         printf("Failed reading interface information\n");
41     } else {
42         printf("Found %d useable addresses, max = %d\n",
43                rxi_numNetAddrs, maxAddrs);
44
45         for (i=0; i<rxi_numNetAddrs; i++) {
46             ina.S_un.S_addr = htonl((unsigned long)addrs[i]);
47             (void) strcpy(addrStr, inet_ntoa(ina));
48             ina.S_un.S_addr = htonl((unsigned long)masks[i]);
49             printf("IP: 0x%x %s  MASK: 0x%x %s\n",
50                    addrs[i], addrStr, masks[i],
51                    inet_ntoa(ina));
52         }
53     }
54     return 0;
55 }