| 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 routebsd |
| 6 |
|
| 7 |
import ( |
| 8 |
"syscall" |
| 9 |
"unsafe" |
| 10 |
) |
| 11 |
|
| 12 |
// MTU returns the interface MTU. |
| 13 |
func (m *InterfaceMessage) MTU() int { |
| 14 |
return int(nativeEndian.Uint32(m.raw[28:32])) |
| 15 |
} |
| 16 |
|
| 17 |
func probeRoutingStack() (int, map[int]*wireFormat) { |
| 18 |
var p uintptr |
| 19 |
ifm := &wireFormat{extOff: -1, bodyOff: -1} |
| 20 |
ifm.parse = ifm.parseInterfaceMessage |
| 21 |
ifam := &wireFormat{extOff: -1, bodyOff: -1} |
| 22 |
ifam.parse = ifam.parseInterfaceAddrMessage |
| 23 |
return int(unsafe.Sizeof(p)), map[int]*wireFormat{ |
| 24 |
syscall.RTM_NEWADDR: ifam, |
| 25 |
syscall.RTM_DELADDR: ifam, |
| 26 |
syscall.RTM_IFINFO: ifm, |
| 27 |
} |
| 28 |
} |