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

     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 (
     8  	"syscall"
     9  	"unsafe"
    10  )
    11  
    12  func (typ RIBType) parseable() bool {
    13  	switch typ {
    14  	case syscall.NET_RT_STATS, syscall.NET_RT_TABLE:
    15  		return false
    16  	default:
    17  		return true
    18  	}
    19  }
    20  
    21  // RouteMetrics represents route metrics.
    22  type RouteMetrics struct {
    23  	PathMTU int // path maximum transmission unit
    24  }
    25  
    26  // SysType implements the SysType method of Sys interface.
    27  func (rmx *RouteMetrics) SysType() SysType { return SysMetrics }
    28  
    29  // Sys implements the Sys method of Message interface.
    30  func (m *RouteMessage) Sys() []Sys {
    31  	return []Sys{
    32  		&RouteMetrics{
    33  			PathMTU: int(nativeEndian.Uint32(m.raw[60:64])),
    34  		},
    35  	}
    36  }
    37  
    38  // InterfaceMetrics represents interface metrics.
    39  type InterfaceMetrics struct {
    40  	Type int // interface type
    41  	MTU  int // maximum transmission unit
    42  }
    43  
    44  // SysType implements the SysType method of Sys interface.
    45  func (imx *InterfaceMetrics) SysType() SysType { return SysMetrics }
    46  
    47  // Sys implements the Sys method of Message interface.
    48  func (m *InterfaceMessage) Sys() []Sys {
    49  	return []Sys{
    50  		&InterfaceMetrics{
    51  			Type: int(m.raw[24]),
    52  			MTU:  int(nativeEndian.Uint32(m.raw[28:32])),
    53  		},
    54  	}
    55  }
    56  
    57  func probeRoutingStack() (int, map[int]*wireFormat) {
    58  	var p uintptr
    59  	rtm := &wireFormat{extOff: -1, bodyOff: -1}
    60  	rtm.parse = rtm.parseRouteMessage
    61  	ifm := &wireFormat{extOff: -1, bodyOff: -1}
    62  	ifm.parse = ifm.parseInterfaceMessage
    63  	ifam := &wireFormat{extOff: -1, bodyOff: -1}
    64  	ifam.parse = ifam.parseInterfaceAddrMessage
    65  	ifanm := &wireFormat{extOff: -1, bodyOff: -1}
    66  	ifanm.parse = ifanm.parseInterfaceAnnounceMessage
    67  	return int(unsafe.Sizeof(p)), map[int]*wireFormat{
    68  		syscall.RTM_ADD:        rtm,
    69  		syscall.RTM_DELETE:     rtm,
    70  		syscall.RTM_CHANGE:     rtm,
    71  		syscall.RTM_GET:        rtm,
    72  		syscall.RTM_LOSING:     rtm,
    73  		syscall.RTM_REDIRECT:   rtm,
    74  		syscall.RTM_MISS:       rtm,
    75  		syscall.RTM_RESOLVE:    rtm,
    76  		syscall.RTM_NEWADDR:    ifam,
    77  		syscall.RTM_DELADDR:    ifam,
    78  		syscall.RTM_IFINFO:     ifm,
    79  		syscall.RTM_IFANNOUNCE: ifanm,
    80  		syscall.RTM_DESYNC:     rtm,
    81  	}
    82  }
    83  

View as plain text