1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27#include <linux/skbuff.h>
28#include <linux/init.h>
29#include <linux/fs.h>
30#include <linux/seq_file.h>
31
32#include <asm/byteorder.h>
33#include <asm/unaligned.h>
34
35#include <net/irda/irda.h>
36#include <net/irda/irlap.h>
37#include <net/irda/irlmp.h>
38#include <net/irda/parameters.h>
39#include <net/irda/irttp.h>
40
41static struct irttp_cb *irttp;
42
43static void __irttp_close_tsap(struct tsap_cb *self);
44
45static int irttp_data_indication(void *instance, void *sap,
46 struct sk_buff *skb);
47static int irttp_udata_indication(void *instance, void *sap,
48 struct sk_buff *skb);
49static void irttp_disconnect_indication(void *instance, void *sap,
50 LM_REASON reason, struct sk_buff *);
51static void irttp_connect_indication(void *instance, void *sap,
52 struct qos_info *qos, __u32 max_sdu_size,
53 __u8 header_size, struct sk_buff *skb);
54static void irttp_connect_confirm(void *instance, void *sap,
55 struct qos_info *qos, __u32 max_sdu_size,
56 __u8 header_size, struct sk_buff *skb);
57static void irttp_run_tx_queue(struct tsap_cb *self);
58static void irttp_run_rx_queue(struct tsap_cb *self);
59
60static void irttp_flush_queues(struct tsap_cb *self);
61static void irttp_fragment_skb(struct tsap_cb *self, struct sk_buff *skb);
62static struct sk_buff *irttp_reassemble_skb(struct tsap_cb *self);
63static void irttp_todo_expired(unsigned long data);
64static int irttp_param_max_sdu_size(void *instance, irda_param_t *param,
65 int get);
66
67static void irttp_flow_indication(void *instance, void *sap, LOCAL_FLOW flow);
68static void irttp_status_indication(void *instance,
69 LINK_STATUS link, LOCK_STATUS lock);
70
71
72static pi_minor_info_t pi_minor_call_table[] = {
73 { NULL, 0 },
74 { irttp_param_max_sdu_size, PV_INTEGER | PV_BIG_ENDIAN }
75};
76static pi_major_info_t pi_major_call_table[] = {{ pi_minor_call_table, 2 }};
77static pi_param_info_t param_info = { pi_major_call_table, 1, 0x0f, 4 };
78
79
80
81
82
83
84
85
86
87int __init irttp_init(void)
88{
89 irttp = kzalloc(sizeof(struct irttp_cb), GFP_KERNEL);
90 if (irttp == NULL)
91 return -ENOMEM;
92
93 irttp->magic = TTP_MAGIC;
94
95 irttp->tsaps = hashbin_new(HB_LOCK);
96 if (!irttp->tsaps) {
97 IRDA_ERROR("%s: can't allocate IrTTP hashbin!\n",
98 __FUNCTION__);
99 kfree(irttp);
100 return -ENOMEM;
101 }
102
103 return 0;
104}
105
106
107
108
109
110
111
112void irttp_cleanup(void)
113{
114
115 IRDA_ASSERT(irttp->magic == TTP_MAGIC, return;);
116
117
118
119
120 hashbin_delete(irttp->tsaps, (FREE_FUNC) __irttp_close_tsap);
121
122 irttp->magic = 0;
123
124
125 kfree(irttp);
126
127 irttp = NULL;
128}
129
130
131
132
133
134
135
136
137
138
139static inline void irttp_start_todo_timer(struct tsap_cb *self, int timeout)
140{
141
142 mod_timer(&self->todo_timer, jiffies + timeout);
143}
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159static void irttp_todo_expired(unsigned long data)
160{
161 struct tsap_cb *self = (struct tsap_cb *) data;
162
163
164 if (!self || self->magic != TTP_TSAP_MAGIC)
165 return;
166
167 IRDA_DEBUG(4, "%s(instance=%p)\n", __FUNCTION__, self);
168
169
170 irttp_run_rx_queue(self);
171 irttp_run_tx_queue(self);
172
173
174 if (test_bit(0, &self->disconnect_pend)) {
175
176 if (skb_queue_empty(&self->tx_queue)) {
177
178 clear_bit(0, &self->disconnect_pend);
179
180
181 irttp_disconnect_request(self, self->disconnect_skb,
182 P_NORMAL);
183 self->disconnect_skb = NULL;
184 } else {
185
186 irttp_start_todo_timer(self, HZ/10);
187
188
189 return;
190 }
191 }
192
193
194 if (self->close_pend)
195
196 irttp_close_tsap(self);
197}
198
199
200
201
202
203
204void irttp_flush_queues(struct tsap_cb *self)
205{
206 struct sk_buff* skb;
207
208 IRDA_DEBUG(4, "%s()\n", __FUNCTION__);
209
210 IRDA_ASSERT(self != NULL, return;);
211 IRDA_ASSERT(self->magic == TTP_TSAP_MAGIC, return;);
212
213
214 while ((skb = skb_dequeue(&self->tx_queue)) != NULL)
215 dev_kfree_skb(skb);
216
217
218 while ((skb = skb_dequeue(&self->rx_queue)) != NULL)
219 dev_kfree_skb(skb);
220
221
222 while ((skb = skb_dequeue(&self->rx_fragments)) != NULL)
223 dev_kfree_skb(skb);
224}
225
226
227
228
229
230
231
232
233static struct sk_buff *irttp_reassemble_skb(struct tsap_cb *self)
234{
235 struct sk_buff *skb, *frag;
236 int n = 0;
237
238 IRDA_ASSERT(self != NULL, return NULL;);
239 IRDA_ASSERT(self->magic == TTP_TSAP_MAGIC, return NULL;);
240
241 IRDA_DEBUG(2, "%s(), self->rx_sdu_size=%d\n", __FUNCTION__,
242 self->rx_sdu_size);
243
244 skb = dev_alloc_skb(TTP_HEADER + self->rx_sdu_size);
245 if (!skb)
246 return NULL;
247
248
249
250
251
252 skb_reserve(skb, TTP_HEADER);
253 skb_put(skb, self->rx_sdu_size);
254
255
256
257
258 while ((frag = skb_dequeue(&self->rx_fragments)) != NULL) {
259 skb_copy_to_linear_data_offset(skb, n, frag->data, frag->len);
260 n += frag->len;
261
262 dev_kfree_skb(frag);
263 }
264
265 IRDA_DEBUG(2,
266 "%s(), frame len=%d, rx_sdu_size=%d, rx_max_sdu_size=%d\n",
267 __FUNCTION__, n, self->rx_sdu_size, self->rx_max_sdu_size);
268
269
270
271
272
273
274 IRDA_ASSERT(n <= self->rx_sdu_size, n = self->rx_sdu_size;);
275
276
277 skb_trim(skb, n);
278
279 self->rx_sdu_size = 0;
280
281 return skb;
282}
283
284
285
286
287
288
289
290static inline void irttp_fragment_skb(struct tsap_cb *self,
291 struct sk_buff *skb)
292{
293 struct sk_buff *frag;
294 __u8 *frame;
295
296 IRDA_DEBUG(2, "%s()\n", __FUNCTION__);
297
298 IRDA_ASSERT(self != NULL, return;);
299 IRDA_ASSERT(self->magic == TTP_TSAP_MAGIC, return;);
300 IRDA_ASSERT(skb != NULL, return;);
301
302
303
304
305 while (skb->len > self->max_seg_size) {
306 IRDA_DEBUG(2, "%s(), fragmenting ...\n", __FUNCTION__);
307
308
309 frag = alloc_skb(self->max_seg_size+self->max_header_size,
310 GFP_ATOMIC);
311 if (!frag)
312 return;
313
314 skb_reserve(frag, self->max_header_size);
315
316
317 skb_copy_from_linear_data(skb, skb_put(frag, self->max_seg_size),
318 self->max_seg_size);
319
320
321 frame = skb_push(frag, TTP_HEADER);
322 frame[0] = TTP_MORE;
323
324
325 skb_pull(skb, self->max_seg_size);
326
327
328 skb_queue_tail(&self->tx_queue, frag);
329 }
330
331 IRDA_DEBUG(2, "%s(), queuing last segment\n", __FUNCTION__);
332
333 frame = skb_push(skb, TTP_HEADER);
334 frame[0] = 0x00;
335
336
337 skb_queue_tail(&self->tx_queue, skb);
338}
339
340
341
342
343
344
345
346
347static int irttp_param_max_sdu_size(void *instance, irda_param_t *param,
348 int get)
349{
350 struct tsap_cb *self;
351
352 self = (struct tsap_cb *) instance;
353
354 IRDA_ASSERT(self != NULL, return -1;);
355 IRDA_ASSERT(self->magic == TTP_TSAP_MAGIC, return -1;);
356
357 if (get)
358 param->pv.i = self->tx_max_sdu_size;
359 else
360 self->tx_max_sdu_size = param->pv.i;
361
362 IRDA_DEBUG(1, "%s(), MaxSduSize=%d\n", __FUNCTION__, param->pv.i);
363
364 return 0;
365}
366
367
368
369
370
371
372
373
374
375static void irttp_init_tsap(struct tsap_cb *tsap)
376{
377 spin_lock_init(&tsap->lock);
378 init_timer(&tsap->todo_timer);
379
380 skb_queue_head_init(&tsap->rx_queue);
381 skb_queue_head_init(&tsap->tx_queue);
382 skb_queue_head_init(&tsap->rx_fragments);
383}
384
385
386
387
388
389
390struct tsap_cb *irttp_open_tsap(__u8 stsap_sel, int credit, notify_t *notify)
391{
392 struct tsap_cb *self;
393 struct lsap_cb *lsap;
394 notify_t ttp_notify;
395
396 IRDA_ASSERT(irttp->magic == TTP_MAGIC, return NULL;);
397
398
399
400
401 if((stsap_sel != LSAP_ANY) &&
402 ((stsap_sel < 0x01) || (stsap_sel >= 0x70))) {
403 IRDA_DEBUG(0, "%s(), invalid tsap!\n", __FUNCTION__);
404 return NULL;
405 }
406
407 self = kzalloc(sizeof(struct tsap_cb), GFP_ATOMIC);
408 if (self == NULL) {
409 IRDA_DEBUG(0, "%s(), unable to kmalloc!\n", __FUNCTION__);
410 return NULL;
411 }
412
413
414 irttp_init_tsap(self);
415
416
417 self->todo_timer.data = (unsigned long) self;
418 self->todo_timer.function = &irttp_todo_expired;
419
420
421 irda_notify_init(&ttp_notify);
422 ttp_notify.connect_confirm = irttp_connect_confirm;
423 ttp_notify.connect_indication = irttp_connect_indication;
424 ttp_notify.disconnect_indication = irttp_disconnect_indication;
425 ttp_notify.data_indication = irttp_data_indication;
426 ttp_notify.udata_indication = irttp_udata_indication;
427 ttp_notify.flow_indication = irttp_flow_indication;
428 if(notify->status_indication != NULL)
429 ttp_notify.status_indication = irttp_status_indication;
430 ttp_notify.instance = self;
431 strncpy(ttp_notify.name, notify->name, NOTIFY_MAX_NAME);
432
433 self->magic = TTP_TSAP_MAGIC;
434 self->connected = FALSE;
435
436
437
438
439 lsap = irlmp_open_lsap(stsap_sel, &ttp_notify, 0);
440 if (lsap == NULL) {
441 IRDA_WARNING("%s: unable to allocate LSAP!!\n", __FUNCTION__);
442 return NULL;
443 }
444
445
446
447
448
449
450 self->stsap_sel = lsap->slsap_sel;
451 IRDA_DEBUG(4, "%s(), stsap_sel=%02x\n", __FUNCTION__, self->stsap_sel);
452
453 self->notify = *notify;
454 self->lsap = lsap;
455
456 hashbin_insert(irttp->tsaps, (irda_queue_t *) self, (long) self, NULL);
457
458 if (credit > TTP_RX_MAX_CREDIT)
459 self->initial_credit = TTP_RX_MAX_CREDIT;
460 else
461 self->initial_credit = credit;
462
463 return self;
464}
465EXPORT_SYMBOL(irttp_open_tsap);
466
467
468
469
470
471
472
473
474static void __irttp_close_tsap(struct tsap_cb *self)
475{
476
477 IRDA_ASSERT(self != NULL, return;);
478 IRDA_ASSERT(self->magic == TTP_TSAP_MAGIC, return;);
479
480 irttp_flush_queues(self);
481
482 del_timer(&self->todo_timer);
483
484
485
486 if (self->disconnect_skb)
487 dev_kfree_skb(self->disconnect_skb);
488
489 self->connected = FALSE;
490 self->magic = ~TTP_TSAP_MAGIC;
491
492 kfree(self);
493}
494
495
496
497
498
499
500
501
502
503
504
505int irttp_close_tsap(struct tsap_cb *self)
506{
507 struct tsap_cb *tsap;
508
509 IRDA_DEBUG(4, "%s()\n", __FUNCTION__);
510
511 IRDA_ASSERT(self != NULL, return -1;);
512 IRDA_ASSERT(self->magic == TTP_TSAP_MAGIC, return -1;);
513
514
515 if (self->connected) {
516
517 if (!test_bit(0, &self->disconnect_pend)) {
518 IRDA_WARNING("%s: TSAP still connected!\n",
519 __FUNCTION__);
520 irttp_disconnect_request(self, NULL, P_NORMAL);
521 }
522 self->close_pend = TRUE;
523 irttp_start_todo_timer(self, HZ/10);
524
525 return 0;
526 }
527
528 tsap = hashbin_remove(irttp->tsaps, (long) self, NULL);
529
530 IRDA_ASSERT(tsap == self, return -1;);
531
532
533 if (self->lsap) {
534 irlmp_close_lsap(self->lsap);
535 self->lsap = NULL;
536 }
537
538 __irttp_close_tsap(self);
539
540 return 0;
541}
542EXPORT_SYMBOL(irttp_close_tsap);
543
544
545
546
547
548
549
550int irttp_udata_request(struct tsap_cb *self, struct sk_buff *skb)
551{
552 IRDA_ASSERT(self != NULL, return -1;);
553 IRDA_ASSERT(self->magic == TTP_TSAP_MAGIC, return -1;);
554 IRDA_ASSERT(skb != NULL, return -1;);
555
556 IRDA_DEBUG(4, "%s()\n", __FUNCTION__);
557
558
559 if ((skb->len == 0) || (!self->connected)) {
560 IRDA_DEBUG(1, "%s(), No data, or not connected\n",
561 __FUNCTION__);
562 goto err;
563 }
564
565 if (skb->len > self->max_seg_size) {
566 IRDA_DEBUG(1, "%s(), UData is too large for IrLAP!\n",
567 __FUNCTION__);
568 goto err;
569 }
570
571 irlmp_udata_request(self->lsap, skb);
572 self->stats.tx_packets++;
573
574 return 0;
575
576err:
577 dev_kfree_skb(skb);
578 return -1;
579}
580EXPORT_SYMBOL(irttp_udata_request);
581
582
583
584
585
586
587
588
589int irttp_data_request(struct tsap_cb *self, struct sk_buff *skb)
590{
591 __u8 *frame;
592 int ret;
593
594 IRDA_ASSERT(self != NULL, return -1;);
595 IRDA_ASSERT(self->magic == TTP_TSAP_MAGIC, return -1;);
596 IRDA_ASSERT(skb != NULL, return -1;);
597
598 IRDA_DEBUG(2, "%s() : queue len = %d\n", __FUNCTION__,
599 skb_queue_len(&self->tx_queue));
600
601
602 if ((skb->len == 0) || (!self->connected)) {
603 IRDA_WARNING("%s: No data, or not connected\n", __FUNCTION__);
604 ret = -ENOTCONN;
605 goto err;
606 }
607
608
609
610
611
612 if ((self->tx_max_sdu_size == 0) && (skb->len > self->max_seg_size)) {
613 IRDA_ERROR("%s: SAR disabled, and data is too large for IrLAP!\n",
614 __FUNCTION__);
615 ret = -EMSGSIZE;
616 goto err;
617 }
618
619
620
621
622
623 if ((self->tx_max_sdu_size != 0) &&
624 (self->tx_max_sdu_size != TTP_SAR_UNBOUND) &&
625 (skb->len > self->tx_max_sdu_size))
626 {
627 IRDA_ERROR("%s: SAR enabled, but data is larger than TxMaxSduSize!\n",
628 __FUNCTION__);
629 ret = -EMSGSIZE;
630 goto err;
631 }
632
633
634
635 if (skb_queue_len(&self->tx_queue) >= TTP_TX_MAX_QUEUE) {
636
637
638
639 irttp_run_tx_queue(self);
640
641
642
643 ret = -ENOBUFS;
644 goto err;
645 }
646
647
648 if ((self->tx_max_sdu_size == 0) || (skb->len < self->max_seg_size)) {
649
650 IRDA_ASSERT(skb_headroom(skb) >= TTP_HEADER, return -1;);
651 frame = skb_push(skb, TTP_HEADER);
652 frame[0] = 0x00;
653
654 skb_queue_tail(&self->tx_queue, skb);
655 } else {
656
657
658
659
660
661
662 irttp_fragment_skb(self, skb);
663 }
664
665
666 if ((!self->tx_sdu_busy) &&
667 (skb_queue_len(&self->tx_queue) > TTP_TX_HIGH_THRESHOLD)) {
668
669 if (self->notify.flow_indication) {
670 self->notify.flow_indication(self->notify.instance,
671 self, FLOW_STOP);
672 }
673
674
675
676
677
678
679
680 self->tx_sdu_busy = TRUE;
681 }
682
683
684 irttp_run_tx_queue(self);
685
686 return 0;
687
688err:
689 dev_kfree_skb(skb);
690 return ret;
691}
692EXPORT_SYMBOL(irttp_data_request);
693
694
695
696
697
698
699
700static void irttp_run_tx_queue(struct tsap_cb *self)
701{
702 struct sk_buff *skb;
703 unsigned long flags;
704 int n;
705
706 IRDA_DEBUG(2, "%s() : send_credit = %d, queue_len = %d\n",
707 __FUNCTION__,
708 self->send_credit, skb_queue_len(&self->tx_queue));
709
710
711 if (irda_lock(&self->tx_queue_lock) == FALSE)
712 return;
713
714
715
716
717 while ((self->send_credit > 0) &&
718 (!irlmp_lap_tx_queue_full(self->lsap)) &&
719 (skb = skb_dequeue(&self->tx_queue)))
720 {
721
722
723
724
725
726 spin_lock_irqsave(&self->lock, flags);
727
728 n = self->avail_credit;
729 self->avail_credit = 0;
730
731
732 if (n > 127) {
733 self->avail_credit = n-127;
734 n = 127;
735 }
736 self->remote_credit += n;
737 self->send_credit--;
738
739 spin_unlock_irqrestore(&self->lock, flags);
740
741
742
743
744
745 skb->data[0] |= (n & 0x7f);
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765 if (skb->sk != NULL) {
766
767 skb_orphan(skb);
768 }
769
770
771
772 irlmp_data_request(self->lsap, skb);
773 self->stats.tx_packets++;
774 }
775
776
777
778
779
780
781
782 if ((self->tx_sdu_busy) &&
783 (skb_queue_len(&self->tx_queue) < TTP_TX_LOW_THRESHOLD) &&
784 (!self->close_pend))
785 {
786 if (self->notify.flow_indication)
787 self->notify.flow_indication(self->notify.instance,
788 self, FLOW_START);
789
790
791
792
793 self->tx_sdu_busy = FALSE;
794 }
795
796
797 self->tx_queue_lock = 0;
798}
799
800
801
802
803
804
805
806static inline void irttp_give_credit(struct tsap_cb *self)
807{
808 struct sk_buff *tx_skb = NULL;
809 unsigned long flags;
810 int n;
811
812 IRDA_ASSERT(self != NULL, return;);
813 IRDA_ASSERT(self->magic == TTP_TSAP_MAGIC, return;);
814
815 IRDA_DEBUG(4, "%s() send=%d,avail=%d,remote=%d\n",
816 __FUNCTION__,
817 self->send_credit, self->avail_credit, self->remote_credit);
818
819
820 tx_skb = alloc_skb(TTP_MAX_HEADER, GFP_ATOMIC);
821 if (!tx_skb)
822 return;
823
824
825 skb_reserve(tx_skb, LMP_MAX_HEADER);
826
827
828
829
830
831
832 spin_lock_irqsave(&self->lock, flags);
833
834 n = self->avail_credit;
835 self->avail_credit = 0;
836
837
838 if (n > 127) {
839 self->avail_credit = n - 127;
840 n = 127;
841 }
842 self->remote_credit += n;
843
844 spin_unlock_irqrestore(&self->lock, flags);
845
846 skb_put(tx_skb, 1);
847 tx_skb->data[0] = (__u8) (n & 0x7f);
848
849 irlmp_data_request(self->lsap, tx_skb);
850 self->stats.tx_packets++;
851}
852
853
854
855
856
857
858
859static int irttp_udata_indication(void *instance, void *sap,
860 struct sk_buff *skb)
861{
862 struct tsap_cb *self;
863 int err;
864
865 IRDA_DEBUG(4, "%s()\n", __FUNCTION__);
866
867 self = (struct tsap_cb *) instance;
868
869 IRDA_ASSERT(self != NULL, return -1;);
870 IRDA_ASSERT(self->magic == TTP_TSAP_MAGIC, return -1;);
871 IRDA_ASSERT(skb != NULL, return -1;);
872
873 self->stats.rx_packets++;
874
875
876 if (self->notify.udata_indication) {
877 err = self->notify.udata_indication(self->notify.instance,
878 self,skb);
879
880 if (!err)
881 return 0;
882 }
883
884 dev_kfree_skb(skb);
885
886 return 0;
887}
888
889
890
891
892
893
894
895static int irttp_data_indication(void *instance, void *sap,
896 struct sk_buff *skb)
897{
898 struct tsap_cb *self;
899 unsigned long flags;
900 int n;
901
902 self = (struct tsap_cb *) instance;
903
904 n = skb->data[0] & 0x7f;
905
906 self->stats.rx_packets++;
907
908
909
910
911
912
913 spin_lock_irqsave(&self->lock, flags);
914 self->send_credit += n;
915 if (skb->len > 1)
916 self->remote_credit--;
917 spin_unlock_irqrestore(&self->lock, flags);
918
919
920
921
922
923 if (skb->len > 1) {
924
925
926
927
928 skb_queue_tail(&self->rx_queue, skb);
929 } else {
930
931 dev_kfree_skb(skb);
932 }
933
934
935
936
937
938
939
940
941
942
943
944
945
946 irttp_run_rx_queue(self);
947
948
949
950
951
952
953
954
955
956
957
958
959
960 if (self->send_credit == n) {
961
962 irttp_run_tx_queue(self);
963
964
965
966 }
967
968 return 0;
969}
970
971
972
973
974
975
976
977static void irttp_status_indication(void *instance,
978 LINK_STATUS link, LOCK_STATUS lock)
979{
980 struct tsap_cb *self;
981
982 IRDA_DEBUG(4, "%s()\n", __FUNCTION__);
983
984 self = (struct tsap_cb *) instance;
985
986 IRDA_ASSERT(self != NULL, return;);
987 IRDA_ASSERT(self->magic == TTP_TSAP_MAGIC, return;);
988
989
990 if (self->close_pend)
991 return;
992
993
994
995
996 if (self->notify.status_indication != NULL)
997 self->notify.status_indication(self->notify.instance,
998 link, lock);
999 else
1000 IRDA_DEBUG(2, "%s(), no handler\n", __FUNCTION__);
1001}
1002
1003
1004
1005
1006
1007
1008
1009static void irttp_flow_indication(void *instance, void *sap, LOCAL_FLOW flow)
1010{
1011 struct tsap_cb *self;
1012
1013 self = (struct tsap_cb *) instance;
1014
1015 IRDA_ASSERT(self != NULL, return;);
1016 IRDA_ASSERT(self->magic == TTP_TSAP_MAGIC, return;);
1017
1018 IRDA_DEBUG(4, "%s(instance=%p)\n", __FUNCTION__, self);
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029 irttp_run_tx_queue(self);
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043 if(self->disconnect_pend)
1044 irttp_start_todo_timer(self, 0);
1045}
1046
1047
1048
1049
1050
1051
1052
1053
1054void irttp_flow_request(struct tsap_cb *self, LOCAL_FLOW flow)
1055{
1056 IRDA_DEBUG(1, "%s()\n", __FUNCTION__);
1057
1058 IRDA_ASSERT(self != NULL, return;);
1059 IRDA_ASSERT(self->magic == TTP_TSAP_MAGIC, return;);
1060
1061 switch (flow) {
1062 case FLOW_STOP:
1063 IRDA_DEBUG(1, "%s(), flow stop\n", __FUNCTION__);
1064 self->rx_sdu_busy = TRUE;
1065 break;
1066 case FLOW_START:
1067 IRDA_DEBUG(1, "%s(), flow start\n", __FUNCTION__);
1068 self->rx_sdu_busy = FALSE;
1069
1070
1071
1072 irttp_run_rx_queue(self);
1073
1074 break;
1075 default:
1076 IRDA_DEBUG(1, "%s(), Unknown flow command!\n", __FUNCTION__);
1077 }
1078}
1079EXPORT_SYMBOL(irttp_flow_request);
1080
1081
1082
1083
1084
1085
1086
1087int irttp_connect_request(struct tsap_cb *self, __u8 dtsap_sel,
1088 __u32 saddr, __u32 daddr,
1089 struct qos_info *qos, __u32 max_sdu_size,
1090 struct sk_buff *userdata)
1091{
1092 struct sk_buff *tx_skb;
1093 __u8 *frame;
1094 __u8 n;
1095
1096 IRDA_DEBUG(4, "%s(), max_sdu_size=%d\n", __FUNCTION__, max_sdu_size);
1097
1098 IRDA_ASSERT(self != NULL, return -EBADR;);
1099 IRDA_ASSERT(self->magic == TTP_TSAP_MAGIC, return -EBADR;);
1100
1101 if (self->connected) {
1102 if(userdata)
1103 dev_kfree_skb(userdata);
1104 return -EISCONN;
1105 }
1106
1107
1108 if (userdata == NULL) {
1109 tx_skb = alloc_skb(TTP_MAX_HEADER + TTP_SAR_HEADER,
1110 GFP_ATOMIC);
1111 if (!tx_skb)
1112 return -ENOMEM;
1113
1114
1115 skb_reserve(tx_skb, TTP_MAX_HEADER + TTP_SAR_HEADER);
1116 } else {
1117 tx_skb = userdata;
1118
1119
1120
1121
1122 IRDA_ASSERT(skb_headroom(userdata) >= TTP_MAX_HEADER,
1123 { dev_kfree_skb(userdata); return -1; } );
1124 }
1125
1126
1127 self->connected = FALSE;
1128 self->avail_credit = 0;
1129 self->rx_max_sdu_size = max_sdu_size;
1130 self->rx_sdu_size = 0;
1131 self->rx_sdu_busy = FALSE;
1132 self->dtsap_sel = dtsap_sel;
1133
1134 n = self->initial_credit;
1135
1136 self->remote_credit = 0;
1137 self->send_credit = 0;
1138
1139
1140
1141
1142 if (n > 127) {
1143 self->avail_credit=n-127;
1144 n = 127;
1145 }
1146
1147 self->remote_credit = n;
1148
1149
1150 if (max_sdu_size > 0) {
1151 IRDA_ASSERT(skb_headroom(tx_skb) >= (TTP_MAX_HEADER + TTP_SAR_HEADER),
1152 { dev_kfree_skb(tx_skb); return -1; } );
1153
1154
1155 frame = skb_push(tx_skb, TTP_HEADER+TTP_SAR_HEADER);
1156
1157 frame[0] = TTP_PARAMETERS | n;
1158 frame[1] = 0x04;
1159 frame[2] = 0x01;
1160 frame[3] = 0x02;
1161
1162 put_unaligned(cpu_to_be16((__u16) max_sdu_size),
1163 (__be16 *)(frame+4));
1164 } else {
1165
1166 frame = skb_push(tx_skb, TTP_HEADER);
1167
1168
1169 frame[0] = n & 0x7f;
1170 }
1171
1172
1173 return irlmp_connect_request(self->lsap, dtsap_sel, saddr, daddr, qos,
1174 tx_skb);
1175}
1176EXPORT_SYMBOL(irttp_connect_request);
1177
1178
1179
1180
1181
1182
1183
1184static void irttp_connect_confirm(void *instance, void *sap,
1185 struct qos_info *qos, __u32 max_seg_size,
1186 __u8 max_header_size, struct sk_buff *skb)
1187{
1188 struct tsap_cb *self;
1189 int parameters;
1190 int ret;
1191 __u8 plen;
1192 __u8 n;
1193
1194 IRDA_DEBUG(4, "%s()\n", __FUNCTION__);
1195
1196 self = (struct tsap_cb *) instance;
1197
1198 IRDA_ASSERT(self != NULL, return;);
1199 IRDA_ASSERT(self->magic == TTP_TSAP_MAGIC, return;);
1200 IRDA_ASSERT(skb != NULL, return;);
1201
1202 self->max_seg_size = max_seg_size - TTP_HEADER;
1203 self->max_header_size = max_header_size + TTP_HEADER;
1204
1205
1206
1207
1208
1209 if (qos) {
1210 IRDA_DEBUG(4, "IrTTP, Negotiated BAUD_RATE: %02x\n",
1211 qos->baud_rate.bits);
1212 IRDA_DEBUG(4, "IrTTP, Negotiated BAUD_RATE: %d bps.\n",
1213 qos->baud_rate.value);
1214 }
1215
1216 n = skb->data[0] & 0x7f;
1217
1218 IRDA_DEBUG(4, "%s(), Initial send_credit=%d\n", __FUNCTION__, n);
1219
1220 self->send_credit = n;
1221 self->tx_max_sdu_size = 0;
1222 self->connected = TRUE;
1223
1224 parameters = skb->data[0] & 0x80;
1225
1226 IRDA_ASSERT(skb->len >= TTP_HEADER, return;);
1227 skb_pull(skb, TTP_HEADER);
1228
1229 if (parameters) {
1230 plen = skb->data[0];
1231
1232 ret = irda_param_extract_all(self, skb->data+1,
1233 IRDA_MIN(skb->len-1, plen),
1234 ¶m_info);
1235
1236
1237 if (ret < 0) {
1238 IRDA_WARNING("%s: error extracting parameters\n",
1239 __FUNCTION__);
1240 dev_kfree_skb(skb);
1241
1242
1243 return;
1244 }
1245
1246 skb_pull(skb, IRDA_MIN(skb->len, plen+1));
1247 }
1248
1249 IRDA_DEBUG(4, "%s() send=%d,avail=%d,remote=%d\n", __FUNCTION__,
1250 self->send_credit, self->avail_credit, self->remote_credit);
1251
1252 IRDA_DEBUG(2, "%s(), MaxSduSize=%d\n", __FUNCTION__,
1253 self->tx_max_sdu_size);
1254
1255 if (self->notify.connect_confirm) {
1256 self->notify.connect_confirm(self->notify.instance, self, qos,
1257 self->tx_max_sdu_size,
1258 self->max_header_size, skb);
1259 } else
1260 dev_kfree_skb(skb);
1261}
1262
1263
1264
1265
1266
1267
1268
1269void irttp_connect_indication(void *instance, void *sap, struct qos_info *qos,
1270 __u32 max_seg_size, __u8 max_header_size,
1271 struct sk_buff *skb)
1272{
1273 struct tsap_cb *self;
1274 struct lsap_cb *lsap;
1275 int parameters;
1276 int ret;
1277 __u8 plen;
1278 __u8 n;
1279
1280 self = (struct tsap_cb *) instance;
1281
1282 IRDA_ASSERT(self != NULL, return;);
1283 IRDA_ASSERT(self->magic == TTP_TSAP_MAGIC, return;);
1284 IRDA_ASSERT(skb != NULL, return;);
1285
1286 lsap = (struct lsap_cb *) sap;
1287
1288 self->max_seg_size = max_seg_size - TTP_HEADER;
1289 self->max_header_size = max_header_size+TTP_HEADER;
1290
1291 IRDA_DEBUG(4, "%s(), TSAP sel=%02x\n", __FUNCTION__, self->stsap_sel);
1292
1293
1294 self->dtsap_sel = lsap->dlsap_sel;
1295
1296 n = skb->data[0] & 0x7f;
1297
1298 self->send_credit = n;
1299 self->tx_max_sdu_size = 0;
1300
1301 parameters = skb->data[0] & 0x80;
1302
1303 IRDA_ASSERT(skb->len >= TTP_HEADER, return;);
1304 skb_pull(skb, TTP_HEADER);
1305
1306 if (parameters) {
1307 plen = skb->data[0];
1308
1309 ret = irda_param_extract_all(self, skb->data+1,
1310 IRDA_MIN(skb->len-1, plen),
1311 ¶m_info);
1312
1313
1314 if (ret < 0) {
1315 IRDA_WARNING("%s: error extracting parameters\n",
1316 __FUNCTION__);
1317 dev_kfree_skb(skb);
1318
1319
1320 return;
1321 }
1322
1323
1324 skb_pull(skb, IRDA_MIN(skb->len, plen+1));
1325 }
1326
1327 if (self->notify.connect_indication) {
1328 self->notify.connect_indication(self->notify.instance, self,
1329 qos, self->tx_max_sdu_size,
1330 self->max_header_size, skb);
1331 } else
1332 dev_kfree_skb(skb);
1333}
1334
1335
1336
1337
1338
1339
1340
1341
1342int irttp_connect_response(struct tsap_cb *self, __u32 max_sdu_size,
1343 struct sk_buff *userdata)
1344{
1345 struct sk_buff *tx_skb;
1346 __u8 *frame;
1347 int ret;
1348 __u8 n;
1349
1350 IRDA_ASSERT(self != NULL, return -1;);
1351 IRDA_ASSERT(self->magic == TTP_TSAP_MAGIC, return -1;);
1352
1353 IRDA_DEBUG(4, "%s(), Source TSAP selector=%02x\n", __FUNCTION__,
1354 self->stsap_sel);
1355
1356
1357 if (userdata == NULL) {
1358 tx_skb = alloc_skb(TTP_MAX_HEADER + TTP_SAR_HEADER,
1359 GFP_ATOMIC);
1360 if (!tx_skb)
1361 return -ENOMEM;
1362
1363
1364 skb_reserve(tx_skb, TTP_MAX_HEADER + TTP_SAR_HEADER);
1365 } else {
1366 tx_skb = userdata;
1367
1368
1369
1370
1371 IRDA_ASSERT(skb_headroom(userdata) >= TTP_MAX_HEADER,
1372 { dev_kfree_skb(userdata); return -1; } );
1373 }
1374
1375 self->avail_credit = 0;
1376 self->remote_credit = 0;
1377 self->rx_max_sdu_size = max_sdu_size;
1378 self->rx_sdu_size = 0;
1379 self->rx_sdu_busy = FALSE;
1380
1381 n = self->initial_credit;
1382
1383
1384 if (n > 127) {
1385 self->avail_credit = n - 127;
1386 n = 127;
1387 }
1388
1389 self->remote_credit = n;
1390 self->connected = TRUE;
1391
1392
1393 if (max_sdu_size > 0) {
1394 IRDA_ASSERT(skb_headroom(tx_skb) >= (TTP_MAX_HEADER + TTP_SAR_HEADER),
1395 { dev_kfree_skb(tx_skb); return -1; } );
1396
1397
1398 frame = skb_push(tx_skb, TTP_HEADER+TTP_SAR_HEADER);
1399
1400 frame[0] = TTP_PARAMETERS | n;
1401 frame[1] = 0x04;
1402
1403
1404
1405
1406 frame[2] = 0x01;
1407 frame[3] = 0x02;
1408
1409 put_unaligned(cpu_to_be16((__u16) max_sdu_size),
1410 (__be16 *)(frame+4));
1411 } else {
1412
1413 frame = skb_push(tx_skb, TTP_HEADER);
1414
1415 frame[0] = n & 0x7f;
1416 }
1417
1418 ret = irlmp_connect_response(self->lsap, tx_skb);
1419
1420 return ret;
1421}
1422EXPORT_SYMBOL(irttp_connect_response);
1423
1424
1425
1426
1427
1428
1429
1430struct tsap_cb *irttp_dup(struct tsap_cb *orig, void *instance)
1431{
1432 struct tsap_cb *new;
1433 unsigned long flags;
1434
1435 IRDA_DEBUG(1, "%s()\n", __FUNCTION__);
1436
1437
1438 spin_lock_irqsave(&irttp->tsaps->hb_spinlock, flags);
1439
1440
1441 if (!hashbin_find(irttp->tsaps, (long) orig, NULL)) {
1442 IRDA_DEBUG(0, "%s(), unable to find TSAP\n", __FUNCTION__);
1443 spin_unlock_irqrestore(&irttp->tsaps->hb_spinlock, flags);
1444 return NULL;
1445 }
1446
1447
1448 new = kmalloc(sizeof(struct tsap_cb), GFP_ATOMIC);
1449 if (!new) {
1450 IRDA_DEBUG(0, "%s(), unable to kmalloc\n", __FUNCTION__);
1451 spin_unlock_irqrestore(&irttp->tsaps->hb_spinlock, flags);
1452 return NULL;
1453 }
1454
1455 memcpy(new, orig, sizeof(struct tsap_cb));
1456
1457
1458 spin_unlock_irqrestore(&irttp->tsaps->hb_spinlock, flags);
1459
1460
1461 new->lsap = irlmp_dup(orig->lsap, new);
1462 if (!new->lsap) {
1463 IRDA_DEBUG(0, "%s(), dup failed!\n", __FUNCTION__);
1464 kfree(new);
1465 return NULL;
1466 }
1467
1468
1469 new->notify.instance = instance;
1470
1471
1472 irttp_init_tsap(new);
1473
1474
1475 hashbin_insert(irttp->tsaps, (irda_queue_t *) new, (long) new, NULL);
1476
1477 return new;
1478}
1479EXPORT_SYMBOL(irttp_dup);
1480
1481
1482
1483
1484
1485
1486
1487
1488int irttp_disconnect_request(struct tsap_cb *self, struct sk_buff *userdata,
1489 int priority)
1490{
1491 int ret;
1492
1493 IRDA_ASSERT(self != NULL, return -1;);
1494 IRDA_ASSERT(self->magic == TTP_TSAP_MAGIC, return -1;);
1495
1496
1497 if (!self->connected) {
1498 IRDA_DEBUG(4, "%s(), already disconnected!\n", __FUNCTION__);
1499 if (userdata)
1500 dev_kfree_skb(userdata);
1501 return -1;
1502 }
1503
1504
1505
1506
1507
1508
1509 if(test_and_set_bit(0, &self->disconnect_pend)) {
1510 IRDA_DEBUG(0, "%s(), disconnect already pending\n",
1511 __FUNCTION__);
1512 if (userdata)
1513 dev_kfree_skb(userdata);
1514
1515
1516 irttp_run_tx_queue(self);
1517 return -1;
1518 }
1519
1520
1521
1522
1523 if (!skb_queue_empty(&self->tx_queue)) {
1524 if (priority == P_HIGH) {
1525
1526
1527
1528
1529
1530 IRDA_DEBUG(1, "%s(): High priority!!()\n", __FUNCTION__);
1531 irttp_flush_queues(self);
1532 } else if (priority == P_NORMAL) {
1533
1534
1535
1536
1537
1538 self->disconnect_skb = userdata;
1539
1540 irttp_run_tx_queue(self);
1541
1542 irttp_start_todo_timer(self, HZ/10);
1543 return -1;
1544 }
1545 }
1546
1547
1548
1549
1550
1551 IRDA_DEBUG(1, "%s(), Disconnecting ...\n", __FUNCTION__);
1552 self->connected = FALSE;
1553
1554 if (!userdata) {
1555 struct sk_buff *tx_skb;
1556 tx_skb = alloc_skb(LMP_MAX_HEADER, GFP_ATOMIC);
1557 if (!tx_skb)
1558 return -ENOMEM;
1559
1560
1561
1562
1563 skb_reserve(tx_skb, LMP_MAX_HEADER);
1564
1565 userdata = tx_skb;
1566 }
1567 ret = irlmp_disconnect_request(self->lsap, userdata);
1568
1569
1570 clear_bit(0, &self->disconnect_pend);
1571
1572 return ret;
1573}
1574EXPORT_SYMBOL(irttp_disconnect_request);
1575
1576
1577
1578
1579
1580
1581
1582void irttp_disconnect_indication(void *instance, void *sap, LM_REASON reason,
1583 struct sk_buff *skb)
1584{
1585 struct tsap_cb *self;
1586
1587 IRDA_DEBUG(4, "%s()\n", __FUNCTION__);
1588
1589 self = (struct tsap_cb *) instance;
1590
1591 IRDA_ASSERT(self != NULL, return;);
1592 IRDA_ASSERT(self->magic == TTP_TSAP_MAGIC, return;);
1593
1594
1595 self->connected = FALSE;
1596
1597
1598 if (self->close_pend) {
1599
1600
1601 if (skb)
1602 dev_kfree_skb(skb);
1603 irttp_close_tsap(self);
1604 return;
1605 }
1606
1607
1608
1609
1610
1611
1612
1613
1614 if(self->notify.disconnect_indication)
1615 self->notify.disconnect_indication(self->notify.instance, self,
1616 reason, skb);
1617 else
1618 if (skb)
1619 dev_kfree_skb(skb);
1620}
1621
1622
1623
1624
1625
1626
1627
1628
1629static void irttp_do_data_indication(struct tsap_cb *self, struct sk_buff *skb)
1630{
1631 int err;
1632
1633
1634 if (self->close_pend) {
1635 dev_kfree_skb(skb);
1636 return;
1637 }
1638
1639 err = self->notify.data_indication(self->notify.instance, self, skb);
1640
1641
1642
1643
1644
1645
1646 if (err) {
1647 IRDA_DEBUG(0, "%s() requeueing skb!\n", __FUNCTION__);
1648
1649
1650 self->rx_sdu_busy = TRUE;
1651
1652
1653 skb_push(skb, TTP_HEADER);
1654 skb->data[0] = 0x00;
1655
1656
1657 skb_queue_head(&self->rx_queue, skb);
1658 }
1659}
1660
1661
1662
1663
1664
1665
1666
1667void irttp_run_rx_queue(struct tsap_cb *self)
1668{
1669 struct sk_buff *skb;
1670 int more = 0;
1671
1672 IRDA_DEBUG(2, "%s() send=%d,avail=%d,remote=%d\n", __FUNCTION__,
1673 self->send_credit, self->avail_credit, self->remote_credit);
1674
1675
1676 if (irda_lock(&self->rx_queue_lock) == FALSE)
1677 return;
1678
1679
1680
1681
1682 while (!self->rx_sdu_busy && (skb = skb_dequeue(&self->rx_queue))) {
1683
1684 more = skb->data[0] & 0x80;
1685
1686
1687 skb_pull(skb, TTP_HEADER);
1688
1689
1690 self->rx_sdu_size += skb->len;
1691
1692
1693
1694
1695
1696
1697
1698 if (self->rx_max_sdu_size == TTP_SAR_DISABLE) {
1699 irttp_do_data_indication(self, skb);
1700 self->rx_sdu_size = 0;
1701
1702 continue;
1703 }
1704
1705
1706 if (more) {
1707
1708
1709
1710
1711 if (self->rx_sdu_size <= self->rx_max_sdu_size) {
1712 IRDA_DEBUG(4, "%s(), queueing frag\n",
1713 __FUNCTION__);
1714 skb_queue_tail(&self->rx_fragments, skb);
1715 } else {
1716
1717 dev_kfree_skb(skb);
1718 }
1719 continue;
1720 }
1721
1722
1723
1724 if ((self->rx_sdu_size <= self->rx_max_sdu_size) ||
1725 (self->rx_max_sdu_size == TTP_SAR_UNBOUND))
1726 {
1727
1728
1729
1730
1731
1732
1733 if (!skb_queue_empty(&self->rx_fragments)) {
1734 skb_queue_tail(&self->rx_fragments,
1735 skb);
1736
1737 skb = irttp_reassemble_skb(self);
1738 }
1739
1740
1741 irttp_do_data_indication(self, skb);
1742 } else {
1743 IRDA_DEBUG(1, "%s(), Truncated frame\n", __FUNCTION__);
1744
1745
1746 dev_kfree_skb(skb);
1747
1748
1749 skb = irttp_reassemble_skb(self);
1750
1751 irttp_do_data_indication(self, skb);
1752 }
1753 self->rx_sdu_size = 0;
1754 }
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767 self->avail_credit = (self->initial_credit -
1768 (self->remote_credit +
1769 skb_queue_len(&self->rx_queue) +
1770 skb_queue_len(&self->rx_fragments)));
1771
1772
1773 if ((self->remote_credit <= TTP_RX_MIN_CREDIT) &&
1774 (self->avail_credit > 0)) {
1775
1776 irttp_give_credit(self);
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791 }
1792
1793
1794 self->rx_queue_lock = 0;
1795}
1796
1797#ifdef CONFIG_PROC_FS
1798struct irttp_iter_state {
1799 int id;
1800};
1801
1802static void *irttp_seq_start(struct seq_file *seq, loff_t *pos)
1803{
1804 struct irttp_iter_state *iter = seq->private;
1805 struct tsap_cb *self;
1806
1807
1808 spin_lock_irq(&irttp->tsaps->hb_spinlock);
1809 iter->id = 0;
1810
1811 for (self = (struct tsap_cb *) hashbin_get_first(irttp->tsaps);
1812 self != NULL;
1813 self = (struct tsap_cb *) hashbin_get_next(irttp->tsaps)) {
1814 if (iter->id == *pos)
1815 break;
1816 ++iter->id;
1817 }
1818
1819 return self;
1820}
1821
1822static void *irttp_seq_next(struct seq_file *seq, void *v, loff_t *pos)
1823{
1824 struct irttp_iter_state *iter = seq->private;
1825
1826 ++*pos;
1827 ++iter->id;
1828 return (void *) hashbin_get_next(irttp->tsaps);
1829}
1830
1831static void irttp_seq_stop(struct seq_file *seq, void *v)
1832{
1833 spin_unlock_irq(&irttp->tsaps->hb_spinlock);
1834}
1835
1836static int irttp_seq_show(struct seq_file *seq, void *v)
1837{
1838 const struct irttp_iter_state *iter = seq->private;
1839 const struct tsap_cb *self = v;
1840
1841 seq_printf(seq, "TSAP %d, ", iter->id);
1842 seq_printf(seq, "stsap_sel: %02x, ",
1843 self->stsap_sel);
1844 seq_printf(seq, "dtsap_sel: %02x\n",
1845 self->dtsap_sel);
1846 seq_printf(seq, " connected: %s, ",
1847 self->connected? "TRUE":"FALSE");
1848 seq_printf(seq, "avail credit: %d, ",
1849 self->avail_credit);
1850 seq_printf(seq, "remote credit: %d, ",
1851 self->remote_credit);
1852 seq_printf(seq, "send credit: %d\n",
1853 self->send_credit);
1854 seq_printf(seq, " tx packets: %ld, ",
1855 self->stats.tx_packets);
1856 seq_printf(seq, "rx packets: %ld, ",
1857 self->stats.rx_packets);
1858 seq_printf(seq, "tx_queue len: %d ",
1859 skb_queue_len(&self->tx_queue));
1860 seq_printf(seq, "rx_queue len: %d\n",
1861 skb_queue_len(&self->rx_queue));
1862 seq_printf(seq, " tx_sdu_busy: %s, ",
1863 self->tx_sdu_busy? "TRUE":"FALSE");
1864 seq_printf(seq, "rx_sdu_busy: %s\n",
1865 self->rx_sdu_busy? "TRUE":"FALSE");
1866 seq_printf(seq, " max_seg_size: %d, ",
1867 self->max_seg_size);
1868 seq_printf(seq, "tx_max_sdu_size: %d, ",
1869 self->tx_max_sdu_size);
1870 seq_printf(seq, "rx_max_sdu_size: %d\n",
1871 self->rx_max_sdu_size);
1872
1873 seq_printf(seq, " Used by (%s)\n\n",
1874 self->notify.name);
1875 return 0;
1876}
1877
1878static const struct seq_operations irttp_seq_ops = {
1879 .start = irttp_seq_start,
1880 .next = irttp_seq_next,
1881 .stop = irttp_seq_stop,
1882 .show = irttp_seq_show,
1883};
1884
1885static int irttp_seq_open(struct inode *inode, struct file *file)
1886{
1887 return seq_open_private(file, &irttp_seq_ops,
1888 sizeof(struct irttp_iter_state));
1889}
1890
1891const struct file_operations irttp_seq_fops = {
1892 .owner = THIS_MODULE,
1893 .open = irttp_seq_open,
1894 .read = seq_read,
1895 .llseek = seq_lseek,
1896 .release = seq_release_private,
1897};
1898
1899#endif
1900