uint32_t min_depth;
/* the max length of data after which this parser won't be invoked */
uint32_t max_depth;
- /* the probing parser function */
- ProbingParserFPtr ProbingParser;
+
+ /* the to_server probing parser function */
+ ProbingParserFPtr ProbingParserTs;
+
+ /* the to_client probing parser function */
+ ProbingParserFPtr ProbingParserTc;
struct AppLayerProtoDetectProbingParserElement_ *next;
} AppLayerProtoDetectProbingParserElement;
continue;
}
- alproto = pe->ProbingParser(buf, buflen, NULL);
- if (alproto != ALPROTO_UNKNOWN && alproto != ALPROTO_FAILED)
- goto end;
- if (alproto == ALPROTO_FAILED ||
- (pe->max_depth != 0 && buflen > pe->max_depth)) {
- alproto_masks[0] |= pe->alproto_mask;
- }
- pe = pe->next;
+ if (direction & STREAM_TOSERVER && pe->ProbingParserTs != NULL) {
+ alproto = pe->ProbingParserTs(buf, buflen, NULL);
+ } else if (pe->ProbingParserTc != NULL) {
+ alproto = pe->ProbingParserTc(buf, buflen, NULL);
+ }
+ if (alproto != ALPROTO_UNKNOWN && alproto != ALPROTO_FAILED)
+ goto end;
+ if (alproto == ALPROTO_FAILED ||
+ (pe->max_depth != 0 && buflen > pe->max_depth)) {
+ alproto_masks[0] |= pe->alproto_mask;
+ }
+ pe = pe->next;
}
pe = pe2;
while (pe != NULL) {
continue;
}
- alproto = pe->ProbingParser(buf, buflen, NULL);
+ alproto = pe->ProbingParserTs(buf, buflen, NULL);
if (alproto != ALPROTO_UNKNOWN && alproto != ALPROTO_FAILED)
goto end;
if (alproto == ALPROTO_FAILED ||
AppLayerProtoDetectProbingParserElementCreate(AppProto alproto,
uint16_t port,
uint16_t min_depth,
- uint16_t max_depth,
- uint16_t (*AppLayerProtoDetectProbingParserFunc)
- (uint8_t *input, uint32_t input_len, uint32_t *offset))
+ uint16_t max_depth)
{
AppLayerProtoDetectProbingParserElement *pe = AppLayerProtoDetectProbingParserElementAlloc();
pe->alproto_mask = AppLayerProtoDetectProbingParserGetMask(alproto);
pe->min_depth = min_depth;
pe->max_depth = max_depth;
- pe->ProbingParser = AppLayerProtoDetectProbingParserFunc;
pe->next = NULL;
if (max_depth != 0 && min_depth >= max_depth) {
"the probing parser. Invalid alproto - %d", alproto);
goto error;
}
- if (AppLayerProtoDetectProbingParserFunc == NULL) {
- SCLogError(SC_ERR_ALPARSER, "Invalid arguments sent to "
- "register the probing parser. Probing parser func NULL");
- goto error;
- }
SCReturnPtr(pe, "AppLayerProtoDetectProbingParserElement");
error:
new_pe->alproto_mask = pe->alproto_mask;
new_pe->min_depth = pe->min_depth;
new_pe->max_depth = pe->max_depth;
- new_pe->ProbingParser = pe->ProbingParser;
+ new_pe->ProbingParserTs = pe->ProbingParserTs;
+ new_pe->ProbingParserTc = pe->ProbingParserTc;
new_pe->next = NULL;
SCReturnPtr(new_pe, "AppLayerProtoDetectProbingParserElement");
AppProto alproto,
uint16_t min_depth, uint16_t max_depth,
uint8_t direction,
- ProbingParserFPtr ProbingParser)
+ ProbingParserFPtr ProbingParser1,
+ ProbingParserFPtr ProbingParser2)
{
SCEnter();
AppLayerProtoDetectProbingParserElement *new_pe =
AppLayerProtoDetectProbingParserElementCreate(alproto,
curr_port->port,
- min_depth, max_depth,
- ProbingParser);
+ min_depth, max_depth);
if (new_pe == NULL)
goto error;
curr_pe = new_pe;
AppLayerProtoDetectProbingParserElement **head_pe;
if (direction & STREAM_TOSERVER) {
+ curr_pe->ProbingParserTs = ProbingParser1;
+ curr_pe->ProbingParserTc = ProbingParser2;
if (curr_port->dp == NULL)
curr_port->dp_max_depth = new_pe->max_depth;
if (new_pe->max_depth == 0)
curr_port->alproto_mask |= new_pe->alproto_mask;
head_pe = &curr_port->dp;
} else {
+ curr_pe->ProbingParserTs = ProbingParser2;
+ curr_pe->ProbingParserTc = ProbingParser1;
if (curr_port->sp == NULL)
curr_port->sp_max_depth = new_pe->max_depth;
if (new_pe->max_depth == 0)
AppProto alproto,
uint16_t min_depth, uint16_t max_depth,
uint8_t direction,
- ProbingParserFPtr ProbingParser)
+ ProbingParserFPtr ProbingParser1,
+ ProbingParserFPtr ProbingParser2)
{
SCEnter();
alproto,
min_depth, max_depth,
direction,
- ProbingParser);
+ ProbingParser1,
+ ProbingParser2);
}
temp_dp = temp_dp->next;
}
const char *alproto_name,
AppProto alproto,
uint16_t min_depth, uint16_t max_depth,
- ProbingParserFPtr ProbingParser)
+ ProbingParserFPtr ProbingParserTs,
+ ProbingParserFPtr ProbingParserTc)
{
SCEnter();
alproto,
min_depth, max_depth,
STREAM_TOSERVER, /* to indicate dp */
- ProbingParser);
+ ProbingParserTs, ProbingParserTc);
}
/* detect by source port of flow */
alproto,
min_depth, max_depth,
STREAM_TOCLIENT, /* to indicate sp */
- ProbingParser);
+ ProbingParserTc, ProbingParserTs);
}
ALPROTO_HTTP,
5, 8,
STREAM_TOSERVER,
- ProbingParserDummyForTesting);
+ ProbingParserDummyForTesting, NULL);
AppLayerProtoDetectPPRegister(IPPROTO_TCP,
"80",
ALPROTO_SMB,
5, 6,
STREAM_TOSERVER,
- ProbingParserDummyForTesting);
+ ProbingParserDummyForTesting, NULL);
AppLayerProtoDetectPPRegister(IPPROTO_TCP,
"80",
ALPROTO_FTP,
7, 10,
STREAM_TOSERVER,
- ProbingParserDummyForTesting);
+ ProbingParserDummyForTesting, NULL);
AppLayerProtoDetectPPRegister(IPPROTO_TCP,
"81",
ALPROTO_DCERPC,
9, 10,
STREAM_TOSERVER,
- ProbingParserDummyForTesting);
+ ProbingParserDummyForTesting, NULL);
AppLayerProtoDetectPPRegister(IPPROTO_TCP,
"81",
ALPROTO_FTP,
7, 15,
STREAM_TOSERVER,
- ProbingParserDummyForTesting);
+ ProbingParserDummyForTesting, NULL);
AppLayerProtoDetectPPRegister(IPPROTO_TCP,
"0",
ALPROTO_SMTP,
12, 0,
STREAM_TOSERVER,
- ProbingParserDummyForTesting);
+ ProbingParserDummyForTesting, NULL);
AppLayerProtoDetectPPRegister(IPPROTO_TCP,
"0",
ALPROTO_TLS,
12, 18,
STREAM_TOSERVER,
- ProbingParserDummyForTesting);
+ ProbingParserDummyForTesting, NULL);
AppLayerProtoDetectPPRegister(IPPROTO_TCP,
"85",
ALPROTO_DCERPC,
9, 10,
STREAM_TOSERVER,
- ProbingParserDummyForTesting);
+ ProbingParserDummyForTesting, NULL);
AppLayerProtoDetectPPRegister(IPPROTO_TCP,
"85",
ALPROTO_FTP,
7, 15,
STREAM_TOSERVER,
- ProbingParserDummyForTesting);
+ ProbingParserDummyForTesting, NULL);
result = 1;
AppLayerProtoDetectPPRegister(IPPROTO_UDP,
ALPROTO_IMAP,
12, 23,
STREAM_TOSERVER,
- ProbingParserDummyForTesting);
+ ProbingParserDummyForTesting, NULL);
/* toclient */
AppLayerProtoDetectPPRegister(IPPROTO_TCP,
ALPROTO_JABBER,
12, 23,
STREAM_TOCLIENT,
- ProbingParserDummyForTesting);
+ ProbingParserDummyForTesting, NULL);
AppLayerProtoDetectPPRegister(IPPROTO_TCP,
"0",
ALPROTO_IRC,
12, 14,
STREAM_TOCLIENT,
- ProbingParserDummyForTesting);
+ ProbingParserDummyForTesting, NULL);
AppLayerProtoDetectPPRegister(IPPROTO_TCP,
"85",
ALPROTO_DCERPC,
9, 10,
STREAM_TOCLIENT,
- ProbingParserDummyForTesting);
+ ProbingParserDummyForTesting, NULL);
AppLayerProtoDetectPPRegister(IPPROTO_TCP,
"81",
ALPROTO_FTP,
7, 15,
STREAM_TOCLIENT,
- ProbingParserDummyForTesting);
+ ProbingParserDummyForTesting, NULL);
AppLayerProtoDetectPPRegister(IPPROTO_TCP,
"0",
ALPROTO_TLS,
12, 18,
STREAM_TOCLIENT,
- ProbingParserDummyForTesting);
+ ProbingParserDummyForTesting, NULL);
AppLayerProtoDetectPPRegister(IPPROTO_TCP,
"80",
ALPROTO_HTTP,
5, 8,
STREAM_TOCLIENT,
- ProbingParserDummyForTesting);
+ ProbingParserDummyForTesting, NULL);
AppLayerProtoDetectPPRegister(IPPROTO_TCP,
"81",
ALPROTO_DCERPC,
9, 10,
STREAM_TOCLIENT,
- ProbingParserDummyForTesting);
+ ProbingParserDummyForTesting, NULL);
AppLayerProtoDetectPPRegister(IPPROTO_TCP,
"90",
ALPROTO_FTP,
7, 15,
STREAM_TOCLIENT,
- ProbingParserDummyForTesting);
+ ProbingParserDummyForTesting, NULL);
AppLayerProtoDetectPPRegister(IPPROTO_TCP,
"80",
ALPROTO_SMB,
5, 6,
STREAM_TOCLIENT,
- ProbingParserDummyForTesting);
+ ProbingParserDummyForTesting, NULL);
AppLayerProtoDetectPPRegister(IPPROTO_UDP,
"85",
ALPROTO_IMAP,
12, 23,
STREAM_TOCLIENT,
- ProbingParserDummyForTesting);
+ ProbingParserDummyForTesting, NULL);
AppLayerProtoDetectPPRegister(IPPROTO_TCP,
"0",
ALPROTO_SMTP,
12, 17,
STREAM_TOCLIENT,
- ProbingParserDummyForTesting);
+ ProbingParserDummyForTesting, NULL);
AppLayerProtoDetectPPRegister(IPPROTO_TCP,
"80",
ALPROTO_FTP,
7, 10,
STREAM_TOCLIENT,
- ProbingParserDummyForTesting);
+ ProbingParserDummyForTesting, NULL);
AppLayerProtoDetectPPTestDataElement element_ts_80[] = {
{ "http", ALPROTO_HTTP, 80, 1 << ALPROTO_HTTP, 5, 8 },
if (RunmodeIsUnittests())
{
AppLayerProtoDetectPPRegister(IPPROTO_UDP, "44818", ALPROTO_ENIP,
- 0, sizeof(ENIPEncapHdr), STREAM_TOSERVER, ENIPProbingParser);
+ 0, sizeof(ENIPEncapHdr), STREAM_TOSERVER, ENIPProbingParser, NULL);
AppLayerProtoDetectPPRegister(IPPROTO_UDP, "44818", ALPROTO_ENIP,
- 0, sizeof(ENIPEncapHdr), STREAM_TOCLIENT, ENIPProbingParser);
+ 0, sizeof(ENIPEncapHdr), STREAM_TOCLIENT, ENIPProbingParser, NULL);
} else
{
if (!AppLayerProtoDetectPPParseConfPorts("udp", IPPROTO_UDP,
proto_name, ALPROTO_ENIP, 0, sizeof(ENIPEncapHdr),
- ENIPProbingParser))
+ ENIPProbingParser, ENIPProbingParser))
{
SCLogDebug(
"no ENIP UDP config found enabling ENIP detection on port 44818.");
AppLayerProtoDetectPPRegister(IPPROTO_UDP, "44818",
ALPROTO_ENIP, 0, sizeof(ENIPEncapHdr), STREAM_TOSERVER,
- ENIPProbingParser);
+ ENIPProbingParser, NULL);
AppLayerProtoDetectPPRegister(IPPROTO_UDP, "44818",
ALPROTO_ENIP, 0, sizeof(ENIPEncapHdr), STREAM_TOCLIENT,
- ENIPProbingParser);
+ ENIPProbingParser, NULL);
}
}
if (RunmodeIsUnittests())
{
AppLayerProtoDetectPPRegister(IPPROTO_TCP, "44818", ALPROTO_ENIP,
- 0, sizeof(ENIPEncapHdr), STREAM_TOSERVER, ENIPProbingParser);
+ 0, sizeof(ENIPEncapHdr), STREAM_TOSERVER, ENIPProbingParser, NULL);
AppLayerProtoDetectPPRegister(IPPROTO_TCP, "44818", ALPROTO_ENIP,
- 0, sizeof(ENIPEncapHdr), STREAM_TOCLIENT, ENIPProbingParser);
+ 0, sizeof(ENIPEncapHdr), STREAM_TOCLIENT, ENIPProbingParser, NULL);
} else
{
if (!AppLayerProtoDetectPPParseConfPorts("tcp", IPPROTO_TCP,
proto_name, ALPROTO_ENIP, 0, sizeof(ENIPEncapHdr),
- ENIPProbingParser))
+ ENIPProbingParser, ENIPProbingParser))
{
return;
}