Merge pull request #25959 from neo1973/TagLib_deprecation_warnings
[xbmc.git] / lib / libUPnP / Neptune / Source / Apps / NetConfig / NetConfig.cpp
blob072b49b9226907aa01f2753b917646629df60770
1 /*****************************************************************
3 | Neptune Utilities - Network Configuration Dump
5 | (c) 2001-2005 Gilles Boccon-Gibod
6 | Author: Gilles Boccon-Gibod (bok@bok.net)
8 ****************************************************************/
10 /*----------------------------------------------------------------------
11 | includes
12 +---------------------------------------------------------------------*/
13 #include "NptConfig.h"
14 #include "Neptune.h"
15 #include "NptDebug.h"
17 #if defined(NPT_CONFIG_HAVE_STDLIB_H)
18 #include <stdlib.h>
19 #endif
21 #if defined(NPT_CONFIG_HAVE_STRING_H)
22 #include <string.h>
23 #endif
25 #if defined(NPT_CONFIG_HAVE_STDIO_H)
26 #include <stdio.h>
27 #endif
30 /*----------------------------------------------------------------------
31 | globals
32 +---------------------------------------------------------------------*/
34 /*----------------------------------------------------------------------
35 | PrintUsageAndExit
36 +---------------------------------------------------------------------*/
37 static void
38 PrintUsageAndExit(void)
40 fprintf(stderr,
41 "usage: NetConfig\n");
42 exit(1);
45 /*----------------------------------------------------------------------
46 | PrintFlags
47 +---------------------------------------------------------------------*/
48 static void
49 PrintFlags(NPT_Flags flags)
51 if (flags & NPT_NETWORK_INTERFACE_FLAG_LOOPBACK) {
52 printf("LOOPBACK ");
54 if (flags & NPT_NETWORK_INTERFACE_FLAG_PROMISCUOUS) {
55 printf("PROMISCUOUS ");
57 if (flags & NPT_NETWORK_INTERFACE_FLAG_BROADCAST) {
58 printf("BROADCAST ");
60 if (flags & NPT_NETWORK_INTERFACE_FLAG_MULTICAST) {
61 printf("MULTICAST ");
63 if (flags & NPT_NETWORK_INTERFACE_FLAG_POINT_TO_POINT) {
64 printf("POINT-TO-POINT ");
68 /*----------------------------------------------------------------------
69 | main
70 +---------------------------------------------------------------------*/
71 int
72 main(int argc, char**)
74 // check command line
75 if (argc < 1) {
76 PrintUsageAndExit();
79 NPT_List<NPT_NetworkInterface*> interfaces;
80 NPT_Result result = NPT_NetworkInterface::GetNetworkInterfaces(interfaces);
81 if (NPT_FAILED(result)) {
82 printf("GetNetworkInterfaces() failed\n");
83 return 0;
85 NPT_List<NPT_NetworkInterface*>::Iterator iface = interfaces.GetFirstItem();
86 unsigned int index = 0;
87 while (iface) {
88 printf("Interface %d: -------------------------------------\n", index);
89 printf(" name = %s\n", (*iface)->GetName().GetChars());
90 printf(" flags = %x [ ", (*iface)->GetFlags());
91 PrintFlags((*iface)->GetFlags());
92 printf("]\n");
93 printf(" mac = %s (type=%d)\n", (*iface)->GetMacAddress().ToString().GetChars(), (*iface)->GetMacAddress().GetType());
95 // print all addresses
96 NPT_List<NPT_NetworkInterfaceAddress>::Iterator nwifaddr =
97 (*iface)->GetAddresses().GetFirstItem();
98 unsigned int addr_index = 0;
99 while (nwifaddr) {
100 printf(" address %d:\n", addr_index);
101 printf(" primary address = ");
102 printf("%s\n", nwifaddr->GetPrimaryAddress().ToString().GetChars());
103 if ((*iface)->GetFlags() & NPT_NETWORK_INTERFACE_FLAG_BROADCAST) {
104 printf(" broadcast address = ");
105 printf("%s\n", nwifaddr->GetBroadcastAddress().ToString().GetChars());
107 if ((*iface)->GetFlags() & NPT_NETWORK_INTERFACE_FLAG_POINT_TO_POINT) {
108 printf(" destination address = ");
109 printf("%s\n", nwifaddr->GetDestinationAddress().ToString().GetChars());
111 printf(" netmask = ");
112 printf("%s\n", nwifaddr->GetNetMask().ToString().GetChars());
113 ++nwifaddr;
114 ++addr_index;
117 ++iface;
118 ++index;
121 return 0;