Changeset 1387 for pjproject/trunk
- Timestamp:
- Jun 23, 2007 4:22:51 AM (17 years ago)
- Location:
- pjproject/trunk/pjsip
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/include/pjsip/sip_transport.h
r1310 r1387 905 905 typedef pj_status_t (*pjsip_tx_callback)(pjsip_endpoint*, pjsip_tx_data*); 906 906 /** 907 * Create a new transport manager. 907 * Create a transport manager. Normally application doesn't need to call 908 * this function directly, since a transport manager will be created and 909 * destroyed automatically by the SIP endpoint. 908 910 * 909 911 * @param pool Pool. … … 960 962 961 963 /** 962 * Destroy transport manager. 964 * Destroy a transport manager. Normally application doesn't need to call 965 * this function directly, since a transport manager will be created and 966 * destroyed automatically by the SIP endpoint. 967 * 968 * @param mgr The transport manager. 969 * 970 * @return PJ_SUCCESS on success. 963 971 */ 964 972 PJ_DECL(pj_status_t) pjsip_tpmgr_destroy(pjsip_tpmgr *mgr); … … 966 974 967 975 /** 968 * Dump transport info. 976 * Dump transport info and status to log. 977 * 978 * @param mgr The transport manager. 969 979 */ 970 980 PJ_DECL(void) pjsip_tpmgr_dump_transports(pjsip_tpmgr *mgr); … … 1003 1013 pjsip_transport **tp); 1004 1014 1015 /** 1016 * Type of callback to receive notification when message or raw data 1017 * has been sent. 1018 * 1019 * @param token The token that was given when calling the function 1020 * to send message or raw data. 1021 * @param tdata The transmit buffer used to send the message. 1022 * @param bytes_sent Number of bytes sent. On success, the value will be 1023 * positive number indicating the number of bytes sent. 1024 * On failure, the value will be a negative number of 1025 * the error code (i.e. bytes_sent = -status). 1026 */ 1005 1027 typedef void (*pjsip_tp_send_callback)(void *token, pjsip_tx_data *tdata, 1006 pj_ssize_t bytes_sent); 1007 /** 1008 * Send a SIP message using the specified transport. 1028 pj_ssize_t bytes_sent); 1029 1030 1031 /** 1032 * This is a low-level function to send a SIP message using the specified 1033 * transport to the specified destination. 1034 * 1035 * @param tr The SIP transport to be used. 1036 * @param tdata Transmit data buffer containing SIP message. 1037 * @param addr Destination address. 1038 * @param addr_len Length of destination address. 1039 * @param token Arbitrary token to be returned back to callback. 1040 * @param cb Optional callback to be called to notify caller about 1041 * the completion status of the pending send operation. 1042 * 1043 * @return If the message has been sent successfully, this function 1044 * will return PJ_SUCCESS and the callback will not be 1045 * called. If message cannot be sent immediately, this 1046 * function will return PJ_EPENDING, and application will 1047 * be notified later about the completion via the callback. 1048 * Any statuses other than PJ_SUCCESS or PJ_EPENDING 1049 * indicates immediate failure, and in this case the 1050 * callback will not be called. 1009 1051 */ 1010 1052 PJ_DECL(pj_status_t) pjsip_transport_send( pjsip_transport *tr, … … 1017 1059 1018 1060 /** 1061 * This is a low-level function to send raw data using the specified transport 1062 * to the specified destination. 1063 * 1064 * @param tr The SIP transport to be used. 1065 * @param raw_data The data to be sent. 1066 * @param data_len The length of the data. 1067 * @param addr Destination address. 1068 * @param addr_len Length of destination address. 1069 * @param token Arbitrary token to be returned back to callback. 1070 * @param cb Optional callback to be called to notify caller about 1071 * the completion status of the pending send operation. 1072 * 1073 * @return If the message has been sent successfully, this function 1074 * will return PJ_SUCCESS and the callback will not be 1075 * called. If message cannot be sent immediately, this 1076 * function will return PJ_EPENDING, and application will 1077 * be notified later about the completion via the callback. 1078 * Any statuses other than PJ_SUCCESS or PJ_EPENDING 1079 * indicates immediate failure, and in this case the 1080 * callback will not be called. 1081 */ 1082 PJ_DECL(pj_status_t) pjsip_transport_send_raw(pjsip_transport *tr, 1083 const void *raw_data, 1084 pj_size_t data_len, 1085 const pj_sockaddr_t *addr, 1086 int addr_len, 1087 void *token, 1088 pjsip_tp_send_callback cb); 1089 1090 1091 /** 1019 1092 * @} 1020 1093 */ -
pjproject/trunk/pjsip/src/pjsip/sip_transport.c
r1310 r1387 602 602 return status; 603 603 } 604 605 606 /* Send raw data */ 607 PJ_DEF(pj_status_t) pjsip_transport_send_raw(pjsip_transport *tr, 608 const void *raw_data, 609 pj_size_t data_len, 610 const pj_sockaddr_t *addr, 611 int addr_len, 612 void *token, 613 pjsip_tp_send_callback cb) 614 { 615 pjsip_tx_data *tdata; 616 pj_status_t status; 617 618 status = pjsip_endpt_create_tdata(tr->endpt, &tdata); 619 if (status != PJ_SUCCESS) 620 return status; 621 622 /* Add reference counter. */ 623 pjsip_tx_data_add_ref(tdata); 624 625 /* Allocate buffer */ 626 tdata->buf.start = (char*) pj_pool_alloc(tdata->pool, data_len); 627 tdata->buf.end = tdata->buf.start + data_len; 628 629 /* Copy data */ 630 pj_memcpy(tdata->buf.start, raw_data, data_len); 631 tdata->buf.cur = tdata->buf.start + data_len; 632 633 /* Save callback data. */ 634 tdata->token = token; 635 tdata->cb = cb; 636 637 /* Mark as pending. */ 638 tdata->is_pending = 1; 639 640 /* Send to transoprt */ 641 status = tr->send_msg(tr, tdata, addr, addr_len, 642 tdata, &transport_send_callback); 643 644 if (status != PJ_EPENDING) { 645 /* callback will not be called, so destroy tdata now. */ 646 pjsip_tx_data_dec_ref(tdata); 647 } 648 649 return status; 650 } 651 604 652 605 653 static void transport_idle_callback(pj_timer_heap_t *timer_heap,
Note: See TracChangeset
for help on using the changeset viewer.