* [Bluez-devel] Patch for bluez-hcidump-1.5
@ 2002-12-07 5:04 Maksim Yevmenkin
2002-12-07 16:01 ` Marcel Holtmann
0 siblings, 1 reply; 7+ messages in thread
From: Maksim Yevmenkin @ 2002-12-07 5:04 UTC (permalink / raw)
To: bluez-devel
[-- Attachment #1: Type: text/plain, Size: 699 bytes --]
Dear BlueZ-Developers,
please find attached patch for the bluez-hcidump-1.5 package.
here is the quick summary of the changes
1) __uXXX types replaced with uXXX_t
2) minor fix for l2cap parser
3) minor fix for hcidump.1 man page
4) get_unaligned stuff fix
Note: after applying the patch you still need to move
hcidump.8 to hcidump.1
i also re-arranged #include lines .c files and removed #include
lines from the headers. this way it much easier to port, because
it is clear which headers are used and what needs to be ported.
i would appreciate if any new code in BlueZ will follow this
simple rules.
please review and if there are no objections commit.
thanks,
max
[-- Attachment #2: bluez-hcidump-1.5.diff.gz --]
[-- Type: application/x-gzip, Size: 9064 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Bluez-devel] Patch for bluez-hcidump-1.5
2002-12-07 5:04 Maksim Yevmenkin
@ 2002-12-07 16:01 ` Marcel Holtmann
0 siblings, 0 replies; 7+ messages in thread
From: Marcel Holtmann @ 2002-12-07 16:01 UTC (permalink / raw)
To: Maksim Yevmenkin; +Cc: BlueZ Mailing List
[-- Attachment #1: Type: text/plain, Size: 1626 bytes --]
Hi Maksim,
> please find attached patch for the bluez-hcidump-1.5 package.
> here is the quick summary of the changes
>
> 1) __uXXX types replaced with uXXX_t
> 2) minor fix for l2cap parser
> 3) minor fix for hcidump.1 man page
> 4) get_unaligned stuff fix
>
> Note: after applying the patch you still need to move
> hcidump.8 to hcidump.1
>
> i also re-arranged #include lines .c files and removed #include
> lines from the headers. this way it much easier to port, because
> it is clear which headers are used and what needs to be ported.
> i would appreciate if any new code in BlueZ will follow this
> simple rules.
>
> please review and if there are no objections commit.
please don't put all your changes in one big patch. Such big things are
hard to review. I have removed your changes to the man page and attached
the resulting diff to this email. People with non Intel architectures
please test it. BTW the best command for making diffs is "diff -urN".
What do mean with 2. Maybe I have missed it, but I don't see any fixes
to the L2CAP parser.
The man page belongs to section 8 like all other *dump programs do. See
for example irdadump, tcpdump, pppdump etc. I will look at the man page
code today. What did you have used as reference? I ask because we should
keep the same syntax for all of our man pages. Is there a "best way to
write a man page"?
I left the re-arrange of the #include lines in the patch. I don't see
why this makes it easier, but I have no big experiences on porting stuff
to other OS. Can you give us (or maybe only me) some explanations why
this is good to have.
Regards
Marcel
[-- Attachment #2: patch-hcidump --]
[-- Type: text/x-patch, Size: 34487 bytes --]
diff -urN hcidump/hcidump.c hcidump-mh/hcidump.c
--- hcidump/hcidump.c Mon Nov 25 19:51:58 2002
+++ hcidump-mh/hcidump.c Sat Dec 7 16:43:52 2002
@@ -23,21 +23,21 @@
* $Id: hcidump.c,v 1.27 2002/11/25 17:59:26 maxk Exp $
*/
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <termios.h>
-#include <fcntl.h>
+#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
-#include <sys/types.h>
#include <sys/uio.h>
+#include <netinet/in.h>
+
#include <errno.h>
-#include <string.h>
-#include <pwd.h>
+#include <fcntl.h>
#include <getopt.h>
-
-#include <asm/types.h>
+#include <pwd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <termios.h>
+#include <unistd.h>
#include <bluetooth/bluetooth.h>
#include <bluetooth/hci.h>
diff -urN hcidump/hcidump.h hcidump-mh/hcidump.h
--- hcidump/hcidump.h Thu Feb 7 05:47:36 2002
+++ hcidump-mh/hcidump.h Sat Dec 7 16:43:52 2002
@@ -1,4 +1,4 @@
-/*
+/*
HCIDump - HCI packet analyzer
Copyright (C) 2000-2001 Maxim Krasnyansky <maxk@qualcomm.com>
@@ -31,11 +31,11 @@
};
struct dump_hdr {
- __u16 len;
- __u8 in;
- __u8 pad;
- __u32 ts_sec;
- __u32 ts_usec;
+ uint16_t len;
+ uint8_t in;
+ uint8_t pad;
+ uint32_t ts_sec;
+ uint32_t ts_usec;
} __attribute__ ((packed));
#define DUMP_HDR_SIZE (sizeof(struct dump_hdr))
diff -urN hcidump/parser/bnep.c hcidump-mh/parser/bnep.c
--- hcidump/parser/bnep.c Sat Aug 31 05:12:18 2002
+++ hcidump-mh/parser/bnep.c Sat Dec 7 16:43:52 2002
@@ -28,15 +28,15 @@
* $Id: bnep.c,v 1.3 2002/08/31 03:12:18 sasai Exp $
*/
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+
+#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
-#include <unistd.h>
-#include <errno.h>
#include <string.h>
-
-#include <sys/socket.h>
-#include <sys/types.h>
-#include <asm/types.h>
+#include <unistd.h>
#include <bluetooth/bluetooth.h>
#include <bluetooth/hci.h>
@@ -45,12 +45,6 @@
#include "parser.h"
#include "bnep.h"
-#include <net/ethernet.h>
-#include <netinet/in.h>
-#include <netinet/ip.h>
-#include <netinet/if_ether.h>
-#include <arpa/inet.h>
-
#define PAYLOAD_RAW_DUMP
static char *get_macaddr(struct frame *frm)
@@ -67,11 +61,11 @@
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 +157,9 @@
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 +235,8 @@
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 -urN hcidump/parser/cmtp.c hcidump-mh/parser/cmtp.c
--- hcidump/parser/cmtp.c Sat Aug 31 23:40:51 2002
+++ hcidump-mh/parser/cmtp.c Sat Dec 7 16:43:52 2002
@@ -28,22 +28,22 @@
* $Id: cmtp.c,v 1.1 2002/08/31 21:40:51 holtmann Exp $
*/
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <netinet/in.h>
+
+#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
-#include <unistd.h>
-#include <errno.h>
#include <string.h>
-
-#include <sys/socket.h>
-#include <sys/types.h>
-#include <asm/types.h>
+#include <unistd.h>
#include <bluetooth/bluetooth.h>
#include "parser.h"
-char *bst2str(__u8 bst)
+char *bst2str(uint8_t bst)
{
switch (bst) {
case 0x00:
@@ -61,14 +61,14 @@
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 @@
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 -urN hcidump/parser/hci.c hcidump-mh/parser/hci.c
--- hcidump/parser/hci.c Tue Mar 12 19:47:34 2002
+++ hcidump-mh/parser/hci.c Sat Dec 7 16:43:52 2002
@@ -23,15 +23,15 @@
* $Id: hci.c,v 1.12 2002/03/12 18:47:34 maxk Exp $
*/
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+
+#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
-#include <unistd.h>
-#include <errno.h>
#include <string.h>
-
-#include <sys/socket.h>
-#include <sys/types.h>
-#include <asm/types.h>
+#include <unistd.h>
#include <bluetooth/bluetooth.h>
#include <bluetooth/hci.h>
@@ -223,9 +223,9 @@
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 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 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 @@
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 -urN hcidump/parser/l2cap.c hcidump-mh/parser/l2cap.c
--- hcidump/parser/l2cap.c Sat Aug 31 23:40:51 2002
+++ hcidump-mh/parser/l2cap.c Sat Dec 7 16:43:52 2002
@@ -23,15 +23,15 @@
* $Id: l2cap.c,v 1.17 2002/08/31 21:40:51 holtmann Exp $
*/
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+
+#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
-#include <unistd.h>
-#include <errno.h>
#include <string.h>
-
-#include <sys/socket.h>
-#include <sys/types.h>
-#include <asm/types.h>
+#include <unistd.h>
#include <bluetooth/bluetooth.h>
#include <bluetooth/hci.h>
@@ -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 @@
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 @@
#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 @@
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 @@
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 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 __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_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 @@
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 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 @@
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 @@
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 @@
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 @@
{
struct frame *fr;
l2cap_hdr *hdr;
- __u16 dlen;
+ uint16_t dlen;
if (frm->flags & ACL_START) {
hdr = frm->ptr;
diff -urN hcidump/parser/parser.c hcidump-mh/parser/parser.c
--- hcidump/parser/parser.c Sat Aug 31 23:40:51 2002
+++ hcidump-mh/parser/parser.c Sat Dec 7 16:43:52 2002
@@ -23,15 +23,15 @@
* $Id: parser.c,v 1.13 2002/08/31 21:40:51 holtmann Exp $
*/
+#include <sys/types.h>
+#include <netinet/in.h>
+
+#include <ctype.h>
+#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
-#include <unistd.h>
-#include <errno.h>
#include <string.h>
-#include <ctype.h>
-
-#include <sys/types.h>
-#include <asm/types.h>
+#include <unistd.h>
#include "parser.h"
diff -urN hcidump/parser/parser.h hcidump-mh/parser/parser.h
--- hcidump/parser/parser.h Mon Sep 23 15:40:42 2002
+++ hcidump-mh/parser/parser.h Sat Dec 7 16:43:52 2002
@@ -23,14 +23,6 @@
* $Id: parser.h,v 1.19 2002/09/23 13:40:42 jscrane Exp $
*/
-#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;
@@ -104,34 +96,38 @@
/* 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 @@
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 -urN hcidump/parser/rfcomm.c hcidump-mh/parser/rfcomm.c
--- hcidump/parser/rfcomm.c Sat Oct 12 20:07:10 2002
+++ hcidump-mh/parser/rfcomm.c Sat Dec 7 16:43:52 2002
@@ -28,15 +28,16 @@
* $Id: rfcomm.c,v 1.5 2002/10/12 18:07:10 holtmann Exp $
*/
+#include <asm/byteorder.h>
+
+#include <sys/types.h>
+#include <sys/socket.h>
+
+#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
-#include <unistd.h>
-#include <errno.h>
#include <string.h>
-
-#include <sys/socket.h>
-#include <sys/types.h>
-#include <asm/types.h>
+#include <unistd.h>
#include <bluetooth/bluetooth.h>
@@ -51,12 +52,12 @@
#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 +72,7 @@
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 +80,7 @@
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 +89,7 @@
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 +98,7 @@
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 +125,7 @@
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 +153,10 @@
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 +168,7 @@
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 +186,7 @@
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 +206,7 @@
{
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 +277,7 @@
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 -urN hcidump/parser/rfcomm.h hcidump-mh/parser/rfcomm.h
--- hcidump/parser/rfcomm.h Mon Apr 22 23:47:07 2002
+++ hcidump-mh/parser/rfcomm.h Sat Dec 7 16:43:52 2002
@@ -28,8 +28,6 @@
* $Id: rfcomm.h,v 1.2 2002/04/22 21:47:07 maxk Exp $
*/
-#include <asm/byteorder.h>
-
#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;
+ uint8_t 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;
+ 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;
- __u8 xon;
- __u8 xoff;
+ uint8_t xon;
+ uint8_t xoff;
parameter_mask pm;
} __attribute__ ((packed)) rpn_values;
@@ -213,94 +211,94 @@
#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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 -urN hcidump/parser/sdp.c hcidump-mh/parser/sdp.c
--- hcidump/parser/sdp.c Thu Nov 7 00:13:16 2002
+++ hcidump-mh/parser/sdp.c Sat Dec 7 16:43:52 2002
@@ -28,16 +28,15 @@
* $Id: sdp.c,v 1.14 2002/11/06 23:10:55 holtmann Exp $
*/
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+
+#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
-#include <unistd.h>
-#include <errno.h>
#include <string.h>
-
-#include <sys/socket.h>
-#include <sys/types.h>
-#include <asm/types.h>
-#include <netinet/in.h>
+#include <unistd.h>
#include <bluetooth/bluetooth.h>
#include <bluetooth/hci.h>
@@ -150,11 +149,11 @@
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 @@
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_uuid(int n, struct frame *frm)
{
- __u32 uuid = 0;
+ uint32_t uuid = 0;
char* s;
switch(n) {
@@ -270,7 +269,7 @@
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_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_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_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 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 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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 -urN hcidump/parser/sdp.h hcidump-mh/parser/sdp.h
--- hcidump/parser/sdp.h Thu Nov 7 00:02:14 2002
+++ hcidump-mh/parser/sdp.h Sat Dec 7 16:43:52 2002
@@ -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
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: [Bluez-devel] Patch for bluez-hcidump-1.5
@ 2002-12-07 17:07 Maksim Yevmenkin
2002-12-08 0:18 ` Marcel Holtmann
0 siblings, 1 reply; 7+ messages in thread
From: Maksim Yevmenkin @ 2002-12-07 17:07 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: BlueZ Mailing List
Hi Marcel,
> > please find attached patch for the bluez-hcidump-1.5 package.
> > here is the quick summary of the changes
> >=20
> > 1) __uXXX types replaced with uXXX_t=20
> > 2) minor fix for l2cap parser
> > 3) minor fix for hcidump.1 man page
> > 4) get_unaligned stuff fix
> >=20
> > Note: after applying the patch you still need to move
> > hcidump.8 to hcidump.1
> >=20
> > i also re-arranged #include lines .c files and removed #include
> > lines from the headers. this way it much easier to port, because
> > it is clear which headers are used and what needs to be ported.
> > i would appreciate if any new code in BlueZ will follow this
> > simple rules.=20
> >=20
> > please review and if there are no objections commit.
>=20
> please don't put all your changes in one big patch. Such big things are
> hard to review. I have removed your changes to the man page and attached
> the resulting diff to this email. People with non Intel architectures
> please test it. BTW the best command for making diffs is "diff -urN".
normally i would agree with you, but not in this case :) the changes
are mostly mechanical, i.e s/__u8/uint8_t/g. this should be very easy
to review. i did not change logic or code structure at all. however,
if people think it is hard to review i will split it.
> What do mean with 2. Maybe I have missed it, but I don't see any fixes
> to the L2CAP parser.
in the parser/l2cap.c file there is a function called parse_l2cap().
after signal l2cap packet gets processed frm->len and frm->ptr
are adjusted by hdr->len. i think it should be btohs(hdr->len).
> The man page belongs to section 8 like all other *dump programs do. See
> for example irdadump, tcpdump, pppdump etc. I will look at the man page
> code today.
hmmm...
man 1 intro
on Linux - Introduction to user commands
on *BSD - Introduction to general commands (tools and utilities)
on Solaris - Introduction to commands and application programs
man 8 intro
on Linux - Introduction to administration and privileged commands
on *BSD - Introduction to system maintainance and opearation commands
on Solaris - no man page?
tcpdump has .1 man page on *BSD, snoop (similar to tcpdump) has .1M
man page on Solaris. tcpdump has .8 man page on Linux - really *strange*, b=
ecause tcpdump does not even come standard with Linux (well at least
in my case :). i had to install tcpdump RPM.
IMO tcpdump, pppdump, hcidump are hardly an "administration" commands,
however i admit they may be "privileged". if Linux has chosen to
put man pages for these tools in .8 section then it is fine. just
revert Makefile.{im|am} and change section in the hcidump.8 file.
> What did you have used as reference? I ask because we should
> keep the same syntax for all of our man pages. Is there a "best way to
> write a man page"?
man mdoc(7) on *BSD systems gives you general guidelines and page
template. man mdoc(7) on Linux gives you a little bit less information,
but still a good place to start.
> I left the re-arrange of the #include lines in the patch. I don't see
> why this makes it easier, but I have no big experiences on porting stuff
> to other OS. Can you give us (or maybe only me) some explanations why
> this is good to have.
*BSD systems have style(9) man page. this page describes the
coding style guidelines for *BSD kernel. i found these guidelines
very useful and try to follow them. i *personally* try not to put
#include lines in the header files. any dependencies should be
indicated elsewhere. this comes from my experince with the couple
of big projects where is was a pure nightmare to track down some
minor change in the distant header file. another reason is that it=20
much easier for me to port, because when i see something like
#include <bluetooth/x.h>
#include <bluetooth/y.h>
#include <bluetooth/z.h>
rather then
#include "something.h"
i know exactly how to translate BlueZ headers into FreeBSD
headers. i admin that it will not matter any more as soon as
both systems will have common headers.
thanks,
max
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: [Bluez-devel] Patch for bluez-hcidump-1.5
2002-12-07 17:07 Maksim Yevmenkin
@ 2002-12-08 0:18 ` Marcel Holtmann
0 siblings, 0 replies; 7+ messages in thread
From: Marcel Holtmann @ 2002-12-08 0:18 UTC (permalink / raw)
To: Maksim Yevmenkin; +Cc: BlueZ Mailing List
Hi Maksim,
> normally i would agree with you, but not in this case :) the changes
> are mostly mechanical, i.e s/__u8/uint8_t/g. this should be very easy
> to review. i did not change logic or code structure at all. however,
> if people think it is hard to review i will split it.
I like to have this mechanical one as a seperate patch so we can take a
quick look at it and apply them to CVS. If you have much mechanical
stuff in it is hard to find the other ones, especially if they are only
oneliner.
And don't diff Makefile.in, Makefile or configure. They are all
autogenerated.
> in the parser/l2cap.c file there is a function called parse_l2cap().
> after signal l2cap packet gets processed frm->len and frm->ptr
> are adjusted by hdr->len. i think it should be btohs(hdr->len).
Ok, got it. Is it not better to use the defined variable dlen?
> > The man page belongs to section 8 like all other *dump programs do. See
> > for example irdadump, tcpdump, pppdump etc. I will look at the man page
> > code today.
>
> hmmm...
>
> man 1 intro
> on Linux - Introduction to user commands
> on *BSD - Introduction to general commands (tools and utilities)
> on Solaris - Introduction to commands and application programs
>
> man 8 intro
> on Linux - Introduction to administration and privileged commands
> on *BSD - Introduction to system maintainance and opearation commands
> on Solaris - no man page?
>
> tcpdump has .1 man page on *BSD, snoop (similar to tcpdump) has .1M
> man page on Solaris. tcpdump has .8 man page on Linux - really *strange*, because tcpdump does not even come standard with Linux (well at least
> in my case :). i had to install tcpdump RPM.
>
> IMO tcpdump, pppdump, hcidump are hardly an "administration" commands,
> however i admit they may be "privileged". if Linux has chosen to
> put man pages for these tools in .8 section then it is fine. just
> revert Makefile.{im|am} and change section in the hcidump.8 file.
Let's have hcidump.8 because hcidump needs root privilige to work as
expected.
> man mdoc(7) on *BSD systems gives you general guidelines and page
> template. man mdoc(7) on Linux gives you a little bit less information,
> but still a good place to start.
Thanks, I will take a look at it.
> *BSD systems have style(9) man page. this page describes the
> coding style guidelines for *BSD kernel. i found these guidelines
> very useful and try to follow them. i *personally* try not to put
> #include lines in the header files. any dependencies should be
> indicated elsewhere. this comes from my experince with the couple
> of big projects where is was a pure nightmare to track down some
> minor change in the distant header file. another reason is that it
> much easier for me to port, because when i see something like
>
> #include <bluetooth/x.h>
> #include <bluetooth/y.h>
> #include <bluetooth/z.h>
>
> rather then
>
> #include "something.h"
>
> i know exactly how to translate BlueZ headers into FreeBSD
> headers. i admin that it will not matter any more as soon as
> both systems will have common headers.
I agree with you that header files should avoid to include other header
files. But my question was, why you did the reorder of header files like
you have done in the patch. I always start with <stdio.h> and following.
Then take the <sys/*.h> and after that comes <bluetooth/*.h> as needed.
And I think this is a good order and I can't get the advantage of
changing it. What do you really need to make it easy to port them to
FreeBSD?
Regards
Marcel
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: [Bluez-devel] Patch for bluez-hcidump-1.5
@ 2002-12-08 4:17 Maksim Yevmenkin
0 siblings, 0 replies; 7+ messages in thread
From: Maksim Yevmenkin @ 2002-12-08 4:17 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: BlueZ Mailing List
Hi Marcel,
> > normally i would agree with you, but not in this case :) the changes
> > are mostly mechanical, i.e s/__u8/uint8_t/g. this should be very easy
> > to review. i did not change logic or code structure at all. however,
> > if people think it is hard to review i will split it.
>=20
> I like to have this mechanical one as a seperate patch so we can take a
> quick look at it and apply them to CVS. If you have much mechanical
> stuff in it is hard to find the other ones, especially if they are only
> oneliner.
amen :)
> > in the parser/l2cap.c file there is a function called parse_l2cap().
> > after signal l2cap packet gets processed frm->len and frm->ptr
> > are adjusted by hdr->len. i think it should be btohs(hdr->len).
>=20
> Ok, got it. Is it not better to use the defined variable dlen?
yes, you can use dlen. for i386 architecture it probably makes no
difference anyway :)=20
> > > The man page belongs to section 8 like all other *dump programs do. S=
ee
> > > for example irdadump, tcpdump, pppdump etc. I will look at the man pa=
ge
> > > code today.
[...]
> Let's have hcidump.8 because hcidump needs root privilige to work as
> expected.
amen :)
> > *BSD systems have style(9) man page. this page describes the
> > coding style guidelines for *BSD kernel. i found these guidelines
> > very useful and try to follow them. i *personally* try not to put
> > #include lines in the header files. any dependencies should be
> > indicated elsewhere. this comes from my experince with the couple
> > of big projects where is was a pure nightmare to track down some
> > minor change in the distant header file. another reason is that it=20
> > much easier for me to port, because when i see something like
> >=20
> > #include <bluetooth/x.h>
> > #include <bluetooth/y.h>
> > #include <bluetooth/z.h>
> >=20
> > rather then
> >=20
> > #include "something.h"
> >=20
> > i know exactly how to translate BlueZ headers into FreeBSD
> > headers. i admin that it will not matter any more as soon as
> > both systems will have common headers.
>=20
> I agree with you that header files should avoid to include other header
> files. But my question was, why you did the reorder of header files like
> you have done in the patch. I always start with <stdio.h> and following.
> Then take the <sys/*.h> and after that comes <bluetooth/*.h> as needed.
> And I think this is a good order and I can't get the advantage of
> changing it. What do you really need to make it easy to port them to
> FreeBSD?
the answer to your first question lies in the style(9) man page :)
it defines the order of #inlude's. <sys/*.h>, <machine/*.h> and
other <*/*.h> come first, then other headers in alphabetical order
(if possible). i personally got used to this order and think it
makes sense. first you have #incude's that could possibly be system
dependant and then then rest of the #include's. however, i can deal
with any order of #include's as long as everything is working :)
porting to FreeBSD is pretty much straight forward, i.e. mechanical
changes for some types, #define's and structure names. however,
i would really like to not port anything at all, i.e. use original
BlueZ source code. unfortunately it is not possible right now.
low level API for HCI and L2CAP are somewhat different. although my
FreeBSD Bluetooth code also has HCI and L2CAP sockets - the types,
structure names and API (ioctl's, setsockopt defines) are still
different.=20
i will try to make the first step and create hci.h and l2cap.h
that will contain only HCI and L2CAP types and defines - no system
specific code. the next step is to define API for Bluetooth sockets
(HCI and L2CAP), i.e. ioctl names, setsockopt defines etc. i also
propose to define common libBluetooth, libHCI (and probably libL2CAP)
API that will hide possible implementation differences. after we
do that all application just will use defined API and source code
will be 100% portable.
as for RFCOMM, SDP etc. then you guys will lead the parade :)
i'm currently using BlueZ code with the minimal changes. i'm just
hoping that SDP, RFCOMM etc. implementation won't become too
Linux specific :)
thanks,
max
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: [Bluez-devel] Patch for bluez-hcidump-1.5
[not found] <45258A4365C6B24A9832BFE224837D552B1270@sjdcex01.int.exodus .net>
@ 2002-12-09 17:58 ` Max Krasnyansky
2002-12-09 18:37 ` Maksim Yevmenkin
0 siblings, 1 reply; 7+ messages in thread
From: Max Krasnyansky @ 2002-12-09 17:58 UTC (permalink / raw)
To: Maksim Yevmenkin, Marcel Holtmann; +Cc: BlueZ Mailing List
At 8:7 M 2/7/2002 -0800, Maksim Yevmenkin wrote:
>i will try to make the first step and create hci.h and l2cap.h
>that will contain only HCI and L2CAP types and defines - no system
>specific code. the next step is to define API for Bluetooth sockets
>(HCI and L2CAP), i.e. ioctl names, setsockopt defines etc. i also
>propose to define common libBluetooth, libHCI (and probably libL2CAP)
>API that will hide possible implementation differences. after we
>do that all application just will use defined API and source code
>will be 100% portable.
libL2CAP ?? We don't have libTCP/IP, do we ?
To much abstraction is _bad_.
>as for RFCOMM, SDP etc. then you guys will lead the parade :)
>i'm currently using BlueZ code with the minimal changes. i'm just
>hoping that SDP, RFCOMM etc. implementation won't become too
>Linux specific :)
SDP should be portable.
But RFCOMM TTY stuff will probably be different. How are you going to
implement it btw ?
Max
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Bluez-devel] Patch for bluez-hcidump-1.5
2002-12-09 17:58 ` [Bluez-devel] Patch for bluez-hcidump-1.5 Max Krasnyansky
@ 2002-12-09 18:37 ` Maksim Yevmenkin
0 siblings, 0 replies; 7+ messages in thread
From: Maksim Yevmenkin @ 2002-12-09 18:37 UTC (permalink / raw)
To: Max Krasnyansky; +Cc: Maksim Yevmenkin, Marcel Holtmann, BlueZ Mailing List
Max Krasnyansky wrote:
>
> At 8:7 M 2/7/2002 -0800, Maksim Yevmenkin wrote:
>
> >i will try to make the first step and create hci.h and l2cap.h
> >that will contain only HCI and L2CAP types and defines - no system
> >specific code. the next step is to define API for Bluetooth sockets
> >(HCI and L2CAP), i.e. ioctl names, setsockopt defines etc. i also
> >propose to define common libBluetooth, libHCI (and probably libL2CAP)
> >API that will hide possible implementation differences. after we
> >do that all application just will use defined API and source code
> >will be 100% portable.
> libL2CAP ?? We don't have libTCP/IP, do we ?
> To much abstraction is _bad_.
:) i said *probably* :) there are still some differences in
L2CAP API. i have a different semantic for raw L2CAP sockets
for example. in order to send L2CAP PING and GET_INFO i use
ioctl() to avoid L2CAP command ID's collisions. the L2CAP
library could hide stuff like this. but then again - may be
its way too much abstraction :)
> >as for RFCOMM, SDP etc. then you guys will lead the parade :)
> >i'm currently using BlueZ code with the minimal changes. i'm just
> >hoping that SDP, RFCOMM etc. implementation won't become too
> >Linux specific :)
> SDP should be portable.
amen :)
> But RFCOMM TTY stuff will probably be different. How are you going to
> implement it btw ?
i have not decided yet :( i have bigger problems now :( my
current plan is to make it completely in user space. FreeBSD
has the null-modem driver which will play the role of virtual
serial port. a service will start on the null-modem master's
side. a client will start on the null-modem's slave side. in
both cases rfcomm daemon will control other side of the
null-modem, monitor L2CAP socket and maintain rfcomm sessions.
i'm also thinking about RFCOMM sockets module.
max
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2002-12-09 18:37 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <45258A4365C6B24A9832BFE224837D552B1270@sjdcex01.int.exodus .net>
2002-12-09 17:58 ` [Bluez-devel] Patch for bluez-hcidump-1.5 Max Krasnyansky
2002-12-09 18:37 ` Maksim Yevmenkin
2002-12-08 4:17 Maksim Yevmenkin
-- strict thread matches above, loose matches on Subject: below --
2002-12-07 17:07 Maksim Yevmenkin
2002-12-08 0:18 ` Marcel Holtmann
2002-12-07 5:04 Maksim Yevmenkin
2002-12-07 16:01 ` Marcel Holtmann
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.