Separated IMV session management from IMV policy database
[strongswan.git] / src / libimcv / os_info / os_info.c
1 /*
2 * Copyright (C) 2012-2014 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 #include "os_info.h"
17
18 ENUM(os_type_names, OS_TYPE_UNKNOWN, OS_TYPE_ANDROID,
19 "Unknown",
20 "Debian",
21 "Ubuntu",
22 "Fedora",
23 "Red Hat",
24 "CentOS",
25 "SUSE",
26 "Gentoo",
27 "Android"
28 );
29
30 ENUM(os_fwd_status_names, OS_FWD_DISABLED, OS_FWD_UNKNOWN,
31 "disabled",
32 "enabled",
33 "unknown"
34 );
35
36 ENUM(os_package_state_names, OS_PACKAGE_STATE_UPDATE, OS_PACKAGE_STATE_BLACKLIST,
37 "",
38 " [s]",
39 " [b]"
40 );
41
42 /**
43 * See header
44 */
45 os_type_t os_type_from_name(chunk_t name)
46 {
47 os_type_t type;
48 char *name_str;
49
50 for (type = OS_TYPE_DEBIAN; type < OS_TYPE_ROOF; type++)
51 {
52 /* name_str is a substring of name.ptr */
53 name_str = enum_to_name(os_type_names, type);
54 if (memeq(name.ptr, name_str, min(name.len, strlen(name_str))))
55 {
56 return type;
57 }
58 }
59 return OS_TYPE_UNKNOWN;
60 }