registrar_storage.h File Reference


Detailed Description

Serving-CSCF - Registrar Storage Operations.

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

Definition in file registrar_storage.h.

#include "../../sr_module.h"
#include "../../locking.h"
#include "../tm/tm_load.h"
#include "../../qvalue.h"
#include "registrar_parser.h"
#include "registrar_notify.h"

Go to the source code of this file.

Data Structures

struct  _r_subscriber
 registrar subscriber structure More...
struct  _r_contact
 Registrar Contact Structure. More...
struct  _t_regexp_unit
struct  _t_regexp_list
struct  _r_public
 Registrar Public Identity Structure. More...
struct  r_hash_slot
 Registrar Slot Structure. More...

Typedefs

typedef _r_subscriber r_subscriber
 registrar subscriber structure
typedef _r_contact r_contact
 registrar contact structure
typedef _t_regexp_unit t_regexp_unit
typedef _t_regexp_list t_regexp_list
typedef _r_public r_public
 registrar public identity structure
typedef r_public *(*) get_r_public_f (str aor)
 funtion to find a public identity in a registrar
typedef void(*) r_unlock_f (int hash)
 function to unlock a registrar slot
typedef int(*) get_r_public_expires_f (str aor)
 function to get the expiration of a public identity in a registrar

Enumerations

enum  { IMS_EVENT_NONE, IMS_EVENT_REG }
 Events for subscriptions. More...
enum  Reg_States {
  NOT_REGISTERED = 0, REGISTERED = 1, REG_PENDING = -1, DEREGISTERED = -2,
  NOT_REGISTERED = 0, REGISTERED = 1, UNREGISTERED = -1
}
 Enumeration for Registration States. More...

Functions

void r_act_time ()
 Update the time.
int r_valid_contact (r_contact *c)
 Returns if a contact is valid.
int r_valid_subscriber (r_subscriber *c)
 Returns if a subscriber is valid (as in not expired).
unsigned int get_aor_hash (str aor, int hash_size)
 Computes the hash for a string.
int r_storage_init (int hash_size)
 Initialize the registrar.
void r_storage_destroy ()
 Destroy the registrar.
void r_lock (unsigned int hash)
 Lock a registrar hash slot.
void r_unlock (unsigned int hash)
 UnLock a registrar hash slot.
r_subscribernew_r_subscriber (str subscriber, int event, int expires, dlg_t *dialog)
 Creates a registrar public id subscriber This does not insert it in the registrar.
r_subscriberget_r_subscriber (r_public *p, str subscriber, int event)
 Searches for a r_subscriber subscriber and returns it.
r_subscriberadd_r_subscriber (r_public *p, str subscriber, int event, int expires, dlg_t *dialog)
 Adds a new subscriber to the list for the user.
r_subscriberupdate_r_subscriber (r_public *p, str subscriber, int event, int *expires, dlg_t *dialog)
 Updates the r_subscriber with the new expires value If not found, it will be inserted.
void del_r_subscriber (r_public *p, r_subscriber *s)
 Drops and deallocates a r_subscriber.
void free_r_subscriber (r_subscriber *s)
 Frees memory taken by a r_subscriber structure.
r_contactnew_r_contact (str uri, int expires, str ua, str path, qvalue_t qvalue)
 Creates a registrar contact.
r_contactget_r_contact (r_public *p, str uri)
 Searches for a r_contact contact and returns it.
r_contactadd_r_contact (r_public *p, str uri, int expires, str ua, str path, qvalue_t qvalue)
 Creates and Adds a new r_contact.
r_contactupdate_r_contact (r_public *p, str uri, int *expires, str *ua, str *path, qvalue_t qvalue)
 Updates the r_contact with the new expires, ua valu, path value.
void del_r_contact (r_public *p, r_contact *c)
 Drops and deallocates a r_contact.
void free_r_contact (r_contact *c)
 Frees memory taken by a r_contact structure.
r_publicnew_r_public (str aor, enum Reg_States reg_state, ims_subscription *s)
 In case of a Wildcarded PSI, it compiles the regexp for quick processing.
r_publicget_r_public (str aor)
 Searches for a r_public record and returns it.
int get_r_public_expires (str aor)
 Searches for a r_public record and returns its expiration value.
r_publicget_r_public_nolock (str aor)
 Searches for a r_public record and returns it.
r_publicget_r_public_previous_lock (str aor, int locked_hash)
 Searches for a r_public record and returns, with a previous lock aquired.
