dotpcap / sharppcap

Official repository - Fully managed, cross platform (Windows, Mac, Linux) .NET library for capturing packets
1.33k stars 268 forks source link

libpcap function pcap_findalldevs_ex is only supported in windows #41

Closed zamiramos closed 5 years ago

zamiramos commented 6 years ago

Cannot run in Linux because some functions are only exported in windows:

Unhandled Exception: System.EntryPointNotFoundException: Unable to find an entry point named 'pcap_findalldevs_ex' in DLL 'wpcap'. at SharpPcap.WinPcap.SafeNativeMethods.pcap_findalldevs_ex(String source, IntPtr auth, IntPtr& alldevs, StringBuilder errbuf) at SharpPcap.WinPcap.WinPcapDeviceList.Devices(String rpcapString, RemoteAuthentication remoteAuthentication) at SharpPcap.WinPcap.WinPcapDeviceList.GetDevices() at SharpPcap.WinPcap.WinPcapDeviceList.Refresh() at SharpPcap.WinPcap.WinPcapDeviceList..ctor() at SharpPcap.WinPcap.WinPcapDeviceList.get_Instance()

Here the full list: https://www.winpcap.org/docs/docs_40_2/html/group__wpcapfunc.html

In addition the native library wpcap need to be change to pcap in order to match Linux OS.

Thanks, Amos.

chmorgan commented 6 years ago

Hello.

Have you included a SharpPcap.dll.config file that defines the mapping from wpcap to libpcap? There should be an example in the source and binary packages.

Chris

On Mon, Apr 9, 2018 at 7:07 AM zamiramos notifications@github.com wrote:

Cannot run in Linux because some functions are only exported in windows:

Unhandled Exception: System.EntryPointNotFoundException: Unable to find an entry point named 'pcap_findalldevs_ex' in DLL 'wpcap'. at SharpPcap.WinPcap.SafeNativeMethods.pcap_findalldevs_ex(String source, IntPtr auth, IntPtr& alldevs, StringBuilder errbuf) at SharpPcap.WinPcap.WinPcapDeviceList.Devices(String rpcapString, RemoteAuthentication remoteAuthentication) at SharpPcap.WinPcap.WinPcapDeviceList.GetDevices() at SharpPcap.WinPcap.WinPcapDeviceList.Refresh() at SharpPcap.WinPcap.WinPcapDeviceList..ctor() at SharpPcap.WinPcap.WinPcapDeviceList.get_Instance()

Here the full list: https://www.winpcap.org/docs/docs_40_2/html/group__wpcapfunc.html

In addition the native library wpcap need to be change to pcap in order to match Linux OS.

Thanks, Amos.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/chmorgan/sharppcap/issues/41, or mute the thread https://github.com/notifications/unsubscribe-auth/ABJ-AE1M_US-ukvLAC8zpKOC0f9ftg6fks5tm0DWgaJpZM4TMWeG .

zamiramos commented 6 years ago

Hi Chris,

Thank you for reply.

I assume that you refer to run it under Mono but I run it with Dot.Net Standard/Core.

I'll fork from master and try to find alternatives to windows only extensions.

Thanks, Amos.

2018-04-09 23:36 GMT+03:00 Chris Morgan notifications@github.com:

Hello.

Have you included a SharpPcap.dll.config file that defines the mapping from wpcap to libpcap? There should be an example in the source and binary packages.

Chris

On Mon, Apr 9, 2018 at 7:07 AM zamiramos notifications@github.com wrote:

Cannot run in Linux because some functions are only exported in windows:

