components/python/python27/patches/07-dlpi.patch
author Mike Sullivan <Mike.Sullivan@Oracle.COM>
Mon, 11 Mar 2013 10:38:09 -0700
branchs11-update
changeset 2520 ceec631e74d1
parent 458 2edc011b559e
child 1246 164605dfef4e
child 3367 ed5024e47b53
permissions -rw-r--r--
Close of build 10.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
458
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
     1
diff --git Python-2.6.4/Modules/dlpimodule.c Python-2.6.4/Modules/dlpimodule.c
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
     2
new file mode 100644
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
     3
--- /dev/null
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
     4
+++ Python-2.6.4/Modules/dlpimodule.c
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
     5
@@ -0,0 +1,1205 @@
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
     6
+/*
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
     7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
     8
+ * of this software and associated documentation files (the "Software"), to
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
     9
+ * deal in the Software without restriction, including without limitation the
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    10
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    11
+ * sell copies of the Software, and to permit persons to whom the Software is
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    12
+ * furnished to do so, subject to the following conditions:
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    13
+ *
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    14
+ * The above copyright notice and this permission notice shall be included in
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    15
+ * all copies or substantial portions of the Software.
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    16
+ *
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    22
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    23
+ * DEALINGS IN THE SOFTWARE.
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    24
+ *
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    25
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    26
+ */
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    27
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    28
+#include <Python.h>
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    29
+#include <stdio.h>
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    30
+#include <libdlpi.h>
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    31
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    32
+typedef struct {
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    33
+	PyObject_HEAD
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    34
+	dlpi_handle_t dlpihdl;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    35
+} pylink_t;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    36
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    37
+typedef struct {
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    38
+	PyObject *pyfunc;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    39
+	PyObject *pyarg;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    40
+} callback_data_t;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    41
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    42
+/*
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    43
+ * dlpi_err: the only exception raised for libdlpi related error.
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    44
+ * The accompanying value is:
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    45
+ * (dlpi_error_number, string), when it's a dlpi specific error,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    46
+ * or, (DL_SYSERR, errno, string), when it's coming from a system call.
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    47
+ */
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    48
+static PyObject *dlpi_err;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    49
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    50
+static void
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    51
+dlpi_raise_exception(int err)
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    52
+{
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    53
+	PyObject *e = NULL;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    54
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    55
+	if (err == DL_SYSERR) {
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    56
+		e = Py_BuildValue("(iis)", DL_SYSERR, errno, strerror(errno));
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    57
+	} else {
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    58
+		e = Py_BuildValue("(is)", err, dlpi_strerror(err));
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    59
+	}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    60
+	if (e != NULL) {
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    61
+		PyErr_SetObject(dlpi_err, e);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    62
+		Py_DECREF(e);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    63
+	}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    64
+}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    65
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    66
+PyDoc_STRVAR(link_doc,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    67
+    "link(linkname[, flags]) -> link object\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    68
+    "\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    69
+    "Open linkname with specified flags.\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    70
+    "Three flags are supported: PASSIVE, RAW, NATIVE.\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    71
+    "And these flags can be bitwise-OR'ed together(default flag is 0).\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    72
+    "You need sys_net_rawaccess privilege to open a link.\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    73
+    "See dlpi_open(3DLPI).\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    74
+);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    75
+static int
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    76
+link_init(PyObject *self, PyObject *args, PyObject *kwds)
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    77
+{
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    78
+	uint_t flags = 0;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    79
+	dlpi_handle_t dh;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    80
+	char *linkname;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    81
+	int rval;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    82
+	static char *keywords[] = {"linkname", "flags", NULL};
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    83
+	pylink_t *link = (pylink_t *)self;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    84
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    85
+	if (!PyArg_ParseTupleAndKeywords(args, kwds, "s|I", keywords,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    86
+	    &linkname, &flags))
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    87
+		return (-1);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    88
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    89
+	if ((rval = dlpi_open(linkname, &dh, flags)) != DLPI_SUCCESS) {
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    90
+		dlpi_raise_exception(rval);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    91
+		return (-1);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    92
+	}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    93
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    94
+	link->dlpihdl = dh;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    95
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    96
+	return (0);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    97
+}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    98
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    99
+static void
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   100
+link_dealloc(pylink_t *link)
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   101
+{
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   102
+	if (link->dlpihdl != NULL)
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   103
+		dlpi_close(link->dlpihdl);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   104
+	link->ob_type->tp_free((PyObject *)link);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   105
+}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   106
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   107
+PyDoc_STRVAR(bind_doc,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   108
+    "bind(sap) -> unsigned int\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   109
+    "\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   110
+    "Attempts to bind the link to specified SAP, or ANY_SAP.\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   111
+    "Returns the SAP that the function actually bound to, which\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   112
+    "could be different from the SAP requested.\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   113
+    "See dlpi_bind(3DLPI).\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   114
+);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   115
+static PyObject *
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   116
+link_bind(pylink_t *link, PyObject *args, PyObject *kwds)
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   117
+{
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   118
+	uint_t sap = 0, boundsap = 0;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   119
+	static char *keywords[] = {"sap", NULL};
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   120
+	int rval;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   121
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   122
+	if (link->dlpihdl == NULL) {
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   123
+		errno = EINVAL;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   124
+		dlpi_raise_exception(DL_SYSERR);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   125
+		return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   126
+	}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   127
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   128
+	if (!PyArg_ParseTupleAndKeywords(args, kwds, "I", keywords, &sap))
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   129
+		return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   130
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   131
+	if ((rval = dlpi_bind(link->dlpihdl, sap, &boundsap)) !=
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   132
+	    DLPI_SUCCESS) {
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   133
+		dlpi_raise_exception(rval);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   134
+		return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   135
+	}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   136
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   137
+	return (Py_BuildValue("I", boundsap));
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   138
+}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   139
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   140
+PyDoc_STRVAR(unbind_doc,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   141
+    "unbind() -> None\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   142
+    "\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   143
+    "Attempts to unbind the link from previously bound sap.\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   144
+    "See dlpi_unbind(3DLPI).\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   145
+);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   146
+static PyObject *
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   147
+link_unbind(pylink_t *link)
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   148
+{
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   149
+	int rval;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   150
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   151
+	if (link->dlpihdl == NULL) {
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   152
+		errno = EINVAL;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   153
+		dlpi_raise_exception(DL_SYSERR);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   154
+		return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   155
+	}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   156
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   157
+	if ((rval = dlpi_unbind(link->dlpihdl)) != DLPI_SUCCESS) {
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   158
+		dlpi_raise_exception(rval);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   159
+		return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   160
+	}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   161
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   162
+	Py_INCREF(Py_None);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   163
+	return (Py_None);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   164
+}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   165
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   166
+PyDoc_STRVAR(send_doc,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   167
+    "send(destaddr, message[, sap, minpri, maxpri]) -> None\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   168
+    "\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   169
+    "Attempts to send message over this link to sap on destaddr.\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   170
+    "If SAP is not specified, the bound SAP is used\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   171
+    "You can also specify priority range (minpri, maxpri).\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   172
+    "See dlpi_send(3DLPI).\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   173
+);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   174
+static PyObject *
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   175
+link_send(pylink_t *link, PyObject *args, PyObject *kwds)
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   176
+{
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   177
+	char *daddr = NULL, *msgbuf = NULL;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   178
+	size_t daddrlen = 0, msglen = 0;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   179
+	t_scalar_t minpri = DL_QOS_DONT_CARE, maxpri = DL_QOS_DONT_CARE;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   180
+	uint_t sap = DLPI_ANY_SAP;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   181
+	dlpi_sendinfo_t ds, *dsp = NULL;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   182
+	static char *keywords[] =
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   183
+	    {"destaddr", "message", "sap", "minpri", "maxpri", NULL};
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   184
+	int rval;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   185
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   186
+	if (link->dlpihdl == NULL) {
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   187
+		errno = EINVAL;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   188
+		dlpi_raise_exception(DL_SYSERR);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   189
+		return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   190
+	}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   191
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   192
+	if (!PyArg_ParseTupleAndKeywords(args, kwds, "s#s#|Iii", keywords,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   193
+	    &daddr, &daddrlen, &msgbuf, &msglen, &sap, &minpri, &maxpri))
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   194
+		return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   195
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   196
+	if ((sap != DLPI_ANY_SAP) || (minpri != DL_QOS_DONT_CARE) ||
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   197
+	    (maxpri != DL_QOS_DONT_CARE)) {
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   198
+		ds.dsi_sap = sap;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   199
+		ds.dsi_prio.dl_min = minpri;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   200
+		ds.dsi_prio.dl_max = maxpri;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   201
+		dsp = &ds;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   202
+	}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   203
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   204
+	if ((rval = dlpi_send(link->dlpihdl, daddr, daddrlen,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   205
+	    msgbuf, msglen, dsp)) != DLPI_SUCCESS) {
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   206
+		dlpi_raise_exception(rval);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   207
+		return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   208
+	}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   209
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   210
+	Py_INCREF(Py_None);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   211
+	return (Py_None);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   212
+}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   213
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   214
+PyDoc_STRVAR(recv_doc,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   215
+    "recv(msglen[, timeout]) -> (string, string), or (None, None)\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   216
+    "\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   217
+    "Attempts to receive message over this link.\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   218
+    "You need to specify the message length for the received message.\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   219
+    "And you can specify timeout value in milliseconds.\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   220
+    "The default timeout value is -1 (wait forever).\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   221
+    "Returns (source address, message data), or (None, None) when error occurs.\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   222
+    "See dlpi_recv(3DLPI).\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   223
+);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   224
+static PyObject *
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   225
+link_recv(pylink_t *link, PyObject *args, PyObject *kwds)
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   226
+{
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   227
+	PyObject *obj;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   228
+	char *saddr = NULL, *msgbuf = NULL;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   229
+	size_t saddrlen = 0, msglen = 0, *saddrlenp = NULL, *msglenp = NULL;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   230
+	int msec = -1; /* block until receive data */
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   231
+	static char *keywords[] = {"msglen", "timeout", NULL};
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   232
+	int rval;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   233
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   234
+	if (link->dlpihdl == NULL) {
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   235
+		errno = EINVAL;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   236
+		dlpi_raise_exception(DL_SYSERR);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   237
+		return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   238
+	}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   239
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   240
+	if (!PyArg_ParseTupleAndKeywords(args, kwds, "k|i",
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   241
+	    keywords, &msglen, &msec))
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   242
+		return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   243
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   244
+	if (msglen > 0) {
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   245
+		msgbuf = malloc(msglen);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   246
+		if (msgbuf == NULL) {
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   247
+			dlpi_raise_exception(DL_SYSERR);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   248
+			return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   249
+		}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   250
+		saddrlen = DLPI_PHYSADDR_MAX;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   251
+		saddr = malloc(saddrlen);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   252
+		if (saddr == NULL) {
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   253
+			dlpi_raise_exception(DL_SYSERR);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   254
+			free(msgbuf);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   255
+			return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   256
+		}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   257
+		msglenp = &msglen;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   258
+		saddrlenp = &saddrlen;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   259
+	}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   260
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   261
+	if ((rval = dlpi_recv(link->dlpihdl, saddr, saddrlenp, msgbuf,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   262
+	    msglenp, msec, NULL)) != DLPI_SUCCESS) {
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   263
+		if (msgbuf != NULL)
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   264
+			free(msgbuf);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   265
+		if (saddr != NULL)
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   266
+			free(saddr);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   267
+		dlpi_raise_exception(rval);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   268
+		return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   269
+	}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   270
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   271
+	obj = Py_BuildValue("s#s#", saddr, saddrlen, msgbuf, msglen);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   272
+	if (msgbuf != NULL)
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   273
+		free(msgbuf);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   274
+	if (saddr != NULL)
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   275
+		free(saddr);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   276
+	return (obj);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   277
+}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   278
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   279
+PyDoc_STRVAR(disabmulti_doc,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   280
+    "disabmulti(address) -> None\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   281
+    "\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   282
+    "Disable a specified multicast address on this link.\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   283
+    "See dlpi_disabmulti(3DLPI).\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   284
+);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   285
+static PyObject *
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   286
+link_disabmulti(pylink_t *link, PyObject *args, PyObject *kwds)
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   287
+{
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   288
+	char *addr = NULL;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   289
+	size_t addrlen = 0;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   290
+	static char *keywords[] = {"address", NULL};
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   291
+	int rval;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   292
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   293
+	if (link->dlpihdl == NULL) {
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   294
+		errno = EINVAL;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   295
+		dlpi_raise_exception(DL_SYSERR);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   296
+		return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   297
+	}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   298
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   299
+	if (!PyArg_ParseTupleAndKeywords(args, kwds, "s#", keywords,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   300
+	    &addr, &addrlen))
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   301
+		return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   302
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   303
+	if ((addrlen == 0) || (addrlen > DLPI_PHYSADDR_MAX)) {
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   304
+		errno = EINVAL;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   305
+		dlpi_raise_exception(DL_SYSERR);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   306
+		return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   307
+	}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   308
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   309
+	if ((rval = dlpi_disabmulti(link->dlpihdl, addr, addrlen)) !=
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   310
+	    DLPI_SUCCESS) {
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   311
+		dlpi_raise_exception(rval);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   312
+		return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   313
+	}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   314
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   315
+	Py_INCREF(Py_None);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   316
+	return (Py_None);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   317
+}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   318
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   319
+PyDoc_STRVAR(enabmulti_doc,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   320
+    "enabmulti(address) -> None\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   321
+    "\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   322
+    "Enable a specified multicast address on this link.\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   323
+    "See dlpi_enabmulti(3DLPI).\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   324
+);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   325
+static PyObject *
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   326
+link_enabmulti(pylink_t *link, PyObject *args, PyObject *kwds)
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   327
+{
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   328
+	char *addr = NULL;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   329
+	size_t addrlen = 0;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   330
+	static char *keywords[] = {"address", NULL};
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   331
+	int rval;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   332
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   333
+	if (link->dlpihdl == NULL) {
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   334
+		errno = EINVAL;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   335
+		dlpi_raise_exception(DL_SYSERR);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   336
+		return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   337
+	}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   338
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   339
+	if (!PyArg_ParseTupleAndKeywords(args, kwds, "s#", keywords,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   340
+	    &addr, &addrlen))
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   341
+		return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   342
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   343
+	if ((addrlen == 0) || (addrlen > DLPI_PHYSADDR_MAX)) {
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   344
+		errno = EINVAL;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   345
+		dlpi_raise_exception(DL_SYSERR);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   346
+		return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   347
+	}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   348
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   349
+	if ((rval = dlpi_enabmulti(link->dlpihdl, addr, addrlen)) !=
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   350
+	    DLPI_SUCCESS) {
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   351
+		dlpi_raise_exception(rval);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   352
+		return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   353
+	}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   354
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   355
+	Py_INCREF(Py_None);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   356
+	return (Py_None);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   357
+}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   358
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   359
+static void
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   360
+dlpi_callback(dlpi_handle_t hdl, dlpi_notifyinfo_t *ni, void *arg)
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   361
+{
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   362
+	callback_data_t *cd = (callback_data_t *)arg;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   363
+	PyObject *arglist, *result;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   364
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   365
+	switch (ni->dni_note) {
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   366
+	case DL_NOTE_SPEED:
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   367
+		arglist = Py_BuildValue("(OII)",
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   368
+		    cd->pyarg, ni->dni_note, ni->dni_speed);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   369
+		break;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   370
+	case DL_NOTE_SDU_SIZE:
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   371
+		arglist = Py_BuildValue("(OII)",
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   372
+		    cd->pyarg, ni->dni_note, ni->dni_size);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   373
+		break;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   374
+	case DL_NOTE_PHYS_ADDR:
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   375
+		arglist = Py_BuildValue("(OIs#)",
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   376
+		    cd->pyarg, ni->dni_note, ni->dni_physaddr,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   377
+		    ni->dni_physaddrlen);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   378
+		break;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   379
+	default:
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   380
+		arglist = Py_BuildValue("(OIO)", cd->pyarg, ni->dni_note,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   381
+		    Py_None);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   382
+	}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   383
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   384
+	result = PyEval_CallObject(cd->pyfunc, arglist);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   385
+	Py_DECREF(arglist);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   386
+	if (result == NULL) {
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   387
+		PyErr_Clear(); /* cannot raise error */
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   388
+	}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   389
+	Py_DECREF(result);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   390
+	Py_DECREF(cd->pyfunc);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   391
+	Py_XDECREF(cd->pyarg);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   392
+	free(cd);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   393
+}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   394
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   395
+PyDoc_STRVAR(enabnotify_doc,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   396
+    "enabnotify(events, function[, arg]) -> unsigned long\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   397
+    "\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   398
+    "Enables a notification callback for the set of specified events,\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   399
+    "which must be one or more (by a logical OR) events listed as below:\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   400
+    "NOTE_LINK_DOWN         Notify when link has gone down\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   401
+    "NOTE_LINK_UP           Notify when link has come up\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   402
+    "NOTE_PHYS_ADDR         Notify when address changes\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   403
+    "NOTE_SDU_SIZE          Notify when MTU changes\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   404
+    "NOTE_SPEED             Notify when speed changes\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   405
+    "NOTE_PROMISC_ON_PHYS   Notify when PROMISC_PHYS is set\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   406
+    "NOTE_PROMISC_OFF_PHYS  Notify when PROMISC_PHYS is cleared\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   407
+    "Returns a handle for this registration.\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   408
+    "See dlpi_enabnotify(3DLPI).\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   409
+);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   410
+static PyObject *
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   411
+link_enabnotify(pylink_t *link, PyObject *args, PyObject *kwds)
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   412
+{
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   413
+	PyObject *func = NULL, *arg = NULL;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   414
+	callback_data_t *cd;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   415
+	uint_t notes = 0;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   416
+	static char *keywords[] = {"events", "function", "arg", NULL};
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   417
+	dlpi_notifyid_t id;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   418
+	int rval;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   419
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   420
+	if (link->dlpihdl == NULL) {
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   421
+		errno = EINVAL;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   422
+		dlpi_raise_exception(DL_SYSERR);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   423
+		return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   424
+	}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   425
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   426
+	if (!PyArg_ParseTupleAndKeywords(args, kwds, "IO|O",
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   427
+	    keywords, &notes, &func, &arg))
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   428
+		return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   429
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   430
+	if (!PyCallable_Check(func)) {
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   431
+		errno = EINVAL;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   432
+		dlpi_raise_exception(DL_SYSERR);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   433
+		return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   434
+	}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   435
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   436
+	cd = malloc(sizeof(callback_data_t));
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   437
+	if (cd == NULL) {
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   438
+		dlpi_raise_exception(DL_SYSERR);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   439
+		return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   440
+	}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   441
+	Py_INCREF(func);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   442
+	Py_XINCREF(arg);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   443
+	cd->pyfunc = func;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   444
+	cd->pyarg = arg;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   445
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   446
+	if ((rval = dlpi_enabnotify(link->dlpihdl, notes, dlpi_callback,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   447
+	    cd, &id)) != DLPI_SUCCESS) {
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   448
+		free(cd);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   449
+		Py_DECREF(func);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   450
+		Py_XDECREF(arg);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   451
+		dlpi_raise_exception(rval);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   452
+		return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   453
+	}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   454
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   455
+	return (Py_BuildValue("k", id));
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   456
+}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   457
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   458
+PyDoc_STRVAR(disabnotify_doc,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   459
+    "disabnotify(handle) -> argument object, or None\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   460
+    "\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   461
+    "Disables the notification registration associated with handle.\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   462
+    "You should get this handle by calling enabnotify().\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   463
+    "Returns the argument passed in when registering the callback, or None.\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   464
+    "See dlpi_disabnotify(3DLPI).\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   465
+);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   466
+static PyObject *
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   467
+link_disabnotify(pylink_t *link, PyObject *args, PyObject *kwds)
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   468
+{
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   469
+	dlpi_notifyid_t id;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   470
+	callback_data_t *arg;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   471
+	PyObject *pyargsaved;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   472
+	static char *keywords[] = {"handle", NULL};
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   473
+	int rval;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   474
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   475
+	if (link->dlpihdl == NULL) {
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   476
+		errno = EINVAL;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   477
+		dlpi_raise_exception(DL_SYSERR);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   478
+		return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   479
+	}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   480
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   481
+	if (!PyArg_ParseTupleAndKeywords(args, kwds, "k", keywords, &id))
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   482
+		return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   483
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   484
+	if ((rval = dlpi_disabnotify(link->dlpihdl, id, (void **)&arg)) !=
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   485
+	    DLPI_SUCCESS) {
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   486
+		dlpi_raise_exception(rval);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   487
+		return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   488
+	}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   489
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   490
+	/* clean up */
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   491
+	pyargsaved = arg->pyarg;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   492
+	Py_XINCREF(pyargsaved);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   493
+	Py_XDECREF(arg->pyarg);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   494
+	Py_DECREF(arg->pyfunc);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   495
+	free(arg);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   496
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   497
+	if (pyargsaved != NULL)
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   498
+		return (pyargsaved);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   499
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   500
+	Py_INCREF(Py_None);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   501
+	return (Py_None);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   502
+}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   503
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   504
+PyDoc_STRVAR(get_sap_doc,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   505
+    "get_sap() -> unsigned int\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   506
+    "\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   507
+    "Returns the sap bound to this link.\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   508
+    "See dlpi_info(3DLPI).\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   509
+);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   510
+static PyObject *
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   511
+link_get_sap(pylink_t *link)
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   512
+{
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   513
+	dlpi_info_t info;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   514
+	int rval;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   515
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   516
+	if (link->dlpihdl == NULL) {
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   517
+		errno = EINVAL;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   518
+		dlpi_raise_exception(DL_SYSERR);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   519
+		return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   520
+	}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   521
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   522
+	if ((rval = dlpi_info(link->dlpihdl, &info, 0)) !=
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   523
+	    DLPI_SUCCESS) {
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   524
+		dlpi_raise_exception(rval);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   525
+		return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   526
+	}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   527
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   528
+	return (Py_BuildValue("I", info.di_sap));
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   529
+}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   530
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   531
+PyDoc_STRVAR(get_fd_doc,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   532
+    "get_fd() -> int\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   533
+    "\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   534
+    "Returns the integer file descriptor that can be used to directly\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   535
+    "operate on the link.\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   536
+    "See dlpi_fd(3DLPI).\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   537
+);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   538
+static PyObject *
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   539
+link_get_fd(pylink_t *link)
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   540
+{
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   541
+	int fd;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   542
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   543
+	if (link->dlpihdl == NULL) {
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   544
+		errno = EINVAL;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   545
+		dlpi_raise_exception(DL_SYSERR);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   546
+		return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   547
+	}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   548
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   549
+	if ((fd = dlpi_fd(link->dlpihdl)) == -1) {
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   550
+		dlpi_raise_exception(DL_SYSERR);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   551
+		return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   552
+	}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   553
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   554
+	return (Py_BuildValue("i", fd));
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   555
+}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   556
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   557
+PyDoc_STRVAR(get_linkname_doc,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   558
+    "get_linkname() -> string\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   559
+    "\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   560
+    "Returns the name of the link.\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   561
+    "See dlpi_linkname(3DLPI).\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   562
+);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   563
+static PyObject *
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   564
+link_get_linkname(pylink_t *link)
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   565
+{
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   566
+	const char *name = NULL;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   567
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   568
+	if (link->dlpihdl == NULL) {
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   569
+		errno = EINVAL;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   570
+		dlpi_raise_exception(DL_SYSERR);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   571
+		return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   572
+	}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   573
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   574
+	if ((name = dlpi_linkname(link->dlpihdl)) == NULL) {
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   575
+		dlpi_raise_exception(DL_SYSERR);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   576
+		return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   577
+	}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   578
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   579
+	return (Py_BuildValue("s", name));
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   580
+}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   581
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   582
+PyDoc_STRVAR(get_bcastaddr_doc,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   583
+    "get_bcastaddr() -> string, or None\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   584
+    "\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   585
+    "Returns the broadcast address of the link.\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   586
+    "Returns None if the broadcast address is empty.\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   587
+    "See dlpi_info(3DLPI).\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   588
+);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   589
+static PyObject *
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   590
+link_get_bcastaddr(pylink_t *link)
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   591
+{
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   592
+	char *addr[DLPI_PHYSADDR_MAX];
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   593
+	size_t addrlen = 0;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   594
+	dlpi_info_t info;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   595
+	int rval;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   596
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   597
+	if (link->dlpihdl == NULL) {
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   598
+		errno = EINVAL;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   599
+		dlpi_raise_exception(DL_SYSERR);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   600
+		return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   601
+	}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   602
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   603
+	if ((rval = dlpi_info(link->dlpihdl, &info, 0)) !=
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   604
+	    DLPI_SUCCESS) {
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   605
+		dlpi_raise_exception(rval);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   606
+		return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   607
+	}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   608
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   609
+	if (info.di_bcastaddrlen == 0) {
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   610
+		Py_INCREF(Py_None);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   611
+		return (Py_None);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   612
+	}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   613
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   614
+	return (Py_BuildValue("s#", info.di_bcastaddr, info.di_bcastaddrlen));
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   615
+}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   616
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   617
+PyDoc_STRVAR(get_physaddr_doc,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   618
+    "get_physaddr(addrtype) -> string, or None\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   619
+    "\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   620
+    "Addrtype can be any one of the value listed below:\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   621
+    "FACT_PHYS_ADDR    Factory physical address\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   622
+    "CURR_PHYS_ADDR    Current physical address\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   623
+    "Returns the corresponding physical address of the link.\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   624
+    "See dlpi_get_physaddr(3DLPI).\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   625
+);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   626
+static PyObject *
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   627
+link_get_physaddr(pylink_t *link, PyObject *args, PyObject *kwds)
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   628
+{
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   629
+	char *addr[DLPI_PHYSADDR_MAX];
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   630
+	size_t addrlen = DLPI_PHYSADDR_MAX;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   631
+	static char *keywords[] = {"addrtype", NULL};
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   632
+	uint_t type;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   633
+	int rval;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   634
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   635
+	if (link->dlpihdl == NULL) {
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   636
+		errno = EINVAL;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   637
+		dlpi_raise_exception(DL_SYSERR);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   638
+		return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   639
+	}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   640
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   641
+	if (!PyArg_ParseTupleAndKeywords(args, kwds, "I", keywords, &type))
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   642
+		return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   643
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   644
+	if ((rval = dlpi_get_physaddr(link->dlpihdl, type, addr, &addrlen)) !=
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   645
+	    DLPI_SUCCESS) {
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   646
+		dlpi_raise_exception(rval);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   647
+		return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   648
+	}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   649
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   650
+	return (Py_BuildValue("s#", addr, addrlen));
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   651
+}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   652
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   653
+PyDoc_STRVAR(set_physaddr_doc,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   654
+    "set_physaddr(address) -> None\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   655
+    "\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   656
+    "Sets the physical address of the link.\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   657
+    "See dlpi_set_physaddr(3DLPI).\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   658
+);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   659
+static PyObject *
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   660
+link_set_physaddr(pylink_t *link, PyObject *args, PyObject *kwds)
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   661
+{
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   662
+	char *addr = NULL;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   663
+	size_t addrlen = 0;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   664
+	static char *keywords[] = {"address", NULL};
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   665
+	int rval;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   666
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   667
+	if (link->dlpihdl == NULL) {
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   668
+		errno = EINVAL;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   669
+		dlpi_raise_exception(DL_SYSERR);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   670
+		return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   671
+	}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   672
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   673
+	if (!PyArg_ParseTupleAndKeywords(args, kwds, "s#", keywords,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   674
+	    &addr, &addrlen))
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   675
+		return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   676
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   677
+	if ((rval = dlpi_set_physaddr(link->dlpihdl, DL_CURR_PHYS_ADDR,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   678
+	    addr, addrlen)) != DLPI_SUCCESS) {
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   679
+		dlpi_raise_exception(rval);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   680
+		return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   681
+	}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   682
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   683
+	Py_INCREF(Py_None);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   684
+	return (Py_None);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   685
+}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   686
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   687
+PyDoc_STRVAR(promiscon_doc,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   688
+    "promiscon([level]) -> None\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   689
+    "\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   690
+    "Enables promiscuous mode for the link at levels:\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   691
+    "PROMISC_PHYS     Promiscuous mode at the physical level(default)\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   692
+    "PROMISC_SAP      Promiscuous mode at the SAP level\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   693
+    "PROMISC_MULTI    Promiscuous mode for all multicast addresses\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   694
+    "See dlpi_promiscon(3DLPI).\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   695
+);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   696
+static PyObject *
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   697
+link_promiscon(pylink_t *link, PyObject *args, PyObject *kwds)
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   698
+{
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   699
+	uint_t level = DL_PROMISC_PHYS;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   700
+	static char *keywords[] = {"level", NULL};
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   701
+	int rval;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   702
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   703
+	if (link->dlpihdl == NULL) {
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   704
+		errno = EINVAL;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   705
+		dlpi_raise_exception(DL_SYSERR);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   706
+		return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   707
+	}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   708
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   709
+	if (!PyArg_ParseTupleAndKeywords(args, kwds, "|I", keywords, &level))
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   710
+		return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   711
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   712
+	if ((rval = dlpi_promiscon(link->dlpihdl, level)) != DLPI_SUCCESS) {
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   713
+		dlpi_raise_exception(rval);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   714
+		return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   715
+	}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   716
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   717
+	Py_INCREF(Py_None);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   718
+	return (Py_None);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   719
+}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   720
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   721
+PyDoc_STRVAR(promiscoff_doc,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   722
+    "promiscoff([level]) -> None\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   723
+    "\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   724
+    "Disables promiscuous mode for the link at levels:\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   725
+    "PROMISC_PHYS     Promiscuous mode at the physical level(default)\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   726
+    "PROMISC_SAP      Promiscuous mode at the SAP level\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   727
+    "PROMISC_MULTI    Promiscuous mode for all multicast addresses\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   728
+    "See dlpi_promiscoff(3DLPI).\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   729
+);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   730
+static PyObject *
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   731
+link_promiscoff(pylink_t *link, PyObject *args, PyObject *kwds)
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   732
+{
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   733
+	uint_t level = DL_PROMISC_PHYS;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   734
+	static char *keywords[] = {"level", NULL};
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   735
+	int rval;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   736
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   737
+	if (link->dlpihdl == NULL) {
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   738
+		errno = EINVAL;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   739
+		dlpi_raise_exception(DL_SYSERR);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   740
+		return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   741
+	}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   742
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   743
+	if (!PyArg_ParseTupleAndKeywords(args, kwds, "|I", keywords, &level))
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   744
+		return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   745
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   746
+	if ((rval = dlpi_promiscoff(link->dlpihdl, level)) != DLPI_SUCCESS) {
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   747
+		dlpi_raise_exception(rval);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   748
+		return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   749
+	}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   750
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   751
+	Py_INCREF(Py_None);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   752
+	return (Py_None);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   753
+}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   754
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   755
+PyDoc_STRVAR(get_timeout_doc,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   756
+    "get_timeout() -> int\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   757
+    "\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   758
+    "Returns current time out value of the link.\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   759
+    "See dlpi_info(3DLPI).\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   760
+);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   761
+static PyObject *
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   762
+link_get_timeout(pylink_t *link)
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   763
+{
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   764
+	dlpi_info_t info;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   765
+	int rval;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   766
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   767
+	if (link->dlpihdl == NULL) {
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   768
+		errno = EINVAL;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   769
+		dlpi_raise_exception(DL_SYSERR);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   770
+		return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   771
+	}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   772
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   773
+	if ((rval = dlpi_info(link->dlpihdl, &info, 0)) !=
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   774
+	    DLPI_SUCCESS) {
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   775
+		dlpi_raise_exception(rval);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   776
+		return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   777
+	}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   778
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   779
+	return (Py_BuildValue("i", info.di_timeout));
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   780
+}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   781
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   782
+PyDoc_STRVAR(get_mactype_doc,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   783
+    "get_mactype() -> unsigned char\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   784
+    "\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   785
+    "Returns MAC type of the link.\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   786
+    "See <sys/dlpi.h> for the list of possible MAC types.\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   787
+    "See dlpi_info(3DLPI).\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   788
+);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   789
+static PyObject *
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   790
+link_get_mactype(pylink_t *link)
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   791
+{
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   792
+	dlpi_info_t info;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   793
+	int rval;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   794
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   795
+	if (link->dlpihdl == NULL) {
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   796
+		errno = EINVAL;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   797
+		dlpi_raise_exception(DL_SYSERR);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   798
+		return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   799
+	}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   800
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   801
+	if ((rval = dlpi_info(link->dlpihdl, &info, 0)) !=
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   802
+	    DLPI_SUCCESS) {
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   803
+		dlpi_raise_exception(rval);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   804
+		return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   805
+	}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   806
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   807
+	return (Py_BuildValue("B", info.di_mactype));
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   808
+}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   809
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   810
+PyDoc_STRVAR(set_timeout_doc,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   811
+    "set_timeout(timeout) -> None\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   812
+    "\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   813
+    "Sets time out value of the link (default value: DEF_TIMEOUT).\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   814
+    "See dlpi_set_timeout(3DLPI).\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   815
+);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   816
+static PyObject *
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   817
+link_set_timeout(pylink_t *link, PyObject *args, PyObject *kwds)
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   818
+{
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   819
+	int timeout = DLPI_DEF_TIMEOUT;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   820
+	static char *keywords[] = {"timeout", NULL};
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   821
+	int rval;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   822
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   823
+	if (link->dlpihdl == NULL) {
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   824
+		errno = EINVAL;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   825
+		dlpi_raise_exception(DL_SYSERR);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   826
+		return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   827
+	}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   828
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   829
+	if (!PyArg_ParseTupleAndKeywords(args, kwds, "i", keywords, &timeout))
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   830
+		return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   831
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   832
+	if ((rval = dlpi_set_timeout(link->dlpihdl, timeout)) != DLPI_SUCCESS) {
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   833
+		dlpi_raise_exception(rval);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   834
+		return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   835
+	}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   836
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   837
+	Py_INCREF(Py_None);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   838
+	return (Py_None);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   839
+}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   840
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   841
+PyDoc_STRVAR(get_sdu_doc,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   842
+    "get_sdu() -> (unsigned int, unsigned int)\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   843
+    "\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   844
+    "Returns (min sdu, max sdu).\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   845
+    "See dlpi_info(3DLPI).\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   846
+);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   847
+static PyObject *
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   848
+link_get_sdu(pylink_t *link)
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   849
+{
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   850
+	dlpi_info_t info;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   851
+	int rval;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   852
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   853
+	if (link->dlpihdl == NULL) {
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   854
+		errno = EINVAL;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   855
+		dlpi_raise_exception(DL_SYSERR);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   856
+		return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   857
+	}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   858
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   859
+	if ((rval = dlpi_info(link->dlpihdl, &info, 0)) !=
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   860
+	    DLPI_SUCCESS) {
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   861
+		dlpi_raise_exception(rval);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   862
+		return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   863
+	}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   864
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   865
+	return (Py_BuildValue("II", info.di_min_sdu, info.di_max_sdu));
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   866
+}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   867
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   868
+PyDoc_STRVAR(get_state_doc,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   869
+    "get_state() -> unsigned int\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   870
+    "\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   871
+    "Returns current state of the link (either UNBOUND or IDLE).\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   872
+    "See dlpi_info(3DLPI).\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   873
+);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   874
+static PyObject *
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   875
+link_get_state(pylink_t *link)
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   876
+{
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   877
+	dlpi_info_t info;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   878
+	int rval;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   879
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   880
+	if (link->dlpihdl == NULL) {
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   881
+		errno = EINVAL;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   882
+		dlpi_raise_exception(DL_SYSERR);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   883
+		return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   884
+	}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   885
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   886
+	if ((rval = dlpi_info(link->dlpihdl, &info, 0)) !=
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   887
+	    DLPI_SUCCESS) {
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   888
+		dlpi_raise_exception(rval);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   889
+		return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   890
+	}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   891
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   892
+	return (Py_BuildValue("I", info.di_state));
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   893
+}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   894
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   895
+PyDoc_STRVAR(get_qos_select_doc,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   896
+    "get_qos_select() -> (unsigned int, int, int, int)\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   897
+    "\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   898
+    "Returns (qos type, trans delay, priority, residul err).\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   899
+    "Unsupported QOS parameters are set to UNKNOWN.\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   900
+    "See dlpi_info(3DLPI).\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   901
+);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   902
+static PyObject *
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   903
+link_get_qos_select(pylink_t *link)
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   904
+{
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   905
+	dlpi_info_t info;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   906
+	int rval;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   907
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   908
+	if (link->dlpihdl == NULL) {
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   909
+		errno = EINVAL;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   910
+		dlpi_raise_exception(DL_SYSERR);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   911
+		return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   912
+	}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   913
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   914
+	if ((rval = dlpi_info(link->dlpihdl, &info, 0)) !=
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   915
+	    DLPI_SUCCESS) {
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   916
+		dlpi_raise_exception(rval);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   917
+		return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   918
+	}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   919
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   920
+	return (Py_BuildValue("Iiiii",
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   921
+	    info.di_qos_sel.dl_qos_type,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   922
+	    info.di_qos_sel.dl_trans_delay,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   923
+	    info.di_qos_sel.dl_priority,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   924
+	    info.di_qos_sel.dl_residual_error));
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   925
+}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   926
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   927
+PyDoc_STRVAR(get_qos_range_doc,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   928
+    "get_qos_range() -> \n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   929
+    "	(unsigned int, (int, int), (int, int), (int, int), int)\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   930
+    "\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   931
+    "Returns (qos type, (trans delay target, trans delay accept),\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   932
+    "(min priority, max priority), (min protection, max protection),\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   933
+    "residual err).\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   934
+    "Unsupported QOS range values are set to UNKNOWN.\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   935
+    "See dlpi_info(3DLPI).\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   936
+);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   937
+static PyObject *
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   938
+link_get_qos_range(pylink_t *link)
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   939
+{
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   940
+	dlpi_info_t info;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   941
+	int rval;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   942
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   943
+	if (link->dlpihdl == NULL) {
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   944
+		errno = EINVAL;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   945
+		dlpi_raise_exception(DL_SYSERR);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   946
+		return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   947
+	}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   948
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   949
+	if ((rval = dlpi_info(link->dlpihdl, &info, 0)) !=
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   950
+	    DLPI_SUCCESS) {
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   951
+		dlpi_raise_exception(rval);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   952
+		return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   953
+	}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   954
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   955
+	return (Py_BuildValue("I(ii)(ii)(ii)i",
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   956
+	    info.di_qos_range.dl_qos_type,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   957
+	    info.di_qos_range.dl_trans_delay.dl_target_value,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   958
+	    info.di_qos_range.dl_trans_delay.dl_accept_value,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   959
+	    info.di_qos_range.dl_priority.dl_min,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   960
+	    info.di_qos_range.dl_priority.dl_max,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   961
+	    info.di_qos_range.dl_protection.dl_min,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   962
+	    info.di_qos_range.dl_protection.dl_max,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   963
+	    info.di_qos_range.dl_residual_error));
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   964
+}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   965
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   966
+static PyMethodDef pylink_methods[] = {
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   967
+	{"bind", (PyCFunction)link_bind, METH_VARARGS|METH_KEYWORDS, bind_doc},
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   968
+	{"unbind", (PyCFunction)link_unbind, METH_NOARGS, unbind_doc},
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   969
+	{"send", (PyCFunction)link_send, METH_VARARGS|METH_KEYWORDS,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   970
+	    send_doc},
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   971
+	{"recv", (PyCFunction)link_recv, METH_VARARGS|METH_KEYWORDS,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   972
+	    recv_doc},
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   973
+	{"disabmulti", (PyCFunction)link_disabmulti, METH_VARARGS|METH_KEYWORDS,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   974
+	    disabmulti_doc},
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   975
+	{"enabmulti", (PyCFunction)link_enabmulti, METH_VARARGS|METH_KEYWORDS,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   976
+	    enabmulti_doc},
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   977
+	{"enabnotify", (PyCFunction)link_enabnotify,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   978
+	    METH_VARARGS|METH_KEYWORDS, enabnotify_doc},
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   979
+	{"disabnotify", (PyCFunction)link_disabnotify,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   980
+	    METH_VARARGS|METH_KEYWORDS, disabnotify_doc},
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   981
+	{"get_fd", (PyCFunction)link_get_fd, METH_NOARGS, get_fd_doc},
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   982
+	{"get_sap", (PyCFunction)link_get_sap, METH_NOARGS, get_sap_doc},
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   983
+	{"get_mactype", (PyCFunction)link_get_mactype, METH_NOARGS,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   984
+	    get_mactype_doc},
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   985
+	{"get_linkname", (PyCFunction)link_get_linkname, METH_NOARGS,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   986
+	    get_linkname_doc},
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   987
+	{"get_bcastaddr", (PyCFunction)link_get_bcastaddr, METH_NOARGS,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   988
+	    get_bcastaddr_doc},
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   989
+	{"get_physaddr", (PyCFunction)link_get_physaddr,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   990
+	    METH_VARARGS|METH_KEYWORDS, get_physaddr_doc},
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   991
+	{"set_physaddr", (PyCFunction)link_set_physaddr,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   992
+	    METH_VARARGS|METH_KEYWORDS, set_physaddr_doc},
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   993
+	{"promiscon", (PyCFunction)link_promiscon, METH_VARARGS|METH_KEYWORDS,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   994
+	    promiscon_doc},
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   995
+	{"promiscoff", (PyCFunction)link_promiscoff, METH_VARARGS|METH_KEYWORDS,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   996
+	    promiscoff_doc},
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   997
+	{"get_timeout", (PyCFunction)link_get_timeout, METH_NOARGS,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   998
+	    get_timeout_doc},
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   999
+	{"set_timeout", (PyCFunction)link_set_timeout,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1000
+	    METH_VARARGS|METH_KEYWORDS, set_timeout_doc},
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1001
+	{"get_sdu", (PyCFunction)link_get_sdu, METH_NOARGS, get_sdu_doc},
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1002
+	{"get_state", (PyCFunction)link_get_state, METH_NOARGS,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1003
+	    get_state_doc},
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1004
+	{"get_qos_select", (PyCFunction)link_get_qos_select, METH_NOARGS,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1005
+	    get_qos_select_doc},
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1006
+	{"get_qos_range", (PyCFunction)link_get_qos_range, METH_NOARGS,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1007
+	    get_qos_range_doc},
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1008
+	{NULL}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1009
+};
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1010
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1011
+static PyTypeObject pylink_type = {
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1012
+	PyObject_HEAD_INIT(0)	/* Must fill in type value later */
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1013
+	0,					/* ob_size */
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1014
+	"dlpi.link",				/* tp_name */
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1015
+	sizeof(pylink_t),			/* tp_basicsize */
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1016
+	0,					/* tp_itemsize */
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1017
+	(destructor)link_dealloc,		/* tp_dealloc */
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1018
+	0,					/* tp_print */
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1019
+	0,					/* tp_getattr */
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1020
+	0,					/* tp_setattr */
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1021
+	0,					/* tp_compare */
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1022
+	0,					/* tp_repr */
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1023
+	0,					/* tp_as_number */
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1024
+	0,					/* tp_as_sequence */
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1025
+	0,					/* tp_as_mapping */
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1026
+	0,					/* tp_hash */
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1027
+	0,					/* tp_call */
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1028
+	0,					/* tp_str */
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1029
+	0,					/* tp_getattro */
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1030
+	0,					/* tp_setattro */
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1031
+	0,					/* tp_as_buffer */
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1032
+	Py_TPFLAGS_DEFAULT,			/* tp_flags */
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1033
+	link_doc,				/* tp_doc */
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1034
+	0,					/* tp_traverse */
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1035
+	0,					/* tp_clear */
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1036
+	0,					/* tp_richcompare */
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1037
+	0,					/* tp_weaklistoffset */
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1038
+	0,					/* tp_iter */
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1039
+	0,					/* tp_iternext */
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1040
+	pylink_methods,				/* tp_methods */
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1041
+	0,					/* tp_members */
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1042
+	0,					/* tp_getset */
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1043
+	0,					/* tp_base */
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1044
+	0,					/* tp_dict */
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1045
+	0,					/* tp_descr_get */
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1046
+	0,					/* tp_descr_set */
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1047
+	0,					/* tp_dictoffset */
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1048
+	(initproc)link_init,			/* tp_init */
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1049
+	0,					/* tp_alloc */
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1050
+	PyType_GenericNew,			/* tp_new */
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1051
+	0,					/* tp_free */
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1052
+};
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1053
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1054
+PyDoc_STRVAR(arptype_doc,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1055
+    "arptype(arptype) -> unsigned int\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1056
+    "\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1057
+    "Converts a DLPI MAC type to an ARP hardware type defined\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1058
+    " in <netinet/arp.h>\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1059
+    "See dlpi_arptype(3DLPI)\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1060
+);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1061
+static PyObject *
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1062
+arptype(PyObject *dlpi, PyObject *args, PyObject *kwds)
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1063
+{
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1064
+	static char *keywords[] = {"arptype", NULL};
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1065
+	uint_t dlpityp, arptyp;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1066
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1067
+	if (!PyArg_ParseTupleAndKeywords(args, kwds, "I", keywords, &dlpityp))
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1068
+		return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1069
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1070
+	if ((arptyp = dlpi_arptype(dlpityp)) == 0) {
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1071
+		errno = EINVAL;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1072
+		dlpi_raise_exception(DL_SYSERR);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1073
+		return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1074
+	}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1075
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1076
+	return (Py_BuildValue("I", arptyp));
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1077
+}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1078
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1079
+PyDoc_STRVAR(iftype_doc,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1080
+    "iftype(iftype) -> unsigned int\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1081
+    "\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1082
+    "Converts a DLPI MAC type to a BSD socket interface type\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1083
+    "defined in <net/if_types.h>\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1084
+    "See dlpi_iftype(3DLPI)\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1085
+);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1086
+static PyObject *
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1087
+iftype(PyObject *dlpi, PyObject *args, PyObject *kwds)
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1088
+{
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1089
+	static char *keywords[] = {"iftype", NULL};
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1090
+	uint_t dlpityp, iftyp;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1091
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1092
+	if (!PyArg_ParseTupleAndKeywords(args, kwds, "I", keywords, &dlpityp))
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1093
+		return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1094
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1095
+	if ((iftyp = dlpi_iftype(dlpityp)) == 0) {
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1096
+		errno = EINVAL;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1097
+		dlpi_raise_exception(DL_SYSERR);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1098
+		return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1099
+	}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1100
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1101
+	return (Py_BuildValue("I", iftyp));
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1102
+}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1103
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1104
+PyDoc_STRVAR(mactype_doc,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1105
+    "mactype(mactype) -> string\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1106
+    "\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1107
+    "Returns a string that describes the specified mactype.\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1108
+    "Valid mac types are defined in <sys/dlpi.h>.\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1109
+    "See dlpi_mactype(3DLPI)\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1110
+);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1111
+static PyObject *
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1112
+mactype(PyObject *dlpi, PyObject *args, PyObject *kwds)
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1113
+{
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1114
+	static char *keywords[] = {"mactype", NULL};
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1115
+	uint_t mactyp;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1116
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1117
+	if (!PyArg_ParseTupleAndKeywords(args, kwds, "I", keywords, &mactyp))
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1118
+		return (NULL);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1119
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1120
+	return (Py_BuildValue("s", dlpi_mactype(mactyp)));
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1121
+}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1122
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1123
+static boolean_t
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1124
+link_walker(const char *name, void *arg)
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1125
+{
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1126
+	PyObject *linkname;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1127
+	PyObject *list = (PyObject *)arg;
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1128
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1129
+	if ((list == NULL) || !PyList_Check(list))
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1130
+		return (B_FALSE);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1131
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1132
+	linkname = Py_BuildValue("s", name);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1133
+	if (PyList_Append(list, linkname) == -1)
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1134
+		return (B_TRUE);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1135
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1136
+	Py_DECREF(linkname);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1137
+	return (B_FALSE);
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1138
+}
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1139
+
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1140
+PyDoc_STRVAR(listlink_doc,
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1141
+    "listlink() -> list\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
  1142
+    "\n"
2edc011b559e 7004671 Add Python 2.7.1
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset