mapper.c revision 1.11 1 1.11 itojun /* $NetBSD: mapper.c,v 1.11 2002/08/09 02:17:26 itojun Exp $ */
2 1.2 thorpej
3 1.1 mycroft /* Mapper for connections between MRouteD multicast routers.
4 1.1 mycroft * Written by Pavel Curtis <Pavel (at) PARC.Xerox.Com>
5 1.1 mycroft */
6 1.1 mycroft
7 1.1 mycroft /*
8 1.7 itojun * Copyright (c) 1992, 2001 Xerox Corporation. All rights reserved.
9 1.7 itojun *
10 1.7 itojun * Redistribution and use in source and binary forms, with or without modification,
11 1.7 itojun * are permitted provided that the following conditions are met:
12 1.7 itojun *
13 1.7 itojun * Redistributions of source code must retain the above copyright notice,
14 1.7 itojun * this list of conditions and the following disclaimer.
15 1.7 itojun *
16 1.7 itojun * Redistributions in binary form must reproduce the above copyright notice,
17 1.7 itojun * this list of conditions and the following disclaimer in the documentation
18 1.7 itojun * and/or other materials provided with the distribution.
19 1.7 itojun *
20 1.7 itojun * Neither name of the Xerox, PARC, nor the names of its contributors may be used
21 1.7 itojun * to endorse or promote products derived from this software
22 1.7 itojun * without specific prior written permission.
23 1.7 itojun *
24 1.7 itojun * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
25 1.7 itojun * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
26 1.7 itojun * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
27 1.7 itojun * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE XEROX CORPORATION OR CONTRIBUTORS
28 1.7 itojun * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 1.7 itojun * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 1.7 itojun * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
31 1.7 itojun * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
32 1.7 itojun * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
33 1.7 itojun * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
34 1.7 itojun * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 1.1 mycroft */
36 1.1 mycroft
37 1.1 mycroft #include <string.h>
38 1.1 mycroft #include <netdb.h>
39 1.1 mycroft #include <sys/time.h>
40 1.1 mycroft #include "defs.h"
41 1.3 mycroft #include <arpa/inet.h>
42 1.3 mycroft #include <stdarg.h>
43 1.1 mycroft
44 1.1 mycroft #define DEFAULT_TIMEOUT 2 /* How long to wait before retrying requests */
45 1.1 mycroft #define DEFAULT_RETRIES 1 /* How many times to ask each router */
46 1.1 mycroft
47 1.1 mycroft
48 1.1 mycroft /* All IP addresses are stored in the data structure in NET order. */
49 1.1 mycroft
50 1.1 mycroft typedef struct neighbor {
51 1.1 mycroft struct neighbor *next;
52 1.1 mycroft u_int32_t addr; /* IP address in NET order */
53 1.1 mycroft u_char metric; /* TTL cost of forwarding */
54 1.1 mycroft u_char threshold; /* TTL threshold to forward */
55 1.1 mycroft u_short flags; /* flags on connection */
56 1.1 mycroft #define NF_PRESENT 0x8000 /* True if flags are meaningful */
57 1.1 mycroft } Neighbor;
58 1.1 mycroft
59 1.1 mycroft typedef struct interface {
60 1.1 mycroft struct interface *next;
61 1.1 mycroft u_int32_t addr; /* IP address of the interface in NET order */
62 1.1 mycroft Neighbor *neighbors; /* List of neighbors' IP addresses */
63 1.1 mycroft } Interface;
64 1.1 mycroft
65 1.1 mycroft typedef struct node {
66 1.1 mycroft u_int32_t addr; /* IP address of this entry in NET order */
67 1.1 mycroft u_int32_t version; /* which mrouted version is running */
68 1.1 mycroft int tries; /* How many requests sent? -1 for aliases */
69 1.1 mycroft union {
70 1.1 mycroft struct node *alias; /* If alias, to what? */
71 1.1 mycroft struct interface *interfaces; /* Else, neighbor data */
72 1.1 mycroft } u;
73 1.1 mycroft struct node *left, *right;
74 1.1 mycroft } Node;
75 1.1 mycroft
76 1.1 mycroft
77 1.1 mycroft Node *routers = 0;
78 1.1 mycroft u_int32_t our_addr, target_addr = 0; /* in NET order */
79 1.1 mycroft int debug = 0;
80 1.1 mycroft int retries = DEFAULT_RETRIES;
81 1.1 mycroft int timeout = DEFAULT_TIMEOUT;
82 1.1 mycroft int show_names = TRUE;
83 1.1 mycroft vifi_t numvifs; /* to keep loader happy */
84 1.1 mycroft /* (see COPY_TABLES macro called in kern.c) */
85 1.1 mycroft
86 1.10 wiz Node * find_node(u_int32_t addr, Node **ptr);
87 1.10 wiz Interface * find_interface(u_int32_t addr, Node *node);
88 1.10 wiz Neighbor * find_neighbor(u_int32_t addr, Node *node);
89 1.10 wiz int main(int argc, char *argv[]);
90 1.10 wiz void ask(u_int32_t dst);
91 1.10 wiz void ask2(u_int32_t dst);
92 1.10 wiz int retry_requests(Node *node);
93 1.10 wiz char * inet_name(u_int32_t addr);
94 1.10 wiz void print_map(Node *node);
95 1.10 wiz char * graph_name(u_int32_t addr, char *buf);
96 1.10 wiz void graph_edges(Node *node);
97 1.10 wiz void elide_aliases(Node *node);
98 1.10 wiz void graph_map(void);
99 1.10 wiz int get_number(int *var, int deflt, char ***pargv,
100 1.10 wiz int *pargc);
101 1.10 wiz u_int32_t host_addr(char *name);
102 1.3 mycroft
103 1.5 is void log(int severity, int syserr, const char *format, ...)
104 1.5 is __attribute__((__format__(__printf__, 3, 4)));
105 1.1 mycroft
106 1.10 wiz Node *find_node(u_int32_t addr, Node **ptr)
107 1.1 mycroft {
108 1.1 mycroft Node *n = *ptr;
109 1.1 mycroft
110 1.1 mycroft if (!n) {
111 1.1 mycroft *ptr = n = (Node *) malloc(sizeof(Node));
112 1.1 mycroft n->addr = addr;
113 1.1 mycroft n->version = 0;
114 1.1 mycroft n->tries = 0;
115 1.1 mycroft n->u.interfaces = 0;
116 1.1 mycroft n->left = n->right = 0;
117 1.1 mycroft return n;
118 1.1 mycroft } else if (addr == n->addr)
119 1.1 mycroft return n;
120 1.1 mycroft else if (addr < n->addr)
121 1.1 mycroft return find_node(addr, &(n->left));
122 1.1 mycroft else
123 1.1 mycroft return find_node(addr, &(n->right));
124 1.1 mycroft }
125 1.1 mycroft
126 1.1 mycroft
127 1.10 wiz Interface *find_interface(u_int32_t addr, Node *node)
128 1.1 mycroft {
129 1.1 mycroft Interface *ifc;
130 1.1 mycroft
131 1.1 mycroft for (ifc = node->u.interfaces; ifc; ifc = ifc->next)
132 1.1 mycroft if (ifc->addr == addr)
133 1.1 mycroft return ifc;
134 1.1 mycroft
135 1.1 mycroft ifc = (Interface *) malloc(sizeof(Interface));
136 1.1 mycroft ifc->addr = addr;
137 1.1 mycroft ifc->next = node->u.interfaces;
138 1.1 mycroft node->u.interfaces = ifc;
139 1.1 mycroft ifc->neighbors = 0;
140 1.1 mycroft
141 1.1 mycroft return ifc;
142 1.1 mycroft }
143 1.1 mycroft
144 1.1 mycroft
145 1.10 wiz Neighbor *find_neighbor(u_int32_t addr, Node *node)
146 1.1 mycroft {
147 1.1 mycroft Interface *ifc;
148 1.1 mycroft
149 1.1 mycroft for (ifc = node->u.interfaces; ifc; ifc = ifc->next) {
150 1.1 mycroft Neighbor *nb;
151 1.1 mycroft
152 1.1 mycroft for (nb = ifc->neighbors; nb; nb = nb->next)
153 1.1 mycroft if (nb->addr == addr)
154 1.1 mycroft return nb;
155 1.1 mycroft }
156 1.1 mycroft
157 1.1 mycroft return 0;
158 1.1 mycroft }
159 1.1 mycroft
160 1.1 mycroft
161 1.1 mycroft /*
162 1.1 mycroft * Log errors and other messages to stderr, according to the severity of the
163 1.1 mycroft * message and the current debug level. For errors of severity LOG_ERR or
164 1.1 mycroft * worse, terminate the program.
165 1.1 mycroft */
166 1.3 mycroft void
167 1.5 is log(int severity, int syserr, const char *format, ...)
168 1.3 mycroft {
169 1.8 wiz va_list ap;
170 1.8 wiz char fmt[100];
171 1.1 mycroft
172 1.1 mycroft switch (debug) {
173 1.1 mycroft case 0: if (severity > LOG_WARNING) return;
174 1.1 mycroft case 1: if (severity > LOG_NOTICE ) return;
175 1.1 mycroft case 2: if (severity > LOG_INFO ) return;
176 1.1 mycroft default:
177 1.1 mycroft fmt[0] = '\0';
178 1.1 mycroft if (severity == LOG_WARNING)
179 1.1 mycroft strcat(fmt, "warning - ");
180 1.1 mycroft strncat(fmt, format, 80);
181 1.5 is format = fmt;
182 1.8 wiz va_start(ap, format);
183 1.5 is vfprintf(stderr, format, ap);
184 1.8 wiz va_end(ap);
185 1.1 mycroft if (syserr == 0)
186 1.1 mycroft fprintf(stderr, "\n");
187 1.1 mycroft else
188 1.4 kleink fprintf(stderr, ": %s\n", strerror(syserr));
189 1.1 mycroft }
190 1.1 mycroft
191 1.1 mycroft if (severity <= LOG_ERR)
192 1.6 wiz exit(1);
193 1.1 mycroft }
194 1.1 mycroft
195 1.1 mycroft
196 1.1 mycroft /*
197 1.1 mycroft * Send a neighbors-list request.
198 1.1 mycroft */
199 1.10 wiz void ask(u_int32_t dst)
200 1.1 mycroft {
201 1.1 mycroft send_igmp(our_addr, dst, IGMP_DVMRP, DVMRP_ASK_NEIGHBORS,
202 1.1 mycroft htonl(MROUTED_LEVEL), 0);
203 1.1 mycroft }
204 1.1 mycroft
205 1.10 wiz void ask2(u_int32_t dst)
206 1.1 mycroft {
207 1.1 mycroft send_igmp(our_addr, dst, IGMP_DVMRP, DVMRP_ASK_NEIGHBORS2,
208 1.1 mycroft htonl(MROUTED_LEVEL), 0);
209 1.1 mycroft }
210 1.1 mycroft
211 1.1 mycroft
212 1.1 mycroft /*
213 1.1 mycroft * Process an incoming group membership report.
214 1.1 mycroft */
215 1.10 wiz void accept_group_report(u_int32_t src, u_int32_t dst, u_int32_t group, int r_type)
216 1.1 mycroft {
217 1.1 mycroft log(LOG_INFO, 0, "ignoring IGMP group membership report from %s to %s",
218 1.1 mycroft inet_fmt(src, s1), inet_fmt(dst, s2));
219 1.1 mycroft }
220 1.1 mycroft
221 1.1 mycroft
222 1.1 mycroft /*
223 1.1 mycroft * Process an incoming neighbor probe message.
224 1.1 mycroft */
225 1.10 wiz void accept_probe(u_int32_t src, u_int32_t dst, char *p, int datalen,
226 1.10 wiz u_int32_t level)
227 1.1 mycroft {
228 1.1 mycroft log(LOG_INFO, 0, "ignoring DVMRP probe from %s to %s",
229 1.1 mycroft inet_fmt(src, s1), inet_fmt(dst, s2));
230 1.1 mycroft }
231 1.1 mycroft
232 1.1 mycroft
233 1.1 mycroft /*
234 1.1 mycroft * Process an incoming route report message.
235 1.1 mycroft */
236 1.10 wiz void accept_report(u_int32_t src, u_int32_t dst, char *p, int datalen,
237 1.10 wiz u_int32_t level)
238 1.1 mycroft {
239 1.1 mycroft log(LOG_INFO, 0, "ignoring DVMRP routing report from %s to %s",
240 1.1 mycroft inet_fmt(src, s1), inet_fmt(dst, s2));
241 1.1 mycroft }
242 1.1 mycroft
243 1.1 mycroft
244 1.1 mycroft /*
245 1.1 mycroft * Process an incoming neighbor-list request message.
246 1.1 mycroft */
247 1.10 wiz void accept_neighbor_request(u_int32_t src, u_int32_t dst)
248 1.1 mycroft {
249 1.1 mycroft if (src != our_addr)
250 1.1 mycroft log(LOG_INFO, 0,
251 1.1 mycroft "ignoring spurious DVMRP neighbor request from %s to %s",
252 1.1 mycroft inet_fmt(src, s1), inet_fmt(dst, s2));
253 1.1 mycroft }
254 1.1 mycroft
255 1.10 wiz void accept_neighbor_request2(u_int32_t src, u_int32_t dst)
256 1.1 mycroft {
257 1.1 mycroft if (src != our_addr)
258 1.1 mycroft log(LOG_INFO, 0,
259 1.1 mycroft "ignoring spurious DVMRP neighbor request2 from %s to %s",
260 1.1 mycroft inet_fmt(src, s1), inet_fmt(dst, s2));
261 1.1 mycroft }
262 1.1 mycroft
263 1.1 mycroft
264 1.1 mycroft /*
265 1.1 mycroft * Process an incoming neighbor-list message.
266 1.1 mycroft */
267 1.10 wiz void accept_neighbors(u_int32_t src, u_int32_t dst, u_char *p, int datalen,
268 1.10 wiz u_int32_t level)
269 1.1 mycroft {
270 1.1 mycroft Node *node = find_node(src, &routers);
271 1.1 mycroft
272 1.1 mycroft if (node->tries == 0) /* Never heard of 'em; must have hit them at */
273 1.1 mycroft node->tries = 1; /* least once, though...*/
274 1.1 mycroft else if (node->tries == -1) /* follow alias link */
275 1.1 mycroft node = node->u.alias;
276 1.1 mycroft
277 1.1 mycroft #define GET_ADDR(a) (a = ((u_int32_t)*p++ << 24), a += ((u_int32_t)*p++ << 16),\
278 1.1 mycroft a += ((u_int32_t)*p++ << 8), a += *p++)
279 1.1 mycroft
280 1.1 mycroft /* if node is running a recent mrouted, ask for additional info */
281 1.1 mycroft if (level != 0) {
282 1.3 mycroft node->version = level;
283 1.3 mycroft node->tries = 1;
284 1.1 mycroft ask2(src);
285 1.1 mycroft return;
286 1.1 mycroft }
287 1.1 mycroft
288 1.1 mycroft if (debug > 3) {
289 1.1 mycroft int i;
290 1.1 mycroft
291 1.1 mycroft fprintf(stderr, " datalen = %d\n", datalen);
292 1.1 mycroft for (i = 0; i < datalen; i++) {
293 1.1 mycroft if ((i & 0xF) == 0)
294 1.1 mycroft fprintf(stderr, " ");
295 1.1 mycroft fprintf(stderr, " %02x", p[i]);
296 1.1 mycroft if ((i & 0xF) == 0xF)
297 1.1 mycroft fprintf(stderr, "\n");
298 1.1 mycroft }
299 1.1 mycroft if ((datalen & 0xF) != 0xF)
300 1.1 mycroft fprintf(stderr, "\n");
301 1.1 mycroft }
302 1.1 mycroft
303 1.1 mycroft while (datalen > 0) { /* loop through interfaces */
304 1.1 mycroft u_int32_t ifc_addr;
305 1.1 mycroft u_char metric, threshold, ncount;
306 1.1 mycroft Node *ifc_node;
307 1.1 mycroft Interface *ifc;
308 1.1 mycroft Neighbor *old_neighbors;
309 1.1 mycroft
310 1.1 mycroft if (datalen < 4 + 3) {
311 1.1 mycroft log(LOG_WARNING, 0, "received truncated interface record from %s",
312 1.1 mycroft inet_fmt(src, s1));
313 1.1 mycroft return;
314 1.1 mycroft }
315 1.1 mycroft
316 1.1 mycroft GET_ADDR(ifc_addr);
317 1.1 mycroft ifc_addr = htonl(ifc_addr);
318 1.1 mycroft metric = *p++;
319 1.1 mycroft threshold = *p++;
320 1.1 mycroft ncount = *p++;
321 1.1 mycroft datalen -= 4 + 3;
322 1.1 mycroft
323 1.1 mycroft /* Fix up any alias information */
324 1.1 mycroft ifc_node = find_node(ifc_addr, &routers);
325 1.1 mycroft if (ifc_node->tries == 0) { /* new node */
326 1.1 mycroft ifc_node->tries = -1;
327 1.1 mycroft ifc_node->u.alias = node;
328 1.1 mycroft } else if (ifc_node != node
329 1.1 mycroft && (ifc_node->tries > 0 || ifc_node->u.alias != node)) {
330 1.1 mycroft /* must merge two hosts' nodes */
331 1.1 mycroft Interface *ifc_i, *next_ifc_i;
332 1.1 mycroft
333 1.1 mycroft if (ifc_node->tries == -1) {
334 1.1 mycroft Node *tmp = ifc_node->u.alias;
335 1.1 mycroft
336 1.1 mycroft ifc_node->u.alias = node;
337 1.1 mycroft ifc_node = tmp;
338 1.1 mycroft }
339 1.1 mycroft
340 1.1 mycroft /* Merge ifc_node (foo_i) into node (foo_n) */
341 1.1 mycroft
342 1.1 mycroft if (ifc_node->tries > node->tries)
343 1.1 mycroft node->tries = ifc_node->tries;
344 1.1 mycroft
345 1.1 mycroft for (ifc_i = ifc_node->u.interfaces; ifc_i; ifc_i = next_ifc_i) {
346 1.1 mycroft Neighbor *nb_i, *next_nb_i, *nb_n;
347 1.1 mycroft Interface *ifc_n = find_interface(ifc_i->addr, node);
348 1.1 mycroft
349 1.1 mycroft old_neighbors = ifc_n->neighbors;
350 1.1 mycroft for (nb_i = ifc_i->neighbors; nb_i; nb_i = next_nb_i) {
351 1.1 mycroft next_nb_i = nb_i->next;
352 1.1 mycroft for (nb_n = old_neighbors; nb_n; nb_n = nb_n->next)
353 1.1 mycroft if (nb_i->addr == nb_n->addr) {
354 1.1 mycroft if (nb_i->metric != nb_n->metric
355 1.3 mycroft || nb_i->threshold != nb_n->threshold)
356 1.1 mycroft log(LOG_WARNING, 0,
357 1.1 mycroft "inconsistent %s for neighbor %s of %s",
358 1.1 mycroft "metric/threshold",
359 1.1 mycroft inet_fmt(nb_i->addr, s1),
360 1.1 mycroft inet_fmt(node->addr, s2));
361 1.1 mycroft free(nb_i);
362 1.1 mycroft break;
363 1.1 mycroft }
364 1.1 mycroft if (!nb_n) { /* no match for this neighbor yet */
365 1.1 mycroft nb_i->next = ifc_n->neighbors;
366 1.1 mycroft ifc_n->neighbors = nb_i;
367 1.1 mycroft }
368 1.1 mycroft }
369 1.1 mycroft
370 1.1 mycroft next_ifc_i = ifc_i->next;
371 1.1 mycroft free(ifc_i);
372 1.1 mycroft }
373 1.1 mycroft
374 1.1 mycroft ifc_node->tries = -1;
375 1.1 mycroft ifc_node->u.alias = node;
376 1.1 mycroft }
377 1.1 mycroft
378 1.1 mycroft ifc = find_interface(ifc_addr, node);
379 1.1 mycroft old_neighbors = ifc->neighbors;
380 1.1 mycroft
381 1.1 mycroft /* Add the neighbors for this interface */
382 1.1 mycroft while (ncount--) {
383 1.1 mycroft u_int32_t neighbor;
384 1.1 mycroft Neighbor *nb;
385 1.1 mycroft Node *n_node;
386 1.1 mycroft
387 1.1 mycroft if (datalen < 4) {
388 1.1 mycroft log(LOG_WARNING, 0, "received truncated neighbor list from %s",
389 1.1 mycroft inet_fmt(src, s1));
390 1.1 mycroft return;
391 1.1 mycroft }
392 1.1 mycroft
393 1.1 mycroft GET_ADDR(neighbor);
394 1.1 mycroft neighbor = htonl(neighbor);
395 1.1 mycroft datalen -= 4;
396 1.1 mycroft
397 1.1 mycroft for (nb = old_neighbors; nb; nb = nb->next)
398 1.1 mycroft if (nb->addr == neighbor) {
399 1.1 mycroft if (metric != nb->metric || threshold != nb->threshold)
400 1.1 mycroft log(LOG_WARNING, 0,
401 1.1 mycroft "inconsistent %s for neighbor %s of %s",
402 1.1 mycroft "metric/threshold",
403 1.1 mycroft inet_fmt(nb->addr, s1), inet_fmt(node->addr, s2));
404 1.1 mycroft goto next_neighbor;
405 1.1 mycroft }
406 1.1 mycroft
407 1.1 mycroft nb = (Neighbor *) malloc(sizeof(Neighbor));
408 1.1 mycroft nb->next = ifc->neighbors;
409 1.1 mycroft ifc->neighbors = nb;
410 1.1 mycroft nb->addr = neighbor;
411 1.1 mycroft nb->metric = metric;
412 1.1 mycroft nb->threshold = threshold;
413 1.1 mycroft nb->flags = 0;
414 1.1 mycroft
415 1.1 mycroft n_node = find_node(neighbor, &routers);
416 1.1 mycroft if (n_node->tries == 0 && !target_addr) { /* it's a new router */
417 1.1 mycroft ask(neighbor);
418 1.1 mycroft n_node->tries = 1;
419 1.1 mycroft }
420 1.1 mycroft
421 1.1 mycroft next_neighbor: ;
422 1.1 mycroft }
423 1.1 mycroft }
424 1.1 mycroft }
425 1.1 mycroft
426 1.10 wiz void accept_neighbors2(u_int32_t src, u_int32_t dst, u_char *p, int datalen,
427 1.10 wiz u_int32_t level)
428 1.1 mycroft {
429 1.1 mycroft Node *node = find_node(src, &routers);
430 1.3 mycroft u_int broken_cisco = ((level & 0xffff) == 0x020a); /* 10.2 */
431 1.3 mycroft /* well, only possibly_broken_cisco, but that's too long to type. */
432 1.1 mycroft
433 1.1 mycroft if (node->tries == 0) /* Never heard of 'em; must have hit them at */
434 1.1 mycroft node->tries = 1; /* least once, though...*/
435 1.1 mycroft else if (node->tries == -1) /* follow alias link */
436 1.1 mycroft node = node->u.alias;
437 1.1 mycroft
438 1.1 mycroft while (datalen > 0) { /* loop through interfaces */
439 1.1 mycroft u_int32_t ifc_addr;
440 1.1 mycroft u_char metric, threshold, ncount, flags;
441 1.1 mycroft Node *ifc_node;
442 1.1 mycroft Interface *ifc;
443 1.1 mycroft Neighbor *old_neighbors;
444 1.1 mycroft
445 1.1 mycroft if (datalen < 4 + 4) {
446 1.1 mycroft log(LOG_WARNING, 0, "received truncated interface record from %s",
447 1.1 mycroft inet_fmt(src, s1));
448 1.1 mycroft return;
449 1.1 mycroft }
450 1.1 mycroft
451 1.1 mycroft ifc_addr = *(u_int32_t*)p;
452 1.1 mycroft p += 4;
453 1.1 mycroft metric = *p++;
454 1.1 mycroft threshold = *p++;
455 1.1 mycroft flags = *p++;
456 1.1 mycroft ncount = *p++;
457 1.1 mycroft datalen -= 4 + 4;
458 1.1 mycroft
459 1.3 mycroft if (broken_cisco && ncount == 0) /* dumb Ciscos */
460 1.3 mycroft ncount = 1;
461 1.3 mycroft if (broken_cisco && ncount > 15) /* dumb Ciscos */
462 1.3 mycroft ncount = ncount & 0xf;
463 1.3 mycroft
464 1.1 mycroft /* Fix up any alias information */
465 1.1 mycroft ifc_node = find_node(ifc_addr, &routers);
466 1.1 mycroft if (ifc_node->tries == 0) { /* new node */
467 1.1 mycroft ifc_node->tries = -1;
468 1.1 mycroft ifc_node->u.alias = node;
469 1.1 mycroft } else if (ifc_node != node
470 1.1 mycroft && (ifc_node->tries > 0 || ifc_node->u.alias != node)) {
471 1.1 mycroft /* must merge two hosts' nodes */
472 1.1 mycroft Interface *ifc_i, *next_ifc_i;
473 1.1 mycroft
474 1.1 mycroft if (ifc_node->tries == -1) {
475 1.1 mycroft Node *tmp = ifc_node->u.alias;
476 1.1 mycroft
477 1.1 mycroft ifc_node->u.alias = node;
478 1.1 mycroft ifc_node = tmp;
479 1.1 mycroft }
480 1.1 mycroft
481 1.1 mycroft /* Merge ifc_node (foo_i) into node (foo_n) */
482 1.1 mycroft
483 1.1 mycroft if (ifc_node->tries > node->tries)
484 1.1 mycroft node->tries = ifc_node->tries;
485 1.1 mycroft
486 1.1 mycroft for (ifc_i = ifc_node->u.interfaces; ifc_i; ifc_i = next_ifc_i) {
487 1.1 mycroft Neighbor *nb_i, *next_nb_i, *nb_n;
488 1.1 mycroft Interface *ifc_n = find_interface(ifc_i->addr, node);
489 1.1 mycroft
490 1.1 mycroft old_neighbors = ifc_n->neighbors;
491 1.1 mycroft for (nb_i = ifc_i->neighbors; nb_i; nb_i = next_nb_i) {
492 1.1 mycroft next_nb_i = nb_i->next;
493 1.1 mycroft for (nb_n = old_neighbors; nb_n; nb_n = nb_n->next)
494 1.1 mycroft if (nb_i->addr == nb_n->addr) {
495 1.1 mycroft if (nb_i->metric != nb_n->metric
496 1.1 mycroft || nb_i->threshold != nb_i->threshold)
497 1.1 mycroft log(LOG_WARNING, 0,
498 1.1 mycroft "inconsistent %s for neighbor %s of %s",
499 1.1 mycroft "metric/threshold",
500 1.1 mycroft inet_fmt(nb_i->addr, s1),
501 1.1 mycroft inet_fmt(node->addr, s2));
502 1.1 mycroft free(nb_i);
503 1.1 mycroft break;
504 1.1 mycroft }
505 1.1 mycroft if (!nb_n) { /* no match for this neighbor yet */
506 1.1 mycroft nb_i->next = ifc_n->neighbors;
507 1.1 mycroft ifc_n->neighbors = nb_i;
508 1.1 mycroft }
509 1.1 mycroft }
510 1.1 mycroft
511 1.1 mycroft next_ifc_i = ifc_i->next;
512 1.1 mycroft free(ifc_i);
513 1.1 mycroft }
514 1.1 mycroft
515 1.1 mycroft ifc_node->tries = -1;
516 1.1 mycroft ifc_node->u.alias = node;
517 1.1 mycroft }
518 1.1 mycroft
519 1.1 mycroft ifc = find_interface(ifc_addr, node);
520 1.1 mycroft old_neighbors = ifc->neighbors;
521 1.1 mycroft
522 1.1 mycroft /* Add the neighbors for this interface */
523 1.3 mycroft while (ncount-- && datalen > 0) {
524 1.1 mycroft u_int32_t neighbor;
525 1.1 mycroft Neighbor *nb;
526 1.1 mycroft Node *n_node;
527 1.1 mycroft
528 1.1 mycroft if (datalen < 4) {
529 1.1 mycroft log(LOG_WARNING, 0, "received truncated neighbor list from %s",
530 1.1 mycroft inet_fmt(src, s1));
531 1.1 mycroft return;
532 1.1 mycroft }
533 1.1 mycroft
534 1.1 mycroft neighbor = *(u_int32_t*)p;
535 1.1 mycroft p += 4;
536 1.1 mycroft datalen -= 4;
537 1.1 mycroft if (neighbor == 0)
538 1.1 mycroft /* make leaf nets point to themselves */
539 1.1 mycroft neighbor = ifc_addr;
540 1.1 mycroft
541 1.1 mycroft for (nb = old_neighbors; nb; nb = nb->next)
542 1.1 mycroft if (nb->addr == neighbor) {
543 1.1 mycroft if (metric != nb->metric || threshold != nb->threshold)
544 1.1 mycroft log(LOG_WARNING, 0,
545 1.1 mycroft "inconsistent %s for neighbor %s of %s",
546 1.1 mycroft "metric/threshold",
547 1.1 mycroft inet_fmt(nb->addr, s1), inet_fmt(node->addr, s2));
548 1.1 mycroft goto next_neighbor;
549 1.1 mycroft }
550 1.1 mycroft
551 1.1 mycroft nb = (Neighbor *) malloc(sizeof(Neighbor));
552 1.1 mycroft nb->next = ifc->neighbors;
553 1.1 mycroft ifc->neighbors = nb;
554 1.1 mycroft nb->addr = neighbor;
555 1.1 mycroft nb->metric = metric;
556 1.1 mycroft nb->threshold = threshold;
557 1.1 mycroft nb->flags = flags | NF_PRESENT;
558 1.1 mycroft
559 1.1 mycroft n_node = find_node(neighbor, &routers);
560 1.1 mycroft if (n_node->tries == 0 && !target_addr) { /* it's a new router */
561 1.1 mycroft ask(neighbor);
562 1.1 mycroft n_node->tries = 1;
563 1.1 mycroft }
564 1.1 mycroft
565 1.1 mycroft next_neighbor: ;
566 1.1 mycroft }
567 1.1 mycroft }
568 1.1 mycroft }
569 1.1 mycroft
570 1.1 mycroft
571 1.10 wiz void check_vif_state(void)
572 1.1 mycroft {
573 1.1 mycroft log(LOG_NOTICE, 0, "network marked down...");
574 1.1 mycroft }
575 1.1 mycroft
576 1.1 mycroft
577 1.10 wiz int retry_requests(Node *node)
578 1.1 mycroft {
579 1.1 mycroft int result;
580 1.1 mycroft
581 1.1 mycroft if (node) {
582 1.1 mycroft result = retry_requests(node->left);
583 1.1 mycroft if (node->tries > 0 && node->tries < retries) {
584 1.1 mycroft if (node->version)
585 1.1 mycroft ask2(node->addr);
586 1.1 mycroft else
587 1.1 mycroft ask(node->addr);
588 1.1 mycroft node->tries++;
589 1.1 mycroft result = 1;
590 1.1 mycroft }
591 1.1 mycroft return retry_requests(node->right) || result;
592 1.1 mycroft } else
593 1.1 mycroft return 0;
594 1.1 mycroft }
595 1.1 mycroft
596 1.1 mycroft
597 1.10 wiz char *inet_name(u_int32_t addr)
598 1.1 mycroft {
599 1.1 mycroft struct hostent *e;
600 1.1 mycroft
601 1.1 mycroft e = gethostbyaddr((char *)&addr, sizeof(addr), AF_INET);
602 1.1 mycroft
603 1.1 mycroft return e ? e->h_name : 0;
604 1.1 mycroft }
605 1.1 mycroft
606 1.1 mycroft
607 1.10 wiz void print_map(Node *node)
608 1.1 mycroft {
609 1.1 mycroft if (node) {
610 1.1 mycroft char *name, *addr;
611 1.1 mycroft
612 1.1 mycroft print_map(node->left);
613 1.1 mycroft
614 1.1 mycroft addr = inet_fmt(node->addr, s1);
615 1.1 mycroft if (!target_addr
616 1.1 mycroft || (node->tries >= 0 && node->u.interfaces)
617 1.1 mycroft || (node->tries == -1
618 1.1 mycroft && node->u.alias->tries >= 0
619 1.1 mycroft && node->u.alias->u.interfaces)) {
620 1.1 mycroft if (show_names && (name = inet_name(node->addr)))
621 1.1 mycroft printf("%s (%s):", addr, name);
622 1.1 mycroft else
623 1.1 mycroft printf("%s:", addr);
624 1.1 mycroft if (node->tries < 0)
625 1.1 mycroft printf(" alias for %s\n\n", inet_fmt(node->u.alias->addr, s1));
626 1.1 mycroft else if (!node->u.interfaces)
627 1.1 mycroft printf(" no response to query\n\n");
628 1.1 mycroft else {
629 1.1 mycroft Interface *ifc;
630 1.1 mycroft
631 1.1 mycroft if (node->version)
632 1.1 mycroft printf(" <v%d.%d>", node->version & 0xff,
633 1.1 mycroft (node->version >> 8) & 0xff);
634 1.1 mycroft printf("\n");
635 1.1 mycroft for (ifc = node->u.interfaces; ifc; ifc = ifc->next) {
636 1.1 mycroft Neighbor *nb;
637 1.1 mycroft char *ifc_name = inet_fmt(ifc->addr, s1);
638 1.1 mycroft int ifc_len = strlen(ifc_name);
639 1.1 mycroft int count = 0;
640 1.1 mycroft
641 1.1 mycroft printf(" %s:", ifc_name);
642 1.1 mycroft for (nb = ifc->neighbors; nb; nb = nb->next) {
643 1.1 mycroft if (count > 0)
644 1.1 mycroft printf("%*s", ifc_len + 5, "");
645 1.1 mycroft printf(" %s", inet_fmt(nb->addr, s1));
646 1.1 mycroft if (show_names && (name = inet_name(nb->addr)))
647 1.1 mycroft printf(" (%s)", name);
648 1.1 mycroft printf(" [%d/%d", nb->metric, nb->threshold);
649 1.1 mycroft if (nb->flags) {
650 1.1 mycroft u_short flags = nb->flags;
651 1.1 mycroft if (flags & DVMRP_NF_TUNNEL)
652 1.1 mycroft printf("/tunnel");
653 1.1 mycroft if (flags & DVMRP_NF_SRCRT)
654 1.1 mycroft printf("/srcrt");
655 1.1 mycroft if (flags & DVMRP_NF_QUERIER)
656 1.1 mycroft printf("/querier");
657 1.1 mycroft if (flags & DVMRP_NF_DISABLED)
658 1.1 mycroft printf("/disabled");
659 1.1 mycroft if (flags & DVMRP_NF_DOWN)
660 1.1 mycroft printf("/down");
661 1.1 mycroft }
662 1.1 mycroft printf("]\n");
663 1.1 mycroft count++;
664 1.1 mycroft }
665 1.1 mycroft }
666 1.1 mycroft printf("\n");
667 1.1 mycroft }
668 1.1 mycroft }
669 1.1 mycroft print_map(node->right);
670 1.1 mycroft }
671 1.1 mycroft }
672 1.1 mycroft
673 1.1 mycroft
674 1.10 wiz char *graph_name(u_int32_t addr, char *buf)
675 1.1 mycroft {
676 1.1 mycroft char *name;
677 1.1 mycroft
678 1.1 mycroft if (show_names && (name = inet_name(addr)))
679 1.1 mycroft strcpy(buf, name);
680 1.1 mycroft else
681 1.1 mycroft inet_fmt(addr, buf);
682 1.1 mycroft
683 1.1 mycroft return buf;
684 1.1 mycroft }
685 1.1 mycroft
686 1.1 mycroft
687 1.10 wiz void graph_edges(Node *node)
688 1.1 mycroft {
689 1.1 mycroft Interface *ifc;
690 1.1 mycroft Neighbor *nb;
691 1.1 mycroft char name[100];
692 1.1 mycroft
693 1.1 mycroft if (node) {
694 1.1 mycroft graph_edges(node->left);
695 1.1 mycroft if (node->tries >= 0) {
696 1.1 mycroft printf(" %d {$ NP %d0 %d0 $} \"%s%s\" \n",
697 1.1 mycroft (int) node->addr,
698 1.1 mycroft node->addr & 0xFF, (node->addr >> 8) & 0xFF,
699 1.1 mycroft graph_name(node->addr, name),
700 1.1 mycroft node->u.interfaces ? "" : "*");
701 1.1 mycroft for (ifc = node->u.interfaces; ifc; ifc = ifc->next)
702 1.1 mycroft for (nb = ifc->neighbors; nb; nb = nb->next) {
703 1.1 mycroft Node *nb_node = find_node(nb->addr, &routers);
704 1.1 mycroft Neighbor *nb2;
705 1.1 mycroft
706 1.1 mycroft if (nb_node->tries < 0)
707 1.1 mycroft nb_node = nb_node->u.alias;
708 1.1 mycroft
709 1.1 mycroft if (node != nb_node &&
710 1.1 mycroft (!(nb2 = find_neighbor(node->addr, nb_node))
711 1.1 mycroft || node->addr < nb_node->addr)) {
712 1.1 mycroft printf(" %d \"%d/%d",
713 1.1 mycroft nb_node->addr, nb->metric, nb->threshold);
714 1.1 mycroft if (nb2 && (nb2->metric != nb->metric
715 1.1 mycroft || nb2->threshold != nb->threshold))
716 1.1 mycroft printf(",%d/%d", nb2->metric, nb2->threshold);
717 1.1 mycroft if (nb->flags & NF_PRESENT)
718 1.1 mycroft printf("%s%s",
719 1.1 mycroft nb->flags & DVMRP_NF_SRCRT ? "" :
720 1.1 mycroft nb->flags & DVMRP_NF_TUNNEL ? "E" : "P",
721 1.1 mycroft nb->flags & DVMRP_NF_DOWN ? "D" : "");
722 1.1 mycroft printf("\"\n");
723 1.1 mycroft }
724 1.1 mycroft }
725 1.1 mycroft printf(" ;\n");
726 1.1 mycroft }
727 1.1 mycroft graph_edges(node->right);
728 1.1 mycroft }
729 1.1 mycroft }
730 1.1 mycroft
731 1.10 wiz void elide_aliases(Node *node)
732 1.1 mycroft {
733 1.1 mycroft if (node) {
734 1.1 mycroft elide_aliases(node->left);
735 1.1 mycroft if (node->tries >= 0) {
736 1.1 mycroft Interface *ifc;
737 1.1 mycroft
738 1.1 mycroft for (ifc = node->u.interfaces; ifc; ifc = ifc->next) {
739 1.1 mycroft Neighbor *nb;
740 1.1 mycroft
741 1.1 mycroft for (nb = ifc->neighbors; nb; nb = nb->next) {
742 1.1 mycroft Node *nb_node = find_node(nb->addr, &routers);
743 1.1 mycroft
744 1.1 mycroft if (nb_node->tries < 0)
745 1.1 mycroft nb->addr = nb_node->u.alias->addr;
746 1.1 mycroft }
747 1.1 mycroft }
748 1.1 mycroft }
749 1.1 mycroft elide_aliases(node->right);
750 1.1 mycroft }
751 1.1 mycroft }
752 1.1 mycroft
753 1.10 wiz void graph_map(void)
754 1.1 mycroft {
755 1.1 mycroft time_t now = time(0);
756 1.1 mycroft char *nowstr = ctime(&now);
757 1.1 mycroft
758 1.1 mycroft nowstr[24] = '\0'; /* Kill the newline at the end */
759 1.1 mycroft elide_aliases(routers);
760 1.1 mycroft printf("GRAPH \"Multicast Router Connectivity: %s\" = UNDIRECTED\n",
761 1.1 mycroft nowstr);
762 1.1 mycroft graph_edges(routers);
763 1.1 mycroft printf("END\n");
764 1.1 mycroft }
765 1.1 mycroft
766 1.1 mycroft
767 1.10 wiz int get_number(int *var, int deflt, char ***pargv, int *pargc)
768 1.1 mycroft {
769 1.1 mycroft if ((*pargv)[0][2] == '\0') { /* Get the value from the next argument */
770 1.1 mycroft if (*pargc > 1 && isdigit((*pargv)[1][0])) {
771 1.1 mycroft (*pargv)++, (*pargc)--;
772 1.1 mycroft *var = atoi((*pargv)[0]);
773 1.1 mycroft return 1;
774 1.1 mycroft } else if (deflt >= 0) {
775 1.1 mycroft *var = deflt;
776 1.1 mycroft return 1;
777 1.1 mycroft } else
778 1.1 mycroft return 0;
779 1.1 mycroft } else { /* Get value from the rest of this argument */
780 1.1 mycroft if (isdigit((*pargv)[0][2])) {
781 1.1 mycroft *var = atoi((*pargv)[0] + 2);
782 1.1 mycroft return 1;
783 1.1 mycroft } else {
784 1.1 mycroft return 0;
785 1.1 mycroft }
786 1.1 mycroft }
787 1.1 mycroft }
788 1.1 mycroft
789 1.1 mycroft
790 1.10 wiz u_int32_t host_addr(char *name)
791 1.1 mycroft {
792 1.1 mycroft struct hostent *e = gethostbyname(name);
793 1.1 mycroft int addr;
794 1.1 mycroft
795 1.1 mycroft if (e)
796 1.1 mycroft memcpy(&addr, e->h_addr_list[0], e->h_length);
797 1.1 mycroft else {
798 1.1 mycroft addr = inet_addr(name);
799 1.1 mycroft if (addr == -1)
800 1.1 mycroft addr = 0;
801 1.1 mycroft }
802 1.1 mycroft
803 1.1 mycroft return addr;
804 1.1 mycroft }
805 1.1 mycroft
806 1.1 mycroft
807 1.10 wiz int main(int argc, char **argv)
808 1.1 mycroft {
809 1.1 mycroft int flood = FALSE, graph = FALSE;
810 1.1 mycroft
811 1.1 mycroft setlinebuf(stderr);
812 1.1 mycroft
813 1.1 mycroft if (geteuid() != 0) {
814 1.1 mycroft fprintf(stderr, "must be root\n");
815 1.1 mycroft exit(1);
816 1.1 mycroft }
817 1.1 mycroft
818 1.1 mycroft argv++, argc--;
819 1.1 mycroft while (argc > 0 && argv[0][0] == '-') {
820 1.1 mycroft switch (argv[0][1]) {
821 1.1 mycroft case 'd':
822 1.1 mycroft if (!get_number(&debug, DEFAULT_DEBUG, &argv, &argc))
823 1.1 mycroft goto usage;
824 1.1 mycroft break;
825 1.1 mycroft case 'f':
826 1.1 mycroft flood = TRUE;
827 1.1 mycroft break;
828 1.1 mycroft case 'g':
829 1.1 mycroft graph = TRUE;
830 1.1 mycroft break;
831 1.1 mycroft case 'n':
832 1.1 mycroft show_names = FALSE;
833 1.1 mycroft break;
834 1.1 mycroft case 'r':
835 1.1 mycroft if (!get_number(&retries, -1, &argv, &argc))
836 1.1 mycroft goto usage;
837 1.1 mycroft break;
838 1.1 mycroft case 't':
839 1.1 mycroft if (!get_number(&timeout, -1, &argv, &argc))
840 1.1 mycroft goto usage;
841 1.1 mycroft break;
842 1.1 mycroft default:
843 1.1 mycroft goto usage;
844 1.1 mycroft }
845 1.1 mycroft argv++, argc--;
846 1.1 mycroft }
847 1.1 mycroft
848 1.1 mycroft if (argc > 1) {
849 1.1 mycroft usage:
850 1.1 mycroft fprintf(stderr,
851 1.1 mycroft "Usage: map-mbone [-f] [-g] [-n] [-t timeout] %s\n\n",
852 1.1 mycroft "[-r retries] [-d [debug-level]] [router]");
853 1.1 mycroft fprintf(stderr, "\t-f Flood the routing graph with queries\n");
854 1.1 mycroft fprintf(stderr, "\t (True by default unless `router' is given)\n");
855 1.1 mycroft fprintf(stderr, "\t-g Generate output in GraphEd format\n");
856 1.1 mycroft fprintf(stderr, "\t-n Don't look up DNS names for routers\n");
857 1.1 mycroft exit(1);
858 1.1 mycroft } else if (argc == 1 && !(target_addr = host_addr(argv[0]))) {
859 1.1 mycroft fprintf(stderr, "Unknown host: %s\n", argv[0]);
860 1.1 mycroft exit(2);
861 1.1 mycroft }
862 1.1 mycroft
863 1.1 mycroft if (debug)
864 1.1 mycroft fprintf(stderr, "Debug level %u\n", debug);
865 1.1 mycroft
866 1.1 mycroft init_igmp();
867 1.1 mycroft
868 1.1 mycroft { /* Find a good local address for us. */
869 1.1 mycroft int udp;
870 1.1 mycroft struct sockaddr_in addr;
871 1.1 mycroft int addrlen = sizeof(addr);
872 1.1 mycroft
873 1.9 itojun memset(&addr, 0, sizeof(addr));
874 1.1 mycroft addr.sin_family = AF_INET;
875 1.1 mycroft #if (defined(BSD) && (BSD >= 199103))
876 1.1 mycroft addr.sin_len = sizeof addr;
877 1.1 mycroft #endif
878 1.1 mycroft addr.sin_addr.s_addr = dvmrp_group;
879 1.1 mycroft addr.sin_port = htons(2000); /* any port over 1024 will do... */
880 1.1 mycroft if ((udp = socket(AF_INET, SOCK_DGRAM, 0)) < 0
881 1.1 mycroft || connect(udp, (struct sockaddr *) &addr, sizeof(addr)) < 0
882 1.1 mycroft || getsockname(udp, (struct sockaddr *) &addr, &addrlen) < 0) {
883 1.1 mycroft perror("Determining local address");
884 1.6 wiz exit(1);
885 1.1 mycroft }
886 1.1 mycroft close(udp);
887 1.1 mycroft our_addr = addr.sin_addr.s_addr;
888 1.1 mycroft }
889 1.1 mycroft
890 1.1 mycroft /* Send initial seed message to all local routers */
891 1.1 mycroft ask(target_addr ? target_addr : allhosts_group);
892 1.1 mycroft
893 1.1 mycroft if (target_addr) {
894 1.1 mycroft Node *n = find_node(target_addr, &routers);
895 1.1 mycroft
896 1.1 mycroft n->tries = 1;
897 1.1 mycroft
898 1.1 mycroft if (flood)
899 1.1 mycroft target_addr = 0;
900 1.1 mycroft }
901 1.1 mycroft
902 1.1 mycroft /* Main receive loop */
903 1.1 mycroft for(;;) {
904 1.1 mycroft fd_set fds;
905 1.1 mycroft struct timeval tv;
906 1.1 mycroft int count, recvlen, dummy = 0;
907 1.1 mycroft
908 1.1 mycroft FD_ZERO(&fds);
909 1.11 itojun if (igmp_socket >= FD_SETSIZE)
910 1.11 itojun log(LOG_ERR, 0, "descriptor too big");
911 1.1 mycroft FD_SET(igmp_socket, &fds);
912 1.1 mycroft
913 1.1 mycroft tv.tv_sec = timeout;
914 1.1 mycroft tv.tv_usec = 0;
915 1.1 mycroft
916 1.1 mycroft count = select(igmp_socket + 1, &fds, 0, 0, &tv);
917 1.1 mycroft
918 1.1 mycroft if (count < 0) {
919 1.1 mycroft if (errno != EINTR)
920 1.1 mycroft perror("select");
921 1.1 mycroft continue;
922 1.1 mycroft } else if (count == 0) {
923 1.1 mycroft log(LOG_DEBUG, 0, "Timed out receiving neighbor lists");
924 1.1 mycroft if (retry_requests(routers))
925 1.1 mycroft continue;
926 1.1 mycroft else
927 1.1 mycroft break;
928 1.1 mycroft }
929 1.1 mycroft
930 1.1 mycroft recvlen = recvfrom(igmp_socket, recv_buf, RECV_BUF_SIZE,
931 1.1 mycroft 0, NULL, &dummy);
932 1.1 mycroft if (recvlen >= 0)
933 1.1 mycroft accept_igmp(recvlen);
934 1.1 mycroft else if (errno != EINTR)
935 1.1 mycroft perror("recvfrom");
936 1.1 mycroft }
937 1.1 mycroft
938 1.1 mycroft printf("\n");
939 1.1 mycroft
940 1.1 mycroft if (graph)
941 1.1 mycroft graph_map();
942 1.1 mycroft else {
943 1.1 mycroft if (!target_addr)
944 1.1 mycroft printf("Multicast Router Connectivity:\n\n");
945 1.1 mycroft print_map(routers);
946 1.1 mycroft }
947 1.1 mycroft
948 1.1 mycroft exit(0);
949 1.1 mycroft }
950 1.1 mycroft
951 1.3 mycroft /* dummies */
952 1.10 wiz void accept_prune(u_int32_t src, u_int32_t dst, char *p, int datalen)
953 1.3 mycroft {
954 1.3 mycroft }
955 1.10 wiz void accept_graft(u_int32_t src, u_int32_t dst, char *p, int datalen)
956 1.3 mycroft {
957 1.3 mycroft }
958 1.10 wiz void accept_g_ack(u_int32_t src, u_int32_t dst, char *p, int datalen)
959 1.1 mycroft {
960 1.1 mycroft }
961 1.10 wiz void add_table_entry(u_int32_t origin, u_int32_t mcastgrp)
962 1.1 mycroft {
963 1.1 mycroft }
964 1.10 wiz void accept_leave_message(u_int32_t src, u_int32_t dst, u_int32_t group)
965 1.1 mycroft {
966 1.1 mycroft }
967 1.10 wiz void accept_mtrace(u_int32_t src, u_int32_t dst, u_int32_t group, char *data,
968 1.10 wiz u_int no, int datalen)
969 1.1 mycroft {
970 1.1 mycroft }
971 1.10 wiz void accept_membership_query(u_int32_t src, u_int32_t dst, u_int32_t group,
972 1.10 wiz int tmo)
973 1.1 mycroft {
974 1.1 mycroft }
975 1.10 wiz void accept_info_request(u_int32_t src, u_int32_t dst, u_char *p, int datalen)
976 1.1 mycroft {
977 1.1 mycroft }
978 1.10 wiz void accept_info_reply(u_int32_t src, u_int32_t dst, u_char *p, int datalen)
979 1.1 mycroft {
980 1.1 mycroft }
981