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

SVN commits to the libpri project libpri-commits at lists.digium.com
Tue Mar 23 10:15:38 CDT 2010


Author: dvossel
Date: Tue Mar 23 10:15:34 2010
New Revision: 1567

URL: http://svnview.digium.com/svn/libpri?view=rev&rev=1567
Log:
aoc request response support

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

Modified: team/dvossel/aoc_send/libpri.h
URL: http://svnview.digium.com/svn/libpri/team/dvossel/aoc_send/libpri.h?view=diff&rev=1567&r1=1566&r2=1567
==============================================================================
--- team/dvossel/aoc_send/libpri.h (original)
+++ team/dvossel/aoc_send/libpri.h Tue Mar 23 10:15:34 2010
@@ -652,6 +652,12 @@
 	int invoke_id;
 };
 
+enum PRI_AOC_REQUEST_RESPONSE {
+	PRI_AOC_REQUEST_RESPONSE_NOT_IMPLEMENTED,
+	PRI_AOC_REQUEST_RESPONSE_NOT_AVAILABLE,
+	PRI_AOC_REQUEST_RESPONSE_CHARGING_INFO_FOLLOWS,
+};
+
 enum PRI_AOC_REQUEST {
 	PRI_AOC_REQUEST_S,
 	PRI_AOC_REQUEST_D,
@@ -664,6 +670,11 @@
 	 * \see enum PRI_AOC_REQUEST
 	 */
 	int charging_request;
+
+	/*!
+	 * \brief Value given by the initiating request.
+	 */
+	 unsigned int invoke_id;
 };
 
 /*! \brief What is being charged. */
@@ -1486,6 +1497,10 @@
 /* Request AOC on call setup */
 int pri_sr_set_aoc_charging_request(struct pri_sr *sr, int charging_request);
 
+
+/* Send AOC-Request message */
+int pri_aoc_charging_request_response(struct pri *ctrl, q931_call *call, int response, const struct pri_subcmd_aoc_request *aoc_request);
+
 /* Send AOC-Request message */
 int pri_aoc_charging_request_send(struct pri *ctrl, q931_call *c, const struct pri_subcmd_aoc_request *aoc_request);
 

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=1567&r1=1566&r2=1567
==============================================================================
--- team/dvossel/aoc_send/pri_aoc.c (original)
+++ team/dvossel/aoc_send/pri_aoc.c Tue Mar 23 10:15:34 2010
@@ -138,6 +138,7 @@
 
 	subcmd->cmd = PRI_SUBCMD_AOC_CHARGING_REQUEST;
 
+	subcmd->u.aoc_request.invoke_id = invoke->invoke_id;
 	switch (invoke->args.etsi.ChargingRequest.charging_case) {
 	case 0:
 		subcmd->u.aoc_request.charging_request = PRI_AOC_REQUEST_S;
@@ -958,7 +959,7 @@
 
 /*!
  * \internal
- * \brief Encode the ETSI ChargingRequest invoke message.
+ * \brief Encode the ETSI ChargingRequest Response message
  *
  * \param ctrl D channel controller for diagnostic messages or global options.
  * \param pos Starting position to encode the facility ie contents.
@@ -968,16 +969,71 @@
  * \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;
-
+static unsigned char *enc_etsi_aoc_request_response(struct pri *ctrl, unsigned char *pos,
+	unsigned char *end, int response, unsigned int invoke_id)
+{
+	struct rose_msg_result msg_result;
+	struct rose_msg_error msg_error;
+	int is_error = 0;
 	pos = facility_encode_header(ctrl, pos, end, NULL);
 	if (!pos) {
 		return NULL;
 	}
 
+	switch (response) {
+		case PRI_AOC_REQUEST_RESPONSE_NOT_IMPLEMENTED:
+			memset(&msg_error, 0, sizeof(msg_error));
+			is_error = 1;
+			msg_error.code = ROSE_ERROR_Gen_NotImplemented;
+			break;
+		case PRI_AOC_REQUEST_RESPONSE_NOT_AVAILABLE:
+			memset(&msg_error, 0, sizeof(msg_error));
+			msg_error.code = ROSE_ERROR_Gen_NotAvailable;
+			is_error = 1;
+			break;
+		case PRI_AOC_REQUEST_RESPONSE_CHARGING_INFO_FOLLOWS:
+			memset(&msg_result, 0, sizeof(msg_result));
+			msg_result.args.etsi.ChargingRequest.type = 0;
+			break;
+		default:
+			/* no valid request parameters are present */
+			return NULL;
+	}
+
+	if (is_error) {
+		msg_error.invoke_id = invoke_id;
+		pos = rose_encode_error(ctrl, pos, end, &msg_error);
+	} else {
+		msg_result.operation = ROSE_ETSI_ChargingRequest;
+		msg_result.invoke_id = invoke_id;
+		pos = rose_encode_result(ctrl, pos, end, &msg_result);
+	}
+
+	return pos;
+}
+
+/*!
+ * \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);
@@ -1000,6 +1056,41 @@
 	pos = rose_encode_invoke(ctrl, pos, end, &msg);
 
 	return pos;
+}
+
+/*!
+ * \internal
+ * \brief Send the ETSI AOC Request Response message.
+ *
+ * \param ctrl D channel controller for diagnostic messages or global options.
+ * \param call Call leg from which to encode AOC.
+ * \param response code
+ * \param invoke_id
+ *
+ * \retval 0 on success.
+ * \retval -1 on error.
+ */
+static int aoc_charging_request_response_encode(struct pri *ctrl, q931_call *call, int response, const struct pri_subcmd_aoc_request *aoc_request)
+{
+	unsigned char buffer[255];
+	unsigned char *end = 0;
+
+	end = enc_etsi_aoc_request_response(ctrl, buffer, buffer + sizeof(buffer), response, aoc_request->invoke_id);
+
+	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 request response facility message for call %d\n", call->cr);
+		return -1;
+	}
+
+	return 0;
+
 }
 
 /*!
@@ -1115,6 +1206,24 @@
 	return 0;
 }
 
+int pri_aoc_charging_request_response(struct pri *ctrl, q931_call *call, int response, 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_response_encode(ctrl, call, response, aoc_request);
+	case PRI_SWITCH_QSIG:
+		break;
+	default:
+		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)




More information about the libpri-commits mailing list