|
1 // Copyright (c) 2004-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 #include <nifman.h> |
|
17 #include <comms-infras/nifprvar.h> |
|
18 #include "PKTDRV.H" |
|
19 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
20 #include <networking/pktdrv_internal.h> |
|
21 #endif |
|
22 |
|
23 EXPORT_C void CPktDrvFactory::Close() |
|
24 { |
|
25 Dec(); |
|
26 if (AccessCount()==0) |
|
27 { |
|
28 RLibrary lib; |
|
29 lib.SetHandle(iLib.Handle()); |
|
30 iLib.SetHandle(0); |
|
31 delete this; |
|
32 lib.Close(); |
|
33 } |
|
34 } |
|
35 |
|
36 void CPktDrvFactory::Install( RLibrary& aLib ) |
|
37 { |
|
38 iLib.SetHandle(aLib.Handle()); |
|
39 aLib.SetHandle(0); |
|
40 } |
|
41 |
|
42 |
|
43 /** |
|
44 Constructor. |
|
45 @param aFactory A reference to CPktDrvFactory class. |
|
46 */ |
|
47 EXPORT_C CPktDrvBase::CPktDrvBase(CPktDrvFactory& aFactory) |
|
48 { |
|
49 iFactory=&aFactory; |
|
50 iFactory->Open(); |
|
51 } |
|
52 |
|
53 /** |
|
54 Destructor. |
|
55 */ |
|
56 EXPORT_C CPktDrvBase::~CPktDrvBase() |
|
57 { |
|
58 if (iFactory) |
|
59 iFactory->Close(); |
|
60 delete iName; |
|
61 } |
|
62 |
|
63 /** |
|
64 Set the name for the factory function. |
|
65 */ |
|
66 EXPORT_C void CPktDrvBase::SetNameL(const TDesC& aName) |
|
67 { |
|
68 iName = aName.AllocL(); |
|
69 } |
|
70 |
|
71 /** |
|
72 TIeee802Addr |
|
73 */ |
|
74 EXPORT_C TIeee802Addr::TIeee802Addr() |
|
75 { |
|
76 Reset(); |
|
77 } |
|
78 |
|
79 /** |
|
80 Constructs a device address from a data buffer. |
|
81 The buffer is copied directly into the object. The function panics if aDes |
|
82 does not have a length of 6 bytes (48 bits). |
|
83 @param aDes Data buffer for device address |
|
84 */ |
|
85 EXPORT_C TIeee802Addr::TIeee802Addr(const TDesC8& aDes) |
|
86 { |
|
87 __ASSERT_ALWAYS(aDes.Length() == KIeee802AddrSize, Panic(EIeee802AddrBadDescriptor)); |
|
88 Mem::Copy(&iAddr[0], aDes.Ptr(), KIeee802AddrSize); |
|
89 } |
|
90 |
|
91 /** |
|
92 Constructs a device address from a TInt64. |
|
93 The function panics if the most significant 16 bits of aInt are non-zero, |
|
94 as device addresses are 48 bits in size. |
|
95 @param aInt Value for device address. |
|
96 */ |
|
97 EXPORT_C TIeee802Addr::TIeee802Addr(const TInt64& aInt) |
|
98 { |
|
99 __ASSERT_ALWAYS((I64HIGH(aInt) & 0xffff0000u) == 0, Panic(EIeee802AddrBadTInt64)); |
|
100 TInt64 int64 (aInt); |
|
101 for (TInt i = KIeee802AddrSize-1; i>=0; --i) |
|
102 { |
|
103 iAddr[i] = TUint8(I64LOW(int64)); |
|
104 int64 >>= 8; |
|
105 } |
|
106 } |
|
107 |
|
108 EXPORT_C void TIeee802Addr::Reset() |
|
109 { |
|
110 iAddr.Reset(); |
|
111 } |
|
112 |
|
113 /** |
|
114 TEthernetAddr |
|
115 */ |
|
116 EXPORT_C TEthernetAddr::TEthernetAddr() : |
|
117 TIeee802Addr() |
|
118 { |
|
119 } |
|
120 |
|
121 EXPORT_C TEthernetAddr::TEthernetAddr(const TInt64& aInt) : |
|
122 TIeee802Addr(aInt) |
|
123 { |
|
124 } |
|
125 |
|
126 EXPORT_C TEthernetAddr::TEthernetAddr(const TDesC8& aDes) : |
|
127 TIeee802Addr(aDes) |
|
128 { |
|
129 } |
|
130 |
|
131 /** |
|
132 Global panic fn |
|
133 */ |
|
134 GLDEF_C void Panic(TIeee802AddrPanics aCode) |
|
135 { |
|
136 _LIT(KPanicName, "IEEE802Addr"); |
|
137 User::Panic(KPanicName, aCode); |
|
138 } |