Main Page | Class List | Directories | File List | Class Members | File Members

ipmi_ui.h File Reference

#include <OpenIPMI/ipmi_types.h>
#include <OpenIPMI/os_handler.h>
#include <OpenIPMI/selector.h>

Go to the source code of this file.

Functions

int ipmi_ui_init (selector_t **selector, int full_screen)
void ipmi_ui_shutdown (void)
void ipmi_ui_set_first_domain (ipmi_domain_id_t fdomain_id)
void ipmi_ui_setup_done (ipmi_domain_t *mc, int err, unsigned int conn_num, unsigned int port_num, int still_connected, void *user_data)

Variables

os_handler_t ipmi_ui_cb_handlers


Function Documentation

int ipmi_ui_init selector_t **  selector,
int  full_screen
 

Definition at line 7055 of file ui.c.

References full_screen, help_cmd(), IEXTEN, init_commands(), init_keypad(), init_win(), ipmi_event_state_size(), ipmi_init(), ipmi_mem_alloc(), ipmi_states_size(), ipmi_thresholds_size(), leave_err(), old_flags, old_termios, redisplay_timeout(), redisplay_timer, sel_alloc_selector(), sel_alloc_timer(), SEL_FD_HANDLER_ENABLED, sel_set_fd_handlers(), sel_set_fd_read_handler(), sel_start_timer(), ui_log(), and user_input_ready().

Referenced by main().

07056 {
07057     int rv;
07058 
07059     full_screen = do_full_screen;
07060 
07061     rv = sel_alloc_selector(&ipmi_ui_cb_handlers, &ui_sel);
07062     if (rv) {
07063         fprintf(stderr, "Could not allocate selector\n");
07064         exit(1);
07065     }
07066 
07067     sel_set_fd_handlers(ui_sel, 0, NULL, user_input_ready, NULL, NULL, NULL);
07068     sel_set_fd_read_handler(ui_sel, 0, SEL_FD_HANDLER_ENABLED);
07069 
07070     ipmi_init(&ipmi_ui_cb_handlers);
07071 
07072     /* This is a dummy allocation just to make sure that the malloc
07073        debugger is working. */
07074     ipmi_mem_alloc(10);
07075 
07076     sensor_states = ipmi_mem_alloc(ipmi_states_size());
07077     if (!sensor_states) {
07078         fprintf(stderr, "Could not allocate sensor states\n");
07079         exit(1);
07080     }
07081 
07082     sensor_event_states = ipmi_mem_alloc(ipmi_event_state_size());
07083     if (!sensor_event_states) {
07084         fprintf(stderr, "Could not allocate sensor event states\n");
07085         exit(1);
07086     }
07087 
07088     sensor_thresholds = ipmi_mem_alloc(ipmi_thresholds_size());
07089     if (!sensor_thresholds) {
07090         fprintf(stderr, "Could not allocate sensor thresholds\n");
07091         exit(1);
07092     }
07093 
07094     rv = init_commands();
07095     if (rv) {
07096         fprintf(stderr, "Could not initialize commands\n");
07097         exit(1);
07098     }
07099 
07100     rv = init_keypad();
07101     if (rv) {
07102         fprintf(stderr, "Could not initialize keymap\n");
07103         exit(1);
07104     }
07105 
07106     if (full_screen) {
07107         rv = init_win();
07108         if (rv) {
07109             fprintf(stderr, "Could not initialize curses\n");
07110             exit(1);
07111         }
07112     } else {
07113         struct termios new_termios;
07114 
07115         tcgetattr(0, &old_termios);
07116         new_termios = old_termios;
07117         new_termios.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP
07118                                  |INLCR|IGNCR|ICRNL|IXON);
07119         new_termios.c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN);
07120         tcsetattr(0, TCSADRAIN, &new_termios);
07121         old_flags = fcntl(0, F_GETFL) & O_ACCMODE;
07122 //      fcntl(0, F_SETFL, old_flags | O_NONBLOCK);
07123     }
07124 
07125     help_cmd(NULL, NULL, NULL);
07126 
07127     ui_log("Starting setup, wait until complete before entering commands.\n");
07128 
07129     {
07130         struct timeval now;
07131         rv = sel_alloc_timer(ui_sel, redisplay_timeout, NULL,
07132                              &redisplay_timer);
07133         if (rv)
07134             leave_err(rv, "sel_alloc_timer");
07135         gettimeofday(&now, NULL);
07136         now.tv_sec += 1;
07137         rv = sel_start_timer(redisplay_timer, &now);
07138         if (rv)
07139             leave_err(rv, "Unable to restart redisplay timer");
07140     }
07141 
07142     *selector = ui_sel;
07143 
07144     return 0;
07145 }

void ipmi_ui_set_first_domain ipmi_domain_id_t  fdomain_id  ) 
 

void ipmi_ui_setup_done ipmi_domain_t mc,
int  err,
unsigned int  conn_num,
unsigned int  port_num,
int  still_connected,
void *  user_data
 

Definition at line 7001 of file ui.c.

References entity_change(), event_handler(), ipmi_domain_add_entity_update_handler(), ipmi_domain_add_event_handler(), ipmi_domain_add_mc_updated_handler(), ipmi_domain_convert_to_id(), ipmi_domain_enable_events(), leave_err(), mc_change(), and ui_log().

Referenced by main(), and new_domain_cmd().

07007 {
07008     int rv;
07009 
07010     if (err)
07011         ui_log("IPMI connection to con.port %d.%d is down"
07012                "  due to error 0x%x\n",
07013                conn_num, port_num, err);
07014     else
07015         ui_log("IPMI connection to con.port %d.%d is up\n",
07016                conn_num, port_num);
07017 
07018     if (!still_connected) {
07019         ui_log("All IPMI connections down\n");
07020         return;
07021     }
07022 
07023     domain_id = ipmi_domain_convert_to_id(domain);
07024 
07025     rv = ipmi_domain_add_event_handler(domain, event_handler, NULL);
07026     if (rv)
07027         leave_err(rv, "ipmi_register_for_events");
07028 
07029     rv = ipmi_domain_enable_events(domain);
07030     if (rv)
07031         leave_err(rv, "ipmi_domain_enable_events");
07032 
07033     rv = ipmi_domain_add_entity_update_handler(domain, entity_change, domain);
07034     if (rv)
07035         leave_err(rv, "ipmi_bmc_set_entity_update_handler");
07036 
07037     rv = ipmi_domain_add_mc_updated_handler(domain, mc_change, domain);
07038     if (rv)
07039         leave_err(rv, "ipmi_bmc_set_entity_update_handler");
07040     pef = NULL;
07041     lanparm = NULL;
07042 }

void ipmi_ui_shutdown void   ) 
 

Definition at line 7148 of file ui.c.

References ipmi_mem_free(), and leave().

Referenced by main().

07149 {
07150     ipmi_mem_free(sensor_states);
07151     sensor_states = NULL;
07152     ipmi_mem_free(sensor_event_states);
07153     sensor_event_states = NULL;
07154     ipmi_mem_free(sensor_thresholds);
07155     sensor_thresholds = NULL;
07156     leave(0, "");
07157 }


Variable Documentation

os_handler_t ipmi_ui_cb_handlers
 

Definition at line 504 of file ui_os.c.

Referenced by main().


© sourcejam.com 2005-2008