dlg_state.h File Reference


Detailed Description

Serving-CSCF - Dialog State Operations.

Author:
Dragos Vingarzan vingarzan -at- fokus dot fraunhofer dot de

Alberto Diez - Changes to handle release_call

Definition in file dlg_state.h.

#include "../../sr_module.h"
#include "mod.h"
#include "../../locking.h"
#include "../tm/dlg.h"

Go to the source code of this file.

Data Structures

struct  _s_dialog
 Structure for S-CSCF dialogs. More...
struct  s_dialog_hash_slot
 Structure for a S-CSCF dialog hash slot. More...

Defines

#define DLG_METHOD_MAX   DLG_METHOD_SUBSCRIBE
 The last dialog type.

Typedefs

typedef _s_dialog s_dialog
 Structure for S-CSCF dialogs.

Enumerations

enum  s_dialog_method { DLG_METHOD_OTHER = 0, DLG_METHOD_INVITE = 1, DLG_METHOD_SUBSCRIBE = 2 }
 Enumeration for known dialogs. More...
enum  s_dialog_state {
  DLG_STATE_UNKNOWN = 0, DLG_STATE_INITIAL = 1, DLG_STATE_EARLY = 2, DLG_STATE_CONFIRMED = 3,
  DLG_STATE_TERMINATED_ONE_SIDE = 4, DLG_STATE_TERMINATED = 5
}
 Enumeration for dialog states. More...
enum  s_dialog_direction { DLG_MOBILE_ORIGINATING = 0, DLG_MOBILE_TERMINATING = 1, DLG_MOBILE_UNKNOWN = 2 }
 Enumeration for dialog directions. More...

Functions

unsigned int get_s_dialog_hash (str call_id)
 Computes the hash for a string.
int s_dialogs_init (int hash_size)
 Initialize the S-CSCF dialogs registrar.
void s_dialogs_destroy ()
 Destroy the registrar.
void d_lock (unsigned int hash)
 Locks the required part of the hash table.
void d_unlock (unsigned int hash)
 UnLocks the required part of the hash table.
s_dialognew_s_dialog (str call_id, str aor, enum s_dialog_direction dir)
 Creates a new s_dialog structure.
s_dialogadd_s_dialog (str call_id, str aor, enum s_dialog_direction dir)
 Creates and adds a dialog to the hash table.
int is_s_dialog (str call_id, str aor, enum s_dialog_direction dir)
 Finds out if a dialog is in the hash table.
int is_s_dialog_dir (str call_id, enum s_dialog_direction dir)
 Finds out if a dialog is in the hash table.
s_dialogget_s_dialog (str call_id, str aor)
 Finds and returns a dialog from the hash table.
s_dialogget_s_dialog_dir (str call_id, enum s_dialog_direction dir)
 Finds and returns a dialog from the hash table.
s_dialogget_s_dialog_dir_nolock (str call_id, enum s_dialog_direction dir)
 Finds and returns a dialog from the hash table.
int terminate_s_dialog (s_dialog *d)
 Terminates a dialog - called before del_s_dialog to send out terminatination messages.
void del_s_dialog (s_dialog *d)
 Deletes a dialog from the hash table.
void free_s_dialog (s_dialog *d)
 Frees a dialog.
void print_s_dialogs (int log_level)
 Prints the list of dialogs.
enum s_dialog_direction get_dialog_direction (char *direction)
 Returns the s_dialog_direction from the direction string.
int S_is_in_dialog (struct sip_msg *msg, char *str1, char *str2)
 Find out if a message is within a saved dialog.
int S_save_dialog (struct sip_msg *msg, char *str1, char *str2)
 Saves a dialog.
int S_update_dialog (struct sip_msg *msg, char *str1, char *str2)
 Updates a dialog.
int S_drop_dialog (struct sip_msg *msg, char *str1, char *str2)
 Drops and deletes a dialog.
