/**************************************************************
$Workfile:   report.c  $
***************************************************************
**                                                                                                        
** FIRMWARE, Copyright (C) 2000-2002
** Ikanos Communication, Fremont, CA
** All rights reserved.
**
** The information and contents of this file are the
** proprietary information of Ikanos Communication and may not
** be disclosed or used without the formal written approval of
** Ikanos Communication
**
$Revision: 1.5 $
$Date: 2007/01/22 14:49:09 $
**************************************************************/                    
#include <stdio.h>
#ifdef ALASKA
#include <errno.h>
#endif

#include "ipos.h"
#include "portmap.h"
#include "HostPtmfApi.h"
#include "appconfig.h"
#include "report.h"
#include "oampdb.h" /* IXDP425 */
#include "oampdef.h"
#include "oampstruct.h"
#include "portmap.h"
#include "dapi_parms.h"
#include "apilocal.h"
#include "pprofile.h"
		   
/* note:  subtract 1 from the line number (see getLineNum ) to obtain the index into showtimeParams */

static ShowtimeParams	showtimeParams[ MAX_NUM_OF_PORTS ];

extern void DumpSysConfig (ipos_port_id pid, struct tSystemProv *newSysProv, struct tSystemProv *oldSysProv);
extern void DumpPortConfig (ipos_port_id pid, tPortProfile *newPortProfile, tPortProfile *oldPortProfile);
extern ipos_api_bme apiBme[];
extern ipos_pm_counters *pPmCntr24Hrs[IPOS_MAX_BME + 1][IPOS_MAX_PORT_PER_BME + 1];

failureBitString neFlrToStrMap[16] =  { "FLR_LOS",
                                        "FLR_LOF",
                                        "FLR_LPR",
                                        "FLR_LOM",
                                        "FLR_ESE",
                                        "FLR_NCD_S",
                                        "FLR_LCD_S",
                                        "FLR_NCD_F",
                                        "FLR_LCD_F",
                                        "N/A",
                                        "N/A",
                                        "N/A",
                                        "N/A",
                                        "N/A",
                                        "N/A",
                                        "N/A" };



failureBitString feFlrToStrMap[16] =  { "FLR_FE_LOS",   // Far-end Failures
                                        "FLR_FE_RDI",
                                        "FLR_FE_LPR",
                                        "FLR_FE_LOM",
                                        "FLR_FE_ESE",
                                        "FLR_FE_NCD_S",
                                        "FLR_FE_LCD_S",
                                        "FLR_FE_NCD_F",
                                        "FLR_FE_LCD_F",
                                        "FLR_FE_PO"};


/*******************************************************************

	Thsi header file includes the function prototypes for 
		1. print: port brief status
		2. print: extended port status
		3. print: the port counter
		4. print: the port NE SNR ATTN
			
	
*********************************************************************/
extern oamp_bme oampBme [IPOS_MAX_BME+1];  				/* BME objects for OAMP   */
#ifdef ALASKA
extern int webflag;
#endif

void displayPerfCntrs(ipos_port_id Pid)
{
#ifdef INI_SUPPORT
    int IniIndex, IniFast, IniSlow;
#endif // INI_SUPPORT
    ShowtimeParams *pSTp = getShowtimeParamsRef(Pid) ;
  printf ("\nFEC_F: %lu, CRC_F: %u, FEC_S: %lu, CRC_S: %u, LOS: %u SEF: %u LOM: %u",
          (oampBme[Pid.bmeNum].oampPort[Pid.portNum].Counters.NeFEC_F),
          (oampBme[Pid.bmeNum].oampPort[Pid.portNum].Counters.NeCRC_F),
          (oampBme[Pid.bmeNum].oampPort[Pid.portNum].Counters.NeFEC_S),
          (oampBme[Pid.bmeNum].oampPort[Pid.portNum].Counters.NeCRC_S),
    	   oampBme[Pid.bmeNum].oampPort[Pid.portNum].Counters.NeLOS,
           oampBme[Pid.bmeNum].oampPort[Pid.portNum].Counters.NeSEF,
           oampBme[Pid.bmeNum].oampPort[Pid.portNum].Counters.NeLOM);

  printf ("\nNeFECUnCrr_F: %lu, NeFECUnCrr_S: %lu",
          (oampBme[Pid.bmeNum].oampPort[Pid.portNum].Counters.NeFECUnCrr_F),
          (oampBme[Pid.bmeNum].oampPort[Pid.portNum].Counters.NeFECUnCrr_S));

   printf ("\nTxBlkCnt_F: %lu, TxBlkCnt_S: %lu, RxBlkCnt_F: %lu, RxBlkCnt_S: %lu",
          (oampBme[Pid.bmeNum].oampPort[Pid.portNum].Counters.numTxBlk_F),
          (oampBme[Pid.bmeNum].oampPort[Pid.portNum].Counters.numTxBlk_S),
          (oampBme[Pid.bmeNum].oampPort[Pid.portNum].Counters.numRxBlk_F),
          (oampBme[Pid.bmeNum].oampPort[Pid.portNum].Counters.numRxBlk_S));
              			
   printf ("\nUser cells(bearer0): %lu,   User cells(bearer1): %lu, \nIdle cells(bearer0): %lu,   Idle cells(bearer1): %lu",
    	  (oampBme[Pid.bmeNum].oampPort[Pid.portNum].Counters.numUsrCell_F),
          (oampBme[Pid.bmeNum].oampPort[Pid.portNum].Counters.numUsrCell_S),
          (oampBme[Pid.bmeNum].oampPort[Pid.portNum].Counters.numIdlCell_F),
          (oampBme[Pid.bmeNum].oampPort[Pid.portNum].Counters.numIdlCell_S));

   printf ("\nNCD_F: %u,    NCD_S: %u,    OCD_F: %u,    OCD_S: %u,    HEC_F: %u,    HEC_S: %u",
   		  (oampBme[Pid.bmeNum].oampPort[Pid.portNum].Counters.NeNCD_F),
       	  (oampBme[Pid.bmeNum].oampPort[Pid.portNum].Counters.NeNCD_S),
		  (oampBme[Pid.bmeNum].oampPort[Pid.portNum].Counters.NeOCD_F),
       	  (oampBme[Pid.bmeNum].oampPort[Pid.portNum].Counters.NeOCD_S),
		  (oampBme[Pid.bmeNum].oampPort[Pid.portNum].Counters.NeHEC_F),
       	  (oampBme[Pid.bmeNum].oampPort[Pid.portNum].Counters.NeHEC_S));

	
  printf ("\nFE_FEC_F: %hu, FE_CRC_F: %hu, FE_FEC_S: %hu, FE_CRC_S: %hu",
          (oampBme[Pid.bmeNum].oampPort[Pid.portNum].Counters.FeFEC_F),
          (oampBme[Pid.bmeNum].oampPort[Pid.portNum].Counters.FeCRC_F),
          (oampBme[Pid.bmeNum].oampPort[Pid.portNum].Counters.FeFEC_S),
          (oampBme[Pid.bmeNum].oampPort[Pid.portNum].Counters.FeCRC_S));

  printf ("\nFE_LOS: %hu,   FE_RDI: %hu,   FE_LPR: %hu    FE_LOM: %hu    FE_PO: %hu",
    	    (oampBme[Pid.bmeNum].oampPort[Pid.portNum].Counters.FeLOS),
          (oampBme[Pid.bmeNum].oampPort[Pid.portNum].Counters.FeRDI),
          (oampBme[Pid.bmeNum].oampPort[Pid.portNum].Counters.FeLPR),
          (oampBme[Pid.bmeNum].oampPort[Pid.portNum].Counters.FeLOM),
          (oampBme[Pid.bmeNum].oampPort[Pid.portNum].Counters.FePO));


  printf ("\nFE_OCD_F: %hu, FE_OCD_S: %hu, FE_HEC_F: %hu, FE_HEC_S: %hu",
          (oampBme[Pid.bmeNum].oampPort[Pid.portNum].Counters.FeOCD_F),
       	  (oampBme[Pid.bmeNum].oampPort[Pid.portNum].Counters.FeOCD_S),
          (oampBme[Pid.bmeNum].oampPort[Pid.portNum].Counters.FeHEC_F),
       	  (oampBme[Pid.bmeNum].oampPort[Pid.portNum].Counters.FeHEC_S));

    if (pSTp->LineType & VDSL2_TYPE_SUPPORTED)
    {
        IK_PRINTF ("\nFE_FEC_ES: %lu, FE_ES: %lu, FE_SES: %lu, FE_LOS_ES: %lu, FE_UNAVL_ES: %lu",
                   (oampBme[Pid.bmeNum].oampPort[Pid.portNum].Counters.FeFecEs_S),
                   (oampBme[Pid.bmeNum].oampPort[Pid.portNum].Counters.FeEs_S),
                   (oampBme[Pid.bmeNum].oampPort[Pid.portNum].Counters.FeSEs_S),
                   (oampBme[Pid.bmeNum].oampPort[Pid.portNum].Counters.FeLosEs_S), 
                   (oampBme[Pid.bmeNum].oampPort[Pid.portNum].Counters.FeUnAvlEs_S)) ;
        //IK_PRINTF ("\nFE_BE: %lu", (oampBme[Pid.bmeNum].oampPort[Pid.portNum].Counters.FeBER_S)) ;
    }

#ifdef INI_SUPPORT
/* Added for Dual Latency Support*/
	getIniMap(Pid, &IniIndex, &IniSlow, &IniFast);

	iposPtmfPrintCounters (IniIndex);
	if (IniSlow != IniFast)
	{
	   iposPtmfPrintCounters (IniIndex + 1);
	}

#endif  // INI_SUPPORT*/

}

