From 071dd2c070e219005d103f7efbbbc9c36b5d25c9 Mon Sep 17 00:00:00 2001 From: Arne Sund Date: Wed, 18 Mar 2015 22:17:11 +0100 Subject: Changed mgmt_ipv6 structure --- planning/planning.cpp | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) (limited to 'planning/planning.cpp') diff --git a/planning/planning.cpp b/planning/planning.cpp index ac2e10d..7a499ad 100644 --- a/planning/planning.cpp +++ b/planning/planning.cpp @@ -326,6 +326,22 @@ string port_name(unsigned distro, unsigned portnum) return buf; } +char oct_to_letter(unsigned oct) +{ + if(oct == 0) { + return 'a'; + } + else if(oct == 64) { + return 'b'; + } + else if(oct == 128) { + return 'c'; + } + else { + return 'd'; + } +} + void Planner::init_switches() { switches.clear(); @@ -714,26 +730,12 @@ int Planner::do_work(int distro_placements[NUM_DISTRO]) unsigned int fourth_oct = ntohl(subnet_address) % 256; unsigned int fourth_oct_mgmt = ntohl(distro_mgmt_ip[distro]) % 256; - char fourth; - if(fourth_oct == 0) { - fourth = 'a'; - } - else if(fourth_oct == 64) { - fourth = 'b'; - } - else if(fourth_oct == 128) { - fourth = 'c'; - } - else { - fourth = 'd'; - } - // fprintf(switchlist, "e%u-%u %s/%u %s%u%c::/64 ",switches[i].row * 2 - 1, switches[i].num + 1, - inet_ntoa(subnet_addr4), SUBNET_SIZE, IPV6_PREFIX, third_oct, fourth); + inet_ntoa(subnet_addr4), SUBNET_SIZE, IPV6_PREFIX, third_oct, oct_to_letter(fourth_oct)); - fprintf(switchlist, "%s/26 %s%u:%u::%u/64 1%02u%u %s\n", - inet_ntoa(mgmt_ip4), IPV6_PREFIX, third_oct_mgmt, (fourth_oct_mgmt / 64) * 64, fourth_oct_mgmt, + fprintf(switchlist, "%s/26 %s%u%c::%u/64 1%02u%u %s\n", + inet_ntoa(mgmt_ip4), IPV6_PREFIX, third_oct_mgmt, oct_to_letter((fourth_oct_mgmt / 64) * 64), fourth_oct_mgmt, switches[i].row * 2 - 1, switches[i].num + 1, distro_name(distro).c_str()); subnet_address = htonl(ntohl(subnet_address) + (1ULL << (32 - SUBNET_SIZE))); -- cgit v1.2.3