blob: ea6da1ba2aa6b046cd14365227ad887082150fcc [file] [log] [blame]
btolsch9ccfa782018-07-26 00:16:08 -07001// Copyright 2018 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef PLATFORM_API_SOCKET_H_
6#define PLATFORM_API_SOCKET_H_
7
8#include "base/ip_address.h"
9
10namespace openscreen {
11namespace platform {
12
13// Opaque type for the platform to implement.
btolsch56aa52a2018-09-10 11:40:12 -070014struct UdpSocketPrivate;
15using UdpSocketPtr = UdpSocketPrivate*;
btolsch9ccfa782018-07-26 00:16:08 -070016
btolsch56aa52a2018-09-10 11:40:12 -070017UdpSocketPtr CreateUdpSocketIPv4();
18UdpSocketPtr CreateUdpSocketIPv6();
btolsch9ccfa782018-07-26 00:16:08 -070019
20// Closes the underlying platform socket and frees any allocated memory.
btolsch56aa52a2018-09-10 11:40:12 -070021void DestroyUdpSocket(UdpSocketPtr socket);
btolsch9ccfa782018-07-26 00:16:08 -070022
btolsch56aa52a2018-09-10 11:40:12 -070023bool BindUdpSocket(UdpSocketPtr socket,
24 const IPEndpoint& endpoint,
25 int32_t ifindex);
26bool JoinUdpMulticastGroup(UdpSocketPtr socket,
27 const IPAddress& address,
28 int32_t ifindex);
btolsch9ccfa782018-07-26 00:16:08 -070029
btolsch56aa52a2018-09-10 11:40:12 -070030int64_t ReceiveUdp(UdpSocketPtr socket,
31 void* data,
32 int64_t length,
33 IPEndpoint* src,
34 IPEndpoint* original_destination);
35int64_t SendUdp(UdpSocketPtr socket,
36 const void* data,
37 int64_t length,
38 const IPEndpoint& dest);
btolsch9ccfa782018-07-26 00:16:08 -070039
40} // namespace platform
41} // namespace openscreen
42
btolscha21e8ed2018-08-30 15:13:48 -070043#endif // PLATFORM_API_SOCKET_H_