diff options
author | Dimitri Staessens <[email protected]> | 2016-04-11 17:02:55 +0200 |
---|---|---|
committer | Dimitri Staessens <[email protected]> | 2016-04-11 17:02:55 +0200 |
commit | dbe01cb34001f06519a42e9c21d144f52e7d8758 (patch) | |
tree | 046635cd3ca941f0debad37fa0865357b5b62a41 /src/lib | |
parent | 1d5c9ae5c7c77f200e9670bbee714adad983136e (diff) | |
parent | 9906ac98c45530e530d7aa439937aedf526c3508 (diff) | |
download | ouroboros-dbe01cb34001f06519a42e9c21d144f52e7d8758.tar.gz ouroboros-dbe01cb34001f06519a42e9c21d144f52e7d8758.zip |
Merged in sandervrijders/ouroboros/be (pull request #54)
Dif config now correctly passed to the IPCP
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/CMakeLists.txt | 6 | ||||
-rw-r--r-- | src/lib/dif_config.proto | 16 | ||||
-rw-r--r-- | src/lib/ipcp.c | 16 | ||||
-rw-r--r-- | src/lib/ipcpd_messages.proto | 4 | ||||
-rw-r--r-- | src/lib/irm.c | 43 | ||||
-rw-r--r-- | src/lib/irmd_messages.proto | 21 |
6 files changed, 82 insertions, 24 deletions
diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index 1f7b0f55..c2d1bcc7 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -8,6 +8,8 @@ find_package(ProtobufC REQUIRED) include_directories(${PROTOBUF_INCLUDE_DIRS}) protobuf_generate_c(IRM_PROTO_SRCS IRM_PROTO_HDRS irmd_messages.proto) protobuf_generate_c(IPCP_PROTO_SRCS IPCP_PROTO_HDRS ipcpd_messages.proto) +protobuf_generate_c(DIF_CONFIG_PROTO_SRCS DIF_CONFIG_PROTO_HDRS + dif_config.proto) find_library(LIBRT_LIBRARIES rt) if(NOT LIBRT_LIBRARIES) @@ -36,11 +38,11 @@ set(SOURCE_FILES utils.c ) -install(FILES ${IRM_PROTO_HDRS} ${IPCP_PROTO_HDRS} +install(FILES ${IRM_PROTO_HDRS} ${IPCP_PROTO_HDRS} ${DIF_CONFIG_PROTO_HDRS} DESTINATION include/ouroboros) add_library(ouroboros SHARED ${SOURCE_FILES} - ${IRM_PROTO_SRCS} ${IPCP_PROTO_SRCS}) + ${IRM_PROTO_SRCS} ${IPCP_PROTO_SRCS} ${DIF_CONFIG_PROTO_SRCS}) target_link_libraries(ouroboros ${LIBRT_LIBRARIES} ${LIBPTHREAD_LIBRARIES} ${PROTOBUF_C_LIBRARY}) diff --git a/src/lib/dif_config.proto b/src/lib/dif_config.proto new file mode 100644 index 00000000..87cb222f --- /dev/null +++ b/src/lib/dif_config.proto @@ -0,0 +1,16 @@ +message dif_config_msg { + required string dif_name = 1; + required int32 ipcp_type = 2; + // Config for normal IPCP + optional uint32 addr_size = 3; + optional uint32 cep_id_size = 4; + optional uint32 pdu_length_size = 5; + optional uint32 qos_id_size = 6; + optional uint32 seqno_size = 7; + optional uint32 ttl_size = 8; + optional uint32 chk_size = 9; + optional uint32 min_pdu_size = 10; + optional uint32 max_pdu_size = 11; + // Config for shim UDP + optional uint32 ip_addr = 12; +}
\ No newline at end of file diff --git a/src/lib/ipcp.c b/src/lib/ipcp.c index d61fcb50..a0febe4e 100644 --- a/src/lib/ipcp.c +++ b/src/lib/ipcp.c @@ -100,7 +100,7 @@ static ipcp_msg_t * send_recv_ipcp_msg(pid_t pid, } pid_t ipcp_create(instance_name_t * api, - char * ipcp_type) + enum ipcp_type ipcp_type) { pid_t pid = 0; char * api_id = NULL; @@ -108,11 +108,6 @@ pid_t ipcp_create(instance_name_t * api, char * ipcp_dir = "bin/ipcpd"; char * full_name = NULL; - if (ipcp_type == NULL) - return -1; - - LOG_DBG("%lu", _POSIX_C_SOURCE); - pid = fork(); if (pid == -1) { LOG_ERR("Failed to fork"); @@ -146,7 +141,7 @@ pid_t ipcp_create(instance_name_t * api, char * argv[] = {full_name, api->name, api_id, - ipcp_type, 0}; + 0}; char * envp[] = {0}; @@ -241,14 +236,19 @@ int ipcp_unreg(pid_t pid, return ret; } + int ipcp_bootstrap(pid_t pid, - struct dif_config * conf) + dif_config_msg_t * conf) { ipcp_msg_t msg = IPCP_MSG__INIT; ipcp_msg_t * recv_msg = NULL; int ret = -1; + if (conf == NULL) + return -EINVAL; + msg.code = IPCP_MSG_CODE__IPCP_BOOTSTRAP; + msg.conf = conf; recv_msg = send_recv_ipcp_msg(pid, &msg); if (recv_msg == NULL) diff --git a/src/lib/ipcpd_messages.proto b/src/lib/ipcpd_messages.proto index bcdd54ae..b83c34c7 100644 --- a/src/lib/ipcpd_messages.proto +++ b/src/lib/ipcpd_messages.proto @@ -1,3 +1,5 @@ +import "dif_config.proto"; + enum ipcp_msg_code { IPCP_BOOTSTRAP = 1; IPCP_ENROLL = 2; @@ -14,7 +16,7 @@ enum ipcp_msg_code { message ipcp_msg { required ipcp_msg_code code = 1; optional string ap_name = 2; - // Missing dif_config field here + optional dif_config_msg conf = 3; repeated string dif_name = 4; optional int32 result = 5; optional uint32 port_id = 6; diff --git a/src/lib/irm.c b/src/lib/irm.c index 7c187be1..70b7b3a5 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 IPCP_NORMAL: + 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 IPCP_SHIM_UDP: + 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); diff --git a/src/lib/irmd_messages.proto b/src/lib/irmd_messages.proto index 44070755..3a2432f3 100644 --- a/src/lib/irmd_messages.proto +++ b/src/lib/irmd_messages.proto @@ -1,3 +1,5 @@ +import "dif_config.proto"; + enum irm_msg_code { IRM_CREATE_IPCP = 1; IRM_DESTROY_IPCP = 2; @@ -26,14 +28,13 @@ message irm_msg { optional string ap_name = 2; optional uint32 api_id = 3; optional string ae_name = 4; - optional string ipcp_type = 5; - // Missing dif_config field here - repeated string dif_name = 7; - optional int32 fd = 8; - optional int32 result = 9; - // Missing qos_spec here - optional int32 oflags = 10; - optional string dst_ap_name = 11; - optional uint32 port_id = 12; - optional int32 pid = 13; + optional uint32 ipcp_type = 5; + repeated string dif_name = 6; + optional int32 fd = 7; + optional int32 result = 8; + optional int32 oflags = 9; + optional string dst_ap_name = 10; + optional uint32 port_id = 11; + optional int32 pid = 12; + optional dif_config_msg conf = 13; }; |