Mercurial > hg > freeDiameter
annotate extensions/test_app/ta_cli.c @ 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 | 1d1a20a0779d |
children | 035f489b845b |
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:
706
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 * * |
928
5053f1abcf5d
Updated copyright information
Sebastien Decugis <sdecugis@freediameter.net>
parents:
924
diff
changeset
|
5 * Copyright (c) 2013, 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 /* Create and send a message, and receive it */ |
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 /* Note that we use both sessions and the argument to answer callback to pass the same value. |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
39 * This is just for the purpose of checking everything went OK. |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
40 */ |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
41 |
120
d7acdc46134d
Renamed several extensions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
99
diff
changeset
|
42 #include "test_app.h" |
93
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
43 |
98 | 44 #include <stdio.h> |
45 | |
120
d7acdc46134d
Renamed several extensions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
99
diff
changeset
|
46 static struct session_handler * ta_cli_reg = NULL; |
93
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
47 |
1088
1d1a20a0779d
Second part of changeset 1083, now the code compiles again. Still missing some functions implementation, though
Sebastien Decugis <sdecugis@freediameter.net>
parents:
930
diff
changeset
|
48 struct sess_state { |
93
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
49 int32_t randval; /* a random value to store in Test-AVP */ |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
50 struct timespec ts; /* Time of sending the message */ |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
51 } ; |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
52 |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
53 /* Cb called when an answer is received */ |
120
d7acdc46134d
Renamed several extensions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
99
diff
changeset
|
54 static void ta_cb_ans(void * data, struct msg ** msg) |
93
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
55 { |
1088
1d1a20a0779d
Second part of changeset 1083, now the code compiles again. Still missing some functions implementation, though
Sebastien Decugis <sdecugis@freediameter.net>
parents:
930
diff
changeset
|
56 struct sess_state * mi = NULL; |
93
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
57 struct timespec ts; |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
58 struct session * sess; |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
59 struct avp * avp; |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
60 struct avp_hdr * hdr; |
930
64d8ba7976d0
Include client stats in non-benchmark mode in test_app
Sebastien Decugis <sdecugis@freediameter.net>
parents:
928
diff
changeset
|
61 unsigned long dur; |
64d8ba7976d0
Include client stats in non-benchmark mode in test_app
Sebastien Decugis <sdecugis@freediameter.net>
parents:
928
diff
changeset
|
62 int error = 0; |
93
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
63 |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
64 CHECK_SYS_DO( clock_gettime(CLOCK_REALTIME, &ts), return ); |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
65 |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
66 /* Search the session, retrieve its data */ |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
67 { |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
68 int new; |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
69 CHECK_FCT_DO( fd_msg_sess_get(fd_g_config->cnf_dict, *msg, &sess, &new), return ); |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
70 ASSERT( new == 0 ); |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
71 |
120
d7acdc46134d
Renamed several extensions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
99
diff
changeset
|
72 CHECK_FCT_DO( fd_sess_state_retrieve( ta_cli_reg, sess, &mi ), return ); |
93
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
73 TRACE_DEBUG( INFO, "%p %p", mi, data); |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
74 ASSERT( (void *)mi == data ); |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
75 } |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
76 |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
77 /* Now log content of the answer */ |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
78 fprintf(stderr, "RECV "); |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
79 |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
80 /* Value of Test-AVP */ |
120
d7acdc46134d
Renamed several extensions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
99
diff
changeset
|
81 CHECK_FCT_DO( fd_msg_search_avp ( *msg, ta_avp, &avp), return ); |
93
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
82 if (avp) { |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
83 CHECK_FCT_DO( fd_msg_avp_hdr( avp, &hdr ), return ); |
930
64d8ba7976d0
Include client stats in non-benchmark mode in test_app
Sebastien Decugis <sdecugis@freediameter.net>
parents:
928
diff
changeset
|
84 if (hdr->avp_value->i32 == mi->randval) { |
64d8ba7976d0
Include client stats in non-benchmark mode in test_app
Sebastien Decugis <sdecugis@freediameter.net>
parents:
928
diff
changeset
|
85 fprintf(stderr, "%x (%s) ", hdr->avp_value->i32, "Ok"); |
64d8ba7976d0
Include client stats in non-benchmark mode in test_app
Sebastien Decugis <sdecugis@freediameter.net>
parents:
928
diff
changeset
|
86 } else { |
64d8ba7976d0
Include client stats in non-benchmark mode in test_app
Sebastien Decugis <sdecugis@freediameter.net>
parents:
928
diff
changeset
|
87 fprintf(stderr, "%x (%s) ", hdr->avp_value->i32, "PROBLEM"); |
64d8ba7976d0
Include client stats in non-benchmark mode in test_app
Sebastien Decugis <sdecugis@freediameter.net>
parents:
928
diff
changeset
|
88 error++; |
64d8ba7976d0
Include client stats in non-benchmark mode in test_app
Sebastien Decugis <sdecugis@freediameter.net>
parents:
928
diff
changeset
|
89 } |
93
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
90 } else { |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
91 fprintf(stderr, "no_Test-AVP "); |
930
64d8ba7976d0
Include client stats in non-benchmark mode in test_app
Sebastien Decugis <sdecugis@freediameter.net>
parents:
928
diff
changeset
|
92 error++; |
93
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
93 } |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
94 |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
95 /* Value of Result Code */ |
120
d7acdc46134d
Renamed several extensions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
99
diff
changeset
|
96 CHECK_FCT_DO( fd_msg_search_avp ( *msg, ta_res_code, &avp), return ); |
93
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
97 if (avp) { |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
98 CHECK_FCT_DO( fd_msg_avp_hdr( avp, &hdr ), return ); |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
99 fprintf(stderr, "Status: %d ", hdr->avp_value->i32); |
930
64d8ba7976d0
Include client stats in non-benchmark mode in test_app
Sebastien Decugis <sdecugis@freediameter.net>
parents:
928
diff
changeset
|
100 if (hdr->avp_value->i32 != 2001) |
64d8ba7976d0
Include client stats in non-benchmark mode in test_app
Sebastien Decugis <sdecugis@freediameter.net>
parents:
928
diff
changeset
|
101 error++; |
93
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
102 } else { |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
103 fprintf(stderr, "no_Result-Code "); |
930
64d8ba7976d0
Include client stats in non-benchmark mode in test_app
Sebastien Decugis <sdecugis@freediameter.net>
parents:
928
diff
changeset
|
104 error++; |
93
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
105 } |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
106 |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
107 /* Value of Origin-Host */ |
120
d7acdc46134d
Renamed several extensions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
99
diff
changeset
|
108 CHECK_FCT_DO( fd_msg_search_avp ( *msg, ta_origin_host, &avp), return ); |
93
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
109 if (avp) { |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
110 CHECK_FCT_DO( fd_msg_avp_hdr( avp, &hdr ), return ); |
406
345f3541df81
Fix a few additional warnings on 64bits arch
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
403
diff
changeset
|
111 fprintf(stderr, "From '%.*s' ", (int)hdr->avp_value->os.len, hdr->avp_value->os.data); |
93
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
112 } else { |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
113 fprintf(stderr, "no_Origin-Host "); |
930
64d8ba7976d0
Include client stats in non-benchmark mode in test_app
Sebastien Decugis <sdecugis@freediameter.net>
parents:
928
diff
changeset
|
114 error++; |
93
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
115 } |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
116 |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
117 /* Value of Origin-Realm */ |
120
d7acdc46134d
Renamed several extensions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
99
diff
changeset
|
118 CHECK_FCT_DO( fd_msg_search_avp ( *msg, ta_origin_realm, &avp), return ); |
93
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
119 if (avp) { |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
120 CHECK_FCT_DO( fd_msg_avp_hdr( avp, &hdr ), return ); |
406
345f3541df81
Fix a few additional warnings on 64bits arch
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
403
diff
changeset
|
121 fprintf(stderr, "('%.*s') ", (int)hdr->avp_value->os.len, hdr->avp_value->os.data); |
93
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
122 } else { |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
123 fprintf(stderr, "no_Origin-Realm "); |
930
64d8ba7976d0
Include client stats in non-benchmark mode in test_app
Sebastien Decugis <sdecugis@freediameter.net>
parents:
928
diff
changeset
|
124 error++; |
93
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
125 } |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
126 |
930
64d8ba7976d0
Include client stats in non-benchmark mode in test_app
Sebastien Decugis <sdecugis@freediameter.net>
parents:
928
diff
changeset
|
127 CHECK_POSIX_DO( pthread_mutex_lock(&ta_conf->stats_lock), ); |
64d8ba7976d0
Include client stats in non-benchmark mode in test_app
Sebastien Decugis <sdecugis@freediameter.net>
parents:
928
diff
changeset
|
128 dur = ((ts.tv_sec - mi->ts.tv_sec) * 1000000) + ((ts.tv_nsec - mi->ts.tv_nsec) / 1000); |
64d8ba7976d0
Include client stats in non-benchmark mode in test_app
Sebastien Decugis <sdecugis@freediameter.net>
parents:
928
diff
changeset
|
129 if (ta_conf->stats.nb_recv) { |
64d8ba7976d0
Include client stats in non-benchmark mode in test_app
Sebastien Decugis <sdecugis@freediameter.net>
parents:
928
diff
changeset
|
130 /* Ponderate in the avg */ |
64d8ba7976d0
Include client stats in non-benchmark mode in test_app
Sebastien Decugis <sdecugis@freediameter.net>
parents:
928
diff
changeset
|
131 ta_conf->stats.avg = (ta_conf->stats.avg * ta_conf->stats.nb_recv + dur) / (ta_conf->stats.nb_recv + 1); |
64d8ba7976d0
Include client stats in non-benchmark mode in test_app
Sebastien Decugis <sdecugis@freediameter.net>
parents:
928
diff
changeset
|
132 /* Min, max */ |
64d8ba7976d0
Include client stats in non-benchmark mode in test_app
Sebastien Decugis <sdecugis@freediameter.net>
parents:
928
diff
changeset
|
133 if (dur < ta_conf->stats.shortest) |
64d8ba7976d0
Include client stats in non-benchmark mode in test_app
Sebastien Decugis <sdecugis@freediameter.net>
parents:
928
diff
changeset
|
134 ta_conf->stats.shortest = dur; |
64d8ba7976d0
Include client stats in non-benchmark mode in test_app
Sebastien Decugis <sdecugis@freediameter.net>
parents:
928
diff
changeset
|
135 if (dur > ta_conf->stats.longest) |
64d8ba7976d0
Include client stats in non-benchmark mode in test_app
Sebastien Decugis <sdecugis@freediameter.net>
parents:
928
diff
changeset
|
136 ta_conf->stats.longest = dur; |
64d8ba7976d0
Include client stats in non-benchmark mode in test_app
Sebastien Decugis <sdecugis@freediameter.net>
parents:
928
diff
changeset
|
137 } else { |
64d8ba7976d0
Include client stats in non-benchmark mode in test_app
Sebastien Decugis <sdecugis@freediameter.net>
parents:
928
diff
changeset
|
138 ta_conf->stats.shortest = dur; |
64d8ba7976d0
Include client stats in non-benchmark mode in test_app
Sebastien Decugis <sdecugis@freediameter.net>
parents:
928
diff
changeset
|
139 ta_conf->stats.longest = dur; |
64d8ba7976d0
Include client stats in non-benchmark mode in test_app
Sebastien Decugis <sdecugis@freediameter.net>
parents:
928
diff
changeset
|
140 ta_conf->stats.avg = dur; |
64d8ba7976d0
Include client stats in non-benchmark mode in test_app
Sebastien Decugis <sdecugis@freediameter.net>
parents:
928
diff
changeset
|
141 } |
64d8ba7976d0
Include client stats in non-benchmark mode in test_app
Sebastien Decugis <sdecugis@freediameter.net>
parents:
928
diff
changeset
|
142 |
64d8ba7976d0
Include client stats in non-benchmark mode in test_app
Sebastien Decugis <sdecugis@freediameter.net>
parents:
928
diff
changeset
|
143 if (error) |
64d8ba7976d0
Include client stats in non-benchmark mode in test_app
Sebastien Decugis <sdecugis@freediameter.net>
parents:
928
diff
changeset
|
144 ta_conf->stats.nb_errs++; |
64d8ba7976d0
Include client stats in non-benchmark mode in test_app
Sebastien Decugis <sdecugis@freediameter.net>
parents:
928
diff
changeset
|
145 else |
64d8ba7976d0
Include client stats in non-benchmark mode in test_app
Sebastien Decugis <sdecugis@freediameter.net>
parents:
928
diff
changeset
|
146 ta_conf->stats.nb_recv++; |
64d8ba7976d0
Include client stats in non-benchmark mode in test_app
Sebastien Decugis <sdecugis@freediameter.net>
parents:
928
diff
changeset
|
147 |
64d8ba7976d0
Include client stats in non-benchmark mode in test_app
Sebastien Decugis <sdecugis@freediameter.net>
parents:
928
diff
changeset
|
148 |
64d8ba7976d0
Include client stats in non-benchmark mode in test_app
Sebastien Decugis <sdecugis@freediameter.net>
parents:
928
diff
changeset
|
149 CHECK_POSIX_DO( pthread_mutex_unlock(&ta_conf->stats_lock), ); |
64d8ba7976d0
Include client stats in non-benchmark mode in test_app
Sebastien Decugis <sdecugis@freediameter.net>
parents:
928
diff
changeset
|
150 |
64d8ba7976d0
Include client stats in non-benchmark mode in test_app
Sebastien Decugis <sdecugis@freediameter.net>
parents:
928
diff
changeset
|
151 /* Display how long it took */ |
93
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
152 if (ts.tv_nsec > mi->ts.tv_nsec) { |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
153 fprintf(stderr, "in %d.%06ld sec", |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
154 (int)(ts.tv_sec - mi->ts.tv_sec), |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
155 (long)(ts.tv_nsec - mi->ts.tv_nsec) / 1000); |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
156 } else { |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
157 fprintf(stderr, "in %d.%06ld sec", |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
158 (int)(ts.tv_sec + 1 - mi->ts.tv_sec), |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
159 (long)(1000000000 + ts.tv_nsec - mi->ts.tv_nsec) / 1000); |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
160 } |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
161 fprintf(stderr, "\n"); |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
162 fflush(stderr); |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
163 |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
164 /* Free the message */ |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
165 CHECK_FCT_DO(fd_msg_free(*msg), return); |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
166 *msg = NULL; |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
167 |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
168 free(mi); |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
169 |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
170 return; |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
171 } |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
172 |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
173 /* Create a test message */ |
658
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
639
diff
changeset
|
174 static void ta_cli_test_message() |
93
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
175 { |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
176 struct msg * req = NULL; |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
177 struct avp * avp; |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
178 union avp_value val; |
1088
1d1a20a0779d
Second part of changeset 1083, now the code compiles again. Still missing some functions implementation, though
Sebastien Decugis <sdecugis@freediameter.net>
parents:
930
diff
changeset
|
179 struct sess_state * mi = NULL, *svg; |
93
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
180 struct session *sess = NULL; |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
181 |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
182 TRACE_DEBUG(FULL, "Creating a new message for sending."); |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
183 |
1214
c2fbaf2985f4
New options to test_app extension to generate long Diameter messages
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1088
diff
changeset
|
184 /* Create the request */ |
120
d7acdc46134d
Renamed several extensions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
99
diff
changeset
|
185 CHECK_FCT_DO( fd_msg_new( ta_cmd_r, MSGFL_ALLOC_ETEID, &req ), goto out ); |
93
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
186 |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
187 /* Create a new session */ |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
188 #define TEST_APP_SID_OPT "app_test" |
924
877592751fee
Fix (tentative) for invalid handling of sessions fast creation/destruction as pointed by Yusuke Okura -- http://lists.freediameter.net/pipermail/help/2013-February/000584.html and http://lists.freediameter.net/pipermail/help/2013-February/000589.html -- Thank you very much
Sebastien Decugis <sdecugis@freediameter.net>
parents:
740
diff
changeset
|
189 CHECK_FCT_DO( fd_msg_new_session( req, (os0_t)TEST_APP_SID_OPT, CONSTSTRLEN(TEST_APP_SID_OPT) ), goto out ); |
877592751fee
Fix (tentative) for invalid handling of sessions fast creation/destruction as pointed by Yusuke Okura -- http://lists.freediameter.net/pipermail/help/2013-February/000584.html and http://lists.freediameter.net/pipermail/help/2013-February/000589.html -- Thank you very much
Sebastien Decugis <sdecugis@freediameter.net>
parents:
740
diff
changeset
|
190 CHECK_FCT_DO( fd_msg_sess_get(fd_g_config->cnf_dict, req, &sess, NULL), goto out ); |
93
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
191 |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
192 /* Create the random value to store with the session */ |
1088
1d1a20a0779d
Second part of changeset 1083, now the code compiles again. Still missing some functions implementation, though
Sebastien Decugis <sdecugis@freediameter.net>
parents:
930
diff
changeset
|
193 mi = malloc(sizeof(struct sess_state)); |
93
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
194 if (mi == NULL) { |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
195 fd_log_debug("malloc failed: %s", strerror(errno)); |
98 | 196 goto out; |
93
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
197 } |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
198 |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
199 mi->randval = (int32_t)random(); |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
200 |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
201 /* Now set all AVPs values */ |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
202 |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
203 /* Set the Destination-Realm AVP */ |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
204 { |
120
d7acdc46134d
Renamed several extensions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
99
diff
changeset
|
205 CHECK_FCT_DO( fd_msg_avp_new ( ta_dest_realm, 0, &avp ), goto out ); |
d7acdc46134d
Renamed several extensions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
99
diff
changeset
|
206 val.os.data = (unsigned char *)(ta_conf->dest_realm); |
d7acdc46134d
Renamed several extensions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
99
diff
changeset
|
207 val.os.len = strlen(ta_conf->dest_realm); |
98 | 208 CHECK_FCT_DO( fd_msg_avp_setvalue( avp, &val ), goto out ); |
209 CHECK_FCT_DO( fd_msg_avp_add( req, MSG_BRW_LAST_CHILD, avp ), goto out ); | |
93
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
210 } |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
211 |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
212 /* Set the Destination-Host AVP if needed*/ |
120
d7acdc46134d
Renamed several extensions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
99
diff
changeset
|
213 if (ta_conf->dest_host) { |
d7acdc46134d
Renamed several extensions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
99
diff
changeset
|
214 CHECK_FCT_DO( fd_msg_avp_new ( ta_dest_host, 0, &avp ), goto out ); |
d7acdc46134d
Renamed several extensions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
99
diff
changeset
|
215 val.os.data = (unsigned char *)(ta_conf->dest_host); |
d7acdc46134d
Renamed several extensions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
99
diff
changeset
|
216 val.os.len = strlen(ta_conf->dest_host); |
98 | 217 CHECK_FCT_DO( fd_msg_avp_setvalue( avp, &val ), goto out ); |
218 CHECK_FCT_DO( fd_msg_avp_add( req, MSG_BRW_LAST_CHILD, avp ), goto out ); | |
93
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
219 } |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
220 |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
221 /* Set Origin-Host & Origin-Realm */ |
98 | 222 CHECK_FCT_DO( fd_msg_add_origin ( req, 0 ), goto out ); |
93
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
223 |
127
8ee43cf85a5f
Added User-Name AVP in test_app extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
121
diff
changeset
|
224 /* Set the User-Name AVP if needed*/ |
8ee43cf85a5f
Added User-Name AVP in test_app extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
121
diff
changeset
|
225 if (ta_conf->user_name) { |
8ee43cf85a5f
Added User-Name AVP in test_app extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
121
diff
changeset
|
226 CHECK_FCT_DO( fd_msg_avp_new ( ta_user_name, 0, &avp ), goto out ); |
8ee43cf85a5f
Added User-Name AVP in test_app extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
121
diff
changeset
|
227 val.os.data = (unsigned char *)(ta_conf->user_name); |
8ee43cf85a5f
Added User-Name AVP in test_app extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
121
diff
changeset
|
228 val.os.len = strlen(ta_conf->user_name); |
8ee43cf85a5f
Added User-Name AVP in test_app extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
121
diff
changeset
|
229 CHECK_FCT_DO( fd_msg_avp_setvalue( avp, &val ), goto out ); |
8ee43cf85a5f
Added User-Name AVP in test_app extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
121
diff
changeset
|
230 CHECK_FCT_DO( fd_msg_avp_add( req, MSG_BRW_LAST_CHILD, avp ), goto out ); |
8ee43cf85a5f
Added User-Name AVP in test_app extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
121
diff
changeset
|
231 } |
93
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
232 |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
233 /* Set the Test-AVP AVP */ |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
234 { |
120
d7acdc46134d
Renamed several extensions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
99
diff
changeset
|
235 CHECK_FCT_DO( fd_msg_avp_new ( ta_avp, 0, &avp ), goto out ); |
93
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
236 val.i32 = mi->randval; |
98 | 237 CHECK_FCT_DO( fd_msg_avp_setvalue( avp, &val ), goto out ); |
238 CHECK_FCT_DO( fd_msg_avp_add( req, MSG_BRW_LAST_CHILD, avp ), goto out ); | |
93
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
239 } |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
240 |
1214
c2fbaf2985f4
New options to test_app extension to generate long Diameter messages
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1088
diff
changeset
|
241 /* Set the Test-Payload-AVP AVP */ |
c2fbaf2985f4
New options to test_app extension to generate long Diameter messages
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1088
diff
changeset
|
242 if (ta_conf->long_avp_id) { |
c2fbaf2985f4
New options to test_app extension to generate long Diameter messages
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1088
diff
changeset
|
243 int l; |
c2fbaf2985f4
New options to test_app extension to generate long Diameter messages
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1088
diff
changeset
|
244 CHECK_FCT_DO( fd_msg_avp_new ( ta_avp_long, 0, &avp ), goto out ); |
c2fbaf2985f4
New options to test_app extension to generate long Diameter messages
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1088
diff
changeset
|
245 CHECK_MALLOC_DO( val.os.data = malloc(ta_conf->long_avp_len), goto out); |
c2fbaf2985f4
New options to test_app extension to generate long Diameter messages
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1088
diff
changeset
|
246 val.os.len = ta_conf->long_avp_len; |
c2fbaf2985f4
New options to test_app extension to generate long Diameter messages
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1088
diff
changeset
|
247 for (l=0; l < ta_conf->long_avp_len; l++) |
c2fbaf2985f4
New options to test_app extension to generate long Diameter messages
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1088
diff
changeset
|
248 val.os.data[l]=l; |
c2fbaf2985f4
New options to test_app extension to generate long Diameter messages
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1088
diff
changeset
|
249 CHECK_FCT_DO( fd_msg_avp_setvalue( avp, &val ), goto out ); |
c2fbaf2985f4
New options to test_app extension to generate long Diameter messages
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1088
diff
changeset
|
250 free(val.os.data); |
c2fbaf2985f4
New options to test_app extension to generate long Diameter messages
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1088
diff
changeset
|
251 CHECK_FCT_DO( fd_msg_avp_add( req, MSG_BRW_LAST_CHILD, avp ), goto out ); |
c2fbaf2985f4
New options to test_app extension to generate long Diameter messages
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1088
diff
changeset
|
252 } |
c2fbaf2985f4
New options to test_app extension to generate long Diameter messages
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1088
diff
changeset
|
253 |
98 | 254 CHECK_SYS_DO( clock_gettime(CLOCK_REALTIME, &mi->ts), goto out ); |
93
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
255 |
99 | 256 /* Keep a pointer to the session data for debug purpose, in real life we would not need it */ |
257 svg = mi; | |
258 | |
93
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
259 /* Store this value in the session */ |
120
d7acdc46134d
Renamed several extensions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
99
diff
changeset
|
260 CHECK_FCT_DO( fd_sess_state_store ( ta_cli_reg, sess, &mi ), goto out ); |
93
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
261 |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
262 /* Log sending the message */ |
120
d7acdc46134d
Renamed several extensions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
99
diff
changeset
|
263 fprintf(stderr, "SEND %x to '%s' (%s)\n", svg->randval, ta_conf->dest_realm, ta_conf->dest_host?:"-" ); |
93
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
264 fflush(stderr); |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
265 |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
266 /* Send the request */ |
120
d7acdc46134d
Renamed several extensions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
99
diff
changeset
|
267 CHECK_FCT_DO( fd_msg_send( &req, ta_cb_ans, svg ), goto out ); |
98 | 268 |
930
64d8ba7976d0
Include client stats in non-benchmark mode in test_app
Sebastien Decugis <sdecugis@freediameter.net>
parents:
928
diff
changeset
|
269 /* Increment the counter */ |
64d8ba7976d0
Include client stats in non-benchmark mode in test_app
Sebastien Decugis <sdecugis@freediameter.net>
parents:
928
diff
changeset
|
270 CHECK_POSIX_DO( pthread_mutex_lock(&ta_conf->stats_lock), ); |
64d8ba7976d0
Include client stats in non-benchmark mode in test_app
Sebastien Decugis <sdecugis@freediameter.net>
parents:
928
diff
changeset
|
271 ta_conf->stats.nb_sent++; |
64d8ba7976d0
Include client stats in non-benchmark mode in test_app
Sebastien Decugis <sdecugis@freediameter.net>
parents:
928
diff
changeset
|
272 CHECK_POSIX_DO( pthread_mutex_unlock(&ta_conf->stats_lock), ); |
64d8ba7976d0
Include client stats in non-benchmark mode in test_app
Sebastien Decugis <sdecugis@freediameter.net>
parents:
928
diff
changeset
|
273 |
98 | 274 out: |
93
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
275 return; |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
276 } |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
277 |
120
d7acdc46134d
Renamed several extensions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
99
diff
changeset
|
278 int ta_cli_init(void) |
93
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
279 { |
1088
1d1a20a0779d
Second part of changeset 1083, now the code compiles again. Still missing some functions implementation, though
Sebastien Decugis <sdecugis@freediameter.net>
parents:
930
diff
changeset
|
280 CHECK_FCT( fd_sess_handler_create(&ta_cli_reg, (void *)free, NULL, NULL) ); |
93
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
281 |
658
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
639
diff
changeset
|
282 CHECK_FCT( fd_event_trig_regcb(ta_conf->signal, "test_app.cli", ta_cli_test_message ) ); |
93
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
283 |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
284 return 0; |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
285 } |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
286 |
120
d7acdc46134d
Renamed several extensions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
99
diff
changeset
|
287 void ta_cli_fini(void) |
93
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
288 { |
658
f198d16fa7f4
Initial commit for 1.1.0:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
639
diff
changeset
|
289 // CHECK_FCT_DO( fd_sig_unregister(ta_conf->signal), /* continue */ ); |
93
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
290 |
639
95a784729cac
Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
406
diff
changeset
|
291 CHECK_FCT_DO( fd_sess_handler_destroy(&ta_cli_reg, NULL), /* continue */ ); |
93
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
292 |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
293 return; |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
294 }; |