summaryrefslogtreecommitdiffstats
path: root/python
Commit message (Collapse)AuthorAgeFilesLines
* python: fix wrongly passing argument to function in ObjIterator.next()Hiroaki KAWAI2014-04-091-1/+1
| | | | | | | | | self.__next__() bound method does not take an extra argument. https://github.com/thom311/libnl/pull/57 Signed-off-by: Hiroaki KAWAI <kawai@stratosphere.co.jp> Signed-off-by: Thomas Haller <thaller@redhat.com>
* python: fix build error for missing library_path in setup.pyThomas Haller2014-01-211-0/+4
| | | | | | | | | Patch obtained from gentoo package. https://bugs.gentoo.org/show_bug.cgi?id=477110 https://bugs.gentoo.org/show_bug.cgi?id=490584 Signed-off-by: Thomas Haller <thaller@redhat.com>
* python: Include all files in distributionThomas Graf2013-11-065-2/+22
| | | | Signed-off-by: Thomas Graf <tgraf@suug.ch>
* python: add bridge flags APINicolas PLANEL2013-10-222-0/+45
| | | | | | | | | | | Add flags set/get methods aim to change bridge flags : o hairpin_mode o bpdu_guard o root_block o fast_leave Signed-off-by: Nicolas PLANEL <nicolas.planel@enovance.com> Signed-off-by: Thomas Graf <tgraf@suug.ch>
* test: add python bridge testing sampleNicolas PLANEL2013-10-221-0/+28
| | | | | | | | New test sample file, test-create-bridge.py Create an bridge (testbrige) and attach an already setup interface (testtap1) to it. Signed-off-by: Nicolas PLANEL <nicolas.planel@enovance.com> Signed-off-by: Thomas Graf <tgraf@suug.ch>
* python: add basic netlink protocol bridge interface supportNicolas PLANEL2013-10-223-0/+118
| | | | | | | Implements basic bridge interface support using netlink protocol Signed-off-by: Nicolas PLANEL <nicolas.planel@enovance.com> Signed-off-by: Thomas Graf <tgraf@suug.ch>
* Fixed ObjIterator for python3, fixed output of _color and added missing ↵Teto2013-10-072-3/+9
| | | | | | | | | | | | | | | | | | | | parameter to nl_cache_resync Here are a few things I fixed and that provoked a python error. I canno't answer to this thread but one solution I found while using the python binding is to iterate over all and filter via python http://list-archives.org/2013/09/09/libnl-lists-infradead-org/missing-feature-for-retrieving-cached- address-objects/f/5031600704 Example: cache = nlrta.AddressCache() cache.resync() for i in cache: print ("item", i ) # then you can filter here Signed-off-by: Thomas Graf <tgraf@suug.ch>
* python: fixup VLANLink() initializationNicolas PLANEL2013-10-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | The varialble name should be link._rtnl_link instead of link._link to get rid of the AttributeError. Traceback (most recent call last): File "examples/test.py", line 11, in <module> eth0 = link.resolve('eth0.800') ... File "/home/ubuntu/libnl/python/build/lib.linux-x86_64-2.7/netlink/route/link.py", line 151, in __init__ self._module_lookup('netlink.route.links.' + self.type) ... File "/home/ubuntu/libnl/python/build/lib.linux-x86_64-2.7/netlink/route/links/vlan.py", line 70, in init link.vlan = VLANLink(link._link) AttributeError: 'Link' object has no attribute '_link' Signed-off-by: Nicolas PLANEL <nicolas.planel@enovance.com> Signed-off-by: Thomas Graf <tgraf@suug.ch>
* python: remove use of PyArg_ParseTuple() for callback resultArend van Spriel2013-10-072-12/+17
| | | | | | | | | | | | | | The message receive callback handler in the netlink api processes the result object from the python callback. It used PyArg_ParseTuple() to get the value, but this does not work as intended (see ref [1]). Instead check the type and convert it accordingly. refs: [1] http://stackoverflow.com/questions/13636711/what-is-the-proper-usage-of-pyarg-parsetuple Reported-by: Teto <mattator@gmail.com> Signed-off-by: Arend van Spriel <arend@broadcom.com> Signed-off-by: Thomas Graf <tgraf@suug.ch>
* python: add send and receive functions to Socket classArend van Spriel2013-09-051-0/+15
| | | | | | | | Adding class methods send_auto_complete() and recvmsgs() that call their swig capi equivalent function. Signed-off-by: Arend van Spriel <arend@broadcom.com> Signed-off-by: Thomas Graf <tgraf@suug.ch>
* python: fix typo in Socket::__str__() functionArend van Spriel2013-09-051-1/+1
| | | | | | | | | | | | | | | The property name used in __str__ should be local_port instead of localPort to get rid of the AttributeError. >>> str(s) Traceback (most recent call last): File "<stdin>", line 1, in <module> File ".../netlink/core.py", line 172, in __str__ return 'nlsock<{0}>'.format(self.localPort) AttributeError: 'Socket' object has no attribute 'localPort' Signed-off-by: Arend van Spriel <arend@broadcom.com> Signed-off-by: Thomas Graf <tgraf@suug.ch>
* python: remove unnecessary callback type definitionsArend van Spriel2013-09-051-18/+0
| | | | | | | | Copied the typedefs when adding callback support, but they serve no actual use in the swig input file. Signed-off-by: Arend van Spriel <arend@broadcom.com> Signed-off-by: Thomas Graf <tgraf@suug.ch>
* python: allow callback function to be a class methodArend van Spriel2013-09-051-4/+28
| | | | | | | | | | | | | | | | | | | | | | The callback functionality only worked for regular Python functions. With this patch it also allows the callback to be a class method (bounded or unbounded) as show in example below. class test_class(object): def my_callback(self, msg, arg): print('handling %s' % str(msg)) s = netlink.core.Socket() testobj = test_class() netlink.capi.py_nl_cb_set(cb, netlink.capi.NL_CB_VALID, netlink.capi.NL_CB_CUSTOM, test_class.my_callback, testobj) netlink.capi.py_nl_cb_err(cb, netlink.capi.NL_CB_CUSTOM, test_class.my_callback, s) Signed-off-by: Arend van Spriel <arend@broadcom.com> Signed-off-by: Thomas Graf <tgraf@suug.ch>
* use Callback object constructing SocketArend van Spriel2013-09-051-2/+4
| | | | | Signed-off-by: Arend van Spriel <arend@broadcom.com> Signed-off-by: Thomas Graf <tgraf@suug.ch>
* python: rework netlink callback handlingArend van Spriel2013-09-053-27/+221
| | | | | | | | | | | | | | | | | | The initial commit adding netlink callback handling also introduced memory leak issue. The python callback info was stored in an allocated structure, but that was never freed. Only exposing nl_cb_alloc() as is. nl_cb_get() is removed as it is not very useful to use reference counting mechanism. Python uses that itself internally. To deal properly with Python callback info the function nl_cb_put() and nl_cb_clone() have a custom wrapper taking care of Python reference counting. This commit also adds a Callback python class using the netlink callback functions. Signed-off-by: Arend van Spriel <arend@broadcom.com> Signed-off-by: Thomas Graf <tgraf@suug.ch>
* add python examples using swig provided apiArend van Spriel2013-09-053-0/+1811
| | | | | | | | using the nl80211 family to show use of generic netlink api and attribute parsing. Signed-off-by: Arend van Spriel <arend@broadcom.com> Signed-off-by: Thomas Graf <tgraf@suug.ch>
* Add VXLAN support.Yasunobu Chiba2013-08-041-0/+63
|
* add generic netlink functions to swigArend van Spriel2013-07-181-0/+97
| | | | | | | | | Provide wrapper function for generic netlink library functions. The genlmsg_parse() function is handled similar to nla_parse_nested() so it returns tuple with error code and dictionary of parsed attributes. Signed-off-by: Arend van Spriel <arend@broadcom.com> Signed-off-by: Thomas Graf <tgraf@suug.ch>
* add python module for generic netlink libraryArend van Spriel2013-07-185-4/+27
| | | | | | | | | This commit adds creation of the netlink.genl package. The actual capi.i will be filled in upcoming commits so the module is rather dumb for now. Signed-off-by: Arend van Spriel <arend@broadcom.com> Signed-off-by: Thomas Graf <tgraf@suug.ch>
* add support functions for attributes and callback handlersArend van Spriel2013-07-181-0/+373
| | | | | | | | | | | | | | | | | | | | | | | | | | | | added support functions to access the netlink attributes and use custom callback handlers. Most is wrapped as is, but there are a couple of special cases handled. 1) void *nla_data(struct nlattr *); The return value is changed to a Python byte array so it includes the lenght of the data stream. 2) int nla_parse_nested(...); This returns a tuple (err, dict). 'err' is the error code and 'dict' is a dictionary with attribute identifier as key and value represents a struct nlattr object. 3) macro nla_for_each_nested() Provide nla_get_nested() which returns a Python list of struct nlattr objects that is iterable. 4) allocate struct nla_policy array Provide nla_policy_array() function that allocates consecutive space in memory for struct nla_policy array entries. Each entry is put in a Python list so the entry fields can be modified in Python. This array object can be passed to the nla_parse_nested() function. Signed-off-by: Arend van Spriel <arend@broadcom.com> Signed-off-by: Thomas Graf <tgraf@suug.ch>
* Add macvlan supportMichael Braun2013-05-161-0/+16
| | | | | | This patch add support for kernel macvlan interfaces. Signed-off-by: Michael Braun <michael-dev@fami-braun.de>
* Enabled the use of Links as context managers.Antoni S. Puimedon2012-10-041-0/+9
| | | | | | | | | | | | | | | | | With this change you can still set do modifications of Links and then to change to pass the changes to the kernel. But it additionally enables you to interact with this part of libnl-python in a more pythonic way. Instead of: eth0 = links['eth0'] eth0.mtu = 5000 eth0.change() you can do: with links['eth0'] as eth0: eth0.mtu = 5000
* Fixed memory leak in Cache destructorКоренберг Марк2012-06-081-1/+1
| | | | destructor of Cache was missing due to typo
* rtnl_link_(get|set)_weight is deprecated in libnl.Коренберг Марк (ноутбук дома)2012-06-082-21/+0
| | | | So, remove from python binding. Should not break compatibility.
* netlink.nlattr re-implemented in more pythonic wayКоренберг Марк2012-06-088-116/+66
|
* nl_pickup removed from python bindingКоренберг Марк2012-06-081-5/+0
|
* Remove unnecessary commentsКоренберг Марк (ноутбук дома)2012-06-086-186/+0
|
* Refine some placesКоренберг Марк (ноутбук дома)2012-06-082-19/+20
| | | | No real logick change
* pylint's first review and trivial fixesКоренберг Марк (ноутбук дома)2012-06-088-91/+105
|
* Using only single quotes now and multi-line listsКоренберг Марк (ноутбук дома)2012-06-087-41/+59
| | | | Nothing algorithmic changed really, just cosmetics
* Fix indentation (spaces vs tabs)Коренберг Марк (ноутбук дома)2012-06-089-2192/+2192
| | | | Now, python files use pseudo-tab equal 4 spaces
* Code cleanupsКоренберг Марк (ноутбук дома)2012-06-082-8/+2
| | | | | | 1. unused "import struct" removed 2. AddressFamily.__len__ is defined, but why in so way? removed. 3. comparison against instancemethod type fixed
* Flags properties description and implementation fixedКоренберг Марк (ноутбук дома)2012-06-083-9/+42
| | | | | | | 1. Address, Link and Vlan classes affected with same bug 2. Flags property are not designed as set class. Setting to property will not replace flags, just add flags to set. So, jist document that, and fixed obvious logick.
* Fixed various str-related logickКоренберг Марк (ноутбук дома)2012-06-085-10/+10
|
* Fix whitespaces at EOLКоренберг Марк (ноутбук дома)2012-06-087-27/+27
| | | | Make git happy with that
* Introduce Python's absolute_importsКоренберг Марк (ноутбук дома)2012-06-089-31/+47
| | | | Helps greatly when porting to Python 3
* Fix typo in still unused function that generate colored messageКоренберг Марк (ноутбук дома)2012-06-081-1/+1
|
* Make syntax highlighters happyКоренберг Марк (ноутбук дома)2012-06-081-1/+1
| | | | Fix typo in docstring
* Removed generated .pyc files from repositoryКоренберг Марк2012-06-083-0/+0
|
* Fixed address deletionКоренберг Марк (ноутбук дома)2012-06-081-3/+3
| | | | | 1. rtnl_addr_delete require three arguments 2. comment fixed (fixed copy-past from link.py)
* python: Link against nl-3 and nl-route-3Thomas Graf2011-10-261-2/+2
|
* python: Include python/ in distribution and provide a README on how to build ↵Thomas Graf2011-08-126-1/+41
| | | | & install
* use rtnl_link_set/get_type()Thomas Graf2011-07-213-4/+6
|
* removed autogenerated swig interface files from git treeThomas Graf2011-07-214-20757/+0
|
* ignore python build directoryThomas Graf2011-07-211-0/+1
|
* Work on libnl-pythonThomas Graf2011-06-1020-324/+21478
| | | | Changes too numerous to describe them
* python interface to netlink protocolsThomas Graf2011-05-1021-0/+3985
currently includes experimental support for links, addresses and some traffic control