| @@ 247-336 (lines=90) @@ | ||
| 244 | """ |
|
| 245 | ||
| 246 | def __init__(self, items=None): |
|
| 247 | """The constructor just assigns parameters to object attributes. |
|
| 248 | ||
| 249 | Args: |
|
| 250 | items (|Property_v0x04|): Instance or a list of instances. |
|
| 251 | """ |
|
| 252 | super().__init__(pyof_class=Property, items=items) |
|
| 253 | ||
| 254 | ||
| 255 | class TableFeatures(GenericStruct): |
|
| 256 | """Abstration of common class Table Features. |
|
| 257 | ||
| 258 | Body for MultipartRequest of type OFPMP_TABLE_FEATURES. |
|
| 259 | Body of reply to OFPMP_TABLE_FEATURES request. |
|
| 260 | """ |
|
| 261 | ||
| 262 | length = UBInt16() |
|
| 263 | # /* Identifier of table. Lower numbered tables are consulted first. */ |
|
| 264 | table_id = UBInt8() |
|
| 265 | # /* Align to 64-bits. */ |
|
| 266 | pad = Pad(5) |
|
| 267 | name = Char(length=OFP_MAX_TABLE_NAME_LEN) |
|
| 268 | # /* Bits of metadata table can match. */ |
|
| 269 | metadata_match = UBInt64() |
|
| 270 | # /* Bits of metadata table can write. */ |
|
| 271 | metadata_write = UBInt64() |
|
| 272 | # /* Bitmap of OFPTC_* values */ |
|
| 273 | config = UBInt32() |
|
| 274 | # /* Max number of entries supported. */ |
|
| 275 | max_entries = UBInt32() |
|
| 276 | # /* Table Feature Property list */ |
|
| 277 | properties = ListOfProperty() |
|
| 278 | ||
| 279 | def __init__(self, table_id=Table.OFPTT_ALL, name="", |
|
| 280 | metadata_match=0xFFFFFFFFFFFFFFFF, |
|
| 281 | metadata_write=0xFFFFFFFFFFFFFFFF, |
|
| 282 | config=0, |
|
| 283 | max_entries=0, |
|
| 284 | properties=ListOfProperty()): |
|
| 285 | """The constructor of TableFeatures receives the paramters below. |
|
| 286 | ||
| 287 | Args: |
|
| 288 | table_id(int): Indetifier of table.The default value |
|
| 289 | OFPTT_ALL(0xff) will apply the configuration to all tables in |
|
| 290 | the switch. |
|
| 291 | name(Char): Characters representing the table name. |
|
| 292 | metadata_match(int): Indicate the bits of the metadata field that |
|
| 293 | the table can match on.The default value 0xFFFFFFFFFFFFFFFF |
|
| 294 | indicates that the table can match the full metadata field. |
|
| 295 | metadata_write(int): Indicates the bits of the metadata field that |
|
| 296 | the table can write using the OFPIT_WRITE_METADATA instruction. |
|
| 297 | The default value 0xFFFFFFFFFFFFFFFF indicates that the table |
|
| 298 | can write the full metadata field. |
|
| 299 | config(int): Field reseved for future use. |
|
| 300 | max_entries(int): Describe the maximum number of flow entries that |
|
| 301 | can be inserted into that table. |
|
| 302 | properties(Property_v0x04): List of Property intances. |
|
| 303 | """ |
|
| 304 | super().__init__() |
|
| 305 | self.table_id = table_id |
|
| 306 | self.name = name |
|
| 307 | self.metadata_match = metadata_match |
|
| 308 | self.metadata_write = metadata_write |
|
| 309 | self.config = config |
|
| 310 | self.max_entries = max_entries |
|
| 311 | self.properties = properties |
|
| 312 | self.update_length() |
|
| 313 | ||
| 314 | def pack(self, value=None): |
|
| 315 | """Pack method used to update the length of instance and packing. |
|
| 316 | ||
| 317 | Args: |
|
| 318 | value: Structure to be packed. |
|
| 319 | """ |
|
| 320 | self.update_length() |
|
| 321 | return super().pack(value) |
|
| 322 | ||
| 323 | def update_length(self): |
|
| 324 | """Update the length of current instance.""" |
|
| 325 | self.length = self.get_size() |
|
| 326 | ||
| 327 | def unpack(self, buff=None, offset=0): |
|
| 328 | """Unpack *buff* into this object. |
|
| 329 | ||
| 330 | This method will convert a binary data into a readable value according |
|
| 331 | to the attribute format. |
|
| 332 | ||
| 333 | Args: |
|
| 334 | buff (bytes): Binary buffer. |
|
| 335 | offset (int): Where to begin unpacking. |
|
| 336 | ||
| 337 | Raises: |
|
| 338 | :exc:`~.exceptions.UnpackException`: If unpack fails. |
|
| 339 | """ |
|
| @@ 582-651 (lines=70) @@ | ||
| 579 | """Band Statistics. |
|
| 580 | ||
| 581 | Statistics for each meter band. |
|
| 582 | """ |
|
| 583 | ||
| 584 | packet_band_count = UBInt64() |
|
| 585 | byte_band_count = UBInt64() |
|
| 586 | ||
| 587 | def __init__(self, packet_band_count=None, byte_band_count=None): |
|
| 588 | """The constructor just assigns parameters to object attributes. |
|
| 589 | ||
| 590 | Args: |
|
| 591 | packet_band_count(int): Number of packets in band. |
|
| 592 | byte_band_count(int): Number of bytes in band. |
|
| 593 | """ |
|
| 594 | super().__init__() |
|
| 595 | self.packet_band_count = packet_band_count |
|
| 596 | self.byte_band_count = byte_band_count |
|
| 597 | ||
| 598 | ||
| 599 | class ListOfBandStats(FixedTypeList): |
|
| 600 | """List of BandStats. |
|
| 601 | ||
| 602 | Represented by instances of BandStats. |
|
| 603 | """ |
|
| 604 | ||
| 605 | def __init__(self, items=None): |
|
| 606 | """The constructor just assigns parameters to object attributes. |
|
| 607 | ||
| 608 | Args: |
|
| 609 | items (|BandStats_v0x04|): Instance or a list of instances. |
|
| 610 | """ |
|
| 611 | super().__init__(pyof_class=BandStats, items=items) |
|
| 612 | ||
| 613 | ||
| 614 | class MeterStats(GenericStruct): |
|
| 615 | """Meter Statistics. |
|
| 616 | ||
| 617 | Body of reply to OFPMP_METER request. |
|
| 618 | """ |
|
| 619 | ||
| 620 | meter_id = UBInt32() |
|
| 621 | length = UBInt16() |
|
| 622 | pad = Pad(6) |
|
| 623 | flow_count = UBInt32() |
|
| 624 | packet_in_count = UBInt64() |
|
| 625 | byte_in_count = UBInt64() |
|
| 626 | duration_sec = UBInt32() |
|
| 627 | duration_nsec = UBInt32() |
|
| 628 | band_stats = ListOfBandStats() |
|
| 629 | ||
| 630 | def __init__(self, meter_id=None, flow_count=None, |
|
| 631 | packet_in_count=None, byte_in_count=None, duration_sec=None, |
|
| 632 | duration_nsec=None, band_stats=None): |
|
| 633 | """The constructor just assigns parameters to object attributes. |
|
| 634 | ||
| 635 | Args: |
|
| 636 | meter_id (|Meter_v0x04|): Meter instance. |
|
| 637 | flow_count(int): Number of flows bound to meter. |
|
| 638 | packet_in_count(int): Number of packets in input. |
|
| 639 | byte_in_count(int): Number of bytes in input. |
|
| 640 | duration_sec(int): Time meter has been alive in seconds. |
|
| 641 | duration_nsec(int): Time meter has been alive in |
|
| 642 | nanoseconds beyond duration_sec. |
|
| 643 | band_stats(list): Instances of BandStats |
|
| 644 | """ |
|
| 645 | super().__init__() |
|
| 646 | self.meter_id = meter_id |
|
| 647 | self.flow_count = flow_count |
|
| 648 | self.packet_in_count = packet_in_count |
|
| 649 | self.byte_in_count = byte_in_count |
|
| 650 | self.duration_sec = duration_sec |
|
| 651 | self.duration_nsec = duration_nsec |
|
| 652 | self.band_stats = band_stats if band_stats else [] |
|
| 653 | self.update_length() |
|
| 654 | ||