Add mISDNuser to this project

jolly/uk0
Andreas Eversberg 8 months ago
parent 7ebde07432
commit 4150cc3e67
  1. 1
      .gitignore
  2. 1
      configure.ac
  3. 1
      src/Makefile.am
  4. 23
      src/libmisdnuser/Makefile.am
  5. 57
      src/libmisdnuser/asn1/asn1.c
  6. 173
      src/libmisdnuser/asn1/asn1_enc.c
  7. 234
      src/libmisdnuser/asn1/asn1_generic.c
  8. 26
      src/libmisdnuser/include/3pty.h
  9. 290
      src/libmisdnuser/include/asn1.h
  10. 94
      src/libmisdnuser/include/ccbs.h
  11. 78
      src/libmisdnuser/include/debug.h
  12. 91
      src/libmisdnuser/include/diversion.h
  13. 74
      src/libmisdnuser/include/dss1.h
  14. 47
      src/libmisdnuser/include/ect.h
  15. 63
      src/libmisdnuser/include/fsm.h
  16. 76
      src/libmisdnuser/include/helper.h
  17. 178
      src/libmisdnuser/include/layer3.h
  18. 40
      src/libmisdnuser/include/mISDN/af_isdn.h
  19. 78
      src/libmisdnuser/include/mISDN/l3dss1.h
  20. 5
      src/libmisdnuser/include/mISDN/mISDNcompat.h
  21. 420
      src/libmisdnuser/include/mISDN/mISDNif.h
  22. 259
      src/libmisdnuser/include/mISDN/mbuffer.h
  23. 260
      src/libmisdnuser/include/mISDN/mlayer3.h
  24. 363
      src/libmisdnuser/include/mISDN/q931.h
  25. 1267
      src/libmisdnuser/include/mISDN/suppserv.h
  26. 119
      src/libmisdnuser/include/mlist.h
  27. 46
      src/libmisdnuser/include/mtimer.h
  28. 1905
      src/libmisdnuser/layer3/dss1net.c
  29. 2343
      src/libmisdnuser/layer3/dss1user.c
  30. 1051
      src/libmisdnuser/layer3/layer3.c
  31. 386
      src/libmisdnuser/layer3/mlayer3.c
  32. 1326
      src/libmisdnuser/layer3/q931.c
  33. 162
      src/libmisdnuser/misc/debug.c
  34. 159
      src/libmisdnuser/misc/fsm.c
  35. 457
      src/libmisdnuser/misc/mbuffer.c
  36. 176
      src/libmisdnuser/misc/mtimer.c
  37. 110
      src/libmisdnuser/suppserv/3pty.c
  38. 624
      src/libmisdnuser/suppserv/address.c
  39. 348
      src/libmisdnuser/suppserv/aoc.c
  40. 13
      src/libmisdnuser/suppserv/basic_service.c
  41. 1666
      src/libmisdnuser/suppserv/ccbs.c
  42. 590
      src/libmisdnuser/suppserv/component.c
  43. 1569
      src/libmisdnuser/suppserv/diversion.c
  44. 403
      src/libmisdnuser/suppserv/ect.c
  45. 879
      src/libmisdnuser/suppserv/fac.c

1
.gitignore vendored

@ -41,4 +41,5 @@ src/libosmocc/libosmocc.a
src/libsample/libsample.a
src/libtimer/libtimer.a
src/libmisdn/libmisdn.a
src/libmisdnuser/libmisdnuser.a
src/isdn/osmo-cc-misdn-endpoint

@ -88,6 +88,7 @@ AC_OUTPUT(
src/libosmocc/Makefile
src/libg711/Makefile
src/libmisdn/Makefile
src/libmisdnuser/Makefile
src/isdn/Makefile
src/Makefile
Makefile)

@ -9,5 +9,6 @@ SUBDIRS = \
libosmocc \
libg711 \
libmisdn \
libmisdnuser \
isdn

@ -0,0 +1,23 @@
AM_CPPFLAGS = -Wall -Wextra -Wno-unused-parameter -Wno-array-bounds -Wno-sign-compare -g $(all_includes) -I$(srcdir)/include
noinst_LIBRARIES = libmisdnuser.a
ASN1_SRC = asn1/asn1.c asn1/asn1_enc.c asn1/asn1_generic.c
SUPPSERV_SRC = suppserv/aoc.c suppserv/basic_service.c suppserv/component.c \
suppserv/diversion.c suppserv/address.c suppserv/ccbs.c \
suppserv/fac.c suppserv/ect.c suppserv/3pty.c
SUPPSERV_INC = include/ccbs.h include/diversion.h include/ect.h include/asn1.h \
include/3pty.h
MISC_SRC = misc/debug.c misc/fsm.c misc/mbuffer.c misc/mtimer.c
LAYER3_SRC = layer3/dss1net.c layer3/dss1user.c layer3/layer3.c layer3/mlayer3.c layer3/q931.c
INCLUDE_SRC = include/debug.h include/dss1.h include/fsm.h include/helper.h include/layer3.h \
include/mlist.h include/mtimer.h $(SUPPSERV_INC)
libmisdnuser_a_SOURCES = $(MISC_SRC) $(LAYER3_SRC) $(INCLUDE_SRC) $(ASN1_SRC) $(SUPPSERV_SRC)

@ -0,0 +1,57 @@
/*
* Basic ASN1 parser functions
*
* Copyright 2009,2010 by Karsten Keil <kkeil@linux-pingi.de>
*
* This code is free software; you can redistribute it and/or modify
* it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE
* version 2.1 as published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU LESSER GENERAL PUBLIC LICENSE for more details.
*
*/
#include "asn1.h"
int ParseTag(u_char * p, u_char * end, int *tag)
{
if (p >= end) {
eprint("ParseTag underflow %p/%p\n", p, end);
return -1;
}
*tag = *p;
return 1;
}
int ParseLen(u_char * p, u_char * end, int *len)
{
int l, i;
if (p >= end) {
eprint("ParseLen underflow %p/%p\n", p, end);
return -1;
}
if (*p == 0x80) { // indefinite
*len = -1;
return 1;
}
if (!(*p & 0x80)) { // one byte
*len = *p;
return 1;
}
*len = 0;
l = *p & ~0x80;
p++;
if (p + l >= end) {
eprint("ParseLen underflow %p/%p\n", p, end);
return -1;
}
for (i = 0; i < l; i++) {
*len = (*len << 8) + *p;
p++;
}
return l + 1;
}

