{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "$id": "https://api.byteblower.com/test-framework/json/test-cases/docsis-atp/mulpi-v4-0/ll-04-40/part1/config-schema.json",
    "title": "Test configuration parameters",
    "description": "Root structure of the JSON configuration file for the ByteBlower DOCSIS 4.0 ATP Test Case command-line interface.",
    "type": "object",
    "properties": {
        "server": {
            "$ref": "#/$defs/server_address"
        },
        "cpe": {
            "$ref": "#/$defs/port"
        },
        "nsi": {
            "$ref": "#/$defs/port"
        }
    },
    "additionalProperties": true,
    "$defs": {
        "server_address": {
            "$$target": "#/$defs/server_address",
            "title": "ByteBlower server address",
            "description": "Host name or IP address of the ByteBlower Server.",
            "type": "string",
            "oneOf": [
                {
                    "format": "hostname"
                },
                {
                    "format": "ipv4"
                },
                {
                    "format": "ipv6"
                }
            ]
        },
        "port": {
            "$$target": "#/$defs/port",
            "title": "Configuration parameters for a ByteBlower Port or Endpoint",
            "description": "Configuration parameters for a ByteBlower Port or Endpoint",
            "type": "object",
            "properties": {
                "name": {
                    "type": "string",
                    "description": "Name of this ByteBlower traffic endpoint.",
                    "$$description": [
                        "(typically ``Source`` for the tester entity, and ``Destination`` for the NUT)."
                    ]
                },
                "interface": {
                    "description": "Name of the physical ByteBlower interface where this ByteBlower port is created.",
                    "$$description": [
                        "*ByteBlower Port only*. Mutually exclusive with ``\"uuid\"``."
                    ],
                    "type": "string",
                    "pattern": "^(nontrunk[-][0-9]+|trunk[-][0-9]+[-][0-9]+)$"
                },
                "uuid": {
                    "type": "string",
                    "anyOf": [
                        {
                            "format": "uuid"
                        },
                        {
                            "pattern": "^[0-9a-zA-Z]$"
                        }
                    ],
                    "description": "Device identifier of the ByteBlower Endpoint.",
                    "$$description": [
                        "*ByteBlower Endpoint only*. Mutually exclusive with ``\"interface\"``.",
                        "",
                        ".. note::",
                        "   Using an Endpoint also requires the ``\"meeting_point\"`` to be provided",
                        "   *and* ``\"ipv4\"`` or ``\"ipv6\"`` set to ``true`` for this port configuration.",
                        ""
                    ]
                },
                "mac": {
                    "type": "string",
                    "description": "MAC address for the ByteBlower port",
                    "$$description": [
                        "*ByteBlower Port only*.",
                        "",
                        "Default: Auto-generated MAC address",
                        "",
                        ".. note::",
                        "   When using Byteblower Endpoint, the device's mac address will be used"
                    ],
                    "pattern": "^([0-9A-Fa-f]{2}([-:])){5}[0-9A-Fa-f]{2}$|^([0-9A-Fa-f]{4}\\.){2}[0-9A-Fa-f]{4}$",
                    "examples": [
                        "00:1A:2B:3C:4D:5E",
                        "00-1A-2B-3C-4D-5E",
                        "001A.2B3C.4D5E"
                    ]
                },
                "vlans": {
                    "type": "array",
                    "items": {
                        "$ref": "#/$defs/vlan"
                    },
                    "title": "VLAN (stack) configuration",
                    "description": "List of VLAN configurations for single VLAN or VLAN stack. See details in VLAN configuration.",
                    "$$description": [
                        ".. note::",
                        "   Not supported by ByteBlower Endpoint."
                    ]
                },
                "ipv4": {
                    "title": "IPv4 addressing method",
                    "description": "Enable IPv4 on this traffic endpoint.",
                    "$$description": [
                        "Supports the following values:",
                        "",
                        "- *IPv4 address* for static IPv4 IP address (*ByteBlower Port only*).",
                        "- ``\"dhcp\"`` for dynamic IPv4 address allocation (*ByteBlower Port only*).",
                        "- ``true``: To use the IPv4 address(es) of the system (*ByteBlower Endpoint only*).",
                        "",
                        "Default: ``\"dhcp\"`` (*ByteBlower Port*) or *undefined* (*ByteBlower Endpoint*).",
                        "",
                        ".. note::",
                        "   For ByteBlower Endpoint, you must specify either ``\"ipv4\": true`` or ``\"ipv6\": true``."
                    ],
                    "oneOf": [
                        {
                            "type": "string",
                            "oneOf": [
                                {
                                    "description": "IPv4 automatic address configuration",
                                    "enum": [
                                        "dhcp"
                                    ]
                                },
                                {
                                    "description": "IPv4 address for the ByteBlower Port",
                                    "format": "ipv4"
                                }
                            ]
                        },
                        {
                            "description": "Use IPv4 on the ByteBlower Endpoint",
                            "type": "boolean"
                        }
                    ]
                },
                "netmask": {
                    "type": "string",
                    "format": "ipv4",
                    "description": "Netmask of the IPv4 network.",
                    "$$description": [
                        "Default: *Assigned by DHCP* or ``255.255.255.0`` for static IPv4 address configuration.",
                        "",
                        ".. note::",
                        "   - Not supported by ByteBlower Endpoint."
                    ]
                },
                "gateway": {
                    "type": "string",
                    "oneOf": [
                        {
                            "format": "ipv4"
                        },
                        {
                            "format": "ipv6"
                        }
                    ],
                    "description": "Gateway of the IPv4/IPv6 network.",
                    "$$description": [
                        "Set the (default) gateway for IPv4 network or preferred router for IPv6 network",
                        "",
                        "Default: *Assigned by DHCP* or *none* for static IPv4 address configuration.",
                        "",
                        ".. note::",
                        "   - Not supported by ByteBlower Endpoint."
                    ]
                },
                "nat": {
                    "type": "boolean",
                    "description": "Define whether this port is located behind a NAT gateway.",
                    "$$description": [
                        "Defaults to ``false``.",
                        "",
                        ".. note::",
                        "   Enabled by default for ByteBlower Endpoint."
                    ]
                },
                "ipv6": {
                    "title": "IPv6 addressing method",
                    "description": "Enable IPv6 on this traffic endpoint.",
                    "$$description": [
                        "Supports the following values:",
                        "",
                        "- ``\"dhcp\"``: to let the port perform DHCPv6 (*ByteBlower Port only*)",
                        "- ``\"slaac\"``: to let the port perform stateless address auto-configuration (*ByteBlower Port only*).",
                        "- *IPv6 manual address list*: List of manual IPv6 addresses. (*ByteBlower Port only*)",
                        "   Each address definition consists of:",
                        "",
                        "   - ``\"address\"``: string of IPv6 address or IPv6 address with prefix length.",
                        "   - ``\"prefix_length\"``: string or integer defining the prefix length.",
                        "      Only used when the ``\"address\"`` field does not contain",
                        "      the prefix length. Defaults to :const:`DEFAULT_PREFIX_LENGTH` (``64``).",
                        "",
                        "- ``true``: To use the IPv6 address(es) of the system (*ByteBlower Endpoint only*).",
                        "",
                        "Default: *undefined*.",
                        "",
                        ".. note::",
                        "   For ByteBlower Endpoint, you must specify either ``\"ipv4\": true`` or ``\"ipv6\": true``."
                    ],
                    "oneOf": [
                        {
                            "description": "IPv6 automatic address configuration",
                            "type": "string",
                            "enum": [
                                "dhcp",
                                "slaac"
                            ]
                        },
                        {
                            "description": "List of IPv6 addresses",
                            "type": "array",
                            "items": {
                                "type": "object",
                                "properties": {
                                    "address": {
                                        "description": "IPv6 address",
                                        "type": "string",
                                        "format": "ipv6"
                                    },
                                    "prefix": {
                                        "description": "IPv6 address prefix length (0-128)",
                                        "oneOf": [
                                            {
                                                "type": "string"
                                            },
                                            {
                                                "type": "integer"
                                            }
                                        ],
                                        "minimum": 0,
                                        "maximum": 128
                                    }
                                }
                            }
                        },
                        {
                            "description": "Use IPv6 on the ByteBlower Endpoint",
                            "type": "boolean"
                        }
                    ]
                },
                "firewall": {
                    "type": "boolean",
                    "description": "Define whether this port is located behind a gateway that blocks IPv6 inbound traffic.",
                    "$$description": [
                        "Defaults to ``false``.",
                        "",
                        ".. note::",
                        "   IPv6 only.",
                        "   When enabled, inbound traffic will be allowed.",
                        "   Enabled by default for ByteBlower Endpoint."
                    ]
                }
            }
        },
        "vlan": {
            "title": "VLAN configuration",
            "$$target": "#/$defs/vlan",
            "type": "object",
            "properties": {
                "protocol_id": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 65535,
                    "description": "VLAN protocol ID (TPID).",
                    "$$description": [
                        "Default value is:",
                        "",
                        "- ``\"0x8100\"`` for a single VLAN configuration",
                        "- ``\"0x88a8\"`` for the outer VLAN(s) in a VLAN stack configuration",
                        "- ``\"0x8100\"`` for the most inner VLAN in a VLAN stack configuration.",
                        "",
                        ".. note::",
                        "   Configuration of the VLAN protocol ID (TPID) requires ByteBlower Server version >= 2.20.0."
                    ]
                },
                "id": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 4095,
                    "description": "VLAN ID (12-bit; 0-4095)"
                },
                "priority": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 3,
                    "description": "3 bits defining the VLAN PCP bits. Default: 0"
                },
                "drop_eligible": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 1,
                    "description": "1-bit flag. Default: 0"
                }
            }
        }
    }
}
