^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) CMTP implementation for Linux Bluetooth stack (BlueZ).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) Copyright (C) 2002-2003 Marcel Holtmann <marcel@holtmann.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) This program is free software; you can redistribute it and/or modify
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) it under the terms of the GNU General Public License version 2 as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) published by the Free Software Foundation;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) SOFTWARE IS DISCLAIMED.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #ifndef __CMTP_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #define __CMTP_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #include <net/bluetooth/bluetooth.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #define BTNAMSIZ 21
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) /* CMTP ioctl defines */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #define CMTPCONNADD _IOW('C', 200, int)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #define CMTPCONNDEL _IOW('C', 201, int)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #define CMTPGETCONNLIST _IOR('C', 210, int)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) #define CMTPGETCONNINFO _IOR('C', 211, int)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) #define CMTP_LOOPBACK 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) struct cmtp_connadd_req {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) int sock; /* Connected socket */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) __u32 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) struct cmtp_conndel_req {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) bdaddr_t bdaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) __u32 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) struct cmtp_conninfo {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) bdaddr_t bdaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) __u32 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) __u16 state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) int num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) struct cmtp_connlist_req {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) __u32 cnum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) struct cmtp_conninfo __user *ci;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) int cmtp_add_connection(struct cmtp_connadd_req *req, struct socket *sock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) int cmtp_del_connection(struct cmtp_conndel_req *req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) int cmtp_get_connlist(struct cmtp_connlist_req *req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) int cmtp_get_conninfo(struct cmtp_conninfo *ci);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) /* CMTP session defines */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) #define CMTP_INTEROP_TIMEOUT (HZ * 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) #define CMTP_INITIAL_MSGNUM 0xff00
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) struct cmtp_session {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) struct list_head list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) struct socket *sock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) bdaddr_t bdaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) unsigned long state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) uint mtu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) char name[BTNAMSIZ];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) atomic_t terminate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) struct task_struct *task;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) wait_queue_head_t wait;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) int ncontroller;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) int num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) struct capi_ctr ctrl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) struct list_head applications;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) unsigned long blockids;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) int msgnum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) struct sk_buff_head transmit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) struct sk_buff *reassembly[16];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) struct cmtp_application {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) struct list_head list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) unsigned long state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) __u16 appl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) __u16 mapping;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) __u16 msgnum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) struct cmtp_scb {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) int id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) int data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) int cmtp_attach_device(struct cmtp_session *session);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) void cmtp_detach_device(struct cmtp_session *session);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) void cmtp_recv_capimsg(struct cmtp_session *session, struct sk_buff *skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) /* CMTP init defines */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) int cmtp_init_sockets(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) void cmtp_cleanup_sockets(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) #endif /* __CMTP_H */