#include "conf.h"#include "../../mem/mem.h"#include "../../mem/shm_mem.h"#include "../../sr_module.h"#include "../../proxy.h"#include <ctype.h>#include <errno.h>#include <limits.h>#include <string.h>#include <stdlib.h>#include <stdio.h>

Go to the source code of this file.
Data Structures | |
| struct | fwd_setting |
Defines | |
| #define | BUFSIZE 1000 |
Enumerations | |
| enum | { sfidx_request = 0, sfidx_reply, sfilter_cnt } |
Functions | |
| void | conf_destroy (void) |
| Destroy configuration. | |
| int | conf_init (int max_id) |
| Initialize configuration. | |
| struct proxy_l * | conf_needs_forward (struct sip_msg *msg, int id) |
| Checks forwarding is needed. | |
| int | conf_parse_filter (char *settings) |
| Parses a configuration string for the filter Parses a configuration string for switch settings and updates the configuration structure. | |
| int | conf_parse_proxy (char *settings) |
| Parses a configuration string for proxy settings Parses a configuration string for proxy settings and updates the configuration structure. | |
| int | conf_parse_switch (char *settings) |
| Parses configuration string for the switch Parses a configuration string for switch settings and updates the configuration structure. | |
| int | conf_show (struct mi_root *rpl_tree) |
| Output configuration in FIFO format. | |
| int | conf_str2id (char *id_str) |
| Converts string to integer and checks for validity. | |
| static int | conf_str2int (char *s) |
| Converts a string to integer. | |
| static int | filter_methods_contains_request (int id, char *method, int method_len) |
| Checks if method string is in filter_methods. | |
| static void | remove_spaces (char *s) |
| Removes white spaces and new lines from s. | |
| static int | update_filter (int id, char *flist) |
| Updates filter configuration. Updates filter configuration. If filter_methods is not NULL, memory is freed. If filter methods are found, memory for the string is allocated, otherwise filter_methods is set to NULL. | |
| static int | update_proxy (int id, char *host_str, char *port_str) |
| static int | update_switch (int id, char *param_str) |
| Updates switch configuration. | |
Variables | |
| static int | fwd_max_id = 0 |
| static struct fwd_setting * | fwd_settings = NULL |
| static int | sfilter_mask [sfilter_cnt] = { 1, 2 } |
| static char * | sfilter_str [sfilter_cnt] |
| #define BUFSIZE 1000 |
| anonymous enum |
| void conf_destroy | ( | void | ) |
Destroy configuration.
Definition at line 556 of file conf.c.
References fwd_setting::active, free_shm_proxy(), fwd_max_id, id, proxy, and shm_free.
| int conf_init | ( | int | max_id | ) |
Initialize configuration.
| max_id | number of configuration statements |
Definition at line 539 of file conf.c.
References fwd_max_id, NULL, shm_malloc(), and SHM_MEM_ERROR.
Referenced by mod_init().
Checks forwarding is needed.
| msg | the SIP message to be forwarded | |
| id | use configuration with this ID when checking |
Definition at line 508 of file conf.c.
References filter_methods_contains_request(), sip_msg::first_line, NULL, fwd_setting::proxy, msg_start::request, sfidx_reply, sfidx_request, sfilter_mask, SIP_REPLY, SIP_REQUEST, msg_start::type, and msg_start::u.
Referenced by utils_forward().
| int conf_parse_filter | ( | char * | settings | ) |
Parses a configuration string for the filter Parses a configuration string for switch settings and updates the configuration structure.
| settings | The configuration string in the following form: <id>=<filter>[:<filter>]...[,<id>=<filter>[:<filter>]...]... |
Definition at line 398 of file conf.c.
References conf_str2id(), len, LM_ERR, NULL, pkg_free, pkg_malloc, PKG_MEM_ERROR, remove_spaces(), and update_filter().
Referenced by forward_fifo_filter(), and mod_init().
| int conf_parse_proxy | ( | char * | settings | ) |
Parses a configuration string for proxy settings Parses a configuration string for proxy settings and updates the configuration structure.
| settings,: | The configuration string in the following form: <id>=<host>:<port>[,<id>=<host>:<port>]... |
Definition at line 441 of file conf.c.
References conf_str2id(), len, LM_ERR, NULL, pkg_free, pkg_malloc, PKG_MEM_ERROR, remove_spaces(), and update_proxy().
Referenced by forward_fifo_proxy(), and mod_init().
| int conf_parse_switch | ( | char * | settings | ) |
Parses configuration string for the switch Parses a configuration string for switch settings and updates the configuration structure.
| settings | the configuration string in the following form: <id>=<switch>[,<id>=<switch>]... |
Definition at line 298 of file conf.c.
References conf_str2id(), len, LM_ERR, NULL, pkg_free, pkg_malloc, PKG_MEM_ERROR, remove_spaces(), and update_switch().
Referenced by forward_fifo_switch(), and mod_init().
| int conf_show | ( | struct mi_root * | rpl_tree | ) |
Output configuration in FIFO format.
| rpl_tree | FIFO root |
Definition at line 340 of file conf.c.
References fwd_setting::active, addf_mi_node_child(), buf, BUFSIZE, fwd_max_id, id, proxy_l::name, mi_root::node, NULL, proxy_l::port, fwd_setting::proxy, _str::s, sfilter_cnt, sfilter_mask, sfilter_str, and snprintf.
Referenced by forward_fifo_list().
| int conf_str2id | ( | char * | id_str | ) |
Converts string to integer and checks for validity.
Definition at line 121 of file conf.c.
References conf_str2int(), fwd_max_id, and LM_ERR.
Referenced by conf_parse_filter(), conf_parse_proxy(), and conf_parse_switch().
| static int conf_str2int | ( | char * | s | ) | [static] |
Converts a string to integer.
Definition at line 96 of file conf.c.
Referenced by conf_str2id(), and update_proxy().
| static int filter_methods_contains_request | ( | int | id, | |
| char * | method, | |||
| int | method_len | |||
| ) | [static] |
Checks if method string is in filter_methods.
| id | use configuration with this ID when checking | |
| method | method string to be searched for | |
| method_len | length of method string |
Definition at line 486 of file conf.c.
References fwd_setting::filter_methods, and NULL.
Referenced by conf_needs_forward().
| static void remove_spaces | ( | char * | s | ) | [static] |
Removes white spaces and new lines from s.
| s | the string. |
Definition at line 75 of file conf.c.
Referenced by conf_parse_filter(), conf_parse_proxy(), and conf_parse_switch().
| static int update_filter | ( | int | id, | |
| char * | flist | |||
| ) | [static] |
Updates filter configuration. Updates filter configuration. If filter_methods is not NULL, memory is freed. If filter methods are found, memory for the string is allocated, otherwise filter_methods is set to NULL.
| id | update the configuration with this ID. | |
| flist | a list of filter names. |
Definition at line 170 of file conf.c.
References buf, BUFSIZE, fwd_setting::filter_methods, len, LM_ERR, NULL, fwd_setting::sfilter, sfilter_cnt, sfilter_mask, sfilter_str, shm_free, shm_malloc(), SHM_MEM_ERROR, and snprintf.
Referenced by conf_parse_filter().
| static int update_proxy | ( | int | id, | |
| char * | host_str, | |||
| char * | port_str | |||
| ) | [static] |
Updates proxy configuration
| id | update the configuration with this ID. | |
| host_str | the destination host. | |
| port_str | the port number as string. |
Definition at line 240 of file conf.c.
References conf_str2int(), free_shm_proxy(), _str::len, LM_ERR, mk_shm_proxy(), NULL, port, PROTO_UDP, fwd_setting::proxy, proxy, _str::s, shm_free, shm_malloc(), and SHM_MEM_ERROR.
Referenced by conf_parse_proxy().
| static int update_switch | ( | int | id, | |
| char * | param_str | |||
| ) | [static] |
Updates switch configuration.
| id | Update the configuration with this ID. | |
| param_str | can be either "off" or "on". |
Definition at line 140 of file conf.c.
References fwd_setting::active, LM_ERR, and NULL.
Referenced by conf_parse_switch().
int fwd_max_id = 0 [static] |
Definition at line 66 of file conf.c.
Referenced by conf_destroy(), conf_init(), conf_show(), and conf_str2id().
struct fwd_setting* fwd_settings = NULL [static] |
int sfilter_mask[sfilter_cnt] = { 1, 2 } [static] |
special filter masks
Definition at line 48 of file conf.c.
Referenced by conf_needs_forward(), conf_show(), and update_filter().
char* sfilter_str[sfilter_cnt] [static] |
Initial value:
{
"REQUEST",
"REPLY"
}
Definition at line 51 of file conf.c.
Referenced by conf_show(), and update_filter().
1.5.6