From abccf94bbe664e80a0104c0cd9fd9c6cae062f16 Mon Sep 17 00:00:00 2001 From: giovanni Date: Mon, 6 Oct 2008 08:49:41 +0000 Subject: [PATCH] Some file moved and little changes --- backend.spec | 4 +- .../etc/udev/rules.d => }/96-umts-tools.rules | 0 backend/Makefile | 6 +- backend/TODO | 2 +- backend/VERSION | 2 +- backend/old/wvdial_umts.conf | 20 ---- backend/{root/etc/rc.d/init.d => }/umts | 0 backend/{root/vsys => }/umts_backend | 3 + backend/{root/usr/lib => }/umts_functions | 99 ++++++------------- frontend.spec | 2 +- frontend/VERSION | 2 +- frontend/umts.c | 2 +- 12 files changed, 46 insertions(+), 96 deletions(-) rename backend/{root/etc/udev/rules.d => }/96-umts-tools.rules (100%) delete mode 100644 backend/old/wvdial_umts.conf rename backend/{root/etc/rc.d/init.d => }/umts (100%) rename backend/{root/vsys => }/umts_backend (96%) rename backend/{root/usr/lib => }/umts_functions (84%) diff --git a/backend.spec b/backend.spec index abc1c5a..641e542 100644 --- a/backend.spec +++ b/backend.spec @@ -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 diff --git a/backend/root/etc/udev/rules.d/96-umts-tools.rules b/backend/96-umts-tools.rules similarity index 100% rename from backend/root/etc/udev/rules.d/96-umts-tools.rules rename to backend/96-umts-tools.rules diff --git a/backend/Makefile b/backend/Makefile index c7b8309..4cdfc87 100644 --- a/backend/Makefile +++ b/backend/Makefile @@ -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 \{} \; diff --git a/backend/TODO b/backend/TODO index f77c0ee..0849844 100644 --- a/backend/TODO +++ b/backend/TODO @@ -1,2 +1,2 @@ -0.5 +0.6 * Support more providers diff --git a/backend/VERSION b/backend/VERSION index bd73f47..2eb3c4f 100644 --- a/backend/VERSION +++ b/backend/VERSION @@ -1 +1 @@ -0.4 +0.5 diff --git a/backend/old/wvdial_umts.conf b/backend/old/wvdial_umts.conf deleted file mode 100644 index 4d0ac17..0000000 --- a/backend/old/wvdial_umts.conf +++ /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" diff --git a/backend/root/etc/rc.d/init.d/umts b/backend/umts similarity index 100% rename from backend/root/etc/rc.d/init.d/umts rename to backend/umts diff --git a/backend/root/vsys/umts_backend b/backend/umts_backend similarity index 96% rename from backend/root/vsys/umts_backend rename to backend/umts_backend index e65b9b8..b695763 100755 --- a/backend/root/vsys/umts_backend +++ b/backend/umts_backend @@ -1,5 +1,8 @@ #!/bin/bash +# Vsys backend of the planetlab-umts-tools + + sliver=$1 . /usr/lib/umts_functions diff --git a/backend/root/usr/lib/umts_functions b/backend/umts_functions similarity index 84% rename from backend/root/usr/lib/umts_functions rename to backend/umts_functions index 076c3af..c97c321 100644 --- a/backend/root/usr/lib/umts_functions +++ b/backend/umts_functions @@ -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 diff --git a/frontend.spec b/frontend.spec index 4838c8e..9c21c9e 100644 --- a/frontend.spec +++ b/frontend.spec @@ -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} diff --git a/frontend/VERSION b/frontend/VERSION index bd73f47..2eb3c4f 100644 --- a/frontend/VERSION +++ b/frontend/VERSION @@ -1 +1 @@ -0.4 +0.5 diff --git a/frontend/umts.c b/frontend/umts.c index f6c4d87..09455e8 100644 --- a/frontend/umts.c +++ b/frontend/umts.c @@ -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){ -- 2.43.0