blob: 436eb01ccaeb2fca604d5d1e081a38ae3f76d7cd [file] [log] [blame]
paul718e3742002-12-13 20:15:29 +00001/* BGP open message handling
2 Copyright (C) 1999 Kunihiro Ishiguro
3
4This file is part of GNU Zebra.
5
6GNU Zebra is free software; you can redistribute it and/or modify it
7under the terms of the GNU General Public License as published by the
8Free Software Foundation; either version 2, or (at your option) any
9later version.
10
11GNU Zebra is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU Zebra; see the file COPYING. If not, write to the Free
18Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
1902111-1307, USA. */
20
paul00d252c2005-05-23 14:19:54 +000021#ifndef _QUAGGA_BGP_OPEN_H
22#define _QUAGGA_BGP_OPEN_H
23
Paul Jakma6d582722007-08-06 15:21:45 +000024/* Standard header for capability TLV */
25struct capability_header
26{
27 u_char code;
28 u_char length;
29};
30
31/* Generic MP capability data */
32struct capability_mp_data
paul718e3742002-12-13 20:15:29 +000033{
34 u_int16_t afi;
35 u_char reserved;
36 u_char safi;
37};
38
Paul Jakma6d582722007-08-06 15:21:45 +000039#pragma pack(1)
40struct capability_orf_entry
paul718e3742002-12-13 20:15:29 +000041{
Paul Jakma6d582722007-08-06 15:21:45 +000042 struct capability_mp_data mpc;
43 u_char num;
44 struct {
45 u_char type;
46 u_char mode;
47 } orfs[];
48} __attribute__ ((packed));
49#pragma pack()
paul718e3742002-12-13 20:15:29 +000050
hasso538621f2004-05-21 09:31:30 +000051struct graceful_restart_af
52{
53 u_int16_t afi;
54 u_char safi;
55 u_char flag;
56};
paul718e3742002-12-13 20:15:29 +000057
Paul Jakma6d582722007-08-06 15:21:45 +000058struct capability_gr
59{
60 u_int16_t restart_flag_time;
61 struct graceful_restart_af gr[];
62};
63
hasso538621f2004-05-21 09:31:30 +000064/* Capability Code */
65#define CAPABILITY_CODE_MP 1 /* Multiprotocol Extensions */
66#define CAPABILITY_CODE_REFRESH 2 /* Route Refresh Capability */
67#define CAPABILITY_CODE_ORF 3 /* Cooperative Route Filtering Capability */
68#define CAPABILITY_CODE_RESTART 64 /* Graceful Restart Capability */
Paul Jakma6d582722007-08-06 15:21:45 +000069#define CAPABILITY_CODE_AS4 65 /* 4-octet AS number Capability */
hasso538621f2004-05-21 09:31:30 +000070#define CAPABILITY_CODE_DYNAMIC 66 /* Dynamic Capability */
71#define CAPABILITY_CODE_REFRESH_OLD 128 /* Route Refresh Capability(cisco) */
72#define CAPABILITY_CODE_ORF_OLD 130 /* Cooperative Route Filtering Capability(cisco) */
73
74/* Capability Length */
75#define CAPABILITY_CODE_MP_LEN 4
paul718e3742002-12-13 20:15:29 +000076#define CAPABILITY_CODE_REFRESH_LEN 0
hasso538621f2004-05-21 09:31:30 +000077#define CAPABILITY_CODE_DYNAMIC_LEN 0
78#define CAPABILITY_CODE_RESTART_LEN 2 /* Receiving only case */
Paul Jakma6d582722007-08-06 15:21:45 +000079#define CAPABILITY_CODE_AS4_LEN 4
paul718e3742002-12-13 20:15:29 +000080
81/* Cooperative Route Filtering Capability. */
paul718e3742002-12-13 20:15:29 +000082
hasso538621f2004-05-21 09:31:30 +000083/* ORF Type */
paul718e3742002-12-13 20:15:29 +000084#define ORF_TYPE_PREFIX 64
85#define ORF_TYPE_PREFIX_OLD 128
86
hasso538621f2004-05-21 09:31:30 +000087/* ORF Mode */
paul718e3742002-12-13 20:15:29 +000088#define ORF_MODE_RECEIVE 1
89#define ORF_MODE_SEND 2
90#define ORF_MODE_BOTH 3
91
paul718e3742002-12-13 20:15:29 +000092/* Capability Message Action. */
93#define CAPABILITY_ACTION_SET 0
94#define CAPABILITY_ACTION_UNSET 1
95
hasso538621f2004-05-21 09:31:30 +000096/* Graceful Restart */
97#define RESTART_R_BIT 0x8000
98#define RESTART_F_BIT 0x80
99
paul94f2b392005-06-28 12:44:16 +0000100extern int bgp_open_option_parse (struct peer *, u_char, int *);
101extern void bgp_open_capability (struct stream *, struct peer *);
102extern void bgp_capability_vty_out (struct vty *, struct peer *);
Paul Jakma6d582722007-08-06 15:21:45 +0000103extern int bgp_afi_safi_valid_indices (afi_t, safi_t *);
paul00d252c2005-05-23 14:19:54 +0000104
105#endif /* _QUAGGA_BGP_OPEN_H */