-/* Copyright (C) 2007-2013 Open Information Security Foundation
+/* Copyright (C) 2007-2020 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
void TmqhOutputFlowHash(ThreadVars *tv, Packet *p)
{
- int16_t qid = 0;
-
+ uint32_t qid;
TmqhFlowCtx *ctx = (TmqhFlowCtx *)tv->outctx;
if (p->flags & PKT_WANTS_FLOW) {
*/
void TmqhOutputFlowIPPair(ThreadVars *tv, Packet *p)
{
- int16_t qid = 0;
uint32_t addr_hash = 0;
- int i;
TmqhFlowCtx *ctx = (TmqhFlowCtx *)tv->outctx;
if (p->src.family == AF_INET6) {
- for (i = 0; i < 4; i++) {
+ for (int i = 0; i < 4; i++) {
addr_hash += p->src.addr_data32[i] + p->dst.addr_data32[i];
}
} else {
addr_hash = p->src.addr_data32[0] + p->dst.addr_data32[0];
}
- /* we don't have to worry about possible overflow, since
- * ctx->size will be lesser than 2 ** 31 for sure */
- qid = addr_hash % ctx->size;
-
+ uint32_t qid = addr_hash % ctx->size;
PacketQueue *q = ctx->queues[qid].q;
SCMutexLock(&q->mutex_q);
PacketEnqueue(q, p);