47 #include <sys/types.h>
49 #include <sys/socket.h>
52 #include <sys/ioctl.h>
58 #include <systemd/sd-daemon.h>
87 struct sockaddr_un clnt_addr;
89 clnt_len =
sizeof(clnt_addr);
91 if ((new_sock = accept(
commonSocket, (
struct sockaddr *) &clnt_addr,
94 Log2(PCSC_LOG_CRITICAL,
"Accept on common socket: %s",
99 *pdwClientID = new_sock;
124 struct sockaddr_un un;
130 if ((
commonSocket = socket(PF_UNIX, SOCK_STREAM, 0)) < 0)
132 Log2(PCSC_LOG_CRITICAL,
"Unable to create common socket: %s",
137 memset(&sa, 0,
sizeof sa);
138 sa.un.sun_family = AF_UNIX;
139 strncpy(sa.un.sun_path, PCSCLITE_CSOCK_NAME,
sizeof sa.un.sun_path);
140 (void)
remove(PCSCLITE_CSOCK_NAME);
144 Log2(PCSC_LOG_CRITICAL,
"Unable to bind common socket: %s",
151 Log2(PCSC_LOG_CRITICAL,
"Unable to listen common socket: %s",
159 (void)chmod(PCSCLITE_CSOCK_NAME, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
164 #ifdef USE_LIBSYSTEMD
177 INTERNAL int32_t ListenExistingSocket(
int fd)
179 if (!sd_is_socket(fd, AF_UNIX, SOCK_STREAM, -1))
181 Log1(PCSC_LOG_CRITICAL,
"Passed FD is not an UNIX socket");
203 #if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
224 selret = select(
commonSocket + 1, &read_fd, (fd_set *) NULL,
238 Log2(PCSC_LOG_CRITICAL,
"Select returns with failure: %s",
252 Log1(PCSC_LOG_DEBUG,
"Common channel packet arrival");
256 "error in ProcessCommonChannelRequest: %d", *pdwClientID);
264 "ProcessCommonChannelRequest detects: %d", *pdwClientID);
static int ProcessCommonChannelRequest(uint32_t *pdwClientID)
Accepts a Client connection.
This defines some structures and #defines to be used over the transport layer.
INTERNAL int32_t InitializeSocket(void)
Prepares the communication channel used by the server to talk to the clients.
static int commonSocket
Socket to a file, used for clients-server communication.
INTERNAL int32_t ProcessEventsServer(uint32_t *pdwClientID)
Looks for messages sent by clients.
This handles smart card reader communications.