[libpri-commits] dvossel: branch dvossel/aoc_send r1562 - /team/dvossel/aoc_send/

SVN commits to the libpri project libpri-commits at lists.digium.com
Mon Mar 22 10:59:01 CDT 2010


Author: dvossel
Date: Mon Mar 22 10:58:57 2010
New Revision: 1562

URL: http://svnview.digium.com/svn/libpri?view=rev&rev=1562
Log:
addition of AOC Charging Request send routine

Modified:
    team/dvossel/aoc_send/libpri.h
    team/dvossel/aoc_send/pri_aoc.c
    team/dvossel/aoc_send/pri_facility.c
    team/dvossel/aoc_send/pri_facility.h

Modified: team/dvossel/aoc_send/libpri.h
URL: http://svnview.digium.com/svn/libpri/team/dvossel/aoc_send/libpri.h?view=diff&rev=1562&r1=1561&r2=1562
==============================================================================
--- team/dvossel/aoc_send/libpri.h (original)
+++ team/dvossel/aoc_send/libpri.h Mon Mar 22 10:58:57 2010
@@ -542,6 +542,7 @@
 #define PRI_SUBCMD_AOC_S					18	/*!< Advice Of Charge Start information (Rate list) */
 #define PRI_SUBCMD_AOC_D					19	/*!< Advice Of Charge During information */
 #define PRI_SUBCMD_AOC_E					20	/*!< Advice Of Charge End information */
+#define PRI_SUBCMD_AOC_CHARGING_REQUEST		21	/*!< Advice Of Charge Request information */
 
 #if defined(STATUS_REQUEST_PLACE_HOLDER)
 struct pri_subcmd_status_request {
@@ -649,6 +650,20 @@
 	int is_call_2_held;
 	/*! Invocation ID to use when sending a reply to the transfer request. */
 	int invoke_id;
+};
+
+enum PRI_AOC_REQUEST {
+	PRI_AOC_REQUEST_S,
+	PRI_AOC_REQUEST_D,
+	PRI_AOC_REQUEST_E,
+};
+
+struct pri_subcmd_aoc_request {
+	/*!
+	 * \brief What types of aoc are being requested.
+	 * \see enum PRI_AOC_REQUEST
+	 */
+	int charging_request;
 };
 
 /*! \brief What is being charged. */
@@ -877,6 +892,7 @@
 		struct pri_subcmd_cc_id cc_call;
 		struct pri_subcmd_cc_cancel cc_cancel;
 		struct pri_subcmd_transfer transfer;
+		struct pri_subcmd_aoc_request aoc_request;
 		struct pri_subcmd_aoc_s aoc_s;
 		struct pri_subcmd_aoc_d aoc_d;
 		struct pri_subcmd_aoc_e aoc_e;
@@ -1467,6 +1483,9 @@
    (and maybe some timers) */
 void pri_enslave(struct pri *master, struct pri *slave);
 
+/* Send AOC-Request message */
+int pri_aoc_charging_request_send(struct pri *ctrl, q931_call *c, const struct pri_subcmd_aoc_request *aoc_request);
+
 /* Send AOC-D message */
 int pri_aoc_d_send(struct pri *ctrl, q931_call *c, const struct pri_subcmd_aoc_d *aoc_d);
 

Modified: team/dvossel/aoc_send/pri_aoc.c
URL: http://svnview.digium.com/svn/libpri/team/dvossel/aoc_send/pri_aoc.c?view=diff&rev=1562&r1=1561&r2=1562
==============================================================================
--- team/dvossel/aoc_send/pri_aoc.c (original)
+++ team/dvossel/aoc_send/pri_aoc.c Mon Mar 22 10:58:57 2010
@@ -114,6 +114,43 @@
 		}
 	}
 	subcmd_recorded->num_items = idx;
