Hi,
I spent 3 hours to get irda12 in the same state as I was
having irda10. For a starter, irda12 didn't even compile, so I won't
be talking of regression testing and all this useless QA
stuff. Basically, everything was broken...
What really bug me is that half the fixes is things that I
already sent to Dag, and for a few of them it's only the third time
that I'm sending them. So, I wonder why I'm fixing Dag's bugs...
So now, with this patch which apply to 2.2.13-irda12 (as I
downloaded this morning - 254373 bytes), all kind of sockets are
working (STREAM, SEQPACKET, DGRAM, ULTRA). It's tested. IrLAN and
IrComm do work as well. It's tested.
Ok, listen Dag : if the next release of irda doesn't compile
out of the box and if not all the patch included here are in the next
version, I keep my own and forget about yours. I don't need your bugs,
my stuff is working better than yours...
Jean
diff -u -p linux/include/linux/irda.d2.h linux/include/linux/irda.h
--- linux/include/linux/irda.d2.h Thu Dec 9 05:45:46 1999
+++ linux/include/linux/irda.h Thu Dec 9 05:45:26 1999
@@ -25,6 +25,8 @@
*
********************************************************************/
+#include <linux/types.h> /* for __u8, __u32 & ... */
+
#ifndef KERNEL_IRDA_H
#define KERNEL_IRDA_H
@@ -72,11 +74,11 @@ typedef enum {
} IRDA_DONGLE;
/* Protocol types to be used for SOCK_DGRAM */
-enum {
+typedef enum {
IRDAPROTO_UNITDATA = 0,
IRDAPROTO_ULTRA = 1,
IRDAPROTO_MAX
-};
+} IRDA_DGRAM_PROTOCOLS;
#define SOL_IRLMP 266 /* Same as SOL_IRDA for now */
#define SOL_IRTTP 266 /* Same as SOL_IRDA for now */
@@ -84,7 +86,7 @@ enum {
#define IRLMP_ENUMDEVICES 1
#define IRLMP_IAS_SET 2
#define IRLMP_IAS_QUERY 3
-#define IRLMP_HINTS_SET 4
+#define IRLMP_HINTS_SET 4
#define IRTTP_QOS_SET 5
#define IRTTP_QOS_GET 6
@@ -99,21 +101,21 @@ enum {
struct sockaddr_irda {
sa_family_t sir_family; /* AF_IRDA */
- u_int8_t sir_lsap_sel; /* LSAP selector */
- u_int32_t sir_addr; /* Device address */
+ __u8 sir_lsap_sel; /* LSAP selector */
+ __u32 sir_addr; /* Device address */
char sir_name[25]; /* Usually <service>:IrDA:TinyTP */
};
struct irda_device_info {
- u_int32_t saddr; /* Address of local interface */
- u_int32_t daddr; /* Address of remote device */
+ __u32 saddr; /* Address of local interface */
+ __u32 daddr; /* Address of remote device */
char info[22]; /* Description */
- u_int8_t charset; /* Charset used for description */
- u_int8_t hints[2]; /* Hint bits */
+ __u8 charset; /* Charset used for description */
+ __u8 hints[2]; /* Hint bits */
};
struct irda_device_list {
- u_int32_t len;
+ __u32 len;
struct irda_device_info dev[1];
};
diff -u -p linux/include/net/irda/irlap_frame.d2.h linux/include/net/irda/irlap_frame.h
--- linux/include/net/irda/irlap_frame.d2.h Thu Dec 9 04:32:51 1999
+++ linux/include/net/irda/irlap_frame.h Thu Dec 9 05:46:05 1999
@@ -116,8 +116,6 @@ void irlap_send_snrm_frame(struct irlap_
void irlap_send_test_frame(struct irlap_cb *self, __u32 daddr,
struct sk_buff *cmd);
void irlap_send_ua_response_frame(struct irlap_cb *, struct qos_info *);
-void irlap_send_ui_frame(struct irlap_cb *self, struct sk_buff *skb,
- int command);
void irlap_send_dm_frame(struct irlap_cb *);
void irlap_send_disc_frame(struct irlap_cb *);
void irlap_send_rr_frame(struct irlap_cb *, int command);
@@ -129,7 +127,8 @@ void irlap_send_data_secondary_final(str
void irlap_resend_rejected_frames(struct irlap_cb *, int command);
void irlap_send_i_frame(struct irlap_cb *, struct sk_buff *, int command);
-void irlap_send_ui_frame(struct irlap_cb *, struct sk_buff *, int command);
+void irlap_send_ui_frame(struct irlap_cb *self, struct sk_buff *skb,
+ __u8 caddr, int command);
extern int irlap_insert_qos_negotiation_params(struct irlap_cb *self,
struct sk_buff *skb);
diff -u -p linux/net/irda/af_irda.d2.c linux/net/irda/af_irda.c
--- linux/net/irda/af_irda.d2.c Thu Dec 9 04:25:53 1999
+++ linux/net/irda/af_irda.c Thu Dec 9 09:26:47 1999
@@ -570,6 +570,10 @@ static int irda_bind(struct socket *sock
/* Special care for Ultra sockets */
if ((sk->type == SOCK_DGRAM) && (sk->protocol == IRDAPROTO_ULTRA)) {
self->pid = addr->sir_lsap_sel;
+ if (self->pid & 0x80) {
+ IRDA_DEBUG(0, __FUNCTION__ "(), extension in PID not supp!\n");
+ return - 1;
+ }
err = irda_open_lsap(self, self->pid);
if (err < 0)
@@ -1047,6 +1051,9 @@ static int irda_recvmsg_dgram(struct soc
copied = skb->len;
if (copied > size) {
+ IRDA_DEBUG(2, __FUNCTION__
+ "(), Received truncated frame (%d < %d)!\n",
+ copied, size);
copied = size;
msg->msg_flags |= MSG_TRUNC;
}
diff -u -p linux/net/irda/irlap_frame.d2.c linux/net/irda/irlap_frame.c
--- linux/net/irda/irlap_frame.d2.c Thu Dec 9 08:23:01 1999
+++ linux/net/irda/irlap_frame.c Thu Dec 9 08:28:48 1999
@@ -1001,7 +1001,7 @@ void irlap_send_ui_frame(struct irlap_cb
frame = skb->data;
/* Insert connection address */
- frame[0] = caddr | (command) ? CMD_FRAME : 0;
+ frame[0] = caddr | ((command) ? CMD_FRAME : 0);
irlap_queue_xmit(self, skb);
}
diff -u -p linux/net/irda/irlmp.d2.c linux/net/irda/irlmp.c
--- linux/net/irda/irlmp.d2.c Thu Dec 9 09:02:41 1999
+++ linux/net/irda/irlmp.c Thu Dec 9 09:27:41 1999
@@ -147,8 +147,11 @@ struct lsap_cb *irlmp_open_lsap(__u8 sls
slsap_sel = irlmp_find_free_slsap();
if (!slsap_sel)
return NULL;
- } else if (irlmp_slsap_inuse(slsap_sel))
+ } else if (irlmp_slsap_inuse(slsap_sel)) {
+ IRDA_DEBUG(1, __FUNCTION__
+ "(), lsap already in use!\n");
return NULL;
+ }
/* Allocate new instance of a LSAP connection */
self = kmalloc(sizeof(struct lsap_cb), GFP_ATOMIC);
@@ -976,11 +979,12 @@ int irlmp_connless_data_request(struct l
ASSERT(skb_headroom(skb) >= LMP_HEADER+LMP_PID_HEADER, return -1;);
skb_push(skb, LMP_HEADER+LMP_PID_HEADER);
- /* Insert protocol identifier */
- skb->data[0] = self->pid;
-
/* Connectionless sockets must use 0x70 */
- skb->data[1] = skb->data[2] = LSAP_CONNLESS;
+ skb->data[0] = skb->data[1] = LSAP_CONNLESS;
+
+ /* Insert protocol identifier */
+printk("pid = 0x%X\n", self->pid);
+ skb->data[2] = self->pid;
/* Try to send Connectionless packets out on all links */
lap = (struct lap_cb *) hashbin_get_first(irlmp->links);
diff -u -p linux/net/irda/irlmp_frame.d2.c linux/net/irda/irlmp_frame.c
--- linux/net/irda/irlmp_frame.d2.c Thu Dec 9 04:28:03 1999
+++ linux/net/irda/irlmp_frame.c Thu Dec 9 09:09:42 1999
@@ -176,7 +176,7 @@ void irlmp_link_data_indication(struct l
} else if (unreliable) {
/* Optimize and bypass the state machine if possible */
if (lsap->lsap_state == LSAP_DATA_TRANSFER_READY)
- irlmp_data_indication(lsap, skb);
+ irlmp_udata_indication(lsap, skb);
else
irlmp_do_lsap_event(lsap, LM_UDATA_INDICATION, skb);
} else {
@@ -221,12 +221,14 @@ void irlmp_link_unitdata_indication(stru
if (pid & 0x80) {
IRDA_DEBUG(0, __FUNCTION__ "(), extension in PID not supp!\n");
dev_kfree_skb(skb);
+ return;
}
/* Check if frame is addressed to the connectionless LSAP */
if ((slsap_sel != LSAP_CONNLESS) || (dlsap_sel != LSAP_CONNLESS)) {
IRDA_DEBUG(0, __FUNCTION__ "(), dropping frame!\n");
dev_kfree_skb(skb);
+ return;
}
/*
diff -u -p linux/net/irda/wrapper.d2.c linux/net/irda/wrapper.c
--- linux/net/irda/wrapper.d2.c Thu Dec 9 04:22:21 1999
+++ linux/net/irda/wrapper.c Thu Dec 9 08:49:48 1999
@@ -282,6 +282,8 @@ static void state_link_escape(struct dev
{
switch (byte) {
case BOF: /* New frame? */
+ IRDA_DEBUG(1, __FUNCTION__
+ "(), Discarding incomplete frame\n");
rx_buff->state = BEGIN_FRAME;
irda_device_set_media_busy(dev, TRUE);
break;
@@ -323,6 +325,8 @@ static void state_inside_frame(struct de
switch (byte) {
case BOF: /* New frame? */
+ IRDA_DEBUG(1, __FUNCTION__
+ "(), Discarding incomplete frame\n");
rx_buff->state = BEGIN_FRAME;
irda_device_set_media_busy(dev, TRUE);
break;
diff -u -p linux/net/irda/irlap_event.d2.c linux/net/irda/irlap_event.c
--- linux/net/irda/irlap_event.d2.c Thu Dec 9 04:29:46 1999
+++ linux/net/irda/irlap_event.c Thu Dec 9 06:25:09 1999
@@ -413,7 +413,7 @@ static int irlap_state_ndm(struct irlap_
skb = skb_dequeue(&self->txq_ultra);
if (skb)
irlap_send_ui_frame(self, skb, CBROADCAST,
- TRUE);
+ CMD_FRAME);
else
break;
}