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

Method addfield

scapy/layers/dcerpc.py:1744–1766  ·  view source on GitHub ↗
(self, pkt, s, val)

Source from the content-addressed store, hash-verified

1742 )
1743
1744 def addfield(self, pkt, s, val):
1745 if val is not None and not isinstance(val, NDRPointer):
1746 raise ValueError(
1747 "Expected NDRPointer in %s. You are using it wrong!" % self.name
1748 )
1749 fmt = _e(pkt.ndrendian) + ["I", "Q"][pkt.ndr64]
1750 fld = NDRAlign(Field("", 0, fmt=fmt), align=(4, 8))
1751
1752 # No value
1753 if val is None and not self.EMBEDDED_REF:
1754 return fld.addfield(pkt, s, 0)
1755
1756 # With value
1757 _set_ctx_on(val.value, pkt)
1758 s = fld.addfield(pkt, s, val.referent_id)
1759 if self.EMBEDDED:
1760 # deferred
1761 pkt.deferred_pointers.append(
1762 ((lambda s: self.fld.addfield(pkt, s, val.value)), val)
1763 )
1764 return s
1765
1766 return self.fld.addfield(pkt, s, val.value)
1767
1768 def any2i(self, pkt, x):
1769 # User-friendly helper

Callers

nothing calls this directly

Calls 6

FieldClass · 0.90
_eFunction · 0.85
NDRAlignClass · 0.85
_set_ctx_onFunction · 0.85
addfieldMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected