cr_rule.c File Reference

Contains the functions to manage routing rule data.

More...

#include "../../ut.h"
#include "cr_rule.h"

Include dependency graph for cr_rule.c:

Go to the source code of this file.

Functions

int add_backup_rule (struct route_rule *rule, struct route_rule *backup)
struct failure_route_ruleadd_failure_route_rule (struct failure_route_rule **frr_head, const str *prefix, const str *host, const str *reply_code, flag_t flags, flag_t mask, const int next_domain, const str *comment)
struct route_flagsadd_route_flags (struct route_flags **rf_head, const flag_t flags, const flag_t mask)
int add_route_rule (struct route_flags *rf, const str *prefix, int max_targets, double prob, const str *rewrite_hostpart, int strip, const str *rewrite_local_prefix, const str *rewrite_local_suffix, int status, int hash_index, int backup, int *backed_up, const str *comment)
void destroy_failure_route_rule (struct failure_route_rule *frr)
void destroy_route_flags (struct route_flags *rf)
void destroy_route_rule (struct route_rule *rr)
static int failure_rule_prio_cmp (struct failure_route_rule *frr1, struct failure_route_rule *frr2)
struct route_rulefind_auto_backup (struct route_flags *rf, struct route_rule *rule)
struct route_rulefind_rule_by_hash (struct route_flags *rf, int hash)
struct route_rulefind_rule_by_host (struct route_flags *rf, str *host)
int remove_backed_up (struct route_rule *rule)


Detailed Description

Contains the functions to manage routing rule data.

Definition in file cr_rule.c.


Function Documentation

int add_backup_rule ( struct route_rule rule,
struct route_rule backup 
)

struct failure_route_rule* add_failure_route_rule ( struct failure_route_rule **  frr_head,
const str prefix,
const str host,
const str reply_code,
flag_t  flags,
flag_t  mask,
const int  next_domain,
const str comment 
) [read]

Adds a failure route rule to rule list. prefix, host, reply_code, and comment must not contain NULL pointers.

Parameters:
frr_head pointer to the head of the failure route rule list, might be changed during insert
prefix the whole scan prefix
host the hostname last tried
reply_code the reply code
flags user defined flags
mask mask for user defined flags
next_domain continue routing with this domain
comment a comment for the route rule
Returns:
pointer to the failure_route_rul struct on success, NULL on failure.
See also:
add_failure_route_to_tree()

Definition at line 339 of file cr_rule.c.

References failure_route_rule::comment, destroy_failure_route_rule(), failure_rule_prio_cmp(), failure_route_rule::flags, failure_route_rule::host, failure_route_rule::mask, failure_route_rule::next, failure_route_rule::next_domain, NULL, failure_route_rule::reply_code, shm_malloc(), SHM_MEM_ERROR, and shm_str_dup().

Referenced by add_failure_route_to_tree().

struct route_flags* add_route_flags ( struct route_flags **  rf_head,
const flag_t  flags,
const flag_t  mask 
) [read]

Try to find a matching route_flags struct in rt and return it, add it if not found.

Parameters:
rf_head pointer to the head of the route flags list, might be changed during insert.
flags user defined flags
mask mask for user defined flags
Returns:
pointer to the route_flags struct on success, NULL on failure.

Definition at line 206 of file cr_rule.c.

References route_flags::flags, route_flags::mask, route_flags::next, NULL, shm_malloc(), and SHM_MEM_ERROR.

Referenced by add_route_to_tree().

int add_route_rule ( struct route_flags rf,
const str prefix,
int  max_targets,
double  prob,
const str rewrite_hostpart,
int  strip,
const str rewrite_local_prefix,
const str rewrite_local_suffix,
int  status,
int  hash_index,
int  backup,
int *  backed_up,
const str comment 
)

Adds a route rule to rf. prefix, rewrite_hostpart, rewrite_local_prefix, rewrite_local_suffix, and comment must not contain NULL pointers.

Parameters:
rf the current route_flags struct
prefix the whole scan prefix
max_targets the number of targets
prob the weight of the rule
rewrite_hostpart the rewrite_host of the rule
strip the strip value of the rule
rewrite_local_prefix the rewrite prefix
rewrite_local_suffix the rewrite suffix
status the status of the rule
hash_index the hash index of the rule
backup indicates if the route is backed up by another. only useful if status==0, if set, it is the hash value of another rule
backed_up an NULL-termintated array of hash indices of the route for which this route is backup
comment a comment for the route rule
Returns:
0 on success, -1 on failure
See also:
add_route_to_tree()

Definition at line 59 of file cr_rule.c.

References route_rule::backed_up, route_rule::backup, route_rule::comment, destroy_route_rule(), route_rule_p_list::hash_index, route_rule::hash_index, route_rule::host, LM_INFO, route_rule::local_prefix, route_rule::local_suffix, route_flags::max_targets, route_rule::next, route_rule_p_list::next, NULL, route_rule::orig_prob, route_rule::prefix, route_rule::prob, route_flags::rule_list, shm_malloc(), SHM_MEM_ERROR, shm_str_dup(), route_rule::status, and route_rule::strip.

Referenced by add_route_to_tree().

void destroy_failure_route_rule ( struct failure_route_rule frr  ) 

Destroys failure route rule frr by freeing all its memory.

Parameters:
frr route rule to be destroyed

Definition at line 400 of file cr_rule.c.

References failure_route_rule::comment, failure_route_rule::host, failure_route_rule::prefix, failure_route_rule::reply_code, _str::s, and shm_free.

Referenced by add_failure_route_rule(), and destroy_failure_route_rule_list().

void destroy_route_flags ( struct route_flags rf  ) 

Destroys route_flags in shared memory by freing all its memory.

Parameters:
rf route_flags struct to be destroyed

Definition at line 251 of file cr_rule.c.

References destroy_route_rule(), route_rule::next, NULL, route_flags::rule_list, route_flags::rules, and shm_free.

Referenced by destroy_route_flags_list().

void destroy_route_rule ( struct route_rule rr  ) 

Destroys route rule rr by freeing all its memory.

Parameters:
rr route rule to be destroyed

Definition at line 166 of file cr_rule.c.

References route_rule::backed_up, route_rule::backup, route_rule::comment, route_rule::host, route_rule::local_prefix, route_rule::local_suffix, route_rule_p_list::next, route_rule::prefix, _str::s, and shm_free.

Referenced by add_route_rule(), destroy_route_flags(), and update_route_data_recursor().

static int failure_rule_prio_cmp ( struct failure_route_rule frr1,
struct failure_route_rule frr2 
) [static]

Compares the priority of two failure route rules.

Parameters:
frr1 first failure rule
frr2 second failure rule
Returns:
0 if frr1 and frr2 have the same priority, -1 if frr1 has higher priority than frr2, 1 if frr1 has lower priority than frr2.
See also:
add_failure_route_to_tree()

Definition at line 277 of file cr_rule.c.

References failure_route_rule::host, _str::len, failure_route_rule::mask, failure_route_rule::reply_code, and _str::s.

Referenced by add_failure_route_rule().

struct route_rule* find_auto_backup ( struct route_flags rf,
struct route_rule rule 
) [read]

struct route_rule* find_rule_by_hash ( struct route_flags rf,
int  hash 
) [read]

struct route_rule* find_rule_by_host ( struct route_flags rf,
str host 
) [read]

int remove_backed_up ( struct route_rule rule  ) 


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