/*****************************************************************************
* Copyright (c) 1990-98 Digi International Inc., All Rights Reserved
* 
* This software contains proprietary and confidential information of Digi
* International Inc.  By accepting transfer of this copy, Recipient agrees
* to retain this software in confidence, to prevent disclosure to others,
* and to make no use of this software other than that for which it was
* delivered.  This is an unpublished copyrighted work of Digi International
* Inc.  Except as permitted by federal law, 17 USC 117, copying is strictly
* prohibited.
* 
* Restricted Rights Legend
*
* Use, duplication, or disclosure by the Government is subject to
* restrictions set forth in sub-paragraph (c)(1)(ii) of The Rights in
* Technical Data and Computer Software clause at DFARS 252.227-7031 or
* subparagraphs (c)(1) and (2) of the Commercial Computer Software -
* Restricted Rights at 48 CFR 52.227-19, as applicable.
*
* Digi International Inc. 11001 Bren Road East, Minnetonka, MN 55343
*
*****************************************************************************/

#ifndef __PVC_H
#define __PVC_H

#include "Port.h"
#include "utils.h"
#include "defs.h"

#define PVC_EXISTING	0x0001
#define PVC_NEW			0x0002
#define PVC_DELETE		0x0004
#define PVC_MODIFIED    0x0008
// Permanent Virtual Channel (PVC) Base class
class SERVICE_EXPORTED_CLASS CPortPVC : public CPort
{
	DECLARE_DYNAMIC(CPortPVC)
// attributes common to both Frame Relay and X.25
protected:

	CString m_szDescription;
	CString m_szNetworkAddress;
	CString m_szProtocol;
    CString m_szIPAddress;
	CString m_szSubnetMask;
	BOOL m_bAutoManage;
	// these are really index specifying routed/bridged/bridged&routed etc.
	// need a better approach
	int	m_nTCPIP;
	int m_nIPX;
	int m_nEthernet;
	DWORD m_nPVCFlags;
	DWORD m_dwSnid;
// operations
public:
	CPortPVC(HKEY const hKeyRoot, CString const strRegPath, CConfigObject const * const pParent);
	virtual ~CPortPVC();
	CPortPVC& operator=(const CPortPVC& rhs);
	// 
	virtual BOOL GetParameters(void);
	virtual BOOL SetParameters(void);
	virtual BOOL RemoveParameters(BOOL fRemoveKey = FALSE);

	virtual BOOL AddChild(void){ASSERT(FALSE);return FALSE;}
	virtual BOOL DoProperties(void){ASSERT(FALSE);return FALSE;}
	virtual void ParentUpdate(void);
	CString GetDescription()const {return m_szDescription;}
	
};

// Frame Relay PVC class
class SERVICE_EXPORTED_CLASS CPortFR : public CPortPVC
{
	DECLARE_DYNAMIC(CPortFR)
//attributes
private:
	int m_nDLCI;
	int m_nBCMAX;
	int m_nBCMIN;
	int m_nBE;
	int m_nCIR;
	int m_nCMP;
	int m_nModeOneRRMax;
	int m_nModeOneRRPeriod;
	int m_nBaudRate;
//operations
public:
	CPortFR(HKEY const hKeyRoot, CString const strRegPath, CConfigObject const * const pParent);
	virtual ~CPortFR();
	CPortFR& operator=(const CPortFR& rhs);
	// 
	virtual BOOL GetParameters(void);
	virtual BOOL SetParameters(void);

	virtual BOOL AddWizardPages(CConfigWizSheet * const pSheet);
	virtual BOOL NextWizardPage(int const nState);

	virtual BOOL AddChild(void){ASSERT(FALSE);return FALSE;}
	virtual BOOL DoProperties(void);
    virtual CString GetInformationText(void);
	virtual void ParentUpdate(void);

	BOOL ValidateDLCI(int nDLCI) const;
	BOOL AssignDLCI(int& rDLCI);
private:
	void SetName();
};


class SERVICE_EXPORTED_CLASS CPortX25 : public CPortPVC
{
	DECLARE_DYNAMIC(CPortX25)
private:
	int m_nChannel;
	int m_nLocDefPktsize;
	int m_nLocDefWsize;
	int m_nRemDefPktsize;
	int m_nRemDefWsize;

public:
	CPortX25(HKEY const hKeyRoot, CString const strRegPath, CConfigObject const * const pParent);
	virtual ~CPortX25();
	CPortX25& operator=(const CPortX25& rhs);
	// 
	virtual BOOL GetParameters(void);
	virtual BOOL SetParameters(void);

	virtual BOOL AddWizardPages(CConfigWizSheet * const pSheet);
	virtual BOOL NextWizardPage(int const nState);

	virtual BOOL AddChild(void){ASSERT(FALSE);return FALSE;}
	virtual BOOL DoProperties(void);
    virtual CString GetInformationText(void);

	BOOL ValidateChannel(int nChannel) const;
	BOOL AssignChannel(int& rChannel);
//	int GetPVCChannel(void) const{return m_nChannel;}
	void SetWindowSize(int remwndsize,int locwndsize);
	BOOL ValidateChannelRange(DWORD nChannelStart,DWORD nChannelEnd);
private:
	void SetName();
   void SetDescription();

};


#endif __PVC_H