File: omi.h

package info (click to toggle)
fis-gtm 6.2-000-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 30,784 kB
  • ctags: 42,554
  • sloc: ansic: 358,483; asm: 4,847; csh: 4,574; sh: 2,261; awk: 200; makefile: 86; sed: 13
file content (406 lines) | stat: -rw-r--r-- 9,281 bytes parent folder | download | duplicates (3)
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
/****************************************************************
 *								*
 *	Copyright 2001, 2013 Fidelity Information Services, Inc *
 *								*
 *	This source code contains the intellectual property	*
 *	of its copyright holder(s), and is made available	*
 *	under a license.  If you do not know the terms of	*
 *	the license, please stop and do not read further.	*
 *								*
 ****************************************************************/

/*
 *  omi.h ---
 *
 *	Include file for the GTCM server (OMI code).
 *
 *  $Header:$
 *
 */

#ifndef OMI_H
#define OMI_H

#include "gtcm_sysenv.h"

/*  Numbers */
#define OMI_PROTO_MAJOR	 1
#define MAX_USER_NAME	20
#define OMI_PROTO_MINOR	 0
#define OMI_EXT_N2F(NUM) (1 << ((NUM) - 1))
#define OMI_XTN_BUNCH	 1
#define OMI_XTF_BUNCH	 OMI_EXT_N2F(OMI_XTN_BUNCH)
#define OMI_XTN_GGR	 2	/* Not supported */
#define OMI_XTF_GGR	 OMI_EXT_N2F(OMI_XTN_GGR)
#define OMI_XTN_NEWOP	 3
#define OMI_XTF_NEWOP	 OMI_EXT_N2F(OMI_XTN_NEWOP)
#ifdef GTCM_RC
#ifdef LTL_END
#define OMI_XTN_RC	 4
#define OMI_XTF_RC	 OMI_EXT_N2F(OMI_XTN_RC)
#else /*defined(LTL_END) */
#ifdef BIG_END
#define OMI_XTN_RC	 5
#define OMI_XTF_RC	 OMI_EXT_N2F(OMI_XTN_RC)
#endif /* defined(BIG_END) */
#endif /* !defined(LTL_END) */
#else /* defined(RC) */
#define OMI_XTN_RC	 0
#define OMI_XTF_RC	 0
#endif /* !defined(GTCM_RC) */
#define OMI_EXTENSIONS	 (OMI_XTF_BUNCH | OMI_XTF_NEWOP | OMI_XTF_RC)
#define OMI_NUM_EXT	 5


#define OMI_DBG_STMP							\
	do								\
	{								\
		extern FILE	*omi_debug;				\
		time_t		clock;					\
		char		*time_ptr;				\
									\
		if (omi_debug)						\
		{							\
			clock = time((time_t *)0);			\
			GTM_CTIME(time_ptr, &clock);			\
			FPRINTF(omi_debug, "%s", time_ptr);		\
			FFLUSH(omi_debug);				\
		}							\
	} while (0)

#define OMI_DBG(X)							\
	do								\
	{								\
		extern FILE	*omi_debug;				\
		if (omi_debug)						\
		{							\
			FPRINTF X ;					\
			FFLUSH(omi_debug);				\
		}							\
	} while (0)


/*#define OMI_DBG(X)
#define OMI_DBG_STMP*/

/*  Operations */
#define OMI_CONNECT	  1
#define OMI_STATUS	  2
#define OMI_DISCONNECT	  3
#define OMI_SET		 10
#define OMI_SETPIECE	 11
#define OMI_SETEXTRACT	 12
#define OMI_KILL	 13
#define OMI_INCREMENT	 14
#define OMI_GET		 20
#define OMI_DEFINE	 21
#define OMI_ORDER	 22
#define OMI_NEXT	 23
#define OMI_QUERY	 24
#define OMI_REVERSEORDER 25
#define OMI_REVERSEQUERY 26
#define OMI_LOCK	 30
#define OMI_UNLOCK	 31
#define OMI_UNLOCKCLIENT 32
#define OMI_UNLOCKALL	 33
#define OMI_OP_MAX	 34

/*  Error codes */
#define OMI_ER_NO_ERROR		 0
#define OMI_ER_DB_USERNOAUTH	 1
#define OMI_ER_DB_NOSUCHENV	 2
#define OMI_ER_DB_INVGLOBREF	 3
#define OMI_ER_DB_LONGGLOBREF	 4
#define OMI_ER_DB_LONGGLOBVAL	 5
#define OMI_ER_DB_UNRECOVER	 6
#define OMI_ER_PR_INVGLOBREF	10
#define OMI_ER_PR_INVMSGFMT	11
#define OMI_ER_PR_INVOPTYPE	12
#define OMI_ER_PR_SRVCSUSPEND	13
#define OMI_ER_PR_SEQNUMERR	14
#define OMI_ER_SE_VRSNOTSUPP	20
#define OMI_ER_SE_LENMIN	21
#define OMI_ER_SE_LENMAX	22
#define OMI_ER_SE_CONNREQ	23
#define OMI_ER_SE_NOSESS	24
#define OMI_ER_MAX		25

