Fix some address code related compiler warnings.

remotes/origin/master-1.0.x
Victor Julien 17 years ago
parent d2b089f359
commit 3ec5f66729

@ -47,11 +47,6 @@ int AddressCmpIPv4(DetectAddressData *a, DetectAddressData *b) {
printf("Internal Error: should be unreachable\n");
}
printf("a->ip[0] %u, a->ip2[0] %u\n", ntohl(a->ip[0]), ntohl(a->ip2[0]));
DetectAddressDataPrint(a);
printf("b->ip[0] %u, b->ip2[0] %u\n", ntohl(b->ip[0]), ntohl(b->ip2[0]));
DetectAddressDataPrint(b);
printf ("ADDRESS_ER\n");
return ADDRESS_ER;
}
@ -76,7 +71,7 @@ int AddressCutIPv4(DetectAddressData *a, DetectAddressData *b, DetectAddressData
/* default to NULL */
*c = NULL;
int r = AddressCmp(a,b);
int r = AddressCmpIPv4(a,b);
if (r != ADDRESS_ES && r != ADDRESS_EB && r != ADDRESS_LE && r != ADDRESS_GE) {
goto error;
}

@ -75,6 +75,49 @@ int AddressIPv6Ge(u_int32_t *a, u_int32_t *b) {
return 0;
}
int AddressCmpIPv6(DetectAddressData *a, DetectAddressData *b) {
/* ADDRESS_EQ */
if (AddressIPv6Eq(a->ip, b->ip) == 1 &&
AddressIPv6Eq(a->ip2, b->ip2) == 1) {
//printf("ADDRESS_EQ\n");
return ADDRESS_EQ;
/* ADDRESS_ES */
} else if (AddressIPv6Ge(a->ip, b->ip) == 1 &&
AddressIPv6Lt(a->ip, b->ip2) == 1 &&
AddressIPv6Le(a->ip2, b->ip2) == 1) {
//printf("ADDRESS_ES\n");
return ADDRESS_ES;
/* ADDRESS_EB */
} else if (AddressIPv6Le(a->ip, b->ip) == 1 &&
AddressIPv6Ge(a->ip2, b->ip2) == 1) {
//printf("ADDRESS_EB\n");
return ADDRESS_EB;
} else if (AddressIPv6Lt(a->ip, b->ip) == 1 &&
AddressIPv6Lt(a->ip2, b->ip2) == 1 &&
AddressIPv6Gt(a->ip2, b->ip) == 1) {
//printf("ADDRESS_LE\n");
return ADDRESS_LE;
} else if (AddressIPv6Lt(a->ip, b->ip) == 1 &&
AddressIPv6Lt(a->ip2, b->ip2) == 1) {
//printf("ADDRESS_LT\n");
return ADDRESS_LT;
} else if (AddressIPv6Gt(a->ip, b->ip) == 1 &&
AddressIPv6Lt(a->ip, b->ip2) == 1 &&
AddressIPv6Gt(a->ip2, b->ip2) == 1) {
//printf("ADDRESS_GE\n");
return ADDRESS_GE;
} else if (AddressIPv6Gt(a->ip, b->ip2) == 1) {
//printf("ADDRESS_GT\n");
return ADDRESS_GT;
} else {
/* should be unreachable */
printf("Internal Error: should be unreachable\n");
}
// printf ("ADDRESS_ER\n");
return ADDRESS_ER;
}
/* address is in host order! */
static void AddressCutIPv6CopySubOne(u_int32_t *a, u_int32_t *b) {
u_int32_t t = a[3];
@ -152,7 +195,7 @@ int AddressCutIPv6(DetectAddressData *a, DetectAddressData *b, DetectAddressData
/* default to NULL */
*c = NULL;
int r = AddressCmp(a,b);
int r = AddressCmpIPv6(a,b);
if (r != ADDRESS_ES && r != ADDRESS_EB && r != ADDRESS_LE && r != ADDRESS_GE) {
goto error;
}
@ -297,49 +340,6 @@ error:
return -1;
}
int AddressCmpIPv6(DetectAddressData *a, DetectAddressData *b) {
/* ADDRESS_EQ */
if (AddressIPv6Eq(a->ip, b->ip) == 1 &&
AddressIPv6Eq(a->ip2, b->ip2) == 1) {
//printf("ADDRESS_EQ\n");
return ADDRESS_EQ;
/* ADDRESS_ES */
} else if (AddressIPv6Ge(a->ip, b->ip) == 1 &&
AddressIPv6Lt(a->ip, b->ip2) == 1 &&
AddressIPv6Le(a->ip2, b->ip2) == 1) {
//printf("ADDRESS_ES\n");
return ADDRESS_ES;
/* ADDRESS_EB */
} else if (AddressIPv6Le(a->ip, b->ip) == 1 &&
AddressIPv6Ge(a->ip2, b->ip2) == 1) {
//printf("ADDRESS_EB\n");
return ADDRESS_EB;
} else if (AddressIPv6Lt(a->ip, b->ip) == 1 &&
AddressIPv6Lt(a->ip2, b->ip2) == 1 &&
AddressIPv6Gt(a->ip2, b->ip) == 1) {
//printf("ADDRESS_LE\n");
return ADDRESS_LE;
} else if (AddressIPv6Lt(a->ip, b->ip) == 1 &&
AddressIPv6Lt(a->ip2, b->ip2) == 1) {
//printf("ADDRESS_LT\n");
return ADDRESS_LT;
} else if (AddressIPv6Gt(a->ip, b->ip) == 1 &&
AddressIPv6Lt(a->ip, b->ip2) == 1 &&
AddressIPv6Gt(a->ip2, b->ip2) == 1) {
//printf("ADDRESS_GE\n");
return ADDRESS_GE;
} else if (AddressIPv6Gt(a->ip, b->ip2) == 1) {
//printf("ADDRESS_GT\n");
return ADDRESS_GT;
} else {
/* should be unreachable */
printf("Internal Error: should be unreachable\n");
}
// printf ("ADDRESS_ER\n");
return ADDRESS_ER;
}
/* TESTS */

@ -35,5 +35,10 @@ typedef struct DetectAddressGroup_ {
} DetectAddressGroup;
typedef struct DetectAddressGroups_ {
DetectAddressGroup *ipv4_head;
DetectAddressGroup *ipv6_head;
} DetectAddressGroups;
#endif /* __DETECT_ADDRESS_H__ */

Loading…
Cancel
Save