Lines Matching +full:len +full:- +full:or +full:- +full:define

3    Copyright (C) 2002-2003 Marcel Holtmann <marcel@holtmann.org>
5 This program is free software; you can redistribute it and/or modify
10 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13 CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
47 #define CAPI_INTEROPERABILITY 0x20
49 #define CAPI_INTEROPERABILITY_REQ CAPICMD(CAPI_INTEROPERABILITY, CAPI_REQ)
50 #define CAPI_INTEROPERABILITY_CONF CAPICMD(CAPI_INTEROPERABILITY, CAPI_CONF)
51 #define CAPI_INTEROPERABILITY_IND CAPICMD(CAPI_INTEROPERABILITY, CAPI_IND)
52 #define CAPI_INTEROPERABILITY_RESP CAPICMD(CAPI_INTEROPERABILITY, CAPI_RESP)
54 #define CAPI_INTEROPERABILITY_REQ_LEN (CAPI_MSG_BASELEN + 2)
55 #define CAPI_INTEROPERABILITY_CONF_LEN (CAPI_MSG_BASELEN + 4)
56 #define CAPI_INTEROPERABILITY_IND_LEN (CAPI_MSG_BASELEN + 2)
57 #define CAPI_INTEROPERABILITY_RESP_LEN (CAPI_MSG_BASELEN + 2)
59 #define CAPI_FUNCTION_REGISTER 0
60 #define CAPI_FUNCTION_RELEASE 1
61 #define CAPI_FUNCTION_GET_PROFILE 2
62 #define CAPI_FUNCTION_GET_MANUFACTURER 3
63 #define CAPI_FUNCTION_GET_VERSION 4
64 #define CAPI_FUNCTION_GET_SERIAL_NUMBER 5
65 #define CAPI_FUNCTION_MANUFACTURER 6
66 #define CAPI_FUNCTION_LOOPBACK 7
69 #define CMTP_MSGNUM 1
70 #define CMTP_APPLID 2
71 #define CMTP_MAPPING 3
82 app->state = BT_OPEN; in cmtp_application_add()
83 app->appl = appl; in cmtp_application_add()
85 list_add_tail(&app->list, &session->applications); in cmtp_application_add()
95 list_del(&app->list); in cmtp_application_del()
104 list_for_each_entry(app, &session->applications, list) { in cmtp_application_get()
107 if (app->msgnum == value) in cmtp_application_get()
111 if (app->appl == value) in cmtp_application_get()
115 if (app->mapping == value) in cmtp_application_get()
126 session->msgnum++; in cmtp_msgnum_get()
128 if ((session->msgnum & 0xff) > 200) in cmtp_msgnum_get()
129 session->msgnum = CMTP_INITIAL_MSGNUM + 1; in cmtp_msgnum_get()
131 return session->msgnum; in cmtp_msgnum_get()
136 struct cmtp_scb *scb = (void *) skb->cb; in cmtp_send_capimsg()
138 BT_DBG("session %p skb %p len %u", session, skb, skb->len); in cmtp_send_capimsg()
140 scb->id = -1; in cmtp_send_capimsg()
141 scb->data = (CAPIMSG_COMMAND(skb->data) == CAPI_DATA_B3); in cmtp_send_capimsg()
143 skb_queue_tail(&session->transmit, skb); in cmtp_send_capimsg()
145 wake_up_interruptible(sk_sleep(session->sock->sk)); in cmtp_send_capimsg()
150 __u16 function, unsigned char *buf, int len) in cmtp_send_interopmsg() argument
157 skb = alloc_skb(CAPI_MSG_BASELEN + 6 + len, GFP_ATOMIC); in cmtp_send_interopmsg()
163 s = skb_put(skb, CAPI_MSG_BASELEN + 6 + len); in cmtp_send_interopmsg()
165 capimsg_setu16(s, 0, CAPI_MSG_BASELEN + 6 + len); in cmtp_send_interopmsg()
174 capimsg_setu8 (s, 10, 3 + len); in cmtp_send_interopmsg()
176 capimsg_setu8 (s, 13, len); in cmtp_send_interopmsg()
178 if (len > 0) in cmtp_send_interopmsg()
179 memcpy(s + 14, buf, len); in cmtp_send_interopmsg()
186 struct capi_ctr *ctrl = &session->ctrl; in cmtp_recv_interopmsg()
191 BT_DBG("session %p skb %p len %u", session, skb, skb->len); in cmtp_recv_interopmsg()
193 switch (CAPIMSG_SUBCOMMAND(skb->data)) { in cmtp_recv_interopmsg()
195 if (skb->len < CAPI_MSG_BASELEN + 10) in cmtp_recv_interopmsg()
198 func = CAPIMSG_U16(skb->data, CAPI_MSG_BASELEN + 5); in cmtp_recv_interopmsg()
199 info = CAPIMSG_U16(skb->data, CAPI_MSG_BASELEN + 8); in cmtp_recv_interopmsg()
203 msgnum = CAPIMSG_MSGID(skb->data); in cmtp_recv_interopmsg()
207 application->state = BT_CONNECTED; in cmtp_recv_interopmsg()
208 application->msgnum = 0; in cmtp_recv_interopmsg()
209 application->mapping = CAPIMSG_APPID(skb->data); in cmtp_recv_interopmsg()
210 wake_up_interruptible(&session->wait); in cmtp_recv_interopmsg()
216 appl = CAPIMSG_APPID(skb->data); in cmtp_recv_interopmsg()
220 application->state = BT_CLOSED; in cmtp_recv_interopmsg()
221 application->msgnum = 0; in cmtp_recv_interopmsg()
222 wake_up_interruptible(&session->wait); in cmtp_recv_interopmsg()
228 if (skb->len < CAPI_MSG_BASELEN + 11 + sizeof(capi_profile)) in cmtp_recv_interopmsg()
231 controller = CAPIMSG_U16(skb->data, CAPI_MSG_BASELEN + 11); in cmtp_recv_interopmsg()
232 msgnum = CAPIMSG_MSGID(skb->data); in cmtp_recv_interopmsg()
235 session->ncontroller = controller; in cmtp_recv_interopmsg()
236 wake_up_interruptible(&session->wait); in cmtp_recv_interopmsg()
241 memcpy(&ctrl->profile, in cmtp_recv_interopmsg()
242 skb->data + CAPI_MSG_BASELEN + 11, in cmtp_recv_interopmsg()
244 session->state = BT_CONNECTED; in cmtp_recv_interopmsg()
251 if (!info && ctrl && skb->len > CAPI_MSG_BASELEN + 14) in cmtp_recv_interopmsg()
252 strscpy_pad(ctrl->manu, in cmtp_recv_interopmsg()
253 skb->data + CAPI_MSG_BASELEN + 15, in cmtp_recv_interopmsg()
254 skb->data[CAPI_MSG_BASELEN + 14]); in cmtp_recv_interopmsg()
258 if (skb->len < CAPI_MSG_BASELEN + 32) in cmtp_recv_interopmsg()
262 ctrl->version.majorversion = CAPIMSG_U32(skb->data, CAPI_MSG_BASELEN + 16); in cmtp_recv_interopmsg()
263 ctrl->version.minorversion = CAPIMSG_U32(skb->data, CAPI_MSG_BASELEN + 20); in cmtp_recv_interopmsg()
264 ctrl->version.majormanuversion = CAPIMSG_U32(skb->data, CAPI_MSG_BASELEN + 24); in cmtp_recv_interopmsg()
265 ctrl->version.minormanuversion = CAPIMSG_U32(skb->data, CAPI_MSG_BASELEN + 28); in cmtp_recv_interopmsg()
271 if (!info && ctrl && skb->len > CAPI_MSG_BASELEN + 16) in cmtp_recv_interopmsg()
272 strscpy_pad(ctrl->serial, in cmtp_recv_interopmsg()
273 skb->data + CAPI_MSG_BASELEN + 17, in cmtp_recv_interopmsg()
274 skb->data[CAPI_MSG_BASELEN + 16]); in cmtp_recv_interopmsg()
281 if (skb->len < CAPI_MSG_BASELEN + 6) in cmtp_recv_interopmsg()
284 func = CAPIMSG_U16(skb->data, CAPI_MSG_BASELEN + 3); in cmtp_recv_interopmsg()
287 int len = min_t(uint, skb->len - CAPI_MSG_BASELEN - 6, in cmtp_recv_interopmsg() local
288 skb->data[CAPI_MSG_BASELEN + 5]); in cmtp_recv_interopmsg()
289 appl = CAPIMSG_APPID(skb->data); in cmtp_recv_interopmsg()
290 msgnum = CAPIMSG_MSGID(skb->data); in cmtp_recv_interopmsg()
292 skb->data + CAPI_MSG_BASELEN + 6, len); in cmtp_recv_interopmsg()
303 struct capi_ctr *ctrl = &session->ctrl; in cmtp_recv_capimsg()
308 BT_DBG("session %p skb %p len %u", session, skb, skb->len); in cmtp_recv_capimsg()
310 if (skb->len < CAPI_MSG_BASELEN) in cmtp_recv_capimsg()
313 if (CAPIMSG_COMMAND(skb->data) == CAPI_INTEROPERABILITY) { in cmtp_recv_capimsg()
318 if (session->flags & BIT(CMTP_LOOPBACK)) { in cmtp_recv_capimsg()
323 appl = CAPIMSG_APPID(skb->data); in cmtp_recv_capimsg()
324 contr = CAPIMSG_CONTROL(skb->data); in cmtp_recv_capimsg()
328 appl = application->appl; in cmtp_recv_capimsg()
329 CAPIMSG_SETAPPID(skb->data, appl); in cmtp_recv_capimsg()
337 contr = (contr & 0xffffff80) | session->num; in cmtp_recv_capimsg()
338 CAPIMSG_SETCONTROL(skb->data, contr); in cmtp_recv_capimsg()
353 struct cmtp_session *session = ctrl->driverdata; in cmtp_reset_ctr()
359 atomic_inc(&session->terminate); in cmtp_reset_ctr()
360 wake_up_process(session->task); in cmtp_reset_ctr()
366 struct cmtp_session *session = ctrl->driverdata; in cmtp_register_appl()
370 int err = 0, nconn, want = rp->level3cnt; in cmtp_register_appl()
373 ctrl, appl, rp->level3cnt, rp->datablkcnt, rp->datablklen); in cmtp_register_appl()
382 nconn = ctrl->profile.nbchannel * -want; in cmtp_register_appl()
387 nconn = ctrl->profile.nbchannel; in cmtp_register_appl()
390 capimsg_setu16(buf, 2, rp->datablkcnt); in cmtp_register_appl()
391 capimsg_setu16(buf, 4, rp->datablklen); in cmtp_register_appl()
393 application->state = BT_CONFIG; in cmtp_register_appl()
394 application->msgnum = cmtp_msgnum_get(session); in cmtp_register_appl()
396 cmtp_send_interopmsg(session, CAPI_REQ, 0x0000, application->msgnum, in cmtp_register_appl()
399 add_wait_queue(&session->wait, &wait); in cmtp_register_appl()
404 err = -EAGAIN; in cmtp_register_appl()
408 if (application->state == BT_CLOSED) { in cmtp_register_appl()
409 err = -application->err; in cmtp_register_appl()
413 if (application->state == BT_CONNECTED) in cmtp_register_appl()
417 err = -EINTR; in cmtp_register_appl()
424 remove_wait_queue(&session->wait, &wait); in cmtp_register_appl()
434 struct cmtp_session *session = ctrl->driverdata; in cmtp_release_appl()
445 application->msgnum = cmtp_msgnum_get(session); in cmtp_release_appl()
447 cmtp_send_interopmsg(session, CAPI_REQ, application->mapping, application->msgnum, in cmtp_release_appl()
450 wait_event_interruptible_timeout(session->wait, in cmtp_release_appl()
451 (application->state == BT_CLOSED), CMTP_INTEROP_TIMEOUT); in cmtp_release_appl()
458 struct cmtp_session *session = ctrl->driverdata; in cmtp_send_message()
465 appl = CAPIMSG_APPID(skb->data); in cmtp_send_message()
466 contr = CAPIMSG_CONTROL(skb->data); in cmtp_send_message()
469 if ((!application) || (application->state != BT_CONNECTED)) { in cmtp_send_message()
474 CAPIMSG_SETAPPID(skb->data, application->mapping); in cmtp_send_message()
476 if ((contr & 0x7f) == session->num) { in cmtp_send_message()
478 CAPIMSG_SETCONTROL(skb->data, contr); in cmtp_send_message()
493 struct capi_ctr *ctrl = m->private; in cmtp_proc_show()
494 struct cmtp_session *session = ctrl->driverdata; in cmtp_proc_show()
498 seq_printf(m, "addr %s\n", session->name); in cmtp_proc_show()
499 seq_printf(m, "ctrl %d\n", session->num); in cmtp_proc_show()
501 list_for_each_entry(app, &session->applications, list) { in cmtp_proc_show()
502 seq_printf(m, "appl %u -> %u\n", app->appl, app->mapping); in cmtp_proc_show()
520 ret = wait_event_interruptible_timeout(session->wait, in cmtp_attach_device()
521 session->ncontroller, CMTP_INTEROP_TIMEOUT); in cmtp_attach_device()
523 BT_INFO("Found %d CAPI controller(s) on device %s", session->ncontroller, session->name); in cmtp_attach_device()
526 return -ETIMEDOUT; in cmtp_attach_device()
528 if (!session->ncontroller) in cmtp_attach_device()
529 return -ENODEV; in cmtp_attach_device()
531 if (session->ncontroller > 1) in cmtp_attach_device()
534 session->ctrl.owner = THIS_MODULE; in cmtp_attach_device()
535 session->ctrl.driverdata = session; in cmtp_attach_device()
536 strcpy(session->ctrl.name, session->name); in cmtp_attach_device()
538 session->ctrl.driver_name = "cmtp"; in cmtp_attach_device()
539 session->ctrl.load_firmware = cmtp_load_firmware; in cmtp_attach_device()
540 session->ctrl.reset_ctr = cmtp_reset_ctr; in cmtp_attach_device()
541 session->ctrl.register_appl = cmtp_register_appl; in cmtp_attach_device()
542 session->ctrl.release_appl = cmtp_release_appl; in cmtp_attach_device()
543 session->ctrl.send_message = cmtp_send_message; in cmtp_attach_device()
545 session->ctrl.procinfo = cmtp_procinfo; in cmtp_attach_device()
546 session->ctrl.proc_show = cmtp_proc_show; in cmtp_attach_device()
548 if (attach_capi_ctr(&session->ctrl) < 0) { in cmtp_attach_device()
550 return -EBUSY; in cmtp_attach_device()
553 session->num = session->ctrl.cnr; in cmtp_attach_device()
555 BT_DBG("session %p num %d", session, session->num); in cmtp_attach_device()
578 detach_capi_ctr(&session->ctrl); in cmtp_detach_device()