1 // Copyright (c) 1997-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 the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
24 #if !defined(__ES_PROT_H__)
31 ESock subsession unique id
34 typedef TUint TSubSessionUniqueId;
48 enum TESOCKActivePriority
50 ESSExclusivePriority=100000,
51 ECommReceivePriority=200, ///< Must always run.
52 ECommTransmitPriority=100,
53 ECAsyncImmediatePriority=75, ///< I.e. before a timer event goes off.
54 ESocketTimerPriority=50,
55 EActiveIpcPriority=20,
56 EActiveHighPriority=10,
58 EActiveLowPriority=-10,
59 ECAsyncDeferredPriority=-20,
63 End of data,Socket can't receive more data.
67 const TUint KNewDataEndofData = 0xFFFFFFFF;
69 class CServProviderBase;
73 /** Abstract base class used by a CServProviderBase-derived object, through its
74 iSocket member, to notify the socket server that various events have occurred.
76 The class provides several up-call member functions.
78 All up-calls on an MSocketNotify should be made in the context of the socket
79 server's thread - i.e. the thread which called NewSAPL() on the protocol.
82 @released Since v5.0 */
85 /** Delete and detach flags. */
90 /** Don't delete SAP */
94 enum TOperationBitmasks
96 /** An error has occurred which affects Send() operations */
99 /** An error has occurred which affects Receive() operations. */
100 EErrorRecv=0x0000002,
102 /** An error has occurred which affects Connect() operations */
103 EErrorConnect=0x0000004,
105 /** An error has occurred which affects Close() operations */
106 EErrorClose=0x00000008,
108 /** An error has occurred which affects Ioctl() operations */
109 EErrorIoctl=0x00000010,
111 /** A fatal error has occurred */
112 EErrorFatal=0x10000000,
114 /** An error has occurred which affects all operations */
115 EErrorAllOperations=0x7fffffff,
119 Indicates that new data is available on a service access point
121 For a stream-oriented protocol aCount should be a byte count; for datagram-oriented
122 sockets aCount should be a datagram count.
124 @note aCount is the amount of new data, not the total amount of data waiting
127 @param aCount The amount of new data. A value of KNewDataEndofData indicates
128 that the socket is in a half-closed state and will receive no more data. Any subsequent
129 reads will complete with KErrEof and a length of 0. */
130 virtual void NewData(TUint aCount) = 0;
131 /** Indicates that new buffer space is available on a service. */
132 virtual void CanSend() = 0;
133 /** Indicates that a connection attempt has completed successfully (for active opens).
135 There are four versions of this up-call: two are for active opens and two are for passive
136 opens. Both active and passive versions support a variant carrying user connection
137 data for protocols which support it.
139 @note A connection-less protocol should never call the ConnectComplete() up-calls.
140 @note A protocol should keep a count of sockets which have called ConnectComplete()
141 but have not had Start() called. Sockets in this state have their Error()
142 and NewData() calls deferred until Start() is called.*/
143 virtual void ConnectComplete() = 0;
144 /** Indicates that a connection attempt has completed successfully (for active opens).
146 There are four versions of this up-call: two are for active opens and two are for passive
147 opens. Both active and passive versions support a variant carrying user connection
148 data for protocols which support it.
150 @note A connection-less protocol should never call the ConnectComplete() up-calls.
151 @note A protocol should keep a count of sockets which have called ConnectComplete()
152 but have not had Start() called. Sockets in this state have their Error()
153 and NewData() calls deferred until Start() is called.
155 @param aConnectData Connect data (if supported).
157 virtual void ConnectComplete(const TDesC8& aConnectData) = 0;
158 /** Indicates that a connection attempt has completed successfully (for passive opens).
160 There are four versions of this up-call: two are for active opens and two are for passive
161 opens. Both active and passive versions support a variant carrying user connection
162 data for protocols which support it.
164 The versions of ConnectComplete() for passive opens carry a new SSP (socket service
165 provider, or SAP) for the newly created socket. A new socket will then be linked up to
166 the SSP and data transfer can take place. The original socket stays listening.
168 @note A connection-less protocol should never call the ConnectComplete() up-calls.
169 @note A protocol should keep a count of sockets which have called ConnectComplete()
170 but have not had Start() called. Sockets in this state have their Error()
171 and NewData() calls deferred until Start() is called.
173 @param aSSP The new SSP for passive opens.
175 virtual void ConnectComplete(CServProviderBase& aSSP) = 0;
176 /** Indicates that a connection attempt has completed successfully (for passive opens).
178 There are four versions of this up-call: two are for active opens and two are for passive
179 opens. Both active and passive versions support a variant carrying user connection
180 data for protocols which support it.
182 The versions of ConnectComplete() for passive opens carry a new SSP (socket service
183 provider, or SAP) for the newly created socket. A new socket will then be linked up to
184 the SSP and data transfer can take place. The original socket stays listening.
186 @note A connection-less protocol should never call the ConnectComplete() up-calls.
187 @note A protocol should keep a count of sockets which have called ConnectComplete()
188 but have not had Start() called. Sockets in this state have their Error()
189 and NewData() calls deferred until Start() is called.
191 @param aSSP The new SSP for passive opens.
192 @param aConnectData Connect data (if supported). */
193 virtual void ConnectComplete(CServProviderBase& aSSP,const TDesC8& aConnectData) = 0;
194 /** Indicates that the SAP has finished closing down.
196 This up-call is the response to a Shutdown(). A connection-oriented protocol should call
197 CanClose() when it has terminated communications with the remote host. Protocols can call
198 CanClose() from within their Shutdown() code. After CanClose() has been called, an SAP may
199 be deleted by the socket server.
201 @note The protocol must not access the CServProviderBase object after calling CanClose().
202 @param aDelete Delete SAP.
204 virtual void CanClose(TDelete aDelete=EDelete) = 0;
205 /** Indicates that the SAP has finished closing down.
207 This up-call is the response to a Shutdown(). A connection-oriented protocol should call
208 CanClose() when it has terminated communications with the remote host. Protocols can call
209 CanClose() from within their Shutdown() code. After CanClose() has been called, an SAP may
210 be deleted by the socket server.
212 @note The protocol must not access the CServProviderBase object after calling CanClose().
213 @param aDisconnectData Any user data carried on the disconnect frame.
214 @param aDelete Delete SAP.
216 virtual void CanClose(const TDesC8& aDisconnectData,TDelete aDelete=EDelete) = 0;
217 /** Tells the socket server that an error state has arisen within the protocol.
219 It should not be used to report programmatic errors, either in the protocol
220 itself or the socket server (a panic should be used in these cases). When
221 Error() is called on a connection-oriented socket, the socket is moved into
222 a dead state which denies user access to it.
224 @param anError KErrNone or another of the system-wide error codes.
225 @param anOperationMask A bitmask of TOperationBitmasks values specifying which
226 pending operations are affected by the Error up-call. */
227 virtual void Error(TInt anError,TUint anOperationMask=EErrorAllOperations) = 0;
228 /** Indicates that the other end of a connection has disconnected.
230 This is analogous to CanClose(), but in this case the other end initiated it.
232 Once the client has called Shutdown() it is illegal to call Disconnect(). Instead,
233 CanClose() or Error(KErrDisconnected) should be called.
235 virtual void Disconnect(void) = 0;
236 /** Indicates that the other end of a connection has disconnected.
238 This is analogous to CanClose(), but in this case the other end initiated it.
240 Once the client has called Shutdown() it is illegal to call Disconnect(). Instead,
241 CanClose() or Error(KErrDisconnected) should be called.
243 @param aConnectData User data in the disconnect frame.
245 virtual void Disconnect(TDesC8& aDisconnectData) = 0;
246 /** Indicates that the currently pending Ioctl has completed.
248 The parameter aBuf is protocol defined - in fact it is defined by the specific
251 @param aBuf Any data requested by the Ioctl operation. */
252 virtual void IoctlComplete(TDesC8* aBuf) = 0;
255 Indicates that there are no bearer available
257 @param aConnectionParams, the connection parameters.
259 virtual void NoBearer(const TDesC8& aConnectionParams) = 0;
262 Indicates the bearer available.
264 @param aConnectionInfo, Information about socket connection.
266 virtual void Bearer(const TDesC8& aConnectionInfo) = 0;
269 Indicates that this socket is now completed an asynchronous join
270 with a sub-connection. It now can use the properties of the sub-connection
272 virtual void JoinedSubConnection() {;};
275 Indicates that this socket was not able to complete an asynchronous join
276 with a sub-connection. The socket is still joined, but cannot use the
277 properties of the sub-connection
279 @param aError Reason the socket could not be joined
281 virtual void SubConnectionJoinFailed(TInt /*aError*/) {;};
284 Indicates that this socket has now completed an asynchronous leave
285 from a sub-connection. The socket is now connected to the sub-connection
288 virtual void LeftSubConnection() {;};
296 class MConnectionNotify
298 * Callback interface from CConnectionProvdBase-derived classes
299 * @internalTechnology
303 virtual void SelectionComplete(TInt aError, const TDesC8& aSelectionInfo) = 0;
304 virtual void ConnectionError(TInt aError) = 0;
305 virtual void LinkLayerOpen(TInt aError) = 0;
306 virtual void LinkLayerClosed(TInt aError) = 0;
307 virtual void ProgressNotification(TInt aStage, TInt aError) = 0;
308 virtual void ProgressNotification(TSubConnectionUniqueId aSubConnectionUniqueId, TInt aStage, TInt aError) = 0;
309 virtual void ServiceChangeNotification(TUint32 aId, const TDesC& aType) = 0;
310 virtual void InterfaceStateChangeNotification(TDesC8& aInfo) = 0;
311 virtual void NotifyDataSent(TSubConnectionUniqueId aSubConnectionUniqueId, TUint aUplinkVolume) = 0;
312 virtual void NotifyDataReceived(TSubConnectionUniqueId aSubConnectionUniqueId, TUint aDownlinkVolume) = 0;
314 virtual void SubConnectionEvent(const TSubConnectionEvent& aSubConnectionEvent) = 0;
320 enum TProtocolServiceInfo
322 ESocketSupport=0x00000001, ///< Can make sockets
323 ETransport=0x00000002, ///< Can act as a transport - ie can be bound to
324 EPreferMBufChains=0x00000004, ///< Will process MBufChains (I.e. won't convert them to descriptors)
325 EPreferDescriptors=0x00000008, ///< Will process Descriptors (I.e. won't convert them to MBufChains)
326 ECantProcessMBufChains=0x00000010, ///< Will Panic if asked to process an MBufChain
327 ENeedMBufs=0x00000020, ///< Uses MBufChains internally.
328 EUseCanSend=0x00000040, ///< Uses the inter-protocol CanSend upcall.
329 EInterface=0x00000080, ///< Is a CInterfaceBase rather than CProtocolBase
337 ENormalProtocol, ///< Normal protocol
338 EInterfaceProtocol ///< Has EInterface flags set and supports GetBinderL()
344 const TInt KUnlimitedSockets=-1;
346 struct TServerProtocolDesc : public TProtocolDesc
348 Contains data that describes a particular protocol.
352 @see CProtocolFamilyBase::ProtocolList().
355 TInt iServiceTypeInfo; ///< Set this to 1 if the protocol supports socket creation
356 TInt iNumSockets; ///< The maximum number of SSPs the protocol supports
360 class MResolverNotify
367 virtual void QueryComplete(TInt anError)=0;
370 /** Ensure that the requested length for datagrams is bigger than any real one. This ensures that
371 naive providers deliver them without truncation, so allowing the client to perform continuation reads.
374 const TUint KGetDataWholeDatagram = 0x40000000;
377 Security checker class passed down to providers which is used to perform security checks on the client
378 of the provider. The provider calls the CheckPolicy(...) method with a suitable TSecurityPolicy
379 class and a diagnostic string as arguments.
381 @see CServProviderBase
382 @see CResolverProvdBase
385 _LIT_SECURITY_POLICY_C1(myPolicy1, ECapabilityNetworkServices);
387 TInt CMyProvider::SecurityCheck(MProvdSecurityChecker *aChecker)
390 if (aChecker->CheckPolicy(myPolicy1, "CMyProvider main") == KErrNone)
392 // client has NetworkServices capability
401 class MProvdSecurityChecker
405 Check the security policy of a client process.
407 Called from a socket or resolver provider to check whether the client process conforms to a security policy.
409 @param aPolicy A TSecurityPolicy class instance containing the security information to be checked against the client.
410 @param aDiagnostic A diagnostic string used when logging system-wide security failures, else 0.
411 @return KErrNone if client process has the required security information, else KErrPermissionDenied.
412 (In the future, some other system error may be returned).
414 virtual TInt CheckPolicy(const TSecurityPolicy& aPolicy, const char *aDiagnostic) = 0;
418 class CSubConnectionProviderBase;
419 class CServProviderBase : public CBase
420 /** Service Access Point.
422 Provides transport services to a single protocol. Several of the calls to
423 CServProviderBase have pre-conditions attached to them - for example
424 a connection oriented protocol must have its local address set (either by
425 a SetLocalName() or AutoBind()) before it is opened. If the socket server
426 calls the CServProviderBase in such an erroneous way, the protocol should panic.
429 @released Since 5.0 */
431 friend class ProtocolManager;
434 /** Describes the behaviour the SAP should take on shutdown.*/
437 ENormal, ///< The protocol should shutdown gracefully — no further input or output will be requested.
438 EStopInput, ///< The protocol should shut down gracefully — all further and pending input should be discarded.
439 EStopOutput, ///< The protocol should shutdown gracefully — all pending output should be discarded.
440 EImmediate ///< The protocol should close the connection immediately and free all resources without performing a graceful disconnect.
442 IMPORT_C CServProviderBase();
443 IMPORT_C virtual ~CServProviderBase();
445 IMPORT_C virtual void SetNotify(MSocketNotify* aSocket);
447 IMPORT_C virtual void SetSockType(TUint aSockType);
448 IMPORT_C TUint SockType() const;
450 IMPORT_C virtual void JoinSubConnectionL(CSubConnectionProviderBase& aSubConnProvider);
451 IMPORT_C virtual void LeaveSubConnection(CSubConnectionProviderBase& aSubConnProvider);
459 Start a service provider.
461 virtual void Start()=0;
462 /** Gets the local name (address) of the socket service provider entity. The format
463 of the data in the TSockAddr object is defined by individual protocols.
465 The local address is the address of the local machine plus a local port number.
466 Generally only the port number is important, unless you have two IP interfaces,
469 @param anAddr The address to be filled in */
470 virtual void LocalName(TSockAddr& anAddr) const =0;
471 /** Sets the local name (address) of the socket service provider entity. The format
472 of the data in the TSockAddr object is defined by individual protocols.
474 @param anAddr The address
475 @return Returns KErrNone if the local name is correctly set or, if this is
476 not the case, an informative error number. */
477 virtual TInt SetLocalName(TSockAddr& anAddr)=0;
478 /** Gets the remote name (address) of the socket service provider entity. The format
479 of the data in the TSockAddr object is defined by individual protocols.
481 A remote address is either the address you're sending data to (non connection-oriented
482 sockets)* or the remote end of the connection. It is the address of the remote
483 machine (your peer in the network) plus a port number.
485 @note RemName is only meaningful if the socket server client has called Connect()
486 to set up a default address for SendTo(). This function will only be called
487 on the protocol if this is the case.
489 @param anAddr The address to be filled in */
490 virtual void RemName(TSockAddr& anAddr) const =0;
491 /** Sets the remote name (address) of the socket service provider entity. The format
492 of the data in the TSockAddr object is defined by individual protocols.
494 @param anAddr The address
495 @return Returns KErrNone if the remote name is correctly set or, if this is
496 not the case, an informative error number. */
497 virtual TInt SetRemName(TSockAddr& anAddr)=0;
498 /** Gets some protocol specific option when called by the socket server on behalf of a
499 client. A protocol may pass the request down a protocol stack (to protocols it is bound
500 to) using the GetOption() function of CProtocolBase.
502 @param aLevel Option level.
503 @param aName Option name.
504 @param anOption Option data.
505 @return System wide error code.
507 virtual TInt GetOption(TUint level,TUint name,TDes8& anOption)const =0;
508 /** Performs some protocol specific IO control.
510 @note If this function is called erroneously, the protocol should call Error() on the
511 socket. If an Ioctl call is already outstanding, the client will be panicked with the
514 @param aLevel Option level.
515 @param aName Option name.
516 @param anOption Option data.
517 @return System wide error code.
519 virtual void Ioctl(TUint level,TUint name,TDes8* anOption)=0;
520 /** Cancels an outstanding Ioctl call. You are guaranteed only to have one outstanding
523 @param aLevel IOCTL level.
524 @param aName IOCTL name.
526 virtual void CancelIoctl(TUint aLevel,TUint aName)=0;
527 /** Sets some protocol specific option when called by the socket server on behalf of a
528 client. A protocol may pass the request down a protocol stack (to protocols it is bound
529 to) using the SetOption() function of CProtocolBase.
531 @param aLevel Option level.
532 @param aName Option name.
533 @param anOption Option data.
534 @return System wide error code.
536 virtual TInt SetOption(TUint level,TUint name,const TDesC8& anOption)=0;
537 virtual void ActiveOpen()=0;
538 /** Initiates a connection operation - this means that it tells the protocol to
539 attempt to connect to a peer. It is called by the socket server in response
540 to a connect request from a client.
542 This version of the function has user data in the connection frame.
544 Only ever called on connection-oriented sockets. Such a socket
545 should always have both the local address and the remote address specified
546 before this function is called. If this is not the case then the protocol
549 When a connection has completed, the protocol should call ConnectComplete()
550 on its TNotify. If an error occurs during connection the protocol should not
551 call ConnectComplete() at all; instead it should call Error().
553 @param aConnectionData If the protocol supports user specified connection
554 data, then it will be held in this buffer. */
555 virtual void ActiveOpen(const TDesC8& aConnectionData)=0;
556 /** Tells the protocol to start waiting for an incoming connection request on this
557 socket (i.e. port). It is called by the socket server in response to a listen
558 request from a client.
560 Only ever called on connection-oriented sockets. Such a socket
561 should always have both the local address and the remote address specified
562 before this function is called. If this is not the case, then the protocol
565 The aQue parameter is the number of sockets which can be waiting for an outstanding
566 Start after calling ConnectComplete(). The protocol should keep a count of
567 sockets in this state - incrementing a variable in ConnectComplete(), and
568 decrementing it in Start().
570 When a connection has completed, the protocol should call ConnectComplete()
571 on its TNotify. If an error occurs during connection the protocol should not
572 call ConnectComplete() at all; instead it should call Error().
574 @param aQueSize Size of connect queue.
576 virtual TInt PassiveOpen(TUint aQueSize)=0;
577 /** Tells the protocol to start waiting for an incoming connection request on this
578 socket (i.e. port). It is called by the socket server in response to a listen
579 request from a client.
581 This version of the function has user data in the connection frame.
583 Only ever called on connection-oriented sockets. Such a socket
584 should always have both the local address and the remote address specified
585 before this function is called. If this is not the case then the protocol
588 The aQue parameter is the number of sockets which can be waiting for an outstanding
589 Start after calling ConnectComplete(). The protocol should keep a count of
590 sockets in this state - incrementing a variable in ConnectComplete(), and
591 decrementing it in Start().
593 When a connection has completed the protocol should call ConnectComplete()
594 on its TNotify. If an error occurs during connection the protocol should not
595 call ConnectComplete() at all; instead it should call Error().
597 @param aQueSize size of connect queue
598 @param aConnectionData if the protocol supports user specified connection data
599 then it will be held in this buffer. */
600 virtual TInt PassiveOpen(TUint aQueSize,const TDesC8& aConnectionData)=0;
601 /** Terminates a connection (or closes a non connection-oriented socket down).
603 The value of the option argument specifies the type of processing which will
604 be required of the protocol after this function is called.
606 Normally, when the socket server has called Shutdown() for a socket, it will
607 wait for the socket to call CanClose() before destroying the CServProviderBase
608 object. However, if the option argument is EImmediate, the CServProviderBase
609 will be destroyed as soon as Shutdown() returns.
611 @param option The shutdown type. */
612 virtual void Shutdown(TCloseType option)=0;
613 /** Terminates a connection (or closes a non connection-oriented socket down).
615 The value of the option argument specifies the type of processing which will
616 be required of the protocol after this function is called.
618 Normally, when the socket server has called Shutdown() for a socket, it will
619 wait for the socket to call CanClose() before destroying the CServProviderBase
620 object. However, if the option argument is EImmediate, the CServProviderBase
621 will be destroyed as soon as Shutdown() returns.
623 @param option The shutdown type.
624 @param aDisconnectionData If the protocol supports disconnect data, any such
625 data required will be held in this buffer. */
626 virtual void Shutdown(TCloseType option,const TDesC8& aDisconnectionData)=0;
627 /** Specifies that the protocol should choose a local address for the service access
629 virtual void AutoBind()=0;
631 // protocol read/write data; ESock v1.5 calls down to the v1.5 itf (RMBufChain).
632 // v1.5-ready protocols implement this, laggard protocols inherit these base class
633 // implementations which call the v1.0 descriptor itf instead.
635 /** Sends data onto the network via the protocol.
637 Connection-oriented sockets must be in a connected state (that is ConnectComplete() has
638 been called on their MSocketNotify before Write() is called).
640 The socket server keeps track of how much data is waiting and then tries to send it all
641 until the protocol tells it to hold off by returning 0 (datagram sockets) or 'less than
642 all data consumed' (stream sockets) to Write(). The protocol should call CanSend() when it
643 is ready to send more data.
645 anAddr is the address to write the data to. Connection oriented sockets always use the
648 @param aDesc The data to be sent.
649 @param aOptions Protocol specific options.
650 @param anAddr Address to write the data to.
652 @returns For stream-oriented protocols the return value is the number of bytes actually written.
653 If this is less than the length of the descriptor then the protocol should call CanSend()
654 when it is ready to send more data. For datagram-oriented protocols, the write should return
655 either 0 if the write cannot be completed, or the length of the descriptor if the write succeeds -
656 no other values are valid. If the Write() must return 0, then it should call CanSend() when it is
657 ready to send more data. If the Write() fails due to some error, then it should call Error() with
658 an informative error number.
660 IMPORT_C virtual TUint Write(const TDesC8& aDesc,TUint options, TSockAddr* anAddr=NULL);
661 /** Sends data onto the network via the protocol.
663 Connection-oriented sockets must be in a connected state (that is ConnectComplete() has
664 been called on their MSocketNotify before Write() is called).
666 The socket server keeps track of how much data is waiting and then tries to send it all
667 until the protocol tells it to hold off by returning 0 (datagram sockets) or 'less than
668 all data consumed' (stream sockets) to Write(). The protocol should call CanSend() when it
669 is ready to send more data.
671 anAddr is the address to write the data to. Connection oriented sockets always use the
674 @param aData The data to be sent.
675 @param aOptions Protocol specific options.
676 @param anAddr Address to write the data to.
678 @returns For stream-oriented protocols the return value is the number of bytes actually written.
679 If this is less than the length of the descriptor then the protocol should call CanSend()
680 when it is ready to send more data. For datagram-oriented protocols, the write should return
681 either 0 if the write cannot be completed, or the length of the descriptor if the write succeeds -
682 no other values are valid. If the Write() must return 0, then it should call CanSend() when it is
683 ready to send more data. If the Write() fails due to some error, then it should call Error() with
684 an informative error number.
686 IMPORT_C virtual TInt Write(RMBufChain& aData, TUint aOptions, TSockAddr* anAddr=NULL);
688 /** Gets data which the protocol has indicated is waiting in its buffers using the NewData
689 up-call on the MSocketNotify.
691 GetData() will only ever be called for as much data as the protocol has specified it can process
692 using the NewData up-call.
694 For stream oriented protocols GetData() should fill the descriptor with data from the stream. On
695 a datagram protocol GetData() should copy one datagram into the descriptor and set the length of
696 the descriptor. If a full datagram will not fit into the supplied descriptor, the overflow should
699 anAddr should be filled in by the protocol with the address of where the data came from.
701 @param aDesc The buffer for data.
702 @param aOptions Protocol specific options.
703 @param anAddr Address where the data came from.
705 IMPORT_C virtual void GetData(TDes8& aDesc,TUint options,TSockAddr* anAddr=NULL);
706 /** Gets data which the protocol has indicated is waiting in its buffers using the NewData
707 up-call on the MSocketNotify.
709 GetData() will only ever be called for as much data as the protocol has specified it can process
710 using the NewData up-call.
712 For stream oriented protocols GetData() should fill the descriptor with data from the stream. On
713 a datagram protocol GetData() should copy one datagram into the descriptor and set the length of
714 the descriptor. If a full datagram will not fit into the supplied descriptor, the overflow should
717 anAddr should be filled in by the protocol with the address of where the data came from.
719 @param aDesc The buffer for data.
720 @param aOptions Protocol specific options.
721 @param anAddr Address where the data came from.
723 IMPORT_C virtual TInt GetData(RMBufChain& aData, TUint aLength, TUint aOptions, TSockAddr* anAddr=NULL);
725 /** Use the class instance argument to perform security policy checks on the originating client process.
727 This method is called when a SAP is created and when a socket is transferred between sessions. The SAP is
728 required to check whether the originating client process has enough privileges to request services from the SAP.
729 The MProvdSecurityChecker class instance is used to perform security policy checks. The SAP may choose
730 to perform a security policy check in its SecurityCheck(...) method, or it may choose to store the
731 MProvdSecurityChecker class instance argument and perform checking later (i.e. when subsequent
732 SAP methods are called).
734 @param aSecurityChecker Pointer to class used by SAP to perform security checks on the client process. This
735 pointer becomes invalid when the SAP is destroyed or detached.
736 @returns KErrPermissionDenied if SAP wishes to disallow access to the client, else KErrNone. This would
737 normally be as a result of calling MProvdSecurityChecker::CheckPolicy(...) with a suitable security policy argument.
739 IMPORT_C virtual TInt SecurityCheck(MProvdSecurityChecker *aSecurityChecker);
742 /** On socket creation, the socket server sets this member to point to a server
743 notification interface. */
744 MSocketNotify* iSocket;
746 //V1.0 interface support specifics
747 HBufC8* iV1ShimDataIn;
748 HBufC8* iV1ShimDataOut;
753 class CResolverProvdBase : public CBase
759 friend class ProtocolManager;
761 inline void SetNotify(MResolverNotify* aNotifier);
766 virtual void CancelCurrentOperation()=0;
768 /** Use the class instance argument to perform security policy checks on the originating client process.
770 This method is called when a resolver is created. The resolver is required to check whether the originating
771 client process has enough privileges to request services from the resolver. The MProvdSecurityChecker
772 class instance is used to perform security policy checks. The resolver may choose to perform a security
773 policy check in its SecurityCheck(...) method, or it may choose to store the MProvdSecurityChecker class
774 instance argument and use it to perform checking later (i.e. when subsequent resolver methods are called).
776 @param aSecurityChecker Pointer to class used by resolver to perform security checks on the client process. This
777 pointer becomes invalid when the resolver is destroyed or detached.
778 @returns KErrPermissionDenied if resolver wishes to disallow access to the client, else KErrNone. This would
779 normally be as a result of calling MProvdSecurityChecker::CheckPolicy(...) with a suitable security policy argument.
781 IMPORT_C virtual TInt SecurityCheck(MProvdSecurityChecker *aSecurityChecker);
784 MResolverNotify* iNotify;
786 CProtocolBase* iProtocol;
789 class CHostResolvProvdBase : public CResolverProvdBase
791 Provides Host name resolver service
796 friend class ProtocolManager;
800 Get the Host name by name
801 @param aName, results of name queries
803 virtual void GetByName(TNameRecord& aName)=0;
806 Gets the Host name by address
807 @param aName, results of name queries
809 virtual void GetByAddress(TNameRecord& aName)=0;
813 @param aNameBuf, name to set
815 virtual void SetHostName(TDes& aNameBuf)=0;
819 @param aNameBuf, name to retrieve
821 virtual void GetHostName(TDes& aNameBuf)=0;
822 IMPORT_C virtual TInt SetOption(TUint level,TUint name,const TDesC8& anOption);
823 IMPORT_C virtual void Query(const TDesC8& aQryBuf, TDes8& aResBuf, TInt aCounter);
826 class CServiceResolvProvdBase : public CResolverProvdBase
832 friend class ProtocolManager;
836 Get the Host name by name
837 @param aName, results of name queries
839 virtual void GetByName(const TDesC& aNameBuf,TInt32& aPortNum)=0;
842 Gets the Host name by address
843 @param aName, results of name queries
845 virtual void GetByNumber(TDes& aNameBuf,TInt32 aPortNum)=0;
849 @param aNameBuf, name to set
851 virtual void RegisterService(const TDesC& aNameBuf,TInt32 aPortNum)=0;
855 @param aNameBuf, name to retrieve
857 virtual void RemoveService(const TDesC& aNameBuf,TInt32 aPortNum)=0;
860 class CNetDBProvdBase : public CResolverProvdBase
862 Provides network Database access
867 friend class ProtocolManager;
869 virtual void Query(TDes8& aBuffer)=0;
870 virtual void Add(TDes8& aBuffer)=0;
871 virtual void Remove(TDes8& aBuffer)=0;
875 Definition of argument to CConnectionProvdBase::SetUsageProfile()
880 const TUint KConnProfileNone = 0;
883 Definition of argument to CConnectionProvdBase::SetUsageProfile()
888 const TUint KConnProfileLong = 1;
891 Definition of argument to CConnectionProvdBase::SetUsageProfile()
896 const TUint KConnProfileMedium = 2;
899 class CSubConnectionProviderBase;
902 class CConnectionProvdBase : public CBase
904 * Base class for connection providers (currently nifman)
905 * @internalTechnology
908 friend class ProtocolManager;
909 friend class CConnection;
910 friend class CConnectionSettingsShim; //to access the virtual "Do" db functions directly
912 IMPORT_C virtual ~CConnectionProvdBase();
914 IMPORT_C TUint Id() const;
915 IMPORT_C void SetConnectionProviderClient(MConnectionNotify* aClient);
916 MConnectionNotify* ConnectionProviderClient();
919 // SubConnectionProvider Management
920 void JoinL(CSubConnectionProviderBase& aSubConnProvider);
921 void Leave(CSubConnectionProviderBase& aSubConnProvider);
923 virtual void StartL(TConnStartType aConnectType, const RMessagePtr2* aMessage) = 0;
924 virtual void StartL(TConnStartType aConnectType, const TConnPref& aPref, const RMessagePtr2* aMessage) = 0;
925 virtual void AttachToConnectionL(const TDesC8& aConnectionInfo, TBool aMonitorAttach, const RMessagePtr2* aMessage) = 0;
926 virtual TInt Stop(TInt aError, const RMessagePtr2* aMessage) = 0;
927 virtual void ProgressL(TNifProgressBuf& aBuffer) const = 0;
928 virtual void ProgressL(TSubConnectionUniqueId aSubConnectionUniqueId, TNifProgressBuf& aBuffer) const = 0;
929 virtual void LastProgressError(TNifProgressBuf& aBuffer) = 0;
930 virtual void RequestServiceChangeNotificationL() = 0;
931 virtual void CancelServiceChangeNotification() = 0;
932 virtual void EnumerateConnectionsL(RPointerArray<TConnectionInfo>& aConnectionInfoPtrArray) = 0;
933 virtual TBool AllInterfaceNotificationL() = 0;
934 virtual void ControlL(TUint aOptionLevel, TUint aOptionName, TDes8& aOption, const RMessagePtr2* aMessage) = 0;
935 virtual void SetUsageProfile(TUint aProfile) = 0;
938 Stop the specified subconnection
940 @param aSubConnectionUniqueId The id of the subconnection to be stopped
941 @param aError The error code to be propogated to the clients of the subconnection
943 virtual TInt Stop(TSubConnectionUniqueId aSubConnectionUniqueId, TInt aError, const RMessagePtr2* aMessage)=0;
946 Find out the number of subconnetions on a connection
948 @param aCount On return, contains the number of subconnections
950 virtual TInt EnumerateSubConnections(TUint& aCount)=0;
953 Get information about a subconnection specified only by generic index
956 @param aSubConnectionInfo An appropriate SubConnectionInfo-derived class; on return, this is filled in
958 virtual TInt GetSubConnectionInfo(TUint aIndex, TDes8& aSubConnectionInfo)=0;
961 Get information about a subconnection specifed by its unique id
963 @param aSubConnectionInfo An appropriate SubConnectionInfo-derived class containing a valid TSubConnectionUniqueId; on return, this is filled in
965 virtual TInt GetSubConnectionInfo(TDes8& aSubConnectionInfo)=0;
968 Register for all subconnection notifications
970 virtual TInt AllSubConnectionNotificationEnable()=0;
973 Cancel registration for AllSubConnectionNotification
975 virtual TInt CancelAllSubConnectionNotification()=0;
978 Find out how much data has been sent and received
980 @param aSubConnectionUniqueId The id of the subconnection to which this request refers
981 @param aUplinkVolume The total number of bytes sent on this subconnection
982 @param aDownlinkVolume The total number of bytes received on this subconnection
984 virtual TInt DataTransferred(TSubConnectionUniqueId aSubConnectionUniqueId, TUint& aUplinkVolume, TUint& aDownlinkVolume)=0;
987 Cancel a request for the amount of data sent and received
989 @param aSubConnectionUniqueId The id of the subconnection that this request refers to
990 @note At present this method is never called, as this is a synchronous operation on the server side
992 virtual TInt DataTransferredCancel(TSubConnectionUniqueId aSubConnectionUniqueId)=0;
995 Make a request for notifications about data sent at the specifed granularity on a specified subconnection
997 @param aSubConnectionUniqueId The id of the subconnection to which this request refers
998 @param aUplinkGranularity The granularity in bytes at which notifications should be sent
1000 virtual TInt SetDataSentNotificationGranularity(TSubConnectionUniqueId aSubConnectionUniqueId, TUint aUplinkGranularity)=0;
1003 Cancel a request for notifications about data sent on a specified subconnection
1005 @param aSubConnectionUniqueId The id of the subconnection to which this request refers
1007 virtual TInt DataSentNotificationCancel(TSubConnectionUniqueId aSubConnectionUniqueId)=0;
1010 Make a request for notifications about data received at the specifed granularity on a specified subconnection
1012 @param aSubConnectionUniqueId The id of the subconnection to which this request refers
1013 @param aDownlinkGranularity The granularity in bytes at which notifications should be sent
1015 virtual TInt SetDataReceivedNotificationGranularity(TSubConnectionUniqueId aSubConnectionUniqueId, TUint aDownlinkGranularity)=0;
1018 Cancel a request for notifications about data received on a specified subconnection
1020 @param aSubConnectionUniqueId The id of the subconnection to which this request refers
1022 virtual TInt DataReceivedNotificationCancel(TSubConnectionUniqueId aSubConnectionUniqueId)=0;
1025 * SendIoctlMessageL forwards Ioctl request to the target
1026 * Important - message has to be completed by the target. There is no notification back
1027 * to the caller => meant for forwarding Ioctl messages the forwarding path is not really
1028 * interested in apart from "routing informations"
1029 * @param aMessage forwarded message (it's the caller's resposibility to forward just Ioctl
1032 virtual void SendIoctlMessageL(const RMessage2& aMessage) = 0;
1033 virtual void SendCancelIoctl() = 0;
1036 #ifdef SYMBIAN_NETWORKING_3GPPDEFAULTQOS
1037 virtual CNifIfBase* GetNif(TInt aIndex) = 0;
1039 //SYMBIAN_NETWORKING_3GPPDEFAULTQOS //PREQ399_REMOVE
1041 IMPORT_C void GetBoolSettingL(const TDesC& aSettingName, TBool& aValue );
1042 IMPORT_C void GetBoolSettingL(const TDesC& aSettingName, TBool& aValue, const RMessagePtr2* aMessage );
1043 IMPORT_C void GetDes16SettingL(const TDesC& aSettingName, TDes16& aValue );
1044 IMPORT_C void GetDes16SettingL(const TDesC& aSettingName, TDes16& aValue, const RMessagePtr2* aMessage );
1045 IMPORT_C void GetDes8SettingL(const TDesC& aSettingName, TDes8& aValue );
1046 IMPORT_C void GetDes8SettingL(const TDesC& aSettingName, TDes8& aValue, const RMessagePtr2* aMessage );
1047 IMPORT_C void GetIntSettingL(const TDesC& aSettingName, TUint32& aValue );
1048 IMPORT_C void GetIntSettingL(const TDesC& aSettingName, TUint32& aValue, const RMessagePtr2* aMessage );
1049 IMPORT_C HBufC* GetLongDesSettingLC(const TDesC& aSettingName, const RMessagePtr2* aMessage );
1050 IMPORT_C HBufC* GetLongDesSettingLC(const TDesC& aSettingName );
1053 IMPORT_C CConnectionProvdBase(TUint aId);
1054 IMPORT_C void CreateL(MConnectionNotify* aConnection);
1056 virtual void DoGetIntSettingL(const TDesC& aSettingName, TUint32& aValue, const RMessagePtr2* aMessage ) = 0;
1057 virtual void DoGetBoolSettingL(const TDesC& aSettingName, TBool& aValue, const RMessagePtr2* aMessage ) = 0;
1058 virtual void DoGetDes8SettingL(const TDesC& aSettingName, TDes8& aValue, const RMessagePtr2* aMessage ) = 0;
1059 virtual void DoGetDes16SettingL(const TDesC& aSettingName, TDes16& aValue, const RMessagePtr2* aMessage ) = 0;
1060 virtual HBufC* DoGetLongDesSettingLC(const TDesC& aSettingName, const RMessagePtr2* aMessage ) = 0;
1063 MConnectionNotify* iConnection;
1064 RPointerArray<CSubConnectionProviderBase> iSubConnProviders;
1068 class CProtocolFamilyBase;
1071 class CProtocolBase : public CBase
1072 /** Protocols created by protocol families must be instances of sub-classes of
1073 the abstract CProtocolBase.
1075 @released Since v5.0 */
1077 friend class ProtocolManager;
1078 friend class CProtocolRef;
1081 IMPORT_C virtual CServProviderBase* NewSAPL(TUint aProtocol);
1082 IMPORT_C virtual CHostResolvProvdBase* NewHostResolverL();
1083 IMPORT_C virtual CServiceResolvProvdBase* NewServiceResolverL();
1084 IMPORT_C virtual CNetDBProvdBase* NewNetDatabaseL();
1085 IMPORT_C CProtocolBase();
1086 IMPORT_C virtual ~CProtocolBase();
1087 CProtocolFamilyBase* ProtocolFamily();
1088 IMPORT_C virtual void Close();
1089 IMPORT_C virtual void Open();
1090 IMPORT_C virtual void CloseNow();
1091 IMPORT_C virtual void StartSending(CProtocolBase* aProtocol); // Up
1092 IMPORT_C TPtrC Tag();
1093 IMPORT_C virtual void InitL(TDesC& aTag); // From ProtocolManager before all binding.
1094 IMPORT_C virtual void StartL(); // From Protocol Manager - after all binding
1095 IMPORT_C virtual void BindL(CProtocolBase* protocol, TUint id); // From higher protocol
1096 IMPORT_C virtual void BindToL(CProtocolBase* protocol); // From Protocol Manager
1097 IMPORT_C virtual TInt Send(RMBufChain& aPDU,CProtocolBase* aSourceProtocol=NULL); // Down
1098 IMPORT_C virtual TInt Send(TDes8& aPDU,TSockAddr* to,TSockAddr* from=NULL,CProtocolBase* aSourceProtocol=NULL); // Done
1099 IMPORT_C virtual void Process(RMBufChain&,CProtocolBase* aSourceProtocol=NULL); // Up
1100 IMPORT_C virtual void Process(TDes8& aPDU,TSockAddr* from,TSockAddr* to=NULL,CProtocolBase* aSourceProtocol=NULL); // Up
1101 IMPORT_C virtual TInt GetOption(TUint level,TUint name,TDes8& option,CProtocolBase* aSourceProtocol=NULL); // Down
1102 IMPORT_C virtual TInt SetOption(TUint level,TUint name,const TDesC8& option,CProtocolBase* aSourceProtocol=NULL); // Down
1103 IMPORT_C virtual void Error(TInt anError,CProtocolBase* aSourceProtocol=NULL); // Up
1106 /** Fills in the passed TServerProtocolDesc with data describing the protocol.
1108 @param aProtocolDesc Protocol description object to fill in */
1109 virtual void Identify(TServerProtocolDesc* aProtocolDesc)const =0; // from anyone.
1111 inline TInt RefCount() const;
1113 IMPORT_C void CanClose(); // Up
1117 // TProtocolDesc iDesc;
1119 CProtocolRef* iManagerRef;
1123 class CProtocolFamilyRef;
1126 class CConnectionProvdBase;
1127 class CProtocolFamilyBase : public CBase
1128 /** Defines the interface for protocol families.
1130 Protocol families must:
1132 be able to identify the protocols which they can create
1134 be able to create instances of protocol objects for all the protocols they
1140 friend class ProtocolManager;
1141 friend class CProtocolFamilyRef;
1143 IMPORT_C virtual ~CProtocolFamilyBase();
1144 IMPORT_C CProtocolFamilyBase();
1145 IMPORT_C virtual void Close();
1146 IMPORT_C virtual void Open();
1147 IMPORT_C virtual TInt Remove();
1148 IMPORT_C virtual TBool QueryVersionSupported(const TVersion& aVer) const;
1150 void SetLibraryL(RLibrary& aLib);
1153 /** Initialises a protocol family.
1155 After the CProtocolFamilyBase-derived object has been created, the first function
1156 called by the socket server on that object is Install(). It is at this point that the
1157 CProtocolFamilyBase-derived object should perform any initialisation which it needs.
1159 @return System-wide error code */
1160 virtual TInt Install()=0;
1161 /** Creates a new protocol object.
1163 During socket creation, after the socket server has called Open() on a protocol family,
1164 it next calls this function to create an instance of a CProtocolBase-derived object -
1165 the protocol itself.
1167 @param aSockType A supported socket type for the protocol family as advertised
1168 in the protocol list.
1169 @param aProtocol A protocol number specifying a protocol returned by ProtocolList().
1171 @return A protocol, or NULL if some error has prevented the protocol from being
1173 virtual CProtocolBase * NewProtocolL(TUint aSockType,TUint aProtocol)=0;
1174 /** Gets a list of supported protocols.
1176 Called during initialisation, directly after Install(). ProtocolList() returns a list
1177 of all the protocols in the protocol family. The protocol family object should allocate
1178 memory to hold an array of TServerProtocolDesc structures. This function should then
1179 fill them in and return the pointer and a count of the number of protocols
1180 supported. The socket server caches this information, so that it does not
1181 need to keep the protocol module loaded.
1183 The protocol family should not attempt to use static data (which it can't)
1184 or to free this memory later, as the socket server will automatically free
1187 @param aProtocolList This pointer is set to point to memory allocated by the
1188 protocol family and filled in as described above
1189 @return The number of protocols in this protocol family (and entries in the
1190 list of protocols) */
1191 virtual TUint ProtocolList(TServerProtocolDesc*& aProtocolList)=0;
1193 inline TInt RefCount() const;
1197 /** Contains version information */
1201 CLibUnloader* iLibUnloader;
1202 CProtocolFamilyRef* iManagerRef;
1209 typedef CProtocolFamilyBase* (*TProtocolNew)();
1218 IMPORT_C static void Queue(TTimeIntervalMicroSeconds32 aTimeInMicroSeconds,TDeltaTimerEntry& aTimer);
1219 IMPORT_C static void Remove(TDeltaTimerEntry& aTimer);
1228 IMPORT_C static CProtocolBase* FindAndLoadProtocolL(const TDesC& aName, TProtocolType aType=ENormalProtocol);
1229 IMPORT_C static CProtocolBase* FindAndLoadProtocolL(TUint aAddrFamily, TUint aSockType, TUint aProtocol);
1230 IMPORT_C static void InstallExtensionL(const TDesC& aDllName, const TDesC& aArgs);
1231 IMPORT_C static void OpenSession();
1232 IMPORT_C static void CloseSession();
1233 IMPORT_C static void InstallSchedulerWaitHook(TCallBack* aCall);
1236 class CSocketServExtRef;
1237 class CSocketServExtBase : public CBase
1239 Base class for extensions
1245 IMPORT_C virtual ~CSocketServExtBase();
1247 IMPORT_C CSocketServExtBase();
1249 virtual void InstallL(const TDesC& aArgs)=0;
1250 virtual void Remove()=0;
1253 friend class CSocketServExtRef;
1254 CSocketServExtRef* iExtRef;
1261 Definition for internal SetOption() from ESock to Provider to communicate
1262 socket owner information.
1267 const TInt KSOLProvider = 2;
1269 const TUint KSoOwnerInfo = 1 | KSocketInternalOptionBit;
1273 Class used to communicate the owner of a socket from ESOCK to Provider.
1284 Definition for internal SetOption() from ESock to Provider to communicate
1285 connection selection information. Note that the information is opaque
1286 to ESock and comes from Nifman in the form of a TSoIfConnectionInfo class.
1289 const TInt KSoConnectionInfo = 2 | KSocketInternalOptionBit;
1292 UID of Protocol Modules
1295 const TInt KUidProtocolModule = 0x1000004A;
1298 UID of Unicode Protocol Modules
1302 const TInt KUidUnicodeProtocolModule = 0x10003d38;
1304 /** @internalTechnology */
1305 const TInt KUidEsockExtension = 0x10000387;
1307 #include <es_prot.inl>