Exemplo n.º 1
0
static void
sensor_set_hysteresis(ipmi_sensor_t *sensor, void *cb_data)
{
    ipmi_cmd_info_t    *cmd_info = cb_data;
    ipmi_cmdlang_t     *cmdlang = ipmi_cmdinfo_get_cmdlang(cmd_info);
    int                rv;
    int                curr_arg = ipmi_cmdlang_get_curr_arg(cmd_info);
    int                argc = ipmi_cmdlang_get_argc(cmd_info);
    char               **argv = ipmi_cmdlang_get_argv(cmd_info);
    int                pos, neg;

    if ((argc - curr_arg) < 2) {
	/* Not enough parameters */
	cmdlang->errstr = "Not enough parameters";
	cmdlang->err = EINVAL;
	goto out_err;
    }

    ipmi_cmdlang_get_int(argv[curr_arg], &pos, cmd_info);
    if (cmdlang->err) {
	cmdlang->errstr = "Invalid positive hysteresis";
	goto out_err;
    }
    curr_arg++;

    ipmi_cmdlang_get_int(argv[curr_arg], &neg, cmd_info);
    if (cmdlang->err) {
	cmdlang->errstr = "Invalid negative hysteresis";
	goto out_err;
    }
    curr_arg++;

    ipmi_cmdlang_cmd_info_get(cmd_info);
    rv = ipmi_sensor_set_hysteresis(sensor, pos, neg,
				    sensor_set_hysteresis_done, cmd_info);
    if (rv) {
	ipmi_cmdlang_cmd_info_put(cmd_info);
	cmdlang->err = rv;
	cmdlang->errstr = "Error setting hysteresis";
	goto out_err;
    }

 out_err:
    ipmi_sensor_get_name(sensor, cmdlang->objstr,
			 cmdlang->objstr_len);
    cmdlang->location = "cmd_sensor.c(sensor_set_hysteresis)";
}
Exemplo n.º 2
0
static void
solparm_new(ipmi_mc_t *mc, void *cb_data)
{
    ipmi_cmd_info_t *cmd_info = cb_data;
    ipmi_cmdlang_t  *cmdlang = ipmi_cmdinfo_get_cmdlang(cmd_info);
    int             channel;
    int             rv;
    int             curr_arg = ipmi_cmdlang_get_curr_arg(cmd_info);
    int             argc = ipmi_cmdlang_get_argc(cmd_info);
    char            **argv = ipmi_cmdlang_get_argv(cmd_info);
    ipmi_solparm_t  *solparm;
    char            solparm_name[IPMI_SOLPARM_NAME_LEN];

    if ((argc - curr_arg) < 1) {
	/* Not enough parameters */
	cmdlang->errstr = "Not enough parameters";
	cmdlang->err = EINVAL;
	goto out_err;
    }

    ipmi_cmdlang_get_int(argv[curr_arg], &channel, cmd_info);
    if (cmdlang->err) {
	cmdlang->errstr = "channel invalid";
	goto out_err;
    }
    curr_arg++;

    rv = ipmi_solparm_alloc(mc, channel, &solparm);
    if (rv) {
	cmdlang->errstr = "Error from ipmi_solparm_alloc";
	cmdlang->err = rv;
	goto out_err;
    }

    ipmi_solparm_get_name(solparm, solparm_name, sizeof(solparm_name));
    ipmi_cmdlang_out(cmd_info, "SOLPARM", solparm_name);

    return;

 out_err:
    ipmi_mc_get_name(mc, cmdlang->objstr,
		     cmdlang->objstr_len);
    cmdlang->location = "cmd_solparm.c(solparm_new)";
}
Exemplo n.º 3
0
static void
sensor_set_thresholds(ipmi_sensor_t *sensor, void *cb_data)
{
    ipmi_cmd_info_t    *cmd_info = cb_data;
    ipmi_cmdlang_t     *cmdlang = ipmi_cmdinfo_get_cmdlang(cmd_info);
    int                rv;
    int                curr_arg = ipmi_cmdlang_get_curr_arg(cmd_info);
    int                argc = ipmi_cmdlang_get_argc(cmd_info);
    char               **argv = ipmi_cmdlang_get_argv(cmd_info);
    ipmi_thresholds_t  *th = NULL;
    enum ipmi_thresh_e thresh;
    double             val;

    if ((argc - curr_arg) < 1) {
	/* Not enough parameters */
	cmdlang->errstr = "Not enough parameters";
	cmdlang->err = EINVAL;
	goto out_err;
    }

    th = ipmi_mem_alloc(ipmi_thresholds_size());
    if (!th) {
	cmdlang->errstr = "Out of memory";
	cmdlang->err = ENOMEM;
	goto out_err;
    }
    ipmi_thresholds_init(th);
    while (curr_arg < argc) {
	ipmi_cmdlang_get_threshold(argv[curr_arg], &thresh, cmd_info);
	if (cmdlang->err) {
	    cmdlang->errstr = "Invalid threshold";
	    goto out_err;
	}
	curr_arg++;

	ipmi_cmdlang_get_double(argv[curr_arg], &val, cmd_info);
	if (cmdlang->err) {
	    cmdlang->errstr = "Invalid threshold value";
	    goto out_err;
	}
	curr_arg++;

	rv = ipmi_threshold_set(th, sensor, thresh, val);
	if (rv) {
	    cmdlang->errstr = "Error setting value";
	    cmdlang->err = rv;
	    goto out_err;
	}
    }

    ipmi_cmdlang_cmd_info_get(cmd_info);
    rv = ipmi_sensor_set_thresholds(sensor, th, sensor_set_thresholds_done,
				    cmd_info);
    if (rv) {
	ipmi_cmdlang_cmd_info_put(cmd_info);
	cmdlang->err = rv;
	cmdlang->errstr = "Error setting thresholds";
	goto out_err;
    }
    ipmi_mem_free(th);
    return;

 out_err:
    ipmi_sensor_get_name(sensor, cmdlang->objstr,
			 cmdlang->objstr_len);
    cmdlang->location = "cmd_sensor.c(sensor_set_thresholds)";
    if (th)
	ipmi_mem_free(th);
}
Exemplo n.º 4
0
static void
sensor_rearm(ipmi_sensor_t *sensor, void *cb_data)
{
    ipmi_cmd_info_t    *cmd_info = cb_data;
    ipmi_cmdlang_t     *cmdlang = ipmi_cmdinfo_get_cmdlang(cmd_info);
    int                rv;
    int                curr_arg = ipmi_cmdlang_get_curr_arg(cmd_info);
    int                argc = ipmi_cmdlang_get_argc(cmd_info);
    char               **argv = ipmi_cmdlang_get_argv(cmd_info);
    int                global;
    ipmi_event_state_t *s = NULL;

    if ((argc - curr_arg) < 1) {
	cmdlang->errstr = "Not enough parameters";
	cmdlang->err = EINVAL;
	goto out_err;
    }

    if (strcmp(argv[curr_arg], "global") == 0) {
	global = 1;
    } else {
	global = 0;
	s = ipmi_mem_alloc(ipmi_event_state_size());
	if (!s) {
	    cmdlang->errstr = "Out of memory";
	    cmdlang->err = ENOMEM;
	    goto out_err;
	}
	ipmi_event_state_init(s);

	if (ipmi_sensor_get_event_reading_type(sensor)
	    == IPMI_EVENT_READING_TYPE_THRESHOLD)
	{
	    enum ipmi_thresh_e          thresh;
	    enum ipmi_event_value_dir_e value_dir;
	    enum ipmi_event_dir_e       dir;

	    while (curr_arg < argc) {
		ipmi_cmdlang_get_threshold_ev(argv[curr_arg], &thresh,
					      &value_dir, &dir, cmd_info);
		if (cmdlang->err) {
		    goto out_err;
		}
		ipmi_threshold_event_set(s, thresh, value_dir, dir);
		curr_arg++;
	    }
	} else {
	    int                   offset;
	    enum ipmi_event_dir_e dir;
	    
	    while (curr_arg < argc) {
		ipmi_cmdlang_get_discrete_ev(argv[curr_arg], &offset,
					     &dir, cmd_info);
		if (cmdlang->err) {
		    goto out_err;
		}
		ipmi_discrete_event_set(s, offset, dir);
		curr_arg++;
	    }
	}
    }

    ipmi_cmdlang_cmd_info_get(cmd_info);
    rv = ipmi_sensor_rearm(sensor, global, s, sensor_rearm_done, cmd_info);
    if (rv) {
	ipmi_cmdlang_cmd_info_put(cmd_info);
	cmdlang->err = rv;
	cmdlang->errstr = "Error rearming sensor";
	goto out_err;
    }

    if (s)
	ipmi_mem_free(s);
    return;

 out_err:
    ipmi_sensor_get_name(sensor, cmdlang->objstr,
			 cmdlang->objstr_len);
    cmdlang->location = "cmd_sensor.c(sensor_rearm)";
    if (s)
	ipmi_mem_free(s);
}
Exemplo n.º 5
0
static void
mod_event_enables(ipmi_sensor_t *sensor, void *cb_data, enum ev_en_kind kind)
{
    ipmi_cmd_info_t    *cmd_info = cb_data;
    ipmi_cmdlang_t     *cmdlang = ipmi_cmdinfo_get_cmdlang(cmd_info);
    int                rv;
    int                curr_arg = ipmi_cmdlang_get_curr_arg(cmd_info);
    int                argc = ipmi_cmdlang_get_argc(cmd_info);
    char               **argv = ipmi_cmdlang_get_argv(cmd_info);
    ipmi_event_state_t *s = NULL;

    if ((argc - curr_arg) < 2) {
	/* Not enough parameters */
	cmdlang->errstr = "Not enough parameters";
	cmdlang->err = EINVAL;
	goto out_err;
    }

    s = ipmi_mem_alloc(ipmi_states_size());
    if (!s) {
	cmdlang->errstr = "Out of memory";
	cmdlang->err = ENOMEM;
	goto out_err;
    }
    ipmi_event_state_init(s);

    if (strcmp(argv[curr_arg], "msg") == 0)
	ipmi_event_state_set_events_enabled(s, 1);
    else if (strcmp(argv[curr_arg], "nomsg") == 0)
	ipmi_event_state_set_events_enabled(s, 0);
    else {
	cmdlang->errstr = "Invalid message enable setting";
	cmdlang->err = EINVAL;
	goto out_err;
    }
    curr_arg++;

    if (strcmp(argv[curr_arg], "scan") == 0)
	ipmi_event_state_set_scanning_enabled(s, 1);
    else if (strcmp(argv[curr_arg], "noscan") == 0)
	ipmi_event_state_set_scanning_enabled(s, 0);
    else {
	cmdlang->errstr = "Invalid scanning enable setting";
	cmdlang->err = EINVAL;
	goto out_err;
    }
    curr_arg++;

    if (ipmi_sensor_get_event_reading_type(sensor)
	== IPMI_EVENT_READING_TYPE_THRESHOLD)
    {
	while (curr_arg < argc) {
	    enum ipmi_thresh_e          thresh;
	    enum ipmi_event_value_dir_e value_dir;
	    enum ipmi_event_dir_e       dir;

	    ipmi_cmdlang_get_threshold_ev(argv[curr_arg], &thresh,
					  &value_dir, &dir, cmd_info);
	    if (cmdlang->err) {
		goto out_err;
	    }
	    ipmi_threshold_event_set(s, thresh, value_dir, dir);
	    curr_arg++;
	}
    } else {
	while (curr_arg < argc) {
	    int                   offset;
	    enum ipmi_event_dir_e dir;

	    ipmi_cmdlang_get_discrete_ev(argv[curr_arg], &offset,
					 &dir, cmd_info);
	    if (cmdlang->err) {
		goto out_err;
	    }
	    ipmi_discrete_event_set(s, offset, dir);
	    curr_arg++;
	}
    }

    ipmi_cmdlang_cmd_info_get(cmd_info);
    switch (kind) {
    case ev_en_set:
	rv = ipmi_sensor_set_event_enables(sensor, s,
					   sensor_set_event_enables_done,
					   cmd_info);
	break;
    case ev_en_enable:
	rv = ipmi_sensor_enable_events(sensor, s,
				       sensor_set_event_enables_done,
				       cmd_info);
	break;
    case ev_en_disable:
	rv = ipmi_sensor_disable_events(sensor, s,
					sensor_set_event_enables_done,
					cmd_info);
	break;
    default:
	rv = EINVAL;
    }

    if (rv) {
	ipmi_cmdlang_cmd_info_put(cmd_info);
	cmdlang->err = rv;
	cmdlang->errstr = "Error setting event enables";
	goto out_err;
    }
    ipmi_mem_free(s);
    return;

 out_err:
    ipmi_sensor_get_name(sensor, cmdlang->objstr,
			 cmdlang->objstr_len);
    cmdlang->location = "cmd_sensor.c(sensor_set_event_enables)";
    if (s)
	ipmi_mem_free(s);
}