00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef _AST_AOC_H_
00027 #define _AST_AOC_H_
00028
00029 #include "asterisk/channel.h"
00030
00031 #define AOC_CURRENCY_NAME_SIZE (10 + 1)
00032
00033
00034 enum ast_aoc_currency_multiplier {
00035 AST_AOC_MULT_ONETHOUSANDTH = 1,
00036 AST_AOC_MULT_ONEHUNDREDTH,
00037 AST_AOC_MULT_ONETENTH,
00038 AST_AOC_MULT_ONE,
00039 AST_AOC_MULT_TEN,
00040 AST_AOC_MULT_HUNDRED,
00041 AST_AOC_MULT_THOUSAND,
00042 AST_AOC_MULT_NUM_ENTRIES,
00043 };
00044
00045
00046
00047
00048
00049 enum ast_aoc_billing_id {
00050 AST_AOC_BILLING_NA = 0,
00051 AST_AOC_BILLING_NORMAL,
00052 AST_AOC_BILLING_REVERSE_CHARGE,
00053 AST_AOC_BILLING_CREDIT_CARD,
00054 AST_AOC_BILLING_CALL_FWD_UNCONDITIONAL,
00055 AST_AOC_BILLING_CALL_FWD_BUSY,
00056 AST_AOC_BILLING_CALL_FWD_NO_REPLY,
00057 AST_AOC_BILLING_CALL_DEFLECTION,
00058 AST_AOC_BILLING_CALL_TRANSFER,
00059 AST_AOC_BILLING_NUM_ENTRIES
00060 };
00061
00062 enum ast_aoc_type {
00063 AST_AOC_REQUEST = 0,
00064 AST_AOC_S,
00065 AST_AOC_D,
00066 AST_AOC_E,
00067 };
00068
00069 enum ast_aoc_charge_type {
00070 AST_AOC_CHARGE_NA = 0,
00071 AST_AOC_CHARGE_FREE,
00072 AST_AOC_CHARGE_CURRENCY,
00073 AST_AOC_CHARGE_UNIT,
00074 };
00075
00076 enum ast_aoc_request {
00077 AST_AOC_REQUEST_S = (1 << 0),
00078 AST_AOC_REQUEST_D = (1 << 1),
00079 AST_AOC_REQUEST_E = (1 << 2),
00080 };
00081
00082 enum ast_aoc_total_type {
00083 AST_AOC_TOTAL = 0,
00084 AST_AOC_SUBTOTAL = 1,
00085 };
00086
00087 enum ast_aoc_time_scale {
00088 AST_AOC_TIME_SCALE_HUNDREDTH_SECOND,
00089 AST_AOC_TIME_SCALE_TENTH_SECOND,
00090 AST_AOC_TIME_SCALE_SECOND,
00091 AST_AOC_TIME_SCALE_TEN_SECOND,
00092 AST_AOC_TIME_SCALE_MINUTE,
00093 AST_AOC_TIME_SCALE_HOUR,
00094 AST_AOC_TIME_SCALE_DAY,
00095 };
00096
00097 struct ast_aoc_time {
00098
00099 uint32_t length;
00100 uint16_t scale;
00101 };
00102
00103 struct ast_aoc_duration_rate {
00104 uint32_t amount;
00105 uint32_t time;
00106
00107 uint32_t granularity_time;
00108
00109 uint16_t multiplier;
00110 uint16_t time_scale;
00111 uint16_t granularity_time_scale;
00112
00113
00114 char currency_name[AOC_CURRENCY_NAME_SIZE];
00115
00116
00117
00118
00119
00120
00121
00122 uint8_t charging_type;
00123 };
00124
00125 enum ast_aoc_volume_unit {
00126 AST_AOC_VOLUME_UNIT_OCTET,
00127 AST_AOC_VOLUME_UNIT_SEGMENT,
00128 AST_AOC_VOLUME_UNIT_MESSAGE,
00129 };
00130
00131 struct ast_aoc_volume_rate {
00132 uint32_t amount;
00133 uint16_t multiplier;
00134 uint16_t volume_unit;
00135 char currency_name[AOC_CURRENCY_NAME_SIZE];
00136 };
00137
00138 struct ast_aoc_flat_rate {
00139 uint32_t amount;
00140 uint16_t multiplier;
00141
00142 char currency_name[AOC_CURRENCY_NAME_SIZE];
00143 };
00144
00145 enum ast_aoc_s_charged_item {
00146 AST_AOC_CHARGED_ITEM_NA,
00147 AST_AOC_CHARGED_ITEM_SPECIAL_ARRANGEMENT,
00148 AST_AOC_CHARGED_ITEM_BASIC_COMMUNICATION,
00149 AST_AOC_CHARGED_ITEM_CALL_ATTEMPT,
00150 AST_AOC_CHARGED_ITEM_CALL_SETUP,
00151 AST_AOC_CHARGED_ITEM_USER_USER_INFO,
00152 AST_AOC_CHARGED_ITEM_SUPPLEMENTARY_SERVICE,
00153 };
00154
00155 enum ast_aoc_s_rate_type {
00156 AST_AOC_RATE_TYPE_NA,
00157 AST_AOC_RATE_TYPE_FREE,
00158 AST_AOC_RATE_TYPE_FREE_FROM_BEGINNING,
00159 AST_AOC_RATE_TYPE_DURATION,
00160 AST_AOC_RATE_TYPE_FLAT,
00161 AST_AOC_RATE_TYPE_VOLUME,
00162 AST_AOC_RATE_TYPE_SPECIAL_CODE,
00163 };
00164
00165 struct ast_aoc_s_entry {
00166 uint16_t charged_item;
00167 uint16_t rate_type;
00168
00169
00170 union {
00171 struct ast_aoc_duration_rate duration;
00172 struct ast_aoc_flat_rate flat;
00173 struct ast_aoc_volume_rate volume;
00174 uint16_t special_code;
00175 } rate;
00176 } __attribute__((packed));
00177
00178 struct ast_aoc_unit_entry {
00179 char valid_amount;
00180 unsigned int amount;
00181 char valid_type;
00182 unsigned int type;
00183 };
00184
00185 enum AST_AOC_CHARGING_ASSOCIATION {
00186 AST_AOC_CHARGING_ASSOCIATION_NA,
00187 AST_AOC_CHARGING_ASSOCIATION_NUMBER,
00188 AST_AOC_CHARGING_ASSOCIATION_ID,
00189 };
00190 struct ast_aoc_charging_association_number {
00191 uint8_t plan;
00192 char number[32];
00193 } __attribute__((packed));
00194 struct ast_aoc_charging_association {
00195 union {
00196 int32_t id;
00197 struct ast_aoc_charging_association_number number;
00198 } charge;
00199
00200 uint8_t charging_type;
00201 } __attribute__((packed));
00202
00203
00204 struct ast_aoc_encoded;
00205
00206
00207 struct ast_aoc_decoded;
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222 struct ast_aoc_decoded *ast_aoc_create(const enum ast_aoc_type msg_type,
00223 const enum ast_aoc_charge_type charge_type,
00224 const enum ast_aoc_request requests);
00225
00226
00227
00228 void *ast_aoc_destroy_decoded(struct ast_aoc_decoded *decoded);
00229
00230
00231 void *ast_aoc_destroy_encoded(struct ast_aoc_encoded *encoded);
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244 struct ast_aoc_decoded *ast_aoc_decode(struct ast_aoc_encoded *encoded, size_t size, struct ast_channel *chan);
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257 struct ast_aoc_encoded *ast_aoc_encode(struct ast_aoc_decoded *decoded, size_t *out_size, struct ast_channel *chan);
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270 int ast_aoc_set_total_type(struct ast_aoc_decoded *decoded, const enum ast_aoc_total_type type);
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283 int ast_aoc_set_currency_info(struct ast_aoc_decoded *decoded,
00284 const unsigned int amount,
00285 const enum ast_aoc_currency_multiplier multiplier,
00286 const char *name);
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303 int ast_aoc_add_unit_entry(struct ast_aoc_decoded *decoded,
00304 const unsigned int amount_is_present,
00305 const unsigned int amount,
00306 const unsigned int type_is_present,
00307 const unsigned int type);
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318 int ast_aoc_set_billing_id(struct ast_aoc_decoded *decoded, const enum ast_aoc_billing_id id);
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332 int ast_aoc_set_association_id(struct ast_aoc_decoded *decoded, const int id);
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347 int ast_aoc_set_association_number(struct ast_aoc_decoded *decoded, const char *num, uint8_t plan);
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362 int ast_aoc_set_termination_request(struct ast_aoc_decoded *decoded);
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382 int ast_aoc_s_add_rate_duration(struct ast_aoc_decoded *decoded,
00383 enum ast_aoc_s_charged_item charged_item,
00384 unsigned int amount,
00385 enum ast_aoc_currency_multiplier multiplier,
00386 const char *currency_name,
00387 unsigned long time,
00388 enum ast_aoc_time_scale time_scale,
00389 unsigned long granularity_time,
00390 enum ast_aoc_time_scale granularity_time_scale,
00391 int step_function);
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406 int ast_aoc_s_add_rate_flat(struct ast_aoc_decoded *decoded,
00407 enum ast_aoc_s_charged_item charged_item,
00408 unsigned int amount,
00409 enum ast_aoc_currency_multiplier multiplier,
00410 const char *currency_name);
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426 int ast_aoc_s_add_rate_volume(struct ast_aoc_decoded *decoded,
00427 enum ast_aoc_s_charged_item charged_item,
00428 enum ast_aoc_volume_unit volume_unit,
00429 unsigned int amount,
00430 enum ast_aoc_currency_multiplier multiplier,
00431 const char *currency_name);
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444 int ast_aoc_s_add_rate_special_charge_code(struct ast_aoc_decoded *decoded,
00445 enum ast_aoc_s_charged_item charged_item,
00446 unsigned int code);
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459 int ast_aoc_s_add_rate_free(struct ast_aoc_decoded *decoded,
00460 enum ast_aoc_s_charged_item charged_item, int from_beginning);
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472 int ast_aoc_s_add_rate_na(struct ast_aoc_decoded *decoded,
00473 enum ast_aoc_s_charged_item charged_item);
00474
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485 int ast_aoc_s_add_special_arrangement(struct ast_aoc_decoded *decoded,
00486 unsigned int code);
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498 int ast_aoc_decoded2str(const struct ast_aoc_decoded *decoded, struct ast_str **msg);
00499
00500
00501 int ast_aoc_manager_event(const struct ast_aoc_decoded *decoded, struct ast_channel *chan);
00502
00503
00504 enum ast_aoc_type ast_aoc_get_msg_type(struct ast_aoc_decoded *decoded);
00505
00506
00507 enum ast_aoc_charge_type ast_aoc_get_charge_type(struct ast_aoc_decoded *decoded);
00508
00509
00510 enum ast_aoc_request ast_aoc_get_request(struct ast_aoc_decoded *decoded);
00511
00512
00513 enum ast_aoc_total_type ast_aoc_get_total_type(struct ast_aoc_decoded *decoded);
00514
00515
00516 unsigned int ast_aoc_get_currency_amount(struct ast_aoc_decoded *decoded);
00517
00518
00519 unsigned int ast_aoc_s_get_count(struct ast_aoc_decoded *decoded);
00520
00521
00522
00523
00524
00525
00526
00527
00528 const struct ast_aoc_s_entry *ast_aoc_s_get_rate_info(struct ast_aoc_decoded *decoded, unsigned int entry_number);
00529
00530
00531 unsigned int ast_aoc_get_unit_count(struct ast_aoc_decoded *decoded);
00532
00533
00534
00535
00536
00537
00538
00539
00540 const struct ast_aoc_unit_entry *ast_aoc_get_unit_info(struct ast_aoc_decoded *decoded, unsigned int entry_number);
00541
00542
00543 enum ast_aoc_currency_multiplier ast_aoc_get_currency_multiplier(struct ast_aoc_decoded *decoded);
00544
00545
00546 const char *ast_aoc_get_currency_multiplier_decimal(struct ast_aoc_decoded *decoded);
00547
00548
00549 const char *ast_aoc_get_currency_name(struct ast_aoc_decoded *decoded);
00550
00551
00552 enum ast_aoc_billing_id ast_aoc_get_billing_id(struct ast_aoc_decoded *decoded);
00553
00554
00555 const struct ast_aoc_charging_association *ast_aoc_get_association_info(struct ast_aoc_decoded *decoded);
00556
00557
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570 int ast_aoc_get_termination_request(struct ast_aoc_decoded *decoded);
00571
00572
00573
00574
00575
00576
00577
00578
00579 int ast_aoc_test_encode_decode_match(struct ast_aoc_decoded *decoded);
00580
00581
00582 int ast_aoc_cli_init(void);
00583
00584 #endif