representation of one MACsec frame
| 208 | |
| 209 | |
| 210 | class MACsec(Packet): |
| 211 | """representation of one MACsec frame""" |
| 212 | name = '802.1AE' |
| 213 | deprecated_fields = { |
| 214 | 'an': ("AN", "2.4.4"), |
| 215 | 'pn': ("PN", "2.4.4"), |
| 216 | 'sci': ("SCI", "2.4.4"), |
| 217 | 'shortlen': ("SL", "2.4.4"), |
| 218 | } |
| 219 | # 802.1AE-2018 - Section 9 |
| 220 | fields_desc = [ |
| 221 | # 802.1AE-2018 - Section 9.5 |
| 222 | BitField('Ver', 0, 1), |
| 223 | BitField('ES', 0, 1), # End Station |
| 224 | BitField('SC', 0, 1), # Secure Channel |
| 225 | BitField('SCB', 0, 1), # Single Copy Broadcast |
| 226 | BitField('E', 0, 1), # Encryption |
| 227 | BitField('C', 0, 1), # Changed Text |
| 228 | BitField('AN', 0, 2), # Association Number |
| 229 | # 802.1AE-2018 - Section 9.7 |
| 230 | BitField('reserved', 0, 2), |
| 231 | BitField('SL', 0, 6), # Short Length |
| 232 | # 802.1AE-2018 - Section 9.8 |
| 233 | IntField("PN", 1), # Packet Number |
| 234 | # 802.1AE-2018 - Section 9.9 |
| 235 | ConditionalField( |
| 236 | PacketField("SCI", None, MACsecSCI), |
| 237 | lambda pkt: pkt.SC |
| 238 | ), |
| 239 | # Off-spec. Used for conveniency (only present if passed manually) |
| 240 | ConditionalField(XShortEnumField("type", None, ETHER_TYPES), |
| 241 | lambda pkt: "type" in pkt.fields)] |
| 242 | |
| 243 | def mysummary(self): |
| 244 | summary = self.sprintf("AN=%MACsec.AN%, PN=%MACsec.PN%") |
| 245 | if self.SC: |
| 246 | summary += self.sprintf(", SCI=%MACsec.SCI%") |
| 247 | if self.type is not None: |
| 248 | summary += self.sprintf(", %MACsec.type%") |
| 249 | return summary |
| 250 | |
| 251 | |
| 252 | bind_layers(MACsec, IP, type=ETH_P_IP) |
no test coverage detected