1 <?xml version='1.0'?> <!--*-nxml-*-->
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
6 This file is part of elogind.
8 Copyright 2014 Lennart Poettering
10 elogind 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.
15 elogind 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.
20 You should have received a copy of the GNU Lesser General Public License
21 along with elogind; If not, see <http://www.gnu.org/licenses/>.
24 <refentry id="sd_machine_get_class">
27 <title>sd_machine_get_class</title>
28 <productname>elogind</productname>
32 <contrib>Developer</contrib>
33 <firstname>Lennart</firstname>
34 <surname>Poettering</surname>
35 <email>lennart@poettering.net</email>
41 <refentrytitle>sd_machine_get_class</refentrytitle>
42 <manvolnum>3</manvolnum>
46 <refname>sd_machine_get_class</refname>
47 <refname>sd_machine_get_ifindices</refname>
48 <refpurpose>Determine the class and network interface indices of a
49 locally running virtual machine or container.</refpurpose>
54 <funcsynopsisinfo>#include <elogind/sd-login.h></funcsynopsisinfo>
57 <funcdef>int <function>sd_machine_get_class</function></funcdef>
58 <paramdef>const char* <parameter>machine</parameter></paramdef>
59 <paramdef>char **<parameter>class</parameter></paramdef>
63 <funcdef>int <function>sd_machine_get_ifindices</function></funcdef>
64 <paramdef>const char* <parameter>machine</parameter></paramdef>
65 <paramdef>int **<parameter>ifindices</parameter></paramdef>
71 <title>Description</title>
73 <para><function>sd_machine_get_class()</function> may be used to
74 determine the class of a locally running virtual machine or
75 container that is registered with
76 <citerefentry><refentrytitle>elogind-machined.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
77 The string returned is either <literal>vm</literal> or
78 <literal>container</literal>. The returned string needs to be
79 freed with the libc <citerefentry
80 project='man-pages'><refentrytitle>free</refentrytitle><manvolnum>3</manvolnum></citerefentry>
81 call after use.</para>
83 <para><function>sd_machine_get_ifindices()</function> may be used
84 to determine the numeric indices of the network interfaces on the
85 host that are pointing towards the specified locally running
86 virtual machine or container that is registered with
87 <citerefentry><refentrytitle>elogind-machined.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
88 The returned array needs to be freed with the libc <citerefentry
89 project='man-pages'><refentrytitle>free</refentrytitle><manvolnum>3</manvolnum></citerefentry>
90 call after use.</para>
94 <title>Return Value</title>
96 <para>On success, these calls return 0 or a positive integer. On
97 failure, these calls return a negative errno-style error
102 <title>Errors</title>
104 <para>Returned errors may indicate the following problems:</para>
109 <term><constant>-ENXIO</constant></term>
111 <listitem><para>The specified machine does not exist or is currently not running.</para>
116 <term><constant>-EINVAL</constant></term>
118 <listitem><para>An input parameter was invalid (out of range,
119 or NULL, where that is not accepted).</para></listitem>
123 <term><constant>-ENOMEM</constant></term>
125 <listitem><para>Memory allocation failed.</para></listitem>
133 <para>The <function>sd_machine_get_class()</function> and
134 <function>sd_machine_get_ifindices()</function> interfaces are
135 available as a shared library, which can be compiled and linked to
137 <constant>libelogind</constant> <citerefentry project='die-net'><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry>
142 <title>See Also</title>
145 <citerefentry><refentrytitle>elogind</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
146 <citerefentry><refentrytitle>sd-login</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
147 <citerefentry><refentrytitle>elogind-machined.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
148 <citerefentry><refentrytitle>sd_pid_get_machine_name</refentrytitle><manvolnum>3</manvolnum></citerefentry>