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

Method send

scapy/arch/linux/__init__.py:347–390  ·  view source on GitHub ↗
(self, x)

Source from the content-addressed store, hash-verified

345 return pkt
346
347 def send(self, x):
348 # type: (Packet) -> int
349 # Select the file descriptor to send the packet on.
350 iff = x.route()[0]
351 if iff is None:
352 iff = network_name(conf.iface)
353 type_x = type(x)
354 if iff not in self.send_socks:
355 self.send_socks[iff] = L3PacketSocket(
356 iface=iff,
357 type=conf.l3types.layer2num.get(type_x, self.type),
358 filter=self.filter,
359 promisc=self.promisc,
360 )
361 sock = self.send_socks[iff]
362 fd = sock.outs
363 if sock.lvl == 3:
364 if not issubclass(sock.LL, type_x):
365 warning("Incompatible L3 types detected using %s instead of %s !",
366 type_x, sock.LL)
367 sock.LL = type_x
368 if sock.lvl == 2:
369 sx = bytes(sock.LL() / x)
370 else:
371 sx = bytes(x)
372 # Now send.
373 try:
374 x.sent_time = time.time()
375 except AttributeError:
376 pass
377 try:
378 return fd.send(sx)
379 except socket.error as msg:
380 if msg.errno == 22 and len(sx) < conf.min_pkt_size:
381 return fd.send(
382 sx + b"\x00" * (conf.min_pkt_size - len(sx))
383 )
384 elif conf.auto_fragment and msg.errno == 90:
385 i = 0
386 for p in x.fragment():
387 i += fd.send(bytes(self.LL() / p))
388 return i
389 else:
390 raise
391
392 @staticmethod
393 def select(sockets, remain=None):

Callers

nothing calls this directly

Calls 7

network_nameFunction · 0.90
warningFunction · 0.90
L3PacketSocketClass · 0.85
routeMethod · 0.45
getMethod · 0.45
sendMethod · 0.45
fragmentMethod · 0.45

Tested by

no test coverage detected