Module: kamailio
Branch: master
Commit: 1440a865f61129461ca7d04424af98fb2d0c2406
URL: 
https://github.com/kamailio/kamailio/commit/1440a865f61129461ca7d04424af98fb2d0c2406

Author: Daniel-Constantin Mierla <[email protected]>
Committer: Daniel-Constantin Mierla <[email protected]>
Date: 2026-05-17T08:44:16+02:00

sdpops: loost at address family in streams if none in session

- GH #4718

---

Modified: src/modules/sdpops/sdpops_mod.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/1440a865f61129461ca7d04424af98fb2d0c2406.diff
Patch: 
https://github.com/kamailio/kamailio/commit/1440a865f61129461ca7d04424af98fb2d0c2406.patch

---

diff --git a/src/modules/sdpops/sdpops_mod.c b/src/modules/sdpops/sdpops_mod.c
index 7631779c70f..61e2f657354 100644
--- a/src/modules/sdpops/sdpops_mod.c
+++ b/src/modules/sdpops/sdpops_mod.c
@@ -1018,10 +1018,11 @@ it helps to extract IP address family at c line from sdp
 */
 static int w_sdp_get_address_family(sip_msg_t *msg)
 {
-
        sdp_session_cell_t *session;
+       sdp_stream_cell_t *stream;
        int sdp_session_num;
        int result = -1;
+
        if(parse_sdp(msg) < 0) {
                LM_ERR("Unable to parse sdp body \n");
                return -1;
@@ -1030,23 +1031,44 @@ static int w_sdp_get_address_family(sip_msg_t *msg)
        sdp_session_num = 0;
 
        for(;;) {
-
                session = get_sdp_session(msg, sdp_session_num);
                if(!session)
                        break;
 
-               if(session->pf == AF_INET) {
-                       result = 4;
-               } else if(session->pf == AF_INET6) {
-                       result = 6;
+               if(session->ip_addr.s != NULL && session->ip_addr.len > 0) {
+                       if(session->pf == AF_INET) {
+                               result = 4;
+                       } else if(session->pf == AF_INET6) {
+                               result = 6;
+                       } else {
+                               result = -1;
+                       }
                } else {
-                       result = -1;
+                       stream = session->streams;
+                       while(stream) {
+                               if(stream->ip_addr.s != NULL && 
stream->ip_addr.len > 0) {
+                                       if(stream->pf == AF_INET) {
+                                               result = 4;
+                                       } else if(stream->pf == AF_INET6) {
+                                               result = 6;
+                                       } else {
+                                               result = -1;
+                                       }
+                                       break;
+                               }
+                               stream = stream->next;
+                       }
+               }
+
+               if(result == 4 || result == 6) {
+                       break;
                }
                sdp_session_num++;
        }
 
        return result;
 }
+
 /**
  * @brief remove streams matching the m='media'
  * @return -1 - error; 0 - not found; >=1 - found

_______________________________________________
Kamailio - Development Mailing List -- [email protected]
To unsubscribe send an email to [email protected]
Important: keep the mailing list in the recipients, do not reply only to the 
sender!

Reply via email to