Changeset 127 for pjproject/trunk/pjsip/src/pjsip/sip_endpoint.c
- Timestamp:
- Jan 30, 2006 6:40:05 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsip/sip_endpoint.c
r116 r127 78 78 pjsip_module module_list; 79 79 80 /** Number of supported methods. */81 unsigned method_cnt;82 83 /** Array of supported methods. */84 const pjsip_method *methods[MAX_METHODS];85 86 /** Allow header. */87 pjsip_allow_hdr *allow_hdr;88 89 80 /** Route header list. */ 90 81 pjsip_route_hdr route_hdr_list; 82 83 /** Capability header list. */ 84 pjsip_hdr cap_hdr; 91 85 92 86 /** Additional request headers. */ … … 197 191 198 192 /* Done. */ 199 PJ_TODO(BUILD_ALLOW_HEADER_BASED_ON_MODULES_SUPPORTED_METHODS);200 193 201 194 on_return: … … 249 242 status = PJ_SUCCESS; 250 243 251 PJ_TODO(REMOVE_METHODS_FROM_ALLOW_HEADER_WHEN_MODULE_IS_UNREGISTERED);252 253 244 on_return: 254 245 pj_rwmutex_unlock_write(endpt->mod_mutex); … … 256 247 } 257 248 258 /* 259 * Get "Allow" header. 260 */ 261 PJ_DEF(const pjsip_allow_hdr*) pjsip_endpt_get_allow_hdr( pjsip_endpoint *endpt ) 262 { 263 return endpt->allow_hdr; 249 250 /* 251 * Get the value of the specified capability header field. 252 */ 253 PJ_DEF(const pjsip_hdr*) pjsip_endpt_get_capability( pjsip_endpoint *endpt, 254 int htype, 255 const pj_str_t *hname) 256 { 257 pjsip_hdr *hdr = endpt->cap_hdr.next; 258 259 /* Check arguments. */ 260 PJ_ASSERT_RETURN(endpt != NULL, NULL); 261 PJ_ASSERT_RETURN(htype != PJSIP_H_OTHER || hname, NULL); 262 263 if (htype != PJSIP_H_OTHER) { 264 while (hdr != &endpt->cap_hdr) { 265 if (hdr->type == htype) 266 return hdr; 267 hdr = hdr->next; 268 } 269 } 270 return NULL; 271 } 272 273 274 /* 275 * Add or register new capabilities as indicated by the tags to the 276 * appropriate header fields in the endpoint. 277 */ 278 PJ_DEF(pj_status_t) pjsip_endpt_add_capability( pjsip_endpoint *endpt, 279 pjsip_module *mod, 280 int htype, 281 const pj_str_t *hname, 282 unsigned count, 283 const pj_str_t tags[]) 284 { 285 pjsip_generic_array_hdr *hdr; 286 unsigned i; 287 288 /* Check arguments. */ 289 PJ_ASSERT_RETURN(endpt!=NULL && mod!=NULL && count>0 && tags, PJ_EINVAL); 290 PJ_ASSERT_RETURN(htype==PJSIP_H_ACCEPT || 291 htype==PJSIP_H_ALLOW || 292 htype==PJSIP_H_SUPPORTED, 293 PJ_EINVAL); 294 295 /* Find the header. */ 296 hdr = (pjsip_generic_array_hdr*) pjsip_endpt_get_capability(endpt, 297 htype, hname); 298 299 /* Create the header when it's not present */ 300 if (hdr == NULL) { 301 switch (htype) { 302 case PJSIP_H_ACCEPT: 303 hdr = pjsip_accept_hdr_create(endpt->pool); 304 break; 305 case PJSIP_H_ALLOW: 306 hdr = pjsip_allow_hdr_create(endpt->pool); 307 break; 308 case PJSIP_H_SUPPORTED: 309 hdr = pjsip_supported_hdr_create(endpt->pool); 310 break; 311 default: 312 return PJ_EINVAL; 313 } 314 } 315 316 /* Add the tags to the header. */ 317 for (i=0; i<count; ++i) { 318 pj_strdup(endpt->pool, &hdr->values[hdr->count], &tags[i]); 319 ++hdr->count; 320 } 321 322 /* Done. */ 323 return PJ_SUCCESS; 264 324 } 265 325 … … 326 386 pj_pool_t *pool; 327 387 pjsip_endpoint *endpt; 328 pjsip_max_f orwards_hdr *mf_hdr;388 pjsip_max_fwd_hdr *mf_hdr; 329 389 pj_lock_t *lock = NULL; 330 390 … … 420 480 421 481 /* Add "Max-Forwards" for request header. */ 422 mf_hdr = pjsip_max_f orwards_hdr_create(endpt->pool);423 mf_hdr->ivalue = PJSIP_MAX_FORWARDS_VALUE;482 mf_hdr = pjsip_max_fwd_hdr_create(endpt->pool, 483 PJSIP_MAX_FORWARDS_VALUE); 424 484 pj_list_insert_before( &endpt->req_hdr, mf_hdr); 485 486 /* Initialize capability header list. */ 487 pj_list_init(&endpt->cap_hdr); 425 488 426 489 /* Done. */
Note: See TracChangeset
for help on using the changeset viewer.