blob: 8d01a452cb1042a1d97b25c61ca2d985a9f29269 [file] [log] [blame]
Brian Waters13d96012017-12-08 16:53:31 -06001/*********************************************************************************************************
2* Software License Agreement (BSD License) *
3* Author: Sebastien Decugis <sdecugis@freediameter.net> *
4* *
5* Copyright (c) 2013, WIDE Project and NICT *
6* All rights reserved. *
7* *
8* Redistribution and use of this software in source and binary forms, with or without modification, are *
9* permitted provided that the following conditions are met: *
10* *
11* * Redistributions of source code must retain the above *
12* copyright notice, this list of conditions and the *
13* following disclaimer. *
14* *
15* * Redistributions in binary form must reproduce the above *
16* copyright notice, this list of conditions and the *
17* following disclaimer in the documentation and/or other *
18* materials provided with the distribution. *
19* *
20* * Neither the name of the WIDE Project or NICT nor the *
21* names of its contributors may be used to endorse or *
22* promote products derived from this software without *
23* specific prior written permission of WIDE Project and *
24* NICT. *
25* *
26* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED *
27* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
28* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR *
29* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
30* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS *
31* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR *
32* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF *
33* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
34*********************************************************************************************************/
35
36/* Header file for the app_test extension.
37 *
38 * This extension provides a way to send configurable messages on the network
39 *
40 * See the app_test.conf.sample file for the format of the configuration file.
41 */
42
43#include <freeDiameter/extension.h>
44#include <signal.h>
45
46#ifndef TEST_APP_DEFAULT_SIGNAL
47#define TEST_APP_DEFAULT_SIGNAL SIGUSR1
48#endif /* TEST_APP_DEFAULT_SIGNAL */
49
50
51/* Mode for the extension */
52#define MODE_SERV 0x1
53#define MODE_CLI 0x2
54#define MODE_BENCH 0x4
55
56/* The module configuration */
57struct ta_conf {
58 uint32_t vendor_id; /* default 999999 */
59 uint32_t appli_id; /* default 123456 */
60 uint32_t cmd_id; /* default 234567 */
61 uint32_t avp_id; /* default 345678 */
62 uint32_t long_avp_id; /* default 0 */
63 size_t long_avp_len; /* default 5000 */
64 int mode; /* default MODE_SERV | MODE_CLI */
65 char * dest_realm; /* default local realm */
66 char * dest_host; /* default NULL */
67 char * user_name; /* default NULL */
68 int signal; /* default TEST_APP_DEFAULT_SIGNAL */
69 int bench_concur; /* default 100 */
70 int bench_duration; /* default 10 */
71 struct ta_stats {
72 unsigned long long nb_echoed; /* server */
73 unsigned long long nb_sent; /* client */
74 unsigned long long nb_recv; /* client */
75 unsigned long long nb_errs; /* client */
76 unsigned long shortest; /* fastest answer, in microseconds */
77 unsigned long longest; /* slowest answer, in microseconds */
78 unsigned long avg; /* average answer time, in microseconds */
79 } stats;
80 pthread_mutex_t stats_lock;
81};
82extern struct ta_conf * ta_conf;
83
84/* Parse the configuration file */
85int ta_conf_handle(char * conffile);
86
87/* Handle incoming messages (server) */
88int ta_serv_init(void);
89void ta_serv_fini(void);
90
91/* Create outgoing message (client) */
92int ta_cli_init(void);
93void ta_cli_fini(void);
94
95/* Benchmark flavour */
96int ta_bench_init(void);
97void ta_bench_fini(void);
98
99/* Initialize dictionary definitions */
100int ta_dict_init(void);
101
102
103/* Some global variables for dictionary */
104extern struct dict_object * ta_vendor;
105extern struct dict_object * ta_appli;
106extern struct dict_object * ta_cmd_r;
107extern struct dict_object * ta_cmd_a;
108extern struct dict_object * ta_avp;
109extern struct dict_object * ta_avp_long;
110
111extern struct dict_object * ta_sess_id;
112extern struct dict_object * ta_origin_host;
113extern struct dict_object * ta_origin_realm;
114extern struct dict_object * ta_dest_host;
115extern struct dict_object * ta_dest_realm;
116extern struct dict_object * ta_user_name;
117extern struct dict_object * ta_res_code;