On Sunday 20 July 2003 02:06, Bruno Rodrigues wrote:
> Now it's the right time to fix what's wrong, just before releasing a new
> version ;)
Speaking of compatibility breaking - I'd like to suggest a more radical change
: changing the message ID used in kannel internal messaging to 64 bit length.
while not changing a lot for the public APIs, this will allow for greater
flexability, as more and more providers are supplying their own abstraction
layers over their network SMSCs and more of these everyday make use of 64 bit
message ids.
The major down side is that this breaks the internal binary API, which causes
boxes with 64bit ids not to be able to talk to boxes with 32bit ids, and also
this invalidates store files created before the change.
The changes are supprisingly small, and our systems have been running this w/o
a hitch for more then 6 months. I've been reluctant to send this to the list
as I know how much people here dislike change (I'm all for you guys, don't
like it myself ;-). but if we're already on the subject of breaking
compatibility..
Patch attached.
--
Oded Arbel
m-Wise mobile solutions
[EMAIL PROTECTED]
+972-9-9581711 (116)
+972-67-340014
::..
Speaking as a recovering physics grad student, I think the situation might
best be best summed up by Feynmann's own description of Dirac's book on
Quantum Mechanics:
"We all quote this book, but none of us have read shit."
--- gateway/gw/msg.h 2003-03-27 10:55:01.000000000 +0200
+++ gateway/gw/msg.h 2003-06-24 12:07:38.000000000 +0300
@@ -22,6 +22,7 @@
enum msg_type type;
#define INTEGER(name) long name
+ #define INT64(name) long long name
#define OCTSTR(name) Octstr *name
#define MSG(type, stmt) struct type stmt type;
#include "msg-decl.h"
--- gateway/gw/msg.c 2003-07-20 09:43:38.000000000 +0300
+++ gateway/gw/msg.c 2003-07-20 09:51:33.000000000 +0300
@@ -20,9 +20,11 @@
*/
static void append_integer(Octstr *os, long i);
+static void append_int64(Octstr *os, unsigned long long i);
static void append_string(Octstr *os, Octstr *field);
static int parse_integer(long *i, Octstr *packed, int *off);
+static int parse_int64(long long *i, Octstr *packed, int *off);
static int parse_string(Octstr **os, Octstr *packed, int *off);
static char *type_as_str(Msg *msg);
@@ -40,6 +42,7 @@
msg->type = type;
#define INTEGER(name) p->name = 0
+#define INT64(name) p->name = 0
#define OCTSTR(name) p->name = NULL
#define MSG(type, stmt) { struct type *p = &msg->type; stmt }
#include "msg-decl.h"
@@ -65,6 +68,7 @@
new = msg_create(msg->type);
#define INTEGER(name) p->name = q->name
+#define INT64(name) p->name = q->name
#define OCTSTR(name) \
if (q->name == NULL) p->name = NULL; \
else p->name = octstr_duplicate(q->name);
@@ -83,6 +87,7 @@
return;
#define INTEGER(name) p->name = 0
+#define INT64(name) p->name = 0
#define OCTSTR(name) octstr_destroy(p->name)
#define MSG(type, stmt) { struct type *p = &msg->type; stmt }
#include "msg-decl.h"
@@ -101,6 +106,8 @@
debug("gw.msg", 0, "%*s type: %s", level, "", type_as_str(msg));
#define INTEGER(name) \
debug("gw.msg", 0, "%*s %s.%s: %ld", level, "", t, #name, (long) p->name)
+#define INT64(name) \
+ debug("gw.msg", 0, "%*s %s.%s: %lld", level, "", t, #name, (long long) p->name)
#define OCTSTR(name) \
debug("gw.msg", 0, "%*s %s.%s:", level, "", t, #name); \
octstr_dump(p->name, level + 1)
@@ -125,6 +132,7 @@
append_integer(os, msg->type);
#define INTEGER(name) append_integer(os, p->name)
+#define INT64(name) append_int64(os, p->name)
#define OCTSTR(name) append_string(os, p->name)
#define MSG(type, stmt) \
case type: { struct type *p = &msg->type; stmt } break;
@@ -158,6 +166,8 @@
#define INTEGER(name) \
if (parse_integer(&(p->name), os, &off) == -1) goto error
+#define INT64(name) \
+ if (parse_int64(&(p->name), os, &off) == -1) goto error
#define OCTSTR(name) \
if (parse_string(&(p->name), os, &off) == -1) goto error
#define MSG(type, stmt) \
@@ -191,6 +201,14 @@
octstr_append_data(os, buf, 4);
}
+static void append_int64(Octstr *os, unsigned long long i)
+{
+ unsigned char buf[8];
+
+ encode_network_int64(buf, i);
+ octstr_append_data(os, buf, 8);
+}
+
static void append_string(Octstr *os, Octstr *field)
{
if (field == NULL)
@@ -218,6 +236,21 @@
return 0;
}
+static int parse_int64(long long *i, Octstr *packed, int *off)
+{
+ unsigned char buf[8];
+
+ gw_assert(*off >= 0);
+ if (*off + 8 > octstr_len(packed)) {
+ error(0, "Packet too short while unpacking Msg.");
+ return -1;
+ }
+
+ octstr_get_many_chars(buf, packed, *off, 8);
+ *i = decode_network_int64(buf);
+ *off += 8;
+ return 0;
+}
static int parse_string(Octstr **os, Octstr *packed, int *off)
{
--- gateway/gw/msg-decl.h 2003-07-20 09:43:38.000000000 +0300
+++ gateway/gw/msg-decl.h 2003-06-24 12:07:13.000000000 +0300
@@ -31,7 +31,7 @@
OCTSTR(smsc_id);
OCTSTR(service);
OCTSTR(account);
- INTEGER(id);
+ INT64(id);
INTEGER(sms_type);
INTEGER(mclass);
INTEGER(mwi);
@@ -52,7 +52,7 @@
{
INTEGER(nack);
INTEGER(time);
- INTEGER(id);
+ INT64(id);
})
MSG(wdp_datagram,
@@ -66,4 +70,5 @@
#undef MSG
#undef INTEGER
+#undef INT64
#undef OCTSTR
--- gateway/gwlib/utils.h 2003-07-20 10:24:13.000000000 +0300
+++ gateway/gwlib/utils.h 2002-09-06 00:21:24.000000000 +0300
@@ -104,6 +104,12 @@
*/
void encode_network_long(unsigned char *data, unsigned long value);
+/*
+ * Same as the previous two, but encodes and decodes 64 bit unsigned intergers
+ */
+unsigned long long decode_network_int64(unsigned char *data);
+void encode_network_int64(unsigned char *data, unsigned long long value);
+
/* kannel implementation of cfmakeraw, which is an extension in GNU libc */
void kannel_cfmakeraw (struct termios *tio);
--- gateway/gwlib/utils.c 2003-07-20 10:23:55.000000000 +0300
+++ gateway/gwlib/utils.c 2003-06-26 16:43:40.000000000 +0300
@@ -332,6 +332,26 @@
data[3] = value & 0xff;
}
+unsigned long long decode_network_int64(unsigned char *data) {
+ return
+ ((long long)data[0] << 56) | ((long long)data[1] << 48) |
+ ((long long)data[2] << 40) | ((long long)data[3] << 32) |
+ ((long long)data[4] << 24) | ((long long)data[5] << 16) |
+ ((long long)data[6] << 8) | (long long)data[7];
+}
+
+
+void encode_network_int64(unsigned char *data, unsigned long long value) {
+ data[0] = (value >> 56) & 0xff;
+ data[1] = (value >> 48) & 0xff;
+ data[2] = (value >> 40) & 0xff;
+ data[3] = (value >> 32) & 0xff;
+ data[4] = (value >> 24) & 0xff;
+ data[5] = (value >> 16) & 0xff;
+ data[6] = (value >> 8) & 0xff;
+ data[7] = value & 0xff;
+}
+
/* Something that does the same as GNU cfmakeraw. We don't use cfmakeraw
so that we always know what it does, and also to reduce configure.in
complexity. */