aboutsummaryrefslogtreecommitdiffstats
path: root/octdev_types.h
blob: 9c2397ac6208d24aa636fae3f267dfa21b9984c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\

File: OCTDEV_TYPES.h

Copyright (c) 2018 Octasic Inc. All rights reserved.

Description: 

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.


Release: OCTSDR Software Development Kit OCTSDR_GSM-02.11.00-B1927 (2018/04/27)

$Revision: $

\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/

#ifndef __OCTDEV_TYPES_H__
#define __OCTDEV_TYPES_H__


/*****************************  INCLUDE FILES  *******************************/
#include <limits.h>


/************************  COMMON DEFINITIONS  *******************************/

/*-------------------------------------------------------------------------------------
 	API Data Types
-------------------------------------------------------------------------------------*/

                
#ifndef NULL
#ifdef __cplusplus
#define NULL    0
#else
#define NULL    ((void *)0)
#endif
#endif
                
#if SHRT_MAX == 32767
	/* short is 16-bit */
	typedef unsigned short	tOCT_UINT16;
	typedef short			tOCT_INT16;
#elif INT_MAX == 32767
	/* integer is 16-bit */
	typedef unsigned int	tOCT_UINT16;
	typedef int				tOCT_INT16;
#else
	/* unexpected 16-bit type */
	#error Cannot determine 16-bit type
#endif

#if INT_MAX == 2147483647L
	/* integer is 32-bit */
	typedef int				tOCT_INT32;
	typedef unsigned int	tOCT_UINT32;
#elif LONG_MAX == 2147483647L
	/* long is 32-bit */
	typedef long			tOCT_INT32;
	typedef unsigned long	tOCT_UINT32;
#else
	/* unexpected 32-bit type */
	#error Cannot determine 32-bit type
#endif

typedef long long			tOCT_INT64;
typedef unsigned long long	tOCT_UINT64;

typedef char			tOCT_INT8;
typedef unsigned char	tOCT_UINT8;
            
              
/*-------------------------------------------------------------------------------------
 	TRUE/FALSE
-------------------------------------------------------------------------------------*/
/*-------------------------------------------------------------------------------------
	tOCT_BOOL32 :
-------------------------------------------------------------------------------------*/
#define tOCT_BOOL32											tOCT_UINT32

#define cOCT_TRUE											1		
#define cOCT_FALSE											0		

/*-------------------------------------------------------------------------------------
 	Generic Timeout value
-------------------------------------------------------------------------------------*/
#define cOCTDEV_TIMEOUT_FOREVER								0xFFFFFFFF	

                
/*--------------------------------------------------------------------------
	ENDIAN Determination

    _OCT_ENDIAN_TYPE_BE_: Defined when target is Big Endian
    _OCT_ENDIAN_TYPE_LE_: Defined when target is Little Endian

	These must be set by the user. If not set the system will try to
	automatically determine them based on some common compiler #define
	values.

----------------------------------------------------------------------------*/

