Changeset 141 for pjproject/trunk/pjsip/src/pjsip/sip_dialog.c
- Timestamp:
- Feb 7, 2006 6:48:01 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsip/sip_dialog.c
r139 r141 698 698 } 699 699 700 /* Copy authorization headers. */ 701 status = pjsip_auth_clt_init_req( &dlg->auth_sess, tdata ); 702 if (status != PJ_SUCCESS) 703 return status; 700 /* Copy authorization headers, if request is not ACK or CANCEL. */ 701 if (method->id != PJSIP_ACK_METHOD && method->id != PJSIP_CANCEL_METHOD) { 702 status = pjsip_auth_clt_init_req( &dlg->auth_sess, tdata ); 703 if (status != PJ_SUCCESS) 704 return status; 705 } 704 706 705 707 /* Done. */ … … 1133 1135 { 1134 1136 unsigned i; 1137 int res_code; 1135 1138 1136 1139 /* Lock the dialog. */ … … 1140 1143 pj_assert(pjsip_rdata_get_dlg(rdata) == dlg); 1141 1144 1142 /* Update the remote tag , if none is specified yet. */1143 if ( dlg->remote.info->tag.slen == 0 && rdata->msg_info.to->tag.slen!= 0) {1145 /* Update the remote tag if it is different. */ 1146 if (pj_strcmp(&dlg->remote.info->tag, &rdata->msg_info.to->tag) != 0) { 1144 1147 1145 1148 pj_strdup(dlg->pool, &dlg->remote.info->tag, &rdata->msg_info.to->tag); … … 1148 1151 } 1149 1152 1150 /* Update remote target when receiving certain response messages. */ 1151 if (pjsip_method_creates_dialog(&rdata->msg_info.cseq->method) && 1152 rdata->msg_info.msg->line.status.code/100 == 2) 1153 /* Keep the response's status code */ 1154 res_code = rdata->msg_info.msg->line.status.code; 1155 1156 /* When we receive response that establishes dialog, update the route 1157 * set and dialog target. 1158 */ 1159 if (!dlg->established && 1160 pjsip_method_creates_dialog(&rdata->msg_info.cseq->method) && 1161 (res_code > 100 && res_code < 300) && 1162 rdata->msg_info.to->tag.slen) 1153 1163 { 1164 /* RFC 3271 Section 12.1.2: 1165 * The route set MUST be set to the list of URIs in the Record-Route 1166 * header field from the response, taken in reverse order and 1167 * preserving all URI parameters. If no Record-Route header field 1168 * is present in the response, the route set MUST be set to the 1169 * empty set. This route set, even if empty, overrides any pre-existing 1170 * route set for future requests in this dialog. 1171 */ 1172 pjsip_hdr *hdr, *end_hdr; 1154 1173 pjsip_contact_hdr *contact; 1155 1174 1175 pj_list_init(&dlg->route_set); 1176 1177 end_hdr = &rdata->msg_info.msg->hdr; 1178 for (hdr=rdata->msg_info.msg->hdr.prev; hdr!=end_hdr; hdr=hdr->prev) { 1179 if (hdr->type == PJSIP_H_RECORD_ROUTE) { 1180 pjsip_route_hdr *r; 1181 r = pjsip_hdr_clone(dlg->pool, hdr); 1182 pjsip_routing_hdr_set_route(r); 1183 pj_list_push_back(&dlg->route_set, r); 1184 } 1185 } 1186 1187 /* The remote target MUST be set to the URI from the Contact header 1188 * field of the response. 1189 */ 1156 1190 contact = pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_CONTACT, 1157 1191 NULL); … … 1160 1194 dlg->target = dlg->remote.contact->uri; 1161 1195 } 1162 } 1196 1197 dlg->established = 1; 1198 } 1199 1200 /* Update remote target (again) when receiving 2xx response messages 1201 * that's defined as target refresh. 1202 */ 1203 if (pjsip_method_creates_dialog(&rdata->msg_info.cseq->method) && 1204 res_code/100 == 2) 1205 { 1206 pjsip_contact_hdr *contact; 1207 1208 contact = pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_CONTACT, 1209 NULL); 1210 if (contact) { 1211 dlg->remote.contact = pjsip_hdr_clone(dlg->pool, contact); 1212 dlg->target = dlg->remote.contact->uri; 1213 } 1214 } 1215 1163 1216 1164 1217 /* Pass to dialog usages. */
Note: See TracChangeset
for help on using the changeset viewer.