|
1 /* |
|
2 * Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Implements receiver class for target |
|
15 * |
|
16 */ |
|
17 |
|
18 /* |
|
19 * %version: 12 % |
|
20 */ |
|
21 |
|
22 #include <nifmbuf.h> |
|
23 #include "am_debug.h" |
|
24 #include "receiver_hw.h" |
|
25 #include "WlanProto.h" |
|
26 #include "carddrv.h" |
|
27 |
|
28 // --------------------------------------------------------- |
|
29 // CReceiver::CReceiver() |
|
30 // --------------------------------------------------------- |
|
31 // |
|
32 CReceiver::CReceiver( CPcCardPktDrv* aParent ) : |
|
33 CActive(EPriorityStandard), |
|
34 iParent(aParent) |
|
35 { |
|
36 } |
|
37 |
|
38 // --------------------------------------------------------- |
|
39 // CReceiver::ConstructL() |
|
40 // --------------------------------------------------------- |
|
41 // |
|
42 void CReceiver::ConstructL() |
|
43 { |
|
44 DEBUG("CReceiver::ConstructL()"); |
|
45 } |
|
46 |
|
47 // --------------------------------------------------------- |
|
48 // CReceiver::NewL() |
|
49 // --------------------------------------------------------- |
|
50 // |
|
51 CReceiver* CReceiver::NewL( CPcCardPktDrv* aParent ) |
|
52 { |
|
53 DEBUG("CReceiver::NewL()"); |
|
54 CReceiver* self = new (ELeave) CReceiver( aParent ); |
|
55 CleanupStack::PushL( self ); |
|
56 self->ConstructL(); |
|
57 CActiveScheduler::Add( self ); |
|
58 CleanupStack::Pop( self ); |
|
59 return self; |
|
60 } |
|
61 |
|
62 // --------------------------------------------------------- |
|
63 // CReceiver::~CReceiver() |
|
64 // --------------------------------------------------------- |
|
65 // |
|
66 CReceiver::~CReceiver() |
|
67 { |
|
68 DEBUG("CReceiver::~CReceiver()"); |
|
69 Cancel(); |
|
70 } |
|
71 |
|
72 // --------------------------------------------------------- |
|
73 // CReceiver::DoCancel() |
|
74 // --------------------------------------------------------- |
|
75 // |
|
76 void CReceiver::DoCancel() |
|
77 { |
|
78 DEBUG("CReceiver::DoCancel()"); |
|
79 iParent->iCard.ReadCancel(); |
|
80 } |
|
81 |
|
82 // --------------------------------------------------------- |
|
83 // CReceiver::QueueRead() |
|
84 // --------------------------------------------------------- |
|
85 // |
|
86 void CReceiver::QueueRead() |
|
87 { |
|
88 iParent->iCard.RequestFrame( iStatus ); |
|
89 SetActive(); |
|
90 } |
|
91 |
|
92 |
|
93 // --------------------------------------------------------- |
|
94 // CReceiver::RunL() |
|
95 // --------------------------------------------------------- |
|
96 // |
|
97 void CReceiver::RunL() |
|
98 { |
|
99 DEBUG("CReceiver::RunL()" ); |
|
100 |
|
101 while( iParent->iFrameXferBlock->GetNextRxDataBuffer( iDataBuffer ) ) |
|
102 { |
|
103 TUint8* buf = iDataBuffer->GetBuffer(); |
|
104 TUint32 len = iDataBuffer->GetLength(); |
|
105 |
|
106 //Save the original buf value which points |
|
107 //to the beginning of the Ethernet header |
|
108 TUint8* bufOrig = buf; |
|
109 |
|
110 DEBUG1("CReceiver::RunL() - packet length: %u", len ); |
|
111 |
|
112 if( buf && len > 0 && len <= KMaxEthernetFrameLength ) |
|
113 { |
|
114 //Now set buf point to the beginning of the Payload |
|
115 buf = buf + KEtherHeaderSize; |
|
116 |
|
117 len = len - KEtherHeaderSize; |
|
118 |
|
119 TPtrC8 pkt(buf, len); |
|
120 RMBufPacket pFrame; //Payload |
|
121 TRAPD( ret, pFrame.CreateL( pkt ) ); |
|
122 if( ret == KErrNone ) |
|
123 { |
|
124 pFrame.Pack(); |
|
125 |
|
126 iParent->iParent->Process( pFrame, bufOrig, iDataBuffer->UserPriority() ); |
|
127 } |
|
128 } |
|
129 } |
|
130 |
|
131 if( iParent->CardOpen() ) |
|
132 { |
|
133 QueueRead(); |
|
134 } |
|
135 } |