Exemple #1
0
SmlPcdataPtr_t convert_to_meta(char * format,
                               char * type)
{
    SmlPcdataPtr_t metaP = NULL;
    SmlMetInfMetInfPtr_t metInfP;

    if (format == NULL && type == NULL)
    {
        return NULL;
    }

    metInfP = smlAllocMetInfMetInf();
    if (!metInfP) return NULL;

    if (type) metInfP->type = smlString2Pcdata(type);
    if (format) metInfP->format = smlString2Pcdata(format);

    metaP = smlAllocPcdata();
    if (!metaP)
    {
        smlFreeMetinfMetinf(metInfP);
        return NULL;
    }
    metaP->contentType = SML_PCDATA_EXTENSION;
    metaP->extension = SML_EXT_METINF;
    metaP->length = 0;
    metaP->content = metInfP;

    return metaP;
}
Exemple #2
0
SmlPcdataPtr_t create_chal_meta(dmclt_authType_t type,
                                buffer_t * nonceP)
{
    SmlMetInfMetInfPtr_t metInfP;
    SmlPcdataPtr_t metaP;

    metInfP = smlAllocMetInfMetInf();
    if (!metInfP) return NULL;

    metInfP->type = smlString2Pcdata(auth_type_as_string(type));
    metInfP->format = smlString2Pcdata("b64");
    if (nonceP)
    {
        char * tmp = encode_b64(*nonceP);
        metInfP->nextnonce = smlString2Pcdata(tmp);
        free(tmp);
    }

    metaP = smlAllocPcdata();
    if (!metaP)
    {
        smlFreeMetinfMetinf(metInfP);
        return NULL;
    }
    metaP->contentType = SML_PCDATA_EXTENSION;
    metaP->extension = SML_EXT_METINF;
    metaP->length = 0;
    metaP->content = metInfP;

    return metaP;
 }
Exemple #3
0
static int prv_fill_item(SmlItemPtr_t itemP,
                         dmtree_node_t node)
{
    itemP->source = smlAllocSource();
    if (!itemP->source)
    {
        return OMADM_SYNCML_ERROR_COMMAND_FAILED;
    }
    smlFreePcdata(itemP->source->locURI);
    itemP->source->locURI = smlString2Pcdata(node.uri);
    if (node.data_buffer)
    {
        itemP->data = smlAllocPcdata();
        if (!itemP->data)
        {
            return OMADM_SYNCML_ERROR_COMMAND_FAILED;
        }
        itemP->data->content = malloc(node.data_size);
        if (!itemP->data->content)
        {
            return OMADM_SYNCML_ERROR_COMMAND_FAILED;
        }
        memcpy(itemP->data->content, node.data_buffer, node.data_size);
        itemP->data->contentType = SML_PCDATA_OPAQUE;
        itemP->data->length = node.data_size;
    }
    itemP->meta = convert_to_meta(node.format, node.type);

    return OMADM_SYNCML_ERROR_SUCCESS;
}
static void prvCreatePacket1(internals_t * internP)
{
    // this is the beginning of the session
    SmlAlertPtr_t   alertP;

    alertP = smlAllocAlert();
    if (alertP)
    {
        SmlReplacePtr_t replaceP;

        switch(internP->state)
        {
        case STATE_CLIENT_INIT:
            alertP->data = smlString2Pcdata("1201");
            break;
        case STATE_SERVER_INIT:
            alertP->data = smlString2Pcdata("1200");
            break;
        default:
            smlFreeProtoElement((basicElement_t *)alertP);
            return;
        }
        smlFreeItemList(alertP->itemList);
        alertP->itemList = NULL;

        replaceP = get_device_info(internP);
        if (replaceP)
        {
            add_element(internP, (basicElement_t *)alertP);
            add_element(internP, (basicElement_t *)replaceP);
            internP->state = STATE_IN_SESSION;
        }
        else
        {
            smlFreeProtoElement((basicElement_t *)alertP);
        }
    }
}
static SmlSyncHdrPtr_t prvGetHeader(internals_t * internP)
{
    SmlSyncHdrPtr_t headerP;

    headerP = smlAllocSyncHdr();
    if (headerP)
    {
        set_pcdata_string(headerP->version, "1.2");
        set_pcdata_string(headerP->proto, "DM/1.2");
        set_pcdata_hex(headerP->sessionID, internP->session_id);
        set_pcdata_int(headerP->msgID, internP->message_id);
        set_pcdata_int(headerP->msgID, internP->message_id);
        set_pcdata_string(headerP->target->locURI, internP->account->server_uri);
        set_pcdata_string(headerP->source->locURI, internP->account->id);
        if (OMADM_SYNCML_ERROR_AUTHENTICATION_ACCEPTED != internP->clt_auth)
        {
            headerP->cred = get_credentials(internP->account->toServerCred);
        }
        headerP->meta = smlAllocPcdata();
        if (headerP->meta)
        {
            SmlMetInfMetInfPtr_t metInfP;

            metInfP = smlAllocMetInfMetInf();
            if (metInfP)
            {
                metInfP->maxmsgsize = smlString2Pcdata(PRV_MAX_MESSAGE_SIZE);
                headerP->meta->contentType = SML_PCDATA_EXTENSION;
                headerP->meta->extension = SML_EXT_METINF;
                headerP->meta->length = 0;
                headerP->meta->content = metInfP;
            }
            else
            {
                smlFreePcdata(headerP->meta);
                headerP->meta = NULL;
            }
        }

    }

    return headerP;
}
dmclt_err_t omadmclient_add_generic_alert(dmclt_session sessionH,
										  char * correlator,
                                          dmclt_item_t * itemP)
{
    internals_t * internP = (internals_t *)sessionH;
    SmlAlertPtr_t alertP;
    
    if (!internP || !itemP || !itemP->type || !itemP->format || !itemP->data)
    {
        return DMCLT_ERR_USAGE;
    }

    alertP = smlAllocAlert();
    if (NULL == alertP)
    {
        return DMCLT_ERR_MEMORY;
    }
    
    alertP->data = smlString2Pcdata("1226");
    if (NULL == alertP->data)
    {
        smlFreeAlert(alertP);
        return DMCLT_ERR_MEMORY;
    }

    if (correlator)
    {
        alertP->correlator = smlString2Pcdata(correlator);
        if (NULL == alertP->correlator)
        {
            smlFreeAlert(alertP);
            return DMCLT_ERR_MEMORY;
        }
    }

    if (itemP->source)
    {
        alertP->itemList->item->source = smlAllocSource();
        if (NULL == alertP->itemList->item->source)
        {
            smlFreeAlert(alertP);
            return DMCLT_ERR_MEMORY;
        }
        alertP->itemList->item->source->locURI = smlString2Pcdata(itemP->source);
    }
    
    if (itemP->target)
    {
        alertP->itemList->item->target = smlAllocTarget();
        if (NULL == alertP->itemList->item->target)
        {
            smlFreeAlert(alertP);
            return DMCLT_ERR_MEMORY;
        }
        alertP->itemList->item->target->locURI = smlString2Pcdata(itemP->target);
    }

    alertP->itemList->item->meta = convert_to_meta(itemP->format, itemP->type);
    alertP->itemList->item->data = smlString2Pcdata(itemP->data);
    if (NULL == alertP->itemList->item->meta || NULL == alertP->itemList->item->data)
    {
        smlFreeAlert(alertP);
        return DMCLT_ERR_MEMORY;
    }

    add_element(internP, (basicElement_t *)alertP);

    return DMCLT_ERR_NONE;
}