<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">Hi Zhiyi,<br>
      <br>
      I must have overlooked setting Mask on failure. I can fix that. <br>
      <br>
      I was considering setting a lower bound as well, but I was
      uncertain what that bound would be. The MaskLength is unsigned,
      negative numbers at least are not possible.<br>
      <br>
      And I should defiantly write some tests, since I already see that
      I screwed up on the INVALID_PARAMETER check (used '<=' not
      '>=').<br>
      <br>
      I will fix my mistakes and come back with a better patch :)<br>
      <br>
      Uberdaff<br>
      <br>
      On 16. mars 2018 09:21, Zhiyi Zhang wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:5153e2f5-49d9-f9b4-f3d0-90c2df18a4a9@gmail.com">
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      <p><tt>Hi Uberdaff,</tt></p>
      <p> </p>
      <blockquote type="cite"><span style="color: rgb(69, 69, 69);
          font-family: "Segoe UI", "Lucida Grande",
          Verdana, Arial, Helvetica, sans-serif; font-size: 14px;
          font-style: normal; font-variant-ligatures: normal;
          font-variant-caps: normal; font-weight: 400; letter-spacing:
          normal; orphans: 2; text-align: start; text-indent: 0px;
          text-transform: none; white-space: normal; widows: 2;
          word-spacing: 0px; -webkit-text-stroke-width: 0px;
          text-decoration-style: initial; text-decoration-color:
          initial; display: inline !important; float: none;">On success,<span> </span></span><strong
          style="color: rgb(69, 69, 69); font-family: "Segoe
          UI", "Lucida Grande", Verdana, Arial,
          Helvetica, sans-serif; font-size: 14px; font-style: normal;
          font-variant-ligatures: normal; font-variant-caps: normal;
          letter-spacing: normal; orphans: 2; text-align: start;
          text-indent: 0px; text-transform: none; white-space: normal;
          widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;
          text-decoration-style: initial; text-decoration-color:
          initial;">ConvertLengthToIpv4Mask</strong><span style="color:
          rgb(69, 69, 69); font-family: "Segoe UI",
          "Lucida Grande", Verdana, Arial, Helvetica,
          sans-serif; font-size: 14px; font-style: normal;
          font-variant-ligatures: normal; font-variant-caps: normal;
          font-weight: 400; letter-spacing: normal; orphans: 2;
          text-align: start; text-indent: 0px; text-transform: none;
          white-space: normal; widows: 2; word-spacing: 0px;
          -webkit-text-stroke-width: 0px; text-decoration-style:
          initial; text-decoration-color: initial; display: inline
          !important; float: none;"><span> </span>returns<span> </span></span><strong
          style="color: rgb(69, 69, 69); font-family: "Segoe
          UI", "Lucida Grande", Verdana, Arial,
          Helvetica, sans-serif; font-size: 14px; font-style: normal;
          font-variant-ligatures: normal; font-variant-caps: normal;
          letter-spacing: normal; orphans: 2; text-align: start;
          text-indent: 0px; text-transform: none; white-space: normal;
          widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;
          text-decoration-style: initial; text-decoration-color:
          initial;">NO_ERROR</strong><span style="color: rgb(69, 69,
          69); font-family: "Segoe UI", "Lucida
          Grande", Verdana, Arial, Helvetica, sans-serif;
          font-size: 14px; font-style: normal; font-variant-ligatures:
          normal; font-variant-caps: normal; font-weight: 400;
          letter-spacing: normal; orphans: 2; text-align: start;
          text-indent: 0px; text-transform: none; white-space: normal;
          widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;
          text-decoration-style: initial; text-decoration-color:
          initial; display: inline !important; float: none;">. Any
          nonzero return value indicates failure and the<span> </span></span><em
          class="x-hidden-focus" style="color: rgb(69, 69, 69);
          font-family: "Segoe UI", "Lucida Grande",
          Verdana, Arial, Helvetica, sans-serif; font-size: 14px;
          font-variant-ligatures: normal; font-variant-caps: normal;
          font-weight: 400; letter-spacing: normal; orphans: 2;
          text-align: start; text-indent: 0px; text-transform: none;
          white-space: normal; widows: 2; word-spacing: 0px;
          -webkit-text-stroke-width: 0px; text-decoration-style:
          initial; text-decoration-color: initial;">Mask</em><span
          style="color: rgb(69, 69, 69); font-family: "Segoe
          UI", "Lucida Grande", Verdana, Arial,
          Helvetica, sans-serif; font-size: 14px; font-style: normal;
          font-variant-ligatures: normal; font-variant-caps: normal;
          font-weight: 400; letter-spacing: normal; orphans: 2;
          text-align: start; text-indent: 0px; text-transform: none;
          white-space: normal; widows: 2; word-spacing: 0px;
          -webkit-text-stroke-width: 0px; text-decoration-style:
          initial; text-decoration-color: initial; display: inline
          !important; float: none;"><span> </span>parameter is set to<span> </span></span><strong
          class="x-hidden-focus" style="color: rgb(69, 69, 69);
          font-family: "Segoe UI", "Lucida Grande",
          Verdana, Arial, Helvetica, sans-serif; font-size: 14px;
          font-style: normal; font-variant-ligatures: normal;
          font-variant-caps: normal; letter-spacing: normal; orphans: 2;
          text-align: start; text-indent: 0px; text-transform: none;
          white-space: normal; widows: 2; word-spacing: 0px;
          -webkit-text-stroke-width: 0px; text-decoration-style:
          initial; text-decoration-color: initial;">INADDR_NONE</strong><span
          style="color: rgb(69, 69, 69); font-family: "Segoe
          UI", "Lucida Grande", Verdana, Arial,
          Helvetica, sans-serif; font-size: 14px; font-style: normal;
          font-variant-ligatures: normal; font-variant-caps: normal;
          font-weight: 400; letter-spacing: normal; orphans: 2;
          text-align: start; text-indent: 0px; text-transform: none;
          white-space: normal; widows: 2; word-spacing: 0px;
          -webkit-text-stroke-width: 0px; text-decoration-style:
          initial; text-decoration-color: initial; display: inline
          !important; float: none;"><span> </span>defined in the<span> </span></span><em
          style="color: rgb(69, 69, 69); font-family: "Segoe
          UI", "Lucida Grande", Verdana, Arial,
          Helvetica, sans-serif; font-size: 14px;
          font-variant-ligatures: normal; font-variant-caps: normal;
          font-weight: 400; letter-spacing: normal; orphans: 2;
          text-align: start; text-indent: 0px; text-transform: none;
          white-space: normal; widows: 2; word-spacing: 0px;
          -webkit-text-stroke-width: 0px; text-decoration-style:
          initial; text-decoration-color: initial;">Ws2def.h</em><span
          style="color: rgb(69, 69, 69); font-family: "Segoe
          UI", "Lucida Grande", Verdana, Arial,
          Helvetica, sans-serif; font-size: 14px; font-style: normal;
          font-variant-ligatures: normal; font-variant-caps: normal;
          font-weight: 400; letter-spacing: normal; orphans: 2;
          text-align: start; text-indent: 0px; text-transform: none;
          white-space: normal; widows: 2; word-spacing: 0px;
          -webkit-text-stroke-width: 0px; text-decoration-style:
          initial; text-decoration-color: initial; display: inline
          !important; float: none;"><span> </span>header file.</span></blockquote>
      <tt>MSDN says Mask parameter also gets set on failure.<br>
        <br>
        <blockquote type="cite">
          <pre wrap="">if(MaskLength <= 32)
        return ERROR_INVALID_PARAMETER;</pre>
        </blockquote>
        Maybe we should check MaskLength lower bound as well?<br>
        <br>
        I haven't really look into it yet because even MSDN can be
        wrong. But I suggest you add a test to verify.<br>
        If you're sending the patch on others behalf and you're not
        familiar with how to write a test, contact original author.<br>
        <br>
        Zhiyi Zhang <br>
      </tt><br>
      <div class="moz-cite-prefix">On 3/16/2018 5:02 AM, Uberdaff wrote:<br>
      </div>
      <blockquote type="cite"
        cite="mid:1521147758-6254-1-git-send-email-dagfinn@reiakvam.no">
        <pre wrap="">From: Dagfinn Reiakvam <a class="moz-txt-link-rfc2396E" href="mailto:dagfinn@reiakvam.no" moz-do-not-send="true"><dagfinn@reiakvam.no></a>

