# Path: netjsonconfig/backends/openwrt/schema.py



from collections import OrderedDict
from copy import deepcopy
from ipaddress import ip_address, ip_interface
from ..schema import schema
from .base import OpenWrtConverter
        if not isinstance(ipv6, list):
            netmask = interface.pop('netmask', 128)
            parsed_ip = self.__netjson_parse_ip(ipv6, netmask)
            ipv6 = [parsed_ip] if parsed_ip else []
        if proto.startswith('dhcp'):
            family = 'ipv4' if proto == 'dhcp' else 'ipv6'
            addresses.append({'proto': 'dhcp', 'family': family})
        for address in ipv4 + ipv6:
            address = self.__netjson_parse_ip(address)
            if not address:
                continue
            addresses.append(self.__netjson_address(address, interface))
        if addresses:
            interface['addresses'] = addresses
        return interface

    def _netjson_dialup(self, interface):
        interface['type'] = 'dialup'
        return interface

    _modem_manager_schema = schema['definitions']['modemmanager_interface']['allOf'][0]

    def _netjson_modem_manager(self, interface):
        del interface['proto']
        interface['type'] = 'modem-manager'
        interface['pin'] = interface.pop('pincode', None)
        return self.type_cast(interface, schema=self._modem_manager_schema)

    _netjson_modemmanager = _netjson_modem_manager


# Path: netjsonconfig/backends/openwrt/schema.py



# Path: netjsonconfig/backends/openwrt/converters/interfaces.py
from collections import OrderedDict
from copy import deepcopy
from ipaddress import ip_address, ip_interface
from ..schema import schema
from .base import OpenWrtConverter

        if not isinstance(ipv6, list):
            netmask = interface.pop('netmask', 128)
            parsed_ip = self.__netjson_parse_ip(ipv6, netmask)
            ipv6 = [parsed_ip] if parsed_ip else []
        if proto.startswith('dhcp'):
            family = 'ipv4' if proto == 'dhcp' else 'ipv6'
            addresses.append({'proto': 'dhcp', 'family': family})
        for address in ipv4 + ipv6:
            address = self.__netjson_parse_ip(address)
            if not address:
                continue
            addresses.append(self.__netjson_address(address, interface))
        if addresses:
            interface['addresses'] = addresses
        return interface

    def _netjson_dialup(self, interface):
        interface['type'] = 'dialup'
        return interface

    _modem_manager_schema = schema['definitions']['modemmanager_interface']['allOf'][0]

    def _netjson_modem_manager(self, interface):
        del interface['proto']
        interface['type'] = 'modem-manager'
        interface['pin'] = interface.pop('pincode', None)
        return self.type_cast(interface, schema=self._modem_manager_schema)

    _netjson_modemmanager = _netjson_modem_manager


    _wireguard_schema = schema['definitions']['wireguard_interface']['allOf'][0]