@ -0,0 +1,173 @@
/*
* Encode basic ASN1 elements
*
* Copyright 2009,2010 by Karsten Keil <kkeil@linux-pingi.de>
*
* This code is free software; you can redistribute it and/or modify
* it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE
* version 2.1 as published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU LESSER GENERAL PUBLIC LICENSE for more details.
*
*/
#include "asn1.h"
#include <string.h>
int encodeLen_Long_u8(__u8 * dest, __u8 length)
{
dest[0] = 0x80 + ASN1_NUM_OCTETS_LONG_LENGTH_u8 - 1;
dest[1] = length;
return ASN1_NUM_OCTETS_LONG_LENGTH_u8;
} /* end encodeLen_Long_u8() */
int encodeLen_Long_u16(__u8 * dest, __u16 length)
{
dest[0] = 0x80 + ASN1_NUM_OCTETS_LONG_LENGTH_u16 - 1;
dest[1] = (length >> 8) & 0xFF;
dest[2] = length & 0xFF;
return ASN1_NUM_OCTETS_LONG_LENGTH_u16;
} /* end encodeLen_Long_u16() */
int encodeNull(__u8 * dest, __u8 tagType)
{
dest[0] = tagType;
dest[1] = 0; /* length */
return 2;
}
int encodeBoolean(__u8 * dest, __u8 tagType, __u32 i)
{
dest[0] = tagType;
dest[1] = 1; /* length */
dest[2] = i ? 1 : 0; /* value */
return 3;
}
int encodeInt(__u8 * dest, __u8 tagType, __s32 i)
{
unsigned count;
__u32 test_mask;
__u32 value;
__u8 *p;
dest[0] = tagType;
/* Find most significant octet of 32 bit integer that carries meaning. */
test_mask = 0xFF800000;
value = (__u32) i;
for (count = 4; --count;) {
if ((value & test_mask) != test_mask && (value & test_mask) != 0) {
/*
* The first 9 bits of a multiple octet integer is not
* all ones or zeroes.
*/
break;
}
test_mask >>= 8;
} /* end for */
/* length */
dest[1] = count + 1;
/* Store value */
p = &dest[2];
do {
value = (__u32) i;
value >>= (8 * count);
*p++ = value & 0xFF;
} while (count--);
return p - dest;
}
int encodeEnum(__u8 * dest, __u8 tagType, __s32 i)
{
return encodeInt(dest, tagType, i);
}
/*
* Use to encode the following string types:
* ASN1_TAG_OCTET_STRING
* ASN1_TAG_NUMERIC_STRING
* ASN1_TAG_PRINTABLE_STRING
* ASN1_TAG_IA5_STRING
*
* Note The string length MUST be less than 128 characters.
*/
static int encodeString(__u8 * dest, __u8 tagType, const __s8 * str, __u8 len)
{
__u8 *p;
int i;
dest[0] = tagType;
/* Store value */
p = &dest[2];
for (i = 0; i < len; i++)
*p++ = *str++;
/* length */
dest[1] = p - &dest[2];
return p - dest;
}
int encodeOctetString(__u8 * dest, __u8 tagType, const __s8 * str, __u8 len)
{
return encodeString(dest, tagType, str, len);
} /* end encodeOctetString() */
int encodeNumericString(__u8 * dest, __u8 tagType, const __s8 * str, __u8 len)
{
return encodeString(dest, tagType, str, len);
} /* end encodeNumericString() */
int encodePrintableString(__u8 * dest, __u8 tagType, const __s8 * str, __u8 len)
{
return encodeString(dest, tagType, str, len);
} /* end encodePrintableString() */
int encodeIA5String(__u8 * dest, __u8 tagType, const __s8 * str, __u8 len)
{
return encodeString(dest, tagType, str, len);
} /* end encodeIA5String() */
int encodeOid(__u8 * dest, __u8 tagType, const struct asn1Oid *oid)
{
unsigned numValues;
unsigned count;
__u32 value;
__u8 *p;
dest[0] = tagType;
/* For all OID subidentifer values */
p = &dest[2];
for (numValues = 0; numValues < oid->numValues; ++numValues) {
/*
* Count the number of 7 bit chunks that are needed
* to encode the integer.
*/
value = oid->value[numValues] >> 7;
for (count = 0; value; ++count) {
/* There are bits still set */
value >>= 7;
} /* end for */
/* Store OID subidentifier value */
do {
value = oid->value[numValues];
value >>= (7 * count);
*p++ = (value & 0x7F) | (count ? 0x80 : 0);
} while (count--);
} /* end for */
/* length */
dest[1] = p - &dest[2];
return p - dest;
} /* end encodeOid() */

@ -0,0 +1,234 @@
/*
* ASN1 parser for standard elements
*
* Copyright 2009,2010 by Karsten Keil <kkeil@linux-pingi.de>
*
* This code is free software; you can redistribute it and/or modify
* it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE
* version 2.1 as published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU LESSER GENERAL PUBLIC LICENSE for more details.
*
*/
#include "asn1.h"
// ======================================================================
// general ASN.1
int ParseBoolean(struct asn1_parm *pc, u_char * p, u_char * end, int *i)
{
INIT;
*i = *p ? 1 : 0;
dprint(DBGM_ASN1_DEC, " DEBUG> BOOL = %d %#x\n", *i, *i);
return end - beg;
}
int ParseNull(struct asn1_parm *pc, u_char * p, u_char * end, int dummy)
{
INIT;
return p - beg;
}
static int ParseUInt(struct asn1_parm *pc, u_char * p, u_char * end, unsigned int *i)
{
INIT;
*i = 0;
while (len--) {
*i = (*i << 8) | *p;
p++;
}
return p - beg;
} /* end ParseInt() */
static int ParseSInt(struct asn1_parm *pc, u_char * p, u_char * end, signed int *i)
{
INIT;
/* Read value as signed */
if (*p & 0x80) {
/* The value is negative */
*i = -1;
} else {
*i = 0;
}
while (len--) {
*i = (*i << 8) | *p;
p++;
}
return p - beg;
} /* end ParseInt() */
int ParseUnsignedInteger(struct asn1_parm *pc, u_char * p, u_char * end, unsigned int *i)
{
int length;
length = ParseUInt(pc, p, end, i);
dprint(DBGM_ASN1_DEC, " DEBUG> INT = %d %#x\n", *i, *i);
return length;
}
int ParseSignedInteger(struct asn1_parm *pc, u_char * p, u_char * end, signed int *i)
{
int length;
length = ParseSInt(pc, p, end, i);
dprint(DBGM_ASN1_DEC, " DEBUG> INT = %d %#x\n", *i, *i);
return length;
}
int ParseEnum(struct asn1_parm *pc, u_char * p, u_char * end, unsigned int *i)
{
int length;
length = ParseUInt(pc, p, end, i);
dprint(DBGM_ASN1_DEC, " DEBUG> ENUM = %d %#x\n", *i, *i);
return length;
}
int ParseIA5String(struct asn1_parm *pc, u_char * p, u_char * end, struct asn1ParseString *str)
{
char *buf;
int numChars;
INIT;
if (len < 0) {
/* We do not handle indefinite length strings */
return -1;
}
if (str->maxSize < len + 1) {
numChars = str->maxSize - 1;
} else {
numChars = len;
}
len -= numChars;
str->length = numChars;
buf = str->buf;
while (numChars--)
*buf++ = *p++;
*buf = 0;
dprint(DBGM_ASN1_DEC, " DEBUG> IA5 = %s\n", str->buf);
if (0 < len) {
wprint("Discard %d IA5 max %zd\n", len, str->maxSize);
/* Discard the remainder of the string. We have no room left. */
p += len;
}
return p - beg;
}
int ParseNumericString(struct asn1_parm *pc, u_char * p, u_char * end, struct asn1ParseString *str)
{
char *buf;
int numChars;
INIT;
if (len < 0) {
/* We do not handle indefinite length strings */
return -1;
}
if (str->maxSize < len + 1) {
numChars = str->maxSize - 1;
} else {
numChars = len;
}
len -= numChars;
str->length = numChars;
buf = str->buf;
while (numChars--)
*buf++ = *p++;
*buf = 0;
dprint(DBGM_ASN1_DEC, " DEBUG> NumStr = %s\n", str->buf);
if (0 < len) {
wprint("Discard %d NumStr max %zd\n", len, str->maxSize);
/* Discard the remainder of the string. We have no room left. */
p += len;
}
return p - beg;
}
int ParseOctetString(struct asn1_parm *pc, u_char * p, u_char * end, struct asn1ParseString *str)
{
char *buf;
INIT;
if (len < 0) {
/* We do not handle indefinite length strings */
return -1;
}
if (str->maxSize < len + 1) {
/*
* The octet string will not fit in the available buffer
* and truncating it is not a good idea in all cases.
*/
eprint("OctetString does not fit %d max %zd\n", len, str->maxSize);
return -1;
}
str->length = len;
buf = str->buf;
while (len--)
*buf++ = *p++;
*buf = 0;
if (DBGM_ASN1_DEC & mI_debug_mask) {
char *tmp = malloc((3 * len) + 1);
if (tmp) {
mi_shexprint(tmp, p, len);
dprint(DBGM_ASN1_DEC, " DEBUG> Octets = %s\n", tmp);
free(tmp);
} else
eprint("MALLOC for %d bytes failed\n", (3 * len) + 1);
}
return p - beg;
}
int ParseOid(struct asn1_parm *pc, u_char * p, u_char * end, struct asn1Oid *oid)
{
int numValues;
int value;
INIT;
numValues = 0;
while (len) {
value = 0;
for (;;) {
--len;
value = (value << 7) | (*p & 0x7F);
if (!(*p++ & 0x80)) {
/* Last octet in the OID subidentifier value */
if (numValues < sizeof(oid->value) / sizeof(oid->value[0])) {
oid->value[numValues] = value;
} else {
dprint(DBGM_ASN1_WARN, "Too many OID subidentifier %d\n", value);
}
++numValues;
break;
}
if (!len) {
oid->numValues = 0;
wprint("Last OID subidentifier value (%d) not terminated!\n", value);
return -1;
}
} /* end for */
} /* end while */
if (numValues <= sizeof(oid->value) / sizeof(oid->value[0])) {
oid->numValues = numValues;
for (numValues = 0; numValues < oid->numValues; numValues++)
dprint(DBGM_ASN1_DEC, "OID->value[%d] = %d\n", numValues, oid->value[numValues]);
return p - beg;
} else {
/* Need to increase the size of the OID subidentifier list. */
wprint("Too many OID values (%d)!\n", numValues);
return -1;
}
}