void displayPmCounters(ipos_port_id Pid)
{
#ifdef INI_SUPPORT
  int IniIndex, IniFast, IniSlow;
#endif // INI_SUPPORT
  ipos_pm_counters *pmCntrs;
  ipos_pm_counters *pm24hrs;
  ipos_pm_counters *pmStart;

#ifdef ALASKA
      FILE *vdslout;

      vdslout = fopen("/tmp/vdslcmd.out","w");
      if(vdslout == NULL)
      {
        perror("displayPmCounters(): cannot open /tmp/vdslcmd.out in write mode");
        return;
      }
#endif
  pmCntrs = &(oampBme[Pid.bmeNum].oampPort[Pid.portNum].PmCounters);
  pmStart = &(oampBme[Pid.bmeNum].oampPort[Pid.portNum].PmCountersAtPortStart);
  pm24hrs = pPmCntr24Hrs[Pid.bmeNum][Pid.portNum];

#ifdef ALASKA
  fprintf (vdslout,"\nFEC_F: %lu, CRC_F: %lu, FEC_S: %lu, CRC_S: %lu, LOS: %u SEF: %u LOM: %u",
          pm24hrs->NeFEC_F + pmCntrs->NeFEC_F - pmStart->NeFEC_F,
          pm24hrs->NeCRC_F + pmCntrs->NeCRC_F - pmStart->NeCRC_F,
          pm24hrs->NeFEC_S + pmCntrs->NeFEC_S - pmStart->NeFEC_S,
          pm24hrs->NeCRC_S + pmCntrs->NeCRC_S - pmStart->NeCRC_S,
    	  pm24hrs->NeLOS   + pmCntrs->NeLOS   - pmStart->NeLOS,
    	  pm24hrs->NeLOF   + pmCntrs->NeLOF   - pmStart->NeLOF,
    	  pm24hrs->NeLOM   + pmCntrs->NeLOM   - pmStart->NeLOM );

  fprintf (vdslout,"\nNeFECUnCrr_S: %lu, NeFECUnCrr_F: %lu", 
          pm24hrs->NeFECUnCrr_S + pmCntrs->NeFECUnCrr_S - pmStart->NeFECUnCrr_S,
          pm24hrs->NeFECUnCrr_F + pmCntrs->NeFECUnCrr_F - pmStart->NeFECUnCrr_F);

   fprintf (vdslout,"\nTxBlkCnt_S: %lu, TxBlkCnt_F: %lu, RxBlkCnt_S: %lu, RxBlkCnt_F: %lu",
          pm24hrs->numTxBlk_S  + pmCntrs->numTxBlk_S - pmStart->numTxBlk_S,
          pm24hrs->numTxBlk_F  + pmCntrs->numTxBlk_F - pmStart->numTxBlk_F,
          pm24hrs->numRxBlk_S  + pmCntrs->numRxBlk_S - pmStart->numRxBlk_S,
          pm24hrs->numRxBlk_F  + pmCntrs->numRxBlk_F - pmStart->numRxBlk_F);
#else
  printf ("\nFEC_F: %lu, CRC_F: %lu, FEC_S: %lu, CRC_S: %lu, LOS: %u SEF: %u LOM: %u",
          pm24hrs->NeFEC_F + pmCntrs->NeFEC_F - pmStart->NeFEC_F,
          pm24hrs->NeCRC_F + pmCntrs->NeCRC_F - pmStart->NeCRC_F,
          pm24hrs->NeFEC_S + pmCntrs->NeFEC_S - pmStart->NeFEC_S,
          pm24hrs->NeCRC_S + pmCntrs->NeCRC_S - pmStart->NeCRC_S,
    	  pm24hrs->NeLOS   + pmCntrs->NeLOS   - pmStart->NeLOS,
    	  pm24hrs->NeLOF   + pmCntrs->NeLOF   - pmStart->NeLOF,
    	  pm24hrs->NeLOM   + pmCntrs->NeLOM   - pmStart->NeLOM );

  IK_PRINTF ("\nNeFECUnCrr_S: %lu, NeFECUnCrr_F: %lu", 
          pm24hrs->NeFECUnCrr_S + pmCntrs->NeFECUnCrr_S - pmStart->NeFECUnCrr_S,
          pm24hrs->NeFECUnCrr_F + pmCntrs->NeFECUnCrr_F - pmStart->NeFECUnCrr_F);

   IK_PRINTF ("\nTxBlkCnt_S: %lu, TxBlkCnt_F: %lu, RxBlkCnt_S: %lu, RxBlkCnt_F: %lu",
          pm24hrs->numTxBlk_S  + pmCntrs->numTxBlk_S - pmStart->numTxBlk_S,
          pm24hrs->numTxBlk_F  + pmCntrs->numTxBlk_F - pmStart->numTxBlk_F,
          pm24hrs->numRxBlk_S  + pmCntrs->numRxBlk_S - pmStart->numRxBlk_S,
          pm24hrs->numRxBlk_F  + pmCntrs->numRxBlk_F - pmStart->numRxBlk_F);
#endif


#if 0
          (oampBme[Pid.bmeNum].oampPort[Pid.portNum].Counters.numTxBlk_F),
          (oampBme[Pid.bmeNum].oampPort[Pid.portNum].Counters.numTxBlk_S),
          (oampBme[Pid.bmeNum].oampPort[Pid.portNum].Counters.numRxBlk_F),
          (oampBme[Pid.bmeNum].oampPort[Pid.portNum].Counters.numRxBlk_S));
#endif
              			
#ifdef ALASKA
   fprintf (vdslout,"\nUser cells(bearer0): %lu,   User cells(bearer1): %lu, \nIdle cells(bearer0): %lu,   Idle cells(bearer1): %lu",
    	  pm24hrs->numUSRcell_F  + pmCntrs->numUSRcell_F  - pmStart->numUSRcell_F,
          pm24hrs->numUSRcell_S  + pmCntrs->numUSRcell_S  - pmStart->numUSRcell_S,
          pm24hrs->numIDLEcell_F + pmCntrs->numIDLEcell_F - pmStart->numIDLEcell_F,
          pm24hrs->numIDLEcell_S + pmCntrs->numIDLEcell_S - pmStart->numIDLEcell_S);

   fprintf (vdslout,"\nNCD_F: %u,    NCD_S: %u,    OCD_F: %u,    OCD_S: %u,    HEC_F: %lu,    HEC_S: %lu",
   		  pm24hrs->NeNCD_F + pmCntrs->NeNCD_F - pmStart->NeNCD_F,
       	  pm24hrs->NeNCD_S + pmCntrs->NeNCD_S - pmStart->NeNCD_S,
		  pm24hrs->NeLCD_F + pmCntrs->NeLCD_F - pmStart->NeLCD_F,
       	  pm24hrs->NeLCD_S + pmCntrs->NeLCD_S - pmStart->NeLCD_S,
		  pm24hrs->NeHEC_F + pmCntrs->NeHEC_F - pmStart->NeHEC_F,
       	  pm24hrs->NeHEC_S + pmCntrs->NeHEC_S - pmStart->NeHEC_S);

   fprintf (vdslout,"\nFEC_ES: %lu, ES: %lu, SES: %lu, LOS_ES: %lu, UNAVL_ES: %lu",
                           pm24hrs->NeFECS+ pmCntrs->NeFECS- pmStart->NeFECS,
                           pm24hrs->NeES+ pmCntrs->NeES- pmStart->NeES,
                           pm24hrs->NeSES+ pmCntrs->NeSES- pmStart->NeSES,
                           pm24hrs->NeLOSS+ pmCntrs->NeLOSS- pmStart->NeLOSS,
                           pm24hrs->NeUnavl+pmCntrs->NeUnavl-pmStart->NeUnavl);
	
  fprintf (vdslout,"\nFE_FEC_F: %lu, FE_CRC_F: %lu, FE_FEC_S: %lu, FE_CRC_S: %lu",
          pm24hrs->FeFEC_F + pmCntrs->FeFEC_F - pmStart->FeFEC_F,
          pm24hrs->FeCRC_F + pmCntrs->FeCRC_F - pmStart->FeCRC_F,
          pm24hrs->FeFEC_S + pmCntrs->FeFEC_S - pmStart->FeFEC_S,
          pm24hrs->FeCRC_S + pmCntrs->FeCRC_S - pmStart->FeCRC_S);

  fprintf (vdslout,"\nFE_LOS: %hu,   FE_RDI: %hu,   FE_LPR: %hu    FE_LOM: %hu    FE_PO: %s",
    	  pm24hrs->FeLOS + pmCntrs->FeLOS - pmStart->FeLOS,
    	  pm24hrs->FeRDI + pmCntrs->FeRDI - pmStart->FeRDI,
    	  pm24hrs->FeLPR + pmCntrs->FeLPR - pmStart->FeLPR,
    	  pm24hrs->FeLOM + pmCntrs->FeLOM - pmStart->FeLOM,
    	  pm24hrs->FePO + pmCntrs->FePO - pmStart->FePO);



  fprintf (vdslout,"\nFE_OCD_F: %hu, FE_OCD_S: %hu, FE_HEC_F: %lu, FE_HEC_S: %lu",
          pm24hrs->FeLCD_F + pmCntrs->FeLCD_F - pmStart->FeLCD_F,
       	  pm24hrs->FeLCD_S + pmCntrs->FeLCD_S - pmStart->FeLCD_S,
          pm24hrs->FeHEC_F + pmCntrs->FeHEC_F - pmStart->FeHEC_F,
       	  pm24hrs->FeHEC_S + pmCntrs->FeHEC_S - pmStart->FeHEC_S );

   fprintf (vdslout,"\nFE_FEC_ES: %lu,  FE_ES: %lu,  FE_S_ES: %lu,  FE_LOS_ES: %lu FE_UNAVL_ES: %lu ",
                           pm24hrs->FeFECS+ pmCntrs->FeFECS- pmStart->FeFECS,
                           pm24hrs->FeES+ pmCntrs->FeES- pmStart->FeES,
                           pm24hrs->FeSES+ pmCntrs->FeSES- pmStart->FeSES,
                           pm24hrs->FeLOSS+ pmCntrs->FeLOSS- pmStart->FeLOSS,
                           pm24hrs->FeUnavl+ pmCntrs->FeUnavl- pmStart->FeUnavl);
   fclose(vdslout);
