// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Network interface identification package net import ( "bytes" "fmt" "os" ) // A HardwareAddr represents a physical hardware address. type HardwareAddr []byte func (a HardwareAddr) String() string { var buf bytes.Buffer for i, b := range a { if i > 0 { buf.WriteByte(':') } fmt.Fprintf(&buf, "%02x", b) } return buf.String() } // Interface represents a mapping between network interface name // and index. It also represents network interface facility // information. type Interface struct { Index int // positive integer that starts at one, zero is never used MTU int // maximum transmission unit Name string // e.g., "en0", "lo0", "eth0.100" HardwareAddr HardwareAddr // IEEE MAC-48, EUI-48 and EUI-64 form Flags Flags // e.g., FlagUp, FlagLoopback, FlagMulticast } type Flags uint const ( FlagUp Flags = 1 << iota // interface is up FlagBroadcast // interface supports broadcast access capability FlagLoopback // interface is a loopback interface FlagPointToPoint // interface belongs to a point-to-point link FlagMulticast // interface supports multicast access capability ) var flagNames = []string{ "up", "broadcast", "loopback", "pointtopoint", "multicast", } func (f Flags) String() string { s := "" for i, name := range flagNames { if f&(1<