go-nsupdate/netlink.go

25 lines
403 B
Go
Raw Normal View History

2016-06-19 11:46:23 -05:00
package main
import (
"fmt"
2016-06-19 14:50:21 -05:00
"github.com/vishvananda/netlink"
2016-06-19 11:46:23 -05:00
)
// zero value is unspec=all
type Family int
func (f *Family) UnmarshalFlag(value string) error {
2016-06-19 14:50:21 -05:00
switch value {
2016-06-19 13:56:06 -05:00
case "unspec", "all":
*f = netlink.FAMILY_ALL
2016-06-19 11:46:23 -05:00
case "inet", "ipv4":
*f = netlink.FAMILY_V4
case "inet6", "ipv6":
*f = netlink.FAMILY_V6
default:
return fmt.Errorf("Invalid --family=%v", value)
}
return nil
}