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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
/* $OpenBSD: irrfilter.h,v 1.7 2007/03/06 16:45:34 henning Exp $ */
/*
* Copyright (c) 2007 Henning Brauer <henning@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER IN
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <sys/queue.h>
#include <sys/tree.h>
#include <netinet/in.h>
#define F_IMPORTONLY 0x01 /* skip export: items */
int irrflags;
int irrverbose;
enum pdir {
PDIR_NONE,
IMPORT,
EXPORT
};
struct policy_item {
TAILQ_ENTRY(policy_item) entry;
char *peer_addr;
char *action;
char *filter;
enum pdir dir;
u_int16_t peer_as;
};
TAILQ_HEAD(policy_head, policy_item);
struct router {
TAILQ_ENTRY(router) entry;
char *address;
struct policy_head policy_h;
};
TAILQ_HEAD(router_head, router) router_head;
/* keep qtype and qtype_objs in whois.c in sync! */
enum qtype {
QTYPE_NONE,
QTYPE_OWNAS,
QTYPE_ASSET,
QTYPE_ROUTE
};
struct as_set {
RB_ENTRY(as_set) entry;
char *name;
char **members; /* direct members */
char **as_set; /* members as-set */
char **as; /* members aut-num */
u_int n_members;
u_int n_as_set;
u_int n_as;
};
struct irr_prefix {
union {
struct in_addr in;
} addr;
sa_family_t af;
u_int8_t len;
u_int8_t maxlen;
};
struct prefix_set {
RB_ENTRY(prefix_set) entry;
char *as;
struct irr_prefix **prefix;
u_int prefixcnt;
};
/* eat trailing and leading whitespace */
#define ISWS(x) (x == ' ' || x == '\t')
#define EATWS(s) \
do { \
char *ps; \
while (ISWS(*s)) \
s++; \
ps = s + strlen(s) - 1; \
while (ps && ps >= s && ISWS(*ps)) \
*ps-- = '\0'; \
} while (0);
__dead void irr_main(u_int32_t, int, char *);
int whois(const char *, enum qtype);
int parse_response(FILE *, enum qtype);
int write_filters(char *);
struct as_set *asset_expand(char *);
int asset_addmember(char *);
struct prefix_set *prefixset_get(char *);
int prefixset_addmember(char *);
|