go.ligato.io/vpp-agent/v3@v3.5.0/plugins/vpp/ifplugin/vppcalls/vpp2202/vppcalls_handler.go (about) 1 // Copyright (c) 2022 Cisco and/or its affiliates. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at: 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package vpp2202 16 17 import ( 18 govppapi "go.fd.io/govpp/api" 19 "go.ligato.io/cn-infra/v2/logging" 20 21 "go.ligato.io/vpp-agent/v3/plugins/vpp" 22 vpp2202 "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2202" 23 "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2202/af_packet" 24 "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2202/bond" 25 "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2202/dhcp" 26 "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2202/gre" 27 "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2202/gtpu" 28 interfaces "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2202/interface" 29 "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2202/ip" 30 "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2202/ip6_nd" 31 "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2202/ipsec" 32 "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2202/l2" 33 "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2202/memif" 34 "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2202/rd_cp" 35 "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2202/rdma" 36 "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2202/span" 37 "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2202/tapv2" 38 "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2202/vmxnet3" 39 "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2202/vxlan" 40 "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2202/wireguard" 41 "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin/vppcalls" 42 ) 43 44 var HandlerVersion = vpp.HandlerVersion{ 45 Version: vpp2202.Version, 46 Check: func(c vpp.Client) error { 47 msgs := vpp.Messages( 48 af_packet.AllMessages, 49 bond.AllMessages, 50 dhcp.AllMessages, 51 interfaces.AllMessages, 52 ip.AllMessages, 53 ipsec.AllMessages, 54 gre.AllMessages, 55 l2.AllMessages, 56 span.AllMessages, 57 tapv2.AllMessages, 58 vxlan.AllMessages, 59 ) 60 if c.IsPluginLoaded(gtpu.APIFile) { 61 msgs.Add(gtpu.AllMessages) 62 } 63 if c.IsPluginLoaded(memif.APIFile) { 64 msgs.Add(memif.AllMessages) 65 } 66 if c.IsPluginLoaded(vmxnet3.APIFile) { 67 msgs.Add(vmxnet3.AllMessages) 68 } 69 if c.IsPluginLoaded(wireguard.APIFile) { 70 msgs.Add(wireguard.AllMessages) 71 } 72 if c.IsPluginLoaded(rdma.APIFile) { 73 msgs.Add(rdma.AllMessages) 74 } 75 return c.CheckCompatiblity(msgs.AllMessages()...) 76 }, 77 NewHandler: func(c vpp.Client, a ...interface{}) vpp.HandlerAPI { 78 return NewInterfaceVppHandler(c, a[0].(logging.Logger)) 79 }, 80 } 81 82 func init() { 83 vppcalls.Handler.AddVersion(HandlerVersion) 84 } 85 86 // InterfaceVppHandler is accessor for interface-related vppcalls methods 87 type InterfaceVppHandler struct { 88 callsChannel govppapi.Channel 89 interfaces interfaces.RPCService 90 ipsec ipsec.RPCService 91 gtpu gtpu.RPCService 92 memif memif.RPCService 93 vmxnet3 vmxnet3.RPCService 94 rpcIP6nd ip6_nd.RPCService 95 rpcRdCp rd_cp.RPCService 96 wireguard wireguard.RPCService 97 rdma rdma.RPCService 98 log logging.Logger 99 } 100 101 // NewInterfaceVppHandler returns new InterfaceVppHandler. 102 func NewInterfaceVppHandler(c vpp.Client, log logging.Logger) vppcalls.InterfaceVppAPI { 103 ch, err := c.NewAPIChannel() 104 if err != nil { 105 return nil 106 } 107 h := &InterfaceVppHandler{ 108 callsChannel: ch, 109 interfaces: interfaces.NewServiceClient(c), 110 ipsec: ipsec.NewServiceClient(c), 111 rpcIP6nd: ip6_nd.NewServiceClient(c), 112 rpcRdCp: rd_cp.NewServiceClient(c), 113 log: log, 114 } 115 if c.IsPluginLoaded(gtpu.APIFile) { 116 h.gtpu = gtpu.NewServiceClient(c) 117 } 118 if c.IsPluginLoaded(memif.APIFile) { 119 h.memif = memif.NewServiceClient(c) 120 } 121 if c.IsPluginLoaded(vmxnet3.APIFile) { 122 h.vmxnet3 = vmxnet3.NewServiceClient(c) 123 } 124 if c.IsPluginLoaded(wireguard.APIFile) { 125 h.wireguard = wireguard.NewServiceClient(c) 126 } 127 if c.IsPluginLoaded(rdma.APIFile) { 128 h.rdma = rdma.NewServiceClient(c) 129 } 130 return h 131 }