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