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

Class CoAP

scapy/contrib/coap.py:212–236  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

210
211
212class CoAP(Packet):
213 __slots__ = ["content_format"]
214 name = "CoAP"
215
216 fields_desc = [BitField("ver", 1, 2),
217 BitEnumField("type", 0, 2, {0: "CON", 1: "NON", 2: "ACK", 3: "RST"}), # noqa: E501
218 BitFieldLenField("tkl", None, 4, length_of='token'),
219 ByteEnumField("code", 0, coap_codes),
220 ShortField("msg_id", 0),
221 StrLenField("token", "", length_from=lambda pkt: pkt.tkl),
222 _CoAPOptsField("options", []),
223 _CoAPPaymark("paymark", b"")
224 ]
225
226 def getfieldval(self, attr):
227 v = getattr(self, attr)
228 if v:
229 return v
230 return Packet.getfieldval(self, attr)
231
232 def post_dissect(self, pay):
233 for k in self.options:
234 if k[0] == "Content-Format":
235 self.content_format = k[1]
236 return pay
237
238
239bind_layers(UDP, CoAP, sport=5683)

Callers

nothing calls this directly

Calls 8

BitFieldClass · 0.90
BitEnumFieldClass · 0.90
BitFieldLenFieldClass · 0.90
ByteEnumFieldClass · 0.90
ShortFieldClass · 0.90
StrLenFieldClass · 0.90
_CoAPOptsFieldClass · 0.85
_CoAPPaymarkClass · 0.85

Tested by

no test coverage detected