diff --git a/src/detect-engine-address-ipv4.c b/src/detect-engine-address-ipv4.c index a810ae6598..e6577786db 100644 --- a/src/detect-engine-address-ipv4.c +++ b/src/detect-engine-address-ipv4.c @@ -58,10 +58,10 @@ */ int DetectAddressCmpIPv4(DetectAddress *a, DetectAddress *b) { - uint32_t a_ip1 = ntohl(a->ip[0]); - uint32_t a_ip2 = ntohl(a->ip2[0]); - uint32_t b_ip1 = ntohl(b->ip[0]); - uint32_t b_ip2 = ntohl(b->ip2[0]); + uint32_t a_ip1 = ntohl(a->ip.addr_data32[0]); + uint32_t a_ip2 = ntohl(a->ip2.addr_data32[0]); + uint32_t b_ip1 = ntohl(b->ip.addr_data32[0]); + uint32_t b_ip2 = ntohl(b->ip2.addr_data32[0]); if (a_ip1 == b_ip1 && a_ip2 == b_ip2) { SCLogDebug("ADDRESS_EQ"); @@ -113,10 +113,10 @@ int DetectAddressCmpIPv4(DetectAddress *a, DetectAddress *b) int DetectAddressCutIPv4(DetectEngineCtx *de_ctx, DetectAddress *a, DetectAddress *b, DetectAddress **c) { - uint32_t a_ip1 = ntohl(a->ip[0]); - uint32_t a_ip2 = ntohl(a->ip2[0]); - uint32_t b_ip1 = ntohl(b->ip[0]); - uint32_t b_ip2 = ntohl(b->ip2[0]); + uint32_t a_ip1 = ntohl(a->ip.addr_data32[0]); + uint32_t a_ip2 = ntohl(a->ip2.addr_data32[0]); + uint32_t b_ip1 = ntohl(b->ip.addr_data32[0]); + uint32_t b_ip2 = ntohl(b->ip2.addr_data32[0]); DetectPort *port = NULL; DetectAddress *tmp = NULL; DetectAddress *tmp_c = NULL; @@ -144,19 +144,19 @@ int DetectAddressCutIPv4(DetectEngineCtx *de_ctx, DetectAddress *a, if (r == ADDRESS_LE) { SCLogDebug("DetectAddressCutIPv4: r == ADDRESS_LE"); - a->ip[0] = htonl(a_ip1); - a->ip2[0] = htonl(b_ip1 - 1); + a->ip.addr_data32[0] = htonl(a_ip1); + a->ip2.addr_data32[0] = htonl(b_ip1 - 1); - b->ip[0] = htonl(b_ip1); - b->ip2[0] = htonl(a_ip2); + b->ip.addr_data32[0] = htonl(b_ip1); + b->ip2.addr_data32[0] = htonl(a_ip2); tmp_c = DetectAddressInit(); if (tmp_c == NULL) goto error; - tmp_c->family = AF_INET; - tmp_c->ip[0] = htonl(a_ip2 + 1); - tmp_c->ip2[0] = htonl(b_ip2); + tmp_c->ip.family = AF_INET; + tmp_c->ip.addr_data32[0] = htonl(a_ip2 + 1); + tmp_c->ip2.addr_data32[0] = htonl(b_ip2); *c = tmp_c; if (de_ctx != NULL) { @@ -180,19 +180,19 @@ int DetectAddressCutIPv4(DetectEngineCtx *de_ctx, DetectAddress *a, } else if (r == ADDRESS_GE) { SCLogDebug("DetectAddressCutIPv4: r == ADDRESS_GE"); - a->ip[0] = htonl(b_ip1); - a->ip2[0] = htonl(a_ip1 - 1); + a->ip.addr_data32[0] = htonl(b_ip1); + a->ip2.addr_data32[0] = htonl(a_ip1 - 1); - b->ip[0] = htonl(a_ip1); - b->ip2[0] = htonl(b_ip2); + b->ip.addr_data32[0] = htonl(a_ip1); + b->ip2.addr_data32[0] = htonl(b_ip2); tmp_c = DetectAddressInit(); if (tmp_c == NULL) goto error; - tmp_c->family = AF_INET; - tmp_c->ip[0] = htonl(b_ip2 + 1); - tmp_c->ip2[0] = htonl(a_ip2); + tmp_c->ip.family = AF_INET; + tmp_c->ip.addr_data32[0] = htonl(b_ip2 + 1); + tmp_c->ip2.addr_data32[0] = htonl(a_ip2); *c = tmp_c; if (de_ctx != NULL) { @@ -251,11 +251,11 @@ int DetectAddressCutIPv4(DetectEngineCtx *de_ctx, DetectAddress *a, if (a_ip1 == b_ip1) { SCLogDebug("DetectAddressCutIPv4: 1"); - a->ip[0] = htonl(a_ip1); - a->ip2[0] = htonl(a_ip2); + a->ip.addr_data32[0] = htonl(a_ip1); + a->ip2.addr_data32[0] = htonl(a_ip2); - b->ip[0] = htonl(a_ip2 + 1); - b->ip2[0] = htonl(b_ip2); + b->ip.addr_data32[0] = htonl(a_ip2 + 1); + b->ip2.addr_data32[0] = htonl(b_ip2); if (de_ctx != NULL) { /* 'b' overlaps 'a' so 'a' needs the 'b' sigs */ @@ -268,11 +268,11 @@ int DetectAddressCutIPv4(DetectEngineCtx *de_ctx, DetectAddress *a, } else if (a_ip2 == b_ip2) { SCLogDebug("DetectAddressCutIPv4: 2"); - a->ip[0] = htonl(b_ip1); - a->ip2[0] = htonl(a_ip1 - 1); + a->ip.addr_data32[0] = htonl(b_ip1); + a->ip2.addr_data32[0] = htonl(a_ip1 - 1); - b->ip[0] = htonl(a_ip1); - b->ip2[0] = htonl(a_ip2); + b->ip.addr_data32[0] = htonl(a_ip1); + b->ip2.addr_data32[0] = htonl(a_ip2); if (de_ctx != NULL) { /* 'a' overlaps 'b' so 'b' needs the 'a' sigs */ @@ -298,19 +298,19 @@ int DetectAddressCutIPv4(DetectEngineCtx *de_ctx, DetectAddress *a, } else { SCLogDebug("3"); - a->ip[0] = htonl(b_ip1); - a->ip2[0] = htonl(a_ip1 - 1); + a->ip.addr_data32[0] = htonl(b_ip1); + a->ip2.addr_data32[0] = htonl(a_ip1 - 1); - b->ip[0] = htonl(a_ip1); - b->ip2[0] = htonl(a_ip2); + b->ip.addr_data32[0] = htonl(a_ip1); + b->ip2.addr_data32[0] = htonl(a_ip2); tmp_c = DetectAddressInit(); if (tmp_c == NULL) goto error; - tmp_c->family = AF_INET; - tmp_c->ip[0] = htonl(a_ip2 + 1); - tmp_c->ip2[0] = htonl(b_ip2); + tmp_c->ip.family = AF_INET; + tmp_c->ip.addr_data32[0] = htonl(a_ip2 + 1); + tmp_c->ip2.addr_data32[0] = htonl(b_ip2); *c = tmp_c; if (de_ctx != NULL) { @@ -369,11 +369,11 @@ int DetectAddressCutIPv4(DetectEngineCtx *de_ctx, DetectAddress *a, if (a_ip1 == b_ip1) { SCLogDebug("DetectAddressCutIPv4: 1"); - a->ip[0] = htonl(b_ip1); - a->ip2[0] = htonl(b_ip2); + a->ip.addr_data32[0] = htonl(b_ip1); + a->ip2.addr_data32[0] = htonl(b_ip2); - b->ip[0] = htonl(b_ip2 + 1); - b->ip2[0] = htonl(a_ip2); + b->ip.addr_data32[0] = htonl(b_ip2 + 1); + b->ip2.addr_data32[0] = htonl(a_ip2); if (de_ctx != NULL) { /* 'b' overlaps 'a' so a needs the 'b' sigs */ @@ -399,11 +399,11 @@ int DetectAddressCutIPv4(DetectEngineCtx *de_ctx, DetectAddress *a, } else if (a_ip2 == b_ip2) { SCLogDebug("DetectAddressCutIPv4: 2"); - a->ip[0] = htonl(a_ip1); - a->ip2[0] = htonl(b_ip1 - 1); + a->ip.addr_data32[0] = htonl(a_ip1); + a->ip2.addr_data32[0] = htonl(b_ip1 - 1); - b->ip[0] = htonl(b_ip1); - b->ip2[0] = htonl(b_ip2); + b->ip.addr_data32[0] = htonl(b_ip1); + b->ip2.addr_data32[0] = htonl(b_ip2); if (de_ctx != NULL) { /* 'a' overlaps 'b' so a needs the 'a' sigs */ @@ -417,19 +417,19 @@ int DetectAddressCutIPv4(DetectEngineCtx *de_ctx, DetectAddress *a, } else { SCLogDebug("DetectAddressCutIPv4: 3"); - a->ip[0] = htonl(a_ip1); - a->ip2[0] = htonl(b_ip1 - 1); + a->ip.addr_data32[0] = htonl(a_ip1); + a->ip2.addr_data32[0] = htonl(b_ip1 - 1); - b->ip[0] = htonl(b_ip1); - b->ip2[0] = htonl(b_ip2); + b->ip.addr_data32[0] = htonl(b_ip1); + b->ip2.addr_data32[0] = htonl(b_ip2); tmp_c = DetectAddressInit(); if (tmp_c == NULL) goto error; - tmp_c->family = AF_INET; - tmp_c->ip[0] = htonl(b_ip2 + 1); - tmp_c->ip2[0] = htonl(a_ip2); + tmp_c->ip.family = AF_INET; + tmp_c->ip.addr_data32[0] = htonl(b_ip2 + 1); + tmp_c->ip2.addr_data32[0] = htonl(a_ip2); *c = tmp_c; if (de_ctx != NULL) { @@ -478,26 +478,26 @@ int DetectAddressIsCompleteIPSpaceIPv4(DetectAddress *ag) return 0; /* if we don't start with 0.0.0.0 we know we're good */ - if (ntohl(ag->ip[0]) != 0x00000000) + if (ntohl(ag->ip.addr_data32[0]) != 0x00000000) return 0; /* if we're ending with 255.255.255.255 while we know we started with * 0.0.0.0 it's the complete space */ - if (ntohl(ag->ip2[0]) == 0xFFFFFFFF) + if (ntohl(ag->ip2.addr_data32[0]) == 0xFFFFFFFF) return 1; - next_ip = htonl(ntohl(ag->ip2[0]) + 1); + next_ip = htonl(ntohl(ag->ip2.addr_data32[0]) + 1); ag = ag->next; for ( ; ag != NULL; ag = ag->next) { - if (ag->ip[0] != next_ip) + if (ag->ip.addr_data32[0] != next_ip) return 0; - if (ntohl(ag->ip2[0]) == 0xFFFFFFFF) + if (ntohl(ag->ip2.addr_data32[0]) == 0xFFFFFFFF) return 1; - next_ip = htonl(ntohl(ag->ip2[0]) + 1); + next_ip = htonl(ntohl(ag->ip2.addr_data32[0]) + 1); } return 0; @@ -526,31 +526,31 @@ int DetectAddressIsCompleteIPSpaceIPv4(DetectAddress *ag) */ int DetectAddressCutNotIPv4(DetectAddress *a, DetectAddress **b) { - uint32_t a_ip1 = ntohl(a->ip[0]); - uint32_t a_ip2 = ntohl(a->ip2[0]); + uint32_t a_ip1 = ntohl(a->ip.addr_data32[0]); + uint32_t a_ip2 = ntohl(a->ip2.addr_data32[0]); DetectAddress *tmp_b = NULL; /* default to NULL */ *b = NULL; if (a_ip1 != 0x00000000 && a_ip2 != 0xFFFFFFFF) { - a->ip[0] = htonl(0x00000000); - a->ip2[0] = htonl(a_ip1 - 1); + a->ip.addr_data32[0] = htonl(0x00000000); + a->ip2.addr_data32[0] = htonl(a_ip1 - 1); tmp_b = DetectAddressInit(); if (tmp_b == NULL) goto error; - tmp_b->family = AF_INET; - tmp_b->ip[0] = htonl(a_ip2 + 1); - tmp_b->ip2[0] = htonl(0xFFFFFFFF); + tmp_b->ip.family = AF_INET; + tmp_b->ip.addr_data32[0] = htonl(a_ip2 + 1); + tmp_b->ip2.addr_data32[0] = htonl(0xFFFFFFFF); *b = tmp_b; } else if (a_ip1 == 0x00000000 && a_ip2 != 0xFFFFFFFF) { - a->ip[0] = htonl(a_ip2 + 1); - a->ip2[0] = htonl(0xFFFFFFFF); + a->ip.addr_data32[0] = htonl(a_ip2 + 1); + a->ip2.addr_data32[0] = htonl(0xFFFFFFFF); } else if (a_ip1 != 0x00000000 && a_ip2 == 0xFFFFFFFF) { - a->ip[0] = htonl(0x00000000); - a->ip2[0] = htonl(a_ip1 - 1); + a->ip.addr_data32[0] = htonl(0x00000000); + a->ip2.addr_data32[0] = htonl(a_ip1 - 1); } else { goto error; } @@ -591,11 +591,11 @@ int DetectAddressJoinIPv4(DetectEngineCtx *de_ctx, DetectAddress *target, if (source == NULL || target == NULL) return -1; - if (ntohl(source->ip[0]) < ntohl(target->ip[0])) - target->ip[0] = source->ip[0]; + if (ntohl(source->ip.addr_data32[0]) < ntohl(target->ip.addr_data32[0])) + target->ip.addr_data32[0] = source->ip.addr_data32[0]; - if (ntohl(source->ip2[0]) > ntohl(target->ip2[0])) - target->ip2[0] = source->ip2[0]; + if (ntohl(source->ip2.addr_data32[0]) > ntohl(target->ip2.addr_data32[0])) + target->ip2.addr_data32[0] = source->ip2.addr_data32[0]; return 0; } @@ -616,424 +616,424 @@ static int DetectAddressIPv4TestAddressCmp01(void) if (inet_pton(AF_INET, "1.2.3.4", &in) < 0) goto error; - a->ip[0] = in.s_addr; + a->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "192.168.1.1", &in) < 0) goto error; - a->ip2[0] = in.s_addr; + a->ip2.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "1.2.3.4", &in) < 0) goto error; - b->ip[0] = in.s_addr; + b->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "192.168.1.1", &in) < 0) goto error; - b->ip2[0] = in.s_addr; + b->ip2.addr_data32[0] = in.s_addr; result &= (DetectAddressCmpIPv4(a, b) == ADDRESS_EQ); if (inet_pton(AF_INET, "1.2.3.4", &in) < 0) goto error; - a->ip[0] = in.s_addr; + a->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "192.168.1.1", &in) < 0) goto error; - a->ip2[0] = in.s_addr; + a->ip2.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "1.2.3.3", &in) < 0) goto error; - b->ip[0] = in.s_addr; + b->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "192.168.1.1", &in) < 0) goto error; - b->ip2[0] = in.s_addr; + b->ip2.addr_data32[0] = in.s_addr; result &= (DetectAddressCmpIPv4(a, b) == ADDRESS_ES); if (inet_pton(AF_INET, "1.2.3.4", &in) < 0) goto error; - a->ip[0] = in.s_addr; + a->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "192.168.1.1", &in) < 0) goto error; - a->ip2[0] = in.s_addr; + a->ip2.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "1.2.3.4", &in) < 0) goto error; - b->ip[0] = in.s_addr; + b->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "192.168.1.2", &in) < 0) goto error; - b->ip2[0] = in.s_addr; + b->ip2.addr_data32[0] = in.s_addr; result &= (DetectAddressCmpIPv4(a, b) == ADDRESS_ES); if (inet_pton(AF_INET, "1.2.3.4", &in) < 0) goto error; - a->ip[0] = in.s_addr; + a->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "192.168.1.2", &in) < 0) goto error; - a->ip2[0] = in.s_addr; + a->ip2.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "1.2.3.3", &in) < 0) goto error; - b->ip[0] = in.s_addr; + b->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "192.168.1.2", &in) < 0) goto error; - b->ip2[0] = in.s_addr; + b->ip2.addr_data32[0] = in.s_addr; result &= (DetectAddressCmpIPv4(a, b) == ADDRESS_ES); if (inet_pton(AF_INET, "1.2.3.4", &in) < 0) goto error; - a->ip[0] = in.s_addr; + a->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "192.168.1.1", &in) < 0) goto error; - a->ip2[0] = in.s_addr; + a->ip2.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "1.2.3.3", &in) < 0) goto error; - b->ip[0] = in.s_addr; + b->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "192.168.1.2", &in) < 0) goto error; - b->ip2[0] = in.s_addr; + b->ip2.addr_data32[0] = in.s_addr; result &= (DetectAddressCmpIPv4(a, b) == ADDRESS_ES); if (inet_pton(AF_INET, "1.2.3.4", &in) < 0) goto error; - a->ip[0] = in.s_addr; + a->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "192.168.1.2", &in) < 0) goto error; - a->ip2[0] = in.s_addr; + a->ip2.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "1.2.3.4", &in) < 0) goto error; - b->ip[0] = in.s_addr; + b->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "192.168.1.1", &in) < 0) goto error; - b->ip2[0] = in.s_addr; + b->ip2.addr_data32[0] = in.s_addr; result &= (DetectAddressCmpIPv4(a, b) != ADDRESS_ES); if (inet_pton(AF_INET, "1.2.3.4", &in) < 0) goto error; - a->ip[0] = in.s_addr; + a->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "192.168.1.2", &in) < 0) goto error; - a->ip2[0] = in.s_addr; + a->ip2.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "1.2.3.4", &in) < 0) goto error; - b->ip[0] = in.s_addr; + b->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "192.168.1.1", &in) < 0) goto error; - b->ip2[0] = in.s_addr; + b->ip2.addr_data32[0] = in.s_addr; result &= (DetectAddressCmpIPv4(a, b) == ADDRESS_EB); if (inet_pton(AF_INET, "1.2.3.3", &in) < 0) goto error; - a->ip[0] = in.s_addr; + a->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "192.168.1.1", &in) < 0) goto error; - a->ip2[0] = in.s_addr; + a->ip2.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "1.2.3.4", &in) < 0) goto error; - b->ip[0] = in.s_addr; + b->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "192.168.1.1", &in) < 0) goto error; - b->ip2[0] = in.s_addr; + b->ip2.addr_data32[0] = in.s_addr; result &= (DetectAddressCmpIPv4(a, b) == ADDRESS_EB); if (inet_pton(AF_INET, "1.2.3.3", &in) < 0) goto error; - a->ip[0] = in.s_addr; + a->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "192.168.1.2", &in) < 0) goto error; - a->ip2[0] = in.s_addr; + a->ip2.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "1.2.3.4", &in) < 0) goto error; - b->ip[0] = in.s_addr; + b->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "192.168.1.1", &in) < 0) goto error; - b->ip2[0] = in.s_addr; + b->ip2.addr_data32[0] = in.s_addr; result &= (DetectAddressCmpIPv4(a, b) == ADDRESS_EB); if (inet_pton(AF_INET, "1.2.3.5", &in) < 0) goto error; - a->ip[0] = in.s_addr; + a->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "192.168.1.2", &in) < 0) goto error; - a->ip2[0] = in.s_addr; + a->ip2.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "1.2.3.4", &in) < 0) goto error; - b->ip[0] = in.s_addr; + b->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "192.168.1.1", &in) < 0) goto error; - b->ip2[0] = in.s_addr; + b->ip2.addr_data32[0] = in.s_addr; result &= (DetectAddressCmpIPv4(a, b) != ADDRESS_EB); if (inet_pton(AF_INET, "1.2.3.3", &in) < 0) goto error; - a->ip[0] = in.s_addr; + a->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "128.128.128.128", &in) < 0) goto error; - a->ip2[0] = in.s_addr; + a->ip2.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "128.128.128.128", &in) < 0) goto error; - b->ip[0] = in.s_addr; + b->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "192.168.1.1", &in) < 0) goto error; - b->ip2[0] = in.s_addr; + b->ip2.addr_data32[0] = in.s_addr; result &= (DetectAddressCmpIPv4(a, b) == ADDRESS_LE); if (inet_pton(AF_INET, "1.2.3.3", &in) < 0) goto error; - a->ip[0] = in.s_addr; + a->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "170.170.170.170", &in) < 0) goto error; - a->ip2[0] = in.s_addr; + a->ip2.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "128.128.128.128", &in) < 0) goto error; - b->ip[0] = in.s_addr; + b->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "192.168.1.1", &in) < 0) goto error; - b->ip2[0] = in.s_addr; + b->ip2.addr_data32[0] = in.s_addr; result &= (DetectAddressCmpIPv4(a, b) == ADDRESS_LE); if (inet_pton(AF_INET, "170.170.170.170", &in) < 0) goto error; - a->ip[0] = in.s_addr; + a->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "180.180.180.180", &in) < 0) goto error; - a->ip2[0] = in.s_addr; + a->ip2.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "170.170.170.170", &in) < 0) goto error; - b->ip[0] = in.s_addr; + b->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "192.168.1.1", &in) < 0) goto error; - b->ip2[0] = in.s_addr; + b->ip2.addr_data32[0] = in.s_addr; result &= (DetectAddressCmpIPv4(a, b) != ADDRESS_LE); if (inet_pton(AF_INET, "170.170.170.169", &in) < 0) goto error; - a->ip[0] = in.s_addr; + a->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "180.180.180.180", &in) < 0) goto error; - a->ip2[0] = in.s_addr; + a->ip2.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "170.170.170.170", &in) < 0) goto error; - b->ip[0] = in.s_addr; + b->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "192.168.1.1", &in) < 0) goto error; - b->ip2[0] = in.s_addr; + b->ip2.addr_data32[0] = in.s_addr; result &= (DetectAddressCmpIPv4(a, b) == ADDRESS_LE); if (inet_pton(AF_INET, "170.170.170.169", &in) < 0) goto error; - a->ip[0] = in.s_addr; + a->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "192.168.1.1", &in) < 0) goto error; - a->ip2[0] = in.s_addr; + a->ip2.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "170.170.170.170", &in) < 0) goto error; - b->ip[0] = in.s_addr; + b->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "192.168.1.1", &in) < 0) goto error; - b->ip2[0] = in.s_addr; + b->ip2.addr_data32[0] = in.s_addr; result &= (DetectAddressCmpIPv4(a, b) != ADDRESS_LE); if (inet_pton(AF_INET, "1.2.3.4", &in) < 0) goto error; - a->ip[0] = in.s_addr; + a->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "170.170.170.170", &in) < 0) goto error; - a->ip2[0] = in.s_addr; + a->ip2.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "180.180.180.180", &in) < 0) goto error; - b->ip[0] = in.s_addr; + b->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "192.168.1.1", &in) < 0) goto error; - b->ip2[0] = in.s_addr; + b->ip2.addr_data32[0] = in.s_addr; result &= (DetectAddressCmpIPv4(a, b) == ADDRESS_LT); if (inet_pton(AF_INET, "1.2.3.4", &in) < 0) goto error; - a->ip[0] = in.s_addr; + a->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "185.185.185.185", &in) < 0) goto error; - a->ip2[0] = in.s_addr; + a->ip2.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "180.180.180.180", &in) < 0) goto error; - b->ip[0] = in.s_addr; + b->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "192.168.1.1", &in) < 0) goto error; - b->ip2[0] = in.s_addr; + b->ip2.addr_data32[0] = in.s_addr; /* we could get a LE */ result &= (DetectAddressCmpIPv4(a, b) != ADDRESS_LT); if (inet_pton(AF_INET, "1.2.3.4", &in) < 0) goto error; - a->ip[0] = in.s_addr; + a->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "180.180.180.180", &in) < 0) goto error; - a->ip2[0] = in.s_addr; + a->ip2.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "180.180.180.180", &in) < 0) goto error; - b->ip[0] = in.s_addr; + b->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "192.168.1.1", &in) < 0) goto error; - b->ip2[0] = in.s_addr; + b->ip2.addr_data32[0] = in.s_addr; /* we could get a LE */ result &= (DetectAddressCmpIPv4(a, b) != ADDRESS_LT); if (inet_pton(AF_INET, "1.2.3.4", &in) < 0) goto error; - a->ip[0] = in.s_addr; + a->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "192.168.1.2", &in) < 0) goto error; - a->ip2[0] = in.s_addr; + a->ip2.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "180.180.180.180", &in) < 0) goto error; - b->ip[0] = in.s_addr; + b->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "192.168.1.1", &in) < 0) goto error; - b->ip2[0] = in.s_addr; + b->ip2.addr_data32[0] = in.s_addr; result &= (DetectAddressCmpIPv4(a, b) != ADDRESS_LT); if (inet_pton(AF_INET, "1.2.3.4", &in) < 0) goto error; - a->ip[0] = in.s_addr; + a->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "192.168.1.1", &in) < 0) goto error; - a->ip2[0] = in.s_addr; + a->ip2.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "180.180.180.180", &in) < 0) goto error; - b->ip[0] = in.s_addr; + b->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "192.168.1.1", &in) < 0) goto error; - b->ip2[0] = in.s_addr; + b->ip2.addr_data32[0] = in.s_addr; result &= (DetectAddressCmpIPv4(a, b) != ADDRESS_LT); if (inet_pton(AF_INET, "1.2.3.4", &in) < 0) goto error; - a->ip[0] = in.s_addr; + a->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "170.170.170.170", &in) < 0) goto error; - a->ip2[0] = in.s_addr; + a->ip2.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "1.2.3.4", &in) < 0) goto error; - b->ip[0] = in.s_addr; + b->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "192.168.1.1", &in) < 0) goto error; - b->ip2[0] = in.s_addr; + b->ip2.addr_data32[0] = in.s_addr; result &= (DetectAddressCmpIPv4(a, b) != ADDRESS_LT); if (inet_pton(AF_INET, "128.128.128.128", &in) < 0) goto error; - a->ip[0] = in.s_addr; + a->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "192.168.1.1", &in) < 0) goto error; - a->ip2[0] = in.s_addr; + a->ip2.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "1.2.3.3", &in) < 0) goto error; - b->ip[0] = in.s_addr; + b->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "128.128.128.128", &in) < 0) goto error; - b->ip2[0] = in.s_addr; + b->ip2.addr_data32[0] = in.s_addr; result &= (DetectAddressCmpIPv4(a, b) == ADDRESS_GE); if (inet_pton(AF_INET, "128.128.128.128", &in) < 0) goto error; - a->ip[0] = in.s_addr; + a->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "192.168.1.1", &in) < 0) goto error; - a->ip2[0] = in.s_addr; + a->ip2.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "1.2.3.3", &in) < 0) goto error; - b->ip[0] = in.s_addr; + b->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "170.170.170.170", &in) < 0) goto error; - b->ip2[0] = in.s_addr; + b->ip2.addr_data32[0] = in.s_addr; result &= (DetectAddressCmpIPv4(a, b) == ADDRESS_GE); if (inet_pton(AF_INET, "170.170.170.170", &in) < 0) goto error; - a->ip[0] = in.s_addr; + a->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "192.168.1.1", &in) < 0) goto error; - a->ip2[0] = in.s_addr; + a->ip2.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "170.170.170.170", &in) < 0) goto error; - b->ip[0] = in.s_addr; + b->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "180.180.180.180", &in) < 0) goto error; - b->ip2[0] = in.s_addr; + b->ip2.addr_data32[0] = in.s_addr; result &= (DetectAddressCmpIPv4(a, b) != ADDRESS_GE); if (inet_pton(AF_INET, "170.170.170.170", &in) < 0) goto error; - a->ip[0] = in.s_addr; + a->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "192.168.1.1", &in) < 0) goto error; - a->ip2[0] = in.s_addr; + a->ip2.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "170.170.170.169", &in) < 0) goto error; - b->ip[0] = in.s_addr; + b->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "180.180.180.180", &in) < 0) goto error; - b->ip2[0] = in.s_addr; + b->ip2.addr_data32[0] = in.s_addr; result &= (DetectAddressCmpIPv4(a, b) == ADDRESS_GE); if (inet_pton(AF_INET, "170.170.170.169", &in) < 0) goto error; - a->ip[0] = in.s_addr; + a->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "192.168.1.2", &in) < 0) goto error; - a->ip2[0] = in.s_addr; + a->ip2.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "170.170.170.170", &in) < 0) goto error; - b->ip[0] = in.s_addr; + b->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "192.168.1.1", &in) < 0) goto error; - b->ip2[0] = in.s_addr; + b->ip2.addr_data32[0] = in.s_addr; result &= (DetectAddressCmpIPv4(a, b) != ADDRESS_GE); if (inet_pton(AF_INET, "170.170.170.170", &in) < 0) goto error; - a->ip[0] = in.s_addr; + a->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "192.168.1.1", &in) < 0) goto error; - a->ip2[0] = in.s_addr; + a->ip2.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "170.170.169.170", &in) < 0) goto error; - b->ip[0] = in.s_addr; + b->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "192.168.1.1", &in) < 0) goto error; - b->ip2[0] = in.s_addr; + b->ip2.addr_data32[0] = in.s_addr; result &= (DetectAddressCmpIPv4(a, b) != ADDRESS_GE); if (inet_pton(AF_INET, "192.168.1.2", &in) < 0) goto error; - a->ip[0] = in.s_addr; + a->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "200.200.200.200", &in) < 0) goto error; - a->ip2[0] = in.s_addr; + a->ip2.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "170.170.170.170", &in) < 0) goto error; - b->ip[0] = in.s_addr; + b->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "185.185.185.185", &in) < 0) goto error; - b->ip2[0] = in.s_addr; + b->ip2.addr_data32[0] = in.s_addr; result &= (DetectAddressCmpIPv4(a, b) == ADDRESS_GT); if (inet_pton(AF_INET, "192.168.1.2", &in) < 0) goto error; - a->ip[0] = in.s_addr; + a->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "200.200.200.200", &in) < 0) goto error; - a->ip2[0] = in.s_addr; + a->ip2.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "170.170.170.170", &in) < 0) goto error; - b->ip[0] = in.s_addr; + b->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "192.168.1.2", &in) < 0) goto error; - b->ip2[0] = in.s_addr; + b->ip2.addr_data32[0] = in.s_addr; result &= (DetectAddressCmpIPv4(a, b) != ADDRESS_GT); if (inet_pton(AF_INET, "182.168.1.2", &in) < 0) goto error; - a->ip[0] = in.s_addr; + a->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "200.200.200.200", &in) < 0) goto error; - a->ip2[0] = in.s_addr; + a->ip2.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "170.170.170.170", &in) < 0) goto error; - b->ip[0] = in.s_addr; + b->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "192.168.1.2", &in) < 0) goto error; - b->ip2[0] = in.s_addr; + b->ip2.addr_data32[0] = in.s_addr; result &= (DetectAddressCmpIPv4(a, b) != ADDRESS_GT); if (a != NULL) @@ -1061,18 +1061,18 @@ static int DetectAddressIPv4IsCompleteIPSpace02(void) if (inet_pton(AF_INET, "0.0.0.0", &in) < 0) goto error; - a->ip[0] = in.s_addr; + a->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "255.255.255.255", &in) < 0) goto error; - a->ip2[0] = in.s_addr; + a->ip2.addr_data32[0] = in.s_addr; result &= (DetectAddressIsCompleteIPSpaceIPv4(a) == 1); if (inet_pton(AF_INET, "0.0.0.1", &in) < 0) goto error; - a->ip[0] = in.s_addr; + a->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "255.255.255.255", &in) < 0) goto error; - a->ip2[0] = in.s_addr; + a->ip2.addr_data32[0] = in.s_addr; result &= (DetectAddressIsCompleteIPSpaceIPv4(a) == 0); DetectAddressFree(a); @@ -1082,10 +1082,10 @@ static int DetectAddressIPv4IsCompleteIPSpace02(void) if (inet_pton(AF_INET, "0.0.0.0", &in) < 0) goto error; - a->ip[0] = in.s_addr; + a->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "255.255.255.254", &in) < 0) goto error; - a->ip2[0] = in.s_addr; + a->ip2.addr_data32[0] = in.s_addr; result &= (DetectAddressIsCompleteIPSpaceIPv4(a) == 0); DetectAddressFree(a); @@ -1111,10 +1111,10 @@ static int DetectAddressIPv4IsCompleteIPSpace03(void) if (inet_pton(AF_INET, "0.0.0.0", &in) < 0) goto error; - a->ip[0] = in.s_addr; + a->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "1.2.3.4", &in) < 0) goto error; - a->ip2[0] = in.s_addr; + a->ip2.addr_data32[0] = in.s_addr; result &= (DetectAddressIsCompleteIPSpaceIPv4(a) == 0); if ( (temp->next = DetectAddressInit()) == NULL) @@ -1123,10 +1123,10 @@ static int DetectAddressIPv4IsCompleteIPSpace03(void) if (inet_pton(AF_INET, "1.2.3.5", &in) < 0) goto error; - temp->ip[0] = in.s_addr; + temp->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "126.36.62.61", &in) < 0) goto error; - temp->ip2[0] = in.s_addr; + temp->ip2.addr_data32[0] = in.s_addr; result &= (DetectAddressIsCompleteIPSpaceIPv4(a) == 0); if ( (temp->next = DetectAddressInit()) == NULL) @@ -1135,10 +1135,10 @@ static int DetectAddressIPv4IsCompleteIPSpace03(void) if (inet_pton(AF_INET, "126.36.62.62", &in) < 0) goto error; - temp->ip[0] = in.s_addr; + temp->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "222.52.21.62", &in) < 0) goto error; - temp->ip2[0] = in.s_addr; + temp->ip2.addr_data32[0] = in.s_addr; result &= (DetectAddressIsCompleteIPSpaceIPv4(a) == 0); if ( (temp->next = DetectAddressInit()) == NULL) @@ -1147,10 +1147,10 @@ static int DetectAddressIPv4IsCompleteIPSpace03(void) if (inet_pton(AF_INET, "222.52.21.63", &in) < 0) goto error; - temp->ip[0] = in.s_addr; + temp->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "255.255.255.254", &in) < 0) goto error; - temp->ip2[0] = in.s_addr; + temp->ip2.addr_data32[0] = in.s_addr; result &= (DetectAddressIsCompleteIPSpaceIPv4(a) == 0); if ( (temp->next = DetectAddressInit()) == NULL) @@ -1159,10 +1159,10 @@ static int DetectAddressIPv4IsCompleteIPSpace03(void) if (inet_pton(AF_INET, "255.255.255.255", &in) < 0) goto error; - temp->ip[0] = in.s_addr; + temp->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "255.255.255.255", &in) < 0) goto error; - temp->ip2[0] = in.s_addr; + temp->ip2.addr_data32[0] = in.s_addr; result &= (DetectAddressIsCompleteIPSpaceIPv4(a) == 1); DetectAddressFree(a); @@ -1188,10 +1188,10 @@ static int DetectAddressIPv4IsCompleteIPSpace04(void) if (inet_pton(AF_INET, "0.0.0.0", &in) < 0) goto error; - a->ip[0] = in.s_addr; + a->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "1.2.3.4", &in) < 0) goto error; - a->ip2[0] = in.s_addr; + a->ip2.addr_data32[0] = in.s_addr; result &= (DetectAddressIsCompleteIPSpaceIPv4(a) == 0); if ( (temp->next = DetectAddressInit()) == NULL) @@ -1200,10 +1200,10 @@ static int DetectAddressIPv4IsCompleteIPSpace04(void) if (inet_pton(AF_INET, "1.2.3.5", &in) < 0) goto error; - temp->ip[0] = in.s_addr; + temp->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "126.36.62.61", &in) < 0) goto error; - temp->ip2[0] = in.s_addr; + temp->ip2.addr_data32[0] = in.s_addr; result &= (DetectAddressIsCompleteIPSpaceIPv4(a) == 0); if ( (temp->next = DetectAddressInit()) == NULL) @@ -1212,10 +1212,10 @@ static int DetectAddressIPv4IsCompleteIPSpace04(void) if (inet_pton(AF_INET, "126.36.62.62", &in) < 0) goto error; - temp->ip[0] = in.s_addr; + temp->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "222.52.21.62", &in) < 0) goto error; - temp->ip2[0] = in.s_addr; + temp->ip2.addr_data32[0] = in.s_addr; result &= (DetectAddressIsCompleteIPSpaceIPv4(a) == 0); if ( (temp->next = DetectAddressInit()) == NULL) @@ -1224,10 +1224,10 @@ static int DetectAddressIPv4IsCompleteIPSpace04(void) if (inet_pton(AF_INET, "222.52.21.64", &in) < 0) goto error; - temp->ip[0] = in.s_addr; + temp->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "255.255.255.254", &in) < 0) goto error; - temp->ip2[0] = in.s_addr; + temp->ip2.addr_data32[0] = in.s_addr; result &= (DetectAddressIsCompleteIPSpaceIPv4(a) == 0); if ( (temp->next = DetectAddressInit()) == NULL) @@ -1236,10 +1236,10 @@ static int DetectAddressIPv4IsCompleteIPSpace04(void) if (inet_pton(AF_INET, "255.255.255.255", &in) < 0) goto error; - temp->ip[0] = in.s_addr; + temp->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "255.255.255.255", &in) < 0) goto error; - temp->ip2[0] = in.s_addr; + temp->ip2.addr_data32[0] = in.s_addr; result &= (DetectAddressIsCompleteIPSpaceIPv4(a) == 0); DetectAddressFree(a); @@ -1264,10 +1264,10 @@ static int DetectAddressIPv4CutNot05(void) if (inet_pton(AF_INET, "0.0.0.0", &in) < 0) goto error; - a->ip[0] = in.s_addr; + a->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "255.255.255.255", &in) < 0) goto error; - a->ip2[0] = in.s_addr; + a->ip2.addr_data32[0] = in.s_addr; result &= (DetectAddressCutNotIPv4(a, &b) == -1); if (a != NULL) @@ -1296,18 +1296,18 @@ static int DetectAddressIPv4CutNot06(void) if (inet_pton(AF_INET, "0.0.0.0", &in) < 0) goto error; - a->ip[0] = in.s_addr; + a->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "1.2.3.4", &in) < 0) goto error; - a->ip2[0] = in.s_addr; + a->ip2.addr_data32[0] = in.s_addr; result &= (DetectAddressCutNotIPv4(a, &b) == 0); if (inet_pton(AF_INET, "1.2.3.5", &in) < 0) goto error; - result = (a->ip[0] == in.s_addr); + result = (a->ip.addr_data32[0] == in.s_addr); if (inet_pton(AF_INET, "255.255.255.255", &in) < 0) goto error; - result &= (a->ip2[0] = in.s_addr); + result &= (a->ip2.addr_data32[0] = in.s_addr); result &= (b == NULL); if (a != NULL) @@ -1336,18 +1336,18 @@ static int DetectAddressIPv4CutNot07(void) if (inet_pton(AF_INET, "1.2.3.4", &in) < 0) goto error; - a->ip[0] = in.s_addr; + a->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "255.255.255.255", &in) < 0) goto error; - a->ip2[0] = in.s_addr; + a->ip2.addr_data32[0] = in.s_addr; result &= (DetectAddressCutNotIPv4(a, &b) == 0); if (inet_pton(AF_INET, "0.0.0.0", &in) < 0) goto error; - result = (a->ip[0] == in.s_addr); + result = (a->ip.addr_data32[0] == in.s_addr); if (inet_pton(AF_INET, "1.2.3.3", &in) < 0) goto error; - result &= (a->ip2[0] = in.s_addr); + result &= (a->ip2.addr_data32[0] = in.s_addr); result &= (b == NULL); if (a != NULL) @@ -1376,18 +1376,18 @@ static int DetectAddressIPv4CutNot08(void) if (inet_pton(AF_INET, "1.2.3.4", &in) < 0) goto error; - a->ip[0] = in.s_addr; + a->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "1.2.3.4", &in) < 0) goto error; - a->ip2[0] = in.s_addr; + a->ip2.addr_data32[0] = in.s_addr; result &= (DetectAddressCutNotIPv4(a, &b) == 0); if (inet_pton(AF_INET, "0.0.0.0", &in) < 0) goto error; - result &= (a->ip[0] == in.s_addr); + result &= (a->ip.addr_data32[0] == in.s_addr); if (inet_pton(AF_INET, "1.2.3.3", &in) < 0) goto error; - result &= (a->ip2[0] = in.s_addr); + result &= (a->ip2.addr_data32[0] = in.s_addr); if (b == NULL) { result = 0; @@ -1397,10 +1397,10 @@ static int DetectAddressIPv4CutNot08(void) } if (inet_pton(AF_INET, "1.2.3.5", &in) < 0) goto error; - result &= (b->ip[0] == in.s_addr); + result &= (b->ip.addr_data32[0] == in.s_addr); if (inet_pton(AF_INET, "255.255.255.255", &in) < 0) goto error; - result &= (b->ip2[0] = in.s_addr); + result &= (b->ip2.addr_data32[0] = in.s_addr); if (a != NULL) DetectAddressFree(a); @@ -1428,18 +1428,18 @@ static int DetectAddressIPv4CutNot09(void) if (inet_pton(AF_INET, "1.2.3.4", &in) < 0) goto error; - a->ip[0] = in.s_addr; + a->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "192.168.1.2", &in) < 0) goto error; - a->ip2[0] = in.s_addr; + a->ip2.addr_data32[0] = in.s_addr; result &= (DetectAddressCutNotIPv4(a, &b) == 0); if (inet_pton(AF_INET, "0.0.0.0", &in) < 0) goto error; - result &= (a->ip[0] == in.s_addr); + result &= (a->ip.addr_data32[0] == in.s_addr); if (inet_pton(AF_INET, "1.2.3.3", &in) < 0) goto error; - result &= (a->ip2[0] = in.s_addr); + result &= (a->ip2.addr_data32[0] = in.s_addr); if (b == NULL) { result = 0; @@ -1449,10 +1449,10 @@ static int DetectAddressIPv4CutNot09(void) } if (inet_pton(AF_INET, "192.168.1.3", &in) < 0) goto error; - result &= (b->ip[0] == in.s_addr); + result &= (b->ip.addr_data32[0] == in.s_addr); if (inet_pton(AF_INET, "255.255.255.255", &in) < 0) goto error; - result &= (b->ip2[0] = in.s_addr); + result &= (b->ip2.addr_data32[0] = in.s_addr); if (a != NULL) DetectAddressFree(a); @@ -1480,113 +1480,113 @@ static int DetectAddressIPv4Join10(void) if (inet_pton(AF_INET, "128.51.61.124", &in) < 0) goto error; - target->ip[0] = in.s_addr; + target->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "192.168.1.2", &in) < 0) goto error; - target->ip2[0] = in.s_addr; + target->ip2.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "1.2.3.4", &in) < 0) goto error; - source->ip[0] = in.s_addr; + source->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "192.168.1.2", &in) < 0) goto error; - source->ip2[0] = in.s_addr; + source->ip2.addr_data32[0] = in.s_addr; result &= (DetectAddressJoinIPv4(NULL, target, source) == 0); if (inet_pton(AF_INET, "1.2.3.4", &in) < 0) goto error; - result &= (target->ip[0] == in.s_addr); + result &= (target->ip.addr_data32[0] == in.s_addr); if (inet_pton(AF_INET, "192.168.1.2", &in) < 0) goto error; - result &= (target->ip2[0] == in.s_addr); + result &= (target->ip2.addr_data32[0] == in.s_addr); if (inet_pton(AF_INET, "1.2.3.4", &in) < 0) goto error; - target->ip[0] = in.s_addr; + target->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "192.168.1.2", &in) < 0) goto error; - target->ip2[0] = in.s_addr; + target->ip2.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "1.2.3.5", &in) < 0) goto error; - source->ip[0] = in.s_addr; + source->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "192.168.1.1", &in) < 0) goto error; - source->ip2[0] = in.s_addr; + source->ip2.addr_data32[0] = in.s_addr; result &= (DetectAddressJoinIPv4(NULL, target, source) == 0); if (inet_pton(AF_INET, "1.2.3.4", &in) < 0) goto error; - result &= (target->ip[0] == in.s_addr); + result &= (target->ip.addr_data32[0] == in.s_addr); if (inet_pton(AF_INET, "192.168.1.2", &in) < 0) goto error; - result &= (target->ip2[0] == in.s_addr); + result &= (target->ip2.addr_data32[0] == in.s_addr); if (inet_pton(AF_INET, "1.2.3.4", &in) < 0) goto error; - target->ip[0] = in.s_addr; + target->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "192.168.1.2", &in) < 0) goto error; - target->ip2[0] = in.s_addr; + target->ip2.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "128.1.5.15", &in) < 0) goto error; - source->ip[0] = in.s_addr; + source->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "200.202.200.200", &in) < 0) goto error; - source->ip2[0] = in.s_addr; + source->ip2.addr_data32[0] = in.s_addr; result &= (DetectAddressJoinIPv4(NULL, target, source) == 0); if (inet_pton(AF_INET, "1.2.3.4", &in) < 0) goto error; - result &= (target->ip[0] == in.s_addr); + result &= (target->ip.addr_data32[0] == in.s_addr); if (inet_pton(AF_INET, "200.202.200.200", &in) < 0) goto error; - result &= (target->ip2[0] == in.s_addr); + result &= (target->ip2.addr_data32[0] == in.s_addr); if (inet_pton(AF_INET, "128.51.61.124", &in) < 0) goto error; - target->ip[0] = in.s_addr; + target->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "192.168.1.2", &in) < 0) goto error; - target->ip2[0] = in.s_addr; + target->ip2.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "1.2.3.4", &in) < 0) goto error; - source->ip[0] = in.s_addr; + source->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "192.168.1.2", &in) < 0) goto error; - source->ip2[0] = in.s_addr; + source->ip2.addr_data32[0] = in.s_addr; result &= (DetectAddressJoinIPv4(NULL, target, source) == 0); if (inet_pton(AF_INET, "1.2.3.4", &in) < 0) goto error; - result &= (target->ip[0] == in.s_addr); + result &= (target->ip.addr_data32[0] == in.s_addr); if (inet_pton(AF_INET, "192.168.1.2", &in) < 0) goto error; - result &= (target->ip2[0] == in.s_addr); + result &= (target->ip2.addr_data32[0] == in.s_addr); if (inet_pton(AF_INET, "1.2.3.4", &in) < 0) goto error; - target->ip[0] = in.s_addr; + target->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "192.168.1.2", &in) < 0) goto error; - target->ip2[0] = in.s_addr; + target->ip2.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "1.2.3.4", &in) < 0) goto error; - source->ip[0] = in.s_addr; + source->ip.addr_data32[0] = in.s_addr; if (inet_pton(AF_INET, "192.168.1.2", &in) < 0) goto error; - source->ip2[0] = in.s_addr; + source->ip2.addr_data32[0] = in.s_addr; result &= (DetectAddressJoinIPv4(NULL, target, source) == 0); if (inet_pton(AF_INET, "1.2.3.4", &in) < 0) goto error; - result &= (target->ip[0] == in.s_addr); + result &= (target->ip.addr_data32[0] == in.s_addr); if (inet_pton(AF_INET, "192.168.1.2", &in) < 0) goto error; - result &= (target->ip2[0] == in.s_addr); + result &= (target->ip2.addr_data32[0] == in.s_addr); if (source != NULL) DetectAddressFree(source); diff --git a/src/detect-engine-address-ipv6.c b/src/detect-engine-address-ipv6.c index 6fd33eb249..5cdb09f582 100644 --- a/src/detect-engine-address-ipv6.c +++ b/src/detect-engine-address-ipv6.c @@ -48,10 +48,23 @@ * \retval 1 If a < b. * \retval 0 Otherwise, i.e. a >= b. */ -int AddressIPv6Lt(uint32_t *a, uint32_t *b) +int AddressIPv6Lt(Address *a, Address *b) { int i = 0; + for (i = 0; i < 4; i++) { + if (ntohl(a->addr_data32[i]) < ntohl(b->addr_data32[i])) + return 1; + if (ntohl(a->addr_data32[i]) > ntohl(b->addr_data32[i])) + break; + } + + return 0; +} + +static int AddressIPv6LtU32(uint32_t *a, uint32_t *b) { + int i = 0; + for (i = 0; i < 4; i++) { if (ntohl(a[i]) < ntohl(b[i])) return 1; @@ -72,7 +85,21 @@ int AddressIPv6Lt(uint32_t *a, uint32_t *b) * \retval 1 If a > b. * \retval 0 Otherwise, i.e. a <= b. */ -int AddressIPv6Gt(uint32_t *a, uint32_t *b) +int AddressIPv6Gt(Address *a, Address *b) +{ + int i = 0; + + for (i = 0; i < 4; i++) { + if (ntohl(a->addr_data32[i]) > ntohl(b->addr_data32[i])) + return 1; + if (ntohl(a->addr_data32[i]) < ntohl(b->addr_data32[i])) + break; + } + + return 0; +} + +int AddressIPv6GtU32(uint32_t *a, uint32_t *b) { int i = 0; @@ -96,7 +123,19 @@ int AddressIPv6Gt(uint32_t *a, uint32_t *b) * \retval 1 If a == b. * \retval 0 Otherwise. */ -int AddressIPv6Eq(uint32_t *a, uint32_t *b) +int AddressIPv6Eq(Address *a, Address *b) +{ + int i = 0; + + for (i = 0; i < 4; i++) { + if (a->addr_data32[i] != b->addr_data32[i]) + return 0; + } + + return 1; +} + +static int AddressIPv6EqU32(uint32_t *a, uint32_t *b) { int i = 0; @@ -118,7 +157,7 @@ int AddressIPv6Eq(uint32_t *a, uint32_t *b) * \retval 1 If a <= b. * \retval 0 Otherwise, i.e. a > b. */ -int AddressIPv6Le(uint32_t *a, uint32_t *b) +int AddressIPv6Le(Address *a, Address *b) { if (AddressIPv6Eq(a, b) == 1) @@ -129,6 +168,17 @@ int AddressIPv6Le(uint32_t *a, uint32_t *b) return 0; } +static int AddressIPv6LeU32(uint32_t *a, uint32_t *b) +{ + + if (AddressIPv6EqU32(a, b) == 1) + return 1; + if (AddressIPv6LtU32(a, b) == 1) + return 1; + + return 0; +} + /** * \brief Compares 2 ipv6 addresses and returns if the first address(a) is * greater than or equal to the second address(b) or not. @@ -139,7 +189,7 @@ int AddressIPv6Le(uint32_t *a, uint32_t *b) * \retval 1 If a >= b. * \retval 0 Otherwise, i.e. a < b. */ -int AddressIPv6Ge(uint32_t *a, uint32_t *b) +int AddressIPv6Ge(Address *a, Address *b) { if (AddressIPv6Eq(a, b) == 1) @@ -150,6 +200,17 @@ int AddressIPv6Ge(uint32_t *a, uint32_t *b) return 0; } +static int AddressIPv6GeU32(uint32_t *a, uint32_t *b) +{ + + if (AddressIPv6EqU32(a, b) == 1) + return 1; + if (AddressIPv6GtU32(a, b) == 1) + return 1; + + return 0; +} + /** * \brief Compares 2 addresses(address ranges) and returns the relationship * between the 2 addresses. @@ -168,28 +229,28 @@ int AddressIPv6Ge(uint32_t *a, uint32_t *b) */ int DetectAddressCmpIPv6(DetectAddress *a, DetectAddress *b) { - if (AddressIPv6Eq(a->ip, b->ip) == 1 && - AddressIPv6Eq(a->ip2, b->ip2) == 1) { + if (AddressIPv6Eq(&a->ip, &b->ip) == 1 && + AddressIPv6Eq(&a->ip2, &b->ip2) == 1) { return ADDRESS_EQ; - } else if (AddressIPv6Ge(a->ip, b->ip) == 1 && - AddressIPv6Le(a->ip, b->ip2) == 1 && - AddressIPv6Le(a->ip2, b->ip2) == 1) { + } else if (AddressIPv6Ge(&a->ip, &b->ip) == 1 && + AddressIPv6Le(&a->ip, &b->ip2) == 1 && + AddressIPv6Le(&a->ip2, &b->ip2) == 1) { return ADDRESS_ES; - } else if (AddressIPv6Le(a->ip, b->ip) == 1 && - AddressIPv6Ge(a->ip2, b->ip2) == 1) { + } else if (AddressIPv6Le(&a->ip, &b->ip) == 1 && + AddressIPv6Ge(&a->ip2, &b->ip2) == 1) { return ADDRESS_EB; - } else if (AddressIPv6Lt(a->ip, b->ip) == 1 && - AddressIPv6Lt(a->ip2, b->ip2) == 1 && - AddressIPv6Ge(a->ip2, b->ip) == 1) { + } else if (AddressIPv6Lt(&a->ip, &b->ip) == 1 && + AddressIPv6Lt(&a->ip2, &b->ip2) == 1 && + AddressIPv6Ge(&a->ip2, &b->ip) == 1) { return ADDRESS_LE; - } else if (AddressIPv6Lt(a->ip, b->ip) == 1 && - AddressIPv6Lt(a->ip2, b->ip2) == 1) { + } else if (AddressIPv6Lt(&a->ip, &b->ip) == 1 && + AddressIPv6Lt(&a->ip2, &b->ip2) == 1) { return ADDRESS_LT; - } else if (AddressIPv6Gt(a->ip, b->ip) == 1 && - AddressIPv6Le(a->ip, b->ip2) == 1 && - AddressIPv6Gt(a->ip2, b->ip2) == 1) { + } else if (AddressIPv6Gt(&a->ip, &b->ip) == 1 && + AddressIPv6Le(&a->ip, &b->ip2) == 1 && + AddressIPv6Gt(&a->ip2, &b->ip2) == 1) { return ADDRESS_GE; - } else if (AddressIPv6Gt(a->ip, b->ip2) == 1) { + } else if (AddressIPv6Gt(&a->ip, &b->ip2) == 1) { return ADDRESS_GT; } else { /* should be unreachable */ @@ -296,14 +357,14 @@ static void AddressCutIPv6Copy(uint32_t *a, uint32_t *b) int DetectAddressCutIPv6(DetectEngineCtx *de_ctx, DetectAddress *a, DetectAddress *b, DetectAddress **c) { - uint32_t a_ip1[4] = { ntohl(a->ip[0]), ntohl(a->ip[1]), - ntohl(a->ip[2]), ntohl(a->ip[3]) }; - uint32_t a_ip2[4] = { ntohl(a->ip2[0]), ntohl(a->ip2[1]), - ntohl(a->ip2[2]), ntohl(a->ip2[3]) }; - uint32_t b_ip1[4] = { ntohl(b->ip[0]), ntohl(b->ip[1]), - ntohl(b->ip[2]), ntohl(b->ip[3]) }; - uint32_t b_ip2[4] = { ntohl(b->ip2[0]), ntohl(b->ip2[1]), - ntohl(b->ip2[2]), ntohl(b->ip2[3]) }; + uint32_t a_ip1[4] = { ntohl(a->ip.addr_data32[0]), ntohl(a->ip.addr_data32[1]), + ntohl(a->ip.addr_data32[2]), ntohl(a->ip.addr_data32[3]) }; + uint32_t a_ip2[4] = { ntohl(a->ip2.addr_data32[0]), ntohl(a->ip2.addr_data32[1]), + ntohl(a->ip2.addr_data32[2]), ntohl(a->ip2.addr_data32[3]) }; + uint32_t b_ip1[4] = { ntohl(b->ip.addr_data32[0]), ntohl(b->ip.addr_data32[1]), + ntohl(b->ip.addr_data32[2]), ntohl(b->ip.addr_data32[3]) }; + uint32_t b_ip2[4] = { ntohl(b->ip2.addr_data32[0]), ntohl(b->ip2.addr_data32[1]), + ntohl(b->ip2.addr_data32[2]), ntohl(b->ip2.addr_data32[3]) }; DetectPort *port = NULL; DetectAddress *tmp = NULL; @@ -328,20 +389,20 @@ int DetectAddressCutIPv6(DetectEngineCtx *de_ctx, DetectAddress *a, * part c: a_ip2 + 1 <-> b_ip2 */ if (r == ADDRESS_LE) { - AddressCutIPv6Copy(a_ip1, a->ip); - AddressCutIPv6CopySubOne(b_ip1, a->ip2); + AddressCutIPv6Copy(a_ip1, a->ip.addr_data32); + AddressCutIPv6CopySubOne(b_ip1, a->ip2.addr_data32); - AddressCutIPv6Copy(b_ip1, b->ip); - AddressCutIPv6Copy(a_ip2, b->ip2); + AddressCutIPv6Copy(b_ip1, b->ip.addr_data32); + AddressCutIPv6Copy(a_ip2, b->ip2.addr_data32); DetectAddress *tmp_c; tmp_c = DetectAddressInit(); if (tmp_c == NULL) goto error; - tmp_c->family = AF_INET6; + tmp_c->ip.family = AF_INET6; - AddressCutIPv6CopyAddOne(a_ip2, tmp_c->ip); - AddressCutIPv6Copy(b_ip2, tmp_c->ip2); + AddressCutIPv6CopyAddOne(a_ip2, tmp_c->ip.addr_data32); + AddressCutIPv6Copy(b_ip2, tmp_c->ip2.addr_data32); *c = tmp_c; @@ -364,20 +425,20 @@ int DetectAddressCutIPv6(DetectEngineCtx *de_ctx, DetectAddress *a, * part c: b_ip2 + 1 <-> a_ip2 */ } else if (r == ADDRESS_GE) { - AddressCutIPv6Copy(b_ip1, a->ip); - AddressCutIPv6CopySubOne(a_ip1, a->ip2); + AddressCutIPv6Copy(b_ip1, a->ip.addr_data32); + AddressCutIPv6CopySubOne(a_ip1, a->ip2.addr_data32); - AddressCutIPv6Copy(a_ip1, b->ip); - AddressCutIPv6Copy(b_ip2, b->ip2); + AddressCutIPv6Copy(a_ip1, b->ip.addr_data32); + AddressCutIPv6Copy(b_ip2, b->ip2.addr_data32); DetectAddress *tmp_c; tmp_c = DetectAddressInit(); if (tmp_c == NULL) goto error; - tmp_c->family = AF_INET6; + tmp_c->ip.family = AF_INET6; - AddressCutIPv6CopyAddOne(b_ip2, tmp_c->ip); - AddressCutIPv6Copy(a_ip2, tmp_c->ip2); + AddressCutIPv6CopyAddOne(b_ip2, tmp_c->ip.addr_data32); + AddressCutIPv6Copy(a_ip2, tmp_c->ip2.addr_data32); *c = tmp_c; /* 'a' gets clean and then 'b' sigs @@ -429,12 +490,12 @@ int DetectAddressCutIPv6(DetectEngineCtx *de_ctx, DetectAddress *a, * part c: a_ip2 + 1 <-> b_ip2 */ } else if (r == ADDRESS_ES) { - if (AddressIPv6Eq(a_ip1, b_ip1) == 1) { - AddressCutIPv6Copy(a_ip1, a->ip); - AddressCutIPv6Copy(a_ip2, a->ip2); + if (AddressIPv6EqU32(a_ip1, b_ip1) == 1) { + AddressCutIPv6Copy(a_ip1, a->ip.addr_data32); + AddressCutIPv6Copy(a_ip2, a->ip2.addr_data32); - AddressCutIPv6CopyAddOne(a_ip2, b->ip); - AddressCutIPv6Copy(b_ip2, b->ip2); + AddressCutIPv6CopyAddOne(a_ip2, b->ip.addr_data32); + AddressCutIPv6Copy(b_ip2, b->ip2.addr_data32); /* 'b' overlaps 'a' so 'a' needs the 'b' sigs */ SigGroupHeadCopySigs(de_ctx, b->sh, &a->sh); @@ -444,12 +505,12 @@ int DetectAddressCutIPv6(DetectEngineCtx *de_ctx, DetectAddress *a, a->cnt += b->cnt; - } else if (AddressIPv6Eq(a_ip2, b_ip2) == 1) { - AddressCutIPv6Copy(b_ip1, a->ip); - AddressCutIPv6CopySubOne(a_ip1, a->ip2); + } else if (AddressIPv6EqU32(a_ip2, b_ip2) == 1) { + AddressCutIPv6Copy(b_ip1, a->ip.addr_data32); + AddressCutIPv6CopySubOne(a_ip1, a->ip2.addr_data32); - AddressCutIPv6Copy(a_ip1, b->ip); - AddressCutIPv6Copy(a_ip2, b->ip2); + AddressCutIPv6Copy(a_ip1, b->ip.addr_data32); + AddressCutIPv6Copy(a_ip2, b->ip2.addr_data32); /* 'a' overlaps 'b' so 'b' needs the 'a' sigs */ SigGroupHeadCopySigs(de_ctx, a->sh, &tmp->sh); @@ -471,20 +532,20 @@ int DetectAddressCutIPv6(DetectEngineCtx *de_ctx, DetectAddress *a, b->cnt += tmp->cnt; tmp->cnt = 0; } else { - AddressCutIPv6Copy(b_ip1, a->ip); - AddressCutIPv6CopySubOne(a_ip1, a->ip2); + AddressCutIPv6Copy(b_ip1, a->ip.addr_data32); + AddressCutIPv6CopySubOne(a_ip1, a->ip2.addr_data32); - AddressCutIPv6Copy(a_ip1, b->ip); - AddressCutIPv6Copy(a_ip2, b->ip2); + AddressCutIPv6Copy(a_ip1, b->ip.addr_data32); + AddressCutIPv6Copy(a_ip2, b->ip2.addr_data32); DetectAddress *tmp_c; tmp_c = DetectAddressInit(); if (tmp_c == NULL) { goto error; } - tmp_c->family = AF_INET6; - AddressCutIPv6CopyAddOne(a_ip2, tmp_c->ip); - AddressCutIPv6Copy(b_ip2, tmp_c->ip2); + tmp_c->ip.family = AF_INET6; + AddressCutIPv6CopyAddOne(a_ip2, tmp_c->ip.addr_data32); + AddressCutIPv6Copy(b_ip2, tmp_c->ip2.addr_data32); *c = tmp_c; /* 'a' gets clean and then 'b' sigs @@ -536,12 +597,12 @@ int DetectAddressCutIPv6(DetectEngineCtx *de_ctx, DetectAddress *a, * part c: b_ip2 + 1 <-> a_ip2 */ } else if (r == ADDRESS_EB) { - if (AddressIPv6Eq(a_ip1, b_ip1) == 1) { - AddressCutIPv6Copy(b_ip1, a->ip); - AddressCutIPv6Copy(b_ip2, a->ip2); + if (AddressIPv6EqU32(a_ip1, b_ip1) == 1) { + AddressCutIPv6Copy(b_ip1, a->ip.addr_data32); + AddressCutIPv6Copy(b_ip2, a->ip2.addr_data32); - AddressCutIPv6CopyAddOne(b_ip2, b->ip); - AddressCutIPv6Copy(a_ip2, b->ip2); + AddressCutIPv6CopyAddOne(b_ip2, b->ip.addr_data32); + AddressCutIPv6Copy(a_ip2, b->ip2.addr_data32); /* 'b' overlaps 'a' so a needs the 'b' sigs */ SigGroupHeadCopySigs(de_ctx, b->sh, &tmp->sh); @@ -562,12 +623,12 @@ int DetectAddressCutIPv6(DetectEngineCtx *de_ctx, DetectAddress *a, b->cnt += a->cnt; a->cnt += tmp->cnt; tmp->cnt = 0; - } else if (AddressIPv6Eq(a_ip2, b_ip2) == 1) { - AddressCutIPv6Copy(a_ip1, a->ip); - AddressCutIPv6CopySubOne(b_ip1, a->ip2); + } else if (AddressIPv6EqU32(a_ip2, b_ip2) == 1) { + AddressCutIPv6Copy(a_ip1, a->ip.addr_data32); + AddressCutIPv6CopySubOne(b_ip1, a->ip2.addr_data32); - AddressCutIPv6Copy(b_ip1, b->ip); - AddressCutIPv6Copy(b_ip2, b->ip2); + AddressCutIPv6Copy(b_ip1, b->ip.addr_data32); + AddressCutIPv6Copy(b_ip2, b->ip2.addr_data32); /* 'a' overlaps 'b' so a needs the 'a' sigs */ SigGroupHeadCopySigs(de_ctx, a->sh, &b->sh); @@ -577,20 +638,20 @@ int DetectAddressCutIPv6(DetectEngineCtx *de_ctx, DetectAddress *a, b->cnt += a->cnt; } else { - AddressCutIPv6Copy(a_ip1, a->ip); - AddressCutIPv6CopySubOne(b_ip1, a->ip2); + AddressCutIPv6Copy(a_ip1, a->ip.addr_data32); + AddressCutIPv6CopySubOne(b_ip1, a->ip2.addr_data32); - AddressCutIPv6Copy(b_ip1, b->ip); - AddressCutIPv6Copy(b_ip2, b->ip2); + AddressCutIPv6Copy(b_ip1, b->ip.addr_data32); + AddressCutIPv6Copy(b_ip2, b->ip2.addr_data32); DetectAddress *tmp_c; tmp_c = DetectAddressInit(); if (tmp_c == NULL) goto error; - tmp_c->family = AF_INET6; - AddressCutIPv6CopyAddOne(b_ip2, tmp_c->ip); - AddressCutIPv6Copy(a_ip2, tmp_c->ip2); + tmp_c->ip.family = AF_INET6; + AddressCutIPv6CopyAddOne(b_ip2, tmp_c->ip.addr_data32); + AddressCutIPv6Copy(a_ip2, tmp_c->ip2.addr_data32); *c = tmp_c; /* 'a' stays the same wrt sigs @@ -809,10 +870,10 @@ error: */ int DetectAddressCutNotIPv6(DetectAddress *a, DetectAddress **b) { - uint32_t a_ip1[4] = { ntohl(a->ip[0]), ntohl(a->ip[1]), - ntohl(a->ip[2]), ntohl(a->ip[3]) }; - uint32_t a_ip2[4] = { ntohl(a->ip2[0]), ntohl(a->ip2[1]), - ntohl(a->ip2[2]), ntohl(a->ip2[3]) }; + uint32_t a_ip1[4] = { ntohl(a->ip.addr_data32[0]), ntohl(a->ip.addr_data32[1]), + ntohl(a->ip.addr_data32[2]), ntohl(a->ip.addr_data32[3]) }; + uint32_t a_ip2[4] = { ntohl(a->ip2.addr_data32[0]), ntohl(a->ip2.addr_data32[1]), + ntohl(a->ip2.addr_data32[2]), ntohl(a->ip2.addr_data32[3]) }; uint32_t ip_nul[4] = { 0x00000000, 0x00000000, 0x00000000, 0x00000000 }; uint32_t ip_max[4] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF }; @@ -823,29 +884,29 @@ int DetectAddressCutNotIPv6(DetectAddress *a, DetectAddress **b) a_ip1[2] == 0x00000000 && a_ip1[3] == 0x00000000) && !(a_ip2[0] == 0xFFFFFFFF && a_ip2[1] == 0xFFFFFFFF && a_ip2[2] == 0xFFFFFFFF && a_ip2[3] == 0xFFFFFFFF)) { - AddressCutIPv6Copy(ip_nul, a->ip); - AddressCutIPv6CopySubOne(a_ip1, a->ip2); + AddressCutIPv6Copy(ip_nul, a->ip.addr_data32); + AddressCutIPv6CopySubOne(a_ip1, a->ip2.addr_data32); DetectAddress *tmp_b = DetectAddressInit(); if (tmp_b == NULL) goto error; - tmp_b->family = AF_INET6; - AddressCutIPv6CopyAddOne(a_ip2, tmp_b->ip); - AddressCutIPv6Copy(ip_max, tmp_b->ip2); + tmp_b->ip.family = AF_INET6; + AddressCutIPv6CopyAddOne(a_ip2, tmp_b->ip.addr_data32); + AddressCutIPv6Copy(ip_max, tmp_b->ip2.addr_data32); *b = tmp_b; } else if ((a_ip1[0] == 0x00000000 && a_ip1[1] == 0x00000000 && a_ip1[2] == 0x00000000 && a_ip1[3] == 0x00000000) && !(a_ip2[0] == 0xFFFFFFFF && a_ip2[1] == 0xFFFFFFFF && a_ip2[2] == 0xFFFFFFFF && a_ip2[3] == 0xFFFFFFFF)) { - AddressCutIPv6CopyAddOne(a_ip2, a->ip); - AddressCutIPv6Copy(ip_max, a->ip2); + AddressCutIPv6CopyAddOne(a_ip2, a->ip.addr_data32); + AddressCutIPv6Copy(ip_max, a->ip2.addr_data32); } else if (!(a_ip1[0] == 0x00000000 && a_ip1[1] == 0x00000000 && a_ip1[2] == 0x00000000 && a_ip1[3] == 0x00000000) && (a_ip2[0] == 0xFFFFFFFF && a_ip2[1] == 0xFFFFFFFF && a_ip2[2] == 0xFFFFFFFF && a_ip2[3] == 0xFFFFFFFF)) { - AddressCutIPv6Copy(ip_nul, a->ip); - AddressCutIPv6CopySubOne(a_ip1, a->ip2); + AddressCutIPv6Copy(ip_nul, a->ip.addr_data32); + AddressCutIPv6CopySubOne(a_ip1, a->ip2.addr_data32); } else { goto error; } @@ -883,18 +944,12 @@ error: int DetectAddressJoinIPv6(DetectEngineCtx *de_ctx, DetectAddress *target, DetectAddress *source) { - if (AddressIPv6Lt(source->ip, target->ip)) { - target->ip[0] = source->ip[0]; - target->ip[1] = source->ip[1]; - target->ip[2] = source->ip[2]; - target->ip[3] = source->ip[3]; + if (AddressIPv6Lt(&source->ip, &target->ip)) { + COPY_ADDRESS(&source->ip, &target->ip); } - if (AddressIPv6Gt(source->ip, target->ip)) { - target->ip2[0] = source->ip2[0]; - target->ip2[1] = source->ip2[1]; - target->ip2[2] = source->ip2[2]; - target->ip2[3] = source->ip2[3]; + if (AddressIPv6Gt(&source->ip, &target->ip)) { + COPY_ADDRESS(&source->ip2, &target->ip2); } return 0; @@ -912,7 +967,7 @@ int AddressTestIPv6Gt01(void) uint32_t a[4] = { 1, 2, 3, 4 }; uint32_t b[4] = { 0, 2, 3, 4 }; - if (AddressIPv6Gt(a, b) == 1) + if (AddressIPv6GtU32(a, b) == 1) result = 1; return result; @@ -925,7 +980,7 @@ int AddressTestIPv6Gt02(void) uint32_t a[4] = { 0, 2, 3, 4 }; uint32_t b[4] = { 1, 2, 3, 4 }; - if (AddressIPv6Gt(a, b) == 0) + if (AddressIPv6GtU32(a, b) == 0) result = 1; return result; @@ -938,7 +993,7 @@ int AddressTestIPv6Gt03(void) uint32_t a[4] = { 1, 2, 3, 4 }; uint32_t b[4] = { 1, 2, 3, 4 }; - if (AddressIPv6Gt(a, b) == 0) + if (AddressIPv6GtU32(a, b) == 0) result = 1; return result; @@ -951,7 +1006,7 @@ int AddressTestIPv6Gt04(void) uint32_t a[4] = { 1, 2, 3, 5 }; uint32_t b[4] = { 1, 2, 3, 4 }; - if (AddressIPv6Gt(a, b) == 1) + if (AddressIPv6GtU32(a, b) == 1) result = 1; return result; @@ -964,7 +1019,7 @@ int AddressTestIPv6Lt01(void) uint32_t a[4] = { 0, 2, 3, 4 }; uint32_t b[4] = { 1, 2, 3, 4 }; - if (AddressIPv6Lt(a, b) == 1) + if (AddressIPv6LtU32(a, b) == 1) result = 1; return result; @@ -977,7 +1032,7 @@ int AddressTestIPv6Lt02(void) uint32_t a[4] = { 1, 2, 3, 4 }; uint32_t b[4] = { 0, 2, 3, 4 }; - if (AddressIPv6Lt(a, b) == 0) + if (AddressIPv6LtU32(a, b) == 0) result = 1; return result; @@ -990,7 +1045,7 @@ int AddressTestIPv6Lt03(void) uint32_t a[4] = { 1, 2, 3, 4 }; uint32_t b[4] = { 1, 2, 3, 4 }; - if (AddressIPv6Lt(a, b) == 0) + if (AddressIPv6LtU32(a, b) == 0) result = 1; return result; @@ -1003,7 +1058,7 @@ int AddressTestIPv6Lt04(void) uint32_t a[4] = { 1, 2, 3, 4 }; uint32_t b[4] = { 1, 2, 3, 5 }; - if (AddressIPv6Lt(a, b) == 1) + if (AddressIPv6LtU32(a, b) == 1) result = 1; return result; @@ -1016,7 +1071,7 @@ int AddressTestIPv6Eq01(void) uint32_t a[4] = { 0, 2, 3, 4 }; uint32_t b[4] = { 1, 2, 3, 4 }; - if (AddressIPv6Eq(a, b) == 0) + if (AddressIPv6EqU32(a, b) == 0) result = 1; return result; @@ -1029,7 +1084,7 @@ int AddressTestIPv6Eq02(void) uint32_t a[4] = { 1, 2, 3, 4 }; uint32_t b[4] = { 0, 2, 3, 4 }; - if (AddressIPv6Eq(a, b) == 0) + if (AddressIPv6EqU32(a, b) == 0) result = 1; return result; @@ -1042,7 +1097,7 @@ int AddressTestIPv6Eq03(void) uint32_t a[4] = { 1, 2, 3, 4 }; uint32_t b[4] = { 1, 2, 3, 4 }; - if (AddressIPv6Eq(a, b) == 1) + if (AddressIPv6EqU32(a, b) == 1) result = 1; return result; @@ -1055,7 +1110,7 @@ int AddressTestIPv6Eq04(void) uint32_t a[4] = { 1, 2, 3, 4 }; uint32_t b[4] = { 1, 2, 3, 5 }; - if (AddressIPv6Eq(a, b) == 0) + if (AddressIPv6EqU32(a, b) == 0) result = 1; return result; @@ -1068,7 +1123,7 @@ int AddressTestIPv6Le01(void) uint32_t a[4] = { 0, 2, 3, 4 }; uint32_t b[4] = { 1, 2, 3, 4 }; - if (AddressIPv6Le(a, b) == 1) + if (AddressIPv6LeU32(a, b) == 1) result = 1; return result; @@ -1081,7 +1136,7 @@ int AddressTestIPv6Le02(void) uint32_t a[4] = { 1, 2, 3, 4 }; uint32_t b[4] = { 0, 2, 3, 4 }; - if (AddressIPv6Le(a, b) == 0) + if (AddressIPv6LeU32(a, b) == 0) result = 1; return result; @@ -1094,7 +1149,7 @@ int AddressTestIPv6Le03(void) uint32_t a[4] = { 1, 2, 3, 4 }; uint32_t b[4] = { 1, 2, 3, 4 }; - if (AddressIPv6Le(a, b) == 1) + if (AddressIPv6LeU32(a, b) == 1) result = 1; return result; @@ -1107,7 +1162,7 @@ int AddressTestIPv6Le04(void) uint32_t a[4] = { 1, 2, 3, 4 }; uint32_t b[4] = { 1, 2, 3, 5 }; - if (AddressIPv6Le(a, b) == 1) + if (AddressIPv6LeU32(a, b) == 1) result = 1; return result; @@ -1127,7 +1182,7 @@ int AddressTestIPv6Le05(void) inet_pton(AF_INET6, "2000::0", &in6); memcpy(&b, &in6.s6_addr, sizeof(in6.s6_addr)); - if (AddressIPv6Le(a, b) == 1) + if (AddressIPv6LeU32(a, b) == 1) result = 1; return result; @@ -1140,7 +1195,7 @@ int AddressTestIPv6Ge01(void) uint32_t a[4] = { 0, 2, 3, 4 }; uint32_t b[4] = { 1, 2, 3, 4 }; - if (AddressIPv6Ge(a, b) == 0) + if (AddressIPv6GeU32(a, b) == 0) result = 1; return result; @@ -1153,7 +1208,7 @@ int AddressTestIPv6Ge02(void) uint32_t a[4] = { 1, 2, 3, 4 }; uint32_t b[4] = { 0, 2, 3, 4 }; - if (AddressIPv6Ge(a, b) == 1) + if (AddressIPv6GeU32(a, b) == 1) result = 1; return result; @@ -1166,7 +1221,7 @@ int AddressTestIPv6Ge03(void) uint32_t a[4] = { 1, 2, 3, 4 }; uint32_t b[4] = { 1, 2, 3, 4 }; - if (AddressIPv6Ge(a, b) == 1) + if (AddressIPv6GeU32(a, b) == 1) result = 1; return result; @@ -1179,7 +1234,7 @@ int AddressTestIPv6Ge04(void) uint32_t a[4] = { 1, 2, 3, 4 }; uint32_t b[4] = { 1, 2, 3, 5 }; - if (AddressIPv6Ge(a, b) == 0) + if (AddressIPv6GeU32(a, b) == 0) result = 1; return result; @@ -1199,7 +1254,7 @@ int AddressTestIPv6Ge05(void) inet_pton(AF_INET6, "2000::0", &in6); memcpy(&b, &in6.s6_addr, sizeof(in6.s6_addr)); - if (AddressIPv6Ge(a, b) == 0) + if (AddressIPv6GeU32(a, b) == 0) result = 1; return result; @@ -1325,424 +1380,424 @@ static int AddressTestIPv6AddressCmp01(void) if (inet_pton(AF_INET6, "2000::1", &in6) < 0) goto error; - memcpy(a->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::10", &in6) < 0) goto error; - memcpy(a->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::1", &in6) < 0) goto error; - memcpy(b->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&b->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::10", &in6) < 0) goto error; - memcpy(b->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&b->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); result &= (DetectAddressCmpIPv6(a, b) == ADDRESS_EQ); if (inet_pton(AF_INET6, "2000::1", &in6) < 0) goto error; - memcpy(a->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::10", &in6) < 0) goto error; - memcpy(a->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::0", &in6) < 0) goto error; - memcpy(b->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&b->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::10", &in6) < 0) goto error; - memcpy(b->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&b->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); result &= (DetectAddressCmpIPv6(a, b) == ADDRESS_ES); if (inet_pton(AF_INET6, "2000::1", &in6) < 0) goto error; - memcpy(a->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::10", &in6) < 0) goto error; - memcpy(a->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::1", &in6) < 0) goto error; - memcpy(b->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&b->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::11", &in6) < 0) goto error; - memcpy(b->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&b->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); result &= (DetectAddressCmpIPv6(a, b) == ADDRESS_ES); if (inet_pton(AF_INET6, "2000::1", &in6) < 0) goto error; - memcpy(a->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::10", &in6) < 0) goto error; - memcpy(a->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::0", &in6) < 0) goto error; - memcpy(b->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&b->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::10", &in6) < 0) goto error; - memcpy(b->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&b->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); result &= (DetectAddressCmpIPv6(a, b) == ADDRESS_ES); if (inet_pton(AF_INET6, "2000::1", &in6) < 0) goto error; - memcpy(a->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::10", &in6) < 0) goto error; - memcpy(a->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::0", &in6) < 0) goto error; - memcpy(b->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&b->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::11", &in6) < 0) goto error; - memcpy(b->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&b->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); result &= (DetectAddressCmpIPv6(a, b) == ADDRESS_ES); if (inet_pton(AF_INET6, "2000::1", &in6) < 0) goto error; - memcpy(a->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::11", &in6) < 0) goto error; - memcpy(a->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::1", &in6) < 0) goto error; - memcpy(b->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&b->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::10", &in6) < 0) goto error; - memcpy(b->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&b->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); result &= (DetectAddressCmpIPv6(a, b) != ADDRESS_ES); if (inet_pton(AF_INET6, "2000::1", &in6) < 0) goto error; - memcpy(a->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::11", &in6) < 0) goto error; - memcpy(a->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::1", &in6) < 0) goto error; - memcpy(b->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&b->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::10", &in6) < 0) goto error; - memcpy(b->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&b->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); result &= (DetectAddressCmpIPv6(a, b) == ADDRESS_EB); if (inet_pton(AF_INET6, "2000::0", &in6) < 0) goto error; - memcpy(a->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::10", &in6) < 0) goto error; - memcpy(a->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::1", &in6) < 0) goto error; - memcpy(b->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&b->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::10", &in6) < 0) goto error; - memcpy(b->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&b->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); result &= (DetectAddressCmpIPv6(a, b) == ADDRESS_EB); if (inet_pton(AF_INET6, "2000::0", &in6) < 0) goto error; - memcpy(a->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::11", &in6) < 0) goto error; - memcpy(a->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::1", &in6) < 0) goto error; - memcpy(b->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&b->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::10", &in6) < 0) goto error; - memcpy(b->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&b->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); result &= (DetectAddressCmpIPv6(a, b) == ADDRESS_EB); if (inet_pton(AF_INET6, "2000::1", &in6) < 0) goto error; - memcpy(a->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::11", &in6) < 0) goto error; - memcpy(a->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::0", &in6) < 0) goto error; - memcpy(b->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&b->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::10", &in6) < 0) goto error; - memcpy(b->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&b->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); result &= (DetectAddressCmpIPv6(a, b) != ADDRESS_EB); if (inet_pton(AF_INET6, "2000::0", &in6) < 0) goto error; - memcpy(a->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::10", &in6) < 0) goto error; - memcpy(a->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::10", &in6) < 0) goto error; - memcpy(b->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&b->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::20", &in6) < 0) goto error; - memcpy(b->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&b->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); result &= (DetectAddressCmpIPv6(a, b) == ADDRESS_LE); if (inet_pton(AF_INET6, "2000::1", &in6) < 0) goto error; - memcpy(a->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::15", &in6) < 0) goto error; - memcpy(a->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::10", &in6) < 0) goto error; - memcpy(b->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&b->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::20", &in6) < 0) goto error; - memcpy(b->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&b->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); result &= (DetectAddressCmpIPv6(a, b) == ADDRESS_LE); if (inet_pton(AF_INET6, "2000::1", &in6) < 0) goto error; - memcpy(a->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::10", &in6) < 0) goto error; - memcpy(a->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::1", &in6) < 0) goto error; - memcpy(b->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&b->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::20", &in6) < 0) goto error; - memcpy(b->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&b->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); result &= (DetectAddressCmpIPv6(a, b) != ADDRESS_LE); if (inet_pton(AF_INET6, "2000::0", &in6) < 0) goto error; - memcpy(a->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::10", &in6) < 0) goto error; - memcpy(a->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::1", &in6) < 0) goto error; - memcpy(b->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&b->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::20", &in6) < 0) goto error; - memcpy(b->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&b->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); result &= (DetectAddressCmpIPv6(a, b) == ADDRESS_LE); if (inet_pton(AF_INET6, "2000::0", &in6) < 0) goto error; - memcpy(a->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::10", &in6) < 0) goto error; - memcpy(a->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::1", &in6) < 0) goto error; - memcpy(b->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&b->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::10", &in6) < 0) goto error; - memcpy(b->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&b->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); result &= (DetectAddressCmpIPv6(a, b) != ADDRESS_LE); if (inet_pton(AF_INET6, "2000::1", &in6) < 0) goto error; - memcpy(a->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::10", &in6) < 0) goto error; - memcpy(a->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::15", &in6) < 0) goto error; - memcpy(b->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&b->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::20", &in6) < 0) goto error; - memcpy(b->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&b->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); result &= (DetectAddressCmpIPv6(a, b) == ADDRESS_LT); if (inet_pton(AF_INET6, "2000::1", &in6) < 0) goto error; - memcpy(a->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::15", &in6) < 0) goto error; - memcpy(a->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::10", &in6) < 0) goto error; - memcpy(b->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&b->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::20", &in6) < 0) goto error; - memcpy(b->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&b->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); /* we could get a LE */ result &= (DetectAddressCmpIPv6(a, b) != ADDRESS_LT); if (inet_pton(AF_INET6, "2000::1", &in6) < 0) goto error; - memcpy(a->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::10", &in6) < 0) goto error; - memcpy(a->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::10", &in6) < 0) goto error; - memcpy(b->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&b->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::20", &in6) < 0) goto error; - memcpy(b->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&b->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); /* we could get a LE */ result &= (DetectAddressCmpIPv6(a, b) != ADDRESS_LT); if (inet_pton(AF_INET6, "2000::1", &in6) < 0) goto error; - memcpy(a->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::19", &in6) < 0) goto error; - memcpy(a->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::10", &in6) < 0) goto error; - memcpy(b->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&b->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::20", &in6) < 0) goto error; - memcpy(b->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&b->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); result &= (DetectAddressCmpIPv6(a, b) != ADDRESS_LT); if (inet_pton(AF_INET6, "2000::1", &in6) < 0) goto error; - memcpy(a->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::20", &in6) < 0) goto error; - memcpy(a->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::10", &in6) < 0) goto error; - memcpy(b->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&b->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::20", &in6) < 0) goto error; - memcpy(b->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&b->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); result &= (DetectAddressCmpIPv6(a, b) != ADDRESS_LT); if (inet_pton(AF_INET6, "2000::1", &in6) < 0) goto error; - memcpy(a->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::10", &in6) < 0) goto error; - memcpy(a->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::1", &in6) < 0) goto error; - memcpy(b->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&b->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::20", &in6) < 0) goto error; - memcpy(b->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&b->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); result &= (DetectAddressCmpIPv6(a, b) != ADDRESS_LT); if (inet_pton(AF_INET6, "2000::10", &in6) < 0) goto error; - memcpy(a->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::20", &in6) < 0) goto error; - memcpy(a->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::1", &in6) < 0) goto error; - memcpy(b->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&b->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::10", &in6) < 0) goto error; - memcpy(b->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&b->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); result &= (DetectAddressCmpIPv6(a, b) == ADDRESS_GE); if (inet_pton(AF_INET6, "2000::10", &in6) < 0) goto error; - memcpy(a->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::20", &in6) < 0) goto error; - memcpy(a->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::1", &in6) < 0) goto error; - memcpy(b->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&b->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::15", &in6) < 0) goto error; - memcpy(b->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&b->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); result &= (DetectAddressCmpIPv6(a, b) == ADDRESS_GE); if (inet_pton(AF_INET6, "2000::1", &in6) < 0) goto error; - memcpy(a->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::20", &in6) < 0) goto error; - memcpy(a->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::1", &in6) < 0) goto error; - memcpy(b->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&b->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::15", &in6) < 0) goto error; - memcpy(b->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&b->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); result &= (DetectAddressCmpIPv6(a, b) != ADDRESS_GE); if (inet_pton(AF_INET6, "2000::1", &in6) < 0) goto error; - memcpy(a->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::20", &in6) < 0) goto error; - memcpy(a->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::0", &in6) < 0) goto error; - memcpy(b->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&b->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::10", &in6) < 0) goto error; - memcpy(b->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&b->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); result &= (DetectAddressCmpIPv6(a, b) == ADDRESS_GE); if (inet_pton(AF_INET6, "2000::0", &in6) < 0) goto error; - memcpy(a->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::20", &in6) < 0) goto error; - memcpy(a->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::1", &in6) < 0) goto error; - memcpy(b->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&b->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::19", &in6) < 0) goto error; - memcpy(b->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&b->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); result &= (DetectAddressCmpIPv6(a, b) != ADDRESS_GE); if (inet_pton(AF_INET6, "2000::1", &in6) < 0) goto error; - memcpy(a->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::20", &in6) < 0) goto error; - memcpy(a->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::0", &in6) < 0) goto error; - memcpy(b->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&b->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::20", &in6) < 0) goto error; - memcpy(b->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&b->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); result &= (DetectAddressCmpIPv6(a, b) != ADDRESS_GE); if (inet_pton(AF_INET6, "2000::15", &in6) < 0) goto error; - memcpy(a->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::20", &in6) < 0) goto error; - memcpy(a->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::1", &in6) < 0) goto error; - memcpy(b->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&b->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::10", &in6) < 0) goto error; - memcpy(b->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&b->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); result &= (DetectAddressCmpIPv6(a, b) == ADDRESS_GT); if (inet_pton(AF_INET6, "2000::15", &in6) < 0) goto error; - memcpy(a->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::20", &in6) < 0) goto error; - memcpy(a->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::1", &in6) < 0) goto error; - memcpy(b->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&b->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::15", &in6) < 0) goto error; - memcpy(b->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&b->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); result &= (DetectAddressCmpIPv6(a, b) != ADDRESS_GT); if (inet_pton(AF_INET6, "2000::10", &in6) < 0) goto error; - memcpy(a->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::20", &in6) < 0) goto error; - memcpy(a->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::1", &in6) < 0) goto error; - memcpy(b->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&b->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::10", &in6) < 0) goto error; - memcpy(b->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&b->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); result &= (DetectAddressCmpIPv6(a, b) != ADDRESS_GT); if (a != NULL) @@ -1771,10 +1826,10 @@ static int AddressTestIPv6CutNot01(void) if (inet_pton(AF_INET6, "::", &in6) < 0) goto error; - memcpy(a->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF", &in6) < 0) goto error; - memcpy(a->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); result &= (DetectAddressCutNotIPv6(a, &b) == -1); if (a != NULL) @@ -1806,20 +1861,20 @@ static int AddressTestIPv6CutNot02(void) if (inet_pton(AF_INET6, "::", &in6) < 0) goto error; - memcpy(a->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::0", &in6) < 0) goto error; - memcpy(a->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); result &= (DetectAddressCutNotIPv6(a, &b) == 0); result &= (b == NULL); if (inet_pton(AF_INET6, "2000::1", &in6) < 0) goto error; - memcpy(temp->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&temp->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF", &in6) < 0) goto error; - memcpy(temp->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&temp->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); result = (DetectAddressCmpIPv6(a, temp) == ADDRESS_EQ); @@ -1856,20 +1911,20 @@ static int AddressTestIPv6CutNot03(void) if (inet_pton(AF_INET6, "2000::1", &in6) < 0) goto error; - memcpy(a->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF", &in6) < 0) goto error; - memcpy(a->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); result &= (DetectAddressCutNotIPv6(a, &b) == 0); result &= (b == NULL); if (inet_pton(AF_INET6, "::", &in6) < 0) goto error; - memcpy(temp->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&temp->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::0", &in6) < 0) goto error; - memcpy(temp->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&temp->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); result = (DetectAddressCmpIPv6(a, temp) == ADDRESS_EQ); @@ -1906,18 +1961,18 @@ static int AddressTestIPv6CutNot04(void) if (inet_pton(AF_INET6, "2000::1", &in6) < 0) goto error; - memcpy(a->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::1", &in6) < 0) goto error; - memcpy(a->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); result &= (DetectAddressCutNotIPv6(a, &b) == 0); if (inet_pton(AF_INET6, "::", &in6) < 0) goto error; - memcpy(temp->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&temp->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::0", &in6) < 0) goto error; - memcpy(temp->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&temp->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); result = (DetectAddressCmpIPv6(a, temp) == ADDRESS_EQ); result &= (b != NULL); @@ -1925,10 +1980,10 @@ static int AddressTestIPv6CutNot04(void) goto error; if (inet_pton(AF_INET6, "2000::2", &in6) < 0) goto error; - memcpy(temp->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&temp->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF", &in6) < 0) goto error; - memcpy(temp->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&temp->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); result = (DetectAddressCmpIPv6(b, temp) == ADDRESS_EQ); if (a != NULL) @@ -1964,18 +2019,18 @@ static int AddressTestIPv6CutNot05(void) if (inet_pton(AF_INET6, "2000::1", &in6) < 0) goto error; - memcpy(a->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::20", &in6) < 0) goto error; - memcpy(a->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&a->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); result &= (DetectAddressCutNotIPv6(a, &b) == 0); if (inet_pton(AF_INET6, "::", &in6) < 0) goto error; - memcpy(temp->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&temp->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::0", &in6) < 0) goto error; - memcpy(temp->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&temp->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); result = (DetectAddressCmpIPv6(a, temp) == ADDRESS_EQ); result &= (b != NULL); @@ -1983,10 +2038,10 @@ static int AddressTestIPv6CutNot05(void) goto error; if (inet_pton(AF_INET6, "2000::21", &in6) < 0) goto error; - memcpy(temp->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&temp->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF", &in6) < 0) goto error; - memcpy(temp->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&temp->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); result = (DetectAddressCmpIPv6(b, temp) == ADDRESS_EQ); if (a != NULL) @@ -2021,121 +2076,121 @@ static int AddressTestIPv6Join01(void) /* case 1 */ if (inet_pton(AF_INET6, "2000::10", &in6) < 0) goto error; - memcpy(target->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&target->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::20", &in6) < 0) goto error; - memcpy(target->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&target->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::1", &in6) < 0) goto error; - memcpy(source->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&source->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000:20", &in6) < 0) goto error; - memcpy(source->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&source->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); result &= (DetectAddressJoinIPv6(NULL, target, source) == 0); if (inet_pton(AF_INET6, "2000::1", &in6) < 0) goto error; - memcpy(temp->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&temp->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::20", &in6) < 0) goto error; - memcpy(temp->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&temp->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); result = (DetectAddressCmpIPv6(target, temp) == ADDRESS_EQ); /* case 2 */ if (inet_pton(AF_INET6, "2000::1", &in6) < 0) goto error; - memcpy(target->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&target->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::20", &in6) < 0) goto error; - memcpy(target->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&target->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::2", &in6) < 0) goto error; - memcpy(source->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&source->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::19", &in6) < 0) goto error; - memcpy(source->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&source->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); result &= (DetectAddressJoinIPv6(NULL, target, source) == 0); if (inet_pton(AF_INET6, "2000::1", &in6) < 0) goto error; - memcpy(temp->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&temp->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::20", &in6) < 0) goto error; - memcpy(temp->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&temp->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); result = (DetectAddressCmpIPv6(target, temp) == ADDRESS_EQ); /* case 3 */ if (inet_pton(AF_INET6, "2000::1", &in6) < 0) goto error; - memcpy(target->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&target->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::15", &in6) < 0) goto error; - memcpy(target->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&target->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::10", &in6) < 0) goto error; - memcpy(source->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&source->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::20", &in6) < 0) goto error; - memcpy(source->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&source->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); result &= (DetectAddressJoinIPv6(NULL, target, source) == 0); if (inet_pton(AF_INET6, "2000::1", &in6) < 0) goto error; - memcpy(temp->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&temp->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::20", &in6) < 0) goto error; - memcpy(temp->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&temp->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); result = (DetectAddressCmpIPv6(target, temp) == ADDRESS_EQ); /* case 4 */ if (inet_pton(AF_INET6, "2000::10", &in6) < 0) goto error; - memcpy(target->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&target->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::20", &in6) < 0) goto error; - memcpy(target->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&target->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::1", &in6) < 0) goto error; - memcpy(source->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&source->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::20", &in6) < 0) goto error; - memcpy(source->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&source->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); result &= (DetectAddressJoinIPv6(NULL, target, source) == 0); if (inet_pton(AF_INET6, "2000::1", &in6) < 0) goto error; - memcpy(temp->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&temp->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::20", &in6) < 0) goto error; - memcpy(temp->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&temp->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); result = (DetectAddressCmpIPv6(target, temp) == ADDRESS_EQ); /* case 5 */ if (inet_pton(AF_INET6, "2000::1", &in6) < 0) goto error; - memcpy(target->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&target->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::20", &in6) < 0) goto error; - memcpy(target->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&target->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::1", &in6) < 0) goto error; - memcpy(source->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&source->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::20", &in6) < 0) goto error; - memcpy(source->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&source->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); result &= (DetectAddressJoinIPv6(NULL, target, source) == 0); if (inet_pton(AF_INET6, "2000::1", &in6) < 0) goto error; - memcpy(temp->ip, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&temp->ip.address, in6.s6_addr, sizeof(in6.s6_addr)); if (inet_pton(AF_INET6, "2000::20", &in6) < 0) goto error; - memcpy(temp->ip2, in6.s6_addr, sizeof(in6.s6_addr)); + memcpy(&temp->ip2.address, in6.s6_addr, sizeof(in6.s6_addr)); result = (DetectAddressCmpIPv6(target, temp) == ADDRESS_EQ); if (source != NULL) diff --git a/src/detect-engine-address-ipv6.h b/src/detect-engine-address-ipv6.h index aac22e49fc..dedf090bff 100644 --- a/src/detect-engine-address-ipv6.h +++ b/src/detect-engine-address-ipv6.h @@ -24,11 +24,11 @@ #ifndef __DETECT_ENGINE_ADDRESS_IPV6_H__ #define __DETECT_ENGINE_ADDRESS_IPV6_H__ -int AddressIPv6Lt(uint32_t *, uint32_t *); -int AddressIPv6Gt(uint32_t *, uint32_t *); -int AddressIPv6Eq(uint32_t *, uint32_t *); -int AddressIPv6Le(uint32_t *, uint32_t *); -int AddressIPv6Ge(uint32_t *, uint32_t *); +int AddressIPv6Lt(Address *, Address *); +int AddressIPv6Gt(Address *, Address *); +int AddressIPv6Eq(Address *, Address *); +int AddressIPv6Le(Address *, Address *); +int AddressIPv6Ge(Address *, Address *); int DetectAddressCutNotIPv6(DetectAddress *, DetectAddress **); int DetectAddressCmpIPv6(DetectAddress *a, DetectAddress *b); diff --git a/src/detect-engine-address.c b/src/detect-engine-address.c index 7e244a4d52..3c8974f491 100644 --- a/src/detect-engine-address.c +++ b/src/detect-engine-address.c @@ -153,22 +153,11 @@ DetectAddress *DetectAddressCopy(DetectAddress *orig) DetectAddress *ag = DetectAddressInit(); if (ag == NULL) return NULL; + ag->flags = orig->flags; - ag->family = orig->family; - - if (ag->family == AF_INET) { - ag->ip[0] = orig->ip[0]; - ag->ip2[0] = orig->ip2[0]; - } else if (ag->family == AF_INET6) { - ag->ip[0] = orig->ip[0]; - ag->ip[1] = orig->ip[1]; - ag->ip[2] = orig->ip[2]; - ag->ip[3] = orig->ip[3]; - ag->ip2[0] = orig->ip2[0]; - ag->ip2[1] = orig->ip2[1]; - ag->ip2[2] = orig->ip2[2]; - ag->ip2[3] = orig->ip2[3]; - } + + COPY_ADDRESS(&orig->ip, &ag->ip); + COPY_ADDRESS(&orig->ip2, &ag->ip2); ag->cnt = 1; @@ -345,12 +334,12 @@ static int SetHeadPtr(DetectAddressHead *gh, DetectAddress *newhead) { if (newhead->flags & ADDRESS_FLAG_ANY) { gh->any_head = newhead; - } else if (newhead->family == AF_INET) { + } else if (newhead->ip.family == AF_INET) { gh->ipv4_head = newhead; - } else if (newhead->family == AF_INET6) { + } else if (newhead->ip.family == AF_INET6) { gh->ipv6_head = newhead; } else { - SCLogDebug("newhead->family %u not supported", newhead->family); + SCLogDebug("newhead->family %u not supported", newhead->ip.family); return -1; } @@ -374,9 +363,9 @@ static DetectAddress *GetHeadPtr(DetectAddressHead *gh, DetectAddress *new) if (new->flags & ADDRESS_FLAG_ANY) head = gh->any_head; - else if (new->family == AF_INET) + else if (new->ip.family == AF_INET) head = gh->ipv4_head; - else if (new->family == AF_INET6) + else if (new->ip.family == AF_INET6) head = gh->ipv6_head; return head; @@ -408,7 +397,7 @@ int DetectAddressInsert(DetectEngineCtx *de_ctx, DetectAddressHead *gh, if (new == NULL) return 0; - BUG_ON(new->family == 0 && !(new->flags & ADDRESS_FLAG_ANY)); + BUG_ON(new->ip.family == 0 && !(new->flags & ADDRESS_FLAG_ANY)); /* get our head ptr based on the address we want to insert */ head = GetHeadPtr(gh, new); @@ -547,7 +536,7 @@ int DetectAddressJoin(DetectEngineCtx *de_ctx, DetectAddress *target, if (target == NULL || source == NULL) return -1; - if (target->family != source->family) + if (target->ip.family != source->ip.family) return -1; target->cnt += source->cnt; @@ -557,9 +546,9 @@ int DetectAddressJoin(DetectEngineCtx *de_ctx, DetectAddress *target, for ( ; port != NULL; port = port->next) DetectPortInsertCopy(de_ctx, &target->port, port); - if (target->family == AF_INET) + if (target->ip.family == AF_INET) return DetectAddressJoinIPv4(de_ctx, target, source); - else if (target->family == AF_INET6) + else if (target->ip.family == AF_INET6) return DetectAddressJoinIPv6(de_ctx, target, source); return -1; @@ -652,7 +641,7 @@ static int DetectAddressParseString(DetectAddress *dd, char *str) /* IPv4 Address */ struct in_addr in; - dd->family = AF_INET; + dd->ip.family = AF_INET; if ((mask = strchr(ip, '/')) != NULL) { /* 1.2.3.4/xxx format (either dotted or cidr notation */ @@ -690,8 +679,8 @@ static int DetectAddressParseString(DetectAddress *dd, char *str) ip4addr = in.s_addr; - dd->ip[0] = dd->ip2[0] = ip4addr & netmask; - dd->ip2[0] |=~ netmask; + dd->ip.addr_data32[0] = dd->ip2.addr_data32[0] = ip4addr & netmask; + dd->ip2.addr_data32[0] |=~ netmask; } else if ((ip2 = strchr(ip, '-')) != NULL) { /* 1.2.3.4-1.2.3.6 range format */ ip[ip2 - ip] = '\0'; @@ -700,15 +689,15 @@ static int DetectAddressParseString(DetectAddress *dd, char *str) r = inet_pton(AF_INET, ip, &in); if (r <= 0) goto error; - dd->ip[0] = in.s_addr; + dd->ip.addr_data32[0] = in.s_addr; r = inet_pton(AF_INET, ip2, &in); if (r <= 0) goto error; - dd->ip2[0] = in.s_addr; + dd->ip2.addr_data32[0] = in.s_addr; /* a > b is illegal, a = b is ok */ - if (ntohl(dd->ip[0]) > ntohl(dd->ip2[0])) + if (ntohl(dd->ip.addr_data32[0]) > ntohl(dd->ip2.addr_data32[0])) goto error; } else { /* 1.2.3.4 format */ @@ -716,15 +705,15 @@ static int DetectAddressParseString(DetectAddress *dd, char *str) if (r <= 0) goto error; /* single host */ - dd->ip[0] = in.s_addr; - dd->ip2[0] = in.s_addr; + dd->ip.addr_data32[0] = in.s_addr; + dd->ip2.addr_data32[0] = in.s_addr; } } else { /* IPv6 Address */ struct in6_addr in6, mask6; uint32_t ip6addr[4], netmask[4]; - dd->family = AF_INET6; + dd->ip.family = AF_INET6; if ((mask = strchr(ip, '/')) != NULL) { ip[mask - ip] = '\0'; @@ -738,15 +727,15 @@ static int DetectAddressParseString(DetectAddress *dd, char *str) DetectAddressParseIPv6CIDR(atoi(mask), &mask6); memcpy(&netmask, &mask6.s6_addr, sizeof(netmask)); - dd->ip2[0] = dd->ip[0] = ip6addr[0] & netmask[0]; - dd->ip2[1] = dd->ip[1] = ip6addr[1] & netmask[1]; - dd->ip2[2] = dd->ip[2] = ip6addr[2] & netmask[2]; - dd->ip2[3] = dd->ip[3] = ip6addr[3] & netmask[3]; + dd->ip2.addr_data32[0] = dd->ip.addr_data32[0] = ip6addr[0] & netmask[0]; + dd->ip2.addr_data32[1] = dd->ip.addr_data32[1] = ip6addr[1] & netmask[1]; + dd->ip2.addr_data32[2] = dd->ip.addr_data32[2] = ip6addr[2] & netmask[2]; + dd->ip2.addr_data32[3] = dd->ip.addr_data32[3] = ip6addr[3] & netmask[3]; - dd->ip2[0] |=~ netmask[0]; - dd->ip2[1] |=~ netmask[1]; - dd->ip2[2] |=~ netmask[2]; - dd->ip2[3] |=~ netmask[3]; + dd->ip2.addr_data32[0] |=~ netmask[0]; + dd->ip2.addr_data32[1] |=~ netmask[1]; + dd->ip2.addr_data32[2] |=~ netmask[2]; + dd->ip2.addr_data32[3] |=~ netmask[3]; } else if ((ip2 = strchr(ip, '-')) != NULL) { /* 2001::1-2001::4 range format */ ip[ip2 - ip] = '\0'; @@ -755,30 +744,30 @@ static int DetectAddressParseString(DetectAddress *dd, char *str) r = inet_pton(AF_INET6, ip, &in6); if (r <= 0) goto error; - memcpy(dd->ip, &in6.s6_addr, sizeof(ip6addr)); + memcpy(&dd->ip.address, &in6.s6_addr, sizeof(ip6addr)); r = inet_pton(AF_INET6, ip2, &in6); if (r <= 0) goto error; - memcpy(dd->ip2, &in6.s6_addr, sizeof(ip6addr)); + memcpy(&dd->ip2.address, &in6.s6_addr, sizeof(ip6addr)); /* a > b is illegal, a=b is ok */ - if (AddressIPv6Gt(dd->ip, dd->ip2)) + if (AddressIPv6Gt(&dd->ip, &dd->ip2)) goto error; } else { r = inet_pton(AF_INET6, ip, &in6); if (r <= 0) goto error; - memcpy(&dd->ip, &in6.s6_addr, sizeof(dd->ip)); - memcpy(&dd->ip2, &in6.s6_addr, sizeof(dd->ip2)); + memcpy(&dd->ip.address, &in6.s6_addr, sizeof(dd->ip.address)); + memcpy(&dd->ip2.address, &in6.s6_addr, sizeof(dd->ip2.address)); } } SCFree(ipdup); - BUG_ON(dd->family == 0); + BUG_ON(dd->ip.family == 0); return 0; @@ -887,7 +876,7 @@ int DetectAddressSetup(DetectAddressHead *gh, char *s) if (ad == NULL) goto error; - BUG_ON(ad->family == 0); + BUG_ON(ad->ip.family == 0); if (DetectAddressInsert(NULL, gh, ad) < 0) { SCLogDebug("DetectAddressInsert failed"); @@ -897,7 +886,7 @@ int DetectAddressSetup(DetectAddressHead *gh, char *s) if (ad == NULL) goto error; - BUG_ON(ad->family == 0); + BUG_ON(ad->ip.family == 0); if (DetectAddressInsert(NULL, gh, ad) < 0) { SCLogDebug("DetectAddressInsert failed"); @@ -1348,9 +1337,9 @@ void DetectAddressHeadFree(DetectAddressHead *gh) int DetectAddressCut(DetectEngineCtx *de_ctx, DetectAddress *a, DetectAddress *b, DetectAddress **c) { - if (a->family == AF_INET) + if (a->ip.family == AF_INET) return DetectAddressCutIPv4(de_ctx, a, b, c); - else if (a->family == AF_INET6) + else if (a->ip.family == AF_INET6) return DetectAddressCutIPv6(de_ctx, a, b, c); return -1; @@ -1389,9 +1378,9 @@ int DetectAddressCut(DetectEngineCtx *de_ctx, DetectAddress *a, */ int DetectAddressCutNot(DetectAddress *a, DetectAddress **b) { - if (a->family == AF_INET) + if (a->ip.family == AF_INET) return DetectAddressCutNotIPv4(a, b); - else if (a->family == AF_INET6) + else if (a->ip.family == AF_INET6) return DetectAddressCutNotIPv6(a, b); return -1; @@ -1405,15 +1394,15 @@ int DetectAddressCutNot(DetectAddress *a, DetectAddress **b) */ int DetectAddressCmp(DetectAddress *a, DetectAddress *b) { - if (a->family != b->family) + if (a->ip.family != b->ip.family) return ADDRESS_ER; /* check any */ if (a->flags & ADDRESS_FLAG_ANY && b->flags & ADDRESS_FLAG_ANY) return ADDRESS_EQ; - else if (a->family == AF_INET) + else if (a->ip.family == AF_INET) return DetectAddressCmpIPv4(a, b); - else if (a->family == AF_INET6) + else if (a->ip.family == AF_INET6) return DetectAddressCmpIPv6(a, b); return ADDRESS_ER; @@ -1436,7 +1425,7 @@ int DetectAddressMatch(DetectAddress *dd, Address *a) { SCEnter(); - if (dd->family != a->family) { + if (dd->ip.family != a->family) { SCReturnInt(0); } @@ -1448,8 +1437,8 @@ int DetectAddressMatch(DetectAddress *dd, Address *a) /* XXX figure out a way to not need to do this ntohl if we switch to * Address inside DetectAddressData we can do uint8_t checks */ - if (ntohl(a->addr_data32[0]) >= ntohl(dd->ip[0]) && - ntohl(a->addr_data32[0]) <= ntohl(dd->ip2[0])) + if (ntohl(a->addr_data32[0]) >= ntohl(dd->ip.addr_data32[0]) && + ntohl(a->addr_data32[0]) <= ntohl(dd->ip2.addr_data32[0])) { SCReturnInt(1); } else { @@ -1458,8 +1447,9 @@ int DetectAddressMatch(DetectAddress *dd, Address *a) break; case AF_INET6: - if (AddressIPv6Ge(a->addr_data32, dd->ip) == 1 && - AddressIPv6Le(a->addr_data32, dd->ip2) == 1) { + if (AddressIPv6Ge(a, &dd->ip) == 1 && + AddressIPv6Le(a, &dd->ip2) == 1) + { SCReturnInt(1); } else { SCReturnInt(0); @@ -1489,18 +1479,18 @@ void DetectAddressPrint(DetectAddress *gr) if (gr->flags & ADDRESS_FLAG_ANY) { SCLogDebug("ANY"); - } else if (gr->family == AF_INET) { + } else if (gr->ip.family == AF_INET) { struct in_addr in; char ip[16], mask[16]; - memcpy(&in, &gr->ip[0], sizeof(in)); + memcpy(&in, &gr->ip.addr_data32[0], sizeof(in)); inet_ntop(AF_INET, &in, ip, sizeof(ip)); - memcpy(&in, &gr->ip2[0], sizeof(in)); + memcpy(&in, &gr->ip2.addr_data32[0], sizeof(in)); inet_ntop(AF_INET, &in, mask, sizeof(mask)); SCLogDebug("%s/%s", ip, mask); // printf("%s/%s", ip, mask); - } else if (gr->family == AF_INET6) { + } else if (gr->ip.family == AF_INET6) { struct in6_addr in6; char ip[66], mask[66]; @@ -1578,8 +1568,8 @@ int AddressTestParse02(void) DetectAddress *dd = DetectAddressParseSingle("1.2.3.4"); if (dd) { - if (dd->ip2[0] != 0x04030201 || - dd->ip[0] != 0x04030201) { + if (dd->ip2.addr_data32[0] != 0x04030201 || + dd->ip.addr_data32[0] != 0x04030201) { result = 0; } @@ -1608,8 +1598,8 @@ int AddressTestParse04(void) DetectAddress *dd = DetectAddressParseSingle("1.2.3.4/255.255.255.0"); if (dd) { - if (dd->ip2[0] != 0xff030201 || - dd->ip[0] != 0x00030201) { + if (dd->ip2.addr_data32[0] != 0xff030201 || + dd->ip.addr_data32[0] != 0x00030201) { result = 0; } @@ -1638,8 +1628,8 @@ int AddressTestParse06(void) DetectAddress *dd = DetectAddressParseSingle("1.2.3.4/24"); if (dd) { - if (dd->ip2[0] != 0xff030201 || - dd->ip[0] != 0x00030201) { + if (dd->ip2.addr_data32[0] != 0xff030201 || + dd->ip.addr_data32[0] != 0x00030201) { result = 0; } @@ -1668,11 +1658,11 @@ int AddressTestParse08(void) DetectAddress *dd = DetectAddressParseSingle("2001::/3"); if (dd) { - if (dd->ip[0] != 0x00000020 || dd->ip[1] != 0x00000000 || - dd->ip[2] != 0x00000000 || dd->ip[3] != 0x00000000 || + if (dd->ip.addr_data32[0] != 0x00000020 || dd->ip.addr_data32[1] != 0x00000000 || + dd->ip.addr_data32[2] != 0x00000000 || dd->ip.addr_data32[3] != 0x00000000 || - dd->ip2[0] != 0xFFFFFF3F || dd->ip2[1] != 0xFFFFFFFF || - dd->ip2[2] != 0xFFFFFFFF || dd->ip2[3] != 0xFFFFFFFF) { + dd->ip2.addr_data32[0] != 0xFFFFFF3F || dd->ip2.addr_data32[1] != 0xFFFFFFFF || + dd->ip2.addr_data32[2] != 0xFFFFFFFF || dd->ip2.addr_data32[3] != 0xFFFFFFFF) { DetectAddressPrint(dd); result = 0; } @@ -1702,11 +1692,11 @@ int AddressTestParse10(void) DetectAddress *dd = DetectAddressParseSingle("2001::/128"); if (dd) { - if (dd->ip[0] != 0x00000120 || dd->ip[1] != 0x00000000 || - dd->ip[2] != 0x00000000 || dd->ip[3] != 0x00000000 || + if (dd->ip.addr_data32[0] != 0x00000120 || dd->ip.addr_data32[1] != 0x00000000 || + dd->ip.addr_data32[2] != 0x00000000 || dd->ip.addr_data32[3] != 0x00000000 || - dd->ip2[0] != 0x00000120 || dd->ip2[1] != 0x00000000 || - dd->ip2[2] != 0x00000000 || dd->ip2[3] != 0x00000000) { + dd->ip2.addr_data32[0] != 0x00000120 || dd->ip2.addr_data32[1] != 0x00000000 || + dd->ip2.addr_data32[2] != 0x00000000 || dd->ip2.addr_data32[3] != 0x00000000) { DetectAddressPrint(dd); result = 0; } @@ -1736,11 +1726,11 @@ int AddressTestParse12(void) DetectAddress *dd = DetectAddressParseSingle("2001::/48"); if (dd) { - if (dd->ip[0] != 0x00000120 || dd->ip[1] != 0x00000000 || - dd->ip[2] != 0x00000000 || dd->ip[3] != 0x00000000 || + if (dd->ip.addr_data32[0] != 0x00000120 || dd->ip.addr_data32[1] != 0x00000000 || + dd->ip.addr_data32[2] != 0x00000000 || dd->ip.addr_data32[3] != 0x00000000 || - dd->ip2[0] != 0x00000120 || dd->ip2[1] != 0xFFFF0000 || - dd->ip2[2] != 0xFFFFFFFF || dd->ip2[3] != 0xFFFFFFFF) { + dd->ip2.addr_data32[0] != 0x00000120 || dd->ip2.addr_data32[1] != 0xFFFF0000 || + dd->ip2.addr_data32[2] != 0xFFFFFFFF || dd->ip2.addr_data32[3] != 0xFFFFFFFF) { DetectAddressPrint(dd); result = 0; } @@ -1769,11 +1759,11 @@ int AddressTestParse14(void) DetectAddress *dd = DetectAddressParseSingle("2001::/16"); if (dd) { - if (dd->ip[0] != 0x00000120 || dd->ip[1] != 0x00000000 || - dd->ip[2] != 0x00000000 || dd->ip[3] != 0x00000000 || + if (dd->ip.addr_data32[0] != 0x00000120 || dd->ip.addr_data32[1] != 0x00000000 || + dd->ip.addr_data32[2] != 0x00000000 || dd->ip.addr_data32[3] != 0x00000000 || - dd->ip2[0] != 0xFFFF0120 || dd->ip2[1] != 0xFFFFFFFF || - dd->ip2[2] != 0xFFFFFFFF || dd->ip2[3] != 0xFFFFFFFF) { + dd->ip2.addr_data32[0] != 0xFFFF0120 || dd->ip2.addr_data32[1] != 0xFFFFFFFF || + dd->ip2.addr_data32[2] != 0xFFFFFFFF || dd->ip2.addr_data32[3] != 0xFFFFFFFF) { result = 0; } @@ -1802,11 +1792,11 @@ int AddressTestParse16(void) DetectAddress *dd = DetectAddressParseSingle("2001::/0"); if (dd) { - if (dd->ip[0] != 0x00000000 || dd->ip[1] != 0x00000000 || - dd->ip[2] != 0x00000000 || dd->ip[3] != 0x00000000 || + if (dd->ip.addr_data32[0] != 0x00000000 || dd->ip.addr_data32[1] != 0x00000000 || + dd->ip.addr_data32[2] != 0x00000000 || dd->ip.addr_data32[3] != 0x00000000 || - dd->ip2[0] != 0xFFFFFFFF || dd->ip2[1] != 0xFFFFFFFF || - dd->ip2[2] != 0xFFFFFFFF || dd->ip2[3] != 0xFFFFFFFF) { + dd->ip2.addr_data32[0] != 0xFFFFFFFF || dd->ip2.addr_data32[1] != 0xFFFFFFFF || + dd->ip2.addr_data32[2] != 0xFFFFFFFF || dd->ip2.addr_data32[3] != 0xFFFFFFFF) { result = 0; } @@ -1835,8 +1825,8 @@ int AddressTestParse18(void) DetectAddress *dd = DetectAddressParseSingle("1.2.3.4-1.2.3.6"); if (dd) { - if (dd->ip2[0] != 0x06030201 || - dd->ip[0] != 0x04030201) { + if (dd->ip2.addr_data32[0] != 0x06030201 || + dd->ip.addr_data32[0] != 0x04030201) { result = 0; } @@ -1877,11 +1867,11 @@ int AddressTestParse21(void) DetectAddress *dd = DetectAddressParseSingle("2001::1-2001::4"); if (dd) { - if (dd->ip[0] != 0x00000120 || dd->ip[1] != 0x00000000 || - dd->ip[2] != 0x00000000 || dd->ip[3] != 0x01000000 || + if (dd->ip.addr_data32[0] != 0x00000120 || dd->ip.addr_data32[1] != 0x00000000 || + dd->ip.addr_data32[2] != 0x00000000 || dd->ip.addr_data32[3] != 0x01000000 || - dd->ip2[0] != 0x00000120 || dd->ip2[1] != 0x00000000 || - dd->ip2[2] != 0x00000000 || dd->ip2[3] != 0x04000000) { + dd->ip2.addr_data32[0] != 0x00000120 || dd->ip2.addr_data32[1] != 0x00000000 || + dd->ip2.addr_data32[2] != 0x00000000 || dd->ip2.addr_data32[3] != 0x04000000) { result = 0; } @@ -1975,7 +1965,7 @@ int AddressTestParse28(void) if (dd) { if (dd->flags & ADDRESS_FLAG_NOT && - dd->ip[0] == 0x04030201) { + dd->ip.addr_data32[0] == 0x04030201) { result = 1; } @@ -2005,8 +1995,8 @@ int AddressTestParse30(void) if (dd) { if (dd->flags & ADDRESS_FLAG_NOT && - dd->ip[0] == 0x00030201 && - dd->ip2[0] == 0xFF030201) { + dd->ip.addr_data32[0] == 0x00030201 && + dd->ip2.addr_data32[0] == 0xFF030201) { result = 1; } @@ -2051,8 +2041,8 @@ int AddressTestParse33(void) if (dd) { if (dd->flags & ADDRESS_FLAG_NOT && - dd->ip[0] == 0x00000120 && dd->ip[1] == 0x00000000 && - dd->ip[2] == 0x00000000 && dd->ip[3] == 0x01000000) { + dd->ip.addr_data32[0] == 0x00000120 && dd->ip.addr_data32[1] == 0x00000000 && + dd->ip.addr_data32[2] == 0x00000000 && dd->ip.addr_data32[3] == 0x01000000) { result = 1; } @@ -2082,11 +2072,11 @@ int AddressTestParse35(void) if (dd) { if (dd->flags & ADDRESS_FLAG_NOT && - dd->ip[0] == 0x00000120 && dd->ip[1] == 0x00000000 && - dd->ip[2] == 0x00000000 && dd->ip[3] == 0x00000000 && + dd->ip.addr_data32[0] == 0x00000120 && dd->ip.addr_data32[1] == 0x00000000 && + dd->ip.addr_data32[2] == 0x00000000 && dd->ip.addr_data32[3] == 0x00000000 && - dd->ip2[0] == 0xFFFF0120 && dd->ip2[1] == 0xFFFFFFFF && - dd->ip2[2] == 0xFFFFFFFF && dd->ip2[3] == 0xFFFFFFFF) { + dd->ip2.addr_data32[0] == 0xFFFF0120 && dd->ip2.addr_data32[1] == 0xFFFFFFFF && + dd->ip2.addr_data32[2] == 0xFFFFFFFF && dd->ip2.addr_data32[3] == 0xFFFFFFFF) { result = 1; } @@ -2926,11 +2916,11 @@ int AddressTestAddressGroupSetup11(void) * 10.10.11.0/10.10.11.1 * 10.10.11.2/255.255.255.255 */ - if (one->ip[0] == 0x00000000 && one->ip2[0] == 0xFF090A0A && - two->ip[0] == 0x000A0A0A && two->ip2[0] == 0x090A0A0A && - three->ip[0] == 0x0A0A0A0A && three->ip2[0] == 0xFF0A0A0A && - four->ip[0] == 0x000B0A0A && four->ip2[0] == 0x010B0A0A && - five->ip[0] == 0x020B0A0A && five->ip2[0] == 0xFFFFFFFF) { + if (one->ip.addr_data32[0] == 0x00000000 && one->ip2.addr_data32[0] == 0xFF090A0A && + two->ip.addr_data32[0] == 0x000A0A0A && two->ip2.addr_data32[0] == 0x090A0A0A && + three->ip.addr_data32[0] == 0x0A0A0A0A && three->ip2.addr_data32[0] == 0xFF0A0A0A && + four->ip.addr_data32[0] == 0x000B0A0A && four->ip2.addr_data32[0] == 0x010B0A0A && + five->ip.addr_data32[0] == 0x020B0A0A && five->ip2.addr_data32[0] == 0xFFFFFFFF) { result = 1; } } @@ -2965,11 +2955,11 @@ int AddressTestAddressGroupSetup12 (void) * 10.10.11.0/10.10.11.1 * 10.10.11.2/255.255.255.255 */ - if (one->ip[0] == 0x00000000 && one->ip2[0] == 0xFF090A0A && - two->ip[0] == 0x000A0A0A && two->ip2[0] == 0x090A0A0A && - three->ip[0] == 0x0A0A0A0A && three->ip2[0] == 0xFF0A0A0A && - four->ip[0] == 0x000B0A0A && four->ip2[0] == 0x010B0A0A && - five->ip[0] == 0x020B0A0A && five->ip2[0] == 0xFFFFFFFF) { + if (one->ip.addr_data32[0] == 0x00000000 && one->ip2.addr_data32[0] == 0xFF090A0A && + two->ip.addr_data32[0] == 0x000A0A0A && two->ip2.addr_data32[0] == 0x090A0A0A && + three->ip.addr_data32[0] == 0x0A0A0A0A && three->ip2.addr_data32[0] == 0xFF0A0A0A && + four->ip.addr_data32[0] == 0x000B0A0A && four->ip2.addr_data32[0] == 0x010B0A0A && + five->ip.addr_data32[0] == 0x020B0A0A && five->ip2.addr_data32[0] == 0xFFFFFFFF) { result = 1; } } @@ -3004,11 +2994,11 @@ int AddressTestAddressGroupSetup13(void) * 10.10.11.0/10.10.11.1 * 10.10.11.2/255.255.255.255 */ - if (one->ip[0] == 0x00000000 && one->ip2[0] == 0xFF090A0A && - two->ip[0] == 0x000A0A0A && two->ip2[0] == 0x090A0A0A && - three->ip[0] == 0x0A0A0A0A && three->ip2[0] == 0xFF0A0A0A && - four->ip[0] == 0x000B0A0A && four->ip2[0] == 0x010B0A0A && - five->ip[0] == 0x020B0A0A && five->ip2[0] == 0xFFFFFFFF) { + if (one->ip.addr_data32[0] == 0x00000000 && one->ip2.addr_data32[0] == 0xFF090A0A && + two->ip.addr_data32[0] == 0x000A0A0A && two->ip2.addr_data32[0] == 0x090A0A0A && + three->ip.addr_data32[0] == 0x0A0A0A0A && three->ip2.addr_data32[0] == 0xFF0A0A0A && + four->ip.addr_data32[0] == 0x000B0A0A && four->ip2.addr_data32[0] == 0x010B0A0A && + five->ip.addr_data32[0] == 0x020B0A0A && five->ip2.addr_data32[0] == 0xFFFFFFFF) { result = 1; } } @@ -3036,8 +3026,8 @@ int AddressTestAddressGroupSetupIPv414(void) * 0.0.0.0/1.2.3.3 * 1.2.3.5/255.255.255.255 */ - if (one->ip[0] == 0x00000000 && one->ip2[0] == 0x03030201 && - two->ip[0] == 0x05030201 && two->ip2[0] == 0xFFFFFFFF) { + if (one->ip.addr_data32[0] == 0x00000000 && one->ip2.addr_data32[0] == 0x03030201 && + two->ip.addr_data32[0] == 0x05030201 && two->ip2.addr_data32[0] == 0xFFFFFFFF) { result = 1; } else { printf("unexpected addresses: "); @@ -3068,7 +3058,7 @@ int AddressTestAddressGroupSetupIPv415(void) /* result should be: * 0.0.0.1/255.255.255.255 */ - if (one->ip[0] == 0x01000000 && one->ip2[0] == 0xFFFFFFFF) + if (one->ip.addr_data32[0] == 0x01000000 && one->ip2.addr_data32[0] == 0xFFFFFFFF) result = 1; } } @@ -3092,7 +3082,7 @@ int AddressTestAddressGroupSetupIPv416(void) /* result should be: * 0.0.0.0/255.255.255.254 */ - if (one->ip[0] == 0x00000000 && one->ip2[0] == 0xFEFFFFFF) + if (one->ip.addr_data32[0] == 0x00000000 && one->ip2.addr_data32[0] == 0xFEFFFFFF) result = 1; } } @@ -3331,50 +3321,50 @@ int AddressTestAddressGroupSetup24(void) DetectAddress *one = gh->ipv6_head, *two = one->next, *three = two->next, *four = three->next, *five = four->next; - if (one->ip[0] == 0x00000000 && - one->ip[1] == 0x00000000 && - one->ip[2] == 0x00000000 && - one->ip[3] == 0x00000000 && - one->ip2[0] == 0xFFFFFF1F && - one->ip2[1] == 0xFFFFFFFF && - one->ip2[2] == 0xFFFFFFFF && - one->ip2[3] == 0xFFFFFFFF && - - two->ip[0] == 0x00000020 && - two->ip[1] == 0x00000000 && - two->ip[2] == 0x00000000 && - two->ip[3] == 0x00000000 && - two->ip2[0] == 0x00000120 && - two->ip2[1] == 0x00000000 && - two->ip2[2] == 0x00000000 && - two->ip2[3] == 0x03000000 && - - three->ip[0] == 0x00000120 && - three->ip[1] == 0x00000000 && - three->ip[2] == 0x00000000 && - three->ip[3] == 0x04000000 && - three->ip2[0] == 0x00000120 && - three->ip2[1] == 0x00000000 && - three->ip2[2] == 0x00000000 && - three->ip2[3] == 0x06000000 && - - four->ip[0] == 0x00000120 && - four->ip[1] == 0x00000000 && - four->ip[2] == 0x00000000 && - four->ip[3] == 0x07000000 && - four->ip2[0] == 0xFFFFFF3F && - four->ip2[1] == 0xFFFFFFFF && - four->ip2[2] == 0xFFFFFFFF && - four->ip2[3] == 0xFFFFFFFF && - - five->ip[0] == 0x00000040 && - five->ip[1] == 0x00000000 && - five->ip[2] == 0x00000000 && - five->ip[3] == 0x00000000 && - five->ip2[0] == 0xFFFFFFFF && - five->ip2[1] == 0xFFFFFFFF && - five->ip2[2] == 0xFFFFFFFF && - five->ip2[3] == 0xFFFFFFFF) { + if (one->ip.addr_data32[0] == 0x00000000 && + one->ip.addr_data32[1] == 0x00000000 && + one->ip.addr_data32[2] == 0x00000000 && + one->ip.addr_data32[3] == 0x00000000 && + one->ip2.addr_data32[0] == 0xFFFFFF1F && + one->ip2.addr_data32[1] == 0xFFFFFFFF && + one->ip2.addr_data32[2] == 0xFFFFFFFF && + one->ip2.addr_data32[3] == 0xFFFFFFFF && + + two->ip.addr_data32[0] == 0x00000020 && + two->ip.addr_data32[1] == 0x00000000 && + two->ip.addr_data32[2] == 0x00000000 && + two->ip.addr_data32[3] == 0x00000000 && + two->ip2.addr_data32[0] == 0x00000120 && + two->ip2.addr_data32[1] == 0x00000000 && + two->ip2.addr_data32[2] == 0x00000000 && + two->ip2.addr_data32[3] == 0x03000000 && + + three->ip.addr_data32[0] == 0x00000120 && + three->ip.addr_data32[1] == 0x00000000 && + three->ip.addr_data32[2] == 0x00000000 && + three->ip.addr_data32[3] == 0x04000000 && + three->ip2.addr_data32[0] == 0x00000120 && + three->ip2.addr_data32[1] == 0x00000000 && + three->ip2.addr_data32[2] == 0x00000000 && + three->ip2.addr_data32[3] == 0x06000000 && + + four->ip.addr_data32[0] == 0x00000120 && + four->ip.addr_data32[1] == 0x00000000 && + four->ip.addr_data32[2] == 0x00000000 && + four->ip.addr_data32[3] == 0x07000000 && + four->ip2.addr_data32[0] == 0xFFFFFF3F && + four->ip2.addr_data32[1] == 0xFFFFFFFF && + four->ip2.addr_data32[2] == 0xFFFFFFFF && + four->ip2.addr_data32[3] == 0xFFFFFFFF && + + five->ip.addr_data32[0] == 0x00000040 && + five->ip.addr_data32[1] == 0x00000000 && + five->ip.addr_data32[2] == 0x00000000 && + five->ip.addr_data32[3] == 0x00000000 && + five->ip2.addr_data32[0] == 0xFFFFFFFF && + five->ip2.addr_data32[1] == 0xFFFFFFFF && + five->ip2.addr_data32[2] == 0xFFFFFFFF && + five->ip2.addr_data32[3] == 0xFFFFFFFF) { result = 1; } } @@ -3401,50 +3391,50 @@ int AddressTestAddressGroupSetup25(void) DetectAddress *one = gh->ipv6_head, *two = one->next, *three = two->next, *four = three->next, *five = four->next; - if (one->ip[0] == 0x00000000 && - one->ip[1] == 0x00000000 && - one->ip[2] == 0x00000000 && - one->ip[3] == 0x00000000 && - one->ip2[0] == 0xFFFFFF1F && - one->ip2[1] == 0xFFFFFFFF && - one->ip2[2] == 0xFFFFFFFF && - one->ip2[3] == 0xFFFFFFFF && - - two->ip[0] == 0x00000020 && - two->ip[1] == 0x00000000 && - two->ip[2] == 0x00000000 && - two->ip[3] == 0x00000000 && - two->ip2[0] == 0x00000120 && - two->ip2[1] == 0x00000000 && - two->ip2[2] == 0x00000000 && - two->ip2[3] == 0x03000000 && - - three->ip[0] == 0x00000120 && - three->ip[1] == 0x00000000 && - three->ip[2] == 0x00000000 && - three->ip[3] == 0x04000000 && - three->ip2[0] == 0x00000120 && - three->ip2[1] == 0x00000000 && - three->ip2[2] == 0x00000000 && - three->ip2[3] == 0x06000000 && - - four->ip[0] == 0x00000120 && - four->ip[1] == 0x00000000 && - four->ip[2] == 0x00000000 && - four->ip[3] == 0x07000000 && - four->ip2[0] == 0xFFFFFF3F && - four->ip2[1] == 0xFFFFFFFF && - four->ip2[2] == 0xFFFFFFFF && - four->ip2[3] == 0xFFFFFFFF && - - five->ip[0] == 0x00000040 && - five->ip[1] == 0x00000000 && - five->ip[2] == 0x00000000 && - five->ip[3] == 0x00000000 && - five->ip2[0] == 0xFFFFFFFF && - five->ip2[1] == 0xFFFFFFFF && - five->ip2[2] == 0xFFFFFFFF && - five->ip2[3] == 0xFFFFFFFF) { + if (one->ip.addr_data32[0] == 0x00000000 && + one->ip.addr_data32[1] == 0x00000000 && + one->ip.addr_data32[2] == 0x00000000 && + one->ip.addr_data32[3] == 0x00000000 && + one->ip2.addr_data32[0] == 0xFFFFFF1F && + one->ip2.addr_data32[1] == 0xFFFFFFFF && + one->ip2.addr_data32[2] == 0xFFFFFFFF && + one->ip2.addr_data32[3] == 0xFFFFFFFF && + + two->ip.addr_data32[0] == 0x00000020 && + two->ip.addr_data32[1] == 0x00000000 && + two->ip.addr_data32[2] == 0x00000000 && + two->ip.addr_data32[3] == 0x00000000 && + two->ip2.addr_data32[0] == 0x00000120 && + two->ip2.addr_data32[1] == 0x00000000 && + two->ip2.addr_data32[2] == 0x00000000 && + two->ip2.addr_data32[3] == 0x03000000 && + + three->ip.addr_data32[0] == 0x00000120 && + three->ip.addr_data32[1] == 0x00000000 && + three->ip.addr_data32[2] == 0x00000000 && + three->ip.addr_data32[3] == 0x04000000 && + three->ip2.addr_data32[0] == 0x00000120 && + three->ip2.addr_data32[1] == 0x00000000 && + three->ip2.addr_data32[2] == 0x00000000 && + three->ip2.addr_data32[3] == 0x06000000 && + + four->ip.addr_data32[0] == 0x00000120 && + four->ip.addr_data32[1] == 0x00000000 && + four->ip.addr_data32[2] == 0x00000000 && + four->ip.addr_data32[3] == 0x07000000 && + four->ip2.addr_data32[0] == 0xFFFFFF3F && + four->ip2.addr_data32[1] == 0xFFFFFFFF && + four->ip2.addr_data32[2] == 0xFFFFFFFF && + four->ip2.addr_data32[3] == 0xFFFFFFFF && + + five->ip.addr_data32[0] == 0x00000040 && + five->ip.addr_data32[1] == 0x00000000 && + five->ip.addr_data32[2] == 0x00000000 && + five->ip.addr_data32[3] == 0x00000000 && + five->ip2.addr_data32[0] == 0xFFFFFFFF && + five->ip2.addr_data32[1] == 0xFFFFFFFF && + five->ip2.addr_data32[2] == 0xFFFFFFFF && + five->ip2.addr_data32[3] == 0xFFFFFFFF) { result = 1; } } @@ -3471,50 +3461,50 @@ int AddressTestAddressGroupSetup26(void) DetectAddress *one = gh->ipv6_head, *two = one->next, *three = two->next, *four = three->next, *five = four->next; - if (one->ip[0] == 0x00000000 && - one->ip[1] == 0x00000000 && - one->ip[2] == 0x00000000 && - one->ip[3] == 0x00000000 && - one->ip2[0] == 0xFFFFFF1F && - one->ip2[1] == 0xFFFFFFFF && - one->ip2[2] == 0xFFFFFFFF && - one->ip2[3] == 0xFFFFFFFF && - - two->ip[0] == 0x00000020 && - two->ip[1] == 0x00000000 && - two->ip[2] == 0x00000000 && - two->ip[3] == 0x00000000 && - two->ip2[0] == 0x00000120 && - two->ip2[1] == 0x00000000 && - two->ip2[2] == 0x00000000 && - two->ip2[3] == 0x03000000 && - - three->ip[0] == 0x00000120 && - three->ip[1] == 0x00000000 && - three->ip[2] == 0x00000000 && - three->ip[3] == 0x04000000 && - three->ip2[0] == 0x00000120 && - three->ip2[1] == 0x00000000 && - three->ip2[2] == 0x00000000 && - three->ip2[3] == 0x06000000 && - - four->ip[0] == 0x00000120 && - four->ip[1] == 0x00000000 && - four->ip[2] == 0x00000000 && - four->ip[3] == 0x07000000 && - four->ip2[0] == 0xFFFFFF3F && - four->ip2[1] == 0xFFFFFFFF && - four->ip2[2] == 0xFFFFFFFF && - four->ip2[3] == 0xFFFFFFFF && - - five->ip[0] == 0x00000040 && - five->ip[1] == 0x00000000 && - five->ip[2] == 0x00000000 && - five->ip[3] == 0x00000000 && - five->ip2[0] == 0xFFFFFFFF && - five->ip2[1] == 0xFFFFFFFF && - five->ip2[2] == 0xFFFFFFFF && - five->ip2[3] == 0xFFFFFFFF) { + if (one->ip.addr_data32[0] == 0x00000000 && + one->ip.addr_data32[1] == 0x00000000 && + one->ip.addr_data32[2] == 0x00000000 && + one->ip.addr_data32[3] == 0x00000000 && + one->ip2.addr_data32[0] == 0xFFFFFF1F && + one->ip2.addr_data32[1] == 0xFFFFFFFF && + one->ip2.addr_data32[2] == 0xFFFFFFFF && + one->ip2.addr_data32[3] == 0xFFFFFFFF && + + two->ip.addr_data32[0] == 0x00000020 && + two->ip.addr_data32[1] == 0x00000000 && + two->ip.addr_data32[2] == 0x00000000 && + two->ip.addr_data32[3] == 0x00000000 && + two->ip2.addr_data32[0] == 0x00000120 && + two->ip2.addr_data32[1] == 0x00000000 && + two->ip2.addr_data32[2] == 0x00000000 && + two->ip2.addr_data32[3] == 0x03000000 && + + three->ip.addr_data32[0] == 0x00000120 && + three->ip.addr_data32[1] == 0x00000000 && + three->ip.addr_data32[2] == 0x00000000 && + three->ip.addr_data32[3] == 0x04000000 && + three->ip2.addr_data32[0] == 0x00000120 && + three->ip2.addr_data32[1] == 0x00000000 && + three->ip2.addr_data32[2] == 0x00000000 && + three->ip2.addr_data32[3] == 0x06000000 && + + four->ip.addr_data32[0] == 0x00000120 && + four->ip.addr_data32[1] == 0x00000000 && + four->ip.addr_data32[2] == 0x00000000 && + four->ip.addr_data32[3] == 0x07000000 && + four->ip2.addr_data32[0] == 0xFFFFFF3F && + four->ip2.addr_data32[1] == 0xFFFFFFFF && + four->ip2.addr_data32[2] == 0xFFFFFFFF && + four->ip2.addr_data32[3] == 0xFFFFFFFF && + + five->ip.addr_data32[0] == 0x00000040 && + five->ip.addr_data32[1] == 0x00000000 && + five->ip.addr_data32[2] == 0x00000000 && + five->ip.addr_data32[3] == 0x00000000 && + five->ip2.addr_data32[0] == 0xFFFFFFFF && + five->ip2.addr_data32[1] == 0xFFFFFFFF && + five->ip2.addr_data32[2] == 0xFFFFFFFF && + five->ip2.addr_data32[3] == 0xFFFFFFFF) { result = 1; } } @@ -3747,11 +3737,11 @@ int AddressTestCutIPv403(void) if (c == NULL) goto error; - if (a->ip[0] != 0x00020201 && a->ip2[0] != 0xff020201) + if (a->ip.addr_data32[0] != 0x00020201 && a->ip2.addr_data32[0] != 0xff020201) goto error; - if (b->ip[0] != 0x00030201 && b->ip2[0] != 0x04030201) + if (b->ip.addr_data32[0] != 0x00030201 && b->ip2.addr_data32[0] != 0x04030201) goto error; - if (c->ip[0] != 0x05030201 && c->ip2[0] != 0xff030201) + if (c->ip.addr_data32[0] != 0x05030201 && c->ip2.addr_data32[0] != 0xff030201) goto error; DetectAddressFree(a); @@ -3778,11 +3768,11 @@ int AddressTestCutIPv404(void) if (c == NULL) goto error; - if (a->ip[0] != 0x00030201 && a->ip2[0] != 0x02030201) + if (a->ip.addr_data32[0] != 0x00030201 && a->ip2.addr_data32[0] != 0x02030201) goto error; - if (b->ip[0] != 0x03030201 && b->ip2[0] != 0x04030201) + if (b->ip.addr_data32[0] != 0x03030201 && b->ip2.addr_data32[0] != 0x04030201) goto error; - if (c->ip[0] != 0x05030201 && c->ip2[0] != 0x06030201) + if (c->ip.addr_data32[0] != 0x05030201 && c->ip2.addr_data32[0] != 0x06030201) goto error; DetectAddressFree(a); @@ -3809,11 +3799,11 @@ int AddressTestCutIPv405(void) if (c == NULL) goto error; - if (a->ip[0] != 0x00030201 && a->ip2[0] != 0x02030201) + if (a->ip.addr_data32[0] != 0x00030201 && a->ip2.addr_data32[0] != 0x02030201) goto error; - if (b->ip[0] != 0x03030201 && b->ip2[0] != 0x06030201) + if (b->ip.addr_data32[0] != 0x03030201 && b->ip2.addr_data32[0] != 0x06030201) goto error; - if (c->ip[0] != 0x07030201 && c->ip2[0] != 0x09030201) + if (c->ip.addr_data32[0] != 0x07030201 && c->ip2.addr_data32[0] != 0x09030201) goto error; DetectAddressFree(a); @@ -3840,11 +3830,11 @@ int AddressTestCutIPv406(void) if (c == NULL) goto error; - if (a->ip[0] != 0x00030201 && a->ip2[0] != 0x02030201) + if (a->ip.addr_data32[0] != 0x00030201 && a->ip2.addr_data32[0] != 0x02030201) goto error; - if (b->ip[0] != 0x03030201 && b->ip2[0] != 0x06030201) + if (b->ip.addr_data32[0] != 0x03030201 && b->ip2.addr_data32[0] != 0x06030201) goto error; - if (c->ip[0] != 0x07030201 && c->ip2[0] != 0x09030201) + if (c->ip.addr_data32[0] != 0x07030201 && c->ip2.addr_data32[0] != 0x09030201) goto error; DetectAddressFree(a); @@ -3871,9 +3861,9 @@ int AddressTestCutIPv407(void) if (c != NULL) goto error; - if (a->ip[0] != 0x00030201 && a->ip2[0] != 0x06030201) + if (a->ip.addr_data32[0] != 0x00030201 && a->ip2.addr_data32[0] != 0x06030201) goto error; - if (b->ip[0] != 0x07030201 && b->ip2[0] != 0x09030201) + if (b->ip.addr_data32[0] != 0x07030201 && b->ip2.addr_data32[0] != 0x09030201) goto error; DetectAddressFree(a); @@ -3900,9 +3890,9 @@ int AddressTestCutIPv408(void) if (c != NULL) goto error; - if (a->ip[0] != 0x00030201 && a->ip2[0] != 0x02030201) + if (a->ip.addr_data32[0] != 0x00030201 && a->ip2.addr_data32[0] != 0x02030201) goto error; - if (b->ip[0] != 0x03030201 && b->ip2[0] != 0x09030201) + if (b->ip.addr_data32[0] != 0x03030201 && b->ip2.addr_data32[0] != 0x09030201) goto error; DetectAddressFree(a); @@ -3929,9 +3919,9 @@ int AddressTestCutIPv409(void) if (c != NULL) goto error; - if (a->ip[0] != 0x00030201 && a->ip2[0] != 0x06030201) + if (a->ip.addr_data32[0] != 0x00030201 && a->ip2.addr_data32[0] != 0x06030201) goto error; - if (b->ip[0] != 0x07030201 && b->ip2[0] != 0x09030201) + if (b->ip.addr_data32[0] != 0x07030201 && b->ip2.addr_data32[0] != 0x09030201) goto error; DetectAddressFree(a); @@ -3958,9 +3948,9 @@ int AddressTestCutIPv410(void) if (c != NULL) goto error; - if (a->ip[0] != 0x00030201 && a->ip2[0] != 0x02030201) + if (a->ip.addr_data32[0] != 0x00030201 && a->ip2.addr_data32[0] != 0x02030201) goto error; - if (b->ip[0] != 0x03030201 && b->ip2[0] != 0x09030201) + if (b->ip.addr_data32[0] != 0x03030201 && b->ip2.addr_data32[0] != 0x09030201) goto error; DetectAddressFree(a); diff --git a/src/detect.c b/src/detect.c index 79a59c684f..595d516149 100644 --- a/src/detect.c +++ b/src/detect.c @@ -1454,7 +1454,7 @@ static int DetectEngineLookupBuildSourceAddressList(DetectEngineCtx *de_ctx, Det /* for each source address group in the signature... */ for (gr = head; gr != NULL; gr = gr->next) { - BUG_ON(gr->family == 0 && !(gr->flags & ADDRESS_FLAG_ANY)); + BUG_ON(gr->ip.family == 0 && !(gr->flags & ADDRESS_FLAG_ANY)); /* ...and each protocol the signature matches on... */ for (proto = 0; proto < 256; proto++) { @@ -1598,7 +1598,7 @@ int CreateGroupedAddrList(DetectEngineCtx *de_ctx, DetectAddress *srchead, /* insert the addresses into the tmplist, where it will * be sorted descending on 'cnt'. */ for (gr = srchead; gr != NULL; gr = gr->next) { - BUG_ON(gr->family == 0 && !(gr->flags & ADDRESS_FLAG_ANY)); + BUG_ON(gr->ip.family == 0 && !(gr->flags & ADDRESS_FLAG_ANY)); if (SMALL_MPM(gr->sh->mpm_content_maxlen) && unique_groups > 0) unique_groups++; @@ -1650,7 +1650,7 @@ int CreateGroupedAddrList(DetectEngineCtx *de_ctx, DetectAddress *srchead, if (i == 0) i = groups; for (gr = tmplist; gr != NULL; ) { - BUG_ON(gr->family == 0 && !(gr->flags & ADDRESS_FLAG_ANY)); + BUG_ON(gr->ip.family == 0 && !(gr->flags & ADDRESS_FLAG_ANY)); if (i == 0) { if (joingr == NULL) { @@ -1703,7 +1703,7 @@ int CreateGroupedAddrList(DetectEngineCtx *de_ctx, DetectAddress *srchead, * * Start with inserting the unique groups */ for (gr = tmplist2; gr != NULL; ) { - BUG_ON(gr->family == 0 && !(gr->flags & ADDRESS_FLAG_ANY)); + BUG_ON(gr->ip.family == 0 && !(gr->flags & ADDRESS_FLAG_ANY)); DetectAddress *newtmp = DetectAddressCopy(gr); if (newtmp == NULL) { diff --git a/src/detect.h b/src/detect.h index 9259e984af..73cb160a02 100644 --- a/src/detect.h +++ b/src/detect.h @@ -102,9 +102,11 @@ enum { */ typedef struct DetectAddress_ { /** address data for this group */ - uint8_t family; /**< address family, AF_INET (IPv4) or AF_INET6 (IPv6) */ - uint32_t ip[4]; /**< the address, or lower end of a range */ - uint32_t ip2[4]; /**< higher end of a range */ + Address ip; + Address ip2; +// uint8_t family; /**< address family, AF_INET (IPv4) or AF_INET6 (IPv6) */ +// uint32_t ip[4]; /**< the address, or lower end of a range */ +// uint32_t ip2[4]; /**< higher end of a range */ /** ptr to the next address (dst addr in that case) or to the src port */ union {