*/
int PortTestParse14 (void) {
DetectPort *dd = NULL;
- int result = 1;
+ int result = 0;
int r = DetectPortParseInsertString(&dd, "0:100");
if (r != 0)
if (r != 0 || dd->next == NULL)
goto end;
+ result = 1;
result &= (dd->port == 0) ? 1 : 0;
result &= (dd->port2 == 100) ? 1 : 0;
result &= (dd->next->port == 1000) ? 1 : 0;
*/
int PortTestParse15 (void) {
DetectPort *dd = NULL;
- int result = 1;
+ int result = 0;
int r = DetectPortParse(&dd,"![0:100,1000:3000]");
if (r != 0 || dd->next == NULL)
goto end;
+ result = 1;
result &= (dd->port == 101) ? 1 : 0;
result &= (dd->port2 == 999) ? 1 : 0;
result &= (dd->next->port == 3001) ? 1 : 0;
int PortTestFunctions01(void) {
DetectPort *head = NULL;
DetectPort *dp1= NULL;
- int result = 1;
+ int result = 0;
/* Parse */
int r = DetectPortParse(&head,"![0:100,1000:65535]");
goto end;
/* We should have only one DetectPort */
- result &= (head->port == 101) ? 1 : 0;
- result &= (head->port2 == 999) ? 1 : 0;
- result &= (head->next == NULL) ? 1 : 0;
-
- if (result == 0) goto end;
+ if (!(head->port == 101))
+ goto end;
+ if (!(head->port2 == 999))
+ goto end;
+ if (!(head->next == NULL))
+ goto end;
r = DetectPortParse(&dp1,"2000:3000");
- if (r != 0 || dp1->next == NULL)
+ if (r != 0 || dp1->next != NULL)
+ goto end;
+ if (!(dp1->port == 2000))
+ goto end;
+ if (!(dp1->port2 == 3000))
goto end;
- result &= (dp1->port == 101) ? 1 : 0;
- result &= (dp1->port2 == 999) ? 1 : 0;
/* Add */
r = DetectPortAdd(&head, dp1);
if (r != 0 || head->next == NULL)
goto end;
- result &= (head->port == 101) ? 1 : 0;
- result &= (head->port2 == 999) ? 1 : 0;
- result &= (head->next->port == 2000) ? 1 : 0;
- result &= (head->next->port2 == 3000) ? 1 : 0;
-
- if (result == 0) goto end;
+ if (!(head->port == 101))
+ goto end;
+ if (!(head->port2 == 999))
+ goto end;
+ if (!(head->next->port == 2000))
+ goto end;
+ if (!(head->next->port2 == 3000))
+ goto end;
/* Match */
- result &= DetectPortMatch(head, 150);
- result &= DetectPortMatch(head, 1500);
- result &= (DetectPortMatch(head, 3500))? 0 : 1;
- result &= (DetectPortMatch(head, 50))? 0 : 1;
-
+ if (!DetectPortMatch(head, 150))
+ goto end;
+ if (DetectPortMatch(head->next, 1500))
+ goto end;
+ if ((DetectPortMatch(head, 3500)))
+ goto end;
+ if ((DetectPortMatch(head, 50)))
+ goto end;
+ result = 1;
end:
if (dp1 != NULL)
DetectPortFree(dp1);
DetectPort *head = NULL;
DetectPort *dp1= NULL;
DetectPort *dp2= NULL;
- int result = 1;
+ int result = 0;
/* Parse */
int r = DetectPortParse(&head, "![0:100,1000:65535]");
if (r != 0 || head->next != NULL)
goto end;
- result &= (head->port == 200) ? 1 : 0;
- result &= (head->port2 == 300) ? 1 : 0;
+ if (!(head->port == 200))
+ goto end;
+ if (!(head->port2 == 300))
+ goto end;
+
+ result = 1;
end:
if (dp1 != NULL)
DetectPort *dp1= NULL;
DetectPort *dp2= NULL;
DetectPort *dp3= NULL;
- int result = 1;
+ int result = 0;
int r = DetectPortParse(&dp1, "200:300");
if (r != 0)
if (r != 0)
goto end;
- result &= (dp1->port == 200) ? 1 : 0;
- result &= (dp1->port2 == 249) ? 1 : 0;
- result &= (dp2->port == 250) ? 1 : 0;
- result &= (dp2->port2 == 300) ? 1 : 0;
-
- if (result == 0)
+ if (!(dp1->port == 200))
+ goto end;
+ if (!(dp1->port2 == 249))
+ goto end;
+ if (!(dp2->port == 250))
+ goto end;
+ if (!(dp2->port2 == 300))
goto end;
dp1->port = 0;
DetectPortCut(NULL, dp1, dp2, &dp3);
if (r != 0)
goto end;
- result &= (dp1->port == 0) ? 1 : 0;
- result &= (dp1->port2 == 249) ? 1 : 0;
- result &= (dp2->port == 250) ? 1 : 0;
- result &= (dp2->port2 == 500) ? 1 : 0;
- result &= (dp3->port == 501) ? 1 : 0;
- result &= (dp3->port2 == 750) ? 1 : 0;
+ if (!(dp1->port == 0))
+ goto end;
+ if (!(dp1->port2 == 249))
+ goto end;
+ if (!(dp2->port == 250))
+ goto end;
+ if (!(dp2->port2 == 500))
+ goto end;
+ if (!(dp3->port == 501))
+ goto end;
+ if (!(dp3->port2 == 750))
+ goto end;
+
+ result = 1;
end:
if (dp1 != NULL)
int PortTestFunctions04(void) {
DetectPort *dp1= NULL;
DetectPort *dp2= NULL;
- int result = 1;
+ int result = 0;
int r = DetectPortParse(&dp1, "200:300");
if (r != 0)
if (r != 0)
goto end;
- result &= (dp1->port == 0);
- result &= (dp1->port2 == 199);
- result &= (dp2->port == 301);
- result &= (dp2->port2 == 65535);
+ if (!(dp1->port == 0))
+ goto end;
+ if (!(dp1->port2 == 199))
+ goto end;
+ if (!(dp2->port == 301))
+ goto end;
+ if (!(dp2->port2 == 65535))
+ goto end;
+ result = 1;
end:
if (dp1 != NULL)
DetectPortFree(dp1);
int PortTestMatchReal(uint8_t *raw_eth_pkt, uint16_t pktsize, char *sig,
uint32_t sid)
{
- int result = 1;
+ int result = 0;
FlowInitConfig(FLOW_QUIET);
Packet *p = UTHBuildPacketFromEth(raw_eth_pkt, pktsize);
result = UTHPacketMatchSig(p, sig);