go.ligato.io/vpp-agent/v3@v3.5.0/plugins/vpp/ipfixplugin/vppcalls/vpp2106/dump_vppcalls.go (about) 1 // Copyright (c) 2021 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 vpp2106 16 17 import ( 18 "fmt" 19 "net" 20 21 vpp_ipfix "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2106/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 21.06 does not support IPv6 addresses for IPFIX configuration, 30 // but this may change in future versions. Be careful porting this method to 31 // another version of VPP. 32 // 33 func (h *IpfixVppHandler) DumpExporters() ([]*ipfix.IPFIX, error) { 34 var ipfixes []*ipfix.IPFIX 35 reqCtx := h.callsChannel.SendMultiRequest(&vpp_ipfix.IpfixExporterDump{}) 36 for { 37 details := &vpp_ipfix.IpfixExporterDetails{} 38 stop, err := reqCtx.ReceiveReply(details) 39 if stop { 40 break 41 } 42 if err != nil { 43 return nil, fmt.Errorf("failed to dump IPFIX: %v", err) 44 } 45 46 collectorIPAddr := details.CollectorAddress.Un.GetIP4() 47 sourceIPAddr := details.SrcAddress.Un.GetIP4() 48 49 ipfixes = append(ipfixes, 50 &ipfix.IPFIX{ 51 Collector: &ipfix.IPFIX_Collector{ 52 Address: net.IP(collectorIPAddr[:]).To4().String(), 53 Port: uint32(details.CollectorPort), 54 }, 55 SourceAddress: net.IP(sourceIPAddr[:]).To4().String(), 56 VrfId: details.VrfID, 57 PathMtu: details.PathMtu, 58 TemplateInterval: details.TemplateInterval, 59 }, 60 ) 61 62 } 63 64 return ipfixes, nil 65 }