[libpri-commits] rmudgett: branch group/issue14068 r816 - /team/group/issue14068/

SVN commits to the libpri project libpri-commits at lists.digium.com
Wed May 27 10:16:28 CDT 2009


Author: rmudgett
Date: Wed May 27 10:16:25 2009
New Revision: 816

URL: http://svn.asterisk.org/svn-view/libpri?view=rev&rev=816
Log:
Adjusted COLP API to reduce the amount of memory and copying needed.

Modified:
    team/group/issue14068/libpri.h
    team/group/issue14068/pri_internal.h
    team/group/issue14068/q931.c

Modified: team/group/issue14068/libpri.h
URL: http://svn.asterisk.org/svn-view/libpri/team/group/issue14068/libpri.h?view=diff&rev=816&r1=815&r2=816
==============================================================================
--- team/group/issue14068/libpri.h (original)
+++ team/group/issue14068/libpri.h Wed May 27 10:16:25 2009
@@ -359,9 +359,9 @@
 /*! \brief Information needed to identify an endpoint in a call. */
 struct pri_party_id {
 	/*! Subscriber phone number */
-	char number[256];
+	char number[64];
 	/*! Subscriber name */
-	char name[256];
+	char name[64];
 	/*! Q.931 encoded "type of number" and "numbering plan identification" */
 	int number_type;
 	/*! Q.931 encoded "presentation indicator" and "screening indicator" */
@@ -416,14 +416,14 @@
 	int cmd;
 	union {
 		/*! Reserve room for possible expansion to maintain ABI compatibility. */
-		char reserve_space[2048];
+		char reserve_space[512];
 		struct pri_subcmd_connected_line connected_line;
 		struct pri_subcmd_redirecting redirecting;
 	};
 };
 
 /* Max number of subcommands per event message */
-#define PRI_MAX_SUBCOMMANDS	4
+#define PRI_MAX_SUBCOMMANDS	6
 
 struct pri_subcommands {
 	int counter_subcmd;
@@ -458,7 +458,7 @@
 	char callednum[256];
 	int calledpres;
 	int calledplan;
-	struct pri_subcommands subcmds;
+	struct pri_subcommands *subcmds;
 } pri_event_ringing;
 
 typedef struct pri_event_answer {
@@ -474,7 +474,7 @@
 	int connectedpres;
 	int connectedplan;
 	int source;
-	struct pri_subcommands subcmds;
+	struct pri_subcommands *subcmds;
 } pri_event_answer;
 
 /*! Deprecated replaced by struct pri_event_facility. */
@@ -498,7 +498,7 @@
 	q931_call *call;
 	int callingpres;			/*!< Presentation of Calling CallerID (Deprecated, preserved for struct pri_event_facname compatibility) */
 	int callingplan;			/*!< Dialing plan of Calling entity (Deprecated, preserved for struct pri_event_facname compatibility) */
-	struct pri_subcommands subcmds;
+	struct pri_subcommands *subcmds;
 };
 
 #define PRI_CALLINGPLANANI
@@ -535,7 +535,7 @@
 	int origredirectingreason;
 	int redirectingpres;
 	int redirectingcount;