#else
   printf ("\nUser cells(bearer0): %lu,   User cells(bearer1): %lu, \nIdle cells(bearer0): %lu,   Idle cells(bearer1): %lu",
    	  pm24hrs->numUSRcell_F  + pmCntrs->numUSRcell_F  - pmStart->numUSRcell_F,
          pm24hrs->numUSRcell_S  + pmCntrs->numUSRcell_S  - pmStart->numUSRcell_S,
          pm24hrs->numIDLEcell_F + pmCntrs->numIDLEcell_F - pmStart->numIDLEcell_F,
          pm24hrs->numIDLEcell_S + pmCntrs->numIDLEcell_S - pmStart->numIDLEcell_S);

   printf ("\nNCD_F: %u,    NCD_S: %u,    OCD_F: %u,    OCD_S: %u,    HEC_F: %lu,    HEC_S: %lu",
   		  pm24hrs->NeNCD_F + pmCntrs->NeNCD_F - pmStart->NeNCD_F,
       	  pm24hrs->NeNCD_S + pmCntrs->NeNCD_S - pmStart->NeNCD_S,
		  pm24hrs->NeLCD_F + pmCntrs->NeLCD_F - pmStart->NeLCD_F,
       	  pm24hrs->NeLCD_S + pmCntrs->NeLCD_S - pmStart->NeLCD_S,
		  pm24hrs->NeHEC_F + pmCntrs->NeHEC_F - pmStart->NeHEC_F,
       	  pm24hrs->NeHEC_S + pmCntrs->NeHEC_S - pmStart->NeHEC_S);

   IK_PRINTF ("\nFEC_ES: %lu, ES: %lu, SES: %lu, LOS_ES: %lu, UNAVL_ES: %lu",
                           pm24hrs->NeFECS+ pmCntrs->NeFECS- pmStart->NeFECS,
                           pm24hrs->NeES+ pmCntrs->NeES- pmStart->NeES,
                           pm24hrs->NeSES+ pmCntrs->NeSES- pmStart->NeSES,
                           pm24hrs->NeLOSS+ pmCntrs->NeLOSS- pmStart->NeLOSS,
                           pm24hrs->NeUnavl+pmCntrs->NeUnavl-pmStart->NeUnavl);
	
  IK_PRINTF ("\nESE: %lu, FE_ESE: %lu",
                           pm24hrs->NeESE+ pmCntrs->NeESE- pmStart->NeESE,
                           pm24hrs->FeESE+ pmCntrs->FeESE- pmStart->FeESE);

    IK_PRINTF("\nNear-End Active Failures %x : ",pmCntrs->NeFailures);  

  {
    U8 i;
    U16 failureFlag,cnt=0,failureCount=0;
       failureFlag = pmCntrs->NeFailures; 
       for(i=0;i<16;i++){
           if(failureFlag & (1<<i)){
               if(failureCount++ > 1) IK_PRINTF(",");
               IK_PRINTF(" %s",&neFlrToStrMap[i].fstring);
               if(cnt++ >=4 ){
                     cnt=0;
                     IK_PRINTF("\n                              :");
               }
           }
       }
   }

   IK_PRINTF("\nFar-End Active Failures %x : ",pmCntrs->FeFailures);  

  {
    U8 i;
    U16 failureFlag,cnt=0,failureCount=0;

       failureFlag = pmCntrs->FeFailures;
       for(i=0;i<16;i++){
           if(failureFlag & (1<<i)){
               if(failureCount++ > 1) IK_PRINTF(",");
               IK_PRINTF(" %s",&feFlrToStrMap[i].fstring);
               if(cnt++ >=4 ){
                     cnt=0;
                     IK_PRINTF("\n                              :");
               }
           }
       }
    }

    IK_PRINTF ("\nCurr numReInit: %lu,Curr numInitFailure: %lu",
               pm24hrs->numReInit + pmCntrs->numReInit,
               pm24hrs->numInitFailure + pmCntrs->numInitFailure);

  printf ("\nFE_FEC_F: %lu, FE_CRC_F: %lu, FE_FEC_S: %lu, FE_CRC_S: %lu",
          pm24hrs->FeFEC_F + pmCntrs->FeFEC_F - pmStart->FeFEC_F,
          pm24hrs->FeCRC_F + pmCntrs->FeCRC_F - pmStart->FeCRC_F,
          pm24hrs->FeFEC_S + pmCntrs->FeFEC_S - pmStart->FeFEC_S,
          pm24hrs->FeCRC_S + pmCntrs->FeCRC_S - pmStart->FeCRC_S);

  printf ("\nFE_LOS: %hu,   FE_RDI: %hu,   FE_LPR: %hu    FE_LOM: %hu    FE_PO: %s",
    	  pm24hrs->FeLOS + pmCntrs->FeLOS - pmStart->FeLOS,
    	  pm24hrs->FeRDI + pmCntrs->FeRDI - pmStart->FeRDI,
    	  pm24hrs->FeLPR + pmCntrs->FeLPR - pmStart->FeLPR,
    	  pm24hrs->FeLOM + pmCntrs->FeLOM - pmStart->FeLOM,
    	  pm24hrs->FePO + pmCntrs->FePO - pmStart->FePO);



  printf ("\nFE_OCD_F: %hu, FE_OCD_S: %hu, FE_HEC_F: %lu, FE_HEC_S: %lu",
          pm24hrs->FeLCD_F + pmCntrs->FeLCD_F - pmStart->FeLCD_F,
       	  pm24hrs->FeLCD_S + pmCntrs->FeLCD_S - pmStart->FeLCD_S,
          pm24hrs->FeHEC_F + pmCntrs->FeHEC_F - pmStart->FeHEC_F,
       	  pm24hrs->FeHEC_S + pmCntrs->FeHEC_S - pmStart->FeHEC_S );

   IK_PRINTF ("\nFE_FEC_ES: %lu,  FE_ES: %lu,  FE_S_ES: %lu,  FE_LOS_ES: %lu FE_UNAVL_ES: %lu ",
                           pm24hrs->FeFECS+ pmCntrs->FeFECS- pmStart->FeFECS,
                           pm24hrs->FeES+ pmCntrs->FeES- pmStart->FeES,
                           pm24hrs->FeSES+ pmCntrs->FeSES- pmStart->FeSES,
                           pm24hrs->FeLOSS+ pmCntrs->FeLOSS- pmStart->FeLOSS,
                           pm24hrs->FeUnavl+ pmCntrs->FeUnavl- pmStart->FeUnavl);
#endif
#ifdef ALASKA
  printf("\n");
#endif
#ifdef INI_SUPPORT
/* Added for Dual Latency Support*/
	getIniMap(Pid, &IniIndex, &IniSlow, &IniFast);

	iposPtmfPrintCounters (IniIndex);
	if (IniSlow != IniFast)
	{
	   iposPtmfPrintCounters (IniIndex + 1);
	}

#endif  // INI_SUPPORT*/

}

void displayAllPmCounters(ipos_port_id Pid)
{
    ipos_pm_counters *pmCntrs;
    ipos_pm_counters *pm24hrs;
    ipos_pm_counters *pmStart;

#define PrintPMCounters(parm) IK_PRINTF("\n%-15s:%12lu%12lu%12lu%12lu",#parm, (U32)pm24hrs->parm, (U32)pmCntrs->parm, (U32)pmStart->parm, (U32)pm24hrs->parm + pmCntrs->parm - pmStart->parm)
    
    pmCntrs = &(oampBme[Pid.bmeNum].oampPort[Pid.portNum].PmCounters);
    pmStart = &(oampBme[Pid.bmeNum].oampPort[Pid.portNum].PmCountersAtPortStart);
    pm24hrs = pPmCntr24Hrs[Pid.bmeNum][Pid.portNum];

    IK_PRINTF("\n%-15s   %10s + %10s - %10s = %10s","Parameter","Cur 24hr","Cur 15 min","Port Start","Sessoin");
    IK_PRINTF("\n-----------------------------------------------------------------");	
    PrintPMCounters(NeFEC_S);
    PrintPMCounters(NeCRC_S);
    PrintPMCounters(NeFEC_F);
    PrintPMCounters(NeCRC_F);
    PrintPMCounters(NeLOS);
    PrintPMCounters(NeLOF);
    PrintPMCounters(NeLOM);
    PrintPMCounters(NeNCD_F);
    PrintPMCounters(NeLCD_F);
    PrintPMCounters(NeNCD_S);
    PrintPMCounters(NeLCD_S);
    PrintPMCounters(NeHEC_S);
    PrintPMCounters(NeHEC_F);
    PrintPMCounters(NeFECS);
    PrintPMCounters(NeES);
    PrintPMCounters(NeSES);
    PrintPMCounters(NeESE);
    PrintPMCounters(NeLOSS);
    PrintPMCounters(NeUnavl);
#if 0
    PrintPMCounters(NeFECUnCrr_F);
    PrintPMCounters(NeFECUnCrr_S);
#endif
    PrintPMCounters(FeFEC_S);
    PrintPMCounters(FeCRC_S);
    PrintPMCounters(FeFEC_F);
    PrintPMCounters(FeCRC_F);
    PrintPMCounters(FeLOS);
    PrintPMCounters(FeRDI);
    PrintPMCounters(FeLPR);
    PrintPMCounters(FeLOM);
    PrintPMCounters(FePO);
    PrintPMCounters(FeLCD_S);
    PrintPMCounters(FeLCD_F);
    PrintPMCounters(FeHEC_S);
    PrintPMCounters(FeHEC_F);
    PrintPMCounters(FeFECS);
    PrintPMCounters(FeES);
    PrintPMCounters(FeSES);
    PrintPMCounters(FeESE);
    PrintPMCounters(FeLOSS);
    PrintPMCounters(FeUnavl);
    PrintPMCounters(numUSRcell_F);
    PrintPMCounters(numUSRcell_S);
    PrintPMCounters(numIDLEcell_F);
    PrintPMCounters(numIDLEcell_S);
    PrintPMCounters(numTxBlk_S);
    PrintPMCounters(numTxBlk_F);
    PrintPMCounters(numRxBlk_S);
    PrintPMCounters(numRxBlk_F);
    PrintPMCounters(NeFECUnCrr_F);
    PrintPMCounters(NeFECUnCrr_S);
    PrintPMCounters(numReInit);
    PrintPMCounters(numInitFailure);
    IK_PRINTF("\n");	
 }


