isdn_lib_intern.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. #ifndef ISDN_LIB_INTERN
  2. #define ISDN_LIB_INTERN
  3. #include <mISDNuser/mISDNlib.h>
  4. #include <mISDNuser/isdn_net.h>
  5. #include <mISDNuser/l3dss1.h>
  6. #include <mISDNuser/net_l3.h>
  7. #include <pthread.h>
  8. #include "isdn_lib.h"
  9. #ifndef MISDNUSER_VERSION_CODE
  10. #error "You need a newer version of mISDNuser ..."
  11. #elif MISDNUSER_VERSION_CODE < MISDNUSER_VERSION(1, 0, 3)
  12. #error "You need a newer version of mISDNuser ..."
  13. #endif
  14. #define QI_ELEMENT(a) a.off
  15. #ifndef mISDNUSER_HEAD_SIZE
  16. #define mISDNUSER_HEAD_SIZE (sizeof(mISDNuser_head_t))
  17. /*#define mISDNUSER_HEAD_SIZE (sizeof(mISDN_head_t))*/
  18. #endif
  19. #if 0
  20. ibuffer_t *astbuf; /* Not used */
  21. ibuffer_t *misdnbuf; /* Not used */
  22. #endif
  23. struct send_lock {
  24. pthread_mutex_t lock;
  25. };
  26. struct isdn_msg {
  27. unsigned long misdn_msg;
  28. enum event_e event;
  29. void (*msg_parser)(struct isdn_msg *msgs, msg_t *msg, struct misdn_bchannel *bc, int nt);
  30. msg_t *(*msg_builder)(struct isdn_msg *msgs, struct misdn_bchannel *bc, int nt);
  31. char *info;
  32. } ;
  33. /* for isdn_msg_parser.c */
  34. msg_t *create_l3msg(int prim, int mt, int dinfo , int size, int nt);
  35. #if defined(AST_MISDN_ENHANCEMENTS)
  36. /* Max call-completion REGISTER signaling links per stack/port */
  37. #define MISDN_MAX_REGISTER_LINKS MAX_BCHANS
  38. #else
  39. /* Max call-completion REGISTER signaling links per stack/port */
  40. #define MISDN_MAX_REGISTER_LINKS 0
  41. #endif /* defined(AST_MISDN_ENHANCEMENTS) */
  42. #define MAXPROCS 0x100
  43. struct misdn_stack {
  44. /** is first element because &nst equals &mISDNlist **/
  45. net_stack_t nst;
  46. manager_t mgr;
  47. pthread_mutex_t nstlock;
  48. /*! \brief Stack struct critical section lock. */
  49. pthread_mutex_t st_lock;
  50. /*! \brief D Channel mISDN driver stack ID (Parent stack ID) */
  51. int d_stid;
  52. /*! /brief Number of B channels supported by this port */
  53. int b_num;
  54. /*! \brief B Channel mISDN driver stack IDs (Child stack IDs) */
  55. int b_stids[MAX_BCHANS + 1];
  56. /*! \brief TRUE if Point-To-Point(PTP) (Point-To-Multipoint(PTMP) otherwise) */
  57. int ptp;
  58. /*! \brief Number of consecutive times PTP Layer 2 declared down */
  59. int l2upcnt;
  60. int l2_id; /* Not used */
  61. /*! \brief Lower layer mISDN ID (addr) (Layer 1/3) */
  62. int lower_id;
  63. /*! \brief Upper layer mISDN ID (addr) (Layer 2/4) */
  64. int upper_id;
  65. /*! \brief TRUE if port is blocked */
  66. int blocked;
  67. /*! \brief TRUE if Layer 2 is UP */
  68. int l2link;
  69. /*! \brief TRUE if Layer 1 is UP */
  70. int l1link;
  71. /*! \brief TRUE if restart has been sent to the other side after stack startup */
  72. int restart_sent;
  73. /*! \brief mISDN device handle returned by mISDN_open() */
  74. int midev;
  75. /*! \brief TRUE if NT side of protocol (TE otherwise) */
  76. int nt;
  77. /*! \brief TRUE if ISDN-PRI (ISDN-BRI otherwise) */
  78. int pri;
  79. /*! \brief CR Process ID allocation table. TRUE if ID allocated */
  80. int procids[MAXPROCS];
  81. /*! \brief Queue of Event messages to send to mISDN */
  82. msg_queue_t downqueue;
  83. msg_queue_t upqueue; /* No code puts anything on this queue */
  84. int busy; /* Not used */
  85. /*! \brief Logical Layer 1 port associated with this stack */
  86. int port;
  87. /*!
  88. * \brief B Channel record pool array
  89. * (Must be dimensioned the same as struct misdn_stack.channels[])
  90. */
  91. struct misdn_bchannel bc[MAX_BCHANS + 1 + MISDN_MAX_REGISTER_LINKS];
  92. /*!
  93. * \brief Array of B channels in use (a[0] = B1). TRUE if B channel in use.
  94. * (Must be dimensioned the same as struct misdn_stack.bc[])
  95. */
  96. char channels[MAX_BCHANS + 1 + MISDN_MAX_REGISTER_LINKS];
  97. /*! \brief List of held channels */
  98. struct misdn_bchannel *holding;
  99. /*! \brief Next stack in the list of stacks */
  100. struct misdn_stack *next;
  101. };
  102. struct misdn_stack* get_stack_by_bc(struct misdn_bchannel *bc);
  103. int isdn_msg_get_index(struct isdn_msg msgs[], msg_t *frm, int nt);
  104. enum event_e isdn_msg_get_event(struct isdn_msg msgs[], msg_t *frm, int nt);
  105. int isdn_msg_parse_event(struct isdn_msg msgs[], msg_t *frm, struct misdn_bchannel *bc, int nt);
  106. char * isdn_get_info(struct isdn_msg msgs[], enum event_e event, int nt);
  107. msg_t * isdn_msg_build_event(struct isdn_msg msgs[], struct misdn_bchannel *bc, enum event_e event, int nt);
  108. int isdn_msg_get_index_by_event(struct isdn_msg msgs[], enum event_e event, int nt);
  109. char * isdn_msg_get_info(struct isdn_msg msgs[], msg_t *msg, int nt);
  110. #endif