Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1658)

Side by Side Diff: unix/route_dragonfly.go

Issue 126960043: code review 126960043: go.sys: copy files from syscall package to go.sys/{plan... (Closed)
Patch Set: diff -r 89b705e036f489a14b4d11c6e025ea61a53bb735 https://code.google.com/p/go.sys Created 10 years, 7 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « unix/route_darwin.go ('k') | unix/route_freebsd.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 // Routing sockets and messages for Dragonfly
6
7 package syscall
8
9 import "unsafe"
10
11 func (any *anyMessage) toRoutingMessage(b []byte) RoutingMessage {
12 switch any.Type {
13 case RTM_ADD, RTM_DELETE, RTM_CHANGE, RTM_GET, RTM_LOSING, RTM_REDIRECT, RTM_MISS, RTM_LOCK, RTM_RESOLVE:
14 p := (*RouteMessage)(unsafe.Pointer(any))
15 return &RouteMessage{Header: p.Header, Data: b[SizeofRtMsghdr:an y.Msglen]}
16 case RTM_IFINFO:
17 p := (*InterfaceMessage)(unsafe.Pointer(any))
18 return &InterfaceMessage{Header: p.Header, Data: b[SizeofIfMsghd r:any.Msglen]}
19 case RTM_IFANNOUNCE:
20 p := (*InterfaceAnnounceMessage)(unsafe.Pointer(any))
21 return &InterfaceAnnounceMessage{Header: p.Header}
22 case RTM_NEWADDR, RTM_DELADDR:
23 p := (*InterfaceAddrMessage)(unsafe.Pointer(any))
24 return &InterfaceAddrMessage{Header: p.Header, Data: b[SizeofIfa Msghdr:any.Msglen]}
25 case RTM_NEWMADDR, RTM_DELMADDR:
26 p := (*InterfaceMulticastAddrMessage)(unsafe.Pointer(any))
27 return &InterfaceMulticastAddrMessage{Header: p.Header, Data: b[ SizeofIfmaMsghdr:any.Msglen]}
28 }
29 return nil
30 }
31
32 // InterfaceAnnounceMessage represents a routing message containing
33 // network interface arrival and departure information.
34 type InterfaceAnnounceMessage struct {
35 Header IfAnnounceMsghdr
36 }
37
38 func (m *InterfaceAnnounceMessage) sockaddr() (sas []Sockaddr) { return nil }
39
40 // InterfaceMulticastAddrMessage represents a routing message
41 // containing network interface address entries.
42 type InterfaceMulticastAddrMessage struct {
43 Header IfmaMsghdr
44 Data []byte
45 }
46
47 const rtaIfmaMask = RTA_GATEWAY | RTA_IFP | RTA_IFA
48
49 func (m *InterfaceMulticastAddrMessage) sockaddr() (sas []Sockaddr) {
50 if m.Header.Addrs&rtaIfmaMask == 0 {
51 return nil
52 }
53 b := m.Data[:]
54 for i := uint(0); i < RTAX_MAX; i++ {
55 if m.Header.Addrs&rtaIfmaMask&(1<<i) == 0 {
56 continue
57 }
58 rsa := (*RawSockaddr)(unsafe.Pointer(&b[0]))
59 switch i {
60 case RTAX_IFA:
61 sa, e := anyToSockaddr((*RawSockaddrAny)(unsafe.Pointer( rsa)))
62 if e != nil {
63 return nil
64 }
65 sas = append(sas, sa)
66 case RTAX_GATEWAY, RTAX_IFP:
67 // nothing to do
68 }
69 b = b[rsaAlignOf(int(rsa.Len)):]
70 }
71 return sas
72 }
OLDNEW
« no previous file with comments | « unix/route_darwin.go ('k') | unix/route_freebsd.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b