From: "flichtenheld (Code Review)" Date: Thu, 12 Feb 2026 13:51:49 +0000 References: Reply-To: frank@...2641..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net Message-ID: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="uD0H/IEfBUY="; charset=UTF-8 Subject: [Openvpn-devel] [M] Change in openvpn[master]: Win32: Make interface index DWORD consistently List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos Cc: openvpn-devel --uD0H/IEfBUY= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: plaisthos. Hello plaisthos, I'd like you to do a code review. Please visit http://gerrit.openvpn.net/c/openvpn/+/1519?usp=3Demail to review the following change. Change subject: Win32: Make interface index DWORD consistently ...................................................................... Win32: Make interface index DWORD consistently Previously we had a weird mix of int and DWORD. But the Win32 APIs seem to be consistent (they have different names, but NET_IFINDEX is ULONG is DWORD). So use that. Change-Id: I38bb2d1fa66c543e8bcf47b7d77b6154d1895f81 Signed-off-by: Frank Lichtenheld --- M include/openvpn-msg.h M src/openvpn/dns.c M src/openvpn/route.c M src/openvpn/tun.c M src/openvpn/tun.h M src/openvpn/win32.c M src/openvpnserv/interactive.c 7 files changed, 48 insertions(+), 57 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/19/1519/1 diff --git a/include/openvpn-msg.h b/include/openvpn-msg.h index a0cec53..34f50c8 100644 --- a/include/openvpn-msg.h +++ b/include/openvpn-msg.h @@ -66,7 +66,8 @@ typedef struct { - int index; +#define TUN_ADAPTER_INDEX_INVALID ((DWORD)-1) + DWORD index; char name[256]; } interface_t; diff --git a/src/openvpn/dns.c b/src/openvpn/dns.c index fd388ce..2137a75 100644 --- a/src/openvpn/dns.c +++ b/src/openvpn/dns.c @@ -468,9 +468,10 @@ make_domain_list("dns search domains", search_domains, false, nrpt.sea= rch_domains, sizeof(nrpt.search_domains)); - msg(D_LOW, "%s NRPT DNS%s%s on '%s' (if_index =3D %d) using service", + msg(D_LOW, "%s NRPT DNS%s%s on '%s' (if_index =3D %lu) using service", (add ? "Setting" : "Deleting"), nrpt.resolve_domains[0] !=3D 0 ? "= , resolve domains" : "", - nrpt.search_domains[0] !=3D 0 ? ", search domains" : "", nrpt.ifac= e.name, nrpt.iface.index); + nrpt.search_domains[0] !=3D 0 ? ", search domains" : "", + nrpt.iface.name, nrpt.iface.index); send_msg_iservice(o->msg_channel, &nrpt, sizeof(nrpt), &ack, "DNS"); } diff --git a/src/openvpn/route.c b/src/openvpn/route.c index b196713..af21b92 100644 --- a/src/openvpn/route.c +++ b/src/openvpn/route.c @@ -2470,8 +2470,8 @@ } } - msg(D_ROUTE, "TEST ROUTES: %d/%d succeeded len=3D%d ret=3D%d a=3D%d u/= d=3D%s", good, count, len, - (int)ret, ambig, adapter_up ? "up" : "down"); + msg(D_ROUTE, "TEST ROUTES: %d/%d succeeded len=3D%d ret=3D%u a=3D%d u/= d=3D%s", + good, count, len, ret, ambig, adapter_up ? "up" : "down"); gc_free(&gc); return ret; @@ -2495,9 +2495,9 @@ const DWORD index =3D row->dwForwardIfIndex; const DWORD metric =3D row->dwForwardMetric1; - dmsg(D_ROUTE_DEBUG, "GDGR: route[%lu] %s/%s i=3D%d m=3D%d", i, + dmsg(D_ROUTE_DEBUG, "GDGR: route[%lu] %s/%s i=3D%lu m=3D%lu", = i, print_in_addr_t((in_addr_t)net, 0, &gc), print_in_addr_t(= (in_addr_t)mask, 0, &gc), - (int)index, (int)metric); + index, metric); if (!net && !mask && metric < lowest_metric) { @@ -2508,7 +2508,7 @@ } } - dmsg(D_ROUTE_DEBUG, "GDGR: best=3D%d lm=3D%u", best, (unsigned int)low= est_metric); + dmsg(D_ROUTE_DEBUG, "GDGR: best=3D%d lm=3D%lu", best, lowest_metric); gc_free(&gc); return ret; @@ -2542,7 +2542,7 @@ goto done; } - msg(D_ROUTE_DEBUG, "GetBestInterfaceEx() returned if=3D%d", (int)best_= if_index); + msg(D_ROUTE_DEBUG, "GetBestInterfaceEx() returned if=3D%lu", best_if_i= ndex); /* get the routing information (such as NextHop) for the destination a= nd interface */ NET_LUID luid; @@ -2552,8 +2552,8 @@ status =3D GetBestRoute2(&luid, best_if_index, NULL, dest, 0, best_rou= te, &best_src); if (status !=3D NO_ERROR) { - msg(D_ROUTE, "NOTE: GetIpForwardEntry2 returned error: %s (code=3D= %u)", - strerror_win32(status, gc), (unsigned int)status); + msg(D_ROUTE, "NOTE: GetIpForwardEntry2 returned error: %s (code=3D= %lu)", + strerror_win32(status, gc), status); goto done; } @@ -2647,8 +2647,8 @@ print_in_addr_t(r->gateway, 0, &gc), count); } - dmsg(D_ROUTE_DEBUG, "DEBUG: route find if: on_tun=3D%d count=3D%d inde= x=3D%d", on_tun, count, - (int)ret); + dmsg(D_ROUTE_DEBUG, "DEBUG: route find if: on_tun=3D%d count=3D%d inde= x=3D%lu", + on_tun, count, ret); gc_free(&gc); return ret; @@ -2687,8 +2687,8 @@ print_in6_addr(BestRoute.DestinationPrefix.Prefix.Ipv6.sin6_addr, = 0, &gc), BestRoute.DestinationPrefix.PrefixLength, print_in6_addr(BestRoute.NextHop.Ipv6.sin6_addr, 0, &gc)); - msg(D_ROUTE, "GDG6: Metric=3D%d, Loopback=3D%d, AA=3D%d, I=3D%d", (int= )BestRoute.Metric, - (int)BestRoute.Loopback, (int)BestRoute.AutoconfigureAddress, (int= )BestRoute.Immortal); + msg(D_ROUTE, "GDG6: Metric=3D%lu, Loopback=3D%u, AA=3D%u, I=3D%u", Bes= tRoute.Metric, + BestRoute.Loopback, BestRoute.AutoconfigureAddress, BestRoute.Immo= rtal); rgi6->gateway.addr_ipv6 =3D BestRoute.NextHop.Ipv6.sin6_addr; rgi6->adapter_index =3D BestRoute.InterfaceIndex; @@ -2855,7 +2855,7 @@ ret =3D (ack.error_number =3D=3D ERROR_OBJECT_ALREADY_EXISTS) ? RT= A_EEXIST : RTA_ERROR; if (ret =3D=3D RTA_ERROR) { - msg(M_WARN, "ERROR: route %s failed using service: %s [status= =3D%u if_index=3D%d]", + msg(M_WARN, "ERROR: route %s failed using service: %s [status= =3D%u if_index=3D%lu]", (add ? "addition" : "deletion"), strerror_win32(ack.error_= number, &gc), ack.error_number, rt->iface.index); } @@ -2869,17 +2869,12 @@ return ret; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wsign-compare" -#endif - /* Returns RTA_SUCCESS on success, RTA_EEXIST if route exists, RTA_ERROR o= n error */ static int do_route_ipv4_service(const bool add, const struct route_ipv4 *r, const st= ruct tuntap *tt) { DWORD if_index =3D windows_route_find_if_index(r, tt); - if (if_index =3D=3D ~0) + if (if_index =3D=3D TUN_ADAPTER_INDEX_INVALID) { return RTA_ERROR; } @@ -3023,10 +3018,6 @@ return status; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - /* Returns RTA_SUCCESS on success, RTA_EEXIST if route exists, RTA_ERROR o= n error */ static int add_route_service(const struct route_ipv4 *r, const struct tuntap *tt) @@ -3057,14 +3048,14 @@ format_route_entry(const MIB_IPFORWARDROW *r, struct gc_arena *gc) { struct buffer out =3D alloc_buf_gc(256, gc); - buf_printf(&out, "%s %s %s p=3D%d i=3D%d t=3D%d pr=3D%d a=3D%d h=3D%d = m=3D%d/%d/%d/%d/%d", + buf_printf(&out, "%s %s %s p=3D%lu i=3D%lu t=3D%lu pr=3D%lu a=3D%lu h= =3D%lu m=3D%lu/%lu/%lu/%lu/%lu", print_in_addr_t(r->dwForwardDest, IA_NET_ORDER, gc), print_in_addr_t(r->dwForwardMask, IA_NET_ORDER, gc), - print_in_addr_t(r->dwForwardNextHop, IA_NET_ORDER, gc), (in= t)r->dwForwardPolicy, - (int)r->dwForwardIfIndex, (int)r->dwForwardType, (int)r->dw= ForwardProto, - (int)r->dwForwardAge, (int)r->dwForwardNextHopAS, (int)r->d= wForwardMetric1, - (int)r->dwForwardMetric2, (int)r->dwForwardMetric3, (int)r-= >dwForwardMetric4, - (int)r->dwForwardMetric5); + print_in_addr_t(r->dwForwardNextHop, IA_NET_ORDER, gc), r->= dwForwardPolicy, + r->dwForwardIfIndex, r->dwForwardType, r->dwForwardProto, + r->dwForwardAge, r->dwForwardNextHopAS, r->dwForwardMetric1, + r->dwForwardMetric2, r->dwForwardMetric3, r->dwForwardMetri= c4, + r->dwForwardMetric5); return BSTR(&out); } diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c index ad77117..5c1ba25 100644 --- a/src/openvpn/tun.c +++ b/src/openvpn/tun.c @@ -158,7 +158,7 @@ if (ack.error_number !=3D NO_ERROR) { - msg(M_WARN, "TUN: %s address failed using service: %s [status=3D%u= if_index=3D%d]", + msg(M_WARN, "TUN: %s address failed using service: %s [status=3D%u= if_index=3D%lu]", (add ? "adding" : "deleting"), strerror_win32(ack.error_number= , &gc), ack.error_number, addr.iface.index); goto out; @@ -220,7 +220,7 @@ strncpy(dns.domains + dstlen, o->domain_search_list[i], srclen + 1= ); } - msg(D_LOW, "%s DNS domains on '%s' (if_index =3D %d) using service", + msg(D_LOW, "%s DNS domains on '%s' (if_index =3D %lu) using service", (add ? "Setting" : "Deleting"), dns.iface.name, dns.iface.index); if (!send_msg_iservice(o->msg_channel, &dns, sizeof(dns), &ack, "TUN")) { @@ -289,7 +289,7 @@ } } - msg(D_LOW, "%s %s dns servers on '%s' (if_index =3D %d) using service", + msg(D_LOW, "%s %s dns servers on '%s' (if_index =3D %lu) using service= ", (add ? "Setting" : "Deleting"), ip_proto_name, dns.iface.name, dns= .iface.index); if (!send_msg_iservice(pipe, &dns, sizeof(dns), &ack, "TUN")) @@ -346,7 +346,7 @@ wins.addr[i].ipv4.s_addr =3D htonl(tt->options.wins[i]); } - msg(D_LOW, "%s WINS servers on '%s' (if_index =3D %d) using service", + msg(D_LOW, "%s WINS servers on '%s' (if_index =3D %lu) using service", (add ? "Setting" : "Deleting"), wins.iface.name, wins.iface.index); if (!send_msg_iservice(pipe, &wins, sizeof(wins), &ack, "TUN")) @@ -398,13 +398,13 @@ if (ack.error_number !=3D NO_ERROR) { - msg(M_NONFATAL, "TUN: setting %s mtu using service failed: %s [sta= tus=3D%u if_index=3D%d]", + msg(M_NONFATAL, "TUN: setting %s mtu using service failed: %s [sta= tus=3D%u if_index=3D%lu]", family_name, strerror_win32(ack.error_number, &gc), ack.error_= number, mtu_msg.iface.index); } else { - msg(M_INFO, "%s MTU set to %d on interface %d using service", fami= ly_name, mtu, + msg(M_INFO, "%s MTU set to %d on interface %lu using service", fam= ily_name, mtu, mtu_msg.iface.index); ret =3D true; } @@ -4456,8 +4456,8 @@ list =3D list->Next; } - dmsg(D_ROUTE_DEBUG, "DEBUG: IP Locate: ip=3D%s nm=3D%s index=3D%d coun= t=3D%d metric=3D%d", - print_in_addr_t(ip, 0, &gc), print_in_addr_t(highest_netmask, 0, = &gc), (int)ret, + dmsg(D_ROUTE_DEBUG, "DEBUG: IP Locate: ip=3D%s nm=3D%s index=3D%lu cou= nt=3D%d metric=3D%d", + print_in_addr_t(ip, 0, &gc), print_in_addr_t(highest_netmask, 0, = &gc), ret, count ? *count : -1, lowest_metric); if (ret =3D=3D TUN_ADAPTER_INDEX_INVALID && count) @@ -4634,7 +4634,7 @@ show_adapter(msglvl_t msglevel, const IP_ADAPTER_INFO *a, struct gc_arena = *gc) { msg(msglevel, "%s", a->Description); - msg(msglevel, " Index =3D %d", (int)a->Index); + msg(msglevel, " Index =3D %lu", a->Index); msg(msglevel, " GUID =3D %s", a->AdapterName); msg(msglevel, " IP =3D %s", format_ip_addr_string(&a->IpAddressList, = gc)); msg(msglevel, " MAC =3D %s", format_hex_ex(a->Address, a->AddressLeng= th, 0, 1, ":", gc)); @@ -5215,12 +5215,12 @@ if (ack.error_number !=3D NO_ERROR) { - msg(M_NONFATAL, "TUN: enabling dhcp using service failed: %s [stat= us=3D%u if_index=3D%d]", + msg(M_NONFATAL, "TUN: enabling dhcp using service failed: %s [stat= us=3D%u if_index=3D%lu]", strerror_win32(ack.error_number, &gc), ack.error_number, dhcp.= iface.index); } else { - msg(M_INFO, "DHCP enabled on interface %d using service", dhcp.ifa= ce.index); + msg(M_INFO, "DHCP enabled on interface %lu using service", dhcp.if= ace.index); ret =3D true; } @@ -5510,7 +5510,7 @@ /* flush arp cache */ if (tt->backend_driver =3D=3D WINDOWS_DRIVER_TAP_WINDOWS6 && index != =3D TUN_ADAPTER_INDEX_INVALID) { - DWORD status =3D -1; + DWORD status =3D (DWORD)-1; if (tt->options.msg_channel) { @@ -5534,7 +5534,7 @@ { msg(M_INFO, "Successful ARP Flush on interface [%lu] %s", inde= x, device_guid); } - else if (status !=3D -1) + else if (status !=3D (DWORD)-1) { msg(D_TUNTAP_INFO, "NOTE: FlushIpNetTable failed on interface [%lu] %s (statu= s=3D%lu) : %s", index, diff --git a/src/openvpn/tun.h b/src/openvpn/tun.h index a226e37..388f5b7 100644 --- a/src/openvpn/tun.h +++ b/src/openvpn/tun.h @@ -61,8 +61,6 @@ #if defined(_WIN32) || defined(TARGET_ANDROID) || defined(DHCP_UNIT_TEST) -#define TUN_ADAPTER_INDEX_INVALID ((DWORD)-1) - /* time constants for --ip-win32 adaptive */ #define IPW32_SET_ADAPTIVE_DELAY_WINDOW 300 #define IPW32_SET_ADAPTIVE_TRY_NETSH 20 @@ -230,7 +228,7 @@ in_addr_t adapter_netmask; /* Windows adapter index for TAP-Windows adapter, - * ~0 if undefined */ + * TUN_ADAPTER_INDEX_INVALID if undefined */ DWORD adapter_index; int standby_iter; diff --git a/src/openvpn/win32.c b/src/openvpn/win32.c index ac449fd..b2a7331 100644 --- a/src/openvpn/win32.c +++ b/src/openvpn/win32.c @@ -1185,7 +1185,7 @@ if (ack.error_number !=3D NO_ERROR) { msg(M_WARN, - "WFP block: %s block filters using service failed: %s [status= =3D0x%x if_index=3D%d]", + "WFP block: %s block filters using service failed: %s [status= =3D0x%x if_index=3D%lu]", (add ? "adding" : "deleting"), strerror_win32(ack.error_number= , &gc), ack.error_number, data.iface.index); goto out; diff --git a/src/openvpnserv/interactive.c b/src/openvpnserv/interactive.c index 09c709e..b50aeb3 100644 --- a/src/openvpnserv/interactive.c +++ b/src/openvpnserv/interactive.c @@ -96,7 +96,7 @@ typedef struct { HANDLE engine; - int index; + DWORD index; int metric_v4; int metric_v6; } wfp_block_data_t; @@ -584,7 +584,7 @@ addr_row->Address =3D sockaddr_inet(msg->family, &msg->address); addr_row->OnLinkPrefixLength =3D (UINT8)msg->prefix_len; - if (msg->iface.index !=3D -1) + if (msg->iface.index !=3D TUN_ADAPTER_INDEX_INVALID) { addr_row->InterfaceIndex =3D msg->iface.index; } @@ -667,7 +667,7 @@ fwd_row->DestinationPrefix.PrefixLength =3D (UINT8)msg->prefix_len; fwd_row->NextHop =3D sockaddr_inet(msg->family, &msg->gateway); - if (msg->iface.index !=3D -1) + if (msg->iface.index !=3D TUN_ADAPTER_INDEX_INVALID) { fwd_row->InterfaceIndex =3D msg->iface.index; } @@ -1010,7 +1010,7 @@ * if action =3D "set" then "static" is added before $addr */ static DWORD -netsh_wins_cmd(const wchar_t *action, int if_index, const wchar_t *addr) +netsh_wins_cmd(const wchar_t *action, DWORD if_index, const wchar_t *addr) { DWORD err =3D 0; int timeout =3D 30000; /* in msec */ @@ -1036,7 +1036,7 @@ /* cmd template: * netsh interface ip $action wins $if_name $static $addr */ - const wchar_t *fmt =3D L"netsh interface ip %ls wins %d %ls %ls"; + const wchar_t *fmt =3D L"netsh interface ip %ls wins %lu %ls %ls"; /* max cmdline length in wchars -- include room for worst case and som= e */ size_t ncmdline =3D wcslen(fmt) + 11 /*if_index*/ + wcslen(action) + w= cslen(addr) @@ -2984,7 +2984,7 @@ */ } - int *if_index =3D malloc(sizeof(msg->iface.index)); + PDWORD if_index =3D malloc(sizeof(msg->iface.index)); if (if_index) { *if_index =3D msg->iface.index; @@ -3017,7 +3017,7 @@ /* cmd template: * netsh interface ipv4 set address name=3D$if_index source=3Ddhcp */ - const wchar_t *fmt =3D L"netsh interface ipv4 set address name=3D\"%d\= " source=3Ddhcp"; + const wchar_t *fmt =3D L"netsh interface ipv4 set address name=3D\"%lu= \" source=3Ddhcp"; /* max cmdline length in wchars -- include room for if index: * 10 chars for 32 bit int in decimal and +1 for NUL @@ -3250,7 +3250,7 @@ break; case undo_wins: - netsh_wins_cmd(L"delete", *(int *)item->data, NULL); + netsh_wins_cmd(L"delete", *(PDWORD)item->data, NULL); break; case wfp_block: -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1519?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings?usp=3Demail Gerrit-MessageType: newchange Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I38bb2d1fa66c543e8bcf47b7d77b6154d1895f81 Gerrit-Change-Number: 1519 Gerrit-PatchSet: 1 Gerrit-Owner: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos --uD0H/IEfBUY= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is cur= rently required from: plaisthos.

