Mercurial > hg > freeDiameter
comparison extensions/test_ccload/test_ccload.c @ 1382:f62e18dc4800
test_ccload: allow sending to a realm instead of a particular host
author | Thomas Klausner <tk@giga.or.at> |
---|---|
date | Fri, 05 Jul 2019 18:31:50 +0200 |
parents | f374d3f8f7d3 |
children |
comparison
equal
deleted
inserted
replaced
1381:f374d3f8f7d3 | 1382:f62e18dc4800 |
---|---|
29 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * | 29 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * |
30 **********************************************************************************************************/ | 30 **********************************************************************************************************/ |
31 | 31 |
32 /* This extension waits for a signal (SIGUSR2). When it gets it, it | 32 /* This extension waits for a signal (SIGUSR2). When it gets it, it |
33 * generates messages as quickly as possible to the configured target | 33 * generates messages as quickly as possible to the configured target |
34 * host; a second SIGUSR2 signal will stop this */ | 34 * host; a second SIGUSR2 signal will stop this. |
35 * If the target host starts with "REALM:", send to that Destination-Realm instead | |
36 * of a particular host. */ | |
35 | 37 |
36 #include <freeDiameter/extension.h> | 38 #include <freeDiameter/extension.h> |
37 | 39 |
38 #include <pthread.h> | 40 #include <pthread.h> |
39 #include <signal.h> | 41 #include <signal.h> |
194 fd_log_error("can't set Origin for 'Credit-Control-Request' message"); | 196 fd_log_error("can't set Origin for 'Credit-Control-Request' message"); |
195 fd_msg_free(msg); | 197 fd_msg_free(msg); |
196 return NULL; | 198 return NULL; |
197 } | 199 } |
198 | 200 |
199 /* Destination-Host */ | 201 if (strncmp("REALM:", target, 6) != 0) { |
200 fd_msg_avp_new(dh_avp_do, 0, &avp); | 202 /* Destination-Host */ |
201 memset(&val, 0, sizeof(val)); | 203 fd_msg_avp_new(dh_avp_do, 0, &avp); |
202 val.os.data = (uint8_t *)target; | 204 memset(&val, 0, sizeof(val)); |
203 val.os.len = strlen(target); | 205 val.os.data = (uint8_t *)target; |
204 if (fd_msg_avp_setvalue(avp, &val) != 0) { | 206 val.os.len = strlen(target); |
205 fd_msg_free(msg); | 207 if (fd_msg_avp_setvalue(avp, &val) != 0) { |
206 fd_log_error("can't set value for 'Destination-Host' for 'Credit-Control-Request' message"); | 208 fd_msg_free(msg); |
207 return NULL; | 209 fd_log_error("can't set value for 'Destination-Host' for 'Credit-Control-Request' message"); |
208 } | 210 return NULL; |
209 fd_msg_avp_add(msg, MSG_BRW_LAST_CHILD, avp); | 211 } |
210 | 212 fd_msg_avp_add(msg, MSG_BRW_LAST_CHILD, avp); |
211 if ((realm = strchr(target, '.')) == NULL) { | 213 |
212 fd_msg_free(msg); | 214 if ((realm = strchr(target, '.')) == NULL) { |
213 fd_log_error("can't extract realm from host '%s'", target); | 215 fd_msg_free(msg); |
214 return NULL; | 216 fd_log_error("can't extract realm from host '%s'", target); |
215 } | 217 return NULL; |
216 /* skip dot */ | 218 } |
217 realm++; | 219 /* skip dot */ |
220 realm++; | |
221 } else { | |
222 realm = target + 6; /* skip "REALM:" */ | |
223 } | |
218 /* Destination-Realm */ | 224 /* Destination-Realm */ |
219 fd_msg_avp_new(dr_avp_do, 0, &avp); | 225 fd_msg_avp_new(dr_avp_do, 0, &avp); |
220 memset(&val, 0, sizeof(val)); | 226 memset(&val, 0, sizeof(val)); |
221 val.os.data = (uint8_t *)realm; | 227 val.os.data = (uint8_t *)realm; |
222 val.os.len = strlen(realm); | 228 val.os.len = strlen(realm); |