Unhandled Exception: System.EntryPointNotFoundException: Unable to find an entry point named 'pcap_findalldevs_ex' in DLL 'wpcap'. at SharpPcap.WinPcap.SafeNativeMethods.pcap_findalldevs_ex(String source, IntPtr auth, IntPtr& alldevs, StringBuilder errbuf) at SharpPcap.WinPcap.WinPcapDeviceList.Devices(String rpcapString, RemoteAuthentication remoteAuthentication) at SharpPcap.WinPcap.WinPcapDeviceList.GetDevices() at SharpPcap.WinPcap.WinPcapDeviceList.Refresh() at SharpPcap.WinPcap.WinPcapDeviceList..ctor() at SharpPcap.WinPcap.WinPcapDeviceList.get_Instance()

Here the full list: https://www.winpcap.org/docs/docs_40_2/html/group__wpcapfunc.html

In addition the native library wpcap need to be change to pcap in order to match Linux OS.

Thanks, Amos.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/chmorgan/sharppcap/issues/41, or mute the thread https://github.com/notifications/unsubscribe-auth/ABJ-AE1M_US- ukvLAC8zpKOC0f9ftg6fks5tm0DWgaJpZM4TMWeG .

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/chmorgan/sharppcap/issues/41#issuecomment-379885856, or mute the thread https://github.com/notifications/unsubscribe-auth/AXwamhi5VVjnXK2hfmiPaf5GKZX-y4pGks5tm8ZNgaJpZM4TMWeG .

chmorgan commented 6 years ago

Does dotnet provide a mechanism to map dlls? The goal of course is a single assembly that can be used across platforms.

On Tue, Apr 10, 2018 at 4:23 AM, zamiramos notifications@github.com wrote:

Hi Chris,

Thank you for reply.

I assume that you refer to run it under Mono but I run it with Dot.Net Standard/Core.

I'll fork from master and try to find alternatives to windows only extensions.

Thanks, Amos.

2018-04-09 23:36 GMT+03:00 Chris Morgan notifications@github.com:

Hello.

Have you included a SharpPcap.dll.config file that defines the mapping from wpcap to libpcap? There should be an example in the source and binary packages.

Chris

On Mon, Apr 9, 2018 at 7:07 AM zamiramos notifications@github.com wrote:

Cannot run in Linux because some functions are only exported in windows:

Unhandled Exception: System.EntryPointNotFoundException: Unable to find an entry point named 'pcap_findalldevs_ex' in DLL 'wpcap'. at SharpPcap.WinPcap.SafeNativeMethods.pcap_findalldevs_ex(String source, IntPtr auth, IntPtr& alldevs, StringBuilder errbuf) at SharpPcap.WinPcap.WinPcapDeviceList.Devices(String rpcapString, RemoteAuthentication remoteAuthentication) at SharpPcap.WinPcap.WinPcapDeviceList.GetDevices() at SharpPcap.WinPcap.WinPcapDeviceList.Refresh() at SharpPcap.WinPcap.WinPcapDeviceList..ctor() at SharpPcap.WinPcap.WinPcapDeviceList.get_Instance()

Here the full list: https://www.winpcap.org/docs/docs_40_2/html/group__wpcapfunc.html

In addition the native library wpcap need to be change to pcap in order to match Linux OS.

Thanks, Amos.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/chmorgan/sharppcap/issues/41, or mute the thread https://github.com/notifications/unsubscribe-auth/ABJ-AE1M_US- ukvLAC8zpKOC0f9ftg6fks5tm0DWgaJpZM4TMWeG .

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <https://github.com/chmorgan/sharppcap/issues/41#issuecomment-379885856 , or mute the thread https://github.com/notifications/unsubscribe-auth/ AXwamhi5VVjnXK2hfmiPaf5GKZX-y4pGks5tm8ZNgaJpZM4TMWeG .

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/chmorgan/sharppcap/issues/41#issuecomment-380016650, or mute the thread https://github.com/notifications/unsubscribe-auth/ABJ-ALi4ATvx5v1oJ3zZTdKbbE1Z3arNks5tnGwbgaJpZM4TMWeG .

zamiramos commented 6 years ago

AFAIK no.