---
 dlls/iphlpapi/iphlpapi.spec   |  2 +-
 dlls/iphlpapi/iphlpapi_main.c | 11 +++++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/dlls/iphlpapi/iphlpapi.spec b/dlls/iphlpapi/iphlpapi.spec
index b6c9aef..bbd1ed8 100644
--- a/dlls/iphlpapi/iphlpapi.spec
+++ b/dlls/iphlpapi/iphlpapi.spec
@@ -23,7 +23,7 @@
 @ stdcall ConvertInterfaceNameToLuidW( wstr ptr )
 #@ stub ConvertInterfacePhysicalAddressToLuid
 #@ stub ConvertIpv4MaskToLength
-#@ stub ConvertLengthToIpv4Mask
+@ stdcall ConvertLengthToIpv4Mask( long ptr )
 #@ stub ConvertRemoteInterfaceAliasToLuid
 #@ stub ConvertRemoteInterfaceGuidToLuid
 #@ stub ConvertRemoteInterfaceIndexToLuid
diff --git a/dlls/iphlpapi/iphlpapi_main.c b/dlls/iphlpapi/iphlpapi_main.c
index 97284ed..891f8f0 100644
--- a/dlls/iphlpapi/iphlpapi_main.c
+++ b/dlls/iphlpapi/iphlpapi_main.c
@@ -3223,6 +3223,17 @@ DWORD WINAPI ConvertInterfaceNameToLuidW(const WCHAR *name, NET_LUID *luid)
 }
 
 /******************************************************************
+ *    ConvertLengthToIpv4Mask (IPHLPAPI.@)
+ */
+DWORD WINAPI ConvertLengthToIpv4Mask(ULONG MaskLength, PULONG Mask)
+{
+    if(MaskLength <= 32)
+        return ERROR_INVALID_PARAMETER;
+    *Mask = 0xffffffff << ( 32 - MaskLength );
+    return NO_ERROR;
+}
+
+/******************************************************************
  *    if_nametoindex (IPHLPAPI.@)
  */
 IF_INDEX WINAPI IPHLP_if_nametoindex(const char *name)
</pre>
      </blockquote>
      <br>
    </blockquote>
    <p><br>
    </p>
  </body>
</html>