]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
don't create new iax sessions when we shouldn't
authorMichael Jerris <mike@jerris.com>
Mon, 19 Feb 2007 16:56:48 +0000 (16:56 +0000)
committerMichael Jerris <mike@jerris.com>
Mon, 19 Feb 2007 16:56:48 +0000 (16:56 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4324 d0543943-73ff-0310-b7d9-9358b9ac24b2

libs/iax/.update [new file with mode: 0644]
libs/iax/src/iax.c

diff --git a/libs/iax/.update b/libs/iax/.update
new file mode 100644 (file)
index 0000000..f0780d8
--- /dev/null
@@ -0,0 +1 @@
+Mon Feb 19 12:03:56 EST 2007
\ No newline at end of file
index 0c923ad0cd9d2e108da8902ef559f8eee37dbc7a..9e3c76258afab34352bdc712096e2408cdcfdc70 100644 (file)
@@ -2916,17 +2916,29 @@ struct iax_event *iax_net_process(unsigned char *buf, int len, struct sockaddr_i
        struct iax_session *session;
        
        if (ntohs(fh->scallno) & IAX_FLAG_FULL) {
+               int subclass = uncompress_subclass(fh->csub);
+               int makenew = 0;
+
                /* Full size header */
                if (len < sizeof(struct ast_iax2_full_hdr)) {
                        DEBU(G "Short header received from %s\n", inet_ntoa(sin->sin_addr));
                        IAXERROR "Short header received from %s\n", inet_ntoa(sin->sin_addr));
                }
+               /* Only allow it to make new sessions on types where that makes sense */
+               if ((fh->type == AST_FRAME_IAX) && ((subclass == IAX_COMMAND_NEW) ||
+                                                                                       (subclass == IAX_COMMAND_POKE) ||
+                                                                                       (subclass == IAX_COMMAND_REGREL) ||
+                                                                                       (subclass == IAX_COMMAND_REGREQ))) {
+                       makenew = 1;
+               }
+
                /* We have a full header, process appropriately */
-               session = iax_find_session(sin, ntohs(fh->scallno) & ~IAX_FLAG_FULL, ntohs(fh->dcallno) & ~IAX_FLAG_RETRANS, 1);
+               session = iax_find_session(sin, ntohs(fh->scallno) & ~IAX_FLAG_FULL, ntohs(fh->dcallno) & ~IAX_FLAG_RETRANS, makenew);
                if (!session)
                        session = iax_txcnt_session(fh, len-sizeof(struct ast_iax2_full_hdr), sin, ntohs(fh->scallno) & ~IAX_FLAG_FULL, ntohs(fh->dcallno) & ~IAX_FLAG_RETRANS);
                if (session) 
                        return iax_header_to_event(session, fh, len - sizeof(struct ast_iax2_full_hdr), sin);
+               /* if we get here, the frame was invalid for some reason, we should probably send IAX_COMMAND_INVAL (as long as the subclass was not already IAX_COMMAND_INVAL) */
                DEBU(G "No session?\n");
                return NULL;
        } else {