Merge branch 'opaque-ports'
[strongswan.git] / src / libstrongswan / pen / pen.h
1 /*
2 * Copyright (C) 2011-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 pen pen
18 * @ingroup libstrongswan
19 *
20 * @defgroup pent pen
21 * @{ @ingroup pen
22 */
23
24 #ifndef PEN_H_
25 #define PEN_H_
26
27 #include <library.h>
28
29 typedef enum pen_t pen_t;
30 typedef struct pen_type_t pen_type_t;
31
32 /**
33 * Private enterprise numbers allocated by IANA.
34 *
35 * http://www.iana.org/assignments/enterprise-numbers
36 */
37 enum pen_t {
38 PEN_IETF = 0x000000, /* 0 */
39 PEN_IBM = 0x000002, /* 2 */
40 PEN_MICROSOFT = 0x000137, /* 311 */
41 PEN_REDHAT = 0x000908, /* 2312 */
42 PEN_OSC = 0x002358, /* 9048 */
43 PEN_DEBIAN = 0x002572, /* 9586 */
44 PEN_GOOGLE = 0x002B79, /* 11129 */
45 PEN_TCG = 0x005597, /* 21911 */
46 PEN_CANONICAL = 0x007132, /* 28978 */
47 PEN_FEDORA = 0x0076C1, /* 30401 */
48 PEN_FHH = 0x0080ab, /* 32939 */
49 PEN_ITA = 0x00902a, /* 36906 */
50 PEN_OPENPTS = 0x00950e, /* 38158 */
51 PEN_UNASSIGNED = 0xfffffe, /* 16777214 */
52 PEN_RESERVED = 0xffffff, /* 16777215 */
53 };
54
55 /**
56 * Vendor specific type in vendor specific namespace.
57 */
58 struct pen_type_t {
59 pen_t vendor_id;
60 u_int32_t type;
61 };
62
63 /**
64 * Create a pen_type_t struct
65 *
66 * @param vendor_id vendor ID to create a pen_type_t
67 * @param type type to create a pen_type_t
68 * @return created pen_type_t
69 */
70 static inline pen_type_t pen_type_create(pen_t vendor_id, u_int32_t type)
71 {
72 pen_type_t pen_type = { vendor_id, type };
73 return pen_type;
74 }
75
76 /**
77 * Check two pen_type_t for equality.
78 *
79 * @param a first pen_type_t to compare
80 * @param b second pen_type_t to compare
81 * @return TRUE if a == b
82 */
83 static inline bool pen_type_equals(pen_type_t a, pen_type_t b)
84 {
85 return a.vendor_id == b.vendor_id && a.type == b.type;
86 }
87
88 /**
89 * Check if a pen_type_t matches vendor and type.
90 *
91 * @param pen_type pen_type_t to compare
92 * @param vendor_id vendor to check in pen_type
93 * @param type type to check in pen_type
94 * @return TRUE if vendor_id and type matches pen_type
95 */
96 static inline bool pen_type_is(pen_type_t pen_type,
97 pen_t vendor_id, u_int32_t type)
98 {
99 return pen_type.vendor_id == vendor_id && pen_type.type == type;
100 }
101
102 /**
103 * enum names for pen_t.
104 */
105 extern enum_name_t *pen_names;
106
107 #endif /** PEN_H_ @}*/