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
cdb33d87
Commit
cdb33d87
authored
7 years ago
by
Pierre LALET
Browse files
Options
Downloads
Patches
Plain Diff
TUN/TAP tests: bring interfaces up
parent
1f871459
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/sendsniff.uts
+26
-6
26 additions, 6 deletions
test/sendsniff.uts
with
26 additions
and
6 deletions
test/sendsniff.uts
+
26
−
6
View file @
cdb33d87
...
@@ -9,15 +9,25 @@
...
@@ -9,15 +9,25 @@
~ tap linux
~ tap linux
= Create two tap interfaces
= Create two tap interfaces
tap0, tap1 = [TunTapInterface("tap%d" % i, create=True) for i in range(2)]
import subprocess
from threading import Thread
from threading import Thread
tap0, tap1 = [TunTapInterface("tap%d" % i) for i in range(2)]
if LINUX:
for i in range(2):
assert subprocess.check_call(["ip", "link", "set", "tap%d" % i, "up"]) == 0
else:
for i in range(2):
assert subprocess.check_call(["ifconfig", "tap%d" % i, "up"]) == 0
= Run a sniff thread on the tap1 **interface**
= Run a sniff thread on the tap1 **interface**
* It will terminate when 5 IP packets from 1.2.3.4 have been sniffed
* It will terminate when 5 IP packets from 1.2.3.4 have been sniffed
t_sniff = Thread(
t_sniff = Thread(
target=sniff,
target=sniff,
kwargs={"iface": "tap1", "count": 5, "prn": Packet.summary,
kwargs={"iface": "tap1", "count": 5, "prn": Packet.summary,
"lfilter": lambda p: IP in p and p[IP].src == "1.2.3.4"}
"lfilter": lambda p: IP in p and p[IP].src == "1.2.3.4"}
)
)
t_sniff.start()
t_sniff.start()
...
@@ -42,7 +52,7 @@ t_sniff.join()
...
@@ -42,7 +52,7 @@ t_sniff.join()
t_sniff = Thread(
t_sniff = Thread(
target=sniff,
target=sniff,
kwargs={"iface": "tap1", "count": 5, "prn": Packet.summary,
kwargs={"iface": "tap1", "count": 5, "prn": Packet.summary,
"lfilter": lambda p: IP in p and p[IP].src == "2.3.4.5"}
"lfilter": lambda p: IP in p and p[IP].src == "2.3.4.5"}
)
)
t_sniff.start()
t_sniff.start()
...
@@ -81,15 +91,25 @@ del tap0, tap1
...
@@ -81,15 +91,25 @@ del tap0, tap1
~ tun linux not_pcapdnet
~ tun linux not_pcapdnet
= Create two tun interfaces
= Create two tun interfaces
tun0, tun1 = [TunTapInterface("tun%d" % i, create=True) for i in range(2)]
import subprocess
from threading import Thread
from threading import Thread
tun0, tun1 = [TunTapInterface("tun%d" % i) for i in range(2)]
if LINUX:
for i in range(2):
assert subprocess.check_call(["ip", "link", "set", "tun%d" % i, "up"]) == 0
else:
for i in range(2):
assert subprocess.check_call(["ifconfig", "tun%d" % i, "up"]) == 0
= Run a sniff thread on the tun1 **interface**
= Run a sniff thread on the tun1 **interface**
* It will terminate when 5 IP packets from 1.2.3.4 have been sniffed
* It will terminate when 5 IP packets from 1.2.3.4 have been sniffed
t_sniff = Thread(
t_sniff = Thread(
target=sniff,
target=sniff,
kwargs={"iface": "tun1", "count": 5, "prn": Packet.summary,
kwargs={"iface": "tun1", "count": 5, "prn": Packet.summary,
"lfilter": lambda p: IP in p and p[IP].src == "1.2.3.4"}
"lfilter": lambda p: IP in p and p[IP].src == "1.2.3.4"}
)
)
t_sniff.start()
t_sniff.start()
...
@@ -116,7 +136,7 @@ t_sniff.join()
...
@@ -116,7 +136,7 @@ t_sniff.join()
t_sniff = Thread(
t_sniff = Thread(
target=sniff,
target=sniff,
kwargs={"iface": "tun1", "count": 5, "prn": Packet.summary,
kwargs={"iface": "tun1", "count": 5, "prn": Packet.summary,
"lfilter": lambda p: IP in p and p[IP].src == "2.3.4.5"}
"lfilter": lambda p: IP in p and p[IP].src == "2.3.4.5"}
)
)
t_sniff.start()
t_sniff.start()
...
...
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