/** * Default MIH event handler. * * @param msg Received message. * @param ec Error code. */ void mih_user::event_handler(odtone::mih::message& msg, const boost::system::error_code& ec) { if (ec) { log_(0, __FUNCTION__, " error : ", ec.message()); send_link_get_parameters_request(); return; } odtone::mih::link_tuple_id li; msg >> odtone::mih::indication() & odtone::mih::tlv_link_identifier(li); odtone::mih::mac_addr mac = boost::get<odtone::mih::mac_addr>(li.addr); odtone::mih::link_type type = boost::get<odtone::mih::link_type>(li.type); switch (msg.mid()) { case odtone::mih::indication::link_up: log_(0, "MIH-User has received a local event \"link_up\""); this->links.add_interface(mac,type); break; case odtone::mih::indication::link_down: log_(0, "MIH-User has received a local event \"link_down\""); this->links.remove_interface(mac); break; case odtone::mih::indication::link_detected: log_(0, "MIH-User has received a local event \"link_detected\""); break; case odtone::mih::indication::link_going_down: log_(0, "MIH-User has received a local event \"link_going_down\""); break; case odtone::mih::indication::link_handover_imminent: log_(0, "MIH-User has received a local event \"link_handover_imminent\""); break; case odtone::mih::indication::link_handover_complete: log_(0, "MIH-User has received a local event \"link_handover_complete\""); break; default: log_(0, "MIH-User has received a local event \"unknown\""); break; } this->links.print_interfaces(); }
/** * Default MIH event handler. * * @param msg Received message. * @param ec Error code. */ void link_sap::default_handler(odtone::mih::message& msg, const boost::system::error_code& ec) { if (ec) return; odtone::mih::status st; switch (msg.mid()) { case odtone::mih::request::capability_discover: { odtone::mih::message m; // fill the status st = odtone::mih::status_success; m << odtone::mih::confirm(odtone::mih::confirm::capability_discover) & odtone::mih::tlv_status(st) & odtone::mih::tlv_link_evt_list(capabilities_event_list) & odtone::mih::tlv_link_cmd_list(capabilities_command_list); m.tid(msg.tid()); _mihf.async_send(m); } break; case odtone::mih::request::event_subscribe: { odtone::mih::link_evt_list events; msg >> odtone::mih::request() & odtone::mih::tlv_link_evt_list(events); odtone::mih::message m; // fill the status st = odtone::mih::status_success; m << odtone::mih::confirm(odtone::mih::confirm::event_subscribe) & odtone::mih::tlv_status(st) & odtone::mih::tlv_link_evt_list(events); m.tid(msg.tid()); _mihf.async_send(m); break; } case odtone::mih::request::event_unsubscribe: { odtone::mih::link_evt_list events; msg >> odtone::mih::request() & odtone::mih::tlv_link_evt_list(events); odtone::mih::message m; // fill the status st = odtone::mih::status_success; m << odtone::mih::confirm(odtone::mih::confirm::event_unsubscribe) & odtone::mih::tlv_status(st) & odtone::mih::tlv_link_evt_list(events); m.tid(msg.tid()); _mihf.async_send(m); break; } case odtone::mih::request::link_get_parameters: { odtone::mih::link_param_list lpl; odtone::mih::link_states_rsp_list lsrl; odtone::mih::link_desc_rsp_list ldrl; odtone::mih::message m; // fill the status st = odtone::mih::status_success; m << odtone::mih::confirm(odtone::mih::confirm::link_get_parameters) & odtone::mih::tlv_status(st) & odtone::mih::tlv_link_parameters_status_list(lpl) & odtone::mih::tlv_link_states_rsp(lsrl) & odtone::mih::tlv_link_descriptor_rsp(ldrl); m.tid(msg.tid()); _mihf.async_send(m); break; } case odtone::mih::request::link_configure_thresholds: { odtone::mih::link_cfg_param_list lcpl; msg >> odtone::mih::request() & odtone::mih::tlv_link_cfg_param_list(lcpl); odtone::mih::message m; // fill the status st = odtone::mih::status_failure; odtone::mih::link_cfg_status_list lcsl; m << odtone::mih::confirm(odtone::mih::confirm::link_configure_thresholds) & odtone::mih::tlv_status(st) & odtone::mih::tlv_link_cfg_status_list(lcsl); m.tid(msg.tid()); _mihf.async_send(m); break; } default: { odtone::mih::message m; st = odtone::mih::status_failure; m << odtone::mih::confirm(odtone::mih::confirm::capability_discover) & odtone::mih::tlv_status(st); _mihf.async_send(m); } } }
/** * Default MIH event handler. * * @param msg Received message. * @param ec Error code. */ void mih_user::event_handler(odtone::mih::message& msg, const boost::system::error_code& ec) { //yan-start-17/02/2012 //odtone::mih::message m; //m << odtone::mih::indication(odtone::mih::indication::link_get_parameters); //_mihf.sync_send(m); //yan-end if (ec) { log_(0, __FUNCTION__, " error: ", ec.message()); return; } //yan-start-17/02/2012 odtone::mih::link_tuple_id lid; odtone::mih::octet_string ifname; std::vector<link_info>::iterator it; std::vector<client_info>::iterator it_app; bool exist = false; msg >> odtone::mih::indication() & odtone::mih::tlv_link_identifier(lid); switch (msg.mid()) { case odtone::mih::indication::link_up: log_(0, "MIH-User has received a local event \"link_up\""); //log_(0, lid.addr); //_mihlid[_num_links] = lid; //++_num_links; exist = false; for (it = _mihlnks.begin(); it != _mihlnks.end(); ++it) { if (it->lid() == lid) { exist = true; break; } } if (!exist) { ifname = mih_get_ifname(lid); _mihlnks.push_back(link_info(lid, ifname)); for (it_app = _applist.begin(); it_app != _applist.end(); ++it_app) { //notify the applications that interface change occurs it_app->send_msg(_sockfd, ""); } } break; case odtone::mih::indication::link_down: log_(0, "MIH-User has received a local event \"link_down\""); for (it = _mihlnks.begin(); it != _mihlnks.end(); ++it) { if (it->lid() == lid) { _mihlnks.erase(it); for (it_app = _applist.begin(); it_app != _applist.end(); ++it_app) { //notify the applications that interface change occurs it_app->send_msg(_sockfd, ""); } break; } } /*int i; for (i = 0; i < _num_links; ++i) { if (_mihlid[i] == lid) { --_num_links; break; } } for (i = i + 1; i <= _num_links; ++i) { _mihlid[i-1] = _mihlid[i]; }*/ break; //yan-end case odtone::mih::indication::link_detected: log_(0, "MIH-User has received a local event \"link_detected\""); break; case odtone::mih::indication::link_going_down: log_(0, "MIH-User has received a local event \"link_going_down\""); break; case odtone::mih::indication::link_handover_imminent: log_(0, "MIH-User has received a local event \"link_handover_imminent\""); break; case odtone::mih::indication::link_handover_complete: log_(0, "MIH-User has received a local event \"link_handover_complete\""); break; } }