diff options
author | Mark Michelson <mmichelson@digium.com> | 2010-07-08 22:08:07 +0000 |
---|---|---|
committer | Mark Michelson <mmichelson@digium.com> | 2010-07-08 22:08:07 +0000 |
commit | cd4ebd336f6fdd1fe5d2ad57f06654a9678d88d4 (patch) | |
tree | c05335b563c3f7cb9a3edbf3e101d8e1b80e0be4 /channels/chan_skinny.c | |
parent | 816f26c16ce6cf03cf97b7d0e7af64837283e79d (diff) |
Add IPv6 to Asterisk.
This adds a generic API for accommodating IPv6 and IPv4 addresses
within Asterisk. While many files have been updated to make use of the
API, chan_sip and the RTP code are the files which actually support
IPv6 addresses at the time of this commit. The way has been paved for
easier upgrading for other files in the near future, though.
Big thanks go to Simon Perrault, Marc Blanchet, and Jean-Philippe Dionne
for their hard work on this.
(closes issue #17565)
Reported by: russell
Patches:
asteriskv6-test-report.pdf uploaded by russell (license 2)
Review: https://reviewboard.asterisk.org/r/743
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@274783 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels/chan_skinny.c')
-rw-r--r-- | channels/chan_skinny.c | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/channels/chan_skinny.c b/channels/chan_skinny.c index 2c0224a7c..6ddc3f0cf 100644 --- a/channels/chan_skinny.c +++ b/channels/chan_skinny.c @@ -2804,6 +2804,8 @@ static int skinny_set_rtp_peer(struct ast_channel *c, struct ast_rtp_instance *r struct ast_format_list fmt; struct sockaddr_in us = { 0, }; struct sockaddr_in them = { 0, }; + struct ast_sockaddr them_tmp; + struct ast_sockaddr us_tmp; sub = c->tech_pvt; @@ -2818,7 +2820,8 @@ static int skinny_set_rtp_peer(struct ast_channel *c, struct ast_rtp_instance *r d = l->device; if (rtp){ - ast_rtp_instance_get_remote_address(rtp, &them); + ast_rtp_instance_get_remote_address(rtp, &them_tmp); + ast_sockaddr_to_sin(&them_tmp, &them); /* Shutdown any early-media or previous media on re-invite */ transmit_stopmediatransmission(d, sub); @@ -2832,7 +2835,8 @@ static int skinny_set_rtp_peer(struct ast_channel *c, struct ast_rtp_instance *r ast_verb(1, "Setting payloadType to '%s' (%d ms)\n", ast_getformatname(fmt.bits), fmt.cur_ms); if (!(l->directmedia) || (l->nat)){ - ast_rtp_instance_get_local_address(rtp, &us); + ast_rtp_instance_get_local_address(rtp, &us_tmp); + ast_sockaddr_to_sin(&us_tmp, &us); us.sin_addr.s_addr = us.sin_addr.s_addr ? us.sin_addr.s_addr : d->ourip.s_addr; transmit_startmediatransmission(d, sub, us, fmt); } else { @@ -3702,12 +3706,14 @@ static void start_rtp(struct skinny_subchannel *sub) struct skinny_line *l = sub->parent; struct skinny_device *d = l->device; int hasvideo = 0; + struct ast_sockaddr bindaddr_tmp; ast_mutex_lock(&sub->lock); /* Allocate the RTP */ - sub->rtp = ast_rtp_instance_new("asterisk", sched, &bindaddr, NULL); + ast_sockaddr_from_sin(&bindaddr_tmp, &bindaddr); + sub->rtp = ast_rtp_instance_new("asterisk", sched, &bindaddr_tmp, NULL); if (hasvideo) - sub->vrtp = ast_rtp_instance_new("asterisk", sched, &bindaddr, NULL); + sub->vrtp = ast_rtp_instance_new("asterisk", sched, &bindaddr_tmp, NULL); if (sub->rtp) { ast_rtp_instance_set_prop(sub->rtp, AST_RTP_PROPERTY_RTCP, 1); @@ -5603,6 +5609,8 @@ static int handle_open_receive_channel_ack_message(struct skinny_req *req, struc struct ast_format_list fmt; struct sockaddr_in sin = { 0, }; struct sockaddr_in us = { 0, }; + struct ast_sockaddr sin_tmp; + struct ast_sockaddr us_tmp; uint32_t addr; int port; int status; @@ -5629,8 +5637,10 @@ static int handle_open_receive_channel_ack_message(struct skinny_req *req, struc l = sub->parent; if (sub->rtp) { - ast_rtp_instance_set_remote_address(sub->rtp, &sin); - ast_rtp_instance_get_local_address(sub->rtp, &us); + ast_sockaddr_from_sin(&sin_tmp, &sin); + ast_rtp_instance_set_remote_address(sub->rtp, &sin_tmp); + ast_rtp_instance_get_local_address(sub->rtp, &us_tmp); + ast_sockaddr_to_sin(&us_tmp, &us); us.sin_addr.s_addr = us.sin_addr.s_addr ? us.sin_addr.s_addr : d->ourip.s_addr; } else { ast_log(LOG_ERROR, "No RTP structure, this is very bad\n"); @@ -6802,9 +6812,13 @@ static struct ast_channel *skinny_request(const char *type, format_t format, con } } else if (!strcasecmp(v->name, "host")) { if (type & (TYPE_DEVICE)) { - if (ast_get_ip(&CDEV->addr, v->value)) { + struct ast_sockaddr CDEV_addr_tmp; + + if (ast_get_ip(&CDEV_addr_tmp, v->value)) { ast_log(LOG_WARNING, "Bad IP '%s' at line %d.\n", v->value, v->lineno); } + ast_sockaddr_to_sin(&CDEV_addr_tmp, + &CDEV->addr); continue; } } else if (!strcasecmp(v->name, "port")) { |