int S_drop_all_dialogs (str aor)
 Drop all dialogs belonging to one AOR.
int S_record_route (struct sip_msg *msg, char *user, char *str2)
 Record routes, with given user as parameter.
int S_is_record_routed (struct sip_msg *msg, char *str1, char *str2)
 Check if we already did record-route.
void dialog_timer (unsigned int ticks, void *param)
 The dialog timer looks for expired dialogs and removes them.
int S_check_session_expires (struct sip_msg *msg, char *str1, char *str2)
 Checks if Session-Expires value is over Min_SE local policy.
int S_422_session_expires (struct sip_msg *msg, char *str1, char *str2)
 Send a 422 Session Interval Too Small.


Define Documentation

#define DLG_METHOD_MAX   DLG_METHOD_SUBSCRIBE

The last dialog type.

Definition at line 72 of file dlg_state.h.


Typedef Documentation

typedef struct _s_dialog s_dialog

Structure for S-CSCF dialogs.


Enumeration Type Documentation

enum s_dialog_method

Enumeration for known dialogs.

Enumerator:
DLG_METHOD_OTHER 
DLG_METHOD_INVITE 
DLG_METHOD_SUBSCRIBE 

Definition at line 65 of file dlg_state.h.

00065                      {
00066     DLG_METHOD_OTHER=0,
00067     DLG_METHOD_INVITE=1,
00068     DLG_METHOD_SUBSCRIBE=2  
00069 };

enum s_dialog_state

Enumeration for dialog states.

Enumerator:
DLG_STATE_UNKNOWN 
DLG_STATE_INITIAL 
DLG_STATE_EARLY 
DLG_STATE_CONFIRMED 
DLG_STATE_TERMINATED_ONE_SIDE 
DLG_STATE_TERMINATED 

Definition at line 75 of file dlg_state.h.

enum s_dialog_direction

Enumeration for dialog directions.

Enumerator:
DLG_MOBILE_ORIGINATING 
DLG_MOBILE_TERMINATING 
DLG_MOBILE_UNKNOWN 

Definition at line 85 of file dlg_state.h.

00085                         {
00086     DLG_MOBILE_ORIGINATING=0,
00087     DLG_MOBILE_TERMINATING=1,
00088     DLG_MOBILE_UNKNOWN=2
00089 };


Function Documentation

unsigned int get_s_dialog_hash ( str  call_id  )  [inline]

Computes the hash for a string.

Parameters:
call_id - the string to compute for
Returns:
the hash % scscf_dialogs_hash_size

Definition at line 121 of file dlg_state.c.

References h_inc, and s_dialogs_hash_size.

Referenced by bin_decode_s_dialog(), get_s_dialog(), get_s_dialog_dir(), get_s_dialog_dir_nolock(), is_s_dialog(), is_s_dialog_dir(), and new_s_dialog().

00122 {
00123     if (call_id.len==0) return 0;
00124 #define h_inc h+=v^(v>>3)
00125     char* p;
00126     register unsigned v;
00127     register unsigned h;
00128     
00129     h=0;
00130     for (p=call_id.s; p<=(call_id.s+call_id.len-4); p+=4){
00131         v=(*p<<24)+(p[1]<<16)+(p[2]<<8)+p[3];
00132         h_inc;
00133     }
00134     v=0;
00135     for (;p<(call_id.s+call_id.len); p++) {
00136         v<<=8;
00137         v+=*p;
00138     }
00139     h_inc;
00140     
00141     h=((h)+(h>>11))+((h>>13)+(h>>23));
00142     return (h)%s_dialogs_hash_size;
00143 #undef h_inc 
00144 }

int s_dialogs_init ( int  hash_size  ) 

Initialize the S-CSCF dialogs registrar.

Parameters:
hash_size - size of the dialog hash table
Returns:
1 if OK, 0 on error

Definition at line 151 of file dlg_state.c.

References s_dialog_hash_slot::lock, M_NAME, s_dialogs, and s_dialogs_hash_size.

