From: Vasu Dasari <vdasari@gmail.com>
[mpls-ldp-portable.git] / common / mpls_struct.h
bloba04369bd6a022434d00ef11501b3f20294a07310
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 struct mpls_fec;
179 typedef struct mpls_nexthop {
180 short distance;
181 short metric;
182 mpls_bool attached;
184 unsigned char type;
185 struct mpls_inet_addr ip;
186 mpls_if_handle if_handle;
187 mpls_outsegment_handle outsegment_handle;
189 /* only used during gets */
190 uint32_t index;
191 } mpls_nexthop;
193 typedef struct mpls_fec {
194 enum mpls_fec_enum type;
195 union {
196 struct {
197 struct mpls_inet_addr network;
198 uint8_t length;
199 } prefix;
200 struct mpls_inet_addr host;
201 struct {
202 mpls_if_handle interface;
203 uint32_t connection_id;
204 uint32_t group_id;
205 uint8_t type;
206 } l2cc;
207 } u;
209 /* only used during gets */
210 mpls_bool is_route;
211 uint32_t index;
212 } mpls_fec;
214 typedef struct mpls_insegment {
215 struct mpls_label_struct label;
216 uint32_t npop;
217 uint32_t labelspace;
218 uint16_t family;
219 mpls_insegment_handle handle;
220 mpls_owners_enum owner;
221 } mpls_insegment;
223 typedef struct mpls_outsegment {
224 struct mpls_label_struct label;
225 mpls_bool push_label;
226 struct mpls_nexthop nexthop;
227 mpls_outsegment_handle handle;
228 mpls_owners_enum owner;
229 } mpls_outsegment;
231 typedef struct mpls_xconnect {
232 uint32_t lspid;
233 uint8_t stack_size;
234 struct mpls_label_struct stack[MPLS_MAX_LABELSTACK];
235 mpls_bool is_persistent;
236 mpls_xconnect_handle handle;
237 mpls_owners_enum owner;
238 } mpls_xconnect;
240 typedef void *mpls_cfg_handle;
242 #endif