Added close() method to stream classes.
[sockstream.git] / include / inetaddress.h
1 /**************************************************************************
2 **  (c) Copyright 2012, Andromeda Technology & Automation
3 ***************************************************************************
4 ** MODULE INFORMATION *
5 ***********************
6 **      FILE NAME      : inetaddress.h
7 **      SYSTEM NAME    : Network and socket classes
8 **      VERSION NUMBER : 0.1
9 **
10 **  DESCRIPTION      :  Internet address class definition
11 **
12 **  EXPORTED OBJECTS : class InternetAddress
13 **  LOCAL    OBJECTS : 
14 **  MODULES  USED    :
15 ***************************************************************************
16 **  ADMINISTRATIVE INFORMATION *
17 ********************************
18 **      ORIGINAL AUTHOR : Arjen Baart - arjen@andromeda.nl
19 **      CREATION DATE   : Mar 02, 2012
20 **      LAST UPDATE     : Mar 02, 2012
21 **      MODIFICATIONS   : 
22 **************************************************************************/
23
24 #ifndef _INETADDRESS_H_
25 #define _INETADDRESS_H_
26
27 #include <arpa/inet.h>
28 #include <netdb.h>
29 #include <AXE/String.h>
30
31 /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
32 **  NAME           : InternetAddress - IPv4 or IPv6 address handling.
33 **  MEMBERS        : af        : The address family, AF_UNSPEC, AF_INET of AF_INET6
34 **                   inet_addr : The address itself, in network byte order.
35 **  OPERATORS      : None
36 **  METHODS        : address_family()
37 **
38 **  DESCRIPTION    : An InternetAddress object holds an IP address which can be
39 **                   either an IPv4 address or an IPv6 address.
40 **                   Its main purpose is to perform the conversion between addresses
41 **                   in network byte order end textual representations of an IP address.
42 **
43 **
44 **  RELATIONS      : 
45 **  SEE ALSO       : inet_pton(3), inet_ntop()
46 **  LAST MODIFIED  : Mar 02, 2012
47 **+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
48 */
49
50 class InternetAddress
51 {
52    int af;
53    unsigned char inet_addr[16];
54
55
56 public:
57
58    InternetAddress()
59    {
60       af = AF_UNSPEC;
61    }
62
63    InternetAddress(const char *);      // InternetAddress x = "127.0.0.1"
64    InternetAddress(const struct addrinfo *);
65    InternetAddress(const struct in6_addr addr);
66    InternetAddress(const struct in_addr addr);
67
68    operator String();
69
70    int address_family()
71    {
72       return af;
73    }
74
75    struct in6_addr get_in6_addr();
76    struct in_addr  get_in_addr();
77 };
78
79 #endif // _INETADDRESS_H_