Code Review
/
govpp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Fix import path in examples/binapi
[govpp.git]
/
examples
/
union-example
/
union_example.go
diff --git
a/examples/union-example/union_example.go
b/examples/union-example/union_example.go
index
22fb362
..
92c3ec2
100644
(file)
--- a/
examples/union-example/union_example.go
+++ b/
examples/union-example/union_example.go
@@
-22,6
+22,8
@@
import (
"net"
"git.fd.io/govpp.git/examples/binapi/ip"
"net"
"git.fd.io/govpp.git/examples/binapi/ip"
+ "git.fd.io/govpp.git/examples/binapi/ip_types"
+
"github.com/lunixbochs/struc"
)
"github.com/lunixbochs/struc"
)
@@
-37,8
+39,8
@@
func encodingExample() {
// use it in the Address type
addr := &ip.Address{
// use it in the Address type
addr := &ip.Address{
- Af: ip.ADDRESS_IP4,
- Un: ip.AddressUnionIP4(ip.IP4Address{192, 168, 1, 10}),
+ Af: ip
_types
.ADDRESS_IP4,
+ Un: ip
_types
.AddressUnionIP4(ip.IP4Address{192, 168, 1, 10}),
}
log.Printf("encoding union IPv4: %v", addr.Un.GetIP4())
}
log.Printf("encoding union IPv4: %v", addr.Un.GetIP4())
@@
-89,12
+91,12
@@
func ipToAddress(ipstr string) (addr ip.Address, err error) {
return ip.Address{}, fmt.Errorf("invalid IP: %q", ipstr)
}
if ip4 := netIP.To4(); ip4 == nil {
return ip.Address{}, fmt.Errorf("invalid IP: %q", ipstr)
}
if ip4 := netIP.To4(); ip4 == nil {
- addr.Af = ip.ADDRESS_IP6
+ addr.Af = ip
_types
.ADDRESS_IP6
var ip6addr ip.IP6Address
copy(ip6addr[:], netIP.To16())
addr.Un.SetIP6(ip6addr)
} else {
var ip6addr ip.IP6Address
copy(ip6addr[:], netIP.To16())
addr.Un.SetIP6(ip6addr)
} else {
- addr.Af = ip.ADDRESS_IP4
+ addr.Af = ip
_types
.ADDRESS_IP4
var ip4addr ip.IP4Address
copy(ip4addr[:], ip4)
addr.Un.SetIP4(ip4addr)
var ip4addr ip.IP4Address
copy(ip4addr[:], ip4)
addr.Un.SetIP4(ip4addr)