r_publicadd_r_public (str aor, enum Reg_States reg_state, ims_subscription *s)
 Creates and Adds a new r_public record.
r_publicadd_r_public_previous_lock (str aor, int locked_hash, enum Reg_States reg_state, ims_subscription *s)
 Creates and Adds a new r_public record with a previous lock already aquired.
r_publicupdate_r_public (str aor, enum Reg_States *reg_state, ims_subscription **s, str *ccf1, str *ccf2, str *ecf1, str *ecf2)
 Updates the r_public with the new reg_state and ims_subscription values.
r_publicupdate_r_public_previous_lock (str aor, int locked_hash, enum Reg_States *reg_state, ims_subscription **s, str *ccf1, str *ccf2, str *ecf1, str *ecf2)
 Updates the r_public with the new reg_state and ims_subscription values, with a previous lock on the registrar.
void r_public_expire (str public_id)
 Expires all the contacts for the given public id.
void r_private_expire (str private_id)
 Expires all the contacts of public identities that are related to the given private id.
void del_r_public (r_public *p)
 Drops and deallocates a r_public.
void free_r_public (r_public *p)
 Frees memory taken by a r_public aor structure.
void print_r (int log_level)
 Debug print the contents of the entire registrar.

Variables

enum { ... }  IMS_Events
 Events for subscriptions.


Typedef Documentation

typedef struct _r_subscriber r_subscriber

registrar subscriber structure

typedef struct _r_contact r_contact

registrar contact structure

typedef struct _t_regexp_unit t_regexp_unit

typedef struct _t_regexp_list t_regexp_list

typedef struct _r_public r_public

registrar public identity structure

typedef r_public*(*) get_r_public_f(str aor)

funtion to find a public identity in a registrar

Definition at line 151 of file registrar_storage.h.

typedef void(*) r_unlock_f(int hash)

function to unlock a registrar slot

Definition at line 153 of file registrar_storage.h.

typedef int(*) get_r_public_expires_f(str aor)

function to get the expiration of a public identity in a registrar

Definition at line 155 of file registrar_storage.h.


Enumeration Type Documentation

anonymous enum

Events for subscriptions.

Enumerator:
IMS_EVENT_NONE  Generic, no event.
IMS_EVENT_REG  Registration event.

Definition at line 74 of file registrar_storage.h.

00074      {
00075     IMS_EVENT_NONE,             
00076     IMS_EVENT_REG               
00077 }IMS_Events;

enum Reg_States

Enumeration for Registration States.

Enumerator:
NOT_REGISTERED  User not-registered.
REGISTERED  User registered.
REG_PENDING  Registration pending.
DEREGISTERED  DeRegistered-IPSec on - used to relay last messages to freshly de-registered user.
NOT_REGISTERED  User not-registered, no profile stored.
REGISTERED  User registered.
UNREGISTERED  User not-registered, profile stored.

Definition at line 106 of file registrar_storage.h.

00106                 {
00107     NOT_REGISTERED=0,           
00108     REGISTERED=1,               
00109     UNREGISTERED=-1             
00110 } ;


Function Documentation

void r_act_time (  )  [inline]

Update the time.

Definition at line 79 of file registrar_storage.c.

References time_now.

00080 {
00081     time_now=time(0);
00082 }

int r_valid_contact ( r_contact c  )  [inline]

Returns if a contact is valid.

Caller should do actualization of time_now

Parameters:
c - the contact to check
Returns:
1 if valid, else 0

Definition at line 90 of file registrar_storage.c.

References DEREGISTERED, _r_contact::expires, NOT_REGISTERED, _r_contact::reg_state, and time_now.

00091 {
00092 //  LOG(L_ERR,"%.*s -> %ld\n",c->uri.len,c->uri.s,c->expires-time_now);
00093     return (c->reg_state!=NOT_REGISTERED && c->reg_state!=DEREGISTERED)&&(c->expires>time_now);
00094 }

int r_valid_subscriber ( r_subscriber s  )  [inline]

Returns if a subscriber is valid (as in not expired).

Caller should do actualization of time_now

Parameters:
s - the contact to check
Returns:
1 if valid, else 0

Definition at line 131 of file registrar_storage.c.

References _r_subscriber::expires, and time_now.

Referenced by registrar_timer().

00132 {
00133     return (s->expires>time_now);
00134 }

unsigned int get_aor_hash ( str  aor,
int  hash_size 
) [inline]

Computes the hash for a string.