flichtenheld would like plaisthos to review this change.

V= iew Change

Win32: Make interface index DWORD consisten=
tly

Previously we had a weird mix of int and DWORD. But the
Win32= APIs seem to be consistent (they have different names,
but NET_IFINDEX = is ULONG is DWORD). So use that.

Change-Id: I38bb2d1fa66c543e8bcf47b= 7d77b6154d1895f81
Signed-off-by: Frank Lichtenheld <frank@...2641...&= gt;
---
M include/openvpn-msg.h
M src/openvpn/dns.c
M src/openv= pn/route.c
M src/openvpn/tun.c
M src/openvpn/tun.h
M src/openvpn/w= in32.c
M src/openvpnserv/interactive.c
7 files changed, 48 insertions= (+), 57 deletions(-)

git pull ssh://gerrit.openv=
pn.net:29418/openvpn refs/changes/19/1519/1
diff --git a/include/op=
envpn-msg.h b/include/openvpn-msg.h
index a0cec53..34f50c8 = 100644
--- a/include/openvpn-msg.h
+++ b/in= clude/openvpn-msg.h
@@ -66,7 +66,8 @@

typedef struct
{
- int index;
+#define TUN_ADAPTER_INDEX_INVALID ((DWORD)-1)+ DWORD index;
<= span> char name[256];

} interface_t;
=
diff --git a/src/openvpn/dns.c b/src/openvpn/dns.c<= br>index fd388ce..2137a75 100644
--- a/src/openvpn/dn= s.c
+++ b/src/openvpn/dns.c
@@ -468,9 +468,= 10 @@
make_domain_list("dns search domains",= search_domains, false, nrpt.search_domains,
= sizeof(nrpt.search_domains));

