summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/core_test.go19
-rw-r--r--core/msg_codec.go32
2 files changed, 26 insertions, 25 deletions
diff --git a/core/core_test.go b/core/core_test.go
index 3184ef5..37c0b9c 100644
--- a/core/core_test.go
+++ b/core/core_test.go
@@ -12,13 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package core
+package core_test
import (
"testing"
"git.fd.io/govpp.git/adapter/mock"
"git.fd.io/govpp.git/api"
+ "git.fd.io/govpp.git/core"
"git.fd.io/govpp.git/core/bin_api/vpe"
"git.fd.io/govpp.git/examples/bin_api/interfaces"
@@ -27,7 +28,7 @@ import (
type testCtx struct {
mockVpp *mock.VppAdapter
- conn *Connection
+ conn *core.Connection
ch *api.Channel
}
@@ -38,7 +39,7 @@ func setupTest(t *testing.T) *testCtx {
ctx.mockVpp = &mock.VppAdapter{}
var err error
- ctx.conn, err = Connect(ctx.mockVpp)
+ ctx.conn, err = core.Connect(ctx.mockVpp)
Expect(err).ShouldNot(HaveOccurred())
ctx.ch, err = ctx.conn.NewAPIChannel()
@@ -146,7 +147,7 @@ func TestNotifications(t *testing.T) {
func TestNilConnection(t *testing.T) {
RegisterTestingT(t)
- var conn *Connection
+ var conn *core.Connection
ch, err := conn.NewAPIChannel()
Expect(ch).Should(BeNil())
@@ -163,7 +164,7 @@ func TestDoubleConnection(t *testing.T) {
ctx := setupTest(t)
defer ctx.teardownTest()
- conn, err := Connect(ctx.mockVpp)
+ conn, err := core.Connect(ctx.mockVpp)
Expect(err).Should(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("only one connection per process"))
Expect(conn).Should(BeNil())
@@ -174,14 +175,14 @@ func TestAsyncConnection(t *testing.T) {
defer ctx.teardownTest()
ctx.conn.Disconnect()
- conn, ch, err := AsyncConnect(ctx.mockVpp)
+ conn, ch, err := core.AsyncConnect(ctx.mockVpp)
ctx.conn = conn
Expect(err).ShouldNot(HaveOccurred())
Expect(conn).ShouldNot(BeNil())
ev := <-ch
- Expect(ev.State).Should(BeEquivalentTo(Connected))
+ Expect(ev.State).Should(BeEquivalentTo(core.Connected))
}
func TestFullBuffer(t *testing.T) {
@@ -218,7 +219,7 @@ func TestFullBuffer(t *testing.T) {
func TestCodec(t *testing.T) {
RegisterTestingT(t)
- codec := &MsgCodec{}
+ codec := &core.MsgCodec{}
// request
data, err := codec.EncodeMsg(&vpe.CreateLoopback{MacAddress: []byte{1, 2, 3, 4, 5, 6}}, 11)
@@ -254,7 +255,7 @@ func TestCodec(t *testing.T) {
func TestCodecNegative(t *testing.T) {
RegisterTestingT(t)
- codec := &MsgCodec{}
+ codec := &core.MsgCodec{}
// nil message for encoding
data, err := codec.EncodeMsg(nil, 15)
diff --git a/core/msg_codec.go b/core/msg_codec.go
index c72b7f3..3887e3f 100644
--- a/core/msg_codec.go
+++ b/core/msg_codec.go
@@ -30,27 +30,27 @@ import (
// binary format as accepted by VPP.
type MsgCodec struct{}
-// vppRequestHeader struct contains header fields implemented by all VPP requests.
-type vppRequestHeader struct {
+// VppRequestHeader struct contains header fields implemented by all VPP requests.
+type VppRequestHeader struct {
VlMsgID uint16
ClientIndex uint32
Context uint32
}
-// vppReplyHeader struct contains header fields implemented by all VPP replies.
-type vppReplyHeader struct {
+// VppReplyHeader struct contains header fields implemented by all VPP replies.
+type VppReplyHeader struct {
VlMsgID uint16
Context uint32
}
-// vppEventHeader struct contains header fields implemented by all VPP events.
-type vppEventHeader struct {
+// VppEventHeader struct contains header fields implemented by all VPP events.
+type VppEventHeader struct {
VlMsgID uint16
Context uint32
}
-// vppOtherHeader struct contains header fields implemented by other VPP messages (not requests nor replies).
-type vppOtherHeader struct {
+// VppOtherHeader struct contains header fields implemented by other VPP messages (not requests nor replies).
+type VppOtherHeader struct {
VlMsgID uint16
}
@@ -72,13 +72,13 @@ func (*MsgCodec) EncodeMsg(msg api.Message, msgID uint16) ([]byte, error) {
// encode message header
var header interface{}
if msg.GetMessageType() == api.RequestMessage {
- header = &vppRequestHeader{VlMsgID: msgID}
+ header = &VppRequestHeader{VlMsgID: msgID}
} else if msg.GetMessageType() == api.ReplyMessage {
- header = &vppReplyHeader{VlMsgID: msgID}
+ header = &VppReplyHeader{VlMsgID: msgID}
} else if msg.GetMessageType() == api.EventMessage {
- header = &vppEventHeader{VlMsgID: msgID}
+ header = &VppEventHeader{VlMsgID: msgID}
} else {
- header = &vppOtherHeader{VlMsgID: msgID}
+ header = &VppOtherHeader{VlMsgID: msgID}
}
err := struc.Pack(buf, header)
if err != nil {
@@ -115,13 +115,13 @@ func (*MsgCodec) DecodeMsg(data []byte, msg api.Message) error {
// check which header is expected
var header interface{}
if msg.GetMessageType() == api.RequestMessage {
- header = &vppRequestHeader{}
+ header = &VppRequestHeader{}
} else if msg.GetMessageType() == api.ReplyMessage {
- header = &vppReplyHeader{}
+ header = &VppReplyHeader{}
} else if msg.GetMessageType() == api.EventMessage {
- header = &vppEventHeader{}
+ header = &VppEventHeader{}
} else {
- header = &vppOtherHeader{}
+ header = &VppOtherHeader{}
}
// decode message header