/*****************************************************************/
/**                                                             **/
/**             (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_ASNsendP_start[] = "@(#)ASNsendP_st.c	1.12 10/19/92 13:20:13  LLNL ";

/*
	Embedded Language for Remote Operations Services
	ELROS

	AUTHOR:		James A. Guse
			Network Systems Division

	DATE WRITTEN:	10/12/90

	ROUTINE:	sendP_start
	Version:	__ROr_ASNsendP_start

PURPOSE:
	This routine sends the PPDU header

IN:
	instance -

OUT:


CALLED ROUTINES:
	

	
MODIFICATION HISTORY:
	Added sending_PPDUs field to instance record (ls 920414)


*/

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

int __ROr_ASNsendPPDU_start(instance)

	__RO_Instance_Record *instance;

{
  if (instance->sending_PPDUs) {
    if (!instance->sending_nesting || instance->sending_flushed) 
      __ROr_sendP_2element(instance,__ROe_full_PPDU_header);

    instance->sending_nesting++;
    instance->sending_flushed = 0;
  }

  return(SUCCESS);
}


int __ROr_ASNsendPDV_start(instance)

	__RO_Instance_Record *instance;

{
  if (instance->sending_PPDUs) {
    int pci = instance->ISO_Contexts.specific_pcid;
    unsigned long pcisize = sizeof(pci),
                  pcilength = sizeof(pci);

    if (instance->sending_flushed) {
      if ((instance->sendPPDU_start)(instance))
         return(EXCEPTION);
      instance->sending_nesting--;
    }

    __ROr_sendP_2element(instance,__ROe_PDV_list_header);

    __ROr_sendP_1element(instance,__ROe_Integer_header);
    if (instance->sendP_Integer(instance,&pci,&pcisize,&pcilength,NULL))
       return(EXCEPTION);
    __ROr_sendP_2element(instance,__ROe_single_ASN_type_header);
  }

  return(SUCCESS);
}

