Fix IP-Only unittests failing on Big Endian.

remotes/origin/master-1.1.x
Victor Julien 14 years ago
parent b8cf50678f
commit e197f50727

@ -5359,8 +5359,8 @@ int SigTest19Real (int mpm_type) {
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
p->src.family = AF_INET;
p->src.addr_data32[0] = 0x0102080a;
p->dst.addr_data32[0] = 0x04030201;
p->src.addr_data32[0] = UTHSetIPv4Address("192.168.0.1");
p->dst.addr_data32[0] = UTHSetIPv4Address("1.2.3.4");
p->dst.family = AF_INET;
p->payload = buf;
p->payload_len = buflen;
@ -5430,8 +5430,8 @@ static int SigTest20Real (int mpm_type) {
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
p->src.family = AF_INET;
p->src.addr_data32[0] = 0x0102080a;
p->dst.addr_data32[0] = 0x04030201;
p->src.addr_data32[0] = UTHSetIPv4Address("192.168.0.1");
p->dst.addr_data32[0] = UTHSetIPv4Address("1.2.3.4");
p->dst.family = AF_INET;
p->payload = buf;
p->payload_len = buflen;
@ -8013,8 +8013,8 @@ int SigTest40NoPacketInspection01(void) {
memset(&tcphdr, 0, sizeof(tcphdr));
p->src.family = AF_INET;
p->src.addr_data32[0] = 0x0102080a;
p->dst.addr_data32[0] = 0x04030201;
p->src.addr_data32[0] = UTHSetIPv4Address("192.168.0.1");
p->dst.addr_data32[0] = UTHSetIPv4Address("1.2.3.4");
p->dst.family = AF_INET;
p->payload = buf;
p->payload_len = buflen;
@ -8619,7 +8619,7 @@ static int SigTestSgh03 (void) {
p->payload_len = 1;
p->proto = IPPROTO_TCP;
p->dp = 80;
p->dst.addr_data32[0] = 0x04030201;
p->dst.addr_data32[0] = UTHSetIPv4Address("1.2.3.4");
DetectEngineCtx *de_ctx = DetectEngineCtxInit();
if (de_ctx == NULL) {
@ -8696,7 +8696,7 @@ static int SigTestSgh03 (void) {
goto end;
}
p->dst.addr_data32[0] = 0x05030201;
p->dst.addr_data32[0] = UTHSetIPv4Address("1.2.3.5");
sgh = SigMatchSignaturesGetSgh(de_ctx, det_ctx, p);
if (sgh == NULL) {
@ -8735,7 +8735,7 @@ static int SigTestSgh03 (void) {
}
p->dst.addr_data32[0] = 0x06030201;
p->dst.addr_data32[0] = UTHSetIPv4Address("1.2.3.6");
sgh = SigMatchSignaturesGetSgh(de_ctx, det_ctx, p);
if (sgh == NULL) {
@ -8791,7 +8791,7 @@ static int SigTestSgh04 (void) {
p->payload_len = 1;
p->proto = IPPROTO_TCP;
p->dp = 80;
p->dst.addr_data32[0] = 0x04030201;
p->dst.addr_data32[0] = UTHSetIPv4Address("1.2.3.4");
DetectEngineCtx *de_ctx = DetectEngineCtxInit();
if (de_ctx == NULL) {
@ -8867,7 +8867,7 @@ static int SigTestSgh04 (void) {
printf("sgh->sig_size %u\n", sgh->sig_size);
printf("sgh->refcnt %u\n", sgh->refcnt);
#endif
p->dst.addr_data32[0] = 0x05030201;
p->dst.addr_data32[0] = UTHSetIPv4Address("1.2.3.5");
sgh = SigMatchSignaturesGetSgh(de_ctx, det_ctx, p);
if (sgh == NULL) {
@ -8903,7 +8903,7 @@ static int SigTestSgh04 (void) {
printf("sgh->sig_size %u\n", sgh->sig_size);
printf("sgh->refcnt %u\n", sgh->refcnt);
#endif
p->dst.addr_data32[0] = 0x06030201;
p->dst.addr_data32[0] = UTHSetIPv4Address("1.2.3.6");
sgh = SigMatchSignaturesGetSgh(de_ctx, det_ctx, p);
if (sgh == NULL) {
@ -8984,7 +8984,7 @@ static int SigTestSgh05 (void) {
p->payload_len = 1;
p->proto = IPPROTO_TCP;
p->dp = 80;
p->dst.addr_data32[0] = 0x04030201;
p->dst.addr_data32[0] = UTHSetIPv4Address("1.2.3.4");
DetectEngineCtx *de_ctx = DetectEngineCtxInit();
if (de_ctx == NULL) {

@ -27,7 +27,6 @@
#include "suricata-common.h"
#include <netinet/in.h>
#include "decode.h"
#include "flow-private.h"
@ -43,6 +42,19 @@
#include "util-unittest.h"
#include "util-unittest-helper.h"
/**
* \brief return the uint32_t for a ipv4 address string
*
* \param str Valid ipaddress in string form (e.g. 1.2.3.4)
*
* \retval uint the uin32_t representation
*/
uint32_t UTHSetIPv4Address(char *str) {
struct in_addr in;
inet_pton(AF_INET, str, &in);
return (uint32_t)in.s_addr;
}
/**
* \brief UTHBuildPacketReal is a function that create tcp/udp packets for unittests
* specifying ip and port sources and destinations (IPV6)

@ -24,6 +24,8 @@
#ifndef __UTIL_UNITTEST_HELPER__
#define __UTIL_UNITTEST_HELPER__
uint32_t UTHSetIPv4Address(char *);
Packet *UTHBuildPacketReal(uint8_t *, uint16_t, uint16_t, char *, char *, uint16_t, uint16_t);
Packet *UTHBuildPacket(uint8_t *, uint16_t, uint16_t);
Packet *UTHBuildPacketSrcDst(uint8_t *, uint16_t, uint16_t, char *, char *);

Loading…
Cancel
Save