From 410023fd604af49434ed5039c99c7ee6abc99b20 Mon Sep 17 00:00:00 2001
From: Daniil Baturin <daniil.baturin@vyatta.com>
Date: Fri, 4 Nov 2011 04:46:00 +0700
Subject: Initial commit.

---
 templates/system/conntrack/modules/sip/node.def | 61 +++++++++++++++++++++++++
 1 file changed, 61 insertions(+)
 create mode 100644 templates/system/conntrack/modules/sip/node.def

(limited to 'templates/system/conntrack/modules/sip/node.def')

diff --git a/templates/system/conntrack/modules/sip/node.def b/templates/system/conntrack/modules/sip/node.def
new file mode 100644
index 0000000..b5a3225
--- /dev/null
+++ b/templates/system/conntrack/modules/sip/node.def
@@ -0,0 +1,61 @@
+help: SIP connection tracking settings
+
+end: /bin/cli-shell-api existsEffective system conntrack modules sip disable && exit 0
+  reload=0
+  sdm=2
+  if [ -f /sys/module/nf_conntrack_sip/parameters/sip_direct_media ]; then
+    sdm=$(sudo cat /sys/module/nf_conntrack_sip/parameters/sip_direct_media)
+  fi
+  if [ -n "$VAR(./enable-indirect-media)" ]; then
+    indirectmedia='sip_direct_media=0'
+    if [ $sdm -ge 1 ]; then reload=1; fi
+  else
+    if [ $sdm -eq 0 ]; then reload=1; fi
+  fi
+
+  sds=2
+  if [ -f /sys/module/nf_conntrack_sip/parameters/sip_direct_signalling ]; then
+    sds=$(sudo cat /sys/module/nf_conntrack_sip/parameters/sip_direct_signalling)
+  fi
+  if [ -n "$VAR(./enable-indirect-signalling)" ]; then
+    indirectsignalling='sip_direct_signalling=0'
+    if [ $sds -ge 1 ]; then reload=1; fi
+  else
+    if [ $sds -eq 0 ]; then reload=1; fi
+  fi
+
+  if [ -n "$VAR(./port/@@)" ]; then
+     numports=0
+     for port in $VAR(./port/@@); do
+     	 if [ -z "$portval" ]; then
+     	     portval=$port
+	 else
+	     portval="${portval},$port"
+	 fi
+	 (( numports++ ))
+     done
+     portopt="ports=$portval"
+     if [ $numports -gt 8 ]; then
+     	echo "Error: Can not specify more than 8 ports."
+	exit 1
+     fi
+     reload=1
+  fi
+
+  if [ -f /etc/modprobe.d/options ]; then
+    sudo sed -i '/nf_conntrack_sip/d' /etc/modprobe.d/options
+  fi
+
+  if [ -n "$indirectmedia" ] || [ -n "$indirectsignalling" ] || \
+      [ -n "$portopt" ]; then
+      sudo sh -c "echo \# Auto-generated by `whoami` at `date` > /etc/modprobe.d/vyatta_sip_options.conf"
+      sudo sh -c "echo options nf_conntrack_sip $indirectmedia $indirectsignalling $portopt >> /etc/modprobe.d/vyatta_sip_options.conf "
+  else
+      sudo rm -f /etc/modprobe.d/vyatta_sip_options.conf
+  fi
+
+  if [ $reload -eq 1 ]; then
+    sudo modprobe -r nf_nat_sip nf_conntrack_sip
+    sudo modprobe nf_conntrack_sip
+    sudo modprobe nf_nat_sip
+  fi
-- 
cgit v1.2.3

