:param packet.Packet|None pkt: the packet instance containing this field instance; probably unused. # noqa: E501 :param str|(str, int) s: either a str if size%8==0 or a tuple with the string to parse from and the number of # noqa: E501 bits already consumed by previous b
(self, pkt, s)
| 88 | return super(HPackMagicBitField, self).addfield(pkt, s, self._magic) |
| 89 | |
| 90 | def getfield(self, pkt, s): |
| 91 | # type: (Optional[packet.Packet], Union[str, Tuple[str, int]]) -> Tuple[Union[Tuple[str, int], str], int] # noqa: E501 |
| 92 | """ |
| 93 | :param packet.Packet|None pkt: the packet instance containing this field instance; probably unused. # noqa: E501 |
| 94 | :param str|(str, int) s: either a str if size%8==0 or a tuple with the string to parse from and the number of # noqa: E501 |
| 95 | bits already consumed by previous bitfield-compatible fields. |
| 96 | :return: (str|(str, int), int): Returns the remaining string and the parsed value. May return a tuple if there # noqa: E501 |
| 97 | are remaining bits to parse in the first byte. Returned value is equal to default value # noqa: E501 |
| 98 | :raises: AssertionError |
| 99 | """ |
| 100 | r = super(HPackMagicBitField, self).getfield(pkt, s) |
| 101 | assert ( |
| 102 | isinstance(r, tuple) and |
| 103 | len(r) == 2 and |
| 104 | isinstance(r[1], int) |
| 105 | ), 'Second element of BitField.getfield return value expected to be an int or a long; API change detected' # noqa: E501 |
| 106 | assert r[1] == self._magic, 'Invalid value parsed from s; error in class guessing detected!' # noqa: E501 |
| 107 | return r |
| 108 | |
| 109 | def h2i(self, pkt, x): |
| 110 | # type: (Optional[packet.Packet], int) -> int |