@ -0,0 +1,26 @@
/*
*
* Three Party (3PTY) Supplementary Services ETS 300 188-2
*
* 3PTY Facility ie encode/decode header
*/
#ifndef __ASN1_3PTY_H
#define __ASN1_3PTY_H
#ifdef __cplusplus
extern "C" {
#endif
/* ------------------------------------------------------------------- */
int encodeFacBegin3PTY(__u8 * Dest, const struct asn1_parm *pc, const void *unused);
int encodeFacEnd3PTY(__u8 * Dest, const struct asn1_parm *pc, const void *unused);
/* ------------------------------------------------------------------- */
#ifdef __cplusplus
}
#endif
#endif /* __ASN1_3PTY_H */
/* ------------------------------------------------------------------- *//* end asn1_3pty.h */

@ -0,0 +1,290 @@
/*
*
* Abstract Syntax Notation.1 (ASN.1) ITU-T X.208
*
* Copyright 2009,2010 by Karsten Keil <kkeil@linux-pingi.de>
*
* This code is free software; you can redistribute it and/or modify
* it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE
* version 2.1 as published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU LESSER GENERAL PUBLIC LICENSE for more details.
*
*/
#ifndef __ASN1_H__
#define __ASN1_H__
#include <mISDN/suppserv.h>
#include <asm/types.h>
#include <sys/types.h>
#include "debug.h"
#ifdef __cplusplus
extern "C" {
#endif
/* ------------------------------------------------------------------- */
int ParseTag(u_char * p, u_char * end, int *tag);
int ParseLen(u_char * p, u_char * end, int *len);
#define ASN1_TAG_BOOLEAN 1
#define ASN1_TAG_INTEGER 2
#define ASN1_TAG_BIT_STRING 3
#define ASN1_TAG_OCTET_STRING 4
#define ASN1_TAG_NULL 5
#define ASN1_TAG_OBJECT_IDENTIFIER 6
#define ASN1_TAG_ENUM 10
#define ASN1_TAG_SEQUENCE (ASN1_TAG_CONSTRUCTED | 16)
#define ASN1_TAG_SET (ASN1_TAG_CONSTRUCTED | 17)
#define ASN1_TAG_NUMERIC_STRING 18
#define ASN1_TAG_PRINTABLE_STRING 19
#define ASN1_TAG_IA5_STRING 22
#define ASN1_TAG_UTC_TIME 23
#define ASN1_TAG_CONSTRUCTED 0x20
#define ASN1_TAG_TYPE_MASK 0xC0
#define ASN1_TAG_UNIVERSAL 0x00
#define ASN1_TAG_APPLICATION_WIDE 0x40
#define ASN1_TAG_CONTEXT_SPECIFIC 0x80
#define ASN1_TAG_PRIVATE 0xC0
#define ASN1_TAG_EXPLICIT 0x100
#define ASN1_TAG_OPT 0x200
#define ASN1_NOT_TAGGED 0x400
#define CallASN1(ret, p, end, todo) \
do { \
ret = todo; \
if (ret < 0) { \
eprint("CallASN1 internal error\n"); \
return -1; \
} \
p += ret; \
} while (0)
/* INIT must be placed after the last variable declared */
#define INIT \
int tag, len; \
int ret; \
u_char *beg __attribute__((unused)); \
\
beg = p; \
CallASN1(ret, p, end, ParseTag(p, end, &tag)); \
CallASN1(ret, p, end, ParseLen(p, end, &len)); \
if (len >= 0) { \
if (p + len > end) { \
eprint("ASN1 parser underflow %p/%p in %s\n", p + len, end, __func__); \
return -1; \
} \
dprint(DBGM_ASN1_DEC, "Start p=%p end=%p-->%p len=%d\n", p, end, p + len, len); \
end = p + len; \
}
#define XSEQUENCE_1(todo, act_tag, the_tag, arg1) \
do { \
if (p < end) { \
if (((the_tag) & ~ASN1_TAG_OPT) == ASN1_NOT_TAGGED) { \
if (((act_tag) == ASN1_NOT_TAGGED) || ((u_char) (act_tag) == *p)) { \
CallASN1(ret, p, end, todo(pc, p, end, arg1)); \
} else { \
if (!((the_tag) & ASN1_TAG_OPT)) { \
eprint("ASN1 XSEQUENCE_1 internal error 1\n"); \
return -1; \
} \
} \
} else if ((the_tag) & ASN1_TAG_EXPLICIT) { \
/* EXPLICIT tags are always constructed */ \
if ((u_char) (((the_tag) & 0xff) | (((act_tag) & ASN1_TAG_TYPE_MASK) | ASN1_TAG_CONSTRUCTED)) == *p) { \
int xtag, xlen; \
CallASN1(ret, p, end, ParseTag(p, end, &xtag)); \
CallASN1(ret, p, end, ParseLen(p, end, &xlen)); \
CallASN1(ret, p, end, todo(pc, p, end, arg1)); \
} else { \
if (!((the_tag) & ASN1_TAG_OPT)) { \
eprint("ASN1 XSEQUENCE_1 internal error 2\n"); \
return -1; \
} \
} \
} else { /* IMPLICIT */ \
if ((u_char) (((the_tag) & 0xff) | ((act_tag) & (ASN1_TAG_TYPE_MASK | ASN1_TAG_CONSTRUCTED))) == *p) { \
CallASN1(ret, p, end, todo(pc, p, end, arg1)); \
} else { \
if (!((the_tag) & ASN1_TAG_OPT)) { \
eprint("ASN1 XSEQUENCE_1 internal error 3\n"); \
return -1; \
} \
} \
} \
} else { \
if (!((the_tag) & ASN1_TAG_OPT)) { \
eprint("ASN1 XSEQUENCE_1 internal error 4\n"); \
return -1; \
} \
} \
} while (0)
#define XSEQUENCE_OPT_1(todo, act_tag, the_tag, arg1) \
XSEQUENCE_1(todo, act_tag, (the_tag | ASN1_TAG_OPT), arg1)
#define XSEQUENCE(todo, act_tag, the_tag) XSEQUENCE_1(todo, act_tag, the_tag, -1)
#define XSEQUENCE_OPT(todo, act_tag, the_tag) XSEQUENCE_OPT_1(todo, act_tag, the_tag, -1)
#define XCHOICE_1(todo, act_tag, the_tag, arg1) \
do { \
if ((act_tag) == ASN1_NOT_TAGGED) { \
return todo(pc, beg, end, arg1); \
} else if ((the_tag) == ASN1_NOT_TAGGED) { \
if ((act_tag) == tag) { \
return todo(pc, beg, end, arg1); \
} \
} else if ((act_tag) & ASN1_TAG_EXPLICIT) { \
/* EXPLICIT tags are always constructed */ \
if (((the_tag) | (((act_tag) & ASN1_TAG_TYPE_MASK) | ASN1_TAG_CONSTRUCTED)) == tag) { \
return todo(pc, p, end, arg1); \
} \
} else { \
if (((the_tag) | ((act_tag) & (ASN1_TAG_TYPE_MASK | ASN1_TAG_CONSTRUCTED))) == tag) { \
return todo(pc, beg, end, arg1); \
} \
} \
} while (0)
#define XCHOICE(todo, act_tag, the_tag) XCHOICE_1(todo, act_tag, the_tag, -1)
#define XCHOICE_DEFAULT \
do { \
eprint("ASN1 XCHOICE_DEFAULT internal error in %s\n", __func__); \
return -1; \
} while (0)
#define CHECK_P \
do { \
if (p >= end) { \
eprint("ASN1 parser underflow %p/%p in %s\n", p, end, __func__); \
return -1; \
} \
} while (0)
const struct asn1OidConvert *FindOidByOidValue(int length, const __u16 oidValues[]);
const struct asn1OidConvert *FindOidByEnum(__u16 value);
__u16 ConvertOidToEnum(const struct asn1Oid *oid, __u16 errorValue);
int ConvertEnumToOid(struct asn1Oid *oid, __u16 enumValue);
#define IsEnumOid(enumValue) \
((FAC_OID_BASE(1) <= (enumValue) \
&& (enumValue) < FAC_OID_BASE(FacOIDBase_Last)) ? 1 : 0)
/*
** ASN.1 Encoding
*/
/* Facility-Information-Element-Components prototypes */
enum asn1ComponentTag {
asn1ComponentTag_Invoke = ASN1_TAG_CONTEXT_SPECIFIC | ASN1_TAG_CONSTRUCTED | 1,
asn1ComponentTag_Result = ASN1_TAG_CONTEXT_SPECIFIC | ASN1_TAG_CONSTRUCTED | 2,
asn1ComponentTag_Error = ASN1_TAG_CONTEXT_SPECIFIC | ASN1_TAG_CONSTRUCTED | 3,
asn1ComponentTag_Reject = ASN1_TAG_CONTEXT_SPECIFIC | ASN1_TAG_CONSTRUCTED | 4,
};
__u8 *encodeComponent_Head(__u8 * p, enum asn1ComponentTag componentTag);
__u8 *encodeComponent_Head_Long_u8(__u8 * p, enum asn1ComponentTag componentTag);
int encodeComponent_Length(__u8 * msg, __u8 * end);
int encodeComponent_Length_Long_u8(__u8 * msg, __u8 * p);
__u8 *encodeComponentInvoke_Head(__u8 * Dest, int InvokeID, enum Operation OperationValue);
__u8 *encodeComponentInvoke_Head_Long_u8(__u8 * Dest, int InvokeID, enum Operation OperationValue);
int encodeOperationValue(__u8 * dest, int operationValue);
int encodeErrorValue(__u8 * dest, int errorValue);
/* Primitive ASN.1 prototypes */
#define ASN1_NUM_OCTETS_LONG_LENGTH_u8 2
#define ASN1_NUM_OCTETS_LONG_LENGTH_u16 3
int encodeLen_Long_u8(__u8 * dest, __u8 length);
int encodeLen_Long_u16(__u8 * dest, __u16 length);
int encodeNull(__u8 * dest, __u8 tagType);
int encodeBoolean(__u8 * dest, __u8 tagType, __u32 i);
int encodeInt(__u8 * dest, __u8 tagType, __s32 i);
int encodeEnum(__u8 * dest, __u8 tagType, __s32 i);
int encodeOctetString(__u8 * dest, __u8 tagType, const __s8 * str, __u8 len);
int encodeNumericString(__u8 * dest, __u8 tagType, const __s8 * str, __u8 len);
int encodePrintableString(__u8 * dest, __u8 tagType, const __s8 * str, __u8 len);
int encodeIA5String(__u8 * dest, __u8 tagType, const __s8 * str, __u8 len);
int encodeOid(__u8 * dest, __u8 tagType, const struct asn1Oid *oid);
/* Addressing-Data-Elements prototypes */
int encodePartyNumber_Full(__u8 * Dest, const struct FacPartyNumber *PartyNumber);
int encodePartySubaddress_Full(__u8 * Dest, const struct FacPartySubaddress *PartySubaddress);
int encodeAddress_Full(__u8 * Dest, const struct FacAddress *Address);
int encodePresentedNumberUnscreened_Full(__u8 * Dest, const struct FacPresentedNumberUnscreened *Presented);
int encodePresentedAddressScreened_Full(__u8 * Dest, const struct FacPresentedAddressScreened *Presented);
/*
** ASN.1 Parsing
*/
/* Facility-Information-Element-Components prototypes */
int ParseComponent(struct asn1_parm *parm, u_char * p, u_char * end);
/* Primitive ASN.1 prototypes */
int ParseBoolean(struct asn1_parm *pc, u_char * p, u_char * end, int *i);
int ParseNull(struct asn1_parm *pc, u_char * p, u_char * end, int dummy);
int ParseUnsignedInteger(struct asn1_parm *pc, u_char * p, u_char * end, unsigned int *i);
int ParseSignedInteger(struct asn1_parm *pc, u_char * p, u_char * end, signed int *i);
int ParseEnum(struct asn1_parm *pc, u_char * p, u_char * end, unsigned int *i);
struct asn1ParseString {
char *buf; /* Where to put the parsed string characters */
size_t maxSize; /* sizeof string buffer (Including an ASCIIz terminator) */
size_t length; /* length of string put into the string buffer (Without the terminator) */
};
int ParseIA5String(struct asn1_parm *pc, u_char * p, u_char * end, struct asn1ParseString *str);
int ParseNumericString(struct asn1_parm *pc, u_char * p, u_char * end, struct asn1ParseString *str);
int ParseOctetString(struct asn1_parm *pc, u_char * p, u_char * end, struct asn1ParseString *str);
int ParseOid(struct asn1_parm *pc, u_char * p, u_char * end, struct asn1Oid *oid);
/* Addressing-Data-Elements prototypes */
int ParsePartyNumber_Full(struct asn1_parm *pc, u_char * p, u_char * end, struct FacPartyNumber *PartyNumber);
int ParsePartySubaddress_Full(struct asn1_parm *pc, u_char * p, u_char * end, struct FacPartySubaddress *PartySubaddress);
int ParseAddress_Full(struct asn1_parm *pc, u_char * p, u_char * end, struct FacAddress *Address);
int ParsePresentedNumberUnscreened_Full(struct asn1_parm *pc, u_char * p, u_char * end,
struct FacPresentedNumberUnscreened *Presented);
int ParsePresentedAddressScreened_Full(struct asn1_parm *pc, u_char * p, u_char * end,
struct FacPresentedAddressScreened *Presented);
/* Advice Of Charge (AOC) prototypes */
int ParseAOCECurrency(struct asn1_parm *pc, u_char * p, u_char * end, struct FacAOCCurrency *cur);
int ParseAOCDChargingUnit(struct asn1_parm *pc, u_char * p, u_char * end, struct FacAOCChargingUnit *chu);
int ParseAOCDCurrency(struct asn1_parm *pc, u_char * p, u_char * end, struct FacAOCCurrency *cur);
int ParseAOCDCurrencyInfo(struct asn1_parm *pc, u_char * p, u_char * end, struct FacAOCCurrency *cur);
int ParseAOCDChargingUnitInfo(struct asn1_parm *pc, u_char * p, u_char * end, struct FacAOCChargingUnit *chu);
int ParseRecordedCurrency(struct asn1_parm *pc, u_char * p, u_char * end, struct FacAOCCurrency *cur);
int ParseRecordedUnitsList(struct asn1_parm *pc, u_char * p, u_char * end, __u32 *recordedUnits);
int ParseTypeOfChargingInfo(struct asn1_parm *pc, u_char * p, u_char * end, __u32 *typeOfChargingInfo);
int ParseRecordedUnits(struct asn1_parm *pc, u_char * p, u_char * end, __u32 *recordedUnits);
int ParseAOCDBillingId(struct asn1_parm *pc, u_char * p, u_char * end, __u32 *billingId);
int ParseAOCECurrencyInfo(struct asn1_parm *pc, u_char * p, u_char * end, struct FacAOCCurrency *cur);
int ParseAOCEChargingUnit(struct asn1_parm *pc, u_char * p, u_char * end, struct FacAOCChargingUnit *chu);
int ParseAOCEChargingUnitInfo(struct asn1_parm *pc, u_char * p, u_char * end, struct FacAOCChargingUnit *chu);
int ParseAOCEBillingId(struct asn1_parm *pc, u_char * p, u_char * end, __u32 *billingId);
int ParseCurrency(struct asn1_parm *pc, u_char * p, u_char * end, char *currency);
int ParseAmount(struct asn1_parm *pc, u_char * p, u_char * end, struct FacAOCCurrency *cur);
int ParseCurrencyAmount(struct asn1_parm *pc, u_char * p, u_char * end, unsigned int *currencyAmount);
int ParseMultiplier(struct asn1_parm *pc, u_char * p, u_char * end, unsigned int *multiplier);
int ParseTypeOfUnit(struct asn1_parm *pc, u_char * p, u_char * end, unsigned int *typeOfUnit);
int ParseNumberOfUnits(struct asn1_parm *pc, u_char * p, u_char * end, unsigned int *numberOfUnits);
int ParseChargingAssociation(struct asn1_parm *pc, u_char * p, u_char * end, struct ChargingAssociation *chargeAssoc);
int ParseChargeIdentifier(struct asn1_parm *pc, u_char * p, u_char * end, int *chargeIdentifier);
/* ------------------------------------------------------------------- */
#ifdef __cplusplus
}
#endif
#endif /* __ASN1_H__ */
/* ------------------------------------------------------------------- *//* end asn1.h */

