-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Applayer plugin 5053 v3.4 #11795
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Applayer plugin 5053 v3.4 #11795
Changes from all commits
7cd4a9c
bf0c748
76f8e47
3f2ee60
7e3a380
23703d5
8a8a51a
936d65e
65f4fa8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -159,7 +159,10 @@ typedef struct AppLayerProtoDetectCtx_ { | |
| /* Indicates the protocols that have registered themselves | ||
| * for protocol detection. This table is independent of the | ||
| * ipproto. */ | ||
| const char *alproto_names[ALPROTO_MAX]; | ||
| const char **alproto_names; | ||
|
|
||
| /* Protocol expectations, like ftp-data on tcp */ | ||
| uint8_t *expectation_proto; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand the type here. What does it point to?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is an array of ALPROTO_MAX "iptypes" : IPPROTO_TCP, IPPROTO_UDP or something else like 0 |
||
| } AppLayerProtoDetectCtx; | ||
|
|
||
| typedef struct AppLayerProtoDetectAliases_ { | ||
|
|
@@ -1718,6 +1721,15 @@ int AppLayerProtoDetectSetup(void) | |
| } | ||
| } | ||
|
|
||
| alpd_ctx.alproto_names = SCCalloc(ALPROTO_MAX, sizeof(char *)); | ||
| if (unlikely(alpd_ctx.alproto_names == NULL)) { | ||
| FatalError("Unable to alloc alproto_names."); | ||
| } | ||
| // to realloc when dynamic protos are added | ||
| alpd_ctx.expectation_proto = SCCalloc(ALPROTO_MAX, sizeof(uint8_t)); | ||
| if (unlikely(alpd_ctx.expectation_proto == NULL)) { | ||
| FatalError("Unable to alloc expectation_proto."); | ||
| } | ||
| AppLayerExpectationSetup(); | ||
|
|
||
| SCReturnInt(0); | ||
|
|
@@ -1749,6 +1761,11 @@ int AppLayerProtoDetectDeSetup(void) | |
| } | ||
| } | ||
|
|
||
| SCFree(alpd_ctx.alproto_names); | ||
| alpd_ctx.alproto_names = NULL; | ||
| SCFree(alpd_ctx.expectation_proto); | ||
| alpd_ctx.expectation_proto = NULL; | ||
|
|
||
| SpmDestroyGlobalThreadCtx(alpd_ctx.spm_global_thread_ctx); | ||
|
|
||
| AppLayerProtoDetectFreeAliases(); | ||
|
|
@@ -1762,6 +1779,7 @@ void AppLayerProtoDetectRegisterProtocol(AppProto alproto, const char *alproto_n | |
| { | ||
| SCEnter(); | ||
|
|
||
| // should have just been realloced when dynamic protos is added | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what does this mean?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is more a TODO note for me for the next PR that |
||
| if (alpd_ctx.alproto_names[alproto] == NULL) | ||
| alpd_ctx.alproto_names[alproto] = alproto_name; | ||
|
|
||
|
|
@@ -2111,27 +2129,25 @@ void AppLayerProtoDetectSupportedAppProtocols(AppProto *alprotos) | |
| SCReturn; | ||
| } | ||
|
|
||
| uint8_t expectation_proto[ALPROTO_MAX]; | ||
|
|
||
| static void AppLayerProtoDetectPEGetIpprotos(AppProto alproto, | ||
| uint8_t *ipprotos) | ||
| { | ||
| if (expectation_proto[alproto] == IPPROTO_TCP) { | ||
| if (alpd_ctx.expectation_proto[alproto] == IPPROTO_TCP) { | ||
| ipprotos[IPPROTO_TCP / 8] |= 1 << (IPPROTO_TCP % 8); | ||
| } | ||
| if (expectation_proto[alproto] == IPPROTO_UDP) { | ||
| if (alpd_ctx.expectation_proto[alproto] == IPPROTO_UDP) { | ||
| ipprotos[IPPROTO_UDP / 8] |= 1 << (IPPROTO_UDP % 8); | ||
| } | ||
| } | ||
|
|
||
| void AppLayerRegisterExpectationProto(uint8_t proto, AppProto alproto) | ||
| { | ||
| if (expectation_proto[alproto]) { | ||
| if (proto != expectation_proto[alproto]) { | ||
| if (alpd_ctx.expectation_proto[alproto]) { | ||
| if (proto != alpd_ctx.expectation_proto[alproto]) { | ||
| SCLogError("Expectation on 2 IP protocols are not supported"); | ||
| } | ||
| } | ||
| expectation_proto[alproto] = proto; | ||
| alpd_ctx.expectation_proto[alproto] = proto; | ||
| } | ||
|
|
||
| /***** Unittests *****/ | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.