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

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Mar 8 15:25:44 CST 2010


Author: dvossel
Date: Mon Mar  8 15:25:41 2010
New Revision: 251395

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=251395
Log:
addition of api documentation

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=251395&r1=251394&r2=251395
==============================================================================
--- team/group/aoc/include/asterisk/aoc.h (original)
+++ team/group/aoc/include/asterisk/aoc.h Mon Mar  8 15:25:41 2010
@@ -83,7 +83,6 @@
 	unsigned char data[0];
 };
 
-
 /* Decoded AOC data */
 struct ast_aoc_decoded {
 	enum ast_aoc_type msg_type;
@@ -94,7 +93,7 @@
 	/* currency information */
 	enum ast_aoc_currency_multiplier multiplier;
 	unsigned int currency_amount;
-	char name[10+1];
+	char currency_name[10+1];
 
 	/* unit information */
 	unsigned int unit_amount;
@@ -109,49 +108,127 @@
 };
 
 
-/* \brief creates a ast_aoc_decode object of a specific message type */
-struct ast_aoc_decoded *ast_aoc_create(const enum ast_aoc_type msg_type);
-
+/* \brief creates a ast_aoc_decode object of a specific message type
+ *
+ * \param message type AOC-D, AOC-E, or AOC Request
+ * \param charge type, this is ignored if message type is not
+ *        AOC-D or AOC-E.
+ * \param requests flags.  This defines the types of AOC requested. This
+ *        field should only be set when the message type is AOC Request,
+ *        the value is ignored otherwise.
+ *
+ * \retval heap allocated ast_aoc_decoded object ptr on success
+ * \retval NULL failure
+ */
+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);
+
+/* \brief decodes an encoded aoc payload.
+ *
+ * \param ast_aoc_encoded, the encoded payload to decode.
+ *
+ * \retval heap allocated ast_aoc_decoded object ptr on success
+ * \retval NULL failure
+ */
 struct ast_aoc_decoded *ast_aoc_decode(struct ast_aoc_encoded *encoded);
 
+/* \brief encodes a decoded aoc structure so it can be passed on the wire
+ *
+ * \param ast_aoc_decoded structe to be encoded
+ *
+ * \retval heap allocated ast_aoc_encoded object ptr on success
+ * \retval NULL failure
+ */
 struct ast_aoc_encoded *ast_aoc_encode(struct ast_aoc_decoded *decoded);
 
-
-/* get set functions */
+/* \brief Sets the type of total for a AOC-D message
+ *
+ * \param total type, TOTAL or SUBTOTAL
+ *
+ * \retval 0 success
+ */
+int ast_aoc_set_total_type(struct ast_aoc_decoded *decoded, const enum ast_aoc_total_type type);
+
+/* \brief Sets the currency values for a AOC-D or AOC-E message
+ *
+ * \param ast_aoc_decoded struct to set values on
+ * \param currency amount REQUIRED
+ * \param currency multiplier REQUIRED
+ * \param currency name OPTIONAL
+ *
+ * \retval 0 success
+ */
+int ast_aoc_set_currency_info(struct ast_aoc_decoded *decoded,
+		const unsigned int amount,
+		const enum ast_aoc_currency_multiplier multiplier,
+		const char *name);
+
+/* \brief Adds a unit entry into the list of units
+ *
+ * \param ast_aoc_decoded struct to set values on
+ * \param number of units
+ * \param unit type
+ *
+ * \retval 0 success
+ */
+int ast_aoc_add_unit_entry(struct ast_aoc_decoded *decoded,
+		const unsigned int amount,
+		unsigned int type);
+
+/* \brief set the billing id for a AOC-D or AOC_E message
+ *
+ * \param ast_aoc_decoded struct to set values on
+ * \param billing id
+ *
+ * \retval 0 success
+ */
+int ast_aoc_set_billing_id(struct ast_aoc_decoded *decoded, const enum ast_aoc_billing_id id);
+
+/* \brief set the charging association id for an AOC_E message
+ *
+ * \param ast_aoc_decoded struct to set values on
+ * \param charging association identifier
+ *
+ * \retval 0 success
+ */
+int ast_aoc_set_association_id(struct ast_aoc_decoded *decoded, const int id);
+
+/* \brief set the charging accociation number for an AOC-E message
+ *
+ * \param ast_aoc_decoded struct to set values on
+ * \param charging association number
+ *
+ * \retval 0 success
+ */
+int ast_aoc_set_association_number(struct ast_aoc_decoded *decoded, const char *num);
+
+/* \brief get the message type, AOC-D, AOC-E, or AOC Request */
 enum ast_aoc_type ast_aoc_get_msg_type(struct ast_aoc_decoded *decoded);
 
