Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bcc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
bcc
Commits
ef0b9849
Commit
ef0b9849
authored
Mar 26, 2017
by
Brenden Blanco
Committed by
GitHub
Mar 26, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1066 from pchaigno/remove-import-netaddr
solisten: replace netaddr with socket library
parents
78948e4a
83320685
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
11 deletions
+8
-11
tools/solisten.py
tools/solisten.py
+8
-11
No files found.
tools/solisten.py
View file @
ef0b9849
...
...
@@ -18,8 +18,8 @@
# 04-Mar-2016 Jean-Tiare Le Bigot Created this.
import
os
import
socket
import
netaddr
from
socket
import
inet_ntop
,
AF_INET
,
AF_INET6
,
SOCK_STREAM
,
SOCK_DGRAM
from
struct
import
pack
import
argparse
from
bcc
import
BPF
import
ctypes
as
ct
...
...
@@ -110,8 +110,6 @@ int kprobe__inet_listen(struct pt_regs *ctx, struct socket *sock, int backlog)
} else if (family == AF_INET6) {
bpf_probe_read(evt.laddr, sizeof(evt.laddr),
sk->__sk_common.skc_v6_rcv_saddr.in6_u.u6_addr32);
evt.laddr[0] = be64_to_cpu(evt.laddr[0]);
evt.laddr[1] = be64_to_cpu(evt.laddr[1]);
}
// Send event to userland
...
...
@@ -147,20 +145,19 @@ def event_printer(show_netns):
proto_family
=
event
.
proto
&
0xff
proto_type
=
event
.
proto
>>
16
&
0xff
if
proto_family
==
socket
.
SOCK_STREAM
:
if
proto_family
==
SOCK_STREAM
:
protocol
=
"TCP"
elif
proto_family
==
socket
.
SOCK_DGRAM
:
elif
proto_family
==
SOCK_DGRAM
:
protocol
=
"UDP"
else
:
protocol
=
"UNK"
address
=
""
if
proto_type
==
socket
.
AF_INET
:
if
proto_type
==
AF_INET
:
protocol
+=
"v4"
address
=
netaddr
.
IPAddress
(
event
.
laddr
[
0
])
elif
proto_type
==
socket
.
AF_INET6
:
address
=
netaddr
.
IPAddress
(
event
.
laddr
[
0
]
<<
64
|
event
.
laddr
[
1
],
version
=
6
)
address
=
inet_ntop
(
AF_INET
,
pack
(
"I"
,
event
.
laddr
[
0
]))
elif
proto_type
==
AF_INET6
:
address
=
inet_ntop
(
AF_INET6
,
event
.
laddr
)
protocol
+=
"v6"
# Display
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment