Skip to content

Commit

Permalink
Fix compile-time errors for C# binding on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
joseph-henry committed May 11, 2021
1 parent 1ea88d0 commit 64fe1d0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 34 deletions.
8 changes: 4 additions & 4 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@ function Build-All

function BuildNuGetPackages([string]$Version)
{
BuildNuGetPackage-Sockets -BuildType "Release" -Arch "x64" -Version $Version
BuildNuGetPackage-Sockets -BuildType "Debug" -Arch "x64" -Version $Version
BuildNuGetPackage-Sockets -BuildType "Release" -Arch "Win32" -Version $Version
BuildNuGetPackage-Sockets -BuildType "Debug" -Arch "Win32" -Version $Version
BuildNuGetPackage -BuildType "Release" -Arch "x64" -Version $Version
BuildNuGetPackage -BuildType "Debug" -Arch "x64" -Version $Version
BuildNuGetPackage -BuildType "Release" -Arch "Win32" -Version $Version
BuildNuGetPackage -BuildType "Debug" -Arch "Win32" -Version $Version
}

function BuildNuGetPackage([string]$BuildType, [string]$Arch, [string]$Version)
Expand Down
19 changes: 7 additions & 12 deletions src/bindings/csharp/Node.cs
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ void OnZeroTierEvent(IntPtr msgPtr)
newEvent.NetworkInfo = ni;
newEvent.NetworkInfo.Id = net_info.net_id;
newEvent.NetworkInfo.MACAddress = net_info.mac;
newEvent.NetworkInfo.Name = System.Text.Encoding.Default.GetString(net_info.name);
newEvent.NetworkInfo.Name = System.Text.Encoding.UTF8.GetString(net_info.name);
newEvent.NetworkInfo.Status = net_info.status;
newEvent.NetworkInfo.Type = net_info.type;
newEvent.NetworkInfo.MTU = net_info.mtu;
Expand Down Expand Up @@ -581,7 +581,7 @@ public string Version
}

[DllImport("libzt", CharSet = CharSet.Ansi, EntryPoint = "CSharp_zts_id_new")] static extern int
zts_id_new(string arg1, global::System.Runtime.InteropServices.HandleRef arg2);
zts_id_new(string arg1, IntPtr arg2);

