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