go.ligato.io/vpp-agent/v3@v3.5.0/plugins/vpp/natplugin/vppcalls/vpp2210/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 vpp2210 16 17 import ( 18 govppapi "go.fd.io/govpp/api" 19 "go.ligato.io/cn-infra/v2/idxmap" 20 "go.ligato.io/cn-infra/v2/logging" 21 22 "go.ligato.io/vpp-agent/v3/plugins/vpp" 23 "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2210" 24 vpp_nat_ed "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2210/nat44_ed" 25 vpp_nat_ei "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2210/nat44_ei" 26 "go.ligato.io/vpp-agent/v3/plugins/vpp/ifplugin/ifaceidx" 27 "go.ligato.io/vpp-agent/v3/plugins/vpp/natplugin/vppcalls" 28 ) 29 30 func init() { 31 var msgs []govppapi.Message 32 msgs = append(msgs, vpp_nat_ed.AllMessages()...) 33 msgs = append(msgs, vpp_nat_ei.AllMessages()...) 34 35 vppcalls.AddNatHandlerVersion(vpp2210.Version, msgs, NewNatVppHandler) 36 } 37 38 // NatVppHandler is accessor for NAT-related vppcalls methods. 39 type NatVppHandler struct { 40 callsChannel govppapi.Channel 41 natEd vpp_nat_ed.RPCService 42 natEi vpp_nat_ei.RPCService 43 ifIndexes ifaceidx.IfaceMetadataIndex 44 dhcpIndex idxmap.NamedMapping 45 log logging.Logger 46 ed bool 47 } 48 49 // NewNatVppHandler creates new instance of NAT vppcalls handler. 50 func NewNatVppHandler(c vpp.Client, 51 ifIndexes ifaceidx.IfaceMetadataIndex, dhcpIndex idxmap.NamedMapping, log logging.Logger, 52 ) vppcalls.NatVppAPI { 53 callsChan, _ := c.NewAPIChannel() 54 return &NatVppHandler{ 55 callsChannel: callsChan, 56 natEd: vpp_nat_ed.NewServiceClient(c), 57 natEi: vpp_nat_ei.NewServiceClient(c), 58 ifIndexes: ifIndexes, 59 dhcpIndex: dhcpIndex, 60 log: log, 61 ed: true, 62 } 63 }