CHAILink SDK  Version 1.3
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
CLCm_Message.h
Go to the documentation of this file.
1 //*********************************************************
2 // File: CLCm_Message.h
3 // Project: CopperLan CHAILink SDK Common Part
4 // For Client & Server
5 // Version: 1.3
6 // Release Date: 2014/04/15
7 //*********************************************************
8 
9 /********************************************************************
10 Software License Agreement: CHAILink Client source code
11 
12 The software supplied herewith by Klavis Technology (the “Company”) is intended and
13 supplied to you, the Company’s customer, for use solely and exclusively on embedded
14 CopperLan products needing a CHAILink Client.
15  The software is owned by the Company and/or its supplier, and is protected
16  under applicable copyright laws. All rights are reserved. Any use in violation of the
17  foregoing restrictions may subject the user to criminal sanctions under applicable laws,
18 as well as to civil liability for the breach of the terms and conditions of this license.
19 
20 THIS SOFTWARE MUST REMAIN UNMODIFIED. NO WARRANTIES, WHETHER EXPRESS,
21  IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
22  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE
23 IN CASE OF SOURCE CODE CHANGE BY THE CUSTOMER. IN CASE OF SUCH CHANGE, THE
24 COMPANY SHALL NOT BE LIABLE FOR SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES
25 OF ANY KIND.
26 ********************************************************************/
27 
28 #ifndef __CLCM_MESSAGE_H__
29 #define __CLCM_MESSAGE_H__
30 
31 #include "CLCm_Defines.h"
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
38 
39 //=========================================================================
40 // Message map
41 //=========================================================================
42 
43 /*
44  CopperLan CMD payload legend
45  oh oh oh oh : Object handle
46  mi mi : Method ID (CMLID_* value)
47  st st : Status (used for function call return command)
48  ** ** : n bytes of Arguments depending on Method IDs
49  | : end of payload
50 
51  CopperLan CMD message:
52  oh oh oh oh
53  mi mi st st
54  ** ** |
55 */
56 
57 //=========================================================================
58 // CHAILink command message sizes & positions
59 //=========================================================================
60 
61 #define CLMSG_HEADER_OBJECTHANDLE_SIZE (4)
62 #define CLMSG_HEADER_METHODID_SIZE (2)
63 #define CLMSG_HEADER_STATUS_SIZE (2)
64 #define CLMSG_HEADER_SIZE (CLMSG_HEADER_OBJECTHANDLE_SIZE + CLMSG_HEADER_METHODID_SIZE + CLMSG_HEADER_STATUS_SIZE)
65 
66 #define CLMSG_HEADER_POS (0)
67 #define CLMSG_HEADER_OBJECTHANDLE_POS (CLMSG_HEADER_POS)
68 #define CLMSG_HEADER_METHODID_POS (CLMSG_HEADER_OBJECTHANDLE_POS + CLMSG_HEADER_OBJECTHANDLE_SIZE)
69 #define CLMSG_HEADER_STATUS_POS (CLMSG_HEADER_METHODID_POS + CLMSG_HEADER_METHODID_SIZE)
70 #define CLMSG_DATA_POS (CLMSG_HEADER_STATUS_POS + CLMSG_HEADER_STATUS_SIZE)
71 
72 #define CLMSG_ETHERNETFRAMEMAXSIZE (1500 + 18) // This size correspond to a valid Ethernet 2 frame :
73  // 18 bytes for header and
74  // 1500 bytes for max payload
75  // The CRC is created or verified by the VNM Chip
76 #define CLMSG_ETHERNETMSGMAXSIZE (CLMSG_HEADER_SIZE + 2 + CLMSG_ETHERNETFRAMEMAXSIZE)
77 
78 // Message size default and minimum size is 400
79 #define CLMSG_MESSAGEMINSIZE 400
80 #define CLMSG_MESSAGEMAXSIZE CLMSG_ETHERNETMSGMAXSIZE
81 
82 // CLMSG_MESSAGESIZE corresponds to the maximum CHAI Link message size except for Ethernet passthru messages.
83 // Check CLMSG_MESSAGESIZE
84 #if !defined(CLMSG_MESSAGESIZE)
85 #define CLMSG_MESSAGESIZE CLMSG_MESSAGEMINSIZE
86 #else
87 #if CLMSG_MESSAGESIZE < CLMSG_MESSAGEMINSIZE
88 #error CLMSG_MESSAGESIZE MUST be at least 400 bytes long.
89 #elif CLMSG_MESSAGESIZE > CLMSG_MESSAGEMAXSIZE
90 #error CLMSG_MESSAGESIZE MUST be less than CLMSG_MESSAGEMAXSIZE bytes long.
91 #endif
92 #endif
93 
94 #define CLMSG_PAYLOADMAXSIZE (CLMSG_MESSAGESIZE - CLMSG_HEADER_SIZE)
95 
96 #define DESERIALIZE_MSGHEADER(hObject, wMethodID, wStatus, ptr) \
97  DESERIALIZE_UINT32(hObject, ptr); \
98  DESERIALIZE_UINT16(wMethodID, ptr); \
99  DESERIALIZE_UINT16(wStatus, ptr); \
100 
101 #define SERIALIZE_MSGHEADER(ptr, hObject, wMethodID, wStatus) \
102  SERIALIZE_UINT32(ptr, hObject); \
103  SERIALIZE_UINT16(ptr, wMethodID); \
104  SERIALIZE_UINT16(ptr, wStatus); \
105 
106 
108 #ifdef __cplusplus
109 }
110 #endif
111 
112 #endif // __CLCM_MESSAGE_H__