zeek/src/analyzer/protocol/udp/UDP.h
Tim Wojtulewicz 485d9d5458 Mark the majority of the analyzer classes as final, where appropriate.
Most of these came from use of the -Wsuggest-final-types flag for gcc.
2020-04-03 18:44:09 -04:00

54 lines
1.4 KiB
C++

// See the file "COPYING" in the main distribution directory for copyright.
#pragma once
#include "analyzer/Analyzer.h"
#include <netinet/udp.h>
namespace analyzer { namespace udp {
typedef enum {
UDP_INACTIVE, // no packet seen
UDP_ACTIVE, // packets seen
} UDP_EndpointState;
class UDP_Analyzer final : public analyzer::TransportLayerAnalyzer {
public:
explicit UDP_Analyzer(Connection* conn);
~UDP_Analyzer() override;
void Init() override;
void UpdateConnVal(RecordVal *conn_val) override;
static analyzer::Analyzer* Instantiate(Connection* conn)
{ return new UDP_Analyzer(conn); }
protected:
void Done() override;
void DeliverPacket(int len, const u_char* data, bool orig,
uint64_t seq, const IP_Hdr* ip, int caplen) override;
bool IsReuse(double t, const u_char* pkt) override;
unsigned int MemoryAllocation() const override;
void ChecksumEvent(bool is_orig, uint32_t threshold);
// Returns true if the checksum is valid, false if not
static bool ValidateChecksum(const IP_Hdr* ip, const struct udphdr* up,
int len);
bro_int_t request_len, reply_len;
private:
void UpdateEndpointVal(RecordVal* endp, bool is_orig);
#define HIST_ORIG_DATA_PKT 0x1
#define HIST_RESP_DATA_PKT 0x2
#define HIST_ORIG_CORRUPT_PKT 0x4
#define HIST_RESP_CORRUPT_PKT 0x8
// For tracking checksum history.
uint32_t req_chk_cnt, req_chk_thresh;
uint32_t rep_chk_cnt, rep_chk_thresh;
};
} } // namespace analyzer::*