Convert to a generic FEC handling architecture. Part of this change
[mpls-ldp-portable.git] / common / mpls_struct.h
blob080a309258ab7b989dfc1324783ac6176b554dac
2 /*
3 * Copyright (C) James R. Leu 2002
4 * jleu@mindspring.com
6 * This software is covered under the LGPL, for more
7 * info check out http://www.gnu.org/copyleft/lgpl.html
8 */
10 #ifndef _MPLS_STRUCT_H_
11 #define _MPLS_STRUCT_H_
13 #define MPLS_MAX_IF_NAME 16
14 #define MPLS_MAX_LABELSTACK 4
16 #include "mpls_handle_type.h"
17 #include "mpls_bitfield.h"
19 typedef enum {
20 MPLS_SUCCESS = 1,
21 MPLS_FAILURE,
22 MPLS_FATAL,
23 MPLS_CLOSED,
24 MPLS_NON_BLOCKING,
25 MPLS_END_OF_LIST,
26 MPLS_NO_ROUTE,
27 } mpls_return_enum;
29 typedef enum {
30 MPLS_UPDATE_ADD,
31 MPLS_UPDATE_DEL,
32 MPLS_UPDATE_MODIFY
33 } mpls_update_enum;
35 typedef enum {
36 MPLS_OPER_UP = 1,
37 MPLS_OPER_DOWN,
38 } mpls_oper_state_enum;
40 typedef enum {
41 MPLS_TIMER_ONESHOT = 1,
42 MPLS_TIMER_REOCCURRING,
43 } mpls_timer_type_enum;
45 typedef enum {
46 MPLS_UNIT_MICRO = 1,
47 MPLS_UNIT_SEC,
48 MPLS_UNIT_MIN,
49 MPLS_UNIT_HOUR
50 } mpls_time_unit_enum;
52 typedef enum {
53 MPLS_ADMIN_ENABLE = 1,
54 MPLS_ADMIN_DISABLE
55 } mpls_admin_state_enum;
57 typedef enum {
58 MPLS_LABEL_RANGE_GENERIC = 1,
59 MPLS_LABEL_RANGE_ATM_VP,
60 MPLS_LABEL_RANGE_ATM_VC,
61 MPLS_LABEL_RANGE_ATM_VP_VC,
62 MPLS_LABEL_RANGE_FR_10,
63 MPLS_LABEL_RANGE_FR_24
64 } mpls_label_range_type;
66 typedef enum {
67 MPLS_LABEL_TYPE_NONE,
68 MPLS_LABEL_TYPE_GENERIC,
69 MPLS_LABEL_TYPE_ATM,
70 MPLS_LABEL_TYPE_FR
71 } mpls_label_type;
73 typedef enum {
74 MPLS_BOOL_FALSE = 0,
75 MPLS_BOOL_TRUE = 1
76 } mpls_bool;
78 typedef enum {
79 MPLS_SOCKET_UDP_DATA = 1,
80 MPLS_SOCKET_TCP_LISTEN,
81 MPLS_SOCKET_TCP_CONNECT,
82 MPLS_SOCKET_TCP_DATA,
83 MPLS_SOCKET_ROUTE_UPDATE,
84 } mpls_socket_enum;
86 typedef enum {
87 MPLS_SOCKOP_NONBLOCK = 0x1,
88 MPLS_SOCKOP_REUSE = 0x2,
89 MPLS_SOCKOP_ROUTERALERT = 0x4,
90 MPLS_SOCKOP_HDRINCL = 0x8
91 } mpls_socket_option_type;
93 typedef enum {
94 MPLS_TRACE_STATE_SEND,
95 MPLS_TRACE_STATE_RECV,
96 MPLS_TRACE_STATE_ALL
97 } mpls_trace_states;
99 typedef enum {
100 MPLS_OWNER_LDP,
101 MPLS_OWNER_CRLDP,
102 MPLS_OWNER_STATIC,
103 MPLS_OWNER_RSVP_TE
104 } mpls_owners_enum;
106 /* this structure is slurped from GNU header files */
107 typedef struct mpls_iphdr {
108 BITFIELDS_ASCENDING_2(unsigned int ihl:4,
109 unsigned int version:4);
110 u_int8_t tos;
111 u_int16_t tot_len;
112 u_int16_t id;
113 u_int16_t frag_off;
114 u_int8_t ttl;
115 u_int8_t protocol;
116 u_int16_t check;
117 u_int32_t saddr;
118 u_int32_t daddr;
119 /*The options start here. */
120 } mpls_iphdr;
122 typedef struct mpls_label_struct {
123 mpls_label_type type;
124 union {
125 int gen;
126 struct {
127 int vpi;
128 int vci;
129 } atm;
130 struct {
131 int len;
132 int dlci;
133 } fr;
134 } u;
135 } mpls_label_struct;
137 typedef enum mpls_family_enum {
138 MPLS_FAMILY_NONE,
139 MPLS_FAMILY_IPV4,
140 MPLS_FAMILY_IPV6,
141 } mpls_family_enum;
143 typedef struct mpls_inet_addr {
144 enum mpls_family_enum type;
145 union {
146 uint8_t ipv6[16];
147 uint32_t ipv4;
148 } u;
149 } mpls_inet_addr;
151 typedef struct mpls_dest {
152 struct mpls_inet_addr addr;
153 uint16_t port;
154 mpls_if_handle if_handle;
155 } mpls_dest;
157 typedef struct mpls_range {
158 int label_space;
159 mpls_label_range_type type;
160 struct mpls_label_struct min, max;
161 } mpls_range;
163 typedef enum mpls_nexthop_enum {
164 MPLS_NH_NONE = 0x0,
165 MPLS_NH_IP = 0x1,
166 MPLS_NH_IF = 0x2,
167 MPLS_NH_OUTSEGMENT = 0x4
168 } mpls_nexthop_enum;
170 typedef enum mpls_fec_enum {
171 MPLS_FEC_NONE,
172 MPLS_FEC_PREFIX,
173 MPLS_FEC_HOST,
174 MPLS_FEC_L2CC,
175 } mpls_fec_enum;
177 typedef struct mpls_nexthop {
178 unsigned char type;
179 int distance;
180 int metric;
181 mpls_bool attached;
182 struct mpls_inet_addr ip;
183 mpls_if_handle if_handle;
184 mpls_outsegment_handle outsegment_handle;
185 } mpls_nexthop;
187 typedef struct mpls_fec {
188 enum mpls_fec_enum type;
189 union {
190 struct {
191 struct mpls_inet_addr network;
192 uint8_t length;
193 } prefix;
194 struct mpls_inet_addr host;
195 struct {
196 mpls_if_handle interface;
197 uint32_t connection_id;
198 uint32_t group_id;
199 uint8_t type;
200 } l2cc;
201 } u;
202 /* ECMP */
203 struct mpls_nexthop nh;
204 } mpls_fec;
206 typedef struct mpls_insegment {
207 struct mpls_label_struct label;
208 uint32_t npop;
209 uint32_t labelspace;
210 uint16_t family;
211 mpls_insegment_handle handle;
212 mpls_owners_enum owner;
213 } mpls_insegment;
215 typedef struct mpls_outsegment {
216 struct mpls_label_struct label;
217 mpls_bool push_label;
218 struct mpls_nexthop nexthop;
219 mpls_outsegment_handle handle;
220 mpls_owners_enum owner;
221 } mpls_outsegment;
223 typedef struct mpls_xconnect {
224 uint32_t lspid;
225 uint8_t stack_size;
226 struct mpls_label_struct stack[MPLS_MAX_LABELSTACK];
227 mpls_bool is_persistent;
228 mpls_xconnect_handle handle;
229 mpls_owners_enum owner;
230 } mpls_xconnect;
232 typedef void *mpls_cfg_handle;
234 #endif