+ switch(subnet->type) {
+ case SUBNET_MAC:
+ snprintf(netstr, len, "%x:%x:%x:%x:%x:%x#%d",
+ subnet->net.mac.address.x[0],
+ subnet->net.mac.address.x[1],
+ subnet->net.mac.address.x[2],
+ subnet->net.mac.address.x[3],
+ subnet->net.mac.address.x[4],
+ subnet->net.mac.address.x[5],
+ subnet->weight);
+ break;
+
+ case SUBNET_IPV4:
+ snprintf(netstr, len, "%u.%u.%u.%u/%d#%d",
+ subnet->net.ipv4.address.x[0],
+ subnet->net.ipv4.address.x[1],
+ subnet->net.ipv4.address.x[2],
+ subnet->net.ipv4.address.x[3],
+ subnet->net.ipv4.prefixlength,
+ subnet->weight);
+ break;
+
+ case SUBNET_IPV6:
+ snprintf(netstr, len, "%x:%x:%x:%x:%x:%x:%x:%x/%d#%d",
+ ntohs(subnet->net.ipv6.address.x[0]),
+ ntohs(subnet->net.ipv6.address.x[1]),
+ ntohs(subnet->net.ipv6.address.x[2]),
+ ntohs(subnet->net.ipv6.address.x[3]),
+ ntohs(subnet->net.ipv6.address.x[4]),
+ ntohs(subnet->net.ipv6.address.x[5]),
+ ntohs(subnet->net.ipv6.address.x[6]),
+ ntohs(subnet->net.ipv6.address.x[7]),
+ subnet->net.ipv6.prefixlength,
+ subnet->weight);
+ break;
+
+ default:
+ logger(LOG_ERR,
+ "net2str() was called with unknown subnet type %d, exiting!",
+ subnet->type);
+ exit(0);
+ }
+
+ return true;