Move MMDB logic out of mmdb.bif and into MMDB.cc/h.

This does not change the implementation except for some light renaming where
things are now naturally scoped within MMDB.cc.
This commit is contained in:
Christian Kreibich 2024-01-09 21:18:35 -08:00
parent 20841ac689
commit a06053ce75
4 changed files with 456 additions and 494 deletions

38
src/MMDB.h Normal file
View file

@ -0,0 +1,38 @@
// See the file "COPYING" in the main distribution directory for copyright.
#pragma once
#include "zeek/Val.h"
namespace zeek {
#ifdef USE_GEOIP
#include <maxminddb.h>
class MMDB {
public:
MMDB(const char* filename, struct stat info);
~MMDB();
MMDB_lookup_result_s Lookup(const struct sockaddr* const sa);
bool StaleDB();
const char* Filename();
private:
MMDB_s mmdb;
struct stat file_info;
bool lookup_error;
double last_check;
};
#endif // USE_GEOIP
ValPtr mmdb_open_location_db(zeek::StringVal* filename);
ValPtr mmdb_open_asn_db(zeek::StringVal* filename);
RecordValPtr mmdb_lookup_location(zeek::AddrVal* addr);
RecordValPtr mmdb_lookup_autonomous_system(zeek::AddrVal* addr);
} // namespace zeek