From d5daa90a2130f627e2b1b0297affe16b6cc3ab26 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Sun, 8 Dec 2002 00:37:07 +0000 Subject: [PATCH] hcidump: Replace __uXXX with uXXX_t and fix get_unaligned stuff --- tools/hcidump.c | 10 +- tools/parser/bnep.c | 18 +-- tools/parser/cmtp.c | 20 +-- tools/parser/hci.c | 20 +-- tools/parser/l2cap.c | 46 +++--- tools/parser/parser.c | 2 +- tools/parser/parser.h | 32 ++--- tools/parser/rfcomm.c | 34 ++--- tools/parser/rfcomm.h | 326 +++++++++++++++++++++--------------------- tools/parser/sdp.c | 49 ++++--- tools/parser/sdp.h | 6 +- 11 files changed, 278 insertions(+), 285 deletions(-) diff --git a/tools/hcidump.c b/tools/hcidump.c index 205531eee..d33b56510 100644 --- a/tools/hcidump.c +++ b/tools/hcidump.c @@ -28,16 +28,16 @@ #include #include #include -#include -#include -#include -#include #include #include #include #include -#include +#include +#include +#include +#include +#include #include #include diff --git a/tools/parser/bnep.c b/tools/parser/bnep.c index 7dc42e433..f4782312f 100644 --- a/tools/parser/bnep.c +++ b/tools/parser/bnep.c @@ -34,9 +34,9 @@ #include #include -#include #include -#include +#include +#include #include #include @@ -67,11 +67,11 @@ static char *get_macaddr(struct frame *frm) 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) { @@ -163,9 +163,9 @@ static void bnep_control(int level, struct frame *frm, int header_length) 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) { @@ -241,8 +241,8 @@ static void ip_dump(int level, struct frame *frm) 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 a8e68edc7..0c137a63e 100644 --- a/tools/parser/cmtp.c +++ b/tools/parser/cmtp.c @@ -34,16 +34,16 @@ #include #include -#include #include -#include +#include +#include #include #include "parser.h" -char *bst2str(__u8 bst) +char *bst2str(uint8_t bst) { switch (bst) { case 0x00: @@ -61,14 +61,14 @@ char *bst2str(__u8 bst) 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; @@ -83,11 +83,11 @@ void cmtp_dump(int level, struct frame *frm) 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 10794b5a3..4745f8a8d 100644 --- a/tools/parser/hci.c +++ b/tools/parser/hci.c @@ -29,9 +29,9 @@ #include #include -#include #include -#include +#include +#include #include #include @@ -223,9 +223,9 @@ char *cmd_status_map[] = { 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)) @@ -307,9 +307,9 @@ static inline void event_dump(int level, struct frame *frm) 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); @@ -332,7 +332,7 @@ static inline void acl_dump(int level, struct frame *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); @@ -348,7 +348,7 @@ static inline void sco_dump(int level, struct frame *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 856a7ad9c..e34e75334 100644 --- a/tools/parser/l2cap.c +++ b/tools/parser/l2cap.c @@ -29,9 +29,9 @@ #include #include -#include #include -#include +#include +#include #include #include @@ -40,7 +40,7 @@ #include "parser.h" typedef struct { - __u16 handle; + uint16_t handle; struct frame frm; } handle_info; #define HANDLE_TABLE_SIZE 10 @@ -48,8 +48,8 @@ typedef struct { 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 @@ -58,7 +58,7 @@ static cid_info cid_table[2][CID_TABLE_SIZE]; #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; @@ -71,7 +71,7 @@ static struct frame * add_handle(__u16 handle) 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; @@ -83,7 +83,7 @@ static struct frame * get_frame(__u16 handle) 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; @@ -96,10 +96,10 @@ static void add_cid(int in, __u16 cid, __u16 psm) } } -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; @@ -118,7 +118,7 @@ static void del_cid(int in, __u16 dcid, __u16 scid) } } -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; @@ -153,7 +153,7 @@ static inline void conn_req(int level, struct frame *frm) 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); @@ -166,17 +166,17 @@ static inline void conn_rsp(int level, struct frame *frm) 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; } @@ -299,9 +299,9 @@ static inline void info_rsp(int level, l2cap_cmd_hdr *cmd, struct frame *frm) 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; @@ -372,8 +372,8 @@ static void l2cap_parse(int level, struct frame *frm) 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 */ @@ -381,7 +381,7 @@ static void l2cap_parse(int level, struct frame *frm) if (p_filter(FILT_L2CAP)) return; - psm = btohs(*(__u16*)frm->ptr); + psm = btohs(*(uint16_t*)frm->ptr); frm->len -= 2; p_indent(level, frm); @@ -389,7 +389,7 @@ static void l2cap_parse(int level, struct frame *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); @@ -441,7 +441,7 @@ void l2cap_dump(int level, struct frame *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 f06de3349..02fdcac5b 100644 --- a/tools/parser/parser.c +++ b/tools/parser/parser.c @@ -31,7 +31,7 @@ #include #include -#include +#include #include "parser.h" diff --git a/tools/parser/parser.h b/tools/parser/parser.h index 6747e039d..4f5282cf7 100644 --- a/tools/parser/parser.h +++ b/tools/parser/parser.h @@ -23,14 +23,6 @@ * $Id$ */ -#include - -#include -#include -#include - -#include - struct frame { void *data; int data_len; @@ -104,34 +96,38 @@ static inline void p_indent(int level, struct frame *f) /* 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); @@ -139,7 +135,7 @@ static inline __u64 get_u64(struct frame *frm) 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 287908e95..62904668c 100644 --- a/tools/parser/rfcomm.c +++ b/tools/parser/rfcomm.c @@ -34,9 +34,9 @@ #include #include -#include #include -#include +#include +#include #include @@ -51,12 +51,12 @@ static char *cr_str[] = { #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); @@ -71,7 +71,7 @@ void print_mcc(mcc_long_frame_head* mcc_head) 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) { @@ -79,7 +79,7 @@ static inline void mcc_test(int level, __u8 *ptr, int len, 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) { @@ -88,7 +88,7 @@ static inline void mcc_fcon(int level, __u8 *ptr, int len, 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) { @@ -97,7 +97,7 @@ static inline void mcc_fcoff(int level, __u8 *ptr, int len, 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) { @@ -124,7 +124,7 @@ static inline void mcc_msc(int level, __u8 *ptr, int len, 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) { @@ -152,10 +152,10 @@ static inline void mcc_rpn(int level, __u8 *ptr, int len, 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) { @@ -167,7 +167,7 @@ static inline void mcc_rls(int level, __u8 *ptr, int len, 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) { @@ -185,7 +185,7 @@ static inline void mcc_pn(int level, __u8 *ptr, int len, 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) { @@ -205,7 +205,7 @@ static inline void mcc_frame(int level, struct frame *frm, long_frame_head *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; @@ -276,7 +276,7 @@ static inline void uih_frame(int level, struct frame *frm, long_frame_head *head 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 3823773d5..c22d57a6c 100644 --- a/tools/parser/rfcomm.h +++ b/tools/parser/rfcomm.h @@ -28,8 +28,6 @@ * $Id$ */ -#include - #define RFCOMM_PSM 3 #define TRUE 1 @@ -118,83 +116,83 @@ #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; @@ -213,94 +211,94 @@ typedef struct 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 { @@ -309,7 +307,7 @@ 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 { @@ -317,7 +315,7 @@ 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 */ @@ -325,9 +323,9 @@ typedef struct rls_msg { 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 */ @@ -335,17 +333,17 @@ typedef struct pn_msg { 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 */ @@ -353,98 +351,98 @@ 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; #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 { @@ -453,7 +451,7 @@ 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 { @@ -461,39 +459,39 @@ 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 a3fb7c83e..ef35584e6 100644 --- a/tools/parser/sdp.c +++ b/tools/parser/sdp.c @@ -34,9 +34,8 @@ #include #include -#include #include -#include +#include #include #include @@ -150,11 +149,11 @@ static inline char* get_attr_id_name(int attr_id) 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) { @@ -175,9 +174,9 @@ static inline __u8 parse_de_hdr(struct frame *frm, int* n) 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: @@ -223,7 +222,7 @@ static inline void print_int(__u8 de_type, int level, int n, struct frame *frm) static inline void print_uuid(int n, struct frame *frm) { - __u32 uuid = 0; + uint32_t uuid = 0; char* s; switch(n) { @@ -270,7 +269,7 @@ static inline void print_string(int n, struct frame *frm, const char *name) 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 ) @@ -280,7 +279,7 @@ static inline void print_des(__u8 de_type, int level, int n, struct frame *frm, 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: @@ -342,8 +341,8 @@ static inline void print_srv_srch_pat(int level, struct frame *frm) 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; @@ -380,7 +379,7 @@ static inline void print_attr_id_list(int level, struct frame *frm) 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; @@ -439,7 +438,7 @@ static inline void print_attr_lists(int level, struct frame *frm, int 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); @@ -453,7 +452,7 @@ static inline void err_rsp(int level, __u16 tid, __u16 len, struct frame *frm) } -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); @@ -465,11 +464,11 @@ static inline void ss_req(int level, __u16 tid, __u16 len, struct frame *frm) 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); @@ -486,7 +485,7 @@ static inline void ss_rsp(int level, __u16 tid, __u16 len, struct frame *frm) 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); @@ -502,7 +501,7 @@ static inline void sa_req(int level, __u16 tid, __u16 len, struct frame *frm) 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); @@ -514,7 +513,7 @@ static inline void sa_rsp(int level, __u16 tid, __u16 len, struct frame *frm) 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); @@ -529,7 +528,7 @@ static inline void ssa_req(int level, __u16 tid, __u16 len, struct frame *frm) 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); @@ -546,8 +545,8 @@ static inline void ssa_rsp(int level, __u16 tid, __u16 len, struct frame *frm) 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 3fc5f3e47..fe66e71d8 100644 --- a/tools/parser/sdp.h +++ b/tools/parser/sdp.h @@ -135,9 +135,9 @@ /* 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 -- 2.47.3