19 #ifndef PACKETPARSER_H 20 #define PACKETPARSER_H 23 #include "bctoolbox/list.h" 47 #define ZRTP_PACKET_HEADER_LENGTH 12 77 #define ZRTP_FRAGMENTEDPACKET_HEADER_LENGTH 20 78 #define ZRTP_PACKET_CRC_LENGTH 4 79 #define ZRTP_PACKET_OVERHEAD (ZRTP_PACKET_HEADER_LENGTH + ZRTP_PACKET_CRC_LENGTH) 80 #define ZRTP_FRAGMENTEDPACKET_OVERHEAD (ZRTP_FRAGMENTEDPACKET_HEADER_LENGTH + ZRTP_PACKET_CRC_LENGTH) 82 #define BZRTP_PARSER_ERROR_INVALIDCRC 0xa001 83 #define BZRTP_PARSER_ERROR_INVALIDPACKET 0xa002 84 #define BZRTP_PARSER_ERROR_OUTOFORDER 0xa004 85 #define BZRTP_PARSER_ERROR_INVALIDMESSAGE 0xa008 86 #define BZRTP_PARSER_ERROR_INVALIDCONTEXT 0xa010 87 #define BZRTP_PARSER_ERROR_UNMATCHINGCONFIRMMAC 0xa020 88 #define BZRTP_PARSER_ERROR_UNMATCHINGSSRC 0xa040 89 #define BZRTP_PARSER_ERROR_UNMATCHINGHASHCHAIN 0xa080 90 #define BZRTP_PARSER_ERROR_UNMATCHINGMAC 0xa100 91 #define BZRTP_PARSER_ERROR_UNEXPECTEDMESSAGE 0xa200 92 #define BZRTP_PARSER_ERROR_UNMATCHINGHVI 0xa400 93 #define BZRTP_PARSER_INFO_PACKETFRAGMENT 0xa800 95 #define BZRTP_BUILDER_ERROR_INVALIDPACKET 0x5001 96 #define BZRTP_BUILDER_ERROR_INVALIDMESSAGE 0x5002 97 #define BZRTP_BUILDER_ERROR_INVALIDMESSAGETYPE 0x5004 98 #define BZRTP_BUILDER_ERROR_UNKNOWN 0x5008 99 #define BZRTP_BUILDER_ERROR_INVALIDCONTEXT 0x5010 100 #define BZRTP_BUILDER_ERROR_UNABLETOFRAGMENT 0x5020 102 #define BZRTP_CREATE_ERROR_INVALIDMESSAGETYPE 0x0a01 103 #define BZRTP_CREATE_ERROR_UNABLETOCREATECRYPTOCONTEXT 0x0a02 104 #define BZRTP_CREATE_ERROR_INVALIDCONTEXT 0x0a04 107 #define MSGTYPE_INVALID 0x00 108 #define MSGTYPE_HELLO 0x01 109 #define MSGTYPE_HELLOACK 0x02 110 #define MSGTYPE_COMMIT 0x03 111 #define MSGTYPE_DHPART1 0x04 112 #define MSGTYPE_DHPART2 0x05 113 #define MSGTYPE_CONFIRM1 0x06 114 #define MSGTYPE_CONFIRM2 0x07 115 #define MSGTYPE_CONF2ACK 0x08 116 #define MSGTYPE_ERROR 0x10 117 #define MSGTYPE_ERRORACK 0x11 118 #define MSGTYPE_GOCLEAR 0x12 119 #define MSGTYPE_CLEARACK 0x13 120 #define MSGTYPE_SASRELAY 0x14 121 #define MSGTYPE_RELAYACK 0x15 122 #define MSGTYPE_PING 0x16 123 #define MSGTYPE_PINGACK 0x17 124 #define MSGTYPE_FRAGMENT 0xff 202 #define ZRTP_KEMPART2_NONCE_SIZE 16 struct bzrtpGoClearMessage_struct bzrtpGoClearMessage_t
Conf2 ACK Message rfc 5.8 This message contains no data but only a length and message type which are ...
uint8_t kc
Definition: packetParser.h:166
struct bzrtpPacket_struct bzrtpPacket_t
Store all zrtpPacket informations according to type a specific structure type is mapped to the void *...
uint8_t ac
Definition: packetParser.h:164
#define BZRTP_EXPORT
Definition: bzrtp.h:41
uint8_t keyAgreementAlgo
Definition: packetParser.h:191
uint8_t * signatureBlock
Definition: packetParser.h:291
uint8_t hc
Definition: packetParser.h:160
struct bzrtpHelloMessage_struct bzrtpHelloMessage_t
Hello Message rfc 5.2.
uint32_t cacheExpirationInterval
Definition: packetParser.h:235
Hello ACK Message rfc 5.3 This message contains no data but only a length and message type which are ...
Definition: packetParser.h:185
void * messageData
Definition: packetParser.h:139
uint8_t * packetString
Definition: packetParser.h:140
uint16_t sig_len
Definition: packetParser.h:284
Confirm Message rfc 5.7 Confirm1 and Confirm2 messages have the same structure Confirm1 is generated ...
Definition: packetParser.h:226
unsigned short uint16_t
Definition: stdint.h:79
BZRTP_EXPORT void bzrtp_freeZrtpPacket(bzrtpPacket_t *zrtpPacket)
Deallocate zrtp Packet.
Definition: packetParser.c:1654
Store all zrtpPacket informations according to type a specific structure type is mapped to the void *...
Definition: packetParser.h:134
uint8_t cipherAlgo
Definition: packetParser.h:189
unsigned char uint8_t
Definition: stdint.h:78
struct bzrtpPingAckMessage_struct bzrtpPingAckMessage_t
PingAck Message The Ping and PingACK messages are unrelated to the rest of the ZRTP protocol...
uint8_t * pv
Definition: packetParser.h:215
uint8_t sasAlgo
Definition: packetParser.h:192
uint8_t hashAlgo
Definition: packetParser.h:188
struct bzrtpPingMessage_struct bzrtpPingMessage_t
Relay ACK Message rfc 5.14 This message contains no data but only a length and message type which are...
uint8_t D
Definition: packetParser.h:287
Relay ACK Message rfc 5.14 This message contains no data but only a length and message type which are...
Definition: packetParser.h:305
struct bzrtpSASRelayMessage_struct bzrtpSASRelayMessage_t
Clear ACK Message rfc 5.12 This message contains no data but only a length and message type which are...
uint8_t V
Definition: packetParser.h:285
BZRTP_EXPORT bzrtpPacket_t * bzrtp_createZrtpPacket(bzrtpContext_t *zrtpContext, bzrtpChannelContext_t *zrtpChannelContext, uint32_t messageType, int *exitCode)
Create an empty packet and allocate the messageData according to requested packetType.
Definition: packetParser.c:1307
struct bzrtpConfirmMessage_struct bzrtpConfirmMessage_t
Confirm Message rfc 5.7 Confirm1 and Confirm2 messages have the same structure Confirm1 is generated ...
uint16_t sequenceNumber
Definition: packetParser.h:135
uint8_t S
Definition: packetParser.h:157
structure of the ZRTP engine context Store current state, timers, HMAC and encryption keys ...
Definition: typedef.h:235
unsigned int uint32_t
Definition: stdint.h:80
uint8_t A
Definition: packetParser.h:286
PingAck Message The Ping and PingACK messages are unrelated to the rest of the ZRTP protocol...
Definition: packetParser.h:315
uint8_t D
Definition: packetParser.h:234
uint8_t sc
Definition: packetParser.h:168
uint32_t sourceIdentifier
Definition: packetParser.h:136
uint8_t M
Definition: packetParser.h:158
bctbx_list_t * fragments
Definition: packetParser.h:141
struct bzrtpCommitMessage_struct bzrtpCommitMessage_t
Hello ACK Message rfc 5.3 This message contains no data but only a length and message type which are ...
struct bzrtpDHPartMessage_struct bzrtpDHPartMessage_t
DHPart Message rfc 5.5 and rfc 5.6 DHPart1 and DHPart2 message have the same structure DHPart1 is gen...
uint32_t SSRC
Definition: packetParser.h:319
Clear ACK Message rfc 5.12 This message contains no data but only a length and message type which are...
Definition: packetParser.h:281
uint8_t A
Definition: packetParser.h:233
Hello Message rfc 5.2.
Definition: packetParser.h:152
uint8_t authTagAlgo
Definition: packetParser.h:190
uint8_t * signatureBlock
Definition: packetParser.h:237
uint8_t P
Definition: packetParser.h:159
uint16_t messageLength
Definition: packetParser.h:138
DHPart Message rfc 5.5 and rfc 5.6 DHPart1 and DHPart2 message have the same structure DHPart1 is gen...
Definition: packetParser.h:209
uint8_t * pv
Definition: packetParser.h:196
uint8_t V
Definition: packetParser.h:232
BZRTP_EXPORT int bzrtp_packetBuild(bzrtpContext_t *zrtpContext, bzrtpChannelContext_t *zrtpChannelContext, bzrtpPacket_t *zrtpPacket)
Create a ZRTP packet string from the ZRTP packet values present in the structure messageType, messageData and sourceIdentifier in zrtpPacket must have been correctly set before calling this function The packet is not ready to be sent at that stage, sequenceNumber and CRC must be set using bzrtp_packetSetSequenceNumber.
Definition: packetParser.c:848
Conf2 ACK Message rfc 5.8 This message contains no data but only a length and message type which are ...
Definition: packetParser.h:264
BZRTP_EXPORT int bzrtp_packetParser(bzrtpContext_t *zrtpContext, bzrtpChannelContext_t *zrtpChannelContext, const uint8_t *input, uint16_t inputLength, bzrtpPacket_t *zrtpPacket)
Parse the packet to extract the message and allocate the matching message structure if needed...
The zrtp context of a channel.
Definition: typedef.h:157
uint8_t messageType
Definition: packetParser.h:137
uint16_t sig_len
Definition: packetParser.h:230
BZRTP_EXPORT int bzrtp_packetSetSequenceNumber(bzrtpPacket_t *zrtpPacket, uint16_t sequenceNumber)
Set the current sequence number of the packet in the packetString and sequenceNumber fields The CRC a...
Definition: packetParser.c:1705
uint8_t E
Definition: packetParser.h:231
uint8_t cc
Definition: packetParser.h:162
uint8_t signatureBlockType
Definition: packetParser.h:290
BZRTP_EXPORT bzrtpPacket_t * bzrtp_packetCheck(uint8_t **inputPtr, uint16_t *inputLength, bzrtpChannelContext_t *zrtpChannelContext, int *exitCode)
Parse a string which shall be a valid ZRTP packet Check validity and allocate the bzrtpPacket structu...
Definition: packetParser.c:95