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

Function _socket_changer

scapy/config.py:883–904  ·  view source on GitHub ↗
(attr, val, old)

Source from the content-addressed store, hash-verified

881
882
883def _socket_changer(attr, val, old):
884 # type: (str, bool, bool) -> Any
885 if not isinstance(val, bool):
886 raise TypeError("This argument should be a boolean")
887 Interceptor.set_from_hook(conf, attr, val)
888 dependencies = { # Things that will be turned off
889 "use_pcap": ["use_bpf"],
890 "use_bpf": ["use_pcap"],
891 }
892 restore = {k: getattr(conf, k) for k in dependencies}
893 del restore[attr] # This is handled directly by _set_conf_sockets
894 if val: # Only if True
895 for param in dependencies[attr]:
896 Interceptor.set_from_hook(conf, param, False)
897 try:
898 _set_conf_sockets()
899 except (ScapyInvalidPlatformException, ImportError) as e:
900 for key, value in restore.items():
901 Interceptor.set_from_hook(conf, key, value)
902 if isinstance(e, ScapyInvalidPlatformException):
903 raise
904 return getattr(conf, attr)
905
906
907def _loglevel_changer(attr, val, old):

Callers

nothing calls this directly

Calls 3

_set_conf_socketsFunction · 0.85
set_from_hookMethod · 0.80
itemsMethod · 0.80

Tested by

no test coverage detected