dialog: more safety checks to detect if dialog is gone after event route execution
authorDaniel-Constantin Mierla <miconda@gmail.com>
Fri, 21 Apr 2017 19:39:22 +0000 (21:39 +0200)
committerDaniel-Constantin Mierla <miconda@gmail.com>
Fri, 21 Apr 2017 19:39:22 +0000 (21:39 +0200)
- avoid execution of script callbacks for event route
- related to GH #1059 and #1069

src/modules/dialog/dlg_handlers.c
src/modules/dialog/dlg_hash.h
src/modules/dialog/dlg_profile.c
src/modules/dialog/dlg_var.c
src/modules/ims_dialog/dlg_var.c

index 030847b..eb5d41c 100644 (file)
@@ -455,7 +455,11 @@ static void dlg_onreply(struct cell* t, int type, struct tmcb_params *param)
                event = DLG_EVENT_RPL3xx;
 
        next_state_dlg( dlg, event, &old_state, &new_state, &unref);
-       dlg_run_event_route(dlg, (rpl==FAKED_REPLY)?NULL:rpl, old_state, new_state);
+       if(dlg_run_event_route(dlg, (rpl==FAKED_REPLY)?NULL:rpl, old_state,
+                       new_state)<0) {
+               /* dialog is gone */
+               return;
+       }
 
        if (new_state==DLG_STATE_EARLY) {
                run_dlg_callbacks(DLGCB_EARLY, dlg, req, rpl, DLG_DIR_UPSTREAM, 0);
@@ -1227,7 +1231,6 @@ dlg_cell_t *dlg_get_msg_dialog(sip_msg_t *msg)
 void dlg_onroute(struct sip_msg* req, str *route_params, void *param)
 {
        dlg_cell_t *dlg = NULL;
-       dlg_cell_t *dlg0 = NULL;
        dlg_iuid_t *iuid = NULL;
        str val, callid, ftag, ttag;
        int h_entry=0, h_id=0, new_state=0, old_state=0;
@@ -1366,15 +1369,9 @@ void dlg_onroute(struct sip_msg* req, str *route_params, void *param)
        CURR_DLG_LIFETIME = (unsigned int)(time(0))-dlg->start_ts;
        CURR_DLG_STATUS = new_state;
 
-       dlg_run_event_route(dlg, req, old_state, new_state);
-
-       dlg0 = dlg_lookup(h_entry, h_id);
-       if (dlg0==0) {
-               LM_ALERT("after event route - dialog not found [%u:%u] (%d/%d) (%p)\n",
-                               h_entry, h_id, old_state, new_state, dlg);
+       if(dlg_run_event_route(dlg, req, old_state, new_state)<0) {
+               /* dialog is gone */
                return;
-       } else {
-               dlg_release(dlg0);
        }
 
        /* delay deletion of dialog until transaction has died off in order
@@ -1589,7 +1586,10 @@ void dlg_ontimeout(struct dlg_tl *tl)
                timeout_cb = (void *)CONFIRMED_DIALOG_STATE;
        }
 
-       dlg_run_event_route(dlg, NULL, old_state, new_state);
+       if(dlg_run_event_route(dlg, NULL, old_state, new_state)<0) {
+               /* dialog is gone */
+               return;
+       }
 
        if (new_state==DLG_STATE_DELETED && old_state!=DLG_STATE_DELETED) {
                LM_WARN("timeout for dlg with CallID '%.*s' and tags '%.*s' '%.*s'\n",
@@ -1680,20 +1680,24 @@ int pv_get_dlg_status(struct sip_msg *msg, pv_param_t *param, pv_value_t *res)
 
 /*!
  * \brief Execute event routes based on new state
- *
+ * - returns: -1 if dialog doesn't exist after event route execution
+ *             0 if all ok
  */
-void dlg_run_event_route(dlg_cell_t *dlg, sip_msg_t *msg, int ostate, int nstate)
+int dlg_run_event_route(dlg_cell_t *dlg, sip_msg_t *msg, int ostate, int nstate)
 {
        sip_msg_t *fmsg;
        int rt;
        int bkroute;
        sr_kemi_eng_t *keng = NULL;
-       str evname;
+       str evname = str_init("unknown");
+       int h_entry=0;
+       int h_id=0;
+       dlg_cell_t *dlg0 = NULL;
 
        if(dlg==NULL)
-               return;
+               return -1;
        if(ostate==nstate)
-               return;
+               return 0;
 
        rt = -1;
        if(dlg_event_callback.s==NULL || dlg_event_callback.len<=0) {
@@ -1713,13 +1717,13 @@ void dlg_run_event_route(dlg_cell_t *dlg, sip_msg_t *msg, int ostate, int nstate
                        }
                }
                if(rt==-1 || event_rt.rlist[rt]==NULL)
-                       return;
+                       return 0;
        }  else {
                keng = sr_kemi_eng_get();
                if(keng==NULL) {
                        LM_DBG("event callback (%s) set, but no cfg engine\n",
                                        dlg_event_callback.s);
-                       return;
+                       return 0;
                }
        }
 
@@ -1730,9 +1734,11 @@ void dlg_run_event_route(dlg_cell_t *dlg, sip_msg_t *msg, int ostate, int nstate
                        fmsg = msg;
 
                if (exec_pre_script_cb(fmsg, LOCAL_CB_TYPE)<=0)
-                       return;
+                       return 0;
 
                dlg_ref(dlg, 1);
+               h_entry = dlg->h_entry;
+               h_id = dlg->h_id;
                dlg_set_ctx_iuid(dlg);
                LM_DBG("executing event_route %d on state %d\n", rt, nstate);
                bkroute = get_route_type();
@@ -1750,9 +1756,19 @@ void dlg_run_event_route(dlg_cell_t *dlg, sip_msg_t *msg, int ostate, int nstate
                }
                dlg_reset_ctx_iuid();
                exec_post_script_cb(fmsg, LOCAL_CB_TYPE);
-               dlg_unref(dlg, 1);
                set_route_type(bkroute);
+               /* re-lookup the dialog, execution of the route could take long time */
+               dlg0 = dlg_lookup(h_entry, h_id);
+               if (dlg0==0) {
+                       LM_ALERT("after event route - dialog not found [%u:%u] (%d/%d) (%p) (%.*s)\n",
+                                       h_entry, h_id, ostate, nstate, dlg, evname.len, evname.s);
+                       return -1;
+               } else {
+                       dlg_release(dlg0);
+                       dlg_unref(dlg, 1);
+               }
        }
+       return 0;
 }
 
 int dlg_manage(sip_msg_t *msg)
index 63e64d5..f66d8f4 100644 (file)
@@ -561,7 +561,7 @@ static inline int match_downstream_dialog(dlg_cell_t *dlg, str *callid, str *fta
 /*!
  *
  */
-void dlg_run_event_route(dlg_cell_t *dlg, sip_msg_t *msg, int ostate, int nstate);
+int dlg_run_event_route(dlg_cell_t *dlg, sip_msg_t *msg, int ostate, int nstate);
 
 
 int dlg_ka_add(dlg_cell_t *dlg);
index fa3d2e8..09d3ef4 100644 (file)
@@ -203,7 +203,7 @@ static struct dlg_profile_table* new_dlg_profile( str *name, unsigned int size,
 
        /* set inner pointers */
        profile->entries = (struct dlg_profile_entry*)(profile + 1);
-       profile->name.s = ((char*)profile->entries) + 
+       profile->name.s = ((char*)profile->entries) +
                size*sizeof(struct dlg_profile_entry);
 
        /* copy the name of the profile */
@@ -258,7 +258,7 @@ void destroy_dlg_profiles(void)
 /*!
  * \brief Destroy dialog linkers
  * \param linker dialog linker
- */ 
+ */
 void destroy_linkers(struct dlg_profile_link *linker)
 {
        struct dlg_profile_entry *p_entry;
@@ -437,6 +437,10 @@ int profile_cleanup( struct sip_msg *msg, unsigned int flags, void *param )
 {
        dlg_cell_t *dlg;
 
+       if(get_route_type()==LOCAL_ROUTE) {
+               return 1;
+       }
+
        current_dlg_msg_id = 0;
        current_dlg_msg_pid = 0;
        dlg = dlg_get_ctx_dialog();
@@ -481,7 +485,7 @@ static void link_profile(struct dlg_profile_link *linker, str *vkey)
                p_entry->first->prev->next = &linker->hash_linker;
                p_entry->first->prev = &linker->hash_linker;
        } else {
-               p_entry->first = linker->hash_linker.next 
+               p_entry->first = linker->hash_linker.next
                        = linker->hash_linker.prev = &linker->hash_linker;
        }
        p_entry->content ++;
@@ -847,7 +851,7 @@ int is_known_dlg(struct sip_msg *msg) {
        dlg_cell_t *dlg;
 
        dlg = dlg_get_msg_dialog(msg);
-       
+
        if(dlg == NULL)
                return -1;
 
@@ -863,14 +867,14 @@ int       is_known_dlg(struct sip_msg *msg) {
  * \param timeout The dialog timeout to apply.
  */
 
-int    dlg_set_timeout_by_profile(struct dlg_profile_table *profile, 
-                                  str *value, int timeout) 
+int    dlg_set_timeout_by_profile(struct dlg_profile_table *profile,
+                                  str *value, int timeout)
 {
        unsigned int            i = 0;
        dlg_cell_t              *this_dlg = NULL;
        struct dlg_profile_hash *ph = NULL;
 
-       /* Private structure necessary for manipulating dialog 
+       /* Private structure necessary for manipulating dialog
          * timeouts outside of profile locks.  Admittedly, an
          * ugly hack, but avoids some concurrency issues.
          */
@@ -883,7 +887,7 @@ int dlg_set_timeout_by_profile(struct dlg_profile_table *profile,
 
        map_head = NULL;
 
-       /* If the profile has no value, iterate through every 
+       /* If the profile has no value, iterate through every
         * node and set its timeout.
         */
 
@@ -894,8 +898,8 @@ int dlg_set_timeout_by_profile(struct dlg_profile_table *profile,
                        ph = profile->entries[i].first;
 
                        if(!ph) continue;
-                       
-                       do { 
+
+                       do {
                                struct dlg_map_list *d = malloc(sizeof(struct dlg_map_list));
 
                                if(!d)
@@ -912,10 +916,10 @@ int       dlg_set_timeout_by_profile(struct dlg_profile_table *profile,
                                        d->next = map_head;
                                        map_head = d;
                                }
-       
+
                                ph = ph->next;
                        } while(ph != profile->entries[i].first);
-               } 
+               }
 
                lock_release(&profile->lock);
        }
@@ -957,7 +961,7 @@ int dlg_set_timeout_by_profile(struct dlg_profile_table *profile,
        }
 
        /* Walk the list and bulk-set the timeout */
-       
+
        for(map_scan = map_head; map_scan != NULL; map_scan = map_scan_next) {
                map_scan_next = map_scan->next;
 
@@ -965,7 +969,7 @@ int dlg_set_timeout_by_profile(struct dlg_profile_table *profile,
 
                if(!this_dlg) {
                        LM_CRIT("Unable to find dialog %d:%d\n", map_scan->h_entry, map_scan->h_id);
-               } else if(this_dlg->state >= DLG_STATE_EARLY) { 
+               } else if(this_dlg->state >= DLG_STATE_EARLY) {
                        if(update_dlg_timeout(this_dlg, timeout) < 0) {
                                        LM_ERR("Unable to set timeout on %d:%d\n", map_scan->h_entry,
                                        map_scan->h_id);
index c7d1ad1..344ff18 100644 (file)
@@ -48,6 +48,9 @@ int msg_id;
 int dlg_cfg_cb(sip_msg_t *msg, unsigned int flags, void *cbp)
 {
        dlg_cell_t *dlg;
+       if(get_route_type()==LOCAL_ROUTE) {
+               return 1;
+       }
        if(flags&POST_SCRIPT_CB) {
                dlg = dlg_get_ctx_dialog();
                if(dlg!=NULL) {
@@ -77,6 +80,10 @@ int dlg_cfg_cb(sip_msg_t *msg, unsigned int flags, void *cbp)
 
 int cb_dlg_cfg_reset(sip_msg_t *msg, unsigned int flags, void *cbp)
 {
+       if(get_route_type()==LOCAL_ROUTE) {
+               return 1;
+       }
+
        memset(&_dlg_ctx, 0, sizeof(dlg_ctx_t));
 
        return 1;
@@ -84,6 +91,9 @@ int cb_dlg_cfg_reset(sip_msg_t *msg, unsigned int flags, void *cbp)
 
 int cb_dlg_locals_reset(sip_msg_t *msg, unsigned int flags, void *cbp)
 {
+       if(get_route_type()==LOCAL_ROUTE) {
+               return 1;
+       }
        LM_DBG("resetting the local dialog shortcuts on script callback: %u\n", flags);
        cb_dlg_cfg_reset(msg, flags, cbp);
        cb_profile_reset(msg, flags, cbp);
@@ -106,7 +116,7 @@ static inline struct dlg_var *new_dlg_var(str *key, str *val)
        var->key.len = key->len;
        var->key.s = (char*)shm_malloc(var->key.len+1);
        if (var->key.s==NULL) {
-               shm_free(var);                  
+               shm_free(var);
                LM_ERR("no more shm mem\n");
                return NULL;
        }
@@ -116,8 +126,8 @@ static inline struct dlg_var *new_dlg_var(str *key, str *val)
        var->value.len = val->len;
        var->value.s = (char*)shm_malloc(var->value.len+1);
        if (var->value.s==NULL) {
-               shm_free(var->key.s);                   
-               shm_free(var);                  
+               shm_free(var->key.s);
+               shm_free(var);
                LM_ERR("no more shm mem\n");
                return NULL;
        }
@@ -160,10 +170,10 @@ int set_dlg_variable_unsafe(struct dlg_cell *dlg, str *key, str *val)
        struct dlg_var * it;
        struct dlg_var * it_prev;
        struct dlg_var ** var_list;
-       
-       if (dlg) 
+
+       if (dlg)
                var_list = &dlg->vars;
-       else 
+       else
                var_list = &_dlg_var_table;
 
        if ( val && (var=new_dlg_var(key, val))==NULL) {
@@ -188,7 +198,7 @@ int set_dlg_variable_unsafe(struct dlg_cell *dlg, str *key, str *val)
                                /* Take the previous vflags: */
                                var->vflags = it->vflags | DLG_FLAG_CHANGED;
                                if (it_prev) it_prev->next = var;
-                               else *var_list = var;                             
+                               else *var_list = var;
                        }
 
                        /* Free this var: */
@@ -216,7 +226,7 @@ str * get_dlg_variable_unsafe(struct dlg_cell *dlg, str *key)
 {
        struct dlg_var *var, *var_list;
 
-       if (dlg) 
+       if (dlg)
                var_list = dlg->vars;
        else
                var_list = _dlg_var_table;
@@ -385,7 +395,7 @@ int pv_set_dlg_variable(struct sip_msg* msg, pv_param_t *param, int op, pv_value
 
        /* Retrieve the dialog for current message */
        dlg=dlg_get_msg_dialog( msg);
-       
+
        if (dlg) {
                /* Lock the dialog */
                dlg_lock(d_table, &(d_table->entries[dlg->h_entry]));
@@ -816,24 +826,24 @@ int pv_parse_dlg_name(pv_spec_p sp, str *in)
 
        switch(in->len)
        {
-               case 3: 
+               case 3:
                        if(strncmp(in->s, "ref", 3)==0)
                                sp->pvp.pvn.u.isname.name.n = 0;
                        else goto error;
                break;
-               case 4: 
+               case 4:
                        if(strncmp(in->s, "h_id", 4)==0)
                                sp->pvp.pvn.u.isname.name.n = 1;
                        else goto error;
                break;
-               case 5: 
+               case 5:
                        if(strncmp(in->s, "state", 5)==0)
                                sp->pvp.pvn.u.isname.name.n = 2;
                        else if(strncmp(in->s, "to_rs", 5)==0)
                                sp->pvp.pvn.u.isname.name.n = 3;
                        else goto error;
                break;
-               case 6: 
+               case 6:
                        if(strncmp(in->s, "dflags", 6)==0)
                                sp->pvp.pvn.u.isname.name.n = 4;
                        else if(strncmp(in->s, "sflags", 6)==0)
@@ -846,7 +856,7 @@ int pv_parse_dlg_name(pv_spec_p sp, str *in)
                                sp->pvp.pvn.u.isname.name.n = 8;
                        else goto error;
                break;
-               case 7: 
+               case 7:
                        if(strncmp(in->s, "toroute", 7)==0)
                                sp->pvp.pvn.u.isname.name.n = 9;
                        else if(strncmp(in->s, "to_cseq", 7)==0)
@@ -857,7 +867,7 @@ int pv_parse_dlg_name(pv_spec_p sp, str *in)
                                sp->pvp.pvn.u.isname.name.n = 21;
                        else goto error;
                break;
-               case 8: 
+               case 8:
                        if(strncmp(in->s, "from_uri", 8)==0)
                                sp->pvp.pvn.u.isname.name.n = 12;
                        else if(strncmp(in->s, "from_tag", 8)==0)
@@ -868,27 +878,27 @@ int pv_parse_dlg_name(pv_spec_p sp, str *in)
                                sp->pvp.pvn.u.isname.name.n = 15;
                        else goto error;
                break;
-               case 9: 
+               case 9:
                        if(strncmp(in->s, "from_cseq", 9)==0)
                                sp->pvp.pvn.u.isname.name.n = 16;
                        else goto error;
                break;
-               case 10: 
+               case 10:
                        if(strncmp(in->s, "to_contact", 10)==0)
                                sp->pvp.pvn.u.isname.name.n = 17;
                        else goto error;
                break;
-               case 11: 
+               case 11:
                        if(strncmp(in->s, "to_bindaddr", 11)==0)
                                sp->pvp.pvn.u.isname.name.n = 18;
                        else goto error;
                break;
-               case 12: 
+               case 12:
                        if(strncmp(in->s, "from_contact", 12)==0)
                                sp->pvp.pvn.u.isname.name.n = 19;
                        else goto error;
                break;
-               case 13: 
+               case 13:
                        if(strncmp(in->s, "from_bindaddr", 13)==0)
                                sp->pvp.pvn.u.isname.name.n = 20;
                        else goto error;
@@ -930,6 +940,9 @@ dlg_ctx_t* dlg_get_dlg_ctx(void)
 
 int spiral_detect_reset(struct sip_msg *foo, unsigned int flags, void *bar)
 {
+       if(get_route_type()==LOCAL_ROUTE) {
+               return 1;
+       }
        spiral_detected = -1;
 
        return 0;
index 808a752..7972333 100644 (file)
@@ -20,7 +20,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
-                      
+
 #include "../../core/route.h"
 #include "../../core/pvapi.h"
 
@@ -40,7 +40,10 @@ int msg_id;
 
 int dlg_cfg_cb(struct sip_msg *foo, unsigned int flags, void *bar)
 {
-        memset(&_dlg_ctx, 0, sizeof(dlg_ctx_t));
+       if(get_route_type()==LOCAL_ROUTE) {
+               return 1;
+       }
+       memset(&_dlg_ctx, 0, sizeof(dlg_ctx_t));
        return 1;
 }
 
@@ -60,7 +63,7 @@ static inline struct dlg_var *new_dlg_var(str *key, str *val)
        var->key.len = key->len;
        var->key.s = (char*)shm_malloc(var->key.len);
        if (var->key.s==NULL) {
-               shm_free(var);                  
+               shm_free(var);
                LM_ERR("no more shm mem\n");
                return NULL;
        }
@@ -69,8 +72,8 @@ static inline struct dlg_var *new_dlg_var(str *key, str *val)
        var->value.len = val->len;
        var->value.s = (char*)shm_malloc(var->value.len);
        if (var->value.s==NULL) {
-               shm_free(var->key.s);                   
-               shm_free(var);                  
+               shm_free(var->key.s);
+               shm_free(var);
                LM_ERR("no more shm mem\n");
                return NULL;
        }
@@ -111,10 +114,10 @@ int set_dlg_variable_unsafe(struct dlg_cell *dlg, str *key, str *val)
        struct dlg_var * it;
        struct dlg_var * it_prev;
        struct dlg_var ** var_list;
-       
-       if (dlg) 
+
+       if (dlg)
                var_list = &dlg->vars;
-       else 
+       else
                var_list = &var_table;
 
        if ( val && (var=new_dlg_var(key, val))==NULL) {
@@ -139,7 +142,7 @@ int set_dlg_variable_unsafe(struct dlg_cell *dlg, str *key, str *val)
                                /* Take the previous vflags: */
                                var->vflags = it->vflags & DLG_FLAG_CHANGED;
                                if (it_prev) it_prev->next = var;
-                               else *var_list = var;                             
+                               else *var_list = var;
                        }
 
                        /* Free this var: */
@@ -167,7 +170,7 @@ str * get_dlg_variable_unsafe(struct dlg_cell *dlg, str *key)
 {
        struct dlg_var *var, *var_list;
 
-       if (dlg) 
+       if (dlg)
                var_list = dlg->vars;
        else
                var_list = var_table;
@@ -222,17 +225,17 @@ void print_lists(struct dlg_cell *dlg) {
 
 str * api_get_dlg_variable(str *callid, str *ftag, str *ttag, str *key) {
     struct dlg_cell *dlg;
-    
+
     unsigned int dir = DLG_DIR_NONE;
     dlg = get_dlg(callid, ftag, ttag, &dir); //increments ref count!
-    
+
     if (!dlg) {
         LM_ERR("Asked to tear down non existent dialog\n");
         return NULL;
     }
-    
+
     unref_dlg(dlg, 1);
-    
+
     return get_dlg_variable(dlg, key);
 }
 
@@ -256,20 +259,20 @@ str * get_dlg_variable(struct dlg_cell *dlg, str *key)
 
 int api_set_dlg_variable(str *callid, str *ftag, str *ttag, str *key, str *val) {
     struct dlg_cell *dlg;
-    
+
     unsigned int dir = DLG_DIR_NONE;
     dlg = get_dlg(callid, ftag, ttag, &dir); //increments ref count!
-    
+
     if (!dlg) {
         LM_ERR("Asked to tear down non existent dialog\n");
         return -1;
     }
-    
+
     unref_dlg(dlg, 1);
-     
+
     return set_dlg_variable(dlg, key, val);
-    
-   
+
+
 }
 
 int set_dlg_variable(struct dlg_cell *dlg, str *key, str *val)
@@ -380,7 +383,7 @@ int pv_set_dlg_variable(struct sip_msg* msg, pv_param_t *param, int op, pv_value
 
        /* Retrieve the dialog for current message */
        dlg=dlg_get_msg_dialog( msg);
-       
+
        if (dlg) {
                /* Lock the dialog */
                dlg_lock(d_table, &(d_table->entries[dlg->h_entry]));
@@ -521,29 +524,29 @@ int pv_parse_dlg_ctx_name(pv_spec_p sp, str *in)
 
        switch(in->len)
        {
-               case 2: 
+               case 2:
                        if(strncmp(in->s, "on", 2)==0)
                                sp->pvp.pvn.u.isname.name.n = 0;
                        else goto error;
                break;
-               case 3: 
+               case 3:
                        if(strncmp(in->s, "set", 3)==0)
                                sp->pvp.pvn.u.isname.name.n = 5;
                        else if(strncmp(in->s, "dir", 3)==0)
                                sp->pvp.pvn.u.isname.name.n = 6;
                        else goto error;
                break;
-               case 5: 
+               case 5:
                        if(strncmp(in->s, "flags", 6)==0)
                                sp->pvp.pvn.u.isname.name.n = 1;
                        else goto error;
                break;
-               case 7: 
+               case 7:
                        if(strncmp(in->s, "timeout", 7)==0)
                                sp->pvp.pvn.u.isname.name.n = 2;
                        else goto error;
                break;
-               case 11: 
+               case 11:
                        if(strncmp(in->s, "timeout_bye", 11)==0)
                                sp->pvp.pvn.u.isname.name.n = 3;
                        else goto error;
@@ -691,24 +694,24 @@ int pv_parse_dlg_name(pv_spec_p sp, str *in)
 
        switch(in->len)
        {
-               case 3: 
+               case 3:
                        if(strncmp(in->s, "ref", 3)==0)
                                sp->pvp.pvn.u.isname.name.n = 0;
                        else goto error;
                break;
-               case 4: 
+               case 4:
                        if(strncmp(in->s, "h_id", 4)==0)
                                sp->pvp.pvn.u.isname.name.n = 1;
                        else goto error;
                break;
-               case 5: 
+               case 5:
                        if(strncmp(in->s, "state", 5)==0)
                                sp->pvp.pvn.u.isname.name.n = 2;
                        else if(strncmp(in->s, "to_rs", 5)==0)
                                sp->pvp.pvn.u.isname.name.n = 3;
                        else goto error;
                break;
-               case 6: 
+               case 6:
                        if(strncmp(in->s, "dflags", 6)==0)
                                sp->pvp.pvn.u.isname.name.n = 4;
                        else if(strncmp(in->s, "sflags", 6)==0)
@@ -721,7 +724,7 @@ int pv_parse_dlg_name(pv_spec_p sp, str *in)
                                sp->pvp.pvn.u.isname.name.n = 8;
                        else goto error;
                break;
-               case 7: 
+               case 7:
                        if(strncmp(in->s, "toroute", 7)==0)
                                sp->pvp.pvn.u.isname.name.n = 9;
                        else if(strncmp(in->s, "to_cseq", 7)==0)
@@ -732,7 +735,7 @@ int pv_parse_dlg_name(pv_spec_p sp, str *in)
                                sp->pvp.pvn.u.isname.name.n = 21;
                        else goto error;
                break;
-               case 8: 
+               case 8:
                        if(strncmp(in->s, "from_uri", 8)==0)
                                sp->pvp.pvn.u.isname.name.n = 12;
                        else if(strncmp(in->s, "from_tag", 8)==0)
@@ -743,27 +746,27 @@ int pv_parse_dlg_name(pv_spec_p sp, str *in)
                                sp->pvp.pvn.u.isname.name.n = 15;
                        else goto error;
                break;
-               case 9: 
+               case 9:
                        if(strncmp(in->s, "from_cseq", 9)==0)
                                sp->pvp.pvn.u.isname.name.n = 16;
                        else goto error;
                break;
-               case 10: 
+               case 10:
                        if(strncmp(in->s, "to_contact", 10)==0)
                                sp->pvp.pvn.u.isname.name.n = 17;
                        else goto error;
                break;
-               case 11: 
+               case 11:
                        if(strncmp(in->s, "to_bindaddr", 11)==0)
                                sp->pvp.pvn.u.isname.name.n = 18;
                        else goto error;
                break;
-               case 12: 
+               case 12:
                        if(strncmp(in->s, "from_contact", 12)==0)
                                sp->pvp.pvn.u.isname.name.n = 19;
                        else goto error;
                break;
-               case 13: 
+               case 13:
                        if(strncmp(in->s, "from_bindaddr", 20)==0)
                                sp->pvp.pvn.u.isname.name.n = 2;
                        else goto error;