chiark / gitweb /
758ffad1b742222179fa0afc4937053feba779b6
[elogind.git] / src / libsystemd / sd-netlink / netlink-types.h
1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2
3 #pragma once
4
5 /***
6   This file is part of systemd.
7
8   Copyright 2014 Tom Gundersen <teg@jklm.no>
9
10   systemd is free software; you can redistribute it and/or modify it
11   under the terms of the GNU Lesser General Public License as published by
12   the Free Software Foundation; either version 2.1 of the License, or
13   (at your option) any later version.
14
15   systemd is distributed in the hope that it will be useful, but
16   WITHOUT ANY WARRANTY; without even the implied warranty of
17   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18   Lesser General Public License for more details.
19
20   You should have received a copy of the GNU Lesser General Public License
21   along with systemd; If not, see <http://www.gnu.org/licenses/>.
22 ***/
23
24 enum {
25         NETLINK_TYPE_UNSPEC,
26         NETLINK_TYPE_U8,                        /* NLA_U8 */
27         NETLINK_TYPE_U16,                       /* NLA_U16 */
28         NETLINK_TYPE_U32,                       /* NLA_U32 */
29         NETLINK_TYPE_U64,                       /* NLA_U64 */
30         NETLINK_TYPE_STRING,                    /* NLA_STRING */
31         NETLINK_TYPE_IN_ADDR,
32         NETLINK_TYPE_ETHER_ADDR,
33         NETLINK_TYPE_CACHE_INFO,
34         NETLINK_TYPE_NESTED,                    /* NLA_NESTED */
35         NETLINK_TYPE_UNION,
36 };
37
38 typedef enum NLMatchType {
39         NL_MATCH_SIBLING,
40         NL_MATCH_PROTOCOL,
41 } NLMatchType;
42
43 typedef struct NLTypeSystemUnion NLTypeSystemUnion;
44 typedef struct NLTypeSystem NLTypeSystem;
45 typedef struct NLType NLType;
46
47 struct NLTypeSystemUnion {
48         int num;
49         NLMatchType match_type;
50         uint16_t match;
51         int (*lookup)(const char *);
52         const NLTypeSystem *type_systems;
53 };
54
55 extern const NLTypeSystem type_system_root;
56
57 uint16_t type_get_type(const NLType *type);
58 size_t type_get_size(const NLType *type);
59 void type_get_type_system(const NLType *type, const NLTypeSystem **ret);
60 void type_get_type_system_union(const NLType *type, const NLTypeSystemUnion **ret);
61
62 uint16_t type_system_get_count(const NLTypeSystem *type_system);
63 int type_system_get_type(const NLTypeSystem *type_system, const NLType **ret, uint16_t type);
64 int type_system_get_type_system(const NLTypeSystem *type_system, const NLTypeSystem **ret, uint16_t type);
65 int type_system_get_type_system_union(const NLTypeSystem *type_system, const NLTypeSystemUnion **ret, uint16_t type);
66 int type_system_union_get_type_system(const NLTypeSystemUnion *type_system_union, const NLTypeSystem **ret, const char *key);
67 int type_system_union_protocol_get_type_system(const NLTypeSystemUnion *type_system_union, const NLTypeSystem **ret, uint16_t protocol);
68
69 typedef enum NLUnionLinkInfoData {
70         NL_UNION_LINK_INFO_DATA_BOND,
71         NL_UNION_LINK_INFO_DATA_BRIDGE,
72         NL_UNION_LINK_INFO_DATA_VLAN,
73         NL_UNION_LINK_INFO_DATA_VETH,
74         NL_UNION_LINK_INFO_DATA_DUMMY,
75         NL_UNION_LINK_INFO_DATA_MACVLAN,
76         NL_UNION_LINK_INFO_DATA_MACVTAP,
77         NL_UNION_LINK_INFO_DATA_IPVLAN,
78         NL_UNION_LINK_INFO_DATA_VXLAN,
79         NL_UNION_LINK_INFO_DATA_IPIP_TUNNEL,
80         NL_UNION_LINK_INFO_DATA_IPGRE_TUNNEL,
81         NL_UNION_LINK_INFO_DATA_IPGRETAP_TUNNEL,
82         NL_UNION_LINK_INFO_DATA_IP6GRE_TUNNEL,
83         NL_UNION_LINK_INFO_DATA_IP6GRETAP_TUNNEL,
84         NL_UNION_LINK_INFO_DATA_SIT_TUNNEL,
85         NL_UNION_LINK_INFO_DATA_VTI_TUNNEL,
86         NL_UNION_LINK_INFO_DATA_VTI6_TUNNEL,
87         NL_UNION_LINK_INFO_DATA_IP6TNL_TUNNEL,
88         _NL_UNION_LINK_INFO_DATA_MAX,
89         _NL_UNION_LINK_INFO_DATA_INVALID = -1
90 } NLUnionLinkInfoData;
91
92 const char *nl_union_link_info_data_to_string(NLUnionLinkInfoData p) _const_;
93 NLUnionLinkInfoData nl_union_link_info_data_from_string(const char *p) _pure_;