#if 0
{
#ifdef INI_SUPPORT
  int IniIndex, IniFast, IniSlow;
#endif // INI_SUPPORT
  ipos_pm_counters *pmCntrs;

  pmCntrs = &(oampBme[Pid.bmeNum].oampPort[Pid.portNum].PmCounters);

  printf ("\nFEC_F: %lu, CRC_F: %u, FEC_S: %lu, CRC_S: %u, LOS: %u SEF: %u LOM: %u",
          pmCntrs->NeFEC_F,
          pmCntrs->NeCRC_F,
          pmCntrs->NeFEC_S,
          pmCntrs->NeCRC_S,
    	  pmCntrs->NeLOS,
    	  pmCntrs->NeLOF,
    	  pmCntrs->NeLOM );

  printf ("\nNeFECUnCrr_F: %s, NeFECUnCrr_S: %s", "N/A", "N/A");
#if 0
          (oampBme[Pid.bmeNum].oampPort[Pid.portNum].Counters.NeFECUnCrr_F),
          (oampBme[Pid.bmeNum].oampPort[Pid.portNum].Counters.NeFECUnCrr_S));
#endif

   printf ("\nTxBlkCnt_F: %s, TxBlkCnt_S: %s, RxBlkCnt_F: %s, RxBlkCnt_S: %s",
           "N/A", "N/A", "N/A", "N/A");
#if 0
          (oampBme[Pid.bmeNum].oampPort[Pid.portNum].Counters.numTxBlk_F),
          (oampBme[Pid.bmeNum].oampPort[Pid.portNum].Counters.numTxBlk_S),
          (oampBme[Pid.bmeNum].oampPort[Pid.portNum].Counters.numRxBlk_F),
          (oampBme[Pid.bmeNum].oampPort[Pid.portNum].Counters.numRxBlk_S));
#endif
              			
   printf ("\nUser cells(bearer0): %lu,   User cells(bearer1): %lu, \nIdle cells(bearer0): %lu,   Idle cells(bearer1): %lu",
    	  pmCntrs->numUSRcell_F,
          pmCntrs->numUSRcell_S,
          pmCntrs->numIDLEcell_F,
          pmCntrs->numIDLEcell_S);

   printf ("\nNCD_F: %u,    NCD_S: %u,    OCD_F: %u,    OCD_S: %u,    HEC_F: %u,    HEC_S: %u",
   		  pmCntrs->NeNCD_F,
       	  pmCntrs->NeNCD_S,
		  pmCntrs->NeLCD_F,
       	  pmCntrs->NeLCD_S,
		  pmCntrs->NeHEC_F,
       	  pmCntrs->NeHEC_S);

	
  printf ("\nFE_FEC_F: %hu, FE_CRC_F: %hu, FE_FEC_S: %hu, FE_CRC_S: %hu",
          pmCntrs->FeFEC_F,
          pmCntrs->FeCRC_F,
          pmCntrs->FeFEC_S,
          pmCntrs->FeCRC_S);

  printf ("\nFE_LOS: %hu,   FE_RDI: %hu,   FE_LPR: %hu    FE_LOM: %hu    FE_PO: %s",
    	  pmCntrs->FeLOS,
    	  pmCntrs->FeRDI,
    	  pmCntrs->FeLPR,
    	  pmCntrs->FeLOM,
          "N/A");


  printf ("\nFE_OCD_F: %hu, FE_OCD_S: %hu, FE_HEC_F: %hu, FE_HEC_S: %hu",
          pmCntrs->FeLCD_F,
       	  pmCntrs->FeLCD_S,
          pmCntrs->FeHEC_F,
       	  pmCntrs->FeHEC_S );

#ifdef INI_SUPPORT
/* Added for Dual Latency Support*/
	getIniMap(Pid, &IniIndex, &IniSlow, &IniFast);

	iposPtmfPrintCounters (IniIndex);
	if (IniSlow != IniFast)
	{
	   iposPtmfPrintCounters (IniIndex + 1);
	}

#endif  // INI_SUPPORT*/

}
#endif

#if 0

void displayPmCounters(ipos_port_id Pid)
{

#ifdef INI_SUPPORT
    int IniIndex, IniFast, IniSlow;
#endif // INI_SUPPORT
  ipos_pm_counters *pmCntrs;

  pmCntrs = &(oampBme[Pid.bmeNum].oampPort[Pid.portNum].PmCounters);

  printf ("\n\t PERFORMANCE MANAGEMENT DATA\n");
  printf ("\nALERTS");
  printf ("\n======");
  printf ("\nNear-End Failures: 0x%04X; Far-end Failures: 0x%04X",
           pmCntrs->NeFailures, pmCntrs->FeFailures); 
  printf ("\nNear-End TCA1    : 0x%04X; Far-end TCA1    : 0x%04X",
           pmCntrs->NeTCA1, pmCntrs->FeTCA1); 
  printf ("\nNear-End TCA2    : 0x%04X; Far-end TCA2    : 0x%04X",
           pmCntrs->NeTCA2, pmCntrs->FeTCA2); 

  printf ("\n\nFAILURE COUNTS");
  printf ("\n==============");
  printf ("\nNeLOS=%u; NeLOF=%u; NeLOM=%u; NeESE=%u", pmCntrs->NeLOS,
          pmCntrs->NeLOF, pmCntrs->NeLOM, pmCntrs->NeESE); 
  printf ("\nFeLOS=%u; FeLOF=%u; FeLPR=%u; FeLOM=%u; FeESE=%u", pmCntrs->FeLOS,
          pmCntrs->FeRDI, pmCntrs->FeLPR, pmCntrs->FeLOM, pmCntrs->FeESE); 
  printf ("\nNeNCD_S=%u; NeLCD_S=%u; NeNCD_F=%u; NeLCD_F=%u;", pmCntrs->NeNCD_S,
          pmCntrs->NeLCD_S, pmCntrs->NeNCD_F, pmCntrs->NeLCD_F); 
  printf ("\nFeNCD_S=%u; FeLCD_S=%u; FeNCD_F=%u; FeLCD_F=%u;", pmCntrs->FeNCD_S,
          pmCntrs->FeLCD_S, pmCntrs->FeNCD_F, pmCntrs->FeLCD_F); 

  printf ("\n\nCOUNT OF SECONDS WITH ANOMALY");
  printf ("\n=============================");
  printf ("\nNeFECS=%u; NeES=%u; NeSES=%u; NeLOSS=%u",
          pmCntrs->NeFECS, pmCntrs->NeES, pmCntrs->NeSES, pmCntrs->NeLOSS);
  printf ("\nFeFECS=%u; FeES=%u; FeSES=%u; FeLOSS=%u",
          pmCntrs->FeFECS, pmCntrs->FeES, pmCntrs->FeSES, pmCntrs->FeLOSS);

  printf ("\n\nANOMALY COUNTERS");
  printf ("\n================");
  printf ("\nNeFEC_S=%lu; NeFEC_F=%lu;", pmCntrs->NeFEC_S, pmCntrs->NeFEC_F);
  printf ("\nNeCRC_S=%lu; NeCRC_F=%lu;", pmCntrs->NeCRC_S, pmCntrs->NeCRC_F);
  printf ("\nNeHEC_S=%lu; NeHEC_F=%lu;", pmCntrs->NeHEC_S, pmCntrs->NeHEC_F);
  printf ("\nFeFEC_S=%lu; FeFEC_F=%lu;", pmCntrs->FeFEC_S, pmCntrs->FeFEC_F);
  printf ("\nFeCRC_S=%lu; FeCRC_F=%lu;", pmCntrs->FeCRC_S, pmCntrs->FeCRC_F);
  printf ("\nFeHEC_S=%lu; FeHEC_F=%lu;", pmCntrs->FeHEC_S, pmCntrs->FeHEC_F);

  printf ("\n\nCELL COUNTERS");
  printf ("\n=============");
  printf ("\nUser Cells(bearer1)=%lu; User Cells(bearer0)=%lu",
           pmCntrs->numUSRcell_S, pmCntrs->numUSRcell_F);
  printf ("\nIdle Cells(bearer1)=%lu; Idle Cells(bearer0)=%lu",
           pmCntrs->numIDLEcell_S, pmCntrs->numIDLEcell_F); 

#if 0
  printf ("\n\n");

#ifdef INI_SUPPORT
        /* Added for Dual Latency Support*/
	getIniMap(Pid, &IniIndex, &IniSlow, &IniFast);

	iposPtmfPrintCounters (IniIndex);
	if (IniSlow != IniFast)
	{
	   iposPtmfPrintCounters (IniIndex + 1);
	}
#endif  // INI_SUPPORT*/

#endif

}
#endif