Parameters:
aor - the aor to compute the hash on
hash_size - value to % with
Returns:
the hash % hash_size

Definition at line 142 of file registrar_storage.c.

References h_inc.

Referenced by bin_decode_r_public(), get_r_public(), get_r_public_nolock(), get_r_public_previous_lock(), new_r_public(), and r_get_reginfo_full().

00143 {
00144 #define h_inc h+=v^(v>>3)
00145    char* p;
00146    register unsigned v;
00147    register unsigned h;
00148 
00149    h=0;
00150    for (p=aor.s; p<=(aor.s+aor.len-4); p+=4){
00151        v=(*p<<24)+(p[1]<<16)+(p[2]<<8)+p[3];
00152        h_inc;
00153    }
00154    v=0;
00155    for (;p<(aor.s+aor.len); p++) {
00156        v<<=8;
00157        v+=*p;
00158    }
00159    h_inc;
00160 
00161    h=((h)+(h>>11))+((h>>13)+(h>>23));
00162    return (h)%hash_size;
00163 #undef h_inc 
00164 }

int r_storage_init ( int  hash_size  ) 

Initialize the registrar.

Parameters:
hash_size - number of hash slots to create
Returns:
1 on success, 0 on error

Definition at line 149 of file registrar_storage.c.

References r_hash_slot::lock, M_NAME, r_hash_size, and registrar.

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

void r_storage_destroy (  ) 

Destroy the registrar.

Definition at line 174 of file registrar_storage.c.

References free_r_contact(), free_r_public(), r_hash_slot::head, _r_public::next, _r_contact::next, r_hash_size, r_lock(), r_unlock(), and registrar.

00175 {
00176     int i;
00177     r_contact *c,*nc;
00178     for(i=0;i<r_hash_size;i++){
00179         r_lock(i);
00180             c = registrar[i].head;
00181             while(c){
00182                 nc = c->next;
00183                 free_r_contact(c);
00184                 c = nc;
00185             }
00186         r_unlock(i);
00187         lock_dealloc(registrar[i].lock);
00188     }
00189     shm_free(registrar);    
00190 }

void r_lock ( unsigned int  hash  )  [inline]

Lock a registrar hash slot.

Parameters:
hash - the index of the slot

Definition at line 196 of file registrar_storage.c.

References registrar.

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

void r_unlock ( unsigned int  hash  )  [inline]

UnLock a registrar hash slot.

Parameters:
hash - the index of the slot

Definition at line 206 of file registrar_storage.c.

References registrar.

00207 {
00208 //  LOG(L_CRIT,"REL %d\n",hash);    
00209     lock_release(registrar[hash].lock);
00210 }

r_subscriber* new_r_subscriber ( str  subscriber,
int  event,
int  expires,
dlg_t *  dialog 
)

Creates a registrar public id subscriber This does not insert it in the registrar.

Parameters:
subscriber - the contact of the subscribption - the subscriber
event - what event to subscribe to
expires - time of expiration
dialog - dialog for the subscription
Returns:
the r_subscriber created, NULL on error

Definition at line 248 of file registrar_storage.c.

References _r_subscriber::dialog, _r_subscriber::event, _r_subscriber::expires, M_NAME, STR_SHM_DUP, and _r_subscriber::subscriber.

Referenced by add_r_subscriber().

00249 {
00250     r_subscriber *s;
00251     
00252     s = shm_malloc(sizeof(r_subscriber));
00253     if (!s) {
00254         LOG(L_ERR,"ERR:"M_NAME":new_r_subscriber(): Unable to alloc %d bytes\n",
00255             sizeof(r_subscriber));
00256         goto error;
00257     }
00258     memset(s,0,sizeof(r_subscriber));
00259     
00260     STR_SHM_DUP(s->subscriber,subscriber,"new_r_subscriber");
00261     
00262     s->event = event;
00263     
00264     s->expires = expires;
00265 
00266     s->dialog = dialog;
00267                     
00268     return s;
00269 error:
00270 out_of_memory:
00271     if (s){
00272         if (s->subscriber.s) shm_free(s->subscriber.s);
00273         shm_free(s);        
00274     }
00275     return 0;
00276 }

r_subscriber* get_r_subscriber ( r_public p,
str  subscriber,
int  event 
)

Searches for a r_subscriber subscriber and returns it.

Parameters:
p - the r_public record to look into
subscriber - the uri of the subscriber
event - what event to look for
Returns:
- the r_subscriber found, 0 if not found

Definition at line 286 of file registrar_storage.c.

