go.ligato.io/vpp-agent/v3@v3.5.0/plugins/vpp/ifplugin/vppcalls/vpp2202/loopback_vppcalls.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 vpp_ifs "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2202/interface" 19 "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2202/interface_types" 20 ) 21 22 func (h *InterfaceVppHandler) AddLoopbackInterface(ifName string) (swIndex uint32, err error) { 23 req := &vpp_ifs.CreateLoopback{} 24 reply := &vpp_ifs.CreateLoopbackReply{} 25 26 if err = h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { 27 return 0, err 28 } 29 30 return uint32(reply.SwIfIndex), h.SetInterfaceTag(ifName, uint32(reply.SwIfIndex)) 31 } 32 33 func (h *InterfaceVppHandler) DeleteLoopbackInterface(ifName string, idx uint32) error { 34 // Prepare the message. 35 req := &vpp_ifs.DeleteLoopback{ 36 SwIfIndex: interface_types.InterfaceIndex(idx), 37 } 38 reply := &vpp_ifs.DeleteLoopbackReply{} 39 40 if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { 41 return err 42 } 43 44 return h.RemoveInterfaceTag(ifName, idx) 45 }