summaryrefslogtreecommitdiff
path: root/usr.sbin/ospfd/config.c
blob: 18425131af7aa9fa2a1c9c4ea12e78d243a9dcfb (plain)
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
/*	$OpenBSD: config.c,v 1.7 2005/05/23 19:59:02 norby Exp $ */

/*
 * Copyright (c) 2004, 2005 Esben Norby <norby@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 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/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>

#include "ospf.h"
#include "ospfd.h"
#include "ospfe.h"
#include "log.h"

void	show_db_sum(struct lsa_hdr *);
void	show_neighbor(struct nbr *);
void	show_interface(struct iface *);
void	show_area(struct area *);

extern char *__progname;

void
show_db_sum(struct lsa_hdr *db_sum)
{

	log_debug("        age %d", db_sum->age);
	log_debug("        opts %d", db_sum->opts);
	log_debug("        type %d", db_sum->type);
	log_debug("        ls_id %u", (db_sum->ls_id));
	log_debug("        adv_rtr %u", (db_sum->adv_rtr));
	log_debug("        seq_num 0x%x", db_sum->seq_num);
	log_debug("        chksum 0x%x", db_sum->ls_chksum);
	log_debug("        len %d", db_sum->len);
}

void
show_neighbor(struct nbr *nbr)
{
	struct lsa_entry	*lsa_entry = NULL;

	log_debug("      state: %s", nbr_state_name(nbr->state));
	log_debug("      inactivity timer: ");
	log_debug("      master: %d", nbr->master);
	log_debug("      dd seq num: %d", nbr->dd_seq_num);
	log_debug("      last rx options: %d", nbr->last_rx_options);
	log_debug("      id: %s", inet_ntoa(nbr->id));
	log_debug("      priority: %d", nbr->priority);
	log_debug("      address: %s", inet_ntoa(nbr->addr));
	log_debug("      options: %d", nbr->options);
	log_debug("      dr: %s", inet_ntoa(nbr->dr));
	log_debug("      bdr: %s", inet_ntoa(nbr->bdr));

	log_debug("      ls retrans: ");

	log_debug("      db sum list: ");
	TAILQ_FOREACH(lsa_entry, &nbr->db_sum_list, entry) {
		show_db_sum(lsa_entry->le_lsa);
	}

	log_debug("      ls request: ");
	TAILQ_FOREACH(lsa_entry, &nbr->ls_req_list, entry) {
		show_db_sum(lsa_entry->le_lsa);
	}
}

void
show_interface(struct iface *iface)
{
	struct nbr	*nbr = NULL;
	struct auth_md	*md;

	log_debug("  interface: %s", iface->name);
	log_debug("    type: %s", if_type_name(iface->type));
	log_debug("    state: %s", if_state_name(iface->state));
	log_debug("    address: %s", inet_ntoa(iface->addr));
	log_debug("    mask: %s", inet_ntoa(iface->mask));
	log_debug("    dst: %s", inet_ntoa(iface->dst));
	log_debug("    area: %s", inet_ntoa(iface->area->id));
	log_debug("    hello interval: %d", iface->hello_interval);
	log_debug("    dead interval: %d", iface->dead_interval);
	log_debug("    transmit delay: %d", iface->transmit_delay);
	log_debug("    priority: %d", iface->priority);
	log_debug("    hello timer: ");
	log_debug("    wait timer: ");
	log_debug("    neighbor:");

	LIST_FOREACH(nbr, &iface->nbr_list, entry) {
		show_neighbor(nbr);
	}

	log_debug("    dr: ");
	log_debug("    bdr: ");
	log_debug("    metric: %d", iface->metric);
	log_debug("    rxmt interval: %d", iface->rxmt_interval);
	log_debug("    auth type: %s", if_auth_name(iface->auth_type));
	log_debug("    auth_key: '%s'", iface->auth_key);
	log_debug("    auth keyid: %d", iface->auth_keyid);

	TAILQ_FOREACH(md, &iface->auth_md_list, entry)
		log_debug("      keyid: %d key: %s", md->keyid, md->key);

	log_debug("    mtu: %d", iface->mtu);
	log_debug("    fd: %d", iface->fd);
	log_debug("    passive: %d", iface->passive);
	log_debug("    ifindex: %d", iface->ifindex);
}

void
show_area(struct area *area)
{
	struct iface	*iface = NULL;

	log_debug("area: %s", inet_ntoa(area->id));

	LIST_FOREACH(iface, &area->iface_list, entry) {
		show_interface(iface);
	}

	log_debug("  transit: %d", area->transit);
	log_debug("  stub: %d", area->stub);
	log_debug("  stub default cost: %d", area->stub_default_cost);
}

void
show_config(struct ospfd_conf *xconf)
{
	struct area	*area = NULL;

	log_debug("--------------------------------------------------------");
	log_debug("dumping %s configuration", __progname);
	log_debug("--------------------------------------------------------");

	log_debug("router-id: %s", inet_ntoa(xconf->rtr_id));
	log_debug("rfc1583compat: %d", xconf->rfc1583compat);
	log_debug("ospf socket: %d", xconf->ospf_socket);

	LIST_FOREACH(area, &xconf->area_list, entry) {
		show_area(area);
	}
	log_debug("--------------------------------------------------------");
}