]> The Tcpdump Group git mirrors - tcpdump/blob - forces.h
IETF FORCES protocol printer, from Jamal Hadi Salim <hadi at cyberus.ca.
[tcpdump] / forces.h
1 /*
2 * Copyright (c) 1982, 1986, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * Copyright (c) 2009 Mojatatu Networks, Inc
34 *
35 */
36
37 /*
38 * Per draft-ietf-forces-protocol-22
39 */
40 #define ForCES_VERS 1
41 #define ForCES_HDRL 24
42 #define ForCES_ALNL 4
43 #define TLV_HDRL 4
44 #define ILV_HDRL 8
45
46 #define TOM_RSVD 0x0
47 #define TOM_ASSNSETUP 0x1
48 #define TOM_ASSNTEARD 0x2
49 #define TOM_CONFIG 0x3
50 #define TOM_QUERY 0x4
51 #define TOM_EVENTNOT 0x5
52 #define TOM_PKTREDIR 0x6
53 #define TOM_HEARTBT 0x0F
54 #define TOM_ASSNSETREP 0x11
55 #define TOM_CONFIGREP 0x13
56 #define TOM_QUERYREP 0x14
57
58 /*
59 * tom_h Flags: resv1(8b):maxtlvs(4b):resv2(2b):mintlv(2b)
60 */
61 #define ZERO_TTLV 0x01
62 #define ZERO_MORE_TTLV 0x02
63 #define ONE_MORE_TTLV 0x04
64 #define ZERO_TLV 0x00
65 #define ONE_TLV 0x10
66 #define TWO_TLV 0x20
67 #define MAX_TLV 0xF0
68
69 #define TTLV_T1 (ONE_MORE_TTLV|ONE_TLV)
70 #define TTLV_T2 (ONE_MORE_TTLV|MAX_TLV)
71
72 struct tom_h {
73 u_int32_t v;
74 u_int16_t flags;
75 u_int16_t op_msk;
76 const char *s;
77 int (*print) (register const u_char * pptr, register u_int len,
78 u_int16_t op_msk, int indent);
79 };
80
81 enum {
82 TOM_RSV_I,
83 TOM_ASS_I,
84 TOM_AST_I,
85 TOM_CFG_I,
86 TOM_QRY_I,
87 TOM_EVN_I,
88 TOM_RED_I,
89 TOM_HBT_I,
90 TOM_ASR_I,
91 TOM_CNR_I,
92 TOM_QRR_I,
93 _TOM_RSV_MAX
94 };
95 #define TOM_MAX_IND (_TOM_RSV_MAX - 1)
96
97 int lfbselect_print(register const u_char * pptr, register u_int len,
98 u_int16_t op_msk, int indent);
99 int redirect_print(register const u_char * pptr, register u_int len,
100 u_int16_t op_msk, int indent);
101 int asrtlv_print(register const u_char * pptr, register u_int len,
102 u_int16_t op_msk, int indent);
103 int asttlv_print(register const u_char * pptr, register u_int len,
104 u_int16_t op_msk, int indent);
105 int gentltlv_print(register const u_char * pptr, register u_int len,
106 u_int16_t op_msk, int indent);
107
108 static inline tom_valid(u_int8_t tom)
109 {
110 if (tom > 0) {
111 if (tom >= 0x7 && tom <= 0xe)
112 return 0;
113 if (tom == 0x10)
114 return 0;
115 if (tom > 0x14)
116 return 0;
117 return 1;
118 } else
119 return 0;
120 }
121
122 static inline const char *ForCES_node(u_int32_t node)
123 {
124 if (node >= 0 && node <= 0x3FFFFFFF)
125 return "FE";
126 if (node >= 0x40000000 && node <= 0x7FFFFFFF)
127 return "CE";
128 if (node >= 0xC0000000 && node <= 0xFFFFFFEF)
129 return "AllMulticast";
130 if (node == 0xFFFFFFFD)
131 return "AllCEsBroadcast";
132 if (node == 0xFFFFFFFE)
133 return "AllFEsBroadcast";
134 if (node == 0xFFFFFFFF)
135 return "AllBroadcast";
136
137 return "ForCESreserved";
138
139 }
140
141 static inline const char *ForCES_ACKp(u_int32_t flg)
142 {
143 if (flg == 0x0)
144 return "NoACK";
145 if (flg == 0x1)
146 return "SuccessACK";
147 if (flg == 0x2)
148 return "FailureACK";
149 if (flg == 0x3)
150 return "AlwaysACK";
151 return "ACKUnknown";
152 }
153
154 static inline const char *ForCES_EMp(u_int32_t flg)
155 {
156 if (flg == 0x0)
157 return "EMReserved";
158 if (flg == 0x1)
159 return "execute-all-or-none";
160 if (flg == 0x2)
161 return "execute-until-failure";
162 if (flg == 0x3)
163 return "continue-execute-on-failure";
164 return "EMUnknown";
165 }
166
167 static inline const char *ForCES_ATp(u_int32_t flg)
168 {
169 if (flg == 0x0)
170 return "Standalone";
171 if (flg == 0x1)
172 return "2PCtransaction";
173 return "ATUnknown";
174 }
175
176 static inline const char *ForCES_TPp(u_int32_t flg)
177 {
178 if (flg == 0x0)
179 return "StartofTransaction";
180 if (flg == 0x1)
181 return "MiddleofTransaction";
182 if (flg == 0x2)
183 return "EndofTransaction";
184 if (flg == 0x3)
185 return "abort";
186 return "TPUnknown";
187 }
188
189 /*
190 * Structure of forces header, naked of TLVs.
191 */
192 struct forcesh {
193 #if BYTE_ORDER == LITTLE_ENDIAN
194 u_int8_t fm_rsvd:4, fm_version:4;
195 #elif BYTE_ORDER == BIG_ENDIAN
196 u_int8_t fm_version:4, fm_rsvd:4;
197 #endif
198
199 #define ForCES_V(forcesh) (forcesh)->fm_version
200 u_int8_t fm_tom; /* type of message */
201 u_int16_t fm_len; /* total length * 4 bytes */
202 #define ForCES_BLN(forcesh) ntohs((forcesh)->fm_len) << 2
203 u_int32_t fm_sid; /* Source ID */
204 #define ForCES_SID(forcesh) ntohl((forcesh)->fm_sid)
205 u_int32_t fm_did; /* Destination ID */
206 #define ForCES_DID(forcesh) ntohl((forcesh)->fm_did)
207 u_int8_t fm_cor[8]; /* correlator */
208 #if BYTE_ORDER == LITTLE_ENDIAN
209 u_int16_t f_rs1:3, f_pri:3, f_ack:2, f_rs2:3, f_tp:2, f_at:1, f_em:2;
210 #elif BYTE_ORDER == BIG_ENDIAN
211 u_int16_t f_ack:2, f_pri:3, f_rs1:3, f_em:2, f_at:1, f_tp:2, f_rs2:3;
212 #endif
213 u_int16_t f_rs3;
214
215 };
216
217 #define ForCES_HLN_VALID(fhl,tlen) ((tlen) >= (int)sizeof(struct forcesh) && \
218 (fhl) >= sizeof(struct forcesh) && \
219 (fhl) == (tlen))
220
221 #define F_LFB_RSVD 0x0
222 #define F_LFB_FEO 0x1
223 #define F_LFB_FEPO 0x2
224 struct tok ForCES_LFBs[] = {
225 {F_LFB_RSVD, "Invalid TLV"},
226 {F_LFB_FEO, "FEObj LFB"},
227 {F_LFB_FEPO, "FEProtoObj LFB"},
228 {0, NULL}
229 };
230
231 enum {
232 F_OP_RSV,
233 F_OP_SET,
234 F_OP_SETPROP,
235 F_OP_SETRESP,
236 F_OP_SETPRESP,
237 F_OP_DEL,
238 F_OP_DELRESP,
239 F_OP_GET,
240 F_OP_GETPROP,
241 F_OP_GETRESP,
242 F_OP_GETPRESP,
243 F_OP_REPORT,
244 F_OP_COMMIT,
245 F_OP_RCOMMIT,
246 F_OP_RTRCOMP,
247 _F_OP_MAX
248 };
249
250 #define F_OP_MAX (_F_OP_MAX - 1)
251 enum {
252 B_OP_SET = 1 << (F_OP_SET - 1),
253 B_OP_SETPROP = 1 << (F_OP_SETPROP - 1),
254 B_OP_SETRESP = 1 << (F_OP_SETRESP - 1),
255 B_OP_SETPRESP = 1 << (F_OP_SETPRESP - 1),
256 B_OP_DEL = 1 << (F_OP_DEL - 1),
257 B_OP_DELRESP = 1 << (F_OP_DELRESP - 1),
258 B_OP_GET = 1 << (F_OP_GET - 1),
259 B_OP_GETPROP = 1 << (F_OP_GETPROP - 1),
260 B_OP_GETRESP = 1 << (F_OP_GETRESP - 1),
261 B_OP_GETPRESP = 1 << (F_OP_GETPRESP - 1),
262 B_OP_REPORT = 1 << (F_OP_REPORT - 1),
263 B_OP_COMMIT = 1 << (F_OP_COMMIT - 1),
264 B_OP_RCOMMIT = 1 << (F_OP_RCOMMIT - 1),
265 B_OP_RTRCOMP = 1 << (F_OP_RTRCOMP - 1),
266 };
267
268 struct optlv_h {
269 u_int16_t flags;
270 u_int16_t op_msk;
271 const char *s;
272 int (*print) (register const u_char * pptr, register u_int len,
273 u_int16_t op_msk, int indent);
274 };
275
276 int genoptlv_print(register const u_char * pptr, register u_int len,
277 u_int16_t op_msk, int indent);
278 int recpdoptlv_print(register const u_char * pptr, register u_int len,
279 u_int16_t op_msk, int indent);
280 int invoptlv_print(register const u_char * pptr, register u_int len,
281 u_int16_t op_msk, int indent);
282
283 #define OP_MIN_SIZ 8
284 struct pathdata_h {
285 u_int16_t pflags;
286 u_int16_t pIDcnt;
287 };
288
289 #define B_FULLD 0x1
290 #define B_SPARD 0x2
291 #define B_RESTV 0x4
292 #define B_KEYIN 0x8
293
294 static struct optlv_h OPTLV_msg[F_OP_MAX + 1] = {
295 [F_OP_RSV] = {ZERO_TTLV, 0, "Invalid OPTLV", invoptlv_print},
296 [F_OP_SET] = {TTLV_T2, B_FULLD | B_SPARD, " Set", recpdoptlv_print},
297 [F_OP_SETPROP] =
298 {TTLV_T2, B_FULLD | B_SPARD, " SetProp", recpdoptlv_print},
299 [F_OP_SETRESP] = {TTLV_T2, B_RESTV, " SetResp", recpdoptlv_print},
300 [F_OP_SETPRESP] = {TTLV_T2, B_RESTV, " SetPropResp", recpdoptlv_print},
301 [F_OP_DEL] = {ZERO_TTLV, 0, " Del", recpdoptlv_print},
302 [F_OP_DELRESP] = {TTLV_T2, B_RESTV, " DelResp", recpdoptlv_print},
303 [F_OP_GET] = {ZERO_TTLV, 0, " Get", recpdoptlv_print},
304 [F_OP_GETPROP] = {ZERO_TTLV, 0, " GetProp", recpdoptlv_print},
305 [F_OP_GETRESP] =
306 {TTLV_T2, B_FULLD | B_RESTV, " GetResp", recpdoptlv_print},
307 [F_OP_GETPRESP] =
308 {TTLV_T2, B_FULLD | B_RESTV, " GetPropResp", recpdoptlv_print},
309 [F_OP_REPORT] =
310 {TTLV_T2, B_FULLD | B_SPARD, " Report", recpdoptlv_print},
311 [F_OP_COMMIT] = {ZERO_TTLV, 0, " Commit", NULL},
312 [F_OP_RCOMMIT] = {TTLV_T1, B_RESTV, " RCommit", genoptlv_print},
313 [F_OP_RTRCOMP] = {ZERO_TTLV, 0, " RTRCOMP", NULL},
314 };
315
316 static inline struct optlv_h *get_forces_optlv_h(u_int16_t opt)
317 {
318 if (opt > F_OP_MAX || opt <= F_OP_RSV)
319 return &OPTLV_msg[F_OP_RSV];
320
321 return &OPTLV_msg[opt];
322 }
323
324 #define IND_SIZE 256
325 #define IND_CHR ' '
326 #define IND_PREF '\n'
327 #define IND_SUF 0x0
328 char ind_buf[IND_SIZE];
329
330 static inline char *indent_pr(int indent, int nlpref)
331 {
332 int i = 0;
333 char *r = ind_buf;
334
335 if (indent > (IND_SIZE - 1))
336 indent = IND_SIZE - 1;
337
338 if (nlpref) {
339 r[i] = IND_PREF;
340 i++;
341 indent--;
342 }
343
344 while (--indent >= 0)
345 r[i++] = IND_CHR;
346
347 r[i] = IND_SUF;
348 return r;
349 }
350
351 static inline op_valid(u_int16_t op, u_int16_t mask)
352 {
353 int opb = 1 << (op - 1);
354
355 if (op == 0)
356 return 0;
357 if (opb & mask)
358 return 1;
359 // I guess we should allow vendor operations?
360 if (op >= 0x8000)
361 return 1;
362 return 0;
363 }
364
365 #define F_TLV_RSVD 0x0000
366 #define F_TLV_REDR 0x0001
367 #define F_TLV_ASRS 0x0010
368 #define F_TLV_ASRT 0x0011
369 #define F_TLV_LFBS 0x1000
370 #define F_TLV_PDAT 0x0110
371 #define F_TLV_KEYI 0x0111
372 #define F_TLV_FULD 0x0112
373 #define F_TLV_SPAD 0x0113
374 #define F_TLV_REST 0x0114
375 #define F_TLV_METD 0x0115
376 #define F_TLV_REDD 0x0116
377 #define F_TLV_VNST 0x8000
378
379 static struct tok ForCES_TLV[] = {
380 {F_TLV_RSVD, "Invalid TLV"},
381 {F_TLV_REDR, "REDIRECT TLV"},
382 {F_TLV_ASRS, "ASResult TLV"},
383 {F_TLV_ASRT, "ASTreason TLV"},
384 {F_TLV_LFBS, "LFBselect TLV"},
385 {F_TLV_PDAT, "PATH-DATA TLV"},
386 {F_TLV_KEYI, "KEYINFO TLV"},
387 {F_TLV_FULD, "FULLDATA TLV"},
388 {F_TLV_SPAD, "SPARSEDATA TLV"},
389 {F_TLV_REST, "RESULT TLV"},
390 {F_TLV_METD, "METADATA TLV"},
391 {F_TLV_REDD, "REDIRECTDATA TLV"},
392 {0, NULL}
393 };
394
395 #define TLV_HLN 4
396 static inline int ttlv_valid(u_int16_t ttlv)
397 {
398 if (ttlv > 0) {
399 if (ttlv == 1 || ttlv == 0x1000)
400 return 1;
401 if (ttlv >= 0x10 && ttlv <= 0x11)
402 return 1;
403 if (ttlv >= 0x110 && ttlv <= 0x116)
404 return 1;
405 if (ttlv >= 0x8000)
406 return 0; //XXX:
407 }
408
409 return 0;
410 }
411
412 struct forces_ilv {
413 u_int32_t type;
414 u_int32_t length;
415 };
416
417 struct forces_tlv {
418 u_int16_t type;
419 u_int16_t length;
420 };
421
422 #define F_ALN_LEN(len) ( ((len)+ForCES_ALNL-1) & ~(ForCES_ALNL-1) )
423 #define GET_TOP_TLV(fhdr) ((struct forces_tlv *)((fhdr) + sizeof (struct forcesh)))
424 #define TLV_SET_LEN(len) (F_ALN_LEN(sizeof(struct forces_tlv)) + (len))
425 #define TLV_ALN_LEN(len) F_ALN_LEN(TLV_SET_LEN(len))
426 #define TLV_RDAT_LEN(tlv) ((int)(ntohs((tlv)->length)) - TLV_SET_LEN(0))
427 #define TLV_DATA(tlvp) ((void*)(((char*)(tlvp)) + TLV_SET_LEN(0)))
428 #define GO_NXT_TLV(tlv,rlen) ((rlen) -= F_ALN_LEN(ntohs((tlv)->length)), \
429 (struct forces_tlv*)(((char*)(tlv)) \
430 + F_ALN_LEN(ntohs((tlv)->length))))
431 #define ILV_SET_LEN(len) (F_ALN_LEN(sizeof(struct forces_ilv)) + (len))
432 #define ILV_ALN_LEN(len) F_ALN_LEN(ILV_SET_LEN(len))
433 #define ILV_RDAT_LEN(ilv) ((int)(ntohl((ilv)->length)) - ILV_SET_LEN(0))
434 #define ILV_DATA(ilvp) ((void*)(((char*)(ilvp)) + ILV_SET_LEN(0)))
435 #define GO_NXT_ILV(ilv,rlen) ((rlen) -= F_ALN_LEN(ntohl((ilv)->length)), \
436 (struct forces_ilv *)(((char*)(ilv)) \
437 + F_ALN_LEN(ntohl((ilv)->length))))
438 #define INVALID_RLEN -1
439 #define INVALID_STLN -2
440 #define INVALID_LTLN -3
441 #define INVALID_ALEN -4
442
443 static struct tok ForCES_TLV_err[] = {
444 {INVALID_RLEN, "Invalid total length"},
445 {INVALID_STLN, "xLV too short"},
446 {INVALID_LTLN, "xLV too long"},
447 {INVALID_ALEN, "data padding missing"},
448 {0, NULL}
449 };
450
451 static inline int tlv_valid(struct forces_tlv *tlv, int rlen)
452 {
453 if (rlen < sizeof(struct forces_tlv))
454 return INVALID_RLEN;
455 if (ntohs(tlv->length) < sizeof(struct forces_tlv))
456 return INVALID_STLN;
457 if (ntohs(tlv->length) > rlen)
458 return INVALID_LTLN;
459 if (rlen < F_ALN_LEN(ntohs(tlv->length)))
460 return INVALID_ALEN;
461
462 return 0;
463 }
464
465 static inline int ilv_valid(struct forces_ilv *ilv, int rlen)
466 {
467 if (rlen < sizeof(struct forces_ilv))
468 return INVALID_RLEN;
469 if (ntohl(ilv->length) < sizeof(struct forces_ilv))
470 return INVALID_STLN;
471 if (ntohl(ilv->length) > rlen)
472 return INVALID_LTLN;
473 if (rlen < F_ALN_LEN(ntohl(ilv->length)))
474 return INVALID_ALEN;
475
476 return 0;
477 }
478
479 struct forces_lfbsh {
480 u_int32_t class;
481 u_int32_t instance;
482 };
483
484 #define ASSNS_OPS (B_OP_REPORT)
485 #define CFG_OPS (B_OP_SET|B_OP_SETPROP|B_OP_DEL|B_OP_COMMIT|B_OP_RTRCOMP)
486 #define CFG_ROPS (B_OP_SETRESP|B_OP_SETPRESP|B_OP_DELRESP|B_OP_RCOMMIT)
487 #define CFG_QY (B_OP_GET|B_OP_GETPROP)
488 #define CFG_QYR (B_OP_GETRESP|B_OP_GETPRESP)
489 #define CFG_EVN (B_OP_REPORT)
490
491 static struct tom_h ForCES_msg[TOM_MAX_IND + 1] = {
492 [TOM_RSV_I] = {TOM_RSVD, ZERO_TTLV, 0, "Invalid message", NULL},
493 [TOM_ASS_I] = {TOM_ASSNSETUP, ZERO_MORE_TTLV | TWO_TLV, ASSNS_OPS,
494 "Association Setup", lfbselect_print},
495 [TOM_AST_I] =
496 {TOM_ASSNTEARD, TTLV_T1, 0, "Association TearDown", asttlv_print},
497 [TOM_CFG_I] = {TOM_CONFIG, TTLV_T2, CFG_OPS, "Config", lfbselect_print},
498 [TOM_QRY_I] = {TOM_QUERY, TTLV_T2, CFG_QY, "Query", lfbselect_print},
499 [TOM_EVN_I] = {TOM_EVENTNOT, TTLV_T1, CFG_EVN, "Event Notification",
500 lfbselect_print},
501 [TOM_RED_I] =
502 {TOM_PKTREDIR, TTLV_T2, 0, "Packet Redirect", redirect_print},
503 [TOM_HBT_I] = {TOM_HEARTBT, ZERO_TTLV, 0, "HeartBeat", NULL},
504 [TOM_ASR_I] =
505 {TOM_ASSNSETREP, TTLV_T1, 0, "Association Response", asrtlv_print},
506 [TOM_CNR_I] = {TOM_CONFIGREP, TTLV_T2, CFG_ROPS, "Config Response",
507 lfbselect_print},
508 [TOM_QRR_I] =
509 {TOM_QUERYREP, TTLV_T2, CFG_QYR, "Query Response", lfbselect_print},
510 };
511
512 static inline struct tom_h *get_forces_tom(u_int8_t tom)
513 {
514 int i;
515 for (i = TOM_RSV_I; i <= TOM_MAX_IND; i++) {
516 struct tom_h *th = &ForCES_msg[i];
517 if (th->v == tom)
518 return th;
519 }
520 return &ForCES_msg[TOM_RSV_I];
521 }
522
523 struct pdata_ops {
524 u_int32_t v;
525 u_int16_t flags;
526 u_int16_t op_msk;
527 const char *s;
528 int (*print) (register const u_char * pptr, register u_int len,
529 u_int16_t op_msk, int indent);
530 };
531
532 enum {
533 PD_RSV_I,
534 PD_SEL_I,
535 PD_FDT_I,
536 PD_SDT_I,
537 PD_RES_I,
538 PD_PDT_I,
539 _PD_RSV_MAX
540 };
541 #define PD_MAX_IND (_TOM_RSV_MAX - 1)
542
543 static inline int pd_valid(u_int16_t pd)
544 {
545 if (pd > 0) {
546 if (pd >= F_TLV_PDAT && pd <= F_TLV_REST)
547 return 1;
548 } else
549 return 0;
550 }
551
552 static inline int chk_op_type(u_int16_t type, u_int16_t msk, u_int16_t omsk)
553 {
554 if (type != F_TLV_PDAT) {
555 if (msk & B_KEYIN) {
556 if (type != F_TLV_KEYI) {
557 printf
558 ("Based on flags expected KEYINFO TLV!\n");
559 }
560 } else {
561 if (!(msk & omsk)) {
562 printf
563 ("Illegal DATA encoding for type 0x%x programmed %x got %x \n",
564 type, omsk, msk);
565 }
566 }
567 }
568
569 }
570
571 int fdatatlv_print(register const u_char * pptr, register u_int len,
572 u_int16_t op_msk, int indent);
573 int sdatatlv_print(register const u_char * pptr, register u_int len,
574 u_int16_t op_msk, int indent);
575 int pdatatlv_print(register const u_char * pptr, register u_int len,
576 u_int16_t op_msk, int indent);
577 int pkeyitlv_print(register const u_char * pptr, register u_int len,
578 u_int16_t op_msk, int indent);
579
580 int prestlv_print(register const u_char * pptr, register u_int len,
581 u_int16_t op_msk, int indent);
582 #define F_SELKEY 1
583
584 struct res_val {
585 u_int8_t result;
586 u_int8_t resv1;
587 u_int16_t resv2;
588 };
589
590 static struct pdata_ops ForCES_pdata[PD_MAX_IND + 1] = {
591 [PD_RSV_I] = {0, 0, 0, "Invalid message", NULL},
592 [PD_SEL_I] = {F_TLV_KEYI, 0, 0, "KEYINFO TLV", pkeyitlv_print},
593 [PD_FDT_I] = {F_TLV_FULD, 0, B_FULLD, "FULLDATA TLV", fdatatlv_print},
594 [PD_SDT_I] = {F_TLV_SPAD, 0, B_SPARD, "SPARSEDATA TLV", sdatatlv_print},
595 [PD_RES_I] = {F_TLV_REST, 0, B_RESTV, "RESULT TLV", prestlv_print},
596 [PD_PDT_I] =
597 {F_TLV_PDAT, 0, 0, "Inner PATH-DATA TLV", recpdoptlv_print},
598 };
599
600 static inline struct pdata_ops *get_forces_pd(u_int16_t pd)
601 {
602 int i;
603 for (i = PD_RSV_I + 1; i <= PD_MAX_IND; i++) {
604 struct pdata_ops *pdo = &ForCES_pdata[i];
605 if (pdo->v == pd)
606 return pdo;
607 }
608 return &ForCES_pdata[TOM_RSV_I];
609 }
610
611 enum {
612 E_SUCCESS,
613 E_INVALID_HEADER,
614 E_LENGTH_MISMATCH,
615 E_VERSION_MISMATCH,
616 E_INVALID_DESTINATION_PID,
617 E_LFB_UNKNOWN,
618 E_LFB_NOT_FOUND,
619 E_LFB_INSTANCE_ID_NOT_FOUND,
620 E_INVALID_PATH,
621 E_COMPONENT_DOES_NOT_EXIST,
622 E_EXISTS,
623 E_NOT_FOUND,
624 E_READ_ONLY,
625 E_INVALID_ARRAY_CREATION,
626 E_VALUE_OUT_OF_RANGE,
627 E_CONTENTS_TOO_LONG,
628 E_INVALID_PARAMETERS,
629 E_INVALID_MESSAGE_TYPE,
630 E_INVALID_FLAGS,
631 E_INVALID_TLV,
632 E_EVENT_ERROR,
633 E_NOT_SUPPORTED,
634 E_MEMORY_ERROR,
635 E_INTERNAL_ERROR,
636 // 0x18-0xFE are reserved ..
637 E_UNSPECIFIED_ERROR = 0XFF
638 };
639
640 struct tok ForCES_errs[] = {
641 {E_SUCCESS, "SUCCESS"},
642 {E_INVALID_HEADER, "INVALID HEADER"},
643 {E_LENGTH_MISMATCH, "LENGTH MISMATCH"},
644 {E_VERSION_MISMATCH, "VERSION MISMATCH"},
645 {E_INVALID_DESTINATION_PID, "INVALID DESTINATION PID"},
646 {E_LFB_UNKNOWN, "LFB UNKNOWN"},
647 {E_LFB_NOT_FOUND, "LFB NOT FOUND"},
648 {E_LFB_INSTANCE_ID_NOT_FOUND, "LFB INSTANCE ID NOT FOUND"},
649 {E_INVALID_PATH, "INVALID PATH"},
650 {E_COMPONENT_DOES_NOT_EXIST, "COMPONENT DOES NOT EXIST"},
651 {E_EXISTS, "EXISTS ALREADY"},
652 {E_NOT_FOUND, "NOT FOUND"},
653 {E_READ_ONLY, "READ ONLY"},
654 {E_INVALID_ARRAY_CREATION, "INVALID ARRAY CREATION"},
655 {E_VALUE_OUT_OF_RANGE, "VALUE OUT OF RANGE"},
656 {E_CONTENTS_TOO_LONG, "CONTENTS TOO LONG"},
657 {E_INVALID_PARAMETERS, "INVALID PARAMETERS"},
658 {E_INVALID_MESSAGE_TYPE, "INVALID MESSAGE TYPE"},
659 {E_INVALID_FLAGS, "INVALID FLAGS"},
660 {E_INVALID_TLV, "INVALID TLV"},
661 {E_EVENT_ERROR, "EVENT ERROR"},
662 {E_NOT_SUPPORTED, "NOT SUPPORTED"},
663 {E_MEMORY_ERROR, "MEMORY ERROR"},
664 {E_INTERNAL_ERROR, "INTERNAL ERROR"},
665 {E_UNSPECIFIED_ERROR, "UNSPECIFIED ERROR"},
666 {0, NULL}
667 };