Skip to content

Commit 9f27eef

Browse files
committed
Fix import path in examples/binapi
Change-Id: I6af1ae2778b73f37be09c64a2948417e576f02ab Signed-off-by: Ondrej Fabry <[email protected]>
1 parent d4d3b9c commit 9f27eef

File tree

10 files changed

+45
-46
lines changed

10 files changed

+45
-46
lines changed

core/channel_test.go

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222

2323
"git.fd.io/govpp.git/adapter/mock"
2424
"git.fd.io/govpp.git/api"
25+
"git.fd.io/govpp.git/examples/binapi/interface_types"
2526
"git.fd.io/govpp.git/examples/binapi/interfaces"
2627
"git.fd.io/govpp.git/examples/binapi/memif"
2728
"git.fd.io/govpp.git/examples/binapi/vpe"
@@ -128,7 +129,7 @@ func TestMultiRequestReplySwInterfaceMemifDump(t *testing.T) {
128129
var msgs []api.Message
129130
for i := 1; i <= 10; i++ {
130131
msgs = append(msgs, &memif.MemifDetails{
131-
SwIfIndex: uint32(i),
132+
SwIfIndex: interfaces.InterfaceIndex(i),
132133
})
133134
}
134135
ctx.mockVpp.MockReply(msgs...)
@@ -159,8 +160,8 @@ func TestNotificationEvent(t *testing.T) {
159160

160161
// mock event and force its delivery
161162
ctx.mockVpp.MockReply(&interfaces.SwInterfaceEvent{
162-
SwIfIndex: 2,
163-
LinkUpDown: 1,
163+
SwIfIndex: 2,
164+
Flags: interface_types.IF_STATUS_API_FLAG_LINK_UP,
164165
})
165166
ctx.mockVpp.SendMsg(0, []byte(""))
166167

@@ -178,7 +179,7 @@ func TestNotificationEvent(t *testing.T) {
178179

179180
// verify the received notifications
180181
Expect(notif.SwIfIndex).To(BeEquivalentTo(2), "Incorrect SwIfIndex value for SwInterfaceSetFlags")
181-
Expect(notif.LinkUpDown).To(BeEquivalentTo(1), "Incorrect LinkUpDown value for SwInterfaceSetFlags")
182+
Expect(notif.Flags).To(BeEquivalentTo(interface_types.IF_STATUS_API_FLAG_LINK_UP), "Incorrect LinkUpDown value for SwInterfaceSetFlags")
182183

183184
err = sub.Unsubscribe()
184185
Expect(err).ShouldNot(HaveOccurred())
@@ -287,7 +288,7 @@ func TestMultiRequestDouble(t *testing.T) {
287288
for i := 1; i <= 3; i++ {
288289
msgs = append(msgs, mock.MsgWithContext{
289290
Msg: &interfaces.SwInterfaceDetails{
290-
SwIfIndex: uint32(i),
291+
SwIfIndex: interfaces.InterfaceIndex(i),
291292
InterfaceName: "if-name-test",
292293
},
293294
Multipart: true,
@@ -300,7 +301,7 @@ func TestMultiRequestDouble(t *testing.T) {
300301
msgs = append(msgs,
301302
mock.MsgWithContext{
302303
Msg: &interfaces.SwInterfaceDetails{
303-
SwIfIndex: uint32(i),
304+
SwIfIndex: interfaces.InterfaceIndex(i),
304305
InterfaceName: "if-name-test",
305306
},
306307
Multipart: true,
@@ -368,8 +369,8 @@ func TestReceiveReplyAfterTimeout(t *testing.T) {
368369
)
369370

370371
req := &interfaces.SwInterfaceSetFlags{
371-
SwIfIndex: 1,
372-
AdminUpDown: 1,
372+
SwIfIndex: 1,
373+
Flags: interface_types.IF_STATUS_API_FLAG_ADMIN_UP,
373374
}
374375
reply := &interfaces.SwInterfaceSetFlagsReply{}
375376

@@ -426,7 +427,7 @@ func TestReceiveReplyAfterTimeoutMultiRequest(t *testing.T) {
426427
for i := 1; i <= 3; i++ {
427428
msgs = append(msgs, mock.MsgWithContext{
428429
Msg: &interfaces.SwInterfaceDetails{
429-
SwIfIndex: uint32(i),
430+
SwIfIndex: interfaces.InterfaceIndex(i),
430431
InterfaceName: "if-name-test",
431432
},
432433
Multipart: true,
@@ -440,8 +441,8 @@ func TestReceiveReplyAfterTimeoutMultiRequest(t *testing.T) {
440441
ctx.mockVpp.MockReplyWithContext(mock.MsgWithContext{Msg: &interfaces.SwInterfaceSetFlagsReply{}, SeqNum: 3})
441442

442443
req := &interfaces.SwInterfaceSetFlags{
443-
SwIfIndex: 1,
444-
AdminUpDown: 1,
444+
SwIfIndex: 1,
445+
Flags: interface_types.IF_STATUS_API_FLAG_ADMIN_UP,
445446
}
446447
reply := &interfaces.SwInterfaceSetFlagsReply{}
447448

core/connection_test.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@ package core_test
1717
import (
1818
"testing"
1919

20+
. "github.com/onsi/gomega"
21+
2022
"git.fd.io/govpp.git/adapter/mock"
2123
"git.fd.io/govpp.git/api"
2224
"git.fd.io/govpp.git/codec"
2325
"git.fd.io/govpp.git/core"
2426
"git.fd.io/govpp.git/examples/binapi/interfaces"
2527
"git.fd.io/govpp.git/examples/binapi/vpe"
26-
. "github.com/onsi/gomega"
2728
)
2829

2930
type testCtx struct {
@@ -94,14 +95,14 @@ func TestCodec(t *testing.T) {
9495
msgCodec := &codec.MsgCodec{}
9596

9697
// request
97-
data, err := msgCodec.EncodeMsg(&interfaces.CreateLoopback{MacAddress: []byte{1, 2, 3, 4, 5, 6}}, 11)
98+
data, err := msgCodec.EncodeMsg(&interfaces.CreateLoopback{MacAddress: interfaces.MacAddress{1, 2, 3, 4, 5, 6}}, 11)
9899
Expect(err).ShouldNot(HaveOccurred())
99100
Expect(data).ShouldNot(BeEmpty())
100101

101102
msg1 := &interfaces.CreateLoopback{}
102103
err = msgCodec.DecodeMsg(data, msg1)
103104
Expect(err).ShouldNot(HaveOccurred())
104-
Expect(msg1.MacAddress).To(BeEquivalentTo([]byte{1, 2, 3, 4, 5, 6}))
105+
Expect(msg1.MacAddress).To(BeEquivalentTo(interfaces.MacAddress{1, 2, 3, 4, 5, 6}))
105106

106107
// reply
107108
data, err = msgCodec.EncodeMsg(&vpe.ControlPingReply{Retval: 55}, 22)
@@ -160,7 +161,7 @@ func TestMultiRequestsWithSequenceNumbers(t *testing.T) {
160161

161162
var msgs []api.Message
162163
for i := 0; i < 10; i++ {
163-
msgs = append(msgs, &interfaces.SwInterfaceDetails{SwIfIndex: uint32(i)})
164+
msgs = append(msgs, &interfaces.SwInterfaceDetails{SwIfIndex: interfaces.InterfaceIndex(i)})
164165
}
165166
ctx.mockVpp.MockReply(msgs...)
166167
ctx.mockVpp.MockReply(&vpe.ControlPingReply{})
@@ -279,7 +280,7 @@ func TestMultiRequestsWithErrors(t *testing.T) {
279280
}
280281
for i := 0; i < 10; i++ {
281282
msgs = append(msgs, mock.MsgWithContext{
282-
Msg: &interfaces.SwInterfaceDetails{SwIfIndex: uint32(i)},
283+
Msg: &interfaces.SwInterfaceDetails{SwIfIndex: interfaces.InterfaceIndex(i)},
283284
SeqNum: 1,
284285
Multipart: true,
285286
})

examples/binapi/af_packet/af_packet.ba.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/binapi/gen.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ package binapi
77
//go:generate binapi-generator --output-dir=. --input-file=/usr/share/vpp/api/core/ip_types.api.json
88
//go:generate binapi-generator --output-dir=. --input-file=/usr/share/vpp/api/core/vpe_types.api.json
99

10-
//go:generate -command binapigen binapi-generator --output-dir=. --import-prefix=git.fd.io/govpp.git/examples --input-types=/usr/share/vpp/api/core/ethernet_types.api.json,/usr/share/vpp/api/core/ip_types.api.json,/usr/share/vpp/api/core/interface_types.api.json,/usr/share/vpp/api/core/vpe_types.api.json
10+
//go:generate -command binapigen binapi-generator --output-dir=. --import-prefix=git.fd.io/govpp.git/examples/binapi --input-types=/usr/share/vpp/api/core/ethernet_types.api.json,/usr/share/vpp/api/core/ip_types.api.json,/usr/share/vpp/api/core/interface_types.api.json,/usr/share/vpp/api/core/vpe_types.api.json
1111

1212
//go:generate binapigen --input-file=/usr/share/vpp/api/core/af_packet.api.json
1313
//go:generate binapigen --input-file=/usr/share/vpp/api/core/interface.api.json

examples/binapi/interfaces/interfaces.ba.go

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/binapi/ip/ip.ba.go

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/binapi/memif/memif.ba.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/binapi/vpe/vpe.ba.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/simple-client/simple_client.go

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ import (
2727
"git.fd.io/govpp.git/adapter/socketclient"
2828
"git.fd.io/govpp.git/api"
2929
"git.fd.io/govpp.git/core"
30+
"git.fd.io/govpp.git/examples/binapi/interface_types"
3031
"git.fd.io/govpp.git/examples/binapi/interfaces"
3132
"git.fd.io/govpp.git/examples/binapi/ip"
33+
"git.fd.io/govpp.git/examples/binapi/ip_types"
3234
"git.fd.io/govpp.git/examples/binapi/vpe"
3335
)
3436

@@ -153,19 +155,15 @@ func addIPAddress(ch api.Channel) {
153155
fmt.Println("Adding IP address to interface")
154156

155157
req := &interfaces.SwInterfaceAddDelAddress{
156-
SwIfIndex: 1,
157-
IsAdd: 1,
158-
Address: []byte{10, 10, 0, 1},
159-
AddressLength: 24,
160-
/* below for 20.01-rc0
158+
SwIfIndex: 1,
161159
IsAdd: true,
162-
Prefix: interfaces.Prefix{
160+
Prefix: ip_types.AddressWithPrefix{
163161
Address: interfaces.Address{
164-
Af: interfaces.ADDRESS_IP4,
165-
Un: interfaces.AddressUnionIP4(interfaces.IP4Address{10, 10, 0, 1}),
162+
Af: ip_types.ADDRESS_IP4,
163+
Un: ip_types.AddressUnionIP4(interfaces.IP4Address{10, 10, 0, 1}),
166164
},
167165
Len: 24,
168-
},*/
166+
},
169167
}
170168
reply := &interfaces.SwInterfaceAddDelAddressReply{}
171169

@@ -236,11 +234,8 @@ func interfaceNotifications(ch api.Channel) {
236234
return
237235
}
238236
err = ch.SendRequest(&interfaces.SwInterfaceSetFlags{
239-
SwIfIndex: 1,
240-
AdminUpDown: 1,
241-
/* below for 20.01-rc0
242-
AdminUpDown: true,
243-
Flags: interfaces.IF_STATUS_API_FLAG_ADMIN_UP,*/
237+
SwIfIndex: 1,
238+
Flags: interface_types.IF_STATUS_API_FLAG_ADMIN_UP,
244239
}).ReceiveReply(&interfaces.SwInterfaceSetFlagsReply{})
245240
if err != nil {
246241
logError(err, "setting interface flags")

examples/union-example/union_example.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import (
2222
"net"
2323

2424
"git.fd.io/govpp.git/examples/binapi/ip"
25+
"git.fd.io/govpp.git/examples/binapi/ip_types"
26+
2527
"github.com/lunixbochs/struc"
2628
)
2729

@@ -37,8 +39,8 @@ func encodingExample() {
3739

3840
// use it in the Address type
3941
addr := &ip.Address{
40-
Af: ip.ADDRESS_IP4,
41-
Un: ip.AddressUnionIP4(ip.IP4Address{192, 168, 1, 10}),
42+
Af: ip_types.ADDRESS_IP4,
43+
Un: ip_types.AddressUnionIP4(ip.IP4Address{192, 168, 1, 10}),
4244
}
4345
log.Printf("encoding union IPv4: %v", addr.Un.GetIP4())
4446

@@ -89,12 +91,12 @@ func ipToAddress(ipstr string) (addr ip.Address, err error) {
8991
return ip.Address{}, fmt.Errorf("invalid IP: %q", ipstr)
9092
}
9193
if ip4 := netIP.To4(); ip4 == nil {
92-
addr.Af = ip.ADDRESS_IP6
94+
addr.Af = ip_types.ADDRESS_IP6
9395
var ip6addr ip.IP6Address
9496
copy(ip6addr[:], netIP.To16())
9597
addr.Un.SetIP6(ip6addr)
9698
} else {
97-
addr.Af = ip.ADDRESS_IP4
99+
addr.Af = ip_types.ADDRESS_IP4
98100
var ip4addr ip.IP4Address
99101
copy(ip4addr[:], ip4)
100102
addr.Un.SetIP4(ip4addr)

0 commit comments

Comments
 (0)