Skip to content

Commit

Permalink
Moved Netflow timeout to external header file as we use it for IPFIX
Browse files Browse the repository at this point in the history
  • Loading branch information
pavel-odintsov committed Jan 13, 2025
1 parent f914ba7 commit 4e710fd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 41 deletions.
44 changes: 18 additions & 26 deletions src/netflow_plugin/netflow.hpp
Original file line number Diff line number Diff line change
@@ -1,37 +1,14 @@
// ISC license header

/*
* Copyright (c) 2004,2005 Damien Miller <[email protected]>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

// Netflow packet definitions

#pragma once

#include <string>
#include <cstdint>
#include <optional>
#include <string>

enum class netflow_protocol_version_t { netflow_v5, netflow_v9, ipfix };

/*
* These are Cisco Netflow(tm) packet formats
* Based on:
* http://www.cisco.com/univercd/cc/td/doc/product/rtrmgmt/nfc/nfc_3_0/nfc_ug/nfcform.htm
*/

/* Common header fields */
// Common header fields
class __attribute__((__packed__)) netflow_header_common_t {
public:
uint16_t version = 0;
Expand All @@ -44,3 +21,18 @@ class interface_id_to_name_t {
uint32_t interface_id = 0;
std::string interface_description{};
};

// Active timeout for IPFIX
class device_timeouts_t {
public:
// Both values use seconds
std::optional<uint32_t> active_timeout = 0;
std::optional<uint32_t> inactive_timeout = 0;

bool operator!=(const device_timeouts_t& rhs) const {
return !(*this == rhs);
}

// We generate default == operator which compares each field in class using standard compare operators for each class
bool operator==(const device_timeouts_t& rhs) const = default;
};
15 changes: 0 additions & 15 deletions src/netflow_plugin/netflow_collector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,21 +63,6 @@ std::map<std::string, uint32_t> netflow9_sampling_rates;
std::mutex ipfix_sampling_rates_mutex;
std::map<std::string, uint32_t> ipfix_sampling_rates;

// Active timeout for IPFIX
class device_timeouts_t {
public:
// Both values use seconds
std::optional<uint32_t> active_timeout = 0;
std::optional<uint32_t> inactive_timeout = 0;

bool operator!=(const device_timeouts_t& rhs) const {
return !(*this == rhs);
}

// We generate default == operator which compares each field in class using standard compare operators for each class
bool operator==(const device_timeouts_t& rhs) const = default;
};

// Variable encoding may be single or two byte and we need to distinguish them explicitly
enum class variable_length_encoding_t { unknown, single_byte, two_byte };

Expand Down

0 comments on commit 4e710fd

Please sign in to comment.