Use uint instead of u_int

This commit is contained in:
Maksim Yevmenkin 2004-04-09 23:58:53 +00:00
parent 2f122b6e8a
commit 079a8a3e69
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=128079
10 changed files with 64 additions and 64 deletions

View File

@ -93,11 +93,11 @@ usage(void)
int
main(int argc, char *argv[])
{
FILE *firmware_file = NULL;
char buffer[80], path[NG_PATHSIZ],
*firmware_filename = NULL;
u_int8_t *firmware = NULL;
int firmware_size, opt, cs, ds;
FILE *firmware_file = NULL;
char buffer[80], path[NG_PATHSIZ],
*firmware_filename = NULL;
uint8_t *firmware = NULL;
int firmware_size, opt, cs, ds;
memset(path, 0, sizeof(path));
openlog(BT3CFW_IDENT, LOG_NDELAY|LOG_PID|LOG_PERROR, LOG_USER);
@ -123,8 +123,8 @@ main(int argc, char *argv[])
usage();
/* NOT REACHED */
firmware = (u_int8_t *) calloc(BT3CFW_MAX_FIRMWARE_SIZE,
sizeof(u_int8_t));
firmware = (uint8_t *) calloc(BT3CFW_MAX_FIRMWARE_SIZE,
sizeof(uint8_t));
if (firmware == NULL) {
syslog(LOG_ERR, "Could not allocate firmware buffer");
exit(255);
@ -147,7 +147,7 @@ main(int argc, char *argv[])
if (buffer[1] == '3') {
ng_bt3c_firmware_block_ep *block = NULL;
u_int16_t *data = NULL;
uint16_t *data = NULL;
block = (ng_bt3c_firmware_block_ep *)
(firmware + firmware_size);
@ -185,7 +185,7 @@ main(int argc, char *argv[])
cs += hexa2int8(buffer + 2 + i * 2);
/* Data + second part of the cheksum: data */
data = (u_int16_t *)(block + 1);
data = (uint16_t *)(block + 1);
for (i = 0; i < block->block_size; i++) {
data[i] = hexa2int16(buffer + (i * 4) + 12);
cs += (((data[i] & 0xff00) >> 8) & 0xff);

View File

@ -66,7 +66,7 @@ char const * const hci_vdata2str (int);
char const * const hci_hmode2str (int, char *, int);
char const * const hci_ver2str (int);
char const * const hci_manufacturer2str(int);
char const * const hci_features2str (u_int8_t *, char *, int);
char const * const hci_features2str (uint8_t *, char *, int);
char const * const hci_cc2str (int);
char const * const hci_con_state2str (int);
char const * const hci_status2str (int);

View File

@ -64,9 +64,9 @@ hci_hexa2int8(const char *a)
return ((hi << 4) | lo);
}
/* Convert ascii hex string to the u_int8_t[] */
/* Convert ascii hex string to the uint8_t[] */
static int
hci_hexstring2array(char const *s, u_int8_t *a, int asize)
hci_hexstring2array(char const *s, uint8_t *a, int asize)
{
int i, l, b;
@ -145,7 +145,7 @@ hci_write_pin_type(int s, int argc, char **argv)
if (sscanf(argv[0], "%d", &n) != 1 || n < 0 || n > 1)
return (USAGE);
cp.pin_type = (u_int8_t) n;
cp.pin_type = (uint8_t) n;
break;
default:
@ -183,7 +183,7 @@ hci_read_stored_link_key(int s, int argc, char **argv)
union {
ng_hci_command_compl_ep cc;
ng_hci_return_link_keys_ep key;
u_int8_t b[NG_HCI_EVENT_PKT_SIZE];
uint8_t b[NG_HCI_EVENT_PKT_SIZE];
} ep;
} __attribute__ ((packed)) event;
@ -257,7 +257,7 @@ hci_read_stored_link_key(int s, int argc, char **argv)
case NG_HCI_EVENT_RETURN_LINK_KEYS: {
struct _key {
bdaddr_t bdaddr;
u_int8_t key[NG_HCI_KEY_SIZE];
uint8_t key[NG_HCI_KEY_SIZE];
} __attribute__ ((packed)) *k = NULL;
fprintf(stdout, "Event: Number of keys: %d\n",
@ -293,7 +293,7 @@ hci_write_stored_link_key(int s, int argc, char **argv)
struct {
ng_hci_write_stored_link_key_cp p;
bdaddr_t bdaddr;
u_int8_t key[NG_HCI_KEY_SIZE];
uint8_t key[NG_HCI_KEY_SIZE];
} cp;
ng_hci_write_stored_link_key_rp rp;
int32_t n;
@ -489,7 +489,7 @@ hci_write_connection_accept_timeout(int s, int argc, char **argv)
if (sscanf(argv[0], "%d", &n) != 1 || n < 1 || n > 0xb540)
return (USAGE);
cp.timeout = (u_int16_t) n;
cp.timeout = (uint16_t) n;
cp.timeout = htole16(cp.timeout);
break;
@ -554,7 +554,7 @@ hci_write_page_timeout(int s, int argc, char **argv)
if (sscanf(argv[0], "%d", &n) != 1 || n < 1 || n > 0xffff)
return (USAGE);
cp.timeout = (u_int16_t) n;
cp.timeout = (uint16_t) n;
cp.timeout = htole16(cp.timeout);
break;
@ -618,7 +618,7 @@ hci_write_scan_enable(int s, int argc, char **argv)
if (sscanf(argv[0], "%d", &n) != 1 || n < 0 || n > 3)
return (USAGE);
cp.scan_enable = (u_int8_t) n;
cp.scan_enable = (uint8_t) n;
break;
default:
@ -686,13 +686,13 @@ hci_write_page_scan_activity(int s, int argc, char **argv)
if (sscanf(argv[0], "%d", &n) != 1 || n < 0x12 || n > 0x1000)
return (USAGE);
cp.page_scan_interval = (u_int16_t) n;
cp.page_scan_interval = (uint16_t) n;
/* page scan window */
if (sscanf(argv[0], "%d", &n) != 1 || n < 0x12 || n > 0x1000)
return (USAGE);
cp.page_scan_window = (u_int16_t) n;
cp.page_scan_window = (uint16_t) n;
if (cp.page_scan_window > cp.page_scan_interval)
return (USAGE);
@ -767,13 +767,13 @@ hci_write_inquiry_scan_activity(int s, int argc, char **argv)
if (sscanf(argv[0], "%d", &n) != 1 || n < 0x12 || n > 0x1000)
return (USAGE);
cp.inquiry_scan_interval = (u_int16_t) n;
cp.inquiry_scan_interval = (uint16_t) n;
/* inquiry scan window */
if (sscanf(argv[0], "%d", &n) != 1 || n < 0x12 || n > 0x1000)
return (USAGE);
cp.inquiry_scan_window = (u_int16_t) n;
cp.inquiry_scan_window = (uint16_t) n;
if (cp.inquiry_scan_window > cp.inquiry_scan_interval)
return (USAGE);
@ -843,7 +843,7 @@ hci_write_authentication_enable(int s, int argc, char **argv)
if (sscanf(argv[0], "%d", &n) != 1 || n < 0 || n > 1)
return (USAGE);
cp.auth_enable = (u_int8_t) n;
cp.auth_enable = (uint8_t) n;
break;
default:
@ -906,7 +906,7 @@ hci_write_encryption_mode(int s, int argc, char **argv)
if (sscanf(argv[0], "%d", &n) != 1 || n < 0 || n > 2)
return (USAGE);
cp.encryption_mode = (u_int8_t) n;
cp.encryption_mode = (uint8_t) n;
break;
default:
@ -1050,7 +1050,7 @@ hci_write_voice_settings(int s, int argc, char **argv)
if (sscanf(argv[0], "%x", &n) != 1)
return (USAGE);
cp.settings = (u_int16_t) n;
cp.settings = (uint16_t) n;
cp.settings = htole16(cp.settings);
break;
@ -1114,7 +1114,7 @@ hci_write_number_broadcast_retransmissions(int s, int argc, char **argv)
if (sscanf(argv[0], "%d", &n) != 1 || n < 0 || n > 0xff)
return (USAGE);
cp.counter = (u_int8_t) n;
cp.counter = (uint8_t) n;
break;
default:
@ -1184,7 +1184,7 @@ hci_write_hold_mode_activity(int s, int argc, char **argv)
if (sscanf(argv[0], "%d", &n) != 1 || n < 0 || n > 4)
return (USAGE);
cp.hold_mode_activity = (u_int8_t) n;
cp.hold_mode_activity = (uint8_t) n;
break;
default:
@ -1247,7 +1247,7 @@ hci_write_sco_flow_control_enable(int s, int argc, char **argv)
if (sscanf(argv[0], "%d", &n) != 1 || n < 0 || n > 1)
return (USAGE);
cp.flow_control = (u_int8_t) n;
cp.flow_control = (uint8_t) n;
break;
default:
@ -1285,7 +1285,7 @@ hci_read_link_supervision_timeout(int s, int argc, char **argv)
if (sscanf(argv[0], "%d", &n) != 1 || n <= 0 || n > 0x0eff)
return (USAGE);
cp.con_handle = (u_int16_t) (n & 0x0fff);
cp.con_handle = (uint16_t) (n & 0x0fff);
cp.con_handle = htole16(cp.con_handle);
break;
@ -1330,14 +1330,14 @@ hci_write_link_supervision_timeout(int s, int argc, char **argv)
if (sscanf(argv[0], "%d", &n) != 1 || n <= 0 || n > 0x0eff)
return (USAGE);
cp.con_handle = (u_int16_t) (n & 0x0fff);
cp.con_handle = (uint16_t) (n & 0x0fff);
cp.con_handle = htole16(cp.con_handle);
/* link supervision timeout */
if (sscanf(argv[1], "%d", &n) != 1 || n < 0 || n > 0xeff)
return (USAGE);
cp.timeout = (u_int16_t) (n & 0x0fff);
cp.timeout = (uint16_t) (n & 0x0fff);
cp.timeout = htole16(cp.timeout);
break;

View File

@ -35,14 +35,14 @@
#include <string.h>
#include "hccontrol.h"
static void hci_inquiry_response (int n, u_int8_t **b);
static void hci_inquiry_response (int n, uint8_t **b);
/* Send Inquiry command to the unit */
static int
hci_inquiry(int s, int argc, char **argv)
{
int n0, n1, n2, timo;
u_int8_t b[512];
uint8_t b[512];
ng_hci_inquiry_cp cp;
ng_hci_event_pkt_t *e = (ng_hci_event_pkt_t *) b;
@ -117,7 +117,7 @@ hci_inquiry(int s, int argc, char **argv)
case NG_HCI_EVENT_INQUIRY_RESULT: {
ng_hci_inquiry_result_ep *ir =
(ng_hci_inquiry_result_ep *)(e + 1);
u_int8_t *r = (u_int8_t *)(ir + 1);
uint8_t *r = (uint8_t *)(ir + 1);
fprintf(stdout, "Inquiry result, num_responses=%d\n",
ir->num_responses);
@ -144,15 +144,15 @@ hci_inquiry(int s, int argc, char **argv)
/* Print Inquiry_Result event */
static void
hci_inquiry_response(int n, u_int8_t **b)
hci_inquiry_response(int n, uint8_t **b)
{
struct inquiry_response {
bdaddr_t bdaddr;
u_int8_t page_scan_rep_mode;
u_int8_t page_scan_period_mode;
u_int8_t page_scan_mode;
u_int8_t class[NG_HCI_CLASS_SIZE];
u_int16_t clock_offset;
uint8_t page_scan_rep_mode;
uint8_t page_scan_period_mode;
uint8_t page_scan_mode;
uint8_t class[NG_HCI_CLASS_SIZE];
uint16_t clock_offset;
} *ir = (struct inquiry_response *)(*b);
fprintf(stdout, "Inquiry result #%d\n", n);
@ -312,14 +312,14 @@ hci_disconnect(int s, int argc, char **argv)
if (sscanf(argv[1], "%d", &n) != 1 || n <= 0x00 || n > 0xff)
return (USAGE);
cp.reason = (u_int8_t) (n & 0xff);
cp.reason = (uint8_t) (n & 0xff);
case 1:
/* connection handle */
if (sscanf(argv[0], "%d", &n) != 1 || n <= 0 || n > 0x0eff)
return (USAGE);
cp.con_handle = (u_int16_t) (n & 0x0fff);
cp.con_handle = (uint16_t) (n & 0x0fff);
cp.con_handle = htole16(cp.con_handle);
break;
@ -390,7 +390,7 @@ hci_add_sco_connection(int s, int argc, char **argv)
if (n == 0)
return (USAGE);
cp.pkt_type = (u_int16_t) (n & 0x0fff);
cp.pkt_type = (uint16_t) (n & 0x0fff);
cp.pkt_type = htole16(cp.pkt_type);
case 1:
@ -398,7 +398,7 @@ hci_add_sco_connection(int s, int argc, char **argv)
if (sscanf(argv[0], "%d", &n) != 1 || n <= 0 || n > 0x0eff)
return (USAGE);
cp.con_handle = (u_int16_t) (n & 0x0fff);
cp.con_handle = (uint16_t) (n & 0x0fff);
cp.con_handle = htole16(cp.con_handle);
break;
@ -462,14 +462,14 @@ hci_change_connection_packet_type(int s, int argc, char **argv)
if (sscanf(argv[0], "%d", &n) != 1 || n <= 0 || n > 0x0eff)
return (USAGE);
cp.con_handle = (u_int16_t) (n & 0x0fff);
cp.con_handle = (uint16_t) (n & 0x0fff);
cp.con_handle = htole16(cp.con_handle);
/* packet type */
if (sscanf(argv[1], "%x", &n) != 1)
return (USAGE);
cp.pkt_type = (u_int16_t) (n & 0xffff);
cp.pkt_type = (uint16_t) (n & 0xffff);
cp.pkt_type = htole16(cp.pkt_type);
break;

View File

@ -50,7 +50,7 @@ hci_role_discovery(int s, int argc, char **argv)
if (sscanf(argv[0], "%d", &n) != 1 || n <= 0 || n > 0x0eff)
return (USAGE);
cp.con_handle = (u_int16_t) (n & 0x0fff);
cp.con_handle = (uint16_t) (n & 0x0fff);
cp.con_handle = htole16(cp.con_handle);
break;
@ -166,7 +166,7 @@ hci_read_link_policy_settings(int s, int argc, char **argv)
if (sscanf(argv[0], "%d", &n) != 1 || n <= 0 || n > 0x0eff)
return (USAGE);
cp.con_handle = (u_int16_t) (n & 0x0fff);
cp.con_handle = (uint16_t) (n & 0x0fff);
cp.con_handle = htole16(cp.con_handle);
break;
@ -209,14 +209,14 @@ hci_write_link_policy_settings(int s, int argc, char **argv)
if (sscanf(argv[0], "%d", &n) != 1 || n <= 0 || n > 0x0eff)
return (USAGE);
cp.con_handle = (u_int16_t) (n & 0x0fff);
cp.con_handle = (uint16_t) (n & 0x0fff);
cp.con_handle = htole16(cp.con_handle);
/* link policy settings */
if (sscanf(argv[1], "%x", &n) != 1)
return (USAGE);
cp.settings = (u_int16_t) (n & 0x0ffff);
cp.settings = (uint16_t) (n & 0x0ffff);
cp.settings = htole16(cp.settings);
break;

View File

@ -54,13 +54,13 @@ hci_request(int s, int opcode, char const *cp, int cp_size, char *rp, int *rp_si
assert(*rp_size > 0);
c->type = NG_HCI_CMD_PKT;
c->opcode = (u_int16_t) opcode;
c->opcode = (uint16_t) opcode;
c->opcode = htole16(c->opcode);
if (cp != NULL) {
assert(0 < cp_size && cp_size <= NG_HCI_CMD_PKT_SIZE);
c->length = (u_int8_t) cp_size;
c->length = (uint8_t) cp_size;
memcpy(buffer + sizeof(*c), cp, cp_size);
} else
c->length = 0;

View File

@ -50,7 +50,7 @@ hci_read_failed_contact_counter(int s, int argc, char **argv)
if (sscanf(argv[0], "%d", &n) != 1 || n <= 0 || n > 0x0eff)
return (USAGE);
cp.con_handle = (u_int16_t) (n & 0x0fff);
cp.con_handle = (uint16_t) (n & 0x0fff);
cp.con_handle = htole16(cp.con_handle);
break;
@ -92,7 +92,7 @@ hci_reset_failed_contact_counter(int s, int argc, char **argv)
if (sscanf(argv[0], "%d", &n) != 1 || n <= 0 || n > 0x0eff)
return (USAGE);
cp.con_handle = (u_int16_t) (n & 0x0fff);
cp.con_handle = (uint16_t) (n & 0x0fff);
cp.con_handle = htole16(cp.con_handle);
break;
@ -131,7 +131,7 @@ hci_get_link_quality(int s, int argc, char **argv)
if (sscanf(argv[0], "%d", &n) != 1 || n <= 0 || n > 0x0eff)
return (USAGE);
cp.con_handle = (u_int16_t) (n & 0x0fff);
cp.con_handle = (uint16_t) (n & 0x0fff);
cp.con_handle = htole16(cp.con_handle);
break;
@ -173,7 +173,7 @@ hci_read_rssi(int s, int argc, char **argv)
if (sscanf(argv[0], "%d", &n) != 1 || n <= 0 || n > 0x0eff)
return (USAGE);
cp.con_handle = (u_int16_t) (n & 0x0fff);
cp.con_handle = (uint16_t) (n & 0x0fff);
cp.con_handle = htole16(cp.con_handle);
break;

View File

@ -213,7 +213,7 @@ hci_manufacturer2str(int m)
} /* hci_manufacturer2str */
char const * const
hci_features2str(u_int8_t *features, char *buffer, int size)
hci_features2str(uint8_t *features, char *buffer, int size)
{
static char const * const t[][8] = {
{ /* byte 0 */

View File

@ -51,7 +51,7 @@ static int process_link_key_request_event
static int send_pin_code_reply
(int sock, struct sockaddr_hci *addr, bdaddr_p bdaddr, char const *pin);
static int send_link_key_reply
(int sock, struct sockaddr_hci *addr, bdaddr_p bdaddr, u_int8_t *key);
(int sock, struct sockaddr_hci *addr, bdaddr_p bdaddr, uint8_t *key);
static int process_link_key_notification_event
(int sock, struct sockaddr_hci *addr, ng_hci_link_key_notification_ep *ep);
static void sighup
@ -264,7 +264,7 @@ static int
send_pin_code_reply(int sock, struct sockaddr_hci *addr,
bdaddr_p bdaddr, char const *pin)
{
u_int8_t buffer[HCSECD_BUFFER_SIZE];
uint8_t buffer[HCSECD_BUFFER_SIZE];
ng_hci_cmd_pkt_t *cmd = NULL;
memset(buffer, 0, sizeof(buffer));
@ -321,9 +321,9 @@ send_pin_code_reply(int sock, struct sockaddr_hci *addr,
/* Send Link_Key_[Negative]_Reply */
static int
send_link_key_reply(int sock, struct sockaddr_hci *addr,
bdaddr_p bdaddr, u_int8_t *key)
bdaddr_p bdaddr, uint8_t *key)
{
u_int8_t buffer[HCSECD_BUFFER_SIZE];
uint8_t buffer[HCSECD_BUFFER_SIZE];
ng_hci_cmd_pkt_t *cmd = NULL;
memset(buffer, 0, sizeof(buffer));
@ -400,7 +400,7 @@ process_link_key_notification_event(int sock, struct sockaddr_hci *addr,
(key->key != NULL)? "exists" : "doesn't exist");
if (key->key == NULL) {
key->key = (u_int8_t *) malloc(NG_HCI_KEY_SIZE);
key->key = (uint8_t *) malloc(NG_HCI_KEY_SIZE);
if (key->key == NULL) {
syslog(LOG_ERR, "Could not allocate link key");
exit(1);

View File

@ -41,7 +41,7 @@ struct link_key
{
bdaddr_t bdaddr; /* remote device BDADDR */
char *name; /* remote device name */
u_int8_t *key; /* link key (or NULL if no key) */
uint8_t *key; /* link key (or NULL if no key) */
char *pin; /* pin (or NULL if no pin) */
LIST_ENTRY(link_key) next; /* link to the next */
};