root/src/ftmod/ftmod_libpri/lpwrap_pri.h

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

INCLUDED FROM


   1 /*
   2  * Copyright (c) 2009, Anthony Minessale II
   3  * All rights reserved.
   4  *
   5  * Redistribution and use in source and binary forms, with or without
   6  * modification, are permitted provided that the following conditions
   7  * are met:
   8  *
   9  * * Redistributions of source code must retain the above copyright
  10  * notice, this list of conditions and the following disclaimer.
  11  *
  12  * * Redistributions in binary form must reproduce the above copyright
  13  * notice, this list of conditions and the following disclaimer in the
  14  * documentation and/or other materials provided with the distribution.
  15  *
  16  * * Neither the name of the original author; nor the names of any contributors
  17  * may be used to endorse or promote products derived from this software
  18  * without specific prior written permission.
  19  *
  20  *
  21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  24  * A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER
  25  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  26  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  27  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  28  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  29  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  30  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  31  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32  */
  33 
  34 #ifndef _LPWRAP_PRI_H
  35 #define _LPWRAP_PRI_H
  36 #include <libpri.h>
  37 #include <freetdm.h>
  38 
  39 
  40 #define LPWRAP_MAX_CHAN_PER_SPAN 32
  41 
  42 typedef enum {
  43         LPWRAP_PRI_EVENT_ANY           = 0,
  44         LPWRAP_PRI_EVENT_DCHAN_UP      = PRI_EVENT_DCHAN_UP,
  45         LPWRAP_PRI_EVENT_DCHAN_DOWN    = PRI_EVENT_DCHAN_DOWN,
  46         LPWRAP_PRI_EVENT_RESTART       = PRI_EVENT_RESTART,
  47         LPWRAP_PRI_EVENT_CONFIG_ERR    = PRI_EVENT_CONFIG_ERR,
  48         LPWRAP_PRI_EVENT_RING          = PRI_EVENT_RING,
  49         LPWRAP_PRI_EVENT_HANGUP        = PRI_EVENT_HANGUP,
  50         LPWRAP_PRI_EVENT_RINGING       = PRI_EVENT_RINGING,
  51         LPWRAP_PRI_EVENT_ANSWER        = PRI_EVENT_ANSWER,
  52         LPWRAP_PRI_EVENT_HANGUP_ACK    = PRI_EVENT_HANGUP_ACK,
  53         LPWRAP_PRI_EVENT_RESTART_ACK   = PRI_EVENT_RESTART_ACK,
  54 #ifdef PRI_EVENT_FACILITY
  55         LPWRAP_PRI_EVENT_FACILITY      = PRI_EVENT_FACILITY,
  56 #else
  57         LPWRAP_PRI_EVENT_FACILITY      = PRI_EVENT_FACNAME,
  58 #endif
  59         LPWRAP_PRI_EVENT_INFO_RECEIVED = PRI_EVENT_INFO_RECEIVED,
  60         LPWRAP_PRI_EVENT_PROCEEDING    = PRI_EVENT_PROCEEDING,
  61         LPWRAP_PRI_EVENT_SETUP_ACK     = PRI_EVENT_SETUP_ACK,
  62         LPWRAP_PRI_EVENT_HANGUP_REQ    = PRI_EVENT_HANGUP_REQ,
  63         LPWRAP_PRI_EVENT_NOTIFY        = PRI_EVENT_NOTIFY,
  64         LPWRAP_PRI_EVENT_PROGRESS      = PRI_EVENT_PROGRESS,
  65         LPWRAP_PRI_EVENT_KEYPAD_DIGIT  = PRI_EVENT_KEYPAD_DIGIT,
  66         LPWRAP_PRI_EVENT_IO_FAIL       = 19,
  67 
  68         /* don't touch */
  69         LPWRAP_PRI_EVENT_MAX
  70 } lpwrap_pri_event_t;
  71 
  72 typedef enum {
  73         LPWRAP_PRI_NETWORK = PRI_NETWORK,
  74         LPWRAP_PRI_CPE = PRI_CPE
  75 } lpwrap_pri_node_t;
  76 
  77 typedef enum {
  78         LPWRAP_PRI_SWITCH_UNKNOWN     = PRI_SWITCH_UNKNOWN,
  79         LPWRAP_PRI_SWITCH_NI2         = PRI_SWITCH_NI2,
  80         LPWRAP_PRI_SWITCH_DMS100      = PRI_SWITCH_DMS100,
  81         LPWRAP_PRI_SWITCH_LUCENT5E    = PRI_SWITCH_LUCENT5E,
  82         LPWRAP_PRI_SWITCH_ATT4ESS     = PRI_SWITCH_ATT4ESS,
  83         LPWRAP_PRI_SWITCH_EUROISDN_E1 = PRI_SWITCH_EUROISDN_E1,
  84         LPWRAP_PRI_SWITCH_EUROISDN_T1 = PRI_SWITCH_EUROISDN_T1,
  85         LPWRAP_PRI_SWITCH_NI1         = PRI_SWITCH_NI1,
  86         LPWRAP_PRI_SWITCH_GR303_EOC   = PRI_SWITCH_GR303_EOC,
  87         LPWRAP_PRI_SWITCH_GR303_TMC   = PRI_SWITCH_GR303_TMC,
  88         LPWRAP_PRI_SWITCH_QSIG        = PRI_SWITCH_QSIG,
  89 
  90         /* don't touch */
  91         LPWRAP_PRI_SWITCH_MAX
  92 } lpwrap_pri_switch_t;
  93 
  94 typedef enum {
  95         LPWRAP_PRI_READY = (1 << 0)
  96 } lpwrap_pri_flag_t;
  97 
  98 struct lpwrap_pri;
  99 typedef int (*event_handler)(struct lpwrap_pri *, lpwrap_pri_event_t, pri_event *);
 100 typedef int (*loop_handler)(struct lpwrap_pri *);
 101 
 102 struct lpwrap_pri {
 103         struct pri *pri;
 104         ftdm_span_t *span;
 105         ftdm_channel_t *dchan;
 106         unsigned int flags;
 107         void *private_info;
 108         event_handler eventmap[LPWRAP_PRI_EVENT_MAX];
 109         loop_handler on_loop;
 110         int errs;
 111 };
 112 
 113 typedef struct lpwrap_pri lpwrap_pri_t;
 114 
 115 struct lpwrap_pri_event_list {
 116         int event_id;
 117         int pri_event;
 118         const char *name;
 119 };
 120 
 121 
 122 
 123 #define LPWRAP_MAP_PRI_EVENT(spri, event, func) spri.eventmap[event] = func;
 124 
 125 const char *lpwrap_pri_event_str(lpwrap_pri_event_t event_id);
 126 int lpwrap_one_loop(struct lpwrap_pri *spri);
 127 int lpwrap_init_pri(struct lpwrap_pri *spri, ftdm_span_t *span, ftdm_channel_t *dchan, int swtype, int node, int debug);
 128 int lpwrap_init_bri(struct lpwrap_pri *spri, ftdm_span_t *span, ftdm_channel_t *dchan, int swtype, int node, int ptp, int debug);
 129 int lpwrap_run_pri(struct lpwrap_pri *spri);
 130 #define lpwrap_run_bri(x)       lpwrap_run_pri(x)
 131 
 132 #endif

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