[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bluetooth-dev] patch: more big endian changes



Hi Everybody,

here are the rest of the big endian changes for openbt stack. The
current cvs version really does not support big endian CPUs. The only BE
support that is available was indented for one of the older releases
before the cvs time.

In the last days gordon put big endian support for the RFCOMM layer into
the cvs and though that the lower layers were already corrected. They
were not, but now they are :-)

I took Gordons old patches and applied them by hand to the current cvs
version. I also moved some conversion macros from  rfcomm.c to local.h,
where I think they belong to.

I tested the big endian stuff with real (but old) hardware between a
Linux PC (kernel 2.4.0) and our embedded Linux custom board with an
IBM405CR CPU (PowerPC). I could do inquiries, rfcomm connections and ppp
over rfcomm with some pingin' over it ! No problems ... nearly no
problems ... After some ftp over the link I got error from
send_acl_packet saying 'negativ cur_len -135'. But I think this is
caused by my faulty ROK101007 firmware, because after the message the
HCI fsm gets out of sync ... (those 'discarding data ... waiting for
ever' messages). Are there some other possible reasons ?

I also did some changes on apps/Rules.elinux and
linux/drivers/char/bluetooth/Makefile for cross compiling for my
powerpc-linux system (I am using hardhat linux). You can now do a

  make INCLUDEDIR=/usr/src/hardhatlinux/include
CROSSCOMPILE=powerpc-linux-

(if your kernel includes for your target are under that path and if your
crossdev tools are named like 'powerpc-linux-gcc' etc.

I hope that the endianess problem are fixed by now. SDP still has to be
checked !!!

Can anybody check this in ?

Matthias
-- 
-------------------------------------------------
\ Matthias Fuchs                                 \
 \ esd electronic system design Gmbh              \
  \ Vahrenwalder Straße 205                        \
   \ D-30165 Hannover                               \
    \ email: matthias.fuchs@xxxxxxx.com      \
     \ phone: +49-511-37298-0                         \
      \ fax:   +49-511-37298-68                        \
       --------------------------------------------------
diff -u -r ./Makefile ../cvs_patch/Makefile
--- ./Makefile	Thu Mar  1 00:42:08 2001
+++ ../cvs_patch/Makefile	Mon Mar 12 13:26:48 2001
@@ -1,7 +1,5 @@
 include $(APPS)/Rules.elinux
 
-#SUBDIRS = src libs apps
-
 INSTDIR = /usr/local/bin
 CONFDIR = /etc
 
diff -u -r ./apps/CVS/Entries ../cvs_patch/apps/CVS/Entries
--- ./apps/CVS/Entries	Mon Mar 12 15:18:48 2001
+++ ../cvs_patch/apps/CVS/Entries	Mon Mar 12 12:26:27 2001
@@ -1,3 +1,3 @@
 /Makefile/1.1/Sun Feb 18 12:35:43 2001//
 /Rules.elinux/1.2/Wed Feb 28 23:42:08 2001//
-D/bluetooth////
+D
Only in ../cvs_patch/apps/CVS: Entries.Log
diff -u -r ./apps/Rules.elinux ../cvs_patch/apps/Rules.elinux
--- ./apps/Rules.elinux	Thu Mar  1 00:42:08 2001
+++ ../cvs_patch/apps/Rules.elinux	Mon Mar 12 12:32:17 2001
@@ -67,8 +67,12 @@
 
 # This is for building for the local host
 
-RANLIB = ranlib
-
+RANLIB  = $(CROSSCOMPILE)ranlib
+OBJCOPY = $(CROSSCOMPILE)objcopy
+LD      = $(CROSSCOMPILE)ld
+AR      = $(CROSSCOMPILE)ar
+CC      = $(CROSSCOMPILE)gcc
+ 
 TARGET_TYPE = host
 TARGET_ENV = "\$$HROOT"
 ifdef HROOT
diff -u -r ./apps/bluetooth/BluetoothPN/CVS/Entries ../cvs_patch/apps/bluetooth/BluetoothPN/CVS/Entries
--- ./apps/bluetooth/BluetoothPN/CVS/Entries	Mon Mar 12 15:18:48 2001
+++ ../cvs_patch/apps/bluetooth/BluetoothPN/CVS/Entries	Mon Mar 12 12:26:27 2001
@@ -3,4 +3,4 @@
 /Makefile/1.2/Wed Mar  7 17:51:23 2001//
 /README/1.1.1.1/Sun Mar  4 05:26:45 2001//
 /main.cxx/1.1.1.1/Sun Mar  4 05:26:45 2001//
-D/fltk////
+D
Only in ../cvs_patch/apps/bluetooth/BluetoothPN/CVS: Entries.Log
diff -u -r ./apps/bluetooth/BluetoothPN/fltk/CVS/Entries ../cvs_patch/apps/bluetooth/BluetoothPN/fltk/CVS/Entries
--- ./apps/bluetooth/BluetoothPN/fltk/CVS/Entries	Mon Mar 12 15:18:48 2001
+++ ../cvs_patch/apps/bluetooth/BluetoothPN/fltk/CVS/Entries	Mon Mar 12 12:26:27 2001
@@ -2,5 +2,4 @@
 /Fl_Toggle_Node_Base.cxx/1.1.1.1/Sun Mar  4 05:26:45 2001//
 /Fl_Toggle_Tree.cxx/1.1.1.1/Sun Mar  4 05:26:45 2001//
 /Fl_Toggle_Tree_Base.cxx/1.1.1.1/Sun Mar  4 05:26:45 2001//
-D/include////
-D/lib////
+D
Only in ../cvs_patch/apps/bluetooth/BluetoothPN/fltk/CVS: Entries.Log
diff -u -r ./apps/bluetooth/BluetoothPN/fltk/include/CVS/Entries ../cvs_patch/apps/bluetooth/BluetoothPN/fltk/include/CVS/Entries
--- ./apps/bluetooth/BluetoothPN/fltk/include/CVS/Entries	Mon Mar 12 15:18:48 2001
+++ ../cvs_patch/apps/bluetooth/BluetoothPN/fltk/include/CVS/Entries	Mon Mar 12 12:26:27 2001
@@ -1 +1 @@
-D/FL////
+D
Only in ../cvs_patch/apps/bluetooth/BluetoothPN/fltk/include/CVS: Entries.Log
diff -u -r ./apps/bluetooth/CVS/Entries ../cvs_patch/apps/bluetooth/CVS/Entries
--- ./apps/bluetooth/CVS/Entries	Mon Mar 12 15:18:48 2001
+++ ../cvs_patch/apps/bluetooth/CVS/Entries	Mon Mar 12 12:26:27 2001
@@ -1,6 +1,2 @@
 /Makefile/1.2/Wed Feb 28 23:42:08 2001//
-D/BluetoothPN////
-D/btd////
-D/experimental////
-D/sdp_server////
-D/userstack////
+D
Only in ../cvs_patch/apps/bluetooth/CVS: Entries.Log
diff -u -r ./libs/CVS/Entries ../cvs_patch/libs/CVS/Entries
--- ./libs/CVS/Entries	Mon Mar 12 15:18:48 2001
+++ ../cvs_patch/libs/CVS/Entries	Mon Mar 12 12:26:30 2001
@@ -1,2 +1,2 @@
 /Makefile/1.1/Sun Feb 18 12:35:44 2001//
-D/expat////
+D
Only in ../cvs_patch/libs/CVS: Entries.Log
diff -u -r ./libs/expat/CVS/Entries ../cvs_patch/libs/expat/CVS/Entries
--- ./libs/expat/CVS/Entries	Mon Mar 12 15:18:48 2001
+++ ../cvs_patch/libs/expat/CVS/Entries	Mon Mar 12 12:26:30 2001
@@ -1,3 +1,2 @@
 /Makefile/1.1/Sun Feb 18 12:35:44 2001//
-D/xmlparse////
-D/xmltok////
+D
Only in ../cvs_patch/libs/expat/CVS: Entries.Log
diff -u -r ./linux/CVS/Entries ../cvs_patch/linux/CVS/Entries
--- ./linux/CVS/Entries	Mon Mar 12 15:18:48 2001
+++ ../cvs_patch/linux/CVS/Entries	Mon Mar 12 12:26:31 2001
@@ -1,2 +1 @@
-D/drivers////
-D/include////
+D
Only in ../cvs_patch/linux/CVS: Entries.Log
diff -u -r ./linux/drivers/CVS/Entries ../cvs_patch/linux/drivers/CVS/Entries
--- ./linux/drivers/CVS/Entries	Mon Mar 12 15:18:48 2001
+++ ../cvs_patch/linux/drivers/CVS/Entries	Mon Mar 12 12:26:31 2001
@@ -1 +1 @@
-D/char////
+D
Only in ../cvs_patch/linux/drivers/CVS: Entries.Log
diff -u -r ./linux/drivers/char/CVS/Entries ../cvs_patch/linux/drivers/char/CVS/Entries
--- ./linux/drivers/char/CVS/Entries	Mon Mar 12 15:18:48 2001
+++ ../cvs_patch/linux/drivers/char/CVS/Entries	Mon Mar 12 12:26:32 2001
@@ -1 +1 @@
-D/bluetooth////
+D
Only in ../cvs_patch/linux/drivers/char/CVS: Entries.Log
diff -u -r ./linux/drivers/char/bluetooth/Makefile ../cvs_patch/linux/drivers/char/bluetooth/Makefile
--- ./linux/drivers/char/bluetooth/Makefile	Sat Mar 10 14:00:15 2001
+++ ../cvs_patch/linux/drivers/char/bluetooth/Makefile	Mon Mar 12 13:28:28 2001
@@ -2,6 +2,9 @@
 # Makefile for the Bluetooth device driver.
 #
 
+CC=$(CROSSCOMPILE)gcc
+LD=$(CROSSCOMPILE)ld
+
 # This would have worked had it not been for test.c which is not to be
 # included by default
 #OBJS      = $(patsubst %.c, %.o, $(wildcard *.c))
diff -u -r ./linux/drivers/char/bluetooth/hci.c ../cvs_patch/linux/drivers/char/bluetooth/hci.c
--- ./linux/drivers/char/bluetooth/hci.c	Mon Mar  5 17:56:45 2001
+++ ../cvs_patch/linux/drivers/char/bluetooth/hci.c	Mon Mar 12 15:25:19 2001
@@ -32,10 +32,10 @@
  * General Public License. Your use of that executable is in no way
  * restricted on account of using the AXIS OpenBT Stack code with it.
  *
- * This exception does not however invalidate any other reasons why
+ * This exception does not however invalidate any other reasons wh
  * the executable file might be covered by the provisions of the GNU
  * General Public License.
- *
+ 
  * $Id: hci.c,v 1.124 2001/03/05 16:56:45 pkj Exp $
  *
  */
@@ -69,6 +69,7 @@
 #include "include/btmem.h"
 #include "include/tcs.h"
 #include "include/sec_client.h"
+#include "include/local.h"
 #endif
 
 /****************** CONSTANT AND MACRO SECTION ******************************/
@@ -85,10 +86,10 @@
 					      (((x2)&1)<<1) + ((x1)&1))
 
 
-#define MAKE_ACL_HDR(hci_hdl,pb,bc,len) (((len & 0xffff) << 16) + \
+#define MAKE_ACL_HDR(hci_hdl,pb,bc,len) (cpu_to_le32(((len & 0xffff) << 16) + \
 					 ((bc & 0x3) << 14) + \
 					 ((pb & 0x3) << 12) + \
-					 (hci_hdl & 0xfff))
+					 (hci_hdl & 0xfff)))
 
 #define ACL_LINK 1
 #define SCO_LINK 0