- msg(D_LOW, "%s NRPT DNS%s%s on &= #39;%s' (if_index =3D %d) using service",
+ msg(D_LOW, "%s NRPT DNS%s%s on '= ;%s' (if_index =3D %lu) using service",
(= add ? "Setting" : "Deleting"), nrpt.resolve_domains[0] = !=3D 0 ? ", resolve domains" : "",
- nrpt.search_domains[0] !=3D 0 ? &q= uot;, search domains" : "", nrpt.iface.name, nrpt.iface.inde= x);
+ nrpt.sea= rch_domains[0] !=3D 0 ? ", search domains" : "",=
+ nrpt.iface.name, n= rpt.iface.index);

send_msg_iservice(= o->msg_channel, &nrpt, sizeof(nrpt), &ack, "DNS");
}
diff --git a/src/openvpn/route.c b/src/open= vpn/route.c
index b196713..af21b92 100644
-= -- a/src/openvpn/route.c
+++ b/src/openvpn/route.c@@ -2470,8 +2470,8 @@
}
= }

= - msg(D_ROUTE, "TEST ROUTES: %d/%d succeeded len=3D%d ret=3D%d a=3D= %d u/d=3D%s", good, count, len,
- (int)ret, ambig, adapter_up ? "up" : "= ;down");
+ ms= g(D_ROUTE, "TEST ROUTES: %d/%d succeeded len=3D%d ret=3D%u a=3D%d u/d= =3D%s",
+ = good, count, len, ret, ambig, adapter_up ? "up" : "down&quo= t;);

gc_free(&gc);
return ret;

@@ -2495,9 +2495,9 @@
= const DWORD index =3D row->dwForwardIfIndex;
const DWORD metric =3D row->dwForwardMetric1;

- dmsg= (D_ROUTE_DEBUG, "GDGR: route[%lu] %s/%s i=3D%d m=3D%d", i,=
+ dmsg(D_ROUTE_D= EBUG, "GDGR: route[%lu] %s/%s i=3D%lu m=3D%lu", i,
print_in_addr_t((in_addr_t)net, 0, &gc), print_in_a= ddr_t((in_addr_t)mask, 0, &gc),
- (int)index, (int)metric);
+ index, metric);


if (!net && !mask &&a= mp; metric < lowest_metric)
{
@@ -2508,7 +2508,7 @@
}
}<= /span>

