ucontact.h File Reference

USRLOC - Usrloc contact structure. More...

#include <stdio.h>
#include <time.h>
#include "../../qvalue.h"
#include "../../str.h"

Include dependency graph for ucontact.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ucontact
 Main structure for handling of registered Contact data. More...
struct  ucontact_info
 Informations related to a contact. More...

Defines

#define UL_EXPIRED_TIME   10
 ancient time used for marking the contacts forced to expired
#define VALID_CONTACT(c, t)   ((c->expires>t) || (c->expires==0))
 Valid contact is a contact that either didn't expire yet or is permanent.

Typedefs

typedef enum cstate cstate_t
 States for in-memory contacts in regards to contact storage handler (db, in-memory, ldap etc).
typedef enum flags flags_t
 Flags that can be associated with a Contact.
typedef struct ucontact_info ucontact_info_t
 Informations related to a contact.
typedef struct ucontact ucontact_t
 Main structure for handling of registered Contact data.
typedef int(* update_ucontact_t )(struct urecord *_r, ucontact_t *_c, ucontact_info_t *_ci)
 Update ucontact with new values.

Enumerations

enum  cstate { CS_NEW, CS_SYNC, CS_DIRTY }
 States for in-memory contacts in regards to contact storage handler (db, in-memory, ldap etc). More...
enum  flags { FL_NONE = 0, FL_MEM = 1 << 0, FL_ALL = (int)0xFFFFFFFF }
 Flags that can be associated with a Contact. More...

Functions

int db_delete_ucontact (ucontact_t *_c)
 Delete contact from the database.
int db_insert_ucontact (ucontact_t *_c)
 Insert contact into the database.
int db_update_ucontact (ucontact_t *_c)
 Update contact in the database.
void free_ucontact (ucontact_t *_c)
 Free all memory associated with given contact structure.
int mem_update_ucontact (ucontact_t *_c, ucontact_info_t *_ci)
 Update existing contact in memory with new values.
ucontact_tnew_ucontact (str *_dom, str *_aor, str *_contact, ucontact_info_t *_ci)
 Create a new contact structure.
void print_ucontact (FILE *_f, ucontact_t *_c)
 Print contact, for debugging purposes only.
int st_delete_ucontact (ucontact_t *_c)
 Update state of the contact.
int st_expired_ucontact (ucontact_t *_c)
 Called when the timer is about to delete an expired contact.
int st_flush_ucontact (ucontact_t *_c)
 Called when the timer is about flushing the contact, updates contact state.
void st_update_ucontact (ucontact_t *_c)
 Update state of the contact if we are using write-back scheme.
int update_ucontact (struct urecord *_r, ucontact_t *_c, ucontact_info_t *_ci)
 Update ucontact with new values.


Detailed Description

USRLOC - Usrloc contact structure.

Definition in file ucontact.h.


Define Documentation

#define UL_EXPIRED_TIME   10

ancient time used for marking the contacts forced to expired

Definition at line 103 of file ucontact.h.

Referenced by mi_add_aor_node(), print_ucontact(), and st_delete_ucontact().

#define VALID_CONTACT ( c,
 )     ((c->expires>t) || (c->expires==0))

Valid contact is a contact that either didn't expire yet or is permanent.

Definition at line 106 of file ucontact.h.

Referenced by build_contact(), calc_buf_len(), lookup(), mi_usrloc_show_contact(), nodb_timer(), registered(), test_max_contacts(), wb_timer(), and wt_timer().


Typedef Documentation

typedef enum cstate cstate_t

States for in-memory contacts in regards to contact storage handler (db, in-memory, ldap etc).

typedef enum flags flags_t

Flags that can be associated with a Contact.

Informations related to a contact.

typedef struct ucontact ucontact_t

Main structure for handling of registered Contact data.

typedef int(* update_ucontact_t)(struct urecord *_r, ucontact_t *_c, ucontact_info_t *_ci)

