Add function to send TRAP over Control Interface

Change-Id: Ic0b8d88c4f5c4d42c3f8fb754f8eabf049c9e388
Related: OS#1646
This commit is contained in:
Max 2016-08-04 11:07:08 +02:00
parent 530736f315
commit bc067eb0a2
2 changed files with 22 additions and 0 deletions

View File

@ -20,6 +20,7 @@ struct ctrl_handle {
int ctrl_cmd_send(struct osmo_wqueue *queue, struct ctrl_cmd *cmd);
int ctrl_cmd_send_trap(struct ctrl_handle *ctrl, const char *name, char *value);
struct ctrl_handle *ctrl_interface_setup(void *data, uint16_t port,
ctrl_cmd_lookup lookup);
struct ctrl_handle *ctrl_interface_setup_dynip(void *data,

View File

@ -117,6 +117,27 @@ int ctrl_cmd_send(struct osmo_wqueue *queue, struct ctrl_cmd *cmd)
return ret;
}
/*! \brief Send TRAP over given Control Interface
* \param[in] ctrl Control Interface over which TRAP will be sent
* \param[in] name Name of the TRAP variable
* \param[in] value Value of the TRAP variable
* \return Negative value on error, result of ctrl_cmd_send_to_all() otherwise
*/
int ctrl_cmd_send_trap(struct ctrl_handle *ctrl, const char *name, char *value)
{
int r;
struct ctrl_cmd *cmd = ctrl_cmd_create(NULL, CTRL_TYPE_TRAP);
if (!cmd)
return -ENOMEM;
cmd->id = "0"; /* It's a TRAP! */
cmd->variable = name;
cmd->reply = value;
r = ctrl_cmd_send_to_all(ctrl, cmd);
talloc_free(cmd);
return r;
}
struct ctrl_cmd *ctrl_cmd_trap(struct ctrl_cmd *cmd)
{
struct ctrl_cmd *trap;