Skip to content

Commit caf29e7

Browse files
Support latest 3GPP TS 33102 (#4414)
1 parent 5088932 commit caf29e7

File tree

2 files changed

+93
-26
lines changed

2 files changed

+93
-26
lines changed

pjsip/include/pjsip/sip_auth_aka.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ PJ_BEGIN_DECL
129129
/**
130130
* Length of permanent/subscriber Key (K) in bytes.
131131
*/
132-
#define PJSIP_AKA_KLEN 16
132+
#define PJSIP_AKA_KLEN 32
133133

134134
/**
135135
* Length of AKA authentication code in bytes.

pjsip/src/pjsua-lib/pjsua_acc.c

Lines changed: 92 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2728,10 +2728,7 @@ static pj_status_t pjsua_regc_init(int acc_id)
27282728
pjsua_perror(THIS_FILE, "Unable to generate suitable Contact header"
27292729
" for registration",
27302730
status);
2731-
destroy_regc(acc, PJ_TRUE);
2732-
pj_pool_release(pool);
2733-
acc->regc = NULL;
2734-
return status;
2731+
goto on_return;
27352732
}
27362733

27372734
pj_strdup_with_null(acc->pool, &acc->contact, &tmp_contact);
@@ -2748,37 +2745,72 @@ static pj_status_t pjsua_regc_init(int acc_id)
27482745
pjsua_perror(THIS_FILE,
27492746
"Client registration initialization error",
27502747
status);
2751-
destroy_regc(acc, PJ_TRUE);
2752-
pj_pool_release(pool);
2753-
2754-
return status;
2748+
goto on_return;
27552749
}
27562750

2757-
pjsip_regc_set_reg_tsx_cb(acc->regc, regc_tsx_cb);
2751+
status = pjsip_regc_set_reg_tsx_cb(acc->regc, regc_tsx_cb);
2752+
if (status != PJ_SUCCESS) {
2753+
pjsua_perror(THIS_FILE,
2754+
"Failed setting registration callback",
2755+
status);
2756+
goto on_return;
2757+
}
27582758

27592759
/* Set client registration's transport based on acc's config. */
27602760
pjsua_init_tpselector(acc_id, &tp_sel);
2761-
pjsip_regc_set_transport(acc->regc, &tp_sel);
2761+
status = pjsip_regc_set_transport(acc->regc, &tp_sel);
2762+
if (status != PJ_SUCCESS) {
2763+
pjsua_perror(THIS_FILE,
2764+
"Failed setting registration transport",
2765+
status);
2766+
goto on_return;
2767+
}
27622768

27632769
if (acc->cfg.use_shared_auth) {
2764-
pjsip_regc_set_auth_sess(acc->regc, &acc->shared_auth_sess);
2770+
status = pjsip_regc_set_auth_sess(acc->regc, &acc->shared_auth_sess);
2771+
if (status != PJ_SUCCESS) {
2772+
pjsua_perror(THIS_FILE,
2773+
"Failed setting registration shared auth session",
2774+
status);
2775+
goto on_return;
2776+
}
27652777
}
27662778

2767-
/* Set credentials
2768-
*/
2779+
/* Set credentials */
27692780
if (acc->cred_cnt) {
2770-
pjsip_regc_set_credentials( acc->regc, acc->cred_cnt, acc->cred);
2781+
status = pjsip_regc_set_credentials(acc->regc, acc->cred_cnt,
2782+
acc->cred);
2783+
if (status != PJ_SUCCESS) {
2784+
pjsua_perror(THIS_FILE,
2785+
"Failed setting credentials for registration",
2786+
status);
2787+
goto on_return;
2788+
}
27712789
}
27722790

27732791
/* Set delay before registration refresh */
2774-
pjsip_regc_set_delay_before_refresh(acc->regc,
2792+
status = pjsip_regc_set_delay_before_refresh(
2793+
acc->regc,
27752794
acc->cfg.reg_delay_before_refresh);
2795+
if (status != PJ_SUCCESS) {
2796+
/* Maybe too big, it will fallback to the default setting,
2797+
* just print warning.
2798+
*/
2799+
pjsua_perror(THIS_FILE,
2800+
"Warning: failed setting registration refresh delay",
2801+
status);
2802+
}
27762803

27772804
/* Set authentication preference */
2778-
pjsip_regc_set_prefs(acc->regc, &acc->cfg.auth_pref);
2805+
status = pjsip_regc_set_prefs(acc->regc, &acc->cfg.auth_pref);
2806+
if (status != PJ_SUCCESS) {
2807+
pjsua_perror(THIS_FILE,
2808+
"Failed setting registration auth preference",
2809+
status);
2810+
goto on_return;
2811+
}
27792812

2780-
/* Set route-set
2781-
*/
2813+
/* Set route-set */
27822814
if (acc->cfg.reg_use_proxy) {
27832815
pjsip_route_hdr route_set;
27842816
const pjsip_route_hdr *r;
@@ -2807,12 +2839,25 @@ static pj_status_t pjsua_regc_init(int acc_id)
28072839
}
28082840
}
28092841

2810-
if (!pj_list_empty(&route_set))
2811-
pjsip_regc_set_route_set( acc->regc, &route_set );
2842+
if (!pj_list_empty(&route_set)) {
2843+
status = pjsip_regc_set_route_set( acc->regc, &route_set );
2844+
if (status != PJ_SUCCESS) {
2845+
pjsua_perror(THIS_FILE,
2846+
"Failed setting registration route set",
2847+
status);
2848+
goto on_return;
2849+
}
2850+
}
28122851
}
28132852

