Skip to content

Instantly share code, notes, and snippets.

@angad
Created May 11, 2011 15:13
Show Gist options
  • Save angad/966643 to your computer and use it in GitHub Desktop.
Save angad/966643 to your computer and use it in GitHub Desktop.
Native JNI libpcap
#include <jni.h>
#include <string.h>
#include <android/log.h>
#include <pcap.h>
#define DEBUG_TAG "Sample_LIBPCAP_DEBUGGING"
void Java_com_umit_android_libpcap_libpcap_testLog(JNIEnv * env, jobject this, jstring logThis)
{
jboolean isCopy;
char *dev, errbuf[100];
char * szLogThis;
dev = pcap_lookupdev(errbuf);
if (dev == NULL) {
szLogThis = "Couldn't find default device";
}
else szLogThis = dev;
__android_log_print(ANDROID_LOG_DEBUG, DEBUG_TAG, "NDK:LC: [%s]", szLogThis);
(*env)->ReleaseStringUTFChars(env, logThis, szLogThis);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment