# Copyright (c) 2020-2021 Project CHIP Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import("//build_overrides/build.gni")
import("//build_overrides/chip.gni")
import("//build_overrides/nlassert.gni")
import("//build_overrides/nlfaultinjection.gni")

import("${chip_root}/build/chip/buildconfig_header.gni")
import("${chip_root}/build/chip/tests.gni")
import("${chip_root}/src/platform/device.gni")
import("inet.gni")

if (chip_system_config_use_open_thread_inet_endpoints) {
  import("//build_overrides/openthread.gni")
}

if (chip_system_config_use_lwip) {
  import("//build_overrides/lwip.gni")
}

declare_args() {
  # Extra header to include in SystemConfig.h for project.
  chip_inet_project_config_include = ""
}

buildconfig_header("inet_buildconfig") {
  header = "InetBuildConfig.h"
  header_dir = "inet"

  defines = [
    "INET_CONFIG_TEST=${chip_build_tests}",
    "INET_CONFIG_ENABLE_IPV4=${chip_inet_config_enable_ipv4}",
    "INET_CONFIG_ENABLE_TCP_ENDPOINT=${chip_inet_config_enable_tcp_endpoint}",
    "INET_CONFIG_ENABLE_UDP_ENDPOINT=${chip_inet_config_enable_udp_endpoint}",
    "HAVE_LWIP_RAW_BIND_NETIF=true",
  ]

  if (chip_inet_project_config_include != "") {
    defines +=
        [ "INET_PROJECT_CONFIG_INCLUDE=${chip_inet_project_config_include}" ]
  }
  if (chip_inet_platform_config_include != "") {
    defines +=
        [ "INET_PLATFORM_CONFIG_INCLUDE=${chip_inet_platform_config_include}" ]
  }

  defines += [ "INET_TCP_END_POINT_IMPL_CONFIG_FILE=<inet/TCPEndPointImpl${chip_system_config_inet}.h>" ]
  defines += [ "INET_UDP_END_POINT_IMPL_CONFIG_FILE=<inet/UDPEndPointImpl${chip_system_config_inet}.h>" ]

  visibility = [ ":inet_config_header" ]
}

source_set("inet_config_header") {
  sources = [ "InetConfig.h" ]

  public_configs = [ "${chip_root}/src:includes" ]

  public_deps = [ "${chip_root}/src/system:system_config_header" ]

  deps = [ ":inet_buildconfig" ]
}

static_library("inet") {
  output_name = "libInetLayer"

  sources = [
    "EndPointBasis.h",
    "EndPointState${chip_system_config_inet}.h",
    "IANAConstants.h",
    "IPAddress-StringFuncts.cpp",
    "IPAddress.cpp",
    "IPAddress.h",
    "IPPacketInfo.cpp",
    "IPPacketInfo.h",
    "IPPrefix.cpp",
    "IPPrefix.h",
    "Inet.h",
    "InetArgParser.cpp",
    "InetArgParser.h",
    "InetError.cpp",
    "InetError.h",
    "InetInterface.cpp",
    "InetInterface.h",
    "InetLayer.h",
    "arpa-inet-compatibility.h",
  ]

  public_deps = [
    ":inet_config_header",
    "${chip_root}/src/lib/core:types",
    "${chip_root}/src/lib/support",
    "${chip_root}/src/platform:platform_config_header",
    "${chip_root}/src/system",
  ]

  if (chip_system_config_use_lwip) {
    sources += [ "EndPointStateLwIP.cpp" ]
    public_deps += [ "${lwip_root}:lwip" ]
  }

  if (chip_system_config_use_open_thread_inet_endpoints) {
    public_deps += [ "${chip_root}/third_party/openthread:openthread" ]
  }

  if (chip_inet_config_enable_tcp_endpoint) {
    sources += [
      "TCPEndPoint.cpp",
      "TCPEndPoint.h",
      "TCPEndPointImpl${chip_system_config_inet}.cpp",
      "TCPEndPointImpl${chip_system_config_inet}.h",
      "TCPEndPointImpl.h",
    ]
  }

  if (chip_inet_config_enable_udp_endpoint) {
    sources += [
      "BasicPacketFilters.h",
      "EndpointQueueFilter.h",
      "UDPEndPoint.cpp",
      "UDPEndPoint.h",
      "UDPEndPointImpl${chip_system_config_inet}.cpp",
      "UDPEndPointImpl${chip_system_config_inet}.h",
      "UDPEndPointImpl.h",
    ]
  }

  if (chip_with_nlfaultinjection) {
    sources += [
      "InetFaultInjection.cpp",
      "InetFaultInjection.h",
    ]
    public_deps += [ "${nlfaultinjection_root}:nlfaultinjection" ]
  }

  if (current_os == "android") {
    public_deps += [ "${chip_root}/src/platform/android:inet" ]
  } else {
    sources += [ "InetInterfaceImplDefault.cpp" ]
  }

  cflags = [ "-Wconversion" ]
}
