diff --git a/tools/hcidump.c b/tools/hcidump.c
index 205531e..d33b565 100644
--- a/tools/hcidump.c
+++ b/tools/hcidump.c
#include <unistd.h>
#include <termios.h>
#include <fcntl.h>
-#include <sys/ioctl.h>
-#include <sys/socket.h>
-#include <sys/types.h>
-#include <sys/uio.h>
#include <errno.h>
#include <string.h>
#include <pwd.h>
#include <getopt.h>
-#include <asm/types.h>
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <sys/socket.h>
+#include <sys/uio.h>
+#include <netinet/in.h>
#include <bluetooth/bluetooth.h>
#include <bluetooth/hci.h>
diff --git a/tools/parser/bnep.c b/tools/parser/bnep.c
index 7dc42e4..f478231 100644
--- a/tools/parser/bnep.c
+++ b/tools/parser/bnep.c
#include <errno.h>
#include <string.h>
-#include <sys/socket.h>
#include <sys/types.h>
-#include <asm/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
#include <bluetooth/bluetooth.h>
#include <bluetooth/hci.h>
static void bnep_control(int level, struct frame *frm, int header_length)
{
- __u8 uuid_size;
+ uint8_t uuid_size;
int i, length;
char *s;
- __u32 uuid = 0;
- __u8 type = get_u8(frm);
+ uint32_t uuid = 0;
+ uint8_t type = get_u8(frm);
p_indent(++level, frm);
switch (type) {
static void bnep_eval_extension(int level, struct frame *frm)
{
- __u8 type = get_u8(frm);
+ uint8_t type = get_u8(frm);
int extension = type & 0x80;
- __u8 length = get_u8(frm);
+ uint8_t length = get_u8(frm);
p_indent(level, frm);
switch (type & 0x7f) {
void bnep_dump(int level, struct frame *frm)
{
- __u8 type = get_u8(frm);
- __u16 proto = 0x0000;
+ uint8_t type = get_u8(frm);
+ uint16_t proto = 0x0000;
int extension = type & 0x80;
p_indent(level, frm);
diff --git a/tools/parser/cmtp.c b/tools/parser/cmtp.c
index a8e68ed..0c137a6 100644
--- a/tools/parser/cmtp.c
+++ b/tools/parser/cmtp.c
#include <errno.h>
#include <string.h>
-#include <sys/socket.h>
#include <sys/types.h>
-#include <asm/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
#include <bluetooth/bluetooth.h>
#include "parser.h"
-char *bst2str(__u8 bst)
+char *bst2str(uint8_t bst)
{
switch (bst) {
case 0x00:
void cmtp_dump(int level, struct frame *frm)
{
- __u8 hdr_size;
- __u8 head;
- __u8 bst, bid, nlb;
- __u16 len;
+ uint8_t hdr_size;
+ uint8_t head;
+ uint8_t bst, bid, nlb;
+ uint16_t len;
while (frm->len > 0) {
- head = *(__u8 *)frm->ptr;
+ head = *(uint8_t *)frm->ptr;
bst = (head & 0x03);
bid = (head & 0x3c) >> 2;
break;
case 0x01:
hdr_size = 2;
- len = *(__u8 *)(frm->ptr + 1);
+ len = *(uint8_t *)(frm->ptr + 1);
break;
case 0x02:
hdr_size = 3;
- len = *(__u8 *)(frm->ptr + 1) + (*(__u8 *)(frm->ptr + 2) * 256);
+ len = *(uint8_t *)(frm->ptr + 1) + (*(uint8_t *)(frm->ptr + 2) * 256);
break;
}
diff --git a/tools/parser/hci.c b/tools/parser/hci.c
index 10794b5..4745f8a 100644
--- a/tools/parser/hci.c
+++ b/tools/parser/hci.c
#include <errno.h>
#include <string.h>
-#include <sys/socket.h>
#include <sys/types.h>
-#include <asm/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
#include <bluetooth/bluetooth.h>
#include <bluetooth/hci.h>
static inline void command_dump(int level, struct frame *frm)
{
hci_command_hdr *hdr = frm->ptr;
- __u16 opcode = btohs(hdr->opcode);
- __u16 ogf = cmd_opcode_ogf(opcode);
- __u16 ocf = cmd_opcode_ocf(opcode);
+ uint16_t opcode = btohs(hdr->opcode);
+ uint16_t ogf = cmd_opcode_ogf(opcode);
+ uint16_t ocf = cmd_opcode_ocf(opcode);
char *cmd;
if (p_filter(FILT_HCI))
static inline void acl_dump(int level, struct frame *frm)
{
hci_acl_hdr *hdr = (void *) frm->ptr;
- __u16 handle = btohs(hdr->handle);
- __u16 dlen = btohs(hdr->dlen);
- __u8 flags = acl_flags(handle);
+ uint16_t handle = btohs(hdr->handle);
+ uint16_t dlen = btohs(hdr->dlen);
+ uint8_t flags = acl_flags(handle);
if (!p_filter(FILT_HCI)) {
p_indent(level, frm);
static inline void sco_dump(int level, struct frame *frm)
{
hci_sco_hdr *hdr = (void *) frm->ptr;
- __u16 handle = btohs(hdr->handle);
+ uint16_t handle = btohs(hdr->handle);
if (!p_filter(FILT_SCO)) {
p_indent(level, frm);
void hci_dump(int level, struct frame *frm)
{
- __u8 type = *(__u8 *)frm->ptr;
+ uint8_t type = *(uint8_t *)frm->ptr;
frm->ptr++; frm->len--;
diff --git a/tools/parser/l2cap.c b/tools/parser/l2cap.c
index 856a7ad..e34e753 100644
--- a/tools/parser/l2cap.c
+++ b/tools/parser/l2cap.c
#include <errno.h>
#include <string.h>
-#include <sys/socket.h>
#include <sys/types.h>
-#include <asm/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
#include <bluetooth/bluetooth.h>
#include <bluetooth/hci.h>
#include "parser.h"
typedef struct {
- __u16 handle;
+ uint16_t handle;
struct frame frm;
} handle_info;
#define HANDLE_TABLE_SIZE 10
static handle_info handle_table[HANDLE_TABLE_SIZE];
typedef struct {
- __u16 cid;
- __u16 psm;
+ uint16_t cid;
+ uint16_t psm;
} cid_info;
#define CID_TABLE_SIZE 20
#define SCID cid_table[0]
#define DCID cid_table[1]
-static struct frame * add_handle(__u16 handle)
+static struct frame * add_handle(uint16_t handle)
{
register handle_info *t = handle_table;
register int i;
return NULL;
}
-static struct frame * get_frame(__u16 handle)
+static struct frame * get_frame(uint16_t handle)
{
register handle_info *t = handle_table;
register int i;
return add_handle(handle);
}
-static void add_cid(int in, __u16 cid, __u16 psm)
+static void add_cid(int in, uint16_t cid, uint16_t psm)
{
register cid_info *table = cid_table[in];
register int i;
}
}
-static void del_cid(int in, __u16 dcid, __u16 scid)
+static void del_cid(int in, uint16_t dcid, uint16_t scid)
{
register int t, i;
- __u16 cid[2];
+ uint16_t cid[2];
if (!in) {
cid[0] = dcid;
}
}
-static __u16 get_psm(int in, __u16 cid)
+static uint16_t get_psm(int in, uint16_t cid)
{
register cid_info *table = cid_table[in];
register int i;
static inline void conn_rsp(int level, struct frame *frm)
{
l2cap_conn_rsp *h = frm->ptr;
- __u16 psm;
+ uint16_t psm;
if ((psm = get_psm(!frm->in, btohs(h->scid))))
add_cid(frm->in, btohs(h->dcid), psm);
btohs(h->result), btohs(h->status));
}
-static __u32 conf_opt_val(__u8 *ptr, __u8 len)
+static uint32_t conf_opt_val(uint8_t *ptr, uint8_t len)
{
switch (len) {
case 1:
return *ptr;
case 2:
- return btohs(*(__u16 *)ptr);
+ return btohs(*(uint16_t *)ptr);
case 4:
- return btohl(*(__u32 *)ptr);
+ return btohl(*(uint32_t *)ptr);
}
return 0;
}
static void l2cap_parse(int level, struct frame *frm)
{
l2cap_hdr *hdr = (void *)frm->ptr;
- __u16 dlen = btohs(hdr->len);
- __u16 cid = btohs(hdr->cid);
- __u16 psm;
+ uint16_t dlen = btohs(hdr->len);
+ uint16_t cid = btohs(hdr->cid);
+ uint16_t psm;
frm->ptr += L2CAP_HDR_SIZE;
frm->len -= L2CAP_HDR_SIZE;
hdr->code, hdr->ident, btohs(hdr->len));
raw_dump(level, frm);
}
- frm->ptr += hdr->len;
- frm->len -= hdr->len;
+ frm->ptr += btohs(hdr->len);
+ frm->len -= btohs(hdr->len);
}
} else if (cid == 0x2) {
/* Connectionless channel */
if (p_filter(FILT_L2CAP))
return;
- psm = btohs(*(__u16*)frm->ptr);
+ psm = btohs(*(uint16_t*)frm->ptr);
frm->len -= 2;
p_indent(level, frm);
raw_dump(level, frm);
} else {
/* Connection oriented channel */
- __u16 psm = get_psm(!frm->in, cid);
+ uint16_t psm = get_psm(!frm->in, cid);
if (!p_filter(FILT_L2CAP)) {
p_indent(level, frm);
{
struct frame *fr;
l2cap_hdr *hdr;
- __u16 dlen;
+ uint16_t dlen;
if (frm->flags & ACL_START) {
hdr = frm->ptr;
diff --git a/tools/parser/parser.c b/tools/parser/parser.c
index f06de33..02fdcac 100644
--- a/tools/parser/parser.c
+++ b/tools/parser/parser.c
#include <ctype.h>
#include <sys/types.h>
-#include <asm/types.h>
+#include <netinet/in.h>
#include "parser.h"
diff --git a/tools/parser/parser.h b/tools/parser/parser.h
index 6747e03..4f5282c 100644
--- a/tools/parser/parser.h
+++ b/tools/parser/parser.h
* $Id$
*/
-#include <sys/resource.h>
-
-#include <sys/socket.h>
-#include <sys/types.h>
-#include <netinet/in.h>
-
-#include <asm/unaligned.h>
-
struct frame {
void *data;
int data_len;
/* get_uXX functions do byte swaping */
-static inline __u8 get_u8(struct frame *frm)
+/* use memmove to prevent gcc from using builtin memcpy */
+#define get_unaligned(p) \
+ ({ __typeof__(*(p)) t; memmove(&t, (p), sizeof(t)); t; })
+
+static inline uint8_t get_u8(struct frame *frm)
{
- __u8 *u8_ptr = frm->ptr;
+ uint8_t *u8_ptr = frm->ptr;
frm->ptr += 1;
frm->len -= 1;
return *u8_ptr;
}
-static inline __u16 get_u16(struct frame *frm)
+static inline uint16_t get_u16(struct frame *frm)
{
- __u16 *u16_ptr = frm->ptr;
+ uint16_t *u16_ptr = frm->ptr;
frm->ptr += 2;
frm->len -= 2;
return ntohs(get_unaligned(u16_ptr));
}
-static inline __u32 get_u32(struct frame *frm)
+static inline uint32_t get_u32(struct frame *frm)
{
- __u32 *u32_ptr = frm->ptr;
+ uint32_t *u32_ptr = frm->ptr;
frm->ptr += 4;
frm->len -= 4;
return ntohl(get_unaligned(u32_ptr));
}
-static inline __u64 get_u64(struct frame *frm)
+static inline uint64_t get_u64(struct frame *frm)
{
- __u64 *u64_ptr = frm->ptr;
- __u64 u64 = get_unaligned(u64_ptr), tmp;
+ uint64_t *u64_ptr = frm->ptr;
+ uint64_t u64 = get_unaligned(u64_ptr), tmp;
frm->ptr += 8;
frm->len -= 8;
tmp = ntohl(u64 & 0xffffffff);
return u64;
}
-static inline void get_u128(struct frame *frm, __u64 *l, __u64 *h)
+static inline void get_u128(struct frame *frm, uint64_t *l, uint64_t *h)
{
*h = get_u64(frm);
*l = get_u64(frm);
diff --git a/tools/parser/rfcomm.c b/tools/parser/rfcomm.c
index 287908e..6290466 100644
--- a/tools/parser/rfcomm.c
+++ b/tools/parser/rfcomm.c
#include <errno.h>
#include <string.h>
-#include <sys/socket.h>
#include <sys/types.h>
-#include <asm/types.h>
+#include <sys/socket.h>
+#include <asm/byteorder.h>
#include <bluetooth/bluetooth.h>
#define CR_STR(mcc_head) cr_str[mcc_head->type.cr]
#define GET_DLCI(addr) ((addr.server_chn << 1) | (addr.d & 1))
-void print_rfcomm_hdr(long_frame_head* head, __u8 *ptr, int len)
+void print_rfcomm_hdr(long_frame_head* head, uint8_t *ptr, int len)
{
address_field addr = head->addr;
- __u8 ctr = head->control;
- __u16 ilen = head->length.bits.len;
- __u8 ctr_type,pf,dlci,fcs;
+ uint8_t ctr = head->control;
+ uint16_t ilen = head->length.bits.len;
+ uint8_t ctr_type,pf,dlci,fcs;
dlci = GET_DLCI(addr);
pf = GET_PF(ctr);
printf("mcc_len %d\n", mcc_head->length.bits.len);
}
-static inline void mcc_test(int level, __u8 *ptr, int len,
+static inline void mcc_test(int level, uint8_t *ptr, int len,
long_frame_head *head,
mcc_long_frame_head *mcc_head)
{
print_rfcomm_hdr(head, ptr, len);
print_mcc(mcc_head);
}
-static inline void mcc_fcon(int level, __u8 *ptr, int len,
+static inline void mcc_fcon(int level, uint8_t *ptr, int len,
long_frame_head *head,
mcc_long_frame_head *mcc_head)
{
print_mcc(mcc_head);
}
-static inline void mcc_fcoff(int level, __u8 *ptr, int len,
+static inline void mcc_fcoff(int level, uint8_t *ptr, int len,
long_frame_head *head,
mcc_long_frame_head *mcc_head)
{
print_mcc(mcc_head);
}
-static inline void mcc_msc(int level, __u8 *ptr, int len,
+static inline void mcc_msc(int level, uint8_t *ptr, int len,
long_frame_head *head,
mcc_long_frame_head *mcc_head)
{
printf("\n");
}
-static inline void mcc_rpn(int level, __u8 *ptr, int len,
+static inline void mcc_rpn(int level, uint8_t *ptr, int len,
long_frame_head *head,
mcc_long_frame_head *mcc_head)
{
rpn->rpn_val.rtr_input, rpn->rpn_val.rtr_output,
rpn->rpn_val.rtc_input, rpn->rpn_val.rtc_output,
rpn->rpn_val.xon, rpn->rpn_val.xoff,
- btohs(*(__u16 *)&(rpn->rpn_val.pm)));
+ btohs(*(uint16_t *)&(rpn->rpn_val.pm)));
}
-static inline void mcc_rls(int level, __u8 *ptr, int len,
+static inline void mcc_rls(int level, uint8_t *ptr, int len,
long_frame_head *head,
mcc_long_frame_head *mcc_head)
{
printf("dlci %d error: %d", GET_DLCI(rls->dlci), rls->error);
}
-static inline void mcc_pn(int level, __u8 *ptr, int len,
+static inline void mcc_pn(int level, uint8_t *ptr, int len,
long_frame_head *head,
mcc_long_frame_head *mcc_head)
{
pn->credits);
}
-static inline void mcc_nsc(int level, __u8 *ptr, int len,
+static inline void mcc_nsc(int level, uint8_t *ptr, int len,
long_frame_head *head,
mcc_long_frame_head *mcc_head)
{
{
mcc_short_frame_head *mcc_short_head_p = frm->ptr;
mcc_long_frame_head mcc_head;
- __u8 hdr_size;
+ uint8_t hdr_size;
if ( mcc_short_head_p->length.ea == EA ) {
mcc_head.type = mcc_short_head_p->type;
void rfcomm_dump(int level, struct frame *frm)
{
- __u8 hdr_size, ctr_type;
+ uint8_t hdr_size, ctr_type;
short_frame_head *short_head_p = (void *) frm->ptr;
long_frame_head head;
diff --git a/tools/parser/rfcomm.h b/tools/parser/rfcomm.h
index 3823773..c22d57a 100644
--- a/tools/parser/rfcomm.h
+++ b/tools/parser/rfcomm.h
* $Id$
*/
-#include <asm/byteorder.h>
-
#define RFCOMM_PSM 3
#define TRUE 1
#ifdef __LITTLE_ENDIAN_BITFIELD
typedef struct parameter_mask{
- __u8 bit_rate:1;
- __u8 data_bits:1;
- __u8 stop_bit:1;
- __u8 parity:1;
- __u8 parity_type:1;
- __u8 xon:1;
- __u8 xoff:1;
- __u8 res1:1;
- __u8 xon_input:1;
- __u8 xon_output:1;
- __u8 rtr_input:1;
- __u8 rtr_output:1;
- __u8 rtc_input:1;
- __u8 rtc_output:1;
- __u8 res2:2;
+ uint8_t bit_rate:1;
+ uint8_t data_bits:1;
+ uint8_t stop_bit:1;
+ uint8_t parity:1;
+ uint8_t parity_type:1;
+ uint8_t xon:1;
+ uint8_t xoff:1;
+ uint8_t res1:1;
+ uint8_t xon_input:1;
+ uint8_t xon_output:1;
+ uint8_t rtr_input:1;
+ uint8_t rtr_output:1;
+ uint8_t rtc_input:1;
+ uint8_t rtc_output:1;
+ uint8_t res2:2;
} __attribute__ ((packed)) parameter_mask;
typedef struct rpn_values{
- __u8 bit_rate;
- __u8 data_bits:2;
- __u8 stop_bit:1;
- __u8 parity:1;
- __u8 parity_type:2;
- __u8 res1:2;
- __u8 xon_input:1;
- __u8 xon_output:1;
- __u8 rtr_input:1;
- __u8 rtr_output:1;
- __u8 rtc_input:1;
- __u8 rtc_output:1;
- __u8 res2:2;
- __u8 xon;
- __u8 xoff;
+ uint8_t bit_rate;
+ uint8_t data_bits:2;
+ uint8_t stop_bit:1;
+ uint8_t parity:1;
+ uint8_t parity_type:2;
+ uint8_t res1:2;
+ uint8_t xon_input:1;
+ uint8_t xon_output:1;
+ uint8_t rtr_input:1;
+ uint8_t rtr_output:1;
+ uint8_t rtc_input:1;
+ uint8_t rtc_output:1;
+ uint8_t res2:2;
+ uint8_t xon;
+ uint8_t xoff;
parameter_mask pm;
} __attribute__ ((packed)) rpn_values;
#elif defined(__BIG_ENDIAN_BITFIELD)
typedef struct parameter_mask{
- __u8 res1:1;
- __u8 xoff:1;
- __u8 xon:1;
- __u8 parity_type:1;
- __u8 parity:1;
- __u8 stop_bit:1;
- __u8 data_bits:1;
- __u8 bit_rate:1;
-
- __u8 res2:2;
- __u8 rtc_output:1;
- __u8 rtc_input:1;
- __u8 rtr_output:1;
- __u8 rtr_input:1;
- __u8 xon_output:1;
- __u8 xon_input:1;
+ uint8_t res1:1;
+ uint8_t xoff:1;
+ uint8_t xon:1;
+ uint8_t parity_type:1;
+ uint8_t parity:1;
+ uint8_t stop_bit:1;
+ uint8_t data_bits:1;
+ uint8_t bit_rate:1;
+
+ uint8_t res2:2;
+ uint8_t rtc_output:1;
+ uint8_t rtc_input:1;
+ uint8_t rtr_output:1;
+ uint8_t rtr_input:1;
+ uint8_t xon_output:1;
+ uint8_t xon_input:1;
} __attribute__ ((packed)) parameter_mask;
typedef struct rpn_values{
- __u8 bit_rate;
-
- __u8 res1:2;
- __u8 parity_type:2;
- __u8 parity:1;
- __u8 stop_bit:1;
- __u8 data_bits:2;
-
- __u8 res2:2;
- __u8 rtc_output:1;
- __u8 rtc_input:1;
- __u8 rtr_output:1;
- __u8 rtr_input:1;
- __u8 xon_output:1;
- __u8 xon_input:1;
-
- __u8 xon;
- __u8 xoff;
+ uint8_t bit_rate;
+
+ uint8_t res1:2;
+ uint8_t parity_type:2;
+ uint8_t parity:1;
+ uint8_t stop_bit:1;
+ uint8_t data_bits:2;
+
+ uint8_t res2:2;
+ uint8_t rtc_output:1;
+ uint8_t rtc_input:1;
+ uint8_t rtr_output:1;
+ uint8_t rtr_input:1;
+ uint8_t xon_output:1;
+ uint8_t xon_input:1;
+
+ uint8_t xon;
+ uint8_t xoff;
parameter_mask pm;
} __attribute__ ((packed)) rpn_values;
#ifdef __LITTLE_ENDIAN_BITFIELD
typedef struct address_field {
- __u8 ea:1;
- __u8 cr:1;
- __u8 d:1;
- __u8 server_chn:5;
+ uint8_t ea:1;
+ uint8_t cr:1;
+ uint8_t d:1;
+ uint8_t server_chn:5;
} __attribute__ ((packed)) address_field;
typedef struct short_length {
- __u8 ea:1;
- __u8 len:7;
+ uint8_t ea:1;
+ uint8_t len:7;
} __attribute__ ((packed)) short_length;
typedef union long_length {
struct bits {
- __u8 ea:1;
+ uint8_t ea:1;
unsigned short len:15;
} __attribute__ ((packed)) bits ;
- __u16 val ;
+ uint16_t val ;
} __attribute__ ((packed)) long_length;
typedef struct short_frame_head {
address_field addr;
- __u8 control;
+ uint8_t control;
short_length length;
} __attribute__ ((packed)) short_frame_head;
typedef struct short_frame {
short_frame_head h;
- __u8 data[0];
+ uint8_t data[0];
} __attribute__ ((packed)) short_frame;
typedef struct long_frame_head {
address_field addr;
- __u8 control;
+ uint8_t control;
long_length length;
- __u8 data[0];
+ uint8_t data[0];
} __attribute__ ((packed)) long_frame_head;
typedef struct long_frame {
long_frame_head h;
- __u8 data[0];
+ uint8_t data[0];
} __attribute__ ((packed)) long_frame;
/* Typedefinitions for structures used for the multiplexer commands */
typedef struct mcc_type {
- __u8 ea:1;
- __u8 cr:1;
- __u8 type:6;
+ uint8_t ea:1;
+ uint8_t cr:1;
+ uint8_t type:6;
} __attribute__ ((packed)) mcc_type;
typedef struct mcc_short_frame_head {
mcc_type type;
short_length length;
- __u8 value[0];
+ uint8_t value[0];
} __attribute__ ((packed)) mcc_short_frame_head;
typedef struct mcc_short_frame {
mcc_short_frame_head h;
- __u8 value[0];
+ uint8_t value[0];
} __attribute__ ((packed)) mcc_short_frame;
typedef struct mcc_long_frame_head {
mcc_type type;
long_length length;
- __u8 value[0];
+ uint8_t value[0];
} __attribute__ ((packed)) mcc_long_frame_head;
typedef struct mcc_long_frame {
mcc_long_frame_head h;
- __u8 value[0];
+ uint8_t value[0];
} __attribute__ ((packed)) mcc_long_frame;
/* MSC-command */
typedef struct v24_signals {
- __u8 ea:1;
- __u8 fc:1;
- __u8 rtc:1;
- __u8 rtr:1;
- __u8 reserved:2;
- __u8 ic:1;
- __u8 dv:1;
+ uint8_t ea:1;
+ uint8_t fc:1;
+ uint8_t rtc:1;
+ uint8_t rtr:1;
+ uint8_t reserved:2;
+ uint8_t ic:1;
+ uint8_t dv:1;
} __attribute__ ((packed)) v24_signals;
typedef struct break_signals {
- __u8 ea:1;
- __u8 b1:1;
- __u8 b2:1;
- __u8 b3:1;
- __u8 len:4;
+ uint8_t ea:1;
+ uint8_t b1:1;
+ uint8_t b2:1;
+ uint8_t b3:1;
+ uint8_t len:4;
} __attribute__ ((packed)) break_signals;
typedef struct msc_msg {
address_field dlci;
v24_signals v24_sigs;
//break_signals break_sigs;
- __u8 fcs;
+ uint8_t fcs;
} __attribute__ ((packed)) msc_msg;
typedef struct rpn_msg {
mcc_short_frame_head mcc_s_head;
address_field dlci;
rpn_values rpn_val;
- __u8 fcs;
+ uint8_t fcs;
} __attribute__ ((packed)) rpn_msg;
/* RLS-command */
short_frame_head s_head;
mcc_short_frame_head mcc_s_head;
address_field dlci;
- __u8 error:4;
- __u8 res:4;
- __u8 fcs;
+ uint8_t error:4;
+ uint8_t res:4;
+ uint8_t fcs;
} __attribute__ ((packed)) rls_msg;
/* PN-command */
short_frame_head s_head;
mcc_short_frame_head mcc_s_head;
/* The res1, res2 and res3 values have to be set to 0 by the sender */
- __u8 dlci:6;
- __u8 res1:2;
- __u8 frame_type:4;
- __u8 credit_flow:4;
- __u8 prior:6;
- __u8 res2:2;
- __u8 ack_timer;
- __u16 frame_size:16;
- __u8 max_nbrof_retrans;
- __u8 credits;
- __u8 fcs;
+ uint8_t dlci:6;
+ uint8_t res1:2;
+ uint8_t frame_type:4;
+ uint8_t credit_flow:4;
+ uint8_t prior:6;
+ uint8_t res2:2;
+ uint8_t ack_timer;
+ uint16_t frame_size:16;
+ uint8_t max_nbrof_retrans;
+ uint8_t credits;
+ uint8_t fcs;
} __attribute__ ((packed)) pn_msg;
/* NSC-command */
short_frame_head s_head;
mcc_short_frame_head mcc_s_head;
mcc_type command_type;
- __u8 fcs;
+ uint8_t fcs;
} __attribute__ ((packed)) nsc_msg;
#elif defined(__BIG_ENDIAN_BITFIELD)
typedef struct address_field {
- __u8 server_chn:5;
- __u8 d:1;
- __u8 cr:1;
- __u8 ea:1;
+ uint8_t server_chn:5;
+ uint8_t d:1;
+ uint8_t cr:1;
+ uint8_t ea:1;
} __attribute__ ((packed)) address_field;
typedef struct short_length {
- __u8 len:7;
- __u8 ea:1;
+ uint8_t len:7;
+ uint8_t ea:1;
} __attribute__ ((packed)) short_length;
typedef union long_length {
struct bits {
unsigned short len:15;
- __u8 ea:1;
+ uint8_t ea:1;
} __attribute__ ((packed)) bits;
- __u16 val;
+ uint16_t val;
} __attribute__ ((packed)) long_length;
typedef struct short_frame_head {
address_field addr;
- __u8 control;
+ uint8_t control;
short_length length;
} __attribute__ ((packed)) short_frame_head;
typedef struct short_frame {
short_frame_head h;
- __u8 data[0];
+ uint8_t data[0];
} __attribute__ ((packed)) short_frame;
typedef struct long_frame_head {
address_field addr;
- __u8 control;
+ uint8_t control;
long_length length;
- __u8 data[0];
+ uint8_t data[0];
} __attribute__ ((packed)) long_frame_head;
typedef struct long_frame {
long_frame_head h;
- __u8 data[0];
+ uint8_t data[0];
} __attribute__ ((packed)) long_frame;
typedef struct mcc_type {
- __u8 type:6;
- __u8 cr:1;
- __u8 ea:1;
+ uint8_t type:6;
+ uint8_t cr:1;
+ uint8_t ea:1;
} __attribute__ ((packed)) mcc_type;
typedef struct mcc_short_frame_head {
mcc_type type;
short_length length;
- __u8 value[0];
+ uint8_t value[0];
} __attribute__ ((packed)) mcc_short_frame_head;
typedef struct mcc_short_frame {
mcc_short_frame_head h;
- __u8 value[0];
+ uint8_t value[0];
} __attribute__ ((packed)) mcc_short_frame;
typedef struct mcc_long_frame_head {
mcc_type type;
long_length length;
- __u8 value[0];
+ uint8_t value[0];
} __attribute__ ((packed)) mcc_long_frame_head;
typedef struct mcc_long_frame {
mcc_long_frame_head h;
- __u8 value[0];
+ uint8_t value[0];
} __attribute__ ((packed)) mcc_long_frame;
typedef struct v24_signals {
- __u8 dv:1;
- __u8 ic:1;
- __u8 reserved:2;
- __u8 rtr:1;
- __u8 rtc:1;
- __u8 fc:1;
- __u8 ea:1;
+ uint8_t dv:1;
+ uint8_t ic:1;
+ uint8_t reserved:2;
+ uint8_t rtr:1;
+ uint8_t rtc:1;
+ uint8_t fc:1;
+ uint8_t ea:1;
} __attribute__ ((packed)) v24_signals;
typedef struct break_signals {
- __u8 len:4;
- __u8 b3:1;
- __u8 b2:1;
- __u8 b1:1;
- __u8 ea:1;
+ uint8_t len:4;
+ uint8_t b3:1;
+ uint8_t b2:1;
+ uint8_t b1:1;
+ uint8_t ea:1;
} __attribute__ ((packed)) break_signals;
typedef struct msc_msg {
address_field dlci;
v24_signals v24_sigs;
//break_signals break_sigs;
- __u8 fcs;
+ uint8_t fcs;
} __attribute__ ((packed)) msc_msg;
typedef struct rpn_msg {
mcc_short_frame_head mcc_s_head;
address_field dlci;
rpn_values rpn_val;
- __u8 fcs;
+ uint8_t fcs;
} __attribute__ ((packed)) rpn_msg;
typedef struct rls_msg {
short_frame_head s_head;
mcc_short_frame_head mcc_s_head;
address_field dlci;
- __u8 res:4;
- __u8 error:4;
- __u8 fcs;
+ uint8_t res:4;
+ uint8_t error:4;
+ uint8_t fcs;
} __attribute__ ((packed)) rls_msg;
typedef struct pn_msg {
short_frame_head s_head;
mcc_short_frame_head mcc_s_head;
- __u8 res1:2;
- __u8 dlci:6;
- __u8 credit_flow:4;
- __u8 frame_type:4;
- __u8 res2:2;
- __u8 prior:6;
- __u8 ack_timer;
- __u16 frame_size:16;
- __u8 max_nbrof_retrans;
- __u8 credits;
- __u8 fcs;
+ uint8_t res1:2;
+ uint8_t dlci:6;
+ uint8_t credit_flow:4;
+ uint8_t frame_type:4;
+ uint8_t res2:2;
+ uint8_t prior:6;
+ uint8_t ack_timer;
+ uint16_t frame_size:16;
+ uint8_t max_nbrof_retrans;
+ uint8_t credits;
+ uint8_t fcs;
} __attribute__ ((packed)) pn_msg;
typedef struct nsc_msg {
short_frame_head s_head;
mcc_short_frame_head mcc_s_head;
mcc_type command_type;
- __u8 fcs;
+ uint8_t fcs;
} __attribute__ ((packed)) nsc_msg;
#else /* __XXX_ENDIAN */
diff --git a/tools/parser/sdp.c b/tools/parser/sdp.c
index a3fb7c8..ef35584 100644
--- a/tools/parser/sdp.c
+++ b/tools/parser/sdp.c
#include <errno.h>
#include <string.h>
-#include <sys/socket.h>
#include <sys/types.h>
-#include <asm/types.h>
+#include <sys/socket.h>
#include <netinet/in.h>
#include <bluetooth/bluetooth.h>
return 0;
}
-static inline __u8 parse_de_hdr(struct frame *frm, int* n)
+static inline uint8_t parse_de_hdr(struct frame *frm, int* n)
{
- __u8 de_hdr = get_u8(frm);
- __u8 de_type = de_hdr >> 3;
- __u8 siz_idx = de_hdr & 0x07;
+ uint8_t de_hdr = get_u8(frm);
+ uint8_t de_type = de_hdr >> 3;
+ uint8_t siz_idx = de_hdr & 0x07;
/* Get the number of bytes */
if (sdp_siz_idx_lookup_table[siz_idx].addl_bits) {
return de_type;
}
-static inline void print_int(__u8 de_type, int level, int n, struct frame *frm)
+static inline void print_int(uint8_t de_type, int level, int n, struct frame *frm)
{
- __u64 val, val2;
+ uint64_t val, val2;
switch(de_type) {
case SDP_DE_UINT:
static inline void print_uuid(int n, struct frame *frm)
{
- __u32 uuid = 0;
+ uint32_t uuid = 0;
char* s;
switch(n) {
frm->len -= n;
}
-static inline void print_des(__u8 de_type, int level, int n, struct frame *frm, int *split)
+static inline void print_des(uint8_t de_type, int level, int n, struct frame *frm, int *split)
{
int len = frm->len;
while (len - frm->len < n )
static inline void print_de(int level, struct frame *frm, int *split)
{
int n;
- __u8 de_type = parse_de_hdr(frm, &n);
+ uint8_t de_type = parse_de_hdr(frm, &n);
switch(de_type) {
case SDP_DE_NULL:
static inline void print_attr_id_list(int level, struct frame *frm)
{
- __u16 attr_id;
- __u32 attr_id_range;
+ uint16_t attr_id;
+ uint32_t attr_id_range;
int len = frm->len;
int n1, n2;
static inline void print_attr_list(int level, struct frame *frm)
{
- __u16 attr_id;
+ uint16_t attr_id;
int n1, n2, split;
int len = frm->len;
}
-static inline void err_rsp(int level, __u16 tid, __u16 len, struct frame *frm)
+static inline void err_rsp(int level, uint16_t tid, uint16_t len, struct frame *frm)
{
printf("SDP Error Rsp: tid 0x%x len 0x%x\n", tid, len);
}
-static inline void ss_req(int level, __u16 tid, __u16 len, struct frame *frm)
+static inline void ss_req(int level, uint16_t tid, uint16_t len, struct frame *frm)
{
printf("SDP SS Req: tid 0x%x len 0x%x\n", tid, len);
printf("max 0x%x\n", get_u16(frm));
}
-static inline void ss_rsp(int level, __u16 tid, __u16 len, struct frame *frm)
+static inline void ss_rsp(int level, uint16_t tid, uint16_t len, struct frame *frm)
{
register int i;
- __u16 cur_srv_rec_cnt = get_u16(frm); /* Parse CurrentServiceRecordCount */
- __u16 tot_srv_rec_cnt = get_u16(frm); /* Parse TotalServiceRecordCount */
+ uint16_t cur_srv_rec_cnt = get_u16(frm); /* Parse CurrentServiceRecordCount */
+ uint16_t tot_srv_rec_cnt = get_u16(frm); /* Parse TotalServiceRecordCount */
printf("SDP SS Rsp: tid 0x%x len 0x%x\n", tid, len);
printf("\n");
}
-static inline void sa_req(int level, __u16 tid, __u16 len, struct frame *frm)
+static inline void sa_req(int level, uint16_t tid, uint16_t len, struct frame *frm)
{
printf("SDP SA Req: tid 0x%x len 0x%x\n", tid, len);
print_attr_id_list(level, frm);
}
-static inline void sa_rsp(int level, __u16 tid, __u16 len, struct frame *frm)
+static inline void sa_rsp(int level, uint16_t tid, uint16_t len, struct frame *frm)
{
printf("SDP SA Rsp: tid 0x%x len 0x%x\n", tid, len);
print_attr_list(level, frm);
}
-static inline void ssa_req(int level, __u16 tid, __u16 len, struct frame *frm)
+static inline void ssa_req(int level, uint16_t tid, uint16_t len, struct frame *frm)
{
printf("SDP SSA Req: tid 0x%x len 0x%x\n", tid, len);
print_attr_id_list(level, frm);
}
-static inline void ssa_rsp(int level, __u16 tid, __u16 len, struct frame *frm)
+static inline void ssa_rsp(int level, uint16_t tid, uint16_t len, struct frame *frm)
{
int cnt;
printf("SDP SSA Rsp: tid 0x%x len 0x%x\n", tid, len);
void sdp_dump(int level, struct frame *frm)
{
sdp_pdu_hdr *hdr = frm->ptr;
- __u16 tid = ntohs(hdr->tid);
- __u16 len = ntohs(hdr->len);
+ uint16_t tid = ntohs(hdr->tid);
+ uint16_t len = ntohs(hdr->len);
frm->ptr += SDP_PDU_HDR_SIZE;
frm->len -= SDP_PDU_HDR_SIZE;
diff --git a/tools/parser/sdp.h b/tools/parser/sdp.h
index 3fc5f3e..fe66e71 100644
--- a/tools/parser/sdp.h
+++ b/tools/parser/sdp.h
/* SDP structures */
typedef struct {
- __u8 pid;
- __u16 tid;
- __u16 len;
+ uint8_t pid;
+ uint16_t tid;
+ uint16_t len;
} __attribute__ ((packed)) sdp_pdu_hdr;
#define SDP_PDU_HDR_SIZE 5