1 $Id: INTERFACE,v 1.15 1999/08/25 20:02:13 werner Exp $
3 Description of the Interface between Linklevel and Hardwarelevel
7 The Communication between Linklevel (LL) and Hardwarelevel (HL)
8 is based on the struct isdn_if (defined in isdnif.h).
10 An HL-driver can register itself at LL by calling the function
11 register_isdn() with a pointer to that struct. Prior to that, it has
12 to preset some of the fields of isdn_if. The LL sets the rest of
13 the fields. All further communication is done via callbacks using
14 the function-pointers defined in isdn_if.
16 Changes/Version numbering:
18 During development of the ISDN subsystem, several changes have been
19 made to the interface. Before it went into kernel, the package
20 had a unique version number. The last version, distributed separately
21 was 0.7.4. When the subsystem went into kernel, every functional unit
22 got a separate version number. These numbers are shown at initialization,
25 c.c/t.t/n.n/p.p/a.a/v.v
29 c.c is the revision of the common code.
30 t.t is the revision of the tty related code.
31 n.n is the revision of the network related code.
32 p.p is the revision of the ppp related code.
33 a.a is the revision of the audio related code.
34 v.v is the revision of the V.110 related code.
36 Changes in this document are marked with '***CHANGEx' where x representing
37 the version number. If that number starts with 0, it refers to the old,
38 separately distributed package. If it starts with one of the letters
39 above, it refers to the revision of the corresponding module.
40 ***CHANGEIx refers to the revision number of the isdnif.h
42 1. Description of the fields of isdn_if:
46 This field has to be set by the HL-driver to the number of channels
47 supported prior to calling register_isdn(). Upon return of the call,
48 the LL puts an id there, which has to be used by the HL-driver when
49 invoking the other callbacks.
53 ***CHANGE0.6: New since this version.
55 Also to be preset by the HL-driver. With this value the HL-driver
56 tells the LL the maximum size of a data-packet it will accept.
58 unsigned long features;
60 To be preset by the HL-driver. Using this field, the HL-driver
61 announces the features supported. At the moment this is limited to
62 report the supported layer2 and layer3-protocols. For setting this
63 field the constants ISDN_FEATURE..., declared in isdnif.h have to be
66 ***CHANGE0.7.1: The line type (1TR6, EDSS1) has to be set.
68 unsigned short hl_hdrlen;
70 ***CHANGE0.7.4: New field.
72 To be preset by the HL-driver, if it supports sk_buff's. The driver
73 should put here the amount of additional space needed in sk_buff's for
74 its internal purposes. Drivers not supporting sk_buff's should
75 initialize this field to 0.
77 void (*rcvcallb_skb)(int, int, struct sk_buff *)
79 ***CHANGE0.7.4: New field.
81 This field will be set by LL. The HL-driver delivers received data-
82 packets by calling this function. Upon calling, the HL-driver must
83 already have its private data pulled off the head of the sk_buff.
87 int Channel-number locally to the driver. (starting with 0)
88 struct sk_buff * Pointer to sk_buff, containing received data.
90 int (*statcallb)(isdn_ctrl*);
92 This field will be set by LL. This function has to be called by the
93 HL-driver for signaling status-changes or other events to the LL.
98 The struct isdn_ctrl also defined in isdn_if. The exact meanings of its
99 fields are described together with the descriptions of the possible
100 events. Here is only a short description of the fields:
103 command = event-type. (one of the constants ISDN_STAT_...)
104 arg = depends on event-type.
105 num = depends on event-type.
108 0 on success, else -1
110 int (*command)(isdn_ctrl*);
112 This field has to be preset by the HL-driver. It points to a function,
113 to be called by LL to perform functions like dialing, B-channel
114 setup, etc. The exact meaning of the parameters is described with the
115 descriptions of the possible commands.
120 command = command to perform. (one of the constants ISDN_CMD_...)
121 arg = depends on command.
122 num = depends on command.
125 >=0 on success, else error-code (-ENODEV etc.)
127 int (*writebuf_skb)(int, int, int, struct sk_buff *)
129 ***CHANGE0.7.4: New field.
130 ***CHANGEI.1.21: New field.
132 This field has to be preset by the HL-driver. The given function will
133 be called by the LL for delivering data to be send via B-Channel.
137 int driver-Id ***CHANGE0.7.4: New parameter.
138 int channel-number locally to the HL-driver. (starts with 0)
139 int ack ***ChangeI1.21: New parameter
140 If this is !0, the driver has to signal the delivery
141 by sending an ISDN_STAT_BSENT. If this is 0, the driver
142 MUST NOT send an ISDN_STAT_BSENT.
143 struct sk_buff * Pointer to sk_buff containing data to be send via
147 Length of data accepted on success, else error-code (-EINVAL on
148 oversized packets etc.)
150 int (*writecmd)(u_char*, int, int, int, int);
152 This field has to be preset by the HL-driver. The given function will be
153 called to perform write-requests on /dev/isdnctrl (i.e. sending commands
154 to the card) The data-format is hardware-specific. This function is
155 intended for debugging only. It is not necessary for normal operation
156 and never will be called by the tty-emulation- or network-code. If
157 this function is not supported, the driver has to set NULL here.
160 u_char* pointer to data.
162 int flag: 0 = call from within kernel-space. (HL-driver must use
163 memcpy, may NOT use schedule())
164 1 = call from user-space. (HL-driver must use
165 memcpy_fromfs, use of schedule() allowed)
167 int channel-number locally to the HL-driver. (starts with 0)
169 ***CHANGEI1.14: The driver-Id and channel-number are new since this revision.
172 Length of data accepted on success, else error-code (-EINVAL etc.)
174 int (*readstat)(u_char*, int, int, int, int);
176 This field has to be preset by the HL-driver. The given function will be
177 called to perform read-requests on /dev/isdnctrl (i.e. reading replies
178 from the card) The data-format is hardware-specific. This function is
179 intended for debugging only. It is not necessary for normal operation
180 and never will be called by the tty-emulation- or network-code. If
181 this function is not supported, the driver has to set NULL here.
184 u_char* pointer to data.
186 int flag: 0 = call from within kernel-space. (HL-driver must use
187 memcpy, may NOT use schedule())
188 1 = call from user-space. (HL-driver must use
189 memcpy_fromfs, use of schedule() allowed)
191 int channel-number locally to the HL-driver. (starts with 0)
193 ***CHANGEI1.14: The driver-Id and channel-number are new since this revision.
196 Length of data on success, else error-code (-EINVAL etc.)
199 ***CHANGE0.7: New since this version.
201 This string has to be preset by the HL-driver. Its purpose is for
202 identification of the driver by the user. Eg.: it is shown in the
203 status-info of /dev/isdninfo. Furthermore it is used as Id for binding
204 net-interfaces to a specific channel. If a string of length zero is
205 given, upon return, isdn4linux will replace it by a generic name. (line0,
206 line1 etc.) It is recommended to make this string configurable during
207 module-load-time. (copy a global variable to this string.) For doing that,
208 modules 1.2.8 or newer are necessary.
210 2. Description of the commands, a HL-driver has to support:
212 All commands will be performed by calling the function command() described
213 above from within the LL. The field command of the struct-parameter will
214 contain the desired command, the field driver is always set to the
215 appropriate driver-Id.
217 Until now, the following commands are defined:
219 ***CHANGEI1.34: The parameter "num" has been replaced by a union "parm" containing
220 the old "num" and a new setup_type struct used for ISDN_CMD_DIAL
221 and ISDN_STAT_ICALL callback.
225 This command is intended for performing ioctl-calls for configuring
226 hardware or similar purposes (setting port-addresses, loading firmware
227 etc.) For this purpose, in the LL all ioctl-calls with an argument
228 >= IIOCDRVCTL (0x100) will be handed transparently to this
229 function after subtracting 0x100 and placing the result in arg.
231 If a userlevel-program calls ioctl(0x101,...) the function gets
232 called with the field command set to 1.
236 command = ISDN_CMD_IOCTL
237 arg = Original ioctl-cmd - IIOCDRVCTL
238 parm.num = first bytes filled with (unsigned long)arg
246 This command is used to tell the HL-driver it should dial a given
251 command = ISDN_CMD_DIAL
252 arg = channel-number locally to the driver. (starting with 0)
254 parm.setup.phone = An ASCII-String containing the number to dial.
255 parm.setup.eazmsn = An ASCII-Sting containing the own EAZ or MSN.
256 parm.setup.si1 = The Service-Indicator.
257 parm.setup.si2 = Additional Service-Indicator.
259 If the Line has been designed as SPV (a special german
260 feature, meaning semi-leased-line) the phone has to
262 ***CHANGE0.6: In previous versions the EAZ has been given in the
264 ***CHANGE0.7.1: New since this version: ServiceIndicator and AddInfo.
268 With this command, the HL-driver is told to accept a D-Channel-setup.
269 (Response to an incoming call)
273 command = ISDN_CMD_ACCEPTD
274 arg = channel-number locally to the driver. (starting with 0)
279 With this command, the HL-driver is told to perform a B-Channel-setup.
280 (after establishing D-Channel-Connection)
284 command = ISDN_CMD_ACCEPTB
285 arg = channel-number locally to the driver. (starting with 0)
290 With this command, the HL-driver is told to hangup (B-Channel if
291 established first, then D-Channel). This command is also used for
292 actively rejecting an incoming call.
296 command = ISDN_CMD_HANGUP
297 arg = channel-number locally to the driver. (starting with 0)
302 With this command, the HL-driver is told not to signal incoming
307 command = ISDN_CMD_CLREAZ
308 arg = channel-number locally to the driver. (starting with 0)
313 With this command, the HL-driver is told to signal incoming calls for
314 the given EAZs/MSNs to the LL.
318 command = ISDN_CMD_SETEAZ
319 arg = channel-number locally to the driver. (starting with 0)
320 parm.num = ASCII-String, containing the desired EAZ's/MSN's
321 (comma-separated). If an empty String is given, the
322 HL-driver should respond to ALL incoming calls,
323 regardless of the destination-address.
324 ***CHANGE0.6: New since this version the "empty-string"-feature.
326 ISDN_CMD_GETEAZ: (currently unused)
328 With this command, the HL-driver is told to report the current setting
329 given with ISDN_CMD_SETEAZ.
333 command = ISDN_CMD_GETEAZ
334 arg = channel-number locally to the driver. (starting with 0)
335 parm.num = ASCII-String, containing the current EAZ's/MSN's
337 ISDN_CMD_SETSIL: (currently unused)
339 With this command, the HL-driver is told to signal only incoming
340 calls with the given Service-Indicators.
344 command = ISDN_CMD_SETSIL
345 arg = channel-number locally to the driver. (starting with 0)
346 parm.num = ASCII-String, containing the desired Service-Indicators.
348 ISDN_CMD_GETSIL: (currently unused)
350 With this command, the HL-driver is told to return the current
351 Service-Indicators it will respond to.
355 command = ISDN_CMD_SETSIL
356 arg = channel-number locally to the driver. (starting with 0)
357 parm.num = ASCII-String, containing the current Service-Indicators.
361 With this command, the HL-driver is told to select the given Layer-2-
362 protocol. This command is issued by the LL prior to ISDN_CMD_DIAL or
368 command = ISDN_CMD_SETL2
369 arg = channel-number locally to the driver. (starting with 0)
370 logical or'ed with (protocol-Id << 8)
371 protocol-Id is one of the constants ISDN_PROTO_L2...
374 ISDN_CMD_GETL2: (currently unused)
376 With this command, the HL-driver is told to return the current
377 setting of the Layer-2-protocol.
381 command = ISDN_CMD_GETL2
382 arg = channel-number locally to the driver. (starting with 0)
385 current protocol-Id (one of the constants ISDN_L2_PROTO)
389 With this command, the HL-driver is told to select the given Layer-3-
390 protocol. This command is issued by the LL prior to ISDN_CMD_DIAL or
396 command = ISDN_CMD_SETL3
397 arg = channel-number locally to the driver. (starting with 0)
398 logical or'ed with (protocol-Id << 8)
399 protocol-Id is one of the constants ISDN_PROTO_L3...
400 parm.fax = Pointer to T30_s fax struct. (fax usage only)
402 ISDN_CMD_GETL2: (currently unused)
404 With this command, the HL-driver is told to return the current
405 setting of the Layer-3-protocol.
409 command = ISDN_CMD_GETL3
410 arg = channel-number locally to the driver. (starting with 0)
413 current protocol-Id (one of the constants ISDN_L3_PROTO)
417 With this command the HL-driver is told, that it will be used by the
418 LL and therefore may not be unloaded. The HL-driver should use
419 MOD_INC_USE_COUNT to tell that to the kernel.
423 command = ISDN_CMD_LOCK
429 With this command the HL-driver is told, that it is no more used by the
430 LL and therefore may be unloaded. The HL-driver should use
431 DEC_INC_USE_COUNT to tell that to the kernel.
435 command = ISDN_CMD_UNLOCK
441 With this command, the HL-driver is told to proceed with a incoming call.
445 command = ISDN_CMD_PROCEED
446 arg = channel-number locally to the driver. (starting with 0)
447 setup.eazmsn= empty string or string send as uus1 in DSS1 with
452 With this command, the HL-driver is told to alert a proceeding call.
456 command = ISDN_CMD_ALERT
457 arg = channel-number locally to the driver. (starting with 0)
458 setup.eazmsn= empty string or string send as uus1 in DSS1 with
463 With this command, the HL-driver is told to redirect a call in proceeding
468 command = ISDN_CMD_REDIR
469 arg = channel-number locally to the driver. (starting with 0)
470 setup.eazmsn= empty string or string send as uus1 in DSS1 protocol
471 setup.screen= screening indicator
472 setup.phone = redirected to party number
476 With this call, the LL-driver invokes protocol specific features through
478 The call is not implicitely bound to a connection.
482 command = ISDN_CMD_PROT_IO
483 arg = The lower 8 Bits define the adressed protocol as defined
484 in ISDN_PTYPE..., the upper bits are used to differenciate
485 the protocol specific CMD.
487 para = protocol and function specific. See isdnif.h for detail.
492 With this command the HL-driver receives a fax sub-command.
493 For details refer to INTERFACE.fax
497 command = ISDN_CMD_FAXCMD
498 arg = channel-number locally to the driver. (starting with 0)
502 3. Description of the events to be signaled by the HL-driver to the LL.
504 All status-changes are signaled via calling the previously described
505 function statcallb(). The field command of the struct isdn_cmd has
506 to be set by the HL-driver with the appropriate Status-Id (event-number).
507 The field arg has to be set to the channel-number (locally to the driver,
508 starting with 0) to which this event applies. (Exception: STAVAIL-event)
510 Until now, the following Status-Ids are defined:
514 With this call, the HL-driver signals the availability of new data
515 for readstat(). Used only for debugging-purposes, see description
520 command = ISDN_STAT_STAVAIL
521 arg = length of available data.
527 With this call, the HL-driver signals an incoming call to the LL.
528 If ICALLW is signalled the incoming call is a waiting call without
533 command = ISDN_STAT_ICALL
534 arg = channel-number, locally to the driver. (starting with 0)
535 para.setup.phone = Callernumber.
536 para.setup.eazmsn = CalledNumber.
537 para.setup.si1 = Service Indicator.
538 para.setup.si2 = Additional Service Indicator.
539 para.setup.plan = octet 3 from Calling party number Information Element.
540 para.setup.screen = octet 3a from Calling party number Information Element.
543 0 = No device matching this call.
544 1 = At least one device matching this call (RING on ttyI).
545 HL-driver may send ALERTING on the D-channel in this case.
546 2 = Call will be rejected.
547 3 = Incoming called party number is currently incomplete.
548 Additional digits are required.
549 Used for signalling with PtP connections.
550 4 = Call will be held in a proceeding state
551 (HL driver sends PROCEEDING)
552 Used when a user space prog needs time to interpret a call
553 para.setup.eazmsn may be filled with an uus1 message of
554 30 octets maximum. Empty string if no uus.
555 5 = Call will be actively deflected to another party
556 Only available in DSS1/EURO protocol
557 para.setup.phone must be set to destination party number
558 para.setup.eazmsn may be filled with an uus1 message of
559 30 octets maximum. Empty string if no uus.
560 -1 = An error happened. (Invalid parameters for example.)
561 The keypad support now is included in the dial command.
566 With this call, the HL-driver signals availability of the ISDN-card.
567 (after initializing, loading firmware)
571 command = ISDN_STAT_RUN
577 With this call, the HL-driver signals unavailability of the ISDN-card.
578 (before unloading, while resetting/reconfiguring the card)
582 command = ISDN_STAT_STOP
588 With this call, the HL-driver signals the successful establishment of
589 a D-Channel-connection. (Response to ISDN_CMD_ACCEPTD or ISDN_CMD_DIAL)
593 command = ISDN_STAT_DCONN
594 arg = channel-number, locally to the driver. (starting with 0)
599 With this call, the HL-driver signals the successful establishment of
600 a B-Channel-connection. (Response to ISDN_CMD_ACCEPTB or because the
601 remote-station has initiated establishment)
603 The HL driver should call this when the logical l2/l3 protocol
604 connection on top of the physical B-channel is established.
608 command = ISDN_STAT_BCONN
609 arg = channel-number, locally to the driver. (starting with 0)
610 parm.num = ASCII-String, containing type of connection (for analog
611 modem only). This will be appended to the CONNECT message
616 With this call, the HL-driver signals the shutdown of a
617 D-Channel-connection. This could be a response to a prior ISDN_CMD_HANGUP,
618 or caused by a remote-hangup or if the remote-station has actively
623 command = ISDN_STAT_DHUP
624 arg = channel-number, locally to the driver. (starting with 0)
629 With this call, the HL-driver signals the shutdown of a
630 B-Channel-connection. This could be a response to a prior ISDN_CMD_HANGUP,
631 or caused by a remote-hangup.
633 The HL driver should call this as soon as the logical l2/l3 protocol
634 connection on top of the physical B-channel is released.
638 command = ISDN_STAT_BHUP
639 arg = channel-number, locally to the driver. (starting with 0)
644 With this call, the HL-driver delivers charge-unit information to the
649 command = ISDN_STAT_CINF
650 arg = channel-number, locally to the driver. (starting with 0)
651 parm.num = ASCII string containing charge-units (digits only).
653 ISDN_STAT_LOAD: (currently unused)
657 With this call, the HL-driver signals that it will be unloaded now. This
658 tells the LL to release all corresponding data-structures.
662 command = ISDN_STAT_UNLOAD
668 With this call the HL-driver signals the delivery of a data-packet.
669 This callback is used by the network-interfaces only, tty-Emulation
670 does not need this call.
674 command = ISDN_STAT_BSENT
675 arg = channel-number, locally to the driver. (starting with 0)
676 parm.length = ***CHANGEI.1.21: New field.
677 the driver has to set this to the original length
678 of the skb at the time of receiving it from the linklevel.
682 With this call, the driver has to respond to a prior ISDN_CMD_DIAL, if
683 no D-Channel is available.
687 command = ISDN_STAT_NODCH
688 arg = channel-number, locally to the driver. (starting with 0)
693 This call is for HL-drivers, which are unable to check card-type
694 or numbers of supported channels before they have loaded any firmware
695 using ioctl. Those HL-driver simply set the channel-parameter to a
696 minimum channel-number when registering, and later if they know
697 the real amount, perform this call, allocating additional channels.
701 command = ISDN_STAT_ADDCH
702 arg = number of channels to be added.
707 With this call, the HL-driver delivers CAUSE-messages to the LL.
708 Currently the LL does not use this messages. Their contents is simply
709 logged via kernel-messages. Therefore, currently the format of the
710 messages is completely free. However they should be printable.
714 command = ISDN_STAT_NODCH
715 arg = channel-number, locally to the driver. (starting with 0)
716 parm.num = ASCII string containing CAUSE-message.
720 With this call, the HL-driver delivers DISPLAY-messages to the LL.
721 Currently the LL does not use this messages.
725 command = ISDN_STAT_DISPLAY
726 arg = channel-number, locally to the driver. (starting with 0)
727 para.display= string containing DISPLAY-message.
731 With this call, the HL-driver delivers protocol specific infos to the LL.
732 The call is not implicitely bound to a connection.
736 command = ISDN_STAT_PROT
737 arg = The lower 8 Bits define the adressed protocol as defined
738 in ISDN_PTYPE..., the upper bits are used to differenciate
739 the protocol specific STAT.
741 para = protocol and function specific. See isdnif.h for detail.
745 With this call, the HL-driver signals the LL to disable or enable the
746 use of supplied channel and driver.
747 The call may be used to reduce the available number of B-channels after
748 loading the driver. The LL has to ignore a disabled channel when searching
749 for free channels. The HL driver itself never delivers STAT callbacks for
751 The LL returns a nonzero code if the operation was not successfull or the
752 selected channel is actually regarded as busy.
756 command = ISDN_STAT_DISCH
757 arg = channel-number, locally to the driver. (starting with 0)
758 parm.num[0] = 0 if channel shall be disabled, else enabled.
762 ***CHANGEI1.21 new status message.
763 A signal can be sent to the linklevel if an Layer1-error results in
764 packet-loss on receive or send. The field errcode of the cmd.parm
765 union describes the error more precisely.
769 command = ISDN_STAT_L1ERR
770 arg = channel-number, locally to the driver. (starting with 0)
771 parm.errcode= ISDN_STAT_L1ERR_SEND: Packet lost while sending.
772 ISDN_STAT_L1ERR_RECV: Packet lost while receiving.
775 With this call the HL-driver signals a fax sub-command to the LL.
776 For details refer to INTERFACE.fax
780 command = ISDN_STAT_FAXIND
781 arg = channel-number, locally to the driver. (starting with 0)