- = dmsg(D_ROUTE_DEBUG, "GDGR: best=3D%d lm=3D%u", best, (unsigned in= t)lowest_metric);
+ = dmsg(D_ROUTE_DEBUG, "GDGR: best=3D%d lm=3D%lu", best, lowest_me= tric);

gc_free(&gc);
<= span> return ret;

@@ -2542,7 +2542,7 @@
goto done;
}

- msg(D_ROUTE_DEBUG, "GetBes= tInterfaceEx() returned if=3D%d", (int)best_if_index);
+ msg(D_ROUTE_DEBUG, "GetBes= tInterfaceEx() returned if=3D%lu", best_if_index);

/* get the routing information (such as NextHop) for th= e destination and interface */
NET_LUID luid;@@ -2552,8 +2552,8 @@
status =3D GetBestRoute2= (&luid, best_if_index, NULL, dest, 0, best_route, &best_src);

if (status !=3D NO_ERROR)
{
= - msg(D_ROUTE, "NOTE:= GetIpForwardEntry2 returned error: %s (code=3D%u)",
- strerror_win32(status, gc),= (unsigned int)status);
+ msg(D_ROUTE, "NOTE: GetIpForwardEntry2 returned error: %s = (code=3D%lu)",
+= strerror_win32(status, gc), status);
g= oto done;
}

