CProtocolInet6Binder Class Reference

class CProtocolInet6Binder : public CProtocolBaseUnbind

Base class for protocols that bind to the network layer (IPv6 instance).

It provides default BindToL() processing, name services, and a pathway to the IP layer and interface manager through the MNetworkService class.

This class was designed for upper layer protocols and the implementation assumes thet the TServerProtocolDesc::iProtocol contains the id of the implemented protocol (for example, the id is 6 for TCP and 17 for UDP). Upper layer protocols can also be implemented using other base classes, for example CProtocolPosthook . The iProtocol field value is also the protocol parameter in RSocket::Open function. This, and the address family determine the protocol module to which the socket is created.

Note:

This is also the base class of the IP protocol instance. A hook or protocol that binds to or is bound from IP layer, and recognizes it as being instance of IP layer, can cast the CProtocolBase into this class and then use the NetworkService() to get full access to the network layer.

Since
v7.0

Inherits from

Public Member Functions
~CProtocolInet6Binder ()
IMPORT_C void BindToL ( CProtocolBase *)
MNetworkService * NetworkService ()
IMPORT_C CHostResolvProvdBase * NewHostResolverL ()
IMPORT_C CNetDBProvdBase * NewNetDatabaseL ()
IMPORT_C CServiceResolvProvdBase * NewServiceResolverL ()
Protected Member Functions
IMPORT_C TInt DoBindTo ( CProtocolBase *)
Inherited Functions
CBase::CBase()
CBase::Delete(CBase *)
CBase::Extension_(TUint,TAny *&,TAny *)
CBase::operator new(TUint)
CBase::operator new(TUint,TAny *)
CBase::operator new(TUint,TLeave)
CBase::operator new(TUint,TLeave,TUint)
CBase::operator new(TUint,TUint)
CBase::~CBase()
CProtocolBase::BindL(CProtocolBase *,TUint)
CProtocolBase::CProtocolBase()
CProtocolBase::CanClose()
CProtocolBase::Close()
CProtocolBase::CloseNow()
CProtocolBase::Error(TInt,CProtocolBase *)
CProtocolBase::GetOption(TUint,TUint,TDes8 &,CProtocolBase *)
CProtocolBase::Identify(TServerProtocolDesc *)const
CProtocolBase::InitL(TDesC &)
CProtocolBase::NewSAPL(TUint)
CProtocolBase::Open()
CProtocolBase::Process(RMBufChain &,CProtocolBase *)
CProtocolBase::Process(TDes8 &,TSockAddr *,TSockAddr *,CProtocolBase *)
CProtocolBase::ProtocolFamily()
CProtocolBase::RefCount()const
CProtocolBase::Send(RMBufChain &,CProtocolBase *)
CProtocolBase::Send(TDes8 &,TSockAddr *,TSockAddr *,CProtocolBase *)
CProtocolBase::SetOption(TUint,TUint,const TDesC8 &,CProtocolBase *)
CProtocolBase::StartL()
CProtocolBase::StartSending(CProtocolBase *)
CProtocolBase::Tag()
CProtocolBase::~CProtocolBase()
CProtocolBaseUnbind::Unbind(CProtocolBase *,TUint)
Protected Attributes
MNetworkService * iNetwork

Constructor & Destructor Documentation

~CProtocolInet6Binder()

IMPORT_C ~CProtocolInet6Binder ( ) [virtual]

Destructor.

This handles unbinding from the network (iNetwork), if it has been bound.

Member Functions Documentation

BindToL(CProtocolBase *)

IMPORT_C void BindToL ( CProtocolBase * aProtocol ) [virtual]

Bind to another protocol.

This default implementation only handles the network bind. The implementation is just a call to CProtocolInet6Binder::DoBindTo and a leave with KErrNotSupported, if the protocol was not the network (= IPv6) instance.

If this handling is not sufficient, the derived class must override this method and call first the CProtocolInet6Binder::DoBindTo for network bind, and then handle the other allowed bindings.

Parameters

CProtocolBase * aProtocol Protocol to bind (see CProtocolInet6Binder::DoBindTo)

DoBindTo(CProtocolBase *)

IMPORT_C TInt DoBindTo ( CProtocolBase * aProtocol ) [protected]

Performs the BindToL processing for the IP binding.

This method exists for derived classes that override the default CProtocolInet6Binder::BindToL for their own processing. They can first call DoBindTo to handle the network bind, and then handle other binds. If the bound protocol is a network, the CProtocolInet6Binder::iNetwork is initialized and this protocol is bound to the network using the BindL(this, id) function, where id is the value of the TServerProtocolDesc::iProtocol field from this protocol. This must be in range [1..255] and it maps directly the to protocol field (next header in IPv6) of the IP header ( TInet6HeaderIP and TInet6HeaderIP4 ).

Only one network bind is accepted. If protocol is bound to multiple protocols which have either KProtocolInet6Ip or KProtocolInetIp as their TServerProtocolDesc::iProtocol , then the first one used in DoBindTo is the effective one, the remaining ones are returned as if bind wast to some other protocol.

Note:

Because the return value is used for both error indication (= negative return), and for unprocessed protocol number, the implementation prevents use of protocol numbers that would be negative numbers when treated as signed integers. If such is required, the derived class must handle them by other means.

Example, assuming your ESK contains
         [upper]
filename= upper.prt
index= 1
bindto= ip6,other
        
the socket server will call your BindToL twice, once for 'ip6' and once for 'other'. If your 'upper' protocol does not override the BindToL function, then the default implementation of CProtocolInet6Binder handles the 'ip6' case, but leaves with 'other'. To handle the above case, your overriding BindToL could look as follows:
         CProtocolUpper::BindToL(CProtocolBase *aProtocol)
	{
	TInt id = DoBindTo(aProtocol);
	if (id == your_other_protocol_id)
		{
		// handle your bind to other, for example
		iOther = aProtocol;
		iOther->Open();
		iOther->BindL(this, your_id_or_something_else);
		}
	else if (id != KErrNone)
		{
		// Not ip6 or 'other
		User::Leave(KErrNotSupported);
		}
	}

CProtocolUpper::~CProtocolUpper
	{
	if (iOther)
		{
		// iOther->Unbind(this); // maybe needed, depends on 'other'
		iOther->Close();
		iOther = NULL;
		}
	}
        

Parameters

CProtocolBase * aProtocol This protocol is recognized as a "network", if the TServerProtocolDesc::iProtocol field contains the special value KProtocolInet6Ip (or KProtocolInetIp).

NetworkService()

MNetworkService * NetworkService ( ) const [inline]

Gets the network layer (IPv6) of the stack.

NewHostResolverL()

IMPORT_C CHostResolvProvdBase * NewHostResolverL ( ) [virtual]

Gets the default name services provider from the network layer.

NewNetDatabaseL()

IMPORT_C CNetDBProvdBase * NewNetDatabaseL ( ) [virtual]

Gets the default net database provider from the network layer.

NewServiceResolverL()

IMPORT_C CServiceResolvProvdBase * NewServiceResolverL ( ) [virtual]

Gets the default service resolver provider from the network layer.

Member Data Documentation

MNetworkService * iNetwork

MNetworkService * iNetwork [protected]

Network instance, if non-NULL.

Initialized and maintained by DoBindTo, The pointer value should be considered as "read-only" by the derived class.