X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=include%2Ftr_filter.h;h=46f502423cae1e02f849467e303a10cd169b7777;hb=6d1c81903470e97cd18eba15dacfea5fbd307dc3;hp=718dca0179e7042152a84cce98045d6245726216;hpb=b530c6da3eecfef355272d1e8995954626f10f8e;p=trust_router.git diff --git a/include/tr_filter.h b/include/tr_filter.h index 718dca0..46f5024 100644 --- a/include/tr_filter.h +++ b/include/tr_filter.h @@ -35,25 +35,35 @@ #ifndef TR_FILTER_H #define TR_FILTER_H +#include +#include + #include #include -#include #define TR_MAX_FILTERS 5 #define TR_MAX_FILTER_LINES 8 #define TR_MAX_FILTER_SPECS 8 /* Filter actions */ -#define TR_FILTER_ACTION_REJECT 0 -#define TR_FILTER_ACTION_ACCEPT 1 +typedef enum { + TR_FILTER_ACTION_REJECT=0, + TR_FILTER_ACTION_ACCEPT, + TR_FILTER_ACTION_UNKNOWN +} TR_FILTER_ACTION; /* Match codes */ #define TR_FILTER_MATCH 0 #define TR_FILTER_NO_MATCH 1 /* Filter types */ -#define TR_FILTER_TYPE_RP_PERMITTED 0 -/* Other types TBD */ +typedef enum { + TR_FILTER_TYPE_TID_INCOMING=0, + TR_FILTER_TYPE_UNKNOWN +} TR_FILTER_TYPE; +/* #define for backward compatibility, TODO: get rid of this -jlr */ +#define TR_FILTER_TYPE_RP_PERMITTED TR_FILTER_TYPE_TID_INCOMING + typedef struct tr_fspec { TR_NAME *field; @@ -61,18 +71,30 @@ typedef struct tr_fspec { } TR_FSPEC; typedef struct tr_fline { - int action; + TR_FILTER_ACTION action; TR_FSPEC *specs[TR_MAX_FILTER_SPECS]; TR_CONSTRAINT *realm_cons; TR_CONSTRAINT *domain_cons; } TR_FLINE; typedef struct tr_filter { - int type; + TR_FILTER_TYPE type; TR_FLINE *lines[TR_MAX_FILTER_LINES]; } TR_FILTER; -void tr_filter_free (TR_FILTER *filt); +TR_FILTER *tr_filter_new(TALLOC_CTX *mem_ctx); +void tr_filter_free(TR_FILTER *filt); +void tr_filter_set_type(TR_FILTER *filt, TR_FILTER_TYPE type); +TR_FILTER_TYPE tr_filter_get_type(TR_FILTER *filt); + +TR_FLINE *tr_fline_new(TALLOC_CTX *mem_ctx); +void tr_fline_free(TR_FLINE *fline); +TR_FSPEC *tr_fspec_new(TALLOC_CTX *mem_ctx); +void tr_fspec_free(TR_FSPEC *fspec); +void tr_fspec_set_match(TR_FSPEC *fspec, TR_NAME *match); +int tr_fspec_matches(TR_FSPEC *fspec, TR_NAME *name); + + /*In tr_constraint.c and exported, but not really a public symbol; needed by tr_filter.c and by tr_constraint.c*/ int TR_EXPORT tr_prefix_wildcard_match (const char *str, const char *wc_str); int tr_filter_process_rp_permitted (TR_NAME *rp_realm, TR_FILTER *rpp_filter, TR_CONSTRAINT_SET *in_constraints, TR_CONSTRAINT_SET **out_constraints, int *out_action);