Module Name:    src
Committed By:   christos
Date:           Sun Jan 25 15:52:12 UTC 2015

Added Files:
        src/external/bsd/bind/dist/bin/named: pfilter.c pfilter.h

Log Message:
blacklist new files


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/external/bsd/bind/dist/bin/named/pfilter.c \
    src/external/bsd/bind/dist/bin/named/pfilter.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Added files:

Index: src/external/bsd/bind/dist/bin/named/pfilter.c
diff -u /dev/null src/external/bsd/bind/dist/bin/named/pfilter.c:1.1
--- /dev/null	Sun Jan 25 10:52:12 2015
+++ src/external/bsd/bind/dist/bin/named/pfilter.c	Sun Jan 25 10:52:12 2015
@@ -0,0 +1,53 @@
+#include <config.h>
+
+#include <isc/platform.h>
+#include <isc/util.h>
+#include <named/types.h>
+#include <named/client.h>
+
+#include <blacklist.h>
+
+#include "pfilter.h"
+
+static struct blacklist *blstate;
+
+void
+pfilter_open(void)
+{
+	if (blstate == NULL)
+		blstate = blacklist_open();
+}
+
+#define TCP_CLIENT(c)  (((c)->attributes & NS_CLIENTATTR_TCP) != 0)
+
+void
+pfilter_notify(isc_result_t res, ns_client_t *client, const char *msg)
+{
+	int rv;
+	isc_socket_t *socket;
+
+	pfilter_open();
+
+	if (TCP_CLIENT(client))
+		socket = client->tcpsocket;
+	else {
+		socket = client->udpsocket;
+		if (!client->peeraddr_valid) {
+			syslog(LOG_ERR, "no peer res=%d\n", res);
+			return;
+		}
+	}
+	if (socket == NULL) {
+		syslog(LOG_ERR, "null socket res=%d\n", res);
+		return;
+	}
+	if (blstate == NULL) {
+		syslog(LOG_ERR, "null blstate res=%d\n", res);
+		return;
+	}
+	rv = blacklist_sa_r(blstate, 
+	    res != ISC_R_SUCCESS, isc_socket_getfd(socket),
+	    &client->peeraddr.type.sa, client->peeraddr.length, msg);
+	if (rv || res != ISC_R_SUCCESS)
+		syslog(LOG_ERR, "blacklist rv=%d res=%d\n", rv, res);
+}
Index: src/external/bsd/bind/dist/bin/named/pfilter.h
diff -u /dev/null src/external/bsd/bind/dist/bin/named/pfilter.h:1.1
--- /dev/null	Sun Jan 25 10:52:12 2015
+++ src/external/bsd/bind/dist/bin/named/pfilter.h	Sun Jan 25 10:52:12 2015
@@ -0,0 +1,2 @@
+void pfilter_open(void);
+void pfilter_notify(isc_result_t, ns_client_t *, const char *);

Reply via email to