Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
scapy
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CodeLinaro
public-release-test-restored
platform
external
scapy
Commits
1f871459
Commit
1f871459
authored
7 years ago
by
Pierre LALET
Browse files
Options
Downloads
Patches
Plain Diff
TUN/TAP: remove .create() / .delete() methods
parent
a8b37396
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scapy/supersocket.py
+3
-45
3 additions, 45 deletions
scapy/supersocket.py
with
3 additions
and
45 deletions
scapy/supersocket.py
+
3
−
45
View file @
1f871459
...
...
@@ -208,18 +208,14 @@ class L2ListenTcpdump(SuperSocket):
class
TunTapInterface
(
SuperSocket
):
"""
A socket to act as the host
'
s peer of a tun / tap interface. The
interface can also be created, using `create=True`.
"""
A socket to act as the host
'
s peer of a tun / tap interface.
"""
desc
=
"
Act as the host
'
s peer of a tun / tap interface
"
def
__init__
(
self
,
iface
=
None
,
create
=
False
,
mode_tun
=
None
,
*
arg
,
**
karg
):
def
__init__
(
self
,
iface
=
None
,
mode_tun
=
None
,
*
arg
,
**
karg
):
self
.
iface
=
conf
.
iface
if
iface
is
None
else
iface
self
.
mode_tun
=
(
"
tun
"
in
iface
)
if
mode_tun
is
None
else
mode_tun
self
.
created
=
False
if
create
:
self
.
create
()
self
.
closed
=
True
self
.
open
()
...
...
@@ -228,47 +224,9 @@ interface can also be created, using `create=True`.
def
__del__
(
self
):
self
.
close
()
self
.
delete
()
def
__exit__
(
self
,
*
_
):
pass
def
create
(
self
):
"""
Create the TUN or TAP interface, using system commands (ip on
Linux, ifconfig on *BSD & Darwin).
"""
if
self
.
created
:
return
if
LINUX
:
for
cmd
in
[
[
"
ip
"
,
"
tuntap
"
,
"
add
"
,
"
mode
"
,
"
tun
"
if
self
.
mode_tun
else
"
tap
"
,
"
name
"
,
self
.
iface
],
[
"
ip
"
,
"
link
"
,
"
set
"
,
self
.
iface
,
"
up
"
],
]:
subprocess
.
check_call
(
cmd
)
elif
OPENBSD
and
not
self
.
mode_tun
:
subprocess
.
check_call
([
"
ifconfig
"
,
self
.
iface
,
"
create
"
,
"
link0
"
])
elif
BSD
:
subprocess
.
check_call
([
"
ifconfig
"
,
self
.
iface
,
"
create
"
])
else
:
raise
RuntimeError
(
"
Don
'
t know how to create %s
"
%
self
.
iface
)
self
.
created
=
True
def
delete
(
self
):
"""
Destroy the TUN or TAP interface, using system commands (ip on
Linux, ifconfig on *BSD & Darwin).
"""
if
not
self
.
created
:
return
if
LINUX
:
subprocess
.
check_call
([
"
ip
"
,
"
tuntap
"
,
"
del
"
,
"
mode
"
,
"
tun
"
if
self
.
mode_tun
else
"
tap
"
,
"
name
"
,
self
.
iface
])
elif
BSD
:
subprocess
.
check_call
([
"
ifconfig
"
,
self
.
iface
,
"
destroy
"
])
self
.
created
=
False
self
.
close
()
def
open
(
self
):
"""
Open the TUN or TAP device.
"""
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment