/*
 * Copyright 2018 The Android Open Source Project
 *
 * 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.
 */

package android.system.net.netd@1.1;

import @1.0::INetd;

/**
 * This is the root of the HAL module and is the interface returned when
 * loading an implementation of the INetd HAL.
 */
interface INetd extends @1.0::INetd {
    /**
     * Add route to a specified OEM network
     * Either both, or one of the ifname and nexthop must be specified.
     *
     * @param networkHandle Handle to the OEM network previously returned from
     *                      @1.0::createOemNetwork.
     * @param ifname        Interface name specified by the route, or an empty
     *                      string for a route that does not specify an
     *                      interface.
     *                      For e.g. "dummy0"
     * @param destination   The destination prefix of the route in CIDR notation.
     *                      For e.g. 192.0.2.0/24 or 2001:db8:1::/48.
     * @param nexthop       IP address of the gateway for the route, or an empty
     *                      string for a directly-connected route. If non-empty,
     *                      must be of the same address family as the
     *                      destination.
     *                      For e.g. 10.0.0.1 or 2001:db8:1::cafe.
     */
    @callflow(next={"*"})
    addRouteToOemNetwork(uint64_t networkHandle, string ifname,
                         string destination, string nexthop)
              generates (StatusCode status);

    /**
     * Remove route from a specified OEM network.
     * Either both, or one of the ifname and nexthop must be specified.
     *
     * @param networkHandle Handle to the OEM network previously returned from
     *                      @1.0::createOemNetwork.
     * @param ifname        Interface name specified by the route, or an empty
     *                      string for a route that does not specify an
     *                      interface.
     *                      For e.g. "dummy0"
     * @param destination   The destination prefix of the route in CIDR notation.
     *                      For e.g. 192.0.2.0/24 or 2001:db8:1::/48.
     * @param nexthop       IP address of the gateway for the route, or an empty
     *                      string for a directly-connected route. If non-empty,
     *                      must be of the same address family as the
     *                      destination.
     *                      For e.g. 10.0.0.1 or 2001:db8:1::cafe.
     */
    @callflow(next={"*"})
    removeRouteFromOemNetwork(uint64_t networkHandle, string ifname,
                              string destination, string nexthop)
                   generates (StatusCode status);

    /**
     * Add interface to a specified OEM network
     *
     * @param networkHandle Handle to the OEM network previously returned from
     *                      @1.0::createOemNetwork.
     * @param ifname        Interface name to add to the OEM network.
     *                      For e.g. "dummy0".
     */
    @callflow(next={"*"})
    addInterfaceToOemNetwork(uint64_t networkHandle, string ifname)
                  generates (StatusCode status);

    /**
     * Remove interface from a specified OEM network.
     *
     * @param networkHandle Handle to the OEM network previously returned from
     *                      @1.0::createOemNetwork.
     * @param ifname        Interface name to remove from the OEM network.
     *                      For e.g. "dummy0".
     */
    @callflow(next={"*"})
    removeInterfaceFromOemNetwork(uint64_t networkHandle, string ifname)
                       generates (StatusCode status);

    /**
     * Enable IP forwarding on the system. Client must disable forwarding when
     * it's no longer needed.
     *
     * @param enable    bool to enable or disable forwarding.
     */
    @callflow(next={"*"})
    setIpForwardEnable(bool enable) generates (StatusCode status);

    /**
     * Enables forwarding between two interfaces, one of which must be in an
     * OEM network.
     *
     * @param inputIfName  Input interface. For e.g. "dummy0".
     * @param outputIfName Output interface. For e.g. "rmnet_data7".
     * @param enable       bool to enable or disable forwarding between the
     *                     two interfaces.
     */
    @callflow(next={"*"})
    setForwardingBetweenInterfaces(string inputIfName, string outputIfName,
                                   bool enable)
                        generates (StatusCode status);
};