Bonjour,

Le problème est que mon code n'arrive pas à accéder aux classes de la bibliothèque JNetPcap meme si je l'ai ajouté au projet en tant que "user library" ce qui a été indiqué dans le site officiel du Framework. http://jnetpcap.com/eclipse

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
 
import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.SocketException;
import java.net.UnknownHostException;
import java.util.List;
 
import org.jnetpcap.PcapIf;
import org.jnetpcap.packet.JMemoryPacket;
import org.jnetpcap.packet.JPacket;
import org.jnetpcap.protocol.JProtocol;
 
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
 
public class Server_Android extends Activity{
 
    private final static int SERVER_PORT = 1234;
//    public final static int RECEIVING_TIMEOUT_SERVER = 3000;
    DatagramSocket socket;
    DatagramPacket packetOut;
    DatagramPacket packetIn;
    byte[] DataIn;
    byte[] DataOut;
    List<PcapIf> alldevs;
    StringBuilder errbuf;
 
    /*Android widgets*/
    TextView text;
    EditText edit;
    Button button;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
 
        setContentView(R.layout.activity_server_android);
        //text = (EditText)
        button =(Button)findViewById(R.id.button1);
        edit = (EditText)findViewById(R.id.editText1);
        text =(TextView)findViewById(R.id.textView2);   
        text.setText("");
 
        handlingpacket();
 
        /* Thread for receiving Data from CLient */
        new Thread(new Message_handler()).start();
            try {   
        Thread.sleep(500);
        reply();
        }catch(InterruptedException e){
            Log.e("UDP", "UDP receive failed!");
        }
 
    }
 
//  
    public void handlingpacket(){
 
        JPacket jmp = new JMemoryPacket(JProtocol.UDP_ID,
                  "001801bf 6adc0025 4bb7afec 08004500 "  
                + " 0041a983 40004006 d69ac0a8 00342f8c "  
                + " ca30c3ef 008f2e80 11f52ea8 4b578018 "  
                + " ffffa6ea 00000101 080a152e ef03002a "  
                + " 2c943538 322e3430 204e4f4f 500d0a");
        text.append("" + jmp);
 
    }
//  
    public class Message_handler implements Runnable{
 
            public Message_handler(){}
 
            public void run(){
 
            try {
                DataOut = new byte[1024];
 
            while(true){
 
                    socket = new DatagramSocket(SERVER_PORT);
                    socket.setReuseAddress(true);
                    socket.setBroadcast(true);
        //          socket.setSoTimeout(RECEIVING_TIMEOUT_SERVER);
                    packetIn = new DatagramPacket(DataOut,DataOut.length);          
                    socket.receive(packetIn);
 
                        runOnUiThread( new Runnable(){ // original thread for UI interactions
 
                                public void run(){
                                    String message = new String(packetIn.getData());
                                    text.append("Message " + message +"\n From :" + packetIn.getAddress() + " on port : "+  packetIn.getPort() +"\n");
                                    Log.d("UDP", "le message reçu");
                                    Log.d("Message : ", "" + message);  
 
                                }
                        });
 
 
                }
            }
                catch(UnknownHostException exc) {
                    exc.printStackTrace();
                }
                catch(SocketException exc) {
                    System.out.println("Problem openning socket");
                }
                catch(IOException exc) {
                    System.out.println("Problem in reception of messages");
                }
 
            socket.close();
 
            }
 
        }
}
Voilà le fichier Log:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
 
08-21 11:43:01.950: W/dalvikvm(1350): No implementation found for native Lcom/slytechs/library/NativeLibrary;.dlopen (Ljava/lang/String;)J
08-21 11:43:01.950: W/dalvikvm(1350): Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lorg/jnetpcap/nio/JMemory;
08-21 11:43:01.950: D/AndroidRuntime(1350): Shutting down VM
08-21 11:43:01.950: W/dalvikvm(1350): threadid=1: thread exiting with uncaught exception (group=0x40a2d1f8)
08-21 11:43:01.950: E/AndroidRuntime(1350): FATAL EXCEPTION: main
08-21 11:43:01.950: E/AndroidRuntime(1350): java.lang.ExceptionInInitializerError
08-21 11:43:01.950: E/AndroidRuntime(1350): 	at com.example.server_android.Server_Android.handlingpacket(Server_Android.java:71)
08-21 11:43:01.950: E/AndroidRuntime(1350): 	at com.example.server_android.Server_Android.onCreate(Server_Android.java:51)
08-21 11:43:01.950: E/AndroidRuntime(1350): 	at android.app.Activity.performCreate(Activity.java:4465)
08-21 11:43:01.950: E/AndroidRuntime(1350): 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
08-21 11:43:01.950: E/AndroidRuntime(1350): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2033)
08-21 11:43:01.950: E/AndroidRuntime(1350): 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2104)
08-21 11:43:01.950: E/AndroidRuntime(1350): 	at android.app.ActivityThread.access$600(ActivityThread.java:132)
08-21 11:43:01.950: E/AndroidRuntime(1350): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1157)
08-21 11:43:01.950: E/AndroidRuntime(1350): 	at android.os.Handler.dispatchMessage(Handler.java:99)
08-21 11:43:01.950: E/AndroidRuntime(1350): 	at android.os.Looper.loop(Looper.java:137)
08-21 11:43:01.950: E/AndroidRuntime(1350): 	at android.app.ActivityThread.main(ActivityThread.java:4575)
08-21 11:43:01.950: E/AndroidRuntime(1350): 	at java.lang.reflect.Method.invokeNative(Native Method)
08-21 11:43:01.950: E/AndroidRuntime(1350): 	at java.lang.reflect.Method.invoke(Method.java:511)
08-21 11:43:01.950: E/AndroidRuntime(1350): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
08-21 11:43:01.950: E/AndroidRuntime(1350): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
08-21 11:43:01.950: E/AndroidRuntime(1350): 	at dalvik.system.NativeStart.main(Native Method)
08-21 11:43:01.950: E/AndroidRuntime(1350): Caused by: java.lang.UnsatisfiedLinkError: dlopen
08-21 11:43:01.950: E/AndroidRuntime(1350): 	at com.slytechs.library.NativeLibrary.dlopen(Native Method)
08-21 11:43:01.950: E/AndroidRuntime(1350): 	at com.slytechs.library.NativeLibrary.<init>(Unknown Source)
08-21 11:43:01.950: E/AndroidRuntime(1350): 	at com.slytechs.library.JNILibrary.<init>(Unknown Source)
08-21 11:43:01.950: E/AndroidRuntime(1350): 	at com.slytechs.library.JNILibrary.loadLibrary(Unknown Source)
08-21 11:43:01.950: E/AndroidRuntime(1350): 	at com.slytechs.library.JNILibrary.register(Unknown Source)
08-21 11:43:01.950: E/AndroidRuntime(1350): 	at com.slytechs.library.JNILibrary.register(Unknown Source)
08-21 11:43:01.950: E/AndroidRuntime(1350): 	at com.slytechs.library.JNILibrary.register(Unknown Source)
08-21 11:43:01.950: E/AndroidRuntime(1350): 	at org.jnetpcap.nio.JMemory.<clinit>(Unknown Source)
08-21 11:43:01.950: E/AndroidRuntime(1350): 	... 16 more