-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcommon.h
64 lines (50 loc) · 2.08 KB
/
common.h
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
/******************************************************************************
*
* FILENAME:
* common.h
*
* DESCRIPTION:
* Define some structures for client and server.
*
* REVISION(MM/DD/YYYY):
* 05/03/2016 Shengkui Leng ([email protected])
* - Initial version
*
******************************************************************************/
#ifndef _COMMON_H_
#define _COMMON_H_
#include "uds.h"
/*--------------------------------------------------------------
* Definition for both client and server
*--------------------------------------------------------------*/
#define UDS_SOCK_PATH "/tmp/uds.1234"
/* Extra status code, refer STATUS_ERROR defined in uds.h,
* the values used in struct uds_command_t.status */
#define STATUS_INIT_ERROR (STATUS_ERROR+1) /* Server/client init error */
#define STATUS_INVALID_COMMAND (STATUS_ERROR+2) /* Unkown request type */
/* Request type, the values used in struct uds_command_t.command */
enum uds_command_type {
CMD_GET_VERSION = 0x8001, /* Get the version of server */
CMD_GET_MESSAGE, /* Receive a message from server */
CMD_PUT_MESSAGE, /* Send a message to server */
CMD_UNKNOWN /* */
};
/* Response for CMD_GET_VERSION */
typedef struct uds_response_version {
uds_command_t common; /* Common header of response */
uint8_t major; /* Major version */
uint8_t minor; /* Minor version */
} BYTE_ALIGNED uds_response_version_t;
/* Response for CMD_GET_MESSAGE */
#define UDS_GET_MSG_SIZE 256
typedef struct uds_response_get_msg {
uds_command_t common; /* Common header of response */
char data[UDS_GET_MSG_SIZE]; /* Data from server to client */
} BYTE_ALIGNED uds_response_get_msg_t;
/* Request for CMD_PUT_MESSAGE */
#define UDS_PUT_MSG_SIZE 256
typedef struct uds_request_put_msg {
uds_command_t common; /* Common header of request */
char data[UDS_PUT_MSG_SIZE]; /* Data from client to server */
} BYTE_ALIGNED uds_request_put_msg_t;
#endif /* _COMMON_H_ */