Changeset 58
- Timestamp:
- Nov 19, 2005 8:28:08 PM (19 years ago)
- Location:
- pjproject/trunk/pjsip
- Files:
-
- 1 added
- 6 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/build/pjsip.dsw
r44 r58 48 48 Package=<4> 49 49 {{{ 50 Begin Project Dependency 51 Project_Dep_Name pjlib 52 End Project Dependency 53 Begin Project Dependency 54 Project_Dep_Name pjlib_util 55 End Project Dependency 50 56 }}} 51 57 -
pjproject/trunk/pjsip/build/pjsip_core.dsp
r57 r58 208 208 # Begin Source File 209 209 210 SOURCE=..\include\pjsip\sip_transport_udp.h 211 # End Source File 212 # Begin Source File 213 210 214 SOURCE=..\include\pjsip\sip_types.h 211 215 # End Source File -
pjproject/trunk/pjsip/include/pjsip/sip_transport.h
r57 r58 333 333 /** Transport manager internal. */ 334 334 void *token; 335 void (*cb)(void*, pjsip_tx_data*, pj_s tatus_t);335 void (*cb)(void*, pjsip_tx_data*, pj_ssize_t); 336 336 }; 337 337 -
pjproject/trunk/pjsip/src/pjsip/sip_transaction.c
r54 r58 718 718 pjsip_transaction *tsx = token; 719 719 struct tsx_lock_data lck; 720 pjsip_transport *tp; 720 721 721 722 PJ_LOG(4, (tsx->obj_name, "resolver job complete, status=%d", status)); … … 742 743 743 744 tsx->transport_state = PJSIP_TSX_TRANSPORT_STATE_CONNECTING; 744 pjsip_endpt_get_transport(tsx->endpt, tsx->pool,745 addr->entry[0].type,&addr->entry[0].addr,746 tsx,747 &tsx_transport_callback);745 status = pjsip_endpt_alloc_transport( tsx->endpt, addr->entry[0].type, 746 &addr->entry[0].addr, 747 &tp); 748 tsx_transport_callback(tp, tsx, status); 748 749 749 750 /* Unlock transaction */ … … 941 942 tsx->current_addr = 0; 942 943 tsx->remote_addr.count = 1; 943 tsx->remote_addr.entry[0].type = 944 pjsip_transport_get_type(tsx->transport); 944 tsx->remote_addr.entry[0].type = tsx->transport->type; 945 945 pj_memcpy(&tsx->remote_addr.entry[0].addr, 946 946 &rdata->pkt_info.addr, rdata->pkt_info.addr_len); … … 1182 1182 1183 1183 /* 1184 * Transport send completion callback. 1185 */ 1186 static void tsx_on_send_complete(void *token, pjsip_tx_data *tdata, 1187 pj_ssize_t bytes_sent) 1188 { 1189 PJ_UNUSED_ARG(token); 1190 PJ_UNUSED_ARG(tdata); 1191 1192 if (bytes_sent <= 0) { 1193 PJ_TODO(HANDLE_TRANSPORT_ERROR); 1194 } 1195 } 1196 1197 /* 1184 1198 * Send message to the transport. 1185 1199 * If transport is not yet available, then do nothing. The message will be … … 1194 1208 1195 1209 if (tsx->transport_state == PJSIP_TSX_TRANSPORT_STATE_FINAL) { 1196 pj_ssize_t sent;1197 1210 pjsip_event before_tx_event; 1198 1211 … … 1228 1241 1229 1242 tsx->has_unsent_msg = 0; 1230 status = pjsip_transport_send _msg(1231 tsx->transport, tdata,1232 &tsx->remote_addr.entry[tsx->current_addr].addr,1233 &sent); 1234 if (status != PJ_SUCCESS) {1243 status = pjsip_transport_send(tsx->transport, tdata, 1244 &tsx->remote_addr.entry[tsx->current_addr].addr, 1245 tsx, &tsx_on_send_complete); 1246 if (status != PJ_SUCCESS && status != PJ_EPENDING) { 1247 PJ_TODO(HANDLE_TRANSPORT_ERROR); 1235 1248 goto on_error; 1236 1249 } -
pjproject/trunk/pjsip/src/pjsip/sip_transport.c
r57 r58 173 173 } 174 174 175 pj_ioqueue_op_key_init(&tdata->op_key , sizeof(tdata->op_key));175 pj_ioqueue_op_key_init(&tdata->op_key.key, sizeof(tdata->op_key)); 176 176 177 177 *p_tdata = tdata; … … 245 245 static void transport_send_callback(pjsip_transport *transport, 246 246 void *token, 247 pj_s tatus_t status)247 pj_ssize_t size) 248 248 { 249 249 pjsip_tx_data *tdata = token; … … 258 258 /* Call callback, if any. */ 259 259 if (tdata->cb) { 260 (*tdata->cb)(tdata->token, tdata, s tatus);260 (*tdata->cb)(tdata->token, tdata, size); 261 261 } 262 262 … … 274 274 void (*cb)(void *token, 275 275 pjsip_tx_data *tdata, 276 pj_s tatus_t))276 pj_ssize_t)) 277 277 { 278 278 pj_status_t status; … … 318 318 319 319 /* Send to transport. */ 320 status = (*tr->send_msg)(tr, tdata->buf.start, 321 tdata->buf.cur - tdata->buf.start, 322 &tdata->op_key, 323 addr, tdata, &transport_send_callback); 320 status = (*tr->send_msg)(tr, tdata, addr, (void*)tdata, 321 &transport_send_callback); 324 322 325 323 if (status != PJ_EPENDING) { -
pjproject/trunk/pjsip/src/pjsip/sip_transport_udp.c
r57 r58 110 110 /* Read next packet. */ 111 111 bytes_read = sizeof(rdata->pkt_info.packet); 112 rdata->pkt_info.addr_len = sizeof(rdata->pkt_info.addr); 112 113 status = pj_ioqueue_recvfrom(key, op_key, 113 114 rdata->pkt_info.packet, … … 161 162 pjsip_tx_data_op_key *tdata_op_key = (pjsip_tx_data_op_key*)op_key; 162 163 164 tdata_op_key->tdata = NULL; 165 163 166 if (tdata_op_key->callback) { 164 167 tdata_op_key->callback(&tp->base, tdata_op_key->token, bytes_sent); … … 184 187 185 188 PJ_ASSERT_RETURN(transport && tdata, PJ_EINVAL); 186 189 PJ_ASSERT_RETURN(tdata->op_key.tdata == NULL, PJSIP_EPENDINGTX); 190 187 191 /* Init op key. */ 188 192 tdata->op_key.tdata = tdata; … … 240 244 241 245 /* 242 * pjsip_udp_transport_ start()243 * 244 * Start an UDP transport/listener.245 */ 246 PJ_DEF(pj_status_t) pjsip_udp_transport_ start( pjsip_endpoint *endpt,247 const pj_sockaddr_in *local,248 249 250 246 * pjsip_udp_transport_attach() 247 * 248 * Attach UDP socket and start transport. 249 */ 250 PJ_DEF(pj_status_t) pjsip_udp_transport_attach( pjsip_endpoint *endpt, 251 pj_sock_t sock, 252 const pj_sockaddr_in *pub_addr, 253 unsigned async_cnt, 254 pjsip_transport **p_transport) 251 255 { 252 256 pj_pool_t *pool; … … 255 259 pj_ioqueue_callback ioqueue_cb; 256 260 unsigned i; 261 int addrlen; 257 262 pj_status_t status; 258 263 … … 273 278 274 279 /* Init addresses. */ 275 pj_memcpy(&tp->base.local_addr, local, sizeof(pj_sockaddr_in)); 280 addrlen = sizeof(tp->base.local_addr); 281 status = pj_sock_getsockname(sock, &tp->base.local_addr, &addrlen); 282 if (status != PJ_SUCCESS) { 283 pjsip_endpt_destroy_pool(endpt, pool); 284 return status; 285 } 276 286 pj_memcpy(&tp->base.public_addr, pub_addr, sizeof(pj_sockaddr_in)); 277 287 tp->base.rem_addr.sin_family = PJ_AF_INET; … … 287 297 goto on_error; 288 298 289 /* Create socket. */ 290 status = pj_sock_socket(PJ_AF_INET, PJ_SOCK_DGRAM, 0, &tp->sock); 291 if (status != PJ_SUCCESS) 292 goto on_error; 293 294 /* Bind socket. */ 295 status = pj_sock_bind(tp->sock, local, sizeof(pj_sockaddr_in)); 296 if (status != PJ_SUCCESS) 297 goto on_error; 299 /* Attach socket. */ 300 tp->sock = sock; 298 301 299 302 /* Register to ioqueue. */ … … 377 380 } 378 381 379 382 /* 383 * pjsip_udp_transport_start() 384 * 385 * Start an UDP transport/listener. 386 */ 387 PJ_DEF(pj_status_t) pjsip_udp_transport_start( pjsip_endpoint *endpt, 388 const pj_sockaddr_in *local, 389 const pj_sockaddr_in *pub_addr, 390 unsigned async_cnt, 391 pjsip_transport **p_transport) 392 { 393 pj_sock_t sock; 394 pj_status_t status; 395 396 status = pj_sock_socket(PJ_AF_INET, PJ_SOCK_DGRAM, 0, &sock); 397 if (status != PJ_SUCCESS) 398 return status; 399 400 status = pj_sock_bind(sock, local, sizeof(*local)); 401 if (status != PJ_SUCCESS) { 402 pj_sock_close(sock); 403 return status; 404 } 405 406 return pjsip_udp_transport_attach( endpt, sock, pub_addr, async_cnt, 407 p_transport ); 408 } 409 410
Note: See TracChangeset
for help on using the changeset viewer.