lcr_mod.h

Go to the documentation of this file.
00001 /*
00002  * $Id$
00003  *
00004  * Various lcr related constant, types, and external variables
00005  *
00006  * Copyright (C) 2005-2012 Juha Heinanen
00007  *
00008  * This file is part of SIP Router, a free SIP server.
00009  *
00010  * SIP Router is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2 of the License, or
00013  * (at your option) any later version
00014  *
00015  * SIP Router is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  * GNU General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU General Public License 
00021  * along with this program; if not, write to the Free Software 
00022  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00023  *
00024  * History:
00025  * --------
00026  * 2005-02-06: created by jh
00027  */
00028 
00037 #ifndef LCR_MOD_H
00038 #define LCR_MOD_H
00039 
00040 #include <stdio.h>
00041 #include <pcre.h>
00042 #include "../../lib/kmi/mi.h"
00043 #include "../../locking.h"
00044 #include "../../parser/parse_uri.h"
00045 #include "../../ip_addr.h"
00046 
00047 #define MAX_PREFIX_LEN 16
00048 #define MAX_URI_LEN 256
00049 #define MAX_HOST_LEN 64
00050 #define MAX_NO_OF_GWS 128
00051 #define MAX_NAME_LEN 128
00052 #define MAX_TAG_LEN 64
00053 #define MAX_USER_LEN 64
00054 #define MAX_PARAMS_LEN 64
00055 
00056 typedef enum sip_protos uri_transport;
00057 
00058 struct rule_info {
00059     unsigned int rule_id;
00060     char prefix[MAX_PREFIX_LEN];
00061     unsigned short prefix_len;
00062     char from_uri[MAX_URI_LEN + 1];
00063     unsigned short from_uri_len;
00064     pcre *from_uri_re;
00065     char request_uri[MAX_URI_LEN + 1];
00066     unsigned short request_uri_len;
00067     pcre *request_uri_re;
00068     unsigned short stopper;
00069     unsigned int enabled;
00070     struct target *targets;
00071     struct rule_info *next;
00072 };
00073 
00074 struct rule_id_info {
00075     unsigned int rule_id;
00076     struct rule_info *rule_addr;
00077     struct rule_id_info *next;
00078 };
00079 
00080 struct target {
00081     unsigned short gw_index;
00082     unsigned short priority;
00083     unsigned short weight;
00084     struct target *next;
00085 };
00086 
00087 struct instance {
00088     unsigned short instance_id;
00089     struct instance *next;
00090 };
00091 
00092 struct gw_info {
00093     unsigned int gw_id;
00094     char gw_name[MAX_NAME_LEN];
00095     unsigned short gw_name_len;
00096     uri_type scheme;
00097     struct ip_addr ip_addr;
00098     char hostname[MAX_HOST_LEN];
00099     unsigned short hostname_len;
00100     unsigned int port;
00101     uri_transport transport;
00102     char params[MAX_PARAMS_LEN];
00103     unsigned short params_len;
00104     unsigned int strip;
00105     char prefix[MAX_PREFIX_LEN];
00106     unsigned short prefix_len;
00107     char tag[MAX_TAG_LEN];
00108     unsigned short tag_len;
00109     unsigned int flags;
00110     unsigned int defunct_until;
00111 };
00112 
00113 extern unsigned int lcr_rule_hash_size_param;
00114 
00115 extern unsigned int lcr_count_param;
00116 
00117 extern gen_lock_t *reload_lock;
00118 
00119 extern struct gw_info **gw_pt;
00120 extern struct rule_info ***rule_pt;
00121 extern struct rule_id_info **rule_id_hash_table;
00122 
00123 extern int reload_tables();
00124 extern int rpc_defunct_gw(unsigned int, unsigned int, unsigned int);
00125 
00126 #endif /* LCR_MOD_H */