<!DOCTYPE doctype PUBLIC "-//w3c//dtd html 4.0 transitional//en"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>HEARTBEAT API</title> </head> <body> <h1>HEARTBEAT API</h1> <h1>Introduction:</h1> <font size="+1" face="Arial,Helvetica"><b>This document describes the application program interface for heartbeat. The following are the interfaces available for heartbeat</b>.</font> <ol> <li> <b><font color="#3333ff"><font size="+2"><a href="#ll_cluster_new%28%29">ll_cluster_new()</a></font></font></b></li> <li> <b><font size="+2"><a href="#signon%28%29">singon()</a></font></b></li> <li> <b><font size="+2"><a href="#signoff%28%29">signoff()</a></font></b></li> <li> <b><font size="+2"><a href="#delete%28%29">delete()</a></font></b></li> <li> <b><font size="+2"><a href="#set_msg_callback%28%29">set_msg_callback()</a></font></b></li> <li> <b><font size="+2"><a href="#set_nstatus_callback%28%29">set_nstatus_callback()</a></font></b></li> <li> <b><font size="+2"><a href="#set_ifstatus_callback%28%29">set _ifstatus_callback()</a></font></b></li> <li> <b><font size="+2"><a href="#init_nodewalk%28%29">init_nodewalk()</a></font></b></li> <li> <b><font size="+2"><a href="#nextnode%28%29">nextnode()</a></font></b></li> <li> <b><font size="+2"><a href="#end_nodewalk%28%29">end_nodewalk()</a></font></b></li> <li> <b><font size="+2"><a href="#init_ifwalk%28%29">init_ifwalk()</a></font></b></li> <li> <b><font size="+2"><a href="#nextif%28ll_cluster_t%20*cinfo%29">nextif()</a></font></b></li> <li> <b><font size="+2"><a href="#end_ifwalk%28%29">end_ifwalk()</a></font></b></li> <li> <b><font size="+2"><a href="#if_status%28%29">if_status()</a></font></b></li> <li> <b><font size="+2"><a href="#sendclustermsg%28%29">sendclustermsg()</a></font></b></li> <li> <b><font size="+2"><a href="#sendnodemsg%28%29">sendnodemsg()</a></font></b></li> <li> <b><font size="+2"><a href="#inputfd%28%29">inputfd()</a></font></b></li> <li> <b><font size="+2"><a href="#msgready%28%29">msgready()</a></font></b></li> <li> <b><font size="+2"><a href="#setmsgsignal%28%29">setmsgsignal()</a></font></b></li> <li> <b><font size="+2"><a href="#rcvmsg%28%29">rcvmsg()</a></font></b></li> <li> <b><font size="+2"><a href="#readmsg%28%29">readmsg()</a></font></b></li> <li> <b><font size="+2"><a href="#setfmode%28%29">setfmode()</a></font></b></li> <li><a href="#get_parameter"><b><font color="blue"><big><big>get_parameter()</big></big></font></b></a></li> <li><a href="#get_deadtime"><b><font color="blue"><big><big>get_deadtime()</big></big></font></b></a><br> </li> <li><a href="#get_keepalive"><b><font color="blue"><big><big>get_keepalive()</big></big></font></b></a></li> <li><a href="#get_mynodeid"><b><font color="blue"><big><big>get_mynodeid()</big></big></font></b></a><br> </li> <li><a href="#get_logfacility"><b><font color="blue"><big><big>get_logfacility()</big></big></font></b></a></li> <li><a href="#get_resources"><b><font color="blue"><big><big>get_resources()</big></big></font></b></a><br> </li> <li><b><font size="+2"><a href="#errmsg%28%29">errmsg()</a></font></b></li> </ol> <h1>Description:</h1> <b>The details of each of the api functions are as follows:</b> <h2><a name="ll_cluster_new()"><b><font size="+2">ll_cluster_new()</font></b></a></h2> <i><font color="#3333ff"><font size="+2"> ll_cluster_t *ll_cluster_new(const char *type)</font></font></i> <dl> <dt><font color="#ff0000"><i><font size="+1">Parameter description</font></i>:</font></dt> <dd>'<i><font color="#cc33cc">type</font></i>' identifies the service provider. It's value must currently be "heartbeat". </dd> <dt><i><font size="+1"><font color="#ff0000">Description</font>:</font></i></dt> <dd> Register with the heartbeat library and create a client instance of type "heartbeat" </dd> <dt><i><font color="#ff0000" size="+1">Return Value:</font></i></dt> <dd> returns a handle to the heartbeat library instance. This handle is a opaque object with a set of member functions. The member functions provide the necessary mechanism to interact with the heartbeat daemon. Returns <b>NULL</b> on failure. </dd> <dt><i><font color="#ff0000"><font size="+1">Observation:</font></font></i></dt> <dd> Why is '<i><font color="#cc66cc">type'</font></i> parameter required when we know for sure that we are only interacting with the heartbeat daemon? Or is it that the library wants to be generic and wants to interact with any arbitrary daemon? <b><font color="#ff0000">Yes. The latter.</font></b> </dd> </dl> <h2><a name="signon()"><font size="+2">signon()</font></a></h2> <i><font color="#3366ff"><font size="+2">int *signon(struct ll_cluster cinfo*, const char *service)</font></font></i> <dl> <dt> <i><font color="#ff0000"><font size="+1">Parameter Description:</font></font></i></dt> <dt>'<i><font color="#993399">cinfo</font></i>'</dt> <dd>is the handle to the library instance got through ll_cluster_new() '<i><font color="#993399">service</font></i>' is the type of service, which the calling process registers with the heartbeat daemon. </dd> <dt><i><font color="#ff0000"><font size="+1">Description:</font></font></i></dt> <dd> This function sets up a communication link with the local heartbeat daemon and registers itself for the '<i><font color="#993399">service</font></i>' service. In the case of casual client the clientid is NULL. But in the case of non-casual client the clientid is non-NULL and it indicates the service to which this client wants to sign on for. This special communication link setup with the heartbeat daemon is a fifo. Non-casual clients interact using a fifo whose name is derived from the pid of the clients process. Casual clients interact with heartbeat daemon using the fifo whose name is derived from the '<i><font color="#993399">service'</font></i>string. <p> The heartbeat daemon has no notion for '<i>s<font color="#993399">ervice</font></i><font color="#993399">'</font>. Only the clients registered with the heartbeat daemons for the same service, have the notion for that service. '<i><font color="#993399">service</font></i>' mostly is a mechanism of providing primitive group services to a set of non-casual clients registered for that service. </p> </dd> <dt><i><font color="#ff0000" size="+1">Return value</font></i>:</dt> <dd> On success returns HA_OK <br> On failure returns HA_FAIL </dd> </dl> <h2><a name="signoff()"><font size="+2">signoff()</font></a></h2> <i><font color="#3366ff"><font size="+2">int signoff(struct ll_cluster *cinfo)</font></font></i> <dl> <dt><font color="#ff0000">Parameter Description:</font></dt> <dt><i><font color="#993399">'cinfo' </font></i></dt> <dd>is the handle to the library instance got through ll_cluster_new() </dd> <dt><i><font color="#ff0000"><font size="+1">Description:</font></font></i></dt> <dd> This function deletes the communication link with the local heartbeat daemon and unsubscribe itself from being a heartbeat client. </dd> <dt><i><font color="#ff0000">Return Value:</font></i></dt> <dd> On success it returns HA_OK.<br> On failure it returns HA_FAIL. </dd> </dl> <h2> <a name="delete()"><font size="+2">delete()</font></a></h2> <br> <i><font color="#3333ff"><font size="+2">int delete(struct ll_cluster *cinfo)</font></font></i> <dl> <dt><i><font color="#ff0000"><font size="+1">Parameter Description:</font></font></i></dt> <dt><i><font color="#993399">cinfo</font></i>'</dt> <dd>is the handle to the library instance got through ll_cluster_new() </dd> <dt><i><font color="#ff0000"><font size="+1">Description:</font></font></i></dt> <dd> This operation is reverse of ll_cluster_new(). It unsubscribes itself from the heartbeat library and cleans up the corresponding datastructures. </dd> <dt><i><font color="#ff0000"><font size="+1">Return Value:</font></font></i></dt> <dd> On success returns HA_OK <br> On failure returns HA_FAIL </dd> </dl> <h2><a name="set_msg_callback()"><font size="+2">set_msg_callback()</font></a></h2> <i><font color="#3366ff"><font size="+2">int set_msg_callback(struct ll_cluster *cinfo,</font></font></i> <i><font color="#3366ff"><font size="+2"> const char *msgtype,</font></font></i> <i><font color="#3366ff"><font size="+2"> llc_msg_callback_t callback, void * p)</font></font></i> <dl> <dt><i><font color="#ff0000"><font size="+1">Parameter Description:</font></font></i></dt> <dd> <br> </dd> <dt><i><font color="#993399">cinfo</font></i>'</dt> <dd>is the handle to the library instance got through ll_cluster_new() </dd> <dt>'<i><font color="#993399">msgtype'</font></i></dt> <dd> is the type of message on receipt of which the 'callback' is called. </dd> <dt>'<i><font color="#993399">callback</font></i>'</dt> <dd> is the function to be called on receipt of a message of type '<i><font color="#993399">msgtype</font></i>'. </dd> <dt><i><font color="#993399">'p'</font></i> </dt> <dd> is the parameter to be passed to the 'callback' function. </dd> <dt><i><font color="#ff0000"><font size="+1">Description</font></font></i>:</dt> <dd> This function registers a callback function along with its parameter. The callback function is called by the heartbeat library on receipt of a message of type '<i><font color="#993399">msgtype</font></i>' from the heartbeat daemon. </dd> <dt>NOTE:</dt> <dd> Neither the heartbeat library nor heartbeat daemon interpret '<font color="#993399">msgtype'.</font> The '<i><font color="#993399">msgtype' </font></i>is interpreted only by the client. Clients can coin their own msgtype as long as all the clients signed up for the same service can interpret it. </dd> <dt><i><font color="#ff0000" size="+1">Return Value:</font></i></dt> <dd> On success HA_OK is returned. <br> On failure HA_FAIL is returned. </dd> </dl> <h2> <a name="set_nstatus_callback()"><font size="+2">set_nstatus_callback()</font></a></h2> <i><font color="#3333ff"><font size="+2">int set_nstatus_callback(struct ll_cluster *cinfo,</font></font></i> <i><font color="#3333ff"><font size="+2"> llc_nstatus_callback_t cbf, void *p)</font></font></i> <dl> <dt> <i><font color="#ff0000"><font size="+1">Parameter Description:</font></font></i></dt> <dt>'<i><font color="#993399">cinfo</font></i>'</dt> <dd>is the handle to the library instance got through ll_cluster_new </dd> <dt>'<i><font color="#993399">cbf</font></i>'</dt> <dd> is the function pointer to be called on change of status of any node in the cluster. </dd> <dt>'<i><font color="#993399">p</font></i>'</dt> <dd> is the parameter to be passed to the callback function. </dd> <dt><i><font color="#ff0000"><font size="+1">Description:</font></font></i></dt> <dd> This function registers a callback function along with its parameter. The callback function is called by the heartbeat library on change of status of any node in the cluster. </dd> <dt><i><font color="#ff0000"><font size="+1">Return Value:</font></font></i></dt> <dd> On success HA_OK is returned. </dd> <dt> <i><font color="#ff0000"><font size="+1">Observation:</font></font></i></dt> <dd> There is a bug in this function. It does not validate the 'cinfo' parameter'. It should return HA_FAIL on failure. </dd> </dl> <h2><a name="set_ifstatus_callback()"><font size="+2">set_ifstatus_callback()</font></a></h2> <i><font color="#3366ff"><font size="+2">int set_ifstatus_callback(struct ll_cluster *cinfo,</font></font></i> <i><font color="#3366ff"><font size="+2"> llc_ifstatus_callback_t cbf, void *p)</font></font></i> <dl> <dt><i><font color="#ff0000" size="+1">Parameter Description:</font></i></dt> <dt> '<font color="#993399">cinfo</font>'</dt> <dd>is the handle to the library instance got through ll_cluster_new() </dd> <dt><i><font color="#993399">cbf'</font></i></dt> <dd> is the function pointer to be called on change of status of any interface in the cluster. </dd> <dt>'<i><font color="#993399">p'</font></i></dt> <dd> is the parameter to be passed for the callback function. </dd> <dt><i><font color="#ff0000"><font size="+1">Description:</font></font></i></dt> <dd> This function registers a callback function along with its parameter. The callback function is called by the heartbeat library on change of status of any network interface in the cluster in the view of the current cluster node. </dd> <dt><i><font color="#ff0000"><font size="+1">Return Value:</font></font></i></dt> <dd> On success HA_OK is returned. <p> Also there is a bug in this function. It does not validate the 'cinfo' parameter'. It should return HA_FAIL on failure. </p> </dd> </dl> <h2><a name="init_nodewalk()"><font size="+2">init_nodewalk()</font></a></h2> <br> <i><font size="+2" color="#3366ff">int init_nodewalk(struct ll_cluster_t *cinfo)</font></i> <dl> <dt><i><font color="#ff0000" size="+1">Parameter Description:</font></i></dt> <dt><i><font color="#993399">'cinfo' </font></i></dt> <dd>is the handle to the library instance got through ll_cluster_new </dd> <dt><i><font color="#ff0000" size="+1">Description:</font></i> </dt> <dd> This function talks to the heartbeat daemon and retrieves the set of nodes that are part of the cluster. If the retrieval is successful HA_OK is returned. </dd> <dt><font color="#ff6666" size="+1">Return Value:</font></dt> <dd>On success HA_OK is returned <br> On failure HA_FAIL is returned </dd> </dl> <h2><a name="nextnode()"><font size="+2">nextnode()</font></a></h2> <i><font color="#3366ff"><font size="+2">char *nextnode(ll_cluster_t *cinfo)</font></font></i> <dl> <dt> <i><font color="#ff0000" size="+1">Parameter Description:</font></i></dt> <dt>'<i><font color="#663366">cinfo'</font></i></dt> <dd>is the handle to the library instance gotten through ll_cluster_new(). </dd> <dt><i><font color="#ff0000"><font size="+1">Description/Return Value:</font></font></i>,</dt> <dd> This function returns the next node in the cluster, which is cached in the heartbeat library. If no more node is available it returns NULL. </dd> </dl> <h2><a name="end_nodewalk()"><font size="+2">end_nodewalk()</font></a></h2> <br> <i><font size="+2"> <font color="#3366ff">int end_nodewalk(ll_cluster_t *cinfo)</font></font></i> <dl> <dt><i><font color="#ff0000"><font size="+1">Parameter Description:</font></font></i></dt> <dt>'<i><font color="#993399">cinfo'</font></i></dt> <dd>is the handle to the library instance got through ll_cluster_new(). </dd> <dt><i><font color="#ff0000">Description:</font></i></dt> <dd> This clears the cluster node information cached in the heartbeat library. </dd> <dt><i><font color="#ff0000"><font size="+1">Return Value:</font></font></i></dt> <dd> returns HA_OK on success and HA_FAIL on failure. </dd> </dl> <h2><a name="init_ifwalk()"><font size="+2">init_ifwalk()</font></a></h2> <i><font color="#3366ff"><font size="+2">int init_ifwalk(struct ll_cluster_t *cinfo, char *host)</font></font></i> <dl> <dt><font color="#ff0000"><font size="+1">Parameter Description:</font></font></dt> <dt>'<i><font color="#993399">cinfo</font></i>'</dt> <dd> is the handle to the library instance got through ll_cluster_new</dd> <dt>'<i><font color="#993399">host</font></i>'</dt> <dd> is the node in the cluster whose network interfaces are of interest. </dd> <dt><i><font color="#ff0000"><font size="+1">Description:</font></font></i></dt> <dd> This function talks to the heartbeat daemon and caches all the network interface information associated with '<i><font color="#993399">host'</font></i> node. This caching is done in the heartbeat library. </dd> <dt><i><font color="#ff0000"><font size="+1">Return Value:</font></font></i></dt> <dd> If the network interface information can be successfully retrieved, HA_OK is returned. Failure returns HA_FAIL. </dd> </dl> <h2><a name="nextif(ll_cluster_t *cinfo)"><font size="+2">nextif()</font></a></h2> <font size="+2"> <font color="#3366ff">char * nextif(ll_cluster_t *cinfo)</font></font> <dl> <dt><i><font color="#ff0000"><font size="+1">Parameter Description:</font></font></i></dt> <dt>'<i><font color="#993399">cinfo</font></i>'</dt> <dd>is the handle to the library instance got through ll_cluster_new(). </dd> <dt><i><font color="#ff0000"><font size="+1">Description:</font></font></i> </dt> <dd> This function returns the next network interface of the '<i><font color="#993399">host</font></i>' node in the cluster, which is cached in the heartbeat library. </dd> <dt>NOTE:</dt> <dd> The '<i><font color="#993399">host</font></i>' is the node of the cluster specified during the call to init_ifwalk() </dd> <dt><i><font color="#ff0000"><font size="+1"> Return Value</font></font></i>:</dt> <dd> If no more interfaces are available it returns NULL. </dd> </dl> <h2><a name="end_ifwalk()"><font size="+2">end_ifwalk()</font></a></h2> <br> <i><font size="+2"> <font color="#3366ff">int end_ifwalk(ll_cluster_t *cinfo)</font></font></i> <dl> <dt><i><font color="#ff0000" size="+1">Parameter Description:</font></i></dt> <dt><i><font color="#993399"> 'cinfo' </font></i></dt> <dd>is the handle to the library instance got through ll_cluster_new(). </dd> <dt><i><font color="#ff0000"><font size="+1">Description</font></font></i>:</dt> <dd> This clears the network interface information cached in the heartbeat library. </dd> <dt><i><font color="#ff0000"><font size="+1">Return Value:</font></font></i></dt> <dd> returns HA_OK on success and HA_FAIL of failure. </dd> </dl> <h2><a name="if_status()"><font size="+2">if_status()</font></a></h2> <i><font color="#3366ff"><font size="+2">char * if_status(ll_cluster_t *cinfo, const char *host,</font></font></i> <br> <i><font color="#3366ff"><font size="+2"> const char *ifname)</font></font></i> <dl> <dt><i><font color="#ff0000" size="+1">Parameter Description:</font></i> </dt> <dt>'<i><font color="#993399">cinfo</font></i>'</dt> <dd>is the handle to the library instance got through ll_cluster_new(). </dd> <dt>'<i><font color="#993399">host</font></i>'</dt> <dd> is the node name whose interface's status is queried. </dd> <dt>'<i><font color="#993399">ifname'</font></i></dt> is the name of the interface whose status is queried. <dt><i><font color="#ff0000" size="+1">Description:</font></i></dt> <dd> This function returns a string that specifies the state of the interface 'ifname' on cluster node 'host' </dd> <dt><i><font color="#ff0000" size="+1">Return Value:</font></i></dt> <dd> It returns "up" if the link is active and "dead" if the link is down. NULL if there was a error. </dd> </dl> <h2> <a name="sendclustermsg()"><font size="+2">sendclustermsg()</font></a></h2> <i><font size="+2">int sendclustermsg(ll_cluster_t *cinfo, struct ha_msg* msg)</font></i> <dl> <dt><i><font color="#ff0000" size="+1">Parameter Description:</font></i></dt> <dt>'<i><font color="#993399">cinfo'</font></i> </dt> <dd>is the handle to the library instance got through ll_cluster_new(). </dd> <dt>'<i><font color="#993399">msg' </font></i></dt> <dd> is the message to be sent to all non-casual clients signed up for the same service as that of the calling client. </dd> <dt><i><font color="#ff0000" size="+1">Description:</font></i></dt> <dd> This function broadcasts the message to all members of the group. </dd> <dt><i><font size="+1" color="#cc0000">Return Value:</font></i></dt> <dd> This function returns HA_FAIL if called by a casual client or if there was some other failure. <br> On success it returns HA_OK. </dd> </dl> <h2> <a name="sendnodemsg()"><font size="+2">sendnodemsg()</font></a></h2> <i><font size="+2"> <font color="#3333ff">int sendnodemsg(ll_cluster_t *cinfo, struct ha_msg* msg,</font></font></i> <br> <i><font color="#3333ff"><font size="+2"> const char *nodename)</font></font></i> <dl> <dt><i><font color="#ff0000" size="+1">Parameter Description:</font></i></dt> <dt> '<i><font color="#993399">cinfo</font></i>'</dt> <dd>is the handle to the library instance got through ll_cluster_new(). </dd> <dt> <i><font color="#993399"> 'msg</font></i>'</dt> <dd> is the message to be sent to a non-casual client signed on to the same service on node 'nodename'. </dd> <dt><i><font color="#ff0000"><font size="+1">Description:</font></font></i></dt> <dd> This function sends the message to a non-casual client residing on node 'nodename'. The client belongs to the same group as that of the calling client. </dd> <dt><i><font color="#ff0000"><font size="+1">Return Value</font></font></i>:</dt> <dd> This function returns HA_FAIL if called by a casual client or if there was some other failure. <br> On success it returns HA_OK. </dd> </dl> <h2><a name="inputfd()"><font size="+2">inputfd()</font></a></h2> <i><font size="+2"> <font color="#3366ff">int inputfd(ll_cluster * cinfo)</font></font></i> <dl> <dt><i><font color="#ff0000"><font size="+1"> Parameter Description</font></font></i>:</dt> <dt> '<i><font color="#cc0000">cinfo</font></i>'</dt> <dd>is the handle to the library instance got through ll_cluster_new(). </dd> <dd> <br> </dd> <dt><i><font color="#ff0000"><font size="+1"> Description/Return Value:</font></font></i></dt> <dd> returns the file descriptor of the communication link setup with the local heartbeat daemon. <br> On failure it returns -1. </dd> <dt><i><font color="#ff0000"><font size="+1"> Observation:</font></font></i></dt> <dd> This function is needed in order to be able to perform a select function which selects on incoming API messages. It should <i>not</i> be used for any other purpose. </dd> </dl> <h2><a name="msgready()"><font size="+2">msgready()</font></a></h2> <i><font size="+2">int msgready(ll_cluster_t *cinfo)</font></i> <dl> <dt><i><font color="#ff0000" size="+1">Parameter Description:</font></i></dt> <dt>'<i><font color="#cc0000">cinfo</font></i>'</dt> <dd>is the handle to the library instance got through ll_cluster_new(). </dd> <dt><i><font color="#ff0000" size="+1">Description:</font></i></dt> <dd> checks if there is any message to be read. </dd> <dt><i><font color="#ff0000" size="+1">Return Value:</font></i></dt> <dd> If a message is ready to be read returns non zero value. Otherwise returns 0. </dd> </dl> <h2><a name="setmsgsignal()"><font size="+2">setmsgsignal()</font></a></h2> <font color="#3366ff"><i><font size="+2"> int setmsgsignal(ll_cluster_t *cinfo, int nsig)</font></i></font> <dl> <dt><font color="#ff0000"><font size="+1"><i>Parameter Description</i></font></font><i>:</i> </dt> <dt> '<i><font color="#cc0000">cinfo</font></i>'</dt> <dd>is the handle to the library instance got through ll_cluster_new(). </dd> <dt> '<i><font color="#cc0000">nsig</font></i>'</dt> <dd> is the signal to be used by heartbeat daemon to signal the client process. </dd> <dt><i><font color="#ff0000"><font size="+1">Description:</font></font></i></dt> <dd> This function informs the heartbeat daemon send signal number '<i><font color="#cc0000">nsig</font></i>' whenever a message arrives for it. </dd> <dt><i><font color="#ff0000" size="+1">Return Value:</font></i></dt> <dd> returns HA_OK on success <br> and HA_FAIL on failure </dd> </dl> <h2><a name="rcvmsg()"><font size="+2">rcvmsg()</font></a></h2> <font color="#3366ff"><i><font size="+2"> int rcvmsg(ll_cluster_t *cinfo, int blocking)</font></i></font> <dl> <dt><i><font color="#ff0000"><font size="+1"> Parameter Description:</font></font></i></dt> <dt>'<i><font color="#cc0000">cinfo</font></i>'</dt> <dd>is the handle to the library instance got through ll_cluster_new(). </dd> <dt>'<i><font color="#cc0000">blocking'</font></i> </dt> <dd> indicates whether to block for the receipt of a message or not. </dd> <dt><i><font color="#ff0000"><font size="+1">Description/Return Value:</font></font></i></dt> <dd> This function returns true if a message for which a callback function was not registered is received. <p> If blocking is set, then it waits till a message arrives. But it returns true only if that message does not have a callback registered. </p> </dd> <dt>NOTE:</dt> <dd>In all cases, received messages are deleted by this call. </dd> <dt><font color="#ff0000" size="+1"><i>Observation:</i></font></dt> <dd> This interface is provided as a convenience to allow for clients which only process certain message types through registered callback functions to never have to worry about the possibility of failing to destroy their messages. If you process all messages you handle with callbacks, then this function is a convenient choice. Otherwise, you likely need to use readmsg(). </dd> </dl> <h2> <a name="readmsg()"><font size="+2">readmsg()</font></a></h2> <br> <font color="#3366ff"><i><font size="+2">struct ha_msg * readmsg(ll_cluster_t *cinfo, int blocking)</font></i></font> <dl> <dt><font color="#ff0000"><font size="+1"> Parameter Description:</font></font></dt> <dt> '<i><font color="#993399">cinfo</font></i>' </dt> <dd>is the handle to the library instance got through ll_cluster_new(). </dd> <dt>'<i><font color="#993399">blocking'</font></i></dt> <dd> indicates whether to block for the receipt of a message or not. </dd> <dt><b><i><font color="#ff0000"><font size="+1">Description/Return Value:</font></font></i></b></dt> <dd> This function is same as rcvmsg except that it returns messages without registered callbacks to the caller (and does not delete them). It returns the next message for which a callback is not registered. <p> If '<i><font color="#993399">blocking'</font></i> is set to FALSE, it will not wait for a message to arrive. It returns NULL if there is not currently a message ready to read which is not intercepted by a callback function. </p> </dd> <dt>NOTE:</dt> <dd>The message returned must be disposed off by the caller by calling ha_msg_del(). </dd> </dl> <h2><a name="setfmode()"><font size="+2">setfmode()</font></a></h2> <br> <font color="#3366ff"> <i><font size="+2">int setfmode(ll_cluster_t *cinfo, int mode)</font></i></font> <dl> <dt><i> <font color="#ff0000" size="+1">Parameter Description:</font></i></dt> <dt>'<i><font color="#993399">cinfo</font></i>'</dt> <dd>is the handle to the library instance got through ll_cluster_new(). </dd> <dt>'<i><font color="#993399">mode</font></i>'</dt> <dd> indicates the type of messages to be delivered to the client and to filter out the rest. <p> The modes have the following meanings: </p> </dd> <dl> <dt><b>LLC_FILTER_DEFAULT</b></dt> <dd> All messages destined to this client are received, along with all that are addressed to all clients. </dd> <dt><b>LLC_FILTER_PMODE</b></dt> <dd>All messages, but filter out heartbeats that don't tell us anything new. </dd> <dt><b>LLC_FILTER_ALLHB</b></dt> <dd> All heartbeats including those that don't change status. </dd> <dt><b>LLC_FILTER_RAW</b></dt> <dd> All packets from all interfaces, even duplicates. Packets with authentication errors are still ignored. </dd> </dl> <dt><i><font color="#ff0000"><font size="+1"> Description:</font></font></i></dt> <dd> This function sets up the type of messages that the client is interested; to be received from the local heartbeat daemon. It is mainly used for debugging. </dd> <dt> <i><font color="#ff0000"><font size="+1">Return Value:</font></font></i> </dt> <dd> returns HA_OK on success and HA_FAIL on failure</dd> <dd><br> </dd> </dl> <b><a name="get_parameter"><font size="+2">get_parameter()</font></a></b> <dl> <dd> <i><font color="#3366ff"><font size="+2">char* get_parameter(struct ll_cluster_t * cinfo, char *pname)</font></font></i> </dd> <dt><font color="#ff0000"><font size="+1">Parameter Description:</font></font></dt> <dt>'<i><font color="#993399">cinfo</font></i>'</dt> <dd> is the handle to the library instance got through ll_cluster_new</dd> <dt>'<i><font color="#993399">pname</font></i>'</dt> <dd>is the name of the parameter to retrieve </dd> <dt><i><font color="#ff0000"><font size="+1">Description:</font></font></i></dt> <dd> This function retrieves the value of the named parameter from heartbeat. The parameters supported are listed in <hb_api.h>. </dd> <dt><i><font color="#ff0000"><font size="+1">Return Value:</font></font></i></dt> <dd> If the network interface information can be successfully retrieved, a pointer to a malloced string is returned. NULL is returned on failure. This value is malloced, and the caller must free the return value is no longer needed.</dd> </dl> <b><a name="get_deadtime"><font size="+2">get_deadtime()</font></a></b> <dl> <dd> <i><font color="#3366ff"><font size="+2">long get_deadtime(struct ll_cluster_t * cinfo)</font></font></i> </dd> <dt><font color="#ff0000"><font size="+1">Parameter Description:</font></font></dt> <dt>'<i><font color="#993399">cinfo</font></i>'</dt> <dd> is the handle to the library instance got through ll_cluster_new</dd> <dd> </dd> <dt><i><font color="#ff0000"><font size="+1">Description:</font></font></i></dt> <dd> This function retrieves the deadtime value from heartbeat. The value returned is in milliseconds. </dd> <dt><i><font color="#ff0000"><font size="+1">Return Value:</font></font></i></dt> <dd>The return value is the deadtime, measured in milliseconds. </dd> </dl> <b><a name="get_keepalive"><font size="+2">get_keepalive()</font></a></b> <dl> <dd> <i><font color="#3366ff"><font size="+2">long get_keepalive(struct ll_cluster_t * cinfo)</font></font></i> </dd> <dt><font color="#ff0000"><font size="+1">Parameter Description:</font></font></dt> <dt>'<i><font color="#993399">cinfo</font></i>'</dt> <dd> is the handle to the library instance got through ll_cluster_new().</dd> <dd> <br> </dd> <dt><i><font color="#ff0000"><font size="+1">Description:</font></font></i></dt> <dd> This function retrieves the keepalive value from heartbeat. The value returned is in milliseconds. </dd> <dt><i><font color="#ff0000"><font size="+1">Return Value:</font></font></i></dt> <dd>The return value is the keepalive interval, measured in milliseconds.</dd> </dl> <h2><a name="get_mynodeid"><b><font size="+2">get_mynodeid()</font></b></a></h2> <i><font color="#3366ff" size="+2">const char * get_mynodeid(ll_cluster_t *cinfo)</font></i> <dl> <dt><i><font size="+1" color="#cc0000">Parameter Description:</font></i></dt> <dt>'<i><font color="#993399">cinfo</font></i>'</dt> <dd>is the handle to the library instance got through ll_cluster_new</dd> <dt><i><font color="#ff0000" size="+1"> Description/Return Value:</font></i></dt> <dd> This function returns the node id of the current cluster node. It is generally (though not always) the same as the uname -n name of the current server. The return value is a static value. </dd> </dl> <br> <b><a name="get_logfacility"><font size="+2">get_logfacility()</font></a></b> <dl> <dd> <i><font color="#3366ff"><font size="+2">long get_logfacility(struct ll_cluster_t * cinfo)</font></font></i> </dd> <dt><font color="#ff0000"><font size="+1">Parameter Description:</font></font></dt> <dt>'<i><font color="#993399">cinfo</font></i>'</dt> <dd> is the handle to the library instance got through ll_cluster_new().</dd> <dd> <br> </dd> <dt><i><font color="#ff0000"><font size="+1">Description:</font></font></i></dt> <dd> This function retrieves the logfacility value from heartbeat. </dd> <dt><i><font color="#ff0000"><font size="+1">Return Value:</font></font></i></dt> <dd>The return value is the logfacility currently being used by heartbeat. If there is no log facility being used by heartbeat, then it will return -1. </dd> </dl> <h2><a name="get_resources"><b><font size="+2">get_resources()</font></b></a></h2> <i><font color="#3366ff" size="+2">const char * get_resources(ll_cluster_t *cinfo)</font></i> <dl> <dt><i><font size="+1" color="#cc0000">Parameter Description:</font></i></dt> <dt>'<i><font color="#993399">cinfo</font></i>'</dt> <dd>is the handle to the library instance got through ll_cluster_new</dd> <dt><i><font color="#ff0000" size="+1"> Description/Return Value:</font></i></dt> <dd> This function returns the current resource allocation as supported by the current resource management function. The return value is a static string containing one of "local", "foreign", "all", "none" or "transition".. "local" means the local nodes is supporting only local resources. "foreign" means the local node is supporting only foreign resources (those belonging to the other node). "all" means the local node is supporting all cluster resources. "none" means the local node is not providing any cluster resources. "transition" means that resources are currently in transition. If heartbeat is not providing resource management, the return value will be <b><big><tt>NULL</tt></big></b>. </dd> </dl> <br> <h2><a name="errmsg()"><b><font size="+2">errmsg()</font></b></a></h2> <i><font color="#3366ff" size="+2">const char * errmsg(ll_cluster_t *cinfo)</font></i> <dl> <dt><i><font size="+1" color="#cc0000">Parameter Description:</font></i></dt> <dt>'<i><font color="#993399">cinfo</font></i>'</dt> <dd>is the handle to the library instance got through ll_cluster_new</dd> <dt><i><font color="#ff0000" size="+1"> Description/Return Value:</font></i></dt> <dd> This function returns the last set of error messages from the previous API call. This is not a very wonderful interface (according to alanr) </dd> </dl> <br> </body> </html>