@@ -2647= ,8 +2647,8 @@
print_in_addr_t(r->gateway, 0= , &gc), count);
}

- dmsg(D_ROUTE_DEBUG, "DEBUG:= route find if: on_tun=3D%d count=3D%d index=3D%d", on_tun, count,

- (int)ret);

+ dmsg(D_ROUTE_DEBUG, &= quot;DEBUG: route find if: on_tun=3D%d count=3D%d index=3D%lu",=
+ on_tun, count, re= t);

gc_free(&gc);
return ret;
@@ -2687,8 +2687,8 @@
= print_in6_addr(BestRoute.DestinationPrefix.Prefix.Ipv6.sin6_addr, 0,= &gc),
BestRoute.DestinationPrefix.PrefixLengt= h,
print_in6_addr(BestRoute.NextHop.Ipv6.sin6_addr= , 0, &gc));
- ms= g(D_ROUTE, "GDG6: Metric=3D%d, Loopback=3D%d, AA=3D%d, I=3D%d", (= int)BestRoute.Metric,
-= (int)BestRoute.Loopback, (int)BestRoute.AutoconfigureAddress, (int)= BestRoute.Immortal);
= + msg(D_ROUTE, "GDG6: Metric=3D%lu, Loopback=3D%u, AA=3D%u, I=3D%u&= quot;, BestRoute.Metric,
+ BestRoute.Loopback, BestRoute.AutoconfigureAddress, BestRoute.= Immortal);

