MCPcopy Create free account
hub / github.com/USArmyResearchLab/Dshell / add_packet

Method add_packet

dshell/core.py:1271–1306  ·  view source on GitHub ↗

Adds packet to connection. :param packet: a Packet object to add to the connection

(self, packet: Packet)

Source from the content-addressed store, hash-verified

1269 yield from blobs
1270
1271 def add_packet(self, packet: Packet):
1272 """
1273 Adds packet to connection.
1274
1275 :param packet: a Packet object to add to the connection
1276 """
1277 if packet.sip not in (self.sip, self.dip):
1278 raise ValueError(f"Address {repr(packet.sip)} is not part of connection.")
1279
1280 self.packets.append(packet)
1281 # A new packet means we might need to recalculate all of the blobs
1282 self._blob_cache = []
1283
1284 # Adjust state if packet is part of a startup or shutdown.
1285 if packet.tcp_flags is not None:
1286 # Acknowledging a completed handshake to open connection.
1287 if packet.tcp_flags == (tcp.TH_SYN | tcp.TH_ACK):
1288 self.server_state = self.ESTABLISHED
1289 self.client_state = self.ESTABLISHED
1290
1291 # Asking to close connection.
1292 elif packet.tcp_flags & (tcp.TH_FIN | tcp.TH_RST):
1293 if packet.sip == self.serverip:
1294 self.server_state = self.FINISHING
1295 else:
1296 self.client_state = self.FINISHING
1297
1298 # Closing connection acknowledged.
1299 elif packet.tcp_flags & tcp.TH_ACK:
1300 if packet.dip == self.serverip and self.server_state == self.FINISHING:
1301 self.server_state = self.CLOSED
1302 elif packet.dip == self.clientip and self.client_state == self.FINISHING:
1303 self.client_state = self.CLOSED
1304
1305 if packet.dt > self.endtime:
1306 self.endtime = packet.dt
1307
1308 def info(self):
1309 """

Callers 2

_connection_handlerMethod · 0.95
__init__Method · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected