-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathLearningSwitch13.java
More file actions
59 lines (46 loc) · 1.46 KB
/
LearningSwitch13.java
File metadata and controls
59 lines (46 loc) · 1.46 KB
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
import java.math.BigInteger;
import java.nio.ByteBuffer;
import java.util.HashMap;
import java.util.Map;
import java.util.Arrays;
import fluid.base.*;
import fluid.msg13.*;
public class LearningSwitch13 extends OFServer {
static {
System.loadLibrary("fluid_base");
System.loadLibrary("fluid_msg_of10");
System.loadLibrary("fluid_msg_of13");
}
static short test(short bytes) {
return bytes;
}
static Map<Integer, Map<Long, Integer>> table = new HashMap<Integer, Map<Long, Integer>>();
@Override
public void connection_callback(OFConnection conn,
OFConnection.Event event_type) {
System.out.println("## Connection id=" + conn.get_id() + " event="
+ event_type);
}
private Long get_long_mac(byte[] mac) {
ByteBuffer br = ByteBuffer.allocate(8);
br.put(mac);
br.putShort((short) 0x0000);
br.flip();
return br.getLong();
}
private void flood(OFConnection conn, PacketIn pi) {
// TODO: implement this method
}
@Override
public void message_callback(OFConnection conn, short type, byte[] data,
long len) {
System.out.println("Type Packet: "+type + " Version Protcol: "+conn.get_version());
}
public LearningSwitch13(String address, int port, int nthreads) {
super(address, port, nthreads,false,new OFServerSettings().supported_version((short)1).supported_version((short)4).keep_data_ownership(false));
}
public static void main(String argv[]) {
LearningSwitch13 l2 = new LearningSwitch13("0.0.0.0", 6653, 1);
l2.start(true);
}
}