Home | History | Annotate | Download | only in src
      1 /* Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
      2  * Use of this source code is governed by a BSD-style license that can be
      3  * found in the LICENSE file.
      4  *
      5  * This module exposes the constants from the linux/if_tun.h header file to
      6  * allow a Python script to create and manipulate TUN/TAP interfaces.
      7  * It also includes constants from linux/if.h and sys/ioctl.h not available in
      8  * other python modules.
      9  *
     10  * Some of these constants are architecture specific and can't be implemented
     11  * in pure Python, like the ioctl() call numbers.
     12  */
     13 
     14 #include <Python.h>
     15 
     16 /* Python wrappers */
     17 void _init_linux_if_h(PyObject *m);
     18 void _init_linux_if_tun_h(PyObject *m);
     19 void _init_sys_ioctl_h(PyObject *m);
     20 
     21 /* Module initialization */
     22 static PyMethodDef pyiftun_methods[] = {
     23   {NULL, NULL, 0, NULL}        /* Sentinel */
     24 };
     25 
     26 PyMODINIT_FUNC
     27 initpyiftun(void) {
     28   PyObject *m;
     29   m = Py_InitModule("pyiftun", pyiftun_methods);
     30   if (!m) return;
     31 
     32   /* Initialize the wrappers */
     33   _init_linux_if_h(m);
     34   _init_linux_if_tun_h(m);
     35   _init_sys_ioctl_h(m);
     36 }
     37