EC Protocol HOWTO

From AMule Project FAQ
Revision as of 17:14, 21 August 2007 by 87.139.115.64 (Talk)

Jump to: navigation, search

Basic Protocol Structure


Future Changes Future changes of the EC protocol (probably after 2.2.0) may be:

  • no more \0 for string termination
  • last bit of flag byte indicates a following flag byte, and so on

Examples

This is a packet in hex values that is send to aMule for authorization:

00 00 00 22 //flag
00 00 00 36 //packet body length 54
02      //EC_OP_AUTH_REQ
04      //tag count

c8 80          //EC_TAG_CLIENT_NAME
06             //EC_TAGTYPE_STRING
0d             //value length 13
61 6d 75 6c 65 2d 72 65 6d 6f 74 65 00 //"amule-remote\0"

c8 82          //EC_TAG_CLIENT_VERSION
06             //EC_TAGTYPE_STRING
07             //value length 7
30 78 30 30 30 31 00 // "0x0001\0"

04             //EC_TAG_PROTOCOL_VERSION
03             //EC_TAGTYPE_UINT16
02             //value length 2
02 00          //value is defined by EC_CURRENT_PROTOCOL_VERSION

02              //EC_TAG_PASSWD_HASH
09             //EC_TAGTYPE_HASH16
10             //value length 16
47 bc e5 c7 4f 58 9f 48 //md5 hashed password string
67 db d5 7e 9c a9 f8 08 //password "aaa" was used

c8 80 is in fact an utf8 encoded number. It decodes to 02 00 (or 512 in decimal).
As every tag code, it is shifted one bit to left to fit in a bit that indicates the presence of subtags.
The lowest bit of 02 00 is 0; so this tag doesn't have subtags.
When we shift the value to the right one bit (or divide by 2), we get 01 00.
That's the value that can be found in ECCodes.h.