go.ligato.io/vpp-agent/v3@v3.5.0/plugins/vpp/dnsplugin/vppcalls/vpp2210/vppcalls_handler.go (about)

     1  // Copyright (c) 2022 Pantheon.tech
     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 vpp2210
    16  
    17  import (
    18  	govppapi "go.fd.io/govpp/api"
    19  	"go.ligato.io/cn-infra/v2/logging"
    20  
    21  	core_vppcalls "go.ligato.io/vpp-agent/v3/plugins/govppmux/vppcalls"
    22  	core_vpp2210 "go.ligato.io/vpp-agent/v3/plugins/govppmux/vppcalls/vpp2210"
    23  	"go.ligato.io/vpp-agent/v3/plugins/vpp"
    24  	"go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2210"
    25  	"go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2210/dns"
    26  	"go.ligato.io/vpp-agent/v3/plugins/vpp/dnsplugin/vppcalls"
    27  )
    28  
    29  func init() {
    30  	msgs := vpp.Messages(
    31  		dns.AllMessages,
    32  	)
    33  	vppcalls.AddHandlerVersion(vpp2210.Version, msgs.AllMessages(), NewDNSVppHandler)
    34  }
    35  
    36  // DNSVppHandler is accessor for DNS-related vppcalls methods
    37  type DNSVppHandler struct {
    38  	core_vppcalls.VppCoreAPI
    39  
    40  	log          logging.Logger
    41  	callsChannel govppapi.Channel
    42  }
    43  
    44  // NewDNSVppHandler creates new instance of DNS vppcalls handler
    45  func NewDNSVppHandler(c vpp.Client, log logging.Logger) vppcalls.DNSVppAPI {
    46  	vppChan, err := c.NewAPIChannel()
    47  	if err != nil {
    48  		logging.Warnf("failed to create API channel")
    49  		return nil
    50  	}
    51  	return &DNSVppHandler{
    52  		callsChannel: vppChan,
    53  		log:          log,
    54  		VppCoreAPI:   core_vpp2210.NewVpeHandler(c),
    55  	}
    56  }