tsalarm.c revision 4a6822d07d6d3f9ffe6907ef5f10d11dcadd75c6
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* alarms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <libpcp.h>
#include "tsalarm.h"
/* Message Types */
#define TSALARM_CONTROL 15
#define TSALARM_CONTROL_R 16
#define TSALARM_CHANNEL_TIMEOUT 20
#define TSALARM_MAX_RETRIES 3
#define TSALARM_SERVICE_NAME "SUNW,sun4v-telco-alarm"
int
{
int chnl_fd;
int rc = TSALARM_SUCCESS;
int retries;
/* initialize virtual channel */
if (retries == TSALARM_MAX_RETRIES) {
goto cleanup;
}
(void) sleep(TSALARM_CHANNEL_TIMEOUT);
} else
break;
}
/* create request message data */
goto cleanup;
}
/*
* Send the request and receive the response.
*/
TSALARM_CHANNEL_TIMEOUT) < 0) {
/* we either timed out or erred; either way try again */
(void) sleep(TSALARM_CHANNEL_TIMEOUT);
TSALARM_CHANNEL_TIMEOUT) < 0) {
goto cleanup;
}
}
/*
* validate that this data was meant for us
*/
goto cleanup;
}
/*
* verify that the Alarm action has taken place
*/
goto cleanup;
goto cleanup;
}
goto cleanup;
}
/* close virtual channel fd */
return (rc);
}
int
{
int chnl_fd;
int rc = TSALARM_SUCCESS;
int retries;
/* initialize virtual channel */
if (retries == TSALARM_MAX_RETRIES) {
goto cleanup;
}
(void) sleep(TSALARM_CHANNEL_TIMEOUT);
} else
break;
}
/* create request message data */
goto cleanup;
}
if (alarm_state == TSALARM_STATE_ON)
else if (alarm_state == TSALARM_STATE_OFF)
/*
* Send the request and receive the response.
*/
TSALARM_CHANNEL_TIMEOUT) < 0) {
/* we either timed out or erred; either way try again */
(void) sleep(TSALARM_CHANNEL_TIMEOUT);
TSALARM_CHANNEL_TIMEOUT) < 0) {
goto cleanup;
}
}
/*
* validate that this data was meant for us
*/
goto cleanup;
}
/*
* verify that the Alarm action has taken place
*/
goto cleanup;
goto cleanup;
}
/*
* ensure the Alarm action taken is the one requested
*/
goto cleanup;
goto cleanup;
goto cleanup;
}
/* close virtual channel fd */
return (rc);
}