From 9207af5536d466e2af2dbac019cf0a5e43102271 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Mon, 18 Jan 2010 15:01:02 -0800 Subject: [PATCH] (SIGAR-199) add Java ArpList binding --- bindings/java/src/jni/javasigar.c | 31 +++++++++++++++++++ .../java/src/org/hyperic/sigar/Sigar.java | 3 ++ 2 files changed, 34 insertions(+) diff --git a/bindings/java/src/jni/javasigar.c b/bindings/java/src/jni/javasigar.c index 45dd0e26..59705fcc 100644 --- a/bindings/java/src/jni/javasigar.c +++ b/bindings/java/src/jni/javasigar.c @@ -1045,6 +1045,37 @@ JNIEXPORT jstring SIGAR_JNI(NetConnection_getStateString) sigar_net_connection_state_get(state)); } +JNIEXPORT jobjectArray SIGAR_JNIx(getArpList) +(JNIEnv *env, jobject sigar_obj) +{ + int status; + unsigned int i; + sigar_arp_list_t arplist; + jobjectArray arparray; + jclass cls = SIGAR_FIND_CLASS("Arp"); + dSIGAR(NULL); + + if ((status = sigar_arp_list_get(sigar, &arplist)) != SIGAR_OK) { + sigar_throw_error(env, jsigar, status); + return NULL; + } + + JAVA_SIGAR_INIT_FIELDS_ARP(cls); + + arparray = JENV->NewObjectArray(env, arplist.number, cls, 0); + + for (i=0; iAllocObject(env, cls); + JAVA_SIGAR_SET_FIELDS_ARP(cls, info_obj, + arplist.data[i]); + JENV->SetObjectArrayElement(env, arparray, i, info_obj); + } + + sigar_arp_list_destroy(sigar, &arplist); + + return arparray; +} + JNIEXPORT jobjectArray SIGAR_JNIx(getWhoList) (JNIEnv *env, jobject sigar_obj) { diff --git a/bindings/java/src/org/hyperic/sigar/Sigar.java b/bindings/java/src/org/hyperic/sigar/Sigar.java index a83914d2..2408646e 100644 --- a/bindings/java/src/org/hyperic/sigar/Sigar.java +++ b/bindings/java/src/org/hyperic/sigar/Sigar.java @@ -808,6 +808,9 @@ public class Sigar implements SigarProxy { return netstat; } + public native Arp[] getArpList() + throws SigarException; + public native Who[] getWhoList() throws SigarException;