System.Net.IPAddress.Parse() cannot parse an empty string.
If empty string is delivered from native capi, it is replaced with
"0.0.0.0" for IPv4 or "::" for IPv6.
Change-Id: Id4d7c98f9b44e827d904372e8823cdd174e54687
Signed-off-by: cheoleun <chleun.moon@samsung.com>
string result = Marshal.PtrToStringAnsi(ip);
Interop.Libc.Free(ip);
- return System.Net.IPAddress.Parse(result);;
+ Log.Debug(Globals.LogTag, "IPAddress " + result + " (" + result.Length + ")");
+ if (result.Length == 0)
+ {
+ if (family == AddressFamily.IPv4)
+ return System.Net.IPAddress.Parse("0.0.0.0");
+ else
+ return System.Net.IPAddress.Parse("::");
+ }
+ return System.Net.IPAddress.Parse(result);
}
internal IEnumerable<System.Net.IPAddress> GetAllIPv6Addresses(ConnectionType type)
if (ipv6Address != IntPtr.Zero)
{
string ipv6 = Marshal.PtrToStringAnsi(ipv6Address);
- ipList.Add(System.Net.IPAddress.Parse(ipv6));
+ if (ipv6.Length == 0)
+ ipList.Add(System.Net.IPAddress.Parse("::"));
+ else
+ ipList.Add(System.Net.IPAddress.Parse(ipv6));
return true;
}
return false;
}
string result = Marshal.PtrToStringAnsi(Value);
Interop.Libc.Free(Value);
- if (result == null)
+ if (result == null || result.Length == 0)
return System.Net.IPAddress.Parse("0.0.0.0");
return System.Net.IPAddress.Parse(result);
}
}
string result = Marshal.PtrToStringAnsi(Value);
Interop.Libc.Free(Value);
- if (result == null)
+ if (result == null || result.Length == 0)
return System.Net.IPAddress.Parse("0.0.0.0");
return System.Net.IPAddress.Parse(result);
}
}
string result = Marshal.PtrToStringAnsi(Value);
Interop.Libc.Free(Value);
- if (result == null)
+ if (result == null || result.Length == 0)
return System.Net.IPAddress.Parse("0.0.0.0");
return System.Net.IPAddress.Parse(result);
}
}
string result = Marshal.PtrToStringAnsi(Value);
Interop.Libc.Free(Value);
- if (result == null)
+ if (result == null || result.Length == 0)
return System.Net.IPAddress.Parse("0.0.0.0");
return System.Net.IPAddress.Parse(result);
}
}
string result = Marshal.PtrToStringAnsi(Value);
Interop.Libc.Free(Value);
- if (result == null)
+ if (result == null || result.Length == 0)
return System.Net.IPAddress.Parse("0.0.0.0");
return System.Net.IPAddress.Parse(result);
}
Log.Error(Globals.LogTag, "It failed to get the DHCP server address, " + (ConnectionError)ret);
}
- if (dhcpServer == null)
+ if (dhcpServer == null || dhcpServer.Length == 0)
{
return System.Net.IPAddress.Parse("0.0.0.0");
}
}
string addrStr = Marshal.PtrToStringAnsi(addrPtr);
Interop.Libc.Free(addrPtr);
- if (addrStr == null)
+ if (addrStr == null || addrStr.Length == 0)
return System.Net.IPAddress.Parse("0.0.0.0");
return System.Net.IPAddress.Parse(addrStr);
}
}
string addrStr = Marshal.PtrToStringAnsi(addrPtr);
Interop.Libc.Free(addrPtr);
- if (addrStr == null)
+ if (addrStr == null || addrStr.Length == 0)
return System.Net.IPAddress.Parse("0.0.0.0");
return System.Net.IPAddress.Parse(addrStr);
}
}
string addrStr = Marshal.PtrToStringAnsi(addrPtr);
Interop.Libc.Free(addrPtr);
- if (addrStr == null)
+ if (addrStr == null || addrStr.Length == 0)
return System.Net.IPAddress.Parse("0.0.0.0");
return System.Net.IPAddress.Parse(addrStr);
}
}
string addrStr = Marshal.PtrToStringAnsi(addrPtr);
Interop.Libc.Free(addrPtr);
- if (addrStr == null)
+ if (addrStr == null || addrStr.Length == 0)
return System.Net.IPAddress.Parse("0.0.0.0");
return System.Net.IPAddress.Parse(addrStr);
}
}
string addrStr = Marshal.PtrToStringAnsi(addrPtr);
Interop.Libc.Free(addrPtr);
- if (addrStr == null)
+ if (addrStr == null || addrStr.Length == 0)
return System.Net.IPAddress.Parse("0.0.0.0");
return System.Net.IPAddress.Parse(addrStr);
}
Log.Error(Globals.LogTag, "Failed to get DHCP server address, Error - " + (WiFiError)ret);
}
- if (dhcpServer == null)
+ if (dhcpServer == null || dhcpServer.Length == 0)
{
return IPAddress.Parse("0.0.0.0");
}
if (ipv6Address != IntPtr.Zero)
{
string ipv6 = Marshal.PtrToStringAnsi(ipv6Address);
- ipList.Add(System.Net.IPAddress.Parse(ipv6));
+ if (ipv6.Length == 0)
+ ipList.Add(System.Net.IPAddress.Parse("::"));
+ else
+ ipList.Add(System.Net.IPAddress.Parse(ipv6));
return true;
}
return false;