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

Class _ExtcapNetworkInterface

scapy/libs/extcap.py:84–127  ·  view source on GitHub ↗

Extcap NetworkInterface

Source from the content-addressed store, hash-verified

82
83
84class _ExtcapNetworkInterface(NetworkInterface):
85 """
86 Extcap NetworkInterface
87 """
88
89 def get_extcap_config(self) -> Dict[str, Tuple[str, ...]]:
90 """
91 Return a list of available configuration options on an extcap interface
92 """
93 return _extcap_call(
94 self.provider.cmdprog, # type: ignore
95 ["--extcap-interface", self.network_name, "--extcap-config"],
96 {
97 "arg": ["number", "call", "display", "default", "required"],
98 "value": ["arg", "value", "display", "default"],
99 },
100 )
101
102 def get_extcap_cmd(self, **kwarg: Dict[str, str]) -> List[str]:
103 """
104 Return the extcap command line options
105 """
106 cmds = []
107 for x in self.get_extcap_config()["arg"]:
108 key = x[1].strip("-").replace("-", "_")
109 if key in kwarg:
110 # Apply argument
111 cmds += [x[1], str(kwarg[key])]
112 else:
113 # Apply default
114 if x[4] == "true": # required
115 raise ValueError(
116 "Missing required argument: '%s' on iface %s." % (
117 key,
118 self.network_name,
119 )
120 )
121 elif not x[3] or x[3] == "false": # no default (or false)
122 continue
123 if x[3] == "true":
124 cmds += [x[1]]
125 else:
126 cmds += [x[1], x[3]]
127 return cmds
128
129
130class _ExtcapSocket(SuperSocket):

Callers 1

loadMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected