about summary refs log tree commit diff
path: root/src/libnm-base/nm-net-aux.h
blob: 6c6b7a7467b9fc20e7627914cb2311715fa99db0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/* SPDX-License-Identifier: LGPL-2.1-or-later */

#ifndef __NM_NET_AUX_H__
#define __NM_NET_AUX_H__

const char *nm_net_aux_rtnl_rtntype_n2a(guint8 v);
int         nm_net_aux_rtnl_rtntype_a2n(const char *name);

#define nm_net_aux_rtnl_rtntype_n2a_maybe_buf(v, buf)                      \
    ({                                                                     \
        const guint8 _v = (v);                                             \
                                                                           \
        /* Warning: this will only touch/initialize @buf if necessary.
         * That means, don't assume that @buf was initialized after calling
         * this macro. */     \
        nm_net_aux_rtnl_rtntype_n2a(v) ?: nm_sprintf_buf((buf), "%u", _v); \
    })

/*****************************************************************************/

#endif /* __NM_NET_AUX_H__ */