[svn-commits] dvossel: branch dvossel/aoc_send r1569 - /team/dvossel/aoc_send/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Mar 23 14:34:24 CDT 2010


Author: dvossel
Date: Tue Mar 23 14:34:21 2010
New Revision: 1569

URL: http://svnview.digium.com/svn/libpri?view=rev&rev=1569
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=1569&r1=1568&r2=1569
==============================================================================
--- team/dvossel/aoc_send/libpri.h (original)
+++ team/dvossel/aoc_send/libpri.h Tue Mar 23 14:34:21 2010
@@ -543,6 +543,7 @@
 #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 */
+#define PRI_SUBCMD_AOC_CHARGING_REQUEST_RESPONSE	22	/*!< Advice Of Charge Request Response information */
 
 #if defined(STATUS_REQUEST_PLACE_HOLDER)
 struct pri_subcmd_status_request {
@@ -653,8 +654,17 @@
 };
 
 enum PRI_AOC_REQUEST_RESPONSE {
-	PRI_AOC_REQUEST_RESPONSE_NOT_IMPLEMENTED,
-	PRI_AOC_REQUEST_RESPONSE_NOT_AVAILABLE,
+
+	/* Error Results */
+	PRI_AOC_REQUEST_RESPONSE_ERROR_NOT_IMPLEMENTED,
+	PRI_AOC_REQUEST_RESPONSE_ERROR_NOT_AVAILABLE,
+	PRI_AOC_REQUEST_RESPONSE_ERROR_TIMEOUT,
+	/* generic error result all other errors are lumped into */
+	PRI_AOC_REQUEST_RESPONSE_ERROR,
+
+	/* AOC Results */
+	PRI_AOC_REQUEST_RESPONSE_CURRENCY_INFO_LIST,
+	PRI_AOC_REQUEST_RESPONSE_SPECIAL_ARG,
 	PRI_AOC_REQUEST_RESPONSE_CHARGING_INFO_FOLLOWS,
 };
 
@@ -664,6 +674,21 @@
 	PRI_AOC_REQUEST_E,
 };
 
+struct pri_subcmd_aoc_request_response {
+	/*!
+	 * \brief What type of aoc was requested.
+	 * \see enum PRI_AOC_REQUEST
+	 */
+	int charging_request;
+
+	/*!
+	 * \brief response to the charging_request
+	 * \see enum PRI_AOC_REQUEST_RESPONSE
+	 */
+	int charging_response;
+
+};
+
 struct pri_subcmd_aoc_request {
 	/*!
 	 * \brief What types of aoc are being requested.
@@ -674,7 +699,7 @@
 	/*!
 	 * \brief Value given by the initiating request.
 	 */
-	 unsigned int invoke_id;
+	 int invoke_id;
 };
 
 /*! \brief What is being charged. */
@@ -904,6 +929,7 @@
 		struct pri_subcmd_cc_cancel cc_cancel;
 		struct pri_subcmd_transfer transfer;
 		struct pri_subcmd_aoc_request aoc_request;
+		struct pri_subcmd_aoc_request_response aoc_request_response;
 		struct pri_subcmd_aoc_s aoc_s;
 		struct pri_subcmd_aoc_d aoc_d;
 		struct pri_subcmd_aoc_e aoc_e;

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=1569&r1=1568&r2=1569
==============================================================================
--- team/dvossel/aoc_send/pri_aoc.c (original)
+++ team/dvossel/aoc_send/pri_aoc.c Tue Mar 23 14:34:21 2010
@@ -970,10 +970,10 @@
  * \retval NULL on error.
  */
 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;
+	unsigned char *end, int response, int invoke_id)
+{
+	struct rose_msg_result msg_result = { 0, };
+	struct rose_msg_error msg_error = { 0, };
 	int is_error = 0;
 	pos = facility_encode_header(ctrl, pos, end, NULL);
 	if (!pos) {
@@ -981,23 +981,26 @@
 	}
 
 	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;
+	case PRI_AOC_REQUEST_RESPONSE_CURRENCY_INFO_LIST:
+		msg_result.args.etsi.ChargingRequest.type = 0;
+		break;
+	case PRI_AOC_REQUEST_RESPONSE_SPECIAL_ARG:
+		msg_result.args.etsi.ChargingRequest.type = 1;
+		break;
+	case PRI_AOC_REQUEST_RESPONSE_CHARGING_INFO_FOLLOWS:
+		msg_result.args.etsi.ChargingRequest.type = 2;
+		break;
+	case PRI_AOC_REQUEST_RESPONSE_ERROR_NOT_IMPLEMENTED:
+		msg_error.code = ROSE_ERROR_Gen_NotImplemented;
+		is_error = 1;
+		break;
+	case PRI_AOC_REQUEST_RESPONSE_ERROR:
+	case PRI_AOC_REQUEST_RESPONSE_ERROR_NOT_AVAILABLE:
+	case PRI_AOC_REQUEST_RESPONSE_ERROR_TIMEOUT:
+	default:
+		is_error = 1;
+		msg_error.code = ROSE_ERROR_Gen_NotAvailable;
+		break;
 	}
 
 	if (is_error) {
@@ -1093,6 +1096,68 @@
 
 }
 
