summaryrefslogtreecommitdiff
path: root/fw/src/rules.h
diff options
context:
space:
mode:
Diffstat (limited to 'fw/src/rules.h')
-rw-r--r--fw/src/rules.h34
1 files changed, 33 insertions, 1 deletions
diff --git a/fw/src/rules.h b/fw/src/rules.h
index 6aad0ae..f2c38d4 100644
--- a/fw/src/rules.h
+++ b/fw/src/rules.h
@@ -49,7 +49,39 @@ long fmtrules(char*, long); /* current set, back in ndb form */
long fmthits(char*, long); /* the same, with hit counts */
void dumprules(void);
void checklogging(void);
-char* matchrule(int verb, char *proto, uchar *ip, int anyip, int port, int lport, Rule**);
+/*
+ * One question for the rule list, and its answer, in the caller's
+ * frame.
+ *
+ * matchrule used to hand back a Rule* and a pointer into a static
+ * buffer, and callers read both after it had let go of the lock. A
+ * rule set installed in between freed the Rule under them, and two
+ * procs deciding at once overwrote each other's reason - in a program
+ * whose entire output is the reason. Nothing here outlives the Match,
+ * and the Match belongs to whoever asked.
+ *
+ * count says to charge the decision to the rule's tally. Re-checking
+ * live flows after a rule change is not traffic and must not be
+ * counted, or "how often has this rule decided something" answers a
+ * different question every time the rules are edited.
+ */
+typedef struct Match Match;
+struct Match
+{
+ int verb; /* in */
+ char *proto; /* nil: any */
+ uchar *ip; /* the peer; unread if anyip */
+ int anyip;
+ int port; /* peer port, -1: any */
+ int lport; /* local port, -1: any */
+ int count; /* charge this to the rule */
+
+ int nr; /* out: the rule that decided, 0 if none */
+ int log; /* it asked to be logged */
+ char err[128]; /* why not, if it said no */
+};
+
+int matchrule(Match*); /* 1 to permit, 0 to refuse */
int protoname2num(char*);
char* protonum2name(int);