Skip to content

Commit 7f7e8c1

Browse files
Merge pull request #72 from Tomas-Vrana/field_classifier_dev
Field classifier dev: enabling std::byte fields to be copied to output
2 parents 80f3fb3 + 0e8ae12 commit 7f7e8c1

3 files changed

Lines changed: 9 additions & 11 deletions

File tree

modules/fieldClassifier/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ module takes the following parameters:
8282
* Specify if the geolocation should be done for source, destination or both IP addresses. Possible
8383
values are `src`, `dst` or `both`. Default is `both`.
8484

85+
* `-c`, `--cacheCapacity` number
86+
87+
* Specify the capacity of the internal cache (number of entries). Default is `4000`.
88+
8589
## Geolite parameters
8690

8791
* `--pathGeolite` path

modules/fieldClassifier/src/fieldClassifier.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
#include "plugins/plugin.hpp"
1313
#include <stdexcept>
1414

15-
extern int g_debug_level;
16-
1715
namespace NFieldClassifier {
1816
void FieldClassifier::handleParams(int argc, char** argv, argparse::ArgumentParser& parser)
1917
{
@@ -412,13 +410,9 @@ void FieldClassifier::fillInputFieldsToOutput(
412410
break;
413411
}
414412
case DataType::BYTES: {
415-
// Nemea::UnirecArray<std::byte> const arr
416-
// = input->getFieldAsUnirecArray<std::byte>(fieldId);
417-
// output->setFieldFromUnirecArray<std::byte>(arr, fieldId);
418-
419-
// std::byte value = input->getFieldAsType<std::byte>(fieldId);
420-
// output->setFieldFromType<std::byte>(value, fieldId);
421-
413+
Nemea::UnirecArray<std::byte> const arr
414+
= input->getFieldAsUnirecArray<std::byte>(fieldId);
415+
output->setFieldFromUnirecArray<std::byte>(arr, fieldId);
422416
break;
423417
}
424418
case DataType::A_INT8: {

modules/fieldClassifier/src/plugins/asn.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ void ASN::storeParameters(argparse::ArgumentParser& parser)
3030
FieldDefinition ASN::defineFields()
3131
{
3232
// list of all fields provided by this plugin
33-
FieldDefinition allFields = {{"ASN", DataType::UINT16}, {"ASO", DataType::STRING}};
33+
FieldDefinition allFields = {{"ASN", DataType::UINT32}, {"ASO", DataType::STRING}};
3434

3535
return allFields;
3636
}
@@ -53,7 +53,7 @@ bool ASN::getData(DataMap& dataMap, std::string& ipAddr)
5353
}
5454
if (dataMap.find("ASN") != dataMap.end()) {
5555
err = MMDB_get_value(&result.entry, &entryData, "autonomous_system_number", NULL);
56-
dataMap.at("ASN") = checkEntryData() ? entryData.uint16 : EMPTY_UINT16;
56+
dataMap.at("ASN") = checkEntryData() ? entryData.uint32 : EMPTY_UINT16;
5757
}
5858
if (dataMap.find("ASO") != dataMap.end()) {
5959
err = MMDB_get_value(&result.entry, &entryData, "autonomous_system_organization", NULL);

0 commit comments

Comments
 (0)