Ejemplo n.º 1
0
/*
 * sipsdp_src_dest_create()
 *
 * Allocates and initializes a SRC and/or DEST SDP.  If the sdp_info
 * structure has not yet been allocated, it is allocated here.
 *
 * Input:
 *   flags   - bitmask indicating if src and/or dest sdp should be
 *             created
 *
 * Returns: pointer to SIP SDP structure - if successful
 *          NULL                         - failure to allocate storage
 */
void
sipsdp_src_dest_create (const char *peerconnection,
    uint16_t flags, cc_sdp_t **sdp_info)
{

    if (!(*sdp_info)) {
        *sdp_info = sipsdp_info_create();
        if (!(*sdp_info)) {
            return;
        }
    }

    /* Create the SRC and/or DEST SDP */
    if (flags & CCSIP_SRC_SDP_BIT) {
        (*sdp_info)->src_sdp = sipsdp_create(peerconnection);
        if (!((*sdp_info)->src_sdp)) {
            sipsdp_src_dest_free(flags, sdp_info);
            return;
        }
    }

    if (flags & CCSIP_DEST_SDP_BIT) {
        (*sdp_info)->dest_sdp = sipsdp_create(peerconnection);
        if (!((*sdp_info)->dest_sdp)) {
            sipsdp_src_dest_free(flags, sdp_info);
            return;
        }
    }
}
Ejemplo n.º 2
0
/*
 * sipsdp_create_from_buf()
 *
 * Parse buffer into common SDP structure
 *
 * Returns: NULL if non-recoverable error encountered
 *
 */
cc_sdp_t *
sipsdp_create_from_buf (char *buf, uint32_t nbytes, cc_sdp_t *sdp)
{
    const char *fname = "sipsdp_create_from_buf";
    cc_sdp_t *sip_info = NULL;

    if (!buf) {
        return (NULL);
    }

    if (sdp) {
        sip_info = sdp;
    } else {
        sipsdp_src_dest_create(CCSIP_DEST_SDP_BIT | CCSIP_SRC_SDP_BIT,
                               &sip_info);
    }

    if (!sip_info) {
        /*
         * make sure that the src_sdp and dest_sdp are
         * valid as well.
         */
        return (NULL);
    }


    if (sdp_parse(sip_info->dest_sdp, &buf, (uint16_t)nbytes) != SDP_SUCCESS) {
        sipsdp_src_dest_free(CCSIP_DEST_SDP_BIT | CCSIP_SRC_SDP_BIT,
                             &sip_info);
        CCSIP_DEBUG_ERROR(SIP_F_PREFIX"Error parsing SDP\n", fname);
        return (NULL);
    }

    return (sip_info);
}