6a477ca1ff19ac44a6fe34b86e06e6eaa5d88f41
[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_fwd_status_t os_fwd_status_t;
26
27 #include <library.h>
28
29 #include <time.h>
30
31 /**
32 * Defines the IPv4 forwarding status
33 */
34 enum os_fwd_status_t {
35 OS_FWD_DISABLED = 0,
36 OS_FWD_ENABLED = 1,
37 OS_FWD_UNKNOWN = 2
38 };
39
40 extern enum_name_t *os_fwd_status_names;
41
42 /**
43 * Interface for the Operating System (OS) information module
44 */
45 struct os_info_t {
46
47 /**
48 * Get the OS product name or distribution
49 *
50 * @return OS name
51 */
52 chunk_t (*get_name)(os_info_t *this);
53
54 /**
55 * Get the numeric OS version or release
56 *
57 * @param major OS major version number
58 * @param minor OS minor version number
59 */
60 void (*get_numeric_version)(os_info_t *this, u_int32_t *major,
61 u_int32_t *minor);
62
63 /**
64 * Get the OS version or release
65 *
66 * @return OS version
67 */
68 chunk_t (*get_version)(os_info_t *this);
69
70 /**
71 * Get the OS IPv4 forwarding status
72 *
73 * @return IP forwarding status
74 */
75 os_fwd_status_t (*get_fwd_status)(os_info_t *this);
76
77 /**
78 * Get the OS uptime in seconds
79 *
80 * @return OS uptime
81 */
82 time_t (*get_uptime)(os_info_t *this);
83
84 /**
85 * Get an OS setting (restricted to /proc, /sys, and /etc)
86 *
87 * @param name name of OS setting
88 * @return value of OS setting
89 */
90 chunk_t (*get_setting)(os_info_t *this, char *name);
91
92 /**
93 * Enumerates over all installed packages
94 *
95 * @return return package enumerator
96 */
97 enumerator_t* (*create_package_enumerator)(os_info_t *this);
98
99 /**
100 * Destroys an os_info_t object.
101 */
102 void (*destroy)(os_info_t *this);
103 };
104
105 /**
106 * Create an os_info_t object
107 */
108 os_info_t* os_info_create(void);
109
110 #endif /** OS_INFO_H_ @}*/