void	uiLogPortStatusBrief(ipos_port_id pid, ipos_port_status_brief	*pPortStatus)
{
#ifdef ALASKA
        FILE *vdslout;
        int i;

        vdslout = fopen("/tmp/vdslcmd.out","w+");
        if(vdslout == NULL)
        {
          perror("uiLogPortStatusBrief: cannot open /tmp/vdslcmd.out in w+ mode");
          return;
        }
        fprintf (vdslout,"\nBrief Port Status");
        fprintf (vdslout,"\n=================");
#else
	printf ("\nBrief Port Status");
	printf ("\n=================");
#endif
	if (pPortStatus->portStatus&0x1)
	{
#ifdef ALASKA
	   	fprintf (vdslout,"\nBme: %d  Port: %d Status: Port Enabled(Provisioned)",pid.bmeNum,pid.portNum);
#else
	   	printf ("\nBme: %d  Port: %d Status: Port Enabled(Provisioned)",pid.bmeNum,pid.portNum);
#endif
	}

	if (pPortStatus->portStatus&0x4)
	{
#ifdef ALASKA
		fprintf (vdslout,"\nBme: %d  Port: %d Status: Port Showtime",pid.bmeNum,pid.portNum);
#else
		printf ("\nBme: %d  Port: %d Status: Port Showtime",pid.bmeNum,pid.portNum);
#endif
	}
	else if (pPortStatus->portStatus&0x2)
	{
#ifdef ALASKA
	   fprintf (vdslout,"\nBme: %d  Port: %d Status: Port Activating",pid.bmeNum,pid.portNum);
#else
	   printf ("\nBme: %d  Port: %d Status: Port Activating",pid.bmeNum,pid.portNum);
#endif
	
	}

#ifdef ALASKA
        if(!webflag)
        {
	  fflush(vdslout);
	  rewind(vdslout);
	  while((i=fgetc(vdslout))!=EOF)
                printf("%c",i);
	}
	fclose(vdslout);
#endif
	printf(PROMPT);
}



char * convertLineTypeToString (U32 LineType)
{
  char * str;
  int i = 0;
  while ((ui_line_type[i].type != 0) && (ui_line_type[i].type != LineType)) i++;
  str = ui_line_type[i].name;
  return (str);
}

void	uiLogPortStatus(ipos_port_id pid, ipos_port_status	*pPortStatus, int bandRate)
{

	short txPwr = pPortStatus->TransmitPower;
	short sign;
	int i;
	
#ifdef ALASKA
        FILE *vdslout;
        vdslout = fopen("/tmp/vdslcmd.out","w+");
        if(vdslout == NULL)
        {
          perror("uiLogPortStatus(): cannot open /tmp/vdslcmd.out in w+ mode");
          return;
        }

	fprintf (vdslout,"\nExtended Port Status");
	fprintf (vdslout,"\n=================");
	fprintf (vdslout,"\nBme: %d Port: %d",pid.bmeNum,pid.portNum);

	fprintf (vdslout,"\nDownstream line rate: %ld kbps", pPortStatus->DsLineRate*bandRate);

	fprintf (vdslout,"\nUpstream line rate: %ld kbps",pPortStatus->UsLineRate*bandRate);

	fprintf (vdslout,"\nBearer0 Downstream payload rate: %ld kbps",pPortStatus->FastDsPayloadRate*bandRate);

	fprintf (vdslout,"\nBearer1 Downstream payload rate: %ld kbps",pPortStatus->SlowDsPayloadRate*bandRate);

	fprintf (vdslout,"\nBearer0 Upstream payload rate: %ld kbps", pPortStatus->FastUsPayloadRate*bandRate);

	fprintf (vdslout,"\nBearer1 Upstream payload rate: %ld kbps",pPortStatus->SlowUsPayloadRate*bandRate);

	fprintf (vdslout,"\nDownstream attainable payload rate: %d kbps",
          pPortStatus->DsAttainableRate*bandRate);

	fprintf (vdslout,"\nDownstream attainable line rate: %d kbps",
          pPortStatus->DsAttainableLineRate*bandRate);
#else
	printf ("\nExtended Port Status");
	printf ("\n=================");
	printf ("\nBme: %d Port: %d",pid.bmeNum,pid.portNum);


	printf ("\nDownstream line rate: %ld kbps", pPortStatus->DsLineRate*bandRate);

	printf ("\nUpstream line rate: %ld kbps",pPortStatus->UsLineRate*bandRate);

	printf ("\nBearer0 Downstream payload rate: %ld kbps",pPortStatus->FastDsPayloadRate*bandRate);

	printf ("\nBearer1 Downstream payload rate: %ld kbps",pPortStatus->SlowDsPayloadRate*bandRate);

	printf ("\nBearer0 Upstream payload rate: %ld kbps", pPortStatus->FastUsPayloadRate*bandRate);

	printf ("\nBearer1 Upstream payload rate: %ld kbps",pPortStatus->SlowUsPayloadRate*bandRate);

	printf ("\nDownstream attainable payload rate: %d kbps",
          pPortStatus->DsAttainableRate*bandRate);

	printf ("\nDownstream attainable line rate: %d kbps",
          pPortStatus->DsAttainableLineRate*bandRate);
#endif

#ifdef VTU_O
	printf ("\nUpstream attainable payload rate: %d kbps",
      pPortStatus->UsAttainableRate*bandRate);

	printf ("\nUpstream attainable line rate: %d kbps",
      pPortStatus->UsAttainableLineRate*bandRate);
#endif

#ifdef ALASKA
	fprintf (vdslout,"\nDownstream Training Margin: %d.%d dB", pPortStatus->DsTrainingMargin / 10,
          pPortStatus->DsTrainingMargin % 10);
#else
	printf ("\nDownstream Training Margin: %d.%d dB", pPortStatus->DsTrainingMargin / 10,
          pPortStatus->DsTrainingMargin % 10);
#endif

#ifdef VTU_O
	printf ("\nUpstream Training Margin: %d.%d dB", pPortStatus->UsTrainingMargin / 10,
          pPortStatus->UsTrainingMargin % 10);
#endif

#ifdef ALASKA
	fprintf (vdslout,"\nDownstream Line Protection (Bearer1 Path): %d.%d DMT Symbols",
          pPortStatus->SlowDsLineProtection/ 10, pPortStatus->SlowDsLineProtection % 10);

	fprintf (vdslout,"\nUpstream Line Protection (Bearer1 Path): %d.%d DMT Symbols",
          pPortStatus->SlowUsLineProtection/ 10, pPortStatus->SlowUsLineProtection % 10);

  fprintf (vdslout,"\nNear-end ITU Vendor Id: 0x");
  for (i = 0; i < 8; i++)
    fprintf (vdslout,"%02x", pPortStatus->NeItuVendorId[i]);

  fprintf (vdslout,"\nFar-end ITU Vendor Id: 0x");
  for (i = 0; i < 8; i++)
    fprintf (vdslout,"%02x", pPortStatus->FeItuVendorId[i]);

	fprintf (vdslout,"\nDownstream delay: %d.%d ms", pPortStatus->DsDelay/10, pPortStatus->DsDelay%10);
	fprintf (vdslout,"\nUpstream delay: %d.%d ms", pPortStatus->UsDelay/10, pPortStatus->UsDelay%10);
#else
	printf ("\nDownstream Line Protection (Bearer1 Path): %d.%d DMT Symbols",
          pPortStatus->SlowDsLineProtection/ 10, pPortStatus->SlowDsLineProtection % 10);

	printf ("\nUpstream Line Protection (Bearer1 Path): %d.%d DMT Symbols",
          pPortStatus->SlowUsLineProtection/ 10, pPortStatus->SlowUsLineProtection % 10);

  printf ("\nNear-end ITU Vendor Id: 0x");
  for (i = 0; i < 8; i++)
    printf ("%02x", pPortStatus->NeItuVendorId[i]);

  printf ("\nFar-end ITU Vendor Id: 0x");
  for (i = 0; i < 8; i++)
    printf ("%02x", pPortStatus->FeItuVendorId[i]);

	printf ("\nDownstream delay: %d.%d ms", pPortStatus->DsDelay/10, pPortStatus->DsDelay%10);
	printf ("\nUpstream delay: %d.%d ms", pPortStatus->UsDelay/10, pPortStatus->UsDelay%10);
#endif
	
	if(txPwr>=0) 
		sign = 1;
	else
	{
		sign = -1;
	}
	txPwr = sign*txPwr;
	
#ifdef ALASKA
	fprintf(vdslout,"\nTx total power %d.%d dbm", sign*(txPwr / 10), txPwr % 10);
#else
	printf("\nTx total power %d.%d dbm", sign*(txPwr / 10), txPwr % 10);
#endif

	txPwr = pPortStatus->FeTransmitPower;
	if(txPwr>=0) 
		sign = 1;
	else
		sign = -1;
	txPwr = sign*txPwr;
#ifdef ALASKA
	fprintf(vdslout,"\nFE Tx total power %d.%d dbm", sign*(txPwr / 10), txPwr % 10);
    /* Printing the Loop Length. */
    fprintf(vdslout,"\nVDSL Estimated Loop Length : %d ft",pPortStatus->LoopLength);
    fprintf(vdslout,"\nG.Hs Estimated Near End Loop Length : %d ft", pPortStatus->ghsNearEndLoopLength);
    fprintf(vdslout,"\nG.Hs Estimated Far End Loop Length :%d ft",pPortStatus->ghsFarEndLoopLength);
    fprintf(vdslout,"\nCurrent framing mode: 0x%02x",pPortStatus->currentFramingMode);
    
    fprintf(vdslout,"\nBandplan Type...........: %d", pPortStatus->bandType);
    fprintf(vdslout,"\nNo. of Upstream Bands...: %d", pPortStatus->numOfBandsUsDs >> 4);
    fprintf(vdslout,"\nNo. of Downstream Bands.: %d", pPortStatus->numOfBandsUsDs & 0x0f);
    fprintf(vdslout,"\nLine Type: 0x%08x\n",pPortStatus->LineType);
   if(!webflag)
   {
     fflush(vdslout);
     rewind(vdslout);
     while((i=fgetc(vdslout))!=EOF)
	printf("%c",i);
   }
   fclose(vdslout);
#else
	printf("\nFE Tx total power %d.%d dbm", sign*(txPwr / 10), txPwr % 10);

    /* Printing the Loop Length. */
    printf("\nVDSL Estimated Loop Length : %d ft",pPortStatus->LoopLength);
    printf("\nG.Hs Estimated Near End Loop Length : %d ft", pPortStatus->ghsNearEndLoopLength);
    printf("\nG.Hs Estimated Far End Loop Length :%d ft",pPortStatus->ghsFarEndLoopLength);
    printf("\nCurrent framing mode: 0x%02x",pPortStatus->currentFramingMode);
    
    printf("\nBandplan Type...........: %d", pPortStatus->bandType);
    printf("\nNo. of Upstream Bands...: %d", pPortStatus->numOfBandsUsDs >> 4);
    printf("\nNo. of Downstream Bands.: %d", pPortStatus->numOfBandsUsDs & 0x0f);
    printf("\nLine Type: 0x%08x",pPortStatus->LineType);
	printf(PROMPT);
#endif
}

