1 /* 2 * Various lcr related constant, types, and external variables 3 * 4 * Copyright (C) 2005-2014 Juha Heinanen 5 * 6 * This file is part of Kamailio, a free SIP server. 7 * 8 * Kamailio is free software; you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License as published by 10 * the Free Software Foundation; either version 2 of the License, or 11 * (at your option) any later version 12 * 13 * Kamailio is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; if not, write to the Free Software 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 * 22 */ 23 24 /*! 25 * \file 26 * \brief Kamailio lcr :: Various LCR related constant, types, and external variables 27 * \ingroup lcr 28 * Module: \ref lcr 29 */ 30 31 32 #ifndef LCR_MOD_H 33 #define LCR_MOD_H 34 35 #include <stdio.h> 36 #include <pcre.h> 37 #include "../../core/locking.h" 38 #include "../../core/parser/parse_uri.h" 39 #include "../../core/ip_addr.h" 40 41 #define MAX_PREFIX_LEN 16 42 #define MAX_URI_LEN 256 43 #define MAX_HOST_LEN 64 44 #define MAX_NO_OF_GWS 128 45 #define MAX_NAME_LEN 128 46 #define MAX_TAG_LEN 64 47 #define MAX_USER_LEN 64 48 #define MAX_PARAMS_LEN 64 49 #define MAX_NO_OF_REPLY_CODES 15 50 #define MAX_MT_TVALUE_LEN 128 51 52 typedef enum sip_protos uri_transport; 53 54 struct rule_info 55 { 56 unsigned int rule_id; 57 char prefix[MAX_PREFIX_LEN]; 58 unsigned short prefix_len; 59 char from_uri[MAX_URI_LEN + 1]; 60 unsigned short from_uri_len; 61 char mt_tvalue[MAX_MT_TVALUE_LEN + 1]; 62 unsigned short mt_tvalue_len; 63 pcre *from_uri_re; 64 char request_uri[MAX_URI_LEN + 1]; 65 unsigned short request_uri_len; 66 pcre *request_uri_re; 67 unsigned short stopper; 68 unsigned int enabled; 69 struct target *targets; 70 struct rule_info *next; 71 }; 72 73 struct rule_id_info 74 { 75 unsigned int rule_id; 76 struct rule_info *rule_addr; 77 struct rule_id_info *next; 78 }; 79 80 struct matched_gw_info 81 { 82 unsigned short gw_index; 83 unsigned int rule_id; 84 unsigned short prefix_len; 85 unsigned short priority; 86 unsigned int weight; 87 unsigned short duplicate; 88 }; 89 90 struct target 91 { 92 unsigned short gw_index; 93 unsigned short priority; 94 unsigned short weight; 95 struct target *next; 96 }; 97 98 struct instance 99 { 100 unsigned short instance_id; 101 struct instance *next; 102 }; 103 104 /* gw states */ 105 /* if state > GW_INACTIVE has not yet reached failure threshold */ 106 #define GW_ACTIVE 0 107 #define GW_PINGING 1 108 #define GW_INACTIVE 2 109 110 struct gw_info 111 { 112 unsigned int gw_id; 113 char gw_name[MAX_NAME_LEN]; 114 unsigned short gw_name_len; 115 char scheme[5]; 116 unsigned short scheme_len; 117 struct ip_addr ip_addr; 118 char hostname[MAX_HOST_LEN]; 119 unsigned short hostname_len; 120 unsigned int port; 121 uri_transport transport_code; 122 char transport[15]; 123 unsigned int transport_len; 124 char params[MAX_PARAMS_LEN]; 125 unsigned short params_len; 126 unsigned int strip; 127 char prefix[MAX_PREFIX_LEN]; 128 unsigned short prefix_len; 129 char tag[MAX_TAG_LEN]; 130 unsigned short tag_len; 131 unsigned int flags; 132 unsigned short state; 133 char uri[MAX_URI_LEN]; 134 unsigned short uri_len; 135 unsigned int defunct_until; 136 }; 137 138 extern unsigned int lcr_rule_hash_size_param; 139 140 extern unsigned int lcr_count_param; 141 142 extern gen_lock_t *reload_lock; 143 144 extern struct gw_info **gw_pt; 145 extern struct rule_info ***rule_pt; 146 extern struct rule_id_info **rule_id_hash_table; 147 148 extern int load_gws_dummy(int lcr_id, str *ruri_user, str *from_uri, 149 str *request_uri, unsigned int *gw_indexes); 150 extern int reload_tables(); 151 extern int rpc_defunct_gw(unsigned int, unsigned int, unsigned int); 152 153 #endif /* LCR_MOD_H */ 154