MCPcopy Index your code
hub / github.com/secdev/scapy / addfield

Method addfield

scapy/fields.py:232–247  ·  view source on GitHub ↗

Add an internal value to a string Copy the network representation of field `val` (belonging to layer `pkt`) to the raw string packet `s`, and return the new string packet.

(self, pkt, s, val)

Source from the content-addressed store, hash-verified

230 return repr(self.i2h(pkt, x))
231
232 def addfield(self, pkt, s, val):
233 # type: (Packet, bytes, Optional[I]) -> bytes
234 """Add an internal value to a string
235
236 Copy the network representation of field `val` (belonging to layer
237 `pkt`) to the raw string packet `s`, and return the new string packet.
238 """
239 try:
240 return s + self.struct.pack(self.i2m(pkt, val))
241 except struct.error as ex:
242 raise ValueError(
243 "Incorrect type of value for field %s:\n" % self.name +
244 "struct.error('%s')\n" % ex +
245 "To inject bytes into the field regardless of the type, " +
246 "use RawVal. See help(RawVal)"
247 )
248
249 def getfield(self, pkt, s):
250 # type: (Packet, bytes) -> Tuple[bytes, I]

Callers 9

addfieldMethod · 0.45
addfieldMethod · 0.45
addfieldMethod · 0.45
addfieldMethod · 0.45
addfieldMethod · 0.45
addfieldMethod · 0.45
addfieldMethod · 0.45
self_buildMethod · 0.45
do_build_psMethod · 0.45

Calls 1

i2mMethod · 0.95

Tested by

no test coverage detected