-	struct pri_subcommands subcmds;
+	struct pri_subcommands *subcmds;
 } pri_event_ring;
 
 typedef struct pri_event_hangup {
@@ -546,7 +546,7 @@
 	q931_call *call;			/* Opaque call pointer */
 	long aoc_units;				/* Advise of Charge number of charged units */
 	char useruserinfo[260];		/* User->User info */
-	struct pri_subcommands subcmds;
+	struct pri_subcommands *subcmds;
 } pri_event_hangup;	
 
 typedef struct pri_event_restart_ack {
@@ -563,20 +563,21 @@
 	int progressmask;
 	int cause;
 	q931_call *call;
-	struct pri_subcommands subcmds;
+	struct pri_subcommands *subcmds;
 } pri_event_proceeding;
  
 typedef struct pri_event_setup_ack {
 	int e;
 	int channel;
 	q931_call *call;
-	struct pri_subcommands subcmds;
+	struct pri_subcommands *subcmds;
 } pri_event_setup_ack;
 
 typedef struct pri_event_notify {
 	int e;
 	int channel;
 	int info;
+	struct pri_subcommands *subcmds;
 } pri_event_notify;
 
 typedef struct pri_event_keypad_digit {
@@ -584,7 +585,7 @@
 	int channel;
 	q931_call *call;
 	char digits[64];
-	struct pri_subcommands subcmds;
+	struct pri_subcommands *subcmds;
 } pri_event_keypad_digit;
 
 typedef struct pri_event_service {

Modified: team/group/issue14068/pri_internal.h
URL: http://svn.asterisk.org/svn-view/libpri/team/group/issue14068/pri_internal.h?view=diff&rev=816&r1=815&r2=816
==============================================================================
--- team/group/issue14068/pri_internal.h (original)
+++ team/group/issue14068/pri_internal.h Wed May 27 10:16:25 2009
@@ -113,6 +113,8 @@
 	struct timeval tv;
 	int schedev;
 	pri_event ev;		/* Static event thingy */
+	/*! Subcommands for static event thingy. */
+	struct pri_subcommands subcmds;
 	
 	/* Q.921 Re-transmission queue */
 	struct q921_frame *txqueue;
@@ -423,4 +425,6 @@
 void q931_party_redirecting_init(struct q931_party_redirecting *redirecting);
 int q931_party_id_presentation(const struct q931_party_id *id);
 
+struct pri_subcommand *q931_alloc_subcommand(struct pri *ctrl);
+
 #endif

Modified: team/group/issue14068/q931.c
URL: http://svn.asterisk.org/svn-view/libpri/team/group/issue14068/q931.c?view=diff&rev=816&r1=815&r2=816
==============================================================================
--- team/group/issue14068/q931.c (original)
+++ team/group/issue14068/q931.c Wed May 27 10:16:25 2009
@@ -3626,17 +3626,15 @@
 	return 0;
 }
 
