static switch_status_t handle_msg_tuple(listener_t *listener, erlang_msg * msg, ei_x_buff * buf, ei_x_buff * rbuf) { char tupletag[MAXATOMLEN]; int arity; switch_status_t ret = SWITCH_STATUS_SUCCESS; ei_decode_tuple_header(buf->buff, &buf->index, &arity); if (ei_decode_atom(buf->buff, &buf->index, tupletag)) { ei_x_encode_tuple_header(rbuf, 2); ei_x_encode_atom(rbuf, "error"); ei_x_encode_atom(rbuf, "badarg"); } else { if (!strncmp(tupletag, "fetch_reply", MAXATOMLEN)) { ret = handle_msg_fetch_reply(listener, buf, rbuf); } else if (!strncmp(tupletag, "set_log_level", MAXATOMLEN)) { ret = handle_msg_set_log_level(listener, arity, buf, rbuf); } else if (!strncmp(tupletag, "event", MAXATOMLEN)) { ret = handle_msg_event(listener, arity, buf, rbuf); } else if (!strncmp(tupletag, "session_event", MAXATOMLEN)) { ret = handle_msg_session_event(listener, msg, arity, buf, rbuf); } else if (!strncmp(tupletag, "nixevent", MAXATOMLEN)) { ret = handle_msg_nixevent(listener, arity, buf, rbuf); } else if (!strncmp(tupletag, "session_nixevent", MAXATOMLEN)) { ret = handle_msg_session_nixevent(listener, msg, arity, buf, rbuf); } else if (!strncmp(tupletag, "api", MAXATOMLEN)) { ret = handle_msg_api(listener, msg, arity, buf, rbuf); } else if (!strncmp(tupletag, "bgapi", MAXATOMLEN)) { ret = handle_msg_bgapi(listener, msg, arity, buf, rbuf); } else if (!strncmp(tupletag, "sendevent", MAXATOMLEN)) { ret = handle_msg_sendevent(listener, arity, buf, rbuf); } else if (!strncmp(tupletag, "sendmsg", MAXATOMLEN)) { ret = handle_msg_sendmsg(listener, arity, buf, rbuf); } else if (!strncmp(tupletag, "bind", MAXATOMLEN)) { ret = handle_msg_bind(listener, msg, buf, rbuf); } else if (!strncmp(tupletag, "handlecall", MAXATOMLEN)) { ret = handle_msg_handlecall(listener, msg, arity, buf, rbuf); } else if (!strncmp(tupletag, "rex", MAXATOMLEN)) { ret = handle_msg_rpcresponse(listener, msg, arity, buf, rbuf); } else if (!strncmp(tupletag, "setevent", MAXATOMLEN)) { ret = handle_msg_setevent(listener, msg, arity, buf, rbuf); } else if (!strncmp(tupletag, "session_setevent", MAXATOMLEN)) { ret = handle_msg_session_setevent(listener, msg, arity, buf, rbuf); } else { ei_x_encode_tuple_header(rbuf, 2); ei_x_encode_atom(rbuf, "error"); ei_x_encode_atom(rbuf, "undef"); } } return ret; }
/* Function name: handler_report_event * * Purpose: * Start/stop profiling according to message and log events * * Input: IKGT Event Info * Return: response code in ikgt_event_info_t * */ void handler_report_event(ikgt_event_info_t *event_info) { /* log handler only profiling so allow all other actions by default */ event_info->response = IKGT_EVENT_RESPONSE_ALLOW; if (!g_b_init_status) return; /* memory events need special handling for agent */ switch (event_info->type) { case IKGT_EVENT_TYPE_MEM: handle_memory_event(event_info); break; case IKGT_EVENT_TYPE_CPU: handle_cpu_event(event_info); break; case IKGT_EVENT_TYPE_MSG: handle_msg_event(event_info); break; } }