Posted on August 16, 2015 10:47 pm
 |  Asked by Alessandro Carpi
 |  497 views
RESOLVED
0
0
Print Friendly, PDF & Email

<I posted this question earlier but seems like was not logged in, and cannot find my querry, so posting again>

Hi,

I am trying to use EosSdk to get notifications when a route  gets added/removed. I was expecting to see on_route_set/del or on_fec_set/del notifications when I add/remove a static route, not no luck. I can see the interface notification when interface status goes up/down using the following script. Can someone please help if there is anything wrong in the way I am registering for notifictions, or if I need to enable something else:

class proxy_reactor : public eos::agent_handler,
public eos::intf_handler,
public eos::fib_handler,
public eos::ip_intf_handler {
public:
eos::tracer t;
explicit proxy_reactor(eos::sdk & sdk) : eos::agent_handler(sdk.get_agent_mgr()),
eos::intf_handler(sdk.get_intf_mgr()),
eos::fib_handler(sdk.get_fib_mgr()),
eos::ip_intf_handler(sdk.get_ip_intf_mgr()),
t(“EosProxySdkAgent”) {
watch_all_intfs(true);
watch_all_ip_intfs(true);
}

void on_oper_status(eos::intf_id_t intf, eos::oper_status_t status) {
t.trace0(“Intf status changed for intf %s to state %d”, intf.to_string().c_str(), status);
}

void on_route_set(eos::fib_route_t route) {
t.trace0( “route added” );
}

void on_route_del(eos::fib_route_key_t route) {
t.trace0( “route deleted” );
}

void on_fec_set(eos::fib_fec_t fec) {
t.trace0( “fec added” );
}

void on_fec_del(eos::fib_fec_key_t fec) {
t.trace0( “fec deleted” );
}

};

int main(int argc, char **argv) {
eos::sdk sdk;
proxy_reactor agent(sdk);
sdk.main_loop(argc, argv);
}

0
Answered on August 16, 2015 10:49 pm
By default, get_fib_mgr has the mode defined as MODE_TYPE_READ_ONLY. This will not generate notifications. MODE_TYPE_READ_ONLY is like a passive reader.
We need to call get_fib_mgr with mode as MODE_TYPE_READ_NOTIFYING.
Also, there was a bug where mgr_mode_type_t values are not accessible from swig (this is fixed in version 1.6.0). However, the work around of passing the value as integer will work (get_fib_mgr(1)).

Thanks Navdeep, that worked very well!

(Alessandro Carpi at August 17, 2015 6:52 pm)

Post your Answer

You must be logged in to post an answer.