-static void clr_subcommands(struct pri_subcommands *sub)
-{
-	sub->counter_subcmd = 0;
-}
-
-static struct pri_subcommand *get_ptr_subcommand(struct pri_subcommands *sub)
-{
-	if (sub->counter_subcmd < PRI_MAX_SUBCOMMANDS) {
-		int count = sub->counter_subcmd;
-		sub->counter_subcmd++;
-		return &sub->subcmd[count];
+static void q931_clr_subcommands(struct pri *ctrl)
+{
+	ctrl->subcmds.counter_subcmd = 0;
+}
+
+struct pri_subcommand *q931_alloc_subcommand(struct pri *ctrl)
+{
+	if (ctrl->subcmds.counter_subcmd < PRI_MAX_SUBCOMMANDS) {
+		return &ctrl->subcmds.subcmd[ctrl->subcmds.counter_subcmd++];
 	}
 
 	return NULL;
@@ -3859,6 +3857,7 @@
 	} else {
 		prepare_to_handle_q931_message(pri, mh, c);
 	}
+	q931_clr_subcommands(pri);
 	
 	/* Handle IEs */
 	memset(mandies, 0, sizeof(mandies));
@@ -4050,6 +4049,7 @@
 			break;
 		}
 		pri->ev.e = PRI_EVENT_RING;
+		pri->ev.ring.subcmds = &pri->subcmds;
 		pri->ev.ring.channel = c->channelno | (c->ds1no << 8) | (c->ds1explicit << 16);
 		pri->ev.ring.callingpres = q931_party_id_presentation(&c->caller_id);
 		pri->ev.ring.callingplan = c->caller_id.number.plan;
@@ -4096,6 +4096,7 @@
 		UPDATE_OURCALLSTATE(pri, c, Q931_CALL_STATE_CALL_DELIVERED);
 		c->peercallstate = Q931_CALL_STATE_CALL_RECEIVED;
 		pri->ev.e = PRI_EVENT_RINGING;
+		pri->ev.ringing.subcmds = &pri->subcmds;
 		pri->ev.ringing.channel = c->channelno | (c->ds1no << 8) | (c->ds1explicit << 16);
 		pri->ev.ringing.cref = c->cr;
 		pri->ev.ringing.call = c;
@@ -4139,6 +4140,7 @@
 		UPDATE_OURCALLSTATE(pri, c, Q931_CALL_STATE_ACTIVE);
 		c->peercallstate = Q931_CALL_STATE_CONNECT_REQUEST;
 		pri->ev.e = PRI_EVENT_ANSWER;
+		pri->ev.answer.subcmds = &pri->subcmds;
 		pri->ev.answer.channel = c->channelno | (c->ds1no << 8) | (c->ds1explicit << 16);
 		pri->ev.answer.cref = c->cr;
 		pri->ev.answer.call = c;
@@ -4162,8 +4164,6 @@
 			int haveevent = 0;
 			struct pri_subcommand *subcmd;
 
-			clr_subcommands(&pri->ev.facility.subcmds);
-
 			if (c->newcall) {
 				q931_release_complete(pri,c,PRI_CAUSE_INVALID_CALL_REFERENCE);
 				break;
@@ -4175,7 +4175,7 @@
 					/* answered(0) */
 					pri_message(pri, "Got CT-Complete, callStatus = answered(0)\n");
 
-					subcmd = get_ptr_subcommand(&pri->ev.facility.subcmds);
+					subcmd = q931_alloc_subcommand(pri);
 					if (subcmd) {
 						struct pri_subcmd_connected_line *cmdcl = &subcmd->connected_line;
 
@@ -4192,7 +4192,7 @@
 					/* alerting(1) */
 					pri_message(pri, "Got CT-Complete, callStatus = alerting(1)\n");
 
-					subcmd = get_ptr_subcommand(&pri->ev.facility.subcmds);
+					subcmd = q931_alloc_subcommand(pri);
 					if (subcmd) {
 						struct pri_subcmd_redirecting *cmdr = &subcmd->redirecting;
 
@@ -4218,7 +4218,7 @@
 
 				pri_message(pri, "Got CT-Active\n");
 
-				subcmd = get_ptr_subcommand(&pri->ev.facility.subcmds);
+				subcmd = q931_alloc_subcommand(pri);
 				if (subcmd) {
 					struct pri_subcmd_connected_line *cmdcl = &subcmd->connected_line;
 
@@ -4236,7 +4236,7 @@
 
 				pri_message(pri, "Got DivertingLegInformation1\n");
 
-				subcmd = get_ptr_subcommand(&pri->ev.facility.subcmds);
+				subcmd = q931_alloc_subcommand(pri);
 				if (subcmd) {
 					struct pri_subcmd_redirecting *cmdr = &subcmd->redirecting;
 
@@ -4258,6 +4258,7 @@
 
 			if (haveevent) {
 				pri->ev.e = PRI_EVENT_FACILITY;
+				pri->ev.facility.subcmds = &pri->subcmds;
 				pri->ev.facility.channel = c->channelno | (c->ds1no << 8) | (c->ds1explicit << 16);
 				pri->ev.facility.cref = c->cr;
 				pri->ev.facility.call = c;
@@ -4282,6 +4283,7 @@
 		pri->ev.proceeding.cause = c->cause;
 		/* Fall through */
 	case Q931_CALL_PROCEEDING:
+		pri->ev.proceeding.subcmds = &pri->subcmds;
 		if (c->newcall) {
 			q931_release_complete(pri,c,PRI_CAUSE_INVALID_CALL_REFERENCE);
 			break;
@@ -4353,6 +4355,7 @@
 
 		if (!c->sugcallstate) {
 #endif
+			pri->ev.hangup.subcmds = &pri->subcmds;
 			pri->ev.hangup.channel = c->channelno | (c->ds1no << 8) | (c->ds1explicit << 16);
 			pri->ev.hangup.cause = c->cause;
 			pri->ev.hangup.cref = c->cr;
@@ -4381,6 +4384,7 @@
 	case Q931_RELEASE_COMPLETE:
 		UPDATE_OURCALLSTATE(pri, c, Q931_CALL_STATE_NULL);
 		c->peercallstate = Q931_CALL_STATE_NULL;
+		pri->ev.hangup.subcmds = &pri->subcmds;
 		pri->ev.hangup.channel = c->channelno | (c->ds1no << 8) | (c->ds1explicit << 16);
 		pri->ev.hangup.cause = c->cause;
 		pri->ev.hangup.cref = c->cr;
@@ -4416,6 +4420,7 @@
 		}
 		UPDATE_OURCALLSTATE(pri, c, Q931_CALL_STATE_NULL);
 		pri->ev.e = PRI_EVENT_HANGUP;
+		pri->ev.hangup.subcmds = &pri->subcmds;
 		pri->ev.hangup.channel = c->channelno | (c->ds1no << 8) | (c->ds1explicit << 16);
 		pri->ev.hangup.cause = c->cause;
 		pri->ev.hangup.cref = c->cr;
@@ -4450,6 +4455,7 @@
 
 		/* Return such an event */
 		pri->ev.e = PRI_EVENT_HANGUP_REQ;
+		pri->ev.hangup.subcmds = &pri->subcmds;
 		pri->ev.hangup.channel = c->channelno | (c->ds1no << 8) | (c->ds1explicit << 16);
 		pri->ev.hangup.cause = c->cause;
 		pri->ev.hangup.cref = c->cr;
@@ -4479,12 +4485,14 @@
 		}
 		if (c->ourcallstate != Q931_CALL_STATE_OVERLAP_RECEIVING) {
 			pri->ev.e = PRI_EVENT_KEYPAD_DIGIT;
+			pri->ev.digit.subcmds = &pri->subcmds;
 			pri->ev.digit.call = c;
 			pri->ev.digit.channel = c->channelno | (c->ds1no << 8);
 			libpri_copy_string(pri->ev.digit.digits, c->keypad_digits, sizeof(pri->ev.digit.digits));
 			return Q931_RES_HAVEEVENT;
 		}
 		pri->ev.e = PRI_EVENT_INFO_RECEIVED;
+		pri->ev.ring.subcmds = &pri->subcmds;
 		pri->ev.ring.call = c;
 		pri->ev.ring.channel = c->channelno | (c->ds1no << 8) | (c->ds1explicit << 16);
 		libpri_copy_string(pri->ev.ring.callednum, c->overlap_digits, sizeof(pri->ev.ring.callednum));
@@ -4505,6 +4513,7 @@
 		UPDATE_OURCALLSTATE(pri, c, Q931_CALL_STATE_OVERLAP_SENDING);
 		c->peercallstate = Q931_CALL_STATE_OVERLAP_RECEIVING;
 		pri->ev.e = PRI_EVENT_SETUP_ACK;
+		pri->ev.setup_ack.subcmds = &pri->subcmds;
 		pri->ev.setup_ack.channel = c->channelno | (c->ds1no << 8) | (c->ds1explicit << 16);
 		pri->ev.setup_ack.call = c;
 
@@ -4520,6 +4529,7 @@
 		return Q931_RES_HAVEEVENT;
 	case Q931_NOTIFY:
 		pri->ev.e = PRI_EVENT_NOTIFY;
+		pri->ev.notify.subcmds = &pri->subcmds;
 		pri->ev.notify.channel = c->channelno;
 		pri->ev.notify.info = c->notify;
 		return Q931_RES_HAVEEVENT;
@@ -4570,6 +4580,7 @@
 
 	UPDATE_OURCALLSTATE(pri, c, Q931_CALL_STATE_NULL);
 	c->peercallstate = Q931_CALL_STATE_NULL;
+	pri->ev.hangup.subcmds = &pri->subcmds;
 	pri->ev.hangup.channel = c->channelno | (c->ds1no << 8) | (c->ds1explicit << 16);
 	pri->ev.hangup.cause = c->cause;      		
 	pri->ev.hangup.cref = c->cr;          		




More information about the libpri-commits mailing list