~ubuntu-branches/debian/stretch/assaultcube-data/stretch

« back to all changes in this revision

Viewing changes to source/CubeMS/App_Code/IPTools.cs

  • Committer: Bazaar Package Importer
  • Author(s): Gonéri Le Bouder, Ansgar Burchardt, Gonéri Le Bouder
  • Date: 2010-04-02 23:37:55 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20100402233755-kf74fxwlu634o6vg
Tags: 1.0.4+repack1-1
[ Ansgar Burchardt ]
* debian/control: fix typo in short description

[ Gonéri Le Bouder ]
* Upgrade to 1.0.4
* bump standards-version to 3.8.4
* Add Depends: ${misc:Depends} just to avoid a lintian warning
* Add a debian/source/format file for the same reason

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
using System;
 
2
using System.Data;
 
3
using System.Configuration;
 
4
using System.Web;
 
5
using System.Web.Security;
 
6
using System.Web.UI;
 
7
using System.Web.UI.WebControls;
 
8
using System.Web.UI.WebControls.WebParts;
 
9
using System.Web.UI.HtmlControls;
 
10
 
 
11
using System.Net;
 
12
 
 
13
/// <summary>
 
14
/// Summary description for IPTools
 
15
/// </summary>
 
16
public static class IPTools
 
17
{
 
18
    public static int IPToInt(IPAddress address)
 
19
    {
 
20
        byte[] ip = address.GetAddressBytes();
 
21
        if(ip.Length == 4) return (int)(ip[0] | (ip[1] << 8) | (ip[2] << 16) | (ip[3] << 24));
 
22
        else return 0;
 
23
    }
 
24
 
 
25
    public static IPAddress IntToIp(int address)
 
26
    {
 
27
        byte[] octets = { (byte)(address & 0xFF), (byte)((address >> 8) & 0xFF), (byte)((address >> 16) & 0xFF), (byte)((address >> 24) & 0xFF) };
 
28
        return new IPAddress(octets);
 
29
    }
 
30
}