2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FNetIpAddress.h
20 * @brief This is the header file for the %IpAddress class.
22 * This header file contains the declarations of the %IpAddress class.
24 #ifndef _FNET_IP_ADDRESS_H_
25 #define _FNET_IP_ADDRESS_H_
27 #include <FBaseObject.h>
28 #include <FBaseByteBuffer.h>
29 #include <FBaseString.h>
30 #include <FBaseResult.h>
31 #include <FBaseErrors.h>
32 #include <FNetSockSocketTypes.h>
34 namespace Tizen { namespace Net
39 * @brief This abstract class encapsulates an Internet Protocol (IP) address and the methods to manipulate it.
43 * The %IpAddress class contains the address of a computer on an IP network. Different computers use different conventions for ordering the bytes
44 * within multi-byte integer values. Some computers put the most significant byte first (known as big-endian order) and others put the
45 * least-significant byte first (known as little-endian order). To work with the computers that use different byte ordering, all integer values sent
46 * over the network are sent in network byte order. This class provides methods to change the order. An endpoint includes an IP address
49 * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/net/net_namespace.htm">Net Guide</a>.
51 class _OSP_EXPORT_ IpAddress
52 : public Tizen::Base::Object
56 * This destructor overrides Tizen::Base::Object::~Object().
60 virtual ~IpAddress(void);
63 * Converts the specified unsigned short address from the host byte order to the network byte order.
67 * @return The address as an unsigned @c short value, in the network @c byte order
68 * @param[in] host The IP address to convert, expressed in host @c byte order
70 * @see NetworkToHostOrder()
72 static unsigned short HostToNetworkOrder(unsigned short host);
75 * Converts the specified unsigned long address from the host byte order to the network byte order.
79 * @return The address as an unsigned @c long value, in the network @c byte order
80 * @param[in] host The IP address to convert, expressed in the host @c byte order
82 * @see NetworkToHostOrder()
84 static unsigned long HostToNetworkOrder(unsigned long host);
87 * Converts the specified short integer address from network byte order to host byte order.
91 * @return The address as an unsigned @c short value, in the host @c byte order
92 * @param[in] network The IP address to convert, expressed in the network @c byte order
94 * @see HostToNetworkOrder()
96 static unsigned short NetworkToHostOrder(unsigned short network);
99 * Converts the specified unsigned long address from the network byte order to the host byte order.
103 * @return The address as an unsigned @c long value, in the host @c byte order
104 * @param[in] network The IP address to convert, expressed in the network @c byte order
106 * @see HostToNetworkOrder()
108 static unsigned long NetworkToHostOrder(unsigned long network);
111 * Gets the address family to which the %IpAddress belongs.
115 * @return The address family
117 virtual NetAddressFamily GetNetAddressFamily(void) const = 0;
120 * Gets the raw IP address of the endpoint. @n
121 * An endpoint includes an IP address and a port.
125 * @return An error code
126 * @param[out] ipAddr A Tizen::Base::ByteBuffer object for getting the raw IP address
127 * @exception E_SUCCESS The method is successful.
128 * @exception E_INVALID_ARG The specified @c ipAddr is invalid.
129 * @exception E_OVERFLOW This operation has caused the memory to overflow.
130 * @remarks The result @c ipAddr is in the host @c byte order. This method writes the raw address into the buffer parameter, starting from the
131 * current position of the buffer. After the operation, the position of the buffer is incremented by the number of bytes successfully written
132 * even if the operation fails. The new position cannot be larger than the original limit.
134 virtual result GetAddress(Tizen::Base::ByteBuffer& ipAddr) const = 0;
137 * Gets the IP address of the endpoint as a string. @n
138 * An endpoint includes an IP address and a port.
142 * @return The IP address, @n
143 * else a null string if the address is not set
145 virtual Tizen::Base::String ToString(void) const = 0;
148 * Creates and returns a copy of this instance.
152 * @return The copy of this instance
153 * @remarks The GetLastResult() method is used to check whether the %IpAddress instance is copied successfully.
155 virtual IpAddress* CloneN(void) const = 0;
159 * This default constructor is intentionally declared as protected because this class cannot be constructed.
167 // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
169 // This method is reserved and may change its name at any time without prior notice.
173 virtual void IpAddress_Reserved1(void) {}
176 // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
178 // This method is reserved and may change its name at any time without prior notice.
182 virtual void IpAddress_Reserved2(void) {}
185 // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
187 // This method is reserved and may change its name at any time without prior notice.
191 virtual void IpAddress_Reserved3(void) {}
194 // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
196 // This method is reserved and may change its name at any time without prior notice.
200 virtual void IpAddress_Reserved4(void) {}
203 // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
205 // This method is reserved and may change its name at any time without prior notice.
209 virtual void IpAddress_Reserved5(void) {}
213 * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
215 * @param[in] rhs An instance of IpAddress
217 IpAddress(const IpAddress& rhs);
220 * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
222 * @param[in] rhs An instance of %IpAddress
224 IpAddress& operator =(const IpAddress& rhs);
227 _IpAddressImpl* _pIpAddressImpl;
229 friend class _IpAddressImpl;
234 #endif // _FNET_IP_ADDRESS_H_