diff -r 000000000000 -r 89d6a7a84779 Symbian3/SDK/Source/GUID-45E1953A-DEFB-5E48-AC96-443A3234F913.dita --- /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 @@ + + + + + +Retrieving +an IP Network Parameters TutorialHow to retrieve IP network parameters from a DHCP server configured +network connection. +

The high level steps to retrieve an IP network parameters are +as follows:

+ +Open a socket using RSocketServer object. + +Create a connection +using RConnection function. + +Start the connection +using RConnection with necessary preferences. +For example, enable DHCP server. The active connection is configured +by the DHCP server. + +To retrieve the +active network connection parameters, Call the RConnection::Ioctl() function +by passing the relevant arguments. + +The RConnection::Ioctl() function +returns the necessary parameters. +

Multiple option codes can be queried to a DHCP server using +the <api-item>TDhcpRawOptionMultipleDataPckg</api-item> object.

The +advantages of retrieving multiple parameters are:

    +
  • It reduces IPC calls between application and the DHCP daemon.

  • +
  • It reduces the messages exchanged between the DHCP daemon and the DHCP +server.

  • +
+
+
+ Retrieve IP Network Parameters example

The following +is an example code for how to retrieve IP network parameters:

+ +//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); +... + + +
+
+DHCP + +
\ No newline at end of file