Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added statustostr method #55

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion pcapobj.cc
Original file line number Diff line number Diff line change
Expand Up @@ -732,10 +732,14 @@ p_activate(register pcapobject* pp, PyObject*)
return err_closed();

int ret = pcap_activate(pp->pcap);
if (ret)
{
PyErr_SetString(PcapError, pcap_geterr(pp->pcap));
return NULL;
}
return Py_BuildValue("i", ret);
}


static PyObject*
p_sendpacket(register pcapobject* pp, PyObject* args)
{
Expand Down
14 changes: 14 additions & 0 deletions pcapy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,19 @@ bpf_compile(PyObject* self, PyObject* args)
return new_bpfobject( bpf );
}

static PyObject*
pcap_statustostr(PyObject *self, PyObject *args)
{
const char * status;
int error;

if (!PyArg_ParseTuple(args, "i:pcap_statustostr", &error))
return NULL;

status = pcap_statustostr(error);

return Py_BuildValue("s", status);
}

static PyMethodDef pcap_methods[] = {
{"open_live", open_live, METH_VARARGS, "open_live(device, snaplen, promisc, to_ms) opens a pcap device"},
Expand All @@ -218,6 +231,7 @@ static PyMethodDef pcap_methods[] = {
{"findalldevs", findalldevs, METH_VARARGS, "findalldevs() lists all available interfaces"},
{"compile", bpf_compile, METH_VARARGS, "compile(linktype, snaplen, filter, optimize, netmask) creates a bpfprogram object"},
{"create", pcap_create, METH_VARARGS, "create(device) is used to create a packet capture handle to look at packets on the network."},
{"statustostr", pcap_statustostr, METH_VARARGS, "statustostr(error) is used to convert a PCAP_ERROR or PCAP_WARNING to a string"},
{NULL, NULL}
};

Expand Down