14137N/A+ * Permission is hereby granted, free of charge, to any person obtaining a copy
14137N/A+ * of this software and associated documentation files (the "Software"), to
14137N/A+ * deal in the Software without restriction, including without limitation the
14137N/A+ * rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or 14137N/A+ * sell copies of the Software, and to permit persons to whom the Software is
14137N/A+ * furnished to do so, subject to the following conditions:
14137N/A+ * The above copyright notice and this permission notice shall be included in
14137N/A+ * all copies or substantial portions of the Software.
14137N/A+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14137N/A+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14137N/A+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14137N/A+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
14137N/A+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
14137N/A+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
14137N/A+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
14137N/A+ * Use is subject to license terms.
14137N/A+ * dlpi_err: the only exception raised for libdlpi related error.
14137N/A+ * (dlpi_error_number, string), when it's a dlpi specific error,
14137N/A+ * or, (DL_SYSERR, errno, string), when it's coming from a system call.
14137N/A+ e = Py_BuildValue("(iis)", DL_SYSERR, errno, strerror(errno));
14137N/A+ e = Py_BuildValue("(is)", err, dlpi_strerror(err));
14137N/A+ "link(linkname[, flags]) -> link object\n"
14137N/A+ "Open linkname with specified flags.\n"
14137N/A+ "Three flags are supported: PASSIVE, RAW, NATIVE.\n"
14137N/A+ "And these flags can be bitwise-OR'ed together(default flag is 0).\n"
14137N/A+ "You need sys_net_rawaccess privilege to open a link.\n"
14137N/A+link_init(PyObject *self, PyObject *args, PyObject *kwds)
14137N/A+ static char *keywords[] = {"linkname", "flags", NULL};
14137N/A+ pylink_t *link = (pylink_t *)self;
14137N/A+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "s|I", keywords,
14137N/A+ if ((rval = dlpi_open(linkname, &dh, flags)) != DLPI_SUCCESS) {
14137N/A+ link->ob_type->tp_free((PyObject *)link);
14137N/A+ "Attempts to bind the link to specified SAP, or ANY_SAP.\n"
14137N/A+ "Returns the SAP that the function actually bound to, which\n"
14137N/A+ "could be different from the SAP requested.\n"
14137N/A+link_bind(pylink_t *link, PyObject *args, PyObject *kwds)
14137N/A+ static char *keywords[] = {"sap", NULL};
14137N/A+ dlpi_raise_exception(DL_SYSERR);
14137N/A+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "I", keywords, &sap))
14137N/A+ if ((rval = dlpi_bind(link->dlpihdl, sap, &boundsap)) !=
14137N/A+ return (Py_BuildValue("I", boundsap));
14137N/A+ "Attempts to unbind the link from previously bound sap.\n"
14137N/A+ dlpi_raise_exception(DL_SYSERR);
14137N/A+ if ((rval = dlpi_unbind(link->dlpihdl)) != DLPI_SUCCESS) {
14137N/A+ "send(destaddr, message[, sap, minpri, maxpri]) -> None\n"
14137N/A+ "Attempts to send message over this link to sap on destaddr.\n"
14137N/A+ "If SAP is not specified, the bound SAP is used\n"
14137N/A+ "You can also specify priority range (minpri, maxpri).\n"
14137N/A+link_send(pylink_t *link, PyObject *args, PyObject *kwds)
14137N/A+ char *daddr = NULL, *msgbuf = NULL;
14137N/A+ size_t daddrlen = 0, msglen = 0;
14137N/A+ t_scalar_t minpri = DL_QOS_DONT_CARE, maxpri = DL_QOS_DONT_CARE;
14137N/A+ dlpi_sendinfo_t ds, *dsp = NULL;
14137N/A+ {"destaddr", "message", "sap", "minpri", "maxpri", NULL};
14137N/A+ dlpi_raise_exception(DL_SYSERR);
14137N/A+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "s#s#|Iii", keywords,
14137N/A+ &daddr, &daddrlen, &msgbuf, &msglen, &sap, &minpri, &maxpri))
14137N/A+ if ((sap != DLPI_ANY_SAP) || (minpri != DL_QOS_DONT_CARE) ||
14137N/A+ (maxpri != DL_QOS_DONT_CARE)) {
14137N/A+ if ((rval = dlpi_send(link->dlpihdl, daddr, daddrlen,
14137N/A+ msgbuf, msglen, dsp)) != DLPI_SUCCESS) {
14137N/A+ "recv(msglen[, timeout]) -> (string, string), or (None, None)\n"
14137N/A+ "Attempts to receive message over this link.\n"
14137N/A+ "You need to specify the message length for the received message.\n"
14137N/A+ "And you can specify timeout value in milliseconds.\n"
14137N/A+ "The default timeout value is -1 (wait forever).\n"
14137N/A+ "Returns (source address, message data), or (None, None) when error occurs.\n"
14137N/A+link_recv(pylink_t *link, PyObject *args, PyObject *kwds)
14137N/A+ char *saddr = NULL, *msgbuf = NULL;
14137N/A+ size_t saddrlen = 0, msglen = 0, *saddrlenp = NULL, *msglenp = NULL;
14137N/A+ int msec = -1; /* block until receive data */
14137N/A+ static char *keywords[] = {"msglen", "timeout", NULL};
14137N/A+ dlpi_raise_exception(DL_SYSERR);
14137N/A+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "k|i",
14137N/A+ dlpi_raise_exception(DL_SYSERR);
14137N/A+ dlpi_raise_exception(DL_SYSERR);
14137N/A+ if ((rval = dlpi_recv(link->dlpihdl, saddr, saddrlenp, msgbuf,
14137N/A+ msglenp, msec, NULL)) != DLPI_SUCCESS) {
14137N/A+ obj = Py_BuildValue("s#s#", saddr, saddrlen, msgbuf, msglen);
14137N/A+ "disabmulti(address) -> None\n"
14137N/A+ "Disable a specified multicast address on this link.\n"
14137N/A+ "See dlpi_disabmulti(3DLPI).\n"
14137N/A+link_disabmulti(pylink_t *link, PyObject *args, PyObject *kwds)
14137N/A+ static char *keywords[] = {"address", NULL};
14137N/A+ dlpi_raise_exception(DL_SYSERR);
14137N/A+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "s#", keywords,
14137N/A+ if ((addrlen == 0) || (addrlen > DLPI_PHYSADDR_MAX)) {
14137N/A+ dlpi_raise_exception(DL_SYSERR);
14137N/A+ if ((rval = dlpi_disabmulti(link->dlpihdl, addr, addrlen)) !=
14137N/A+ "enabmulti(address) -> None\n"
14137N/A+ "Enable a specified multicast address on this link.\n"
14137N/A+ "See dlpi_enabmulti(3DLPI).\n"
14137N/A+link_enabmulti(pylink_t *link, PyObject *args, PyObject *kwds)
14137N/A+ static char *keywords[] = {"address", NULL};
14137N/A+ dlpi_raise_exception(DL_SYSERR);
14137N/A+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "s#", keywords,
14137N/A+ if ((addrlen == 0) || (addrlen > DLPI_PHYSADDR_MAX)) {
14137N/A+ dlpi_raise_exception(DL_SYSERR);
14137N/A+ if ((rval = dlpi_enabmulti(link->dlpihdl, addr, addrlen)) !=
14137N/A+dlpi_callback(dlpi_handle_t hdl, dlpi_notifyinfo_t *ni, void *arg)
14137N/A+ callback_data_t *cd = (callback_data_t *)arg;
14137N/A+ arglist = Py_BuildValue("(OII)",
14137N/A+ cd->pyarg, ni->dni_note, ni->dni_speed);
14137N/A+ arglist = Py_BuildValue("(OII)",
14137N/A+ cd->pyarg, ni->dni_note, ni->dni_size);
14137N/A+ arglist = Py_BuildValue("(OIs#)",
14137N/A+ cd->pyarg, ni->dni_note, ni->dni_physaddr,
14137N/A+ arglist = Py_BuildValue("(OIO)", cd->pyarg, ni->dni_note,
14137N/A+ result = PyEval_CallObject(cd->pyfunc, arglist);
14137N/A+ PyErr_Clear(); /* cannot raise error */
14137N/A+ "enabnotify(events, function[, arg]) -> unsigned long\n"
14137N/A+ "Enables a notification callback for the set of specified events,\n"
14137N/A+ "which must be one or more (by a logical OR) events listed as below:\n"
14137N/A+ "NOTE_LINK_DOWN Notify when link has gone down\n"
14137N/A+ "NOTE_LINK_UP Notify when link has come up\n"
14137N/A+ "NOTE_PHYS_ADDR Notify when address changes\n"
14137N/A+ "NOTE_SDU_SIZE Notify when MTU changes\n"
14137N/A+ "NOTE_SPEED Notify when speed changes\n"
14137N/A+ "NOTE_PROMISC_ON_PHYS Notify when PROMISC_PHYS is set\n"
14137N/A+ "NOTE_PROMISC_OFF_PHYS Notify when PROMISC_PHYS is cleared\n"
14137N/A+ "Returns a handle for this registration.\n"
14137N/A+ "See dlpi_enabnotify(3DLPI).\n"
14137N/A+link_enabnotify(pylink_t *link, PyObject *args, PyObject *kwds)
14137N/A+ PyObject *func = NULL, *arg = NULL;
14137N/A+ static char *keywords[] = {"events", "function", "arg", NULL};
14137N/A+ dlpi_raise_exception(DL_SYSERR);
14137N/A+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "IO|O",
14137N/A+ keywords, ¬es, &func, &arg))
14137N/A+ if (!PyCallable_Check(func)) {
14137N/A+ dlpi_raise_exception(DL_SYSERR);
14137N/A+ cd = malloc(sizeof(callback_data_t));
14137N/A+ dlpi_raise_exception(DL_SYSERR);
14137N/A+ if ((rval = dlpi_enabnotify(link->dlpihdl, notes, dlpi_callback,
14137N/A+ return (Py_BuildValue("k", id));
14137N/A+ "disabnotify(handle) -> argument object, or None\n"
14137N/A+ "Disables the notification registration associated with handle.\n"
14137N/A+ "You should get this handle by calling enabnotify().\n"
14137N/A+ "Returns the argument passed in when registering the callback, or None.\n"
14137N/A+ "See dlpi_disabnotify(3DLPI).\n"
14137N/A+link_disabnotify(pylink_t *link, PyObject *args, PyObject *kwds)
14137N/A+ static char *keywords[] = {"handle", NULL};
14137N/A+ dlpi_raise_exception(DL_SYSERR);
14137N/A+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "k", keywords, &id))
14137N/A+ if ((rval = dlpi_disabnotify(link->dlpihdl, id, (void **)&arg)) !=
14137N/A+ "Returns the sap bound to this link.\n"
14137N/A+ dlpi_raise_exception(DL_SYSERR);
14137N/A+ if ((rval = dlpi_info(link->dlpihdl, &info, 0)) !=
14137N/A+ "Returns the integer file descriptor that can be used to directly\n"
14137N/A+ dlpi_raise_exception(DL_SYSERR);
14137N/A+ if ((fd = dlpi_fd(link->dlpihdl)) == -1) {
14137N/A+ dlpi_raise_exception(DL_SYSERR);
14137N/A+ return (Py_BuildValue("i", fd));
14137N/A+ "Returns the name of the link.\n"
14137N/A+link_get_linkname(pylink_t *link)
14137N/A+ dlpi_raise_exception(DL_SYSERR);
14137N/A+ if ((name = dlpi_linkname(link->dlpihdl)) == NULL) {
14137N/A+ dlpi_raise_exception(DL_SYSERR);
14137N/A+ return (Py_BuildValue("s", name));
14137N/A+PyDoc_STRVAR(get_bcastaddr_doc,
14137N/A+ "get_bcastaddr() -> string, or None\n"
14137N/A+ "Returns the broadcast address of the link.\n"
14137N/A+ "Returns None if the broadcast address is empty.\n"
14137N/A+link_get_bcastaddr(pylink_t *link)
14137N/A+ char *addr[DLPI_PHYSADDR_MAX];
14137N/A+ dlpi_raise_exception(DL_SYSERR);
14137N/A+ if ((rval = dlpi_info(link->dlpihdl, &info, 0)) !=
14137N/A+ "get_physaddr(addrtype) -> string, or None\n"
14137N/A+ "Addrtype can be any one of the value listed below:\n"
14137N/A+ "FACT_PHYS_ADDR Factory physical address\n"
14137N/A+ "CURR_PHYS_ADDR Current physical address\n"
14137N/A+ "Returns the corresponding physical address of the link.\n"
14137N/A+ "See dlpi_get_physaddr(3DLPI).\n"
14137N/A+link_get_physaddr(pylink_t *link, PyObject *args, PyObject *kwds)
14137N/A+ char *addr[DLPI_PHYSADDR_MAX];
14137N/A+ size_t addrlen = DLPI_PHYSADDR_MAX;
14137N/A+ static char *keywords[] = {"addrtype", NULL};
14137N/A+ dlpi_raise_exception(DL_SYSERR);
14137N/A+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "I", keywords, &type))
14137N/A+ if ((rval = dlpi_get_physaddr(link->dlpihdl, type, addr, &addrlen)) !=
14137N/A+ return (Py_BuildValue("s#", addr, addrlen));
14137N/A+ "set_physaddr(address) -> None\n"
14137N/A+ "Sets the physical address of the link.\n"
14137N/A+ "See dlpi_set_physaddr(3DLPI).\n"
14137N/A+link_set_physaddr(pylink_t *link, PyObject *args, PyObject *kwds)
14137N/A+ static char *keywords[] = {"address", NULL};
14137N/A+ dlpi_raise_exception(DL_SYSERR);
14137N/A+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "s#", keywords,
14137N/A+ if ((rval = dlpi_set_physaddr(link->dlpihdl, DL_CURR_PHYS_ADDR,
14137N/A+ addr, addrlen)) != DLPI_SUCCESS) {
14137N/A+ "promiscon([level]) -> None\n"
14137N/A+ "Enables promiscuous mode for the link at levels:\n"
14137N/A+ "PROMISC_PHYS Promiscuous mode at the physical level(default)\n"
14137N/A+ "PROMISC_SAP Promiscuous mode at the SAP level\n"
14137N/A+ "PROMISC_MULTI Promiscuous mode for all multicast addresses\n"
14137N/A+ "See dlpi_promiscon(3DLPI).\n"
14137N/A+link_promiscon(pylink_t *link, PyObject *args, PyObject *kwds)
14137N/A+ uint_t level = DL_PROMISC_PHYS;
14137N/A+ static char *keywords[] = {"level", NULL};
14137N/A+ dlpi_raise_exception(DL_SYSERR);
14137N/A+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "|I", keywords, &level))
14137N/A+ if ((rval = dlpi_promiscon(link->dlpihdl, level)) != DLPI_SUCCESS) {
14137N/A+ "promiscoff([level]) -> None\n"
14137N/A+ "Disables promiscuous mode for the link at levels:\n"
14137N/A+ "PROMISC_PHYS Promiscuous mode at the physical level(default)\n"
14137N/A+ "PROMISC_SAP Promiscuous mode at the SAP level\n"
14137N/A+ "PROMISC_MULTI Promiscuous mode for all multicast addresses\n"
14137N/A+ "See dlpi_promiscoff(3DLPI).\n"
14137N/A+link_promiscoff(pylink_t *link, PyObject *args, PyObject *kwds)
14137N/A+ uint_t level = DL_PROMISC_PHYS;
14137N/A+ static char *keywords[] = {"level", NULL};
14137N/A+ dlpi_raise_exception(DL_SYSERR);
14137N/A+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "|I", keywords, &level))
14137N/A+ if ((rval = dlpi_promiscoff(link->dlpihdl, level)) != DLPI_SUCCESS) {
14137N/A+ "Returns current time out value of the link.\n"
14137N/A+link_get_timeout(pylink_t *link)
14137N/A+ dlpi_raise_exception(DL_SYSERR);
14137N/A+ if ((rval = dlpi_info(link->dlpihdl, &info, 0)) !=
14137N/A+ "get_mactype() -> unsigned char\n"
14137N/A+ "Returns MAC type of the link.\n"
14137N/A+link_get_mactype(pylink_t *link)
14137N/A+ dlpi_raise_exception(DL_SYSERR);
14137N/A+ if ((rval = dlpi_info(link->dlpihdl, &info, 0)) !=
14137N/A+ "set_timeout(timeout) -> None\n"
14137N/A+ "Sets time out value of the link (default value: DEF_TIMEOUT).\n"
14137N/A+ "See dlpi_set_timeout(3DLPI).\n"
14137N/A+link_set_timeout(pylink_t *link, PyObject *args, PyObject *kwds)
14137N/A+ int timeout = DLPI_DEF_TIMEOUT;
14137N/A+ static char *keywords[] = {"timeout", NULL};
14137N/A+ dlpi_raise_exception(DL_SYSERR);
14137N/A+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "i", keywords, &timeout))
14137N/A+ if ((rval = dlpi_set_timeout(link->dlpihdl, timeout)) != DLPI_SUCCESS) {
14137N/A+ "get_sdu() -> (unsigned int, unsigned int)\n"
14137N/A+ "Returns (min sdu, max sdu).\n"
14137N/A+ dlpi_raise_exception(DL_SYSERR);
14137N/A+ if ((rval = dlpi_info(link->dlpihdl, &info, 0)) !=
14137N/A+ "get_state() -> unsigned int\n"
14137N/A+ "Returns current state of the link (either UNBOUND or IDLE).\n"
14137N/A+ dlpi_raise_exception(DL_SYSERR);
14137N/A+ if ((rval = dlpi_info(link->dlpihdl, &info, 0)) !=
14137N/A+PyDoc_STRVAR(get_qos_select_doc,
14137N/A+ "get_qos_select() -> (unsigned int, int, int, int)\n"
14137N/A+ "Returns (qos type, trans delay, priority, residul err).\n"
14137N/A+ "Unsupported QOS parameters are set to UNKNOWN.\n"
14137N/A+link_get_qos_select(pylink_t *link)
14137N/A+ dlpi_raise_exception(DL_SYSERR);
14137N/A+ if ((rval = dlpi_info(link->dlpihdl, &info, 0)) !=
14137N/A+ return (Py_BuildValue("Iiiii",
14137N/A+PyDoc_STRVAR(get_qos_range_doc,
14137N/A+ " (unsigned int, (int, int), (int, int), (int, int), int)\n"
14137N/A+ "Returns (qos type, (trans delay target, trans delay accept),\n"
14137N/A+ "(min priority, max priority), (min protection, max protection),\n"
14137N/A+ "Unsupported QOS range values are set to UNKNOWN.\n"
14137N/A+link_get_qos_range(pylink_t *link)
14137N/A+ dlpi_raise_exception(DL_SYSERR);
14137N/A+ if ((rval = dlpi_info(link->dlpihdl, &info, 0)) !=
14137N/A+ return (Py_BuildValue("I(ii)(ii)(ii)i",
14137N/A+static PyMethodDef pylink_methods[] = {
14137N/A+ {"bind", (PyCFunction)link_bind, METH_VARARGS|METH_KEYWORDS, bind_doc},
14137N/A+ {"unbind", (PyCFunction)link_unbind, METH_NOARGS, unbind_doc},
14137N/A+ {"send", (PyCFunction)link_send, METH_VARARGS|METH_KEYWORDS,
14137N/A+ {"recv", (PyCFunction)link_recv, METH_VARARGS|METH_KEYWORDS,
14137N/A+ {"disabmulti", (PyCFunction)link_disabmulti, METH_VARARGS|METH_KEYWORDS,
14137N/A+ {"enabmulti", (PyCFunction)link_enabmulti, METH_VARARGS|METH_KEYWORDS,
14137N/A+ {"enabnotify", (PyCFunction)link_enabnotify,
14137N/A+ METH_VARARGS|METH_KEYWORDS, enabnotify_doc},
14137N/A+ {"disabnotify", (PyCFunction)link_disabnotify,
14137N/A+ METH_VARARGS|METH_KEYWORDS, disabnotify_doc},
14137N/A+ {"get_fd", (PyCFunction)link_get_fd, METH_NOARGS, get_fd_doc},
14137N/A+ {"get_sap", (PyCFunction)link_get_sap, METH_NOARGS, get_sap_doc},
14137N/A+ {"get_mactype", (PyCFunction)link_get_mactype, METH_NOARGS,
14137N/A+ {"get_linkname", (PyCFunction)link_get_linkname, METH_NOARGS,
14137N/A+ {"get_bcastaddr", (PyCFunction)link_get_bcastaddr, METH_NOARGS,
14137N/A+ {"get_physaddr", (PyCFunction)link_get_physaddr,
14137N/A+ METH_VARARGS|METH_KEYWORDS, get_physaddr_doc},
14137N/A+ {"set_physaddr", (PyCFunction)link_set_physaddr,
14137N/A+ METH_VARARGS|METH_KEYWORDS, set_physaddr_doc},
14137N/A+ {"promiscon", (PyCFunction)link_promiscon, METH_VARARGS|METH_KEYWORDS,
14137N/A+ {"promiscoff", (PyCFunction)link_promiscoff, METH_VARARGS|METH_KEYWORDS,
14137N/A+ {"get_timeout", (PyCFunction)link_get_timeout, METH_NOARGS,
14137N/A+ {"set_timeout", (PyCFunction)link_set_timeout,
14137N/A+ METH_VARARGS|METH_KEYWORDS, set_timeout_doc},
14137N/A+ {"get_sdu", (PyCFunction)link_get_sdu, METH_NOARGS, get_sdu_doc},
14137N/A+ {"get_state", (PyCFunction)link_get_state, METH_NOARGS,
14137N/A+ {"get_qos_select", (PyCFunction)link_get_qos_select, METH_NOARGS,
14137N/A+ {"get_qos_range", (PyCFunction)link_get_qos_range, METH_NOARGS,
14137N/A+static PyTypeObject pylink_type = {
14137N/A+ PyObject_HEAD_INIT(0) /* Must fill in type value later */
14137N/A+ sizeof(pylink_t), /* tp_basicsize */
14137N/A+ (destructor)link_dealloc, /* tp_dealloc */
14137N/A+ Py_TPFLAGS_DEFAULT, /* tp_flags */
14137N/A+ pylink_methods, /* tp_methods */
14137N/A+ (initproc)link_init, /* tp_init */
14137N/A+ PyType_GenericNew, /* tp_new */
14137N/A+ "arptype(arptype) -> unsigned int\n"
14137N/A+ "Converts a DLPI MAC type to an ARP hardware type defined\n"
14137N/A+arptype(PyObject *dlpi, PyObject *args, PyObject *kwds)
14137N/A+ static char *keywords[] = {"arptype", NULL};
14137N/A+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "I", keywords, &dlpityp))
14137N/A+ if ((arptyp = dlpi_arptype(dlpityp)) == 0) {
14137N/A+ dlpi_raise_exception(DL_SYSERR);
14137N/A+ return (Py_BuildValue("I", arptyp));
14137N/A+ "iftype(iftype) -> unsigned int\n"
14137N/A+ "Converts a DLPI MAC type to a BSD socket interface type\n"
14137N/A+iftype(PyObject *dlpi, PyObject *args, PyObject *kwds)
14137N/A+ static char *keywords[] = {"iftype", NULL};
14137N/A+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "I", keywords, &dlpityp))
14137N/A+ if ((iftyp = dlpi_iftype(dlpityp)) == 0) {
14137N/A+ dlpi_raise_exception(DL_SYSERR);
14137N/A+ return (Py_BuildValue("I", iftyp));
14137N/A+ "mactype(mactype) -> string\n"
14137N/A+ "Returns a string that describes the specified mactype.\n"
14137N/A+mactype(PyObject *dlpi, PyObject *args, PyObject *kwds)
14137N/A+ static char *keywords[] = {"mactype", NULL};
14137N/A+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "I", keywords, &mactyp))
14137N/A+ return (Py_BuildValue("s", dlpi_mactype(mactyp)));
14137N/A+link_walker(const char *name, void *arg)
14137N/A+ PyObject *list = (PyObject *)arg;
14137N/A+ if ((list == NULL) || !PyList_Check(list))
14137N/A+ linkname = Py_BuildValue("s", name);
14137N/A+ if (PyList_Append(list, linkname) == -1)
14137N/A+ "Returns a list containing link names of all links on the system.\n"
14137N/A+ if ((list = PyList_New(0)) == NULL)
14137N/A+ dlpi_walk(link_walker, list, 0);
14137N/A+static PyMethodDef dlpi_methods[] = {
14137N/A+ {"arptype", (PyCFunction)arptype, METH_VARARGS|METH_KEYWORDS,
14137N/A+ {"iftype", (PyCFunction)iftype, METH_VARARGS|METH_KEYWORDS,
14137N/A+ {"mactype", (PyCFunction)mactype, METH_VARARGS|METH_KEYWORDS,
14137N/A+ {"listlink", (PyCFunction)listlink, METH_NOARGS, listlink_doc},
14137N/A+ if (PyType_Ready(&pylink_type) < 0)
14137N/A+ mod = Py_InitModule("dlpi", dlpi_methods);
14137N/A+ PyModule_AddObject(mod, "error", dlpi_err);
14137N/A+ PyModule_AddObject(mod, "link", (PyObject *)&pylink_type);
14137N/A+ PyModule_AddIntConstant(mod, "PASSIVE", DLPI_PASSIVE);
14137N/A+ PyModule_AddIntConstant(mod, "RAW", DLPI_RAW);
14137N/A+ PyModule_AddIntConstant(mod, "NATIVE", DLPI_NATIVE);
14137N/A+ PyModule_AddIntConstant(mod, "ANY_SAP", DLPI_ANY_SAP);
14137N/A+ PyModule_AddIntConstant(mod, "DEF_TIMEOUT", DLPI_DEF_TIMEOUT);
14137N/A+ PyModule_AddIntConstant(mod, "NOTE_LINK_DOWN", DL_NOTE_LINK_DOWN);
14137N/A+ PyModule_AddIntConstant(mod, "NOTE_LINK_UP", DL_NOTE_LINK_UP);
14137N/A+ PyModule_AddIntConstant(mod, "NOTE_PHYS_ADDR", DL_NOTE_PHYS_ADDR);
14137N/A+ PyModule_AddIntConstant(mod, "NOTE_SDU_SIZE", DL_NOTE_SDU_SIZE);
14137N/A+ PyModule_AddIntConstant(mod, "NOTE_SPEED", DL_NOTE_SPEED);
14137N/A+ PyModule_AddIntConstant(mod, "NOTE_PROMISC_ON_PHYS",
14137N/A+ PyModule_AddIntConstant(mod, "NOTE_PROMISC_OFF_PHYS",
14137N/A+ PyModule_AddIntConstant(mod, "FACT_PHYS_ADDR", DL_FACT_PHYS_ADDR);
14137N/A+ PyModule_AddIntConstant(mod, "CURR_PHYS_ADDR", DL_CURR_PHYS_ADDR);
14137N/A+ PyModule_AddIntConstant(mod, "PROMISC_PHYS", DL_PROMISC_PHYS);
14137N/A+ PyModule_AddIntConstant(mod, "PROMISC_SAP", DL_PROMISC_SAP);
14137N/A+ PyModule_AddIntConstant(mod, "PROMISC_MULTI", DL_PROMISC_MULTI);
14137N/A+ PyModule_AddIntConstant(mod, "UNKNOWN", DL_UNKNOWN);
14137N/A+ PyModule_AddIntConstant(mod, "UNBOUND", DL_UNBOUND);
14137N/A+ PyModule_AddIntConstant(mod, "IDLE", DL_IDLE);
14137N/A+ PyModule_AddIntConstant(mod, "SYSERR", DL_SYSERR);
14137N/A # Thomas Heller's _ctypes module