1 // Copyright 2011 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
9 // See http://www.freebsd.org/doc/en/books/porters-handbook/freebsd-versions.html.
10 var freebsdVersion
uint32
13 freebsdVersion
, _
= SysctlUint32("kern.osreldate")
14 conf
, _
:= Sysctl("kern.conftxt")
15 for i
, j
:= 0, 0; j
< len(conf
); j
++ {
21 if len(s
) > len("machine") && s
[:len("machine")] == "machine" {
22 s
= s
[len("machine"):]
23 for k
:= 0; k
< len(s
); k
++ {
24 if s
[k
] == ' ' || s
[k
] == '\t' {
35 func (any
*anyMessage
) toRoutingMessage(b
[]byte) RoutingMessage
{
37 case RTM_ADD
, RTM_DELETE
, RTM_CHANGE
, RTM_GET
, RTM_LOSING
, RTM_REDIRECT
, RTM_MISS
, RTM_LOCK
, RTM_RESOLVE
:
38 return any
.parseRouteMessage(b
)
40 return any
.parseInterfaceMessage(b
)
42 p
:= (*InterfaceAnnounceMessage
)(unsafe
.Pointer(any
))
43 return &InterfaceAnnounceMessage
{Header
: p
.Header
}
44 case RTM_NEWADDR
, RTM_DELADDR
:
45 p
:= (*InterfaceAddrMessage
)(unsafe
.Pointer(any
))
46 return &InterfaceAddrMessage
{Header
: p
.Header
, Data
: b
[SizeofIfaMsghdr
:any
.Msglen
]}
47 case RTM_NEWMADDR
, RTM_DELMADDR
:
48 p
:= (*InterfaceMulticastAddrMessage
)(unsafe
.Pointer(any
))
49 return &InterfaceMulticastAddrMessage
{Header
: p
.Header
, Data
: b
[SizeofIfmaMsghdr
:any
.Msglen
]}
54 // InterfaceAnnounceMessage represents a routing message containing
55 // network interface arrival and departure information.
56 type InterfaceAnnounceMessage
struct {
57 Header IfAnnounceMsghdr
60 func (m
*InterfaceAnnounceMessage
) sockaddr() ([]Sockaddr
, error
) { return nil, nil }
62 // InterfaceMulticastAddrMessage represents a routing message
63 // containing network interface address entries.
64 type InterfaceMulticastAddrMessage
struct {
69 func (m
*InterfaceMulticastAddrMessage
) sockaddr() ([]Sockaddr
, error
) {
70 var sas
[RTAX_MAX
]Sockaddr
72 for i
:= uint(0); i
< RTAX_MAX
&& len(b
) >= minRoutingSockaddrLen
; i
++ {
73 if m
.Header
.Addrs
&(1<<i
) == 0 {
76 rsa
:= (*RawSockaddr
)(unsafe
.Pointer(&b
[0]))
79 sa
, err
:= parseSockaddrLink(b
)
84 b
= b
[rsaAlignOf(int(rsa
.Len
)):]
85 case AF_INET
, AF_INET6
:
86 sa
, err
:= parseSockaddrInet(b
, rsa
.Family
)
91 b
= b
[rsaAlignOf(int(rsa
.Len
)):]
93 sa
, l
, err
:= parseLinkLayerAddr(b
)