|
|
|
|
@ -768,13 +768,11 @@ int AppLayerParse(Flow *f, uint8_t proto, uint8_t flags, uint8_t *input,
|
|
|
|
|
AppLayerProto *p = &al_proto_table[proto];
|
|
|
|
|
TcpSession *ssn = NULL;
|
|
|
|
|
|
|
|
|
|
/* Used only if it's TCP */
|
|
|
|
|
ssn = f->protoctx;
|
|
|
|
|
if (ssn == NULL) {
|
|
|
|
|
SCLogDebug("no TCP session");
|
|
|
|
|
goto error;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (flags & STREAM_GAP) {
|
|
|
|
|
/** Do this check before calling AppLayerParse */
|
|
|
|
|
if (flags & FLOW_AL_STREAM_GAP) {
|
|
|
|
|
SCLogDebug("stream gap detected (missing packets), this is not yet supported.");
|
|
|
|
|
goto error;
|
|
|
|
|
}
|
|
|
|
|
@ -782,26 +780,27 @@ int AppLayerParse(Flow *f, uint8_t proto, uint8_t flags, uint8_t *input,
|
|
|
|
|
/* Get the parser state (if any) */
|
|
|
|
|
AppLayerParserStateStore *parser_state_store = NULL;
|
|
|
|
|
|
|
|
|
|
if (ssn->aldata != NULL) {
|
|
|
|
|
if (f->aldata != NULL) {
|
|
|
|
|
parser_state_store = (AppLayerParserStateStore *)
|
|
|
|
|
ssn->aldata[app_layer_sid];
|
|
|
|
|
f->aldata[app_layer_sid];
|
|
|
|
|
if (parser_state_store == NULL) {
|
|
|
|
|
parser_state_store = AppLayerParserStateStoreAlloc();
|
|
|
|
|
if (parser_state_store == NULL)
|
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
|
|
ssn->aldata[app_layer_sid] = (void *)parser_state_store;
|
|
|
|
|
f->aldata[app_layer_sid] = (void *)parser_state_store;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
SCLogDebug("No App Layer Data");
|
|
|
|
|
/* Nothing is there to clean up, so just return from here after setting
|
|
|
|
|
* up the no reassembly flags */
|
|
|
|
|
StreamTcpSetSessionNoApplayerInspectionFlag(ssn);
|
|
|
|
|
FlowSetSessionNoApplayerInspectionFlag(f);
|
|
|
|
|
|
|
|
|
|
SCReturnInt(-1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AppLayerParserState *parser_state = NULL;
|
|
|
|
|
if (flags & STREAM_TOSERVER) {
|
|
|
|
|
if (flags & FLOW_AL_STREAM_TOSERVER) {
|
|
|
|
|
SCLogDebug("to_server msg (flow %p)", f);
|
|
|
|
|
|
|
|
|
|
parser_state = &parser_state_store->to_server;
|
|
|
|
|
@ -834,12 +833,12 @@ int AppLayerParse(Flow *f, uint8_t proto, uint8_t flags, uint8_t *input,
|
|
|
|
|
SCReturnInt(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (flags & STREAM_EOF)
|
|
|
|
|
if (flags & FLOW_AL_STREAM_EOF)
|
|
|
|
|
parser_state->flags |= APP_LAYER_PARSER_EOF;
|
|
|
|
|
|
|
|
|
|
/* See if we already have a 'app layer' state */
|
|
|
|
|
void *app_layer_state = NULL;
|
|
|
|
|
app_layer_state = ssn->aldata[p->storage_id];
|
|
|
|
|
app_layer_state = f->aldata[p->storage_id];
|
|
|
|
|
|
|
|
|
|
if (app_layer_state == NULL) {
|
|
|
|
|
/* lock the allocation of state as we may
|
|
|
|
|
@ -849,12 +848,12 @@ int AppLayerParse(Flow *f, uint8_t proto, uint8_t flags, uint8_t *input,
|
|
|
|
|
goto error;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ssn->aldata[p->storage_id] = app_layer_state;
|
|
|
|
|
f->aldata[p->storage_id] = app_layer_state;
|
|
|
|
|
SCLogDebug("alloced new app layer state %p (p->storage_id %u, name %s)",
|
|
|
|
|
app_layer_state, p->storage_id, al_proto_table[ssn->alproto].name);
|
|
|
|
|
app_layer_state, p->storage_id, al_proto_table[f->alproto].name);
|
|
|
|
|
} else {
|
|
|
|
|
SCLogDebug("using existing app layer state %p (p->storage_id %u, name %s))",
|
|
|
|
|
app_layer_state, p->storage_id, al_proto_table[ssn->alproto].name);
|
|
|
|
|
app_layer_state, p->storage_id, al_proto_table[f->alproto].name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* invoke the recursive parser, but only on data. We may get empty msgs on EOF */
|
|
|
|
|
@ -868,12 +867,16 @@ int AppLayerParse(Flow *f, uint8_t proto, uint8_t flags, uint8_t *input,
|
|
|
|
|
/* set the packets to no inspection and reassembly for the TLS sessions */
|
|
|
|
|
if (parser_state->flags & APP_LAYER_PARSER_NO_INSPECTION) {
|
|
|
|
|
FlowSetNoPayloadInspectionFlag(f);
|
|
|
|
|
FlowSetSessionNoApplayerInspectionFlag(f);
|
|
|
|
|
|
|
|
|
|
/* Set the no reassembly flag for both the stream in this TcpSession */
|
|
|
|
|
if (parser_state->flags & APP_LAYER_PARSER_NO_REASSEMBLY) {
|
|
|
|
|
StreamTcpSetSessionNoReassemblyFlag(ssn, flags & STREAM_TOCLIENT ? 1 : 0);
|
|
|
|
|
StreamTcpSetSessionNoReassemblyFlag(ssn, flags & STREAM_TOSERVER ? 1 : 0);
|
|
|
|
|
StreamTcpSetSessionNoApplayerInspectionFlag(ssn);
|
|
|
|
|
if (ssn != NULL) {
|
|
|
|
|
StreamTcpSetSessionNoReassemblyFlag(ssn,
|
|
|
|
|
flags & FLOW_AL_STREAM_TOCLIENT ? 1 : 0);
|
|
|
|
|
StreamTcpSetSessionNoReassemblyFlag(ssn,
|
|
|
|
|
flags & FLOW_AL_STREAM_TOSERVER ? 1 : 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -892,8 +895,9 @@ int AppLayerParse(Flow *f, uint8_t proto, uint8_t flags, uint8_t *input,
|
|
|
|
|
SCReturnInt(0);
|
|
|
|
|
error:
|
|
|
|
|
if (ssn != NULL) {
|
|
|
|
|
/* Set the no reassembly flag for both the stream in this TcpSession */
|
|
|
|
|
StreamTcpSetSessionNoApplayerInspectionFlag(ssn);
|
|
|
|
|
/* Set the no app layer inspection flag for both
|
|
|
|
|
* the stream in this Flow */
|
|
|
|
|
FlowSetSessionNoApplayerInspectionFlag(f);
|
|
|
|
|
|
|
|
|
|
if (f->src.family == AF_INET) {
|
|
|
|
|
char src[16];
|
|
|
|
|
@ -906,7 +910,7 @@ error:
|
|
|
|
|
SCLogError(SC_ERR_ALPARSER, "Error occured in parsing \"%s\" app layer "
|
|
|
|
|
"protocol, using network protocol %"PRIu8", source IP "
|
|
|
|
|
"address %s, destination IP address %s, src port %"PRIu16" and "
|
|
|
|
|
"dst port %"PRIu16"", al_proto_table[ssn->alproto].name,
|
|
|
|
|
"dst port %"PRIu16"", al_proto_table[f->alproto].name,
|
|
|
|
|
f->proto, src, dst, f->sp, f->dp);
|
|
|
|
|
} else {
|
|
|
|
|
char dst6[46];
|
|
|
|
|
@ -920,7 +924,7 @@ error:
|
|
|
|
|
SCLogError(SC_ERR_ALPARSER, "Error occured in parsing \"%s\" app layer "
|
|
|
|
|
"protocol, using network protocol %"PRIu8", source IPv6 "
|
|
|
|
|
"address %s, destination IPv6 address %s, src port %"PRIu16" and "
|
|
|
|
|
"dst port %"PRIu16"", al_proto_table[ssn->alproto].name,
|
|
|
|
|
"dst port %"PRIu16"", al_proto_table[f->alproto].name,
|
|
|
|
|
f->proto, src6, dst6, f->sp, f->dp);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -932,24 +936,18 @@ error:
|
|
|
|
|
int AppLayerTransactionGetBaseId(Flow *f) {
|
|
|
|
|
SCEnter();
|
|
|
|
|
|
|
|
|
|
if (f->proto != IPPROTO_TCP) {
|
|
|
|
|
SCLogDebug("no TCP");
|
|
|
|
|
goto error;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TcpSession *ssn = f->protoctx;
|
|
|
|
|
if (ssn == NULL) {
|
|
|
|
|
SCLogDebug("no TCP session");
|
|
|
|
|
if (f->proto != IPPROTO_TCP && f->proto != IPPROTO_UDP) {
|
|
|
|
|
SCLogDebug("no TCP or UDP");
|
|
|
|
|
goto error;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Get the parser state (if any) */
|
|
|
|
|
if (ssn->aldata == NULL) {
|
|
|
|
|
if (f->aldata == NULL) {
|
|
|
|
|
SCLogDebug("no aldata");
|
|
|
|
|
goto error;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AppLayerParserStateStore *parser_state_store = parser_state_store = (AppLayerParserStateStore *)ssn->aldata[app_layer_sid];
|
|
|
|
|
AppLayerParserStateStore *parser_state_store = parser_state_store = (AppLayerParserStateStore *)f->aldata[app_layer_sid];
|
|
|
|
|
if (parser_state_store == NULL) {
|
|
|
|
|
SCLogDebug("no state store");
|
|
|
|
|
goto error;
|
|
|
|
|
@ -965,24 +963,18 @@ error:
|
|
|
|
|
int AppLayerTransactionGetLoggableId(Flow *f) {
|
|
|
|
|
SCEnter();
|
|
|
|
|
|
|
|
|
|
if (f->proto != IPPROTO_TCP) {
|
|
|
|
|
SCLogDebug("no TCP");
|
|
|
|
|
goto error;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TcpSession *ssn = f->protoctx;
|
|
|
|
|
if (ssn == NULL) {
|
|
|
|
|
SCLogDebug("no TCP session");
|
|
|
|
|
if (f->proto != IPPROTO_TCP && f->proto != IPPROTO_UDP) {
|
|
|
|
|
SCLogDebug("no TCP or UDP");
|
|
|
|
|
goto error;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Get the parser state (if any) */
|
|
|
|
|
if (ssn->aldata == NULL) {
|
|
|
|
|
if (f->aldata == NULL) {
|
|
|
|
|
SCLogDebug("no aldata");
|
|
|
|
|
goto error;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AppLayerParserStateStore *parser_state_store = parser_state_store = (AppLayerParserStateStore *)ssn->aldata[app_layer_sid];
|
|
|
|
|
AppLayerParserStateStore *parser_state_store = parser_state_store = (AppLayerParserStateStore *)f->aldata[app_layer_sid];
|
|
|
|
|
if (parser_state_store == NULL) {
|
|
|
|
|
SCLogDebug("no state store");
|
|
|
|
|
goto error;
|
|
|
|
|
@ -1007,24 +999,18 @@ error:
|
|
|
|
|
void AppLayerTransactionUpdateLoggedId(Flow *f) {
|
|
|
|
|
SCEnter();
|
|
|
|
|
|
|
|
|
|
if (f->proto != IPPROTO_TCP) {
|
|
|
|
|
SCLogDebug("no TCP");
|
|
|
|
|
goto error;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TcpSession *ssn = f->protoctx;
|
|
|
|
|
if (ssn == NULL) {
|
|
|
|
|
SCLogDebug("no TCP session");
|
|
|
|
|
if (f->proto != IPPROTO_TCP && f->proto != IPPROTO_UDP) {
|
|
|
|
|
SCLogDebug("no TCP or UDP");
|
|
|
|
|
goto error;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Get the parser state (if any) */
|
|
|
|
|
if (ssn->aldata == NULL) {
|
|
|
|
|
if (f->aldata == NULL) {
|
|
|
|
|
SCLogDebug("no aldata");
|
|
|
|
|
goto error;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AppLayerParserStateStore *parser_state_store = parser_state_store = (AppLayerParserStateStore *)ssn->aldata[app_layer_sid];
|
|
|
|
|
AppLayerParserStateStore *parser_state_store = parser_state_store = (AppLayerParserStateStore *)f->aldata[app_layer_sid];
|
|
|
|
|
if (parser_state_store == NULL) {
|
|
|
|
|
SCLogDebug("no state store");
|
|
|
|
|
goto error;
|
|
|
|
|
@ -1040,24 +1026,18 @@ error:
|
|
|
|
|
int AppLayerTransactionGetLoggedId(Flow *f) {
|
|
|
|
|
SCEnter();
|
|
|
|
|
|
|
|
|
|
if (f->proto != IPPROTO_TCP) {
|
|
|
|
|
SCLogDebug("no TCP");
|
|
|
|
|
goto error;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TcpSession *ssn = f->protoctx;
|
|
|
|
|
if (ssn == NULL) {
|
|
|
|
|
SCLogDebug("no TCP session");
|
|
|
|
|
if (f->proto != IPPROTO_TCP && f->proto != IPPROTO_UDP) {
|
|
|
|
|
SCLogDebug("no TCP or UDP");
|
|
|
|
|
goto error;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Get the parser state (if any) */
|
|
|
|
|
if (ssn->aldata == NULL) {
|
|
|
|
|
if (f->aldata == NULL) {
|
|
|
|
|
SCLogDebug("no aldata");
|
|
|
|
|
goto error;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AppLayerParserStateStore *parser_state_store = parser_state_store = (AppLayerParserStateStore *)ssn->aldata[app_layer_sid];
|
|
|
|
|
AppLayerParserStateStore *parser_state_store = parser_state_store = (AppLayerParserStateStore *)f->aldata[app_layer_sid];
|
|
|
|
|
if (parser_state_store == NULL) {
|
|
|
|
|
SCLogDebug("no state store");
|
|
|
|
|
goto error;
|
|
|
|
|
@ -1081,23 +1061,17 @@ int AppLayerTransactionUpdateInspectId(Flow *f)
|
|
|
|
|
|
|
|
|
|
int r = 0;
|
|
|
|
|
|
|
|
|
|
if (f->proto != IPPROTO_TCP) {
|
|
|
|
|
SCLogDebug("no TCP flow");
|
|
|
|
|
goto end;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TcpSession *ssn = f->protoctx;
|
|
|
|
|
if (ssn == NULL) {
|
|
|
|
|
SCLogDebug("no TCP session");
|
|
|
|
|
if (f->proto != IPPROTO_TCP && f->proto != IPPROTO_UDP) {
|
|
|
|
|
SCLogDebug("no TCP or UDP flow");
|
|
|
|
|
goto end;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Get the parser state (if any) */
|
|
|
|
|
AppLayerParserStateStore *parser_state_store = NULL;
|
|
|
|
|
|
|
|
|
|
if (ssn->aldata != NULL) {
|
|
|
|
|
if (f->aldata != NULL) {
|
|
|
|
|
parser_state_store = (AppLayerParserStateStore *)
|
|
|
|
|
ssn->aldata[app_layer_sid];
|
|
|
|
|
f->aldata[app_layer_sid];
|
|
|
|
|
if (parser_state_store != NULL) {
|
|
|
|
|
/* update inspect_id and see if it there are other transactions
|
|
|
|
|
* as well */
|
|
|
|
|
@ -1142,38 +1116,38 @@ void RegisterAppLayerParsers(void)
|
|
|
|
|
al_result_pool = PoolInit(1000,250,AlpResultElmtPoolAlloc,NULL,AlpResultElmtPoolFree);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AppLayerParserCleanupState(TcpSession *ssn)
|
|
|
|
|
void AppLayerParserCleanupState(Flow *f)
|
|
|
|
|
{
|
|
|
|
|
if (ssn == NULL) {
|
|
|
|
|
SCLogDebug("no ssn");
|
|
|
|
|
if (f == NULL) {
|
|
|
|
|
SCLogDebug("no flow");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (ssn->alproto >= ALPROTO_MAX) {
|
|
|
|
|
if (f->alproto >= ALPROTO_MAX) {
|
|
|
|
|
SCLogDebug("app layer proto unknown");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* free the parser protocol state */
|
|
|
|
|
AppLayerProto *p = &al_proto_table[ssn->alproto];
|
|
|
|
|
if (p->StateFree != NULL && ssn->aldata != NULL) {
|
|
|
|
|
if (ssn->aldata[p->storage_id] != NULL) {
|
|
|
|
|
AppLayerProto *p = &al_proto_table[f->alproto];
|
|
|
|
|
if (p->StateFree != NULL && f->aldata != NULL) {
|
|
|
|
|
if (f->aldata[p->storage_id] != NULL) {
|
|
|
|
|
SCLogDebug("calling StateFree");
|
|
|
|
|
p->StateFree(ssn->aldata[p->storage_id]);
|
|
|
|
|
ssn->aldata[p->storage_id] = NULL;
|
|
|
|
|
p->StateFree(f->aldata[p->storage_id]);
|
|
|
|
|
f->aldata[p->storage_id] = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* free the app layer parser api state */
|
|
|
|
|
if (ssn->aldata != NULL) {
|
|
|
|
|
if (ssn->aldata[app_layer_sid] != NULL) {
|
|
|
|
|
if (f->aldata != NULL) {
|
|
|
|
|
if (f->aldata[app_layer_sid] != NULL) {
|
|
|
|
|
SCLogDebug("calling AppLayerParserStateStoreFree");
|
|
|
|
|
AppLayerParserStateStoreFree(ssn->aldata[app_layer_sid]);
|
|
|
|
|
ssn->aldata[app_layer_sid] = NULL;
|
|
|
|
|
AppLayerParserStateStoreFree(f->aldata[app_layer_sid]);
|
|
|
|
|
f->aldata[app_layer_sid] = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StreamTcpDecrMemuse((uint32_t)(StreamL7GetStorageSize() * sizeof(void *)));
|
|
|
|
|
SCFree(ssn->aldata);
|
|
|
|
|
ssn->aldata = NULL;
|
|
|
|
|
//StreamTcpDecrMemuse((uint32_t)(StreamL7GetStorageSize() * sizeof(void *)));
|
|
|
|
|
SCFree(f->aldata);
|
|
|
|
|
f->aldata = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -1322,9 +1296,8 @@ static int AppLayerParserTest01 (void)
|
|
|
|
|
AppLayerRegisterStateFuncs(ALPROTO_TEST, TestProtocolStateAlloc,
|
|
|
|
|
TestProtocolStateFree);
|
|
|
|
|
|
|
|
|
|
ssn.alproto = ALPROTO_TEST;
|
|
|
|
|
|
|
|
|
|
FLOW_INITIALIZE(&f);
|
|
|
|
|
f.alproto = ALPROTO_TEST;
|
|
|
|
|
f.protoctx = (void *)&ssn;
|
|
|
|
|
|
|
|
|
|
inet_pton(AF_INET, "1.2.3.4", &addr.s_addr);
|
|
|
|
|
@ -1340,7 +1313,7 @@ static int AppLayerParserTest01 (void)
|
|
|
|
|
f.proto = IPPROTO_TCP;
|
|
|
|
|
|
|
|
|
|
StreamTcpInitConfig(TRUE);
|
|
|
|
|
StreamL7DataPtrInit(&ssn);
|
|
|
|
|
FlowL7DataPtrInit(&f);
|
|
|
|
|
|
|
|
|
|
int r = AppLayerParse(&f, ALPROTO_TEST, STREAM_TOSERVER|STREAM_EOF, testbuf,
|
|
|
|
|
testlen);
|
|
|
|
|
@ -1349,7 +1322,7 @@ static int AppLayerParserTest01 (void)
|
|
|
|
|
goto end;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!(ssn.flags & STREAMTCP_FLAG_NO_APPLAYER_INSPECTION))
|
|
|
|
|
if (!(f.alflags & FLOW_AL_NO_APPLAYER_INSPECTION))
|
|
|
|
|
{
|
|
|
|
|
printf("flag should have been set, but is not: ");
|
|
|
|
|
goto end;
|
|
|
|
|
@ -1357,7 +1330,62 @@ static int AppLayerParserTest01 (void)
|
|
|
|
|
|
|
|
|
|
result = 1;
|
|
|
|
|
end:
|
|
|
|
|
StreamL7DataPtrFree(&ssn);
|
|
|
|
|
FlowL7DataPtrFree(&f);
|
|
|
|
|
StreamTcpFreeConfig(TRUE);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** \test Test the deallocation of app layer parser memory on occurance of
|
|
|
|
|
* error in the parsing process for UDP.
|
|
|
|
|
*/
|
|
|
|
|
static int AppLayerParserTest02 (void)
|
|
|
|
|
{
|
|
|
|
|
int result = 1;
|
|
|
|
|
Flow f;
|
|
|
|
|
uint8_t testbuf[] = { 0x11 };
|
|
|
|
|
uint32_t testlen = sizeof(testbuf);
|
|
|
|
|
struct in_addr addr;
|
|
|
|
|
struct in_addr addr1;
|
|
|
|
|
Address src;
|
|
|
|
|
Address dst;
|
|
|
|
|
|
|
|
|
|
memset(&f, 0, sizeof(f));
|
|
|
|
|
memset(&src, 0, sizeof(src));
|
|
|
|
|
memset(&dst, 0, sizeof(dst));
|
|
|
|
|
|
|
|
|
|
/* Register the Test protocol state and parser functions */
|
|
|
|
|
AppLayerRegisterProto("test", ALPROTO_TEST, STREAM_TOSERVER,
|
|
|
|
|
TestProtocolParser);
|
|
|
|
|
AppLayerRegisterStateFuncs(ALPROTO_TEST, TestProtocolStateAlloc,
|
|
|
|
|
TestProtocolStateFree);
|
|
|
|
|
|
|
|
|
|
f.alproto = ALPROTO_TEST;
|
|
|
|
|
|
|
|
|
|
inet_pton(AF_INET, "1.2.3.4", &addr.s_addr);
|
|
|
|
|
src.family = AF_INET;
|
|
|
|
|
src.addr_data32[0] = addr.s_addr;
|
|
|
|
|
inet_pton(AF_INET, "4.3.2.1", &addr1.s_addr);
|
|
|
|
|
dst.family = AF_INET;
|
|
|
|
|
dst.addr_data32[0] = addr1.s_addr;
|
|
|
|
|
f.src = src;
|
|
|
|
|
f.dst = dst;
|
|
|
|
|
f.sp = htons(20);
|
|
|
|
|
f.dp = htons(40);
|
|
|
|
|
f.proto = IPPROTO_UDP;
|
|
|
|
|
|
|
|
|
|
StreamTcpInitConfig(TRUE);
|
|
|
|
|
FlowL7DataPtrInit(&f);
|
|
|
|
|
|
|
|
|
|
int r = AppLayerParse(&f, ALPROTO_TEST, STREAM_TOSERVER|STREAM_EOF, testbuf,
|
|
|
|
|
testlen);
|
|
|
|
|
if (r != -1) {
|
|
|
|
|
printf("returned %" PRId32 ", expected -1: \n", r);
|
|
|
|
|
result = 0;
|
|
|
|
|
goto end;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
end:
|
|
|
|
|
FlowL7DataPtrFree(&f);
|
|
|
|
|
StreamTcpFreeConfig(TRUE);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
@ -1368,5 +1396,6 @@ void AppLayerParserRegisterTests(void)
|
|
|
|
|
{
|
|
|
|
|
#ifdef UNITTESTS
|
|
|
|
|
UtRegisterTest("AppLayerParserTest01", AppLayerParserTest01, 1);
|
|
|
|
|
UtRegisterTest("AppLayerParserTest02", AppLayerParserTest02, 1);
|
|
|
|
|
#endif /* UNITTESTS */
|
|
|
|
|
}
|
|
|
|
|
|