Editing Mod protocol
From EMule Wiki
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. | ||
== Introduction == | == Introduction == | ||
− | |||
− | + | Modprot is needed for more clean protocol extensions by eMule modders.... | |
− | + | The main idea is to set a bit in CT_EMULE_MISCOPTIONS2 in the initial hello. If that bit is set and receive by e eMule mod that is capable of processing extensions then that mod will send the options it is cabpale of in the response. and the first cleitn will also send back the protocol extensions it is capable of. | |
− | + | Important: | |
− | + | Clients that are not capable of processing the mod protocol(like official eMule/amule) will not set the mod bit in CT_EMULE_MISCOPTIONS2 and will never receive extended protocol information. | |
− | All mod communication is to be done over the OP_MODPROT/OP_MODPACKEDPROT | + | == Documentation == |
− | When a hello(answer) with a set mod bit is received | + | All mod communication is to be done over the OP_MODPROT/OP_MODPACKEDPROT, |
− | ConnectionEstablished | + | When a hello(answer) with a set mod bit is received ConnectionEstablished is to be delayed, and instead the mod info packet with the opcode OP_MODINFO is ti be sent, |
+ | ConnectionEstablished is to be triggered when the mod info packet is received. | ||
<pre> | <pre> | ||
A B | A B | ||
− | Hello ---> MB Set (see | + | Hello ---> MB Set (see ModBit is set) |
MB Set <--- Hello Answer | MB Set <--- Hello Answer | ||
ConEst <--- MInfo (Mod Info) | ConEst <--- MInfo (Mod Info) | ||
MInfo ---> ConEst (call ConnectionEstablished) | MInfo ---> ConEst (call ConnectionEstablished) | ||
</pre> | </pre> | ||
− | The mod info packet | + | The mod info packet have to contain eEmuleTags that announces supported features: |
<pre> | <pre> | ||
<uint 32> tag count | <uint 32> tag count | ||
Line 32: | Line 32: | ||
<emule tag n> | <emule tag n> | ||
</pre> | </pre> | ||
− | + | Only mod features are allowed to use that what was announces by both sides, | |
− | + | after the capability exchange all reminding opcodes > 0x01 (0x01 is mod info packet) are allowed to be used by clients in any way they want. | |
All further communication is not part of this specification. | All further communication is not part of this specification. | ||
== Protocol == | == Protocol == | ||
− | |||
− | + | === Hello === | |
+ | |||
+ | Set the modbit ot in in CT_EMULE_MISCOPTIONS2 | ||
in baseclient.cpp, void CUpDownClient::SendHelloTypePacket(CSafeMemFile* data) | in baseclient.cpp, void CUpDownClient::SendHelloTypePacket(CSafeMemFile* data) | ||
Line 69: | Line 70: | ||
</pre> | </pre> | ||
− | === | + | === Process hello. === |
− | + | ||
− | + | ||
baseclient.cpp bool CUpDownClient::ProcessHelloTypePacket(CSafeMemFile* data) | baseclient.cpp bool CUpDownClient::ProcessHelloTypePacket(CSafeMemFile* data) | ||
Line 102: | Line 101: | ||
</pre> | </pre> | ||
− | == | + | ==Send 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) | ||
Line 118: | Line 118: | ||
− | Example of | + | Example of sendmoinfopacket: |
<pre> | <pre> | ||
void CUpDownClient::SendModInfoPacket(){ | void CUpDownClient::SendModInfoPacket(){ | ||
− | if (socket == NULL){ // first we | + | if (socket == NULL){ // first we chack if we have a valid socket, actualy we was called form the socket so this check is rather unnesesery, but in case |
ASSERT(0); | ASSERT(0); | ||
return; | return; | ||
Line 156: | Line 156: | ||
</pre> | </pre> | ||
− | === | + | === delay ConnectionEstablished & send mod info packet === |
listensocket.cpp | listensocket.cpp | ||
− | |||
<pre> | <pre> | ||
+ | bool CClientReqSocket::ProcessPacket(const BYTE* packet, uint32 size, UINT opcode) | ||
+ | { | ||
+ | try | ||
+ | { | ||
+ | try | ||
+ | { | ||
+ | if (!client && opcode != OP_HELLO) | ||
+ | { | ||
+ | theStats.AddDownDataOverheadOther(size); | ||
+ | throw GetResString(IDS_ERR_NOHELLO); | ||
+ | } | ||
+ | else if (client && opcode != OP_HELLO && opcode != OP_HELLOANSWER) | ||
+ | client->CheckHandshakeFinished(); | ||
+ | switch(opcode) | ||
+ | { | ||
case OP_HELLOANSWER: | case OP_HELLOANSWER: | ||
{ | { | ||
Line 171: | Line 185: | ||
// NEO: NMP - [NeoModProt] -- Xanatos --> | // NEO: NMP - [NeoModProt] -- Xanatos --> | ||
− | if(client-> | + | if(client->GetNeoModProtVersion() == 0) |
// 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 <-- Xanatos -- | ||
− | + | ||
− | + | // start secure identification, if | |
− | + | // - we have received OP_EMULEINFO and OP_HELLOANSWER (old eMule) | |
− | + | // - we have received eMule-OP_HELLOANSWER (new eMule) | |
− | + | if (client->GetInfoPacketsReceived() == IP_BOTH) | |
− | + | client->InfoPacketsReceived(); | |
− | + | ||
if (client) | if (client) | ||
{ | { | ||
// NEO: NMP - [NeoModProt] -- Xanatos --> | // NEO: NMP - [NeoModProt] -- Xanatos --> | ||
− | if (client-> | + | if (client->GetNeoModProtVersion()) |
− | client->SendModInfoPacket(); | + | client->SendModInfoPacket(); |
− | else // we | + | else // we will call ConnectionEstablished when we recieve the Mod Info |
− | + | ||
// NEO: NMP END <-- Xanatos -- | // NEO: NMP END <-- Xanatos -- | ||
{ | { | ||
Line 197: | Line 209: | ||
break; | break; | ||
} | } | ||
− | |||
− | |||
− | |||
− | |||
− | |||
case OP_HELLO: | case OP_HELLO: | ||
{ | { | ||
− | [..................] | + | theStats.AddDownDataOverheadOther(size); |
+ | |||
+ | [...........................] | ||
+ | |||
+ | client->SendHelloAnswer(); | ||
if (client) | if (client) | ||
{ | { | ||
// NEO: NMP - [NeoModProt] -- Xanatos --> | // NEO: NMP - [NeoModProt] -- Xanatos --> | ||
− | if(client-> | + | if(client->GetNeoModProtVersion()) |
− | client->SendModInfoPacket(); | + | client->SendModInfoPacket(); |
− | else // we | + | else // we will call ConnectionEstablished when we recieve the Mod Info |
− | + | ||
// NEO: NMP END <-- Xanatos -- | // NEO: NMP END <-- Xanatos -- | ||
client->ConnectionEstablished(); | client->ConnectionEstablished(); | ||
Line 221: | Line 231: | ||
{ | { | ||
// NEO: NMP - [NeoModProt] -- Xanatos --> | // NEO: NMP - [NeoModProt] -- Xanatos --> | ||
− | |||
// we will start the SUI when we recieve the mod info packet | // we will start the SUI when we recieve the mod info packet | ||
+ | if(client->GetNeoModProtVersion() == 0) | ||
// NEO: NMP END <-- Xanatos -- | // NEO: NMP END <-- Xanatos -- | ||
− | |||
− | + | // start secure identification, if | |
− | + | // - we have received eMule-OP_HELLO (new eMule) | |
− | + | if (client->GetInfoPacketsReceived() == IP_BOTH) | |
− | + | client->InfoPacketsReceived(); | |
− | + | ||
if( client->GetKadPort() ) | if( client->GetKadPort() ) | ||
Line 237: | Line 245: | ||
break; | break; | ||
} | } | ||
+ | |||
</pre> | </pre> | ||
− | === | + | === process modinfo packet === |
listensocket.cpp | listensocket.cpp | ||
Line 338: | Line 347: | ||
</pre> | </pre> | ||
− | === | + | === proces mod data example === |
+ | |||
+ | |||
+ | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
Line 367: | Line 358: | ||
<pre> | <pre> | ||
// NEO: NMP - [NeoModProt] -- Xanatos --> | // NEO: NMP - [NeoModProt] -- Xanatos --> | ||
− | |||
case OP_MODPACKEDPROT: | case OP_MODPACKEDPROT: | ||
if (!packet->UnPackPacket()){ | if (!packet->UnPackPacket()){ | ||
Line 387: | Line 377: | ||
try | try | ||
{ | { | ||
− | |||
if (!client) | if (!client) | ||
{ | { | ||
Line 396: | Line 385: | ||
ASSERT_VALID(client); | ASSERT_VALID(client); | ||
− | switch(opcode) | + | switch(opcode) |
{ | { | ||
− | |||
case OP_MODINFOPACKET: | case OP_MODINFOPACKET: | ||
{ | { | ||
Line 405: | Line 393: | ||
theStats.AddDownDataOverheadOther(uRawSize); | theStats.AddDownDataOverheadOther(uRawSize); | ||
− | if(client-> | + | if(client->GetNeoModProtVersion() == 0) |
throw CString(_T("Recieved Neo Mod Info Packet from a cleint whitch doe snot support this feature!")); | throw CString(_T("Recieved Neo Mod Info Packet from a cleint whitch doe snot support this feature!")); | ||
− | |||
client->ProcessModInfoPacket(packet,size); | client->ProcessModInfoPacket(packet,size); | ||
Line 421: | Line 408: | ||
} | } | ||
− | default: | + | default: |
− | + | ||
theStats.AddDownDataOverheadOther(uRawSize); | theStats.AddDownDataOverheadOther(uRawSize); | ||
PacketToDebugLogLine(_T("ModProt"), packet, size, opcode); | PacketToDebugLogLine(_T("ModProt"), packet, size, opcode); | ||
Line 449: | Line 435: | ||
} | } | ||
return true; | return true; | ||
− | + | } | |
// NEO: NMP END <-- Xanatos -- | // NEO: NMP END <-- Xanatos -- | ||
</pre> | </pre> | ||
− | == | + | == backward compatibility == |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
+ | Modstring is still send and replied in hello packet to maintain backward compatibility. However a opcode for modstring will be defined for those who also want to move it to the mod protocol. A mod using the modbit MUST identify itself. (A mod that uses extensions but refuses to identify itslef CAN be considered a bad mod by some antileecher systems) | ||
− | == | + | == OPCODES== |
<pre> | <pre> | ||
− | OP_MODPROT | + | OP_MODPROT 0x57 |
− | OP_MODPACKEDPROT | + | OP_MODPACKEDPROT 0x58 |
OP_MODINFOPACKET 0x01 | OP_MODINFOPACKET 0x01 | ||
</pre> | </pre> | ||
− | == | + | == TAGS defines == |
− | Tags used must be reserved in modprot topic at | + | Tags used must be reserved in modprot topic at emule-project.net. Source must be published withing 3 months for claiming a tag. |
− | + | ||
− | + | A mod can claim only up to 4 tags, BUT with capabilty bit in a tag this should be MORE than enough! If you need more you are dowin something wrong probably. Note that also string tags are available that are not regulated. | |
− | + | only tags in the rage from 0x20 (space) - 0x7e are to be used in this version of modprot. | |
− | + | ||
− | + | ||
− | + | ||
− | + | TODO: add more detailded cescriptoin of these tags. | |
{| style="font-size: 85%; text-align: Left;Border="1"; | {| style="font-size: 85%; text-align: Left;Border="1"; | ||
Line 557: | Line 470: | ||
|MISC_PROTOCOL_EXTENSIONS | |MISC_PROTOCOL_EXTENSIONS | ||
| 'M' 4D | | 'M' 4D | ||
− | | | + | |(etc..) |
− | + | ||
|- | |- | ||
− | | | + | |FILE_STATUS_EXTENSIONS |
− | | ' | + | | 'S' 53 |
− | | | + | |(SCT, ICS, etc..) |
− | + | ||
|- | |- | ||
− | | | + | |NEO_PROTOCOL_EXTENSIONS |
− | | ' | + | |'N' 4E |
− | | | + | |(NatT, NeoXS, etc..) |
− | + | ||
|- | |- | ||
− | | | + | |EMULE_BUDDYID |
| '@' 40 | | '@' 40 | ||
− | | | + | |(for NatT by david xanatos|- |
− | | | + | |
|- | |- | ||
− | | | + | |CT_MOD_VERSION |
− | | ' | + | | 'U' 0x55 |
− | | | + | | Modstring. Modstring MUST be sent either in hello OR Modprotocol (note that sending it in mod protocol is not backward compatible) |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
|- | |- | ||
+ | |||
|} | |} | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
== See also == | == See also == | ||
References to emule protocol... | References to emule protocol... | ||
− |