I think that the advanced feature which winpcap gives upon libpcap should be canceled automatically (by detecting OS) when run in Linux environment. (inspired from https://github.com/robertdavidgraham/isowall/blob/master/src/rawsock.c)

I want to try something buy I didn't find how you compile the source to .Net standard. Maybe I look at the wrong branch.

Where I can find the source code of https://www.nuget.org/packages/SharpPcap.Standard/4.4.0?

2018-04-10 13:51 GMT+03:00 Chris Morgan notifications@github.com:

Does dotnet provide a mechanism to map dlls? The goal of course is a single assembly that can be used across platforms.

On Tue, Apr 10, 2018 at 4:23 AM, zamiramos notifications@github.com wrote:

Hi Chris,

Thank you for reply.

I assume that you refer to run it under Mono but I run it with Dot.Net Standard/Core.

I'll fork from master and try to find alternatives to windows only extensions.

Thanks, Amos.

2018-04-09 23:36 GMT+03:00 Chris Morgan notifications@github.com:

Hello.

Have you included a SharpPcap.dll.config file that defines the mapping from wpcap to libpcap? There should be an example in the source and binary packages.

Chris

On Mon, Apr 9, 2018 at 7:07 AM zamiramos notifications@github.com wrote:

Cannot run in Linux because some functions are only exported in windows:

Unhandled Exception: System.EntryPointNotFoundException: Unable to find an entry point named 'pcap_findalldevs_ex' in DLL 'wpcap'. at SharpPcap.WinPcap.SafeNativeMethods.pcap_findalldevs_ex(String source, IntPtr auth, IntPtr& alldevs, StringBuilder errbuf) at SharpPcap.WinPcap.WinPcapDeviceList.Devices(String rpcapString, RemoteAuthentication remoteAuthentication) at SharpPcap.WinPcap.WinPcapDeviceList.GetDevices() at SharpPcap.WinPcap.WinPcapDeviceList.Refresh() at SharpPcap.WinPcap.WinPcapDeviceList..ctor() at SharpPcap.WinPcap.WinPcapDeviceList.get_Instance()

Here the full list: https://www.winpcap.org/docs/docs_40_2/html/group__wpcapfunc.html

In addition the native library wpcap need to be change to pcap in order to match Linux OS.

Thanks, Amos.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/chmorgan/sharppcap/issues/41, or mute the thread https://github.com/notifications/unsubscribe-auth/ABJ-AE1M_US- ukvLAC8zpKOC0f9ftg6fks5tm0DWgaJpZM4TMWeG .

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <https://github.com/chmorgan/sharppcap/issues/41# issuecomment-379885856 , or mute the thread https://github.com/notifications/unsubscribe-auth/ AXwamhi5VVjnXK2hfmiPaf5GKZX-y4pGks5tm8ZNgaJpZM4TMWeG .

— You are receiving this because you commented. Reply to this email directly, view it on GitHub <https://github.com/chmorgan/sharppcap/issues/41#issuecomment-380016650 , or mute the thread https://github.com/notifications/unsubscribe-auth/ABJ- ALi4ATvx5v1oJ3zZTdKbbE1Z3arNks5tnGwbgaJpZM4TMWeG

.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/chmorgan/sharppcap/issues/41#issuecomment-380057208, or mute the thread https://github.com/notifications/unsubscribe-auth/AXwamp4LC1veYDjim1yICCC3hngAYxMWks5tnI6igaJpZM4TMWeG .

chmorgan commented 6 years ago

It's a bit more complex to maintain multiple platform support but looks like it can be done via dynamic library loading. I'll probably be looking at that in the near future as dotnet has dropped support for dllmap and there isn't really another elegant way of doing it.

No idea what package that is, I'm not the publisher of it. I did just publish 4.5.0 which targets .net standard 2.0 if that's why that package is interesting to you.

chmorgan commented 5 years ago

Hi @zamiramos can you try the 4.6.0 release? That should address cross platform issues.