blob: ce323c24fc30704e5dec880a28e2c109b94e8741 [file] [log] [blame]
Rich Lane5ec97b82013-01-06 18:04:25 -08001
2# Python OpenFlow instruction wrapper classes
3
4from cstruct import *
5from action_list import action_list
6
7
8
9class instruction_goto_table(ofp_instruction_goto_table):
10 """
11 Wrapper class for goto_table instruction object
12
13 Data members inherited from ofp_instruction_goto_table:
14 @arg type
15 @arg len
16 @arg table_id
17
18 """
19 def __init__(self):
20 ofp_instruction_goto_table.__init__(self)
21 self.type = OFPIT_GOTO_TABLE
22 self.len = self.__len__()
23 def show(self, prefix=''):
24 outstr = prefix + "instruction_goto_table\n"
25 outstr += ofp_instruction_goto_table.show(self, prefix)
26 return outstr
27
28
29class instruction_write_actions(ofp_instruction_actions):
30 """
31 Wrapper class for write_actions instruction object
32
33 Data members inherited from ofp_instruction_actions:
34 @arg type
35 @arg len
36
37 """
38 def __init__(self):
39 ofp_instruction_actions.__init__(self)
40 self.type = OFPIT_WRITE_ACTIONS
41 self.actions = action_list()
42 self.len = self.__len__()
43 def show(self, prefix=''):
44 outstr = prefix + "instruction_write_actions\n"
45 outstr += ofp_instruction_actions.show(self, prefix)
46 outstr += self.actions.show(prefix)
47 return outstr
48 def unpack(self, binary_string):
49 binary_string = ofp_instruction_actions.unpack(self, binary_string)
50 bytes = self.len - OFP_INSTRUCTION_ACTIONS_BYTES
51 self.actions = action_list()
52 binary_string = self.actions.unpack(binary_string, bytes=bytes)
53 return binary_string
54 def pack(self):
55 self.len = self.__len__()
56 packed = ""
57 packed += ofp_instruction_actions.pack(self)
58 packed += self.actions.pack()
59 return packed
60 def __len__(self):
61 return ofp_instruction_actions.__len__(self) + self.actions.__len__()
62
63
64class instruction_apply_actions(ofp_instruction_actions):
65 """
66 Wrapper class for apply_actions instruction object
67
68 Data members inherited from ofp_instruction_actions:
69 @arg type
70 @arg len
71
72 """
73 def __init__(self):
74 ofp_instruction_actions.__init__(self)
75 self.type = OFPIT_APPLY_ACTIONS
76 self.actions = action_list()
77 self.len = self.__len__()
78 def show(self, prefix=''):
79 outstr = prefix + "instruction_apply_actions\n"
80 outstr += ofp_instruction_actions.show(self, prefix)
81 outstr += self.actions.show(prefix)
82 return outstr
83 def unpack(self, binary_string):
84 binary_string = ofp_instruction_actions.unpack(self, binary_string)
85 bytes = self.len - OFP_INSTRUCTION_ACTIONS_BYTES
86 self.actions = action_list()
87 binary_string = self.actions.unpack(binary_string, bytes=bytes)
88 return binary_string
89 def pack(self):
90 self.len = self.__len__()
91 packed = ""
92 packed += ofp_instruction_actions.pack(self)
93 packed += self.actions.pack()
94 return packed
95 def __len__(self):
96 return ofp_instruction_actions.__len__(self) + self.actions.__len__()
97
98
99class instruction_experimenter(ofp_instruction_experimenter):
100 """
101 Wrapper class for experimenter instruction object
102
103 Data members inherited from ofp_instruction_experimenter:
104 @arg type
105 @arg len
106 @arg experimenter
107
108 """
109 def __init__(self):
110 ofp_instruction_experimenter.__init__(self)
111 self.type = OFPIT_EXPERIMENTER
112 self.len = self.__len__()
113 def show(self, prefix=''):
114 outstr = prefix + "instruction_experimenter\n"
115 outstr += ofp_instruction_experimenter.show(self, prefix)
116 return outstr
117
118
119class instruction_write_metadata(ofp_instruction_write_metadata):
120 """
121 Wrapper class for write_metadata instruction object
122
123 Data members inherited from ofp_instruction_write_metadata:
124 @arg type
125 @arg len
126 @arg metadata
127 @arg metadata_mask
128
129 """
130 def __init__(self):
131 ofp_instruction_write_metadata.__init__(self)
132 self.type = OFPIT_WRITE_METADATA
133 self.len = self.__len__()
134 def show(self, prefix=''):
135 outstr = prefix + "instruction_write_metadata\n"
136 outstr += ofp_instruction_write_metadata.show(self, prefix)
137 return outstr
138
139
140class instruction_clear_actions(ofp_instruction):
141 """
142 Wrapper class for clear_actions instruction object
143
144 Data members inherited from ofp_instruction:
145 @arg type
146 @arg len
147
148 """
149 def __init__(self):
150 ofp_instruction.__init__(self)
151 self.type = OFPIT_CLEAR_ACTIONS
152 self.len = self.__len__()
153 def show(self, prefix=''):
154 outstr = prefix + "instruction_clear_actions\n"
155 outstr += ofp_instruction.show(self, prefix)
156 return outstr
157
158instruction_class_list = (
159 instruction_apply_actions,
160 instruction_clear_actions,
161 instruction_experimenter,
162 instruction_goto_table,
163 instruction_write_actions,
164 instruction_write_metadata)