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.
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.
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 *) |
Protected Attributes | |
---|---|
MNetworkService * | iNetwork |
IMPORT_C | ~CProtocolInet6Binder | ( | ) | [virtual] |
Destructor.
This handles unbinding from the network (iNetwork), if it has been bound.
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.
CProtocolBase * aProtocol | Protocol to bind (see CProtocolInet6Binder::DoBindTo) |
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.
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.
[upper] filename= upper.prt index= 1 bindto= ip6,otherthe 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; } }
CProtocolBase * aProtocol | This protocol is recognized as a "network", if the TServerProtocolDesc::iProtocol field contains the special value KProtocolInet6Ip (or KProtocolInetIp). |
MNetworkService * | NetworkService | ( | ) | const [inline] |
Gets the network layer (IPv6) of the stack.
IMPORT_C CHostResolvProvdBase * | NewHostResolverL | ( | ) | [virtual] |
Gets the default name services provider from the network layer.
IMPORT_C CNetDBProvdBase * | NewNetDatabaseL | ( | ) | [virtual] |
Gets the default net database provider from the network layer.
IMPORT_C CServiceResolvProvdBase * | NewServiceResolverL | ( | ) | [virtual] |
Gets the default service resolver provider from the network layer.
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.
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.