Example #1
0
static uint32
__bro_val_hash(BroVal *val)
{
  uint32 result;
  int i;

  D_ENTER;

  if (! val)
    D_RETURN_(0);

  result = __bro_sobject_hash((BroSObject*) val->val_type);

  switch (val->val_type->internal_tag)
    {
    case BRO_INTTYPE_INT:
    case BRO_INTTYPE_UNSIGNED:
      result ^= val->val_int64;
      break;
    case BRO_INTTYPE_IPADDR:
      for ( i = 0; i < 4; ++i )
        result ^= val->val_addr.addr[i];
      break;

    case BRO_INTTYPE_DOUBLE:
      result ^= (uint32) val->val_double;
      break;

    case BRO_INTTYPE_STRING:
      result ^= __bro_ht_str_hash(val->val_str.str_val);
      break;

    case BRO_INTTYPE_SUBNET:
      for ( i = 0; i < 4; ++i )
        result ^= val->val_subnet.sn_net.addr[i];

      result ^= val->val_subnet.sn_width;
      break;

    case BRO_INTTYPE_OTHER:
      D(("WARNING -- __bro_val_hash() invoked on derived type.\n"));
      break;

    default:
      D(("Unknown internal type tag: %i\n", val->val_type->internal_tag));
      break;
    }

  D_RETURN_(result);
}
Example #2
0
uint32
__bro_id_hash(BroID *id)
{
  uint32 result = 0;

  D_ENTER;

  if (! id)
    D_RETURN_(0);

  result ^= __bro_ht_str_hash(id->name.str_val);
  result ^= ((uint32) id->scope) << 8;
  result ^= (uint32) id->is_export;
  result ^= id->is_const;
  result ^= id->is_enum_const;
  result ^= id->is_type;
  result ^= id->offset;
  
  D_RETURN_(result);
}