HPackHdrString is a packet that that is serialized into a RFC7541 par5.2 string literal repr.
| 1298 | |
| 1299 | |
| 1300 | class HPackHdrString(packet.Packet): |
| 1301 | """ HPackHdrString is a packet that that is serialized into a RFC7541 par5.2 |
| 1302 | string literal repr. |
| 1303 | """ |
| 1304 | name = 'HPack Header String' |
| 1305 | fields_desc = [ |
| 1306 | fields.BitEnumField('type', None, 1, {0: 'Literal', 1: 'Compressed'}), |
| 1307 | FieldUVarLenField('len', None, 7, length_of='data'), |
| 1308 | HPackStrLenField( |
| 1309 | 'data', HPackLiteralString(''), |
| 1310 | length_from=lambda pkt: pkt.getfieldval('len'), |
| 1311 | type_from='type' |
| 1312 | ) |
| 1313 | ] |
| 1314 | |
| 1315 | def guess_payload_class(self, payload): |
| 1316 | # type: (str) -> Packet_metaclass |
| 1317 | # Trick to tell scapy that the remaining bytes of the currently |
| 1318 | # dissected string is not a payload of this packet but of some other |
| 1319 | # underlayer packet |
| 1320 | return config.conf.padding_layer |
| 1321 | |
| 1322 | def self_build(self, **kwargs): |
| 1323 | # type: (Any) -> str |
| 1324 | """self_build is overridden because type and len are determined at |
| 1325 | build time, based on the "data" field internal type |
| 1326 | """ |
| 1327 | if self.getfieldval('type') is None: |
| 1328 | self.type = 1 if isinstance(self.getfieldval('data'), HPackZString) else 0 # noqa: E501 |
| 1329 | return super(HPackHdrString, self).self_build(**kwargs) |
| 1330 | |
| 1331 | |
| 1332 | class HPackHeaders(packet.Packet): |
no test coverage detected
searching dependent graphs…