Virgin import of NgATM shared kernel/user part 0.91

This commit is contained in:
Hartmut Brandt 2003-11-03 09:05:49 +00:00
parent f0be771edd
commit 3224b86e51
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/vendor-sys/ngatm/dist/; revision=121934
20 changed files with 11628 additions and 0 deletions

View File

@ -0,0 +1,42 @@
/*
* Copyright (c) 1996-2003
* Fraunhofer Institute for Open Communication Systems (FhG Fokus).
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* Author: Hartmut Brandt <harti@freebsd.org>
*
* $Begemot: libunimsg/atm/addr.h,v 1.2 2003/09/19 13:10:35 hbb Exp $
*/
#ifndef _NETNATM_ADDR_H_
#define _NETNATM_ADDR_H_
int uni_str2nsap(u_char *, const char *);
void uni_nsap2str(char *, const u_char *, int);
void uni_prefix2str(char *, const u_char *, u_int, int);
int uni_e1642nsap(u_char *, const char *);
int uni_nsap2e164(char *, const u_char *, int);
#endif

View File

@ -0,0 +1,15 @@
#!/bin/sh
# Copyright (c) 2003
# Fraunhofer Institute for Open Communication Systems (FhG Fokus).
# All rights reserved.
#
# $Begemot: libunimsg/atm/genfiles,v 1.3 2003/09/19 11:51:57 hbb Exp $
#
# Author: Harti Brandt <harti@freebsd.org>
#
awk -f ${SRC}msg/parseie.awk -f ${SRC}msg/geniec.awk ${SRC}msg/ie.def >${DST}msg/uni_ietab.h
awk -f ${SRC}msg/parseie.awk -f ${SRC}msg/genieh.awk ${SRC}msg/ie.def >${DST}msg/uni_ie.h
awk -f ${SRC}msg/parsemsg.awk -f ${SRC}msg/genmsgc.awk ${SRC}msg/msg.def >${DST}msg/uni_msg.c
awk -f ${SRC}msg/parsemsg.awk -f ${SRC}msg/genmsgh.awk ${SRC}msg/msg.def >${DST}msg/uni_msg.h
# awk -f ${SRC}msg/parsemsg.awk -f ${SRC}sig/genmsgcpyh.awk ${SRC}msg/msg.def >${DST}sig/unimsgcpy.h
# awk -f ${SRC}msg/parsemsg.awk -f ${SRC}sig/genmsgcpyc.awk ${SRC}msg/msg.def >${DST}sig/sig_unimsgcpy.c

View File

@ -0,0 +1,235 @@
/*
* Copyright (c) 1996-2003
* Fraunhofer Institute for Open Communication Systems (FhG Fokus).
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* Author: Hartmut Brandt <harti@freebsd.org>
*
* $Begemot: libunimsg/atm/misc/straddr.c,v 1.3 2003/09/19 12:05:45 hbb Exp $
*/
#include <sys/types.h>
#ifdef _KERNEL
#include <sys/ctype.h>
#include <sys/libkern.h>
#else
#include <ctype.h>
#include <string.h>
#endif
#include <netnatm/addr.h>
/*
* Convert an NSAP address from the ASCII format to the binary.
* ASCII format means each byte formatted as a 2-byte hex number
* with dots freely interspersed between the bytes.
* If the conversion is succesful, the function returns 0, -1
* on conversion errors.
*/
int
uni_str2nsap(u_char *out, const char *in)
{
int i;
int c;
for(i = 0; i < 20; i++) {
while((c = *in++) == '.')
;
if(!isascii(c) || !isxdigit(c))
return -1;
out[i] = isdigit(c) ? (c - '0')
: islower(c) ? (c - 'a' + 10)
: (c - 'A' + 10);
out[i] <<= 4;
c = *in++;
if(!isascii(c) || !isxdigit(c))
return -1;
out[i] |= isdigit(c) ? (c - '0')
: islower(c) ? (c - 'a' + 10)
: (c - 'A' + 10);
}
return *in != '\0';
}
/*
* Parse an emebedded E.164 NSAP address.
* If check is 0, the contents of the last 11 bytes are ignored
* If check is 1, the contents of all of these but the selector byte
* are checked to be zero. If check is 2 all 11 bytes must be 0.
*/
int
uni_nsap2e164(char *e164, const u_char *nsap, int check)
{
char *p = e164;
u_int d;
int i;
if(nsap[0] != 0x45)
return -1;
if((nsap[8] & 0xf) != 0xf)
return -1;
for(i = 1; i <= 7; i++) {
d = (nsap[i] >> 4) & 0xf;
if(d == 0x00 && p == e164)
continue;
if(d >= 0xa)
return -1;
*p++ = d + '0';
d = nsap[i] & 0xf;
if(d == 0x00 && p == e164)
continue;
if(d >= 0xa)
return -1;
*p++ = d + '0';
}
d = (nsap[i] >> 4) & 0xf;
if(d != 0x00 || p == e164) {
if(d >= 0xa)
return -1;
*p++ = d + '0';
}
if(p == e164)
return -1;
*p++ = 0;
if(check == 0)
return 0;
while(i < ((check == 1) ? 19 : 20)) {
if(nsap[i] != 0x00)
return -1;
i++;
}
return 0;
}
/*
* Convert a binary representation to ASCII. The standard formats are
* recognized and dotted. Non-standard formats get no dots altogether.
*/
void
uni_prefix2str(char *out, const u_char *in, u_int len, int dotit)
{
static char hex[16] = "0123456789abcdef";
static int fmt[3][6] = {
{ 1, 2, 10, 6, 1, 0 },
{ 1, 2, 10, 6, 1, 0 },
{ 1, 8, 4, 6, 1, 0 },
};
int f, b;
u_int i;
if (len > 20)
len = 20;
if(dotit) {
switch(*in) {
case 0x39: /* DCC */
i = 0;
fmt:
for(f = 0; fmt[i][f]; f++) {
if (len == 0)
goto done;
if(f != 0)
*out++ = '.';
for(b = 0; b < fmt[i][f]; b++) {
if (len-- == 0)
goto done;
*out++ = hex[(*in >> 4) & 0xf];
*out++ = hex[*in & 0xf];
in++;
}
}
done:
*out = '\0';
return;
case 0x47: /* ICD */
i = 1;
goto fmt;
case 0x45: /* E.164 */
i = 2;
goto fmt;
}
}
/* undotted */
for(i = 0; i < len; i++) {
*out++ = hex[(*in >> 4) & 0xf];
*out++ = hex[*in & 0xf];
in++;
}
*out = '\0';
}
void
uni_nsap2str(char *out, const u_char *in, int dotit)
{
uni_prefix2str(out, in, 20, dotit);
}
/*
* Make an embedded E.164 NSAP address from a NSAP address.
* The E.164 address is a string of digits, at least one digit and
* not more than 15 digits long. The NSAP address will start with
* byte 0x45 and then a 8 byte field, which contains the right
* justified E.164 address in BCD coding, filled with a 0xf to the
* right. The rest of the address is zero.
* The function returns 0 if everything is ok, -1 in case of a wrong
* E.164 address.
*/
int
uni_e1642nsap(u_char *nsap, const char *e164)
{
size_t len;
int fill;
u_int i;
if((len = strlen(e164)) > 15 || len == 0)
return -1;
for(i = 0; i < len; i++)
if(!isdigit(e164[i]))
return -1;
*nsap++ = 0x45;
fill = (15 - len) / 2;
while(fill--)
*nsap++ = 0x00;
if((len & 1) == 0) {
*nsap++ = *e164++ - '0';
len--;
}
while(len > 1) {
len -= 2;
*nsap = (*e164++ - '0') << 4;
*nsap++ |= *e164 - '0';
}
*nsap++ = ((*e164++ - '0') << 4) | 0xf;
for(fill = 0; fill < 11; fill++)
*nsap++ = 0;
return 0;
}

View File

@ -0,0 +1,110 @@
#
# Copyright (c) 2001-2003
# Fraunhofer Institute for Open Communication Systems (FhG Fokus).
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# Author: Hartmut Brandt <harti@freebsd.org>
#
# $Begemot: libunimsg/atm/msg/geniec.awk,v 1.3 2003/09/19 11:58:15 hbb Exp $
#
# Generate table for IE parsing.
#
# This function is called before the first line
#
function begin() {
for(i = 0; i < 256; i++) {
for(j = 0; j < 4; j++) {
decl[i,j] = ""
}
}
}
#
# This function is called after the last line.
#
function end() {
print ""
print "const struct iedecl *uni_ietable[256][4] = {"
for(i = 0; i < 256; i++) {
printf "\t{"
for(j = 0; j < 4; j++) {
if(decl[i,j] == "") {
printf " NULL,"
} else {
printf " &%s,", decl[i,j]
}
}
printf " }, /* 0x%02x */\n", i
}
print "};"
}
#
# This function is called just when the first information element was found
#
function first_element() {
print "/* This file was created automatically"
print " * Source file: " id
print " */"
print ""
}
#
# This is called, when the information element is defaulted (there is
# only the name and the coding scheme
#
function element_default() {
print ""
print "static const struct iedecl decl_" coding "_" ie " = {"
print "\tUNIFL_DEFAULT,"
print "\t0,"
print "\t(uni_print_f)NULL,"
print "\t(uni_check_f)NULL,"
print "\t(uni_encode_f)NULL,"
print "\t(uni_decode_f)NULL"
print "};"
decl[number,ncoding] = "decl_" coding "_" ie
}
#
# This is found for a real, non-default IE
#
function element() {
print ""
print "static void uni_ie_print_" coding "_" ie "(struct uni_ie_" ie " *, struct unicx *);"
print "static int uni_ie_check_" coding "_" ie "(struct uni_ie_" ie " *, struct unicx *);"
print "static int uni_ie_encode_" coding "_" ie "(struct uni_msg *, struct uni_ie_" ie " *, struct unicx *);"
print "static int uni_ie_decode_" coding "_" ie "(struct uni_ie_" ie " *, struct uni_msg *, u_int, struct unicx *);"
print ""
print "static struct iedecl decl_" coding "_" ie " = {"
if(access) print "\tUNIFL_ACCESS,"
else print "\t0,"
print "\t" len ","
print "\t(uni_print_f)uni_ie_print_" coding "_" ie ","
print "\t(uni_check_f)uni_ie_check_" coding "_" ie ","
print "\t(uni_encode_f)uni_ie_encode_" coding "_" ie ","
print "\t(uni_decode_f)uni_ie_decode_" coding "_" ie ""
print "};"
decl[number,ncoding] = "decl_" coding "_" ie
}

