libei: push the new brei_message one level up into eiproto

This is the proto parser and it'll know when we need an fd on the message, so
let's make sure we have everything in place to fetch the fd.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer 2020-08-21 13:19:40 +10:00
parent d4fedc1a4b
commit 38c50d0d3d
3 changed files with 8 additions and 7 deletions

View file

@ -49,14 +49,15 @@ static void servermessage_cleanup(ServerMessage **m) {
#define _cleanup_servermessage_ _cleanup_(servermessage_cleanup)
struct message *
ei_proto_parse_message(const char *msgdata, size_t msglen, size_t *consumed)
ei_proto_parse_message(struct brei_message *bmsg, size_t *consumed)
{
_cleanup_servermessage_ ServerMessage *proto = server_message__unpack(NULL, msglen,
(const unsigned char*)msgdata);
_cleanup_servermessage_ ServerMessage *proto = server_message__unpack(NULL,
bmsg->len,
(const unsigned char*)bmsg->data);
if (!proto)
return NULL;
*consumed = msglen;
*consumed = bmsg->len;
_cleanup_message_ struct message *msg = xalloc(sizeof(*msg));

View file

@ -28,6 +28,7 @@
#include "util-macros.h"
#include "util-mem.h"
#include "brei-shared.h"
#include "libei-private.h"
/* The message type for the wire format */
@ -71,7 +72,7 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(struct message*, message_free);
#define _cleanup_message_ _cleanup_(message_freep)
struct message *
ei_proto_parse_message(const char *data, size_t len, size_t *consumed);
ei_proto_parse_message(struct brei_message *message, size_t *consumed);
int
ei_proto_send_connect(struct ei *ei);

View file

@ -544,8 +544,7 @@ connection_message_callback(struct brei_message *bmsg, void *userdata)
struct ei *ei = userdata;
size_t consumed;
_cleanup_message_ struct message *msg =
ei_proto_parse_message(bmsg->data, bmsg->len, &consumed);
_cleanup_message_ struct message *msg = ei_proto_parse_message(bmsg, &consumed);
if (!msg)
return -EBADMSG;