38 static void DetectAppLayerProtocolRegisterTests(
void);
56 static int DetectAppLayerProtocolPacketMatch(
124 #define MAX_ALPROTO_NAME 50
131 char *sep = strchr(arg,
',');
134 strlcpy(alproto_copy, arg, sep - arg + 1);
135 alproto_name = alproto_copy;
137 alproto_name = (
char *)arg;
139 if (strcmp(alproto_name,
"failed") == 0) {
145 "keyword supplied with unknown protocol \"%s\"",
152 if (strcmp(sep + 1,
"final") == 0) {
154 }
else if (strcmp(sep + 1,
"original") == 0) {
156 }
else if (strcmp(sep + 1,
"either") == 0) {
158 }
else if (strcmp(sep + 1,
"to_server") == 0) {
160 }
else if (strcmp(sep + 1,
"to_client") == 0) {
162 }
else if (strcmp(sep + 1,
"direction") == 0) {
166 "keyword supplied with unknown mode \"%s\"",
206 "have the rule match on an app layer protocol set through "
207 "other keywords that match on this protocol, or have "
208 "already seen a non-negated app-layer-protocol.");
217 for ( ; tsm != NULL; tsm = tsm->
next) {
221 if (HasConflicts(data, them)) {
223 "positive app-layer-protocol match with negated "
224 "match or match for 'failed'.");
255 if (!PrefilterPacketHeaderExtraMatch(
ctx, p)) {
260 if (p->
flow == NULL) {
272 bool negated = (bool)
ctx->v1.u8[2];
273 switch (
ctx->v1.u8[3]) {
298 PrefilterAddSids(&det_ctx->
pmq,
ctx->sigs_array,
ctx->sigs_cnt);
301 PrefilterAddSids(&det_ctx->
pmq,
ctx->sigs_array,
ctx->sigs_cnt);
308 if (AppProtoEquals(
ctx->v1.u16[0], alproto) ^ negated) {
309 PrefilterAddSids(&det_ctx->
pmq,
ctx->sigs_array,
ctx->sigs_cnt);
336 PrefilterPacketAppProtoMatch);
339 static bool PrefilterAppProtoIsPrefilterable(
const Signature *s)
354 DetectAppLayerProtocolPacketMatch;
356 DetectAppLayerProtocolSetup;
358 DetectAppLayerProtocolFree;
361 DetectAppLayerProtocolRegisterTests;
367 PrefilterSetupAppProto;
369 PrefilterAppProtoIsPrefilterable;
376 static int DetectAppLayerProtocolTest01(
void)
382 DetectAppLayerProtocolFree(NULL, data);
386 static int DetectAppLayerProtocolTest02(
void)
392 DetectAppLayerProtocolFree(NULL, data);
396 static int DetectAppLayerProtocolTest03(
void)
405 "(app-layer-protocol:http; sid:1;)");
420 static int DetectAppLayerProtocolTest04(
void)
429 "(app-layer-protocol:!http; sid:1;)");
446 static int DetectAppLayerProtocolTest05(
void)
455 "(app-layer-protocol:!http; app-layer-protocol:!smtp; sid:1;)");
477 static int DetectAppLayerProtocolTest06(
void)
485 "(app-layer-protocol:smtp; sid:1;)");
491 static int DetectAppLayerProtocolTest07(
void)
499 "(app-layer-protocol:!smtp; sid:1;)");
505 static int DetectAppLayerProtocolTest08(
void)
513 "(app-layer-protocol:!smtp; app-layer-protocol:http; sid:1;)");
519 static int DetectAppLayerProtocolTest09(
void)
527 "(app-layer-protocol:http; app-layer-protocol:!smtp; sid:1;)");
533 static int DetectAppLayerProtocolTest10(
void)
541 "(app-layer-protocol:smtp; app-layer-protocol:!http; sid:1;)");
547 static int DetectAppLayerProtocolTest11(
void)
553 DetectAppLayerProtocolFree(NULL, data);
557 static int DetectAppLayerProtocolTest12(
void)
563 DetectAppLayerProtocolFree(NULL, data);
567 static int DetectAppLayerProtocolTest13(
void)
576 "(app-layer-protocol:failed; sid:1;)");
591 static int DetectAppLayerProtocolTest14(
void)
599 "(app-layer-protocol:http; flowbits:set,blah; sid:1;)");
609 "(app-layer-protocol:http; flow:to_client; sid:2;)");
620 "(app-layer-protocol:http; flow:to_client,established; sid:3;)");
639 static void DetectAppLayerProtocolRegisterTests(
void)
642 DetectAppLayerProtocolTest01);
644 DetectAppLayerProtocolTest02);
646 DetectAppLayerProtocolTest03);
648 DetectAppLayerProtocolTest04);
650 DetectAppLayerProtocolTest05);
652 DetectAppLayerProtocolTest06);
654 DetectAppLayerProtocolTest07);
656 DetectAppLayerProtocolTest08);
658 DetectAppLayerProtocolTest09);
660 DetectAppLayerProtocolTest10);
662 DetectAppLayerProtocolTest11);
664 DetectAppLayerProtocolTest12);
666 DetectAppLayerProtocolTest13);
668 DetectAppLayerProtocolTest14);