#include "asterisk/frame.h"
#include "asterisk/io.h"
#include "asterisk/sched.h"
#include "asterisk/channel.h"
#include <netinet/in.h>
Include dependency graph for udptl.h:
This graph shows which files directly or indirectly include this file:
Go to the source code of this file.
typedef int(*) ast_udptl_callback(struct ast_udptl *udptl, struct ast_frame *f, void *data) |
anonymous enum |
UDPTL_ERROR_CORRECTION_NONE | |
UDPTL_ERROR_CORRECTION_FEC | |
UDPTL_ERROR_CORRECTION_REDUNDANCY |
Definition at line 28 of file udptl.h.
00029 { 00030 UDPTL_ERROR_CORRECTION_NONE, 00031 UDPTL_ERROR_CORRECTION_FEC, 00032 UDPTL_ERROR_CORRECTION_REDUNDANCY 00033 };
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 963 of file udptl.c.
References ast_channel_lock, ast_channel_trylock, ast_channel_unlock, ast_check_hangup(), AST_FRAME_MODEM, ast_frfree, ast_inet_ntoa(), ast_log(), ast_read(), ast_udptl_get_peer(), ast_waitfor_n(), ast_write(), f, get_proto(), ast_udptl_protocol::get_udptl_info, inaddrcmp(), LOG_DEBUG, LOG_WARNING, ast_channel::masq, ast_channel::masqr, ast_udptl_protocol::set_udptl_peer, and ast_channel::tech_pvt.
00964 { 00965 struct ast_frame *f; 00966 struct ast_channel *who; 00967 struct ast_channel *cs[3]; 00968 struct ast_udptl *p0; 00969 struct ast_udptl *p1; 00970 struct ast_udptl_protocol *pr0; 00971 struct ast_udptl_protocol *pr1; 00972 struct sockaddr_in ac0; 00973 struct sockaddr_in ac1; 00974 struct sockaddr_in t0; 00975 struct sockaddr_in t1; 00976 void *pvt0; 00977 void *pvt1; 00978 int to; 00979 00980 ast_channel_lock(c0); 00981 while (ast_channel_trylock(c1)) { 00982 ast_channel_unlock(c0); 00983 usleep(1); 00984 ast_channel_lock(c0); 00985 } 00986 pr0 = get_proto(c0); 00987 pr1 = get_proto(c1); 00988 if (!pr0) { 00989 ast_log(LOG_WARNING, "Can't find native functions for channel '%s'\n", c0->name); 00990 ast_channel_unlock(c0); 00991 ast_channel_unlock(c1); 00992 return -1; 00993 } 00994 if (!pr1) { 00995 ast_log(LOG_WARNING, "Can't find native functions for channel '%s'\n", c1->name); 00996 ast_channel_unlock(c0); 00997 ast_channel_unlock(c1); 00998 return -1; 00999 } 01000 pvt0 = c0->tech_pvt; 01001 pvt1 = c1->tech_pvt; 01002 p0 = pr0->get_udptl_info(c0); 01003 p1 = pr1->get_udptl_info(c1); 01004 if (!p0 || !p1) { 01005 /* Somebody doesn't want to play... */ 01006 ast_channel_unlock(c0); 01007 ast_channel_unlock(c1); 01008 return -2; 01009 } 01010 if (pr0->set_udptl_peer(c0, p1)) { 01011 ast_log(LOG_WARNING, "Channel '%s' failed to talk to '%s'\n", c0->name, c1->name); 01012 memset(&ac1, 0, sizeof(ac1)); 01013 } else { 01014 /* Store UDPTL peer */ 01015 ast_udptl_get_peer(p1, &ac1); 01016 } 01017 if (pr1->set_udptl_peer(c1, p0)) { 01018 ast_log(LOG_WARNING, "Channel '%s' failed to talk back to '%s'\n", c1->name, c0->name); 01019 memset(&ac0, 0, sizeof(ac0)); 01020 } else { 01021 /* Store UDPTL peer */ 01022 ast_udptl_get_peer(p0, &ac0); 01023 } 01024 ast_channel_unlock(c0); 01025 ast_channel_unlock(c1); 01026 cs[0] = c0; 01027 cs[1] = c1; 01028 cs[2] = NULL; 01029 for (;;) { 01030 if ((c0->tech_pvt != pvt0) || 01031 (c1->tech_pvt != pvt1) || 01032 (c0->masq || c0->masqr || c1->masq || c1->masqr)) { 01033 ast_log(LOG_DEBUG, "Oooh, something is weird, backing out\n"); 01034 /* Tell it to try again later */ 01035 return -3; 01036 } 01037 to = -1; 01038 ast_udptl_get_peer(p1, &t1); 01039 ast_udptl_get_peer(p0, &t0); 01040 if (inaddrcmp(&t1, &ac1)) { 01041 ast_log(LOG_DEBUG, "Oooh, '%s' changed end address to %s:%d\n", 01042 c1->name, ast_inet_ntoa(t1.sin_addr), ntohs(t1.sin_port)); 01043 ast_log(LOG_DEBUG, "Oooh, '%s' was %s:%d\n", 01044 c1->name, ast_inet_ntoa(ac1.sin_addr), ntohs(ac1.sin_port)); 01045 memcpy(&ac1, &t1, sizeof(ac1)); 01046 } 01047 if (inaddrcmp(&t0, &ac0)) { 01048 ast_log(LOG_DEBUG, "Oooh, '%s' changed end address to %s:%d\n", 01049 c0->name, ast_inet_ntoa(t0.sin_addr), ntohs(t0.sin_port)); 01050 ast_log(LOG_DEBUG, "Oooh, '%s' was %s:%d\n", 01051 c0->name, ast_inet_ntoa(ac0.sin_addr), ntohs(ac0.sin_port)); 01052 memcpy(&ac0, &t0, sizeof(ac0)); 01053 } 01054 who = ast_waitfor_n(cs, 2, &to); 01055 if (!who) { 01056 ast_log(LOG_DEBUG, "Ooh, empty read...\n"); 01057 /* check for hangup / whentohangup */ 01058 if (ast_check_hangup(c0) || ast_check_hangup(c1)) 01059 break; 01060 continue; 01061 } 01062 f = ast_read(who); 01063 if (!f) { 01064 *fo = f; 01065 *rc = who; 01066 ast_log(LOG_DEBUG, "Oooh, got a %s\n", f ? "digit" : "hangup"); 01067 /* That's all we needed */ 01068 return 0; 01069 } else { 01070 if (f->frametype == AST_FRAME_MODEM) { 01071 /* Forward T.38 frames if they happen upon us */ 01072 if (who == c0) { 01073 ast_write(c1, f); 01074 } else if (who == c1) { 01075 ast_write(c0, f); 01076 } 01077 } 01078 ast_frfree(f); 01079 } 01080 /* Swap priority. Not that it's a big deal at this point */ 01081 cs[2] = cs[0]; 01082 cs[0] = cs[1]; 01083 cs[1] = cs[2]; 01084 } 01085 return -1; 01086 }
void ast_udptl_destroy | ( | struct ast_udptl * | udptl | ) |
Definition at line 863 of file udptl.c.
References ast_io_remove(), ast_udptl::fd, free, ast_udptl::io, and ast_udptl::ioid.
Referenced by __sip_destroy(), and create_addr_from_peer().
00864 { 00865 if (udptl->ioid) 00866 ast_io_remove(udptl->io, udptl->ioid); 00867 if (udptl->fd > -1) 00868 close(udptl->fd); 00869 free(udptl); 00870 }
int ast_udptl_fd | ( | struct ast_udptl * | udptl | ) |
Definition at line 589 of file udptl.c.
References ast_udptl::fd.
Referenced by __oh323_new(), and sip_new().
00590 { 00591 return udptl->fd; 00592 }
void ast_udptl_get_current_formats | ( | struct ast_udptl * | udptl, | |
int * | astFormats, | |||
int * | nonAstFormats | |||
) |
int ast_udptl_get_error_correction_scheme | ( | struct ast_udptl * | udptl | ) |
Definition at line 680 of file udptl.c.
References ast_log(), ast_udptl::error_correction_scheme, and LOG_WARNING.
Referenced by create_addr_from_peer(), sip_alloc(), and sip_handle_t38_reinvite().
00681 { 00682 if (udptl) 00683 return udptl->error_correction_scheme; 00684 else { 00685 ast_log(LOG_WARNING, "udptl structure is null\n"); 00686 return -1; 00687 } 00688 }
int ast_udptl_get_far_max_datagram | ( | struct ast_udptl * | udptl | ) |
Definition at line 720 of file udptl.c.
References ast_log(), ast_udptl::far_max_datagram_size, and LOG_WARNING.
00721 { 00722 if (udptl) 00723 return udptl->far_max_datagram_size; 00724 else { 00725 ast_log(LOG_WARNING, "udptl structure is null\n"); 00726 return -1; 00727 } 00728 }
int ast_udptl_get_local_max_datagram | ( | struct ast_udptl * | udptl | ) |
Definition at line 710 of file udptl.c.
References ast_log(), ast_udptl::local_max_datagram_size, and LOG_WARNING.
Referenced by add_t38_sdp(), and sip_handle_t38_reinvite().
00711 { 00712 if (udptl) 00713 return udptl->local_max_datagram_size; 00714 else { 00715 ast_log(LOG_WARNING, "udptl structure is null\n"); 00716 return -1; 00717 } 00718 }
void ast_udptl_get_peer | ( | struct ast_udptl * | udptl, | |
struct sockaddr_in * | them | |||
) |
Definition at line 844 of file udptl.c.
References ast_udptl::them.
Referenced by ast_udptl_bridge(), sip_handle_t38_reinvite(), and sip_set_udptl_peer().
00845 { 00846 memset(them, 0, sizeof(*them)); 00847 them->sin_family = AF_INET; 00848 them->sin_port = udptl->them.sin_port; 00849 them->sin_addr = udptl->them.sin_addr; 00850 }
void ast_udptl_get_us | ( | struct ast_udptl * | udptl, | |
struct sockaddr_in * | us | |||
) |
void ast_udptl_init | ( | void | ) |
Definition at line 1245 of file udptl.c.
References ast_cli_register_multiple(), ast_udptl_reload(), and cli_udptl.
Referenced by main().
01246 { 01247 ast_cli_register_multiple(cli_udptl, sizeof(cli_udptl) / sizeof(struct ast_cli_entry)); 01248 ast_udptl_reload(); 01249 }
int ast_udptl_lookup_code | ( | struct ast_udptl * | udptl, | |
int | isAstFormat, | |||
int | code | |||
) |
struct ast_udptl* ast_udptl_new | ( | struct sched_context * | sched, | |
struct io_context * | io, | |||
int | callbackmode | |||
) |
Definition at line 822 of file udptl.c.
References ast_udptl_new_with_bindaddr(), io, and sched.
00823 { 00824 struct in_addr ia; 00825 memset(&ia, 0, sizeof(ia)); 00826 return ast_udptl_new_with_bindaddr(sched, io, callbackmode, ia); 00827 }
struct ast_udptl* ast_udptl_new_with_bindaddr | ( | struct sched_context * | sched, | |
struct io_context * | io, | |||
int | callbackmode, | |||
struct in_addr | in | |||
) |
Definition at line 746 of file udptl.c.
References ast_calloc, ast_io_add(), AST_IO_IN, ast_log(), ast_random(), errno, ast_udptl::flags, free, io, LOG_WARNING, sched, UDPTL_ERROR_CORRECTION_FEC, UDPTL_ERROR_CORRECTION_NONE, UDPTL_ERROR_CORRECTION_REDUNDANCY, and udptlread().
Referenced by ast_udptl_new(), and sip_alloc().
00747 { 00748 struct ast_udptl *udptl; 00749 int x; 00750 int startplace; 00751 int i; 00752 long int flags; 00753 00754 if (!(udptl = ast_calloc(1, sizeof(*udptl)))) 00755 return NULL; 00756 00757 if (udptlfectype == 2) 00758 udptl->error_correction_scheme = UDPTL_ERROR_CORRECTION_FEC; 00759 else if (udptlfectype == 1) 00760 udptl->error_correction_scheme = UDPTL_ERROR_CORRECTION_REDUNDANCY; 00761 else 00762 udptl->error_correction_scheme = UDPTL_ERROR_CORRECTION_NONE; 00763 udptl->error_correction_span = udptlfecspan; 00764 udptl->error_correction_entries = udptlfecentries; 00765 00766 udptl->far_max_datagram_size = udptlmaxdatagram; 00767 udptl->local_max_datagram_size = udptlmaxdatagram; 00768 00769 memset(&udptl->rx, 0, sizeof(udptl->rx)); 00770 memset(&udptl->tx, 0, sizeof(udptl->tx)); 00771 for (i = 0; i <= UDPTL_BUF_MASK; i++) { 00772 udptl->rx[i].buf_len = -1; 00773 udptl->tx[i].buf_len = -1; 00774 } 00775 00776 udptl->them.sin_family = AF_INET; 00777 udptl->us.sin_family = AF_INET; 00778 00779 if ((udptl->fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { 00780 free(udptl); 00781 ast_log(LOG_WARNING, "Unable to allocate socket: %s\n", strerror(errno)); 00782 return NULL; 00783 } 00784 flags = fcntl(udptl->fd, F_GETFL); 00785 fcntl(udptl->fd, F_SETFL, flags | O_NONBLOCK); 00786 #ifdef SO_NO_CHECK 00787 if (nochecksums) 00788 setsockopt(udptl->fd, SOL_SOCKET, SO_NO_CHECK, &nochecksums, sizeof(nochecksums)); 00789 #endif 00790 /* Find us a place */ 00791 x = (ast_random() % (udptlend - udptlstart)) + udptlstart; 00792 startplace = x; 00793 for (;;) { 00794 udptl->us.sin_port = htons(x); 00795 udptl->us.sin_addr = addr; 00796 if (bind(udptl->fd, (struct sockaddr *) &udptl->us, sizeof(udptl->us)) == 0) 00797 break; 00798 if (errno != EADDRINUSE) { 00799 ast_log(LOG_WARNING, "Unexpected bind error: %s\n", strerror(errno)); 00800 close(udptl->fd); 00801 free(udptl); 00802 return NULL; 00803 } 00804 if (++x > udptlend) 00805 x = udptlstart; 00806 if (x == startplace) { 00807 ast_log(LOG_WARNING, "No UDPTL ports remaining\n"); 00808 close(udptl->fd); 00809 free(udptl); 00810 return NULL; 00811 } 00812 } 00813 if (io && sched && callbackmode) { 00814 /* Operate this one in a callback mode */ 00815 udptl->sched = sched; 00816 udptl->io = io; 00817 udptl->ioid = ast_io_add(udptl->io, udptl->fd, udptlread, AST_IO_IN, udptl); 00818 } 00819 return udptl; 00820 }
void ast_udptl_offered_from_local | ( | struct ast_udptl * | udptl, | |
int | local | |||
) |
Definition at line 672 of file udptl.c.
References ast_log(), LOG_WARNING, and ast_udptl::udptl_offered_from_local.
Referenced by transmit_invite(), transmit_reinvite_with_t38_sdp(), and transmit_response_with_t38_sdp().
00673 { 00674 if (udptl) 00675 udptl->udptl_offered_from_local = local; 00676 else 00677 ast_log(LOG_WARNING, "udptl structure is null\n"); 00678 }
int ast_udptl_proto_register | ( | struct ast_udptl_protocol * | proto | ) |
Definition at line 933 of file udptl.c.
References ast_log(), LOG_WARNING, ast_udptl_protocol::next, protos, and ast_udptl_protocol::type.
Referenced by load_module().
00934 { 00935 struct ast_udptl_protocol *cur; 00936 00937 cur = protos; 00938 while (cur) { 00939 if (cur->type == proto->type) { 00940 ast_log(LOG_WARNING, "Tried to register same protocol '%s' twice\n", cur->type); 00941 return -1; 00942 } 00943 cur = cur->next; 00944 } 00945 proto->next = protos; 00946 protos = proto; 00947 return 0; 00948 }
void ast_udptl_proto_unregister | ( | struct ast_udptl_protocol * | proto | ) |
Definition at line 913 of file udptl.c.
References ast_udptl_protocol::next, and protos.
Referenced by unload_module().
00914 { 00915 struct ast_udptl_protocol *cur; 00916 struct ast_udptl_protocol *prev; 00917 00918 cur = protos; 00919 prev = NULL; 00920 while (cur) { 00921 if (cur == proto) { 00922 if (prev) 00923 prev->next = proto->next; 00924 else 00925 protos = proto->next; 00926 return; 00927 } 00928 prev = cur; 00929 cur = cur->next; 00930 } 00931 }
Definition at line 621 of file udptl.c.
References ast_assert, AST_FRIENDLY_OFFSET, ast_inet_ntoa(), ast_log(), ast_null_frame, ast_verbose(), errno, ast_udptl::f, ast_udptl::fd, len, LOG_DEBUG, 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().
00622 { 00623 int res; 00624 struct sockaddr_in sin; 00625 socklen_t len; 00626 uint16_t seqno = 0; 00627 uint16_t *udptlheader; 00628 00629 len = sizeof(sin); 00630 00631 /* Cache where the header will go */ 00632 res = recvfrom(udptl->fd, 00633 udptl->rawdata + AST_FRIENDLY_OFFSET, 00634 sizeof(udptl->rawdata) - AST_FRIENDLY_OFFSET, 00635 0, 00636 (struct sockaddr *) &sin, 00637 &len); 00638 udptlheader = (uint16_t *)(udptl->rawdata + AST_FRIENDLY_OFFSET); 00639 if (res < 0) { 00640 if (errno != EAGAIN) 00641 ast_log(LOG_WARNING, "UDPTL read error: %s\n", strerror(errno)); 00642 ast_assert(errno != EBADF); 00643 return &ast_null_frame; 00644 } 00645 00646 /* Ignore if the other side hasn't been given an address yet. */ 00647 if (!udptl->them.sin_addr.s_addr || !udptl->them.sin_port) 00648 return &ast_null_frame; 00649 00650 if (udptl->nat) { 00651 /* Send to whoever sent to us */ 00652 if ((udptl->them.sin_addr.s_addr != sin.sin_addr.s_addr) || 00653 (udptl->them.sin_port != sin.sin_port)) { 00654 memcpy(&udptl->them, &sin, sizeof(udptl->them)); 00655 ast_log(LOG_DEBUG, "UDPTL NAT: Using address %s:%d\n", ast_inet_ntoa(udptl->them.sin_addr), ntohs(udptl->them.sin_port)); 00656 } 00657 } 00658 00659 if (udptl_debug_test_addr(&sin)) { 00660 ast_verbose("Got UDPTL packet from %s:%d (type %d, seq %d, len %d)\n", 00661 ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port), 0, seqno, res); 00662 } 00663 #if 0 00664 printf("Got UDPTL packet from %s:%d (seq %d, len = %d)\n", ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port), seqno, res); 00665 #endif 00666 if (udptl_rx_packet(udptl, udptl->rawdata + AST_FRIENDLY_OFFSET, res) < 1) 00667 return &ast_null_frame; 00668 00669 return &udptl->f[0]; 00670 }
void ast_udptl_reload | ( | void | ) |
Definition at line 1169 of file udptl.c.
References ast_config_destroy(), ast_config_load(), ast_false(), ast_log(), ast_variable_retrieve(), ast_verbose(), LOCAL_FAX_MAX_DATAGRAM, LOG_WARNING, MAX_FEC_ENTRIES, MAX_FEC_SPAN, option_verbose, s, and VERBOSE_PREFIX_2.
Referenced by ast_udptl_init().
01170 { 01171 struct ast_config *cfg; 01172 const char *s; 01173 01174 udptlstart = 4500; 01175 udptlend = 4999; 01176 udptlfectype = 0; 01177 udptlfecentries = 0; 01178 udptlfecspan = 0; 01179 udptlmaxdatagram = 0; 01180 01181 if ((cfg = ast_config_load("udptl.conf"))) { 01182 if ((s = ast_variable_retrieve(cfg, "general", "udptlstart"))) { 01183 udptlstart = atoi(s); 01184 if (udptlstart < 1024) 01185 udptlstart = 1024; 01186 if (udptlstart > 65535) 01187 udptlstart = 65535; 01188 } 01189 if ((s = ast_variable_retrieve(cfg, "general", "udptlend"))) { 01190 udptlend = atoi(s); 01191 if (udptlend < 1024) 01192 udptlend = 1024; 01193 if (udptlend > 65535) 01194 udptlend = 65535; 01195 } 01196 if ((s = ast_variable_retrieve(cfg, "general", "udptlchecksums"))) { 01197 #ifdef SO_NO_CHECK 01198 if (ast_false(s)) 01199 nochecksums = 1; 01200 else 01201 nochecksums = 0; 01202 #else 01203 if (ast_false(s)) 01204 ast_log(LOG_WARNING, "Disabling UDPTL checksums is not supported on this operating system!\n"); 01205 #endif 01206 } 01207 if ((s = ast_variable_retrieve(cfg, "general", "T38FaxUdpEC"))) { 01208 if (strcmp(s, "t38UDPFEC") == 0) 01209 udptlfectype = 2; 01210 else if (strcmp(s, "t38UDPRedundancy") == 0) 01211 udptlfectype = 1; 01212 } 01213 if ((s = ast_variable_retrieve(cfg, "general", "T38FaxMaxDatagram"))) { 01214 udptlmaxdatagram = atoi(s); 01215 if (udptlmaxdatagram < 0) 01216 udptlmaxdatagram = 0; 01217 if (udptlmaxdatagram > LOCAL_FAX_MAX_DATAGRAM) 01218 udptlmaxdatagram = LOCAL_FAX_MAX_DATAGRAM; 01219 } 01220 if ((s = ast_variable_retrieve(cfg, "general", "UDPTLFECentries"))) { 01221 udptlfecentries = atoi(s); 01222 if (udptlfecentries < 0) 01223 udptlfecentries = 0; 01224 if (udptlfecentries > MAX_FEC_ENTRIES) 01225 udptlfecentries = MAX_FEC_ENTRIES; 01226 } 01227 if ((s = ast_variable_retrieve(cfg, "general", "UDPTLFECspan"))) { 01228 udptlfecspan = atoi(s); 01229 if (udptlfecspan < 0) 01230 udptlfecspan = 0; 01231 if (udptlfecspan > MAX_FEC_SPAN) 01232 udptlfecspan = MAX_FEC_SPAN; 01233 } 01234 ast_config_destroy(cfg); 01235 } 01236 if (udptlstart >= udptlend) { 01237 ast_log(LOG_WARNING, "Unreasonable values for UDPTL start/end\n"); 01238 udptlstart = 4500; 01239 udptlend = 4999; 01240 } 01241 if (option_verbose > 1) 01242 ast_verbose(VERBOSE_PREFIX_2 "UDPTL allocating from port range %d -> %d\n", udptlstart, udptlend); 01243 }
void ast_udptl_reset | ( | struct ast_udptl * | udptl | ) |
void ast_udptl_set_callback | ( | struct ast_udptl * | udptl, | |
ast_udptl_callback | callback | |||
) |
Definition at line 599 of file udptl.c.
References ast_udptl::callback.
00600 { 00601 udptl->callback = callback; 00602 }
void ast_udptl_set_data | ( | struct ast_udptl * | udptl, | |
void * | data | |||
) |
Definition at line 594 of file udptl.c.
References ast_udptl::data.
00595 { 00596 udptl->data = data; 00597 }
void ast_udptl_set_error_correction_scheme | ( | struct ast_udptl * | udptl, | |
int | ec | |||
) |
Definition at line 690 of file udptl.c.
References ast_log(), ast_udptl::error_correction_scheme, LOG_WARNING, UDPTL_ERROR_CORRECTION_FEC, UDPTL_ERROR_CORRECTION_NONE, and UDPTL_ERROR_CORRECTION_REDUNDANCY.
Referenced by process_sdp(), and sip_handle_t38_reinvite().
00691 { 00692 if (udptl) { 00693 switch (ec) { 00694 case UDPTL_ERROR_CORRECTION_FEC: 00695 udptl->error_correction_scheme = UDPTL_ERROR_CORRECTION_FEC; 00696 break; 00697 case UDPTL_ERROR_CORRECTION_REDUNDANCY: 00698 udptl->error_correction_scheme = UDPTL_ERROR_CORRECTION_REDUNDANCY; 00699 break; 00700 case UDPTL_ERROR_CORRECTION_NONE: 00701 udptl->error_correction_scheme = UDPTL_ERROR_CORRECTION_NONE; 00702 break; 00703 default: 00704 ast_log(LOG_WARNING, "error correction parameter invalid\n"); 00705 }; 00706 } else 00707 ast_log(LOG_WARNING, "udptl structure is null\n"); 00708 }
void ast_udptl_set_far_max_datagram | ( | struct ast_udptl * | udptl, | |
int | max_datagram | |||
) |
Definition at line 738 of file udptl.c.
References ast_log(), ast_udptl::far_max_datagram_size, and LOG_WARNING.
Referenced by process_sdp(), and sip_handle_t38_reinvite().
00739 { 00740 if (udptl) 00741 udptl->far_max_datagram_size = max_datagram; 00742 else 00743 ast_log(LOG_WARNING, "udptl structure is null\n"); 00744 }
void ast_udptl_set_local_max_datagram | ( | struct ast_udptl * | udptl, | |
int | max_datagram | |||
) |
Definition at line 730 of file udptl.c.
References ast_log(), ast_udptl::local_max_datagram_size, and LOG_WARNING.
Referenced by process_sdp(), and sip_handle_t38_reinvite().
00731 { 00732 if (udptl) 00733 udptl->local_max_datagram_size = max_datagram; 00734 else 00735 ast_log(LOG_WARNING, "udptl structure is null\n"); 00736 }
void ast_udptl_set_m_type | ( | struct ast_udptl * | udptl, | |
int | pt | |||
) |
void ast_udptl_set_peer | ( | struct ast_udptl * | udptl, | |
struct sockaddr_in * | them | |||
) |
Definition at line 838 of file udptl.c.
References ast_udptl::them.
Referenced by process_sdp().
00839 { 00840 udptl->them.sin_port = them->sin_port; 00841 udptl->them.sin_addr = them->sin_addr; 00842 }
void ast_udptl_set_udptlmap_type | ( | struct ast_udptl * | udptl, | |
int | pt, | |||
char * | mimeType, | |||
char * | mimeSubtype | |||
) |
void ast_udptl_setnat | ( | struct ast_udptl * | udptl, | |
int | nat | |||
) |
int ast_udptl_settos | ( | struct ast_udptl * | udptl, | |
int | tos | |||
) |
Definition at line 829 of file udptl.c.
References ast_log(), ast_udptl::fd, and LOG_WARNING.
Referenced by sip_alloc().
00830 { 00831 int res; 00832 00833 if ((res = setsockopt(udptl->fd, IPPROTO_IP, IP_TOS, &tos, sizeof(tos)))) 00834 ast_log(LOG_WARNING, "UDPTL unable to set TOS to %d\n", tos); 00835 return res; 00836 }
void ast_udptl_stop | ( | struct ast_udptl * | udptl | ) |
Definition at line 857 of file udptl.c.
References ast_udptl::them.
Referenced by process_sdp(), and stop_media_flows().
00858 { 00859 memset(&udptl->them.sin_addr, 0, sizeof(udptl->them.sin_addr)); 00860 memset(&udptl->them.sin_port, 0, sizeof(udptl->them.sin_port)); 00861 }
Definition at line 872 of file udptl.c.
References AST_FRAME_MODEM, ast_inet_ntoa(), ast_log(), ast_verbose(), errno, f, len, LOCAL_FAX_MAX_DATAGRAM, LOG_NOTICE, LOG_WARNING, s, seq, udptl_build_packet(), and udptl_debug_test_addr().
Referenced by sip_write().
00873 { 00874 int seq; 00875 int len; 00876 int res; 00877 uint8_t buf[LOCAL_FAX_MAX_DATAGRAM]; 00878 00879 /* If we have no peer, return immediately */ 00880 if (s->them.sin_addr.s_addr == INADDR_ANY) 00881 return 0; 00882 00883 /* If there is no data length, return immediately */ 00884 if (f->datalen == 0) 00885 return 0; 00886 00887 if (f->frametype != AST_FRAME_MODEM) { 00888 ast_log(LOG_WARNING, "UDPTL can only send T.38 data\n"); 00889 return -1; 00890 } 00891 00892 /* Save seq_no for debug output because udptl_build_packet increments it */ 00893 seq = s->tx_seq_no & 0xFFFF; 00894 00895 /* Cook up the UDPTL packet, with the relevant EC info. */ 00896 len = udptl_build_packet(s, buf, f->data, f->datalen); 00897 00898 if (len > 0 && s->them.sin_port && s->them.sin_addr.s_addr) { 00899 if ((res = sendto(s->fd, buf, len, 0, (struct sockaddr *) &s->them, sizeof(s->them))) < 0) 00900 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)); 00901 #if 0 00902 printf("Sent %d bytes of UDPTL data to %s:%d\n", res, ast_inet_ntoa(udptl->them.sin_addr), ntohs(udptl->them.sin_port)); 00903 #endif 00904 if (udptl_debug_test_addr(&s->them)) 00905 ast_verbose("Sent UDPTL packet to %s:%d (type %d, seq %d, len %d)\n", 00906 ast_inet_ntoa(s->them.sin_addr), 00907 ntohs(s->them.sin_port), 0, seq, len); 00908 } 00909 00910 return 0; 00911 }