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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
|
Index: bgpd/printconf.c
===================================================================
RCS file: /home/cvs/private/hrs/openbgpd/bgpd/printconf.c,v
retrieving revision 1.1.1.7
retrieving revision 1.6
diff -u -p -r1.1.1.7 -r1.6
--- bgpd/printconf.c 14 Feb 2010 20:19:57 -0000 1.1.1.7
+++ bgpd/printconf.c 4 Feb 2010 16:22:23 -0000 1.6
@@ -1,4 +1,4 @@
-/* $OpenBSD: printconf.c,v 1.70 2009/06/06 01:10:29 claudio Exp $ */
+/* $OpenBSD: printconf.c,v 1.77 2009/12/17 09:32:59 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -19,6 +19,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#if defined(__FreeBSD__) /* limits.h */
+#include <limits.h>
+#endif
#include "bgpd.h"
#include "mrt.h"
@@ -27,6 +30,8 @@
void print_op(enum comp_ops);
void print_community(int, int);
+void print_extcommunity(struct filter_extcommunity *);
+void print_origin(u_int8_t);
void print_set(struct filter_set_head *);
void print_mainconf(struct bgpd_config *);
void print_network(struct network_config *);
@@ -34,7 +39,7 @@ void print_peer(struct peer_config *,
const char *);
const char *print_auth_alg(u_int8_t);
const char *print_enc_alg(u_int8_t);
-const char *print_safi(u_int8_t);
+void print_announce(struct peer_config *, const char *);
void print_rule(struct peer *, struct filter_rule *);
const char * mrt_type(enum mrt_type);
void print_mrt(u_int32_t, u_int32_t, const char *, const char *);
@@ -94,6 +99,45 @@ print_community(int as, int type)
}
void
+print_extcommunity(struct filter_extcommunity *c)
+{
+ switch (c->type & EXT_COMMUNITY_VALUE) {
+ case EXT_COMMUNITY_TWO_AS:
+ printf("%s %i:%i", log_ext_subtype(c->subtype),
+ c->data.ext_as.as, c->data.ext_as.val);
+ break;
+ case EXT_COMMUNITY_IPV4:
+ printf("%s %s:%i", log_ext_subtype(c->subtype),
+ inet_ntoa(c->data.ext_ip.addr), c->data.ext_ip.val);
+ break;
+ case EXT_COMMUNITY_FOUR_AS:
+ printf("%s %s:%i", log_ext_subtype(c->subtype),
+ log_as(c->data.ext_as4.as4), c->data.ext_as.val);
+ break;
+ case EXT_COMMUNITY_OPAQUE:
+ printf("%s 0x%llx", log_ext_subtype(c->subtype),
+ c->data.ext_opaq);
+ break;
+ default:
+ printf("0x%x 0x%llx", c->type, c->data.ext_opaq);
+ break;
+ }
+}
+
+void
+print_origin(u_int8_t o)
+{
+ if (o == ORIGIN_IGP)
+ printf("igp ");
+ else if (o == ORIGIN_EGP)
+ printf("egp ");
+ else if (o == ORIGIN_INCOMPLETE)
+ printf("incomplete ");
+ else
+ printf("%u ", o);
+}
+
+void
print_set(struct filter_set_head *set)
{
struct filter_set *s;
@@ -161,11 +205,25 @@ print_set(struct filter_set_head *set)
case ACTION_RTLABEL:
printf("rtlabel %s ", s->action.rtlabel);
break;
+ case ACTION_SET_ORIGIN:
+ printf("origin ");
+ print_origin(s->action.origin);
+ break;
case ACTION_RTLABEL_ID:
case ACTION_PFTABLE_ID:
/* not possible */
printf("king bula saiz: config broken");
break;
+ case ACTION_SET_EXT_COMMUNITY:
+ printf("ext-community ");
+ print_extcommunity(&s->action.ext_community);
+ printf(" ");
+ break;
+ case ACTION_DEL_EXT_COMMUNITY:
+ printf("ext-community delete ");
+ print_extcommunity(&s->action.ext_community);
+ printf(" ");
+ break;
}
}
printf("}");
@@ -263,8 +321,8 @@ print_peer(struct peer_config *p, struct
char *method;
struct in_addr ina;
- if ((p->remote_addr.af == AF_INET && p->remote_masklen != 32) ||
- (p->remote_addr.af == AF_INET6 && p->remote_masklen != 128))
+ if ((p->remote_addr.aid == AID_INET && p->remote_masklen != 32) ||
+ (p->remote_addr.aid == AID_INET6 && p->remote_masklen != 128))
printf("%sneighbor %s/%u {\n", c, log_addr(&p->remote_addr),
p->remote_masklen);
else
@@ -281,7 +339,7 @@ print_peer(struct peer_config *p, struct
printf("%s\tmultihop %u\n", c, p->distance);
if (p->passive)
printf("%s\tpassive\n", c);
- if (p->local_addr.af)
+ if (p->local_addr.aid)
printf("%s\tlocal-address %s\n", c, log_addr(&p->local_addr));
if (p->max_prefix) {
printf("%s\tmax-prefix %u", c, p->max_prefix);
@@ -295,6 +353,12 @@ print_peer(struct peer_config *p, struct
printf("%s\tholdtime min %u\n", c, p->min_holdtime);
if (p->announce_capa == 0)
printf("%s\tannounce capabilities no\n", c);
+ if (p->capabilities.refresh == 0)
+ printf("%s\tannounce refresh no\n", c);
+ if (p->capabilities.restart == 1)
+ printf("%s\tannounce restart yes\n", c);
+ if (p->capabilities.as4byte == 0)
+ printf("%s\tannounce as4byte no\n", c);
if (p->announce_type == ANNOUNCE_SELF)
printf("%s\tannounce self\n", c);
else if (p->announce_type == ANNOUNCE_NONE)
@@ -324,6 +388,10 @@ print_peer(struct peer_config *p, struct
printf("%s\tdepend on \"%s\"\n", c, p->if_depend);
if (p->flags & PEERFLAG_TRANS_AS)
printf("%s\ttransparent-as yes\n", c);
+#if defined(IPV6_LINKLOCAL_PEER)
+ if (p->lliface[0])
+ printf("%s\tinterface %s\n", c, p->lliface);
+#endif
if (p->auth.method == AUTH_MD5SIG)
printf("%s\ttcp md5sig\n", c);
@@ -354,8 +422,7 @@ print_peer(struct peer_config *p, struct
if (p->ttlsec)
printf("%s\tttl-security yes\n", c);
- printf("%s\tannounce IPv4 %s\n", c, print_safi(p->capabilities.mp_v4));
- printf("%s\tannounce IPv6 %s\n", c, print_safi(p->capabilities.mp_v6));
+ print_announce(p, c);
if (p->softreconfig_in == 1)
printf("%s\tsoftreconfig in yes\n", c);
@@ -399,17 +466,14 @@ print_enc_alg(u_int8_t alg)
}
}
-const char *
-print_safi(u_int8_t safi)
+void
+print_announce(struct peer_config *p, const char *c)
{
- switch (safi) {
- case SAFI_NONE:
- return ("none");
- case SAFI_UNICAST:
- return ("unicast");
- default:
- return ("?");
- }
+ u_int8_t aid;
+
+ for (aid = 0; aid < AID_MAX; aid++)
+ if (p->capabilities.mp[aid])
+ printf("%s\tannounce %s\n", c, aid2str(aid));
}
void
@@ -455,14 +519,14 @@ print_rule(struct peer *peer_l, struct f
} else
printf("any ");
- if (r->match.prefix.addr.af)
+ if (r->match.prefix.addr.aid)
printf("prefix %s/%u ", log_addr(&r->match.prefix.addr),
r->match.prefix.len);
- if (r->match.prefix.addr.af == 0 && r->match.prefixlen.af) {
- if (r->match.prefixlen.af == AF_INET)
+ if (r->match.prefix.addr.aid == 0 && r->match.prefixlen.aid) {
+ if (r->match.prefixlen.aid == AID_INET)
printf("inet ");
- if (r->match.prefixlen.af == AF_INET6)
+ if (r->match.prefixlen.aid == AID_INET6)
printf("inet6 ");
}
|