28142853
/* Add custom request headers specified in the account config */
2815-
pjsip_regc_add_headers(acc->regc, &acc->cfg.reg_hdr_list);
2854+
status = pjsip_regc_add_headers(acc->regc, &acc->cfg.reg_hdr_list);
2855+
if (status != PJ_SUCCESS) {
2856+
pjsua_perror(THIS_FILE,
2857+
"Failed setting registration custom headers",
2858+
status);
2859+
goto on_return;
2860+
}
28162861

28172862
/* Add other request headers. */
28182863
if (pjsua_var.ua_cfg.user_agent.slen) {
@@ -2826,7 +2871,15 @@ static pj_status_t pjsua_regc_init(int acc_id)
28262871
&pjsua_var.ua_cfg.user_agent);
28272872
pj_list_push_back(&hdr_list, (pjsip_hdr*)h);
28282873

2829-
pjsip_regc_add_headers(acc->regc, &hdr_list);
2874+
status = pjsip_regc_add_headers(acc->regc, &hdr_list);
2875+
if (status != PJ_SUCCESS) {
2876+
/* Informational header, just print warning */
2877+
pjsua_perror(THIS_FILE,
2878+
"Warning: failed setting registration "
2879+
"user-agent header",
2880+
status);
2881+
status = PJ_SUCCESS;
2882+
}
28302883
}
28312884

28322885
/* If SIP outbound is used, add "Supported: outbound, path header" */
@@ -2844,12 +2897,26 @@ static pj_status_t pjsua_regc_init(int acc_id)
28442897
hsup->values[0] = pj_str("outbound");
28452898
hsup->values[1] = pj_str("path");
28462899

2847-
pjsip_regc_add_headers(acc->regc, &hdr_list);
2900+
status = pjsip_regc_add_headers(acc->regc, &hdr_list);
2901+
if (status != PJ_SUCCESS) {
2902+
pjsua_perror(THIS_FILE,
2903+
"Failed setting registration outbound support "
2904+
"indication",
2905+
status);
2906+
goto on_return;
2907+
}
28482908
}
28492909

2850-
pj_pool_release(pool);
2910+
on_return:
2911+
if (status != PJ_SUCCESS) {
2912+
if (acc->regc)
2913+
destroy_regc(acc, PJ_TRUE);
28512914

2852-
return PJ_SUCCESS;
2915+
pjsua_perror(THIS_FILE, "Error initializing client registration",
2916+
status);
2917+
}
2918+
pj_pool_release(pool);
2919+
return status;
28532920
}
28542921

28552922
pj_bool_t pjsua_sip_acc_is_using_ipv6(pjsua_acc_id acc_id)

0 commit comments

Comments
 (0)