+}
+
+/*!
+ * \brief Handle the ETSI ChargingRequest.
+ *
+ * \param ctrl D channel controller for diagnostic messages or global options.
+ * \param invoke Decoded ROSE invoke message contents.
+ *
+ * \return Nothing
+ */
+void aoc_etsi_aoc_request(struct pri *ctrl, const struct rose_msg_invoke *invoke)
+{
+	struct pri_subcommand *subcmd;
+
+	if (!PRI_MASTER(ctrl)->aoc_support) {
+		return;
+	}
+	subcmd = q931_alloc_subcommand(ctrl);
+	if (!subcmd) {
+		return;
+	}
+
+	subcmd->cmd = PRI_SUBCMD_AOC_CHARGING_REQUEST;
+
+	switch (invoke->args.etsi.ChargingRequest.charging_case) {
+	case 0:
+		subcmd->u.aoc_request.charging_request = PRI_AOC_REQUEST_S;
+		break;
+	case 1:
+		subcmd->u.aoc_request.charging_request = PRI_AOC_REQUEST_D;
+		break;
+	case 2:
+		subcmd->u.aoc_request.charging_request = PRI_AOC_REQUEST_E;
+		break;
+	default:
+		subcmd->u.aoc_request.charging_request = PRI_AOC_REQUEST_S;
+	}
 }
 
 /*!
@@ -921,6 +958,53 @@
 
 /*!
  * \internal
+ * \brief Encode the ETSI ChargingRequest invoke message.
+ *
+ * \param ctrl D channel controller for diagnostic messages or global options.
+ * \param pos Starting position to encode the facility ie contents.
+ * \param end End of facility ie contents encoding data buffer.
+ * \param aoc_request, the aoc charging request data to encode.
+ *
+ * \retval Start of the next ASN.1 component to encode on success.
+ * \retval NULL on error.
+ */
+static unsigned char *enc_etsi_aoc_request(struct pri *ctrl, unsigned char *pos,
+	unsigned char *end, const struct pri_subcmd_aoc_request *aoc_request)
+{
+	struct rose_msg_invoke msg;
+
+	pos = facility_encode_header(ctrl, pos, end, NULL);
+	if (!pos) {
+		return NULL;
+	}
+
+	memset(&msg, 0, sizeof(msg));
+	msg.operation = ROSE_ETSI_ChargingRequest;
+	msg.invoke_id = get_invokeid(ctrl);
+
+	switch (aoc_request->charging_request) {
+		case PRI_AOC_REQUEST_S:
+			msg.args.etsi.ChargingRequest.charging_case = 0;
+			break;
+		case PRI_AOC_REQUEST_D:
+			msg.args.etsi.ChargingRequest.charging_case = 1;
+			break;
+		case PRI_AOC_REQUEST_E:
+			msg.args.etsi.ChargingRequest.charging_case = 2;
+			break;
+		default:
+			/* no valid request parameters are present */
+			return NULL;
+	}
+
+	pos = rose_encode_invoke(ctrl, pos, end, &msg);
+
+	return pos;
+}
+
+
+/*!
+ * \internal
  * \brief Send the ETSI AOCE invoke message.
  *
  * \param ctrl D channel controller for diagnostic messages or global options.
@@ -955,7 +1039,7 @@
 	 * have to explicitly send the facility message ourselves */
 	if (pri_call_apdu_queue(call, Q931_FACILITY, buffer, end - buffer, NULL)
 		|| q931_facility(call->pri, call)) {
-		pri_message(ctrl, "Could not schedule aoce charging unit facility message for call %d\n", call->cr);
+		pri_message(ctrl, "Could not schedule aoc-e facility message for call %d\n", call->cr);
 		return -1;
 	}
 
