libtmcd.h 3.3 KB
Newer Older
1 2
/*
 * Copyright (c) 2008-2009 University of Utah and the Flux Group.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
 * 
 * {{{EMULAB-LICENSE
 * 
 * This file is part of the Emulab network testbed software.
 * 
 * This file is free software: you can redistribute it and/or modify it
 * under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or (at
 * your option) any later version.
 * 
 * This file is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public
 * License for more details.
 * 
 * You should have received a copy of the GNU Affero General Public License
 * along with this file.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * }}}
22 23
 */

24 25 26 27
#ifndef _LIBTMCD_H_
#define _LIBTMCD_H_

#include <netinet/in.h>
28
#include <mysql/mysql.h>
29 30 31
#include <arpa/inet.h>
#include "tbdefs.h"

32 33 34 35 36 37 38
#ifdef EVENTSYS
#include "event.h"
#endif

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

39
#define TMCD_STATUS_OK				0
Ryan Jackson's avatar
Ryan Jackson committed
40
#define TMCD_STATUS_UNKNOWN_COMMAND		1
41 42 43 44 45
#define TMCD_STATUS_INVALID_UDP_REQUEST		2
#define TMCD_STATUS_INVALID_REMOTE_UDP_REQUEST	3
#define TMCD_STATUS_REQUIRES_ENCRYPTION		4
#define TMCD_STATUS_NODE_NOT_ALLOCATED		5
#define TMCD_STATUS_MALLOC_FAILED		6
Ryan Jackson's avatar
Ryan Jackson committed
46
#define TMCD_STATUS_COMMAND_FAILED		7
47

48 49 50 51 52
/*
 * 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 {
53 54 55 56 57 58 59 60 61 62 63 64 65
	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;
66 67 68 69 70 71 72
	int		version;
	struct in_addr  client;
	int		allocated;
	int		jailflag;
	int		isvnode;
	int		issubnode;
	int		islocal;
73
	int		isdedicatedwa;
74 75 76 77 78 79 80
	int		iscontrol;
	int		isplabdslice;
	int		isplabsvc;
	int		elab_in_elab;
        int		singlenet;	  /* Modifier for elab_in_elab */
	int		update_accounts;
	int		exptidx;
81 82 83 84
	int		creator_idx;
	int		swapper_idx;
	int		swapper_isadmin;
	int		genisliver_idx;
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
	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];
103
	char		tmcd_redirect[TBDB_FLEN_TINYTEXT];
104
	char		privkey[TBDB_FLEN_PRIVKEY+1];
105 106 107 108
} tmcdreq_t;

typedef struct {
	char		*data;
109
	char		*type;
110 111 112
	int		length;
} tmcdresp_t;

113
int	iptonodeid(tmcdreq_t *reqp, struct in_addr ipaddr, char* nodekey);
114
int	checkprivkey(tmcdreq_t *reqp, struct in_addr, char *);
115 116
int	checkdbredirect(tmcdreq_t *);
void	tmcd_free_response(tmcdresp_t *);
117
int tmcd_handle_request(tmcdreq_t *, tmcdresp_t **, char *, char *);
118
int tmcd_init(tmcdreq_t *reqp, struct in_addr *, char *);
119 120

#endif /* _LIBTMCD_H_ */