MNetworkService Class Reference

class MNetworkService : public MFlowManager

Represents the network layer (ip6) of the stack.

In addition to own functions, the interface encapsulates some often-used CProtocolBase functions. For other functions, Protocol() gets the real CProtocolBase-derived object, which can be used for other basic functions when required.
Since
v7.0

Inherits from

Member Functions Documentation

BindL(CProtocolBase *, TUint)

void BindL ( CProtocolBase * aProtocol,
TUint aId
) [pure virtual]

Binds a protocol or hook to the network layer.

This is the same as CProtocolBase::BindL implemented in the ip6 protocol.

This is the primary method of installing a upper layer (or some hook) to the IP layer. The aId determines the type of binding
  • aId == 0, invalid

  • 0 < aId <= 255, upper layer bind. The aId is the protocol number as defined for the IPv4 (protocol in TInet6HeaderIP4 ) or IPv6 (next header in TInet6HeaderIP ) header. The bind registers aProtocol as an upper layer receiver of all packets of this protocol. The receiver protocol must be derived from CProtocolBase (but see also CProtocolInet6Binder , which can make interfacing easier).

  • aid > 255, hook bind. The aId determines the type of binding. The bind registers aProtocol as a hook. The hook protocol must be derived from CIp6Hook (but, see CProtocolPosthook , which is derived from CIp6Hook and provides some automatic support for the hook attachment).

See also bindl_interface for more information.

Parameters

CProtocolBase * aProtocol The protocol or hook requesting the bind
TUint aId The bind id.

Icmp4Send(RMBufRecvPacket &, TInt, TInt, TUint32, TInt)

void Icmp4Send ( RMBufRecvPacket & aPacket,
TInt aType,
TInt aCode = 0,
TUint32 aParameter = 0,
TInt aMC = 0
) [pure virtual]

Sends an ICMP (v4) error message based on a received IP packet.

This function is used to send an ICMP error message based on received IP packet (stored in aPacket). aPacket must begin with the received IP header (either IPv4 or IPv6) at offset 0.

The aPacket must be in "unpacked state" for the info block (assume RMBufRecvPacket::Unpack() has been called).

The info block is assumed to be RMBufRecvInfo . But, only the following data is significant:

  • RMBufPktInfo::iFlags only KIpNeverIcmpError flag is tested, and if non-zero, then no ICMP error will be generated, and packet is just dropped.

  • RMBufRecvInfo::iIcmp must be ZERO. If non-zero, no ICMP error will be generated, and packet is just dropped. A non-zero iIcmp indicates that the received packet itself is being processed as an ICMP error message, and no ICMP error should be generated from ICMP error.

  • RMBufRecvInfo::iInterfaceIndex identifies the interface of the received packet. The ICMP error message is normally sent to the incoming interface. For any received packet, this field is properly initialized and should not be touched. If an ICMP error is to be generated from an outgoing packet for which no source interface is known, one can use ZERO here.

  • all other fields are ignored. The source and destination addresses for the ICMP error message are constructed from the IP header of the packet. The addresses in the info block are ignored.

Parameters

RMBufRecvPacket & aPacket The received packet for which the ICMP error is being generated. This must start with correct IP header (either IPv4 or IPv6) at offset 0. (The RMbufRecvInfo::iOffset is ignored, and has no significance). The buffer is "consumed" by the call, caller does not need to call Free() for the Packet.
TInt aType The type of the ICMP [0..255]
TInt aCode = 0 The code of the ICMP [0..255]
TUint32 aParameter = 0 The parameter value of the ICMP.
TInt aMC = 0 If non-zero, send ICMP even if the original packet was sent to a multicast or broadcast address. Normally, ICMP error messages are not generated from multicast packets.

Icmp6Send(RMBufRecvPacket &, TInt, TInt, TUint32, TInt)

void Icmp6Send ( RMBufRecvPacket & aPacket,
TInt aType,
TInt aCode = 0,
TUint32 aParameter = 0,
TInt aMC = 0
) [pure virtual]

Sends an ICMP (v6) error message based on a received IP packet.

See documentation on the MNetworkService::Icmp4Send method for the parameters.

Parameters

RMBufRecvPacket & aPacket
TInt aType
TInt aCode = 0
TUint32 aParameter = 0
TInt aMC = 0

Interfacer()

MInterfaceManager * Interfacer ( ) const [pure virtual]

Gets the interface manager for the network layer (ip6) of the stack.

NewHostResolverL()

CHostResolvProvdBase * NewHostResolverL ( ) [pure virtual]

Gets the default name services provider from the network layer.

The network layer (IP) provides a gateway to the name resolver implementation for DNS.

In EPOC, each protocol is responsible for implementing it's own name resolution. Any protocol wishing to support RhostResolver can get the full DNS support from the network layer by just delegating the call via this method.

