Home | History | Annotate | Download | only in tools
      1 /*
      2  *
      3  *  BlueZ - Bluetooth protocol stack for Linux
      4  *
      5  *  Copyright (C) 2002-2003  Maxim Krasnyansky <maxk (at) qualcomm.com>
      6  *  Copyright (C) 2002-2010  Marcel Holtmann <marcel (at) holtmann.org>
      7  *
      8  *
      9  *  This program is free software; you can redistribute it and/or modify
     10  *  it under the terms of the GNU General Public License as published by
     11  *  the Free Software Foundation; either version 2 of the License, or
     12  *  (at your option) any later version.
     13  *
     14  *  This program is distributed in the hope that it will be useful,
     15  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
     16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     17  *  GNU General Public License for more details.
     18  *
     19  *  You should have received a copy of the GNU General Public License
     20  *  along with this program; if not, write to the Free Software
     21  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
     22  *
     23  */
     24 
     25 #ifdef HAVE_CONFIG_H
     26 #include <config.h>
     27 #endif
     28 
     29 #include <stdio.h>
     30 #include <sys/socket.h>
     31 
     32 #include <bluetooth/bluetooth.h>
     33 #include <bluetooth/hci.h>
     34 #include <bluetooth/hci_lib.h>
     35 
     36 int main(void)
     37 {
     38 	uint32_t type_mask;
     39 	uint32_t event_mask[2];
     40 	uint32_t ocf_mask[4];
     41 
     42 	/* Packet types */
     43 	memset(&type_mask, 0, sizeof(type_mask));
     44 	hci_set_bit(HCI_EVENT_PKT, &type_mask);
     45 
     46 	printf("Type mask:        { 0x%02x }\n", type_mask);
     47 
     48 	/* Events */
     49 	memset(event_mask, 0, sizeof(event_mask));
     50 	hci_set_bit(EVT_INQUIRY_COMPLETE,			event_mask);
     51 	hci_set_bit(EVT_INQUIRY_RESULT,				event_mask);
     52 	hci_set_bit(EVT_CONN_COMPLETE,				event_mask);
     53 	hci_set_bit(EVT_CONN_REQUEST,				event_mask);
     54 	hci_set_bit(EVT_DISCONN_COMPLETE,			event_mask);
     55 	hci_set_bit(EVT_AUTH_COMPLETE,				event_mask);
     56 	hci_set_bit(EVT_REMOTE_NAME_REQ_COMPLETE,		event_mask);
     57 	hci_set_bit(EVT_ENCRYPT_CHANGE,				event_mask);
     58 	hci_set_bit(EVT_READ_REMOTE_FEATURES_COMPLETE,		event_mask);
     59 	hci_set_bit(EVT_READ_REMOTE_VERSION_COMPLETE,		event_mask);
     60 	hci_set_bit(EVT_CMD_COMPLETE,				event_mask);
     61 	hci_set_bit(EVT_CMD_STATUS,				event_mask);
     62 	hci_set_bit(EVT_READ_CLOCK_OFFSET_COMPLETE,		event_mask);
     63 	hci_set_bit(EVT_INQUIRY_RESULT_WITH_RSSI,		event_mask);
     64 	hci_set_bit(EVT_READ_REMOTE_EXT_FEATURES_COMPLETE,	event_mask);
     65 	hci_set_bit(EVT_SYNC_CONN_COMPLETE,			event_mask);
     66 	hci_set_bit(EVT_SYNC_CONN_CHANGED,			event_mask);
     67 	hci_set_bit(EVT_EXTENDED_INQUIRY_RESULT,		event_mask);
     68 
     69 	printf("Event mask:       { 0x%08x, 0x%08x }\n",
     70 					event_mask[0], event_mask[1]);
     71 
     72 	/* OGF_LINK_CTL */
     73 	memset(ocf_mask, 0, sizeof(ocf_mask));
     74 	hci_set_bit(OCF_INQUIRY,			ocf_mask);
     75 	hci_set_bit(OCF_INQUIRY_CANCEL,			ocf_mask);
     76 	hci_set_bit(OCF_REMOTE_NAME_REQ,		ocf_mask);
     77 	hci_set_bit(OCF_REMOTE_NAME_REQ_CANCEL,		ocf_mask);
     78 	hci_set_bit(OCF_READ_REMOTE_FEATURES,		ocf_mask);
     79 	hci_set_bit(OCF_READ_REMOTE_EXT_FEATURES,	ocf_mask);
     80 	hci_set_bit(OCF_READ_REMOTE_VERSION,		ocf_mask);
     81 	hci_set_bit(OCF_READ_CLOCK_OFFSET,		ocf_mask);
     82 	hci_set_bit(OCF_READ_LMP_HANDLE,		ocf_mask);
     83 
     84 	printf("OGF_LINK_CTL:     { 0x%08x, 0x%08x, 0x%08x, 0x%02x }\n",
     85 			ocf_mask[0], ocf_mask[1], ocf_mask[2], ocf_mask[3]);
     86 
     87 	/* OGF_LINK_POLICY */
     88 	memset(ocf_mask, 0, sizeof(ocf_mask));
     89 	hci_set_bit(OCF_ROLE_DISCOVERY,			ocf_mask);
     90 	hci_set_bit(OCF_READ_LINK_POLICY,		ocf_mask);
     91 	hci_set_bit(OCF_READ_DEFAULT_LINK_POLICY,	ocf_mask);
     92 
     93 	printf("OGF_LINK_POLICY:  { 0x%08x, 0x%08x, 0x%08x, 0x%02x }\n",
     94 			ocf_mask[0], ocf_mask[1], ocf_mask[2], ocf_mask[3]);
     95 
     96 	/* OGF_HOST_CTL */
     97 	memset(ocf_mask, 0, sizeof(ocf_mask));
     98 	hci_set_bit(OCF_READ_PIN_TYPE,			ocf_mask);
     99 	hci_set_bit(OCF_READ_LOCAL_NAME,		ocf_mask);
    100 	hci_set_bit(OCF_READ_CONN_ACCEPT_TIMEOUT,	ocf_mask);
    101 	hci_set_bit(OCF_READ_PAGE_TIMEOUT,		ocf_mask);
    102 	hci_set_bit(OCF_READ_SCAN_ENABLE,		ocf_mask);
    103 	hci_set_bit(OCF_READ_PAGE_ACTIVITY,		ocf_mask);
    104 	hci_set_bit(OCF_READ_INQ_ACTIVITY,		ocf_mask);
    105 	hci_set_bit(OCF_READ_AUTH_ENABLE,		ocf_mask);
    106 	hci_set_bit(OCF_READ_ENCRYPT_MODE,		ocf_mask);
    107 	hci_set_bit(OCF_READ_CLASS_OF_DEV,		ocf_mask);
    108 	hci_set_bit(OCF_READ_VOICE_SETTING,		ocf_mask);
    109 	hci_set_bit(OCF_READ_AUTOMATIC_FLUSH_TIMEOUT,	ocf_mask);
    110 	hci_set_bit(OCF_READ_NUM_BROADCAST_RETRANS,	ocf_mask);
    111 	hci_set_bit(OCF_READ_HOLD_MODE_ACTIVITY,	ocf_mask);
    112 	hci_set_bit(OCF_READ_TRANSMIT_POWER_LEVEL,	ocf_mask);
    113 	hci_set_bit(OCF_READ_LINK_SUPERVISION_TIMEOUT,	ocf_mask);
    114 	hci_set_bit(OCF_READ_NUM_SUPPORTED_IAC,		ocf_mask);
    115 	hci_set_bit(OCF_READ_CURRENT_IAC_LAP,		ocf_mask);
    116 	hci_set_bit(OCF_READ_PAGE_SCAN_PERIOD_MODE,	ocf_mask);
    117 	hci_set_bit(OCF_READ_PAGE_SCAN_MODE,		ocf_mask);
    118 	hci_set_bit(OCF_READ_INQUIRY_SCAN_TYPE,		ocf_mask);
    119 	hci_set_bit(OCF_READ_INQUIRY_MODE,		ocf_mask);
    120 	hci_set_bit(OCF_READ_PAGE_SCAN_TYPE,		ocf_mask);
    121 	hci_set_bit(OCF_READ_AFH_MODE,			ocf_mask);
    122 	hci_set_bit(OCF_READ_EXT_INQUIRY_RESPONSE,	ocf_mask);
    123 	hci_set_bit(OCF_READ_SIMPLE_PAIRING_MODE,	ocf_mask);
    124 	hci_set_bit(OCF_READ_INQ_RESPONSE_TX_POWER_LEVEL,	ocf_mask);
    125 	hci_set_bit(OCF_READ_DEFAULT_ERROR_DATA_REPORTING,	ocf_mask);
    126 
    127 	printf("OGF_HOST_CTL:     { 0x%08x, 0x%08x, 0x%08x, 0x%02x }\n",
    128 			ocf_mask[0], ocf_mask[1], ocf_mask[2], ocf_mask[3]);
    129 
    130 	/* OGF_INFO_PARAM */
    131 	memset(ocf_mask, 0, sizeof(ocf_mask));
    132 	hci_set_bit(OCF_READ_LOCAL_VERSION,		ocf_mask);
    133 	hci_set_bit(OCF_READ_LOCAL_COMMANDS,		ocf_mask);
    134 	hci_set_bit(OCF_READ_LOCAL_FEATURES,		ocf_mask);
    135 	hci_set_bit(OCF_READ_LOCAL_EXT_FEATURES,	ocf_mask);
    136 	hci_set_bit(OCF_READ_BUFFER_SIZE,		ocf_mask);
    137 	hci_set_bit(OCF_READ_COUNTRY_CODE,		ocf_mask);
    138 	hci_set_bit(OCF_READ_BD_ADDR,			ocf_mask);
    139 
    140 	printf("OGF_INFO_PARAM:   { 0x%08x, 0x%08x, 0x%08x, 0x%02x }\n",
    141 			ocf_mask[0], ocf_mask[1], ocf_mask[2], ocf_mask[3]);
    142 
    143 	/* OGF_STATUS_PARAM */
    144 	memset(ocf_mask, 0, sizeof(ocf_mask));
    145 	hci_set_bit(OCF_READ_FAILED_CONTACT_COUNTER,	ocf_mask);
    146 	hci_set_bit(OCF_READ_LINK_QUALITY,		ocf_mask);
    147 	hci_set_bit(OCF_READ_RSSI,			ocf_mask);
    148 	hci_set_bit(OCF_READ_AFH_MAP,			ocf_mask);
    149 	hci_set_bit(OCF_READ_CLOCK,			ocf_mask);
    150 
    151 	printf("OGF_STATUS_PARAM: { 0x%08x, 0x%08x, 0x%08x, 0x%02x }\n",
    152 			ocf_mask[0], ocf_mask[1], ocf_mask[2], ocf_mask[3]);
    153 
    154 	return 0;
    155 }
    156