1 /******************************************************************************
4 Lantiq Deutschland GmbH
6 For licensing information, see the file 'LICENSE' in the root folder of
9 ******************************************************************************/
10 #ifndef __LOG_INFO_H__
11 #define __LOG_INFO_H__
22 #include "aux_utils.h"
23 #include "logsrv_protocol.h"
27 friend istream
&operator>> (istream
&is
, CLogInfo
&info
);
29 class exc_bad_info_magic
: public exc_basic
32 exc_bad_info_magic (uint32 magic
) {
34 ss
<< "Incorrect Log Info magic:" << hex
<< showbase
<< setfill('0') << setw(8) << magic
;
38 class exc_bad_info_size
: public exc_basic
41 exc_bad_info_size (uint32 size
) {
43 ss
<< "Incorrect Log Info size:" << hex
<< showbase
<< setfill('0') << setw(8) << size
;
47 class exc_bad_info_ver_major
: public exc_basic
50 exc_bad_info_ver_major (uint16 major
, uint16 supported
) {
52 ss
<< "Incorrect Log Info major: " << major
<< " (required: " << supported
<<")";
60 memset(&m_info
, 0, sizeof(m_info
));
67 void Read (istream
&in_s
) {
69 in_s
.read((char *)&m_info
, sizeof(m_info
));
71 catch (const ios_base::failure
&/*ex*/) {
73 /* EOF is not an error in our case */
76 /* Other stream error */
77 throw; /* throw this exception up */
80 m_info
.magic
= ntohl(m_info
.magic
);
81 if (m_info
.magic
!= LOGSRV_INFO_MAGIC
) {
82 throw exc_bad_info_magic(m_info
.magic
);
85 m_info
.size
= ntohl(m_info
.size
);
86 if (m_info
.size
!= sizeof(m_info
)) {
87 throw exc_bad_info_size(m_info
.size
);
90 m_info
.log_ver_major
= ntohs(m_info
.log_ver_major
);
91 if (m_info
.log_ver_major
!= RTLOGGER_VER_MAJOR
) {
92 throw exc_bad_info_ver_major(m_info
.log_ver_major
, RTLOGGER_VER_MAJOR
);
95 m_info
.log_ver_minor
= ntohs(m_info
.log_ver_minor
);
98 struct logsrv_info m_info
;
101 istream
&operator>> (istream
&is
, CLogInfo
&info
)
107 #endif /* __LOG_INFO_H__ */