Commit d05be75f authored by Dustin L. Howett's avatar Dustin L. Howett

Widen the size field in the DADY format to 4 bytes from 2.

parent 91cbe124
......@@ -25,8 +25,8 @@ void dump(const char *s, int len) {
}
*/
static int _default_group_tag_cb(uint32_t tagtype, uint16_t len, uint8_t *data, struct dady_callback *cb, void *cbdata) {
uint16_t size = len;// - 4;
static int _default_group_tag_cb(uint32_t tagtype, uint32_t len, uint8_t *data, struct dady_callback *cb, void *cbdata) {
uint32_t size = len;// - 4;
//uint32_t cksm = *(uint32_t*)(data+size);
/*
......@@ -53,8 +53,8 @@ static int _default_group_tag_cb(uint32_t tagtype, uint16_t len, uint8_t *data,
return len;
}
static int _default_tag_cb(uint32_t tagtype, uint16_t len, uint8_t *data, struct dady_callback *cb, void *cbdata) {
_D("Callback got a tag of type %8.08x with a length of %hu.\n", tagtype, len);
static int _default_tag_cb(uint32_t tagtype, uint32_t len, uint8_t *data, struct dady_callback *cb, void *cbdata) {
_D("Callback got a tag of type %8.08x with a length of %u.\n", tagtype, len);
return len;
}
......@@ -70,7 +70,7 @@ int bscantag(uint8_t *buf, uint32_t buflen, struct dady_callback *cb, void *cbda
}
uint32_t tagtype = *((uint32_t*)buf);
uint16_t size = *(uint16_t*)((uint32_t*)buf+1);
uint32_t size = *(uint32_t*)((uint32_t*)buf+1);
int r = 0;
......@@ -98,14 +98,14 @@ int bscantag(uint8_t *buf, uint32_t buflen, struct dady_callback *cb, void *cbda
return datalen + 8 + (checksum ? 4 : 0);
}*/
uint32_t bprinttag(uint8_t *buf, uint32_t tagtype, uint16_t len, void *data, bool checksum) {
uint16_t headlen = len;
uint32_t bprinttag(uint8_t *buf, uint32_t tagtype, uint32_t len, void *data, bool checksum) {
uint32_t headlen = len;
if(checksum) headlen += 4;
if(buf) {
uint8_t *tag = buf;
*(uint32_t*)tag = tagtype;
*(uint16_t*)(tag+4) = headlen;
*(uint32_t*)(tag+4) = headlen;
memcpy(tag+_TAG_HEAD_LEN, data, len);
if(checksum) {
uint32_t crc = crc32(0, tag, _TAG_LENGTH(len));
......@@ -115,7 +115,7 @@ uint32_t bprinttag(uint8_t *buf, uint32_t tagtype, uint16_t len, void *data, boo
return headlen + _TAG_HEAD_LEN;
}
uint32_t abprinttag(uint8_t **buf, uint32_t tagtype, uint16_t len, void *data, bool checksum) {
uint32_t abprinttag(uint8_t **buf, uint32_t tagtype, uint32_t len, void *data, bool checksum) {
uint32_t taglen = bprinttag(NULL, tagtype, len, data, checksum);
*buf = (uint8_t*)malloc(taglen);
return bprinttag(*buf, tagtype, len, data, checksum);
......
......@@ -10,7 +10,7 @@
#define TAG_ID_FD__ 'FD__'
#define TAG_ID_NICK 'NICK'
#define _TAG_HEAD_LEN 6
#define _TAG_HEAD_LEN 8
#define _TAG_LENGTH(datalen) (datalen+_TAG_HEAD_LEN)
#define _TAG_LENGTH_CHECKSUM(datalen) (datalen+_TAG_HEAD_LEN+4)
......@@ -34,18 +34,18 @@
extern "C" {
#endif
struct dady_callback {
int (*group_tag_cb)(uint32_t tagtype, uint16_t len, uint8_t *data, struct dady_callback *cb, void *cbdata);
int (*tag_cb)(uint32_t tagtype, uint16_t len, uint8_t *data, struct dady_callback *cb, void *cbdata);
int (*group_tag_cb)(uint32_t tagtype, uint32_t len, uint8_t *data, struct dady_callback *cb, void *cbdata);
int (*tag_cb)(uint32_t tagtype, uint32_t len, uint8_t *data, struct dady_callback *cb, void *cbdata);
};
typedef int (*tag_callback)(uint32_t tagtype, uint16_t len, uint8_t *data, struct dady_callback *cb, void *cbdata);
typedef int (*tag_callback)(uint32_t tagtype, uint32_t len, uint8_t *data, struct dady_callback *cb, void *cbdata);
int bscantag(uint8_t *buf, uint32_t buflen, struct dady_callback *cb, void *cbdata);
uint32_t bprinttag(uint8_t *buf, uint32_t tagtype, uint16_t len, void *data, bool checksum _DEFAULT(false));
uint32_t abprinttag(uint8_t **buf, uint32_t tagtype, uint16_t len, void *data, bool checksum _DEFAULT(false));
uint32_t bprinttag(uint8_t *buf, uint32_t tagtype, uint32_t len, void *data, bool checksum _DEFAULT(false));
uint32_t abprinttag(uint8_t **buf, uint32_t tagtype, uint32_t len, void *data, bool checksum _DEFAULT(false));
struct tag_info {
uint32_t type;
uint16_t len;
uint32_t len;
void *bufp;
};
......
......@@ -83,7 +83,7 @@ void do_copyover(char *requester) {
_D("Copyover failed: %s\n", strerror(errno));
}
static int _load_copyover_tag_cb(uint32_t tagtype, uint16_t len, uint8_t *data, struct dady_callback *cb, void *cbdata) {
static int _load_copyover_tag_cb(uint32_t tagtype, uint32_t len, uint8_t *data, struct dady_callback *cb, void *cbdata) {
switch(tagtype) {
case 'RBUF':
if(len > 0) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment