rx buffer size parameter of nfc_target_init() function is now a const size_t.
This commit is contained in:
parent
5e796e0a26
commit
00818e048c
14 changed files with 36 additions and 40 deletions
|
|
@ -1592,7 +1592,7 @@ pn53x_initiator_deselect_target (struct nfc_device *pnd)
|
|||
#define SAK_ISO14443_4_COMPLIANT 0x20
|
||||
#define SAK_ISO18092_COMPLIANT 0x40
|
||||
int
|
||||
pn53x_target_init (struct nfc_device *pnd, nfc_target *pnt, uint8_t *pbtRx, size_t *pszRx, int timeout)
|
||||
pn53x_target_init (struct nfc_device *pnd, nfc_target *pnt, uint8_t *pbtRx, const size_t szRxLen, int timeout)
|
||||
{
|
||||
pn53x_reset_settings(pnd);
|
||||
|
||||
|
|
@ -1742,13 +1742,14 @@ pn53x_target_init (struct nfc_device *pnd, nfc_target *pnt, uint8_t *pbtRx, size
|
|||
}
|
||||
|
||||
bool targetActivated = false;
|
||||
size_t szRx;
|
||||
while (!targetActivated) {
|
||||
uint8_t btActivatedMode;
|
||||
|
||||
if((res = pn53x_TgInitAsTarget(pnd, ptm, pbtMifareParams, pbtTkt, szTkt, pbtFeliCaParams, pbtNFCID3t, pbtGBt, szGBt, pbtRx, *pszRx, &btActivatedMode, timeout)) < 0) {
|
||||
if((res = pn53x_TgInitAsTarget(pnd, ptm, pbtMifareParams, pbtTkt, szTkt, pbtFeliCaParams, pbtNFCID3t, pbtGBt, szGBt, pbtRx, szRxLen, &btActivatedMode, timeout)) < 0) {
|
||||
return res;
|
||||
}
|
||||
*pszRx = (size_t) res;
|
||||
szRx = (size_t) res;
|
||||
nfc_modulation nm = {
|
||||
.nmt = NMT_DEP, // Silent compilation warnings
|
||||
.nbr = NBR_UNDEFINED
|
||||
|
|
@ -1805,12 +1806,12 @@ pn53x_target_init (struct nfc_device *pnd, nfc_target *pnt, uint8_t *pbtRx, size
|
|||
if (ptm & PTM_ISO14443_4_PICC_ONLY) {
|
||||
// When PN532 is in PICC target mode, it automatically reply to RATS so
|
||||
// we don't need to forward this command
|
||||
*pszRx = 0;
|
||||
szRx = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return *pszRx;
|
||||
return szRx;
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
|||
|
|
@ -308,7 +308,7 @@ int pn53x_initiator_transceive_bytes_timed (struct nfc_device *pnd, const uin
|
|||
int pn53x_initiator_deselect_target (struct nfc_device *pnd);
|
||||
|
||||
// NFC device as Target functions
|
||||
int pn53x_target_init (struct nfc_device *pnd, nfc_target *pnt, uint8_t *pbtRx, size_t *pszRx, int timeout);
|
||||
int pn53x_target_init (struct nfc_device *pnd, nfc_target *pnt, uint8_t *pbtRx, const size_t szRxLen, int timeout);
|
||||
int pn53x_target_receive_bits (struct nfc_device *pnd, uint8_t *pbtRx, const size_t szRxLen, uint8_t *pbtRxPar);
|
||||
int pn53x_target_receive_bytes (struct nfc_device *pnd, uint8_t *pbtRx, const size_t szRxLen, int timeout);
|
||||
int pn53x_target_send_bits (struct nfc_device *pnd, const uint8_t *pbtTx, const size_t szTxBits, const uint8_t *pbtTxPar);
|
||||
|
|
|
|||
|
|
@ -31,23 +31,23 @@ int
|
|||
nfc_emulate_target (nfc_device *pnd, struct nfc_emulator *emulator)
|
||||
{
|
||||
uint8_t abtRx[ISO7816_SHORT_R_APDU_MAX_LEN];
|
||||
size_t szRx = sizeof(abtRx);
|
||||
int szRx;
|
||||
uint8_t abtTx[ISO7816_SHORT_C_APDU_MAX_LEN];
|
||||
int res = 0;
|
||||
|
||||
if (nfc_target_init (pnd, emulator->target, abtRx, &szRx, 0) < 0) {
|
||||
if ((szRx = nfc_target_init (pnd, emulator->target, abtRx, sizeof(abtRx), 0)) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
while (res >= 0) {
|
||||
res = emulator->state_machine->io (emulator, abtRx, szRx, abtTx, sizeof (abtTx));
|
||||
res = emulator->state_machine->io (emulator, abtRx, (size_t) szRx, abtTx, sizeof (abtTx));
|
||||
if (res > 0) {
|
||||
if (nfc_target_send_bytes(pnd, abtTx, res, 0) < 0) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (res >= 0) {
|
||||
if ((res = nfc_target_receive_bytes(pnd, abtRx, szRx, 0)) < 0) {
|
||||
if ((res = nfc_target_receive_bytes(pnd, abtRx, (size_t) szRx, 0)) < 0) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ struct nfc_driver_t {
|
|||
int (*initiator_transceive_bytes_timed) (struct nfc_device *pnd, const uint8_t * pbtTx, const size_t szTx, uint8_t * pbtRx, uint32_t * cycles);
|
||||
int (*initiator_transceive_bits_timed) (struct nfc_device *pnd, const uint8_t * pbtTx, const size_t szTxBits, const uint8_t * pbtTxPar, uint8_t * pbtRx, uint8_t * pbtRxPar, uint32_t * cycles);
|
||||
|
||||
int (*target_init) (struct nfc_device *pnd, nfc_target * pnt, uint8_t * pbtRx, size_t * pszRx, int timeout);
|
||||
int (*target_init) (struct nfc_device *pnd, nfc_target * pnt, uint8_t * pbtRx, const size_t szRx, int timeout);
|
||||
int (*target_send_bytes) (struct nfc_device *pnd, const uint8_t * pbtTx, const size_t szTx, int timeout);
|
||||
int (*target_receive_bytes) (struct nfc_device *pnd, uint8_t * pbtRx, const size_t szRxLen, int timeout);
|
||||
int (*target_send_bits) (struct nfc_device *pnd, const uint8_t * pbtTx, const size_t szTxBits, const uint8_t * pbtTxPar);
|
||||
|
|
|
|||
|
|
@ -609,7 +609,7 @@ nfc_initiator_transceive_bits_timed (nfc_device *pnd, const uint8_t *pbtTx, cons
|
|||
* and/or NDM_UNDEFINED (ie. for DEP mode), these fields will be updated.
|
||||
*
|
||||
* @param[out] pbtRx Rx buffer pointer
|
||||
* @param[out] pszRx received bytes count
|
||||
* @param[out] szRx received bytes count
|
||||
* @param timeout in milliseconds
|
||||
*
|
||||
* This function initializes NFC device in \e target mode in order to emulate a
|
||||
|
|
@ -629,7 +629,7 @@ nfc_initiator_transceive_bits_timed (nfc_device *pnd, const uint8_t *pbtTx, cons
|
|||
* receive functions can be used.
|
||||
*/
|
||||
int
|
||||
nfc_target_init (nfc_device *pnd, nfc_target *pnt, uint8_t *pbtRx, size_t * pszRx, int timeout)
|
||||
nfc_target_init (nfc_device *pnd, nfc_target *pnt, uint8_t *pbtRx, const size_t szRx, int timeout)
|
||||
{
|
||||
int res = 0;
|
||||
// Disallow invalid frame
|
||||
|
|
@ -656,7 +656,7 @@ nfc_target_init (nfc_device *pnd, nfc_target *pnt, uint8_t *pbtRx, size_t * pszR
|
|||
if ((res = nfc_device_set_property_bool (pnd, NP_ACTIVATE_FIELD, false)) < 0)
|
||||
return res;
|
||||
|
||||
HAL (target_init, pnd, pnt, pbtRx, pszRx, timeout);
|
||||
HAL (target_init, pnd, pnt, pbtRx, szRx, timeout);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue