uint32_t TcpAckOption::hash() const
{
- uint32_t a,b,c;
+ uint32_t a = config.op;
+ uint32_t b = config.min;
+ uint32_t c = config.max;
- a = config.op;
- b = config.min;
- c = config.max;
+ mix(a,b,c);
+ a += IpsOption::hash();
- mix_str(a,b,c,get_name());
finalize(a,b,c);
-
return c;
}
bool TcpAckOption::operator==(const IpsOption& ips) const
{
- if ( strcmp(s_name, ips.get_name()) )
+ if ( !IpsOption::operator==(ips) )
return false;
const TcpAckOption& rhs = (const TcpAckOption&)ips;
uint32_t Asn1Option::hash() const
{
- uint32_t a,b,c;
- const ASN1_CTXT* data = &config;
-
- a = data->bs_overflow;
- b = data->double_overflow;
- c = data->print;
+ uint32_t a = config.bs_overflow;
+ uint32_t b = config.double_overflow;
+ uint32_t c = config.print;
mix(a,b,c);
- a += data->length;
- b += data->max_length;
- c += data->offset;
+ a += config.length;
+ b += config.max_length;
+ c += config.offset;
mix(a,b,c);
- mix_str(a,b,c,get_name());
- a += data->offset_type;
+ a += config.offset_type;
+ b += IpsOption::hash();
finalize(a,b,c);
-
return c;
}
uint32_t Base64DecodeOption::hash() const
{
- uint32_t a,b,c;
-
- a = config.bytes_to_decode;
- b = config.offset;
- c = config.flags;
+ uint32_t a = config.bytes_to_decode;
+ uint32_t b = config.offset;
+ uint32_t c = config.flags;
mix(a,b,c);
- mix_str(a,b,c,get_name());
+ a += IpsOption::hash();
+ mix(a,b,c);
finalize(a,b,c);
return c;
uint32_t BerDataOption::hash() const
{
- uint32_t a = type, b = 0, c = 0;
+ uint32_t a = type, b = IpsOption::hash(), c = 0;
- mix_str(a,b,c,s_name);
+ mix(a,b,c);
finalize(a,b,c);
return c;
bool BerDataOption::operator==(const IpsOption& ips) const
{
+ if ( !IpsOption::operator==(ips) )
+ return false;
+
const BerDataOption& rhs = (const BerDataOption&)ips;
if ( type != rhs.type )
uint32_t BerSkipOption::hash() const
{
- uint32_t a = type, b = optional, c = 0;
+ uint32_t a = type, b = optional, c = IpsOption::hash();
- mix_str(a,b,c,s_name);
+ mix(a,b,c);
finalize(a,b,c);
return c;
bool BerSkipOption::operator==(const IpsOption& ips) const
{
+ if ( !IpsOption::operator==(ips) )
+ return false;
+
const BerSkipOption& rhs = (const BerSkipOption&)ips;
if ( type != rhs.type )
uint32_t LenOption::hash() const
{
- uint32_t a,b,c;
+ uint32_t a = config.op;
+ uint32_t b = config.min;
+ uint32_t c = config.max;
- a = config.op;
- b = config.min;
- c = config.max;
+ mix(a,b,c);
+ a += IpsOption::hash();
- mix_str(a,b,c,get_name());
finalize(a,b,c);
-
return c;
}
uint32_t ByteExtractOption::hash() const
{
- uint32_t a,b,c;
- const ByteExtractData* data = &config;
-
- a = data->bytes_to_grab;
- b = data->offset;
- c = data->base;
+ uint32_t a = config.bytes_to_grab;
+ uint32_t b = config.offset;
+ uint32_t c = config.base;
mix(a,b,c);
- a += (data->relative_flag << 24 |
- data->data_string_convert_flag << 16 |
- data->align << 8 |
- data->endianness);
- b += data->multiplier;
- c += data->var_number;
+ a += (config.relative_flag << 24 |
+ config.data_string_convert_flag << 16 |
+ config.align << 8 |
+ config.endianness);
+ b += config.multiplier;
+ c += config.var_number;
mix(a,b,c);
- a += data->bitmask_val;
- mix_str(a,b,c,get_name());
+ a += config.bitmask_val;
+ b += IpsOption::hash();
+ mix(a,b,c);
finalize(a,b,c);
return c;
uint32_t ByteJumpOption::hash() const
{
- uint32_t a,b,c;
- const ByteJumpData* data = &config;
-
- a = data->bytes_to_grab;
- b = data->offset;
- c = data->base;
+ uint32_t a = config.bytes_to_grab;
+ uint32_t b = config.offset;
+ uint32_t c = config.base;
mix(a,b,c);
- a += (data->relative_flag << 24 |
- data->data_string_convert_flag << 16 |
- data->from_beginning_flag << 8 |
- data->align_flag);
- b += data->endianness;
- c += data->multiplier;
+ a += (config.relative_flag << 24 |
+ config.data_string_convert_flag << 16 |
+ config.from_beginning_flag << 8 |
+ config.align_flag);
+ b += config.endianness;
+ c += config.multiplier;
mix(a,b,c);
- a += data->post_offset;
- b += data->from_end_flag << 16 | (uint32_t) data->offset_var << 8 | data->post_offset_var;
- c += data->bitmask_val;
+ a += config.post_offset;
+ b += config.from_end_flag << 16 | (uint32_t) config.offset_var << 8 | config.post_offset_var;
+ c += config.bitmask_val;
mix(a,b,c);
- mix_str(a,b,c,get_name());
+ a += IpsOption::hash();
finalize(a,b,c);
-
return c;
}
uint32_t pos;
if ( bjd->from_beginning_flag )
- pos = jump;
+ pos = 0;
else if ( bjd->from_end_flag )
- pos = c.size() + jump;
+ pos = c.size();
else
- pos = c.get_pos() + offset + payload_bytes_grabbed + jump;
+ pos = (base_ptr - start_ptr) + payload_bytes_grabbed;
- pos += post_offset;
+ pos += jump + post_offset;
if ( !c.set_pos(pos) )
return NO_MATCH;
uint32_t ByteMathOption::hash() const
{
- uint32_t a,b,c;
- const ByteMathData* data = &config;
+ uint32_t a = config.bytes_to_extract;
+ uint32_t b = config.rvalue;
+ uint32_t c = config.oper;
- a = data->bytes_to_extract;
- b = data->rvalue;
- c = data->oper;
+ mix(a,b,c);
+
+ a += config.offset;
+ b += ((uint32_t) config.rvalue_var << 24 |
+ (uint32_t) config.offset_var << 16 |
+ (uint32_t) config.result_var << 8 |
+ config.endianess);
+ c += config.base;
mix(a,b,c);
- a += data->offset;
- b += ((uint32_t) data->rvalue_var << 24 |
- (uint32_t) data->offset_var << 16 |
- (uint32_t) data->result_var << 8 |
- data->endianess);
- c += data->base;
+ a += config.bitmask_val;
+ b += config.relative_flag;
+ c += config.string_convert_flag;
mix(a,b,c);
- a += data->bitmask_val;
- b += data->relative_flag;
- c += data->string_convert_flag;
- mix_str(a,b,c,get_name());
- finalize(a,b,c);
+ a += IpsOption::hash();
+ finalize(a,b,c);
return c;
}
uint32_t ByteTestOption::hash() const
{
- uint32_t a,b,c;
- const ByteTestData* data = &config;
-
- a = data->bytes_to_compare;
- b = data->cmp_value;
- c = data->opcode;
+ uint32_t a = config.bytes_to_compare;
+ uint32_t b = config.cmp_value;
+ uint32_t c = config.opcode;
mix(a,b,c);
- a += data->offset;
- b += data->not_flag ? (1 << 24) : 0;
- b += data->relative_flag ? (1 << 16) : 0;
- b += data->data_string_convert_flag ? (1 << 8) : 0;
- b += data->endianness;
- c += data->base;
+ a += config.offset;
+ b += config.not_flag ? (1 << 24) : 0;
+ b += config.relative_flag ? (1 << 16) : 0;
+ b += config.data_string_convert_flag ? (1 << 8) : 0;
+ b += config.endianness;
+ c += config.base;
mix(a,b,c);
- a += data->cmp_value_var;
- b += data->offset_var;
- c += data->bitmask_val;
+ a += config.cmp_value_var;
+ b += config.offset_var;
+ c += config.bitmask_val;
+
+ mix(a,b,c);
+ a += IpsOption::hash();
mix(a,b,c);
- mix_str(a,b,c,get_name());
finalize(a,b,c);
return c;
uint32_t ContentOption::hash() const
{
- const ContentData* cd = config;
-
- uint32_t a = cd->pmd.flags;
- uint32_t b = cd->pmd.offset;
- uint32_t c = cd->pmd.depth;
+ uint32_t a = config->pmd.flags;
+ uint32_t b = config->pmd.offset;
+ uint32_t c = config->pmd.depth;
mix(a,b,c);
- a += cd->pmd.pattern_size;
- b += cd->pmd.fp_offset;
- c += cd->pmd.fp_length;
+ a += config->pmd.pattern_size;
+ b += config->pmd.fp_offset;
+ c += config->pmd.fp_length;
mix(a,b,c);
- a += cd->pmd.pm_type;
+ a += config->pmd.pm_type;
+ b += IpsOption::hash();
- if ( cd->pmd.pattern_size )
- mix_str(a, b, c, cd->pmd.pattern_buf, cd->pmd.pattern_size);
+ mix(a, b, c);
- mix_str(a, b, c, get_name());
+ if ( config->pmd.pattern_size )
+ mix_str(a, b, c, config->pmd.pattern_buf, config->pmd.pattern_size);
- a += cd->depth_var;
- b += cd->offset_var;
- c += cd->match_delta;
+ a += config->depth_var;
+ b += config->offset_var;
+ c += config->match_delta;
mix(a, b, c);
-
finalize(a, b, c);
return c;
uint32_t CvsOption::hash() const
{
- uint32_t a,b,c;
- const CvsRuleOption* data = &config;
+ uint32_t a = config.type;
+ uint32_t b = IpsOption::hash();
+ uint32_t c = 0;
- a = data->type;
- b = 0;
- c = 0;
-
- mix_str(a,b,c,get_name());
+ mix(a,b,c);
finalize(a,b,c);
return c;
bool CvsOption::operator==(const IpsOption& ips) const
{
- if ( strcmp(get_name(), ips.get_name()) )
+ if ( !IpsOption::operator==(ips) )
return false;
const CvsOption& rhs = (const CvsOption&)ips;
uint32_t DsizeOption::hash() const
{
- uint32_t a,b,c;
-
- a = config.min;
- b = config.max;
- c = config.op;
+ uint32_t a = config.min;
+ uint32_t b = config.max;
+ uint32_t c = config.op;
mix(a,b,c);
- mix_str(a,b,c,get_name());
- finalize(a,b,c);
+ a += IpsOption::hash();
+ finalize(a,b,c);
return c;
}
bool DsizeOption::operator==(const IpsOption& ips) const
{
- if ( strcmp(get_name(), ips.get_name()) )
+ if ( !IpsOption::operator==(ips) )
return false;
const DsizeOption& rhs = (const DsizeOption&)ips;
uint32_t FileTypeOption::hash() const
{
- uint32_t a = 0, b = 0, c = 0;
- mix_str(a, b, c, get_name());
+ uint32_t a = IpsOption::hash(), b = 0, c = 0;
mix_str(a, b, c, types.to_string().c_str());
finalize(a, b, c);
return c;
bool FileTypeOption::operator==(const IpsOption& ips) const
{
- if ( strcmp(get_name(), ips.get_name()) )
+ if ( !IpsOption::operator==(ips) )
return false;
return types == ((const FileTypeOption&) ips).types;
uint32_t TcpFlagOption::hash() const
{
- uint32_t a,b,c;
- const TcpFlagCheckData* data = &config;
+ uint32_t a = config.mode;
+ uint32_t b = config.tcp_flags | (config.tcp_mask << 8);
+ uint32_t c = IpsOption::hash();
- a = data->mode;
- b = data->tcp_flags | (data->tcp_mask << 8);
- c = 0;
-
- mix_str(a,b,c,get_name());
+ mix(a,b,c);
finalize(a,b,c);
return c;
bool TcpFlagOption::operator==(const IpsOption& ips) const
{
- if ( strcmp(get_name(), ips.get_name()) )
+ if ( !IpsOption::operator==(ips) )
return false;
const TcpFlagOption& rhs = (const TcpFlagOption&)ips;
uint32_t FlowCheckOption::hash() const
{
- uint32_t a,b,c;
- const FlowCheckData* data = &config;
-
- a = data->from_server | (data->from_client << 16);
- b = data->ignore_reassembled | (data->only_reassembled << 16);
- c = data->stateless | (data->established << 16);
+ uint32_t a = config.from_server | (config.from_client << 16);
+ uint32_t b = config.ignore_reassembled | (config.only_reassembled << 16);
+ uint32_t c = config.stateless | (config.established << 16);
mix(a,b,c);
- mix_str(a,b,c,get_name());
- a += data->unestablished;
+ a += config.unestablished;
+ b += IpsOption::hash();
+
+ mix(a,b,c);
finalize(a,b,c);
return c;
bool FlowCheckOption::operator==(const IpsOption& ips) const
{
- if ( strcmp(get_name(), ips.get_name()) )
+ if ( !IpsOption::operator==(ips) )
return false;
const FlowCheckOption& rhs = (const FlowCheckOption&)ips;
uint32_t FlowBitsOption::hash() const
{
- uint32_t a,b,c;
- const FlowBitCheck* data = config;
- unsigned i;
- unsigned j = 0;
-
- a = data->or_bits ? 1 : 0;
- b = data->type;
- c = 0;
+ uint32_t a = config->or_bits ? 1 : 0;
+ uint32_t b = config->type;
+ uint32_t c = IpsOption::hash();
mix(a,b,c);
- mix_str(a,b,c,get_name());
- for (i = 0, j = 0; i < data->ids.size(); i++, j++)
+ unsigned i;
+ unsigned j = 0;
+
+ for (i = 0, j = 0; i < config->ids.size(); i++, j++)
{
if (j >= 3)
{
- a += data->ids[i - 2];
- b += data->ids[i - 1];
- c += data->ids[i];
+ a += config->ids[i - 2];
+ b += config->ids[i - 1];
+ c += config->ids[i];
mix(a,b,c);
j -= 3;
}
}
if (1 == j)
{
- a += data->ids[data->ids.size() - 1];
- b += data->ids.size();
+ a += config->ids[config->ids.size() - 1];
+ b += config->ids.size();
}
else if (2 == j)
{
- a += data->ids[data->ids.size() - 2];
- b += data->ids[data->ids.size() - 1]|data->ids.size() << 16;
+ a += config->ids[config->ids.size() - 2];
+ b += config->ids[config->ids.size() - 1]|config->ids.size() << 16;
}
finalize(a,b,c);
-
return c;
}
bool FlowBitsOption::operator==(const IpsOption& ips) const
{
- if ( strcmp(get_name(), ips.get_name()) )
+ if ( !IpsOption::operator==(ips) )
return false;
const FlowBitsOption& rhs = (const FlowBitsOption&)ips;
uint32_t FragBitsOption::hash() const
{
- uint32_t a,b,c;
- const FragBitsData* data = &fragBitsData;
+ uint32_t a = fragBitsData.get_mode();
+ uint32_t b = fragBitsData.get_frag_bits();
+ uint32_t c = IpsOption::hash();
- a = data->get_mode();
- b = data->get_frag_bits();
- c = 0;
-
- mix_str(a,b,c,get_name());
+ mix(a,b,c);
finalize(a,b,c);
return c;
bool FragBitsOption::operator==(const IpsOption& ips) const
{
- if ( strcmp(get_name(), ips.get_name()) )
+ if ( !IpsOption::operator==(ips) )
return false;
const FragBitsOption& rhs = (const FragBitsOption&)ips;
uint32_t FragOffsetOption::hash() const
{
- uint32_t a,b,c;
+ uint32_t a = config.op;
+ uint32_t b = (uint32_t)config.min;
+ uint32_t c = (uint32_t)config.max;
- a = config.op;
- b = (uint32_t)config.min;
- c = (uint32_t)config.max;
+ mix(a,b,c);
+ a += IpsOption::hash();
- mix_str(a,b,c,get_name());
finalize(a,b,c);
-
return c;
}
bool FragOffsetOption::operator==(const IpsOption& ips) const
{
- if ( strcmp(get_name(), ips.get_name()) )
+ if ( !IpsOption::operator==(ips) )
return false;
const FragOffsetOption& rhs = (const FragOffsetOption&)ips;
uint32_t HashOption::hash() const
{
- uint32_t a,b,c;
- const HashMatchData* hmd = config;
+ uint32_t a = config->negated;
+ uint32_t b = config->relative;
+ uint32_t c = size;
- a = hmd->negated;
- b = hmd->relative;
- c = size;
+ mix(a,b,c);
+ a += IpsOption::hash();
- mix_str(a,b,c,hmd->hash.c_str());
+ mix_str(a,b,c,config->hash.c_str());
- a += hmd->length;
- b += hmd->offset;
- c += hmd->offset_var;
+ a += config->length;
+ b += config->offset;
+ c += config->offset_var;
- mix_str(a,b,c,get_name());
+ mix(a,b,c);
finalize(a,b,c);
return c;
uint32_t IcmpIdOption::hash() const
{
- uint32_t a,b,c;
+ uint32_t a = config.op;
+ uint32_t b = config.min;
+ uint32_t c = config.max;
- a = config.op;
- b = config.min;
- c = config.max;
+ mix(a,b,c);
+ a += IpsOption::hash();
- mix_str(a,b,c,get_name());
finalize(a,b,c);
-
return c;
}
bool IcmpIdOption::operator==(const IpsOption& ips) const
{
- if ( strcmp(get_name(), ips.get_name()) )
+ if ( !IpsOption::operator==(ips) )
return false;
const IcmpIdOption& rhs = (const IcmpIdOption&)ips;
uint32_t IcmpSeqOption::hash() const
{
- uint32_t a,b,c;
+ uint32_t a = config.op;
+ uint32_t b = config.min;
+ uint32_t c = config.max;
- a = config.op;
- b = config.min;
- c = config.max;
+ mix(a,b,c);
+ a += IpsOption::hash();
- mix_str(a,b,c,get_name());
finalize(a,b,c);
-
return c;
}
bool IcmpSeqOption::operator==(const IpsOption& ips) const
{
- if ( strcmp(get_name(), ips.get_name()) )
+ if ( !IpsOption::operator==(ips) )
return false;
const IcmpSeqOption& rhs = (const IcmpSeqOption&)ips;
uint32_t IcodeOption::hash() const
{
- uint32_t a,b,c;
+ uint32_t a = config.op;
+ uint32_t b = config.min;
+ uint32_t c = config.max;
- a = config.op;
- b = config.min;
- c = config.max;
+ mix(a,b,c);
+ a += IpsOption::hash();
- mix_str(a,b,c,get_name());
finalize(a,b,c);
-
return c;
}
bool IcodeOption::operator==(const IpsOption& ips) const
{
- if ( strcmp(get_name(), ips.get_name()) )
+ if ( !IpsOption::operator==(ips) )
return false;
const IcodeOption& rhs = (const IcodeOption&)ips;
uint32_t IpIdOption::hash() const
{
- uint32_t a,b,c;
+ uint32_t a = config.op;
+ uint32_t b = config.min;
+ uint32_t c = config.max;
- a = config.op;
- b = config.min;
- c = config.max;
+ mix(a,b,c);
+ a += IpsOption::hash();
- mix_str(a,b,c,get_name());
finalize(a,b,c);
-
return c;
}
bool IpIdOption::operator==(const IpsOption& ips) const
{
- if ( strcmp(get_name(), ips.get_name()) )
+ if ( !IpsOption::operator==(ips) )
return false;
const IpIdOption& rhs = (const IpIdOption&)ips;
uint32_t IpProtoOption::hash() const
{
- uint32_t a,b,c;
- const IpProtoData* data = &config;
+ uint32_t a = to_utype(config.protocol);
+ uint32_t b = config.comparison_flag;
+ uint32_t c = IpsOption::hash();
- a = to_utype(data->protocol);
- b = data->comparison_flag;
- c = 0;
-
- mix_str(a,b,c,get_name());
+ mix(a,b,c);
finalize(a,b,c);
return c;
bool IpProtoOption::operator==(const IpsOption& ips) const
{
- if ( strcmp(get_name(), ips.get_name()) )
+ if ( !IpsOption::operator==(ips) )
return false;
const IpProtoOption& rhs = (const IpProtoOption&)ips;
uint32_t IpOptOption::hash() const
{
- uint32_t a,b,c;
- const IpOptionData* data = &config;
+ uint32_t a = (uint32_t)config.ip_option;
+ uint32_t b = config.any_flag;
+ uint32_t c = IpsOption::hash();
- a = (uint32_t)data->ip_option;
- b = data->any_flag;
- c = 0;
-
- mix_str(a,b,c,get_name());
+ mix(a,b,c);
finalize(a,b,c);
return c;
bool IpOptOption::operator==(const IpsOption& ips) const
{
- if ( strcmp(get_name(), ips.get_name()) )
+ if ( !IpsOption::operator==(ips) )
return false;
const IpOptOption& rhs = (const IpOptOption&)ips;
uint32_t IsDataAtOption::hash() const
{
- uint32_t a,b,c;
- const IsDataAtData* data = &config;
-
- a = data->offset;
- b = data->flags;
- c = data->offset_var;
+ uint32_t a = config.offset;
+ uint32_t b = config.flags;
+ uint32_t c = config.offset_var;
mix(a,b,c);
- mix_str(a,b,c,get_name());
- finalize(a,b,c);
+ a += IpsOption::hash();
+ finalize(a,b,c);
return c;
}
bool IsDataAtOption::operator==(const IpsOption& ips) const
{
- if ( strcmp(get_name(), ips.get_name()) )
+ if ( !IpsOption::operator==(ips) )
return false;
const IsDataAtOption& rhs = (const IsDataAtOption&)ips;
uint32_t IcmpTypeOption::hash() const
{
- uint32_t a,b,c;
-
- a = config.op;
- b = config.min;
- c = config.max;
+ uint32_t a = config.op;
+ uint32_t b = config.min;
+ uint32_t c = config.max;
mix(a,b,c);
- mix_str(a,b,c,get_name());
- finalize(a,b,c);
+ a += IpsOption::hash();
+ finalize(a,b,c);
return c;
}
bool IcmpTypeOption::operator==(const IpsOption& ips) const
{
- if ( strcmp(get_name(), ips.get_name()) )
+ if ( !IpsOption::operator==(ips) )
return false;
const IcmpTypeOption& rhs = (const IcmpTypeOption&)ips;
uint32_t LuaJitOption::hash() const
{
- uint32_t a = 0, b = 0, c = 0;
- mix_str(a,b,c,get_name());
+ uint32_t a = IpsOption::hash(), b = 0, c = 0;
mix_str(a,b,c,config.c_str());
finalize(a,b,c);
return c;
}
a += config->options;
+ b += IpsOption::hash();
- mix_str(a,b,c,get_name());
+ mix(a,b,c);
finalize(a,b,c);
return c;
uint32_t b = config.pmd.mpse_flags;
uint32_t c = config.pmd.pm_type;
+ mix(a, b, c);
+ a += IpsOption::hash();
+
mix_str(a, b, c, config.re.c_str());
- mix_str(a, b, c, get_name());
finalize(a, b, c);
return c;
uint32_t ReplaceOption::hash() const
{
- uint32_t a,b,c;
-
- const char* s = repl.c_str();
- unsigned n = repl.size();
-
- a = 0;
- b = n;
- c = 0;
+ uint32_t a = IpsOption::hash();
+ uint32_t b = repl.size();
+ uint32_t c = 0;
mix(a,b,c);
- mix_str(a,b,c,s,n);
- mix_str(a,b,c,get_name());
+ mix_str(a,b,c,repl.c_str());
finalize(a,b,c);
return c;
bool ReplaceOption::operator==(const IpsOption& ips) const
{
- if ( strcmp(get_name(), ips.get_name()) )
+ if ( !IpsOption::operator==(ips) )
return false;
const ReplaceOption& rhs = (const ReplaceOption&)ips;
uint32_t RpcOption::hash() const
{
- uint32_t a,b,c;
- const RpcCheckData* data = &config;
-
- a = data->program;
- b = data->version;
- c = data->procedure;
+ uint32_t a = config.program;
+ uint32_t b = config.version;
+ uint32_t c = config.procedure;
mix(a,b,c);
- a += data->flags;
+ a += config.flags;
+ b += IpsOption::hash();
- mix_str(a,b,c,get_name());
+ mix(a,b,c);
finalize(a,b,c);
return c;
bool RpcOption::operator==(const IpsOption& ips) const
{
- if ( strcmp(get_name(), ips.get_name()) )
+ if ( !IpsOption::operator==(ips) )
return false;
const RpcOption& rhs = (const RpcOption&)ips;
uint32_t b = config.pmd.pm_type;
uint32_t c = config.threshold;
+ mix(a, b, c);
+ a += IpsOption::hash();
+
mix_str(a, b, c, config.pii.c_str());
- mix_str(a, b, c, get_name());
finalize(a, b, c);
return c;
uint32_t TcpSeqOption::hash() const
{
- uint32_t a,b,c;
+ uint32_t a = config.op;
+ uint32_t b = config.min;
+ uint32_t c = config.max;
- a = config.op;
- b = config.min;
- c = config.max;
+ mix(a,b,c);
+ a += IpsOption::hash();
- mix_str(a,b,c,get_name());
finalize(a,b,c);
-
return c;
}
bool TcpSeqOption::operator==(const IpsOption& ips) const
{
- if ( strcmp(get_name(), ips.get_name()) )
+ if ( !IpsOption::operator==(ips) )
return false;
const TcpSeqOption& rhs = (const TcpSeqOption&)ips;
uint32_t SoOption::hash() const
{
- uint32_t a = relative_flag, b = 0, c = 0;
+ uint32_t a = relative_flag, b = IpsOption::hash(), c = 0;
mix_str(a,b,c,soid);
mix_str(a,b,c,so);
finalize(a,b,c);
bool SoOption::operator==(const IpsOption& ips) const
{
+ if ( !IpsOption::operator==(ips) )
+ return false;
+
const SoOption& rhs = (const SoOption&)ips;
if ( strcmp(soid, rhs.soid) )
uint32_t IpTosOption::hash() const
{
- uint32_t a,b,c;
+ uint32_t a = config.op;
+ uint32_t b = config.min;
+ uint32_t c = config.max;
- a = config.op;
- b = config.min;
- c = config.max;
+ mix(a,b,c);
+ a += IpsOption::hash();
- mix_str(a,b,c,get_name());
finalize(a,b,c);
-
return c;
}
bool IpTosOption::operator==(const IpsOption& ips) const
{
- if ( strcmp(get_name(), ips.get_name()) )
+ if ( !IpsOption::operator==(ips) )
return false;
const IpTosOption& rhs = (const IpTosOption&)ips;
uint32_t TtlOption::hash() const
{
- uint32_t a,b,c;
+ uint32_t a = config.op;
+ uint32_t b = config.min;
+ uint32_t c = config.max;
- a = config.op;
- b = config.min;
- c = config.max;
+ mix(a,b,c);
+ a += IpsOption::hash();
mix(a,b,c);
- mix_str(a,b,c,get_name());
finalize(a,b,c);
return c;
bool TtlOption::operator==(const IpsOption& ips) const
{
- if ( strcmp(get_name(), ips.get_name()) )
+ if ( !IpsOption::operator==(ips) )
return false;
const TtlOption& rhs = (const TtlOption&)ips;
uint32_t TcpWinOption::hash() const
{
- uint32_t a,b,c;
+ uint32_t a = config.op;
+ uint32_t b = config.min;
+ uint32_t c = config.max;
- a = config.op;
- b = config.min;
- c = config.max;
+ mix(a,b,c);
+ a += IpsOption::hash();
- mix_str(a,b,c,get_name());
finalize(a,b,c);
-
return c;
}
bool TcpWinOption::operator==(const IpsOption& ips) const
{
- if ( strcmp(get_name(), ips.get_name()) )
+ if ( !IpsOption::operator==(ips) )
return false;
const TcpWinOption& rhs = (const TcpWinOption&)ips;
const IpsApi* api = (const IpsApi*) ips_regex;
IpsOption* opt = api->ctor(mod, &otn);
+ IpsOption::set_buffer("pkt_data");
return opt;
}
fprintf(stderr,"Fatal Error, Quitting..\n");
}
+ // guard against FatalError calls from non-main thread (which should not happen!)
+ if ( !in_main_thread() )
+ abort();
+
SnortConfig::cleanup_fatal_error();
#if 0
#include "detection/fp_create.h"
#include "dump_config/json_config_output.h"
#include "dump_config/text_config_output.h"
+#include "file_api/file_service.h"
#include "filters/detection_filter.h"
#include "filters/rate_filter.h"
#include "filters/sfrf.h"
void SnortConfig::cleanup_fatal_error()
{
- // guard against FatalError calls from packet threads (which should not happen!)
- // FIXIT-L should also guard against non-main non-packet threads calling FatalError
- if ( is_packet_thread() )
- return;
+ // FIXIT-L need a generic way to manage type other threads
+ // and preferably not start them too soon
+ FileService::close();
+#ifdef REG_TEST
const SnortConfig* sc = SnortConfig::get_conf();
if ( sc && !sc->dirty_pig )
{
IpsManager::release_plugins();
InspectorManager::release_plugins();
}
+#endif
}
{
SO_PUBLIC unsigned get_instance_id();
SO_PUBLIC SThreadType get_thread_type();
+
+SO_PUBLIC inline bool in_main_thread()
+{ return get_thread_type() == STHREAD_TYPE_MAIN; }
+
SO_PUBLIC inline bool is_packet_thread()
-{
- return get_thread_type() == STHREAD_TYPE_PACKET;
-}
+{ return get_thread_type() == STHREAD_TYPE_PACKET; }
// all modules that use packet thread files should call this function to
// get a packet thread specific path. name should be the module name or
/* accumulate MIME attachment filenames. The filenames are appended by commas */
int MailLogState::log_file_name(const uint8_t* start, int length)
{
- uint8_t* alt_buf;
- int alt_size;
- uint16_t* alt_len;
-
- int log_avail = 0;
-
if (!start || (length <= 0))
- {
return -1;
- }
- alt_buf = filenames;
- alt_size = MAX_FILE;
- alt_len = &(file_logged);
- log_avail = alt_size - *alt_len;
+ uint8_t* alt_buf = filenames;
+ int alt_size = MAX_FILE;
+ uint16_t* alt_len = &(file_logged);
+
+ int sep = (*alt_len > 0) ? 1 : 0;
+ int log_avail = alt_size - *alt_len - sep;
if (!alt_buf || (log_avail <= 0))
return -1;
- if (*alt_len > 0 && ((*alt_len + 1) < alt_size))
- {
- alt_buf[*alt_len] = ',';
- *alt_len = *alt_len + 1;
- }
-
- if (length > log_avail)
- {
- if (*alt_len != 0)
- *alt_len = *alt_len - 1;
- return -1;
- }
+ else if (log_avail < length )
+ length = log_avail;
if (length > 0)
+ {
+ if (sep)
+ {
+ alt_buf[*alt_len] = ',';
+ *alt_len = *alt_len + 1;
+ }
memcpy_s(alt_buf + *alt_len, log_avail, start, length);
-
- file_current = *alt_len;
- *alt_len += length;
+ file_current = *alt_len;
+ *alt_len += length;
+ }
log_flags |= MIME_FLAG_FILENAME_PRESENT;
/* Accumulate EOL separated headers, one or more at a time */
int MailLogState::log_email_hdrs(const uint8_t* start, int length)
{
- int log_avail = 0;
- uint8_t* log_buf;
-
if (length <= 0)
return -1;
- log_avail = log_depth - hdrs_logged;
- log_buf = (uint8_t*)emailHdrs;
+ int log_avail = log_depth - hdrs_logged;
+ uint8_t* log_buf = (uint8_t*)emailHdrs;
if (log_avail <= 0)
return 0;
by comma */
int MailLogState::log_email_id(const uint8_t* start, int length, EmailUserType type)
{
- uint8_t* alt_buf;
- int alt_size;
- uint16_t* alt_len;
- int log_avail=0;
- const uint8_t* tmp_eol;
-
if (length <= 0)
return -1;
- tmp_eol = (const uint8_t*)memchr(start, ':', length);
- if (tmp_eol == nullptr)
+ const uint8_t* tmp_eol = (const uint8_t*)memchr(start, ':', length);
+
+ if ( !tmp_eol )
return -1;
if ((tmp_eol + 1) < (start + length))
else
return -1;
+ uint8_t* alt_buf;
+ int alt_size;
+ uint16_t* alt_len;
+
switch (type)
{
case EMAIL_SENDER:
return -1;
}
- log_avail = alt_size - *alt_len;
+ int sep = (*alt_len > 0) ? 1 : 0;
+ int log_avail = alt_size - *alt_len - sep;
if (log_avail <= 0 || !alt_buf)
return -1;
- else if (log_avail < length)
- length = log_avail;
- if (*alt_len > 0 && ((*alt_len + 1) < alt_size))
- {
- alt_buf[*alt_len] = ',';
- *alt_len = *alt_len + 1;
- }
-
- if (length > log_avail)
- {
- if (*alt_len != 0)
- *alt_len = *alt_len - 1;
- return -1;
- }
+ else if (log_avail < length )
+ length = log_avail;
if (length > 0)
+ {
+ if (sep)
+ {
+ alt_buf[*alt_len] = ',';
+ *alt_len = *alt_len + 1;
+ }
memcpy_s(alt_buf + *alt_len, log_avail, start, length);
-
- *alt_len += length;
+ *alt_len += length;
+ }
if (type == EMAIL_SENDER)
log_flags |= MIME_FLAG_MAIL_FROM_PRESENT;
else
log_flags |= MIME_FLAG_RCPT_TO_PRESENT;
+
return 0;
}
uint32_t AppIdIpsOption::hash() const
{
- uint32_t abc[3];
+ uint32_t a = appid_table.size();
+ uint32_t b = IpsOption::hash();
+ uint32_t c = 0;
- abc[0] = appid_table.size();
- abc[1] = 0;
- abc[2] = 0;
-
- mix(abc[0], abc[1], abc[2]);
+ mix(a, b, c);
for ( auto& appid_name : appid_table )
- mix_str(abc[0], abc[1], abc[2],
- appid_name.c_str(), appid_name.length());
-
- finalize(abc[0], abc[1], abc[2]);
+ mix_str(a, b, c, appid_name.c_str(), appid_name.length());
- return abc[2];
+ finalize(a, b, c);
+ return c;
}
bool AppIdIpsOption::operator==(const IpsOption& ips) const
uint32_t CipAttributeOption::hash() const
{
- uint32_t a, b, c;
+ uint32_t a = cip_attr.op;
+ uint32_t b = cip_attr.min;
+ uint32_t c = cip_attr.max;
- a = cip_attr.op;
- b = cip_attr.min;
- c = cip_attr.max;
+ mix(a, b, c);
+ a += IpsOption::hash();
- mix_str(a, b, c, get_name());
finalize(a,b,c);
-
return c;
}
bool CipAttributeOption::operator==(const IpsOption& ips) const
{
- if ( strcmp(get_name(), ips.get_name()) )
+ if ( !IpsOption::operator==(ips) )
return false;
const CipAttributeOption& rhs = static_cast<const CipAttributeOption&>(ips);
uint32_t CipClassOption::hash() const
{
- uint32_t a,b,c;
+ uint32_t a = cip_class.op;
+ uint32_t b = cip_class.min;
+ uint32_t c = cip_class.max;
- a = cip_class.op;
- b = cip_class.min;
- c = cip_class.max;
+ mix(a, b, c);
+ a += IpsOption::hash();
- mix_str(a, b, c, get_name());
finalize(a,b,c);
-
return c;
}
bool CipClassOption::operator==(const IpsOption& ips) const
{
- if ( strcmp(get_name(), ips.get_name()) )
+ if ( !IpsOption::operator==(ips) )
return false;
const CipClassOption& rhs = static_cast<const CipClassOption&>(ips);
uint32_t CipConnpathclassOption::hash() const
{
- uint32_t a,b,c;
+ uint32_t a = cip_cpc.op;
+ uint32_t b = cip_cpc.min;
+ uint32_t c = cip_cpc.max;
- a = cip_cpc.op;
- b = cip_cpc.min;
- c = cip_cpc.max;
+ mix(a, b, c);
+ a += IpsOption::hash();
- mix_str(a, b, c, get_name());
finalize(a,b,c);
-
return c;
}
bool CipConnpathclassOption::operator==(const IpsOption& ips) const
{
- if ( strcmp(get_name(), ips.get_name()) )
+ if ( !IpsOption::operator==(ips) )
return false;
const CipConnpathclassOption& rhs = static_cast<const CipConnpathclassOption&>(ips);
uint32_t CipEnipCommandOption::hash() const
{
- uint32_t a,b,c;
+ uint32_t a = cip_enip_cmd.op;
+ uint32_t b = cip_enip_cmd.min;
+ uint32_t c = cip_enip_cmd.max;
- a = cip_enip_cmd.op;
- b = cip_enip_cmd.min;
- c = cip_enip_cmd.max;
+ mix(a, b, c);
+ a += IpsOption::hash();
- mix_str(a, b, c, get_name());
finalize(a,b,c);
-
return c;
}
bool CipEnipCommandOption::operator==(const IpsOption& ips) const
{
- if ( strcmp(get_name(), ips.get_name()) )
+ if ( !IpsOption::operator==(ips) )
return false;
const CipEnipCommandOption& rhs = static_cast<const CipEnipCommandOption&>(ips);
uint32_t CipEnipreqOption::hash() const
{
- uint32_t a = 0, b = 0, c = 0;
+ uint32_t a = IpsOption::hash(), b = 0, c = 0;
- mix_str(a, b, c, get_name());
+ mix(a, b, c);
finalize(a,b,c);
return c;
bool CipEnipreqOption::operator==(const IpsOption& ips) const
{
- return !strcmp(get_name(), ips.get_name());
+ return IpsOption::operator==(ips);
}
IpsOption::EvalStatus CipEnipreqOption::eval(Cursor&, Packet* p)
uint32_t CipEnipRspOption::hash() const
{
- uint32_t a = 0, b = 0, c = 0;
+ uint32_t a = IpsOption::hash(), b = 0, c = 0;
- mix_str(a, b, c, get_name());
+ mix(a, b, c);
finalize(a,b,c);
return c;
bool CipEnipRspOption::operator==(const IpsOption& ips) const
{
- return !strcmp(get_name(), ips.get_name());
+ return IpsOption::operator==(ips);
}
IpsOption::EvalStatus CipEnipRspOption::eval(Cursor&, Packet* p)
uint32_t CipInstanceOption::hash() const
{
- uint32_t a, b, c;
+ uint32_t a = cip_inst.op;
+ uint32_t b = cip_inst.min;
+ uint32_t c = cip_inst.max;
- a = cip_inst.op;
- b = cip_inst.min;
- c = cip_inst.max;
+ mix(a, b, c);
+ a += IpsOption::hash();
- mix_str(a, b, c, get_name());
finalize(a,b,c);
-
return c;
}
bool CipInstanceOption::operator==(const IpsOption& ips) const
{
- if ( strcmp(get_name(), ips.get_name()) )
+ if ( !IpsOption::operator==(ips) )
return false;
const CipInstanceOption& rhs = static_cast<const CipInstanceOption&>(ips);
uint32_t CipReqOption::hash() const
{
- uint32_t a = 0, b = 0, c = 0;
+ uint32_t a = IpsOption::hash(), b = 0, c = 0;
- mix_str(a, b, c, get_name());
+ mix(a, b, c);
finalize(a,b,c);
return c;
bool CipReqOption::operator==(const IpsOption& ips) const
{
- return !strcmp(get_name(), ips.get_name());
+ return IpsOption::operator==(ips);
}
IpsOption::EvalStatus CipReqOption::eval(Cursor&, Packet* p)
uint32_t CipRspOption::hash() const
{
- uint32_t a = 0, b = 0, c = 0;
+ uint32_t a = IpsOption::hash(), b = 0, c = 0;
- mix_str(a, b, c, get_name());
+ mix(a, b, c);
finalize(a,b,c);
return c;
bool CipRspOption::operator==(const IpsOption& ips) const
{
- return !strcmp(get_name(), ips.get_name());
+ return IpsOption::operator==(ips);
}
IpsOption::EvalStatus CipRspOption::eval(Cursor&, Packet* p)
uint32_t CipServiceOption::hash() const
{
- uint32_t a, b, c;
+ uint32_t a = cip_serv.op;
+ uint32_t b = cip_serv.min;
+ uint32_t c = cip_serv.max;
- a = cip_serv.op;
- b = cip_serv.min;
- c = cip_serv.max;
+ mix(a, b, c);
+ a += IpsOption::hash();
- mix_str(a, b, c, get_name());
finalize(a,b,c);
-
return c;
}
bool CipServiceOption::operator==(const IpsOption& ips) const
{
- if ( strcmp(get_name(), ips.get_name()) )
+ if ( !IpsOption::operator==(ips) )
return false;
const CipServiceOption& rhs = static_cast<const CipServiceOption&>(ips);
uint32_t CipStatusOption::hash() const
{
- uint32_t a, b, c;
+ uint32_t a = cip_status.op;
+ uint32_t b = cip_status.min;
+ uint32_t c = cip_status.max;
- a = cip_status.op;
- b = cip_status.min;
- c = cip_status.max;
+ mix(a, b, c);
+ a += IpsOption::hash();
- mix_str(a, b, c, get_name());
finalize(a,b,c);
-
return c;
}
bool CipStatusOption::operator==(const IpsOption& ips) const
{
- if ( strcmp(get_name(), ips.get_name()) )
+ if ( !IpsOption::operator==(ips) )
return false;
const CipStatusOption& rhs = static_cast<const CipStatusOption&>(ips);
(uuid.node[0] << 8) |
(uuid.node[1]);
- mix_str(a, b, c, get_name());
+ mix(a, b, c);
a += (uuid.node[2] << 24) |
(uuid.node[3] << 16) |
a += version.op;
b += any_frag;
+ c += IpsOption::hash();
finalize(a, b, c);
{
uint32_t a = opnum.opnum_lo, b = opnum.opnum_hi, c = opnum.mask_size;
- mix_str(a,b,c,get_name());
+ mix(a,b,c);
if (opnum.mask_size != 0)
{
mix(a,b,c);
}
+ a += IpsOption::hash();
finalize(a, b, c);
bool Dce2OpnumOption::operator==(const IpsOption& ips) const
{
- if ( strcmp(get_name(), ips.get_name()) )
+ if ( !IpsOption::operator==(ips) )
return false;
const Dce2OpnumOption& rhs = (const Dce2OpnumOption&)ips;
uint32_t Dce2StubDataOption::hash() const
{
- uint32_t a = 0, b = 0, c = 0;
+ uint32_t a = IpsOption::hash();
+ uint32_t b = 0, c = 0;
- mix_str(a, b, c, get_name());
+ mix(a, b, c);
finalize(a,b,c);
return c;
bool Dce2StubDataOption::operator==(const IpsOption& ips) const
{
- return !strcmp(get_name(), ips.get_name());
+ return IpsOption::operator==(ips);
}
IpsOption::EvalStatus Dce2StubDataOption::eval(Cursor& c, Packet* p)
uint32_t Dnp3DataOption::hash() const
{
- uint32_t a = 0, b = 0, c = 0;
+ uint32_t a = IpsOption::hash(), b = 0, c = 0;
- mix_str(a, b, c, get_name());
+ mix(a, b, c);
finalize(a,b,c);
return c;
bool Dnp3DataOption::operator==(const IpsOption& ips) const
{
- return !strcmp(get_name(), ips.get_name());
+ return IpsOption::operator==(ips);
}
IpsOption::EvalStatus Dnp3DataOption::eval(Cursor& c, Packet* p)
uint32_t Dnp3FuncOption::hash() const
{
- uint32_t a = func, b = 0, c = 0;
+ uint32_t a = func, b = IpsOption::hash(), c = 0;
- mix_str(a,b,c,get_name());
+ mix(a,b,c);
finalize(a,b,c);
return c;
bool Dnp3FuncOption::operator==(const IpsOption& ips) const
{
- if ( strcmp(get_name(), ips.get_name()) )
+ if ( !IpsOption::operator==(ips) )
return false;
const Dnp3FuncOption& rhs = (const Dnp3FuncOption&)ips;
uint32_t Dnp3IndOption::hash() const
{
- uint32_t a = flags, b = 0, c = 0;
+ uint32_t a = flags, b = IpsOption::hash(), c = 0;
- mix_str(a,b,c,get_name());
+ mix(a,b,c);
finalize(a,b,c);
return c;
bool Dnp3IndOption::operator==(const IpsOption& ips) const
{
- if ( strcmp(get_name(), ips.get_name()) )
+ if ( !IpsOption::operator==(ips) )
return false;
const Dnp3IndOption& rhs = (const Dnp3IndOption&)ips;
uint32_t Dnp3ObjOption::hash() const
{
- uint32_t a = group, b = var, c = 0;
+ uint32_t a = group, b = var, c = IpsOption::hash();
- mix_str(a,b,c,get_name());
+ mix(a,b,c);
finalize(a,b,c);
return c;
bool Dnp3ObjOption::operator==(const IpsOption& ips) const
{
- if ( strcmp(get_name(), ips.get_name()) )
+ if ( !IpsOption::operator==(ips) )
return false;
const Dnp3ObjOption& rhs = (const Dnp3ObjOption&)ips;
uint32_t b = types[1];
uint32_t c = types[2];
- mix_str(a, b, c, get_name());
- finalize(a,b,c);
+ mix(a, b, c);
+ a += IpsOption::hash();
+ finalize(a,b,c);
return c;
}
bool GtpInfoOption::operator==(const IpsOption& ips) const
{
- if ( strcmp(get_name(), ips.get_name()) )
+ if ( !IpsOption::operator==(ips) )
return false;
const GtpInfoOption& rhs = (const GtpInfoOption&)ips;
uint32_t b = types[1].count();
uint32_t c = types[2].count();
- mix_str(a, b, c, get_name());
- finalize(a,b,c);
+ mix(a, b, c);
+ a += IpsOption::hash();
+ finalize(a,b,c);
return c;
}
bool GtpTypeOption::operator==(const IpsOption& ips) const
{
- if ( strcmp(get_name(), ips.get_name()) )
+ if ( !IpsOption::operator==(ips) )
return false;
const GtpTypeOption& rhs = (const GtpTypeOption&)ips;
uint32_t GtpVersionOption::hash() const
{
- uint32_t a = version, b = 0, c = 0;
+ uint32_t a = version, b = IpsOption::hash(), c = 0;
- mix_str(a, b, c, get_name());
+ mix(a, b, c);
finalize(a,b,c);
return c;
bool GtpVersionOption::operator==(const IpsOption& ips) const
{
- if ( strcmp(get_name(), ips.get_name()) )
+ if ( !IpsOption::operator==(ips) )
return false;
const GtpVersionOption& rhs = (const GtpVersionOption&)ips;
return true;
}
-bool Http2HpackDecoder::write_header_part(Field& header, const uint8_t* suffix,
+bool Http2HpackDecoder::write_header_part(const Field& header, const uint8_t* suffix,
uint32_t suffix_length, uint8_t* decoded_header_buffer, const uint32_t decoded_header_length,
uint32_t& bytes_written)
{
const HpackTableEntry* get_hpack_table_entry(const uint8_t* encoded_header_buffer,
const uint32_t encoded_header_length, const Http2HpackIntDecode& decode_int,
uint32_t& bytes_consumed);
- bool write_header_part(Field& header, const uint8_t* suffix, uint32_t suffix_length,
+ bool write_header_part(const Field& header, const uint8_t* suffix, uint32_t suffix_length,
uint8_t* decoded_header_buffer, const uint32_t decoded_header_length,
uint32_t& bytes_written);
bool decode_indexed_name(const uint8_t* encoded_header_buffer,
return false;
break;
case InspectionBuffer::IBT_METHOD:
- if ((get_latest_src(p) != SRC_CLIENT) || (get_latest_is(p) != IS_HEADER))
+ if ((get_latest_src(p) != SRC_CLIENT) || (get_latest_is(p) == IS_BODY))
return false;
break;
case InspectionBuffer::IBT_STAT_CODE:
uint32_t ModbusDataOption::hash() const
{
- uint32_t a = 0, b = 0, c = 0;
+ uint32_t a = IpsOption::hash(), b = 0, c = 0;
- mix_str(a, b, c, get_name());
+ mix(a, b, c);
finalize(a,b,c);
return c;
bool ModbusDataOption::operator==(const IpsOption& ips) const
{
- return !strcmp(get_name(), ips.get_name());
+ return IpsOption::operator==(ips);
}
IpsOption::EvalStatus ModbusDataOption::eval(Cursor& c, Packet* p)
uint32_t ModbusFuncOption::hash() const
{
- uint32_t a = func, b = 0, c = 0;
+ uint32_t a = func, b = IpsOption::hash(), c = 0;
- mix_str(a, b, c, get_name());
+ mix(a, b, c);
finalize(a,b,c);
return c;
bool ModbusFuncOption::operator==(const IpsOption& ips) const
{
- if ( strcmp(get_name(), ips.get_name()) )
+ if ( !IpsOption::operator==(ips) )
return false;
const ModbusFuncOption& rhs = (const ModbusFuncOption&)ips;
uint32_t ModbusUnitOption::hash() const
{
- uint32_t a = unit, b = 0, c = 0;
+ uint32_t a = unit, b = IpsOption::hash(), c = 0;
- mix_str(a, b, c, get_name());
+ mix(a, b, c);
finalize(a,b,c);
return c;
bool ModbusUnitOption::operator==(const IpsOption& ips) const
{
- if ( strcmp(get_name(), ips.get_name()) )
+ if ( !IpsOption::operator==(ips) )
return false;
const ModbusUnitOption& rhs = (const ModbusUnitOption&)ips;
uint32_t S7commplusContentOption::hash() const
{
- uint32_t a = 0, b = 0, c = 0;
+ uint32_t a = IpsOption::hash(), b = 0, c = 0;
- mix_str(a, b, c, get_name());
+ mix(a, b, c);
finalize(a,b,c);
return c;
bool S7commplusContentOption::operator==(const IpsOption& ips) const
{
- return !strcmp(get_name(), ips.get_name());
+ return IpsOption::operator==(ips);
}
IpsOption::EvalStatus S7commplusContentOption::eval(Cursor& c, Packet* p)
uint32_t S7commplusFuncOption::hash() const
{
- uint32_t a = func, b = 0, c = 0;
+ uint32_t a = func, b = IpsOption::hash(), c = 0;
- mix_str(a, b, c, get_name());
+ mix(a, b, c);
finalize(a,b,c);
return c;
bool S7commplusFuncOption::operator==(const IpsOption& ips) const
{
- if ( strcmp(get_name(), ips.get_name()) )
+ if ( !IpsOption::operator==(ips) )
return false;
const S7commplusFuncOption& rhs = (const S7commplusFuncOption&)ips;
uint32_t S7commplusOpcodeOption::hash() const
{
- uint32_t a = opcode, b = 0, c = 0;
+ uint32_t a = opcode, b = IpsOption::hash(), c = 0;
- mix_str(a, b, c, get_name());
+ mix(a, b, c);
finalize(a,b,c);
return c;
bool S7commplusOpcodeOption::operator==(const IpsOption& ips) const
{
- if ( strcmp(get_name(), ips.get_name()) )
+ if ( !IpsOption::operator==(ips) )
return false;
const S7commplusOpcodeOption& rhs = (const S7commplusOpcodeOption&)ips;
uint32_t SipMethodOption::hash() const
{
- uint32_t a,b,c;
+ uint32_t a = methods.size();
+ uint32_t b = a ? methods.begin()->second : 0;
+ uint32_t c = IpsOption::hash();
- a = methods.size();
- b = a ? methods.begin()->second : 0;
- c = 0;
-
- mix_str(a, b, c, get_name());
+ mix(a, b, c);
for ( auto& m : methods )
mix_str(a, b, c, m.first.c_str(), m.first.size());
finalize(a, b, c);
-
return c;
}
bool SipMethodOption::operator==(const IpsOption& ips) const
{
- if ( strcmp(get_name(), ips.get_name()) )
+ if ( !IpsOption::operator==(ips) )
return false;
const SipMethodOption& rhs = (const SipMethodOption&)ips;
uint32_t SipStatCodeOption::hash() const
{
- uint32_t a = 0, b = 0, c = 0;
+ uint32_t a = IpsOption::hash(), b = 0, c = 0;
unsigned n = 0;
while ( n < SIP_NUM_STAT_CODE_MAX and ssod.stat_codes[n] ) ++n;
mix_str(a, b, c, (const char*)ssod.stat_codes, n*sizeof(ssod.stat_codes[0]));
- mix_str(a, b, c, get_name());
+ finalize(a, b, c);
return c;
}
bool SipStatCodeOption::operator==(const IpsOption& ips) const
{
- if ( strcmp(get_name(), ips.get_name()) )
+ if ( !IpsOption::operator==(ips) )
return false;
const SipStatCodeOption& rhs = (const SipStatCodeOption&)ips;
uint32_t SslStateOption::hash() const
{
- uint32_t a,b,c;
+ uint32_t a = ssod.flags;
+ uint32_t b = ssod.mask;
+ uint32_t c = IpsOption::hash();
- a = ssod.flags;
- b = ssod.mask;
- c = 0;
-
- mix_str(a,b,c,get_name());
finalize(a,b,c);
-
return c;
}
bool SslStateOption::operator==(const IpsOption& ips) const
{
- if ( strcmp(get_name(), ips.get_name()) )
+ if ( !IpsOption::operator==(ips) )
return false;
const SslStateOption& rhs = (const SslStateOption&)ips;
uint32_t SslVersionOption::hash() const
{
- uint32_t a,b,c;
+ uint32_t a = svod.flags;
+ uint32_t b = svod.mask;
+ uint32_t c = IpsOption::hash();
- a = svod.flags;
- b = svod.mask;
- c = 0;
-
- mix_str(a,b,c,get_name());
finalize(a,b,c);
-
return c;
}
bool SslVersionOption::operator==(const IpsOption& ips) const
{
- if ( strcmp(get_name(), ips.get_name()) )
+ if ( !IpsOption::operator==(ips) )
return false;
const SslVersionOption& rhs = (const SslVersionOption&)ips;
* further.
*/
trunc = 0;
- if (right)
- continue;
+ continue;
}
if (curr_end < frag_end)
uint32_t ReassembleOption::hash() const
{
- uint32_t a,b,c;
-
- a = srod.enable;
- b = srod.direction;
- c = srod.alert;
+ uint32_t a = srod.enable;
+ uint32_t b = srod.direction;
+ uint32_t c = srod.alert;
mix(a,b,c);
a = srod.fastpath;
+ b += IpsOption::hash();
- mix_str(a,b,c,get_name());
+ mix(a,b,c);
finalize(a,b,c);
return c;
bool ReassembleOption::operator==(const IpsOption& ips) const
{
- if ( strcmp(get_name(), ips.get_name()) )
+ if ( !IpsOption::operator==(ips) )
return false;
const ReassembleOption& rhs = (const ReassembleOption&)ips;
uint32_t SizeOption::hash() const
{
- uint32_t a,b,c;
-
- a = ssod.op;
- b = ssod.min;
- c = ssod.max;
+ uint32_t a = ssod.op;
+ uint32_t b = ssod.min;
+ uint32_t c = ssod.max;
mix(a,b,c);
a = direction;
+ b += IpsOption::hash();
- mix_str(a,b,c,get_name());
+ mix(a,b,c);
finalize(a,b,c);
return c;
bool SizeOption::operator==(const IpsOption& ips) const
{
- if ( strcmp(get_name(), ips.get_name()) )
+ if ( !IpsOption::operator==(ips) )
return false;
const SizeOption& rhs = (const SizeOption&)ips;