Hi,
I guess that life would not be life without a few fixes to
irdadump, so this is the weekly patch ;-)
o Obex Packets larger than 256 were acting weird.
o More reply codes
The patch is additional to my previous patch of
irdadump. Actually, let's put both patches here ;-)
Have fun...
Jean
diff -u -p irda-utils-0.9.13/irdadump/src/netbuf.d1.h
irda-utils-0.9.13/irdadump/src/netbuf.h
--- irda-utils-0.9.13/irdadump/src/netbuf.d1.h Tue Dec 12 16:43:11 2000
+++ irda-utils-0.9.13/irdadump/src/netbuf.h Tue Dec 12 16:43:16 2000
@@ -65,7 +65,7 @@ void g_netbuf_set_size(GNetBuf *msg,
void g_netbuf_print(GNetBuf *msg);
static inline guint8 *g_netbuf_get_data(GNetBuf *msg) { return msg->data; }
-static inline guint8 g_netbuf_get_len(GNetBuf *msg) { return msg->len; }
+static inline guint g_netbuf_get_len(GNetBuf *msg) { return msg->len; }
#endif
diff -u -p irda-utils-0.9.13/irdadump/src/obex.d1.h
irda-utils-0.9.13/irdadump/src/obex.h
--- irda-utils-0.9.13/irdadump/src/obex.d1.h Tue Dec 12 16:41:41 2000
+++ irda-utils-0.9.13/irdadump/src/obex.h Tue Dec 12 16:35:39 2000
@@ -46,6 +46,7 @@
#define OBEX_SUCCESS 0x20
#define OBEX_CREATED 0x21
#define OBEX_ACCEPTED 0x22
+#define OBEX_BAD_REQUEST 0x40
#define OBEX_FORBIDDEN 0x43
#define OBEX_CONFLICT 0x49
#define OBEX_INTERNAL_SERVER_ERROR 0x50
diff -u -p irda-utils-0.9.13/irdadump/src/obex.d1.c
irda-utils-0.9.13/irdadump/src/obex.c
--- irda-utils-0.9.13/irdadump/src/obex.d1.c Tue Dec 12 16:41:49 2000
+++ irda-utils-0.9.13/irdadump/src/obex.c Tue Dec 12 16:38:34 2000
@@ -253,15 +253,15 @@ inline void parse_obex(struct lsap_state
guint8 opcode;
int len;
+ /* g_print(__FUNCTION__);fflush(stdout); */
+
+ g_string_append(str, "\n\tOBEX ");
+
/* Check for empty frames - Jean II */
len = g_netbuf_get_len(buf);
if(len == 0)
return;
- /* g_print(__FUNCTION__);fflush(stdout); */
-
- g_string_append(str, "\n\tOBEX ");
-
opcode = buf->data[0] & ~OBEX_FINAL; /* Remove final bit */
/* Check if it's a command or response frame - Jean II */
@@ -281,6 +281,9 @@ inline void parse_obex(struct lsap_state
break;
case OBEX_ACCEPTED:
g_string_append(str, "ACCEPTED ");
+ break;
+ case OBEX_BAD_REQUEST:
+ g_string_append(str, "BAD REQUEST ");
break;
case OBEX_FORBIDDEN:
g_string_append(str, "FORBIDDEN ");
diff -u -p -r irda-utils-0.9.13/irdadump/src/irlmp.c
irda-utils-0.9.10/irdadump/src/irlmp.c
--- irda-utils-0.9.13/irdadump/src/irlmp.c Wed Nov 22 11:54:36 2000
+++ irda-utils-0.9.10/irdadump/src/irlmp.c Mon Nov 13 13:47:35 2000
@@ -327,10 +327,10 @@ inline void parse_irlmp(GNetBuf *buf, GS
if (conn[i].valid && conn[i].ttp)
parse_irttp(buf, str);
if (conn[i].valid && conn[i].obex)
- parse_obex(&conn[0], buf, str, cmd);
+ parse_obex(&conn[i], buf, str, cmd);
#if 0
if (conn[i].valid && conn[i].ircomm)
- parse_ircomm(&conn[0], buf, str);
+ parse_ircomm(&conn[i], buf, str);
#endif
}
}
@@ -366,5 +366,15 @@ inline void parse_ui_irlmp(GNetBuf *buf,
g_netbuf_pull(buf, 1);
g_string_sprintfa(str, " Ultra-PID=%02x ", upid);
+
+ /* Check Obex over Ultra */
+ if(upid == 0x01)
+ {
+ /* Remove SAR field */
+ g_netbuf_pull(buf, 1);
+
+ /* Decode Obex stuff - no connection, always a command */
+ parse_obex(NULL, buf, str, 1);
+ }
}
}
diff -u -p -r irda-utils-0.9.13/irdadump/src/obex.c
irda-utils-0.9.10/irdadump/src/obex.c
--- irda-utils-0.9.13/irdadump/src/obex.c Wed Nov 22 11:54:36 2000
+++ irda-utils-0.9.10/irdadump/src/obex.c Tue Nov 21 14:55:53 2000
@@ -200,6 +200,7 @@ inline void parse_obex_connect(GNetBuf *
/*
* The first success frame contains the negociated Obex parameters
+ * We also need to parse the anser to GET request properly
* Jean II
*/
inline void parse_obex_success(GNetBuf *buf, GString *str)
@@ -214,8 +215,9 @@ inline void parse_obex_success(GNetBuf *
length = ntohs(frame->len);
- /* Check if it contains connection setup parameters */
- if(length == 7) {
+ switch(length) {
+ case 7:
+ /* Frame contains connection setup parameters */
version = frame->version;
flags = frame->flags;
mtu = ntohs(frame->mtu);
@@ -224,8 +226,17 @@ inline void parse_obex_success(GNetBuf *
"SUCCESS len=%d ver=%d.%d flags=%d mtu=%d ",
length, ((version & 0xf0) >> 4),
version & 0x0f, flags, mtu);
- } else
+ break;
+ case 3:
+ /* Frame contains nothing */
g_string_sprintfa(str, "SUCCESS len=%d ", length);
+ break;
+ default:
+ /* Frame contains some headers (probably a GET reply) */
+ g_string_append(str, "SUCCESS ");
+ parse_obex_headers(buf, str);
+ break;
+ }
}
/*
@@ -233,6 +244,8 @@ inline void parse_obex_success(GNetBuf *
*
* Parse OBEX commands and responses
*
+ * Note : in the case of Ultra frames, this function will be called
+ * with (conn == NULL). We should handle that gracefully.
*/
inline void parse_obex(struct lsap_state *conn, GNetBuf *buf, GString *str,
int cmd)
@@ -280,8 +293,6 @@ inline void parse_obex(struct lsap_state
opcode);
break;
}
- /* Next frame is a command (maybe) */
- conn->obex_rsp = 0;
} else {
switch (opcode) {
case OBEX_CONNECT:
@@ -314,7 +325,5 @@ inline void parse_obex(struct lsap_state
opcode);
break;
}
- /* Next frame should be a response (maybe) */
- conn->obex_rsp = 1;
}
}