MCPcopy Create free account
hub / github.com/secdev/scapy / H2PaddedHeadersFrame

Class H2PaddedHeadersFrame

scapy/contrib/http2.py:1525–1570  ·  view source on GitHub ↗

H2PaddedHeadersFrame is the variant of H2HeadersFrame where padding flag is set and priority flag is cleared

Source from the content-addressed store, hash-verified

1523
1524
1525class H2PaddedHeadersFrame(H2AbstractHeadersFrame):
1526 """ H2PaddedHeadersFrame is the variant of H2HeadersFrame where padding flag
1527 is set and priority flag is cleared
1528 """
1529 __slots__ = ['s_len']
1530
1531 name = 'HTTP/2 Headers Frame with Padding'
1532 fields_desc = [
1533 fields.FieldLenField('padlen', None, length_of='padding', fmt='B'),
1534 fields.PacketListField('hdrs', [], HPackHeaders,
1535 length_from=lambda pkt: pkt.get_hdrs_len()
1536 ),
1537 fields.StrLenField('padding', '',
1538 length_from=lambda pkt: pkt.getfieldval('padlen')
1539 )
1540 ]
1541
1542 def get_hdrs_len(self):
1543 # type: () -> int
1544 """ get_hdrs_len computes the length of the hdrs field
1545
1546 To do this computation, the length of the padlen field and the actual
1547 padding is subtracted to the string that was provided to the pre_dissect # noqa: E501
1548 fun of the pkt parameter.
1549 :return: int; length of the data part of the HTTP/2 frame packet provided as parameter # noqa: E501
1550 :raises: AssertionError
1551 """
1552 padding_len = self.getfieldval('padlen')
1553 fld, fval = self.getfield_and_val('padlen')
1554 padding_len_len = fld.i2len(self, fval)
1555
1556 ret = self.s_len - padding_len_len - padding_len
1557 assert ret >= 0
1558 return ret
1559
1560 def pre_dissect(self, s):
1561 # type: (str) -> str
1562 """pre_dissect is filling the s_len property of this instance. This
1563 property is later used during the parsing of the hdrs PacketListField
1564 when trying to evaluate the length of the PacketListField! This "trick"
1565 works because the underlayer packet (H2Frame) is assumed to override the # noqa: E501
1566 "extract_padding" method and to only provide to this packet the data
1567 necessary for this packet. Tricky, tricky, will break some day probably! # noqa: E501
1568 """
1569 self.s_len = len(s)
1570 return s
1571
1572
1573class H2PriorityHeadersFrame(H2AbstractHeadersFrame):

Callers

nothing calls this directly

Calls 2

get_hdrs_lenMethod · 0.45
getfieldvalMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…