go.ligato.io/vpp-agent/v3@v3.5.0/plugins/vpp/natplugin/vppcalls/vpp2106/vppcalls_handler.go (about) 1 // Copyright (c) 2021 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 vpp2106 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/vpp2106" 24 vpp_nat_ed "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2106/nat44_ed" 25 vpp_nat_ei "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2106/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(vpp2106.Version, msgs, NewNatVppHandler) 36 } 37 38 // NatVppHandler is accessor for NAT-related vppcalls methods. 39 type NatVppHandler struct { 40 callsChannel govppapi.Channel 41 ifIndexes ifaceidx.IfaceMetadataIndex 42 dhcpIndex idxmap.NamedMapping 43 log logging.Logger 44 ed bool 45 } 46 47 // NewNatVppHandler creates new instance of NAT vppcalls handler. 48 func NewNatVppHandler(c vpp.Client, 49 ifIndexes ifaceidx.IfaceMetadataIndex, dhcpIndex idxmap.NamedMapping, log logging.Logger, 50 ) vppcalls.NatVppAPI { 51 callsChan, _ := c.NewAPIChannel() 52 return &NatVppHandler{ 53 callsChannel: callsChan, 54 ifIndexes: ifIndexes, 55 dhcpIndex: dhcpIndex, 56 log: log, 57 ed: true, 58 } 59 }