00001 /* 00002 * $Id: dlg_profile.h 5786 2009-04-02 19:52:49Z henningw $ 00003 * 00004 * Copyright (C) 2008 Voice System SRL 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 * History: 00023 * -------- 00024 * 2008-04-20 initial version (bogdan) 00025 * 00026 */ 00027 00028 00029 00030 #ifndef _DIALOG_DLG_PROFILE_H_ 00031 #define _DIALOG_DLG_PROFILE_H_ 00032 00033 #include "../../parser/msg_parser.h" 00034 #include "../../locking.h" 00035 #include "../../str.h" 00036 00037 00038 /*! 00039 * \file 00040 * \brief Profile related functions for the dialog module 00041 * \ingroup dialog 00042 * Module: \ref dialog 00043 */ 00044 00045 00046 /*! dialog profile hash list */ 00047 struct dlg_profile_hash { 00048 str value; /*!< hash value */ 00049 struct dlg_cell *dlg; /*!< dialog cell */ 00050 struct dlg_profile_hash *next; 00051 struct dlg_profile_hash *prev; 00052 unsigned int hash; /*!< position in the hash table */ 00053 }; 00054 00055 00056 /*! list with links to dialog profiles */ 00057 struct dlg_profile_link { 00058 struct dlg_profile_hash hash_linker; 00059 struct dlg_profile_link *next; 00060 struct dlg_profile_table *profile; 00061 }; 00062 00063 00064 /*! dialog profile entry */ 00065 struct dlg_profile_entry { 00066 struct dlg_profile_hash *first; 00067 unsigned int content; /*!< content of the entry */ 00068 }; 00069 00070 00071 /*! dialog profile table */ 00072 struct dlg_profile_table { 00073 str name; /*!< name of the dialog profile */ 00074 unsigned int size; /*!< size of the dialog profile */ 00075 unsigned int has_value; /*!< 0 for profiles without value, otherwise it has a value */ 00076 gen_lock_t lock; /*! lock for concurrent access */ 00077 struct dlg_profile_entry *entries; 00078 struct dlg_profile_table *next; 00079 }; 00080 00081 00082 /*! 00083 * \brief Add profile definitions to the global list 00084 * \see new_dlg_profile 00085 * \param profiles profile name 00086 * \param has_value set to 0 for a profile without value, otherwise it has a value 00087 * \return 0 on success, -1 on failure 00088 */ 00089 int add_profile_definitions( char* profiles, unsigned int has_value); 00090 00091 00092 /*! 00093 * \brief Destroy the global dialog profile list 00094 */ 00095 void destroy_dlg_profiles(void); 00096 00097 00098 /*! 00099 * \brief Search a dialog profile in the global list 00100 * \note Linear search, this won't have the best performance for huge profile lists 00101 * \param name searched dialog profile 00102 * \return pointer to the profile on success, NULL otherwise 00103 */ 00104 struct dlg_profile_table* search_dlg_profile(str *name); 00105 00106 00107 /*! 00108 * \brief Cleanup a profile 00109 * \param msg SIP message 00110 * \param unused 00111 * \return 1 00112 */ 00113 int profile_cleanup( struct sip_msg *msg, void *param ); 00114 00115 00116 /*! 00117 * \brief Destroy dialog linkers 00118 * \param linker dialog linker 00119 */ 00120 void destroy_linkers(struct dlg_profile_link *linker); 00121 00122 00123 /*! 00124 * \brief Set the global variables to the current dialog 00125 * \param msg SIP message 00126 * \param dlg dialog cell 00127 */ 00128 void set_current_dialog(struct sip_msg *msg, struct dlg_cell *dlg); 00129 00130 00131 /*! 00132 * \brief Set the dialog profile 00133 * \param msg SIP message 00134 * \param value value 00135 * \param profile dialog profile table 00136 * \return 0 on success, -1 on failure 00137 */ 00138 int set_dlg_profile(struct sip_msg *msg, str *value, 00139 struct dlg_profile_table *profile); 00140 00141 00142 /*! 00143 * \brief Unset a dialog profile 00144 * \param msg SIP message 00145 * \param value value 00146 * \param profile dialog profile table 00147 * \return 1 on success, -1 on failure 00148 */ 00149 int unset_dlg_profile(struct sip_msg *msg, str *value, 00150 struct dlg_profile_table *profile); 00151 00152 00153 /*! 00154 * \brief Check if a dialog belongs to a profile 00155 * \param msg SIP message 00156 * \param profile dialog profile table 00157 * \param value value 00158 * \return 1 on success, -1 on failure 00159 */ 00160 int is_dlg_in_profile(struct sip_msg *msg, struct dlg_profile_table *profile, 00161 str *value); 00162 00163 00164 /*! 00165 * \brief Get the size of a profile 00166 * \param profile evaluated profile 00167 * \param value value 00168 * \return the profile size 00169 */ 00170 unsigned int get_profile_size(struct dlg_profile_table *profile, str *value); 00171 00172 00173 /*! 00174 * \brief Output a profile via MI interface 00175 * \param cmd_tree MI command tree 00176 * \param param MI parameter 00177 * \return MI root output on success, NULL on failure 00178 */ 00179 struct mi_root * mi_get_profile(struct mi_root *cmd_tree, void *param ); 00180 00181 00182 /*! 00183 * \brief List the profiles via MI interface 00184 * \param cmd_tree MI command tree 00185 * \param param unused 00186 * \return MI root output on success, NULL on failure 00187 */ 00188 struct mi_root * mi_profile_list(struct mi_root *cmd_tree, void *param ); 00189 00190 #endif
1.5.6