Commit | Line | Data |
---|---|---|
970ed795 | 1 | /////////////////////////////////////////////////////////////////////////////// |
3abe9331 | 2 | // Copyright (c) 2000-2015 Ericsson Telecom AB |
970ed795 EL |
3 | // All rights reserved. This program and the accompanying materials |
4 | // are made available under the terms of the Eclipse Public License v1.0 | |
5 | // which accompanies this distribution, and is available at | |
6 | // http://www.eclipse.org/legal/epl-v10.html | |
7 | /////////////////////////////////////////////////////////////////////////////// | |
8 | #ifndef LICENSE_H | |
9 | #define LICENSE_H | |
10 | ||
11 | #include <time.h> | |
12 | ||
13 | /* Initial features */ | |
14 | #define FEATURE_TTCN3 0x1u | |
15 | #define FEATURE_CODEGEN 0x2u | |
16 | #define FEATURE_TPGEN 0x4u | |
17 | #define FEATURE_SINGLE 0x8u | |
18 | #define FEATURE_MCTR 0x10u | |
19 | #define FEATURE_HC 0x20u | |
20 | #define FEATURE_LOGFORMAT 0x40u | |
21 | /* Added in 1.2.pl0 */ | |
22 | #define FEATURE_ASN1 0x80u | |
23 | #define FEATURE_RAW 0x100u | |
24 | #define FEATURE_BER 0x200u | |
25 | #define FEATURE_PER 0x400u | |
26 | /* Added in 1.5.pl7 */ | |
27 | #define FEATURE_GUI 0x800u // deprecated mctr GUI was removed | |
28 | /* Added in 1.5.pl8 */ | |
29 | #define FEATURE_TEXT 0x1000u | |
30 | /* Added in 1.8.pl0 */ | |
31 | #define FEATURE_XER 0x2000u | |
32 | ||
33 | /* Limitation types */ | |
34 | #define LIMIT_HOST 0x1 | |
35 | #define LIMIT_USER 0x2 | |
36 | ||
37 | /* Limit for expiration warning in days */ | |
38 | #define EXPIRY_WARNING 14 | |
39 | ||
40 | /* Where to send the license. | |
41 | * | |
42 | * The values 1,2,3 work as either an enumeration or a bit field. */ | |
43 | #define SENDTO_LICENSEE 1 | |
44 | #define SENDTO_CONTACT 2 | |
45 | #define SENDTO_BOTH 3 | |
46 | ||
47 | /** "Cooked" license information suitable for processing. */ | |
48 | typedef struct { | |
49 | char *license_file; | |
50 | unsigned int unique_id; | |
51 | char *licensee_name, *licensee_email, | |
52 | *licensee_company, *licensee_department; | |
53 | char *contact_name, *contact_email; | |
54 | unsigned int send_to; | |
55 | time_t valid_from, valid_until; | |
56 | unsigned long int host_id; | |
57 | char *login_name; | |
58 | unsigned int from_major, from_minor, from_patchlevel, | |
59 | to_major, to_minor, to_patchlevel; | |
60 | unsigned int feature_list, limitation_type; | |
61 | unsigned int max_ptcs; | |
62 | } license_struct; | |
63 | ||
64 | /** Raw license information. | |
65 | * | |
66 | * The license file is a Base64-encode of a BER-encoded version of this structure. | |
67 | * | |
68 | * @note Modifying this structure will render it incompatible with | |
69 | * previous versions of Titan (the size of the structure is checked) */ | |
70 | typedef struct { | |
71 | unsigned char unique_id[4]; | |
72 | char licensee_name[48], licensee_email[48], | |
73 | licensee_company[48], licensee_department[16]; | |
74 | unsigned char valid_from[4], valid_until[4]; | |
75 | unsigned char host_id[4]; | |
76 | char login_name[8]; | |
77 | unsigned char from_major[4], from_minor[4], from_patchlevel[4], | |
78 | to_major[4], to_minor[4], to_patchlevel[4]; | |
79 | unsigned char feature_list[4], limitation_type[4]; | |
80 | unsigned char max_ptcs[4]; | |
81 | unsigned char dsa_signature[48]; | |
82 | } license_raw; | |
83 | ||
84 | #ifdef __cplusplus | |
85 | extern "C" { | |
86 | #endif | |
87 | ||
88 | /** Load license information. | |
89 | * | |
90 | * Loads license information from the file specified in the | |
91 | * \c TTCN3_LICENSE_FILE environment variable. | |
92 | * | |
93 | * Calls \c load_license_from_file() | |
94 | * | |
95 | * @param [out] lptr pointer to license data */ | |
96 | void load_license(license_struct *lptr); | |
97 | ||
98 | /** Load license information from a specified file. | |
99 | * @param [out] lptr pointer to license data | |
100 | * @param [in] file_name string containing the license file name */ | |
101 | void load_license_from_file(license_struct *lptr, const char *file_name); | |
102 | ||
103 | /** Free resources | |
104 | * @param [in] lptr pointer to license data */ | |
105 | void free_license(license_struct *lptr); | |
106 | ||
107 | /** Check if the license allows the use of the product. | |
108 | * | |
109 | * Verifies that we are within the license period, that the host or user | |
110 | * restriction is satisfied, and the program version is within the limits | |
111 | * allowed by the license. | |
112 | * | |
113 | * If the license is about to expire in less than \c EXPIRY_WARNING days, | |
114 | * a warning is printed. | |
115 | * | |
116 | * If a check fails, function returns 0. | |
117 | * | |
118 | * @param [in] lptr pointer to license information | |
119 | * @return 1 if the license is valid, 0 if invalid. */ | |
120 | int verify_license(const license_struct *lptr); | |
121 | ||
122 | /** Check if the license allows the use of a certain feature. | |
123 | * | |
124 | * @param lptr pointer to license information | |
125 | * @param feature feature to check. It should be one of the FEATURE_ macros. | |
126 | * @return nonzero if feature is enabled, 0 if disabled. */ | |
127 | unsigned int check_feature(const license_struct *lptr, unsigned int feature); | |
128 | ||
129 | /** Print the details of the supplied license information | |
130 | * | |
131 | * @param [in] lptr pointer to license information */ | |
132 | void print_license(const license_struct *lptr); | |
133 | ||
134 | /** Print information about the license used by the program. | |
135 | * | |
136 | * The license is loaded from the file specified by the \c TTCN3_LICENSE_FILE | |
137 | * environment variable. | |
138 | * | |
139 | * This function terminates the program if the license is not valid. */ | |
140 | void print_license_info(void); | |
141 | ||
142 | void init_openssl(void); | |
143 | void free_openssl(void); | |
144 | ||
145 | const char * openssl_version_str(void); | |
146 | ||
147 | #if defined(WIN32) || defined(INTERIX) | |
148 | long gethostid(void); | |
149 | #endif | |
150 | ||
151 | #ifdef __cplusplus | |
152 | } | |
153 | #endif | |
154 | ||
155 | #endif |