Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
bio-rd
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review 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
danet
bio-rd
Commits
8b30d41f
Commit
8b30d41f
authored
6 years ago
by
Christoph Petrausch
Browse files
Options
Downloads
Patches
Plain Diff
Assured that IPv4ToUint32 works also an interal 16 byte v4 representation
parent
64b98409
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
net/helper.go
+1
-0
1 addition, 0 deletions
net/helper.go
net/helper_test.go
+6
-0
6 additions, 0 deletions
net/helper_test.go
with
7 additions
and
0 deletions
net/helper.go
+
1
−
0
View file @
8b30d41f
...
...
@@ -4,5 +4,6 @@ import "net"
// IPv4ToUint32 converts an `net.IP` to an uint32 interpretation
func
IPv4ToUint32
(
ip
net
.
IP
)
uint32
{
ip
=
ip
.
To4
()
return
uint32
(
ip
[
3
])
+
uint32
(
ip
[
2
])
<<
8
+
uint32
(
ip
[
1
])
<<
16
+
uint32
(
ip
[
0
])
<<
24
}
This diff is collapsed.
Click to expand it.
net/helper_test.go
+
6
−
0
View file @
8b30d41f
...
...
@@ -3,6 +3,8 @@ package net
import
(
"testing"
"net"
"github.com/stretchr/testify/assert"
)
...
...
@@ -23,6 +25,10 @@ func TestIPv4ToUint32(t *testing.T) {
input
:
[]
byte
{
172
,
24
,
5
,
1
},
expected
:
2887255297
,
},
{
input
:
net
.
ParseIP
(
"172.24.5.1"
),
expected
:
2887255297
,
},
}
for
_
,
test
:=
range
tests
{
...
...
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