Protocols/OSCAR/FLAP: Difference between revisions
No edit summary |
|||
(8 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
{{Protocols/OSCAR}} | {{Protocols/OSCAR}} | ||
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 [[Protocols/OSCAR/SNAC|SNAC]]. | 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 [[Protocols/OSCAR/SNAC|SNAC]]. | ||
Line 32: | Line 31: | ||
|} | |} | ||
=== Class: FLAP__FRAME === | |||
There are several different frame types, with the most common being the DATA frame. | |||
{| class="wikitable" | |||
! 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__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. | |||
{| class="wikitable" | |||
! Name | |||
! Type | |||
! Notes | |||
|- | |||
| header | |||
| [[Protocols/OSCAR/FLAP#FLAP_Header|FLAP Header]] | |||
| FLAP header, type will be FLAP__FRAME_SIGNON | |||
|- | |||
| flapVersion | |||
| uint32 (dword) | |||
| Always 1 | |||
|- | |||
| tlvs | |||
| Array of [[Protocols/OSCAR/TLV|TLV]] length payloadLength-4 | |||
| ''[Class: [[Protocols/OSCAR/Sign_On#TLV_Class:_FLAP_SIGNON_TAGS|FLAP__SIGNON_TAGS]]]'' TLVs | |||
|} | |||
Example in hex: 2a011234000400000001 | |||
== FLAP__FRAME_DATA == | |||
A data frame will always just contain a single [[Protocols/OSCAR/SNAC|SNAC]]. | |||
{| class="wikitable" | |||
! Name | |||
! Type | |||
! Notes | |||
|- | |||
| header | |||
| [[Protocols/OSCAR/FLAP#FLAP_Header|FLAP Header]] | |||
| FLAP header, type will be FLAP__FRAME_KEEP_DATA | |||
|- | |||
| snacHeader | |||
| [[Protocols/OSCAR/SNAC#Datatype:_SNAC_Header|SNAC Header]] | |||
| SNAC header | |||
|- | |||
| snac | |||
| blob | |||
| snac described by the SNAC header | |||
|} | |||
== FLAP__FRAME_ERROR == | |||
{| class="wikitable" | |||
! Name | |||
! Type | |||
! Notes | |||
|- | |||
| header | |||
| [[Protocols/OSCAR/FLAP#FLAP_Header|FLAP Header]] | |||
| FLAP header, type will be FLAP__FRAME_ERROR | |||
|} | |||
== FLAP__FRAME_SIGNOFF == | |||
This FLAP frame type is sent both to the client and server. | |||
* Sent to the client to tell it that it is getting bumped off gracefully. The client should NOT try to auto reconnect if it receives one of these messages. | |||
* Sent to the server by the client to tell it that it is going away gracefully. | |||
{| class="wikitable" | |||
! Name | |||
! Type | |||
! Notes | |||
|- | |||
| header | |||
| [[Protocols/OSCAR/FLAP#FLAP_Header|FLAP Header]] | |||
| FLAP header, type will be FLAP__FRAME_SIGNOFF | |||
|} | |||
== FLAP__FRAME_KEEP_ALIVE == | |||
Many modern operating systems and networks come with firewalls and packet inspectors to protect the user. Unfortunately, these services and devices have proven to be buggy with long lived connections. We recommend that a client sends a FLAP KEEP_ALIVE packet to the server every minute after the connection has gone idle to help keep the connection alive. Please do not send it more often then once a minute or when the connection is not idle. There is no response to this message and a client will never receive a KEEP_ALIVE packet from the server. | |||
{| class="wikitable" | |||
! Name | |||
! Type | |||
! Notes | |||
|- | |||
| header | |||
| [[Protocols/OSCAR/FLAP#FLAP_Header|FLAP Header]] | |||
| FLAP header, type will be FLAP__FRAME_KEEP_ALIVE | |||
|} | |||
=== From Aleksandr Shutko: Basic OSCAR information: FLAP === | |||
<table width=640 cellSpacing=0 cellPadding=0 border=0> | |||
<tr> | |||
<td> | |||
<table width=640 bgcolor=darkblue cellSpacing=0 cellPadding=0 border=0><tr><td> | |||
<table width=100% cellSpacing=2 cellPadding=0 border=0><tr><td bgcolor=#E9E9E9 > | |||
<table width=100% cellSpacing=0 cellPadding=0 bgcolor="#4040FF" border=0> | |||
<tr> | |||
<td><b><font size=2 color="white"> FLAP transport (version 1.0) </font></b></td> | |||
</tr> | |||
</table> | |||
</td></tr> | |||
<tr><td bgcolor=#E9E9E9 > | |||
<table width=100% cellSpacing=0 cellPadding=0 border=0> | |||
<tr><td width=5> </td> | |||
<td><br> | |||
| |||
FLAP is a low-level communications protocol that facilitates the development of | |||
higher-level, datagram-oriented, communications layers. It is used on the TCP | |||
connection between all clients and servers. Here is format of FLAP datagram:<br><br> | |||
<table width=100% cellSpacing=0 cellPadding=0 align=center border=0> | |||
<tr><td width=20></td> | |||
<td> | |||
<table width=400 bgcolor=darkgreen cellSpacing=0 cellPadding=0 border=0><tr><td> | |||
<table width=100% cellSpacing=2 cellPadding=0 border=0><tr><td bgcolor=#fafafa > | |||
<table width=400 cellSpacing=0 cellPadding=0 align=center border=0> | |||
<tr> | |||
<td width=20%> 2A</td> | |||
<td width=5> </td> | |||
<td width=20%>byte</td> | |||
<td width=5> </td> | |||
<td width=65%>FLAP id byte</td> | |||
</tr> | |||
<tr> | |||
<td> xx</td> | |||
<td> </td> | |||
<td>byte</td> | |||
<td> </td> | |||
<td>FLAP channel</td> | |||
</tr> | |||
<tr> | |||
<td> xx xx</td> | |||
<td> </td> | |||
<td>word</td> | |||
<td> </td> | |||
<td>FLAP datagram seq number</td> | |||
</tr> | |||
<tr> | |||
<td> xx xx</td> | |||
<td> </td> | |||
<td>word</td> | |||
<td> </td> | |||
<td>FLAP data size</td> | |||
</tr> | |||
</table> | |||
</td></tr> | |||
<tr><td bgcolor=#fafafa > | |||
<table width=400 cellSpacing=0 cellPadding=0 align=center border=0> | |||
<tr><td height=8 colspan=3></td></tr> | |||
<tr><td width=50> </td> | |||
<td> | |||
<table width=350 bgcolor=darkred cellSpacing=0 cellPadding=0 border=0><tr><td> | |||
<table width=100% cellSpacing=2 cellPadding=0 align=center border=0><tr><td bgcolor=#fafafa > | |||
<table width=350 cellSpacing=0 cellPadding=0 align=center border=0> | |||
<tr> | |||
<td height=50 align=center valign=middle> ......</td> | |||
<td valign=middle width=65%>FLAP data</td> | |||
</tr> | |||
</table> | |||
</td></tr> | |||
</table> | |||
</td></tr></table> | |||
</td><td width=5> </td> | |||
</tr> | |||
<tr><td height=5 colspan=3> </td></tr> | |||
</table> | |||
</td></tr> | |||
</table> | |||
</td></tr></table> | |||
</td></tr> | |||
</table> | |||
<br> | |||
| |||
FLAP id byte is always 0x2A. It is frame-start sign.<br><br> | |||
| |||
The flap sequence numbers used for errors detection. So server can detect problem | |||
when client set flap data size field = 10 and write 20 bytes 0x2A as data. The flap | |||
sequence number origins are picked quite randomly. There is no connection between | |||
the sequence number set from the server and the set from the client. Sequence numbers are | |||
always incremented upward (towards 0x8000) for each command sent. If the sequence number | |||
does reach 0x8000, it will wrap to 0x0000, for obvious reasons. If you start a new connection, | |||
it is recommended that a new sequence number origin is picked for that connection, for purposes | |||
of internal coherency. Sequence numbers are independent of channels: there's a single series | |||
of sequence numbers per TCP connection (per socket).<br><br> | |||
| |||
Channels are the method used to multiplex separate paths of communication across the same | |||
TCP socket. These are analogous to TCP/UDP port numbers. Five channels are currently used | |||
by OSCAR: | |||
<ul> | |||
<li><b>0x01</b> - New Connection Negotiation </li> | |||
<li><b>0x02</b> - [[Protocols/OSCAR/SNAC|SNAC]] data</li> | |||
<li><b>0x03</b> - FLAP-level Error </li> | |||
<li><b>0x04</b> - Close Connection Negotiation </li> | |||
<li><b>0x05</b> - Keep alive</li> | |||
</ul> | |||
| |||
After a new connection (socket) is set up using channel 0x01, data should only be carried | |||
on channel 0x02, until a low-level FLAP error occurs (channel 0x03) or there is planned | |||
termination, which gets "negotiated" (on channel 0x04). Most live events processed during | |||
the lifespan of the client are done over channel 0x02. <b>[[Protocols/OSCAR/SNAC|SNACs]] are | |||
never transmitted on any channel other than 0x02</b><br><br> | |||
| |||
The best way to read an incoming FLAP command is to first read only the starting 6 bytes | |||
(the FLAP headers). From these 6bytes, you can determine how many more bytes you need to | |||
read to complete the command, and how much memory you need to allocate to store it. Never | |||
read more or less than the number of bytes specified in the FLAP headers, or your read will | |||
result in a truncated or uninterpretable command. (If you read too much, you will probably | |||
end up reading the start of the next command, which is bad. Lost data is unacceptable in | |||
the AIM standard.)<br><br> | |||
| |||
Because every command must follow FLAP guidelines, I'd recommend using a low-level routine | |||
to add the FLAP headers (normally, this will be the "flush transmit queue" routine, so that | |||
addition of sequence numbers and the rest of the FLAP headers is done as close timewise as | |||
possible to the command being put on the wire). This is the best way to prevent out-of-order | |||
seqnums from getting used (which, as stated earlier, is quite fatal). <br><br> | |||
</td> | |||
<td width=5></td></tr> | |||
</table> | |||
</td></tr> | |||
</table> | |||
</td></tr></table> | |||
</td> | |||
</tr> | |||
</table> | |||
[[Category:With_Contrib]] | |||
[[Category:Stub]] | [[Category:Stub]] | ||
[[Category:AOL]] | [[Category:AOL]] |
Latest revision as of 10:34, 14 February 2021
OSCAR Protocol |
Introduction • Terms • Clients |
Basic |
Datatypes • FLAP • SNAC • TLV |
UUIDs • Errors • Tool IDs |
Host Interaction |
Rate Limits • Migration • Messages |
Other Services |
ADMIN • ADVERT • ALERT |
BART • BOS • BUCP • CHAT |
CHAT_NAV |
Tutorials |
Sign On • BART • Rendezvous |
ICBM • Locate • Buddies |
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__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
FLAP__FRAME_DATA
A data frame will always just contain a single SNAC.
Name | Type | Notes |
---|---|---|
header | FLAP Header | FLAP header, type will be FLAP__FRAME_KEEP_DATA |
snacHeader | SNAC Header | SNAC header |
snac | blob | snac described by the SNAC header |
FLAP__FRAME_ERROR
Name | Type | Notes |
---|---|---|
header | FLAP Header | FLAP header, type will be FLAP__FRAME_ERROR |
FLAP__FRAME_SIGNOFF
This FLAP frame type is sent both to the client and server.
- Sent to the client to tell it that it is getting bumped off gracefully. The client should NOT try to auto reconnect if it receives one of these messages.
- Sent to the server by the client to tell it that it is going away gracefully.
Name | Type | Notes |
---|---|---|
header | FLAP Header | FLAP header, type will be FLAP__FRAME_SIGNOFF |
FLAP__FRAME_KEEP_ALIVE
Many modern operating systems and networks come with firewalls and packet inspectors to protect the user. Unfortunately, these services and devices have proven to be buggy with long lived connections. We recommend that a client sends a FLAP KEEP_ALIVE packet to the server every minute after the connection has gone idle to help keep the connection alive. Please do not send it more often then once a minute or when the connection is not idle. There is no response to this message and a client will never receive a KEEP_ALIVE packet from the server.
Name | Type | Notes |
---|---|---|
header | FLAP Header | FLAP header, type will be FLAP__FRAME_KEEP_ALIVE |
From Aleksandr Shutko: Basic OSCAR information: FLAP
|