Update ucontact with new values.

Parameters:
_r record the contact belongs to
_c updated contact
_ci new contact informations
Returns:
0 on success, -1 on failure

Definition at line 215 of file ucontact.h.


Enumeration Type Documentation

enum cstate

States for in-memory contacts in regards to contact storage handler (db, in-memory, ldap etc).

Enumerator:
CS_NEW  New contact - not flushed yet
CS_SYNC  Synchronized contact with the database
CS_DIRTY  Update contact - not flushed yet

Definition at line 48 of file ucontact.h.

enum flags

Flags that can be associated with a Contact.

Enumerator:
FL_NONE  No flags set
FL_MEM  Update memory only
FL_ALL  All flags set

Definition at line 56 of file ucontact.h.


Function Documentation

int db_delete_ucontact ( ucontact_t _c  ) 

int db_insert_ucontact ( ucontact_t _c  ) 

int db_update_ucontact ( ucontact_t _c  ) 

void free_ucontact ( ucontact_t _c  ) 

Free all memory associated with given contact structure.

Parameters:
_c freed contact

Definition at line 110 of file ucontact.c.

References ucontact::c, ucontact::callid, ucontact::path, ucontact::received, _str::s, shm_free, and ucontact::user_agent.

Referenced by free_urecord(), mem_delete_ucontact(), and preload_udomain().

int mem_update_ucontact ( ucontact_t _c,
ucontact_info_t _ci 
)

ucontact_t* new_ucontact ( str _dom,
str _aor,
str _contact,
ucontact_info_t _ci 
)

void print_ucontact ( FILE *  _f,
ucontact_t _c 
)

int st_delete_ucontact ( ucontact_t _c  ) 

Update state of the contact.

Parameters:
_c updated contact
Returns:
1 if the contact should be deleted from memory immediately, 0 otherwise

Definition at line 280 of file ucontact.c.

References CS_DIRTY, CS_NEW, CS_SYNC, db_mode, ucontact::expires, ucontact::state, UL_EXPIRED_TIME, and WRITE_BACK.

Referenced by delete_ucontact().

int st_expired_ucontact ( ucontact_t _c  ) 

Called when the timer is about to delete an expired contact.

Parameters:
_c expired contact
Returns:
1 if the contact should be removed from the database and 0 otherwise

Definition at line 321 of file ucontact.c.

References CS_DIRTY, CS_NEW, CS_SYNC, and ucontact::state.

Referenced by wb_timer().

int st_flush_ucontact ( ucontact_t _c  ) 

Called when the timer is about flushing the contact, updates contact state.

Parameters:
_c flushed contact
Returns:
1 if the contact should be inserted, 2 if update and 0 otherwise

Definition at line 350 of file ucontact.c.

References CS_DIRTY, CS_NEW, CS_SYNC, and ucontact::state.

Referenced by wb_timer().

void st_update_ucontact ( ucontact_t _c  ) 

Update state of the contact if we are using write-back scheme.

Parameters:
_c updated contact

Definition at line 244 of file ucontact.c.

References CS_DIRTY, CS_NEW, CS_SYNC, db_mode, ucontact::state, WRITE_BACK, and WRITE_THROUGH.

Referenced by update_ucontact().

int update_ucontact ( struct urecord _r,
ucontact_t _c,
ucontact_info_t _ci 
)

Update ucontact with new values.

Parameters:
_r record the contact belongs to
_c updated contact
_ci new contact informations
Returns:
0 on success, -1 on failure

Definition at line 792 of file ucontact.c.

References CS_SYNC, db_mode, DB_ONLY, db_update_ucontact(), exists_ulcb_type, LM_DBG, LM_ERR, mem_update_ucontact(), run_ul_callbacks(), st_update_ucontact(), ucontact::state, UL_CONTACT_UPDATE, update_contact_pos(), and WRITE_THROUGH.

Referenced by bind_usrloc(), and mi_usrloc_add().


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