Xfire Protocol Documentation


This is a short try on creating a protocol documentation for xfire.

1. Introduction

Beat Wolf (aka asraniel) has written a very useful and almost complete documentation on the packets of the xfire protocol a while ago on his gfire website.

Although it explained in detail on how to parse each separate packet it lacked to explain a few meanings of common packets.

2. Attribute-based packets

Most xfire packets consist of only attributes - all these attributes are in the same structure and can therefore be parsed in the same way for every packet.

But there are quite a few packets which are not of that sort - i have yet to figure out what they actually mean.

Examples of these packets are the ids: 141 (preference packet), 151, 152, 155, 157, 177, 163, 144 (DID packet?) - i currently simply ignore those packets.

3. Packet layout

After a packet header (5 bytes) which consists of:

  • 1 + 2. bytes total packet length including header
  • 3 byte: zero ?
  • 4 byte: packet type id
  • 5 byte: number of attributes

3.1. Attribute

Every attribute consists of a name and a value:

<attribute name><attribute value>

3.2. Attribute Name

The name consists of it's length, and then the name itself:

<name length (1 byte)><name (length bytes)>

3.3. Attribute Value

The attribute value consists of a byte describing the value type (and it's length) and afterwards the value itself:

<value type (1 byte)><value>

3.3.1. Value types

There are quite a few value types - the most basic i came across are:

  • 1: String
  • 2: short int -> 4 bytes
  • 3: 16 bytes long (sid)
  • 4: Array

See below on how to parse these:

3.3.2. Value type String

For string values you have to read it's length, a zero separator and then the string itself:

<string length 2 bytes> <string>

3.3.3. Value type Array

An array consists again of any value type described above.

<array entry value type (1 byte)> <number of entries (2 bytes)> <attribute values ...>

4. Summary

summed up .. this all looks like:

    <attribute name><attribute value>

attribute name:
    <name length 1 byte><name>

attribute value:
    <value type 1 byte><value>

value type:
    1: string
    2: short int -> 4 byte
    3: sid -> 16 byte
    4: array

value type string:
    <string length 2 bytes> <string>

value type array
    <array entry value type 1 byte> <number of entries 2 bytes> <attribute value>*

5. Example implementation

You can look at the java xfire library i began to write.

Last Modified: 2008-03-02 00:25:51 by Herbert Poul - [ Snip Changes ] [ Wiki History ]


No comments yet.

Please login to create a new thread.

Personal website and blog of Herbert Poul. Also check out my Photo Gallery.

Herby's Photo Gallery



You are not logged in.