@ -145,6 +145,58 @@ namespace network
*/
class DVM_COMMON_API Network : public BaseNetwork {
public :
/**
* @ brief Receive packet preprocessing result .
* @ ingroup network_core
*/
enum class RX_PACKET_PREPROCESS_RESULT : uint8_t {
ACCEPT , //!< Continue normal receive stream processing.
DROP //!< Discard the packet without changing receive stream state.
} ;
/**
* @ brief Protocol receive packet preprocessor callback .
* @ param data Pointer to the packet data .
* @ param length Length of the packet data .
* @ param streamId Stream ID .
* @ param rxStreamId Receive stream ID .
*/
using RxPacketPreprocessor = std : : function < RX_PACKET_PREPROCESS_RESULT ( const uint8_t * data , uint32_t length , uint32_t streamId , uint32_t rxStreamId ) > ;
/**
* @ brief Callback for ICC commands that include a slot number .
* @ param command ICC command .
* @ param dstId Destination ID .
* @ param slotNo Slot number .
* @ param peerId Peer ID .
* @ param ssrc RTP SSRC .
* @ param streamId Stream ID .
*/
using ICCSlotCallback = std : : function < void ( NET_ICC : : ENUM command , uint32_t dstId , uint8_t slotNo , uint32_t peerId , uint32_t ssrc , uint32_t streamId ) > ;
/**
* @ brief Callback for ICC commands that do not include a slot number .
* @ param command ICC command .
* @ param dstId Destination ID .
* @ param peerId Peer ID .
* @ param ssrc RTP SSRC .
* @ param streamId Stream ID .
*/
using ICCCallback = std : : function < void ( NET_ICC : : ENUM command , uint32_t dstId , uint32_t peerId , uint32_t ssrc , uint32_t streamId ) > ;
/**
* @ brief Callback for key responses .
* @ param ki Key item .
* @ param algId Algorithm ID .
* @ param keyLength Key length .
*/
using KeyResponseCallback = std : : function < void ( p25 : : kmm : : KeyItem ki , uint8_t algId , uint8_t keyLength ) > ;
/**
* @ brief Callback for KEK key responses .
* @ param rsi RSI .
* @ param ki Key item .
* @ param algId Algorithm ID .
* @ param keyLength Key length .
*/
using KEKKeyResponseCallback = std : : function < void ( uint32_t rsi , p25 : : kmm : : KeyItem ki , uint8_t algId , uint8_t keyLength ) > ;
/**
* @ brief Initializes a new instance of the Network class .
* @ param address Network Hostname / IP address to connect to .
@ -322,42 +374,68 @@ namespace network
*/
void setPeerDisconnectedCallback ( std : : function < void ( ) > & & callback ) { m_peerDisconnectedCallback = callback ; }
/**
* @ brief Sets the optional DMR receive packet preprocessor .
* @ param callback Callback invoked before DMR receive stream selection , or an empty callback to disable preprocessing .
*/
void setDMRRxPacketPreprocessor ( RxPacketPreprocessor & & callback ) { m_dmrRxPacketPreprocessor = callback ; }
/**
* @ brief Sets the optional P25 receive packet preprocessor .
* @ param callback Callback invoked before P25 receive stream selection , or an empty callback to disable preprocessing .
*/
void setP25RxPacketPreprocessor ( RxPacketPreprocessor & & callback ) { m_p25RxPacketPreprocessor = callback ; }
/**
* @ brief Sets the optional P25 Phase 2 receive packet preprocessor .
* @ param callback Callback invoked before P25 Phase 2 receive stream selection , or an empty callback to disable preprocessing .
*/
void setP25P2RxPacketPreprocessor ( RxPacketPreprocessor & & callback ) { m_p25P2RxPacketPreprocessor = callback ; }
/**
* @ brief Sets the optional NXDN receive packet preprocessor .
* @ param callback Callback invoked before NXDN receive stream selection , or an empty callback to disable preprocessing .
*/
void setNXDNRxPacketPreprocessor ( RxPacketPreprocessor & & callback ) { m_nxdnRxPacketPreprocessor = callback ; }
/**
* @ brief Sets the optional analog receive packet preprocessor .
* @ param callback Callback invoked before analog receive stream selection , or an empty callback to disable preprocessing .
*/
void setAnalogRxPacketPreprocessor ( RxPacketPreprocessor & & callback ) { m_analogRxPacketPreprocessor = callback ; }
/**
* @ brief Helper to set the DMR In - Call Control callback .
* @ param callback
*/
void setDMRICCCallback ( std : : function < void ( NET_ICC : : ENUM , uint32_t , uint8_t , uint32_t , uint32_t , uint32_t ) > & & callback ) { m_dmrInCallCallback = callback ; }
void setDMRICCCallback ( ICCSlotCallback & & callback ) { m_dmrInCallCallback = callback ; }
/**
* @ brief Helper to set the P25 In - Call Control callback .
* @ param callback
*/
void setP25ICCCallback ( std : : function < void ( NET_ICC : : ENUM , uint32_t , uint32_t , uint32_t , uint32_t ) > & & callback ) { m_p25InCallCallback = callback ; }
void setP25ICCCallback ( ICCCallback & & callback ) { m_p25InCallCallback = callback ; }
/**
* @ brief Helper to set the P25 Phase 2 In - Call Control callback .
* @ param callback
*/
void setP25P2ICCCallback ( std : : function < void ( NET_ICC : : ENUM , uint32_t , uint8_t , uint32_t , uint32_t , uint32_t ) > & & callback ) { m_p25P2InCallCallback = callback ; }
void setP25P2ICCCallback ( ICCSlotCallback & & callback ) { m_p25P2InCallCallback = callback ; }
/**
* @ brief Helper to set the NXDN In - Call Control callback .
* @ param callback
*/
void setNXDNICCCallback ( std : : function < void ( NET_ICC : : ENUM , uint32_t , uint32_t , uint32_t , uint32_t ) > & & callback ) { m_nxdnInCallCallback = callback ; }
void setNXDNICCCallback ( ICCCallback & & callback ) { m_nxdnInCallCallback = callback ; }
/**
* @ brief Helper to set the analog In - Call Control callback .
* @ param callback
*/
void setAnalogICCCallback ( std : : function < void ( NET_ICC : : ENUM , uint32_t , uint32_t , uint32_t , uint32_t ) > & & callback ) { m_analogInCallCallback = callback ; }
void setAnalogICCCallback ( ICCCallback & & callback ) { m_analogInCallCallback = callback ; }
/**
* @ brief Helper to set the enc . key response callback .
* @ param callback
*/
void setKeyResponseCallback ( std: : function < void ( p25 : : kmm : : KeyItem , uint8_t , uint8_t ) > & & callback ) { m_keyRespCallback = callback ; }
void setKeyResponseCallback ( KeyResponseCallback & & callback ) { m_keyRespCallback = callback ; }
/**
* @ brief Helper to set the UKEK / LLA encryption key response callback .
* @ param callback
*/
void setKEKKeyResponseCallback ( std: : function < void ( uint32_t , p25 : : kmm : : KeyItem , uint8_t , uint8_t ) > & & callback ) { m_kekKeyRespCallback = callback ; }
void setKEKKeyResponseCallback ( KEKKeyResponseCallback & & callback ) { m_kekKeyRespCallback = callback ; }
public :
/**
@ -365,7 +443,7 @@ namespace network
*/
DECLARE_RO_PROPERTY_PLAIN ( uint16_t , pktLastSeq ) ;
/**
/**
* @ brief Flag indicating that network unit - to - unit traffic is discarded .
*/
DECLARE_RO_PROPERTY_PLAIN ( bool , disallowUnitToUnit ) ;
@ -457,48 +535,81 @@ namespace network
*/
std : : function < void ( ) > m_peerDisconnectedCallback ;
/**
* @ brief Optional DMR receive packet preprocessor .
* ( This is called before DMR receive stream selection . )
*/
RxPacketPreprocessor m_dmrRxPacketPreprocessor ;
/**
* @ brief Optional P25 receive packet preprocessor .
* ( This is called before P25 receive stream selection . )
*/
RxPacketPreprocessor m_p25RxPacketPreprocessor ;
/**
* @ brief Optional P25 Phase 2 receive packet preprocessor .
* ( This is called before P25 Phase 2 receive stream selection . )
*/
RxPacketPreprocessor m_p25P2RxPacketPreprocessor ;
/**
* @ brief Optional NXDN receive packet preprocessor .
* ( This is called before NXDN receive stream selection . )
*/
RxPacketPreprocessor m_nxdnRxPacketPreprocessor ;
/**
* @ brief Optional analog receive packet preprocessor .
* ( This is called before analog receive stream selection . )
*/
RxPacketPreprocessor m_analogRxPacketPreprocessor ;
/**
* @ brief DMR In - Call Control Function Callback .
* ( This is called when the master sends a In - Call Control request . )
*/
std : : function < void ( NET_ICC : : ENUM command , uint32_t dstId , uint8_t slotNo ,
uint32_t peerId , uint32_t ssrc , uint32_t streamId ) > m_dmrInCallCallback ;
ICCSlotCallback m_dmrInCallCallback ;
/**
* @ brief P25 In - Call Control Function Callback .
* ( This is called once the master sends a In - Call Control request . )
*/
std : : function < void ( NET_ICC : : ENUM command , uint32_t dstId ,
uint32_t peerId , uint32_t ssrc , uint32_t streamId ) > m_p25InCallCallback ;
ICCCallback m_p25InCallCallback ;
/**
* @ brief P25 Phase 2 In - Call Control Function Callback .
* ( This is called once the master sends a In - Call Control request . )
*/
std : : function < void ( NET_ICC : : ENUM command , uint32_t dstId , uint8_t slotNo ,
uint32_t peerId , uint32_t ssrc , uint32_t streamId ) > m_p25P2InCallCallback ;
ICCSlotCallback m_p25P2InCallCallback ;
/**
* @ brief NXDN In - Call Control Function Callback .
* ( This is called once the master sends a In - Call Control request . )
*/
std : : function < void ( NET_ICC : : ENUM command , uint32_t dstId ,
uint32_t peerId , uint32_t ssrc , uint32_t streamId ) > m_nxdnInCallCallback ;
ICCCallback m_nxdnInCallCallback ;
/**
* @ brief Analog In - Call Control Function Callback .
* ( This is called once the master sends a In - Call Control request . )
*/
std : : function < void ( NET_ICC : : ENUM command , uint32_t dstId ,
uint32_t peerId , uint32_t ssrc , uint32_t streamId ) > m_analogInCallCallback ;
ICCCallback m_analogInCallCallback ;
/**
* @ brief Encryption Key Response Function Callback .
* ( This is called once the master responds to a key request . )
*/
std: : function < void ( p25 : : kmm : : KeyItem ki , uint8_t algId , uint8_t keyLength ) > m_keyRespCallback ;
KeyResponseCallback m_keyRespCallback ;
/**
* @ brief LLA / UKEK Encryption Key Response Function Callback .
* ( This is called once the master responds to a key KEK request . )
*/
std: : function < void ( uint32_t rsi , p25 : : kmm : : KeyItem ki , uint8_t algId , uint8_t keyLength ) > m_kekKeyRespCallback ;
KEKKeyResponseCallback m_kekKeyRespCallback ;
/**
* @ brief Function pointer type for packet handlers .
* @ param network Instance of the Network class .
* @ param peerId Peer ID .
* @ param streamId Stream ID .
* @ param now Current time in milliseconds .
* @ param fneHeader RTP FNE Header .
* @ param rtpHeader RTP Header .
* @ param buffer Buffer containing the packet data .
* @ param length Length of buffer .
* @ returns bool True , if the packet was handled , otherwise false .
*/
using PacketHandlerFunc = bool ( * ) ( Network * network , uint32_t peerId , uint32_t streamId , uint64_t now ,
const frame : : RTPFNEHeader & fneHeader , const frame : : RTPHeader & rtpHeader , const uint8_t * buffer , int length ) ;