* detect-engine-address-ipv6.c's AddressIPv6GtU32 is likely
* what you are looking for.
*/
-static inline int FlowHashRawAddressIPv6GtU32(uint32_t *a, uint32_t *b)
+static inline int FlowHashRawAddressIPv6GtU32(const uint32_t *a, const uint32_t *b)
{
int i;
*
* For ICMP we only consider UNREACHABLE errors atm.
*/
-static inline uint32_t FlowGetKey(Packet *p)
+static inline uint32_t FlowGetKey(const Packet *p)
{
uint32_t key;
* \retval 1 match
* \retval 0 no match
*/
-static inline int FlowCompareICMPv4(Flow *f, Packet *p)
+static inline int FlowCompareICMPv4(Flow *f, const Packet *p)
{
if (ICMPV4_DEST_UNREACH_IS_VALID(p)) {
/* first check the direction of the flow, in other words, the client ->
return 0;
}
-static inline int FlowCompare(Flow *f, Packet *p)
+static inline int FlowCompare(Flow *f, const Packet *p)
{
if (p->proto == IPPROTO_ICMP) {
return FlowCompareICMPv4(f, p);
* \retval 1 true
* \retval 0 false
*/
-static inline int FlowCreateCheck(Packet *p)
+static inline int FlowCreateCheck(const Packet *p)
{
if (PKT_IS_ICMPV4(p)) {
if (ICMPV4_IS_ERROR_MSG(p)) {
*
* \retval f *LOCKED* flow on succes, NULL on error.
*/
-static Flow *FlowGetNew(Packet *p)
+static Flow *FlowGetNew(const Packet *p)
{
Flow *f = NULL;
*
* returns a *LOCKED* flow or NULL
*/
-Flow *FlowGetFlowFromHash(Packet *p)
+Flow *FlowGetFlowFromHash(const Packet *p)
{
Flow *f = NULL;
FlowHashCountInit;
fb->head = f;
fb->tail = f;
- /* Point the Packet at the Flow */
- FlowReference(&p->flow, f);
-
/* got one, now lock, initialize and return */
FlowInit(f, p);
f->fb = fb;
f->hprev = pf;
- /* Point the Packet at the Flow */
- FlowReference(&p->flow, f);
-
/* initialize and return */
FlowInit(f, p);
f->fb = fb;
fb->head->hprev = f;
fb->head = f;
- /* Point the Packet at the Flow */
- FlowReference(&p->flow, f);
-
/* found our flow, lock & return */
FLOWLOCK_WRLOCK(f);
FBLOCK_UNLOCK(fb);
}
}
- /* Point the Packet at the Flow */
- FlowReference(&p->flow, f);
/* lock & return */
FLOWLOCK_WRLOCK(f);
FBLOCK_UNLOCK(fb);
/* prototypes */
-Flow *FlowGetFlowFromHash(Packet *);
+Flow *FlowGetFlowFromHash(const Packet *);
/** enable to print stats on hash lookups in flow-debug.log */
//#define FLOW_DEBUG_STATS
/* initialize the flow from the first packet
* we see from it. */
-void FlowInit(Flow *f, Packet *p)
+void FlowInit(Flow *f, const Packet *p)
{
SCEnter();
SCLogDebug("flow %p", f);
Flow *FlowAllocDirect(void);
void FlowFree(Flow *);
uint8_t FlowGetProtoMapping(uint8_t);
-void FlowInit(Flow *, Packet *);
+void FlowInit(Flow *, const Packet *);
#endif /* __FLOW_UTIL_H__ */
* \retval 0 to_server
* \retval 1 to_client
*/
-int FlowGetPacketDirection(Flow *f, Packet *p)
+int FlowGetPacketDirection(Flow *f, const Packet *p)
{
if (p->proto == IPPROTO_TCP || p->proto == IPPROTO_UDP || p->proto == IPPROTO_SCTP) {
if (!(CMP_PORT(p->sp,p->dp))) {
* \retval 1 true
* \retval 0 false
*/
-static inline int FlowUpdateSeenFlag(Packet *p)
+static inline int FlowUpdateSeenFlag(const Packet *p)
{
if (PKT_IS_ICMPV4(p)) {
if (ICMPV4_IS_ERROR_MSG(p)) {
* \param tv threadvars
* \param p packet to handle flow for
*/
-void FlowHandlePacket (ThreadVars *tv, Packet *p)
+void FlowHandlePacket(ThreadVars *tv, Packet *p)
{
/* Get this packet's flow from the hash. FlowHandlePacket() will setup
* a new flow if nescesary. If we get NULL, we're out of flow memory.
if (f == NULL)
return;
+ /* Point the Packet at the Flow */
+ FlowReference(&p->flow, f);
+
/* update the last seen timestamp of this flow */
f->lastts_sec = p->ts.tv_sec;
/* update flags and counters */
- if (FlowGetPacketDirection(f,p) == TOSERVER) {
+ if (FlowGetPacketDirection(f, p) == TOSERVER) {
if (FlowUpdateSeenFlag(p)) {
f->flags |= FLOW_TO_DST_SEEN;
}
static inline void FlowSetNoPayloadInspectionFlag(Flow *);
static inline void FlowSetSessionNoApplayerInspectionFlag(Flow *);
-int FlowGetPacketDirection(Flow *, Packet *);
+int FlowGetPacketDirection(Flow *, const Packet *);
void FlowCleanupAppLayer(Flow *);