root/src/ftmod/ftmod_sangoma_boost/sangoma_boost_interface.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


   1 /*
   2  * Copyright (c) 2009, Sangoma Technologies
   3  * Moises Silva <moy@sangoma.com>
   4  * All rights reserved.
   5  * 
   6  * Redistribution and use in source and binary forms, with or without
   7  * modification, are permitted provided that the following conditions
   8  * are met:
   9  * 
  10  * * Redistributions of source code must retain the above copyright
  11  * notice, this list of conditions and the following disclaimer.
  12  * 
  13  * * Redistributions in binary form must reproduce the above copyright
  14  * notice, this list of conditions and the following disclaimer in the
  15  * documentation and/or other materials provided with the distribution.
  16  * 
  17  * * Neither the name of the original author; nor the names of any contributors
  18  * may be used to endorse or promote products derived from this software
  19  * without specific prior written permission.
  20  * 
  21  * 
  22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  23  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  25  * A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER
  26  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  27  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  28  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  29  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  30  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  31  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  32  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  33  */
  34 
  35 #ifndef SANGOMA_BOOST_INTERFACE_H
  36 #define SANGOMA_BOOST_INTERFACE_H
  37 
  38 #include "private/ftdm_core.h"
  39 
  40 #ifdef __cplusplus
  41 extern "C" {
  42 #endif
  43 
  44 /*! 
  45   \brief Callback used to notify signaling status changes on a channel
  46   \param ftdmchan The freetdm channel where the signaling status just changed
  47   \param status The new signaling status
  48  */
  49 #define BOOST_SIG_STATUS_CB_ARGS (ftdm_channel_t *ftdmchan, ftdm_signaling_status_t status)
  50 typedef void (*boost_sig_status_cb_func_t) BOOST_SIG_STATUS_CB_ARGS;
  51 #define BOOST_SIG_STATUS_CB_FUNCTION(name) void name BOOST_SIG_STATUS_CB_ARGS
  52 
  53 /*! 
  54   \brief Write a boost msg to a boost endpoint 
  55   \param span The freetdm span where this msg was generated
  56   \param msg The generic message pointer, owned by the caller
  57   \param msglen The length of the provided structure pointed by msg
  58   \return FTDM_SUCCESS or FTDM_FAIL
  59 
  60    The msg buffer is owned by the caller and it should
  61    be either t_sigboost_callstart or t_sigboost_short
  62    the endpoint receiving the msg will first cast to
  63    t_sigboost_short, check the event type, and if needed.
  64  */
  65 #define BOOST_WRITE_MSG_ARGS (ftdm_span_t *span, void *msg, ftdm_size_t msglen)
  66 typedef ftdm_status_t (*boost_write_msg_func_t) BOOST_WRITE_MSG_ARGS;
  67 #define BOOST_WRITE_MSG_FUNCTION(name) ftdm_status_t name BOOST_WRITE_MSG_ARGS
  68 
  69 /*! 
  70   \brief Set the callback to be used by a signaling module to write boost messages
  71   \param callback The callback to be used by the signaling module
  72 
  73    The provided callback will be used for the signaling boost module to notify the
  74    user with boost messages.
  75  */
  76 #define BOOST_SET_WRITE_MSG_CB_ARGS (boost_write_msg_func_t callback)
  77 typedef void (*boost_set_write_msg_cb_func_t) BOOST_SET_WRITE_MSG_CB_ARGS;
  78 #define BOOST_SET_WRITE_MSG_CB_FUNCTION(name) void name BOOST_SET_WRITE_MSG_CB_ARGS
  79 
  80 /*! 
  81   \brief Notify hardware status change
  82   \param ftdmchan The freetdm channel
  83   \param status The hw status 
  84   \return FTDM_SUCCESS or FTDM_FAIL 
  85  */
  86 #define BOOST_ON_HW_LINK_STATUS_CHANGE_ARGS (ftdm_channel_t *ftdmchan, ftdm_channel_hw_link_status_t status)
  87 typedef void (*boost_on_hw_link_status_change_func_t) BOOST_ON_HW_LINK_STATUS_CHANGE_ARGS;
  88 #define BOOST_ON_HW_LINK_STATUS_CHANGE_FUNCTION(name) void name BOOST_ON_HW_LINK_STATUS_CHANGE_ARGS
  89 
  90 /*! 
  91   \brief Set signaling status callback used by the signaling module to report signaling status changes
  92   \param callback The callback to be used by the signaling module
  93 
  94    The provided callback will be used for the signaling boost module to notify the
  95    user with signaling link status changes.
  96  */
  97 #define BOOST_SET_SIG_STATUS_CB_ARGS (boost_sig_status_cb_func_t callback)
  98 typedef void (*boost_set_sig_status_cb_func_t) BOOST_SET_SIG_STATUS_CB_ARGS;
  99 #define BOOST_SET_SIG_STATUS_CB_FUNCTION(name) void name BOOST_SET_SIG_STATUS_CB_ARGS
 100 
 101 /*! 
 102   \brief Get the signaling status on the given channel.
 103   \param ftdmchan The freetdm channel
 104   \param status The status pointer where the current signaling status will be set
 105  */
 106 #define BOOST_GET_CHANNEL_SIG_STATUS_ARGS (ftdm_channel_t *ftdmchan, ftdm_signaling_status_t *status)
 107 typedef ftdm_status_t (*boost_get_channel_sig_status_func_t) BOOST_GET_CHANNEL_SIG_STATUS_ARGS;
 108 #define BOOST_GET_CHANNEL_SIG_STATUS_FUNCTION(name) ftdm_status_t name BOOST_GET_CHANNEL_SIG_STATUS_ARGS
 109 
 110 /*! 
 111   \brief Set the signaling status on the given channel.
 112   \param ftdmchan The freetdm channel
 113   \param status The new status for the channel
 114   \return FTDM_SUCCESS or FTDM_FAIL 
 115  */
 116 #define BOOST_SET_CHANNEL_SIG_STATUS_ARGS (ftdm_channel_t *ftdmchan, ftdm_signaling_status_t status)
 117 typedef ftdm_status_t (*boost_set_channel_sig_status_func_t) BOOST_SET_CHANNEL_SIG_STATUS_ARGS;
 118 #define BOOST_SET_CHANNEL_SIG_STATUS_FUNCTION(name) ftdm_status_t name BOOST_SET_CHANNEL_SIG_STATUS_ARGS
 119 
 120 /*! 
 121   \brief Get the signaling status on the given span.
 122   \param span The freetdm span 
 123   \param status The status pointer where the current signaling status will be set
 124  */
 125 #define BOOST_GET_SPAN_SIG_STATUS_ARGS (ftdm_span_t *span, ftdm_signaling_status_t *status)
 126 typedef ftdm_status_t (*boost_get_span_sig_status_func_t) BOOST_GET_SPAN_SIG_STATUS_ARGS;
 127 #define BOOST_GET_SPAN_SIG_STATUS_FUNCTION(name) ftdm_status_t name BOOST_GET_SPAN_SIG_STATUS_ARGS
 128 
 129 /*! 
 130   \brief Set the signaling status on the given span.
 131   \param ftdmchan The freetdm span
 132   \param status The new status for the span
 133   \return FTDM_SUCCESS or FTDM_FAIL 
 134  */
 135 #define BOOST_SET_SPAN_SIG_STATUS_ARGS (ftdm_span_t *span, ftdm_signaling_status_t status)
 136 typedef ftdm_status_t (*boost_set_span_sig_status_func_t) BOOST_SET_SPAN_SIG_STATUS_ARGS;
 137 #define BOOST_SET_SPAN_SIG_STATUS_FUNCTION(name) ftdm_status_t name BOOST_SET_SPAN_SIG_STATUS_ARGS
 138 
 139 /*! 
 140   \brief Configure the given span signaling
 141   \param span The freetdm span
 142   \param parameters The array of configuration key,value pairs (must be null terminated)
 143   \return FTDM_SUCCESS or FTDM_FAIL 
 144  */
 145 #define BOOST_CONFIGURE_SPAN_ARGS (ftdm_span_t *span, ftdm_conf_parameter_t *parameters) 
 146 typedef ftdm_status_t (*boost_configure_span_func_t) BOOST_CONFIGURE_SPAN_ARGS;
 147 #define BOOST_CONFIGURE_SPAN_FUNCTION(name) ftdm_status_t name BOOST_CONFIGURE_SPAN_ARGS
 148 
 149 /*! 
 150   \brief Start the given span
 151   \param span The freetdm span
 152   \return FTDM_SUCCESS or FTDM_FAIL 
 153  */
 154 #define BOOST_START_SPAN_ARGS (ftdm_span_t *span) 
 155 typedef ftdm_status_t (*boost_start_span_func_t) BOOST_START_SPAN_ARGS;
 156 #define BOOST_START_SPAN_FUNCTION(name) ftdm_status_t name BOOST_START_SPAN_ARGS
 157 
 158 /*! 
 159   \brief Stop the given span
 160   \param span The freetdm span
 161   \return FTDM_SUCCESS or FTDM_FAIL 
 162  */
 163 #define BOOST_STOP_SPAN_ARGS (ftdm_span_t *span) 
 164 typedef ftdm_status_t (*boost_stop_span_func_t) BOOST_START_SPAN_ARGS;
 165 #define BOOST_STOP_SPAN_FUNCTION(name) ftdm_status_t name BOOST_STOP_SPAN_ARGS
 166 
 167 /*! 
 168   \brief Called when the module is being loaded BEFORE calling anything else
 169   \return FTDM_SUCCESS or FTDM_FAIL
 170  */
 171 #define BOOST_ON_LOAD_ARGS (void) 
 172 typedef ftdm_status_t (*boost_on_load_func_t) BOOST_ON_LOAD_ARGS;
 173 #define BOOST_ON_LOAD_FUNCTION(name) ftdm_status_t name BOOST_ON_LOAD_ARGS 
 174 
 175 /*! 
 176   \brief Called when the module is being unloaded, last chance to stop everything!
 177  */
 178 #define BOOST_ON_UNLOAD_ARGS (void) 
 179 typedef ftdm_status_t (*boost_on_unload_func_t) BOOST_ON_UNLOAD_ARGS;
 180 #define BOOST_ON_UNLOAD_FUNCTION(name) ftdm_status_t name BOOST_ON_UNLOAD_ARGS 
 181 
 182 /*!
 183         \brief Called when user wants to execute sigmod api function
 184         \return FTDM_SUCCESS or FTDM_FAIL
 185  */
 186 #define BOOST_API_ARGS (ftdm_stream_handle_t *stream, char *cmd)
 187 typedef ftdm_status_t (*boost_api_func_t) BOOST_API_ARGS;
 188 #define BOOST_API_FUNCTION(name) ftdm_status_t name BOOST_API_ARGS
 189 
 190 
 191 /*! 
 192   \brief The boost signaling module interface 
 193  */
 194 typedef struct boost_sigmod_interface_s {
 195         /*! \brief Module name */
 196         const char *name;
 197         /*! \brief write boost message function */
 198         boost_write_msg_func_t write_msg;       
 199         /*! \brief set the user write boost message function */
 200         boost_set_write_msg_cb_func_t set_write_msg_cb;
 201         /*! \brief set the user signaling status function */
 202         boost_set_sig_status_cb_func_t set_sig_status_cb;
 203         /*! \brief get channel signaling status */
 204         boost_get_channel_sig_status_func_t get_channel_sig_status;
 205         /*! \brief set channel signaling status */
 206         boost_set_channel_sig_status_func_t set_channel_sig_status;
 207         /*! \brief get span signaling status */
 208         boost_get_span_sig_status_func_t get_span_sig_status;
 209         /*! \brief set span signaling status */
 210         boost_set_span_sig_status_func_t set_span_sig_status;
 211         /*! \brief set notify hardware link status change */
 212         boost_on_hw_link_status_change_func_t on_hw_link_status_change;
 213         /*! \brief configure span signaling */
 214         boost_configure_span_func_t configure_span;
 215         /*! \brief start freetdm span */
 216         boost_start_span_func_t start_span;
 217         /*! \brief stop freetdm span */
 218         boost_stop_span_func_t stop_span;
 219         /*! \brief the module was just loaded */
 220         boost_on_load_func_t on_load;
 221         /*! \brief the module is about to be unloaded */
 222         boost_on_unload_func_t on_unload;
 223         /*! \brief module api function */
 224         boost_api_func_t  exec_api;
 225         /*! \brief private pointer for the interface user */
 226         void *pvt;
 227 } boost_sigmod_interface_t;
 228 
 229 #ifdef __cplusplus
 230 } // extern C
 231 #endif
 232 
 233 #define BOOST_INTERFACE_NAME boost_sigmod_interface
 234 #define BOOST_INTERFACE_NAME_STR "boost_sigmod_interface"
 235 /* use this in your sig boost module to declare your interface */
 236 #ifndef WIN32
 237 #define BOOST_INTERFACE boost_sigmod_interface_t BOOST_INTERFACE_NAME
 238 #else
 239 #define BOOST_INTERFACE __declspec(dllexport) boost_sigmod_interface_t BOOST_INTERFACE_NAME
 240 #endif
 241 #endif
 242 
 243 
 244 /* For Emacs:
 245  * Local Variables:
 246  * mode:c
 247  * indent-tabs-mode:t
 248  * tab-width:4
 249  * c-basic-offset:4
 250  * End:
 251  * For VIM:
 252  * vim:set softtabstop=4 shiftwidth=4 tabstop=4:
 253  */
 254 

/* [<][>][^][v][top][bottom][index][help] */