OSI/MHS Management Programming Manual

Examples
OSI/MHS Management Programming Manual424824-001
C-34
Example in C
if (rcv_bytes_read < 0)
{
printf ("Error on $RECEIVE : %d\n", errno);
exit (EXIT_FAILURE);
} /* if (rcv_status) */
else /* no read error */
{
if (!valid_spi_request (rcv_buf))
{
send_password_response (PASSW_ERROR_RSP, NULL);
}
else
{
process_spi_request (rcv_buf);
}
} /* no read error */
} /* while (1) */
} /* end main */
/***************************************************************************/
/* Function: valid_spi_request */
/* Usage : if (!valid_spi_request) */
/* Parameters: None */
/*-------------------------------------------------------------------------*/
/* Verify that the incoming request is a valid SPI request. Check the */
/* SSID token, and the COMMAND and HDRTYPE tokens to verify that the */
/* request is valid. */
/* Return TRUE if the request is valid, FALSE otherwise. */
/***************************************************************************/
bool valid_spi_request (char *spi_req_buf)
{
int spi_status;
int tkn_command;
int tkn_hdrtype;
zmhs_val_ssid_def tkn_ssid_buf;
int zmhs_buflen = ZMHS_VAL_BUFLEN;
short *spi_req_buf_s = (short *)spi_req_buf;
/* reset control information in the buffer */
spi_status = SSPUTTKN (spi_req_buf_s,
ZSPI_TKN_RESET_BUFFER,
(char *)&zmhs_buflen);
if (spi_status)
{
return (FALSE);
} /* end if (spi_status) */
/* validate COMMAND, HDRTYPE, and SSID tokens */
spi_status = SSGETTKN (spi_req_buf_s,
ZSPI_TKN_COMMAND,
(char *)&tkn_command);
if (!spi_status)
{
spi_status = SSGETTKN (spi_req_buf_s,
ZSPI_TKN_HDRTYPE,
(char *)&tkn_hdrtype);
}
if (!spi_status)
{
spi_status = SSGETTKN (spi_req_buf_s,
ZSPI_TKN_SSID,