Referenced by mod_init().

00152 {
00153     int i;
00154     
00155     s_dialogs_hash_size = hash_size;
00156     s_dialogs = shm_malloc(sizeof(s_dialog_hash_slot)*s_dialogs_hash_size);
00157 
00158     if (!s_dialogs) return 0;
00159 
00160     memset(s_dialogs,0,sizeof(s_dialog_hash_slot)*s_dialogs_hash_size);
00161     
00162     for(i=0;i<s_dialogs_hash_size;i++){
00163         s_dialogs[i].lock = lock_alloc();
00164         if (!s_dialogs[i].lock){
00165             LOG(L_ERR,"ERR:"M_NAME":d_hash_table_init(): Error creating lock\n");
00166             return 0;
00167         }
00168         s_dialogs[i].lock = lock_init(s_dialogs[i].lock);
00169     }
00170             
00171     return 1;
00172 }

void s_dialogs_destroy (  ) 

Destroy the registrar.

Definition at line 177 of file dlg_state.c.

References d_lock(), d_unlock(), free_s_dialog(), s_dialog_hash_slot::head, _s_dialog::next, s_dialogs, and s_dialogs_hash_size.

Referenced by mod_destroy().

00178 {
00179     int i;
00180     s_dialog *d,*nd;
00181     for(i=0;i<s_dialogs_hash_size;i++){
00182         d_lock(i);
00183             d = s_dialogs[i].head;
00184             while(d){
00185                 nd = d->next;
00186                 free_s_dialog(d);
00187                 d = nd;
00188             }
00189         d_unlock(i);
00190         lock_dealloc(s_dialogs[i].lock);
00191     }
00192     shm_free(s_dialogs);
00193 }

void d_lock ( unsigned int  hash  )  [inline]

Locks the required part of the hash table.

Parameters:
hash - index of the slot to lock

Definition at line 198 of file dlg_state.c.

References p_dialogs, and s_dialogs.

00199 {
00200 //  LOG(L_CRIT,"GET %d\n",hash);
00201     lock_get(p_dialogs[(hash)].lock);
00202 //  LOG(L_CRIT,"GOT %d\n",hash);    
00203 }

void d_unlock ( unsigned int  hash  )  [inline]

UnLocks the required part of the hash table.

Parameters:
hash - index of the slot to unlock

Definition at line 209 of file dlg_state.c.

References p_dialogs, and s_dialogs.

00210 {
00211     lock_release(p_dialogs[(hash)].lock);
00212 //  LOG(L_CRIT,"RELEASED %d\n",hash);   
00213 }

s_dialog* new_s_dialog ( str  call_id,
str  aor,
enum s_dialog_direction  dir 
)

Creates a new s_dialog structure.

Does not add the structure to the list

Parameters:
call_id - call_id of the dialog
aor - aor of the user
dir - the direction
Returns:
the new s_dialog* or NULL s_dialog

Definition at line 287 of file dlg_state.c.

References _s_dialog::aor, _s_dialog::call_id, _s_dialog::direction, get_s_dialog_hash(), _s_dialog::hash, _s_dialog::is_releasing, M_NAME, s_dialog_count_decrement(), s_dialog_count_increment(), and STR_SHM_DUP.

Referenced by add_s_dialog().

00288 {
00289     s_dialog *d;
00290     
00291     if (!s_dialog_count_increment()) return 0;
00292     d = shm_malloc(sizeof(s_dialog));
00293     if (!d) {
00294         LOG(L_ERR,"ERR:"M_NAME":new_s_dialog(): Unable to alloc %d bytes\n",
00295             sizeof(s_dialog));
00296         goto error;
00297     }
00298     memset(d,0,sizeof(s_dialog));
00299     
00300     d->hash = get_s_dialog_hash(call_id);       
00301     STR_SHM_DUP(d->call_id,call_id,"shm");
00302     STR_SHM_DUP(d->aor,aor,"shm");  
00303     d->direction = dir;
00304     d->is_releasing = 0;
00305     return d;
00306 error:
00307 out_of_memory:
00308     if (d){
00309         shm_free(d);        
00310     }
00311     s_dialog_count_decrement();
00312     return 0;
00313 }

