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

Class DataPacket

scapy/contrib/rtps/rtps.py:165–208  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

163
164
165class DataPacket(EPacket):
166 name = "Data Packet"
167 _pl_type = None
168 _pl_len = 0
169
170 fields_desc = [
171 XShortField("encapsulationKind", 0),
172 XShortField("encapsulationOptions", 0),
173 # if payload encoding == PL_CDR_{LE,BE} then parameter list
174 ConditionalField(
175 EPacketField("parameterList", "", ParameterListPacket),
176 lambda pkt: pkt.encapsulationKind == 0x0003,
177 ),
178 # if writer entity id == 0x200c2: then participant message data
179 ConditionalField(
180 EPacketField(
181 "participantMessageData", "", ParticipantMessageDataPacket),
182 lambda pkt: pkt._pl_type == "ParticipantMessageData",
183 ),
184 # else (neither the cases)
185 ConditionalField(
186 SerializedDataField(
187 "serializedData", "", length_from=lambda pkt: pkt._pl_len
188 ),
189 lambda pkt: (
190 pkt.encapsulationKind != 0x0003 \
191 and pkt._pl_type != "ParticipantMessageData"
192 ),
193 ),
194 ]
195
196 def __init__(self, *args, **kwargs):
197 writer_entity_id_key = kwargs.pop("writer_entity_id_key", None)
198 writer_entity_id_kind = kwargs.pop("writer_entity_id_kind", None)
199 pl_len = kwargs.pop("pl_len", 0)
200 if (writer_entity_id_key == 0x200 or writer_entity_id_key == 0x100) and \
201 writer_entity_id_kind == 0xC2:
202 DataPacket._pl_type = "ParticipantMessageData"
203 else:
204 DataPacket._pl_type = "SerializedData"
205
206 DataPacket._pl_len = pl_len
207
208 super(DataPacket, self).__init__(*args, **kwargs)
209
210
211class RTPSSubMessage_DATA(EPacket):

Callers

nothing calls this directly

Calls 4

XShortFieldClass · 0.90
ConditionalFieldClass · 0.90
EPacketFieldClass · 0.90
SerializedDataFieldClass · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…