[libpri-commits] seanbright: branch 1.4 r907 - /branches/1.4/

SVN commits to the libpri project libpri-commits at lists.digium.com
Thu Jun 25 13:53:42 CDT 2009


Author: seanbright
Date: Thu Jun 25 13:53:38 2009
New Revision: 907

URL: http://svn.asterisk.org/svn-view/libpri?view=rev&rev=907
Log:
Add support for sending Reverse Charging Indication IE on ISDN PRI.

Add the ability to transmit a Reverse Charging Indication IE during a SETUP
message.  In passing, re-work some of the receive logic to be forwards
compatible with new RCI values that may be added in the future.  Also removed
the PRI_REVERSECHARGE_SUPPORT define that I added on the last commit since we
can just check for PRI_REVERSECHARGE_NONE or _REQUESTED on the Asterisk side to
determine support for this.

Special thanks to rmudgett who could have written this in half the time he spent
reviewing it, but instead talked me through it.  Much appreciated!

(issue #13760)
Reported by: mrgabu

Review: https://reviewboard.asterisk.org/r/292/

Modified:
    branches/1.4/libpri.h
    branches/1.4/pri.c
    branches/1.4/pri_internal.h
    branches/1.4/q931.c

Modified: branches/1.4/libpri.h
URL: http://svn.asterisk.org/svn-view/libpri/branches/1.4/libpri.h?view=diff&rev=907&r1=906&r2=907
==============================================================================
--- branches/1.4/libpri.h (original)
+++ branches/1.4/libpri.h Thu Jun 25 13:53:38 2009
@@ -182,6 +182,10 @@
 
 #define PRES_NUMBER_NOT_AVAILABLE \
 	(PRI_PRES_UNAVAILABLE | PRI_PRES_NETWORK_NUMBER)
+
+/* Reverse Charging Indication */
+#define PRI_REVERSECHARGE_NONE      -1
+#define PRI_REVERSECHARGE_REQUESTED  1
 
 /* Causes for disconnection */
 #define PRI_CAUSE_UNALLOCATED					1
@@ -643,6 +647,7 @@
 #define PRI_USER_USER_TX
 /* Set the user user field.  Warning!  don't send binary data accross this field */
 void pri_sr_set_useruser(struct pri_sr *sr, const char *userchars);
+void pri_sr_set_reversecharge(struct pri_sr *sr, int requested);
 
 void pri_call_set_useruser(q931_call *sr, const char *userchars);
 
@@ -709,7 +714,6 @@
 #define PRI_REDIRECTING_REASON
 #define PRI_AOC_UNITS
 #define PRI_ANI
-#define PRI_REVERSECHARGE_SUPPORT
 
 /* Send notification */
 int pri_notify(struct pri *pri, q931_call *c, int channel, int info);

Modified: branches/1.4/pri.c
URL: http://svn.asterisk.org/svn-view/libpri/branches/1.4/pri.c?view=diff&rev=907&r1=906&r2=907
==============================================================================
--- branches/1.4/pri.c (original)
+++ branches/1.4/pri.c Thu Jun 25 13:53:38 2009
@@ -692,7 +692,7 @@
 static void pri_sr_init(struct pri_sr *req)
 {
 	memset(req, 0, sizeof(struct pri_sr));
-	
+	req->reversecharge = PRI_REVERSECHARGE_NONE;
 }
 
 int pri_sr_set_connection_call_independent(struct pri_sr *req)
@@ -961,3 +961,8 @@
 	sr->redirectingreason = reason;
 	return 0;
 }
+
+void pri_sr_set_reversecharge(struct pri_sr *sr, int requested)
+{
+	sr->reversecharge = requested;
+}

Modified: branches/1.4/pri_internal.h
URL: http://svn.asterisk.org/svn-view/libpri/branches/1.4/pri_internal.h?view=diff&rev=907&r1=906&r2=907
==============================================================================
--- branches/1.4/pri_internal.h (original)
+++ branches/1.4/pri_internal.h Thu Jun 25 13:53:38 2009
@@ -156,6 +156,7 @@
 	int justsignalling;
 	const char *useruserinfo;
 	int transferable;
+	int reversecharge;
 };
 
 /* Internal switch types */
@@ -272,7 +273,10 @@
 	q931_call *bridged_call;        /* Pointer to other leg of bridged call (Used by Q.SIG when eliminating tromboned calls) */
 
 	int changestatus;		/* SERVICE message changestatus */