s_dialog* add_s_dialog ( str  call_id,
str  aor,
enum s_dialog_direction  dir 
)

Creates and adds a dialog to the hash table.

Note:
Locks the hash slot if OK! Call d_unlock(s_dialog->hash) when you are finished)

make sure that is_s_dialog(call_id) returns 0 or there will be unreachable duplicates!

Parameters:
call_id - call_id of the dialog
aor - aor of the user
dir - the direction
Returns:
the new s_dialog* or NULL s_dialog

Definition at line 324 of file dlg_state.c.

References d_lock(), _s_dialog::hash, s_dialog_hash_slot::head, new_s_dialog(), _s_dialog::next, _s_dialog::prev, s_dialogs, and s_dialog_hash_slot::tail.

Referenced by S_save_dialog().

00325 {
00326     s_dialog *d;
00327     
00328     d = new_s_dialog(call_id,aor,dir);
00329     if (!d) return 0;       
00330     
00331     d_lock(d->hash);
00332         d->next = 0;
00333         d->prev = s_dialogs[d->hash].tail;
00334         if (d->prev) d->prev->next = d;
00335         s_dialogs[d->hash].tail = d;
00336         if (!s_dialogs[d->hash].head) s_dialogs[d->hash].head = d;
00337 
00338         return d;
00339 }

int is_s_dialog ( str  call_id,
str  aor,
enum s_dialog_direction  dir 
)

Finds out if a dialog is in the hash table.

Parameters:
call_id - call_id of the dialog
aor - aor of the user
Returns:
1 if found, 0 if not found

Definition at line 347 of file dlg_state.c.

References _s_dialog::aor, _s_dialog::call_id, d_lock(), d_unlock(), _s_dialog::direction, get_s_dialog_hash(), s_dialog_hash_slot::head, _s_dialog::next, and s_dialogs.

Referenced by S_save_dialog().

00348 {
00349     s_dialog *d=0;
00350     unsigned int hash = get_s_dialog_hash(call_id);
00351 
00352     d_lock(hash);
00353         d = s_dialogs[hash].head;
00354         while(d){
00355                 if (d->direction == dir &&
00356                     d->aor.len == aor.len &&
00357                     d->call_id.len == call_id.len &&
00358                     strncasecmp(d->aor.s,aor.s,aor.len)==0 &&
00359                     strncasecmp(d->call_id.s,call_id.s,call_id.len)==0) {
00360                     d_unlock(hash);
00361                     return 1;
00362                 }
00363             d = d->next;
00364         }
00365     d_unlock(hash);
00366     return 0;
00367 }

int is_s_dialog_dir ( str  call_id,
enum s_dialog_direction  dir 
)

Finds out if a dialog is in the hash table.

Parameters:
call_id - call_id of the dialog
dir - the direction
Returns:
1 if found, 0 if not found

Definition at line 375 of file dlg_state.c.

References _s_dialog::call_id, d_lock(), d_unlock(), _s_dialog::direction, get_s_dialog_hash(), s_dialog_hash_slot::head, _s_dialog::next, and s_dialogs.

Referenced by S_is_in_dialog().

00376 {
00377     s_dialog *d=0;
00378     unsigned int hash = get_s_dialog_hash(call_id);
00379 
00380     d_lock(hash);
00381         d = s_dialogs[hash].head;
00382         while(d){
00383                 if (d->direction == dir &&
00384                 d->call_id.len == call_id.len &&
00385                 strncasecmp(d->call_id.s,call_id.s,call_id.len)==0) {
00386                     d_unlock(hash);
00387                     return 1;
00388                 }
00389             d = d->next;
00390         }
00391     d_unlock(hash);
00392     return 0;
00393 }

