marionnet-0.90.6+bzr508.orig/ 0000755 0001750 0001750 00000000000 13175722672 014603 5 ustar lucas lucas marionnet-0.90.6+bzr508.orig/motherboard_builder.ml 0000644 0001750 0001750 00000014370 13175722671 021155 0 ustar lucas lucas (* This file is part of Marionnet, a virtual network laboratory
Copyright (C) 2009, 2010 Jean-Vincent Loddo
Copyright (C) 2009, 2010 Université Paris 13
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see . *)
open Gettext;;
#load "include_type_definitions_p4.cmo"
;;
INCLUDE DEFINITIONS "motherboard_builder.mli"
;;
module Make (S : sig val st:State.globalState end) = struct
open S
let w = st#mainwin
(* ----------------------------------------
Reactive window title
---------------------------------------- *)
(* Reactive setting: st#project_filename -> w#window_MARIONNET#title *)
let update_main_window_title : Thunk.id =
Cortex.on_commit_append
(st#project_paths#filename)
(fun _ filename -> (* previous and commited state *)
let title = match filename with
| None -> Initialization.window_title
| Some filename -> Printf.sprintf "%s - %s" (Initialization.window_title) (filename)
in
w#window_MARIONNET#set_title (title))
(* ----------------------------------------
Reactive sensitiveness
---------------------------------------- *)
(* Note: why the GC doesn't free this structure (and the related trigger)? *)
let update_project_state_sensitiveness =
Cortex.group_pair
~on_commit:(fun (_,_) (filename, nodes) -> (* previous and commited state *)
(* Convenient aliases: *)
let wa = (st#sensitive_when_Active) in
let wr = (st#sensitive_when_Runnable) in
let wn = (st#sensitive_when_NoActive) in
(* --- *)
let active = (filename <> None) in
let runnable = active && (not (Queue.is_empty nodes)) in
let () =
Log.printf2 "update_project_state_sensitiveness: state project is: active=%b runnable=%b\n"
(active) (runnable)
in
match active, runnable with
| false, _ ->
StackExtra.iter (fun x->x#misc#set_sensitive false) (wa);
StackExtra.iter (fun x->x#misc#set_sensitive false) (wr);
StackExtra.iter (fun x->x#misc#set_sensitive true) (wn);
(* --- *)
| true, false ->
StackExtra.iter (fun x->x#misc#set_sensitive true) (wa);
StackExtra.iter (fun x->x#misc#set_sensitive false) (wr);
StackExtra.iter (fun x->x#misc#set_sensitive false) (wn);
(* --- *)
| true, true ->
StackExtra.iter (fun x->x#misc#set_sensitive true) (wa);
StackExtra.iter (fun x->x#misc#set_sensitive true) (wr);
StackExtra.iter (fun x->x#misc#set_sensitive false) (wn);
) (* end of ~on_commit *)
(* --- *)
(st#project_paths#filename) (* first member of the group *)
(st#network#nodes) (* second member of the group *)
(* Reactive setting: st#network#nodes -> cable's menu sensitiveness.
Forbid cable additions if there are not enough free ports; explicitly enable
them if free ports are enough: *)
let update_cable_menu_entries_sensitiveness : unit =
(* The previous and commited state are ignored.
This kind of code (on_commit) is outside a critical section,
so we can comfortably re-call st#network methods: *)
let reaction _ _ =
let () = Log.printf1 "update_cable_menu_entries_sensitiveness: updating %d widgets\n"
(StackExtra.length st#sensitive_cable_menu_entries)
in
let condition = st#network#are_there_almost_2_free_endpoints in
(StackExtra.iter (fun x->x#misc#set_sensitive condition) st#sensitive_cable_menu_entries)
in
let _ = Cortex.on_commit_append (st#network#nodes) (reaction) in
let _ = Cortex.on_commit_append (st#network#cables) (reaction) in
()
(* Called in marionnet.ml before entering the main loop: *)
let sensitive_widgets_initializer () =
let () = StackExtra.iter (fun x->x#misc#set_sensitive false) (st#sensitive_when_Active) in
let () = StackExtra.iter (fun x->x#misc#set_sensitive false) (st#sensitive_when_Runnable) in
let () = StackExtra.iter (fun x->x#misc#set_sensitive true) (st#sensitive_when_NoActive) in
(* --- *)
let () = StackExtra.iter (fun x->x#misc#set_sensitive false) (st#sensitive_cable_menu_entries) in
()
(* ----------------------------------------
Reactive sketch
---------------------------------------- *)
(* --- *)
let () =
let d = st#network#dotoptions in
let update = (fun _ _ -> st#refresh_sketch) in
let _ = Cortex.on_commit_append (d#iconsize) (update) in
let _ = Cortex.on_commit_append (d#rankdir) (update) in
let _ = Cortex.on_commit_append (d#curved_lines) (update) in
let _ = Cortex.on_commit_append (d#shuffler) (update) in
let _ = Cortex.on_commit_append (d#nodesep) (update) in
let _ = Cortex.on_commit_append (d#labeldistance) (update) in
let _ = Cortex.on_commit_append (d#extrasize) (update) in
()
(* ----------------------------------------
Debugging
---------------------------------------- *)
(* Debugging: press F5 for immediately exiting the gtk main loop (only in the toplevel) *)
let _ =
if !Sys.interactive then
let stars = "*************************************" in
Printf.kfprintf flush stdout
"%s\nPress F5 to switch to the toplevel.\n%s\n\n" stars stars;
ignore (st#mainwin#toplevel#event#connect#key_press ~callback:(fun k ->
(match (GdkEvent.Key.keyval k) = GdkKeysyms._F5 with
| true ->
Printf.kfprintf flush stdout
"%s\nYou are now in the toplevel.\nType:\nGMain.Main.main ();;\nto come back to the Marionnet window.\n%s\n\n" stars stars;
GtkMain.Main.quit ()
| false -> ()
);
false))
else ()
end
marionnet-0.90.6+bzr508.orig/message_passing.ml 0000644 0001750 0001750 00000005203 13175722671 020304 0 ustar lucas lucas (* This file is part of Marionnet, a virtual network laboratory
Copyright (C) 2007, 2008 Luca Saiu
Copyright (C) 2010 Jean-Vincent Loddo
Copyright (C) 2007, 2008, 2010 Université Paris 13
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see . *)
(** A general-purpose message-passing facility, with transparent
thread synchronization *)
class ['a] queue = object(self)
val elements = ref []
val mutex = Mutex.create ()
val empty_condition = Condition.create ()
(** This is not synchronized *)
method private __empty =
!elements = []
method enqueue x =
Mutex.lock mutex;
elements := !elements @ [x];
Condition.signal empty_condition;
Mutex.unlock mutex
(* This allows the user to use the queue as a deque, for 'urgent' messages, like
thread termination requests: *)
method prepend x =
Mutex.lock mutex;
elements := x :: !elements;
Condition.signal empty_condition;
Mutex.unlock mutex
method dequeue : 'a =
Mutex.lock mutex;
while self#__empty do
Condition.wait empty_condition mutex;
done;
let result =
match !elements with
x :: rest -> elements := rest; x
| _ -> assert false in
Mutex.unlock mutex;
result
end;;
(*
let queue = new queue;;
let make_producer () =
Thread.create
(fun () ->
while true do
queue#enqueue (Random.int 1000);
done)
();;
let make_consumer =
let consumer_next_id = ref 1 in
fun () ->
let id = ! consumer_next_id in
consumer_next_id := !consumer_next_id + 1;
Thread.create
(fun () ->
while true do
Log.printf "From consumer %i: got %i\n" id (queue#dequeue);
flush_all ();
done)
();;
let w = new task_runner;;
let make_producer x =
Thread.create
(fun () ->
while true do
w#schedule
(fun () -> Log.printf "%i" x; flush_all ());
done)
();;
let _ = make_producer 1;;
let _ = make_producer 2;;
let _ = make_producer 3;;
let _ = make_producer 4;;
let _ = make_producer 5;;
let _ = make_producer 6;;
Unix.sleep 30;;
w#terminate;;
*)
marionnet-0.90.6+bzr508.orig/scripts/ 0000755 0001750 0001750 00000000000 13175722671 016271 5 ustar lucas lucas marionnet-0.90.6+bzr508.orig/scripts/marionnet_telnet.sh 0000755 0001750 0001750 00000007343 13175722671 022206 0 ustar lucas lucas #!/bin/bash
# This file is part of Marionnet, a virtual network laboratory
# Copyright (C) 2017 Jean-Vincent Loddo
# Copyright (C) 2017 Université Paris 13
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
# ---
# Usage: marionnet_telnet.sh HOST PORT TIMEOUT
# Add a timeout functionality to the standard program `telnet'
# ---
# Check dependencies:
type -t telnet &>/dev/null || exit 127
type -t grep &>/dev/null || exit 127
type -t rm &>/dev/null || exit 127
# ---
function usage {
local EXIT_CODE=${1:-0}
echo "Usage: marionnet_telnet.sh HOST [PORT] [TIMEOUT]"
echo "---"
echo "Add a timeout functionality to the standard program \`telnet'."
echo "By default, PORT is set to 23, TIMEOUT is set to 30 (seconds)."
echo "---"
echo "This utility is called by marionnet (on ports 2601..2612) to"
echo "activate Quagga terminals (CISCO-IOS-like commands)."
exit $EXIT_CODE
}
# I dont want suppose the presence of `mktemp':
function simple_mktemp {
local RESULT="${TMPDIR:-/tmp}/simple_mktemp".$RANDOM
if [[ -f $RESULT ]]; then simple_mktemp; else
>$RESULT
echo $RESULT;
fi
}
# I suppose `grep', `rm' (and `telnet', of course) here:
function is_host_accepting_connections {
local HOST=${1:-"172.23.0.1"}
local PORT=${2:-"2601"}
# ---
shift 2 || return 3 # invalid call
# ---
local TIMEOUT=${1:-"3"}
# ---
local TMPFILE=$(simple_mktemp)
# ---
telnet $HOST $PORT 1>$TMPFILE 2>/dev/null & # job %1
local TELNET_PID="$!"
# ---
(sleep $TIMEOUT; kill -9 $TELNET_PID) &>/dev/null & # job %2
local KILLER_PID="$!"
# ---
wait $TELNET_PID &>/dev/null
# ---
local JOB1_CODE=$?
kill -9 $TELNET_PID $KILLER_PID &>/dev/null
# ---
local RESULT=2 # host/port unavailable (timeout expired)
# ---
if [[ $JOB1_CODE = 1 ]] && grep -q "Connected to $HOST" $TMPFILE; then
RESULT=0 # connection accepted
elif [[ $JOB1_CODE = 1 ]]; then
RESULT=1 # connection refused, but the host is answering: the port is not (already?) open.
fi
# ---
rm -f $TMPFILE
# ---
return $RESULT
}
# Main:
if [[ $1 = "-h" || $1 = "--help" ]]; then usage 0; fi
# else continue:
HOST="$1"
shift 1 || usage 3
# ---
PORT="${1:-23}" # the default telnet port is 23
# ---
TOTAL_TIMEOUT="${2:-"30"}" # 30 seconds by default
MAX_TRIALS="10" # 10 trials, no more
TIMEOUT="$((TOTAL_TIMEOUT/MAX_TRIALS))" # 3 seconds per trial (10 trials) by default
[[ $TIMEOUT -lt 1 ]] && TIMEOUT=1
# ---
TIME=0
while [[ $TIME -lt $TOTAL_TIMEOUT ]]; do
# ---
is_host_accepting_connections "$HOST" "$PORT" "$TIMEOUT" 2>/dev/null;
LAST_ERROR_CODE=$?
# ---
case $LAST_ERROR_CODE in
# ---
# Do it now:
0) exec telnet $HOST $PORT;;
# ---
# Sleep now because `is_host_accepting_connections' has returned immediately in this case:
1) sleep $TIMEOUT;;
# ---
esac
TIME=$((TIME+TIMEOUT))
done
# ---
# Just before exiting:
# ---
case $LAST_ERROR_CODE in
1) echo "Connection refused by $HOST on port $PORT" 1>&2 ;;
2) echo "Timeout exceeded trying to connect to $HOST on port $PORT" 1>&2 ;;
esac
# --- Fail with the last observed error code:
exit $LAST_ERROR_CODE
marionnet-0.90.6+bzr508.orig/scripts/can-directory-host-sparse-files.sh 0000755 0001750 0001750 00000002770 13175722671 024747 0 ustar lucas lucas #!/bin/bash
# This file is part of Marionnet, a virtual network laboratory
# Copyright (C) 2007 Jean-Vincent Loddo
# Copyright (C) 2007 Luca Saiu
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
DIR=${1:-$PWD}
[[ -d "$DIR" ]] || {
echo "Directory doesn't exist. Exiting."
exit 3
} >&2
# The mounted directory containing $DIR:
# (note that df resolves symlinks, relative paths and paths not in normal form)
MOUNTED_DIR=$(df -P "$DIR" | tail -n -1 | awk '{print $NF}')
# The related filesystem type:
FSTYPE=$(mount -l | awk '$3 == "'${MOUNTED_DIR}'" {print $5}')
[[ -n "$FSTYPE" ]] || {
echo "Cannot determine the filesystem type. Exiting."
exit 2
} >&2
# Check if the filesystem type belongs the white list.
# Note that apparently xfs no longer supports sparse files in Ubuntu 12.04 (kernel 3.2).
WHITE_LIST="reiserfs reiser4 ext4 ext4dev ext3 ext2 udf ntfs jfs ufs tmpfs vxfs xiafs"
echo "$WHITE_LIST" | grep -qw "$FSTYPE"
exit $?
marionnet-0.90.6+bzr508.orig/uml/ 0000755 0001750 0001750 00000000000 13175722671 015377 5 ustar lucas lucas marionnet-0.90.6+bzr508.orig/uml/startup.old/ 0000755 0001750 0001750 00000000000 13175722671 017656 5 ustar lucas lucas marionnet-0.90.6+bzr508.orig/uml/startup.old/marionnet_grab_config 0000755 0001750 0001750 00000002160 13175722671 024117 0 ustar lucas lucas #!/bin/sh
# This file is part of Marionnet, a virtual network laboratory
# Copyright (C) 2007 Luca Saiu
# Copyright (C) 2007 Jean-Vincent Loddo
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
#DIR="/boot/"$(date "+%d-%m-%Y.%Hh%M")
DIR="/mnt/hostfs/report-"$(date "+%d-%m-%Y.%Hh%Mm%Ss")
mkdir -p "$DIR" 2>/dev/null
pushd "$DIR"
cp /root/.bash_history bash_history
cfg2html -H -S -f -l
# Copy the HTML version of the report and the latest bash history into the hostfs path:
cp *.html ../report.html
cp bash_history ../bash_history.text
#gzip *
popd
marionnet-0.90.6+bzr508.orig/uml/startup.old/marionnet_source_cmdline 0000644 0001750 0001750 00000001734 13175722671 024655 0 ustar lucas lucas # This file is part of Marionnet, a virtual network laboratory
# Copyright (C) 2007 Luca Saiu
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
# This should be executed with 'source', as it updates the shell
# environment:
# This should be executed with 'source', as it updates the shell
# environment:
cat /proc/cmdline | tr " " "\n" > /tmp/cmdline
source /tmp/cmdline &> /dev/null
rm /tmp/cmdline
marionnet-0.90.6+bzr508.orig/uml/startup.old/DEPENDENCIES.png 0000644 0001750 0001750 00000124766 13175722671 022232 0 ustar lucas lucas PNG
IHDR e d] bKGD IDATxw|[8WdIֶa;N<+$2.Җnm/r/Je].PlJ4؎{He~,ˎly9:>:zu;a~B!B! B!B7pA!B!2 B!BE\B!B!L&Ȝbx<j\.pvvFa/
'܌bd2TfH$r@ -KHHo9X,t#
Uv=b07uݑonw8SI$Id2E|@f(
Bh9N&B\.jf2X@Oz\.fre@~
ABneٜN'd4FF¨"͌ A42B#&4".+"23q.x2aR0A4ӗH$qqq4
ȰX,p82fd2 f
a(Yjô4XoiX.x^LBEI( F@l=*oDt@0.K#Zrz$"ceB89h4Z,Qb6F#,l6hn@ %mY__l'X:& ǃ\PՇrWH-d2L,D"X,Hd2,cd|&