#include "asterisk/network.h"
#include "asterisk/frame.h"
#include "asterisk/io.h"
#include "asterisk/sched.h"
#include "asterisk/channel.h"
#include "asterisk/netsock2.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 ast_sockaddr *them) |
void | ast_udptl_get_us (const struct ast_udptl *udptl, struct ast_sockaddr *us) |
void | ast_udptl_init (void) |
ast_udptl * | ast_udptl_new_with_bindaddr (struct sched_context *sched, struct io_context *io, int callbackmode, struct ast_sockaddr *in) |
int | ast_udptl_proto_register (struct ast_udptl_protocol *proto) |
void | ast_udptl_proto_unregister (struct ast_udptl_protocol *proto) |
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 ast_sockaddr *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) |
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 37 of file udptl.h.
00037 { 00038 UDPTL_ERROR_CORRECTION_NONE, 00039 UDPTL_ERROR_CORRECTION_FEC, 00040 UDPTL_ERROR_CORRECTION_REDUNDANCY 00041 };
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 1129 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_log(), ast_read(), ast_sockaddr_cmp(), ast_sockaddr_copy(), ast_sockaddr_stringify(), ast_udptl_get_peer(), ast_waitfor_n(), ast_write(), f, get_proto(), ast_udptl_protocol::get_udptl_info, LOG_WARNING, ast_channel::masq, ast_channel::masqr, ast_channel::name, ast_udptl_protocol::set_udptl_peer, t1, and ast_channel::tech_pvt.
01130 { 01131 struct ast_frame *f; 01132 struct ast_channel *who; 01133 struct ast_channel *cs[3]; 01134 struct ast_udptl *p0; 01135 struct ast_udptl *p1; 01136 struct ast_udptl_protocol *pr0; 01137 struct ast_udptl_protocol *pr1; 01138 struct ast_sockaddr ac0; 01139 struct ast_sockaddr ac1; 01140 struct ast_sockaddr t0; 01141 struct ast_sockaddr t1; 01142 void *pvt0; 01143 void *pvt1; 01144 int to; 01145 01146 ast_channel_lock(c0); 01147 while (ast_channel_trylock(c1)) { 01148 ast_channel_unlock(c0); 01149 usleep(1); 01150 ast_channel_lock(c0); 01151 } 01152 pr0 = get_proto(c0); 01153 pr1 = get_proto(c1); 01154 if (!pr0) { 01155 ast_log(LOG_WARNING, "Can't find native functions for channel '%s'\n", c0->name); 01156 ast_channel_unlock(c0); 01157 ast_channel_unlock(c1); 01158 return -1; 01159 } 01160 if (!pr1) { 01161 ast_log(LOG_WARNING, "Can't find native functions for channel '%s'\n", c1->name); 01162 ast_channel_unlock(c0); 01163 ast_channel_unlock(c1); 01164 return -1; 01165 } 01166 pvt0 = c0->tech_pvt; 01167 pvt1 = c1->tech_pvt; 01168 p0 = pr0->get_udptl_info(c0); 01169 p1 = pr1->get_udptl_info(c1); 01170 if (!p0 || !p1) { 01171 /* Somebody doesn't want to play... */ 01172 ast_channel_unlock(c0); 01173 ast_channel_unlock(c1); 01174 return -2; 01175 } 01176 if (pr0->set_udptl_peer(c0, p1)) { 01177 ast_log(LOG_WARNING, "Channel '%s' failed to talk to '%s'\n", c0->name, c1->name); 01178 memset(&ac1, 0, sizeof(ac1)); 01179 } else { 01180 /* Store UDPTL peer */ 01181 ast_udptl_get_peer(p1, &ac1); 01182 } 01183 if (pr1->set_udptl_peer(c1, p0)) { 01184 ast_log(LOG_WARNING, "Channel '%s' failed to talk back to '%s'\n", c1->name, c0->name); 01185 memset(&ac0, 0, sizeof(ac0)); 01186 } else { 01187 /* Store UDPTL peer */ 01188 ast_udptl_get_peer(p0, &ac0); 01189 } 01190 ast_channel_unlock(c0); 01191 ast_channel_unlock(c1); 01192 cs[0] = c0; 01193 cs[1] = c1; 01194 cs[2] = NULL; 01195 for (;;) { 01196 if ((c0->tech_pvt != pvt0) || 01197 (c1->tech_pvt != pvt1) || 01198 (c0->masq || c0->masqr || c1->masq || c1->masqr)) { 01199 ast_debug(1, "Oooh, something is weird, backing out\n"); 01200 /* Tell it to try again later */ 01201 return -3; 01202 } 01203 to = -1; 01204 ast_udptl_get_peer(p1, &t1); 01205 ast_udptl_get_peer(p0, &t0); 01206 if (ast_sockaddr_cmp(&t1, &ac1)) { 01207 ast_debug(1, "Oooh, '%s' changed end address to %s\n", 01208 c1->name, ast_sockaddr_stringify(&t1)); 01209 ast_debug(1, "Oooh, '%s' was %s\n", 01210 c1->name, ast_sockaddr_stringify(&ac1)); 01211 ast_sockaddr_copy(&ac1, &t1); 01212 } 01213 if (ast_sockaddr_cmp(&t0, &ac0)) { 01214 ast_debug(1, "Oooh, '%s' changed end address to %s\n", 01215 c0->name, ast_sockaddr_stringify(&t0)); 01216 ast_debug(1, "Oooh, '%s' was %s\n", 01217 c0->name, ast_sockaddr_stringify(&ac0)); 01218 ast_sockaddr_copy(&ac0, &t0); 01219 } 01220 who = ast_waitfor_n(cs, 2, &to); 01221 if (!who) { 01222 ast_debug(1, "Ooh, empty read...\n"); 01223 /* check for hangup / whentohangup */ 01224 if (ast_check_hangup(c0) || ast_check_hangup(c1)) 01225 break; 01226 continue; 01227 } 01228 f = ast_read(who); 01229 if (!f) { 01230 *fo = f; 01231 *rc = who; 01232 ast_debug(1, "Oooh, got a %s\n", f ? "digit" : "hangup"); 01233 /* That's all we needed */ 01234 return 0; 01235 } else { 01236 if (f->frametype == AST_FRAME_MODEM) { 01237 /* Forward T.38 frames if they happen upon us */ 01238 if (who == c0) { 01239 ast_write(c1, f); 01240 } else if (who == c1) { 01241 ast_write(c0, f); 01242 } 01243 } 01244 ast_frfree(f); 01245 } 01246 /* Swap priority. Not that it's a big deal at this point */ 01247 cs[2] = cs[0]; 01248 cs[0] = cs[1]; 01249 cs[1] = cs[2]; 01250 } 01251 return -1; 01252 }
void ast_udptl_destroy | ( | struct ast_udptl * | udptl | ) |
Definition at line 1027 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().
01028 { 01029 if (udptl->ioid) 01030 ast_io_remove(udptl->io, udptl->ioid); 01031 if (udptl->fd > -1) 01032 close(udptl->fd); 01033 if (udptl->tag) 01034 ast_free(udptl->tag); 01035 ast_free(udptl); 01036 }
int ast_udptl_fd | ( | const struct ast_udptl * | udptl | ) |
Definition at line 635 of file udptl.c.
References ast_udptl::fd.
Referenced by __oh323_new(), and sip_new().
00636 { 00637 return udptl->fd; 00638 }
enum ast_t38_ec_modes ast_udptl_get_error_correction_scheme | ( | const struct ast_udptl * | udptl | ) |
Definition at line 822 of file udptl.c.
References ast_udptl::error_correction_scheme.
Referenced by add_sdp().
00823 { 00824 return udptl->error_correction_scheme; 00825 }
unsigned int ast_udptl_get_far_max_datagram | ( | const struct ast_udptl * | udptl | ) |
Definition at line 890 of file udptl.c.
References ast_udptl::far_max_datagram.
Referenced by process_sdp().
00891 { 00892 if (udptl->far_max_datagram < 0) { 00893 return 0; 00894 } 00895 return udptl->far_max_datagram; 00896 }
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 898 of file udptl.c.
References calculate_far_max_ifp(), and ast_udptl::far_max_ifp.
Referenced by change_t38_state(), and interpret_t38_parameters().
00899 { 00900 if (udptl->far_max_ifp == -1) { 00901 calculate_far_max_ifp(udptl); 00902 } 00903 00904 if (udptl->far_max_ifp < 0) { 00905 return 0; 00906 } 00907 return udptl->far_max_ifp; 00908 }
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 866 of file udptl.c.
References calculate_local_max_datagram(), and ast_udptl::local_max_datagram.
Referenced by add_sdp().
00867 { 00868 if (udptl->local_max_datagram == -1) { 00869 calculate_local_max_datagram(udptl); 00870 } 00871 00872 /* this function expects a unsigned value in return. */ 00873 if (udptl->local_max_datagram < 0) { 00874 return 0; 00875 } 00876 return udptl->local_max_datagram; 00877 }
void ast_udptl_get_peer | ( | const struct ast_udptl * | udptl, | |
struct ast_sockaddr * | them | |||
) |
Definition at line 1012 of file udptl.c.
References ast_sockaddr_copy(), and ast_udptl::them.
Referenced by ast_udptl_bridge(), and sip_set_udptl_peer().
01013 { 01014 ast_sockaddr_copy(them, &udptl->them); 01015 }
void ast_udptl_get_us | ( | const struct ast_udptl * | udptl, | |
struct ast_sockaddr * | us | |||
) |
Definition at line 1017 of file udptl.c.
References ast_sockaddr_copy(), and ast_udptl::us.
Referenced by add_sdp().
01018 { 01019 ast_sockaddr_copy(us, &udptl->us); 01020 }
void ast_udptl_init | ( | void | ) |
Definition at line 1410 of file udptl.c.
References __ast_udptl_reload(), ARRAY_LEN, ast_cli_register_multiple(), and cli_udptl.
Referenced by main().
01411 { 01412 ast_cli_register_multiple(cli_udptl, ARRAY_LEN(cli_udptl)); 01413 __ast_udptl_reload(0); 01414 }
struct ast_udptl* ast_udptl_new_with_bindaddr | ( | struct sched_context * | sched, | |
struct io_context * | io, | |||
int | callbackmode, | |||
struct ast_sockaddr * | in | |||
) |
Definition at line 910 of file udptl.c.
References ast_bind(), ast_calloc, ast_free, ast_log(), ast_random(), ast_sockaddr_copy(), ast_sockaddr_is_ipv6(), ast_sockaddr_set_port, errno, ast_udptl::flags, and LOG_WARNING.
Referenced by create_addr_from_peer(), handle_request_invite(), and sip_alloc().
00911 { 00912 struct ast_udptl *udptl; 00913 int x; 00914 int startplace; 00915 int i; 00916 long int flags; 00917 00918 if (!(udptl = ast_calloc(1, sizeof(*udptl)))) 00919 return NULL; 00920 00921 udptl->error_correction_span = udptlfecspan; 00922 udptl->error_correction_entries = udptlfecentries; 00923 00924 udptl->far_max_datagram = -1; 00925 udptl->far_max_ifp = -1; 00926 udptl->local_max_ifp = -1; 00927 udptl->local_max_datagram = -1; 00928 00929 for (i = 0; i <= UDPTL_BUF_MASK; i++) { 00930 udptl->rx[i].buf_len = -1; 00931 udptl->tx[i].buf_len = -1; 00932 } 00933 00934 if ((udptl->fd = socket(ast_sockaddr_is_ipv6(addr) ? 00935 AF_INET6 : AF_INET, SOCK_DGRAM, 0)) < 0) { 00936 ast_free(udptl); 00937 ast_log(LOG_WARNING, "Unable to allocate socket: %s\n", strerror(errno)); 00938 return NULL; 00939 } 00940 flags = fcntl(udptl->fd, F_GETFL); 00941 fcntl(udptl->fd, F_SETFL, flags | O_NONBLOCK); 00942 #ifdef SO_NO_CHECK 00943 if (nochecksums) 00944 setsockopt(udptl->fd, SOL_SOCKET, SO_NO_CHECK, &nochecksums, sizeof(nochecksums)); 00945 #endif 00946 /* Find us a place */ 00947 x = (udptlstart == udptlend) ? udptlstart : (ast_random() % (udptlend - udptlstart)) + udptlstart; 00948 if (use_even_ports && (x & 1)) { 00949 ++x; 00950 } 00951 startplace = x; 00952 for (;;) { 00953 ast_sockaddr_copy(&udptl->us, addr); 00954 ast_sockaddr_set_port(&udptl->us, x); 00955 if (ast_bind(udptl->fd, &udptl->us) == 0) { 00956 break; 00957 } 00958 if (errno != EADDRINUSE) { 00959 ast_log(LOG_WARNING, "Unexpected bind error: %s\n", strerror(errno)); 00960 close(udptl->fd); 00961 ast_free(udptl); 00962 return NULL; 00963 } 00964 if (use_even_ports) { 00965 x += 2; 00966 } else { 00967 ++x; 00968 } 00969 if (x > udptlend) 00970 x = udptlstart; 00971 if (x == startplace) { 00972 ast_log(LOG_WARNING, "No UDPTL ports remaining\n"); 00973 close(udptl->fd); 00974 ast_free(udptl); 00975 return NULL; 00976 } 00977 } 00978 if (io && sched && callbackmode) { 00979 /* Operate this one in a callback mode */ 00980 udptl->sched = sched; 00981 udptl->io = io; 00982 udptl->ioid = ast_io_add(udptl->io, udptl->fd, udptlread, AST_IO_IN, udptl); 00983 } 00984 return udptl; 00985 }
int ast_udptl_proto_register | ( | struct ast_udptl_protocol * | proto | ) |
Definition at line 1098 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().
01099 { 01100 struct ast_udptl_protocol *cur; 01101 01102 AST_RWLIST_WRLOCK(&protos); 01103 AST_RWLIST_TRAVERSE(&protos, cur, list) { 01104 if (cur->type == proto->type) { 01105 ast_log(LOG_WARNING, "Tried to register same protocol '%s' twice\n", cur->type); 01106 AST_RWLIST_UNLOCK(&protos); 01107 return -1; 01108 } 01109 } 01110 AST_RWLIST_INSERT_TAIL(&protos, proto, list); 01111 AST_RWLIST_UNLOCK(&protos); 01112 return 0; 01113 }
void ast_udptl_proto_unregister | ( | struct ast_udptl_protocol * | proto | ) |
Definition at line 1091 of file udptl.c.
References AST_RWLIST_REMOVE, AST_RWLIST_UNLOCK, and AST_RWLIST_WRLOCK.
Referenced by unload_module().
01092 { 01093 AST_RWLIST_WRLOCK(&protos); 01094 AST_RWLIST_REMOVE(&protos, proto, list); 01095 AST_RWLIST_UNLOCK(&protos); 01096 }
Definition at line 667 of file udptl.c.
References ast_assert, ast_debug, AST_FRIENDLY_OFFSET, ast_log(), ast_null_frame, ast_recvfrom(), ast_sockaddr_cmp(), ast_sockaddr_copy(), ast_sockaddr_isnull(), ast_sockaddr_stringify(), ast_verb, errno, ast_udptl::f, ast_udptl::fd, 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().
00668 { 00669 int res; 00670 struct ast_sockaddr addr; 00671 uint16_t seqno = 0; 00672 uint16_t *udptlheader; 00673 00674 /* Cache where the header will go */ 00675 res = ast_recvfrom(udptl->fd, 00676 udptl->rawdata + AST_FRIENDLY_OFFSET, 00677 sizeof(udptl->rawdata) - AST_FRIENDLY_OFFSET, 00678 0, 00679 &addr); 00680 udptlheader = (uint16_t *)(udptl->rawdata + AST_FRIENDLY_OFFSET); 00681 if (res < 0) { 00682 if (errno != EAGAIN) 00683 ast_log(LOG_WARNING, "(%s): UDPTL read error: %s\n", 00684 LOG_TAG(udptl), strerror(errno)); 00685 ast_assert(errno != EBADF); 00686 return &ast_null_frame; 00687 } 00688 00689 /* Ignore if the other side hasn't been given an address yet. */ 00690 if (ast_sockaddr_isnull(&udptl->them)) { 00691 return &ast_null_frame; 00692 } 00693 00694 if (udptl->nat) { 00695 /* Send to whoever sent to us */ 00696 if (ast_sockaddr_cmp(&udptl->them, &addr)) { 00697 ast_sockaddr_copy(&udptl->them, &addr); 00698 ast_debug(1, "UDPTL NAT (%s): Using address %s\n", 00699 LOG_TAG(udptl), ast_sockaddr_stringify(&udptl->them)); 00700 } 00701 } 00702 00703 if (udptl_debug_test_addr(&addr)) { 00704 ast_verb(1, "UDPTL (%s): packet from %s (type %d, seq %d, len %d)\n", 00705 LOG_TAG(udptl), ast_sockaddr_stringify(&addr), 0, seqno, res); 00706 } 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 1404 of file udptl.c.
References __ast_udptl_reload().
01405 { 01406 __ast_udptl_reload(1); 01407 return 0; 01408 }
void ast_udptl_reset | ( | struct ast_udptl * | udptl | ) |
void ast_udptl_set_callback | ( | struct ast_udptl * | udptl, | |
ast_udptl_callback | callback | |||
) |
Definition at line 645 of file udptl.c.
References ast_udptl::callback.
00646 { 00647 udptl->callback = callback; 00648 }
void ast_udptl_set_data | ( | struct ast_udptl * | udptl, | |
void * | data | |||
) |
Definition at line 640 of file udptl.c.
References ast_udptl::data.
00641 { 00642 udptl->data = data; 00643 }
void ast_udptl_set_error_correction_scheme | ( | struct ast_udptl * | udptl, | |
enum ast_t38_ec_modes | ec | |||
) |
Definition at line 827 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(), process_sdp_a_image(), and set_t38_capabilities().
00828 { 00829 udptl->error_correction_scheme = ec; 00830 switch (ec) { 00831 case UDPTL_ERROR_CORRECTION_FEC: 00832 udptl->error_correction_scheme = UDPTL_ERROR_CORRECTION_FEC; 00833 if (udptl->error_correction_entries == 0) { 00834 udptl->error_correction_entries = 3; 00835 } 00836 if (udptl->error_correction_span == 0) { 00837 udptl->error_correction_span = 3; 00838 } 00839 break; 00840 case UDPTL_ERROR_CORRECTION_REDUNDANCY: 00841 udptl->error_correction_scheme = UDPTL_ERROR_CORRECTION_REDUNDANCY; 00842 if (udptl->error_correction_entries == 0) { 00843 udptl->error_correction_entries = 3; 00844 } 00845 break; 00846 default: 00847 /* nothing to do */ 00848 break; 00849 }; 00850 /* reset calculated values so they'll be computed again */ 00851 udptl->local_max_datagram = -1; 00852 udptl->far_max_ifp = -1; 00853 }
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 879 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().
00880 { 00881 if (!max_datagram || (max_datagram > FAX_MAX_DATAGRAM_LIMIT)) { 00882 udptl->far_max_datagram = DEFAULT_FAX_MAX_DATAGRAM; 00883 } else { 00884 udptl->far_max_datagram = max_datagram; 00885 } 00886 /* reset calculated values so they'll be computed again */ 00887 udptl->far_max_ifp = -1; 00888 }
void ast_udptl_set_local_max_ifp | ( | struct ast_udptl * | udptl, | |
unsigned int | max_ifp | |||
) |
Definition at line 855 of file udptl.c.
References ast_udptl::local_max_datagram, and ast_udptl::local_max_ifp.
Referenced by interpret_t38_parameters().
00856 { 00857 /* make sure max_ifp is a positive value since a cast will take place when 00858 * when setting local_max_ifp */ 00859 if ((signed int) max_ifp > 0) { 00860 udptl->local_max_ifp = max_ifp; 00861 /* reset calculated values so they'll be computed again */ 00862 udptl->local_max_datagram = -1; 00863 } 00864 }
void ast_udptl_set_m_type | ( | struct ast_udptl * | udptl, | |
unsigned int | pt | |||
) |
void ast_udptl_set_peer | ( | struct ast_udptl * | udptl, | |
const struct ast_sockaddr * | them | |||
) |
Definition at line 1007 of file udptl.c.
References ast_sockaddr_copy(), and ast_udptl::them.
Referenced by process_sdp().
01008 { 01009 ast_sockaddr_copy(&udptl->them, them); 01010 }
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 |
none |
Definition at line 987 of file udptl.c.
References ast_free, ast_vasprintf, and ast_udptl::tag.
Referenced by change_t38_state().
00988 { 00989 va_list ap; 00990 00991 if (udptl->tag) { 00992 ast_free(udptl->tag); 00993 udptl->tag = NULL; 00994 } 00995 va_start(ap, format); 00996 if (ast_vasprintf(&udptl->tag, format, ap) == -1) { 00997 udptl->tag = NULL; 00998 } 00999 va_end(ap); 01000 }
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 1002 of file udptl.c.
References ast_netsock_set_qos(), and ast_udptl::fd.
Referenced by sip_alloc().
01003 { 01004 return ast_netsock_set_qos(udptl->fd, tos, cos, "UDPTL"); 01005 }
void ast_udptl_stop | ( | struct ast_udptl * | udptl | ) |
Definition at line 1022 of file udptl.c.
References ast_sockaddr_setnull(), and ast_udptl::them.
Referenced by process_sdp(), and stop_media_flows().
01023 { 01024 ast_sockaddr_setnull(&udptl->them); 01025 }
Definition at line 1038 of file udptl.c.
References AST_FRAME_MODEM, ast_log(), AST_MODEM_T38, ast_sendto(), ast_sockaddr_isnull(), ast_sockaddr_stringify(), ast_verb, DEFAULT_FAX_MAX_DATAGRAM, errno, f, ast_udptl::far_max_datagram, ast_udptl::far_max_ifp, ast_udptl::fd, len(), LOG_NOTICE, LOG_TAG, LOG_WARNING, seq, ast_udptl::them, ast_udptl::tx_seq_no, udptl_build_packet(), and udptl_debug_test_addr().
Referenced by sip_write().
01039 { 01040 unsigned int seq; 01041 unsigned int len = f->datalen; 01042 int res; 01043 /* if no max datagram size is provided, use default value */ 01044 const int bufsize = (s->far_max_datagram > 0) ? s->far_max_datagram : DEFAULT_FAX_MAX_DATAGRAM; 01045 uint8_t buf[bufsize]; 01046 01047 memset(buf, 0, sizeof(buf)); 01048 01049 /* If we have no peer, return immediately */ 01050 if (ast_sockaddr_isnull(&s->them)) { 01051 return 0; 01052 } 01053 01054 /* If there is no data length, return immediately */ 01055 if (f->datalen == 0) 01056 return 0; 01057 01058 if ((f->frametype != AST_FRAME_MODEM) || 01059 (f->subclass.codec != AST_MODEM_T38)) { 01060 ast_log(LOG_WARNING, "(%s): UDPTL can only send T.38 data.\n", 01061 LOG_TAG(s)); 01062 return -1; 01063 } 01064 01065 if (len > s->far_max_ifp) { 01066 ast_log(LOG_WARNING, 01067 "(%s): UDPTL asked to send %d bytes of IFP when far end only prepared to accept %d bytes; data loss will occur." 01068 "You may need to override the T38FaxMaxDatagram value for this endpoint in the channel driver configuration.\n", 01069 LOG_TAG(s), len, s->far_max_ifp); 01070 len = s->far_max_ifp; 01071 } 01072 01073 /* Save seq_no for debug output because udptl_build_packet increments it */ 01074 seq = s->tx_seq_no & 0xFFFF; 01075 01076 /* Cook up the UDPTL packet, with the relevant EC info. */ 01077 len = udptl_build_packet(s, buf, sizeof(buf), f->data.ptr, len); 01078 01079 if ((signed int) len > 0 && !ast_sockaddr_isnull(&s->them)) { 01080 if ((res = ast_sendto(s->fd, buf, len, 0, &s->them)) < 0) 01081 ast_log(LOG_NOTICE, "(%s): UDPTL Transmission error to %s: %s\n", 01082 LOG_TAG(s), ast_sockaddr_stringify(&s->them), strerror(errno)); 01083 if (udptl_debug_test_addr(&s->them)) 01084 ast_verb(1, "UDPTL (%s): packet to %s (type %d, seq %d, len %d)\n", 01085 LOG_TAG(s), ast_sockaddr_stringify(&s->them), 0, seq, len); 01086 } 01087 01088 return 0; 01089 }