43 #include <curl/curl.h> 52 static size_t read_callback(
void *ptr,
size_t size,
size_t nmemb,
void *userp);
71 CURLcode curl_rc = CURLE_OK;
72 char curl_err_string[CURL_ERROR_SIZE] =
"<NULL>";
77 CURL * curl_handle = curl_easy_init();
78 assert(curl_handle != NULL);
83 curl_rc = curl_easy_setopt(curl_handle,
86 assert(curl_rc == CURLE_OK);
91 char version_string[10] = {0};
98 snprintf(test_control_url,
100 "%s://%s:%d/testControl/v%s/commandList",
101 secure ?
"https" :
"http",
105 curl_rc = curl_easy_setopt(curl_handle, CURLOPT_URL, test_control_url);
106 assert(curl_rc == CURLE_OK);
112 curl_rc = curl_easy_setopt(curl_handle,
114 "libcurl-agent/1.0");
115 assert(curl_rc == CURLE_OK);
120 curl_rc = curl_easy_setopt(curl_handle, CURLOPT_POST, 1L);
121 assert(curl_rc == CURLE_OK);
126 curl_rc = curl_easy_setopt(curl_handle, CURLOPT_READFUNCTION, read_callback);
127 assert(curl_rc == CURLE_OK);
134 static struct curl_slist * hdr_chunk = NULL;
135 hdr_chunk = curl_slist_append(hdr_chunk,
"Content-type: application/json");
136 hdr_chunk = curl_slist_append(hdr_chunk,
"Expect:");
141 curl_rc = curl_easy_setopt(curl_handle, CURLOPT_HTTPHEADER, hdr_chunk);
142 assert(curl_rc == CURLE_OK);
147 const int TEST_CTRL_TIMEOUT = 2;
148 curl_rc = curl_easy_setopt(curl_handle, CURLOPT_TIMEOUT, TEST_CTRL_TIMEOUT);
149 assert(curl_rc == CURLE_OK);
155 curl_rc = curl_easy_setopt(curl_handle, CURLOPT_READDATA, &tx_chunk);
156 assert(curl_rc == CURLE_OK);
161 curl_rc = curl_easy_setopt(curl_handle,
162 CURLOPT_POSTFIELDSIZE,
164 assert(curl_rc == CURLE_OK);
169 curl_rc = curl_easy_perform(curl_handle);
170 assert(curl_rc == CURLE_OK);
175 curl_easy_cleanup(curl_handle);
188 static size_t read_callback(
void *ptr,
size_t size,
size_t nmemb,
void *userp)
191 size_t bytes_to_write = 0;
196 bytes_to_write =
min(size * nmemb, tx_chunk->
size);
198 if (bytes_to_write > 0)
200 strncpy((
char *)ptr, tx_chunk->
memory, bytes_to_write);
201 tx_chunk->
memory += bytes_to_write;
202 tx_chunk->
size -= bytes_to_write;
203 rtn = bytes_to_write;
227 const int MAX_JSON = 10000;
228 char json_buffer[MAX_JSON];
236 json_size += snprintf(
237 json_buffer + json_size,
238 MAX_JSON - json_size,
240 " \"commandList\": [" 243 " \"commandType\": \"throttlingSpecification\"," 244 " \"eventDomainThrottleSpecification\": {" 245 " \"eventDomain\": \"fault\"" 251 " \"commandType\": \"throttlingSpecification\"," 252 " \"eventDomainThrottleSpecification\": {" 253 " \"eventDomain\": \"measurementsForVfScaling\"" 259 " \"commandType\": \"throttlingSpecification\"," 260 " \"eventDomainThrottleSpecification\": {" 261 " \"eventDomain\": \"mobileFlow\"" 267 " \"commandType\": \"throttlingSpecification\"," 268 " \"eventDomainThrottleSpecification\": {" 269 " \"eventDomain\": \"serviceEvents\"" 275 " \"commandType\": \"throttlingSpecification\"," 276 " \"eventDomainThrottleSpecification\": {" 277 " \"eventDomain\": \"signaling\"" 283 " \"commandType\": \"throttlingSpecification\"," 284 " \"eventDomainThrottleSpecification\": {" 285 " \"eventDomain\": \"stateChange\"" 291 " \"commandType\": \"throttlingSpecification\"," 292 " \"eventDomainThrottleSpecification\": {" 293 " \"eventDomain\": \"syslog\"" 302 json_size += snprintf(
303 json_buffer + json_size,
304 MAX_JSON - json_size,
306 " \"commandList\": [" 309 " \"commandType\": \"throttlingSpecification\"," 310 " \"eventDomainThrottleSpecification\": {" 311 " \"suppressedFieldNames\": [" 312 " \"alarmInterfaceA\"," 313 " \"alarmAdditionalInformation\"" 315 " \"eventDomain\": \"fault\"" 324 json_size += snprintf(
325 json_buffer + json_size,
326 MAX_JSON - json_size,
328 " \"commandList\": [" 331 " \"commandType\": \"throttlingSpecification\"," 332 " \"eventDomainThrottleSpecification\": {" 333 " \"suppressedNvPairsList\": [" 335 " \"nvPairFieldName\": \"alarmAdditionalInformation\"," 336 " \"suppressedNvPairNames\": [" 342 " \"suppressedFieldNames\": [" 343 " \"alarmInterfaceA\"" 345 " \"eventDomain\": \"fault\"" 354 json_size += snprintf(
355 json_buffer + json_size,
356 MAX_JSON - json_size,
358 " \"commandList\": [" 361 " \"commandType\": \"throttlingSpecification\"," 362 " \"eventDomainThrottleSpecification\": {" 363 " \"eventDomain\": \"fault\"" 372 json_size += snprintf(
373 json_buffer + json_size,
374 MAX_JSON - json_size,
376 " \"commandList\": [" 379 " \"commandType\": \"throttlingSpecification\"," 380 " \"eventDomainThrottleSpecification\": {" 381 " \"suppressedNvPairsList\": [" 383 " \"nvPairFieldName\": \"alarmAdditionalInformation\"," 384 " \"suppressedNvPairNames\": [" 390 " \"eventDomain\": \"fault\"" 399 json_size += snprintf(
400 json_buffer + json_size,
401 MAX_JSON - json_size,
403 " \"commandList\": [" 406 " \"commandType\": \"throttlingSpecification\"," 407 " \"eventDomainThrottleSpecification\": {" 408 " \"suppressedNvPairsList\": [" 410 " \"nvPairFieldName\": \"cpuUsageArray\"," 411 " \"suppressedNvPairNames\": [" 417 " \"suppressedFieldNames\": [" 418 " \"numberOfMediaPortsInUse\"," 419 " \"aggregateCpuUsage\"" 421 " \"eventDomain\": \"measurementsForVfScaling\"" 430 json_size += snprintf(
431 json_buffer + json_size,
432 MAX_JSON - json_size,
434 " \"commandList\": [" 437 " \"commandType\": \"throttlingSpecification\"," 438 " \"eventDomainThrottleSpecification\": {" 439 " \"suppressedFieldNames\": [" 440 " \"radioAccessTechnology\"," 441 " \"samplingAlgorithm\"" 443 " \"eventDomain\": \"mobileFlow\"" 452 json_size += snprintf(
453 json_buffer + json_size,
454 MAX_JSON - json_size,
456 " \"commandList\": [" 459 " \"commandType\": \"throttlingSpecification\"," 460 " \"eventDomainThrottleSpecification\": {" 461 " \"suppressedNvPairsList\": [" 463 " \"nvPairFieldName\": \"additionalFields\"," 464 " \"suppressedNvPairNames\": [" 470 " \"suppressedFieldNames\": [" 471 " \"reportingEntityId\"," 474 " \"codecSelected\"," 475 " \"codecSelectedTranscoding\"," 477 " \"endOfCallVqmSummaries\"," 480 " \"eventDomain\": \"serviceEvents\"" 489 json_size += snprintf(
490 json_buffer + json_size,
491 MAX_JSON - json_size,
493 " \"commandList\": [" 496 " \"commandType\": \"throttlingSpecification\"," 497 " \"eventDomainThrottleSpecification\": {" 498 " \"suppressedFieldNames\": [" 499 " \"reportingEntityId\"," 502 " \"localIpAddress\"," 504 " \"remoteIpAddress\"," 508 " \"eventDomain\": \"signaling\"" 517 json_size += snprintf(
518 json_buffer + json_size,
519 MAX_JSON - json_size,
521 " \"commandList\": [" 524 " \"commandType\": \"throttlingSpecification\"," 525 " \"eventDomainThrottleSpecification\": {" 526 " \"suppressedNvPairsList\": [" 528 " \"nvPairFieldName\": \"additionalFields\"," 529 " \"suppressedNvPairNames\": [" 534 " \"suppressedFieldNames\": [" 535 " \"reportingEntityId\"," 539 " \"eventDomain\": \"stateChange\"" 548 json_size += snprintf(
549 json_buffer + json_size,
550 MAX_JSON - json_size,
552 " \"commandList\": [" 555 " \"commandType\": \"throttlingSpecification\"," 556 " \"eventDomainThrottleSpecification\": {" 557 " \"suppressedNvPairsList\": [" 559 " \"nvPairFieldName\": \"additionalFields\"," 560 " \"suppressedNvPairNames\": [" 566 " \"suppressedFieldNames\": [" 567 " \"syslogFacility\"," 571 " \"eventDomain\": \"syslog\"" 580 json_size += snprintf(
581 json_buffer + json_size,
582 MAX_JSON - json_size,
584 " \"commandList\": [" 587 " \"commandType\": \"provideThrottlingState\"" 619 const int MAX_JSON = 10000;
620 char json_buffer[MAX_JSON];
625 json_size += snprintf(
626 json_buffer + json_size,
627 MAX_JSON - json_size,
628 "{\"commandList\": [{\"command\": " 629 "{\"commandType\": \"measurementIntervalChange\", " 630 "\"measurementInterval\": %d}}]}",
A chunk of memory used in the cURL functions.
Utility to post test control commands to the test_collector testControl API.
void evel_test_control_scenario(const EVEL_TEST_CONTROL_SCENARIO scenario, const int secure, const char *fqdn, const int port)
POST a pre-set test scenario to the test_collector testControl API.
void evel_test_control(char *const json_buffer, const int json_size, const int secure, const char *fqdn, const int port)
POST provide JSON to the test_collector testControl API.
#define EVEL_API_MAJOR_VERSION
void evel_test_control_meas_interval(const int interval, const int secure, const char *fqdn, const int port)
POST a measurement interval change to the test_collector testControl API.
#define EVEL_API_MINOR_VERSION
EVEL internal definitions.
EVEL_TEST_CONTROL_SCENARIO