lapb-module.rst 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. .. SPDX-License-Identifier: GPL-2.0
  2. ===============================
  3. The Linux LAPB Module Interface
  4. ===============================
  5. Version 1.3
  6. Jonathan Naylor 29.12.96
  7. Changed (Henner Eisen, 2000-10-29): int return value for data_indication()
  8. The LAPB module will be a separately compiled module for use by any parts of
  9. the Linux operating system that require a LAPB service. This document
  10. defines the interfaces to, and the services provided by this module. The
  11. term module in this context does not imply that the LAPB module is a
  12. separately loadable module, although it may be. The term module is used in
  13. its more standard meaning.
  14. The interface to the LAPB module consists of functions to the module,
  15. callbacks from the module to indicate important state changes, and
  16. structures for getting and setting information about the module.
  17. Structures
  18. ----------
  19. Probably the most important structure is the skbuff structure for holding
  20. received and transmitted data, however it is beyond the scope of this
  21. document.
  22. The two LAPB specific structures are the LAPB initialisation structure and
  23. the LAPB parameter structure. These will be defined in a standard header
  24. file, <linux/lapb.h>. The header file <net/lapb.h> is internal to the LAPB
  25. module and is not for use.
  26. LAPB Initialisation Structure
  27. -----------------------------
  28. This structure is used only once, in the call to lapb_register (see below).
  29. It contains information about the device driver that requires the services
  30. of the LAPB module::
  31. struct lapb_register_struct {
  32. void (*connect_confirmation)(int token, int reason);
  33. void (*connect_indication)(int token, int reason);
  34. void (*disconnect_confirmation)(int token, int reason);
  35. void (*disconnect_indication)(int token, int reason);
  36. int (*data_indication)(int token, struct sk_buff *skb);
  37. void (*data_transmit)(int token, struct sk_buff *skb);
  38. };
  39. Each member of this structure corresponds to a function in the device driver
  40. that is called when a particular event in the LAPB module occurs. These will
  41. be described in detail below. If a callback is not required (!!) then a NULL
  42. may be substituted.
  43. LAPB Parameter Structure
  44. ------------------------
  45. This structure is used with the lapb_getparms and lapb_setparms functions
  46. (see below). They are used to allow the device driver to get and set the
  47. operational parameters of the LAPB implementation for a given connection::
  48. struct lapb_parms_struct {
  49. unsigned int t1;
  50. unsigned int t1timer;
  51. unsigned int t2;
  52. unsigned int t2timer;
  53. unsigned int n2;
  54. unsigned int n2count;
  55. unsigned int window;
  56. unsigned int state;
  57. unsigned int mode;
  58. };
  59. T1 and T2 are protocol timing parameters and are given in units of 100ms. N2
  60. is the maximum number of tries on the link before it is declared a failure.
  61. The window size is the maximum number of outstanding data packets allowed to
  62. be unacknowledged by the remote end, the value of the window is between 1
  63. and 7 for a standard LAPB link, and between 1 and 127 for an extended LAPB
  64. link.
  65. The mode variable is a bit field used for setting (at present) three values.
  66. The bit fields have the following meanings:
  67. ====== =================================================
  68. Bit Meaning
  69. ====== =================================================
  70. 0 LAPB operation (0=LAPB_STANDARD 1=LAPB_EXTENDED).
  71. 1 [SM]LP operation (0=LAPB_SLP 1=LAPB=MLP).
  72. 2 DTE/DCE operation (0=LAPB_DTE 1=LAPB_DCE)
  73. 3-31 Reserved, must be 0.
  74. ====== =================================================
  75. Extended LAPB operation indicates the use of extended sequence numbers and
  76. consequently larger window sizes, the default is standard LAPB operation.
  77. MLP operation is the same as SLP operation except that the addresses used by
  78. LAPB are different to indicate the mode of operation, the default is Single
  79. Link Procedure. The difference between DCE and DTE operation is (i) the
  80. addresses used for commands and responses, and (ii) when the DCE is not
  81. connected, it sends DM without polls set, every T1. The upper case constant
  82. names will be defined in the public LAPB header file.
  83. Functions
  84. ---------
  85. The LAPB module provides a number of function entry points.
  86. ::
  87. int lapb_register(void *token, struct lapb_register_struct);
  88. This must be called before the LAPB module may be used. If the call is
  89. successful then LAPB_OK is returned. The token must be a unique identifier
  90. generated by the device driver to allow for the unique identification of the
  91. instance of the LAPB link. It is returned by the LAPB module in all of the
  92. callbacks, and is used by the device driver in all calls to the LAPB module.
  93. For multiple LAPB links in a single device driver, multiple calls to
  94. lapb_register must be made. The format of the lapb_register_struct is given
  95. above. The return values are:
  96. ============= =============================
  97. LAPB_OK LAPB registered successfully.
  98. LAPB_BADTOKEN Token is already registered.
  99. LAPB_NOMEM Out of memory
  100. ============= =============================
  101. ::
  102. int lapb_unregister(void *token);
  103. This releases all the resources associated with a LAPB link. Any current
  104. LAPB link will be abandoned without further messages being passed. After
  105. this call, the value of token is no longer valid for any calls to the LAPB
  106. function. The valid return values are:
  107. ============= ===============================
  108. LAPB_OK LAPB unregistered successfully.
  109. LAPB_BADTOKEN Invalid/unknown LAPB token.
  110. ============= ===============================
  111. ::
  112. int lapb_getparms(void *token, struct lapb_parms_struct *parms);
  113. This allows the device driver to get the values of the current LAPB
  114. variables, the lapb_parms_struct is described above. The valid return values
  115. are:
  116. ============= =============================
  117. LAPB_OK LAPB getparms was successful.
  118. LAPB_BADTOKEN Invalid/unknown LAPB token.
  119. ============= =============================
  120. ::
  121. int lapb_setparms(void *token, struct lapb_parms_struct *parms);
  122. This allows the device driver to set the values of the current LAPB
  123. variables, the lapb_parms_struct is described above. The values of t1timer,
  124. t2timer and n2count are ignored, likewise changing the mode bits when
  125. connected will be ignored. An error implies that none of the values have
  126. been changed. The valid return values are:
  127. ============= =================================================
  128. LAPB_OK LAPB getparms was successful.
  129. LAPB_BADTOKEN Invalid/unknown LAPB token.
  130. LAPB_INVALUE One of the values was out of its allowable range.
  131. ============= =================================================
  132. ::
  133. int lapb_connect_request(void *token);
  134. Initiate a connect using the current parameter settings. The valid return
  135. values are:
  136. ============== =================================
  137. LAPB_OK LAPB is starting to connect.
  138. LAPB_BADTOKEN Invalid/unknown LAPB token.
  139. LAPB_CONNECTED LAPB module is already connected.
  140. ============== =================================
  141. ::
  142. int lapb_disconnect_request(void *token);
  143. Initiate a disconnect. The valid return values are:
  144. ================= ===============================
  145. LAPB_OK LAPB is starting to disconnect.
  146. LAPB_BADTOKEN Invalid/unknown LAPB token.
  147. LAPB_NOTCONNECTED LAPB module is not connected.
  148. ================= ===============================
  149. ::
  150. int lapb_data_request(void *token, struct sk_buff *skb);
  151. Queue data with the LAPB module for transmitting over the link. If the call
  152. is successful then the skbuff is owned by the LAPB module and may not be
  153. used by the device driver again. The valid return values are:
  154. ================= =============================
  155. LAPB_OK LAPB has accepted the data.
  156. LAPB_BADTOKEN Invalid/unknown LAPB token.
  157. LAPB_NOTCONNECTED LAPB module is not connected.
  158. ================= =============================
  159. ::
  160. int lapb_data_received(void *token, struct sk_buff *skb);
  161. Queue data with the LAPB module which has been received from the device. It
  162. is expected that the data passed to the LAPB module has skb->data pointing
  163. to the beginning of the LAPB data. If the call is successful then the skbuff
  164. is owned by the LAPB module and may not be used by the device driver again.
  165. The valid return values are:
  166. ============= ===========================
  167. LAPB_OK LAPB has accepted the data.
  168. LAPB_BADTOKEN Invalid/unknown LAPB token.
  169. ============= ===========================
  170. Callbacks
  171. ---------
  172. These callbacks are functions provided by the device driver for the LAPB
  173. module to call when an event occurs. They are registered with the LAPB
  174. module with lapb_register (see above) in the structure lapb_register_struct
  175. (see above).
  176. ::
  177. void (*connect_confirmation)(void *token, int reason);
  178. This is called by the LAPB module when a connection is established after
  179. being requested by a call to lapb_connect_request (see above). The reason is
  180. always LAPB_OK.
  181. ::
  182. void (*connect_indication)(void *token, int reason);
  183. This is called by the LAPB module when the link is established by the remote
  184. system. The value of reason is always LAPB_OK.
  185. ::
  186. void (*disconnect_confirmation)(void *token, int reason);
  187. This is called by the LAPB module when an event occurs after the device
  188. driver has called lapb_disconnect_request (see above). The reason indicates
  189. what has happened. In all cases the LAPB link can be regarded as being
  190. terminated. The values for reason are:
  191. ================= ====================================================
  192. LAPB_OK The LAPB link was terminated normally.
  193. LAPB_NOTCONNECTED The remote system was not connected.
  194. LAPB_TIMEDOUT No response was received in N2 tries from the remote
  195. system.
  196. ================= ====================================================
  197. ::
  198. void (*disconnect_indication)(void *token, int reason);
  199. This is called by the LAPB module when the link is terminated by the remote
  200. system or another event has occurred to terminate the link. This may be
  201. returned in response to a lapb_connect_request (see above) if the remote
  202. system refused the request. The values for reason are:
  203. ================= ====================================================
  204. LAPB_OK The LAPB link was terminated normally by the remote
  205. system.
  206. LAPB_REFUSED The remote system refused the connect request.
  207. LAPB_NOTCONNECTED The remote system was not connected.
  208. LAPB_TIMEDOUT No response was received in N2 tries from the remote
  209. system.
  210. ================= ====================================================
  211. ::
  212. int (*data_indication)(void *token, struct sk_buff *skb);
  213. This is called by the LAPB module when data has been received from the
  214. remote system that should be passed onto the next layer in the protocol
  215. stack. The skbuff becomes the property of the device driver and the LAPB
  216. module will not perform any more actions on it. The skb->data pointer will
  217. be pointing to the first byte of data after the LAPB header.
  218. This method should return NET_RX_DROP (as defined in the header
  219. file include/linux/netdevice.h) if and only if the frame was dropped
  220. before it could be delivered to the upper layer.
  221. ::
  222. void (*data_transmit)(void *token, struct sk_buff *skb);
  223. This is called by the LAPB module when data is to be transmitted to the
  224. remote system by the device driver. The skbuff becomes the property of the
  225. device driver and the LAPB module will not perform any more actions on it.
  226. The skb->data pointer will be pointing to the first byte of the LAPB header.