3 * Author Karsten Keil <kkeil@novell.com>
5 * Copyright 2008 by Karsten Keil <kkeil@novell.com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
18 #include <linux/mISDNif.h>
26 struct Fsm l2fsm
= {NULL
, 0, 0, NULL
, NULL
};
28 static char *strL2State
[] =
52 EV_L2_DL_ESTABLISH_REQ
,
65 #define L2_EVENT_COUNT (EV_L2_FRAME_ERROR+1)
67 static char *strL2Event
[] =
80 "EV_L2_DL_ESTABLISH_REQ",
81 "EV_L2_DL_RELEASE_REQ",
89 "EV_L2_CLEAR_OWN_BUSY",
94 l2m_debug(struct FsmInst
*fi
, char *fmt
, ...)
96 struct layer2
*l2
= fi
->userdata
;
99 if (!(*debug
& DEBUG_L2_FSM
))
102 printk(KERN_DEBUG
"l2 (sapi %d tei %d): ", l2
->sapi
, l2
->tei
);
109 l2headersize(struct layer2
*l2
, int ui
)
111 return ((test_bit(FLG_MOD128
, &l2
->flag
) && (!ui
)) ? 2 : 1) +
112 (test_bit(FLG_LAPD
, &l2
->flag
) ? 2 : 1);
116 l2addrsize(struct layer2
*l2
)
118 return test_bit(FLG_LAPD
, &l2
->flag
) ? 2 : 1;
122 l2_newid(struct layer2
*l2
)
136 l2up(struct layer2
*l2
, u_int prim
, struct sk_buff
*skb
)
142 mISDN_HEAD_PRIM(skb
) = prim
;
143 mISDN_HEAD_ID(skb
) = (l2
->ch
.nr
<< 16) | l2
->ch
.addr
;
144 err
= l2
->up
->send(l2
->up
, skb
);
146 printk(KERN_WARNING
"%s: err=%d\n", __func__
, err
);
152 l2up_create(struct layer2
*l2
, u_int prim
, int len
, void *arg
)
155 struct mISDNhead
*hh
;
160 skb
= mI_alloc_skb(len
, GFP_ATOMIC
);
163 hh
= mISDN_HEAD_P(skb
);
165 hh
->id
= (l2
->ch
.nr
<< 16) | l2
->ch
.addr
;
167 memcpy(skb_put(skb
, len
), arg
, len
);
168 err
= l2
->up
->send(l2
->up
, skb
);
170 printk(KERN_WARNING
"%s: err=%d\n", __func__
, err
);
176 l2down_skb(struct layer2
*l2
, struct sk_buff
*skb
) {
179 ret
= l2
->ch
.recv(l2
->ch
.peer
, skb
);
180 if (ret
&& (*debug
& DEBUG_L2_RECV
))
181 printk(KERN_DEBUG
"l2down_skb: ret(%d)\n", ret
);
186 l2down_raw(struct layer2
*l2
, struct sk_buff
*skb
)
188 struct mISDNhead
*hh
= mISDN_HEAD_P(skb
);
190 if (hh
->prim
== PH_DATA_REQ
) {
191 if (test_and_set_bit(FLG_L1_NOTREADY
, &l2
->flag
)) {
192 skb_queue_tail(&l2
->down_queue
, skb
);
195 l2
->down_id
= mISDN_HEAD_ID(skb
);
197 return l2down_skb(l2
, skb
);
201 l2down(struct layer2
*l2
, u_int prim
, u_int id
, struct sk_buff
*skb
)
203 struct mISDNhead
*hh
= mISDN_HEAD_P(skb
);
207 return l2down_raw(l2
, skb
);
211 l2down_create(struct layer2
*l2
, u_int prim
, u_int id
, int len
, void *arg
)
215 struct mISDNhead
*hh
;
217 skb
= mI_alloc_skb(len
, GFP_ATOMIC
);
220 hh
= mISDN_HEAD_P(skb
);
224 memcpy(skb_put(skb
, len
), arg
, len
);
225 err
= l2down_raw(l2
, skb
);
232 ph_data_confirm(struct layer2
*l2
, struct mISDNhead
*hh
, struct sk_buff
*skb
) {
233 struct sk_buff
*nskb
= skb
;
236 if (test_bit(FLG_L1_NOTREADY
, &l2
->flag
)) {
237 if (hh
->id
== l2
->down_id
) {
238 nskb
= skb_dequeue(&l2
->down_queue
);
240 l2
->down_id
= mISDN_HEAD_ID(nskb
);
241 if (l2down_skb(l2
, nskb
)) {
243 l2
->down_id
= MISDN_ID_NONE
;
246 l2
->down_id
= MISDN_ID_NONE
;
251 if (l2
->down_id
== MISDN_ID_NONE
) {
252 test_and_clear_bit(FLG_L1_NOTREADY
, &l2
->flag
);
253 mISDN_FsmEvent(&l2
->l2m
, EV_L2_ACK_PULL
, NULL
);
257 if (!test_and_set_bit(FLG_L1_NOTREADY
, &l2
->flag
)) {
258 nskb
= skb_dequeue(&l2
->down_queue
);
260 l2
->down_id
= mISDN_HEAD_ID(nskb
);
261 if (l2down_skb(l2
, nskb
)) {
263 l2
->down_id
= MISDN_ID_NONE
;
264 test_and_clear_bit(FLG_L1_NOTREADY
, &l2
->flag
);
267 test_and_clear_bit(FLG_L1_NOTREADY
, &l2
->flag
);
273 l2mgr(struct layer2
*l2
, u_int prim
, void *arg
) {
277 "l2mgr: addr:%x prim %x %c\n", l2
->id
, prim
, (char)c
);
278 if (test_bit(FLG_LAPD
, &l2
->flag
) &&
279 !test_bit(FLG_FIXED_TEI
, &l2
->flag
)) {
285 l2_tei(l2
, prim
, (u_long
)arg
);
293 set_peer_busy(struct layer2
*l2
) {
294 test_and_set_bit(FLG_PEER_BUSY
, &l2
->flag
);
295 if (skb_queue_len(&l2
->i_queue
) || skb_queue_len(&l2
->ui_queue
))
296 test_and_set_bit(FLG_L2BLOCK
, &l2
->flag
);
300 clear_peer_busy(struct layer2
*l2
) {
301 if (test_and_clear_bit(FLG_PEER_BUSY
, &l2
->flag
))
302 test_and_clear_bit(FLG_L2BLOCK
, &l2
->flag
);
306 InitWin(struct layer2
*l2
)
310 for (i
= 0; i
< MAX_WINDOW
; i
++)
311 l2
->windowar
[i
] = NULL
;
315 freewin(struct layer2
*l2
)
319 for (i
= 0; i
< MAX_WINDOW
; i
++) {
320 if (l2
->windowar
[i
]) {
322 dev_kfree_skb(l2
->windowar
[i
]);
323 l2
->windowar
[i
] = NULL
;
330 ReleaseWin(struct layer2
*l2
)
332 int cnt
= freewin(l2
);
336 "isdnl2 freed %d skbuffs in release\n", cnt
);
340 cansend(struct layer2
*l2
)
344 if (test_bit(FLG_MOD128
, &l2
->flag
))
345 p1
= (l2
->vs
- l2
->va
) % 128;
347 p1
= (l2
->vs
- l2
->va
) % 8;
348 return (p1
< l2
->window
) && !test_bit(FLG_PEER_BUSY
, &l2
->flag
);
352 clear_exception(struct layer2
*l2
)
354 test_and_clear_bit(FLG_ACK_PEND
, &l2
->flag
);
355 test_and_clear_bit(FLG_REJEXC
, &l2
->flag
);
356 test_and_clear_bit(FLG_OWN_BUSY
, &l2
->flag
);
361 sethdraddr(struct layer2
*l2
, u_char
*header
, int rsp
)
363 u_char
*ptr
= header
;
366 if (test_bit(FLG_LAPD
, &l2
->flag
)) {
367 if (test_bit(FLG_LAPD_NET
, &l2
->flag
))
369 *ptr
++ = (l2
->sapi
<< 2) | (crbit
? 2 : 0);
370 *ptr
++ = (l2
->tei
<< 1) | 1;
373 if (test_bit(FLG_ORIG
, &l2
->flag
))
384 enqueue_super(struct layer2
*l2
, struct sk_buff
*skb
)
386 if (l2down(l2
, PH_DATA_REQ
, l2_newid(l2
), skb
))
391 enqueue_ui(struct layer2
*l2
, struct sk_buff
*skb
)
394 l2_tei(l2
, MDL_STATUS_UI_IND
, 0);
395 if (l2down(l2
, PH_DATA_REQ
, l2_newid(l2
), skb
))
402 return (data
[0] & 0xef) == UI
;
408 return (data
[0] & 0xef) == UA
;
414 return (data
[0] & 0xef) == DM
;
420 return (data
[0] & 0xef) == DISC
;
424 IsRR(u_char
*data
, struct layer2
*l2
)
426 if (test_bit(FLG_MOD128
, &l2
->flag
))
427 return data
[0] == RR
;
429 return (data
[0] & 0xf) == 1;
433 IsSFrame(u_char
*data
, struct layer2
*l2
)
435 register u_char d
= *data
;
437 if (!test_bit(FLG_MOD128
, &l2
->flag
))
439 return ((d
& 0xf3) == 1) && ((d
& 0x0c) != 0x0c);
443 IsSABME(u_char
*data
, struct layer2
*l2
)
445 u_char d
= data
[0] & ~0x10;
447 return test_bit(FLG_MOD128
, &l2
->flag
) ? d
== SABME
: d
== SABM
;
451 IsREJ(u_char
*data
, struct layer2
*l2
)
453 return test_bit(FLG_MOD128
, &l2
->flag
) ?
454 data
[0] == REJ
: (data
[0] & 0xf) == REJ
;
460 return (data
[0] & 0xef) == FRMR
;
464 IsRNR(u_char
*data
, struct layer2
*l2
)
466 return test_bit(FLG_MOD128
, &l2
->flag
) ?
467 data
[0] == RNR
: (data
[0] & 0xf) == RNR
;
471 iframe_error(struct layer2
*l2
, struct sk_buff
*skb
)
474 int rsp
= *skb
->data
& 0x2;
476 i
= l2addrsize(l2
) + (test_bit(FLG_MOD128
, &l2
->flag
) ? 2 : 1);
477 if (test_bit(FLG_ORIG
, &l2
->flag
))
483 if ((skb
->len
- i
) > l2
->maxlen
)
489 super_error(struct layer2
*l2
, struct sk_buff
*skb
)
491 if (skb
->len
!= l2addrsize(l2
) +
492 (test_bit(FLG_MOD128
, &l2
->flag
) ? 2 : 1))
498 unnum_error(struct layer2
*l2
, struct sk_buff
*skb
, int wantrsp
)
500 int rsp
= (*skb
->data
& 0x2) >> 1;
501 if (test_bit(FLG_ORIG
, &l2
->flag
))
505 if (skb
->len
!= l2addrsize(l2
) + 1)
511 UI_error(struct layer2
*l2
, struct sk_buff
*skb
)
513 int rsp
= *skb
->data
& 0x2;
514 if (test_bit(FLG_ORIG
, &l2
->flag
))
518 if (skb
->len
> l2
->maxlen
+ l2addrsize(l2
) + 1)
524 FRMR_error(struct layer2
*l2
, struct sk_buff
*skb
)
526 u_int headers
= l2addrsize(l2
) + 1;
527 u_char
*datap
= skb
->data
+ headers
;
528 int rsp
= *skb
->data
& 0x2;
530 if (test_bit(FLG_ORIG
, &l2
->flag
))
534 if (test_bit(FLG_MOD128
, &l2
->flag
)) {
535 if (skb
->len
< headers
+ 5)
537 else if (*debug
& DEBUG_L2
)
539 "FRMR information %2x %2x %2x %2x %2x",
540 datap
[0], datap
[1], datap
[2], datap
[3], datap
[4]);
542 if (skb
->len
< headers
+ 3)
544 else if (*debug
& DEBUG_L2
)
546 "FRMR information %2x %2x %2x",
547 datap
[0], datap
[1], datap
[2]);
553 legalnr(struct layer2
*l2
, unsigned int nr
)
555 if (test_bit(FLG_MOD128
, &l2
->flag
))
556 return ((nr
- l2
->va
) % 128) <= ((l2
->vs
- l2
->va
) % 128);
558 return ((nr
- l2
->va
) % 8) <= ((l2
->vs
- l2
->va
) % 8);
562 setva(struct layer2
*l2
, unsigned int nr
)
566 while (l2
->va
!= nr
) {
568 if (test_bit(FLG_MOD128
, &l2
->flag
))
572 if (l2
->windowar
[l2
->sow
]) {
573 skb_trim(l2
->windowar
[l2
->sow
], 0);
574 skb_queue_tail(&l2
->tmp_queue
, l2
->windowar
[l2
->sow
]);
575 l2
->windowar
[l2
->sow
] = NULL
;
577 l2
->sow
= (l2
->sow
+ 1) % l2
->window
;
579 skb
= skb_dequeue(&l2
->tmp_queue
);
582 skb
= skb_dequeue(&l2
->tmp_queue
);
587 send_uframe(struct layer2
*l2
, struct sk_buff
*skb
, u_char cmd
, u_char cr
)
589 u_char tmp
[MAX_L2HEADER_LEN
];
592 i
= sethdraddr(l2
, tmp
, cr
);
597 skb
= mI_alloc_skb(i
, GFP_ATOMIC
);
599 printk(KERN_WARNING
"%s: can't alloc skbuff\n",
604 memcpy(skb_put(skb
, i
), tmp
, i
);
605 enqueue_super(l2
, skb
);
610 get_PollFlag(struct layer2
*l2
, struct sk_buff
*skb
)
612 return skb
->data
[l2addrsize(l2
)] & 0x10;
616 get_PollFlagFree(struct layer2
*l2
, struct sk_buff
*skb
)
620 PF
= get_PollFlag(l2
, skb
);
626 start_t200(struct layer2
*l2
, int i
)
628 mISDN_FsmAddTimer(&l2
->t200
, l2
->T200
, EV_L2_T200
, NULL
, i
);
629 test_and_set_bit(FLG_T200_RUN
, &l2
->flag
);
633 restart_t200(struct layer2
*l2
, int i
)
635 mISDN_FsmRestartTimer(&l2
->t200
, l2
->T200
, EV_L2_T200
, NULL
, i
);
636 test_and_set_bit(FLG_T200_RUN
, &l2
->flag
);
640 stop_t200(struct layer2
*l2
, int i
)
642 if (test_and_clear_bit(FLG_T200_RUN
, &l2
->flag
))
643 mISDN_FsmDelTimer(&l2
->t200
, i
);
647 st5_dl_release_l2l3(struct layer2
*l2
)
651 if (test_and_clear_bit(FLG_PEND_REL
, &l2
->flag
))
655 l2up_create(l2
, pr
, 0, NULL
);
659 lapb_dl_release_l2l3(struct layer2
*l2
, int f
)
661 if (test_bit(FLG_LAPB
, &l2
->flag
))
662 l2down_create(l2
, PH_DEACTIVATE_REQ
, l2_newid(l2
), 0, NULL
);
663 l2up_create(l2
, f
, 0, NULL
);
667 establishlink(struct FsmInst
*fi
)
669 struct layer2
*l2
= fi
->userdata
;
674 cmd
= (test_bit(FLG_MOD128
, &l2
->flag
) ? SABME
: SABM
) | 0x10;
675 send_uframe(l2
, NULL
, cmd
, CMD
);
676 mISDN_FsmDelTimer(&l2
->t203
, 1);
678 test_and_clear_bit(FLG_PEND_REL
, &l2
->flag
);
680 mISDN_FsmChangeState(fi
, ST_L2_5
);
684 l2_mdl_error_ua(struct FsmInst
*fi
, int event
, void *arg
)
686 struct sk_buff
*skb
= arg
;
687 struct layer2
*l2
= fi
->userdata
;
689 if (get_PollFlagFree(l2
, skb
))
690 l2mgr(l2
, MDL_ERROR_IND
, (void *) 'C');
692 l2mgr(l2
, MDL_ERROR_IND
, (void *) 'D');
697 l2_mdl_error_dm(struct FsmInst
*fi
, int event
, void *arg
)
699 struct sk_buff
*skb
= arg
;
700 struct layer2
*l2
= fi
->userdata
;
702 if (get_PollFlagFree(l2
, skb
))
703 l2mgr(l2
, MDL_ERROR_IND
, (void *) 'B');
705 l2mgr(l2
, MDL_ERROR_IND
, (void *) 'E');
707 test_and_clear_bit(FLG_L3_INIT
, &l2
->flag
);
712 l2_st8_mdl_error_dm(struct FsmInst
*fi
, int event
, void *arg
)
714 struct sk_buff
*skb
= arg
;
715 struct layer2
*l2
= fi
->userdata
;
717 if (get_PollFlagFree(l2
, skb
))
718 l2mgr(l2
, MDL_ERROR_IND
, (void *) 'B');
720 l2mgr(l2
, MDL_ERROR_IND
, (void *) 'E');
722 test_and_clear_bit(FLG_L3_INIT
, &l2
->flag
);
726 l2_go_st3(struct FsmInst
*fi
, int event
, void *arg
)
728 dev_kfree_skb((struct sk_buff
*)arg
);
729 mISDN_FsmChangeState(fi
, ST_L2_3
);
733 l2_mdl_assign(struct FsmInst
*fi
, int event
, void *arg
)
735 struct layer2
*l2
= fi
->userdata
;
737 mISDN_FsmChangeState(fi
, ST_L2_3
);
738 dev_kfree_skb((struct sk_buff
*)arg
);
739 l2_tei(l2
, MDL_ASSIGN_IND
, 0);
743 l2_queue_ui_assign(struct FsmInst
*fi
, int event
, void *arg
)
745 struct layer2
*l2
= fi
->userdata
;
746 struct sk_buff
*skb
= arg
;
748 skb_queue_tail(&l2
->ui_queue
, skb
);
749 mISDN_FsmChangeState(fi
, ST_L2_2
);
750 l2_tei(l2
, MDL_ASSIGN_IND
, 0);
754 l2_queue_ui(struct FsmInst
*fi
, int event
, void *arg
)
756 struct layer2
*l2
= fi
->userdata
;
757 struct sk_buff
*skb
= arg
;
759 skb_queue_tail(&l2
->ui_queue
, skb
);
763 tx_ui(struct layer2
*l2
)
766 u_char header
[MAX_L2HEADER_LEN
];
769 i
= sethdraddr(l2
, header
, CMD
);
770 if (test_bit(FLG_LAPD_NET
, &l2
->flag
))
771 header
[1] = 0xff; /* tei 127 */
773 while ((skb
= skb_dequeue(&l2
->ui_queue
))) {
774 memcpy(skb_push(skb
, i
), header
, i
);
780 l2_send_ui(struct FsmInst
*fi
, int event
, void *arg
)
782 struct layer2
*l2
= fi
->userdata
;
783 struct sk_buff
*skb
= arg
;
785 skb_queue_tail(&l2
->ui_queue
, skb
);
790 l2_got_ui(struct FsmInst
*fi
, int event
, void *arg
)
792 struct layer2
*l2
= fi
->userdata
;
793 struct sk_buff
*skb
= arg
;
795 skb_pull(skb
, l2headersize(l2
, 1));
797 * in states 1-3 for broadcast
801 l2_tei(l2
, MDL_STATUS_UI_IND
, 0);
802 l2up(l2
, DL_UNITDATA_IND
, skb
);
806 l2_establish(struct FsmInst
*fi
, int event
, void *arg
)
808 struct sk_buff
*skb
= arg
;
809 struct layer2
*l2
= fi
->userdata
;
812 test_and_set_bit(FLG_L3_INIT
, &l2
->flag
);
817 l2_discard_i_setl3(struct FsmInst
*fi
, int event
, void *arg
)
819 struct sk_buff
*skb
= arg
;
820 struct layer2
*l2
= fi
->userdata
;
822 skb_queue_purge(&l2
->i_queue
);
823 test_and_set_bit(FLG_L3_INIT
, &l2
->flag
);
824 test_and_clear_bit(FLG_PEND_REL
, &l2
->flag
);
829 l2_l3_reestablish(struct FsmInst
*fi
, int event
, void *arg
)
831 struct sk_buff
*skb
= arg
;
832 struct layer2
*l2
= fi
->userdata
;
834 skb_queue_purge(&l2
->i_queue
);
836 test_and_set_bit(FLG_L3_INIT
, &l2
->flag
);
841 l2_release(struct FsmInst
*fi
, int event
, void *arg
)
843 struct layer2
*l2
= fi
->userdata
;
844 struct sk_buff
*skb
= arg
;
847 l2up(l2
, DL_RELEASE_CNF
, skb
);
851 l2_pend_rel(struct FsmInst
*fi
, int event
, void *arg
)
853 struct sk_buff
*skb
= arg
;
854 struct layer2
*l2
= fi
->userdata
;
856 test_and_set_bit(FLG_PEND_REL
, &l2
->flag
);
861 l2_disconnect(struct FsmInst
*fi
, int event
, void *arg
)
863 struct layer2
*l2
= fi
->userdata
;
864 struct sk_buff
*skb
= arg
;
866 skb_queue_purge(&l2
->i_queue
);
868 mISDN_FsmChangeState(fi
, ST_L2_6
);
870 send_uframe(l2
, NULL
, DISC
| 0x10, CMD
);
871 mISDN_FsmDelTimer(&l2
->t203
, 1);
878 l2_start_multi(struct FsmInst
*fi
, int event
, void *arg
)
880 struct layer2
*l2
= fi
->userdata
;
881 struct sk_buff
*skb
= arg
;
888 send_uframe(l2
, NULL
, UA
| get_PollFlag(l2
, skb
), RSP
);
889 mISDN_FsmChangeState(fi
, ST_L2_7
);
890 mISDN_FsmAddTimer(&l2
->t203
, l2
->T203
, EV_L2_T203
, NULL
, 3);
892 l2up(l2
, DL_ESTABLISH_IND
, skb
);
894 l2_tei(l2
, MDL_STATUS_UP_IND
, 0);
898 l2_send_UA(struct FsmInst
*fi
, int event
, void *arg
)
900 struct layer2
*l2
= fi
->userdata
;
901 struct sk_buff
*skb
= arg
;
903 send_uframe(l2
, skb
, UA
| get_PollFlag(l2
, skb
), RSP
);
907 l2_send_DM(struct FsmInst
*fi
, int event
, void *arg
)
909 struct layer2
*l2
= fi
->userdata
;
910 struct sk_buff
*skb
= arg
;
912 send_uframe(l2
, skb
, DM
| get_PollFlag(l2
, skb
), RSP
);
916 l2_restart_multi(struct FsmInst
*fi
, int event
, void *arg
)
918 struct layer2
*l2
= fi
->userdata
;
919 struct sk_buff
*skb
= arg
;
922 send_uframe(l2
, skb
, UA
| get_PollFlag(l2
, skb
), RSP
);
924 l2mgr(l2
, MDL_ERROR_IND
, (void *) 'F');
926 if (l2
->vs
!= l2
->va
) {
927 skb_queue_purge(&l2
->i_queue
);
936 mISDN_FsmChangeState(fi
, ST_L2_7
);
938 mISDN_FsmRestartTimer(&l2
->t203
, l2
->T203
, EV_L2_T203
, NULL
, 3);
941 l2up_create(l2
, DL_ESTABLISH_IND
, 0, NULL
);
942 /* mISDN_queue_data(&l2->inst, l2->inst.id | MSG_BROADCAST,
943 * MGR_SHORTSTATUS | INDICATION, SSTATUS_L2_ESTABLISHED,
946 if (skb_queue_len(&l2
->i_queue
) && cansend(l2
))
947 mISDN_FsmEvent(fi
, EV_L2_ACK_PULL
, NULL
);
951 l2_stop_multi(struct FsmInst
*fi
, int event
, void *arg
)
953 struct layer2
*l2
= fi
->userdata
;
954 struct sk_buff
*skb
= arg
;
956 mISDN_FsmChangeState(fi
, ST_L2_4
);
957 mISDN_FsmDelTimer(&l2
->t203
, 3);
960 send_uframe(l2
, skb
, UA
| get_PollFlag(l2
, skb
), RSP
);
961 skb_queue_purge(&l2
->i_queue
);
963 lapb_dl_release_l2l3(l2
, DL_RELEASE_IND
);
965 l2_tei(l2
, MDL_STATUS_DOWN_IND
, 0);
969 l2_connected(struct FsmInst
*fi
, int event
, void *arg
)
971 struct layer2
*l2
= fi
->userdata
;
972 struct sk_buff
*skb
= arg
;
975 if (!get_PollFlag(l2
, skb
)) {
976 l2_mdl_error_ua(fi
, event
, arg
);
980 if (test_and_clear_bit(FLG_PEND_REL
, &l2
->flag
))
981 l2_disconnect(fi
, event
, NULL
);
982 if (test_and_clear_bit(FLG_L3_INIT
, &l2
->flag
)) {
983 pr
= DL_ESTABLISH_CNF
;
984 } else if (l2
->vs
!= l2
->va
) {
985 skb_queue_purge(&l2
->i_queue
);
986 pr
= DL_ESTABLISH_IND
;
993 mISDN_FsmChangeState(fi
, ST_L2_7
);
994 mISDN_FsmAddTimer(&l2
->t203
, l2
->T203
, EV_L2_T203
, NULL
, 4);
996 l2up_create(l2
, pr
, 0, NULL
);
998 if (skb_queue_len(&l2
->i_queue
) && cansend(l2
))
999 mISDN_FsmEvent(fi
, EV_L2_ACK_PULL
, NULL
);
1002 l2_tei(l2
, MDL_STATUS_UP_IND
, 0);
1006 l2_released(struct FsmInst
*fi
, int event
, void *arg
)
1008 struct layer2
*l2
= fi
->userdata
;
1009 struct sk_buff
*skb
= arg
;
1011 if (!get_PollFlag(l2
, skb
)) {
1012 l2_mdl_error_ua(fi
, event
, arg
);
1017 lapb_dl_release_l2l3(l2
, DL_RELEASE_CNF
);
1018 mISDN_FsmChangeState(fi
, ST_L2_4
);
1020 l2_tei(l2
, MDL_STATUS_DOWN_IND
, 0);
1024 l2_reestablish(struct FsmInst
*fi
, int event
, void *arg
)
1026 struct layer2
*l2
= fi
->userdata
;
1027 struct sk_buff
*skb
= arg
;
1029 if (!get_PollFlagFree(l2
, skb
)) {
1031 test_and_set_bit(FLG_L3_INIT
, &l2
->flag
);
1036 l2_st5_dm_release(struct FsmInst
*fi
, int event
, void *arg
)
1038 struct layer2
*l2
= fi
->userdata
;
1039 struct sk_buff
*skb
= arg
;
1041 if (get_PollFlagFree(l2
, skb
)) {
1043 if (!test_bit(FLG_L3_INIT
, &l2
->flag
))
1044 skb_queue_purge(&l2
->i_queue
);
1045 if (test_bit(FLG_LAPB
, &l2
->flag
))
1046 l2down_create(l2
, PH_DEACTIVATE_REQ
,
1047 l2_newid(l2
), 0, NULL
);
1048 st5_dl_release_l2l3(l2
);
1049 mISDN_FsmChangeState(fi
, ST_L2_4
);
1051 l2_tei(l2
, MDL_STATUS_DOWN_IND
, 0);
1056 l2_st6_dm_release(struct FsmInst
*fi
, int event
, void *arg
)
1058 struct layer2
*l2
= fi
->userdata
;
1059 struct sk_buff
*skb
= arg
;
1061 if (get_PollFlagFree(l2
, skb
)) {
1063 lapb_dl_release_l2l3(l2
, DL_RELEASE_CNF
);
1064 mISDN_FsmChangeState(fi
, ST_L2_4
);
1066 l2_tei(l2
, MDL_STATUS_DOWN_IND
, 0);
1071 enquiry_cr(struct layer2
*l2
, u_char typ
, u_char cr
, u_char pf
)
1073 struct sk_buff
*skb
;
1074 u_char tmp
[MAX_L2HEADER_LEN
];
1077 i
= sethdraddr(l2
, tmp
, cr
);
1078 if (test_bit(FLG_MOD128
, &l2
->flag
)) {
1080 tmp
[i
++] = (l2
->vr
<< 1) | (pf
? 1 : 0);
1082 tmp
[i
++] = (l2
->vr
<< 5) | typ
| (pf
? 0x10 : 0);
1083 skb
= mI_alloc_skb(i
, GFP_ATOMIC
);
1086 "isdnl2 can't alloc sbbuff for enquiry_cr\n");
1089 memcpy(skb_put(skb
, i
), tmp
, i
);
1090 enqueue_super(l2
, skb
);
1094 enquiry_response(struct layer2
*l2
)
1096 if (test_bit(FLG_OWN_BUSY
, &l2
->flag
))
1097 enquiry_cr(l2
, RNR
, RSP
, 1);
1099 enquiry_cr(l2
, RR
, RSP
, 1);
1100 test_and_clear_bit(FLG_ACK_PEND
, &l2
->flag
);
1104 transmit_enquiry(struct layer2
*l2
)
1106 if (test_bit(FLG_OWN_BUSY
, &l2
->flag
))
1107 enquiry_cr(l2
, RNR
, CMD
, 1);
1109 enquiry_cr(l2
, RR
, CMD
, 1);
1110 test_and_clear_bit(FLG_ACK_PEND
, &l2
->flag
);
1116 nrerrorrecovery(struct FsmInst
*fi
)
1118 struct layer2
*l2
= fi
->userdata
;
1120 l2mgr(l2
, MDL_ERROR_IND
, (void *) 'J');
1122 test_and_clear_bit(FLG_L3_INIT
, &l2
->flag
);
1126 invoke_retransmission(struct layer2
*l2
, unsigned int nr
)
1131 while (l2
->vs
!= nr
) {
1133 if (test_bit(FLG_MOD128
, &l2
->flag
)) {
1135 p1
= (l2
->vs
- l2
->va
) % 128;
1138 p1
= (l2
->vs
- l2
->va
) % 8;
1140 p1
= (p1
+ l2
->sow
) % l2
->window
;
1141 if (l2
->windowar
[p1
])
1142 skb_queue_head(&l2
->i_queue
, l2
->windowar
[p1
]);
1145 "%s: windowar[%d] is NULL\n",
1147 l2
->windowar
[p1
] = NULL
;
1149 mISDN_FsmEvent(&l2
->l2m
, EV_L2_ACK_PULL
, NULL
);
1154 l2_st7_got_super(struct FsmInst
*fi
, int event
, void *arg
)
1156 struct layer2
*l2
= fi
->userdata
;
1157 struct sk_buff
*skb
= arg
;
1158 int PollFlag
, rsp
, typ
= RR
;
1161 rsp
= *skb
->data
& 0x2;
1162 if (test_bit(FLG_ORIG
, &l2
->flag
))
1165 skb_pull(skb
, l2addrsize(l2
));
1166 if (IsRNR(skb
->data
, l2
)) {
1170 clear_peer_busy(l2
);
1171 if (IsREJ(skb
->data
, l2
))
1174 if (test_bit(FLG_MOD128
, &l2
->flag
)) {
1175 PollFlag
= (skb
->data
[1] & 0x1) == 0x1;
1176 nr
= skb
->data
[1] >> 1;
1178 PollFlag
= (skb
->data
[0] & 0x10);
1179 nr
= (skb
->data
[0] >> 5) & 0x7;
1185 l2mgr(l2
, MDL_ERROR_IND
, (void *) 'A');
1187 enquiry_response(l2
);
1189 if (legalnr(l2
, nr
)) {
1192 invoke_retransmission(l2
, nr
);
1194 if (mISDN_FsmAddTimer(&l2
->t203
, l2
->T203
,
1195 EV_L2_T203
, NULL
, 6))
1196 l2m_debug(&l2
->l2m
, "Restart T203 ST7 REJ");
1197 } else if ((nr
== l2
->vs
) && (typ
== RR
)) {
1200 mISDN_FsmRestartTimer(&l2
->t203
, l2
->T203
,
1201 EV_L2_T203
, NULL
, 7);
1202 } else if ((l2
->va
!= nr
) || (typ
== RNR
)) {
1205 mISDN_FsmDelTimer(&l2
->t203
, 9);
1206 restart_t200(l2
, 12);
1208 if (skb_queue_len(&l2
->i_queue
) && (typ
== RR
))
1209 mISDN_FsmEvent(fi
, EV_L2_ACK_PULL
, NULL
);
1211 nrerrorrecovery(fi
);
1215 l2_feed_i_if_reest(struct FsmInst
*fi
, int event
, void *arg
)
1217 struct layer2
*l2
= fi
->userdata
;
1218 struct sk_buff
*skb
= arg
;
1220 if (!test_bit(FLG_L3_INIT
, &l2
->flag
))
1221 skb_queue_tail(&l2
->i_queue
, skb
);
1227 l2_feed_i_pull(struct FsmInst
*fi
, int event
, void *arg
)
1229 struct layer2
*l2
= fi
->userdata
;
1230 struct sk_buff
*skb
= arg
;
1232 skb_queue_tail(&l2
->i_queue
, skb
);
1233 mISDN_FsmEvent(fi
, EV_L2_ACK_PULL
, NULL
);
1237 l2_feed_iqueue(struct FsmInst
*fi
, int event
, void *arg
)
1239 struct layer2
*l2
= fi
->userdata
;
1240 struct sk_buff
*skb
= arg
;
1242 skb_queue_tail(&l2
->i_queue
, skb
);
1246 l2_got_iframe(struct FsmInst
*fi
, int event
, void *arg
)
1248 struct layer2
*l2
= fi
->userdata
;
1249 struct sk_buff
*skb
= arg
;
1254 if (test_bit(FLG_MOD128
, &l2
->flag
)) {
1255 PollFlag
= ((skb
->data
[i
+ 1] & 0x1) == 0x1);
1256 ns
= skb
->data
[i
] >> 1;
1257 nr
= (skb
->data
[i
+ 1] >> 1) & 0x7f;
1259 PollFlag
= (skb
->data
[i
] & 0x10);
1260 ns
= (skb
->data
[i
] >> 1) & 0x7;
1261 nr
= (skb
->data
[i
] >> 5) & 0x7;
1263 if (test_bit(FLG_OWN_BUSY
, &l2
->flag
)) {
1266 enquiry_response(l2
);
1270 if (test_bit(FLG_MOD128
, &l2
->flag
))
1274 test_and_clear_bit(FLG_REJEXC
, &l2
->flag
);
1276 enquiry_response(l2
);
1278 test_and_set_bit(FLG_ACK_PEND
, &l2
->flag
);
1279 skb_pull(skb
, l2headersize(l2
, 0));
1280 l2up(l2
, DL_DATA_IND
, skb
);
1284 if (test_and_set_bit(FLG_REJEXC
, &l2
->flag
)) {
1286 enquiry_response(l2
);
1288 enquiry_cr(l2
, REJ
, RSP
, PollFlag
);
1289 test_and_clear_bit(FLG_ACK_PEND
, &l2
->flag
);
1293 if (legalnr(l2
, nr
)) {
1294 if (!test_bit(FLG_PEER_BUSY
, &l2
->flag
) &&
1295 (fi
->state
== ST_L2_7
)) {
1298 mISDN_FsmRestartTimer(&l2
->t203
, l2
->T203
,
1299 EV_L2_T203
, NULL
, 7);
1300 } else if (nr
!= l2
->va
)
1301 restart_t200(l2
, 14);
1305 nrerrorrecovery(fi
);
1308 if (skb_queue_len(&l2
->i_queue
) && (fi
->state
== ST_L2_7
))
1309 mISDN_FsmEvent(fi
, EV_L2_ACK_PULL
, NULL
);
1310 if (test_and_clear_bit(FLG_ACK_PEND
, &l2
->flag
))
1311 enquiry_cr(l2
, RR
, RSP
, 0);
1315 l2_got_tei(struct FsmInst
*fi
, int event
, void *arg
)
1317 struct layer2
*l2
= fi
->userdata
;
1320 l2
->tei
= (signed char)(long)arg
;
1321 set_channel_address(&l2
->ch
, l2
->sapi
, l2
->tei
);
1322 info
= DL_INFO_L2_CONNECT
;
1323 l2up_create(l2
, DL_INFORMATION_IND
, sizeof(info
), &info
);
1324 if (fi
->state
== ST_L2_3
) {
1326 test_and_set_bit(FLG_L3_INIT
, &l2
->flag
);
1328 mISDN_FsmChangeState(fi
, ST_L2_4
);
1329 if (skb_queue_len(&l2
->ui_queue
))
1334 l2_st5_tout_200(struct FsmInst
*fi
, int event
, void *arg
)
1336 struct layer2
*l2
= fi
->userdata
;
1338 if (test_bit(FLG_LAPD
, &l2
->flag
) &&
1339 test_bit(FLG_DCHAN_BUSY
, &l2
->flag
)) {
1340 mISDN_FsmAddTimer(&l2
->t200
, l2
->T200
, EV_L2_T200
, NULL
, 9);
1341 } else if (l2
->rc
== l2
->N200
) {
1342 mISDN_FsmChangeState(fi
, ST_L2_4
);
1343 test_and_clear_bit(FLG_T200_RUN
, &l2
->flag
);
1344 skb_queue_purge(&l2
->i_queue
);
1345 l2mgr(l2
, MDL_ERROR_IND
, (void *) 'G');
1346 if (test_bit(FLG_LAPB
, &l2
->flag
))
1347 l2down_create(l2
, PH_DEACTIVATE_REQ
,
1348 l2_newid(l2
), 0, NULL
);
1349 st5_dl_release_l2l3(l2
);
1351 l2_tei(l2
, MDL_STATUS_DOWN_IND
, 0);
1354 mISDN_FsmAddTimer(&l2
->t200
, l2
->T200
, EV_L2_T200
, NULL
, 9);
1355 send_uframe(l2
, NULL
, (test_bit(FLG_MOD128
, &l2
->flag
) ?
1356 SABME
: SABM
) | 0x10, CMD
);
1361 l2_st6_tout_200(struct FsmInst
*fi
, int event
, void *arg
)
1363 struct layer2
*l2
= fi
->userdata
;
1365 if (test_bit(FLG_LAPD
, &l2
->flag
) &&
1366 test_bit(FLG_DCHAN_BUSY
, &l2
->flag
)) {
1367 mISDN_FsmAddTimer(&l2
->t200
, l2
->T200
, EV_L2_T200
, NULL
, 9);
1368 } else if (l2
->rc
== l2
->N200
) {
1369 mISDN_FsmChangeState(fi
, ST_L2_4
);
1370 test_and_clear_bit(FLG_T200_RUN
, &l2
->flag
);
1371 l2mgr(l2
, MDL_ERROR_IND
, (void *) 'H');
1372 lapb_dl_release_l2l3(l2
, DL_RELEASE_CNF
);
1374 l2_tei(l2
, MDL_STATUS_DOWN_IND
, 0);
1377 mISDN_FsmAddTimer(&l2
->t200
, l2
->T200
, EV_L2_T200
,
1379 send_uframe(l2
, NULL
, DISC
| 0x10, CMD
);
1384 l2_st7_tout_200(struct FsmInst
*fi
, int event
, void *arg
)
1386 struct layer2
*l2
= fi
->userdata
;
1388 if (test_bit(FLG_LAPD
, &l2
->flag
) &&
1389 test_bit(FLG_DCHAN_BUSY
, &l2
->flag
)) {
1390 mISDN_FsmAddTimer(&l2
->t200
, l2
->T200
, EV_L2_T200
, NULL
, 9);
1393 test_and_clear_bit(FLG_T200_RUN
, &l2
->flag
);
1395 mISDN_FsmChangeState(fi
, ST_L2_8
);
1396 transmit_enquiry(l2
);
1401 l2_st8_tout_200(struct FsmInst
*fi
, int event
, void *arg
)
1403 struct layer2
*l2
= fi
->userdata
;
1405 if (test_bit(FLG_LAPD
, &l2
->flag
) &&
1406 test_bit(FLG_DCHAN_BUSY
, &l2
->flag
)) {
1407 mISDN_FsmAddTimer(&l2
->t200
, l2
->T200
, EV_L2_T200
, NULL
, 9);
1410 test_and_clear_bit(FLG_T200_RUN
, &l2
->flag
);
1411 if (l2
->rc
== l2
->N200
) {
1412 l2mgr(l2
, MDL_ERROR_IND
, (void *) 'I');
1414 test_and_clear_bit(FLG_L3_INIT
, &l2
->flag
);
1416 transmit_enquiry(l2
);
1422 l2_st7_tout_203(struct FsmInst
*fi
, int event
, void *arg
)
1424 struct layer2
*l2
= fi
->userdata
;
1426 if (test_bit(FLG_LAPD
, &l2
->flag
) &&
1427 test_bit(FLG_DCHAN_BUSY
, &l2
->flag
)) {
1428 mISDN_FsmAddTimer(&l2
->t203
, l2
->T203
, EV_L2_T203
, NULL
, 9);
1431 mISDN_FsmChangeState(fi
, ST_L2_8
);
1432 transmit_enquiry(l2
);
1437 l2_pull_iqueue(struct FsmInst
*fi
, int event
, void *arg
)
1439 struct layer2
*l2
= fi
->userdata
;
1440 struct sk_buff
*skb
, *nskb
, *oskb
;
1441 u_char header
[MAX_L2HEADER_LEN
];
1447 skb
= skb_dequeue(&l2
->i_queue
);
1451 if (test_bit(FLG_MOD128
, &l2
->flag
))
1452 p1
= (l2
->vs
- l2
->va
) % 128;
1454 p1
= (l2
->vs
- l2
->va
) % 8;
1455 p1
= (p1
+ l2
->sow
) % l2
->window
;
1456 if (l2
->windowar
[p1
]) {
1457 printk(KERN_WARNING
"isdnl2 try overwrite ack queue entry %d\n",
1459 dev_kfree_skb(l2
->windowar
[p1
]);
1461 l2
->windowar
[p1
] = skb
;
1462 i
= sethdraddr(l2
, header
, CMD
);
1463 if (test_bit(FLG_MOD128
, &l2
->flag
)) {
1464 header
[i
++] = l2
->vs
<< 1;
1465 header
[i
++] = l2
->vr
<< 1;
1466 l2
->vs
= (l2
->vs
+ 1) % 128;
1468 header
[i
++] = (l2
->vr
<< 5) | (l2
->vs
<< 1);
1469 l2
->vs
= (l2
->vs
+ 1) % 8;
1472 nskb
= skb_clone(skb
, GFP_ATOMIC
);
1473 p1
= skb_headroom(nskb
);
1475 memcpy(skb_push(nskb
, i
), header
, i
);
1478 "isdnl2 pull_iqueue skb header(%d/%d) too short\n", i
, p1
);
1480 nskb
= mI_alloc_skb(oskb
->len
+ i
, GFP_ATOMIC
);
1482 dev_kfree_skb(oskb
);
1483 printk(KERN_WARNING
"%s: no skb mem\n", __func__
);
1486 memcpy(skb_put(nskb
, i
), header
, i
);
1487 memcpy(skb_put(nskb
, oskb
->len
), oskb
->data
, oskb
->len
);
1488 dev_kfree_skb(oskb
);
1490 l2down(l2
, PH_DATA_REQ
, l2_newid(l2
), nskb
);
1491 test_and_clear_bit(FLG_ACK_PEND
, &l2
->flag
);
1492 if (!test_and_set_bit(FLG_T200_RUN
, &l2
->flag
)) {
1493 mISDN_FsmDelTimer(&l2
->t203
, 13);
1494 mISDN_FsmAddTimer(&l2
->t200
, l2
->T200
, EV_L2_T200
, NULL
, 11);
1499 l2_st8_got_super(struct FsmInst
*fi
, int event
, void *arg
)
1501 struct layer2
*l2
= fi
->userdata
;
1502 struct sk_buff
*skb
= arg
;
1503 int PollFlag
, rsp
, rnr
= 0;
1506 rsp
= *skb
->data
& 0x2;
1507 if (test_bit(FLG_ORIG
, &l2
->flag
))
1510 skb_pull(skb
, l2addrsize(l2
));
1512 if (IsRNR(skb
->data
, l2
)) {
1516 clear_peer_busy(l2
);
1518 if (test_bit(FLG_MOD128
, &l2
->flag
)) {
1519 PollFlag
= (skb
->data
[1] & 0x1) == 0x1;
1520 nr
= skb
->data
[1] >> 1;
1522 PollFlag
= (skb
->data
[0] & 0x10);
1523 nr
= (skb
->data
[0] >> 5) & 0x7;
1526 if (rsp
&& PollFlag
) {
1527 if (legalnr(l2
, nr
)) {
1529 restart_t200(l2
, 15);
1532 mISDN_FsmAddTimer(&l2
->t203
, l2
->T203
,
1533 EV_L2_T203
, NULL
, 5);
1536 invoke_retransmission(l2
, nr
);
1537 mISDN_FsmChangeState(fi
, ST_L2_7
);
1538 if (skb_queue_len(&l2
->i_queue
) && cansend(l2
))
1539 mISDN_FsmEvent(fi
, EV_L2_ACK_PULL
, NULL
);
1541 nrerrorrecovery(fi
);
1543 if (!rsp
&& PollFlag
)
1544 enquiry_response(l2
);
1545 if (legalnr(l2
, nr
))
1548 nrerrorrecovery(fi
);
1553 l2_got_FRMR(struct FsmInst
*fi
, int event
, void *arg
)
1555 struct layer2
*l2
= fi
->userdata
;
1556 struct sk_buff
*skb
= arg
;
1558 skb_pull(skb
, l2addrsize(l2
) + 1);
1560 if (!(skb
->data
[0] & 1) || ((skb
->data
[0] & 3) == 1) || /* I or S */
1561 (IsUA(skb
->data
) && (fi
->state
== ST_L2_7
))) {
1562 l2mgr(l2
, MDL_ERROR_IND
, (void *) 'K');
1564 test_and_clear_bit(FLG_L3_INIT
, &l2
->flag
);
1570 l2_st24_tei_remove(struct FsmInst
*fi
, int event
, void *arg
)
1572 struct layer2
*l2
= fi
->userdata
;
1574 skb_queue_purge(&l2
->ui_queue
);
1575 l2
->tei
= GROUP_TEI
;
1576 mISDN_FsmChangeState(fi
, ST_L2_1
);
1580 l2_st3_tei_remove(struct FsmInst
*fi
, int event
, void *arg
)
1582 struct layer2
*l2
= fi
->userdata
;
1584 skb_queue_purge(&l2
->ui_queue
);
1585 l2
->tei
= GROUP_TEI
;
1586 l2up_create(l2
, DL_RELEASE_IND
, 0, NULL
);
1587 mISDN_FsmChangeState(fi
, ST_L2_1
);
1591 l2_st5_tei_remove(struct FsmInst
*fi
, int event
, void *arg
)
1593 struct layer2
*l2
= fi
->userdata
;
1595 skb_queue_purge(&l2
->i_queue
);
1596 skb_queue_purge(&l2
->ui_queue
);
1598 l2
->tei
= GROUP_TEI
;
1600 st5_dl_release_l2l3(l2
);
1601 mISDN_FsmChangeState(fi
, ST_L2_1
);
1605 l2_st6_tei_remove(struct FsmInst
*fi
, int event
, void *arg
)
1607 struct layer2
*l2
= fi
->userdata
;
1609 skb_queue_purge(&l2
->ui_queue
);
1610 l2
->tei
= GROUP_TEI
;
1612 l2up_create(l2
, DL_RELEASE_IND
, 0, NULL
);
1613 mISDN_FsmChangeState(fi
, ST_L2_1
);
1617 l2_tei_remove(struct FsmInst
*fi
, int event
, void *arg
)
1619 struct layer2
*l2
= fi
->userdata
;
1621 skb_queue_purge(&l2
->i_queue
);
1622 skb_queue_purge(&l2
->ui_queue
);
1624 l2
->tei
= GROUP_TEI
;
1626 mISDN_FsmDelTimer(&l2
->t203
, 19);
1627 l2up_create(l2
, DL_RELEASE_IND
, 0, NULL
);
1628 /* mISDN_queue_data(&l2->inst, l2->inst.id | MSG_BROADCAST,
1629 * MGR_SHORTSTATUS_IND, SSTATUS_L2_RELEASED,
1632 mISDN_FsmChangeState(fi
, ST_L2_1
);
1636 l2_st14_persistant_da(struct FsmInst
*fi
, int event
, void *arg
)
1638 struct layer2
*l2
= fi
->userdata
;
1639 struct sk_buff
*skb
= arg
;
1641 skb_queue_purge(&l2
->i_queue
);
1642 skb_queue_purge(&l2
->ui_queue
);
1643 if (test_and_clear_bit(FLG_ESTAB_PEND
, &l2
->flag
))
1644 l2up(l2
, DL_RELEASE_IND
, skb
);
1650 l2_st5_persistant_da(struct FsmInst
*fi
, int event
, void *arg
)
1652 struct layer2
*l2
= fi
->userdata
;
1653 struct sk_buff
*skb
= arg
;
1655 skb_queue_purge(&l2
->i_queue
);
1656 skb_queue_purge(&l2
->ui_queue
);
1659 st5_dl_release_l2l3(l2
);
1660 mISDN_FsmChangeState(fi
, ST_L2_4
);
1662 l2_tei(l2
, MDL_STATUS_DOWN_IND
, 0);
1667 l2_st6_persistant_da(struct FsmInst
*fi
, int event
, void *arg
)
1669 struct layer2
*l2
= fi
->userdata
;
1670 struct sk_buff
*skb
= arg
;
1672 skb_queue_purge(&l2
->ui_queue
);
1674 l2up(l2
, DL_RELEASE_CNF
, skb
);
1675 mISDN_FsmChangeState(fi
, ST_L2_4
);
1677 l2_tei(l2
, MDL_STATUS_DOWN_IND
, 0);
1681 l2_persistant_da(struct FsmInst
*fi
, int event
, void *arg
)
1683 struct layer2
*l2
= fi
->userdata
;
1684 struct sk_buff
*skb
= arg
;
1686 skb_queue_purge(&l2
->i_queue
);
1687 skb_queue_purge(&l2
->ui_queue
);
1690 mISDN_FsmDelTimer(&l2
->t203
, 19);
1691 l2up(l2
, DL_RELEASE_IND
, skb
);
1692 mISDN_FsmChangeState(fi
, ST_L2_4
);
1694 l2_tei(l2
, MDL_STATUS_DOWN_IND
, 0);
1698 l2_set_own_busy(struct FsmInst
*fi
, int event
, void *arg
)
1700 struct layer2
*l2
= fi
->userdata
;
1701 struct sk_buff
*skb
= arg
;
1703 if (!test_and_set_bit(FLG_OWN_BUSY
, &l2
->flag
)) {
1704 enquiry_cr(l2
, RNR
, RSP
, 0);
1705 test_and_clear_bit(FLG_ACK_PEND
, &l2
->flag
);
1712 l2_clear_own_busy(struct FsmInst
*fi
, int event
, void *arg
)
1714 struct layer2
*l2
= fi
->userdata
;
1715 struct sk_buff
*skb
= arg
;
1717 if (!test_and_clear_bit(FLG_OWN_BUSY
, &l2
->flag
)) {
1718 enquiry_cr(l2
, RR
, RSP
, 0);
1719 test_and_clear_bit(FLG_ACK_PEND
, &l2
->flag
);
1726 l2_frame_error(struct FsmInst
*fi
, int event
, void *arg
)
1728 struct layer2
*l2
= fi
->userdata
;
1730 l2mgr(l2
, MDL_ERROR_IND
, arg
);
1734 l2_frame_error_reest(struct FsmInst
*fi
, int event
, void *arg
)
1736 struct layer2
*l2
= fi
->userdata
;
1738 l2mgr(l2
, MDL_ERROR_IND
, arg
);
1740 test_and_clear_bit(FLG_L3_INIT
, &l2
->flag
);
1743 static struct FsmNode L2FnList
[] =
1745 {ST_L2_1
, EV_L2_DL_ESTABLISH_REQ
, l2_mdl_assign
},
1746 {ST_L2_2
, EV_L2_DL_ESTABLISH_REQ
, l2_go_st3
},
1747 {ST_L2_4
, EV_L2_DL_ESTABLISH_REQ
, l2_establish
},
1748 {ST_L2_5
, EV_L2_DL_ESTABLISH_REQ
, l2_discard_i_setl3
},
1749 {ST_L2_7
, EV_L2_DL_ESTABLISH_REQ
, l2_l3_reestablish
},
1750 {ST_L2_8
, EV_L2_DL_ESTABLISH_REQ
, l2_l3_reestablish
},
1751 {ST_L2_4
, EV_L2_DL_RELEASE_REQ
, l2_release
},
1752 {ST_L2_5
, EV_L2_DL_RELEASE_REQ
, l2_pend_rel
},
1753 {ST_L2_7
, EV_L2_DL_RELEASE_REQ
, l2_disconnect
},
1754 {ST_L2_8
, EV_L2_DL_RELEASE_REQ
, l2_disconnect
},
1755 {ST_L2_5
, EV_L2_DL_DATA
, l2_feed_i_if_reest
},
1756 {ST_L2_7
, EV_L2_DL_DATA
, l2_feed_i_pull
},
1757 {ST_L2_8
, EV_L2_DL_DATA
, l2_feed_iqueue
},
1758 {ST_L2_1
, EV_L2_DL_UNITDATA
, l2_queue_ui_assign
},
1759 {ST_L2_2
, EV_L2_DL_UNITDATA
, l2_queue_ui
},
1760 {ST_L2_3
, EV_L2_DL_UNITDATA
, l2_queue_ui
},
1761 {ST_L2_4
, EV_L2_DL_UNITDATA
, l2_send_ui
},
1762 {ST_L2_5
, EV_L2_DL_UNITDATA
, l2_send_ui
},
1763 {ST_L2_6
, EV_L2_DL_UNITDATA
, l2_send_ui
},
1764 {ST_L2_7
, EV_L2_DL_UNITDATA
, l2_send_ui
},
1765 {ST_L2_8
, EV_L2_DL_UNITDATA
, l2_send_ui
},
1766 {ST_L2_1
, EV_L2_MDL_ASSIGN
, l2_got_tei
},
1767 {ST_L2_2
, EV_L2_MDL_ASSIGN
, l2_got_tei
},
1768 {ST_L2_3
, EV_L2_MDL_ASSIGN
, l2_got_tei
},
1769 {ST_L2_2
, EV_L2_MDL_ERROR
, l2_st24_tei_remove
},
1770 {ST_L2_3
, EV_L2_MDL_ERROR
, l2_st3_tei_remove
},
1771 {ST_L2_4
, EV_L2_MDL_REMOVE
, l2_st24_tei_remove
},
1772 {ST_L2_5
, EV_L2_MDL_REMOVE
, l2_st5_tei_remove
},
1773 {ST_L2_6
, EV_L2_MDL_REMOVE
, l2_st6_tei_remove
},
1774 {ST_L2_7
, EV_L2_MDL_REMOVE
, l2_tei_remove
},
1775 {ST_L2_8
, EV_L2_MDL_REMOVE
, l2_tei_remove
},
1776 {ST_L2_4
, EV_L2_SABME
, l2_start_multi
},
1777 {ST_L2_5
, EV_L2_SABME
, l2_send_UA
},
1778 {ST_L2_6
, EV_L2_SABME
, l2_send_DM
},
1779 {ST_L2_7
, EV_L2_SABME
, l2_restart_multi
},
1780 {ST_L2_8
, EV_L2_SABME
, l2_restart_multi
},
1781 {ST_L2_4
, EV_L2_DISC
, l2_send_DM
},
1782 {ST_L2_5
, EV_L2_DISC
, l2_send_DM
},
1783 {ST_L2_6
, EV_L2_DISC
, l2_send_UA
},
1784 {ST_L2_7
, EV_L2_DISC
, l2_stop_multi
},
1785 {ST_L2_8
, EV_L2_DISC
, l2_stop_multi
},
1786 {ST_L2_4
, EV_L2_UA
, l2_mdl_error_ua
},
1787 {ST_L2_5
, EV_L2_UA
, l2_connected
},
1788 {ST_L2_6
, EV_L2_UA
, l2_released
},
1789 {ST_L2_7
, EV_L2_UA
, l2_mdl_error_ua
},
1790 {ST_L2_8
, EV_L2_UA
, l2_mdl_error_ua
},
1791 {ST_L2_4
, EV_L2_DM
, l2_reestablish
},
1792 {ST_L2_5
, EV_L2_DM
, l2_st5_dm_release
},
1793 {ST_L2_6
, EV_L2_DM
, l2_st6_dm_release
},
1794 {ST_L2_7
, EV_L2_DM
, l2_mdl_error_dm
},
1795 {ST_L2_8
, EV_L2_DM
, l2_st8_mdl_error_dm
},
1796 {ST_L2_1
, EV_L2_UI
, l2_got_ui
},
1797 {ST_L2_2
, EV_L2_UI
, l2_got_ui
},
1798 {ST_L2_3
, EV_L2_UI
, l2_got_ui
},
1799 {ST_L2_4
, EV_L2_UI
, l2_got_ui
},
1800 {ST_L2_5
, EV_L2_UI
, l2_got_ui
},
1801 {ST_L2_6
, EV_L2_UI
, l2_got_ui
},
1802 {ST_L2_7
, EV_L2_UI
, l2_got_ui
},
1803 {ST_L2_8
, EV_L2_UI
, l2_got_ui
},
1804 {ST_L2_7
, EV_L2_FRMR
, l2_got_FRMR
},
1805 {ST_L2_8
, EV_L2_FRMR
, l2_got_FRMR
},
1806 {ST_L2_7
, EV_L2_SUPER
, l2_st7_got_super
},
1807 {ST_L2_8
, EV_L2_SUPER
, l2_st8_got_super
},
1808 {ST_L2_7
, EV_L2_I
, l2_got_iframe
},
1809 {ST_L2_8
, EV_L2_I
, l2_got_iframe
},
1810 {ST_L2_5
, EV_L2_T200
, l2_st5_tout_200
},
1811 {ST_L2_6
, EV_L2_T200
, l2_st6_tout_200
},
1812 {ST_L2_7
, EV_L2_T200
, l2_st7_tout_200
},
1813 {ST_L2_8
, EV_L2_T200
, l2_st8_tout_200
},
1814 {ST_L2_7
, EV_L2_T203
, l2_st7_tout_203
},
1815 {ST_L2_7
, EV_L2_ACK_PULL
, l2_pull_iqueue
},
1816 {ST_L2_7
, EV_L2_SET_OWN_BUSY
, l2_set_own_busy
},
1817 {ST_L2_8
, EV_L2_SET_OWN_BUSY
, l2_set_own_busy
},
1818 {ST_L2_7
, EV_L2_CLEAR_OWN_BUSY
, l2_clear_own_busy
},
1819 {ST_L2_8
, EV_L2_CLEAR_OWN_BUSY
, l2_clear_own_busy
},
1820 {ST_L2_4
, EV_L2_FRAME_ERROR
, l2_frame_error
},
1821 {ST_L2_5
, EV_L2_FRAME_ERROR
, l2_frame_error
},
1822 {ST_L2_6
, EV_L2_FRAME_ERROR
, l2_frame_error
},
1823 {ST_L2_7
, EV_L2_FRAME_ERROR
, l2_frame_error_reest
},
1824 {ST_L2_8
, EV_L2_FRAME_ERROR
, l2_frame_error_reest
},
1825 {ST_L2_1
, EV_L1_DEACTIVATE
, l2_st14_persistant_da
},
1826 {ST_L2_2
, EV_L1_DEACTIVATE
, l2_st24_tei_remove
},
1827 {ST_L2_3
, EV_L1_DEACTIVATE
, l2_st3_tei_remove
},
1828 {ST_L2_4
, EV_L1_DEACTIVATE
, l2_st14_persistant_da
},
1829 {ST_L2_5
, EV_L1_DEACTIVATE
, l2_st5_persistant_da
},
1830 {ST_L2_6
, EV_L1_DEACTIVATE
, l2_st6_persistant_da
},
1831 {ST_L2_7
, EV_L1_DEACTIVATE
, l2_persistant_da
},
1832 {ST_L2_8
, EV_L1_DEACTIVATE
, l2_persistant_da
},
1836 ph_data_indication(struct layer2
*l2
, struct mISDNhead
*hh
, struct sk_buff
*skb
)
1838 u_char
*datap
= skb
->data
;
1845 if (skb
->len
<= l
) {
1846 mISDN_FsmEvent(&l2
->l2m
, EV_L2_FRAME_ERROR
, (void *) 'N');
1849 if (test_bit(FLG_LAPD
, &l2
->flag
)) { /* Maybe not needed */
1852 if ((psapi
& 1) || !(ptei
& 1)) {
1854 "l2 D-channel frame wrong EA0/EA1\n");
1859 if (psapi
!= l2
->sapi
) {
1860 /* not our bussiness */
1861 if (*debug
& DEBUG_L2
)
1862 printk(KERN_DEBUG
"%s: sapi %d/%d mismatch\n",
1863 __func__
, psapi
, l2
->sapi
);
1867 if ((ptei
!= l2
->tei
) && (ptei
!= GROUP_TEI
)) {
1868 /* not our bussiness */
1869 if (*debug
& DEBUG_L2
)
1870 printk(KERN_DEBUG
"%s: tei %d/%d mismatch\n",
1871 __func__
, ptei
, l2
->tei
);
1877 if (!(*datap
& 1)) { /* I-Frame */
1878 c
= iframe_error(l2
, skb
);
1880 ret
= mISDN_FsmEvent(&l2
->l2m
, EV_L2_I
, skb
);
1881 } else if (IsSFrame(datap
, l2
)) { /* S-Frame */
1882 c
= super_error(l2
, skb
);
1884 ret
= mISDN_FsmEvent(&l2
->l2m
, EV_L2_SUPER
, skb
);
1885 } else if (IsUI(datap
)) {
1886 c
= UI_error(l2
, skb
);
1888 ret
= mISDN_FsmEvent(&l2
->l2m
, EV_L2_UI
, skb
);
1889 } else if (IsSABME(datap
, l2
)) {
1890 c
= unnum_error(l2
, skb
, CMD
);
1892 ret
= mISDN_FsmEvent(&l2
->l2m
, EV_L2_SABME
, skb
);
1893 } else if (IsUA(datap
)) {
1894 c
= unnum_error(l2
, skb
, RSP
);
1896 ret
= mISDN_FsmEvent(&l2
->l2m
, EV_L2_UA
, skb
);
1897 } else if (IsDISC(datap
)) {
1898 c
= unnum_error(l2
, skb
, CMD
);
1900 ret
= mISDN_FsmEvent(&l2
->l2m
, EV_L2_DISC
, skb
);
1901 } else if (IsDM(datap
)) {
1902 c
= unnum_error(l2
, skb
, RSP
);
1904 ret
= mISDN_FsmEvent(&l2
->l2m
, EV_L2_DM
, skb
);
1905 } else if (IsFRMR(datap
)) {
1906 c
= FRMR_error(l2
, skb
);
1908 ret
= mISDN_FsmEvent(&l2
->l2m
, EV_L2_FRMR
, skb
);
1912 printk(KERN_WARNING
"l2 D-channel frame error %c\n", c
);
1913 mISDN_FsmEvent(&l2
->l2m
, EV_L2_FRAME_ERROR
, (void *)(long)c
);
1919 l2_send(struct mISDNchannel
*ch
, struct sk_buff
*skb
)
1921 struct layer2
*l2
= container_of(ch
, struct layer2
, ch
);
1922 struct mISDNhead
*hh
= mISDN_HEAD_P(skb
);
1925 if (*debug
& DEBUG_L2_RECV
)
1926 printk(KERN_DEBUG
"%s: prim(%x) id(%x) sapi(%d) tei(%d)\n",
1927 __func__
, hh
->prim
, hh
->id
, l2
->sapi
, l2
->tei
);
1930 ret
= ph_data_indication(l2
, hh
, skb
);
1933 ret
= ph_data_confirm(l2
, hh
, skb
);
1935 case PH_ACTIVATE_IND
:
1936 test_and_set_bit(FLG_L1_ACTIV
, &l2
->flag
);
1937 l2up_create(l2
, MPH_ACTIVATE_IND
, 0, NULL
);
1938 if (test_and_clear_bit(FLG_ESTAB_PEND
, &l2
->flag
))
1939 ret
= mISDN_FsmEvent(&l2
->l2m
,
1940 EV_L2_DL_ESTABLISH_REQ
, skb
);
1942 case PH_DEACTIVATE_IND
:
1943 test_and_clear_bit(FLG_L1_ACTIV
, &l2
->flag
);
1944 l2up_create(l2
, MPH_DEACTIVATE_IND
, 0, NULL
);
1945 ret
= mISDN_FsmEvent(&l2
->l2m
, EV_L1_DEACTIVATE
, skb
);
1947 case MPH_INFORMATION_IND
:
1950 ret
= l2
->up
->send(l2
->up
, skb
);
1953 ret
= mISDN_FsmEvent(&l2
->l2m
, EV_L2_DL_DATA
, skb
);
1955 case DL_UNITDATA_REQ
:
1956 ret
= mISDN_FsmEvent(&l2
->l2m
, EV_L2_DL_UNITDATA
, skb
);
1958 case DL_ESTABLISH_REQ
:
1959 if (test_bit(FLG_LAPB
, &l2
->flag
))
1960 test_and_set_bit(FLG_ORIG
, &l2
->flag
);
1961 if (test_bit(FLG_L1_ACTIV
, &l2
->flag
)) {
1962 if (test_bit(FLG_LAPD
, &l2
->flag
) ||
1963 test_bit(FLG_ORIG
, &l2
->flag
))
1964 ret
= mISDN_FsmEvent(&l2
->l2m
,
1965 EV_L2_DL_ESTABLISH_REQ
, skb
);
1967 if (test_bit(FLG_LAPD
, &l2
->flag
) ||
1968 test_bit(FLG_ORIG
, &l2
->flag
)) {
1969 test_and_set_bit(FLG_ESTAB_PEND
,
1972 ret
= l2down(l2
, PH_ACTIVATE_REQ
, l2_newid(l2
),
1976 case DL_RELEASE_REQ
:
1977 if (test_bit(FLG_LAPB
, &l2
->flag
))
1978 l2down_create(l2
, PH_DEACTIVATE_REQ
,
1979 l2_newid(l2
), 0, NULL
);
1980 ret
= mISDN_FsmEvent(&l2
->l2m
, EV_L2_DL_RELEASE_REQ
,
1984 if (*debug
& DEBUG_L2
)
1985 l2m_debug(&l2
->l2m
, "l2 unknown pr %04x",
1996 tei_l2(struct layer2
*l2
, u_int cmd
, u_long arg
)
2000 if (*debug
& DEBUG_L2_TEI
)
2001 printk(KERN_DEBUG
"%s: cmd(%x)\n", __func__
, cmd
);
2003 case (MDL_ASSIGN_REQ
):
2004 ret
= mISDN_FsmEvent(&l2
->l2m
, EV_L2_MDL_ASSIGN
, (void *)arg
);
2006 case (MDL_REMOVE_REQ
):
2007 ret
= mISDN_FsmEvent(&l2
->l2m
, EV_L2_MDL_REMOVE
, NULL
);
2009 case (MDL_ERROR_IND
):
2010 ret
= mISDN_FsmEvent(&l2
->l2m
, EV_L2_MDL_ERROR
, NULL
);
2012 case (MDL_ERROR_RSP
):
2013 /* ETS 300-125 5.3.2.1 Test: TC13010 */
2014 printk(KERN_NOTICE
"MDL_ERROR|REQ (tei_l2)\n");
2015 ret
= mISDN_FsmEvent(&l2
->l2m
, EV_L2_MDL_ERROR
, NULL
);
2022 release_l2(struct layer2
*l2
)
2024 mISDN_FsmDelTimer(&l2
->t200
, 21);
2025 mISDN_FsmDelTimer(&l2
->t203
, 16);
2026 skb_queue_purge(&l2
->i_queue
);
2027 skb_queue_purge(&l2
->ui_queue
);
2028 skb_queue_purge(&l2
->down_queue
);
2030 if (test_bit(FLG_LAPD
, &l2
->flag
)) {
2033 l2
->ch
.st
->dev
->D
.ctrl(&l2
->ch
.st
->dev
->D
,
2034 CLOSE_CHANNEL
, NULL
);
2040 l2_ctrl(struct mISDNchannel
*ch
, u_int cmd
, void *arg
)
2042 struct layer2
*l2
= container_of(ch
, struct layer2
, ch
);
2045 if (*debug
& DEBUG_L2_CTRL
)
2046 printk(KERN_DEBUG
"%s:(%x)\n", __func__
, cmd
);
2050 if (test_bit(FLG_LAPD
, &l2
->flag
)) {
2051 set_channel_address(&l2
->ch
, l2
->sapi
, l2
->tei
);
2052 info
= DL_INFO_L2_CONNECT
;
2053 l2up_create(l2
, DL_INFORMATION_IND
,
2054 sizeof(info
), &info
);
2059 l2
->ch
.peer
->ctrl(l2
->ch
.peer
, CLOSE_CHANNEL
, NULL
);
2067 create_l2(struct mISDNchannel
*ch
, u_int protocol
, u_long options
, int tei
,
2071 struct channel_req rq
;
2073 l2
= kzalloc(sizeof(struct layer2
), GFP_KERNEL
);
2075 printk(KERN_ERR
"kzalloc layer2 failed\n");
2079 l2
->down_id
= MISDN_ID_NONE
;
2082 l2
->ch
.send
= l2_send
;
2083 l2
->ch
.ctrl
= l2_ctrl
;
2085 case ISDN_P_LAPD_NT
:
2086 test_and_set_bit(FLG_LAPD
, &l2
->flag
);
2087 test_and_set_bit(FLG_LAPD_NET
, &l2
->flag
);
2088 test_and_set_bit(FLG_MOD128
, &l2
->flag
);
2090 l2
->maxlen
= MAX_DFRAME_LEN
;
2091 if (test_bit(OPTION_L2_PMX
, &options
))
2095 if (test_bit(OPTION_L2_PTP
, &options
))
2096 test_and_set_bit(FLG_PTP
, &l2
->flag
);
2097 if (test_bit(OPTION_L2_FIXEDTEI
, &options
))
2098 test_and_set_bit(FLG_FIXED_TEI
, &l2
->flag
);
2103 if (test_bit(OPTION_L2_PMX
, &options
))
2104 rq
.protocol
= ISDN_P_NT_E1
;
2106 rq
.protocol
= ISDN_P_NT_S0
;
2108 l2
->ch
.st
->dev
->D
.ctrl(&l2
->ch
.st
->dev
->D
, OPEN_CHANNEL
, &rq
);
2110 case ISDN_P_LAPD_TE
:
2111 test_and_set_bit(FLG_LAPD
, &l2
->flag
);
2112 test_and_set_bit(FLG_MOD128
, &l2
->flag
);
2113 test_and_set_bit(FLG_ORIG
, &l2
->flag
);
2115 l2
->maxlen
= MAX_DFRAME_LEN
;
2116 if (test_bit(OPTION_L2_PMX
, &options
))
2120 if (test_bit(OPTION_L2_PTP
, &options
))
2121 test_and_set_bit(FLG_PTP
, &l2
->flag
);
2122 if (test_bit(OPTION_L2_FIXEDTEI
, &options
))
2123 test_and_set_bit(FLG_FIXED_TEI
, &l2
->flag
);
2128 if (test_bit(OPTION_L2_PMX
, &options
))
2129 rq
.protocol
= ISDN_P_TE_E1
;
2131 rq
.protocol
= ISDN_P_TE_S0
;
2133 l2
->ch
.st
->dev
->D
.ctrl(&l2
->ch
.st
->dev
->D
, OPEN_CHANNEL
, &rq
);
2135 case ISDN_P_B_X75SLP
:
2136 test_and_set_bit(FLG_LAPB
, &l2
->flag
);
2138 l2
->maxlen
= MAX_DATA_SIZE
;
2146 printk(KERN_ERR
"layer2 create failed prt %x\n",
2151 skb_queue_head_init(&l2
->i_queue
);
2152 skb_queue_head_init(&l2
->ui_queue
);
2153 skb_queue_head_init(&l2
->down_queue
);
2154 skb_queue_head_init(&l2
->tmp_queue
);
2156 l2
->l2m
.fsm
= &l2fsm
;
2157 if (test_bit(FLG_LAPB
, &l2
->flag
) ||
2158 test_bit(FLG_PTP
, &l2
->flag
) ||
2159 test_bit(FLG_LAPD_NET
, &l2
->flag
))
2160 l2
->l2m
.state
= ST_L2_4
;
2162 l2
->l2m
.state
= ST_L2_1
;
2163 l2
->l2m
.debug
= *debug
;
2164 l2
->l2m
.userdata
= l2
;
2165 l2
->l2m
.userint
= 0;
2166 l2
->l2m
.printdebug
= l2m_debug
;
2168 mISDN_FsmInitTimer(&l2
->l2m
, &l2
->t200
);
2169 mISDN_FsmInitTimer(&l2
->l2m
, &l2
->t203
);
2174 x75create(struct channel_req
*crq
)
2178 if (crq
->protocol
!= ISDN_P_B_X75SLP
)
2179 return -EPROTONOSUPPORT
;
2180 l2
= create_l2(crq
->ch
, crq
->protocol
, 0, 0, 0);
2184 crq
->protocol
= ISDN_P_B_HDLC
;
2188 static struct Bprotocol X75SLP
= {
2189 .Bprotocols
= (1 << (ISDN_P_B_X75SLP
& ISDN_P_B_MASK
)),
2195 Isdnl2_Init(u_int
*deb
)
2198 mISDN_register_Bprotocol(&X75SLP
);
2199 l2fsm
.state_count
= L2_STATE_COUNT
;
2200 l2fsm
.event_count
= L2_EVENT_COUNT
;
2201 l2fsm
.strEvent
= strL2Event
;
2202 l2fsm
.strState
= strL2State
;
2203 mISDN_FsmNew(&l2fsm
, L2FnList
, ARRAY_SIZE(L2FnList
));
2209 Isdnl2_cleanup(void)
2211 mISDN_unregister_Bprotocol(&X75SLP
);
2213 mISDN_FsmFree(&l2fsm
);