week 10 bug fix submission (SF PDK version): Bug 1892, Bug 1897, Bug 1319. Also 3 or 4 documents were found to contain code blocks with SFL, which has been fixed. Partial fix for broken links, links to Forum Nokia, and the 'Symbian platform' terminology issues.
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
<!-- This component and the accompanying materials are made available under the terms of the License
"Eclipse Public License v1.0" which accompanies this distribution,
and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
<!-- Initial Contributors:
Nokia Corporation - initial contribution.
Contributors:
-->
<!DOCTYPE task
PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="GUID-45E1953A-DEFB-5E48-AC96-443A3234F913" xml:lang="en"><title>Retrieving
an IP Network Parameters Tutorial</title><shortdesc>How to retrieve IP network parameters from a DHCP server configured
network connection. </shortdesc><prolog><metadata><keywords/></metadata></prolog><taskbody>
<context id="GUID-C919A1D1-FE46-4D60-B20B-75D919404AB6"><p> The high level steps to retrieve an IP network parameters are
as follows: </p></context>
<steps id="GUID-A25ECF43-E64D-5DB2-B783-924BFA48F4A0">
<step id="GUID-5851EFBA-6976-55A6-A736-2480750951B6"><cmd>Open a socket using <codeph>RSocketServer</codeph> object. </cmd>
</step>
<step id="GUID-0E0A1640-7A99-587F-B70A-2057C6E3C201"><cmd>Create a connection
using <xref href="GUID-BED8A733-2ED7-31AD-A911-C1F4707C67FD.dita"><apiname>RConnection</apiname></xref> function. </cmd>
</step>
<step id="GUID-A248BB53-9180-5777-93C4-2B964C15FFC3"><cmd>Start the connection
using <xref href="GUID-BED8A733-2ED7-31AD-A911-C1F4707C67FD.dita"><apiname>RConnection</apiname></xref> with necessary preferences. </cmd>
<info>For example, enable DHCP server. The active connection is configured
by the DHCP server. </info>
</step>
<step id="GUID-796FB8CD-D4CD-54CE-93E0-90E8AD2F1B10"><cmd>To retrieve the
active network connection parameters, Call the <xref href="GUID-BED8A733-2ED7-31AD-A911-C1F4707C67FD.dita#GUID-BED8A733-2ED7-31AD-A911-C1F4707C67FD/GUID-9F820CF9-1D4F-3452-983B-E0C694D6783A"><apiname>RConnection::Ioctl()</apiname></xref> function
by passing the relevant arguments. </cmd>
</step>
<step id="GUID-926BD804-72F9-55F3-8569-4385FAB28989"><cmd>The <xref href="GUID-BED8A733-2ED7-31AD-A911-C1F4707C67FD.dita#GUID-BED8A733-2ED7-31AD-A911-C1F4707C67FD/GUID-9F820CF9-1D4F-3452-983B-E0C694D6783A"><apiname>RConnection::Ioctl()</apiname></xref> function
returns the necessary parameters. </cmd>
<info><p><note> Multiple option codes can be queried to a DHCP server using
the <api-item>TDhcpRawOptionMultipleDataPckg</api-item> object.</note></p><p> The
advantages of retrieving multiple parameters are: </p><ul>
<li><p>It reduces IPC calls between application and the DHCP daemon. </p></li>
<li><p>It reduces the messages exchanged between the DHCP daemon and the DHCP
server. </p></li>
</ul></info>
</step>
</steps>
<example><title> Retrieve IP Network Parameters example</title> <p>The following
is an example code for how to retrieve IP network parameters: </p> <codeblock id="GUID-39A702E4-A746-5BFA-A00E-AD34DBE2AD97" xml:space="preserve">
//create a socket connection
RSocketServ esock;
TInt err = eSock.Connect();
...
//handle the error
...
RConnection aConnection; //create a RConnection
err = aConnection.Open(esock);
...
//start the connection with necessary preferences
...
err = aConnection.Start(iConnPrefs);
//Retrieve the TFTP server address
TRequestStatus status1;
TTftpServerAddrBuf tftpserveraddr; // Buffer to store TFTP server address
tftpserveraddr().index = 0;
aConnection.Ioctl(KCOLConfiguration, KConnGetTftpServerAddr, status1, &tftpserveraddress);
User::WaitForRequest(status1);
...
//Retrieve the host name of the TFTP server
TRequestStatus status2;
TBuf<256> tftpname; //buffer to store TFTP server name
aConnection.Ioctl(KCOLConfiguration, KConnGetTftpServerName, status2, &tftpname);
User::WaitForRequest(status2);
...
//Retrieve SiAddr field from a DHCP header
TRequestStatus status3;
TConnectionAddrBuf addr;
addr().iAddressFamily = IpAddressFamily();
aConnection.Ioctl(KCOLConfiguration, KConnGetDhcpHdrSiaddr, status3, &addr);
...
//Retrieve SName field from a DHCP header
TRequestStatus status4;
TBuf<64> snamebuf;
aConnection.Ioctl(KCOLConfiguration, KConnGetDhcpHdrSname, status4, &snamebuf);
...
//Retrieve the active IP address
TRequestStatus status5;
TConnectionAddress actaddr;
actaddr().iAddressFamily = IpAddressFamily();
aConnection.Ioctl(KCOLConfiguration, KConnGetCurrentAddr, status5, &actaddr);
...
//Retrieve multiple parameters
Multiple opcodes can be queried to a DHCP server using the
TDhcpRawOptionMultipleDataPckg object.
TBuf8<300> rawbuf;
rawbuf.FillZ(300); //buffer must be large enough for all returned options values
TDhcpRawOptionMultipleDataPckg pckg1(rawbuf);
pckg1.AddRawOptionCodeL(KTFtpServerAddress); //option 150
pckg1.AddRawOptionCodeL(KGeoConfCivicOption); //option 99
pckg1.AddRawOptionCodeL(KTFtpServerName); // option 66
TRequestStatus status6;
// Get raw option data for ip4
aConnection.Ioctl(KCOLConfiguration, KConnDhcpGetMultipleParams, status6, &rawbuf);
User::WaitForRequest(status);
...
</codeblock> </example>
</taskbody><related-links>
<link href="GUID-69B46D92-8D07-5B42-B603-3F725977AA4A.dita"><linktext>DHCP</linktext>
</link>
</related-links></task>