Exemplo n.º 1
0
        public static string GetGatewayAddress(string ip, string mask)
        {
            byte fb  = (byte)(IPCon.FirstByte(ip) & IPCon.FirstByte(mask));
            byte sb  = (byte)(IPCon.SecondByte(ip) & IPCon.SecondByte(mask));
            byte tb  = (byte)(IPCon.ThirdByte(ip) & IPCon.ThirdByte(mask));
            byte fob = (byte)((IPCon.FourthByte(ip) & IPCon.FourthByte(mask)) + 1);

            return(IPCon.BytesToIP(fb, sb, tb, fob));
        }
Exemplo n.º 2
0
        public static string GetBroadcastAddress(string ip, string mask)
        {
            string nwa = GetNetworkAddress(ip, mask);
            byte   fb  = (byte)(~(IPCon.FirstByte(mask)) | (IPCon.FirstByte(nwa)));
            byte   sb  = (byte)(~(IPCon.SecondByte(mask)) | (IPCon.SecondByte(nwa)));
            byte   tb  = (byte)(~(IPCon.ThirdByte(mask)) | (IPCon.ThirdByte(nwa)));
            byte   fob = (byte)(~(IPCon.FourthByte(mask)) | (IPCon.FourthByte(nwa)));

            return(IPCon.BytesToIP(fb, sb, tb, fob));
        }
Exemplo n.º 3
0
 public static byte[] GetBytes(string ip)
 {
     byte[] bytes = { IPCon.FirstByte(ip), IPCon.SecondByte(ip), IPCon.ThirdByte(ip), IPCon.FourthByte(ip) };
     return(bytes);
 }