View File

@ -0,0 +1,61 @@
#
# Copyright (c) 2001-2003
# Fraunhofer Institute for Open Communication Systems (FhG Fokus).
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# Author: Hartmut Brandt <harti@freebsd.org>
#
# $Begemot: libunimsg/atm/msg/genieh.awk,v 1.3 2003/09/19 11:58:15 hbb Exp $
#
# Generate IE header file
#
function begin() {
}
function first_element() {
print "/* This file was created automatically"
print " * Source file: " id
print " */"
print ""
print "#ifndef _NETNATM_MSG_UNI_IE_H_"
print "#define _NETNATM_MSG_UNI_IE_H_"
print ""
print "union uni_ieall {"
print " struct uni_iehdr h;"
}
function end() {
print "};"
print ""
print "#endif"
}
function element_default() {
}
function element() {
if(ie in u) return
u[ie] = 1
print " struct uni_ie_" ie " " ie ";"
}

View File

@ -0,0 +1,274 @@
#
# Copyright (c) 2001-2003
# Fraunhofer Institute for Open Communication Systems (FhG Fokus).
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# Author: Hartmut Brandt <harti@freebsd.org>
#
# $Begemot: libunimsg/atm/msg/genmsgc.awk,v 1.3 2003/09/19 11:58:15 hbb Exp $
#
# Generate message functions.
#
function begin() {
}
function first_entry() {
print "/* This file was created automatically"
print " * Source file: " id
print " */"
print ""
print "#include <sys/types.h>"
print "#include <sys/param.h>"
print ""
print "#ifdef _KERNEL"
print "#include <sys/libkern.h>"
print "#else"
print "#include <string.h>"
print "#endif"
print "#include <netnatm/unimsg.h>"
print "#include <netnatm/msg/unistruct.h>"
print "#include <netnatm/msg/unimsglib.h>"
print "#include <netnatm/msg/priv.h>"
print "#include <netnatm/msg/privmsg.c>"
}
function end() {
print ""
print "const struct msgdecl *uni_msgtable[256] = {"
for(i = 0; i < 256; i++) {
if(decl[i] == "") {
printf "\t&decl_unknown,"
} else {
printf "\t&%s,", decl[i]
}
printf "\t/* 0x%02x */\n", i
}
print "};"
}
function start_message() {
}
function end_message() {
gen_print()
gen_check()
gen_encode()
gen_decode()
gen_reg()
}
function gen_print() {
print ""
print "static void"
print "print_" msg "(struct uni_" msg " *msg, struct unicx *cx)"
print "{"
if(msgrep) {
print "\tu_int i;"
print ""
}
for(i = 0; i < cnt; i++) {
ie = iename[i]
uie = toupper(iename[i])
if(ierep[i]) {
print "\tif(msg->" ie "_repeat.h.present & UNI_IE_PRESENT)"
print "\t\tuni_print_ie_internal(UNI_IE_REPEAT, (union uni_ieall *)&msg->" ie "_repeat, cx);"
}
if(ienum[i] == "-") {
print "\tif(msg->" ie ".h.present & UNI_IE_PRESENT)"
print "\t\tuni_print_ie_internal(UNI_IE_" uie ", (union uni_ieall *)&msg->" ie ", cx);"
} else {
print "\tfor(i = 0; i < " ienum[i] "; i++)"
print "\t\tif(msg->" ie "[i].h.present & UNI_IE_PRESENT)"
print "\t\t\tuni_print_ie_internal(UNI_IE_" uie ", (union uni_ieall *)&msg->" ie "[i], cx);"
}
}
print "}"
}
function gen_check() {
print ""
print "static int"
print "check_" msg "(struct uni_" msg " *m, struct unicx *cx)"
print "{"
print "\tint ret = 0;"
if(msgrep) {
print "\tu_int i;"
}
print ""
for(i = 0; i < cnt; i++) {
ie = iename[i]
if(ierep[i]) {
if(iecond[i] == "1") {
print "\tret |= uni_check_ie(UNI_IE_REPEAT, (union uni_ieall *)&m->" ie "_repeat, cx);"
} else {
print "\tif(!(" iecond[i] "))"
print "\t\tret |= IE_ISPRESENT(m->" ie "_repeat);"
print "\telse"
print "\t\tret |= uni_check_ie(UNI_IE_REPEAT, (union uni_ieall *)&m->" ie "_repeat, cx);"
}
}
if(ienum[i] == "-") {
if(iecond[i] == "1") {
print "\tret |= uni_check_ie(UNI_IE_" toupper(ie) ", (union uni_ieall *)&m->" ie ", cx);"
} else {
print "\tif(!(" iecond[i] "))"
print "\t\tret |= IE_ISPRESENT(m->" ie ");"
print "\telse"
print "\t\tret |= uni_check_ie(UNI_IE_" toupper(ie) ", (union uni_ieall *)&m->" ie ", cx);"
}
} else {
print "\tfor(i = 0; i < " ienum[i]" ; i++) {"
if(iecond[i] == "1") {
print "\t\tret |= uni_check_ie(UNI_IE_" toupper(ie) ", (union uni_ieall *)&m->" ie "[i], cx);"
} else {
print "\t\tif(!(" iecond[i] "))"
print "\t\t\tret |= IE_ISPRESENT(m->" ie "[i]);"
print "\t\telse"
print "\t\t\tret |= uni_check_ie(UNI_IE_" toupper(ie) ", (union uni_ieall *)&m->" ie "[i], cx);"
}
print "\t}"
}
}
print ""
print "\treturn ret;"
print "}"
}
function gen_encode() {
print ""
print "static int"
print "encode_" msg "(struct uni_msg *msg, struct uni_" msg " *p, struct unicx *cx)"
print "{"
print "\tu_int mlen;"
if(msgrep) {
print "\tu_int i;"
}
print ""
print "\tif(uni_encode_msg_hdr(msg, &p->hdr, UNI_" toupper(msg) ", cx, &mlen))"
print "\t\treturn (-2);"
print ""
for(i = 0; i < cnt; i++) {
ie = iename[i]
if(ierep[i]) {
print "\tif((p->" ie "_repeat.h.present & UNI_IE_PRESENT) &&"
print "\t uni_encode_ie(UNI_IE_" toupper(ie) ", msg, (union uni_ieall *)&p->" ie "_repeat, cx))"
print "\t\treturn (0x10000000 + UNI_IE_" toupper(ie) ");"
}
if(ienum[i] == "-") {
print "\tif((p->" ie ".h.present & UNI_IE_PRESENT) &&"
print "\t uni_encode_ie(UNI_IE_" toupper(ie) ", msg, (union uni_ieall *)&p->" ie ", cx))"
print "\t\treturn (UNI_IE_" toupper(ie) ");"
} else {
print "\tfor(i = 0; i < " ienum[i] "; i++)"
print "\t\tif((p->" ie "[i].h.present & UNI_IE_PRESENT) &&"
print "\t\t uni_encode_ie(UNI_IE_" toupper(ie) ", msg, (union uni_ieall *)&p->" ie "[i], cx))"
print "\t\treturn ((i << 16) + UNI_IE_" toupper(ie) ");"
}
}
print ""
print "\tmsg->b_buf[mlen+0] = ((msg->b_wptr-msg->b_rptr)-mlen-2) >> 8;"
print "\tmsg->b_buf[mlen+1] = ((msg->b_wptr-msg->b_rptr)-mlen-2) >> 0;"
print ""
print "\treturn (0);"
print "}"
}
function gen_decode() {
print ""
print "static int"
print "decode_" msg "(struct uni_" msg " *out, struct uni_msg *msg,"
print " enum uni_ietype ie, struct uni_iehdr *hdr, u_int ielen,"
print " struct unicx *cx)"
print "{"
if (msgrep) {
print " u_int i;"
print ""
}
print " switch (ie) {"
rep=0
for (i = 0; i < cnt; i++) {
ie = iename[i]
print ""
print " case UNI_IE_" toupper(ie) ":"
if (iecond[i] != "1") {
print " if (!(" iecond[i] "))"
print " return (DEC_ILL);"
}
if (ierep[i]) {
rep=1
print " if (IE_ISPRESENT(cx->repeat))"
print " out->" ie "_repeat = cx->repeat;"
}
if (ienum[i] == "-") {
print " out->" ie ".h = *hdr;"
print " if (hdr->present & UNI_IE_ERROR)"
print " return (DEC_ERR);"
print " if(uni_decode_ie_body(UNI_IE_"toupper(ie)", (union uni_ieall *)&out->"ie", msg, ielen, cx))"
print " return (DEC_ERR);"
} else {
print " for(i = 0; i < " ienum[i] "; i++)"
print " if (!IE_ISPRESENT(out->" ie "[i])) {"
print " out->" ie "[i].h = *hdr;"
print " if (hdr->present & UNI_IE_ERROR)"
print " return (DEC_ERR);"
print " if(uni_decode_ie_body(UNI_IE_"toupper(ie)", (union uni_ieall *)&out->"ie"[i], msg, ielen, cx))"
print " return (DEC_ERR);"
print " break;"
print " }"
}
print " break;"
}
if(rep) {
print ""
print " case UNI_IE_REPEAT:"
print " cx->repeat.h = *hdr;"
print " if (hdr->present & UNI_IE_ERROR)"
print " return (DEC_ERR);"
print " if (uni_decode_ie_body(UNI_IE_REPEAT, (union uni_ieall *)&cx->repeat, msg, ielen, cx))"
print " return (DEC_ERR);"
print " break;"
}
print ""
print " default:"
print " return (DEC_ILL);"
print " }"
print " return (DEC_OK);"
print "}"
}
function gen_reg() {
print ""
print "static const struct msgdecl decl_" msg " = {"
print "\t0,"
print "\t\"" msg "\","
print "\t(uni_msg_print_f)print_" msg ","
print "\t(uni_msg_check_f)check_" msg ","
print "\t(uni_msg_encode_f)encode_" msg ","
print "\t(uni_msg_decode_f)decode_" msg
print "};"
decl[code] = "decl_" msg
}

