Protocols/OSCAR/FLAP

From NINA Wiki
Revision as of 21:15, 22 March 2020 by AD (talk | contribs)
Jump to navigation Jump to search
OSCAR Protocol
IntroductionTermsClients
Basic
DatatypesFLAPSNACTLV
UUIDsErrorsTool IDs
Host Interaction
Rate LimitsMigrationMessages
Other Services
ADMINADVERTALERT
BARTBOSBUCPCHAT
CHAT_NAV
Tutorials
Sign OnBARTRendezvous
ICBMLocateBuddies
Foodgroups
OSERVICE (0x0001)
LOCATE (0x0002)
BUDDY (0x0003)
ICBM (0x0004)
ADVERT (0x0005)
INVITE (0x0006)
ADMIN (0x0007)
POPUP (0x0008)
PD (0x0009)
USER_LOOKUP (0x000A)
STATS (0x000B)
TRANSLATE (0x000C)
CHAT_NAV (0x000D)
CHAT (0x000E)
ODIR (0x000F)
BART (0x0010)
FEEDBAG (0x0013)
ICQ (0x0015)
BUCP (0x0017)
ALERT (0x0018)
PLUGIN (0x0022)
UNNAMED_FG_24 (0x0024)
MDIR (0x0025)
ARS (0x044A)


FLAP (Frame Layer Protocol) provides the packet framing on top of TCP or TLS layer for the OSCAR protocol. Each message sent to and from the AIM backend is encapsulated in a FLAP frame that is easily identified using a 6 byte header followed by a variable length data segment. The payload of a FLAP frame is in most cases a SNAC.

FLAP Header

The header contains the frame type, a sequence number, and the length of the following data segment. The sequence number is independently sequential in each direction. Packets from the server to client have one sequence number, while the packets from the client to server have a different independently increasing number.

If the server receives a sequence number out of order it will terminate the connection. A common mistake is to use a uint8 (byte) to represent the sequence number, which will roll over at 255 and cause the server to disconnect the client.

Name Type Notes
FLAP__MARKER uint8 (byte) ASTERISK (literal ASCII "*")
FLAP__FRAME uint8 (byte) Class: FLAP__FRAME_TYPE
FLAP__SEQUENCE uint16 (word) Initialized to a random value, increments for each send
FLAP__LENGTH uint16 (word) Length of data, does not include the 6 byte header length

Class: FLAP__FRAME

There are several different frame types, with the most common being the DATA frame.

Name Value Notes
FLAP__FRAME_SIGNON 0x01 Initialize the FLAP connection
FLAP__FRAME_DATA 0x02 Messages using the FLAP connection, usually a SNAC message
FLAP__FRAME_ERROR 0x03 A FLAP error - rare
FLAP__FRAME_SIGNOFF 0x04 Close down the FLAP connection gracefully
FLAP__FRAME_KEEP_ALIVE 0x05 Send a heartbeat to server to help keep connection open

FLAP: FLAP__FRAME_SIGNON

On connection, the server and client each send a FLAP SIGNON frame to initialize the connection. The sequence number field should be initialized with a random value. The data portion of the frame contains a 4 byte version number, currently always 1, followed by any TLVs that are required.

Name Type Notes
header FLAP Header FLAP header, type will be FLAP__FRAME_SIGNON
flapVersion uint32 (dword) Always 1
tlvs Array of TLV length payloadLength-4 [Class: FLAP__SIGNON_TAGS] TLVs

Example in hex: 2a011234000400000001