CODE EXAMPLE 1-1System Watchdog Node Management Code Example (Continued)

ptr = strchr(wd_name, ’:’);

if (ptr == NULL) { /* invalid format */

(void) fprintf(stderr, "%s:Node not found:%d\n", prog, picl2errno(PICL_NODENOTFOUND));

return (PICL_NODENOTFOUND);

}

wd_arg.name = wd_name; wd_arg.action = action; wd_arg.error_code = 0; if (timeout) {

errno = 0;

wd_arg.timeout = strtol(timeout, NULL, 10); if (errno != 0) {

(void) fprintf(stderr, "%s:Illegal timeout value\n", prog);

return (PICL_INVALIDARG);

}

} else {

wd_arg.timeout = ILLEGAL_TIMEOUT; /* need not program timeout */

}

err = picl_walk_tree_by_class(rooth, PICL_WATCHDOG_CONTROLLER, (void *)&wd_arg, wd_set_params);

return (err);

}

/*

*This is the callback function that gets called due to

*picl_walk_tree_by_class function call from control_wd function.

*This function is used to arm/disarm the watchdog controller.

*/

static int

wd_change_state(picl_nodehdl_t nodeh, void *arg)

{

int err = PICL_SUCCESS;

char cntrl_name[PICL_PROPNAMELEN_MAX];

wdadm_args_t *wd_arg = NULL;

wd_arg = (wdadm_args_t *)arg;

if (wd_arg == NULL wd_arg->name == NULL) return (PICL_WALK_TERMINATE);

err = picl_get_propval_by_name(nodeh, PICL_PROP_NAME, (void *)cntrl_name, PICL_PROPNAMELEN_MAX);

if (err != PICL_SUCCESS) {

16 Netra CP2500 Board Programming Guide • March 2007

Page 30
Image 30
Sun Microsystems CP2500 manual Code Example 1-1System Watchdog Node Management Code Example