View File

@ -0,0 +1,80 @@
#
# Copyright (c) 2001-2003
# Fraunhofer Institute for Open Communication Systems (FhG Fokus).
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# Author: Hartmut Brandt <harti@freebsd.org>
#
# $Begemot: libunimsg/atm/msg/genmsgh.awk,v 1.3 2003/09/19 11:58:15 hbb Exp $
#
# Generate message header
#
function begin() {
}
function first_entry() {
print "/* This file was created automatically"
print " * Source file: " id
print " */"
print ""
print "#ifndef _NETNATM_MSG_UNI_MSG_H_"
print "#define _NETNATM_MSG_UNI_MSG_H_"
}
function end() {
print ""
print "union uni_msgall {"
print "\tstruct uni_msghdr\thdr;"
for(i = 0; i < mcnt; i++) {
m = messages[i]
if(msgcond[i] == "") {
print "\tstruct uni_" m "\t" m ";"
} else {
print "\tstruct uni_" m "\t" m ";\t/* " msgcond[i] " */"
}
}
print "};"
print ""
print "#endif"
}
function start_message() {
}
function end_message() {
print ""
print "struct uni_" msg " {"
print "\tstruct uni_msghdr\thdr;"
for(i = 0; i < cnt; i++) {
if(ierep[i]) {
print "\tstruct uni_ie_repeat\t" iename[i] "_repeat;"
}
if(ienum[i] != "-") {
print "\tstruct uni_ie_" iename[i] "\t" iename[i] "[" ienum[i] "];"
} else {
print "\tstruct uni_ie_" iename[i] "\t" iename[i] ";"
}
}
print "};"
}

View File

@ -0,0 +1,84 @@
#
# Copyright (c) 2001-2003
# Fraunhofer Institute for Open Communication Systems (FhG Fokus).
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# Author: Hartmut Brandt <harti@freebsd.org>
#
# $Begemot: libunimsg/atm/msg/ie.def,v 1.3 2003/09/19 11:58:15 hbb Exp $
#
# Define information elements --- no content definition
#
#########################################################################
element cause 0x08 itu 34
element cause 0x08 net 34
element callstate 0x14 itu 5
element facility 0x1c itu UNI_FACILITY_MAXAPDU+1+4 q2932
element notify 0x27 itu UNI_NOTIFY_MAXLEN+4
element eetd 0x42 itu 11
element eetd 0x42 net 13
element conned 0x4c itu 25 file=addr
element connedsub 0x4d itu 25 access file=addr
element epref 0x54 itu 7
element epstate 0x55 itu 5
element aal 0x58 itu 21 access
element traffic 0x59 itu 30
element traffic 0x59 net
element connid 0x5a itu 9
element qos 0x5c itu 6
element qos 0x5c net 6
element bhli 0x5d itu 13 access
element bearer 0x5e itu 7
element blli 0x5f itu 17 access
element lshift 0x60 itu 5 0 file=shift
element nlshift 0x61 itu 5 0 file=shift
element scompl 0x62 itu 5 !pnni
element repeat 0x63 itu 5
element calling 0x6c itu 26 file=addr
element callingsub 0x6d itu 25 access file=addr
element called 0x70 itu 25 file=addr
element calledsub 0x71 itu 25 access file=addr
element tns 0x78 itu 9
element tns 0x78 net
element restart 0x79 itu 5
element uu 0x7e itu UNI_UU_MAXLEN+4 access !pnni
element git 0x7f net 33
element mintraffic 0x81 itu 20 file=traffic
element mintraffic 0x81 net
element atraffic 0x82 itu 30 file=traffic
element atraffic 0x82 net
element abrsetup 0x84 net 36 file=abr
element report 0x89 itu 5
element called_soft 0xe0 net 11 file=soft pnni
element crankback 0xe1 net 72 pnni
element dtl 0xe2 net UNI_DTL_LOGNP_SIZE*UNI_DTL_MAXNUM+6 pnni
element calling_soft 0xe3 net 10 file=soft pnni
element abradd 0xe4 net 14 file=abr
element lij_callid 0xe8 net 9 file=lij !pnni
element lij_param 0xe9 net 5 file=lij !pnni
element lij_seqno 0xea net 8 file=lij !pnni
element cscope 0xeb net 6
element exqos 0xec net 25
element mdcr 0xf0 net 13 file=traffic
element unrec 0xfe itu 128

View File

@ -0,0 +1,582 @@
#
# Copyright (c) 2001-2003
# Fraunhofer Institute for Open Communication Systems (FhG Fokus).
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# Author: Hartmut Brandt <harti@freebsd.org>
#
# $Begemot: libunimsg/atm/msg/msg.def,v 1.3 2003/09/19 11:58:15 hbb Exp $
#
# Define message contents
#
#########################################################################
#
# ALERTING message
#
# References:
# Q.2931 8, 17*
# ...A4 4, 11*
# Q.2957 3
# Q.2971 6
# UNI4.0 5
# PNNI1.0 177...178, 184*
#
# Notes:
# N-ISDN compatiblity not implemented.
#
start alerting 0x01
connid - !pnni
epref
notify
git UNI_NUM_IE_GIT
uu - !pnni
report - !pnni
unrec
end
#########################################################################
#
# CALL PROCEEDING message
#
# References:
# Q.2931 9, 18*
# Q.2971 6
# UNI4.0 5
# PNNI1.0 178
#
# Notes:
# N-ISDN compatiblity not implemented.
#
start call_proc 0x02
connid
epref
notify - !pnni
unrec
end
#########################################################################
#
# CONNECT message
#
# References:
# Q.2931 p. 10, 19*
# ...A4 6, 12*
# Q.2932.1 p. 17
# Q.2951 p. 30
# Q.2957 p. 4
# Q.2962 p. 3
# Q.2971 p. 7
# UNI4.0 p. 5-6, 61, 68, 77
# PNNI1.0 pp. 178...179, 184...185*
#
# Notes:
# N-ISDN compatiblity not implemented.
#
start connect 0x07
aal
blli
connid - !pnni
epref
notify
conned
connedsub
eetd
git UNI_NUM_IE_GIT
uu - !pnni
traffic
exqos
facility - q2932
abrsetup
abradd
called_soft - pnni
report - !pnni
unrec
end
#########################################################################
#
# CONNECT ACKNOWLEDGE message
#
# References:
# Q.2931 11
#
start connect_ack 0x0f !pnni
notify
unrec
end
#########################################################################
#
# RELEASE message
#
# References:
# Q.2931 p. 11, 22*
# Q.2932.1 p. 18
# Q.2957 p. 4
# Q.2962 p. 3
# UNI4.0 p. 6
# PNNI1.0 pp. 179...180, 185...186*
#
# Notes:
# N-ISDN compatiblity not implemented.
#
start release 0x4d
cause 2
notify
git UNI_NUM_IE_GIT
uu - !pnni
facility - q2932
crankback - pnni
unrec
end
#########################################################################
#
# RELEASE COMPLETE message
#
# References:
# Q.2931 p. 12
# UNI4.0 p. 6
# PNNI1.0 p. 180
#
start release_compl 0x5a
cause 2
git UNI_NUM_IE_GIT !pnni
uu - !pnni
crankback - pnni
unrec
end
#########################################################################
#
# SETUP message
#
# References:
# Q.2931 13-14, 23-24*
# ...A4 7-9, 13-16*
# Q.2957 5
# Q.2962 3
# Q.2971 7
# UNI4.0 6-7, 43, 57*, 60-61, 68-69, 78
# PNNI1.0 180...182, 186*
# af-cs-0147.000
#
# Notes:
#
start setup 0x05
aal
traffic
bearer
bhli
blli UNI_NUM_IE_BLLI/R
called
calledsub UNI_NUM_IE_CALLEDSUB
calling
callingsub UNI_NUM_IE_CALLINGSUB
connid
qos
eetd
notify
scompl - !pnni
tns UNI_NUM_IE_TNS
epref
atraffic
mintraffic
uu - !pnni
git UNI_NUM_IE_GIT
lij_callid - !pnni
lij_param - !pnni
lij_seqno - !pnni
exqos
abrsetup
abradd
cscope
calling_soft - pnni
called_soft - pnni
dtl UNI_NUM_IE_DTL/R pnni
report - !pnni
mdcr
unrec
end
#########################################################################
#
# STATUS message
#
# References:
# Q.2931 p. 14
# Q.2971 p. 8
# PNNI1.0 p. 182
#
start status 0x7d
callstate
cause
epref
epstate
unrec
end
#########################################################################
#
# STATUS ENQUIRY message
#
# References:
# Q.2931 p. 15
# Q.2971 p. 8
# PNNI1.0 pp. 182...183
#
start status_enq 0x75
epref
unrec
end
#########################################################################
#
# NOTIFY message
#
# References:
# Q.2931 p. 15
# Q.2971 p. 8
# PNNI1.0 p. 183
#
start notify 0x6e
notify
epref
unrec
end
#########################################################################
#
# RESTART message
#
# References:
# Q.2931 p. 26
# UNI4.0 p. 7
# PNNI1.0 pp. 186...187
#
start restart 0x46
connid
restart
unrec
end
#########################################################################
#
# RESTART ACKNOWLEDGE message
#
# References:
# Q.2931 p. 26
# UNI4.0 p. 7
# PNNI1.0 p. 187
#
start restart_ack 0x4e
connid
restart
unrec
end
#########################################################################
#
# ADD PARTY message
#
# References:
# Q.2971 10, 47
# UNI4.0 39, 43-44
# PNNI1.0 188...189
#
# Notes:
#
start add_party 0x80
aal
bhli
blli
called
calledsub UNI_NUM_IE_CALLEDSUB
calling
callingsub UNI_NUM_IE_CALLINGSUB
scompl - !pnni
tns UNI_NUM_IE_TNS
epref
notify
eetd
uu - !pnni
git UNI_NUM_IE_GIT
lij_seqno - !pnni
calling_soft - pnni
called_soft - pnni
dtl UNI_NUM_IE_DTL/R pnni
unrec
end
#########################################################################
#
# ADD PARTY ACKNOWLEDGE message
#
# References:
# Q.2971 10, 42, 47
# UNI4.0 39
# PNNI1.0 189
#
# Notes:
#
start add_party_ack 0x81
epref
aal
blli
notify
eetd
conned
connedsub
uu - !pnni
git UNI_NUM_IE_GIT
called_soft - pnni
unrec
end
#########################################################################
#
# PARTY ALERTING message
#
# References:
# Q.2971 12, 49
# UNI4.0 39
# PNNI1.0 189...190
#
# Notes:
#
start party_alerting 0x85
epref
notify
uu - !pnni
git UNI_NUM_IE_GIT
unrec
end
#########################################################################
#
# ADD PARTY REJECT message
#
# References:
# Q.2971 12, 48
# UNI4.0 40
# PNNI1.0 190
#
# Notes:
#
start add_party_rej 0x82
cause
epref
uu - !pnni
git UNI_NUM_IE_GIT
crankback - pnni
unrec
end
#########################################################################
#
# DROP PARTY message
#
# References:
# Q.2971 13, 48
# UNI4.0 40
# PNNI1.0 191
#
# Notes:
#
start drop_party 0x83
cause
epref
notify
uu - !pnni
git UNI_NUM_IE_GIT
unrec
end
#########################################################################
#
# DROP PARTY ACKNOWLEDGE message
#
# References:
# Q.2971 13, 49
# UNI4.0 40
# PNNI1.0 191
#
# Notes:
#
start drop_party_ack 0x84
epref
cause
uu - !pnni
git UNI_NUM_IE_GIT
unrec
end
#########################################################################
#
# LEAF SETUP REQUEST message
#
# References:
# UNI4.0 45...46
#
# Notes:
#
start leaf_setup_req 0x91 !pnni
tns UNI_NUM_IE_TNS
calling
callingsub UNI_NUM_IE_CALLINGSUB
called
calledsub UNI_NUM_IE_CALLEDSUB
lij_callid
lij_seqno
unrec
end
#########################################################################
#
# LEAF SETUP FAIL message
#
# References:
# UNI4.0 45...46
#
# Notes:
#
start leaf_setup_fail 0x90 !pnni
cause
called
calledsub
lij_seqno
tns UNI_NUM_IE_TNS
unrec
end
#########################################################################
#
# CO-BI SETUP message
#
# References:
# Q.2932.1 16
#
# Notes:
#
start cobisetup 0x15 !pnni&&q2932
facility
called
calledsub
calling
notify
unrec
end
#########################################################################
#
# FACILITY message
#
# References:
# Q.2932.1 14...15
#
# Notes:
#
start facility 0x62 !pnni&&q2932
facility
called
calledsub
calling
notify
unrec
end
#########################################################################
#
# MODIFY REQUEST message
#
# References:
# Q.2963.1 p. 6
# Q.2963.4 p. 4
# UNI4.0-MFY p. 3
#
start modify_req 0x88 !pnni
traffic
atraffic
mintraffic
notify
git UNI_NUM_IE_GIT
unrec
end
#########################################################################
#
# MODIFY ACKNOWLEDGE message
#
# References:
# Q.2963.1 p.6
# Q.2963.3 p.5
# UNI4.0-MFY p.3
#
start modify_ack 0x89 !pnni
report
traffic
notify
git UNI_NUM_IE_GIT
unrec
end
#########################################################################
#
# MODIFY REJECT message
#
# References:
# Q.2963 p.6
# UNI4.0-MFY p.3
#
start modify_rej 0x8a !pnni
cause
notify
git UNI_NUM_IE_GIT
unrec
end
#########################################################################
#
# CONNECTION AVAILABLE message
#
# References:
# Q.2931A4 9...10
# Q.2963 p.6
# UNI4.0-MFY p.3
#
start conn_avail 0x8b !pnni
notify
git UNI_NUM_IE_GIT
report
unrec
end
#########################################################################
#
# UNKNOWN message
#
start unknown 0x100
epref
unrec
end

