47 #include <sys/types.h> 49 #include <sys/socket.h> 52 #include <sys/ioctl.h> 57 #ifdef HAVE_SYS_FILIO_H 58 #include <sys/filio.h> 61 #include <systemd/sd-daemon.h> 91 struct sockaddr_un clnt_addr;
93 clnt_len =
sizeof(clnt_addr);
95 if ((new_sock = accept(
commonSocket, (
struct sockaddr *) &clnt_addr,
98 Log2(PCSC_LOG_CRITICAL,
"Accept on common socket: %s",
103 *pdwClientID = new_sock;
127 struct sockaddr_un un;
133 if ((
commonSocket = socket(PF_UNIX, SOCK_STREAM, 0)) < 0)
135 Log2(PCSC_LOG_CRITICAL,
"Unable to create common socket: %s",
140 memset(&sa, 0,
sizeof sa);
141 sa.un.sun_family = AF_UNIX;
142 strncpy(sa.un.sun_path, PCSCLITE_CSOCK_NAME,
sizeof sa.un.sun_path);
143 (void)
remove(PCSCLITE_CSOCK_NAME);
147 Log2(PCSC_LOG_CRITICAL,
"Unable to bind common socket: %s",
154 Log2(PCSC_LOG_CRITICAL,
"Unable to listen common socket: %s",
162 (void)chmod(PCSCLITE_CSOCK_NAME, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
179 #ifdef USE_LIBSYSTEMD 180 INTERNAL int32_t ListenExistingSocket(
int fd)
182 if (!sd_is_socket(fd, AF_UNIX, SOCK_STREAM, -1))
184 Log1(PCSC_LOG_CRITICAL,
"Passed FD is not an UNIX socket");
206 #if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) 227 selret = select(
commonSocket + 1, &read_fd, (fd_set *) NULL,
241 Log2(PCSC_LOG_CRITICAL,
"Select returns with failure: %s",
255 Log1(PCSC_LOG_DEBUG,
"Common channel packet arrival");
259 "error in ProcessCommonChannelRequest: %d", *pdwClientID);
267 "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 comminication.
This keeps a list of defines for pcsc-lite.
INTERNAL int32_t ProcessEventsServer(uint32_t *pdwClientID)
Acquires a socket passed in from systemd.
This handles smart card reader communications.