Some file moved and little changes
authorgiovanni <giovanni@41d37cc5-eb28-0410-a9bf-d37491348ade>
Mon, 6 Oct 2008 08:49:41 +0000 (08:49 +0000)
committergiovanni <giovanni@41d37cc5-eb28-0410-a9bf-d37491348ade>
Mon, 6 Oct 2008 08:49:41 +0000 (08:49 +0000)
12 files changed:
backend.spec
backend/96-umts-tools.rules [moved from backend/root/etc/udev/rules.d/96-umts-tools.rules with 100% similarity]
backend/Makefile
backend/TODO
backend/VERSION
backend/old/wvdial_umts.conf [deleted file]
backend/umts [moved from backend/root/etc/rc.d/init.d/umts with 100% similarity]
backend/umts_backend [moved from backend/root/vsys/umts_backend with 96% similarity]
backend/umts_functions [moved from backend/root/usr/lib/umts_functions with 84% similarity]
frontend.spec
frontend/VERSION
frontend/umts.c

index abc1c5a..641e542 100644 (file)
@@ -2,7 +2,7 @@
 
 %define name planetlab-umts-tools-backend
 %define version 0.5
-%define release 1
+%define release 2
 
 Summary: Umts-tools for PlanetLab - backend part
 Name: %{name}
@@ -33,7 +33,7 @@ pushd backend
 rm -rf $RPM_BUILD_ROOT
 mkdir -p $RPM_BUILD_ROOT
 make clean
