Changeset 5055 for pjproject/trunk
- Timestamp:
- Apr 8, 2015 10:10:44 AM (10 years ago)
- Location:
- pjproject/trunk/pjsip
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/include/pjsip/sip_endpoint.h
r4275 r5055 392 392 393 393 /** 394 * Set the DNS external resolver implementation to use in the SIP resolver. 395 * 396 * Note that naturally when implementing its own resolver, application would not 397 * need the internal resolver, hence this function will also destroy the 398 * PJLIB-UTIL DNS resolver if any (e.g: set using #pjsip_endpt_set_resolver()). 399 * Application that needs it, still be able create its own instance. 400 * 401 * @param res The SIP resolver engine. 402 * @param ext_res The external resolver implementation callback. This argument 403 * can be NULL to reset the whole external implementation. 404 * However, it is prohibited to reset individual callback. 405 * 406 * @return PJ_SUCCESS on success, or the appropriate error code. 407 */ 408 PJ_DECL(pj_status_t) pjsip_endpt_set_ext_resolver(pjsip_endpoint *endpt, 409 pjsip_ext_resolver *ext_res); 410 411 /** 394 412 * Get the DNS resolver being used by the SIP resolver. 395 413 * -
pjproject/trunk/pjsip/include/pjsip/sip_resolve.h
r3553 r5055 119 119 * response caching, query aggregation, parallel nameservers, fallback 120 120 * nameserver, etc., which will be described below. 121 * - Enable application to provide its own resolver implementation. 121 122 * 122 123 * … … 156 157 * PJSIP needs to send SIP request/response messages. 157 158 * 159 * \section PJSIP_RESOLVE_EXT_RESOLVER External Resolver 160 * 161 * As an alternative to enabling PJLIB-UTIL DNS resolver, application can 162 * provide its own resolver implementation by defining the callback in 163 * pjsip_ext_resolver and pass the callback to 164 * #pjsip_resolver_set_ext_resolver() function. Please note that if the 165 * implementation needs feature from PJLIB-UTL DNS resolver, it has to create 166 * its own PJLIB-UTL DNS resolver instance. 158 167 * 159 168 * \section PJSIP_RESOLVE_REFERENCE Reference … … 208 217 209 218 /** 219 * This structure describes application callback to receive various event from 220 * the SIP resolver engine. Application can use this for its own resolver 221 * implementation. 222 */ 223 typedef struct pjsip_ext_resolver 224 { 225 /** 226 * Notify application when the resolution should begin. 227 * 228 * @param resolver The resolver engine. 229 * @param pool The pool to allocate resolver job. 230 * @param target The target specification to be resolved. 231 * @param token A user defined token to be passed back to callback 232 * function. 233 * @param cb The callback function. 234 */ 235 void (*resolve) (pjsip_resolver_t *resolver, pj_pool_t *pool, 236 const pjsip_host_info *target, void *token, 237 pjsip_resolver_callback *cb); 238 239 } pjsip_ext_resolver; 240 241 242 /** 210 243 * Create SIP resolver engine. Note that this function is normally called 211 244 * internally by pjsip_endpoint instance. … … 237 270 pj_dns_resolver *dns_res); 238 271 272 273 /** 274 * Set the DNS external resolver implementation to use in the SIP resolver 275 * engine. Naturally when implementing its own resolver, application would not 276 * need the internal resolver, hence this function will also destroy the 277 * PJLIB-UTIL DNS resolver if any (e.g: set using 278 * #pjsip_resolver_set_resolver()). Application that needs it, still be able 279 * create its own instance. 280 * 281 * Note that application normally will use #pjsip_endpt_set_ext_resolver() 282 * instead since it does not normally have access to the SIP resolver instance. 283 * 284 * @param res The SIP resolver engine. 285 * @param ext_res The external resolver implementation callback. This argument 286 * can be NULL to reset the whole external implementation. 287 * However, it is prohibited to reset individual callback. 288 * 289 * @return PJ_SUCCESS on success, or the appropriate error code. 290 */ 291 PJ_DECL(pj_status_t) pjsip_resolver_set_ext_resolver( 292 pjsip_resolver_t *res, 293 pjsip_ext_resolver *ext_res); 239 294 240 295 /** -
pjproject/trunk/pjsip/src/pjsip/sip_endpoint.c
r4704 r5055 1129 1129 1130 1130 /* 1131 * Set DNS external resolver implementation to be used by the SIP resolver. 1132 */ 1133 PJ_DEF(pj_status_t) pjsip_endpt_set_ext_resolver(pjsip_endpoint *endpt, 1134 pjsip_ext_resolver *ext_res) 1135 { 1136 return pjsip_resolver_set_ext_resolver(endpt->resolver, ext_res); 1137 } 1138 1139 /* 1131 1140 * Get the DNS resolver being used by the SIP resolver. 1132 1141 */ -
pjproject/trunk/pjsip/src/pjsip/sip_resolve.c
r4954 r5055 71 71 { 72 72 pj_dns_resolver *res; 73 pjsip_ext_resolver *ext_res; 73 74 }; 74 75 … … 115 116 } 116 117 118 /* 119 * Public API to set the DNS external resolver implementation for the SIP 120 * resolver. 121 */ 122 PJ_DEF(pj_status_t) pjsip_resolver_set_ext_resolver(pjsip_resolver_t *res, 123 pjsip_ext_resolver *ext_res) 124 { 125 if (ext_res && !ext_res->resolve) 126 return PJ_EINVAL; 127 128 if (ext_res && res->res) { 129 #if PJSIP_HAS_RESOLVER 130 pj_dns_resolver_destroy(res->res, PJ_FALSE); 131 #endif 132 res->res = NULL; 133 } 134 res->ext_res = ext_res; 135 return PJ_SUCCESS; 136 } 137 117 138 118 139 /* … … 175 196 struct query *query; 176 197 pjsip_transport_type_e type = target->type; 198 199 /* If an external implementation has been provided use it instead */ 200 if (resolver->ext_res) { 201 (*resolver->ext_res->resolve)(resolver, pool, target, token, cb); 202 return; 203 } 177 204 178 205 /* Is it IP address or hostname? And if it's an IP, which version? */
Note: See TracChangeset
for help on using the changeset viewer.