X-Git-Url: https://gerrit.fd.io/r/gitweb?p=govpp.git;a=blobdiff_plain;f=internal%2Ftestbinapi%2Fbinapi2001%2Fpunt%2Fpunt.ba.go;fp=internal%2Ftestbinapi%2Fbinapi2001%2Fpunt%2Fpunt.ba.go;h=e10832f5b5be8e10f718deb4149354c21a7f8c90;hp=285aaf130ae6c1cf740007abcdc490c0a950ce09;hb=4102c72bce694babd94a481b1201d33895a6f9c5;hpb=a4112fac7b86fe09650d2bb57969fe46404edd7d diff --git a/internal/testbinapi/binapi2001/punt/punt.ba.go b/internal/testbinapi/binapi2001/punt/punt.ba.go index 285aaf1..e10832f 100644 --- a/internal/testbinapi/binapi2001/punt/punt.ba.go +++ b/internal/testbinapi/binapi2001/punt/punt.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/core/punt.api.json @@ -17,11 +17,12 @@ package punt import ( "fmt" - api "git.fd.io/govpp.git/api" - codec "git.fd.io/govpp.git/codec" "net" "strconv" "strings" + + api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" ) // This is a compile-time assertion to ensure that this generated file @@ -277,12 +278,15 @@ func ParseAddressWithPrefix(s string) (AddressWithPrefix, error) { } return AddressWithPrefix(prefix), nil } + func (x AddressWithPrefix) String() string { return Prefix(x).String() } + func (x *AddressWithPrefix) MarshalText() ([]byte, error) { return []byte(x.String()), nil } + func (x *AddressWithPrefix) UnmarshalText(text []byte) error { prefix, err := ParseAddressWithPrefix(string(text)) if err != nil { @@ -308,12 +312,15 @@ func ParseIP4Address(s string) (IP4Address, error) { func (x IP4Address) ToIP() net.IP { return net.IP(x[:]).To4() } + func (x IP4Address) String() string { return x.ToIP().String() } + func (x *IP4Address) MarshalText() ([]byte, error) { return []byte(x.String()), nil } + func (x *IP4Address) UnmarshalText(text []byte) error { ipaddr, err := ParseIP4Address(string(text)) if err != nil { @@ -342,12 +349,15 @@ func ParseIP6Address(s string) (IP6Address, error) { func (x IP6Address) ToIP() net.IP { return net.IP(x[:]).To16() } + func (x IP6Address) String() string { return x.ToIP().String() } + func (x *IP6Address) MarshalText() ([]byte, error) { return []byte(x.String()), nil } + func (x *IP6Address) UnmarshalText(text []byte) error { ipaddr, err := ParseIP6Address(string(text)) if err != nil { @@ -371,6 +381,10 @@ func ParseAddress(s string) (Address, error) { if ip == nil { return Address{}, fmt.Errorf("invalid address: %s", s) } + return AddressFromIP(ip), nil +} + +func AddressFromIP(ip net.IP) Address { var addr Address if ip.To4() == nil { addr.Af = ADDRESS_IP6 @@ -383,8 +397,9 @@ func ParseAddress(s string) (Address, error) { copy(ip4[:], ip.To4()) addr.Un.SetIP4(ip4) } - return addr, nil + return addr } + func (x Address) ToIP() net.IP { if x.Af == ADDRESS_IP6 { ip6 := x.Un.GetIP6() @@ -394,12 +409,15 @@ func (x Address) ToIP() net.IP { return net.IP(ip4[:]).To4() } } + func (x Address) String() string { return x.ToIP().String() } + func (x *Address) MarshalText() ([]byte, error) { return []byte(x.String()), nil } + func (x *Address) UnmarshalText(text []byte) error { addr, err := ParseAddress(string(text)) if err != nil { @@ -442,18 +460,22 @@ func ParseIP4Prefix(s string) (prefix IP4Prefix, err error) { } return prefix, nil } + func (x IP4Prefix) ToIPNet() *net.IPNet { mask := net.CIDRMask(int(x.Len), 32) ipnet := &net.IPNet{IP: x.Address.ToIP(), Mask: mask} return ipnet } + func (x IP4Prefix) String() string { ip := x.Address.String() return ip + "/" + strconv.Itoa(int(x.Len)) } + func (x *IP4Prefix) MarshalText() ([]byte, error) { return []byte(x.String()), nil } + func (x *IP4Prefix) UnmarshalText(text []byte) error { prefix, err := ParseIP4Prefix(string(text)) if err != nil { @@ -496,18 +518,22 @@ func ParseIP6Prefix(s string) (prefix IP6Prefix, err error) { } return prefix, nil } + func (x IP6Prefix) ToIPNet() *net.IPNet { mask := net.CIDRMask(int(x.Len), 128) ipnet := &net.IPNet{IP: x.Address.ToIP(), Mask: mask} return ipnet } + func (x IP6Prefix) String() string { ip := x.Address.String() return ip + "/" + strconv.Itoa(int(x.Len)) } + func (x *IP6Prefix) MarshalText() ([]byte, error) { return []byte(x.String()), nil } + func (x *IP6Prefix) UnmarshalText(text []byte) error { prefix, err := ParseIP6Prefix(string(text)) if err != nil { @@ -558,6 +584,7 @@ func ParsePrefix(ip string) (prefix Prefix, err error) { } return prefix, nil } + func (x Prefix) ToIPNet() *net.IPNet { var mask net.IPMask if x.Address.Af == ADDRESS_IP4 { @@ -568,13 +595,16 @@ func (x Prefix) ToIPNet() *net.IPNet { ipnet := &net.IPNet{IP: x.Address.ToIP(), Mask: mask} return ipnet } + func (x Prefix) String() string { ip := x.Address.String() return ip + "/" + strconv.Itoa(int(x.Len)) } + func (x *Prefix) MarshalText() ([]byte, error) { return []byte(x.String()), nil } + func (x *Prefix) UnmarshalText(text []byte) error { prefix, err := ParsePrefix(string(text)) if err != nil { @@ -622,8 +652,9 @@ type PuntReason struct { // AddressUnion defines union 'address_union'. type AddressUnion struct { - // IP4 *IP4Address - // IP6 *IP6Address + // AddressUnion can be one of: + // - IP4 *IP4Address + // - IP6 *IP6Address XXX_UnionData [16]byte } @@ -657,9 +688,10 @@ func (u *AddressUnion) GetIP6() (a IP6Address) { // PuntUnion defines union 'punt_union'. type PuntUnion struct { - // Exception *PuntException - // L4 *PuntL4 - // IPProto *PuntIPProto + // PuntUnion can be one of: + // - Exception *PuntException + // - L4 *PuntL4 + // - IPProto *PuntIPProto XXX_UnionData [10]byte }