@@ -155,6 +155,12 @@ stats_print(const struct instance_data *inst)
155155 printf ("- total packets: %10" PRIu64 "\n" , inst -> cnt_pkts );
156156}
157157
158+ uint64_t
159+ difftime_periodic (struct timespec start , struct timespec end )
160+ {
161+ return (end .tv_sec - start .tv_sec ) * 1000 + (end .tv_nsec - start .tv_nsec ) / 1000000 ;
162+ }
163+
158164int
159165ipx_plugin_init (ipx_ctx_t * ctx , const char * params )
160166{
@@ -172,7 +178,7 @@ ipx_plugin_init(ipx_ctx_t *ctx, const char *params)
172178 ipx_ctx_private_set (ctx , data );
173179
174180 // Subscribe to receive IPFIX messages and Transport Session events
175- uint16_t new_mask = IPX_MSG_IPFIX | IPX_MSG_SESSION ;
181+ uint16_t new_mask = IPX_MSG_IPFIX | IPX_MSG_SESSION | IPX_MSG_PERIODIC ;
176182 ipx_ctx_subscribe (ctx , & new_mask , NULL );
177183 return IPX_OK ;
178184}
@@ -197,6 +203,15 @@ ipx_plugin_process(ipx_ctx_t *ctx, void *cfg, ipx_msg_t *msg)
197203 struct instance_data * data = (struct instance_data * ) cfg ;
198204
199205 int type = ipx_msg_get_type (msg );
206+
207+ if (type == IPX_MSG_PERIODIC ) {
208+ ipx_msg_periodic_t * periodic_message = ipx_msg_base2periodic (msg );
209+ IPX_CTX_INFO (ctx , "Periodic message %lu: %lu ms" ,
210+ ipx_msg_periodic_get_seq_num (periodic_message ),
211+ difftime_periodic (ipx_msg_periodic_get_created (periodic_message ),
212+ ipx_msg_periodic_get_last_processed (periodic_message )));
213+ }
214+
200215 if (type == IPX_MSG_IPFIX ) {
201216 // Process IPFIX message
202217 ipx_msg_ipfix_t * ipfix_msg = ipx_msg_base2ipfix (msg );
0 commit comments