@@ 188-217 (lines=30) @@ | ||
185 | return cls(tll) |
|
186 | ||
187 | ||
188 | class MatchEXTHDR(MatchField): |
|
189 | """Match for IPv6 EXTHDR.""" |
|
190 | ||
191 | name = 'v6_hdr' |
|
192 | oxm_field = OxmOfbMatchField.OFPXMT_OFB_IPV6_EXTHDR |
|
193 | ||
194 | def as_of_tlv(self): |
|
195 | """Return a pyof OXM TLV instance.""" |
|
196 | try: |
|
197 | value = int(self.value) |
|
198 | mask = None |
|
199 | oxm_hasmask = False |
|
200 | except ValueError: |
|
201 | value, mask = map(int, self.value.split('/')) |
|
202 | oxm_hasmask = True |
|
203 | value_bytes = value.to_bytes(2, 'big') |
|
204 | if mask: |
|
205 | value_bytes += mask.to_bytes(2, 'big') |
|
206 | return OxmTLV(oxm_field=self.oxm_field, |
|
207 | oxm_hasmask=oxm_hasmask, |
|
208 | oxm_value=value_bytes) |
|
209 | ||
210 | @classmethod |
|
211 | def from_of_tlv(cls, tlv): |
|
212 | """Return an instance from a pyof OXM TLV.""" |
|
213 | value = int.from_bytes(tlv.oxm_value[:2], 'big') |
|
214 | if tlv.oxm_hasmask: |
|
215 | exhead_mask = int.from_bytes(tlv.oxm_value[2:], 'big') |
|
216 | value = f'{value}/{exhead_mask}' |
|
217 | return cls(value) |
|
218 | ||
@@ 66-95 (lines=30) @@ | ||
63 | return cls(value) |
|
64 | ||
65 | ||
66 | class MatchIPv6FLabel(MatchField): |
|
67 | """Match for IPv6 Flow Label.""" |
|
68 | ||
69 | name = 'ipv6_flabel' |
|
70 | oxm_field = OxmOfbMatchField.OFPXMT_OFB_IPV6_FLABEL |
|
71 | ||
72 | def as_of_tlv(self): |
|
73 | """Return a pyof OXM TLV instance.""" |
|
74 | try: |
|
75 | value = int(self.value) |
|
76 | mask = None |
|
77 | oxm_hasmask = False |
|
78 | except ValueError: |
|
79 | value, mask = map(int, self.value.split('/')) |
|
80 | oxm_hasmask = True |
|
81 | value_bytes = value.to_bytes(4, 'big') |
|
82 | if mask: |
|
83 | value_bytes += mask.to_bytes(4, 'big') |
|
84 | return OxmTLV(oxm_field=self.oxm_field, |
|
85 | oxm_hasmask=oxm_hasmask, |
|
86 | oxm_value=value_bytes) |
|
87 | ||
88 | @classmethod |
|
89 | def from_of_tlv(cls, tlv): |
|
90 | """Return an instance from a pyof OXM TLV.""" |
|
91 | value = int.from_bytes(tlv.oxm_value[:4], 'big') |
|
92 | if tlv.oxm_hasmask: |
|
93 | flabel_mask = int.from_bytes(tlv.oxm_value[4:], 'big') |
|
94 | value = f'{value}/{flabel_mask}' |
|
95 | return cls(value) |
|
96 | ||
97 | ||
98 | class MatchICMPV6Type(MatchField): |
@@ 751-780 (lines=30) @@ | ||
748 | return cls(value) |
|
749 | ||
750 | ||
751 | class MatchTUNNELID(MatchField): |
|
752 | """Match for tunnel id.""" |
|
753 | ||
754 | name = 'tun_id' |
|
755 | oxm_field = OxmOfbMatchField.OFPXMT_OFB_TUNNEL_ID |
|
756 | ||
757 | def as_of_tlv(self): |
|
758 | """Return a pyof OXM TLV instance.""" |
|
759 | try: |
|
760 | value = int(self.value) |
|
761 | mask = None |
|
762 | oxm_hasmask = False |
|
763 | except ValueError: |
|
764 | value, mask = map(int, self.value.split('/')) |
|
765 | oxm_hasmask = True |
|
766 | value_bytes = value.to_bytes(8, 'big') |
|
767 | if mask: |
|
768 | value_bytes += mask.to_bytes(8, 'big') |
|
769 | return OxmTLV(oxm_field=self.oxm_field, |
|
770 | oxm_hasmask=oxm_hasmask, |
|
771 | oxm_value=value_bytes) |
|
772 | ||
773 | @classmethod |
|
774 | def from_of_tlv(cls, tlv): |
|
775 | """Return an instance from a pyof OXM TLV.""" |
|
776 | value = int.from_bytes(tlv.oxm_value[:8], 'big') |
|
777 | if tlv.oxm_hasmask: |
|
778 | tunnel_mask = int.from_bytes(tlv.oxm_value[8:], 'big') |
|
779 | value = f'{value}/{tunnel_mask}' |
|
780 | return cls(value) |
|
781 | ||
@@ 719-748 (lines=30) @@ | ||
716 | return cls(value) |
|
717 | ||
718 | ||
719 | class MatchMetadata(MatchField): |
|
720 | """Match for table metadata.""" |
|
721 | ||
722 | name = 'metadata' |
|
723 | oxm_field = OxmOfbMatchField.OFPXMT_OFB_METADATA |
|
724 | ||
725 | def as_of_tlv(self): |
|
726 | """Return a pyof OXM TLV instance.""" |
|
727 | try: |
|
728 | value = int(self.value) |
|
729 | mask = None |
|
730 | oxm_hasmask = False |
|
731 | except ValueError: |
|
732 | value, mask = map(int, self.value.split('/')) |
|
733 | oxm_hasmask = True |
|
734 | value_bytes = value.to_bytes(8, 'big') |
|
735 | if mask: |
|
736 | value_bytes += mask.to_bytes(8, 'big') |
|
737 | return OxmTLV(oxm_field=self.oxm_field, |
|
738 | oxm_hasmask=oxm_hasmask, |
|
739 | oxm_value=value_bytes) |
|
740 | ||
741 | @classmethod |
|
742 | def from_of_tlv(cls, tlv): |
|
743 | """Return an instance from a pyof OXM TLV.""" |
|
744 | value = int.from_bytes(tlv.oxm_value[:8], 'big') |
|
745 | if tlv.oxm_hasmask: |
|
746 | metadata_mask = int.from_bytes(tlv.oxm_value[8:], 'big') |
|
747 | value = f'{value}/{metadata_mask}' |
|
748 | return cls(value) |
|
749 | ||
750 | ||
751 | class MatchTUNNELID(MatchField): |
|
@@ 687-716 (lines=30) @@ | ||
684 | return cls(bos) |
|
685 | ||
686 | ||
687 | class MatchPBBISID(MatchField): |
|
688 | """Match for PBB ISID.""" |
|
689 | ||
690 | name = 'pbb_isid' |
|
691 | oxm_field = OxmOfbMatchField.OFPXMT_OFB_PBB_ISID |
|
692 | ||
693 | def as_of_tlv(self): |
|
694 | """Return a pyof OXM TLV instance.""" |
|
695 | try: |
|
696 | value = int(self.value) |
|
697 | mask = None |
|
698 | oxm_hasmask = False |
|
699 | except ValueError: |
|
700 | value, mask = map(int, self.value.split('/')) |
|
701 | oxm_hasmask = True |
|
702 | value_bytes = value.to_bytes(3, 'big') |
|
703 | if mask: |
|
704 | value_bytes += mask.to_bytes(3, 'big') |
|
705 | return OxmTLV(oxm_field=self.oxm_field, |
|
706 | oxm_hasmask=oxm_hasmask, |
|
707 | oxm_value=value_bytes) |
|
708 | ||
709 | @classmethod |
|
710 | def from_of_tlv(cls, tlv): |
|
711 | """Return an instance from a pyof OXM TLV.""" |
|
712 | value = int.from_bytes(tlv.oxm_value[:3], 'big') |
|
713 | if tlv.oxm_hasmask: |
|
714 | pbb_isid_mask = int.from_bytes(tlv.oxm_value[3:], 'big') |
|
715 | value = f'{value}/{pbb_isid_mask}' |
|
716 | return cls(value) |
|
717 | ||
718 | ||
719 | class MatchMetadata(MatchField): |