go.ligato.io/vpp-agent/v3@v3.5.0/plugins/vpp/ifplugin/vppcalls/vpp2202/subif_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  // CreateSubif creates sub interface.
    23  func (h *InterfaceVppHandler) CreateSubif(ifIdx, vlanID uint32) (uint32, error) {
    24  	req := &vpp_ifs.CreateVlanSubif{
    25  		SwIfIndex: interface_types.InterfaceIndex(ifIdx),
    26  		VlanID:    vlanID,
    27  	}
    28  
    29  	reply := &vpp_ifs.CreateVlanSubifReply{}
    30  	if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil {
    31  		return 0, err
    32  	}
    33  
    34  	return uint32(reply.SwIfIndex), nil
    35  }
    36  
    37  // DeleteSubif deletes sub interface.
    38  func (h *InterfaceVppHandler) DeleteSubif(ifIdx uint32) error {
    39  	req := &vpp_ifs.DeleteSubif{
    40  		SwIfIndex: interface_types.InterfaceIndex(ifIdx),
    41  	}
    42  
    43  	reply := &vpp_ifs.DeleteSubifReply{}
    44  	if err := h.callsChannel.SendRequest(req).ReceiveReply(reply); err != nil {
    45  		return err
    46  	}
    47  
    48  	return nil
    49  }