isdnloop.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /* $Id: isdnloop.h,v 1.5.6.3 2001/09/23 22:24:56 kai Exp $
  2. *
  3. * Loopback lowlevel module for testing of linklevel.
  4. *
  5. * Copyright 1997 by Fritz Elfert (fritz@isdn4linux.de)
  6. *
  7. * This software may be used and distributed according to the terms
  8. * of the GNU General Public License, incorporated herein by reference.
  9. *
  10. */
  11. #ifndef isdnloop_h
  12. #define isdnloop_h
  13. #define ISDNLOOP_IOCTL_DEBUGVAR 0
  14. #define ISDNLOOP_IOCTL_ADDCARD 1
  15. #define ISDNLOOP_IOCTL_LEASEDCFG 2
  16. #define ISDNLOOP_IOCTL_STARTUP 3
  17. /* Struct for adding new cards */
  18. typedef struct isdnloop_cdef {
  19. char id1[10];
  20. } isdnloop_cdef;
  21. /* Struct for configuring cards */
  22. typedef struct isdnloop_sdef {
  23. int ptype;
  24. char num[3][20];
  25. } isdnloop_sdef;
  26. #if defined(__KERNEL__) || defined(__DEBUGVAR__)
  27. #ifdef __KERNEL__
  28. /* Kernel includes */
  29. #include <linux/errno.h>
  30. #include <linux/fs.h>
  31. #include <linux/major.h>
  32. #include <asm/io.h>
  33. #include <linux/kernel.h>
  34. #include <linux/signal.h>
  35. #include <linux/slab.h>
  36. #include <linux/mm.h>
  37. #include <linux/mman.h>
  38. #include <linux/ioport.h>
  39. #include <linux/timer.h>
  40. #include <linux/wait.h>
  41. #include <linux/isdnif.h>
  42. #endif /* __KERNEL__ */
  43. #define ISDNLOOP_FLAGS_B1ACTIVE 1 /* B-Channel-1 is open */
  44. #define ISDNLOOP_FLAGS_B2ACTIVE 2 /* B-Channel-2 is open */
  45. #define ISDNLOOP_FLAGS_RUNNING 4 /* Cards driver activated */
  46. #define ISDNLOOP_FLAGS_RBTIMER 8 /* scheduling of B-Channel-poll */
  47. #define ISDNLOOP_TIMER_BCREAD 1 /* B-Channel poll-cycle */
  48. #define ISDNLOOP_TIMER_DCREAD (HZ/2) /* D-Channel poll-cycle */
  49. #define ISDNLOOP_TIMER_ALERTWAIT (10 * HZ) /* Alert timeout */
  50. #define ISDNLOOP_MAX_SQUEUE 65536 /* Max. outstanding send-data */
  51. #define ISDNLOOP_BCH 2 /* channels per card */
  52. /*
  53. * Per card driver data
  54. */
  55. typedef struct isdnloop_card {
  56. struct isdnloop_card *next; /* Pointer to next device struct */
  57. struct isdnloop_card
  58. *rcard[ISDNLOOP_BCH]; /* Pointer to 'remote' card */
  59. int rch[ISDNLOOP_BCH]; /* 'remote' channel */
  60. int myid; /* Driver-Nr. assigned by linklevel */
  61. int leased; /* Flag: This Adapter is connected */
  62. /* to a leased line */
  63. int sil[ISDNLOOP_BCH]; /* SI's to listen for */
  64. char eazlist[ISDNLOOP_BCH][11];
  65. /* EAZ's to listen for */
  66. char s0num[3][20]; /* 1TR6 base-number or MSN's */
  67. unsigned short flags; /* Statusflags */
  68. int ptype; /* Protocol type (1TR6 or Euro) */
  69. struct timer_list st_timer; /* Timer for Status-Polls */
  70. struct timer_list rb_timer; /* Timer for B-Channel-Polls */
  71. struct timer_list
  72. c_timer[ISDNLOOP_BCH]; /* Timer for Alerting */
  73. int l2_proto[ISDNLOOP_BCH]; /* Current layer-2-protocol */
  74. isdn_if interface; /* Interface to upper layer */
  75. int iptr; /* Index to imsg-buffer */
  76. char imsg[60]; /* Internal buf for status-parsing */
  77. int optr; /* Index to omsg-buffer */
  78. char omsg[60]; /* Internal buf for cmd-parsing */
  79. char msg_buf[2048]; /* Buffer for status-messages */
  80. char *msg_buf_write; /* Writepointer for statusbuffer */
  81. char *msg_buf_read; /* Readpointer for statusbuffer */
  82. char *msg_buf_end; /* Pointer to end of statusbuffer */
  83. int sndcount[ISDNLOOP_BCH]; /* Byte-counters for B-Ch.-send */
  84. struct sk_buff_head
  85. bqueue[ISDNLOOP_BCH]; /* B-Channel queues */
  86. struct sk_buff_head dqueue; /* D-Channel queue */
  87. spinlock_t isdnloop_lock;
  88. } isdnloop_card;
  89. /*
  90. * Main driver data
  91. */
  92. #ifdef __KERNEL__
  93. static isdnloop_card *cards = (isdnloop_card *) 0;
  94. #endif /* __KERNEL__ */
  95. /* Utility-Macros */
  96. #define CID (card->interface.id)
  97. #endif /* defined(__KERNEL__) || defined(__DEBUGVAR__) */
  98. #endif /* isdnloop_h */