|
1 /* |
|
2 * Copyright (c) 2005-2008 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 the License "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: Implementation of the WlanDot11IbssMode class. |
|
15 * |
|
16 */ |
|
17 |
|
18 /* |
|
19 * %version: 21 % |
|
20 */ |
|
21 |
|
22 #include "config.h" |
|
23 #include "UmacDot11IbssMode.h" |
|
24 #include "UmacContextImpl.h" |
|
25 |
|
26 // ======== MEMBER FUNCTIONS ======== |
|
27 |
|
28 // --------------------------------------------------------------------------- |
|
29 // |
|
30 // --------------------------------------------------------------------------- |
|
31 // |
|
32 void WlanDot11IbssMode::DoSetTxMpduDaAddress( |
|
33 SDataFrameHeader& aDataFrameHeader, |
|
34 const TMacAddress& aMac ) const |
|
35 { |
|
36 aDataFrameHeader.iAddress1 = aMac; |
|
37 } |
|
38 |
|
39 // --------------------------------------------------------------------------- |
|
40 // |
|
41 // --------------------------------------------------------------------------- |
|
42 // |
|
43 TBool WlanDot11IbssMode::DoIsRxFrameSAourAddress( |
|
44 WlanContextImpl& aCtxImpl, |
|
45 const SDataFrameHeader& aFrameHeader, |
|
46 const SAmsduSubframeHeader* /*aSubFrameHeader*/) const |
|
47 { |
|
48 return aFrameHeader.iAddress2 == aCtxImpl.iWlanMib.dot11StationId; |
|
49 } |
|
50 |
|
51 // --------------------------------------------------------------------------- |
|
52 // |
|
53 // --------------------------------------------------------------------------- |
|
54 // |
|
55 TBool WlanDot11IbssMode::DoIsValidAddressBitCombination( |
|
56 const SDataFrameHeader& aFrameHeader ) const |
|
57 { |
|
58 return !( aFrameHeader.IsFromDsBitSet() |
|
59 || aFrameHeader.IsToDsBitSet() ); |
|
60 } |
|
61 |
|
62 // --------------------------------------------------------------------------- |
|
63 // |
|
64 // --------------------------------------------------------------------------- |
|
65 // |
|
66 void WlanDot11IbssMode::DoBuildEthernetFrame( |
|
67 TDataBuffer& aBuffer, |
|
68 const SDataMpduHeader& aDot11DataMpdu, |
|
69 const TUint8* aStartOfEtherPayload, |
|
70 TUint aEtherPayloadLength, |
|
71 TBool /*aAmsdu*/, |
|
72 TUint8* /*aCopyBuffer*/ ) |
|
73 { |
|
74 OsTracePrint( KUmacDetails, (TUint8*) |
|
75 ("UMAC: WlanDot11InfrastructureMode::DoBuildEthernetFrame")); |
|
76 |
|
77 // copy SA to the correct location. |
|
78 os_memcpy( |
|
79 const_cast<TUint8*>(aStartOfEtherPayload) - sizeof( TMacAddress ), |
|
80 reinterpret_cast<const TUint8*>( |
|
81 aDot11DataMpdu.iHdr.iAddress2.iMacAddress ), |
|
82 sizeof( TMacAddress ) ); |
|
83 |
|
84 // copy DA to the correct location. |
|
85 os_memcpy( |
|
86 const_cast<TUint8*>(aStartOfEtherPayload) |
|
87 - ( 2 * sizeof( TMacAddress ) ), |
|
88 reinterpret_cast<const TUint8*>( |
|
89 aDot11DataMpdu.iHdr.iAddress1.iMacAddress ), |
|
90 sizeof( TMacAddress ) ); |
|
91 |
|
92 // set the length |
|
93 aBuffer.KeSetLength( |
|
94 aEtherPayloadLength |
|
95 + ( sizeof( TMacAddress ) * 2 ) ); |
|
96 |
|
97 // set the frame type |
|
98 aBuffer.FrameType( TDataBuffer::KEthernetFrame ); |
|
99 |
|
100 // set the offset to the beginning of the ready ethernet frame |
|
101 // from the beginning of the Rx buf |
|
102 aBuffer.KeSetOffsetToFrameBeginning( |
|
103 aStartOfEtherPayload - ( 2 * sizeof( TMacAddress ) ) // frame beginning |
|
104 - aBuffer.KeGetBufferStart() ); // buffer beginning |
|
105 |
|
106 OsTracePrint( KRxFrame, (TUint8*) |
|
107 ("UMAC: WlanDot11IbssMode::DoBuildEthernetFrame: offset to frame beginning: %d"), |
|
108 aBuffer.KeOffsetToFrameBeginning()); |
|
109 } |