Dateianhang 'ipmitool-1.6.0-tyan.diff'
Herunterladen 1 diff -urN ipmitool-1.6.0/configure.in ipmitool-1.6.0-tyan/configure.in
2 --- ipmitool-1.6.0/configure.in 2004-09-10 22:10:29.000000000 +0200
3 +++ ipmitool-1.6.0-tyan/configure.in 2004-12-23 19:26:34.000000000 +0100
4 @@ -1,11 +1,10 @@
5 dnl
6 dnl autoconf for ipmitool
7 dnl
8 -AC_INIT([src/ipmitool.c])
9 +AC_INIT([ipmitool], [1.6.0])
10 AC_CANONICAL_SYSTEM
11 -AM_INIT_AUTOMAKE([ipmitool], [1.6.0])
12 +AM_INIT_AUTOMAKE([foreign])
13 AM_CONFIG_HEADER(config.h)
14 -AC_CONFIG_SRCDIR([src/ipmitool.c])
15 AC_PREREQ(2.50)
16 AC_SUBST(ac_configure_args)
17
18 diff -urN ipmitool-1.6.0/include/ipmitool/ipmi.h ipmitool-1.6.0-tyan/include/ipmitool/ipmi.h
19 --- ipmitool-1.6.0/include/ipmitool/ipmi.h 2004-09-10 22:11:59.000000000 +0200
20 +++ ipmitool-1.6.0-tyan/include/ipmitool/ipmi.h 2004-12-23 19:24:39.000000000 +0100
21 @@ -238,6 +238,7 @@
22 #define IPMI_NETFN_STORAGE 0xa
23 #define IPMI_NETFN_TRANSPORT 0xc
24 #define IPMI_NETFN_ISOL 0x34
25 +#define IPMI_NETFN_OEM 0x30
26
27 #define IPMI_BMC_SLAVE_ADDR 0x20
28 #define IPMI_REMOTE_SWID 0x81
29 diff -urN ipmitool-1.6.0/include/ipmitool/ipmi_oem_tyan.h ipmitool-1.6.0-tyan/include/ipmitool/ipmi_oem_tyan.h
30 --- ipmitool-1.6.0/include/ipmitool/ipmi_oem_tyan.h 1970-01-01 01:00:00.000000000 +0100
31 +++ ipmitool-1.6.0-tyan/include/ipmitool/ipmi_oem_tyan.h 2004-12-23 19:24:39.000000000 +0100
32 @@ -0,0 +1,15 @@
33 +#ifndef IPMI_OEM_TYAN_H
34 +#define IPMI_OEM_TYAN_H
35 +
36 +#include <ipmitool/ipmi.h>
37 +
38 +#define IPMI_OEM_TYAN_BOOTDEVICE_BIOS 0x1
39 +
40 +#define IPMI_OEM_TYAN_COMMAND_CONREDIR_STOP 0x2
41 +#define IPMI_OEM_TYAN_COMMAND_CONREDIR_STROKE 0x3
42 +#define IPMI_OEM_TYAN_COMMAND_BOOTDEVICE 0x4
43 +#define IPMI_OEM_TYAN_COMMAND_CONREDIR_START 0x6
44 +
45 +int ipmi_oem_tyan_main(struct ipmi_intf *, int, char **);
46 +
47 +#endif /*IPMI_OEM_TYAN_H*/
48 diff -urN ipmitool-1.6.0/lib/ipmi_oem_tyan.c ipmitool-1.6.0-tyan/lib/ipmi_oem_tyan.c
49 --- ipmitool-1.6.0/lib/ipmi_oem_tyan.c 1970-01-01 01:00:00.000000000 +0100
50 +++ ipmitool-1.6.0-tyan/lib/ipmi_oem_tyan.c 2004-12-24 17:22:44.000000000 +0100
51 @@ -0,0 +1,253 @@
52 +#include <signal.h>
53 +#include <stdbool.h>
54 +#include <stdlib.h>
55 +#include <string.h>
56 +#include <stdio.h>
57 +#include <sys/poll.h>
58 +#include <termios.h>
59 +#include <unistd.h>
60 +
61 +#include <ipmitool/helper.h>
62 +#include <ipmitool/ipmi.h>
63 +#include <ipmitool/ipmi_intf.h>
64 +#include <ipmitool/ipmi_oem_tyan.h>
65 +
66 +extern int verbose;
67 +
68 +static const struct valstr ipmi_oem_tyan_bootdevice_vals[] = {
69 + { 0x01, "BIOS" },
70 + { 0x00, NULL }
71 +};
72 +
73 +static int ipmi_oem_tyan_bootdevice(struct ipmi_intf * intf, unsigned char ctl)
74 +{
75 + struct ipmi_rs * rsp;
76 + struct ipmi_rq req;
77 + unsigned char data[4];
78 +
79 + ipmi_intf_session_set_privlvl(intf, IPMI_SESSION_PRIV_ADMIN);
80 +
81 + data[0] = ctl;
82 + data[1] = 0;
83 + data[2] = 0;
84 + data[3] = 0;
85 +
86 + memset(&req, 0, sizeof(req));
87 + req.msg.netfn = IPMI_NETFN_OEM;
88 + req.msg.cmd = IPMI_OEM_TYAN_COMMAND_BOOTDEVICE;
89 + req.msg.data = data;
90 + req.msg.data_len = sizeof(data);
91 +
92 + rsp = intf->sendrecv(intf, &req);
93 +
94 + if (!rsp || rsp->ccode) {
95 + printf("Unable to set Bootdevice to %s\n",
96 + val2str(ctl, ipmi_oem_tyan_bootdevice_vals));
97 + return -1;
98 + } else {
99 + printf("Bootdevice: %s\n",
100 + val2str(ctl, ipmi_oem_tyan_bootdevice_vals));
101 + }
102 + return 0;
103 +}
104 +
105 +union conredir_data
106 +{
107 + struct
108 + {
109 + struct in_addr sin_addr; /* Internet address. */
110 + in_port_t sin_port; /* Port number. */
111 + }
112 + addr __attribute__((packed));
113 + unsigned char data[7];
114 +};
115 +
116 +static bool _in_raw_mode;
117 +static struct termios _saved_tio;
118 +
119 +static int ipmi_oem_tyan_conredir_stop();
120 +
121 +static void leave_raw_mode(void)
122 +{
123 + if (!_in_raw_mode)
124 + return;
125 + if (tcsetattr(fileno(stdin), TCSADRAIN, &_saved_tio) == -1)
126 + perror("tcsetattr");
127 + else
128 + _in_raw_mode = false;
129 +}
130 +
131 +static void enter_raw_mode(void)
132 +{
133 + struct termios tio;
134 + if (tcgetattr(fileno(stdin), &tio) == -1) {
135 + perror("tcgetattr");
136 + return;
137 + }
138 + _saved_tio = tio;
139 + tio.c_iflag &= ~(ISTRIP | INLCR | IGNCR | ICRNL | IXON | IXANY | IXOFF);
140 + tio.c_lflag &= ~(ICANON | ECHO | ECHOE | ECHOK | ECHONL | IEXTEN);
141 + tio.c_oflag &= ~OPOST;
142 + tio.c_cc[VMIN] = 1;
143 + tio.c_cc[VTIME] = 0;
144 + if (tcsetattr(fileno(stdin), TCSADRAIN, &tio) == -1)
145 + perror("tcsetattr");
146 + else
147 + _in_raw_mode = true;
148 +}
149 +
150 +static void sighandler(int sig)
151 +{
152 + switch (sig)
153 + {
154 + }
155 +}
156 +
157 +static int ipmi_oem_tyan_conredir(struct ipmi_intf * intf)
158 +{
159 + struct ipmi_rs *rsp;
160 + struct ipmi_rq req;
161 + union conredir_data conredir_data;
162 + struct sockaddr_in addr;
163 + socklen_t len = sizeof(addr);
164 + int fd, ret = -1;
165 + struct pollfd fds[2] =
166 + {
167 + { 0, POLLIN, 0 },
168 + { 0, POLLIN, 0 },
169 + };
170 + struct sigaction act, oldact;
171 +
172 + ipmi_intf_session_set_privlvl(intf, IPMI_SESSION_PRIV_ADMIN);
173 +
174 + if (!intf->opened)
175 + intf->open(intf);
176 +
177 + if (getsockname(intf->fd, (struct sockaddr *)&addr, &len) != 0) {
178 + perror("getsockname");
179 + return -1;
180 + }
181 + conredir_data.addr.sin_addr = addr.sin_addr;
182 + conredir_data.addr.sin_port = addr.sin_port = htons(6666);
183 +
184 + fd = socket(PF_INET, SOCK_DGRAM, 0);
185 + if (bind(fd, (struct sockaddr *)&addr, sizeof(addr)) != 0) {
186 + perror("bind");
187 + return -1;
188 + }
189 + conredir_data.data[6] = 0;
190 +
191 + memset(&req, 0, sizeof(req));
192 + req.msg.netfn = IPMI_NETFN_OEM;
193 + req.msg.cmd = IPMI_OEM_TYAN_COMMAND_CONREDIR_START;
194 + req.msg.data = conredir_data.data;
195 + req.msg.data_len = sizeof(conredir_data.data);
196 +
197 + rsp = intf->sendrecv(intf, &req);
198 +
199 + if (!rsp || rsp->ccode) {
200 + printf("Unable to start console redirection\n");
201 + goto error;
202 + } else {
203 + printf("Established console redirection\n");
204 + }
205 +
206 + memset(&act, 0, sizeof(act));
207 + act.sa_handler = sighandler;
208 + act.sa_flags = 0;
209 +
210 + if (sigemptyset(&act.sa_mask) < 0) {
211 + psignal(SIGINT, "unable to empty signal set");
212 + goto error;
213 + }
214 +
215 + if (sigaction(SIGINT, &act, &oldact) < 0) {
216 + psignal(SIGINT, "unable to register handler");
217 + goto error;
218 + }
219 +
220 + enter_raw_mode();
221 +
222 + fds[1].fd = fd;
223 +
224 + while (1) {
225 + char buf[1024];
226 + int r = poll(fds, 2, -1);
227 + if (r < 0)
228 + break;
229 +
230 + if (fds[0].revents & POLLIN) {
231 + r = read(fds[0].fd, buf + 1, 255);
232 + req.msg.cmd = IPMI_OEM_TYAN_COMMAND_CONREDIR_STROKE;
233 + req.msg.data = buf;
234 + buf[0] = r + 1;
235 + req.msg.data_len = r + 1;
236 +
237 + rsp = intf->sendrecv(intf, &req);
238 + }
239 + else if (fds[1].revents & POLLIN) {
240 + char *tmp = buf;
241 + r = read(fds[1].fd, buf, sizeof(buf));
242 + while (r > 0)
243 + if (!*tmp) {
244 + tmp++;
245 + r--;
246 + }
247 + else
248 + break;
249 + if (r > 0)
250 + write(1, tmp, r);
251 + }
252 + }
253 +
254 + leave_raw_mode();
255 +
256 + req.msg.cmd = IPMI_OEM_TYAN_COMMAND_CONREDIR_STOP;
257 + req.msg.data = conredir_data.data;
258 + req.msg.data_len = sizeof(conredir_data.data);
259 +
260 + rsp = intf->sendrecv(intf, &req);
261 +
262 + ret = 0;
263 +
264 +error:
265 +
266 + if (sigaction(SIGINT, &oldact, NULL) < 0)
267 + psignal(SIGINT, "unable to reset handler");
268 +
269 + close (fd);
270 +
271 + return ret;
272 +}
273 +
274 +int ipmi_oem_tyan_main(struct ipmi_intf * intf, int argc, char ** argv)
275 +{
276 + if (!argc || !strncmp(argv[0], "help", 4)) {
277 + printf("OEM Tyan Commands: bootdevice\n");
278 + return 0;
279 + }
280 + else if (!strncmp(argv[0], "bootdevice", 10)) {
281 + unsigned char ctl = 0;
282 +
283 + if (argc < 2 || !strncmp(argv[1], "help", 4)) {
284 + printf("chassis power Commands: status, on, off, cycle, reset, diag, soft\n");
285 + return 0;
286 + }
287 +
288 + if (!strncmp(argv[1], "bios", 4))
289 + ctl = IPMI_OEM_TYAN_BOOTDEVICE_BIOS;
290 + else {
291 + printf("Invalid chassis power command: %s\n", argv[1]);
292 + return -1;
293 + }
294 + return ipmi_oem_tyan_bootdevice(intf, ctl);
295 + }
296 + else if (!strncmp(argv[0], "conredir", 0)) {
297 + return ipmi_oem_tyan_conredir(intf);
298 + }
299 + else {
300 + printf("Invalid Tyan command: %s\n", argv[0]);
301 + return -1;
302 + }
303 + return 0;
304 +}
305 diff -urN ipmitool-1.6.0/lib/Makefile.am ipmitool-1.6.0-tyan/lib/Makefile.am
306 --- ipmitool-1.6.0/lib/Makefile.am 2004-09-01 01:11:45.000000000 +0200
307 +++ ipmitool-1.6.0-tyan/lib/Makefile.am 2004-12-23 19:24:39.000000000 +0100
308 @@ -39,7 +39,8 @@
309 libipmitool_la_SOURCES = helper.c ipmi_sdr.c ipmi_sel.c ipmi_sol.c ipmi_isol.c \
310 ipmi_lanp.c ipmi_fru.c ipmi_chassis.c ipmi_bmc.c log.c \
311 dimm_spd.c ipmi_sensor.c ipmi_channel.c ipmi_event.c \
312 - ipmi_session.c ipmi_strings.c ipmi_user.c ipmi_raw.c
313 + ipmi_session.c ipmi_strings.c ipmi_user.c ipmi_raw.c \
314 + ipmi_oem_tyan.c
315 libipmitool_la_LDFLAGS = -export-dynamic
316 libipmitool_la_LIBADD = -lm
317 libipmitool_la_DEPENDENCIES =
318 diff -urN ipmitool-1.6.0/lib/test ipmitool-1.6.0-tyan/lib/test
319 --- ipmitool-1.6.0/lib/test 1970-01-01 01:00:00.000000000 +0100
320 +++ ipmitool-1.6.0-tyan/lib/test 2004-12-24 15:52:05.000000000 +0100
321 @@ -0,0 +1,38 @@
322 +void
323 +leave_raw_mode(void)
324 +{
325 + if (!_in_raw_mode)
326 + return;
327 + if (tcsetattr(fileno(stdin), TCSADRAIN, &_saved_tio) == -1)
328 + perror("tcsetattr");
329 + else
330 + _in_raw_mode = 0;
331 +}
332 +
333 +
334 +
335 +void
336 +enter_raw_mode(void)
337 +{
338 + struct termios tio;
339 + if (tcgetattr(fileno(stdin), &tio) == -1) {
340 + perror("tcgetattr");
341 + return;
342 + }
343 + _saved_tio = tio;
344 + tio.c_iflag |= IGNPAR;
345 + tio.c_iflag &= ~(ISTRIP | INLCR | IGNCR | ICRNL | IXON | IXANY | IXOFF)\
346 + ;
347 + tio.c_lflag &= ~(ISIG | ICANON | ECHO | ECHOE | ECHOK | ECHONL);
348 + // #ifdef IEXTEN
349 + tio.c_lflag &= ~IEXTEN;
350 + // #endif
351 + tio.c_oflag &= ~OPOST;
352 + tio.c_cc[VMIN] = 1;
353 + tio.c_cc[VTIME] = 0;
354 + if (tcsetattr(fileno(stdin), TCSADRAIN, &tio) == -1)
355 + perror("tcsetattr");
356 + else
357 + _in_raw_mode = 1;
358 +}
359 +
360 diff -urN ipmitool-1.6.0/src/ipmitool.c ipmitool-1.6.0-tyan/src/ipmitool.c
361 --- ipmitool-1.6.0/src/ipmitool.c 2004-09-04 00:19:32.000000000 +0200
362 +++ ipmitool-1.6.0-tyan/src/ipmitool.c 2004-12-24 23:08:37.000000000 +0100
363 @@ -40,6 +40,7 @@
364 #include <stdlib.h>
365 #include <string.h>
366 #include <ctype.h>
367 +#include <signal.h>
368
369 #include <ipmitool/helper.h>
370 #include <ipmitool/log.h>
371 @@ -60,6 +61,7 @@
372 #include <ipmitool/ipmi_event.h>
373 #include <ipmitool/ipmi_user.h>
374 #include <ipmitool/ipmi_raw.h>
375 +#include <ipmitool/ipmi_oem_tyan.h>
376
377 #ifdef HAVE_CONFIG_H
378 # include <config.h>
379 @@ -73,6 +75,8 @@
380 extern const struct valstr ipmi_privlvl_vals[];
381 extern const struct valstr ipmi_authtype_session_vals[];
382
383 +struct ipmi_intf * intf = NULL;
384 +
385 /* defined in ipmishell.c */
386 extern int ipmi_shell_main(struct ipmi_intf * intf, int argc, char ** argv);
387 extern int ipmi_set_main(struct ipmi_intf * intf, int argc, char ** argv);
388 @@ -100,6 +104,7 @@
389 { ipmi_shell_main, "shell", "Launch interactive IPMI shell" },
390 { ipmi_exec_main, "exec", "Run list of commands from file" },
391 { ipmi_set_main, "set", "Set runtime variable for shell and exec" },
392 + { ipmi_oem_tyan_main, "oem-tyan", "OEM Tyan" },
393 { NULL },
394 };
395
396 @@ -195,10 +200,20 @@
397 return pass;
398 }
399
400 +static void sighandler (int sig)
401 +{
402 + switch (sig)
403 + {
404 + case SIGINT:
405 + if (intf)
406 + intf->close(intf);
407 + exit(EXIT_SUCCESS);
408 + break;
409 + }
410 +}
411
412 int main(int argc, char ** argv)
413 {
414 - struct ipmi_intf * intf = NULL;
415 unsigned char privlvl = 0;
416 unsigned char target_addr = 0;
417 unsigned char my_addr = 0;
418 @@ -326,6 +341,9 @@
419 goto out_free;
420 }
421
422 + /* init signal handler */
423 + signal_handler(SIGINT, sighandler);
424 +
425 /* load interface */
426 intf = ipmi_intf_load(intfname);
427 if (!intf) {
Gespeicherte Dateianhänge
Um Dateianhänge in eine Seite einzufügen sollte unbedingt eine Angabe wie attachment:dateiname benutzt werden, wie sie auch in der folgenden Liste der Dateien erscheint. Es sollte niemals die URL des Verweises ("laden") kopiert werden, da sich diese jederzeit ändern kann und damit der Verweis auf die Datei brechen würde.Sie dürfen keine Anhänge an diese Seite anhängen!