2b65d6df0990907b1c5fcd27a14139d1a3af35fa
[platform/core/system/swap-probe.git] / probe_tizenapi / tizen_socket.cpp
1 /*
2  *  DA probe
3  *
4  * Copyright (File::*c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact:
7  *
8  * Hyunjong Park        <phjwithyou.park@samsung.com>
9  * Juyoung Kim          <j0.kim@samsung.com>
10  * Vitaliy Cherepanov   <v.cherepanov@samsung.com>
11  *
12  * This library is free software; you can redistribute it and/or modify it under
13  * the terms of the GNU Lesser General Public License as published by the
14  * Free Software Foundation; either version 2.1 of the License, or (at your option)
15  * any later version.
16  *
17  * This library is distributed in the hope that it will be useful, but WITHOUT ANY
18  * WARRANTY; without even the implied warranty of MERCHANTABILITY or
19  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
20  * License for more details.
21  *
22  * You should have received a copy of the GNU Lesser General Public License
23  * along with this library; if not, write to the Free Software Foundation, Inc., 51
24  * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25  *
26  * Contributors:
27  * - S-Core Co., Ltd
28  * - Samsung RnD Institute Russia
29  *
30  */
31
32 #include <FBase.h>
33 #include <FBaseObject.h>
34 #include <FBaseResult.h>
35 #include <arpa/inet.h>
36 #include "daprobe.h"
37 #include "probeinfo.h"
38 #include "dahelper.h"
39 #include "dacollection.h"
40 #include "tizen_probe.h"
41 #include "../probe_socket/da_socket.h"
42 #include "binproto.h"
43 #include "api_id_mapping.h"
44
45 static enum DaOptions _sopt = OPT_NETWORK;
46
47 namespace Tizen {
48 namespace Net {
49
50 typedef int NetAccountId;
51
52 enum NetAddressFamily {
53
54         NET_AF_IPV4 = 1, /**< The default @n An IPv4 address [RFC791] is represented in decimal format with dots as delimiters. */
55         NET_AF_IPV6, /**< An IPv6 address [RFC2373] is generally represented in hexadecimal numbers with colons as delimiters @n It can also be a combination of hexadecimal and decimal numbers with dots and colons as delimiters. */
56         NET_AF_ALPHANUMERIC, /**< A generic alphanumeric address (as defined by alphanum in [RFC2396]) */
57         NET_AF_APN, /**< A GPRS APN as defined in [GENFORM] */
58         NET_AF_NONE = 0 // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, and consistency-related issues in the application. Network Address Family not set
59 };
60
61 enum NetConnectionState {
62         NET_CONNECTION_STATE_NONE, /**< The initial state */
63         NET_CONNECTION_STATE_STARTING, /**< The network connection is being established */
64         NET_CONNECTION_STATE_STARTED, /**< The network connection has been established */
65         NET_CONNECTION_STATE_STOPPING, /**< The network connection is being disconnected */
66         NET_CONNECTION_STATE_STOPPED, /**< The network connection has been disconnected */
67         NET_CONNECTION_STATE_SUSPENDED, /**< The network connection has been suspended */
68         NET_CONNECTION_STATE_SUSPEND = 5, // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, and consistency-related issues in the application.
69         NET_CONNECTION_STATE_RESUMED, /**< The network connection is established, and recovered from SUSPEND state - enable to send/receive packet data */
70         NET_CONNECTION_STATE_AVAILABLE, // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, and consistency-related issues in the application.
71         NET_CONNECTION_STATE_UNAVAILABLE, // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, and consistency-related issues in the application.
72 };
73 enum NetBearerType {
74         NET_BEARER_PS = 1, /**< The bearer type for the PS domain */
75         NET_BEARER_CS, // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, and consistency-related issues in the application.
76         NET_BEARER_WIFI, /**< The bearer type for Wi-Fi */
77         NET_BEARER_WIFI_DIRECT, /**< The bearer type for Wi-Fi Direct @n
78          *      This bearer type cannot be tested on the Emulator. */
79         NET_BEARER_USB, /**< The bearer type for USB NDIS mode @n
80          *      Can use this bearer type via USB Tethering mode. @n
81          *      This bearer type cannot be tested on the Emulator. */
82         NET_BEARER_MMS, /**< The bearer type for MMS */
83         NET_BEARER_NONE = 0 // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, and consistency-related issues in the application. Network Bearer Type not set
84 };
85
86 enum NetAddressScheme {
87         NET_ADDRESS_SCHEME_DYNAMIC = 1, /**< The Dynamic IP or DNS Address */
88         NET_ADDRESS_SCHEME_STATIC, /**< The Static IP or DNS Address */
89         NET_ADDRESS_SCHEME_NONE = 0 // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, and consistency-related issues in the application. Network Address Scheme not set
90 };
91
92 enum NetProtocolType {
93         NET_PROTO_TYPE_IPV4 = 1, /**< The IPV4 type */
94         NET_PROTO_TYPE_PPP, /**< The PPP type */
95         NET_PROTO_TYPE_IPV6, /**< The IPV6 type, currently NOT supported */
96         NET_PROTO_TYPE_NONE = 0 // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, and consistency-related issues in the application. Network Protocol type not set
97 };
98
99 class _IpAddressImpl;
100 class IpAddress {
101 public:
102         virtual ~IpAddress(void);
103         static unsigned short HostToNetworkOrder(unsigned short host);
104         static unsigned long HostToNetworkOrder(unsigned long host);
105         static unsigned short NetworkToHostOrder(unsigned short network);
106         static unsigned long NetworkToHostOrder(unsigned long network);
107         virtual NetAddressFamily GetNetAddressFamily(void) const = 0;
108         virtual result GetAddress(Tizen::Base::ByteBuffer& ipAddr) const = 0;
109         virtual Tizen::Base::String ToString(void) const = 0;
110         virtual IpAddress* CloneN(void) const = 0;
111 protected:
112         IpAddress(void);
113 protected:
114         virtual void IpAddress_Reserved1(void) {
115         }
116         virtual void IpAddress_Reserved2(void) {
117         }
118         virtual void IpAddress_Reserved3(void) {
119         }
120         virtual void IpAddress_Reserved4(void) {
121         }
122         virtual void IpAddress_Reserved5(void) {
123         }
124 private:
125         IpAddress(const IpAddress& rhs);
126         IpAddress& operator =(const IpAddress& rhs);
127 protected:
128         _IpAddressImpl* _pIpAddressImpl;
129         friend class _IpAddressImpl;
130 };
131 // IpAddress
132
133 class Ip4Address {
134 public:
135         Tizen::Base::String ToString(void) const;
136         //unsigned long GetAddress(unsigned long& ipAddr) const;
137         unsigned long GetAddress(uint32_t *ipAddr) const;
138 };
139
140 Tizen::Base::String Ip4Address::ToString(void) const {
141         typedef Tizen::Base::String (Ip4Address::*methodType)(void) const;
142         static methodType ToStringp;
143         CALL_ORIGINAL_TIZEN_NET( _ZNK5Tizen3Net10Ip4Address8ToStringEv, ToStringp);
144         return (this->*ToStringp)();
145 }
146
147 /* INFO this is not original Ip4Address function */
148 unsigned long Ip4Address::GetAddress( uint32_t *ipAddr) const {
149         unsigned long IP, res;
150         typedef unsigned long (Ip4Address::*methodType)(unsigned long& ipAddr) const;
151         static methodType GetAddresgp;
152         CALL_ORIGINAL_TIZEN_NET(_ZNK5Tizen3Net10Ip4Address10GetAddressERm,
153                                 GetAddresgp);
154         res = (this->*GetAddresgp)(IP);
155         *ipAddr = ntohl(IP);
156         return res;
157 }
158
159 class NetEndPoint {
160 public:
161         unsigned short GetPort(void) const;
162         IpAddress* GetAddress(void) const;
163 };
164
165 unsigned short NetEndPoint::GetPort(void) const {
166         typedef unsigned short (NetEndPoint::*methodType)(void) const;
167         static methodType GetPortp;
168         CALL_ORIGINAL_TIZEN_NET( _ZNK5Tizen3Net11NetEndPoint7GetPortEv, GetPortp);
169         return (this->*GetPortp)();
170 }
171
172 IpAddress* NetEndPoint::GetAddress(void) const {
173         typedef IpAddress *(NetEndPoint::*methodType)(void) const;
174         static methodType GetAddressp;
175         CALL_ORIGINAL_TIZEN_NET( _ZNK5Tizen3Net11NetEndPoint10GetAddressEv,
176                         GetAddressp);
177         return (this->*GetAddressp)();
178 }
179
180 class NetConnectionInfo;
181 class INetConnectionEventListener;
182
183 class _NetConnectionImpl;
184 class NetConnection {
185 public:
186         NetConnection(void);
187         virtual ~NetConnection(void);
188         result Construct(NetAccountId netAccountId);
189 public:
190         result AddNetConnectionListener(INetConnectionEventListener& listener);
191         result RemoveNetConnectionListener(INetConnectionEventListener& listener);
192         result Start(void);
193         result Stop(void);
194         result Close(void);
195         NetAccountId GetNetAccountId(void) const;
196         const NetConnectionInfo* GetNetConnectionInfo(void) const;
197         static NetConnectionInfo* GetNetConnectionInfoN(NetAccountId netAccountId);
198         static Tizen::Base::Collection::IList* GetAllNetConnectionInfoN(void);
199         NetConnectionState GetConnectionState(void) const;
200 private:
201         NetConnection(const NetConnection& rhs);
202         NetConnection& operator =(const NetConnection& rhs);
203 private:
204         _NetConnectionImpl* __pNetConnectionImpl;
205         friend class _NetConnectionImpl;
206 };
207
208 class INetConnectionEventListener {
209 public:
210         virtual ~INetConnectionEventListener(void) {
211         }
212 public:
213         virtual void OnNetConnectionStarted(NetConnection& netConnection,
214                         result r) = 0;
215         virtual void OnNetConnectionStopped(NetConnection& netConnection,
216                         result r) = 0;
217         virtual void OnNetConnectionSuspended(NetConnection& netConnection) = 0;
218         virtual void OnNetConnectionResumed(NetConnection& netConnection) = 0;
219 protected:
220         virtual void INetConnectionEventListener_Reserved1(void) {
221         }
222         virtual void INetConnectionEventListener_Reserved2(void) {
223         }
224 };
225
226 class _NetConnectionInfoImpl;
227 class NetConnectionInfo {
228 public:
229         NetConnectionInfo(void);
230         virtual ~NetConnectionInfo(void);
231         NetBearerType GetBearerType(void) const;
232         NetProtocolType GetProtocolType(void) const;
233         Tizen::Base::String GetAccessPointName(void) const;
234         NetAddressScheme GetLocalAddressScheme(void) const;
235         const IpAddress* GetLocalAddress(void) const;
236         NetAddressScheme GetDnsAddressScheme(void) const;
237         const IpAddress* GetPrimaryDnsAddress(void) const;
238         const IpAddress* GetSecondaryDnsAddress(void) const;
239         const IpAddress* GetSubnetMaskAddress(void) const;
240         const IpAddress* GetDefaultGatewayAddress(void) const;
241         NetConnectionInfo(const NetConnectionInfo& rhs);
242         NetConnectionInfo& operator =(const NetConnectionInfo& rhs);
243         virtual bool Equals(const Tizen::Base::Object& rhs) const;
244         virtual int GetHashCode(void) const;
245 private:
246         _NetConnectionInfoImpl* __pNetConnectionInfoImpl;
247         friend class _NetConnectionInfoImpl;
248 };
249
250 }
251 } //namespace Tizen { namespace Net {
252
253 namespace Tizen {
254 namespace Net {
255 namespace Sockets {
256
257 enum NetSocketAddressFamily {
258         //NET_SOCKET_AF_LOCAL = 1,                            /*< The local socket for loopback*/
259         NET_SOCKET_AF_IPV4 = 2, /**< An IP version 4 address family */
260         //NET_SOCKET_AF_IPV6,                                           /*< An IP version 6 address family */
261         NET_SOCKET_AF_NONE = 0 // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, and consistency-related issues in the application.
262 };
263 //
264 enum NetSocketType {
265         NET_SOCKET_TYPE_STREAM = 1, /**< The stream socket */
266         NET_SOCKET_TYPE_DATAGRAM, /**< The datagram socket */
267         NET_SOCKET_TYPE_NONE = 0 // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, and consistency-related issues in the application.
268 };
269 //
270 enum NetSocketProtocol {
271         NET_SOCKET_PROTOCOL_TCP = 1, /**< The TCP protocol */
272         NET_SOCKET_PROTOCOL_UDP, /**< The UDP protocol */
273         NET_SOCKET_PROTOCOL_SSL, /**< The SSL protocol */
274         NET_SOCKET_PROTOCOL_NONE = 0 // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, and consistency-related issues in the application.
275 };
276
277 enum NetSocketIoctlCmd {
278         NET_SOCKET_FIONBIO = 1, /**< The command to set the non-blocking/blocking mode on a socket */
279         NET_SOCKET_FIONREAD, /**< The command to determine the amount of data pending in the network input buffer */
280         NET_SOCKET_FIONWRITE, /**< The functionality is not supported in this SDK */
281         NET_SOCKET_SIOCATMARK, /**< The command to determine whether all out-of-band data is read */
282         NET_SOCKET_IOCTLCMD_NONE = 0 // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, and consistency-related issues in the application.
283 };
284
285 enum NetSocketOptLevel {
286         NET_SOCKET_IPPROTO_TCP = 1, /**< The socket options apply only to the TCP sockets */
287         NET_SOCKET_IPPROTO_IP, /**< The socket options apply only to the IP sockets */
288         NET_SOCKET_SOL_SOCKET, /**< The socket options apply to all the sockets */
289         NET_SOCKET_OPTLEVEL_NONE = 0 // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, and consistency-related issues in the application.
290 };
291 //
292 enum NetSocketOptName {
293         NET_SOCKET_TCP_NODELAY = 1, /**< The option name is Level: NET_SOCKET_IPPROTO_TCP - Set/Get is possible */
294         NET_SOCKET_TCP_MAXSEG, /**< The option name is Level: NET_SOCKET_IPPROTO_TCP - Set/Get is possible */
295         NET_SOCKET_IP_TTL, /**< The option name is Level: NET_SOCKET_IPPROTO_IP - Set/Get is possible */
296         NET_SOCKET_IP_TOS, /**< The option name is Level: NET_SOCKET_IPPROTO_IP - Set/Get is possible */
297         NET_SOCKET_IP_ADD_MEMBERSHIP, /**< The option name is Level: NET_SOCKET_IPPROTO_IP - Only Set is possible */
298         NET_SOCKET_IP_DROP_MEMBERSHIP, /**< The option name is Level: NET_SOCKET_IPPROTO_IP - Only Set is possible */
299         NET_SOCKET_SO_ACCEPTCONN, /**< The option name is Level: NET_SOCKET_SOL_SOCKET - Only Get is possible */
300         NET_SOCKET_SO_BROADCAST, /**< The option name is Level: NET_SOCKET_SOL_SOCKET - Set/Get is possible */
301         NET_SOCKET_SO_DEBUG, // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, and consistency-related issues in the application. The option name is Level: NET_SOCKET_SOL_SOCKET - Set/Get is possible (Currently, not supported)
302         NET_SOCKET_SO_DONTROUTE, /**< The option name is Level: NET_SOCKET_SOL_SOCKET - Set/Get is possible */
303         NET_SOCKET_SO_ERROR, /**< The option name is Level: NET_SOCKET_SOL_SOCKET - Only Get is possible */
304         NET_SOCKET_SO_KEEPALIVE, /**< The option name is Level: NET_SOCKET_SOL_SOCKET - Set/Get is possible */
305         NET_SOCKET_SO_LINGER, /**< The option name is Level: NET_SOCKET_SOL_SOCKET - Set/Get is possible */
306         NET_SOCKET_SO_OOBINLINE, /**< The option name is Level: NET_SOCKET_SOL_SOCKET - Set/Get is possible */
307         NET_SOCKET_SO_RCVBUF, /**< The option name is Level: NET_SOCKET_SOL_SOCKET - Set/Get is possible */
308         NET_SOCKET_SO_RCVLOWAT, // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, and consistency-related issues in the application. The option name is Level: NET_SOCKET_SOL_SOCKET - Set/Get is possible (Currently, not supported)
309         NET_SOCKET_SO_RCVTIMEO, /**< The option name is Level: NET_SOCKET_SOL_SOCKET - Set/Get is possible */
310         NET_SOCKET_SO_REUSEADDR, /**< The option name is Level: NET_SOCKET_SOL_SOCKET - Set/Get is possible */
311         NET_SOCKET_SO_SNDBUF, /**< The option name is Level: NET_SOCKET_SOL_SOCKET - Set/Get is possible */
312         NET_SOCKET_SO_SNDLOWAT, // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, and consistency-related issues in the application. The option name is Level: NET_SOCKET_SOL_SOCKET - Set/Get is possible (Currently, not supported)
313         NET_SOCKET_SO_SNDTIMEO, /**< The option name is Level: NET_SOCKET_SOL_SOCKET - Set/Get is possible */
314         NET_SOCKET_SO_TYPE, /**< The option name is Level: NET_SOCKET_SOL_SOCKET - Only Get is possible */
315
316         //Secure Socket only
317         NET_SOCKET_SO_SSLVERSION, /**< The option name is Level: NET_SOCKET_SOL_SOCKET - Set/Get is possible */
318         NET_SOCKET_SO_SSLCIPHERSUITEID, /**< The option name is Level: NET_SOCKET_SOL_SOCKET - Set/Get is possible */
319         NET_SOCKET_SO_SSLCERTVERIFY, /**< The option name is Level: NET_SOCKET_SOL_SOCKET - Only Set is possible */
320         NET_SOCKET_SO_SSLCERTID, /**< The option name is Level: NET_SOCKET_SOL_SOCKET - Only Set is possible */
321         NET_SOCKET_SO_SSLCLIENTCERTVERIFY, /**< The option name is Level: NET_SOCKET_SOL_SOCKET - Only Set is possible */
322         NET_SOCKET_OPTNAME_NONE = 0 // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, and consistency-related issues in the application.
323 };
324
325 enum NetSocketClosedReason {
326         NET_SOCKET_CLOSED_REASON_NORMAL = 1, /**< A normal closed status by peer */
327         NET_SOCKET_CLOSED_REASON_TIMEOUT, /**< The connection attempt failed due to timeout */
328         NET_SOCKET_CLOSED_REASON_NETWORK_UNAVAILABLE, /**< The network is unavailable */
329         NET_SOCKET_CLOSED_REASON_SYSTEM, /**< An internal error has occurred */
330         NET_SOCKET_CLOSED_REASON_NO_CERTIFICATE, /**< The reason is there is no client's SSL certificate */
331         NET_SOCKET_CLOSED_REASON_BY_USER, /**< The connection closed by user */
332         NET_SOCKET_CLOSED_REASON_NONE = 0 // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, and consistency-related issues in the application.
333 };
334
335 class Socket;
336
337 class _LingerOptionImpl;
338 class LingerOption {
339 public:
340         LingerOption(bool enable, int seconds);
341         virtual ~LingerOption(void);
342         LingerOption(const LingerOption& rhs);
343         LingerOption& operator =(const LingerOption& rhs);
344         virtual bool Equals(const Tizen::Base::Object& obj) const;
345         virtual int GetHashCode(void) const;
346 public:
347         void SetEnabled(bool on);
348         void SetLingerTime(int seconds);
349         int GetLingerTime(void) const;
350         bool IsEnabled(void) const;
351 private:
352         LingerOption(void);
353 private:
354         _LingerOptionImpl* __pLingerOptionImpl;
355         friend class _LingerOptionImpl;
356 };
357
358 class _IpMulticastRequestOptionImpl;
359 class IpMulticastRequestOption {
360 public:
361         IpMulticastRequestOption(const NetEndPoint& multicastAddress,
362                         const NetEndPoint& interfaceAddress);
363         virtual ~IpMulticastRequestOption(void);
364         IpMulticastRequestOption(const IpMulticastRequestOption& rhs);
365         IpMulticastRequestOption& operator =(const IpMulticastRequestOption& rhs);
366 public:
367         result SetMulticastEndPoint(NetEndPoint& multicastAddress);
368         result SetInterfaceEndPoint(NetEndPoint& interfaceAddress);
369         const NetEndPoint* GetMulticastEndPoint(void) const;
370         const NetEndPoint* GetInterfaceEndPoint(void) const;
371         virtual bool Equals(const Tizen::Base::Object& obj) const;
372         virtual int GetHashCode(void) const;
373 private:
374         IpMulticastRequestOption(void);
375 private:
376         _IpMulticastRequestOptionImpl* __pIpMulticastRequestOptionImpl;
377         friend class _IpMulticastRequestOptionImpl;
378 };
379
380 class ISocketEventListener {
381 public:
382         virtual ~ISocketEventListener(void) {
383         }
384 public:
385         virtual void OnSocketConnected(Socket& socket) = 0;
386         virtual void OnSocketClosed(Socket& socket,
387                         NetSocketClosedReason reason) = 0;
388         virtual void OnSocketReadyToReceive(Socket& socket) = 0;
389         virtual void OnSocketReadyToSend(Socket& socket) = 0;
390         virtual void OnSocketAccept(Socket& socket) = 0;
391 protected:
392         virtual void ISocketEventListener_Reserved1(void) {
393         }
394         virtual void ISocketEventListener_Reserved2(void) {
395         }
396 };
397
398 class Socket {
399 public:
400         result Construct(NetSocketAddressFamily addressFamily,
401                         NetSocketType socketType, NetSocketProtocol protocol);
402         result Construct(const NetConnection& netConnection,
403                         NetSocketAddressFamily addressFamily, NetSocketType socketType,
404                         NetSocketProtocol protocol);
405         result Bind(const Tizen::Net::NetEndPoint& localEndPoint);
406         result Listen(int backLog);
407         result Connect(const Tizen::Net::NetEndPoint& remoteEndPoint);
408         Socket* AcceptN(void) const;
409         result Receive(Tizen::Base::ByteBuffer& buffer) const;
410         result Receive(void* pBuffer, int length, int& rcvdLength) const;
411         result ReceiveFrom(Tizen::Base::ByteBuffer& buffer,
412                         Tizen::Net::NetEndPoint& remoteEndPoint) const;
413         result ReceiveFrom(void* pBuffer, int length,
414                         Tizen::Net::NetEndPoint& remoteEndPoint, int& rcvdLength) const;
415         result Send(Tizen::Base::ByteBuffer& buffer);
416         result Send(void* pBuffer, int length, int& sentLength);
417         result SendTo(Tizen::Base::ByteBuffer& buffer,
418                         const Tizen::Net::NetEndPoint& remoteEndPoint);
419         result SendTo(void* pBuffer, int length,
420                         const Tizen::Net::NetEndPoint& remoteEndPoint, int& sentLength);
421         result Close(void);
422
423         result SetSockOpt(NetSocketOptLevel optionLevel,
424                         NetSocketOptName optionName, int optionValue);
425         result SetSockOpt(NetSocketOptLevel optionLevel,
426                         NetSocketOptName optionName, const LingerOption& optionValue);
427         result SetSockOpt(NetSocketOptLevel optionLevel,
428                         NetSocketOptName optionName,
429                         const IpMulticastRequestOption& optionValue);
430         result Ioctl(NetSocketIoctlCmd cmd, unsigned long& value) const;
431         result AddSocketListener(ISocketEventListener& listener);
432         result AsyncSelectByListener(unsigned long socketEventType);
433         result RemoveSocketListener(ISocketEventListener& listener);
434         result GetSockOpt(NetSocketOptLevel optionLevel,
435                         NetSocketOptName optionName, int& optionValue) const;
436         result GetSockOpt(NetSocketOptLevel optionLevel,
437                         NetSocketOptName optionName, LingerOption& optionValue) const;
438 };
439
440 result Socket::Construct(NetSocketAddressFamily addressFamily,
441                 NetSocketType socketType, NetSocketProtocol protocol) {
442         typedef result (Socket::*methodType)(NetSocketAddressFamily addressFamily,
443                         NetSocketType socketType, NetSocketProtocol protocol);
444         static methodType Constructp;
445         result retVal;
446
447         BEFORE_ORIGINAL_TIZEN_NET(
448                         _ZN5Tizen3Net7Sockets6Socket9ConstructENS1_22NetSocketAddressFamilyENS1_13NetSocketTypeENS1_17NetSocketProtocolE,
449                         Constructp);
450
451         retVal = (this->*Constructp)(addressFamily, socketType, protocol);
452
453         AFTER_ORIGINAL_TIZEN_SOCK("Socket::Construct", VT_ULONG, retVal,
454                         (unsigned int)this, (unsigned int)this, SOCKET_API_FD_OPEN, 
455                         info, "ddd", addressFamily, socketType, protocol);
456
457         return retVal;
458 }
459
460 result Socket::Construct(const NetConnection& netConnection,
461                 NetSocketAddressFamily addressFamily, NetSocketType socketType,
462                 NetSocketProtocol protocol) {
463         typedef result (Socket::*methodType)(const NetConnection& netConnection,
464                         NetSocketAddressFamily addressFamily, NetSocketType socketType,
465                         NetSocketProtocol protocol);
466         static methodType Constructp;
467         result retVal;
468
469         BEFORE_ORIGINAL_TIZEN_NET(
470                         _ZN5Tizen3Net7Sockets6Socket9ConstructERKNS0_13NetConnectionENS1_22NetSocketAddressFamilyENS1_13NetSocketTypeENS1_17NetSocketProtocolE,
471                         Constructp);
472
473         retVal = (this->*Constructp)(netConnection, addressFamily, socketType,
474                         protocol);
475
476         AFTER_ORIGINAL_TIZEN_SOCK("Socket::Construct", VT_ULONG, retVal,
477                         (unsigned int)this, (unsigned int)this, SOCKET_API_FD_OPEN, 
478                         info, "xddd",
479                         (uint64_t)(&netConnection), addressFamily, socketType, protocol);
480
481         return retVal;
482 }
483
484 Socket* Socket::AcceptN(void) const {
485         typedef Socket* (Socket::*methodType)(void) const;
486         static methodType AcceptNp;
487         Socket* pret;
488
489         BEFORE_ORIGINAL_TIZEN_NET( _ZNK5Tizen3Net7Sockets6Socket7AcceptNEv,
490                         AcceptNp);
491
492         AFTER_ORIGINAL_TIZEN_SOCK_WAIT_FUNC_START("Socket::AcceptN", VT_NULL, NULL,
493                         (unsigned int)this, (unsigned int)this, SOCKET_API_ACCEPT_START, 
494                         info, "s", "void");
495
496         pret = (this->*AcceptNp)();
497         if (pret == NULL)
498                 newerrno = 1;
499         AFTER_ORIGINAL_TIZEN_SOCK_WAIT_FUNC_END("Socket::AcceptN", VT_PTR, pret,
500                         (unsigned int)this, (unsigned int)this, SOCKET_API_ACCEPT_END, 
501                         info, "s", "void");
502
503         return pret;
504 }
505
506 result Socket::Connect(const Tizen::Net::NetEndPoint& remoteEndPoint) {
507         typedef result (Socket::*methodType)(
508                         const Tizen::Net::NetEndPoint& remoteEndPoint);
509         static methodType Connectp;
510         result retVal;
511
512         BEFORE_ORIGINAL_TIZEN_NET(
513                         _ZN5Tizen3Net7Sockets6Socket7ConnectERKNS0_11NetEndPointE,
514                         Connectp);
515
516         Ip4Address* iv4PeerAddr = (Ip4Address*) remoteEndPoint.GetAddress();
517
518         char temp[64];
519         WcharToChar(temp, iv4PeerAddr->ToString().GetPointer());
520         char addressInfo[64];
521         sprintf(addressInfo, "%s:%d", temp, remoteEndPoint.GetPort());
522         info.host_port = remoteEndPoint.GetPort();
523         iv4PeerAddr->GetAddress(&info.host_ip);
524         retVal = (this->*Connectp)(remoteEndPoint);
525
526
527         AFTER_ORIGINAL_TIZEN_SOCK("Socket::Connect", VT_ULONG, retVal,
528                         (unsigned int)this, (unsigned int)this, SOCKET_API_CONNECT,
529                         info, "s", addressInfo);
530
531         return retVal;
532 }
533
534 result Socket::Close(void) {
535         typedef result (Socket::*methodType)(void);
536         static methodType Closep;
537         result retVal;
538
539         BEFORE_ORIGINAL_TIZEN_NET( _ZN5Tizen3Net7Sockets6Socket5CloseEv, Closep);
540
541         retVal = (this->*Closep)();
542
543         AFTER_ORIGINAL_TIZEN_SOCK("Socket::Close", VT_ULONG, retVal,
544                         (unsigned int)this, (unsigned int)this, SOCKET_API_FD_CLOSE, 
545                         info, "s", "void");
546
547         return retVal;
548 }
549
550 result Socket::Bind(const Tizen::Net::NetEndPoint& localEndPoint) {
551         typedef result (Socket::*methodType)(
552                         const Tizen::Net::NetEndPoint& localEndPoint);
553         static methodType Bindp;
554         result retVal;
555
556         BEFORE_ORIGINAL_TIZEN_NET(
557                         _ZN5Tizen3Net7Sockets6Socket4BindERKNS0_11NetEndPointE, Bindp);
558
559         retVal = (this->*Bindp)(localEndPoint);
560
561         Ip4Address* iv4PeerAddr = (Ip4Address*) localEndPoint.GetAddress();
562         char temp[64];
563         WcharToChar(temp, iv4PeerAddr->ToString().GetPointer());
564         char addressInfo[64];
565         sprintf(addressInfo, "%s:%d", temp, localEndPoint.GetPort());
566         info.host_port = localEndPoint.GetPort();
567         iv4PeerAddr->GetAddress(&info.host_ip);
568
569         AFTER_ORIGINAL_TIZEN_SOCK("Socket::Bind", VT_ULONG, retVal,
570                         (unsigned int)this, (unsigned int)this, SOCKET_API_BIND, 
571                         info, "s", addressInfo);
572         return retVal;
573 }
574
575 result Socket::Listen(int backLog) {
576         typedef result (Socket::*methodType)(int backLog);
577         static methodType Listenp;
578         result retVal;
579
580         BEFORE_ORIGINAL_TIZEN_NET( _ZN5Tizen3Net7Sockets6Socket6ListenEi, Listenp);
581
582         retVal = (this->*Listenp)(backLog);
583
584         AFTER_ORIGINAL_TIZEN_SOCK("Socket::Listen", VT_ULONG, retVal,
585                         (unsigned int)this, (unsigned int)this, SOCKET_API_LISTEN, 
586                         info, "d", backLog);
587
588         return retVal;
589 }
590
591 result Socket::Receive(Tizen::Base::ByteBuffer& buffer) const {
592         typedef result (Socket::*methodType)(Tizen::Base::ByteBuffer& buffer) const;
593         static methodType Receivep;
594         result pret;
595
596         BEFORE_ORIGINAL_TIZEN_NET(
597                         _ZNK5Tizen3Net7Sockets6Socket7ReceiveERNS_4Base10ByteBufferE,
598                         Receivep);
599
600         AFTER_ORIGINAL_TIZEN_SOCK_WAIT_FUNC_START("Socket::Receive", VT_NULL, NULL,
601                         (unsigned int)this, (unsigned int)this, SOCKET_API_RECV_START,
602                         info, "x", (uint64_t)(&buffer));
603
604         pret = (this->*Receivep)(buffer);
605
606         info.msg_total_size = buffer.GetLimit();
607         info.msg_pack_size = info.msg_total_size;
608         info.msg_buf = (char*)(buffer.GetPointer());
609
610         if (info.msg_pack_size > SOCKET_SEND_SIZE)
611                 info.msg_pack_size = SOCKET_SEND_SIZE;
612
613         AFTER_ORIGINAL_TIZEN_SOCK_WAIT_FUNC_END("Socket::Receive", VT_ULONG, pret,
614                         (unsigned int)this, (unsigned int)this, SOCKET_API_RECV_END,
615                         info, "x", (uint64_t)(&buffer));
616         return pret;
617 }
618
619 result Socket::Receive(void* pBuffer, int length, int& rcvdLength) const {
620         typedef result (Socket::*methodType)(void* pBuffer, int length,
621                         int& rcvdLength) const;
622         static methodType Receivep;
623         result pret;
624
625         BEFORE_ORIGINAL_TIZEN_NET(
626                         _ZNK5Tizen3Net7Sockets6Socket11ReceiveFromEPviRNS0_11NetEndPointERi,
627                         Receivep);
628
629         AFTER_ORIGINAL_TIZEN_SOCK_WAIT_FUNC_START("Socket::Receive", VT_NULL,
630                                                   NULL,
631                                                   (unsigned int)this,
632                                                   (unsigned int)this,
633                                                   SOCKET_API_RECV_START,
634                                                   info, "xdx",
635                                                   (uint64_t)(&pBuffer),
636                                                   length,
637                                                   (uint64_t)(rcvdLength));
638
639         pret = (this->*Receivep)(pBuffer, length, rcvdLength);
640         info.msg_buf = (char *)pBuffer;
641         info.msg_total_size = rcvdLength;
642         info.msg_pack_size = rcvdLength > SOCKET_SEND_SIZE ? SOCKET_SEND_SIZE : rcvdLength;
643
644         AFTER_ORIGINAL_TIZEN_SOCK_WAIT_FUNC_END("Socket::Receive", VT_ULONG,
645                                                 pret,
646                                                 (unsigned int)this,
647                                                 (unsigned int)this,
648                                                 SOCKET_API_RECV_END,
649                                                 info, "xdx",
650                                                 (uint64_t)(&pBuffer), length,
651                                                 (uint64_t)(rcvdLength));
652
653         return pret;
654 }
655
656 result Socket::ReceiveFrom(Tizen::Base::ByteBuffer& buffer,
657                 Tizen::Net::NetEndPoint& remoteEndPoint) const {
658         typedef result (Socket::*methodType)(Tizen::Base::ByteBuffer& buffer,
659                         Tizen::Net::NetEndPoint& remoteEndPoint) const;
660         static methodType ReceiveFromp;
661         result pret;
662
663         BEFORE_ORIGINAL_TIZEN_NET(
664                         _ZNK5Tizen3Net7Sockets6Socket11ReceiveFromERNS_4Base10ByteBufferERNS0_11NetEndPointE,
665                         ReceiveFromp);
666
667         Ip4Address* iv4PeerAddr = (Ip4Address*) remoteEndPoint.GetAddress();
668         char temp[64];
669         WcharToChar(temp, iv4PeerAddr->ToString().GetPointer());
670         char addressInfo[64];
671         sprintf(addressInfo, "%s:%d", temp, remoteEndPoint.GetPort());
672         info.host_port = remoteEndPoint.GetPort();
673         iv4PeerAddr->GetAddress(&info.host_ip);
674
675         AFTER_ORIGINAL_TIZEN_SOCK_WAIT_FUNC_START("Socket::ReceiveFrom", VT_NULL,
676                         NULL, (unsigned int)this, (unsigned int)this, SOCKET_API_RECV_START,
677                         
678                         info, "xs", (uint64_t)(&buffer), temp);
679
680         pret = (this->*ReceiveFromp)(buffer, remoteEndPoint);
681
682         int bufferSize = buffer.GetLimit();
683         char* pBuffer = (char*) (buffer.GetPointer());
684         Tizen::Base::String strData;
685         strData.SetCapacity(bufferSize);
686         strData.Append(pBuffer);
687         char* out = new char[bufferSize];
688         WcharToChar(out, strData.GetPointer());
689
690         info.msg_buf = out;
691         info.msg_total_size = bufferSize;
692         info.msg_pack_size = bufferSize > SOCKET_SEND_SIZE ? SOCKET_SEND_SIZE : bufferSize;
693
694         AFTER_ORIGINAL_TIZEN_SOCK_WAIT_FUNC_END("Socket::ReceiveFrom", VT_ULONG,
695                         pret, (unsigned int)this, (unsigned int)this, SOCKET_API_RECV_END,
696                         info, "xs", (uint64_t)(&buffer), temp);
697         delete [] out;
698         return pret;
699 }
700 result Socket::ReceiveFrom(void* pBuffer, int length,
701                 Tizen::Net::NetEndPoint& remoteEndPoint, int& rcvdLength) const {
702         typedef result (Socket::*methodType)(void* pBuffer, int length,
703                         Tizen::Net::NetEndPoint& remoteEndPoint, int& rcvdLength) const;
704         static methodType ReceiveFromp;
705         result pret;
706
707         BEFORE_ORIGINAL_TIZEN_NET(
708                         _ZNK5Tizen3Net7Sockets6Socket11ReceiveFromEPviRNS0_11NetEndPointERi,
709                         ReceiveFromp);
710
711         Ip4Address* iv4PeerAddr = (Ip4Address*) remoteEndPoint.GetAddress();
712         char temp[64];
713         WcharToChar(temp, iv4PeerAddr->ToString().GetPointer());
714         char addressInfo[64];
715         sprintf(addressInfo, "%s:%d", temp, remoteEndPoint.GetPort());
716         info.host_port = remoteEndPoint.GetPort();
717         iv4PeerAddr->GetAddress(&info.host_ip);
718
719         AFTER_ORIGINAL_TIZEN_SOCK_WAIT_FUNC_START("Socket::ReceiveFrom",
720                                                   VT_NULL,
721                                                   NULL, (unsigned int)this,
722                                                   (unsigned int)this,
723                                                   SOCKET_API_RECV_START,
724                                                   info, "xdsx",
725                                                   (uint64_t)(&pBuffer),
726                                                   length, temp,
727                                                   (uint64_t)(rcvdLength));
728
729         pret = (this->*ReceiveFromp)(pBuffer, length, remoteEndPoint, rcvdLength);
730
731         info.msg_buf = (char *)pBuffer;
732         info.msg_total_size = length;
733         info.msg_pack_size = length > SOCKET_SEND_SIZE ? SOCKET_SEND_SIZE : length;
734
735         AFTER_ORIGINAL_TIZEN_SOCK_WAIT_FUNC_END("Socket::ReceiveFrom", VT_ULONG,
736                                                 pret, (unsigned int)this,
737                                                 (unsigned int)this,
738                                                 SOCKET_API_RECV_END,
739                                                 info, "xdsx",
740                                                 (uint64_t)(&pBuffer),
741                                                 length, temp,
742                                                 (uint64_t)(rcvdLength));
743
744         return pret;
745 }
746
747 result Socket::Send(Tizen::Base::ByteBuffer& buffer) {
748         typedef result (Socket::*methodType)(Tizen::Base::ByteBuffer& buffer);
749         static methodType Sendp;
750         result pret;
751
752         BEFORE_ORIGINAL_TIZEN_NET(
753                         _ZN5Tizen3Net7Sockets6Socket4SendERNS_4Base10ByteBufferE, Sendp);
754
755         AFTER_ORIGINAL_TIZEN_SOCK_WAIT_FUNC_START("Socket::Send", VT_NULL, NULL,
756                                                   (unsigned int)this,
757                                                   (unsigned int)this,
758                                                   SOCKET_API_SEND_START,
759                                                   info, "x",
760                                                   (uint64_t)(&buffer));
761
762         pret = (this->*Sendp)(buffer);
763         int bufferSize = buffer.GetLimit();
764         char* pBuffer = (char*) (buffer.GetPointer());
765         Tizen::Base::String strData;
766         strData.SetCapacity(bufferSize);
767         strData.Append(pBuffer);
768         char* out = new char[bufferSize];
769         WcharToChar(out, strData.GetPointer());
770
771         info.msg_buf = out;
772         info.msg_total_size = bufferSize;
773         info.msg_pack_size = bufferSize > SOCKET_SEND_SIZE ? SOCKET_SEND_SIZE : bufferSize;
774
775         AFTER_ORIGINAL_TIZEN_SOCK_WAIT_FUNC_END("Socket::Send", VT_ULONG, pret,
776                                                 (unsigned int)this,
777                                                 (unsigned int)this,
778                                                 SOCKET_API_SEND_END,
779                                                 info, "x",
780                                                 (uint64_t)(&buffer));
781         delete [] out;
782         return pret;
783 }
784
785 result Socket::Send(void* pBuffer, int length, int& sentLength) {
786         typedef result (Socket::*methodType)(void* pBuffer, int length,
787                         int& sentLength);
788         static methodType Sendp;
789         result pret;
790
791         BEFORE_ORIGINAL_TIZEN_NET(
792                         _ZZN5Tizen3Net7Sockets6Socket4SendEPviRiE19__PRETTY_FUNCTION__,
793                         Sendp);
794
795         AFTER_ORIGINAL_TIZEN_SOCK_WAIT_FUNC_START("Socket::Send", VT_NULL, NULL,
796                                                   (unsigned int)this,
797                                                   (unsigned int)this,
798                                                   SOCKET_API_SEND_START,
799                                                   info, "xdx",
800                                                   (uint64_t)(&pBuffer),
801                                                   length,
802                                                   (uint64_t)(&sentLength));
803
804         pret = (this->*Sendp)(pBuffer, length, sentLength);
805
806         info.msg_buf = (char *)pBuffer;
807         info.msg_total_size = length;
808         info.msg_pack_size = length > SOCKET_SEND_SIZE ? SOCKET_SEND_SIZE : length;
809
810         AFTER_ORIGINAL_TIZEN_SOCK_WAIT_FUNC_END("Socket::Send", VT_ULONG, pret,
811                                                 (unsigned int)this,
812                                                 (unsigned int)this,
813                                                 SOCKET_API_SEND_END,
814                                                 info, "xdx",
815                                                 (uint64_t)(&pBuffer), length,
816                                                 (uint64_t)(&sentLength));
817
818         return pret;
819
820 }
821
822 result Socket::SendTo(Tizen::Base::ByteBuffer& buffer,
823                 const Tizen::Net::NetEndPoint& remoteEndPoint) {
824         typedef result (Socket::*methodType)(Tizen::Base::ByteBuffer& buffer,
825                         const Tizen::Net::NetEndPoint& remoteEndPoint);
826         static methodType SendTop;
827         result pret;
828
829         BEFORE_ORIGINAL_TIZEN_NET(
830                         _ZN5Tizen3Net7Sockets6Socket6SendToERNS_4Base10ByteBufferERKNS0_11NetEndPointE,
831                         SendTop);
832
833         Ip4Address* iv4PeerAddr = (Ip4Address*) remoteEndPoint.GetAddress();
834         char temp[64];
835         WcharToChar(temp, iv4PeerAddr->ToString().GetPointer());
836         char addressInfo[64];
837         sprintf(addressInfo, "%s:%d", temp, remoteEndPoint.GetPort());
838         info.host_port = remoteEndPoint.GetPort();
839         iv4PeerAddr->GetAddress(&info.host_ip);
840
841         AFTER_ORIGINAL_TIZEN_SOCK_WAIT_FUNC_START("Socket::SendTo", VT_NULL, NULL,
842                                                   (unsigned int)this,
843                                                   (unsigned int)this,
844                                                   SOCKET_API_SEND_START, 
845                                                   info, "xs",
846                                                   (uint64_t)(&buffer),
847                                                   temp);
848
849         pret = (this->*SendTop)(buffer, remoteEndPoint);
850
851         int bufferSize = buffer.GetLimit();
852         char* pBuffer = (char*) (buffer.GetPointer());
853         Tizen::Base::String strData;
854         strData.SetCapacity(bufferSize);
855         strData.Append(pBuffer);
856         char* out = new char[bufferSize];
857         WcharToChar(out, strData.GetPointer());
858
859         info.msg_buf = out;
860         info.msg_total_size = bufferSize;
861         info.msg_pack_size = bufferSize > SOCKET_SEND_SIZE ? SOCKET_SEND_SIZE : bufferSize;
862
863         AFTER_ORIGINAL_TIZEN_SOCK_WAIT_FUNC_END("Socket::SendTo", VT_ULONG, pret,
864                                                 (unsigned int)this,
865                                                 (unsigned int)this,
866                                                 SOCKET_API_SEND_END,
867                                                 info, "xs",
868                                                 (uint64_t)(&buffer),
869                                                 temp);
870         delete [] out;
871         return pret;
872 }
873
874 result Socket::SendTo(void* pBuffer, int length,
875                 const Tizen::Net::NetEndPoint& remoteEndPoint, int& sentLength) {
876         typedef result (Socket::*methodType)(void* pBuffer, int length,
877                         const Tizen::Net::NetEndPoint& remoteEndPoint, int& sentLength);
878         static methodType SendTop;
879         result pret;
880
881         BEFORE_ORIGINAL_TIZEN_NET(
882                         _ZN5Tizen3Net7Sockets6Socket6SendToEPviRKNS0_11NetEndPointERi,
883                         SendTop);
884
885         Ip4Address* iv4PeerAddr = (Ip4Address*) remoteEndPoint.GetAddress();
886         char temp[64];
887         WcharToChar(temp, iv4PeerAddr->ToString().GetPointer());
888         char addressInfo[64];
889         sprintf(addressInfo, "%s:%d", temp, remoteEndPoint.GetPort());
890         info.host_port = remoteEndPoint.GetPort();
891         iv4PeerAddr->GetAddress(&info.host_ip);
892
893         AFTER_ORIGINAL_TIZEN_SOCK_WAIT_FUNC_START("Socket::SendTo", VT_NULL, NULL,
894                         (unsigned int)this, (unsigned int)this, SOCKET_API_SEND_START, 
895                         info, "xdsx,",
896                         (unsigned int)&pBuffer, length, temp, (unsigned int)&sentLength);
897
898         pret = (this->*SendTop)(pBuffer, length, remoteEndPoint, sentLength);
899
900         info.msg_buf = (char *)pBuffer;
901         info.msg_total_size = length;
902         info.msg_pack_size = length > SOCKET_SEND_SIZE ? SOCKET_SEND_SIZE : length;
903
904         AFTER_ORIGINAL_TIZEN_SOCK_WAIT_FUNC_END("Socket::SendTo", VT_ULONG, pret,
905                         (unsigned int)this, (unsigned int)this, SOCKET_API_SEND_END,
906                         info, "xdsx,", (unsigned int)&pBuffer, length, temp,
907                         (unsigned int)&sentLength);
908
909         return pret;
910
911 }
912
913 //Option
914 result Socket::AddSocketListener(ISocketEventListener& listener) {
915         typedef result (Socket::*methodType)(ISocketEventListener& listener);
916         static methodType AddSocketListenerp;
917         result retVal;
918
919         BEFORE_ORIGINAL_TIZEN_NET(
920                         _ZN5Tizen3Net7Sockets6Socket17AddSocketListenerERNS1_20ISocketEventListenerE,
921                         AddSocketListenerp);
922
923         retVal = (this->*AddSocketListenerp)(listener);
924
925         AFTER_ORIGINAL_TIZEN_SOCK("Socket::AddSocketListener", VT_ULONG, retVal,
926                         (unsigned int)this, (unsigned int)this, SOCKET_API_OTHER, info,
927                         "x", (unsigned int) &listener);
928
929         return retVal;
930 }
931
932 result Socket::AsyncSelectByListener(unsigned long socketEventType) {
933         typedef result (Socket::*methodType)(unsigned long socketEventType);
934         static methodType AsyncSelectByListenerp;
935         result retVal;
936
937         BEFORE_ORIGINAL_TIZEN_NET(
938                         _ZN5Tizen3Net7Sockets6Socket21AsyncSelectByListenerEm,
939                         AsyncSelectByListenerp);
940
941         retVal = (this->*AsyncSelectByListenerp)(socketEventType);
942
943         AFTER_ORIGINAL_TIZEN_SOCK("Socket::AsyncSelectByListener", VT_ULONG, retVal,
944                         (unsigned int)this, (unsigned int)this, SOCKET_API_OTHER, info,
945                         "x", socketEventType);
946
947         return retVal;
948 }
949
950 result Socket::Ioctl(NetSocketIoctlCmd cmd, unsigned long& value) const {
951         typedef result (Socket::*methodType)(NetSocketIoctlCmd cmd,
952                         unsigned long& value) const;
953         static methodType Ioctlp;
954         result retVal;
955
956         BEFORE_ORIGINAL_TIZEN_NET(
957                         _ZNK5Tizen3Net7Sockets6Socket5IoctlENS1_17NetSocketIoctlCmdERm,
958                         Ioctlp);
959
960         retVal = (this->*Ioctlp)(cmd, value);
961
962         AFTER_ORIGINAL_TIZEN_SOCK("Socket::Ioctl", VT_ULONG, retVal,
963                                   (unsigned int)this, (unsigned int)this,
964                                   SOCKET_API_OTHER, info,
965                                   "dx", cmd, (uint64_t)(&value));
966
967         return retVal;
968 }
969
970 result Socket::SetSockOpt(NetSocketOptLevel optionLevel,
971                 NetSocketOptName optionName, int optionValue) {
972         typedef result (Socket::*methodType)(NetSocketOptLevel optionLevel,
973                         NetSocketOptName optionName, int optionValue);
974         static methodType SetSockOptp;
975         result retVal;
976
977         BEFORE_ORIGINAL_TIZEN_NET(
978                         _ZN5Tizen3Net7Sockets6Socket10SetSockOptENS1_17NetSocketOptLevelENS1_16NetSocketOptNameEi,
979                         SetSockOptp);
980
981         retVal = (this->*SetSockOptp)(optionLevel, optionName, optionValue);
982
983         AFTER_ORIGINAL_TIZEN_SOCK("Socket::SetSockOpt", VT_ULONG, retVal,
984                         (unsigned int)this, (unsigned int)this, SOCKET_API_OTHER, info,
985                         "ddd", optionLevel, optionName, optionValue);
986
987         return retVal;
988 }
989 result Socket::SetSockOpt(NetSocketOptLevel optionLevel,
990                 NetSocketOptName optionName, const LingerOption& optionValue) {
991         typedef result (Socket::*methodType)(NetSocketOptLevel optionLevel,
992                         NetSocketOptName optionName, const LingerOption& optionValue);
993         static methodType SetSockOptp;
994         result retVal;
995
996         BEFORE_ORIGINAL_TIZEN_NET(
997                         _ZN5Tizen3Net7Sockets6Socket10SetSockOptENS1_17NetSocketOptLevelENS1_16NetSocketOptNameERKNS1_12LingerOptionE,
998                         SetSockOptp);
999
1000         retVal = (this->*SetSockOptp)(optionLevel, optionName, optionValue);
1001
1002         AFTER_ORIGINAL_TIZEN_SOCK("Socket::SetSockOpt", VT_ULONG, retVal,
1003                                   (unsigned int)this, (unsigned int)this,
1004                                   SOCKET_API_OTHER, info,
1005                                   "ddx", optionLevel, optionName,
1006                                   (uint64_t)(&optionValue));
1007
1008         return retVal;
1009 }
1010 result Socket::SetSockOpt(NetSocketOptLevel optionLevel,
1011                 NetSocketOptName optionName,
1012                 const IpMulticastRequestOption& optionValue) {
1013         typedef result (Socket::*methodType)(NetSocketOptLevel optionLevel,
1014                         NetSocketOptName optionName,
1015                         const IpMulticastRequestOption& optionValue);
1016         static methodType SetSockOptp;
1017         result retVal;
1018
1019         BEFORE_ORIGINAL_TIZEN_NET(
1020                         _ZN5Tizen3Net7Sockets6Socket10SetSockOptENS1_17NetSocketOptLevelENS1_16NetSocketOptNameERKNS1_12LingerOptionE,
1021                         SetSockOptp);
1022
1023         retVal = (this->*SetSockOptp)(optionLevel, optionName, optionValue);
1024
1025         AFTER_ORIGINAL_TIZEN_SOCK("Socket::SetSockOpt", VT_ULONG, retVal,
1026                                   (unsigned int)this, (unsigned int)this,
1027                                   SOCKET_API_OTHER, info,
1028                                   "ddx", optionLevel, optionName,
1029                                   (uint64_t)(&optionValue));
1030
1031         return retVal;
1032 }
1033
1034 result Socket::GetSockOpt(NetSocketOptLevel optionLevel,
1035                 NetSocketOptName optionName, int& optionValue) const {
1036         typedef result (Socket::*methodType)(NetSocketOptLevel optionLevel,
1037                         NetSocketOptName optionName, int& optionValue) const;
1038         static methodType GetSockOptp;
1039         result retVal;
1040
1041         BEFORE_ORIGINAL_TIZEN_NET(
1042                         _ZNK5Tizen3Net7Sockets6Socket10GetSockOptENS1_17NetSocketOptLevelENS1_16NetSocketOptNameERi,
1043                         GetSockOptp);
1044
1045         retVal = (this->*GetSockOptp)(optionLevel, optionName, optionValue);
1046
1047         AFTER_ORIGINAL_TIZEN_SOCK("Socket::GetSockOpt", VT_ULONG, retVal,
1048                                   (unsigned int)this, (unsigned int)this,
1049                                   SOCKET_API_OTHER, info,
1050                                   "ddx", optionLevel, optionName,
1051                                   (uint64_t)(&optionValue));
1052
1053         return retVal;
1054 }
1055
1056 result Socket::GetSockOpt(NetSocketOptLevel optionLevel,
1057                 NetSocketOptName optionName, LingerOption& optionValue) const {
1058         typedef result (Socket::*methodType)(NetSocketOptLevel optionLevel,
1059                         NetSocketOptName optionName, LingerOption& optionValue) const;
1060         static methodType GetSockOptp;
1061         result retVal;
1062
1063         BEFORE_ORIGINAL_TIZEN_NET(
1064                         _ZNK5Tizen3Net7Sockets6Socket10GetSockOptENS1_17NetSocketOptLevelENS1_16NetSocketOptNameERNS1_12LingerOptionE,
1065                         GetSockOptp);
1066
1067         retVal = (this->*GetSockOptp)(optionLevel, optionName, optionValue);
1068
1069         AFTER_ORIGINAL_TIZEN_SOCK("Socket::GetSockOpt", VT_ULONG, retVal,
1070                                   (unsigned int)this, (unsigned int)this,
1071                                   SOCKET_API_OTHER, info,
1072                                   "ddx", optionLevel, optionName,
1073                                   (uint64_t)(&optionValue));
1074
1075         return retVal;
1076 }
1077
1078 result Socket::RemoveSocketListener(ISocketEventListener& listener) {
1079         typedef result (Socket::*methodType)(ISocketEventListener& listener);
1080         static methodType RemoveSocketListenerp;
1081         result retVal;
1082
1083         BEFORE_ORIGINAL_TIZEN_NET(
1084                         _ZN5Tizen3Net7Sockets6Socket20RemoveSocketListenerERNS1_20ISocketEventListenerE,
1085                         RemoveSocketListenerp);
1086
1087         retVal = (this->*RemoveSocketListenerp)(listener);
1088
1089         AFTER_ORIGINAL_TIZEN_SOCK("Socket::RemoveSocketListener", VT_ULONG, retVal,
1090                         (unsigned int)this, (unsigned int)this, SOCKET_API_OTHER, info,
1091                         "x", (uint64_t)(&listener));
1092
1093         return retVal;
1094 }
1095
1096 }
1097 }
1098 } //namespace Tizen {namespace Net {namespace Sockets {
1099