OWLNext
7.0
Borland's Object Windows Library for the modern age
Toggle main menu visibility
Loading...
Searching...
No Matches
wskaddr.h
Go to the documentation of this file.
1
//----------------------------------------------------------------------------
2
// ObjectWindows
3
// Copyright (c) 1995, 1996 by Borland International, All Rights Reserved
4
//
5
/// \file
6
/// Winsock for OWL subsystem.
7
/// Based on work by Paul Pedriana, 70541.3223@compuserve.com
8
//----------------------------------------------------------------------------
9
10
#if !defined(OWL_WSKADDR_H)
11
#define OWL_WSKADDR_H
12
13
#include <
owl/private/defs.h
>
14
#if defined(BI_HAS_PRAGMA_ONCE)
15
# pragma once
16
#endif
17
18
#include <
owl/defs.h
>
19
20
#pragma pack(push, 8)
21
#include <
winsock.h
>
22
#pragma pack(pop)
23
24
25
namespace
owl
{
26
27
#include <
owl/preclass.h
>
28
29
30
//
31
/// \class TSocketAddress
32
// ~~~~~ ~~~~~~~~~~~~~~
33
/// The TSocketAddress class stores a Winsock socket address. This class is much
34
/// like the sockaddr class; in fact, it is a subclass of sockaddr. Note that the
35
/// TSocketAddress class does not store Internet (IP) addresses specifically. It
36
/// stores generic socket addresses. The TINetSocketAddress class is used to store
37
/// Internet addresses.
38
///
39
/// TSocketAddress normally stores its data in network byte ordering, as opposed to host byte ordering.
40
//
41
class
_OWLCLASS
TSocketAddress
:
public
sockaddr {
42
public
:
43
TSocketAddress
();
44
TSocketAddress
(
const
sockaddr& src);
45
TSocketAddress
(
const
TSocketAddress
& src);
46
TSocketAddress
(
ushort
family,
char
* data,
short
dataLength);
47
48
TSocketAddress
& operator =(
const
sockaddr& src);
49
friend
bool
operator ==(
const
TSocketAddress
& address1,
const
TSocketAddress
& address2);
50
51
ushort
GetFamily
()
const
;
52
void
SetFamily
(
ushort
family);
53
void
SetAddress
(
ushort
family,
const
char
* data,
short
dataLength);
54
};
55
56
//
57
/// \class TINetSocketAddress
58
// ~~~~~ ~~~~~~~~~~~~~~~~~~
59
/// The TINetSocketAddress class encapsulates a Winsock Internet address. This
60
/// class stores a complete Internet address, which includes an address family, a
61
/// port, and a 32 bit (4 byte) IP address. The Internet address-specific
62
/// information is stored in the sa_data field of the sockaddr.
63
///
64
/// \todo What about IPv6?
65
//
66
class
_OWLCLASS
TINetSocketAddress
:
public
TSocketAddress
{
67
public
:
68
69
/// TINetClass is an enumeration that specifies which network class it belongs to.
70
/// There are three network classes: class A, class B, and class C. The classes
71
/// determine how many possible hosts there are on the network. Note that these
72
/// classes are the same when programming Windows Sockets.
73
///
74
/// An address resolves to a 32-bit value. Each class has a different encoding scheme.
75
//
76
enum
TINetClass
{
77
ClassA
,
///< A class net addressing
78
ClassB
,
///< B class net addressing
79
ClassC
,
///< C class net addressing
80
ClassUnknown
///< Unknown class net addressing
81
};
82
83
TINetSocketAddress
();
84
TINetSocketAddress
(
const
sockaddr& src);
85
TINetSocketAddress
(
ushort
newPort,
ulong
newAddress = INADDR_ANY,
86
ushort
newFamily = AF_INET);
87
TINetSocketAddress
(
ushort
newPort,
const
char
* newAddress,
88
ushort
newFamily = AF_INET);
89
90
TINetSocketAddress
& operator =(
const
sockaddr& src);
91
operator
sockaddr_in()
const
;
92
93
TINetClass GetClass()
const
;
94
ushort
GetPort()
const
;
95
ulong
GetNetworkAddress()
const
;
96
ulong
GetNetwork()
const
;
97
ulong
GetNetwork(
ulong
subnet)
const
;
98
ulong
GetNode()
const
;
99
ulong
GetNode(
ulong
subnet)
const
;
100
void
SetAddress(
ushort
newFamily,
ushort
newPort,
ulong
newAddress);
101
void
SetPort(
ushort
port);
102
void
SetNetworkAddress(
ulong
address);
103
void
SetNetworkAddress(
const
char
* addressDottedDecimal);
104
void
SetFiller();
105
106
static
ulong
ConvertAddress(
const
char
* address);
107
static
char
* ConvertAddress(
ulong
address);
108
static
short
IsAddressDottedDecimal(
const
char
* address);
109
};
110
111
#include <
owl/posclass.h
>
112
113
//----------------------------------------------------------------------------
114
// Inline implementations
115
//
116
117
//
118
/// Returns the family of addressing this address belongs to.
119
//
120
inline
ushort
121
TSocketAddress::GetFamily
()
const
122
{
123
return
sa_family;
124
}
125
126
//
127
/// Sets the family of addressing this address belongs to.
128
//
129
inline
void
130
TSocketAddress::SetFamily
(
ushort
family)
131
{
132
sa_family = family;
133
}
134
135
//
136
/// This function converts this address to the sockaddr_in structure.
137
//
138
inline
139
TINetSocketAddress::operator sockaddr_in()
const
140
{
141
return
*((sockaddr_in*)
this
);
142
}
143
144
//
145
/// This function returns the network ID masked with the subnet.
146
//
147
inline
ulong
148
TINetSocketAddress::GetNetwork
(
ulong
subnet)
const
149
{
150
return
GetNetworkAddress
() & subnet;
151
}
152
153
//
154
/// This function returns the node of this address.
155
//
156
inline
ulong
157
TINetSocketAddress::GetNode
(
ulong
subnet)
const
158
{
159
return
GetNetworkAddress
() & ~subnet;
160
}
161
162
}
// OWL namespace
163
164
165
#endif
// OWL_WSKADDR_H
owl::TINetSocketAddress
The TINetSocketAddress class encapsulates a Winsock Internet address.
Definition
wskaddr.h:66
owl::TINetSocketAddress::TINetClass
TINetClass
TINetClass is an enumeration that specifies which network class it belongs to.
Definition
wskaddr.h:76
owl::TINetSocketAddress::ClassUnknown
@ ClassUnknown
Unknown class net addressing.
Definition
wskaddr.h:80
owl::TINetSocketAddress::ClassB
@ ClassB
B class net addressing.
Definition
wskaddr.h:78
owl::TINetSocketAddress::ClassA
@ ClassA
A class net addressing.
Definition
wskaddr.h:77
owl::TINetSocketAddress::ClassC
@ ClassC
C class net addressing.
Definition
wskaddr.h:79
owl::TINetSocketAddress::GetNetworkAddress
ulong GetNetworkAddress() const
This function returns an IP binary address in network byte ordering.
Definition
wskaddr.cpp:242
owl::TINetSocketAddress::GetNetwork
ulong GetNetwork() const
This function returns 0 if the network cannot be determined.
Definition
wskaddr.cpp:252
owl::TINetSocketAddress::TINetSocketAddress
TINetSocketAddress()
This function constructs an object.
Definition
wskaddr.cpp:94
owl::TINetSocketAddress::GetNode
ulong GetNode() const
This function returns the node component of the address with the subnet masked out.
Definition
wskaddr.cpp:275
owl::TSocketAddress::SetFamily
void SetFamily(ushort family)
Sets the family of addressing this address belongs to.
Definition
wskaddr.h:130
owl::TSocketAddress::GetFamily
ushort GetFamily() const
Returns the family of addressing this address belongs to.
Definition
wskaddr.h:121
owl::TSocketAddress::TSocketAddress
TSocketAddress()
Only the family is specified. The rest of the data is currently undefined.
Definition
wskaddr.cpp:20
owl::TSocketAddress::SetAddress
void SetAddress(ushort family, const char *data, short dataLength)
'newFamily' is AF_INET, etc.
Definition
wskaddr.cpp:80
owl
Object Windows Library (OWLNext Core).
Definition
animctrl.h:22
owl::ushort
unsigned short ushort
Definition
number.h:24
owl::ulong
unsigned long ulong
Definition
number.h:26
defs.h
General definitions used by all ObjectWindows programs.
defs.h
_OWLCLASS
#define _OWLCLASS
Definition
defs.h:338
posclass.h
preclass.h
winsock.h
Main header of the Winsock OWL subsystem.
include
owl
wskaddr.h
Generated by
1.18.0