diff options
author | Sander Vrijders <sander.vrijders@intec.ugent.be> | 2016-04-08 16:32:35 +0200 |
---|---|---|
committer | Sander Vrijders <sander.vrijders@intec.ugent.be> | 2016-04-08 16:36:39 +0200 |
commit | 6ad0fcf2f32f412091d0dfd58da1d8f5dc474809 (patch) | |
tree | eb10657a977c7c4c410ae15216d4068535a9f058 /src/lib/irm.c | |
parent | affea724d1810410186b10c93c64b7a8ddbe7aca (diff) | |
download | ouroboros-6ad0fcf2f32f412091d0dfd58da1d8f5dc474809.tar.gz ouroboros-6ad0fcf2f32f412091d0dfd58da1d8f5dc474809.zip |
lib, irmd, irm: Add dif_config
This adds dif_config to the prototype, in which one is able to specify
the parameters a DIF should have. The bootstrap operation of an IPCP
takes this as parameter and is oblivious to whether it is a shim or a
normal IPCP. The dif_config struct is also correctly serialized and
deserialized and passed opaquely to the correct IPCP. This IPCP is in
charge of deserializing it correctly.
Diffstat (limited to 'src/lib/irm.c')
-rw-r--r-- | src/lib/irm.c | 43 |
1 files changed, 40 insertions, 3 deletions
diff --git a/src/lib/irm.c b/src/lib/irm.c index 7c187be1..3078e158 100644 --- a/src/lib/irm.c +++ b/src/lib/irm.c @@ -31,13 +31,13 @@ #include <stdlib.h> int irm_create_ipcp(instance_name_t * api, - char * ipcp_type) + enum ipcp_type ipcp_type) { irm_msg_t msg = IRM_MSG__INIT; irm_msg_t * recv_msg = NULL; int ret = -1; - if (api == NULL || ipcp_type == NULL || api->name == NULL) + if (api == NULL || api->name == NULL) return -EINVAL; msg.code = IRM_MSG_CODE__IRM_CREATE_IPCP; @@ -94,6 +94,7 @@ int irm_bootstrap_ipcp(instance_name_t * api, struct dif_config * conf) { irm_msg_t msg = IRM_MSG__INIT; + dif_config_msg_t config = DIF_CONFIG_MSG__INIT; irm_msg_t * recv_msg = NULL; int ret = -1; @@ -105,9 +106,45 @@ int irm_bootstrap_ipcp(instance_name_t * api, msg.has_api_id = true; msg.api_id = api->id; + msg.conf = &config; + config.dif_name = conf->dif_name; + config.ipcp_type = conf->type; + + switch (conf->type) { + case NORMAL_IPCP: + config.has_addr_size = true; + config.has_cep_id_size = true; + config.has_pdu_length_size = true; + config.has_qos_id_size = true; + config.has_seqno_size = true; + config.has_ttl_size = true; + config.has_chk_size = true; + config.has_min_pdu_size = true; + config.has_max_pdu_size = true; + + config.addr_size = conf->addr_size; + config.cep_id_size = conf->cep_id_size; + config.pdu_length_size = conf->pdu_length_size; + config.qos_id_size = conf->qos_id_size; + config.seqno_size = conf->seqno_size; + config.ttl_size = conf->ttl_size; + config.chk_size = conf->chk_size; + config.min_pdu_size = conf->min_pdu_size; + config.max_pdu_size = conf->max_pdu_size; + break; + case SHIM_UDP_IPCP: + config.has_ip_addr = true; + + config.ip_addr = conf->ip_addr; + break; + default: + return -1; + } + recv_msg = send_recv_irm_msg(&msg); - if (recv_msg == NULL) + if (recv_msg == NULL) { return -1; + } if (recv_msg->has_result == false) { irm_msg__free_unpacked(recv_msg, NULL); |