[svn-commits] dvossel: branch dvossel/generic_aoc r254887 - in /team/dvossel/generic_aoc: i...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Mar 25 16:52:02 CDT 2010


Author: dvossel
Date: Thu Mar 25 16:51:58 2010
New Revision: 254887

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=254887
Log:
addition of AOC-S generic representation

Modified:
    team/dvossel/generic_aoc/include/asterisk/aoc.h
    team/dvossel/generic_aoc/main/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=254887&r1=254886&r2=254887
==============================================================================
--- team/dvossel/generic_aoc/include/asterisk/aoc.h (original)
+++ team/dvossel/generic_aoc/include/asterisk/aoc.h Thu Mar 25 16:51:58 2010
@@ -25,6 +25,8 @@
 
 #ifndef _AST_AOC_H_
 #define _AST_AOC_H_
+
+#define AOC_CURRENCY_NAME_SIZE (10 + 1)
 
 /*! \brief Defines the currency multiplier for an aoc message. */
 enum ast_aoc_currency_multiplier {
@@ -56,7 +58,7 @@
 
 enum ast_aoc_type {
 	AST_AOC_REQUEST = 0,
-	/* AOC_S */  /* Reserved for AOC-S support */
+	AST_AOC_S,
 	AST_AOC_D,
 	AST_AOC_E, /* aoc-e must remain the last item in this enum */
 };
@@ -77,6 +79,97 @@
 enum ast_aoc_total_type {
 	AST_AOC_TOTAL = 0,
 	AST_AOC_SUBTOTAL = 1,
+};
+
+enum ast_aoc_time_scale {
+	AST_AOC_TIME_SCALE_HUNDREDTH_SECOND,
+	AST_AOC_TIME_SCALE_TENTH_SECOND,
+	AST_AOC_TIME_SCALE_SECOND,
+	AST_AOC_TIME_SCALE_TEN_SECOND,
+	AST_AOC_TIME_SCALE_MINUTE,
+	AST_AOC_TIME_SCALE_HOUR,
+	AST_AOC_TIME_SCALE_DAY,
+};
+
+struct ast_aoc_time {
+	/*! LengthOfTimeUnit (Not valid if length is zero.) */
+	unsigned long length;
+	enum ast_aoc_time_scale scale;
+};
+
+struct ast_aoc_duration_rate {
+	enum ast_aoc_currency_multiplier multiplier;
+	unsigned int amount;
+
+	unsigned long time;
+	enum ast_aoc_time_scale time_scale;
+
+	/*! Not present if the granularity time is zero. */
+	unsigned long granularity_time;
+	enum ast_aoc_time_scale granularity_time_scale;
+
+	/*!
+	 * \brief Charging interval type
+	 * \details
+	 * continuousCharging(0),
+	 * stepFunction(1)
+	 */
+	uint8_t charging_type;
+	/*! Name of currency involved.  Null terminated. */
+	char currency_name[AOC_CURRENCY_NAME_SIZE];
+};
+
+enum ast_aoc_volume_unit {
+	AST_AOC_VOLUME_UNIT_OCTET,
+	AST_AOC_VOLUME_UNIT_SEGMENT,
+	AST_AOC_VOLUME_UNIT_MESSAGE,
+};
+
+struct ast_aoc_volume_rate {
+	enum ast_aoc_currency_multiplier multiplier;
+	unsigned int amount;
+	enum ast_aoc_volume_unit unit;
+	char currency_name[AOC_CURRENCY_NAME_SIZE];
+};
+
+struct ast_aoc_flat_rate {
+	enum ast_aoc_currency_multiplier multiplier;
+	unsigned int amount;
+
+	/*! Name of currency involved.  Null terminated. */
+	char currency_name[AOC_CURRENCY_NAME_SIZE];
+};
+
+enum ast_aoc_s_charged_item {
+	AST_AOC_CHARGED_ITEM_NA,
+	AST_AOC_CHARGED_ITEM_SPECIAL_ARRANGEMENT,
+	AST_AOC_CHARGED_ITEM_BASIC_COMMUNICATION,
+	AST_AOC_CHARGED_ITEM_CALL_ATTEMPT,
+	AST_AOC_CHARGED_ITEM_CALL_SETUP,
+	AST_AOC_CHARGED_ITEM_USER_USER_INFO,
+	AST_AOC_CHARGED_ITEM_SUPPLEMENTARY_SERVICE,
+};
+
+enum ast_aoc_s_rate_type {
+	AST_AOC_RATE_TYPE_NA,
+	AST_AOC_RATE_TYPE_FREE,
+	AST_AOC_RATE_TYPE_DURATION,
+	AST_AOC_RATE_TYPE_FLAT,
+	AST_AOC_RATE_TYPE_VOLUME,
+	AST_AOC_RATE_TYPE_SPECIAL_CODE,
+};
+struct ast_aoc_s_entry {
+	enum ast_aoc_s_charged_item charged_item;
+
+	enum ast_aoc_s_rate_type rate_type;
+
+	/*! \brief Charge rate being applied. */
+	union {
+		struct ast_aoc_duration_rate duration;
+		struct ast_aoc_flat_rate flat;
+		struct ast_aoc_volume_rate volume;
+		unsigned int special_code; /* 1...10 */
+	} rate;
 };
 
 struct ast_aoc_unit_entry {
@@ -204,6 +297,43 @@
  */
 int ast_aoc_set_association_number(struct ast_aoc_decoded *decoded, const char *num, uint8_t plan);
 
+int ast_aoc_s_add_rate_duration(struct ast_aoc_decoded *decoded,
+	enum ast_aoc_s_charged_item charged_item,
+	unsigned int amount,
+	enum ast_aoc_currency_multiplier multiplier,
+	unsigned long time,
+	enum ast_aoc_time_scale time_scale,
+	unsigned long granularity_time,
+	enum ast_aoc_time_scale granularity_time_scale,
+	int step_function,
+	const char *currency_name);
+
+int ast_aoc_s_add_rate_flat(struct ast_aoc_decoded *decoded,
+	enum ast_aoc_s_charged_item charged_item,
+	unsigned int amount,
+	enum ast_aoc_currency_multiplier multiplier,
+	const char *currency_name);
+
+int ast_aoc_s_add_rate_volume(struct ast_aoc_decoded *decoded,
+	enum ast_aoc_s_charged_item charged_item,
+	enum ast_aoc_volume_unit volume_unit,
+	unsigned int amount,
+	enum ast_aoc_currency_multiplier multiplier,
+	const char *currency_name);
+
+int ast_aoc_s_add_rate_special_charge_code(struct ast_aoc_decoded *decoded,
+	enum ast_aoc_s_charged_item charged_item,
+	unsigned int code);
+
+int ast_aoc_s_add_rate_free(struct ast_aoc_decoded *decoded,
+	enum ast_aoc_s_charged_item charged_item);
+
+int ast_aoc_s_add_rate_na(struct ast_aoc_decoded *decoded,
+	enum ast_aoc_s_charged_item charged_item);
+
+int ast_aoc_s_add_special_arrangement(struct ast_aoc_decoded *decoded,
+	unsigned int code);
+
 /*! \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);
 

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=254887&r1=254886&r2=254887
==============================================================================
--- team/dvossel/generic_aoc/main/aoc.c (original)
+++ team/dvossel/generic_aoc/main/aoc.c Thu Mar 25 16:51:58 2010
@@ -52,7 +52,6 @@
 
 #define AST_AOC_ENCODE_VERSION 1
 
-#define AOC_CURRENCY_NAME_SIZE (10 + 1)
 
 static char aoc_debug_enabled = 0;
 static void aoc_display_decoded(const struct ast_aoc_decoded *decoded, int decoding);
@@ -88,6 +87,11 @@
 	int charging_association_id;
 	uint8_t charging_association_plan;
 	char charging_association_number[32];
+
+
+	/* AOC-S charge information */
+	int aoc_s_count;
+	struct ast_aoc_s_entry aoc_s_entries[10];
 };
 
 struct aoc_pl_ie_hdr {
@@ -446,6 +450,135 @@
 	return encoded;
 }
 
+
+static int aoc_s_add_entry(struct ast_aoc_decoded *decoded, struct ast_aoc_s_entry *entry)
+{
+	if (decoded->aoc_s_count >= ARRAY_LEN(decoded->aoc_s_entries)) {
+		return -1;
+	}
+
+	memcpy(&decoded->aoc_s_entries[decoded->aoc_s_count], entry, sizeof(decoded->aoc_s_entries[decoded->aoc_s_count]));
+	decoded->aoc_s_count++;
+
+	return 0;
+}
+
+int ast_aoc_s_add_rate_duration(struct ast_aoc_decoded *decoded,
+	enum ast_aoc_s_charged_item charged_item,
+	unsigned int amount,
+	enum ast_aoc_currency_multiplier multiplier,
+	unsigned long time,
+	enum ast_aoc_time_scale time_scale,
+	unsigned long granularity_time,
+	enum ast_aoc_time_scale granularity_time_scale,
+	int step_function,
+	const char *currency_name)
+{
+
+	struct ast_aoc_s_entry entry = { 0, };
+
+	entry.charged_item = charged_item;
+	entry.rate_type = AST_AOC_RATE_TYPE_DURATION;
+	entry.rate.duration.amount = amount;
+	entry.rate.duration.multiplier = multiplier;
+	entry.rate.duration.time = time;
+	entry.rate.duration.time_scale = time_scale;
+	entry.rate.duration.granularity_time = granularity_time;
+	entry.rate.duration.granularity_time_scale = granularity_time_scale;
+	entry.rate.duration.charging_type = step_function ? 1 : 0;
+
+	if (!ast_strlen_zero(currency_name)) {
+		ast_copy_string(entry.rate.duration.currency_name, currency_name, sizeof(entry.rate.duration.currency_name));
+	}
+
+	return aoc_s_add_entry(decoded, &entry);
+}
+
+int ast_aoc_s_add_rate_flat(struct ast_aoc_decoded *decoded,
+	enum ast_aoc_s_charged_item charged_item,
+	unsigned int amount,
+	enum ast_aoc_currency_multiplier multiplier,
+	const char *currency_name)
+{
+	struct ast_aoc_s_entry entry = { 0, };
+
+	entry.charged_item = charged_item;
+	entry.rate_type = AST_AOC_RATE_TYPE_FLAT;
+	entry.rate.flat.amount = amount;
+	entry.rate.flat.multiplier = multiplier;
+
+	if (!ast_strlen_zero(currency_name)) {
+		ast_copy_string(entry.rate.flat.currency_name, currency_name, sizeof(entry.rate.flat.currency_name));
+	}
+
+	return aoc_s_add_entry(decoded, &entry);
+}
+
+
+int ast_aoc_s_add_rate_volume(struct ast_aoc_decoded *decoded,
+	enum ast_aoc_s_charged_item charged_item,
+	enum ast_aoc_volume_unit volume_unit,
+	unsigned int amount,
+	enum ast_aoc_currency_multiplier multiplier,
+	const char *currency_name)
+{
+	struct ast_aoc_s_entry entry = { 0, };
+	entry.charged_item = charged_item;
+	entry.rate_type = AST_AOC_RATE_TYPE_VOLUME;
+	entry.rate.volume.multiplier = multiplier;
+	entry.rate.volume.amount = amount;
+	entry.rate.volume.unit = volume_unit;
+
+	if (!ast_strlen_zero(currency_name)) {
+		ast_copy_string(entry.rate.volume.currency_name, currency_name, sizeof(entry.rate.volume.currency_name));
+	}
+
+	return aoc_s_add_entry(decoded, &entry);
+}
+
+int ast_aoc_s_add_rate_special_charge_code(struct ast_aoc_decoded *decoded,
+	enum ast_aoc_s_charged_item charged_item,
+	unsigned int code)
+{
+	struct ast_aoc_s_entry entry = { 0, };
+	entry.charged_item = charged_item;
+	entry.rate_type = AST_AOC_RATE_TYPE_SPECIAL_CODE;
+	entry.rate.special_code = code;
+
+	return aoc_s_add_entry(decoded, &entry);
+}
+
+int ast_aoc_s_add_rate_free(struct ast_aoc_decoded *decoded,
+	enum ast_aoc_s_charged_item charged_item)
+{
+	struct ast_aoc_s_entry entry = { 0, };
+	entry.charged_item = charged_item;
+	entry.rate_type = AST_AOC_RATE_TYPE_FREE;
+
+	return aoc_s_add_entry(decoded, &entry);
+}
+
+int ast_aoc_s_add_rate_na(struct ast_aoc_decoded *decoded,
+	enum ast_aoc_s_charged_item charged_item)
+{
+	struct ast_aoc_s_entry entry = { 0, };
+	entry.charged_item = charged_item;
+	entry.rate_type = AST_AOC_RATE_TYPE_NA;
+
+	return aoc_s_add_entry(decoded, &entry);
+}
+
+int ast_aoc_s_add_special_arrangement(struct ast_aoc_decoded *decoded,
+	unsigned int code)
+{
+	struct ast_aoc_s_entry entry = { 0, };
+	entry.charged_item = AST_AOC_CHARGED_ITEM_SPECIAL_ARRANGEMENT;
+	entry.rate_type = AST_AOC_RATE_TYPE_SPECIAL_CODE;
+	entry.rate.special_code = code;
+
+	return aoc_s_add_entry(decoded, &entry);
+}
+
 enum ast_aoc_type ast_aoc_get_msg_type(struct ast_aoc_decoded *decoded)
 {
 	return decoded->msg_type;
@@ -626,7 +759,6 @@
 	case AST_AOC_CHARGE_UNIT:
 		return "Unit";
 	}
-
 	return "Unknown";
 }
 
@@ -651,7 +783,6 @@
 		break;
 	};
 	return "Unknown";
-
 }
 
 static const char *aoc_billingid_str(const struct ast_aoc_decoded *decoded)
@@ -685,6 +816,8 @@
 static const char *aoc_msg_type_str(const struct ast_aoc_decoded *decoded)
 {
 	switch (decoded->msg_type) {
+	case AST_AOC_S:
+		return "AOC-S";
 	case AST_AOC_D:
 		return "AOC-D";
 	case AST_AOC_E:
@@ -766,6 +899,9 @@
 	}
 
 	switch (decoded->msg_type) {
+	case AST_AOC_S:
+		/* TODO implement this */
+		break;
 	case AST_AOC_D:
 		aoc_display_decoded_aocd(decoded);
 		break;




More information about the svn-commits mailing list