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

Method addfield

scapy/contrib/http2.py:583–600  ·  view source on GitHub ↗

:param packet.Packet|None pkt: the packet instance containing this field instance. This parameter must not be # noqa: E501 None if the val parameter is. :param str|(str, int, long) s: the string to append this field to. A tuple indicates that some bits were already # noq

(self, pkt, s, val)

Source from the content-addressed store, hash-verified

581 self._adjust = adjust
582
583 def addfield(self, pkt, s, val):
584 # type: (Optional[packet.Packet], Union[str, Tuple[str, int, int]], Optional[int]) -> str # noqa: E501
585 """
586 :param packet.Packet|None pkt: the packet instance containing this field instance. This parameter must not be # noqa: E501
587 None if the val parameter is.
588 :param str|(str, int, long) s: the string to append this field to. A tuple indicates that some bits were already # noqa: E501
589 generated by another bitfield-compatible field. This MUST be the case if "size" is not 8. The int is the # noqa: E501
590 number of bits already generated in the first byte of the str. The long is the value that was generated by the # noqa: E501
591 previous bitfield-compatible fields.
592 :param int|None val: the positive or null value to be added. If None, the value is computed from pkt. # noqa: E501
593 :return: str: s concatenated with the machine representation of this field. # noqa: E501
594 :raises: AssertionError
595 """
596 if val is None:
597 assert isinstance(pkt, packet.Packet), \
598 'EINVAL: pkt: Packet expected when val is None; received {}'.format(type(pkt)) # noqa: E501
599 val = self._compute_value(pkt)
600 return super(FieldUVarLenField, self).addfield(pkt, s, val)
601
602 def i2m(self, pkt, x):
603 # type: (Optional[packet.Packet], Optional[int]) -> str

Callers

nothing calls this directly

Calls 3

_compute_valueMethod · 0.95
formatMethod · 0.45
addfieldMethod · 0.45

Tested by

no test coverage detected