govmtools/network_xdr.go
2021-11-10 09:06:53 +01:00

140 lines
2.5 KiB
Go

package govmtools
import (
xdr "github.com/stellar/go-xdr/xdr3"
)
type InetAddressType int
const (
IatUnknown InetAddressType = iota
IatIpv4
IatIpv6
IatIpv4Z
IatIpv6Z
IatDns
)
type IpAddressOrigin int
const (
IaoOther IpAddressOrigin = 1
IaoManual IpAddressOrigin = 2
IaoDhcp IpAddressOrigin = 4
IaoLinkLayer IpAddressOrigin = 5
IaoRandom IpAddressOrigin = 6
)
type IpAddressStatus int
const (
IasPreferred = iota + 1
IasDeprecated
IasInvalid
IasInaccessible
IasUnknown
IasTentative
IasDuplicate
IasOptimistic
)
type InetAddress []byte
type TypedIpAddress struct {
IpAddressAddrType InetAddressType
IpAddressAddr InetAddress
}
type InetAddressPrefixLength uint
type IpAddressEntry struct {
IpAddressAddr TypedIpAddress
IpAddressPrefixLength InetAddressPrefixLength
IpAddressOrigin []IpAddressOrigin
IpAddressStatus []IpAddressStatus
}
type DnsConfigInfo struct {
HostName []string
DomainName []string
ServerList []TypedIpAddress
SearchSuffixes []string
}
type WinsConfigInfo struct {
Primary TypedIpAddress
Secondary TypedIpAddress
}
type DhcpConfigInfo struct {
Enabled bool
DhcpSettings []string
}
type GuestNicV3 struct {
MacAddress string
Ips []IpAddressEntry
DnsConfigInfo []DnsConfigInfo
WinsConfigInfo []WinsConfigInfo
DhcpConfigInfoV4 []DhcpConfigInfo
DhcpConfigInfoV6 []DhcpConfigInfo
}
type InetCidrRouteType int
const (
IcrtOther InetCidrRouteType = iota + 1
IcrtReject
IcrtLocal
IcrtRemote
)
type InetCidrRouteEntry struct {
InetCidrRouteDest TypedIpAddress
InetCidrRoutePfxLen InetAddressPrefixLength
InetCidrRouteNextHop []TypedIpAddress
InetCidrRouteIfIndex uint32
InetCidrRouteType InetCidrRouteType
InetCidrRouteMetric uint32
}
type NicInfoV3Wrapper struct {
NicInfoV3 []NicInfoV3
}
type NicInfoV3 struct {
Nics []GuestNicV3
Routes []InetCidrRouteEntry
DnsConfigInfo []DnsConfigInfo
WinsConfigInfo []WinsConfigInfo
DhcpConfigInfoV4 []DhcpConfigInfo
DhcpConfigInfoV6 []DhcpConfigInfo
}
type GuestNicProtoType int
const (
ProtoTypeV3 = 3
)
func (GuestNicProtoType) ValidEnum(i int32) bool {
return i == ProtoTypeV3
}
type GuestNicProto struct {
Type GuestNicProtoType
NicInfoV3 *NicInfoV3Wrapper
}
var _ xdr.Union = (*GuestNicProto)(nil)
func (g GuestNicProto) ArmForSwitch(i int32) (string, bool) {
if i != 3 {
return "", false
}
return "NicInfoV3", true
}
func (g GuestNicProto) SwitchFieldName() string {
return "Type"
}