linux/net/bluetooth/rfcomm/core.c

/*
   RFCOMM implementation for Linux Bluetooth stack (BlueZ).
   Copyright (C) 2002 Maxim Krasnyansky <[email protected]>
   Copyright (C) 2002 Marcel Holtmann <[email protected]>

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License version 2 as
   published by the Free Software Foundation;

   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
   IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
   CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
   WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
   OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

   ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
   COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
   SOFTWARE IS DISCLAIMED.
*/

/*
 * Bluetooth RFCOMM core.
 */

#include <linux/module.h>
#include <linux/debugfs.h>
#include <linux/kthread.h>
#include <asm/unaligned.h>

#include <net/bluetooth/bluetooth.h>
#include <net/bluetooth/hci_core.h>
#include <net/bluetooth/l2cap.h>
#include <net/bluetooth/rfcomm.h>

#include <trace/events/sock.h>

#define VERSION

static bool disable_cfc;
static bool l2cap_ertm;
static int channel_mtu =;

static struct task_struct *rfcomm_thread;

static DEFINE_MUTEX(rfcomm_mutex);
#define rfcomm_lock()
#define rfcomm_unlock()


static LIST_HEAD(session_list);

static int rfcomm_send_frame(struct rfcomm_session *s, u8 *data, int len);
static int rfcomm_send_sabm(struct rfcomm_session *s, u8 dlci);
static int rfcomm_send_disc(struct rfcomm_session *s, u8 dlci);
static int rfcomm_queue_disc(struct rfcomm_dlc *d);
static int rfcomm_send_nsc(struct rfcomm_session *s, int cr, u8 type);
static int rfcomm_send_pn(struct rfcomm_session *s, int cr, struct rfcomm_dlc *d);
static int rfcomm_send_msc(struct rfcomm_session *s, int cr, u8 dlci, u8 v24_sig);
static int rfcomm_send_test(struct rfcomm_session *s, int cr, u8 *pattern, int len);
static int rfcomm_send_credits(struct rfcomm_session *s, u8 addr, u8 credits);
static void rfcomm_make_uih(struct sk_buff *skb, u8 addr);

static void rfcomm_process_connect(struct rfcomm_session *s);

static struct rfcomm_session *rfcomm_session_create(bdaddr_t *src,
							bdaddr_t *dst,
							u8 sec_level,
							int *err);
static struct rfcomm_session *rfcomm_session_get(bdaddr_t *src, bdaddr_t *dst);
static struct rfcomm_session *rfcomm_session_del(struct rfcomm_session *s);

/* ---- RFCOMM frame parsing macros ---- */
#define __get_dlci(b)
#define __get_type(b)

#define __test_ea(b)
#define __test_cr(b)
#define __test_pf(b)

#define __session_dir(s)

#define __addr(cr, dlci)
#define __ctrl(type, pf)
#define __dlci(dir, chn)
#define __srv_channel(dlci)

#define __len8(len)
#define __len16(len)

/* MCC macros */
#define __mcc_type(cr, type)
#define __get_mcc_type(b)
#define __get_mcc_len(b)

/* RPN macros */
#define __rpn_line_settings(data, stop, parity)
#define __get_rpn_data_bits(line)
#define __get_rpn_stop_bits(line)
#define __get_rpn_parity(line)

static DECLARE_WAIT_QUEUE_HEAD(rfcomm_wq);

static void rfcomm_schedule(void)
{}

/* ---- RFCOMM FCS computation ---- */

/* reversed, 8-bit, poly=0x07 */
static unsigned char rfcomm_crc_table[256] =;

/* CRC on 2 bytes */
#define __crc(data)

/* FCS on 2 bytes */
static inline u8 __fcs(u8 *data)
{}

/* FCS on 3 bytes */
static inline u8 __fcs2(u8 *data)
{}

/* Check FCS */
static inline int __check_fcs(u8 *data, int type, u8 fcs)
{}

/* ---- L2CAP callbacks ---- */
static void rfcomm_l2state_change(struct sock *sk)
{}

static void rfcomm_l2data_ready(struct sock *sk)
{}

static int rfcomm_l2sock_create(struct socket **sock)
{}

static int rfcomm_check_security(struct rfcomm_dlc *d)
{}

static void rfcomm_session_timeout(struct timer_list *t)
{}

