1504 iMessageSender->Cancel(); |
1512 iMessageSender->Cancel(); |
1505 |
1513 |
1506 __CFLOG_VAR((KLogSubSysDHCP, KLogCode, _L8("CDHCPIP4StateMachine::ConfigureInterfaceL - KSoNoSourceAddressSelect"))); |
1514 __CFLOG_VAR((KLogSubSysDHCP, KLogCode, _L8("CDHCPIP4StateMachine::ConfigureInterfaceL - KSoNoSourceAddressSelect"))); |
1507 User::LeaveIfError(iSocket.SetOpt(KSoNoSourceAddressSelect, KSolInetIp, 0)); |
1515 User::LeaveIfError(iSocket.SetOpt(KSoNoSourceAddressSelect, KSolInetIp, 0)); |
1508 |
1516 |
1509 TSoInet6InterfaceInfo interfaceInfo; |
1517 // Using the new structure derived from TSoInet6InterfaceInfo |
1510 |
1518 // to be able to set domain search list for the interface |
1511 CDHCPMessageHeaderIP4* v4Msg = DhcpMessage(); |
1519 TSoInetInterfaceInfoExtnDnsSuffix interfaceInfo; |
|
1520 |
|
1521 CDHCPMessageHeaderIP4* v4Msg = DhcpMessage(); |
|
1522 |
|
1523 |
|
1524 // Read the optiond data buffer for option 119 and decrypt it |
|
1525 HBufC8* domainSearchBuf(NULL); |
|
1526 v4Msg->iOptions.CopyDomainSearchL(domainSearchBuf); |
|
1527 if (domainSearchBuf) |
|
1528 { |
|
1529 // Perform decryption only if option data has been returned by dhcp server |
|
1530 SplitDomainSearchBufferL(domainSearchBuf); |
|
1531 delete domainSearchBuf; |
|
1532 domainSearchBuf = NULL; |
|
1533 } |
1512 |
1534 |
1513 if (!IsUsingStaticAddress()) |
1535 if (!IsUsingStaticAddress()) |
1514 { |
1536 { |
1515 iCurrentAddress.SetAddress(v4Msg->GetYIAddr()); |
1537 iCurrentAddress.SetAddress(v4Msg->GetYIAddr()); |
1516 iServerAddress = v4Msg->iOptions.GetServerId(); |
1538 iServerAddress = v4Msg->iOptions.GetServerId(); |
1579 interfaceInfo.iAlias = EFalse; |
1601 interfaceInfo.iAlias = EFalse; |
1580 interfaceInfo.iDoId = ETrue; |
1602 interfaceInfo.iDoId = ETrue; |
1581 interfaceInfo.iDoState = ETrue; |
1603 interfaceInfo.iDoState = ETrue; |
1582 interfaceInfo.iDoAnycast = EFalse; |
1604 interfaceInfo.iDoAnycast = EFalse; |
1583 interfaceInfo.iDoProxy = EFalse; |
1605 interfaceInfo.iDoProxy = EFalse; |
1584 |
1606 |
|
1607 // Depending on number of domain suffix(es) received from the DHCP server, |
|
1608 // we have to call CDHCPStateMachine::ConfigureInterfaceL multiple times |
|
1609 TUint suffixCount = iSuffixList.Count(); |
|
1610 |
|
1611 if (suffixCount > 0) |
|
1612 interfaceInfo.iDomainSuffix.Copy(iSuffixList[0]); |
|
1613 |
|
1614 // If there is no domain suffix available for updating the interface, |
|
1615 // we end up calling ConfigureInterfaceL once |
1585 CDHCPStateMachine::ConfigureInterfaceL( interfaceInfo ); |
1616 CDHCPStateMachine::ConfigureInterfaceL( interfaceInfo ); |
|
1617 |
|
1618 // Repeat ConfigureInterface call for each domain suffix returned from the server |
|
1619 for (TUint index = 1; index < suffixCount; index++) |
|
1620 { |
|
1621 interfaceInfo.iDomainSuffix.Copy(iSuffixList[index]); |
|
1622 CDHCPStateMachine::ConfigureInterfaceL( interfaceInfo ); |
|
1623 } |
1586 } |
1624 } |
1587 |
1625 |
1588 void CDHCPIP4StateMachine::CreateFqdnUpdateRequestL() |
1626 void CDHCPIP4StateMachine::CreateFqdnUpdateRequestL() |
1589 { |
1627 { |
1590 #ifndef SYMBIAN_COMMS_REPOSITORY |
1628 #ifndef SYMBIAN_COMMS_REPOSITORY |
1873 } |
1911 } |
1874 __CFLOG_VAR((KLogSubSysDHCP, KLogCode, _L8("Client Harware address not provisioned"))); |
1912 __CFLOG_VAR((KLogSubSysDHCP, KLogCode, _L8("Client Harware address not provisioned"))); |
1875 return EFalse; |
1913 return EFalse; |
1876 } |
1914 } |
1877 #endif //SYMBIAN_NETWORKING_ADDRESS_PROVISION |
1915 #endif //SYMBIAN_NETWORKING_ADDRESS_PROVISION |
|
1916 |
|
1917 /** |
|
1918 * @name AppendMultipleExtraOptionsParam |
|
1919 * Parses dhcp.ini for extra dhcp options and adds them to |
|
1920 * the dhcp server's parameter request list |
|
1921 * |
|
1922 * @internalTechnology |
|
1923 */ |
|
1924 void CDHCPIP4StateMachine::AppendMultipleExtraOptionsParamL() |
|
1925 { |
|
1926 TBuf8<KOpCodeOutOfBounds> iniValue; |
|
1927 User::LeaveIfError(IniRead(KDhcpExtraOptions, iniValue)); |
|
1928 |
|
1929 TLex8 iniLex(iniValue); |
|
1930 TChar ch; |
|
1931 |
|
1932 while((ch = iniLex.Get()) != 0) |
|
1933 { |
|
1934 TUint8 opCode(ch); |
|
1935 TPtr8 opCodePtr(&opCode,1,1); |
|
1936 |
|
1937 if (!iSavedExtraParameters.Length()) |
|
1938 { |
|
1939 iSavedExtraParameters.CreateL(opCodePtr); |
|
1940 } |
|
1941 else |
|
1942 { |
|
1943 iSavedExtraParameters.ReAllocL(iSavedExtraParameters.Length()+opCodePtr.Length()); |
|
1944 iSavedExtraParameters.Append(opCodePtr); |
|
1945 } |
|
1946 } |
|
1947 } |
|
1948 |
|
1949 /** |
|
1950 * @name SplitDomainSearchBufferL |
|
1951 * Decrypt dhcp server option data response for option code 119 |
|
1952 * and retrieve the domain search list for configuring the interface |
|
1953 * |
|
1954 * @internalTechnology |
|
1955 */ |
|
1956 void CDHCPIP4StateMachine::SplitDomainSearchBufferL(HBufC8* aDomainSearchBuf) |
|
1957 { |
|
1958 typedef TBuf8<KMaxDomainSuffixLength> THostName8; |
|
1959 const TInt KMaxDomainSearchBufferLength = 4096; |
|
1960 |
|
1961 // Retrieve the total length of the option data content |
|
1962 TPtr8 ptr(aDomainSearchBuf->Des()); |
|
1963 TInt totalLength = 0; |
|
1964 totalLength = aDomainSearchBuf->Length(); |
|
1965 |
|
1966 // Create a buffer of a length capable |
|
1967 // to hold domain search list from the option data |
|
1968 TLex8 primaryLex; |
|
1969 RBuf8 suffixList; |
|
1970 suffixList.CreateL(KMaxDomainSearchBufferLength); |
|
1971 |
|
1972 // To overcome specific limitations of TLex |
|
1973 // Converting all '0's to '@'s in the option data buffer |
|
1974 TInt offset = 0; |
|
1975 THostName8 tmpBuf; |
|
1976 while((offset = ptr.Locate(0)) != KErrNotFound) |
|
1977 { |
|
1978 tmpBuf.Append(ptr.MidTPtr(0, offset)); |
|
1979 tmpBuf.Append('@'); |
|
1980 if (ptr.Length() > (offset +1)) |
|
1981 ptr.Set(ptr.MidTPtr((offset+1))); |
|
1982 else |
|
1983 ptr.SetLength(0); |
|
1984 } |
|
1985 ptr.Set(tmpBuf.MidTPtr(0)); |
|
1986 primaryLex.Assign(ptr.Ptr()); |
|
1987 |
|
1988 |
|
1989 // Creating temporary objects for parsing the buffer |
|
1990 THostName8 domainName; |
|
1991 domainName.SetLength(0); |
|
1992 TInt noOfDomainNames = 0; |
|
1993 TChar ch; |
|
1994 |
|
1995 /* Start of decryption algorithm implementation for the option data buffer |
|
1996 * Synopsis |
|
1997 * Option data contains domain suffixes seaparated by either a '@' or a two-octet compression pointer i.e. C004 (hex) |
|
1998 * which points to offset 4 in the complete aggregated block of Domain Search Option data |
|
1999 * where another validly encoded domain name can be found to complete the name |
|
2000 * Each sub-domain in a domain name is defined by a digit representing number of characters following this digit |
|
2001 */ |
|
2002 for (TInt i=0; i<totalLength; i++) |
|
2003 { |
|
2004 ch = primaryLex.Peek(); |
|
2005 if (ch == 64) // if the character is a '@' |
|
2006 { |
|
2007 // Marks end of a domain name in the list |
|
2008 // add the domainName constructed to a array and initialise it for next domain name parsing |
|
2009 // Inc a counter to keep track of number of domain names retrieved |
|
2010 // Maintain a continous list of the domain name as well for lookup during use of compression pointer |
|
2011 suffixList.Append(ch); |
|
2012 TBuf<KMaxDomainSuffixLength> domainName16; |
|
2013 domainName16.Copy(domainName); |
|
2014 iSuffixList.AppendL(domainName16); |
|
2015 domainName.FillZ(); |
|
2016 domainName.SetLength(0); |
|
2017 primaryLex.Inc(); |
|
2018 noOfDomainNames++; |
|
2019 } |
|
2020 else if (ch < 48) // if the character is a digit |
|
2021 { |
|
2022 // Marks '.' completing a sub-domain and defines the length |
|
2023 // of the next sub-domain in the option data buffer |
|
2024 if (domainName.Length() != 0) |
|
2025 { |
|
2026 suffixList.Append('.'); |
|
2027 domainName.Append('.'); |
|
2028 } |
|
2029 TInt domainPartLength(ch); |
|
2030 suffixList.Append(ptr.Mid(i+1,ch)); |
|
2031 domainName.Append(ptr.Mid(i+1,ch)); |
|
2032 |
|
2033 TInt inc = (TInt)ch + 1; |
|
2034 i+=(TInt)ch; |
|
2035 primaryLex.Inc(inc); |
|
2036 } |
|
2037 else if (ch == 192) // if the character is a hex 0xC0 |
|
2038 { |
|
2039 // Marks start of compression pointer |
|
2040 // Looks up to the suffixList buffer created earlier that holds |
|
2041 // the domain names read until now in contigous sequence |
|
2042 // for extracting the remainder of the sub-domains to complete the domain name |
|
2043 if (domainName.Length() != 0) |
|
2044 { |
|
2045 suffixList.Append('.'); |
|
2046 domainName.Append('.'); |
|
2047 } |
|
2048 i++; |
|
2049 primaryLex.Inc(); |
|
2050 ch = primaryLex.Peek(); |
|
2051 TInt refOffset(ch), actOffset=0; |
|
2052 THostName compressedDomain; |
|
2053 TPtr8 tmpPtr(suffixList.MidTPtr(0)); |
|
2054 TLex8 tmpLex(tmpPtr); |
|
2055 TInt ind=0; |
|
2056 for (; ind < tmpPtr.Length() && actOffset < refOffset; ind++) |
|
2057 { |
|
2058 TChar ch1 = tmpLex.Peek(); |
|
2059 if (ch1 != 46 && ch1 != 64) |
|
2060 actOffset++; |
|
2061 tmpLex.Inc(); |
|
2062 } |
|
2063 tmpPtr.Set(tmpPtr.MidTPtr(ind-1)); |
|
2064 tmpPtr.Set(tmpPtr.MidTPtr(0,tmpPtr.Locate('@'))); |
|
2065 suffixList.Append(tmpPtr); |
|
2066 domainName.Append(tmpPtr); |
|
2067 suffixList.Append('@'); |
|
2068 TBuf<KMaxDomainSuffixLength> domainName16; |
|
2069 domainName16.Copy(domainName); |
|
2070 iSuffixList.AppendL(domainName16); |
|
2071 domainName.FillZ(); |
|
2072 domainName.SetLength(0); |
|
2073 primaryLex.Inc(); |
|
2074 noOfDomainNames++; |
|
2075 } |
|
2076 else |
|
2077 { |
|
2078 // Marks completion of the option data buffer |
|
2079 // Free up memory allocated on the heap |
|
2080 suffixList.Close(); |
|
2081 return; |
|
2082 } |
|
2083 } |
|
2084 // End of decryption algorithm implementation for the option data buffer |
|
2085 } |
|
2086 |
1878 #endif // SYMBIAN_NETWORKING_DHCPSERVER |
2087 #endif // SYMBIAN_NETWORKING_DHCPSERVER |