6946b1ed7deca57f9984e9ccb85e8e6a0906a4a7
[strongswan.git] / src / libimcv / os_info / os_info.h
1 /*
2 * Copyright (C) 2012 Andreas Steffen
3 * HSR Hochschule fuer Technik Rapperswil
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 */
15
16 /**
17 * @defgroup os_info os_info
18 * @{ @ingroup libimcv
19 */
20
21 #ifndef OS_INFO_H_
22 #define OS_INFO_H_
23
24 typedef struct os_info_t os_info_t;
25 typedef enum os_type_t os_type_t;
26 typedef enum os_fwd_status_t os_fwd_status_t;
27
28 #include <library.h>
29
30 #include <time.h>
31
32 enum os_type_t {
33 OS_TYPE_UNKNOWN,
34 OS_TYPE_DEBIAN,
35 OS_TYPE_UBUNTU,
36 OS_TYPE_FEDORA,
37 OS_TYPE_REDHAT,
38 OS_TYPE_CENTOS,
39 OS_TYPE_SUSE,
40 OS_TYPE_GENTOO,
41 OS_TYPE_ANDROID,
42 OS_TYPE_ROOF
43 };
44
45 extern enum_name_t *os_type_names;
46
47 /**
48 * Defines the IPv4 forwarding status
49 */
50 enum os_fwd_status_t {
51 OS_FWD_DISABLED = 0,
52 OS_FWD_ENABLED = 1,
53 OS_FWD_UNKNOWN = 2
54 };
55
56 extern enum_name_t *os_fwd_status_names;
57
58 /**
59 * Interface for the Operating System (OS) information module
60 */
61 struct os_info_t {
62
63 /**
64 * Get the OS type if it can be determined
65 *
66 * @return OS type
67 */
68 os_type_t (*get_type)(os_info_t *this);
69
70 /**
71 * Get the OS product name or distribution
72 *
73 * @return OS name
74 */
75 chunk_t (*get_name)(os_info_t *this);
76
77 /**
78 * Get the numeric OS version or release
79 *
80 * @param major OS major version number
81 * @param minor OS minor version number
82 */
83 void (*get_numeric_version)(os_info_t *this, u_int32_t *major,
84 u_int32_t *minor);
85
86 /**
87 * Get the OS version or release
88 *
89 * @return OS version
90 */
91 chunk_t (*get_version)(os_info_t *this);
92
93 /**
94 * Get the OS IPv4 forwarding status
95 *
96 * @return IP forwarding status
97 */
98 os_fwd_status_t (*get_fwd_status)(os_info_t *this);
99
100 /**
101 * Get the OS uptime in seconds
102 *
103 * @return OS uptime
104 */
105 time_t (*get_uptime)(os_info_t *this);
106
107 /**
108 * Get an OS setting (restricted to /proc, /sys, and /etc)
109 *
110 * @param name name of OS setting
111 * @return value of OS setting
112 */
113 chunk_t (*get_setting)(os_info_t *this, char *name);
114
115 /**
116 * Enumerates over all installed packages
117 *
118 * @return return package enumerator
119 */
120 enumerator_t* (*create_package_enumerator)(os_info_t *this);
121
122 /**
123 * Destroys an os_info_t object.
124 */
125 void (*destroy)(os_info_t *this);
126 };
127
128 /**
129 * Convert an OS name into an OS enumeration type
130 *
131 * @param name OS name
132 * @return OS enumeration type
133 */
134 os_type_t os_type_from_name(chunk_t name);
135
136 /**
137 * Create an os_info_t object
138 */
139 os_info_t* os_info_create(void);
140
141 #endif /** OS_INFO_H_ @}*/