Andrew Nguyen : ipconfig: Implement gateway address output.

Alexandre Julliard julliard at winehq.org
Mon Sep 27 11:29:38 CDT 2010


Module: wine
Branch: master
Commit: 11d332c37c5630d5c144090e0a6fa9ce753171c8
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=11d332c37c5630d5c144090e0a6fa9ce753171c8

Author: Andrew Nguyen <anguyen at codeweavers.com>
Date:   Mon Sep 27 04:30:59 2010 -0500

ipconfig: Implement gateway address output.

---

 programs/ipconfig/En.rc      |    1 +
 programs/ipconfig/ipconfig.c |   44 ++++++++++++++++++++++++++++++++++++++++-
 programs/ipconfig/ipconfig.h |    1 +
 3 files changed, 44 insertions(+), 2 deletions(-)

diff --git a/programs/ipconfig/En.rc b/programs/ipconfig/En.rc
index 6606fe4..97fb223 100644
--- a/programs/ipconfig/En.rc
+++ b/programs/ipconfig/En.rc
@@ -44,4 +44,5 @@ STRINGTABLE
     STRING_DHCP_ENABLED, "DHCP enabled"
     STRING_YES, "Yes"
     STRING_NO, "No"
+    STRING_DEFAULT_GATEWAY, "Default gateway"
 }
diff --git a/programs/ipconfig/ipconfig.c b/programs/ipconfig/ipconfig.c
index bf186c1..e76b549 100644
--- a/programs/ipconfig/ipconfig.c
+++ b/programs/ipconfig/ipconfig.c
@@ -130,6 +130,17 @@ static void print_field(int msg, const WCHAR *value)
     ipconfig_printfW(formatW, field, value);
 }
 
+static void print_value(const WCHAR *value)
+{
+    static const WCHAR formatW[] = {' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',
+                                    ' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',
+                                    ' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',
+                                    ' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',
+                                    '%','s','\n',0};
+
+    ipconfig_printfW(formatW, value);
+}
+
 static BOOL socket_address_to_string(WCHAR *buf, DWORD len, SOCKET_ADDRESS *addr)
 {
     return WSAAddressToStringW(addr->lpSockaddr,
@@ -155,8 +166,10 @@ static void print_basic_information(void)
             for (p = adapters; p; p = p->Next)
             {
                 static const WCHAR newlineW[] = {'\n',0};
+                static const WCHAR emptyW[] = {0};
 
                 IP_ADAPTER_UNICAST_ADDRESS *addr;
+                IP_ADAPTER_GATEWAY_ADDRESS_LH *gateway;
                 WCHAR addr_buf[54];
 
                 ipconfig_message_printfW(STRING_ADAPTER_FRIENDLY, iftype_to_string(p->IfType), p->FriendlyName);
@@ -170,7 +183,20 @@ static void print_basic_information(void)
                     /* FIXME: Output corresponding subnet mask. */
                 }
 
-                /* FIXME: Output default gateway address. */
+                if (p->FirstGatewayAddress)
+                {
+                    if (socket_address_to_string(addr_buf, sizeof(addr_buf)/sizeof(WCHAR), &p->FirstGatewayAddress->Address))
+                        print_field(STRING_DEFAULT_GATEWAY, addr_buf);
+
+                    for (gateway = p->FirstGatewayAddress->Next; gateway; gateway = gateway->Next)
+                    {
+                        if (socket_address_to_string(addr_buf, sizeof(addr_buf)/sizeof(WCHAR), &gateway->Address))
+                            print_value(addr_buf);
+                    }
+                }
+                else
+                    print_field(STRING_DEFAULT_GATEWAY, emptyW);
+
                 ipconfig_printfW(newlineW);
             }
         }
@@ -245,6 +271,7 @@ static const WCHAR *boolean_to_string(int value)
 static void print_full_information(void)
 {
     static const WCHAR newlineW[] = {'\n',0};
+    static const WCHAR emptyW[] = {0};
 
     FIXED_INFO *info;
     IP_ADAPTER_ADDRESSES *adapters;
@@ -290,6 +317,7 @@ static void print_full_information(void)
             {
                 IP_ADAPTER_UNICAST_ADDRESS *addr;
                 WCHAR physaddr_buf[3 * MAX_ADAPTER_ADDRESS_LENGTH];
+                IP_ADAPTER_GATEWAY_ADDRESS_LH *gateway;
                 WCHAR addr_buf[54];
 
                 ipconfig_message_printfW(STRING_ADAPTER_FRIENDLY, iftype_to_string(p->IfType), p->FriendlyName);
@@ -308,7 +336,19 @@ static void print_full_information(void)
                     /* FIXME: Output corresponding subnet mask. */
                 }
 
-                /* FIXME: Output default gateway address. */
+                if (p->FirstGatewayAddress)
+                {
+                    if (socket_address_to_string(addr_buf, sizeof(addr_buf)/sizeof(WCHAR), &p->FirstGatewayAddress->Address))
+                        print_field(STRING_DEFAULT_GATEWAY, addr_buf);
+
+                    for (gateway = p->FirstGatewayAddress->Next; gateway; gateway = gateway->Next)
+                    {
+                        if (socket_address_to_string(addr_buf, sizeof(addr_buf)/sizeof(WCHAR), &gateway->Address))
+                            print_value(addr_buf);
+                    }
+                }
+                else
+                    print_field(STRING_DEFAULT_GATEWAY, emptyW);
 
                 ipconfig_printfW(newlineW);
             }
diff --git a/programs/ipconfig/ipconfig.h b/programs/ipconfig/ipconfig.h
index d209006..593a43c 100644
--- a/programs/ipconfig/ipconfig.h
+++ b/programs/ipconfig/ipconfig.h
@@ -40,3 +40,4 @@
 #define STRING_DHCP_ENABLED     117
 #define STRING_YES              118
 #define STRING_NO               119
+#define STRING_DEFAULT_GATEWAY  120




More information about the wine-cvs mailing list