Attention is currently required from: Arne Schwabe, Răzvan Cojocaru.

Hello Arne Schwabe, Răzvan Cojocaru,

I'd like you to reexamine a change. Please visit

    https://gerrit.openvpn.net/c/openvpn/+/2342?usp=email

to look at the new patch set (#2).

The following approvals got outdated and were removed:
Code-Review-1 by Răzvan Cojocaru


Change subject: Windows: Switch all uses of address family to ADDRESS_FAMILY 
type
......................................................................

Windows: Switch all uses of address family to ADDRESS_FAMILY type

Previously we had conversion errors between short
and unsigned short.

Also remove useless SetNameServers wrapper. Wrapping
only a name is really not that useful.

Add a definition for ADDRESS_FAMILY for cppcheck.
The built-in windows platform definition doesn't
cover it.

Change-Id: I225c21dbd843601b697fe712b5b66c2a4f5c2ac2
Signed-off-by: Frank Lichtenheld <[email protected]>
---
M dev-tools/openvpn-cppcheck-windows.cfg
M include/openvpn-msg.h
M src/openvpn/tun.c
M src/openvpnserv/interactive.c
4 files changed, 22 insertions(+), 36 deletions(-)


  git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/42/2342/2

diff --git a/dev-tools/openvpn-cppcheck-windows.cfg 
b/dev-tools/openvpn-cppcheck-windows.cfg
index dca2b07..19d32a1 100644
--- a/dev-tools/openvpn-cppcheck-windows.cfg
+++ b/dev-tools/openvpn-cppcheck-windows.cfg
@@ -8,6 +8,7 @@
       <formatstr />
     </arg>
   </function>
+  <podtype name="ADDRESS_FAMILY" sign="u" size="2" />
   <!-- MinGW uses GCC, so we need to handle GCC builtins. gnu.cfg has these,
        but we do not load it for Windows. Without this cppcheck does not
        understand our likely()/unlikely() macros. -->
diff --git a/include/openvpn-msg.h b/include/openvpn-msg.h
index ca3267e8..dd20f7b 100644
--- a/include/openvpn-msg.h
+++ b/include/openvpn-msg.h
@@ -80,7 +80,7 @@
 typedef struct
 {
     message_header_t header;
-    short family;
+    ADDRESS_FAMILY family;
     inet_address_t address;
     int prefix_len;
     interface_t iface;
@@ -89,7 +89,7 @@
 typedef struct
 {
     message_header_t header;
-    short family;
+    ADDRESS_FAMILY family;
     inet_address_t prefix;
     int prefix_len;
     inet_address_t gateway;
@@ -102,7 +102,7 @@
     message_header_t header;
     interface_t iface;
     char domains[512];
-    short family;
+    ADDRESS_FAMILY family;
     unsigned int addr_len;
     inet_address_t addr[4]; /* support up to 4 dns addresses */
 } dns_cfg_message_t;
@@ -150,7 +150,7 @@
 typedef struct
 {
     message_header_t header;
-    short family;
+    ADDRESS_FAMILY family;
     interface_t iface;
 } flush_neighbors_message_t;

@@ -177,7 +177,7 @@
 {
     message_header_t header;
     interface_t iface;
-    short family;
+    ADDRESS_FAMILY family;
     int mtu;
 } set_mtu_message_t;

diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c
index fe1af45..65edf73 100644
--- a/src/openvpn/tun.c
+++ b/src/openvpn/tun.c
@@ -101,7 +101,7 @@
 static void netsh_ifconfig(const struct tuntap_options *to, DWORD 
adapter_index, const in_addr_t ip,
                            const in_addr_t netmask, const unsigned int flags);

-static void windows_set_mtu(const int iface_index, const short family, const 
int mtu);
+static void windows_set_mtu(const int iface_index, const ADDRESS_FAMILY 
family, const int mtu);

 static void netsh_set_dns6_servers(const struct in6_addr *addr_list, const 
unsigned int addr_len,
                                    DWORD adapter_index);
@@ -118,7 +118,7 @@
 #endif

 static bool
-do_address_service(const bool add, const short family, const struct tuntap *tt)
+do_address_service(const bool add, const ADDRESS_FAMILY family, const struct 
tuntap *tt)
 {
     bool ret = false;
     ack_message_t ack;
@@ -241,7 +241,7 @@
 }

 static void
-do_dns_service(bool add, const short family, const struct tuntap *tt)
+do_dns_service(bool add, const ADDRESS_FAMILY family, const struct tuntap *tt)
 {
     ack_message_t ack;
     struct gc_arena gc = gc_new();
@@ -366,7 +366,7 @@
 }

 static bool
-do_set_mtu_service(const struct tuntap *tt, const short family, const int mtu)
+do_set_mtu_service(const struct tuntap *tt, const ADDRESS_FAMILY family, const 
int mtu)
 {
     bool ret = false;
     ack_message_t ack;
@@ -5320,7 +5320,7 @@
 }

 static void
-windows_set_mtu(const int iface_index, const short family, const int mtu)
+windows_set_mtu(const int iface_index, const ADDRESS_FAMILY family, const int 
mtu)
 {
     DWORD err = 0;
     MIB_IPINTERFACE_ROW ipiface;
diff --git a/src/openvpnserv/interactive.c b/src/openvpnserv/interactive.c
index ad0fda2..fb7463a 100644
--- a/src/openvpnserv/interactive.c
+++ b/src/openvpnserv/interactive.c
@@ -536,7 +536,7 @@
 #endif

 static SOCKADDR_INET
-sockaddr_inet(short family, const inet_address_t *addr)
+sockaddr_inet(ADDRESS_FAMILY family, const inet_address_t *addr)
 {
     SOCKADDR_INET sa_inet;
     ZeroMemory(&sa_inet, sizeof(sa_inet));
@@ -1865,7 +1865,7 @@
  * @return BOOL to indicate success or failure
  */
 static BOOL
-GetInterfacesKey(short family, PHKEY key)
+GetInterfacesKey(ADDRESS_FAMILY family, PHKEY key)
 {
     PCSTR itfs_key = family == AF_INET6
                          ? 
"SYSTEM\\CurrentControlSet\\Services\\Tcpip6\\Parameters\\Interfaces"
@@ -1875,7 +1875,7 @@
     if (err)
     {
         *key = INVALID_HANDLE_VALUE;
-        MsgToEventLog(M_SYSERR, L"%S: could not open interfaces registry key 
for family %d (%lu)",
+        MsgToEventLog(M_SYSERR, L"%S: could not open interfaces registry key 
for family %hu (%lu)",
                       __func__, family, err);
     }
 
@@ -1892,7 +1892,7 @@
  * @return DWORD NO_ERROR on success, a Windows error code otherwise
  */
 static DWORD
-SetNameServersValue(PCWSTR itf_id, short family, PCSTR value)
+SetNameServersValue(PCWSTR itf_id, ADDRESS_FAMILY family, PCSTR value)
 {
     DWORD err;

@@ -1906,7 +1906,7 @@
     err = RegOpenKeyExW(itfs, itf_id, 0, KEY_ALL_ACCESS, &itf);
     if (err)
     {
-        MsgToEventLog(M_SYSERR, L"%S: could not open interface key for %s 
family %d (%lu)",
+        MsgToEventLog(M_SYSERR, L"%S: could not open interface key for %s 
family %hu (%lu)",
                       __func__, itf_id, family, err);
         goto out;
     }
@@ -1914,7 +1914,7 @@
     err = RegSetValueExA(itf, "NameServer", 0, REG_SZ, (PBYTE)value, 
(DWORD)strlen(value) + 1);
     if (err)
     {
-        MsgToEventLog(M_SYSERR, L"%S: could not set name servers '%S' for %s 
family %d (%lu)",
+        MsgToEventLog(M_SYSERR, L"%S: could not set name servers '%S' for %s 
family %hu (%lu)",
                       __func__, value, itf_id, family, err);
     }

@@ -1931,21 +1931,6 @@
 }

 /**
- * Set the DNS name servers in a registry interface configuration
- *
- * @param itf_id    the interface id to set the servers for
- * @param family    internet address family to set the servers for
- * @param addrs     comma separated list of name server addresses
- *
- * @return DWORD NO_ERROR on success, a Windows error code otherwise
- */
-static DWORD
-SetNameServers(PCWSTR itf_id, short family, PCSTR addrs)
-{
-    return SetNameServersValue(itf_id, family, addrs);
-}
-
-/**
  * Delete all DNS name servers from a registry interface configuration
  *
  * @param itf_id    the interface id to clear the servers for
@@ -1954,7 +1939,7 @@
  * @return DWORD NO_ERROR on success, a Windows error code otherwise
  */
 static DWORD
-ResetNameServers(PCWSTR itf_id, short family)
+ResetNameServers(PCWSTR itf_id, ADDRESS_FAMILY family)
 {
     return SetNameServersValue(itf_id, family, "");
 }
@@ -2042,7 +2027,7 @@
             offset = strlen(addrs);
         }

-        err = SetNameServers(iid, msg->family, addrs);
+        err = SetNameServersValue(iid, msg->family, addrs);
         if (err)
         {
             return err;
@@ -2103,10 +2088,10 @@
 static LSTATUS
 SetNameServerAddresses(PWSTR itf_id, const nrpt_address_t *addresses)
 {
-    const short families[] = { AF_INET, AF_INET6 };
+    const ADDRESS_FAMILY families[] = { AF_INET, AF_INET6 };
     for (size_t i = 0; i < _countof(families); i++)
     {
-        short family = families[i];
+        ADDRESS_FAMILY family = families[i];

         /* Create a comma sparated list of addresses of this family */
         size_t offset = 0;
@@ -2134,7 +2119,7 @@
         }

         /* Set name server addresses */
-        LSTATUS err = SetNameServers(itf_id, family, addr_list);
+        LSTATUS err = SetNameServersValue(itf_id, family, addr_list);
         if (err)
         {
             return err;

--
To view, visit https://gerrit.openvpn.net/c/openvpn/+/2342?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I225c21dbd843601b697fe712b5b66c2a4f5c2ac2
Gerrit-Change-Number: 2342
Gerrit-PatchSet: 2
Gerrit-Owner: Frank Lichtenheld <[email protected]>
Gerrit-Reviewer: Arne Schwabe <[email protected]>
Gerrit-Reviewer: Răzvan Cojocaru <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: Răzvan Cojocaru <[email protected]>
Gerrit-Attention: Arne Schwabe <[email protected]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

Reply via email to