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
  • pcapobj.cc

    old new  
    5858static PyObject* p_getnonblock(register pcapobject* pp, PyObject* args);
    5959static PyObject* p_dump_open(register pcapobject* pp, PyObject* args);
    6060static PyObject* p_sendpacket(register pcapobject* pp, PyObject* args);
     61static PyObject* p_inject(register pcapobject* pp, PyObject* args);
    6162
    6263
    6364static PyMethodDef p_methods[] = {
     
    7273  {"setnonblock", (PyCFunction) p_setnonblock, METH_VARARGS, "puts into `non-blocking' mode, or take it out, depending on the argument"},
    7374  {"dump_open", (PyCFunction) p_dump_open, METH_VARARGS, "creates a dumper object"},
    7475  {"sendpacket", (PyCFunction) p_sendpacket, METH_VARARGS, "sends a packet through the interface"},
     76  {"inject", (PyCFunction) p_inject, METH_VARARGS, "sends a packet over pcap"},
    7577  {NULL, NULL}  /* sentinel */
    7678};
    7779
     
    436438  Py_INCREF(Py_None);
    437439  return Py_None;
    438440}
     441
     442static PyObject*
     443p_inject(register pcapobject* pp, PyObject* args)
     444{
     445    int len;
     446    const char *data;
     447    int status;
     448   
     449    if (pp->ob_type != &Pcaptype)
     450    {
     451      PyErr_SetString(PcapError, "Not a pcap object");
     452      return NULL;
     453    }
     454   
     455    if (!PyArg_ParseTuple(args, "s#", &data, &len))
     456        return NULL;
     457   
     458    status = pcap_inject(pp->pcap, data, len);
     459    return Py_BuildValue("i", status);
     460}
Note: See TracBrowser for help on using the repository browser.