Add 3PTY call facility to mISDNuser/suppserv

jolly <[email protected]>
Newsgroups gmane.linux.isdn.i4l.user
Message-ID <[email protected]>
hi karsten,

i just added 3PTY call to mISDN user package. I tested it with LCR and
it works, but please review anyway.

regards,

andreas

_______________________________________________
isdn4linux mailing list
[email protected]
https://www.isdn4linux.de/mailman/listinfo/isdn4linux
0001-Add-3PTY-call-facility-to-suppserv.patch (text/plain, 10.2 KB)
From a10f216a07eb4dfeb62d5f233e1441c659155832 Mon Sep 17 00:00:00 2001
From: root <root@pbx.(none)>
Date: Sat, 28 Jul 2012 16:25:46 +0200
Subject: [PATCH] Add 3PTY call facility to suppserv

---
 include/mISDN/suppserv.h |    3 +
 lib/Makefile.am          |    5 +-
 lib/Makefile.in          |   13 ++++-
 lib/include/3pty.h       |   27 +++++++++++
 lib/suppserv/3pty.c      |  111 ++++++++++++++++++++++++++++++++++++++++++++++
 lib/suppserv/component.c |    9 ++++
 lib/suppserv/fac.c       |   12 +++++
 7 files changed, 175 insertions(+), 5 deletions(-)
 create mode 100644 lib/include/3pty.h
 create mode 100644 lib/suppserv/3pty.c

