[asterisk-commits] file: trunk r187773 - in /trunk: main/rtp_engine.c res/res_rtp_asterisk.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Apr 10 13:14:50 CDT 2009
Author: file
Date: Fri Apr 10 13:14:47 2009
New Revision: 187773
URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=187773
Log:
Change how we set the local and remote address.
The code will now only change the address and port. It will not overwrite any other values.
Modified:
trunk/main/rtp_engine.c
trunk/res/res_rtp_asterisk.c
Modified: trunk/main/rtp_engine.c
URL: http://svn.digium.com/svn-view/asterisk/trunk/main/rtp_engine.c?view=diff&rev=187773&r1=187772&r2=187773
==============================================================================
--- trunk/main/rtp_engine.c (original)
+++ trunk/main/rtp_engine.c Fri Apr 10 13:14:47 2009
@@ -312,7 +312,9 @@
return NULL;
}
instance->engine = engine;
- memcpy(&instance->local_address, sin, sizeof(instance->local_address));
+ instance->local_address.sin_family = AF_INET;
+ instance->local_address.sin_addr = sin->sin_addr;
+ instance->remote_address.sin_family = AF_INET;
ast_debug(1, "Using engine '%s' for RTP instance '%p'\n", engine->name, instance);
@@ -350,20 +352,22 @@
int ast_rtp_instance_set_local_address(struct ast_rtp_instance *instance, struct sockaddr_in *address)
{
- memcpy(&instance->local_address, address, sizeof(instance->local_address));
+ instance->local_address.sin_addr = address->sin_addr;
+ instance->local_address.sin_port = address->sin_port;
return 0;
}
int ast_rtp_instance_set_remote_address(struct ast_rtp_instance *instance, struct sockaddr_in *address)
{
if (&instance->remote_address != address) {
- memcpy(&instance->remote_address, address, sizeof(instance->remote_address));
+ instance->remote_address.sin_addr = address->sin_addr;
+ instance->remote_address.sin_port = address->sin_port;
}
/* moo */
if (instance->engine->remote_address_set) {
- instance->engine->remote_address_set(instance, address);
+ instance->engine->remote_address_set(instance, &instance->remote_address);
}
return 0;
Modified: trunk/res/res_rtp_asterisk.c
URL: http://svn.digium.com/svn-view/asterisk/trunk/res/res_rtp_asterisk.c?view=diff&rev=187773&r1=187772&r2=187773
==============================================================================
--- trunk/res/res_rtp_asterisk.c (original)
+++ trunk/res/res_rtp_asterisk.c Fri Apr 10 13:14:47 2009
@@ -406,13 +406,11 @@
startplace = x;
for (;;) {
- struct sockaddr_in local_address = { 0, };
-
- local_address.sin_port = htons(x);
+ sin->sin_port = htons(x);
/* Try to bind, this will tell us whether the port is available or not */
- if (!bind(rtp->s, (struct sockaddr*)&local_address, sizeof(local_address))) {
+ if (!bind(rtp->s, (struct sockaddr *)sin, sizeof(*sin))) {
ast_debug(1, "Allocated port %d for RTP instance '%p'\n", x, instance);
- ast_rtp_instance_set_local_address(instance, &local_address);
+ ast_rtp_instance_set_local_address(instance, sin);
break;
}
More information about the asterisk-commits
mailing list