|
1 // Copyright (c) 2005-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 // CNifIfBase and CProtocolBase shim layer functionality |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file nif.cpp |
|
20 */ |
|
21 |
|
22 #include <e32base.h> |
|
23 #include <comms-infras/ss_subconnflow.h> |
|
24 #include <comms-infras/ss_protflow.h> |
|
25 |
|
26 #include "in_sock.h" |
|
27 #include "in_iface.h" |
|
28 #include "in6_if.h" |
|
29 |
|
30 #include "nif6.h" |
|
31 #include "notify.h" |
|
32 #include "panic.h" |
|
33 #include "IPProtoDeMux.h" |
|
34 |
|
35 using namespace ESock; |
|
36 |
|
37 // |
|
38 // CIPShimIfBase methods // |
|
39 // |
|
40 |
|
41 CIPShimIfBase6* CIPShimIfBase6::NewL(const TDesC8& aProtocolName) |
|
42 { |
|
43 CIPShimIfBase6* p = new (ELeave) CIPShimIfBase6(aProtocolName); |
|
44 CleanupStack::PushL(p); |
|
45 p->ConstructL(); |
|
46 CleanupStack::Pop(p); |
|
47 return p; |
|
48 } |
|
49 |
|
50 CIPShimIfBase6::CIPShimIfBase6(const TDesC8& aProtocolName) |
|
51 : CIPShimIfBase(aProtocolName) |
|
52 { |
|
53 iConfig6.iFamily = KAFUnspec; |
|
54 } |
|
55 |
|
56 TInt CIPShimIfBase6::ServiceInfoControl(TDes8& aOption, TUint aName) |
|
57 /** |
|
58 Service KSoIfInfo/KSoIfInfo6 calls from upper protocol |
|
59 */ |
|
60 { |
|
61 TBinderInfo* ourInfo = NULL; |
|
62 // Validate the size of structure passed in |
|
63 switch (aName) |
|
64 { |
|
65 case KSoIfInfo: |
|
66 return KErrNotSupported; |
|
67 |
|
68 case KSoIfInfo6: |
|
69 ASSERT(aOption.Length() == sizeof(TSoIfInfo6)); |
|
70 if (iConfig6.iFamily != KAfInet6) |
|
71 { |
|
72 return KErrNotSupported; |
|
73 } |
|
74 ourInfo = &iConfig6.iInfo; |
|
75 break; |
|
76 default: |
|
77 Panic(EBadInfoControlOption); |
|
78 } |
|
79 |
|
80 TUint8* ptr = const_cast<TUint8*>(aOption.Ptr()); |
|
81 TSoIfInfo& info = reinterpret_cast<TSoIfInfo&>(*ptr); |
|
82 |
|
83 // Fill in iFeatures, iMtu, iSpeedMetric |
|
84 info.iFeatures = ourInfo->iFeatures; |
|
85 info.iSpeedMetric = ourInfo->iSpeedMetric; |
|
86 info.iMtu = ourInfo->iMtu; |
|
87 |
|
88 if (aName == KSoIfInfo6) |
|
89 { |
|
90 TSoIfInfo6& info = reinterpret_cast<TSoIfInfo6&>(*ptr); |
|
91 // For IP6, also fill in iRMtu |
|
92 info.iRMtu = ourInfo->iRMtu; |
|
93 } |
|
94 |
|
95 return KErrNone; |
|
96 } |
|
97 |
|
98 TInt CIPShimIfBase6::ServiceConfigControl(TDes8& aOption) |
|
99 /** |
|
100 Service KSoIfConfig calls from upper protocol |
|
101 */ |
|
102 { |
|
103 TUint8* ptr = const_cast<TUint8*>(aOption.Ptr()); |
|
104 |
|
105 TUint family = reinterpret_cast<TSoIfConfigBase&>(*ptr).iFamily; |
|
106 |
|
107 switch (family) |
|
108 { |
|
109 case KAfInet6: // IP6 |
|
110 { |
|
111 ASSERT(aOption.Length() == sizeof(TSoInet6IfConfig)); |
|
112 TSoInet6IfConfig& cf = reinterpret_cast<TSoInet6IfConfig&>(*ptr); |
|
113 |
|
114 if (iConfig6.iFamily != KAfInet6) |
|
115 { |
|
116 return KErrNotSupported; |
|
117 } |
|
118 else |
|
119 { |
|
120 cf.iLocalId = iConfig6.iLocalId; |
|
121 cf.iRemoteId = iConfig6.iRemoteId; |
|
122 cf.iNameSer1 = iConfig6.iNameSer1; |
|
123 cf.iNameSer2 = iConfig6.iNameSer2; |
|
124 } |
|
125 } |
|
126 break; |
|
127 |
|
128 default: |
|
129 Panic(EBadConfigControlFamily); |
|
130 break; |
|
131 } |
|
132 |
|
133 return KErrNone; |
|
134 } |
|
135 |
|
136 |
|
137 void CIPShimIfBase6::GetConfigFirstTime() |
|
138 /** |
|
139 Retrieve the IP4/IP6 configuration information from the lower binder, if |
|
140 we haven't already done so. |
|
141 */ |
|
142 { |
|
143 if (iConfig6.iFamily == KAFUnspec) |
|
144 { |
|
145 // retrieve the configuration information into the iConfig4/6 union (we are |
|
146 // just specifying the address of the first data type in the union, but |
|
147 // it equally specifies iConfig6). |
|
148 |
|
149 TBinderConfig& config = iConfig6; |
|
150 if(iProtoBinders[0]->iLowerControl->GetConfig(config) != KErrNone) |
|
151 Panic(EBinderConfigNotSupported); |
|
152 |
|
153 iConfig6.iFamily = config.iFamily; |
|
154 ASSERT(iConfig6.iFamily == KAfInet6); |
|
155 } |
|
156 } |
|
157 |