[PATCH libnl 03/11] addr: Add implementations for mpls_ntop and mpls_pton

Thomas Haller thaller at redhat.com
Mon Aug 14 01:42:43 PDT 2017


Hi David,

sorry for the long delay for response.


On Fri, 2017-06-30 at 10:48 -0600, David Ahern wrote:
> Implementations of mpls_ntop and mpls_pton taken from iproute2.
> 
> Signed-off-by: David Ahern <dsahern at gmail.com>
> ---
>  Makefile.am                  |   3 +-
>  include/netlink/route/mpls.h |  15 ++++++
>  lib/mpls.c                   | 108
> +++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 125 insertions(+), 1 deletion(-)
>  create mode 100644 include/netlink/route/mpls.h
>  create mode 100644 lib/mpls.c
> 
> diff --git a/Makefile.am b/Makefile.am
> index 2b817f4a185b..3fd6ba83ad6c 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -323,7 +323,8 @@ lib_libnl_3_la_SOURCES = \
>  	lib/utils.c \
>  	lib/version.c \
>  	lib/hash.c \
> -	lib/hashtable.c
> +	lib/hashtable.c \
> +	lib/mpls.c

from the name of the header file include/netlink/route/mpls.h, it seems
you want this new file be part of libnl-route-3.so sub-package.

either, move the header to be part of the core libnl-3.so package
(include/netlink/mpls.h), or
  - move lib/mpls.c to lib/route/mpls.c
  - link in Makefile with lib_libnl_route_3_la_SOURCES


>  EXTRA_lib_libnl_3_la_DEPENDENCIES = \
>  	libnl-3.sym
>  lib_libnl_3_la_CPPFLAGS = \
> diff --git a/include/netlink/route/mpls.h
> b/include/netlink/route/mpls.h
> new file mode 100644
> index 000000000000..502fd34ad4fb
> --- /dev/null
> +++ b/include/netlink/route/mpls.h
> @@ -0,0 +1,15 @@
> +#ifndef MPLS_H_
> +#define MPLS_H_

Everything from public headers must have a particular libnl3 prefix.
Unfortunately, we are not very consistent about that...

If the new header is in libnl-route-3.so (see above), then the prefix
shall be rtnl_*, otherwise it shall be nl_*.

Regarding the include guard, we usually have NETLINK_*

> +
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
> +
> +extern const char *mpls_ntop(int af, const void *addr, char *buf,
> size_t buflen);
> +extern int mpls_pton(int af, const char *src, void *addr, size_t
> alen);
> +
> +#ifdef __cplusplus
> +}
> +#endif
> +
> +#endif
> diff --git a/lib/mpls.c b/lib/mpls.c
> 


Also, the new symbols must be exported in libnl-3.sym or libnl-route-
3.sym.



best,
Thomas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <http://lists.infradead.org/pipermail/libnl/attachments/20170814/9c9103c4/attachment.sig>


More information about the libnl mailing list