[svn-commits] simon.perreault: branch group/v6 r86295 - in /team/group/v6/trunk: channels/ ...
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Thu Oct 18 10:38:29 CDT 2007
Author: simon.perreault
Date: Thu Oct 18 10:38:28 2007
New Revision: 86295
URL: http://svn.digium.com/view/asterisk?view=rev&rev=86295
Log:
Merged viudptl namespace back into base udptl namespace.
Modified:
team/group/v6/trunk/channels/chan_sip.c
team/group/v6/trunk/include/asterisk/udptl.h
team/group/v6/trunk/main/udptl.c
Modified: team/group/v6/trunk/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/group/v6/trunk/channels/chan_sip.c?view=diff&rev=86295&r1=86294&r2=86295
==============================================================================
--- team/group/v6/trunk/channels/chan_sip.c (original)
+++ team/group/v6/trunk/channels/chan_sip.c Thu Oct 18 10:38:28 2007
@@ -1082,7 +1082,7 @@
struct t38properties t38; /*!< T38 settings */
struct sockaddr_storage udptlredirip; /*!< Where our T.38 UDPTL should be going if not to us */
socklen_t udptlredirip_len;
- struct ast_viudptl *udptl; /*!< T.38 UDPTL session */
+ struct ast_udptl *udptl; /*!< T.38 UDPTL session */
int callingpres; /*!< Calling presentation */
int authtries; /*!< Times we've tried to authenticate */
int expiry; /*!< How long we take to expire */
@@ -1810,8 +1810,8 @@
/*------ T38 Support --------- */
static int sip_handle_t38_reinvite(struct ast_channel *chan, struct sip_pvt *pvt, int reinvite);
static int transmit_response_with_t38_sdp(struct sip_pvt *p, char *msg, struct sip_request *req, int retrans);
-static struct ast_viudptl *sip_get_viudptl_peer(struct ast_channel *chan);
-static int sip_set_viudptl_peer(struct ast_channel *chan, struct ast_viudptl *udptl);
+static struct ast_udptl *sip_get_udptl_peer(struct ast_channel *chan);
+static int sip_set_udptl_peer(struct ast_channel *chan, struct ast_udptl *udptl);
/*! \brief Definition of this channel for PBX channel registration */
static const struct ast_channel_tech sip_tech = {
@@ -1929,10 +1929,10 @@
}
/*! \brief Interface structure with callbacks used to connect to UDPTL module*/
-static struct ast_viudptl_protocol sip_udptl = {
+static struct ast_udptl_protocol sip_udptl = {
type: "SIP",
- get_udptl_info: sip_get_viudptl_peer,
- set_udptl_peer: sip_set_viudptl_peer,
+ get_udptl_info: sip_get_udptl_peer,
+ set_udptl_peer: sip_set_udptl_peer,
};
/*! \brief Append to SIP dialog history
@@ -3340,7 +3340,7 @@
}
if (p->udptl) {
ast_debug(1, "Setting NAT on UDPTL to %s\n", mode);
- ast_viudptl_setnat(p->udptl, natflags);
+ ast_udptl_setnat(p->udptl, natflags);
}
if (p->trtp) {
ast_debug(1, "Setting NAT on TRTP to %s\n", mode);
@@ -3390,18 +3390,18 @@
ast_vinetsock_sa_is_ipv4((struct sockaddr*)&dialog->sa)) {
dialog->t38.capability = global_t38_capability;
if (dialog->udptl) {
- if (ast_viudptl_get_error_correction_scheme(dialog->udptl) == UDPTL_ERROR_CORRECTION_FEC )
+ if (ast_udptl_get_error_correction_scheme(dialog->udptl) == UDPTL_ERROR_CORRECTION_FEC )
dialog->t38.capability |= T38FAX_UDP_EC_FEC;
- else if (ast_viudptl_get_error_correction_scheme(dialog->udptl) == UDPTL_ERROR_CORRECTION_REDUNDANCY )
+ else if (ast_udptl_get_error_correction_scheme(dialog->udptl) == UDPTL_ERROR_CORRECTION_REDUNDANCY )
dialog->t38.capability |= T38FAX_UDP_EC_REDUNDANCY;
- else if (ast_viudptl_get_error_correction_scheme(dialog->udptl) == UDPTL_ERROR_CORRECTION_NONE )
+ else if (ast_udptl_get_error_correction_scheme(dialog->udptl) == UDPTL_ERROR_CORRECTION_NONE )
dialog->t38.capability |= T38FAX_UDP_EC_NONE;
dialog->t38.capability |= T38FAX_RATE_MANAGEMENT_TRANSFERED_TCF;
ast_debug(2,"Our T38 capability (%d)\n", dialog->t38.capability);
}
dialog->t38.jointcapability = dialog->t38.capability;
} else if (dialog->udptl) {
- ast_viudptl_destroy(dialog->udptl);
+ ast_udptl_destroy(dialog->udptl);
dialog->udptl = NULL;
}
do_setnat(dialog, ast_test_flag(&dialog->flags[0], SIP_NAT) & SIP_NAT_ROUTE );
@@ -3658,7 +3658,7 @@
if (p->trtp)
ast_rtp_destroy(p->trtp);
if (p->udptl)
- ast_viudptl_destroy(p->udptl);
+ ast_udptl_destroy(p->udptl);
if (p->refer)
ast_free(p->refer);
if (p->route) {
@@ -4308,7 +4308,7 @@
Fax will re-transmit.
*/
if (p->udptl && ast->_state == AST_STATE_UP)
- res = ast_viudptl_write(p->udptl, frame);
+ res = ast_udptl_write(p->udptl, frame);
sip_pvt_unlock(p);
}
break;
@@ -4626,7 +4626,7 @@
ast_channel_set_fd(tmp, 4, ast_rtp_fd(i->trtp));
}
if (i->udptl) {
- ast_channel_set_fd(tmp, 5, ast_viudptl_fd(i->udptl));
+ ast_channel_set_fd(tmp, 5, ast_udptl_fd(i->udptl));
}
if (state == AST_STATE_RING)
tmp->rings = 1;
@@ -4864,7 +4864,7 @@
}
break;
case 5:
- f = ast_viudptl_read(p->udptl); /* UDPTL for T.38 */
+ f = ast_udptl_read(p->udptl); /* UDPTL for T.38 */
break;
default:
f = &ast_null_frame;
@@ -5152,7 +5152,7 @@
ns->bindaddrlen);
if (ast_test_flag(&p->flags[1], SIP_PAGE2_T38SUPPORT) &&
ast_vinetsock_sa_is_ipv4((struct sockaddr*)&ns->bindaddr))
- p->udptl = ast_viudptl_new_with_bindaddr(sched, io, 0,
+ p->udptl = ast_udptl_new_with_bindaddr(sched, io, 0,
(struct sockaddr*)&ns->bindaddr, ns->bindaddrlen);
if (!p->rtp|| (ast_test_flag(&p->flags[1], SIP_PAGE2_VIDEOSUPPORT) && !p->vrtp)
|| (ast_test_flag(&p->flags[1], SIP_PAGE2_TEXTSUPPORT) && !p->trtp)) {
@@ -5187,7 +5187,7 @@
ast_rtp_setdtmfcompensate(p->trtp, 0);
}
if (p->udptl)
- ast_viudptl_setqos(p->udptl, global_tos_audio, global_cos_audio);
+ ast_udptl_setqos(p->udptl, global_tos_audio, global_cos_audio);
p->maxcallbitrate = default_maxcallbitrate;
}
@@ -5216,11 +5216,11 @@
p->noncodeccapability |= AST_RTP_DTMF;
if (p->udptl) {
p->t38.capability = global_t38_capability;
- if (ast_viudptl_get_error_correction_scheme(p->udptl) == UDPTL_ERROR_CORRECTION_REDUNDANCY)
+ if (ast_udptl_get_error_correction_scheme(p->udptl) == UDPTL_ERROR_CORRECTION_REDUNDANCY)
p->t38.capability |= T38FAX_UDP_EC_REDUNDANCY;
- else if (ast_viudptl_get_error_correction_scheme(p->udptl) == UDPTL_ERROR_CORRECTION_FEC)
+ else if (ast_udptl_get_error_correction_scheme(p->udptl) == UDPTL_ERROR_CORRECTION_FEC)
p->t38.capability |= T38FAX_UDP_EC_FEC;
- else if (ast_viudptl_get_error_correction_scheme(p->udptl) == UDPTL_ERROR_CORRECTION_NONE)
+ else if (ast_udptl_get_error_correction_scheme(p->udptl) == UDPTL_ERROR_CORRECTION_NONE)
p->t38.capability |= T38FAX_UDP_EC_NONE;
p->t38.capability |= T38FAX_RATE_MANAGEMENT_TRANSFERED_TCF;
p->t38.jointcapability = p->t38.capability;
@@ -5879,14 +5879,14 @@
if (p->udptl) {
if (udptlportno > 0) {
ast_vinetsock_sa_setport((struct sockaddr *)&sa, udptlportno);
- ast_viudptl_set_peer(p->udptl, (struct sockaddr *)&sa, sa_len);
+ ast_udptl_set_peer(p->udptl, (struct sockaddr *)&sa, sa_len);
/* TODO MB */
if (debug) {
ast_vinetsock_sa_get_hostport((struct sockaddr*)&sa, sa_len, hostport, sizeof(hostport));
ast_log(LOG_DEBUG,"Peer T.38 UDPTL is at port %s\n",hostport);
}
} else {
- ast_viudptl_stop(p->udptl);
+ ast_udptl_stop(p->udptl);
if (debug)
ast_debug(1, "Peer doesn't provide T.38 UDPTL\n");
}
@@ -6071,8 +6071,8 @@
} else if ((sscanf(a, "T38FaxMaxDatagram:%d", &x) == 1)) {
found = 1;
ast_debug(3, "FaxMaxDatagram: %d\n",x);
- ast_viudptl_set_far_max_datagram(p->udptl, x);
- ast_viudptl_set_local_max_datagram(p->udptl, x);
+ ast_udptl_set_far_max_datagram(p->udptl, x);
+ ast_udptl_set_local_max_datagram(p->udptl, x);
} else if ((sscanf(a, "T38FaxFillBitRemoval:%d", &x) == 1)) {
found = 1;
ast_debug(3, "FillBitRemoval: %d\n",x);
@@ -6101,13 +6101,13 @@
ast_debug(3, "UDP EC: %s\n", s);
if (!strcasecmp(s, "t38UDPRedundancy")) {
peert38capability |= T38FAX_UDP_EC_REDUNDANCY;
- ast_viudptl_set_error_correction_scheme(p->udptl, UDPTL_ERROR_CORRECTION_REDUNDANCY);
+ ast_udptl_set_error_correction_scheme(p->udptl, UDPTL_ERROR_CORRECTION_REDUNDANCY);
} else if (!strcasecmp(s, "t38UDPFEC")) {
peert38capability |= T38FAX_UDP_EC_FEC;
- ast_viudptl_set_error_correction_scheme(p->udptl, UDPTL_ERROR_CORRECTION_FEC);
+ ast_udptl_set_error_correction_scheme(p->udptl, UDPTL_ERROR_CORRECTION_FEC);
} else {
peert38capability |= T38FAX_UDP_EC_NONE;
- ast_viudptl_set_error_correction_scheme(p->udptl, UDPTL_ERROR_CORRECTION_NONE);
+ ast_udptl_set_error_correction_scheme(p->udptl, UDPTL_ERROR_CORRECTION_NONE);
}
}
}
@@ -7105,7 +7105,7 @@
p->sessionversion++;
/* Our T.38 end is */
- ast_viudptl_get_us(p->udptl, (struct sockaddr*)&udptlsa, udptlsa_len);
+ ast_udptl_get_us(p->udptl, (struct sockaddr*)&udptlsa, &udptlsa_len);
/* Determine T.38 UDPTL destination */
if (p->udptlredirip_len) {
@@ -7155,7 +7155,7 @@
ast_str_append(&a_modem, 0, "a=T38FaxTranscodingMMR:%d\r\n", (p->t38.jointcapability & T38FAX_TRANSCODING_MMR) ? 1 : 0);
ast_str_append(&a_modem, 0, "a=T38FaxTranscodingJBIG:%d\r\n", (p->t38.jointcapability & T38FAX_TRANSCODING_JBIG) ? 1 : 0);
ast_str_append(&a_modem, 0, "a=T38FaxRateManagement:%s\r\n", (p->t38.jointcapability & T38FAX_RATE_MANAGEMENT_LOCAL_TCF) ? "localTCF" : "transferredTCF");
- x = ast_viudptl_get_local_max_datagram(p->udptl);
+ x = ast_udptl_get_local_max_datagram(p->udptl);
ast_str_append(&a_modem, 0, "a=T38FaxMaxBuffer:%d\r\n",x);
ast_str_append(&a_modem, 0, "a=T38FaxMaxDatagram:%d\r\n",x);
if (p->t38.jointcapability != T38FAX_UDP_EC_NONE)
@@ -7557,7 +7557,7 @@
}
respprep(&resp, p, msg, req);
if (p->udptl) {
- ast_viudptl_offered_from_local(p->udptl, 0);
+ ast_udptl_offered_from_local(p->udptl, 0);
add_t38_sdp(&resp, p);
} else
ast_log(LOG_ERROR, "Can't add SDP to response, since we have no UDPTL session allocated. Call-ID %s\n", p->callid);
@@ -8028,7 +8028,7 @@
}
if (sdp) {
if (p->udptl && p->t38.state == T38_LOCAL_DIRECT) {
- ast_viudptl_offered_from_local(p->udptl, 1);
+ ast_udptl_offered_from_local(p->udptl, 1);
ast_debug(1, "T38 is in state %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>");
add_t38_sdp(&req, p);
} else if (p->rtp)
@@ -13942,7 +13942,7 @@
if (p->trtp)
ast_rtp_stop(p->trtp);
if (p->udptl)
- ast_viudptl_stop(p->udptl);
+ ast_udptl_stop(p->udptl);
}
/*! \brief Handle SIP response in dialogue */
@@ -18728,10 +18728,10 @@
return 0;
}
-static struct ast_viudptl *sip_get_viudptl_peer(struct ast_channel *chan)
+static struct ast_udptl *sip_get_udptl_peer(struct ast_channel *chan)
{
struct sip_pvt *p;
- struct ast_viudptl *udptl = NULL;
+ struct ast_udptl *udptl = NULL;
p = chan->tech_pvt;
if (!p)
@@ -18744,7 +18744,7 @@
return udptl;
}
-static int sip_set_viudptl_peer(struct ast_channel *chan, struct ast_viudptl *udptl)
+static int sip_set_udptl_peer(struct ast_channel *chan, struct ast_udptl *udptl)
{
struct sip_pvt *p;
char hostport[NI_MAXHOST] = "<error>";
@@ -18753,10 +18753,10 @@
if (!p)
return -1;
sip_pvt_lock(p);
- if (udptl) {
- ast_viudptl_get_peer(udptl, (struct sockaddr*)&p->udptlredirip, p->udptlredirip_len);
- p->udptlredirip_len = sizeof(p->udptlredirip);
- } else {
+ if (udptl)
+ ast_udptl_get_peer(udptl, (struct sockaddr*)&p->udptlredirip,
+ &p->udptlredirip_len);
+ else {
memset(&p->udptlredirip, 0, sizeof(p->udptlredirip));
p->udptlredirip_len = 0;
}
@@ -18803,9 +18803,9 @@
maybe it should move there. */
p->t38.jointcapability = p->t38.peercapability = pvt->t38.jointcapability;
- ast_viudptl_set_far_max_datagram(p->udptl, ast_viudptl_get_local_max_datagram(pvt->udptl));
- ast_viudptl_set_local_max_datagram(p->udptl, ast_viudptl_get_local_max_datagram(pvt->udptl));
- ast_viudptl_set_error_correction_scheme(p->udptl, ast_viudptl_get_error_correction_scheme(pvt->udptl));
+ ast_udptl_set_far_max_datagram(p->udptl, ast_udptl_get_local_max_datagram(pvt->udptl));
+ ast_udptl_set_local_max_datagram(p->udptl, ast_udptl_get_local_max_datagram(pvt->udptl));
+ ast_udptl_set_error_correction_scheme(p->udptl, ast_udptl_get_error_correction_scheme(pvt->udptl));
if (reinvite) { /* If we are handling sending re-invite to the other side of the bridge */
/*! \note The SIP_CAN_REINVITE flag is for RTP media redirects,
@@ -18814,10 +18814,12 @@
NAT
*/
if (ast_test_flag(&p->flags[0], SIP_CAN_REINVITE) && ast_test_flag(&pvt->flags[0], SIP_CAN_REINVITE)) {
- ast_viudptl_get_peer(pvt->udptl, (struct sockaddr*)&p->udptlredirip, p->udptlredirip_len);
+ ast_udptl_get_peer(pvt->udptl, (struct sockaddr*)&p->udptlredirip,
+ &p->udptlredirip_len);
flag =1;
} else {
memset(&p->udptlredirip, 0, sizeof(p->udptlredirip));
+ p->udptlredirip_len = 0;
}
if (!ast_test_flag(&p->flags[0], SIP_GOTREFER)) {
if (!p->pendinginvite) {
@@ -18850,10 +18852,12 @@
return 0;
} else { /* If we are handling sending 200 OK to the other side of the bridge */
if (ast_test_flag(&p->flags[0], SIP_CAN_REINVITE) && ast_test_flag(&pvt->flags[0], SIP_CAN_REINVITE)) {
- ast_viudptl_get_peer(pvt->udptl, (struct sockaddr*)&p->udptlredirip, p->udptlredirip_len);
+ ast_udptl_get_peer(pvt->udptl, (struct sockaddr*)&p->udptlredirip,
+ &p->udptlredirip_len);
flag = 1;
} else {
memset(&p->udptlredirip, 0, sizeof(p->udptlredirip));
+ p->udptlredirip_len = 0;
}
if (flag) {
ast_vinetsock_sa_get_hostport((struct sockaddr*)&p->udptlredirip,
@@ -19380,7 +19384,7 @@
ast_rtp_proto_register(&sip_rtp);
/* Tell the UDPTL subdriver that we're here */
- ast_viudptl_proto_register(&sip_udptl);
+ ast_udptl_proto_register(&sip_udptl);
/* Register dialplan applications */
ast_register_application(app_dtmfmode, sip_dtmfmode, synopsis_dtmfmode, descrip_dtmfmode);
@@ -19432,7 +19436,7 @@
ast_rtp_proto_unregister(&sip_rtp);
/* Disconnect from UDPTL */
- ast_viudptl_proto_unregister(&sip_udptl);
+ ast_udptl_proto_unregister(&sip_udptl);
/* Unregister AMI actions */
ast_manager_unregister("SIPpeers");
Modified: team/group/v6/trunk/include/asterisk/udptl.h
URL: http://svn.digium.com/view/asterisk/team/group/v6/trunk/include/asterisk/udptl.h?view=diff&rev=86295&r1=86294&r2=86295
==============================================================================
--- team/group/v6/trunk/include/asterisk/udptl.h (original)
+++ team/group/v6/trunk/include/asterisk/udptl.h Thu Oct 18 10:38:28 2007
@@ -51,13 +51,17 @@
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);
+struct ast_udptl *ast_udptl_new_with_bindaddr(struct sched_context *sched,
+ struct io_context *io, int callbackmode,
+ const struct sockaddr *in, socklen_t in_len);
-void ast_udptl_set_peer(struct ast_udptl *udptl, struct sockaddr_in *them);
+void ast_udptl_set_peer(struct ast_udptl *udptl,
+ struct sockaddr *them, socklen_t them_len);
-void ast_udptl_get_peer(struct ast_udptl *udptl, struct sockaddr_in *them);
+void ast_udptl_get_peer(struct ast_udptl *udptl,
+ struct sockaddr *them, socklen_t *them_len);
-void ast_udptl_get_us(struct ast_udptl *udptl, struct sockaddr_in *us);
+void ast_udptl_get_us(struct ast_udptl *udptl, struct sockaddr *us, socklen_t *us_len);
void ast_udptl_destroy(struct ast_udptl *udptl);
@@ -113,86 +117,6 @@
void ast_udptl_reload(void);
-/* IP version independent versions */
-/* Marc Blanchet */
-
-#include "asterisk/netsock.h"
-
-struct ast_viudptl_protocol {
- /* Get UDPTL struct, or NULL if unwilling to transfer */
- struct ast_viudptl *(*get_udptl_info)(struct ast_channel *chan);
- /* Set UDPTL peer */
- int (* const set_udptl_peer)(struct ast_channel *chan, struct ast_viudptl *peer);
- const char * const type;
- struct ast_viudptl_protocol *next;
-};
-
-struct ast_viudptl;
-
-typedef int (*ast_viudptl_callback)(struct ast_viudptl *udptl, struct ast_frame *f, void *data);
-
-struct ast_viudptl *ast_viudptl_new(struct sched_context *sched, struct io_context *io, int callbackmode);
-
-struct ast_viudptl *ast_viudptl_new_with_bindaddr(struct sched_context *sched, struct io_context *io, int callbackmode, struct sockaddr *sa, socklen_t salen);
-
-void ast_viudptl_set_peer(struct ast_viudptl *udptl, struct sockaddr *them, socklen_t themlen);
-
-void ast_viudptl_get_peer(struct ast_viudptl *udptl, struct sockaddr *them, socklen_t themlen);
-
-void ast_viudptl_get_us(struct ast_viudptl *udptl, struct sockaddr *us, socklen_t uslen);
-
-void ast_viudptl_destroy(struct ast_viudptl *udptl);
-
-void ast_viudptl_reset(struct ast_viudptl *udptl);
-
-void ast_viudptl_set_callback(struct ast_viudptl *udptl, ast_viudptl_callback callback);
-
-void ast_viudptl_set_data(struct ast_viudptl *udptl, void *data);
-
-int ast_viudptl_write(struct ast_viudptl *udptl, struct ast_frame *f);
-
-struct ast_frame *ast_viudptl_read(struct ast_viudptl *udptl);
-
-int ast_viudptl_fd(struct ast_viudptl *udptl);
-
-int ast_viudptl_setqos(struct ast_viudptl *udptl, int tos, int cos);
-
-int ast_viudptl_settos(struct ast_viudptl *udptl, int tos);
-
-void ast_viudptl_set_m_type(struct ast_viudptl* udptl, int pt);
-
-void ast_viudptl_set_udptlmap_type(struct ast_viudptl* udptl, int pt,
- char* mimeType, char* mimeSubtype);
-
-int ast_viudptl_lookup_code(struct ast_viudptl* udptl, int isAstFormat, int code);
-
-void ast_viudptl_offered_from_local(struct ast_viudptl* udptl, int local);
-
-int ast_viudptl_get_error_correction_scheme(struct ast_viudptl* udptl);
-
-void ast_viudptl_set_error_correction_scheme(struct ast_viudptl* udptl, int ec);
-
-int ast_viudptl_get_local_max_datagram(struct ast_viudptl* udptl);
-
-void ast_viudptl_set_local_max_datagram(struct ast_viudptl* udptl, int max_datagram);
-
-int ast_viudptl_get_far_max_datagram(struct ast_viudptl* udptl);
-
-void ast_viudptl_set_far_max_datagram(struct ast_viudptl* udptl, int max_datagram);
-
-void ast_viudptl_get_current_formats(struct ast_viudptl* udptl,
- int* astFormats, int* nonAstFormats);
-
-void ast_viudptl_setnat(struct ast_viudptl *udptl, int nat);
-
-int ast_viudptl_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags, struct ast_frame **fo, struct ast_channel **rc);
-
-int ast_viudptl_proto_register(struct ast_viudptl_protocol *proto);
-
-void ast_viudptl_proto_unregister(struct ast_viudptl_protocol *proto);
-
-void ast_viudptl_stop(struct ast_viudptl *udptl);
-
#if defined(__cplusplus) || defined(c_plusplus)
}
#endif
Modified: team/group/v6/trunk/main/udptl.c
URL: http://svn.digium.com/view/asterisk/team/group/v6/trunk/main/udptl.c?view=diff&rev=86295&r1=86294&r2=86295
==============================================================================
--- team/group/v6/trunk/main/udptl.c (original)
+++ team/group/v6/trunk/main/udptl.c Thu Oct 18 10:38:28 2007
@@ -90,7 +90,8 @@
static int udptlstart;
static int udptlend;
static int udptldebug; /*!< Are we debugging? */
-static struct sockaddr_in udptldebugaddr; /*!< Debug packets to/from this host */
+static struct sockaddr_storage udptldebugaddr; /*!< Debug packets to/from this host */
+static socklen_t udptldebugaddr_len;
#ifdef SO_NO_CHECK
static int nochecksums;
#endif
@@ -128,8 +129,10 @@
unsigned int lasteventseqn;
int nat;
int flags;
- struct sockaddr_in us;
- struct sockaddr_in them;
+ struct sockaddr_storage us;
+ socklen_t us_len;
+ struct sockaddr_storage them;
+ socklen_t them_len;
int *ioid;
uint16_t seqno;
struct sched_context *sched;
@@ -160,7 +163,8 @@
int verbose;
- struct sockaddr_in far;
+ struct sockaddr_storage far;
+ socklen_t far_len;
int tx_seq_no;
int rx_seq_no;
@@ -175,14 +179,18 @@
static int udptl_rx_packet(struct ast_udptl *s, uint8_t *buf, int len);
static int udptl_build_packet(struct ast_udptl *s, uint8_t *buf, uint8_t *ifp, int ifp_len);
-static inline int udptl_debug_test_addr(struct sockaddr_in *addr)
+static inline int udptl_debug_test_addr(struct sockaddr *addr, socklen_t addr_len)
{
if (udptldebug == 0)
return 0;
- if (udptldebugaddr.sin_addr.s_addr) {
- if (((ntohs(udptldebugaddr.sin_port) != 0)
- && (udptldebugaddr.sin_port != addr->sin_port))
- || (udptldebugaddr.sin_addr.s_addr != addr->sin_addr.s_addr))
+ if (udptldebugaddr_len) {
+ if ((ast_vinetsock_sa_getport((struct sockaddr*)&udptldebugaddr,
+ udptldebugaddr_len) != 0
+ && ast_vinetsock_sacmp_port(
+ (struct sockaddr*)&udptldebugaddr,
+ udptldebugaddr_len, addr, addr_len))
+ || ast_vinetsock_sacmp((struct sockaddr*)&udptldebugaddr,
+ udptldebugaddr_len, addr, addr_len, 1))
return 0;
}
return 1;
@@ -665,20 +673,19 @@
struct ast_frame *ast_udptl_read(struct ast_udptl *udptl)
{
int res;
- struct sockaddr_in sin;
- socklen_t len;
+ struct sockaddr_storage sa;
+ socklen_t salen = 0;
uint16_t seqno = 0;
uint16_t *udptlheader;
-
- len = sizeof(sin);
-
+ char hostport[NI_MAXHOST] = "<error>";
+
/* Cache where the header will go */
res = recvfrom(udptl->fd,
udptl->rawdata + AST_FRIENDLY_OFFSET,
sizeof(udptl->rawdata) - AST_FRIENDLY_OFFSET,
0,
- (struct sockaddr *) &sin,
- &len);
+ (struct sockaddr *) &sa,
+ &salen);
udptlheader = (uint16_t *)(udptl->rawdata + AST_FRIENDLY_OFFSET);
if (res < 0) {
if (errno != EAGAIN)
@@ -689,24 +696,27 @@
}
/* Ignore if the other side hasn't been given an address yet. */
- if (!udptl->them.sin_addr.s_addr || !udptl->them.sin_port)
+ if (!udptl->them_len)
return &ast_null_frame;
+
+ ast_vinetsock_sa_get_hostport((struct sockaddr*)&udptl->them, udptl->them_len,
+ hostport, sizeof(hostport));
if (udptl->nat) {
/* Send to whoever sent to us */
- if ((udptl->them.sin_addr.s_addr != sin.sin_addr.s_addr) ||
- (udptl->them.sin_port != sin.sin_port)) {
- memcpy(&udptl->them, &sin, sizeof(udptl->them));
- ast_debug(1, "UDPTL NAT: Using address %s:%d\n", ast_inet_ntoa(udptl->them.sin_addr), ntohs(udptl->them.sin_port));
- }
- }
-
- if (udptl_debug_test_addr(&sin)) {
- ast_verb(1, "Got UDPTL packet from %s:%d (type %d, seq %d, len %d)\n",
- ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port), 0, seqno, res);
+ if (ast_vinetsock_sacmp((struct sockaddr*)&udptl->them, udptl->them_len,
+ (struct sockaddr*)&sa, salen, 0)) {
+ memcpy(&udptl->them, &sa, salen);
+ ast_debug(1, "UDPTL NAT: Using address %s\n", hostport);
+ }
+ }
+
+ if (udptl_debug_test_addr((struct sockaddr*)&sa, salen)) {
+ ast_verb(1, "Got UDPTL packet from %s (type %d, seq %d, len %d)\n",
+ hostport, 0, seqno, res);
}
#if 0
- printf("Got UDPTL packet from %s:%d (seq %d, len = %d)\n", ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port), seqno, res);
+ printf("Got UDPTL packet from %s:%d (seq %d, len = %d)\n", ast_inet_ntoa(sa.sin_addr), ntohs(sa.sin_port), seqno, res);
#endif
udptl_rx_packet(udptl, udptl->rawdata + AST_FRIENDLY_OFFSET, res);
@@ -787,7 +797,9 @@
ast_log(LOG_WARNING, "udptl structure is null\n");
}
-struct ast_udptl *ast_udptl_new_with_bindaddr(struct sched_context *sched, struct io_context *io, int callbackmode, struct in_addr addr)
+struct ast_udptl *ast_udptl_new_with_bindaddr(struct sched_context *sched,
+ struct io_context *io, int callbackmode,
+ const struct sockaddr *addr, socklen_t addr_len)
{
struct ast_udptl *udptl;
int x;
@@ -818,8 +830,6 @@
}
udptl->seqno = ast_random() & 0xffff;
- udptl->them.sin_family = AF_INET;
- udptl->us.sin_family = AF_INET;
if ((udptl->fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
ast_free(udptl);
@@ -836,8 +846,8 @@
x = (ast_random() % (udptlend - udptlstart)) + udptlstart;
startplace = x;
for (;;) {
- udptl->us.sin_port = htons(x);
- udptl->us.sin_addr = addr;
+ memcpy(&udptl->us, addr, addr_len);
+ ast_vinetsock_sa_setport((struct sockaddr*)&udptl->us, x);
if (bind(udptl->fd, (struct sockaddr *) &udptl->us, sizeof(udptl->us)) == 0)
break;
if (errno != EADDRINUSE) {
@@ -866,9 +876,7 @@
struct ast_udptl *ast_udptl_new(struct sched_context *sched, struct io_context *io, int callbackmode)
{
- struct in_addr ia;
- memset(&ia, 0, sizeof(ia));
- return ast_udptl_new_with_bindaddr(sched, io, callbackmode, ia);
+ return ast_udptl_new_with_bindaddr(sched, io, callbackmode, NULL, 0);
}
int ast_udptl_setqos(struct ast_udptl *udptl, int tos, int cos)
@@ -876,28 +884,30 @@
return ast_netsock_set_qos(udptl->fd, tos, cos);
}
-void ast_udptl_set_peer(struct ast_udptl *udptl, struct sockaddr_in *them)
-{
- udptl->them.sin_port = them->sin_port;
- udptl->them.sin_addr = them->sin_addr;
-}
-
-void ast_udptl_get_peer(struct ast_udptl *udptl, struct sockaddr_in *them)
-{
- them->sin_family = AF_INET;
- them->sin_port = udptl->them.sin_port;
- them->sin_addr = udptl->them.sin_addr;
-}
-
-void ast_udptl_get_us(struct ast_udptl *udptl, struct sockaddr_in *us)
-{
- memcpy(us, &udptl->us, sizeof(udptl->us));
+void ast_udptl_set_peer(struct ast_udptl *udptl,
+ struct sockaddr *them, socklen_t them_len)
+{
+ memcpy(&udptl->them, them, them_len);
+ udptl->them_len = them_len;
+}
+
+void ast_udptl_get_peer(struct ast_udptl *udptl,
+ struct sockaddr *them, socklen_t *them_len)
+{
+ memcpy(them, &udptl->them, udptl->them_len);
+ *them_len = udptl->them_len;
+}
+
+void ast_udptl_get_us(struct ast_udptl *udptl, struct sockaddr *us, socklen_t *us_len)
+{
+ memcpy(us, &udptl->us, udptl->us_len);
+ *us_len = udptl->us_len;
}
void ast_udptl_stop(struct ast_udptl *udptl)
{
- memset(&udptl->them.sin_addr, 0, sizeof(udptl->them.sin_addr));
- memset(&udptl->them.sin_port, 0, sizeof(udptl->them.sin_port));
+ bzero(&udptl->them, sizeof(udptl->them));
+ udptl->them_len = 0;
}
void ast_udptl_destroy(struct ast_udptl *udptl)
@@ -916,7 +926,7 @@
uint8_t buf[LOCAL_FAX_MAX_DATAGRAM];
/* If we have no peer, return immediately */
- if (s->them.sin_addr.s_addr == INADDR_ANY)
+ if (!s->them_len)
return 0;
/* If there is no data length, return immediately */
@@ -931,16 +941,21 @@
/* Cook up the UDPTL packet, with the relevant EC info. */
len = udptl_build_packet(s, buf, f->data, f->datalen);
- if (len > 0 && s->them.sin_port && s->them.sin_addr.s_addr) {
- if ((res = sendto(s->fd, buf, len, 0, (struct sockaddr *) &s->them, sizeof(s->them))) < 0)
- 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));
+ if (len > 0 && s->them_len) {
+ char hostport[NI_MAXHOST] = "<error>";
+ ast_vinetsock_sa_get_hostport((struct sockaddr*)&s->them, s->them_len,
+ hostport, sizeof(hostport));
+
+ if ((res = sendto(s->fd, buf, len, 0, (struct sockaddr*)&s->them,
+ s->them_len)) < 0)
+ ast_log(LOG_NOTICE, "UDPTL Transmission error to %s: %s\n",
+ hostport, strerror(errno));
#if 0
printf("Sent %d bytes of UDPTL data to %s:%d\n", res, ast_inet_ntoa(udptl->them.sin_addr), ntohs(udptl->them.sin_port));
#endif
- if (udptl_debug_test_addr(&s->them))
- ast_verbose("Sent UDPTL packet to %s:%d (type %d, seq %d, len %d)\n",
- ast_inet_ntoa(s->them.sin_addr),
- ntohs(s->them.sin_port), 0, s->seqno, len);
+ if (udptl_debug_test_addr((struct sockaddr*)&s->them, s->them_len))
+ ast_verbose("Sent UDPTL packet to %s (type %d, seq %d, len %d)\n",
+ hostport, 0, s->seqno, len);
}
return 0;
@@ -993,13 +1008,14 @@
struct ast_udptl *p1;
struct ast_udptl_protocol *pr0;
struct ast_udptl_protocol *pr1;
- struct sockaddr_in ac0;
- struct sockaddr_in ac1;
- struct sockaddr_in t0;
- struct sockaddr_in t1;
+ struct sockaddr_storage ac0; socklen_t ac0_len;
+ struct sockaddr_storage ac1; socklen_t ac1_len;
+ struct sockaddr_storage t0; socklen_t t0_len;
+ struct sockaddr_storage t1; socklen_t t1_len;
void *pvt0;
void *pvt1;
int to;
+ char hostport[NI_MAXHOST] = "<error>";
ast_channel_lock(c0);
while (ast_channel_trylock(c1)) {
@@ -1035,13 +1051,13 @@
ast_log(LOG_WARNING, "Channel '%s' failed to talk to '%s'\n", c0->name, c1->name);
} else {
/* Store UDPTL peer */
- ast_udptl_get_peer(p1, &ac1);
+ ast_udptl_get_peer(p1, (struct sockaddr*)&ac1, &ac1_len);
}
if (pr1->set_udptl_peer(c1, p0))
ast_log(LOG_WARNING, "Channel '%s' failed to talk back to '%s'\n", c1->name, c0->name);
else {
/* Store UDPTL peer */
- ast_udptl_get_peer(p0, &ac0);
+ ast_udptl_get_peer(p0, (struct sockaddr*)&ac0, &ac0_len);
}
ast_channel_unlock(c0);
ast_channel_unlock(c1);
@@ -1057,21 +1073,35 @@
return -3;
}
to = -1;
- ast_udptl_get_peer(p1, &t1);
- ast_udptl_get_peer(p0, &t0);
- if (inaddrcmp(&t1, &ac1)) {
- ast_debug(1, "Oooh, '%s' changed end address to %s:%d\n",
- c1->name, ast_inet_ntoa(t1.sin_addr), ntohs(t1.sin_port));
- ast_debug(1, "Oooh, '%s' was %s:%d\n",
- c1->name, ast_inet_ntoa(ac1.sin_addr), ntohs(ac1.sin_port));
- memcpy(&ac1, &t1, sizeof(ac1));
- }
- if (inaddrcmp(&t0, &ac0)) {
- ast_debug(1, "Oooh, '%s' changed end address to %s:%d\n",
- c0->name, ast_inet_ntoa(t0.sin_addr), ntohs(t0.sin_port));
- ast_debug(1, "Oooh, '%s' was %s:%d\n",
- c0->name, ast_inet_ntoa(ac0.sin_addr), ntohs(ac0.sin_port));
- memcpy(&ac0, &t0, sizeof(ac0));
+ ast_udptl_get_peer(p1, (struct sockaddr*)&t1, &t1_len);
+ ast_udptl_get_peer(p0, (struct sockaddr*)&t0, &t0_len);
+ if (ast_vinetsock_sacmp((struct sockaddr*)&t1, t1_len,
+ (struct sockaddr*)&ac1, ac1_len, 0)) {
+ ast_vinetsock_sa_get_hostport((struct sockaddr *)&t1, t1_len,
+ hostport, sizeof(hostport));
+ ast_debug(1, "Oooh, '%s' changed end address to %s\n",
+ c1->name, hostport);
+
+ ast_vinetsock_sa_get_hostport((struct sockaddr *)&ac1, ac1_len,
+ hostport, sizeof(hostport));
+ ast_debug(1, "Oooh, '%s' was %s\n", c1->name, hostport);
+
+ memcpy(&ac1, &t1, t1_len);
+ ac1_len = t1_len;
+ }
+ if (ast_vinetsock_sacmp((struct sockaddr*)&t0, t0_len,
+ (struct sockaddr*)&ac0, ac0_len, 0)) {
+ ast_vinetsock_sa_get_hostport((struct sockaddr *)&t0, t0_len,
+ hostport, sizeof(hostport));
+ ast_debug(1, "Oooh, '%s' changed end address to %s\n",
+ c0->name, hostport);
+
+ ast_vinetsock_sa_get_hostport((struct sockaddr *)&ac0, ac0_len,
+ hostport, sizeof(hostport));
+ ast_debug(1, "Oooh, '%s' was %s\n", c0->name, hostport);
+
+ memcpy(&ac0, &t0, t0_len);
+ ac0_len = t0_len;
}
who = ast_waitfor_n(cs, 2, &to);
if (!who) {
@@ -1109,11 +1139,8 @@
static char *handle_cli_udptl_debug_ip(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
- struct hostent *hp;
- struct ast_hostent ahp;
- int port;
- char *p;
- char *arg;
+ char host[NI_MAXHOST] = "<error>";
+ char port[NI_MAXSERV] = "<error>";
switch (cmd) {
case CLI_INIT:
@@ -1126,27 +1153,20 @@
return NULL;
}
- port = 0;
-
if (a->argc != 4)
return CLI_SHOWUSAGE;
- arg = a->argv[3];
- p = strstr(arg, ":");
- if (p) {
- *p = '\0';
- p++;
- port = atoi(p);
- }
- hp = ast_gethostbyname(arg, &ahp);
- if (hp == NULL)
+
+ if (ast_vinetsock_str2hp(host, sizeof(host), port, sizeof(port), a->argv[3], 1,
+ NULL))
return CLI_SHOWUSAGE;
- udptldebugaddr.sin_family = AF_INET;
- memcpy(&udptldebugaddr.sin_addr, hp->h_addr, sizeof(udptldebugaddr.sin_addr));
- udptldebugaddr.sin_port = htons(port);
- if (port == 0)
- ast_cli(a->fd, "UDPTL Debugging Enabled for IP: %s\n", ast_inet_ntoa(udptldebugaddr.sin_addr));
- else
- ast_cli(a->fd, "UDPTL Debugging Enabled for IP: %s:%d\n", ast_inet_ntoa(udptldebugaddr.sin_addr), port);
+ if (ast_vinetsock_sa_fromstr(host, port, (struct sockaddr*)&udptldebugaddr,
+ &udptldebugaddr_len, AF_UNSPEC, 1))
+ return CLI_SHOWUSAGE;
+
+ ast_vinetsock_sa_get_hostport((struct sockaddr*)&udptldebugaddr,
+ udptldebugaddr_len, host, sizeof(host));
+ ast_cli(a->fd, "UDPTL Debugging Enabled for IP: %s\n", host);
+
udptldebug = 1;
return CLI_SUCCESS;
}
@@ -1196,28 +1216,10 @@
return CLI_SUCCESS;
}
-/* XXX: remove this when the VI namespace is removed */
-static const char debug_usage[] =
- "Usage: udptl debug [ip host[:port]]\n"
- " Enable dumping of all UDPTL packets to and from host.\n";
-
-/* forward declaration of version independent versions of debug functions */
-static int viudptl_do_debug_ip(int fd, int argc, char *argv[]);
-static int viudptl_do_debug(int fd, int argc, char *argv[]);
-
static struct ast_cli_entry cli_udptl[] = {
NEW_CLI(handle_cli_udptl_debug, "Enable UDPTL debugging"),
NEW_CLI(handle_cli_udptl_debug_ip, "Enable UDPTL debugging on IP"),
- NEW_CLI(handle_cli_udptl_debug_off, "Disable UDPTL debugging"),
-
-/* temporary new cmds to debug version independent mode */
- { { "udptl", "videbug", NULL },
- viudptl_do_debug, "Enable UDPTL debugging",
- debug_usage },
-
- { { "udptl", "videbug", "ip", NULL },
- viudptl_do_debug, "Enable UDPTL debugging on IP",
- debug_usage }
+ NEW_CLI(handle_cli_udptl_debug_off, "Disable UDPTL debugging")
};
static void __ast_udptl_reload(int reload)
@@ -1309,981 +1311,3 @@
ast_cli_register_multiple(cli_udptl, sizeof(cli_udptl) / sizeof(struct ast_cli_entry));
__ast_udptl_reload(0);
}
-
-/*!
- *
- * New versions of udptl routines for IP version independence(IPv4 and IPv6)
- * new routines start with ast_viudptl
- * using a new namespace to avoid conflict with current code
- * so any channel and module can transition to IPv6 one at a time.
- * duplicate code however is not automatically synched with changes
- *
- * \author Marc Blanchet <marc.blanchet at viagenie.ca>
- * Copyright (C) 2006, Viagenie, Inc.
- */
-
-#include "asterisk/netsock.h"
-
-static struct sockaddr_storage viudptldebugaddr; /* Debug packets to/from this host */
-static socklen_t viudptldebugaddr_len = 0;
-
-struct ast_viudptl {
- int fd;
- char resp;
- struct ast_frame f[16];
- unsigned char rawdata[8192 + AST_FRIENDLY_OFFSET];
- unsigned int lasteventseqn;
- int nat;
- int flags;
- struct sockaddr_storage us;
- socklen_t us_len;
- struct sockaddr_storage them;
- socklen_t them_len;
- int *ioid;
- uint16_t seqno;
- struct sched_context *sched;
- struct io_context *io;
- void *data;
- ast_viudptl_callback callback;
- int udptl_offered_from_local;
-
- /*! This option indicates the error correction scheme used in transmitted UDPTL
- packets. */
- int error_correction_scheme;
-
- /*! This option indicates the number of error correction entries transmitted in
- UDPTL packets. */
- int error_correction_entries;
-
- /*! This option indicates the span of the error correction entries in transmitted
- UDPTL packets (FEC only). */
- int error_correction_span;
-
- /*! This option indicates the maximum size of a UDPTL packet that can be accepted by
- the remote device. */
- int far_max_datagram_size;
-
- /*! This option indicates the maximum size of a UDPTL packet that we are prepared to
- accept. */
- int local_max_datagram_size;
-
- int verbose;
-
- struct sockaddr_storage far;
- socklen_t farlen;
-
- int tx_seq_no;
- int rx_seq_no;
- int rx_expected_seq_no;
-
- udptl_fec_tx_buffer_t tx[UDPTL_BUF_MASK + 1];
- udptl_fec_rx_buffer_t rx[UDPTL_BUF_MASK + 1];
-};
-
-static struct ast_viudptl_protocol *viprotos;
-
-static int viudptl_rx_packet(struct ast_viudptl *s, uint8_t *buf, int len);
-static int viudptl_build_packet(struct ast_viudptl *s, uint8_t *buf, uint8_t *ifp, int ifp_len);
-
-static inline int viudptl_debug_test_addr(struct sockaddr *addr, socklen_t addr_len)
-{
- if (udptldebug == 0)
- return 0;
-
- if (viudptldebugaddr_len) {
- if (((ast_vinetsock_sa_getport((struct sockaddr*)&viudptldebugaddr, viudptldebugaddr_len) != 0)
- && ast_vinetsock_sacmp_port((struct sockaddr*)&viudptldebugaddr, viudptldebugaddr_len, addr, addr_len))
- || ast_vinetsock_sacmp((struct sockaddr*)&viudptldebugaddr, viudptldebugaddr_len, addr, addr_len, 1))
- return 0;
- }
- return 1;
-}
-
-static int viudptl_rx_packet(struct ast_viudptl *s, uint8_t *buf, int len)
-{
- int stat;
- int stat2;
- int i;
- int j;
- int k;
- int l;
- int m;
- int x;
- int limit;
- int which;
- int ptr;
- int count;
- int total_count;
- int seq_no;
- const uint8_t *ifp;
- const uint8_t *data;
- int ifp_len;
- int repaired[16];
- const uint8_t *bufs[16];
- int lengths[16];
- int span;
- int entries;
- int ifp_no;
-
- ptr = 0;
- ifp_no = 0;
- memset(&s->f[0], 0, sizeof(s->f[0]));
-
- /* Decode seq_number */
- if (ptr + 2 > len)
- return -1;
- seq_no = (buf[0] << 8) | buf[1];
- ptr += 2;
-
- /* Break out the primary packet */
- if ((stat = decode_open_type(buf, len, &ptr, &ifp, &ifp_len)) != 0)
- return -1;
- /* Decode error_recovery */
- if (ptr + 1 > len)
- return -1;
- if ((buf[ptr++] & 0x80) == 0) {
- /* Secondary packet mode for error recovery */
- if (seq_no > s->rx_seq_no) {
- /* We received a later packet than we expected, so we need to check if we can fill in the gap from the
- secondary packets. */
- total_count = 0;
- do {
- if ((stat2 = decode_length(buf, len, &ptr, &count)) < 0)
- return -1;
- for (i = 0; i < count; i++) {
- if ((stat = decode_open_type(buf, len, &ptr, &bufs[total_count + i], &lengths[total_count + i])) != 0)
- return -1;
- }
- total_count += count;
- }
- while (stat2 > 0);
- /* Step through in reverse order, so we go oldest to newest */
- for (i = total_count; i > 0; i--) {
- if (seq_no - i >= s->rx_seq_no) {
- /* This one wasn't seen before */
- /* Decode the secondary IFP packet */
- //fprintf(stderr, "Secondary %d, len %d\n", seq_no - i, lengths[i - 1]);
- s->f[ifp_no].frametype = AST_FRAME_MODEM;
- s->f[ifp_no].subclass = AST_MODEM_T38;
-
- s->f[ifp_no].mallocd = 0;
- //s->f[ifp_no].???seq_no = seq_no - i;
- s->f[ifp_no].datalen = lengths[i - 1];
- s->f[ifp_no].data = (uint8_t *) bufs[i - 1];
- s->f[ifp_no].offset = 0;
- s->f[ifp_no].src = "UDPTL";
- if (ifp_no > 0)
- AST_LIST_NEXT(&s->f[ifp_no - 1], frame_list) = &s->f[ifp_no];
- AST_LIST_NEXT(&s->f[ifp_no], frame_list) = NULL;
- ifp_no++;
- }
- }
- }
- /* If packets are received out of sequence, we may have already processed this packet from the error
- recovery information in a packet already received. */
- if (seq_no >= s->rx_seq_no) {
- /* Decode the primary IFP packet */
- s->f[ifp_no].frametype = AST_FRAME_MODEM;
- s->f[ifp_no].subclass = AST_MODEM_T38;
-
- s->f[ifp_no].mallocd = 0;
- //s->f[ifp_no].???seq_no = seq_no;
- s->f[ifp_no].datalen = ifp_len;
- s->f[ifp_no].data = (uint8_t *) ifp;
- s->f[ifp_no].offset = 0;
- s->f[ifp_no].src = "UDPTL";
- if (ifp_no > 0)
- AST_LIST_NEXT(&s->f[ifp_no - 1], frame_list) = &s->f[ifp_no];
- AST_LIST_NEXT(&s->f[ifp_no], frame_list) = NULL;
- }
- }
- else
- {
- /* FEC mode for error recovery */
- /* Our buffers cannot tolerate overlength IFP packets in FEC mode */
- if (ifp_len > LOCAL_FAX_MAX_DATAGRAM)
- return -1;
- /* Update any missed slots in the buffer */
- for ( ; seq_no > s->rx_seq_no; s->rx_seq_no++) {
- x = s->rx_seq_no & UDPTL_BUF_MASK;
- s->rx[x].buf_len = -1;
- s->rx[x].fec_len[0] = 0;
- s->rx[x].fec_span = 0;
- s->rx[x].fec_entries = 0;
- }
-
- x = seq_no & UDPTL_BUF_MASK;
-
- memset(repaired, 0, sizeof(repaired));
-
- /* Save the new IFP packet */
- memcpy(s->rx[x].buf, ifp, ifp_len);
- s->rx[x].buf_len = ifp_len;
- repaired[x] = TRUE;
-
- /* Decode the FEC packets */
- /* The span is defined as an unconstrained integer, but will never be more
- than a small value. */
- if (ptr + 2 > len)
- return -1;
- if (buf[ptr++] != 1)
- return -1;
- span = buf[ptr++];
- s->rx[x].fec_span = span;
-
- /* The number of entries is defined as a length, but will only ever be a small
- value. Treat it as such. */
- if (ptr + 1 > len)
- return -1;
- entries = buf[ptr++];
- s->rx[x].fec_entries = entries;
-
- /* Decode the elements */
- for (i = 0; i < entries; i++) {
[... 748 lines stripped ...]
More information about the svn-commits
mailing list