go.ligato.io/vpp-agent/v3@v3.5.0/plugins/vpp/l2plugin/vppcalls/vpp2202/bridge_domain_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_l2 "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2202/l2"
    19  	l2 "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/l2"
    20  )
    21  
    22  // AddBridgeDomain adds new bridge domain.
    23  func (h *BridgeDomainVppHandler) AddBridgeDomain(bdIdx uint32, bd *l2.BridgeDomain) error {
    24  	req := &vpp_l2.BridgeDomainAddDel{
    25  		IsAdd:   true,
    26  		BdID:    bdIdx,
    27  		Learn:   bd.Learn,
    28  		ArpTerm: bd.ArpTermination,
    29  		Flood:   bd.Flood,
    30  		UuFlood: bd.UnknownUnicastFlood,
    31  		Forward: bd.Forward,
    32  		MacAge:  uint8(bd.MacAge),
    33  		BdTag:   bd.Name,
    34  	}
    35  	reply := &vpp_l2.BridgeDomainAddDelReply{}
    36  
    37  	if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil {
    38  		return err
    39  	}
    40  
    41  	return nil
    42  }
    43  
    44  // DeleteBridgeDomain removes existing bridge domain.
    45  func (h *BridgeDomainVppHandler) DeleteBridgeDomain(bdIdx uint32) error {
    46  	req := &vpp_l2.BridgeDomainAddDel{
    47  		IsAdd: false,
    48  		BdID:  bdIdx,
    49  	}
    50  	reply := &vpp_l2.BridgeDomainAddDelReply{}
    51  
    52  	if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil {
    53  		return err
    54  	}
    55  
    56  	return nil
    57  }