38 static void DetectAppLayerProtocolRegisterTests(
void);
56 static int DetectAppLayerProtocolPacketMatch(
153 #define MAX_ALPROTO_NAME 50
160 char *sep = strchr(arg,
',');
163 strlcpy(alproto_copy, arg, sep - arg + 1);
164 alproto_name = alproto_copy;
166 alproto_name = (
char *)arg;
168 if (strcmp(alproto_name,
"failed") == 0) {
170 }
else if (strcmp(alproto_name,
"unknown") == 0) {
173 "keyword can't use negation with protocol 'unknown'");
181 "keyword supplied with unknown protocol \"%s\"",
188 if (strcmp(sep + 1,
"final") == 0) {
190 }
else if (strcmp(sep + 1,
"original") == 0) {
192 }
else if (strcmp(sep + 1,
"either") == 0) {
194 }
else if (strcmp(sep + 1,
"to_server") == 0) {
196 }
else if (strcmp(sep + 1,
"to_client") == 0) {
198 }
else if (strcmp(sep + 1,
"direction") == 0) {
202 "keyword supplied with unknown mode \"%s\"",
242 "have the rule match on an app layer protocol set through "
243 "other keywords that match on this protocol, or have "
244 "already seen a non-negated app-layer-protocol.");
253 for ( ; tsm != NULL; tsm = tsm->
next) {
257 if (HasConflicts(data, them)) {
259 "positive app-layer-protocol match with negated "
260 "match or match for 'failed'.");
291 if (!PrefilterPacketHeaderExtraMatch(
ctx, p)) {
296 if (p->
flow == NULL) {
308 bool negated = (bool)
ctx->v1.u8[2];
309 switch (
ctx->v1.u8[3]) {
335 PrefilterAddSids(&det_ctx->
pmq,
ctx->sigs_array,
ctx->sigs_cnt);
338 PrefilterAddSids(&det_ctx->
pmq,
ctx->sigs_array,
ctx->sigs_cnt);
343 PrefilterAddSids(&det_ctx->
pmq,
ctx->sigs_array,
ctx->sigs_cnt);
352 if (!AppProtoEquals(
ctx->v1.u16[0], alproto)) {
353 PrefilterAddSids(&det_ctx->
pmq,
ctx->sigs_array,
ctx->sigs_cnt);
357 if (AppProtoEquals(
ctx->v1.u16[0], alproto)) {
358 PrefilterAddSids(&det_ctx->
pmq,
ctx->sigs_array,
ctx->sigs_cnt);
384 PrefilterPacketAppProtoSet, PrefilterPacketAppProtoCompare,
385 PrefilterPacketAppProtoMatch);
388 static bool PrefilterAppProtoIsPrefilterable(
const Signature *s)
419 static int DetectAppLayerProtocolTest01(
void)
425 DetectAppLayerProtocolFree(NULL, data);
429 static int DetectAppLayerProtocolTest02(
void)
435 DetectAppLayerProtocolFree(NULL, data);
439 static int DetectAppLayerProtocolTest03(
void)
448 "(app-layer-protocol:http; sid:1;)");
463 static int DetectAppLayerProtocolTest04(
void)
472 "(app-layer-protocol:!http; sid:1;)");
489 static int DetectAppLayerProtocolTest05(
void)
498 "(app-layer-protocol:!http; app-layer-protocol:!smtp; sid:1;)");
520 static int DetectAppLayerProtocolTest06(
void)
528 "(app-layer-protocol:smtp; sid:1;)");
534 static int DetectAppLayerProtocolTest07(
void)
542 "(app-layer-protocol:!smtp; sid:1;)");
548 static int DetectAppLayerProtocolTest08(
void)
556 "(app-layer-protocol:!smtp; app-layer-protocol:http; sid:1;)");
562 static int DetectAppLayerProtocolTest09(
void)
570 "(app-layer-protocol:http; app-layer-protocol:!smtp; sid:1;)");
576 static int DetectAppLayerProtocolTest10(
void)
584 "(app-layer-protocol:smtp; app-layer-protocol:!http; sid:1;)");
590 static int DetectAppLayerProtocolTest11(
void)
596 DetectAppLayerProtocolFree(NULL, data);
600 static int DetectAppLayerProtocolTest12(
void)
606 DetectAppLayerProtocolFree(NULL, data);
610 static int DetectAppLayerProtocolTest13(
void)
619 "(app-layer-protocol:failed; sid:1;)");
634 static int DetectAppLayerProtocolTest14(
void)
642 "(app-layer-protocol:http; flowbits:set,blah; sid:1;)");
652 "(app-layer-protocol:http; flow:to_client; sid:2;)");
663 "(app-layer-protocol:http; flow:to_client,established; sid:3;)");
682 static void DetectAppLayerProtocolRegisterTests(
void)
685 DetectAppLayerProtocolTest01);
687 DetectAppLayerProtocolTest02);
689 DetectAppLayerProtocolTest03);
691 DetectAppLayerProtocolTest04);
693 DetectAppLayerProtocolTest05);
695 DetectAppLayerProtocolTest06);
697 DetectAppLayerProtocolTest07);
699 DetectAppLayerProtocolTest08);
701 DetectAppLayerProtocolTest09);
703 DetectAppLayerProtocolTest10);
705 DetectAppLayerProtocolTest11);
707 DetectAppLayerProtocolTest12);
709 DetectAppLayerProtocolTest13);
711 DetectAppLayerProtocolTest14);