MCPcopy
hub / github.com/USArmyResearchLab/Dshell / packet_handler

Method packet_handler

dshell/plugins/voip/rtp.py:81–105  ·  view source on GitHub ↗
(self, pkt)

Source from the content-addressed store, hash-verified

79 self.payload_type[i] = "Dynamic"
80
81 def packet_handler(self, pkt):
82 # Scrape out the UDP layer of the packet
83 udpp = pkt.pkt.upper_layer
84 while not isinstance(udpp, udp.UDP):
85 try:
86 udpp = udpp.upper_layer
87 except AttributeError:
88 # There doesn't appear to be an UDP layer
89 return
90
91 # Parse the RTP protocol from above the UDP layer
92 rtpp = rtp.RTP(udpp.body_bytes)
93
94 if rtpp.version != 2:
95 # RTP should always be version 2
96 return
97
98 pt = self.payload_type.get(rtpp.pt, "??")
99
100 self.write("\n\tFrom: {0} ({1}) to {2} ({3}) \n\tPayload Type (7 bits): {4}\n\tSequence Number (16 bits): {5}\n\tTimestamp (32 bits): {6} \n\tSynchronization source (32 bits): {7}\n\tArrival Time: {8} --> {9}\n\tContributing source (32 bits): {10}, Padding (1 bit): {11}, Extension (1 bit): {12}, Marker (1 bit): {13}\n".format(
101 pkt.sip, pkt.smac, pkt.dip, pkt.dmac, pt, rtpp.seq, rtpp.ts,
102 rtpp.ssrc, pkt.ts, datetime.datetime.utcfromtimestamp(pkt.ts),
103 rtpp.cc, rtpp.p, rtpp.x, rtpp.m), **pkt.info())
104
105 return pkt

Callers

nothing calls this directly

Calls 2

writeMethod · 0.45
infoMethod · 0.45

Tested by

no test coverage detected