kcapi.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. /*
  2. * Kernel CAPI 2.0 Module
  3. *
  4. * Copyright 1999 by Carsten Paeth <[email protected]>
  5. * Copyright 2002 by Kai Germaschewski <[email protected]>
  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. #include <linux/kernel.h>
  12. #include <linux/spinlock.h>
  13. #include <linux/list.h>
  14. #include <linux/isdn/capilli.h>
  15. #ifdef KCAPI_DEBUG
  16. #define DBG(format, arg...) do { \
  17. printk(KERN_DEBUG "%s: " format "\n" , __func__ , ## arg); \
  18. } while (0)
  19. #else
  20. #define DBG(format, arg...) /* */
  21. #endif
  22. enum {
  23. CAPI_CTR_DETACHED = 0,
  24. CAPI_CTR_DETECTED = 1,
  25. CAPI_CTR_LOADING = 2,
  26. CAPI_CTR_RUNNING = 3,
  27. };
  28. extern struct capi_ctr *capi_controller[CAPI_MAXCONTR];
  29. extern struct mutex capi_controller_lock;
  30. extern struct capi20_appl *capi_applications[CAPI_MAXAPPL];
  31. void kcapi_proc_init(void);
  32. void kcapi_proc_exit(void);
  33. struct capi20_appl {
  34. u16 applid;
  35. capi_register_params rparam;
  36. void (*recv_message)(struct capi20_appl *ap, struct sk_buff *skb);
  37. void *private;
  38. /* internal to kernelcapi.o */
  39. unsigned long nrecvctlpkt;
  40. unsigned long nrecvdatapkt;
  41. unsigned long nsentctlpkt;
  42. unsigned long nsentdatapkt;
  43. struct mutex recv_mtx;
  44. struct sk_buff_head recv_queue;
  45. struct work_struct recv_work;
  46. int release_in_progress;
  47. };
  48. u16 capi20_isinstalled(void);
  49. u16 capi20_register(struct capi20_appl *ap);
  50. u16 capi20_release(struct capi20_appl *ap);
  51. u16 capi20_put_message(struct capi20_appl *ap, struct sk_buff *skb);
  52. u16 capi20_get_manufacturer(u32 contr, u8 buf[CAPI_MANUFACTURER_LEN]);
  53. u16 capi20_get_version(u32 contr, struct capi_version *verp);
  54. u16 capi20_get_serial(u32 contr, u8 serial[CAPI_SERIAL_LEN]);
  55. u16 capi20_get_profile(u32 contr, struct capi_profile *profp);
  56. int capi20_manufacturer(unsigned long cmd, void __user *data);
  57. #define CAPICTR_UP 0
  58. #define CAPICTR_DOWN 1
  59. int kcapi_init(void);
  60. void kcapi_exit(void);
  61. /*----- basic-type definitions -----*/
  62. typedef __u8 *_cstruct;
  63. typedef enum {
  64. CAPI_COMPOSE,
  65. CAPI_DEFAULT
  66. } _cmstruct;
  67. /*
  68. The _cmsg structure contains all possible CAPI 2.0 parameter.
  69. All parameters are stored here first. The function CAPI_CMSG_2_MESSAGE
  70. assembles the parameter and builds CAPI2.0 conform messages.
  71. CAPI_MESSAGE_2_CMSG disassembles CAPI 2.0 messages and stores the
  72. parameter in the _cmsg structure
  73. */
  74. typedef struct {
  75. /* Header */
  76. __u16 ApplId;
  77. __u8 Command;
  78. __u8 Subcommand;
  79. __u16 Messagenumber;
  80. /* Parameter */
  81. union {
  82. __u32 adrController;
  83. __u32 adrPLCI;
  84. __u32 adrNCCI;
  85. } adr;
  86. _cmstruct AdditionalInfo;
  87. _cstruct B1configuration;
  88. __u16 B1protocol;
  89. _cstruct B2configuration;
  90. __u16 B2protocol;
  91. _cstruct B3configuration;
  92. __u16 B3protocol;
  93. _cstruct BC;
  94. _cstruct BChannelinformation;
  95. _cmstruct BProtocol;
  96. _cstruct CalledPartyNumber;
  97. _cstruct CalledPartySubaddress;
  98. _cstruct CallingPartyNumber;
  99. _cstruct CallingPartySubaddress;
  100. __u32 CIPmask;
  101. __u32 CIPmask2;
  102. __u16 CIPValue;
  103. __u32 Class;
  104. _cstruct ConnectedNumber;
  105. _cstruct ConnectedSubaddress;
  106. __u32 Data;
  107. __u16 DataHandle;
  108. __u16 DataLength;
  109. _cstruct FacilityConfirmationParameter;
  110. _cstruct Facilitydataarray;
  111. _cstruct FacilityIndicationParameter;
  112. _cstruct FacilityRequestParameter;
  113. __u16 FacilitySelector;
  114. __u16 Flags;
  115. __u32 Function;
  116. _cstruct HLC;
  117. __u16 Info;
  118. _cstruct InfoElement;
  119. __u32 InfoMask;
  120. __u16 InfoNumber;
  121. _cstruct Keypadfacility;
  122. _cstruct LLC;
  123. _cstruct ManuData;
  124. __u32 ManuID;
  125. _cstruct NCPI;
  126. __u16 Reason;
  127. __u16 Reason_B3;
  128. __u16 Reject;
  129. _cstruct Useruserdata;
  130. /* intern */
  131. unsigned l, p;
  132. unsigned char *par;
  133. __u8 *m;
  134. /* buffer to construct message */
  135. __u8 buf[180];
  136. } _cmsg;
  137. /*-----------------------------------------------------------------------*/
  138. /*
  139. * Debugging / Tracing functions
  140. */
  141. char *capi_cmd2str(__u8 cmd, __u8 subcmd);
  142. typedef struct {
  143. u_char *buf;
  144. u_char *p;
  145. size_t size;
  146. size_t pos;
  147. } _cdebbuf;
  148. #define CDEBUG_SIZE 1024
  149. #define CDEBUG_GSIZE 4096
  150. void cdebbuf_free(_cdebbuf *cdb);
  151. int cdebug_init(void);
  152. void cdebug_exit(void);
  153. _cdebbuf *capi_message2str(__u8 *msg);