References _r_subscriber::event, _r_subscriber::next, _r_public::shead, and _r_subscriber::subscriber.

Referenced by S_subscribe(), and update_r_subscriber().

00287 {
00288     r_subscriber *s=0;
00289     if (!p) return 0;
00290     s = p->shead;
00291     while(s){
00292         if (s->event == event &&
00293             s->subscriber.len == subscriber.len &&
00294             strncasecmp(s->subscriber.s,subscriber.s,subscriber.len)==0) return s;
00295         s = s->next;
00296     }
00297     return 0;
00298 }

r_subscriber* add_r_subscriber ( r_public p,
str  subscriber,
int  event,
int  expires,
dlg_t *  dialog 
)

Adds a new subscriber to the list for the user.

Note:
Make sure that get_r_subscriber(p,subscriber) returns 0 in order to avoid ureachable duplicates
Parameters:
p - the r_public to add to
subscriber - the contact of the subscribption - the subscriber
event - what event to subscribe to
expires - time of expiration
dialog - dialog for the subscription
Returns:
the r_subscriber that has been added, NULL on error

Definition at line 310 of file registrar_storage.c.

References new_r_subscriber(), _r_subscriber::next, _r_subscriber::prev, _r_public::shead, and _r_public::stail.

Referenced by update_r_subscriber().

00311 {
00312     r_subscriber *s;
00313 
00314     if (!p) return 0;
00315     
00316     s = new_r_subscriber(subscriber,event,expires,dialog);
00317     if (!s) return 0;       
00318     s->next = 0;
00319     s->prev = p->stail;
00320     if (p->stail) p->stail->next = s;
00321     p->stail = s;
00322     if (!p->shead) p->shead=s;
00323     
00324     return s;
00325 }

r_subscriber* update_r_subscriber ( r_public p,
str  subscriber,
int  event,
int *  expires,
dlg_t *  dialog 
)

Updates the r_subscriber with the new expires value If not found, it will be inserted.

Parameters:
p - the r_public to add to
subscriber - the subscriber to update
expires - new expires value, NULL if not necessary
ua - new user agent string, NULL if no update necessary
dialog - dialog for the subscription
Returns:
the newly added r_public, 0 on error

Definition at line 337 of file registrar_storage.c.

References add_r_subscriber(), _r_subscriber::dialog, _r_subscriber::expires, get_r_subscriber(), and tmb.

Referenced by S_subscribe().

00338 {
00339     r_subscriber *s;
00340     
00341     if (!p) return 0;
00342     s = get_r_subscriber(p,subscriber,event);
00343     if (!s){
00344         if (expires)
00345             return add_r_subscriber(p,subscriber,event,*expires,dialog);
00346         else return 0;
00347     }else{
00348         if (expires) s->expires = *expires;
00349         if (s->dialog && s->dialog!=dialog) tmb.free_dlg(s->dialog);
00350         s->dialog = dialog;
00351         return s;
00352     }
00353 }

void del_r_subscriber ( r_public p,
r_subscriber s 
)

Drops and deallocates a r_subscriber.

Note:
When calling be sure that get_r_subscriber(p,uri) returns c, to avoid a bogus removal.
Parameters:
p - the r_public record to look into
s - the r_subscriber to remove

Definition at line 361 of file registrar_storage.c.

References _r_subscriber::dialog, free_r_subscriber(), _r_subscriber::next, _r_subscriber::prev, _r_public::shead, _r_public::stail, and tmb.

Referenced by registrar_timer(), and S_subscribe().

00362 {
00363 //  LOG(L_ERR,"DBG:"M_NAME":del_r_subscriber: LIST: %p --> %p\n",p->shead,p->stail);
00364 //  LOG(L_ERR,"DBG:"M_NAME":del_r_subscriber: %p<- S:%p ->%p\n",s->prev,s,s->next); 
00365     if (p->shead == s) p->shead = s->next;
00366     else s->prev->next = s->next;
00367     if (p->stail == s) p->stail = s->prev;
00368     else s->next->prev = s->prev;
00369     if (s->dialog) tmb.free_dlg(s->dialog);
00370     
00371     free_r_subscriber(s);
00372 }

void free_r_subscriber ( r_subscriber s  ) 

Frees memory taken by a r_subscriber structure.

Parameters:
s - the r_contact to be deallocated

Definition at line 378 of file registrar_storage.c.

References _r_subscriber::subscriber.

Referenced by bin_decode_r_public(), del_r_subscriber(), and free_r_public().

00379 {
00380     if (!s) return;
00381     if (s->subscriber.s) shm_free(s->subscriber.s);
00382     shm_free(s);
00383 }

r_contact* new_r_contact ( str  uri,
int  expires,
str  ua,
str  path,
qvalue_t  qvalue 
)

Creates a registrar contact.

This does not insert it in the registrar

Parameters:
uri - the contact uri
expires - the time of expiration
ua - the useragent string
path - Path header received at registration
qvalue - Q-value of the contact
Returns:
the new r_contact or NULL on error

Definition at line 415 of file registrar_storage.c.

References _r_contact::expires, M_NAME, _r_contact::path, _r_contact::qvalue, _r_contact::ua, and _r_contact::uri.

00416 {
00417     r_contact *c;
00418     
00419     c = shm_malloc(sizeof(r_contact));
00420     if (!c) {
00421         LOG(L_ERR,"ERR:"M_NAME":new_r_contact(): Unable to alloc %d bytes\n",
00422             sizeof(r_contact));
00423         goto error;
00424     }
00425     memset(c,0,sizeof(r_contact));
00426     
00427     c->uri.s = shm_malloc(uri.len);
00428     if (!c->uri.s){
00429         LOG(L_ERR,"ERR:"M_NAME":new_r_contact(): Unable to alloc %d bytes\n",
00430             uri.len);
00431         goto error;
00432     }   
00433     c->uri.len = uri.len;
00434     memcpy(c->uri.s,uri.s,uri.len);
00435     
00436     c->expires = expires;
00437     
00438     c->ua.s = shm_malloc(ua.len);
00439     if (!c->ua.s){
00440         LOG(L_ERR,"ERR:"M_NAME":new_r_contact(): Unable to alloc %d bytes\n",
00441             ua.len);
00442         goto error;
00443     }
00444     c->ua.len = ua.len;
00445     memcpy(c->ua.s,ua.s,ua.len);    
00446 
00447     if (path.len){
00448         c->path.s = shm_malloc(path.len);
00449         if (!c->path.s){
00450             LOG(L_ERR,"ERR:"M_NAME":new_r_contact(): Unable to alloc %d bytes\n",
00451                 path.len);
00452             goto error;
00453         }
00454         c->path.len = path.len;
00455         memcpy(c->path.s,path.s,path.len);  
00456     }
00457 
00458     c->qvalue = qvalue;
00459         
00460     return c;
00461 error:
00462     if (c){
00463         if (c->uri.s) shm_free(c->uri.s);
00464         if (c->ua.s) shm_free(c->ua.s);
00465         shm_free(c);
00466             
00467     }
00468     return 0;
00469 }

r_contact* get_r_contact ( r_public p,
str  uri 
)

Searches for a r_contact contact and returns it.

Parameters:
p - the r_public record to look into
uri - the uri of the contact
Returns:
- the r_contact found, 0 if not found

Definition at line 392 of file registrar_storage.c.

References _r_public::head, _r_contact::next, and _r_contact::uri.

00393 {
00394     r_contact *c=0;
00395     if (!p) return 0;
00396     c = p->head;
00397     while(c){
00398         if (c->uri.len == uri.len &&
00399             strncasecmp(c->uri.s,uri.s,uri.len)==0) return c;
00400         c = c->next;
00401     }
00402     return 0;
00403 }

r_contact* add_r_contact ( r_public p,
str  uri,
int  expires,
str  ua,
str  path,
qvalue_t  qvalue 
)

Creates and Adds a new r_contact.

Note:
When calling be sure that get_r_contact(p,uri) returns 0, to avoid unreachable duplicates.
Parameters:
p - the r_public to add to
uri - the uri of the contact
expires - the expiration time
ua - the user agent string
path - Path header received at registration
qvalue - Q-value of the contact
Returns:
the newly added r_contact or NULL on error

Definition at line 482 of file registrar_storage.c.

References _r_public::head, new_r_contact(), _r_contact::next, _r_contact::prev, and _r_public::tail.

00483 {
00484     r_contact *c;
00485     if (!p) return 0;
00486     c = new_r_contact(uri,expires,ua,path,qvalue);
00487     if (!c) return 0;
00488     c->next=0;
00489     c->prev=p->tail;
00490     if (p->tail) {
00491         p->tail->next = c;
00492         p->tail = c;
00493     }
00494     else p->tail = c;
00495     if (!p->head) p->head=c;
00496     
00497     return c;
00498 }