static void rfcomm_session_set_timer(struct rfcomm_session *s, long timeout)
{}

static void rfcomm_session_clear_timer(struct rfcomm_session *s)
{}

/* ---- RFCOMM DLCs ---- */
static void rfcomm_dlc_timeout(struct timer_list *t)
{}

static void rfcomm_dlc_set_timer(struct rfcomm_dlc *d, long timeout)
{}

static void rfcomm_dlc_clear_timer(struct rfcomm_dlc *d)
{}

static void rfcomm_dlc_clear_state(struct rfcomm_dlc *d)
{}

struct rfcomm_dlc *rfcomm_dlc_alloc(gfp_t prio)
{}

void rfcomm_dlc_free(struct rfcomm_dlc *d)
{}

static void rfcomm_dlc_link(struct rfcomm_session *s, struct rfcomm_dlc *d)
{}

static void rfcomm_dlc_unlink(struct rfcomm_dlc *d)
{}

static struct rfcomm_dlc *rfcomm_dlc_get(struct rfcomm_session *s, u8 dlci)
{}

static int rfcomm_check_channel(u8 channel)
{}

static int __rfcomm_dlc_open(struct rfcomm_dlc *d, bdaddr_t *src, bdaddr_t *dst, u8 channel)
{}

int rfcomm_dlc_open(struct rfcomm_dlc *d, bdaddr_t *src, bdaddr_t *dst, u8 channel)
{}

static void __rfcomm_dlc_disconn(struct rfcomm_dlc *d)
{}

static int __rfcomm_dlc_close(struct rfcomm_dlc *d, int err)
{}

int rfcomm_dlc_close(struct rfcomm_dlc *d, int err)
{}

struct rfcomm_dlc *rfcomm_dlc_exists(bdaddr_t *src, bdaddr_t *dst, u8 channel)
{}

static int rfcomm_dlc_send_frag(struct rfcomm_dlc *d, struct sk_buff *frag)
{}

int rfcomm_dlc_send(struct rfcomm_dlc *d, struct sk_buff *skb)
{}

void rfcomm_dlc_send_noerror(struct rfcomm_dlc *d, struct sk_buff *skb)
{}

void __rfcomm_dlc_throttle(struct rfcomm_dlc *d)
{}

void __rfcomm_dlc_unthrottle(struct rfcomm_dlc *d)
{}

/*
   Set/get modem status functions use _local_ status i.e. what we report
   to the other side.
   Remote status is provided by dlc->modem_status() callback.
 */
int rfcomm_dlc_set_modem_status(struct rfcomm_dlc *d, u8 v24_sig)
{}

int rfcomm_dlc_get_modem_status(struct rfcomm_dlc *d, u8 *v24_sig)
{}

/* ---- RFCOMM sessions ---- */
static struct rfcomm_session *rfcomm_session_add(struct socket *sock, int state)
{}

static struct rfcomm_session *rfcomm_session_del(struct rfcomm_session *s)
{}

static struct rfcomm_session *rfcomm_session_get(bdaddr_t *src, bdaddr_t *dst)
{}

static struct rfcomm_session *rfcomm_session_close(struct rfcomm_session *s,
						   int err)
{}

static struct rfcomm_session *rfcomm_session_create(bdaddr_t *src,
							bdaddr_t *dst,
							u8 sec_level,
							int *err)
{}

void rfcomm_session_getaddr(struct rfcomm_session *s, bdaddr_t *src, bdaddr_t *dst)
{}

/* ---- RFCOMM frame sending ---- */
static int rfcomm_send_frame(struct rfcomm_session *s, u8 *data, int len)
{}

static int rfcomm_send_cmd(struct rfcomm_session *s, struct rfcomm_cmd *cmd)
{}

static int rfcomm_send_sabm(struct rfcomm_session *s, u8 dlci)
{}

static int rfcomm_send_ua(struct rfcomm_session *s, u8 dlci)
{}

static int rfcomm_send_disc(struct rfcomm_session *s, u8 dlci)
{}

static int rfcomm_queue_disc(struct rfcomm_dlc *d)
{}

static int rfcomm_send_dm(struct rfcomm_session *s, u8 dlci)
{}

static int rfcomm_send_nsc(struct rfcomm_session *s, int cr, u8 type)
{}

static int rfcomm_send_pn(struct rfcomm_session *s, int cr, struct rfcomm_dlc *d)
{}

