CProtocolBase Class Reference

class CProtocolBase : public CBase

Protocols created by protocol families must be instances of sub-classes of the abstract CProtocolBase. Since v5.0

Inherits from

Constructor & Destructor Documentation

CProtocolBase()

IMPORT_CCProtocolBase()

Constructor for the Protocol Base

~CProtocolBase()

IMPORT_C~CProtocolBase()[virtual]

Destroy the Protocol Base

Member Functions Documentation

BindL(CProtocolBase *, TUint)

IMPORT_C voidBindL(CProtocolBase *protocol,
TUintid
)[virtual]

This function panics with a panic number of EDoesNotBindBelow.

Parameters

CProtocolBase * protocolThe higher level protocol requesting to bind
TUint idThe ID number of the protocol requesting to bind

BindToL(CProtocolBase *)

IMPORT_C voidBindToL(CProtocolBase *protocol)[virtual]

This function panics with a panic number of EDoesNotBindAbove.

Parameters

CProtocolBase * protocolThe lower level protocol whose bind function must be called.

CanClose()

IMPORT_C voidCanClose()[protected]

Called by derived classes when an acceptable closedown condition has been reached.

Derived classes should not override this function.

CloseNow() for more details.

Close()

IMPORT_C voidClose()[virtual]

Closes a client connection.

The default implementation decrements the reference count and calls CloseNow() if no clients are connected.

Any implementations by derived classes should call this base class implementation.

CloseNow()

IMPORT_C voidCloseNow()[virtual]

Closes the protocol.

Called by Close() when all clients referencing a protocol have disconnected.

The default implementation simply deletes the object. Derived classes can implement this function to provide a delayed closedown: for example, to allow reliable protocols to ensure that all data has drained from the stack before it is deleted. When an acceptable closedown condition has been reached, the protocol should call CanClose().

Error(TInt, CProtocolBase *)

IMPORT_C voidError(TIntanError,
CProtocolBase *aSourceProtocol = NULL
)[virtual]

This function panics with a panic number of EErrorCallNotHandled unless the error is KErrCancel which is simply ignored.

Parameters

TInt anErrorThe error code
CProtocolBase * aSourceProtocol = NULLThe protocol raising the error

GetOption(TUint, TUint, TDes8 &, CProtocolBase *)

IMPORT_C TIntGetOption(TUintlevel,
TUintname,
TDes8 &option,
CProtocolBase *aSourceProtocol = NULL
)[virtual]

Gets options for the protocol on behalf of socket server clients.

The option parameter is protocol-defined - this is a generic API. The protocol is passed in because you might get GetOption() calls from multiple bindees - this is actually more meaningful for SetOption().

Parameters

TUint level
TUint name
TDes8 & option
CProtocolBase * aSourceProtocol = NULLThe protocol making the request.

Identify(TServerProtocolDesc *)

voidIdentify(TServerProtocolDesc *aProtocolDesc)const [pure virtual]

Fills in the passed TServerProtocolDesc with data describing the protocol.

Parameters

TServerProtocolDesc * aProtocolDescProtocol description object to fill in

InitL(TDesC &)

IMPORT_C voidInitL(TDesC &aTag)[virtual]

Initialises a protocol before any binding is performed. A protocol can override it to create any further resources it may require - this might include allocating buffers, opening devices or reading more configuration information.

If the protocol encounters any errors it should leave.

Note:

This implementation does nothing.

Parameters

TDesC & aTagThe string identifier for the protocol as given by its section header in esock.ini

NewHostResolverL()

IMPORT_C CHostResolvProvdBase *NewHostResolverL()[virtual]

This function panics with a panic number of EBadHostResolver.

NewNetDatabaseL()

IMPORT_C CNetDBProvdBase *NewNetDatabaseL()[virtual]

This function panics with a panic number of EBadNetDBRequest.

NewSAPL(TUint)

IMPORT_C CServProviderBase *NewSAPL(TUintaProtocol)[virtual]

Creates a new service access point.

If the protocol cannot create the CServProviderBase for any reason, it should leave.

Parameters

TUint aProtocolProtocol.

NewServiceResolverL()

