mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-01 03:24:41 +01:00
pkt: don't convert endian on header.
This is now only used for internal tests, so endian conversion is overkill. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
a38d0c985e
commit
b312114719
7
pkt.c
7
pkt.c
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
size_t pkt_totlen(const struct pkt *pkt)
|
size_t pkt_totlen(const struct pkt *pkt)
|
||||||
{
|
{
|
||||||
return sizeof(pkt->len) + le32_to_cpu(pkt->len);
|
return sizeof(pkt->len) + pkt->len;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct pkt *to_pkt(const tal_t *ctx, Pkt__PktCase type, const void *msg)
|
static struct pkt *to_pkt(const tal_t *ctx, Pkt__PktCase type, const void *msg)
|
||||||
@ -25,7 +25,7 @@ static struct pkt *to_pkt(const tal_t *ctx, Pkt__PktCase type, const void *msg)
|
|||||||
|
|
||||||
len = pkt__get_packed_size(&p);
|
len = pkt__get_packed_size(&p);
|
||||||
ret = (struct pkt *)tal_arr(ctx, u8, sizeof(ret->len) + len);
|
ret = (struct pkt *)tal_arr(ctx, u8, sizeof(ret->len) + len);
|
||||||
ret->len = cpu_to_le32(len);
|
ret->len = len;
|
||||||
|
|
||||||
pkt__pack(&p, ret->data);
|
pkt__pack(&p, ret->data);
|
||||||
return ret;
|
return ret;
|
||||||
@ -84,8 +84,7 @@ Pkt *any_pkt_from_file(const char *filename)
|
|||||||
err(1, "Opening %s", filename);
|
err(1, "Opening %s", filename);
|
||||||
|
|
||||||
len = tal_count(pkt) - 1;
|
len = tal_count(pkt) - 1;
|
||||||
if (len < sizeof(pkt->len)
|
if (len < sizeof(pkt->len) || len != sizeof(pkt->len) + pkt->len)
|
||||||
|| len != sizeof(pkt->len) + le32_to_cpu(pkt->len))
|
|
||||||
errx(1, "%s length is wrong", filename);
|
errx(1, "%s length is wrong", filename);
|
||||||
len -= sizeof(pkt->len);
|
len -= sizeof(pkt->len);
|
||||||
|
|
||||||
|
3
pkt.h
3
pkt.h
@ -8,13 +8,12 @@
|
|||||||
* insisted on "prettifing" the names they generate into CamelCase.
|
* insisted on "prettifing" the names they generate into CamelCase.
|
||||||
*/
|
*/
|
||||||
#include "lightning.pb-c.h"
|
#include "lightning.pb-c.h"
|
||||||
#include <ccan/endian/endian.h>
|
|
||||||
#include <ccan/short_types/short_types.h>
|
#include <ccan/short_types/short_types.h>
|
||||||
#include <ccan/tal/tal.h>
|
#include <ccan/tal/tal.h>
|
||||||
|
|
||||||
/* A packet, ready to be de-protobuf'ed. */
|
/* A packet, ready to be de-protobuf'ed. */
|
||||||
struct pkt {
|
struct pkt {
|
||||||
le32 len;
|
u32 len;
|
||||||
u8 data[];
|
u8 data[];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user