if (handle == NULL)
{
- SCARD_DEBUG_ERR("ClientIPC::getInstance() failed");
+ _ERR("ClientIPC::getInstance() failed");
return;
}
rv = waitTimedCondition(0);
if (rv < 0)
{
- SCARD_DEBUG_ERR("closeSync failed [%d]", rv);
+ _ERR("closeSync failed [%d]", rv);
this->error = SCARD_ERROR_OPERATION_TIMEOUT;
}
}
else
{
- SCARD_DEBUG_ERR("sendMessage failed");
+ _ERR("sendMessage failed");
this->error = SCARD_ERROR_IPC_FAILED;
}
syncUnlock();
else
{
/* FIXME */
- SCARD_DEBUG("unavailable channel");
+ _DBG("unavailable channel");
}
}
#endif
}
else
{
- SCARD_DEBUG_ERR("unavailable channel");
+ _ERR("unavailable channel");
result = SCARD_ERROR_ILLEGAL_STATE;
}
}
}
else
{
- SCARD_DEBUG_ERR("timeout");
+ _ERR("timeout");
this->error = SCARD_ERROR_OPERATION_TIMEOUT;
}
}
else
{
- SCARD_DEBUG_ERR("sendMessage failed");
+ _ERR("sendMessage failed");
}
syncUnlock();
}
else
{
- SCARD_DEBUG_ERR("unavailable channel");
+ _ERR("unavailable channel");
throw ErrorIllegalState(SCARD_ERROR_UNAVAILABLE);
}
}
else
{
- SCARD_DEBUG_ERR("unavailable channel");
+ _ERR("unavailable channel");
result = SCARD_ERROR_ILLEGAL_STATE;
}
if (msg == NULL)
{
- SCARD_DEBUG_ERR("message is null");
+ _ERR("message is null");
return result;
}
case Message::MSG_REQUEST_TRANSMIT :
{
/* transmit result */
- SCARD_DEBUG("MSG_REQUEST_TRANSMIT");
+ _DBG("MSG_REQUEST_TRANSMIT");
if (msg->error == 0 &&
ResponseHelper::getStatus(msg->data) == 0)
case Message::MSG_REQUEST_CLOSE_CHANNEL :
{
- SCARD_DEBUG("MSG_REQUEST_CLOSE_CHANNEL");
+ _DBG("MSG_REQUEST_CLOSE_CHANNEL");
if (msg->isSynchronousCall() == true) /* synchronized call */
{
break;
default:
- SCARD_DEBUG("unknwon message : %s", msg->toString());
+ _DBG("Unknown message : %s", msg->toString());
break;
}
} \
else \
{ \
- SCARD_DEBUG_ERR("Invalid param"); \
+ _ERR("Invalid param"); \
}
using namespace smartcard_service_api;
bool result = true;
map<void *, SEService *>::iterator item;
- SCARD_BEGIN();
+ _BEGIN();
if ((item = mapSESerivces.find(context)) == mapSESerivces.end())
{
}
else
{
- SCARD_DEBUG("SEService [%p] exists", context);
+ _DBG("SEService [%p] exists", context);
}
- SCARD_END();
+ _END();
return result;
}
{
map<void *, SEService *>::iterator item;
- SCARD_BEGIN();
+ _BEGIN();
if ((item = mapSESerivces.find(context)) != mapSESerivces.end())
{
}
else
{
- SCARD_DEBUG("SEService doesn't exist");
+ _DBG("SEService doesn't exist");
}
- SCARD_END();
+ _END();
}
void *ClientDispatcher::dispatcherThreadFunc(DispatcherMsg *msg, void *data)
{
- SCARD_BEGIN();
+ _BEGIN();
if (msg == NULL)
return NULL;
break;
}
- SCARD_END();
+ _END();
return NULL;
}
{
cookie.setBuffer(buffer, length);
- SCARD_DEBUG("cookie : %s", cookie.toString());
+ _DBG("cookie : %s", cookie.toString());
}
else
{
- SCARD_DEBUG_ERR("security_server_request_cookie failed [%d]", error);
+ _ERR("security_server_request_cookie failed [%d]", error);
}
delete []buffer;
}
else
{
- SCARD_DEBUG_ERR("security_server_get_cookie_size failed");
+ _ERR("security_server_get_cookie_size failed");
}
#endif
}
DBusGConnection *connection;
GError *error = NULL;
- SCARD_BEGIN();
+ _BEGIN();
dbus_g_thread_init();
if (dbus_g_proxy_call(proxy, "launch", &error, G_TYPE_INVALID,
G_TYPE_INT, &result, G_TYPE_INVALID) == false)
{
- SCARD_DEBUG_ERR("org_tizen_smartcard_service_launch failed");
+ _ERR("org_tizen_smartcard_service_launch failed");
if (error != NULL)
{
- SCARD_DEBUG_ERR("message : [%s]", error->message);
+ _ERR("message : [%s]", error->message);
g_error_free(error);
}
}
}
else
{
- SCARD_DEBUG_ERR("ERROR: Can't make dbus proxy");
+ _ERR("ERROR: Can't make dbus proxy");
}
}
else
{
- SCARD_DEBUG_ERR("ERROR: Can't get on system bus [%s]", error->message);
+ _ERR("ERROR: Can't get on system bus [%s]", error->message);
g_error_free(error);
}
- SCARD_END();
+ _END();
}
#endif
#endif
length = stream.getLength();
- SCARD_DEBUG(">>>[SEND]>>> socket [%d], msg [%d], length [%d]",
+ _DBG(">>>[SEND]>>> socket [%d], msg [%d], length [%d]",
ipcSocket, msg->message, stream.getLength());
return IPCHelper::sendMessage(ipcSocket, stream);
int ClientIPC::handleIOErrorCondition(void *channel, GIOCondition condition)
{
- SCARD_BEGIN();
+ _BEGIN();
if (dispatcher != NULL)
{
#endif
}
- SCARD_END();
+ _END();
return FALSE;
}
int ClientIPC::handleInvalidSocketCondition(void *channel, GIOCondition condition)
{
- SCARD_BEGIN();
+ _BEGIN();
/* finalize context */
destroyConnectSocket();
- SCARD_END();
+ _END();
return FALSE;
}
{
int result = FALSE;
- SCARD_BEGIN();
+ _BEGIN();
#ifndef CLIENT_IPC_THREAD
if (channel == ioChannel)
#endif
Message *msg = NULL;
- SCARD_DEBUG("message from server to client socket");
+ _DBG("message from server to client socket");
/* read message */
msg = retrieveMessage();
}
else
{
- SCARD_DEBUG_ERR("Unknown channel event [%p]", channel);
+ _ERR("Unknown channel event [%p]", channel);
}
#endif
- SCARD_END();
+ _END();
return result;
}
{
unsigned int length = 0;
- SCARD_BEGIN();
+ _BEGIN();
this->context = NULL;
this->handle = NULL;
if (context == NULL || name == NULL || strlen(name) == 0 || handle == NULL)
{
- SCARD_DEBUG_ERR("invalid param");
+ _ERR("invalid param");
return;
}
present = true;
- SCARD_END();
+ _END();
}
Reader::~Reader()
rv = waitTimedCondition(0);
if (rv != 0)
{
- SCARD_DEBUG_ERR("time over");
+ _ERR("time over");
this->error = SCARD_ERROR_OPERATION_TIMEOUT;
}
}
else
{
- SCARD_DEBUG_ERR("sendMessage failed");
+ _ERR("sendMessage failed");
this->error = SCARD_ERROR_IPC_FAILED;
}
syncUnlock();
}
else
{
- SCARD_DEBUG_ERR("unavailable reader");
+ _ERR("unavailable reader");
throw ErrorIllegalState(SCARD_ERROR_UNAVAILABLE);
}
{
int result;
- SCARD_BEGIN();
+ _BEGIN();
if (isSecureElementPresent() == true)
{
}
else
{
- SCARD_DEBUG_ERR("sendMessage failed");
+ _ERR("sendMessage failed");
result = SCARD_ERROR_IPC_FAILED;
}
}
else
{
- SCARD_DEBUG_ERR("unavailable reader");
+ _ERR("unavailable reader");
result = SCARD_ERROR_ILLEGAL_STATE;
}
- SCARD_END();
+ _END();
return result;
}
Reader *reader;
bool result = false;
- SCARD_BEGIN();
+ _BEGIN();
if (msg == NULL)
{
- SCARD_DEBUG_ERR("message is null");
+ _ERR("message is null");
return result;
}
{
Session *session = NULL;
- SCARD_DEBUG("MSG_REQUEST_OPEN_SESSION");
+ _DBG("MSG_REQUEST_OPEN_SESSION");
if (msg->param1 != 0)
{
session = new Session(reader->context, reader, (void *)msg->param1);
if (session == NULL)
{
- SCARD_DEBUG_ERR("Session creating instance failed");
+ _ERR("Session creating instance failed");
return session;
}
break;
default:
- SCARD_DEBUG("unknown [%s]", msg->toString());
+ _DBG("unknown [%s]", msg->toString());
break;
}
- SCARD_END();
+ _END();
return result;
}
} \
else \
{ \
- SCARD_DEBUG_ERR("Invalid param"); \
+ _ERR("Invalid param"); \
}
using namespace smartcard_service_api;
}
catch(ExceptionBase &e)
{
- SCARD_DEBUG_ERR("EXCEPTION : %s", e.what());
+ _ERR("EXCEPTION : %s", e.what());
}
catch(...)
{
- SCARD_DEBUG_ERR("EXCEPTION!!!");
+ _ERR("EXCEPTION!!!");
}
for (i = 0; i < readers.size(); i++)
if (ClientIPC::getInstance().sendMessage(&msg) == false)
{
- SCARD_DEBUG_ERR("time over");
+ _ERR("time over");
}
}
}
}
else
{
- SCARD_DEBUG_ERR("time over");
+ _ERR("time over");
}
}
else
{
- SCARD_DEBUG_ERR("sendMessage failed");
+ _ERR("sendMessage failed");
}
syncUnlock();
}
ClientIPC *clientIPC;
ClientDispatcher *clientDispatcher;
- SCARD_BEGIN();
+ _BEGIN();
/* initialize client */
if (!g_thread_supported())
#ifndef CLIENT_IPC_THREAD
if (clientDispatcher->runDispatcherThread() == false)
{
- SCARD_DEBUG_ERR("clientDispatcher->runDispatcherThread() failed");
+ _ERR("clientDispatcher->runDispatcherThread() failed");
return result;
}
if (clientIPC->createConnectSocket() == false)
{
- SCARD_DEBUG_ERR("clientIPC->createConnectSocket() failed");
+ _ERR("clientIPC->createConnectSocket() failed");
return result;
}
result = clientIPC->sendMessage(&msg);
}
- SCARD_END();
+ _END();
return result;
}
memcpy(&handle, data.getBuffer(offset), sizeof(handle));
offset += sizeof(handle);
- SCARD_DEBUG("Reader [%d] : name [%s], handle [%p]", i, name, handle);
-
/* add readers */
reader = new Reader(context, name, handle);
if (reader == NULL)
{
- SCARD_DEBUG_ERR("alloc failed");
+ _ERR("alloc failed");
continue;
}
SEService *service = NULL;
bool result = false;
- SCARD_BEGIN();
+ _BEGIN();
if (msg == NULL)
{
- SCARD_DEBUG_ERR("message is null");
+ _ERR("message is null");
return result;
}
switch (msg->message)
{
case Message::MSG_REQUEST_READERS :
- SCARD_DEBUG("[MSG_REQUEST_READERS]");
+ _DBG("[MSG_REQUEST_READERS]");
service->connected = true;
break;
case Message::MSG_REQUEST_SHUTDOWN :
- SCARD_DEBUG("[MSG_REQUEST_SHUTDOWN]");
+ _DBG("[MSG_REQUEST_SHUTDOWN]");
if (msg->isSynchronousCall() == true) /* synchronized call */
{
{
Reader *reader = NULL;
- SCARD_DEBUG("[MSG_NOTIFY_SE_INSERTED]");
+ _DBG("[MSG_NOTIFY_SE_INSERTED]");
/* add readers */
reader = new Reader(service->context,
}
else
{
- SCARD_DEBUG_ERR("alloc failed");
+ _ERR("alloc failed");
}
if (service->listener != NULL)
}
else
{
- SCARD_DEBUG("listener is null");
+ _DBG("listener is null");
}
}
break;
{
size_t i;
- SCARD_DEBUG("[MSG_NOTIFY_SE_REMOVED]");
+ _DBG("[MSG_NOTIFY_SE_REMOVED]");
for (i = 0; i < service->readers.size(); i++)
{
}
else
{
- SCARD_DEBUG("listener is null");
+ _DBG("listener is null");
}
}
break;
case Message::MSG_OPERATION_RELEASE_CLIENT :
- SCARD_DEBUG("[MSG_OPERATION_RELEASE_CLIENT]");
+ _DBG("[MSG_OPERATION_RELEASE_CLIENT]");
if (service->listener != NULL)
{
}
else
{
- SCARD_DEBUG_ERR("service->listener is null");
+ _ERR("service->listener is null");
}
break;
default :
- SCARD_DEBUG("unknown message [%s]", msg->toString());
+ _DBG("unknown message [%s]", msg->toString());
break;
}
- SCARD_END();
+ _END();
return result;
}
} \
else \
{ \
- SCARD_DEBUG_ERR("Invalid param"); \
+ _ERR("Invalid param"); \
}
using namespace smartcard_service_api;
if (context == NULL || handle == NULL)
{
- SCARD_DEBUG_ERR("handle is null");
+ _ERR("handle is null");
return;
}
rv = waitTimedCondition(0);
if (rv != 0)
{
- SCARD_DEBUG_ERR("time over");
+ _ERR("time over");
this->error = SCARD_ERROR_OPERATION_TIMEOUT;
}
}
else
{
- SCARD_DEBUG_ERR("sendMessage failed");
+ _ERR("sendMessage failed");
this->error = SCARD_ERROR_IPC_FAILED;
}
syncUnlock();
}
else
{
- SCARD_DEBUG_ERR("unavailable session");
+ _ERR("unavailable session");
throw ErrorIllegalState(SCARD_ERROR_UNAVAILABLE);
}
}
else
{
- SCARD_DEBUG_ERR("unavailable session");
+ _ERR("unavailable session");
result = SCARD_ERROR_ILLEGAL_STATE;
}
if (rv != 0)
{
- SCARD_DEBUG_ERR("time over");
+ _ERR("time over");
this->error = SCARD_ERROR_OPERATION_TIMEOUT;
}
}
else
{
- SCARD_DEBUG_ERR("sendMessage failed");
+ _ERR("sendMessage failed");
this->error = SCARD_ERROR_IPC_FAILED;
}
syncUnlock();
rv = waitTimedCondition(0);
if (rv != 0)
{
- SCARD_DEBUG_ERR("time over");
+ _ERR("time over");
this->error = SCARD_ERROR_OPERATION_TIMEOUT;
}
}
else
{
- SCARD_DEBUG_ERR("sendMessage failed");
+ _ERR("sendMessage failed");
this->error = SCARD_ERROR_IPC_FAILED;
}
syncUnlock();
}
else
{
- SCARD_DEBUG_ERR("unavailable session");
+ _ERR("unavailable session");
throw ErrorIllegalState(SCARD_ERROR_UNAVAILABLE);
}
}
else
{
- SCARD_DEBUG_ERR("unavailable session");
+ _ERR("unavailable session");
result = SCARD_ERROR_ILLEGAL_STATE;
}
rv = waitTimedCondition(0);
if (rv != 0)
{
- SCARD_DEBUG_ERR("time over");
+ _ERR("time over");
this->error = SCARD_ERROR_OPERATION_TIMEOUT;
}
}
else
{
- SCARD_DEBUG_ERR("sendMessage failed");
+ _ERR("sendMessage failed");
this->error = SCARD_ERROR_IPC_FAILED;
}
syncUnlock();
}
else
{
- SCARD_DEBUG_ERR("unavailable session");
+ _ERR("unavailable session");
throw ErrorIllegalState(SCARD_ERROR_UNAVAILABLE);
}
}
else
{
- SCARD_DEBUG_ERR("unavailable session");
+ _ERR("unavailable session");
result = SCARD_ERROR_ILLEGAL_STATE;
}
if (msg == NULL)
{
- SCARD_DEBUG_ERR("message is null");
+ _ERR("message is null");
return result;
}
{
Channel *channel = NULL;
- SCARD_DEBUG("MSG_REQUEST_OPEN_CHANNEL");
+ _DBG("MSG_REQUEST_OPEN_CHANNEL");
if (msg->param1 != 0)
{
}
else
{
- SCARD_DEBUG_ERR("alloc failed");
+ _ERR("alloc failed");
msg->error = SCARD_ERROR_OUT_OF_MEMORY;
}
case Message::MSG_REQUEST_GET_ATR :
{
- SCARD_DEBUG("MSG_REQUEST_GET_ATR");
+ _DBG("MSG_REQUEST_GET_ATR");
if (msg->isSynchronousCall() == true) /* synchronized call */
{
case Message::MSG_REQUEST_CLOSE_SESSION :
{
- SCARD_DEBUG("MSG_REQUEST_CLOSE_SESSION");
+ _DBG("MSG_REQUEST_CLOSE_SESSION");
if (msg->isSynchronousCall() == true) /* synchronized call */
{
case Message::MSG_REQUEST_GET_CHANNEL_COUNT :
{
- SCARD_DEBUG("MSG_REQUEST_GET_CHANNEL_COUNT");
+ _DBG("MSG_REQUEST_GET_CHANNEL_COUNT");
if (msg->isSynchronousCall() == true) /* synchronized call */
{
break;
default :
- SCARD_DEBUG("unknown message : %s", msg->toString());
+ _DBG("unknown message : %s", msg->toString());
break;
}
} \
else \
{ \
- SCARD_DEBUG_ERR("Invalid param"); \
+ _ERR("Invalid param"); \
}
using namespace smartcard_service_api;
}
else
{
- SCARD_DEBUG_ERR("command stream is not correct, command.getLength() [%d], offset [%d]", command.getLength(), offset);
+ _ERR("command stream is not correct, command.getLength() [%d], offset [%d]", command.getLength(), offset);
}
return result;
value = tlv.getValue();
- SCARD_DEBUG("APDU rule : %s", value.toString());
+ _DBG("APDU rule : %s", value.toString());
if (value.getLength() == 8) /* apdu 4 bytes + mask 4 bytes */
{
}
else
{
- SCARD_DEBUG_ERR("Invalid APDU rule : %s", value.toString());
+ _ERR("Invalid APDU rule : %s", value.toString());
}
}
else
{
- SCARD_DEBUG_ERR("Unknown tag : 0x%02X", tlv.getTag());
+ _ERR("Unknown tag : 0x%02X", tlv.getTag());
}
}
tlv.returnToParentTLV();
break;
default :
- SCARD_DEBUG_ERR("Unknown tag : 0x%02X", tlv.getTag());
+ _ERR("Unknown tag : 0x%02X", tlv.getTag());
break;
}
}
void APDUAccessRule::printAPDUAccessRules()
{
- SCARD_DEBUG(" +-- APDU Access Rule");
+ _DBG(" +-- APDU Access Rule");
if (mapApduFilters.size() > 0)
{
for (iterMap = mapApduFilters.begin(); iterMap != mapApduFilters.end(); iterMap++)
{
- SCARD_DEBUG(" +--- APDU : %s, Mask : %s", ((ByteArray)(iterMap->first)).toString(), iterMap->second.toString());
+ _DBG(" +--- APDU : %s, Mask : %s", ((ByteArray)(iterMap->first)).toString(), iterMap->second.toString());
}
}
else
{
- SCARD_DEBUG(" +--- permission : %s", permission ? "granted all" : "denied all");
+ _DBG(" +--- permission : %s", permission ? "granted all" : "denied all");
}
}
void NFCAccessRule::printNFCAccessRules()
{
- SCARD_DEBUG(" +-- NFC Access Rule");
- SCARD_DEBUG(" +--- permission : %s", permission ? "granted all" : "denied all");
+ _DBG(" +-- NFC Access Rule");
+ _DBG(" +--- permission : %s", permission ? "granted all" : "denied all");
}
void AccessCondition::loadAccessCondition(ByteArray &aid, ByteArray &data)
switch (tlv.getTag())
{
case 0x04 : /* OCTET STRING : CertHash */
- SCARD_DEBUG("aid : %s, hash : %s", aid.toString(), tlv.getValue().toString());
+ _DBG("aid : %s, hash : %s", aid.toString(), tlv.getValue().toString());
hashes.push_back(tlv.getValue());
break;
break;
default :
- SCARD_DEBUG_ERR("Unknown tag : 0x%02X", tlv.getTag());
+ _ERR("Unknown tag : 0x%02X", tlv.getTag());
break;
}
}
else
{
- SCARD_DEBUG_ERR("tlv.decodeTLV failed");
+ _ERR("tlv.decodeTLV failed");
}
tlv.returnToParentTLV();
break;
default :
- SCARD_DEBUG_ERR("Unknown tag : 0x%02X", tlv.getTag());
+ _ERR("Unknown tag : 0x%02X", tlv.getTag());
break;
}
}
else
{
- SCARD_DEBUG_ERR("tlv.decodeTLV failed");
+ _ERR("tlv.decodeTLV failed");
}
tlv.returnToParentTLV();
}
else
{
- SCARD_DEBUG("access granted for all applications, aid : %s", aid.toString());
+ _DBG("access granted for all applications, aid : %s", aid.toString());
permission = true;
break;
}
else
{
- SCARD_DEBUG("access denied for all applications, aid : %s", aid.toString());
+ _DBG("access denied for all applications, aid : %s", aid.toString());
permission = false;
}
void AccessCondition::printAccessConditions()
{
- SCARD_DEBUG(" +-- Access Condition");
+ _DBG(" +-- Access Condition");
if (hashes.size() > 0)
{
for (i = 0; i < hashes.size(); i++)
{
- SCARD_DEBUG(" +--- hash : %s", hashes[i].toString());
+ _DBG(" +--- hash : %s", hashes[i].toString());
}
}
else
{
- SCARD_DEBUG(" +--- permission : %s", permission ? "granted all" : "denied all");
+ _DBG(" +--- permission : %s", permission ? "granted all" : "denied all");
}
}
} /* namespace smartcard_service_api */
if (result == false)
{
- SCARD_DEBUG("aid : %s", aid.toString());
- SCARD_DEBUG("hash : %s", certHash.toString());
+ _DBG("aid : %s", aid.toString());
+ _DBG("hash : %s", certHash.toString());
/* null aid means default applet */
if (aid.isEmpty() == true)
/* release map and vector */
map<ByteArray, AccessCondition>::iterator iterMap;
- SCARD_DEBUG("================ Certification Hashes ==================");
+ _DBG("================ Certification Hashes ==================");
for (iterMap = mapConditions.begin(); iterMap != mapConditions.end(); iterMap++)
{
temp = iterMap->first;
- SCARD_DEBUG("+ aid : %s", (temp == AID_DEFAULT) ? "DEFAULT" : (temp == AID_ALL) ? "ALL" : temp.toString());
+ _DBG("+ aid : %s", (temp == AID_DEFAULT) ? "DEFAULT" : (temp == AID_ALL) ? "ALL" : temp.toString());
iterMap->second.printAccessConditions();
}
- SCARD_DEBUG("========================================================");
+ _DBG("========================================================");
}
} /* namespace smartcard_service_api */
buffer = new uint8_t[bufferLen];
if (buffer == NULL)
{
- SCARD_DEBUG_ERR("alloc failed");
+ _ERR("alloc failed");
return false;
}
if (offset >= length)
{
- SCARD_DEBUG_ERR("buffer overflow, offset [%d], length [%d]", offset, length);
+ _ERR("buffer overflow, offset [%d], length [%d]", offset, length);
return NULL;
}
{
if (index >= length)
{
- SCARD_DEBUG_ERR("buffer overflow, index [%d], length [%d]", index, length);
+ _ERR("buffer overflow, index [%d], length [%d]", index, length);
return buffer[length -1];
}
{
if (index >= length)
{
- SCARD_DEBUG_ERR("buffer underflow, index [%d], length [%d]", index, length);
+ _ERR("buffer underflow, index [%d], length [%d]", index, length);
return buffer[0];
}
if (array == NULL || bufferLen == 0)
{
- SCARD_DEBUG_ERR("invaild param");
+ _ERR("invaild param");
return false;
}
if (length == 0)
{
- SCARD_DEBUG("length is zero");
+ _DBG("length is zero");
return T;
}
if (newBuffer == NULL)
{
/* assert.... */
- SCARD_DEBUG_ERR("alloc failed");
+ _ERR("alloc failed");
return *this;
}
{
if (index >= length)
{
- SCARD_DEBUG_ERR("buffer overflow, index [%d], length [%d]", index, length);
+ _ERR("buffer overflow, index [%d], length [%d]", index, length);
return buffer[length -1];
}
fflush(file);
fclose(file);
- SCARD_DEBUG("file has written, file [%s], length[%d]", filePath, length);
}
else
{
- SCARD_DEBUG_ERR("file open failed, [%d]", errno);
+ _ERR("file open failed, [%d]", errno);
}
}
if ((ret = pthread_create(&dispatcherThread, &attr, &DispatcherHelper::_dispatcherThreadFunc, this)) != 0)
{
- SCARD_DEBUG_ERR("pthread_create failed [%d]", ret);
+ _ERR("pthread_create failed [%d]", ret);
}
else
{
- SCARD_DEBUG("pthread_create success");
+ _DBG("pthread_create success");
result = true;
}
}
else
{
- SCARD_DEBUG("thread already start");
+ _DBG("thread already start");
result = true;
}
ret = select(dirPath, false);
if (ret == FileObject::SUCCESS)
{
- SCARD_DEBUG("response : %s", selectResponse.toString());
+ _DBG("response : %s", selectResponse.toString());
}
else
{
- SCARD_DEBUG_ERR("EFDIR select failed, [%d]", ret);
+ _ERR("EFDIR select failed, [%d]", ret);
}
}
if (matched == true)
{
- SCARD_DEBUG("Found!! : path %s", result.toString());
+ _DBG("Found!! : path %s", result.toString());
}
else
{
bool result = false;
SimpleTLV tlv;
- SCARD_BEGIN();
+ _BEGIN();
releaseFCP();
if (fcpBuffer[0] != 0x62)
{
- SCARD_DEBUG_ERR("it is not FCP response [%02X]", fcpBuffer[0]);
+ _ERR("it is not FCP response [%02X]", fcpBuffer[0]);
return false;
}
{
case 0x80 : /* file length without sturctural inforamtion */
{
- SCARD_DEBUG("0x%02X : file length without sturctural inforamtion : %s", tlv.getTag(), tlv.getValue().toString());
+ _DBG("0x%02X : file length without sturctural inforamtion : %s", tlv.getTag(), tlv.getValue().toString());
if (tlv.getLength() > 0)
{
fileSize = NumberStream::getBigEndianNumber(tlv.getValue());
case 0x81 : /* file length with sturctural inforamtion */
{
- SCARD_DEBUG("0x%02X : file length with sturctural inforamtion : %s", tlv.getTag(), tlv.getValue().toString());
+ _DBG("0x%02X : file length with sturctural inforamtion : %s", tlv.getTag(), tlv.getValue().toString());
if (tlv.getLength() > 0)
{
maxRecordSize = NumberStream::getBigEndianNumber(tlv.getValue());
case 0x82 : /* file descriptor bytes */
{
- SCARD_DEBUG("0x%02X : file descriptor bytes : %s", tlv.getTag(), tlv.getValue().toString());
+ _DBG("0x%02X : file descriptor bytes : %s", tlv.getTag(), tlv.getValue().toString());
// ByteArray value = tlv.getValue();
}
break;
case 0x83 : /* file identifier */
{
- SCARD_DEBUG("0x%02X : file identifier : %s", tlv.getTag(), tlv.getValue().toString());
+ _DBG("0x%02X : file identifier : %s", tlv.getTag(), tlv.getValue().toString());
if (tlv.getLength() > 0)
{
ByteArray value = tlv.getValue();
case 0x85 : /* proprietary information not encoded in BER-TLV */
{
- SCARD_DEBUG("0x%02X : proprietary information not encoded in BER-TLV : %s", tlv.getTag(), tlv.getValue().toString());
+ _DBG("0x%02X : proprietary information not encoded in BER-TLV : %s", tlv.getTag(), tlv.getValue().toString());
// ByteArray value = tlv.getValue();
}
break;
case 0x87 : /* Identifier of an EF containing an extension of the file control information */
{
- SCARD_DEBUG("0x%02X : Identifier of an EF containing an extension of the file control information : %s", tlv.getTag(), tlv.getValue().toString());
+ _DBG("0x%02X : Identifier of an EF containing an extension of the file control information : %s", tlv.getTag(), tlv.getValue().toString());
// ByteArray value = tlv.getValue();
}
break;
case 0x88 : /* Short EF identifier */
{
- SCARD_DEBUG("0x%02X : Short EF identifier : %s", tlv.getTag(), tlv.getValue().toString());
+ _DBG("0x%02X : Short EF identifier : %s", tlv.getTag(), tlv.getValue().toString());
if (tlv.getLength() > 0)
{
case 0x8A : /* life cycle status byte */
{
- SCARD_DEBUG("0x%02X : life cycle status byte : %s", tlv.getTag(), tlv.getValue().toString());
+ _DBG("0x%02X : life cycle status byte : %s", tlv.getTag(), tlv.getValue().toString());
if (tlv.getLength() > 0)
{
ByteArray value = tlv.getValue();
case 0xA2 : /* Template consisting of one or more pairs of data objects */
{
- SCARD_DEBUG("0x%02X : Template consisting of one or more pairs of data objects : %s", tlv.getTag(), tlv.getValue().toString());
+ _DBG("0x%02X : Template consisting of one or more pairs of data objects : %s", tlv.getTag(), tlv.getValue().toString());
// ByteArray value = tlv.getValue();
}
break;
case 0xA5 : /* proprietary information encoded in BER-TLV */
{
- SCARD_DEBUG("0x%02X : proprietary information encoded in BER-TLV : %s", tlv.getTag(), tlv.getValue().toString());
+ _DBG("0x%02X : proprietary information encoded in BER-TLV : %s", tlv.getTag(), tlv.getValue().toString());
// ByteArray value = tlv.getValue();
}
break;
case 0xAC : /* Cryptographic mechanism identifier template */
{
- SCARD_DEBUG("0x%02X : Cryptographic mechanism identifier template : %s", tlv.getTag(), tlv.getValue().toString());
+ _DBG("0x%02X : Cryptographic mechanism identifier template : %s", tlv.getTag(), tlv.getValue().toString());
// ByteArray value = tlv.getValue();
}
break;
default :
{
- SCARD_DEBUG("0x%02X : unknown : %s", tlv.getTag(), tlv.getValue().toString());
+ _DBG("0x%02X : unknown : %s", tlv.getTag(), tlv.getValue().toString());
}
break;
}
}
else
{
- SCARD_DEBUG_ERR("tlv.decodeTLV failed");
+ _ERR("tlv.decodeTLV failed");
}
- SCARD_END();
+ _END();
return result;
}
fcp.setFCP(resp.getDataField());
- SCARD_DEBUG("FCP : %s", fcp.toString());
+ _DBG("FCP : %s", fcp.toString());
opened = true;
result = true;
}
else
{
- SCARD_DEBUG_ERR("status word [%d][ %02X %02X ]",
+ _ERR("status word [%d][ %02X %02X ]",
resp.getStatus(), resp.getSW1(), resp.getSW2());
}
}
else
{
- SCARD_DEBUG_ERR("invalid response : %s", response.toString());
+ _ERR("invalid response : %s", response.toString());
}
return result;
if (channel == NULL || channel->isClosed())
{
- SCARD_DEBUG_ERR("channel is not open");
+ _ERR("channel is not open");
return ret;
}
}
else
{
- SCARD_DEBUG_ERR("select apdu is failed, rv [%d], length [%d]",
+ _ERR("select apdu is failed, rv [%d], length [%d]",
ret, result.getLength());
ret = ERROR_ILLEGAL_STATE;
ret = resp.getStatus();
if (ret == 0)
{
- SCARD_DEBUG("response [%d] : %s", response.getLength(), response.toString());
+ _DBG("response [%d] : %s", response.getLength(), response.toString());
result = Record(recordId, resp.getDataField());
}
else
{
- SCARD_DEBUG_ERR("status word [%d][ %02X %02X ]", resp.getStatus(), resp.getSW1(), resp.getSW2());
+ _ERR("status word [%d][ %02X %02X ]", resp.getStatus(), resp.getSW1(), resp.getSW2());
}
}
else
{
- SCARD_DEBUG_ERR("select apdu is failed, rv [%d], length [%d]", ret, response.getLength());
+ _ERR("select apdu is failed, rv [%d], length [%d]", ret, response.getLength());
}
return ret;
if (resp.getStatus() == 0)
{
- SCARD_DEBUG("response [%d] : %s", response.getLength(), response.toString());
+ _DBG("response [%d] : %s", response.getLength(), response.toString());
result = resp.getDataField();
}
else
{
- SCARD_DEBUG_ERR("status word [%d][ %02X %02X ]", resp.getStatus(), resp.getSW1(), resp.getSW2());
+ _ERR("status word [%d][ %02X %02X ]", resp.getStatus(), resp.getSW1(), resp.getSW2());
}
}
else
{
- SCARD_DEBUG_ERR("select apdu is failed, rv [%d], length [%d]", ret, response.getLength());
+ _ERR("select apdu is failed, rv [%d], length [%d]", ret, response.getLength());
}
return ret;
if (resp.getStatus() == 0)
{
- SCARD_DEBUG("response [%d] : %s", response.getLength(), response.toString());
+ _DBG("response [%d] : %s", response.getLength(), response.toString());
ret = SUCCESS;
}
else
{
- SCARD_DEBUG_ERR("status word [%d][ %02X %02X ]", resp.getStatus(), resp.getSW1(), resp.getSW2());
+ _ERR("status word [%d][ %02X %02X ]", resp.getStatus(), resp.getSW1(), resp.getSW2());
}
}
else
{
- SCARD_DEBUG_ERR("select apdu is failed, rv [%d], length [%d]", ret, response.getLength());
+ _ERR("select apdu is failed, rv [%d], length [%d]", ret, response.getLength());
}
return ret;
}
else
{
- SCARD_DEBUG_ERR("loadAccessControl failed, every request will be accepted.");
+ _ERR("loadAccessControl failed, every request will be accepted.");
}
}
else
{
- SCARD_DEBUG_ERR("dodf null, every request will be accepted.");
+ _ERR("dodf null, every request will be accepted.");
}
}
else
{
- SCARD_DEBUG_ERR("odf null, every request will be accepted.");
+ _ERR("odf null, every request will be accepted.");
}
}
else
{
- SCARD_DEBUG_ERR("failed to open PKCS15, every request will be accepted.");
+ _ERR("failed to open PKCS15, every request will be accepted.");
}
delete pkcs15;
ByteArray data;
FileObject file(channel);
- SCARD_DEBUG("oid path : %s", path.toString());
+ _DBG("oid path : %s", path.toString());
file.select(NumberStream::getLittleEndianNumber(path));
file.readBinary(0, 0, file.getFCP()->getFileSize(), data);
- SCARD_DEBUG("data : %s", data.toString());
+ _DBG("data : %s", data.toString());
/* PKCS #15 and DODF OID exists. apply access control rule!! */
allGranted = false;
ByteArray refreshTag;
refreshTag = SimpleTLV::getOctetString(tlv);
- SCARD_DEBUG("current refresh tag : %s", refreshTag.toString());
+ _DBG("current refresh tag : %s", refreshTag.toString());
if (this->refreshTag != refreshTag) /* need to update access control list */
{
/* OCTET STRING */
path = SimpleTLV::getOctetString(tlv.getValue());
- SCARD_DEBUG("access control rule path : %s", path.toString());
+ _DBG("access control rule path : %s", path.toString());
if (loadRules(channel, path) == 0)
{
- SCARD_DEBUG("loadRules success");
+ _DBG("loadRules success");
}
else
{
- SCARD_DEBUG_ERR("loadRules failed");
+ _ERR("loadRules failed");
}
}
}
}
else
{
- SCARD_DEBUG_ERR("tlv.decodeTLV failed");
+ _ERR("tlv.decodeTLV failed");
}
}
else
{
- SCARD_DEBUG_ERR("OID not found");
+ _ERR("OID not found");
}
return result;
file.select(NumberStream::getLittleEndianNumber(path));
file.readBinary(0, 0, file.getFCP()->getFileSize(), data);
- SCARD_DEBUG("data : %s", data.toString());
+ _DBG("data : %s", data.toString());
SimpleTLV tlv(data);
break;
}
- SCARD_DEBUG("aid : %s", aid.toString());
+ _DBG("aid : %s", aid.toString());
/* access condition path */
if (tlv.decodeTLV() == true && tlv.getTag() == 0x30) /* SEQUENCE : Path */
/* OCTET STRING */
path = SimpleTLV::getOctetString(tlv.getValue());
- SCARD_DEBUG("path : %s", path.toString());
+ _DBG("path : %s", path.toString());
if (loadAccessConditions(channel, aid, path) == 0)
{
- SCARD_DEBUG("loadCertHashes success");
+ _DBG("loadCertHashes success");
}
else
{
- SCARD_DEBUG_ERR("loadCertHashes failed");
+ _ERR("loadCertHashes failed");
}
}
else
{
- SCARD_DEBUG_ERR("decodeTLV failed");
+ _ERR("decodeTLV failed");
}
}
else
{
- SCARD_DEBUG_ERR("decodeTLV failed");
+ _ERR("decodeTLV failed");
}
tlv.returnToParentTLV();
}
file.select(NumberStream::getLittleEndianNumber(path));
file.readBinary(0, 0, file.getFCP()->getFileSize(), data);
- SCARD_DEBUG("data : %s", data.toString());
+ _DBG("data : %s", data.toString());
AccessCondition condition;
} \
else \
{ \
- SCARD_DEBUG_ERR("Invalid param"); \
+ _ERR("Invalid param"); \
}
using namespace smartcard_service_api;
if (fcntl(socket, F_SETFL, flags) < 0)
{
- /* SCARD_DEBUG_ERR("fcntl, executing nonblock error"); */
+ /* _ERR("fcntl, executing nonblock error"); */
}
}
IPCHelper *helper = (IPCHelper *)data;
gboolean result = FALSE;
- SCARD_DEBUG("channel [%p], condition [%d], data [%p]", channel, condition, data);
+ _DBG("channel [%p], condition [%d], data [%p]", channel, condition, data);
if (helper == NULL)
{
- SCARD_DEBUG_ERR("ipchelper is null");
+ _ERR("ipchelper is null");
return result;
}
ipcSocket = socket(AF_UNIX, SOCK_STREAM, 0);
if (ipcSocket == -1)
{
- SCARD_DEBUG_ERR("get socket is failed");
+ _ERR("get socket is failed");
return false;
}
if (bind(ipcSocket, (struct sockaddr *)&saddrun_rv, sizeof(saddrun_rv)) < 0)
{
- SCARD_DEBUG_ERR("bind is failed \n");
+ _ERR("bind is failed \n");
goto ERROR;
}
if (chmod(SCARD_SERVER_DOMAIN, 0777) < 0)
{
- SCARD_DEBUG_ERR("can not change permission of UNIX DOMAIN file");
+ _ERR("can not change permission of UNIX DOMAIN file");
goto ERROR;
}
if (listen(ipcSocket, IPC_SERVER_MAX_CLIENT) < 0)
{
- SCARD_DEBUG_ERR("listen is failed \n");
+ _ERR("listen is failed \n");
goto ERROR;
}
{
if ((watchId = g_io_add_watch(ioChannel, condition, &IPCHelper::channelCallbackFunc, this)) < 1)
{
- SCARD_DEBUG_ERR(" g_io_add_watch is failed \n");
+ _ERR(" g_io_add_watch is failed \n");
goto ERROR;
}
}
else
{
- SCARD_DEBUG_ERR(" g_io_channel_unix_new is failed \n");
+ _ERR(" g_io_channel_unix_new is failed \n");
goto ERROR;
}
gid = security_server_get_gid("smartcard-service");
if(gid == 0)
{
- SCARD_DEBUG("get gid from security server is failed. this object is not allowed by security server");
+ _DBG("get gid from security server is failed. this object is not allowed by security server");
goto ERROR;
}
}
#endif
- SCARD_DEBUG("server ipc is initialized");
+ _DBG("server ipc is initialized");
return true;
ERROR :
- SCARD_DEBUG_ERR("error while initializing server ipc");
+ _ERR("error while initializing server ipc");
destroyListenSocket();
for (i = 0; i < events; i++)
{
- SCARD_DEBUG("pollEvents[%d].events [%X]", i, pollEvents[i].events);
+ _DBG("pollEvents[%d].events [%X]", i, pollEvents[i].events);
if ((pollEvents[i].events & EPOLLHUP) || (pollEvents[i].events & EPOLLERR))
{
- SCARD_DEBUG_ERR("connection is closed");
+ _ERR("connection is closed");
result = 0;
break;
}
}
else if (errno == EINTR)
{
- SCARD_DEBUG_ERR("epoll_wait interrupted");
+ _ERR("epoll_wait interrupted");
}
else
{
char buffer[1024];
- SCARD_DEBUG_ERR("epoll_wait failed, errno [%d], %s", errno, strerror_r(errno, buffer, sizeof(buffer)));
+ _ERR("epoll_wait failed, errno [%d], %s", errno, strerror_r(errno, buffer, sizeof(buffer)));
}
#else
if (select(ipcSocket + 1, &fdSetRead, NULL, NULL, NULL) > 0)
{
if (val == 0)
{
- SCARD_DEBUG("socket is readable");
+ _DBG("socket is readable");
result = 1;
}
else
{
- SCARD_DEBUG("socket is not available. maybe disconnected");
+ _DBG("socket is not available. maybe disconnected");
result = 0;
}
}
else
{
- SCARD_DEBUG_ERR("getsockopt failed, errno [%d]", errno);
+ _ERR("getsockopt failed, errno [%d]", errno);
result = errno;
}
}
else
{
- SCARD_DEBUG_ERR("FD_ISSET false!!! what's wrong");
+ _ERR("FD_ISSET false!!! what's wrong");
result = -1;
}
}
else
{
- SCARD_DEBUG_ERR("select failed [%d]", errno);
+ _ERR("select failed [%d]", errno);
result = errno;
}
#endif
sigemptyset(&newmask);
sigaddset(&newmask, SIGTERM);
pthread_sigmask(SIG_UNBLOCK, &newmask, NULL);
- SCARD_DEBUG("sighandler is registered");
+ _DBG("sighandler is registered");
pthread_mutex_lock(&g_client_lock);
pthread_cond_signal ((pthread_cond_t *) data);
}
}
- SCARD_DEBUG("threadRead is terminated");
+ _DBG("threadRead is terminated");
return (void *)NULL;
}
int result = 0;
char err[200] = { 0, };
- SCARD_BEGIN();
+ _BEGIN();
if (ipcSocket >= 0)
return true;
ipcSocket = socket(AF_UNIX, SOCK_STREAM, 0);
if (ipcSocket == -1)
{
- SCARD_DEBUG_ERR("get socket is failed [%d, %s]",
+ _ERR("get socket is failed [%d, %s]",
errno, strerror_r(errno, err, sizeof(err)));
goto ERROR;
}
- SCARD_DEBUG("socket is created");
+ _DBG("socket is created");
::setNonBlockSocket(ipcSocket);
if ((result = connect(ipcSocket, (struct sockaddr *)&saddrun_rv, len_saddr)) < 0)
{
- SCARD_DEBUG_ERR("connect failed [%d, %s]",
+ _ERR("connect failed [%d, %s]",
errno, strerror_r(errno, err, sizeof(err)));
goto ERROR;
}
#ifdef USE_IPC_EPOLL
if((fdPoll = epoll_create1(EPOLL_CLOEXEC)) == -1)
{
- SCARD_DEBUG_ERR("epoll_create1 failed [%d, %s]",
+ _ERR("epoll_create1 failed [%d, %s]",
errno, strerror_r(errno, err, sizeof(err)));
goto ERROR;
}
pollEvents = (struct epoll_event *)calloc(EPOLL_SIZE, sizeof(struct epoll_event));
if (pollEvents == NULL)
{
- SCARD_DEBUG_ERR("alloc failed");
+ _ERR("alloc failed");
goto ERROR;
}
if (pthread_create(&readThread, NULL, &IPCHelper::threadRead, this) != 0)
#endif
{
- SCARD_DEBUG_ERR("pthread_create is failed");
+ _ERR("pthread_create is failed");
goto ERROR;
}
{
if ((watchId = g_io_add_watch(ioChannel, condition, &IPCHelper::channelCallbackFunc, this)) < 1)
{
- SCARD_DEBUG_ERR(" g_io_add_watch is failed");
+ _ERR(" g_io_add_watch is failed");
goto ERROR;
}
}
else
{
- SCARD_DEBUG_ERR(" g_io_channel_unix_new is failed");
+ _ERR(" g_io_channel_unix_new is failed");
goto ERROR;
}
#endif
pthread_mutex_unlock(&ipcLock);
- SCARD_DEBUG("connecting success");
+ _DBG("connecting success");
- SCARD_END();
+ _END();
return true;
ERROR :
- SCARD_DEBUG_ERR("error while initializing client ipc");
+ _ERR("error while initializing client ipc");
destroyConnectSocket();
pthread_mutex_unlock(&ipcLock);
- SCARD_END();
+ _END();
return false;
}
stream = msg->serialize();
length = stream.getLength();
- SCARD_DEBUG(">>>[SEND]>>> socket [%d], msg [%d], length [%d]",
+ _DBG(">>>[SEND]>>> socket [%d], msg [%d], length [%d]",
socket, msg->message, stream.getLength());
return sendMessage(socket, stream);
}
else
{
- SCARD_DEBUG_ERR("send failed, sentBytes [%d]", sentBytes);
+ _ERR("send failed, sentBytes [%d]", sentBytes);
}
}
else
{
- SCARD_DEBUG_ERR("stream length is zero");
+ _ERR("stream length is zero");
}
return result;
ByteArray buffer;
Message *msg = NULL;
- SCARD_BEGIN();
+ _BEGIN();
buffer = retrieveBuffer(socket);
if (buffer.getLength() > 0)
}
else
{
- SCARD_DEBUG_ERR("alloc failed");
+ _ERR("alloc failed");
}
}
else
{
- SCARD_DEBUG_ERR("retrieveBuffer failed ");
+ _ERR("retrieveBuffer failed ");
}
- SCARD_END();
+ _END();
return msg;
}
unsigned int length = 0;
int readBytes = 0;
- SCARD_BEGIN();
+ _BEGIN();
/* read 4 bytes (length) */
pthread_mutex_lock(&ipcLock);
while (current < length);
pthread_mutex_unlock(&ipcLock);
- SCARD_DEBUG("<<<[RETRIEVE]<<< socket [%d], msg_length [%d]", socket, length);
+ _DBG("<<<[RETRIEVE]<<< socket [%d], msg_length [%d]", socket, length);
buffer.setBuffer(temp, length);
}
else
{
- SCARD_DEBUG_ERR("allocation failed");
+ _ERR("allocation failed");
}
}
else
{
- SCARD_DEBUG_ERR("invalid length, socket = [%d], msg_length = [%d]", socket, length);
+ _ERR("invalid length, socket = [%d], msg_length = [%d]", socket, length);
}
}
else
{
- SCARD_DEBUG_ERR("failed to recv length, socket = [%d], readBytes [%d]", socket, readBytes);
+ _ERR("failed to recv length, socket = [%d], readBytes [%d]", socket, readBytes);
}
- SCARD_END();
+ _END();
return buffer;
}
}
else
{
- SCARD_DEBUG_ERR("allocation failed");
+ _ERR("allocation failed");
}
return result;
unsigned int current = 0;
unsigned int dataLength = 0;
-// SCARD_DEBUG("buffer [%p], length [%d]", buffer, length);
+// _DBG("buffer [%p], length [%d]", buffer, length);
memcpy(&message, buffer + current, sizeof(message));
current += sizeof(message);
-// SCARD_DEBUG("message [%d]", message);
+// _DBG("message [%d]", message);
memcpy(¶m1, buffer + current, sizeof(param1));
current += sizeof(param1);
-// SCARD_DEBUG("param1 [%d]", param1);
+// _DBG("param1 [%d]", param1);
memcpy(¶m2, buffer + current, sizeof(param2));
current += sizeof(param2);
-// SCARD_DEBUG("param2 [%d]", param2);
+// _DBG("param2 [%d]", param2);
memcpy(&error, buffer + current, sizeof(error));
current += sizeof(error);
memcpy(&userParam, buffer + current, sizeof(userParam));
current += sizeof(userParam);
-// SCARD_DEBUG("userContext [%p]", userContext);
+// _DBG("userContext [%p]", userContext);
if (current + sizeof(dataLength) < length)
{
memcpy(&dataLength, buffer + current, sizeof(dataLength));
current += sizeof(dataLength);
-// SCARD_DEBUG("dataLength [%d]", dataLength);
+// _DBG("dataLength [%d]", dataLength);
data.setBuffer(buffer + current, dataLength);
current += dataLength;
}
else
{
- SCARD_DEBUG_ERR("alloc failed");
+ _ERR("alloc failed");
}
return ret;
{
if (EVP_DigestUpdate(&mdCtx, buffer.getBuffer(), buffer.getLength()) == 0)
{
- SCARD_DEBUG_ERR("EVP_DigestUpdate failed");
+ _ERR("EVP_DigestUpdate failed");
}
if (EVP_DigestFinal(&mdCtx, temp, &resultLen) > 0 &&
}
else
{
- SCARD_DEBUG_ERR("EVP_get_digestbyname(\"%s\") returns NULL", algorithm);
+ _ERR("EVP_get_digestbyname(\"%s\") returns NULL", algorithm);
}
return ret;
ret = select(PKCS15::PKCS15_AID);
if (ret == FileObject::SUCCESS)
{
- SCARD_DEBUG("response : %s", selectResponse.toString());
+ _DBG("response : %s", selectResponse.toString());
}
else if (ret == ResponseHelper::ERROR_FILE_NOT_FOUND)
{
- SCARD_DEBUG_ERR("PKCS15 AID not found, search in EF DIR");
+ _ERR("PKCS15 AID not found, search in EF DIR");
if (selectFromEFDIR() == true)
{
- SCARD_DEBUG("response : %s", selectResponse.toString());
+ _DBG("response : %s", selectResponse.toString());
}
else
{
- SCARD_DEBUG_ERR("PKCS15 select failed, [%d]", ret);
+ _ERR("PKCS15 select failed, [%d]", ret);
}
}
else
{
- SCARD_DEBUG_ERR("PKCS15 select failed, [%d]", ret);
+ _ERR("PKCS15 select failed, [%d]", ret);
}
}
}
else
{
- SCARD_DEBUG_ERR("path select failed, [%d]", ret);
+ _ERR("path select failed, [%d]", ret);
}
}
else
{
- SCARD_DEBUG_ERR("PKCS15 not found");
+ _ERR("PKCS15 not found");
}
return result;
if (odf != NULL && odf->isClosed() == true)
{
- SCARD_DEBUG_ERR("failed to open ODF");
+ _ERR("failed to open ODF");
delete odf;
odf = NULL;
}
}
- SCARD_DEBUG("odf [%p]", odf);
+ _DBG("odf [%p]", odf);
return odf;
}
{
ByteArray dodfData, extra;
- SCARD_DEBUG("response : %s", selectResponse.toString());
+ _DBG("response : %s", selectResponse.toString());
if ((ret = readBinary(0, 0, getFCP()->getFileSize(), dodfData)) == 0)
{
- SCARD_DEBUG("odfData : %s", dodfData.toString());
+ _DBG("odfData : %s", dodfData.toString());
parseData(dodfData);
}
else
{
- SCARD_DEBUG_ERR("readBinary failed, [%d]", ret);
+ _ERR("readBinary failed, [%d]", ret);
}
}
else
{
- SCARD_DEBUG_ERR("select failed, [%d]", ret);
+ _ERR("select failed, [%d]", ret);
}
}
{
ByteArray dodfData, extra;
- SCARD_DEBUG("response : %s", selectResponse.toString());
+ _DBG("response : %s", selectResponse.toString());
if ((ret = readBinary(0, 0, getFCP()->getFileSize(), dodfData)) == 0)
{
- SCARD_DEBUG("dodfData : %s", dodfData.toString());
+ _DBG("dodfData : %s", dodfData.toString());
parseData(dodfData);
}
else
{
- SCARD_DEBUG_ERR("readBinary failed, [%d]", ret);
+ _ERR("readBinary failed, [%d]", ret);
}
}
else
{
- SCARD_DEBUG_ERR("select failed, [%d]", ret);
+ _ERR("select failed, [%d]", ret);
}
}
{
PKCS15OID oid(tlv.getValue());
- SCARD_DEBUG("OID DataObject");
+ _DBG("OID DataObject");
pair<ByteArray, PKCS15OID> newPair(oid.getOID(), oid);
mapOID.insert(newPair);
break;
default :
- SCARD_DEBUG("Unknown tlv : t [%X], l [%d], v %s", tlv.getTag(), tlv.getLength(), tlv.getValue().toString());
+ _DBG("Unknown tlv : t [%X], l [%d], v %s", tlv.getTag(), tlv.getLength(), tlv.getValue().toString());
break;
}
}
- SCARD_DEBUG("dataList.size() = %d", mapOID.size());
+ _DBG("dataList.size() = %d", mapOID.size());
return result;
}
{
ByteArray odfData, extra;
- SCARD_DEBUG("response : %s", selectResponse.toString());
+ _DBG("response : %s", selectResponse.toString());
if ((ret = readBinary(0, 0, getFCP()->getFileSize(), odfData)) == 0)
{
- SCARD_DEBUG("odfData : %s", odfData.toString());
+ _DBG("odfData : %s", odfData.toString());
parseData(odfData);
}
else
{
- SCARD_DEBUG_ERR("readBinary failed, [%d]", ret);
+ _ERR("readBinary failed, [%d]", ret);
}
}
else
{
- SCARD_DEBUG_ERR("select failed, [%d]", ret);
+ _ERR("select failed, [%d]", ret);
}
}
if ((ret = readBinary(0, 0, 0, odfData)) == 0)
{
- SCARD_DEBUG("odfData : %s", odfData.toString());
+ _DBG("odfData : %s", odfData.toString());
parseData(odfData);
}
else
{
- SCARD_DEBUG_ERR("readBinary failed, [%d]", ret);
+ _ERR("readBinary failed, [%d]", ret);
}
}
{
ByteArray dodf;
- SCARD_DEBUG("TAG_DODF");
+ _DBG("TAG_DODF");
dodf = PKCS15Object::getOctetStream(tlv.getValue());
- SCARD_DEBUG("path : %s", dodf.toString());
+ _DBG("path : %s", dodf.toString());
pair<unsigned int, ByteArray> newPair(tlv.getTag(), dodf);
dataList.insert(newPair);
{
ByteArray tokeninfo;
- SCARD_DEBUG("TAG_TOKENINFO");
+ _DBG("TAG_TOKENINFO");
tokeninfo = PKCS15Object::getOctetStream(tlv.getValue());
- SCARD_DEBUG("path : %s", tokeninfo.toString());
+ _DBG("path : %s", tokeninfo.toString());
pair<unsigned int, ByteArray> newPair(tlv.getTag(), tokeninfo);
dataList.insert(newPair);
break;
default :
- SCARD_DEBUG("Unknown tlv : t [%X], l [%d], v %s",
+ _DBG("Unknown tlv : t [%X], l [%d], v %s",
tlv.getTag(), tlv.getLength(), tlv.getValue().toString());
break;
}
}
- SCARD_DEBUG("dataList.size() = %d", dataList.size());
+ _DBG("dataList.size() = %d", dataList.size());
return result;
}
NumberStream num(item->second);
unsigned int fid = num.getLittleEndianNumber();
- SCARD_DEBUG("fid [%X]", fid);
+ _DBG("fid [%X]", fid);
dodf = new PKCS15DODF(fid, channel);
if (dodf != NULL && dodf->isClosed() == true)
{
- SCARD_DEBUG_ERR("failed to open DODF");
+ _ERR("failed to open DODF");
delete dodf;
dodf = NULL;
}
else
{
- SCARD_DEBUG_ERR("[%02X] is not found. total [%d]", TAG_DODF, dataList.size());
+ _ERR("[%02X] is not found. total [%d]", TAG_DODF, dataList.size());
}
}
- SCARD_DEBUG("dodf [%p]", dodf);
+ _DBG("dodf [%p]", dodf);
return dodf;
}
bool result = false;
SimpleTLV tlv(data);
- SCARD_BEGIN();
+ _BEGIN();
while (tlv.decodeTLV() == true)
{
{
/* common object attribute */
/* if you want to use this value, add member variable and parse here */
-// SCARD_DEBUG_ERR("common object attribute is empty");
+// _ERR("common object attribute is empty");
}
break;
case 0xA0 : /* CHOICE 0 : External Oid??? */
- SCARD_DEBUG_ERR("oid doesn't exist");
+ _ERR("oid doesn't exist");
break;
case 0xA1 : /* CHOICE 1 : OidDO */
{
oid = tlv.getValue();
- SCARD_DEBUG("oid : %s", oid.toString());
+ _DBG("oid : %s", oid.toString());
}
else
{
- SCARD_DEBUG_ERR("oid is empty");
+ _ERR("oid is empty");
}
/* path */
{
path = SimpleTLV::getOctetString(tlv.getValue());
- SCARD_DEBUG("path : %s", path.toString());
+ _DBG("path : %s", path.toString());
result = true;
}
else
{
- SCARD_DEBUG_ERR("sequence is empty");
+ _ERR("sequence is empty");
}
tlv.returnToParentTLV();
}
else
{
- SCARD_DEBUG_ERR("common dataobject attribute is empty");
+ _ERR("common dataobject attribute is empty");
}
tlv.returnToParentTLV();
break;
default :
- SCARD_DEBUG_ERR("Unknown tag : 0x%02X", tlv.getTag());
+ _ERR("Unknown tag : 0x%02X", tlv.getTag());
break;
}
}
- SCARD_END();
+ _END();
return result;
}
}
else
{
- SCARD_DEBUG_ERR("TAG_OCTET_STREAM not found");
+ _ERR("TAG_OCTET_STREAM not found");
}
tlv.returnToParentTLV();
}
else
{
- SCARD_DEBUG_ERR("TAG_SEQUENCE not found");
+ _ERR("TAG_SEQUENCE not found");
}
return result;
if (channel == NULL)
{
- SCARD_DEBUG_ERR("invalid channel");
+ _ERR("invalid channel");
return;
}
{
SEServiceHelper::~SEServiceHelper()
{
- SCARD_BEGIN();
- SCARD_END();
+ _BEGIN();
+ _END();
}
} /* namespace smartcard_service_api */
if(pkgmgrinfo_appinfo_get_appinfo(packageName, &handle_appinfo) != PMINFO_R_OK)
{
- SCARD_DEBUG_ERR("pkgmgrinfo_appinfo_get_appinfo fail");
+ _ERR("pkgmgrinfo_appinfo_get_appinfo fail");
return result;
}
if(pkgmgrinfo_appinfo_get_pkgid(handle_appinfo, &pkgid) != PMINFO_R_OK)
{
pkgmgrinfo_appinfo_destroy_appinfo(handle_appinfo);
- SCARD_DEBUG_ERR("pkgmgrinfo_appinfo_get_pkgid fail");
+ _ERR("pkgmgrinfo_appinfo_get_pkgid fail");
return result;
}
pkgmgrinfo_appinfo_destroy_appinfo(handle_appinfo);
OpensslHelper::decodeBase64String(value, result, false);
if (result.getLength() > 0)
{
- SCARD_DEBUG("type [%d] hash [%d] : %s", type, result.getLength(), result.toString());
+ _DBG("type [%d] hash [%d] : %s", type, result.getLength(), result.toString());
break;
}
}
}
else
{
- SCARD_DEBUG_ERR("pkgmgr_pkginfo_load_certinfo failed [%d]", ret);
+ _ERR("pkgmgr_pkginfo_load_certinfo failed [%d]", ret);
}
pkgmgr_pkginfo_destroy_certinfo(handle);
}
else
{
- SCARD_DEBUG_ERR("pkgmgr_pkginfo_create_certinfo failed [%d]", ret);
+ _ERR("pkgmgr_pkginfo_create_certinfo failed [%d]", ret);
}
return result;
}
else
{
- SCARD_DEBUG_ERR("aul_app_get_pkgname_bypid failed [%d]", error);
+ _ERR("aul_app_get_pkgname_bypid failed [%d]", error);
}
return result;
}
else
{
- SCARD_DEBUG_ERR("aul_app_get_pkgname_bypid failed [%d]", error);
+ _ERR("aul_app_get_pkgname_bypid failed [%d]", error);
}
return result;
if(pkgmgrinfo_appinfo_get_appinfo(packageName, &handle_appinfo) != PMINFO_R_OK)
{
- SCARD_DEBUG_ERR("pkgmgrinfo_appinfo_get_appinfo fail");
+ _ERR("pkgmgrinfo_appinfo_get_appinfo fail");
return result;
}
if(pkgmgrinfo_appinfo_get_pkgid(handle_appinfo, &pkgid) != PMINFO_R_OK)
{
pkgmgrinfo_appinfo_destroy_appinfo(handle_appinfo);
- SCARD_DEBUG_ERR("pkgmgrinfo_appinfo_get_pkgid fail");
+ _ERR("pkgmgrinfo_appinfo_get_pkgid fail");
return result;
}
OpensslHelper::digestBuffer("sha1", decodeValue.getBuffer(), decodeValue.getLength(), hash);
if(hash.getLength() > 0)
{
- SCARD_DEBUG("type [%d] hash [%d] : %s", type, hash.getLength(), hash.toString());
+ _DBG("type [%d] hash [%d] : %s", type, hash.getLength(), hash.toString());
certHashes.push_back(hash);
}
}
}
else
{
- SCARD_DEBUG_ERR("pkgmgr_pkginfo_load_certinfo failed [%d]", ret);
+ _ERR("pkgmgr_pkginfo_load_certinfo failed [%d]", ret);
}
pkgmgrinfo_appinfo_destroy_appinfo(handle_appinfo);
}
else
{
- SCARD_DEBUG_ERR("pkgmgr_pkginfo_create_certinfo failed [%d]", ret);
+ _ERR("pkgmgr_pkginfo_create_certinfo failed [%d]", ret);
}
return result;
return head;
ERROR :
- SCARD_DEBUG_ERR("mem alloc fail");
+ _ERR("mem alloc fail");
while (head)
{
}
else
{
- SCARD_DEBUG_ERR("getOctetString failed (0x%02X)", tlv.getTag());
+ _ERR("getOctetString failed (0x%02X)", tlv.getTag());
}
return result;
}
else
{
- SCARD_DEBUG_ERR("getBoolean failed (0x%02X)", tlv.getTag());
+ _ERR("getBoolean failed (0x%02X)", tlv.getTag());
}
return result;
}
else
{
- SCARD_DEBUG_ERR("getInteger failed (0x%02X)", tlv.getTag());
+ _ERR("getInteger failed (0x%02X)", tlv.getTag());
}
return result;
{
bool result = true;
-// SCARD_DEBUG("current [%p], parent [%p]", currentTLV, currentTLV->getParentTLV());
+// _DBG("current [%p], parent [%p]", currentTLV, currentTLV->getParentTLV());
if (currentTLV->getParentTLV() != NULL)
{
/* local header */
-#define COLOR_RED "\033[0;31m"
-#define COLOR_GREEN "\033[0;32m"
-#define COLOR_BROWN "\033[0;33m"
-#define COLOR_BLUE "\033[0;34m"
-#define COLOR_PURPLE "\033[0;35m"
-#define COLOR_CYAN "\033[0;36m"
-#define COLOR_LIGHTBLUE "\033[0;37m"
-#define COLOR_END "\033[0;m"
-
-#define SCARD_DEBUG(fmt, ...)\
- do\
- {\
- LOGD(fmt, ##__VA_ARGS__);\
- } while (0)
-
-#define SCARD_DEBUG_ERR(fmt, ...)\
- do\
- {\
- LOGE(COLOR_RED fmt COLOR_END, ##__VA_ARGS__);\
- }while (0)
-
-#define SCARD_BEGIN() \
- do\
- {\
- LOGD(COLOR_BLUE "BEGIN >>>>" COLOR_END);\
- } while( 0 )
-
-#define SCARD_END() \
- do\
- {\
- LOGD(COLOR_BLUE "END <<<<" COLOR_END);\
- } \
- while( 0 )
+#define COLOR_BLACK "\033[0;30m"
+#define COLOR_RED "\033[0;31m"
+#define COLOR_GREEN "\033[0;32m"
+#define COLOR_BROWN "\033[0;33m"
+#define COLOR_BLUE "\033[0;34m"
+#define COLOR_PURPLE "\033[0;35m"
+#define COLOR_CYAN "\033[0;36m"
+#define COLOR_GRAY "\033[0;37m"
+#define COLOR_END "\033[0;m"
+
+#define _ERR(fmt, ...) \
+ do \
+ { \
+ LOGE(COLOR_RED fmt COLOR_END, ##__VA_ARGS__); \
+ } \
+ while (0)
+
+#define _INFO(fmt, ...) \
+ do \
+ { \
+ LOGI(COLOR_GREEN fmt COLOR_END, ##__VA_ARGS__); \
+ } \
+ while (0)
+
+#define _WARN(fmt, ...) \
+ do \
+ { \
+ LOGI(COLOR_BROWN fmt COLOR_END, ##__VA_ARGS__); \
+ } \
+ while (0)
+
+#define _DBG(fmt, ...) \
+ do \
+ { \
+ LOGD(fmt, ##__VA_ARGS__); \
+ } \
+ while (0)
+
+#define _BEGIN() \
+ do \
+ { \
+ LOGD(COLOR_BLUE"BEGIN >>>>"COLOR_END); \
+ } \
+ while (0)
+
+#define _END() \
+ do \
+ { \
+ LOGD(COLOR_BLUE"END <<<<"COLOR_END); \
+ } \
+ while (0)
#endif /* DEBUG_H_ */
}
else
{
- SCARD_DEBUG_ERR("alloc failed");
+ _ERR("alloc failed");
}
}
else
{
- SCARD_DEBUG_ERR("service already exist [%d]", context);
+ _ERR("service already exist [%d]", context);
}
return result;
if (resp.getStatus() == 0)
{
- SCARD_DEBUG("close success");
+ _DBG("close success");
}
else
{
- SCARD_DEBUG_ERR("status word [%d][ %02X %02X ]", resp.getStatus(), resp.getSW1(), resp.getSW2());
+ _ERR("status word [%d][ %02X %02X ]", resp.getStatus(), resp.getSW1(), resp.getSW2());
}
}
else
{
- SCARD_DEBUG_ERR("select apdu is failed, rv [%d], length [%d]", rv, result.getLength());
+ _ERR("select apdu is failed, rv [%d], length [%d]", rv, result.getLength());
}
}
helper.getBuffer(command);
- SCARD_DEBUG("command [%d] : %s", command.getLength(), command.toString());
+ _DBG("command [%d] : %s", command.getLength(), command.toString());
ret = terminal->transmitSync(command, result);
if (ret == 0 && ResponseHelper::getStatus(result) == 0)
{
ServerDispatcher::ServerDispatcher():DispatcherHelper()
{
- SCARD_BEGIN();
+ _BEGIN();
runDispatcherThread();
- SCARD_END();
+ _END();
}
ServerDispatcher::~ServerDispatcher()
if (data == NULL)
{
- SCARD_DEBUG_ERR("dispatcher instance is null");
+ _ERR("dispatcher instance is null");
return NULL;
}
if (msg == NULL)
{
- SCARD_DEBUG_ERR("message is null");
+ _ERR("message is null");
return NULL;
}
if (instance->getPID() == -1)
{
instance->setPID(msg->error);
- SCARD_DEBUG_ERR("update PID [%d]", msg->error);
+ _ERR("update PID [%d]", msg->error);
/* generate certification hashes */
instance->generateCertificationHashes();
}
else
{
- SCARD_DEBUG("no secure elements");
+ _DBG("no secure elements");
}
}
else
{
- SCARD_DEBUG_ERR("createClient failed");
+ _ERR("createClient failed");
response.error = SCARD_ERROR_UNAVAILABLE;
}
}
else
{
- SCARD_DEBUG("client doesn't exist, socket [%d]", socket);
+ _DBG("client doesn't exist, socket [%d]", socket);
response.error = SCARD_ERROR_UNAVAILABLE;
}
{
Message response(*msg);
- SCARD_DEBUG("[MSG_REQUEST_SHUTDOWN]");
+ _DBG("[MSG_REQUEST_SHUTDOWN]");
response.error = SCARD_ERROR_OK;
Message response(*msg);
unsigned int handle = IntegerHandle::INVALID_HANDLE;
- SCARD_DEBUG("[MSG_REQUEST_OPEN_SESSION]");
+ _DBG("[MSG_REQUEST_OPEN_SESSION]");
if (resource->isValidReaderHandle(msg->param1))
{
}
else
{
- SCARD_DEBUG_ERR("createSession failed [%d]", handle);
+ _ERR("createSession failed [%d]", handle);
response.error = SCARD_ERROR_OUT_OF_MEMORY;
}
}
else
{
- SCARD_DEBUG_ERR("request invalid reader handle [%d]", msg->param1);
+ _ERR("request invalid reader handle [%d]", msg->param1);
response.error = SCARD_ERROR_ILLEGAL_PARAM;
}
{
Message response(*msg);
- SCARD_DEBUG("[MSG_REQUEST_CLOSE_SESSION]");
+ _DBG("[MSG_REQUEST_CLOSE_SESSION]");
response.param1 = 0;
response.error = SCARD_ERROR_OK;
{
Message response(*msg);
- SCARD_DEBUG("[MSG_REQUEST_OPEN_CHANNEL]");
+ _DBG("[MSG_REQUEST_OPEN_CHANNEL]");
response.param1 = IntegerHandle::INVALID_HANDLE;
response.param2 = 0;
}
else
{
- SCARD_DEBUG_ERR("IS IT POSSIBLE??????????????????");
+ _ERR("IS IT POSSIBLE??????????????????");
response.error = SCARD_ERROR_UNKNOWN;
}
}
else
{
- SCARD_DEBUG_ERR("channel is null.");
+ _ERR("channel is null.");
/* set error value */
response.error = SCARD_ERROR_UNAVAILABLE;
{
Message response(*msg);
- SCARD_DEBUG("[MSG_REQUEST_GET_CHANNEL_COUNT]");
+ _DBG("[MSG_REQUEST_GET_CHANNEL_COUNT]");
response.error = SCARD_ERROR_OK;
response.param1 = resource->getChannelCount(socket, msg->error/* service context */, msg->param1);
{
Message response(*msg);
- SCARD_DEBUG("[MSG_REQUEST_CLOSE_CHANNEL]");
+ _DBG("[MSG_REQUEST_CLOSE_CHANNEL]");
response.error = SCARD_ERROR_OK;
ByteArray result;
ServiceInstance *client = NULL;
- SCARD_DEBUG("[MSG_REQUEST_GET_ATR]");
+ _DBG("[MSG_REQUEST_GET_ATR]");
if ((client = resource->getService(socket, msg->error/* service context */)) != NULL)
{
}
else
{
- SCARD_DEBUG_ERR("transmit failed [%d]", rv);
+ _ERR("transmit failed [%d]", rv);
response.error = rv;
}
}
else
{
- SCARD_DEBUG_ERR("getTerminal failed : socket [%d], context [%d], session [%d]", socket, msg->error/* service context */, msg->param1);
+ _ERR("getTerminal failed : socket [%d], context [%d], session [%d]", socket, msg->error/* service context */, msg->param1);
response.error = SCARD_ERROR_UNAVAILABLE;
}
}
else
{
- SCARD_DEBUG_ERR("getClient failed : socket [%d], context [%d], session [%d]", socket, msg->error/* service context */, msg->param1);
+ _ERR("getClient failed : socket [%d], context [%d], session [%d]", socket, msg->error/* service context */, msg->param1);
response.error = SCARD_ERROR_UNAVAILABLE;
}
ByteArray result;
Channel *channel = NULL;
- SCARD_DEBUG("[MSG_REQUEST_TRANSMIT]");
+ _DBG("[MSG_REQUEST_TRANSMIT]");
if ((channel = resource->getChannel(socket, msg->error/* service context */, msg->param1)) != NULL)
{
}
else
{
- SCARD_DEBUG_ERR("transmit failed [%d]", rv);
+ _ERR("transmit failed [%d]", rv);
response.error = rv;
}
}
else
{
- SCARD_DEBUG_ERR("invalid handle : socket [%d], context [%d], channel [%d]", socket, msg->error/* service context */, msg->param1);
+ _ERR("invalid handle : socket [%d], context [%d], channel [%d]", socket, msg->error/* service context */, msg->param1);
response.error = SCARD_ERROR_UNAVAILABLE;
}
{
ServerIPC::ServerIPC():IPCHelper()
{
- SCARD_BEGIN();
+ _BEGIN();
setDispatcher(ServerDispatcher::getInstance());
- SCARD_END();
+ _END();
}
ServerIPC::~ServerIPC()
ByteArray buffer;
Message *msg = NULL;
- SCARD_BEGIN();
+ _BEGIN();
buffer = IPCHelper::retrieveBuffer(socket);
if (buffer.getLength() > 0)
gid = security_server_get_gid("smartcard-daemon");
if ((result = security_server_check_privilege(cookie.getBuffer(), gid)) != SECURITY_SERVER_API_SUCCESS)
{
- SCARD_DEBUG_ERR("security_server_check_privilege failed [%d]", result);
+ _ERR("security_server_check_privilege failed [%d]", result);
return msg;
}
#endif
}
else
{
- SCARD_DEBUG_ERR("alloc failed");
+ _ERR("alloc failed");
}
}
else
{
- SCARD_DEBUG_ERR("retrieveBuffer failed ");
+ _ERR("retrieveBuffer failed ");
}
- SCARD_END();
+ _END();
return msg;
}
GIOChannel *client_channel = NULL;
int client_src_id;
- SCARD_DEBUG("client is trying to connect to server");
+ _DBG("client is trying to connect to server");
pthread_mutex_lock(&ipcLock);
client_sock_fd = accept(ipcSocket, NULL, &addrlen);
if (client_sock_fd < 0)
{
- SCARD_DEBUG_ERR("can not accept client");
+ _ERR("can not accept client");
goto ERROR;
}
- SCARD_DEBUG("client is accepted by server");
+ _DBG("client is accepted by server");
if ((client_channel = g_io_channel_unix_new(client_sock_fd)) == NULL)
{
- SCARD_DEBUG_ERR("create new g io channel is failed");
+ _ERR("create new g io channel is failed");
goto ERROR;
}
if ((client_src_id = g_io_add_watch(client_channel, condition, &IPCHelper::channelCallbackFunc, this)) < 1)
{
- SCARD_DEBUG_ERR("add io callback is failed");
+ _ERR("add io callback is failed");
goto ERROR;
}
- SCARD_DEBUG("client socket is bond with g_io_channel");
+ _DBG("client socket is bond with g_io_channel");
if (ServerResource::getInstance().createClient(client_channel, client_sock_fd, client_src_id, 0, -1) == false)
{
- SCARD_DEBUG_ERR("failed to add client");
+ _ERR("failed to add client");
}
return true;
int ServerIPC::handleIOErrorCondition(void *channel, GIOCondition condition)
{
- SCARD_BEGIN();
+ _BEGIN();
if(channel == ioChannel)
{
- SCARD_DEBUG("server socket is closed");
+ _DBG("server socket is closed");
restartServerIPC();
}
else
DispatcherMsg dispMsg;
int peerSocket = g_io_channel_unix_get_fd((GIOChannel *)channel);
- SCARD_DEBUG("client socket is closed, socket [%d]", peerSocket);
+ _DBG("client socket is closed, socket [%d]", peerSocket);
- /* push messsage to dispatcher */
+ /* push message to dispatcher */
dispMsg.message = Message::MSG_OPERATION_RELEASE_CLIENT;
dispMsg.param1 = peerSocket;
dispMsg.setPeerSocket(peerSocket);
ServerDispatcher::getInstance()->pushMessage(&dispMsg);
}
- SCARD_END();
+ _END();
return FALSE;
}
int ServerIPC::handleInvalidSocketCondition(void *channel, GIOCondition condition)
{
- SCARD_BEGIN();
- SCARD_END();
+ _BEGIN();
+ _END();
return FALSE;
}
{
int result = FALSE;
- SCARD_BEGIN();
+ _BEGIN();
if(channel == ioChannel)
{
/* connect state. should accept */
- SCARD_DEBUG("new client connected");
+ _DBG("new client connected");
result = acceptClient();
}
{
int peerSocket = g_io_channel_unix_get_fd((GIOChannel *)channel);
- SCARD_DEBUG("data incomming from [%d]", peerSocket);
+ _DBG("data incoming from [%d]", peerSocket);
if (peerSocket >= 0)
{
else
{
/* clear client connection */
- SCARD_DEBUG_ERR("retrieve message failed, socket [%d]", peerSocket);
+ _ERR("retrieve message failed, socket [%d]", peerSocket);
}
}
else
{
- SCARD_DEBUG_ERR("client context doesn't exist, socket [%d]", peerSocket);
+ _ERR("client context doesn't exist, socket [%d]", peerSocket);
}
}
- SCARD_END();
+ _END();
return result;
}
if (seService == NULL || name == NULL || strlen(name) == 0 || terminal == NULL)
{
- SCARD_DEBUG_ERR("invalid param");
+ _ERR("invalid param");
return;
}
adminChannel = new ServerChannel(NULL, NULL, 0, terminal);
if (adminChannel == NULL)
{
- SCARD_DEBUG_ERR("alloc failed");
+ _ERR("alloc failed");
}
}
}
else
{
- SCARD_DEBUG_ERR("alloc failed");
+ _ERR("alloc failed");
}
}
while (!result.second);
}
- SCARD_DEBUG("assign handle : newHandle [%d]", newHandle);
+ _DBG("assign handle : newHandle [%d]", newHandle);
return newHandle;
}
void IntegerHandle::releaseHandle(unsigned int handle)
{
- SCARD_DEBUG("will be released : Handle [%d]", handle);
+ _DBG("will be released : Handle [%d]", handle);
SCOPE_LOCK(mutexLock)
{
ServerResource::ServerResource()
: mainLoop(NULL), seLoaded(false)
{
- SCARD_BEGIN();
+ _BEGIN();
serverIPC = ServerIPC::getInstance();
serverDispatcher = ServerDispatcher::getInstance();
- SCARD_END();
+ _END();
}
ServerResource::~ServerResource()
}
else
{
- SCARD_DEBUG_ERR("alloc failed");
+ _ERR("alloc failed");
}
}
else
{
- SCARD_DEBUG_ERR("client already exist [%d]", socket);
+ _ERR("client already exist [%d]", socket);
}
return result;
}
else
{
- SCARD_DEBUG("client removed already [%d]", socket);
+ _DBG("client removed already [%d]", socket);
}
}
{
if ((result = instance->createService(context)) == NULL)
{
- SCARD_DEBUG_ERR("ClientInstance::createService failed [%d] [%d]", socket, context);
+ _ERR("ClientInstance::createService failed [%d] [%d]", socket, context);
}
}
}
else
{
- SCARD_DEBUG_ERR("client doesn't exist [%d]", socket);
+ _ERR("client doesn't exist [%d]", socket);
}
return result;
}
else
{
- SCARD_DEBUG_ERR("client doesn't exist [%d]", socket);
+ _ERR("client doesn't exist [%d]", socket);
}
return result;
}
else
{
- SCARD_DEBUG_ERR("client doesn't exist [%d]", socket);
+ _ERR("client doesn't exist [%d]", socket);
}
}
}
else
{
- SCARD_DEBUG_ERR("client doesn't exist [%d]", socket);
+ _ERR("client doesn't exist [%d]", socket);
}
}
}
else
{
- SCARD_DEBUG_ERR("Terminal doesn't exist [%d]", terminalID);
+ _ERR("Terminal doesn't exist [%d]", terminalID);
}
return result;
}
else
{
- SCARD_DEBUG_ERR("Terminal doesn't exist, reader ID [%d]", readerID);
+ _ERR("Terminal doesn't exist, reader ID [%d]", readerID);
}
return result;
}
else
{
- SCARD_DEBUG_ERR("getService doesn't exist : socket [%d], context [%d]", socket, context);
+ _ERR("getService doesn't exist : socket [%d], context [%d]", socket, context);
}
return result;
}
else
{
- SCARD_DEBUG_ERR("Session doesn't exist : socket [%d], context [%d], handle [%d]", socket, context, sessionID);
+ _ERR("Session doesn't exist : socket [%d], context [%d], handle [%d]", socket, context, sessionID);
}
return result;
}
else
{
- SCARD_DEBUG_ERR("getService doesn't exist : socket [%d], context [%d]", socket, context);
+ _ERR("getService doesn't exist : socket [%d], context [%d]", socket, context);
}
return result;
}
else
{
- SCARD_DEBUG_ERR("getService doesn't exist : socket [%d], context [%d]", socket, context);
+ _ERR("getService doesn't exist : socket [%d], context [%d]", socket, context);
}
}
}
else
{
- SCARD_DEBUG_ERR("acList is null");
+ _ERR("acList is null");
result = false;
}
}
else
{
- SCARD_DEBUG_ERR("status word [%d][ %02X %02X ]", resp.getStatus(), resp.getSW1(), resp.getSW2());
+ _ERR("status word [%d][ %02X %02X ]", resp.getStatus(), resp.getSW1(), resp.getSW2());
if (0)
{
/* TODO : if there is no more channel, return error code */
- SCARD_DEBUG_ERR("no more logical channel");
+ _ERR("no more logical channel");
result = -2;
}
}
}
else
{
- SCARD_DEBUG_ERR("select apdu is failed, rv [%d], length [%d]", rv, response.getLength());
+ _ERR("select apdu is failed, rv [%d], length [%d]", rv, response.getLength());
}
return result;
if (resp.getStatus() == 0)
{
- SCARD_DEBUG("channel closed [%d]", channelNum);
+ _DBG("channel closed [%d]", channelNum);
result = 0;
}
else
{
- SCARD_DEBUG_ERR("status word [%d][ %02X %02X ]", resp.getStatus(), resp.getSW1(), resp.getSW2());
+ _ERR("status word [%d][ %02X %02X ]", resp.getStatus(), resp.getSW1(), resp.getSW2());
}
}
else
{
- SCARD_DEBUG_ERR("select apdu is failed, rv [%d], length [%d]", rv, response.getLength());
+ _ERR("select apdu is failed, rv [%d], length [%d]", rv, response.getLength());
}
return result;
channelNum = _openLogicalChannel(terminal);
if (channelNum > 0)
{
- SCARD_DEBUG("channelNum [%d]", channelNum);
+ _DBG("channelNum [%d]", channelNum);
}
else
{
- SCARD_DEBUG_ERR("_openLogicalChannel failed [%d]", channelNum);
+ _ERR("_openLogicalChannel failed [%d]", channelNum);
throw ExceptionBase(SCARD_ERROR_NOT_ENOUGH_RESOURCE);
}
}
result = service->openChannel(sessionID, channelNum, ByteArray::EMPTY);
if (result == IntegerHandle::INVALID_HANDLE)
{
- SCARD_DEBUG_ERR("channel is null.");
+ _ERR("channel is null.");
/* close logical channel */
if (channelNum > 0)
}
else
{
- SCARD_DEBUG_ERR("select failed");
+ _ERR("select failed");
service->closeChannel(result);
throw ExceptionBase(SCARD_ERROR_IO_FAILED);
}
else
{
- SCARD_DEBUG_ERR("select failed [%d]", rv);
+ _ERR("select failed [%d]", rv);
service->closeChannel(result);
throw ExceptionBase(SCARD_ERROR_IO_FAILED);
}
else
{
- SCARD_DEBUG_ERR("unauthorized access");
+ _ERR("unauthorized access");
service->closeChannel(result);
throw ExceptionBase(SCARD_ERROR_SECURITY_NOT_ALLOWED);
result = _createChannel(terminal, service, channelType, sessionID, aid);
if (result == IntegerHandle::INVALID_HANDLE)
{
- SCARD_DEBUG_ERR("create channel failed [%d]", sessionID);
+ _ERR("create channel failed [%d]", sessionID);
}
}
else
{
- SCARD_DEBUG_ERR("session is invalid [%d]", sessionID);
+ _ERR("session is invalid [%d]", sessionID);
throw ExceptionBase(SCARD_ERROR_UNAVAILABLE);
}
}
else
{
- SCARD_DEBUG_ERR("session is invalid [%d]", sessionID);
+ _ERR("session is invalid [%d]", sessionID);
throw ExceptionBase(SCARD_ERROR_ILLEGAL_PARAM);
}
}
else
{
- SCARD_DEBUG_ERR("getService is failed [%d] [%d]", socket, context);
+ _ERR("getService is failed [%d] [%d]", socket, context);
throw ExceptionBase(SCARD_ERROR_UNAVAILABLE);
}
}
else
{
- SCARD_DEBUG_ERR("Channel doesn't exist : socket [%d], context [%d], handle [%d]", socket, context, channelID);
+ _ERR("Channel doesn't exist : socket [%d], context [%d], handle [%d]", socket, context, channelID);
}
return result;
}
else
{
- SCARD_DEBUG_ERR("getService doesn't exist : socket [%d], context [%d]", socket, context);
+ _ERR("getService doesn't exist : socket [%d], context [%d]", socket, context);
}
}
}
else
{
- SCARD_DEBUG_ERR("alloc failed");
+ _ERR("alloc failed");
}
}
else
}
else
{
- SCARD_DEBUG_ERR("alloc failed");
+ _ERR("alloc failed");
}
}
else
terminal = (Terminal *)createInstance();
if (terminal != NULL)
{
- SCARD_DEBUG("terminal [%p]", terminal);
+ _DBG("terminal [%p]", terminal);
}
else
{
- SCARD_DEBUG_ERR("terminal is null");
+ _ERR("terminal is null");
}
}
else
{
- SCARD_DEBUG_ERR("create_instance is null [%d]", errno);
+ _ERR("create_instance is null [%d]", errno);
}
return terminal;
terminal->setStatusCallback(&ServerResource::terminalCallback);
- SCARD_DEBUG("register success [%s] [%p] [%s] [%p]", library, libHandle, terminal->getName(), terminal);
+ _DBG("register success [%s] [%p] [%s] [%p]", library, libHandle, terminal->getName(), terminal);
if (terminal->isSecureElementPresence() == true)
{
}
else
{
- SCARD_DEBUG_ERR("terminal is null [%s]", library);
+ _ERR("terminal is null [%s]", library);
dlclose(libHandle);
}
}
else
{
- SCARD_DEBUG_ERR("it is not se file [%s] [%d]", library, errno);
+ _ERR("it is not se file [%s] [%d]", library, errno);
}
return result;
}
else
{
- SCARD_DEBUG_ERR("alloc failed");
+ _ERR("alloc failed");
result = -1;
}
}
else
{
- SCARD_DEBUG("no secure element");
+ _DBG("no secure element");
}
return result;
void ServerResource::terminalCallback(void *terminal, int event, int error, void *user_param)
{
- SCARD_DEBUG("terminal [%s], event [%d], error [%d], user_param [%p]", (char *)terminal, event, error, user_param);
+ _DBG("terminal [%s], event [%d], error [%d], user_param [%p]", (char *)terminal, event, error, user_param);
switch (event)
{
unsigned int terminalID = IntegerHandle::INVALID_HANDLE;
Message msg;
- SCARD_DEBUG("[NOTIFY_SE_AVAILABLE]");
+ _DBG("[NOTIFY_SE_AVAILABLE]");
terminalID = instance.getTerminalID((char *)terminal);
if (terminalID != IntegerHandle::INVALID_HANDLE)
unsigned int readerID = IntegerHandle::INVALID_HANDLE;
Message msg;
- SCARD_DEBUG("[NOTIFY_SE_NOT_AVAILABLE]");
+ _DBG("[NOTIFY_SE_NOT_AVAILABLE]");
readerID = instance.getReaderID((char *)terminal);
break;
default :
- SCARD_DEBUG("terminal [%s], event [%d], error [%d], user_param [%p]", (char *)terminal, event, error, user_param);
+ _DBG("terminal [%s], event [%d], error [%d], user_param [%p]", (char *)terminal, event, error, user_param);
break;
}
}
terminal = (Terminal *)createInstance();
if (terminal != NULL)
{
- SCARD_DEBUG("terminal [%p]", terminal);
+ _DBG("terminal [%p]", terminal);
}
else
{
- SCARD_DEBUG_ERR("terminal is null");
+ _ERR("terminal is null");
}
}
else
{
- SCARD_DEBUG_ERR("create_instance is null [%d]", errno);
+ _ERR("create_instance is null [%d]", errno);
}
return terminal;
terminal = createInstance(libHandle);
if (terminal != NULL)
{
- SCARD_DEBUG("SE info : [%s] [%s]", library, terminal->getName());
+ _DBG("SE info : [%s] [%s]", library, terminal->getName());
libraries.push_back(libHandle);
ServerReader *reader = new ServerReader(this, terminal->getName(), terminal);
if (reader != NULL)
{
- SCARD_DEBUG("register success [%s]", terminal->getName());
+ _DBG("register success [%s]", terminal->getName());
readers.push_back(reader);
}
else
{
- SCARD_DEBUG_ERR("ServerReader alloc failed [%s]", terminal->getName());
+ _ERR("ServerReader alloc failed [%s]", terminal->getName());
/* throw exception */
}
}
else
{
- SCARD_DEBUG("SE is not ready [%s]", terminal->getName());
+ _DBG("SE is not ready [%s]", terminal->getName());
}
result = true;
}
else
{
- SCARD_DEBUG_ERR("createInstance failed [%s]", library);
+ _ERR("createInstance failed [%s]", library);
dlclose(libHandle);
}
}
else
{
- SCARD_DEBUG_ERR("it is not se file [%s] [%d]", library, errno);
+ _ERR("it is not se file [%s] [%d]", library, errno);
}
return result;
if (resource.createService(socket, msg->error) != NULL)
{
- SCARD_DEBUG_ERR("client added : pid [%d]", msg->error);
+ _ERR("client added : pid [%d]", msg->error);
response.error = SCARD_ERROR_OK;
}
else
{
- SCARD_DEBUG("no secure elements");
+ _DBG("no secure elements");
response.param1 = 0;
}
}
else
{
- SCARD_DEBUG_ERR("createClient failed");
+ _ERR("createClient failed");
response.error = SCARD_ERROR_OUT_OF_MEMORY;
}
if (caller == NULL || terminal == NULL)
{
- SCARD_DEBUG_ERR("invalid param");
+ _ERR("invalid param");
return;
}
}
else
{
- SCARD_DEBUG_ERR("alloc failed");
+ _ERR("alloc failed");
}
return handle;
GQuark smartcard_service_error_quark(void)
{
- SCARD_DEBUG("smartcard_service_error_quark entered");
+ _DBG("smartcard_service_error_quark entered");
return g_quark_from_static_string("smartcard_service_error");
}
static void smartcard_service_init(Smartcard_Service *smartcard_service)
{
- SCARD_DEBUG("smartcard_service_init entered");
+ _DBG("smartcard_service_init entered");
}
static void smartcard_service_class_init(Smartcard_ServiceClass *smartcard_service_class)
{
- SCARD_DEBUG("smartcard_service_class_init entered");
+ _DBG("smartcard_service_class_init entered");
dbus_g_object_type_install_info(SMARTCARD_SERVICE_TYPE, &dbus_glib_smartcard_service_object_info);
}
gboolean smartcard_service_launch(Smartcard_Service *smartcard_service, guint *result_val, GError **error)
{
- SCARD_DEBUG("smartcard_service_launch entered");
+ _DBG("smartcard_service_launch entered");
return TRUE;
}
DBusGProxy *proxy = NULL;
guint ret = 0;
- SCARD_BEGIN();
+ _BEGIN();
g_type_init();
{
if (!org_freedesktop_DBus_request_name(proxy, SMARTCARD_SERVICE_NAME, 0, &ret, &error))
{
- SCARD_DEBUG_ERR("Unable to register service: %s", error->message);
+ _ERR("Unable to register service: %s", error->message);
g_error_free(error);
}
}
else
{
- SCARD_DEBUG_ERR("dbus_g_proxy_new_for_name failed");
+ _ERR("dbus_g_proxy_new_for_name failed");
}
}
else
{
- SCARD_DEBUG_ERR("ERROR: Can't get on system bus [%s]", error->message);
+ _ERR("ERROR: Can't get on system bus [%s]", error->message);
g_error_free(error);
}
- SCARD_END();
+ _END();
}
static void _finalize_dbus()
{
- SCARD_BEGIN();
+ _BEGIN();
dbus_g_connection_unregister_g_object(connection, object);
g_object_unref(object);
- SCARD_END();
+ _END();
}
#endif
static void __sighandler(int sig)
{
- SCARD_DEBUG("signal!! [%d]", sig);
+ _DBG("signal!! [%d]", sig);
#ifdef USE_AUTOSTART
_finalize_dbus();
{
void serviceConnected(SEServiceHelper *service, void *userData)
{
- SCARD_BEGIN();
+ _BEGIN();
testConnectedCallback(service, userData);
- SCARD_END();
+ _END();
}
void eventHandler(SEServiceHelper *service, char *seName, int event, void *userData)
{
- SCARD_BEGIN();
+ _BEGIN();
- SCARD_DEBUG("event occured service [%p], seName[%p], event [%d]", service, seName, event);
+ _DBG("event occured service [%p], seName[%p], event [%d]", service, seName, event);
- SCARD_END();
+ _END();
}
void errorHandler(SEServiceHelper *service, int error, void *userData)
{
- SCARD_BEGIN();
+ _BEGIN();
- SCARD_DEBUG("error occured service [%p], error [%d]", service, error);
+ _DBG("error occured service [%p], error [%d]", service, error);
- SCARD_END();
+ _END();
}
};
vector<ReaderHelper *> readers;
user_context_t *context = (user_context_t *)userData;
- SCARD_BEGIN();
+ _BEGIN();
if (service != NULL)
{
- SCARD_DEBUG("callback called, service [%p]", service);
+ _DBG("callback called, service [%p]", service);
context->clientService = service;
reader = (Reader *)readers[0];
- SCARD_DEBUG("reader [%p]", reader);
+ _DBG("reader [%p]", reader);
Session *session = (Session *)reader->openSessionSync();
if (session != NULL)
{
- SCARD_DEBUG("session [%p]", session);
+ _DBG("session [%p]", session);
ByteArray temp;
temp = session->getATRSync();
- SCARD_DEBUG("atr[%d] : %s", temp.getLength(), temp.toString());
+ _DBG("atr[%d] : %s", temp.getLength(), temp.toString());
unsigned char MF[] = { 0xA0, 0x00, 0x00, 0x00, 0x63, 0x50, 0x4B, 0x43, 0x53, 0x2D, 0x31, 0x35 };
ByteArray aid;
ClientChannel *channel = (ClientChannel *)session->openLogicalChannelSync(aid);
if (channel != NULL)
{
- SCARD_DEBUG("channel [%p]", channel);
+ _DBG("channel [%p]", channel);
ByteArray response;
ByteArray data, command;
int fid = 0x00003150;
response = channel->getSelectResponse();
- SCARD_DEBUG("response : %s", response.toString());
+ _DBG("response : %s", response.toString());
- SCARD_DEBUG("isBasicChannel() = %s", channel->isBasicChannel() ? "Basic" : "Logical");
- SCARD_DEBUG("isClosed() = %s", channel->isClosed() ? "Closed" : "Opened");
+ _DBG("isBasicChannel() = %s", channel->isBasicChannel() ? "Basic" : "Logical");
+ _DBG("isClosed() = %s", channel->isClosed() ? "Closed" : "Opened");
data.setBuffer((unsigned char *)&fid, 2);
command = APDUHelper::generateAPDU(APDUHelper::COMMAND_SELECT_BY_ID, 0, data);
int error = channel->transmitSync(command, response);
- SCARD_DEBUG("error : %d, response : %s", error, response.toString());
+ _DBG("error : %d, response : %s", error, response.toString());
channel->closeSync();
}
else
{
- SCARD_DEBUG_ERR("openLogicalChannelSync failed");
+ _ERR("openLogicalChannelSync failed");
}
session->closeSync();
}
else
{
- SCARD_DEBUG_ERR("openSessionSync failed");
+ _ERR("openSessionSync failed");
}
service->shutdown();
}
else
{
- SCARD_DEBUG_ERR("reader is empty");
+ _ERR("reader is empty");
}
}
else
{
- SCARD_DEBUG_ERR("service is NULL");
+ _ERR("service is NULL");
}
g_main_loop_quit(loop);
- SCARD_END();
+ _END();
}
int main(int argv, char *args[])
{
void serviceConnected(SEServiceHelper *service, void *userData)
{
- SCARD_BEGIN();
+ _BEGIN();
testConnectedCallback(service, userData);
- SCARD_END();
+ _END();
}
void eventHandler(SEServiceHelper *service, char *seName, int event, void *userData)
vector<ReaderHelper *> readers;
size_t i;
- SCARD_BEGIN();
+ _BEGIN();
- SCARD_DEBUG("event occured service [%p], seName[%s], event [%d], userData [%p]", service, seName, event, userData);
+ _DBG("event occured service [%p], seName[%s], event [%d], userData [%p]", service, seName, event, userData);
readers = service->getReaders();
for (i = 0; i < readers.size(); i++)
{
- SCARD_DEBUG("Reader[%d] : name [%s], %s", i, readers[i]->getName(), readers[i]->isSecureElementPresent() ? "available" : "unavailable");
+ _DBG("Reader[%d] : name [%s], %s", i, readers[i]->getName(), readers[i]->isSecureElementPresent() ? "available" : "unavailable");
}
if (event == 1)
testConnectedCallback(service, userData);
}
- SCARD_END();
+ _END();
}
void errorHandler(SEServiceHelper *service, int error, void *userData)
{
- SCARD_BEGIN();
+ _BEGIN();
- SCARD_DEBUG("error occured service [%p], error [%d]", service, error);
+ _DBG("error occured service [%p], error [%d]", service, error);
- SCARD_END();
+ _END();
}
};
{
user_context_t *context = (user_context_t *)userData;
- SCARD_DEBUG("result [%d], userData [%p]", error, userData);
+ _DBG("result [%d], userData [%p]", error, userData);
context->clientService->shutdown();
}
ByteArray response(buffer, length);
user_context_t *context = (user_context_t *)userData;
- SCARD_DEBUG("buffer [%p], length [%d], error [%d], userData [%p]", buffer, length, error, userData);
+ _DBG("buffer [%p], length [%d], error [%d], userData [%p]", buffer, length, error, userData);
context->clientChannel->close(testCloseCallback, userData);
}
void testOpenChannelCallback(Channel *channel, int error, void *userData)
{
- SCARD_DEBUG("channel [%p]", channel);
+ _DBG("channel [%p]", channel);
if (error == 0 && channel != NULL)
{
response = channel->getSelectResponse();
- SCARD_DEBUG("response : %s", response.toString());
+ _DBG("response : %s", response.toString());
- SCARD_DEBUG("isBasicChannel() = %s", channel->isBasicChannel() ? "Basic" : "Logical");
- SCARD_DEBUG("isClosed() = %s", channel->isClosed() ? "Closed" : "Opened");
+ _DBG("isBasicChannel() = %s", channel->isBasicChannel() ? "Basic" : "Logical");
+ _DBG("isClosed() = %s", channel->isClosed() ? "Closed" : "Opened");
data.setBuffer((unsigned char *)&fid, 2);
command = APDUHelper::generateAPDU(APDUHelper::COMMAND_SELECT_BY_ID, 0, data);
}
else
{
- SCARD_DEBUG_ERR("openBasicChannel failed");
+ _ERR("openBasicChannel failed");
}
}
ByteArray aid, result(atr, length);
user_context_t *context = (user_context_t *)userData;
- SCARD_DEBUG("atr[%d] : %s", result.getLength(), result.toString());
+ _DBG("atr[%d] : %s", result.getLength(), result.toString());
aid.setBuffer(MF, sizeof(MF));
context->clientSession->openLogicalChannel(aid, testOpenChannelCallback, userData);
void testOpenSessionCallback(SessionHelper *session, int error, void *userData)
{
- SCARD_DEBUG("session [%p]", session);
+ _DBG("session [%p]", session);
if (session != NULL)
{
}
else
{
- SCARD_DEBUG_ERR("openSession failed");
+ _ERR("openSession failed");
}
}
vector<ReaderHelper *> readers;
user_context_t *context = (user_context_t *)userData;
- SCARD_BEGIN();
+ _BEGIN();
if (service != NULL)
{
- SCARD_DEBUG("callback called, service [%p]", service);
+ _DBG("callback called, service [%p]", service);
context->clientService = service;
reader = (Reader *)readers[0];
- SCARD_DEBUG("reader [%p]", reader);
+ _DBG("reader [%p]", reader);
reader->openSession(testOpenSessionCallback, userData);
}
else
{
- SCARD_DEBUG_ERR("reader is empty");
+ _ERR("reader is empty");
}
}
else
{
- SCARD_DEBUG_ERR("service is NULL");
+ _ERR("service is NULL");
}
- SCARD_END();
+ _END();
}
int main(int argv, char *args[])
}
catch (...)
{
- SCARD_DEBUG_ERR("exception raised!!!");
+ _ERR("exception raised!!!");
}
if (service != NULL)