コード例 #1
0
/**
 * Event subscribe handler.
 *
 * @param msg Received message.
 * @param ec Error Code.
 */
void mih_user::event_subscribe_response(odtone::mih::message& msg, const boost::system::error_code& ec)
{
    log_(0, __FUNCTION__, "(", msg.tid(), ")");

    if (ec) {
        log_(0, __FUNCTION__, " error: ", ec.message());
        return;
    }

    odtone::mih::status st;

    msg >> odtone::mih::response()
        & odtone::mih::tlv_status(st);

    log_(0, "status: ", st.get());
}
コード例 #2
0
ファイル: link_sap.cpp プロジェクト: columbia-irt/manhattan
/**
 * 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);
		}
	}
}