src/sflow.c
static void sfwb_changed(SFWB *sm)
{
    if(!sfwb_config_valid(sm->config_manager)) {
        return;
    }

    /* create or re-create the agent */
    if(sm->agent) {
        sfl_agent_release(sm->agent);
    }
    
    sm->agent = (SFLAgent *)calloc(1, sizeof(SFLAgent));
    
    uint16_t servicePort = lowestActiveListenPort(sm);

    /* initialize the agent with it's address, bootime, callbacks etc. */
    sfl_agent_init(sm->agent,
                   sfwb_config_agentIP(sm->config_manager),
                   servicePort, /* subAgentId */
                   sm->currentTime,
                   sm->currentTime,
                   sm,
                   sfwb_cb_alloc,
                   sfwb_cb_free,
                   sfwb_cb_error,
                   sfwb_cb_sendPkt);
    
    /* add a receiver */
    sm->receiver = sfl_agent_addReceiver(sm->agent);
    sfl_receiver_set_sFlowRcvrOwner(sm->receiver, "httpd sFlow Probe");
    sfl_receiver_set_sFlowRcvrTimeout(sm->receiver, 0xFFFFFFFF);
    
    /* no need to configure the receiver further, because we are */
    /* using the sendPkt callback to handle the forwarding ourselves. */
    
    /* add a <logicalEntity> datasource to represent this application instance */
    SFLDataSource_instance dsi;
    /* ds_class = <logicalEntity>, ds_index = <lowest service port>, ds_instance = 0 */
    SFL_DS_SET(dsi, SFL_DSCLASS_LOGICAL_ENTITY, servicePort, 0);
    
    /* add a poller for the counters */
    sm->poller = sfl_agent_addPoller(sm->agent, &dsi, sm, sfwb_cb_counters);
    sfl_poller_set_sFlowCpInterval(sm->poller, sfwb_config_polling_secs(sm->config_manager));
    sfl_poller_set_sFlowCpReceiver(sm->poller, 1 /* receiver index == 1 */);
    
    /* add a sampler for the sampled operations */
    sm->sampler = sfl_agent_addSampler(sm->agent, &dsi);
    sfl_sampler_set_sFlowFsPacketSamplingRate(sm->sampler, sfwb_config_sampling_n(sm->config_manager));
    sfl_sampler_set_sFlowFsReceiver(sm->sampler, 1 /* receiver index == 1 */);
    
    /* we're going to handle the skip countdown ourselves, so initialize it here */
    sm->sflow_skip = 0;
    add_random_skip(sm);
}
/*_________________---------------------------__________________
  _________________       sfwb_changed        __________________
  -----------------___________________________------------------

The config changed - build/rebuild the sFlow agent
*/


The config changed - build/rebuild the sFlow agent
The config changed - build / rebuild the sFlow agent
static void sfwb_changed(SFWB *sm)
{
    if(!sfwb_config_valid(sm->config_manager)) {
        return;
    }
    if(sm->agent) {
        sfl_agent_release(sm->agent);
    }
    sm->agent = (SFLAgent *)calloc(1, sizeof(SFLAgent));
    uint16_t servicePort = lowestActiveListenPort(sm);
    sfl_agent_init(sm->agent,
                   sfwb_config_agentIP(sm->config_manager),
                   servicePort, 
                   sm->currentTime,
                   sm->currentTime,
                   sm,
                   sfwb_cb_alloc,
                   sfwb_cb_free,
                   sfwb_cb_error,
                   sfwb_cb_sendPkt);
    sm->receiver = sfl_agent_addReceiver(sm->agent);
    sfl_receiver_set_sFlowRcvrOwner(sm->receiver, "httpd sFlow Probe");
    sfl_receiver_set_sFlowRcvrTimeout(sm->receiver, 0xFFFFFFFF);
    SFLDataSource_instance dsi;
    SFL_DS_SET(dsi, SFL_DSCLASS_LOGICAL_ENTITY, servicePort, 0);
    sm->poller = sfl_agent_addPoller(sm->agent, &dsi, sm, sfwb_cb_counters);
    sfl_poller_set_sFlowCpInterval(sm->poller, sfwb_config_polling_secs(sm->config_manager));
    sfl_poller_set_sFlowCpReceiver(sm->poller, 1 );
    sm->sampler = sfl_agent_addSampler(sm->agent, &dsi);
    sfl_sampler_set_sFlowFsPacketSamplingRate(sm->sampler, sfwb_config_sampling_n(sm->config_manager));
    sfl_sampler_set_sFlowFsReceiver(sm->sampler, 1 );
    sm->sflow_skip = 0;
    add_random_skip(sm);
}
static void sfwb_changed ( SFWB * sm ) { if ( ! sfwb_config_valid ( sm -> config_manager ) ) { return ; } if ( sm -> agent ) { sfl_agent_release ( sm -> agent ) ; } sm -> agent = ( SFLAgent * ) calloc ( 1 , sizeof ( SFLAgent ) ) ; uint16_t servicePort = lowestActiveListenPort ( sm ) ; sfl_agent_init ( sm -> agent , sfwb_config_agentIP ( sm -> config_manager ) , servicePort , sm -> currentTime , sm -> currentTime , sm , sfwb_cb_alloc , sfwb_cb_free , sfwb_cb_error , sfwb_cb_sendPkt ) ; sm -> receiver = sfl_agent_addReceiver ( sm -> agent ) ; sfl_receiver_set_sFlowRcvrOwner ( sm -> receiver , " " ) ; sfl_receiver_set_sFlowRcvrTimeout ( sm -> receiver , 0xFFFFFFFF ) ; SFLDataSource_instance dsi ; SFL_DS_SET ( dsi , SFL_DSCLASS_LOGICAL_ENTITY , servicePort , 0 ) ; sm -> poller = sfl_agent_addPoller ( sm -> agent , & dsi , sm , sfwb_cb_counters ) ; sfl_poller_set_sFlowCpInterval ( sm -> poller , sfwb_config_polling_secs ( sm -> config_manager ) ) ; sfl_poller_set_sFlowCpReceiver ( sm -> poller , 1 ) ; sm -> sampler = sfl_agent_addSampler ( sm -> agent , & dsi ) ; sfl_sampler_set_sFlowFsPacketSamplingRate ( sm -> sampler , sfwb_config_sampling_n ( sm -> config_manager ) ) ; sfl_sampler_set_sFlowFsReceiver ( sm -> sampler , 1 ) ; sm -> sflow_skip = 0 ; add_random_skip ( sm ) ; }
_________________---------------------------__________________
_________________       sfwb_changed        __________________
___________________________
_________________ --------------------------- __________________ _________________ sfwb_changed __________________ ___________________________
/* create or re-create the agent */ /* initialize the agent with it's address, bootime, callbacks etc. */ /* subAgentId */ /* add a receiver */ /* no need to configure the receiver further, because we are */ /* using the sendPkt callback to handle the forwarding ourselves. */ /* add a <logicalEntity> datasource to represent this application instance */ /* ds_class = <logicalEntity>, ds_index = <lowest service port>, ds_instance = 0 */ /* add a poller for the counters */ /* receiver index == 1 */ /* add a sampler for the sampled operations */ /* receiver index == 1 */ /* we're going to handle the skip countdown ourselves, so initialize it here */