"git.fd.io/govpp.git/adapter/mock"
"git.fd.io/govpp.git/api"
+ "git.fd.io/govpp.git/examples/binapi/interface_types"
"git.fd.io/govpp.git/examples/binapi/interfaces"
"git.fd.io/govpp.git/examples/binapi/memif"
"git.fd.io/govpp.git/examples/binapi/vpe"
var msgs []api.Message
for i := 1; i <= 10; i++ {
msgs = append(msgs, &memif.MemifDetails{
- SwIfIndex: uint32(i),
+ SwIfIndex: interfaces.InterfaceIndex(i),
})
}
ctx.mockVpp.MockReply(msgs...)
// mock event and force its delivery
ctx.mockVpp.MockReply(&interfaces.SwInterfaceEvent{
- SwIfIndex: 2,
- LinkUpDown: 1,
+ SwIfIndex: 2,
+ Flags: interface_types.IF_STATUS_API_FLAG_LINK_UP,
})
ctx.mockVpp.SendMsg(0, []byte(""))
// verify the received notifications
Expect(notif.SwIfIndex).To(BeEquivalentTo(2), "Incorrect SwIfIndex value for SwInterfaceSetFlags")
- Expect(notif.LinkUpDown).To(BeEquivalentTo(1), "Incorrect LinkUpDown value for SwInterfaceSetFlags")
+ Expect(notif.Flags).To(BeEquivalentTo(interface_types.IF_STATUS_API_FLAG_LINK_UP), "Incorrect LinkUpDown value for SwInterfaceSetFlags")
err = sub.Unsubscribe()
Expect(err).ShouldNot(HaveOccurred())
for i := 1; i <= 3; i++ {
msgs = append(msgs, mock.MsgWithContext{
Msg: &interfaces.SwInterfaceDetails{
- SwIfIndex: uint32(i),
+ SwIfIndex: interfaces.InterfaceIndex(i),
InterfaceName: "if-name-test",
},
Multipart: true,
msgs = append(msgs,
mock.MsgWithContext{
Msg: &interfaces.SwInterfaceDetails{
- SwIfIndex: uint32(i),
+ SwIfIndex: interfaces.InterfaceIndex(i),
InterfaceName: "if-name-test",
},
Multipart: true,
)
req := &interfaces.SwInterfaceSetFlags{
- SwIfIndex: 1,
- AdminUpDown: 1,
+ SwIfIndex: 1,
+ Flags: interface_types.IF_STATUS_API_FLAG_ADMIN_UP,
}
reply := &interfaces.SwInterfaceSetFlagsReply{}
for i := 1; i <= 3; i++ {
msgs = append(msgs, mock.MsgWithContext{
Msg: &interfaces.SwInterfaceDetails{
- SwIfIndex: uint32(i),
+ SwIfIndex: interfaces.InterfaceIndex(i),
InterfaceName: "if-name-test",
},
Multipart: true,
ctx.mockVpp.MockReplyWithContext(mock.MsgWithContext{Msg: &interfaces.SwInterfaceSetFlagsReply{}, SeqNum: 3})
req := &interfaces.SwInterfaceSetFlags{
- SwIfIndex: 1,
- AdminUpDown: 1,
+ SwIfIndex: 1,
+ Flags: interface_types.IF_STATUS_API_FLAG_ADMIN_UP,
}
reply := &interfaces.SwInterfaceSetFlagsReply{}
import (
"testing"
+ . "github.com/onsi/gomega"
+
"git.fd.io/govpp.git/adapter/mock"
"git.fd.io/govpp.git/api"
"git.fd.io/govpp.git/codec"
"git.fd.io/govpp.git/core"
"git.fd.io/govpp.git/examples/binapi/interfaces"
"git.fd.io/govpp.git/examples/binapi/vpe"
- . "github.com/onsi/gomega"
)
type testCtx struct {
msgCodec := &codec.MsgCodec{}
// request
- data, err := msgCodec.EncodeMsg(&interfaces.CreateLoopback{MacAddress: []byte{1, 2, 3, 4, 5, 6}}, 11)
+ data, err := msgCodec.EncodeMsg(&interfaces.CreateLoopback{MacAddress: interfaces.MacAddress{1, 2, 3, 4, 5, 6}}, 11)
Expect(err).ShouldNot(HaveOccurred())
Expect(data).ShouldNot(BeEmpty())
msg1 := &interfaces.CreateLoopback{}
err = msgCodec.DecodeMsg(data, msg1)
Expect(err).ShouldNot(HaveOccurred())
- Expect(msg1.MacAddress).To(BeEquivalentTo([]byte{1, 2, 3, 4, 5, 6}))
+ Expect(msg1.MacAddress).To(BeEquivalentTo(interfaces.MacAddress{1, 2, 3, 4, 5, 6}))
// reply
data, err = msgCodec.EncodeMsg(&vpe.ControlPingReply{Retval: 55}, 22)
var msgs []api.Message
for i := 0; i < 10; i++ {
- msgs = append(msgs, &interfaces.SwInterfaceDetails{SwIfIndex: uint32(i)})
+ msgs = append(msgs, &interfaces.SwInterfaceDetails{SwIfIndex: interfaces.InterfaceIndex(i)})
}
ctx.mockVpp.MockReply(msgs...)
ctx.mockVpp.MockReply(&vpe.ControlPingReply{})
}
for i := 0; i < 10; i++ {
msgs = append(msgs, mock.MsgWithContext{
- Msg: &interfaces.SwInterfaceDetails{SwIfIndex: uint32(i)},
+ Msg: &interfaces.SwInterfaceDetails{SwIfIndex: interfaces.InterfaceIndex(i)},
SeqNum: 1,
Multipart: true,
})
io "io"
strconv "strconv"
- ethernet_types "git.fd.io/govpp.git/examples/ethernet_types"
- interface_types "git.fd.io/govpp.git/examples/interface_types"
+ ethernet_types "git.fd.io/govpp.git/examples/binapi/ethernet_types"
+ interface_types "git.fd.io/govpp.git/examples/binapi/interface_types"
)
const (
//go:generate binapi-generator --output-dir=. --input-file=/usr/share/vpp/api/core/ip_types.api.json
//go:generate binapi-generator --output-dir=. --input-file=/usr/share/vpp/api/core/vpe_types.api.json
-//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
+//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
//go:generate binapigen --input-file=/usr/share/vpp/api/core/af_packet.api.json
//go:generate binapigen --input-file=/usr/share/vpp/api/core/interface.api.json
io "io"
strconv "strconv"
- ethernet_types "git.fd.io/govpp.git/examples/ethernet_types"
- interface_types "git.fd.io/govpp.git/examples/interface_types"
- ip_types "git.fd.io/govpp.git/examples/ip_types"
+ ethernet_types "git.fd.io/govpp.git/examples/binapi/ethernet_types"
+ interface_types "git.fd.io/govpp.git/examples/binapi/interface_types"
+ ip_types "git.fd.io/govpp.git/examples/binapi/ip_types"
)
const (
io "io"
strconv "strconv"
- ethernet_types "git.fd.io/govpp.git/examples/ethernet_types"
- interface_types "git.fd.io/govpp.git/examples/interface_types"
- ip_types "git.fd.io/govpp.git/examples/ip_types"
+ ethernet_types "git.fd.io/govpp.git/examples/binapi/ethernet_types"
+ interface_types "git.fd.io/govpp.git/examples/binapi/interface_types"
+ ip_types "git.fd.io/govpp.git/examples/binapi/ip_types"
)
const (
io "io"
strconv "strconv"
- ethernet_types "git.fd.io/govpp.git/examples/ethernet_types"
- interface_types "git.fd.io/govpp.git/examples/interface_types"
+ ethernet_types "git.fd.io/govpp.git/examples/binapi/ethernet_types"
+ interface_types "git.fd.io/govpp.git/examples/binapi/interface_types"
)
const (
io "io"
strconv "strconv"
- vpe_types "git.fd.io/govpp.git/examples/vpe_types"
+ vpe_types "git.fd.io/govpp.git/examples/binapi/vpe_types"
)
const (
"git.fd.io/govpp.git/adapter/socketclient"
"git.fd.io/govpp.git/api"
"git.fd.io/govpp.git/core"
+ "git.fd.io/govpp.git/examples/binapi/interface_types"
"git.fd.io/govpp.git/examples/binapi/interfaces"
"git.fd.io/govpp.git/examples/binapi/ip"
+ "git.fd.io/govpp.git/examples/binapi/ip_types"
"git.fd.io/govpp.git/examples/binapi/vpe"
)
fmt.Println("Adding IP address to interface")
req := &interfaces.SwInterfaceAddDelAddress{
- SwIfIndex: 1,
- IsAdd: 1,
- Address: []byte{10, 10, 0, 1},
- AddressLength: 24,
- /* below for 20.01-rc0
+ SwIfIndex: 1,
IsAdd: true,
- Prefix: interfaces.Prefix{
+ Prefix: ip_types.AddressWithPrefix{
Address: interfaces.Address{
- Af: interfaces.ADDRESS_IP4,
- Un: interfaces.AddressUnionIP4(interfaces.IP4Address{10, 10, 0, 1}),
+ Af: ip_types.ADDRESS_IP4,
+ Un: ip_types.AddressUnionIP4(interfaces.IP4Address{10, 10, 0, 1}),
},
Len: 24,
- },*/
+ },
}
reply := &interfaces.SwInterfaceAddDelAddressReply{}
return
}
err = ch.SendRequest(&interfaces.SwInterfaceSetFlags{
- SwIfIndex: 1,
- AdminUpDown: 1,
- /* below for 20.01-rc0
- AdminUpDown: true,
- Flags: interfaces.IF_STATUS_API_FLAG_ADMIN_UP,*/
+ SwIfIndex: 1,
+ Flags: interface_types.IF_STATUS_API_FLAG_ADMIN_UP,
}).ReceiveReply(&interfaces.SwInterfaceSetFlagsReply{})
if err != nil {
logError(err, "setting interface flags")
"net"
"git.fd.io/govpp.git/examples/binapi/ip"
+ "git.fd.io/govpp.git/examples/binapi/ip_types"
+
"github.com/lunixbochs/struc"
)
// 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())
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 {
- addr.Af = ip.ADDRESS_IP4
+ addr.Af = ip_types.ADDRESS_IP4
var ip4addr ip.IP4Address
copy(ip4addr[:], ip4)
addr.Un.SetIP4(ip4addr)