File: ipg

package info (click to toggle)
iputils 3%3A20161105-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 1,060 kB
  • ctags: 1,282
  • sloc: ansic: 11,706; perl: 585; makefile: 344; sh: 277
file content (34 lines) | stat: -rwxr-xr-x 571 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#! /bin/bash

if [ -e /proc/modules ] ; then
	modprobe pg3 >& /dev/null
	modprobe pktgen >& /dev/null
fi

for PGDEV in /proc/net/pg /proc/net/pktgen/pg0 / ; do
	[ -e ${PGDEV} ] && break
done
if [ "${PGDEV}" = "/" ] ; then
	echo "Could not locate pg in /proc/net" 1>&2
	exit 1
fi

function pgset() {
    local result

    echo $1 > ${PGDEV}

    result=`cat ${PGDEV} | fgrep "Result: OK:"`
    if [ "$result" = "" ]; then
         cat ${PGDEV} | fgrep Result:
    fi
}

function pg() {
    echo inject > ${PGDEV}
    cat ${PGDEV}
}

pgset "odev eth0"
pgset "dst 0.0.0.0"