s_dialog* get_s_dialog ( str  call_id,
str  aor 
)

Finds and returns a dialog from the hash table.

Note:
Locks the hash slot if ok! Call d_unlock(s_dialog->hash) when you are finished)
Parameters:
call_id - call_id of the dialog
aor - aor of the user
Returns:
the s_dialog* or NULL if not found

Definition at line 402 of file dlg_state.c.

References _s_dialog::aor, _s_dialog::call_id, d_lock(), d_unlock(), get_s_dialog_hash(), s_dialog_hash_slot::head, _s_dialog::next, and s_dialogs.

00403 {
00404     s_dialog *d=0;
00405     unsigned int hash = get_s_dialog_hash(call_id);
00406 
00407     d_lock(hash);
00408         d = s_dialogs[hash].head;
00409         while(d){
00410             if (d->aor.len == aor.len &&
00411                 d->call_id.len == call_id.len &&
00412                 strncasecmp(d->aor.s,aor.s,aor.len)==0 &&
00413                 strncasecmp(d->call_id.s,call_id.s,call_id.len)==0) {
00414                     return d;
00415                 }
00416             d = d->next;
00417         }
00418     d_unlock(hash);
00419     return 0;
00420 }

s_dialog* get_s_dialog_dir ( str  call_id,
enum s_dialog_direction  dir 
)

Finds and returns a dialog from the hash table.

Note:
Locks the hash slot if ok! Call d_unlock(s_dialog->hash) when you are finished)
Parameters:
call_id - call_id of the dialog
dir - the direction
Returns:
the s_dialog* or NULL if not found

Definition at line 429 of file dlg_state.c.

References _s_dialog::call_id, d_lock(), d_unlock(), _s_dialog::direction, get_s_dialog_hash(), s_dialog_hash_slot::head, _s_dialog::next, and s_dialogs.

Referenced by confirmed_response(), release_call(), S_drop_dialog(), and S_update_dialog().

00430 {
00431     s_dialog *d=0;
00432     unsigned int hash = get_s_dialog_hash(call_id);
00433 
00434     d_lock(hash);
00435         d = s_dialogs[hash].head;
00436         while(d){
00437             if (d->direction == dir &&
00438                 d->call_id.len == call_id.len &&
00439                 strncasecmp(d->call_id.s,call_id.s,call_id.len)==0) {
00440                     return d;
00441                 }
00442             d = d->next;
00443         }
00444     d_unlock(hash);
00445     return 0;
00446 }

s_dialog* get_s_dialog_dir_nolock ( str  call_id,
enum s_dialog_direction  dir 
)

Finds and returns a dialog from the hash table.

Note:
the table should be locked already for the call_id in the parameter
Parameters:
call_id - call_id of the dialog
dir - the direction
Returns:
the s_dialog* or NULL if not found

Definition at line 455 of file dlg_state.c.

References _s_dialog::call_id, _s_dialog::direction, get_s_dialog_hash(), s_dialog_hash_slot::head, _s_dialog::next, and s_dialogs.

Referenced by release_call_s().

00456 {
00457     s_dialog *d=0;
00458     unsigned int hash = get_s_dialog_hash(call_id);
00459 
00460     d = s_dialogs[hash].head;
00461     while(d){
00462         if (d->direction == dir &&
00463             d->call_id.len == call_id.len &&
00464             strncasecmp(d->call_id.s,call_id.s,call_id.len)==0) {
00465                 return d;
00466             }
00467         d = d->next;
00468     }
00469     return 0;
00470 }

int terminate_s_dialog ( s_dialog d  ) 

Terminates a dialog - called before del_s_dialog to send out terminatination messages.

Parameters:
d - the dialog to terminate
Returns:
- 1 if the requests were sent and the dialog will be deleted, 0 on error (you will have to delete the dialog yourself!)

Definition at line 479 of file dlg_state.c.

