summaryrefslogtreecommitdiffstats
path: root/bgpd/bgp_names.c
blob: b22b7d1193cf29a80161f86b43a41cc7fbdf59d5 (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
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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
/* bgpd mapping protocol values to names
   Copyright (C) 1996, 97, 99 Kunihiro Ishiguro

This file is part of GNU Zebra.

GNU Zebra is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any
later version.

GNU Zebra is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.

You should have received a copy of the GNU General Public License
along with GNU Zebra; see the file COPYING.  If not, write to the Free
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.  */

#include <zebra.h>

#include "bgpd/bgp_names.h"

#include "bgpd/bgp_connection.h"
#include "bgpd/bgp_notification.h"

/*------------------------------------------------------------------------------
 * Names of FSM status values
 */
static const char* bgp_fsm_status_map_body[] =
{
  [bgp_fsm_sInitial]      = "Initial",
  [bgp_fsm_sIdle]         = "Idle",
  [bgp_fsm_sConnect]      = "Connect",
  [bgp_fsm_sActive]       = "Active",
  [bgp_fsm_sOpenSent]     = "OpenSent",
  [bgp_fsm_sOpenConfirm]  = "OpenConfirm",
  [bgp_fsm_sEstablished]  = "Established",
  [bgp_fsm_sStopping]     = "Stopping",
} ;

const map_direct_t bgp_fsm_status_map =
      map_direct_s(bgp_fsm_status_map_body, "unknown(%d)") ;

/*------------------------------------------------------------------------------
 * Names of Peer status values
 */
const char* bgp_peer_status_map_body[] =
{
  [bgp_peer_pIdle]         = "Idle",
  [bgp_peer_pEstablished]  = "Established",
  [bgp_peer_pClearing]     = "Clearing",
  [bgp_peer_pDeleting]     = "Deleting",
};

const map_direct_t bgp_peer_status_map =
     map_direct_s(bgp_peer_status_map_body, "unknown(%d)") ;

/*------------------------------------------------------------------------------
 * BGP message type names.
 */
static const char* bgp_message_type_map_body[] =
{
  [BGP_MT_OPEN]               = "OPEN",
  [BGP_MT_UPDATE]             = "UPDATE",
  [BGP_MT_NOTIFICATION]       = "NOTIFICATION",
  [BGP_MT_KEEPALIVE]          = "KEEPALIVE",
  [BGP_MT_ROUTE_REFRESH]      = "ROUTE-REFRESH",

  [BGP_MT_CAPABILITY]         = "CAPABILITY",

  [BGP_MT_ROUTE_REFRESH_pre]  = "ROUTE-REFRESH(pre-RFC2918)",
} ;

const map_direct_t bgp_message_type_map =
      map_direct_s(bgp_message_type_map_body, "unknown(%d)") ;

/*------------------------------------------------------------------------------
 * Names for notification types and sub-types
 */
static const char* bgp_notify_msg_map_body[] =
{
  [BGP_NOTIFY_HEADER_ERR]      = "Message Header Error",
  [BGP_NOTIFY_OPEN_ERR]        = "OPEN Message Error",
  [BGP_NOTIFY_UPDATE_ERR]      = "UPDATE Message Error",
  [BGP_NOTIFY_HOLD_ERR]        = "Hold Timer Expired",
  [BGP_NOTIFY_FSM_ERR]         = "Finite State Machine Error",
  [BGP_NOTIFY_CEASE]           = "Cease",
  [BGP_NOTIFY_CAPABILITY_ERR]  = "CAPABILITY Message Error",
} ;

const map_direct_t bgp_notify_msg_map =
      map_direct_s(bgp_notify_msg_map_body, "Unknown(%d)") ;

/* BGP_NOTIFY_HEADER_ERR subtypes
 */
static const char* bgp_notify_head_msg_map_body[] =
{
  [0]                              = "/Unspecific",
  [BGP_NOTIFY_HEADER_NOT_SYNC]     = "/Connection Not Synchronized",
  [BGP_NOTIFY_HEADER_BAD_MESLEN]   = "/Bad Message Length",
  [BGP_NOTIFY_HEADER_BAD_MESTYPE]  = "/Bad Message Type",
};

const map_direct_t bgp_notify_head_msg_map =
      map_direct_s(bgp_notify_head_msg_map_body, "/Unknown(%d)") ;

/* BGP_NOTIFY_OPEN_ERR subtypes
 */
static const char* bgp_notify_open_msg_map_body[] =
{
  [0]                                = "/Unspecific",
  [BGP_NOTIFY_OPEN_UNSUP_VERSION]    = "/Unsupported Version Number",
  [BGP_NOTIFY_OPEN_BAD_PEER_AS]      = "/Bad Peer AS",
  [BGP_NOTIFY_OPEN_BAD_BGP_IDENT]    = "/Bad BGP Identifier",
  [BGP_NOTIFY_OPEN_UNSUP_PARAM]      = "/Unsupported Optional Parameter",
  [BGP_NOTIFY_OPEN_AUTH_FAILURE]     = "/Authentication Failure",
  [BGP_NOTIFY_OPEN_UNACEP_HOLDTIME]  = "/Unacceptable Hold Time",
  [BGP_NOTIFY_OPEN_UNSUP_CAPBL]      = "/Unsupported Capability",
};

const map_direct_t bgp_notify_open_msg_map =
      map_direct_s(bgp_notify_open_msg_map_body, "/Unknown(%d)") ;

/* BGP_NOTIFY_UPDATE_ERR subtypes
 */
static const char* bgp_notify_update_msg_map_body[] =
{
  [0]                                 = "/Unspecific",
  [BGP_NOTIFY_UPDATE_MAL_ATTR]        = "/Malformed Attribute List",
  [BGP_NOTIFY_UPDATE_UNREC_ATTR]      = "/Unrecognized Well-known Attribute",
  [BGP_NOTIFY_UPDATE_MISS_ATTR]       = "/Missing Well-known Attribute",
  [BGP_NOTIFY_UPDATE_ATTR_FLAG_ERR]   = "/Attribute Flags Error",
  [BGP_NOTIFY_UPDATE_ATTR_LENG_ERR]   = "/Attribute Length Error",
  [BGP_NOTIFY_UPDATE_INVAL_ORIGIN]    = "/Invalid ORIGIN Attribute",
  [BGP_NOTIFY_UPDATE_AS_ROUTE_LOOP]   = "/AS Routing Loop",
  [BGP_NOTIFY_UPDATE_INVAL_NEXT_HOP]  = "/Invalid NEXT_HOP Attribute",
  [BGP_NOTIFY_UPDATE_OPT_ATTR_ERR]    = "/Optional Attribute Error",
  [BGP_NOTIFY_UPDATE_INVAL_NETWORK]   = "/Invalid Network Field",
  [BGP_NOTIFY_UPDATE_MAL_AS_PATH]     = "/Malformed AS_PATH",
};

const map_direct_t bgp_notify_update_msg_map =
      map_direct_s(bgp_notify_update_msg_map_body, "/Unknown(%d)") ;

/* BGP_NOTIFY_CEASE_ERR subtypes
 */
static const char* bgp_notify_cease_msg_map_body[] =
{
  [0]                                   = "/Unspecific",
  [BGP_NOTIFY_CEASE_MAX_PREFIX]         = "/Maximum Number of Prefixes Reached",
  [BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN]     = "/Administratively Shutdown",
  [BGP_NOTIFY_CEASE_PEER_UNCONFIG]      = "/Peer Unconfigured",
  [BGP_NOTIFY_CEASE_ADMIN_RESET]        = "/Administratively Reset",
  [BGP_NOTIFY_CEASE_CONNECT_REJECT]     = "/Connection Rejected",
  [BGP_NOTIFY_CEASE_CONFIG_CHANGE]      = "/Other Configuration Change",
  [BGP_NOTIFY_CEASE_COLLISION_RESOLUTION] = "/Connection collision resolution",
  [BGP_NOTIFY_CEASE_OUT_OF_RESOURCE]    = "/Out of Resource",
};

const map_direct_t bgp_notify_cease_msg_map =
      map_direct_s(bgp_notify_cease_msg_map_body, "/Unknown(%d)") ;

/* BGP_NOTIFY_CAPABILITY_ERR subtypes
 */
static const char* bgp_notify_capability_msg_map_body[] =
{
  [0]                                     = "/Unspecific",
  [BGP_NOTIFY_CAPABILITY_INVALID_ACTION]  = "/Invalid Action Value",
  [BGP_NOTIFY_CAPABILITY_INVALID_LENGTH]  = "/Invalid Capability Length",
  [BGP_NOTIFY_CAPABILITY_MALFORMED_CODE]  = "/Malformed Capability Value",
  [4]                                     = "/Unsupported Capability",
};

const map_direct_t bgp_notify_capability_msg_map =
      map_direct_s(bgp_notify_capability_msg_map_body, "/Unknown(%d)") ;

/* BGP_NOTIFY_HOLD_ERR and BGP_NOTIFY_FSM_ERR subtypes
 *
 * These have no subtypes, so should always be unspecific, but that is not
 * worth remarking on.
 */
static const char* bgp_notify_unspecific_msg_map_body[] =
{
  [0] = "",
};

const map_direct_t bgp_notify_unspecific_msg_map =
      map_direct_s(bgp_notify_unspecific_msg_map_body, "/Unknown(%d)") ;

/* Notification subtypes for unknown type !
 */
static const char* bgp_notify_unknown_msg_map_body[] = {} ;

const map_direct_t bgp_notify_unknown_msg_map =
      map_direct_s(bgp_notify_unknown_msg_map_body, "/Unknown(%d)") ;

/*------------------------------------------------------------------------------
 * Origin names -- short and long
 */
const char* bgp_origin_short_map_body[] =
{
  [BGP_ATT_ORG_IGP]    = "i",
  [BGP_ATT_ORG_EGP]    = "e",
  [BGP_ATT_ORG_INCOMP] = "?",
};

const map_direct_t bgp_origin_short_map =
      map_direct_s(bgp_origin_short_map_body, "X") ;

const char* bgp_origin_long_map_body[] =
{
  [BGP_ATT_ORG_IGP]    = "IGP",
  [BGP_ATT_ORG_EGP]    = "EGP",
  [BGP_ATT_ORG_INCOMP] = "incomplete",
};

const map_direct_t bgp_origin_long_map =
      map_direct_s(bgp_origin_long_map_body, "unknown(%d)") ;

/*------------------------------------------------------------------------------
 * Attribute type names
 */
const char* bgp_attr_name_map_body[] =
{
  [BGP_ATTR_ORIGIN]           = "ORIGIN",
  [BGP_ATTR_AS_PATH]          = "AS_PATH",
  [BGP_ATTR_NEXT_HOP]         = "NEXT_HOP",
  [BGP_ATTR_MULTI_EXIT_DISC]  = "MULTI_EXIT_DISC",
  [BGP_ATTR_LOCAL_PREF]       = "LOCAL_PREF",
  [BGP_ATTR_ATOMIC_AGGREGATE] = "ATOMIC_AGGREGATE",
  [BGP_ATTR_AGGREGATOR]       = "AGGREGATOR",
  [BGP_ATTR_COMMUNITIES]      = "COMMUNITY",
  [BGP_ATTR_ORIGINATOR_ID]    = "ORIGINATOR_ID",
  [BGP_ATTR_CLUSTER_LIST]     = "CLUSTER_LIST",
  [BGP_ATTR_DPA]              = "DPA",
  [BGP_ATTR_ADVERTISER]       = "ADVERTISER" ,
  [BGP_ATTR_RCID_PATH]        = "RCID_PATH",
  [BGP_ATTR_MP_REACH_NLRI]    = "MP_REACH_NLRI",
  [BGP_ATTR_MP_UNREACH_NLRI]  = "MP_UNREACH_NLRI",
  [BGP_ATTR_EXT_COMMUNITIES]  = "EXT_COMMUNITIES",
  [BGP_ATTR_AS4_PATH]         = "AS4_PATH",
  [BGP_ATTR_AS4_AGGREGATOR]   = "AS4_AGGREGATOR",
  [BGP_ATTR_AS_PATHLIMIT]     = "AS_PATHLIMIT",
};

const map_direct_t bgp_attr_name_map =
      map_direct_s(bgp_attr_name_map_body, "unknown(%u)") ;

/*------------------------------------------------------------------------------
 * AFI names
 */
const char* bgp_afi_name_map_body[] =
{
  [AFI_IP]                    = "AFI_IP",
  [AFI_IP6]                   = "AFI_IP6",
};

const map_direct_t bgp_afi_name_map =
      map_direct_s(bgp_afi_name_map_body, "unknown AFI(%u)") ;

/*------------------------------------------------------------------------------
 * SAFI names
 */
const char* bgp_safi_name_map_body[] =
{
  [SAFI_UNICAST]              = "SAFI_UNICAST",
  [SAFI_MULTICAST]            = "SAFI_MULTICAST",
  [SAFI_MPLS_VPN]             = "SAFI_MPLS_VPN",
};

const map_direct_t bgp_safi_name_map =
      map_direct_s(bgp_safi_name_map_body, "unknown SAFI(%u)") ;