+function validate_opt_family(m, section_id, opt) {
+ var sopt = m.section.getOption('src_ip'),
+ dopt = m.section.getOption('dest_ip'),
+ rwopt = m.section.getOption('snat_ip'),
+ fmopt = m.section.getOption('family'),
+ tgopt = m.section.getOption('target');
+
+ if (!sopt.isValid(section_id) && opt != 'src_ip')
+ return true;
+ if (!dopt.isValid(section_id) && opt != 'dest_ip')
+ return true;
+ if (!rwopt.isValid(section_id) && opt != 'snat_ip')
+ return true;
+ if (!fmopt.isValid(section_id) && opt != 'family')
+ return true;
+ if (!tgopt.isValid(section_id) && opt != 'target')
+ return true;
+
+ var sip = sopt.formvalue(section_id) || '',
+ dip = dopt.formvalue(section_id) || '',
+ rwip = rwopt.formvalue(section_id) || '',
+ fm = fmopt.formvalue(section_id) || '',
+ tg = tgopt.formvalue(section_id);
+
+ if (fm == 'ipv6' && (sip.indexOf(':') != -1 || sip == '') && (dip.indexOf(':') != -1 || dip == '') && ((rwip.indexOf(':') != -1 && tg == 'SNAT') || rwip == ''))
+ return true;
+ if (fm == 'ipv4' && (sip.indexOf(':') == -1) && (dip.indexOf(':') == -1) && ((rwip.indexOf(':') == -1 && tg == 'SNAT') || rwip == ''))
+ return true;
+ if (fm == '') {
+ if ((sip.indexOf(':') != -1 || sip == '') && (dip.indexOf(':') != -1 || dip == '') && ((rwip.indexOf(':') != -1 && tg == 'SNAT') || rwip == ''))
+ return true;
+ if ((sip.indexOf(':') == -1) && (dip.indexOf(':') == -1) && ((rwip.indexOf(':') == -1 && tg == 'SNAT') || rwip == ''))
+ return true;
+ }
+
+ return _('Address family, source address, destination address, rewrite IP address must match');
+}
+