rgi6->gateway.addr_ipv= 6 =3D BestRoute.NextHop.Ipv6.sin6_addr;
rgi6->adapt= er_index =3D BestRoute.InterfaceIndex;
@@ -2855,7 +2855,7 @= @
ret =3D (ack.error_number =3D=3D ERROR_OBJECT_AL= READY_EXISTS) ? RTA_EEXIST : RTA_ERROR;
if (ret = =3D=3D RTA_ERROR)
{
- msg(M_WARN, "ERROR: route %s failed= using service: %s [status=3D%u if_index=3D%d]",
+ msg(M_WARN, "ERROR: rout= e %s failed using service: %s [status=3D%u if_index=3D%lu]", (add ? "addition" : "deletion")= , strerror_win32(ack.error_number, &gc),
= ack.error_number, rt->iface.index);
}=
@@ -2869,17 +2869,12 @@
return ret; }

-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Ws= ign-compare"
-#end= if
-
/= * Returns RTA_SUCCESS on success, RTA_EEXIST if route exists, RTA_ERROR on = error */
static int
do_route_ipv4_service= (const bool add, const struct route_ipv4 *r, const struct tuntap *tt)
{
DWORD if_index =3D windows_route_find_if= _index(r, tt);
- if = (if_index =3D=3D ~0)
= + if (if_index =3D=3D TUN_ADAPTER_INDEX_INVALID)
{<= /span>
return RTA_ERROR;
}@@ -3023,10 +3018,6 @@
return status; }

-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
-
/* Returns RTA_SUCCESS on success, RTA_= EEXIST if route exists, RTA_ERROR on error */
static int
add_route_service(const struct route_ipv4 *r, const struct = tuntap *tt)
@@ -3057,14 +3048,14 @@
format= _route_entry(const MIB_IPFORWARDROW *r, struct gc_arena *gc)
{

struct buffer out =3D alloc_buf_gc(256, gc);

- buf_printf(&out, &= quot;%s %s %s p=3D%d i=3D%d t=3D%d pr=3D%d a=3D%d h=3D%d m=3D%d/%d/%d/%d/%d= ",
+ buf_prin= tf(&out, "%s %s %s p=3D%lu i=3D%lu t=3D%lu pr=3D%lu a=3D%lu h=3D%l= u m=3D%lu/%lu/%lu/%lu/%lu",
print_in_a= ddr_t(r->dwForwardDest, IA_NET_ORDER, gc),
= print_in_addr_t(r->dwForwardMask, IA_NET_ORDER, gc),
- print_in_addr_t(r->d= wForwardNextHop, IA_NET_ORDER, gc), (int)r->dwForwardPolicy,
<= span style=3D"color: hsl(0, 100%, 40%);">- (int)r->dwForwa= rdIfIndex, (int)r->dwForwardType, (int)r->dwForwardProto,
<= span style=3D"color: hsl(0, 100%, 40%);">- (int)r->dwForwa= rdAge, (int)r->dwForwardNextHopAS, (int)r->dwForwardMetric1,- (int)r->dwFo= rwardMetric2, (int)r->dwForwardMetric3, (int)r->dwForwardMetric4,

- (int)r->= ;dwForwardMetric5);
+= print_in_addr_t(r->dwForwardNextHop, IA_NET_ORDER, gc), r= ->dwForwardPolicy,
+ r->dwForwardIfIndex, r->dwForwardType, r->dwForwa= rdProto,
+ = r->dwForwardAge, r->dwForwardNextHopAS, r->dwForwardMetric1,
+ r->= dwForwardMetric2, r->dwForwardMetric3, r->dwForwardMetric4,+ r->dwForwar= dMetric5);
return BSTR(&out);
}

diff --git a/src/openvpn/tun.c b/src/openv= pn/tun.c
index ad77117..5c1ba25 100644
--- = a/src/openvpn/tun.c
+++ b/src/openvpn/tun.c
@@ -158,7 +158,7 @@


