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/geniec.awk,v 1.4 2003/10/10 14:50:05 hbb Exp $
31 # Generate table for IE parsing.
33 # This function is called before the first line
36 for(i = 0; i < 256; i++) {
37 for(j = 0; j < 4; j++) {
44 # This function is called after the last line.
48 print "const struct iedecl *uni_ietable[256][4] = {"
49 for(i = 0; i < 256; i++) {
51 for(j = 0; j < 4; j++) {
55 printf " &%s,", decl[i,j]
58 printf " }, /* 0x%02x */\n", i
64 # This function is called just when the first information element was found
66 function first_element() {
67 print "/* This file was created automatically"
68 print " * Source file: " id
74 # This is called, when the information element is defaulted (there is
75 # only the name and the coding scheme
77 function element_default() {
79 print "static const struct iedecl decl_" coding "_" ie " = {"
80 print "\tUNIFL_DEFAULT,"
82 print "\t(uni_print_f)NULL,"
83 print "\t(uni_check_f)NULL,"
84 print "\t(uni_encode_f)NULL,"
85 print "\t(uni_decode_f)NULL"
87 decl[number,ncoding] = "decl_" coding "_" ie
91 # This is found for a real, non-default IE
95 print "static void uni_ie_print_" coding "_" ie "(struct uni_ie_" ie " *, struct unicx *);"
96 print "static int uni_ie_check_" coding "_" ie "(struct uni_ie_" ie " *, struct unicx *);"
97 print "static int uni_ie_encode_" coding "_" ie "(struct uni_msg *, struct uni_ie_" ie " *, struct unicx *);"
98 print "static int uni_ie_decode_" coding "_" ie "(struct uni_ie_" ie " *, struct uni_msg *, u_int, struct unicx *);"
100 print "static struct iedecl decl_" coding "_" ie " = {"
101 if(access) print "\tUNIFL_ACCESS,"
104 print "\t(uni_print_f)uni_ie_print_" coding "_" ie ","
105 print "\t(uni_check_f)uni_ie_check_" coding "_" ie ","
106 print "\t(uni_encode_f)uni_ie_encode_" coding "_" ie ","
107 print "\t(uni_decode_f)uni_ie_decode_" coding "_" ie ""
109 decl[number,ncoding] = "decl_" coding "_" ie