Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mininet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Olaf Bergmann
mininet
Commits
8204a1b6
Commit
8204a1b6
authored
12 years ago
by
Bob Lantz
Browse files
Options
Downloads
Patches
Plain Diff
fix --ipbase: fix ipAdd() and remove unused default from ipStr()
parent
bd558875
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
mininet/util.py
+5
-6
5 additions, 6 deletions
mininet/util.py
with
5 additions
and
6 deletions
mininet/util.py
+
5
−
6
View file @
8204a1b6
...
...
@@ -242,9 +242,8 @@ def macColonHex( mac ):
def
ipStr
(
ip
):
"""
Generate IP address string from an unsigned int.
ip: unsigned int of form w << 24 | x << 16 | y << 8 | z
returns: ip address string w.x.y.z
, or 10.x.y.z if w==0
"""
returns: ip address string w.x.y.z
"""
w
=
(
ip
>>
24
)
&
0xff
w
=
10
if
w
==
0
else
w
x
=
(
ip
>>
16
)
&
0xff
y
=
(
ip
>>
8
)
&
0xff
z
=
ip
&
0xff
...
...
@@ -261,10 +260,10 @@ def ipAdd( i, prefixLen=8, ipBaseNum=0x0a000000 ):
prefixLen: optional IP prefix length
ipBaseNum: option base IP address as int
returns IP address as string
"""
# Ugly but functional
assert
i
<
(
1
<<
(
32
-
prefixLen
)
)
mask
=
0xffffffff
^
(
(
1
<<
prefixLen
)
-
1
)
ipnum
=
i
+
(
ipBaseNum
&
mask
)
imax
=
0xffffffff
>>
prefixLen
assert
i
<
=
imax
mask
=
0xffffffff
^
imax
ipnum
=
(
ipBaseNum
&
mask
)
+
i
return
ipStr
(
ipnum
)
def
ipParse
(
ip
):
...
...
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