Author: viethen Date: Mon Mar 26 08:11:17 2012 New Revision: 2959 Log: Add Fahad's and Nikou's scripts for the webif GUI. Added: trunk/pairing/webif/mobileaccess-cert.sh (contents, props changed) trunk/pairing/webif/mobileaccess-hip.sh (contents, props changed) trunk/pairing/webif/mobileaccess-pisa.sh (contents, props changed) Added: trunk/pairing/webif/mobileaccess-cert.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ trunk/pairing/webif/mobileaccess-cert.sh Mon Mar 26 08:11:17 2012 (r2959) @@ -0,0 +1,41 @@ +#!/usr/bin/webif-page +<? +# Copyright (c) 2012, Distributed Systems Group, RWTH Aachen +# All rights reserved. + +################################################################### +# Certificate Information +# +# Description: +# Certification of the Access Point +# +# Author(s) [in order of work date]: +# <nikou.gholizadeh@xxxxxxxxxxxxxx> +# +# Major revisions: +# +# TODO: +# + +. /usr/lib/webif/webif.sh + +header "MobileACcess" "Certificate Information" "Trust Point certificate, as issued by the Community Operator" ' onload="modechange()" ' "$SCRIPT_NAME" "" 0 + +echo "<br>" + +####################################################### + +cert_path='/etc/hip/host-cert.der' + +pisa-cert-info $cert_path + +#show form +# + +footer ?> + +<!-- +##WEBIF:name:MobileACcess:8:Cert Info +--> + + Added: trunk/pairing/webif/mobileaccess-hip.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ trunk/pairing/webif/mobileaccess-hip.sh Mon Mar 26 08:11:17 2012 (r2959) @@ -0,0 +1,167 @@ +#!/usr/bin/webif-page +<% +# Copyright (c) 2012, Distributed Systems Group, RWTH Aachen +# All rights reserved. + +################################################################### +# PiSA Connections +# +# Description: +# Retrives the connection information for pisa client and server daemon +# +# Author(s) [in order of work date]: +# <nikou.gholizadeh@xxxxxxxxxxxxxx> +# <fahad.aizaz@xxxxxxxxxxxxxx> +# +# Major revisions: +# +# TODO: +# + +. /usr/lib/webif/webif.sh + +header "MobileACcess" "HIP Connections" "HIP Connection Information" "$SCRIPT_NAME" "" 0 +################## VARIABLE DECLARATIONS ###################### +HIP_DAEMON='hipd' +HIP_FIREWALL='hipfw' +HIP_UTILITY='hipconf' +############################################################### + +hipd_not_running () { + echo "<b>${HIP_DAEMON}</b> is not running.<br>" + echo "Please start the <b>${HIP_DAEMON}</b> process before checking further information." +} + +hipd_get_local_hit () { + LOCAL_HIT=$($HIP_UTILITY daemon get hi default 2>&1 | grep "Default HIT" | awk '{ print $3 }' ); + printf "<p><b>Local HIT:</b> %s</p>" $LOCAL_HIT +} + +hipd_parse_all_peers () { + RESULT=$($HIP_UTILITY daemon get ha all 2>&1 | tail +5); + if [[ -z "$RESULT" ]]; then + echo "<b>No peers found.</b><br>" + else + + table='<tr><th>DESTINATION IP</th><th>DESTINATION HIT</th><th>STATUS</th><th>HOSTNAME</th></tr>' + echo $table + + i=1; + IFS=$'\n' + for line in $RESULT + do + if [ $(($i%13)) -eq 0 ]; then + i=1 + printf "<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>\n" $PEER_IP $HIT $STATUS $PEER_NAME + fi + case "$i" in + 1) + STATUS=$(echo $line | awk '{ print $3 }') + ;; + 5) + HIT=$(echo $line | awk '{ print $3 }') + ;; + 10) + PEER_IP=$(echo $line | awk '{ print $3 }') + ;; + 12) + PEER_NAME=$(echo $line | awk '{ print $3 }') + ;; + esac + + i=$((i+1)); + done + printf "<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>\n" $PEER_IP $HIT $STATUS $PEER_NAME + fi +} + +hipfw_not_running () { + echo "<b>${HIP_FIREWALL}</b> is not running.<br>" + echo "Please start the <b>${HIP_FIREWALL}</b> process before checking further information." + exit 0 +} + +hipfw_parse_all_tunnels () { + + RESULT=$($HIP_UTILITY firewall get ha all 2>&1 | tail +3) + if [[ -z "$RESULT" ]]; then + echo "<br><b>No tunnels found.</b><br>" + else + table='<tr><th>SOURCE HIT</th><th>DESTINATION HIT</th><th>SOURCE PORT</th><th>DESTINATION PORT</th><th>STATUS</th></tr>' + echo $table + i=1 + IFS=$'\n' + for line in $RESULT + do + if [ $(($i%13)) -eq 0 ]; then + i=1 + + printf "<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>\n" $SOURCE $DEST $SRC_PORT $DST_PORT $STATUS + fi + + case "$i" in + 1) + STATUS=$(echo $line | awk '{ print $3 }') + ;; + 4) + SOURCE=$(echo $line | awk '{ print $3 }') + ;; + 5) + DEST=$(echo $line | awk '{ print $3 }') + ;; + 9) + SRC_PORT=$(echo $line | awk '{ print $6 }') + ;; + 11) + DST_PORT=$(echo $line | awk '{ print $6 }') + ;; + esac + i=$((i+1)); + done + + printf "<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>\n" $SOURCE $DEST $SRC_PORT $DST_PORT $STATUS + fi + +} + + +PID_DM=$(pgrep $HIP_DAEMON); +PID_FW=$(pgrep $HIP_FIREWALL); + +if [[ -z "$PID_DM" ]]; then + hipd_not_running +else + if [[ -z "$PID_FW" ]]; then + hipfw_not_running + else + + hipd_get_local_hit + +cat <<EOF +<br> +<h3><strong>@TR<<Peers of the local HIP daemon>></strong></h3> +<table style="width: 60%; margin-left: 2.5em; text-align: left; font-size: 0.8em;" border="0" cellpadding="0" cellspacing="0"> +EOF + + hipd_parse_all_peers + + cat <<EOF +</table> +<br> +<h3><strong>@TR<<Connections detected by HIP firewall>></strong></h3> +<table style="width: 60%; margin-left: 2.5em; text-align: left; font-size: 0.8em;" border="0" cellpadding="0" cellspacing="0"> +EOF + + hipfw_parse_all_tunnels + + cat <<EOF +</table> +EOF + + fi +fi + +footer %> +<!-- +##WEBIF:name:MobileACcess:6:HIP Connections +--> Added: trunk/pairing/webif/mobileaccess-pisa.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ trunk/pairing/webif/mobileaccess-pisa.sh Mon Mar 26 08:11:17 2012 (r2959) @@ -0,0 +1,252 @@ +#!/usr/bin/webif-page +<% +# Copyright (c) 2012, Distributed Systems Group, RWTH Aachen +# All rights reserved. + +################################################################### +# PiSA Connections +# +# Description: +# Retrives the connection information for pisa client and server daemon +# +# Author(s) [in order of work date]: +# <nikou.gholizadeh@xxxxxxxxxxxxxx> +# <fahad.aizaz@xxxxxxxxxxxxxx> +# +# Major revisions: +# +# TODO: +# + +. /usr/lib/webif/webif.sh + +header "MobileACcess" "PiSA Connections" "@TR<<PiSA Connection Information>>" "$SCRIPT_NAME" "" 0 + +# Variable declarations +CLIENT_DAEMON='pisacd' +SERVER_DAEMON='pisasd' +CLIENT_UTILITY='pisacdconf' +SERVER_UTILITY='pisasdconf' + +# Cosmetics - Display different row colours +get_tr() { + if equal "$cur_color" "odd"; then + cur_color="even" + echo "<tr>" + else + cur_color="odd" + echo "<tr class=\"odd\">" + fi +} + + +########################################################## Safe Keeping #################################################### +killall $CLIENT_UTILITY +killall $SERVER_UTILITY + + +######################################################## Client Connection List Display ############################################################# +cat <<EOF +<h3><strong>@TR<<Client Connections>></strong></h3> +<table style="width: 90%; margin-left: 2.5em; text-align: left; font-size: 0.8em;" border="0" cellpadding="2" cellspacing="1" summary="@TR<<Connections>>"> +<tr> +<td> +<table style="margin-left: 2.5em; text-align: center;" border="0" cellpadding="5" cellspacing="10" summary="@TR<<Client Connections>>"> +EOF + +if ps ax | grep -v grep | grep $CLIENT_DAEMON > /dev/null +then + COUNT_LINES=$(${CLIENT_UTILITY} get_conns 2>&1 | wc -l) + if [ $COUNT_LINES -eq 1 ]; then + echo "<p>No active connections found.</p>" + echo "</table>" + else + echo "<tr>" + echo "<th>Machine IP</th><th>Local (NAT) IP</th><th>Remote IP</th><th>SRC PORT</th><th>DST PORT</th><th>STATUS</th><th>TYPE</th>" + echo "</tr>" + + # switch colour + cur_color="even" + + ${CLIENT_UTILITY} get_conns 2>&1 | tail +3 | while read line; do + get_tr + echo "<td>" + echo $line | sed 's/[ ][ ]*/<\/td><td>/g' + echo "</td>" + echo "<tr>" + done + + echo "</table>" + fi +else + echo "<b>'$CLIENT_DAEMON'</b> is not running.<br>" + echo "Please start the <b>'$CLIENT_DAEMON'</b> service before checking connections details.<br>" + echo "</table>" +fi + + +########################################################### Client End Points Display ########################################################### + +cat <<EOF +</td> +</tr> +</table> +<br><br> +<h3><strong>@TR<<Client Endpoints>></strong></h3> +<table style="width: 90%; margin-left: 2.5em; text-align: left; font-size: 0.8em;" border="0" cellpadding="2" cellspacing="1" summary="@TR<<Connections>>"> +<tr> +<td> +<table style="margin-left: 2.5em; text-align: center;" border="0" cellpadding="1" cellspacing="2" summary="@TR<<Endpoints>>"> +EOF + +if ps ax | grep -v grep | grep $CLIENT_DAEMON > /dev/null +then + COUNT_LINES=$(${CLIENT_UTILITY} get_endpoints 2>&1 | wc -l) + if [ $COUNT_LINES -eq 0 ]; then + echo "No endpoints found." + echo "</table>" + elif [ $COUNT_LINES -eq 1 ]; then + TMP_STRING=$(${CLIENT_UTILITY} get_endpoints 2>&1) + if [ -n TMP_STRING ]; then + echo "No endpoints found." + echo "</table>" + else + get_tr + echo "td>" + echo $TMP_STRING + echo "</td>" + echo "</tr>" + echo "</table>" + fi + else + + # switch colour + cur_color="odd" + + ${CLIENT_UTILITY} get_endpoints 2>&1 | while read line; do + get_tr + echo "<td>" + echo $line + echo "</td>" + echo "</tr>" + done + + echo "</table>" + fi +else + echo "<b>'$CLIENT_DAEMON'</b> is not running.<br>" + echo "Please start the <b>'$CLIENT_DAEMON'</b> service before checking connections details.<br>" + echo "</table>" +fi + + + +########################################################### Server Connection List Display ############################################################# +cat <<EOF +</td> +</tr> +</table> +<br><br> +<h3><strong>@TR<<Server Connections>></strong></h3> +<table style="width: 90%; margin-left: 2.5em; text-align: left; font-size: 0.8em;" border="0" cellpadding="2" cellspacing="1" summary="@TR<<Connections>>"> +<tr> +<td> +<table style="margin-left: 2.5em; text-align: center;" border="0" cellpadding="5" cellspacing="10" summary="@TR<<Server Connections>>"> +EOF + +if ps ax | grep -v grep | grep $SERVER_DAEMON > /dev/null +then + COUNT_LINES=$(${SERVER_UTILITY} get_conns 2>&1 | wc -l) + if [ $COUNT_LINES -eq 1 ]; then + echo "No active connections found." + echo "</table>" + else + echo "<tr>" + echo "<th>Machine IP</th><th>Local (NAT) IP</th><th>Remote IP</th><th>SRC PORT</th><th>DST PORT</th><th>STATUS</th><th>TYPE</th>" + echo "</tr>" + + # switch colour + cur_color="even" + + ${SERVER_UTILITY} get_conns 2>&1 | tail +3 | while read line; do + get_tr + echo "<td>" + echo $line | sed 's/[ ][ ]*/<\/td><td>/g' + echo "</td>" + echo "</tr>" + done + + echo "</table>" + fi +else + echo "<b>'$SERVER_DAEMON'</b> is not running.<br>" + echo "Please start the <b>'$SERVER_DAEMON'</b> service before checking connections details.<br>" + echo "</table>" +fi + +############################################################# Server Endpoints ########################################################### +cat <<EOF +</td> +</tr> +</table> +<br><br> +<h3><strong>@TR<<Server Endpoints>></strong></h3> +<table style="width: 90%; margin-left: 2.5em; text-align: left; font-size: 0.8em;" border="0" cellpadding="2" cellspacing="1" summary="@TR<<Connections>>"> +<tr> +<td> +<table style="margin-left: 2.5em; text-align: center;" border="0" cellpadding="1" cellspacing="2" summary="@TR<<Endpoints>>"> +EOF + +if ps ax | grep -v grep | grep $SERVER_DAEMON > /dev/null +then + COUNT_LINES=$(${SERVER_UTILITY} get_endpoints 2>&1 | wc -l) + if [ $COUNT_LINES -eq 0 ]; then + echo "No endpoints found." + echo "</table>" + elif [ $COUNT_LINES -eq 1 ]; then + TMP_STRING=$(${SERVER_UTILITY} get_endpoints 2>&1) + if [ -n TMP_STRING ]; then + echo "No endpoints found." + echo "</table>" + else + get_tr + echo "td>" + echo $TMP_STRING + echo "</td>" + echo "</tr>" + echo "</table>" + fi + else + + # switch colour + cur_color="odd" + + ${CLIENT_UTILITY} get_endpoints 2>&1 | while read line; do + get_tr + echo "<td>" + echo $line + echo "</td>" + echo "</tr>" + done + + echo "</table>" + fi +else + echo "<b>'$SERVER_DAEMON'</b> is not running.<br>" + echo "Please start the <b>'$SERVER_DAEMON'</b> service before checking connections details.<br>" + echo "</table>" +fi + +cat <<EOF +</td> +</tr> +</table> + +EOF + + +footer %> +<!-- +##WEBIF:name:MobileACcess:7:PiSA Connections +--> + -- This is the pisa developer mailing list. Please also subscribe to the main pisa list at: //www.freelists.org/list/pisa