console-server.c (e258e51fd256c275cd58a104a6bcb379ff1534f9) console-server.c (b14ca19cf380efbf7a96a348cc6fc81e75bf0591)
1/**
2 * Console server process for OpenBMC
3 *
4 * Copyright © 2016 IBM Corporation
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at

--- 20 unchanged lines hidden (view full) ---

29#include <string.h>
30#include <getopt.h>
31#include <limits.h>
32#include <time.h>
33#include <termios.h>
34
35#include <sys/types.h>
36#include <sys/time.h>
1/**
2 * Console server process for OpenBMC
3 *
4 * Copyright © 2016 IBM Corporation
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at

--- 20 unchanged lines hidden (view full) ---

29#include <string.h>
30#include <getopt.h>
31#include <limits.h>
32#include <time.h>
33#include <termios.h>
34
35#include <sys/types.h>
36#include <sys/time.h>
37#include <sys/socket.h>
37#include <poll.h>
38
39#include "console-server.h"
40
41/* size of the shared backlog ringbuffer */
42const size_t buffer_size = 128ul * 1024ul;
43
44/* state shared with the signal handler */

--- 252 unchanged lines hidden (view full) ---

297 return rc;
298}
299
300int console_data_out(struct console *console, const uint8_t *data, size_t len)
301{
302 return write_buf_to_fd(console->tty_fd, data, len);
303}
304
38#include <poll.h>
39
40#include "console-server.h"
41
42/* size of the shared backlog ringbuffer */
43const size_t buffer_size = 128ul * 1024ul;
44
45/* state shared with the signal handler */

--- 252 unchanged lines hidden (view full) ---

298 return rc;
299}
300
301int console_data_out(struct console *console, const uint8_t *data, size_t len)
302{
303 return write_buf_to_fd(console->tty_fd, data, len);
304}
305
306/* Read console if from config and prepare a socket name */
307static int set_socket_info(struct console *console, struct config *config)
308{
309 ssize_t len;
310
311 console->console_id = config_get_value(config, "socket-id");
312 if (!console->console_id) {
313 warnx("Error: The socket-id is not set in the config file");
314 return EXIT_FAILURE;
315 }
316
317 /* Get the socket name/path */
318 len = console_socket_path(console->socket_name, console->console_id);
319 if (len < 0) {
320 warn("Failed to set socket path: %s", strerror(errno));
321 return EXIT_FAILURE;
322 }
323
324 /* Socket name is not a null terminated string hence save the length */
325 console->socket_name_len = len;
326
327 return 0;
328}
329
305static void handlers_init(struct console *console, struct config *config)
306{
307 /* NOLINTBEGIN(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp) */
308 extern struct handler *__start_handlers;
309 extern struct handler *__stop_handlers;
310 /* NOLINTEND(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp) */
311 struct handler *handler;
312 int i;

--- 414 unchanged lines hidden (view full) ---

727 }
728
729 if (!config_tty_kname) {
730 warnx("No TTY device specified");
731 usage(argv[0]);
732 return EXIT_FAILURE;
733 }
734
330static void handlers_init(struct console *console, struct config *config)
331{
332 /* NOLINTBEGIN(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp) */
333 extern struct handler *__start_handlers;
334 extern struct handler *__stop_handlers;
335 /* NOLINTEND(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp) */
336 struct handler *handler;
337 int i;

--- 414 unchanged lines hidden (view full) ---

752 }
753
754 if (!config_tty_kname) {
755 warnx("No TTY device specified");
756 usage(argv[0]);
757 return EXIT_FAILURE;
758 }
759
760 if (set_socket_info(console, config)) {
761 return EXIT_FAILURE;
762 }
763
735 console->tty_kname = config_tty_kname;
736
737 console->console_id = config_get_value(config, "socket-id");
738 if (!console->console_id) {
739 warnx("Error: The socket-id is not set in the config file");
740 return EXIT_FAILURE;
741 }
742

--- 25 unchanged lines hidden ---
764 console->tty_kname = config_tty_kname;
765
766 console->console_id = config_get_value(config, "socket-id");
767 if (!console->console_id) {
768 warnx("Error: The socket-id is not set in the config file");
769 return EXIT_FAILURE;
770 }
771

--- 25 unchanged lines hidden ---