Implemented a generic payload field lookup function
This commit is contained in:
parent
bf029696c6
commit
e662d62a76
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -268,4 +268,14 @@ payload_t *payload_create(payload_type_t type);
|
|||
*/
|
||||
bool payload_is_known(payload_type_t type);
|
||||
|
||||
/**
|
||||
* Get the value field in a payload using encoding rules.
|
||||
*
|
||||
* @param payload payload to look up a field
|
||||
* @param type encoding rule type to look up
|
||||
* @param skip number rules of type to skip, 0 to get first
|
||||
* @return type specific value pointer, NULL if not found
|
||||
*/
|
||||
void* payload_get_field(payload_t *payload, encoding_type_t type, u_int skip);
|
||||
|
||||
#endif /** PAYLOAD_H_ @}*/
|
||||
|
|
Loading…
Reference in New Issue