-	int reversecharge;		/* Reverse charging indication */
+	int reversecharge;		/* Reverse charging indication:
+							   -1 - No reverse charging
+							    1 - Reverse charging
+							0,2-7 - Reserved for future use */
 };
 
 extern int pri_schedule_event(struct pri *pri, int ms, void (*function)(void *data), void *data);

Modified: branches/1.4/q931.c
URL: http://svn.asterisk.org/svn-view/libpri/branches/1.4/q931.c?view=diff&rev=907&r1=906&r2=907
==============================================================================
--- branches/1.4/q931.c (original)
+++ branches/1.4/q931.c Thu Jun 25 13:53:38 2009
@@ -2154,6 +2154,15 @@
 	return 0;
 }
 
+static int transmit_reverse_charging_indication(int full_ie, struct pri *ctrl, q931_call *call, int msgtype, q931_ie *ie, int len, int order)
+{
+	if (call->reversecharge != PRI_REVERSECHARGE_NONE) {
+		ie->data[0] = 0x80 | (call->reversecharge & 0x7);
+		return 3;
+	}
+	return 0;
+}
+
 static struct ie ies[] = {
 	/* Codeset 0 - Common */
 	{ 1, NATIONAL_CHANGE_STATUS, "Change Status", dump_change_status, receive_change_status, transmit_change_status },
@@ -2170,7 +2179,7 @@
 	{ 1, Q931_BINARY_PARAMETERS, "Packet-layer Binary Parameters" },
 	{ 1, Q931_WINDOW_SIZE, "Packet-layer Window Size" },
 	{ 1, Q931_CLOSED_USER_GROUP, "Closed User Group" },
-	{ 1, Q931_REVERSE_CHARGE_INDIC, "Reverse Charging Indication", dump_reverse_charging_indication, receive_reverse_charging_indication },
+	{ 1, Q931_REVERSE_CHARGE_INDIC, "Reverse Charging Indication", dump_reverse_charging_indication, receive_reverse_charging_indication, transmit_reverse_charging_indication },
 	{ 1, Q931_CALLING_PARTY_NUMBER, "Calling Party Number", dump_calling_party_number, receive_calling_party_number, transmit_calling_party_number },
 	{ 1, Q931_CALLING_PARTY_SUBADDR, "Calling Party Subaddress", dump_calling_party_subaddr, receive_calling_party_subaddr },
 	{ 1, Q931_CALLED_PARTY_NUMBER, "Called Party Number", dump_called_party_number, receive_called_party_number, transmit_called_party_number },
@@ -3116,8 +3125,8 @@
 }
 
 static int setup_ies[] = { Q931_BEARER_CAPABILITY, Q931_CHANNEL_IDENT, Q931_IE_FACILITY, Q931_PROGRESS_INDICATOR, Q931_NETWORK_SPEC_FAC, Q931_DISPLAY,
-	Q931_CALLING_PARTY_NUMBER, Q931_CALLED_PARTY_NUMBER, Q931_REDIRECTING_NUMBER, Q931_IE_USER_USER, Q931_SENDING_COMPLETE,
-	Q931_IE_ORIGINATING_LINE_INFO, Q931_IE_GENERIC_DIGITS, -1 };
+	Q931_REVERSE_CHARGE_INDIC, Q931_CALLING_PARTY_NUMBER, Q931_CALLED_PARTY_NUMBER, Q931_REDIRECTING_NUMBER, Q931_IE_USER_USER,
+	Q931_SENDING_COMPLETE, Q931_IE_ORIGINATING_LINE_INFO, Q931_IE_GENERIC_DIGITS, -1 };
 
 static int gr303_setup_ies[] =  { Q931_BEARER_CAPABILITY, Q931_CHANNEL_IDENT, -1 };
 
@@ -3205,6 +3214,8 @@
 		c->progressmask = PRI_PROG_CALLER_NOT_ISDN;
 	else
 		c->progressmask = 0;
+
+	c->reversecharge = req->reversecharge;
 
 	pri_call_add_standard_apdus(ctrl, c);
 
@@ -3445,6 +3456,7 @@
 		c->complete = 0;
 		c->nonisdn = 0;
 		c->aoc_units = -1;
+		c->reversecharge = -1;
 		/* Fall through */
 	case Q931_CONNECT:
 	case Q931_ALERTING:




More information about the libpri-commits mailing list