IMPORT_C CServiceResolvProvdBase *NewServiceResolverL()[virtual]

This function panics with a panic number of EBadServiceResolver.

Open()

IMPORT_C voidOpen()[virtual]

Opens a client connection.

The default implementation simply increments the reference count.

Any implementations by derived classes should call this base class implementation.

Process(RMBufChain &, CProtocolBase *)

IMPORT_C voidProcess(RMBufChain &,
CProtocolBase *aSourceProtocol = NULL
)[virtual]

This function panics with a panic number of ECantProcessMbufs.

Parameters

RMBufChain &
CProtocolBase * aSourceProtocol = NULL

Process(TDes8 &, TSockAddr *, TSockAddr *, CProtocolBase *)

IMPORT_C voidProcess(TDes8 &aPDU,
TSockAddr *from,
TSockAddr *to = NULL,
CProtocolBase *aSourceProtocol = NULL
)[virtual]

This function panics with a panic number of ECantProcessDescriptors.

Parameters

TDes8 & aPDUThe datagram to process.
TSockAddr * from
TSockAddr * to = NULL
CProtocolBase * aSourceProtocol = NULLThe higher level protocol which we want to process our incoming datagram.

ProtocolFamily()

CProtocolFamilyBase *ProtocolFamily()

Get our family - through the manager ref.

RefCount()

TInt RefCount()const [inline]

Reference counting by protocols created by protocol families.

Send(RMBufChain &, CProtocolBase *)

IMPORT_C TIntSend(RMBufChain &aPDU,
CProtocolBase *aSourceProtocol = NULL
)[virtual]

This function panics with a panic number of ECantSendMBufs.

Parameters

RMBufChain & aPDU
CProtocolBase * aSourceProtocol = NULL

Send(TDes8 &, TSockAddr *, TSockAddr *, CProtocolBase *)

IMPORT_C TIntSend(TDes8 &aPDU,
TSockAddr *to,
TSockAddr *from = NULL,
CProtocolBase *aSourceProtocol = NULL
)[virtual]

This function panics with a panic number of ECantSendDescriptors.

Parameters

TDes8 & aPDUThe datagram to be sent.
TSockAddr * to
TSockAddr * from = NULL
CProtocolBase * aSourceProtocol = NULLThe protocol from which the data has been sent.

SetOption(TUint, TUint, const TDesC8 &, CProtocolBase *)

IMPORT_C TIntSetOption(TUintlevel,
TUintname,
const TDesC8 &option,
CProtocolBase *aSourceProtocol = NULL
)[virtual]

Sets options for the protocol on behalf of socket server clients.

The option parameter is protocol-defined - this is a generic API.

The protocol is passed in because you might get SetOption() calls from multiple bindees and need to distinguish who is setting what.

Parameters

TUint level
TUint name
const TDesC8 & option
CProtocolBase * aSourceProtocol = NULLThe protocol making the request.

StartL()

IMPORT_C voidStartL()[virtual]

Indicates to a protocol that all binding has completed successfully and it can start processing datagrams. This is mainly of interest to the lowest levels of a protocol stack which would queue a read on the network media device driver in response to this call.

If a protocol cannot start to process data (for example it may not have bound correctly) it should leave.

Note:

This implementation does nothing.

StartSending(CProtocolBase *)

IMPORT_C voidStartSending(CProtocolBase *aProtocol)[virtual]

Indicates that data can now be sent. Implementations can call bound higher-level protocols and service access points in turn.

With Send(), this function forms a flow control pair. A zero return from a Send() should flow control off the calling protocol. StartSending() acts as a flow control on.

Note:

This implementation does nothing.

Parameters

CProtocolBase * aProtocolThe calling protocol

Tag()

IMPORT_C TPtrCTag()

Gets a TPtrC to the protocol's tag name. The default implementation returns the tag passed to Init().

TryDelete()

voidTryDelete()[private]

delete Protocol Base if ref count <0 Used from Protocol manager cleanup stack entries

Member Data Documentation

CProtocolRef * iManagerRef

CProtocolRef *iManagerRef[private]

TInt iRefCount

TInt iRefCount[private]