@ -0,0 +1,94 @@
/*
* $Id$
*
* CCBS Supplementary Services ETS 300 359-1
* CCNR Supplementary Services ETS 301 065-1
*
* Generic functional protocol for the support of supplementary services ETS 300 196-1
*
* CCBS/CCNR Facility ie encode/decode header
*/
#ifndef __ASN1_CCBS_H
#define __ASN1_CCBS_H
#ifdef __cplusplus
extern "C" {
#endif
/* ------------------------------------------------------------------- */
int encodeFacStatusRequest(__u8 * Dest, const struct asn1_parm *pc, const struct FacStatusRequest *StatusRequest);
int ParseStatusRequest(struct asn1_parm *pc, u_char * p, u_char * end, struct FacStatusRequest *StatusRequest);
int ParseStatusRequest_RES(struct asn1_parm *pc, u_char * p, u_char * end, struct FacStatusRequest_RES *StatusRequest);
int encodeFacCallInfoRetain(__u8 * Dest, const struct asn1_parm *pc, const struct FacCallInfoRetain *CallInfoRetain);
int ParseCallInfoRetain(struct asn1_parm *pc, u_char * p, u_char * end, struct FacCallInfoRetain *CallInfoRetain);
int encodeFacEraseCallLinkageID(__u8 * Dest, const struct asn1_parm *pc, const struct FacEraseCallLinkageID *EraseCallLinkageID);
int ParseEraseCallLinkageID(struct asn1_parm *pc, u_char * p, u_char * end,
struct FacEraseCallLinkageID *EraseCallLinkageID);
int encodeFacCCBSDeactivate(__u8 * Dest, const struct asn1_parm *pc, const struct FacCCBSDeactivate *CCBSDeactivate);
int ParseCCBSDeactivate(struct asn1_parm *pc, u_char * p, u_char * end, struct FacCCBSDeactivate *CCBSDeactivate);
int encodeFacCCBSErase(__u8 * Dest, const struct asn1_parm *pc, const struct FacCCBSErase *CCBSErase);
int ParseCCBSErase(struct asn1_parm *pc, u_char * p, u_char * end, struct FacCCBSErase *CCBSErase);
int encodeFacCCBSRemoteUserFree(__u8 * Dest, const struct asn1_parm *pc, const struct FacCCBSRemoteUserFree *CCBSRemoteUserFree);
int ParseCCBSRemoteUserFree(struct asn1_parm *pc, u_char * p, u_char * end,
struct FacCCBSRemoteUserFree *CCBSRemoteUserFree);
int encodeFacCCBSCall(__u8 * Dest, const struct asn1_parm *pc, const struct FacCCBSCall *CCBSCall);
int ParseCCBSCall(struct asn1_parm *pc, u_char * p, u_char * end, struct FacCCBSCall *CCBSCall);
int encodeFacCCBSBFree(__u8 * Dest, const struct asn1_parm *pc, const struct FacCCBSBFree *CCBSBFree);
int ParseCCBSBFree(struct asn1_parm *pc, u_char * p, u_char * end, struct FacCCBSBFree *CCBSBFree);
int encodeFacCCBSStopAlerting(__u8 * Dest, const struct asn1_parm *pc, const struct FacCCBSStopAlerting *CCBSStopAlerting);
int ParseCCBSStopAlerting(struct asn1_parm *pc, u_char * p, u_char * end, struct FacCCBSStopAlerting *CCBSStopAlerting);
int encodeFacCCBSStatusRequest(__u8 * Dest, const struct asn1_parm *pc, const struct FacCCBSStatusRequest *CCBSStatusRequest);
int ParseCCBSStatusRequest(struct asn1_parm *pc, u_char * p, u_char * end,
struct FacCCBSStatusRequest *CCBSStatusRequest);
int ParseCCBSStatusRequest_RES(struct asn1_parm *pc, u_char * p, u_char * end,
struct FacCCBSStatusRequest_RES *CCBSStatusRequest);
int encodeFacCCBSRequest(__u8 * Dest, const struct asn1_parm *pc, const struct FacCCBSRequest *CCBSRequest);
int encodeFacCCNRRequest(__u8 * Dest, const struct asn1_parm *pc, const struct FacCCBSRequest *CCNRRequest);
int ParseCCBSRequest(struct asn1_parm *pc, u_char * p, u_char * end, struct FacCCBSRequest *CCBSRequest);
int ParseCCNRRequest(struct asn1_parm *pc, u_char * p, u_char * end, struct FacCCBSRequest *CCNRRequest);
int ParseCCBSRequest_RES(struct asn1_parm *pc, u_char * p, u_char * end, struct FacCCBSRequest_RES *CCBSRequest);
int ParseCCNRRequest_RES(struct asn1_parm *pc, u_char * p, u_char * end, struct FacCCBSRequest_RES *CCNRRequest);
int encodeFacCCBSInterrogate(__u8 * Dest, const struct asn1_parm *pc, const struct FacCCBSInterrogate *CCBSInterrogate);
int encodeFacCCNRInterrogate(__u8 * Dest, const struct asn1_parm *pc, const struct FacCCBSInterrogate *CCNRInterrogate);
int ParseCCBSInterrogate(struct asn1_parm *pc, u_char * p, u_char * end,
struct FacCCBSInterrogate *CCBSInterrogate);
int ParseCCNRInterrogate(struct asn1_parm *pc, u_char * p, u_char * end,
struct FacCCBSInterrogate *CCNRInterrogate);
int ParseCCBSInterrogate_RES(struct asn1_parm *pc, u_char * p, u_char * end,
struct FacCCBSInterrogate_RES *CCBSInterrogate);
int ParseCCNRInterrogate_RES(struct asn1_parm *pc, u_char * p, u_char * end,
struct FacCCBSInterrogate_RES *CCNRInterrogate);
int encodeFacCCBS_T_Call(__u8 * Dest, const struct asn1_parm *pc, const void *val);
int encodeFacCCBS_T_Suspend(__u8 * Dest, const struct asn1_parm *pc, const void *val);
int encodeFacCCBS_T_Resume(__u8 * Dest, const struct asn1_parm *pc, const void *val);
int encodeFacCCBS_T_RemoteUserFree(__u8 * Dest, const struct asn1_parm *pc, const void *val);
int encodeFacCCBS_T_Available(__u8 * Dest, const struct asn1_parm *pc, const void *val);
int encodeFacCCBS_T_Request(__u8 * Dest, const struct asn1_parm *pc, const struct FacCCBS_T_Request *CCBS_T_Request);
int encodeFacCCNR_T_Request(__u8 * Dest, const struct asn1_parm *pc, const struct FacCCBS_T_Request *CCNR_T_Request);
int ParseCCBS_T_Request(struct asn1_parm *pc, u_char * p, u_char * end, struct FacCCBS_T_Request *CCBS_T_Request);
int ParseCCNR_T_Request(struct asn1_parm *pc, u_char * p, u_char * end, struct FacCCBS_T_Request *CCNR_T_Request);
int ParseCCBS_T_Request_RES(struct asn1_parm *pc, u_char * p, u_char * end, struct FacCCBS_T_Request_RES *CCBS_T_Request);
int ParseCCNR_T_Request_RES(struct asn1_parm *pc, u_char * p, u_char * end, struct FacCCBS_T_Request_RES *CCNR_T_Request);
/* ------------------------------------------------------------------- */
#ifdef __cplusplus
}
#endif
#endif /* __ASN1_CCBS_H */
/* ------------------------------------------------------------------- *//* end asn1_ccbs.h */

