suricata
|
#include "suricata-common.h"
#include "decode.h"
#include "detect.h"
#include "flow-var.h"
#include "util-cidr.h"
#include "util-unittest.h"
#include "util-rule-vars.h"
#include "conf.h"
#include "conf-yaml-loader.h"
#include "detect-engine-siggroup.h"
#include "detect-engine-address.h"
#include "detect-engine-address-ipv4.h"
#include "detect-engine-address-ipv6.h"
#include "detect-engine-port.h"
#include "util-debug.h"
#include "util-byte.h"
#include "util-print.h"
#include "util-var.h"
#include "util-hash-lookup3.h"
Go to the source code of this file.
Data Structures | |
struct | DetectAddressMap_ |
struct | UTHValidateDetectAddressHeadRange_ |
Macros | |
#define | DetectAddressPrint(...) |
#define | MAX_ADDRESS_LENGTH 8192 |
Typedefs | |
typedef struct DetectAddressMap_ | DetectAddressMap |
typedef struct UTHValidateDetectAddressHeadRange_ | UTHValidateDetectAddressHeadRange |
Functions | |
int | DetectAddressMergeNot (DetectAddressHead *gh, DetectAddressHead *ghn) |
Merge the + and the - list (+ positive match, - 'not' match) More... | |
DetectAddress * | DetectAddressInit (void) |
Creates and returns a new instance of a DetectAddress. More... | |
void | DetectAddressFree (DetectAddress *ag) |
Frees a DetectAddress instance. More... | |
DetectAddress * | DetectAddressCopy (DetectAddress *orig) |
copy a DetectAddress More... | |
bool | DetectAddressListsAreEqual (DetectAddress *list1, DetectAddress *list2) |
Checks if two address group lists are equal. More... | |
int | DetectAddressTestConfVars (void) |
int | DetectAddressMapInit (DetectEngineCtx *de_ctx) |
void | DetectAddressMapFree (DetectEngineCtx *de_ctx) |
int | DetectAddressParse (const DetectEngineCtx *de_ctx, DetectAddressHead *gh, const char *str) |
Parses an address group sent as a character string and updates the DetectAddressHead sent as the argument with the relevant address ranges from the parsed string. More... | |
const DetectAddressHead * | DetectParseAddress (DetectEngineCtx *de_ctx, const char *string, bool *contains_negation) |
void | DetectAddressHeadCleanup (DetectAddressHead *gh) |
Cleans a DetectAddressHead. The functions frees the address group heads(ipv4 and ipv6) inside the DetectAddressHead instance. More... | |
int | DetectAddressCmp (DetectAddress *a, DetectAddress *b) |
Used to compare 2 address ranges. More... | |
int | DetectAddressMatchIPv4 (const DetectMatchAddressIPv4 *addrs, uint16_t addrs_cnt, const Address *a) |
Match a packets address against a signatures addrs array. More... | |
int | DetectAddressMatchIPv6 (const DetectMatchAddressIPv6 *addrs, uint16_t addrs_cnt, const Address *a) |
Match a packets address against a signatures addrs array. More... | |
DetectAddress * | DetectAddressLookupInHead (const DetectAddressHead *gh, Address *a) |
Find the group matching address in a group head. More... | |
Address part of the detection engine.
Definition in file detect-engine-address.c.
#define DetectAddressPrint | ( | ... | ) |
Definition at line 53 of file detect-engine-address.c.
#define MAX_ADDRESS_LENGTH 8192 |
typedef struct DetectAddressMap_ DetectAddressMap |
int DetectAddressCmp | ( | DetectAddress * | a, |
DetectAddress * | b | ||
) |
Used to compare 2 address ranges.
a | Pointer to the first DetectAddressData to be compared. |
b | Pointer to the second DetectAddressData to be compared. |
Definition at line 1562 of file detect-engine-address.c.
References ADDRESS_ER, DetectAddressCmpIPv4(), DetectAddressCmpIPv6(), Address_::family, and DetectAddress_::ip.
Referenced by DetectAddressListsAreEqual().
DetectAddress* DetectAddressCopy | ( | DetectAddress * | orig | ) |
copy a DetectAddress
orig | Pointer to the instance of DetectAddress that contains the address data to be copied to the new instance. |
ag | Pointer to the new instance of DetectAddress that contains the copied address. |
Definition at line 127 of file detect-engine-address.c.
References COPY_ADDRESS, DetectAddressInit(), DetectAddress_::flags, DetectAddress_::ip, and DetectAddress_::ip2.
Referenced by DetectThresholdDataCopy().
void DetectAddressFree | ( | DetectAddress * | ag | ) |
Frees a DetectAddress instance.
ag | Pointer to the DetectAddress instance to be freed. |
Definition at line 82 of file detect-engine-address.c.
References SCFree.
Referenced by DetectAddressCutIPv4().
void DetectAddressHeadCleanup | ( | DetectAddressHead * | gh | ) |
Cleans a DetectAddressHead. The functions frees the address group heads(ipv4 and ipv6) inside the DetectAddressHead instance.
gh | Pointer to the DetectAddressHead instance that has to be cleaned. |
Definition at line 1476 of file detect-engine-address.c.
References DetectAddressHead_::ipv4_head.
DetectAddress* DetectAddressInit | ( | void | ) |
Creates and returns a new instance of a DetectAddress.
ag | Pointer to the newly created DetectAddress on success; NULL on failure. |
Definition at line 69 of file detect-engine-address.c.
References SCCalloc, and unlikely.
Referenced by DetectAddressCopy(), DetectAddressCutIPv4(), and DetectAddressCutNotIPv4().
bool DetectAddressListsAreEqual | ( | DetectAddress * | list1, |
DetectAddress * | list2 | ||
) |
Checks if two address group lists are equal.
list1 | Pointer to the first address group list. |
list2 | Pointer to the second address group list. |
true | On success. |
false | On failure. |
Definition at line 349 of file detect-engine-address.c.
References ADDRESS_EQ, DetectAddressCmp(), and DetectAddress_::next.
DetectAddress* DetectAddressLookupInHead | ( | const DetectAddressHead * | gh, |
Address * | a | ||
) |
Find the group matching address in a group head.
gh | Pointer to the address group head(DetectAddressHead instance). |
a | Pointer to an Address instance. |
g | On success pointer to an DetectAddress if we find a match for the Address "a", in the DetectAddressHead "gh". |
Definition at line 1798 of file detect-engine-address.c.
References Address_::family, DetectAddressHead_::ipv4_head, DetectAddressHead_::ipv6_head, DetectAddress_::next, SCEnter, SCLogDebug, and SCReturnPtr.
void DetectAddressMapFree | ( | DetectEngineCtx * | de_ctx | ) |
Definition at line 1337 of file detect-engine-address.c.
References DetectEngineCtx_::address_table, de_ctx, and HashListTableFree().
int DetectAddressMapInit | ( | DetectEngineCtx * | de_ctx | ) |
Definition at line 1326 of file detect-engine-address.c.
References DetectEngineCtx_::address_table, de_ctx, and HashListTableInit().
int DetectAddressMatchIPv4 | ( | const DetectMatchAddressIPv4 * | addrs, |
uint16_t | addrs_cnt, | ||
const Address * | a | ||
) |
Match a packets address against a signatures addrs array.
addrs | array of DetectMatchAddressIPv4's |
addrs_cnt | array size in members |
a | packets address |
0 | no match |
1 | match |
Definition at line 1589 of file detect-engine-address.c.
References SCEnter, SCNtohl, and SCReturnInt.
int DetectAddressMatchIPv6 | ( | const DetectMatchAddressIPv6 * | addrs, |
uint16_t | addrs_cnt, | ||
const Address * | a | ||
) |
Match a packets address against a signatures addrs array.
addrs | array of DetectMatchAddressIPv6's |
addrs_cnt | array size in members |
a | packets address |
0 | no match |
1 | match |
Definition at line 1622 of file detect-engine-address.c.
References SCEnter, SCNtohl, and SCReturnInt.
int DetectAddressMergeNot | ( | DetectAddressHead * | gh, |
DetectAddressHead * | ghn | ||
) |
Merge the + and the - list (+ positive match, - 'not' match)
gh | Pointer to the address head containing the non-NOT groups. |
ghn | Pointer to the address head containing the NOT groups. |
0 | On success. |
-1 | On failure. |
Definition at line 1035 of file detect-engine-address.c.
References DetectAddressHead_::ipv4_head, and SCLogDebug.
int DetectAddressParse | ( | const DetectEngineCtx * | de_ctx, |
DetectAddressHead * | gh, | ||
const char * | str | ||
) |
Parses an address group sent as a character string and updates the DetectAddressHead sent as the argument with the relevant address ranges from the parsed string.
de_ctx | Pointer to the detection engine context |
gh | Pointer to the DetectAddressHead. |
str | Pointer to the character string containing the address group that has to be parsed. |
1 | On success. Contained negation. |
0 | On success. Did not contain negation. |
-1 | On failure. |
Definition at line 1394 of file detect-engine-address.c.
References SCLogDebug, and str.
int DetectAddressTestConfVars | ( | void | ) |
Definition at line 1217 of file detect-engine-address.c.
References ConfGetNode(), ConfNode_::name, next, SCLogDebug, TAILQ_FOREACH, TAILQ_HEAD_INITIALIZER, and ConfNode_::val.
const DetectAddressHead* DetectParseAddress | ( | DetectEngineCtx * | de_ctx, |
const char * | string, | ||
bool * | contains_negation | ||
) |
Definition at line 1434 of file detect-engine-address.c.