Initial import from ToT git.
Bug: 9469682
Change-Id: I6fc32550557dc5e94e9ecbbb57b0ec30a844adb4
Upstream: git://git.linux-ipv6.org/gitroot/iputils.git
Commit: 608419a7804caf36a359875d2fdae0b3eb181387
diff --git a/ipg b/ipg
new file mode 100755
index 0000000..9332013
--- /dev/null
+++ b/ipg
@@ -0,0 +1,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"
+