@@ -1791,7 +1792,8 @@
 	c_pkt.type = CMD_PKT;
 	c_pkt.opcode = hci_put_opcode(DISCONNECT, HCI_LC) ;
 
-	memcpy(c_pkt.data, &hdl, 2);
+	c_pkt.data[0] = hdl & 0xff;
+	c_pkt.data[1] = hdl >> 8;
 	c_pkt.data[2] = reason;
 	c_pkt.len = 3;
 
@@ -2529,11 +2531,13 @@
 	c_pkt.type = CMD_PKT;
 	c_pkt.opcode = hci_put_opcode(HOST_BUFFER_SIZE, HCI_HC) ;
   
-	memcpy(c_pkt.data + c, &acl_len, 2);
-	c_pkt.data[(c+= 2)] = sco_len;
-	memcpy(c_pkt.data + (c+= 1), & acl_num, 2);
-	memcpy(c_pkt.data + (c+= 2), & sco_num, 2);
-	c_pkt.len = (c+= 2);
+	c_pkt.data[c++] = acl_len & 0xff;
+	c_pkt.data[c++] = (acl_len >> 8) & 0xff;
+	c_pkt.data[c++] = sco_len;
+	c_pkt.data[c++] = acl_num & 0xff;
+	c_pkt.data[c++] = (acl_num >> 8) & 0xff;
+	c_pkt.data[c++] = sco_num & 0xff;
+	c_pkt.data[c++] = (sco_num >> 8) & 0xff;
 
 	return send_cmd_block((u8*) &c_pkt, c + CMD_HDR_LEN + HCI_HDR_LEN);
 #else
