Browse files

move filter code to ec_filter.c

  • Loading branch information...
1 parent c2fae1e commit 7b9adb9fb1f5c8787c4c470b90df9bc890b1132d @wertarbyte wertarbyte committed Oct 3, 2011
Showing with 18 additions and 12 deletions.
  1. +1 −1 include/ec_filter.h
  2. +1 −9 src/ec_decode.c
  3. +16 −2 src/ec_filter.c
View
2 include/ec_filter.h
@@ -135,7 +135,7 @@ void filter_init_mutex(void);
/* exported functions */
-EC_API_EXTERN int filter_engine(struct filter_op *fop, struct packet_object *po);
+EC_API_EXTERN void filter_packet(struct packet_object *po);
EC_API_EXTERN int filter_load_file(char *filename, struct filter_list **list);
EC_API_EXTERN void filter_unload(struct filter_list **list);
EC_API_EXTERN void filter_clear(void);
View
10 src/ec_decode.c
@@ -297,15 +297,7 @@ FUNC_DECODER(decode_data)
* here we can filter the content of the packet.
* the injection is done elsewhere.
*/
- struct filter_list **l;
- for (l = GBL_FILTERS; *l != NULL; l = &(*l)->next) {
- /* if a script drops the packet, do not present it to following scripts */
- if ( po->flags & PO_DROPPED )
- break;
- /* check whether the filter script is enabled */
- if ((*l)->enabled)
- filter_engine((*l)->env.chain, po);
- }
+ filter_packet(po);
/* If the modified packet exceeds the MTU split it into inject buffer */
inject_split_data(po);
View
18 src/ec_filter.c
@@ -48,7 +48,7 @@ void filter_unload(struct filter_list **list);
static void reconstruct_strings(struct filter_env *fenv, struct filter_header *fh);
static int compile_regex(struct filter_env *fenv, struct filter_header *fh);
-int filter_engine(struct filter_op *fop, struct packet_object *po);
+static int filter_engine(struct filter_op *fop, struct packet_object *po);
static int execute_test(struct filter_op *fop, struct packet_object *po);
static int execute_assign(struct filter_op *fop, struct packet_object *po);
static int execute_incdec(struct filter_op *fop, struct packet_object *po);
@@ -86,7 +86,7 @@ void filter_init_mutex(void) {
* it process the filter_ops and apply the instructions
* on the given packet object
*/
-int filter_engine(struct filter_op *fop, struct packet_object *po)
+static int filter_engine(struct filter_op *fop, struct packet_object *po)
{
u_int32 eip = 0;
u_int32 flags = 0;
@@ -171,6 +171,20 @@ int filter_engine(struct filter_op *fop, struct packet_object *po)
return 0;
}
+/*
+ * pass a packet through every (enabled) filter loaded
+ */
+void filter_packet(struct packet_object *po) {
+ struct filter_list **l;
+ for (l = GBL_FILTERS; *l != NULL; l = &(*l)->next) {
+ /* if a script drops the packet, do not present it to following scripts */
+ if ( po->flags & PO_DROPPED )
+ break;
+ /* check whether the filter script is enabled */
+ if ((*l)->enabled)
+ filter_engine((*l)->env.chain, po);
+ }
+}
/*
* execute a function.

0 comments on commit 7b9adb9

Please sign in to comment.