1#! /bin/bash
2
3if [ -e /proc/modules ] ; then
4	modprobe pg3 >& /dev/null
5	modprobe pktgen >& /dev/null
6fi
7
8for PGDEV in /proc/net/pg /proc/net/pktgen/pg0 / ; do
9	[ -e ${PGDEV} ] && break
10done
11if [ "${PGDEV}" = "/" ] ; then
12	echo "Could not locate pg in /proc/net" 1>&2
13	exit 1
14fi
15
16function pgset() {
17    local result
18
19    echo $1 > ${PGDEV}
20
21    result=`cat ${PGDEV} | fgrep "Result: OK:"`
22    if [ "$result" = "" ]; then
23         cat ${PGDEV} | fgrep Result:
24    fi
25}
26
27function pg() {
28    echo inject > ${PGDEV}
29    cat ${PGDEV}
30}
31
32pgset "odev eth0"
33pgset "dst 0.0.0.0"
34
35