<commit_before>﻿using System;
using System.Net;
using System.Net.Sockets;
using IPTables.Net.Exceptions;
using IPTables.Net.Supporting;
using LukeSkywalker.IPNetwork;

namespace IPTables.Net.Iptables.DataTypes
{
    public struct IpCidr : IEquatable<IpCidr>
    {
        public static IpCidr Any = new IpCidr(IPAddress.Any, 0);

        public IPAddress Address;
        public uint Cidr;

        public IpCidr(IPAddress address, uint cidr = 32)
        {
            Address = address;
            Cidr = cidr;
        }

        public IPNetwork GetIPNetwork()
        {
            return IPNetwork.Parse(Address, IPNetwork.ToNetmask((byte)Cidr));
        }

        public bool Equals(IpCidr other)
        {
            return other.Address.Equals(Address) && other.Cidr == Cidr;
        }

        public static IpCidr Parse(String cidr)
        {
            string[] p = cidr.Split(new[] {'/'});
            IPAddress ip;
            try
            {<commit_msg>fix IP Cidr defaults for IPv6<commit_after>﻿using System;
using System.Net;
using System.Net.Sockets;
using IPTables.Net.Exceptions;
using IPTables.Net.Supporting;
using LukeSkywalker.IPNetwork;

namespace IPTables.Net.Iptables.DataTypes
{
    public struct IpCidr : IEquatable<IpCidr>
    {
        public static IpCidr Any = new IpCidr(IPAddress.Any, 0);

        public IPAddress Address;
        public uint Cidr;

        public IpCidr(IPAddress address, uint cidr)
        {
            Address = address;
            Cidr = cidr;
        }

        public IpCidr(IPAddress address)
        {
            Address = address;
            Cidr = (address.AddressFamily == AddressFamily.InterNetworkV6) ? (uint)128 : 32;
        }

        public IPNetwork GetIPNetwork()
        {
            return IPNetwork.Parse(Address, IPNetwork.ToNetmask((byte)Cidr));
        }

        public bool Equals(IpCidr other)
        {
            return other.Address.Equals(Address) && other.Cidr == Cidr;
        }

        public static IpCidr Parse(String cidr)
        {
            string[] p = cidr.Split(new[] {'/'});
            IPAddress ip;
            try
            {
{'fraction_non_alphanumeric': 0.09286047596826878, 'fraction_numerical': 0.005132991133924405, 'mean_word_length': 1.9695290858725762, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3387349', 'n_tokens_mistral': 696, 'n_tokens_neox': 669, 'n_words': 146}