View File

@ -0,0 +1,150 @@
#
# Copyright (c) 2001-2003
# Fraunhofer Institute for Open Communication Systems (FhG Fokus).
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# Author: Hartmut Brandt <harti@freebsd.org>
#
# $Begemot: libunimsg/atm/msg/parseie.awk,v 1.3 2003/09/19 11:58:15 hbb Exp $
#
# Parse the IE definition file
#
match($0, "Begemot:")!=0 {
gsub("^[^$]*", "")
gsub("[^$]*$", "")
id = $0
next
}
/^#/ {
next
}
NF == 0 {
next
}
BEGIN {
iecnt = 0
id = " * ???"
begin()
}
END {
end()
}
#
# Syntax is:
# element <name> <code> <coding> [<maxlen> [<options>*]]
#
$1=="element" {
if(iecnt == 0) first_element()
if(NF < 4) {
error("Bad number of args: " $0)
}
ie = $2
file = $2
number = parse_hex($3)
coding = $4
if(coding == "itu") {
ncoding = 0
} else if(coding == "net") {
ncoding = 3
} else {
error("bad coding " coding)
}
if(NF == 4) {
element_default()
file=""
} else {
len = $5
parse_options()
element()
}
ies[iecnt] = ie
codings[iecnt] = coding
files[iecnt] = file
iecnt++
next
}
{
error("Bad line: " $0)
}
function parse_options() {
access = 0
cond = ""
for(i = 6; i <= NF; i++) {
if($i == "access") {
access = 1
} else if($i == "-") {
} else if(index($i, "file=") == 1) {
file=substr($i, 6)
} else {
if(cond != "") {
error("Too many conditions: "$0)
}
cond = $i
}
}
}
function parse_hex(str, n)
{
n = 0
if(substr(str,1,2) != "0x") {
error("bad hex number" str)
}
for(i = 3; i <= length(str); i++) {
c = substr(str,i,1)
if(match(c,"[0-9]") != 0) {
n = 16 * n + c
} else if(match(c,"[a-f]")) {
if(c == "a") n = 16 * n + 10
if(c == "b") n = 16 * n + 11
if(c == "c") n = 16 * n + 12
if(c == "d") n = 16 * n + 13
if(c == "e") n = 16 * n + 14
if(c == "f") n = 16 * n + 15
} else if(match(c,"[A-F]")) {
if(c == "A") n = 16 * n + 10
if(c == "B") n = 16 * n + 11
if(c == "C") n = 16 * n + 12
if(c == "D") n = 16 * n + 13
if(c == "E") n = 16 * n + 14
if(c == "F") n = 16 * n + 15
} else {
error("bad hex digit '" c "'")
}
}
return n
}
# function error(str)
# {
# print "error:" str >"/dev/stderr"
# exit 1
# }

View File

@ -0,0 +1,138 @@
#
# Copyright (c) 2001-2003
# Fraunhofer Institute for Open Communication Systems (FhG Fokus).
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# Author: Hartmut Brandt <harti@freebsd.org>
#
# $Begemot: libunimsg/atm/msg/parsemsg.awk,v 1.3 2003/09/19 11:58:15 hbb Exp $
#
# Parse the message definition file
#
match($0, "Begemot:")!=0 {
gsub("^[^$]*", "")
gsub("[^$]*$", "")
id = $0
next
}
/^#/ {
next
}
NF == 0 {
next
}
BEGIN {
state=0
id = " * ???"
mcnt=0
begin()
}
END {
end()
}
state==0 && $1=="start" {
if(NF < 3) error("bad number of fields in message start "$0)
state = 1
msg = $2
code = parse_hex($3)
messages[mcnt] = msg
msgcond[mcnt] = $4
msgrep = 0
msgrepie = 0
cnt = 0
if(mcnt == 0) first_entry()
start_message()
next
}
state==1 && $1=="end" {
state=0
mcnt++
end_message()
next
}
state==1 {
iename[cnt]=$1
if($2 == "") $2="-"
if(match($2, "[A-Za-z][A-Za-z0-9_]*/R") == 1) {
ienum[cnt]=substr($2, 1, length($2)-2)
ierep[cnt]=1
msgrepie=1
} else {
ierep[cnt]=0
ienum[cnt]=$2
}
if(ienum[cnt] != "-") msgrep = 1
if($3 == "" || $3 == "-") {
$3 = "1"
} else {
gsub("[a-zA-Z][a-zA-Z0-9]*", "cx->&", $3)
}
iecond[cnt] = $3
cnt++
next
}
{
error("bad line: "$0)
}
function parse_hex(str, n)
{
n = 0
if(substr(str,1,2) != "0x") {
error("bad hex number" str)
}
for(i = 3; i <= length(str); i++) {
c = substr(str,i,1)
if(match(c,"[0-9]") != 0) {
n = 16 * n + c
} else if(match(c,"[a-f]")) {
if(c == "a") n = 16 * n + 10
if(c == "b") n = 16 * n + 11
if(c == "c") n = 16 * n + 12
if(c == "d") n = 16 * n + 13
if(c == "e") n = 16 * n + 14
if(c == "f") n = 16 * n + 15
} else if(match(c,"[A-F]")) {
if(c == "A") n = 16 * n + 10
if(c == "B") n = 16 * n + 11
if(c == "C") n = 16 * n + 12
if(c == "D") n = 16 * n + 13
if(c == "E") n = 16 * n + 14
if(c == "F") n = 16 * n + 15
} else {
error("bad hex digit '" c "'")
}
}
return n
}
function error(str)
{
print "error:" str >"/dev/stderr"
exit 1
}

View File

