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