|
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 // udp.h - UDP for IPv6/IPv4 |
|
15 // UDP Protocol and Provider declarations. |
|
16 // |
|
17 |
|
18 |
|
19 |
|
20 /** |
|
21 @file udp.h |
|
22 @internalComponent |
|
23 */ |
|
24 |
|
25 #ifndef __UDP_H__ |
|
26 #define __UDP_H__ |
|
27 |
|
28 #include "in_trans.h" |
|
29 #include <udp_hdr.h> |
|
30 #include <in_chk.h> |
|
31 |
|
32 |
|
33 const TUint KUdpDefaultRecvBuf = 32768; //< Default receive window size. |
|
34 |
|
35 |
|
36 typedef TInet6Checksum<TInet6HeaderUDP> TInet6PacketUDP; |
|
37 |
|
38 |
|
39 /** |
|
40 UDP protocol implementation. |
|
41 |
|
42 @internalComponent |
|
43 */ |
|
44 class CProtocolUDP6 : public CProtocolInet6Transport |
|
45 { |
|
46 public: |
|
47 CProtocolUDP6(); |
|
48 CProtocolUDP6& operator=(const CProtocolUDP6&); |
|
49 virtual ~CProtocolUDP6(); |
|
50 virtual CServProviderBase *NewSAPL(TUint aProtocol); |
|
51 virtual void InitL(TDesC& aTag); |
|
52 virtual void StartL(); |
|
53 virtual void Identify(TServerProtocolDesc *) const; |
|
54 //virtual TInt GetOption(TUint level,TUint name,TDes8 &option,CProtocolBase* aSourceProtocol=NULL); |
|
55 //virtual TInt SetOption(TUint level, TUint aName,const TDesC8 &option,CProtocolBase* aSourceProtocol=NULL); |
|
56 virtual TInt Send(RMBufChain& aPDU,CProtocolBase* aSourceProtocol=NULL); |
|
57 virtual void Process(RMBufChain& aPacket, CProtocolBase *aSourceProtocol = NULL); |
|
58 static void Describe(TServerProtocolDesc&); |
|
59 |
|
60 TUint RecvBuf() const { return iRecvBuf; } |
|
61 TUint WaitNif() const { return iWaitNif; } |
|
62 |
|
63 private: |
|
64 // Global receive buffer setting read from udp_recv_buf. Can be overridden with socket option. |
|
65 TUint iRecvBuf; |
|
66 |
|
67 // Set if the sender should be blocked to wait for interface startup. |
|
68 TUint iWaitNif:1; |
|
69 }; |
|
70 |
|
71 |
|
72 /** |
|
73 UDP SAP declaration. |
|
74 |
|
75 @internalComponent |
|
76 */ |
|
77 class CProviderUDP6 : public CProviderInet6Transport |
|
78 { |
|
79 friend class CProtocolUDP6; |
|
80 |
|
81 public: |
|
82 CProviderUDP6(CProtocolInet6Base* aProtocol); |
|
83 virtual ~CProviderUDP6(); |
|
84 virtual void InitL(); |
|
85 virtual TInt GetOption(TUint level,TUint name,TDes8 &anOption) const; |
|
86 virtual void Ioctl(TUint level,TUint name,TDes8* anOption); |
|
87 virtual void CancelIoctl(TUint aLevel, TUint aName); |
|
88 virtual TInt SetOption(TUint level,TUint name, const TDesC8 &anOption); |
|
89 //virtual void AutoBind() {} |
|
90 virtual TInt SetRemName(TSockAddr &aAddr); |
|
91 virtual void Shutdown(TCloseType option); |
|
92 virtual void Process(RMBufChain& aPacket, CProtocolBase *aSourceProtocol = NULL); |
|
93 virtual void Error(TInt aError, TUint aOperationMask = MSocketNotify::EErrorAllOperations); |
|
94 virtual void CanSend(); |
|
95 |
|
96 // PRTv1.0 send and receive methods |
|
97 virtual void GetData(TDes8 &aDesc,TUint options,TSockAddr *aAddr=NULL); |
|
98 |
|
99 // PRTv1.5 send and receive methods |
|
100 virtual TInt GetData(RMBufChain& aData, TUint aLength, TUint aOptions, TSockAddr* anAddr=NULL); |
|
101 |
|
102 private: |
|
103 virtual TInt DoWrite(RMBufSendPacket &aPacket, RMBufSendInfo &aInfo, TUint aOptions, TUint aOffset); |
|
104 virtual TInt Recv(TDualBufPtr& aBuf, TUint aLength, TUint aOptions, TSockAddr* anAddr=NULL); |
|
105 |
|
106 CProtocolUDP6* Protocol() const { return (CProtocolUDP6*)iProtocol; } |
|
107 |
|
108 RMBufAllocator iBufAllocator; |
|
109 RMBufPktQ iSockInQ; //< Queue for incoming packets. |
|
110 RMBufSendPacket iSockOutBuf; //< Stores the last outgoing packet. |
|
111 TUint iSockOutOffset; //< Offset to the UDP header in iSockOutBuf. |
|
112 TUint iSockInQLen; //< Current input queue length in bytes. |
|
113 TUint iSockInBufSize; //< Buffer size for storing inbound data. |
|
114 }; |
|
115 |
|
116 |
|
117 #endif |