summaryrefslogtreecommitdiff
path: root/crypto/external/bsd/openssh/dist/pfilter.c
blob: 84531301893b1861b593fa815ab97fc6574ddd95 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*	$NetBSD: pfilter.c,v 1.8 2020/06/15 01:57:29 christos Exp $	*/
#include "namespace.h"
#include "includes.h"
#include "ssh.h"
#include "packet.h"
#include "log.h"
#include "pfilter.h"
#include <blocklist.h>

#ifndef SMALL
static struct blocklist *blstate;
#endif

#include "includes.h"
__RCSID("$NetBSD: pfilter.c,v 1.8 2020/06/15 01:57:29 christos Exp $");

void
pfilter_init()
{
#ifndef SMALL
	blstate = blocklist_open();
#endif
}

extern struct ssh *the_active_state;

void
pfilter_notify(int a)
{
#ifndef SMALL
	int fd;
	if (the_active_state == NULL)
		return;
	if (blstate == NULL)
		pfilter_init();
	if (blstate == NULL)
		return;
	// XXX: 3?
 	fd = ssh_packet_connection_is_on_socket(the_active_state) ?
	    ssh_packet_get_connection_in(the_active_state) : 3;
	(void)blocklist_r(blstate, a, fd, "ssh");
	if (a == 0) {
		blocklist_close(blstate);
		blstate = NULL;
	}
#else
	__USE(a);
#endif
}