[asterisk-commits] dvossel: branch dvossel/generic_aoc r256486 - in /team/dvossel/generic_aoc: i...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Apr 9 09:49:54 CDT 2010


Author: dvossel
Date: Fri Apr  9 09:49:52 2010
New Revision: 256486

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=256486
Log:
addition of generic AOC request for AOC-E on termination

Modified:
    team/dvossel/generic_aoc/include/asterisk/aoc.h
    team/dvossel/generic_aoc/main/aoc.c
    team/dvossel/generic_aoc/tests/test_aoc.c

Modified: team/dvossel/generic_aoc/include/asterisk/aoc.h
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/generic_aoc/include/asterisk/aoc.h?view=diff&rev=256486&r1=256485&r2=256486
==============================================================================
--- team/dvossel/generic_aoc/include/asterisk/aoc.h (original)
+++ team/dvossel/generic_aoc/include/asterisk/aoc.h Fri Apr  9 09:49:52 2010
@@ -300,6 +300,18 @@
  */
 int ast_aoc_set_association_number(struct ast_aoc_decoded *decoded, const char *num, uint8_t plan);
 
+/*! \brief Mark the AST_AOC_REQUEST message as a termination request.
+ *
+ * \note a termination request indicates that the call has terminated, but that the other side is waiting
+ * for a short period of time before hanging up so it can get the final AOC-E message.
+ *
+ * \param ast_aoc_decoded struct to set values on
+ *
+ * \retval 0 success
+ * \retval -1 failure
+ */
+int ast_aoc_set_termination_request(struct ast_aoc_decoded *decoded);
+
 /*! \brief Add AOC-S duration rate entry
  *
  *  \param aoc decoded object to add entry to
@@ -476,6 +488,18 @@
 /*! \brief get the charging association number for AOC-E messages*/
 const char *ast_aoc_get_association_number(struct ast_aoc_decoded *decoded);
 
+/*! \brief get whether or not the AST_AOC_REQUEST message as a termination request.
+ *
+ * \note a termination request indicates that the call has terminated, but that the other side is waiting
+ * for a short period of time before hanging up so it can get the final AOC-E message.
+ *
+ * \param ast_aoc_decoded struct to get values on
+ *
+ * \retval 0 not a termination request
+ * \retval 1 is a termination request
+ */
+int ast_aoc_get_termination_request(struct ast_aoc_decoded *decoded);
+
 /*! \brief test aoc encode decode routines.
  * \note  This function verifies that a decoded message matches itself after
  *        the encode decode routine.

Modified: team/dvossel/generic_aoc/main/aoc.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/generic_aoc/main/aoc.c?view=diff&rev=256486&r1=256485&r2=256486
==============================================================================
--- team/dvossel/generic_aoc/main/aoc.c (original)
+++ team/dvossel/generic_aoc/main/aoc.c Fri Apr  9 09:49:52 2010
@@ -93,6 +93,9 @@
 	/* AOC-S charge information */
 	int aoc_s_count;
 	struct ast_aoc_s_entry aoc_s_entries[10];
+
+	/* Is this an AOC Termination Request */
+	char termination_request;
 };
 
 struct aoc_pl_ie_hdr {
@@ -131,6 +134,8 @@
 struct aoc_ie_charging_rate {
 	struct ast_aoc_s_entry entry;
 };
+
+#define AOC_IE_TERMINATION_REQUEST 6
 
 struct ast_aoc_decoded *ast_aoc_create(const enum ast_aoc_type msg_type,
 		const enum ast_aoc_charge_type charge_type,
@@ -288,6 +293,12 @@
 				ast_log(LOG_WARNING, "Recieved invalid charging rate ie\n");
 			}
 			break;
+		case AOC_IE_TERMINATION_REQUEST:
+			if (len == 0) {
+				decoded->termination_request = 1;
+			} else {
+				ast_log(LOG_WARNING, "Recieved invalid termination request ie\n");
+			}
 		default:
 			ast_log(LOG_WARNING, "Unknown AOC Information Element, ignoring.\n");
 		}
