From: marta Date: Mon, 24 Aug 2009 21:19:45 +0000 (+0000) Subject: Added support for new commands: X-Git-Tag: ipfw-0.9-4~2 X-Git-Url: http://git.onelab.eu/?p=ipfw.git;a=commitdiff_plain;h=3f06507f45547df04f6be56c4bcb02dce9d2d316 Added support for new commands: netconfig ipfw show netconfig pipe show netconfig -p -d to show rules, pipe and to delete a rule respectively. Removed a debug message from the ipfw source. --- diff --git a/dummynet/ip_dummynet.c b/dummynet/ip_dummynet.c index bdf0a8e..a613bbf 100644 --- a/dummynet/ip_dummynet.c +++ b/dummynet/ip_dummynet.c @@ -1012,7 +1012,6 @@ dummynet_send(struct mbuf *m) #else m_freem(m); #endif - printf("need to drop the skbuf\n"); break; default: diff --git a/slice/netconfig b/slice/netconfig index ff2be2f..efad8e7 100755 --- a/slice/netconfig +++ b/slice/netconfig @@ -45,12 +45,19 @@ help() { cat << EOF Usage: $prog -p port [-U] [-t timeout[STRING]] ipfw_configuration_parameters \n + $prog ipfw show \n + $prog pipe show \n + -h show help \n -p specify the port to configure \n + -d delete specified rules and pipes \n -t specify the timeout. STRING can be "1minute" or "4hours" (default 1 hour) \n ipfw configuration parameters (mandatory) \n extra-delay bw delay proto... plr... \n + + ipfw show show the ipfw ruleset + ipfw pipe show the configured pipes EOF exit 0 } @@ -65,10 +72,11 @@ parse_input() [ -z "$1" ] && help; - while getopts ":hp:t:" opt; do + while getopts ":hdp:t:" opt; do case $opt in h | \?) help;; p) PORT=$OPTARG;; + d) DELETE=1;; t) TIMEOUT=$OPTARG;; esac done @@ -82,17 +90,29 @@ parse_input() OPT_ARGS=$((${OPT_ARGS}-2)) fi + # check for deletion flag + if [ -z ${DELETE} ]; then + DELETE=0 + else + # if d is present configuration is not required + MAND_ARGS=$((${MAND_ARGS}-2)) + fi + # compute residue argument, we need at least 2 # mandatory arguments (for ipfw), exit on error - #debug "Passed args $# Mandatory ${MAND_ARGS} Optional ${OPT_ARGS} Extra $(($#-${MAND_ARGS}-${OPT_ARGS}))" + # debug "Passed args $# Mandatory ${MAND_ARGS} Optional ${OPT_ARGS} Extra $(($#-${MAND_ARGS}-${OPT_ARGS}))" if [ $(($#-${MAND_ARGS}-${OPT_ARGS})) -lt 2 ]; then help fi } +# the backend expects lines in the format: +# ipfw +# pipe +# port timeout configuration_string # main starts here - # allow ipfw show and ipfw pipe show + # allow ipfw show and ipfw pipe show commands if [ x$1 = x"ipfw" ]; then echo "received" $1 echo "ipfw" >> ${PIPE_IN} @@ -111,11 +131,12 @@ parse_input() # print debug debug "PORT ${PORT}" + debug "DELETE ${DELETE}" debug "TIMEOUT ${TIMEOUT}" debug "PIPE_CONFIGURATION $*" # format CMD as expected by the backend script - CMD="${PORT} ${TIMEOUT} $*"; + CMD="${PORT} ${TIMEOUT} ${DELETE} $*"; # send the command debug "Sending: ${CMD}"