comparison src/protocols/oscar/rxqueue.c @ 13254:e9802db22b06

[gaim-migrate @ 15620] This is the way we clean the code, clean the code, clean the code This is the way we clean the code, clean the code, clean the code So early in the morning committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Sun, 12 Feb 2006 22:14:38 +0000
parents f260d319bbbc
children b08f8f3c9197
comparison
equal deleted inserted replaced
13253:87a7c3077c19 13254:e9802db22b06
119 * 0x02 | Sequence number, 2 bytes. 119 * 0x02 | Sequence number, 2 bytes.
120 * 0x04 | Number of data bytes that follow, 2 bytes. 120 * 0x04 | Number of data bytes that follow, 2 bytes.
121 */ 121 */
122 aim_bstream_init(&hdr, hdr_raw, sizeof(hdr_raw)); 122 aim_bstream_init(&hdr, hdr_raw, sizeof(hdr_raw));
123 if (aim_bstream_recv(&hdr, conn->fd, 6) < 6) { 123 if (aim_bstream_recv(&hdr, conn->fd, 6) < 6) {
124 aim_conn_close(conn); 124 aim_conn_close(sess, conn);
125 return -1; 125 return -1;
126 } 126 }
127 127
128 aim_bstream_rewind(&hdr); 128 aim_bstream_rewind(&hdr);
129 129
131 * This shouldn't happen unless the socket breaks, the server breaks, 131 * This shouldn't happen unless the socket breaks, the server breaks,
132 * or we break. We must handle it just in case. 132 * or we break. We must handle it just in case.
133 */ 133 */
134 if (aimbs_get8(&hdr) != 0x2a) { 134 if (aimbs_get8(&hdr) != 0x2a) {
135 gaim_debug_misc("oscar", "Invalid FLAP frame received on FLAP connection!"); 135 gaim_debug_misc("oscar", "Invalid FLAP frame received on FLAP connection!");
136 aim_conn_close(conn); 136 aim_conn_close(sess, conn);
137 return -1; 137 return -1;
138 } 138 }
139 139
140 fr->hdr.flap.channel = aimbs_get8(&hdr); 140 fr->hdr.flap.channel = aimbs_get8(&hdr);
141 fr->hdr.flap.seqnum = aimbs_get16(&hdr); 141 fr->hdr.flap.seqnum = aimbs_get16(&hdr);
142 142
143 return aimbs_get16(&hdr); 143 return aimbs_get16(&hdr);
144 } 144 }
145 145
146 /* 146 /*
147 * Read a rendezvous header from conn into fr, and return the number of 147 * Read a rendezvous header from conn into fr, and return the number of
148 * bytes in the payload. 148 * bytes in the payload.
149 * 149 *
150 * @return -1 on error, otherwise return the length of the payload. 150 * @return -1 on error, otherwise return the length of the payload.
151 */ 151 */
152 static int aim_get_command_rendezvous(OscarSession *sess, OscarConnection *conn, FlapFrame *fr) 152 static int aim_get_command_rendezvous(OscarSession *sess, OscarConnection *conn, FlapFrame *fr)
159 /* 159 /*
160 * Read rendezvous header 160 * Read rendezvous header
161 */ 161 */
162 aim_bstream_init(&hdr, hdr_raw, sizeof(hdr_raw)); 162 aim_bstream_init(&hdr, hdr_raw, sizeof(hdr_raw));
163 if (aim_bstream_recv(&hdr, conn->fd, 8) < 8) { 163 if (aim_bstream_recv(&hdr, conn->fd, 8) < 8) {
164 aim_conn_close(conn); 164 aim_conn_close(sess, conn);
165 return -1; 165 return -1;
166 } 166 }
167 167
168 aim_bstream_rewind(&hdr); 168 aim_bstream_rewind(&hdr);
169 169
203 203
204 if (!(fr = (FlapFrame *)calloc(sizeof(FlapFrame), 1))) 204 if (!(fr = (FlapFrame *)calloc(sizeof(FlapFrame), 1)))
205 return -ENOMEM; 205 return -ENOMEM;
206 206
207 /* 207 /*
208 * Rendezvous (client to client) connections do not speak FLAP, so this 208 * Rendezvous (client to client) connections do not speak FLAP, so this
209 * function will break on them. 209 * function will break on them.
210 */ 210 */
211 if (conn->type == AIM_CONN_TYPE_RENDEZVOUS) 211 if (conn->type == AIM_CONN_TYPE_RENDEZVOUS)
212 payloadlen = aim_get_command_rendezvous(sess, conn, fr); 212 payloadlen = aim_get_command_rendezvous(sess, conn, fr);
213 else if (conn->type == AIM_CONN_TYPE_LISTENER) { 213 else if (conn->type == AIM_CONN_TYPE_LISTENER) {
233 aim_bstream_init(&fr->data, payload, payloadlen); 233 aim_bstream_init(&fr->data, payload, payloadlen);
234 234
235 /* read the payload */ 235 /* read the payload */
236 if (aim_bstream_recv(&fr->data, conn->fd, payloadlen) < payloadlen) { 236 if (aim_bstream_recv(&fr->data, conn->fd, payloadlen) < payloadlen) {
237 aim_frame_destroy(fr); /* free's payload */ 237 aim_frame_destroy(fr); /* free's payload */
238 aim_conn_close(conn); 238 aim_conn_close(sess, conn);
239 return -1; 239 return -1;
240 } 240 }
241 } else 241 } else
242 aim_bstream_init(&fr->data, NULL, 0); 242 aim_bstream_init(&fr->data, NULL, 0);
243 243