-
Notifications
You must be signed in to change notification settings - Fork 28
TCP support for Machnet, when non-machnet application connect a machnet application. #54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -71,7 +71,7 @@ static void Main(string[] args) | |
| { | ||
| // Client | ||
| MachnetFlow_t flow = new MachnetFlow_t(); | ||
| ret = MachnetShim.machnet_connect(channel_ctx, options.LocalIp, options.RemoteIp, kHelloWorldPort, ref flow); | ||
| ret = MachnetShim.machnet_connect(channel_ctx, options.LocalIp, options.RemoteIp, kHelloWorldPort, ref flow, 0); | ||
| CustomCheck(ret == 0, "machnet_connect()"); | ||
|
|
||
| string msg = "Hello World!"; | ||
|
|
@@ -84,7 +84,7 @@ static void Main(string[] args) | |
| else | ||
| { | ||
| Console.WriteLine("Waiting for message from client"); | ||
| ret = MachnetShim.machnet_listen(channel_ctx, options.LocalIp, kHelloWorldPort); | ||
| ret = MachnetShim.machnet_listen(channel_ctx, options.LocalIp, kHelloWorldPort, 0); | ||
|
||
| CustomCheck(ret == 0, "machnet_listen()"); | ||
|
|
||
| while (true) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,10 +21,10 @@ public static class MachnetShim | |
| public static extern IntPtr machnet_attach(); | ||
|
|
||
| [DllImport(libmachnet_shim_location, CallingConvention = CallingConvention.Cdecl)] | ||
| public static extern int machnet_listen(IntPtr channel_ctx, string local_ip, UInt16 port); | ||
| public static extern int machnet_listen(IntPtr channel_ctx, string local_ip, UInt16 port, int protocol); | ||
|
||
|
|
||
| [DllImport(libmachnet_shim_location, CallingConvention = CallingConvention.Cdecl)] | ||
| public static extern int machnet_connect(IntPtr channel_ctx, string local_ip, string remote_ip, UInt16 port, ref MachnetFlow_t flow); | ||
| public static extern int machnet_connect(IntPtr channel_ctx, string local_ip, string remote_ip, UInt16 port, ref MachnetFlow_t flow, int protocol); | ||
|
||
|
|
||
| [DllImport(libmachnet_shim_location, CallingConvention = CallingConvention.Cdecl)] | ||
| public static extern int machnet_send(IntPtr channel_ctx, MachnetFlow_t flow, byte[] data, IntPtr dataSize); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,13 +45,13 @@ MachnetFlow_t __machnet_recvmsg_go(const MachnetChannelCtx_t* ctx, | |
|
|
||
| int __machnet_connect_go(MachnetChannelCtx_t* ctx, uint32_t local_ip, | ||
| uint32_t remote_ip, uint16_t remote_port, | ||
| MachnetFlow_t* flow) { | ||
| return machnet_connect(ctx, local_ip, remote_ip, remote_port, flow); | ||
| MachnetFlow_t* flow, int protocol) { | ||
| return machnet_connect(ctx, local_ip, remote_ip, remote_port, flow, protocol); | ||
| } | ||
|
|
||
| int __machnet_listen_go(MachnetChannelCtx_t* ctx, uint32_t local_ip, | ||
| uint16_t port) { | ||
| return machnet_listen(ctx, local_ip, port); | ||
| uint16_t port, int protocol) { | ||
| return machnet_listen(ctx, local_ip, port, protocol); | ||
| } | ||
|
Comment on lines
46
to
55
|
||
|
|
||
| MachnetFlow_t* __machnet_init_flow() { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -151,7 +151,7 @@ pub fn machnet_attach<'a>() -> Option<MachnetChannel<'a>> { | |
| /// let remote_ip = "192.168.1.3"; | ||
| /// let remote_port = 8080; | ||
| /// | ||
| /// match machnet_connect(&mut channel, local_ip, remote_ip, remote_port) { | ||
| /// match machnet_connect(&mut channel, local_ip, remote_ip, remote_port, 0) { | ||
| /// Some(flow) => { | ||
| /// // Connection was successful, use `flow` here | ||
| /// } | ||
|
|
@@ -166,6 +166,7 @@ pub fn machnet_connect( | |
| local_ip: &str, | ||
| remote_ip: &str, | ||
| remote_port: u16, | ||
| protocol: i32, | ||
| ) -> Option<MachnetFlow> { | ||
| unsafe { | ||
| let channel_ptr = channel.get_ptr(); | ||
|
|
@@ -180,6 +181,7 @@ pub fn machnet_connect( | |
| remote_ip_cstr.as_ptr(), | ||
| remote_port, | ||
| flow_ptr, // &mut flow, | ||
| protocol, | ||
| ); | ||
|
|
||
| match res { | ||
|
|
@@ -226,11 +228,11 @@ pub fn machnet_connect( | |
| /// } | ||
| /// ``` | ||
| /// | ||
| pub fn machnet_listen(channel: &mut MachnetChannel, local_ip: &str, local_port: u16) -> i32 { | ||
| pub fn machnet_listen(channel: &mut MachnetChannel, local_ip: &str, local_port: u16, protocol: i32) -> i32 { | ||
| unsafe { | ||
| let channel_ptr = channel.get_ptr(); | ||
| let local_ip_cstr = CString::new(local_ip).unwrap(); | ||
| bindings::machnet_listen(channel_ptr, local_ip_cstr.as_ptr(), local_port) | ||
| bindings::machnet_listen(channel_ptr, local_ip_cstr.as_ptr(), local_port, protocol) | ||
|
Comment on lines
+231
to
+235
|
||
| } | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace this call with a call to managed code if possible.