[DllImport("libzt", CharSet = CharSet.Ansi, EntryPoint = "CSharp_zts_id_pair_is_valid")]
static extern int zts_id_pair_is_valid(string arg1, int arg2);
Expand Down Expand Up @@ -660,24 +660,19 @@ static extern int zts_core_query_route(
static extern int zts_addr_is_assigned(ulong arg1, int arg2);

[DllImport("libzt", EntryPoint = "CSharp_zts_addr_get")]
static extern int zts_addr_get(ulong arg1, int arg2, global::System.Runtime.InteropServices.HandleRef arg3);
static extern int zts_addr_get(ulong arg1, int arg2, IntPtr arg3);

[DllImport("libzt", CharSet = CharSet.Ansi, EntryPoint = "CSharp_zts_addr_get_str")]
static extern int zts_addr_get_str(ulong arg1, int arg2, IntPtr arg3, int arg4);

[DllImport("libzt", EntryPoint = "CSharp_zts_addr_get_all")]
static extern int zts_addr_get_all(
ulong arg1,
global::System.Runtime.InteropServices.HandleRef arg2,
global::System.Runtime.InteropServices.HandleRef arg3);
static extern int zts_addr_get_all(ulong arg1, IntPtr arg2, IntPtr arg3);

[DllImport("libzt", EntryPoint = "CSharp_zts_addr_compute_6plane")]
static extern int
zts_addr_compute_6plane(ulong arg1, ulong arg2, global::System.Runtime.InteropServices.HandleRef arg3);
static extern int zts_addr_compute_6plane(ulong arg1, ulong arg2, IntPtr arg3);

[DllImport("libzt", EntryPoint = "CSharp_zts_addr_compute_rfc4193")]
static extern int
zts_addr_compute_rfc4193(ulong arg1, ulong arg2, global::System.Runtime.InteropServices.HandleRef arg3);
static extern int zts_addr_compute_rfc4193(ulong arg1, ulong arg2, IntPtr arg3);

[DllImport("libzt", CharSet = CharSet.Ansi, EntryPoint = "CSharp_zts_addr_compute_rfc4193_str")]
static extern int zts_addr_compute_rfc4193_str(ulong arg1, ulong arg2, string arg3, int arg4);
Expand Down Expand Up @@ -745,7 +740,7 @@ static extern int
public static extern ulong zts_node_get_id();

[DllImport("libzt", CharSet = CharSet.Ansi, EntryPoint = "CSharp_zts_node_get_id_pair")]
static extern int zts_node_get_id_pair(string arg1, global::System.Runtime.InteropServices.HandleRef arg2);
static extern int zts_node_get_id_pair(string arg1, IntPtr arg2);

[DllImport("libzt", EntryPoint = "CSharp_zts_node_get_port")]
static extern int zts_node_get_port();
Expand Down
22 changes: 4 additions & 18 deletions src/bindings/csharp/Socket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -490,12 +490,7 @@ public EndPoint LocalEndPoint
zts_bsd_gethostbyname(string jarg1);

[DllImport("libzt", EntryPoint = "CSharp_zts_bsd_select")]
static extern int zts_bsd_select(
int jarg1,
global::System.Runtime.InteropServices.HandleRef jarg2,
global::System.Runtime.InteropServices.HandleRef jarg3,
global::System.Runtime.InteropServices.HandleRef jarg4,
global::System.Runtime.InteropServices.HandleRef jarg5);
static extern int zts_bsd_select(int jarg1, IntPtr jarg2, IntPtr jarg3, IntPtr jarg4, IntPtr jarg5);

[DllImport("libzt", EntryPoint = "CSharp_zts_get_all_stats")]
static extern int zts_get_all_stats(IntPtr arg1);
Expand Down Expand Up @@ -663,12 +658,7 @@ static extern int zts_bsd_select(
static extern int zts_tcp_client(string jarg1, int jarg2);

[DllImport("libzt", CharSet = CharSet.Ansi, EntryPoint = "CSharp_zts_tcp_server")]
static extern int zts_tcp_server(
string jarg1,
int jarg2,
string jarg3,
int jarg4,
global::System.Runtime.InteropServices.HandleRef jarg5);
static extern int zts_tcp_server(string jarg1, int jarg2, string jarg3, int jarg4, IntPtr jarg5);

[DllImport("libzt", CharSet = CharSet.Ansi, EntryPoint = "CSharp_zts_udp_server")]
static extern int zts_udp_server(string jarg1, int jarg2);
Expand All @@ -683,7 +673,7 @@ static extern int zts_tcp_server(
static extern int zts_connect(int jarg1, string jarg2, int jarg3, int jarg4);

[DllImport("libzt", EntryPoint = "CSharp_zts_stats_get_all")]
static extern int zts_stats_get_all(global::System.Runtime.InteropServices.HandleRef jarg1);
static extern int zts_stats_get_all(IntPtr jarg1);

/*
[DllImport("libzt", EntryPoint = "CSharp_zts_set_no_delay")]
Expand Down Expand Up @@ -760,11 +750,7 @@ static extern int zts_tcp_server(
static extern int zts_util_get_ip_family(string jarg1);

[DllImport("libzt", CharSet = CharSet.Ansi, EntryPoint = "CSharp_zts_util_ipstr_to_saddr")]
static extern int zts_util_ipstr_to_saddr(
string jarg1,
int jarg2,
global::System.Runtime.InteropServices.HandleRef jarg3,
global::System.Runtime.InteropServices.HandleRef jarg4);
static extern int zts_util_ipstr_to_saddr(string jarg1, int jarg2, IntPtr jarg3, IntPtr jarg4);

/// <value>The value of errno for the low-level socket layer</value>
public static int ErrNo
Expand Down

0 comments on commit 64fe1d0

Please sign in to comment.