connect's addrlen should be sizeof(local), not the contained path's length.
With the previous code, on OS X connect() will fail with ENOENT.
This permits layer23 to work on OS X using the pl2303 driver,
/dev/tty.usbserial , MacPorts arm-elf-gcc and RANLIB=arm-elf-ranlib
Signed-off-by: Harald Welte <laforge@gnumonks.org>
local.sun_path[sizeof(local.sun_path) - 1] = '\0';
rc = connect(ms->l2_wq.bfd.fd, (struct sockaddr *) &local,
- sizeof(local.sun_family) + strlen(local.sun_path));
+ sizeof(local));
if (rc < 0) {
- fprintf(stderr, "Failed to connect to '%s'.\n", local.sun_path);
+ fprintf(stderr, "Failed to connect to '%s': %s\n", local.sun_path,
+ strerror(errno));
close(ms->l2_wq.bfd.fd);
return rc;
}