diff --git a/capi20/Makefile.am b/capi20/Makefile.am index 16ccd09a..9e0fad81 100644 --- a/capi20/Makefile.am +++ b/capi20/Makefile.am @@ -5,11 +5,14 @@ CLEANFILES = *~ comperr MAINTAINERCLEANFILES = configure aclocal.m4 Makefile.in config.h.in stamp-h.in -include_HEADERS = capi20.h capiutils.h +include_HEADERS = capi20.h capiutils.h capicmd.h lib_LTLIBRARIES = libcapi20.la +lib_LIBRARIES = libcapi20dyn.a libcapi20_la_SOURCES = capi20.c capifunc.c convert.c -libcapi20_la_LDFLAGS = -version-info 2:4:0 +libcapi20_la_LDFLAGS = -version-info 2:5:0 + +libcapi20dyn_a_SOURCES = capidyn.c # libcapi20_la_LIBADD = $(LIBADD_DL) $(OBJECTS): libtool diff --git a/capi20/Makefile.in b/capi20/Makefile.in index fa8d709c..f345ba27 100644 --- a/capi20/Makefile.in +++ b/capi20/Makefile.in @@ -76,21 +76,29 @@ AUTOMAKE_OPTIONS = no-dependencies foreign CLEANFILES = *~ comperr MAINTAINERCLEANFILES = configure aclocal.m4 Makefile.in config.h.in -include_HEADERS = capi20.h capiutils.h +include_HEADERS = capi20.h capiutils.h capicmd.h lib_LTLIBRARIES = libcapi20.la +lib_LIBRARIES = libcapi20dyn.a libcapi20_la_SOURCES = capi20.c capifunc.c convert.c -libcapi20_la_LDFLAGS = -version-info 2:4:0 +libcapi20_la_LDFLAGS = -version-info 2:5:0 + +libcapi20dyn_a_SOURCES = capidyn.c ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_CLEAN_FILES = -LTLIBRARIES = $(lib_LTLIBRARIES) +LIBRARIES = $(lib_LIBRARIES) DEFS = @DEFS@ -I. -I$(srcdir) CPPFLAGS = @CPPFLAGS@ LDFLAGS = @LDFLAGS@ LIBS = @LIBS@ +libcapi20dyn_a_LIBADD = +libcapi20dyn_a_OBJECTS = capidyn.o +AR = ar +LTLIBRARIES = $(lib_LTLIBRARIES) + libcapi20_la_LIBADD = libcapi20_la_OBJECTS = capi20.lo capifunc.lo convert.lo CFLAGS = @CFLAGS@ @@ -109,8 +117,8 @@ DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) TAR = tar GZIP_ENV = --best -SOURCES = $(libcapi20_la_SOURCES) -OBJECTS = $(libcapi20_la_OBJECTS) +SOURCES = $(libcapi20dyn_a_SOURCES) $(libcapi20_la_SOURCES) +OBJECTS = $(libcapi20dyn_a_OBJECTS) $(libcapi20_la_OBJECTS) all: all-redirect .SUFFIXES: @@ -130,29 +138,36 @@ config.status: $(srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) $(srcdir)/configure: $(srcdir)/configure.in $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES) cd $(srcdir) && $(AUTOCONF) -mostlyclean-libLTLIBRARIES: +mostlyclean-libLIBRARIES: -clean-libLTLIBRARIES: - -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) +clean-libLIBRARIES: + -test -z "$(lib_LIBRARIES)" || rm -f $(lib_LIBRARIES) -distclean-libLTLIBRARIES: +distclean-libLIBRARIES: -maintainer-clean-libLTLIBRARIES: +maintainer-clean-libLIBRARIES: -install-libLTLIBRARIES: $(lib_LTLIBRARIES) +install-libLIBRARIES: $(lib_LIBRARIES) @$(NORMAL_INSTALL) $(mkinstalldirs) $(DESTDIR)$(libdir) - @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ + @list='$(lib_LIBRARIES)'; for p in $$list; do \ if test -f $$p; then \ - echo "$(LIBTOOL) --mode=install $(INSTALL) $$p $(DESTDIR)$(libdir)/$$p"; \ - $(LIBTOOL) --mode=install $(INSTALL) $$p $(DESTDIR)$(libdir)/$$p; \ + echo " $(INSTALL_DATA) $$p $(DESTDIR)$(libdir)/$$p"; \ + $(INSTALL_DATA) $$p $(DESTDIR)$(libdir)/$$p; \ + else :; fi; \ + done + @$(POST_INSTALL) + @list='$(lib_LIBRARIES)'; for p in $$list; do \ + if test -f $$p; then \ + echo " $(RANLIB) $(DESTDIR)$(libdir)/$$p"; \ + $(RANLIB) $(DESTDIR)$(libdir)/$$p; \ else :; fi; \ done -uninstall-libLTLIBRARIES: +uninstall-libLIBRARIES: @$(NORMAL_UNINSTALL) - list='$(lib_LTLIBRARIES)'; for p in $$list; do \ - $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$$p; \ + list='$(lib_LIBRARIES)'; for p in $$list; do \ + rm -f $(DESTDIR)$(libdir)/$$p; \ done .c.o: @@ -193,6 +208,36 @@ distclean-libtool: maintainer-clean-libtool: +libcapi20dyn.a: $(libcapi20dyn_a_OBJECTS) $(libcapi20dyn_a_DEPENDENCIES) + -rm -f libcapi20dyn.a + $(AR) cru libcapi20dyn.a $(libcapi20dyn_a_OBJECTS) $(libcapi20dyn_a_LIBADD) + $(RANLIB) libcapi20dyn.a + +mostlyclean-libLTLIBRARIES: + +clean-libLTLIBRARIES: + -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) + +distclean-libLTLIBRARIES: + +maintainer-clean-libLTLIBRARIES: + +install-libLTLIBRARIES: $(lib_LTLIBRARIES) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(libdir) + @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ + if test -f $$p; then \ + echo "$(LIBTOOL) --mode=install $(INSTALL) $$p $(DESTDIR)$(libdir)/$$p"; \ + $(LIBTOOL) --mode=install $(INSTALL) $$p $(DESTDIR)$(libdir)/$$p; \ + else :; fi; \ + done + +uninstall-libLTLIBRARIES: + @$(NORMAL_UNINSTALL) + list='$(lib_LTLIBRARIES)'; for p in $$list; do \ + $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$$p; \ + done + libcapi20.la: $(libcapi20_la_OBJECTS) $(libcapi20_la_DEPENDENCIES) $(LINK) -rpath $(libdir) $(libcapi20_la_LDFLAGS) $(libcapi20_la_OBJECTS) $(libcapi20_la_LIBADD) $(LIBS) @@ -296,7 +341,7 @@ check-am: all-am check: check-am installcheck-am: installcheck: installcheck-am -install-exec-am: install-libLTLIBRARIES +install-exec-am: install-libLIBRARIES install-libLTLIBRARIES install-exec: install-exec-am install-data-am: install-includeHEADERS @@ -305,14 +350,16 @@ install-data: install-data-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am install: install-am -uninstall-am: uninstall-libLTLIBRARIES uninstall-includeHEADERS +uninstall-am: uninstall-libLIBRARIES uninstall-libLTLIBRARIES \ + uninstall-includeHEADERS uninstall: uninstall-am -all-am: Makefile $(LTLIBRARIES) $(HEADERS) +all-am: Makefile $(LIBRARIES) $(LTLIBRARIES) $(HEADERS) all-redirect: all-am install-strip: $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install installdirs: - $(mkinstalldirs) $(DESTDIR)$(libdir) $(DESTDIR)$(includedir) + $(mkinstalldirs) $(DESTDIR)$(libdir) $(DESTDIR)$(libdir) \ + $(DESTDIR)$(includedir) mostlyclean-generic: @@ -326,48 +373,51 @@ distclean-generic: maintainer-clean-generic: -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) -mostlyclean-am: mostlyclean-libLTLIBRARIES mostlyclean-compile \ - mostlyclean-libtool mostlyclean-tags \ - mostlyclean-generic +mostlyclean-am: mostlyclean-libLIBRARIES mostlyclean-compile \ + mostlyclean-libtool mostlyclean-libLTLIBRARIES \ + mostlyclean-tags mostlyclean-generic mostlyclean: mostlyclean-am -clean-am: clean-libLTLIBRARIES clean-compile clean-libtool clean-tags \ - clean-generic mostlyclean-am +clean-am: clean-libLIBRARIES clean-compile clean-libtool \ + clean-libLTLIBRARIES clean-tags clean-generic \ + mostlyclean-am clean: clean-am -distclean-am: distclean-libLTLIBRARIES distclean-compile \ - distclean-libtool distclean-tags distclean-generic \ - clean-am +distclean-am: distclean-libLIBRARIES distclean-compile \ + distclean-libtool distclean-libLTLIBRARIES \ + distclean-tags distclean-generic clean-am -rm -f libtool distclean: distclean-am -rm -f config.status -maintainer-clean-am: maintainer-clean-libLTLIBRARIES \ +maintainer-clean-am: maintainer-clean-libLIBRARIES \ maintainer-clean-compile maintainer-clean-libtool \ - maintainer-clean-tags maintainer-clean-generic \ - distclean-am + maintainer-clean-libLTLIBRARIES maintainer-clean-tags \ + maintainer-clean-generic distclean-am @echo "This command is intended for maintainers to use;" @echo "it deletes files that may require special tools to rebuild." maintainer-clean: maintainer-clean-am -rm -f config.status -.PHONY: mostlyclean-libLTLIBRARIES distclean-libLTLIBRARIES \ +.PHONY: mostlyclean-libLIBRARIES distclean-libLIBRARIES \ +clean-libLIBRARIES maintainer-clean-libLIBRARIES uninstall-libLIBRARIES \ +install-libLIBRARIES mostlyclean-compile distclean-compile \ +clean-compile maintainer-clean-compile mostlyclean-libtool \ +distclean-libtool clean-libtool maintainer-clean-libtool \ +mostlyclean-libLTLIBRARIES distclean-libLTLIBRARIES \ clean-libLTLIBRARIES maintainer-clean-libLTLIBRARIES \ -uninstall-libLTLIBRARIES install-libLTLIBRARIES mostlyclean-compile \ -distclean-compile clean-compile maintainer-clean-compile \ -mostlyclean-libtool distclean-libtool clean-libtool \ -maintainer-clean-libtool uninstall-includeHEADERS \ -install-includeHEADERS tags mostlyclean-tags distclean-tags clean-tags \ -maintainer-clean-tags distdir info-am info dvi-am dvi check check-am \ -installcheck-am installcheck install-exec-am install-exec \ -install-data-am install-data install-am install uninstall-am uninstall \ -all-redirect all-am all installdirs mostlyclean-generic \ -distclean-generic clean-generic maintainer-clean-generic clean \ -mostlyclean distclean maintainer-clean +uninstall-libLTLIBRARIES install-libLTLIBRARIES \ +uninstall-includeHEADERS install-includeHEADERS tags mostlyclean-tags \ +distclean-tags clean-tags maintainer-clean-tags distdir info-am info \ +dvi-am dvi check check-am installcheck-am installcheck install-exec-am \ +install-exec install-data-am install-data install-am install \ +uninstall-am uninstall all-redirect all-am all installdirs \ +mostlyclean-generic distclean-generic clean-generic \ +maintainer-clean-generic clean mostlyclean distclean maintainer-clean stamp-h.in # libcapi20_la_LIBADD = $(LIBADD_DL) diff --git a/capi20/capi20.c b/capi20/capi20.c index a2042b08..3284c586 100644 --- a/capi20/capi20.c +++ b/capi20/capi20.c @@ -2,6 +2,10 @@ * $Id$ * * $Log$ + * Revision 1.15 2000/04/10 09:08:06 calle + * capi20_wait_for_message will now return CapiReceiveQueueEmpty on + * timeout and error. + * * Revision 1.14 2000/04/07 16:06:09 calle * Bugfix: without devfs open where without NONBLOCK, ahhh. * @@ -63,11 +67,6 @@ #include #include "capi20.h" -#define CAPIMSG_LEN(m) (m[0] | (m[1] << 8)) -#define CAPIMSG_COMMAND(m) (m[4]) -#define CAPIMSG_SUBCOMMAND(m) (m[5]) -#define CAPIMSG_DATALEN(m) (m[16] | (m[17]<<8)) - static char capidevname[] = "/dev/capi20"; static char capidevnamenew[] = "/dev/isdn/capi20"; diff --git a/capi20/capicmd.h b/capi20/capicmd.h new file mode 100644 index 00000000..c7a1a18a --- /dev/null +++ b/capi20/capicmd.h @@ -0,0 +1,134 @@ +/* + * $Id$ + * + * CAPI 2.0 Interface for Linux + * + * Copyright 1997 by Carsten Paeth (calle@calle.in-berlin.de) + * + * $Log$ + * Revision 1.2 2000/03/03 15:50:42 calle + * - kernel CAPI: + * - Changed parameter "param" in capi_signal from __u32 to void *. + * - rewrote notifier handling in kcapi.c + * - new notifier NCCI_UP and NCCI_DOWN + * - User CAPI: + * - /dev/capi20 is now a cloning device. + * - middleware extentions prepared. + * - capidrv.c + * - locking of list operations and module count updates. + * + * Revision 1.1 1997/03/04 21:50:30 calle + * Frirst version in isdn4linux + * + * Revision 2.2 1997/02/12 09:31:39 calle + * new version + * + * Revision 1.1 1997/01/31 10:32:20 calle + * Initial revision + * + * + */ +#ifndef __CAPICMD_H__ +#define __CAPICMD_H__ + +#define CAPI_MSG_BASELEN 8 +#define CAPI_DATA_B3_REQ_LEN (CAPI_MSG_BASELEN+4+4+2+2+2) +#define CAPI_DATA_B3_RESP_LEN (CAPI_MSG_BASELEN+4+2) + +/*----- CAPI commands -----*/ +#define CAPI_ALERT 0x01 +#define CAPI_CONNECT 0x02 +#define CAPI_CONNECT_ACTIVE 0x03 +#define CAPI_CONNECT_B3_ACTIVE 0x83 +#define CAPI_CONNECT_B3 0x82 +#define CAPI_CONNECT_B3_T90_ACTIVE 0x88 +#define CAPI_DATA_B3 0x86 +#define CAPI_DISCONNECT_B3 0x84 +#define CAPI_DISCONNECT 0x04 +#define CAPI_FACILITY 0x80 +#define CAPI_INFO 0x08 +#define CAPI_LISTEN 0x05 +#define CAPI_MANUFACTURER 0xff +#define CAPI_RESET_B3 0x87 +#define CAPI_SELECT_B_PROTOCOL 0x41 + +/*----- CAPI subcommands -----*/ + +#define CAPI_REQ 0x80 +#define CAPI_CONF 0x81 +#define CAPI_IND 0x82 +#define CAPI_RESP 0x83 + +/*----- CAPI combined commands -----*/ + +#define CAPICMD(cmd,subcmd) (((cmd)<<8)|(subcmd)) + +#define CAPI_DISCONNECT_REQ CAPICMD(CAPI_DISCONNECT,CAPI_REQ) +#define CAPI_DISCONNECT_CONF CAPICMD(CAPI_DISCONNECT,CAPI_CONF) +#define CAPI_DISCONNECT_IND CAPICMD(CAPI_DISCONNECT,CAPI_IND) +#define CAPI_DISCONNECT_RESP CAPICMD(CAPI_DISCONNECT,CAPI_RESP) + +#define CAPI_ALERT_REQ CAPICMD(CAPI_ALERT,CAPI_REQ) +#define CAPI_ALERT_CONF CAPICMD(CAPI_ALERT,CAPI_CONF) + +#define CAPI_CONNECT_REQ CAPICMD(CAPI_CONNECT,CAPI_REQ) +#define CAPI_CONNECT_CONF CAPICMD(CAPI_CONNECT,CAPI_CONF) +#define CAPI_CONNECT_IND CAPICMD(CAPI_CONNECT,CAPI_IND) +#define CAPI_CONNECT_RESP CAPICMD(CAPI_CONNECT,CAPI_RESP) + +#define CAPI_CONNECT_ACTIVE_REQ CAPICMD(CAPI_CONNECT_ACTIVE,CAPI_REQ) +#define CAPI_CONNECT_ACTIVE_CONF CAPICMD(CAPI_CONNECT_ACTIVE,CAPI_CONF) +#define CAPI_CONNECT_ACTIVE_IND CAPICMD(CAPI_CONNECT_ACTIVE,CAPI_IND) +#define CAPI_CONNECT_ACTIVE_RESP CAPICMD(CAPI_CONNECT_ACTIVE,CAPI_RESP) + +#define CAPI_SELECT_B_PROTOCOL_REQ CAPICMD(CAPI_SELECT_B_PROTOCOL,CAPI_REQ) +#define CAPI_SELECT_B_PROTOCOL_CONF CAPICMD(CAPI_SELECT_B_PROTOCOL,CAPI_CONF) + +#define CAPI_CONNECT_B3_ACTIVE_REQ CAPICMD(CAPI_CONNECT_B3_ACTIVE,CAPI_REQ) +#define CAPI_CONNECT_B3_ACTIVE_CONF CAPICMD(CAPI_CONNECT_B3_ACTIVE,CAPI_CONF) +#define CAPI_CONNECT_B3_ACTIVE_IND CAPICMD(CAPI_CONNECT_B3_ACTIVE,CAPI_IND) +#define CAPI_CONNECT_B3_ACTIVE_RESP CAPICMD(CAPI_CONNECT_B3_ACTIVE,CAPI_RESP) + +#define CAPI_CONNECT_B3_REQ CAPICMD(CAPI_CONNECT_B3,CAPI_REQ) +#define CAPI_CONNECT_B3_CONF CAPICMD(CAPI_CONNECT_B3,CAPI_CONF) +#define CAPI_CONNECT_B3_IND CAPICMD(CAPI_CONNECT_B3,CAPI_IND) +#define CAPI_CONNECT_B3_RESP CAPICMD(CAPI_CONNECT_B3,CAPI_RESP) + + +#define CAPI_CONNECT_B3_T90_ACTIVE_IND CAPICMD(CAPI_CONNECT_B3_T90_ACTIVE,CAPI_IND) +#define CAPI_CONNECT_B3_T90_ACTIVE_RESP CAPICMD(CAPI_CONNECT_B3_T90_ACTIVE,CAPI_RESP) + +#define CAPI_DATA_B3_REQ CAPICMD(CAPI_DATA_B3,CAPI_REQ) +#define CAPI_DATA_B3_CONF CAPICMD(CAPI_DATA_B3,CAPI_CONF) +#define CAPI_DATA_B3_IND CAPICMD(CAPI_DATA_B3,CAPI_IND) +#define CAPI_DATA_B3_RESP CAPICMD(CAPI_DATA_B3,CAPI_RESP) + +#define CAPI_DISCONNECT_B3_REQ CAPICMD(CAPI_DISCONNECT_B3,CAPI_REQ) +#define CAPI_DISCONNECT_B3_CONF CAPICMD(CAPI_DISCONNECT_B3,CAPI_CONF) +#define CAPI_DISCONNECT_B3_IND CAPICMD(CAPI_DISCONNECT_B3,CAPI_IND) +#define CAPI_DISCONNECT_B3_RESP CAPICMD(CAPI_DISCONNECT_B3,CAPI_RESP) + +#define CAPI_RESET_B3_REQ CAPICMD(CAPI_RESET_B3,CAPI_REQ) +#define CAPI_RESET_B3_CONF CAPICMD(CAPI_RESET_B3,CAPI_CONF) +#define CAPI_RESET_B3_IND CAPICMD(CAPI_RESET_B3,CAPI_IND) +#define CAPI_RESET_B3_RESP CAPICMD(CAPI_RESET_B3,CAPI_RESP) + +#define CAPI_LISTEN_REQ CAPICMD(CAPI_LISTEN,CAPI_REQ) +#define CAPI_LISTEN_CONF CAPICMD(CAPI_LISTEN,CAPI_CONF) + +#define CAPI_MANUFACTURER_REQ CAPICMD(CAPI_MANUFACTURER,CAPI_REQ) +#define CAPI_MANUFACTURER_CONF CAPICMD(CAPI_MANUFACTURER,CAPI_CONF) +#define CAPI_MANUFACTURER_IND CAPICMD(CAPI_MANUFACTURER,CAPI_IND) +#define CAPI_MANUFACTURER_RESP CAPICMD(CAPI_MANUFACTURER,CAPI_RESP) + +#define CAPI_FACILITY_REQ CAPICMD(CAPI_FACILITY,CAPI_REQ) +#define CAPI_FACILITY_CONF CAPICMD(CAPI_FACILITY,CAPI_CONF) +#define CAPI_FACILITY_IND CAPICMD(CAPI_FACILITY,CAPI_IND) +#define CAPI_FACILITY_RESP CAPICMD(CAPI_FACILITY,CAPI_RESP) + +#define CAPI_INFO_REQ CAPICMD(CAPI_INFO,CAPI_REQ) +#define CAPI_INFO_CONF CAPICMD(CAPI_INFO,CAPI_CONF) +#define CAPI_INFO_IND CAPICMD(CAPI_INFO,CAPI_IND) +#define CAPI_INFO_RESP CAPICMD(CAPI_INFO,CAPI_RESP) + +#endif /* __CAPICMD_H__ */ diff --git a/capi20/capiutils.h b/capi20/capiutils.h index f7e81fb3..c0b83d55 100644 --- a/capi20/capiutils.h +++ b/capi20/capiutils.h @@ -1,10 +1,12 @@ -#ifndef __CAPIUTIL_H__ -#define __CAPIUTIL_H__ +#ifndef __CAPIUTILS_H__ +#define __CAPIUTILS_H__ #include #include #include +#include + #ifdef __cplusplus extern "C" { #endif @@ -102,6 +104,51 @@ typedef enum { CAPI_COMPOSE = 0, CAPI_DEFAULT = 1 } _cmstruct; #define CAPI_IND 0x82 #define CAPI_RESP 0x83 +/*-----------------------------------------------------------------------*/ + +#define CAPIMSG_BASELEN 8 +#define CAPIMSG_U8(m, off) (m[off]) +#define CAPIMSG_U16(m, off) (m[off]|(m[(off)+1]<<8)) +#define CAPIMSG_U32(m, off) (m[off]|(m[(off)+1]<<8)|(m[(off)+2]<<16)|(m[(off)+3]<<24)) +#define CAPIMSG_LEN(m) CAPIMSG_U16(m,0) +#define CAPIMSG_APPID(m) CAPIMSG_U16(m,2) +#define CAPIMSG_COMMAND(m) CAPIMSG_U8(m,4) +#define CAPIMSG_SUBCOMMAND(m) CAPIMSG_U8(m,5) +#define CAPIMSG_CMD(m) (((m[4])<<8)|(m[5])) +#define CAPIMSG_MSGID(m) CAPIMSG_U16(m,6) +#define CAPIMSG_CONTROLLER(m) (m[8] & 0x7f) +#define CAPIMSG_CONTROL(m) CAPIMSG_U32(m, 8) +#define CAPIMSG_NCCI(m) CAPIMSG_CONTROL(m) +#define CAPIMSG_DATALEN(m) CAPIMSG_U16(m,16) /* DATA_B3_REQ */ + +static inline void capimsg_setu8(void *m, int off, _cbyte val) +{ + ((_cbyte *)m)[off] = val; +} + +static inline void capimsg_setu16(void *m, int off, _cword val) +{ + ((_cbyte *)m)[off] = val & 0xff; + ((_cbyte *)m)[off+1] = (val >> 8) & 0xff; +} + +static inline void capimsg_setu32(void *m, int off, _cdword val) +{ + ((_cbyte *)m)[off] = val & 0xff; + ((_cbyte *)m)[off+1] = (val >> 8) & 0xff; + ((_cbyte *)m)[off+2] = (val >> 16) & 0xff; + ((_cbyte *)m)[off+3] = (val >> 24) & 0xff; +} + +#define CAPIMSG_SETLEN(m, len) capimsg_setu16(m, 0, len) +#define CAPIMSG_SETAPPID(m, applid) capimsg_setu16(m, 2, applid) +#define CAPIMSG_SETCOMMAND(m,cmd) capimsg_setu8(m, 4, cmd) +#define CAPIMSG_SETSUBCOMMAND(m, cmd) capimsg_setu8(m, 5, cmd) +#define CAPIMSG_SETMSGID(m, msgid) capimsg_setu16(m, 6, msgid) +#define CAPIMSG_SETCONTROL(m, contr) capimsg_setu32(m, 8, contr) +#define CAPIMSG_SETDATALEN(m, len) capimsg_setu16(m, 16, len) + + /* * The _cmsg structure contains all possible CAPI 2.0 parameter. * All parameters are stored here first. The function capi_cmsg2message() @@ -111,102 +158,91 @@ typedef enum { CAPI_COMPOSE = 0, CAPI_DEFAULT = 1 } _cmstruct; */ typedef struct { - /* Header */ - _cword ApplId; - _cbyte Command; - _cbyte Subcommand; - _cword Messagenumber; + /* Header */ + _cword ApplId; + _cbyte Command; + _cbyte Subcommand; + _cword Messagenumber; - /* Parameter */ - union { - _cdword adrController; - _cdword adrPLCI; - _cdword adrNCCI; - } adr; + /* Parameter */ + union { + _cdword adrController; + _cdword adrPLCI; + _cdword adrNCCI; + } adr; - _cmstruct AdditionalInfo; - _cstruct B1configuration; - _cword B1protocol; - _cstruct B2configuration; - _cword B2protocol; - _cstruct B3configuration; - _cword B3protocol; - _cstruct BC; - _cstruct BChannelinformation; - _cmstruct BProtocol; - _cstruct CalledPartyNumber; - _cstruct CalledPartySubaddress; - _cstruct CallingPartyNumber; - _cstruct CallingPartySubaddress; - _cdword CIPmask; - _cdword CIPmask2; - _cword CIPValue; - _cdword Class; - _cstruct ConnectedNumber; - _cstruct ConnectedSubaddress; - _cdword Data32; - _cqword Data64; - _cword DataHandle; - _cword DataLength; - _cstruct FacilityConfirmationParameter; - _cstruct Facilitydataarray; - _cstruct FacilityIndicationParameter; - _cstruct FacilityRequestParameter; - _cstruct FacilityResponseParameters; - _cword FacilitySelector; - _cword Flags; - _cdword Function; - _cstruct HLC; - _cword Info; - _cstruct InfoElement; - _cdword InfoMask; - _cword InfoNumber; - _cstruct Keypadfacility; - _cstruct LLC; - _cstruct ManuData; - _cdword ManuID; - _cstruct NCPI; - _cword Reason; - _cword Reason_B3; - _cword Reject; - _cstruct Useruserdata; - unsigned char *Data; + _cmstruct AdditionalInfo; + _cstruct B1configuration; + _cword B1protocol; + _cstruct B2configuration; + _cword B2protocol; + _cstruct B3configuration; + _cword B3protocol; + _cstruct BC; + _cstruct BChannelinformation; + _cmstruct BProtocol; + _cstruct CalledPartyNumber; + _cstruct CalledPartySubaddress; + _cstruct CallingPartyNumber; + _cstruct CallingPartySubaddress; + _cdword CIPmask; + _cdword CIPmask2; + _cword CIPValue; + _cdword Class; + _cstruct ConnectedNumber; + _cstruct ConnectedSubaddress; + _cdword Data32; + _cqword Data64; + _cword DataHandle; + _cword DataLength; + _cstruct FacilityConfirmationParameter; + _cstruct Facilitydataarray; + _cstruct FacilityIndicationParameter; + _cstruct FacilityRequestParameter; + _cstruct FacilityResponseParameters; + _cword FacilitySelector; + _cword Flags; + _cdword Function; + _cstruct HLC; + _cword Info; + _cstruct InfoElement; + _cdword InfoMask; + _cword InfoNumber; + _cstruct Keypadfacility; + _cstruct LLC; + _cstruct ManuData; + _cdword ManuID; + _cstruct NCPI; + _cword Reason; + _cword Reason_B3; + _cword Reject; + _cstruct Useruserdata; + unsigned char *Data; + + /* intern */ + unsigned l, p; + unsigned char *par; + _cbyte *m; + + /* buffer to construct message */ + _cbyte buf[180]; - /* intern */ - unsigned l,p; - unsigned char *par; - unsigned char *m; } _cmsg; -#define capi_cmsg2message capi20_cmsg2message -#define capi_message2cmsg capi20_message2cmsg - -unsigned capi20_cmsg2message(_cmsg *cmsg, unsigned char *msg); - -unsigned capi20_message2cmsg (_cmsg *cmsg, unsigned char *msg); +/* + * capi_cmsg2message() assembles the parameter from _cmsg to a CAPI 2.0 + * conform message + */ +#define capi20_cmsg2message capi_cmsg2message +unsigned capi_cmsg2message(_cmsg *cmsg, unsigned char *msg); /* - * capi20_put_cmsg() works like capi20_put_message() but it converts the - * _cmsg * first with capi20_cmsg2message(). Possible errors from - * capi20_put_message() will be returned. + * capi20_message2cmsg disassembles a CAPI message an writes the parameter + * into _cmsg for easy access */ - -#define CAPI_PUT_CMSG capi20_put_cmsg -#define capi_put_cmsg capi20_put_cmsg - -unsigned capi20_put_cmsg(_cmsg *cmsg); - -/* - * capi20_get_cmsg() works like capi20_get_message() and converts the - * CAPI message * to a _cmsg with capi20_message2cmsg(). - * Possible errors from capi20_get_message() will be returned. - */ - -#define CAPI_GET_CMSG capi20_get_cmsg -#define capi_get_cmsg capi20_get_cmsg - -unsigned capi20_get_cmsg(_cmsg *cmsg, unsigned applid); +#define capi20_message2cmsg capi20_message2cmsg +unsigned capi_message2cmsg (_cmsg *cmsg, unsigned char *msg); /* * capi20_cmsg_header() fills the _cmsg structure with default values, @@ -214,21 +250,64 @@ unsigned capi20_get_cmsg(_cmsg *cmsg, unsigned applid); * sending the message. */ -#define CAPI_CMSG_HEADER capi20_cmsg_header -#define capi_cmsg_header capi20_cmsg_header - -unsigned capi20_cmsg_header (_cmsg *cmsg, unsigned _ApplId, _cbyte _Command, _cbyte _Subcommand, _cword _Messagenumber, _cdword _Controller); +#define CAPI_CMSG_HEADER capi_cmsg_header +#define capi20_cmsg_header capi_cmsg_header +unsigned capi_cmsg_header (_cmsg *cmsg, unsigned _ApplId, _cbyte _Command, _cbyte _Subcommand, _cword _Messagenumber, _cdword _Controller); /* - * capi20_cmsg_answer() is used to answer indications. It changes the header + * capi_cmsg_answer() is used to answer indications. It changes the header * of an indication to a response, and leaves all other parameters the same */ -#define capi_cmsg_answer capi20_cmsg_answer +#define capi20_cmsg_answer capi_cmsg_answer -unsigned capi20_cmsg_answer (_cmsg *cmsg); +static inline void capi_cmsg_answer(_cmsg * cmsg) +{ + cmsg->Subcommand |= 0x01; +} -/*----- defines to access specific parameter -----*/ +/* + * capi_get_cmsg() works like capi20_get_message() and converts the + * CAPI message * to a _cmsg with capi_message2cmsg(). + * Possible errors from capi20_get_message() will be returned. + */ + +#define CAPI_GET_CMSG capi_get_cmsg +#define capi_get_cmsg capi_get_cmsg +unsigned capi_get_cmsg(_cmsg *cmsg, unsigned applid); + +/* + * capi_put_cmsg() works like capi20_put_message() but it converts the + * _cmsg * first with capi_cmsg2message(). Possible errors from + * capi_put_message() will be returned. + */ + +#define CAPI_PUT_CMSG capi_put_cmsg +#define capi20_put_cmsg capi_put_cmsg +unsigned capi_put_cmsg(_cmsg *cmsg); + +/*-----------------------------------------------------------------------*/ + +/* + * Debugging / Tracing functions + */ + +/* + * capi_info2str generated a readable string for Capi2.0 reasons. + */ +#define capi20_info2str capi_info2str +char *capi_info2str(_cword reason); + +#define capi20_cmd2str capi_cmd2str +char *capi_cmd2str(_cbyte cmd, _cbyte subcmd); + +#define capi20_cmsg2str capi_cmsg2str +char *capi_cmsg2str(_cmsg * cmsg); + +#define capi20_message2str capi_message2str +char *capi_message2str(_cbyte * msg); + +/*-----------------------------------------------------------------------*/ #define ALERT_REQ_PLCI(x) ((x)->adr.adrPLCI) /* Physical Link Connection Identifier */ @@ -960,9 +1039,325 @@ unsigned MANUFACTURER_RESP (_cmsg *cmsg, _cword ApplId, _cword Messagenumber unsigned RESET_B3_RESP (_cmsg *cmsg, _cword ApplId, _cword Messagenumber ,_cdword adr); +/*-----------------------------------------------------------------------*/ + +static inline void capi_fill_CONNECT_B3_REQ(_cmsg * cmsg, _cword ApplId, _cword Messagenumber, + _cdword adr, + _cstruct NCPI) +{ + capi_cmsg_header(cmsg, ApplId, 0x82, 0x80, Messagenumber, adr); + cmsg->NCPI = NCPI; +} + +static inline void capi_fill_FACILITY_REQ(_cmsg * cmsg, _cword ApplId, _cword Messagenumber, + _cdword adr, + _cword FacilitySelector, + _cstruct FacilityRequestParameter) +{ + capi_cmsg_header(cmsg, ApplId, 0x80, 0x80, Messagenumber, adr); + cmsg->FacilitySelector = FacilitySelector; + cmsg->FacilityRequestParameter = FacilityRequestParameter; +} + +static inline void capi_fill_INFO_REQ(_cmsg * cmsg, _cword ApplId, _cword Messagenumber, + _cdword adr, + _cstruct CalledPartyNumber, + _cstruct BChannelinformation, + _cstruct Keypadfacility, + _cstruct Useruserdata, + _cstruct Facilitydataarray) +{ + capi_cmsg_header(cmsg, ApplId, 0x08, 0x80, Messagenumber, adr); + cmsg->CalledPartyNumber = CalledPartyNumber; + cmsg->BChannelinformation = BChannelinformation; + cmsg->Keypadfacility = Keypadfacility; + cmsg->Useruserdata = Useruserdata; + cmsg->Facilitydataarray = Facilitydataarray; +} + +static inline void capi_fill_LISTEN_REQ(_cmsg * cmsg, _cword ApplId, _cword Messagenumber, + _cdword adr, + _cdword InfoMask, + _cdword CIPmask, + _cdword CIPmask2, + _cstruct CallingPartyNumber, + _cstruct CallingPartySubaddress) +{ + capi_cmsg_header(cmsg, ApplId, 0x05, 0x80, Messagenumber, adr); + cmsg->InfoMask = InfoMask; + cmsg->CIPmask = CIPmask; + cmsg->CIPmask2 = CIPmask2; + cmsg->CallingPartyNumber = CallingPartyNumber; + cmsg->CallingPartySubaddress = CallingPartySubaddress; +} + +static inline void capi_fill_ALERT_REQ(_cmsg * cmsg, _cword ApplId, _cword Messagenumber, + _cdword adr, + _cstruct BChannelinformation, + _cstruct Keypadfacility, + _cstruct Useruserdata, + _cstruct Facilitydataarray) +{ + capi_cmsg_header(cmsg, ApplId, 0x01, 0x80, Messagenumber, adr); + cmsg->BChannelinformation = BChannelinformation; + cmsg->Keypadfacility = Keypadfacility; + cmsg->Useruserdata = Useruserdata; + cmsg->Facilitydataarray = Facilitydataarray; +} + +static inline void capi_fill_CONNECT_REQ(_cmsg * cmsg, _cword ApplId, _cword Messagenumber, + _cdword adr, + _cword CIPValue, + _cstruct CalledPartyNumber, + _cstruct CallingPartyNumber, + _cstruct CalledPartySubaddress, + _cstruct CallingPartySubaddress, + _cword B1protocol, + _cword B2protocol, + _cword B3protocol, + _cstruct B1configuration, + _cstruct B2configuration, + _cstruct B3configuration, + _cstruct BC, + _cstruct LLC, + _cstruct HLC, + _cstruct BChannelinformation, + _cstruct Keypadfacility, + _cstruct Useruserdata, + _cstruct Facilitydataarray) +{ + + capi_cmsg_header(cmsg, ApplId, 0x02, 0x80, Messagenumber, adr); + cmsg->CIPValue = CIPValue; + cmsg->CalledPartyNumber = CalledPartyNumber; + cmsg->CallingPartyNumber = CallingPartyNumber; + cmsg->CalledPartySubaddress = CalledPartySubaddress; + cmsg->CallingPartySubaddress = CallingPartySubaddress; + cmsg->B1protocol = B1protocol; + cmsg->B2protocol = B2protocol; + cmsg->B3protocol = B3protocol; + cmsg->B1configuration = B1configuration; + cmsg->B2configuration = B2configuration; + cmsg->B3configuration = B3configuration; + cmsg->BC = BC; + cmsg->LLC = LLC; + cmsg->HLC = HLC; + cmsg->BChannelinformation = BChannelinformation; + cmsg->Keypadfacility = Keypadfacility; + cmsg->Useruserdata = Useruserdata; + cmsg->Facilitydataarray = Facilitydataarray; +} + +static inline void capi_fill_DATA_B3_REQ(_cmsg * cmsg, _cword ApplId, _cword Messagenumber, + _cdword adr, + unsigned char *Data, + _cword DataLength, + _cword DataHandle, + _cword Flags) +{ + + capi_cmsg_header(cmsg, ApplId, 0x86, 0x80, Messagenumber, adr); + cmsg->Data = Data; + cmsg->DataLength = DataLength; + cmsg->DataHandle = DataHandle; + cmsg->Flags = Flags; +} + +static inline void capi_fill_DISCONNECT_REQ(_cmsg * cmsg, _cword ApplId, _cword Messagenumber, + _cdword adr, + _cstruct BChannelinformation, + _cstruct Keypadfacility, + _cstruct Useruserdata, + _cstruct Facilitydataarray) +{ + + capi_cmsg_header(cmsg, ApplId, 0x04, 0x80, Messagenumber, adr); + cmsg->BChannelinformation = BChannelinformation; + cmsg->Keypadfacility = Keypadfacility; + cmsg->Useruserdata = Useruserdata; + cmsg->Facilitydataarray = Facilitydataarray; +} + +static inline void capi_fill_DISCONNECT_B3_REQ(_cmsg * cmsg, _cword ApplId, _cword Messagenumber, + _cdword adr, + _cstruct NCPI) +{ + + capi_cmsg_header(cmsg, ApplId, 0x84, 0x80, Messagenumber, adr); + cmsg->NCPI = NCPI; +} + +static inline void capi_fill_MANUFACTURER_REQ(_cmsg * cmsg, _cword ApplId, _cword Messagenumber, + _cdword adr, + _cdword ManuID, + _cdword Class, + _cdword Function, + _cstruct ManuData) +{ + + capi_cmsg_header(cmsg, ApplId, 0xff, 0x80, Messagenumber, adr); + cmsg->ManuID = ManuID; + cmsg->Class = Class; + cmsg->Function = Function; + cmsg->ManuData = ManuData; +} + +static inline void capi_fill_RESET_B3_REQ(_cmsg * cmsg, _cword ApplId, _cword Messagenumber, + _cdword adr, + _cstruct NCPI) +{ + + capi_cmsg_header(cmsg, ApplId, 0x87, 0x80, Messagenumber, adr); + cmsg->NCPI = NCPI; +} + +static inline void capi_fill_SELECT_B_PROTOCOL_REQ(_cmsg * cmsg, _cword ApplId, _cword Messagenumber, + _cdword adr, + _cword B1protocol, + _cword B2protocol, + _cword B3protocol, + _cstruct B1configuration, + _cstruct B2configuration, + _cstruct B3configuration) +{ + + capi_cmsg_header(cmsg, ApplId, 0x41, 0x80, Messagenumber, adr); + cmsg->B1protocol = B1protocol; + cmsg->B2protocol = B2protocol; + cmsg->B3protocol = B3protocol; + cmsg->B1configuration = B1configuration; + cmsg->B2configuration = B2configuration; + cmsg->B3configuration = B3configuration; +} + +static inline void capi_fill_CONNECT_RESP(_cmsg * cmsg, _cword ApplId, _cword Messagenumber, + _cdword adr, + _cword Reject, + _cword B1protocol, + _cword B2protocol, + _cword B3protocol, + _cstruct B1configuration, + _cstruct B2configuration, + _cstruct B3configuration, + _cstruct ConnectedNumber, + _cstruct ConnectedSubaddress, + _cstruct LLC, + _cstruct BChannelinformation, + _cstruct Keypadfacility, + _cstruct Useruserdata, + _cstruct Facilitydataarray) +{ + capi_cmsg_header(cmsg, ApplId, 0x02, 0x83, Messagenumber, adr); + cmsg->Reject = Reject; + cmsg->B1protocol = B1protocol; + cmsg->B2protocol = B2protocol; + cmsg->B3protocol = B3protocol; + cmsg->B1configuration = B1configuration; + cmsg->B2configuration = B2configuration; + cmsg->B3configuration = B3configuration; + cmsg->ConnectedNumber = ConnectedNumber; + cmsg->ConnectedSubaddress = ConnectedSubaddress; + cmsg->LLC = LLC; + cmsg->BChannelinformation = BChannelinformation; + cmsg->Keypadfacility = Keypadfacility; + cmsg->Useruserdata = Useruserdata; + cmsg->Facilitydataarray = Facilitydataarray; +} + +static inline void capi_fill_CONNECT_ACTIVE_RESP(_cmsg * cmsg, _cword ApplId, _cword Messagenumber, + _cdword adr) +{ + + capi_cmsg_header(cmsg, ApplId, 0x03, 0x83, Messagenumber, adr); +} + +static inline void capi_fill_CONNECT_B3_ACTIVE_RESP(_cmsg * cmsg, _cword ApplId, _cword Messagenumber, + _cdword adr) +{ + + capi_cmsg_header(cmsg, ApplId, 0x83, 0x83, Messagenumber, adr); +} + +static inline void capi_fill_CONNECT_B3_RESP(_cmsg * cmsg, _cword ApplId, _cword Messagenumber, + _cdword adr, + _cword Reject, + _cstruct NCPI) +{ + capi_cmsg_header(cmsg, ApplId, 0x82, 0x83, Messagenumber, adr); + cmsg->Reject = Reject; + cmsg->NCPI = NCPI; +} + +static inline void capi_fill_CONNECT_B3_T90_ACTIVE_RESP(_cmsg * cmsg, _cword ApplId, _cword Messagenumber, + _cdword adr) +{ + + capi_cmsg_header(cmsg, ApplId, 0x88, 0x83, Messagenumber, adr); +} + +static inline void capi_fill_DATA_B3_RESP(_cmsg * cmsg, _cword ApplId, _cword Messagenumber, + _cdword adr, + _cword DataHandle) +{ + + capi_cmsg_header(cmsg, ApplId, 0x86, 0x83, Messagenumber, adr); + cmsg->DataHandle = DataHandle; +} + +static inline void capi_fill_DISCONNECT_B3_RESP(_cmsg * cmsg, _cword ApplId, _cword Messagenumber, + _cdword adr) +{ + + capi_cmsg_header(cmsg, ApplId, 0x84, 0x83, Messagenumber, adr); +} + +static inline void capi_fill_DISCONNECT_RESP(_cmsg * cmsg, _cword ApplId, _cword Messagenumber, + _cdword adr) +{ + + capi_cmsg_header(cmsg, ApplId, 0x04, 0x83, Messagenumber, adr); +} + +static inline void capi_fill_FACILITY_RESP(_cmsg * cmsg, _cword ApplId, _cword Messagenumber, + _cdword adr, + _cword FacilitySelector) +{ + + capi_cmsg_header(cmsg, ApplId, 0x80, 0x83, Messagenumber, adr); + cmsg->FacilitySelector = FacilitySelector; +} + +static inline void capi_fill_INFO_RESP(_cmsg * cmsg, _cword ApplId, _cword Messagenumber, + _cdword adr) +{ + + capi_cmsg_header(cmsg, ApplId, 0x08, 0x83, Messagenumber, adr); +} + +static inline void capi_fill_MANUFACTURER_RESP(_cmsg * cmsg, _cword ApplId, _cword Messagenumber, + _cdword adr, + _cdword ManuID, + _cdword Class, + _cdword Function, + _cstruct ManuData) +{ + + capi_cmsg_header(cmsg, ApplId, 0xff, 0x83, Messagenumber, adr); + cmsg->ManuID = ManuID; + cmsg->Class = Class; + cmsg->Function = Function; + cmsg->ManuData = ManuData; +} + +static inline void capi_fill_RESET_B3_RESP(_cmsg * cmsg, _cword ApplId, _cword Messagenumber, + _cdword adr) +{ + + capi_cmsg_header(cmsg, ApplId, 0x87, 0x83, Messagenumber, adr); +} #ifdef __cplusplus } #endif -#endif /* __CAPIUTIL_H__ */ +#endif /* __CAPIUTILS_H__ */ diff --git a/capi20/configure b/capi20/configure index e89ef53d..b767254a 100755 --- a/capi20/configure +++ b/capi20/configure @@ -702,7 +702,7 @@ fi PACKAGE=libcapi20 -VERSION=2.0.4 +VERSION=2.0.5 if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then { echo "configure: error: source directory already configured; run "make distclean" there first" 1>&2; exit 1; } diff --git a/capi20/configure.in b/capi20/configure.in index 640f1600..1360041c 100644 --- a/capi20/configure.in +++ b/capi20/configure.in @@ -1,7 +1,7 @@ dnl Process this file with autoconf to produce a configure script. AC_INIT(capi20.c) -AM_INIT_AUTOMAKE(libcapi20,2.0.4) +AM_INIT_AUTOMAKE(libcapi20,2.0.5) AC_PREFIX_DEFAULT(/usr) dnl Checks for programs. diff --git a/capi20/convert.c b/capi20/convert.c index b0731dce..5912706c 100644 --- a/capi20/convert.c +++ b/capi20/convert.c @@ -2,6 +2,12 @@ * $Id$ * * $Log$ + * Revision 1.9 1999/12/06 17:08:30 calle + * - Splitted capi20.h into capi20.h and capiutils.h. + * - capi20.h: the functions from the CAPI-2.0 Spec + * - capiutils.h: the "CAPI-ADK" functions + * - bug in 64Bit-Support fixed. + * * Revision 1.8 1999/10/20 16:43:17 calle * - The CAPI20 library is now a shared library. * - Arguments of function capi20_put_message swapped, to match capi spec. @@ -39,9 +45,223 @@ #include "capi20.h" +/*-------------------------------------------------------*/ + +char *capi_info2str(_cword reason) +{ + switch (reason) { + +/*-- informative values (corresponding message was processed) -----*/ + case 0x0001: + return "NCPI not supported by current protocol, NCPI ignored"; + case 0x0002: + return "Flags not supported by current protocol, flags ignored"; + case 0x0003: + return "Alert already sent by another application"; + +/*-- error information concerning CAPI_REGISTER -----*/ + case 0x1001: + return "Too many applications"; + case 0x1002: + return "Logical block size too small, must be at least 128 Bytes"; + case 0x1003: + return "Buffer exceeds 64 kByte"; + case 0x1004: + return "Message buffer size too small, must be at least 1024 Bytes"; + case 0x1005: + return "Max. number of logical connections not supported"; + case 0x1006: + return "Reserved"; + case 0x1007: + return "The message could not be accepted because of an internal busy condition"; + case 0x1008: + return "OS resource error (no memory ?)"; + case 0x1009: + return "CAPI not installed"; + case 0x100A: + return "Controller does not support external equipment"; + case 0x100B: + return "Controller does only support external equipment"; + +/*-- error information concerning message exchange functions -----*/ + case 0x1101: + return "Illegal application number"; + case 0x1102: + return "Illegal command or subcommand or message length less than 12 bytes"; + case 0x1103: + return "The message could not be accepted because of a queue full condition !! The error code does not imply that CAPI cannot receive messages directed to another controller, PLCI or NCCI"; + case 0x1104: + return "Queue is empty"; + case 0x1105: + return "Queue overflow, a message was lost !! This indicates a configuration error. The only recovery from this error is to perform a CAPI_RELEASE"; + case 0x1106: + return "Unknown notification parameter"; + case 0x1107: + return "The Message could not be accepted because of an internal busy condition"; + case 0x1108: + return "OS Resource error (no memory ?)"; + case 0x1109: + return "CAPI not installed"; + case 0x110A: + return "Controller does not support external equipment"; + case 0x110B: + return "Controller does only support external equipment"; + +/*-- error information concerning resource / coding problems -----*/ + case 0x2001: + return "Message not supported in current state"; + case 0x2002: + return "Illegal Controller / PLCI / NCCI"; + case 0x2003: + return "Out of PLCI"; + case 0x2004: + return "Out of NCCI"; + case 0x2005: + return "Out of LISTEN"; + case 0x2006: + return "Out of FAX resources (protocol T.30)"; + case 0x2007: + return "Illegal message parameter coding"; + +/*-- error information concerning requested services -----*/ + case 0x3001: + return "B1 protocol not supported"; + case 0x3002: + return "B2 protocol not supported"; + case 0x3003: + return "B3 protocol not supported"; + case 0x3004: + return "B1 protocol parameter not supported"; + case 0x3005: + return "B2 protocol parameter not supported"; + case 0x3006: + return "B3 protocol parameter not supported"; + case 0x3007: + return "B protocol combination not supported"; + case 0x3008: + return "NCPI not supported"; + case 0x3009: + return "CIP Value unknown"; + case 0x300A: + return "Flags not supported (reserved bits)"; + case 0x300B: + return "Facility not supported"; + case 0x300C: + return "Data length not supported by current protocol"; + case 0x300D: + return "Reset procedure not supported by current protocol"; + +/*-- informations about the clearing of a physical connection -----*/ + case 0x3301: + return "Protocol error layer 1 (broken line or B-channel removed by signalling protocol)"; + case 0x3302: + return "Protocol error layer 2"; + case 0x3303: + return "Protocol error layer 3"; + case 0x3304: + return "Another application got that call"; +/*-- T.30 specific reasons -----*/ + case 0x3311: + return "Connecting not successful (remote station is no FAX G3 machine)"; + case 0x3312: + return "Connecting not successful (training error)"; + case 0x3313: + return "Disconnected before transfer (remote station does not support transfer mode, e.g. resolution)"; + case 0x3314: + return "Disconnected during transfer (remote abort)"; + case 0x3315: + return "Disconnected during transfer (remote procedure error, e.g. unsuccessful repetition of T.30 commands)"; + case 0x3316: + return "Disconnected during transfer (local tx data underrun)"; + case 0x3317: + return "Disconnected during transfer (local rx data overflow)"; + case 0x3318: + return "Disconnected during transfer (local abort)"; + case 0x3319: + return "Illegal parameter coding (e.g. SFF coding error)"; + +/*-- disconnect causes from the network according to ETS 300 102-1/Q.931 -----*/ + case 0x3481: return "Unallocated (unassigned) number"; + case 0x3482: return "No route to specified transit network"; + case 0x3483: return "No route to destination"; + case 0x3486: return "Channel unacceptable"; + case 0x3487: + return "Call awarded and being delivered in an established channel"; + case 0x3490: return "Normal call clearing"; + case 0x3491: return "User busy"; + case 0x3492: return "No user responding"; + case 0x3493: return "No answer from user (user alerted)"; + case 0x3495: return "Call rejected"; + case 0x3496: return "Number changed"; + case 0x349A: return "Non-selected user clearing"; + case 0x349B: return "Destination out of order"; + case 0x349C: return "Invalid number format"; + case 0x349D: return "Facility rejected"; + case 0x349E: return "Response to STATUS ENQUIRY"; + case 0x349F: return "Normal, unspecified"; + case 0x34A2: return "No circuit / channel available"; + case 0x34A6: return "Network out of order"; + case 0x34A9: return "Temporary failure"; + case 0x34AA: return "Switching equipment congestion"; + case 0x34AB: return "Access information discarded"; + case 0x34AC: return "Requested circuit / channel not available"; + case 0x34AF: return "Resources unavailable, unspecified"; + case 0x34B1: return "Quality of service unavailable"; + case 0x34B2: return "Requested facility not subscribed"; + case 0x34B9: return "Bearer capability not authorized"; + case 0x34BA: return "Bearer capability not presently available"; + case 0x34BF: return "Service or option not available, unspecified"; + case 0x34C1: return "Bearer capability not implemented"; + case 0x34C2: return "Channel type not implemented"; + case 0x34C5: return "Requested facility not implemented"; + case 0x34C6: return "Only restricted digital information bearer capability is available"; + case 0x34CF: return "Service or option not implemented, unspecified"; + case 0x34D1: return "Invalid call reference value"; + case 0x34D2: return "Identified channel does not exist"; + case 0x34D3: return "A suspended call exists, but this call identity does not"; + case 0x34D4: return "Call identity in use"; + case 0x34D5: return "No call suspended"; + case 0x34D6: return "Call having the requested call identity has been cleared"; + case 0x34D8: return "Incompatible destination"; + case 0x34DB: return "Invalid transit network selection"; + case 0x34DF: return "Invalid message, unspecified"; + case 0x34E0: return "Mandatory information element is missing"; + case 0x34E1: return "Message type non-existent or not implemented"; + case 0x34E2: return "Message not compatible with call state or message type non-existent or not implemented"; + case 0x34E3: return "Information element non-existent or not implemented"; + case 0x34E4: return "Invalid information element contents"; + case 0x34E5: return "Message not compatible with call state"; + case 0x34E6: return "Recovery on timer expiry"; + case 0x34EF: return "Protocol error, unspecified"; + case 0x34FF: return "Interworking, unspecified"; + + case 0x3500: return "Normal end of connection"; + case 0x3501: return "Carrier lost"; + case 0x3502: return "Error in negotation, i.e. no modem with error correction at the other end"; + case 0x3503: return "No answer to protocol request"; + case 0x3504: return "Remote modem only works in synchronous mode"; + case 0x3505: return "Framing fails"; + case 0x3506: return "Protocol negotiation fails"; + case 0x3507: return "Other modem sends wrong protocol request"; + case 0x3508: return "Sync information (data or flags) missing"; + case 0x3509: return "Normal end of connection from the other modem"; + case 0x350A: return "No answer from other modem"; + case 0x350B: return "Protocol error"; + case 0x350C: return "Error in compression"; + case 0x350D: return "No conenct (timeout or wrong modulation)"; + case 0x350E: return "No protocol fall-back allowed"; + case 0x350F: return "No modem or fax at requested number"; + case 0x3510: return "Handshake error"; + + default: return "No additional information"; + } +} + +/*-------------------------------------------------------*/ + typedef struct { - int typ; - unsigned off; + int typ; + size_t off; } _cdef; #define _CBYTE 1 @@ -52,187 +272,141 @@ typedef struct { #define _CMSTRUCT 6 #define _CEND 7 +/*-------------------------------------------------------*/ + static _cdef cdef[] = { /*00*/{_CEND}, /*01*/{_CEND}, /*02*/{_CEND}, - /*03*/{_CDWORD, offsetof(_cmsg,adr.adrController) }, - /*04*/{_CMSTRUCT, offsetof(_cmsg,AdditionalInfo) }, - /*05*/{_CSTRUCT, offsetof(_cmsg,B1configuration) }, - /*06*/{_CWORD, offsetof(_cmsg,B1protocol) }, - /*07*/{_CSTRUCT, offsetof(_cmsg,B2configuration) }, - /*08*/{_CWORD, offsetof(_cmsg,B2protocol) }, - /*09*/{_CSTRUCT, offsetof(_cmsg,B3configuration) }, - /*0a*/{_CWORD, offsetof(_cmsg,B3protocol) }, - /*0b*/{_CSTRUCT, offsetof(_cmsg,BC) }, - /*0c*/{_CSTRUCT, offsetof(_cmsg,BChannelinformation) }, - /*0d*/{_CMSTRUCT, offsetof(_cmsg,BProtocol) }, - /*0e*/{_CSTRUCT, offsetof(_cmsg,CalledPartyNumber) }, - /*0f*/{_CSTRUCT, offsetof(_cmsg,CalledPartySubaddress) }, - /*10*/{_CSTRUCT, offsetof(_cmsg,CallingPartyNumber) }, - /*11*/{_CSTRUCT, offsetof(_cmsg,CallingPartySubaddress) }, - /*12*/{_CDWORD, offsetof(_cmsg,CIPmask) }, - /*13*/{_CDWORD, offsetof(_cmsg,CIPmask2) }, - /*14*/{_CWORD, offsetof(_cmsg,CIPValue) }, - /*15*/{_CDWORD, offsetof(_cmsg,Class) }, - /*16*/{_CSTRUCT, offsetof(_cmsg,ConnectedNumber) }, - /*17*/{_CSTRUCT, offsetof(_cmsg,ConnectedSubaddress) }, - /*18*/{_CDWORD, offsetof(_cmsg,Data32) }, - /*19*/{_CWORD, offsetof(_cmsg,DataHandle) }, - /*1a*/{_CWORD, offsetof(_cmsg,DataLength) }, - /*1b*/{_CSTRUCT, offsetof(_cmsg,FacilityConfirmationParameter) }, - /*1c*/{_CSTRUCT, offsetof(_cmsg,Facilitydataarray) }, - /*1d*/{_CSTRUCT, offsetof(_cmsg,FacilityIndicationParameter) }, - /*1e*/{_CSTRUCT, offsetof(_cmsg,FacilityRequestParameter) }, - /*1f*/{_CSTRUCT, offsetof(_cmsg,FacilityResponseParameters) }, - /*20*/{_CWORD, offsetof(_cmsg,FacilitySelector) }, - /*21*/{_CWORD, offsetof(_cmsg,Flags) }, - /*22*/{_CDWORD, offsetof(_cmsg,Function) }, - /*23*/{_CSTRUCT, offsetof(_cmsg,HLC) }, - /*24*/{_CWORD, offsetof(_cmsg,Info) }, - /*25*/{_CSTRUCT, offsetof(_cmsg,InfoElement) }, - /*26*/{_CDWORD, offsetof(_cmsg,InfoMask) }, - /*27*/{_CWORD, offsetof(_cmsg,InfoNumber) }, - /*28*/{_CSTRUCT, offsetof(_cmsg,Keypadfacility) }, - /*29*/{_CSTRUCT, offsetof(_cmsg,LLC) }, - /*2a*/{_CSTRUCT, offsetof(_cmsg,ManuData) }, - /*2b*/{_CDWORD, offsetof(_cmsg,ManuID) }, - /*2c*/{_CSTRUCT, offsetof(_cmsg,NCPI) }, - /*2d*/{_CWORD, offsetof(_cmsg,Reason) }, - /*2e*/{_CWORD, offsetof(_cmsg,Reason_B3) }, - /*2f*/{_CWORD, offsetof(_cmsg,Reject) }, - /*30*/{_CSTRUCT, offsetof(_cmsg,Useruserdata) }, - /*31*/{_CQWORD, offsetof(_cmsg,Data64) }, + /*03*/{_CDWORD, offsetof(_cmsg, adr.adrController)}, + /*04*/{_CMSTRUCT, offsetof(_cmsg, AdditionalInfo)}, + /*05*/{_CSTRUCT, offsetof(_cmsg, B1configuration)}, + /*06*/{_CWORD, offsetof(_cmsg, B1protocol)}, + /*07*/{_CSTRUCT, offsetof(_cmsg, B2configuration)}, + /*08*/{_CWORD, offsetof(_cmsg, B2protocol)}, + /*09*/{_CSTRUCT, offsetof(_cmsg, B3configuration)}, + /*0a*/{_CWORD, offsetof(_cmsg, B3protocol)}, + /*0b*/{_CSTRUCT, offsetof(_cmsg, BC)}, + /*0c*/{_CSTRUCT, offsetof(_cmsg, BChannelinformation)}, + /*0d*/{_CMSTRUCT, offsetof(_cmsg, BProtocol)}, + /*0e*/{_CSTRUCT, offsetof(_cmsg, CalledPartyNumber)}, + /*0f*/{_CSTRUCT, offsetof(_cmsg, CalledPartySubaddress)}, + /*10*/{_CSTRUCT, offsetof(_cmsg, CallingPartyNumber)}, + /*11*/{_CSTRUCT, offsetof(_cmsg, CallingPartySubaddress)}, + /*12*/{_CDWORD, offsetof(_cmsg, CIPmask)}, + /*13*/{_CDWORD, offsetof(_cmsg, CIPmask2)}, + /*14*/{_CWORD, offsetof(_cmsg, CIPValue)}, + /*15*/{_CDWORD, offsetof(_cmsg, Class)}, + /*16*/{_CSTRUCT, offsetof(_cmsg, ConnectedNumber)}, + /*17*/{_CSTRUCT, offsetof(_cmsg, ConnectedSubaddress)}, + /*18*/{_CDWORD, offsetof(_cmsg, Data32)}, + /*19*/{_CWORD, offsetof(_cmsg, DataHandle)}, + /*1a*/{_CWORD, offsetof(_cmsg, DataLength)}, + /*1b*/{_CSTRUCT, offsetof(_cmsg, FacilityConfirmationParameter)}, + /*1c*/{_CSTRUCT, offsetof(_cmsg, Facilitydataarray)}, + /*1d*/{_CSTRUCT, offsetof(_cmsg, FacilityIndicationParameter)}, + /*1e*/{_CSTRUCT, offsetof(_cmsg, FacilityRequestParameter)}, + /*1f*/{_CSTRUCT, offsetof(_cmsg, FacilityResponseParameters)}, + /*20*/{_CWORD, offsetof(_cmsg, FacilitySelector)}, + /*21*/{_CWORD, offsetof(_cmsg, Flags)}, + /*22*/{_CDWORD, offsetof(_cmsg, Function)}, + /*23*/{_CSTRUCT, offsetof(_cmsg, HLC)}, + /*24*/{_CWORD, offsetof(_cmsg, Info)}, + /*25*/{_CSTRUCT, offsetof(_cmsg, InfoElement)}, + /*26*/{_CDWORD, offsetof(_cmsg, InfoMask)}, + /*27*/{_CWORD, offsetof(_cmsg, InfoNumber)}, + /*28*/{_CSTRUCT, offsetof(_cmsg, Keypadfacility)}, + /*29*/{_CSTRUCT, offsetof(_cmsg, LLC)}, + /*2a*/{_CSTRUCT, offsetof(_cmsg, ManuData)}, + /*2b*/{_CDWORD, offsetof(_cmsg, ManuID)}, + /*2c*/{_CSTRUCT, offsetof(_cmsg, NCPI)}, + /*2d*/{_CWORD, offsetof(_cmsg, Reason)}, + /*2e*/{_CWORD, offsetof(_cmsg, Reason_B3)}, + /*2f*/{_CWORD, offsetof(_cmsg, Reject)}, + /*30*/{_CSTRUCT, offsetof(_cmsg, Useruserdata)}, + /*31*/{_CQWORD, offsetof(_cmsg, Data64)}, }; static unsigned char *cpars[] = { /*00*/ 0, - /*01 ALERT_REQ*/ - (unsigned char*)"\x03\x04\x0c\x28\x30\x1c\x01\x01", - /*02 CONNECT_REQ*/ - (unsigned char*)"\x03\x14\x0e\x10\x0f\x11\x0d\x06\x08\x0a\x05\x07\x09\x01\x0b\x29\x23\x04\x0c\x28\x30\x1c\x01\x01", + /*01 ALERT_REQ*/ (unsigned char*)"\x03\x04\x0c\x28\x30\x1c\x01\x01", + /*02 CONNECT_REQ*/ (unsigned char*)"\x03\x14\x0e\x10\x0f\x11\x0d\x06\x08\x0a\x05\x07\x09\x01\x0b\x29\x23\x04\x0c\x28\x30\x1c\x01\x01", /*03*/ 0, - /*04 DISCONNECT_REQ*/ - (unsigned char*)"\x03\x04\x0c\x28\x30\x1c\x01\x01", - /*05 LISTEN_REQ*/ - (unsigned char*)"\x03\x26\x12\x13\x10\x11\x01", + /*04 DISCONNECT_REQ*/ (unsigned char*)"\x03\x04\x0c\x28\x30\x1c\x01\x01", + /*05 LISTEN_REQ*/ (unsigned char*)"\x03\x26\x12\x13\x10\x11\x01", /*06*/ 0, /*07*/ 0, - /*08 INFO_REQ*/ - (unsigned char*)"\x03\x0e\x04\x0c\x28\x30\x1c\x01\x01", - /*09 FACILITY_REQ*/ - (unsigned char*)"\x03\x20\x1e\x01", - /*0a SELECT_B_PROTOCOL_REQ*/ - (unsigned char*)"\x03\x0d\x06\x08\x0a\x05\x07\x09\x01\x01", - /*0b CONNECT_B3_REQ*/ - (unsigned char*)"\x03\x2c\x01", + /*08 INFO_REQ*/ (unsigned char*)"\x03\x0e\x04\x0c\x28\x30\x1c\x01\x01", + /*09 FACILITY_REQ*/ (unsigned char*)"\x03\x20\x1e\x01", + /*0a SELECT_B_PROTOCOL_REQ*/ (unsigned char*)"\x03\x0d\x06\x08\x0a\x05\x07\x09\x01\x01", + /*0b CONNECT_B3_REQ*/ (unsigned char*)"\x03\x2c\x01", /*0c*/ 0, - /*0d DISCONNECT_B3_REQ*/ - (unsigned char*)"\x03\x2c\x01", + /*0d DISCONNECT_B3_REQ*/ (unsigned char*)"\x03\x2c\x01", /*0e*/ 0, - /*0f DATA_B3_REQ*/ - (unsigned char*)"\x03\x18\x1a\x19\x21\x31\x01", - /*10 RESET_B3_REQ*/ - (unsigned char*)"\x03\x2c\x01", + /*0f DATA_B3_REQ*/ (unsigned char*)"\x03\x18\x1a\x19\x21\x31\x01", + /*10 RESET_B3_REQ*/ (unsigned char*)"\x03\x2c\x01", /*11*/ 0, /*12*/ 0, - /*13 ALERT_CONF*/ - (unsigned char*)"\x03\x24\x01", - /*14 CONNECT_CONF*/ - (unsigned char*)"\x03\x24\x01", + /*13 ALERT_CONF*/ (unsigned char*)"\x03\x24\x01", + /*14 CONNECT_CONF*/ (unsigned char*)"\x03\x24\x01", /*15*/ 0, - /*16 DISCONNECT_CONF*/ - (unsigned char*)"\x03\x24\x01", - /*17 LISTEN_CONF*/ - (unsigned char*)"\x03\x24\x01", - /*18 MANUFACTURER_REQ*/ - (unsigned char*)"\x03\x2b\x15\x22\x2a\x01", + /*16 DISCONNECT_CONF*/ (unsigned char*)"\x03\x24\x01", + /*17 LISTEN_CONF*/ (unsigned char*)"\x03\x24\x01", + /*18 MANUFACTURER_REQ*/ (unsigned char*)"\x03\x2b\x15\x22\x2a\x01", /*19*/ 0, - /*1a INFO_CONF*/ - (unsigned char*)"\x03\x24\x01", - /*1b FACILITY_CONF*/ - (unsigned char*)"\x03\x24\x20\x1b\x01", - /*1c SELECT_B_PROTOCOL_CONF*/ - (unsigned char*)"\x03\x24\x01", - /*1d CONNECT_B3_CONF*/ - (unsigned char*)"\x03\x24\x01", + /*1a INFO_CONF*/ (unsigned char*)"\x03\x24\x01", + /*1b FACILITY_CONF*/ (unsigned char*)"\x03\x24\x20\x1b\x01", + /*1c SELECT_B_PROTOCOL_CONF*/ (unsigned char*)"\x03\x24\x01", + /*1d CONNECT_B3_CONF*/ (unsigned char*)"\x03\x24\x01", /*1e*/ 0, - /*1f DISCONNECT_B3_CONF*/ - (unsigned char*)"\x03\x24\x01", + /*1f DISCONNECT_B3_CONF*/ (unsigned char*)"\x03\x24\x01", /*20*/ 0, - /*21 DATA_B3_CONF*/ - (unsigned char*)"\x03\x19\x24\x01", - /*22 RESET_B3_CONF*/ - (unsigned char*)"\x03\x24\x01", + /*21 DATA_B3_CONF*/ (unsigned char*)"\x03\x19\x24\x01", + /*22 RESET_B3_CONF*/ (unsigned char*)"\x03\x24\x01", /*23*/ 0, /*24*/ 0, /*25*/ 0, - /*26 CONNECT_IND*/ - (unsigned char*)"\x03\x14\x0e\x10\x0f\x11\x0b\x29\x23\x04\x0c\x28\x30\x1c\x01\x01", - /*27 CONNECT_ACTIVE_IND*/ - (unsigned char*)"\x03\x16\x17\x29\x01", - /*28 DISCONNECT_IND*/ - (unsigned char*)"\x03\x2d\x01", + /*26 CONNECT_IND*/ (unsigned char*)"\x03\x14\x0e\x10\x0f\x11\x0b\x29\x23\x04\x0c\x28\x30\x1c\x01\x01", + /*27 CONNECT_ACTIVE_IND*/ (unsigned char*)"\x03\x16\x17\x29\x01", + /*28 DISCONNECT_IND*/ (unsigned char*)"\x03\x2d\x01", /*29*/ 0, - /*2a MANUFACTURER_CONF*/ - (unsigned char*)"\x03\x2b\x15\x22\x2a\x01", + /*2a MANUFACTURER_CONF*/ (unsigned char*)"\x03\x2b\x15\x22\x2a\x01", /*2b*/ 0, - /*2c INFO_IND*/ - (unsigned char*)"\x03\x27\x25\x01", - /*2d FACILITY_IND*/ - (unsigned char*)"\x03\x20\x1d\x01", + /*2c INFO_IND*/ (unsigned char*)"\x03\x27\x25\x01", + /*2d FACILITY_IND*/ (unsigned char*)"\x03\x20\x1d\x01", /*2e*/ 0, - /*2f CONNECT_B3_IND*/ - (unsigned char*)"\x03\x2c\x01", - /*30 CONNECT_B3_ACTIVE_IND*/ - (unsigned char*)"\x03\x2c\x01", - /*31 DISCONNECT_B3_IND*/ - (unsigned char*)"\x03\x2e\x2c\x01", + /*2f CONNECT_B3_IND*/ (unsigned char*)"\x03\x2c\x01", + /*30 CONNECT_B3_ACTIVE_IND*/ (unsigned char*)"\x03\x2c\x01", + /*31 DISCONNECT_B3_IND*/ (unsigned char*)"\x03\x2e\x2c\x01", /*32*/ 0, - /*33 DATA_B3_IND*/ - (unsigned char*)"\x03\x18\x1a\x19\x21\x31\x01", - /*34 RESET_B3_IND*/ - (unsigned char*)"\x03\x2c\x01", - /*35 CONNECT_B3_T90_ACTIVE_IND*/ - (unsigned char*)"\x03\x2c\x01", + /*33 DATA_B3_IND*/ (unsigned char*)"\x03\x18\x1a\x19\x21\x31\x01", + /*34 RESET_B3_IND*/ (unsigned char*)"\x03\x2c\x01", + /*35 CONNECT_B3_T90_ACTIVE_IND*/ (unsigned char*)"\x03\x2c\x01", /*36*/ 0, /*37*/ 0, - /*38 CONNECT_RESP*/ - (unsigned char*)"\x03\x2f\x0d\x06\x08\x0a\x05\x07\x09\x01\x16\x17\x29\x04\x0c\x28\x30\x1c\x01\x01", - /*39 CONNECT_ACTIVE_RESP*/ - (unsigned char*)"\x03\x01", - /*3a DISCONNECT_RESP*/ - (unsigned char*)"\x03\x01", + /*38 CONNECT_RESP*/ (unsigned char*)"\x03\x2f\x0d\x06\x08\x0a\x05\x07\x09\x01\x16\x17\x29\x04\x0c\x28\x30\x1c\x01\x01", + /*39 CONNECT_ACTIVE_RESP*/ (unsigned char*)"\x03\x01", + /*3a DISCONNECT_RESP*/ (unsigned char*)"\x03\x01", /*3b*/ 0, - /*3c MANUFACTURER_IND*/ - (unsigned char*)"\x03\x2b\x15\x22\x2a\x01", + /*3c MANUFACTURER_IND*/ (unsigned char*)"\x03\x2b\x15\x22\x2a\x01", /*3d*/ 0, - /*3e INFO_RESP*/ - (unsigned char*)"\x03\x01", - /*3f FACILITY_RESP*/ - (unsigned char*)"\x03\x20\x1f\x01", + /*3e INFO_RESP*/ (unsigned char*)"\x03\x01", + /*3f FACILITY_RESP*/ (unsigned char*)"\x03\x20\x1f\x01", /*40*/ 0, - /*41 CONNECT_B3_RESP*/ - (unsigned char*)"\x03\x2f\x2c\x01", - /*42 CONNECT_B3_ACTIVE_RESP*/ - (unsigned char*)"\x03\x01", - /*43 DISCONNECT_B3_RESP*/ - (unsigned char*)"\x03\x01", + /*41 CONNECT_B3_RESP*/ (unsigned char*)"\x03\x2f\x2c\x01", + /*42 CONNECT_B3_ACTIVE_RESP*/ (unsigned char*)"\x03\x01", + /*43 DISCONNECT_B3_RESP*/ (unsigned char*)"\x03\x01", /*44*/ 0, - /*45 DATA_B3_RESP*/ - (unsigned char*)"\x03\x19\x01", - /*46 RESET_B3_RESP*/ - (unsigned char*)"\x03\x01", - /*47 CONNECT_B3_T90_ACTIVE_RESP*/ - (unsigned char*)"\x03\x01", + /*45 DATA_B3_RESP*/ (unsigned char*)"\x03\x19\x01", + /*46 RESET_B3_RESP*/ (unsigned char*)"\x03\x01", + /*47 CONNECT_B3_T90_ACTIVE_RESP*/ (unsigned char*)"\x03\x01", /*48*/ 0, /*49*/ 0, /*4a*/ 0, /*4b*/ 0, /*4c*/ 0, /*4d*/ 0, - /*4e MANUFACTURER_RESP*/ - (unsigned char*)"\x03\x2b\x15\x22\x2a\x01", + /*4e MANUFACTURER_RESP*/ (unsigned char*)"\x03\x2b\x15\x22\x2a\x01", }; /*-------------------------------------------------------*/ @@ -240,227 +414,224 @@ static unsigned char *cpars[] = { #define byteTLcpy(x,y) *(_cbyte *)(x)=*(_cbyte *)(y); #define wordTLcpy(x,y) *(_cword *)(x)=*(_cword *)(y); #define dwordTLcpy(x,y) memcpy(x,y,4); -#define qwordTLcpy(x,y) memcpy(x,y,8); #define structTLcpy(x,y,l) memcpy (x,y,l) #define structTLcpyovl(x,y,l) memmove (x,y,l) #define byteTRcpy(x,y) *(_cbyte *)(y)=*(_cbyte *)(x); #define wordTRcpy(x,y) *(_cword *)(y)=*(_cword *)(x); #define dwordTRcpy(x,y) memcpy(y,x,4); -#define qwordTRcpy(x,y) memcpy(y,x,8); #define structTRcpy(x,y,l) memcpy (y,x,l) #define structTRcpyovl(x,y,l) memmove (y,x,l) +#define qwordTLcpy(x,y) memcpy(x,y,8); +#define qwordTRcpy(x,y) memcpy(y,x,8); + /*-------------------------------------------------------*/ -static unsigned command_2_index (unsigned c, unsigned sc) { - if (c & 0x80) c = 0x9+(c&0x0f); - else if (c<=0x0f) ; - else if (c==0x41) c = 0x9+0x1; - else if (c==0xff) c = 0x00; - return (sc&3)*(0x9+0x9)+c; +static unsigned command_2_index(unsigned c, unsigned sc) +{ + if (c & 0x80) + c = 0x9 + (c & 0x0f); + else if (c <= 0x0f); + else if (c == 0x41) + c = 0x9 + 0x1; + else if (c == 0xff) + c = 0x00; + return (sc & 3) * (0x9 + 0x9) + c; } /*-------------------------------------------------------*/ #define TYP (cdef[cmsg->par[cmsg->p]].typ) -#define OFF (((char *)cmsg)+cdef[cmsg->par[cmsg->p]].off) +#define OFF (((_cbyte *)cmsg)+cdef[cmsg->par[cmsg->p]].off) -static void jumpcstruct (_cmsg *cmsg) { - unsigned layer; - for (cmsg->p++,layer=1; layer;) { - assert (cmsg->p); - cmsg->p++; - switch (TYP) { - case _CMSTRUCT: - layer++; - break; - case _CEND: - layer--; - break; - } - } -} -/*-------------------------------------------------------*/ -static void PARS_2_MESSAGE (_cmsg *cmsg) { - - for (;TYP != _CEND; cmsg->p++) { - switch (TYP) { - case _CBYTE: - byteTLcpy (cmsg->m+cmsg->l, OFF); - cmsg->l++; - break; - case _CWORD: - wordTLcpy (cmsg->m+cmsg->l, OFF); - cmsg->l+=2; - break; - case _CDWORD: - dwordTLcpy (cmsg->m+cmsg->l, OFF); - cmsg->l+=4; - break; - case _CQWORD: - qwordTLcpy (cmsg->m+cmsg->l, OFF); - cmsg->l+=8; - break; - case _CSTRUCT: - if (*(CAPI_MESSAGE *) OFF == 0) { - *(cmsg->m+cmsg->l)='\0'; - cmsg->l++; - } - else if(**(_cstruct*)OFF != 0xff) { - structTLcpy (cmsg->m+cmsg->l, *(_cstruct*)OFF, 1+**(_cstruct*)OFF); - cmsg->l+=1+**(_cstruct*)OFF; - } - else { - _cstruct s = *(_cstruct*)OFF; - structTLcpy (cmsg->m+cmsg->l, s, 3+*(_cword*)(s+1)); - cmsg->l+= 3+*(_cword*)(s+1); - } - break; - case _CMSTRUCT: - /*----- Metastruktur 0 -----*/ - if (*(_cmstruct*)OFF == CAPI_DEFAULT) { - *(cmsg->m+cmsg->l)='\0'; - cmsg->l++; - jumpcstruct (cmsg); - } - /*----- Metastruktur wird composed -----*/ - else { - unsigned _l = cmsg->l; - unsigned _ls; - cmsg->l++; - cmsg->p++; - PARS_2_MESSAGE (cmsg); - _ls = cmsg->l-_l-1; - if (_ls < 255) - (cmsg->m+_l)[0] = (_cbyte)_ls; - else { - structTLcpyovl (cmsg->m+_l+3, cmsg->m+_l+1, _ls); - (cmsg->m+_l)[0] = 0xff; - wordTLcpy (cmsg->m+_l+1, &_ls); - cmsg->l+=2; - } - } - break; - } - } -} - -/*-------------------------------------------------------*/ -unsigned capi_cmsg2message (_cmsg *cmsg, CAPI_MESSAGE msg) +static void jumpcstruct(_cmsg * cmsg) { - cmsg->m = msg; - cmsg->l = 8; - cmsg->p = 0; - cmsg->par = cpars [command_2_index (cmsg->Command,cmsg->Subcommand)]; - - if ( cmsg->Command == CAPI_DATA_B3 - && (cmsg->Subcommand == CAPI_REQ || cmsg->Subcommand == CAPI_IND)) { - if (sizeof(void *) == 4) { - cmsg->Data32 = (_cdword)cmsg->Data; - cmsg->Data64 = 0; - } else { - cmsg->Data32 = 0; - cmsg->Data64 = (_cqword)cmsg->Data; - } - } - - PARS_2_MESSAGE (cmsg); - - wordTLcpy (msg+0, &cmsg->l); - byteTLcpy (cmsg->m+4, &cmsg->Command); - byteTLcpy (cmsg->m+5, &cmsg->Subcommand); - wordTLcpy (cmsg->m+2, &cmsg->ApplId); - wordTLcpy (cmsg->m+6, &cmsg->Messagenumber); - - return 0; -} - -/*-------------------------------------------------------*/ -static void MESSAGE_2_PARS (_cmsg *cmsg) { - for (;TYP != _CEND; cmsg->p++) { - - switch (TYP) { - case _CBYTE: - byteTRcpy (cmsg->m+cmsg->l, OFF); - cmsg->l++; - break; - case _CWORD: - wordTRcpy (cmsg->m+cmsg->l, OFF); - cmsg->l+=2; - break; - case _CDWORD: - dwordTRcpy (cmsg->m+cmsg->l, OFF); - cmsg->l+=4; - break; - case _CQWORD: - qwordTRcpy (cmsg->m+cmsg->l, OFF); - cmsg->l+=8; - break; - case _CSTRUCT: - *(CAPI_MESSAGE *)OFF = cmsg->m+cmsg->l; - - if (cmsg->m[cmsg->l] != 0xff) - cmsg->l+= 1+ cmsg->m[cmsg->l]; - else - cmsg->l+= 3+ *(_cword *)(cmsg->m+cmsg->l+1); - break; - case _CMSTRUCT: - /*----- Metastruktur 0 -----*/ - if (cmsg->m[cmsg->l] == '\0') { - *(_cmstruct*)OFF = CAPI_DEFAULT; - cmsg->l++; - jumpcstruct (cmsg); + unsigned layer; + for (cmsg->p++, layer = 1; layer;) { + /* $$$$$ assert (cmsg->p); */ + cmsg->p++; + switch (TYP) { + case _CMSTRUCT: + layer++; + break; + case _CEND: + layer--; + break; } - else { - unsigned _l = cmsg->l; - *(_cmstruct*)OFF = CAPI_COMPOSE; - cmsg->l = (cmsg->m+_l)[0] == 255 ? cmsg->l+3 : cmsg->l+1; - cmsg->p++; - MESSAGE_2_PARS (cmsg); - } - break; } - } } - /*-------------------------------------------------------*/ -unsigned capi_message2cmsg (_cmsg *cmsg, CAPI_MESSAGE msg) +static void pars_2_message(_cmsg * cmsg) { - memset (cmsg, 0, sizeof(_cmsg)); - cmsg->m = msg; - cmsg->l = 8; - cmsg->p = 0; - byteTRcpy (cmsg->m+4, &cmsg->Command); - byteTRcpy (cmsg->m+5, &cmsg->Subcommand); - cmsg->par = cpars [command_2_index (cmsg->Command,cmsg->Subcommand)]; - MESSAGE_2_PARS (cmsg); - - if ( cmsg->Command == CAPI_DATA_B3 - && (cmsg->Subcommand == CAPI_REQ || cmsg->Subcommand == CAPI_IND)) { - if (sizeof(void *) == 4) { - cmsg->Data = (void *)cmsg->Data32; - } else { - cmsg->Data = (void *)cmsg->Data64; - } - } - - wordTRcpy (msg+0, &cmsg->l); - wordTRcpy (cmsg->m+2, &cmsg->ApplId); - wordTRcpy (cmsg->m+6, &cmsg->Messagenumber); - - - return 0; + for (; TYP != _CEND; cmsg->p++) { + switch (TYP) { + case _CBYTE: + byteTLcpy(cmsg->m + cmsg->l, OFF); + cmsg->l++; + break; + case _CWORD: + wordTLcpy(cmsg->m + cmsg->l, OFF); + cmsg->l += 2; + break; + case _CDWORD: + dwordTLcpy(cmsg->m + cmsg->l, OFF); + cmsg->l += 4; + break; + case _CQWORD: + qwordTLcpy (cmsg->m + cmsg->l, OFF); + cmsg->l+=8; + break; + case _CSTRUCT: + if (*(_cbyte **) OFF == 0) { + *(cmsg->m + cmsg->l) = '\0'; + cmsg->l++; + } else if (**(_cstruct *) OFF != 0xff) { + structTLcpy(cmsg->m + cmsg->l, *(_cstruct *) OFF, 1 + **(_cstruct *) OFF); + cmsg->l += 1 + **(_cstruct *) OFF; + } else { + _cstruct s = *(_cstruct *) OFF; + structTLcpy(cmsg->m + cmsg->l, s, 3 + *(_cword *) (s + 1)); + cmsg->l += 3 + *(_cword *) (s + 1); + } + break; + case _CMSTRUCT: +/*----- Metastruktur 0 -----*/ + if (*(_cmstruct *) OFF == CAPI_DEFAULT) { + *(cmsg->m + cmsg->l) = '\0'; + cmsg->l++; + jumpcstruct(cmsg); + } +/*----- Metastruktur wird composed -----*/ + else { + unsigned _l = cmsg->l; + unsigned _ls; + cmsg->l++; + cmsg->p++; + pars_2_message(cmsg); + _ls = cmsg->l - _l - 1; + if (_ls < 255) + (cmsg->m + _l)[0] = (_cbyte) _ls; + else { + structTLcpyovl(cmsg->m + _l + 3, cmsg->m + _l + 1, _ls); + (cmsg->m + _l)[0] = 0xff; + wordTLcpy(cmsg->m + _l + 1, &_ls); + } + } + break; + } + } } /*-------------------------------------------------------*/ -unsigned capi_cmsg_answer (_cmsg *cmsg) +unsigned capi_cmsg2message(_cmsg * cmsg, _cbyte * msg) { - cmsg->Subcommand |= 0x01; - return 0; + cmsg->m = msg; + cmsg->l = 8; + cmsg->p = 0; + cmsg->par = cpars[command_2_index(cmsg->Command, cmsg->Subcommand)]; + + if ( cmsg->Command == CAPI_DATA_B3 + && (cmsg->Subcommand == CAPI_REQ || cmsg->Subcommand == CAPI_IND)) { + if (sizeof(void *) == 4) { + cmsg->Data32 = (_cdword) cmsg->Data; + cmsg->Data64 = 0; + } else { + cmsg->Data32 = 0; + cmsg->Data64 = (_cqword) cmsg->Data; + } + } + + pars_2_message(cmsg); + + wordTLcpy(msg + 0, &cmsg->l); + byteTLcpy(cmsg->m + 4, &cmsg->Command); + byteTLcpy(cmsg->m + 5, &cmsg->Subcommand); + wordTLcpy(cmsg->m + 2, &cmsg->ApplId); + wordTLcpy(cmsg->m + 6, &cmsg->Messagenumber); + + return 0; } /*-------------------------------------------------------*/ -unsigned capi20_cmsg_header (_cmsg *cmsg, unsigned _ApplId, +static void message_2_pars(_cmsg * cmsg) +{ + for (; TYP != _CEND; cmsg->p++) { + + switch (TYP) { + case _CBYTE: + byteTRcpy(cmsg->m + cmsg->l, OFF); + cmsg->l++; + break; + case _CWORD: + wordTRcpy(cmsg->m + cmsg->l, OFF); + cmsg->l += 2; + break; + case _CDWORD: + dwordTRcpy(cmsg->m + cmsg->l, OFF); + cmsg->l += 4; + break; + case _CQWORD: + qwordTRcpy (cmsg->m + cmsg->l, OFF); + cmsg->l+=8; + break; + case _CSTRUCT: + *(_cbyte **) OFF = cmsg->m + cmsg->l; + + if (cmsg->m[cmsg->l] != 0xff) + cmsg->l += 1 + cmsg->m[cmsg->l]; + else + cmsg->l += 3 + *(_cword *) (cmsg->m + cmsg->l + 1); + break; + case _CMSTRUCT: +/*----- Metastruktur 0 -----*/ + if (cmsg->m[cmsg->l] == '\0') { + *(_cmstruct *) OFF = CAPI_DEFAULT; + cmsg->l++; + jumpcstruct(cmsg); + } else { + unsigned _l = cmsg->l; + *(_cmstruct *) OFF = CAPI_COMPOSE; + cmsg->l = (cmsg->m + _l)[0] == 255 ? cmsg->l + 3 : cmsg->l + 1; + cmsg->p++; + message_2_pars(cmsg); + } + break; + } + } +} + +/*-------------------------------------------------------*/ +unsigned capi_message2cmsg(_cmsg * cmsg, _cbyte * msg) +{ + memset(cmsg, 0, sizeof(_cmsg)); + cmsg->m = msg; + cmsg->l = 8; + cmsg->p = 0; + byteTRcpy(cmsg->m + 4, &cmsg->Command); + byteTRcpy(cmsg->m + 5, &cmsg->Subcommand); + cmsg->par = cpars[command_2_index(cmsg->Command, cmsg->Subcommand)]; + + message_2_pars(cmsg); + + if ( cmsg->Command == CAPI_DATA_B3 + && (cmsg->Subcommand == CAPI_REQ || cmsg->Subcommand == CAPI_IND)) { + if (sizeof(void *) == 4) { + cmsg->Data = (void *) cmsg->Data32; + } else { + cmsg->Data = (void *) cmsg->Data64; + } + } + + wordTRcpy(msg + 0, &cmsg->l); + wordTRcpy(cmsg->m + 2, &cmsg->ApplId); + wordTRcpy(cmsg->m + 6, &cmsg->Messagenumber); + + return 0; +} + + +/*-------------------------------------------------------*/ +unsigned capi_cmsg_header (_cmsg *cmsg, unsigned _ApplId, _cbyte _Command, _cbyte _Subcommand, _cword _Messagenumber, _cdword _Controller) { memset (cmsg, 0, sizeof(_cmsg)); @@ -473,7 +644,7 @@ unsigned capi20_cmsg_header (_cmsg *cmsg, unsigned _ApplId, } /*-------------------------------------------------------*/ -unsigned capi20_put_cmsg (_cmsg *cmsg) +unsigned capi_put_cmsg (_cmsg *cmsg) { static unsigned char msg[2048]; @@ -482,7 +653,7 @@ unsigned capi20_put_cmsg (_cmsg *cmsg) } /*-------------------------------------------------------*/ -unsigned capi20_get_cmsg (_cmsg *cmsg, unsigned applid) +unsigned capi_get_cmsg (_cmsg *cmsg, unsigned applid) { MESSAGE_EXCHANGE_ERROR rtn; CAPI_MESSAGE msg; @@ -492,3 +663,300 @@ unsigned capi20_get_cmsg (_cmsg *cmsg, unsigned applid) capi_message2cmsg(cmsg, msg); return rtn; } + +/*-------------------------------------------------------*/ + +static char *mnames[] = +{ + 0, + "ALERT_REQ", + "CONNECT_REQ", + 0, + "DISCONNECT_REQ", + "LISTEN_REQ", + 0, + 0, + "INFO_REQ", + "FACILITY_REQ", + "SELECT_B_PROTOCOL_REQ", + "CONNECT_B3_REQ", + 0, + "DISCONNECT_B3_REQ", + 0, + "DATA_B3_REQ", + "RESET_B3_REQ", + 0, + 0, + "ALERT_CONF", + "CONNECT_CONF", + 0, + "DISCONNECT_CONF", + "LISTEN_CONF", + "MANUFACTURER_REQ", + 0, + "INFO_CONF", + "FACILITY_CONF", + "SELECT_B_PROTOCOL_CONF", + "CONNECT_B3_CONF", + 0, + "DISCONNECT_B3_CONF", + 0, + "DATA_B3_CONF", + "RESET_B3_CONF", + 0, + 0, + 0, + "CONNECT_IND", + "CONNECT_ACTIVE_IND", + "DISCONNECT_IND", + 0, + "MANUFACTURER_CONF", + 0, + "INFO_IND", + "FACILITY_IND", + 0, + "CONNECT_B3_IND", + "CONNECT_B3_ACTIVE_IND", + "DISCONNECT_B3_IND", + 0, + "DATA_B3_IND", + "RESET_B3_IND", + "CONNECT_B3_T90_ACTIVE_IND", + 0, + 0, + "CONNECT_RESP", + "CONNECT_ACTIVE_RESP", + "DISCONNECT_RESP", + 0, + "MANUFACTURER_IND", + 0, + "INFO_RESP", + "FACILITY_RESP", + 0, + "CONNECT_B3_RESP", + "CONNECT_B3_ACTIVE_RESP", + "DISCONNECT_B3_RESP", + 0, + "DATA_B3_RESP", + "RESET_B3_RESP", + "CONNECT_B3_T90_ACTIVE_RESP", + 0, + 0, + 0, + 0, + 0, + 0, + "MANUFACTURER_RESP" +}; + +char *capi_cmd2str(_cbyte cmd, _cbyte subcmd) +{ + return mnames[command_2_index(cmd, subcmd)]; +} + +/*-------------------------------------------------------*/ +/*-------------------------------------------------------*/ + +static char *pnames[] = { + /*00*/0, + /*01*/0, + /*02*/0, + /*03*/"Controller/PLCI/NCCI", + /*04*/"AdditionalInfo", + /*05*/"B1configuration", + /*06*/"B1protocol", + /*07*/"B2configuration", + /*08*/"B2protocol", + /*09*/"B3configuration", + /*0a*/"B3protocol", + /*0b*/"BC", + /*0c*/"BChannelinformation", + /*0d*/"BProtocol", + /*0e*/"CalledPartyNumber", + /*0f*/"CalledPartySubaddress", + /*10*/"CallingPartyNumber", + /*11*/"CallingPartySubaddress", + /*12*/"CIPmask", + /*13*/"CIPmask2", + /*14*/"CIPValue", + /*15*/"Class", + /*16*/"ConnectedNumber", + /*17*/"ConnectedSubaddress", + /*18*/"Data32", + /*19*/"DataHandle", + /*1a*/"DataLength", + /*1b*/"FacilityConfirmationParameter", + /*1c*/"Facilitydataarray", + /*1d*/"FacilityIndicationParameter", + /*1e*/"FacilityRequestParameter", + /*1f*/"FacilityResponseParameters", + /*20*/"FacilitySelector", + /*21*/"Flags", + /*22*/"Function", + /*23*/"HLC", + /*24*/"Info", + /*25*/"InfoElement", + /*26*/"InfoMask", + /*27*/"InfoNumber", + /*28*/"Keypadfacility", + /*29*/"LLC", + /*2a*/"ManuData", + /*2b*/"ManuID", + /*2c*/"NCPI", + /*2d*/"Reason", + /*2e*/"Reason_B3", + /*2f*/"Reject", + /*30*/"Useruserdata", + /*31*/"Data64", +}; + +static char buf[8192]; +static char *p = 0; + +#include +#include + +/*-------------------------------------------------------*/ +static void bufprint(char *fmt,...) +{ + va_list f; + va_start(f, fmt); + vsprintf(p, fmt, f); + va_end(f); + p += strlen(p); +} + +static void printstructlen(_cbyte * m, unsigned len) +{ + unsigned hex = 0; + for (; len; len--, m++) + if (isalnum(*m) || *m == ' ') { + if (hex) + bufprint(">"); + bufprint("%c", *m); + hex = 0; + } else { + if (!hex) + bufprint("<%02x", *m); + else + bufprint(" %02x", *m); + hex = 1; + } + if (hex) + bufprint(">"); +} + +static void printstruct(_cbyte * m) +{ + unsigned len; + if (m[0] != 0xff) { + len = m[0]; + m += 1; + } else { + len = ((_cword *) (m + 1))[0]; + m += 3; + } + printstructlen(m, len); +} + +/*-------------------------------------------------------*/ +#define NAME (pnames[cmsg->par[cmsg->p]]) + +static void protocol_message_2_pars(_cmsg * cmsg, int level) +{ + for (; TYP != _CEND; cmsg->p++) { + int slen = 29 + 3 - level; + int i; + + bufprint(" "); + for (i = 0; i < level - 1; i++) + bufprint(" "); + + switch (TYP) { + case _CBYTE: + bufprint("%-*s = 0x%x\n", slen, NAME, *(_cbyte *) (cmsg->m + cmsg->l)); + cmsg->l++; + break; + case _CWORD: + bufprint("%-*s = 0x%x\n", slen, NAME, *(_cword *) (cmsg->m + cmsg->l)); + cmsg->l += 2; + break; + case _CDWORD: + bufprint("%-*s = 0x%lx\n", slen, NAME, *(_cdword *) (cmsg->m + cmsg->l)); + cmsg->l += 4; + break; + case _CQWORD: + bufprint("%-*s = 0x%llx\n", slen, NAME, *(_cqword *) (cmsg->m + cmsg->l)); + cmsg->l += 4; + break; + case _CSTRUCT: + bufprint("%-*s = ", slen, NAME); + if (cmsg->m[cmsg->l] == '\0') + bufprint("default"); + else + printstruct(cmsg->m + cmsg->l); + bufprint("\n"); + if (cmsg->m[cmsg->l] != 0xff) + cmsg->l += 1 + cmsg->m[cmsg->l]; + else + cmsg->l += 3 + *(_cword *) (cmsg->m + cmsg->l + 1); + + break; + + case _CMSTRUCT: +/*----- Metastruktur 0 -----*/ + if (cmsg->m[cmsg->l] == '\0') { + bufprint("%-*s = default\n", slen, NAME); + cmsg->l++; + jumpcstruct(cmsg); + } else { + char *name = NAME; + unsigned _l = cmsg->l; + bufprint("%-*s\n", slen, name); + cmsg->l = (cmsg->m + _l)[0] == 255 ? cmsg->l + 3 : cmsg->l + 1; + cmsg->p++; + protocol_message_2_pars(cmsg, level + 1); + } + break; + } + } +} +/*-------------------------------------------------------*/ +char *capi_message2str(_cbyte * msg) +{ + + _cmsg cmsg; + p = buf; + p[0] = 0; + + cmsg.m = msg; + cmsg.l = 8; + cmsg.p = 0; + byteTRcpy(cmsg.m + 4, &cmsg.Command); + byteTRcpy(cmsg.m + 5, &cmsg.Subcommand); + cmsg.par = cpars[command_2_index(cmsg.Command, cmsg.Subcommand)]; + + bufprint("%-26s ID=%03d #0x%04x LEN=%04d\n", + mnames[command_2_index(cmsg.Command, cmsg.Subcommand)], + ((unsigned short *) msg)[1], + ((unsigned short *) msg)[3], + ((unsigned short *) msg)[0]); + + protocol_message_2_pars(&cmsg, 1); + return buf; +} + +char *capi_cmsg2str(_cmsg * cmsg) +{ + p = buf; + p[0] = 0; + cmsg->l = 8; + cmsg->p = 0; + bufprint("%s ID=%03d #0x%04x LEN=%04d\n", + mnames[command_2_index(cmsg->Command, cmsg->Subcommand)], + ((_cword *) cmsg->m)[1], + ((_cword *) cmsg->m)[3], + ((_cword *) cmsg->m)[0]); + protocol_message_2_pars(cmsg, 1); + return buf; +}