]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
Skinny: don't crash when requesting an RTP port while the profile is listening on...
authorMathieu Parent <math.parent@gmail.com>
Fri, 25 Feb 2011 20:06:13 +0000 (21:06 +0100)
committerMathieu Parent <math.parent@gmail.com>
Fri, 25 Feb 2011 20:06:22 +0000 (21:06 +0100)
And store some more ip infos in the listener struct

src/mod/endpoints/mod_skinny/mod_skinny.c
src/mod/endpoints/mod_skinny/mod_skinny.h
src/mod/endpoints/mod_skinny/skinny_server.c

index 071e8c54d88c0b7f8fa5b56e015c9e3383be9804..32b4ef8fa295f9a0d701934acae2cf26cdce618b 100644 (file)
@@ -1598,9 +1598,14 @@ new_socket:
 
                switch_mutex_init(&listener->flag_mutex, SWITCH_MUTEX_NESTED, listener->pool);
 
-               switch_socket_addr_get(&listener->sa, SWITCH_TRUE, listener->sock);
-               switch_get_addr(listener->remote_ip, sizeof(listener->remote_ip), listener->sa);
-               listener->remote_port = switch_sockaddr_get_port(listener->sa);
+               switch_socket_addr_get(&listener->remote_sa, SWITCH_TRUE, listener->sock);
+               switch_get_addr(listener->remote_ip, sizeof(listener->remote_ip), listener->remote_sa);
+               listener->remote_port = switch_sockaddr_get_port(listener->remote_sa);
+
+               switch_socket_addr_get(&listener->local_sa, SWITCH_FALSE, listener->sock);
+               switch_get_addr(listener->local_ip, sizeof(listener->local_ip), listener->local_sa);
+               listener->local_port = switch_sockaddr_get_port(listener->local_sa);
+
                launch_listener_thread(listener);
 
        }
index 20d68faba5887f053c9f717710e0fa11f4a484db..bf59c673e69748a5d8f88667fcd140f34f9e9739 100644 (file)
@@ -143,11 +143,14 @@ struct listener {
     switch_socket_t *sock;
     switch_memory_pool_t *pool;
     switch_thread_rwlock_t *rwlock;
-    switch_sockaddr_t *sa;
+    switch_sockaddr_t *remote_sa;
     char remote_ip[50];
+    switch_port_t remote_port;
+    switch_sockaddr_t *local_sa;
+    char local_ip[50];
+    switch_port_t local_port;
     switch_mutex_t *flag_mutex;
     uint32_t flags;
-    switch_port_t remote_port;
     uint32_t id;
     time_t expire_time;
     struct listener *next;
index 538100359f5f181e8167f93152a74426e4f334c8..0aafb9859de7b8b5a6bfd99e8934b73089c6d393 100644 (file)
@@ -1660,12 +1660,12 @@ switch_status_t skinny_handle_open_receive_channel_ack_message(listener_t *liste
                        goto end;
                }
 
+               tech_pvt->local_sdp_audio_ip = listener->local_ip;
                /* Request a local port from the core's allocator */
-               if (!(tech_pvt->local_sdp_audio_port = switch_rtp_request_port(listener->profile->ip))) {
+               if (!(tech_pvt->local_sdp_audio_port = switch_rtp_request_port(tech_pvt->local_sdp_audio_ip))) {
                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_CRIT, "No RTP ports available!\n");
                        return SWITCH_STATUS_FALSE;
                }
-               tech_pvt->local_sdp_audio_ip = switch_core_strdup(switch_core_session_get_pool(session), listener->profile->ip);
 
                tech_pvt->remote_sdp_audio_ip = inet_ntoa(request->data.open_receive_channel_ack.ip);
                tech_pvt->remote_sdp_audio_port = request->data.open_receive_channel_ack.port;