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 (struct ast_udptl *udptl) |
| retrieves far max ifp | |
| unsigned int | ast_udptl_get_local_max_datagram (struct ast_udptl *udptl) |
| retrieves local_max_datagram. | |
| 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) |
| sets far max datagram size. If max_datagram is = 0, the far max datagram size is set to a default value. | |
| 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_tag (struct ast_udptl *udptl, const char *format,...) |
| Associates a character string 'tag' with a UDPTL session. | |
| 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 1143 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.
01144 { 01145 struct ast_frame *f; 01146 struct ast_channel *who; 01147 struct ast_channel *cs[3]; 01148 struct ast_udptl *p0; 01149 struct ast_udptl *p1; 01150 struct ast_udptl_protocol *pr0; 01151 struct ast_udptl_protocol *pr1; 01152 struct sockaddr_in ac0; 01153 struct sockaddr_in ac1; 01154 struct sockaddr_in t0; 01155 struct sockaddr_in t1; 01156 void *pvt0; 01157 void *pvt1; 01158 int to; 01159 01160 ast_channel_lock(c0); 01161 while (ast_channel_trylock(c1)) { 01162 ast_channel_unlock(c0); 01163 usleep(1); 01164 ast_channel_lock(c0); 01165 } 01166 pr0 = get_proto(c0); 01167 pr1 = get_proto(c1); 01168 if (!pr0) { 01169 ast_log(LOG_WARNING, "Can't find native functions for channel '%s'\n", c0->name); 01170 ast_channel_unlock(c0); 01171 ast_channel_unlock(c1); 01172 return -1; 01173 } 01174 if (!pr1) { 01175 ast_log(LOG_WARNING, "Can't find native functions for channel '%s'\n", c1->name); 01176 ast_channel_unlock(c0); 01177 ast_channel_unlock(c1); 01178 return -1; 01179 } 01180 pvt0 = c0->tech_pvt; 01181 pvt1 = c1->tech_pvt; 01182 p0 = pr0->get_udptl_info(c0); 01183 p1 = pr1->get_udptl_info(c1); 01184 if (!p0 || !p1) { 01185 /* Somebody doesn't want to play... */ 01186 ast_channel_unlock(c0); 01187 ast_channel_unlock(c1); 01188 return -2; 01189 } 01190 if (pr0->set_udptl_peer(c0, p1)) { 01191 ast_log(LOG_WARNING, "Channel '%s' failed to talk to '%s'\n", c0->name, c1->name); 01192 memset(&ac1, 0, sizeof(ac1)); 01193 } else { 01194 /* Store UDPTL peer */ 01195 ast_udptl_get_peer(p1, &ac1); 01196 } 01197 if (pr1->set_udptl_peer(c1, p0)) { 01198 ast_log(LOG_WARNING, "Channel '%s' failed to talk back to '%s'\n", c1->name, c0->name); 01199 memset(&ac0, 0, sizeof(ac0)); 01200 } else { 01201 /* Store UDPTL peer */ 01202 ast_udptl_get_peer(p0, &ac0); 01203 } 01204 ast_channel_unlock(c0); 01205 ast_channel_unlock(c1); 01206 cs[0] = c0; 01207 cs[1] = c1; 01208 cs[2] = NULL; 01209 for (;;) { 01210 if ((c0->tech_pvt != pvt0) || 01211 (c1->tech_pvt != pvt1) || 01212 (c0->masq || c0->masqr || c1->masq || c1->masqr)) { 01213 ast_debug(1, "Oooh, something is weird, backing out\n"); 01214 /* Tell it to try again later */ 01215 return -3; 01216 } 01217 to = -1; 01218 ast_udptl_get_peer(p1, &t1); 01219 ast_udptl_get_peer(p0, &t0); 01220 if (inaddrcmp(&t1, &ac1)) { 01221 ast_debug(1, "Oooh, '%s' changed end address to %s:%d\n", 01222 c1->name, ast_inet_ntoa(t1.sin_addr), ntohs(t1.sin_port)); 01223 ast_debug(1, "Oooh, '%s' was %s:%d\n", 01224 c1->name, ast_inet_ntoa(ac1.sin_addr), ntohs(ac1.sin_port)); 01225 memcpy(&ac1, &t1, sizeof(ac1)); 01226 } 01227 if (inaddrcmp(&t0, &ac0)) { 01228 ast_debug(1, "Oooh, '%s' changed end address to %s:%d\n", 01229 c0->name, ast_inet_ntoa(t0.sin_addr), ntohs(t0.sin_port)); 01230 ast_debug(1, "Oooh, '%s' was %s:%d\n", 01231 c0->name, ast_inet_ntoa(ac0.sin_addr), ntohs(ac0.sin_port)); 01232 memcpy(&ac0, &t0, sizeof(ac0)); 01233 } 01234 who = ast_waitfor_n(cs, 2, &to); 01235 if (!who) { 01236 ast_debug(1, "Ooh, empty read...\n"); 01237 /* check for hangup / whentohangup */ 01238 if (ast_check_hangup(c0) || ast_check_hangup(c1)) 01239 break; 01240 continue; 01241 } 01242 f = ast_read(who); 01243 if (!f) { 01244 *fo = f; 01245 *rc = who; 01246 ast_debug(1, "Oooh, got a %s\n", f ? "digit" : "hangup"); 01247 /* That's all we needed */ 01248 return 0; 01249 } else { 01250 if (f->frametype == AST_FRAME_MODEM) { 01251 /* Forward T.38 frames if they happen upon us */ 01252 if (who == c0) { 01253 ast_write(c1, f); 01254 } else if (who == c1) { 01255 ast_write(c0, f); 01256 } 01257 } 01258 ast_frfree(f); 01259 } 01260 /* Swap priority. Not that it's a big deal at this point */ 01261 cs[2] = cs[0]; 01262 cs[0] = cs[1]; 01263 cs[1] = cs[2]; 01264 } 01265 return -1; 01266 }
| void ast_udptl_destroy | ( | struct ast_udptl * | udptl | ) |
Definition at line 1042 of file udptl.c.
References ast_free, ast_io_remove(), ast_udptl::fd, ast_udptl::io, ast_udptl::ioid, and ast_udptl::tag.
Referenced by __sip_destroy(), and create_addr_from_peer().
| int ast_udptl_fd | ( | const struct ast_udptl * | udptl | ) |
Definition at line 640 of file udptl.c.
References ast_udptl::fd.
Referenced by __oh323_new(), and sip_new().
00641 { 00642 return udptl->fd; 00643 }
| enum ast_t38_ec_modes ast_udptl_get_error_correction_scheme | ( | const struct ast_udptl * | udptl | ) |
Definition at line 824 of file udptl.c.
References ast_udptl::error_correction_scheme.
Referenced by add_sdp().
00825 { 00826 return udptl->error_correction_scheme; 00827 }
| unsigned int ast_udptl_get_far_max_datagram | ( | const struct ast_udptl * | udptl | ) |
Definition at line 892 of file udptl.c.
References ast_udptl::far_max_datagram.
Referenced by process_sdp().
00893 { 00894 if (udptl->far_max_datagram < 0) { 00895 return 0; 00896 } 00897 return udptl->far_max_datagram; 00898 }
| unsigned int ast_udptl_get_far_max_ifp | ( | struct ast_udptl * | udptl | ) |
retrieves far max ifp
| positive | value representing max ifp size | |
| 0 | if no value is present |
Definition at line 900 of file udptl.c.
References calculate_far_max_ifp(), and ast_udptl::far_max_ifp.
Referenced by change_t38_state().
00901 { 00902 if (udptl->far_max_ifp == -1) { 00903 calculate_far_max_ifp(udptl); 00904 } 00905 00906 if (udptl->far_max_ifp < 0) { 00907 return 0; 00908 } 00909 return udptl->far_max_ifp; 00910 }
| unsigned int ast_udptl_get_local_max_datagram | ( | struct ast_udptl * | udptl | ) |
retrieves local_max_datagram.
| positive | value representing max datagram size. | |
| 0 | if no value is present |
Definition at line 868 of file udptl.c.
References calculate_local_max_datagram(), and ast_udptl::local_max_datagram.
Referenced by add_sdp().
00869 { 00870 if (udptl->local_max_datagram == -1) { 00871 calculate_local_max_datagram(udptl); 00872 } 00873 00874 /* this function expects a unsigned value in return. */ 00875 if (udptl->local_max_datagram < 0) { 00876 return 0; 00877 } 00878 return udptl->local_max_datagram; 00879 }
| void ast_udptl_get_peer | ( | const struct ast_udptl * | udptl, | |
| struct sockaddr_in * | them | |||
| ) |
Definition at line 1023 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 1500 of file udptl.c.
References __ast_udptl_reload(), and ast_cli_register_multiple().
Referenced by main().
01501 { 01502 ast_cli_register_multiple(cli_udptl, sizeof(cli_udptl) / sizeof(struct ast_cli_entry)); 01503 __ast_udptl_reload(0); 01504 }
| struct ast_udptl* ast_udptl_new | ( | struct sched_context * | sched, | |
| struct io_context * | io, | |||
| int | callbackmode | |||
| ) | [read] |
Definition at line 990 of file udptl.c.
References ast_udptl_new_with_bindaddr().
00991 { 00992 struct in_addr ia; 00993 memset(&ia, 0, sizeof(ia)); 00994 return ast_udptl_new_with_bindaddr(sched, io, callbackmode, ia); 00995 }
| 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 912 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_span, ast_udptl::far_max_datagram, ast_udptl::far_max_ifp, ast_udptl::fd, ast_udptl::flags, ast_udptl::io, ast_udptl::ioid, ast_udptl::local_max_datagram, ast_udptl::local_max_ifp, 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().
00913 { 00914 struct ast_udptl *udptl; 00915 int x; 00916 int startplace; 00917 int i; 00918 long int flags; 00919 00920 if (!(udptl = ast_calloc(1, sizeof(*udptl)))) 00921 return NULL; 00922 00923 udptl->error_correction_span = udptlfecspan; 00924 udptl->error_correction_entries = udptlfecentries; 00925 00926 udptl->far_max_datagram = -1; 00927 udptl->far_max_ifp = -1; 00928 udptl->local_max_ifp = -1; 00929 udptl->local_max_datagram = -1; 00930 00931 for (i = 0; i <= UDPTL_BUF_MASK; i++) { 00932 udptl->rx[i].buf_len = -1; 00933 udptl->tx[i].buf_len = -1; 00934 } 00935 00936 udptl->them.sin_family = AF_INET; 00937 udptl->us.sin_family = AF_INET; 00938 00939 if ((udptl->fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { 00940 ast_free(udptl); 00941 ast_log(LOG_WARNING, "Unable to allocate socket: %s\n", strerror(errno)); 00942 return NULL; 00943 } 00944 flags = fcntl(udptl->fd, F_GETFL); 00945 fcntl(udptl->fd, F_SETFL, flags | O_NONBLOCK); 00946 #ifdef SO_NO_CHECK 00947 if (nochecksums) 00948 setsockopt(udptl->fd, SOL_SOCKET, SO_NO_CHECK, &nochecksums, sizeof(nochecksums)); 00949 #endif 00950 /* Find us a place */ 00951 x = (udptlstart == udptlend) ? udptlstart : (ast_random() % (udptlend - udptlstart)) + udptlstart; 00952 if (use_even_ports && (x & 1)) { 00953 ++x; 00954 } 00955 startplace = x; 00956 for (;;) { 00957 udptl->us.sin_port = htons(x); 00958 udptl->us.sin_addr = addr; 00959 if (bind(udptl->fd, (struct sockaddr *) &udptl->us, sizeof(udptl->us)) == 0) 00960 break; 00961 if (errno != EADDRINUSE) { 00962 ast_log(LOG_WARNING, "Unexpected bind error: %s\n", strerror(errno)); 00963 close(udptl->fd); 00964 ast_free(udptl); 00965 return NULL; 00966 } 00967 if (use_even_ports) { 00968 x += 2; 00969 } else { 00970 ++x; 00971 } 00972 if (x > udptlend) 00973 x = udptlstart; 00974 if (x == startplace) { 00975 ast_log(LOG_WARNING, "No UDPTL ports remaining\n"); 00976 close(udptl->fd); 00977 ast_free(udptl); 00978 return NULL; 00979 } 00980 } 00981 if (io && sched && callbackmode) { 00982 /* Operate this one in a callback mode */ 00983 udptl->sched = sched; 00984 udptl->io = io; 00985 udptl->ioid = ast_io_add(udptl->io, udptl->fd, udptlread, AST_IO_IN, udptl); 00986 } 00987 return udptl; 00988 }
| int ast_udptl_proto_register | ( | struct ast_udptl_protocol * | proto | ) |
Definition at line 1112 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().
01113 { 01114 struct ast_udptl_protocol *cur; 01115 01116 AST_RWLIST_WRLOCK(&protos); 01117 AST_RWLIST_TRAVERSE(&protos, cur, list) { 01118 if (cur->type == proto->type) { 01119 ast_log(LOG_WARNING, "Tried to register same protocol '%s' twice\n", cur->type); 01120 AST_RWLIST_UNLOCK(&protos); 01121 return -1; 01122 } 01123 } 01124 AST_RWLIST_INSERT_TAIL(&protos, proto, list); 01125 AST_RWLIST_UNLOCK(&protos); 01126 return 0; 01127 }
| void ast_udptl_proto_unregister | ( | struct ast_udptl_protocol * | proto | ) |
Definition at line 1105 of file udptl.c.
References AST_RWLIST_REMOVE, AST_RWLIST_UNLOCK, and AST_RWLIST_WRLOCK.
Referenced by unload_module().
01106 { 01107 AST_RWLIST_WRLOCK(&protos); 01108 AST_RWLIST_REMOVE(&protos, proto, list); 01109 AST_RWLIST_UNLOCK(&protos); 01110 }
Definition at line 672 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_TAG, 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().
00673 { 00674 int res; 00675 struct sockaddr_in sin; 00676 socklen_t len; 00677 uint16_t seqno = 0; 00678 uint16_t *udptlheader; 00679 00680 len = sizeof(sin); 00681 00682 /* Cache where the header will go */ 00683 res = recvfrom(udptl->fd, 00684 udptl->rawdata + AST_FRIENDLY_OFFSET, 00685 sizeof(udptl->rawdata) - AST_FRIENDLY_OFFSET, 00686 0, 00687 (struct sockaddr *) &sin, 00688 &len); 00689 udptlheader = (uint16_t *)(udptl->rawdata + AST_FRIENDLY_OFFSET); 00690 if (res < 0) { 00691 if (errno != EAGAIN) 00692 ast_log(LOG_WARNING, "(%s): UDPTL read error: %s\n", 00693 LOG_TAG(udptl), strerror(errno)); 00694 ast_assert(errno != EBADF); 00695 return &ast_null_frame; 00696 } 00697 00698 /* Ignore if the other side hasn't been given an address yet. */ 00699 if (!udptl->them.sin_addr.s_addr || !udptl->them.sin_port) 00700 return &ast_null_frame; 00701 00702 if (udptl->nat) { 00703 /* Send to whoever sent to us */ 00704 if ((udptl->them.sin_addr.s_addr != sin.sin_addr.s_addr) || 00705 (udptl->them.sin_port != sin.sin_port)) { 00706 memcpy(&udptl->them, &sin, sizeof(udptl->them)); 00707 ast_debug(1, "UDPTL NAT (%s): Using address %s:%d\n", 00708 LOG_TAG(udptl), ast_inet_ntoa(udptl->them.sin_addr), ntohs(udptl->them.sin_port)); 00709 } 00710 } 00711 00712 if (udptl_debug_test_addr(&sin)) { 00713 ast_verb(1, "UDPTL (%s): packet from %s:%d (type %d, seq %d, len %d)\n", 00714 LOG_TAG(udptl), ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port), 0, seqno, res); 00715 } 00716 if (udptl_rx_packet(udptl, udptl->rawdata + AST_FRIENDLY_OFFSET, res) < 1) 00717 return &ast_null_frame; 00718 00719 return &udptl->f[0]; 00720 }
| int ast_udptl_reload | ( | void | ) |
Definition at line 1494 of file udptl.c.
References __ast_udptl_reload().
01495 { 01496 __ast_udptl_reload(1); 01497 return 0; 01498 }
| void ast_udptl_reset | ( | struct ast_udptl * | udptl | ) |
| void ast_udptl_set_callback | ( | struct ast_udptl * | udptl, | |
| ast_udptl_callback | callback | |||
| ) |
Definition at line 650 of file udptl.c.
References ast_udptl::callback.
00651 { 00652 udptl->callback = callback; 00653 }
| void ast_udptl_set_data | ( | struct ast_udptl * | udptl, | |
| void * | data | |||
| ) |
Definition at line 645 of file udptl.c.
References ast_udptl::data.
00646 { 00647 udptl->data = data; 00648 }
| void ast_udptl_set_error_correction_scheme | ( | struct ast_udptl * | udptl, | |
| enum ast_t38_ec_modes | ec | |||
| ) |
Definition at line 829 of file udptl.c.
References ast_udptl::error_correction_entries, ast_udptl::error_correction_scheme, ast_udptl::error_correction_span, ast_udptl::far_max_ifp, ast_udptl::local_max_datagram, UDPTL_ERROR_CORRECTION_FEC, and UDPTL_ERROR_CORRECTION_REDUNDANCY.
Referenced by process_sdp_a_image(), and set_t38_capabilities().
00830 { 00831 udptl->error_correction_scheme = ec; 00832 switch (ec) { 00833 case UDPTL_ERROR_CORRECTION_FEC: 00834 udptl->error_correction_scheme = UDPTL_ERROR_CORRECTION_FEC; 00835 if (udptl->error_correction_entries == 0) { 00836 udptl->error_correction_entries = 3; 00837 } 00838 if (udptl->error_correction_span == 0) { 00839 udptl->error_correction_span = 3; 00840 } 00841 break; 00842 case UDPTL_ERROR_CORRECTION_REDUNDANCY: 00843 udptl->error_correction_scheme = UDPTL_ERROR_CORRECTION_REDUNDANCY; 00844 if (udptl->error_correction_entries == 0) { 00845 udptl->error_correction_entries = 3; 00846 } 00847 break; 00848 default: 00849 /* nothing to do */ 00850 break; 00851 }; 00852 /* reset calculated values so they'll be computed again */ 00853 udptl->local_max_datagram = -1; 00854 udptl->far_max_ifp = -1; 00855 }
| void ast_udptl_set_far_max_datagram | ( | struct ast_udptl * | udptl, | |
| unsigned int | max_datagram | |||
| ) |
sets far max datagram size. If max_datagram is = 0, the far max datagram size is set to a default value.
Definition at line 881 of file udptl.c.
References DEFAULT_FAX_MAX_DATAGRAM, ast_udptl::far_max_datagram, ast_udptl::far_max_ifp, and FAX_MAX_DATAGRAM_LIMIT.
Referenced by process_sdp(), and process_sdp_a_image().
00882 { 00883 if (!max_datagram || (max_datagram > FAX_MAX_DATAGRAM_LIMIT)) { 00884 udptl->far_max_datagram = DEFAULT_FAX_MAX_DATAGRAM; 00885 } else { 00886 udptl->far_max_datagram = max_datagram; 00887 } 00888 /* reset calculated values so they'll be computed again */ 00889 udptl->far_max_ifp = -1; 00890 }
| void ast_udptl_set_local_max_ifp | ( | struct ast_udptl * | udptl, | |
| unsigned int | max_ifp | |||
| ) |
Definition at line 857 of file udptl.c.
References ast_udptl::local_max_datagram, and ast_udptl::local_max_ifp.
Referenced by interpret_t38_parameters().
00858 { 00859 /* make sure max_ifp is a positive value since a cast will take place when 00860 * when setting local_max_ifp */ 00861 if ((signed int) max_ifp > 0) { 00862 udptl->local_max_ifp = max_ifp; 00863 /* reset calculated values so they'll be computed again */ 00864 udptl->local_max_datagram = -1; 00865 } 00866 }
| 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_tag | ( | struct ast_udptl * | udptl, | |
| const char * | format, | |||
| ... | ||||
| ) |
Associates a character string 'tag' with a UDPTL session.
| udptl | The UDPTL session. | |
| format | printf-style format string used to construct the tag |
This function formats a tag for the specified UDPTL session, so that any log messages generated by the UDPTL stack related to that session will include the tag and the reader of the messages will be able to identify which endpoint caused them to be generated.
| none |
Definition at line 997 of file udptl.c.
References ast_free, ast_vasprintf, and ast_udptl::tag.
Referenced by change_t38_state().
| 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 1012 of file udptl.c.
References ast_netsock_set_qos(), and ast_udptl::fd.
Referenced by sip_alloc().
01013 { 01014 return ast_netsock_set_qos(udptl->fd, tos, cos, "UDPTL"); 01015 }
| void ast_udptl_stop | ( | struct ast_udptl * | udptl | ) |
Definition at line 1036 of file udptl.c.
References ast_udptl::them.
Referenced by process_sdp(), and stop_media_flows().
Definition at line 1053 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, DEFAULT_FAX_MAX_DATAGRAM, errno, ast_udptl::far_max_datagram, ast_udptl::far_max_ifp, ast_udptl::fd, ast_frame::frametype, len(), LOG_NOTICE, LOG_TAG, 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().
01054 { 01055 unsigned int seq; 01056 unsigned int len = f->datalen; 01057 int res; 01058 /* if no max datagram size is provided, use default value */ 01059 const int bufsize = (s->far_max_datagram > 0) ? s->far_max_datagram : DEFAULT_FAX_MAX_DATAGRAM; 01060 uint8_t buf[bufsize]; 01061 01062 memset(buf, 0, sizeof(buf)); 01063 01064 /* If we have no peer, return immediately */ 01065 if (s->them.sin_addr.s_addr == INADDR_ANY) 01066 return 0; 01067 01068 /* If there is no data length, return immediately */ 01069 if (f->datalen == 0) 01070 return 0; 01071 01072 if ((f->frametype != AST_FRAME_MODEM) || 01073 (f->subclass != AST_MODEM_T38)) { 01074 ast_log(LOG_WARNING, "(%s): UDPTL can only send T.38 data.\n", 01075 LOG_TAG(s)); 01076 return -1; 01077 } 01078 01079 if (len > s->far_max_ifp) { 01080 ast_log(LOG_WARNING, 01081 "(%s): UDPTL asked to send %d bytes of IFP when far end only prepared to accept %d bytes; data loss will occur." 01082 "You may need to override the T38FaxMaxDatagram value for this endpoint in the channel driver configuration.\n", 01083 LOG_TAG(s), len, s->far_max_ifp); 01084 len = s->far_max_ifp; 01085 } 01086 01087 /* Save seq_no for debug output because udptl_build_packet increments it */ 01088 seq = s->tx_seq_no & 0xFFFF; 01089 01090 /* Cook up the UDPTL packet, with the relevant EC info. */ 01091 len = udptl_build_packet(s, buf, sizeof(buf), f->data.ptr, len); 01092 01093 if (len > 0 && s->them.sin_port && s->them.sin_addr.s_addr) { 01094 if ((res = sendto(s->fd, buf, len, 0, (struct sockaddr *) &s->them, sizeof(s->them))) < 0) 01095 ast_log(LOG_NOTICE, "(%s): UDPTL Transmission error to %s:%d: %s\n", 01096 LOG_TAG(s), ast_inet_ntoa(s->them.sin_addr), ntohs(s->them.sin_port), strerror(errno)); 01097 if (udptl_debug_test_addr(&s->them)) 01098 ast_verb(1, "UDPTL (%s): packet to %s:%d (type %d, seq %d, len %d)\n", 01099 LOG_TAG(s), ast_inet_ntoa(s->them.sin_addr), ntohs(s->them.sin_port), 0, seq, len); 01100 } 01101 01102 return 0; 01103 }
1.6.1