+
+static int pri_aoc_request_get_response(enum APDU_CALLBACK_REASON reason, struct pri *ctrl, struct q931_call *call, struct apdu_event *apdu, const struct apdu_msg_data *msg)
+{
+	struct pri_subcommand *subcmd;
+	struct pri_subcmd_aoc_request *aoc_request;
+	int errorcode;
+
+	if (!PRI_MASTER(ctrl)->aoc_support) {
+		return -1;
+	}
+
+	subcmd = q931_alloc_subcommand(ctrl);
+	if (!subcmd) {
+		return -1;
+	}
+
+	aoc_request = apdu->response.user.ptr;
+	subcmd->u.aoc_request_response.charging_request = aoc_request->charging_request;
+	subcmd->cmd = PRI_SUBCMD_AOC_CHARGING_REQUEST_RESPONSE;
+
+	switch (reason) {
+	case APDU_CALLBACK_REASON_ERROR:
+		errorcode = msg->response.error->code;
+		switch (errorcode) {
+		case ROSE_ERROR_Gen_NotImplemented:
+			subcmd->u.aoc_request_response.charging_response = PRI_AOC_REQUEST_RESPONSE_ERROR_NOT_IMPLEMENTED;
+			break;
+		case ROSE_ERROR_Gen_NotAvailable:
+			subcmd->u.aoc_request_response.charging_response = PRI_AOC_REQUEST_RESPONSE_ERROR_NOT_AVAILABLE;
+			break;
+		default:
+			subcmd->u.aoc_request_response.charging_response = PRI_AOC_REQUEST_RESPONSE_ERROR;
+			break;
+		}
+		break;
+	case APDU_CALLBACK_REASON_TIMEOUT:
+		subcmd->u.aoc_request_response.charging_response = PRI_AOC_REQUEST_RESPONSE_ERROR_TIMEOUT;
+		break;
+	case APDU_CALLBACK_REASON_MSG_RESULT:
+		switch (msg->response.result->args.etsi.ChargingRequest.type) {
+		case 0:
+			subcmd->u.aoc_request_response.charging_response = PRI_AOC_REQUEST_RESPONSE_CURRENCY_INFO_LIST;
+			break;
+		case 1:
+			subcmd->u.aoc_request_response.charging_response = PRI_AOC_REQUEST_RESPONSE_SPECIAL_ARG;
+			break;
+		case 2:
+			subcmd->u.aoc_request_response.charging_response = PRI_AOC_REQUEST_RESPONSE_CHARGING_INFO_FOLLOWS;
+			break;
+		default:
+			subcmd->u.aoc_request_response.charging_response = PRI_AOC_REQUEST_RESPONSE_ERROR;
+			break;
+		}
+		break;
+	default:
+		subcmd->u.aoc_request_response.charging_response = PRI_AOC_REQUEST_RESPONSE_ERROR;
+		break;
+	}
+
+	return 0;
+}
+
 /*!
  * \internal
  * \brief Send the ETSI AOC Request invoke message.
@@ -1108,16 +1173,23 @@
 {
 	unsigned char buffer[255];
 	unsigned char *end = 0;
+	struct apdu_callback_data response;
 
 	end = enc_etsi_aoc_request(ctrl, buffer, buffer + sizeof(buffer), aoc_request);
 
 	if (!end) {
 		return -1;
 	}
+
+	memset(&response, 0, sizeof(response));
+	response.invoke_id = ctrl->last_invoke;
+	response.timeout_time = ctrl->timers[PRI_TIMER_T_CCBS1];
+	response.callback = pri_aoc_request_get_response;
+	response.user.ptr = (void *) aoc_request;
 
 	/* in the case of an AOC request message, we queue this on a SETUP message and
 	 * do not have to send it ourselves in this function */
-	return pri_call_apdu_queue(call, Q931_SETUP, buffer, end - buffer, NULL); /*TODO change NULL to callback function to handle reply */
+	return pri_call_apdu_queue(call, Q931_SETUP, buffer, end - buffer, &response);
 }
 
 /*!




More information about the svn-commits mailing list