cr_carrier.h File Reference

Contains the functions to manage carrier data.

More...

#include <sys/types.h>
#include "../../str.h"

Include dependency graph for cr_carrier.h:

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

Go to the source code of this file.

Data Structures

struct  carrier_data_t

Functions

int add_domain_data (struct carrier_data_t *carrier_data, struct domain_data_t *domain_data, int index)
int compare_carrier_data (const void *v1, const void *v2)
struct carrier_data_tcreate_carrier_data (int carrier_id, str *carrier_name, int domains)
void destroy_carrier_data (struct carrier_data_t *carrier_data)
struct domain_data_tget_domain_data (struct carrier_data_t *carrier_data, int domain_id)


Detailed Description

Contains the functions to manage carrier data.

Definition in file cr_carrier.h.


Function Documentation

int add_domain_data ( struct carrier_data_t carrier_data,
struct domain_data_t domain_data,
int  index 
)

Adds a domain_data struct to the given carrier data structure at the given index. Other etries are moved one position up to make space for the new one.

Parameters:
carrier_data the carrier data struct where domain_data should be inserted
domain_data the domain data struct to be inserted
index the index where to insert the domain_data structure in the domain array
Returns:
0 on success, -1 on failure

Definition at line 99 of file cr_carrier.c.

References carrier_data_t::domain_num, carrier_data_t::domains, carrier_data_t::first_empty_domain, carrier_data_t::id, domain_data_t::id, _str::len, LM_DBG, LM_ERR, LM_INFO, carrier_data_t::name, domain_data_t::name, and _str::s.

Referenced by get_domain_data_or_add().

int compare_carrier_data ( const void *  v1,
const void *  v2 
)

Compares the IDs of two carrier data structures. A NULL pointer is always greater than any ID.

Returns:
-1 if v1 < v2, 0 if v1 == v2, 1 if v1 > v2

Definition at line 155 of file cr_carrier.c.

References carrier_data_t::id, and NULL.

Referenced by get_carrier_data(), and reload_route_data().

struct carrier_data_t* create_carrier_data ( int  carrier_id,
str carrier_name,
int  domains 
) [read]

Create a new carrier_data struct in shared memory and set it up.

Parameters:
carrier_id id of carrier
carrier_name pointer to the name of the carrier
domains number of domains for that carrier
Returns:
a pointer to the newly allocated carrier data or NULL on error, in which case it LOGs an error message.

Definition at line 48 of file cr_carrier.c.

References carrier_data_t::domain_num, carrier_data_t::domains, carrier_data_t::id, carrier_data_t::name, NULL, shm_free, shm_malloc(), and SHM_MEM_ERROR.

Referenced by load_config(), and load_route_data_db().

void destroy_carrier_data ( struct carrier_data_t carrier_data  ) 

Destroys the given carrier and frees the used memory.

Parameters:
carrier_data the structure to be destroyed.

Definition at line 75 of file cr_carrier.c.

References destroy_domain_data(), carrier_data_t::domain_num, carrier_data_t::domains, NULL, and shm_free.

Referenced by clear_route_data(), load_config(), and load_route_data_db().

struct domain_data_t* get_domain_data ( struct carrier_data_t carrier_data,
int  domain_id 
) [read]

Returns the domain data for the given id by doing a binary search.

Note:
The domain array must be sorted!
Parameters:
carrier_data carrier data to be searched
domain_id the id of desired domain
Returns:
a pointer to the desired domain data, NULL if not found.

Definition at line 133 of file cr_carrier.c.

References compare_domain_data(), carrier_data_t::domain_num, carrier_data_t::domains, domain_data_t::id, LM_ERR, and NULL.

Referenced by cr_do_route(), and cr_load_next_domain().


Generated on Mon May 21 18:00:38 2012 for Kamailio - The Open Source SIP Server by  doxygen 1.5.6