libsmbios_c library
token.h
Go to the documentation of this file.
1 // vim:expandtab:autoindent:tabstop=4:shiftwidth=4:filetype=c:
2 /*
3  * Copyright (C) 2005 Dell Inc.
4  * by Michael Brown <Michael_E_Brown@dell.com>
5  * Licensed under the Open Software License version 2.1
6  *
7  * Alternatively, you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published
9  * by the Free Software Foundation; either version 2 of the License,
10  * or (at your option) any later version.
11 
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15  * See the GNU General Public License for more details.
16  */
17 
18 
19 #ifndef C_OBJ_TOKEN_H
20 #define C_OBJ_TOKEN_H
21 
22 // include smbios_c/compat.h first
23 #include "smbios_c/compat.h"
24 #include "smbios_c/types.h"
25 
26 // abi_prefix should be last header included before declarations
28 
30 
31 #define TOKEN_DEFAULTS 0x0000
32 #define TOKEN_GET_SINGLETON 0x0001
33 #define TOKEN_GET_NEW 0x0002
34 #define TOKEN_UNIT_TEST_MODE 0x0004
35 #define TOKEN_NO_ERR_CLEAR 0x0008
36 
37 struct token_table;
38 struct token_obj;
39 
40 // construct
41 LIBSMBIOS_C_DLL_SPEC struct token_table *token_table_factory(int flags, ...);
42 
43 // destruct
44 LIBSMBIOS_C_DLL_SPEC void token_table_free(struct token_table *);
45 
46 // format error string
47 LIBSMBIOS_C_DLL_SPEC const char *token_table_strerror(const struct token_table *);
48 LIBSMBIOS_C_DLL_SPEC const char *token_obj_strerror(const struct token_obj *);
49 
50 // for looping/searching
51 LIBSMBIOS_C_DLL_SPEC const struct token_obj *token_table_get_next(const struct token_table *, const struct token_obj *cur);
52 LIBSMBIOS_C_DLL_SPEC const struct token_obj *token_table_get_next_by_id(const struct token_table *, const struct token_obj *cur, u16 id);
53 
54 LIBSMBIOS_C_DLL_SPEC u16 token_obj_get_id(const struct token_obj *);
55 
56 #define token_table_for_each(table_name, struct_name) \
57  for( \
58  const struct token_obj *struct_name = token_table_get_next(table_name, 0);\
59  struct_name;\
60  struct_name = token_table_get_next(table_name, struct_name)\
61  )
62 
63 #define token_table_for_each_id(table_name, struct_name, id) \
64  for( \
65  const struct token_obj *struct_name = token_table_get_next_id(table_name, 0, id);\
66  struct_name;\
67  struct_name = token_table_get_next_id(table_name, struct_name, id)\
68  )
69 
70 LIBSMBIOS_C_DLL_SPEC int token_obj_get_type(const struct token_obj *);
71 LIBSMBIOS_C_DLL_SPEC bool token_obj_is_bool(const struct token_obj *);
72 LIBSMBIOS_C_DLL_SPEC int token_obj_is_active(const struct token_obj *); // return 0,1 or negative error
73 LIBSMBIOS_C_DLL_SPEC int token_obj_activate(const struct token_obj *); // return error
74 
75 LIBSMBIOS_C_DLL_SPEC bool token_obj_is_string(const struct token_obj *);
76 LIBSMBIOS_C_DLL_SPEC char* token_obj_get_string(const struct token_obj *, size_t *len); // return 0 on error
77 LIBSMBIOS_C_DLL_SPEC int token_obj_set_string(const struct token_obj *, const char *, size_t size); // return error
78 
79 LIBSMBIOS_C_DLL_SPEC const struct smbios_struct *token_obj_get_smbios_struct(const struct token_obj *);
80 LIBSMBIOS_C_DLL_SPEC int token_obj_try_password(const struct token_obj *, const char *pass_ascii, const char *pass_scancode);
81 LIBSMBIOS_C_DLL_SPEC const void *token_obj_get_ptr(const struct token_obj *t);
82 
83 #if defined(_MSC_VER)
84 #pragma pack(push,1)
85 #endif
87 {
91  union {
94  };
95 }
97 
99 { /* 0xD4 structure */
109  //variable number of tokens present, but at least one.
110  struct indexed_io_token tokens[];
111 }
113 
115 { /* 0xD5 structure */
128 }
130 
132 { /* 0xD6 structure */
149 }
151 #if defined(_MSC_VER)
152 #pragma pack(pop)
153 #endif
154 
155 enum
156 {
157  CHECK_TYPE_WORD_CHECKSUM = 0x00, //simple running sum in word
158  CHECK_TYPE_BYTE_CHECKSUM = 0x01, //simple running sum in byte
159  CHECK_TYPE_WORD_CRC = 0x02, // crc
160  CHECK_TYPE_WORD_CHECKSUM_N = 0x03, //simple runnign sum in word, then (~result + 1)
161 };
162 
164 
165 // always should be last thing in header file
167 
168 #endif /* TOKEN_H */
indexed_io_access_structure::checkedRangeStartIndex
u8 checkedRangeStartIndex
Definition: token.h:106
dell_protected_value_1_structure::checkIndex
u8 checkIndex
Definition: token.h:127
dell_protected_value_2_structure::handle
u16 handle
Definition: token.h:135
EXTERN_C_BEGIN
#define EXTERN_C_BEGIN
Definition: compat.h:55
abi_prefix.h
token_obj_set_string
LIBSMBIOS_C_DLL_SPEC int token_obj_set_string(const struct token_obj *, const char *, size_t size)
dell_protected_value_1_structure::dataPort
u16 dataPort
Definition: token.h:124
token_obj_strerror
LIBSMBIOS_C_DLL_SPEC const char * token_obj_strerror(const struct token_obj *)
types.h
dell_protected_value_1_structure::indexPort
u16 indexPort
Definition: token.h:123
dell_protected_value_2_structure::valueLen
u8 valueLen
Definition: token.h:137
token_obj_is_active
LIBSMBIOS_C_DLL_SPEC int token_obj_is_active(const struct token_obj *)
token_table_get_next
LIBSMBIOS_C_DLL_SPEC const struct token_obj * token_table_get_next(const struct token_table *, const struct token_obj *cur)
dell_protected_value_2_structure::valueStartIndex
u8 valueStartIndex
Definition: token.h:143
indexed_io_access_structure::length
u8 length
Definition: token.h:101
indexed_io_access_structure::type
u8 type
Definition: token.h:100
dell_protected_value_2_structure::rangeCheckEnd
u8 rangeCheckEnd
Definition: token.h:147
token_obj_get_type
LIBSMBIOS_C_DLL_SPEC int token_obj_get_type(const struct token_obj *)
indexed_io_access_structure::checkType
u8 checkType
Definition: token.h:105
EXTERN_C_END
#define EXTERN_C_END
Definition: compat.h:56
dell_protected_value_2_structure::length
u8 length
Definition: token.h:134
token_table_strerror
LIBSMBIOS_C_DLL_SPEC const char * token_table_strerror(const struct token_table *)
dell_protected_value_2_structure::validationKey
u16 validationKey
Definition: token.h:139
dell_protected_value_1_structure
Definition: token.h:115
CHECK_TYPE_WORD_CHECKSUM_N
@ CHECK_TYPE_WORD_CHECKSUM_N
Definition: token.h:160
LIBSMBIOS_C_DLL_SPEC
#define LIBSMBIOS_C_DLL_SPEC
Definition: compat.h:48
token_obj_try_password
LIBSMBIOS_C_DLL_SPEC int token_obj_try_password(const struct token_obj *, const char *pass_ascii, const char *pass_scancode)
indexed_io_token::andMask
u8 andMask
Definition: token.h:90
indexed_io_access_structure::checkValueIndex
u8 checkValueIndex
Definition: token.h:108
indexed_io_token::orValue
u8 orValue
Definition: token.h:92
dell_protected_value_2_structure::checkType
u8 checkType
Definition: token.h:142
dell_protected_value_1_structure::validationKey
u16 validationKey
Definition: token.h:122
indexed_io_access_structure::dataPort
u16 dataPort
Definition: token.h:104
indexed_io_token::tokenId
u16 tokenId
Definition: token.h:88
dell_protected_value_1_structure::length
u8 length
Definition: token.h:117
compat.h
indexed_io_access_structure::tokens
struct indexed_io_token tokens[]
Definition: token.h:110
CHECK_TYPE_WORD_CHECKSUM
@ CHECK_TYPE_WORD_CHECKSUM
Definition: token.h:157
u16
unsigned short u16
Definition: types.h:33
dell_protected_value_2_structure::rangeCheckIndex
u8 rangeCheckIndex
Definition: token.h:148
CHECK_TYPE_BYTE_CHECKSUM
@ CHECK_TYPE_BYTE_CHECKSUM
Definition: token.h:158
token_obj_get_string
LIBSMBIOS_C_DLL_SPEC char * token_obj_get_string(const struct token_obj *, size_t *len)
token_table_free
LIBSMBIOS_C_DLL_SPEC void token_table_free(struct token_table *)
dell_protected_value_2_structure::rangeCheckStart
u8 rangeCheckStart
Definition: token.h:146
token_obj_get_smbios_struct
LIBSMBIOS_C_DLL_SPEC const struct smbios_struct * token_obj_get_smbios_struct(const struct token_obj *)
dell_protected_value_1_structure::handle
u16 handle
Definition: token.h:118
dell_protected_value_2_structure::tokenId
u16 tokenId
Definition: token.h:136
dell_protected_value_2_structure::indexPort
u16 indexPort
Definition: token.h:140
dell_protected_value_2_structure::type
u8 type
Definition: token.h:133
indexed_io_token
Definition: token.h:87
token_obj_activate
LIBSMBIOS_C_DLL_SPEC int token_obj_activate(const struct token_obj *)
indexed_io_access_structure::indexPort
u16 indexPort
Definition: token.h:103
dell_protected_value_1_structure::tokenId
u16 tokenId
Definition: token.h:119
dell_protected_value_1_structure::checkType
u8 checkType
Definition: token.h:125
indexed_io_access_structure
Definition: token.h:99
indexed_io_token::stringLength
u8 stringLength
Definition: token.h:93
token_obj_is_bool
LIBSMBIOS_C_DLL_SPEC bool token_obj_is_bool(const struct token_obj *)
abi_suffix.h
dell_protected_value_2_structure::valueFormat
u8 valueFormat
Definition: token.h:138
dell_protected_value_2_structure::dataPort
u16 dataPort
Definition: token.h:141
dell_protected_value_2_structure::checkIndex
u8 checkIndex
Definition: token.h:144
indexed_io_token::location
u8 location
Definition: token.h:89
dell_protected_value_1_structure::valueLen
u8 valueLen
Definition: token.h:120
indexed_io_access_structure::checkedRangeEndIndex
u8 checkedRangeEndIndex
Definition: token.h:107
CHECK_TYPE_WORD_CRC
@ CHECK_TYPE_WORD_CRC
Definition: token.h:159
u8
unsigned char u8
Definition: types.h:29
token_table_get_next_by_id
LIBSMBIOS_C_DLL_SPEC const struct token_obj * token_table_get_next_by_id(const struct token_table *, const struct token_obj *cur, u16 id)
token_table_factory
LIBSMBIOS_C_DLL_SPEC struct token_table * token_table_factory(int flags,...)
dell_protected_value_1_structure::type
u8 type
Definition: token.h:116
LIBSMBIOS_C_PACKED_ATTR
struct indexed_io_token LIBSMBIOS_C_PACKED_ATTR
dell_protected_value_2_structure::rangeCheckType
u8 rangeCheckType
Definition: token.h:145
token_obj_get_ptr
LIBSMBIOS_C_DLL_SPEC const void * token_obj_get_ptr(const struct token_obj *t)
dell_protected_value_2_structure
Definition: token.h:132
indexed_io_access_structure::handle
u16 handle
Definition: token.h:102
token_obj_get_id
LIBSMBIOS_C_DLL_SPEC u16 token_obj_get_id(const struct token_obj *)
dell_protected_value_1_structure::valueFormat
u8 valueFormat
Definition: token.h:121
dell_protected_value_1_structure::valueStartIndex
u8 valueStartIndex
Definition: token.h:126
token_obj_is_string
LIBSMBIOS_C_DLL_SPEC bool token_obj_is_string(const struct token_obj *)