@ -0,0 +1,119 @@
/*
* Copyright (c) 2001-2003
* Fraunhofer Institute for Open Communication Systems (FhG Fokus).
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* Author: Hartmut Brandt <harti@freebsd.org>
*
* $Begemot: libunimsg/atm/msg/priv.h,v 1.3 2003/09/19 11:58:15 hbb Exp $
*
* Private definitions for the IE code file.
*/
#ifndef unimsg_priv_h
#define unimsg_priv_h
#ifdef _KERNEL
#include <sys/systm.h>
#include <machine/stdarg.h>
#define PANIC(X) panic X
#else
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#define PANIC(X) abort()
#endif
/*
* Define a structure for the declaration of information elements.
* For each coding scheme a quadrupel of check, print, encode and
* decode functions must be defined. A structure of the same format
* is used for messages.
*/
typedef void (*uni_print_f)(const union uni_ieall *, struct unicx *);
typedef int (*uni_check_f)(union uni_ieall *, struct unicx *);
typedef int (*uni_encode_f)(struct uni_msg *, union uni_ieall *,
struct unicx *);
typedef int (*uni_decode_f)(union uni_ieall *, struct uni_msg *, u_int,
struct unicx *);
typedef void (*uni_msg_print_f)(const union uni_msgall *, struct unicx *);
typedef int (*uni_msg_check_f)(struct uni_all *, struct unicx *);
typedef int (*uni_msg_encode_f)(struct uni_msg *, union uni_msgall *,
struct unicx *);
typedef int (*uni_msg_decode_f)(union uni_msgall *, struct uni_msg *,
enum uni_ietype, struct uni_iehdr *, u_int, struct unicx *);
struct iedecl {
u_int flags; /* information element flags */
u_int maxlen; /* maximum size */
uni_print_f print;
uni_check_f check;
uni_encode_f encode;
uni_decode_f decode;
};
struct msgdecl {
u_int flags;
const char *name;
uni_msg_print_f print;
uni_msg_check_f check;
uni_msg_encode_f encode;
uni_msg_decode_f decode;
};
enum {
UNIFL_DEFAULT = 0x0001,
UNIFL_ACCESS = 0x0002,
};
extern const struct iedecl *uni_ietable[256][4];
extern const struct msgdecl *uni_msgtable[256];
/*
* Need to check range here because declaring a variable as a enum does not
* guarantee that the values will be legal.
*/
#define GET_IEDECL(IE, CODING) \
({ \
const struct iedecl *_decl = NULL; \
\
if((CODING) <= 3 && (IE) <= 255) \
if((_decl = uni_ietable[IE][CODING]) != NULL) \
if((_decl->flags & UNIFL_DEFAULT) != 0) \
if((_decl = uni_ietable[IE][0]) == NULL) \
PANIC(("IE %02x,%02x -- no default", CODING,IE));\
_decl; \
})
enum {
DEC_OK,
DEC_ILL,
DEC_ERR,
};
void uni_print_ie_internal(enum uni_ietype, const union uni_ieall *,
struct unicx *);
#endif

View File

@ -0,0 +1,275 @@
/*
* Copyright (c) 2001-2003
* Fraunhofer Institute for Open Communication Systems (FhG Fokus).
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* Author: Hartmut Brandt <harti@freebsd.org>
*
* $Begemot: libunimsg/atm/msg/privmsg.c,v 1.3 2003/09/19 11:58:15 hbb Exp $
*
* Private definitions for the MSG code file.
*
* This file is included at the begin of the automatically generated
* uni_msg.c.
*/
/*
* Decode a UNI message header.
* Return values:
* 0 - ok
* -1 - ignore message (proto, length, CR error)
*/
int
uni_decode_head(struct uni_msg *msg, struct uni_all *out,
struct unicx *cx __unused)
{
u_int mlen;
cx->errcnt = 0;
(void)memset(out, 0, sizeof(struct uni_all));
if(uni_msg_len(msg) < 9)
return -1; /* Q.2931 5.6.2 */
if(cx->pnni) {
if(*msg->b_rptr++ != PNNI_PROTO)
return -1; /* Q.2931 5.6.1 */
} else {
if(*msg->b_rptr++ != UNI_PROTO)
return -1; /* Q.2931 5.6.1 */
}
if(*msg->b_rptr++ != 3)
return -1; /* Q.2931 5.6.3.1 */
out->u.hdr.cref.flag = (*msg->b_rptr & 0x80) ? 1 : 0;
out->u.hdr.cref.cref = (*msg->b_rptr++ & 0x7f) << 16;
out->u.hdr.cref.cref |= *msg->b_rptr++ << 8;
out->u.hdr.cref.cref |= *msg->b_rptr++;
out->mtype = *msg->b_rptr++;
/*
* Be not too piggy about this byte
*/
switch(*msg->b_rptr & 0x13) {
case 0x00: case 0x01: case 0x02: case 0x03:
out->u.hdr.act = UNI_MSGACT_DEFAULT;
break;
case 0x10: case 0x11: case 0x12:
out->u.hdr.act = *msg->b_rptr & 0x3;
break;
case 0x13: /* Q.2931 5.7.1 */
out->u.hdr.act = UNI_MSGACT_REPORT;
break;
}
if(cx->pnni && (*msg->b_rptr & 0x08))
out->u.hdr.pass = 1;
else
out->u.hdr.pass = 0;
msg->b_rptr++;
mlen = *msg->b_rptr++ << 8;
mlen |= *msg->b_rptr++;
/*
* If the message is longer than the indicated length
* shorten it. If it is shorter, probably one of the IE
* decoders will break, but we should proceed. 5.5.6.5
*/
#if 0
if(uni_msg_len(msg) > mlen)
msg->b_wptr = msg->b_rptr + mlen;
#endif
return 0;
}
static int
uni_decode_body_internal(enum uni_msgtype mtype, struct uni_msg *msg,
union uni_msgall *out, struct unicx *cx)
{
enum uni_ietype ietype;
struct uni_iehdr hdr;
u_int ielen;
const struct iedecl *iedecl;
int err = 0, ret;
u_char *end;
cx->ielast = (enum uni_ietype)0;
cx->repeat.h.present = 0;
while (uni_msg_len(msg) != 0) {
if (uni_decode_ie_hdr(&ietype, &hdr, msg, cx, &ielen)) {
/*
* Short header. Set the ielen to an impossible size.
* Then we should bump out in the error handling below.
* We should have at least an IE type here.
*/
ielen = 0xffffffff;
}
#ifdef DTRACE
printf("IE %x\n", ietype);
#endif
if ((iedecl = GET_IEDECL(ietype, hdr.coding)) == NULL ||
ietype == UNI_IE_UNREC) {
/*
* entirly unknown IE. Check the length and skip it.
* Q.2931 5.6.8.1
*/
if (ielen > uni_msg_len(msg))
msg->b_rptr = msg->b_wptr;
else
msg->b_rptr += ielen;
UNI_SAVE_IERR(cx, ietype, hdr.act, UNI_IERR_UNK);
err = -1;
continue;
}
#ifdef DTRACE
printf("IE %x known\n", ietype);
#endif
if (ielen > iedecl->maxlen - 4 || ielen > uni_msg_len(msg)) {
/*
* Information element too long -> content error.
* Let the decoding routine set the error flag and
* return DEC_ERR.
* Q.2931 5.6.8.2
*/
#if 0
/*
* It is not clear how to best handle this error.
*/
if (ielen > iedecl->maxlen - 4)
ielen = iedecl->maxlen - 4;
#endif
if (ielen > uni_msg_len(msg))
ielen = uni_msg_len(msg);
hdr.present |= UNI_IE_ERROR;
#ifdef DTRACE
printf("IE %x length too large\n", ietype);
#endif
}
#ifdef DTRACE
else
printf("IE %x length ok\n", ietype);
#endif
end = msg->b_rptr + ielen;
ret = uni_msgtable[mtype]->decode(out, msg, ietype,
&hdr, ielen, cx);
msg->b_rptr = end;
#ifdef DTRACE
printf("IE %x ret %d\n", ietype, ret);
#endif
switch (ret) {
case DEC_OK: /* ok */
break;
case DEC_ILL: /* illegal IE */
/*
* Unexpected but recognized.
* Q.2931 5.6.8.3
*/
UNI_SAVE_IERR(cx, ietype, hdr.act, UNI_IERR_UNK);
err = -1;
break;
case DEC_ERR: /* bad IE */
if (iedecl->flags & UNIFL_ACCESS)
/* this may be wrong: 5.6.8.2 */
UNI_SAVE_IERR(cx, ietype, hdr.act, UNI_IERR_ACC);
else
UNI_SAVE_IERR(cx, ietype, hdr.act, UNI_IERR_BAD);
err = -1;
break;
default:
PANIC(("bad decode return"));
}
cx->ielast = ietype;
if (ietype != UNI_IE_REPEAT)
cx->repeat.h.present = 0;
}
return err;
}
/*
* Decode the body of a message. The header is assumed to be decoded
* already and out->hdr is filled in. Only information elements remain.
*/
int
uni_decode_body(struct uni_msg *msg, struct uni_all *out, struct unicx *cx)
{
cx->errcnt = 0;
if (out->mtype >= 256)
return (-1);
if (uni_msgtable[out->mtype] == NULL)
return (-1);
return (uni_decode_body_internal(out->mtype, msg, &out->u, cx));
}
/*
* Decode a uni message
*/
int
uni_decode(struct uni_msg *msg, struct uni_all *out, struct unicx *cx)
{
cx->errcnt = 0;
if (uni_decode_head(msg, out, cx))
return (-1);
if (uni_decode_body(msg, out, cx))
return (-2);
return (0);
}
int
uni_encode(struct uni_msg *msg, struct uni_all *in, struct unicx *cx)
{
if (in->mtype >= 256)
return (-1);
if (uni_msgtable[in->mtype] == NULL)
return (-3);
return ((uni_msgtable[in->mtype]->encode)(msg, &in->u, cx));
}
/*
* Doesn't belong here
*/
void
uni_initcx(struct unicx *cx)
{
memset(cx, 0, sizeof(struct unicx));
cx->tabsiz = 4;
}

View File

