comparison libgaim/protocols/oscar/flap_connection.c @ 15088:25c3a33c6485

[gaim-migrate @ 17874] Add a flap_connection_send_snac() helper function that makes it a little easier/cleaner to send a SNAC-based FLAP command. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Sat, 02 Dec 2006 09:44:53 +0000
parents eed75cc6cb88
children 033e1604cf63
comparison
equal deleted inserted replaced
15087:337dfc40a538 15088:25c3a33c6485
49 byte_stream_put32(&frame->data, 0x00000001); 49 byte_stream_put32(&frame->data, 0x00000001);
50 flap_connection_send(conn, frame); 50 flap_connection_send(conn, frame);
51 } 51 }
52 52
53 /** 53 /**
54 * This sends a channel 1 SNAC containing the FLAP version and 54 * This sends a channel 1 FLAP containing the FLAP version and
55 * the authentication cookie. This is sent when connecting to 55 * the authentication cookie. This is sent when connecting to
56 * any FLAP server after the initial connection to the auth 56 * any FLAP server after the initial connection to the auth
57 * server. It is always the very first packet sent by both the 57 * server. It is always the very first packet sent by both the
58 * server and the client after the SYN, SYN/ACK, ACK handshake. 58 * server and the client after the SYN, SYN/ACK, ACK handshake.
59 */ 59 */
71 71
72 flap_connection_send(conn, frame); 72 flap_connection_send(conn, frame);
73 } 73 }
74 74
75 /** 75 /**
76 * This sends an empty channel 4 SNAC. This is sent to signify 76 * This sends a channel 2 FLAP containing a SNAC. The SNAC family and
77 * subtype are looked up in the rate info for this connection, and if
78 * sending this SNAC will induce rate limiting then we delay sending
79 * of the SNAC by putting it into an outgoing holding queue.
80 */
81 void
82 flap_connection_send_snac(OscarData *od, FlapConnection *conn, guint16 family, guint16 subtype, guint16 flags, aim_snacid_t snacid, ByteStream *data)
83 {
84 FlapFrame *frame;
85 guint32 length;
86
87 length = data != NULL ? data->offset : 0;
88
89 frame = flap_frame_new(od, 0x02, 10 + length);
90 aim_putsnac(&frame->data, family, subtype, flags, snacid);
91
92 if (length > 0)
93 {
94 byte_stream_rewind(data);
95 byte_stream_putbs(&frame->data, data, length);
96 }
97
98 /* TODO: Outgoing message throttling */
99
100 flap_connection_send(conn, frame);
101 }
102
103 /**
104 * This sends an empty channel 4 FLAP. This is sent to signify
77 * that we're logging off. This shouldn't really be necessary-- 105 * that we're logging off. This shouldn't really be necessary--
78 * usually the AIM server will detect that the TCP connection has 106 * usually the AIM server will detect that the TCP connection has
79 * been destroyed--but it's good practice. 107 * been destroyed--but it's good practice.
80 */ 108 */
81 static void 109 static void
86 frame = flap_frame_new(od, 0x04, 0); 114 frame = flap_frame_new(od, 0x04, 0);
87 flap_connection_send(conn, frame); 115 flap_connection_send(conn, frame);
88 } 116 }
89 117
90 /** 118 /**
91 * This sends an empty channel 5 SNAC. This is used as a keepalive 119 * This sends an empty channel 5 FLAP. This is used as a keepalive
92 * packet in FLAP connections. WinAIM 4.x and higher send these 120 * packet in FLAP connections. WinAIM 4.x and higher send these
93 * _every minute_ to keep the connection alive. 121 * _every minute_ to keep the connection alive.
94 */ 122 */
95 void 123 void
96 flap_connection_send_keepalive(OscarData *od, FlapConnection *conn) 124 flap_connection_send_keepalive(OscarData *od, FlapConnection *conn)