t_cancel.h

Go to the documentation of this file.
00001 /*
00002  * $Id: t_cancel.h 4518 2008-07-28 15:39:28Z henningw $
00003  *
00004  * Copyright (C) 2001-2003 FhG Fokus
00005  *
00006  * This file is part of Kamailio, a free SIP server.
00007  *
00008  * Kamailio is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation; either version 2 of the License, or
00011  * (at your option) any later version
00012  *
00013  * Kamailio is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License 
00019  * along with this program; if not, write to the Free Software 
00020  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021  *
00022  * History:
00023  * ---------
00024  *  2004-02-11  FIFO/CANCEL + alignments (hash=f(callid,cseq)) (uli+jiri)
00025  */
00026 
00027 /*! \file
00028  * \brief TM :: CANCEL handling
00029  *
00030  * \ingroup tm
00031  * - Module: \ref tm
00032  */
00033 
00034 #ifndef _CANCEL_H
00035 #define _CANCEL_H
00036 
00037 /*! \brief
00038    A buffer is empty but cannot be used by anyone else
00039 
00040    particularly, we use this value in the buffer pointer
00041    in local_buffer to tell "a process is already scheduled
00042    to generate a CANCEL, other processes are not supposed to"
00043    (which might happen if for example in a three-branch forking,
00044    two 200 would enter separate processes and compete for
00045    canceling the third branch); note that to really avoid
00046    race conditions, the value must be set in REPLY_LOCK
00047 */
00048 #define BUSY_BUFFER ((char *)-1)
00049 
00050 void which_cancel( struct cell *t, branch_bm_t *cancel_bm );
00051 void cancel_uacs( struct cell *t, branch_bm_t cancel_bm );
00052 void cancel_branch( struct cell *t, int branch );
00053 
00054 int unixsock_uac_cancel(str* msg);
00055 
00056 unsigned int t_uac_cancel(str *headers,str *body,
00057    unsigned int cancelledIdx,unsigned int cancelledLabel,
00058    transaction_cb cb, void* cbp);
00059 typedef unsigned int (*tuaccancel_f)( str *headers,str *body,
00060    unsigned int cancelledIdx,unsigned int cancelledLabel,
00061    transaction_cb cb, void* cbp);
00062 
00063 char *build_cancel(struct cell *Trans,unsigned int branch,
00064    unsigned int *len );
00065 
00066 inline static short should_cancel_branch( struct cell *t, int b )
00067 {
00068    int last_received;
00069 
00070    last_received = t->uac[b].last_received;
00071    /* cancel only if provisional received and no one else
00072       attempted to cancel yet */
00073    if ( t->uac[b].local_cancel.buffer.s==NULL ) {
00074       if ( last_received>=100 && last_received<200 ) {
00075          /* we'll cancel -- label it so that no one else
00076          (e.g. another 200 branch) will try to do the same */
00077          t->uac[b].local_cancel.buffer.s=BUSY_BUFFER;
00078          return 1;
00079       } else if (last_received==0) {
00080          /* set flag to catch the delaied replies */
00081          t->uac[b].flags |= T_UAC_TO_CANCEL_FLAG;
00082       }
00083    }
00084    return 0;
00085 }
00086 
00087 
00088 #endif

Generated on Thu May 24 20:00:32 2012 for Kamailio - The Open Source SIP Server by  doxygen 1.5.6