1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2 /* nm-platform.c - Handle runtime kernel networking configuration
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2, or (at your option)
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 * Copyright (C) 2016 Red Hat, Inc.
21 #ifndef __NMP_NETNS_UTILS_H__
22 #define __NMP_NETNS_UTILS_H__
24 /*****************************************************************************/
26 #define NMP_TYPE_NETNS (nmp_netns_get_type ())
27 #define NMP_NETNS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NMP_TYPE_NETNS, NMPNetns))
28 #define NMP_NETNS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NMP_TYPE_NETNS, NMPNetnsClass))
29 #define NMP_IS_NETNS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NMP_TYPE_NETNS))
30 #define NMP_IS_NETNS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NMP_TYPE_NETNS))
31 #define NMP_NETNS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NMP_TYPE_NETNS, NMPNetnsClass))
33 #define NMP_NETNS_FD_NET "fd-net"
34 #define NMP_NETNS_FD_MNT "fd-mnt"
36 struct _NMPNetnsPrivate;
40 struct _NMPNetnsPrivate *priv;
47 GType nmp_netns_get_type (void);
49 NMPNetns *nmp_netns_new (void);
51 gboolean nmp_netns_push (NMPNetns *self);
52 gboolean nmp_netns_push_type (NMPNetns *self, int ns_types);
53 gboolean nmp_netns_pop (NMPNetns *self);
55 NMPNetns *nmp_netns_get_current (void);
56 NMPNetns *nmp_netns_get_initial (void);
57 gboolean nmp_netns_is_initial (void);
59 int nmp_netns_get_fd_net (NMPNetns *self);
60 int nmp_netns_get_fd_mnt (NMPNetns *self);
63 _nm_auto_pop_netns (NMPNetns **p)
69 #define nm_auto_pop_netns __attribute__((cleanup(_nm_auto_pop_netns)))
71 gboolean nmp_netns_bind_to_path (NMPNetns *self, const char *filename, int *out_fd);
72 gboolean nmp_netns_bind_to_path_destroy (NMPNetns *self, const char *filename);
74 #endif /* __NMP_NETNS_UTILS_H__ */