diff -r 000000000000 -r 89d6a7a84779 Symbian3/SDK/Source/GUID-FE3825C5-BDEE-5F18-9FFD-2E794E618FEC.dita --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Symbian3/SDK/Source/GUID-FE3825C5-BDEE-5F18-9FFD-2E794E618FEC.dita Thu Jan 21 18:18:20 2010 +0000 @@ -0,0 +1,49 @@ + + + + + +Data Access ExampleThis example describes typical processing of the data in an RMBufChain.
Downwards flow + Example : flow going downwards +

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.

Upwards flow + Example : flow going upwards +

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.

Overview Comms Buffers (MBuf) + and Comms Chains
\ No newline at end of file