/build/buildd/libnl-1.0~pre6/lib/attr.c

00001 /*
00002  * lib/attr.c           Netlink Attributes
00003  *
00004  *      This library is free software; you can redistribute it and/or
00005  *      modify it under the terms of the GNU Lesser General Public
00006  *      License as published by the Free Software Foundation version 2.1
00007  *      of the License.
00008  *
00009  * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch>
00010  */
00011 
00012 #include <netlink-local.h>
00013 #include <netlink/netlink.h>
00014 #include <netlink/utils.h>
00015 #include <netlink/addr.h>
00016 #include <netlink/attr.h>
00017 #include <netlink/msg.h>
00018 #include <linux/socket.h>
00019 
00020 /**
00021  * @ingroup nl
00022  * @defgroup attr Attributes
00023  * Netlink Attributes Construction/Parsing Interface
00024  * @par 0) Introduction
00025  * Netlink attributes are chained together following each other:
00026  * @code
00027  *    <------- nla_total_size(payload) ------->
00028  *    <---- nla_attr_size(payload) ----->
00029  *   +----------+- - -+- - - - - - - - - +- - -+-------- - -
00030  *   |  Header  | Pad |     Payload      | Pad |  Header
00031  *   +----------+- - -+- - - - - - - - - +- - -+-------- - -
00032  *                     <- nla_len(nla) ->      ^
00033  *   nla_data(nla)----^                        |
00034  *   nla_next(nla)-----------------------------'
00035  * @endcode
00036  *
00037  * @par
00038  * The attribute header and payload must be aligned properly:
00039  * @code
00040  *  <------- NLA_HDRLEN ------> <-- NLA_ALIGN(payload)-->
00041  * +---------------------+- - -+- - - - - - - - - -+- - -+
00042  * |        Header       | Pad |     Payload       | Pad |
00043  * |   (struct nlattr)   | ing |                   | ing |
00044  * +---------------------+- - -+- - - - - - - - - -+- - -+
00045  *  <-------------- nlattr->nla_len -------------->
00046  * @endcode
00047  *
00048  * @par Nested TLVs:
00049  * Nested TLVs are an array of TLVs nested into another TLV. This can be useful
00050  * to allow subsystems to have their own formatting rules without the need to
00051  * make the underlying layer be aware of it. It can also be useful to transfer
00052  * arrays, lists and flattened trees.
00053  * \code
00054  *  <-------------------- NLA_ALIGN(...) ------------------->
00055  * +---------------+- - - - - - - - - - - - - - - - - -+- - -+
00056  * |               |+---------+---------+- - -+-------+|     |
00057  * |  TLV Header   ||  TLV 1  |  TLV 2  |     | TLV n || Pad |
00058  * |               |+---------+---------+- - -+-------+|     |
00059  * +---------------+- - - - - - - - - - - - - - - - - -+- - -+
00060  *                  <--------- nla_data(nla) --------->
00061  * \endcode
00062  *
00063  * @par 1) Constructing a message with attributes
00064  * @code
00065  * int param1 = 10;
00066  * char *param2 = "parameter text";
00067  * struct nlmsghdr hdr = {
00068  *      .nlmsg_type = MY_ACTION,
00069  * };
00070  * struct nl_msg *m = nlmsg_build(&hdr);
00071  * nla_put_u32(m, 1, param1);
00072  * nla_put_string(m, 2, param2);
00073  * 
00074  * nl_send_auto_complete(handle, nl_msg_get(m));
00075  * nlmsg_free(m);
00076  * @endcode
00077  *
00078  * @par 2) Constructing nested attributes
00079  * @code
00080  * struct nl_msg * nested_config(void)
00081  * {
00082  *      int a = 5, int b = 10;
00083  *      struct nl_msg *n = nlmsg_build(NULL);
00084  *      nla_put_u32(n, 10, a);
00085  *      nla_put_u32(n, 20, b);
00086  *      return n;
00087  * }
00088  *
00089  * ...
00090  * struct nl_msg *m = nlmsg_build(&hdr);
00091  * struct nl_msg *nest = nested_config();
00092  * nla_put_nested(m, 1, nest);
00093  *
00094  * nl_send_auto_complete(handle, nl_msg_get(m));
00095  * nlmsg_free(nest);
00096  * nlmsg_free(m);
00097  * @endcode
00098  * @{
00099  */
00100 
00101 /**
00102  * @name Size Calculations
00103  * @{
00104  */
00105 
00106 /**
00107  * length of attribute not including padding
00108  * @arg payload         length of payload
00109  */
00110 int nla_attr_size(int payload)
00111 {
00112         return NLA_HDRLEN + payload;
00113 }
00114 
00115 /**
00116  * total length of attribute including padding
00117  * @arg payload         length of payload
00118  */
00119 int nla_total_size(int payload)
00120 {
00121         return NLA_ALIGN(nla_attr_size(payload));
00122 }
00123 
00124 /**
00125  * length of padding at the tail of the attribute
00126  * @arg payload         length of payload
00127  */
00128 int nla_padlen(int payload)
00129 {
00130         return nla_total_size(payload) - nla_attr_size(payload);
00131 }
00132 
00133 /** @} */
00134 
00135 /**
00136  * @name Payload Access
00137  * @{
00138  */
00139 
00140 /**
00141  * head of payload
00142  * @arg nla             netlink attribute
00143  */
00144 void *nla_data(const struct nlattr *nla)
00145 {
00146         return (char *) nla + NLA_HDRLEN;
00147 }
00148 
00149 /**
00150  * length of payload
00151  * @arg nla             netlink attribute
00152  */
00153 int nla_len(const struct nlattr *nla)
00154 {
00155         return nla->nla_len - NLA_HDRLEN;
00156 }
00157 
00158 /** @} */
00159 
00160 /**
00161  * @name Attribute Parsing
00162  * @{
00163  */
00164 
00165 /**
00166  * check if the netlink attribute fits into the remaining bytes
00167  * @arg nla             netlink attribute
00168  * @arg remaining       number of bytes remaining in attribute stream
00169  */
00170 int nla_ok(const struct nlattr *nla, int remaining)
00171 {
00172         return remaining >= sizeof(*nla) &&
00173                nla->nla_len >= sizeof(*nla) &&
00174                nla->nla_len <= remaining;
00175 }
00176 
00177 /**
00178  * next netlink attribte in attribute stream
00179  * @arg nla             netlink attribute
00180  * @arg remaining       number of bytes remaining in attribute stream
00181  *
00182  * @return the next netlink attribute in the attribute stream and
00183  * decrements remaining by the size of the current attribute.
00184  */
00185 struct nlattr *nla_next(const struct nlattr *nla, int *remaining)
00186 {
00187         int totlen = NLA_ALIGN(nla->nla_len);
00188 
00189         *remaining -= totlen;
00190         return (struct nlattr *) ((char *) nla + totlen);
00191 }
00192 
00193 static uint16_t nla_attr_minlen[NLA_TYPE_MAX+1] = {
00194         [NLA_U8]        = sizeof(uint8_t),
00195         [NLA_U16]       = sizeof(uint16_t),
00196         [NLA_U32]       = sizeof(uint32_t),
00197         [NLA_U64]       = sizeof(uint64_t),
00198         [NLA_STRING]    = 1,
00199         [NLA_NESTED]    = NLA_HDRLEN,
00200 };
00201 
00202 static int validate_nla(struct nlattr *nla, int maxtype,
00203                         struct nla_policy *policy)
00204 {
00205         struct nla_policy *pt;
00206         int minlen = 0;
00207 
00208         if (nla->nla_type <= 0 || nla->nla_type > maxtype)
00209                 return 0;
00210 
00211         pt = &policy[nla->nla_type];
00212 
00213         if (pt->type > NLA_TYPE_MAX)
00214                 BUG();
00215 
00216         if (pt->minlen)
00217                 minlen = pt->minlen;
00218         else if (pt->type != NLA_UNSPEC)
00219                 minlen = nla_attr_minlen[pt->type];
00220 
00221         if (pt->type == NLA_FLAG && nla_len(nla) > 0)
00222                 return -ERANGE;
00223 
00224         if (nla_len(nla) < minlen)
00225                 return -ERANGE;
00226 
00227         if (pt->maxlen && nla_len(nla) > pt->maxlen)
00228                 return -ERANGE;
00229 
00230         if (pt->type == NLA_STRING) {
00231                 char *data = nla_data(nla);
00232                 if (data[nla_len(nla) - 1] != '\0')
00233                         return -EINVAL;
00234         }
00235 
00236         return 0;
00237 }
00238 
00239 
00240 /**
00241  * Parse a stream of attributes into a tb buffer
00242  * @arg tb              destination array with maxtype+1 elements
00243  * @arg maxtype         maximum attribute type to be expected
00244  * @arg head            head of attribute stream
00245  * @arg len             length of attribute stream
00246  * @arg policy          validation policy
00247  *
00248  * Parses a stream of attributes and stores a pointer to each attribute in
00249  * the tb array accessable via the attribute type. Attributes with a type
00250  * exceeding maxtype will be silently ignored for backwards compatibility
00251  * reasons. policy may be set to NULL if no validation is required.
00252  *
00253  * @return 0 on success or a negative error code.
00254  */
00255 int nla_parse(struct nlattr *tb[], int maxtype, struct nlattr *head, int len,
00256               struct nla_policy *policy)
00257 {
00258         struct nlattr *nla;
00259         int rem, err;
00260 
00261         memset(tb, 0, sizeof(struct nlattr *) * (maxtype + 1));
00262 
00263         nla_for_each_attr(nla, head, len, rem) {
00264                 uint16_t type = nla->nla_type;
00265 
00266                 if (type == 0) {
00267                         fprintf(stderr, "Illegal nla->nla_type == 0\n");
00268                         continue;
00269                 }
00270 
00271                 if (type <= maxtype) {
00272                         if (policy) {
00273                                 err = validate_nla(nla, maxtype, policy);
00274                                 if (err < 0)
00275                                         goto errout;
00276                         }
00277 
00278                         tb[type] = nla;
00279                 }
00280         }
00281 
00282         if (rem > 0)
00283                 fprintf(stderr, "netlink: %d bytes leftover after parsing "
00284                        "attributes.\n", rem);
00285 
00286         err = 0;
00287 errout:
00288         return err;
00289 }
00290 
00291 
00292 /**
00293  * parse nested attributes
00294  * @arg tb              destination array with maxtype+1 elements
00295  * @arg maxtype         maximum attribute type to be expected
00296  * @arg nla             attribute containing the nested attributes
00297  * @arg policy          validation policy
00298  *
00299  * @see nla_parse()
00300  */
00301 int nla_parse_nested(struct nlattr *tb[], int maxtype, struct nlattr *nla,
00302                      struct nla_policy *policy)
00303 {
00304         return nla_parse(tb, maxtype, nla_data(nla), nla_len(nla), policy);
00305 }
00306 
00307 /**
00308  * Validate a stream of attributes
00309  * @arg head            head of attribute stream
00310  * @arg len             length of attribute stream
00311  * @arg maxtype         maximum attribute type to be expected
00312  * @arg policy          validation policy
00313  *
00314  * Validates all attributes in the specified attribute stream
00315  * against the specified policy. Attributes with a type exceeding
00316  * maxtype will be ignored. See documenation of struct nla_policy
00317  * for more details.
00318  *
00319  * @return 0 on success or a negative error code.
00320  */
00321 int nla_validate(struct nlattr *head, int len, int maxtype,
00322                  struct nla_policy *policy)
00323 {
00324         struct nlattr *nla;
00325         int rem, err;
00326 
00327         nla_for_each_attr(nla, head, len, rem) {
00328                 err = validate_nla(nla, maxtype, policy);
00329                 if (err < 0)
00330                         goto errout;
00331         }
00332 
00333         err = 0;
00334 errout:
00335         return err;
00336 }
00337 
00338 /**
00339  * Find a specific attribute in a stream of attributes
00340  * @arg head            head of attribute stream
00341  * @arg len             length of attribute stream
00342  * @arg attrtype        type of attribute to look for
00343  *
00344  * @return the first attribute in the stream matching the specified type.
00345  */
00346 struct nlattr *nla_find(struct nlattr *head, int len, int attrtype)
00347 {
00348         struct nlattr *nla;
00349         int rem;
00350 
00351         nla_for_each_attr(nla, head, len, rem)
00352                 if (nla->nla_type == attrtype)
00353                         return nla;
00354 
00355         return NULL;
00356 }
00357 
00358 /** @} */
00359 
00360 /**
00361  * @name Utilities
00362  * @{
00363  */
00364 
00365 /**
00366  * Copy a netlink attribute into another memory area
00367  * @arg dest            where to copy to memcpy
00368  * @arg src             netlink attribute to copy from
00369  * @arg count           size of the destination area
00370  *
00371  * Note: The number of bytes copied is limited by the length of
00372  *       attribute's payload. memcpy
00373  *
00374  * @return the number of bytes copied.
00375  */
00376 int nla_memcpy(void *dest, struct nlattr *src, int count)
00377 {
00378         int minlen;
00379 
00380         if (!src)
00381                 return 0;
00382         
00383         minlen = min_t(int, count, nla_len(src));
00384         memcpy(dest, nla_data(src), minlen);
00385 
00386         return minlen;
00387 }
00388 
00389 /**
00390  * Copy string attribute payload into a sized buffer
00391  * @arg dst             where to copy the string to
00392  * @arg nla             attribute to copy the string from
00393  * @arg dstsize         size of destination buffer
00394  *
00395  * Copies at most dstsize - 1 bytes into the destination buffer.
00396  * The result is always a valid NUL-terminated string. Unlike
00397  * strlcpy the destination buffer is always padded out.
00398  *
00399  * @return the length of the source buffer.
00400  */
00401 size_t nla_strlcpy(char *dst, const struct nlattr *nla, size_t dstsize)
00402 {
00403         size_t srclen = nla_len(nla);
00404         char *src = nla_data(nla);
00405 
00406         if (srclen > 0 && src[srclen - 1] == '\0')
00407                 srclen--;
00408 
00409         if (dstsize > 0) {
00410                 size_t len = (srclen >= dstsize) ? dstsize - 1 : srclen;
00411 
00412                 memset(dst, 0, dstsize);
00413                 memcpy(dst, src, len);
00414         }
00415 
00416         return srclen;
00417 }
00418 
00419 /**
00420  * Compare an attribute with sized memory area
00421  * @arg nla             netlink attribute
00422  * @arg data            memory area
00423  * @arg size            size of memory area
00424  */
00425 int nla_memcmp(const struct nlattr *nla, const void *data,
00426                              size_t size)
00427 {
00428         int d = nla_len(nla) - size;
00429 
00430         if (d == 0)
00431                 d = memcmp(nla_data(nla), data, size);
00432 
00433         return d;
00434 }
00435 
00436 /**
00437  * Compare a string attribute against a string
00438  * @arg nla             netlink string attribute
00439  * @arg str             another string
00440  */
00441 int nla_strcmp(const struct nlattr *nla, const char *str)
00442 {
00443         int len = strlen(str) + 1;
00444         int d = nla_len(nla) - len;
00445 
00446         if (d == 0)
00447                 d = memcmp(nla_data(nla), str, len);
00448 
00449         return d;
00450 }
00451 
00452 /** @} */
00453 
00454 /**
00455  * @name Attribute Construction
00456  * @{
00457  */
00458 
00459 /**
00460  * reserve room for attribute on the skb
00461  * @arg n               netlink message
00462  * @arg attrtype        attribute type
00463  * @arg attrlen         length of attribute payload
00464  *
00465  * Adds a netlink attribute header to a netlink message and reserves
00466  * room for the payload but does not copy it.
00467  */
00468 struct nlattr *nla_reserve(struct nl_msg *n, int attrtype, int attrlen)
00469 {
00470         struct nlattr *nla;
00471         int tlen;
00472         
00473         tlen = NLMSG_ALIGN(n->nm_nlh->nlmsg_len) + nla_total_size(attrlen);
00474 
00475         n->nm_nlh = realloc(n->nm_nlh, tlen);
00476         if (!n->nm_nlh) {
00477                 nl_errno(ENOMEM);
00478                 return NULL;
00479         }
00480 
00481         nla = (struct nlattr *) nlmsg_tail(n->nm_nlh);
00482         nla->nla_type = attrtype;
00483         nla->nla_len = nla_attr_size(attrlen);
00484 
00485         memset((unsigned char *) nla + nla->nla_len, 0, nla_padlen(attrlen));
00486         n->nm_nlh->nlmsg_len = tlen;
00487 
00488         return nla;
00489 }
00490 
00491 /**
00492  * Add a netlink attribute to a netlink message
00493  * @arg n               netlink message
00494  * @arg attrtype        attribute type
00495  * @arg attrlen         length of attribute payload
00496  * @arg data            head of attribute payload
00497  *
00498  * @return -1 if the tailroom of the skb is insufficient to store
00499  * the attribute header and payload.
00500  */
00501 int nla_put(struct nl_msg *n, int attrtype, int attrlen, const void *data)
00502 {
00503         struct nlattr *nla;
00504 
00505         nla = nla_reserve(n, attrtype, attrlen);
00506         if (!nla)
00507                 return nl_errno(ENOMEM);
00508 
00509         memcpy(nla_data(nla), data, attrlen);
00510 
00511         return 0;
00512 }
00513 
00514 /**
00515  * Add a nested netlink attribute to a netlink message
00516  * @arg n               netlink message
00517  * @arg attrtype        attribute type
00518  * @arg nested          netlink attribute to nest
00519  *
00520  * @return -1 if the tailroom of the skb is insufficient to store
00521  * the attribute header and payload.
00522  */
00523 int nla_put_nested(struct nl_msg *n, int attrtype, struct nl_msg *nested)
00524 {
00525         return nla_put(n, attrtype, nlmsg_len(nested->nm_nlh),
00526                        nlmsg_data(nested->nm_nlh));
00527 }
00528 
00529 /**
00530  * Add a u16 netlink attribute to a netlink message
00531  * @arg n               netlink message
00532  * @arg attrtype        attribute type
00533  * @arg value           numeric value
00534  */
00535 int nla_put_u8(struct nl_msg *n, int attrtype, uint8_t value)
00536 {
00537         return nla_put(n, attrtype, sizeof(uint8_t), &value);
00538 }
00539 
00540 /**
00541  * Add a u16 netlink attribute to a netlink message
00542  * @arg n               netlink message
00543  * @arg attrtype        attribute type
00544  * @arg value           numeric value
00545  */
00546 int nla_put_u16(struct nl_msg *n, int attrtype, uint16_t value)
00547 {
00548         return nla_put(n, attrtype, sizeof(uint16_t), &value);
00549 }
00550 
00551 /**
00552  * Add a u32 netlink attribute to a netlink message
00553  * @arg n               netlink message
00554  * @arg attrtype        attribute type
00555  * @arg value           numeric value
00556  */
00557 int nla_put_u32(struct nl_msg *n, int attrtype, uint32_t value)
00558 {
00559         return nla_put(n, attrtype, sizeof(uint32_t), &value);
00560 }
00561 
00562 /**
00563  * Add a u64 netlink attribute to a netlink message
00564  * @arg n               netlink message
00565  * @arg attrtype        attribute type
00566  * @arg value           numeric value
00567  */
00568 int nla_put_u64(struct nl_msg *n, int attrtype, uint64_t value)
00569 {
00570         return nla_put(n, attrtype, sizeof(uint64_t), &value);
00571 }
00572 
00573 /**
00574  * Add a string netlink attribute to a netlink message
00575  * @arg n               netlink message
00576  * @arg attrtype        attribute type
00577  * @arg str             NUL terminated string
00578  */
00579 int nla_put_string(struct nl_msg *n, int attrtype, const char *str)
00580 {
00581         return nla_put(n, attrtype, strlen(str) + 1, str);
00582 }
00583 
00584 /**
00585  * Add a flag netlink attribute to a netlink message
00586  * @arg n               netlink message
00587  * @arg attrtype        attribute type
00588  */
00589 int nla_put_flag(struct nl_msg *n, int attrtype)
00590 {
00591         return nla_put(n, attrtype, 0, NULL);
00592 }
00593 
00594 /**
00595  * Add a msecs netlink attribute to a netlink message
00596  * @arg n               netlink message
00597  * @arg attrtype        attribute type
00598  * @arg msecs           number of msecs
00599  */
00600 int nla_put_msecs(struct nl_msg *n, int attrtype, unsigned long msecs)
00601 {
00602         return nla_put_u64(n, attrtype, msecs);
00603 }
00604 
00605 /**
00606  * Add an abstract data netlink attribute to a netlink message
00607  * @arg n               netlink message
00608  * @arg attrtype        attribute type
00609  * @arg data            abstract data
00610  */
00611 int nla_put_data(struct nl_msg *n, int attrtype, struct nl_data *data)
00612 {
00613         return nla_put(n, attrtype, nl_data_get_size(data),
00614                        nl_data_get(data));
00615 }
00616 
00617 /**
00618  * Add an abstract address netlink attribute to a netlink message
00619  * @arg n               netlink message
00620  * @arg attrtype        attribute type
00621  * @arg addr            abstract address
00622  */
00623 int nla_put_addr(struct nl_msg *n, int attrtype, struct nl_addr *addr)
00624 {
00625         return nla_put(n, attrtype, nl_addr_get_len(addr),
00626                        nl_addr_get_binary_addr(addr));
00627 }
00628 
00629 /** @} */
00630 
00631 /**
00632  * @name Attribute Nesting
00633  * @{
00634  */
00635 
00636 /**
00637  * Start a new level of nested attributes
00638  * @arg n               netlink message
00639  * @arg attrtype        attribute type of container
00640  *
00641  * @return the container attribute
00642  */
00643 struct nlattr *nla_nest_start(struct nl_msg *n, int attrtype)
00644 {
00645         struct nlattr *start = (struct nlattr *) nlmsg_tail(n->nm_nlh);
00646 
00647         if (nla_put(n, attrtype, 0, NULL) < 0)
00648                 return NULL;
00649 
00650         return start;
00651 }
00652 
00653 /**
00654  * Finalize nesting of attributes
00655  * @arg n               netlink message
00656  * @arg start           container attribute
00657  *
00658  * Corrects the container attribute header to include the all
00659  * appeneded attributes.
00660  *
00661  * @return the total data length of the skb.
00662  */
00663 int nla_nest_end(struct nl_msg *n, struct nlattr *start)
00664 {
00665         start->nla_len = (unsigned char *) nlmsg_tail(n->nm_nlh) -
00666                                 (unsigned char *) start;
00667         return 0;
00668 }
00669 
00670 /** @} */
00671 
00672 /**
00673  * @name Attribute Reading
00674  * @{
00675  */
00676 
00677 /**
00678  * Return payload of u32 attribute
00679  * @arg nla             u32 netlink attribute
00680  */
00681 uint32_t nla_get_u32(struct nlattr *nla)
00682 {
00683         return *(uint32_t *) nla_data(nla);
00684 }
00685 
00686 /**
00687  * Return payload of u16 attribute
00688  * @arg nla             u16 netlink attribute
00689  */
00690 uint16_t nla_get_u16(struct nlattr *nla)
00691 {
00692         return *(uint16_t *) nla_data(nla);
00693 }
00694 
00695 /**
00696  * Return payload of u8 attribute
00697  * @arg nla             u8 netlink attribute
00698  */
00699 uint8_t nla_get_u8(struct nlattr *nla)
00700 {
00701         return *(uint8_t *) nla_data(nla);
00702 }
00703 
00704 /**
00705  * Return payload of u64 attribute
00706  * @arg nla             u64 netlink attribute
00707  */
00708 uint64_t nla_get_u64(struct nlattr *nla)
00709 {
00710         uint64_t tmp;
00711 
00712         nla_memcpy(&tmp, nla, sizeof(tmp));
00713 
00714         return tmp;
00715 }
00716 
00717 /**
00718  * Return payload of flag attribute
00719  * @arg nla             flag netlink attribute
00720  */
00721 int nla_get_flag(struct nlattr *nla)
00722 {
00723         return !!nla;
00724 }
00725 
00726 /**
00727  * Return payload of msecs attribute
00728  * @arg nla             msecs netlink attribute
00729  *
00730  * @return the number of milliseconds.
00731  */
00732 unsigned long nla_get_msecs(struct nlattr *nla)
00733 {
00734         return nla_get_u64(nla);
00735 }
00736 
00737 /**
00738  * Return payload of address attribute
00739  * @arg nla             address netlink attribute
00740  * @arg family          address family
00741  *
00742  * @return Newly allocated address handle or NULL
00743  */
00744 struct nl_addr *nla_get_addr(struct nlattr *nla, int family)
00745 {
00746         return nl_addr_build(family, nla_data(nla), nla_len(nla));
00747 }
00748 
00749 /**
00750  * Return payload of abstract data attribute
00751  * @arg nla             abstract data netlink attribute
00752  *
00753  * @return Newly allocated abstract data handle or NULL
00754  */
00755 struct nl_data *nla_get_data(struct nlattr *nla)
00756 {
00757         return nl_data_alloc(nla_data(nla), nla_len(nla));
00758 }
00759 
00760 /** @} */
00761 
00762 /** @} */

Generated on Fri Apr 27 14:14:07 2007 for libnl by  doxygen 1.5.1