77 lines
1.9 KiB
C#
77 lines
1.9 KiB
C#
using System;
|
|
using System.Runtime.InteropServices;
|
|
|
|
namespace Steamworks
|
|
{
|
|
[Serializable]
|
|
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
|
public struct SteamNetworkingIPAddr : IEquatable<SteamNetworkingIPAddr>
|
|
{
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
|
|
public byte[] m_ipv6;
|
|
|
|
public ushort m_port;
|
|
|
|
public const int k_cchMaxString = 48;
|
|
|
|
public void Clear()
|
|
{
|
|
NativeMethods.SteamAPI_SteamNetworkingIPAddr_Clear(ref this);
|
|
}
|
|
|
|
public bool IsIPv6AllZeros()
|
|
{
|
|
return NativeMethods.SteamAPI_SteamNetworkingIPAddr_IsIPv6AllZeros(ref this);
|
|
}
|
|
|
|
public void SetIPv6(byte[] ipv6, ushort nPort)
|
|
{
|
|
NativeMethods.SteamAPI_SteamNetworkingIPAddr_SetIPv6(ref this, ipv6, nPort);
|
|
}
|
|
|
|
public void SetIPv4(uint nIP, ushort nPort)
|
|
{
|
|
NativeMethods.SteamAPI_SteamNetworkingIPAddr_SetIPv4(ref this, nIP, nPort);
|
|
}
|
|
|
|
public bool IsIPv4()
|
|
{
|
|
return NativeMethods.SteamAPI_SteamNetworkingIPAddr_IsIPv4(ref this);
|
|
}
|
|
|
|
public uint GetIPv4()
|
|
{
|
|
return NativeMethods.SteamAPI_SteamNetworkingIPAddr_GetIPv4(ref this);
|
|
}
|
|
|
|
public void SetIPv6LocalHost(ushort nPort = 0)
|
|
{
|
|
NativeMethods.SteamAPI_SteamNetworkingIPAddr_SetIPv6LocalHost(ref this, nPort);
|
|
}
|
|
|
|
public bool IsLocalHost()
|
|
{
|
|
return NativeMethods.SteamAPI_SteamNetworkingIPAddr_IsLocalHost(ref this);
|
|
}
|
|
|
|
public void ToString(out string buf, bool bWithPort)
|
|
{
|
|
IntPtr intPtr = Marshal.AllocHGlobal(48);
|
|
NativeMethods.SteamAPI_SteamNetworkingIPAddr_ToString(ref this, intPtr, 48u, bWithPort);
|
|
buf = InteropHelp.PtrToStringUTF8(intPtr);
|
|
Marshal.FreeHGlobal(intPtr);
|
|
}
|
|
|
|
public bool ParseString(string pszStr)
|
|
{
|
|
using InteropHelp.UTF8StringHandle pszStr2 = new InteropHelp.UTF8StringHandle(pszStr);
|
|
return NativeMethods.SteamAPI_SteamNetworkingIPAddr_ParseString(ref this, pszStr2);
|
|
}
|
|
|
|
public bool Equals(SteamNetworkingIPAddr x)
|
|
{
|
|
return NativeMethods.SteamAPI_SteamNetworkingIPAddr_IsEqualTo(ref this, ref x);
|
|
}
|
|
}
|
|
}
|