Extension Negotiation

Overview

Each extension is given an unique id that is decided when it is first registered. We differentiate between two types of packets:

Those that:

TypePurposeExtension id range
HAS_PACKETSintroduce new packets to the protocol0-191
PACKETLESSdon't use and need any packets192-255

Each extension is given one legacy packet id equal to 64+extension_id. For PACKETLESS extensions this would mean that their packet ids are out of spec >255, thus they don't have any. An example for a packetless extension would be OpenSpades' UnicodeExt.

Each extension packet will contain 1 additional byte in its data, which is a subpacket id, used to have multiple packets available for each extension. This is always the case, even if an extension only needs 1 packet in total.

General extension packet structure:

Field nameTypeNotes
Packet idUByte64-255
Sub packet idUByte0-255
DataUByte[]extension data

ExtInfo Packet

  • Packet ID: 60
  • Total size: 2+2*n
Field nameField typeNotes
lengthUBytelength+1 entries will follow
entriesExtInfoEntrysee below

ExtInfoEntry

Field nameField typeNotes
ext. IDUBytesee #Overview
versionUBytestarting at 0

Protocol Flow

The server MUST send an ExtInfo packet on connect. The client can store the list of extensions and MUST reply with an ExtInfo packet that lists the extensions it supports.

It SHOULD omit any extensions that the server does not support from it's reply.