capi.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  1. /* $Id: capi.h,v 1.6.6.2 2001/09/23 22:24:32 kai Exp $
  2. *
  3. * ISDN lowlevel-module for the IBM ISDN-S0 Active 2000.
  4. *
  5. * Author Fritz Elfert
  6. * Copyright by Fritz Elfert <fritz@isdn4linux.de>
  7. *
  8. * This software may be used and distributed according to the terms
  9. * of the GNU General Public License, incorporated herein by reference.
  10. *
  11. * Thanks to Friedemann Baitinger and IBM Germany
  12. *
  13. */
  14. #ifndef CAPI_H
  15. #define CAPI_H
  16. /* Command-part of a CAPI message */
  17. typedef struct actcapi_msgcmd {
  18. __u8 cmd;
  19. __u8 subcmd;
  20. } actcapi_msgcmd;
  21. /* CAPI message header */
  22. typedef struct actcapi_msghdr {
  23. __u16 len;
  24. __u16 applicationID;
  25. actcapi_msgcmd cmd;
  26. __u16 msgnum;
  27. } actcapi_msghdr;
  28. /* CAPI message description (for debugging) */
  29. typedef struct actcapi_msgdsc {
  30. actcapi_msgcmd cmd;
  31. char *description;
  32. } actcapi_msgdsc;
  33. /* CAPI Address */
  34. typedef struct actcapi_addr {
  35. __u8 len; /* Length of element */
  36. __u8 tnp; /* Type/Numbering Plan */
  37. __u8 num[20]; /* Caller ID */
  38. } actcapi_addr;
  39. /* CAPI INFO element mask */
  40. typedef union actcapi_infonr { /* info number */
  41. __u16 mask; /* info-mask field */
  42. struct bmask { /* bit definitions */
  43. unsigned codes : 3; /* code set */
  44. unsigned rsvd : 5; /* reserved */
  45. unsigned svind : 1; /* single, variable length ind. */
  46. unsigned wtype : 7; /* W-element type */
  47. } bmask;
  48. } actcapi_infonr;
  49. /* CAPI INFO element */
  50. typedef union actcapi_infoel { /* info element */
  51. __u8 len; /* length of info element */
  52. __u8 display[40]; /* display contents */
  53. __u8 uuinfo[40]; /* User-user info field */
  54. struct cause { /* Cause information */
  55. unsigned ext2 : 1; /* extension */
  56. unsigned cod : 2; /* coding standard */
  57. unsigned spare : 1; /* spare */
  58. unsigned loc : 4; /* location */
  59. unsigned ext1 : 1; /* extension */
  60. unsigned cval : 7; /* Cause value */
  61. } cause;
  62. struct charge { /* Charging information */
  63. __u8 toc; /* type of charging info */
  64. __u8 unit[10]; /* charging units */
  65. } charge;
  66. __u8 date[20]; /* date fields */
  67. __u8 stat; /* state of remote party */
  68. } actcapi_infoel;
  69. /* Message for EAZ<->MSN Mapping */
  70. typedef struct actcapi_msn {
  71. __u8 eaz;
  72. __u8 len; /* Length of MSN */
  73. __u8 msn[15];
  74. } __attribute__((packed)) actcapi_msn;
  75. typedef struct actcapi_dlpd {
  76. __u8 len; /* Length of structure */
  77. __u16 dlen; /* Data Length */
  78. __u8 laa; /* Link Address A */
  79. __u8 lab; /* Link Address B */
  80. __u8 modulo; /* Modulo Mode */
  81. __u8 win; /* Window size */
  82. __u8 xid[100]; /* XID Information */
  83. } __attribute__((packed)) actcapi_dlpd;
  84. typedef struct actcapi_ncpd {
  85. __u8 len; /* Length of structure */
  86. __u16 lic;
  87. __u16 hic;
  88. __u16 ltc;
  89. __u16 htc;
  90. __u16 loc;
  91. __u16 hoc;
  92. __u8 modulo;
  93. } __attribute__((packed)) actcapi_ncpd;
  94. #define actcapi_ncpi actcapi_ncpd
  95. /*
  96. * Layout of NCCI field in a B3 DATA CAPI message is different from
  97. * standard at act2000:
  98. *
  99. * Bit 0-4 = PLCI
  100. * Bit 5-7 = Controller
  101. * Bit 8-15 = NCCI
  102. */
  103. #define MAKE_NCCI(plci,contr,ncci) \
  104. ((plci & 0x1f) | ((contr & 0x7) << 5) | ((ncci & 0xff) << 8))
  105. #define EVAL_NCCI(fakencci,plci,contr,ncci) { \
  106. plci = fakencci & 0x1f; \
  107. contr = (fakencci >> 5) & 0x7; \
  108. ncci = (fakencci >> 8) & 0xff; \
  109. }
  110. /*
  111. * Layout of PLCI field in a B3 DATA CAPI message is different from
  112. * standard at act2000:
  113. *
  114. * Bit 0-4 = PLCI
  115. * Bit 5-7 = Controller
  116. * Bit 8-15 = reserved (must be 0)
  117. */
  118. #define MAKE_PLCI(plci,contr) \
  119. ((plci & 0x1f) | ((contr & 0x7) << 5))
  120. #define EVAL_PLCI(fakeplci,plci,contr) { \
  121. plci = fakeplci & 0x1f; \
  122. contr = (fakeplci >> 5) & 0x7; \
  123. }
  124. typedef struct actcapi_msg {
  125. actcapi_msghdr hdr;
  126. union {
  127. __u16 manuf_msg;
  128. struct manufacturer_req_net {
  129. __u16 manuf_msg;
  130. __u16 controller;
  131. __u8 nettype;
  132. } manufacturer_req_net;
  133. struct manufacturer_req_v42 {
  134. __u16 manuf_msg;
  135. __u16 controller;
  136. __u32 v42control;
  137. } manufacturer_req_v42;
  138. struct manufacturer_conf_v42 {
  139. __u16 manuf_msg;
  140. __u16 controller;
  141. } manufacturer_conf_v42;
  142. struct manufacturer_req_err {
  143. __u16 manuf_msg;
  144. __u16 controller;
  145. } manufacturer_req_err;
  146. struct manufacturer_ind_err {
  147. __u16 manuf_msg;
  148. __u16 controller;
  149. __u32 errcode;
  150. __u8 errstring; /* actually up to 160 */
  151. } manufacturer_ind_err;
  152. struct manufacturer_req_msn {
  153. __u16 manuf_msg;
  154. __u16 controller;
  155. actcapi_msn msnmap;
  156. } __attribute ((packed)) manufacturer_req_msn;
  157. /* TODO: TraceInit-req/conf/ind/resp and
  158. * TraceDump-req/conf/ind/resp
  159. */
  160. struct connect_req {
  161. __u8 controller;
  162. __u8 bchan;
  163. __u32 infomask;
  164. __u8 si1;
  165. __u8 si2;
  166. __u8 eaz;
  167. actcapi_addr addr;
  168. } __attribute__ ((packed)) connect_req;
  169. struct connect_conf {
  170. __u16 plci;
  171. __u16 info;
  172. } connect_conf;
  173. struct connect_ind {
  174. __u16 plci;
  175. __u8 controller;
  176. __u8 si1;
  177. __u8 si2;
  178. __u8 eaz;
  179. actcapi_addr addr;
  180. } __attribute__ ((packed)) connect_ind;
  181. struct connect_resp {
  182. __u16 plci;
  183. __u8 rejectcause;
  184. } connect_resp;
  185. struct connect_active_ind {
  186. __u16 plci;
  187. actcapi_addr addr;
  188. } __attribute__ ((packed)) connect_active_ind;
  189. struct connect_active_resp {
  190. __u16 plci;
  191. } connect_active_resp;
  192. struct connect_b3_req {
  193. __u16 plci;
  194. actcapi_ncpi ncpi;
  195. } __attribute__ ((packed)) connect_b3_req;
  196. struct connect_b3_conf {
  197. __u16 plci;
  198. __u16 ncci;
  199. __u16 info;
  200. } connect_b3_conf;
  201. struct connect_b3_ind {
  202. __u16 ncci;
  203. __u16 plci;
  204. actcapi_ncpi ncpi;
  205. } __attribute__ ((packed)) connect_b3_ind;
  206. struct connect_b3_resp {
  207. __u16 ncci;
  208. __u8 rejectcause;
  209. actcapi_ncpi ncpi;
  210. } __attribute__ ((packed)) connect_b3_resp;
  211. struct disconnect_req {
  212. __u16 plci;
  213. __u8 cause;
  214. } disconnect_req;
  215. struct disconnect_conf {
  216. __u16 plci;
  217. __u16 info;
  218. } disconnect_conf;
  219. struct disconnect_ind {
  220. __u16 plci;
  221. __u16 info;
  222. } disconnect_ind;
  223. struct disconnect_resp {
  224. __u16 plci;
  225. } disconnect_resp;
  226. struct connect_b3_active_ind {
  227. __u16 ncci;
  228. actcapi_ncpi ncpi;
  229. } __attribute__ ((packed)) connect_b3_active_ind;
  230. struct connect_b3_active_resp {
  231. __u16 ncci;
  232. } connect_b3_active_resp;
  233. struct disconnect_b3_req {
  234. __u16 ncci;
  235. actcapi_ncpi ncpi;
  236. } __attribute__ ((packed)) disconnect_b3_req;
  237. struct disconnect_b3_conf {
  238. __u16 ncci;
  239. __u16 info;
  240. } disconnect_b3_conf;
  241. struct disconnect_b3_ind {
  242. __u16 ncci;
  243. __u16 info;
  244. actcapi_ncpi ncpi;
  245. } __attribute__ ((packed)) disconnect_b3_ind;
  246. struct disconnect_b3_resp {
  247. __u16 ncci;
  248. } disconnect_b3_resp;
  249. struct info_ind {
  250. __u16 plci;
  251. actcapi_infonr nr;
  252. actcapi_infoel el;
  253. } __attribute__ ((packed)) info_ind;
  254. struct info_resp {
  255. __u16 plci;
  256. } info_resp;
  257. struct listen_b3_req {
  258. __u16 plci;
  259. } listen_b3_req;
  260. struct listen_b3_conf {
  261. __u16 plci;
  262. __u16 info;
  263. } listen_b3_conf;
  264. struct select_b2_protocol_req {
  265. __u16 plci;
  266. __u8 protocol;
  267. actcapi_dlpd dlpd;
  268. } __attribute__ ((packed)) select_b2_protocol_req;
  269. struct select_b2_protocol_conf {
  270. __u16 plci;
  271. __u16 info;
  272. } select_b2_protocol_conf;
  273. struct select_b3_protocol_req {
  274. __u16 plci;
  275. __u8 protocol;
  276. actcapi_ncpd ncpd;
  277. } __attribute__ ((packed)) select_b3_protocol_req;
  278. struct select_b3_protocol_conf {
  279. __u16 plci;
  280. __u16 info;
  281. } select_b3_protocol_conf;
  282. struct listen_req {
  283. __u8 controller;
  284. __u32 infomask;
  285. __u16 eazmask;
  286. __u16 simask;
  287. } __attribute__ ((packed)) listen_req;
  288. struct listen_conf {
  289. __u8 controller;
  290. __u16 info;
  291. } __attribute__ ((packed)) listen_conf;
  292. struct data_b3_req {
  293. __u16 fakencci;
  294. __u16 datalen;
  295. __u32 unused;
  296. __u8 blocknr;
  297. __u16 flags;
  298. } __attribute ((packed)) data_b3_req;
  299. struct data_b3_ind {
  300. __u16 fakencci;
  301. __u16 datalen;
  302. __u32 unused;
  303. __u8 blocknr;
  304. __u16 flags;
  305. } __attribute__ ((packed)) data_b3_ind;
  306. struct data_b3_resp {
  307. __u16 ncci;
  308. __u8 blocknr;
  309. } __attribute__ ((packed)) data_b3_resp;
  310. struct data_b3_conf {
  311. __u16 ncci;
  312. __u8 blocknr;
  313. __u16 info;
  314. } __attribute__ ((packed)) data_b3_conf;
  315. } msg;
  316. } __attribute__ ((packed)) actcapi_msg;
  317. static inline unsigned short
  318. actcapi_nextsmsg(act2000_card *card)
  319. {
  320. unsigned long flags;
  321. unsigned short n;
  322. spin_lock_irqsave(&card->mnlock, flags);
  323. n = card->msgnum;
  324. card->msgnum++;
  325. card->msgnum &= 0x7fff;
  326. spin_unlock_irqrestore(&card->mnlock, flags);
  327. return n;
  328. }
  329. #define DEBUG_MSG
  330. #undef DEBUG_DATA_MSG
  331. #undef DEBUG_DUMP_SKB
  332. extern int actcapi_chkhdr(act2000_card *, actcapi_msghdr *);
  333. extern int actcapi_listen_req(act2000_card *);
  334. extern int actcapi_manufacturer_req_net(act2000_card *);
  335. extern int actcapi_manufacturer_req_errh(act2000_card *);
  336. extern int actcapi_manufacturer_req_msn(act2000_card *);
  337. extern int actcapi_connect_req(act2000_card *, act2000_chan *, char *, char, int, int);
  338. extern void actcapi_select_b2_protocol_req(act2000_card *, act2000_chan *);
  339. extern void actcapi_disconnect_b3_req(act2000_card *, act2000_chan *);
  340. extern void actcapi_connect_resp(act2000_card *, act2000_chan *, __u8);
  341. extern void actcapi_dispatch(struct work_struct *);
  342. #ifdef DEBUG_MSG
  343. extern void actcapi_debug_msg(struct sk_buff *skb, int);
  344. #else
  345. #define actcapi_debug_msg(skb, len)
  346. #endif
  347. #endif