/*****************************************************************/
/**                                                             **/
/**             (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_ASNgetP_end[] = "@(#)ASNgetP_end.c	1.7 10/19/92 13:19:41  LLNL ";

/*
	Embedded Language for Remote Operations Services
	ELROS

	AUTHOR:		James A. Guse
			Network Systems Division

	DATE WRITTEN:	10/12/90

	ROUTINE:	getP_end
	Version:	__ROr_ASNgetP_end

PURPOSE:
	This routine gets 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/typetags.h>

int __ROr_ASNgetP_end(instance)

	__RO_Instance_Record *instance;

{
  if (instance->sending_PPDUs) {
    __RO_int32 type;
    unsigned long length;

    if ((instance->getP_header)(instance,&type,&length))
      return(EXCEPTION);
    if (type != TAG_EOC)
      __RO_RETURN_RUNTIME(instance,__ROx_PPDU_EXPECTEOC1);

    if ((instance->getP_header)(instance,&type,&length))
      return(EXCEPTION);
    if (type != TAG_EOC)
      __RO_RETURN_RUNTIME(instance,__ROx_PPDU_EXPECTEOC2);

    if ((instance->getP_header)(instance,&type,&length))
      return(EXCEPTION);
    if (type == TAG_SEQUENCE)
      instance->get_state.ppdu_state = __ROm_ppdu_state3;
    else if (type == TAG_EOC)
      instance->get_state.ppdu_state = __ROm_ppdu_state1;
    else
      __RO_RETURN_RUNTIME(instance,__ROx_PPDU_EXPECTEOC3);
  }

  return(SUCCESS);
}

