Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nemu3
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
nemu3
Commits
a032a114
Commit
a032a114
authored
Jul 09, 2010
by
Martín Ferrari
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Client-side functions for get_addr_data and get_if_data
parent
1a81ac39
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
6 deletions
+33
-6
src/netns/iproute.py
src/netns/iproute.py
+1
-4
src/netns/protocol.py
src/netns/protocol.py
+32
-2
No files found.
src/netns/iproute.py
View file @
a032a114
...
...
@@ -149,11 +149,8 @@ def get_addr_data():
idx = int(match.group(1))
name = match.group(2)
if match.group(3):
continue # link info
if name not in bynam:
assert idx not in byidx
bynam[name] = byidx[idx] = []
continue # link info
bynam[name].append(address.parse_ip(match.group(4)))
return byidx, bynam
...
...
src/netns/protocol.py
View file @
a032a114
...
...
@@ -349,13 +349,26 @@ class Server(object):
def
do_IF_LIST
(
self
,
cmdname
,
ifnr
=
None
):
ifdata
=
netns
.
iproute
.
get_if_data
()[
0
]
if
ifnr
!=
None
:
if
ifnr
not
in
ifdata
:
self
.
reply
(
500
,
"Interface not found."
)
return
ifdata
=
ifdata
[
ifnr
]
self
.
reply
(
200
,
[
"# Interface data follows."
]
+
yaml
.
dump
(
ifdata
).
split
(
"
\
n
"
))
# def do_IF_SET(self, cmdname, ifnr, key, val):
# def do_IF_RTRN(self, cmdname, ifnr, netns):
# def do_ADDR_LIST(self, cmdname, ifnr = None):
def
do_ADDR_LIST
(
self
,
cmdname
,
ifnr
=
None
):
addrdata
=
netns
.
iproute
.
get_addr_data
()[
0
]
if
ifnr
!=
None
:
if
ifnr
not
in
addrdata
:
self
.
reply
(
500
,
"Interface not found."
)
return
addrdata
=
addrdata
[
ifnr
]
self
.
reply
(
200
,
[
"# Address data follows."
]
+
yaml
.
dump
(
addrdata
).
split
(
"
\
n
"
))
# def do_ADDR_ADD(self, cmdname, ifnr, address, prefixlen, broadcast = None):
# def do_ADDR_DEL(self, cmdname, ifnr, address, prefixlen):
# def do_ROUT_LIST(self, cmdname):
...
...
@@ -504,8 +517,25 @@ class Client(object):
self
.
_send_cmd
(
"PROC"
,
"KILL"
,
pid
,
sig
)
else
:
self
.
_send_cmd
(
"PROC"
,
"KILL"
,
pid
)
text
=
self
.
_read_and_check_reply
()
self
.
_read_and_check_reply
()
def
get_if_data
(
self
,
ifnr
=
None
):
if
ifnr
:
self
.
_send_cmd
(
"IF"
,
"LIST"
,
ifnr
)
else
:
self
.
_send_cmd
(
"IF"
,
"LIST"
)
data
=
self
.
_read_and_check_reply
()
data
=
data
.
partition
(
"
\
n
"
)[
2
]
# ignore first line
return
yaml
.
load
(
data
)
def
get_addr_data
(
self
,
ifnr
=
None
):
if
ifnr
:
self
.
_send_cmd
(
"ADDR"
,
"LIST"
,
ifnr
)
else
:
self
.
_send_cmd
(
"ADDR"
,
"LIST"
)
data
=
self
.
_read_and_check_reply
()
data
=
data
.
partition
(
"
\
n
"
)[
2
]
# ignore first line
return
yaml
.
load
(
data
)
def
_b64
(
text
):
text
=
str
(
text
)
...
...
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