beautypg.com

Sun Microsystems Netra CP2500 User Manual

Page 27

background image

Chapter 1

Watchdog Timer

13

}

return (err);

}

/*

* This function is the callback function that gets called

* due to picl_walk_tree_by_class call from set_wd_params function.

* This function checks if the given controller node has the watchdog-timer

* of interest and then changes the timeout and action of that timer.

*/

static int

wd_set_params(picl_nodehdl_t nodeh, void *args)

{

int err = PICL_SUCCESS;

char *ptr = NULL;

char cntrl_name[PICL_PROPNAMELEN_MAX];

char wd_name[PICL_PROPNAMELEN_MAX];

picl_nodehdl_t childh, peerh;

wdadm_args_t *wd_arg = NULL;

char *status = NULL;

wd_arg = (wdadm_args_t *)args;

if (wd_arg == NULL || wd_arg->name == NULL)

return (PICL_WALK_TERMINATE);

/* get the name of the controller */

err = picl_get_propval_by_name(nodeh, PICL_PROP_NAME,

(void *)cntrl_name, PICL_PROPNAMELEN_MAX);

if (err != PICL_SUCCESS) {

print_errmsg(gettext(err_msg[EM_GETPVALBYNAME]),

picl_strerror(err));

return (err);

}

/*

* name is of cntrl:node_name format (user input)

* do the parsing to extract controller name and watchdog-timer

* name

*/

ptr = strchr(wd_arg->name, ’:’);

if (ptr == NULL) {

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

prog, picl2errno(PICL_NODENOTFOUND));

return (PICL_NODENOTFOUND);

}

/* check if the controller is of interest */

CODE EXAMPLE 1-1

System Watchdog Node Management Code Example (Continued)