diff options
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/ipcp_config.proto | 42 | ||||
-rw-r--r-- | src/lib/irm.c | 70 |
2 files changed, 60 insertions, 52 deletions
diff --git a/src/lib/ipcp_config.proto b/src/lib/ipcp_config.proto index 812d909b..c6481b09 100644 --- a/src/lib/ipcp_config.proto +++ b/src/lib/ipcp_config.proto @@ -27,24 +27,36 @@ message layer_info_msg { required uint32 dir_hash_algo = 2; } +message dt_config_msg { + required uint32 addr_size = 1; + required uint32 eid_size = 2; + required uint32 max_ttl = 3; + required uint32 routing_type = 4; +} + +message uni_config_msg { + required dt_config_msg dt = 1; + required uint32 addr_auth_type = 2; + required uint32 cong_avoid = 3; +} + +message eth_config_msg { + required string dev = 1; + optional uint32 ethertype = 2; +} + +message udp_config_msg { + required uint32 ip_addr = 1; + required uint32 port = 2; + required uint32 dns_addr = 3; /* set to 0 if unused */ +} + message ipcp_config_msg { required layer_info_msg layer_info = 1; required int32 ipcp_type = 2; - // Config for unicast IPCP - optional uint32 addr_size = 3; - optional uint32 eid_size = 4; - optional uint32 max_ttl = 5; - optional uint32 addr_auth_type = 6; - optional uint32 routing_type = 7; - optional uint32 cong_avoid = 8; - // Config for UDP - optional uint32 ip_addr = 9; - optional uint32 dns_addr = 10; - optional uint32 port = 11; - // Config for the Ethernet - optional string dev = 12; - // Config for DIX Ethernet - optional uint32 ethertype = 13; + optional uni_config_msg unicast = 3; + optional udp_config_msg udp = 4; + optional eth_config_msg eth = 5; } enum enroll_code { diff --git a/src/lib/irm.c b/src/lib/irm.c index dbc1c556..2a8aa05c 100644 --- a/src/lib/irm.c +++ b/src/lib/irm.c @@ -98,11 +98,15 @@ int irm_destroy_ipcp(pid_t pid) int irm_bootstrap_ipcp(pid_t pid, const struct ipcp_config * conf) { - irm_msg_t msg = IRM_MSG__INIT; - ipcp_config_msg_t config = IPCP_CONFIG_MSG__INIT; - layer_info_msg_t layer_info = LAYER_INFO_MSG__INIT; - irm_msg_t * recv_msg = NULL; - int ret = -1; + irm_msg_t msg = IRM_MSG__INIT; + ipcp_config_msg_t cfg_msg = IPCP_CONFIG_MSG__INIT; + layer_info_msg_t layer_info_msg = LAYER_INFO_MSG__INIT; + dt_config_msg_t dt_cfg_msg = DT_CONFIG_MSG__INIT; + uni_config_msg_t uni_cfg_msg = UNI_CONFIG_MSG__INIT; + eth_config_msg_t eth_cfg_msg = ETH_CONFIG_MSG__INIT; + udp_config_msg_t udp_cfg_msg = UDP_CONFIG_MSG__INIT; + irm_msg_t * recv_msg = NULL; + int ret = -1; if (pid == -1 || conf == NULL) return -EINVAL; @@ -111,54 +115,46 @@ int irm_bootstrap_ipcp(pid_t pid, msg.has_pid = true; msg.pid = pid; - config.layer_info = &layer_info; - msg.conf = &config; - layer_info.layer_name = (char *) conf->layer_info.layer_name; - - config.ipcp_type = conf->type; - - if (conf->type != IPCP_UDP) - layer_info.dir_hash_algo = conf->layer_info.dir_hash_algo; + cfg_msg.ipcp_type = conf->type; + layer_info_msg.layer_name = (char *) conf->layer_info.layer_name; + layer_info_msg.dir_hash_algo = conf->layer_info.dir_hash_algo; switch (conf->type) { case IPCP_UNICAST: - config.has_addr_size = true; - config.addr_size = conf->addr_size; - config.has_eid_size = true; - config.eid_size = conf->eid_size; - config.has_max_ttl = true; - config.max_ttl = conf->max_ttl; - config.has_addr_auth_type = true; - config.addr_auth_type = conf->addr_auth_type; - config.has_routing_type = true; - config.routing_type = conf->routing_type; - config.has_cong_avoid = true; - config.cong_avoid = conf->cong_avoid; + dt_cfg_msg.addr_size = conf->unicast.dt.addr_size; + dt_cfg_msg.eid_size = conf->unicast.dt.eid_size; + dt_cfg_msg.max_ttl = conf->unicast.dt.max_ttl; + dt_cfg_msg.routing_type = conf->unicast.dt.routing_type; + uni_cfg_msg.dt = &dt_cfg_msg; + uni_cfg_msg.addr_auth_type = conf->unicast.addr_auth_type; + uni_cfg_msg.cong_avoid = conf->unicast.cong_avoid; + cfg_msg.unicast = &uni_cfg_msg; break; case IPCP_UDP: - config.has_ip_addr = true; - config.ip_addr = conf->ip_addr; - config.has_dns_addr = true; - config.dns_addr = conf->dns_addr; - config.has_port = true; - config.port = conf->port; + udp_cfg_msg.ip_addr = conf->udp.ip_addr; + udp_cfg_msg.dns_addr = conf->udp.dns_addr; + udp_cfg_msg.port = conf->udp.port; + cfg_msg.udp = &udp_cfg_msg; break; case IPCP_LOCAL: /* FALLTHRU */ case IPCP_BROADCAST: break; - case IPCP_ETH_LLC: - config.dev = conf->dev; - break; case IPCP_ETH_DIX: - config.dev = conf->dev; - config.has_ethertype = true; - config.ethertype = conf->ethertype; + eth_cfg_msg.has_ethertype = true; + eth_cfg_msg.ethertype = conf->eth.ethertype; + /* FALLTHRU */ + case IPCP_ETH_LLC: + eth_cfg_msg.dev = conf->eth.dev; + cfg_msg.eth = ð_cfg_msg; break; default: return -EIPCPTYPE; } + cfg_msg.layer_info = &layer_info_msg; + msg.conf = &cfg_msg; + recv_msg = send_recv_irm_msg(&msg); if (recv_msg == NULL) return -EIRMD; |