From 346b054ee32a9f7b8491f842709f72cc8d1f3f2e Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Mon, 27 Nov 2023 14:43:11 +0100 Subject: include: Store IPCP name and type in info struct The information for an IPCP is now stored in an ipcp_info struct, containing name and type. The IRM public API is not changed. Signed-off-by: Dimitri Staessens Signed-off-by: Sander Vrijders --- src/lib/protobuf.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'src/lib/protobuf.c') diff --git a/src/lib/protobuf.c b/src/lib/protobuf.c index 7fbcef8c..d4e02549 100644 --- a/src/lib/protobuf.c +++ b/src/lib/protobuf.c @@ -67,6 +67,45 @@ struct layer_info layer_info_msg_to_s(const layer_info_msg_t * msg) return s; } +ipcp_info_msg_t * ipcp_info_s_to_msg(const struct ipcp_info * s) +{ + ipcp_info_msg_t * msg; + + assert(s != NULL); + + msg = malloc(sizeof(*msg)); + if (msg == NULL) + goto fail_malloc; + + ipcp_info_msg__init(msg); + + msg->name = strdup(s->name); + if (msg->name == NULL) + goto fail_msg; + + msg->type = s->type; + + return msg; + fail_msg: + ipcp_info_msg__free_unpacked(msg, NULL); + fail_malloc: + return NULL; +} + +struct ipcp_info ipcp_info_msg_to_s(const ipcp_info_msg_t * msg) +{ + struct ipcp_info s; + + assert(msg != NULL); + assert(msg->name != NULL); + assert(strlen(msg->name) <= NAME_SIZE); + + s.type = msg->type; + strcpy(s.name, msg->name); + + return s; +} + dt_config_msg_t * dt_config_s_to_msg(const struct dt_config * s) { dt_config_msg_t * msg; -- cgit v1.2.3