#if !defined( _OCT_ENDIAN_TYPE_BE_ ) && !defined( _OCT_ENDIAN_TYPE_LE_ )
	/* Not Set - try to determine automatically */

	/* Look for Intel target */
	#if defined( __OCT_ENV_OPUS__ ) || defined( _M_OPUS1 ) || defined( _M_OPUS2 ) || defined( _M_OPUS3 )
		#define _OCT_ENDIAN_TYPE_BE_
		#define _OCT_PLATFORM_OPUS_
	#elif defined( _M_IX86 ) || defined(__x86_64__)
		#define _OCT_ENDIAN_TYPE_LE_
		#define _OCT_PLATFORM_X86_
	#elif defined( __i386 )
		#define _OCT_ENDIAN_TYPE_LE_
		#define _OCT_PLATFORM_X86_
	#elif defined( i386 )
		#define _OCT_ENDIAN_TYPE_LE_
		#define _OCT_PLATFORM_X86_
	/* Look for Motorola PPC target */
	#elif defined( _M_MPPC  ) || defined( _M_PPC ) || defined( __ppc__ ) || defined( __PPC )
		#define _OCT_ENDIAN_TYPE_BE_
		#define _OCT_PLATFORM_PPC_
	/* Look for Sparc target */
	#elif defined( __sparc )
		#define _OCT_ENDIAN_TYPE_BE_
		#define _OCT_PLATFORM_SPARC_
	#elif defined( __sun__ )
		#define _OCT_ENDIAN_TYPE_BE_
		#define _OCT_PLATFORM_SPARC_
	/* Look for ARM target */
	#elif defined( __ARMEB__ ) || defined( __AARCH64EB__ )
		#define _OCT_ENDIAN_TYPE_BE_
		#define _OCT_PLATFORM_ARM_
	#elif defined( __ARMEL__ )|| defined( __AARCH64EL__ )	
		#define _OCT_ENDIAN_TYPE_LE_
		#define _OCT_PLATFORM_ARM_
	/* Look for MIPS target */
	#elif  defined( __mips__ ) || defined( __MIPSEB )
		#define _OCT_ENDIAN_TYPE_BE_
		#define _OCT_PLATFORM_MIPS_
	/* others */
	#elif defined( __BIG_ENDIAN__ )
		#define _OCT_ENDIAN_TYPE_BE_
	#elif defined( __LITTLE_ENDIAN__ )
		#define _OCT_ENDIAN_TYPE_LE_		
	#elif defined( CPU )
		#if CPU==PPC860
			#define _OCT_ENDIAN_TYPE_BE_
			#define _OCT_PLATFORM_PPC_
		#endif
	#endif
#endif

/* Now insure the endian format is set properly */
#if !defined( _OCT_ENDIAN_TYPE_BE_ ) && !defined( _OCT_ENDIAN_TYPE_LE_ )
	#error Processor Endian not determined
#endif
#if defined( _OCT_ENDIAN_TYPE_BE_ ) && defined( _OCT_ENDIAN_TYPE_LE_ )
	#error Processor Endian Set to both Values
#endif

/*--------------------------------------------------------------------------
	PLATFORM Determination

    OCT_WINDOWS_ENV : Defined when target running under windows
      OCT_LINUX_ENV : Defined when target running under linux
       OCT_OPUS_ENV : OPUS env
    OCT_UNKNOWN_ENV : Unknown env

----------------------------------------------------------------------------*/
#define __OCTDEV_TYPE_STR2__(x) #x
#define __OCTDEV_TYPE_STR1__(x) __OCTDEV_TYPE_STR2__(x)
#define __OCTDEV_TYPE_WARNLOC__ __FILE__ "("__OCTDEV_TYPE_STR1__(__LINE__)") : Warning Msg: "

#if defined( __OCT_ENV_OPUS__ ) || defined( _M_OPUS1 ) || defined( _M_OPUS2 ) || defined( _M_OPUS3 )
	#define OCT_ENV_TYPE_OPUS
	#define OCT_ENV_TYPE_OCTSYS
#ifndef NDEBUG
	#define OCT_ENV_MODE_DEBUG
#endif 
#elif defined( _LINUX_ ) || defined( __linux__ )
	#define OCT_ENV_TYPE_LINUX
  #define OCT_ENV_TYPE_OCTOS
#ifndef NDEBUG
	#define OCT_ENV_MODE_DEBUG
#endif   
#elif defined( _WIN32 ) || defined( WIN32 ) || defined( __WIN32__ ) ||	defined( _WIN32_ ) || defined( WIN32S ) || defined( _WIN64 )  || defined( WIN64 )
	#define OCT_ENV_TYPE_WINDOWS
  #define OCT_ENV_TYPE_OCTOS
#ifdef _DEBUG
	#define OCT_ENV_MODE_DEBUG
#endif   
#else
	#define OCT_ENV_TYPE_UNKNOWN
  #pragma message(__OCTDEV_TYPE_WARNLOC__"Environment platform not determined")
#endif

/*--------------------------------------------------------------------------
	POINTER type definition
----------------------------------------------------------------------------*/
#if defined( OCT_ENV_TYPE_WINDOWS )
#include <basetsd.h>

#define tOCT_UINT_PTR	UINT_PTR
#define tOCT_INT_PTR	INT_PTR

#elif defined( OCT_ENV_TYPE_LINUX )
#include <inttypes.h>

