summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Colp <jcolp@digium.com>2009-04-10 18:14:47 +0000
committerJoshua Colp <jcolp@digium.com>2009-04-10 18:14:47 +0000
commitaaf15662228fbfeeb6437957516f4740dd4c0af1 (patch)
tree3aa1c04285c7bcb65dc1284aa65036ec2a9debba
parent8e4b5df187d51d7a64532dd6b0c9ea93d3cb2e90 (diff)
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. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@187773 65c4cc65-6c06-0410-ace0-fbb531ad65f3
-rw-r--r--main/rtp_engine.c12
-rw-r--r--res/res_rtp_asterisk.c8
2 files changed, 11 insertions, 9 deletions
diff --git a/main/rtp_engine.c b/main/rtp_engine.c
index 1b35aa403..89f9a595c 100644
--- a/main/rtp_engine.c
+++ b/main/rtp_engine.c
@@ -312,7 +312,9 @@ struct ast_rtp_instance *ast_rtp_instance_new(const char *engine_name, struct sc
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 @@ struct ast_frame *ast_rtp_instance_read(struct ast_rtp_instance *instance, int r
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;
diff --git a/res/res_rtp_asterisk.c b/res/res_rtp_asterisk.c
index 60e9142e7..87491e82d 100644
--- a/res/res_rtp_asterisk.c
+++ b/res/res_rtp_asterisk.c
@@ -406,13 +406,11 @@ static int ast_rtp_new(struct ast_rtp_instance *instance, struct sched_context *
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;
}