libDwm-0.6.0
DwmIpv6Address.hh
Go to the documentation of this file.
1 //===========================================================================
2 // @(#) $DwmPath: dwm/libDwm/tags/libDwm-0.6.0/include/DwmIpv6Address.hh 8401 $
3 // @(#) $Id: DwmIpv6Address.hh 8401 2016-04-17 06:44:31Z dwm $
4 //===========================================================================
5 // Copyright (c) Daniel W. McRobb 2004-2006, 2016
6 // All rights reserved.
7 //
8 // Redistribution and use in source and binary forms, with or without
9 // modification, are permitted provided that the following conditions
10 // are met:
11 //
12 // 1. Redistributions of source code must retain the above copyright
13 // notice, this list of conditions and the following disclaimer.
14 // 2. Redistributions in binary form must reproduce the above copyright
15 // notice, this list of conditions and the following disclaimer in the
16 // documentation and/or other materials provided with the distribution.
17 // 3. The names of the authors and copyright holders may not be used to
18 // endorse or promote products derived from this software without
19 // specific prior written permission.
20 //
21 // IN NO EVENT SHALL DANIEL W. MCROBB BE LIABLE TO ANY PARTY FOR
22 // DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
23 // INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE,
24 // EVEN IF DANIEL W. MCROBB HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
25 // DAMAGE.
26 //
27 // THE SOFTWARE PROVIDED HEREIN IS ON AN "AS IS" BASIS, AND
28 // DANIEL W. MCROBB HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
29 // UPDATES, ENHANCEMENTS, OR MODIFICATIONS. DANIEL W. MCROBB MAKES NO
30 // REPRESENTATIONS AND EXTENDS NO WARRANTIES OF ANY KIND, EITHER
31 // IMPLIED OR EXPRESS, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
32 // WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR
33 // PURPOSE, OR THAT THE USE OF THIS SOFTWARE WILL NOT INFRINGE ANY
34 // PATENT, TRADEMARK OR OTHER RIGHTS.
35 //===========================================================================
36 
37 //---------------------------------------------------------------------------
40 //---------------------------------------------------------------------------
41 
42 #ifndef _DWMIPV6ADDRESS_HH_
43 #define _DWMIPV6ADDRESS_HH_
44 
45 extern "C" {
46 #include <inttypes.h>
47 #include <netinet/in.h>
48 }
49 
50 #include <string>
51 
52 #include "DwmIpAddress.hh"
53 
54 namespace Dwm {
55 
56  //--------------------------------------------------------------------------
58  //--------------------------------------------------------------------------
60  : public IpAddress
61  {
62  public:
63  //------------------------------------------------------------------------
65  //------------------------------------------------------------------------
66  Ipv6Address();
67 
68  //------------------------------------------------------------------------
70  //------------------------------------------------------------------------
71  Ipv6Address(const std::string & addr);
72 
73  //------------------------------------------------------------------------
75  //------------------------------------------------------------------------
76  Ipv6Address & operator = (const std::string & addr);
77 
78  //------------------------------------------------------------------------
80  //------------------------------------------------------------------------
81  Ipv6Address(const struct in6_addr & addr);
82 
83  //------------------------------------------------------------------------
85  //------------------------------------------------------------------------
86  operator std::string () const;
87 
88  //------------------------------------------------------------------------
90  //------------------------------------------------------------------------
91  operator struct in6_addr () const;
92 
93  //------------------------------------------------------------------------
95  //------------------------------------------------------------------------
96  bool operator < (const Ipv6Address & addr) const;
97 
98  //------------------------------------------------------------------------
100  //------------------------------------------------------------------------
101  bool operator > (const Ipv6Address & addr) const;
102 
103  //------------------------------------------------------------------------
105  //------------------------------------------------------------------------
106  bool operator < (const IpAddress & addr) const;
107 
108  //------------------------------------------------------------------------
110  //------------------------------------------------------------------------
111  bool operator == (const Ipv6Address & addr) const;
112 
113  //------------------------------------------------------------------------
115  //------------------------------------------------------------------------
116  Ipv6Address & operator &= (const Ipv6Address & netmask);
117 
118  //------------------------------------------------------------------------
120  //------------------------------------------------------------------------
121  Ipv6Address operator & (const Ipv6Address & netmask) const;
122 
123  //------------------------------------------------------------------------
125  //------------------------------------------------------------------------
126  inline bool IsV6() const
127  {
128  return(true);
129  }
130 
131  //------------------------------------------------------------------------
133  //------------------------------------------------------------------------
134  inline const uint8_t *RawPointer() const
135  {
136  return (const uint8_t *)&_addr;
137  }
138 
139  //------------------------------------------------------------------------
142  //------------------------------------------------------------------------
143  uint32_t StreamedLength() const;
144 
145  //------------------------------------------------------------------------
147  //------------------------------------------------------------------------
148  std::istream & Read(std::istream & is);
149 
150  //------------------------------------------------------------------------
152  //------------------------------------------------------------------------
153  std::ostream & Write(std::ostream & os) const;
154 
155  //------------------------------------------------------------------------
158  //------------------------------------------------------------------------
159  ssize_t Read(int fd);
160 
161  //------------------------------------------------------------------------
164  //------------------------------------------------------------------------
165  ssize_t Write(int fd) const;
166 
167  //------------------------------------------------------------------------
169  //------------------------------------------------------------------------
170  size_t Read(FILE * f);
171 
172  //------------------------------------------------------------------------
174  //------------------------------------------------------------------------
175  size_t Write(FILE * f) const;
176 
177  //------------------------------------------------------------------------
180  //------------------------------------------------------------------------
181  int Read(gzFile gzf);
182 
183  //------------------------------------------------------------------------
186  //------------------------------------------------------------------------
187  int Write(gzFile gzf) const;
188 
189  //------------------------------------------------------------------------
192  //------------------------------------------------------------------------
193  int BZRead(BZFILE *bzf);
194 
195  //------------------------------------------------------------------------
198  //------------------------------------------------------------------------
199  int BZWrite(BZFILE *bzf) const;
200 
201  private:
202  struct in6_addr _addr;
203  };
204 
205 } // namespace Dwm
206 
207 #endif // _DWMIPV6ADDRESS_HH_
208 
209 //---------------------------- emacs settings -----------------------------
210 // Local Variables:
211 // mode: C++/la
212 // tab-width: 2
213 // indent-tabs-mode: nil
214 // c-basic-offset: 2
215 // End:
216 //-------------------------------------------------------------------------
This class encapsulates an IPv6 address.
Definition: DwmIpv6Address.hh:59
std::istream & Read(std::istream &is)
Reads from an istream. Returns the istream.
Dwm::IpAddress class definition.
Ipv6Address()
Constructor. Sets address to 0::
bool operator>(const Ipv6Address &addr) const
Greater-than operator.
Definition: DwmBZ2IO.hh:67
std::ostream & Write(std::ostream &os) const
Writes to an ostream. Returns the ostream.
int BZWrite(BZFILE *bzf) const
Writes to a BZFILE pointer.
bool operator==(const Ipv6Address &addr) const
Equal-to operator.
This class encapsulates an IP address.
Definition: DwmIpAddress.hh:63
const uint8_t * RawPointer() const
Returns a pointer to the memory containing the address.
Definition: DwmIpv6Address.hh:134
Ipv6Address operator&(const Ipv6Address &netmask) const
Mask operator.
Ipv6Address & operator&=(const Ipv6Address &netmask)
Mask operator.
int BZRead(BZFILE *bzf)
Reads from a BZFILE pointer.
bool operator<(const Ipv6Address &addr) const
Less-than operator.
uint32_t StreamedLength() const
Returns the number of bytes that would be written if we called one of the Write() members...