diff --git a/include/mISDN/suppserv.h b/include/mISDN/suppserv.h
index bcbc003..0325df9 100644
--- a/include/mISDN/suppserv.h
+++ b/include/mISDN/suppserv.h
@@ -66,6 +66,9 @@ extern "C" {
 		 * Malicious Call Identification Operation Request
 		 */
 		Fac_MaliciousCallId = FAC_OID_BASE(FacOIDBase_Local) + 3,
+		/* 3PTY */
+		Fac_Begin3PTY = FAC_OID_BASE(FacOIDBase_Local) + 4,
+		Fac_End3PTY = FAC_OID_BASE(FacOIDBase_Local) + 5,
 		/*
 		 * localValue's from Diversion-Operations
 		 * {ccitt identified-organization etsi(0) 207 operations-and-errors(1)}
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 436d1d8..cfc2a87 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -2,9 +2,10 @@ 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/fac.c suppserv/ect.c suppserv/3pty.c
 
-SUPPSERV_INC = suppserv/ccbs.h suppserv/diversion.h suppserv/ect.h suppserv/asn1.h
+SUPPSERV_INC = suppserv/ccbs.h suppserv/diversion.h suppserv/ect.h suppserv/asn1.h \
+		suppserv/3pty.h
 
 
 MISC_SRC =	misc/debug.c misc/fsm.c misc/mbuffer.c misc/mtimer.c
diff --git a/lib/Makefile.in b/lib/Makefile.in
index 4bfc398..689132e 100644
--- a/lib/Makefile.in
+++ b/lib/Makefile.in
@@ -80,7 +80,7 @@ am__objects_5 = asn1/asn1.lo asn1/asn1_enc.lo asn1/asn1_generic.lo
 am__objects_6 = suppserv/aoc.lo suppserv/basic_service.lo \
 	suppserv/component.lo suppserv/diversion.lo \
 	suppserv/address.lo suppserv/ccbs.lo suppserv/fac.lo \
-	suppserv/ect.lo
+	suppserv/ect.lo suppserv/3pty.lo
 am_libmisdn_la_OBJECTS = $(am__objects_1) $(am__objects_2) \
 	$(am__objects_4) $(am__objects_5) $(am__objects_6)
 libmisdn_la_OBJECTS = $(am_libmisdn_la_OBJECTS)
@@ -230,9 +230,11 @@ top_srcdir = @top_srcdir@
 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/fac.c suppserv/ect.c suppserv/3pty.c
+
+SUPPSERV_INC = suppserv/ccbs.h suppserv/diversion.h suppserv/ect.h suppserv/asn1.h \
+		suppserv/3pty.h
 
-SUPPSERV_INC = suppserv/ccbs.h suppserv/diversion.h suppserv/ect.h suppserv/asn1.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 \
@@ -366,6 +368,8 @@ suppserv/fac.lo: suppserv/$(am__dirstamp) \
 	suppserv/$(DEPDIR)/$(am__dirstamp)
 suppserv/ect.lo: suppserv/$(am__dirstamp) \
 	suppserv/$(DEPDIR)/$(am__dirstamp)
+suppserv/3pty.lo: suppserv/$(am__dirstamp) \
+	suppserv/$(DEPDIR)/$(am__dirstamp)
 libmisdn.la: $(libmisdn_la_OBJECTS) $(libmisdn_la_DEPENDENCIES) 
 	$(libmisdn_la_LINK) -rpath $(libdir) $(libmisdn_la_OBJECTS) $(libmisdn_la_LIBADD) $(LIBS)
 
@@ -395,6 +399,8 @@ mostlyclean-compile:
 	-rm -f misc/mbuffer.lo
 	-rm -f misc/mtimer.$(OBJEXT)
 	-rm -f misc/mtimer.lo
+	-rm -f suppserv/3pty.$(OBJEXT)
+	-rm -f suppserv/3pty.lo
 	-rm -f suppserv/address.$(OBJEXT)
 	-rm -f suppserv/address.lo
 	-rm -f suppserv/aoc.$(OBJEXT)
@@ -427,6 +433,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@misc/$(DEPDIR)/fsm.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@misc/$(DEPDIR)/mbuffer.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@misc/$(DEPDIR)/mtimer.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@suppserv/$(DEPDIR)/3pty.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@suppserv/$(DEPDIR)/address.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@suppserv/$(DEPDIR)/aoc.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@suppserv/$(DEPDIR)/basic_service.Plo@am__quote@
diff --git a/lib/include/3pty.h b/lib/include/3pty.h
new file mode 100644
index 0000000..ea2a15c
--- /dev/null
+++ b/lib/include/3pty.h
@@ -0,0 +1,27 @@
+/*
+ * $Id$
+ *
+ * 3 Party (3PTY) Supplementary Services Q.954-2
+ *
+ * 3PTY Facility ie encode/decode header
+ */
+
+#ifndef __ASN1_3PTY_H
+#define __ASN1_3PTY_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* ------------------------------------------------------------------- */
+
+	int encodeBegin3PTY(__u8 * Dest, const struct asn1_parm *pc, const void *val);
+	int encodeEnd3PTY(__u8 * Dest, const struct asn1_parm *pc, const void *val);
+
+/* ------------------------------------------------------------------- */
+
+#ifdef __cplusplus
+}
+#endif
+#endif				/* __ASN1_3PTY_H */
+/* ------------------------------------------------------------------- *//* end asn1_3pty.h */
diff --git a/lib/suppserv/3pty.c b/lib/suppserv/3pty.c
new file mode 100644
index 0000000..87106a3
--- /dev/null
+++ b/lib/suppserv/3pty.c
@@ -0,0 +1,111 @@
+/*
+ *
+ * Explicit Call Transfer (ECT) Supplementary Services ETS 300 369-1
+ *
+ * ECT Facility ie encode/decode
+ *
+ * Copyright 2009,2010  by Karsten Keil <[email protected]>
+ *
+ * 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 "3pty.h"
+
+/* ******************************************************************* */
+/*!
+ * \brief Encode the Begin3PTY facility ie.
+ *
+ * \param Dest Where to put the encoding
+ *
+ * \retval length on success.
+ * \retval -1 on error.
+ */
+int encodeFacBegin3PTY(__u8 * Dest, const struct asn1_parm *pc, void *unused)
+{
+	int Length;
+	__u8 *p;
+	__u8 *SeqStart;
+
+	switch (pc->comp) {
+	case CompInvoke:
+		p = encodeComponentInvoke_Head(Dest, pc->u.inv.invokeId, Fac_Begin3PTY);
+
+		Length = encodeComponent_Length(Dest, p);
+		break;
+	case CompReturnResult:
+		p = encodeComponent_Head(Dest, asn1ComponentTag_Result);
+		p += encodeInt(p, ASN1_TAG_INTEGER, pc->u.retResult.invokeId);
+
+		SeqStart = p;
+		SeqStart[0] = ASN1_TAG_SEQUENCE;
+		p = &SeqStart[2];
+
+		p += encodeOperationValue(p, Fac_Begin3PTY);
+
+		/* sequence Length */
+		SeqStart[1] = p - &SeqStart[2];
+
+		Length = encodeComponent_Length(Dest, p);
+		break;
+	default:
+		Length = -1;
+		break;
+	}			/* end switch */
+
+	return Length;
+}				/* end encodeFacEctLoopTest() */
+
+/* ******************************************************************* */
+/*!
+ * \brief Encode the End3PTY facility ie.
+ *
+ * \param Dest Where to put the encoding
+ *
+ * \retval length on success.
+ * \retval -1 on error.
+ */
+int encodeFacEnd3PTY(__u8 * Dest, const struct asn1_parm *pc, void *unused)
+{
+	int Length;
+	__u8 *p;
+	__u8 *SeqStart;
+
+	switch (pc->comp) {
+	case CompInvoke:
+		p = encodeComponentInvoke_Head(Dest, pc->u.inv.invokeId, Fac_End3PTY);
+
+		Length = encodeComponent_Length(Dest, p);
+		break;
+	case CompReturnResult:
+		p = encodeComponent_Head(Dest, asn1ComponentTag_Result);
+		p += encodeInt(p, ASN1_TAG_INTEGER, pc->u.retResult.invokeId);
+
+		SeqStart = p;
+		SeqStart[0] = ASN1_TAG_SEQUENCE;
+		p = &SeqStart[2];
+
+		p += encodeOperationValue(p, Fac_End3PTY);
+
+		/* sequence Length */
+		SeqStart[1] = p - &SeqStart[2];
+
+		Length = encodeComponent_Length(Dest, p);
+		break;
+	default:
+		Length = -1;
+		break;
+	}			/* end switch */
+
+	return Length;
+}				/* end encodeFacEctLoopTest() */
+
+
diff --git a/lib/suppserv/component.c b/lib/suppserv/component.c
index af903dc..9eb10c6 100644
--- a/lib/suppserv/component.c
+++ b/lib/suppserv/component.c
@@ -149,6 +149,10 @@ static int ParseInvokeComponent(struct asn1_parm *pc, u_char * p, u_char * end,
 
 	switch (operationValue) {
 		/* Diversion support */
+	case Fac_Begin3PTY:
+	case Fac_End3PTY:
+		/* No additional invoke parameters */
+		break;
 	case Fac_ActivationDiversion:
 		XSEQUENCE_1(ParseActivationDiversion, ASN1_TAG_SEQUENCE, ASN1_NOT_TAGGED, &pc->u.inv.o.ActivationDiversion);
 		break;
@@ -309,6 +313,11 @@ int ParseReturnResultComponentSequence(struct asn1_parm *pc, u_char * p, u_char
 	pc->u.retResult.operationValuePresent = 1;
 
 	switch (pc->u.retResult.operationValue) {
+		/* 3PTY */
+	case Fac_Begin3PTY:
+	case Fac_End3PTY:
+		/* No additional result parameters */
+		break;
 		/* Diversion support */
 	case Fac_ActivationDiversion:
 	case Fac_DeactivationDiversion:
diff --git a/lib/suppserv/fac.c b/lib/suppserv/fac.c
index 244f51d..bbb7c39 100644
--- a/lib/suppserv/fac.c
+++ b/lib/suppserv/fac.c
@@ -360,6 +360,12 @@ static int encodeFacReturnResult(__u8 * dest, const struct asn1_parm *pc)
         dprint(DBGM_ASN1_ENC, "Return result %s Id:%d start encoding\n", ops, res->invokeId);
         if (res->operationValuePresent) {
                 switch (res->operationValue) {
+		case Fac_Begin3PTY:
+			len = encodeFacBegin3PTY(dest, pc, NULL);
+			break;
+		case Fac_End3PTY:
+			len = encodeFacEnd3PTY(dest, pc, NULL);
+			break;
                 case Fac_StatusRequest:
 			len = encodeFacStatusRequest(dest, pc, NULL);
 			break;
@@ -499,6 +505,12 @@ static int encodeFacInvoke(__u8 * dest, const struct asn1_parm *pc)
 	case Fac_ActivationDiversion:
 		len = encodeFacActivationDiversion(dest, pc, &inv->o.ActivationDiversion);
 		break;
+	case Fac_Begin3PTY:
+		len = encodeFacBegin3PTY(dest, pc, NULL);
+		break;
+	case Fac_End3PTY:
+		len = encodeFacEnd3PTY(dest, pc, NULL);
+		break;
 	case Fac_DeactivationDiversion:
 		len = encodeFacDeactivationDiversion(dest, pc, &inv->o.DeactivationDiversion);
 		break;
-- 
1.7.3.4
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.