diff options
author | Gokul Singaraju <goksing@gmail.com> | 2018-01-16 23:51:44 -0500 |
---|---|---|
committer | Gokul Singaraju <goksing@gmail.com> | 2018-01-16 23:52:02 -0500 |
commit | 39f35cca6560c97ecd719a13793ead184f6e7e3c (patch) | |
tree | 95e2a7906758f4998d978f54ced5d3da4d7e452f /vnfs/VES5.0/evel | |
parent | dd78035ca6b571302289636d7946321082371bdd (diff) |
Add ringbuffer size to API
Issue-ID: CERT-12
Change-Id: Ie698da815605d456f34ed05e4ef1ee11c994db86
Signed-Off-by: Gokul Singaraju <goksing@gmail.com>
Diffstat (limited to 'vnfs/VES5.0/evel')
5 files changed, 18 insertions, 0 deletions
diff --git a/vnfs/VES5.0/evel/evel-library/code/evel_library/evel.c b/vnfs/VES5.0/evel/evel-library/code/evel_library/evel.c index c6ead7ad..4e4383e4 100644 --- a/vnfs/VES5.0/evel/evel-library/code/evel_library/evel.c +++ b/vnfs/VES5.0/evel/evel-library/code/evel_library/evel.c @@ -89,6 +89,7 @@ EVEL_ERR_CODES evel_initialize(const char * const fqdn, int port, const char * const path, const char * const topic, + int ring_buf_size, int secure, const char * const cert_file_path, const char * const key_file_path, @@ -251,6 +252,7 @@ EVEL_ERR_CODES evel_initialize(const char * const fqdn, rc = event_handler_initialize(event_api_url, throt_api_url, source_ip, + ring_buf_size, secure, cert_file_path, key_file_path, diff --git a/vnfs/VES5.0/evel/evel-library/code/evel_library/evel.h b/vnfs/VES5.0/evel/evel-library/code/evel_library/evel.h index 119fa793..896dd9d1 100644 --- a/vnfs/VES5.0/evel/evel-library/code/evel_library/evel.h +++ b/vnfs/VES5.0/evel/evel-library/code/evel_library/evel.h @@ -1400,6 +1400,7 @@ typedef struct copyright { * @param port The API's port. * @param path The optional path (may be NULL). * @param topic The optional topic part of the URL (may be NULL). + * @param ring_buf_size Ring buffer size (>=100) ~ Avg Messages in 1hr * @param secure Whether to use HTTPS (0=HTTP, 1=HTTPS). * @param cert_file_path Path to client certificate file * @param key_file_path Path to client key file @@ -1423,6 +1424,7 @@ EVEL_ERR_CODES evel_initialize(const char * const fqdn, int port, const char * const path, const char * const topic, + int ring_buf_size, int secure, const char * const cert_file_path, const char * const key_file_path, diff --git a/vnfs/VES5.0/evel/evel-library/code/evel_library/evel_event.c b/vnfs/VES5.0/evel/evel-library/code/evel_library/evel_event.c index c9bb4345..5babb67c 100644 --- a/vnfs/VES5.0/evel/evel-library/code/evel_library/evel_event.c +++ b/vnfs/VES5.0/evel/evel-library/code/evel_library/evel_event.c @@ -621,6 +621,10 @@ int evel_json_encode_event(char * json, /* Sanity check. */ /***************************************************************************/ assert(jbuf->depth == 0); + if( jbuf->offset >= max_size ){ + EVEL_ERROR("Event exceeded size limit %d", max_size); + assert(0); + } EVEL_EXIT(); diff --git a/vnfs/VES5.0/evel/evel-library/code/evel_library/evel_event_mgr.c b/vnfs/VES5.0/evel/evel-library/code/evel_library/evel_event_mgr.c index 5c6ca4b3..d10543b0 100644 --- a/vnfs/VES5.0/evel/evel-library/code/evel_library/evel_event_mgr.c +++ b/vnfs/VES5.0/evel/evel-library/code/evel_library/evel_event_mgr.c @@ -115,6 +115,7 @@ static char * evel_batch_api_url; * @param[in] throt_api_url * The URL where the Throttling API is expected to be. * @param[in] source_ip Source IP of VES Agent + * @param[in] ring_buf_size Initial size of ring buffer * @param[in] secure Whether Using http or https * @param[in] cert_file_path Path to Client Certificate file * @param[in] key_file_path Path to Client key file @@ -130,6 +131,7 @@ static char * evel_batch_api_url; EVEL_ERR_CODES event_handler_initialize(const char * const event_api_url, const char * const throt_api_url, const char * const source_ip, + int ring_buf_size, int secure, const char * const cert_file_path, const char * const key_file_path, @@ -473,6 +475,12 @@ EVEL_ERR_CODES event_handler_initialize(const char * const event_api_url, /* Initialize a message ring-buffer to be used between the foreground and */ /* the thread which sends the messages. This can't fail. */ /***************************************************************************/ + if( ring_buf_size < EVEL_EVENT_BUFFER_DEPTH ) + { + log_error_state("Warning: Failed to initialize Ring buffer size to %d. " + ring_buf_size); + goto exit_label; + } ring_buffer_initialize(&event_buffer, EVEL_EVENT_BUFFER_DEPTH); /***************************************************************************/ diff --git a/vnfs/VES5.0/evel/evel-library/code/evel_library/evel_internal.h b/vnfs/VES5.0/evel/evel-library/code/evel_library/evel_internal.h index dd4b4b7c..d1a952b6 100644 --- a/vnfs/VES5.0/evel/evel-library/code/evel_library/evel_internal.h +++ b/vnfs/VES5.0/evel/evel-library/code/evel_library/evel_internal.h @@ -175,6 +175,7 @@ typedef struct evel_throttle_spec { * @param[in] throt_api_url * The URL where the Throttling API is expected to be. * @param[in] source_ip Source IP of VES Agent + * @param[in] ring_buf_size Initialization size of Ring Buffer * @param[in] secure Whether Using http or https * @param[in] cert_file_path Path to Client Certificate file * @param[in] key_file_path Path to Client key file @@ -190,6 +191,7 @@ typedef struct evel_throttle_spec { EVEL_ERR_CODES event_handler_initialize(const char * const event_api_url, const char * const throt_api_url, const char * const source_ip, + int ring_buf_size, int secure, const char * const cert_file_path, const char * const key_file_path, |