EPICS Base  7.0.5.1
caProto.h
1 /*************************************************************************\
2 * Copyright (c) 2002 The University of Chicago, as Operator of Argonne
3 * National Laboratory.
4 * Copyright (c) 2002 The Regents of the University of California, as
5 * Operator of Los Alamos National Laboratory.
6 * SPDX-License-Identifier: EPICS
7 * EPICS BASE is distributed subject to a Software License Agreement found
8 * in file LICENSE that is included with this distribution.
9 \*************************************************************************/
10 /*
11  *
12  * Author Jeffrey O. Hill
13  * johill@lanl.gov
14  * 505 665 1831
15  */
16 
17 #ifndef INC_caProto_H
18 #define INC_caProto_H
19 
20 #define capStrOf(A) #A
21 #define capStrOfX(A) capStrOf ( A )
22 
23 /*
24  * CA protocol revision
25  * TCP/UDP port number (bumped each major protocol change)
26  */
27 #define CA_MAJOR_PROTOCOL_REVISION 4
28 #define CA_VERSION_STRING( MINOR_REVISION ) \
29 ( capStrOfX ( CA_MAJOR_PROTOCOL_REVISION ) "." capStrOfX ( MINOR_REVISION ) )
30 #define CA_UKN_MINOR_VERSION 0u /* unknown minor version */
31 #define CA_MINIMUM_SUPPORTED_VERSION 4u
32 # define CA_VSUPPORTED(MINOR) ((MINOR)>=CA_MINIMUM_SUPPORTED_VERSION)
33 # define CA_V41(MINOR) ((MINOR)>=1u)
34 # define CA_V42(MINOR) ((MINOR)>=2u)
35 # define CA_V43(MINOR) ((MINOR)>=3u)
36 # define CA_V44(MINOR) ((MINOR)>=4u)
37 # define CA_V45(MINOR) ((MINOR)>=5u)
38 # define CA_V46(MINOR) ((MINOR)>=6u)
39 # define CA_V47(MINOR) ((MINOR)>=7u)
40 # define CA_V48(MINOR) ((MINOR)>=8u)
41 # define CA_V49(MINOR) ((MINOR)>=9u) /* large arrays, dispatch priorities */
42 # define CA_V410(MINOR) ((MINOR)>=10u) /* beacon counter */
43 # define CA_V411(MINOR) ((MINOR)>=11u) /* sequence numbers in UDP version command */
44 # define CA_V412(MINOR) ((MINOR)>=12u) /* TCP-based search requests */
45 # define CA_V413(MINOR) ((MINOR)>=13u) /* Allow zero length in requests. */
46 
47 /*
48  * These port numbers are only used if the CA repeater and
49  * CA server port numbers cant be obtained from the EPICS
50  * environment variables "EPICS_CA_REPEATER_PORT" and
51  * "EPICS_CA_SERVER_PORT"
52  */
53 #define CA_PORT_BASE IPPORT_USERRESERVED + 56U
54 #define CA_SERVER_PORT (CA_PORT_BASE+CA_MAJOR_PROTOCOL_REVISION*2u)
55 #define CA_REPEATER_PORT (CA_PORT_BASE+CA_MAJOR_PROTOCOL_REVISION*2u+1u)
56 
57 /*
58  * 1500 (max of ethernet and 802.{2,3} MTU) - 20(IP) - 8(UDP)
59  * (the MTU of Ethernet is currently independent of its speed varient)
60  */
61 #define ETHERNET_MAX_UDP ( 1500u - 20u - 8u )
62 #define MAX_UDP_RECV ( 0xffff + 16u ) /* allow large frames to be received in the future */
63 #define MAX_UDP_SEND 1024u /* original MAX_UDP */
64 #define MAX_TCP ( 1024 * 16u ) /* so waveforms fit */
65 #define MAX_MSG_SIZE ( MAX_TCP ) /* the larger of tcp and udp max */
66 
67 #define CA_PROTO_PRIORITY_MIN 0u
68 #define CA_PROTO_PRIORITY_MAX 99u
69 
70 /*
71  * architecture independent types
72  *
73  * (so far this works on all archs we have ported to)
74  */
75 typedef unsigned char ca_uint8_t;
76 typedef unsigned short ca_uint16_t;
77 typedef unsigned int ca_uint32_t;
78 typedef float ca_float32_t;
79 typedef ca_uint32_t caResId;
80 
81 #define ca_uint32_max 0xffffffff
82 
83  /* values for m_cmmd */
84 #define CA_PROTO_VERSION 0u /* set minor version and priority (used to be NOOP cmd) */
85 #define CA_PROTO_EVENT_ADD 1u /* add an event */
86 #define CA_PROTO_EVENT_CANCEL 2u /* cancel an event */
87 #define CA_PROTO_READ 3u /* read and return a channel value*/
88 #define CA_PROTO_WRITE 4u /* write a channel value */
89 #define CA_PROTO_SNAPSHOT 5u /* snapshot of the system */
90 #define CA_PROTO_SEARCH 6u /* IOC channel search */
91 #define CA_PROTO_BUILD 7u /* build - obsolete */
92 #define CA_PROTO_EVENTS_OFF 8u /* flow control */
93 #define CA_PROTO_EVENTS_ON 9u /* flow control */
94 #define CA_PROTO_READ_SYNC 10u /* purge old reads */
95 #define CA_PROTO_ERROR 11u /* an operation failed */
96 #define CA_PROTO_CLEAR_CHANNEL 12u /* free chan resources */
97 #define CA_PROTO_RSRV_IS_UP 13u /* CA server has joined the net */
98 #define CA_PROTO_NOT_FOUND 14u /* channel not found */
99 #define CA_PROTO_READ_NOTIFY 15u /* add a one shot event */
100 #define CA_PROTO_READ_BUILD 16u /* read and build - obsolete */
101 #define REPEATER_CONFIRM 17u /* registration confirmation */
102 #define CA_PROTO_CREATE_CHAN 18u /* client creates channel in server */
103 #define CA_PROTO_WRITE_NOTIFY 19u /* notify after write chan value */
104 #define CA_PROTO_CLIENT_NAME 20u /* CA V4.1 identify client */
105 #define CA_PROTO_HOST_NAME 21u /* CA V4.1 identify client */
106 #define CA_PROTO_ACCESS_RIGHTS 22u /* CA V4.2 asynch access rights chg */
107 #define CA_PROTO_ECHO 23u /* CA V4.3 connection verify */
108 #define REPEATER_REGISTER 24u /* register for repeater fan out */
109 #define CA_PROTO_SIGNAL 25u /* knock the server out of select */
110 #define CA_PROTO_CREATE_CH_FAIL 26u /* unable to create chan resource in server */
111 #define CA_PROTO_SERVER_DISCONN 27u /* server deletes PV (or channel) */
112 
113 #define CA_PROTO_LAST_CMMD CA_PROTO_SERVER_DISCONN
114 
115 /*
116  * for use with search and not_found (if search fails and
117  * its not a broadcast tell the client to look elesewhere)
118  */
119 #define DOREPLY 10u
120 #define DONTREPLY 5u
121 
122 /*
123  * for use with the m_dataType field in UDP messages emitted by servers
124  */
125 #define sequenceNoIsValid 1
126 
127 /* size of object in bytes rounded up to nearest oct word */
128 #define OCT_ROUND(A) (((A)+7)/8)
129 #define OCT_SIZEOF(A) (OCT_ROUND(sizeof(A)))
130 
131 /* size of object in bytes rounded up to nearest long word */
132 #define QUAD_ROUND(A) ((A)+3)/4)
133 #define QUAD_SIZEOF(A) (QUAD_ROUND(sizeof(A)))
134 
135 /* size of object in bytes rounded up to nearest short word */
136 #define BI_ROUND(A) (((A)+1)/2)
137 #define BI_SIZEOF(A) (BI_ROUND(sizeof(A)))
138 
139 /*
140  * For communicating access rights to the clients
141  *
142  * (placed in m_available hdr field of CA_PROTO_ACCESS_RIGHTS cmmd
143  */
144 #define CA_PROTO_ACCESS_RIGHT_READ (1u<<0u)
145 #define CA_PROTO_ACCESS_RIGHT_WRITE (1u<<1u)
146 
147 /*
148  * All structures passed in the protocol must have individual
149  * fields aligned on natural boundaries.
150  *
151  * NOTE: all structures declared in this file must have a
152  * byte count which is evenly divisible by 8 matching
153  * the largest atomic data type in db_access.h.
154  */
155 #define CA_MESSAGE_ALIGN(A) (OCT_ROUND(A)<<3u)
156 
157 /*
158  * the common part of each message sent/recv by the
159  * CA server.
160  */
161 typedef struct ca_hdr {
162  ca_uint16_t m_cmmd; /* operation to be performed */
163  ca_uint16_t m_postsize; /* size of payload */
164  ca_uint16_t m_dataType; /* operation data type */
165  ca_uint16_t m_count; /* operation data count */
166  ca_uint32_t m_cid; /* channel identifier */
167  ca_uint32_t m_available; /* protocol stub dependent */
168 } caHdr;
169 
170 /*
171  * for monitor (event) message extension
172  */
173 struct mon_info {
174  ca_float32_t m_lval; /* low delta */
175  ca_float32_t m_hval; /* high delta */
176  ca_float32_t m_toval; /* period btween samples */
177  ca_uint16_t m_mask; /* event select mask */
178  ca_uint16_t m_pad; /* extend to 32 bits */
179 };
180 
181 /*
182  * PV names greater than this length assumed to be invalid
183  */
184 #define unreasonablePVNameSize 500u
185 
186 #endif /* ifndef INC_caProto_H */
187 
Definition: caProto.h:161