Added support for new commands:
authormarta <marta@8c455092-636d-4788-adf5-e71def0336e8>
Mon, 24 Aug 2009 21:19:45 +0000 (21:19 +0000)
committermarta <marta@8c455092-636d-4788-adf5-e71def0336e8>
Mon, 24 Aug 2009 21:19:45 +0000 (21:19 +0000)
netconfig ipfw show
netconfig pipe show
netconfig -p <port> -d
to show rules, pipe and to delete a rule respectively.

Removed a debug message from the ipfw source.

dummynet/ip_dummynet.c
slice/netconfig

index bdf0a8e..a613bbf 100644 (file)
@@ -1012,7 +1012,6 @@ dummynet_send(struct mbuf *m)
 #else
                        m_freem(m);
 #endif
-                       printf("need to drop the skbuf\n");
                        break;
 
                default:
index ff2be2f..efad8e7 100755 (executable)
@@ -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 <filename> bw <value> delay <value> 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}"