-cp -af root/* $RPM_BUILD_ROOT/
+make install prefix=$RPM_BUILD_ROOT
 popd
 
 %clean
index c7b8309..4cdfc87 100644 (file)
@@ -1,8 +1,10 @@
 
 
 install:
-       cp -a root/* /
-       @chkconfig umts on
+       install -D umts_functions ${prefix}/usr/lib/umts_functions
+       install -D umts_backend ${prefix}/vsys/umts_backend
+       install -D 96-umts-tools.rules ${prefix}/etc/udev/rules.d/96-umts-tools.rules
+       install -D umts ${prefix}/etc/rc.d/init.d/umts
 
 clean:
        find . -name "*~" -exec rm \{} \;
index f77c0ee..0849844 100644 (file)
@@ -1,2 +1,2 @@
-0.5
+0.6
 * Support more providers
index bd73f47..2eb3c4f 100644 (file)
@@ -1 +1 @@
-0.4
+0.5
diff --git a/backend/old/wvdial_umts.conf b/backend/old/wvdial_umts.conf
deleted file mode 100644 (file)
index 4d0ac17..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-[Dialer Defaults]
-Phone = *99***1#
-Username = any
-Password = any
-Stupid Mode = 1
-Dial Command = ATDT
-
-[Dialer hsdpa]
-Modem = /dev/umts_modem
-Baud = 460800
-Init2 = ATZ
-Init3 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
-ISDN = 0
-Modem Type = Analog Modem
-[Dialer 2gonly]
-Init4 = AT+COPS=0,0,"web.vodafone.it",0
-[Dialer 3gonly]
-Init4 = AT+COPS=0,0,"web.vodafone.it",2
-[Dialer vodafone]
-Init5 = AT+CGDCONT=1,"IP","web.vodafone.it"
similarity index 96%
rename from backend/root/vsys/umts_backend
rename to backend/umts_backend
index e65b9b8..b695763 100755 (executable)
@@ -1,5 +1,8 @@
 #!/bin/bash
 
+# Vsys backend of the planetlab-umts-tools
+
+
 sliver=$1
 
 . /usr/lib/umts_functions
similarity index 84%
rename from backend/root/usr/lib/umts_functions
rename to backend/umts_functions
index 076c3af..c97c321 100644 (file)
@@ -1,6 +1,5 @@
 #!/bin/bash
 
-
 PPPD_PIDFILE=/var/run/umts_pppd.pid
 
 PPPD=pppd
@@ -17,7 +16,7 @@ DESTS_FILE="/tmp/umts_dest_file"
 
 FILE_TEMP_NID="/tmp/umts_temp_nid"
 
-FILE_UMTS_INT="/var/run/umts_int"
+FILE_UMTS_INT="/tmp/umts_dev"
 
 
 function set_umts_dev(){
@@ -75,74 +74,41 @@ function init(){
 }
 
 
-
-
 function get_temp_nid(){
        cat $FILE_TEMP_NID
 }
 
 
-function workaround_on(){
-       local sliver_nid=$1
-       local temp_nid=$2
-
-       iptables -t mangle -A OUTPUT -j MARK --copy-xid 0x00
-       iptables -t mangle -A OUTPUT -m mark --mark $sliver_nid -j MARK --set-mark $temp_nid
-       iptables -t nat -A POSTROUTING -o $PPP_INT -j SNAT --to-source `get_ppp_address`
-       iptables -t mangle -I POSTROUTING 1 -m mark --mark $temp_nid -j MARK --set-mark $sliver_nid
-
-#      iptables -t mangle -D POSTROUTING -j MARK --copy-xid 0x00
-#      iptables -t mangle -I POSTROUTING 1 ! -p icmp -j MARK --copy-xid 0x00 
-
-}
-
-function workaround_off(){
-       local sliver_nid=$1
-       local temp_nid=$2
-
-       iptables -t mangle -D OUTPUT -j MARK --copy-xid 0x00
-       iptables -t mangle -D OUTPUT -m mark --mark $sliver_nid -j MARK --set-mark $temp_nid
-       iptables -t nat -D POSTROUTING -o $PPP_INT -j SNAT --to-source `get_ppp_address`
-       iptables -t mangle -D POSTROUTING -m mark --mark $temp_nid -j MARK --set-mark $sliver_nid
-
-#      iptables -t mangle -I POSTROUTING 1 -j MARK --copy-xid 0x00
-#      iptables -t mangle -D POSTROUTING ! -p icmp -j MARK --copy-xid 0x00 
-}
-
-#called when the connection is up
+#called when the connection is started
 function conn_on(){
        local sliver=$1
-       local sliver_nid=$2
+       #local sliver_nid=$2
 
-       #add_interface $1
+       #DESTS_FILE contains added destinations
        rm -f $DESTS_FILE 
-
        touch $DESTS_FILE > /dev/null 2>&1
 
-       
        set_temp_nid $sliver_nid
-       local temp_nid=`get_temp_nid`
 
        set_routes $sliver
 
-
-       workaround_on $sliver_nid $temp_nid
-
        cat $LOGF | grep "local"
        return 0
 
 }
 
-#called when the connection is down
+#called when the connection is terminated
 function conn_off(){
        local sliver=$1
-       local sliver_nid=$2
-
-       temp_nid=`get_temp_nid`
-       workaround_off  $sliver_nid $temp_nid
+       #local sliver_nid=$2
 
        unset_routes $sliver
 
+       for i in `cat $DESTS_FILE`; do
+               del_destination $i $sliver > /dev/null 2>&1
+       done
+
+       rm $DESTS_FILE >/dev/null 2>&1
 }
 
 function start_umts(){
@@ -242,50 +208,51 @@ function add_interface(){
 
 #remove the ppp interface from the slice - not used at the moment
 function del_interface(){
-    #not working yet because of naddress incompleteness
     local nid=`get_nid $1`
     #$NADDRESS --remove --nid $NID --ip $PPP_INT >>$LOGFILE 2>&1;
 }
 
-#get slice network id needed by naddress
+#get slice network id
 function get_nid(){
-    #NIDFILE="/usr/local/etc/vservers/${1}/context"
-    #cat $NIDFILE
     id -u ${1}
 }
 
-#enable the explicit bind to the ppp interface
 function set_routes(){
        local sliver=$1
        local sliver_nid=`get_nid $sliver`
-       PPP_ADDR=`get_ppp_address`
-
+       local temp_nid=`get_temp_nid`
+       local ppp_addr=`get_ppp_address`
 
+       #remarking of packets to trigger rerouting and SNAT
+       iptables -t mangle -A OUTPUT -j MARK --copy-xid 0x00
+       iptables -t mangle -A OUTPUT -m mark --mark $sliver_nid -j MARK --set-mark $temp_nid
+       iptables -t nat -A POSTROUTING -o $PPP_INT -j SNAT --to-source `get_ppp_address`
+       iptables -t mangle -I POSTROUTING 1 -m mark --mark $temp_nid -j MARK --set-mark $sliver_nid
+       
+       #enable the explicit bind to the ppp interface
        ip route flush table umts_table >/dev/null 2>&1 
-
-       # OLD ip rule add from $PPP_ADDR fwmark $sliver_nid table umts_table >/dev/null 2>&1
-       ip rule add from $PPP_ADDR fwmark `get_temp_nid` table umts_table >/dev/null 2>&1
-
+       ip rule add from $ppp_addr fwmark `get_temp_nid` table umts_table >/dev/null 2>&1
        ip route add default dev $PPP_INT src `get_ppp_address` table umts_table >/dev/null 2>&1
        ip route flush cache  >/dev/null 2>&1
 }
 
-#disable the explicit bind to the ppp interface
 function unset_routes(){
        local sliver=$1
        local sliver_nid=`get_nid $sliver`
+       local temp_nid=`get_temp_nid`
        local ppp_addr=`get_ppp_address`
 
+       #remarking and SNAT removed 
+       iptables -t mangle -D OUTPUT -j MARK --copy-xid 0x00
+       iptables -t mangle -D OUTPUT -m mark --mark $sliver_nid -j MARK --set-mark $temp_nid
+       iptables -t nat -D POSTROUTING -o $PPP_INT -j SNAT --to-source `get_ppp_address`
+       iptables -t mangle -D POSTROUTING -m mark --mark $temp_nid -j MARK --set-mark $sliver_nid
+
+       #disable the explicit bind to the ppp interface
        ip rule del from $ppp_addr fwmark `get_temp_nid` table umts_table  >/dev/null 2>&1
        ip route del default dev $PPP_INT  src `get_ppp_address` table umts_table >/dev/null 2>&1
        ip route flush cache  >/dev/null 2>&1
 
-       for i in `cat $DESTS_FILE`; do
-               del_destination $i $sliver > /dev/null 2>&1
-       done
-
-       rm $DESTS_FILE >/dev/null 2>&1
-
 }
 
 function add_destination(){
@@ -302,7 +269,6 @@ function add_destination(){
                return 1;
        fi
        
-       #old - if ip route add to "$dest" dev $PPP_INT >/dev/null 2>&1  ;  then
        if ip rule add to "$dest" fwmark $temp_nid table umts_table >/dev/null 2>&1; then
                echo "$dest" >> $DESTS_FILE
                return 0
@@ -337,10 +303,9 @@ function get_ppp_address(){
 
 function set_temp_nid(){
        local sliver_nid=$1
-       temp_nid=$((0x20000+$sliver_nid))
-       #k=0
+       local temp_nid=$((0x20000+$sliver_nid))
 
-       #FIXME
+       #k=0
        #temp_nid=$sliver_nid
        
        #while grep :$temp_nid: /etc/passwd; do
index 4838c8e..9c21c9e 100644 (file)
@@ -2,7 +2,7 @@
 
 %define name planetlab-umts-tools-frontend
 %define version 0.5
-%define release 1
+%define release 2
 
 Summary: UMTS tools for PlanetLab
 Name: %{name}
index bd73f47..2eb3c4f 100644 (file)
@@ -1 +1 @@
-0.4
+0.5
index f6c4d87..09455e8 100644 (file)
@@ -76,7 +76,7 @@ int main(int argc, char **argv, char **envp){
 
        if (flock(lock_fd, LOCK_EX |  LOCK_NB)){
                if (errno == EWOULDBLOCK){
-                       printf("An operation is already being performed");
+                       printf("An operation is already being performed.\n");
                        close(lock_fd);
                        exit(1);
                } else if (errno == EBADF){