r_contact* update_r_contact ( r_public p,
str  uri,
int *  expires,
str *  ua,
str *  path,
qvalue_t  qvalue 
)

Updates the r_contact with the new expires, ua valu, path value.

Note:
If not found it is added

Must be called with a lock on the hash slot to avoid races

Parameters:
p - the r_public to add to
uri - the contact uri
expires - new expires value, NULL if not necessary
ua - new user agent string, NULL if no update necessary
path - Path header received at registration
qvalue - Q-value of the contact
Returns:
the updated r_contact or NULL on error

Definition at line 512 of file registrar_storage.c.

References add_r_contact(), _r_contact::expires, get_r_contact(), M_NAME, _r_contact::path, _r_contact::qvalue, and _r_contact::ua.

00513 {
00514     r_contact *c;
00515     
00516     if (!p) return 0;
00517     c = get_r_contact(p,uri);
00518     if (!c){
00519         if (expires && ua && path)
00520             return add_r_contact(p,uri,*expires,*ua,*path,qvalue);
00521         else return 0;
00522     }else{
00523         if (expires) c->expires = *expires;
00524         if (ua){
00525             if (c->ua.s) shm_free(c->ua.s);
00526             c->ua.s = shm_malloc(ua->len);
00527             if (!c->ua.s) {
00528                 LOG(L_ERR,"ERR:"M_NAME":update_r_contact(): Error allocating %d bytes\n",
00529                     ua->len);
00530                 c->ua.len=0;
00531                 return 0;
00532             }
00533             c->ua.len = ua->len;
00534             memcpy(c->ua.s,ua->s,ua->len);
00535         }
00536         if (path){
00537             if (c->path.s) shm_free(c->path.s);
00538             c->path.s = shm_malloc(path->len);
00539             if (!c->path.s) {
00540                 LOG(L_ERR,"ERR:"M_NAME":update_r_contact(): Error allocating %d bytes\n",
00541                     path->len);
00542                 c->path.len=0;
00543                 return 0;
00544             }
00545             c->path.len = path->len;
00546             memcpy(c->path.s,path->s,path->len);
00547         }
00548         c->qvalue = qvalue;
00549         return c;
00550     }
00551 }

void del_r_contact ( r_public p,
r_contact c 
)

Drops and deallocates a r_contact.

Note:
When calling be sure that get_r_contact(p,uri) returns c, to avoid a bogus removal
Parameters:
p - the r_public record to look into
c - the r_contact to remove

Definition at line 559 of file registrar_storage.c.

References free_r_contact(), _r_public::head, _r_contact::next, _r_contact::prev, and _r_public::tail.

00560 {
00561     if (p->head == c) p->head = c->next;
00562     else c->prev->next = c->next;
00563     if (p->tail == c) p->tail = c->prev;
00564     else c->next->prev = c->prev;
00565     free_r_contact(c);
00566 }

void free_r_contact ( r_contact c  ) 

Frees memory taken by a r_contact structure.

Parameters:
c - the r_contact to be deallocated

Definition at line 760 of file registrar_storage.c.

References free_r_public(), free_r_security(), _r_contact::head, _r_contact::host, if, _r_public::next, _r_contact::path, _r_contact::pinhole, _r_contact::security, _r_contact::security_temp, _r_contact::service_route, _r_contact::service_route_cnt, _r_contact::ua, and _r_contact::uri.

00761 {
00762     r_public *p,*n;
00763     int i;
00764 
00765     if (!c) return;
00766     if (c->pinhole) shm_free(c->pinhole);
00767     if (c->host.s) shm_free(c->host.s);
00768     if (c->uri.s) shm_free(c->uri.s);
00769     if (c->service_route){
00770         i=0;
00771         for(i=0;i<c->service_route_cnt;i++)
00772             if (c->service_route[i].s)
00773                 shm_free(c->service_route[i].s);
00774         shm_free(c->service_route);
00775     }
00776     p = c->head;
00777     while(p){
00778         n = p->next;
00779         free_r_public(p);
00780         p = n;
00781     }
00782     if (c->security_temp) free_r_security(c->security_temp);
00783     if (c->security) free_r_security(c->security);
00784     shm_free(c);
00785 }

r_public* new_r_public ( str  aor,
enum Reg_States  reg_state,
ims_subscription s 
)

In case of a Wildcarded PSI, it compiles the regexp for quick processing.

Definition at line 638 of file registrar_storage.c.

References escape_all_wildcards_and_copy(), get_aor_hash(),