func GetIPs(cidr string, num int) ([]string, error) {
	ips, err := getAllIPsfromCIDR(cidr)
	if err != nil {
		return nil, err
	}
	if num < 0 {
		return ips, nil
	}
	return ips[0:num], nil
}
GetIPs will get IP address from a CIDR notation
Return an array with IP address. negative num for getting all IP addresses
(network address and broadcast address are not included)
package tinynet
import (
	"fmt"
	log "github.com/sirupsen/logrus"
)
type HostConfig struct {
	name      string
	address   string
	docker    bool
	ifaceName string
	imageRef  string
	mtu       int
}
func NewHostConfig(name, addr, ifaceName string, mtu int, docker bool, imageRef string) HostConfig {
	hostConfig := HostConfig{}
	if name == "" {
		panic("Host name is required")
	}
	if addr == "" {
		panic("Host address is required")
	}
	hostConfig.name = name
	hostConfig.address = addr
	hostConfig.docker = docker
	hostConfig.ifaceName = ifaceName
	if ifaceName == "" {
		hostConfig.ifaceName = "eth1"
	}
	hostConfig.imageRef = imageRef
	if imageRef == "" {
		hostConfig.imageRef = "library/busybox"
	}
	hostConfig.mtu = mtu
	if mtu == 0 {
		hostConfig.mtu = 1500
	}
	return hostConfig
}
func AddHostWithConf(hc HostConfig) (*Host, error) {
	var h *Host
	var err error
	if hc.docker {
		h, err = NewContainer(hc.name, hc.imageRef)
		if err != nil {
			log.Fatal("failed to NewContainer: ", err)
		}
	} else {
		h, err = NewHost(hc.name)
		if err != nil {
			log.Fatal("failed to NewHost: ", err)
		}
	}
	_, err = h.setupVeth(hc.ifaceName, hc.mtu)
	if err != nil {
		log.Fatal("failed to setup veth pair: ", err)
	}
	h.setIfaceIP(hc.address)
	if err != nil {
		log.Fatalf("failed to setIfaceIP for %s: %v", h.Name, err)
		return nil, err
	}
	return h, nil
}
func AddHost(name string, addr string, docker bool) (*Host, error) {
	log.Warnf("AddHost will be deprecated: use AddHostWithConf instead")
	var h *Host
	var err error
	if docker {
		h, err = NewContainer(name, "library/busybox")
		if err != nil {
			log.Fatal("failed to NewContainer: ", err)
		}
	} else {
		h, err = NewHost(name)
		if err != nil {
			log.Fatal("failed to NewHost: ", err)
		}
	}
	_, err = h.setupVeth("eth2", 1500)
	if err != nil {
		log.Fatal("failed to setup veth pair: ", err)
	}
	h.setIfaceIP(addr)
	if err != nil {
		log.Fatalf("failed to setIfaceIP for %s: %v", h.Name, err)
		return nil, err
	}
	return h, nil
}
func AddSwitch(params ...string) (*OVSSwitch, error) {
	sw, err := NewOVSSwitch(params[0])
	if err != nil {
		log.Fatal("failed to NewOVSSwitch: ", err)
	}
	if len(params) == 2 {
		if err := sw.SetCtrl(params[1]); err != nil {
			log.Warnf("failed to SetCtrl for %s: %v", sw.BridgeName, err)
			return nil, err
		}
	} else if len(params) > 2 {
		return nil, fmt.Errorf("Too many arguments")
	}
	return sw, nil
}
func AddLink(n1, n2 interface{}) error {
	var err error
	switch n1.(type) {
	case *OVSSwitch:
		switch n2.(type) {
		case *OVSSwitch:
			tap0, tap1, err := makeVethPair("tap0", "tap1")
			if err != nil {
				log.Fatalf("failed to makeVethPair: %v", err)
			}
			err = n1.(*OVSSwitch).addPort(tap0.Name)
			if err != nil {
				log.Fatalf("failed to addPortswitch - switch: %v", err)
			}
			err = n2.(*OVSSwitch).addPort(tap1.Name)
			if err != nil {
				log.Fatalf("failed to addPort switch - switch: %v", err)
			}
			log.Infof("Adding a link: (%s, %s)", n1.(*OVSSwitch).BridgeName, n2.(*OVSSwitch).BridgeName)
		case *Host:
			err = n1.(*OVSSwitch).addPort(n2.(*Host).VethName)
			if err != nil {
				log.Fatalf("failed to addPort switch - host: %v", err)
			}
			log.Infof("Adding a link: (%s, %s)", n1.(*OVSSwitch).BridgeName, n2.(*Host).Name)
		default:
			log.Fatalf("Type Error")
		}
	case *Host:
		switch n2.(type) {
		case *OVSSwitch:
			err = n2.(*OVSSwitch).addPort(n1.(*Host).VethName)
			if err != nil {
				log.Fatalf("failed to addPort host - switch : %v", err)
			}
			log.Infof("Adding a link: (%s, %s)", n1.(*Host).Name, n2.(*OVSSwitch).BridgeName)
		case *Host:
			log.Fatalf("Type Error: host can not connect to host")
		default:
			log.Fatalf("Type Error")
		}
	default:
		log.Fatalf("Type Error")
	}
	return nil
}