summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri@ouroboros.rocks>2023-11-27 14:43:11 +0100
committerSander Vrijders <sander@ouroboros.rocks>2023-11-29 09:57:29 +0100
commit346b054ee32a9f7b8491f842709f72cc8d1f3f2e (patch)
tree5a406924ca94a03460e9b1e14d50cd1fca7c5c61
parent3f24301fff9c544dfe2b89c5737bc3cdf94ef9a9 (diff)
downloadouroboros-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>
-rw-r--r--include/ouroboros/ipcp.h9
-rw-r--r--include/ouroboros/protobuf.h6
-rw-r--r--src/irmd/configfile.c32
-rw-r--r--src/irmd/ipcp.c11
-rw-r--r--src/irmd/ipcp.h3
-rw-r--r--src/irmd/irmd.h3
-rw-r--r--src/irmd/main.c95
-rw-r--r--src/irmd/reg/ipcp.c11
-rw-r--r--src/irmd/reg/ipcp.h7
-rw-r--r--src/lib/irm.c18
-rw-r--r--src/lib/pb/irm.proto49
-rw-r--r--src/lib/protobuf.c39
12 files changed, 179 insertions, 104 deletions
diff --git a/include/ouroboros/ipcp.h b/include/ouroboros/ipcp.h
index 4be9b48e..d894abb4 100644
--- a/include/ouroboros/ipcp.h
+++ b/include/ouroboros/ipcp.h
@@ -27,6 +27,7 @@
#include <unistd.h>
#include <stdbool.h>
+#define IPCP_NAME_SIZE 255
#define LAYER_NAME_SIZE 255
#define DEV_NAME_SIZE 255
@@ -97,6 +98,12 @@ struct udp_config {
uint16_t port;
};
+/* Info about the IPCP */
+struct ipcp_info {
+ enum ipcp_type type;
+ char name[IPCP_NAME_SIZE + 1];
+};
+
/* Info reported back to the IRMd about the layer on enrollment */
struct layer_info {
char name[LAYER_NAME_SIZE + 1];
@@ -156,7 +163,7 @@ static const struct ipcp_config uni_default_conf = {
.dt = {
.addr_size = 4,
.eid_size = 8,
- .max_ttl = 6,
+ .max_ttl = 60,
.routing_type = ROUTING_LINK_STATE
},
.addr_auth_type = ADDR_AUTH_FLAT_RANDOM,
diff --git a/include/ouroboros/protobuf.h b/include/ouroboros/protobuf.h
index da5d58fd..ed944a3c 100644
--- a/include/ouroboros/protobuf.h
+++ b/include/ouroboros/protobuf.h
@@ -25,6 +25,7 @@
#include <ouroboros/qos.h>
#include <ouroboros/ipcp.h>
+#include <ouroboros/irm.h>
#include <ouroboros/serdes-oep.h>
#include "ipcp_config.pb-c.h"
@@ -39,6 +40,7 @@ typedef UniConfigMsg uni_config_msg_t;
typedef IpcpMsg ipcp_msg_t;
#include "irm.pb-c.h"
+typedef IpcpInfoMsg ipcp_info_msg_t;
typedef IpcpListMsg ipcp_list_msg_t;
typedef NameInfoMsg name_info_msg_t;
@@ -56,6 +58,10 @@ layer_info_msg_t * layer_info_s_to_msg(const struct layer_info * s);
struct layer_info layer_info_msg_to_s(const layer_info_msg_t * msg);
+ipcp_info_msg_t * ipcp_info_s_to_msg(const struct ipcp_info * s);
+
+struct ipcp_info ipcp_info_msg_to_s(const ipcp_info_msg_t * msg);
+
dt_config_msg_t * dt_config_s_to_msg(const struct dt_config * s);
struct dt_config dt_config_msg_to_s(const dt_config_msg_t * msg);
diff --git a/src/irmd/configfile.c b/src/irmd/configfile.c
index 07f31ccf..af2a37c8 100644
--- a/src/irmd/configfile.c
+++ b/src/irmd/configfile.c
@@ -422,20 +422,20 @@ static int toml_connect(toml_table_t * table,
return ret;
}
-static int toml_ipcp(toml_table_t * table,
- const char * name,
- struct ipcp_config * conf)
+static int toml_ipcp(toml_table_t * table,
+ const struct ipcp_info * info,
+ struct ipcp_config * conf)
{
toml_datum_t bootstrap;
toml_datum_t enrol;
pid_t pid;
int ret;
- log_dbg("Found IPCP %s in configuration file.", name);
+ log_dbg("Found IPCP %s in configuration file.", info->name);
- pid = create_ipcp(name, conf->type);
+ pid = create_ipcp(info);
if (pid < 0) {
- log_err("Failed to create IPCP %s.", name);
+ log_err("Failed to create IPCP %s.", info->name);
return -1;
}
@@ -443,13 +443,13 @@ static int toml_ipcp(toml_table_t * table,
enrol = toml_string_in(table, "enrol");
if (bootstrap.ok && enrol.ok) {
- log_err("Ignoring bootstrap for IPCP %s.", name);
+ log_err("Ignoring bootstrap for IPCP %s.", info->name);
free(bootstrap.u.s);
bootstrap.ok = false;
}
if (!bootstrap.ok && !enrol.ok) {
- log_dbg("Nothing more to do for %s.", name);
+ log_dbg("Nothing more to do for %s.", info->name);
return 0;
}
@@ -458,14 +458,14 @@ static int toml_ipcp(toml_table_t * table,
ret = enroll_ipcp(pid, enrol.u.s);
free(enrol.u.s);
if (ret < 0) {
- log_err("Failed to enrol %s.", name);
+ log_err("Failed to enrol %s.", info->name);
return -1;
}
if (get_layer_for_ipcp(pid, layer) < 0)
return -1;
- if (toml_autobind(table, pid, name, layer))
+ if (toml_autobind(table, pid, info->name, layer))
return -1;
if (toml_register(table, pid) < 0) {
@@ -522,7 +522,7 @@ static int toml_ipcp(toml_table_t * table,
if (bootstrap_ipcp(pid, conf) < 0)
return -1;
- if (toml_autobind(table, pid, name, conf->layer_info.name) < 0)
+ if (toml_autobind(table, pid, info->name, conf->layer_info.name) < 0)
return -1;
if (toml_register(table, pid) < 0) {
@@ -541,17 +541,25 @@ static int toml_ipcp_list(toml_table_t * table,
for (i = 0; ret == 0; i++) {
const char * key;
+ struct ipcp_info info;
struct ipcp_config conf;
key = toml_key_in(table, i);
if (key == NULL)
break;
+ if (strlen(key) > IPCP_NAME_SIZE) {
+ log_err("IPCP name too long: %s,", key);
+ return -1;
+ }
+
memset(&conf, 0, sizeof(conf));
+ info.type = type;
+ strcpy(info.name,key);
conf.type = type;
- ret = toml_ipcp(toml_table_in(table, key), key, &conf);
+ ret = toml_ipcp(toml_table_in(table, key), &info, &conf);
}
return ret;
diff --git a/src/irmd/ipcp.c b/src/irmd/ipcp.c
index b0d95b44..281c7176 100644
--- a/src/irmd/ipcp.c
+++ b/src/irmd/ipcp.c
@@ -122,16 +122,15 @@ ipcp_msg_t * send_recv_ipcp_msg(pid_t pid,
return recv_msg;
}
-pid_t ipcp_create(const char * name,
- enum ipcp_type ipcp_type)
+pid_t ipcp_create(const struct ipcp_info * info)
{
pid_t pid;
- char * exec_name;
+ char * exec_name = NULL;
char irmd_pid[10];
char full_name[256];
char * argv[5];
- switch(ipcp_type) {
+ switch(info->type) {
case IPCP_UNICAST:
exec_name = IPCP_UNICAST_EXEC;
break;
@@ -154,7 +153,7 @@ pid_t ipcp_create(const char * name,
return -1;
}
- if (strlen(exec_name) == 0) {
+ if (exec_name == NULL) {
log_err("IPCP type not installed.");
return -1;
}
@@ -167,7 +166,7 @@ pid_t ipcp_create(const char * name,
/* log_file to be placed at the end */
argv[0] = full_name;
argv[1] = irmd_pid;
- argv[2] = (char *) name;
+ argv[2] = (char *) info->name;
if (log_syslog)
argv[3] = "1";
else
diff --git a/src/irmd/ipcp.h b/src/irmd/ipcp.h
index bedbfe01..f59e7090 100644
--- a/src/irmd/ipcp.h
+++ b/src/irmd/ipcp.h
@@ -29,8 +29,7 @@
#ifndef OUROBOROS_IRMD_IPCP_H
#define OUROBOROS_IRMD_IPCP_H
-pid_t ipcp_create(const char * name,
- enum ipcp_type ipcp_type);
+pid_t ipcp_create(const struct ipcp_info * info);
int ipcp_destroy(pid_t pid);
diff --git a/src/irmd/irmd.h b/src/irmd/irmd.h
index a225a2dd..fcf4d1fb 100644
--- a/src/irmd/irmd.h
+++ b/src/irmd/irmd.h
@@ -26,8 +26,7 @@
#include <ouroboros/ipcp.h>
#include <ouroboros/irm.h>
-int create_ipcp(const char * name,
- enum ipcp_type type);
+int create_ipcp(const struct ipcp_info * info);
int bootstrap_ipcp(pid_t pid,
struct ipcp_config * conf);
diff --git a/src/irmd/main.c b/src/irmd/main.c
index 131bd468..f1e0e203 100644
--- a/src/irmd/main.c
+++ b/src/irmd/main.c
@@ -205,7 +205,9 @@ static int registry_add_ipcp(struct reg_ipcp * ipcp)
assert(ipcp);
list_for_each(p, &irmd.ipcps) {
- if (list_entry(p, struct reg_ipcp, next)->type > ipcp->type)
+ struct reg_ipcp * i;
+ i = list_entry(p, struct reg_ipcp, next);
+ if (i->info.type > ipcp->info.type)
break;
}
@@ -220,9 +222,10 @@ static struct reg_ipcp * registry_get_ipcp_by_pid(pid_t pid)
struct list_head * p;
list_for_each(p, &irmd.ipcps) {
- struct reg_ipcp * e = list_entry(p, struct reg_ipcp, next);
- if (e->pid == pid)
- return e;
+ struct reg_ipcp * ipcp;
+ ipcp = list_entry(p, struct reg_ipcp, next);
+ if (ipcp->pid == pid)
+ return ipcp;
}
return NULL;
@@ -246,9 +249,10 @@ static struct reg_ipcp * registry_get_ipcp_by_name(const char * name)
struct list_head * p;
list_for_each(p, &irmd.ipcps) {
- struct reg_ipcp * e = list_entry(p, struct reg_ipcp, next);
- if (strcmp(name, e->name) == 0)
- return e;
+ struct reg_ipcp * ipcp;
+ ipcp = list_entry(p, struct reg_ipcp, next);
+ if (strcmp(name, ipcp->info.name) == 0)
+ return ipcp;
}
return NULL;
@@ -259,9 +263,10 @@ static struct reg_ipcp * registry_get_ipcp_by_layer(const char * layer)
struct list_head * p;
list_for_each(p, &irmd.ipcps) {
- struct reg_ipcp * e = list_entry(p, struct reg_ipcp, next);
- if (strcmp(layer, e->layer) == 0)
- return e;
+ struct reg_ipcp * ipcp;
+ ipcp = list_entry(p, struct reg_ipcp, next);
+ if (strcmp(layer, ipcp->layer) == 0)
+ return ipcp;
}
return NULL;
@@ -279,11 +284,18 @@ static struct reg_ipcp * registry_get_ipcp_by_dst_name(const char * name,
pthread_rwlock_rdlock(&irmd.reg_lock);
list_for_each_safe(p, h, &irmd.ipcps) {
- struct reg_ipcp * e = list_entry(p, struct reg_ipcp, next);
- if (e->layer == NULL || e->pid == src || e->type == IPCP_BROADCAST)
+ struct reg_ipcp * ipcp;
+ ipcp = list_entry(p, struct reg_ipcp, next);
+ if (ipcp->layer == NULL)
continue;
- len = IPCP_HASH_LEN(e);
+ if (ipcp->pid == src)
+ continue;
+
+ if (ipcp->info.type == IPCP_BROADCAST)
+ continue;
+
+ len = IPCP_HASH_LEN(ipcp);
hash = malloc(len);
if (hash == NULL) {
@@ -291,15 +303,15 @@ static struct reg_ipcp * registry_get_ipcp_by_dst_name(const char * name,
return NULL;
}
- str_hash(e->dir_hash_algo, hash, name);
+ str_hash(ipcp->dir_hash_algo, hash, name);
- pid = e->pid;
+ pid = ipcp->pid;
pthread_rwlock_unlock(&irmd.reg_lock);
if (ipcp_query(pid, hash, len) == 0) {
free(hash);
- return e;
+ return ipcp;
}
free(hash);
@@ -500,8 +512,7 @@ static struct reg_proc * registry_get_proc(pid_t pid)
return NULL;
}
-pid_t create_ipcp(const char * name,
- enum ipcp_type type)
+pid_t create_ipcp(const struct ipcp_info * info)
{
struct pid_el * ppid;
struct reg_ipcp * ipcp;
@@ -509,7 +520,7 @@ pid_t create_ipcp(const char * name,
pthread_rwlock_rdlock(&irmd.reg_lock);
- ipcp = registry_get_ipcp_by_name(name);
+ ipcp = registry_get_ipcp_by_name(info->name);
if (ipcp != NULL) {
pthread_rwlock_unlock(&irmd.reg_lock);
log_err("IPCP by that name already exists.");
@@ -522,13 +533,13 @@ pid_t create_ipcp(const char * name,
if (ppid == NULL)
goto fail_ppid;
- ipcp = reg_ipcp_create(name, type);
+ ipcp = reg_ipcp_create(info);
if (ipcp == NULL) {
log_err("Failed to create IPCP entry.");
goto fail_reg_ipcp;
}
- pid = ipcp_create(name, type);
+ pid = ipcp_create(info);
if (pid == -1) {
log_err("Failed to create IPCP.");
goto fail_ipcp;
@@ -616,38 +627,38 @@ static int destroy_ipcp(pid_t pid)
int bootstrap_ipcp(pid_t pid,
struct ipcp_config * conf)
{
- struct reg_ipcp * entry;
- struct layer_info info;
+ struct reg_ipcp * ipcp;
+ struct layer_info info;
pthread_rwlock_wrlock(&irmd.reg_lock);
- entry = registry_get_ipcp_by_pid(pid);
- if (entry == NULL) {
+ ipcp = registry_get_ipcp_by_pid(pid);
+ if (ipcp == NULL) {
pthread_rwlock_unlock(&irmd.reg_lock);
- log_err("No such IPCP.");
+ log_err("No such IPCP: %d.", pid);
return -1;
}
- if (entry->type != conf->type) {
+ if (ipcp->info.type != conf->type) {
pthread_rwlock_unlock(&irmd.reg_lock);
log_err("Configuration does not match IPCP type.");
return -1;
}
- if (ipcp_bootstrap(entry->pid, conf, &info)) {
+ if (ipcp_bootstrap(ipcp->pid, conf, &info)) {
pthread_rwlock_unlock(&irmd.reg_lock);
log_err("Could not bootstrap IPCP.");
return -1;
}
- entry->layer = strdup(info.name);
- if (entry->layer == NULL) {
+ ipcp->layer = strdup(info.name);
+ if (ipcp->layer == NULL) {
pthread_rwlock_unlock(&irmd.reg_lock);
log_warn("Failed to set name of layer.");
return -ENOMEM;
}
- entry->dir_hash_algo = info.dir_hash_algo;
+ ipcp->dir_hash_algo = info.dir_hash_algo;
pthread_rwlock_unlock(&irmd.reg_lock);
@@ -716,7 +727,8 @@ int connect_ipcp(pid_t pid,
const char * component,
qosspec_t qs)
{
- struct reg_ipcp * ipcp;
+ struct reg_ipcp * ipcp;
+ struct ipcp_info * info;
pthread_rwlock_rdlock(&irmd.reg_lock);
@@ -727,7 +739,9 @@ int connect_ipcp(pid_t pid,
return -EIPCP;
}
- if (ipcp->type != IPCP_UNICAST && ipcp->type != IPCP_BROADCAST) {
+ info = &ipcp->info;
+
+ if (info->type != IPCP_UNICAST && info->type != IPCP_BROADCAST) {
pthread_rwlock_unlock(&irmd.reg_lock);
log_err("Cannot establish connections for this IPCP type.");
return -EIPCP;
@@ -752,7 +766,8 @@ static int disconnect_ipcp(pid_t pid,
const char * dst,
const char * component)
{
- struct reg_ipcp * ipcp;
+ struct reg_ipcp * ipcp;
+ struct ipcp_info * info;
pthread_rwlock_rdlock(&irmd.reg_lock);
@@ -763,7 +778,9 @@ static int disconnect_ipcp(pid_t pid,
return -EIPCP;
}
- if (ipcp->type != IPCP_UNICAST && ipcp->type != IPCP_BROADCAST) {
+ info = &ipcp->info;
+
+ if (info->type != IPCP_UNICAST && info->type != IPCP_BROADCAST) {
pthread_rwlock_unlock(&irmd.reg_lock);
log_err("Cannot tear down connections for this IPCP type.");
return -EIPCP;
@@ -949,7 +966,7 @@ static int get_ipcp_info(ipcp_list_msg_t ** msg,
ipcp_list_msg__init(*msg);
- (*msg)->name = strdup(ipcp->name);
+ (*msg)->name = strdup(ipcp->info.name);
if ((*msg)->name == NULL)
goto fail_name;
@@ -959,7 +976,7 @@ static int get_ipcp_info(ipcp_list_msg_t ** msg,
goto fail_layer;
(*msg)->pid = ipcp->pid;
- (*msg)->type = ipcp->type;
+ (*msg)->type = ipcp->info.type;
return 0;
@@ -2057,6 +2074,7 @@ static void free_msg(void * o)
static irm_msg_t * do_command_msg(irm_msg_t * msg)
{
struct ipcp_config conf;
+ struct ipcp_info info;
irm_msg_t * ret_msg;
buffer_t data;
struct reg_flow f;
@@ -2094,7 +2112,8 @@ static irm_msg_t * do_command_msg(irm_msg_t * msg)
switch (msg->code) {
case IRM_MSG_CODE__IRM_CREATE_IPCP:
- res = create_ipcp(msg->name, msg->ipcp_type);
+ info = ipcp_info_msg_to_s(msg->ipcp_info);
+ res = create_ipcp(&info);
break;
case IRM_MSG_CODE__IPCP_CREATE_R:
res = create_ipcp_r(msg->pid, msg->result);
diff --git a/src/irmd/reg/ipcp.c b/src/irmd/reg/ipcp.c
index 62505871..f64bb5a4 100644
--- a/src/irmd/reg/ipcp.c
+++ b/src/irmd/reg/ipcp.c
@@ -42,8 +42,7 @@
#include <stdlib.h>
#include <string.h>
-struct reg_ipcp * reg_ipcp_create(const char * name,
- enum ipcp_type type)
+struct reg_ipcp * reg_ipcp_create(const struct ipcp_info * info)
{
struct reg_ipcp * ipcp;
pthread_condattr_t cattr;
@@ -63,22 +62,17 @@ struct reg_ipcp * reg_ipcp_create(const char * name,
if (pthread_cond_init(&ipcp->cond, &cattr))
goto fail_cond;
- ipcp->name = strdup(name);
- if (ipcp->name == NULL)
- goto fail_name;
+ memcpy(&ipcp->info, info, sizeof(*info));
pthread_condattr_destroy(&cattr);
ipcp->layer = NULL;
- ipcp->type = type;
ipcp->state = IPCP_BOOT;
list_head_init(&ipcp->next);
return ipcp;
- fail_name:
- pthread_cond_destroy(&ipcp->cond);
fail_cond:
pthread_condattr_destroy(&cattr);
fail_cattr:
@@ -99,7 +93,6 @@ void reg_ipcp_destroy(struct reg_ipcp * ipcp)
pthread_cond_wait(&ipcp->cond, &ipcp->mtx);
free(ipcp->layer);
- free(ipcp->name);
pthread_mutex_unlock(&ipcp->mtx);
diff --git a/src/irmd/reg/ipcp.h b/src/irmd/reg/ipcp.h
index 8ad334cf..3757aff4 100644
--- a/src/irmd/reg/ipcp.h
+++ b/src/irmd/reg/ipcp.h
@@ -34,9 +34,9 @@ enum ipcp_state {
struct reg_ipcp {
struct list_head next;
- char * name;
+ struct ipcp_info info;
+
pid_t pid;
- enum ipcp_type type;
enum hash_algo dir_hash_algo;
char * layer;
@@ -45,8 +45,7 @@ struct reg_ipcp {
pthread_mutex_t mtx;
};
-struct reg_ipcp * reg_ipcp_create(const char * name,
- enum ipcp_type type);
+struct reg_ipcp * reg_ipcp_create(const struct ipcp_info * info);
void reg_ipcp_destroy(struct reg_ipcp * i);
diff --git a/src/lib/irm.c b/src/lib/irm.c
index 4c744e8a..ce646ae7 100644
--- a/src/lib/irm.c
+++ b/src/lib/irm.c
@@ -41,17 +41,19 @@
pid_t irm_create_ipcp(const char * name,
enum ipcp_type type)
{
- irm_msg_t msg = IRM_MSG__INIT;
- irm_msg_t * recv_msg = NULL;
- int ret = -1;
+ irm_msg_t msg = IRM_MSG__INIT;
+ irm_msg_t * recv_msg;
+ int ret;
+ struct ipcp_info info;
- if (name == NULL)
+ if (name == NULL || strlen(name) > IPCP_NAME_SIZE)
return -EINVAL;
- msg.code = IRM_MSG_CODE__IRM_CREATE_IPCP;
- msg.name = (char *) name;
- msg.has_ipcp_type = true;
- msg.ipcp_type = type;
+ info.type = type;
+ strcpy(info.name, name);
+
+ msg.code = IRM_MSG_CODE__IRM_CREATE_IPCP;
+ msg.ipcp_info = ipcp_info_s_to_msg(&info);
recv_msg = send_recv_irm_msg(&msg);
if (recv_msg == NULL)
diff --git a/src/lib/pb/irm.proto b/src/lib/pb/irm.proto
index f910baeb..94db28a4 100644
--- a/src/lib/pb/irm.proto
+++ b/src/lib/pb/irm.proto
@@ -53,6 +53,11 @@ enum irm_msg_code {
IRM_REPLY = 25;
}
+message ipcp_info_msg {
+ required uint32 type = 1;
+ required string name = 2;
+}
+
message ipcp_list_msg {
required uint32 pid = 1;
required uint32 type = 2;
@@ -66,26 +71,26 @@ message name_info_msg {
}
message irm_msg {
- required irm_msg_code code = 1;
- optional string prog = 2;
- optional sint32 pid = 3;
- optional string name = 4;
- optional uint32 ipcp_type = 5;
- optional string layer = 6;
- repeated string args = 7;
- optional sint32 response = 8;
- optional string dst = 9;
- optional bytes hash = 10;
- optional sint32 flow_id = 11;
- optional qosspec_msg qosspec = 12;
- optional ipcp_config_msg conf = 13;
- optional uint32 opts = 14;
- repeated ipcp_list_msg ipcps = 15;
- repeated name_info_msg names = 16;
- optional uint32 timeo_sec = 17;
- optional uint32 timeo_nsec = 18;
- optional sint32 mpl = 19;
- optional string comp = 20;
- optional bytes pk = 21; /* piggyback */
- optional sint32 result = 22;
+ required irm_msg_code code = 1;
+ optional string prog = 2;
+ optional sint32 pid = 3;
+ optional string name = 4;
+ optional ipcp_info_msg ipcp_info = 5;
+ optional string layer = 6;
+ repeated string args = 7;
+ optional sint32 response = 8;
+ optional string dst = 9;
+ optional bytes hash = 10;
+ optional sint32 flow_id = 11;
+ optional qosspec_msg qosspec = 12;
+ optional ipcp_config_msg conf = 13;
+ optional uint32 opts = 14;
+ repeated ipcp_list_msg ipcps = 15;
+ repeated name_info_msg names = 16;
+ optional uint32 timeo_sec = 17;
+ optional uint32 timeo_nsec = 18;
+ optional sint32 mpl = 19;
+ optional string comp = 20;
+ optional bytes pk = 21; /* piggyback */
+ optional sint32 result = 22;
}
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;