jicmp 1.0.5 and later dont work under win2k/xp

Description

Error with precompiled 1.0.5-win32 and self-compiled 1.0.6 and svn-trunk:

[DEBUG] System property 'opennms.library.jicmp' set to 'H:_workspace_/icmp_monitor/jicmp.dll. Attempting to load jicmp library from this location.
[INFO] Successfully loaded jicmp library.
Exception in thread "main" java.net.SocketException: Could not get protocol entry for 'icmp'. The getprotobyname("icmp") system call returned NULL.
at org.opennms.protocols.icmp.IcmpSocket.initSocket(Native Method)
at org.opennms.protocols.icmp.IcmpSocket.<init>(IcmpSocket.java:107)
at org.opennms.netmgt.ping.Pinger.initialize(Pinger.java:111)
at org.opennms.netmgt.ping.Pinger.<init>(Pinger.java:105)
at planetng.daemon.monitor.icmp.IcmpDaemon.init(IcmpDaemon.java:45)
at planetng.daemon.monitor.icmp.IcmpDaemon.init(IcmpDaemon.java:50)
at planetng.daemon.monitor.icmp.IcmpDaemon.main(IcmpDaemon.java:136)

i looked thru the code and found a small shortcoming that is required on win32:

JNIEXPORT void JNICALL
Java_org_opennms_protocols_icmp_IcmpSocket_initSocket (JNIEnv *env, jobject instance)
{
#ifdef _WIN32_
WSADATA info;
WSAStartup(MAKEWORD(1,1), &info);
int icmp_fd = socket(AF_INET, SOCK_RAW, 1);
#else
struct protoent *proto;

proto = getprotobyname("icmp");
if (proto == (struct protoent *) NULL) {
char errBuf[128]; /* for exceptions */
jclass ioException = (*env)->FindClass(env, "java/net/SocketException");
if(ioException != NULL)
{
sprintf(errBuf, "Could not get protocol entry for 'icmp'. The getprotobyname(\"icmp\") system call returned NULL.");
(*env)->ThrowNew(env, ioException, (char *)errBuf);
}
return;
}

int icmp_fd = socket(AF_INET, SOCK_RAW, proto->p_proto);
#endif
...

this fix has been tested with 1.0.6 and svn source under msys/mingw32/gcc-3.4.5

Environment

Operating System: Windows 2000 Platform: PC

Acceptance / Success Criteria

None

Attachments

1
  • 20 Dec 2007, 08:40 AM

Lucidchart Diagrams

Activity

Show:

Benjamin Reed February 6, 2008 at 8:34 AM

cmake should work with mingw as well (it has mingw and msys generators) but I don't have the environment set up to test it.

Alfred Reibenschuh February 6, 2008 at 5:53 AM

does that mean that i need M$-VS 2k8 to build or can i continue to use mingw?

Benjamin Reed February 5, 2008 at 3:41 PM

alright, committed to revision 8353, thanks!

In the process, I ported everything to cmake, to make it a bit easier to build/etc. in the future. I don't have my mingw environment anymore, but I was able to test against visual studio express 2008.

Jeff Gehlbach December 20, 2007 at 8:53 AM

Moving assignment to Ben's OpenNMS address

Jeff Gehlbach December 20, 2007 at 8:52 AM

Thanks, Alfred. It almost makes me nostalgic for the last time I had to muck with WSAStartup

I'm marking this as a 1.3.10 blocker since it totally kills us on NT. Assigning to Ben since he's the only one I'm aware of with an NT build environment.

Fixed

Details

Assignee

Reporter

Components

Fix versions

Affects versions

Priority

PagerDuty

Created December 20, 2007 at 7:55 AM
Updated January 27, 2017 at 4:31 PM
Resolved September 6, 2010 at 4:34 PM