Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
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
go
Commits
c2331bb7
Commit
c2331bb7
authored
Feb 03, 2012
by
Mikio Hara
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
net: tweak variable declarations
R=golang-dev, bradfitz, rsc CC=golang-dev
https://golang.org/cl/5617050
parent
4b6cd239
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
12 deletions
+4
-12
src/pkg/net/interface_bsd.go
src/pkg/net/interface_bsd.go
+4
-12
No files found.
src/pkg/net/interface_bsd.go
View file @
c2331bb7
...
...
@@ -18,8 +18,6 @@ import (
// network interfaces. Otherwise it returns a mapping of a specific
// interface.
func
interfaceTable
(
ifindex
int
)
([]
Interface
,
error
)
{
var
ift
[]
Interface
tab
,
err
:=
syscall
.
RouteRIB
(
syscall
.
NET_RT_IFLIST
,
ifindex
)
if
err
!=
nil
{
return
nil
,
os
.
NewSyscallError
(
"route rib"
,
err
)
...
...
@@ -30,6 +28,7 @@ func interfaceTable(ifindex int) ([]Interface, error) {
return
nil
,
os
.
NewSyscallError
(
"route message"
,
err
)
}
var
ift
[]
Interface
for
_
,
m
:=
range
msgs
{
switch
v
:=
m
.
(
type
)
{
case
*
syscall
.
InterfaceMessage
:
...
...
@@ -42,18 +41,16 @@ func interfaceTable(ifindex int) ([]Interface, error) {
}
}
}
return
ift
,
nil
}
func
newLink
(
m
*
syscall
.
InterfaceMessage
)
([]
Interface
,
error
)
{
var
ift
[]
Interface
sas
,
err
:=
syscall
.
ParseRoutingSockaddr
(
m
)
if
err
!=
nil
{
return
nil
,
os
.
NewSyscallError
(
"route sockaddr"
,
err
)
}
var
ift
[]
Interface
for
_
,
s
:=
range
sas
{
switch
v
:=
s
.
(
type
)
{
case
*
syscall
.
SockaddrDatalink
:
...
...
@@ -75,7 +72,6 @@ func newLink(m *syscall.InterfaceMessage) ([]Interface, error) {
ift
=
append
(
ift
,
ifi
)
}
}
return
ift
,
nil
}
...
...
@@ -103,8 +99,6 @@ func linkFlags(rawFlags int32) Flags {
// for all network interfaces. Otherwise it returns addresses
// for a specific interface.
func
interfaceAddrTable
(
ifindex
int
)
([]
Addr
,
error
)
{
var
ifat
[]
Addr
tab
,
err
:=
syscall
.
RouteRIB
(
syscall
.
NET_RT_IFLIST
,
ifindex
)
if
err
!=
nil
{
return
nil
,
os
.
NewSyscallError
(
"route rib"
,
err
)
...
...
@@ -115,6 +109,7 @@ func interfaceAddrTable(ifindex int) ([]Addr, error) {
return
nil
,
os
.
NewSyscallError
(
"route message"
,
err
)
}
var
ifat
[]
Addr
for
_
,
m
:=
range
msgs
{
switch
v
:=
m
.
(
type
)
{
case
*
syscall
.
InterfaceAddrMessage
:
...
...
@@ -127,18 +122,16 @@ func interfaceAddrTable(ifindex int) ([]Addr, error) {
}
}
}
return
ifat
,
nil
}
func
newAddr
(
m
*
syscall
.
InterfaceAddrMessage
)
(
Addr
,
error
)
{
ifa
:=
&
IPNet
{}
sas
,
err
:=
syscall
.
ParseRoutingSockaddr
(
m
)
if
err
!=
nil
{
return
nil
,
os
.
NewSyscallError
(
"route sockaddr"
,
err
)
}
ifa
:=
&
IPNet
{}
for
i
,
s
:=
range
sas
{
switch
v
:=
s
.
(
type
)
{
case
*
syscall
.
SockaddrInet4
:
...
...
@@ -166,6 +159,5 @@ func newAddr(m *syscall.InterfaceAddrMessage) (Addr, error) {
}
}
}
return
ifa
,
nil
}
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