2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
11 #ifndef WEBRTC_TEST_CHANNEL_TRANSPORT_UDP_SOCKET_POSIX_H_
12 #define WEBRTC_TEST_CHANNEL_TRANSPORT_UDP_SOCKET_POSIX_H_
14 #include <arpa/inet.h>
15 #include <netinet/in.h>
16 #include <sys/socket.h>
17 #include <sys/types.h>
19 #include "webrtc/system_wrappers/interface/condition_variable_wrapper.h"
20 #include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
21 #include "webrtc/test/channel_transport/udp_socket_wrapper.h"
26 #define SOCKET_ERROR -1
28 class UdpSocketPosix : public UdpSocketWrapper
31 UdpSocketPosix(const int32_t id, UdpSocketManager* mgr,
32 bool ipV6Enable = false);
34 virtual ~UdpSocketPosix();
36 virtual int32_t ChangeUniqueId(const int32_t id) OVERRIDE;
38 virtual bool SetCallback(CallbackObj obj,
39 IncomingSocketCallback cb) OVERRIDE;
41 virtual bool Bind(const SocketAddress& name) OVERRIDE;
43 virtual bool SetSockopt(int32_t level, int32_t optname,
44 const int8_t* optval, int32_t optlen) OVERRIDE;
46 virtual int32_t SetTOS(const int32_t serviceType) OVERRIDE;
48 virtual int32_t SendTo(const int8_t* buf, int32_t len,
49 const SocketAddress& to) OVERRIDE;
51 // Deletes socket in addition to closing it.
52 // TODO (hellner): make destructor protected.
53 virtual void CloseBlocking() OVERRIDE;
57 virtual bool ValidHandle() OVERRIDE;
59 virtual bool SetQos(int32_t /*serviceType*/,
60 int32_t /*tokenRate*/,
61 int32_t /*bucketSize*/,
62 int32_t /*peekBandwith*/,
63 int32_t /*minPolicedSize*/,
64 int32_t /*maxSduSize*/,
65 const SocketAddress& /*stRemName*/,
66 int32_t /*overrideDSCP*/) OVERRIDE;
71 void ReadyForDeletion();
73 friend class UdpSocketManagerPosix;
76 IncomingSocketCallback _incomingCb;
80 UdpSocketManager* _mgr;
81 ConditionVariableWrapper* _closeBlockingCompletedCond;
82 ConditionVariableWrapper* _readyForDeletionCond;
84 bool _closeBlockingActive;
85 bool _closeBlockingCompleted;
86 bool _readyForDeletion;
88 CriticalSectionWrapper* _cs;
94 #endif // WEBRTC_TEST_CHANNEL_TRANSPORT_UDP_SOCKET_POSIX_H_