ipmi_tsol.c (8ac8361aca1e257b0f39f2a7883f9870f8c15352) | ipmi_tsol.c (eb54136775f63a6a159f3c55ee4772d7aa363cc4) |
---|---|
1/* 2 * Copyright (c) 2005 Tyan Computer Corp. All Rights Reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * Redistribution of source code must retain the above copyright --- 171 unchanged lines hidden (view full) --- 180{ 181 lprintf(LOG_NOTICE, 182" %c. - terminate connection\n" 183" %c^Z - suspend ipmitool\n" 184" %c^X - suspend ipmitool, but don't restore tty on restart\n" 185" %c? - this message\n" 186" %c%c - send the escape character by typing it twice\n" 187" (Note that escapes are only recognized immediately after newline.)", | 1/* 2 * Copyright (c) 2005 Tyan Computer Corp. All Rights Reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * Redistribution of source code must retain the above copyright --- 171 unchanged lines hidden (view full) --- 180{ 181 lprintf(LOG_NOTICE, 182" %c. - terminate connection\n" 183" %c^Z - suspend ipmitool\n" 184" %c^X - suspend ipmitool, but don't restore tty on restart\n" 185" %c? - this message\n" 186" %c%c - send the escape character by typing it twice\n" 187" (Note that escapes are only recognized immediately after newline.)", |
188 intf->session->sol_escape_char, 189 intf->session->sol_escape_char, 190 intf->session->sol_escape_char, 191 intf->session->sol_escape_char, 192 intf->session->sol_escape_char, 193 intf->session->sol_escape_char); | 188 intf->ssn_params.sol_escape_char, 189 intf->ssn_params.sol_escape_char, 190 intf->ssn_params.sol_escape_char, 191 intf->ssn_params.sol_escape_char, 192 intf->ssn_params.sol_escape_char, 193 intf->ssn_params.sol_escape_char); |
194} 195 196static int 197leave_raw_mode(void) 198{ 199 if (!_in_raw_mode) { 200 return -1; 201 } else if (tcsetattr(fileno(stdin), TCSADRAIN, &_saved_tio) == -1) { --- 57 unchanged lines hidden (view full) --- 259{ 260 static int in_esc = 0; 261 static int last_was_cr = 1; 262 int i; 263 264 for(i = 0; i < len ;) { 265 if (!in_esc) { 266 if (last_was_cr && | 194} 195 196static int 197leave_raw_mode(void) 198{ 199 if (!_in_raw_mode) { 200 return -1; 201 } else if (tcsetattr(fileno(stdin), TCSADRAIN, &_saved_tio) == -1) { --- 57 unchanged lines hidden (view full) --- 259{ 260 static int in_esc = 0; 261 static int last_was_cr = 1; 262 int i; 263 264 for(i = 0; i < len ;) { 265 if (!in_esc) { 266 if (last_was_cr && |
267 (in_buff[i] == intf->session->sol_escape_char)) { | 267 (in_buff[i] == intf->ssn_params.sol_escape_char)) { |
268 in_esc = 1; 269 memmove(in_buff, in_buff + 1, len - i - 1); 270 len--; 271 continue; 272 } 273 } 274 if (in_esc) { | 268 in_esc = 1; 269 memmove(in_buff, in_buff + 1, len - i - 1); 270 len--; 271 continue; 272 } 273 } 274 if (in_esc) { |
275 if (in_buff[i] == intf->session->sol_escape_char) { | 275 if (in_buff[i] == intf->ssn_params.sol_escape_char) { |
276 in_esc = 0; 277 i++; 278 continue; 279 } 280 281 switch (in_buff[i]) { 282 case '.': 283 printf("%c. [terminated ipmitool]\n", | 276 in_esc = 0; 277 i++; 278 continue; 279 } 280 281 switch (in_buff[i]) { 282 case '.': 283 printf("%c. [terminated ipmitool]\n", |
284 intf->session->sol_escape_char); | 284 intf->ssn_params.sol_escape_char); |
285 return -1; 286 case 'Z' - 64: 287 printf("%c^Z [suspend ipmitool]\n", | 285 return -1; 286 case 'Z' - 64: 287 printf("%c^Z [suspend ipmitool]\n", |
288 intf->session->sol_escape_char); | 288 intf->ssn_params.sol_escape_char); |
289 /* Restore tty back to raw */ 290 suspend_self(1); 291 break; 292 case 'X' - 64: 293 printf("%c^X [suspend ipmitool]\n", | 289 /* Restore tty back to raw */ 290 suspend_self(1); 291 break; 292 case 'X' - 64: 293 printf("%c^X [suspend ipmitool]\n", |
294 intf->session->sol_escape_char); | 294 intf->ssn_params.sol_escape_char); |
295 /* Don't restore to raw mode */ 296 suspend_self(0); 297 break; 298 case '?': 299 printf("%c? [ipmitool help]\n", | 295 /* Don't restore to raw mode */ 296 suspend_self(0); 297 break; 298 case '?': 299 printf("%c? [ipmitool help]\n", |
300 intf->session->sol_escape_char); | 300 intf->ssn_params.sol_escape_char); |
301 print_escape_seq(intf); 302 break; 303 } 304 305 memmove(in_buff, (in_buff + 1), (len - i - 1)); 306 len--; 307 in_esc = 0; 308 continue; --- 111 unchanged lines hidden (view full) --- 420 } 421 422 /* create udp socket to receive the packet */ 423 memset(&sin, 0, sizeof(sin)); 424 sin.sin_family = AF_INET; 425 sin.sin_port = htons(port); 426 427 sa_in = (struct sockaddr_in *)&intf->session->addr; | 301 print_escape_seq(intf); 302 break; 303 } 304 305 memmove(in_buff, (in_buff + 1), (len - i - 1)); 306 len--; 307 in_esc = 0; 308 continue; --- 111 unchanged lines hidden (view full) --- 420 } 421 422 /* create udp socket to receive the packet */ 423 memset(&sin, 0, sizeof(sin)); 424 sin.sin_family = AF_INET; 425 sin.sin_port = htons(port); 426 427 sa_in = (struct sockaddr_in *)&intf->session->addr; |
428 result = inet_pton(AF_INET, (const char *)intf->session->hostname, | 428 result = inet_pton(AF_INET, (const char *)intf->ssn_params.hostname, |
429 &sa_in->sin_addr); 430 431 if (result <= 0) { | 429 &sa_in->sin_addr); 430 431 if (result <= 0) { |
432 struct hostent *host = gethostbyname((const char *)intf->session->hostname); | 432 struct hostent *host = gethostbyname((const char *)intf->ssn_params.hostname); |
433 if (host == NULL ) { 434 lprintf(LOG_ERR, "Address lookup for %s failed", | 433 if (host == NULL ) { 434 lprintf(LOG_ERR, "Address lookup for %s failed", |
435 intf->session->hostname); | 435 intf->ssn_params.hostname); |
436 return -1; 437 } 438 if (host->h_addrtype != AF_INET) { 439 lprintf(LOG_ERR, 440 "Address lookup for %s failed. Got %s, expected IPv4 address.", | 436 return -1; 437 } 438 if (host->h_addrtype != AF_INET) { 439 lprintf(LOG_ERR, 440 "Address lookup for %s failed. Got %s, expected IPv4 address.", |
441 intf->session->hostname, | 441 intf->ssn_params.hostname, |
442 (host->h_addrtype == AF_INET6) ? "IPv6" : "Unknown"); 443 return (-1); 444 } 445 sa_in->sin_family = host->h_addrtype; 446 memcpy(&sa_in->sin_addr, host->h_addr_list[0], host->h_length); 447 } 448 449 fd_socket = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP); --- 46 unchanged lines hidden (view full) --- 496 result = ipmi_tsol_start(intf, recvip, port); 497 if (result < 0) { 498 lprintf(LOG_ERR, "Error starting SOL"); 499 close(fd_socket); 500 return (-1); 501 } 502 503 printf("[SOL Session operational. Use %c? for help]\n", | 442 (host->h_addrtype == AF_INET6) ? "IPv6" : "Unknown"); 443 return (-1); 444 } 445 sa_in->sin_family = host->h_addrtype; 446 memcpy(&sa_in->sin_addr, host->h_addr_list[0], host->h_length); 447 } 448 449 fd_socket = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP); --- 46 unchanged lines hidden (view full) --- 496 result = ipmi_tsol_start(intf, recvip, port); 497 if (result < 0) { 498 lprintf(LOG_ERR, "Error starting SOL"); 499 close(fd_socket); 500 return (-1); 501 } 502 503 printf("[SOL Session operational. Use %c? for help]\n", |
504 intf->session->sol_escape_char); | 504 intf->ssn_params.sol_escape_char); |
505 506 gettimeofday(&_start_keepalive, 0); 507 508 fds_wait[0].fd = fd_socket; 509 fds_wait[0].events = POLLIN; 510 fds_wait[0].revents = 0; 511 fds_wait[1].fd = fileno(stdin); 512 fds_wait[1].events = POLLIN; --- 97 unchanged lines hidden --- | 505 506 gettimeofday(&_start_keepalive, 0); 507 508 fds_wait[0].fd = fd_socket; 509 fds_wait[0].events = POLLIN; 510 fds_wait[0].revents = 0; 511 fds_wait[1].fd = fileno(stdin); 512 fds_wait[1].events = POLLIN; --- 97 unchanged lines hidden --- |