go.ligato.io/vpp-agent/v3@v3.5.0/plugins/vpp/ipfixplugin/vppcalls/vpp2210/dump_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 vpp2210 16 17 import ( 18 "fmt" 19 "net" 20 21 vpp_ipfix "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2210/ipfix_export" 22 ipfix "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/ipfix" 23 ) 24 25 // DumpExporters returns configured IPFIX. 26 // Since it always only one IPFIX configuration, this method signature 27 // defined as it is to keep consistensy between different vppcalls packages. 28 // 29 // Caution: VPP does not support IPv6 addresses for IPFIX configuration (tested 30 // with VPP 22.10), but this may change in future versions. Be careful porting 31 // this method to another version of VPP. 32 func (h *IpfixVppHandler) DumpExporters() ([]*ipfix.IPFIX, error) { 33 var ipfixes []*ipfix.IPFIX 34 reqCtx := h.callsChannel.SendMultiRequest(&vpp_ipfix.IpfixExporterDump{}) 35 for { 36 details := &vpp_ipfix.IpfixExporterDetails{} 37 stop, err := reqCtx.ReceiveReply(details) 38 if stop { 39 break 40 } 41 if err != nil { 42 return nil, fmt.Errorf("failed to dump IPFIX: %v", err) 43 } 44 45 collectorIPAddr := details.CollectorAddress.Un.GetIP4() 46 sourceIPAddr := details.SrcAddress.Un.GetIP4() 47 48 ipfixes = append(ipfixes, 49 &ipfix.IPFIX{ 50 Collector: &ipfix.IPFIX_Collector{ 51 Address: net.IP(collectorIPAddr[:]).To4().String(), 52 Port: uint32(details.CollectorPort), 53 }, 54 SourceAddress: net.IP(sourceIPAddr[:]).To4().String(), 55 VrfId: details.VrfID, 56 PathMtu: details.PathMtu, 57 TemplateInterval: details.TemplateInterval, 58 }, 59 ) 60 61 } 62 63 return ipfixes, nil 64 }