/*****************************************************************/
/**                                                             **/
/**             (C) Copyright 1992 the Regents of the           **/
/**        University of California.  All Rights Reserved.      **/
/**                                                             **/
/**        This work was produced under the sponsorship of      **/
/**         the U.S. Department of Energy.  The Government      **/
/**                retains certain rights therein.              **/
/**                                                             **/
/**                         Written by                          **/
/**         Distributed Programming Environments Project        **/
/**           Computer Software and Networking Division,        **/
/**                   Livermore Computer Center,                **/
/**            Lawrence Livermore National Laboratory           **/
/**                                                             **/
/*****************************************************************/

static char sccs_STDsendRO_reject[] = "@(#)STDsendRO_re.c	1.9 10/19/92 13:48:15  LLNL ";

/*
	Embedded Language for Remote Operations Services
	ELROS

	AUTHOR:		James A. Guse
			Network Systems Division

	DATE WRITTEN:	10/12/90

	ROUTINE:	sendRO_reject
	Version:	__ROr_STDsendRO_reject

PURPOSE:
	This routine sends the PPDU header

IN:
	instance -

OUT:


CALLED ROUTINES:
	

	
MODIFICATION HISTORY:


*/

#include <elros/instance.h>
#include <elros/sendP_element.h>
#include <elros/typecodes.h>

int __ROr_STDsendRO_reject(instance,problem)

	__RO_Instance_Record *instance;
	unsigned int problem;

{
   unsigned char c;


	/* Rejects are only sent under the ROSE. */

   if (instance->decl_class != __ROm_class_GIVEACCEPT)
      return(SUCCESS);


	/* Don't send Rejects under the L_TOK encoding rules,
	   only under ASN_1. */

   switch (instance->bound_rules)
   {
      case __ROm_rules_ASN_1:
         if ((instance->sendPPDU_start)(instance))
            return(EXCEPTION);
         if ((instance->sendPDV_start)(instance))
            return(EXCEPTION);

         __ROr_sendP_2element(instance,__ROe_ROHtags[3]);
         __ROr_sendP_2element(instance,__ROe_Null);

         __ROr_sendP_1element(instance,(c=0x80,&c)); /* CONTEXT 0 */
         __ROr_sendP_1element(instance,(c=0x01,&c)); /* LENGTH=1 */
         __ROr_sendP_1element(instance,(c=problem,&c)); /* value= {0,1,2} */

         __ROr_sendP_2element(instance,__ROe_EOC);

         if ((instance->sendPDV_end)(instance))
            return(EXCEPTION);
         if ((instance->sendPPDU_end)(instance))
            return(EXCEPTION);
         break;

      case __ROm_rules_L_TOK:
         break;
   }

   return(SUCCESS);
}

