Mercurial > hg > freeDiameter
comparison extensions/test_ccload/test_ccload.c @ 1375:2bd83cd4d2b2
test_ccload: cache Credit-Control-Request object
author | Thomas Klausner <tk@giga.or.at> |
---|---|
date | Thu, 20 Jun 2019 10:37:54 +0200 |
parents | e99e8f20b346 |
children | f374d3f8f7d3 |
comparison
equal
deleted
inserted
replaced
1374:e99e8f20b346 | 1375:2bd83cd4d2b2 |
---|---|
57 struct dict_object * si_avp_do; /* cache the Session-Id dictionary object */ | 57 struct dict_object * si_avp_do; /* cache the Session-Id dictionary object */ |
58 struct dict_object * pi_avp_do; /* cache the Proxy-Info dictionary object */ | 58 struct dict_object * pi_avp_do; /* cache the Proxy-Info dictionary object */ |
59 struct dict_object * ph_avp_do; /* cache the Proxy-Host dictionary object */ | 59 struct dict_object * ph_avp_do; /* cache the Proxy-Host dictionary object */ |
60 struct dict_object * ps_avp_do; /* cache the Proxy-State dictionary object */ | 60 struct dict_object * ps_avp_do; /* cache the Proxy-State dictionary object */ |
61 | 61 |
62 struct dict_object * ccr_do; /* cache the Credit-Control-Request command dictionary object */ | |
63 | |
62 struct statistics { | 64 struct statistics { |
63 uint64_t sent; | 65 uint64_t sent; |
64 uint64_t success; | 66 uint64_t success; |
65 uint64_t error; | 67 uint64_t error; |
66 time_t first; | 68 time_t first; |
152 } | 154 } |
153 | 155 |
154 /* create message to send */ | 156 /* create message to send */ |
155 struct msg *create_message(const char *destination) | 157 struct msg *create_message(const char *destination) |
156 { | 158 { |
157 struct dict_object *command; | |
158 struct msg *msg; | 159 struct msg *msg; |
159 struct avp *avp, *avp1; | 160 struct avp *avp, *avp1; |
160 union avp_value val; | 161 union avp_value val; |
161 struct msg_hdr *msg_hdr; | 162 struct msg_hdr *msg_hdr; |
162 const char *realm; | 163 const char *realm; |
163 char session_id[800]; | 164 char session_id[800]; |
164 const char *service_context_id = "version2.clci.ipc@vodafone.com"; | 165 const char *service_context_id = "version2.clci.ipc@vodafone.com"; |
165 const char *proxy_host = "Dummy-Proxy-Host-to-Increase-Package-Size"; | 166 const char *proxy_host = "Dummy-Proxy-Host-to-Increase-Package-Size"; |
166 const char *proxy_state = "This is just data to increase the package size\nXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX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XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; |
167 | 168 |
168 if (fd_dict_search(fd_g_config->cnf_dict, DICT_COMMAND, CMD_BY_NAME, "Credit-Control-Request", &command, ENOENT) != 0) { | 169 if (fd_msg_new(ccr_do, MSGFL_ALLOC_ETEID, &msg) != 0) { |
169 fd_log_error("can't find template for 'Credit-Control-Request'"); | |
170 return NULL; | |
171 } | |
172 | |
173 if (fd_msg_new(command, MSGFL_ALLOC_ETEID, &msg) != 0) { | |
174 fd_log_error("can't create new 'Credit-Control-Request' message"); | 170 fd_log_error("can't create new 'Credit-Control-Request' message"); |
175 return NULL; | 171 return NULL; |
176 } | 172 } |
177 | 173 |
178 /* Application Id in header needs to be set to for since this Credit-Control-Request is for Diameter Credit Control */ | 174 /* Application Id in header needs to be set to for since this Credit-Control-Request is for Diameter Credit Control */ |
393 { LOG_E("Unable to find 'Proxy-Info' AVP in the loaded dictionaries."); }); | 389 { LOG_E("Unable to find 'Proxy-Info' AVP in the loaded dictionaries."); }); |
394 CHECK_FCT_DO(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Proxy-Host", &ph_avp_do, ENOENT), | 390 CHECK_FCT_DO(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Proxy-Host", &ph_avp_do, ENOENT), |
395 { LOG_E("Unable to find 'Proxy-Host' AVP in the loaded dictionaries."); }); | 391 { LOG_E("Unable to find 'Proxy-Host' AVP in the loaded dictionaries."); }); |
396 CHECK_FCT_DO(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Proxy-State", &ps_avp_do, ENOENT), | 392 CHECK_FCT_DO(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Proxy-State", &ps_avp_do, ENOENT), |
397 { LOG_E("Unable to find 'Proxy-State' AVP in the loaded dictionaries."); }); | 393 { LOG_E("Unable to find 'Proxy-State' AVP in the loaded dictionaries."); }); |
394 CHECK_FCT_DO(fd_dict_search(fd_g_config->cnf_dict, DICT_COMMAND, CMD_BY_NAME, "Credit-Control-Request", &ccr_do, ENOENT), | |
395 { LOG_E("Unable to find 'Credit-Control-Request' command in the loaded dictionaries."); }); | |
398 | 396 |
399 /* Start the generator thread */ | 397 /* Start the generator thread */ |
400 CHECK_POSIX( pthread_create( &gen_thr, NULL, gen_thr_fct, NULL ) ); | 398 CHECK_POSIX( pthread_create( &gen_thr, NULL, gen_thr_fct, NULL ) ); |
401 | 399 |
402 /* Register generator callback */ | 400 /* Register generator callback */ |