Tue Aug 20 16:34:34 2013

Asterisk developer's documentation


isdn_lib_intern.h

Go to the documentation of this file.
00001 #ifndef ISDN_LIB_INTERN
00002 #define ISDN_LIB_INTERN
00003 
00004 
00005 #include <mISDNuser/mISDNlib.h>
00006 #include <mISDNuser/isdn_net.h>
00007 #include <mISDNuser/l3dss1.h>
00008 #include <mISDNuser/net_l3.h>
00009 
00010 #include <pthread.h>
00011 
00012 #include "isdn_lib.h"
00013 
00014 #ifndef MISDNUSER_VERSION_CODE
00015 #error "You need a newer version of mISDNuser ..."
00016 #elif MISDNUSER_VERSION_CODE < MISDNUSER_VERSION(1, 0, 3)
00017 #error "You need a newer version of mISDNuser ..."
00018 #endif
00019 
00020 
00021 #define QI_ELEMENT(a) a.off
00022 
00023 
00024 #ifndef mISDNUSER_HEAD_SIZE
00025 
00026 #define mISDNUSER_HEAD_SIZE (sizeof(mISDNuser_head_t))
00027 /*#define mISDNUSER_HEAD_SIZE (sizeof(mISDN_head_t))*/
00028 #endif
00029 
00030 
00031 #if 0
00032 ibuffer_t *astbuf;      /* Not used */
00033 ibuffer_t *misdnbuf; /* Not used */
00034 #endif
00035 
00036 struct send_lock {
00037    pthread_mutex_t lock;
00038 };
00039 
00040 
00041 struct isdn_msg {
00042    unsigned long misdn_msg;
00043 
00044    enum event_e event;
00045 
00046    void (*msg_parser)(struct isdn_msg *msgs, msg_t *msg, struct misdn_bchannel *bc, int nt);
00047    msg_t *(*msg_builder)(struct isdn_msg *msgs, struct misdn_bchannel *bc, int nt);
00048    char *info;
00049 } ;
00050 
00051 /* for isdn_msg_parser.c */
00052 msg_t *create_l3msg(int prim, int mt, int dinfo , int size, int nt);
00053 
00054 #if defined(AST_MISDN_ENHANCEMENTS)
00055 /* Max call-completion REGISTER signaling links per stack/port */
00056 #define MISDN_MAX_REGISTER_LINKS MAX_BCHANS
00057 #else
00058 /* Max call-completion REGISTER signaling links per stack/port */
00059 #define MISDN_MAX_REGISTER_LINKS 0
00060 #endif   /* defined(AST_MISDN_ENHANCEMENTS) */
00061 
00062 #define MAXPROCS 0x100
00063 
00064 struct misdn_stack {
00065    /** is first element because &nst equals &mISDNlist **/
00066    net_stack_t nst;
00067    manager_t mgr;
00068    pthread_mutex_t nstlock;
00069 
00070    /*! \brief Stack struct critical section lock. */
00071    pthread_mutex_t st_lock;
00072 
00073    /*! \brief D Channel mISDN driver stack ID (Parent stack ID) */
00074    int d_stid;
00075 
00076    /*! /brief Number of B channels supported by this port */
00077    int b_num;
00078 
00079    /*! \brief B Channel mISDN driver stack IDs (Child stack IDs) */
00080    int b_stids[MAX_BCHANS + 1];
00081 
00082    /*! \brief TRUE if Point-To-Point(PTP) (Point-To-Multipoint(PTMP) otherwise) */
00083    int ptp;
00084 
00085    /*! \brief Number of consecutive times PTP Layer 2 declared down */
00086    int l2upcnt;
00087 
00088    int l2_id;  /* Not used */
00089 
00090    /*! \brief Lower layer mISDN ID (addr) (Layer 1/3) */
00091    int lower_id;
00092 
00093    /*! \brief Upper layer mISDN ID (addr) (Layer 2/4) */
00094    int upper_id;
00095 
00096    /*! \brief TRUE if port is blocked */
00097    int blocked;
00098 
00099    /*! \brief TRUE if Layer 2 is UP */
00100    int l2link;
00101 
00102    /*! \brief TRUE if Layer 1 is UP */
00103    int l1link;
00104 
00105    /*! \brief TRUE if restart has been sent to the other side after stack startup */
00106    int restart_sent;
00107 
00108    /*! \brief mISDN device handle returned by mISDN_open() */
00109    int midev;
00110 
00111    /*! \brief TRUE if NT side of protocol (TE otherwise) */
00112    int nt;
00113 
00114    /*! \brief TRUE if ISDN-PRI (ISDN-BRI otherwise) */
00115    int pri;
00116 
00117    /*! \brief CR Process ID allocation table.  TRUE if ID allocated */
00118    int procids[MAXPROCS];
00119 
00120    /*! \brief Queue of Event messages to send to mISDN */
00121    msg_queue_t downqueue;
00122    msg_queue_t upqueue; /* No code puts anything on this queue */
00123    int busy;   /* Not used */
00124 
00125    /*! \brief Logical Layer 1 port associated with this stack */
00126    int port;
00127 
00128    /*!
00129     * \brief B Channel record pool array
00130     * (Must be dimensioned the same as struct misdn_stack.channels[])
00131     */
00132    struct misdn_bchannel bc[MAX_BCHANS + 1 + MISDN_MAX_REGISTER_LINKS];
00133 
00134    /*!
00135     * \brief Array of B channels in use (a[0] = B1).  TRUE if B channel in use.
00136     * (Must be dimensioned the same as struct misdn_stack.bc[])
00137     */
00138    char channels[MAX_BCHANS + 1 + MISDN_MAX_REGISTER_LINKS];
00139 
00140    /*! \brief List of held channels */
00141    struct misdn_bchannel *holding;
00142 
00143    /*! \brief Next stack in the list of stacks */
00144    struct misdn_stack *next;
00145 };
00146 
00147 
00148 struct misdn_stack* get_stack_by_bc(struct misdn_bchannel *bc);
00149 
00150 int isdn_msg_get_index(struct isdn_msg msgs[], msg_t *frm, int nt);
00151 enum event_e isdn_msg_get_event(struct isdn_msg msgs[], msg_t *frm, int nt);
00152 int isdn_msg_parse_event(struct isdn_msg msgs[], msg_t *frm, struct misdn_bchannel *bc, int nt);
00153 char * isdn_get_info(struct isdn_msg msgs[], enum event_e event, int nt);
00154 msg_t * isdn_msg_build_event(struct isdn_msg msgs[], struct misdn_bchannel *bc, enum event_e event, int nt);
00155 int isdn_msg_get_index_by_event(struct isdn_msg msgs[], enum event_e event, int nt);
00156 char * isdn_msg_get_info(struct isdn_msg msgs[], msg_t *msg, int nt);
00157 
00158 
00159 #endif

Generated on 20 Aug 2013 for Asterisk - The Open Source Telephony Project by  doxygen 1.6.1