예제 #1
0
int aries_ipc_fmt_client_send(struct ipc_client *client, struct ipc_message_info *request)
{
    struct ipc_header reqhdr;
    void *data;
    int rc = 0;

    reqhdr.mseq = request->mseq;
    reqhdr.aseq = request->aseq;
    reqhdr.group = request->group;
    reqhdr.index = request->index;
    reqhdr.type = request->type;
    reqhdr.length = (uint16_t) (request->length + sizeof(struct ipc_header));

    data = malloc(reqhdr.length);

    memcpy(data, &reqhdr, sizeof(struct ipc_header));
    memcpy((unsigned char *) (data + sizeof(struct ipc_header)), request->data, request->length);

    assert(client->handlers->write != NULL);

    ipc_client_log_send(client, request, __func__);

    rc = client->handlers->write(data, reqhdr.length, client->handlers->write_data);
    return rc;
}
int xmm626_sec_modem_rfs_send(struct ipc_client *client,
    struct ipc_message *message)
{
    struct ipc_rfs_header header;
    void *buffer;
    size_t length;
    size_t count;
    unsigned char *p;
    int rc;

    if (client == NULL || client->handlers == NULL || client->handlers->write == NULL || message == NULL)
        return -1;

    ipc_rfs_header_setup(&header, message);

    length = header.length;
    buffer = calloc(1, length);

    memcpy(buffer, &header, sizeof(struct ipc_rfs_header));
    if (message->data != NULL && message->size > 0)
        memcpy((void *) ((unsigned char *) buffer + sizeof(struct ipc_rfs_header)), message->data, message->size);

    ipc_client_log_send(client, message, __func__);

    p = (unsigned char *) buffer;

    count = 0;
    while (count < length) {
        rc = client->handlers->write(client->handlers->transport_data, p, length - count);
        if (rc <= 0) {
            ipc_client_log(client, "Writing RFS data failed");
            goto error;
        }

        count += rc;
        p += rc;
    }

    rc = 0;
    goto complete;

error:
    rc = -1;

complete:
    if (buffer != NULL)
        free(buffer);

    return rc;
}
예제 #3
0
int aries_ipc_rfs_client_send(struct ipc_client *client, struct ipc_message_info *request)
{
    struct rfs_hdr *rfs_hdr;
    void *data;
    int rc = 0;

    data = malloc(request->length + sizeof(struct rfs_hdr));
    memset(data, 0, request->length + sizeof(struct rfs_hdr));

    rfs_hdr = (struct rfs_hdr *) data;

    rfs_hdr->id = request->mseq;
    rfs_hdr->cmd = request->index;
    rfs_hdr->len = request->length + sizeof(struct rfs_hdr);

    memcpy((void *) (data + sizeof(struct rfs_hdr)), request->data, request->length);

    assert(client->handlers->write != NULL);

    ipc_client_log_send(client, request, __func__);

    rc = client->handlers->write((uint8_t*) data, rfs_hdr->len, client->handlers->write_data);
    return rc;
}