Skip to content

Commit 18d9d69

Browse files
AdamZvarasedmicha
authored andcommitted
Modifier: work with value returned from callback
1 parent d6af1ba commit 18d9d69

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

include/ipfixcol2/modifier.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ struct ipx_modifier_output {
5454
* \note output size is equal to number of new fields
5555
* \note Any non-negative value in output[i].length means that
5656
* data in output at given position is valid and will be appended to IPFIX message
57-
* \return #IPX_OK if function was successfull, otherwise any non-zero value
57+
* \return #IPX_OK if function was successfull, #IPX_ERR_DENIED if modification can not continue
5858
*/
5959
typedef int (*modifier_adder_cb_t)(const struct fds_drec *rec,
6060
struct ipx_modifier_output output[], void *cb_data);

src/core/modifier.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1090,7 +1090,11 @@ ipx_modifier_modify(ipx_modifier_t *mod, const struct fds_drec *rec, ipx_msg_gar
10901090
output_buffers_init(buffers, mod->fields_cnt);
10911091
if (mod->cb_adder) {
10921092
// Call adder callback to fill output buffers
1093-
mod->cb_adder(rec, buffers, mod->cb_data);
1093+
int cb_rc = mod->cb_adder(rec, buffers, mod->cb_data);
1094+
if (cb_rc != IPX_OK) {
1095+
MODIFIER_ERROR(mod, "Callback function returned error code %d", cb_rc);
1096+
return NULL;
1097+
}
10941098
}
10951099

10961100
// Update template based on modified configuration

src/plugins/intermediate/asn/asn.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ process_ipfix(ipx_ctx_t *ctx, ipx_modifier_t *modifier, ipx_msg_builder_t *build
418418
}
419419
if (!modified_rec) {
420420
// Proper message has been already printed
421-
return rc;
421+
return IPX_ERR_DENIED;
422422
}
423423

424424
// Store modified record in builder

src/plugins/intermediate/geoip/geoip.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ process_ipfix(ipx_ctx_t *ctx, ipx_modifier_t *modifier, ipx_msg_builder_t *build
519519
}
520520
if (!modified_rec) {
521521
// Proper message has been already printed
522-
return rc;
522+
return IPX_ERR_DENIED;
523523
}
524524

525525
// Store modified record in builder

0 commit comments

Comments
 (0)