void	uiLogPortCounters(ipos_port_id pid, ipos_port_counters	*pPortCounters)
{
 	  displayPerfCntrs(pid);
		printf ("%s ",PROMPT);
}

void	uiLogPortPmCounters(ipos_port_id pid, ipos_pm_counters *pPmCntr)
{
    displayPmCounters(pid);
    printf ("%s ",PROMPT);
}

void	uiLogPortNeSnr(ipos_port_id pid, ipos_port_nesnrattn  *pPortNeSnr)
{
#ifdef ALASKA
        FILE *vdslout;
        int i;

        vdslout = fopen("/tmp/vdslcmd.out","w+");
        if(vdslout == NULL)
        {
          perror("uiLogPortNeSnr(): cannot open /tmp/vdslcmd.out in w+ mode");
          return;
        }

	fprintf (vdslout,"\nGet Near End SNR Margin and Attenuation for Bme: %d Port %d",pid.bmeNum,pid.portNum);
	fprintf (vdslout,"\n=================");
	fprintf (vdslout,"\nSNR Margin: ");
#else
	printf ("\nGet Near End SNR Margin and Attenuation for Bme: %d Port %d",pid.bmeNum,pid.portNum);
	printf ("\n=================");
	printf ("\nSNR Margin: ");
#endif


	if (pPortNeSnr->SnrMargin < 0)
	{
		pPortNeSnr->SnrMargin *= -1;
#ifdef ALASKA
		fprintf(vdslout,"-");
#else
		printf("-");
#endif
	}
#ifdef ALASKA
	fprintf (vdslout,"%ld.%ld dB",pPortNeSnr->SnrMargin / 10, pPortNeSnr->SnrMargin % 10);
	fprintf (vdslout,"\nAttenuation: ");
	fprintf (vdslout,"%ld.%ld dB", pPortNeSnr->Attn / 10,pPortNeSnr->Attn % 10);

	fprintf (vdslout,"\nAvg SNR Margin: ");
	if (pPortNeSnr->SnrAvgMargin < 0)
	{
		pPortNeSnr->SnrAvgMargin *= -1;
		fprintf(vdslout,"-");
	}
	fprintf (vdslout,"%ld.%ld dB",pPortNeSnr->SnrAvgMargin / 10, pPortNeSnr->SnrAvgMargin % 10);

	fprintf (vdslout,"\nAvg SNR: ");
	if (pPortNeSnr->SnrAvg < 0)
	{
		pPortNeSnr->SnrAvg *= -1;
		fprintf(vdslout,"-");
	}
	fprintf (vdslout,"%ld.%ld dB\n",pPortNeSnr->SnrAvg / 10, pPortNeSnr->SnrAvg % 10);
        if(!webflag)
        {
	  fflush(vdslout);
          rewind(vdslout);
          while((i=fgetc(vdslout))!=EOF)
                printf("%c",i);
        }
        fclose(vdslout);
#else
	printf ("%ld.%ld dB",pPortNeSnr->SnrMargin / 10, pPortNeSnr->SnrMargin % 10);
	printf ("\nAttenuation: ");
	printf ("%ld.%ld dB", pPortNeSnr->Attn / 10,pPortNeSnr->Attn % 10);

	printf ("\nAvg SNR Margin: ");
	if (pPortNeSnr->SnrAvgMargin < 0)
	{
		pPortNeSnr->SnrAvgMargin *= -1;
		printf("-");
	}
	printf ("%ld.%ld dB",pPortNeSnr->SnrAvgMargin / 10, pPortNeSnr->SnrAvgMargin % 10);

	printf ("\nAvg SNR: ");
	if (pPortNeSnr->SnrAvg < 0)
	{
		pPortNeSnr->SnrAvg *= -1;
		printf("-");
	}
	printf ("%ld.%ld dB",pPortNeSnr->SnrAvg / 10, pPortNeSnr->SnrAvg % 10);
	printf(PROMPT);
#endif

}

/* log status to the UI terminal	*/

void  uiLog(ipos_port_id pid, char *funcName,U8 cmdtag,int status, int errCode)
{
#ifndef BUP_DIAGS
	switch(status)
	{

	case	OAMP_IN_PROGRESS:
		printf("\nb%dp%d  %s cmdtag %d status: IN PROGRESS ",pid.bmeNum, pid.portNum, funcName, cmdtag);
		break;

	case	OAMP_COMPLETE:
		printf("\nb%dp%d  %s cmdtag %d status: COMPLETE ",pid.bmeNum, pid.portNum, funcName, cmdtag);
		break;

	case	OAMP_FAILED:
		printf("\nb%dp%d  %s cmdtag %d status: FAILED error= 0x%x",pid.bmeNum, pid.portNum, funcName, cmdtag, errCode);
		break;

	case	OAMP_RESTART:
		printf("\nb%dp%d  %s cmdtag %d status: RESTART ",pid.bmeNum, pid.portNum, funcName, cmdtag);
		break;

	default:
		printf("\nFailed to print the OAMP function status ");
		break;

	}
	printf(PROMPT);
#endif

}

void	uiLogDeviceVer(int bmeNum, int	len, char *string)
{

		int	i;

#ifdef ALASKA
               FILE *vdslout;

               if(webflag)
               {
                vdslout = fopen("/tmp/vdslcmd.out","w");
                if(vdslout == NULL)
                {
                  perror("uiLogDeviceVer(): cannot open /tmp/vdslcmd.out in write mode");
                  return;
                }
		fprintf (vdslout,"\nBME Firmware Versions");
		fprintf (vdslout,"\n=====================\n");
		for (i=0;i<len;i++)
		{
			fprintf (vdslout,"%c", string[i]);
		
		}
		fprintf(vdslout,"\n");
                fclose(vdslout);
               }
               else
               {
#endif
		printf ("\nBME Firmware Versions");
		printf ("\n=====================\n");
		for (i=0;i<len;i++)
		{
			printf ("%c", string[i]);
		
		}
				

		printf(PROMPT);
#ifdef ALASKA
              }
#endif

}


/*******************************************************************
 Name       : Retrieve System Configuration
 Description: Retrieves the System Configuration from the HOST_RETRIEVE_BME_CONFIG
              message sent from BME, into a local variable of type tSystemProv.
*********************************************************************/

void RetrieveSysConfig (ipos_port_id pid, U8 uid, U32 upar, int status, struct tSystemProv *currSysParams, 
                        struct tSystemProv *rxSysParms)
{
  DumpSysConfig (pid, rxSysParms, currSysParams);
}


/*******************************************************************
 Name       : Dump System Configuration
 Description: Dumps the System Configuration from tSystemProv structure
              on the standard output.
*********************************************************************/

