usr_avp.h File Reference

AVP handling functions More...

#include "str.h"

Include dependency graph for usr_avp.h:

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

Go to the source code of this file.

Data Structures

union  int_str
struct  usr_avp

Defines

#define avp_core_flags(f)   ((f)&0x00ff)
#define AVP_CORE_MASK   0x00ff
#define avp_get_script_flags(f)   (((f)&0xff00)>>8)
#define AVP_NAME_DELIM   ':'
#define AVP_NAME_STR   (1<<0)
#define AVP_NAME_VALUE_MASK   0x0003
#define avp_script_flags(f)   (((f)<<8)&0xff00)
#define AVP_SCRIPT_MASK   0xff00
#define AVP_VAL_STR   (1<<1)
#define is_avp_str_name(a)   (a->flags&AVP_NAME_STR)
#define is_avp_str_val(a)   (a->flags&AVP_VAL_STR)

Functions

int add_avp (unsigned short flags, int_str name, int_str val)
 Add an AVP to the global list.
int add_avp_galias (str *alias, int type, int_str avp_name)
 Add global AVP alias to the list, allocate private memory.
int add_avp_galias_str (char *alias_definition)
 Add global alias.
void destroy_avp (struct usr_avp *avp)
 Search AVP in list and delete it.
void destroy_avp_list (struct usr_avp **list)
 Free an AVP list in shared memory with memory locking.
void destroy_avp_list_unsafe (struct usr_avp **list)
 Free an AVP list in shared memory without memory locking.
int destroy_avps (unsigned short flags, int_str name, int all)
 Search AVP(s) in list and destroy them.
struct usr_avp ** get_avp_list (void)
 Return global AVP list, assert that is not null.
strget_avp_name (struct usr_avp *avp)
 Get AVP name.
void get_avp_val (struct usr_avp *avp, int_str *val)
 Get AVP value.
int lookup_avp_galias (str *alias, int *type, int_str *avp_name)
 Lookup global AVP alias.
int parse_avp_name (str *name, int *type, int_str *avp_name)
 Parse an AVP name (as string) and set type and name.
int parse_avp_spec (str *name, int *type, int_str *avp_name)
 Parse AVP specification (alias or AVP) and set type and name.
void reset_avps (void)
 Destroy global AVP list.
struct usr_avpsearch_first_avp (unsigned short flags, int_str name, int_str *val, struct usr_avp *start)
 Search the first matching AVP in the global list.
struct usr_avpsearch_next_avp (struct usr_avp *avp, int_str *val)
 Search the next AVP in the given AVP list.
struct usr_avp ** set_avp_list (struct usr_avp **list)
 Set global AVP list, assert that old list is not null.


Detailed Description

AVP handling functions

Todo:
1) int_str -> (int,str), 2) avp is double linked list (faster at delete and insert)

Definition in file usr_avp.h.


Define Documentation

#define avp_core_flags (  )     ((f)&0x00ff)

Definition at line 79 of file usr_avp.h.

#define AVP_CORE_MASK   0x00ff

Definition at line 77 of file usr_avp.h.

#define avp_get_script_flags (  )     (((f)&0xff00)>>8)

Definition at line 81 of file usr_avp.h.

#define AVP_NAME_DELIM   ':'

delimiter between data type and name

Definition at line 74 of file usr_avp.h.

Referenced by parse_avp_name(), and parse_avp_spec().

#define AVP_NAME_STR   (1<<0)

#define AVP_NAME_VALUE_MASK   0x0003

Definition at line 76 of file usr_avp.h.

#define avp_script_flags (  )     (((f)<<8)&0xff00)

Definition at line 80 of file usr_avp.h.

Referenced by parse_avp_name().

#define AVP_SCRIPT_MASK   0xff00

Definition at line 78 of file usr_avp.h.

Referenced by ops_delete_avp(), pv_get_avp_name(), search_first_avp(), and search_next_avp().

#define AVP_VAL_STR   (1<<1)

#define is_avp_str_name (  )     (a->flags&AVP_NAME_STR)

Definition at line 86 of file usr_avp.h.

#define is_avp_str_val (  )     (a->flags&AVP_VAL_STR)

Definition at line 87 of file usr_avp.h.

Referenced by extract_aor(), m_store(), ops_subst(), registered(), and siptrace_get_table().


Function Documentation

int add_avp ( unsigned short  flags,
int_str  name,
int_str  val 
)

int add_avp_galias ( str alias,
int  type,
int_str  avp_name 
)

Add global AVP alias to the list, allocate private memory.

Parameters:
alias alias string
type AVP type
avp_name AVP name
Returns:
0 on success, -1 on failure

Definition at line 467 of file usr_avp.c.

References avp_galias::alias, avp_galias::avp, AVP_NAME_STR, check_avp_galias(), _str::len, LM_DBG, LM_ERR, int_str::n, avp_spec::name, avp_galias::next, pkg_free, pkg_malloc, _str::s, int_str::s, and avp_spec::type.

Referenced by add_avp_galias_str().

int add_avp_galias_str ( char *  alias_definition  ) 

Add global alias.

Parameters:
alias_definition alias definition, including the AVP
Returns:
0 on success, -1 on error

Definition at line 621 of file usr_avp.c.

References add_avp_galias(), avp_galias::alias, _str::len, LM_ERR, parse_avp_name(), _str::s, and s.

