go.ligato.io/vpp-agent/v3@v3.5.0/proto/ligato/vpp/punt/models.go (about)

     1  // Copyright (c) 2018 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 vpp_punt
    16  
    17  import (
    18  	"go.ligato.io/vpp-agent/v3/pkg/models"
    19  )
    20  
    21  // ModuleName is the module name used for models.
    22  const ModuleName = "vpp"
    23  
    24  var (
    25  	ModelIPRedirect = models.Register(&IPRedirect{}, models.Spec{
    26  		Module:  ModuleName,
    27  		Type:    "ipredirect",
    28  		Version: "v2",
    29  	}, models.WithNameTemplate(
    30  		"l3/{{.L3Protocol}}/tx/{{.TxInterface}}",
    31  	))
    32  	ModelToHost = models.Register(&ToHost{}, models.Spec{
    33  		Module:  ModuleName,
    34  		Type:    "tohost",
    35  		Version: "v2",
    36  	}, models.WithNameTemplate(
    37  		"l3/{{.L3Protocol}}/l4/{{.L4Protocol}}/port/{{.Port}}",
    38  	))
    39  	ModelException = models.Register(&Exception{}, models.Spec{
    40  		Module:  ModuleName,
    41  		Type:    "exception",
    42  		Version: "v2",
    43  	}, models.WithNameTemplate(
    44  		"reason/{{.Reason}}",
    45  	))
    46  )
    47  
    48  // IPRedirectKey returns key representing IP punt redirect configuration.
    49  func IPRedirectKey(l3Proto L3Protocol, txIf string) string {
    50  	return models.Key(&IPRedirect{
    51  		L3Protocol:  l3Proto,
    52  		TxInterface: txIf,
    53  	})
    54  }
    55  
    56  // ToHostKey returns key representing punt to host/socket configuration.
    57  func ToHostKey(l3Proto L3Protocol, l4Proto L4Protocol, port uint32) string {
    58  	return models.Key(&ToHost{
    59  		L3Protocol: l3Proto,
    60  		L4Protocol: l4Proto,
    61  		Port:       port,
    62  	})
    63  }
    64  
    65  func ExceptionKey(reason string) string {
    66  	return models.Key(&Exception{
    67  		Reason: reason,
    68  	})
    69  }