@@ 591-630 (lines=40) @@ | ||
588 | return cls(value) |
|
589 | ||
590 | ||
591 | class MatchARPTHA(MatchField): |
|
592 | """Match for ARP Target MAC Address.""" |
|
593 | ||
594 | name = 'arp_tha' |
|
595 | oxm_field = OxmOfbMatchField.OFPXMT_OFB_ARP_THA |
|
596 | ||
597 | def as_of_tlv(self): |
|
598 | """Return a pyof OXM TLV instance.""" |
|
599 | if '/' in self.value: |
|
600 | value, mask = self.value.split('/') |
|
601 | mask = mask.upper() |
|
602 | if mask == 'FF:FF:FF:FF:FF:FF': |
|
603 | mask = None |
|
604 | oxm_hasmask = False |
|
605 | else: |
|
606 | oxm_hasmask = True |
|
607 | else: |
|
608 | value = self.value |
|
609 | mask = None |
|
610 | oxm_hasmask = False |
|
611 | value_bytes = HWAddress(value).pack() |
|
612 | if mask: |
|
613 | value_bytes += HWAddress(mask).pack() |
|
614 | return OxmTLV(oxm_field=self.oxm_field, |
|
615 | oxm_hasmask=oxm_hasmask, |
|
616 | oxm_value=value_bytes) |
|
617 | ||
618 | @classmethod |
|
619 | def from_of_tlv(cls, tlv): |
|
620 | """Return an instance from a pyof OXM TLV.""" |
|
621 | hw_address = HWAddress() |
|
622 | hw_address.unpack(tlv.oxm_value) |
|
623 | addr_str = str(hw_address) |
|
624 | value = addr_str |
|
625 | if tlv.oxm_hasmask: |
|
626 | hw_mask = HWAddress() |
|
627 | hw_mask.unpack(tlv.oxm_value[6:]) |
|
628 | mask_str = str(hw_mask) |
|
629 | value = f'{addr_str}/{mask_str}' |
|
630 | return cls(value) |
|
631 | ||
632 | ||
633 | class MatchMPLSLabel(MatchField): |
|
@@ 549-588 (lines=40) @@ | ||
546 | return cls(value) |
|
547 | ||
548 | ||
549 | class MatchARPSHA(MatchField): |
|
550 | """Match for ARP Sender MAC Address.""" |
|
551 | ||
552 | name = 'arp_sha' |
|
553 | oxm_field = OxmOfbMatchField.OFPXMT_OFB_ARP_SHA |
|
554 | ||
555 | def as_of_tlv(self): |
|
556 | """Return a pyof OXM TLV instance.""" |
|
557 | if '/' in self.value: |
|
558 | value, mask = self.value.split('/') |
|
559 | mask = mask.upper() |
|
560 | if mask == 'FF:FF:FF:FF:FF:FF': |
|
561 | mask = None |
|
562 | oxm_hasmask = False |
|
563 | else: |
|
564 | oxm_hasmask = True |
|
565 | else: |
|
566 | value = self.value |
|
567 | mask = None |
|
568 | oxm_hasmask = False |
|
569 | value_bytes = HWAddress(value).pack() |
|
570 | if mask: |
|
571 | value_bytes += HWAddress(mask).pack() |
|
572 | return OxmTLV(oxm_field=self.oxm_field, |
|
573 | oxm_hasmask=oxm_hasmask, |
|
574 | oxm_value=value_bytes) |
|
575 | ||
576 | @classmethod |
|
577 | def from_of_tlv(cls, tlv): |
|
578 | """Return an instance from a pyof OXM TLV.""" |
|
579 | hw_address = HWAddress() |
|
580 | hw_address.unpack(tlv.oxm_value) |
|
581 | addr_str = str(hw_address) |
|
582 | value = addr_str |
|
583 | if tlv.oxm_hasmask: |
|
584 | hw_mask = HWAddress() |
|
585 | hw_mask.unpack(tlv.oxm_value[6:]) |
|
586 | mask_str = str(hw_mask) |
|
587 | value = f'{addr_str}/{mask_str}' |
|
588 | return cls(value) |
|
589 | ||
590 | ||
591 | class MatchARPTHA(MatchField): |
|
@@ 125-164 (lines=40) @@ | ||
122 | return cls(value) |
|
123 | ||
124 | ||
125 | class MatchDLDst(MatchField): |
|
126 | """Match for datalink destination.""" |
|
127 | ||
128 | name = 'dl_dst' |
|
129 | oxm_field = OxmOfbMatchField.OFPXMT_OFB_ETH_DST |
|
130 | ||
131 | def as_of_tlv(self): |
|
132 | """Return a pyof OXM TLV instance.""" |
|
133 | if '/' in self.value: |
|
134 | value, mask = self.value.split('/') |
|
135 | mask = mask.upper() |
|
136 | if mask == 'FF:FF:FF:FF:FF:FF': |
|
137 | mask = None |
|
138 | oxm_hasmask = False |
|
139 | else: |
|
140 | oxm_hasmask = True |
|
141 | else: |
|
142 | value = self.value |
|
143 | mask = None |
|
144 | oxm_hasmask = False |
|
145 | value_bytes = HWAddress(value).pack() |
|
146 | if mask: |
|
147 | value_bytes += HWAddress(mask).pack() |
|
148 | return OxmTLV(oxm_field=self.oxm_field, |
|
149 | oxm_hasmask=oxm_hasmask, |
|
150 | oxm_value=value_bytes) |
|
151 | ||
152 | @classmethod |
|
153 | def from_of_tlv(cls, tlv): |
|
154 | """Return an instance from a pyof OXM TLV.""" |
|
155 | hw_address = HWAddress() |
|
156 | hw_address.unpack(tlv.oxm_value) |
|
157 | addr_str = str(hw_address) |
|
158 | value = addr_str |
|
159 | if tlv.oxm_hasmask: |
|
160 | hw_mask = HWAddress() |
|
161 | hw_mask.unpack(tlv.oxm_value[6:]) |
|
162 | mask_str = str(hw_mask) |
|
163 | value = f'{addr_str}/{mask_str}' |
|
164 | return cls(value) |
|
165 | ||
166 | ||
167 | class MatchDLType(MatchField): |
|
@@ 83-122 (lines=40) @@ | ||
80 | return cls(priority) |
|
81 | ||
82 | ||
83 | class MatchDLSrc(MatchField): |
|
84 | """Match for datalink source.""" |
|
85 | ||
86 | name = 'dl_src' |
|
87 | oxm_field = OxmOfbMatchField.OFPXMT_OFB_ETH_SRC |
|
88 | ||
89 | def as_of_tlv(self): |
|
90 | """Return a pyof OXM TLV instance.""" |
|
91 | if '/' in self.value: |
|
92 | value, mask = self.value.split('/') |
|
93 | mask = mask.upper() |
|
94 | if mask == 'FF:FF:FF:FF:FF:FF': |
|
95 | mask = None |
|
96 | oxm_hasmask = False |
|
97 | else: |
|
98 | oxm_hasmask = True |
|
99 | else: |
|
100 | value = self.value |
|
101 | mask = None |
|
102 | oxm_hasmask = False |
|
103 | value_bytes = HWAddress(value).pack() |
|
104 | if mask: |
|
105 | value_bytes += HWAddress(mask).pack() |
|
106 | return OxmTLV(oxm_field=self.oxm_field, |
|
107 | oxm_hasmask=oxm_hasmask, |
|
108 | oxm_value=value_bytes) |
|
109 | ||
110 | @classmethod |
|
111 | def from_of_tlv(cls, tlv): |
|
112 | """Return an instance from a pyof OXM TLV.""" |
|
113 | hw_address = HWAddress() |
|
114 | hw_address.unpack(tlv.oxm_value) |
|
115 | addr_str = str(hw_address) |
|
116 | value = addr_str |
|
117 | if tlv.oxm_hasmask: |
|
118 | hw_mask = HWAddress() |
|
119 | hw_mask.unpack(tlv.oxm_value[6:]) |
|
120 | mask_str = str(hw_mask) |
|
121 | value = f'{addr_str}/{mask_str}' |
|
122 | return cls(value) |
|
123 | ||
124 | ||
125 | class MatchDLDst(MatchField): |