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         LPWRAP_PRI_EVENT_FACNAME       = PRI_EVENT_FACNAME,
  55         LPWRAP_PRI_EVENT_INFO_RECEIVED = PRI_EVENT_INFO_RECEIVED,
  56         LPWRAP_PRI_EVENT_PROCEEDING    = PRI_EVENT_PROCEEDING,
  57         LPWRAP_PRI_EVENT_SETUP_ACK     = PRI_EVENT_SETUP_ACK,
  58         LPWRAP_PRI_EVENT_HANGUP_REQ    = PRI_EVENT_HANGUP_REQ,
  59         LPWRAP_PRI_EVENT_NOTIFY        = PRI_EVENT_NOTIFY,
  60         LPWRAP_PRI_EVENT_PROGRESS      = PRI_EVENT_PROGRESS,
  61         LPWRAP_PRI_EVENT_KEYPAD_DIGIT  = PRI_EVENT_KEYPAD_DIGIT,
  62         LPWRAP_PRI_EVENT_IO_FAIL       = 19,
  63 
  64         /* don't touch */
  65         LPWRAP_PRI_EVENT_MAX
  66 } lpwrap_pri_event_t;
  67 
  68 typedef enum {
  69         LPWRAP_PRI_NETWORK = PRI_NETWORK,
  70         LPWRAP_PRI_CPE = PRI_CPE
  71 } lpwrap_pri_node_t;
  72 
  73 typedef enum {
  74         LPWRAP_PRI_SWITCH_UNKNOWN     = PRI_SWITCH_UNKNOWN,
  75         LPWRAP_PRI_SWITCH_NI2         = PRI_SWITCH_NI2,
  76         LPWRAP_PRI_SWITCH_DMS100      = PRI_SWITCH_DMS100,
  77         LPWRAP_PRI_SWITCH_LUCENT5E    = PRI_SWITCH_LUCENT5E,
  78         LPWRAP_PRI_SWITCH_ATT4ESS     = PRI_SWITCH_ATT4ESS,
  79         LPWRAP_PRI_SWITCH_EUROISDN_E1 = PRI_SWITCH_EUROISDN_E1,
  80         LPWRAP_PRI_SWITCH_EUROISDN_T1 = PRI_SWITCH_EUROISDN_T1,
  81         LPWRAP_PRI_SWITCH_NI1         = PRI_SWITCH_NI1,
  82         LPWRAP_PRI_SWITCH_GR303_EOC   = PRI_SWITCH_GR303_EOC,
  83         LPWRAP_PRI_SWITCH_GR303_TMC   = PRI_SWITCH_GR303_TMC,
  84         LPWRAP_PRI_SWITCH_QSIG        = PRI_SWITCH_QSIG,
  85 
  86         /* don't touch */
  87         LPWRAP_PRI_SWITCH_MAX
  88 } lpwrap_pri_switch_t;
  89 
  90 typedef enum {
  91         LPWRAP_PRI_READY = (1 << 0)
  92 } lpwrap_pri_flag_t;
  93 
  94 struct lpwrap_pri;
  95 typedef int (*event_handler)(struct lpwrap_pri *, lpwrap_pri_event_t, pri_event *);
  96 typedef int (*loop_handler)(struct lpwrap_pri *);
  97 
  98 struct lpwrap_pri {
  99         struct pri *pri;
 100         ftdm_span_t *span;
 101         ftdm_channel_t *dchan;
 102         unsigned int flags;
 103         void *private_info;
 104         event_handler eventmap[LPWRAP_PRI_EVENT_MAX];
 105         loop_handler on_loop;
 106         int errs;
 107 };
 108 
 109 typedef struct lpwrap_pri lpwrap_pri_t;
 110 
 111 struct lpwrap_pri_event_list {
 112         int event_id;
 113         int pri_event;
 114         const char *name;
 115 };
 116 
 117 
 118 
 119 #define LPWRAP_MAP_PRI_EVENT(spri, event, func) spri.eventmap[event] = func;
 120 
 121 const char *lpwrap_pri_event_str(lpwrap_pri_event_t event_id);
 122 int lpwrap_one_loop(struct lpwrap_pri *spri);
 123 int lpwrap_init_pri(struct lpwrap_pri *spri, ftdm_span_t *span, ftdm_channel_t *dchan, int swtype, int node, int debug);
 124 int lpwrap_run_pri(struct lpwrap_pri *spri);
 125 
 126 #endif

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