@@ -998,7 +1082,58 @@
 	 * have to explicitly send the facility message ourselves */
 	if (pri_call_apdu_queue(call, Q931_FACILITY, buffer, end - buffer, NULL)
 		|| q931_facility(call->pri, call)) {
-		pri_message(ctrl, "Could not schedule aoce charging unit facility message for call %d\n", call->cr);
+		pri_message(ctrl, "Could not schedule aoc-d facility message for call %d\n", call->cr);
+		return -1;
+	}
+
+	return 0;
+}
+
+/*!
+ * \internal
+ * \brief Send the ETSI AOC Request invoke message.
+ *
+ * \param ctrl D channel controller for diagnostic messages or global options.
+ * \param call Call leg from which to encode AOC.
+ * \param aoc_request, the aoc charging request payload data to encode.
+ *
+ * \retval 0 on success.
+ * \retval -1 on error.
+ */
+static int aoc_charging_request_encode(struct pri *ctrl, q931_call *call, const struct pri_subcmd_aoc_request *aoc_request)
+{
+	unsigned char buffer[255];
+	unsigned char *end = 0;
+
+	end = enc_etsi_aoc_request(ctrl, buffer, buffer + sizeof(buffer), aoc_request);
+
+	if (!end) {
+		return -1;
+	}
+
+	/* Remember that if we queue a facility IE for a facility message we
+	 * have to explicitly send the facility message ourselves */
+	if (pri_call_apdu_queue(call, Q931_FACILITY, buffer, end - buffer, NULL)
+		|| q931_facility(call->pri, call)) {
+		pri_message(ctrl, "Could not schedule aoc charging request facility message for call %d\n", call->cr);
+		return -1;
+	}
+
+	return 0;
+}
+
+int pri_aoc_charging_request_send(struct pri *ctrl, q931_call *call, const struct pri_subcmd_aoc_request *aoc_request)
+{
+	if (!ctrl || !call)
+		return -1;
+
+	switch (ctrl->switchtype) {
+	case PRI_SWITCH_EUROISDN_E1:
+	case PRI_SWITCH_EUROISDN_T1:
+		return aoc_charging_request_encode(ctrl, call, aoc_request);
+	case PRI_SWITCH_QSIG:
+		break;
+	default:
 		return -1;
 	}
 

Modified: team/dvossel/aoc_send/pri_facility.c
URL: http://svnview.digium.com/svn/libpri/team/dvossel/aoc_send/pri_facility.c?view=diff&rev=1562&r1=1561&r2=1562
==============================================================================
--- team/dvossel/aoc_send/pri_facility.c (original)
+++ team/dvossel/aoc_send/pri_facility.c Mon Mar 22 10:58:57 2010
@@ -4052,7 +4052,7 @@
 		}
 		break;
 	case ROSE_ETSI_ChargingRequest:
-		/* Ignore messsage */
+		aoc_etsi_aoc_request(ctrl, invoke);
 		break;
 	case ROSE_ETSI_AOCSCurrency:
 		aoc_etsi_aoc_s_currency(ctrl, invoke);

Modified: team/dvossel/aoc_send/pri_facility.h
URL: http://svnview.digium.com/svn/libpri/team/dvossel/aoc_send/pri_facility.h?view=diff&rev=1562&r1=1561&r2=1562
==============================================================================
--- team/dvossel/aoc_send/pri_facility.h (original)
+++ team/dvossel/aoc_send/pri_facility.h Mon Mar 22 10:58:57 2010
@@ -245,6 +245,7 @@
 void pri_cc_qsig_cancel(struct pri *ctrl, q931_call *call, int msgtype, const struct rose_msg_invoke *invoke);
 void pri_cc_qsig_exec_possible(struct pri *ctrl, q931_call *call, int msgtype, const struct rose_msg_invoke *invoke);
 
+void aoc_etsi_aoc_request(struct pri *ctrl, const struct rose_msg_invoke *invoke);
 void aoc_etsi_aoc_s_currency(struct pri *ctrl, const struct rose_msg_invoke *invoke);
 void aoc_etsi_aoc_s_special_arrangement(struct pri *ctrl, const struct rose_msg_invoke *invoke);
 void aoc_etsi_aoc_d_currency(struct pri *ctrl, const struct rose_msg_invoke *invoke);




More information about the libpri-commits mailing list