/* get the flowvar with name 'name' from the flow
*
* name is a normal string*/
-FlowVar *FlowVarGet(Flow *f, uint8_t idx) {
+FlowVar *FlowVarGet(Flow *f, uint16_t idx) {
GenericVar *gv = f->flowvar;
for ( ; gv != NULL; gv = gv->next) {
}
/* add a flowvar to the flow, or update it */
-void FlowVarAddStr(Flow *f, uint8_t idx, uint8_t *value, uint16_t size) {
- //printf("Adding flow var \"%s\" with value(%" PRId32 ") \"%s\"\n", name, size, value);
-
+void FlowVarAddStr(Flow *f, uint16_t idx, uint8_t *value, uint16_t size) {
FLOWLOCK_WRLOCK(f);
FlowVar *fv = FlowVarGet(f, idx);
}
/* add a flowvar to the flow, or update it */
-void FlowVarAddInt(Flow *f, uint8_t idx, uint32_t value) {
- //printf("Adding flow var \"%s\" with value(%" PRId32 ") \"%s\"\n", name, size, value);
-
+void FlowVarAddInt(Flow *f, uint16_t idx, uint32_t value) {
FLOWLOCK_WRLOCK(f);
FlowVar *fv = FlowVarGet(f, idx);
return;
if (fv->datatype == FLOWVAR_TYPE_STR) {
- if (fv->data.fv_str.value != NULL)
- SCFree(fv->data.fv_str.value);
+ if (fv->data.fv_str.value != NULL)
+ SCFree(fv->data.fv_str.value);
}
SCFree(fv);
}
void FlowVarPrint(GenericVar *gv) {
- uint16_t i;
+ uint16_t u;
if (!SCLogDebugEnabled())
return;
FlowVar *fv = (FlowVar *)gv;
if (fv->datatype == FLOWVAR_TYPE_STR) {
- SCLogDebug("Name idx \"%" PRIu32 "\", Value \"", fv->idx);
- for (i = 0; i < fv->data.fv_str.value_len; i++) {
- if (isprint(fv->data.fv_str.value[i]))
- SCLogDebug("%c", fv->data.fv_str.value[i]);
+ SCLogDebug("Name idx \"%" PRIu16 "\", Value \"", fv->idx);
+ for (u = 0; u < fv->data.fv_str.value_len; u++) {
+ if (isprint(fv->data.fv_str.value[u]))
+ SCLogDebug("%c", fv->data.fv_str.value[u]);
else
- SCLogDebug("\\%02X", fv->data.fv_str.value[i]);
+ SCLogDebug("\\%02X", fv->data.fv_str.value[u]);
}
- SCLogDebug("\", Len \"%" PRIu32 "\"\n", fv->data.fv_str.value_len);
+ SCLogDebug("\", Len \"%" PRIu16 "\"\n", fv->data.fv_str.value_len);
} else if (fv->datatype == FLOWVAR_TYPE_INT) {
- SCLogDebug("Name idx \"%" PRIu32 "\", Value \"%" PRIu32 "\"", fv->idx,
+ SCLogDebug("Name idx \"%" PRIu16 "\", Value \"%" PRIu16 "\"", fv->idx,
fv->data.fv_int.value);
} else {
SCLogDebug("Unknown data type at flowvars\n");
-/* Copyright (C) 2007-2010 Open Information Security Foundation
+/* Copyright (C) 2007-2013 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
typedef struct FlowVarTypeStr {
uint8_t *value;
uint16_t value_len;
-}FlowVarTypeStr;
+} FlowVarTypeStr;
/** Struct used to hold the integer data type for flowvars */
typedef struct FlowVarTypeInt_ {
uint32_t value;
-}FlowVarTypeInt;
+} FlowVarTypeInt;
/** Generic Flowvar Structure */
typedef struct FlowVar_ {
- uint8_t type; /* type, DETECT_FLOWVAR in this case */
- GenericVar *next; /* right now just implement this as a list,
- * in the long run we have think of something
- * faster. */
- uint16_t idx; /* name idx */
+ uint8_t type; /* type, DETECT_FLOWVAR in this case */
+ GenericVar *next; /* right now just implement this as a list,
+ * in the long run we have think of something
+ * faster. */
+ uint16_t idx; /* name idx */
uint8_t datatype;
union {
FlowVarTypeStr fv_str;
} FlowVar;
-
/** Flowvar Interface API */
-void FlowVarAddStr(Flow *, uint8_t, uint8_t *, uint16_t);
-void FlowVarAddInt(Flow *, uint8_t, uint32_t);
-FlowVar *FlowVarGet(Flow *, uint8_t);
+void FlowVarAddStr(Flow *, uint16_t, uint8_t *, uint16_t);
+void FlowVarAddInt(Flow *, uint16_t, uint32_t);
+FlowVar *FlowVarGet(Flow *, uint16_t);
void FlowVarFree(FlowVar *);
void FlowVarPrint(GenericVar *);