void destroy_avp ( struct usr_avp avp  ) 

Search AVP in list and delete it.

Parameters:
avp searched AVP

Definition at line 349 of file usr_avp.c.

References usr_avp::next, avp::next, and shm_free.

Referenced by destroy_avps(), ds_next_dst(), generate_uris(), ops_copy_avp(), ops_delete_avp(), ops_op_avp(), ops_subst(), and t_next_contacts().

void destroy_avp_list ( struct usr_avp **  list  )  [inline]

Free an AVP list in shared memory with memory locking.

Parameters:
list AVP list

Definition at line 397 of file usr_avp.c.

References LM_DBG, usr_avp::next, and shm_free.

Referenced by build_cell(), and reset_avps().

void destroy_avp_list_unsafe ( struct usr_avp **  list  ) 

Free an AVP list in shared memory without memory locking.

Parameters:
list AVP list

Definition at line 383 of file usr_avp.c.

References usr_avp::next, and shm_free_unsafe.

Referenced by free_cell().

int destroy_avps ( unsigned short  flags,
int_str  name,
int  all 
)

Search AVP(s) in list and destroy them.

Parameters:
flags AVP flags
name AVP name
all set to 1 to delete all matching AVPs, 0 to delete only the first
Returns:
the number of AVPs that were deleted

Definition at line 367 of file usr_avp.c.

References destroy_avp(), and search_first_avp().

Referenced by ops_delete_avp().

struct usr_avp** get_avp_list ( void   )  [read]

Return global AVP list, assert that is not null.

Returns:
global AVP list

Definition at line 236 of file usr_avp.c.

Referenced by ops_dbstore_avps(), ops_delete_avp(), and ops_print_avp().

str* get_avp_name ( struct usr_avp avp  )  [inline]

Get AVP name.

Parameters:
avp inspected AVP
Returns:
pointer to the name, 0 on error

Definition at line 179 of file usr_avp.c.

References AVP_NAME_STR, AVP_VAL_STR, usr_avp::data, usr_avp::flags, LM_ERR, and str_str_data::name.

Referenced by internal_search_name_avp(), ops_dbstore_avps(), ops_print_avp(), and search_next_avp().

void get_avp_val ( struct usr_avp avp,
int_str val 
) [inline]

int lookup_avp_galias ( str alias,
int *  type,
int_str avp_name 
)

Lookup global AVP alias.

Parameters:
alias alias string
type AVP type
avp_name AVP name
Returns:
0 if alias to specified AVP could be found, -1 if not found

Definition at line 529 of file usr_avp.c.

References avp_galias::alias, avp_galias::avp, _str::len, avp_spec::name, avp_galias::next, _str::s, and avp_spec::type.

Referenced by parse_avp_spec().

int parse_avp_name ( str name,
int *  type,
int_str avp_name 
)

Parse an AVP name (as string) and set type and name.

Parameters:
name AVP name
type AVP type
avp_name AVP name
Returns:
0 on success, -1 on failure

Definition at line 547 of file usr_avp.c.

References AVP_NAME_DELIM, AVP_NAME_STR, avp_script_flags, id, _str::len, LM_ERR, int_str::n, NULL, int_str::s, _str::s, s, and str2int().

Referenced by add_avp_galias_str(), and parse_avp_spec().

int parse_avp_spec ( str name,
int *  type,
int_str avp_name 
)

Parse AVP specification (alias or AVP) and set type and name.

Parameters:
name AVP name
type AVP type
avp_name 
Returns:
0 on success, -1 on failure

Definition at line 604 of file usr_avp.c.

References AVP_NAME_DELIM, _str::len, lookup_avp_galias(), NULL, parse_avp_name(), and _str::s.

void reset_avps ( void   ) 

Destroy global AVP list.

Definition at line 412 of file usr_avp.c.

References destroy_avp_list().

Referenced by build_cell(), receive_msg(), and t_uac_cancel().

struct usr_avp* search_first_avp ( unsigned short  flags,
int_str  name,
int_str val,
struct usr_avp start 
) [read]

struct usr_avp* search_next_avp ( struct usr_avp avp,
int_str val 
) [read]

Search the next AVP in the given AVP list.

Search the next AVP in the given AVP list, that is returned from search_first_avp

Parameters:
avp AVP list
val AVP value
Returns:
found AVP, or NULL on failure

Definition at line 327 of file usr_avp.c.

References AVP_NAME_STR, AVP_SCRIPT_MASK, usr_avp::flags, get_avp_name(), get_avp_val(), usr_avp::id, internal_search_ID_avp(), internal_search_name_avp(), and usr_avp::next.

Referenced by ds_next_dst(), legs2strar(), ospCheckOrigDestination(), ospDumpAllDestination(), ospGetLastOrigDestination(), ospGetNextOrigDestination(), ospReportOrigSetupUsage(), sip_trace(), t_next_contacts(), trace_onreply_in(), trace_onreply_out(), trace_onreq_out(), and trace_sl_onreply_out().

struct usr_avp** set_avp_list ( struct usr_avp **  list  )  [read]

Set global AVP list, assert that old list is not null.

Parameters:
list new AVP list
Returns:
pointer to old list

Definition at line 423 of file usr_avp.c.

Referenced by build_cell(), faked_env(), pre_print_uac_request(), reply_received(), run_reqin_callbacks(), run_trans_callbacks(), and t_uac().


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