Home | History | Annotate | Download | only in hw

Lines Matching refs:ch

165 static void l2cap_retransmission_timer_update(struct l2cap_chan_s *ch)
168 if (ch->mode != L2CAP_MODE_BASIC && ch->rexmit)
169 qemu_mod_timer(ch->retransmission_timer);
171 qemu_del_timer(ch->retransmission_timer);
175 static void l2cap_monitor_timer_update(struct l2cap_chan_s *ch)
178 if (ch->mode != L2CAP_MODE_BASIC && !ch->rexmit)
179 qemu_mod_timer(ch->monitor_timer);
181 qemu_del_timer(ch->monitor_timer);
372 static void l2cap_bframe_in(struct l2cap_chan_s *ch, uint16_t cid,
374 static void l2cap_iframe_in(struct l2cap_chan_s *ch, uint16_t cid,
402 struct l2cap_chan_s *ch = NULL;
413 ch = qemu_mallocz(sizeof(*ch));
414 ch->params.sdu_out = l2cap_bframe_out;
415 ch->params.sdu_submit = l2cap_bframe_submit;
416 ch->frame_in = l2cap_bframe_in;
417 ch->mps = 65536;
418 ch->min_mtu = MAX(48, psm_info->min_mtu);
419 ch->params.remote_mtu = MAX(672, ch->min_mtu);
420 ch->remote_cid = source_cid;
421 ch->mode = L2CAP_MODE_BASIC;
422 ch->l2cap = l2cap;
425 if (!psm_info->new_channel(l2cap->dev, &ch->params)) {
426 l2cap->cid[cid] = ch;
431 qemu_free(ch);
447 return ch;
453 struct l2cap_chan_s *ch = NULL;
464 ch = l2cap->cid[cid];
466 if (likely(ch)) {
467 if (ch->remote_cid != source_cid) {
475 ch->params.close(ch->params.opaque);
476 qemu_free(ch);
483 struct l2cap_chan_s *ch)
485 l2cap_configuration_request(l2cap, ch->remote_cid, 0, NULL, 0);
486 ch->config_req_id = l2cap->last_id;
487 ch->config &= ~L2CAP_CFG_INIT;
491 struct l2cap_chan_s *ch)
494 l2cap_channel_config_null(l2cap, ch);
498 struct l2cap_chan_s *ch, int flag,
528 if (val < ch->min_mtu) {
529 cpu_to_le16w((void *) opt->val, ch->min_mtu);
534 ch->params.remote_mtu = val;
605 ch->mode = val;
606 ch->frame_in = l2cap_bframe_in;
613 ch->mode = val;
614 ch->frame_in = l2cap_iframe_in;
647 ch->monitor_timeout = val;
648 l2cap_monitor_timer_update(ch);
652 if (val < ch->min_mtu) {
653 opt->val[7] = ch->min_mtu & 0xff;
654 opt->val[8] = ch->min_mtu >> 8;
658 ch->mps = val;
677 l2cap_configuration_response(l2cap, ch->remote_cid,
686 struct l2cap_chan_s *ch;
693 ch = l2cap->cid[cid];
700 ch->config &= ~L2CAP_CFG_ACC;
702 if (l2cap_channel_config(l2cap, ch, flag, data, len))
704 ch->config |= L2CAP_CFG_ACC;
710 if (!(ch->config & L2CAP_CFG_INIT) && (ch->config & L2CAP_CFG_ACC) &&
711 !ch->config_req_id)
712 l2cap_channel_config_req_event(l2cap, ch);
718 struct l2cap_chan_s *ch;
725 ch = l2cap->cid[cid];
727 if (ch->config_req_id != l2cap->last_id)
729 ch->config_req_id = 0;
733 ch->config |= L2CAP_CFG_INIT;
735 l2cap_channel_config_null(l2cap, ch);
738 l2cap_channel_config_req_event(l2cap, ch);
746 struct l2cap_chan_s *ch = l2cap_channel_open(l2cap, psm, source_cid);
748 if (!ch)
752 if (!(ch->config & L2CAP_CFG_INIT) && !ch->config_req_id)
753 l2cap_channel_config_req_event(l2cap, ch);
930 static void l2cap_rexmit_enable(struct l2cap_chan_s *ch, int enable)
932 ch->rexmit = enable;
934 l2cap_retransmission_timer_update(ch);
935 l2cap_monitor_timer_update(ch);
972 static void l2cap_sframe_in(struct l2cap_chan_s *ch, uint16_t ctrl)
977 static void l2cap_bframe_in(struct l2cap_chan_s *ch, uint16_t cid,
981 ch->params.sdu_in(ch->params.opaque, hdr->data, len);
985 static void l2cap_iframe_in(struct l2cap_chan_s *ch, uint16_t cid,
995 if ((hdr->data[0] >> 7) == ch->rexmit)
996 l2cap_rexmit_enable(ch, !(hdr->data[0] >> 7));
1003 return l2cap_sframe_in(ch, le16_to_cpup((void *) hdr->data));
1008 if (ch->len_total)
1010 if (len - 4 > ch->mps)
1013 return ch->params.sdu_in(ch->params.opaque, hdr->data + 2, len - 4);
1016 if (ch->len_total || len < 6)
1018 if (len - 6 > ch->mps)
1021 ch->len_total = le16_to_cpup((void *) (hdr->data + 2));
1022 if (len >= 6 + ch->len_total)
1025 ch->len_cur = len - 6;
1026 memcpy(ch->sdu, hdr->data + 4, ch->len_cur);
1030 if (!ch->len_total || ch->len_cur + len - 4 < ch->len_total)
1032 if (len - 4 > ch->mps)
1035 memcpy(ch->sdu + ch->len_cur, hdr->data + 2, len - 4);
1036 return ch->params.sdu_in(ch->params.opaque, ch->sdu, ch->len_total);
1039 if (!ch->len_total || ch->len_cur + len - 4 >= ch->len_total)
1041 if (len - 4 > ch->mps)
1044 memcpy(ch->sdu + ch->len_cur, hdr->data + 2, len - 4);
1045 ch->len_cur += len - 4;
1051 ch->len_cur = 0;
1052 ch->len_total = 0;