summaryrefslogtreecommitdiff
path: root/usr.sbin/relayd/name2id.c
diff options
context:
space:
mode:
authorReyk Floeter <reyk@cvs.openbsd.org>2014-07-09 16:42:06 +0000
committerReyk Floeter <reyk@cvs.openbsd.org>2014-07-09 16:42:06 +0000
commit6581036fa87b031b42e6fb09a7be534f271b3558 (patch)
treed3a1e72d1d971ca9841c3915d96105eff75d8fc4 /usr.sbin/relayd/name2id.c
parent80cffbe9964236d1735bdb0e892108f50a57ae28 (diff)
Replace the protocol directives for HTTP with a new generic filtering
language. The grammar is inspired by pf and allows to write versatile last-matching filter rules in protocol sections starting with the "pass", "block" or "match" keywords. This work was started almost two years ago and replaces large parts of relayd(8)'s HTTP and filtering code. The initial version reimplements and extends HTTP filtering, but will be improved to support generic TCP and other protocols later. With some testing, feedback, and help from benno@ and andre@. OK benno@
Diffstat (limited to 'usr.sbin/relayd/name2id.c')
-rw-r--r--usr.sbin/relayd/name2id.c51
1 files changed, 37 insertions, 14 deletions
diff --git a/usr.sbin/relayd/name2id.c b/usr.sbin/relayd/name2id.c
index fb8f1054b0c..4009fc6488b 100644
--- a/usr.sbin/relayd/name2id.c
+++ b/usr.sbin/relayd/name2id.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: name2id.c,v 1.2 2007/12/07 17:17:00 reyk Exp $ */
+/* $OpenBSD: name2id.c,v 1.3 2014/07/09 16:42:05 reyk Exp $ */
/*
* Copyright (c) 2004, 2005 Henning Brauer <henning@openbsd.org>
@@ -16,16 +16,15 @@
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include <sys/param.h>
+#include <sys/types.h>
#include <sys/socket.h>
#include <sys/queue.h>
#include <net/if.h>
+#include <errno.h>
#include <stdlib.h>
-#include <stdio.h>
#include <string.h>
-#include <errno.h>
#include <event.h>
#include <openssl/ssl.h>
@@ -48,31 +47,55 @@ const char *_id2name(struct n2id_labels *, u_int16_t);
void _unref(struct n2id_labels *, u_int16_t);
void _ref(struct n2id_labels *, u_int16_t);
-/* for protocolnode labels */
-struct n2id_labels pn_labels = TAILQ_HEAD_INITIALIZER(pn_labels);
+struct n2id_labels relay_labels = TAILQ_HEAD_INITIALIZER(relay_labels);
+struct n2id_labels relay_tags = TAILQ_HEAD_INITIALIZER(relay_tags);
+
+u_int16_t
+tag_name2id(const char *name)
+{
+ return (_name2id(&relay_tags, name));
+}
+
+const char *
+tag_id2name(u_int16_t id)
+{
+ return (_id2name(&relay_tags, id));
+}
+
+void
+tag_unref(u_int16_t id)
+{
+ _unref(&relay_tags, id);
+}
+
+void
+tag_ref(u_int16_t id)
+{
+ _ref(&relay_tags, id);
+}
u_int16_t
-pn_name2id(const char *name)
+label_name2id(const char *name)
{
- return (_name2id(&pn_labels, name));
+ return (_name2id(&relay_labels, name));
}
const char *
-pn_id2name(u_int16_t id)
+label_id2name(u_int16_t id)
{
- return (_id2name(&pn_labels, id));
+ return (_id2name(&relay_labels, id));
}
void
-pn_unref(u_int16_t id)
+label_unref(u_int16_t id)
{
- _unref(&pn_labels, id);
+ _unref(&relay_labels, id);
}
void
-pn_ref(u_int16_t id)
+label_ref(u_int16_t id)
{
- _ref(&pn_labels, id);
+ _ref(&relay_labels, id);
}
u_int16_t