-int ast_aoc_set_request(struct ast_aoc_decoded *decode, const enum ast_aoc_request);
-enum ast_aoc_request ast_aoc_get_request(struct ast_aoc_decoded *decode);
-
-int ast_aoc_set_total_type(struct ast_aoc_decoded *decode, const enum ast_aoc_total_type);
-enum ast_aoc_total_type ast_aoc_get_total_type(struct ast_aoc_decoded *decode);
-
-/* currency type */
-int ast_aoc_set_currency_amount(struct ast_aoc_decoded *decode, const unsigned int amount);
-unsigned int ast_aoc_get_currency_amount(struct ast_aoc_decoded *decode);
-
-int ast_aoc_set_currency_multiplier(struct ast_aoc_decoded *decode, const enum ast_aoc_currency_multiplier multiplier);
-enum ast_aoc_currency_multiplier ast_aoc_get_currency_multiplier(struct ast_aoc_decoded *decode);
-
-int ast_aoc_set_currency_name(struct ast_aoc_decoded *decode, const char *name);
-const char *ast_aoc_get_currency_name(struct ast_aoc_decoded *decode);
-
-/* unit type */
-int ast_aoc_set_unit_amount(struct ast_aoc_decoded *decode, const unsigned int amount);
-unsigned int ast_aoc_get_unit_amount(struct ast_aoc_decoded *decode);
-
-int ast_aoc_set_unit_type(struct ast_aoc_decoded *decode, unsigned int);
-unsigned int ast_aoc_get_unit_type(struct ast_aoc_decoded *decode);
-
-/* billing id */
-int ast_aoc_set_billing_id(struct ast_aoc_decoded *decode, const enum ast_aoc_billing_id id);
-enum ast_aoc_billing_id ast_aoc_get_billing_id(struct ast_aoc_decoded *decode);
-
-/* charging association */
-int ast_aoc_set_association_id(struct ast_aoc_decoded *decode, const int id);
-int ast_aoc_get_association_id(struct ast_aoc_decoded *decode);
-
-int ast_aoc_set_association_number(struct ast_aoc_decoded *decode, const char *num);
-char *ast_aoc_get_association_number(struct ast_aoc_decoded *decode);
+/* \brief get the types of AOC requested for when message type is AOC Request */
+enum ast_aoc_request ast_aoc_get_request(struct ast_aoc_decoded *decoded);
+
+/* \brief get the type of total for a AOC-D message */
+enum ast_aoc_total_type ast_aoc_get_total_type(struct ast_aoc_decoded *decoded);
+
+/* \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 currency multiplier for AOC-D and AOC-E messages*/
+enum ast_aoc_currency_multiplier ast_aoc_get_currency_multiplier(struct ast_aoc_decoded *decoded);
+
+/* \brief get the currency name for AOC-D and AOC-E messages*/
+const char *ast_aoc_get_currency_name(struct ast_aoc_decoded *decoded);
+
+/* \brief get the billing id for AOC-D and AOC-E messages*/
+enum ast_aoc_billing_id ast_aoc_get_billing_id(struct ast_aoc_decoded *decoded);
+
+/* \brief get the charging association id for AOC-E messages*/
+int ast_aoc_get_association_id(struct ast_aoc_decoded *decoded);
+
+/* \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=251395&r1=251394&r2=251395
==============================================================================
--- team/group/aoc/main/aoc.c (original)
+++ team/group/aoc/main/aoc.c Mon Mar  8 15:25:41 2010
@@ -26,6 +26,7 @@
 #include "asterisk.h"
 #include "asterisk/aoc.h"
 #include "asterisk/utils.h"
+#include "asterisk/strings.h"
 
 ASTERISK_FILE_VERSION(__FILE__, "$Revision$");
 
@@ -90,12 +91,20 @@
 
 
 
-struct ast_aoc_decoded *ast_aoc_create(const enum ast_aoc_type msg_type)
-{
-	struct ast_aoc_decoded *decoded = ast_calloc(1, sizeof(struct ast_aoc_decoded));
-
-	if (!decoded) {
+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)
+{
+	struct ast_aoc_decoded *decoded = NULL;
+
+	if (!(decoded = ast_calloc(1, sizeof(struct ast_aoc_decoded)))) {
 		ast_log(LOG_WARNING, "Failed to create ast_aoc_decoded object \n");
+	}
+
+	if (msg_type == AOC_REQUEST) {
+		decoded->request_flag = requests;
+	} else if ((msg_type == AOC_D) || (msg_type == AOC_E)) {
+		decoded->charge_type = charge_type;
 	}
 
 	return decoded;
@@ -113,8 +122,6 @@
 //todohere actually decode the encoded msg 
 
 	return decoded;
-
-
 }
 
 struct ast_aoc_encoded *ast_aoc_encode(struct ast_aoc_decoded *decoded)
@@ -129,10 +136,112 @@
 //todohere actually encode a msg 
 
 	return encoded;
-
-
-
-}
-
-
-
+}
+
+enum ast_aoc_type ast_aoc_get_msg_type(struct ast_aoc_decoded *decoded)
+{
+	return decoded->msg_type;
+}
+
+enum ast_aoc_request ast_aoc_get_request(struct ast_aoc_decoded *decoded)
+{
+	return decoded->request_flag;
+}
+
+int ast_aoc_set_total_type(struct ast_aoc_decoded *decoded,
+	const enum ast_aoc_total_type type)
+{
+	decoded->total_type = type;
+	return 0;
+}
+
+enum ast_aoc_total_type ast_aoc_get_total_type(struct ast_aoc_decoded *decoded)
+{
+	return decoded->total_type;
+}
+
+int ast_aoc_set_currency_info(struct ast_aoc_decoded *decoded,
+		const unsigned int amount,
+		const enum ast_aoc_currency_multiplier multiplier,
+		const char *name)
+{
+
+	if (!ast_strlen_zero(name)) {
+		ast_copy_string(decoded->currency_name,
+			name,
+			sizeof(decoded->currency_name));
+	}
+
+	decoded->currency_amount = amount;
+	decoded->multiplier = multiplier;
+
+	return 0;
+
+}
+
+unsigned int ast_aoc_get_currency_amount(struct ast_aoc_decoded *decoded)
+{
+	return decoded->currency_amount;
+}
+
+enum ast_aoc_currency_multiplier ast_aoc_get_currency_multiplier(struct ast_aoc_decoded *decoded)
+{
+	return decoded->multiplier;
+}
+
+const char *ast_aoc_get_currency_name(struct ast_aoc_decoded *decoded)
+{
+	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 */
+int ast_aoc_set_billing_id(struct ast_aoc_decoded *decoded, const enum ast_aoc_billing_id id)
+{
+	decoded->billing_id = id;
+	return 0;
+}
+
+enum ast_aoc_billing_id ast_aoc_get_billing_id(struct ast_aoc_decoded *decoded)
+{
+	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;
+}
+
+int ast_aoc_set_association_number(struct ast_aoc_decoded *decoded, const char *num)
+{
+	if (ast_strlen_zero(num)) {
+		return -1;
+	}
+
+	ast_copy_string(decoded->charging_association_number,
+		num,
+		sizeof(decoded->charging_association_number));
+	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