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
206eed94
Commit
206eed94
authored
Jul 27, 2010
by
Martín Ferrari
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
missing replies; client code for routing
parent
0ee64267
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
2 deletions
+30
-2
src/netns/protocol.py
src/netns/protocol.py
+30
-2
No files found.
src/netns/protocol.py
View file @
206eed94
...
...
@@ -37,8 +37,8 @@ _proto_commands = {
},
"ROUT"
:
{
"LIST"
:
(
""
,
""
),
"ADD"
:
(
"
ssis
i"
,
""
),
"DEL"
:
(
"
ssis
i"
,
""
)
"ADD"
:
(
"
bbib
i"
,
""
),
"DEL"
:
(
"
bbib
i"
,
""
)
},
"PROC"
:
{
"CRTE"
:
(
"b"
,
"b*"
),
...
...
@@ -381,9 +381,11 @@ class Server(object):
def
do_ROUT_ADD
(
self
,
cmdname
,
tipe
,
prefix
,
prefixlen
,
nexthop
,
ifnr
):
netns
.
iproute
.
add_route
(
tipe
,
prefix
,
prefixlen
,
nexthop
,
ifnr
)
self
.
reply
(
200
,
"Done."
)
def
do_ROUT_DEL
(
self
,
cmdname
,
tipe
,
prefix
,
prefixlen
,
nexthop
,
ifnr
):
netns
.
iproute
.
del_route
(
tipe
,
prefix
,
prefixlen
,
nexthop
,
ifnr
)
self
.
reply
(
200
,
"Done."
)
# ============================================================================
#
...
...
@@ -579,6 +581,32 @@ class Client(object):
self
.
_send_cmd
(
"ADDR"
,
"DEL"
,
ifnr
,
address
.
address
,
address
.
prefix_len
)
self
.
_read_and_check_reply
()
def
get_route_data
(
self
):
self
.
_send_cmd
(
"ROUT"
,
"LIST"
)
data
=
self
.
_read_and_check_reply
()
return
yaml
.
load
(
data
)
def
add_route
(
self
,
tipe
,
prefix
,
prefix_len
,
nexthop
,
ifnr
):
_add_del_route
(
"ADD"
,
tipe
,
prefix
,
prefix_len
,
nexthop
,
ifnr
)
def
del_route
(
self
,
tipe
,
prefix
,
prefix_len
,
nexthop
,
ifnr
):
_add_del_route
(
"DEL"
,
tipe
,
prefix
,
prefix_len
,
nexthop
,
ifnr
)
def
_add_del_route
(
self
,
action
,
tipe
,
prefix
,
prefix_len
,
nexthop
,
ifnr
):
if
not
tipe
:
tipe
=
'unicast'
if
not
prefix
:
prefix
=
''
prefix_len
=
0
if
not
nexthop
:
nexthop
=
''
if
not
ifnr
:
ifnr
=
0
args
=
[
"ROUT"
,
action
,
tipe
,
prefix
,
prefix_len
,
nexthop
,
ifnr
]
args
[
2
:
6
]
=
map
(
_b64
,
args
[
2
:
6
])
self
.
_send_cmd
(
args
)
self
.
_read_and_check_reply
()
def
_b64
(
text
):
text
=
str
(
text
)
if
len
(
text
)
==
0
or
filter
(
lambda
x
:
ord
(
x
)
<=
ord
(
" "
)
or
...
...
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