linklayerprotocols/ethernetnif/EtherPkt/Cardctl.h
branchRCL_3
changeset 6 e7dfaa7b0b8d
equal deleted inserted replaced
5:1422c6cd3f0c 6:e7dfaa7b0b8d
       
     1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 /**
       
    17  @file
       
    18  @internalComponent 
       
    19 */
       
    20 
       
    21 #if !defined(__CARDCTL_H__)
       
    22 #define __CARDCTL_H__
       
    23 
       
    24 #include <d32ethernet.h>
       
    25 
       
    26 #include "carddrv.h"
       
    27 #include <comms-infras/connectionsettings.h>	// for KSlashChar
       
    28 
       
    29 const TInt KConfigBufferSize = 12;
       
    30 
       
    31 
       
    32 NONSHARABLE_CLASS(CIOBuffer) : public CBase
       
    33 /**
       
    34 Generic buffer class
       
    35 Enables HBufC8 pointers to be queued
       
    36 @internalComponent
       
    37 */
       
    38 {
       
    39 public:
       
    40 	~CIOBuffer();
       
    41 	inline HBufC8*	Data() const {return iBuf;};
       
    42 	void FreeData();
       
    43 	inline TPtr8& Ptr() {return iBufPtr;};
       
    44 	void Assign(HBufC8* aBuffer = NULL);
       
    45     static CIOBuffer* NewL(HBufC8* aBuf = NULL);
       
    46     static CIOBuffer* NewL(const TInt aSize);
       
    47 	static TInt LinkOffset();
       
    48 
       
    49 private:
       
    50 	CIOBuffer();
       
    51 	void ConstructL(const TInt aSize);
       
    52 	//	void Construct(HBufC8* aBuffer);
       
    53 	
       
    54 	TSglQueLink iLink;
       
    55 	HBufC8* iBuf;
       
    56 	TPtr8 iBufPtr;
       
    57 };
       
    58 
       
    59 
       
    60 // Main Card Control class. Controls open, close, read, write etc 
       
    61 class CPcCardSender;
       
    62 class CPcCardReceiver;
       
    63 class CPcCardIOCTL;
       
    64 class CPcCardEventHandler;
       
    65 
       
    66 NONSHARABLE_CLASS(CPcCardControlEngine) : public CBase
       
    67 /**
       
    68 @internalComponent
       
    69 */
       
    70 {
       
    71 public:
       
    72 	friend class CPcCardSender;
       
    73 	friend class CPcCardReceiver;
       
    74 	friend class CPcCardIOCTL;
       
    75 	friend class CPcCardEventHandler;
       
    76 
       
    77 	static CPcCardControlEngine *NewL(CPcCardPktDrv* aPktDrv);
       
    78 	~CPcCardControlEngine();
       
    79 	void StartL();
       
    80 	void Stop();
       
    81 	TUint8* GetInterfaceAddress();
       
    82 	TInt Send(HBufC8* aBuffer);
       
    83 	TBool CardOpen(){return iCardOpen;};
       
    84 
       
    85 #if (!defined __WINS__)
       
    86 	void ParseMACFromFileL();
       
    87 #endif
       
    88 
       
    89 
       
    90 private:
       
    91 	CPcCardControlEngine(CPcCardPktDrv* aPktDrv);
       
    92 	void ConstructL();
       
    93 	void ProcessReceivedPacket(TDesC8 &aBuffer);
       
    94 	void ResumeSending();
       
    95 	void LinkLayerUp();
       
    96 	void LoadDeviceDriversL();
       
    97 
       
    98 private:
       
    99 	TBool iCardOpen;
       
   100 	CPcCardPktDrv* iNotify;
       
   101 
       
   102 	TBuf8<KConfigBufferSize> iConfig;
       
   103 	
       
   104 	CPcCardSender* iSender;
       
   105 	CPcCardReceiver* iReceiver;
       
   106 	CPcCardEventHandler* iEventHandler;
       
   107 	RBusDevEthernet iCard;
       
   108 	TInt iPcmciaSocket;
       
   109 	
       
   110 	TBuf<KCommsDbSvrDefaultTextFieldLength>	iPDDName;
       
   111 	TBuf<KCommsDbSvrDefaultTextFieldLength>	iLDDName;
       
   112 };
       
   113 
       
   114 NONSHARABLE_CLASS(CPcCardSender) : public CActive
       
   115 /**
       
   116 Writer Active object class
       
   117 Queues buffers for transmit
       
   118 @internalComponent
       
   119 */
       
   120 {
       
   121 public:
       
   122 	static CPcCardSender* NewL(CPcCardControlEngine* aParent);
       
   123 	~CPcCardSender();
       
   124 	TInt Send(CIOBuffer* aBuffer);
       
   125 	void EmptyQueue();
       
   126 
       
   127 private:
       
   128 	virtual void RunL();
       
   129 	virtual void DoCancel();
       
   130 	CPcCardSender();
       
   131 	void InitL(CPcCardControlEngine* aParent);
       
   132 
       
   133 	TInt iQueueLength;
       
   134 	CPcCardControlEngine* iParent;
       
   135 	TSglQue<CIOBuffer> iTxQueue;
       
   136 	TBool iStopSending;
       
   137 };
       
   138 
       
   139 NONSHARABLE_CLASS(CPcCardReceiver) : public CActive
       
   140 /**
       
   141 Reader active object
       
   142 One receive buffer only, read queue handled by LDD
       
   143 @internalComponent
       
   144 */
       
   145 {
       
   146 public:
       
   147 	static CPcCardReceiver* NewL(CPcCardControlEngine* aParent);
       
   148 	~CPcCardReceiver();
       
   149 	void QueueRead();
       
   150 private:
       
   151 	virtual void RunL();
       
   152 	virtual void DoCancel();
       
   153 	CPcCardReceiver();
       
   154 	void InitL(CPcCardControlEngine* aParent);
       
   155 
       
   156 	CPcCardControlEngine* iParent;
       
   157 	HBufC8* iRecvBuffer;
       
   158 	TUint iRecvBufLength;
       
   159 	TPtr8 iRecvBufPtr;
       
   160 };
       
   161 
       
   162 NONSHARABLE_CLASS(CPcCardEventHandler) : public CActive
       
   163 /**
       
   164 @internalComponent
       
   165 */
       
   166 {
       
   167 public:
       
   168 	~CPcCardEventHandler();
       
   169 	static CPcCardEventHandler* NewL(CPcCardControlEngine* aParent);
       
   170 	void GetEvent();
       
   171 private:
       
   172 	virtual void RunL();
       
   173 	virtual void DoCancel();
       
   174 	CPcCardEventHandler();
       
   175 	void InitL(CPcCardControlEngine* aParent);
       
   176 
       
   177 	TBuf8<32>	iEventBuffer;
       
   178 	CPcCardControlEngine* iParent;
       
   179 };
       
   180 
       
   181 NONSHARABLE_CLASS(CPcCardIOCTL) : public CActive
       
   182 /**
       
   183 @internalComponent
       
   184 */
       
   185 {
       
   186 public:
       
   187 	~CPcCardIOCTL();
       
   188 	static CPcCardIOCTL* NewL(CPcCardControlEngine* aParent);
       
   189 	TInt Ioctl(const TUint8 aIOCTLCode);
       
   190 private:
       
   191 	virtual void RunL();
       
   192 	virtual void DoCancel();
       
   193 	CPcCardIOCTL();
       
   194 	void InitL(CPcCardControlEngine* aParent);
       
   195 	TBuf8<32>	iIOCTLBuffer;
       
   196 	TUint8 iCurrentIOCTL;
       
   197 
       
   198 	CPcCardControlEngine* iParent;
       
   199 };
       
   200 
       
   201 #endif