4.0.3 level 15 입니다...

libpcap는 최신 버전은 1.2.1 입니다..

윈도우 환경이기 때문에 cygwin 으로 했어요!

 

 

 

다음과 같은 에러가 나는데.. 미칠 것만 같아요 ㅠ_ㅜ 도와주세요.. 흑흑

 

 

 제목 없음.png 

 

이렇게 구성 하였습니다...

 

저의 생각으로는 Android.mk파일이 잘못 되었는지.. libpcap-native.c 에서 include 해야 하는 헤더 파일들을 읽어 오지 못하는 것 같아요..  

 

왜냐면 pcacplookupdev라는 메쏘드는 pcacp.h 에 분명 선언 되어 있는걸 확인 했고, libpcap-native.c 에도 include 해놨는데.... ㅠ_ㅜ

 

밑에 저의 Android.mk와 libpcap-native.c 와  .java 파일 그리고 libpcap-ntive.c의 원형 .h 파일 함께 올립니다아...

 

 

 

LOCAL_PATH :=./jni

include $(CLEAR_VARS) 
LOCAL_MODULE    := pcaptest 
LOCAL_SRC_FILES := libpcap-native.c 
LOCAL_C_INCLUDES :=$(LOCAL_PATH)/libpcap
LOCAL_STATIC_LIBRARIES := libpcap 

LOCAL_LDLIBS := -ldl -llog 

include $(BUILD_SHARED_LIBRARY)  

include $(LOCAL_PATH)/libpcap/Android.mk 

-------------------------------------------------------------------libpcap-native.c

#include <jni.h> 
#include <string.h> 
#include <android/log.h> 
#include <pcap.h> 

#define DEBUG_TAG "Sample_LIBPCAP_DEBUGGING" 

void Java_org_umit_android_libpcaptest_libpcaptest_testLog(JNIEnv *env, jclass clazz, jstring message) 

    char errbuf[1024]; 
    errbuf[0] = '\0'; 

    char *szLogThis; 
    char *dev = pcap_lookupdev(errbuf); 

    if (dev == NULL) { 
        szLogThis = "Couldn't find default device";      
    } 
    else szLogThis = dev; 

    __android_log_print(ANDROID_LOG_DEBUG, DEBUG_TAG, "Device status: [%s]", szLogThis); 
    __android_log_print(ANDROID_LOG_DEBUG, DEBUG_TAG, "errbuf [%s]", errbuf); 

    (*env)->ReleaseStringUTFChars(env, message, szLogThis); 
}

 

 

----------------------------------------------.java

 

package org.umit.android.libpcaptest;

import android.app.Activity;
import android.os.Bundle;

public class libpcaptest extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
   
    static{ 
        System.loadLibrary("pcaptest"); 
    } 

    private native void testLog(String logThis);
}

 

--------------------------------------------------------------------------원형.h

/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class org_umit_android_libpcaptest_libpcaptest */

#ifndef _Included_org_umit_android_libpcaptest_libpcaptest
#define _Included_org_umit_android_libpcaptest_libpcaptest
#ifdef __cplusplus
extern "C" {
#endif
/*
 * Class:     org_umit_android_libpcaptest_libpcaptest
 * Method:    testLog
 * Signature: (Ljava/lang/String;)V
 */
JNIEXPORT void JNICALL Java_org_umit_android_libpcaptest_libpcaptest_testLog
  (JNIEnv *, jobject, jstring);

#ifdef __cplusplus
}
#endif
#endif