Hacks to enable alert dns even though we have dnstcp and dnsudp parsers. Needs proper solution later.

pull/412/merge
Victor Julien 14 years ago
parent 8e01cba85d
commit 59780ca770

@ -635,6 +635,13 @@ int AppLayerRegisterProto(char *name, uint8_t proto, uint8_t flags,
exit(EXIT_FAILURE);
}
/* register name here as well so pp only protocols will work */
if (al_proto_table[proto].name != NULL) {
BUG_ON(strcmp(al_proto_table[proto].name, name) != 0);
} else {
al_proto_table[proto].name = name;
}
al_parser_table[al_max_parsers].name = name;
al_parser_table[al_max_parsers].AppLayerParser = AppLayerParser;

@ -115,14 +115,22 @@ static DetectAppLayerEventData *DetectAppLayerEventParse(const char *arg)
char buffer[50] = "";
strlcpy(buffer, arg, p_idx - arg + 1); /* + 1 for trailing \0 */
//int module_id = DecoderEventModuleGetModuleId(buffer);
//uint16_t alproto = AppLayerGetProtoByName(buffer);
/** XXX HACK to support "dns" we use this trick */
if (strcasecmp(buffer, "dns") == 0)
strlcpy(buffer, "dnsudp", sizeof(buffer));
uint16_t alproto = AppLayerDecoderEventsModuleGetAlproto(buffer);
if (alproto == ALPROTO_UNKNOWN)
if (alproto == ALPROTO_UNKNOWN) {
SCLogError(SC_ERR_INVALID_SIGNATURE, "app-layer-event keyword supplied "
"with unknown protocol \"%s\"", buffer);
return NULL;
}
int event_id = AppLayerDecoderEventsModuleGetEventId(alproto, p_idx + 1);
if (event_id == -1)
if (event_id == -1) {
SCLogError(SC_ERR_INVALID_SIGNATURE, "app-layer-event keyword protocol "
"\"%s\" don't have event \"%s\" registered", buffer, p_idx + 1);
return NULL;
}
DetectAppLayerEventData *aled = SCMalloc(sizeof(DetectAppLayerEventData));
if (unlikely(aled == NULL))

@ -596,6 +596,17 @@ int SigParseProto(Signature *s, const char *protostr) {
}
als = als->next;
}
/** VJ since our dns parser uses only pp, this is required to set
* ipprotos */
AppLayerProbingParserInfo *ppi =
AppLayerGetProbingParserInfo(alp_proto_ctx.probing_parsers_info,
protostr);
if (ppi != NULL) {
/* indicate that the signature is app-layer */
s->flags |= SIG_FLAG_APPLAYER;
s->alproto = ppi->al_proto;
s->proto.proto[ppi->ip_proto / 8] |= 1 << (ppi->ip_proto % 8);
}
SCReturnInt(0);
}
AppLayerProbingParserInfo *ppi =
@ -762,8 +773,17 @@ static int SigParseBasics(Signature *s, char *sigstr, char ***result, uint8_t ad
goto error;
/* Parse Proto */
if (SigParseProto(s, arr[CONFIG_PROTO]) < 0)
goto error;
if (strcasecmp(arr[CONFIG_PROTO], "dns") == 0) {
/** XXX HACK */
if (SigParseProto(s, "dnstcp") < 0)
goto error;
if (SigParseProto(s, "dnsudp") < 0)
goto error;
} else {
if (SigParseProto(s, arr[CONFIG_PROTO]) < 0)
goto error;
}
if (strcmp(arr[CONFIG_DIREC], "<-") == 0) {
SCLogError(SC_ERR_INVALID_DIRECTION, "\"<-\" is not a valid direction modifier, \"->\" and \"<>\" are supported.");

Loading…
Cancel
Save