obmc-console-server: bind/connect with the correct sockaddr size

Abstract unix sockets start with the nul-charater, but are not nul
terminated. In fact, the nul-character has no meaning in the path.
According to the man page unix(7),

abstract:  an abstract socket address is distinguished (from a pathname
           socket) by the fact that sun_path[0] is a null byte ('\0').
           The socket's address in  this  namespace is  given by the
           additional bytes in sun_path that are covered by the
           specified length of the address structure.  (Null bytes in
           the name have no special significance.)

This means that when calling bind/connect, the size of the sockaddr
structure is not sizeof(sockaddr_un), it is sizeof(sockaddr_un) -
sizeof(sun_path) + (path_len)

Change-Id: I6560ba8b2a25a60644873adf66f02a60ded42b1d
Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
2 files changed
tree: 18cc5c8135b50eb42f0fe7583ee81e4b571d7e99
  1. test/
  2. .gitignore
  3. .travis.yml
  4. bootstrap.sh
  5. config.c
  6. configure.ac
  7. console-client.c
  8. console-server.c
  9. console-server.h
  10. console-socket.c
  11. LICENSE
  12. log-handler.c
  13. MAINTAINERS
  14. Makefile.am
  15. obmc-console.conf.sample
  16. README.md
  17. ringbuffer.c
  18. socket-handler.c
  19. tty-handler.c
  20. util.c
README.md

To Build

Note: In addition to a toolchain and autoconf tools, this requires autotools-archive to be installed.

To build this project, run the following shell commands:

./bootstrap.sh
./configure ${CONFIGURE_FLAGS}
make

To fully clean the repository, run:

./bootstrap.sh clean

To Run Server

Running the server requires a serial port (e.g. /dev/ttyS0):

touch obmc-console.conf
./obmc-console-server --config obmc-console.conf ttyS0

To Connect Client

To connect to the server, simply run the client:

./obmc-console-client

To disconnect the client, use the standard ~. combination.