@ -0,0 +1,78 @@
/* debug.h
*
* Basic Layer3 functions
*
* Author Karsten Keil <kkeil@linux-pingi.de>
*
* Copyright 2007 by Karsten Keil <kkeil@novell.com>
* Copyright 2009, 2010 by Karsten Keil <kkeil@linux-pingi.de>
*
* This code is free software; you can redistribute it and/or modify
* it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE
* version 2.1 as published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU LESSER GENERAL PUBLIC LICENSE for more details.
*
*/
#ifndef ISDN_DEBUG_H
#define ISDN_DEBUG_H
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <mISDN/mISDNcompat.h>
#define L3_DEB_WARN 0x00000001
#define L3_DEB_PROTERR 0x00000002
#define L3_DEB_STATE 0x00000004
#define L3_DEB_PROC 0x00000008
#define L3_DEB_CHECK 0x00000010
#define DBGM_L3 0x00000040
#define DBGM_L3DATA 0x00000080
#define DBGM_L3BUFFER 0x00000100
#define DBGM_L2 0x00000200
#define DBGM_L2_STATE 0x00000400
#define DBGM_ASN1_WARN 0x00010000
#define DBGM_ASN1_ENC 0x00020000
#define DBGM_ASN1_DEC 0x00040000
#define DBGM_ASN1_DATA 0x00080000
#define DBGM_ALL 0xffffffff
extern unsigned int mI_debug_mask;
#define mi_thread_create(a, b, c, d) _mi_thread_create(a, b, c, d, __FILE__, __PRETTY_FUNCTION__, __LINE__, #c)
extern int _mi_thread_create(pthread_t *thread, pthread_attr_t *attr, void *(*start_routine) (void *),
void *arg, const char *file, const char *caller, int line, const char *start_fn);
#define eprint(fmt, ...) mi_printf(__FILE__, __LINE__, __PRETTY_FUNCTION__, 1, fmt, ##__VA_ARGS__)
#define wprint(fmt, ...) mi_printf(__FILE__, __LINE__, __PRETTY_FUNCTION__, 2, fmt, ##__VA_ARGS__)
#define iprint(fmt, ...) mi_printf(__FILE__, __LINE__, __PRETTY_FUNCTION__, 3, fmt, ##__VA_ARGS__)
#define dprint(m, fmt, ...) do { if (m & mI_debug_mask) mi_printf(__FILE__, __LINE__, __PRETTY_FUNCTION__, 4, fmt, ##__VA_ARGS__);} while(0)
extern int mi_printf(const char *file, int line, const char *func, int lev, const char *fmt, ...) __attribute__ ((format (printf,5,6)));
#define dhexprint(m, h, d, l) do { if (m & mI_debug_mask) mi_dhexprint(__FILE__, __LINE__, __PRETTY_FUNCTION__, h, d, l);} while(0)
extern void mi_dhexprint(const char *file, int line, const char *func, const char *head, unsigned char *buf, int len);
extern void mi_shexprint(char *dest, unsigned char *buf, int len);
#ifdef MEMLEAK_DEBUG
extern void *__mi_alloc(size_t size, const char *file, int lineno, const char *func);
extern void *__mi_calloc(size_t nmemb, size_t size, const char *file, int lineno, const char *func);
extern void __mi_free(void *ptr, const char *file, int lineno, const char *func);
extern void __mi_reuse(void *ptr, const char *file, int lineno, const char *func);
#undef malloc
#undef calloc
#undef free
#define malloc(s) __mi_alloc(s, __FILE__, __LINE__, __PRETTY_FUNCTION__)
#define calloc(n, s) __mi_calloc(n, s, __FILE__, __LINE__, __PRETTY_FUNCTION__)
#define free(p) __mi_free(p, __FILE__, __LINE__, __PRETTY_FUNCTION__)
#endif
#endif

