diff options
author | Arne Sund <arnels@stortinget.samfundet.no> | 2015-03-18 22:17:11 +0100 |
---|---|---|
committer | Arne Sund <arnels@stortinget.samfundet.no> | 2015-03-18 22:17:11 +0100 |
commit | 071dd2c070e219005d103f7efbbbc9c36b5d25c9 (patch) | |
tree | 0cbe225ce7cd3cc13e3795527889cf815b12c997 /planning | |
parent | c2c7feb03209a7d1c5f12e8e5b40fbf56902a1f8 (diff) |
Changed mgmt_ipv6 structure
Diffstat (limited to 'planning')
-rw-r--r-- | planning/planning.cpp | 36 |
1 files changed, 19 insertions, 17 deletions
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'; - } - //<switch-hostname> <v4-subnet> <v6-subnet> <v4-mgmt> <v6-mgmt> <vlan-id> <distro-hostname> 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))); |