github.com/osrg/gobgp@v2.0.0+incompatible/internal/pkg/zebra/zapi_bsd.go (about)

     1  // Copyright (C) 2014, 2015 Nippon Telegraph and Telephone Corporation.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //    http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
    12  // implied.
    13  // See the License for the specific language governing permissions and
    14  // limitations under the License.
    15  
    16  // +build freebsd netbsd openbsd
    17  
    18  package zebra
    19  
    20  import (
    21  	"strings"
    22  	"syscall"
    23  )
    24  
    25  func intfflag2string(flag uint64) string {
    26  	ss := make([]string, 0, 10)
    27  	if flag&syscall.IFF_UP > 0 {
    28  		ss = append(ss, "UP")
    29  	}
    30  	if flag&syscall.IFF_BROADCAST > 0 {
    31  		ss = append(ss, "BROADCAST")
    32  	}
    33  	if flag&syscall.IFF_DEBUG > 0 {
    34  		ss = append(ss, "DEBUG")
    35  	}
    36  	if flag&syscall.IFF_LOOPBACK > 0 {
    37  		ss = append(ss, "LOOPBACK")
    38  	}
    39  	if flag&syscall.IFF_POINTOPOINT > 0 {
    40  		ss = append(ss, "POINTOPOINT")
    41  	}
    42  	if flag&syscall.IFF_RUNNING > 0 {
    43  		ss = append(ss, "RUNNING")
    44  	}
    45  	if flag&syscall.IFF_NOARP > 0 {
    46  		ss = append(ss, "NOARP")
    47  	}
    48  	if flag&syscall.IFF_PROMISC > 0 {
    49  		ss = append(ss, "PROMISC")
    50  	}
    51  	if flag&syscall.IFF_ALLMULTI > 0 {
    52  		ss = append(ss, "ALLMULTI")
    53  	}
    54  	if flag&syscall.IFF_MULTICAST > 0 {
    55  		ss = append(ss, "MULTICAST")
    56  	}
    57  	return strings.Join(ss, " | ")
    58  }