rv = waitTimedCondition(0);
if (rv < 0)
{
- _ERR("closeSync failed [%d]", rv);
+ _ERR("timeout [%d]", rv);
this->error = SCARD_ERROR_OPERATION_TIMEOUT;
}
}
}
else
{
- /* FIXME */
- _DBG("unavailable channel");
+ _INFO("unavailable channel");
}
}
#endif
if (ClientIPC::getInstance().sendMessage(&msg) == false)
{
+ _ERR("sendMessage failed");
result = SCARD_ERROR_IPC_FAILED;
}
}
if (rv >= 0)
{
result = response;
-
rv = SCARD_ERROR_OK;
}
else
{
- _ERR("timeout");
-
+ _ERR("timeout [%d]", rv);
this->error = SCARD_ERROR_OPERATION_TIMEOUT;
}
}
}
else
{
+ _ERR("sendMessage failed");
result = SCARD_ERROR_IPC_FAILED;
}
}
case Message::MSG_REQUEST_TRANSMIT :
{
/* transmit result */
- _DBG("MSG_REQUEST_TRANSMIT");
+ _INFO("MSG_REQUEST_TRANSMIT");
if (msg->error == 0 &&
ResponseHelper::getStatus(msg->data) == 0)
case Message::MSG_REQUEST_CLOSE_CHANNEL :
{
- _DBG("MSG_REQUEST_CLOSE_CHANNEL");
+ _INFO("MSG_REQUEST_CLOSE_CHANNEL");
if (msg->isSynchronousCall() == true) /* synchronized call */
{
{
Session *session = NULL;
- _DBG("MSG_REQUEST_OPEN_SESSION");
+ _INFO("MSG_REQUEST_OPEN_SESSION");
if (msg->param1 != 0)
{
int rv;
rv = waitTimedCondition(0);
-
if (rv == 0)
{
ClientDispatcher::getInstance().removeSEService(context);
switch (msg->message)
{
case Message::MSG_REQUEST_READERS :
- _DBG("[MSG_REQUEST_READERS]");
+ _INFO("[MSG_REQUEST_READERS]");
service->connected = true;
break;
case Message::MSG_REQUEST_SHUTDOWN :
- _DBG("[MSG_REQUEST_SHUTDOWN]");
+ _INFO("[MSG_REQUEST_SHUTDOWN]");
if (msg->isSynchronousCall() == true) /* synchronized call */
{
{
Reader *reader = NULL;
- _DBG("[MSG_NOTIFY_SE_INSERTED]");
+ _INFO("[MSG_NOTIFY_SE_INSERTED]");
/* add readers */
reader = new Reader(service->context,
{
size_t i;
- _DBG("[MSG_NOTIFY_SE_REMOVED]");
+ _INFO("[MSG_NOTIFY_SE_REMOVED]");
for (i = 0; i < service->readers.size(); i++)
{
break;
case Message::MSG_OPERATION_RELEASE_CLIENT :
- _DBG("[MSG_OPERATION_RELEASE_CLIENT]");
+ _INFO("[MSG_OPERATION_RELEASE_CLIENT]");
if (service->listener != NULL)
{
}
else
{
+ _ERR("sendMessage failed");
result = SCARD_ERROR_IPC_FAILED;
}
}
if (ClientIPC::getInstance().sendMessage(&msg) == false)
{
+ _ERR("sendMessage failed");
result = SCARD_ERROR_IPC_FAILED;
}
}
}
else
{
+ _ERR("sendMessage failed");
result = SCARD_ERROR_IPC_FAILED;
}
}
}
else
{
+ _ERR("sendMessage failed");
result = SCARD_ERROR_IPC_FAILED;
}
}
{
Channel *channel = NULL;
- _DBG("MSG_REQUEST_OPEN_CHANNEL");
+ _INFO("MSG_REQUEST_OPEN_CHANNEL");
if (msg->param1 != 0)
{
case Message::MSG_REQUEST_GET_ATR :
{
- _DBG("MSG_REQUEST_GET_ATR");
+ _INFO("MSG_REQUEST_GET_ATR");
if (msg->isSynchronousCall() == true) /* synchronized call */
{
case Message::MSG_REQUEST_CLOSE_SESSION :
{
- _DBG("MSG_REQUEST_CLOSE_SESSION");
+ _INFO("MSG_REQUEST_CLOSE_SESSION");
if (msg->isSynchronousCall() == true) /* synchronized call */
{
case Message::MSG_REQUEST_GET_CHANNEL_COUNT :
{
- _DBG("MSG_REQUEST_GET_CHANNEL_COUNT");
+ _INFO("MSG_REQUEST_GET_CHANNEL_COUNT");
if (msg->isSynchronousCall() == true) /* synchronized call */
{
}
else
{
- _DBG("access granted for all applications, aid : %s", aid.toString());
+ _INFO("access granted for all applications, aid : %s", aid.toString());
permission = true;
break;
}
else
{
- _DBG("access denied for all applications, aid : %s", aid.toString());
+ _INFO("access denied for all applications, aid : %s", aid.toString());
permission = false;
}
{
switch (tlv.getTag())
{
- case 0x80 : /* file length without sturctural inforamtion */
+ case 0x80 : /* file length without structural information */
{
- _DBG("0x%02X : file length without sturctural inforamtion : %s", tlv.getTag(), tlv.getValue().toString());
+ _DBG("0x%02X : file length without structural information : %s", tlv.getTag(), tlv.getValue().toString());
if (tlv.getLength() > 0)
{
fileSize = NumberStream::getBigEndianNumber(tlv.getValue());
}
break;
- case 0x81 : /* file length with sturctural inforamtion */
+ case 0x81 : /* file length with structural information */
{
- _DBG("0x%02X : file length with sturctural inforamtion : %s", tlv.getTag(), tlv.getValue().toString());
+ _DBG("0x%02X : file length with structural information : %s", tlv.getTag(), tlv.getValue().toString());
if (tlv.getLength() > 0)
{
maxRecordSize = NumberStream::getBigEndianNumber(tlv.getValue());
#include "IPCHelper.h"
#ifdef USE_UNIX_DOMAIN
-#define SCARD_SERVER_DOMAIN "/tmp/omapi-server-domain"
+#define SCARD_SERVER_DOMAIN "/tmp/smartcard-server-domain"
#endif /* USE_UNIX_DOMAIN */
static void setNonBlockSocket(int socket)
if (bind(ipcSocket, (struct sockaddr *)&saddrun_rv, sizeof(saddrun_rv)) < 0)
{
- _ERR("bind is failed \n");
+ _ERR("bind is failed");
goto ERROR;
}
if (listen(ipcSocket, IPC_SERVER_MAX_CLIENT) < 0)
{
- _ERR("listen is failed \n");
+ _ERR("listen is failed");
goto ERROR;
}
{
if ((watchId = g_io_add_watch(ioChannel, condition, &IPCHelper::channelCallbackFunc, this)) < 1)
{
- _ERR(" g_io_add_watch is failed \n");
+ _ERR(" g_io_add_watch is failed");
goto ERROR;
}
}
else
{
- _ERR(" g_io_channel_unix_new is failed \n");
+ _ERR(" g_io_channel_unix_new is failed");
goto ERROR;
}
}
#endif
- _DBG("server ipc is initialized");
+ _INFO("server ipc is initialized");
return true;
ERROR :
}
}
- _DBG("threadRead is terminated");
+ _INFO("threadRead is terminated");
return (void *)NULL;
}
#endif
pthread_mutex_unlock(&ipcLock);
- _DBG("connecting success");
+ _INFO("connecting success");
_END();
if (count > 4)
return -1;
- count++; /* increse count and increase i value, too */
+ count++;
for (i = 1; i < count; i++)
{
}
}
- _DBG("dataList.size() = %d", mapOID.size());
+ _INFO("dataList.size() = %d", mapOID.size());
return result;
}
}
- _DBG("dataList.size() = %d", dataList.size());
+ _INFO("dataList.size() = %d", dataList.size());
return result;
}
return head;
ERROR :
- _ERR("mem alloc fail");
+ _ERR("alloc fail");
while (head)
{
{
bool result = true;
-// _DBG("current [%p], parent [%p]", currentTLV, currentTLV->getParentTLV());
-
if (currentTLV->getParentTLV() != NULL)
{
currentTLV = currentTLV->getParentTLV();
namespace smartcard_service_api
{
- gboolean ClientInstance::_getCertificationHashes(gpointer user_data)
- {
- gboolean result = false;
- ClientInstance *instance = (ClientInstance *)user_data;
-
- SignatureHelper::getCertificationHashes(instance->getPID(), instance->certHashes);
-
- return result;
- }
-
void ClientInstance::setPID(int pid)
{
this->pid = pid;
-
}
ServiceInstance *ClientInstance::createService(unsigned int context)
void ClientInstance::generateCertificationHashes()
{
- g_idle_add(_getCertificationHashes, (gpointer)this);
+ SignatureHelper::getCertificationHashes(getPID(), certHashes);
}
} /* namespace smartcard_service_api */
/* TODO : insert channel ID using atr information */
helper.setChannel(APDUCommand::CLA_CHANNEL_STANDARD, channelNum);
-
helper.getBuffer(command);
_DBG("command [%d] : %s", command.getLength(), command.toString());
/* handle message */
case Message::MSG_REQUEST_READERS :
{
- SCARD_DEBUG("[MSG_REQUEST_READERS]");
+ _INFO("[MSG_REQUEST_READERS]");
int count = 0;
Message response(*msg);
if (instance->getPID() == -1)
{
instance->setPID(msg->error);
- _ERR("update PID [%d]", msg->error);
+ _INFO("update PID [%d]", msg->error);
/* generate certification hashes */
instance->generateCertificationHashes();
}
else
{
- _DBG("no secure elements");
+ _INFO("no secure elements");
}
}
else
}
else
{
- _DBG("client doesn't exist, socket [%d]", socket);
+ _ERR("client doesn't exist, socket [%d]", socket);
response.error = SCARD_ERROR_UNAVAILABLE;
}
{
Message response(*msg);
- _DBG("[MSG_REQUEST_SHUTDOWN]");
+ _INFO("[MSG_REQUEST_SHUTDOWN]");
response.error = SCARD_ERROR_OK;
Message response(*msg);
unsigned int handle = IntegerHandle::INVALID_HANDLE;
- _DBG("[MSG_REQUEST_OPEN_SESSION]");
+ _INFO("[MSG_REQUEST_OPEN_SESSION]");
if (resource->isValidReaderHandle(msg->param1))
{
{
Message response(*msg);
- _DBG("[MSG_REQUEST_CLOSE_SESSION]");
+ _INFO("[MSG_REQUEST_CLOSE_SESSION]");
response.param1 = 0;
response.error = SCARD_ERROR_OK;
{
Message response(*msg);
- _DBG("[MSG_REQUEST_OPEN_CHANNEL]");
+ _INFO("[MSG_REQUEST_OPEN_CHANNEL]");
response.param1 = IntegerHandle::INVALID_HANDLE;
response.param2 = 0;
{
Message response(*msg);
- _DBG("[MSG_REQUEST_GET_CHANNEL_COUNT]");
+ _INFO("[MSG_REQUEST_GET_CHANNEL_COUNT]");
response.error = SCARD_ERROR_OK;
response.param1 = resource->getChannelCount(socket, msg->error/* service context */, msg->param1);
{
Message response(*msg);
- _DBG("[MSG_REQUEST_CLOSE_CHANNEL]");
+ _INFO("[MSG_REQUEST_CLOSE_CHANNEL]");
response.error = SCARD_ERROR_OK;
ByteArray result;
ServiceInstance *client = NULL;
- _DBG("[MSG_REQUEST_GET_ATR]");
+ _INFO("[MSG_REQUEST_GET_ATR]");
if ((client = resource->getService(socket, msg->error/* service context */)) != NULL)
{
ByteArray result;
Channel *channel = NULL;
- _DBG("[MSG_REQUEST_TRANSMIT]");
+ _INFO("[MSG_REQUEST_TRANSMIT]");
if ((channel = resource->getChannel(socket, msg->error/* service context */, msg->param1)) != NULL)
{
case Message::MSG_OPERATION_RELEASE_CLIENT :
{
- SCARD_DEBUG("[MSG_OPERATION_RELEASE_CLIENT]");
+ _INFO("[MSG_OPERATION_RELEASE_CLIENT]");
resource->removeClient(msg->param1);
- SCARD_DEBUG("remain client [%d]", resource->getClientCount());
+ _DBG("remain client [%d]", resource->getClientCount());
}
#ifdef USE_AUTOSTART
if (resource->getClientCount() == 0)
{
- SCARD_DEBUG("There is no client. shutting down service");
+ _DBG("There is no client. shutting down service");
g_main_loop_quit((GMainLoop *)resource->getMainLoopInstance());
}
#endif
break;
default :
- SCARD_DEBUG("unknown message [%s], socket [%d]", msg->toString(), socket);
+ _DBG("unknown message [%s], socket [%d]", msg->toString(), socket);
break;
}
goto ERROR;
}
- _DBG("client socket is bond with g_io_channel");
+ _INFO("client socket is bond with g_io_channel");
if (ServerResource::getInstance().createClient(client_channel, client_sock_fd, client_src_id, 0, -1) == false)
{
if(channel == ioChannel)
{
- _DBG("server socket is closed");
+ _INFO("server socket is closed");
restartServerIPC();
}
else
DispatcherMsg dispMsg;
int peerSocket = g_io_channel_unix_get_fd((GIOChannel *)channel);
- _DBG("client socket is closed, socket [%d]", peerSocket);
+ _INFO("client socket is closed, socket [%d]", peerSocket);
/* push message to dispatcher */
dispMsg.message = Message::MSG_OPERATION_RELEASE_CLIENT;
if(channel == ioChannel)
{
/* connect state. should accept */
- _DBG("new client connected");
+ _INFO("new client connected");
result = acceptClient();
}
}
else
{
- _DBG("no secure element");
+ _INFO("no secure element");
}
return result;
unsigned int terminalID = IntegerHandle::INVALID_HANDLE;
Message msg;
- _DBG("[NOTIFY_SE_AVAILABLE]");
+ _INFO("[NOTIFY_SE_AVAILABLE]");
terminalID = instance.getTerminalID((char *)terminal);
if (terminalID != IntegerHandle::INVALID_HANDLE)
unsigned int readerID = IntegerHandle::INVALID_HANDLE;
Message msg;
- _DBG("[NOTIFY_SE_NOT_AVAILABLE]");
+ _INFO("[NOTIFY_SE_NOT_AVAILABLE]");
readerID = instance.getReaderID((char *)terminal);
{
_BEGIN();
- _DBG("event occured service [%p], seName[%p], event [%d]", service, seName, event);
+ _INFO("event occurred service [%p], seName[%p], event [%d]", service, seName, event);
_END();
}
{
_BEGIN();
- _DBG("error occured service [%p], error [%d]", service, error);
+ _ERR("error occurred service [%p], error [%d]", service, error);
_END();
}
int fid = 0x00003150;
response = channel->getSelectResponse();
- _DBG("response : %s", response.toString());
+ _INFO("response : %s", response.toString());
_DBG("isBasicChannel() = %s", channel->isBasicChannel() ? "Basic" : "Logical");
_DBG("isClosed() = %s", channel->isClosed() ? "Closed" : "Opened");
command = APDUHelper::generateAPDU(APDUHelper::COMMAND_SELECT_BY_ID, 0, data);
int error = channel->transmitSync(command, response);
- _DBG("error : %d, response : %s", error, response.toString());
+ _INFO("error : %d, response : %s", error, response.toString());
channel->closeSync();
}
_BEGIN();
- _DBG("event occured service [%p], seName[%s], event [%d], userData [%p]", service, seName, event, userData);
+ _INFO("event occurred service [%p], seName[%s], event [%d], userData [%p]", service, seName, event, userData);
readers = service->getReaders();
{
_BEGIN();
- _DBG("error occured service [%p], error [%d]", service, error);
+ _ERR("error occurred service [%p], error [%d]", service, error);
_END();
}
response = channel->getSelectResponse();
- _DBG("response : %s", response.toString());
+ _INFO("response : %s", response.toString());
_DBG("isBasicChannel() = %s", channel->isBasicChannel() ? "Basic" : "Logical");
_DBG("isClosed() = %s", channel->isClosed() ? "Closed" : "Opened");