Changes between Version 5 and Version 6 of MapGuideRfc118


Ignore:
Timestamp:
Jul 4, 2011, 2:28:12 AM (13 years ago)
Author:
wuma
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • MapGuideRfc118

    v5 v6  
    111111}}}
    112112
     113 5. '''Change the way encoding Site IpAddress into SessionId'''
     114MapGuide Server encodes the IP address of site server into the Session Id so that it could pick the right site server from the list by comparing the IP address.
     115The encoding logic currently is: '''{{{(INTERNAL_API)}}}'''
     116{{{
     117STRING MgSiteInfo::ToHexString()
     118{
     119    STRING hexString;
     120    UINT32 n1, n2, n3, n4;
     121    wchar_t buffer[30];
     122    if (4 == ::swscanf(m_target.c_str(), L"%u.%u.%u.%u", &n1, &n2, &n3, &n4))
     123    {
     124        swprintf(buffer, 30, L"%.2X%.2X%.2X%.2X%.4X%.4X%.4X", n1, n2, n3, n4,
     125                 m_sitePort, m_clientPort, m_adminPort);
     126        hexString = buffer;
     127    }
     128
     129    return hexString;
     130}
     131}}}
     132Then it works for only IPv4. And for IPv6, because the valid format is really complicated, then convert it to a hex string is difficult.
     133The solution is: encode the IP as Base64 string. The port numbers will still be converted to hex string so that they could be easily decoded.
     134Then the new method will be like:
     135{{{
     136STRING MgSiteInfo::ToHexString()
     137{
     138    STRING hexString;
     139   
     140    char buf[100] = {0};
     141    char* target = ACE_Wide_To_Ascii(m_target.c_str()).char_rep();
     142    Base64::Encode(buf, (unsigned char*)target, (unsigned long)strlen(target));
     143   
     144    wchar_t buffer[100] = {0}; 
     145    swprintf(buffer, L"%s%.4X%.4X%.4X", ACE_Ascii_To_Wide(buf).wchar_rep(),     
     146             m_sitePort, m_clientPort, m_adminPort);
     147    hexString = buffer;
     148
     149    return hexString;
     150}
     151}}}
     152One thing that needs attention is: A Base64 string might have “=” appended at the end for alignment. But “=” is treated as a reserved character. The solutions is: we remove all appending “=” when doing encoding, and then append them back when doing decoding
     153
    113154== Implications ==
    114 
     155Since it just makes MGOS work with IPv6, it doesn't change any existing functions.
    115156
    116157
    117158== Test Plan ==
    118 
     159Since it doesn't change any existing functions, so no new test cases need be added. 
    119160
    120161