Only in ../cvs_patch/linux/drivers/char/bluetooth: hci.c~
diff -u -r ./linux/drivers/char/bluetooth/l2cap.c ../cvs_patch/linux/drivers/char/bluetooth/l2cap.c
--- ./linux/drivers/char/bluetooth/l2cap.c	Mon Mar  5 17:41:45 2001
+++ ../cvs_patch/linux/drivers/char/bluetooth/l2cap.c	Mon Mar 12 13:57:40 2001
@@ -70,6 +70,7 @@
 #include "include/sdp.h"
 #include "include/test.h"
 #include "include/btmem.h"
+#include "include/local.h"
 #endif
 
 /****************** DEBUG CONSTANT AND MACRO SECTION ************************/
@@ -507,8 +508,10 @@
                    /*u8 bc_flag,*/ u32 *l2cap_len)
 {
 #define FNC "l2cap_receive_data : "
-	l2cap_packet *pkt;
+	l2cap_packet *pkt = NULL;
 	l2cap_con *con;
+	u16 pkt_len;
+	CID pkt_cid;
 
 	D_RCV(FNC" got %d bytes on hci_handle : %d\n", len, hci_handle);
 	PRINTPKT("l2cap_receive_data : ", data, len);
@@ -524,14 +527,17 @@
 
 		pkt = (l2cap_packet *)data;
 
+		pkt_len = le16_to_cpu(pkt->len);
+		pkt_cid = le16_to_cpu(pkt->cid);
+
 		/* l2cap_len is checked in hci, when l2cap_len bytes 
 		   has been received in hci this function is called again */
-		*l2cap_len = pkt->len + L2CAP_HDRSIZE;
+		*l2cap_len = pkt_len + L2CAP_HDRSIZE;
     
-		D_RCV(FNC"New frame len:%d cid:%d\n", pkt->len, pkt->cid);
+		D_RCV(FNC"New frame len:%d cid:%d\n", pkt_len, pkt_cid);
 
 		/* check length */
-		if (!(pkt->len == (len - L2CAP_HDRSIZE)))
+		if (!(pkt_len == (len - L2CAP_HDRSIZE)))
 			return;
 	} else if (len != *l2cap_len) {
 		/* Not recieved full frame yet or BIG packet */
@@ -545,8 +551,10 @@
 
 	/* A whole frame is received */
 	pkt = (l2cap_packet *)data;
+	pkt_len = le16_to_cpu(pkt->len);
+	pkt_cid = le16_to_cpu(pkt->cid);
 
-	switch (pkt->cid) {
+	switch (pkt_cid) {
 	case CIDSIG:
 		/* Signalling channel */
 		D_RCV("l2cap_receive_data : Signal data !\n");
@@ -568,18 +576,18 @@
 		con = get_con_hcihdl(hci_handle);
 		
 		get_upper(CHAR2INT16(pkt->data[1], pkt->data[0]))->
-			receive_data(con, pkt->data + 2, pkt->len - 2);
+			receive_data(con, pkt->data + 2, pkt_len - 2);
 		break;
     
 	default:
 		/* Data channel */
-		con = get_lcon(pkt->cid);
+		con = get_lcon(pkt_cid);
     
 		if (con == NULL)
 			return;
 
 		if (con->current_state == OPEN ) {      
-			process_frame(con, pkt->data, pkt->len);
+			process_frame(con, pkt->data, pkt_len);
 		} else {
 			D_ERR("l2cap_receive_data : not OPEN yet, discard data\n");
 		}
@@ -603,6 +611,8 @@
 
 	cmd = (struct sig_cmd *)(data + pos);
   
+	cmd->len = le16_to_cpu(cmd->len);
+
 	D_RCV(FNC"received %d bytes\n", len);
 	PRINTPKT(FNC"data", data, len);
 
@@ -630,6 +640,7 @@
 		/* parse next command header if more cmds left in packet */
 		if (pos < len){
 			cmd = (struct sig_cmd *)(data + pos);
+			cmd->len = le16_to_cpu(cmd->len);
 			printk("pos %d, len %d\n", pos, len);
 			DSYS("another command in same packet...(%d bytes)\n",
 			     cmd->len);
@@ -656,6 +667,8 @@
 	case SIG_CONREQ:
                 /* Request for connection */
 		conreq = (sig_conreq *)req->data;
+		conreq->psm = le16_to_cpu(conreq->psm);
+		conreq->src_cid = le16_to_cpu(conreq->src_cid);
 		
 		D_STATE(FNC"Connection request\n");
 		D_STATE(FNC"id:%d len:%d PSM 0x%x src_cid:%d\n",
@@ -712,6 +725,8 @@
 	case SIG_CONFREQ:
                 /* Request for configuration */
 		confreq = (sig_confreq *)req->data;
+		confreq->dst_cid = le16_to_cpu(confreq->dst_cid);
+		confreq->flags = le16_to_cpu(confreq->flags);
 		
 		D_STATE(FNC"config request cid:%d flags: 0x%x\n", 
 			confreq->dst_cid, confreq->flags);
@@ -809,6 +824,8 @@
 			
 	case SIG_DISCREQ:
 		discreq = (sig_discreq *)req->data;
+		discreq->dst_cid = le16_to_cpu(discreq->dst_cid);
+		discreq->src_cid = le16_to_cpu(discreq->src_cid);
 
 		D_STATE(FNC"disconnection request id %d\n", 
 			req->id);
@@ -853,6 +870,7 @@
 		D_STATE(FNC"info request\n");
 		
 		info = (sig_info_req*)(req->data);
+		info->type = le16_to_cpu(info->type);
 		
 		switch(info->type) {
 		case INFO_CONNLESS_MTU:
@@ -909,6 +927,7 @@
 		D_STATE(FNC"Command reject - \n");
          
 		cmdreject = (sig_cmdreject*)rsp->data;
+		cmdreject->reason = le16_to_cpu(cmdreject->reason);
 		opt_len = rsp->len - sizeof(sig_cmdreject);
 		switch (cmdreject->reason) {
 		case 0:
@@ -937,6 +956,10 @@
 		/* client */
 		D_STATE(FNC"Got connection response\n");
 		conrsp = (sig_conrsp *)rsp->data;
+		conrsp->src_cid = le16_to_cpu(conrsp->src_cid);
+		conrsp->dst_cid = le16_to_cpu(conrsp->dst_cid);
+		conrsp->result  = le16_to_cpu(conrsp->result);
+		conrsp->status  = le16_to_cpu(conrsp->status);
 
 		/* find connection */
 		if ((con = get_lcon(conrsp->src_cid)) == NULL) {
@@ -1017,6 +1040,9 @@
 	case SIG_CONFRSP:
 		D_STATE(FNC"Got configuration response\n");
 		confrsp = (sig_confrsp *)rsp->data;
+		confrsp->src_cid = le16_to_cpu(confrsp->src_cid);
+		confrsp->flags = le16_to_cpu(confrsp->flags);
+		confrsp->result = le16_to_cpu(confrsp->result);
 		opt_len = rsp->len - sizeof(sig_confrsp);
 
 		PRINTPKT(FNC"config response", rsp->data, rsp->len);
@@ -1109,6 +1135,8 @@
 	case SIG_DISCRSP:
 		D_STATE(FNC"Got disconnect response\n");
 		discrsp = (sig_discrsp *)rsp->data;
+		discrsp->dst_cid = le16_to_cpu(discrsp->dst_cid);
+		discrsp->src_cid = le16_to_cpu(discrsp->src_cid);
 		PRINTPKT(FNC"disconnect response", rsp->data, rsp->len);
 
 		/* find connection */
@@ -1167,6 +1195,8 @@
        
 	case SIG_INFORSP:
 		info = (sig_info_rsp *)(rsp->data);
+		info->type = le16_to_cpu(info->type);
+		info->result = le16_to_cpu(info->result);
 		D_STATE(FNC"Got info response : result %d\n", info->result);
 		break;
        
@@ -1795,7 +1825,7 @@
 	l2cap_tx_buf *l2cap_buf;  /* Entire l2cap frame + lower layer hdrs */
 	sig_cmd *cmd;
 	sig_conreq *req;
-	s32 payload_len;
+	u16 payload_len;
 
         D_XMIT("l2cap_connect_req: Connecting %s (rcid:%d)\n",psm2str(psm), 
                con->remote_cid);
@@ -1805,7 +1835,7 @@
 		return -1;
 	}
 
-	payload_len = SIGCMD_HDRSIZE + CON_REQSIZE;  
+	payload_len = SIGCMD_HDRSIZE + CON_REQSIZE;  /*2 x 4*/
 
 	tx = subscribe_bt_buf(sizeof(l2cap_tx_buf) + L2CAP_HDRSIZE+payload_len);
 	if (!tx) {
@@ -1819,12 +1849,12 @@
 	req = (sig_conreq*)(l2cap_buf->frame + L2CAP_HDRSIZE + SIGCMD_HDRSIZE);
 
 	/* Now fill in header fields */  
-	req->psm = con->psm;
-	req->src_cid = con->local_cid;
+	req->psm = cpu_to_le16(con->psm);
+	req->src_cid = cpu_to_le16(con->local_cid);
   
 	cmd->code = SIG_CONREQ;
 	cmd->id = set_id(con); /* Sets sig_id_sent in l2cap_con */
-	cmd->len = CON_REQSIZE;
+	cmd->len = cpu_to_le16(CON_REQSIZE);
 
 	SET_L2CAP_HDR(l2cap_buf->frame, payload_len, CIDSIG);
 
@@ -1850,7 +1880,7 @@
 	l2cap_tx_buf *l2cap_buf;  /* Entire l2cap frame + lower layer hdrs */
 	sig_cmd *cmd;
 	sig_confreq *req;
-	s32 payload_len;
+	u16 payload_len;
 	s32 opt_len=0;
 	struct l2cap_option *opt;
 
@@ -1935,13 +1965,13 @@
 	}
 
 	/* Request header */
-	req->dst_cid = con->remote_cid; /* Sending end */
+	req->dst_cid = cpu_to_le16(con->remote_cid); /* Sending end */
 	req->flags = 0; /* Negotiate same as remote */
 
 	/* Signalling header */
 	cmd->code = SIG_CONFREQ;
 	cmd->id = set_id(con); /* Sets sig_id_sent in l2cap_con */
-	cmd->len = CONF_REQSIZE + opt_len;
+	cmd->len = cpu_to_le16(CONF_REQSIZE + opt_len);
 
 	SET_L2CAP_HDR(l2cap_buf->frame, payload_len, CIDSIG);
 
@@ -1969,7 +1999,7 @@
 	l2cap_tx_buf *l2cap_buf;  /* Entire l2cap frame + lower layer hdrs */
 	sig_cmd *cmd;
 	sig_discreq *req;
-	s32 payload_len;
+	u16 payload_len;
  
 	D_XMIT("l2cap_disconnect_req : rcid %d\n", con->remote_cid);
 
@@ -1987,12 +2017,12 @@
 	req = (sig_discreq*)(l2cap_buf->frame + L2CAP_HDRSIZE + SIGCMD_HDRSIZE);
 
 	/* Now fill in header fields */  
-	req->dst_cid = con->remote_cid;
-	req->src_cid = con->local_cid;
-  
+	req->dst_cid = cpu_to_le16(con->remote_cid);
+	req->src_cid = cpu_to_le16(con->local_cid);
+
 	cmd->code = SIG_DISCREQ;
 	cmd->id = set_id(con); /* Sets sig_id_sent in l2cap_con */
-	cmd->len = DISC_REQSIZE;
+	cmd->len = cpu_to_le16(DISC_REQSIZE);
 
 	SET_L2CAP_HDR(l2cap_buf->frame, payload_len, CIDSIG);
 	tx->hci_hdl = con->hci_hdl;
@@ -2013,7 +2043,7 @@
 	l2cap_tx_buf *l2cap_buf;  /* Entire l2cap frame + lower layer hdrs */
 	sig_cmd *cmd;
 	sig_echo_pkt *req;
-	s32 payload_len;
+	u16 payload_len;
 	u16 hci_hdl = con->hci_hdl;
 
 	payload_len = SIGCMD_HDRSIZE + sizeof(sig_echo_pkt) + opt_len;
@@ -2037,7 +2067,7 @@
 	cmd->code = SIG_ECHOREQ;
 	cmd->id = get_id();
   
-	cmd->len = opt_len;
+	cmd->len = cpu_to_le16(opt_len);
 
 	SET_L2CAP_HDR(l2cap_buf->frame, payload_len, CIDSIG);
 
@@ -2059,7 +2089,7 @@
 	l2cap_tx_buf *l2cap_buf;  /* Entire l2cap frame + lower layer hdrs */
 	sig_cmd *cmd;
 	sig_echo_pkt *rsp;
-	s32 payload_len;
+	u16 payload_len;
 
 	D_XMIT("l2cap_echo_rsp\n");
 
@@ -2082,7 +2112,7 @@
   
 	cmd->code = SIG_ECHORSP;
 	cmd->id = id;
-	cmd->len = opt_len;
+	cmd->len = cpu_to_le16(opt_len);
 
 	SET_L2CAP_HDR(l2cap_buf->frame, payload_len, CIDSIG);
 
@@ -2118,11 +2148,11 @@
   
 	cmd = (sig_cmd*)(l2cap_buf->frame + L2CAP_HDRSIZE);
 	req = (sig_info_req*)(l2cap_buf->frame + L2CAP_HDRSIZE +SIGCMD_HDRSIZE);
-	req->type = info_type;
+	req->type = cpu_to_le16(info_type);
     
 	cmd->code = SIG_INFOREQ;
 	cmd->id = get_id();
-	cmd->len = sizeof(sig_info_req);
+	cmd->len = cpu_to_le16(sizeof(sig_info_req));
 
 	SET_L2CAP_HDR(l2cap_buf->frame, payload_len, CIDSIG);
 
@@ -2162,8 +2192,8 @@
 	cmd = (sig_cmd*)(l2cap_buf->frame + L2CAP_HDRSIZE);
 	rsp = (sig_info_rsp*)(l2cap_buf->frame + L2CAP_HDRSIZE +SIGCMD_HDRSIZE);
 
-	rsp->type = info_type;
-	rsp->result = result;	
+	rsp->type = cpu_to_le16(info_type);
+	rsp->result = cpu_to_le16(result);	
 
 	/* Now fill in header fields */
 	if (info_len) {
@@ -2172,7 +2202,7 @@
 
 	cmd->code = SIG_INFORSP;
 	cmd->id = id;
-	cmd->len = sizeof(sig_info_rsp) + info_len;
+	cmd->len = cpu_to_le16(sizeof(sig_info_rsp) + info_len);
 
 	SET_L2CAP_HDR(l2cap_buf->frame, payload_len, CIDSIG);
 
@@ -2191,7 +2221,7 @@
 	l2cap_tx_buf *l2cap_buf;  /* Entire l2cap frame + lower layer hdrs */
 	sig_cmd *cmd;
 	sig_cmdreject *cmdrej;
-	s32 payload_len;
+	u16 payload_len;
 
 	payload_len = SIGCMD_HDRSIZE + sizeof(sig_cmdreject) + opt_len;
 
@@ -2215,10 +2245,11 @@
   
 	cmd->code = SIG_CMDREJECT;
 	cmd->id = get_id();
-	cmd->len = sizeof(sig_cmdreject) + opt_len;
+	cmd->len = cpu_to_le16(sizeof(sig_cmdreject) + opt_len);
 
 	/* FIXME: set the reason parameter */
-
+	/* Ok. Does this work? (gjm) */
+	cmdrej->reason = cpu_to_le16((u16)reason);
 	SET_L2CAP_HDR(l2cap_buf->frame, payload_len, CIDSIG);
 
 	/* pb_flag is set from hci_send_data */
@@ -2240,7 +2271,7 @@
 	l2cap_tx_buf *l2cap_buf;  /* Entire l2cap frame + lower layer hdrs */
 	sig_cmd *cmd;
 	sig_conrsp *rsp;
-	s32 payload_len;
+	u16 payload_len;
   
 	D_XMIT("l2cap_connect_rsp : rcid:%d lcid:%d result:%d status:%d \n",
 	       con->remote_cid, con->local_cid, response, status);
@@ -2259,19 +2290,19 @@
 	rsp = (sig_conrsp*)(l2cap_buf->frame + L2CAP_HDRSIZE + SIGCMD_HDRSIZE);
   
 	/* Now fill in header fields */
-	rsp->dst_cid = con->local_cid; /* sending end */
-	rsp->src_cid = con->remote_cid; /* receiving end */
+	rsp->dst_cid = cpu_to_le16(con->local_cid); /* sending end */
+	rsp->src_cid = cpu_to_le16(con->remote_cid); /* receiving end */
 
-	if ((rsp->result = response) == RES_PENDING)
-		rsp->status = status;
+	if ((rsp->result = cpu_to_le16(response)) == RES_PENDING)
+		rsp->status = cpu_to_le16(status);
 	else {
 		printk("Result not pending, force status = no further info\n");
-		rsp->status = STAT_NOINFO;
+		rsp->status = cpu_to_le16(STAT_NOINFO);
 	}
 	
 	cmd->code = SIG_CONRSP;
 	cmd->id = con->sig_id_rcv; /* Send back same id as received on req */
-	cmd->len = CON_RSPSIZE;
+	cmd->len = cpu_to_le16(CON_RSPSIZE);
 
 	SET_L2CAP_HDR(l2cap_buf->frame, payload_len, CIDSIG);
 
@@ -2290,7 +2321,7 @@
 	l2cap_tx_buf *l2cap_buf;  /* Entire l2cap frame + lower layer hdrs */
 	sig_cmd *cmd;
 	sig_confrsp *rsp;
-	s32 payload_len;
+	u16 payload_len;
 
 	D_XMIT("l2cap_config_rsp : rcid : %d, out_mtu: %d \n", 
 	       con->remote_cid, out_mtu);
@@ -2315,16 +2346,16 @@
 	rsp = (sig_confrsp*)(l2cap_buf->frame + L2CAP_HDRSIZE + SIGCMD_HDRSIZE);
   
 	/* Now fill in header fields */  
-	rsp->src_cid = con->remote_cid;
+	rsp->src_cid = cpu_to_le16(con->remote_cid);
 
 	/* FIXME - WHERE ARE THIS DETERMINED ??? */
 	rsp->flags = 0; /* No more config responses to follow */
 
-	rsp->result = CONF_SUCCESS;
+	rsp->result = cpu_to_le16(CONF_SUCCESS);
   
 	cmd->code = SIG_CONFRSP;
 	cmd->id = con->sig_id_rcv; /* Send back same id as received on request */
-	cmd->len = CONF_RSPSIZE;
+	cmd->len = cpu_to_le16(CONF_RSPSIZE);
 
 
 	SET_L2CAP_HDR(l2cap_buf->frame, payload_len, CIDSIG);
@@ -2345,7 +2376,7 @@
 	l2cap_tx_buf *l2cap_buf;  /* Entire l2cap frame + lower layer hdrs */
 	sig_cmd *cmd;
 	sig_discrsp *rsp;
-	s32 payload_len;
+	u16 payload_len;
  
 	payload_len = SIGCMD_HDRSIZE + sizeof(sig_discrsp);
 
@@ -2362,12 +2393,12 @@
 	rsp = (sig_discrsp*)(l2cap_buf->frame + L2CAP_HDRSIZE + SIGCMD_HDRSIZE);
     
 	/* Now fill in header fields */
-	rsp->dst_cid = con->local_cid;
-	rsp->src_cid = con->remote_cid;
+	rsp->dst_cid = cpu_to_le16(con->local_cid);
+	rsp->src_cid = cpu_to_le16(con->remote_cid);
   
 	cmd->code = SIG_DISCRSP;
 	cmd->id = con->sig_id_rcv; /* Send back same id as received on req */
-	cmd->len = sizeof(sig_discrsp);
+	cmd->len = cpu_to_le16(sizeof(sig_discrsp));
 
 	SET_L2CAP_HDR(l2cap_buf->frame, payload_len, CIDSIG);
 
@@ -2895,7 +2926,8 @@
 		opt = (l2cap_option*)(data + pos);
 		switch (opt->type) {
 		case OPT_MTU:
-			con->remote_mtu = *((u16*)opt->option_data);
+			con->remote_mtu = *(opt->option_data) | 
+				(*(opt->option_data + 1) << 8);
 
 			if ((con->remote_mtu < MTU_MIN) && 
 			    ((con->remote_mtu + L2CAP_HDRSIZE) > HCI_IN_SIZE)) {
@@ -2915,7 +2947,8 @@
 			break;
       
 		case OPT_FLUSH:
-			con->flush_timeout = *((u16*)opt->option_data);
+			con->flush_timeout = *(opt->option_data) | 
+				(*(opt->option_data + 1) << 8);
 
 			/* FIXME -- return error code if not accepted */
 			
Only in ../cvs_patch/linux/drivers/char/bluetooth: l2cap.c~
diff -u -r ./linux/drivers/char/bluetooth/rfcomm.c ../cvs_patch/linux/drivers/char/bluetooth/rfcomm.c
--- ./linux/drivers/char/bluetooth/rfcomm.c	Thu Mar  8 16:22:45 2001
+++ ../cvs_patch/linux/drivers/char/bluetooth/rfcomm.c	Mon Mar 12 13:58:29 2001
@@ -65,6 +65,7 @@
 #include "include/btmem.h"
 #include "include/l2cap.h"
 #include "include/bluetooth.h"
+#include "include/local.h"
 #endif
 
 /****************** DEBUG CONSTANT AND MACRO SECTION ************************/
@@ -162,29 +163,6 @@
 #define swap_long_frame(x) ((x)->h.length.val = le16_to_cpu((x)->h.length.val))
 #define swap_mcc_long_frame(x) (swap_long_frame(x))
 #define swap_pn_msg(x) ((x)->frame_size = le16_to_cpu((x)->frame_size))
-
-#ifdef BTD_USERSTACK
-
-#  include <asm/byteorder.h>
-#  ifdef __LITTLE_ENDIAN
-#    define cpu_to_le16(x) (x)
-#    define cpu_to_le32(x) (x)
-#    define cpu_to_be16(x) htons((x))
-#    define cpu_to_be32(x) htonl((x))
-#  else
-#    define cpu_to_be16(x) (x)
-#    define cpu_to_be32(x) (x)
-     extern inline __u16 cpu_to_le16(__u16 x) { return (x<<8) | (x>>8);}
-     extern inline __u32 cpu_to_le32(__u32 x) { return((x>>24) |
-             ((x>>8)&0xff00) | ((x<<8)&0xff0000) | (x<<24));}
-#  endif
-
-#  define le16_to_cpu(x)  cpu_to_le16(x)
-#  define le32_to_cpu(x)  cpu_to_le32(x)
-#  define be16_to_cpu(x)  cpu_to_be16(x)
-#  define be32_to_cpu(x)  cpu_to_be32(x)
-
-#endif
 
 /****************** TYPE DEFINITION SECTION *********************************/
 
Only in ../cvs_patch/linux/drivers/char/bluetooth: rfcomm.c~
diff -u -r ./linux/include/CVS/Entries ../cvs_patch/linux/include/CVS/Entries
--- ./linux/include/CVS/Entries	Mon Mar 12 15:18:48 2001
+++ ../cvs_patch/linux/include/CVS/Entries	Mon Mar 12 12:26:34 2001
@@ -1 +1 @@
-D/linux////
+D
Only in ../cvs_patch/linux/include/CVS: Entries.Log
diff -u -r ./linux/include/linux/CVS/Entries ../cvs_patch/linux/include/linux/CVS/Entries
--- ./linux/include/linux/CVS/Entries	Mon Mar 12 15:18:48 2001
+++ ../cvs_patch/linux/include/linux/CVS/Entries	Mon Mar 12 12:26:34 2001
@@ -1 +1 @@
-D/bluetooth////
+D
Only in ../cvs_patch/linux/include/linux/CVS: Entries.Log
diff -u -r ./linux/include/linux/bluetooth/hci.h ../cvs_patch/linux/include/linux/bluetooth/hci.h
--- ./linux/include/linux/bluetooth/hci.h	Fri Mar  2 11:55:03 2001
+++ ../cvs_patch/linux/include/linux/bluetooth/hci.h	Mon Mar 12 14:19:51 2001
@@ -75,11 +75,10 @@
   u8 data[256];
 } __attribute__ ((packed)) cmd_pkt;
 
-#define hci_put_opcode(ocf, ogf)(((ocf) & 0x03ff) | ((ogf) << 10 & 0xfc00))
-#define hci_put_le16(buf, val) { *((char*)buf) = (val) & 0xff; *((char*)buf + 1) = (val) >> 8; }
-#define hci_get_ocf(opcode) ((opcode) & 0x3ff)
-#define hci_get_ogf(opcode) (((opcode) & 0xfc00) >> 10)                        
-
+#define hci_put_opcode(ocf, ogf)(cpu_to_le16(((ocf) & 0x03ff) | ((ogf) << 10 & 0xfc00)))
+//#define hci_put_le16(buf, val) { *((char*)buf) = (val) & 0xff; *((char*)buf + 1) = (val) >> 8; }
+#define hci_get_ocf(opcode) (cpu_to_le16((opcode) & 0x3ff))
+#define hci_get_ogf(opcode) (cpu_to_le16(((opcode) & 0xfc00) >> 10))
 
 /****************** EXPORTED FUNCTION DECLARATION SECTION *******************/
 
Only in ../cvs_patch/linux/include/linux/bluetooth: hci.h~
diff -u -r ./linux/include/linux/bluetooth/local.h ../cvs_patch/linux/include/linux/bluetooth/local.h
--- ./linux/include/linux/bluetooth/local.h	Thu Feb 15 17:28:47 2001
+++ ../cvs_patch/linux/include/linux/bluetooth/local.h	Mon Mar 12 15:29:10 2001
@@ -46,6 +46,43 @@
 
 /****************** CONSTANT AND MACRO SECTION ******************************/
 
+#include <asm/byteorder.h>
+/* In kernel mode either __LITTLE_ENDIAN or __BIG_ENDIAN is defined, but in user usermode
+ * both are defined. In usermode __BYTE_ORDER contains the correct endianess. So let's undefine
+ * one of them.
+ * __LITTLE_ENDIAN_BITTFIELD and __BIG_ENDIAN_BITFIELD do not cause such problems.
+ */
+#ifndef __KERNEL__
+# if (__BYTE_ORDER == __LITTLE_ENDIAN)
+#  undef __BIG_ENDIAN
+# endif
+# if (__BYTE_ORDER == __BIG_ENDIAN)
+#  undef __LITTLE_ENDIAN
+# endif
+#endif
+ 
+#ifdef BTD_USERSTACK
+ 
+#  ifdef __LITTLE_ENDIAN
+#    define cpu_to_le16(x) (x)
+#    define cpu_to_le32(x) (x)
+#    define cpu_to_be16(x) htons((x))
+#    define cpu_to_be32(x) htonl((x))
+#  else
+#    define cpu_to_be16(x) (x)
+#    define cpu_to_be32(x) (x)
+     extern inline __u16 cpu_to_le16(__u16 x) { return (x<<8) | (x>>8);}
+     extern inline __u32 cpu_to_le32(__u32 x) { return((x>>24) |
+             ((x>>8)&0xff00) | ((x<<8)&0xff0000) | (x<<24));}
+#  endif
+ 
+#  define le16_to_cpu(x)  cpu_to_le16(x)
+#  define le32_to_cpu(x)  cpu_to_le32(x)
+#  define be16_to_cpu(x)  cpu_to_be16(x)
+#  define be32_to_cpu(x)  cpu_to_be32(x)
+ 
+#endif
+
 /****************** TYPE DEFINITION SECTION *********************************/
 
 typedef short           s16;