@ -0,0 +1,91 @@
/*
* $Id$
*
* Diversion Supplementary Services ETS 300 207-1 Table 3
*
* Diversion Facility ie encode/decode header
*
* Copyright 2009,2010 by Karsten Keil <kkeil@linux-pingi.de>
*
* This code is free software; you can redistribute it and/or modify
* it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE
* version 2.1 as published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU LESSER GENERAL PUBLIC LICENSE for more details.
*
*/
#ifndef __ASN1_DIVERSION_H__
#define __ASN1_DIVERSION_H__
#ifdef __cplusplus
extern "C" {
#endif
/* ------------------------------------------------------------------- */
int encodeFacActivationDiversion(__u8 * Dest, const struct asn1_parm *pc, const struct FacActivationDiversion *ActivationDiversion);
int ParseActivationDiversion(struct asn1_parm *pc, u_char * p, u_char * end,
struct FacActivationDiversion *ActivationDiversion);
int encodeFacDeactivationDiversion(__u8 * Dest, const struct asn1_parm *pc, const struct FacDeactivationDiversion *DeactivationDiversion);
int ParseDeactivationDiversion(struct asn1_parm *pc, u_char * p, u_char * end,
struct FacDeactivationDiversion *DeactivationDiversion);
int encodeFacActivationStatusNotificationDiv(__u8 * Dest, const struct asn1_parm *pc,
const struct FacActivationStatusNotificationDiv
*ActivationStatusNotificationDiv);
int ParseActivationStatusNotificationDiv(struct asn1_parm *pc, u_char * p, u_char * end,
struct FacActivationStatusNotificationDiv *ActivationStatusNotificationDiv);
int encodeFacDeactivationStatusNotificationDiv(__u8 * Dest, const struct asn1_parm *pc,
const struct FacDeactivationStatusNotificationDiv
*DeactivationStatusNotificationDiv);
int ParseDeactivationStatusNotificationDiv(struct asn1_parm *pc, u_char * p, u_char * end,
struct FacDeactivationStatusNotificationDiv
*DeactivationStatusNotificationDiv);
int encodeFacInterrogationDiversion(__u8 * Dest, const struct asn1_parm *pc, const struct FacInterrogationDiversion *InterrogationDiversion);
int ParseInterrogationDiversion(struct asn1_parm *pc, u_char * p, u_char * end,
struct FacInterrogationDiversion *InterrogationDiversion);
#define ParseInterrogationDiversion_RES ParseIntResultList
int ParseIntResultList(struct asn1_parm *pc, u_char * p, u_char * end, struct FacForwardingList *IntResultList);
int encodeFacDiversionInformation(__u8 * Dest, const struct asn1_parm *pc, const struct FacDiversionInformation *DiversionInformation);
int ParseDiversionInformation(struct asn1_parm *pc, u_char * p, u_char * end,
struct FacDiversionInformation *DiversionInformation);
int encodeFacCallDeflection(__u8 * Dest, const struct asn1_parm *pc, const struct FacCallDeflection *CallDeflection);
int ParseCallDeflection(struct asn1_parm *pc, u_char * p, u_char * end, struct FacCallDeflection *CallDeflection);
int encodeFacCallRerouteing(__u8 * Dest, const struct asn1_parm *pc, const struct FacCallRerouteing *CallRerouteing);
int ParseCallRerouteing(struct asn1_parm *pc, u_char * p, u_char * end, struct FacCallRerouteing *CallRerouteing);
int encodeFacInterrogateServedUserNumbers(__u8 * Dest, const struct asn1_parm *pc,
const struct FacServedUserNumberList *InterrogateServedUserNumbers);
#define ParseInterrogateServedUserNumbers_RES ParseServedUserNumberList
int ParseServedUserNumberList(struct asn1_parm *pc, u_char * p, u_char * end,
struct FacServedUserNumberList *ServedUserNumberList);
int encodeFacDivertingLegInformation1(__u8 * Dest, const struct asn1_parm *pc, const struct FacDivertingLegInformation1 *DivertingLegInformation1);
int ParseDivertingLegInformation1(struct asn1_parm *pc, u_char * p, u_char * end,
struct FacDivertingLegInformation1 *DivertingLegInformation1);
int encodeFacDivertingLegInformation2(__u8 * Dest, const struct asn1_parm *pc, const struct FacDivertingLegInformation2 *DivertingLegInformation2);
int ParseDivertingLegInformation2(struct asn1_parm *pc, u_char * p, u_char * end,
struct FacDivertingLegInformation2 *DivertingLegInformation2);
int encodeFacDivertingLegInformation3(__u8 * Dest, const struct asn1_parm *pc, const struct FacDivertingLegInformation3 *DivertingLegInformation3);
int ParseDivertingLegInformation3(struct asn1_parm *pc, u_char * p, u_char * end,
struct FacDivertingLegInformation3 *DivertingLegInformation3);
/* ------------------------------------------------------------------- */
#ifdef __cplusplus
}
#endif
#endif /* __ASN1_DIVERSION_H__ */
/* ------------------------------------------------------------------- *//* end asn1_diversion.h */