@ -0,0 +1,406 @@
/*
* Copyright (c) 2001-2003
* Fraunhofer Institute for Open Communication Systems (FhG Fokus).
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* Author: Hartmut Brandt <harti@freebsd.org>
*
* $Begemot: libunimsg/atm/msg/traffic.c,v 1.3 2003/09/19 11:58:15 hbb Exp $
*
* Traffic classification
*/
#include <netnatm/unimsg.h>
#include <netnatm/msg/unistruct.h>
#include <netnatm/msg/unimsglib.h>
#ifdef _KERNEL
#include <sys/systm.h>
#else
#include <stdio.h>
#endif
/*
* Try to set the parameters for the CPCS from the parameters of the
* connection.
*/
enum {
T_CBR23 = 100, T_nrtVBR2_6_UBR12, T_rtVBR236, T_rtVBR2_6
};
static const u_int fmask = UNI_TRAFFIC_FPCR0_P | UNI_TRAFFIC_FPCR1_P |
UNI_TRAFFIC_FSCR0_P | UNI_TRAFFIC_FSCR1_P | UNI_TRAFFIC_FMBS0_P |
UNI_TRAFFIC_FMBS1_P | UNI_TRAFFIC_FABR1_P;
static const u_int bmask = UNI_TRAFFIC_BPCR0_P | UNI_TRAFFIC_BPCR1_P |
UNI_TRAFFIC_BSCR0_P | UNI_TRAFFIC_BSCR1_P | UNI_TRAFFIC_BMBS0_P |
UNI_TRAFFIC_BMBS1_P | UNI_TRAFFIC_BABR1_P;
static const u_int fcbr3 = UNI_TRAFFIC_FPCR0_P | UNI_TRAFFIC_FPCR1_P;
static const u_int bcbr3 = UNI_TRAFFIC_BPCR0_P | UNI_TRAFFIC_BPCR1_P;
static const u_int fvbr16 = UNI_TRAFFIC_FPCR1_P | UNI_TRAFFIC_FSCR1_P |
UNI_TRAFFIC_FMBS1_P;
static const u_int bvbr16 = UNI_TRAFFIC_BPCR1_P | UNI_TRAFFIC_BSCR1_P |
UNI_TRAFFIC_BMBS1_P;
static const u_int fvbr23 = UNI_TRAFFIC_FPCR1_P | UNI_TRAFFIC_FSCR0_P |
UNI_TRAFFIC_FMBS0_P;
static const u_int bvbr23 = UNI_TRAFFIC_BPCR1_P | UNI_TRAFFIC_BSCR0_P |
UNI_TRAFFIC_BMBS0_P;
static const u_int fvbr4 = UNI_TRAFFIC_FPCR0_P | UNI_TRAFFIC_FPCR1_P;
static const u_int bvbr4 = UNI_TRAFFIC_BPCR0_P | UNI_TRAFFIC_BPCR1_P;
int
uni_classify_traffic(const struct uni_ie_bearer *bearer,
const struct uni_ie_traffic *traffic,
enum uni_traffic_class *fclass, enum uni_traffic_class *bclass,
char *ebuf, size_t ebufsiz)
{
u_int tclass;
u_int ft, bt, be, ftag, btag;
/* classify */
switch (bearer->bclass) {
case UNI_BEARER_A:
if (!(bearer->h.present & UNI_BEARER_ATC_P)) {
tclass = T_CBR23;
break;
}
switch (bearer->atc) {
case UNI_BEARER_ATC_CBR1:
tclass = UNI_TRAFFIC_CBR1;
break;
default:
snprintf(ebuf, ebufsiz, "bad ATC=%#02x for BCOB-A",
bearer->atc);
return (-1);
}
break;
case UNI_BEARER_C:
if (!(bearer->h.present & UNI_BEARER_ATC_P)) {
tclass = T_nrtVBR2_6_UBR12;
break;
}
switch (bearer->atc) {
case UNI_BEARER_ATC_VBR1:
tclass = UNI_TRAFFIC_rtVBR1;
break;
case UNI_BEARER_ATC_VBR:
tclass = T_rtVBR236;
break;
case UNI_BEARER_ATC_NVBR1:
tclass = UNI_TRAFFIC_nrtVBR1;
break;
case UNI_BEARER_ATC_ABR:
tclass = UNI_TRAFFIC_ABR;
break;
default:
snprintf(ebuf, ebufsiz, "bad ATC=%#02x for BCOB-C",
bearer->atc);
return (-1);
}
break;
case UNI_BEARER_X:
if (!(bearer->h.present & UNI_BEARER_ATC_P)) {
tclass = T_nrtVBR2_6_UBR12;
break;
}
switch (bearer->atc) {
case UNI_BEARER_ATC_CBR1:
tclass = UNI_TRAFFIC_CBR1;
break;
case UNI_BEARER_ATC_CBR:
case UNI_BEARER_ATCX_4:
case UNI_BEARER_ATCX_6:
tclass = T_CBR23;
break;
case UNI_BEARER_ATC_VBR1:
tclass = UNI_TRAFFIC_rtVBR1;
break;
case UNI_BEARER_ATCX_1:
case UNI_BEARER_ATC_VBR:
tclass = T_rtVBR2_6;
break;
case UNI_BEARER_ATC_NVBR1:
tclass = UNI_TRAFFIC_nrtVBR1;
break;
case UNI_BEARER_ATCX_0:
case UNI_BEARER_ATCX_2:
case UNI_BEARER_ATCX_8:
case UNI_BEARER_ATC_NVBR:
tclass = T_nrtVBR2_6_UBR12;
break;
case UNI_BEARER_ATC_ABR:
tclass = UNI_TRAFFIC_ABR;
break;
default:
snprintf(ebuf, ebufsiz, "bad ATC=%#02x for BCOB-X",
bearer->atc);
return (-1);
}
break;
case UNI_BEARER_TVP:
snprintf(ebuf, ebufsiz, "unsupported bearer class tVP");
return (-1);
default:
snprintf(ebuf, ebufsiz, "bad bearer class %#02x",
bearer->bclass);
return (-1);
}
/*
* Now traffic IE
*/
ft = traffic->h.present & fmask;
bt = traffic->h.present & bmask;
be = traffic->h.present & UNI_TRAFFIC_BEST_P;
ftag = (traffic->h.present & UNI_TRAFFIC_MOPT_P) && traffic->t.ftag;
btag = (traffic->h.present & UNI_TRAFFIC_MOPT_P) && traffic->t.btag;
#define NOBE(C) \
if (be) { \
snprintf(ebuf, ebufsiz, "illegal BE for " C); \
return (-1); \
}
#define NOFT(C) \
if (ftag) { \
snprintf(ebuf, ebufsiz, "illegal forward tag in " C); \
return (-1); \
}
#define NOBT(C) \
if (btag) { \
snprintf(ebuf, ebufsiz, "illegal backward tag in " C); \
return (-1); \
}
#define FBAD(C) do { \
snprintf(ebuf, ebufsiz, "bad forward CRs for " C); \
return (-1); \
} while (0)
#define BBAD(C) do { \
snprintf(ebuf, ebufsiz, "bad backward CRs for " C); \
return (-1); \
} while (0)
switch (tclass) {
case UNI_TRAFFIC_CBR1:
NOBE("CBR.1");
if (ft != UNI_TRAFFIC_FPCR1_P)
FBAD("CBR.1");
NOFT("CBR.1");
if (bt != UNI_TRAFFIC_BPCR1_P)
BBAD("CBR.1");
NOBT("CBR.1");
*fclass = *bclass = UNI_TRAFFIC_CBR1;
break;
case T_CBR23:
NOBE("CBR.2/3");
if (ft == UNI_TRAFFIC_FPCR0_P) {
*fclass = UNI_TRAFFIC_CBR2;
NOFT("CBR.2");
} else if (ft == fcbr3) {
*fclass = UNI_TRAFFIC_CBR3;
if (!ftag) {
snprintf(ebuf, ebufsiz, "need forward tagging for CBR.3");
return (-1);
}
} else
FBAD("CBR.2/3");
if (bt == UNI_TRAFFIC_BPCR0_P) {
*bclass = UNI_TRAFFIC_CBR2;
NOBT("CBR.2");
} else if (bt == bcbr3) {
*bclass = UNI_TRAFFIC_CBR3;
if (!btag) {
snprintf(ebuf, ebufsiz, "need backward tagging for CBR.3");
return (-1);
}
} else
BBAD("CBR.2/3");
break;
case UNI_TRAFFIC_rtVBR1:
NOBE("rtVBR.1");
if (ft != fvbr16)
FBAD("rtVBR.1");
NOFT("rtVBR.1");
if (bt != bvbr16)
BBAD("rtVBR.1");
NOBT("rtVBR.1");
*fclass = *bclass = UNI_TRAFFIC_rtVBR1;
break;
case T_rtVBR236:
NOBE("rtVBR.2/3/6");
if (ft == fvbr23) {
if (ftag)
*fclass = UNI_TRAFFIC_rtVBR3;
else
*fclass = UNI_TRAFFIC_rtVBR2;
} else if (ft == fvbr16) {
*fclass = UNI_TRAFFIC_rtVBR6;
NOFT("rtVBR.6");
} else
FBAD("rtVBR.2/3/6");
if (bt == bvbr23) {
if (btag)
*bclass = UNI_TRAFFIC_rtVBR3;
else
*bclass = UNI_TRAFFIC_rtVBR2;
} else if (bt == bvbr16) {
*bclass = UNI_TRAFFIC_rtVBR6;
NOBT("rtVBR.6");
} else
BBAD("rtVBR.2/3/6");
break;
case T_rtVBR2_6:
NOBE("rtVBR.2-6");
if (ft == fvbr23) {
if (ftag)
*fclass = UNI_TRAFFIC_rtVBR3;
else
*fclass = UNI_TRAFFIC_rtVBR2;
} else if (ft == fvbr4) {
*fclass = UNI_TRAFFIC_rtVBR4;
} else if (ft == UNI_TRAFFIC_FPCR1_P) {
*fclass = UNI_TRAFFIC_rtVBR5;
NOFT("rtVBR.5");
} else if (ft == fvbr16) {
*fclass = UNI_TRAFFIC_rtVBR6;
NOFT("rtVBR.6");
} else
FBAD("rtVBR.2-6");
if (bt == bvbr23) {
if (btag)
*bclass = UNI_TRAFFIC_rtVBR3;
else
*bclass = UNI_TRAFFIC_rtVBR2;
} else if (bt == bvbr4) {
*bclass = UNI_TRAFFIC_rtVBR4;
} else if (bt == UNI_TRAFFIC_BPCR1_P) {
*bclass = UNI_TRAFFIC_rtVBR5;
NOBT("rtVBR.5");
} else if (bt == bvbr16) {
*bclass = UNI_TRAFFIC_rtVBR6;
NOBT("rtVBR.6");
} else
BBAD("rtVBR.2-6");
break;
case UNI_TRAFFIC_nrtVBR1:
NOBE("nrtVBR.1");
if (ft != fvbr16)
FBAD("nrtVBR.1");
NOFT("nrtVBR.1");
if (bt != bvbr16)
BBAD("nrtVBR.1");
NOBT("nrtVBR.1");
*fclass = *bclass = UNI_TRAFFIC_nrtVBR1;
break;
case T_nrtVBR2_6_UBR12:
if (be) {
if (ft != UNI_TRAFFIC_FPCR1_P)
FBAD("UBR.1/2");
if (bt != UNI_TRAFFIC_BPCR1_P)
BBAD("UBR.1/2");
if (ftag)
*fclass = UNI_TRAFFIC_UBR2;
else
*fclass = UNI_TRAFFIC_UBR1;
if (btag)
*bclass = UNI_TRAFFIC_UBR2;
else
*bclass = UNI_TRAFFIC_UBR1;
break;
}
if (ft == fvbr23) {
if (ftag)
*fclass = UNI_TRAFFIC_nrtVBR3;
else
*fclass = UNI_TRAFFIC_nrtVBR2;
} else if (ft == fvbr4) {
*fclass = UNI_TRAFFIC_nrtVBR4;
} else if (ft == UNI_TRAFFIC_FPCR1_P) {
*fclass = UNI_TRAFFIC_nrtVBR5;
NOFT("nrtVBR.5");
} else if (ft == fvbr16) {
*fclass = UNI_TRAFFIC_nrtVBR6;
NOFT("nrtVBR.6");
} else
FBAD("nrtVBR.2-6");
if (bt == bvbr23) {
if (btag)
*bclass = UNI_TRAFFIC_nrtVBR3;
else
*bclass = UNI_TRAFFIC_nrtVBR2;
} else if (bt == bvbr4) {
*bclass = UNI_TRAFFIC_nrtVBR4;
} else if (bt == UNI_TRAFFIC_BPCR1_P) {
*bclass = UNI_TRAFFIC_nrtVBR5;
NOBT("nrtVBR.5");
} else if (bt == bvbr16) {
*bclass = UNI_TRAFFIC_nrtVBR6;
NOBT("nrtVBR.6");
} else
BBAD("nrtVBR.2-6");
break;
case UNI_TRAFFIC_ABR:
NOBE("ABR");
if (ft != UNI_TRAFFIC_FPCR1_P)
FBAD("ABR");
if (bt != UNI_TRAFFIC_BPCR1_P)
BBAD("ABR");
NOFT("ABR");
NOBT("ABR");
*fclass = *bclass = UNI_TRAFFIC_ABR;
break;
}
return (0);
}