References del_s_dialog(), DLG_METHOD_INVITE, DLG_METHOD_SUBSCRIBE, M_NAME, _s_dialog::method, Reason, release_call_s(), release_subscription(), and scscf_dialogs_enable_release.

Referenced by dialog_timer(), and S_drop_all_dialogs().

00480 {
00481     if (!scscf_dialogs_enable_release) return 0;    
00482     switch (d->method){
00483         case DLG_METHOD_INVITE:
00484             if (release_call_s(d,Reason)<=0){
00485                 //dialog has expired and not confirmed
00486                 // or error releasing dialog
00487                 del_s_dialog(d);
00488             }
00489             return 1;
00490             break;
00491         case DLG_METHOD_SUBSCRIBE:
00492             if (!release_subscription(d)){
00493                 //error releasing the subscription - just drop silently
00494                 del_s_dialog(d);
00495             }
00496             return 1;
00497             break;
00498         default:
00499             LOG(L_ERR,"ERR:"M_NAME":terminate_s_dialog(): Not implemented yet for method[%d]!\n",d->method);
00500             return 0;
00501     }
00502 }

void del_s_dialog ( s_dialog d  ) 

Deletes a dialog from the hash table.

Note:
Must be called with a lock on the dialogs slot
Parameters:
d - the dialog to delete

Definition at line 509 of file dlg_state.c.

References _s_dialog::call_id, _s_dialog::direction, free_s_dialog(), _s_dialog::hash, s_dialog_hash_slot::head, M_NAME, _s_dialog::next, _s_dialog::prev, s_dialogs, and s_dialog_hash_slot::tail.

Referenced by confirmed_response(), dialog_timer(), release_subscription(), S_drop_all_dialogs(), S_drop_dialog(), S_save_dialog(), and terminate_s_dialog().

00510 {
00511     LOG(L_INFO,"DBG:"M_NAME":del_s_dialog(): Deleting dialog <%.*s> DIR[%d]\n",d->call_id.len,d->call_id.s,d->direction);
00512     if (d->prev) d->prev->next = d->next;
00513     else s_dialogs[d->hash].head = d->next;
00514     if (d->next) d->next->prev = d->prev;
00515     else s_dialogs[d->hash].tail = d->prev;
00516     free_s_dialog(d);
00517 }

void free_s_dialog ( s_dialog d  ) 

Frees a dialog.

Parameters:
d - the dialog to delete

Definition at line 524 of file dlg_state.c.

References _s_dialog::aor, _s_dialog::call_id, _s_dialog::dialog_c, _s_dialog::dialog_s, _s_dialog::event, _s_dialog::method_str, _s_dialog::refresher, s_dialog_count_decrement(), and tmb.

Referenced by del_s_dialog(), and s_dialogs_destroy().

00525 {
00526     if (!d) return;
00527     if (d->call_id.s) shm_free(d->call_id.s);
00528     if (d->aor.s) shm_free(d->aor.s);   
00529     if (d->method_str.s) shm_free(d->method_str.s);
00530     if (d->dialog_s) tmb.free_dlg(d->dialog_s);
00531     if (d->dialog_c) tmb.free_dlg(d->dialog_c);
00532     if (d->refresher.s) shm_free(d->refresher.s);       
00533     if (d->event.s) shm_free(d->event.s);       
00534     shm_free(d);
00535     s_dialog_count_decrement();     
00536 }

void print_s_dialogs ( int  log_level  ) 

Prints the list of dialogs.

Parameters:
log_level - level to log at

Definition at line 542 of file dlg_state.c.

References ANSI_BLUE, ANSI_GREEN, ANSI_MAGENTA, ANSI_RED, _s_dialog::aor, _s_dialog::call_id, d_act_time(), d_lock(), d_time_now, d_unlock(), _s_dialog::direction, _s_dialog::event, _s_dialog::expires, s_dialog_hash_slot::head, M_NAME, _s_dialog::method, _s_dialog::next, _s_dialog::refresher, s_dialogs, s_dialogs_hash_size, and _s_dialog::state.