void DumpSysConfig (ipos_port_id pid, struct tSystemProv *newSysProv, struct tSystemProv *oldSysProv)
{
  int i, size;

  /* New Line */
  printf ("\n");

  printf("---------------------------------------\n");
  printf("BME %02d Configuration\n", pid.bmeNum);
  printf("---------------------------------------\n\n");


  /* T1E1 Vendor ID */
  printf ("  VendorId T1E1 = %d%c; ", newSysProv->VendorIdT1E1, 
             (newSysProv->VendorIdT1E1 != oldSysProv->VendorIdT1E1) ? '+' : ' ');

  /* ITU Vendor ID */
  size=sizeof (newSysProv->VendorIdItu);
  printf ("  VendorId ITU = `");
  for (i=0; i<size-1; i++)
    printf ("%02x ", newSysProv->VendorIdItu[i]); 
  printf ("%02x'%c; ", newSysProv->VendorIdItu[size-1], 
              (memcmp (&newSysProv->VendorIdItu, &oldSysProv->VendorIdItu, size)) ? '+': ' '); 

  /* New Line */
  printf ("\n");

  /* Revision Num */
  printf ("  Revision Num = %d%c; ", (int) newSysProv->RevisionNum, 
             (newSysProv->RevisionNum != oldSysProv->RevisionNum) ? '+' : ' ');

  /* New Line */
  printf ("\n");

  /* Serial Number */
  size=sizeof (newSysProv->SerialNumber);
  printf ("  Serial Number = `");
  for (i=0; i<size-1; i++) {
    if (i == size/2)
      printf("\n                   ");
    printf ("%x ", newSysProv->SerialNumber[i]); 
  }
  printf ("%x'%c; ", newSysProv->SerialNumber[size-1], 
              (memcmp (&newSysProv->SerialNumber, &oldSysProv->SerialNumber, size)) ? '+': ' '); 

  /* New Line */
  printf ("\n");

  /* Atm Option */
  printf ("  Atm Option = %d%c; ", newSysProv->AtmOption, 
             (newSysProv->AtmOption != oldSysProv->AtmOption) ? '+' : ' ');

  /* AtmCellSize */
  printf ("  Atm Cell Size = %d%c; ", newSysProv->AtmCellSize, 
             (newSysProv->AtmCellSize != oldSysProv->AtmCellSize) ? '+' : ' ');


  /* OptionMask */
  printf ("  Option Mask = %d%c; ", newSysProv->OptionMask, 
             (newSysProv->OptionMask != oldSysProv->OptionMask) ? '+' : ' ');

  /* New Line */
  printf ("\n");

  /* Band Plan */
  printf ("  Band Plan = %d%c; ", newSysProv->BandPlan, 
             (newSysProv->BandPlan != oldSysProv->BandPlan) ? '+' : ' ');


  /* Num Port */
  printf ("  Max Ports = %d%c; ", newSysProv->NumPort, 
             (newSysProv->NumPort != oldSysProv->NumPort) ? '+' : ' ');

  /* PSD Mask Level Index */
  printf ("  PSD Mask Index = %d%c; ", newSysProv->psdMaskLevelIndx, 
             (newSysProv->psdMaskLevelIndx != oldSysProv->psdMaskLevelIndx) ? '+' : ' ');

  /* New Line */
  printf ("\n");

  /* K0 values lower US bands */
  printf ("  K0 = `%d %d %d'%c; ", (int) newSysProv->k0[0], (int) newSysProv->k0[1], (int) newSysProv->k0[2],
              (memcmp (&newSysProv->k0, &oldSysProv->k0, 12)) ? '+': ' '); 

  /* K0 values for higher US bands 4th band onwards */
  printf ("  K0_hi = `%d %d %d'%c; ", (int) newSysProv->k0_hi[0], (int) newSysProv->k0_hi[1], (int) newSysProv->k0_hi[2],
              (memcmp (&newSysProv->k0_hi, &oldSysProv->k0_hi, 12)) ? '+': ' '); 

  /* K1 values lower US bands */
  printf ("  K1 = `%d %d %d'%c; ", (int) newSysProv->k1[0], (int) newSysProv->k1[1], (int) newSysProv->k1[2],
              (memcmp (&newSysProv->k1, &oldSysProv->k1, 12)) ? '+': ' '); 

  /* K1 values for higher US bands 4th band onwards */
  printf ("  K1_hi = `%d %d %d'%c; ", (int) newSysProv->k1_hi[0], (int) newSysProv->k1_hi[1], (int) newSysProv->k1_hi[2],
              (memcmp (&newSysProv->k1_hi, &oldSysProv->k1_hi, 12)) ? '+': ' '); 

  /* New Line */
  printf ("\n");

  /* Customer ID */
  printf ("  Customer ID = %d%c; ", newSysProv->custId, 
             (newSysProv->custId != oldSysProv->custId) ? '+' : ' ');

  /* Customer keys */
  printf ("  Customer keys = `%x %x %x'%c; ", newSysProv->keys[0], newSysProv->keys[1], newSysProv->keys[2],
              (memcmp (&newSysProv->keys, &oldSysProv->keys, 6)) ? '+': ' '); 

  /* IPOS version */
  printf ("  IPOS version = %d; ", newSysProv->iposVer);

  /* New Line */
  printf ("\n");

  /* New Line */
  printf ("\n");
  printf ("  '+' indicates that new value do not match current value.\n\n");

}

/*******************************************************************
 Name       : Retrieve Port Configuration
 Description: Retrieves the Port Configuration from the HOST_RETRIEVE_PORT_CONFIG
              message sent from BME, into a local variable of type tPortProv.
*********************************************************************/

void RetrievePortConfig(ipos_port_id pid, U8 uid, U32 upar, int status, struct tPortProfile *rxPortProfile, 
                                                                        struct tPortProfile *currPortProfile)
{
    
    DumpPortConfig (pid, rxPortProfile, currPortProfile);

}

void DumpPortConfig (ipos_port_id pid, struct tPortProfile *newPortProfile, struct tPortProfile *oldPortProfile)
{

  struct tPortProvision *newPortParams, *oldPortParams;

  /* New Line */
  printf ("\n");

  printf("------------------------------------\n");
  printf("BME %02d Port %02d Configuration \n", pid.bmeNum, pid.portNum);
  printf("------------------------------------\n\n");

  newPortParams = &newPortProfile->PortProvParms;
  oldPortParams = &oldPortProfile->PortProvParms;

  /* InterleavedChannel */
  printf ("  Utopia Addr (Interleaved = %d%c, Bearer0 = %d%c); ", 
              newPortParams->InterleavedChannel, 
              ((newPortParams->InterleavedChannel != oldPortParams->InterleavedChannel) ? '+' : ' '),
              newPortParams->FastChannel, 
              ((newPortParams->FastChannel != oldPortParams->FastChannel) ? '+' : ' '));

  /* New Line */
  printf ("\n");


  /* LineType */
  printf ("  Line Type = %d%c; ", newPortParams->LineType, 
              (newPortParams->LineType != oldPortParams->LineType) ? '+' : ' ');


  /* DslMode */
  printf ("  DSL Mode = %d%c; ", newPortParams->DslMode, 
              (newPortParams->DslMode != oldPortParams->DslMode) ? '+' : ' ');


  /* RateAdaptationMode */
  printf ("  Rate Adaptation Mode = %d%c; ", newPortParams->RateAdaptationMode, 
              (newPortParams->RateAdaptationMode != oldPortParams->RateAdaptationMode) ? '+' : ' ');

  /* New Line */
  printf ("\n");


  /* Upstream Max Min Rates */
  printf ("  US Rate (in kbps) => Bearer0 (Max=%d%c, Min=%d%c), Bearer1 (Max=%d%c, Min=%d%c);", 
              (int) newPortParams->UpstreamMaxRateFast*64, 
              ((newPortParams->UpstreamMaxRateFast != oldPortParams->UpstreamMaxRateFast) ? '+' : ' '),
              (int) newPortParams->UpstreamMinRateFast*64, 
              ((newPortParams->UpstreamMinRateFast != oldPortParams->UpstreamMinRateFast) ? '+' : ' '),
              (int) newPortParams->UpstreamMaxRateSlow*64, 
              ((newPortParams->UpstreamMaxRateSlow != oldPortParams->UpstreamMaxRateSlow) ? '+' : ' '),
              (int) newPortParams->UpstreamMinRateSlow*64, 
              ((newPortParams->UpstreamMinRateSlow != oldPortParams->UpstreamMinRateSlow) ? '+' : ' '));

  /* New Line */
  printf ("\n");


  /* UpstreamMaxInterDelay */
  printf ("  US Max Interleaver Delay = %d msec%c; ", (int) newPortParams->UpstreamMaxInterDelay, 
              (newPortParams->UpstreamMaxInterDelay != oldPortParams->UpstreamMaxInterDelay) ? '+' : ' ');

  /* New Line */
  printf ("\n");

  /* Downstream Max Min Rates */
  printf ("  DS Rate (in kbps) => Bearer0 (Max=%d%c, Min=%d%c), Bearer1 (Max=%d%c, Min=%d%c); \n", 
              (int) newPortParams->DownstreamMaxRateFast*64, 
              ((newPortParams->DownstreamMaxRateFast != oldPortParams->DownstreamMaxRateFast) ? '+' : ' '),
              (int) newPortParams->DownstreamMinRateFast*64, 
              ((newPortParams->DownstreamMinRateFast != oldPortParams->DownstreamMinRateFast) ? '+' : ' '),
              (int) newPortParams->DownstreamMaxRateSlow*64, 
              ((newPortParams->DownstreamMaxRateSlow != oldPortParams->DownstreamMaxRateSlow) ? '+' : ' '),
              (int) newPortParams->DownstreamMinRateSlow*64, 
              ((newPortParams->DownstreamMinRateSlow != oldPortParams->DownstreamMinRateSlow) ? '+' : ' '));


  /* DownstreamMaxInterDelay */
  printf ("  DS Max Interleaver Delay = %d msec%c; ", (int) newPortParams->DownstreamMaxInterDelay, 
              (newPortParams->DownstreamMaxInterDelay != oldPortParams->DownstreamMaxInterDelay) ? '+' : ' ');

  /* New Line */
  printf ("\n");


  /* NumParity Fast & Slow */
  printf ("  NumParity (Bearer0 = %d%c, Bearer1 = %d%c); ", 
              newPortParams->NumParityFast, 
              ((newPortParams->NumParityFast != oldPortParams->NumParityFast) ? '+' : ' '),
              newPortParams->NumParitySlow, 
              ((newPortParams->NumParitySlow != oldPortParams->NumParitySlow) ? '+' : ' '));

  /* New Line */
  printf ("\n");


  /* UsTargetNoiseMargin */
  printf ("  Noise Margin (US Target = %.1f dB%c, DS Target = %.1f dB%c, Min = %.1f dB%c); ", 
              newPortParams->UsTargetNoiseMargin/2.0, 
              ((newPortParams->UsTargetNoiseMargin != oldPortParams->UsTargetNoiseMargin) ? '+' : ' '),
              newPortParams->DsTargetNoiseMargin/2.0, 
              ((newPortParams->DsTargetNoiseMargin != oldPortParams->DsTargetNoiseMargin) ? '+' : ' '),
              newPortParams->MinNoiseMargin/2.0, 
              ((newPortParams->MinNoiseMargin != oldPortParams->MinNoiseMargin) ? '+' : ' '));


  /* New Line */
  printf ("\n");

#if 0
  /* PortProvParms.BandPlan */
  printf ("  BandPlan = %d%c; ", newPortParams->BandPlan,
              (newPortParams->BandPlan != oldPortParams->BandPlan) ? '+' : ' ');
#endif


  /* PortProvParms.NumRFIBand */
  printf ("  Number of RFI Bands = %d%c; ", newPortParams->NumRFIBand,
              (newPortParams->NumRFIBand != oldPortParams->NumRFIBand) ? '+' : ' ');

  /* New Line */
  printf ("\n");

  /* RFI Band Start & Stop */
  printf ("  RFI Band (start, stop) = `(%d, %d), (%d, %d), (%d, %d), (%d, %d), (%d, %d)'%c ",
    newPortParams->Band1Start, newPortParams->Band1Stop,
    newPortParams->Band2Start, newPortParams->Band2Stop,
    newPortParams->Band3Start, newPortParams->Band3Stop,
    newPortParams->Band4Start, newPortParams->Band4Stop,
    newPortParams->Band5Start, newPortParams->Band5Stop,
    (memcmp (&newPortParams->Band1Start, &oldPortParams->Band1Start, 20)) ? '+': ' '); 

  /* New Line */
  printf ("\n");

  /* RFI Band choosen */
  printf ("  RFI Band choosen = `%x %x %x %x %x'%c; ", newPortParams->RFIBand1, newPortParams->RFIBand2, 
              newPortParams->RFIBand3, newPortParams->RFIBand4, newPortParams->RFIBand5, 
              (memcmp (&newPortParams->RFIBand1, &oldPortParams->RFIBand1, 5)) ? '+': ' '); 

  /* New Line */
  printf ("\n");

  /* BandMod.bandModifier */
  printf ("  Band Modifier = %d%c; ", newPortProfile->BandMod.bandModifier,
              (newPortProfile->BandMod.bandModifier != oldPortProfile->BandMod.bandModifier) ? '+' : ' ');


  /* OptionParms.PortOption */
  printf ("  OptionParms.PortOption = %d%c; ", newPortProfile->OptionParms.PortOption,
              (newPortProfile->OptionParms.PortOption != oldPortProfile->OptionParms.PortOption) ? '+' : ' ');

  /* New Line */
  printf ("\n");

  /* IFE_BRD_CFG.pwrMode */
  printf ("  IFE Config (pwrMode = %d%c, Rx Filter Mode = %d%c, Tx Filter Mode = %d%c); ", 
              newPortProfile->IFE_BRD_CFG.pwrMode,
              ((newPortProfile->IFE_BRD_CFG.pwrMode != oldPortProfile->IFE_BRD_CFG.pwrMode) ? '+' : ' '),
              newPortProfile->IFE_BRD_CFG.rxPathFilterMode,
              ((newPortProfile->IFE_BRD_CFG.rxPathFilterMode != oldPortProfile->IFE_BRD_CFG.rxPathFilterMode) ? '+' : ' '),
              newPortProfile->IFE_BRD_CFG.txPathFilterMode,
              ((newPortProfile->IFE_BRD_CFG.txPathFilterMode != oldPortProfile->IFE_BRD_CFG.txPathFilterMode) ? '+' : ' '));


  /* New Line */
  printf ("\n");

}


