]> git.saurik.com Git - wxWidgets.git/blame - include/wx/sckaddr.h
unset the window as invoking window of wxCurrentPopupMenu (which now exists in all...
[wxWidgets.git] / include / wx / sckaddr.h
CommitLineData
f4ada568
GL
1/////////////////////////////////////////////////////////////////////////////
2// Name: sckaddr.h
3// Purpose: Network address classes
4// Author: Guilhem Lavaux
5// Modified by:
6// Created: 26/04/1997
7// RCS-ID: $Id$
8// Copyright: (c) 1997, 1998 Guilhem Lavaux
65571936 9// Licence: wxWindows licence
f4ada568 10/////////////////////////////////////////////////////////////////////////////
2df7be7f 11
f4ada568
GL
12#ifndef _WX_NETWORK_ADDRESS_H
13#define _WX_NETWORK_ADDRESS_H
14
2df7be7f
RR
15#include "wx/defs.h"
16
17#if wxUSE_SOCKETS
18
2df7be7f 19#include "wx/string.h"
65ccd2b8 20#include "wx/gsocket.h"
a324a7bc 21
f4ada568 22
7c4728f6 23class WXDLLIMPEXP_NET wxSockAddress : public wxObject {
f4ada568
GL
24 DECLARE_ABSTRACT_CLASS(wxSockAddress)
25public:
26 typedef enum { IPV4=1, IPV6=2, UNIX=3 } Addr;
27
a324a7bc 28 wxSockAddress();
1539c2f5 29 wxSockAddress(const wxSockAddress& other);
a324a7bc
GL
30 virtual ~wxSockAddress();
31
1539c2f5
VZ
32 wxSockAddress& operator=(const wxSockAddress& other);
33
a324a7bc
GL
34 virtual void Clear();
35 virtual int Type() = 0;
f4ada568 36
a324a7bc
GL
37 GAddress *GetAddress() const { return m_address; }
38 void SetAddress(GAddress *address);
f4ada568 39
acd15a3f 40 // we need to be able to create copies of the addresses polymorphically (i.e.
6c0d0845 41 // without knowing the exact address class)
acd15a3f 42 virtual wxSockAddress *Clone() const = 0;
f4ada568 43
a324a7bc
GL
44protected:
45 GAddress *m_address;
6c0d0845
VZ
46
47private:
48 void Init();
f4ada568
GL
49};
50
be4bd463
JS
51// Interface to an IP address (either IPV4 or IPV6)
52class WXDLLIMPEXP_NET wxIPaddress : public wxSockAddress {
53 DECLARE_ABSTRACT_CLASS(wxIPaddress)
54public:
55 wxIPaddress();
56 wxIPaddress(const wxIPaddress& other);
57 virtual ~wxIPaddress();
58
59 virtual bool Hostname(const wxString& name) = 0;
60 virtual bool Service(const wxString& name) = 0;
61 virtual bool Service(unsigned short port) = 0;
62
63 virtual bool LocalHost() = 0;
64 virtual bool IsLocalHost() const = 0;
65
66 virtual bool AnyAddress() = 0;
60edcf45 67 virtual bool BroadcastAddress() = 0;
be4bd463
JS
68
69 virtual wxString IPAddress() const = 0;
70
71 virtual wxString Hostname() const = 0;
72 virtual unsigned short Service() const = 0;
73};
74
75class WXDLLIMPEXP_NET wxIPV4address : public wxIPaddress {
f4ada568 76 DECLARE_DYNAMIC_CLASS(wxIPV4address)
f4ada568
GL
77public:
78 wxIPV4address();
1539c2f5 79 wxIPV4address(const wxIPV4address& other);
f4ada568
GL
80 virtual ~wxIPV4address();
81
be4bd463
JS
82 // IPV4 name formats
83 //
84 // hostname
85 // dot format a.b.c.d
86 virtual bool Hostname(const wxString& name);
a324a7bc 87 bool Hostname(unsigned long addr);
be4bd463
JS
88 virtual bool Service(const wxString& name);
89 virtual bool Service(unsigned short port);
90
91 // localhost (127.0.0.1)
92 virtual bool LocalHost();
93 virtual bool IsLocalHost() const;
f4ada568 94
be4bd463
JS
95 // any (0.0.0.0)
96 virtual bool AnyAddress();
60edcf45
VZ
97 // all (255.255.255.255)
98 virtual bool BroadcastAddress();
be4bd463
JS
99
100 virtual wxString Hostname() const;
ce22d615 101 wxString OrigHostname() { return m_origHostname; }
be4bd463
JS
102 virtual unsigned short Service() const;
103
104 // a.b.c.d
105 virtual wxString IPAddress() const;
f4ada568 106
acd15a3f 107 virtual int Type() { return wxSockAddress::IPV4; }
ce22d615 108 virtual wxSockAddress *Clone() const;
d775fa82 109
fbfb8bcc 110 bool operator==(const wxIPV4address& addr) const;
ce22d615
RD
111
112private:
113 wxString m_origHostname;
f4ada568
GL
114};
115
2ff35079
VZ
116
117// the IPv6 code probably doesn't work, untested -- set to 1 at your own risk
118#ifndef wxUSE_IPV6
119 #define wxUSE_IPV6 0
120#endif
121
be4bd463
JS
122#if wxUSE_IPV6
123
be4bd463 124class WXDLLIMPEXP_NET wxIPV6address : public wxIPaddress {
f4ada568
GL
125 DECLARE_DYNAMIC_CLASS(wxIPV6address)
126private:
8575ff50 127 wxString m_origHostname;
f4ada568
GL
128public:
129 wxIPV6address();
1539c2f5
VZ
130 wxIPV6address(const wxIPV6address& other);
131 virtual ~wxIPV6address();
f4ada568 132
be4bd463
JS
133 // IPV6 name formats
134 //
135 // hostname
d775fa82 136 // 3ffe:ffff:0100:f101:0210:a4ff:fee3:9566
8575ff50 137 // compact (base85) Itu&-ZQ82s>J%s99FJXT (depends on platform api)
be4bd463
JS
138 // compressed format ::1
139 // ipv4 mapped ::ffff:1.2.3.4
140 virtual bool Hostname(const wxString& name);
141
f4ada568 142 bool Hostname(unsigned char addr[16]);
be4bd463
JS
143 virtual bool Service(const wxString& name);
144 virtual bool Service(unsigned short port);
145
146 // localhost (0000:0000:0000:0000:0000:0000:0000:0001 (::1))
147 virtual bool LocalHost();
148 virtual bool IsLocalHost() const;
f4ada568 149
be4bd463
JS
150 // any (0000:0000:0000:0000:0000:0000:0000:0000 (::))
151 virtual bool AnyAddress();
60edcf45
VZ
152 // all (?)
153 virtual bool BroadcastAddress();
be4bd463 154
d775fa82 155 // 3ffe:ffff:0100:f101:0210:a4ff:fee3:9566
be4bd463
JS
156 virtual wxString IPAddress() const;
157
158 virtual wxString Hostname() const;
159 virtual unsigned short Service() const;
f4ada568 160
acd15a3f
VZ
161 virtual int Type() { return wxSockAddress::IPV6; }
162 virtual wxSockAddress *Clone() const { return new wxIPV6address(*this); }
f4ada568 163};
be4bd463
JS
164
165#endif // wxUSE_IPV6
f4ada568 166
04d8f1ba 167#if defined(__UNIX__) && !defined(__WINE__) && (!defined(__WXMAC__) || defined(__DARWIN__)) && !defined(__WXMSW__)
fd9811b1 168#include <sys/socket.h>
e1c70641
JJ
169#ifndef __VMS__
170# include <sys/un.h>
171#endif
f4ada568 172
7c4728f6 173class WXDLLIMPEXP_NET wxUNIXaddress : public wxSockAddress {
f4ada568
GL
174 DECLARE_DYNAMIC_CLASS(wxUNIXaddress)
175private:
176 struct sockaddr_un *m_addr;
177public:
178 wxUNIXaddress();
1539c2f5
VZ
179 wxUNIXaddress(const wxUNIXaddress& other);
180 virtual ~wxUNIXaddress();
f4ada568 181
f4ada568
GL
182 void Filename(const wxString& name);
183 wxString Filename();
184
acd15a3f
VZ
185 virtual int Type() { return wxSockAddress::UNIX; }
186 virtual wxSockAddress *Clone() const { return new wxUNIXaddress(*this); }
f4ada568
GL
187};
188#endif
2df7be7f 189 // __UNIX__
f4ada568
GL
190
191#endif
2df7be7f 192 // wxUSE_SOCKETS
65ccd2b8 193
2df7be7f
RR
194#endif
195 // _WX_NETWORK_ADDRESS_H