Referenced by S_drop_dialog(), S_save_dialog(), and S_update_dialog().

00543 {
00544     s_dialog *d;
00545     int i;
00546     if (debug<log_level) return; /* to avoid useless calls when nothing will be printed */
00547     d_act_time();
00548     LOG(log_level,"INF:"M_NAME":----------  S-CSCF Dialog List begin --------------\n");
00549     for(i=0;i<s_dialogs_hash_size;i++){
00550         d_lock(i);
00551             d = s_dialogs[i].head;
00552             while(d){
00553                 LOG(log_level,"INF:"M_NAME":[%4d] Dir["ANSI_MAGENTA"%d"ANSI_GREEN
00554                     "] Call-ID:<"ANSI_BLUE"%.*s"ANSI_GREEN
00555                     "> AOR:<"ANSI_RED"%.*s"ANSI_GREEN
00556                     ">\n",i,                
00557                     d->direction,
00558                     d->call_id.len,d->call_id.s,
00559                     d->aor.len,d->aor.s);
00560                 LOG(log_level,"INF:"M_NAME":\t\tMethod:["ANSI_MAGENTA"%d"ANSI_GREEN
00561                     "] State:["ANSI_MAGENTA"%d"ANSI_GREEN
00562                     "] Exp:["ANSI_MAGENTA"%4d"ANSI_GREEN"] Ref:["ANSI_MAGENTA"%.*s"ANSI_GREEN"] Event:["ANSI_MAGENTA"%.*s"ANSI_GREEN"]\n",              
00563                     d->method,
00564                     d->state,
00565                     (int)(d->expires - d_time_now),
00566                     d->refresher.len,d->refresher.s,
00567                     d->event.len,d->event.s);
00568                     
00569                 d = d->next;
00570             }       
00571         d_unlock(i);
00572     }
00573     LOG(log_level,"INF:"M_NAME":----------  S-CSCF Dialog List end   --------------\n");    
00574 }

enum s_dialog_direction get_dialog_direction ( char *  direction  ) 

Returns the s_dialog_direction from the direction string.

Parameters:
direction - "orig" or "term"
Returns:
the s_dialog_direction if ok or DLG_MOBILE_UNKNOWN if not found

Definition at line 583 of file dlg_state.c.

References DLG_MOBILE_ORIGINATING, DLG_MOBILE_TERMINATING, DLG_MOBILE_UNKNOWN, and M_NAME.

00584 {
00585     switch(direction[0]){
00586         case 'o':
00587         case 'O':
00588         case '0':
00589             return DLG_MOBILE_ORIGINATING;
00590         case 't':
00591         case 'T':
00592         case '1':
00593             return DLG_MOBILE_TERMINATING;
00594         default:
00595             LOG(L_CRIT,"ERR:"M_NAME":get_dialog_direction(): Unknown direction %s",direction);
00596             return DLG_MOBILE_UNKNOWN;
00597     }
00598 }

int S_is_in_dialog ( struct sip_msg *  msg,
char *  str1,
char *  str2 
)

Find out if a message is within a saved dialog.

Parameters:
msg - the SIP message
str1 - the direction of the dialog ("orig"/"term")
str2 - not used
Returns:
CSCF_RETURN_TRUE if in, CSCF_RETURN_FALSE else or CSCF_RETURN_BREAK on error

Definition at line 661 of file dlg_state.c.

References cscf_get_call_id(), CSCF_RETURN_FALSE, CSCF_RETURN_TRUE, find_dialog_route_dir(), get_dialog_direction(), and is_s_dialog_dir().

