⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bt_proc.c

📁 bluetooth 驱动
💻 C
字号:
/* * bt_proc.c -- Implementation of /proc files in bluetooth driver * * Copyright (C) 2000, 2001  Axis Communications AB * * Author: Mattias Agren <mattias.agren@axis.com> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. * * Exceptionally, Axis Communications AB grants discretionary and * conditional permissions for additional use of the text contained * in the company's release of the AXIS OpenBT Stack under the * provisions set forth hereunder. * * Provided that, if you use the AXIS OpenBT Stack with other files, * that do not implement functionality as specified in the Bluetooth * System specification, to produce an executable, this does not by * itself cause the resulting executable to be covered by the GNU * General Public License. Your use of that executable is in no way * restricted on account of using the AXIS OpenBT Stack code with it. * * This exception does not however invalidate any other reasons why * the executable file might be covered by the provisions of the GNU * General Public License. * * $Id: bt_proc.c,v 1.21 2001/04/17 16:05:11 pkj Exp $ * *//****************** INCLUDE FILES SECTION ***********************************/#define __NO_VERSION__ /* don't define kernel_version in module.h */#ifdef __KERNEL__#include <linux/module.h>#include <linux/types.h>#include <linux/errno.h>#include <linux/malloc.h>#include <linux/fs.h>#include <linux/locks.h>#include <linux/sched.h>#include <linux/ioctl.h>#include <linux/stat.h>#include <asm/byteorder.h>#include <linux/proc_fs.h>#include <linux/bluetooth/bt_proc.h>#include <linux/bluetooth/bluetooth.h>#include <linux/bluetooth/btcommon.h>#include <linux/bluetooth/hci.h>#include <linux/bluetooth/l2cap.h>#include <linux/bluetooth/rfcomm.h>#else#include "include/bluetooth.h"#include "include/btcommon.h"#include "include/hci.h"#include "include/l2cap.h"#include "include/rfcomm.h"#endif/****************** CONSTANT AND MACRO SECTION ******************************//****************** TYPE DEFINITION SECTION *********************************//****************** LOCAL FUNCTION DECLARATION SECTION **********************//****************** GLOBAL VARIABLE DECLARATION SECTION *********************//****************** LOCAL VARIABLE DECLARATION SECTION **********************//****************** FUNCTION DEFINITION SECTION *****************************/#ifdef __KERNEL__#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)static s32 bt_read_status(char *buf, char **start, off_t offset, 			  int len, int unused)#elsestatic s32 bt_read_status(char *buf, char **start, off_t offset, int len)#endif#elseint bt_read_status(char *buf, int len)#endif{	len = 0;	len += sprintf(buf + len, "[LOCAL INFO]\n");	len += sprintf(buf + len, "stack_initiated  : ");		if (!bt_initiated()) {		len += sprintf(buf + len, "FALSE\n");		return len;	} else {		len += sprintf(buf + len, "TRUE\n");	}	len += sprintf(buf + len, "bytes_received   : %u\n",		       bt_stat.bytes_received);	len += sprintf(buf + len, "bytes_sent       : %u\n",		       bt_stat.bytes_sent);	len += sprintf(buf + len, "local_bd_address : ");	len += hci_sprint_local_bd(buf + len);	len += sprintf(buf + len, "\n");		len += sprintf(buf + len, "\n[REMOTE INFO]\n");	len += hci_sprint_remote_info(buf + len);	return len;} /* Read internal variables used for debugging */#ifdef __KERNEL__extern s32 bt_sprintf_status(u8 *buf);#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)s32 bt_read_internal(char *buf, char **start, off_t offset, 		     int len, int unused)#elses32 bt_read_internal(char *buf, char **start, off_t offset, int len)#endif /* LINUX_VERSION_CODE */#elseint bt_read_internal(char *buf, int len)#endif{	len = 0;        len += sprintf(buf + len, "\n[Bluetooth Status]\n");        len += sprintf(buf + len, "-----------------------------------------\n");        if (!bt_initiated()) {                len += sprintf(buf + len, "\nStack not initiated\n\n");                return len;        }        len += sprintf(buf + len, "bytes received : %u\n",                     bt_stat.bytes_received);        len += sprintf(buf + len, "bytes sent     : %u\n",                     bt_stat.bytes_sent);	/* HW Info */        len += sprintf(buf + len, "\n[Hardware]\n");	len += sprintf(buf + len, "Vendor:        %s\n", bt_hw_vendor());	len += sprintf(buf + len, "Firmware info: %s\n", bt_hw_firmware());	/* print all active sessions */#ifdef __KERNEL__	len += bt_sprintf_status(buf + len);#endif        len += rfcomm_sprint_status(buf + len);        len += l2cap_sprint_status(buf + len);	len += sprintf(buf + len, "\n[HCI]\n");	len += hci_sprint_remote_info(buf + len);        len += hci_sprint_local_info(buf + len);        len += sprintf(buf + len, "\n---------------------------------------\n");        return len;}/* * General test function */#ifdef __KERNEL__#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)static s32 bt_doit(char *buf, char **start, off_t offset, int len, int unused)#elsestatic s32 bt_doit(char *buf, char **start, off_t offset, int len)#endif /* LINUX_VERSION_CODE */#elseint bt_doit(char *buf, int len)#endif{	len = 0;	/*	 * trigger something...	 */	len += sprintf(buf + len, "\n did it !\n");	return len;}#ifdef __KERNEL__#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)struct proc_dir_entry bt_status = {	0, /* dynamic */	9, "bt_status", /* namelen and name*/	S_IFREG | S_IRUGO, /* mode */	1, 0, 0, /* nlinks, owner, group */	0, /* size (unused) */	NULL, /* operations, use default */	&bt_read_status,};struct proc_dir_entry bt_internal_info = {	0, /* dynamic */	11, "bt_internal", /* namelen and name*/	S_IFREG | S_IRUGO, /* mode */	1, 0, 0, /* nlinks, owner, group */	0, /* size (unused) */	NULL, /* operations, use default */	&bt_read_internal,};struct proc_dir_entry bt_proc_doit = {                    	0, /* dynamic */	7, "bt_doit", /* namelen and name*/	S_IFREG | S_IRUGO, /* mode */	1, 0, 0, /* nlinks, owner, group */	0, /* size (unused) */	NULL, /* operations, use default */	&bt_doit,};#else /* LINUX_VERSION >= 2,4,0 */struct proc_dir_entry bt_status = {	0, /* dynamic */	9, "bt_status", /* namelen and name*/	S_IFREG | S_IRUGO, /* mode */	1, 0, 0, /* nlinks, owner, group */	0, /* size (unused) */	NULL, /* inode operations, use default */	NULL, /* file operations, use default */	&bt_read_status,};struct proc_dir_entry bt_internal_info = {	0, /* dynamic */	11, "bt_internal", /* namelen and name*/	S_IFREG | S_IRUGO, /* mode */	1, 0, 0, /* nlinks, owner, group */	0, /* size (unused) */	NULL, /* operations, use default */	NULL, /* file operations, use default */	&bt_read_internal,};struct proc_dir_entry bt_proc_doit = {                    	0, /* dynamic */	7, "bt_doit", /* namelen and name*/	S_IFREG | S_IRUGO, /* mode */	1, 0, 0, /* nlinks, owner, group */	0, /* size (unused) */	NULL, /* operations, use default */	NULL, /* file operations, use default */	&bt_doit,};#endif  /* LINUX_VERSION_CODE */#endif /* __KERNEL__ *//****************** END OF FILE bt_proc.c ***********************************/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -