aboutsummaryrefslogtreecommitdiffstats
path: root/examples/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'examples/cmd')
-rw-r--r--examples/cmd/perf-bench/perf-bench.go16
-rw-r--r--examples/cmd/simple-client/simple_client.go22
-rw-r--r--examples/cmd/stats-client/stats_client.go6
3 files changed, 22 insertions, 22 deletions
diff --git a/examples/cmd/perf-bench/perf-bench.go b/examples/cmd/perf-bench/perf-bench.go
index f3ff752..b1f4dcf 100644
--- a/examples/cmd/perf-bench/perf-bench.go
+++ b/examples/cmd/perf-bench/perf-bench.go
@@ -95,7 +95,7 @@ func main() {
fmt.Printf("Requests per second: %.0f\n", float64(cnt)/elapsed.Seconds())
}
-func syncTest(ch *api.Channel, cnt int) {
+func syncTest(ch api.Channel, cnt int) {
fmt.Printf("Running synchronous perf test with %d requests...\n", cnt)
for i := 0; i < cnt; i++ {
@@ -110,7 +110,7 @@ func syncTest(ch *api.Channel, cnt int) {
}
}
-func asyncTest(ch *api.Channel, cnt int) {
+func asyncTest(ch api.Channel, cnt int) {
fmt.Printf("Running asynchronous perf test with %d requests...\n", cnt)
// start a new go routine that reads the replies
@@ -125,20 +125,20 @@ func asyncTest(ch *api.Channel, cnt int) {
wg.Wait()
}
-func sendAsyncRequests(ch *api.Channel, cnt int) {
+func sendAsyncRequests(ch api.Channel, cnt int) {
for i := 0; i < cnt; i++ {
- ch.ReqChan <- &api.VppRequest{
+ ch.GetRequestChannel() <- &api.VppRequest{
Message: &vpe.ControlPing{},
}
}
}
-func readAsyncReplies(ch *api.Channel, expectedCnt int, wg *sync.WaitGroup) {
+func readAsyncReplies(ch api.Channel, expectedCnt int, wg *sync.WaitGroup) {
cnt := 0
for {
// receive a reply
- reply := <-ch.ReplyChan
+ reply := <-ch.GetReplyChannel()
if reply.Error != nil {
log.Println("Error in reply:", reply.Error)
os.Exit(1)
@@ -146,7 +146,7 @@ func readAsyncReplies(ch *api.Channel, expectedCnt int, wg *sync.WaitGroup) {
// decode the message
msg := &vpe.ControlPingReply{}
- err := ch.MsgDecoder.DecodeMsg(reply.Data, msg)
+ err := ch.GetMessageDecoder().DecodeMsg(reply.Data, msg)
if reply.Error != nil {
log.Println("Error by decoding:", err)
os.Exit(1)
@@ -159,4 +159,4 @@ func readAsyncReplies(ch *api.Channel, expectedCnt int, wg *sync.WaitGroup) {
return
}
}
-} \ No newline at end of file
+}
diff --git a/examples/cmd/simple-client/simple_client.go b/examples/cmd/simple-client/simple_client.go
index 67dc14b..7b7dbcd 100644
--- a/examples/cmd/simple-client/simple_client.go
+++ b/examples/cmd/simple-client/simple_client.go
@@ -66,7 +66,7 @@ func main() {
// compatibilityCheck shows how an management application can check whether generated API messages are
// compatible with the version of VPP which the library is connected to.
-func compatibilityCheck(ch *api.Channel) {
+func compatibilityCheck(ch api.Channel) {
err := ch.CheckMessageCompatibility(
&interfaces.SwInterfaceDump{},
&interfaces.SwInterfaceDetails{},
@@ -78,7 +78,7 @@ func compatibilityCheck(ch *api.Channel) {
}
// aclVersion is the simplest API example - one empty request message and one reply message.
-func aclVersion(ch *api.Channel) {
+func aclVersion(ch api.Channel) {
req := &acl.ACLPluginGetVersion{}
reply := &acl.ACLPluginGetVersionReply{}
@@ -92,7 +92,7 @@ func aclVersion(ch *api.Channel) {
}
// aclConfig is another simple API example - in this case, the request contains structured data.
-func aclConfig(ch *api.Channel) {
+func aclConfig(ch api.Channel) {
req := &acl.ACLAddReplace{
ACLIndex: ^uint32(0),
Tag: []byte("access list 1"),
@@ -127,7 +127,7 @@ func aclConfig(ch *api.Channel) {
}
// aclDump shows an example where SendRequest and ReceiveReply are not chained together.
-func aclDump(ch *api.Channel) {
+func aclDump(ch api.Channel) {
req := &acl.ACLDump{}
reply := &acl.ACLDetails{}
@@ -143,17 +143,17 @@ func aclDump(ch *api.Channel) {
// tapConnect example shows how the Go channels in the API channel can be accessed directly instead
// of using SendRequest and ReceiveReply wrappers.
-func tapConnect(ch *api.Channel) {
+func tapConnect(ch api.Channel) {
req := &tap.TapConnect{
TapName: []byte("testtap"),
UseRandomMac: 1,
}
// send the request to the request go channel
- ch.ReqChan <- &api.VppRequest{Message: req}
+ ch.GetRequestChannel() <- &api.VppRequest{Message: req}
// receive a reply from the reply go channel
- vppReply := <-ch.ReplyChan
+ vppReply := <-ch.GetReplyChannel()
if vppReply.Error != nil {
fmt.Println("Error:", vppReply.Error)
return
@@ -161,7 +161,7 @@ func tapConnect(ch *api.Channel) {
// decode the message
reply := &tap.TapConnectReply{}
- err := ch.MsgDecoder.DecodeMsg(vppReply.Data, reply)
+ err := ch.GetMessageDecoder().DecodeMsg(vppReply.Data, reply)
if err != nil {
fmt.Println("Error:", err)
@@ -171,7 +171,7 @@ func tapConnect(ch *api.Channel) {
}
// interfaceDump shows an example of multipart request (multiple replies are expected).
-func interfaceDump(ch *api.Channel) {
+func interfaceDump(ch api.Channel) {
req := &interfaces.SwInterfaceDump{}
reqCtx := ch.SendMultiRequest(req)
@@ -191,7 +191,7 @@ func interfaceDump(ch *api.Channel) {
// interfaceNotifications shows the usage of notification API. Note that for notifications,
// you are supposed to create your own Go channel with your preferred buffer size. If the channel's
// buffer is full, the notifications will not be delivered into it.
-func interfaceNotifications(ch *api.Channel) {
+func interfaceNotifications(ch api.Channel) {
// subscribe for specific notification message
notifChan := make(chan api.Message, 100)
subs, _ := ch.SubscribeNotification(notifChan, interfaces.NewSwInterfaceSetFlags)
@@ -218,4 +218,4 @@ func interfaceNotifications(ch *api.Channel) {
// unsubscribe from delivery of the notifications
ch.UnsubscribeNotification(subs)
-} \ No newline at end of file
+}
diff --git a/examples/cmd/stats-client/stats_client.go b/examples/cmd/stats-client/stats_client.go
index 17c7956..5f9966f 100644
--- a/examples/cmd/stats-client/stats_client.go
+++ b/examples/cmd/stats-client/stats_client.go
@@ -101,7 +101,7 @@ loop:
}
// subscribeNotifications subscribes for interface counters notifications.
-func subscribeNotifications(ch *api.Channel) (*api.NotifSubscription, *api.NotifSubscription, chan api.Message) {
+func subscribeNotifications(ch api.Channel) (*api.NotifSubscription, *api.NotifSubscription, chan api.Message) {
notifChan := make(chan api.Message, 100)
simpleCountersSubs, _ := ch.SubscribeNotification(notifChan, interfaces.NewVnetInterfaceSimpleCounters)
@@ -111,7 +111,7 @@ func subscribeNotifications(ch *api.Channel) (*api.NotifSubscription, *api.Notif
}
// requestStatistics requests interface counters notifications from VPP.
-func requestStatistics(ch *api.Channel) {
+func requestStatistics(ch api.Channel) {
ch.SendRequest(&stats.WantStats{
Pid: uint32(os.Getpid()),
EnableDisable: 1,
@@ -141,4 +141,4 @@ func processCombinedCounters(counters *interfaces.VnetInterfaceCombinedCounters)
counters.FirstSwIfIndex+i, counterNames[counters.VnetCounterType], counters.Data[i].Packets,
counterNames[counters.VnetCounterType], counters.Data[i].Bytes)
}
-} \ No newline at end of file
+}