go.ligato.io/vpp-agent/v3@v3.5.0/plugins/vpp/l2plugin/vppcalls/vpp2106/arp_term_vppcalls.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 "net" 19 20 vpp_l2 "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2106/l2" 21 ) 22 23 func (h *BridgeDomainVppHandler) callBdIPMacAddDel(isAdd bool, bdID uint32, mac string, ip string) error { 24 ipAddr, err := ipToAddress(ip) 25 if err != nil { 26 return err 27 } 28 macAddr, err := net.ParseMAC(mac) 29 if err != nil { 30 return err 31 } 32 bdEntry := vpp_l2.BdIPMac{ 33 BdID: bdID, 34 IP: ipAddr, 35 } 36 copy(bdEntry.Mac[:], macAddr) 37 38 req := &vpp_l2.BdIPMacAddDel{ 39 IsAdd: isAdd, 40 Entry: bdEntry, 41 } 42 43 reply := &vpp_l2.BdIPMacAddDelReply{} 44 if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil { 45 return err 46 } 47 48 return nil 49 } 50 51 // AddArpTerminationTableEntry creates ARP termination entry for bridge domain. 52 func (h *BridgeDomainVppHandler) AddArpTerminationTableEntry(bdID uint32, mac string, ip string) error { 53 err := h.callBdIPMacAddDel(true, bdID, mac, ip) 54 if err != nil { 55 return err 56 } 57 return nil 58 } 59 60 // RemoveArpTerminationTableEntry removes ARP termination entry from bridge domain. 61 func (h *BridgeDomainVppHandler) RemoveArpTerminationTableEntry(bdID uint32, mac string, ip string) error { 62 err := h.callBdIPMacAddDel(false, bdID, mac, ip) 63 if err != nil { 64 return err 65 } 66 return nil 67 }