Implemented a generic payload field lookup function

This commit is contained in:
Martin Willi
2011-01-05 16:45:51 +01:00
parent bf029696c6
commit e662d62a76
2 changed files with 30 additions and 0 deletions
+20
View File
@@ -196,3 +196,23 @@ bool payload_is_known(payload_type_t type)
#endif
return FALSE;
}
/**
* See header.
*/
void* payload_get_field(payload_t *payload, encoding_type_t type, u_int skip)
{
encoding_rule_t *rule;
size_t count;
int i;
payload->get_encoding_rules(payload, &rule, &count);
for (i = 0; i < count; i++)
{
if (rule[i].type == type && skip-- == 0)
{
return ((char*)payload) + rule[i].offset;
}
}
return NULL;
}