// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef SERVICES_NETWORK_PUBLIC_CPP_P2P_PARAM_TRAITS_H_
#define SERVICES_NETWORK_PUBLIC_CPP_P2P_PARAM_TRAITS_H_

// IPC messages for the P2P Transport API.

#include <stdint.h>

#include "base/component_export.h"
#include "ipc/param_traits_macros.h"
#include "mojo/public/cpp/bindings/enum_traits.h"
#include "net/base/ip_address.h"
#include "net/base/network_interfaces.h"
#include "services/network/public/cpp/p2p_socket_type.h"
#include "services/network/public/mojom/p2p.mojom-shared.h"
#include "third_party/webrtc/rtc_base/async_packet_socket.h"

#ifndef INTERNAL_SERVICES_NETWORK_PUBLIC_CPP_P2P_PARAM_TRAITS_H_
#define INTERNAL_SERVICES_NETWORK_PUBLIC_CPP_P2P_PARAM_TRAITS_H_

#undef IPC_MESSAGE_EXPORT
#define IPC_MESSAGE_EXPORT COMPONENT_EXPORT(NETWORK_CPP_P2P)

namespace mojo {
template <>
struct COMPONENT_EXPORT(NETWORK_CPP_P2P)
    EnumTraits<network::mojom::EcnMarking, webrtc::EcnMarking> {
  static network::mojom::EcnMarking ToMojom(webrtc::EcnMarking input);
  static webrtc::EcnMarking FromMojom(network::mojom::EcnMarking input);
};
}  // namespace mojo

#endif  // INTERNAL_SERVICES_NETWORK_PUBLIC_CPP_P2P_PARAM_TRAITS_H_

IPC_ENUM_TRAITS_MAX_VALUE(network::P2PSocketType, network::P2P_SOCKET_TYPE_LAST)
IPC_ENUM_TRAITS_MAX_VALUE(network::P2PSocketOption,
                          network::P2P_SOCKET_OPT_MAX - 1)
IPC_ENUM_TRAITS_MIN_MAX_VALUE(webrtc::DiffServCodePoint,
                              webrtc::DSCP_NO_CHANGE,
                              webrtc::DSCP_CS7)

IPC_STRUCT_TRAITS_BEGIN(webrtc::PacketTimeUpdateParams)
  IPC_STRUCT_TRAITS_MEMBER(rtp_sendtime_extension_id)
  IPC_STRUCT_TRAITS_MEMBER(srtp_auth_key)
  IPC_STRUCT_TRAITS_MEMBER(srtp_auth_tag_len)
  IPC_STRUCT_TRAITS_MEMBER(srtp_packet_index)
IPC_STRUCT_TRAITS_END()

IPC_STRUCT_TRAITS_BEGIN(webrtc::AsyncSocketPacketOptions)
  IPC_STRUCT_TRAITS_MEMBER(dscp)
  IPC_STRUCT_TRAITS_MEMBER(ect_1)
  IPC_STRUCT_TRAITS_MEMBER(packet_id)
  IPC_STRUCT_TRAITS_MEMBER(packet_time_params)
IPC_STRUCT_TRAITS_END()

IPC_STRUCT_TRAITS_BEGIN(network::P2PHostAndIPEndPoint)
  IPC_STRUCT_TRAITS_MEMBER(hostname)
  IPC_STRUCT_TRAITS_MEMBER(ip_address)
IPC_STRUCT_TRAITS_END()

IPC_STRUCT_TRAITS_BEGIN(network::P2PSendPacketMetrics)
  IPC_STRUCT_TRAITS_MEMBER(packet_id)
  IPC_STRUCT_TRAITS_MEMBER(rtc_packet_id)
  IPC_STRUCT_TRAITS_MEMBER(send_time_ms)
IPC_STRUCT_TRAITS_END()

IPC_STRUCT_TRAITS_BEGIN(network::P2PPortRange)
  IPC_STRUCT_TRAITS_MEMBER(min_port)
  IPC_STRUCT_TRAITS_MEMBER(max_port)
IPC_STRUCT_TRAITS_END()

IPC_STRUCT_TRAITS_BEGIN(network::P2PPacketInfo)
  IPC_STRUCT_TRAITS_MEMBER(destination)
  IPC_STRUCT_TRAITS_MEMBER(packet_options)
  IPC_STRUCT_TRAITS_MEMBER(packet_id)
IPC_STRUCT_TRAITS_END()

#endif  // SERVICES_NETWORK_PUBLIC_CPP_P2P_PARAM_TRAITS_H_