ShowtimeParams *
getShowtimeParamsRef( ipos_port_id pid )
{
	int		 lineNum = 0;
	ShowtimeParams	*retAddr = NULL;

	getLineNum( pid, &lineNum );
	if (lineNum > 0 &&
	    (unsigned int) lineNum <= sizeof( showtimeParams ) / sizeof( showtimeParams[ 0 ] ))
	  retAddr = &showtimeParams[ lineNum - 1 ];

	return( retAddr );
}

#define STORE_SHOWTIME_PARAM( dest, source, field )	\
		dest->field = source->field

void
storeShowtimeParams( ipos_port_id pid, const ipos_port_status *pPortStatus )
{
	ShowtimeParams	*pShowtimeParams = getShowtimeParamsRef( pid );

	if (pShowtimeParams != NULL)
	{
		STORE_SHOWTIME_PARAM( pShowtimeParams, pPortStatus, SlowUsFFTProtection );
		STORE_SHOWTIME_PARAM( pShowtimeParams, pPortStatus, SlowDsFFTProtection );
		STORE_SHOWTIME_PARAM( pShowtimeParams, pPortStatus, FastDsNumParityBytes );
		STORE_SHOWTIME_PARAM( pShowtimeParams, pPortStatus, SlowDsNumParityBytes );
		STORE_SHOWTIME_PARAM( pShowtimeParams, pPortStatus, FastUsNumParityBytes );
		STORE_SHOWTIME_PARAM( pShowtimeParams, pPortStatus, SlowUsNumParityBytes );
		STORE_SHOWTIME_PARAM( pShowtimeParams, pPortStatus, FastDsCodeWordSize );
		STORE_SHOWTIME_PARAM( pShowtimeParams, pPortStatus, SlowDsCodeWordSize );
		STORE_SHOWTIME_PARAM( pShowtimeParams, pPortStatus, FastUsCodeWordSize );
		STORE_SHOWTIME_PARAM( pShowtimeParams, pPortStatus, SlowUsCodeWordSize );
		STORE_SHOWTIME_PARAM( pShowtimeParams, pPortStatus, DsInterleaverDepth );
		STORE_SHOWTIME_PARAM( pShowtimeParams, pPortStatus, UsInterleaverDepth );
		STORE_SHOWTIME_PARAM( pShowtimeParams, pPortStatus, DsInterleaverBlkLen );
		STORE_SHOWTIME_PARAM( pShowtimeParams, pPortStatus, UsInterleaverBlkLen );
		STORE_SHOWTIME_PARAM( pShowtimeParams, pPortStatus, LineType );
		pShowtimeParams->dataIsValid = 1;
	}
	else
	  printf( "cannot translate b%dp%d into a valid line number\n", pid.bmeNum, pid.portNum );
}

void
displayShowtimeParams( ipos_port_id pid )
{
	const ShowtimeParams	*pShowtimeParams = getShowtimeParamsRef( pid );

	if (pShowtimeParams != NULL && pShowtimeParams->dataIsValid == 1)
	{
		printf ("\nDownstream FFT Protection (Slow Path): %d.%d DMT Symbols",
	          pShowtimeParams->SlowDsFFTProtection/ 10, pShowtimeParams->SlowDsFFTProtection % 10);

		printf ("\nUpstream FFT Protection (Slow Path): %d.%d DMT Symbols",
	          pShowtimeParams->SlowUsFFTProtection/ 10, pShowtimeParams->SlowUsFFTProtection % 10);
	
		printf ("\nFast downstream Reed-Soloman N (codeword size): %d",
		  pShowtimeParams->FastDsCodeWordSize );
		printf ("\nSlow downstream Reed-Soloman N (codeword size): %d",
		  pShowtimeParams->SlowDsCodeWordSize );
		printf ("\nFast upstream Reed-Soloman N (codeword size): %d",
		  pShowtimeParams->FastUsCodeWordSize );
		printf ("\nSlow upstream Reed-Soloman N (codeword size): %d",
		  pShowtimeParams->SlowUsCodeWordSize );
	
		printf ("\nFast downstream Reed-Soloman R (number parity bytes): %d",
		  pShowtimeParams->FastDsNumParityBytes );
		printf ("\nSlow downstream Reed-Soloman R (number parity bytes): %d",
		  pShowtimeParams->SlowDsNumParityBytes );
		printf ("\nFast upstream Reed-Soloman R (number parity bytes): %d",
		  pShowtimeParams->FastUsNumParityBytes );
		printf ("\nSlow upstream Reed-Soloman R (number parity bytes): %d",
		  pShowtimeParams->SlowUsNumParityBytes );
	
		printf ("\nDownstream interleaver parameter M (depth): %d",
		  pShowtimeParams->DsInterleaverDepth );
		printf ("\nUpstream interleaver parameter M (depth): %d",
		  pShowtimeParams->UsInterleaverDepth );
	
		printf ("\nDownstream interleaver parameter I (block length): %d",
		  pShowtimeParams->DsInterleaverBlkLen );
		printf ("\nUpstream interleaver parameter I (block length): %d",
		  pShowtimeParams->UsInterleaverBlkLen );
		printf ("\nLine Type: %s",convertLineTypeToString(pShowtimeParams->LineType)) ;
		printf(PROMPT);
	}
	else if (pShowtimeParams != NULL)
	  printf( "Showtime parameters are not valid for b%dp%d\n", pid.bmeNum, pid.portNum );
        else
	  printf( "Cannot translate b%dp%d into a valid line number\n", pid.bmeNum, pid.portNum );
}

void
invalidateShowtimeParams( ipos_port_id pid )
{
	ShowtimeParams	*pShowtimeParams = getShowtimeParamsRef( pid );

	if (pShowtimeParams != NULL)
	{
		pShowtimeParams->dataIsValid = 0;
	}
	else
	  printf( "cannot translate b%dp%d into a valid line number\n", pid.bmeNum, pid.portNum );
}
