...

Source file src/vendor/golang.org/x/net/route/sys_netbsd.go

Documentation: vendor/golang.org/x/net/route

     1  // Copyright 2016 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  package route
     6  
     7  import "syscall"
     8  
     9  func (typ RIBType) parseable() bool { return true }
    10  
    11  // RouteMetrics represents route metrics.
    12  type RouteMetrics struct {
    13  	PathMTU int // path maximum transmission unit
    14  }
    15  
    16  // SysType implements the SysType method of Sys interface.
    17  func (rmx *RouteMetrics) SysType() SysType { return SysMetrics }
    18  
    19  // Sys implements the Sys method of Message interface.
    20  func (m *RouteMessage) Sys() []Sys {
    21  	return []Sys{
    22  		&RouteMetrics{
    23  			PathMTU: int(nativeEndian.Uint64(m.raw[m.extOff+8 : m.extOff+16])),
    24  		},
    25  	}
    26  }
    27  
    28  // RouteMetrics represents route metrics.
    29  type InterfaceMetrics struct {
    30  	Type int // interface type
    31  	MTU  int // maximum transmission unit
    32  }
    33  
    34  // SysType implements the SysType method of Sys interface.
    35  func (imx *InterfaceMetrics) SysType() SysType { return SysMetrics }
    36  
    37  // Sys implements the Sys method of Message interface.
    38  func (m *InterfaceMessage) Sys() []Sys {
    39  	return []Sys{
    40  		&InterfaceMetrics{
    41  			Type: int(m.raw[m.extOff]),
    42  			MTU:  int(nativeEndian.Uint32(m.raw[m.extOff+8 : m.extOff+12])),
    43  		},
    44  	}
    45  }
    46  
    47  func probeRoutingStack() (int, map[int]*wireFormat) {
    48  	rtm := &wireFormat{extOff: 40, bodyOff: sizeofRtMsghdrNetBSD7}
    49  	rtm.parse = rtm.parseRouteMessage
    50  	ifm := &wireFormat{extOff: 16, bodyOff: sizeofIfMsghdrNetBSD7}
    51  	ifm.parse = ifm.parseInterfaceMessage
    52  	ifam := &wireFormat{extOff: sizeofIfaMsghdrNetBSD7, bodyOff: sizeofIfaMsghdrNetBSD7}
    53  	ifam.parse = ifam.parseInterfaceAddrMessage
    54  	ifanm := &wireFormat{extOff: sizeofIfAnnouncemsghdrNetBSD7, bodyOff: sizeofIfAnnouncemsghdrNetBSD7}
    55  	ifanm.parse = ifanm.parseInterfaceAnnounceMessage
    56  	// NetBSD 6 and above kernels require 64-bit aligned access to
    57  	// routing facilities.
    58  	return 8, map[int]*wireFormat{
    59  		syscall.RTM_ADD:        rtm,
    60  		syscall.RTM_DELETE:     rtm,
    61  		syscall.RTM_CHANGE:     rtm,
    62  		syscall.RTM_GET:        rtm,
    63  		syscall.RTM_LOSING:     rtm,
    64  		syscall.RTM_REDIRECT:   rtm,
    65  		syscall.RTM_MISS:       rtm,
    66  		syscall.RTM_LOCK:       rtm,
    67  		syscall.RTM_RESOLVE:    rtm,
    68  		syscall.RTM_NEWADDR:    ifam,
    69  		syscall.RTM_DELADDR:    ifam,
    70  		syscall.RTM_IFANNOUNCE: ifanm,
    71  		syscall.RTM_IFINFO:     ifm,
    72  	}
    73  }
    74  

View as plain text