1 /* $OpenBSD: printconf.c,v 1.3 2010/05/25 13:29:45 claudio Exp $ */ 2 3 /* 4 * Copyright (c) 2004, 2005, 2008 Esben Norby <norby@openbsd.org> 5 * 6 * Permission to use, copy, modify, and distribute this software for any 7 * purpose with or without fee is hereby granted, provided that the above 8 * copyright notice and this permission notice appear in all copies. 9 * 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 */ 18 19 #include <sys/queue.h> 20 #include <sys/types.h> 21 #include <sys/socket.h> 22 #include <netinet/in.h> 23 #include <arpa/inet.h> 24 25 #include <stdio.h> 26 27 #include "ldp.h" 28 #include "ldpd.h" 29 #include "ldpe.h" 30 31 void print_mainconf(struct ldpd_conf *); 32 void print_iface(struct iface *); 33 34 void 35 print_mainconf(struct ldpd_conf *conf) 36 { 37 printf("router-id %s\n\n", inet_ntoa(conf->rtr_id)); 38 39 if (conf->mode & MODE_DIST_INDEPENDENT) 40 printf("distribution independent\n"); 41 else 42 printf("distribution ordered\n"); 43 44 if (conf->mode & MODE_RET_LIBERAL) 45 printf("retention liberal\n"); 46 else 47 printf("retention conservative\n"); 48 49 if (conf->mode & MODE_ADV_ONDEMAND) 50 printf("advertisement ondemand\n"); 51 else 52 printf("advertisement unsolicited\n"); 53 } 54 55 void 56 print_iface(struct iface *iface) 57 { 58 printf("\ninterface %s {\n", iface->name); 59 printf("\tholdtime %d\n", iface->holdtime); 60 printf("\thello-interval %d\n", iface->hello_interval); 61 if (iface->passive) 62 printf("\tpassive\n"); 63 printf("}\n"); 64 } 65 66 void 67 print_config(struct ldpd_conf *conf) 68 { 69 struct iface *iface; 70 71 print_mainconf(conf); 72 printf("\n"); 73 74 LIST_FOREACH(iface, &conf->iface_list, entry) { 75 print_iface(iface); 76 } 77 } 78