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

Class H2PaddedPushPromiseFrame

scapy/contrib/http2.py:1807–1859  ·  view source on GitHub ↗

H2PaddedPushPromiseFrame implements RFC7540 par6.6. This packet is the variant to use when the underlayer padding flag is set

Source from the content-addressed store, hash-verified

1805
1806
1807class H2PaddedPushPromiseFrame(H2PushPromiseFrame):
1808 """ H2PaddedPushPromiseFrame implements RFC7540 par6.6. This
1809 packet is the variant to use when the underlayer padding flag is set
1810 """
1811 __slots__ = ['s_len']
1812
1813 name = 'HTTP/2 Padded Push Promise Frame'
1814 fields_desc = [
1815 fields.FieldLenField('padlen', None, length_of='padding', fmt='B'),
1816 fields.BitField('reserved', 0, 1),
1817 fields.BitField('stream_id', 0, 31),
1818 fields.PacketListField('hdrs', [], HPackHeaders,
1819 length_from=lambda pkt: pkt.get_hdrs_len()
1820 ),
1821 fields.StrLenField('padding', '',
1822 length_from=lambda pkt: pkt.getfieldval('padlen')
1823 )
1824 ]
1825
1826 def get_hdrs_len(self):
1827 # type: () -> int
1828 """ get_hdrs_len computes the length of the hdrs field
1829
1830 To do this computation, the length of the padlen field, reserved,
1831 stream_id and the actual padding is subtracted to the string that was
1832 provided to the pre_dissect fun of the pkt parameter.
1833 :return: int: the length of the hdrs field
1834 :raises: AssertionError
1835 """
1836 fld, padding_len = self.getfield_and_val('padlen')
1837 padding_len_len = fld.i2len(self, padding_len)
1838 bit_len = self.get_field('reserved').size
1839 bit_len += self.get_field('stream_id').size
1840
1841 ret = int(self.s_len -
1842 padding_len_len -
1843 padding_len -
1844 (bit_len / 8)
1845 )
1846 assert ret >= 0
1847 return ret
1848
1849 def pre_dissect(self, s):
1850 # type: (str) -> str
1851 """pre_dissect is filling the s_len property of this instance. This
1852 property is later used during the parsing of the hdrs PacketListField
1853 when trying to evaluate the length of the PacketListField! This "trick"
1854 works because the underlayer packet (H2Frame) is assumed to override the # noqa: E501
1855 "extract_padding" method and to only provide to this packet the data
1856 necessary for this packet. Tricky, tricky, will break some day probably! # noqa: E501
1857 """
1858 self.s_len = len(s)
1859 return s
1860
1861# HTTP/2 Ping Frame Packets # # noqa: E501
1862

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…