22 static constexpr uint8_t kSecureDataPdu = 0;
23 static constexpr uint8_t kSecureSyncRequest = 2;
24 static constexpr uint8_t kSecureSyncResponse = 3;
35 _addrTab = &addrTable;
42 if (_addrTab ==
nullptr)
54 uint16_t plainApduLength = apdu.
length() - 3 - 6 - 4;
58 if (decodeSecureApdu(apdu, plainFrame.
apdu(), secCtrl))
77 if (isSyncService(apdu))
87 uint16_t plainApduLength = apdu.
length() - 3 - 6 - 4;
91 if (decodeSecureApdu(apdu, plainFrame.
apdu(), secCtrl))
105 println(
"dataBroadcastIndication");
114 uint16_t plainApduLength = apdu.
length() - 3 - 6 - 4;
118 if (decodeSecureApdu(apdu, plainFrame.
apdu(), secCtrl))
132 println(
"dataBroadcastConfirm");
137 if (isSyncService(apdu))
147 uint16_t plainApduLength = apdu.
length() - 3 - 6 - 4;
151 if (decodeSecureApdu(apdu, plainFrame.
apdu(), secCtrl))
165 println(
"dataSystemBroadcastIndication");
174 uint16_t plainApduLength = apdu.
length() - 3 - 6 - 4;
178 if (decodeSecureApdu(apdu, plainFrame.
apdu(), secCtrl))
192 println(
"dataSystemBroadcastConfirm");
197 if (isSyncService(apdu))
207 uint16_t plainApduLength = apdu.
length() - 3 - 6 - 4;
211 if (decodeSecureApdu(apdu, plainFrame.
apdu(), secCtrl))
225 println(
"dataIndividualIndication");
234 uint16_t plainApduLength = apdu.
length() - 3 - 6 - 4;
238 if (decodeSecureApdu(apdu, plainFrame.
apdu(), secCtrl))
252 println(
"dataIndividualConfirm");
257 if (isSyncService(apdu))
267 uint16_t plainApduLength = apdu.
length() - 3 - 6 - 4;
271 if (decodeSecureApdu(apdu, plainFrame.
apdu(), secCtrl))
287 println(
"dataConnectedIndication");
296 uint16_t plainApduLength = apdu.
length() - 3 - 6 - 4;
300 if (decodeSecureApdu(apdu, plainFrame.
apdu(), secCtrl))
322 if (_addrTab ==
nullptr)
333 uint16_t secureApduLength = apdu.
length() + 3 + 6 + 4;
337 if (createSecureApdu(apdu, secureFrame.
apdu(), secCtrl))
350 println(
"dataBroadcastRequest");
359 uint16_t secureApduLength = apdu.
length() + 3 + 6 + 4;
363 if (createSecureApdu(apdu, secureFrame.
apdu(), secCtrl))
376 println(
"dataSystemBroadcastRequest");
385 uint16_t secureApduLength = apdu.
length() + 3 + 6 + 4;
389 if (createSecureApdu(apdu, secureFrame.
apdu(), secCtrl))
402 println(
"dataIndividualRequest");
410 uint16_t secureApduLength = apdu.
length() + 3 + 6 + 4;
414 if (createSecureApdu(apdu, secureFrame.
apdu(), secCtrl))
427 println(
"dataConnectedRequest");
435 uint16_t secureApduLength = apdu.
length() + 3 + 6 + 4;
439 if (createSecureApdu(apdu, secureFrame.
apdu(), secCtrl))
451 void SecureApplicationLayer::encryptAesCbc(uint8_t* buffer, uint16_t bufLen,
const uint8_t* iv,
const uint8_t* key)
454 uint8_t zeroIv[16] = {0x00};
466 void SecureApplicationLayer::xcryptAesCtr(uint8_t* buffer, uint16_t bufLen,
const uint8_t* iv,
const uint8_t* key)
475 uint32_t SecureApplicationLayer::calcAuthOnlyMac(uint8_t* apdu, uint8_t apduLength,
const uint8_t* key, uint8_t* iv, uint8_t* ctr0)
477 uint16_t bufLen = 2 + apduLength;
479 uint16_t bufLenPadded = (bufLen + 15) / 16 * 16;
480 uint8_t buffer[bufLenPadded];
482 memset(buffer, 0x00, bufLenPadded);
484 uint8_t* pBuf = buffer;
489 encryptAesCbc(buffer, bufLenPadded, iv, key);
490 xcryptAesCtr(buffer, 4, ctr0, key);
498 uint32_t SecureApplicationLayer::calcConfAuthMac(uint8_t* associatedData, uint16_t associatedDataLength,
499 uint8_t* apdu, uint8_t apduLength,
500 const uint8_t* key, uint8_t* iv)
502 uint16_t bufLen = 2 + associatedDataLength + apduLength;
504 uint16_t bufLenPadded = (bufLen + 15) / 16 * 16;
505 uint8_t buffer[bufLenPadded];
507 memset(buffer, 0x00, bufLenPadded);
509 uint8_t* pBuf = buffer;
511 pBuf =
pushWord(associatedDataLength, pBuf);
512 pBuf =
pushByteArray(associatedData, associatedDataLength, pBuf);
515 encryptAesCbc(buffer, bufLenPadded, iv, key);
518 popInt(mac, &buffer[bufLenPadded - 16]);
523 void SecureApplicationLayer::block0(uint8_t* buffer, uint8_t* seqNum, uint16_t indSrcAddr, uint16_t dstAddr,
bool dstAddrIsGroupAddr, uint8_t extFrameFormat, uint8_t tpci, uint8_t apci, uint8_t payloadLength)
525 uint8_t* pBuf = buffer;
530 pBuf =
pushByte( (dstAddrIsGroupAddr ? 0x80 : 0x00) | (extFrameFormat & 0xf), pBuf);
534 pBuf =
pushByte(payloadLength, pBuf);
537 void SecureApplicationLayer::blockCtr0(uint8_t* buffer, uint8_t* seqNum, uint16_t indSrcAddr, uint16_t dstAddr)
539 uint8_t* pBuf = buffer;
543 pBuf =
pushInt(0x00000000, pBuf);
547 uint16_t SecureApplicationLayer::groupAddressIndex(uint16_t groupAddr)
550 if (_addrTab ==
nullptr)
553 return _addrTab->
getTsap(groupAddr);
556 const uint8_t* SecureApplicationLayer::securityKey(uint16_t addr,
bool isGroupAddress)
560 uint16_t gaIndex = groupAddressIndex(addr);
570 return _secIfObj.
p2pKey(iaIndex);
577 uint64_t SecureApplicationLayer::nextSequenceNumber(
bool toolAccess)
579 return toolAccess ? _sequenceNumberToolAccess : _sequenceNumber;
583 void SecureApplicationLayer::updateSequenceNumber(
bool toolAccess, uint64_t seqNum)
587 _sequenceNumberToolAccess = seqNum;
591 _sequenceNumber = seqNum;
598 uint64_t SecureApplicationLayer::lastValidSequenceNumber(
bool toolAccess, uint16_t srcAddr)
604 return _sequenceNumberToolAccess;
606 return _lastValidSequenceNumberTool;
616 void SecureApplicationLayer::updateLastValidSequence(
bool toolAccess, uint16_t remoteAddr, uint64_t seqNo)
620 _lastValidSequenceNumberTool = seqNo;
627 void SecureApplicationLayer::sendSyncRequest(uint16_t dstAddr,
bool dstAddrIsGroupAddr,
const SecurityControl& secCtrl,
bool systemBcast)
631 println(
"sync.req is always sent with auth+conf!");
635 _syncReqBroadcastOutgoing = (dstAddr == 0x0000) && dstAddrIsGroupAddr;
638 uint64_t challenge = getRandomNumber();
643 CemiFrame request(2 + 6 +
sizeof(asdu) + 4);
648 if (!_syncReqBroadcastOutgoing)
656 print(
"sendSyncRequest: TPCI: ");
659 if (secure(request.data() + APDU_LPDU_DIFF, kSecureSyncRequest, _deviceObj.
individualAddress(), dstAddr, dstAddrIsGroupAddr, tpci, asdu,
sizeof(asdu), secCtrl, systemBcast))
662 request.apdu().printPDU();
664 if (_syncReqBroadcastOutgoing)
682 Addr toAddr = _syncReqBroadcastOutgoing ? (Addr)GrpAddr(0) : (Addr)IndAddr(dstAddr);
687 println(
"SyncRequest: failure during encryption");
691 void SecureApplicationLayer::sendSyncResponse(uint16_t dstAddr,
bool dstAddrIsGroupAddr,
const SecurityControl& secCtrl, uint64_t remoteNextSeqNum,
bool systemBcast)
695 println(
"sync.res is always sent with auth+conf!");
699 uint64_t ourNextSeqNum = nextSequenceNumber(secCtrl.
toolAccess);
705 CemiFrame response(2 + 6 +
sizeof(asdu) + 4);
710 if (!_syncReqBroadcastIncoming)
718 print(
"sendSyncResponse: TPCI: ");
721 if (secure(response.data() + APDU_LPDU_DIFF, kSecureSyncResponse, _deviceObj.
individualAddress(), dstAddr, dstAddrIsGroupAddr, tpci, asdu,
sizeof(asdu), secCtrl, systemBcast))
726 response.apdu().printPDU();
728 if (_syncReqBroadcastIncoming)
748 println(
"SyncResponse: failure during encryption");
752 void SecureApplicationLayer::receivedSyncRequest(uint16_t srcAddr, uint16_t dstAddr,
bool dstAddrIsGroupAddr,
const SecurityControl& secCtrl, uint8_t* seqNum, uint64_t challenge,
bool systemBcast)
754 println(
"Received SyncRequest:");
757 uint64_t nextSeqNum = 1 + lastValidSequenceNumber(secCtrl.
toolAccess, srcAddr);
759 if (nextRemoteSeqNum > nextSeqNum)
761 updateLastValidSequence(secCtrl.
toolAccess, srcAddr, nextRemoteSeqNum - 1);
762 nextSeqNum = nextRemoteSeqNum;
765 _syncReqBroadcastIncoming = (dstAddr == 0x0000) && dstAddrIsGroupAddr;
768 _pendingIncomingSyncRequests.
insertOrAssign(_syncReqBroadcastIncoming ? (Addr) GrpAddr(0) : (Addr) IndAddr(srcAddr), challenge);
770 uint16_t toAddr = _syncReqBroadcastIncoming ? dstAddr : srcAddr;
771 bool toIsGroupAddress = _syncReqBroadcastIncoming;
772 sendSyncResponse(toAddr, toIsGroupAddress, secCtrl, nextSeqNum, systemBcast);
775 void SecureApplicationLayer::receivedSyncResponse(uint16_t remote,
const SecurityControl& secCtrl, uint8_t* plainApdu)
777 println(
"Received SyncResponse:");
779 if (_syncReqBroadcastOutgoing)
781 if (_pendingOutgoingSyncRequests.
get(GrpAddr(0)) ==
nullptr)
783 println(
"Cannot handle sync.res without pending sync.req! (broadcast/systembroadcast)");
789 if (_pendingOutgoingSyncRequests.
get(IndAddr(remote)) ==
nullptr)
791 println(
"Cannot handle sync.res without pending sync.req!");
801 uint64_t last = lastValidSequenceNumber(secCtrl.
toolAccess, remote);
803 if (remoteSeq - 1 > last)
806 updateLastValidSequence(secCtrl.
toolAccess, remote, remoteSeq - 1);
809 uint64_t next = nextSequenceNumber(secCtrl.
toolAccess);
814 updateSequenceNumber(secCtrl.
toolAccess, localSeq);
817 Addr remoteAddr = _syncReqBroadcastOutgoing ? (Addr)GrpAddr(0) : (Addr)IndAddr(remote);
818 _pendingOutgoingSyncRequests.
erase(remoteAddr);
821 bool SecureApplicationLayer::decrypt(uint8_t* plainApdu, uint16_t plainApduLength, uint16_t srcAddr, uint16_t dstAddr,
bool dstAddrIsGroupAddr, uint8_t tpci, uint8_t* secureAsdu,
SecurityControl& secCtrl,
bool systemBcast)
826 pBuf =
popByte(scf, secureAsdu);
828 bool toolAccess = ((scf & 0x80) == 0x80);
829 bool systemBroadcast = ((scf & 0x08) == 0x08);
830 uint8_t sai = (scf >> 4) & 0x07;
831 bool authOnly = ( sai == 0);
832 uint8_t service = (scf & 0x07);
834 if (systemBroadcast != systemBcast)
836 println(
"SBC flag in SCF does not match actual communication mode!");
842 bool syncReq = service == kSecureSyncRequest;
843 bool syncRes = service == kSecureSyncResponse;
846 const uint8_t* key = dstAddrIsGroupAddr && (dstAddr != 0) ? securityKey(dstAddr, dstAddrIsGroupAddr) : toolAccess ? _secIfObj.toolKey() : securityKey(srcAddr, false);
850 print(
"Error: No key found. toolAccess: ");
851 println(toolAccess ?
"true" :
"false");
861 uint8_t knxSerialNumber[6];
863 uint16_t remainingPlainApduLength = plainApduLength;
865 if (service == kSecureDataPdu)
869 uint64_t expectedSeqNumber = lastValidSequenceNumber(toolAccess, srcAddr) + 1;
871 if (receivedSeqNumber < expectedSeqNumber)
874 print(
"security failure: received seqNum: ");
875 print(receivedSeqNumber, HEX);
876 print(
" < expected seqNum: ");
877 print(expectedSeqNumber, HEX);
885 remainingPlainApduLength -= 6;
890 uint8_t emptySerialNumber[6] = {0};
892 if (systemBroadcast || dstAddr != _deviceObj.
individualAddress() || !memcmp(knxSerialNumber, emptySerialNumber, 6))
897 if ((
millis() - _lastSyncRes) < 1000)
905 uint64_t* challenge = _pendingOutgoingSyncRequests.
get(IndAddr(srcAddr));
907 if (challenge ==
nullptr)
909 println(
"Cannot find matching challenge for source address!");
913 uint8_t _challengeSixBytes[6];
918 for (uint8_t i = 0; i <
sizeof(seqNum); i++)
920 seqNum[i] ^= _challengeSixBytes[i];
924 pBuf =
popByteArray(plainApdu, remainingPlainApduLength, pBuf);
928 uint8_t extendedFrameFormat = 0;
930 uint8_t iv[16] = {0x00};
938 block0(iv, seqNum, srcAddr, dstAddr, dstAddrIsGroupAddr, extendedFrameFormat, tpci | (
SecureService >> 8),
SecureService & 0x00FF, remainingPlainApduLength);
941 uint8_t ctr0[16] = {0x00};
943 blockCtr0(ctr0, seqNum, srcAddr, dstAddr);
953 uint32_t calculatedMac = calcAuthOnlyMac(plainApdu, remainingPlainApduLength, key, iv, ctr0);
955 if (calculatedMac != mac)
958 print(
"security failure(auth): calculated MAC: ");
959 print(calculatedMac, HEX);
960 print(
" != received MAC: ");
967 memcpy(plainApdu, secureAsdu, remainingPlainApduLength);
973 uint16_t bufLen = 4 + remainingPlainApduLength;
975 uint16_t bufLenPadded = (bufLen + 15) / 16 * 16;
976 uint8_t buffer[bufLenPadded];
979 memset(buffer, 0x00, bufLenPadded);
982 pushByteArray(plainApdu, remainingPlainApduLength, &buffer[4]);
984 xcryptAesCtr(buffer, bufLenPadded, ctr0, key);
987 uint32_t decryptedMac;
988 popInt(decryptedMac, &buffer[0]);
989 popByteArray(plainApdu, remainingPlainApduLength, &buffer[4]);
992 uint8_t associatedData[syncReq ? 7 : 1];
993 associatedData[0] = scf;
997 memcpy(&associatedData[1], knxSerialNumber, 6);
1005 uint32_t calculatedMac = calcConfAuthMac(associatedData,
sizeof(associatedData), plainApdu, remainingPlainApduLength, key, iv);
1007 if (calculatedMac != decryptedMac)
1010 print(
"security failure(conf+auth): calculated MAC: ");
1011 print(calculatedMac, HEX);
1012 print(
" != decrypted MAC: ");
1013 print(decryptedMac, HEX);
1027 receivedSyncRequest(srcAddr, dstAddr, dstAddrIsGroupAddr, secCtrl, seqNum, challenge, systemBroadcast);
1032 receivedSyncResponse(srcAddr, secCtrl, plainApdu);
1039 print(
"Update our next ");
1040 print(toolAccess ?
"tool access" :
"");
1041 print(
" seq from ");
1042 print(srcAddr, HEX);
1044 println(receivedSeqNumber, HEX);
1045 updateSequenceNumber(toolAccess, receivedSeqNumber + 1);
1049 print(
"Update last valid ");
1050 print(toolAccess ?
"tool access" :
"");
1051 print(
" seq from ");
1052 print(srcAddr, HEX);
1054 println(receivedSeqNumber, HEX);
1055 updateLastValidSequence(toolAccess, srcAddr, receivedSeqNumber);
1067 println(
"decodeSecureApdu: Secure APDU: ");
1074 uint8_t tpci = secureApdu.
frame().
data()[TPDU_LPDU_DIFF];
1075 print(
"decodeSecureApdu: TPCI: ");
1088 if (decrypt(plainApdu.
frame().
data() + APDU_LPDU_DIFF, plainApdu.
length() + 1, srcAddress, dstAddress, isDstAddrGroupAddr, tpci, secureApdu.
data() + 1, secCtrl, isSystemBroadcast))
1090 println(
"decodeSecureApdu: Plain APDU: ");
1099 bool SecureApplicationLayer::secure(uint8_t* buffer, uint16_t service, uint16_t srcAddr, uint16_t dstAddr,
bool dstAddrIsGroupAddr, uint8_t tpci,
1100 uint8_t* apdu, uint16_t apduLength,
const SecurityControl& secCtrl,
bool systemBcast)
1107 if (!confidentiality)
1109 println(
"Error: tool access requires auth+conf security");
1113 if (dstAddrIsGroupAddr && dstAddr != 0)
1115 println(
"Error: tool access requires individual address");
1120 const uint8_t* key = toolAccess ? _secIfObj.
toolKey() : securityKey(dstAddr, dstAddrIsGroupAddr);
1124 print(
"Error: No key found. toolAccess: ");
1125 println(toolAccess ?
"true" :
"false");
1129 bool syncReq = service == kSecureSyncRequest;
1130 bool syncRes = service == kSecureSyncResponse;
1134 uint8_t* pBuf = buffer;
1140 scf |= toolAccess ? 0x80 : 0;
1141 scf |= confidentiality ? 0x10 : 0;
1142 scf |= systemBcast ? 0x8 : 0;
1146 uint64_t seqSend = nextSequenceNumber(toolAccess);
1149 println(
"0 is not a valid sequence number");
1158 uint8_t associatedData[syncReq ? 7 : 1];
1159 associatedData[0] = scf;
1164 uint8_t remoteSerialNo[6] = {0};
1166 uint8_t emptySerialNo[6] = {0};
1167 pBuf =
pushByteArray(systemBcast ? remoteSerialNo : emptySerialNo, 6, pBuf);
1173 uint64_t randomNumber = getRandomNumber();
1176 Addr remote = _syncReqBroadcastIncoming ? (Addr)GrpAddr(0) : (Addr)IndAddr(dstAddr);
1179 uint64_t* challenge = _pendingIncomingSyncRequests.
get(remote);
1181 if (challenge ==
nullptr)
1183 println(
"Cannot send sync.res without corresponding sync.req");
1188 _pendingIncomingSyncRequests.
erase(remote);
1191 uint8_t challengeSixBytes[6];
1196 uint8_t rndXorChallenge[6];
1199 for (uint8_t i = 0; i <
sizeof(rndXorChallenge); i++)
1201 rndXorChallenge[i] ^= challengeSixBytes[i];
1209 uint8_t extendedFrameFormat = 0;
1211 uint8_t iv[16] = {0x00};
1219 block0(iv, seq, srcAddr, dstAddr, dstAddrIsGroupAddr, extendedFrameFormat, tpci, apci, apduLength);
1222 uint8_t ctr0[16] = {0x00};
1224 blockCtr0(ctr0, seq, srcAddr, dstAddr);
1226 if (confidentiality)
1234 uint32_t mac = calcConfAuthMac(associatedData,
sizeof(associatedData), apdu, apduLength, key, iv);
1236 uint8_t tmpBuffer[4 + apduLength];
1240 xcryptAesCtr(tmpBuffer, apduLength + 4, ctr0, key);
1251 uint32_t tmpMac = calcAuthOnlyMac(apdu, apduLength, key, iv, ctr0);
1263 bool SecureApplicationLayer::createSecureApdu(
APDU& plainApdu,
APDU& secureApdu,
const SecurityControl& secCtrl)
1267 println(
"createSecureApdu: Plain APDU: ");
1274 uint8_t tpci = 0x00;
1281 print(
"createSecureApdu: TPCI: ");
1294 if (secure(secureApdu.
frame().
data() + APDU_LPDU_DIFF, kSecureDataPdu, srcAddress, dstAddress, isDstAddrGroupAddr, tpci, plainApdu.
frame().
data() + APDU_LPDU_DIFF, plainApdu.
length() + 1, secCtrl, isSystemBroadcast))
1296 print(
"Update our next ");
1298 print(
" seq from ");
1299 print(srcAddress, HEX);
1304 println(
"createSecureApdu: Secure APDU: ");
1313 uint64_t SecureApplicationLayer::getRandomNumber()
1315 return 0x000102030405;
1324 bool SecureApplicationLayer::isSyncService(
APDU& secureApdu)
1326 uint8_t scf = *(secureApdu.
data() + 1);
1327 uint8_t service = (scf & 0x07);
1329 if ((service == kSecureSyncRequest) || (service == kSecureSyncResponse))
void AES_CTR_xcrypt_buffer(struct AES_ctx *ctx, uint8_t *buf, uint32_t length)
void AES_init_ctx_iv(struct AES_ctx *ctx, const uint8_t *key, const uint8_t *iv)
void AES_CBC_encrypt_buffer(struct AES_ctx *ctx, uint8_t *buf, uint32_t length)
const uint8_t * popByte(uint8_t &b, const uint8_t *data)
uint8_t * pushInt(uint32_t i, uint8_t *data)
uint8_t * pushByteArray(const uint8_t *src, uint32_t size, uint8_t *data)
const uint8_t * popByteArray(uint8_t *dst, uint32_t size, const uint8_t *data)
void sixBytesFromUInt64(uint64_t num, uint8_t *toByteArray)
uint8_t * pushWord(uint16_t w, uint8_t *data)
uint8_t * pushByte(uint8_t b, uint8_t *data)
const uint8_t * popInt(uint32_t &i, const uint8_t *data)
uint64_t sixBytesToUInt64(uint8_t *data)
This class represents an Application Protocol Data Unit.
void printPDU()
Print the contents of the APDU to console.
ApduType type()
Get the type of the APDU.
uint8_t * data()
Get a pointer to the data.
uint8_t length() const
Get the length of the APDU.
CemiFrame & frame()
Get the CemiFrame this APDU is part of.
This class represents the group address table.
uint16_t getGroupAddress(uint16_t tsap)
Get the group address mapped to a TSAP.
uint16_t getTsap(uint16_t groupAddress)
Get the TSAP mapped to a group address.
This is an implementation of the application layer as specified in .
virtual void dataSystemBroadcastIndication(HopCountType hopType, Priority priority, uint16_t source, APDU &apdu)
virtual void dataConnectedRequest(uint16_t tsap, Priority priority, APDU &apdu, const SecurityControl &secCtrl)
virtual void dataIndividualRequest(AckType ack, HopCountType hopType, Priority priority, uint16_t destination, APDU &apdu, const SecurityControl &secCtrl)
virtual void dataBroadcastIndication(HopCountType hopType, Priority priority, uint16_t source, APDU &apdu)
TransportLayer * _transportLayer
virtual void dataGroupRequest(AckType ack, HopCountType hopType, Priority priority, uint16_t tsap, APDU &apdu, const SecurityControl &secCtrl)
virtual void dataConnectedIndication(Priority priority, uint16_t tsap, APDU &apdu)
virtual void dataGroupConfirm(AckType ack, HopCountType hopType, Priority priority, uint16_t tsap, APDU &apdu, bool status)
Report the status of an APDU that we sent via multicast communication back to us.
virtual void dataSystemBroadcastRequest(AckType ack, HopCountType hopType, Priority priority, APDU &apdu, const SecurityControl &secCtrl)
virtual void dataSystemBroadcastConfirm(HopCountType hopType, Priority priority, APDU &apdu, bool status)
virtual void dataIndividualConfirm(AckType ack, HopCountType hopType, Priority priority, uint16_t tsap, APDU &apdu, bool status)
virtual void dataBroadcastConfirm(AckType ack, HopCountType hopType, Priority priority, APDU &apdu, bool status)
virtual void dataGroupIndication(HopCountType hopType, Priority priority, uint16_t tsap, APDU &apdu)
Somebody send us an APDU via multicast communication.
uint16_t getConnectedTsasp()
virtual void dataConnectedConfirm(uint16_t tsap)
virtual void dataBroadcastRequest(AckType ack, HopCountType hopType, Priority priority, APDU &apdu, const SecurityControl &secCtrl)
virtual void dataIndividualIndication(HopCountType hopType, Priority priority, uint16_t source, APDU &apdu)
SystemBroadcast systemBroadcast() const
uint16_t sourceAddress() const
uint16_t destinationAddress() const
AddressType addressType() const
uint16_t individualAddress()
const uint8_t * propertyData(PropertyID id)
bool insertOrAssign(K key, V value)
void dataConnectedRequest(uint16_t tsap, Priority priority, APDU &apdu, const SecurityControl &secCtrl) override
void dataGroupRequest(AckType ack, HopCountType hopType, Priority priority, uint16_t tsap, APDU &apdu, const SecurityControl &secCtrl) override
void dataIndividualConfirm(AckType ack, HopCountType hopType, Priority priority, uint16_t tsap, APDU &apdu, bool status) override
void dataSystemBroadcastRequest(AckType ack, HopCountType hopType, Priority priority, APDU &apdu, const SecurityControl &secCtrl) override
void dataGroupIndication(HopCountType hopType, Priority priority, uint16_t tsap, APDU &apdu) override
Somebody send us an APDU via multicast communication.
void dataSystemBroadcastIndication(HopCountType hopType, Priority priority, uint16_t source, APDU &apdu) override
void dataConnectedIndication(Priority priority, uint16_t tsap, APDU &apdu) override
void dataConnectedConfirm(uint16_t tsap) override
void dataSystemBroadcastConfirm(HopCountType hopType, Priority priority, APDU &apdu, bool status) override
SecureApplicationLayer(DeviceObject &deviceObj, SecurityInterfaceObject &secIfObj, BusAccessUnit &bau)
The constructor.
void groupAddressTable(AddressTableObject &addrTable)
void dataGroupConfirm(AckType ack, HopCountType hopType, Priority priority, uint16_t tsap, APDU &apdu, bool status) override
Report the status of an APDU that we sent via multicast communication back to us.
void dataBroadcastIndication(HopCountType hopType, Priority priority, uint16_t source, APDU &apdu) override
void dataIndividualIndication(HopCountType hopType, Priority priority, uint16_t source, APDU &apdu) override
void dataIndividualRequest(AckType ack, HopCountType hopType, Priority priority, uint16_t destination, APDU &apdu, const SecurityControl &secCtrl) override
void dataBroadcastConfirm(AckType ack, HopCountType hopType, Priority priority, APDU &apdu, bool status) override
void dataBroadcastRequest(AckType ack, HopCountType hopType, Priority priority, APDU &apdu, const SecurityControl &secCtrl) override
const uint8_t * groupKey(uint16_t addressIndex)
uint64_t getLastValidSequenceNumber(uint16_t deviceAddr)
void setLastValidSequenceNumber(uint16_t deviceAddr, uint64_t seqNum)
void setSequenceNumber(bool toolAccess, uint64_t seqNum)
const uint8_t * toolKey()
const uint8_t * p2pKey(uint16_t addressIndex)
uint16_t indAddressIndex(uint16_t indAddr)
void dataBroadcastRequest(AckType ack, HopCountType hopType, Priority priority, APDU &apdu)
void dataConnectedRequest(uint16_t tsap, Priority priority, APDU &apdu)
void dataIndividualRequest(AckType ack, HopCountType hopType, Priority priority, uint16_t destination, APDU &apdu)
uint16_t getConnectionAddress()
@ NetworkLayerParameter
use NetworkLayer::hopCount as NPDU::hopCount
@ SystemPriority
Mainly used by ETS for device programming.
@ AckDontCare
We don't care about DataLinkLayer acknowledgement.
DataSecurity dataSecurity