00662 {
00663     str call_id;
00664     enum s_dialog_direction dir = get_dialog_direction(str1);
00665     enum s_dialog_direction dirmsg = find_dialog_route_dir(msg);
00666     
00667 
00668 //  LOG(L_CRIT,"%d - %d\n",dir,dirmsg);
00669     if (dir!=dirmsg) return CSCF_RETURN_FALSE;              
00670             
00671 //  print_s_dialogs(L_ERR);
00672     call_id = cscf_get_call_id(msg,0);
00673     if (!call_id.len){
00674         
00675         return CSCF_RETURN_FALSE;
00676     }
00677     
00678     if (is_s_dialog_dir(call_id,dir))
00679         return CSCF_RETURN_TRUE;
00680     else 
00681         return CSCF_RETURN_FALSE;
00682 }

int S_save_dialog ( struct sip_msg *  msg,
char *  str1,
char *  str2 
)

Saves a dialog.

Parameters:
msg - the initial request
str1 - direction - "orig" or "term"
str2 - not used
Returns:
CSCF_RETURN_TRUE if ok, CSCF_RETURN_FALSE if not or CSCF_RETURN_BREAK on error

Definition at line 833 of file dlg_state.c.

References add_s_dialog(), cscf_get_call_id(), cscf_get_cseq(), cscf_get_event(), cscf_get_from_tag(), cscf_get_from_uri(), cscf_get_session_expires(), cscf_get_session_expires_body(), cscf_get_to_uri(), CSCF_RETURN_BREAK, CSCF_RETURN_ERROR, CSCF_RETURN_FALSE, CSCF_RETURN_TRUE, d_act_time(), d_unlock(), del_s_dialog(), _s_dialog::dialog_c, _s_dialog::dialog_s, DLG_STATE_INITIAL, _s_dialog::event, _s_dialog::expires, find_dialog_aor(), _s_dialog::first_cseq, get_dialog_direction(), get_dialog_method(), _s_dialog::hash, is_s_dialog(), _s_dialog::last_cseq, _s_dialog::lr_session_expires, M_NAME, _s_dialog::method, _s_dialog::method_str, print_s_dialogs(), _s_dialog::refresher, _s_dialog::state, STR_SHM_DUP, supports_extension(), tmb, and _s_dialog::uac_supp_timer.

00834 {
00835     str call_id;
00836     s_dialog *d;
00837     str aor;
00838     char buf1[256],buf2[256];
00839     str uri,tag,ruri,x; 
00840     time_t t_time;
00841     str ses_exp = {0,0};
00842     str refresher = {0,0};
00843     str event = {0,0};
00844     struct hdr_field *h;
00845     unsigned int hash;
00846     
00847     enum s_dialog_direction dir = get_dialog_direction(str1);
00848     
00849     if (!find_dialog_aor(msg,dir,&aor)){
00850         LOG(L_ERR,"ERR:"M_NAME":S_save_dialog(): Error retrieving %s contact\n",str1);
00851         return CSCF_RETURN_BREAK;
00852     }       
00853         
00854     call_id = cscf_get_call_id(msg,0);
00855     if (!call_id.len)
00856         return CSCF_RETURN_FALSE;
00857 
00858     LOG(L_INFO,"DBG:"M_NAME":S_save_dialog(%s): Call-ID <%.*s>\n",str1,call_id.len,call_id.s);
00859 
00860     if (is_s_dialog(call_id,aor,dir)){
00861         LOG(L_ERR,"ERR:"M_NAME":S_save_dialog: dialog already exists!\n");  
00862         return CSCF_RETURN_TRUE;
00863     }
00864     
00865     d = add_s_dialog(call_id,aor,dir);
00866     if (!d) return CSCF_RETURN_FALSE;
00867 
00868     d->method = get_dialog_method(msg->first_line.u.request.method);
00869     STR_SHM_DUP(d->method_str,msg->first_line.u.request.method,"shm");
00870     d->first_cseq = cscf_get_cseq(msg,0);
00871     d->last_cseq = d->first_cseq;
00872     d->state = DLG_STATE_INITIAL;
00873 
00874     d->