if (ack.error_n= umber !=3D NO_ERROR)
{
- msg(M_WARN, "TUN: %s address failed usin= g service: %s [status=3D%u if_index=3D%d]",
+ msg(M_WARN, "TUN: %s address fail= ed using service: %s [status=3D%u if_index=3D%lu]",
= (add ? "adding" : "deleting"), strerror_win3= 2(ack.error_number, &gc), ack.error_number,
= addr.iface.index);
goto out;
@@ = -220,7 +220,7 @@
strncpy(dns.domains + dstlen, o-&= gt;domain_search_list[i], srclen + 1);
}

- msg(D_LOW, &q= uot;%s DNS domains on '%s' (if_index =3D %d) using service",
+ msg(D_LOW, "= %s DNS domains on '%s' (if_index =3D %lu) using service",
(add ? "Setting" : "Deleting"), dn= s.iface.name, dns.iface.index);
if (!send_msg_iservice= (o->msg_channel, &dns, sizeof(dns), &ack, "TUN"))
{
@@ -289,7 +289,7 @@
= }
}

- msg(D_LOW, "%s %s dns servers on '%s= ' (if_index =3D %d) using service",
+ msg(D_LOW, "%s %s dns servers on '%s&= #39; (if_index =3D %lu) using service",
(add = ? "Setting" : "Deleting"), ip_proto_name, dns.iface.nam= e, dns.iface.index);

if (!send_msg_i= service(pipe, &dns, sizeof(dns), &ack, "TUN"))
= @@ -346,7 +346,7 @@
wins.addr[i].ipv4.s_addr= =3D htonl(tt->options.wins[i]);
}
=
- msg(D_LOW, "= ;%s WINS servers on '%s' (if_index =3D %d) using service",
+ msg(D_LOW, "%s= WINS servers on '%s' (if_index =3D %lu) using service",
(add ? "Setting" : "Deleting"), win= s.iface.name, wins.iface.index);

if = (!send_msg_iservice(pipe, &wins, sizeof(wins), &ack, "TUN"= ;))
@@ -398,13 +398,13 @@

if (ack.error_number !=3D NO_ERROR)

{
= - msg(M_NONFATAL, "TU= N: setting %s mtu using service failed: %s [status=3D%u if_index=3D%d]"= ;,
+ msg(M_NON= FATAL, "TUN: setting %s mtu using service failed: %s [status=3D%u if_i= ndex=3D%lu]",
family_name, strerror_win32= (ack.error_number, &gc), ack.error_number,
= mtu_msg.iface.index);
}
else
{
- = msg(M_INFO, "%s MTU set to %d on interface %d using service"= ;, family_name, mtu,
= + msg(M_INFO, "%s MTU set to %d on interface %lu using service&= quot;, family_name, mtu,
mtu_msg.iface.index);=
ret =3D true;
}
@@ -4456,8 +4456,8 @@

list =3D list->Next;<= /span>
}

- dmsg(D_ROUTE_DEBUG, "DEBUG: IP Locate: ip=3D%s = nm=3D%s index=3D%d count=3D%d metric=3D%d",
- print_in_addr_t(ip, 0, &gc), print_= in_addr_t(highest_netmask, 0, &gc), (int)ret,
+ dmsg(D_ROUTE_DEBUG, "DEBUG: IP Locat= e: ip=3D%s nm=3D%s index=3D%lu count=3D%d metric=3D%d",
+ print_in_addr_t(ip, 0, &a= mp;gc), print_in_addr_t(highest_netmask, 0, &gc), ret,

= count ? *count : -1, lowest_metric);

= if (ret =3D=3D TUN_ADAPTER_INDEX_INVALID && count)
@@ -4634,7 +4634,7 @@
show_adapter(msglvl_t msg= level, const IP_ADAPTER_INFO *a, struct gc_arena *gc)
{
msg(msglevel, "%s", a->Description);=
- msg(msglevel, " In= dex =3D %d", (int)a->Index);
+ msg(msglevel, " Index =3D %lu", a->Index= );
msg(msglevel, " GUID =3D %s", a->Adap= terName);
msg(msglevel, " IP =3D %s", forma= t_ip_addr_string(&a->IpAddressList, gc));
msg(m= sglevel, " MAC =3D %s", format_hex_ex(a->Address, a->Addre= ssLength, 0, 1, ":", gc));
@@ -5215,12 +5215,12 @= @

if (ack.error_number !=3D NO_ERROR= )
{
+ msg(M_NONFATAL, "TUN: enabling dhcp using ser= vice failed: %s [status=3D%u if_index=3D%lu]",
= strerror_win32(ack.error_number, &gc), ack.error_number, dhcp.ifa= ce.index);
}
else
{

- msg(M_= INFO, "DHCP enabled on interface %d using service", dhcp.iface.in= dex);
+ msg(M_= INFO, "DHCP enabled on interface %lu using service", dhcp.iface.i= ndex);
ret =3D true;
}=

@@ -5510,7 +5510,7 @@
/* f= lush arp cache */
if (tt->backend_driver =3D=3D WIN= DOWS_DRIVER_TAP_WINDOWS6 && index !=3D TUN_ADAPTER_INDEX_INVALID)
{
-= DWORD status =3D -1;
+ DWORD status =3D (DWORD)-1;

if (tt->options.msg_channel)

{
@@ -5534,7 +5534,7 @@
{
msg(M_INFO, "Successful ARP Flush on interface [%lu] %= s", index, device_guid);

}
- else if (status !=3D -1)<= br>+ else if (status != =3D (DWORD)-1)
{
msg(= D_TUNTAP_INFO,
"NOTE: FlushIpNetTable= failed on interface [%lu] %s (status=3D%lu) : %s", index,
<= span>diff --git a/src/openvpn/tun.h b/src/openvpn/tun.h

ind= ex a226e37..388f5b7 100644
--- a/src/openvpn/tun.h+++ b/src/openvpn/tun.h
@@ -61,8 +61,6 @@
#if defined(_WIN32) || defined(TARGET_ANDROID) ||= defined(DHCP_UNIT_TEST)

-#define TUN_ADAPTER_INDEX_INVALID ((DWORD)-1)-
/* time cons= tants for --ip-win32 adaptive */
#define IPW32_SET_ADAPTIV= E_DELAY_WINDOW 300
#define IPW32_SET_ADAPTIVE_TRY_NETSH = 20
@@ -230,7 +228,7 @@
in_addr_t adap= ter_netmask;

/* Windows adapter inde= x for TAP-Windows adapter,
- * ~0 if undefined */
+ * TUN_ADAPTER_INDEX_INVALID if undefined */
DWORD adapter_index;


int stand= by_iter;
diff --git a/src/openvpn/win32.c b/src/openvpn/win= 32.c
index ac449fd..b2a7331 100644
--- a/sr= c/openvpn/win32.c
+++ b/src/openvpn/win32.c
@@ -1185,7 +1185,7 @@

if (ack.error_number !=3D NO_ER= ROR)
{
msg(M_WARN,
= - "WFP block: %s = block filters using service failed: %s [status=3D0x%x if_index=3D%d]",=
+ "W= FP block: %s block filters using service failed: %s [status=3D0x%x if_index= =3D%lu]",
(add ? "adding" : &qu= ot;deleting"), strerror_win32(ack.error_number, &gc), ack.error_nu= mber,
data.iface.index);
= goto out;
diff --git a/src/openvpnserv/interactive.c b/= src/openvpnserv/interactive.c
index 09c709e..b50aeb3 100644=
--- a/src/openvpnserv/interactive.c
+++ b/= src/openvpnserv/interactive.c
@@ -96,7 +96,7 @@
<= span> typedef struct

{
HANDLE engine;=
- int index;=
+ DWORD index; int metric_v4;
int metric_v6;
} wfp_block_data_t;

@@ -584,7 +584,7 @@
addr_row->Address =3D sockaddr_inet(msg->family, &msg->= address);
addr_row->OnLinkPrefixLength =3D (UINT8)m= sg->prefix_len;

- if (msg->iface.index !=3D -1)
+ if (msg->iface.index !=3D TUN_ADAP= TER_INDEX_INVALID)
{
addr_row= ->InterfaceIndex =3D msg->iface.index;
}<= br>@@ -667,7 +667,7 @@
fwd_row->DestinationPr= efix.PrefixLength =3D (UINT8)msg->prefix_len;
fwd_r= ow->NextHop =3D sockaddr_inet(msg->family, &msg->gateway);

- if = (msg->iface.index !=3D -1)
+ if (msg->iface.index !=3D TUN_ADAPTER_INDEX_INVALID)
{
fwd_row->InterfaceIndex =3D m= sg->iface.index;
}
@@ -1010,7 +1010= ,7 @@
* if action =3D "set" then "static&q= uot; is added before $addr
*/
static DWO= RD
-netsh_wins_cmd(cons= t wchar_t *action, int if_index, const wchar_t *addr)
+netsh_wins_cmd(const wchar_t *action, DWO= RD if_index, const wchar_t *addr)
{
D= WORD err =3D 0;
int timeout =3D 30000; /* in msec */
@@ -1036,7 +1036,7 @@
/* cmd template:<= /span>
* netsh interface ip $action wins $if_name $static $a= ddr
*/
- const wchar_t *fmt =3D L"netsh interface ip %ls wins %d %ls= %ls";
+ cons= t wchar_t *fmt =3D L"netsh interface ip %ls wins %lu %ls %ls";

/* max cmdline length in wchars -- inc= lude room for worst case and some */
size_t ncmdline = =3D wcslen(fmt) + 11 /*if_index*/ + wcslen(action) + wcslen(addr)@@ -2984,7 +2984,7 @@
*/
= }

- int *if_index =3D malloc(sizeof(msg->iface.index));
+ PDWORD if_index =3D malloc(siz= eof(msg->iface.index));

if (if_index)
{

*if_index =3D msg->iface.index;
@@ -3017,7 +3017,7 @@
/* cmd template:

* netsh interface ipv4 set address name=3D$if_index sourc= e=3Ddhcp
*/
- const wchar_t *fmt =3D L"netsh interface ipv4 set addr= ess name=3D\"%d\" source=3Ddhcp";
+ const wchar_t *fmt =3D L"netsh interf= ace ipv4 set address name=3D\"%lu\" source=3Ddhcp";
/* max cmdline length in wchars -- include r= oom for if index:
* 10 chars for 32 bit int in decima= l and +1 for NUL
@@ -3250,7 +3250,7 @@
= break;

= case undo_wins:
- = netsh_wins_cmd(L"delete", *(int *)item->data, NU= LL);
+ = netsh_wins_cmd(L"delete", *(PDWORD)item->data, NULL);
break;

= case wfp_block:

To vie= w, visit change 1519. To unsubscribe, or for help writing mail filters, visit <= a href=3D"http://gerrit.openvpn.net/settings?usp=3Demail">settings.

=
<= meta itemprop=3D"name" content=3D"View Change"/>
Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I38bb2d1fa66c543e8bcf47b7d77= b6154d1895f81
Gerrit-Change-Number: 1519
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <frank@...2723...= .>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...220...= ..1227...>
= --uD0H/IEfBUY=--