1/* SPDX-License-Identifier: LGPL-2.1-or-later */
2/*
3 * Copyright (C) 2011 - 2014 Red Hat, Inc.
4 */
5
6#ifndef __NM_SETTING_VLAN_H__
7#define __NM_SETTING_VLAN_H__
8
9#if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION)
10#error "Only <NetworkManager.h> can be included directly."
11#endif
12
13#include "nm-setting.h"
14
15G_BEGIN_DECLS
16
17#define NM_TYPE_SETTING_VLAN (nm_setting_vlan_get_type())
18#define NM_SETTING_VLAN(obj) \
19 (G_TYPE_CHECK_INSTANCE_CAST((obj), NM_TYPE_SETTING_VLAN, NMSettingVlan))
20#define NM_SETTING_VLAN_CLASS(klass) \
21 (G_TYPE_CHECK_CLASS_CAST((klass), NM_TYPE_SETTING_VLANCONFIG, NMSettingVlanClass))
22#define NM_IS_SETTING_VLAN(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), NM_TYPE_SETTING_VLAN))
23#define NM_IS_SETTING_VLAN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), NM_TYPE_SETTING_VLAN))
24#define NM_SETTING_VLAN_GET_CLASS(obj) \
25 (G_TYPE_INSTANCE_GET_CLASS((obj), NM_TYPE_SETTING_VLAN, NMSettingVlanClass))
26
27#define NM_SETTING_VLAN_SETTING_NAME "vlan"
28
29#define NM_SETTING_VLAN_PARENT "parent"
30#define NM_SETTING_VLAN_ID "id"
31#define NM_SETTING_VLAN_FLAGS "flags"
32#define NM_SETTING_VLAN_INGRESS_PRIORITY_MAP "ingress-priority-map"
33#define NM_SETTING_VLAN_EGRESS_PRIORITY_MAP "egress-priority-map"
34
35typedef struct _NMSettingVlanClass NMSettingVlanClass;
36
37/**
38 * NMVlanPriorityMap:
39 * @NM_VLAN_INGRESS_MAP: map for incoming data
40 * @NM_VLAN_EGRESS_MAP: map for outgoing data
41 *
42 * A selector for traffic priority maps; these map Linux SKB priorities
43 * to 802.1p priorities used in VLANs.
44 **/
45/* clang-format off */
46typedef enum {
47 NM_VLAN_INGRESS_MAP,
48 NM_VLAN_EGRESS_MAP
49} NMVlanPriorityMap;
50/* clang-format on */
51
52/**
53 * NMVlanFlags:
54 * @NM_VLAN_FLAG_REORDER_HEADERS: indicates that this interface should reorder
55 * outgoing packet headers to look more like a non-VLAN Ethernet interface
56 * @NM_VLAN_FLAG_GVRP: indicates that this interface should use GVRP to register
57 * itself with its switch
58 * @NM_VLAN_FLAG_LOOSE_BINDING: indicates that this interface's operating
59 * state is tied to the underlying network interface but other details
60 * (like routing) are not.
61 * @NM_VLAN_FLAG_MVRP: indicates that this interface should use MVRP to register
62 * itself with its switch
63 *
64 * #NMVlanFlags values control the behavior of the VLAN interface.
65 **/
66typedef enum { /*< flags >*/
67
68 NM_VLAN_FLAG_REORDER_HEADERS = 0x1,
69 NM_VLAN_FLAG_GVRP = 0x2,
70 NM_VLAN_FLAG_LOOSE_BINDING = 0x4,
71 NM_VLAN_FLAG_MVRP = 0x8,
72
73 /* NOTE: if adding flags update nm-setting-vlan.c::verify() */
74
75 /* NOTE: these flags must correspond to the value from the kernel
76 * header files. */
77} NMVlanFlags;
78
79#define NM_VLAN_FLAGS_ALL \
80 (NM_VLAN_FLAG_REORDER_HEADERS | NM_VLAN_FLAG_GVRP | NM_VLAN_FLAG_LOOSE_BINDING \
81 | NM_VLAN_FLAG_MVRP)
82
83GType nm_setting_vlan_get_type(void);
84NMSetting *nm_setting_vlan_new(void);
85
86const char *nm_setting_vlan_get_parent(NMSettingVlan *setting);
87guint32 nm_setting_vlan_get_id(NMSettingVlan *setting);
88guint32 nm_setting_vlan_get_flags(NMSettingVlan *setting);
89
90gint32 nm_setting_vlan_get_num_priorities(NMSettingVlan *setting, NMVlanPriorityMap map);
91
92gboolean nm_setting_vlan_get_priority(NMSettingVlan *setting,
93 NMVlanPriorityMap map,
94 guint32 idx,
95 guint32 *out_from,
96 guint32 *out_to);
97
98gboolean nm_setting_vlan_add_priority(NMSettingVlan *setting,
99 NMVlanPriorityMap map,
100 guint32 from,
101 guint32 to);
102
103void nm_setting_vlan_remove_priority(NMSettingVlan *setting, NMVlanPriorityMap map, guint32 idx);
104
105gboolean nm_setting_vlan_remove_priority_by_value(NMSettingVlan *setting,
106 NMVlanPriorityMap map,
107 guint32 from,
108 guint32 to);
109
110gboolean nm_setting_vlan_remove_priority_str_by_value(NMSettingVlan *setting,
111 NMVlanPriorityMap map,
112 const char *str);
113
114void nm_setting_vlan_clear_priorities(NMSettingVlan *setting, NMVlanPriorityMap map);
115
116gboolean
117nm_setting_vlan_add_priority_str(NMSettingVlan *setting, NMVlanPriorityMap map, const char *str);
118
119G_END_DECLS
120
121#endif /* __NM_SETTING_VLAN_H__ */
122

source code of include/libnm/nm-setting-vlan.h