@ -0,0 +1,74 @@
/* dss1.h
*
* Author Karsten Keil <kkeil@novell.com>
*
* Copyright 2007 by Karsten Keil <kkeil@novell.com>
*
* This code is free software; you can redistribute it and/or modify
* it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE
* version 2.1 as published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU LESSER GENERAL PUBLIC LICENSE for more details.
*
*/
#ifndef DSS1_H
#define DSS1_H
/*
* Timer values
*/
#define T302 15000
#define T303 4000
#define T304 30000
#define T305 30000
#define T308 4000
/* for layer 1 certification T309 < layer1 T3 (e.g. 4000) */
/* This makes some tests easier and quicker */
/* default value is 90 seconds */
#define T309 90000
/* T310 can be between 30-120 Seconds. We use 120 Seconds so the user can hear
the inband messages */
#define T310 120000
#define T312 6000
#define T313 4000
#define T318 4000
#define T319 4000
#define N303 1
#define T_CTRL 180000
#define THOLD 4000
#define TRETRIEVE 4000
/* private TIMER events */
#define CC_T301 0x030101
#define CC_T302 0x030201
#define CC_T303 0x030301
#define CC_T304 0x030401
#define CC_T305 0x030501
#define CC_T308_1 0x030801
#define CC_T308_2 0x030802
#define CC_T309 0x030901
#define CC_T310 0x031001
#define CC_T312 0x031201
#define CC_T313 0x031301
#define CC_T318 0x031801
#define CC_T319 0x031901
#define CC_TCTRL 0x031f01
#define CC_THOLD 0x03a001
#define CC_TRETRIEVE 0x03a101
#define AUX_IDLE 0
#define AUX_HOLD_REQ 1
#define AUX_CALL_HELD 2
#define AUX_RETRIEVE_REQ 3
#define AUX_HOLD_IND 4
#define AUX_RETRIEVE_IND 5
#define VALID_HOLD_STATES_PTMP (SBIT(3) | SBIT(4) | SBIT(10))
#define VALID_HOLD_STATES_PTP (SBIT(3) | SBIT(4) | SBIT(7) | SBIT(8) | SBIT(9) | SBIT(10))
#endif