/*  Default buffer size, and fixed protocol portion */
#define OMI_BUFSIZ	 65535
#define OMI_RH_SIZ	 11
#define OMI_MAX_DATA	 32767	/* XXX */
#define OMI_MAX_SUBSCR	 255	/* XXX */
#define OMI_MAX_REF	 255	/* XXX */

/*  Data packing/unpacking information and structures */
typedef unsigned char	uns_char;
#define OMI_SI_SIZ	1
typedef unsigned short	uns_short;
#define OMI_LI_SIZ	2
typedef uint4		uns_long;
#define OMI_VI_SIZ	4

/*  Header before the specific information */
#define OMI_HDR_SIZ	(OMI_VI_SIZ + OMI_SI_SIZ + OMI_RH_SIZ)

typedef union	omi_si
{
	char		octet[OMI_SI_SIZ];
	uns_char	value;
} omi_si;

typedef union	omi_li
{
	char		octet[OMI_LI_SIZ];
	uns_short	value;
} omi_li;

typedef union	omi_vi
{
	char		octet[OMI_VI_SIZ];
	uns_long	value;
} omi_vi;

#ifdef BIG_END

#define OMI_SI_READ(VO, PTR)			\
	do					\
	{					\
		(VO)->octet[0] = *(PTR)++;	\
	} while (0)

#define OMI_SI_WRIT(VAL, PTR)			\
	do					\
	{					\
		omi_si	 obj;			\
		obj.value = (VAL);		\
		*(PTR)++  = obj.octet[0];	\
	} while (0)

#define OMI_LI_READ(VO, PTR)			\
	do					\
	{					\
		(VO)->octet[1] = *(PTR)++;	\
		(VO)->octet[0] = *(PTR)++;	\
	} while (0)

#define OMI_LI_WRIT(VAL, PTR)			\
	do					\
	{					\
		omi_li	obj;			\
		obj.value = (VAL);		\
		*(PTR)++  = obj.octet[1];	\
		*(PTR)++  = obj.octet[0];	\
	} while (0)

#define OMI_VI_READ(VO, PTR)			\
	do					\
	{					\
		(VO)->octet[3] = *(PTR)++;	\
		(VO)->octet[2] = *(PTR)++;	\
		(VO)->octet[1] = *(PTR)++;	\
		(VO)->octet[0] = *(PTR)++;	\
	} while (0)

#define OMI_VI_WRIT(VAL, PTR)			\
	do					\
	{					\
		omi_vi	obj;			\
		obj.value = (VAL);		\
		*(PTR)++  = obj.octet[3];	\
		*(PTR)++  = obj.octet[2];	\
		*(PTR)++  = obj.octet[1];	\
		*(PTR)++  = obj.octet[0];	\
	} while (0)

#else /* defined(BIG_END) */

#ifdef LTL_END

#define OMI_SI_READ(VO, PTR)			\
	do					\
	{					\
		(VO)->octet[0] = *(PTR)++;	\
	} while (0)

#define OMI_SI_WRIT(VAL, PTR)			\
	do					\
	{					\
		omi_si	obj;			\
		obj.value = (VAL);		\
		*(PTR)++  = obj.octet[0];	\
	} while (0)

#define OMI_LI_READ(VO, PTR)			\
	do					\
	{					\
		(VO)->octet[0] = *(PTR)++;	\
		(VO)->octet[1] = *(PTR)++;	\
	} while (0)

#define OMI_LI_WRIT(VAL, PTR)			\
	do					\
	{					\
		omi_li	obj;			\
		obj.value = (VAL);		\
		*(PTR)++  = obj.octet[0];	\
		*(PTR)++  = obj.octet[1];	\
	} while (0)

#define OMI_VI_READ(VO, PTR)			\
	do					\
	{					\
		(VO)->octet[0] = *(PTR)++;	\
		(VO)->octet[1] = *(PTR)++;	\
		(VO)->octet[2] = *(PTR)++;	\
		(VO)->octet[3] = *(PTR)++;	\
	} while (0)

#define OMI_VI_WRIT(VAL, PTR)			\
	do					\
	{					\
		omi_vi	obj;			\
		obj.value = (VAL);		\
		*(PTR)++  = obj.octet[0];	\
		*(PTR)++  = obj.octet[1];	\
		*(PTR)++  = obj.octet[2];	\
		*(PTR)++  = obj.octet[3];	\
	} while (0)

