Example #1
0
static void
peer_proxy_send(PeerConnection *conn, ProxyFrame *frame)
{
	size_t length;
	ByteStream bs;

	purple_debug_info("oscar", "Outgoing peer proxy frame with "
			"type=0x%04hx, unknown=0x%08x, "
			"flags=0x%04hx, and payload length=%hd\n",
			frame->type, frame->unknown,
			frame->flags, frame->payload.len);

	length = 12 + frame->payload.len;
	byte_stream_new(&bs, length);
	byte_stream_put16(&bs, length - 2);
	byte_stream_put16(&bs, PEER_PROXY_PACKET_VERSION);
	byte_stream_put16(&bs, frame->type);
	byte_stream_put32(&bs, frame->unknown);
	byte_stream_put16(&bs, frame->flags);
	byte_stream_putraw(&bs, frame->payload.data, frame->payload.len);

	peer_connection_send(conn, &bs);

	byte_stream_destroy(&bs);
}
Example #2
0
File: odc.c Project: VoxOx/VoxOx
/**
 * Write the given OdcFrame to a ByteStream and send it out
 * on the established PeerConnection.
 */
static void
peer_odc_send(PeerConnection *conn, OdcFrame *frame)
{
    GaimAccount *account;
    const char *username;
    size_t length;
    ByteStream bs;

    gaim_debug_info("oscar", "Outgoing ODC frame to %s with "
                    "type=0x%04x, flags=0x%04x, payload length=%u\n",
                    conn->sn, frame->type, frame->flags, frame->payload.len);

    account = gaim_connection_get_account(conn->od->gc);
    username = gaim_account_get_username(account);
    memcpy(frame->sn, username, strlen(username));
    memcpy(frame->cookie, conn->cookie, 8);

    length = 76;
    byte_stream_new(&bs, length + frame->payload.len);
    byte_stream_putraw(&bs, conn->magic, 4);
    byte_stream_put16(&bs, length);
    byte_stream_put16(&bs, frame->type);
    byte_stream_put16(&bs, frame->subtype);
    byte_stream_put16(&bs, 0x0000);
    byte_stream_putraw(&bs, frame->cookie, 8);
    byte_stream_put16(&bs, 0x0000);
    byte_stream_put16(&bs, 0x0000);
    byte_stream_put16(&bs, 0x0000);
    byte_stream_put16(&bs, 0x0000);
    byte_stream_put32(&bs, frame->payload.len);
    byte_stream_put16(&bs, 0x0000);
    byte_stream_put16(&bs, frame->encoding);
    byte_stream_put16(&bs, 0x0000);
    byte_stream_put16(&bs, frame->flags);
    byte_stream_put16(&bs, 0x0000);
    byte_stream_put16(&bs, 0x0000);
    byte_stream_putraw(&bs, frame->sn, 32);
    byte_stream_putraw(&bs, frame->payload.data, frame->payload.len);

    peer_connection_send(conn, &bs);

    g_free(bs.data);
}