summaryrefslogtreecommitdiffstats
path: root/lib/qafi_safi.h
blob: 99c86055cb534406a95a3b0ea31951d3c2254f34 (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
/* Quagga AFI/SAFI
 * Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Kunihiro Ishiguro
 * Copyright (C) 2009 Chris Hall (GMCH), Highwayman
 *
 * 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.
 */

#ifndef _QUAGGA_AFI_SAFI_H
#define _QUAGGA_AFI_SAFI_H

#include <stdint.h>
#include "lib/zassert.h"

/*==============================================================================
 * Generic AFI and SAFI types.
 */
typedef uint16_t afi_t;
typedef uint8_t  safi_t;

/*==============================================================================
 * iAFI and iSAFI
 *
 * These are the standard IANA registered AFI and SAFI values that Quagga is
 * at all interested in.
 */

typedef enum iAFI  iAFI_t ;

enum iAFI
{
  iAFI_Reserved    = 0,         /* No meaning defined by IANA   */

  iAFI_IP          = 1,         /* IP (IP version 4)            */
  iAFI_IP6         = 2,         /* IP6 (IP version 6)           */

  iAFI_IPV4        = iAFI_IP,   /* locally AKA                  */
  iAFI_IPV6        = iAFI_IP6   /* locally AKA                  */
} ;


typedef enum iSAFI iSAFI_t ;

enum iSAFI
{
  iSAFI_Reserved   =   0,       /* No meaning defined by IANA   */

  iSAFI_Unicast    =   1,       /* unicast forwarding           */
  iSAFI_Multicast  =   2,       /* multicast forwarding         */

  iSAFI_Unused     =   3,       /* also Reserved by IANA        */

  iSAFI_MPLS_VPN   = 128        /* MPLS-labeled VPN address     */
} ;

/*==============================================================================
 * qAFI and qSAFI
 *
 * These are the AFI and SAFI values that Quagga uses internally.
 *
 * They are almost the same as the IANA numbers, but different where that
 * is required to produce a dense set.
 */

typedef enum qAFI  qAFI_t ;

enum qAFI
{
  qAFI_min         = 0,         /* minimum valid qAFI           */
  qAFI_undef       = 0,         /* undefined AFI                */

  qAFI_first       = 1,         /* first real qAFI              */

  qAFI_IP          = 1,
  qAFI_IP6         = 2,

  qAFI_last        = 2,         /* last real qAFI               */

  qAFI_max         = 2,         /* maximum valid qAFI           */
  qAFI_count,                   /* number of distinct qAFI      */

  qAFI_IPV4        = qAFI_IP,
  qAFI_IPV6        = qAFI_IP6
} ;

typedef enum qSAFI qSAFI_t ;

enum qSAFI
{
  qSAFI_min        =   0,       /* minimum valid qSAFI          */
  qSAFI_undef      =   0,       /* undefined SAFI               */

  qSAFI_first      =   1,       /* first real qSAFI             */

  qSAFI_Unicast    =   1,
  qSAFI_Multicast  =   2,
  qSAFI_Unused     =   3,
  qSAFI_MPLS_VPN   =   4,

  qSAFI_last       =   4,       /* last real qSAFI              */

  qSAFI_max        =   4,       /* maximum valid qSAFI          */
  qSAFI_count                   /* number of distinct qSAFI     */
} ;

/*==============================================================================
 * iAFI_SAFI and qAFI_SAFI structures
 */
struct iAFI_SAFI
{
  iAFI_t   afi ;
  iSAFI_t  safi ;
} ;

typedef struct iAFI_SAFI  iAFI_SAFI_t ;
typedef struct iAFI_SAFI* iAFI_SAFI ;

struct qAFI_SAFI
{
  qAFI_t   afi ;
  qSAFI_t  safi ;
} ;

typedef struct qAFI_SAFI  qAFI_SAFI_t ;
typedef struct qAFI_SAFI* qAFI_SAFI ;

/*==============================================================================
 * POSIX address family type
 */
typedef int pAF_t ;

/*==============================================================================
 * Quagga AFI/SAFI values -- original macro definitions
 */

/* Address family numbers from RFC1700. */
#define AFI_IP                    1
#define AFI_IP6                   2
#define AFI_MAX                   3

CONFIRM( (AFI_IP  == qAFI_IP)
      && (AFI_IP  == iAFI_IP) ) ;
CONFIRM( (AFI_IP6 == qAFI_IP6)
      && (AFI_IP6 == iAFI_IP6) ) ;
CONFIRM(AFI_MAX == qAFI_count) ;

/* Subsequent Address Family Identifier. */
#define SAFI_UNICAST              1
#define SAFI_MULTICAST            2
#define SAFI_UNICAST_MULTICAST    3
#define SAFI_MPLS_VPN             4
#define SAFI_MAX                  5

CONFIRM( (SAFI_UNICAST           == qSAFI_Unicast)
      && (SAFI_UNICAST           == iSAFI_Unicast) ) ;
CONFIRM( (SAFI_MULTICAST         == qSAFI_Multicast)
      && (SAFI_MULTICAST         == iSAFI_Multicast) ) ;
CONFIRM( (SAFI_UNICAST_MULTICAST == qSAFI_Unused)
      && (SAFI_UNICAST_MULTICAST == iSAFI_Unused) ) ;
CONFIRM(SAFI_MPLS_VPN  == qSAFI_MPLS_VPN) ;
CONFIRM(SAFI_MAX       == qSAFI_count) ;

#endif /* _QUAGGA_AFI_SAFI_H */