#!/bin/sh /etc/rc.common
# Copyright (C) 2013 OpenWrt.org 

START=88
USE_PROCD=1

log() {
	modlog "MHI" "$@"
}

do_zone() {
	local config=$1
	local name
	local network

	config_get name $1 name
	config_get network $1 network
	newnet="$network"
	if [ $name = lan ]; then
		WWAN=$(echo "$network" | grep "xlatd1")
		if [ -z "$WWAN" ]; then
			newnet="$newnet xlatd1"
			uci_set firewall "$config" network "$newnet"
			uci_commit firewall
			/etc/init.d/firewall restart
		fi
	fi
}

start_service()
{
	config_load firewall
	config_foreach do_zone zone
	uci delete network.xlatd1
	uci commit network
}
