* response of the parser from HTP library. */
int HTPParserTest01(void)
{
- int result = 1;
+ int result = 0;
Flow *f = NULL;
uint8_t httpbuf1[] = "POST / HTTP/1.0\r\nUser-Agent: Victor/1.0\r\n\r\nPost"
" Data is c0oL!";
if (r != 0) {
printf("toserver chunk %" PRIu32 " returned %" PRId32 ", expected"
" 0: ", u, r);
- result = 0;
SCMutexUnlock(&f->m);
goto end;
}
htp_state = f->alstate;
if (htp_state == NULL) {
printf("no http state: ");
- result = 0;
goto end;
}
" and got: %s \n", bstr_util_strdup_to_c(h->value),
bstr_util_strdup_to_c(tx->request_method),
bstr_util_strdup_to_c(tx->request_protocol));
- result = 0;
goto end;
}
+ result = 1;
end:
if (alp_tctx != NULL)
AppLayerParserThreadCtxFree(alp_tctx);
* response of the parser from HTP library. */
static int HTPParserTest01a(void)
{
- int result = 1;
+ int result = 0;
Flow *f = NULL;
uint8_t httpbuf1[] = " POST / HTTP/1.0\r\nUser-Agent: Victor/1.0\r\n\r\nPost"
" Data is c0oL!";
if (r != 0) {
printf("toserver chunk %" PRIu32 " returned %" PRId32 ", expected"
" 0: ", u, r);
- result = 0;
SCMutexUnlock(&f->m);
goto end;
}
htp_state = f->alstate;
if (htp_state == NULL) {
printf("no http state: ");
- result = 0;
goto end;
}
" and got: %s \n", bstr_util_strdup_to_c(h->value),
bstr_util_strdup_to_c(tx->request_method),
bstr_util_strdup_to_c(tx->request_protocol));
- result = 0;
goto end;
}
-
+ result = 1;
end:
if (alp_tctx != NULL)
AppLayerParserThreadCtxFree(alp_tctx);
/** \test See how it deals with an incomplete request. */
int HTPParserTest02(void)
{
- int result = 1;
+ int result = 0;
Flow *f = NULL;
uint8_t httpbuf1[] = "POST";
uint32_t httplen1 = sizeof(httpbuf1) - 1; /* minus the \0 */
STREAM_EOF, httpbuf1, httplen1);
if (r != 0) {
printf("toserver chunk 1 returned %" PRId32 ", expected 0: ", r);
- result = 0;
SCMutexUnlock(&f->m);
goto end;
}
http_state = f->alstate;
if (http_state == NULL) {
printf("no http state: ");
- result = 0;
goto end;
}
if ((tx->request_method) != NULL || h != NULL)
{
printf("expected method NULL, got %s \n", bstr_util_strdup_to_c(tx->request_method));
- result = 0;
goto end;
}
-
+ result = 1;
end:
if (alp_tctx != NULL)
AppLayerParserThreadCtxFree(alp_tctx);
* and check the response of the parser from HTP library. */
int HTPParserTest03(void)
{
- int result = 1;
+ int result = 0;
Flow *f = NULL;
uint8_t httpbuf1[] = "HELLO / HTTP/1.0\r\n";
uint32_t httplen1 = sizeof(httpbuf1) - 1; /* minus the \0 */
TcpSession ssn;
-
HtpState *htp_state = NULL;
int r = 0;
AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc();
if (r != 0) {
printf("toserver chunk %" PRIu32 " returned %" PRId32 ", expected"
" 0: ", u, r);
- result = 0;
SCMutexUnlock(&f->m);
goto end;
}
htp_state = f->alstate;
if (htp_state == NULL) {
printf("no http state: ");
- result = 0;
goto end;
}
printf("expected method M_UNKNOWN and got %s: , expected protocol "
"HTTP/1.0 and got %s \n", bstr_util_strdup_to_c(tx->request_method),
bstr_util_strdup_to_c(tx->request_protocol));
- result = 0;
goto end;
}
-
+ result = 1;
end:
if (alp_tctx != NULL)
AppLayerParserThreadCtxFree(alp_tctx);
* parser from HTP library. */
int HTPParserTest04(void)
{
- int result = 1;
+ int result = 0;
Flow *f = NULL;
HtpState *htp_state = NULL;
uint8_t httpbuf1[] = "World!\r\n";
htp_state = f->alstate;
if (htp_state == NULL) {
printf("no http state: ");
- result = 0;
goto end;
}
printf("expected method M_UNKNOWN and got %s: , expected protocol "
"NULL and got %s \n", bstr_util_strdup_to_c(tx->request_method),
bstr_util_strdup_to_c(tx->request_protocol));
- result = 0;
goto end;
}
-
+ result = 1;
end:
if (alp_tctx != NULL)
AppLayerParserThreadCtxFree(alp_tctx);
* properly parsed them and also keeps them separated. */
int HTPParserTest05(void)
{
- int result = 1;
+ int result = 0;
Flow *f = NULL;
HtpState *http_state = NULL;
uint8_t httpbuf1[] = "POST / HTTP/1.0\r\nUser-Agent: Victor/1.0\r\n\r\n";
httpbuf1, httplen1);
if (r != 0) {
printf("toserver chunk 1 returned %" PRId32 ", expected 0: ", r);
- result = 0;
SCMutexUnlock(&f->m);
goto end;
}
httplen4);
if (r != 0) {
printf("toserver chunk 4 returned %" PRId32 ", expected 0: ", r);
- result = 0;
SCMutexUnlock(&f->m);
goto end;
}
r = AppLayerParserParse(alp_tctx, f, ALPROTO_HTTP, STREAM_TOCLIENT, httpbuf5, httplen5);
if (r != 0) {
printf("toserver chunk 5 returned %" PRId32 ", expected 0: ", r);
- result = 0;
SCMutexUnlock(&f->m);
goto end;
}
r = AppLayerParserParse(alp_tctx, f, ALPROTO_HTTP, STREAM_TOSERVER, httpbuf2, httplen2);
if (r != 0) {
printf("toserver chunk 2 returned %" PRId32 ", expected 0: ", r);
- result = 0;
SCMutexUnlock(&f->m);
goto end;
}
httplen3);
if (r != 0) {
printf("toserver chunk 3 returned %" PRId32 ", expected 0: ", r);
- result = 0;
SCMutexUnlock(&f->m);
goto end;
}
httplen6);
if (r != 0) {
printf("toserver chunk 6 returned %" PRId32 ", expected 0: ", r);
- result = 0;
SCMutexUnlock(&f->m);
goto end;
}
http_state = f->alstate;
if (http_state == NULL) {
printf("no http state: ");
- result = 0;
goto end;
}
printf("expected method M_POST and got %s: , expected protocol "
"HTTP/1.0 and got %s \n", bstr_util_strdup_to_c(tx->request_method),
bstr_util_strdup_to_c(tx->request_protocol));
- result = 0;
goto end;
}
"HTTP/1.0 and got %s \n", tx->response_status_number,
bstr_util_strdup_to_c(tx->response_message),
bstr_util_strdup_to_c(tx->response_protocol));
- result = 0;
goto end;
}
+ result = 1;
end:
if (alp_tctx != NULL)
AppLayerParserThreadCtxFree(alp_tctx);
*/
int HTPParserTest06(void)
{
- int result = 1;
+ int result = 0;
Flow *f = NULL;
uint8_t httpbuf1[] = "GET /ld/index.php?id=412784631&cid=0064&version=4&"
"name=try HTTP/1.1\r\nAccept: */*\r\nUser-Agent: "
httpbuf1, httplen1);
if (r != 0) {
printf("toserver chunk 1 returned %" PRId32 ", expected 0: ", r);
- result = 0;
SCMutexUnlock(&f->m);
goto end;
}
httplen2);
if (r != 0) {
printf("toclient chunk 2 returned %" PRId32 ", expected 0: ", r);
- result = 0;
SCMutexUnlock(&f->m);
goto end;
}
http_state = f->alstate;
if (http_state == NULL) {
printf("no http state: ");
- result = 0;
goto end;
}
printf("expected method M_GET and got %s: , expected protocol "
"HTTP/1.1 and got %s \n", bstr_util_strdup_to_c(tx->request_method),
bstr_util_strdup_to_c(tx->request_protocol));
- result = 0;
goto end;
}
"col HTTP/1.1 and got %s \n", tx->response_status_number,
bstr_util_strdup_to_c(tx->response_message),
bstr_util_strdup_to_c(tx->response_protocol));
- result = 0;
goto end;
}
+ result = 1;
end:
if (alp_tctx != NULL)
AppLayerParserThreadCtxFree(alp_tctx);
if (r != 0) {
printf("toserver chunk returned %" PRId32 ", expected"
" 0: ", r);
- result = 0;
SCMutexUnlock(&f->m);
goto end;
}
htp_state = f->alstate;
if (htp_state == NULL) {
printf("no http state: ");
- result = 0;
goto end;
}
if (r != 0) {
printf("toserver chunk %" PRIu32 " returned %" PRId32 ", expected"
" 0: ", u, r);
- result = 0;
SCMutexUnlock(&f->m);
goto end;
}
htp_state = f->alstate;
if (htp_state == NULL) {
printf("no http state: ");
- result = 0;
goto end;
}
if (r != 0) {
printf("toserver chunk %" PRIu32 " returned %" PRId32 ", expected"
" 0: ", u, r);
- result = 0;
SCMutexUnlock(&f->m);
goto end;
}
htp_state = f->alstate;
if (htp_state == NULL) {
printf("no http state: ");
- result = 0;
goto end;
}
if (r != 0) {
printf("toserver chunk %" PRIu32 " returned %" PRId32 ", expected"
" 0: ", u, r);
- result = 0;
SCMutexUnlock(&f->m);
goto end;
}
htp_state = f->alstate;
if (htp_state == NULL) {
printf("no http state: ");
- result = 0;
goto end;
}
if (r != 0) {
printf("toserver chunk %" PRIu32 " returned %" PRId32 ", expected"
" 0: ", u, r);
- result = 0;
SCMutexUnlock(&f->m);
goto end;
}
htp_state = f->alstate;
if (htp_state == NULL) {
printf("no http state: ");
- result = 0;
goto end;
}
if (r != 0) {
printf("toserver chunk %" PRIu32 " returned %" PRId32 ", expected"
" 0: ", u, r);
- result = 0;
SCMutexUnlock(&f->m);
goto end;
}
htp_state = f->alstate;
if (htp_state == NULL) {
printf("no http state: ");
- result = 0;
goto end;
}
if (r != 0) {
printf("toserver chunk %" PRIu32 " returned %" PRId32 ", expected"
" 0: ", u, r);
- result = 0;
SCMutexUnlock(&f->m);
goto end;
}
htp_state = f->alstate;
if (htp_state == NULL) {
printf("no http state: ");
- result = 0;
goto end;
}
if (r != 0) {
printf("toserver chunk %" PRIu32 " returned %" PRId32 ", expected"
" 0: ", u, r);
- result = 0;
SCMutexUnlock(&f->m);
goto end;
}
htp_state = f->alstate;
if (htp_state == NULL) {
printf("no http state: ");
- result = 0;
goto end;
}
if (r != 0) {
printf("toserver chunk %" PRIu32 " returned %" PRId32 ", expected"
" 0: ", u, r);
- result = 0;
SCMutexUnlock(&f->m);
goto end;
}
htp_state = f->alstate;
if (htp_state == NULL) {
printf("no http state: ");
- result = 0;
goto end;
}
if (r != 0) {
printf("toserver chunk %" PRIu32 " returned %" PRId32 ", expected"
" 0: ", u, r);
- result = 0;
SCMutexUnlock(&f->m);
goto end;
}
htp_state = f->alstate;
if (htp_state == NULL) {
printf("no http state: ");
- result = 0;
goto end;
}
int r = AppLayerParserParse(alp_tctx, f, ALPROTO_HTTP, STREAM_TOSERVER|STREAM_START, httpbuf1, httplen1);
if (r != 0) {
printf("toserver chunk 1 returned %" PRId32 ", expected 0: ", r);
- result = 0;
SCMutexUnlock(&f->m);
goto end;
}
r = AppLayerParserParse(alp_tctx, f, ALPROTO_HTTP, STREAM_TOSERVER, httpbuf1, httplen1);
if (r != 0) {
printf("toserver chunk 1 returned %" PRId32 ", expected 0: ", r);
- result = 0;
SCMutexUnlock(&f->m);
goto end;
}
http_state = f->alstate;
if (http_state == NULL) {
printf("no http state: ");
- result = 0;
goto end;
}
if (r != 0) {
printf("toserver chunk %" PRIu32 " returned %" PRId32 ", expected"
" 0: ", u, r);
- result = 0;
SCMutexUnlock(&f->m);
goto end;
}
if (r != -1) {
printf("toserver chunk %" PRIu32 " returned %" PRId32 ", expected"
" -1: ", u, r);
- result = 0;
SCMutexUnlock(&f->m);
goto end;
}
if (r != 0) {
printf("toserver chunk %" PRIu32 " returned %" PRId32 ", expected"
" 0: ", u, r);
- result = 0;
SCMutexUnlock(&f->m);
goto end;
}
r = AppLayerParserParse(alp_tctx, f, ALPROTO_HTTP, flags, (uint8_t *)httpbuf, len);
if (r != 0) {
printf("toserver chunk 1 returned %" PRId32 ", expected 0: ", r);
- result = 0;
SCMutexUnlock(&f->m);
goto end;
}