source: ResearchApps/Measurement/install_files/pcapy_warpnet_patch.diff

Last change on this file was 1581, checked in by sgupta, 14 years ago

patch file move

File size: 1.4 KB
RevLine 
[1528]1--- pcapobj.cc  2007-03-28 08:59:04.000000000 -0500
2+++ ../pcapy-0.10.5_patch/pcapobj.cc    2010-05-20 15:59:50.000000000 -0500
3@@ -58,6 +58,7 @@
4 static PyObject* p_getnonblock(register pcapobject* pp, PyObject* args);
5 static PyObject* p_dump_open(register pcapobject* pp, PyObject* args);
6 static PyObject* p_sendpacket(register pcapobject* pp, PyObject* args);
7+static PyObject* p_inject(register pcapobject* pp, PyObject* args);
8 
9 
10 static PyMethodDef p_methods[] = {
11@@ -72,6 +73,7 @@
12   {"setnonblock", (PyCFunction) p_setnonblock, METH_VARARGS, "puts into `non-blocking' mode, or take it out, depending on the argument"},
13   {"dump_open", (PyCFunction) p_dump_open, METH_VARARGS, "creates a dumper object"},
14   {"sendpacket", (PyCFunction) p_sendpacket, METH_VARARGS, "sends a packet through the interface"},
15+  {"inject", (PyCFunction) p_inject, METH_VARARGS, "sends a packet over pcap"},
16   {NULL, NULL} /* sentinel */
17 };
18 
19@@ -436,3 +438,23 @@
20   Py_INCREF(Py_None);
21   return Py_None;
22 }
23+
24+static PyObject*
25+p_inject(register pcapobject* pp, PyObject* args)
26+{
27+   int len;
28+   const char *data;
29+   int status;
30+   
31+   if (pp->ob_type != &Pcaptype)
32+    {
33+      PyErr_SetString(PcapError, "Not a pcap object");
34+      return NULL;
35+    }
36+   
37+   if (!PyArg_ParseTuple(args, "s#", &data, &len))
38+       return NULL;
39+   
40+   status = pcap_inject(pp->pcap, data, len);
41+   return Py_BuildValue("i", status);
42+}
Note: See TracBrowser for help on using the repository browser.