func NewCIDRMapOfMapsKeyValue(cidrs []string, cookie Cookie, tt kernel.TrafficType, ipVersion kernel.NetworkProtocol, action interface{}) (*MapOfMapsKeyValue, error) {
	cidrKv := MapOfMapsKeyValue{
		MapOfMapsKey: &KeyValue{
			Key: &CIDRRouterKey{
				TrafficType: tt,
				Cookie:      cookie,
				IPVersion:   ipVersion,
			},
			Value: nil,
		},
		MapSectionToClone: "cidr_ranges",
		Keys:              []*KeyValue{},
	}
	for _, cidr := range cidrs {
		ip, net, err := net.ParseCIDR(cidr)
		if err != nil {
			return nil, errors.Wrapf(err, "couldn't parse CIDR %v", cidr)
		}
		prefix, _ := net.Mask.Size()
		cidrk := CIDRKey{
			Prefix: uint32(prefix),
		}
		switch ipVersion {
		case kernel.EthPIP:
			ip4 := ip.To4()
			if ip4 == nil {
				return nil, errors.New("invalid IPv4 addr")
			}
			copy(cidrk.Data[:], ip4)
		case kernel.EthPIPV6:
			ip6 := ip.To16()
			if ip6 == nil {
				return nil, errors.New("invalid IPv6 addr")
			}
			copy(cidrk.Data[:], ip6)
		}
		cidrkv := KeyValue{
			Key:   &cidrk,
			Value: action,
		}
		cidrKv.Keys = append(cidrKv.Keys, &cidrkv)
	}
	return &cidrKv, nil
}
// NewCIDRMapOfMapsKeyValue - Creates a new MapOfMaps key-value for the provided cidrs
Creates a new MapOfMaps key-value for the provided cidrs
// NewCIDRMapOfMapsKeyValue - Creates a new MapOfMaps key - value for the provided cidrs
func NewCIDRMapOfMapsKeyValue(cidrs []string, cookie Cookie, tt kernel.TrafficType, ipVersion kernel.NetworkProtocol, action interface{}) (*MapOfMapsKeyValue, error) {
	cidrKv := MapOfMapsKeyValue{
		MapOfMapsKey: &KeyValue{
			Key: &CIDRRouterKey{
				TrafficType: tt,
				Cookie:      cookie,
				IPVersion:   ipVersion,
			},
			Value: nil,
		},
		MapSectionToClone: "cidr_ranges",
		Keys:              []*KeyValue{},
	}
	for _, cidr := range cidrs {
		ip, net, err := net.ParseCIDR(cidr)
		if err != nil {
			return nil, errors.Wrapf(err, "couldn't parse CIDR %v", cidr)
		}
		prefix, _ := net.Mask.Size()
		cidrk := CIDRKey{
			Prefix: uint32(prefix),
		}
		switch ipVersion {
		case kernel.EthPIP:
			ip4 := ip.To4()
			if ip4 == nil {
				return nil, errors.New("invalid IPv4 addr")
			}
			copy(cidrk.Data[:], ip4)
		case kernel.EthPIPV6:
			ip6 := ip.To16()
			if ip6 == nil {
				return nil, errors.New("invalid IPv6 addr")
			}
			copy(cidrk.Data[:], ip6)
		}
		cidrkv := KeyValue{
			Key:   &cidrk,
			Value: action,
		}
		cidrKv.Keys = append(cidrKv.Keys, &cidrkv)
	}
	return &cidrKv, nil
}
func NewCIDRMapOfMapsKeyValue ( cidrs [ ] string , cookie Cookie , tt kernel . TrafficType , ipVersion kernel . NetworkProtocol , action interface { } ) ( * MapOfMapsKeyValue , error ) { cidrKv := MapOfMapsKeyValue { MapOfMapsKey : & KeyValue { Key : & CIDRRouterKey { TrafficType : tt , Cookie : cookie , IPVersion : ipVersion , } , Value : nil , } , MapSectionToClone : " " , Keys : [ ] * KeyValue { } , } for _ , cidr := range cidrs { ip , net , err := net . ParseCIDR ( cidr ) if err != nil { return nil , errors . Wrapf ( err , " " , cidr ) } prefix , _ := net . Mask . Size ( ) cidrk := CIDRKey { Prefix : uint32 ( prefix ) , } switch ipVersion { case kernel . EthPIP : ip4 := ip . To4 ( ) if ip4 == nil { return nil , errors . New ( " " ) } copy ( cidrk . Data [ : ] , ip4 ) case kernel . EthPIPV6 : ip6 := ip . To16 ( ) if ip6 == nil { return nil , errors . New ( " " ) } copy ( cidrk . Data [ : ] , ip6 ) } cidrkv := KeyValue { Key : & cidrk , Value : action , } cidrKv . Keys = append ( cidrKv . Keys , & cidrkv ) } return & cidrKv , nil }
Creates a new MapOfMaps key-value for the provided cidrs
Creates a new MapOfMaps key - value for the provided cidrs