Expand description
NFC (Near Field Communication) virtual tag server.
NetGet emulates an NFC Forum Type 4 tag, which is defined as ISO 7816-4
APDU exchange over ISO-DEP. It cannot generate an RF field — no PC/SC reader
can be driven into card-emulation mode — so the tag is reachable over a bound
TCP socket instead, using the vsmartcard vpcd framing:
reader → tag: u16 big-endian length | payload
tag → reader: u16 big-endian length | payloadA payload of exactly one byte is a vpcd control code (00 power off, 01
power on, 02 reset, 04 request ATR); anything longer is a command APDU.
This is the same wire format src/server/usb/smartcard/ already speaks, and
it is not a private invention: configured with DEVICENAME /dev/null:<host>:<port>
the real vpcd ifdhandler connects out to a listening virtual card, so a
host running pcscd sees this server as a genuine PC/SC reader with a card
in it. A test, meanwhile, only has to write a length-prefixed APDU to the
socket — no hardware, no daemon.
§What the model controls
nfc_server_started→set_atr,set_ndef_messageconfigure the tag.nfc_tag_selected(SELECT by AID) andnfc_apdu_received(every other APDU) →respond_to_apdusupplies the response body and status word.
Nothing is answered by hardcoded card logic: there is no file system and no
stored NDEF parser here, only the state the model itself set. If no handler
produces a response the tag replies 6F00 (fail closed), never a success;
if the backend itself failed it replies 6400 when that backend is merely
saturated, so a reader retries instead of recording a broken card.
Re-exports§
pub use actions::NfcServerProtocol;
Modules§
- actions
- NFC (Near Field Communication) server protocol actions.
- apdu
- ISO 7816-4 command APDU parsing for the virtual NFC Forum Type 4 tag.
Structs§
- NfcServer
- NFC virtual tag server.
Constants§
- MAX_
FRAME_ LEN - Largest frame accepted from a reader. Bounds the read buffer so a hostile length prefix cannot make the server allocate.