NewNetDatabaseL()

CNetDBProvdBase * NewNetDatabaseL ( ) [pure virtual]

Gets the default net database provider from the network layer. Not supported, always leaves.

NewServiceResolverL()

CServiceResolvProvdBase * NewServiceResolverL ( ) [pure virtual]

Gets the default service resolver provider from the network layer. Not supported, always leaves.

Process(RMBufChain &, CProtocolBase *)

void Process ( RMBufChain & aPacket,
CProtocolBase * aSource = NULL
) [pure virtual]

Processes incoming packet.

This is a direct accesss to the IP layer CProtocolBase::Process function.

The IP layer CProtocolBase::Process is the function used by NIFs to feed in packets from the link layer. The aSource must be a CNifIfBase derived object and known to the interface manager of the stack. Otherwise the IP layer will not accept the packet. The passed packet must follow the rules as described in nif_inbound_packets The packet goes through the following process:
  1. the packet is pushed through the inbound posthooks as is (for example, see CProtocolPosthook::Process ), and then queued for IP processing.

  2. the packet from the queue is processed as an IP packet and extension headers are processed by inbound hooks ( MIp6Hook::ApplyL )

  3. the packet is passed to the upper layer protcool ( CProtocolBase::Process )

If any hook or protocol in the inbound path decides to use this function to re-inject a (modified) packet back to the system, then it must remove the packet from the current inbound processing path.

Parameters

RMBufChain & aPacket The packet
CProtocolBase * aSource = NULL The source of the packet (a NIF)

Protocol()

CProtocolInet6Binder * Protocol ( ) const [pure virtual]

Gets the underlying protocol object for the network layer (ip6) of the stack.

Send(RMBufChain &, CProtocolBase *)

TInt Send ( RMBufChain & aPacket,
CProtocolBase * aSource = NULL
) [pure virtual]

Sends outgoing packet.

This is a direct access to the IP layer CProtocolBase::Send function.

The IP layer CProtocolBase::Send is the function used by upper layer protocols to feed in packet to the IP layer. This packet does not normally have the IPv6 or IPv4 headers (unless the KIpHeaderIncluded flag is set the iFlags), and the packet begins directly with the upper layer protocol header (for example TInet6HeaderUDP or TInet6HeaderTCP ).

The information block is RMBufSendInfo , which extends the basic RMBufPktInfo by RFlowContext member. This must be correctly initialized. The three alternatives are
         RFlowContext flow;			// some existing flow
	MNetworkService *manager;
	RMBufSendPacket packet;		// unpacked state.
	RMBufSendInfo *info = packet.Info();
	TInt res = KErrNone;

	// 1. No flow context (avoid this if you can)
	info->iFlow = RFlowContext();

	// 2. A new flow context (assuming the base part of info is already set).
	res = info->iFlow.Open(manager, info->iDstAddr, info->iSrcAddr,
			info->iProtocol, icmp_type, icmp_code);

	// 3. A reference to existing opened flow (this will load the base part
	// of the info from the attached flow).
	res = info->iFlow.Open(flow, info);

	// sending the packet.
	if (res == KErrNone)
		{
		aPacket.Pack();
		manager->Send(aPacket);
		}
	else
		{
		// creation failed (res < 0) or is blocked (res > 0)
		info->iFlow.Close();
		}
	aPacket.Free();
        
The first two are inefficient. They require a full flow open/close sequence for each packet. The third alternative is the most efficient, because the same flow is re-used for multiple packets. This also enables the use of RFlowContext::SetNotify for asynchronous detection of unblocking or error on the flow.
The packet goes through the following steps:
  1. if a flow context is missing, allocate and connect a new flow context for the packet. The flow selectors are based on address and protocol fields of the RMBufPktInfo (alternative 2. in above).

  2. if the packet does not have KIpHeaderIncluded flag set in iFlags of the info, an IPv4 or IPv6 header is added (based on the value of CFlowContext::iHead.ip6.Version()). The content of CFlowContext::iHead.iPacket is copied after the IP header.

  3. the packet is passed through the MFlowHook::ApplyL function of all attached outbound flow hooks.

  4. if the packet is longer than the path MTU, it is fragmented. Unless KIpDontFragment is set. In that case the stack generates an ICMP error message "packet too big".

  5. the packet (or fragments) are passed through all outbound post hooks (for example, CProtocolPosthook::Send ).

  6. the terminator post hook finally passes the packet(s) to the CFlowContext::Send function, which eventually passes the packet to the CNifIfBase::Send (the packet may need to be queued for a while due to neighbor discovery, or just because NIF is blocked). (see also nif_outbound_packets )

Parameters

RMBufChain & aPacket The packet
CProtocolBase * aSource = NULL Protocol sending the data.