isdn.h 30 KB

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