summaryrefslogtreecommitdiffstats
path: root/lanbrowsing/lisa/ipaddress.h
blob: ecca928aac222d3dcbac86b573f6770a3ed548a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*    ipaddress.h
 *
 *    Copyright (c) 1998, 1999, Alexander Neundorf, Lukas Pustina
 *    alexander.neundorf@rz.tu-ilmenau.de
 *    lukas@tronet.de
 *
 *    You may distribute under the terms of the GNU General Public
 *    License as specified in the COPYING file.
 *
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 */

#ifndef IPADDRESS_H
#define IPADDRESS_H

#include "lisadefines.h"

#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdlib.h>
#include "mystring.h"

class IPAddress
{
   public:
      IPAddress();
      IPAddress(const MyString& ip);
      IPAddress(unsigned int ip);
      IPAddress(struct in_addr ip);
      IPAddress(int b1, int b2, int b3, int b4);
      //you know
      MyString asString()         {return s;};
      //in host byte order
      unsigned int asInt()      {return i;};
      //in network byte order
      struct in_addr asStruct() {return n;};
      /*operator= (IPAddress ip);
      operator+= (unsigned int add);*/
      void print();
   private:
      MyString int2String(unsigned int ip);
      MyString struct2String(struct in_addr ip);
      unsigned int string2Int(MyString ip);
      struct in_addr string2Struct(MyString ip);
      MyString s;
      unsigned int i;
      struct in_addr n;
};

#endif