libtmcd.h 1.95 KB
Newer Older
1 2 3 4
#ifndef _LIBTMCD_H_
#define _LIBTMCD_H_

#include <netinet/in.h>
5
#include <mysql/mysql.h>
6 7 8
#include <arpa/inet.h>
#include "tbdefs.h"

9 10 11 12 13 14 15
#ifdef EVENTSYS
#include "event.h"
#endif

#define DBNAME_SIZE	64
#define HOSTID_SIZE	(32+64)

16 17 18 19 20
/*
 * This structure is passed to each request function. The intent is to
 * reduce the number of DB queries per request to a minimum.
 */
typedef struct {
21 22 23 24 25 26 27 28 29 30 31 32 33
	MYSQL		db;
	int		db_connected;
	char		dbname[DBNAME_SIZE];
	char		prev_dbname[DBNAME_SIZE];
	struct in_addr	myipaddr;
#ifdef EVENTSYS
	event_handle_t	event_handle;
#endif
	char		fshostid[HOSTID_SIZE];
	int		verbose;
	int		debug;
	int		isssl;
	int		istcp;
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
	int		version;
	struct in_addr  client;
	int		allocated;
	int		jailflag;
	int		isvnode;
	int		issubnode;
	int		islocal;
	int		iscontrol;
	int		isplabdslice;
	int		isplabsvc;
	int		elab_in_elab;
        int		singlenet;	  /* Modifier for elab_in_elab */
	int		update_accounts;
	int		exptidx;
	char		nodeid[TBDB_FLEN_NODEID];
	char		vnodeid[TBDB_FLEN_NODEID];
	char		pnodeid[TBDB_FLEN_NODEID]; /* XXX */
	char		pid[TBDB_FLEN_PID];
	char		eid[TBDB_FLEN_EID];
	char		gid[TBDB_FLEN_GID];
	char		nickname[TBDB_FLEN_VNAME];
	char		type[TBDB_FLEN_NODETYPE];
	char		class[TBDB_FLEN_NODECLASS];
        char		ptype[TBDB_FLEN_NODETYPE];	/* Of physnode */
	char		pclass[TBDB_FLEN_NODECLASS];	/* Of physnode */
	char		creator[TBDB_FLEN_UID];
	char		swapper[TBDB_FLEN_UID];
	char		syncserver[TBDB_FLEN_VNAME];	/* The vname */
	char		keyhash[TBDB_FLEN_PRIVKEY];
	char		eventkey[TBDB_FLEN_PRIVKEY];
	char		sfshostid[TBDB_FLEN_SFSHOSTID];
	char		testdb[TBDB_FLEN_TINYTEXT];
} tmcdreq_t;

typedef struct {
	char		*data;
	int		length;
} tmcdresp_t;

73 74
int	iptonodeid(tmcdreq_t *, struct in_addr);
int	checkprivkey(tmcdreq_t *reqp, struct in_addr, char *);
75 76
int	checkdbredirect(tmcdreq_t *);
void	tmcd_free_response(tmcdresp_t *);
77 78
tmcdresp_t *tmcd_handle_request(tmcdreq_t *, int, char *, char *);
int tmcd_init(tmcdreq_t *reqp, struct in_addr *, char *);
79 80

#endif /* _LIBTMCD_H_ */