示例#1
0
/**
 * Create and send a Multimedia-Authentication-Request and returns the parsed Answer structure.
 * This function retrieves authentication vectors from the HSS.
 * @param msg - the SIP message to send for
 * @parma public_identity - the public identity of the user
 * @param private_identity - the private identity of the user
 * @param count - how many authentication vectors to ask for
 * @param algorithm - for which algorithm
 * @param authorization - the authorization value
 * @param server_name - local name of the S-CSCF to save on the HSS
 * @returns the parsed maa struct
 */
int cxdx_send_mar(struct sip_msg *msg, str public_identity, str private_identity,
        unsigned int count, str algorithm, str authorization, str server_name, saved_transaction_t* transaction_data) {
    AAAMessage *mar = 0;
    AAASession *session = 0;

    session = cdpb.AAACreateSession(0);

    mar = cdpb.AAACreateRequest(IMS_Cx, IMS_MAR, Flag_Proxyable, session);
    if (session) {
        cdpb.AAADropSession(session);
        session = 0;
    }
    if (!mar) goto error1;

    if (cxdx_dest_host.len > 0) {
       if (!cxdx_add_destination_host(mar, cxdx_dest_host)) goto error1;
    }

    if (!cxdx_add_destination_realm(mar, cxdx_dest_realm)) goto error1;

    if (!cxdx_add_vendor_specific_appid(mar, IMS_vendor_id_3GPP, IMS_Cx, 0 /*IMS_Cx*/)) goto error1;
    if (!cxdx_add_auth_session_state(mar, 1)) goto error1;

    if (!cxdx_add_public_identity(mar, public_identity)) goto error1;
    if (!cxdx_add_user_name(mar, private_identity)) goto error1;
    if (!cxdx_add_sip_number_auth_items(mar, count)) goto error1;
    if (algorithm.len == auth_scheme_types[AUTH_HTTP_DIGEST_MD5].len &&
            strncasecmp(algorithm.s, auth_scheme_types[AUTH_HTTP_DIGEST_MD5].s, algorithm.len) == 0) {
        if (!cxdx_add_sip_auth_data_item_request(mar, algorithm, authorization, private_identity, cxdx_dest_realm,
                msg->first_line.u.request.method, server_name)) goto error1;
    } else {
        if (!cxdx_add_sip_auth_data_item_request(mar, algorithm, authorization, private_identity, cxdx_dest_realm,
                msg->first_line.u.request.method, s_empty)) goto error1;
    }
    if (!cxdx_add_server_name(mar, server_name)) goto error1;

    if (cxdx_forced_peer.len)
        cdpb.AAASendMessageToPeer(mar, &cxdx_forced_peer, (void*) async_cdp_callback, (void*) transaction_data);
    else
        cdpb.AAASendMessage(mar, (void*) async_cdp_callback, (void*) transaction_data);


    LM_DBG("Successfully sent async diameter\n");

    return 0;

error1: //Only free MAR IFF is has not been passed to CDP
    if (mar) cdpb.AAAFreeMessage(&mar);
    LM_ERR("Error occurred trying to send MAR\n");
    return -1;
}
示例#2
0
/**
 * Create and send a Server-Assignment-Request and returns the Answer received for it.
 * This function performs the Server Assignment operation.
 * @param msg - the SIP message to send for
 * @parma public_identity - the public identity of the user
 * @param server_name - local name of the S-CSCF to save on the HSS
 * @param assignment_type - type of the assignment
 * @param data_available - if the data is already available
 * @returns the SAA
 */
