]>
git.proxmox.com Git - mirror_iproute2.git/blob - lib/mpls_ntop.c
1 /* SPDX-License-Identifier: GPL-2.0 */
6 #include <netinet/in.h>
7 #include <linux/mpls.h>
11 static const char *mpls_ntop1(const struct mpls_label
*addr
, char *buf
, size_t buflen
)
13 size_t destlen
= buflen
;
18 uint32_t entry
= ntohl(addr
[count
++].entry
);
19 uint32_t label
= (entry
& MPLS_LS_LABEL_MASK
) >> MPLS_LS_LABEL_SHIFT
;
20 int len
= snprintf(dest
, destlen
, "%u", label
);
25 /* Is this the end? */
26 if (entry
& MPLS_LS_S_MASK
)
41 const char *mpls_ntop(int af
, const void *addr
, char *buf
, size_t buflen
)
46 return mpls_ntop1((struct mpls_label
*)addr
, buf
, buflen
);