// PLPSOCK.H
//
// Copyright (c) 1997-1999 Symbian Ltd.  All rights reserved.
//

#if !defined(__PLPSOCK_H__)
#define __PLPSOCK_H__

#if !defined(__ES_SOCK_H__)
#include <es_sock.h>
#endif

#if !defined(__PLPLINK_H__)
#include <plplink.h>
#endif

const TUint KFamilyPlp               = 273;
const TUint KProtocolPlpTransport    = 4;
const TUint KProtocolPlpLink         = 11;
const TUint KProtocolPlpLoopback     = 12;

const TUint KPlpInfoIoctl                = 30;
const TUint KPlpSerialConfig             = 31;
const TUint KPlpSerialSetConfig          = 32;
const TUint KPlpLinkReset                = 33;
const TUint KPlpLinkStop                 = 34;
const TUint KPlpLinkStart                = 35;
const TUint KPlpLinkInfo                 = 36;
const TUint KPlpProvdSetMtuSize          = 37;
const TUint KPlpProvdMtuSize             = 38;
const TUint KPlpBinderNumber             = 39;
const TUint KPlpBinderSetLocalVersion    = 40;
const TUint KPlpBinderConfig             = 41;
const TUint KPlpBinderList               = 42;
const TUint KPlpBinderSetActivityMinTime = 43;
const TUint KPlpProvdLogonLink           = 44;
const TUint KPlpProvdLogoffLink          = 45;
const TUint KPlpProvdIsLoggingLink       = 46;
const TUint KPlpLinkIsStarted            = 47;

const TUint KPlpPortAny           = 0;
const TUint KPlpInterfaceAny      = 0;
const TUint KPlpInterfaceDevice0  = 1;
const TUint KPlpInterfaceDevice1  = 2;
const TUint KPlpInterfaceLoopback = 3;

const TInt KPlpMaxServiceName = 16;

typedef TBuf8<KPlpMaxServiceName> TPlpServiceName;

class TPlpAddr : public TSockAddr
    {
public:
    IMPORT_C TPlpAddr(TUint aInterface, const TDesC8 &aDes=TPtrC8(), TUint aPort=KPlpPortAny);
    IMPORT_C TPlpAddr();
    IMPORT_C TUint Interface() const;
    IMPORT_C void SetInterface(TUint aInterface);
    IMPORT_C void SetServiceName(const TDesC8 &aDes);
    IMPORT_C TPtrC8 ServiceName() const;
    };

enum TPlpEvent
    {
    EPlpInitialized, EPlpError, EPlpVerOk, 
    EPlpVerInvalid, EPlpDsrHigh, EPlpActivity
    };
    
class TPlpBinderInfo
    {

public:
    TUint iNum;
    TInt iLastNetError;
    TPlpEvent iEvent;
    TUint8 iRemoteVersionNumber;
    TUint8 iLocalVersion;
    TUint iLocalStartDate;
    TUint iRemoteStartDate;
    TUint iActivityMinTime;
    };

typedef TPckgBuf<TPlpBinderInfo> TPlpBinderInfoBuf;
typedef TPckgBuf<TPlpLinkInfo> TPlpLinkInfoBuf;

class TPlpSerialConfig
    {
public:
    TPlpLinkConfig iLinkConfig;
    TCommAccess iAccess;
    TBufC<KMaxPortName> iPort;
    TBufC<KMaxFileName> iModule;
    };

typedef TPckgBuf<TPlpSerialConfig> TPlpSerialConfigBuf;

const TInt32 KPlpConfigCategory = 268435550;

class TPlpSerialCategory : public TRegistryCategory
    {
public:
    IMPORT_C TPlpSerialCategory();
    IMPORT_C void LinkConfig(TUint iId, TPlpSerialConfig& aConfig) const;
    IMPORT_C void SetLinkConfigL(TUint iId, const TPlpSerialConfig& aConfig);
    IMPORT_C TInt PortConfig(const TDesC& aPort, TPlpSerialConfig& aConfig) const;
    IMPORT_C TInt SetPortConfigL(const TPlpSerialConfig& aConfig);

private:
    static TPtrC8 DefaultConfig(TPlpSerialConfig &aConfig);
    static TPtrC DefaultPort(TUint aId);
    };

#endif __PLPSOCK_H__