#define tOCT_UINT_PTR	uintptr_t
#define tOCT_INT_PTR	intptr_t

#elif defined( OCT_ENV_TYPE_OCTSYS )
#include  <stdint.h>

#define tOCT_UINT_PTR	uintptr_t
#define tOCT_INT_PTR	intptr_t

#else 
	#pragma message(__OCTDEV_TYPE_WARNLOC__"Environment pointer determined")


#endif /* OCT_ENV_TYPE_WINDOWS */

              
/*-------------------------------------------------------------------------------------
 	Generic IP Address
-------------------------------------------------------------------------------------*/

/*-------------------------------------------------------------------------------------
	tOCTDEV_IP_VERSION_ENUM :
-------------------------------------------------------------------------------------*/
#define tOCTDEV_IP_VERSION_ENUM								tOCT_UINT32

#define cOCTDEV_IP_VERSION_ENUM_4							0		 	/* IP address version 4 */
#define cOCTDEV_IP_VERSION_ENUM_6							1		 	/* IP address version 6 */
#define cOCTDEV_IP_VERSION_ENUM_INVALID						0xFFFFFFFF	

/*-------------------------------------------------------------------------------------
	tOCTDEV_IP_ADDRESS
 		IP address structure

 Members:
	ulIpVersion
		Default:	cOCTDEV_IP_VERSION_ENUM_4
 		Version of the IP address
	aulIpAddress
 		Ip address, Version 4 -> aulIpAddress[0] only.
-------------------------------------------------------------------------------------*/
typedef struct
{
	tOCTDEV_IP_VERSION_ENUM	ulIpVersion;
	tOCT_UINT32				aulIpAddress[4];

} tOCTDEV_IP_ADDRESS;

/*-------------------------------------------------------------------------------------
 	Generic UDP Address
-------------------------------------------------------------------------------------*/
#define cOCTDEV_UDP_PORT_INVALID							0xFFFFFFFF	 	/* Invalid UDP port specification. */

/*-------------------------------------------------------------------------------------
	tOCTDEV_UDP_ADDRESS
 		UDP address structure

 Members:
	IpAddress
 		IP version and address.
	ulUdpPort
		Default:	cOCTDEV_UDP_PORT_INVALID
 		UDP port used with IP address
-------------------------------------------------------------------------------------*/
typedef struct
{
	tOCTDEV_IP_ADDRESS	IpAddress;
	tOCT_UINT32			ulUdpPort;

} tOCTDEV_UDP_ADDRESS;

/*-------------------------------------------------------------------------------------
 	Generic TCP Address
-------------------------------------------------------------------------------------*/
#define cOCTDEV_TCP_PORT_INVALID							0xFFFFFFFF	 	/* Invalid TCP port specification. */

/*-------------------------------------------------------------------------------------
	tOCTDEV_TCP_ADDRESS
 		TCP address structure

 Members:
	IpAddress
 		IP version and address.
	ulTcpPort
		Default:	cOCTDEV_TCP_PORT_INVALID
 		TCP port used with IP address
-------------------------------------------------------------------------------------*/
typedef struct
{
	tOCTDEV_IP_ADDRESS	IpAddress;
	tOCT_UINT32			ulTcpPort;

} tOCTDEV_TCP_ADDRESS;

/*-------------------------------------------------------------------------------------
 	Generic MAC Address
-------------------------------------------------------------------------------------*/
#define cOCTDEV_MAC_ADDRESS_BYTE_COUNT						6		

/*-------------------------------------------------------------------------------------
	tOCTDEV_MAC_ADDRESS
 		MAC address structure

 Members:
	abyReserved
 		Reserved fields inserted to ensure that the structure is an integer multiple of
 		DWORDS.
	abyMacAddress
 		MAC address; abyMacAddress[0] = msb, abyMacAddress[5] = lsb.
-------------------------------------------------------------------------------------*/
typedef struct
{
	tOCT_UINT8	abyReserved[2];
	tOCT_UINT8	abyMacAddress[cOCTDEV_MAC_ADDRESS_BYTE_COUNT];

} tOCTDEV_MAC_ADDRESS;


#endif /* __OCTDEV_TYPES_H__ */