UDPTL support for T.38. More...
#include "asterisk/network.h"#include "asterisk/frame.h"#include "asterisk/io.h"#include "asterisk/sched.h"#include "asterisk/channel.h"

Go to the source code of this file.
Data Structures | |
| struct | ast_udptl_protocol |
Typedefs | |
| typedef int(* | ast_udptl_callback )(struct ast_udptl *udptl, struct ast_frame *f, void *data) |
Enumerations | |
| enum | ast_t38_ec_modes { UDPTL_ERROR_CORRECTION_NONE, UDPTL_ERROR_CORRECTION_FEC, UDPTL_ERROR_CORRECTION_REDUNDANCY } |
Functions | |
| int | ast_udptl_bridge (struct ast_channel *c0, struct ast_channel *c1, int flags, struct ast_frame **fo, struct ast_channel **rc) |
| void | ast_udptl_destroy (struct ast_udptl *udptl) |
| int | ast_udptl_fd (const struct ast_udptl *udptl) |
| enum ast_t38_ec_modes | ast_udptl_get_error_correction_scheme (const struct ast_udptl *udptl) |
| unsigned int | ast_udptl_get_far_max_datagram (const struct ast_udptl *udptl) |
| unsigned int | ast_udptl_get_far_max_ifp (const struct ast_udptl *udptl) |
| unsigned int | ast_udptl_get_local_max_datagram (const struct ast_udptl *udptl) |
| void | ast_udptl_get_peer (const struct ast_udptl *udptl, struct sockaddr_in *them) |
| void | ast_udptl_get_us (const struct ast_udptl *udptl, struct sockaddr_in *us) |
| void | ast_udptl_init (void) |
| struct ast_udptl * | ast_udptl_new (struct sched_context *sched, struct io_context *io, int callbackmode) |
| struct ast_udptl * | ast_udptl_new_with_bindaddr (struct sched_context *sched, struct io_context *io, int callbackmode, struct in_addr in) |
| int | ast_udptl_proto_register (struct ast_udptl_protocol *proto) |
| void | ast_udptl_proto_unregister (struct ast_udptl_protocol *proto) |
| struct ast_frame * | ast_udptl_read (struct ast_udptl *udptl) |
| int | ast_udptl_reload (void) |
| void | ast_udptl_reset (struct ast_udptl *udptl) |
| void | ast_udptl_set_callback (struct ast_udptl *udptl, ast_udptl_callback callback) |
| void | ast_udptl_set_data (struct ast_udptl *udptl, void *data) |
| void | ast_udptl_set_error_correction_scheme (struct ast_udptl *udptl, enum ast_t38_ec_modes ec) |
| void | ast_udptl_set_far_max_datagram (struct ast_udptl *udptl, unsigned int max_datagram) |
| void | ast_udptl_set_local_max_ifp (struct ast_udptl *udptl, unsigned int max_ifp) |
| void | ast_udptl_set_m_type (struct ast_udptl *udptl, unsigned int pt) |
| void | ast_udptl_set_peer (struct ast_udptl *udptl, const struct sockaddr_in *them) |
| void | ast_udptl_set_udptlmap_type (struct ast_udptl *udptl, unsigned int pt, char *mimeType, char *mimeSubtype) |
| void | ast_udptl_setnat (struct ast_udptl *udptl, int nat) |
| int | ast_udptl_setqos (struct ast_udptl *udptl, unsigned int tos, unsigned int cos) |
| void | ast_udptl_stop (struct ast_udptl *udptl) |
| int | ast_udptl_write (struct ast_udptl *udptl, struct ast_frame *f) |
UDPTL support for T.38.
Definition in file udptl.h.
| typedef int(* ast_udptl_callback)(struct ast_udptl *udptl, struct ast_frame *f, void *data) |
| enum ast_t38_ec_modes |
| UDPTL_ERROR_CORRECTION_NONE | |
| UDPTL_ERROR_CORRECTION_FEC | |
| UDPTL_ERROR_CORRECTION_REDUNDANCY |
Definition at line 36 of file udptl.h.
00036 { 00037 UDPTL_ERROR_CORRECTION_NONE, 00038 UDPTL_ERROR_CORRECTION_FEC, 00039 UDPTL_ERROR_CORRECTION_REDUNDANCY 00040 };
| int ast_udptl_bridge | ( | struct ast_channel * | c0, | |
| struct ast_channel * | c1, | |||
| int | flags, | |||
| struct ast_frame ** | fo, | |||
| struct ast_channel ** | rc | |||
| ) |
Definition at line 1065 of file udptl.c.
References ast_channel_lock, ast_channel_trylock, ast_channel_unlock, ast_check_hangup(), ast_debug, AST_FRAME_MODEM, ast_frfree, ast_inet_ntoa(), ast_log(), ast_read(), ast_udptl_get_peer(), ast_waitfor_n(), ast_write(), f, ast_frame::frametype, get_proto(), ast_udptl_protocol::get_udptl_info, inaddrcmp(), LOG_WARNING, ast_channel::masq, ast_channel::masqr, ast_udptl_protocol::set_udptl_peer, and ast_channel::tech_pvt.
01066 { 01067 struct ast_frame *f; 01068 struct ast_channel *who; 01069 struct ast_channel *cs[3]; 01070 struct ast_udptl *p0; 01071 struct ast_udptl *p1; 01072 struct ast_udptl_protocol *pr0; 01073 struct ast_udptl_protocol *pr1; 01074 struct sockaddr_in ac0; 01075 struct sockaddr_in ac1; 01076 struct sockaddr_in t0; 01077 struct sockaddr_in t1; 01078 void *pvt0; 01079 void *pvt1; 01080 int to; 01081 01082 ast_channel_lock(c0); 01083 while (ast_channel_trylock(c1)) { 01084 ast_channel_unlock(c0); 01085 usleep(1); 01086 ast_channel_lock(c0); 01087 } 01088 pr0 = get_proto(c0); 01089 pr1 = get_proto(c1); 01090 if (!pr0) { 01091 ast_log(LOG_WARNING, "Can't find native functions for channel '%s'\n", c0->name); 01092 ast_channel_unlock(c0); 01093 ast_channel_unlock(c1); 01094 return -1; 01095 } 01096 if (!pr1) { 01097 ast_log(LOG_WARNING, "Can't find native functions for channel '%s'\n", c1->name); 01098 ast_channel_unlock(c0); 01099 ast_channel_unlock(c1); 01100 return -1; 01101 } 01102 pvt0 = c0->tech_pvt; 01103 pvt1 = c1->tech_pvt; 01104 p0 = pr0->get_udptl_info(c0); 01105 p1 = pr1->get_udptl_info(c1); 01106 if (!p0 || !p1) { 01107 /* Somebody doesn't want to play... */ 01108 ast_channel_unlock(c0); 01109 ast_channel_unlock(c1); 01110 return -2; 01111 } 01112 if (pr0->set_udptl_peer(c0, p1)) { 01113 ast_log(LOG_WARNING, "Channel '%s' failed to talk to '%s'\n", c0->name, c1->name); 01114 memset(&ac1, 0, sizeof(ac1)); 01115 } else { 01116 /* Store UDPTL peer */ 01117 ast_udptl_get_peer(p1, &ac1); 01118 } 01119 if (pr1->set_udptl_peer(c1, p0)) { 01120 ast_log(LOG_WARNING, "Channel '%s' failed to talk back to '%s'\n", c1->name, c0->name); 01121 memset(&ac0, 0, sizeof(ac0)); 01122 } else { 01123 /* Store UDPTL peer */ 01124 ast_udptl_get_peer(p0, &ac0); 01125 } 01126 ast_channel_unlock(c0); 01127 ast_channel_unlock(c1); 01128 cs[0] = c0; 01129 cs[1] = c1; 01130 cs[2] = NULL; 01131 for (;;) { 01132 if ((c0->tech_pvt != pvt0) || 01133 (c1->tech_pvt != pvt1) || 01134 (c0->masq || c0->masqr || c1->masq || c1->masqr)) { 01135 ast_debug(1, "Oooh, something is weird, backing out\n"); 01136 /* Tell it to try again later */ 01137 return -3; 01138 } 01139 to = -1; 01140 ast_udptl_get_peer(p1, &t1); 01141 ast_udptl_get_peer(p0, &t0); 01142 if (inaddrcmp(&t1, &ac1)) { 01143 ast_debug(1, "Oooh, '%s' changed end address to %s:%d\n", 01144 c1->name, ast_inet_ntoa(t1.sin_addr), ntohs(t1.sin_port)); 01145 ast_debug(1, "Oooh, '%s' was %s:%d\n", 01146 c1->name, ast_inet_ntoa(ac1.sin_addr), ntohs(ac1.sin_port)); 01147 memcpy(&ac1, &t1, sizeof(ac1)); 01148 } 01149 if (inaddrcmp(&t0, &ac0)) { 01150 ast_debug(1, "Oooh, '%s' changed end address to %s:%d\n", 01151 c0->name, ast_inet_ntoa(t0.sin_addr), ntohs(t0.sin_port)); 01152 ast_debug(1, "Oooh, '%s' was %s:%d\n", 01153 c0->name, ast_inet_ntoa(ac0.sin_addr), ntohs(ac0.sin_port)); 01154 memcpy(&ac0, &t0, sizeof(ac0)); 01155 } 01156 who = ast_waitfor_n(cs, 2, &to); 01157 if (!who) { 01158 ast_debug(1, "Ooh, empty read...\n"); 01159 /* check for hangup / whentohangup */ 01160 if (ast_check_hangup(c0) || ast_check_hangup(c1)) 01161 break; 01162 continue; 01163 } 01164 f = ast_read(who); 01165 if (!f) { 01166 *fo = f; 01167 *rc = who; 01168 ast_debug(1, "Oooh, got a %s\n", f ? "digit" : "hangup"); 01169 /* That's all we needed */ 01170 return 0; 01171 } else { 01172 if (f->frametype == AST_FRAME_MODEM) { 01173 /* Forward T.38 frames if they happen upon us */ 01174 if (who == c0) { 01175 ast_write(c1, f); 01176 } else if (who == c1) { 01177 ast_write(c0, f); 01178 } 01179 } 01180 ast_frfree(f); 01181 } 01182 /* Swap priority. Not that it's a big deal at this point */ 01183 cs[2] = cs[0]; 01184 cs[0] = cs[1]; 01185 cs[1] = cs[2]; 01186 } 01187 return -1; 01188 }
| void ast_udptl_destroy | ( | struct ast_udptl * | udptl | ) |
Definition at line 972 of file udptl.c.
References ast_free, ast_io_remove(), ast_udptl::fd, ast_udptl::io, and ast_udptl::ioid.
Referenced by __sip_destroy(), and create_addr_from_peer().
| int ast_udptl_fd | ( | const struct ast_udptl * | udptl | ) |
Definition at line 630 of file udptl.c.
References ast_udptl::fd.
Referenced by __oh323_new(), and sip_new().
00631 { 00632 return udptl->fd; 00633 }
| enum ast_t38_ec_modes ast_udptl_get_error_correction_scheme | ( | const struct ast_udptl * | udptl | ) |
Definition at line 777 of file udptl.c.
References ast_log(), ast_udptl::error_correction_scheme, and LOG_WARNING.
Referenced by add_sdp().
00778 { 00779 if (udptl) 00780 return udptl->error_correction_scheme; 00781 else { 00782 ast_log(LOG_WARNING, "udptl structure is null\n"); 00783 return -1; 00784 } 00785 }
| unsigned int ast_udptl_get_far_max_datagram | ( | const struct ast_udptl * | udptl | ) |
Definition at line 827 of file udptl.c.
References ast_log(), ast_udptl::far_max_datagram, and LOG_WARNING.
00828 { 00829 if (udptl) 00830 return udptl->far_max_datagram; 00831 else { 00832 ast_log(LOG_WARNING, "udptl structure is null\n"); 00833 return 0; 00834 } 00835 }
| unsigned int ast_udptl_get_far_max_ifp | ( | const struct ast_udptl * | udptl | ) |
Definition at line 853 of file udptl.c.
References ast_udptl::far_max_ifp.
Referenced by change_t38_state().
00854 { 00855 return udptl->far_max_ifp; 00856 }
| unsigned int ast_udptl_get_local_max_datagram | ( | const struct ast_udptl * | udptl | ) |
Definition at line 817 of file udptl.c.
References ast_log(), ast_udptl::local_max_datagram, and LOG_WARNING.
Referenced by add_sdp().
00818 { 00819 if (udptl) 00820 return udptl->local_max_datagram; 00821 else { 00822 ast_log(LOG_WARNING, "udptl structure is null\n"); 00823 return 0; 00824 } 00825 }
| void ast_udptl_get_peer | ( | const struct ast_udptl * | udptl, | |
| struct sockaddr_in * | them | |||
| ) |
Definition at line 953 of file udptl.c.
References ast_udptl::them.
Referenced by ast_udptl_bridge(), and sip_set_udptl_peer().
| void ast_udptl_get_us | ( | const struct ast_udptl * | udptl, | |
| struct sockaddr_in * | us | |||
| ) |
| void ast_udptl_init | ( | void | ) |
Definition at line 1435 of file udptl.c.
References __ast_udptl_reload(), and ast_cli_register_multiple().
Referenced by main().
01436 { 01437 ast_cli_register_multiple(cli_udptl, sizeof(cli_udptl) / sizeof(struct ast_cli_entry)); 01438 __ast_udptl_reload(0); 01439 }
| struct ast_udptl* ast_udptl_new | ( | struct sched_context * | sched, | |
| struct io_context * | io, | |||
| int | callbackmode | |||
| ) | [read] |
Definition at line 935 of file udptl.c.
References ast_udptl_new_with_bindaddr().
00936 { 00937 struct in_addr ia; 00938 memset(&ia, 0, sizeof(ia)); 00939 return ast_udptl_new_with_bindaddr(sched, io, callbackmode, ia); 00940 }
| struct ast_udptl* ast_udptl_new_with_bindaddr | ( | struct sched_context * | sched, | |
| struct io_context * | io, | |||
| int | callbackmode, | |||
| struct in_addr | in | |||
| ) | [read] |
Definition at line 858 of file udptl.c.
References ast_calloc, ast_free, ast_io_add(), AST_IO_IN, ast_log(), ast_random(), udptl_fec_tx_buffer_t::buf_len, udptl_fec_rx_buffer_t::buf_len, errno, ast_udptl::error_correction_entries, ast_udptl::error_correction_scheme, ast_udptl::error_correction_span, ast_udptl::far_max_datagram, ast_udptl::fd, ast_udptl::flags, ast_udptl::io, ast_udptl::ioid, ast_udptl::local_max_datagram, LOG_WARNING, ast_udptl::rx, ast_udptl::sched, ast_udptl::them, ast_udptl::tx, UDPTL_BUF_MASK, udptlread(), and ast_udptl::us.
Referenced by ast_udptl_new(), create_addr_from_peer(), handle_request_invite(), and sip_alloc().
00859 { 00860 struct ast_udptl *udptl; 00861 int x; 00862 int startplace; 00863 int i; 00864 long int flags; 00865 00866 if (!(udptl = ast_calloc(1, sizeof(*udptl)))) 00867 return NULL; 00868 00869 udptl->error_correction_scheme = udptlfectype; 00870 udptl->error_correction_span = udptlfecspan; 00871 udptl->error_correction_entries = udptlfecentries; 00872 00873 udptl->far_max_datagram = udptlmaxdatagram; 00874 udptl->local_max_datagram = udptlmaxdatagram; 00875 00876 for (i = 0; i <= UDPTL_BUF_MASK; i++) { 00877 udptl->rx[i].buf_len = -1; 00878 udptl->tx[i].buf_len = -1; 00879 } 00880 00881 udptl->them.sin_family = AF_INET; 00882 udptl->us.sin_family = AF_INET; 00883 00884 if ((udptl->fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { 00885 ast_free(udptl); 00886 ast_log(LOG_WARNING, "Unable to allocate socket: %s\n", strerror(errno)); 00887 return NULL; 00888 } 00889 flags = fcntl(udptl->fd, F_GETFL); 00890 fcntl(udptl->fd, F_SETFL, flags | O_NONBLOCK); 00891 #ifdef SO_NO_CHECK 00892 if (nochecksums) 00893 setsockopt(udptl->fd, SOL_SOCKET, SO_NO_CHECK, &nochecksums, sizeof(nochecksums)); 00894 #endif 00895 /* Find us a place */ 00896 x = (udptlstart == udptlend) ? udptlstart : (ast_random() % (udptlend - udptlstart)) + udptlstart; 00897 if (use_even_ports && (x & 1)) { 00898 ++x; 00899 } 00900 startplace = x; 00901 for (;;) { 00902 udptl->us.sin_port = htons(x); 00903 udptl->us.sin_addr = addr; 00904 if (bind(udptl->fd, (struct sockaddr *) &udptl->us, sizeof(udptl->us)) == 0) 00905 break; 00906 if (errno != EADDRINUSE) { 00907 ast_log(LOG_WARNING, "Unexpected bind error: %s\n", strerror(errno)); 00908 close(udptl->fd); 00909 ast_free(udptl); 00910 return NULL; 00911 } 00912 if (use_even_ports) { 00913 x += 2; 00914 } else { 00915 ++x; 00916 } 00917 if (x > udptlend) 00918 x = udptlstart; 00919 if (x == startplace) { 00920 ast_log(LOG_WARNING, "No UDPTL ports remaining\n"); 00921 close(udptl->fd); 00922 ast_free(udptl); 00923 return NULL; 00924 } 00925 } 00926 if (io && sched && callbackmode) { 00927 /* Operate this one in a callback mode */ 00928 udptl->sched = sched; 00929 udptl->io = io; 00930 udptl->ioid = ast_io_add(udptl->io, udptl->fd, udptlread, AST_IO_IN, udptl); 00931 } 00932 return udptl; 00933 }
| int ast_udptl_proto_register | ( | struct ast_udptl_protocol * | proto | ) |
Definition at line 1034 of file udptl.c.
References ast_log(), AST_RWLIST_INSERT_TAIL, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_udptl_protocol::list, LOG_WARNING, and ast_udptl_protocol::type.
Referenced by load_module().
01035 { 01036 struct ast_udptl_protocol *cur; 01037 01038 AST_RWLIST_WRLOCK(&protos); 01039 AST_RWLIST_TRAVERSE(&protos, cur, list) { 01040 if (cur->type == proto->type) { 01041 ast_log(LOG_WARNING, "Tried to register same protocol '%s' twice\n", cur->type); 01042 AST_RWLIST_UNLOCK(&protos); 01043 return -1; 01044 } 01045 } 01046 AST_RWLIST_INSERT_TAIL(&protos, proto, list); 01047 AST_RWLIST_UNLOCK(&protos); 01048 return 0; 01049 }
| void ast_udptl_proto_unregister | ( | struct ast_udptl_protocol * | proto | ) |
Definition at line 1027 of file udptl.c.
References AST_RWLIST_REMOVE, AST_RWLIST_UNLOCK, and AST_RWLIST_WRLOCK.
Referenced by unload_module().
01028 { 01029 AST_RWLIST_WRLOCK(&protos); 01030 AST_RWLIST_REMOVE(&protos, proto, list); 01031 AST_RWLIST_UNLOCK(&protos); 01032 }
Definition at line 662 of file udptl.c.
References ast_assert, ast_debug, AST_FRIENDLY_OFFSET, ast_inet_ntoa(), ast_log(), ast_null_frame, ast_verb, errno, ast_udptl::f, ast_udptl::fd, len(), LOG_WARNING, ast_udptl::nat, ast_udptl::rawdata, ast_udptl::them, udptl_debug_test_addr(), and udptl_rx_packet().
Referenced by sip_rtp_read(), skinny_rtp_read(), and udptlread().
00663 { 00664 int res; 00665 struct sockaddr_in sin; 00666 socklen_t len; 00667 uint16_t seqno = 0; 00668 uint16_t *udptlheader; 00669 00670 len = sizeof(sin); 00671 00672 /* Cache where the header will go */ 00673 res = recvfrom(udptl->fd, 00674 udptl->rawdata + AST_FRIENDLY_OFFSET, 00675 sizeof(udptl->rawdata) - AST_FRIENDLY_OFFSET, 00676 0, 00677 (struct sockaddr *) &sin, 00678 &len); 00679 udptlheader = (uint16_t *)(udptl->rawdata + AST_FRIENDLY_OFFSET); 00680 if (res < 0) { 00681 if (errno != EAGAIN) 00682 ast_log(LOG_WARNING, "UDPTL read error: %s\n", strerror(errno)); 00683 ast_assert(errno != EBADF); 00684 return &ast_null_frame; 00685 } 00686 00687 /* Ignore if the other side hasn't been given an address yet. */ 00688 if (!udptl->them.sin_addr.s_addr || !udptl->them.sin_port) 00689 return &ast_null_frame; 00690 00691 if (udptl->nat) { 00692 /* Send to whoever sent to us */ 00693 if ((udptl->them.sin_addr.s_addr != sin.sin_addr.s_addr) || 00694 (udptl->them.sin_port != sin.sin_port)) { 00695 memcpy(&udptl->them, &sin, sizeof(udptl->them)); 00696 ast_debug(1, "UDPTL NAT: Using address %s:%d\n", ast_inet_ntoa(udptl->them.sin_addr), ntohs(udptl->them.sin_port)); 00697 } 00698 } 00699 00700 if (udptl_debug_test_addr(&sin)) { 00701 ast_verb(1, "Got UDPTL packet from %s:%d (type %d, seq %d, len %d)\n", 00702 ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port), 0, seqno, res); 00703 } 00704 #if 0 00705 printf("Got UDPTL packet from %s:%d (seq %d, len = %d)\n", ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port), seqno, res); 00706 #endif 00707 if (udptl_rx_packet(udptl, udptl->rawdata + AST_FRIENDLY_OFFSET, res) < 1) 00708 return &ast_null_frame; 00709 00710 return &udptl->f[0]; 00711 }
| int ast_udptl_reload | ( | void | ) |
Definition at line 1429 of file udptl.c.
References __ast_udptl_reload().
01430 { 01431 __ast_udptl_reload(1); 01432 return 0; 01433 }
| void ast_udptl_reset | ( | struct ast_udptl * | udptl | ) |
| void ast_udptl_set_callback | ( | struct ast_udptl * | udptl, | |
| ast_udptl_callback | callback | |||
| ) |
Definition at line 640 of file udptl.c.
References ast_udptl::callback.
00641 { 00642 udptl->callback = callback; 00643 }
| void ast_udptl_set_data | ( | struct ast_udptl * | udptl, | |
| void * | data | |||
| ) |
Definition at line 635 of file udptl.c.
References ast_udptl::data.
00636 { 00637 udptl->data = data; 00638 }
| void ast_udptl_set_error_correction_scheme | ( | struct ast_udptl * | udptl, | |
| enum ast_t38_ec_modes | ec | |||
| ) |
Definition at line 787 of file udptl.c.
References ast_log(), calculate_far_max_ifp(), calculate_local_max_datagram(), ast_udptl::error_correction_entries, ast_udptl::error_correction_scheme, ast_udptl::error_correction_span, LOG_WARNING, UDPTL_ERROR_CORRECTION_FEC, and UDPTL_ERROR_CORRECTION_REDUNDANCY.
Referenced by process_sdp(), and set_t38_capabilities().
00788 { 00789 if (udptl) { 00790 udptl->error_correction_scheme = ec; 00791 switch (ec) { 00792 case UDPTL_ERROR_CORRECTION_FEC: 00793 udptl->error_correction_scheme = UDPTL_ERROR_CORRECTION_FEC; 00794 if (udptl->error_correction_entries == 0) { 00795 udptl->error_correction_entries = 3; 00796 } 00797 if (udptl->error_correction_span == 0) { 00798 udptl->error_correction_span = 3; 00799 } 00800 break; 00801 case UDPTL_ERROR_CORRECTION_REDUNDANCY: 00802 udptl->error_correction_scheme = UDPTL_ERROR_CORRECTION_REDUNDANCY; 00803 if (udptl->error_correction_entries == 0) { 00804 udptl->error_correction_entries = 3; 00805 } 00806 break; 00807 default: 00808 /* nothing to do */ 00809 break; 00810 }; 00811 calculate_local_max_datagram(udptl); 00812 calculate_far_max_ifp(udptl); 00813 } else 00814 ast_log(LOG_WARNING, "udptl structure is null\n"); 00815 }
| void ast_udptl_set_far_max_datagram | ( | struct ast_udptl * | udptl, | |
| unsigned int | max_datagram | |||
| ) |
Definition at line 837 of file udptl.c.
References ast_log(), calculate_far_max_ifp(), ast_udptl::far_max_datagram, and LOG_WARNING.
Referenced by process_sdp().
00838 { 00839 if (udptl) { 00840 udptl->far_max_datagram = max_datagram; 00841 calculate_far_max_ifp(udptl); 00842 } else { 00843 ast_log(LOG_WARNING, "udptl structure is null\n"); 00844 } 00845 }
| void ast_udptl_set_local_max_ifp | ( | struct ast_udptl * | udptl, | |
| unsigned int | max_ifp | |||
| ) |
Definition at line 847 of file udptl.c.
References calculate_local_max_datagram(), and ast_udptl::local_max_ifp.
Referenced by interpret_t38_parameters().
00848 { 00849 udptl->local_max_ifp = max_ifp; 00850 calculate_local_max_datagram(udptl); 00851 }
| void ast_udptl_set_m_type | ( | struct ast_udptl * | udptl, | |
| unsigned int | pt | |||
| ) |
| void ast_udptl_set_peer | ( | struct ast_udptl * | udptl, | |
| const struct sockaddr_in * | them | |||
| ) |
| void ast_udptl_set_udptlmap_type | ( | struct ast_udptl * | udptl, | |
| unsigned int | pt, | |||
| char * | mimeType, | |||
| char * | mimeSubtype | |||
| ) |
| void ast_udptl_setnat | ( | struct ast_udptl * | udptl, | |
| int | nat | |||
| ) |
| int ast_udptl_setqos | ( | struct ast_udptl * | udptl, | |
| unsigned int | tos, | |||
| unsigned int | cos | |||
| ) |
Definition at line 942 of file udptl.c.
References ast_netsock_set_qos(), and ast_udptl::fd.
Referenced by sip_alloc().
00943 { 00944 return ast_netsock_set_qos(udptl->fd, tos, cos, "UDPTL"); 00945 }
| void ast_udptl_stop | ( | struct ast_udptl * | udptl | ) |
Definition at line 966 of file udptl.c.
References ast_udptl::them.
Referenced by process_sdp(), and stop_media_flows().
Definition at line 981 of file udptl.c.
References AST_FRAME_MODEM, ast_inet_ntoa(), ast_log(), AST_MODEM_T38, ast_verb, buf, ast_frame::data, ast_frame::datalen, errno, ast_udptl::far_max_datagram, ast_udptl::far_max_ifp, ast_udptl::fd, ast_frame::frametype, len(), LOG_NOTICE, LOG_WARNING, ast_frame::ptr, seq, ast_frame::subclass, ast_udptl::them, ast_udptl::tx_seq_no, udptl_build_packet(), and udptl_debug_test_addr().
Referenced by sip_write().
00982 { 00983 unsigned int seq; 00984 unsigned int len; 00985 int res; 00986 uint8_t buf[s->far_max_datagram]; 00987 00988 /* If we have no peer, return immediately */ 00989 if (s->them.sin_addr.s_addr == INADDR_ANY) 00990 return 0; 00991 00992 /* If there is no data length, return immediately */ 00993 if (f->datalen == 0) 00994 return 0; 00995 00996 if ((f->frametype != AST_FRAME_MODEM) || 00997 (f->subclass != AST_MODEM_T38)) { 00998 ast_log(LOG_WARNING, "UDPTL can only send T.38 data.\n"); 00999 return -1; 01000 } 01001 01002 if (f->datalen > s->far_max_ifp) { 01003 ast_log(LOG_WARNING, "UDPTL asked to send %d bytes of IFP when far end only prepared to accept %d bytes; data loss may occur.\n", f->datalen, s->far_max_ifp); 01004 } 01005 01006 /* Save seq_no for debug output because udptl_build_packet increments it */ 01007 seq = s->tx_seq_no & 0xFFFF; 01008 01009 /* Cook up the UDPTL packet, with the relevant EC info. */ 01010 len = udptl_build_packet(s, buf, sizeof(buf), f->data.ptr, f->datalen); 01011 01012 if (len > 0 && s->them.sin_port && s->them.sin_addr.s_addr) { 01013 if ((res = sendto(s->fd, buf, len, 0, (struct sockaddr *) &s->them, sizeof(s->them))) < 0) 01014 ast_log(LOG_NOTICE, "UDPTL Transmission error to %s:%d: %s\n", ast_inet_ntoa(s->them.sin_addr), ntohs(s->them.sin_port), strerror(errno)); 01015 #if 0 01016 printf("Sent %d bytes of UDPTL data to %s:%d\n", res, ast_inet_ntoa(udptl->them.sin_addr), ntohs(udptl->them.sin_port)); 01017 #endif 01018 if (udptl_debug_test_addr(&s->them)) 01019 ast_verb(1, "Sent UDPTL packet to %s:%d (type %d, seq %d, len %d)\n", 01020 ast_inet_ntoa(s->them.sin_addr), 01021 ntohs(s->them.sin_port), 0, seq, len); 01022 } 01023 01024 return 0; 01025 }
1.6.1