-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.py
More file actions
105 lines (95 loc) · 2.53 KB
/
example.py
File metadata and controls
105 lines (95 loc) · 2.53 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
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
import pprint
import pad
def upload_ictp_v1():
ethernet_hrd = """
header ethernet {
fields {
dst_addr : 48;
src_addr : 48;
ethertype : 16;
}
}
parser start {
ethernet;
}
parser ethernet {
switch(ethertype) {
case 0x9100: ictp;
}
}
"""
ictp_hdr = """
header ictp {
fields {
nid : 32;
csn : 32;
}
}
"""
push_ictp = """
action push_ictp {
add_header(ictp, sizeof(ethernet));
}
"""
pop_ictp = """
action pop_ictp {
remove_header(ictp, sizeof(ethernet));
}
"""
pad.add_protocol("Ethernet", ethernet_hrd)
pad.add_protocol("ICTP", ictp_hdr)
pad.add_function("push_ictp", push_ictp)
pad.add_function("pop_ictp", pop_ictp)
of_extensions_ids = pad.commit_configuration()
pprint.pprint(of_extensions_ids)
def remove_ictp_v1():
pad.remove_protocol("ICTP")
def upload_ictp_v2():
ethernet_hrd = """
header ethernet {
fields {
dst_addr : 48;
src_addr : 48;
ethertype : 16;
}
}
parser start {
ethernet;
}
parser ethernet {
switch(ethertype) {
case 0x9100: ictp;
}
}
"""
ictp_hdr = """
header ictp {
fields {
version : 8;
slice : 16;
__skip__ : 8;
nid : 32;
csn : 32;
}
}
"""
push_ictp = """
action push_ictp {
add_header(ictp, sizeof(ethernet));
}
"""
pop_ictp = """
action pop_ictp {
remove_header(ictp, sizeof(ethernet));
}
"""
pad.add_protocol("Ethernet", ethernet_hrd)
pad.add_protocol("ICTP", ictp_hdr)
pad.add_function("push_ictp", push_ictp)
pad.add_function("pop_ictp", pop_ictp)
of_extensions_ids = pad.commit_configuration()
pprint.pprint(of_extensions_ids)
if __name__ == "__main__":
#upload_ictp_v1()
#remove_ictp_v1()
upload_ictp_v2()