View File

@ -0,0 +1,70 @@
/*
* Copyright (c) 1996-2003
* Fraunhofer Institute for Open Communication Systems (FhG Fokus).
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* Author: Hartmut Brandt <harti@freebsd.org>
*
* $Begemot: libunimsg/atm/msg/uni_config.h,v 1.3 2003/09/19 11:58:15 hbb Exp $
*/
#ifndef _uni_uni_config_h_
#define _uni_uni_config_h_
enum {
/* maximum number of reported error IEs */
UNI_MAX_ERRIE = 50,
/* maximum number of Generic Identifier Transport IE's per message */
UNI_NUM_IE_GIT = 3,
/* maximum number of BLLI's in SETUP */
UNI_NUM_IE_BLLI = 3,
/* maximum number of CALLEDSUB's */
UNI_NUM_IE_CALLEDSUB = 2,
/* maximum number of CALLINGSUB's */
UNI_NUM_IE_CALLINGSUB = 2,
/* maximum number of TNS's */
UNI_NUM_IE_TNS = 4,
/* maximum length of TNS name */
UNI_TNS_MAXLEN = 4,
/* maximum info size in user-to-user signalling IE */
UNI_UU_MAXLEN = 128,
/* maximum length of address */
UNI_ADDR_MAXLEN = 20,
/* maximum length of subaddress */
UNI_SUBADDR_MAXLEN = 20,
/* maximum number of DTLs */
UNI_NUM_IE_DTL = 10,
/* maximum number of identifiers in DTL */
UNI_DTL_MAXNUM = 20,
};
#endif

View File

