@@ 66-93 (lines=28) @@ | ||
63 | super().__init__(pyof_class=Bucket, items=items) |
|
64 | ||
65 | ||
66 | class GroupMod(GenericMessage): |
|
67 | """Group setup and teardown (controller -> datapath).""" |
|
68 | ||
69 | header = Header(message_type=Type.OFPT_GROUP_MOD) |
|
70 | command = UBInt16(enum_ref=GroupModCommand) |
|
71 | group_type = UBInt8() |
|
72 | #: Pad to 64 bits. |
|
73 | pad = Pad(1) |
|
74 | group_id = UBInt32() |
|
75 | buckets = ListOfBuckets() |
|
76 | ||
77 | def __init__(self, xid=None, command=None, group_type=None, group_id=None, |
|
78 | buckets=None): |
|
79 | """Create a GroupMod with the optional parameters below. |
|
80 | ||
81 | Args: |
|
82 | xid (int): Header's transaction id. Defaults to random. |
|
83 | command (GroupModCommand): One of OFPGC_*. |
|
84 | group_type (GroupType): One of OFPGT_*. |
|
85 | group_id (int): Group identifier. |
|
86 | buckets (:class:`ListOfBuckets`): The length of the bucket |
|
87 | array is inferred from the length field in the header. |
|
88 | """ |
|
89 | super().__init__(xid) |
|
90 | self.command = command |
|
91 | self.group_type = group_type |
|
92 | self.group_id = group_id |
|
93 | self.buckets = buckets |
|
94 |
@@ 421-445 (lines=25) @@ | ||
418 | self.duration_nsec = duration_nsec |
|
419 | ||
420 | ||
421 | class GroupDescStats(GenericStruct): |
|
422 | """Body of reply to OFPMP_GROUP_DESC request.""" |
|
423 | ||
424 | length = UBInt16() |
|
425 | group_type = UBInt8() |
|
426 | #: Pad to 64 bits. |
|
427 | pad = Pad(1) |
|
428 | group_id = UBInt32() |
|
429 | buckets = FixedTypeList(Bucket) |
|
430 | ||
431 | def __init__(self, length=None, group_type=None, group_id=None, |
|
432 | buckets=None): |
|
433 | """Create a GroupDescStats with the optional parameters below. |
|
434 | ||
435 | Args: |
|
436 | length (int): Length of this entry. |
|
437 | group_type (|GroupType_v0x04|): One of OFPGT_*. |
|
438 | group_id (int): Group identifier. |
|
439 | buckets (|ListOfBuckets_v0x04|): List of buckets in group. |
|
440 | """ |
|
441 | super().__init__() |
|
442 | self.length = length |
|
443 | self.group_type = group_type |
|
444 | self.group_id = group_id |
|
445 | self.buckets = buckets |
|
446 | ||
447 | ||
448 | class GroupFeatures(GenericStruct): |
@@ 83-104 (lines=22) @@ | ||
80 | # Classes |
|
81 | ||
82 | ||
83 | class Header(GenericStruct): |
|
84 | """Representation of an OpenFlow message Header.""" |
|
85 | ||
86 | version = UBInt8(OFP_VERSION) |
|
87 | message_type = UBInt8(enum_ref=Type) |
|
88 | length = UBInt16() |
|
89 | xid = UBInt32() |
|
90 | ||
91 | def __init__(self, message_type=None, length=None, xid=None): |
|
92 | """Create a Header with the optional parameters below. |
|
93 | ||
94 | Args: |
|
95 | message_type (~pyof.v0x04.common.header.Type): |
|
96 | One of the OFPT_* constants. |
|
97 | length (int): Length including this ofp_header. |
|
98 | xid (int): Transaction id associated with this packet. Replies use |
|
99 | the same id as was in the request to facilitate pairing. |
|
100 | """ |
|
101 | super().__init__() |
|
102 | self.message_type = message_type |
|
103 | self.length = length |
|
104 | self.xid = randint(0, MAXID) if xid is None else xid |
|
105 |