aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/isdn/gigaset/capi.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/isdn/gigaset/capi.c')
-rw-r--r--drivers/isdn/gigaset/capi.c405
1 files changed, 285 insertions, 120 deletions
diff --git a/drivers/isdn/gigaset/capi.c b/drivers/isdn/gigaset/capi.c
index 8f78f15c8ef7..6fbe8999c419 100644
--- a/drivers/isdn/gigaset/capi.c
+++ b/drivers/isdn/gigaset/capi.c
@@ -70,7 +70,7 @@
70#define MAX_NUMBER_DIGITS 20 70#define MAX_NUMBER_DIGITS 20
71#define MAX_FMT_IE_LEN 20 71#define MAX_FMT_IE_LEN 20
72 72
73/* values for gigaset_capi_appl.connected */ 73/* values for bcs->apconnstate */
74#define APCONN_NONE 0 /* inactive/listening */ 74#define APCONN_NONE 0 /* inactive/listening */
75#define APCONN_SETUP 1 /* connecting */ 75#define APCONN_SETUP 1 /* connecting */
76#define APCONN_ACTIVE 2 /* B channel up */ 76#define APCONN_ACTIVE 2 /* B channel up */
@@ -80,10 +80,10 @@ struct gigaset_capi_appl {
80 struct list_head ctrlist; 80 struct list_head ctrlist;
81 struct gigaset_capi_appl *bcnext; 81 struct gigaset_capi_appl *bcnext;
82 u16 id; 82 u16 id;
83 struct capi_register_params rp;
83 u16 nextMessageNumber; 84 u16 nextMessageNumber;
84 u32 listenInfoMask; 85 u32 listenInfoMask;
85 u32 listenCIPmask; 86 u32 listenCIPmask;
86 int connected;
87}; 87};
88 88
89/* CAPI specific controller data structure */ 89/* CAPI specific controller data structure */
@@ -319,6 +319,39 @@ static const char *format_ie(const char *ie)
319 return result; 319 return result;
320} 320}
321 321
322/*
323 * emit DATA_B3_CONF message
324 */
325static void send_data_b3_conf(struct cardstate *cs, struct capi_ctr *ctr,
326 u16 appl, u16 msgid, int channel,
327 u16 handle, u16 info)
328{
329 struct sk_buff *cskb;
330 u8 *msg;
331
332 cskb = alloc_skb(CAPI_DATA_B3_CONF_LEN, GFP_ATOMIC);
333 if (!cskb) {
334 dev_err(cs->dev, "%s: out of memory\n", __func__);
335 return;
336 }
337 /* frequent message, avoid _cmsg overhead */
338 msg = __skb_put(cskb, CAPI_DATA_B3_CONF_LEN);
339 CAPIMSG_SETLEN(msg, CAPI_DATA_B3_CONF_LEN);
340 CAPIMSG_SETAPPID(msg, appl);
341 CAPIMSG_SETCOMMAND(msg, CAPI_DATA_B3);
342 CAPIMSG_SETSUBCOMMAND(msg, CAPI_CONF);
343 CAPIMSG_SETMSGID(msg, msgid);
344 CAPIMSG_SETCONTROLLER(msg, ctr->cnr);
345 CAPIMSG_SETPLCI_PART(msg, channel);
346 CAPIMSG_SETNCCI_PART(msg, 1);
347 CAPIMSG_SETHANDLE_CONF(msg, handle);
348 CAPIMSG_SETINFO_CONF(msg, info);
349
350 /* emit message */
351 dump_rawmsg(DEBUG_MCMD, __func__, msg);
352 capi_ctr_handle_message(ctr, appl, cskb);
353}
354
322 355
323/* 356/*
324 * driver interface functions 357 * driver interface functions
@@ -339,7 +372,6 @@ void gigaset_skb_sent(struct bc_state *bcs, struct sk_buff *dskb)
339 struct gigaset_capi_ctr *iif = cs->iif; 372 struct gigaset_capi_ctr *iif = cs->iif;
340 struct gigaset_capi_appl *ap = bcs->ap; 373 struct gigaset_capi_appl *ap = bcs->ap;
341 unsigned char *req = skb_mac_header(dskb); 374 unsigned char *req = skb_mac_header(dskb);
342 struct sk_buff *cskb;
343 u16 flags; 375 u16 flags;
344 376
345 /* update statistics */ 377 /* update statistics */
@@ -351,39 +383,22 @@ void gigaset_skb_sent(struct bc_state *bcs, struct sk_buff *dskb)
351 } 383 }
352 384
353 /* don't send further B3 messages if disconnected */ 385 /* don't send further B3 messages if disconnected */
354 if (ap->connected < APCONN_ACTIVE) { 386 if (bcs->apconnstate < APCONN_ACTIVE) {
355 gig_dbg(DEBUG_LLDATA, "disconnected, discarding ack"); 387 gig_dbg(DEBUG_LLDATA, "disconnected, discarding ack");
356 return; 388 return;
357 } 389 }
358 390
359 /* ToDo: honor unset "delivery confirmation" bit */ 391 /*
392 * send DATA_B3_CONF if "delivery confirmation" bit was set in request;
393 * otherwise it has already been sent by do_data_b3_req()
394 */
360 flags = CAPIMSG_FLAGS(req); 395 flags = CAPIMSG_FLAGS(req);
361 396 if (flags & CAPI_FLAGS_DELIVERY_CONFIRMATION)
362 /* build DATA_B3_CONF message */ 397 send_data_b3_conf(cs, &iif->ctr, ap->id, CAPIMSG_MSGID(req),
363 cskb = alloc_skb(CAPI_DATA_B3_CONF_LEN, GFP_ATOMIC); 398 bcs->channel + 1, CAPIMSG_HANDLE_REQ(req),
364 if (!cskb) { 399 (flags & ~CAPI_FLAGS_DELIVERY_CONFIRMATION) ?
365 dev_err(cs->dev, "%s: out of memory\n", __func__); 400 CapiFlagsNotSupportedByProtocol :
366 return; 401 CAPI_NOERROR);
367 }
368 /* frequent message, avoid _cmsg overhead */
369 CAPIMSG_SETLEN(cskb->data, CAPI_DATA_B3_CONF_LEN);
370 CAPIMSG_SETAPPID(cskb->data, ap->id);
371 CAPIMSG_SETCOMMAND(cskb->data, CAPI_DATA_B3);
372 CAPIMSG_SETSUBCOMMAND(cskb->data, CAPI_CONF);
373 CAPIMSG_SETMSGID(cskb->data, CAPIMSG_MSGID(req));
374 CAPIMSG_SETCONTROLLER(cskb->data, iif->ctr.cnr);
375 CAPIMSG_SETPLCI_PART(cskb->data, bcs->channel + 1);
376 CAPIMSG_SETNCCI_PART(cskb->data, 1);
377 CAPIMSG_SETHANDLE_CONF(cskb->data, CAPIMSG_HANDLE_REQ(req));
378 if (flags & ~CAPI_FLAGS_DELIVERY_CONFIRMATION)
379 CAPIMSG_SETINFO_CONF(cskb->data,
380 CapiFlagsNotSupportedByProtocol);
381 else
382 CAPIMSG_SETINFO_CONF(cskb->data, CAPI_NOERROR);
383
384 /* emit message */
385 dump_rawmsg(DEBUG_LLDATA, "DATA_B3_CONF", cskb->data);
386 capi_ctr_handle_message(&iif->ctr, ap->id, cskb);
387} 402}
388EXPORT_SYMBOL_GPL(gigaset_skb_sent); 403EXPORT_SYMBOL_GPL(gigaset_skb_sent);
389 404
@@ -412,7 +427,7 @@ void gigaset_skb_rcvd(struct bc_state *bcs, struct sk_buff *skb)
412 } 427 }
413 428
414 /* don't send further B3 messages if disconnected */ 429 /* don't send further B3 messages if disconnected */
415 if (ap->connected < APCONN_ACTIVE) { 430 if (bcs->apconnstate < APCONN_ACTIVE) {
416 gig_dbg(DEBUG_LLDATA, "disconnected, discarding data"); 431 gig_dbg(DEBUG_LLDATA, "disconnected, discarding data");
417 dev_kfree_skb_any(skb); 432 dev_kfree_skb_any(skb);
418 return; 433 return;
@@ -484,6 +499,7 @@ int gigaset_isdn_icall(struct at_state_t *at_state)
484 u32 actCIPmask; 499 u32 actCIPmask;
485 struct sk_buff *skb; 500 struct sk_buff *skb;
486 unsigned int msgsize; 501 unsigned int msgsize;
502 unsigned long flags;
487 int i; 503 int i;
488 504
489 /* 505 /*
@@ -608,7 +624,14 @@ int gigaset_isdn_icall(struct at_state_t *at_state)
608 format_ie(iif->hcmsg.CalledPartyNumber)); 624 format_ie(iif->hcmsg.CalledPartyNumber));
609 625
610 /* scan application list for matching listeners */ 626 /* scan application list for matching listeners */
611 bcs->ap = NULL; 627 spin_lock_irqsave(&bcs->aplock, flags);
628 if (bcs->ap != NULL || bcs->apconnstate != APCONN_NONE) {
629 dev_warn(cs->dev, "%s: channel not properly cleared (%p/%d)\n",
630 __func__, bcs->ap, bcs->apconnstate);
631 bcs->ap = NULL;
632 bcs->apconnstate = APCONN_NONE;
633 }
634 spin_unlock_irqrestore(&bcs->aplock, flags);
612 actCIPmask = 1 | (1 << iif->hcmsg.CIPValue); 635 actCIPmask = 1 | (1 << iif->hcmsg.CIPValue);
613 list_for_each_entry(ap, &iif->appls, ctrlist) 636 list_for_each_entry(ap, &iif->appls, ctrlist)
614 if (actCIPmask & ap->listenCIPmask) { 637 if (actCIPmask & ap->listenCIPmask) {
@@ -626,10 +649,12 @@ int gigaset_isdn_icall(struct at_state_t *at_state)
626 dump_cmsg(DEBUG_CMD, __func__, &iif->hcmsg); 649 dump_cmsg(DEBUG_CMD, __func__, &iif->hcmsg);
627 650
628 /* add to listeners on this B channel, update state */ 651 /* add to listeners on this B channel, update state */
652 spin_lock_irqsave(&bcs->aplock, flags);
629 ap->bcnext = bcs->ap; 653 ap->bcnext = bcs->ap;
630 bcs->ap = ap; 654 bcs->ap = ap;
631 bcs->chstate |= CHS_NOTIFY_LL; 655 bcs->chstate |= CHS_NOTIFY_LL;
632 ap->connected = APCONN_SETUP; 656 bcs->apconnstate = APCONN_SETUP;
657 spin_unlock_irqrestore(&bcs->aplock, flags);
633 658
634 /* emit message */ 659 /* emit message */
635 capi_ctr_handle_message(&iif->ctr, ap->id, skb); 660 capi_ctr_handle_message(&iif->ctr, ap->id, skb);
@@ -654,7 +679,7 @@ static void send_disconnect_ind(struct bc_state *bcs,
654 struct gigaset_capi_ctr *iif = cs->iif; 679 struct gigaset_capi_ctr *iif = cs->iif;
655 struct sk_buff *skb; 680 struct sk_buff *skb;
656 681
657 if (ap->connected == APCONN_NONE) 682 if (bcs->apconnstate == APCONN_NONE)
658 return; 683 return;
659 684
660 capi_cmsg_header(&iif->hcmsg, ap->id, CAPI_DISCONNECT, CAPI_IND, 685 capi_cmsg_header(&iif->hcmsg, ap->id, CAPI_DISCONNECT, CAPI_IND,
@@ -668,7 +693,6 @@ static void send_disconnect_ind(struct bc_state *bcs,
668 } 693 }
669 capi_cmsg2message(&iif->hcmsg, __skb_put(skb, CAPI_DISCONNECT_IND_LEN)); 694 capi_cmsg2message(&iif->hcmsg, __skb_put(skb, CAPI_DISCONNECT_IND_LEN));
670 dump_cmsg(DEBUG_CMD, __func__, &iif->hcmsg); 695 dump_cmsg(DEBUG_CMD, __func__, &iif->hcmsg);
671 ap->connected = APCONN_NONE;
672 capi_ctr_handle_message(&iif->ctr, ap->id, skb); 696 capi_ctr_handle_message(&iif->ctr, ap->id, skb);
673} 697}
674 698
@@ -685,9 +709,9 @@ static void send_disconnect_b3_ind(struct bc_state *bcs,
685 struct sk_buff *skb; 709 struct sk_buff *skb;
686 710
687 /* nothing to do if no logical connection active */ 711 /* nothing to do if no logical connection active */
688 if (ap->connected < APCONN_ACTIVE) 712 if (bcs->apconnstate < APCONN_ACTIVE)
689 return; 713 return;
690 ap->connected = APCONN_SETUP; 714 bcs->apconnstate = APCONN_SETUP;
691 715
692 capi_cmsg_header(&iif->hcmsg, ap->id, CAPI_DISCONNECT_B3, CAPI_IND, 716 capi_cmsg_header(&iif->hcmsg, ap->id, CAPI_DISCONNECT_B3, CAPI_IND,
693 ap->nextMessageNumber++, 717 ap->nextMessageNumber++,
@@ -714,14 +738,25 @@ void gigaset_isdn_connD(struct bc_state *bcs)
714{ 738{
715 struct cardstate *cs = bcs->cs; 739 struct cardstate *cs = bcs->cs;
716 struct gigaset_capi_ctr *iif = cs->iif; 740 struct gigaset_capi_ctr *iif = cs->iif;
717 struct gigaset_capi_appl *ap = bcs->ap; 741 struct gigaset_capi_appl *ap;
718 struct sk_buff *skb; 742 struct sk_buff *skb;
719 unsigned int msgsize; 743 unsigned int msgsize;
744 unsigned long flags;
720 745
746 spin_lock_irqsave(&bcs->aplock, flags);
747 ap = bcs->ap;
721 if (!ap) { 748 if (!ap) {
749 spin_unlock_irqrestore(&bcs->aplock, flags);
722 dev_err(cs->dev, "%s: no application\n", __func__); 750 dev_err(cs->dev, "%s: no application\n", __func__);
723 return; 751 return;
724 } 752 }
753 if (bcs->apconnstate == APCONN_NONE) {
754 spin_unlock_irqrestore(&bcs->aplock, flags);
755 dev_warn(cs->dev, "%s: application %u not connected\n",
756 __func__, ap->id);
757 return;
758 }
759 spin_unlock_irqrestore(&bcs->aplock, flags);
725 while (ap->bcnext) { 760 while (ap->bcnext) {
726 /* this should never happen */ 761 /* this should never happen */
727 dev_warn(cs->dev, "%s: dropping extra application %u\n", 762 dev_warn(cs->dev, "%s: dropping extra application %u\n",
@@ -730,11 +765,6 @@ void gigaset_isdn_connD(struct bc_state *bcs)
730 CapiCallGivenToOtherApplication); 765 CapiCallGivenToOtherApplication);
731 ap->bcnext = ap->bcnext->bcnext; 766 ap->bcnext = ap->bcnext->bcnext;
732 } 767 }
733 if (ap->connected == APCONN_NONE) {
734 dev_warn(cs->dev, "%s: application %u not connected\n",
735 __func__, ap->id);
736 return;
737 }
738 768
739 /* prepare CONNECT_ACTIVE_IND message 769 /* prepare CONNECT_ACTIVE_IND message
740 * Note: LLC not supported by device 770 * Note: LLC not supported by device
@@ -772,17 +802,24 @@ void gigaset_isdn_connD(struct bc_state *bcs)
772void gigaset_isdn_hupD(struct bc_state *bcs) 802void gigaset_isdn_hupD(struct bc_state *bcs)
773{ 803{
774 struct gigaset_capi_appl *ap; 804 struct gigaset_capi_appl *ap;
805 unsigned long flags;
775 806
776 /* 807 /*
777 * ToDo: pass on reason code reported by device 808 * ToDo: pass on reason code reported by device
778 * (requires ev-layer state machine extension to collect 809 * (requires ev-layer state machine extension to collect
779 * ZCAU device reply) 810 * ZCAU device reply)
780 */ 811 */
781 for (ap = bcs->ap; ap != NULL; ap = ap->bcnext) { 812 spin_lock_irqsave(&bcs->aplock, flags);
813 while (bcs->ap != NULL) {
814 ap = bcs->ap;
815 bcs->ap = ap->bcnext;
816 spin_unlock_irqrestore(&bcs->aplock, flags);
782 send_disconnect_b3_ind(bcs, ap); 817 send_disconnect_b3_ind(bcs, ap);
783 send_disconnect_ind(bcs, ap, 0); 818 send_disconnect_ind(bcs, ap, 0);
819 spin_lock_irqsave(&bcs->aplock, flags);
784 } 820 }
785 bcs->ap = NULL; 821 bcs->apconnstate = APCONN_NONE;
822 spin_unlock_irqrestore(&bcs->aplock, flags);
786} 823}
787 824
788/** 825/**
@@ -796,24 +833,21 @@ void gigaset_isdn_connB(struct bc_state *bcs)
796{ 833{
797 struct cardstate *cs = bcs->cs; 834 struct cardstate *cs = bcs->cs;
798 struct gigaset_capi_ctr *iif = cs->iif; 835 struct gigaset_capi_ctr *iif = cs->iif;
799 struct gigaset_capi_appl *ap = bcs->ap; 836 struct gigaset_capi_appl *ap;
800 struct sk_buff *skb; 837 struct sk_buff *skb;
838 unsigned long flags;
801 unsigned int msgsize; 839 unsigned int msgsize;
802 u8 command; 840 u8 command;
803 841
842 spin_lock_irqsave(&bcs->aplock, flags);
843 ap = bcs->ap;
804 if (!ap) { 844 if (!ap) {
845 spin_unlock_irqrestore(&bcs->aplock, flags);
805 dev_err(cs->dev, "%s: no application\n", __func__); 846 dev_err(cs->dev, "%s: no application\n", __func__);
806 return; 847 return;
807 } 848 }
808 while (ap->bcnext) { 849 if (!bcs->apconnstate) {
809 /* this should never happen */ 850 spin_unlock_irqrestore(&bcs->aplock, flags);
810 dev_warn(cs->dev, "%s: dropping extra application %u\n",
811 __func__, ap->bcnext->id);
812 send_disconnect_ind(bcs, ap->bcnext,
813 CapiCallGivenToOtherApplication);
814 ap->bcnext = ap->bcnext->bcnext;
815 }
816 if (!ap->connected) {
817 dev_warn(cs->dev, "%s: application %u not connected\n", 851 dev_warn(cs->dev, "%s: application %u not connected\n",
818 __func__, ap->id); 852 __func__, ap->id);
819 return; 853 return;
@@ -825,13 +859,26 @@ void gigaset_isdn_connB(struct bc_state *bcs)
825 * CONNECT_B3_ACTIVE_IND in reply to CONNECT_B3_RESP 859 * CONNECT_B3_ACTIVE_IND in reply to CONNECT_B3_RESP
826 * Parameters in both cases always: NCCI = 1, NCPI empty 860 * Parameters in both cases always: NCCI = 1, NCPI empty
827 */ 861 */
828 if (ap->connected >= APCONN_ACTIVE) { 862 if (bcs->apconnstate >= APCONN_ACTIVE) {
829 command = CAPI_CONNECT_B3_ACTIVE; 863 command = CAPI_CONNECT_B3_ACTIVE;
830 msgsize = CAPI_CONNECT_B3_ACTIVE_IND_BASELEN; 864 msgsize = CAPI_CONNECT_B3_ACTIVE_IND_BASELEN;
831 } else { 865 } else {
832 command = CAPI_CONNECT_B3; 866 command = CAPI_CONNECT_B3;
833 msgsize = CAPI_CONNECT_B3_IND_BASELEN; 867 msgsize = CAPI_CONNECT_B3_IND_BASELEN;
834 } 868 }
869 bcs->apconnstate = APCONN_ACTIVE;
870
871 spin_unlock_irqrestore(&bcs->aplock, flags);
872
873 while (ap->bcnext) {
874 /* this should never happen */
875 dev_warn(cs->dev, "%s: dropping extra application %u\n",
876 __func__, ap->bcnext->id);
877 send_disconnect_ind(bcs, ap->bcnext,
878 CapiCallGivenToOtherApplication);
879 ap->bcnext = ap->bcnext->bcnext;
880 }
881
835 capi_cmsg_header(&iif->hcmsg, ap->id, command, CAPI_IND, 882 capi_cmsg_header(&iif->hcmsg, ap->id, command, CAPI_IND,
836 ap->nextMessageNumber++, 883 ap->nextMessageNumber++,
837 iif->ctr.cnr | ((bcs->channel + 1) << 8) | (1 << 16)); 884 iif->ctr.cnr | ((bcs->channel + 1) << 8) | (1 << 16));
@@ -842,7 +889,6 @@ void gigaset_isdn_connB(struct bc_state *bcs)
842 } 889 }
843 capi_cmsg2message(&iif->hcmsg, __skb_put(skb, msgsize)); 890 capi_cmsg2message(&iif->hcmsg, __skb_put(skb, msgsize));
844 dump_cmsg(DEBUG_CMD, __func__, &iif->hcmsg); 891 dump_cmsg(DEBUG_CMD, __func__, &iif->hcmsg);
845 ap->connected = APCONN_ACTIVE;
846 capi_ctr_handle_message(&iif->ctr, ap->id, skb); 892 capi_ctr_handle_message(&iif->ctr, ap->id, skb);
847} 893}
848 894
@@ -945,8 +991,64 @@ static void gigaset_register_appl(struct capi_ctr *ctr, u16 appl,
945 return; 991 return;
946 } 992 }
947 ap->id = appl; 993 ap->id = appl;
994 ap->rp = *rp;
948 995
949 list_add(&ap->ctrlist, &iif->appls); 996 list_add(&ap->ctrlist, &iif->appls);
997 dev_info(cs->dev, "application %u registered\n", ap->id);
998}
999
1000/*
1001 * remove CAPI application from channel
1002 * helper function to keep indentation levels down and stay in 80 columns
1003 */
1004
1005static inline void remove_appl_from_channel(struct bc_state *bcs,
1006 struct gigaset_capi_appl *ap)
1007{
1008 struct cardstate *cs = bcs->cs;
1009 struct gigaset_capi_appl *bcap;
1010 unsigned long flags;
1011 int prevconnstate;
1012
1013 spin_lock_irqsave(&bcs->aplock, flags);
1014 bcap = bcs->ap;
1015 if (bcap == NULL) {
1016 spin_unlock_irqrestore(&bcs->aplock, flags);
1017 return;
1018 }
1019
1020 /* check first application on channel */
1021 if (bcap == ap) {
1022 bcs->ap = ap->bcnext;
1023 if (bcs->ap != NULL) {
1024 spin_unlock_irqrestore(&bcs->aplock, flags);
1025 return;
1026 }
1027
1028 /* none left, clear channel state */
1029 prevconnstate = bcs->apconnstate;
1030 bcs->apconnstate = APCONN_NONE;
1031 spin_unlock_irqrestore(&bcs->aplock, flags);
1032
1033 if (prevconnstate == APCONN_ACTIVE) {
1034 dev_notice(cs->dev, "%s: hanging up channel %u\n",
1035 __func__, bcs->channel);
1036 gigaset_add_event(cs, &bcs->at_state,
1037 EV_HUP, NULL, 0, NULL);
1038 gigaset_schedule_event(cs);
1039 }
1040 return;
1041 }
1042
1043 /* check remaining list */
1044 do {
1045 if (bcap->bcnext == ap) {
1046 bcap->bcnext = bcap->bcnext->bcnext;
1047 return;
1048 }
1049 bcap = bcap->bcnext;
1050 } while (bcap != NULL);
1051 spin_unlock_irqrestore(&bcs->aplock, flags);
950} 1052}
951 1053
952/* 1054/*
@@ -958,19 +1060,19 @@ static void gigaset_release_appl(struct capi_ctr *ctr, u16 appl)
958 = container_of(ctr, struct gigaset_capi_ctr, ctr); 1060 = container_of(ctr, struct gigaset_capi_ctr, ctr);
959 struct cardstate *cs = iif->ctr.driverdata; 1061 struct cardstate *cs = iif->ctr.driverdata;
960 struct gigaset_capi_appl *ap, *tmp; 1062 struct gigaset_capi_appl *ap, *tmp;
1063 unsigned ch;
961 1064
962 list_for_each_entry_safe(ap, tmp, &iif->appls, ctrlist) 1065 list_for_each_entry_safe(ap, tmp, &iif->appls, ctrlist)
963 if (ap->id == appl) { 1066 if (ap->id == appl) {
964 if (ap->connected != APCONN_NONE) { 1067 /* remove from any channels */
965 dev_err(cs->dev, 1068 for (ch = 0; ch < cs->channels; ch++)
966 "%s: application %u still connected\n", 1069 remove_appl_from_channel(&cs->bcs[ch], ap);
967 __func__, ap->id); 1070
968 /* ToDo: clear active connection */ 1071 /* remove from registration list */
969 }
970 list_del(&ap->ctrlist); 1072 list_del(&ap->ctrlist);
971 kfree(ap); 1073 kfree(ap);
1074 dev_info(cs->dev, "application %u released\n", appl);
972 } 1075 }
973
974} 1076}
975 1077
976/* 1078/*
@@ -1149,7 +1251,8 @@ static void do_connect_req(struct gigaset_capi_ctr *iif,
1149 char **commands; 1251 char **commands;
1150 char *s; 1252 char *s;
1151 u8 *pp; 1253 u8 *pp;
1152 int i, l; 1254 unsigned long flags;
1255 int i, l, lbc, lhlc;
1153 u16 info; 1256 u16 info;
1154 1257
1155 /* decode message */ 1258 /* decode message */
@@ -1164,8 +1267,18 @@ static void do_connect_req(struct gigaset_capi_ctr *iif,
1164 send_conf(iif, ap, skb, CapiNoPlciAvailable); 1267 send_conf(iif, ap, skb, CapiNoPlciAvailable);
1165 return; 1268 return;
1166 } 1269 }
1270 spin_lock_irqsave(&bcs->aplock, flags);
1271 if (bcs->ap != NULL || bcs->apconnstate != APCONN_NONE)
1272 dev_warn(cs->dev, "%s: channel not properly cleared (%p/%d)\n",
1273 __func__, bcs->ap, bcs->apconnstate);
1167 ap->bcnext = NULL; 1274 ap->bcnext = NULL;
1168 bcs->ap = ap; 1275 bcs->ap = ap;
1276 bcs->apconnstate = APCONN_SETUP;
1277 spin_unlock_irqrestore(&bcs->aplock, flags);
1278
1279 bcs->rx_bufsize = ap->rp.datablklen;
1280 dev_kfree_skb(bcs->rx_skb);
1281 gigaset_new_rx_skb(bcs);
1169 cmsg->adr.adrPLCI |= (bcs->channel + 1) << 8; 1282 cmsg->adr.adrPLCI |= (bcs->channel + 1) << 8;
1170 1283
1171 /* build command table */ 1284 /* build command table */
@@ -1273,42 +1386,59 @@ static void do_connect_req(struct gigaset_capi_ctr *iif,
1273 goto error; 1386 goto error;
1274 } 1387 }
1275 1388
1276 /* check/encode parameter: BC */ 1389 /*
1277 if (cmsg->BC && cmsg->BC[0]) { 1390 * check/encode parameters: BC & HLC
1278 /* explicit BC overrides CIP */ 1391 * must be encoded together as device doesn't accept HLC separately
1279 l = 2*cmsg->BC[0] + 7; 1392 * explicit parameters override values derived from CIP
1393 */
1394
1395 /* determine lengths */
1396 if (cmsg->BC && cmsg->BC[0]) /* BC specified explicitly */
1397 lbc = 2*cmsg->BC[0];
1398 else if (cip2bchlc[cmsg->CIPValue].bc) /* BC derived from CIP */
1399 lbc = strlen(cip2bchlc[cmsg->CIPValue].bc);
1400 else /* no BC */
1401 lbc = 0;
1402 if (cmsg->HLC && cmsg->HLC[0]) /* HLC specified explicitly */
1403 lhlc = 2*cmsg->HLC[0];
1404 else if (cip2bchlc[cmsg->CIPValue].hlc) /* HLC derived from CIP */
1405 lhlc = strlen(cip2bchlc[cmsg->CIPValue].hlc);
1406 else /* no HLC */
1407 lhlc = 0;
1408
1409 if (lbc) {
1410 /* have BC: allocate and assemble command string */
1411 l = lbc + 7; /* "^SBC=" + value + "\r" + null byte */
1412 if (lhlc)
1413 l += lhlc + 7; /* ";^SHLC=" + value */
1280 commands[AT_BC] = kmalloc(l, GFP_KERNEL); 1414 commands[AT_BC] = kmalloc(l, GFP_KERNEL);
1281 if (!commands[AT_BC]) 1415 if (!commands[AT_BC])
1282 goto oom; 1416 goto oom;
1283 strcpy(commands[AT_BC], "^SBC="); 1417 strcpy(commands[AT_BC], "^SBC=");
1284 decode_ie(cmsg->BC, commands[AT_BC]+5); 1418 if (cmsg->BC && cmsg->BC[0]) /* BC specified explicitly */
1419 decode_ie(cmsg->BC, commands[AT_BC] + 5);
1420 else /* BC derived from CIP */
1421 strcpy(commands[AT_BC] + 5,
1422 cip2bchlc[cmsg->CIPValue].bc);
1423 if (lhlc) {
1424 strcpy(commands[AT_BC] + lbc + 5, ";^SHLC=");
1425 if (cmsg->HLC && cmsg->HLC[0])
1426 /* HLC specified explicitly */
1427 decode_ie(cmsg->HLC,
1428 commands[AT_BC] + lbc + 12);
1429 else /* HLC derived from CIP */
1430 strcpy(commands[AT_BC] + lbc + 12,
1431 cip2bchlc[cmsg->CIPValue].hlc);
1432 }
1285 strcpy(commands[AT_BC] + l - 2, "\r"); 1433 strcpy(commands[AT_BC] + l - 2, "\r");
1286 } else if (cip2bchlc[cmsg->CIPValue].bc) { 1434 } else {
1287 l = strlen(cip2bchlc[cmsg->CIPValue].bc) + 7; 1435 /* no BC */
1288 commands[AT_BC] = kmalloc(l, GFP_KERNEL); 1436 if (lhlc) {
1289 if (!commands[AT_BC]) 1437 dev_notice(cs->dev, "%s: cannot set HLC without BC\n",
1290 goto oom; 1438 "CONNECT_REQ");
1291 snprintf(commands[AT_BC], l, "^SBC=%s\r", 1439 info = CapiIllMessageParmCoding; /* ? */
1292 cip2bchlc[cmsg->CIPValue].bc); 1440 goto error;
1293 } 1441 }
1294
1295 /* check/encode parameter: HLC */
1296 if (cmsg->HLC && cmsg->HLC[0]) {
1297 /* explicit HLC overrides CIP */
1298 l = 2*cmsg->HLC[0] + 7;
1299 commands[AT_HLC] = kmalloc(l, GFP_KERNEL);
1300 if (!commands[AT_HLC])
1301 goto oom;
1302 strcpy(commands[AT_HLC], "^SHLC=");
1303 decode_ie(cmsg->HLC, commands[AT_HLC]+5);
1304 strcpy(commands[AT_HLC] + l - 2, "\r");
1305 } else if (cip2bchlc[cmsg->CIPValue].hlc) {
1306 l = strlen(cip2bchlc[cmsg->CIPValue].hlc) + 7;
1307 commands[AT_HLC] = kmalloc(l, GFP_KERNEL);
1308 if (!commands[AT_HLC])
1309 goto oom;
1310 snprintf(commands[AT_HLC], l, "^SHLC=%s\r",
1311 cip2bchlc[cmsg->CIPValue].hlc);
1312 } 1442 }
1313 1443
1314 /* check/encode parameter: B Protocol */ 1444 /* check/encode parameter: B Protocol */
@@ -1322,13 +1452,13 @@ static void do_connect_req(struct gigaset_capi_ctr *iif,
1322 bcs->proto2 = L2_HDLC; 1452 bcs->proto2 = L2_HDLC;
1323 break; 1453 break;
1324 case 1: 1454 case 1:
1325 bcs->proto2 = L2_BITSYNC; 1455 bcs->proto2 = L2_VOICE;
1326 break; 1456 break;
1327 default: 1457 default:
1328 dev_warn(cs->dev, 1458 dev_warn(cs->dev,
1329 "B1 Protocol %u unsupported, using Transparent\n", 1459 "B1 Protocol %u unsupported, using Transparent\n",
1330 cmsg->B1protocol); 1460 cmsg->B1protocol);
1331 bcs->proto2 = L2_BITSYNC; 1461 bcs->proto2 = L2_VOICE;
1332 } 1462 }
1333 if (cmsg->B2protocol != 1) 1463 if (cmsg->B2protocol != 1)
1334 dev_warn(cs->dev, 1464 dev_warn(cs->dev,
@@ -1382,7 +1512,6 @@ static void do_connect_req(struct gigaset_capi_ctr *iif,
1382 goto error; 1512 goto error;
1383 } 1513 }
1384 gigaset_schedule_event(cs); 1514 gigaset_schedule_event(cs);
1385 ap->connected = APCONN_SETUP;
1386 send_conf(iif, ap, skb, CapiSuccess); 1515 send_conf(iif, ap, skb, CapiSuccess);
1387 return; 1516 return;
1388 1517
@@ -1410,6 +1539,7 @@ static void do_connect_resp(struct gigaset_capi_ctr *iif,
1410 _cmsg *cmsg = &iif->acmsg; 1539 _cmsg *cmsg = &iif->acmsg;
1411 struct bc_state *bcs; 1540 struct bc_state *bcs;
1412 struct gigaset_capi_appl *oap; 1541 struct gigaset_capi_appl *oap;
1542 unsigned long flags;
1413 int channel; 1543 int channel;
1414 1544
1415 /* decode message */ 1545 /* decode message */
@@ -1429,12 +1559,24 @@ static void do_connect_resp(struct gigaset_capi_ctr *iif,
1429 switch (cmsg->Reject) { 1559 switch (cmsg->Reject) {
1430 case 0: /* Accept */ 1560 case 0: /* Accept */
1431 /* drop all competing applications, keep only this one */ 1561 /* drop all competing applications, keep only this one */
1432 for (oap = bcs->ap; oap != NULL; oap = oap->bcnext) 1562 spin_lock_irqsave(&bcs->aplock, flags);
1433 if (oap != ap) 1563 while (bcs->ap != NULL) {
1564 oap = bcs->ap;
1565 bcs->ap = oap->bcnext;
1566 if (oap != ap) {
1567 spin_unlock_irqrestore(&bcs->aplock, flags);
1434 send_disconnect_ind(bcs, oap, 1568 send_disconnect_ind(bcs, oap,
1435 CapiCallGivenToOtherApplication); 1569 CapiCallGivenToOtherApplication);
1570 spin_lock_irqsave(&bcs->aplock, flags);
1571 }
1572 }
1436 ap->bcnext = NULL; 1573 ap->bcnext = NULL;
1437 bcs->ap = ap; 1574 bcs->ap = ap;
1575 spin_unlock_irqrestore(&bcs->aplock, flags);
1576
1577 bcs->rx_bufsize = ap->rp.datablklen;
1578 dev_kfree_skb(bcs->rx_skb);
1579 gigaset_new_rx_skb(bcs);
1438 bcs->chstate |= CHS_NOTIFY_LL; 1580 bcs->chstate |= CHS_NOTIFY_LL;
1439 1581
1440 /* check/encode B channel protocol */ 1582 /* check/encode B channel protocol */
@@ -1448,13 +1590,13 @@ static void do_connect_resp(struct gigaset_capi_ctr *iif,
1448 bcs->proto2 = L2_HDLC; 1590 bcs->proto2 = L2_HDLC;
1449 break; 1591 break;
1450 case 1: 1592 case 1:
1451 bcs->proto2 = L2_BITSYNC; 1593 bcs->proto2 = L2_VOICE;
1452 break; 1594 break;
1453 default: 1595 default:
1454 dev_warn(cs->dev, 1596 dev_warn(cs->dev,
1455 "B1 Protocol %u unsupported, using Transparent\n", 1597 "B1 Protocol %u unsupported, using Transparent\n",
1456 cmsg->B1protocol); 1598 cmsg->B1protocol);
1457 bcs->proto2 = L2_BITSYNC; 1599 bcs->proto2 = L2_VOICE;
1458 } 1600 }
1459 if (cmsg->B2protocol != 1) 1601 if (cmsg->B2protocol != 1)
1460 dev_warn(cs->dev, 1602 dev_warn(cs->dev,
@@ -1502,31 +1644,45 @@ static void do_connect_resp(struct gigaset_capi_ctr *iif,
1502 send_disconnect_ind(bcs, ap, 0); 1644 send_disconnect_ind(bcs, ap, 0);
1503 1645
1504 /* remove it from the list of listening apps */ 1646 /* remove it from the list of listening apps */
1647 spin_lock_irqsave(&bcs->aplock, flags);
1505 if (bcs->ap == ap) { 1648 if (bcs->ap == ap) {
1506 bcs->ap = ap->bcnext; 1649 bcs->ap = ap->bcnext;
1507 if (bcs->ap == NULL) 1650 if (bcs->ap == NULL) {
1508 /* last one: stop ev-layer hupD notifications */ 1651 /* last one: stop ev-layer hupD notifications */
1652 bcs->apconnstate = APCONN_NONE;
1509 bcs->chstate &= ~CHS_NOTIFY_LL; 1653 bcs->chstate &= ~CHS_NOTIFY_LL;
1654 }
1655 spin_unlock_irqrestore(&bcs->aplock, flags);
1510 return; 1656 return;
1511 } 1657 }
1512 for (oap = bcs->ap; oap != NULL; oap = oap->bcnext) { 1658 for (oap = bcs->ap; oap != NULL; oap = oap->bcnext) {
1513 if (oap->bcnext == ap) { 1659 if (oap->bcnext == ap) {
1514 oap->bcnext = oap->bcnext->bcnext; 1660 oap->bcnext = oap->bcnext->bcnext;
1661 spin_unlock_irqrestore(&bcs->aplock, flags);
1515 return; 1662 return;
1516 } 1663 }
1517 } 1664 }
1665 spin_unlock_irqrestore(&bcs->aplock, flags);
1518 dev_err(cs->dev, "%s: application %u not found\n", 1666 dev_err(cs->dev, "%s: application %u not found\n",
1519 __func__, ap->id); 1667 __func__, ap->id);
1520 return; 1668 return;
1521 1669
1522 default: /* Reject */ 1670 default: /* Reject */
1523 /* drop all competing applications, keep only this one */ 1671 /* drop all competing applications, keep only this one */
1524 for (oap = bcs->ap; oap != NULL; oap = oap->bcnext) 1672 spin_lock_irqsave(&bcs->aplock, flags);
1525 if (oap != ap) 1673 while (bcs->ap != NULL) {
1674 oap = bcs->ap;
1675 bcs->ap = oap->bcnext;
1676 if (oap != ap) {
1677 spin_unlock_irqrestore(&bcs->aplock, flags);
1526 send_disconnect_ind(bcs, oap, 1678 send_disconnect_ind(bcs, oap,
1527 CapiCallGivenToOtherApplication); 1679 CapiCallGivenToOtherApplication);
1680 spin_lock_irqsave(&bcs->aplock, flags);
1681 }
1682 }
1528 ap->bcnext = NULL; 1683 ap->bcnext = NULL;
1529 bcs->ap = ap; 1684 bcs->ap = ap;
1685 spin_unlock_irqrestore(&bcs->aplock, flags);
1530 1686
1531 /* reject call - will trigger DISCONNECT_IND for this app */ 1687 /* reject call - will trigger DISCONNECT_IND for this app */
1532 dev_info(cs->dev, "%s: Reject=%x\n", 1688 dev_info(cs->dev, "%s: Reject=%x\n",
@@ -1549,6 +1705,7 @@ static void do_connect_b3_req(struct gigaset_capi_ctr *iif,
1549{ 1705{
1550 struct cardstate *cs = iif->ctr.driverdata; 1706 struct cardstate *cs = iif->ctr.driverdata;
1551 _cmsg *cmsg = &iif->acmsg; 1707 _cmsg *cmsg = &iif->acmsg;
1708 struct bc_state *bcs;
1552 int channel; 1709 int channel;
1553 1710
1554 /* decode message */ 1711 /* decode message */
@@ -1563,9 +1720,10 @@ static void do_connect_b3_req(struct gigaset_capi_ctr *iif,
1563 send_conf(iif, ap, skb, CapiIllContrPlciNcci); 1720 send_conf(iif, ap, skb, CapiIllContrPlciNcci);
1564 return; 1721 return;
1565 } 1722 }
1723 bcs = &cs->bcs[channel-1];
1566 1724
1567 /* mark logical connection active */ 1725 /* mark logical connection active */
1568 ap->connected = APCONN_ACTIVE; 1726 bcs->apconnstate = APCONN_ACTIVE;
1569 1727
1570 /* build NCCI: always 1 (one B3 connection only) */ 1728 /* build NCCI: always 1 (one B3 connection only) */
1571 cmsg->adr.adrNCCI |= 1 << 16; 1729 cmsg->adr.adrNCCI |= 1 << 16;
@@ -1611,7 +1769,7 @@ static void do_connect_b3_resp(struct gigaset_capi_ctr *iif,
1611 1769
1612 if (cmsg->Reject) { 1770 if (cmsg->Reject) {
1613 /* Reject: clear B3 connect received flag */ 1771 /* Reject: clear B3 connect received flag */
1614 ap->connected = APCONN_SETUP; 1772 bcs->apconnstate = APCONN_SETUP;
1615 1773
1616 /* trigger hangup, causing eventual DISCONNECT_IND */ 1774 /* trigger hangup, causing eventual DISCONNECT_IND */
1617 if (!gigaset_add_event(cs, &bcs->at_state, 1775 if (!gigaset_add_event(cs, &bcs->at_state,
@@ -1683,11 +1841,11 @@ static void do_disconnect_req(struct gigaset_capi_ctr *iif,
1683 } 1841 }
1684 1842
1685 /* skip if DISCONNECT_IND already sent */ 1843 /* skip if DISCONNECT_IND already sent */
1686 if (!ap->connected) 1844 if (!bcs->apconnstate)
1687 return; 1845 return;
1688 1846
1689 /* check for active logical connection */ 1847 /* check for active logical connection */
1690 if (ap->connected >= APCONN_ACTIVE) { 1848 if (bcs->apconnstate >= APCONN_ACTIVE) {
1691 /* 1849 /*
1692 * emit DISCONNECT_B3_IND with cause 0x3301 1850 * emit DISCONNECT_B3_IND with cause 0x3301
1693 * use separate cmsg structure, as the content of iif->acmsg 1851 * use separate cmsg structure, as the content of iif->acmsg
@@ -1736,6 +1894,7 @@ static void do_disconnect_b3_req(struct gigaset_capi_ctr *iif,
1736{ 1894{
1737 struct cardstate *cs = iif->ctr.driverdata; 1895 struct cardstate *cs = iif->ctr.driverdata;
1738 _cmsg *cmsg = &iif->acmsg; 1896 _cmsg *cmsg = &iif->acmsg;
1897 struct bc_state *bcs;
1739 int channel; 1898 int channel;
1740 1899
1741 /* decode message */ 1900 /* decode message */
@@ -1751,17 +1910,17 @@ static void do_disconnect_b3_req(struct gigaset_capi_ctr *iif,
1751 send_conf(iif, ap, skb, CapiIllContrPlciNcci); 1910 send_conf(iif, ap, skb, CapiIllContrPlciNcci);
1752 return; 1911 return;
1753 } 1912 }
1913 bcs = &cs->bcs[channel-1];
1754 1914
1755 /* reject if logical connection not active */ 1915 /* reject if logical connection not active */
1756 if (ap->connected < APCONN_ACTIVE) { 1916 if (bcs->apconnstate < APCONN_ACTIVE) {
1757 send_conf(iif, ap, skb, 1917 send_conf(iif, ap, skb,
1758 CapiMessageNotSupportedInCurrentState); 1918 CapiMessageNotSupportedInCurrentState);
1759 return; 1919 return;
1760 } 1920 }
1761 1921
1762 /* trigger hangup, causing eventual DISCONNECT_B3_IND */ 1922 /* trigger hangup, causing eventual DISCONNECT_B3_IND */
1763 if (!gigaset_add_event(cs, &cs->bcs[channel-1].at_state, 1923 if (!gigaset_add_event(cs, &bcs->at_state, EV_HUP, NULL, 0, NULL)) {
1764 EV_HUP, NULL, 0, NULL)) {
1765 send_conf(iif, ap, skb, CAPI_MSGOSRESOURCEERR); 1924 send_conf(iif, ap, skb, CAPI_MSGOSRESOURCEERR);
1766 return; 1925 return;
1767 } 1926 }
@@ -1782,11 +1941,14 @@ static void do_data_b3_req(struct gigaset_capi_ctr *iif,
1782 struct sk_buff *skb) 1941 struct sk_buff *skb)
1783{ 1942{
1784 struct cardstate *cs = iif->ctr.driverdata; 1943 struct cardstate *cs = iif->ctr.driverdata;
1944 struct bc_state *bcs;
1785 int channel = CAPIMSG_PLCI_PART(skb->data); 1945 int channel = CAPIMSG_PLCI_PART(skb->data);
1786 u16 ncci = CAPIMSG_NCCI_PART(skb->data); 1946 u16 ncci = CAPIMSG_NCCI_PART(skb->data);
1787 u16 msglen = CAPIMSG_LEN(skb->data); 1947 u16 msglen = CAPIMSG_LEN(skb->data);
1788 u16 datalen = CAPIMSG_DATALEN(skb->data); 1948 u16 datalen = CAPIMSG_DATALEN(skb->data);
1789 u16 flags = CAPIMSG_FLAGS(skb->data); 1949 u16 flags = CAPIMSG_FLAGS(skb->data);
1950 u16 msgid = CAPIMSG_MSGID(skb->data);
1951 u16 handle = CAPIMSG_HANDLE_REQ(skb->data);
1790 1952
1791 /* frequent message, avoid _cmsg overhead */ 1953 /* frequent message, avoid _cmsg overhead */
1792 dump_rawmsg(DEBUG_LLDATA, "DATA_B3_REQ", skb->data); 1954 dump_rawmsg(DEBUG_LLDATA, "DATA_B3_REQ", skb->data);
@@ -1802,6 +1964,7 @@ static void do_data_b3_req(struct gigaset_capi_ctr *iif,
1802 send_conf(iif, ap, skb, CapiIllContrPlciNcci); 1964 send_conf(iif, ap, skb, CapiIllContrPlciNcci);
1803 return; 1965 return;
1804 } 1966 }
1967 bcs = &cs->bcs[channel-1];
1805 if (msglen != CAPI_DATA_B3_REQ_LEN && msglen != CAPI_DATA_B3_REQ_LEN64) 1968 if (msglen != CAPI_DATA_B3_REQ_LEN && msglen != CAPI_DATA_B3_REQ_LEN64)
1806 dev_notice(cs->dev, "%s: unexpected length %d\n", 1969 dev_notice(cs->dev, "%s: unexpected length %d\n",
1807 "DATA_B3_REQ", msglen); 1970 "DATA_B3_REQ", msglen);
@@ -1821,7 +1984,7 @@ static void do_data_b3_req(struct gigaset_capi_ctr *iif,
1821 } 1984 }
1822 1985
1823 /* reject if logical connection not active */ 1986 /* reject if logical connection not active */
1824 if (ap->connected < APCONN_ACTIVE) { 1987 if (bcs->apconnstate < APCONN_ACTIVE) {
1825 send_conf(iif, ap, skb, CapiMessageNotSupportedInCurrentState); 1988 send_conf(iif, ap, skb, CapiMessageNotSupportedInCurrentState);
1826 return; 1989 return;
1827 } 1990 }
@@ -1832,17 +1995,19 @@ static void do_data_b3_req(struct gigaset_capi_ctr *iif,
1832 skb_pull(skb, msglen); 1995 skb_pull(skb, msglen);
1833 1996
1834 /* pass to device-specific module */ 1997 /* pass to device-specific module */
1835 if (cs->ops->send_skb(&cs->bcs[channel-1], skb) < 0) { 1998 if (cs->ops->send_skb(bcs, skb) < 0) {
1836 send_conf(iif, ap, skb, CAPI_MSGOSRESOURCEERR); 1999 send_conf(iif, ap, skb, CAPI_MSGOSRESOURCEERR);
1837 return; 2000 return;
1838 } 2001 }
1839 2002
1840 /* DATA_B3_CONF reply will be sent by gigaset_skb_sent() */
1841
1842 /* 2003 /*
1843 * ToDo: honor unset "delivery confirmation" bit 2004 * DATA_B3_CONF will be sent by gigaset_skb_sent() only if "delivery
1844 * (send DATA_B3_CONF immediately?) 2005 * confirmation" bit is set; otherwise we have to send it now
1845 */ 2006 */
2007 if (!(flags & CAPI_FLAGS_DELIVERY_CONFIRMATION))
2008 send_data_b3_conf(cs, &iif->ctr, ap->id, msgid, channel, handle,
2009 flags ? CapiFlagsNotSupportedByProtocol
2010 : CAPI_NOERROR);
1846} 2011}
1847 2012
1848/* 2013/*