15115240jeff/*
25115240jeff * Copyright (c) 2005-2007 Voltaire, Inc. All rights reserved.
35115240jeff *
45115240jeff * This software is available to you under a choice of one of two
55115240jeff * licenses.  You may choose to be licensed under the terms of the GNU
65115240jeff * General Public License (GPL) Version 2, available from the file
75115240jeff * COPYING in the main directory of this source tree, or the
85115240jeff * OpenIB.org BSD license below:
95115240jeff *
105115240jeff *     Redistribution and use in source and binary forms, with or
115115240jeff *     without modification, are permitted provided that the following
125115240jeff *     conditions are met:
135115240jeff *
145115240jeff *      - Redistributions of source code must retain the above
155115240jeff *        copyright notice, this list of conditions and the following
165115240jeff *        disclaimer.
175115240jeff *
185115240jeff *      - Redistributions in binary form must reproduce the above
195115240jeff *        copyright notice, this list of conditions and the following
205115240jeff *        disclaimer in the documentation and/or other materials
215115240jeff *        provided with the distribution.
225115240jeff *
235115240jeff * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
245115240jeff * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
255115240jeff * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
265115240jeff * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
275115240jeff * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
285115240jeff * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
295115240jeff * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
305115240jeff * SOFTWARE.
315115240jeff *
325115240jeff */
335115240jeff/*
345115240jeff * Abstract:
355115240jeff * 	Declaration of osm_console_t.
365115240jeff *	This object represents the OpenSM Console object.
375115240jeff *	This object is part of the OpenSM family of objects.
385115240jeff */
395115240jeff
405115240jeff#ifndef _OSM_CONSOLE_IO_H_
415115240jeff#define _OSM_CONSOLE_IO_H_
425115240jeff
435115240jeff#include <opensm/osm_subnet.h>
445115240jeff#include <opensm/osm_log.h>
455115240jeff
465115240jeff#define OSM_DISABLE_CONSOLE      "off"
475115240jeff#define OSM_LOCAL_CONSOLE        "local"
48c187222hselasky#ifdef ENABLE_OSM_CONSOLE_SOCKET
495115240jeff#define OSM_REMOTE_CONSOLE       "socket"
50c187222hselasky#endif
51c187222hselasky#ifdef ENABLE_OSM_CONSOLE_LOOPBACK
525115240jeff#define OSM_LOOPBACK_CONSOLE     "loopback"
53c187222hselasky#endif
545115240jeff#define OSM_CONSOLE_NAME         "OSM Console"
555115240jeff
565115240jeff#define OSM_DEFAULT_CONSOLE      OSM_DISABLE_CONSOLE
575115240jeff#define OSM_DEFAULT_CONSOLE_PORT 10000
585115240jeff#define OSM_DAEMON_NAME          "opensm"
595115240jeff
605115240jeff#define OSM_COMMAND_PROMPT	 "$ "
615115240jeff
625115240jeff#ifdef __cplusplus
635115240jeff#  define BEGIN_C_DECLS extern "C" {
645115240jeff#  define END_C_DECLS   }
655115240jeff#else				/* !__cplusplus */
665115240jeff#  define BEGIN_C_DECLS
675115240jeff#  define END_C_DECLS
685115240jeff#endif				/* __cplusplus */
695115240jeff
705115240jeffBEGIN_C_DECLS
715115240jefftypedef struct osm_console {
725115240jeff	int socket;
735115240jeff	int in_fd;
745115240jeff	int out_fd;
755115240jeff	int authorized;
765115240jeff	FILE *in;
775115240jeff	FILE *out;
785115240jeff	char client_type[32];
795115240jeff	char client_ip[64];
805115240jeff	char client_hn[128];
815115240jeff} osm_console_t;
825115240jeff
835115240jeffvoid osm_console_prompt(FILE * out);
845115240jeffint osm_console_init(osm_subn_opt_t * opt, osm_console_t * p_oct, osm_log_t * p_log);
855115240jeffvoid osm_console_exit(osm_console_t * p_oct, osm_log_t * p_log);
865115240jeffint is_console_enabled(osm_subn_opt_t *p_opt);
875115240jeff
88c187222hselasky#ifdef ENABLE_OSM_CONSOLE_LOOPBACK
895115240jeffint cio_open(osm_console_t * p_oct, int new_fd, osm_log_t * p_log);
90c187222hselaskyint cio_close(osm_console_t * p_oct, osm_log_t * p_log);
915115240jeffint is_authorized(osm_console_t * p_oct);
92c187222hselasky#else
93c187222hselasky#define cio_close(c, log)
945115240jeff#endif
955115240jeff
965115240jeffEND_C_DECLS
975115240jeff#endif				/* _OSM_CONSOLE_IO_H_ */
98