]> git.proxmox.com Git - mirror_frr.git/blame - ospfd/ospf_dump_api.c
Merge pull request #12798 from donaldsharp/rib_match_multicast
[mirror_frr.git] / ospfd / ospf_dump_api.c
CommitLineData
acddc0ed 1// SPDX-License-Identifier: GPL-2.0-or-later
0a3fc2a5
DL
2/*
3 * OSPFd dump routine (parts used by ospfclient).
4 * Copyright (C) 1999, 2000 Toshiaki Takada
0a3fc2a5
DL
5 */
6
7#include <zebra.h>
8
9#include "log.h"
10#include "prefix.h"
11
12#include "ospf_dump_api.h"
13#include "ospfd.h"
14#include "ospf_asbr.h"
15#include "ospf_lsa.h"
16#include "ospf_nsm.h"
17#include "ospf_ism.h"
18
d62a17ae 19const struct message ospf_ism_state_msg[] = {
20 {ISM_DependUpon, "DependUpon"},
21 {ISM_Down, "Down"},
22 {ISM_Loopback, "Loopback"},
23 {ISM_Waiting, "Waiting"},
24 {ISM_PointToPoint, "Point-To-Point"},
25 {ISM_DROther, "DROther"},
26 {ISM_Backup, "Backup"},
27 {ISM_DR, "DR"},
28 {0}};
0a3fc2a5 29
d62a17ae 30const struct message ospf_nsm_state_msg[] = {{NSM_DependUpon, "DependUpon"},
31 {NSM_Deleted, "Deleted"},
32 {NSM_Down, "Down"},
33 {NSM_Attempt, "Attempt"},
34 {NSM_Init, "Init"},
35 {NSM_TwoWay, "2-Way"},
36 {NSM_ExStart, "ExStart"},
37 {NSM_Exchange, "Exchange"},
38 {NSM_Loading, "Loading"},
39 {NSM_Full, "Full"},
40 {0}};
0a3fc2a5 41
d62a17ae 42const struct message ospf_lsa_type_msg[] = {
43 {OSPF_UNKNOWN_LSA, "unknown"},
44 {OSPF_ROUTER_LSA, "router-LSA"},
45 {OSPF_NETWORK_LSA, "network-LSA"},
46 {OSPF_SUMMARY_LSA, "summary-LSA"},
47 {OSPF_ASBR_SUMMARY_LSA, "summary-LSA"},
48 {OSPF_AS_EXTERNAL_LSA, "AS-external-LSA"},
49 {OSPF_GROUP_MEMBER_LSA, "GROUP MEMBER LSA"},
50 {OSPF_AS_NSSA_LSA, "NSSA-LSA"},
51 {8, "Type-8 LSA"},
52 {OSPF_OPAQUE_LINK_LSA, "Link-Local Opaque-LSA"},
53 {OSPF_OPAQUE_AREA_LSA, "Area-Local Opaque-LSA"},
54 {OSPF_OPAQUE_AS_LSA, "AS-external Opaque-LSA"},
55 {0}};
0a3fc2a5 56
d62a17ae 57const struct message ospf_link_state_id_type_msg[] = {
58 {OSPF_UNKNOWN_LSA, "(unknown)"},
59 {OSPF_ROUTER_LSA, ""},
60 {OSPF_NETWORK_LSA, "(address of Designated Router)"},
61 {OSPF_SUMMARY_LSA, "(summary Network Number)"},
62 {OSPF_ASBR_SUMMARY_LSA, "(AS Boundary Router address)"},
63 {OSPF_AS_EXTERNAL_LSA, "(External Network Number)"},
64 {OSPF_GROUP_MEMBER_LSA, "(Group membership information)"},
65 {OSPF_AS_NSSA_LSA, "(External Network Number for NSSA)"},
66 {8, "(Type-8 LSID)"},
67 {OSPF_OPAQUE_LINK_LSA, "(Link-Local Opaque-Type/ID)"},
68 {OSPF_OPAQUE_AREA_LSA, "(Area-Local Opaque-Type/ID)"},
69 {OSPF_OPAQUE_AS_LSA, "(AS-external Opaque-Type/ID)"},
70 {0}};
0a3fc2a5 71
d62a17ae 72const struct message ospf_network_type_msg[] = {
73 {OSPF_IFTYPE_NONE, "NONE"},
74 {OSPF_IFTYPE_POINTOPOINT, "Point-to-Point"},
75 {OSPF_IFTYPE_BROADCAST, "Broadcast"},
76 {OSPF_IFTYPE_NBMA, "NBMA"},
77 {OSPF_IFTYPE_POINTOMULTIPOINT, "Point-to-MultiPoint"},
78 {OSPF_IFTYPE_VIRTUALLINK, "Virtual-Link"},
79 {0}};
0a3fc2a5
DL
80
81/* AuType */
d62a17ae 82const struct message ospf_auth_type_str[] = {
83 {OSPF_AUTH_NULL, "Null"},
84 {OSPF_AUTH_SIMPLE, "Simple"},
85 {OSPF_AUTH_CRYPTOGRAPHIC, "Cryptographic"},
86 {0}};
0a3fc2a5
DL
87
88#define OSPF_OPTION_STR_MAXLEN 24
89
d7c0a89a 90char *ospf_options_dump(uint8_t options)
0a3fc2a5 91{
d62a17ae 92 static char buf[OSPF_OPTION_STR_MAXLEN];
0a3fc2a5 93
772270f3 94 snprintf(buf, sizeof(buf), "*|%s|%s|%s|%s|%s|%s|%s",
d62a17ae 95 (options & OSPF_OPTION_O) ? "O" : "-",
96 (options & OSPF_OPTION_DC) ? "DC" : "-",
97 (options & OSPF_OPTION_EA) ? "EA" : "-",
98 (options & OSPF_OPTION_NP) ? "N/P" : "-",
99 (options & OSPF_OPTION_MC) ? "MC" : "-",
100 (options & OSPF_OPTION_E) ? "E" : "-",
101 (options & OSPF_OPTION_MT) ? "M/T" : "-");
0a3fc2a5 102
d62a17ae 103 return buf;
0a3fc2a5
DL
104}
105
d62a17ae 106void ospf_lsa_header_dump(struct lsa_header *lsah)
0a3fc2a5 107{
d62a17ae 108 const char *lsah_type = lookup_msg(ospf_lsa_type_msg, lsah->type, NULL);
0a3fc2a5 109
d62a17ae 110 zlog_debug(" LSA Header");
111 zlog_debug(" LS age %d", ntohs(lsah->ls_age));
112 zlog_debug(" Options %d (%s)", lsah->options,
113 ospf_options_dump(lsah->options));
114 zlog_debug(" LS type %d (%s)", lsah->type,
115 (lsah->type ? lsah_type : "unknown type"));
96b663a3
MS
116 zlog_debug(" Link State ID %pI4", &lsah->id);
117 zlog_debug(" Advertising Router %pI4", &lsah->adv_router);
d62a17ae 118 zlog_debug(" LS sequence number 0x%lx",
d7c0a89a 119 (unsigned long)ntohl(lsah->ls_seqnum));
d62a17ae 120 zlog_debug(" LS checksum 0x%x", ntohs(lsah->checksum));
121 zlog_debug(" length %d", ntohs(lsah->length));
0a3fc2a5 122}