This example describes typical processing of the data in an RMBufChain.
The following function is a simplified example of how a component in the middle of the stack could process data sent to the driver. As shown in the above diagram, the upper layer provides the data in the RMBufChain parameter.
void Send (RMBufChain &aChain) { TBuf8<KHeaderLength> aHeader; // [...] fill the header // request space in front of the data aChain.Prepend(KHeaderLength); // add the protocol header aChain.CopyIn(aHeader); // send the updated chain to the next layer downwardComponent->Send(aChain); }
Note that depending on the available space remaining in front of the data in the MBuf, the RMBufChain::Prepend() method may request the pond to add a new MBuf to the front of the chain. For more information, see Buffer layout.
The following function is a simplified example of how a component in the middle of the stack could process data received by the driver. As shown in the above diagram, the underlying layer provides the data in the RMBufChain parameter.
void Process (RMBufChain &aChain) { TBuf8<KHeaderLength> aHeader; // get a copy of the header aChain.CopyOut(KHeaderLength, &aHeader); // discard the header in the chain aChain.TrimStart(KHeaderLength); // [...] process the header // send the updated chain to the next layer appropriateUpwardComponent->Process(aChain); }
Note that the header might not be stored in a contiguous memory area: it can be splitted accross several chained MBufs. For a better performance, you should define a buffer size slightly bigger than your MTU: for more information, see Pond Configuration : Recommendations.
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.