| @@ 176-246 (lines=71) @@ | ||
| 173 | self.dp_desc = dp_desc |
|
| 174 | ||
| 175 | ||
| 176 | class FlowStats(GenericStruct): |
|
| 177 | """Body of reply to OFPST_FLOW request.""" |
|
| 178 | ||
| 179 | length = UBInt16() |
|
| 180 | table_id = UBInt8() |
|
| 181 | #: Align to 32 bits. |
|
| 182 | pad = Pad(1) |
|
| 183 | match = Match() |
|
| 184 | duration_sec = UBInt32() |
|
| 185 | duration_nsec = UBInt32() |
|
| 186 | priority = UBInt16() |
|
| 187 | idle_timeout = UBInt16() |
|
| 188 | hard_timeout = UBInt16() |
|
| 189 | #: Align to 64-bits |
|
| 190 | pad2 = Pad(6) |
|
| 191 | cookie = UBInt64() |
|
| 192 | packet_count = UBInt64() |
|
| 193 | byte_count = UBInt64() |
|
| 194 | actions = ListOfActions() |
|
| 195 | ||
| 196 | def __init__(self, length=None, table_id=None, match=None, |
|
| 197 | duration_sec=None, duration_nsec=None, priority=None, |
|
| 198 | idle_timeout=None, hard_timeout=None, cookie=None, |
|
| 199 | packet_count=None, byte_count=None, actions=None): |
|
| 200 | """Create a FlowStats with the optional parameters below. |
|
| 201 | ||
| 202 | Args: |
|
| 203 | length (int): Length of this entry. |
|
| 204 | table_id (int): ID of table flow came from. |
|
| 205 | match (~pyof.v0x01.common.flow_match.Match): Description of fields. |
|
| 206 | duration_sec (int): Time flow has been alive in seconds. |
|
| 207 | duration_nsec (int): Time flow has been alive in nanoseconds in |
|
| 208 | addition to duration_sec. |
|
| 209 | priority (int): Priority of the entry. Only meaningful when this |
|
| 210 | is not an exact-match entry. |
|
| 211 | idle_timeout (int): Number of seconds idle before expiration. |
|
| 212 | hard_timeout (int): Number of seconds before expiration. |
|
| 213 | cookie (int): Opaque controller-issued identifier. |
|
| 214 | packet_count (int): Number of packets in flow. |
|
| 215 | byte_count (int): Number of bytes in flow. |
|
| 216 | actions (:class:`~pyof.v0x01.common.actions.ListOfActions`): |
|
| 217 | List of Actions. |
|
| 218 | """ |
|
| 219 | super().__init__() |
|
| 220 | self.length = length |
|
| 221 | self.table_id = table_id |
|
| 222 | self.match = match |
|
| 223 | self.duration_sec = duration_sec |
|
| 224 | self.duration_nsec = duration_nsec |
|
| 225 | self.priority = priority |
|
| 226 | self.idle_timeout = idle_timeout |
|
| 227 | self.hard_timeout = hard_timeout |
|
| 228 | self.cookie = cookie |
|
| 229 | self.packet_count = packet_count |
|
| 230 | self.byte_count = byte_count |
|
| 231 | self.actions = [] if actions is None else actions |
|
| 232 | ||
| 233 | def unpack(self, buff, offset=0): |
|
| 234 | """Unpack *buff* into this object. |
|
| 235 | ||
| 236 | Do nothing, since the _length is already defined and it is just a Pad. |
|
| 237 | Keep buff and offset just for compability with other unpack methods. |
|
| 238 | ||
| 239 | Args: |
|
| 240 | buff (bytes): Buffer where data is located. |
|
| 241 | offset (int): Where data stream begins. |
|
| 242 | """ |
|
| 243 | self.length = UBInt16() |
|
| 244 | self.length.unpack(buff, offset) |
|
| 245 | max_length = offset + self.length.value |
|
| 246 | super().unpack(buff[:max_length], offset) |
|
| 247 | ||
| 248 | ||
| 249 | class FlowStatsRequest(GenericStruct): |
|
| @@ 243-311 (lines=69) @@ | ||
| 240 | self.dp_desc = dp_desc |
|
| 241 | ||
| 242 | ||
| 243 | class FlowStats(GenericStruct): |
|
| 244 | """Body of reply to OFPST_FLOW request.""" |
|
| 245 | ||
| 246 | length = UBInt16() |
|
| 247 | table_id = UBInt8() |
|
| 248 | #: Align to 32 bits. |
|
| 249 | pad = Pad(1) |
|
| 250 | duration_sec = UBInt32() |
|
| 251 | duration_nsec = UBInt32() |
|
| 252 | priority = UBInt16() |
|
| 253 | idle_timeout = UBInt16() |
|
| 254 | hard_timeout = UBInt16() |
|
| 255 | flags = UBInt16() |
|
| 256 | #: Align to 64-bits |
|
| 257 | pad2 = Pad(4) |
|
| 258 | cookie = UBInt64() |
|
| 259 | packet_count = UBInt64() |
|
| 260 | byte_count = UBInt64() |
|
| 261 | match = Match() |
|
| 262 | instructions = ListOfInstruction() |
|
| 263 | ||
| 264 | def __init__(self, length=None, table_id=None, duration_sec=None, |
|
| 265 | duration_nsec=None, priority=None, idle_timeout=None, |
|
| 266 | hard_timeout=None, flags=None, cookie=None, packet_count=None, |
|
| 267 | byte_count=None, match=None, instructions=None): |
|
| 268 | """Create a FlowStats with the optional parameters below. |
|
| 269 | ||
| 270 | Args: |
|
| 271 | length (int): Length of this entry. |
|
| 272 | table_id (int): ID of table flow came from. |
|
| 273 | duration_sec (int): Time flow has been alive in seconds. |
|
| 274 | duration_nsec (int): Time flow has been alive in nanoseconds in |
|
| 275 | addition to duration_sec. |
|
| 276 | priority (int): Priority of the entry. Only meaningful when this |
|
| 277 | is not an exact-match entry. |
|
| 278 | idle_timeout (int): Number of seconds idle before expiration. |
|
| 279 | hard_timeout (int): Number of seconds before expiration. |
|
| 280 | cookie (int): Opaque controller-issued identifier. |
|
| 281 | packet_count (int): Number of packets in flow. |
|
| 282 | byte_count (int): Number of bytes in flow. |
|
| 283 | match (~pyof.v0x04.common.flow_match.Match): Description of fields. |
|
| 284 | ||
| 285 | """ |
|
| 286 | super().__init__() |
|
| 287 | self.length = length |
|
| 288 | self.table_id = table_id |
|
| 289 | self.duration_sec = duration_sec |
|
| 290 | self.duration_nsec = duration_nsec |
|
| 291 | self.priority = priority |
|
| 292 | self.idle_timeout = idle_timeout |
|
| 293 | self.hard_timeout = hard_timeout |
|
| 294 | self.flags = flags |
|
| 295 | self.cookie = cookie |
|
| 296 | self.packet_count = packet_count |
|
| 297 | self.byte_count = byte_count |
|
| 298 | self.match = match |
|
| 299 | self.instructions = instructions or [] |
|
| 300 | ||
| 301 | def unpack(self, buff, offset=0): |
|
| 302 | """Unpack a binary message into this object's attributes. |
|
| 303 | ||
| 304 | Pass the correct length for list unpacking. |
|
| 305 | ||
| 306 | Args: |
|
| 307 | buff (bytes): Binary data package to be unpacked. |
|
| 308 | offset (int): Where to begin unpacking. |
|
| 309 | ||
| 310 | """ |
|
| 311 | unpack_length = UBInt16() |
|
| 312 | unpack_length.unpack(buff, offset) |
|
| 313 | super().unpack(buff[:offset+unpack_length], offset) |
|
| 314 | ||