isdn.h 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623
  1. /* $Id: isdn.h,v 1.125.2.3 2004/02/10 01:07:14 keil Exp $
  2. *
  3. * Main header for the Linux ISDN subsystem (linklevel).
  4. *
  5. * Copyright 1994,95,96 by Fritz Elfert (fritz@isdn4linux.de)
  6. * Copyright 1995,96 by Thinking Objects Software GmbH Wuerzburg
  7. * Copyright 1995,96 by Michael Hipp (Michael.Hipp@student.uni-tuebingen.de)
  8. *
  9. * This software may be used and distributed according to the terms
  10. * of the GNU General Public License, incorporated herein by reference.
  11. *
  12. */
  13. #ifndef __ISDN_H__
  14. #define __ISDN_H__
  15. #include <linux/ioctl.h>
  16. #define ISDN_MAX_DRIVERS 32
  17. #define ISDN_MAX_CHANNELS 64
  18. /* New ioctl-codes */
  19. #define IIOCNETAIF _IO('I',1)
  20. #define IIOCNETDIF _IO('I',2)
  21. #define IIOCNETSCF _IO('I',3)
  22. #define IIOCNETGCF _IO('I',4)
  23. #define IIOCNETANM _IO('I',5)
  24. #define IIOCNETDNM _IO('I',6)
  25. #define IIOCNETGNM _IO('I',7)
  26. #define IIOCGETSET _IO('I',8) /* no longer supported */
  27. #define IIOCSETSET _IO('I',9) /* no longer supported */
  28. #define IIOCSETVER _IO('I',10)
  29. #define IIOCNETHUP _IO('I',11)
  30. #define IIOCSETGST _IO('I',12)
  31. #define IIOCSETBRJ _IO('I',13)
  32. #define IIOCSIGPRF _IO('I',14)
  33. #define IIOCGETPRF _IO('I',15)
  34. #define IIOCSETPRF _IO('I',16)
  35. #define IIOCGETMAP _IO('I',17)
  36. #define IIOCSETMAP _IO('I',18)
  37. #define IIOCNETASL _IO('I',19)
  38. #define IIOCNETDIL _IO('I',20)
  39. #define IIOCGETCPS _IO('I',21)
  40. #define IIOCGETDVR _IO('I',22)
  41. #define IIOCNETLCR _IO('I',23) /* dwabc ioctl for LCR from isdnlog */
  42. #define IIOCNETDWRSET _IO('I',24) /* dwabc ioctl to reset abc-values to default on a net-interface */
  43. #define IIOCNETALN _IO('I',32)
  44. #define IIOCNETDLN _IO('I',33)
  45. #define IIOCNETGPN _IO('I',34)
  46. #define IIOCDBGVAR _IO('I',127)
  47. #define IIOCDRVCTL _IO('I',128)
  48. /* cisco hdlck device private ioctls */
  49. #define SIOCGKEEPPERIOD (SIOCDEVPRIVATE + 0)
  50. #define SIOCSKEEPPERIOD (SIOCDEVPRIVATE + 1)
  51. #define SIOCGDEBSERINT (SIOCDEVPRIVATE + 2)
  52. #define SIOCSDEBSERINT (SIOCDEVPRIVATE + 3)
  53. /* Packet encapsulations for net-interfaces */
  54. #define ISDN_NET_ENCAP_ETHER 0
  55. #define ISDN_NET_ENCAP_RAWIP 1
  56. #define ISDN_NET_ENCAP_IPTYP 2
  57. #define ISDN_NET_ENCAP_CISCOHDLC 3 /* Without SLARP and keepalive */
  58. #define ISDN_NET_ENCAP_SYNCPPP 4
  59. #define ISDN_NET_ENCAP_UIHDLC 5
  60. #define ISDN_NET_ENCAP_CISCOHDLCK 6 /* With SLARP and keepalive */
  61. #define ISDN_NET_ENCAP_X25IFACE 7 /* Documentation/networking/x25-iface.txt */
  62. #define ISDN_NET_ENCAP_MAX_ENCAP ISDN_NET_ENCAP_X25IFACE
  63. /* Facility which currently uses an ISDN-channel */
  64. #define ISDN_USAGE_NONE 0
  65. #define ISDN_USAGE_RAW 1
  66. #define ISDN_USAGE_MODEM 2
  67. #define ISDN_USAGE_NET 3
  68. #define ISDN_USAGE_VOICE 4
  69. #define ISDN_USAGE_FAX 5
  70. #define ISDN_USAGE_MASK 7 /* Mask to get plain usage */
  71. #define ISDN_USAGE_DISABLED 32 /* This bit is set, if channel is disabled */
  72. #define ISDN_USAGE_EXCLUSIVE 64 /* This bit is set, if channel is exclusive */
  73. #define ISDN_USAGE_OUTGOING 128 /* This bit is set, if channel is outgoing */
  74. #define ISDN_MODEM_NUMREG 24 /* Number of Modem-Registers */
  75. #define ISDN_LMSNLEN 255 /* Length of tty's Listen-MSN string */
  76. #define ISDN_CMSGLEN 50 /* Length of CONNECT-Message to add for Modem */
  77. #define ISDN_MSNLEN 32
  78. #define NET_DV 0x06 /* Data version for isdn_net_ioctl_cfg */
  79. #define TTY_DV 0x06 /* Data version for iprofd etc. */
  80. #define INF_DV 0x01 /* Data version for /dev/isdninfo */
  81. typedef struct {
  82. char drvid[25];
  83. unsigned long arg;
  84. } isdn_ioctl_struct;
  85. typedef struct {
  86. char name[10];
  87. char phone[ISDN_MSNLEN];
  88. int outgoing;
  89. } isdn_net_ioctl_phone;
  90. typedef struct {
  91. char name[10]; /* Name of interface */
  92. char master[10]; /* Name of Master for Bundling */
  93. char slave[10]; /* Name of Slave for Bundling */
  94. char eaz[256]; /* EAZ/MSN */
  95. char drvid[25]; /* DriverId for Bindings */
  96. int onhtime; /* Hangup-Timeout */
  97. int charge; /* Charge-Units */
  98. int l2_proto; /* Layer-2 protocol */
  99. int l3_proto; /* Layer-3 protocol */
  100. int p_encap; /* Encapsulation */
  101. int exclusive; /* Channel, if bound exclusive */
  102. int dialmax; /* Dial Retry-Counter */
  103. int slavedelay; /* Delay until slave starts up */
  104. int cbdelay; /* Delay before Callback */
  105. int chargehup; /* Flag: Charge-Hangup */
  106. int ihup; /* Flag: Hangup-Timeout on incoming line */
  107. int secure; /* Flag: Secure */
  108. int callback; /* Flag: Callback */
  109. int cbhup; /* Flag: Reject Call before Callback */
  110. int pppbind; /* ippp device for bindings */
  111. int chargeint; /* Use fixed charge interval length */
  112. int triggercps; /* BogoCPS needed for triggering slave */
  113. int dialtimeout; /* Dial-Timeout */
  114. int dialwait; /* Time to wait after failed dial */
  115. int dialmode; /* Flag: off / on / auto */
  116. } isdn_net_ioctl_cfg;
  117. #define ISDN_NET_DIALMODE_MASK 0xC0 /* bits for status */
  118. #define ISDN_NET_DM_OFF 0x00 /* this interface is stopped */
  119. #define ISDN_NET_DM_MANUAL 0x40 /* this interface is on (manual) */
  120. #define ISDN_NET_DM_AUTO 0x80 /* this interface is autodial */
  121. #define ISDN_NET_DIALMODE(x) ((&(x))->flags & ISDN_NET_DIALMODE_MASK)
  122. #ifdef __KERNEL__
  123. #include <linux/errno.h>
  124. #include <linux/fs.h>
  125. #include <linux/major.h>
  126. #include <asm/io.h>
  127. #include <linux/kernel.h>
  128. #include <linux/signal.h>
  129. #include <linux/slab.h>
  130. #include <linux/timer.h>
  131. #include <linux/wait.h>
  132. #include <linux/tty.h>
  133. #include <linux/tty_flip.h>
  134. #include <linux/serial_reg.h>
  135. #include <linux/fcntl.h>
  136. #include <linux/types.h>
  137. #include <linux/interrupt.h>
  138. #include <linux/ip.h>
  139. #include <linux/in.h>
  140. #include <linux/netdevice.h>
  141. #include <linux/etherdevice.h>
  142. #include <linux/skbuff.h>
  143. #include <linux/tcp.h>
  144. #include <linux/mutex.h>
  145. #define ISDN_TTY_MAJOR 43
  146. #define ISDN_TTYAUX_MAJOR 44
  147. #define ISDN_MAJOR 45
  148. /* The minor-devicenumbers for Channel 0 and 1 are used as arguments for
  149. * physical Channel-Mapping, so they MUST NOT be changed without changing
  150. * the correspondent code in isdn.c
  151. */
  152. #define ISDN_MINOR_B 0
  153. #define ISDN_MINOR_BMAX (ISDN_MAX_CHANNELS-1)
  154. #define ISDN_MINOR_CTRL 64
  155. #define ISDN_MINOR_CTRLMAX (64 + (ISDN_MAX_CHANNELS-1))
  156. #define ISDN_MINOR_PPP 128
  157. #define ISDN_MINOR_PPPMAX (128 + (ISDN_MAX_CHANNELS-1))
  158. #define ISDN_MINOR_STATUS 255
  159. #ifdef CONFIG_ISDN_PPP
  160. #ifdef CONFIG_ISDN_PPP_VJ
  161. # include <net/slhc_vj.h>
  162. #endif
  163. #include <linux/ppp_defs.h>
  164. #include <linux/ppp-ioctl.h>
  165. #include <linux/isdn_ppp.h>
  166. #endif
  167. #ifdef CONFIG_ISDN_X25
  168. # include <linux/concap.h>
  169. #endif
  170. #include <linux/isdnif.h>
  171. #define ISDN_DRVIOCTL_MASK 0x7f /* Mask for Device-ioctl */
  172. /* Until now unused */
  173. #define ISDN_SERVICE_VOICE 1
  174. #define ISDN_SERVICE_AB 1<<1
  175. #define ISDN_SERVICE_X21 1<<2
  176. #define ISDN_SERVICE_G4 1<<3
  177. #define ISDN_SERVICE_BTX 1<<4
  178. #define ISDN_SERVICE_DFUE 1<<5
  179. #define ISDN_SERVICE_X25 1<<6
  180. #define ISDN_SERVICE_TTX 1<<7
  181. #define ISDN_SERVICE_MIXED 1<<8
  182. #define ISDN_SERVICE_FW 1<<9
  183. #define ISDN_SERVICE_GTEL 1<<10
  184. #define ISDN_SERVICE_BTXN 1<<11
  185. #define ISDN_SERVICE_BTEL 1<<12
  186. /* Macros checking plain usage */
  187. #define USG_NONE(x) ((x & ISDN_USAGE_MASK)==ISDN_USAGE_NONE)
  188. #define USG_RAW(x) ((x & ISDN_USAGE_MASK)==ISDN_USAGE_RAW)
  189. #define USG_MODEM(x) ((x & ISDN_USAGE_MASK)==ISDN_USAGE_MODEM)
  190. #define USG_VOICE(x) ((x & ISDN_USAGE_MASK)==ISDN_USAGE_VOICE)
  191. #define USG_NET(x) ((x & ISDN_USAGE_MASK)==ISDN_USAGE_NET)
  192. #define USG_FAX(x) ((x & ISDN_USAGE_MASK)==ISDN_USAGE_FAX)
  193. #define USG_OUTGOING(x) ((x & ISDN_USAGE_OUTGOING)==ISDN_USAGE_OUTGOING)
  194. #define USG_MODEMORVOICE(x) (((x & ISDN_USAGE_MASK)==ISDN_USAGE_MODEM) || \
  195. ((x & ISDN_USAGE_MASK)==ISDN_USAGE_VOICE) )
  196. /* Timer-delays and scheduling-flags */
  197. #define ISDN_TIMER_RES 4 /* Main Timer-Resolution */
  198. #define ISDN_TIMER_02SEC (HZ/ISDN_TIMER_RES/5) /* Slow-Timer1 .2 sec */
  199. #define ISDN_TIMER_1SEC (HZ/ISDN_TIMER_RES) /* Slow-Timer2 1 sec */
  200. #define ISDN_TIMER_RINGING 5 /* tty RINGs = ISDN_TIMER_1SEC * this factor */
  201. #define ISDN_TIMER_KEEPINT 10 /* Cisco-Keepalive = ISDN_TIMER_1SEC * this factor */
  202. #define ISDN_TIMER_MODEMREAD 1
  203. #define ISDN_TIMER_MODEMPLUS 2
  204. #define ISDN_TIMER_MODEMRING 4
  205. #define ISDN_TIMER_MODEMXMIT 8
  206. #define ISDN_TIMER_NETDIAL 16
  207. #define ISDN_TIMER_NETHANGUP 32
  208. #define ISDN_TIMER_CARRIER 256 /* Wait for Carrier */
  209. #define ISDN_TIMER_FAST (ISDN_TIMER_MODEMREAD | ISDN_TIMER_MODEMPLUS | \
  210. ISDN_TIMER_MODEMXMIT)
  211. #define ISDN_TIMER_SLOW (ISDN_TIMER_MODEMRING | ISDN_TIMER_NETHANGUP | \
  212. ISDN_TIMER_NETDIAL | ISDN_TIMER_CARRIER)
  213. /* Timeout-Values for isdn_net_dial() */
  214. #define ISDN_TIMER_DTIMEOUT10 (10*HZ/(ISDN_TIMER_02SEC*(ISDN_TIMER_RES+1)))
  215. #define ISDN_TIMER_DTIMEOUT15 (15*HZ/(ISDN_TIMER_02SEC*(ISDN_TIMER_RES+1)))
  216. #define ISDN_TIMER_DTIMEOUT60 (60*HZ/(ISDN_TIMER_02SEC*(ISDN_TIMER_RES+1)))
  217. /* GLOBAL_FLAGS */
  218. #define ISDN_GLOBAL_STOPPED 1
  219. /*=================== Start of ip-over-ISDN stuff =========================*/
  220. /* Feature- and status-flags for a net-interface */
  221. #define ISDN_NET_CONNECTED 0x01 /* Bound to ISDN-Channel */
  222. #define ISDN_NET_SECURE 0x02 /* Accept calls from phonelist only */
  223. #define ISDN_NET_CALLBACK 0x04 /* activate callback */
  224. #define ISDN_NET_CBHUP 0x08 /* hangup before callback */
  225. #define ISDN_NET_CBOUT 0x10 /* remote machine does callback */
  226. #define ISDN_NET_MAGIC 0x49344C02 /* for paranoia-checking */
  227. /* Phone-list-element */
  228. typedef struct {
  229. void *next;
  230. char num[ISDN_MSNLEN];
  231. } isdn_net_phone;
  232. /*
  233. Principles when extending structures for generic encapsulation protocol
  234. ("concap") support:
  235. - Stuff which is hardware specific (here i4l-specific) goes in
  236. the netdev -> local structure (here: isdn_net_local)
  237. - Stuff which is encapsulation protocol specific goes in the structure
  238. which holds the linux device structure (here: isdn_net_device)
  239. */
  240. /* Local interface-data */
  241. typedef struct isdn_net_local_s {
  242. ulong magic;
  243. struct net_device_stats stats; /* Ethernet Statistics */
  244. int isdn_device; /* Index to isdn-device */
  245. int isdn_channel; /* Index to isdn-channel */
  246. int ppp_slot; /* PPPD device slot number */
  247. int pre_device; /* Preselected isdn-device */
  248. int pre_channel; /* Preselected isdn-channel */
  249. int exclusive; /* If non-zero idx to reserved chan.*/
  250. int flags; /* Connection-flags */
  251. int dialretry; /* Counter for Dialout-retries */
  252. int dialmax; /* Max. Number of Dial-retries */
  253. int cbdelay; /* Delay before Callback starts */
  254. int dtimer; /* Timeout-counter for dialing */
  255. char msn[ISDN_MSNLEN]; /* MSNs/EAZs for this interface */
  256. u_char cbhup; /* Flag: Reject Call before Callback*/
  257. u_char dialstate; /* State for dialing */
  258. u_char p_encap; /* Packet encapsulation */
  259. /* 0 = Ethernet over ISDN */
  260. /* 1 = RAW-IP */
  261. /* 2 = IP with type field */
  262. u_char l2_proto; /* Layer-2-protocol */
  263. /* See ISDN_PROTO_L2..-constants in */
  264. /* isdnif.h */
  265. /* 0 = X75/LAPB with I-Frames */
  266. /* 1 = X75/LAPB with UI-Frames */
  267. /* 2 = X75/LAPB with BUI-Frames */
  268. /* 3 = HDLC */
  269. u_char l3_proto; /* Layer-3-protocol */
  270. /* See ISDN_PROTO_L3..-constants in */
  271. /* isdnif.h */
  272. /* 0 = Transparent */
  273. int huptimer; /* Timeout-counter for auto-hangup */
  274. int charge; /* Counter for charging units */
  275. ulong chargetime; /* Timer for Charging info */
  276. int hupflags; /* Flags for charge-unit-hangup: */
  277. /* bit0: chargeint is invalid */
  278. /* bit1: Getting charge-interval */
  279. /* bit2: Do charge-unit-hangup */
  280. /* bit3: Do hangup even on incoming */
  281. int outgoing; /* Flag: outgoing call */
  282. int onhtime; /* Time to keep link up */
  283. int chargeint; /* Interval between charge-infos */
  284. int onum; /* Flag: at least 1 outgoing number */
  285. int cps; /* current speed of this interface */
  286. int transcount; /* byte-counter for cps-calculation */
  287. int sqfull; /* Flag: netdev-queue overloaded */
  288. ulong sqfull_stamp; /* Start-Time of overload */
  289. ulong slavedelay; /* Dynamic bundling delaytime */
  290. int triggercps; /* BogoCPS needed for trigger slave */
  291. isdn_net_phone *phone[2]; /* List of remote-phonenumbers */
  292. /* phone[0] = Incoming Numbers */
  293. /* phone[1] = Outgoing Numbers */
  294. isdn_net_phone *dial; /* Pointer to dialed number */
  295. struct net_device *master; /* Ptr to Master device for slaves */
  296. struct net_device *slave; /* Ptr to Slave device for masters */
  297. struct isdn_net_local_s *next; /* Ptr to next link in bundle */
  298. struct isdn_net_local_s *last; /* Ptr to last link in bundle */
  299. struct isdn_net_dev_s *netdev; /* Ptr to netdev */
  300. struct sk_buff_head super_tx_queue; /* List of supervisory frames to */
  301. /* be transmitted asap */
  302. atomic_t frame_cnt; /* number of frames currently */
  303. /* queued in HL driver */
  304. /* Ptr to orig. hard_header_cache */
  305. spinlock_t xmit_lock; /* used to protect the xmit path of */
  306. /* a particular channel (including */
  307. /* the frame_cnt */
  308. int pppbind; /* ippp device for bindings */
  309. int dialtimeout; /* How long shall we try on dialing? (jiffies) */
  310. int dialwait; /* How long shall we wait after failed attempt? (jiffies) */
  311. ulong dialstarted; /* jiffies of first dialing-attempt */
  312. ulong dialwait_timer; /* jiffies of earliest next dialing-attempt */
  313. int huptimeout; /* How long will the connection be up? (seconds) */
  314. #ifdef CONFIG_ISDN_X25
  315. struct concap_device_ops *dops; /* callbacks used by encapsulator */
  316. #endif
  317. /* use an own struct for that in later versions */
  318. ulong cisco_myseq; /* Local keepalive seq. for Cisco */
  319. ulong cisco_mineseen; /* returned keepalive seq. from remote */
  320. ulong cisco_yourseq; /* Remote keepalive seq. for Cisco */
  321. int cisco_keepalive_period; /* keepalive period */
  322. ulong cisco_last_slarp_in; /* jiffie of last keepalive packet we received */
  323. char cisco_line_state; /* state of line according to keepalive packets */
  324. char cisco_debserint; /* debugging flag of cisco hdlc with slarp */
  325. struct timer_list cisco_timer;
  326. struct work_struct tqueue;
  327. } isdn_net_local;
  328. /* the interface itself */
  329. typedef struct isdn_net_dev_s {
  330. isdn_net_local *local;
  331. isdn_net_local *queue; /* circular list of all bundled
  332. channels, which are currently
  333. online */
  334. spinlock_t queue_lock; /* lock to protect queue */
  335. void *next; /* Pointer to next isdn-interface */
  336. struct net_device *dev; /* interface to upper levels */
  337. #ifdef CONFIG_ISDN_PPP
  338. ippp_bundle * pb; /* pointer to the common bundle structure
  339. * with the per-bundle data */
  340. #endif
  341. #ifdef CONFIG_ISDN_X25
  342. struct concap_proto *cprot; /* connection oriented encapsulation protocol */
  343. #endif
  344. } isdn_net_dev;
  345. /*===================== End of ip-over-ISDN stuff ===========================*/
  346. /*======================= Start of ISDN-tty stuff ===========================*/
  347. #define ISDN_ASYNC_MAGIC 0x49344C01 /* for paranoia-checking */
  348. #define ISDN_ASYNC_INITIALIZED 0x80000000 /* port was initialized */
  349. #define ISDN_ASYNC_CALLOUT_ACTIVE 0x40000000 /* Call out device active */
  350. #define ISDN_ASYNC_NORMAL_ACTIVE 0x20000000 /* Normal device active */
  351. #define ISDN_ASYNC_CLOSING 0x08000000 /* Serial port is closing */
  352. #define ISDN_ASYNC_CTS_FLOW 0x04000000 /* Do CTS flow control */
  353. #define ISDN_ASYNC_CHECK_CD 0x02000000 /* i.e., CLOCAL */
  354. #define ISDN_ASYNC_HUP_NOTIFY 0x0001 /* Notify tty on hangups/closes */
  355. #define ISDN_ASYNC_SESSION_LOCKOUT 0x0100 /* Lock cua opens on session */
  356. #define ISDN_ASYNC_PGRP_LOCKOUT 0x0200 /* Lock cua opens on pgrp */
  357. #define ISDN_ASYNC_CALLOUT_NOHUP 0x0400 /* No hangup for cui */
  358. #define ISDN_ASYNC_SPLIT_TERMIOS 0x0008 /* Sep. termios for dialin/out */
  359. #define ISDN_SERIAL_XMIT_SIZE 1024 /* Default bufsize for write */
  360. #define ISDN_SERIAL_XMIT_MAX 4000 /* Maximum bufsize for write */
  361. #define ISDN_SERIAL_TYPE_NORMAL 1
  362. #define ISDN_SERIAL_TYPE_CALLOUT 2
  363. #ifdef CONFIG_ISDN_AUDIO
  364. /* For using sk_buffs with audio we need some private variables
  365. * within each sk_buff. For this purpose, we declare a struct here,
  366. * and put it always at the private skb->cb data array. A few macros help
  367. * accessing the variables.
  368. */
  369. typedef struct _isdn_audio_data {
  370. unsigned short dle_count;
  371. unsigned char lock;
  372. } isdn_audio_data_t;
  373. #define ISDN_AUDIO_SKB_DLECOUNT(skb) (((isdn_audio_data_t *)&skb->cb[0])->dle_count)
  374. #define ISDN_AUDIO_SKB_LOCK(skb) (((isdn_audio_data_t *)&skb->cb[0])->lock)
  375. #endif
  376. /* Private data of AT-command-interpreter */
  377. typedef struct atemu {
  378. u_char profile[ISDN_MODEM_NUMREG]; /* Modem-Regs. Profile 0 */
  379. u_char mdmreg[ISDN_MODEM_NUMREG]; /* Modem-Registers */
  380. char pmsn[ISDN_MSNLEN]; /* EAZ/MSNs Profile 0 */
  381. char msn[ISDN_MSNLEN]; /* EAZ/MSN */
  382. char plmsn[ISDN_LMSNLEN]; /* Listening MSNs Profile 0 */
  383. char lmsn[ISDN_LMSNLEN]; /* Listening MSNs */
  384. char cpn[ISDN_MSNLEN]; /* CalledPartyNumber on incoming call */
  385. char connmsg[ISDN_CMSGLEN]; /* CONNECT-Msg from HL-Driver */
  386. #ifdef CONFIG_ISDN_AUDIO
  387. u_char vpar[10]; /* Voice-parameters */
  388. int lastDLE; /* Flag for voice-coding: DLE seen */
  389. #endif
  390. int mdmcmdl; /* Length of Modem-Commandbuffer */
  391. int pluscount; /* Counter for +++ sequence */
  392. u_long lastplus; /* Timestamp of last + */
  393. int carrierwait; /* Seconds of carrier waiting */
  394. char mdmcmd[255]; /* Modem-Commandbuffer */
  395. unsigned int charge; /* Charge units of current connection */
  396. } atemu;
  397. /* Private data (similar to async_struct in <linux/serial.h>) */
  398. typedef struct modem_info {
  399. int magic;
  400. struct module *owner;
  401. int flags; /* defined in tty.h */
  402. int x_char; /* xon/xoff character */
  403. int mcr; /* Modem control register */
  404. int msr; /* Modem status register */
  405. int lsr; /* Line status register */
  406. int line;
  407. int count; /* # of fd on device */
  408. int blocked_open; /* # of blocked opens */
  409. long session; /* Session of opening process */
  410. long pgrp; /* pgrp of opening process */
  411. int online; /* 1 = B-Channel is up, drop data */
  412. /* 2 = B-Channel is up, deliver d.*/
  413. int dialing; /* Dial in progress or ATA */
  414. int rcvsched; /* Receive needs schedule */
  415. int isdn_driver; /* Index to isdn-driver */
  416. int isdn_channel; /* Index to isdn-channel */
  417. int drv_index; /* Index to dev->usage */
  418. int ncarrier; /* Flag: schedule NO CARRIER */
  419. unsigned char last_cause[8]; /* Last cause message */
  420. unsigned char last_num[ISDN_MSNLEN];
  421. /* Last phone-number */
  422. unsigned char last_l2; /* Last layer-2 protocol */
  423. unsigned char last_si; /* Last service */
  424. unsigned char last_lhup; /* Last hangup local? */
  425. unsigned char last_dir; /* Last direction (in or out) */
  426. struct timer_list nc_timer; /* Timer for delayed NO CARRIER */
  427. int send_outstanding;/* # of outstanding send-requests */
  428. int xmit_size; /* max. # of chars in xmit_buf */
  429. int xmit_count; /* # of chars in xmit_buf */
  430. unsigned char *xmit_buf; /* transmit buffer */
  431. struct sk_buff_head xmit_queue; /* transmit queue */
  432. atomic_t xmit_lock; /* Semaphore for isdn_tty_write */
  433. #ifdef CONFIG_ISDN_AUDIO
  434. int vonline; /* Voice-channel status */
  435. /* Bit 0 = recording */
  436. /* Bit 1 = playback */
  437. /* Bit 2 = playback, DLE-ETX seen */
  438. struct sk_buff_head dtmf_queue; /* queue for dtmf results */
  439. void *adpcms; /* state for adpcm decompression */
  440. void *adpcmr; /* state for adpcm compression */
  441. void *dtmf_state; /* state for dtmf decoder */
  442. void *silence_state; /* state for silence detection */
  443. #endif
  444. #ifdef CONFIG_ISDN_TTY_FAX
  445. struct T30_s *fax; /* T30 Fax Group 3 data/interface */
  446. int faxonline; /* Fax-channel status */
  447. #endif
  448. struct tty_struct *tty; /* Pointer to corresponding tty */
  449. atemu emu; /* AT-emulator data */
  450. struct ktermios normal_termios; /* For saving termios structs */
  451. struct ktermios callout_termios;
  452. wait_queue_head_t open_wait, close_wait;
  453. spinlock_t readlock;
  454. } modem_info;
  455. #define ISDN_MODEM_WINSIZE 8
  456. /* Description of one ISDN-tty */
  457. typedef struct _isdn_modem {
  458. int refcount; /* Number of opens */
  459. struct tty_driver *tty_modem; /* tty-device */
  460. struct tty_struct *modem_table[ISDN_MAX_CHANNELS]; /* ?? copied from Orig */
  461. struct ktermios *modem_termios[ISDN_MAX_CHANNELS];
  462. struct ktermios *modem_termios_locked[ISDN_MAX_CHANNELS];
  463. modem_info info[ISDN_MAX_CHANNELS]; /* Private data */
  464. } isdn_modem_t;
  465. /*======================= End of ISDN-tty stuff ============================*/
  466. /*======================== Start of V.110 stuff ============================*/
  467. #define V110_BUFSIZE 1024
  468. typedef struct {
  469. int nbytes; /* 1 Matrixbyte -> nbytes in stream */
  470. int nbits; /* Number of used bits in streambyte */
  471. unsigned char key; /* Bitmask in stream eg. 11 (nbits=2) */
  472. int decodelen; /* Amount of data in decodebuf */
  473. int SyncInit; /* Number of sync frames to send */
  474. unsigned char *OnlineFrame; /* Precalculated V110 idle frame */
  475. unsigned char *OfflineFrame; /* Precalculated V110 sync Frame */
  476. int framelen; /* Length of frames */
  477. int skbuser; /* Number of unacked userdata skbs */
  478. int skbidle; /* Number of unacked idle/sync skbs */
  479. int introducer; /* Local vars for decoder */
  480. int dbit;
  481. unsigned char b;
  482. int skbres; /* space to reserve in outgoing skb */
  483. int maxsize; /* maxbufsize of lowlevel driver */
  484. unsigned char *encodebuf; /* temporary buffer for encoding */
  485. unsigned char decodebuf[V110_BUFSIZE]; /* incomplete V110 matrices */
  486. } isdn_v110_stream;
  487. /*========================= End of V.110 stuff =============================*/
  488. /*======================= Start of general stuff ===========================*/
  489. typedef struct {
  490. char *next;
  491. char *private;
  492. } infostruct;
  493. #define DRV_FLAG_RUNNING 1
  494. #define DRV_FLAG_REJBUS 2
  495. #define DRV_FLAG_LOADED 4
  496. /* Description of hardware-level-driver */
  497. typedef struct _isdn_driver {
  498. ulong online; /* Channel-Online flags */
  499. ulong flags; /* Misc driver Flags */
  500. int locks; /* Number of locks for this driver */
  501. int channels; /* Number of channels */
  502. wait_queue_head_t st_waitq; /* Wait-Queue for status-read's */
  503. int maxbufsize; /* Maximum Buffersize supported */
  504. unsigned long pktcount; /* Until now: unused */
  505. int stavail; /* Chars avail on Status-device */
  506. isdn_if *interface; /* Interface to driver */
  507. int *rcverr; /* Error-counters for B-Ch.-receive */
  508. int *rcvcount; /* Byte-counters for B-Ch.-receive */
  509. #ifdef CONFIG_ISDN_AUDIO
  510. unsigned long DLEflag; /* Flags: Insert DLE at next read */
  511. #endif
  512. struct sk_buff_head *rpqueue; /* Pointers to start of Rcv-Queue */
  513. wait_queue_head_t *rcv_waitq; /* Wait-Queues for B-Channel-Reads */
  514. wait_queue_head_t *snd_waitq; /* Wait-Queue for B-Channel-Send's */
  515. char msn2eaz[10][ISDN_MSNLEN]; /* Mapping-Table MSN->EAZ */
  516. } isdn_driver_t;
  517. /* Main driver-data */
  518. typedef struct isdn_devt {
  519. struct module *owner;
  520. spinlock_t lock;
  521. unsigned short flags; /* Bitmapped Flags: */
  522. int drivers; /* Current number of drivers */
  523. int channels; /* Current number of channels */
  524. int net_verbose; /* Verbose-Flag */
  525. int modempoll; /* Flag: tty-read active */
  526. spinlock_t timerlock;
  527. int tflags; /* Timer-Flags: */
  528. /* see ISDN_TIMER_..defines */
  529. int global_flags;
  530. infostruct *infochain; /* List of open info-devs. */
  531. wait_queue_head_t info_waitq; /* Wait-Queue for isdninfo */
  532. struct timer_list timer; /* Misc.-function Timer */
  533. int chanmap[ISDN_MAX_CHANNELS]; /* Map minor->device-channel */
  534. int drvmap[ISDN_MAX_CHANNELS]; /* Map minor->driver-index */
  535. int usage[ISDN_MAX_CHANNELS]; /* Used by tty/ip/voice */
  536. char num[ISDN_MAX_CHANNELS][ISDN_MSNLEN];
  537. /* Remote number of active ch.*/
  538. int m_idx[ISDN_MAX_CHANNELS]; /* Index for mdm.... */
  539. isdn_driver_t *drv[ISDN_MAX_DRIVERS]; /* Array of drivers */
  540. isdn_net_dev *netdev; /* Linked list of net-if's */
  541. char drvid[ISDN_MAX_DRIVERS][20];/* Driver-ID */
  542. struct task_struct *profd; /* For iprofd */
  543. isdn_modem_t mdm; /* tty-driver-data */
  544. isdn_net_dev *rx_netdev[ISDN_MAX_CHANNELS]; /* rx netdev-pointers */
  545. isdn_net_dev *st_netdev[ISDN_MAX_CHANNELS]; /* stat netdev-pointers */
  546. ulong ibytes[ISDN_MAX_CHANNELS]; /* Statistics incoming bytes */
  547. ulong obytes[ISDN_MAX_CHANNELS]; /* Statistics outgoing bytes */
  548. int v110emu[ISDN_MAX_CHANNELS]; /* V.110 emulator-mode 0=none */
  549. atomic_t v110use[ISDN_MAX_CHANNELS]; /* Usage-Semaphore for stream */
  550. isdn_v110_stream *v110[ISDN_MAX_CHANNELS]; /* V.110 private data */
  551. struct mutex mtx; /* serialize list access*/
  552. unsigned long global_features;
  553. } isdn_dev;
  554. extern isdn_dev *dev;
  555. #endif /* __KERNEL__ */
  556. #endif /* __ISDN_H__ */