예제 #1
0
 internal static IPAddress GetAddress(FirewallIpVersion ip_version, uint ip_address, byte[] remaining_bytes)
 {
     byte[] full_bytes = new byte[16];
     Array.Copy(BitConverter.GetBytes(ip_address), full_bytes, 4);
     Array.Copy(remaining_bytes, 0, full_bytes, 4, 12);
     return(GetAddress(ip_version, full_bytes));
 }
예제 #2
0
        internal static IPAddress GetAddress(FirewallIpVersion ip_version, byte[] addr_bytes)
        {
            switch (ip_version)
            {
            case FirewallIpVersion.V4:
                return(new IPAddress(BitConverter.ToUInt32(addr_bytes.Take(4).Reverse().ToArray(), 0)));

            case FirewallIpVersion.V6:
                return(new IPAddress(addr_bytes));
            }
            return(IPAddress.None);
        }
예제 #3
0
 internal static IPEndPoint GetEndpoint(FirewallIpVersion ip_version, byte[] addr_bytes, int port)
 {
     return(new IPEndPoint(GetAddress(ip_version, addr_bytes), port));
 }
예제 #4
0
 internal static IPEndPoint GetEndpoint(FirewallIpVersion ip_version, uint ip_address, byte[] remaining_bytes, int port)
 {
     return(new IPEndPoint(GetAddress(ip_version, ip_address, remaining_bytes), port));
 }