@ -0,0 +1,215 @@
/*
* Copyright (c) 1996-2003
* Fraunhofer Institute for Open Communication Systems (FhG Fokus).
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* Author: Hartmut Brandt <harti@freebsd.org>
*
* $Begemot: libunimsg/atm/msg/uni_hdr.h,v 1.3 2003/09/19 11:58:15 hbb Exp $
*/
#ifndef _NETNATM_MSG_UNI_HDR_H_
#define _NETNATM_MSG_UNI_HDR_H_
#include <sys/types.h>
#include <netnatm/msg/uni_config.h>
enum {
UNI_PROTO = 0x09, /* protocol discriminator */
PNNI_PROTO = 0xf0, /* PNNI protocol discriminator */
};
/*
* Message types
*/
enum uni_msgtype {
UNI_UNKNOWN = 0x100,/* unknown message */
UNI_ALERTING = 0x01, /* alerting */
UNI_CALL_PROC = 0x02, /* call proceeding */
UNI_SETUP = 0x05, /* setup */
UNI_CONNECT = 0x07, /* connect */
UNI_CONNECT_ACK = 0x0f, /* connect ack */
UNI_RESTART = 0x46, /* restart */
UNI_RELEASE = 0x4d, /* release */
UNI_RESTART_ACK = 0x4e, /* restart acknowledgement */
UNI_RELEASE_COMPL = 0x5a, /* release complete */
UNI_NOTIFY = 0x6e, /* notify user */
UNI_STATUS_ENQ = 0x75, /* status enquiry */
UNI_STATUS = 0x7d, /* status */
UNI_ADD_PARTY = 0x80, /* add party */
UNI_ADD_PARTY_ACK = 0x81, /* add party acknowledgement */
UNI_ADD_PARTY_REJ = 0x82, /* add party reject */
UNI_DROP_PARTY = 0x83, /* drop party */
UNI_DROP_PARTY_ACK = 0x84, /* drop party acknowledgement */
UNI_PARTY_ALERTING = 0x85, /* party alerting */
UNI_LEAF_SETUP_FAIL = 0x90, /* leaf setup failed */
UNI_LEAF_SETUP_REQ = 0x91, /* leaf setup request */
UNI_COBISETUP = 0x15, /* Q.2932 COBI-setup */
UNI_FACILITY = 0x62, /* Q.2932 facility */
UNI_MODIFY_REQ = 0x88, /* Q.2963 Modify request */
UNI_MODIFY_ACK = 0x89, /* Q.2963 Modify acknowledgement */
UNI_MODIFY_REJ = 0x8a, /* Q.2963 Modify reject */
UNI_CONN_AVAIL = 0x8b, /* Q.2963 Connection available */
};
/*
* Information element types
*/
enum uni_ietype {
UNI_IE_CAUSE = 0x08, /* cause */
UNI_IE_CALLSTATE = 0x14, /* call state */
UNI_IE_FACILITY = 0x1C, /* Q.2932 facility IE */
UNI_IE_NOTIFY = 0x27, /* UNI4.0 notify */
UNI_IE_EETD = 0x42, /* UNI4.0 end-to-end transit delay */
UNI_IE_CONNED = 0x4c, /* UNI4.0/Q.2951 connected address */
UNI_IE_CONNEDSUB = 0x4d, /* UNI4.0/Q.2951 connected subaddress */
UNI_IE_EPREF = 0x54, /* endpoint reference */
UNI_IE_EPSTATE = 0x55, /* enpoint state */
UNI_IE_AAL = 0x58, /* ATM adaptation layer parameters */
UNI_IE_TRAFFIC = 0x59, /* ATM traffic descriptor */
UNI_IE_CONNID = 0x5a, /* connection identifier */
UNI_IE_QOS = 0x5c, /* quality of service parameter */
UNI_IE_BHLI = 0x5d, /* broadband higher layer information */
UNI_IE_BEARER = 0x5e, /* broadband bearer capability */
UNI_IE_BLLI = 0x5f, /* broadband lower layer information */
UNI_IE_LSHIFT = 0x60, /* broadband locking shift */
UNI_IE_NLSHIFT = 0x61, /* broadband non-locking shift */
UNI_IE_SCOMPL = 0x62, /* broadband sending complete */
UNI_IE_REPEAT = 0x63, /* broadband repeat indicator */
UNI_IE_CALLING = 0x6c, /* calling party number */
UNI_IE_CALLINGSUB = 0x6d, /* calling party subaddress */
UNI_IE_CALLED = 0x70, /* called party number */
UNI_IE_CALLEDSUB = 0x71, /* called party subaddress */
UNI_IE_TNS = 0x78, /* transit network selection */
UNI_IE_RESTART = 0x79, /* restart indicator */
UNI_IE_UU = 0x7e, /* UNI4.0/Q.2957 user-to-user info */
UNI_IE_GIT = 0x7f, /* UNI4.0 generic identifier transport*/
UNI_IE_MINTRAFFIC = 0x81, /* Q.2962 minimum traffic desc */
UNI_IE_ATRAFFIC = 0x82, /* Q.2962 alternate traffic desc */
UNI_IE_ABRSETUP = 0x84, /* UNI4.0 ABR setup parameters */
UNI_IE_REPORT = 0x89, /* Q.2963 broadband report type */
UNI_IE_CALLED_SOFT = 0xe0, /* PNNI Calling party soft PVPC */
UNI_IE_CRANKBACK = 0xe1, /* PNNI Crankback */
UNI_IE_DTL = 0xe2, /* PNNI designated transit list */
UNI_IE_CALLING_SOFT = 0xe3, /* PNNI Called party soft PVPC */
UNI_IE_ABRADD = 0xe4, /* UNI4.0 ABR additional parameters */
UNI_IE_LIJ_CALLID = 0xe8, /* UNI4.0 LIF call identifier */
UNI_IE_LIJ_PARAM = 0xe9, /* UNI4.0 LIF parameters */
UNI_IE_LIJ_SEQNO = 0xea, /* UNI4.0 LIF sequence number */
UNI_IE_CSCOPE = 0xeb, /* UNI4.0 connection scope selection */
UNI_IE_EXQOS = 0xec, /* UNI4.0 extended QoS parameters */
UNI_IE_MDCR = 0xf0, /* UNI4.0+ Minimum desired call rate */
UNI_IE_UNREC = 0xfe,
};
enum uni_coding {
UNI_CODING_ITU = 0x0,
UNI_CODING_NET = 0x3,
};
enum uni_msgact {
UNI_MSGACT_CLEAR = 0x0,
UNI_MSGACT_IGNORE = 0x1,
UNI_MSGACT_REPORT = 0x2,
UNI_MSGACT_DEFAULT = 0x4
};
enum uni_ieact {
UNI_IEACT_CLEAR = 0x00, /* clear call */
UNI_IEACT_IGNORE = 0x01, /* ignore IE and proceed */
UNI_IEACT_REPORT = 0x02, /* ignore IE, report and proceed */
UNI_IEACT_MSG_IGNORE = 0x05, /* ignore message */
UNI_IEACT_MSG_REPORT = 0x06, /* ignore message and report */
UNI_IEACT_DEFAULT = 0x08
};
struct uni_cref {
u_int flag;
u_int cref;
};
/*
* Message header.
*/
struct uni_msghdr {
struct uni_cref cref;
enum uni_msgact act; /* action indicator */
u_int pass:1; /* PNNI pass along request */
};
enum {
CREF_GLOBAL = 0,
CREF_DUMMY = 0x7fffff,
};
/*
* General information element header.
*/
struct uni_iehdr {
enum uni_coding coding; /* coding standard */
enum uni_ieact act; /* action indicator */
u_int pass : 1; /* PNNI pass along request */
u_int present; /* which optional elements are present */
#define UNI_IE_EMPTY 0x80000000
#define UNI_IE_PRESENT 0x40000000
#define UNI_IE_ERROR 0x20000000
#define UNI_IE_XXX 0x10000000
#define UNI_IE_MASK 0xf0000000
};
#define IE_ISPRESENT(IE) \
(((IE).h.present & (UNI_IE_PRESENT|UNI_IE_EMPTY)) == UNI_IE_PRESENT)
#define IE_SETPRESENT(IE) \
((IE).h.present = ((IE).h.present & ~UNI_IE_MASK) | \
UNI_IE_PRESENT)
#define IE_ADDPRESENT(IE) \
((IE).h.present = ((IE).h.present & ~UNI_IE_EMPTY) | \
UNI_IE_PRESENT)
#define IE_ISEMPTY(IE) \
(((IE).h.present & UNI_IE_MASK) == (UNI_IE_PRESENT | UNI_IE_EMPTY))
#define IE_SETEMPTY(IE) \
((IE).h.present = ((IE).h.present & ~UNI_IE_MASK) | \
UNI_IE_EMPTY | UNI_IE_PRESENT)
#define IE_ISERROR(IE) \
(((IE).h.present & UNI_IE_MASK) == (UNI_IE_PRESENT | UNI_IE_ERROR))
#define IE_SETERROR(IE) \
((IE).h.present = ((IE).h.present & ~UNI_IE_MASK) | \
UNI_IE_ERROR | UNI_IE_PRESENT)
#define IE_ISGOOD(IE) \
(((IE).h.present & UNI_IE_MASK) == (UNI_IE_PRESENT))
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,168 @@
/*
* Copyright (c) 1996-2003
* Fraunhofer Institute for Open Communication Systems (FhG Fokus).
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* Author: Hartmut Brandt <harti@freebsd.org>
*
* $Begemot: libunimsg/atm/msg/unimsglib.h,v 1.3 2003/09/19 11:58:16 hbb Exp $
*/
#ifndef _NETNATM_MSG_UNIMSGLIB_H_
#define _NETNATM_MSG_UNIMSGLIB_H_
#include <netnatm/msg/uni_config.h>
struct uni_msg;
enum uni_ierr_type {
UNI_IERR_UNK, /* unknown IE */
UNI_IERR_LEN, /* length error */
UNI_IERR_BAD, /* content error */
UNI_IERR_ACC, /* access element content error */
UNI_IERR_MIS, /* mandatory IE missing (not used here) */
};
struct uni_ierr {
enum uni_ierr_type err; /* what error */
enum uni_ieact act; /* the action indicator */
u_int ie:8; /* the ie type */
u_int man:1; /* mandatory flag */
u_int epref:1;/* Q.2971 9.5.3.2.1 low-pri epref */
};
/*
* Context buffer. Needed to reduce number of arguments to routines.
*/
struct unicx {
/*
* globals for error handling
*/
u_int errcnt; /* number of bad IEs */
struct uni_ierr err[UNI_MAX_ERRIE]; /* the errors */
int q2932; /* Enable GFP */
int pnni; /* Enable PNNI */
int git_hard; /* do hard check on GIT IE */
int bearer_hard; /* do hard check on BEARER IE */
int cause_hard; /* do hard check on cause */
int multiline; /* printing mode */
u_int tabsiz; /* tabulation size */
/*
* Internal context of library -- don't touch
*/
struct uni_ie_repeat repeat; /* repeat IE during decoding */
enum uni_ietype ielast; /* last IE seen for repeat handling */
const char *prefix[20];
u_int nprefix;
int doindent;
char *buf;
size_t bufsiz;
u_int indent; /* indentation */
int dont_init;
};
/*
* Functions for all messages
*/
void uni_print_cref(char *, size_t, const struct uni_cref *, struct unicx *);
void uni_print_msghdr(char *, size_t, const struct uni_msghdr *, struct unicx *);
void uni_print(char *, size_t, const struct uni_all *, struct unicx *);
void uni_print_msg(char *, size_t, u_int _mtype, const union uni_msgall *,
struct unicx *);
int uni_encode(struct uni_msg *, struct uni_all *, struct unicx *);
int uni_decode(struct uni_msg *, struct uni_all *, struct unicx *);
int uni_decode_head(struct uni_msg *, struct uni_all *, struct unicx *);
int uni_decode_body(struct uni_msg *, struct uni_all *, struct unicx *);
int uni_encode_msg_hdr(struct uni_msg *, struct uni_msghdr *, enum uni_msgtype,
struct unicx *, int *);
/*
* Functions for all information elements
*/
void uni_print_ie(char *, size_t, enum uni_ietype, const union uni_ieall *,
struct unicx *);
int uni_check_ie(enum uni_ietype, union uni_ieall *, struct unicx *);
int uni_encode_ie(enum uni_ietype, struct uni_msg *, union uni_ieall *,
struct unicx *);
int uni_decode_ie_hdr(enum uni_ietype *, struct uni_iehdr *, struct uni_msg *,
struct unicx *, u_int *);
int uni_encode_ie_hdr(struct uni_msg *, enum uni_ietype, struct uni_iehdr *,
u_int, struct unicx *);
int uni_decode_ie_body(enum uni_ietype, union uni_ieall *, struct uni_msg *,
u_int, struct unicx *);
/*
* Context handling
*/
void uni_initcx(struct unicx *);
void uni_print_cx(char *, size_t, struct unicx *);
#define UNI_SAVE_IERR(CX, IETYPE, ACT, ERRCODE) \
(((CX)->errcnt < UNI_MAX_ERRIE) ? \
((CX)->err[(CX)->errcnt].ie = (IETYPE), \
(CX)->err[(CX)->errcnt].act = (ACT), \
(CX)->err[(CX)->errcnt].err = (ERRCODE), \
(CX)->err[(CX)->errcnt].man = 0, \
(CX)->errcnt++, \
1) : 0)
/*
* Traffic classification
*/
enum uni_traffic_class {
UNI_TRAFFIC_CBR1,
UNI_TRAFFIC_CBR2,
UNI_TRAFFIC_CBR3,
UNI_TRAFFIC_rtVBR1,
UNI_TRAFFIC_rtVBR2,
UNI_TRAFFIC_rtVBR3,
UNI_TRAFFIC_rtVBR4,
UNI_TRAFFIC_rtVBR5,
UNI_TRAFFIC_rtVBR6,
UNI_TRAFFIC_nrtVBR1,
UNI_TRAFFIC_nrtVBR2,
UNI_TRAFFIC_nrtVBR3,
UNI_TRAFFIC_nrtVBR4,
UNI_TRAFFIC_nrtVBR5,
UNI_TRAFFIC_nrtVBR6,
UNI_TRAFFIC_ABR,
UNI_TRAFFIC_UBR1,
UNI_TRAFFIC_UBR2,
};
/* classify traffic */
int uni_classify_traffic(const struct uni_ie_bearer *,
const struct uni_ie_traffic *,
enum uni_traffic_class *, enum uni_traffic_class *,
char *, size_t);
#endif

View File

@ -0,0 +1,72 @@
/*
* Copyright (c) 2001-2003
* Fraunhofer Institute for Open Communication Systems (FhG Fokus).
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* Author: Hartmut Brandt <harti@freebsd.org>
*
* $Begemot: libunimsg/atm/msg/uniprint.h,v 1.3 2003/09/19 11:58:16 hbb Exp $
*
* Print utility functions. These are only needed if you want to hook to
* the format of the uni printing routines.
*/
#ifndef _NETNATM_MSG_UNIPRINT_H_
#define _NETNATM_MSG_UNIPRINT_H_
#include <netnatm/msg/uni_config.h>
/*
* This structure is used to define value->string mappings.
* It must be terminated by a { NULL, 0 } entry.
*/
struct uni_print_tbl {
const char *name;
u_int val;
};
void uni_print_tbl(const char *_entry, u_int _val,
const struct uni_print_tbl *_tbl, struct unicx *_cx);
/* initialize printing. This must be called at the start from each external
* callable printing function. */
void uni_print_init(char *_buf, size_t _bufsiz, struct unicx *_cx);
/* End the current (semantical) line. This takes care of indendation and
* actually print the newline in the appropriate modes. */
void uni_print_eol(struct unicx *_cx);
/* Push or pop a prefix. This takes care of indendation. */
void uni_print_push_prefix(const char *_prefix, struct unicx *_cx);
void uni_print_pop_prefix(struct unicx *_cx);
/* Print a flag taking care of the right prefixing */
void uni_print_flag(const char *_flag, struct unicx *_cx);
/* Print an entry taking care of the right prefixing */
void uni_print_entry(struct unicx *_cx, const char *_entry,
const char *_fmt, ...) __printflike(3, 4);
/* Generic printf */
void uni_printf(struct unicx *_cx, const char *_fmt, ...) __printflike(2, 3);
#endif

File diff suppressed because it is too large Load Diff