-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdump_yacc.y
92 lines (86 loc) · 1.91 KB
/
dump_yacc.y
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
%token IPADDR IP6ADDR EMAIL TIME AUTO TARPIT GARBAGE
%{
#include "config.h"
#ifdef HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
#ifdef __RCSID
__RCSID("$Id: dump_yacc.y,v 1.21 2009/04/19 00:55:32 manu Exp $");
#endif
#endif
#include <stdlib.h>
#include <string.h>
#include <sysexits.h>
#ifdef USE_DMALLOC
#include <dmalloc.h>
#endif
#include "conf.h"
#include "pending.h"
int dump_lex(void);
void dump_error(char *);
%}
%union {
struct sockaddr_in ipaddr;
#ifdef AF_INET6
struct sockaddr_in6 ip6addr;
#else
struct sockaddr_in ip6addr; /* XXX: for dummy */
#endif
char email[ADDRLEN + 1];
time_t time;
}
%type <ipaddr> IPADDR;
%type <ip6addr> IP6ADDR;
%type <email> EMAIL;
%type <time> TIME;
%%
lines : lines greyentry '\n'
| lines autoentry '\n'
| lines tarpitentry '\n'
| lines '\n'
| error '\n' { yyerrok; }
|
;
greyentry : IPADDR EMAIL EMAIL TIME {
pending_get(SA(&$1), sizeof(struct sockaddr_in), $2,
$3, $4, 0, T_PENDING);
}
| IP6ADDR EMAIL EMAIL TIME {
#ifdef AF_INET6
pending_get(SA(&$1), sizeof(struct sockaddr_in6), $2,
$3, $4, 0, T_PENDING);
#else
printf("IPv6 is not supported, ignore line %d\n",
dump_line);
#endif
}
;
autoentry : IPADDR EMAIL EMAIL TIME AUTO {
pending_get(SA(&$1), sizeof(struct sockaddr_in), $2,
$3, $4, 0, T_AUTOWHITE);
}
| IP6ADDR EMAIL EMAIL TIME AUTO {
#ifdef AF_INET6
pending_get(SA(&$1), sizeof(struct sockaddr_in6), $2,
$3, $4, 0, T_AUTOWHITE);
#else
printf("IPv6 is not supported, ignore line %d\n",
dump_line);
#endif
}
;
tarpitentry : IPADDR EMAIL EMAIL TIME TIME TARPIT {
pending_get(SA(&$1), sizeof(struct sockaddr_in), $2,
$3, $4, $5, T_TARPIT);
}
| IP6ADDR EMAIL EMAIL TIME TIME TARPIT {
#ifdef AF_INET6
pending_get(SA(&$1), sizeof(struct sockaddr_in6), $2,
$3, $4, $5, T_TARPIT);
#else
printf("IPv6 is not supported, ignore line %d\n",
dump_line);
#endif
}
;
%%
#include "dump_lex.c"