|
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 // ip6_sap.cpp - IPv6 service access point |
|
15 // |
|
16 |
|
17 #include "ip6.h" |
|
18 #include <ip6_hdr.h> |
|
19 #include "in_net.h" |
|
20 |
|
21 class CProviderIP6 : public CProviderInet6Network |
|
22 { |
|
23 public: |
|
24 CProviderIP6(CProtocolInet6Base* aProtocol); |
|
25 virtual TInt DoWrite(RMBufSendPacket &aPacket, RMBufSendInfo &aInfo, TUint aOptions, TUint aOffset); |
|
26 virtual TInt SecurityCheck(MProvdSecurityChecker *aChecker); |
|
27 }; |
|
28 |
|
29 // |
|
30 // IP6::NewSAPL |
|
31 // ************ |
|
32 CServProviderBase *IP6::NewSAPL(TUint aSockType, CProtocolInet6Base *aProtocol, TInt /*aId*/) |
|
33 { |
|
34 LOG(Log::Printf(_L("NewSAPL\t%S SockType=%d"), &aProtocol->ProtocolName(), aSockType)); |
|
35 if (aSockType != KSockDatagram) |
|
36 User::Leave(KErrNotSupported); |
|
37 CProviderIP6 *provider = new (ELeave) CProviderIP6(aProtocol); |
|
38 CleanupStack::PushL(provider); |
|
39 provider->InitL(); |
|
40 CleanupStack::Pop(); |
|
41 LOG(Log::Printf(_L("NewSAPL\t%S SAP[%u] OK"), &aProtocol->ProtocolName(), (TInt)provider)); |
|
42 return provider; |
|
43 } |
|
44 |
|
45 // |
|
46 |
|
47 CProviderIP6::CProviderIP6(CProtocolInet6Base* aProtocol) : CProviderInet6Network(aProtocol) |
|
48 { |
|
49 __DECLARE_NAME(_S("CProviderIP6")); |
|
50 } |
|
51 |
|
52 TInt CProviderIP6::DoWrite(RMBufSendPacket &aPacket, RMBufSendInfo &aInfo, TUint /*aOptions*/, TUint /*aOffset*/) |
|
53 { |
|
54 iFlow.SetNotify(this); |
|
55 if (aInfo.iSrcAddr.Family()) |
|
56 iFlow.SetLocalAddr(aInfo.iSrcAddr); |
|
57 if (aInfo.iDstAddr.Family()) |
|
58 iFlow.SetRemoteAddr(aInfo.iDstAddr); |
|
59 |
|
60 const TInt status = aPacket.Info()->iFlow.Open(iFlow, aPacket.Info()); |
|
61 if (status == KErrNone) |
|
62 { |
|
63 // Should compute the IPv6 checksum for the "upper" layer, |
|
64 // if requested by the application (advanced api option in |
|
65 // IPv6. Not for IPv4.) |
|
66 } |
|
67 return status; |
|
68 } |
|
69 |
|
70 TInt CProviderIP6::SecurityCheck(MProvdSecurityChecker *aChecker) |
|
71 { |
|
72 const TInt res = CProviderInet6Network::SecurityCheck(aChecker); |
|
73 if (res == KErrNone) |
|
74 return CheckPolicy(KPolicyNetworkControl, "TCPIP IP SAP"); |
|
75 return res; |
|
76 } |