aboutsummaryrefslogtreecommitdiffstats
path: root/vnfs/vIPSEC/scripts/v_sink_init.sh
diff options
context:
space:
mode:
authorRuoyu Ying <ruoyu.ying@intel.com>2019-04-16 19:15:45 +0800
committerRuoyu Ying <ruoyu.ying@intel.com>2019-04-16 19:17:33 +0800
commit15411868bad0ac9ca4831335442f0b4798e43a4b (patch)
treebb7fee9f3ba7c3876a042a61c490422b99045037 /vnfs/vIPSEC/scripts/v_sink_init.sh
parentd1bef8a2a799a275568642c27fe14ea706b0d166 (diff)
Add scripts for vIPSEC VNF
- Add scripts for vPacketgen and vSink that would be used in vIPSEC VNF. - Fixed minor bugs inside the base_vipsec.yaml Change-Id: Ide06fa3f05babe99a9728653a6d2ac214696049e Issue-ID: INT-793 Signed-off-by: Ruoyu Ying <ruoyu.ying@intel.com>
Diffstat (limited to 'vnfs/vIPSEC/scripts/v_sink_init.sh')
-rwxr-xr-xvnfs/vIPSEC/scripts/v_sink_init.sh17
1 files changed, 17 insertions, 0 deletions
diff --git a/vnfs/vIPSEC/scripts/v_sink_init.sh b/vnfs/vIPSEC/scripts/v_sink_init.sh
new file mode 100755
index 00000000..85c9073b
--- /dev/null
+++ b/vnfs/vIPSEC/scripts/v_sink_init.sh
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+# Convert Network CIDR to Netmask
+cdr2mask () {
+ # Number of args to shift, 255..255, first non-255 byte, zeroes
+ set -- $(( 5 - ($1 / 8) )) 255 255 255 255 $(( (255 << (8 - ($1 % 8))) & 255 )) 0 0 0
+ [ $1 -gt 1 ] && shift $1 || shift
+ echo ${1-0}.${2-0}.${3-0}.${4-0}
+}
+
+# Set the IP address of the protected network interface of the vIPsec as a default gateway to the unprotected network
+PROTECTED_NET_GW=$(cat /opt/config/protected_net_gw.txt)
+PROTECTED_NET_A=$(cat /opt/config/protected_net_A.txt | cut -d'/' -f1)
+BITS=$(cat /opt/config/protected_net_A.txt | cut -d"/" -f2)
+NETMASK=$(cdr2mask $BITS)
+
+route add -net $PROTECTED_NET_A netmask $NETMASK gw $PROTECTED_NET_GW