(SIGAR-199) add Java ArpList binding

This commit is contained in:
Doug MacEachern 2010-01-18 15:01:02 -08:00
parent e804a1b405
commit 9207af5536
2 changed files with 34 additions and 0 deletions

View File

@ -1045,6 +1045,37 @@ JNIEXPORT jstring SIGAR_JNI(NetConnection_getStateString)
sigar_net_connection_state_get(state)); 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; i<arplist.number; i++) {
jobject info_obj = JENV->AllocObject(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) JNIEXPORT jobjectArray SIGAR_JNIx(getWhoList)
(JNIEnv *env, jobject sigar_obj) (JNIEnv *env, jobject sigar_obj)
{ {

View File

@ -808,6 +808,9 @@ public class Sigar implements SigarProxy {
return netstat; return netstat;
} }
public native Arp[] getArpList()
throws SigarException;
public native Who[] getWhoList() public native Who[] getWhoList()
throws SigarException; throws SigarException;