Symbian3/SDK/Source/GUID-45E1953A-DEFB-5E48-AC96-443A3234F913.dita
changeset 0 89d6a7a84779
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Symbian3/SDK/Source/GUID-45E1953A-DEFB-5E48-AC96-443A3234F913.dita	Thu Jan 21 18:18:20 2010 +0000
@@ -0,0 +1,125 @@
+<?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 &lt;api-item&gt;TDhcpRawOptionMultipleDataPckg&lt;/api-item&gt; 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, &amp;tftpserveraddress);
+User::WaitForRequest(status1);
+...
+
+//Retrieve the host name of the TFTP server
+
+TRequestStatus status2;
+TBuf&lt;256&gt; tftpname; //buffer to store TFTP server name
+aConnection.Ioctl(KCOLConfiguration, KConnGetTftpServerName, status2, &amp;tftpname);
+User::WaitForRequest(status2);
+...
+
+//Retrieve SiAddr field from a DHCP header
+
+TRequestStatus status3;
+TConnectionAddrBuf addr;
+addr().iAddressFamily = IpAddressFamily();
+aConnection.Ioctl(KCOLConfiguration, KConnGetDhcpHdrSiaddr, status3, &amp;addr);
+...
+//Retrieve SName field from a DHCP header
+
+TRequestStatus status4;
+TBuf&lt;64&gt; snamebuf;
+aConnection.Ioctl(KCOLConfiguration, KConnGetDhcpHdrSname, status4, &amp;snamebuf);
+...
+//Retrieve the active IP address
+
+TRequestStatus status5;
+TConnectionAddress actaddr;
+actaddr().iAddressFamily = IpAddressFamily();
+aConnection.Ioctl(KCOLConfiguration, KConnGetCurrentAddr, status5, &amp;actaddr); 
+...
+
+//Retrieve multiple parameters
+
+Multiple opcodes can be queried to a DHCP server using the 
+TDhcpRawOptionMultipleDataPckg object. 
+
+TBuf8&lt;300&gt; 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, &amp;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>
\ No newline at end of file