2 * Copyright (c) 2001-2003
3 * Fraunhofer Institute for Open Communication Systems (FhG Fokus).
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * Author: Hartmut Brandt <harti@freebsd.org>
29 * $Begemot: libunimsg/netnatm/msg/priv.h,v 1.4 2003/10/10 14:50:05 hbb Exp $
31 * Private definitions for the IE code file.
37 #include <sys/systm.h>
38 #include <machine/stdarg.h>
39 #define PANIC(X) panic X
44 #define PANIC(X) abort()
48 * Define a structure for the declaration of information elements.
49 * For each coding scheme a quadrupel of check, print, encode and
50 * decode functions must be defined. A structure of the same format
51 * is used for messages.
53 typedef void (*uni_print_f)(const union uni_ieall *, struct unicx *);
54 typedef int (*uni_check_f)(union uni_ieall *, struct unicx *);
55 typedef int (*uni_encode_f)(struct uni_msg *, union uni_ieall *,
57 typedef int (*uni_decode_f)(union uni_ieall *, struct uni_msg *, u_int,
60 typedef void (*uni_msg_print_f)(const union uni_msgall *, struct unicx *);
61 typedef int (*uni_msg_check_f)(struct uni_all *, struct unicx *);
62 typedef int (*uni_msg_encode_f)(struct uni_msg *, union uni_msgall *,
64 typedef int (*uni_msg_decode_f)(union uni_msgall *, struct uni_msg *,
65 enum uni_ietype, struct uni_iehdr *, u_int, struct unicx *);
68 u_int flags; /* information element flags */
69 u_int maxlen; /* maximum size */
79 uni_msg_print_f print;
80 uni_msg_check_f check;
81 uni_msg_encode_f encode;
82 uni_msg_decode_f decode;
86 UNIFL_DEFAULT = 0x0001,
87 UNIFL_ACCESS = 0x0002,
90 extern const struct iedecl *uni_ietable[256][4];
91 extern const struct msgdecl *uni_msgtable[256];
94 * Need to check range here because declaring a variable as a enum does not
95 * guarantee that the values will be legal.
97 #define GET_IEDECL(IE, CODING) \
99 const struct iedecl *_decl = NULL; \
101 if((CODING) <= 3 && (IE) <= 255) \
102 if((_decl = uni_ietable[IE][CODING]) != NULL) \
103 if((_decl->flags & UNIFL_DEFAULT) != 0) \
104 if((_decl = uni_ietable[IE][0]) == NULL) \
105 PANIC(("IE %02x,%02x -- no default", CODING,IE));\
116 void uni_print_ie_internal(enum uni_ietype, const union uni_ieall *,