summaryrefslogtreecommitdiffstats
path: root/lib/attr.c
Commit message (Collapse)AuthorAgeFilesLines
* The commit 6a8d90f5fec4 "attr: Allow attribute type 0" intended toSamuel Gauthier2013-11-291-4/+0
| | | | | | | | | | | allow the parsing of {netlink,packet,unix}_diag, even if they are using type 0 for valid attributes. It lacked this part in nla_parse. Cc: Nicolas Dichtel <nicolas.dichtel@6wind.com> Signed-off-by: Samuel Gauthier <samuel.gauthier@6wind.com> Signed-off-by: Thomas Graf <tgraf@suug.ch>
* attr: Allow attribute type 0Thomas Graf2013-11-281-1/+1
| | | | | | | | | | | | {netlink,packet,unix}_diag use attribute type 0 for valid attributes. The value was reserved and usage was prohibited by the protocol but we can't undo the breakge. Make libnl accept attribute type 0 to allow parsing these attributes. Reported-by: Nicolas Dichtel <nicolas.dichtel@6wind.com> Signed-off-by: Thomas Graf <tgraf@suug.ch>
* Wrong calcultation in nla_reserveEmmanuel Thierry2013-04-281-1/+1
| | | | | | | There seams to be an error in the calculation of needed space for the message in nla_reserve. The current size of the message is counted twice: Once in NLMSG_ALIGN, once in the condition below. This causes nla_put_* calls to be rejected if the allocation size of the message has been strictly calculated by the caller. Signed-off-by: Thomas Graf <tgraf@suug.ch>
* attr: Fix typo in nla_is_nested()Thomas Graf2013-04-281-1/+1
| | | | Signed-off-by: Thomas Graf <tgraf@suug.ch>
* attr: nla_is_nested() must access nla_type directlyThomas Graf2013-04-281-1/+1
| | | | | | Can't used nla_type() as it applies NLA_TYPE_MASK first Signed-off-by: Thomas Graf <tgraf@suug.ch>
* attr: Warn application if nla_parse() observes same attribute multiple timesThomas Graf2013-03-141-8/+13
| | | | | | | | Use a debugging message to warn applications if an attribute is found multiple times in the same message. It is perfectly valid to rely on this behaviour but it is likely to indicate a bug. Signed-off-by: Thomas Graf <tgraf@suug.ch>
* attr: No longer warn about attribute of type 0Thomas Graf2013-03-141-3/+2
| | | | | | The kernel will start using type 0 attributes for padding purposes. Signed-off-by: Thomas Graf <tgraf@suug.ch>
* attr: Do not enforce maximum length for NLA_FLAG attributesThomas Graf2013-03-141-3/+1
| | | | | | | Although wasteful, NLA_FLAG with non zero payload cause no harm and should thus not be rejected. Signed-off-by: Thomas Graf <tgraf@suug.ch>
* attr: Add nla_nest_cancel() to remove partially added nested attributesThomas Graf2013-03-141-2/+23
| | | | Signed-off-by: Thomas Graf <tgraf@suug.ch>
* attr: Provide nla_is_nested() functionThomas Graf2013-02-051-1/+12
| | | | Signed-off-by: Thomas Graf <tgraf@suug.ch>
* Move private header files to <netlink-private/*>Thomas Graf2013-01-241-1/+1
| | | | | | | This clarifies the seperation between public and private header files. Signed-off-by: Thomas Graf <tgraf@suug.ch>
* Use NL_DBG() instead of printing warnings and errors to stderrThomas Graf2012-11-151-2/+2
| | | | Signed-off-by: Thomas Graf <tgraf@suug.ch>
* Fix types-related warnings based on clang diagnosticsКоренберг Марк2012-06-131-1/+2
| | | | | | | | | | | | | | | | | 1. Fix some places where unsigned value compared < 0 2. Fix obsolete %Z specifier to more portable %z 3. Some erroneous types substitution 4. nl_msec2str() - 64-bit msec is now properly used, Only safe changes. I mean int <--> uint32_t and signed/unsigned fixes. Some functinos require size_t argument instead of int, but changes of signatures of that functions is terrible thing. Also, I do not pretend for a full list of fixes. Just to shut up clang -Wall -Wextra One more thing. ifindex. I don't change that because changes will be too big for simple fix.
* doc: documentation restructuringThomas Graf2012-05-101-350/+9
| | | | | | | | | | - changes the modules hierarchy to better represent the set of libaries - list the header file that needs to be included - remove examples/doc from api ref that is included in the guide - add references to the guide - fix doxygen api linking for version 1.8.0 - readd doxygen mainpage to config file - fix a couple of doxygen doc bugs
* Omit empty nested attributesThomas Graf2011-03-231-3/+15
| | | | | Check for empty nested attributes in nla_nest_end() and omit the attribute alltogether if is is the case.
* nl: rename nlmsg_msg_size() to nlmsg_size(), nlmsg_len() -> nlmsg_datalen()Thomas Graf2010-11-221-1/+1
| | | | The old symbols are left around for compatibility.
* attr: Add padding if nested data does not end at an alignment boundryThomas Graf2010-10-291-0/+17
| | | | | This could happen if a user put an unaligned amount of data inside an attribute with nlmsg_append().
* Improved debugging messages while constructing messages/attributesThomas Graf2010-10-291-5/+17
|
* Avoid memcpy()/memset() when reserving space for nested attributesThomas Graf2010-10-281-4/+7
|
* Introduce nla_strdup() to help parse strings attributesThomas Graf2008-06-131-0/+5
|
* Remove obsolete nla_get_addr() and nla_get_data()Thomas Graf2008-05-141-12/+0
| | | | | | | | Replaces obsolete calls to nla_get_addr() and nla_get_data() with nl_addr_alloc_attr() respectively nl_data_alloc_attr(). Also fixes missing error handling while parsing routing multipath configuration.
* Thread-safe error handlingThomas Graf2008-05-141-9/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In order for the interface to become more thread safe, the error handling was revised to no longer depend on a static errno and error string buffer. This patch converts all error paths to return a libnl specific error code which can be translated to a error message using nl_geterror(int error). The functions nl_error() and nl_get_errno() are therefore obsolete. This change required various sets of function prototypes to be changed in order to return an error code, the most prominent are: struct nl_cache *foo_alloc_cache(...); changed to: int foo_alloc_cache(..., struct nl_cache **); struct nl_msg *foo_build_request(...); changed to: int foo_build_request(..., struct nl_msg **); struct foo *foo_parse(...); changed to: int foo_parse(..., struct foo **); This pretty much only leaves trivial allocation functions to still return a pointer object which can still return NULL to signal out of memory. This change is a serious API and ABI breaker, sorry!
* Be liberal when receiving an empty nested attributeThomas Graf2008-02-221-1/+0
| | | | | | No longer enforce at least one attribute in a container of nested attributes. The application may do so itself by setting minlen to NLA_HDRLEN.
* Detailed attribute documentationThomas Graf2008-01-301-310/+705
| | | | | This patch extends and reorganizes the existing attribute documentation and includes various verbose examples.
* Improve message/attribute construction documentation and add nlmsg_expand()Thomas Graf2008-01-141-10/+8
|
* Fix stale data pointers when constructing messagesThomas Graf2008-01-141-3/+2
| | | | | | | | | | | | | | | | Patrick McHardy reported a problem where pointers to the payload of a netlink message as returned by f.e. the nesting helpers become stale when the payload data chunk is reallocated. In order to avoid further problems, the payload chunk is no longer extended on the fly. Instead the allocation is made during netlink message object allocation time with a default size of a page which should be fine for the majority of all users. Additionally the functions nlmsg_alloc_size() and nlmsg_set_default_size() have been added to allocate messages of a particular length and to modify the default message size.
* [LIBNL]: Fix format stringsPatrick McHardy2007-12-131-2/+2
| | | | | | Use %td for ptrdiff_t and %zu for size_t. Signed-off-by: Patrick McHardy <kaber@trash.net>
* Initial importThomas Graf2007-09-141-0/+787