00001 /* 00002 * $Id: cr_fifo.h 5129 2008-10-24 08:28:01Z henningw $ 00003 * 00004 * Copyright (C) 2007-2008 1&1 Internet AG 00005 * 00006 * This file is part of Kamailio, a free SIP server. 00007 * 00008 * Kamailio is free software; you can redistribute it and/or modify 00009 * it under the terms of the GNU General Public License as published by 00010 * the Free Software Foundation; either version 2 of the License, or 00011 * (at your option) any later version 00012 * 00013 * Kamailio is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU General Public License 00019 * along with this program; if not, write to the Free Software 00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00021 */ 00022 00023 /** 00024 * \file cr_fifo.h 00025 * \brief Functions for modifying routing data via fifo commands. 00026 * \ingroup carrierroute 00027 * - Module; \ref carrierroute 00028 */ 00029 00030 #ifndef CR_FIFO_H 00031 #define CR_FIFO_H 00032 00033 #include "../../mi/mi.h" 00034 00035 extern int fifo_err; 00036 00037 #define E_MISC -1 00038 #define E_NOOPT -2 00039 #define E_WRONGOPT -3 00040 #define E_NOMEM -4 00041 #define E_RESET -5 00042 #define E_NOAUTOBACKUP -6 00043 #define E_NOHASHBACKUP -7 00044 #define E_NOHOSTBACKUP -8 00045 #define E_ADDBACKUP -9 00046 #define E_DELBACKUP -10 00047 #define E_LOADCONF -11 00048 #define E_SAVECONF -12 00049 #define E_INVALIDOPT -13 00050 #define E_MISSOPT -14 00051 #define E_RULEFIXUP -15 00052 #define E_NOUPDATE -16 00053 #define E_HELP -17 00054 00055 #define FIFO_ERR(e) (fifo_err = e) 00056 00057 /** 00058 * @struct fifo_opt 00059 * Holds values and command type when a command was passed to fifo 00060 */ 00061 typedef struct fifo_opt { 00062 unsigned int cmd; /*!< Command type passed to FIFO */ 00063 unsigned int opts; /*!< Options used */ 00064 str domain; /*!< the routing domain */ 00065 str prefix; /*!< the scan prefix */ 00066 double prob; /*!< the weight of the route rule */ 00067 str host; /*!< the hostname or address */ 00068 int strip; /*!< the number of digits to be stripped off */ 00069 str new_host; /*!< the new host when a host is going to be replaced */ 00070 str rewrite_prefix; /*!< the rewrite prefix */ 00071 str rewrite_suffix; /*!< the rewrite suffix */ 00072 int hash_index; /*!< the hash index */ 00073 int status; /*!< the status */ 00074 } 00075 fifo_opt_t; 00076 00077 #define FBUF_SIZE 2048 00078 00079 #define OPT_ADD 0 00080 #define OPT_REMOVE 1 00081 #define OPT_REPLACE 2 00082 #define OPT_DEACTIVATE 3 00083 #define OPT_ACTIVATE 4 00084 00085 #define OPT_MANDATORY 0 00086 #define OPT_OPTIONAL 1 00087 #define OPT_INVALID 2 00088 00089 #define OPT_PREFIX 0 00090 #define OPT_DOMAIN 1 00091 #define OPT_HOST 2 00092 #define OPT_NEW_TARGET 3 00093 #define OPT_PROB 4 00094 #define OPT_R_PREFIX 5 00095 #define OPT_R_SUFFIX 6 00096 #define OPT_HASH_INDEX 7 00097 #define OPT_STRIP 8 00098 00099 /** 00100 * Flags for options to determine which options are used 00101 */ 00102 #define O_PREFIX 1 00103 #define O_DOMAIN (1 << 1) 00104 #define O_HOST (1 << 2) 00105 #define O_NEW_TARGET (1 << 3) 00106 #define O_PROB (1 << 4) 00107 #define O_R_PREFIX (1 << 5) 00108 #define O_R_SUFFIX (1 << 6) 00109 #define O_H_INDEX (1 << 7) 00110 #define O_STRIP (1 << 8) 00111 00112 /** 00113 * Constants define option characters 00114 */ 00115 #define OPT_PREFIX_CHR 'p' 00116 #define OPT_DOMAIN_CHR 'd' 00117 #define OPT_HOST_CHR 'h' 00118 #define OPT_NEW_TARGET_CHR 't' 00119 #define OPT_PROB_CHR 'w' 00120 #define OPT_R_PREFIX_CHR 'P' 00121 #define OPT_R_SUFFIX_CHR 'S' 00122 #define OPT_HASH_INDEX_CHR 'i' 00123 #define OPT_STRIP_CHR 's' 00124 #define OPT_HELP_CHR '?' 00125 00126 #define OPT_STAR "*" 00127 00128 struct mi_root* reload_fifo (struct mi_root* cmd_tree, void *param); 00129 00130 struct mi_root* dump_fifo (struct mi_root* cmd_tree, void *param); 00131 00132 struct mi_root* replace_host (struct mi_root* cmd_tree, void *param); 00133 00134 struct mi_root* deactivate_host (struct mi_root* cmd_tree, void *param); 00135 00136 struct mi_root* activate_host (struct mi_root* cmd_tree, void *param); 00137 00138 struct mi_root* add_host (struct mi_root* cmd_tree, void *param); 00139 00140 struct mi_root* delete_host (struct mi_root* cmd_tree, void * param); 00141 00142 #endif
1.5.6