Skip to content

Commit 6bfb11c

Browse files
committed
mid_registrar PN: Finalize PN contact storage & matching
1 parent 4b779d0 commit 6bfb11c

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

modules/mid_registrar/mid_registrar.c

+5
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,11 @@ static int mod_init(void)
284284
return -1;
285285
}
286286

287+
if (pn_init() < 0) {
288+
LM_ERR("failed to init SIP Push Notification support\n");
289+
return -1;
290+
}
291+
287292
if (solve_avp_defs() != 0) {
288293
LM_ERR("failed to parse one or more module AVPs\n");
289294
return -1;

modules/mid_registrar/save.c

+28-1
Original file line numberDiff line numberDiff line change
@@ -2408,6 +2408,7 @@ int mid_reg_save(struct sip_msg *msg, udomain_t *d, str *flags_str,
24082408
{
24092409
urecord_t *r = NULL;
24102410
struct save_ctx sctx;
2411+
contact_t *c;
24112412
struct hdr_field *path;
24122413
int rc = -1, st, unlock_udomain = 0;
24132414

@@ -2455,14 +2456,40 @@ int mid_reg_save(struct sip_msg *msg, udomain_t *d, str *flags_str,
24552456
if (check_contacts(msg, &st) != 0)
24562457
goto out_error;
24572458

2458-
if (!get_first_contact(msg)) {
2459+
if (!(c = get_first_contact(msg))) {
24592460
if (st) {
24602461
sctx.star = 1;
24612462
return prepare_forward(msg, d, &sctx);
24622463
}
24632464
goto quick_reply;
24642465
}
24652466

2467+
if (sctx.cmatch.mode == CT_MATCH_NONE && pn_enable) {
2468+
switch (pn_inspect_ct_params(&c->uri)) {
2469+
case PN_NONE:
2470+
LM_DBG("Contact URI has no PN params\n");
2471+
break;
2472+
2473+
case PN_ON:
2474+
LM_DBG("Contact URI includes all required PN params\n");
2475+
sctx.cmatch.mode = CT_MATCH_PARAMS;
2476+
sctx.cmatch.match_params = pn_ct_params;
2477+
break;
2478+
2479+
case PN_LIST_ALL_PNS:
2480+
LM_DBG("Contact URI includes PN capability query (all PNS)\n");
2481+
break;
2482+
2483+
case PN_LIST_ONE_PNS:
2484+
LM_DBG("Contact URI includes PN capability query (one PNS)\n");
2485+
break;
2486+
2487+
case PN_UNSUPPORTED_PNS:
2488+
rerrno = R_PNS_UNSUP;
2489+
goto quick_reply;
2490+
}
2491+
}
2492+
24662493
/* mid-registrar always rewrites the Contact, so any Path hf must go! */
24672494
if (parse_headers(msg, HDR_PATH_F, 0) == 0 && msg->path) {
24682495
for (path = msg->path; path; path = path->sibling) {

0 commit comments

Comments
 (0)