comerr-behave-like-the-rest-of-the-world-20010918
[openafs.git] / src / WINNT / afsreg / test / getifinfo.c
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  */
9
10 /*
11 /* getifinfo.c retrives the IP configuration information for the machine.
12  * NT stores this information in different places depending on the type
13  * on interface.
14  */
15
16 #include <afs/param.h>
17 #include <afs/stds.h>
18
19 #include <stdlib.h>
20 #include <stddef.h>
21 #include <stdio.h>
22 #include <winsock2.h>
23
24 #include <WINNT/syscfg.h>
25
26
27
28 #define MAXIPADDRS 16
29 int rxi_numNetAddrs;
30 int addrs[MAXIPADDRS];
31 int masks[MAXIPADDRS];
32 int mtus[MAXIPADDRS];
33 int flags[MAXIPADDRS];
34
35 main(int ac, char **av)
36 {
37     int maxAddrs = 0;
38     int i;
39     char addrStr[32];
40     struct in_addr ina;
41
42     rxi_numNetAddrs = MAXIPADDRS;
43
44     if ((maxAddrs = syscfg_GetIFInfo(&rxi_numNetAddrs,
45                                      addrs, masks, mtus, flags)) < 0) {
46         printf("Failed reading interface information\n");
47     } else {
48         printf("Found %d useable addresses, max = %d\n",
49                rxi_numNetAddrs, maxAddrs);
50
51         for (i=0; i<rxi_numNetAddrs; i++) {
52             ina.S_un.S_addr = htonl((unsigned long)addrs[i]);
53             (void) strcpy(addrStr, inet_ntoa(ina));
54             ina.S_un.S_addr = htonl((unsigned long)masks[i]);
55             printf("IP: 0x%x %s  MASK: 0x%x %s\n",
56                    addrs[i], addrStr, masks[i],
57                    inet_ntoa(ina));
58         }
59     }
60     return 0;
61 }