versadac  1
versadac - Scalable Recorder Firmware
rpcrunti.h
1 /*---------------------------------------------------------------------------*/
2 /* Copyright (C) 2006 Woodhead Software & Electonics. All rights reserved. */
3 /*---------------------------------------------------------------------------*/
4 /* This program is protected by international copyright. */
5 /* */
6 /* The use of this software including but not limited to its Source Code */
7 /* is subject to restrictions as agreed in the license agreement between */
8 /* you and Woodhead. */
9 /* Copying or distribution is not allowed unless expressly permitted */
10 /* according to your license agreement with Woodhead. */
11 /*---------------------------------------------------------------------------*/
12 /* */
13 /* Project : STACK PROFINET Controller */
14 /* Component : RPC Interface */
15 /* $Workfile:: rpcrunti.h $*/
16 /* $Revision:: 2 $*/
17 /* $Date:: 9/22/09 6:01p $*/
18 /* */
19 /*---------------------------------------------------------------------------*/
20 /* */
21 /* D e s c r i p t i o n : */
22 /* Main thread managing rpc runtime */
23 /* */
24 /*---------------------------------------------------------------------------*/
25 #ifndef __RPCRUNTIME_H__
26 #define __RPCRUNTIME_H__
27 
28 #include "os_pck.h"
29 /*---------------------------------------------------------------------------*/
30 /* RPC [INTERFACE/FUNCTION] REGISTER */
31 /*---------------------------------------------------------------------------*/
32 #define MAX_REG_INTERFACE 10 /* number of server interface for device */
33 
34 typedef struct _INTERFACE_REGISTER
35 {
36  ST_CLR_RPC_UUID uuidObject; /*REG - Object ID */
37  ST_CLR_RPC_UUID uuidIfId; /*REG - Interface ID */
38  ALIGNED_DWORD_DECL(dwIpTarget); /*IP where to register this interface */
39  ALIGNED_DWORD_DECL(dwOldIpTarget); /*Old IP where to register this interface */
40  ALIGNED_DWORD_DECL(dwQueue); /*CALL - Queue where to send message */
41  APP_WORD wMessageID; /*CALL - Message to send */
42  APP_WORD wNumOp; /*REG - Operation number */
43 }PACK_ALIGNEMENT(ST_INTERFACE_REGISTER),APP_FAR *LPST_INTERFACE_REGISTER;
44 
45 #define ST_INTERFACE_REGISTER_SIZEOF sizeof(ST_INTERFACE_REGISTER)
46 
47 
48 /*---------------------------------------------------------------------------*/
49 /* REQUEST INFORMATION */
50 /*---------------------------------------------------------------------------*/
51 
52 typedef enum _RPC_RES_TYPE
53 {
54  enResponse=0,
55  enReject =1,
56  enFault =2
57 } EN_RPC_RES_TYPE;
58 
59 typedef struct _RPC_REQ
60 {
61  ST_RPC_DATA_BUFFER stRPCData; /* -> Request from device
62  <- Reponse to send to device*/
63  ALIGNED_DWORD_DECL (enResType);
64  ALIGNED_DWORD_DECL (dwRPCStatus); /* Status associated with response*/
65  ALIGNED_DWORD_DECL (dwIPAddressCaller); /* Caller IP Address*/
66 
67 #ifdef __RPC_MICROSOFT_WSE
68  APP_BYTE byServerRepReady; /* Synchronisation as we can't used our messages in RPC Microsoft*/
69 #endif
70  APP_LPVOID lpstServer; /* Main server managing this request */
71 } PACK_ALIGNEMENT(ST_RPC_REQ),APP_FAR *LPST_RPC_REQ;
72 #define ST_RPC_REQ_SIZEOF sizeof(ST_RPC_REQ)
73 STRUCT_SIZE_CHECK(ST_RPC_REQ, ST_RPC_REQ_SIZEOF)
74 
75 #ifdef __RPC_MICROSOFT_WSE
76  #define STATE_ASK 0
77  #define STATE_RESPONSE 1
78  #define STATE_END 2
79  #define GET_REQ_REP_READY(preq) (preq)->byServerRepReady
80  #define SET_REQ_REP_READY(preq,v) (preq)->byServerRepReady =(v)
81 #endif
82 
83 #define REQ_DATA(preq) (&(preq)->stRPCData)
84 
85 #ifndef PLATFORM_NO_PACKING
86 #define GET_REQ_RPC_STATUS(preq) (preq)->dwRPCStatus
87 #define SET_REQ_RPC_STATUS(preq,v) (preq)->dwRPCStatus =(v)
88 #endif
89 
90 #ifdef PLATFORM_NO_PACKING
91 #define GET_REQ_RPC_STATUS(preq) ALIGNED_DWORD_VALUE((preq)->dwRPCStatus)
92 #define SET_REQ_RPC_STATUS(preq,v) ALIGNED_DWORD_ASSIGN((v), (preq)->dwRPCStatus)
93 #endif
94 
95 #define SET_REQ_RPC_STATUS_PNIO(preq,a,b,c,d) (preq)->dwRPCStatus =((a*16777216) + (b*65536) + (c*256) + d)
96 
97 
98 /*---------------------------------------------------------------------------*/
99 /* CLCLIENT CONTEXT */
100 /*---------------------------------------------------------------------------*/
101 
102 typedef struct _RPC_CONTEXT {
103  ST_CLR_RPC_UUID uuidObject; /*16 - 0*/ /* Object ID */
104  ST_CLR_RPC_UUID uuidActivity; /*16 - 16*/ /* Current Activity */
105  ALIGNED_DWORD_DECL(dwSequenceNb); /* 4 - 32*/ /* Last Sequence number */
106  ALIGNED_DWORD_DECL(dwServerBootTime); /* 4 - 36*/ /* Time of server startup */
107  ALIGNED_DWORD_DECL(dwIPAddress); /* 4 - 40*/ /* IP Address of the server */
108  APP_WORD wPort; /* 2 - 44*/ /* Destination Port of server */
109 #ifdef PADDING
110  APP_WORD wPadding; /* 2 - 46*/ /* Destination Port of server */
111 #endif
113 
114 #define ST_RPC_CONTEXT_SIZEOF sizeof(ST_RPC_CONTEXT)
115 
116 
117 /*---------------------------------------------------------------------------*/
118 /* INVOKE INFORMATION */
119 /*---------------------------------------------------------------------------*/
120 
121 typedef struct _RPC_CALL
122 {
123  ST_RPC_DATA_BUFFER stRPCData; /*16- 0*/ /* -> Invoke data to send <- Response of the device */
124  ST_RPC_CONTEXT stRPCContext; /*48- 16*/ /* Current context (to set correctly clclient)*/
125  ST_CLR_RPC_UUID uuidInterface; /*16- 64*/ /* Interface Identificator */
126  ALIGNED_DWORD_DECL( dwIpAddrSrc); /*4 - 80*/
127  ALIGNED_DWORD_DECL( enResType); /*4 - 80*/
128  ALIGNED_DWORD_DECL( dwRPCStatus); /*4 - 84*/ /* Status associated with response */
129  ALIGNED_DWORD_DECL( dwIdQueue); /*4 - 88*/ /* Queue to use */
130  ALIGNED_DWORD_DECL( dwRPCInterfaceVersion); /*4 - 92*/ /* Interface version */
131  APP_WORD wOperationNmb; /*2 - 96*/ /* Num of function to call */
132  /*Way to send response*/
133  APP_WORD wIdRspPos; /*2 - 98*/ /*Message ID in case of positive answer*/
134  APP_WORD wIdRspNeg; /*2 - 100*/ /*Message ID in case of negative answer*/
135  APP_WORD wIdRspCancel; /*2 - 102*/ /*Message ID in case of cancel rpc service*/
136 } PACK_ALIGNEMENT(ST_RPC_CALL),APP_FAR *LPST_RPC_CALL;
137 #define ST_RPC_CALL_SIZEOF sizeof(ST_RPC_CALL)
138 
139 /*DATA*/
140 #define CALL_DATA(pcall) (&((pcall)->stRPCData))
141 
142 /*RPC*/
143 
144 #define GET_CALL_INTERFACE_UUID(pcall) (pcall)->uuidInterface
145 #define GET_CALL_INTERFACE_VERS(pcall) (pcall)->dwRPCInterfaceVersion
146 #define GET_CALL_OPNUM(pcall) (pcall)->wOperationNmb
147 #define GET_CALL_RPC_STATUS(pcall) (pcall)->dwRPCStatus
148 
149 #define SET_CALL_INTERFACE_UUID(pcall,v) OS_MEMCOPY(&((pcall)->uuidInterface),&v,sizeof(ST_CLR_RPC_UUID))
150 
151 #ifndef PLATFORM_NO_PACKING
152 #define SET_CALL_INTERFACE_VERS(pcall,v) (pcall)->dwRPCInterfaceVersion = (v)
153 #define GET_CALL_RPC_IP_SRC(pcall) (pcall)->dwIpAddrSrc
154 #define SET_CALL_RPC_IP_SRC(pcall,v) (pcall)->dwIpAddrSrc = (v)
155 #endif
156 #ifdef PLATFORM_NO_PACKING
157 #define SET_CALL_INTERFACE_VERS(pcall,v) ALIGNED_DWORD_ASSIGN((v), (pcall)->dwRPCInterfaceVersion)
158 #define GET_CALL_RPC_IP_SRC(pcall) ALIGNED_DWORD_VALUE((pcall)->dwIpAddrSrc)
159 #define SET_CALL_RPC_IP_SRC(pcall,v) ALIGNED_DWORD_ASSIGN((v), (pcall)->dwIpAddrSrc)
160 #endif
161 
162 #define SET_CALL_OPNUM(pcall,v) (pcall)->wOperationNmb = (v)
163 
164 #ifndef PLATFORM_NO_PACKING
165 #define SET_CALL_RPC_STATUS(pcall,v) (pcall)->dwRPCStatus = (v)
166 #endif
167 #ifdef PLATFORM_NO_PACKING
168 #define SET_CALL_RPC_STATUS(pcall,v) ALIGNED_DWORD_ASSIGN((v), (pcall)->dwRPCStatus)
169 #endif
170 
171 /*Context*/
172 #define GET_CALL_OBJECTUUID(pcall) (&(pcall)->stRPCContext.uuidObject)
173 #define GET_CALL_ACTIVITYUUID(pcall) (&(pcall)->stRPCContext.uuidActivity)
174 #define GET_CALL_OBJECTUUID_VAL(pcall) (pcall)->stRPCContext.uuidObject
175 #define GET_CALL_ACTIVITYUUID_VAL(pcall) (pcall)->stRPCContext.uuidActivity
176 
177 #ifndef PLATFORM_NO_PACKING
178 #define GET_CALL_IPADDRESS(pcall) (pcall)->stRPCContext.dwIPAddress
179 #define GET_CALL_SEQUENCE(pcall) (pcall)->stRPCContext.dwSequenceNb
180 #define GET_CALL_BOOTTIME(pcall) (pcall)->stRPCContext.dwServerBootTime
181 
182 #define SET_CALL_IPADDRESS(pcall,val) (pcall)->stRPCContext.dwIPAddress = val
183 #define SET_CALL_SEQUENCE(pcall,val) (pcall)->stRPCContext.dwSequenceNb = val
184 #define SET_CALL_BOOTTIME(pcall,val) (pcall)->stRPCContext.dwServerBootTime = val
185 
186 #define SET_CALL_RET_MSG_QUEUE(pcall,v) (pcall)->dwIdQueue = (v)
187 
188 #endif
189 
190 #ifdef PLATFORM_NO_PACKING
191 #define GET_CALL_IPADDRESS(pcall) ALIGNED_DWORD_VALUE((pcall)->stRPCContext.dwIPAddress)
192 #define GET_CALL_SEQUENCE(pcall) ALIGNED_DWORD_VALUE((pcall)->stRPCContext.dwSequenceNb)
193 #define GET_CALL_BOOTTIME(pcall) ALIGNED_DWORD_VALUE((pcall)->stRPCContext.dwServerBootTime)
194 
195 #define SET_CALL_IPADDRESS(pcall,val) ALIGNED_DWORD_ASSIGN((val), (pcall)->stRPCContext.dwIPAddress)
196 #define SET_CALL_SEQUENCE(pcall,val) ALIGNED_DWORD_ASSIGN((val), (pcall)->stRPCContext.dwSequenceNb)
197 #define SET_CALL_BOOTTIME(pcall,val) ALIGNED_DWORD_ASSIGN((val), (pcall)->stRPCContext.dwServerBootTime)
198 
199 #define SET_CALL_RET_MSG_QUEUE(pcall,v) ALIGNED_DWORD_ASSIGN((v), (pcall)->dwIdQueue)
200 
201 #endif
202 
203 #define GET_CALL_RET_MSG_QUEUE(pcall) (pcall)->dwIdQueue
204 #define GET_CALL_PORT(pcall) (pcall)->stRPCContext.wPort
205 #define SET_CALL_PORT(pcall,val) (pcall)->stRPCContext.wPort = val
206 
207 #define SET_CALL_OBJECTUUID(pcall,val) OS_MEMCOPY(&(pcall)->stRPCContext.uuidObject,&val,sizeof(ST_CLR_RPC_UUID))
208 #define SET_CALL_ACTIVITYUUID(pcall,val) OS_MEMCOPY(&(pcall)->stRPCContext.uuidActivity,&val,sizeof(ST_CLR_RPC_UUID))
209 
210 
211 
212 /*Response way*/
213 
214 #define GET_CALL_RET_MSG_IDPOS(pcall) (pcall)->wIdRspPos
215 #define GET_CALL_RET_MSG_IDNEG(pcall) (pcall)->wIdRspNeg
216 #define GET_CALL_RET_MSG_IDCANCEL(pcall) (pcall)->wIdRspCancel
217 
218 
219 #define SET_CALL_RET_MSG_IDPOS(pcall,v) (pcall)->wIdRspPos = (v)
220 #define SET_CALL_RET_MSG_IDNEG(pcall,v) (pcall)->wIdRspNeg = (v)
221 #define SET_CALL_RET_MSG_IDCANCEL(pcall,v) (pcall)->wIdRspCancel = (v)
222 
223 
224 
225 
226 #include "os_unpck.h"
227 /*---------------------------------------------------------------------------*/
228 /* COMMUN DEFINE (CLIENT/SERVER) */
229 /*---------------------------------------------------------------------------*/
230 
231 #define CONST_COMM_FAILURE 0x1C010001UL
232 #define CONST_UNSPECIFIED_REJECT 0x1C000009UL
233 #define CONST_UNSPECIFIED_FAULT 0x1C000012UL
234 #define CONST_REJECT_ARG_OUT_TOO_BIG 0x1C010013UL
235 #define CONST_REJECT_SERVER_BUSY 0x1C010014UL
236 
237 #define CTS_BAD_ACT_ID 0x1c00000AUL
238 #define CTS_NCA_S_INVALID_CHKSUM 0x1c00001fUL
239 #define CTS_UNSPEC_REJECT 0x1c000009UL
240 #define CTS_NO_MEMORY 0x1C00001BUL
241 #define CTS_UNK_IF 0x1C010003UL
242 #define CTS_WRONG_BOOT_TIME 0x1c010006UL
243 #define CTS_YOU_CRASHED 0x1c010009UL
244 #define CTS_RPC_S_OK 0
245 
246 #define CTS_MAX_PINGS 3 /*client max ping */
247 #define CTS_MAX_REQUESTS 3 /*client max resend*/
248 #define CTS_MAX_REPLIES 3 /*Server max retry */
249 
250 /*default RPC Timeout*/
251 #define TIMEOUT_BROADCAST 5000
252 #define TIMEOUT_ACK 1000
253 #define TIMEOUT_CANCEL 1000
254 #define TIMEOUT_FRAG 2000
255 #define TIMEOUT_PING 2000
256 /* So 2s put here in place */
257 #define TIMEOUT_WAIT 2000
258 
259 #define TIMEOUT_IDLE 30000
260 #define TIMEOUT_RESEND 2000
261 
262 #define CTS_CL_VERSION_NUM_V20 PNIO_RPC_VERSION
263 #define CTS_CANCEL_VERSION 0
264 
265 #define CTS_REQUEST RPC_PKT_TYPE_REQUEST
266 #define CTS_PING RPC_PKT_TYPE_PING
267 #define CTS_RESPONSE RPC_PKT_TYPE_RESPONSE
268 #define CTS_FAULT RPC_PKT_TYPE_FAULT
269 #define CTS_WORKING RPC_PKT_TYPE_WORKING
270 #define CTS_NOCALL RPC_PKT_TYPE_NOCALL
271 #define CTS_REJECT RPC_PKT_TYPE_REJECT
272 #define CTS_ACK RPC_PKT_TYPE_ACKNO
273 #define CTS_CANCEL RPC_PKT_TYPE_CNXLESS
274 #define CTS_FACK RPC_PKT_TYPE_FRGACK
275 #define CTS_CANCEL_ACK RPC_PKT_TYPE_CANCELACK
276 
277 /*---------------------------------------------------------------------------*/
278 /* RPC RUNTIME */
279 /*---------------------------------------------------------------------------*/
280 
281 /*Main thread function*/
282 APP_WORD rpcruntime_task(APP_LPVOID pArg);
283 #define RPC_ALLOC_REQ OS_SEND_MESSAGE_RPC(ID_RPC_ALLOC)
284 
285 
286 #endif
Definition: rpcrunti.h:34
Definition: rpcrunti.h:121
Definition: rpcrunti.h:59
Definition: rpcrunti.h:102