Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Dustin L. Howett
oligos
Commits
d05be75f
Commit
d05be75f
authored
Apr 23, 2012
by
Dustin L. Howett
Browse files
Widen the size field in the DADY format to 4 bytes from 2.
parent
91cbe124
Changes
3
Hide whitespace changes
Inline
Side-by-side
dady/dady.c
View file @
d05be75f
...
...
@@ -25,8 +25,8 @@ void dump(const char *s, int len) {
}
*/
static
int
_default_group_tag_cb
(
uint32_t
tagtype
,
uint
16
_t
len
,
uint8_t
*
data
,
struct
dady_callback
*
cb
,
void
*
cbdata
)
{
uint
16
_t
size
=
len
;
// - 4;
static
int
_default_group_tag_cb
(
uint32_t
tagtype
,
uint
32
_t
len
,
uint8_t
*
data
,
struct
dady_callback
*
cb
,
void
*
cbdata
)
{
uint
32
_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
,
uint
16
_t
len
,
uint8_t
*
data
,
struct
dady_callback
*
cb
,
void
*
cbdata
)
{
_D
(
"Callback got a tag of type %8.08x with a length of %
h
u.
\n
"
,
tagtype
,
len
);
static
int
_default_tag_cb
(
uint32_t
tagtype
,
uint
32
_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
);
uint
16
_t
size
=
*
(
uint
16
_t
*
)((
uint32_t
*
)
buf
+
1
);
uint
32
_t
size
=
*
(
uint
32
_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
,
uint
16
_t
len
,
void
*
data
,
bool
checksum
)
{
uint
16
_t
headlen
=
len
;
uint32_t
bprinttag
(
uint8_t
*
buf
,
uint32_t
tagtype
,
uint
32
_t
len
,
void
*
data
,
bool
checksum
)
{
uint
32
_t
headlen
=
len
;
if
(
checksum
)
headlen
+=
4
;
if
(
buf
)
{
uint8_t
*
tag
=
buf
;
*
(
uint32_t
*
)
tag
=
tagtype
;
*
(
uint
16
_t
*
)(
tag
+
4
)
=
headlen
;
*
(
uint
32
_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
,
uint
16
_t
len
,
void
*
data
,
bool
checksum
)
{
uint32_t
abprinttag
(
uint8_t
**
buf
,
uint32_t
tagtype
,
uint
32
_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
);
...
...
dady/dady.h
View file @
d05be75f
...
...
@@ -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
,
uint
16
_t
len
,
uint8_t
*
data
,
struct
dady_callback
*
cb
,
void
*
cbdata
);
int
(
*
tag_cb
)(
uint32_t
tagtype
,
uint
16
_t
len
,
uint8_t
*
data
,
struct
dady_callback
*
cb
,
void
*
cbdata
);
int
(
*
group_tag_cb
)(
uint32_t
tagtype
,
uint
32
_t
len
,
uint8_t
*
data
,
struct
dady_callback
*
cb
,
void
*
cbdata
);
int
(
*
tag_cb
)(
uint32_t
tagtype
,
uint
32
_t
len
,
uint8_t
*
data
,
struct
dady_callback
*
cb
,
void
*
cbdata
);
};
typedef
int
(
*
tag_callback
)(
uint32_t
tagtype
,
uint
16
_t
len
,
uint8_t
*
data
,
struct
dady_callback
*
cb
,
void
*
cbdata
);
typedef
int
(
*
tag_callback
)(
uint32_t
tagtype
,
uint
32
_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
,
uint
16
_t
len
,
void
*
data
,
bool
checksum
_DEFAULT
(
false
));
uint32_t
abprinttag
(
uint8_t
**
buf
,
uint32_t
tagtype
,
uint
16
_t
len
,
void
*
data
,
bool
checksum
_DEFAULT
(
false
));
uint32_t
bprinttag
(
uint8_t
*
buf
,
uint32_t
tagtype
,
uint
32
_t
len
,
void
*
data
,
bool
checksum
_DEFAULT
(
false
));
uint32_t
abprinttag
(
uint8_t
**
buf
,
uint32_t
tagtype
,
uint
32
_t
len
,
void
*
data
,
bool
checksum
_DEFAULT
(
false
));
struct
tag_info
{
uint32_t
type
;
uint
16
_t
len
;
uint
32
_t
len
;
void
*
bufp
;
};
...
...
main.cc
View file @
d05be75f
...
...
@@ -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
,
uint
16
_t
len
,
uint8_t
*
data
,
struct
dady_callback
*
cb
,
void
*
cbdata
)
{
static
int
_load_copyover_tag_cb
(
uint32_t
tagtype
,
uint
32
_t
len
,
uint8_t
*
data
,
struct
dady_callback
*
cb
,
void
*
cbdata
)
{
switch
(
tagtype
)
{
case
'
RBUF
'
:
if
(
len
>
0
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment