[svn-commits] dvossel: branch group/aoc r251396 - in /team/group/aoc: include/asterisk/ main/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Mar 8 16:09:40 CST 2010


Author: dvossel
Date: Mon Mar  8 16:09:36 2010
New Revision: 251396

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=251396
Log:
api to handle creation and iteration of unit entry list

Modified:
    team/group/aoc/include/asterisk/aoc.h
    team/group/aoc/main/aoc.c

Modified: team/group/aoc/include/asterisk/aoc.h
URL: http://svnview.digium.com/svn/asterisk/team/group/aoc/include/asterisk/aoc.h?view=diff&rev=251396&r1=251395&r2=251396
==============================================================================
--- team/group/aoc/include/asterisk/aoc.h (original)
+++ team/group/aoc/include/asterisk/aoc.h Mon Mar  8 16:09:36 2010
@@ -83,6 +83,11 @@
 	unsigned char data[0];
 };
 
+struct ast_aoc_unit_entry {
+	unsigned int amount;
+	unsigned int type; /* 1 - 16 */
+};
+
 /* Decoded AOC data */
 struct ast_aoc_decoded {
 	enum ast_aoc_type msg_type;
@@ -96,8 +101,8 @@
 	char currency_name[10+1];
 
 	/* unit information */
-	unsigned int unit_amount;
-	unsigned int unit_type; /* 1 - 16 */
+	int unit_count;
+	struct ast_aoc_unit_entry unit_list[32];
 
 	/* Billing Id */
 	enum ast_aoc_billing_id billing_id;
@@ -144,6 +149,8 @@
 
 /* \brief Sets the type of total for a AOC-D message
  *
+ * \note If this value is not set, the default for the message is TOTAL 
+ *
  * \param total type, TOTAL or SUBTOTAL
  *
  * \retval 0 success
@@ -174,7 +181,7 @@
  */
 int ast_aoc_add_unit_entry(struct ast_aoc_decoded *decoded,
 		const unsigned int amount,
-		unsigned int type);
+		const unsigned int type);
 
 /* \brief set the billing id for a AOC-D or AOC_E message
  *
@@ -215,6 +222,15 @@
 /* \brief get the currency amount for AOC-D and AOC-E messages*/
 unsigned int ast_aoc_get_currency_amount(struct ast_aoc_decoded *decoded);
 
+/* \brief get the number of unit entries for AOC-D and AOC-E messages*/
+unsigned int ast_aoc_get_unit_count(struct ast_aoc_decoded *decoded);
+
+/* \brief get a specific unit entry.
+ * \note This can be used in conjunction with ast_aoc_get_unit_count to create
+ *       a unit entry iterator.
+ */
+const struct ast_aoc_unit_entry *ast_aoc_get_unit_info(struct ast_aoc_decoded *decoded, unsigned int entry_number);
+
 /* \brief get the currency multiplier for AOC-D and AOC-E messages*/
 enum ast_aoc_currency_multiplier ast_aoc_get_currency_multiplier(struct ast_aoc_decoded *decoded);
 
@@ -229,6 +245,4 @@
 
 /* \brief get the charging association number for AOC-E messages*/
 const char *ast_aoc_get_association_number(struct ast_aoc_decoded *decoded);
-
-
 #endif

Modified: team/group/aoc/main/aoc.c
URL: http://svnview.digium.com/svn/asterisk/team/group/aoc/main/aoc.c?view=diff&rev=251396&r1=251395&r2=251396
==============================================================================
--- team/group/aoc/main/aoc.c (original)
+++ team/group/aoc/main/aoc.c Mon Mar  8 16:09:36 2010
@@ -34,14 +34,14 @@
 
 
 /* Encoded Payload Flags */
-#define AOC_ENCODED_TYPE_REQUEST (0 << 0)
-#define AOC_ENCODED_TYPE_D       (1 << 0)
-#define AOC_ENCODED_TYPE_E       (2 << 0)
+#define AOC_ENCODED_TYPE_REQUEST    (0 << 0)
+#define AOC_ENCODED_TYPE_D          (1 << 0)
+#define AOC_ENCODED_TYPE_E          (2 << 0)
 /* #define AOC_PAYLOAD_TYPE_S (3 << 0)  This is not yet supported, but reserve this for future use */
 
-#define AOC_ENCODED_REQUEST_S    (1 << 2)
-#define AOC_ENCODED_REQUEST_D    (1 << 3)
-#define AOC_ENCODED_REQUEST_E    (1 << 4)
+#define AOC_ENCODED_REQUEST_S       (1 << 2)
+#define AOC_ENCODED_REQUEST_D       (1 << 3)
+#define AOC_ENCODED_REQUEST_E       (1 << 4)
 
 #define AOC_ENCODED_CHARGE_NA       (0 << 5) | (0 << 6)
 #define AOC_ENCODED_CHARGE_FREE     (1 << 5) | (0 << 6)
@@ -89,8 +89,6 @@
 
 };
 
-
-
 struct ast_aoc_decoded *ast_aoc_create(const enum ast_aoc_type msg_type,
 		const enum ast_aoc_charge_type charge_type,
 		const enum ast_aoc_request requests)
@@ -194,19 +192,36 @@
 	return decoded->currency_name;
 }
 
-
-/* unit info */
 int ast_aoc_add_unit_entry(struct ast_aoc_decoded *decoded,
 		const unsigned int amount,
-		unsigned int type)
-{
-	decoded->unit_amount = amount;
-	decoded->unit_type = type;
-
-	return 0;
-}
-
-/* billing id */
+		const unsigned int type)
+{
+	if ((decoded->msg_type == AOC_REQUEST) ||
+		(decoded->unit_count >= ARRAY_LEN(decoded->unit_list))) {
+		return -1;
+	}
+
+	decoded->unit_list[decoded->unit_count].amount = amount;
+	decoded->unit_list[decoded->unit_count].type = type;
+	decoded->unit_count++;
+
+	return 0;
+}
+
+const struct ast_aoc_unit_entry *ast_aoc_get_unit_info(struct ast_aoc_decoded *decoded, unsigned int entry_number)
+{
+	if (entry_number >= decoded->unit_count) {
+		return NULL;
+	}
+
+	return (const struct ast_aoc_unit_entry *) &decoded->unit_list[entry_number];
+}
+
+unsigned int ast_aoc_get_unit_count(struct ast_aoc_decoded *decoded)
+{
+	return decoded->unit_count;
+}
+
 int ast_aoc_set_billing_id(struct ast_aoc_decoded *decoded, const enum ast_aoc_billing_id id)
 {
 	decoded->billing_id = id;
@@ -218,12 +233,12 @@
 	return decoded->billing_id;
 }
 
-/* charging association */
 int ast_aoc_set_association_id(struct ast_aoc_decoded *decoded, const int id)
 {
 	decoded->charging_association_id = id;
 	return 0;
 }
+
 int ast_aoc_get_association_id(struct ast_aoc_decoded *decoded)
 {
 	return decoded->charging_association_id;
@@ -238,8 +253,10 @@
 	ast_copy_string(decoded->charging_association_number,
 		num,
 		sizeof(decoded->charging_association_number));
-	return 0;
-}
+
+	return 0;
+}
+
 const char *ast_aoc_get_association_number(struct ast_aoc_decoded *decoded)
 {
 	return decoded->charging_association_number;




More information about the svn-commits mailing list