summaryrefslogtreecommitdiff
path: root/python
AgeCommit message (Collapse)Author
2019-08-16all: Use __typeof__ instead of typeofMichael Forney
This allows libnl to be built with -std=c99, which prevents the compiler from using non-reserved identifiers for extensions.
2017-02-27build: merge python/Makefile.am into top-level makefileThomas Haller
2015-05-12python: genl: capi: add genlmsg_hdr() to capiArend van Spriel
Allow using genlmsg_hdr() function and make the header fields accessible in Python scripts. Signed-off-by: Arend van Spriel <aspriel@gmail.com>
2015-05-12python: capi: add nla_put() function to python capiArend van Spriel
Adding nla_put() to the capi using a typemap on the input parameter which needs to be either a str or bytearray. Otherwise a SWIG exception with be thrown. Signed-off-by: Arend van Spriel <aspriel@gmail.com>
2015-05-12python: capi: expose multicast membership functionsArend van Spriel
Adding functions to add/drop membership to single multicast group. Signed-off-by: Arend van Spriel <aspriel@gmail.com>
2015-05-12python: disable swig debug print messagesArend van Spriel
The define was left enabled during development on netlink (and genl) python swig api. It is a bit annoying in production release so disable the define. Signed-off-by: Arend van Spriel <aspriel@gmail.com>
2015-01-12python: fix package meta data in setup.pyThomas Haller
http://lists.infradead.org/pipermail/libnl/2015-January/001802.html Acked-by: Thomas Graf <tgraf@suug.ch> Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-05-25Use paths relative to srcdir in setup.py.Michał Górny
Currently, setup.py is created by configure in builddir while source files (.py and .i) reside in srcdir. Adjust paths in setup.py appropriately to make it possible to perform an out-of-source build. This is far from perfect but it mostly works. Python files are copied from srcdir, and swig *.i files are read from there. However, swig output files are created in srcdir rather than builddir, and distutils copies '..' literally when constructing '.o' paths. As a result, '../python/foo.i' would end up being compiled to 'build/temp*/../python/foo.i'. The alternative would be to copy '*.i' files to builddir before proceeding with the build, either in Makefile or through creating additional distutils command.
2014-04-09python: fix wrongly passing argument to function in ObjIterator.next()Hiroaki KAWAI
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>
2014-01-21python: fix build error for missing library_path in setup.pyThomas Haller
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>
2013-11-06python: Include all files in distributionThomas Graf
Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-10-22python: add bridge flags APINicolas PLANEL
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>
2013-10-22test: add python bridge testing sampleNicolas PLANEL
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>
2013-10-22python: add basic netlink protocol bridge interface supportNicolas PLANEL
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>
2013-10-07Fixed ObjIterator for python3, fixed output of _color and added missing ↵Teto
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>
2013-10-07python: fixup VLANLink() initializationNicolas PLANEL
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>
2013-10-07python: remove use of PyArg_ParseTuple() for callback resultArend van Spriel
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>
2013-09-05python: add send and receive functions to Socket classArend van Spriel
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>
2013-09-05python: fix typo in Socket::__str__() functionArend van Spriel
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>
2013-09-05python: remove unnecessary callback type definitionsArend van Spriel
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>
2013-09-05python: allow callback function to be a class methodArend van Spriel
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>
2013-09-05use Callback object constructing SocketArend van Spriel
Signed-off-by: Arend van Spriel <arend@broadcom.com> Signed-off-by: Thomas Graf <tgraf@suug.ch>
2013-09-05python: rework netlink callback handlingArend van Spriel
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>
2013-09-05add python examples using swig provided apiArend van Spriel
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>
2013-08-04Add VXLAN support.Yasunobu Chiba
2013-07-18add generic netlink functions to swigArend van Spriel
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>
2013-07-18add python module for generic netlink libraryArend van Spriel
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>
2013-07-18add support functions for attributes and callback handlersArend van Spriel
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>
2013-05-16Add macvlan supportMichael Braun
This patch add support for kernel macvlan interfaces. Signed-off-by: Michael Braun <michael-dev@fami-braun.de>
2012-10-04Enabled the use of Links as context managers.Antoni S. Puimedon
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
2012-06-08Fixed memory leak in Cache destructorКоренберг Марк
destructor of Cache was missing due to typo
2012-06-08rtnl_link_(get|set)_weight is deprecated in libnl.Коренберг Марк (ноутбук дома)
So, remove from python binding. Should not break compatibility.
2012-06-08netlink.nlattr re-implemented in more pythonic wayКоренберг Марк
2012-06-08nl_pickup removed from python bindingКоренберг Марк
2012-06-08Remove unnecessary commentsКоренберг Марк (ноутбук дома)
2012-06-08Refine some placesКоренберг Марк (ноутбук дома)
No real logick change
2012-06-08pylint's first review and trivial fixesКоренберг Марк (ноутбук дома)
2012-06-08Using only single quotes now and multi-line listsКоренберг Марк (ноутбук дома)
Nothing algorithmic changed really, just cosmetics
2012-06-08Fix indentation (spaces vs tabs)Коренберг Марк (ноутбук дома)
Now, python files use pseudo-tab equal 4 spaces
2012-06-08Code cleanupsКоренберг Марк (ноутбук дома)
1. unused "import struct" removed 2. AddressFamily.__len__ is defined, but why in so way? removed. 3. comparison against instancemethod type fixed
2012-06-08Flags properties description and implementation fixedКоренберг Марк (ноутбук дома)
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.
2012-06-08Fixed various str-related logickКоренберг Марк (ноутбук дома)
2012-06-08Fix whitespaces at EOLКоренберг Марк (ноутбук дома)
Make git happy with that
2012-06-08Introduce Python's absolute_importsКоренберг Марк (ноутбук дома)
Helps greatly when porting to Python 3
2012-06-08Fix typo in still unused function that generate colored messageКоренберг Марк (ноутбук дома)
2012-06-08Make syntax highlighters happyКоренберг Марк (ноутбук дома)
Fix typo in docstring
2012-06-08Removed generated .pyc files from repositoryКоренберг Марк
2012-06-08Fixed address deletionКоренберг Марк (ноутбук дома)
1. rtnl_addr_delete require three arguments 2. comment fixed (fixed copy-past from link.py)
2011-10-26python: Link against nl-3 and nl-route-3Thomas Graf
2011-08-12python: Include python/ in distribution and provide a README on how to build ↵Thomas Graf
& install