#endif /* defined(LTL_END) */

#endif /* !defined(BIG_END) */

/*  OMI request header; common to all operations */
typedef struct	omi_req_hdr
{
	omi_li	op_class;
	omi_si	op_type;
	omi_li	user;
	omi_li	group;
	omi_li	seq;
	omi_li	ref;
} omi_req_hdr;

typedef struct	omi_err_hdr
{
	uns_short	class;
	uns_char	type;
	uns_short	modifier;
} omi_err_hdr;

typedef uns_short omi_status;

/*  OMI connection state */
typedef enum	omi_cn_st
{
	OMI_ST_CONN,
	OMI_ST_DISC,
	OMI_ST_CLOS
} omi_cn_st;

/*  OMI per-connection statistics */
typedef struct	omi_cn_stat
{
	int			id;
	time_t			start;
	struct addrinfo		ai;
	struct sockaddr_storage sas;
	int			bytes_recv;
	int			bytes_send;
	int			xact[OMI_OP_MAX];
	int			errs[OMI_ER_MAX];
} omi_cn_stat;

/*  Incomplete structure reference ("gd_addr" in gdsfhead.h) */
typedef struct gd_addr_struct	 ga_struct;
/*  Incomplete structure reference ("rc_oflow" in rc/rc_oflow.h) */
typedef struct rc_oflow	 oof_struct;


/* PING parameters */
#define MIN_TIMEOUT_INTERVAL		60 /* seconds */
#define TIMEOUT_INTERVAL	       180 /* seconds */
#define PING_TIMEOUT			10
#define MAX_PING_CNT			5

/*  OMI connection information */
typedef struct omi_conn	 omi_conn;
struct omi_conn
{
	omi_conn	*next;
	omi_fd		fd;
	int		ping_cnt;	/* number of pings we have sent to machine */
	int		timeout;	/* time when we should next check this connection */
	int		bsiz;
	char		*buff;
	char		*bptr;
	char		*xptr;
	char		ag_name[MAX_USER_NAME];
	int		blen;
	int		exts;
	omi_cn_st	state;
	ga_struct	*ga;
	oof_struct	*of;
	omi_fd		pklog;
	omi_cn_stat	stats;
};

/*  OMI meta-connection statistics */
typedef struct	omi_cl_stat
{
	int	conn;
	int	disc;
	int	clos;
} omi_cl_stat;

/* OMI connection linked list */
typedef struct	omi_conn_ll
{
	omi_fd		nve;
	omi_conn	*head;
	omi_conn	*tail;
	omi_cl_stat	stats;
	omi_cn_stat	st_cn;
} omi_conn_ll;

/*  Operation pointers */
typedef int (*omi_op)(/* omi_conn *, char * */);

/*  Routines */
int		omi_prc_conn (omi_conn *, char *, char *, char *);
int		omi_prc_stat (omi_conn *, char *, char *, char *);
int		omi_prc_disc (omi_conn *, char *, char *, char *);
int		omi_prc_set  (omi_conn *, char *, char *, char *);
int		omi_prc_setp (omi_conn *, char *, char *, char *);
int		omi_prc_sete (omi_conn *, char *, char *, char *);
int		omi_prc_kill (omi_conn *, char *, char *, char *);
int		omi_prc_incr (omi_conn *, char *, char *, char *);
int		omi_prc_get  (omi_conn *, char *, char *, char *);
int		omi_prc_def  (omi_conn *, char *, char *, char *);
int		omi_prc_ordr (omi_conn *, char *, char *, char *);
int		omi_prc_next (omi_conn *, char *, char *, char *);
int		omi_prc_qry  (omi_conn *, char *, char *, char *);
int		omi_prc_rord (omi_conn *, char *, char *, char *);
int		omi_prc_lock (omi_conn *, char *, char *, char *);
int		omi_prc_unlk (omi_conn *, char *, char *, char *);
int		omi_prc_unlc (omi_conn *, char *, char *, char *);
int		omi_prc_unla (omi_conn *, char *, char *, char *);
void		omi_buff_rsp (omi_req_hdr *, omi_err_hdr *, omi_status, char *, int);
int		omi_gvextnam (omi_conn *, uns_short, char *);
int		omi_lkextnam (omi_conn *, uns_short, char *, char *);
void		omi_dump_pkt (omi_conn *);

#ifdef __STDC__
#define P(X) X
#else /* defined(__STDC__) */
#define P(X) ()
#endif /* !defined(__STDC__) */

int		get_ping_rsp  P((void));
int		icmp_ping     P((int conn));
int		init_ping     P((void));
int		in_cksum      P((u_short *addr, int len));

#undef P
#endif /* !defined(OMI_H) */