Deprecate the internal int/uint types in favor of the cstdint types they were based on

This commit is contained in:
Tim Wojtulewicz 2019-07-30 11:38:42 -07:00
parent 18e4976c6c
commit 54752ef9a1
218 changed files with 1331 additions and 1323 deletions

View file

@ -12,16 +12,16 @@
AnonymizeIPAddr* ip_anonymizer[NUM_ADDR_ANONYMIZATION_METHODS] = {0};
static uint32 rand32()
static uint32_t rand32()
{
return ((bro_random() & 0xffff) << 16) | (bro_random() & 0xffff);
}
// From tcpdpriv.
int bi_ffs(uint32 value)
int bi_ffs(uint32_t value)
{
int add = 0;
static uint8 bvals[] = {
static uint8_t bvals[] = {
0, 4, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1
};
@ -88,7 +88,7 @@ ipaddr32_t AnonymizeIPAddr_Seq::anonymize(ipaddr32_t /* input */)
ipaddr32_t AnonymizeIPAddr_RandomMD5::anonymize(ipaddr32_t input)
{
uint8 digest[16];
uint8_t digest[16];
ipaddr32_t output = 0;
hmac_md5(sizeof(input), (u_char*)(&input), digest);
@ -107,7 +107,7 @@ ipaddr32_t AnonymizeIPAddr_RandomMD5::anonymize(ipaddr32_t input)
ipaddr32_t AnonymizeIPAddr_PrefixMD5::anonymize(ipaddr32_t input)
{
uint8 digest[16];
uint8_t digest[16];
ipaddr32_t prefix_mask = 0xffffffff;
input = ntohl(input);
ipaddr32_t output = input;
@ -179,8 +179,8 @@ int AnonymizeIPAddr_A50::PreservePrefix(ipaddr32_t input, int num_bits)
else if ( num_bits > 0 )
{
assert((0xFFFFFFFFU >> 1) == 0x7FFFFFFFU);
uint32 suffix_mask = (0xFFFFFFFFU >> num_bits);
uint32 prefix_mask = ~suffix_mask;
uint32_t suffix_mask = (0xFFFFFFFFU >> num_bits);
uint32_t prefix_mask = ~suffix_mask;
n->output = (input & prefix_mask) | (rand32() & suffix_mask);
}

View file

@ -37,7 +37,7 @@ enum ip_addr_anonymization_method_t {
NUM_ADDR_ANONYMIZATION_METHODS,
};
typedef uint32 ipaddr32_t;
typedef uint32_t ipaddr32_t;
// NOTE: all addresses in parameters of *public* functions are in
// network order.

View file

@ -153,7 +153,7 @@ int Base64Converter::Decode(int len, const char* data, int* pblen, char** pbuf)
if ( buf + num_octets > *pbuf + blen )
break;
uint32 bit32 =
uint32_t bit32 =
((base64_group[0] & 0x3f) << 18) |
((base64_group[1] & 0x3f) << 12) |
((base64_group[2] & 0x3f) << 6) |

View file

@ -37,7 +37,7 @@ bool Brofiler::ReadStats()
string location(strtok(0, delimiter.c_str()));
string desc(strtok(0, delimiter.c_str()));
pair<string, string> location_desc(location, desc);
uint64 count;
uint64_t count;
atoi_n(cnt.size(), cnt.c_str(), 0, 10, count);
usage_map[location_desc] = count;
}
@ -104,7 +104,7 @@ bool Brofiler::WriteStats()
usage_map[location_desc] = (*it)->GetAccessCount();
}
map<pair<string, string>, uint64 >::const_iterator it;
map<pair<string, string>, uint64_t >::const_iterator it;
for ( it = usage_map.begin(); it != usage_map.end(); ++it )
{
fprintf(f, "%" PRIu64"%c%s%c%s\n", it->second, delim,

View file

@ -59,7 +59,7 @@ private:
* startup time and modified at shutdown time before writing back
* to a file.
*/
map<pair<string, string>, uint64> usage_map;
map<pair<string, string>, uint64_t> usage_map;
/**
* The character to use to delimit Brofiler output files. Default is '\t'.

View file

@ -111,7 +111,7 @@ char* CompositeHash::SingleValHash(int type_check, char* kp0,
case TYPE_INTERNAL_ADDR:
{
uint32* kp = AlignAndPadType<uint32>(kp0);
uint32_t* kp = AlignAndPadType<uint32_t>(kp0);
v->AsAddr().CopyIPv6(kp);
kp1 = reinterpret_cast<char*>(kp+4);
}
@ -119,7 +119,7 @@ char* CompositeHash::SingleValHash(int type_check, char* kp0,
case TYPE_INTERNAL_SUBNET:
{
uint32* kp = AlignAndPadType<uint32>(kp0);
uint32_t* kp = AlignAndPadType<uint32_t>(kp0);
v->AsSubNet().Prefix().CopyIPv6(kp);
kp[4] = v->AsSubNet().Length();
kp1 = reinterpret_cast<char*>(kp+5);
@ -140,7 +140,7 @@ char* CompositeHash::SingleValHash(int type_check, char* kp0,
switch ( v->Type()->Tag() ) {
case TYPE_FUNC:
{
uint32* kp = AlignAndPadType<uint32>(kp0);
uint32_t* kp = AlignAndPadType<uint32_t>(kp0);
*kp = v->AsFunc()->GetUniqueFuncID();
kp1 = reinterpret_cast<char*>(kp+1);
break;
@ -439,13 +439,13 @@ int CompositeHash::SingleTypeKeySize(BroType* bt, const Val* v,
break;
case TYPE_INTERNAL_ADDR:
sz = SizeAlign(sz, sizeof(uint32));
sz += sizeof(uint32) * 3; // to make a total of 4 words
sz = SizeAlign(sz, sizeof(uint32_t));
sz += sizeof(uint32_t) * 3; // to make a total of 4 words
break;
case TYPE_INTERNAL_SUBNET:
sz = SizeAlign(sz, sizeof(uint32));
sz += sizeof(uint32) * 4; // to make a total of 5 words
sz = SizeAlign(sz, sizeof(uint32_t));
sz += sizeof(uint32_t) * 4; // to make a total of 5 words
break;
case TYPE_INTERNAL_DOUBLE:
@ -458,7 +458,7 @@ int CompositeHash::SingleTypeKeySize(BroType* bt, const Val* v,
switch ( bt->Tag() ) {
case TYPE_FUNC:
{
sz = SizeAlign(sz, sizeof(uint32));
sz = SizeAlign(sz, sizeof(uint32_t));
break;
}
@ -770,7 +770,7 @@ const char* CompositeHash::RecoverOneVal(const HashKey* k, const char* kp0,
case TYPE_INTERNAL_ADDR:
{
const uint32* const kp = AlignType<uint32>(kp0);
const uint32_t* const kp = AlignType<uint32_t>(kp0);
kp1 = reinterpret_cast<const char*>(kp+4);
IPAddr addr(IPv6, kp, IPAddr::Network);
@ -790,7 +790,7 @@ const char* CompositeHash::RecoverOneVal(const HashKey* k, const char* kp0,
case TYPE_INTERNAL_SUBNET:
{
const uint32* const kp = AlignType<uint32>(kp0);
const uint32_t* const kp = AlignType<uint32_t>(kp0);
kp1 = reinterpret_cast<const char*>(kp+5);
pval = new SubNetVal(kp, kp[4]);
}
@ -802,7 +802,7 @@ const char* CompositeHash::RecoverOneVal(const HashKey* k, const char* kp0,
switch ( t->Tag() ) {
case TYPE_FUNC:
{
const uint32* const kp = AlignType<uint32>(kp0);
const uint32_t* const kp = AlignType<uint32_t>(kp0);
kp1 = reinterpret_cast<const char*>(kp+1);
Func* f = Func::GetFuncPtrByID(*kp);

View file

@ -50,12 +50,12 @@ void ConnectionTimer::Dispatch(double t, int is_expire)
reporter->InternalError("reference count inconsistency in ConnectionTimer::Dispatch");
}
uint64 Connection::total_connections = 0;
uint64 Connection::current_connections = 0;
uint64 Connection::external_connections = 0;
uint64_t Connection::total_connections = 0;
uint64_t Connection::current_connections = 0;
uint64_t Connection::external_connections = 0;
Connection::Connection(NetSessions* s, HashKey* k, double t, const ConnID* id,
uint32 flow, const Packet* pkt,
uint32_t flow, const Packet* pkt,
const EncapsulationStack* arg_encap)
{
sessions = s;
@ -228,9 +228,9 @@ bool Connection::IsReuse(double t, const u_char* pkt)
return root_analyzer && root_analyzer->IsReuse(t, pkt);
}
bool Connection::ScaledHistoryEntry(char code, uint32& counter,
uint32& scaling_threshold,
uint32 scaling_base)
bool Connection::ScaledHistoryEntry(char code, uint32_t& counter,
uint32_t& scaling_threshold,
uint32_t scaling_base)
{
if ( ++counter == scaling_threshold )
{
@ -254,7 +254,7 @@ bool Connection::ScaledHistoryEntry(char code, uint32& counter,
}
void Connection::HistoryThresholdEvent(EventHandlerPtr e, bool is_orig,
uint32 threshold)
uint32_t threshold)
{
if ( ! e )
return;
@ -568,7 +568,7 @@ void Connection::FlipRoles()
resp_addr = orig_addr;
orig_addr = tmp_addr;
uint32 tmp_port = resp_port;
uint32_t tmp_port = resp_port;
resp_port = orig_port;
orig_port = tmp_port;
@ -582,7 +582,7 @@ void Connection::FlipRoles()
saw_first_resp_packet = saw_first_orig_packet;
saw_first_orig_packet = tmp_bool;
uint32 tmp_flow = resp_flow_label;
uint32_t tmp_flow = resp_flow_label;
resp_flow_label = orig_flow_label;
orig_flow_label = tmp_flow;
@ -678,9 +678,9 @@ void Connection::SetRootAnalyzer(analyzer::TransportLayerAnalyzer* analyzer, ana
primary_PIA = pia;
}
void Connection::CheckFlowLabel(bool is_orig, uint32 flow_label)
void Connection::CheckFlowLabel(bool is_orig, uint32_t flow_label)
{
uint32& my_flow_label = is_orig ? orig_flow_label : resp_flow_label;
uint32_t& my_flow_label = is_orig ? orig_flow_label : resp_flow_label;
if ( my_flow_label != flow_label )
{
@ -710,7 +710,7 @@ void Connection::CheckFlowLabel(bool is_orig, uint32 flow_label)
saw_first_resp_packet = 1;
}
bool Connection::PermitWeird(const char* name, uint64 threshold, uint64 rate,
bool Connection::PermitWeird(const char* name, uint64_t threshold, uint64_t rate,
double duration)
{
return ::PermitWeird(weird_state, name, threshold, rate, duration);

View file

@ -42,13 +42,13 @@ typedef void (Connection::*timer_func)(double t);
struct ConnID {
IPAddr src_addr;
IPAddr dst_addr;
uint32 src_port;
uint32 dst_port;
uint32_t src_port;
uint32_t dst_port;
bool is_one_way; // if true, don't canonicalize order
};
static inline int addr_port_canon_lt(const IPAddr& addr1, uint32 p1,
const IPAddr& addr2, uint32 p2)
static inline int addr_port_canon_lt(const IPAddr& addr1, uint32_t p1,
const IPAddr& addr2, uint32_t p2)
{
return addr1 < addr2 || (addr1 == addr2 && p1 < p2);
}
@ -58,7 +58,7 @@ namespace analyzer { class Analyzer; }
class Connection : public BroObj {
public:
Connection(NetSessions* s, HashKey* k, double t, const ConnID* id,
uint32 flow, const Packet* pkt, const EncapsulationStack* arg_encap);
uint32_t flow, const Packet* pkt, const EncapsulationStack* arg_encap);
~Connection() override;
// Invoked when an encapsulation is discovered. It records the
@ -101,8 +101,8 @@ public:
const IPAddr& OrigAddr() const { return orig_addr; }
const IPAddr& RespAddr() const { return resp_addr; }
uint32 OrigPort() const { return orig_port; }
uint32 RespPort() const { return resp_port; }
uint32_t OrigPort() const { return orig_port; }
uint32_t RespPort() const { return resp_port; }
void FlipRoles();
@ -228,15 +228,15 @@ public:
unsigned int MemoryAllocation() const;
unsigned int MemoryAllocationConnVal() const;
static uint64 TotalConnections()
static uint64_t TotalConnections()
{ return total_connections; }
static uint64 CurrentConnections()
static uint64_t CurrentConnections()
{ return current_connections; }
static uint64 CurrentExternalConnections()
static uint64_t CurrentExternalConnections()
{ return external_connections; }
// Returns true if the history was already seen, false otherwise.
int CheckHistory(uint32 mask, char code)
int CheckHistory(uint32_t mask, char code)
{
if ( (hist_seen & mask) == 0 )
{
@ -252,12 +252,12 @@ public:
// code if it has crossed the next scaling threshold. Scaling
// is done in terms of powers of the third argument.
// Returns true if the threshold was crossed, false otherwise.
bool ScaledHistoryEntry(char code, uint32& counter,
uint32& scaling_threshold,
uint32 scaling_base = 10);
bool ScaledHistoryEntry(char code, uint32_t& counter,
uint32_t& scaling_threshold,
uint32_t scaling_base = 10);
void HistoryThresholdEvent(EventHandlerPtr e, bool is_orig,
uint32 threshold);
uint32_t threshold);
void AddHistory(char code) { history += code; }
@ -278,12 +278,12 @@ public:
const EncapsulationStack* GetEncapsulation() const
{ return encapsulation; }
void CheckFlowLabel(bool is_orig, uint32 flow_label);
void CheckFlowLabel(bool is_orig, uint32_t flow_label);
uint32 GetOrigFlowLabel() { return orig_flow_label; }
uint32 GetRespFlowLabel() { return resp_flow_label; }
uint32_t GetOrigFlowLabel() { return orig_flow_label; }
uint32_t GetRespFlowLabel() { return resp_flow_label; }
bool PermitWeird(const char* name, uint64 threshold, uint64 rate,
bool PermitWeird(const char* name, uint64_t threshold, uint64_t rate,
double duration);
protected:
@ -314,10 +314,10 @@ protected:
IPAddr orig_addr;
IPAddr resp_addr;
uint32 orig_port, resp_port; // in network order
uint32_t orig_port, resp_port; // in network order
TransportProto proto;
uint32 orig_flow_label, resp_flow_label; // most recent IPv6 flow labels
uint32 vlan, inner_vlan; // VLAN this connection traverses, if available
uint32_t orig_flow_label, resp_flow_label; // most recent IPv6 flow labels
uint32_t vlan, inner_vlan; // VLAN this connection traverses, if available
u_char orig_l2_addr[Packet::l2_addr_len]; // Link-layer originator address, if available
u_char resp_l2_addr[Packet::l2_addr_len]; // Link-layer responder address, if available
double start_time, last_time;
@ -338,12 +338,12 @@ protected:
unsigned int saw_first_orig_packet:1, saw_first_resp_packet:1;
// Count number of connections.
static uint64 total_connections;
static uint64 current_connections;
static uint64 external_connections;
static uint64_t total_connections;
static uint64_t current_connections;
static uint64_t external_connections;
string history;
uint32 hist_seen;
uint32_t hist_seen;
analyzer::TransportLayerAnalyzer* root_analyzer;
analyzer::pia::PIA* primary_PIA;

View file

@ -89,7 +89,7 @@ int DNS_Mgr_Request::MakeRequest(nb_dns_info* nb_dns)
return nb_dns_host_request2(nb_dns, host, fam, qtype, (void*) this, err) >= 0;
else
{
const uint32* bytes;
const uint32_t* bytes;
int len = addr.GetBytes(&bytes);
return nb_dns_addr_request2(nb_dns, (char*) bytes,
len == 1 ? AF_INET : AF_INET6, (void*) this, err) >= 0;
@ -98,8 +98,8 @@ int DNS_Mgr_Request::MakeRequest(nb_dns_info* nb_dns)
class DNS_Mapping {
public:
DNS_Mapping(const char* host, struct hostent* h, uint32 ttl);
DNS_Mapping(const IPAddr& addr, struct hostent* h, uint32 ttl);
DNS_Mapping(const char* host, struct hostent* h, uint32_t ttl);
DNS_Mapping(const IPAddr& addr, struct hostent* h, uint32_t ttl);
DNS_Mapping(FILE* f);
int NoMapping() const { return no_mapping; }
@ -147,7 +147,7 @@ protected:
char* req_host;
IPAddr req_addr;
uint32 req_ttl;
uint32_t req_ttl;
int num_names;
char** names;
@ -176,7 +176,7 @@ static TableVal* empty_addr_set()
return new TableVal(s);
}
DNS_Mapping::DNS_Mapping(const char* host, struct hostent* h, uint32 ttl)
DNS_Mapping::DNS_Mapping(const char* host, struct hostent* h, uint32_t ttl)
{
Init(h);
req_host = copy_string(host);
@ -186,7 +186,7 @@ DNS_Mapping::DNS_Mapping(const char* host, struct hostent* h, uint32 ttl)
names[0] = copy_string(host);
}
DNS_Mapping::DNS_Mapping(const IPAddr& addr, struct hostent* h, uint32 ttl)
DNS_Mapping::DNS_Mapping(const IPAddr& addr, struct hostent* h, uint32_t ttl)
{
Init(h);
req_addr = addr;
@ -337,10 +337,10 @@ void DNS_Mapping::Init(struct hostent* h)
addrs = new IPAddr[num_addrs];
for ( int i = 0; i < num_addrs; ++i )
if ( h->h_addrtype == AF_INET )
addrs[i] = IPAddr(IPv4, (uint32*)h->h_addr_list[i],
addrs[i] = IPAddr(IPv4, (uint32_t*)h->h_addr_list[i],
IPAddr::Network);
else if ( h->h_addrtype == AF_INET6 )
addrs[i] = IPAddr(IPv6, (uint32*)h->h_addr_list[i],
addrs[i] = IPAddr(IPv6, (uint32_t*)h->h_addr_list[i],
IPAddr::Network);
}
else
@ -473,7 +473,7 @@ void DNS_Mgr::InitPostScript()
static TableVal* fake_name_lookup_result(const char* name)
{
uint32 hash[4];
uint32_t hash[4];
internal_md5(reinterpret_cast<const u_char*>(name), strlen(name),
reinterpret_cast<u_char*>(hash));
ListVal* hv = new ListVal(TYPE_ADDR);

View file

@ -111,7 +111,7 @@ void ODesc::Add(int i)
}
}
void ODesc::Add(uint32 u)
void ODesc::Add(uint32_t u)
{
if ( IsBinary() )
AddBytes(&u, sizeof(u));
@ -123,7 +123,7 @@ void ODesc::Add(uint32 u)
}
}
void ODesc::Add(int64 i)
void ODesc::Add(int64_t i)
{
if ( IsBinary() )
AddBytes(&i, sizeof(i));
@ -135,7 +135,7 @@ void ODesc::Add(int64 i)
}
}
void ODesc::Add(uint64 u)
void ODesc::Add(uint64_t u)
{
if ( IsBinary() )
AddBytes(&u, sizeof(u));

View file

@ -79,9 +79,9 @@ public:
void AddN(const char* s, int len) { AddBytes(s, len); }
void Add(const string& s) { AddBytes(s.data(), s.size()); }
void Add(int i);
void Add(uint32 u);
void Add(int64 i);
void Add(uint64 u);
void Add(uint32_t u);
void Add(int64_t i);
void Add(uint64_t u);
void Add(double d, bool no_exp=false);
void Add(const IPAddr& addr);
void Add(const IPPrefix& prefix);

View file

@ -65,7 +65,7 @@ public:
}
// Total number of entries ever.
uint64 NumCumulativeInserts() const
uint64_t NumCumulativeInserts() const
{
return cumulative_entries;
}
@ -163,7 +163,7 @@ private:
int num_buckets;
int num_entries;
int max_num_entries;
uint64 cumulative_entries;
uint64_t cumulative_entries;
double den_thresh;
int thresh_entries;

View file

@ -10,8 +10,8 @@
EventMgr mgr;
uint64 num_events_queued = 0;
uint64 num_events_dispatched = 0;
uint64_t num_events_queued = 0;
uint64_t num_events_dispatched = 0;
Event::Event(EventHandlerPtr arg_handler, val_list arg_args,
SourceID arg_src, analyzer::ID arg_aid, TimerMgr* arg_mgr,

View file

@ -49,8 +49,8 @@ protected:
Event* next_event;
};
extern uint64 num_events_queued;
extern uint64 num_events_dispatched;
extern uint64_t num_events_queued;
extern uint64_t num_events_dispatched;
class EventMgr : public BroObj {
public:

View file

@ -1469,11 +1469,11 @@ DivideExpr::DivideExpr(Expr* arg_op1, Expr* arg_op2)
Val* DivideExpr::AddrFold(Val* v1, Val* v2) const
{
uint32 mask;
uint32_t mask;
if ( v2->Type()->Tag() == TYPE_COUNT )
mask = static_cast<uint32>(v2->InternalUnsigned());
mask = static_cast<uint32_t>(v2->InternalUnsigned());
else
mask = static_cast<uint32>(v2->InternalInt());
mask = static_cast<uint32_t>(v2->InternalInt());
auto& a = v1->AsAddr();

View file

@ -97,9 +97,9 @@ void FragReassembler::AddFragment(double t, const IP_Hdr* ip, const u_char* pkt)
// Linux MTU discovery for UDP can do this, for example.
s->Weird("fragment_with_DF", ip);
uint16 offset = ip->FragOffset();
uint32 len = ip->TotalLen();
uint16 hdr_len = ip->HdrLen();
uint16_t offset = ip->FragOffset();
uint32_t len = ip->TotalLen();
uint16_t hdr_len = ip->HdrLen();
if ( len < hdr_len )
{
@ -107,7 +107,7 @@ void FragReassembler::AddFragment(double t, const IP_Hdr* ip, const u_char* pkt)
return;
}
uint64 upper_seq = offset + len - hdr_len;
uint64_t upper_seq = offset + len - hdr_len;
if ( ! offset )
// Make sure to use the first fragment header's next field.
@ -178,7 +178,7 @@ void FragReassembler::Weird(const char* name) const
}
}
void FragReassembler::Overlap(const u_char* b1, const u_char* b2, uint64 n)
void FragReassembler::Overlap(const u_char* b1, const u_char* b2, uint64_t n)
{
if ( memcmp((const void*) b1, (const void*) b2, n) )
Weird("fragment_inconsistency");
@ -231,7 +231,7 @@ void FragReassembler::BlockInserted(DataBlock* /* start_block */)
return;
// We have it all. Compute the expected size of the fragment.
uint64 n = proto_hdr_len + frag_size;
uint64_t n = proto_hdr_len + frag_size;
// It's possible that we have blocks associated with this fragment
// that exceed this size, if we saw MF fragments (which don't lead

View file

@ -34,15 +34,15 @@ public:
protected:
void BlockInserted(DataBlock* start_block) override;
void Overlap(const u_char* b1, const u_char* b2, uint64 n) override;
void Overlap(const u_char* b1, const u_char* b2, uint64_t n) override;
void Weird(const char* name) const;
u_char* proto_hdr;
IP_Hdr* reassembled_pkt;
uint16 proto_hdr_len;
uint16_t proto_hdr_len;
NetSessions* s;
uint64 frag_size; // size of fully reassembled fragment
uint16 next_proto; // first IPv6 fragment header's next proto field
uint64_t frag_size; // size of fully reassembled fragment
uint16_t next_proto; // first IPv6 fragment header's next proto field
HashKey* key;
FragTimer* expire_timer;

View file

@ -68,8 +68,8 @@ public:
virtual TraversalCode Traverse(TraversalCallback* cb) const;
uint32 GetUniqueFuncID() const { return unique_id; }
static Func* GetFuncPtrByID(uint32 id)
uint32_t GetUniqueFuncID() const { return unique_id; }
static Func* GetFuncPtrByID(uint32_t id)
{ return id >= unique_ids.size() ? 0 : unique_ids[id]; }
protected:
@ -86,7 +86,7 @@ protected:
Kind kind;
BroType* type;
string name;
uint32 unique_id;
uint32_t unique_id;
static vector<Func*> unique_ids;
};

View file

@ -47,7 +47,7 @@ HashKey::HashKey(bro_uint_t u)
is_our_dynamic = 0;
}
HashKey::HashKey(uint32 u)
HashKey::HashKey(uint32_t u)
{
key_u.u32 = u;
key = (void*) &key_u;
@ -56,7 +56,7 @@ HashKey::HashKey(uint32 u)
is_our_dynamic = 0;
}
HashKey::HashKey(const uint32 u[], int n)
HashKey::HashKey(const uint32_t u[], int n)
{
size = n * sizeof(u[0]);
key = (void*) u;
@ -173,7 +173,7 @@ hash_t HashKey::HashBytes(const void* bytes, int size)
// Fall back to HMAC/MD5 for longer data (which is usually rare).
assert(sizeof(hash_t) == 8);
hash_t digest[2]; // 2x hash_t (uint64) = 128 bits = 32 hex chars = sizeof md5
hash_t digest[2]; // 2x hash_t (uint64_t) = 128 bits = 32 hex chars = sizeof md5
hmac_md5(size, (const unsigned char*) bytes, (unsigned char*) digest);
return digest[0];
}

View file

@ -9,7 +9,7 @@
#define UHASH_KEY_SIZE 36
typedef uint64 hash_t;
typedef uint64_t hash_t;
typedef enum {
HASH_KEY_INT,
@ -22,8 +22,8 @@ class HashKey {
public:
explicit HashKey(bro_int_t i);
explicit HashKey(bro_uint_t u);
explicit HashKey(uint32 u);
HashKey(const uint32 u[], int n);
explicit HashKey(uint32_t u);
HashKey(const uint32_t u[], int n);
explicit HashKey(double d);
explicit HashKey(const void* p);
explicit HashKey(const char* s);
@ -74,7 +74,7 @@ protected:
union {
bro_int_t i;
uint32 u32;
uint32_t u32;
double d;
const void* p;
} key_u;

116
src/IP.cc
View file

@ -53,13 +53,13 @@ static VectorVal* BuildOptionsVal(const u_char* data, int len)
// Pad1 option
rv->Assign(1, val_mgr->GetCount(0));
rv->Assign(2, val_mgr->GetEmptyString());
data += sizeof(uint8);
len -= sizeof(uint8);
data += sizeof(uint8_t);
len -= sizeof(uint8_t);
}
else
{
// PadN or other option
uint16 off = 2 * sizeof(uint8);
uint16_t off = 2 * sizeof(uint8_t);
rv->Assign(1, val_mgr->GetCount(opt->ip6o_len));
rv->Assign(2, new StringVal(
new BroString(data + off, opt->ip6o_len, 1)));
@ -102,7 +102,7 @@ RecordVal* IPv6_Hdr::BuildRecordVal(VectorVal* chain) const
const struct ip6_hbh* hbh = (const struct ip6_hbh*)data;
rv->Assign(0, val_mgr->GetCount(hbh->ip6h_nxt));
rv->Assign(1, val_mgr->GetCount(hbh->ip6h_len));
uint16 off = 2 * sizeof(uint8);
uint16_t off = 2 * sizeof(uint8_t);
rv->Assign(2, BuildOptionsVal(data + off, Length() - off));
}
@ -114,7 +114,7 @@ RecordVal* IPv6_Hdr::BuildRecordVal(VectorVal* chain) const
const struct ip6_dest* dst = (const struct ip6_dest*)data;
rv->Assign(0, val_mgr->GetCount(dst->ip6d_nxt));
rv->Assign(1, val_mgr->GetCount(dst->ip6d_len));
uint16 off = 2 * sizeof(uint8);
uint16_t off = 2 * sizeof(uint8_t);
rv->Assign(2, BuildOptionsVal(data + off, Length() - off));
}
break;
@ -127,7 +127,7 @@ RecordVal* IPv6_Hdr::BuildRecordVal(VectorVal* chain) const
rv->Assign(1, val_mgr->GetCount(rt->ip6r_len));
rv->Assign(2, val_mgr->GetCount(rt->ip6r_type));
rv->Assign(3, val_mgr->GetCount(rt->ip6r_segleft));
uint16 off = 4 * sizeof(uint8);
uint16_t off = 4 * sizeof(uint8_t);
rv->Assign(4, new StringVal(new BroString(data + off, Length() - off, 1)));
}
break;
@ -150,15 +150,15 @@ RecordVal* IPv6_Hdr::BuildRecordVal(VectorVal* chain) const
rv = new RecordVal(hdrType(ip6_ah_type, "ip6_ah"));
rv->Assign(0, val_mgr->GetCount(((ip6_ext*)data)->ip6e_nxt));
rv->Assign(1, val_mgr->GetCount(((ip6_ext*)data)->ip6e_len));
rv->Assign(2, val_mgr->GetCount(ntohs(((uint16*)data)[1])));
rv->Assign(3, val_mgr->GetCount(ntohl(((uint32*)data)[1])));
rv->Assign(2, val_mgr->GetCount(ntohs(((uint16_t*)data)[1])));
rv->Assign(3, val_mgr->GetCount(ntohl(((uint32_t*)data)[1])));
if ( Length() >= 12 )
{
// Sequence Number and ICV fields can only be extracted if
// Payload Len was non-zero for this header.
rv->Assign(4, val_mgr->GetCount(ntohl(((uint32*)data)[2])));
uint16 off = 3 * sizeof(uint32);
rv->Assign(4, val_mgr->GetCount(ntohl(((uint32_t*)data)[2])));
uint16_t off = 3 * sizeof(uint32_t);
rv->Assign(5, new StringVal(new BroString(data + off, Length() - off, 1)));
}
}
@ -167,7 +167,7 @@ RecordVal* IPv6_Hdr::BuildRecordVal(VectorVal* chain) const
case IPPROTO_ESP:
{
rv = new RecordVal(hdrType(ip6_esp_type, "ip6_esp"));
const uint32* esp = (const uint32*)data;
const uint32_t* esp = (const uint32_t*)data;
rv->Assign(0, val_mgr->GetCount(ntohl(esp[0])));
rv->Assign(1, val_mgr->GetCount(ntohl(esp[1])));
}
@ -187,15 +187,15 @@ RecordVal* IPv6_Hdr::BuildRecordVal(VectorVal* chain) const
RecordVal* msg = new RecordVal(hdrType(ip6_mob_msg_type, "ip6_mobility_msg"));
msg->Assign(0, val_mgr->GetCount(mob->ip6mob_type));
uint16 off = sizeof(ip6_mobility);
uint16_t off = sizeof(ip6_mobility);
const u_char* msg_data = data + off;
switch ( mob->ip6mob_type ) {
case 0:
{
RecordVal* m = new RecordVal(hdrType(ip6_mob_brr_type, "ip6_mobility_brr"));
m->Assign(0, val_mgr->GetCount(ntohs(*((uint16*)msg_data))));
off += sizeof(uint16);
m->Assign(0, val_mgr->GetCount(ntohs(*((uint16_t*)msg_data))));
off += sizeof(uint16_t);
m->Assign(1, BuildOptionsVal(data + off, Length() - off));
msg->Assign(1, m);
}
@ -204,9 +204,9 @@ RecordVal* IPv6_Hdr::BuildRecordVal(VectorVal* chain) const
case 1:
{
RecordVal* m = new RecordVal(hdrType(ip6_mob_brr_type, "ip6_mobility_hoti"));
m->Assign(0, val_mgr->GetCount(ntohs(*((uint16*)msg_data))));
m->Assign(1, val_mgr->GetCount(ntohll(*((uint64*)(msg_data + sizeof(uint16))))));
off += sizeof(uint16) + sizeof(uint64);
m->Assign(0, val_mgr->GetCount(ntohs(*((uint16_t*)msg_data))));
m->Assign(1, val_mgr->GetCount(ntohll(*((uint64_t*)(msg_data + sizeof(uint16_t))))));
off += sizeof(uint16_t) + sizeof(uint64_t);
m->Assign(2, BuildOptionsVal(data + off, Length() - off));
msg->Assign(2, m);
break;
@ -215,9 +215,9 @@ RecordVal* IPv6_Hdr::BuildRecordVal(VectorVal* chain) const
case 2:
{
RecordVal* m = new RecordVal(hdrType(ip6_mob_brr_type, "ip6_mobility_coti"));
m->Assign(0, val_mgr->GetCount(ntohs(*((uint16*)msg_data))));
m->Assign(1, val_mgr->GetCount(ntohll(*((uint64*)(msg_data + sizeof(uint16))))));
off += sizeof(uint16) + sizeof(uint64);
m->Assign(0, val_mgr->GetCount(ntohs(*((uint16_t*)msg_data))));
m->Assign(1, val_mgr->GetCount(ntohll(*((uint64_t*)(msg_data + sizeof(uint16_t))))));
off += sizeof(uint16_t) + sizeof(uint64_t);
m->Assign(2, BuildOptionsVal(data + off, Length() - off));
msg->Assign(3, m);
break;
@ -226,10 +226,10 @@ RecordVal* IPv6_Hdr::BuildRecordVal(VectorVal* chain) const
case 3:
{
RecordVal* m = new RecordVal(hdrType(ip6_mob_brr_type, "ip6_mobility_hot"));
m->Assign(0, val_mgr->GetCount(ntohs(*((uint16*)msg_data))));
m->Assign(1, val_mgr->GetCount(ntohll(*((uint64*)(msg_data + sizeof(uint16))))));
m->Assign(2, val_mgr->GetCount(ntohll(*((uint64*)(msg_data + sizeof(uint16) + sizeof(uint64))))));
off += sizeof(uint16) + 2 * sizeof(uint64);
m->Assign(0, val_mgr->GetCount(ntohs(*((uint16_t*)msg_data))));
m->Assign(1, val_mgr->GetCount(ntohll(*((uint64_t*)(msg_data + sizeof(uint16_t))))));
m->Assign(2, val_mgr->GetCount(ntohll(*((uint64_t*)(msg_data + sizeof(uint16_t) + sizeof(uint64_t))))));
off += sizeof(uint16_t) + 2 * sizeof(uint64_t);
m->Assign(3, BuildOptionsVal(data + off, Length() - off));
msg->Assign(4, m);
break;
@ -238,10 +238,10 @@ RecordVal* IPv6_Hdr::BuildRecordVal(VectorVal* chain) const
case 4:
{
RecordVal* m = new RecordVal(hdrType(ip6_mob_brr_type, "ip6_mobility_cot"));
m->Assign(0, val_mgr->GetCount(ntohs(*((uint16*)msg_data))));
m->Assign(1, val_mgr->GetCount(ntohll(*((uint64*)(msg_data + sizeof(uint16))))));
m->Assign(2, val_mgr->GetCount(ntohll(*((uint64*)(msg_data + sizeof(uint16) + sizeof(uint64))))));
off += sizeof(uint16) + 2 * sizeof(uint64);
m->Assign(0, val_mgr->GetCount(ntohs(*((uint16_t*)msg_data))));
m->Assign(1, val_mgr->GetCount(ntohll(*((uint64_t*)(msg_data + sizeof(uint16_t))))));
m->Assign(2, val_mgr->GetCount(ntohll(*((uint64_t*)(msg_data + sizeof(uint16_t) + sizeof(uint64_t))))));
off += sizeof(uint16_t) + 2 * sizeof(uint64_t);
m->Assign(3, BuildOptionsVal(data + off, Length() - off));
msg->Assign(5, m);
break;
@ -250,13 +250,13 @@ RecordVal* IPv6_Hdr::BuildRecordVal(VectorVal* chain) const
case 5:
{
RecordVal* m = new RecordVal(hdrType(ip6_mob_brr_type, "ip6_mobility_bu"));
m->Assign(0, val_mgr->GetCount(ntohs(*((uint16*)msg_data))));
m->Assign(1, val_mgr->GetBool(ntohs(*((uint16*)(msg_data + sizeof(uint16)))) & 0x8000));
m->Assign(2, val_mgr->GetBool(ntohs(*((uint16*)(msg_data + sizeof(uint16)))) & 0x4000));
m->Assign(3, val_mgr->GetBool(ntohs(*((uint16*)(msg_data + sizeof(uint16)))) & 0x2000));
m->Assign(4, val_mgr->GetBool(ntohs(*((uint16*)(msg_data + sizeof(uint16)))) & 0x1000));
m->Assign(5, val_mgr->GetCount(ntohs(*((uint16*)(msg_data + 2*sizeof(uint16))))));
off += 3 * sizeof(uint16);
m->Assign(0, val_mgr->GetCount(ntohs(*((uint16_t*)msg_data))));
m->Assign(1, val_mgr->GetBool(ntohs(*((uint16_t*)(msg_data + sizeof(uint16_t)))) & 0x8000));
m->Assign(2, val_mgr->GetBool(ntohs(*((uint16_t*)(msg_data + sizeof(uint16_t)))) & 0x4000));
m->Assign(3, val_mgr->GetBool(ntohs(*((uint16_t*)(msg_data + sizeof(uint16_t)))) & 0x2000));
m->Assign(4, val_mgr->GetBool(ntohs(*((uint16_t*)(msg_data + sizeof(uint16_t)))) & 0x1000));
m->Assign(5, val_mgr->GetCount(ntohs(*((uint16_t*)(msg_data + 2*sizeof(uint16_t))))));
off += 3 * sizeof(uint16_t);
m->Assign(6, BuildOptionsVal(data + off, Length() - off));
msg->Assign(6, m);
break;
@ -265,11 +265,11 @@ RecordVal* IPv6_Hdr::BuildRecordVal(VectorVal* chain) const
case 6:
{
RecordVal* m = new RecordVal(hdrType(ip6_mob_brr_type, "ip6_mobility_back"));
m->Assign(0, val_mgr->GetCount(*((uint8*)msg_data)));
m->Assign(1, val_mgr->GetBool(*((uint8*)(msg_data + sizeof(uint8))) & 0x80));
m->Assign(2, val_mgr->GetCount(ntohs(*((uint16*)(msg_data + sizeof(uint16))))));
m->Assign(3, val_mgr->GetCount(ntohs(*((uint16*)(msg_data + 2*sizeof(uint16))))));
off += 3 * sizeof(uint16);
m->Assign(0, val_mgr->GetCount(*((uint8_t*)msg_data)));
m->Assign(1, val_mgr->GetBool(*((uint8_t*)(msg_data + sizeof(uint8_t))) & 0x80));
m->Assign(2, val_mgr->GetCount(ntohs(*((uint16_t*)(msg_data + sizeof(uint16_t))))));
m->Assign(3, val_mgr->GetCount(ntohs(*((uint16_t*)(msg_data + 2*sizeof(uint16_t))))));
off += 3 * sizeof(uint16_t);
m->Assign(4, BuildOptionsVal(data + off, Length() - off));
msg->Assign(7, m);
break;
@ -278,10 +278,10 @@ RecordVal* IPv6_Hdr::BuildRecordVal(VectorVal* chain) const
case 7:
{
RecordVal* m = new RecordVal(hdrType(ip6_mob_brr_type, "ip6_mobility_be"));
m->Assign(0, val_mgr->GetCount(*((uint8*)msg_data)));
const in6_addr* hoa = (const in6_addr*)(msg_data + sizeof(uint16));
m->Assign(0, val_mgr->GetCount(*((uint8_t*)msg_data)));
const in6_addr* hoa = (const in6_addr*)(msg_data + sizeof(uint16_t));
m->Assign(1, new AddrVal(IPAddr(*hoa)));
off += sizeof(uint16) + sizeof(in6_addr);
off += sizeof(uint16_t) + sizeof(in6_addr);
m->Assign(2, BuildOptionsVal(data + off, Length() - off));
msg->Assign(8, m);
break;
@ -372,8 +372,8 @@ RecordVal* IP_Hdr::BuildPktHdrVal(RecordVal* pkt_hdr, int sindex) const
tcp_hdr->Assign(0, val_mgr->GetPort(ntohs(tp->th_sport), TRANSPORT_TCP));
tcp_hdr->Assign(1, val_mgr->GetPort(ntohs(tp->th_dport), TRANSPORT_TCP));
tcp_hdr->Assign(2, val_mgr->GetCount(uint32(ntohl(tp->th_seq))));
tcp_hdr->Assign(3, val_mgr->GetCount(uint32(ntohl(tp->th_ack))));
tcp_hdr->Assign(2, val_mgr->GetCount(uint32_t(ntohl(tp->th_seq))));
tcp_hdr->Assign(3, val_mgr->GetCount(uint32_t(ntohl(tp->th_ack))));
tcp_hdr->Assign(4, val_mgr->GetCount(tcp_hdr_len));
tcp_hdr->Assign(5, val_mgr->GetCount(data_len));
tcp_hdr->Assign(6, val_mgr->GetCount(tp->th_flags));
@ -428,7 +428,7 @@ RecordVal* IP_Hdr::BuildPktHdrVal(RecordVal* pkt_hdr, int sindex) const
return pkt_hdr;
}
static inline bool isIPv6ExtHeader(uint8 type)
static inline bool isIPv6ExtHeader(uint8_t type)
{
switch (type) {
case IPPROTO_HOPOPTS:
@ -447,10 +447,10 @@ static inline bool isIPv6ExtHeader(uint8 type)
}
void IPv6_Hdr_Chain::Init(const struct ip6_hdr* ip6, int total_len,
bool set_next, uint16 next)
bool set_next, uint16_t next)
{
length = 0;
uint8 current_type, next_type;
uint8_t current_type, next_type;
next_type = IPPROTO_IPV6;
const u_char* hdrs = (const u_char*) ip6;
@ -471,7 +471,7 @@ void IPv6_Hdr_Chain::Init(const struct ip6_hdr* ip6, int total_len,
IPv6_Hdr* p = new IPv6_Hdr(current_type, hdrs);
next_type = p->NextHdr();
uint16 cur_len = p->Length();
uint16_t cur_len = p->Length();
// If this header is truncated, don't add it to chain, don't go further.
if ( cur_len > total_len )
@ -510,7 +510,7 @@ void IPv6_Hdr_Chain::Init(const struct ip6_hdr* ip6, int total_len,
isIPv6ExtHeader(next_type) );
}
void IPv6_Hdr_Chain::ProcessRoutingHeader(const struct ip6_rthdr* r, uint16 len)
void IPv6_Hdr_Chain::ProcessRoutingHeader(const struct ip6_rthdr* r, uint16_t len)
{
if ( finalDst )
{
@ -559,11 +559,11 @@ void IPv6_Hdr_Chain::ProcessRoutingHeader(const struct ip6_rthdr* r, uint16 len)
}
#ifdef ENABLE_MOBILE_IPV6
void IPv6_Hdr_Chain::ProcessDstOpts(const struct ip6_dest* d, uint16 len)
void IPv6_Hdr_Chain::ProcessDstOpts(const struct ip6_dest* d, uint16_t len)
{
const u_char* data = (const u_char*) d;
len -= 2 * sizeof(uint8);
data += 2* sizeof(uint8);
len -= 2 * sizeof(uint8_t);
data += 2* sizeof(uint8_t);
while ( len > 0 )
{
@ -587,13 +587,13 @@ void IPv6_Hdr_Chain::ProcessDstOpts(const struct ip6_dest* d, uint16 len)
if ( opt->ip6o_type == 0 )
{
data += sizeof(uint8);
len -= sizeof(uint8);
data += sizeof(uint8_t);
len -= sizeof(uint8_t);
}
else
{
data += 2 * sizeof(uint8) + opt->ip6o_len;
len -= 2 * sizeof(uint8) + opt->ip6o_len;
data += 2 * sizeof(uint8_t) + opt->ip6o_len;
len -= 2 * sizeof(uint8_t) + opt->ip6o_len;
}
}
}
@ -620,7 +620,7 @@ VectorVal* IPv6_Hdr_Chain::BuildVal() const
{
RecordVal* v = chain[i]->BuildRecordVal();
RecordVal* ext_hdr = new RecordVal(ip6_ext_hdr_type);
uint8 type = chain[i]->Type();
uint8_t type = chain[i]->Type();
ext_hdr->Assign(0, val_mgr->GetCount(type));
switch (type) {

View file

@ -20,11 +20,11 @@
#endif
struct ip6_mobility {
uint8 ip6mob_payload;
uint8 ip6mob_len;
uint8 ip6mob_type;
uint8 ip6mob_rsv;
uint16 ip6mob_chksum;
uint8_t ip6mob_payload;
uint8_t ip6mob_len;
uint8_t ip6mob_type;
uint8_t ip6mob_rsv;
uint16_t ip6mob_chksum;
};
#endif //ENABLE_MOBILE_IPV6
@ -37,12 +37,12 @@ public:
/**
* Construct an IPv6 header or extension header from assigned type number.
*/
IPv6_Hdr(uint8 t, const u_char* d) : type(t), data(d) {}
IPv6_Hdr(uint8_t t, const u_char* d) : type(t), data(d) {}
/**
* Replace the value of the next protocol field.
*/
void ChangeNext(uint8 next_type)
void ChangeNext(uint8_t next_type)
{
switch ( type ) {
case IPPROTO_IPV6:
@ -70,7 +70,7 @@ public:
* Returns the assigned IPv6 extension header type number of the header
* that immediately follows this one.
*/
uint8 NextHdr() const
uint8_t NextHdr() const
{
switch ( type ) {
case IPPROTO_IPV6:
@ -93,7 +93,7 @@ public:
/**
* Returns the length of the header in bytes.
*/
uint16 Length() const
uint16_t Length() const
{
switch ( type ) {
case IPPROTO_IPV6:
@ -119,7 +119,7 @@ public:
/**
* Returns the RFC 1700 et seq. IANA assigned number for the header.
*/
uint8 Type() const { return type; }
uint8_t Type() const { return type; }
/**
* Returns pointer to the start of where header structure resides in memory.
@ -132,7 +132,7 @@ public:
RecordVal* BuildRecordVal(VectorVal* chain = 0) const;
protected:
uint8 type;
uint8_t type;
const u_char* data;
};
@ -171,7 +171,7 @@ public:
/**
* Returns the sum of the length of all headers in the chain in bytes.
*/
uint16 TotalLength() const { return length; }
uint16_t TotalLength() const { return length; }
/**
* Accesses the header at the given location in the chain.
@ -203,14 +203,14 @@ public:
* If the header chain is a fragment, returns the offset in number of bytes
* relative to the start of the Fragmentable Part of the original packet.
*/
uint16 FragOffset() const
uint16_t FragOffset() const
{ return IsFragment() ?
(ntohs(GetFragHdr()->ip6f_offlg) & 0xfff8) : 0; }
/**
* If the header chain is a fragment, returns the identification field.
*/
uint32 ID() const
uint32_t ID() const
{ return IsFragment() ? ntohl(GetFragHdr()->ip6f_ident) : 0; }
/**
@ -282,7 +282,7 @@ protected:
* Initializes the header chain from an IPv6 header structure, and replaces
* the first next protocol pointer field that points to a fragment header.
*/
IPv6_Hdr_Chain(const struct ip6_hdr* ip6, uint16 next, int len) :
IPv6_Hdr_Chain(const struct ip6_hdr* ip6, uint16_t next, int len) :
#ifdef ENABLE_MOBILE_IPV6
homeAddr(0),
#endif
@ -295,20 +295,20 @@ protected:
* points to a fragment header.
*/
void Init(const struct ip6_hdr* ip6, int total_len, bool set_next,
uint16 next = 0);
uint16_t next = 0);
/**
* Process a routing header and allocate/remember the final destination
* address if it has segments left and is a valid routing header.
*/
void ProcessRoutingHeader(const struct ip6_rthdr* r, uint16 len);
void ProcessRoutingHeader(const struct ip6_rthdr* r, uint16_t len);
#ifdef ENABLE_MOBILE_IPV6
/**
* Inspect a Destination Option header's options for things we need to
* remember, such as the Home Address option from Mobile IPv6.
*/
void ProcessDstOpts(const struct ip6_dest* d, uint16 len);
void ProcessDstOpts(const struct ip6_dest* d, uint16_t len);
#endif
vector<IPv6_Hdr*> chain;
@ -316,7 +316,7 @@ protected:
/**
* The summation of all header lengths in the chain in bytes.
*/
uint16 length;
uint16_t length;
#ifdef ENABLE_MOBILE_IPV6
/**
@ -459,7 +459,7 @@ public:
* Returns the length of the IP packet's payload (length of packet minus
* header length or, for IPv6, also minus length of all extension headers).
*/
uint16 PayloadLen() const
uint16_t PayloadLen() const
{
if ( ip4 )
return ntohs(ip4->ip_len) - ip4->ip_hl * 4;
@ -470,19 +470,19 @@ public:
/**
* Returns the length of the IP packet (length of headers and payload).
*/
uint32 TotalLen() const
uint32_t TotalLen() const
{ return ip4 ? ntohs(ip4->ip_len) : ntohs(ip6->ip6_plen) + 40; }
/**
* Returns length of IP packet header (includes extension headers for IPv6).
*/
uint16 HdrLen() const
uint16_t HdrLen() const
{ return ip4 ? ip4->ip_hl * 4 : ip6_hdrs->TotalLength(); }
/**
* For IPv6 header chains, returns the type of the last header in the chain.
*/
uint8 LastHeader() const
uint8_t LastHeader() const
{
if ( ip4 )
return IPPROTO_RAW;
@ -528,14 +528,14 @@ public:
* Returns the fragment packet's offset in relation to the original
* packet in bytes.
*/
uint16 FragOffset() const
uint16_t FragOffset() const
{ return ip4 ? (ntohs(ip4->ip_off) & 0x1fff) * 8 :
ip6_hdrs->FragOffset(); }
/**
* Returns the fragment packet's identification field.
*/
uint32 ID() const
uint32_t ID() const
{ return ip4 ? ntohs(ip4->ip_id) : ip6_hdrs->ID(); }
/**
@ -554,7 +554,7 @@ public:
/**
* Returns value of an IPv6 header's flow label field or 0 if it's IPv4.
*/
uint32 FlowLabel() const
uint32_t FlowLabel() const
{ return ip4 ? 0 : (ntohl(ip6->ip6_flow) & 0x000fffff); }
/**

View file

@ -19,8 +19,8 @@ HashKey* BuildConnIDHashKey(const ConnID& id)
struct {
in6_addr ip1;
in6_addr ip2;
uint16 port1;
uint16 port2;
uint16_t port1;
uint16_t port2;
} key;
// Lookup up connection based on canonical ordering, which is
@ -206,7 +206,7 @@ string IPAddr::PtrName() const
for ( unsigned int i = 0; i < 4; ++i )
{
uint32 a = ntohl(p[i]);
uint32_t a = ntohl(p[i]);
for ( unsigned int j = 1; j <=8; ++j )
{
ptr_name.insert(0, 1, '.');

View file

@ -609,7 +609,7 @@ public:
{
struct {
in6_addr ip;
uint32 len;
uint32_t len;
} key;
key.ip = prefix.in6;

View file

@ -249,12 +249,12 @@ void net_packet_dispatch(double t, const Packet* pkt, iosource::PktSrc* src_ps)
if ( load_sample )
{
static uint32 load_freq = 0;
static uint32_t load_freq = 0;
if ( load_freq == 0 )
load_freq = uint32(0xffffffff) / uint32(load_sample_freq);
load_freq = uint32_t(0xffffffff) / uint32_t(load_sample_freq);
if ( uint32(bro_random() & 0xffffffff) < load_freq )
if ( uint32_t(bro_random() & 0xffffffff) < load_freq )
{
// Drain the queued timer events so they're not
// charged against this sample.

View file

@ -108,7 +108,7 @@ protected:
virtual ~Modifiable();
// Number of currently registered receivers.
uint64 num_receivers = 0;
uint64_t num_receivers = 0;
};
}

View file

@ -103,7 +103,7 @@ broker::expected<broker::data> OpaqueVal::SerializeType(BroType* t)
}
// A base type.
return {broker::vector{false, static_cast<uint64>(t->Tag())}};
return {broker::vector{false, static_cast<uint64_t>(t->Tag())}};
}
BroType* OpaqueVal::UnserializeType(const broker::data& data)
@ -133,7 +133,7 @@ BroType* OpaqueVal::UnserializeType(const broker::data& data)
return t->Ref();
}
auto tag = caf::get_if<uint64>(&(*v)[1]);
auto tag = caf::get_if<uint64_t>(&(*v)[1]);
if ( ! tag )
return nullptr;
@ -299,17 +299,17 @@ broker::expected<broker::data> MD5Val::DoSerialize() const
broker::vector d = {
true,
static_cast<uint64>(md->A),
static_cast<uint64>(md->B),
static_cast<uint64>(md->C),
static_cast<uint64>(md->D),
static_cast<uint64>(md->Nl),
static_cast<uint64>(md->Nh),
static_cast<uint64>(md->num)
static_cast<uint64_t>(md->A),
static_cast<uint64_t>(md->B),
static_cast<uint64_t>(md->C),
static_cast<uint64_t>(md->D),
static_cast<uint64_t>(md->Nl),
static_cast<uint64_t>(md->Nh),
static_cast<uint64_t>(md->num)
};
for ( int i = 0; i < MD5_LBLOCK; ++i )
d.emplace_back(static_cast<uint64>(md->data[i]));
d.emplace_back(static_cast<uint64_t>(md->data[i]));
return {std::move(d)};
}
@ -439,18 +439,18 @@ broker::expected<broker::data> SHA1Val::DoSerialize() const
broker::vector d = {
true,
static_cast<uint64>(md->h0),
static_cast<uint64>(md->h1),
static_cast<uint64>(md->h2),
static_cast<uint64>(md->h3),
static_cast<uint64>(md->h4),
static_cast<uint64>(md->Nl),
static_cast<uint64>(md->Nh),
static_cast<uint64>(md->num)
static_cast<uint64_t>(md->h0),
static_cast<uint64_t>(md->h1),
static_cast<uint64_t>(md->h2),
static_cast<uint64_t>(md->h3),
static_cast<uint64_t>(md->h4),
static_cast<uint64_t>(md->Nl),
static_cast<uint64_t>(md->Nh),
static_cast<uint64_t>(md->num)
};
for ( int i = 0; i < SHA_LBLOCK; ++i )
d.emplace_back(static_cast<uint64>(md->data[i]));
d.emplace_back(static_cast<uint64_t>(md->data[i]));
return {std::move(d)};
}
@ -582,17 +582,17 @@ broker::expected<broker::data> SHA256Val::DoSerialize() const
broker::vector d = {
true,
static_cast<uint64>(md->Nl),
static_cast<uint64>(md->Nh),
static_cast<uint64>(md->num),
static_cast<uint64>(md->md_len)
static_cast<uint64_t>(md->Nl),
static_cast<uint64_t>(md->Nh),
static_cast<uint64_t>(md->num),
static_cast<uint64_t>(md->md_len)
};
for ( int i = 0; i < 8; ++i )
d.emplace_back(static_cast<uint64>(md->h[i]));
d.emplace_back(static_cast<uint64_t>(md->h[i]));
for ( int i = 0; i < SHA_LBLOCK; ++i )
d.emplace_back(static_cast<uint64>(md->data[i]));
d.emplace_back(static_cast<uint64_t>(md->data[i]));
return {std::move(d)};
}
@ -663,29 +663,29 @@ broker::expected<broker::data> EntropyVal::DoSerialize() const
{
broker::vector d =
{
static_cast<uint64>(state.totalc),
static_cast<uint64>(state.mp),
static_cast<uint64>(state.sccfirst),
static_cast<uint64>(state.inmont),
static_cast<uint64>(state.mcount),
static_cast<uint64>(state.cexp),
static_cast<uint64>(state.montex),
static_cast<uint64>(state.montey),
static_cast<uint64>(state.montepi),
static_cast<uint64>(state.sccu0),
static_cast<uint64>(state.scclast),
static_cast<uint64>(state.scct1),
static_cast<uint64>(state.scct2),
static_cast<uint64>(state.scct3),
static_cast<uint64_t>(state.totalc),
static_cast<uint64_t>(state.mp),
static_cast<uint64_t>(state.sccfirst),
static_cast<uint64_t>(state.inmont),
static_cast<uint64_t>(state.mcount),
static_cast<uint64_t>(state.cexp),
static_cast<uint64_t>(state.montex),
static_cast<uint64_t>(state.montey),
static_cast<uint64_t>(state.montepi),
static_cast<uint64_t>(state.sccu0),
static_cast<uint64_t>(state.scclast),
static_cast<uint64_t>(state.scct1),
static_cast<uint64_t>(state.scct2),
static_cast<uint64_t>(state.scct3),
};
d.reserve(256 + 3 + RT_MONTEN + 11);
for ( int i = 0; i < 256; ++i )
d.emplace_back(static_cast<uint64>(state.ccount[i]));
d.emplace_back(static_cast<uint64_t>(state.ccount[i]));
for ( int i = 0; i < RT_MONTEN; ++i )
d.emplace_back(static_cast<uint64>(state.monte[i]));
d.emplace_back(static_cast<uint64_t>(state.monte[i]));
return {std::move(d)};
}

View file

@ -25,7 +25,7 @@ protected:
};
struct IP_ID {
uint32 ip, id;
uint32_t ip, id;
};
struct ltipid {
@ -37,6 +37,6 @@ struct ltipid {
};
typedef set<IP_ID, ltipid> IP_IDSet;
uint16 NextIP_ID(const uint32 src_addr, const uint16 id);
uint16_t NextIP_ID(const uint32_t src_addr, const uint16_t id);
#endif

View file

@ -1,34 +1,34 @@
#include "PacketFilter.h"
void PacketFilter::AddSrc(const IPAddr& src, uint32 tcp_flags, double probability)
void PacketFilter::AddSrc(const IPAddr& src, uint32_t tcp_flags, double probability)
{
Filter* f = new Filter;
f->tcp_flags = tcp_flags;
f->probability = uint32(probability * RAND_MAX);
f->probability = uint32_t(probability * RAND_MAX);
src_filter.Insert(src, 128, f);
}
void PacketFilter::AddSrc(Val* src, uint32 tcp_flags, double probability)
void PacketFilter::AddSrc(Val* src, uint32_t tcp_flags, double probability)
{
Filter* f = new Filter;
f->tcp_flags = tcp_flags;
f->probability = uint32(probability * RAND_MAX);
f->probability = uint32_t(probability * RAND_MAX);
src_filter.Insert(src, f);
}
void PacketFilter::AddDst(const IPAddr& dst, uint32 tcp_flags, double probability)
void PacketFilter::AddDst(const IPAddr& dst, uint32_t tcp_flags, double probability)
{
Filter* f = new Filter;
f->tcp_flags = tcp_flags;
f->probability = uint32(probability * RAND_MAX);
f->probability = uint32_t(probability * RAND_MAX);
dst_filter.Insert(dst, 128, f);
}
void PacketFilter::AddDst(Val* dst, uint32 tcp_flags, double probability)
void PacketFilter::AddDst(Val* dst, uint32_t tcp_flags, double probability)
{
Filter* f = new Filter;
f->tcp_flags = tcp_flags;
f->probability = uint32(probability * RAND_MAX);
f->probability = uint32_t(probability * RAND_MAX);
dst_filter.Insert(dst, f);
}
@ -87,5 +87,5 @@ bool PacketFilter::MatchFilter(const Filter& f, const IP_Hdr& ip,
return false;
}
return uint32(bro_random()) < f.probability;
return uint32_t(bro_random()) < f.probability;
}

View file

@ -14,10 +14,10 @@ public:
// Drops all packets from a particular source (which may be given
// as an AddrVal or a SubnetVal) which hasn't any of TCP flags set
// (TH_*) with the given probability (from 0..MAX_PROB).
void AddSrc(const IPAddr& src, uint32 tcp_flags, double probability);
void AddSrc(Val* src, uint32 tcp_flags, double probability);
void AddDst(const IPAddr& src, uint32 tcp_flags, double probability);
void AddDst(Val* src, uint32 tcp_flags, double probability);
void AddSrc(const IPAddr& src, uint32_t tcp_flags, double probability);
void AddSrc(Val* src, uint32_t tcp_flags, double probability);
void AddDst(const IPAddr& src, uint32_t tcp_flags, double probability);
void AddDst(Val* src, uint32_t tcp_flags, double probability);
// Removes the filter entry for the given src/dst
// Returns false if filter doesn not exist.
@ -31,8 +31,8 @@ public:
private:
struct Filter {
uint32 tcp_flags;
uint32 probability;
uint32_t tcp_flags;
uint32_t probability;
};
bool MatchFilter(const Filter& f, const IP_Hdr& ip, int len, int caplen);

View file

@ -54,7 +54,7 @@ public:
int Size() const { return heap_size; }
int PeakSize() const { return peak_heap_size; }
uint64 CumulativeNum() const { return cumulative_num; }
uint64_t CumulativeNum() const { return cumulative_num; }
protected:
int Resize(int new_size);
@ -94,7 +94,7 @@ protected:
int heap_size;
int peak_heap_size;
int max_heap_size;
uint64 cumulative_num;
uint64_t cumulative_num;
};
#endif

View file

@ -34,7 +34,7 @@ extern void synerr(const char str[]);
typedef int AcceptIdx;
typedef std::set<AcceptIdx> AcceptingSet;
typedef uint64 MatchPos;
typedef uint64_t MatchPos;
typedef std::map<AcceptIdx, MatchPos> AcceptingMatchSet;
typedef name_list string_list;

View file

@ -20,12 +20,12 @@ class RandTest {
private:
friend class EntropyVal;
int64 ccount[256]; /* Bins to count occurrences of values */
int64 totalc; /* Total bytes counted */
int64_t ccount[256]; /* Bins to count occurrences of values */
int64_t totalc; /* Total bytes counted */
int mp;
int sccfirst;
unsigned int monte[RT_MONTEN];
int64 inmont, mcount;
int64_t inmont, mcount;
double cexp, montex, montey, montepi,
sccu0, scclast, scct1, scct2, scct3;
};

View file

@ -10,7 +10,7 @@
static const bool DEBUG_reassem = false;
DataBlock::DataBlock(Reassembler* reass, const u_char* data,
uint64 size, uint64 arg_seq, DataBlock* arg_prev,
uint64_t size, uint64_t arg_seq, DataBlock* arg_prev,
DataBlock* arg_next, ReassemblerType reassem_type)
{
seq = arg_seq;
@ -35,10 +35,10 @@ DataBlock::DataBlock(Reassembler* reass, const u_char* data,
Reassembler::total_size += pad_size(size) + padded_sizeof(DataBlock);
}
uint64 Reassembler::total_size = 0;
uint64 Reassembler::sizes[REASSEM_NUM];
uint64_t Reassembler::total_size = 0;
uint64_t Reassembler::sizes[REASSEM_NUM];
Reassembler::Reassembler(uint64 init_seq, ReassemblerType reassem_type)
Reassembler::Reassembler(uint64_t init_seq, ReassemblerType reassem_type)
: blocks(), last_block(), old_blocks(), last_old_block(),
last_reassem_seq(init_seq), trim_seq(init_seq),
max_old_blocks(0), total_old_blocks(0), size_of_all_blocks(0),
@ -53,7 +53,7 @@ Reassembler::~Reassembler()
}
void Reassembler::CheckOverlap(DataBlock *head, DataBlock *tail,
uint64 seq, uint64 len, const u_char* data)
uint64_t seq, uint64_t len, const u_char* data)
{
if ( ! head || ! tail )
return;
@ -62,12 +62,12 @@ void Reassembler::CheckOverlap(DataBlock *head, DataBlock *tail,
// Special case check for common case of appending to the end.
return;
uint64 upper = (seq + len);
uint64_t upper = (seq + len);
for ( DataBlock* b = head; b; b = b->next )
{
uint64 nseq = seq;
uint64 nupper = upper;
uint64_t nseq = seq;
uint64_t nupper = upper;
const u_char* ndata = data;
if ( nupper <= b->seq )
@ -85,20 +85,20 @@ void Reassembler::CheckOverlap(DataBlock *head, DataBlock *tail,
if ( nupper > b->upper )
nupper = b->upper;
uint64 overlap_offset = (nseq - b->seq);
uint64 overlap_len = (nupper - nseq);
uint64_t overlap_offset = (nseq - b->seq);
uint64_t overlap_len = (nupper - nseq);
if ( overlap_len )
Overlap(&b->block[overlap_offset], ndata, overlap_len);
}
}
void Reassembler::NewBlock(double t, uint64 seq, uint64 len, const u_char* data)
void Reassembler::NewBlock(double t, uint64_t seq, uint64_t len, const u_char* data)
{
if ( len == 0 )
return;
uint64 upper_seq = seq + len;
uint64_t upper_seq = seq + len;
CheckOverlap(old_blocks, last_old_block, seq, len, data);
@ -110,7 +110,7 @@ void Reassembler::NewBlock(double t, uint64 seq, uint64 len, const u_char* data)
if ( seq < trim_seq )
{ // Partially old data, just keep the good stuff.
uint64 amount_old = trim_seq - seq;
uint64_t amount_old = trim_seq - seq;
data += amount_old;
seq += amount_old;
@ -128,9 +128,9 @@ void Reassembler::NewBlock(double t, uint64 seq, uint64 len, const u_char* data)
BlockInserted(start_block);
}
uint64 Reassembler::TrimToSeq(uint64 seq)
uint64_t Reassembler::TrimToSeq(uint64_t seq)
{
uint64 num_missing = 0;
uint64_t num_missing = 0;
// Do this accounting before looking for Undelivered data,
// since that will alter last_reassem_seq.
@ -252,7 +252,7 @@ void Reassembler::ClearOldBlocks()
last_old_block = 0;
}
uint64 Reassembler::TotalSize() const
uint64_t Reassembler::TotalSize() const
{
return size_of_all_blocks;
}
@ -262,13 +262,13 @@ void Reassembler::Describe(ODesc* d) const
d->Add("reassembler");
}
void Reassembler::Undelivered(uint64 up_to_seq)
void Reassembler::Undelivered(uint64_t up_to_seq)
{
// TrimToSeq() expects this.
last_reassem_seq = up_to_seq;
}
DataBlock* Reassembler::AddAndCheck(DataBlock* b, uint64 seq, uint64 upper,
DataBlock* Reassembler::AddAndCheck(DataBlock* b, uint64_t seq, uint64_t upper,
const u_char* data)
{
if ( DEBUG_reassem )
@ -315,7 +315,7 @@ DataBlock* Reassembler::AddAndCheck(DataBlock* b, uint64 seq, uint64 upper,
if ( seq < b->seq )
{
// The new block has a prefix that comes before b.
uint64 prefix_len = b->seq - seq;
uint64_t prefix_len = b->seq - seq;
new_b = new DataBlock(this, data, prefix_len, seq,
b->prev, b, rtype);
if ( b == blocks )
@ -327,11 +327,11 @@ DataBlock* Reassembler::AddAndCheck(DataBlock* b, uint64 seq, uint64 upper,
else
new_b = b;
uint64 overlap_start = seq;
uint64 overlap_offset = overlap_start - b->seq;
uint64 new_b_len = upper - seq;
uint64 b_len = b->upper - overlap_start;
uint64 overlap_len = min(new_b_len, b_len);
uint64_t overlap_start = seq;
uint64_t overlap_offset = overlap_start - b->seq;
uint64_t new_b_len = upper - seq;
uint64_t b_len = b->upper - overlap_start;
uint64_t overlap_len = min(new_b_len, b_len);
if ( overlap_len < new_b_len )
{
@ -351,7 +351,7 @@ DataBlock* Reassembler::AddAndCheck(DataBlock* b, uint64 seq, uint64 upper,
return new_b;
}
uint64 Reassembler::MemoryAllocation(ReassemblerType rtype)
uint64_t Reassembler::MemoryAllocation(ReassemblerType rtype)
{
return Reassembler::sizes[rtype];
}

View file

@ -23,17 +23,17 @@ class Reassembler;
class DataBlock {
public:
DataBlock(Reassembler* reass, const u_char* data,
uint64 size, uint64 seq,
uint64_t size, uint64_t seq,
DataBlock* prev, DataBlock* next,
ReassemblerType reassem_type = REASSEM_UNKNOWN);
~DataBlock();
uint64 Size() const { return upper - seq; }
uint64_t Size() const { return upper - seq; }
DataBlock* next; // next block with higher seq #
DataBlock* prev; // previous block with lower seq #
uint64 seq, upper;
uint64_t seq, upper;
u_char* block;
ReassemblerType rtype;
@ -42,49 +42,49 @@ public:
class Reassembler : public BroObj {
public:
Reassembler(uint64 init_seq, ReassemblerType reassem_type = REASSEM_UNKNOWN);
Reassembler(uint64_t init_seq, ReassemblerType reassem_type = REASSEM_UNKNOWN);
~Reassembler() override;
void NewBlock(double t, uint64 seq, uint64 len, const u_char* data);
void NewBlock(double t, uint64_t seq, uint64_t len, const u_char* data);
// Throws away all blocks up to seq. Returns number of bytes
// if not all in-sequence, 0 if they were.
uint64 TrimToSeq(uint64 seq);
uint64_t TrimToSeq(uint64_t seq);
// Delete all held blocks.
void ClearBlocks();
void ClearOldBlocks();
int HasBlocks() const { return blocks != 0; }
uint64 LastReassemSeq() const { return last_reassem_seq; }
uint64_t LastReassemSeq() const { return last_reassem_seq; }
uint64 TotalSize() const; // number of bytes buffered up
uint64_t TotalSize() const; // number of bytes buffered up
void Describe(ODesc* d) const override;
// Sum over all data buffered in some reassembler.
static uint64 TotalMemoryAllocation() { return total_size; }
static uint64_t TotalMemoryAllocation() { return total_size; }
// Data buffered by type of reassembler.
static uint64 MemoryAllocation(ReassemblerType rtype);
static uint64_t MemoryAllocation(ReassemblerType rtype);
void SetMaxOldBlocks(uint32 count) { max_old_blocks = count; }
void SetMaxOldBlocks(uint32_t count) { max_old_blocks = count; }
protected:
Reassembler() { }
friend class DataBlock;
virtual void Undelivered(uint64 up_to_seq);
virtual void Undelivered(uint64_t up_to_seq);
virtual void BlockInserted(DataBlock* b) = 0;
virtual void Overlap(const u_char* b1, const u_char* b2, uint64 n) = 0;
virtual void Overlap(const u_char* b1, const u_char* b2, uint64_t n) = 0;
DataBlock* AddAndCheck(DataBlock* b, uint64 seq,
uint64 upper, const u_char* data);
DataBlock* AddAndCheck(DataBlock* b, uint64_t seq,
uint64_t upper, const u_char* data);
void CheckOverlap(DataBlock *head, DataBlock *tail,
uint64 seq, uint64 len, const u_char* data);
uint64_t seq, uint64_t len, const u_char* data);
DataBlock* blocks;
DataBlock* last_block;
@ -92,16 +92,16 @@ protected:
DataBlock* old_blocks;
DataBlock* last_old_block;
uint64 last_reassem_seq;
uint64 trim_seq; // how far we've trimmed
uint32 max_old_blocks;
uint32 total_old_blocks;
uint64 size_of_all_blocks;
uint64_t last_reassem_seq;
uint64_t trim_seq; // how far we've trimmed
uint32_t max_old_blocks;
uint32_t total_old_blocks;
uint64_t size_of_all_blocks;
ReassemblerType rtype;
static uint64 total_size;
static uint64 sizes[REASSEM_NUM];
static uint64_t total_size;
static uint64_t sizes[REASSEM_NUM];
};
inline DataBlock::~DataBlock()

View file

@ -42,7 +42,7 @@ protected:
class Reporter {
public:
using IPPair = std::pair<IPAddr, IPAddr>;
using WeirdCountMap = std::unordered_map<std::string, uint64>;
using WeirdCountMap = std::unordered_map<std::string, uint64_t>;
using WeirdFlowMap = std::map<IPPair, WeirdCountMap>;
using WeirdSet = std::unordered_set<std::string>;
@ -144,7 +144,7 @@ public:
* Return the total number of weirds generated (counts weirds before
* any rate-limiting occurs).
*/
uint64 GetWeirdCount() const
uint64_t GetWeirdCount() const
{ return weird_count; }
/**
@ -177,7 +177,7 @@ public:
*
* @return weird sampling threshold.
*/
uint64 GetWeirdSamplingThreshold() const
uint64_t GetWeirdSamplingThreshold() const
{
return weird_sampling_threshold;
}
@ -187,7 +187,7 @@ public:
*
* @param weird_sampling_threshold New weird sampling threshold.
*/
void SetWeirdSamplingThreshold(uint64 weird_sampling_threshold)
void SetWeirdSamplingThreshold(uint64_t weird_sampling_threshold)
{
this->weird_sampling_threshold = weird_sampling_threshold;
}
@ -197,7 +197,7 @@ public:
*
* @return weird sampling rate.
*/
uint64 GetWeirdSamplingRate() const
uint64_t GetWeirdSamplingRate() const
{
return weird_sampling_rate;
}
@ -207,7 +207,7 @@ public:
*
* @param weird_sampling_rate New weird sampling rate.
*/
void SetWeirdSamplingRate(uint64 weird_sampling_rate)
void SetWeirdSamplingRate(uint64_t weird_sampling_rate)
{
this->weird_sampling_rate = weird_sampling_rate;
}
@ -268,14 +268,14 @@ private:
std::list<std::pair<const Location*, const Location*> > locations;
uint64 weird_count;
uint64_t weird_count;
WeirdCountMap weird_count_by_type;
WeirdCountMap net_weird_state;
WeirdFlowMap flow_weird_state;
WeirdSet weird_sampling_whitelist;
uint64 weird_sampling_threshold;
uint64 weird_sampling_rate;
uint64_t weird_sampling_threshold;
uint64_t weird_sampling_rate;
double weird_sampling_duration;
};

View file

@ -68,7 +68,7 @@ void Rule::PrintDebug()
}
void Rule::AddPattern(const char* str, Rule::PatternType type,
uint32 offset, uint32 depth)
uint32_t offset, uint32_t depth)
{
Pattern* p = new Pattern;
p->pattern = copy_string(str);

View file

@ -44,7 +44,7 @@ public:
void AddCondition(RuleCondition* cond) { conditions.push_back(cond); }
void AddHdrTest(RuleHdrTest* hdr_test) { hdr_tests.push_back(hdr_test); }
void AddPattern(const char* str, Rule::PatternType type,
uint32 offset = 0, uint32 depth = INT_MAX);
uint32_t offset = 0, uint32_t depth = INT_MAX);
void AddRequires(const char* id, bool opposite_direction, bool negate);
const Location& GetLocation() const { return location; }
@ -88,8 +88,8 @@ private:
char* pattern; // the pattern itself
PatternType type;
int id; // ID of pattern (for identifying it within regexps)
uint32 offset;
uint32 depth;
uint32_t offset;
uint32_t depth;
};
typedef PList<Pattern> pattern_list;

View file

@ -93,7 +93,7 @@ bool RuleConditionPayloadSize::DoMatch(Rule* rule, RuleEndpointState* state,
// We are interested in the first non-empty chunk.
return false;
uint32 payload_size = uint32(state->PayloadSize());
uint32_t payload_size = uint32_t(state->PayloadSize());
switch ( comp ) {
case RULE_EQ:

View file

@ -87,7 +87,7 @@ class RuleConditionPayloadSize : public RuleCondition {
public:
enum Comp { RULE_LE, RULE_GE, RULE_LT, RULE_GT, RULE_EQ, RULE_NE };
RuleConditionPayloadSize(uint32 arg_val, Comp arg_comp)
RuleConditionPayloadSize(uint32_t arg_val, Comp arg_comp)
{ val = arg_val; comp = arg_comp; }
~RuleConditionPayloadSize() override {}
@ -98,7 +98,7 @@ public:
void PrintDebug() override;
private:
uint32 val;
uint32_t val;
Comp comp;
};

View file

@ -23,14 +23,14 @@
// - tcp-state always evaluates to true
// (implemented but deactivated for comparison to Snort)
uint32 RuleHdrTest::idcounter = 0;
uint32_t RuleHdrTest::idcounter = 0;
static bool is_member_of(const int_list& l, int_list::value_type v)
{
return std::find(l.begin(), l.end(), v) != l.end();
}
RuleHdrTest::RuleHdrTest(Prot arg_prot, uint32 arg_offset, uint32 arg_size,
RuleHdrTest::RuleHdrTest(Prot arg_prot, uint32_t arg_offset, uint32_t arg_size,
Comp arg_comp, maskedvalue_list* arg_vals)
{
prot = arg_prot;
@ -428,17 +428,17 @@ void RuleMatcher::BuildPatternSets(RuleHdrTest::pattern_set_list* dst,
}
// Get a 8/16/32-bit value from the given position in the packet header
static inline uint32 getval(const u_char* data, int size)
static inline uint32_t getval(const u_char* data, int size)
{
switch ( size ) {
case 1:
return *(uint8*) data;
return *(uint8_t*) data;
case 2:
return ntohs(*(uint16*) data);
return ntohs(*(uint16_t*) data);
case 4:
return ntohl(*(uint32*) data);
return ntohl(*(uint32_t*) data);
default:
reporter->InternalError("illegal HdrTest size");
@ -451,7 +451,7 @@ static inline uint32 getval(const u_char* data, int size)
// Evaluate a value list (matches if at least one value matches).
template <typename FuncT>
static inline bool match_or(const maskedvalue_list& mvals, uint32 v, FuncT comp)
static inline bool match_or(const maskedvalue_list& mvals, uint32_t v, FuncT comp)
{
// TODO: this could be a find_if
for ( const auto& val : mvals )
@ -479,7 +479,7 @@ static inline bool match_or(const vector<IPPrefix>& prefixes, const IPAddr& a,
// Evaluate a value list (doesn't match if any value matches).
template <typename FuncT>
static inline bool match_not_and(const maskedvalue_list& mvals, uint32 v,
static inline bool match_not_and(const maskedvalue_list& mvals, uint32_t v,
FuncT comp)
{
// TODO: this could be a find_if
@ -506,32 +506,32 @@ static inline bool match_not_and(const vector<IPPrefix>& prefixes,
return true;
}
static inline bool compare(const maskedvalue_list& mvals, uint32 v,
static inline bool compare(const maskedvalue_list& mvals, uint32_t v,
RuleHdrTest::Comp comp)
{
switch ( comp ) {
case RuleHdrTest::EQ:
return match_or(mvals, v, std::equal_to<uint32>());
return match_or(mvals, v, std::equal_to<uint32_t>());
break;
case RuleHdrTest::NE:
return match_not_and(mvals, v, std::equal_to<uint32>());
return match_not_and(mvals, v, std::equal_to<uint32_t>());
break;
case RuleHdrTest::LT:
return match_or(mvals, v, std::less<uint32>());
return match_or(mvals, v, std::less<uint32_t>());
break;
case RuleHdrTest::GT:
return match_or(mvals, v, std::greater<uint32>());
return match_or(mvals, v, std::greater<uint32_t>());
break;
case RuleHdrTest::LE:
return match_or(mvals, v, std::less_equal<uint32>());
return match_or(mvals, v, std::less_equal<uint32_t>());
break;
case RuleHdrTest::GE:
return match_or(mvals, v, std::greater_equal<uint32>());
return match_or(mvals, v, std::greater_equal<uint32_t>());
break;
default:
@ -617,7 +617,7 @@ bool RuleMatcher::AllRulePatternsMatched(const Rule* r, MatchPos matchpos,
}
RuleMatcher::MIME_Matches* RuleMatcher::Match(RuleFileMagicState* state,
const u_char* data, uint64 len,
const u_char* data, uint64_t len,
MIME_Matches* rval) const
{
if ( ! rval )
@ -1281,8 +1281,8 @@ static bool val_to_maskedval(Val* v, maskedvalue_list* append_to,
}
else
{
const uint32* n;
uint32 m[4];
const uint32_t* n;
uint32_t m[4];
v->AsSubNet().Prefix().GetBytes(&n);
v->AsSubNetVal()->Mask().CopyIPv6(m);
@ -1370,7 +1370,7 @@ error:
return dummy;
}
uint32 id_to_uint(const char* id)
uint32_t id_to_uint(const char* id)
{
Val* v = get_bro_val(id);
if ( ! v )

View file

@ -47,13 +47,13 @@ namespace analyzer {
// Given a header expression like "ip[offset:len] & mask = val", we parse
// it into a Range and a MaskedValue.
struct Range {
uint32 offset;
uint32 len;
uint32_t offset;
uint32_t len;
};
struct MaskedValue {
uint32 val;
uint32 mask;
uint32_t val;
uint32_t mask;
};
typedef PList<MaskedValue> maskedvalue_list;
@ -64,7 +64,7 @@ typedef PList<BroString> bstr_list;
extern void id_to_maskedvallist(const char* id, maskedvalue_list* append_to,
vector<IPPrefix>* prefix_vector = 0);
extern char* id_to_str(const char* id);
extern uint32 id_to_uint(const char* id);
extern uint32_t id_to_uint(const char* id);
class RuleHdrTest {
public:
@ -72,7 +72,7 @@ public:
enum Comp { LE, GE, LT, GT, EQ, NE };
enum Prot { NOPROT, IP, IPv6, ICMP, ICMPv6, TCP, UDP, NEXT, IPSrc, IPDst };
RuleHdrTest(Prot arg_prot, uint32 arg_offset, uint32 arg_size,
RuleHdrTest(Prot arg_prot, uint32_t arg_offset, uint32_t arg_size,
Comp arg_comp, maskedvalue_list* arg_vals);
RuleHdrTest(Prot arg_prot, Comp arg_comp, vector<IPPrefix> arg_v);
~RuleHdrTest();
@ -92,11 +92,11 @@ private:
Comp comp;
maskedvalue_list* vals;
vector<IPPrefix> prefix_vals; // for use with IPSrc/IPDst comparisons
uint32 offset;
uint32 size;
uint32_t offset;
uint32_t size;
uint32 id; // For debugging, each HdrTest gets an unique ID
static uint32 idcounter;
uint32_t id; // For debugging, each HdrTest gets an unique ID
static uint32_t idcounter;
// The following are all set by RuleMatcher::BuildRulesTree().
friend class RuleMatcher;
@ -251,7 +251,7 @@ public:
* @return The results of the signature matching.
*/
MIME_Matches* Match(RuleFileMagicState* state, const u_char* data,
uint64 len, MIME_Matches* matches = 0) const;
uint64_t len, MIME_Matches* matches = 0) const;
/**

View file

@ -18,7 +18,7 @@ SerializationFormat::~SerializationFormat()
free(output);
}
void SerializationFormat::StartRead(const char* data, uint32 arg_len)
void SerializationFormat::StartRead(const char* data, uint32_t arg_len)
{
input = data;
input_len = arg_len;
@ -49,9 +49,9 @@ void SerializationFormat::StartWrite()
bytes_written = 0;
}
uint32 SerializationFormat::EndWrite(char** data)
uint32_t SerializationFormat::EndWrite(char** data)
{
uint32 rval = output_pos;
uint32_t rval = output_pos;
*data = output;
output = 0;
output_size = 0;
@ -101,7 +101,7 @@ BinarySerializationFormat::~BinarySerializationFormat()
bool BinarySerializationFormat::Read(int* v, const char* tag)
{
uint32 tmp;
uint32_t tmp;
if ( ! ReadData(&tmp, sizeof(tmp)) )
return false;
@ -110,46 +110,46 @@ bool BinarySerializationFormat::Read(int* v, const char* tag)
return true;
}
bool BinarySerializationFormat::Read(uint16* v, const char* tag)
bool BinarySerializationFormat::Read(uint16_t* v, const char* tag)
{
if ( ! ReadData(v, sizeof(*v)) )
return false;
*v = ntohs(*v);
DBG_LOG(DBG_SERIAL, "Read uint16 %hu [%s]", *v, tag);
DBG_LOG(DBG_SERIAL, "Read uint16_t %hu [%s]", *v, tag);
return true;
}
bool BinarySerializationFormat::Read(uint32* v, const char* tag)
bool BinarySerializationFormat::Read(uint32_t* v, const char* tag)
{
if ( ! ReadData(v, sizeof(*v)) )
return false;
*v = ntohl(*v);
DBG_LOG(DBG_SERIAL, "Read uint32 %" PRIu32 " [%s]", *v, tag);
DBG_LOG(DBG_SERIAL, "Read uint32_t %" PRIu32 " [%s]", *v, tag);
return true;
}
bool BinarySerializationFormat::Read(int64* v, const char* tag)
bool BinarySerializationFormat::Read(int64_t* v, const char* tag)
{
uint32 x[2];
uint32_t x[2];
if ( ! ReadData(x, sizeof(x)) )
return false;
*v = ((int64(ntohl(x[0]))) << 32) | ntohl(x[1]);
DBG_LOG(DBG_SERIAL, "Read int64 %" PRId64 " [%s]", *v, tag);
*v = ((int64_t(ntohl(x[0]))) << 32) | ntohl(x[1]);
DBG_LOG(DBG_SERIAL, "Read int64_t %" PRId64 " [%s]", *v, tag);
return true;
}
bool BinarySerializationFormat::Read(uint64* v, const char* tag)
bool BinarySerializationFormat::Read(uint64_t* v, const char* tag)
{
uint32 x[2];
uint32_t x[2];
if ( ! ReadData(x, sizeof(x)) )
return false;
*v = ((uint64(ntohl(x[0]))) << 32) | ntohl(x[1]);
DBG_LOG(DBG_SERIAL, "Read uint64 %" PRIu64 " [%s]", *v, tag);
*v = ((uint64_t(ntohl(x[0]))) << 32) | ntohl(x[1]);
DBG_LOG(DBG_SERIAL, "Read uint64_t %" PRIu64 " [%s]", *v, tag);
return true;
}
@ -304,16 +304,16 @@ bool BinarySerializationFormat::Write(char v, const char* tag)
return WriteData(&v, 1);
}
bool BinarySerializationFormat::Write(uint16 v, const char* tag)
bool BinarySerializationFormat::Write(uint16_t v, const char* tag)
{
DBG_LOG(DBG_SERIAL, "Write uint16 %hu [%s]", v, tag);
DBG_LOG(DBG_SERIAL, "Write uint16_t %hu [%s]", v, tag);
v = htons(v);
return WriteData(&v, sizeof(v));
}
bool BinarySerializationFormat::Write(uint32 v, const char* tag)
bool BinarySerializationFormat::Write(uint32_t v, const char* tag)
{
DBG_LOG(DBG_SERIAL, "Write uint32 %" PRIu32 " [%s]", v, tag);
DBG_LOG(DBG_SERIAL, "Write uint32_t %" PRIu32 " [%s]", v, tag);
v = htonl(v);
return WriteData(&v, sizeof(v));
}
@ -321,23 +321,23 @@ bool BinarySerializationFormat::Write(uint32 v, const char* tag)
bool BinarySerializationFormat::Write(int v, const char* tag)
{
DBG_LOG(DBG_SERIAL, "Write int %d [%s]", v, tag);
uint32 tmp = htonl((uint32) v);
uint32_t tmp = htonl((uint32_t) v);
return WriteData(&tmp, sizeof(tmp));
}
bool BinarySerializationFormat::Write(uint64 v, const char* tag)
bool BinarySerializationFormat::Write(uint64_t v, const char* tag)
{
DBG_LOG(DBG_SERIAL, "Write uint64 %" PRIu64 " [%s]", v, tag);
uint32 x[2];
DBG_LOG(DBG_SERIAL, "Write uint64_t %" PRIu64 " [%s]", v, tag);
uint32_t x[2];
x[0] = htonl(v >> 32);
x[1] = htonl(v & 0xffffffff);
return WriteData(x, sizeof(x));
}
bool BinarySerializationFormat::Write(int64 v, const char* tag)
bool BinarySerializationFormat::Write(int64_t v, const char* tag)
{
DBG_LOG(DBG_SERIAL, "Write int64 %" PRId64 " [%s]", v, tag);
uint32 x[2];
DBG_LOG(DBG_SERIAL, "Write int64_t %" PRId64 " [%s]", v, tag);
uint32_t x[2];
x[0] = htonl(v >> 32);
x[1] = htonl(v & 0xffffffff);
return WriteData(x, sizeof(x));
@ -432,7 +432,7 @@ bool BinarySerializationFormat::WriteSeparator()
bool BinarySerializationFormat::Write(const char* buf, int len, const char* tag)
{
DBG_LOG(DBG_SERIAL, "Write bytes |%s| [%s]", fmt_bytes(buf, len), tag);
uint32 l = htonl(len);
uint32_t l = htonl(len);
return WriteData(&l, sizeof(l)) && WriteData(buf, len);
}

View file

@ -19,14 +19,14 @@ public:
virtual ~SerializationFormat();
// Unserialization.
virtual void StartRead(const char* data, uint32 len);
virtual void StartRead(const char* data, uint32_t len);
virtual void EndRead();
virtual bool Read(int* v, const char* tag) = 0;
virtual bool Read(uint16* v, const char* tag) = 0;
virtual bool Read(uint32* v, const char* tag) = 0;
virtual bool Read(int64* v, const char* tag) = 0;
virtual bool Read(uint64* v, const char* tag) = 0;
virtual bool Read(uint16_t* v, const char* tag) = 0;
virtual bool Read(uint32_t* v, const char* tag) = 0;
virtual bool Read(int64_t* v, const char* tag) = 0;
virtual bool Read(uint64_t* v, const char* tag) = 0;
virtual bool Read(char* v, const char* tag) = 0;
virtual bool Read(bool* v, const char* tag) = 0;
virtual bool Read(double* d, const char* tag) = 0;
@ -52,13 +52,13 @@ public:
* be reclaimed using "free()".
* @return The number of bytes in the buffer object assigned to \a data.
*/
virtual uint32 EndWrite(char** data);
virtual uint32_t EndWrite(char** data);
virtual bool Write(int v, const char* tag) = 0;
virtual bool Write(uint16 v, const char* tag) = 0;
virtual bool Write(uint32 v, const char* tag) = 0;
virtual bool Write(int64 v, const char* tag) = 0;
virtual bool Write(uint64 v, const char* tag) = 0;
virtual bool Write(uint16_t v, const char* tag) = 0;
virtual bool Write(uint32_t v, const char* tag) = 0;
virtual bool Write(int64_t v, const char* tag) = 0;
virtual bool Write(uint64_t v, const char* tag) = 0;
virtual bool Write(char v, const char* tag) = 0;
virtual bool Write(bool v, const char* tag) = 0;
virtual bool Write(double d, const char* tag) = 0;
@ -81,15 +81,15 @@ protected:
bool ReadData(void* buf, size_t count);
bool WriteData(const void* buf, size_t count);
static const uint32 INITIAL_SIZE = 65536;
static const uint32_t INITIAL_SIZE = 65536;
static const float GROWTH_FACTOR;
char* output;
uint32 output_size;
uint32 output_pos;
uint32_t output_size;
uint32_t output_pos;
const char* input;
uint32 input_len;
uint32 input_pos;
uint32_t input_len;
uint32_t input_pos;
int bytes_written;
int bytes_read;
@ -101,10 +101,10 @@ public:
~BinarySerializationFormat() override;
bool Read(int* v, const char* tag) override;
bool Read(uint16* v, const char* tag) override;
bool Read(uint32* v, const char* tag) override;
bool Read(int64* v, const char* tag) override;
bool Read(uint64* v, const char* tag) override;
bool Read(uint16_t* v, const char* tag) override;
bool Read(uint32_t* v, const char* tag) override;
bool Read(int64_t* v, const char* tag) override;
bool Read(uint64_t* v, const char* tag) override;
bool Read(char* v, const char* tag) override;
bool Read(bool* v, const char* tag) override;
bool Read(double* d, const char* tag) override;
@ -115,10 +115,10 @@ public:
bool Read(struct in_addr* addr, const char* tag) override;
bool Read(struct in6_addr* addr, const char* tag) override;
bool Write(int v, const char* tag) override;
bool Write(uint16 v, const char* tag) override;
bool Write(uint32 v, const char* tag) override;
bool Write(int64 v, const char* tag) override;
bool Write(uint64 v, const char* tag) override;
bool Write(uint16_t v, const char* tag) override;
bool Write(uint32_t v, const char* tag) override;
bool Write(int64_t v, const char* tag) override;
bool Write(uint64_t v, const char* tag) override;
bool Write(char v, const char* tag) override;
bool Write(bool v, const char* tag) override;
bool Write(double d, const char* tag) override;

View file

@ -167,7 +167,7 @@ void NetSessions::NextPacket(double t, const Packet* pkt)
return;
}
uint32 caplen = pkt->cap_len - pkt->hdr_size;
uint32_t caplen = pkt->cap_len - pkt->hdr_size;
if ( pkt->l3_proto == L3_IPV4 )
{
@ -264,7 +264,7 @@ int NetSessions::CheckConnectionTag(Connection* conn)
return 1;
}
static unsigned int gre_header_len(uint16 flags)
static unsigned int gre_header_len(uint16_t flags)
{
unsigned int len = 4; // Always has 2 byte flags and 2 byte protocol type.
@ -292,10 +292,10 @@ static unsigned int gre_header_len(uint16 flags)
void NetSessions::DoNextPacket(double t, const Packet* pkt, const IP_Hdr* ip_hdr,
const EncapsulationStack* encapsulation)
{
uint32 caplen = pkt->cap_len - pkt->hdr_size;
uint32_t caplen = pkt->cap_len - pkt->hdr_size;
const struct ip* ip4 = ip_hdr->IP4_Hdr();
uint32 len = ip_hdr->TotalLen();
uint32_t len = ip_hdr->TotalLen();
if ( len == 0 )
{
// TCP segmentation offloading can zero out the ip_len field.
@ -313,7 +313,7 @@ void NetSessions::DoNextPacket(double t, const Packet* pkt, const IP_Hdr* ip_hdr
// For both of these it is safe to pass ip_hdr because the presence
// is guaranteed for the functions that pass data to us.
uint16 ip_hdr_len = ip_hdr->HdrLen();
uint16_t ip_hdr_len = ip_hdr->HdrLen();
if ( ip_hdr_len > len )
{
Weird("invalid_IP_header_size", ip_hdr, encapsulation);
@ -491,8 +491,8 @@ void NetSessions::DoNextPacket(double t, const Packet* pkt, const IP_Hdr* ip_hdr
return;
}
uint16 flags_ver = ntohs(*((uint16*)(data + 0)));
uint16 proto_typ = ntohs(*((uint16*)(data + 2)));
uint16_t flags_ver = ntohs(*((uint16_t*)(data + 0)));
uint16_t proto_typ = ntohs(*((uint16_t*)(data + 2)));
int gre_version = flags_ver & 0x0007;
// If a carried packet has ethernet, this will help skip it.
@ -515,7 +515,7 @@ void NetSessions::DoNextPacket(double t, const Packet* pkt, const IP_Hdr* ip_hdr
if ( len > gre_len + 14 )
{
eth_len = 14;
proto_typ = ntohs(*((uint16*)(data + gre_len + eth_len - 2)));
proto_typ = ntohs(*((uint16_t*)(data + gre_len + eth_len - 2)));
}
else
{
@ -531,7 +531,7 @@ void NetSessions::DoNextPacket(double t, const Packet* pkt, const IP_Hdr* ip_hdr
{
erspan_len = 8;
eth_len = 14;
proto_typ = ntohs(*((uint16*)(data + gre_len + erspan_len + eth_len - 2)));
proto_typ = ntohs(*((uint16_t*)(data + gre_len + erspan_len + eth_len - 2)));
}
else
{
@ -562,7 +562,7 @@ void NetSessions::DoNextPacket(double t, const Packet* pkt, const IP_Hdr* ip_hdr
}
}
proto_typ = ntohs(*((uint16*)(data + gre_len + erspan_len + eth_len - 2)));
proto_typ = ntohs(*((uint16_t*)(data + gre_len + erspan_len + eth_len - 2)));
}
else
{
@ -618,7 +618,7 @@ void NetSessions::DoNextPacket(double t, const Packet* pkt, const IP_Hdr* ip_hdr
if ( gre_version == 1 )
{
uint16 ppp_proto = ntohs(*((uint16*)(data + gre_len + 2)));
uint16_t ppp_proto = ntohs(*((uint16_t*)(data + gre_len + 2)));
if ( ppp_proto != 0x0021 && ppp_proto != 0x0057 )
{
@ -809,7 +809,7 @@ void NetSessions::DoNextInnerPacket(double t, const Packet* pkt,
const IP_Hdr* inner, const EncapsulationStack* prev,
const EncapsulatingConn& ec)
{
uint32 caplen, len;
uint32_t caplen, len;
caplen = len = inner->TotalLen();
pkt_timeval ts;
@ -883,16 +883,16 @@ int NetSessions::ParseIPPacket(int caplen, const u_char* const pkt, int proto,
return -1;
}
if ( (uint32)caplen != inner->TotalLen() )
return (uint32)caplen < inner->TotalLen() ? -1 : 1;
if ( (uint32_t)caplen != inner->TotalLen() )
return (uint32_t)caplen < inner->TotalLen() ? -1 : 1;
return 0;
}
bool NetSessions::CheckHeaderTrunc(int proto, uint32 len, uint32 caplen,
bool NetSessions::CheckHeaderTrunc(int proto, uint32_t len, uint32_t caplen,
const Packet* p, const EncapsulationStack* encap)
{
uint32 min_hdr_len = 0;
uint32_t min_hdr_len = 0;
switch ( proto ) {
case IPPROTO_TCP:
min_hdr_len = sizeof(struct tcphdr);
@ -938,7 +938,7 @@ bool NetSessions::CheckHeaderTrunc(int proto, uint32 len, uint32 caplen,
FragReassembler* NetSessions::NextFragment(double t, const IP_Hdr* ip,
const u_char* pkt)
{
uint32 frag_id = ip->ID();
uint32_t frag_id = ip->ID();
ListVal* key = new ListVal(TYPE_ANY);
key->Append(new AddrVal(ip->SrcAddr()));
@ -1207,7 +1207,7 @@ void NetSessions::GetStats(SessionStats& s) const
}
Connection* NetSessions::NewConn(HashKey* k, double t, const ConnID* id,
const u_char* data, int proto, uint32 flow_label,
const u_char* data, int proto, uint32_t flow_label,
const Packet* pkt, const EncapsulationStack* encapsulation)
{
// FIXME: This should be cleaned up a bit, it's too protocol-specific.
@ -1282,7 +1282,7 @@ Connection* NetSessions::NewConn(HashKey* k, double t, const ConnID* id,
return conn;
}
bool NetSessions::IsLikelyServerPort(uint32 port, TransportProto proto) const
bool NetSessions::IsLikelyServerPort(uint32_t port, TransportProto proto) const
{
// We keep a cached in-core version of the table to speed up the lookup.
static set<bro_uint_t> port_cache;
@ -1309,9 +1309,9 @@ bool NetSessions::IsLikelyServerPort(uint32 port, TransportProto proto) const
return port_cache.find(port) != port_cache.end();
}
bool NetSessions::WantConnection(uint16 src_port, uint16 dst_port,
bool NetSessions::WantConnection(uint16_t src_port, uint16_t dst_port,
TransportProto transport_proto,
uint8 tcp_flags, bool& flip_roles)
uint8_t tcp_flags, bool& flip_roles)
{
flip_roles = false;
@ -1402,7 +1402,7 @@ void NetSessions::DumpPacket(const Packet *pkt, int len)
if ( len != 0 )
{
if ( (uint32)len > pkt->cap_len )
if ( (uint32_t)len > pkt->cap_len )
reporter->Warning("bad modified caplen");
else
const_cast<Packet *>(pkt)->cap_len = len;

View file

@ -29,19 +29,19 @@ namespace analyzer { namespace arp { class ARP_Analyzer; } }
struct SessionStats {
int num_TCP_conns;
int max_TCP_conns;
uint64 cumulative_TCP_conns;
uint64_t cumulative_TCP_conns;
int num_UDP_conns;
int max_UDP_conns;
uint64 cumulative_UDP_conns;
uint64_t cumulative_UDP_conns;
int num_ICMP_conns;
int max_ICMP_conns;
uint64 cumulative_ICMP_conns;
uint64_t cumulative_ICMP_conns;
int num_fragments;
int max_fragments;
uint64 num_packets;
uint64_t num_packets;
};
// Drains and deletes a timer manager if it hasn't seen any advances
@ -173,7 +173,7 @@ protected:
friend class IPTunnelTimer;
Connection* NewConn(HashKey* k, double t, const ConnID* id,
const u_char* data, int proto, uint32 flow_label,
const u_char* data, int proto, uint32_t flow_label,
const Packet* pkt, const EncapsulationStack* encapsulation);
// Check whether the tag of the current packet is consistent with
@ -189,7 +189,7 @@ protected:
// generally a likely server port, false otherwise.
//
// Note, port is in host order.
bool IsLikelyServerPort(uint32 port,
bool IsLikelyServerPort(uint32_t port,
TransportProto transport_proto) const;
// Upon seeing the first packet of a connection, checks whether
@ -197,9 +197,9 @@ protected:
// connections), and, if yes, whether we should flip the roles of
// originator and responder (based on known ports or such).
// Use tcp_flags=0 for non-TCP.
bool WantConnection(uint16 src_port, uint16 dest_port,
bool WantConnection(uint16_t src_port, uint16_t dest_port,
TransportProto transport_proto,
uint8 tcp_flags, bool& flip_roles);
uint8_t tcp_flags, bool& flip_roles);
// Record the given packet (if a dumper is active). If len=0
// then the whole packet is recorded, otherwise just the first
@ -209,7 +209,7 @@ protected:
// For a given protocol, checks whether the header's length as derived
// from lower-level headers or the length actually captured is less
// than that protocol's minimum header size.
bool CheckHeaderTrunc(int proto, uint32 len, uint32 caplen,
bool CheckHeaderTrunc(int proto, uint32_t len, uint32_t caplen,
const Packet *pkt, const EncapsulationStack* encap);
CompositeHash* ch;
@ -229,7 +229,7 @@ protected:
Discarder* discarder;
PacketFilter* packet_filter;
int dump_this_packet; // if true, current packet should be recorded
uint64 num_packets_processed;
uint64_t num_packets_processed;
PacketProfiler* pkt_profiler;
// We may use independent timer managers for different sets of related

View file

@ -11,12 +11,12 @@
#include "threading/Manager.h"
#include "broker/Manager.h"
uint64 killed_by_inactivity = 0;
uint64_t killed_by_inactivity = 0;
uint64 tot_ack_events = 0;
uint64 tot_ack_bytes = 0;
uint64 tot_gap_events = 0;
uint64 tot_gap_bytes = 0;
uint64_t tot_ack_events = 0;
uint64_t tot_ack_bytes = 0;
uint64_t tot_gap_events = 0;
uint64_t tot_gap_bytes = 0;
class ProfileTimer : public Timer {
@ -79,7 +79,7 @@ void ProfileLogger::Log()
struct timeval tv_utime = r.ru_utime;
struct timeval tv_stime = r.ru_stime;
uint64 total, malloced;
uint64_t total, malloced;
get_memory_usage(&total, &malloced);
static unsigned int first_total = 0;
@ -460,7 +460,7 @@ void PacketProfiler::ProfilePkt(double t, unsigned int bytes)
double curr_Rtime =
ptimestamp.tv_sec + ptimestamp.tv_usec / 1e6;
uint64 curr_mem;
uint64_t curr_mem;
get_memory_usage(&curr_mem, 0);
file->Write(fmt("%.06f %.03f %" PRIu64 " %" PRIu64 " %.03f %.03f %.03f %" PRIu64 "\n",

View file

@ -102,13 +102,13 @@ extern ProfileLogger* segment_logger;
extern SampleLogger* sample_logger;
// Connection statistics.
extern uint64 killed_by_inactivity;
extern uint64_t killed_by_inactivity;
// Content gap statistics.
extern uint64 tot_ack_events;
extern uint64 tot_ack_bytes;
extern uint64 tot_gap_events;
extern uint64 tot_gap_bytes;
extern uint64_t tot_ack_events;
extern uint64_t tot_ack_bytes;
extern uint64_t tot_gap_events;
extern uint64_t tot_gap_bytes;
class PacketProfiler {
public:
@ -127,9 +127,9 @@ protected:
double update_freq;
double last_Utime, last_Stime, last_Rtime;
double last_timestamp, time;
uint64 last_mem;
uint64 pkt_cnt;
uint64 byte_cnt;
uint64_t last_mem;
uint64_t pkt_cnt;
uint64_t byte_cnt;
};
#endif

View file

@ -54,7 +54,7 @@ public:
void RegisterAccess() const { last_access = network_time; access_count++; }
void AccessStats(ODesc* d) const;
uint32 GetAccessCount() const { return access_count; }
uint32_t GetAccessCount() const { return access_count; }
void Describe(ODesc* d) const override;
@ -83,7 +83,7 @@ protected:
// FIXME: Learn the exact semantics of mutable.
mutable double last_access; // time of last execution
mutable uint32 access_count; // number of executions
mutable uint32_t access_count; // number of executions
};
class ExprListStmt : public Stmt {

View file

@ -9,7 +9,7 @@ Tag::Tag(EnumType* etype, type_t arg_type, subtype_t arg_subtype)
type = arg_type;
subtype = arg_subtype;
int64_t i = (int64)(type) | ((int64)subtype << 31);
int64_t i = (int64_t)(type) | ((int64_t)subtype << 31);
Ref(etype);
val = etype->GetVal(i);
}
@ -21,7 +21,7 @@ Tag::Tag(EnumVal* arg_val)
val = arg_val;
Ref(val);
int64 i = val->InternalInt();
int64_t i = val->InternalInt();
type = i & 0xffffffff;
subtype = (i >> 31) & 0xffffffff;
}

View file

@ -32,12 +32,12 @@ public:
/**
* Type for the analyzer's main type.
*/
typedef uint32 type_t;
typedef uint32_t type_t;
/**
* Type for the analyzer's subtype.
*/
typedef uint32 subtype_t;
typedef uint32_t subtype_t;
/**
* Returns the tag's main type.

View file

@ -102,7 +102,7 @@ public:
virtual int Size() const = 0;
virtual int PeakSize() const = 0;
virtual uint64 CumulativeNum() const = 0;
virtual uint64_t CumulativeNum() const = 0;
double LastTimestamp() const { return last_timestamp; }
// Returns time of last advance in global network time.
@ -142,7 +142,7 @@ public:
int Size() const override { return q->Size(); }
int PeakSize() const override { return q->PeakSize(); }
uint64 CumulativeNum() const override { return q->CumulativeNum(); }
uint64_t CumulativeNum() const override { return q->CumulativeNum(); }
protected:
int DoAdvance(double t, int max_expire) override;
@ -164,7 +164,7 @@ public:
int Size() const override { return cq_size(cq); }
int PeakSize() const override { return cq_max_size(cq); }
uint64 CumulativeNum() const override { return cq_cumulative_num(cq); }
uint64_t CumulativeNum() const override { return cq_cumulative_num(cq); }
unsigned int MemoryUsage() const;
protected:

View file

@ -116,8 +116,8 @@ public:
protected:
IPAddr src_addr;
IPAddr dst_addr;
uint16 src_port;
uint16 dst_port;
uint16_t src_port;
uint16_t dst_port;
TransportProto proto;
BifEnum::Tunnel::Type type;
Bro::UID uid;

View file

@ -7,7 +7,7 @@
using namespace Bro;
using namespace std;
void UID::Set(bro_uint_t bits, const uint64* v, size_t n)
void UID::Set(bro_uint_t bits, const uint64_t* v, size_t n)
{
initialized = true;

View file

@ -28,7 +28,7 @@ public:
* Construct a UID of a given bit-length, optionally from given values.
* @see UID::Set
*/
explicit UID(bro_uint_t bits, const uint64* v = 0, size_t n = 0)
explicit UID(bro_uint_t bits, const uint64_t* v = 0, size_t n = 0)
{ Set(bits, v, n); }
/**
@ -47,7 +47,7 @@ public:
* 64, then a value is truncated to bit in desired bit-length.
* @param n number of 64-bit elements in array pointed to by \a v.
*/
void Set(bro_uint_t bits, const uint64* v = 0, size_t n = 0);
void Set(bro_uint_t bits, const uint64_t* v = 0, size_t n = 0);
/**
* Returns a base62 (characters 0-9, A-Z, a-z) representation of the UID.
@ -81,7 +81,7 @@ public:
{ return ! ( u1 == u2 ); }
private:
uint64 uid[BRO_UID_LEN];
uint64_t uid[BRO_UID_LEN];
bool initialized; // Since technically uid == 0 is a legit UID
};

View file

@ -701,17 +701,17 @@ void IntervalVal::ValDescribe(ODesc* d) const
DO_UNIT(Microseconds, "usec")
}
PortVal* PortManager::Get(uint32 port_num) const
PortVal* PortManager::Get(uint32_t port_num) const
{
return val_mgr->GetPort(port_num);
}
PortVal* PortManager::Get(uint32 port_num, TransportProto port_type) const
PortVal* PortManager::Get(uint32_t port_num, TransportProto port_type) const
{
return val_mgr->GetPort(port_num, port_type);
}
uint32 PortVal::Mask(uint32 port_num, TransportProto port_type)
uint32_t PortVal::Mask(uint32_t port_num, TransportProto port_type)
{
// Note, for ICMP one-way connections:
// src_port = icmp_type, dst_port = icmp_code.
@ -742,18 +742,18 @@ uint32 PortVal::Mask(uint32 port_num, TransportProto port_type)
return port_num;
}
PortVal::PortVal(uint32 p, TransportProto port_type) : Val(TYPE_PORT)
PortVal::PortVal(uint32_t p, TransportProto port_type) : Val(TYPE_PORT)
{
auto port_num = PortVal::Mask(p, port_type);
val.uint_val = static_cast<bro_uint_t>(port_num);
}
PortVal::PortVal(uint32 p, bool unused) : Val(TYPE_PORT)
PortVal::PortVal(uint32_t p, bool unused) : Val(TYPE_PORT)
{
val.uint_val = static_cast<bro_uint_t>(p);
}
PortVal::PortVal(uint32 p) : Val(TYPE_PORT)
PortVal::PortVal(uint32_t p) : Val(TYPE_PORT)
{
if ( p >= 65536 * NUM_PORT_SPACES )
{
@ -764,9 +764,9 @@ PortVal::PortVal(uint32 p) : Val(TYPE_PORT)
val.uint_val = static_cast<bro_uint_t>(p);
}
uint32 PortVal::Port() const
uint32_t PortVal::Port() const
{
uint32 p = static_cast<uint32>(val.uint_val);
uint32_t p = static_cast<uint32_t>(val.uint_val);
return p & ~PORT_SPACE_MASK;
}
@ -799,7 +799,7 @@ int PortVal::IsICMP() const
void PortVal::ValDescribe(ODesc* d) const
{
uint32 p = static_cast<uint32>(val.uint_val);
uint32_t p = static_cast<uint32_t>(val.uint_val);
d->Add(p & ~PORT_SPACE_MASK);
d->Add("/");
d->Add(Protocol());
@ -821,13 +821,13 @@ AddrVal::AddrVal(const std::string& text) : Val(TYPE_ADDR)
val.addr_val = new IPAddr(text);
}
AddrVal::AddrVal(uint32 addr) : Val(TYPE_ADDR)
AddrVal::AddrVal(uint32_t addr) : Val(TYPE_ADDR)
{
// ### perhaps do gethostbyaddr here?
val.addr_val = new IPAddr(IPv4, &addr, IPAddr::Network);
}
AddrVal::AddrVal(const uint32 addr[4]) : Val(TYPE_ADDR)
AddrVal::AddrVal(const uint32_t addr[4]) : Val(TYPE_ADDR)
{
val.addr_val = new IPAddr(IPv6, addr, IPAddr::Network);
}
@ -874,13 +874,13 @@ SubNetVal::SubNetVal(const char* text, int width) : Val(TYPE_SUBNET)
val.subnet_val = new IPPrefix(text, width);
}
SubNetVal::SubNetVal(uint32 addr, int width) : Val(TYPE_SUBNET)
SubNetVal::SubNetVal(uint32_t addr, int width) : Val(TYPE_SUBNET)
{
IPAddr a(IPv4, &addr, IPAddr::Network);
val.subnet_val = new IPPrefix(a, width);
}
SubNetVal::SubNetVal(const uint32* addr, int width) : Val(TYPE_SUBNET)
SubNetVal::SubNetVal(const uint32_t* addr, int width) : Val(TYPE_SUBNET)
{
IPAddr a(IPv6, addr, IPAddr::Network);
val.subnet_val = new IPPrefix(a, width);
@ -933,17 +933,17 @@ IPAddr SubNetVal::Mask() const
{
// We need to special-case a mask width of zero, since
// the compiler doesn't guarantee that 1 << 32 yields 0.
uint32 m[4];
uint32_t m[4];
for ( unsigned int i = 0; i < 4; ++i )
m[i] = 0;
IPAddr rval(IPv6, m, IPAddr::Host);
return rval;
}
uint32 m[4];
uint32* mp = m;
uint32_t m[4];
uint32_t* mp = m;
uint32 w;
uint32_t w;
for ( w = val.subnet_val->Length(); w >= 32; w -= 32 )
*(mp++) = 0xffffffff;
@ -3229,7 +3229,7 @@ StringVal* ValManager::GetEmptyString() const
return empty_string;
}
PortVal* ValManager::GetPort(uint32 port_num, TransportProto port_type) const
PortVal* ValManager::GetPort(uint32_t port_num, TransportProto port_type) const
{
if ( port_num >= 65536 )
{
@ -3242,7 +3242,7 @@ PortVal* ValManager::GetPort(uint32 port_num, TransportProto port_type) const
return rval;
}
PortVal* ValManager::GetPort(uint32 port_num) const
PortVal* ValManager::GetPort(uint32_t port_num) const
{
auto mask = port_num & PORT_SPACE_MASK;
port_num &= ~PORT_SPACE_MASK;

View file

@ -97,7 +97,7 @@ public:
}
ZEEK_DEPRECATED("Remove in v3.1: use val_mgr->GetBool, GetFalse/GetTrue, GetInt, or GetCount instead")
Val(int32 i, TypeTag t)
Val(int32_t i, TypeTag t)
{
val.int_val = bro_int_t(i);
type = base_type(t);
@ -107,7 +107,7 @@ public:
}
ZEEK_DEPRECATED("Remove in v3.1: use val_mgr->GetBool, GetFalse/GetTrue, GetInt, or GetCount instead")
Val(uint32 u, TypeTag t)
Val(uint32_t u, TypeTag t)
{
val.uint_val = bro_uint_t(u);
type = base_type(t);
@ -117,7 +117,7 @@ public:
}
ZEEK_DEPRECATED("Remove in v3.1: use val_mgr->GetBool, GetFalse/GetTrue, GetInt, or GetCount instead")
Val(int64 i, TypeTag t)
Val(int64_t i, TypeTag t)
{
val.int_val = i;
type = base_type(t);
@ -127,7 +127,7 @@ public:
}
ZEEK_DEPRECATED("Remove in v3.1: use val_mgr->GetBool, GetFalse/GetTrue, GetInt, or GetCount instead")
Val(uint64 u, TypeTag t)
Val(uint64_t u, TypeTag t)
{
val.uint_val = u;
type = base_type(t);
@ -434,15 +434,15 @@ class PortManager {
public:
// Port number given in host order.
ZEEK_DEPRECATED("Remove in v3.1: use val_mgr->GetPort() instead")
PortVal* Get(uint32 port_num, TransportProto port_type) const;
PortVal* Get(uint32_t port_num, TransportProto port_type) const;
// Host-order port number already masked with port space protocol mask.
ZEEK_DEPRECATED("Remove in v3.1: use val_mgr->GetPort() instead")
PortVal* Get(uint32 port_num) const;
PortVal* Get(uint32_t port_num) const;
// Returns a masked port number
ZEEK_DEPRECATED("Remove in v3.1: use PortVal::Mask() instead")
uint32 Mask(uint32 port_num, TransportProto port_type) const;
uint32_t Mask(uint32_t port_num, TransportProto port_type) const;
};
extern PortManager* port_mgr;
@ -471,13 +471,13 @@ public:
inline Val* GetBool(bool b) const
{ return b ? b_true->Ref() : b_false->Ref(); }
inline Val* GetInt(int64 i) const
inline Val* GetInt(int64_t i) const
{
return i < PREALLOCATED_INT_LOWEST || i > PREALLOCATED_INT_HIGHEST ?
Val::MakeInt(i) : ints[i - PREALLOCATED_INT_LOWEST]->Ref();
}
inline Val* GetCount(uint64 i) const
inline Val* GetCount(uint64_t i) const
{
return i >= PREALLOCATED_COUNTS ? Val::MakeCount(i) : counts[i]->Ref();
}
@ -485,10 +485,10 @@ public:
StringVal* GetEmptyString() const;
// Port number given in host order.
PortVal* GetPort(uint32 port_num, TransportProto port_type) const;
PortVal* GetPort(uint32_t port_num, TransportProto port_type) const;
// Host-order port number already masked with port space protocol mask.
PortVal* GetPort(uint32 port_num) const;
PortVal* GetPort(uint32_t port_num) const;
private:
@ -524,16 +524,16 @@ class PortVal : public Val {
public:
// Port number given in host order.
ZEEK_DEPRECATED("Remove in v3.1: use val_mgr->GetPort() instead")
PortVal(uint32 p, TransportProto port_type);
PortVal(uint32_t p, TransportProto port_type);
// Host-order port number already masked with port space protocol mask.
ZEEK_DEPRECATED("Remove in v3.1: use val_mgr->GetPort() instead")
explicit PortVal(uint32 p);
explicit PortVal(uint32_t p);
Val* SizeVal() const override { return val_mgr->GetInt(val.uint_val); }
// Returns the port number in host order (not including the mask).
uint32 Port() const;
uint32_t Port() const;
string Protocol() const;
// Tests for protocol types.
@ -554,13 +554,13 @@ public:
}
// Returns a masked port number
static uint32 Mask(uint32 port_num, TransportProto port_type);
static uint32_t Mask(uint32_t port_num, TransportProto port_type);
protected:
friend class Val;
friend class ValManager;
PortVal() {}
PortVal(uint32 p, bool unused);
PortVal(uint32_t p, bool unused);
void ValDescribe(ODesc* d) const override;
Val* DoClone(CloneState* state) override;
@ -575,8 +575,8 @@ public:
Val* SizeVal() const override;
// Constructor for address already in network order.
explicit AddrVal(uint32 addr); // IPv4.
explicit AddrVal(const uint32 addr[4]); // IPv6.
explicit AddrVal(uint32_t addr); // IPv4.
explicit AddrVal(const uint32_t addr[4]); // IPv6.
explicit AddrVal(const IPAddr& addr);
unsigned int MemoryAllocation() const override;
@ -594,8 +594,8 @@ class SubNetVal : public Val {
public:
explicit SubNetVal(const char* text);
SubNetVal(const char* text, int width);
SubNetVal(uint32 addr, int width); // IPv4.
SubNetVal(const uint32 addr[4], int width); // IPv6.
SubNetVal(uint32_t addr, int width); // IPv4.
SubNetVal(const uint32_t addr[4], int width); // IPv6.
SubNetVal(const IPAddr& addr, int width);
explicit SubNetVal(const IPPrefix& prefix);
~SubNetVal() override;
@ -1034,7 +1034,7 @@ public:
~VectorVal() override;
Val* SizeVal() const override
{ return val_mgr->GetCount(uint32(val.vector_val->size())); }
{ return val_mgr->GetCount(uint32_t(val.vector_val->size())); }
// Returns false if the type of the argument was wrong.
// The vector will automatically grow to accomodate the index.

View file

@ -204,7 +204,7 @@ void Analyzer::Done()
finished = true;
}
void Analyzer::NextPacket(int len, const u_char* data, bool is_orig, uint64 seq,
void Analyzer::NextPacket(int len, const u_char* data, bool is_orig, uint64_t seq,
const IP_Hdr* ip, int caplen)
{
if ( skip )
@ -251,7 +251,7 @@ void Analyzer::NextStream(int len, const u_char* data, bool is_orig)
}
}
void Analyzer::NextUndelivered(uint64 seq, int len, bool is_orig)
void Analyzer::NextUndelivered(uint64_t seq, int len, bool is_orig)
{
if ( skip )
return;
@ -288,7 +288,7 @@ void Analyzer::NextEndOfData(bool is_orig)
}
void Analyzer::ForwardPacket(int len, const u_char* data, bool is_orig,
uint64 seq, const IP_Hdr* ip, int caplen)
uint64_t seq, const IP_Hdr* ip, int caplen)
{
if ( output_handler )
output_handler->DeliverPacket(len, data, is_orig, seq,
@ -336,7 +336,7 @@ void Analyzer::ForwardStream(int len, const u_char* data, bool is_orig)
AppendNewChildren();
}
void Analyzer::ForwardUndelivered(uint64 seq, int len, bool is_orig)
void Analyzer::ForwardUndelivered(uint64_t seq, int len, bool is_orig)
{
if ( output_handler )
output_handler->Undelivered(seq, len, is_orig);
@ -610,7 +610,7 @@ SupportAnalyzer* Analyzer::FirstSupportAnalyzer(bool orig)
}
void Analyzer::DeliverPacket(int len, const u_char* data, bool is_orig,
uint64 seq, const IP_Hdr* ip, int caplen)
uint64_t seq, const IP_Hdr* ip, int caplen)
{
DBG_LOG(DBG_ANALYZER, "%s DeliverPacket(%d, %s, %" PRIu64", %p, %d) [%s%s]",
fmt_analyzer(this).c_str(), len, is_orig ? "T" : "F", seq, ip, caplen,
@ -624,7 +624,7 @@ void Analyzer::DeliverStream(int len, const u_char* data, bool is_orig)
fmt_bytes((const char*) data, min(40, len)), len > 40 ? "..." : "");
}
void Analyzer::Undelivered(uint64 seq, int len, bool is_orig)
void Analyzer::Undelivered(uint64_t seq, int len, bool is_orig)
{
DBG_LOG(DBG_ANALYZER, "%s Undelivered(%" PRIu64", %d, %s)",
fmt_analyzer(this).c_str(), seq, len, is_orig ? "T" : "F");
@ -816,7 +816,7 @@ SupportAnalyzer* SupportAnalyzer::Sibling(bool only_active) const
}
void SupportAnalyzer::ForwardPacket(int len, const u_char* data, bool is_orig,
uint64 seq, const IP_Hdr* ip, int caplen)
uint64_t seq, const IP_Hdr* ip, int caplen)
{
// We do not call parent's method, as we're replacing the functionality.
@ -857,7 +857,7 @@ void SupportAnalyzer::ForwardStream(int len, const u_char* data, bool is_orig)
Parent()->DeliverStream(len, data, is_orig);
}
void SupportAnalyzer::ForwardUndelivered(uint64 seq, int len, bool is_orig)
void SupportAnalyzer::ForwardUndelivered(uint64_t seq, int len, bool is_orig)
{
// We do not call parent's method, as we're replacing the functionality.

View file

@ -26,7 +26,7 @@ class SupportAnalyzer;
class OutputHandler;
typedef list<Analyzer*> analyzer_list;
typedef uint32 ID;
typedef uint32_t ID;
typedef void (Analyzer::*analyzer_timer_func)(double t);
/**
@ -44,7 +44,7 @@ public:
* Analyzer::DeliverPacket().
*/
virtual void DeliverPacket(int len, const u_char* data,
bool orig, uint64 seq,
bool orig, uint64_t seq,
const IP_Hdr* ip, int caplen)
{ }
@ -59,7 +59,7 @@ public:
* Hook for receiving notification of stream gaps. Parameters are the
* same as for Analyzer::Undelivered().
*/
virtual void Undelivered(uint64 seq, int len, bool orig) { }
virtual void Undelivered(uint64_t seq, int len, bool orig) { }
};
/**
@ -143,7 +143,7 @@ public:
* @param caplen The packet's capture length, if available.
*/
void NextPacket(int len, const u_char* data, bool is_orig,
uint64 seq = -1, const IP_Hdr* ip = 0, int caplen = 0);
uint64_t seq = -1, const IP_Hdr* ip = 0, int caplen = 0);
/**
* Passes stream input to the analyzer for processing. The analyzer
@ -173,7 +173,7 @@ public:
*
* @param is_orig True if this is about originator-side input.
*/
void NextUndelivered(uint64 seq, int len, bool is_orig);
void NextUndelivered(uint64_t seq, int len, bool is_orig);
/**
* Reports a message boundary. This is a generic method that can be
@ -195,7 +195,7 @@ public:
* Parameters are the same as for NextPacket().
*/
virtual void ForwardPacket(int len, const u_char* data,
bool orig, uint64 seq,
bool orig, uint64_t seq,
const IP_Hdr* ip, int caplen);
/**
@ -212,7 +212,7 @@ public:
*
* Parameters are the same as for NextUndelivered().
*/
virtual void ForwardUndelivered(uint64 seq, int len, bool orig);
virtual void ForwardUndelivered(uint64_t seq, int len, bool orig);
/**
* Forwards an end-of-data notification on to all child analyzers.
@ -227,7 +227,7 @@ public:
* Parameters are the same.
*/
virtual void DeliverPacket(int len, const u_char* data, bool orig,
uint64 seq, const IP_Hdr* ip, int caplen);
uint64_t seq, const IP_Hdr* ip, int caplen);
/**
* Hook for accessing stream input for parsing. This is called by
@ -241,7 +241,7 @@ public:
* NextUndelivered() and can be overridden by derived classes.
* Parameters are the same.
*/
virtual void Undelivered(uint64 seq, int len, bool orig);
virtual void Undelivered(uint64_t seq, int len, bool orig);
/**
* Hook for accessing end-of-data notifications. This is called by
@ -768,7 +768,7 @@ public:
* Parameters same as for Analyzer::ForwardPacket.
*/
void ForwardPacket(int len, const u_char* data, bool orig,
uint64 seq, const IP_Hdr* ip, int caplen) override;
uint64_t seq, const IP_Hdr* ip, int caplen) override;
/**
* Passes stream input to the next sibling SupportAnalyzer if any, or
@ -788,7 +788,7 @@ public:
*
* Parameters same as for Analyzer::ForwardPacket.
*/
void ForwardUndelivered(uint64 seq, int len, bool orig) override;
void ForwardUndelivered(uint64_t seq, int len, bool orig) override;
protected:
friend class Analyzer;

View file

@ -19,7 +19,7 @@
using namespace analyzer;
Manager::ConnIndex::ConnIndex(const IPAddr& _orig, const IPAddr& _resp,
uint16 _resp_p, uint16 _proto)
uint16_t _resp_p, uint16_t _proto)
{
if ( _orig == IPAddr(string("0.0.0.0")) )
// don't use the IPv4 mapping, use the literal unspecified address
@ -255,7 +255,7 @@ bool Manager::UnregisterAnalyzerForPort(EnumVal* val, PortVal* port)
return UnregisterAnalyzerForPort(p->Tag(), port->PortType(), port->Port());
}
bool Manager::RegisterAnalyzerForPort(Tag tag, TransportProto proto, uint32 port)
bool Manager::RegisterAnalyzerForPort(Tag tag, TransportProto proto, uint32_t port)
{
tag_set* l = LookupPort(proto, port, true);
@ -271,7 +271,7 @@ bool Manager::RegisterAnalyzerForPort(Tag tag, TransportProto proto, uint32 port
return true;
}
bool Manager::UnregisterAnalyzerForPort(Tag tag, TransportProto proto, uint32 port)
bool Manager::UnregisterAnalyzerForPort(Tag tag, TransportProto proto, uint32_t port)
{
tag_set* l = LookupPort(proto, port, true);
@ -326,7 +326,7 @@ Analyzer* Manager::InstantiateAnalyzer(const char* name, Connection* conn)
return tag ? InstantiateAnalyzer(tag, conn) : 0;
}
Manager::tag_set* Manager::LookupPort(TransportProto proto, uint32 port, bool add_if_not_found)
Manager::tag_set* Manager::LookupPort(TransportProto proto, uint32_t port, bool add_if_not_found)
{
analyzer_map_by_port* m = 0;
@ -464,7 +464,7 @@ bool Manager::BuildInitialAnalyzerTree(Connection* conn)
// handle non-reassembled data, it doesn't really fit into
// our general framing ... Better would be to turn it
// on *after* we discover we have interactive traffic.
uint16 resp_port = ntohs(conn->RespPort());
uint16_t resp_port = ntohs(conn->RespPort());
if ( resp_port == 22 || resp_port == 23 || resp_port == 513 )
{
AddrVal src(conn->OrigAddr());
@ -541,7 +541,7 @@ void Manager::ExpireScheduledAnalyzers()
}
void Manager::ScheduleAnalyzer(const IPAddr& orig, const IPAddr& resp,
uint16 resp_p,
uint16_t resp_p,
TransportProto proto, Tag analyzer,
double timeout)
{
@ -566,7 +566,7 @@ void Manager::ScheduleAnalyzer(const IPAddr& orig, const IPAddr& resp,
}
void Manager::ScheduleAnalyzer(const IPAddr& orig, const IPAddr& resp,
uint16 resp_p,
uint16_t resp_p,
TransportProto proto, const char* analyzer,
double timeout)
{

View file

@ -180,7 +180,7 @@ public:
*
* @return True if successful.
*/
bool RegisterAnalyzerForPort(Tag tag, TransportProto proto, uint32 port);
bool RegisterAnalyzerForPort(Tag tag, TransportProto proto, uint32_t port);
/**
* Unregisters a well-known port for an anlyzers.
@ -208,7 +208,7 @@ public:
* @param tag The analyzer's tag as an enum of script type \c
* Analyzer::Tag.
*/
bool UnregisterAnalyzerForPort(Tag tag, TransportProto proto, uint32 port);
bool UnregisterAnalyzerForPort(Tag tag, TransportProto proto, uint32_t port);
/**
* Instantiates a new analyzer instance for a connection.
@ -269,7 +269,7 @@ public:
* @param timeout An interval after which to timeout the request to
* schedule this analyzer. Must be non-zero.
*/
void ScheduleAnalyzer(const IPAddr& orig, const IPAddr& resp, uint16 resp_p,
void ScheduleAnalyzer(const IPAddr& orig, const IPAddr& resp, uint16_t resp_p,
TransportProto proto, Tag analyzer, double timeout);
/**
@ -293,7 +293,7 @@ public:
* @param timeout An interval after which to timeout the request to
* schedule this analyzer. Must be non-zero.
*/
void ScheduleAnalyzer(const IPAddr& orig, const IPAddr& resp, uint16 resp_p,
void ScheduleAnalyzer(const IPAddr& orig, const IPAddr& resp, uint16_t resp_p,
TransportProto proto, const char* analyzer,
double timeout);
@ -339,15 +339,15 @@ public:
/**
* @return the UDP port numbers to be associated with VXLAN traffic.
*/
const std::vector<uint16>& GetVxlanPorts() const
const std::vector<uint16_t>& GetVxlanPorts() const
{ return vxlan_ports; }
private:
typedef set<Tag> tag_set;
typedef map<uint32, tag_set*> analyzer_map_by_port;
typedef map<uint32_t, tag_set*> analyzer_map_by_port;
tag_set* LookupPort(PortVal* val, bool add_if_not_found);
tag_set* LookupPort(TransportProto proto, uint32 port, bool add_if_not_found);
tag_set* LookupPort(TransportProto proto, uint32_t port, bool add_if_not_found);
tag_set GetScheduled(const Connection* conn);
void ExpireScheduledAnalyzers();
@ -365,11 +365,11 @@ private:
struct ConnIndex {
IPAddr orig;
IPAddr resp;
uint16 resp_p;
uint16 proto;
uint16_t resp_p;
uint16_t proto;
ConnIndex(const IPAddr& _orig, const IPAddr& _resp,
uint16 _resp_p, uint16 _proto);
uint16_t _resp_p, uint16_t _proto);
ConnIndex();
bool operator<(const ConnIndex& other) const;
@ -395,7 +395,7 @@ private:
conns_map conns;
conns_queue conns_by_timeout;
std::vector<uint16> vxlan_ports;
std::vector<uint16_t> vxlan_ports;
};
}

View file

@ -225,7 +225,7 @@ void ARP_Analyzer::RREvent(EventHandlerPtr e,
AddrVal* ARP_Analyzer::ConstructAddrVal(const void* addr)
{
// ### For now, we only handle IPv4 addresses.
return new AddrVal(*(const uint32*) addr);
return new AddrVal(*(const uint32_t*) addr);
}
StringVal* ARP_Analyzer::EthAddrToStr(const u_char* addr)

View file

@ -21,7 +21,7 @@ void AYIYA_Analyzer::Done()
Event(udp_session_done);
}
void AYIYA_Analyzer::DeliverPacket(int len, const u_char* data, bool orig, uint64 seq, const IP_Hdr* ip, int caplen)
void AYIYA_Analyzer::DeliverPacket(int len, const u_char* data, bool orig, uint64_t seq, const IP_Hdr* ip, int caplen)
{
Analyzer::DeliverPacket(len, data, orig, seq, ip, caplen);

View file

@ -12,7 +12,7 @@ public:
virtual void Done();
virtual void DeliverPacket(int len, const u_char* data, bool orig,
uint64 seq, const IP_Hdr* ip, int caplen);
uint64_t seq, const IP_Hdr* ip, int caplen);
static analyzer::Analyzer* Instantiate(Connection* conn)
{ return new AYIYA_Analyzer(conn); }

View file

@ -30,7 +30,7 @@ void BitTorrent_Analyzer::Done()
void BitTorrent_Analyzer::DeliverStream(int len, const u_char* data, bool orig)
{
uint64& this_stream_len = orig ? stream_len_orig : stream_len_resp;
uint64_t& this_stream_len = orig ? stream_len_orig : stream_len_resp;
bool& this_stop = orig ? stop_orig : stop_resp;
tcp::TCP_ApplicationAnalyzer::DeliverStream(len, data, orig);
@ -68,7 +68,7 @@ void BitTorrent_Analyzer::DeliverStream(int len, const u_char* data, bool orig)
}
}
void BitTorrent_Analyzer::Undelivered(uint64 seq, int len, bool orig)
void BitTorrent_Analyzer::Undelivered(uint64_t seq, int len, bool orig)
{
tcp::TCP_ApplicationAnalyzer::Undelivered(seq, len, orig);
@ -77,10 +77,10 @@ void BitTorrent_Analyzer::Undelivered(uint64 seq, int len, bool orig)
// The way it's currently tracking the next message offset isn't
// compatible with new 64bit int support in binpac either.
//uint64 entry_offset = orig ?
//uint64_t entry_offset = orig ?
// *interp->upflow()->next_message_offset() :
// *interp->downflow()->next_message_offset();
//uint64& this_stream_len = orig ? stream_len_orig : stream_len_resp;
//uint64_t& this_stream_len = orig ? stream_len_orig : stream_len_resp;
//bool& this_stop = orig ? stop_orig : stop_resp;
//
//this_stream_len += len;

View file

@ -16,7 +16,7 @@ public:
void Done() override;
void DeliverStream(int len, const u_char* data, bool orig) override;
void Undelivered(uint64 seq, int len, bool orig) override;
void Undelivered(uint64_t seq, int len, bool orig) override;
void EndpointEOF(bool is_orig) override;
static analyzer::Analyzer* Instantiate(Connection* conn)
@ -27,7 +27,7 @@ protected:
binpac::BitTorrent::BitTorrent_Conn* interp;
bool stop_orig, stop_resp;
uint64 stream_len_orig, stream_len_resp;
uint64_t stream_len_orig, stream_len_resp;
};
} } // namespace analyzer::*

View file

@ -207,7 +207,7 @@ void BitTorrentTracker_Analyzer::ServerReply(int len, const u_char* data)
}
}
void BitTorrentTracker_Analyzer::Undelivered(uint64 seq, int len, bool orig)
void BitTorrentTracker_Analyzer::Undelivered(uint64_t seq, int len, bool orig)
{
tcp::TCP_ApplicationAnalyzer::Undelivered(seq, len, orig);
@ -477,8 +477,8 @@ void BitTorrentTracker_Analyzer::ResponseBenc(int name_len, char* name,
// addresses in network order but PortVal's
// take ports in host order. BitTorrent specifies
// that both are in network order here.
uint32 ad = extract_uint32((u_char*) value);
uint16 pt = ntohs((value[4] << 8) | value[5]);
uint32_t ad = extract_uint32((u_char*) value);
uint16_t pt = ntohs((value[4] << 8) | value[5]);
RecordVal* peer = new RecordVal(bittorrent_peer);
peer->Assign(0, new AddrVal(ad));

View file

@ -49,7 +49,7 @@ public:
void Done() override;
void DeliverStream(int len, const u_char* data, bool orig) override;
void Undelivered(uint64 seq, int len, bool orig) override;
void Undelivered(uint64_t seq, int len, bool orig) override;
void EndpointEOF(bool is_orig) override;
static analyzer::Analyzer* Instantiate(Connection* conn)

View file

@ -43,7 +43,7 @@ void ConnSize_Analyzer::Done()
Analyzer::Done();
}
void ConnSize_Analyzer::ThresholdEvent(EventHandlerPtr f, uint64 threshold, bool is_orig)
void ConnSize_Analyzer::ThresholdEvent(EventHandlerPtr f, uint64_t threshold, bool is_orig)
{
if ( ! f )
return;
@ -100,7 +100,7 @@ void ConnSize_Analyzer::CheckThresholds(bool is_orig)
}
}
void ConnSize_Analyzer::DeliverPacket(int len, const u_char* data, bool is_orig, uint64 seq, const IP_Hdr* ip, int caplen)
void ConnSize_Analyzer::DeliverPacket(int len, const u_char* data, bool is_orig, uint64_t seq, const IP_Hdr* ip, int caplen)
{
Analyzer::DeliverPacket(len, data, is_orig, seq, ip, caplen);
@ -118,7 +118,7 @@ void ConnSize_Analyzer::DeliverPacket(int len, const u_char* data, bool is_orig,
CheckThresholds(is_orig);
}
void ConnSize_Analyzer::SetByteAndPacketThreshold(uint64 threshold, bool bytes, bool orig)
void ConnSize_Analyzer::SetByteAndPacketThreshold(uint64_t threshold, bool bytes, bool orig)
{
if ( bytes )
{

View file

@ -22,7 +22,7 @@ public:
void FlipRoles() override;
void SetByteAndPacketThreshold(uint64_t threshold, bool bytes, bool orig);
uint64 GetByteAndPacketThreshold(bool bytes, bool orig);
uint64_t GetByteAndPacketThreshold(bool bytes, bool orig);
void SetDurationThreshold(double duration);
double GetDurationThreshold() { return duration_thresh; };
@ -32,10 +32,10 @@ public:
protected:
void DeliverPacket(int len, const u_char* data, bool is_orig,
uint64 seq, const IP_Hdr* ip, int caplen) override;
uint64_t seq, const IP_Hdr* ip, int caplen) override;
void CheckThresholds(bool is_orig);
void ThresholdEvent(EventHandlerPtr f, uint64 threshold, bool is_orig);
void ThresholdEvent(EventHandlerPtr f, uint64_t threshold, bool is_orig);
uint64_t orig_bytes;
uint64_t resp_bytes;

View file

@ -39,7 +39,7 @@ void DCE_RPC_Analyzer::EndpointEOF(bool is_orig)
interp->FlowEOF(is_orig);
}
void DCE_RPC_Analyzer::Undelivered(uint64 seq, int len, bool orig)
void DCE_RPC_Analyzer::Undelivered(uint64_t seq, int len, bool orig)
{
TCP_ApplicationAnalyzer::Undelivered(seq, len, orig);
had_gap = true;

View file

@ -19,10 +19,10 @@ public:
void Done() override;
void DeliverStream(int len, const u_char* data, bool orig) override;
void Undelivered(uint64 seq, int len, bool orig) override;
void Undelivered(uint64_t seq, int len, bool orig) override;
void EndpointEOF(bool is_orig) override;
bool SetFileID(uint64 fid_in)
bool SetFileID(uint64_t fid_in)
{ interp->set_file_id(fid_in); return true; }
static analyzer::Analyzer* Instantiate(Connection* conn)

View file

@ -22,7 +22,7 @@ void DHCP_Analyzer::Done()
}
void DHCP_Analyzer::DeliverPacket(int len, const u_char* data,
bool orig, uint64 seq, const IP_Hdr* ip, int caplen)
bool orig, uint64_t seq, const IP_Hdr* ip, int caplen)
{
Analyzer::DeliverPacket(len, data, orig, seq, ip, caplen);

View file

@ -14,7 +14,7 @@ public:
void Done() override;
void DeliverPacket(int len, const u_char* data, bool orig,
uint64 seq, const IP_Hdr* ip, int caplen) override;
uint64_t seq, const IP_Hdr* ip, int caplen) override;
static analyzer::Analyzer* Instantiate(Connection* conn)
{ return new DHCP_Analyzer(conn); }

View file

@ -418,7 +418,7 @@ void DNP3_TCP_Analyzer::DeliverStream(int len, const u_char* data, bool orig)
}
}
void DNP3_TCP_Analyzer::Undelivered(uint64 seq, int len, bool orig)
void DNP3_TCP_Analyzer::Undelivered(uint64_t seq, int len, bool orig)
{
TCP_ApplicationAnalyzer::Undelivered(seq, len, orig);
Interpreter()->NewGap(orig, len);
@ -439,7 +439,7 @@ DNP3_UDP_Analyzer::~DNP3_UDP_Analyzer()
{
}
void DNP3_UDP_Analyzer::DeliverPacket(int len, const u_char* data, bool orig, uint64 seq, const IP_Hdr* ip, int caplen)
void DNP3_UDP_Analyzer::DeliverPacket(int len, const u_char* data, bool orig, uint64_t seq, const IP_Hdr* ip, int caplen)
{
Analyzer::DeliverPacket(len, data, orig, seq, ip, caplen);

View file

@ -69,7 +69,7 @@ public:
void Done() override;
void DeliverStream(int len, const u_char* data, bool orig) override;
void Undelivered(uint64 seq, int len, bool orig) override;
void Undelivered(uint64_t seq, int len, bool orig) override;
void EndpointEOF(bool is_orig) override;
static Analyzer* Instantiate(Connection* conn)
@ -82,7 +82,7 @@ public:
~DNP3_UDP_Analyzer() override;
void DeliverPacket(int len, const u_char* data, bool orig,
uint64 seq, const IP_Hdr* ip, int caplen) override;
uint64_t seq, const IP_Hdr* ip, int caplen) override;
static analyzer::Analyzer* Instantiate(Connection* conn)
{ return new DNP3_UDP_Analyzer(conn); }

View file

@ -77,8 +77,8 @@ event dnp3_header_block%(c: connection, is_orig: bool, len: count, ctrl: count,
## Generated for a DNP3 "Response_Data_Object".
## The "Response_Data_Object" contains two parts: object prefix and object
## data. In most cases, object data are defined by new record types. But
## in a few cases, object data are directly basic types, such as int16, or
## int8; thus we use an additional *data_value* to record the values of those
## in a few cases, object data are directly basic types, such as int16_t, or
## int8_t; thus we use an additional *data_value* to record the values of those
## object data.
##
## c: The connection the DNP3 communication is part of.

View file

@ -475,12 +475,12 @@ int DNS_Interpreter::ExtractLabel(const u_char*& data, int& len,
return 1;
}
uint16 DNS_Interpreter::ExtractShort(const u_char*& data, int& len)
uint16_t DNS_Interpreter::ExtractShort(const u_char*& data, int& len)
{
if ( len < 2 )
return 0;
uint16 val;
uint16_t val;
val = data[0] << 8;
@ -495,12 +495,12 @@ uint16 DNS_Interpreter::ExtractShort(const u_char*& data, int& len)
return val;
}
uint32 DNS_Interpreter::ExtractLong(const u_char*& data, int& len)
uint32_t DNS_Interpreter::ExtractLong(const u_char*& data, int& len)
{
if ( len < 4 )
return 0;
uint32 val;
uint32_t val;
val = data[0] << 24;
val |= data[1] << 16;
@ -588,11 +588,11 @@ int DNS_Interpreter::ParseRR_SOA(DNS_MsgInfo* msg,
if ( len < 20 )
return 0;
uint32 serial = ExtractLong(data, len);
uint32 refresh = ExtractLong(data, len);
uint32 retry = ExtractLong(data, len);
uint32 expire = ExtractLong(data, len);
uint32 minimum = ExtractLong(data, len);
uint32_t serial = ExtractLong(data, len);
uint32_t refresh = ExtractLong(data, len);
uint32_t retry = ExtractLong(data, len);
uint32_t expire = ExtractLong(data, len);
uint32_t minimum = ExtractLong(data, len);
if ( data - data_start != rdlength )
analyzer->Weird("DNS_RR_length_mismatch");
@ -727,7 +727,7 @@ int DNS_Interpreter::ParseRR_EDNS(DNS_MsgInfo* msg,
void DNS_Interpreter::ExtractOctets(const u_char*& data, int& len,
BroString** p)
{
uint16 dlen = ExtractShort(data, len);
uint16_t dlen = ExtractShort(data, len);
dlen = min(len, static_cast<int>(dlen));
if ( p )
@ -762,7 +762,7 @@ int DNS_Interpreter::ParseRR_TSIG(DNS_MsgInfo* msg,
if ( ! alg_name_end )
return 0;
uint32 sign_time_sec = ExtractLong(data, len);
uint32_t sign_time_sec = ExtractLong(data, len);
unsigned int sign_time_msec = ExtractShort(data, len);
unsigned int fudge = ExtractShort(data, len);
BroString* request_MAC;
@ -809,13 +809,13 @@ int DNS_Interpreter::ParseRR_RRSIG(DNS_MsgInfo* msg,
unsigned int type_covered = ExtractShort(data, len);
// split the two bytes for algo and labels extraction
uint32 algo_lab = ExtractShort(data, len);
uint32_t algo_lab = ExtractShort(data, len);
unsigned int algo = (algo_lab >> 8) & 0xff;
unsigned int lab = algo_lab & 0xff;
uint32 orig_ttl = ExtractLong(data, len);
uint32 sign_exp = ExtractLong(data, len);
uint32 sign_incp = ExtractLong(data, len);
uint32_t orig_ttl = ExtractLong(data, len);
uint32_t sign_exp = ExtractLong(data, len);
uint32_t sign_incp = ExtractLong(data, len);
unsigned int key_tag = ExtractShort(data, len);
//implement signer's name with the msg_start offset
@ -1015,7 +1015,7 @@ int DNS_Interpreter::ParseRR_NSEC(DNS_MsgInfo* msg,
while ( typebitmaps_len > 0 && len > 0 )
{
uint32 block_bmlen = ExtractShort(data, len);
uint32_t block_bmlen = ExtractShort(data, len);
unsigned int win_blck = (block_bmlen >> 8) & 0xff;
unsigned int bmlen = block_bmlen & 0xff;
@ -1059,12 +1059,12 @@ int DNS_Interpreter::ParseRR_NSEC3(DNS_MsgInfo* msg,
return 0;
const u_char* data_start = data;
uint32 halgo_flags = ExtractShort(data, len);
uint32_t halgo_flags = ExtractShort(data, len);
unsigned int hash_algo = (halgo_flags >> 8) & 0xff;
unsigned int nsec_flags = halgo_flags & 0xff;
unsigned int iter = ExtractShort(data, len);
uint8 salt_len = 0;
uint8_t salt_len = 0;
if ( len > 0 )
{
@ -1075,7 +1075,7 @@ int DNS_Interpreter::ParseRR_NSEC3(DNS_MsgInfo* msg,
auto salt_val = ExtractStream(data, len, static_cast<int>(salt_len));
uint8 hash_len = 0;
uint8_t hash_len = 0;
if ( len > 0 )
{
@ -1092,7 +1092,7 @@ int DNS_Interpreter::ParseRR_NSEC3(DNS_MsgInfo* msg,
while ( typebitmaps_len > 0 && len > 0 )
{
uint32 block_bmlen = ExtractShort(data, len);
uint32_t block_bmlen = ExtractShort(data, len);
unsigned int win_blck = ( block_bmlen >> 8) & 0xff;
unsigned int bmlen = block_bmlen & 0xff;
@ -1146,7 +1146,7 @@ int DNS_Interpreter::ParseRR_DS(DNS_MsgInfo* msg,
unsigned int ds_key_tag = ExtractShort(data, len);
// split the two bytes for algorithm and digest type extraction
uint32 ds_algo_dtype = ExtractShort(data, len);
uint32_t ds_algo_dtype = ExtractShort(data, len);
unsigned int ds_algo = (ds_algo_dtype >> 8) & 0xff;
unsigned int ds_dtype = ds_algo_dtype & 0xff;
DNSSEC_Digest ds_digest_type = DNSSEC_Digest(ds_dtype);
@ -1197,7 +1197,7 @@ int DNS_Interpreter::ParseRR_A(DNS_MsgInfo* msg,
return 0;
}
uint32 addr = ExtractLong(data, len);
uint32_t addr = ExtractLong(data, len);
if ( dns_A_reply && ! msg->skip_event )
{
@ -1215,7 +1215,7 @@ int DNS_Interpreter::ParseRR_A(DNS_MsgInfo* msg,
int DNS_Interpreter::ParseRR_AAAA(DNS_MsgInfo* msg,
const u_char*& data, int& len, int rdlength)
{
uint32 addr[4];
uint32_t addr[4];
for ( int i = 0; i < 4; ++i )
{
@ -1273,7 +1273,7 @@ static StringVal* extract_char_string(analyzer::Analyzer* analyzer,
if ( rdlen <= 0 )
return 0;
uint8 str_size = data[0];
uint8_t str_size = data[0];
--rdlen;
--len;
@ -1755,7 +1755,7 @@ void DNS_Analyzer::Done()
}
void DNS_Analyzer::DeliverPacket(int len, const u_char* data, bool orig,
uint64 seq, const IP_Hdr* ip, int caplen)
uint64_t seq, const IP_Hdr* ip, int caplen)
{
tcp::TCP_ApplicationAnalyzer::DeliverPacket(len, data, orig, seq, ip, caplen);
interp->ParseMessage(data, len, orig);

View file

@ -143,7 +143,7 @@ struct RRSIG_DATA {
unsigned short type_covered; // 16 : ExtractShort(data, len)
unsigned short algorithm; // 8
unsigned short labels; // 8
uint32 orig_ttl; // 32
uint32_t orig_ttl; // 32
unsigned long sig_exp; // 32
unsigned long sig_incep; // 32
unsigned short key_tag; //16
@ -208,7 +208,7 @@ public:
StringVal* query_name;
RR_Type atype;
int aclass; ///< normally = 1, inet
uint32 ttl;
uint32_t ttl;
DNS_AnswerType answer_type;
int skip_event; ///< if true, don't generate corresponding events
@ -249,8 +249,8 @@ protected:
u_char*& label, int& label_len,
const u_char* msg_start);
uint16 ExtractShort(const u_char*& data, int& len);
uint32 ExtractLong(const u_char*& data, int& len);
uint16_t ExtractShort(const u_char*& data, int& len);
uint32_t ExtractLong(const u_char*& data, int& len);
void ExtractOctets(const u_char*& data, int& len, BroString** p);
BroString* ExtractStream(const u_char*& data, int& len, int sig_len);
@ -353,7 +353,7 @@ public:
~DNS_Analyzer() override;
void DeliverPacket(int len, const u_char* data, bool orig,
uint64 seq, const IP_Hdr* ip, int caplen) override;
uint64_t seq, const IP_Hdr* ip, int caplen) override;
void Init() override;
void Done() override;

View file

@ -40,7 +40,7 @@ void File_Analyzer::DeliverStream(int len, const u_char* data, bool orig)
orig, file_id_resp);
}
void File_Analyzer::Undelivered(uint64 seq, int len, bool orig)
void File_Analyzer::Undelivered(uint64_t seq, int len, bool orig)
{
TCP_ApplicationAnalyzer::Undelivered(seq, len, orig);

View file

@ -17,7 +17,7 @@ public:
void DeliverStream(int len, const u_char* data, bool orig) override;
void Undelivered(uint64 seq, int len, bool orig) override;
void Undelivered(uint64_t seq, int len, bool orig) override;
// static analyzer::Analyzer* Instantiate(Connection* conn)
// { return new File_Analyzer(conn); }

View file

@ -50,7 +50,7 @@ void FTP_Analyzer::Done()
Weird("partial_ftp_request");
}
static uint32 get_reply_code(int len, const char* line)
static uint32_t get_reply_code(int len, const char* line)
{
if ( len >= 3 && isdigit(line[0]) && isdigit(line[1]) && isdigit(line[2]) )
return (line[0] - '0') * 100 + (line[1] - '0') * 10 + (line[2] - '0');
@ -113,7 +113,7 @@ void FTP_Analyzer::DeliverStream(int length, const u_char* data, bool orig)
}
else
{
uint32 reply_code = get_reply_code(length, line);
uint32_t reply_code = get_reply_code(length, line);
int cont_resp;
@ -232,7 +232,7 @@ void FTP_ADAT_Analyzer::DeliverStream(int len, const u_char* data, bool orig)
// that the fourth and fifth bytes indicating the length of
// the record match the length of the decoded data.
if ( msg_len < 5 || msg[0] != 0x16 ||
msg_len - 5 != ntohs(*((uint16*)(msg + 3))) )
msg_len - 5 != ntohs(*((uint16_t*)(msg + 3))) )
{
// Doesn't look like TLS/SSL, so done analyzing.
done = true;
@ -251,7 +251,7 @@ void FTP_ADAT_Analyzer::DeliverStream(int len, const u_char* data, bool orig)
else
{
uint32 reply_code = get_reply_code(len, line);
uint32_t reply_code = get_reply_code(len, line);
switch ( reply_code ) {
case 232:

View file

@ -23,7 +23,7 @@ public:
protected:
login::NVT_Analyzer* nvt_orig;
login::NVT_Analyzer* nvt_resp;
uint32 pending_reply; // code associated with multi-line reply, or 0
uint32_t pending_reply; // code associated with multi-line reply, or 0
string auth_requested; // AUTH method requested
};

View file

@ -21,9 +21,9 @@ static Val* parse_port(const char* line)
break;
}
uint32 addr = (bytes[0] << 24) | (bytes[1] << 16) |
uint32_t addr = (bytes[0] << 24) | (bytes[1] << 16) |
(bytes[2] << 8) | bytes[3];
uint32 port = (bytes[4] << 8) | bytes[5];
uint32_t port = (bytes[4] << 8) | bytes[5];
// Since port is unsigned, no need to check for < 0.
if ( port > 65535 )
@ -38,7 +38,7 @@ static Val* parse_port(const char* line)
}
else
{
r->Assign(0, new AddrVal(uint32(0)));
r->Assign(0, new AddrVal(uint32_t(0)));
r->Assign(1, val_mgr->GetPort(0, TRANSPORT_TCP));
r->Assign(2, val_mgr->GetBool(0));
}
@ -199,12 +199,12 @@ function parse_ftp_epsv%(str: string%): ftp_port
## .. zeek:see:: parse_ftp_port parse_eftp_port parse_ftp_pasv parse_ftp_epsv
function fmt_ftp_port%(a: addr, p: port%): string
%{
const uint32* addr;
const uint32_t* addr;
int len = a->AsAddr().GetBytes(&addr);
if ( len == 1 )
{
uint32 a = ntohl(addr[0]);
uint32 pn = p->Port();
uint32_t a = ntohl(addr[0]);
uint32_t pn = p->Port();
return new StringVal(fmt("%d,%d,%d,%d,%d,%d",
a >> 24, (a >> 16) & 0xff,
(a >> 8) & 0xff, a & 0xff,

View file

@ -49,7 +49,7 @@ void GSSAPI_Analyzer::DeliverStream(int len, const u_char* data, bool orig)
}
}
void GSSAPI_Analyzer::Undelivered(uint64 seq, int len, bool orig)
void GSSAPI_Analyzer::Undelivered(uint64_t seq, int len, bool orig)
{
tcp::TCP_ApplicationAnalyzer::Undelivered(seq, len, orig);
interp->NewGap(orig, len);

View file

@ -22,7 +22,7 @@ public:
void Done() override;
void DeliverStream(int len, const u_char* data, bool orig) override;
void Undelivered(uint64 seq, int len, bool orig) override;
void Undelivered(uint64_t seq, int len, bool orig) override;
// Overriden from tcp::TCP_ApplicationAnalyzer.
void EndpointEOF(bool is_orig) override;

View file

@ -23,7 +23,7 @@ void GTPv1_Analyzer::Done()
Event(udp_session_done);
}
void GTPv1_Analyzer::DeliverPacket(int len, const u_char* data, bool orig, uint64 seq, const IP_Hdr* ip, int caplen)
void GTPv1_Analyzer::DeliverPacket(int len, const u_char* data, bool orig, uint64_t seq, const IP_Hdr* ip, int caplen)
{
Analyzer::DeliverPacket(len, data, orig, seq, ip, caplen);
try

View file

@ -12,7 +12,7 @@ public:
virtual void Done();
virtual void DeliverPacket(int len, const u_char* data, bool orig,
uint64 seq, const IP_Hdr* ip, int caplen);
uint64_t seq, const IP_Hdr* ip, int caplen);
static analyzer::Analyzer* Instantiate(Connection* conn)
{ return new GTPv1_Analyzer(conn); }

View file

@ -1091,7 +1091,7 @@ void HTTP_Analyzer::DeliverStream(int len, const u_char* data, bool is_orig)
}
}
void HTTP_Analyzer::Undelivered(uint64 seq, int len, bool is_orig)
void HTTP_Analyzer::Undelivered(uint64_t seq, int len, bool is_orig)
{
tcp::TCP_ApplicationAnalyzer::Undelivered(seq, len, is_orig);

View file

@ -168,7 +168,7 @@ public:
// Overriden from Analyzer.
void Done() override;
void DeliverStream(int len, const u_char* data, bool orig) override;
void Undelivered(uint64 seq, int len, bool orig) override;
void Undelivered(uint64_t seq, int len, bool orig) override;
// Overriden from tcp::TCP_ApplicationAnalyzer
void EndpointEOF(bool is_orig) override;

View file

@ -31,7 +31,7 @@ void ICMP_Analyzer::Done()
}
void ICMP_Analyzer::DeliverPacket(int len, const u_char* data,
bool is_orig, uint64 seq, const IP_Hdr* ip, int caplen)
bool is_orig, uint64_t seq, const IP_Hdr* ip, int caplen)
{
assert(ip);
@ -238,10 +238,10 @@ RecordVal* ICMP_Analyzer::BuildICMPVal(const struct icmp* icmpp, int len,
return icmp_conn_val;
}
TransportProto ICMP_Analyzer::GetContextProtocol(const IP_Hdr* ip_hdr, uint32* src_port, uint32* dst_port)
TransportProto ICMP_Analyzer::GetContextProtocol(const IP_Hdr* ip_hdr, uint32_t* src_port, uint32_t* dst_port)
{
const u_char* transport_hdr;
uint32 ip_hdr_len = ip_hdr->HdrLen();
uint32_t ip_hdr_len = ip_hdr->HdrLen();
bool ip4 = ip_hdr->IP4_Hdr();
if ( ip4 )
@ -308,15 +308,15 @@ RecordVal* ICMP_Analyzer::ExtractICMP4Context(int len, const u_char*& data)
const IP_Hdr ip_hdr_data((const struct ip*) data, false);
const IP_Hdr* ip_hdr = &ip_hdr_data;
uint32 ip_hdr_len = ip_hdr->HdrLen();
uint32_t ip_hdr_len = ip_hdr->HdrLen();
uint32 ip_len, frag_offset;
uint32_t ip_len, frag_offset;
TransportProto proto = TRANSPORT_UNKNOWN;
int DF, MF, bad_hdr_len, bad_checksum;
IPAddr src_addr, dst_addr;
uint32 src_port, dst_port;
uint32_t src_port, dst_port;
if ( len < (int)sizeof(struct ip) || ip_hdr_len > uint32(len) )
if ( len < (int)sizeof(struct ip) || ip_hdr_len > uint32_t(len) )
{
// We don't have an entire IP header.
bad_hdr_len = 1;
@ -338,7 +338,7 @@ RecordVal* ICMP_Analyzer::ExtractICMP4Context(int len, const u_char*& data)
MF = ip_hdr->MF();
frag_offset = ip_hdr->FragOffset();
if ( uint32(len) >= ip_hdr_len + 4 )
if ( uint32_t(len) >= ip_hdr_len + 4 )
proto = GetContextProtocol(ip_hdr, &src_port, &dst_port);
else
{
@ -376,8 +376,8 @@ RecordVal* ICMP_Analyzer::ExtractICMP6Context(int len, const u_char*& data)
IPAddr src_addr;
IPAddr dst_addr;
uint32 ip_len, frag_offset = 0;
uint32 src_port, dst_port;
uint32_t ip_len, frag_offset = 0;
uint32_t src_port, dst_port;
if ( len < (int)sizeof(struct ip6_hdr) )
{
@ -397,7 +397,7 @@ RecordVal* ICMP_Analyzer::ExtractICMP6Context(int len, const u_char*& data)
MF = ip_hdr->MF();
DF = ip_hdr->DF();
if ( uint32(len) >= uint32(ip_hdr->HdrLen() + 4) )
if ( uint32_t(len) >= uint32_t(ip_hdr->HdrLen() + 4) )
proto = GetContextProtocol(ip_hdr, &src_port, &dst_port);
else
{
@ -530,7 +530,7 @@ void ICMP_Analyzer::RouterAdvert(double t, const struct icmp* icmpp, int len,
if ( ! f )
return;
uint32 reachable = 0, retrans = 0;
uint32_t reachable = 0, retrans = 0;
if ( caplen >= (int)sizeof(reachable) )
memcpy(&reachable, data, sizeof(reachable));
@ -744,8 +744,8 @@ VectorVal* ICMP_Analyzer::BuildNDOptionsVal(int caplen, const u_char* data)
break;
}
uint8 type = *((const uint8*)data);
uint8 length = *((const uint8*)(data + 1));
uint8_t type = *((const uint8_t*)data);
uint8_t length = *((const uint8_t*)(data + 1));
if ( length == 0 )
{
@ -788,11 +788,11 @@ VectorVal* ICMP_Analyzer::BuildNDOptionsVal(int caplen, const u_char* data)
if ( caplen >= 30 )
{
RecordVal* info = new RecordVal(icmp6_nd_prefix_info_type);
uint8 prefix_len = *((const uint8*)(data));
bool L_flag = (*((const uint8*)(data + 1)) & 0x80) != 0;
bool A_flag = (*((const uint8*)(data + 1)) & 0x40) != 0;
uint32 valid_life = *((const uint32*)(data + 2));
uint32 prefer_life = *((const uint32*)(data + 6));
uint8_t prefix_len = *((const uint8_t*)(data));
bool L_flag = (*((const uint8_t*)(data + 1)) & 0x80) != 0;
bool A_flag = (*((const uint8_t*)(data + 1)) & 0x40) != 0;
uint32_t valid_life = *((const uint32_t*)(data + 2));
uint32_t prefer_life = *((const uint32_t*)(data + 6));
in6_addr prefix = *((const in6_addr*)(data + 14));
info->Assign(0, val_mgr->GetCount(prefix_len));
info->Assign(1, val_mgr->GetBool(L_flag));
@ -827,7 +827,7 @@ VectorVal* ICMP_Analyzer::BuildNDOptionsVal(int caplen, const u_char* data)
// MTU option
{
if ( caplen >= 6 )
rv->Assign(5, val_mgr->GetCount(ntohl(*((const uint32*)(data + 2)))));
rv->Assign(5, val_mgr->GetCount(ntohl(*((const uint32_t*)(data + 2)))));
else
set_payload_field = true;

View file

@ -27,7 +27,7 @@ public:
protected:
void Done() override;
void DeliverPacket(int len, const u_char* data, bool orig,
uint64 seq, const IP_Hdr* ip, int caplen) override;
uint64_t seq, const IP_Hdr* ip, int caplen) override;
bool IsReuse(double t, const u_char* pkt) override;
unsigned int MemoryAllocation() const override;
@ -60,8 +60,8 @@ protected:
void Context4(double t, const struct icmp* icmpp, int len, int caplen,
const u_char*& data, const IP_Hdr* ip_hdr);
TransportProto GetContextProtocol(const IP_Hdr* ip_hdr, uint32* src_port,
uint32* dst_port);
TransportProto GetContextProtocol(const IP_Hdr* ip_hdr, uint32_t* src_port,
uint32_t* dst_port);
void NextICMP6(double t, const struct icmp* icmpp, int len, int caplen,
const u_char*& data, const IP_Hdr* ip_hdr );

View file

@ -65,7 +65,7 @@ void IMAP_Analyzer::DeliverStream(int len, const u_char* data, bool orig)
}
}
void IMAP_Analyzer::Undelivered(uint64 seq, int len, bool orig)
void IMAP_Analyzer::Undelivered(uint64_t seq, int len, bool orig)
{
tcp::TCP_ApplicationAnalyzer::Undelivered(seq, len, orig);
had_gap = true;

View file

@ -18,7 +18,7 @@ public:
void Done() override;
void DeliverStream(int len, const u_char* data, bool orig) override;
void Undelivered(uint64 seq, int len, bool orig) override;
void Undelivered(uint64_t seq, int len, bool orig) override;
// Overriden from tcp::TCP_ApplicationAnalyzer.
void EndpointEOF(bool is_orig) override;

View file

@ -650,7 +650,7 @@ void IRC_Analyzer::DeliverStream(int length, const u_char* line, bool orig)
}
// Calculate IP address.
uint32 raw_ip = 0;
uint32_t raw_ip = 0;
for ( unsigned int i = 0; i < parts[3].size(); ++i )
{
string s = parts[3].substr(i, 1);

View file

@ -65,7 +65,7 @@ void KRB_Analyzer::Done()
}
void KRB_Analyzer::DeliverPacket(int len, const u_char* data, bool orig,
uint64 seq, const IP_Hdr* ip, int caplen)
uint64_t seq, const IP_Hdr* ip, int caplen)
{
Analyzer::DeliverPacket(len, data, orig, seq, ip, caplen);

View file

@ -21,7 +21,7 @@ public:
virtual void Done();
virtual void DeliverPacket(int len, const u_char* data, bool orig,
uint64 seq, const IP_Hdr* ip, int caplen);
uint64_t seq, const IP_Hdr* ip, int caplen);
static analyzer::Analyzer* Instantiate(Connection* conn)
{ return new KRB_Analyzer(conn); }

View file

@ -57,7 +57,7 @@ void KRB_Analyzer::DeliverStream(int len, const u_char* data, bool orig)
}
}
void KRB_Analyzer::Undelivered(uint64 seq, int len, bool orig)
void KRB_Analyzer::Undelivered(uint64_t seq, int len, bool orig)
{
tcp::TCP_ApplicationAnalyzer::Undelivered(seq, len, orig);
had_gap = true;

View file

@ -17,7 +17,7 @@ public:
void Done() override;
void DeliverStream(int len, const u_char* data, bool orig) override;
void Undelivered(uint64 seq, int len, bool orig) override;
void Undelivered(uint64_t seq, int len, bool orig) override;
// Overriden from tcp::TCP_ApplicationAnalyzer.
void EndpointEOF(bool is_orig) override;

View file

@ -257,7 +257,7 @@ protected:
BroString* data_buffer;
uint64 cur_entity_len;
uint64_t cur_entity_len;
string cur_entity_id;
};

Some files were not shown because too many files have changed in this diff Show more