diff options
author | Dimitri Staessens <dimitri@ouroboros.rocks> | 2023-11-27 14:43:11 +0100 |
---|---|---|
committer | Sander Vrijders <sander@ouroboros.rocks> | 2023-11-29 09:57:29 +0100 |
commit | 346b054ee32a9f7b8491f842709f72cc8d1f3f2e (patch) | |
tree | 5a406924ca94a03460e9b1e14d50cd1fca7c5c61 /src/lib/protobuf.c | |
parent | 3f24301fff9c544dfe2b89c5737bc3cdf94ef9a9 (diff) | |
download | ouroboros-346b054ee32a9f7b8491f842709f72cc8d1f3f2e.tar.gz ouroboros-346b054ee32a9f7b8491f842709f72cc8d1f3f2e.zip |
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 <dimitri@ouroboros.rocks>
Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
Diffstat (limited to 'src/lib/protobuf.c')
-rw-r--r-- | src/lib/protobuf.c | 39 |
1 files changed, 39 insertions, 0 deletions
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; |