19 #ifndef PACKETPARSER_H 20 #define PACKETPARSER_H 26 #define ZRTP_PACKET_HEADER_LENGTH 12 27 #define ZRTP_PACKET_CRC_LENGTH 4 28 #define ZRTP_PACKET_OVERHEAD 16 30 #define BZRTP_PARSER_ERROR_INVALIDCRC 0xa001 31 #define BZRTP_PARSER_ERROR_INVALIDPACKET 0xa002 32 #define BZRTP_PARSER_ERROR_OUTOFORDER 0xa004 33 #define BZRTP_PARSER_ERROR_INVALIDMESSAGE 0xa008 34 #define BZRTP_PARSER_ERROR_INVALIDCONTEXT 0xa010 35 #define BZRTP_PARSER_ERROR_UNMATCHINGCONFIRMMAC 0xa020 36 #define BZRTP_PARSER_ERROR_UNMATCHINGSSRC 0xa040 37 #define BZRTP_PARSER_ERROR_UNMATCHINGHASHCHAIN 0xa080 38 #define BZRTP_PARSER_ERROR_UNMATCHINGMAC 0xa100 39 #define BZRTP_PARSER_ERROR_UNEXPECTEDMESSAGE 0xa200 40 #define BZRTP_PARSER_ERROR_UNMATCHINGHVI 0xa400 42 #define BZRTP_BUILDER_ERROR_INVALIDPACKET 0x5001 43 #define BZRTP_BUILDER_ERROR_INVALIDMESSAGE 0x5002 44 #define BZRTP_BUILDER_ERROR_INVALIDMESSAGETYPE 0x5004 45 #define BZRTP_BUILDER_ERROR_UNKNOWN 0x5008 46 #define BZRTP_BUILDER_ERROR_INVALIDCONTEXT 0x5010 48 #define BZRTP_CREATE_ERROR_INVALIDMESSAGETYPE 0x0a01 49 #define BZRTP_CREATE_ERROR_UNABLETOCREATECRYPTOCONTEXT 0x0a02 50 #define BZRTP_CREATE_ERROR_INVALIDCONTEXT 0x0a04 53 #define MSGTYPE_INVALID 0x00 54 #define MSGTYPE_HELLO 0x01 55 #define MSGTYPE_HELLOACK 0x02 56 #define MSGTYPE_COMMIT 0x03 57 #define MSGTYPE_DHPART1 0x04 58 #define MSGTYPE_DHPART2 0x05 59 #define MSGTYPE_CONFIRM1 0x06 60 #define MSGTYPE_CONFIRM2 0x07 61 #define MSGTYPE_CONF2ACK 0x08 62 #define MSGTYPE_ERROR 0x10 63 #define MSGTYPE_ERRORACK 0x11 64 #define MSGTYPE_GOCLEAR 0x12 65 #define MSGTYPE_CLEARACK 0x13 66 #define MSGTYPE_SASRELAY 0x14 67 #define MSGTYPE_RELAYACK 0x15 68 #define MSGTYPE_PING 0x16 69 #define MSGTYPE_PINGACK 0x17 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:106
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:104
#define BZRTP_EXPORT
Definition: bzrtp.h:41
uint8_t keyAgreementAlgo
Definition: packetParser.h:131
uint8_t * signatureBlock
Definition: packetParser.h:228
BZRTP_EXPORT int bzrtp_packetBuild(bzrtpContext_t *zrtpContext, bzrtpChannelContext_t *zrtpChannelContext, bzrtpPacket_t *zrtpPacket, uint16_t sequenceNumber)
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.
Definition: packetParser.c:735
uint8_t hc
Definition: packetParser.h:100
struct bzrtpHelloMessage_struct bzrtpHelloMessage_t
Hello Message rfc 5.2.
uint32_t cacheExpirationInterval
Definition: packetParser.h:172
Hello ACK Message rfc 5.3 This message contains no data but only a length and message type which are ...
Definition: packetParser.h:125
void * messageData
Definition: packetParser.h:80
uint8_t * packetString
Definition: packetParser.h:81
uint16_t sig_len
Definition: packetParser.h:221
Confirm Message rfc 5.7 Confirm1 and Confirm2 messages have the same structure Confirm1 is generated ...
Definition: packetParser.h:163
unsigned short uint16_t
Definition: stdint.h:79
BZRTP_EXPORT void bzrtp_freeZrtpPacket(bzrtpPacket_t *zrtpPacket)
Deallocate zrtp Packet.
Definition: packetParser.c:1404
Store all zrtpPacket informations according to type a specific structure type is mapped to the void *...
Definition: packetParser.h:75
uint8_t cipherAlgo
Definition: packetParser.h:129
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:152
uint8_t sasAlgo
Definition: packetParser.h:132
uint8_t hashAlgo
Definition: packetParser.h:128
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:224
Relay ACK Message rfc 5.14 This message contains no data but only a length and message type which are...
Definition: packetParser.h:242
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:222
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:1123
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:76
BZRTP_EXPORT bzrtpPacket_t * bzrtp_packetCheck(const uint8_t *input, uint16_t inputLength, uint16_t lastValidSequenceNumber, int *exitCode)
Parse a string which shall be a valid ZRTP packet Check validity and allocate the bzrtpPacket structu...
Definition: packetParser.c:101
uint8_t S
Definition: packetParser.h:97
structure of the ZRTP engine context Store current state, timers, HMAC and encryption keys ...
Definition: typedef.h:202
unsigned int uint32_t
Definition: stdint.h:80
uint8_t A
Definition: packetParser.h:223
PingAck Message The Ping and PingACK messages are unrelated to the rest of the ZRTP protocol...
Definition: packetParser.h:252
BZRTP_EXPORT int bzrtp_packetUpdateSequenceNumber(bzrtpPacket_t *zrtpPacket, uint16_t sequenceNumber)
Modify the current sequence number of the packet in the packetString and sequenceNumber fields The CR...
Definition: packetParser.c:1445
uint8_t D
Definition: packetParser.h:171
uint8_t sc
Definition: packetParser.h:108
uint32_t sourceIdentifier
Definition: packetParser.h:77
uint8_t M
Definition: packetParser.h:98
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:256
Clear ACK Message rfc 5.12 This message contains no data but only a length and message type which are...
Definition: packetParser.h:218
uint8_t A
Definition: packetParser.h:170
Hello Message rfc 5.2.
Definition: packetParser.h:92
uint8_t authTagAlgo
Definition: packetParser.h:130
uint8_t * signatureBlock
Definition: packetParser.h:174
uint8_t P
Definition: packetParser.h:99
uint16_t messageLength
Definition: packetParser.h:79
DHPart Message rfc 5.5 and rfc 5.6 DHPart1 and DHPart2 message have the same structure DHPart1 is gen...
Definition: packetParser.h:146
uint8_t V
Definition: packetParser.h:169
Conf2 ACK Message rfc 5.8 This message contains no data but only a length and message type which are ...
Definition: packetParser.h:201
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...
Definition: packetParser.c:195
The zrtp context of a channel.
Definition: typedef.h:132
uint8_t messageType
Definition: packetParser.h:78
uint16_t sig_len
Definition: packetParser.h:167
uint8_t E
Definition: packetParser.h:168
uint8_t cc
Definition: packetParser.h:102
uint8_t signatureBlockType
Definition: packetParser.h:227