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

/*
	Embedded Language for Remote Operations Services
	ELROS

	AUTHOR:		James A. Guse
			Network Systems Division

	DATE WRITTEN:	10/12/90

	ROUTINE:	sendP_end
	Version:	__ROr_ASNsendP_end

PURPOSE:
	This routine sends the PPDU trailer

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_end(instance)

	__RO_Instance_Record *instance;

{
  if (instance->sending_PPDUs) {

    instance->sending_nesting--;

    if (!instance->sending_nesting && !instance->sending_flushed) {
      __ROr_sendP_2element(instance,__ROe_EOC);
      instance->send_state.boundary_flag = 1;
      if ((*instance->send_data)(instance))
        return(EXCEPTION);
    }

  }

  else { /* Not sending_PPDUs */
    if (!instance->sending_flushed) {
      instance->send_state.boundary_flag = 1;
      if ((*instance->send_data)(instance))
        return(EXCEPTION);
    }
  }

  return(SUCCESS);
}

int __ROr_ASNsendPDV_end(instance)

	__RO_Instance_Record *instance;

{
   if (instance->sending_PPDUs) {

     __ROr_sendP_2element(instance,__ROe_EOC);
     __ROr_sendP_2element(instance,__ROe_EOC);

   }

   return(SUCCESS);
}