@ -0,0 +1,47 @@
/*
* $Id$
*
* Explicit Call Transfer (ECT) Supplementary Services ETS 300 369-1
*
* ECT Facility ie encode/decode header
*/
#ifndef __ASN1_ECT_H
#define __ASN1_ECT_H
#ifdef __cplusplus
extern "C" {
#endif
/* ------------------------------------------------------------------- */
int encodeFacEctExecute(__u8 * Dest, const struct asn1_parm *pc, const void *val);
int encodeFacExplicitEctExecute(__u8 * Dest, const struct asn1_parm *pc, const struct FacExplicitEctExecute *ExplicitEctExecute);
int ParseExplicitEctExecute(struct asn1_parm *pc, u_char * p, u_char * end,
struct FacExplicitEctExecute *ExplicitEctExecute);
int encodeFacRequestSubaddress(__u8 * Dest, const struct asn1_parm *pc, const void *val);
int encodeFacSubaddressTransfer(__u8 * Dest, const struct asn1_parm *pc, const struct FacSubaddressTransfer *SubaddressTransfer);
int ParseSubaddressTransfer(struct asn1_parm *pc, u_char * p, u_char * end,
struct FacSubaddressTransfer *SubaddressTransfer);
int encodeFacEctLinkIdRequest(__u8 * Dest, const struct asn1_parm *pc, const struct FacEctLinkIdRequest_RES *EctLinkIdRequest);
int ParseEctLinkIdRequest_RES(struct asn1_parm *pc, u_char * p, u_char * end,
struct FacEctLinkIdRequest_RES *EctLinkIdRequest);
int encodeFacEctInform(__u8 * Dest, const struct asn1_parm *pc, const struct FacEctInform *EctInform);
int ParseEctInform(struct asn1_parm *pc, u_char * p, u_char * end, struct FacEctInform *EctInform);
int encodeFacEctLoopTest(__u8 * Dest, const struct asn1_parm *pc, const struct FacEctLoopTest *EctLoopTest);
int ParseEctLoopTest(struct asn1_parm *pc, u_char * p, u_char * end, struct FacEctLoopTest *EctLoopTest);
int ParseEctLoopTest_RES(struct asn1_parm *pc, u_char * p, u_char * end, struct FacEctLoopTest_RES *EctLoopTest);
/* ------------------------------------------------------------------- */
#ifdef __cplusplus
}
#endif
#endif /* __ASN1_ECT_H */
/* ------------------------------------------------------------------- *//* end asn1_ect.h */

@ -0,0 +1,63 @@
/* $Id: fsm.h,v 2.0 2007/06/29 14:35:31 kkeil Exp $
*
*
* Author Karsten Keil <kkeil@novell.com>
*
* Copyright 2007 by Karsten Keil <kkeil@novell.com>
*
* This code is free software; you can redistribute it and/or modify
* it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE
* version 2.1 as published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU LESSER GENERAL PUBLIC LICENSE for more details.
*
*/
/* Statemachine */
#include "mtimer.h"
struct FsmInst;
typedef void (* FSMFNPTR)(struct FsmInst *, int, void *);
struct Fsm {
FSMFNPTR *jumpmatrix;
int state_count, event_count;
const char **strEvent, **strState;
};
struct FsmInst {
struct Fsm *fsm;
struct timer_base *tb;
int state;
int debug;
void *userdata;
int userint;
void (*printdebug)(struct FsmInst *, const char *, ...);
};
struct FsmNode {
int state, event;
void (*routine) (struct FsmInst *, int, void *);
};
struct FsmTimer {
struct FsmInst *fi;
struct mtimer tl;
int event;
void *arg;
};
extern void FsmNew(struct Fsm *, struct FsmNode *, int);
extern void FsmFree(struct Fsm *);
extern int FsmEvent(struct FsmInst *, int , void *);
extern void FsmChangeState(struct FsmInst *, int);
extern void FsmInitTimer(struct FsmInst *, struct FsmTimer *);
extern int FsmAddTimer(struct FsmTimer *, int, int, void *, int);
extern void FsmRestartTimer(struct FsmTimer *, int, int, void *, int);
extern void FsmDelTimer(struct FsmTimer *, int);

@ -0,0 +1,76 @@
/* helper.h
*
* some helper functions
*
* Author Karsten Keil <kkeil@novell.com>
*
* Copyright 2007 by Karsten Keil <kkeil@novell.com>
*
* This code is free software; you can redistribute it and/or modify
* it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE
* version 2.1 as published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU LESSER GENERAL PUBLIC LICENSE for more details.
*
*/
#ifndef _HELPER_H
#define _HELPER_H
#undef offsetof
#ifdef __compiler_offsetof
#define offsetof(TYPE,MEMBER) __compiler_offsetof(TYPE,MEMBER)
#else