int cxdx_send_sar(struct sip_msg *msg, str public_identity, str private_identity,
        str server_name, int assignment_type, int data_available, saved_transaction_t* transaction_data) {
    AAAMessage *sar = 0;
    AAASession *session = 0;
    unsigned int hash = 0, label = 0;
    struct hdr_field *hdr;

    session = cdpb.AAACreateSession(0);

    sar = cdpb.AAACreateRequest(IMS_Cx, IMS_SAR, Flag_Proxyable, session);
    if (session) {
        cdpb.AAADropSession(session);
        session = 0;
    }
    if (!sar) goto error1;

    if (send_vs_callid_avp)
		if (!cxdx_add_call_id(sar, cscf_get_call_id(msg, &hdr))) goto error1;
    if (!cxdx_add_destination_realm(sar, cxdx_dest_realm)) goto error1;

    if (!cxdx_add_vendor_specific_appid(sar, IMS_vendor_id_3GPP, IMS_Cx, 0 /*IMS_Cx*/)) goto error1;
    if (!cxdx_add_auth_session_state(sar, 1)) goto error1;

    if (!cxdx_add_public_identity(sar, public_identity)) goto error1;
    if (!cxdx_add_server_name(sar, server_name)) goto error1;
    if (private_identity.len)
        if (!cxdx_add_user_name(sar, private_identity)) goto error1;
    if (!cxdx_add_server_assignment_type(sar, assignment_type)) goto error1;
    if (!cxdx_add_userdata_available(sar, data_available)) goto error1;

    if (msg && tmb.t_get_trans_ident(msg, &hash, &label) < 0) {
        // it's ok cause we can call this async with a message for ul callbacks!
        LM_DBG("SIP message without transaction... must be a ul callback\n");
        //return 0;
    }

    if (cxdx_forced_peer.len)
        cdpb.AAASendMessageToPeer(sar, &cxdx_forced_peer, (void*) async_cdp_callback, (void*) transaction_data);
    else
        cdpb.AAASendMessage(sar, (void*) async_cdp_callback, (void*) transaction_data);

    return 0;

error1: //Only free SAR IFF it has not been passed to CDP
    if (sar) cdpb.AAAFreeMessage(&sar);

    return -1;


}
示例#3
0
/**
 * Sends an UAR and returns the parsed UAA struct.
 * @param msg - the SIP message
 * @param private_identity - the username
 * @param public_identity - the public identity
 * @param visited_network_id - id of the roaming network
 * @param authorization_type - if registration or de-registration
 * @returns the status of sending the async UAR - 0 for success, !0 for failure
 */
int cxdx_send_uar(struct sip_msg *msg, str private_identity, str public_identity, str visited_network_id,
        int authorization_type, int sos_reg, saved_uar_transaction_t* transaction_data) {
    AAAMessage *uar = 0;
    AAASession *session = 0;

    session = cdpb.AAACreateSession(0);

    uar = cdpb.AAACreateRequest(IMS_Cx, IMS_UAR, Flag_Proxyable, session);
    if (session) {
        cdpb.AAADropSession(session);
        session = 0;
    }
    if (!uar) goto error1;

    if (!cxdx_add_destination_realm(uar, cxdx_dest_realm)) goto error1;

    if (!cxdx_add_vendor_specific_appid(uar, IMS_vendor_id_3GPP, IMS_Cx, 0)) goto error1;
    if (!cxdx_add_auth_session_state(uar, 1)) goto error1;

    if (!cxdx_add_user_name(uar, private_identity)) goto error1;
    if (!cxdx_add_public_identity(uar, public_identity)) goto error1;
    if (!cxdx_add_visited_network_id(uar, visited_network_id)) goto error1;
    if (!cxdx_add_UAR_flags(uar, sos_reg)) goto error1;
    if (authorization_type != AVP_IMS_UAR_REGISTRATION)
        if (!cxdx_add_authorization_type(uar, authorization_type)) goto error1;

    if (cxdx_forced_peer.len)
        cdpb.AAASendMessageToPeer(uar, &cxdx_forced_peer, (void*) async_cdp_uar_callback, (void*) transaction_data);
    else
        cdpb.AAASendMessage(uar, (void*) async_cdp_uar_callback, (void*) transaction_data);

    LM_DBG("Successfully sent async diameter\n");

    return 0;

error1:
    //Only free UAR IFF it has not been passed to CDP
    if (uar) cdpb.AAAFreeMessage(&uar);
    LM_ERR("Error occurred trying to send UAR\n");
    return -1;
}