@@ -379,8 +390,10 @@
 	}
 	ied->buf[ied->pos++] = ie_id;
 	ied->buf[ied->pos++] = datalen;
-	memcpy(ied->buf + ied->pos, data, datalen);
-	ied->pos += datalen;
+	if (datalen) {
+		memcpy(ied->buf + ied->pos, data, datalen);
+		ied->pos += datalen;
+	}
 	return 0;
 }
 
@@ -482,6 +495,10 @@
 			aoc_create_ie_data_charging_rate(&decoded->aoc_s_entries[i], &ie);
 			aoc_append_ie(ied, AOC_IE_RATE, (const void *) &ie, sizeof(ie));
 		}
+	}
+
+	if (decoded->termination_request) {
+		aoc_append_ie(ied, AOC_IE_TERMINATION_REQUEST, NULL, 0);
 	}
 }
 
@@ -888,6 +905,22 @@
 unsigned short ast_aoc_get_association_plan(struct ast_aoc_decoded *decoded)
 {
 	return decoded->charging_association_plan;
+}
+
+
+int ast_aoc_set_termination_request(struct ast_aoc_decoded *decoded)
+{
+	if (decoded->msg_type != AST_AOC_REQUEST) {
+		return -1;
+	}
+	decoded->termination_request = 1;
+
+	return 0;
+}
+
+int ast_aoc_get_termination_request(struct ast_aoc_decoded *decoded)
+{
+	return decoded->termination_request;
 }
 
 /*!

Modified: team/dvossel/generic_aoc/tests/test_aoc.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/generic_aoc/tests/test_aoc.c?view=diff&rev=256486&r1=256485&r2=256486
==============================================================================
--- team/dvossel/generic_aoc/tests/test_aoc.c (original)
+++ team/dvossel/generic_aoc/tests/test_aoc.c Fri Apr  9 09:49:52 2010
@@ -433,6 +433,7 @@
 		for (i = 0; i < ARRAY_LEN(request); i++) {
 			if (!(decoded = ast_aoc_create(AST_AOC_REQUEST, 0, request[i])) ||
 				(ast_aoc_get_msg_type(decoded) != AST_AOC_REQUEST) ||
+				(ast_aoc_get_termination_request(decoded)) ||
 				(ast_aoc_get_request(decoded) != request[i])) {
 
 				ast_test_status_update(test, "Test 3: failed to create AOC-Request message, iteration #%d\n", i);
@@ -449,6 +450,28 @@
 			/* cleanup decoded msg */
 			decoded = ast_aoc_destroy_decoded(decoded);
 		}
+
+
+		/* Test termination Request Type */
+		if (!(decoded = ast_aoc_create(AST_AOC_REQUEST, 0, AST_AOC_REQUEST_E)) ||
+			(ast_aoc_set_termination_request(decoded)) ||
+			(!ast_aoc_get_termination_request(decoded)) ||
+			(ast_aoc_get_msg_type(decoded) != AST_AOC_REQUEST) ||
+			(ast_aoc_get_request(decoded) != AST_AOC_REQUEST_E)) {
+
+			ast_test_status_update(test, "Test 3: failed to create AOC-Request message with Termination Request set\n");
+			res = AST_TEST_FAIL;
+			goto cleanup_aoc_test;
+		}
+
+		/* Encode the message */
+		if (ast_aoc_test_encode_decode_match(decoded)) {
+			ast_test_status_update(test, "Test3: encode decode routine did not match expected results with termination request set\n");
+			res = AST_TEST_FAIL;
+			goto cleanup_aoc_test;
+		}
+		/* cleanup decoded msg */
+		decoded = ast_aoc_destroy_decoded(decoded);
 	}
 
 	/* ---- Test 4 ----  Make stuff blow up */




More information about the asterisk-commits mailing list