Don't send communities in triggered updates. Comms now flood!
[trust_router.git] / common / tr_filter.c
index eecc4ca..e1ab4f2 100644 (file)
@@ -59,7 +59,7 @@ int tr_filter_process_rp_permitted (TR_NAME *rp_realm, TR_FILTER *rpp_filter, TR
 
       if ((rpp_filter->lines[i]) && 
          (rpp_filter->lines[i]->specs[j]) && 
-         (tr_prefix_wildcard_match(rp_realm->buf, rpp_filter->lines[i]->specs[j]->match->buf))) {
+         (tr_fspec_matches(rpp_filter->lines[i]->specs[j], rp_realm))) {
        *out_action = rpp_filter->lines[i]->action;
        *out_constraints = in_constraints;
        if (rpp_filter->lines[i]->realm_cons)
@@ -82,9 +82,10 @@ void tr_fspec_free(TR_FSPEC *fspec)
   talloc_free(fspec);
 }
 
-int tr_fspec_destructor(void *obj)
+static int tr_fspec_destructor(void *obj)
 {
   TR_FSPEC *fspec=talloc_get_type_abort(obj, TR_FSPEC);
+
   if (fspec->field!=NULL)
     tr_free_name(fspec->field);
   if (fspec->match!=NULL)
@@ -104,6 +105,20 @@ TR_FSPEC *tr_fspec_new(TALLOC_CTX *mem_ctx)
   return fspec;
 }
 
+void tr_fspec_set_match(TR_FSPEC *fspec, TR_NAME *match)
+{
+  if (fspec->match!=NULL)
+    tr_free_name(fspec->match);
+  fspec->match=match;
+}
+
+/* returns 1 if the spec matches */
+int tr_fspec_matches(TR_FSPEC *fspec, TR_NAME *name)
+{
+  return ((fspec->match!=NULL) &&
+          (0!=tr_prefix_wildcard_match(name->buf, fspec->match->buf)));
+}
+
 void tr_fline_free(TR_FLINE *fline)
 {
   talloc_free(fline);