int rfcomm_send_rpn(struct rfcomm_session *s, int cr, u8 dlci,
			u8 bit_rate, u8 data_bits, u8 stop_bits,
			u8 parity, u8 flow_ctrl_settings,
			u8 xon_char, u8 xoff_char, u16 param_mask)
{}

static int rfcomm_send_rls(struct rfcomm_session *s, int cr, u8 dlci, u8 status)
{}

static int rfcomm_send_msc(struct rfcomm_session *s, int cr, u8 dlci, u8 v24_sig)
{}

static int rfcomm_send_fcoff(struct rfcomm_session *s, int cr)
{}

static int rfcomm_send_fcon(struct rfcomm_session *s, int cr)
{}

static int rfcomm_send_test(struct rfcomm_session *s, int cr, u8 *pattern, int len)
{}

static int rfcomm_send_credits(struct rfcomm_session *s, u8 addr, u8 credits)
{}

static void rfcomm_make_uih(struct sk_buff *skb, u8 addr)
{}

/* ---- RFCOMM frame reception ---- */
static struct rfcomm_session *rfcomm_recv_ua(struct rfcomm_session *s, u8 dlci)
{}

static struct rfcomm_session *rfcomm_recv_dm(struct rfcomm_session *s, u8 dlci)
{}

static struct rfcomm_session *rfcomm_recv_disc(struct rfcomm_session *s,
					       u8 dlci)
{}

void rfcomm_dlc_accept(struct rfcomm_dlc *d)
{}

static void rfcomm_check_accept(struct rfcomm_dlc *d)
{}

static int rfcomm_recv_sabm(struct rfcomm_session *s, u8 dlci)
{}

static int rfcomm_apply_pn(struct rfcomm_dlc *d, int cr, struct rfcomm_pn *pn)
{}

static int rfcomm_recv_pn(struct rfcomm_session *s, int cr, struct sk_buff *skb)
{}

static int rfcomm_recv_rpn(struct rfcomm_session *s, int cr, int len, struct sk_buff *skb)
{}

static int rfcomm_recv_rls(struct rfcomm_session *s, int cr, struct sk_buff *skb)
{}

static int rfcomm_recv_msc(struct rfcomm_session *s, int cr, struct sk_buff *skb)
{}

static int rfcomm_recv_mcc(struct rfcomm_session *s, struct sk_buff *skb)
{}

static int rfcomm_recv_data(struct rfcomm_session *s, u8 dlci, int pf, struct sk_buff *skb)
{}

static struct rfcomm_session *rfcomm_recv_frame(struct rfcomm_session *s,
						struct sk_buff *skb)
{}

/* ---- Connection and data processing ---- */

static void rfcomm_process_connect(struct rfcomm_session *s)
{}

/* Send data queued for the DLC.
 * Return number of frames left in the queue.
 */
static int rfcomm_process_tx(struct rfcomm_dlc *d)
{}

static void rfcomm_process_dlcs(struct rfcomm_session *s)
{}

static struct rfcomm_session *rfcomm_process_rx(struct rfcomm_session *s)
{}

static void rfcomm_accept_connection(struct rfcomm_session *s)
{}

static struct rfcomm_session *rfcomm_check_connection(struct rfcomm_session *s)
{}

static void rfcomm_process_sessions(void)
{}

static int rfcomm_add_listener(bdaddr_t *ba)
{}

static void rfcomm_kill_listener(void)
{}

static int rfcomm_run(void *unused)
{}

static void rfcomm_security_cfm(struct hci_conn *conn, u8 status, u8 encrypt)
{}

static struct hci_cb rfcomm_cb =;

static int rfcomm_dlc_debugfs_show(struct seq_file *f, void *x)
{}

DEFINE_SHOW_ATTRIBUTE();

static struct dentry *rfcomm_dlc_debugfs;

/* ---- Initialization ---- */
static int __init rfcomm_init(void)
{}

static void __exit rfcomm_exit(void)
{}

module_init();
module_exit(rfcomm_exit);

module_param(disable_cfc, bool, 0644);
MODULE_PARM_DESC();

module_param(channel_mtu, int, 0644);
MODULE_PARM_DESC();

module_param(l2cap_ertm, bool, 0644);
MODULE_PARM_DESC();

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_VERSION();
MODULE_LICENSE();
MODULE_ALIAS();