|
@@ -0,0 +1,166 @@
|
|
1
|
+//
|
|
2
|
+// Created by robin on 1/23/18.
|
|
3
|
+//
|
|
4
|
+
|
|
5
|
+#include "dns-base/QDnsLabel.h"
|
|
6
|
+#include "dns-base/RecordData/QDnsRecordDataSOA.h"
|
|
7
|
+
|
|
8
|
+namespace QDns
|
|
9
|
+{
|
|
10
|
+ namespace Base
|
|
11
|
+ {
|
|
12
|
+ QDnsRecordDataSOA::QDnsRecordDataSOA()
|
|
13
|
+ : QDnsRecordData()
|
|
14
|
+ {
|
|
15
|
+ }
|
|
16
|
+
|
|
17
|
+ QDnsRecordDataSOA::QDnsRecordDataSOA(const QByteArray &packetData, quint32 pos)
|
|
18
|
+ : QDnsRecordDataSOA()
|
|
19
|
+ {
|
|
20
|
+ QDataStream dataStream(packetData);
|
|
21
|
+ dataStream.skipRawData(pos);
|
|
22
|
+ parse(packetData, dataStream);
|
|
23
|
+ }
|
|
24
|
+
|
|
25
|
+ QDnsRecordDataSOA::QDnsRecordDataSOA(const QByteArray &packetData, QDataStream &dataStream)
|
|
26
|
+ : QDnsRecordDataSOA()
|
|
27
|
+ {
|
|
28
|
+ parse(packetData, dataStream);
|
|
29
|
+ }
|
|
30
|
+
|
|
31
|
+ void QDnsRecordDataSOA::parse(const QByteArray &packetData, QDataStream &dataStream)
|
|
32
|
+ {
|
|
33
|
+ if (dataStream.device()->bytesAvailable() < 22)
|
|
34
|
+ {
|
|
35
|
+ m_isValid = false;
|
|
36
|
+ }
|
|
37
|
+ else
|
|
38
|
+ {
|
|
39
|
+ m_primaryNs = QDnsLabel::parse(packetData, dataStream);
|
|
40
|
+ if (m_primaryNs.isNull())
|
|
41
|
+ {
|
|
42
|
+ m_isValid = false;
|
|
43
|
+ }
|
|
44
|
+ else
|
|
45
|
+ {
|
|
46
|
+ m_adminMb = QDnsLabel::parse(packetData, dataStream);
|
|
47
|
+ if (m_adminMb.isNull())
|
|
48
|
+ {
|
|
49
|
+ m_isValid = false;
|
|
50
|
+ }
|
|
51
|
+ else
|
|
52
|
+ {
|
|
53
|
+ dataStream >> m_serialNumber;
|
|
54
|
+ dataStream >> m_refreshInterval;
|
|
55
|
+ dataStream >> m_retryInterval;
|
|
56
|
+ dataStream >> m_expirationLimit;
|
|
57
|
+ dataStream >> m_minimumTtl;
|
|
58
|
+ }
|
|
59
|
+ }
|
|
60
|
+ }
|
|
61
|
+ }
|
|
62
|
+
|
|
63
|
+ QByteArray QDnsRecordDataSOA::serialize() const
|
|
64
|
+ {
|
|
65
|
+ QByteArray byteArray;
|
|
66
|
+ QDataStream dataStream(&byteArray, QIODevice::WriteOnly);
|
|
67
|
+ serialize(dataStream);
|
|
68
|
+ return byteArray;
|
|
69
|
+ }
|
|
70
|
+
|
|
71
|
+ void QDnsRecordDataSOA::serialize(QDataStream &dataStream) const
|
|
72
|
+ {
|
|
73
|
+ QDnsLabel::serialize(m_primaryNs, dataStream);
|
|
74
|
+ QDnsLabel::serialize(m_adminMb, dataStream);
|
|
75
|
+ dataStream << m_serialNumber;
|
|
76
|
+ dataStream << m_refreshInterval;
|
|
77
|
+ dataStream << m_retryInterval;
|
|
78
|
+ dataStream << m_expirationLimit;
|
|
79
|
+ dataStream << m_minimumTtl;
|
|
80
|
+ }
|
|
81
|
+
|
|
82
|
+ QDnsRecordData *QDnsRecordDataSOA::clone() const
|
|
83
|
+ {
|
|
84
|
+ auto data = new QDnsRecordDataSOA();
|
|
85
|
+ data->m_isValid = m_isValid;
|
|
86
|
+ data->m_primaryNs = m_primaryNs;
|
|
87
|
+ data->m_adminMb = m_adminMb;
|
|
88
|
+ data->m_serialNumber = m_serialNumber;
|
|
89
|
+ data->m_refreshInterval = m_refreshInterval;
|
|
90
|
+ data->m_retryInterval = m_retryInterval;
|
|
91
|
+ data->m_expirationLimit = m_expirationLimit;
|
|
92
|
+ data->m_minimumTtl = m_minimumTtl;
|
|
93
|
+ return data;
|
|
94
|
+ }
|
|
95
|
+
|
|
96
|
+ const QString &QDnsRecordDataSOA::getPrimaryNs() const
|
|
97
|
+ {
|
|
98
|
+ return m_primaryNs;
|
|
99
|
+ }
|
|
100
|
+
|
|
101
|
+ void QDnsRecordDataSOA::setPrimaryNs(const QString &primaryNs)
|
|
102
|
+ {
|
|
103
|
+ m_primaryNs = primaryNs;
|
|
104
|
+ }
|
|
105
|
+
|
|
106
|
+ const QString &QDnsRecordDataSOA::getAdminMb() const
|
|
107
|
+ {
|
|
108
|
+ return m_adminMb;
|
|
109
|
+ }
|
|
110
|
+
|
|
111
|
+ void QDnsRecordDataSOA::setAdminMb(const QString &adminMb)
|
|
112
|
+ {
|
|
113
|
+ m_adminMb = adminMb;
|
|
114
|
+ }
|
|
115
|
+
|
|
116
|
+ quint32 QDnsRecordDataSOA::getSerialNumber() const
|
|
117
|
+ {
|
|
118
|
+ return m_serialNumber;
|
|
119
|
+ }
|
|
120
|
+
|
|
121
|
+ void QDnsRecordDataSOA::setSerialNumber(quint32 serialNumber)
|
|
122
|
+ {
|
|
123
|
+ m_serialNumber = serialNumber;
|
|
124
|
+ }
|
|
125
|
+
|
|
126
|
+ quint32 QDnsRecordDataSOA::getRefreshInterval() const
|
|
127
|
+ {
|
|
128
|
+ return m_refreshInterval;
|
|
129
|
+ }
|
|
130
|
+
|
|
131
|
+ void QDnsRecordDataSOA::setRefreshInterval(quint32 refreshInterval)
|
|
132
|
+ {
|
|
133
|
+ m_refreshInterval = refreshInterval;
|
|
134
|
+ }
|
|
135
|
+
|
|
136
|
+ quint32 QDnsRecordDataSOA::getRetryInterval() const
|
|
137
|
+ {
|
|
138
|
+ return m_retryInterval;
|
|
139
|
+ }
|
|
140
|
+
|
|
141
|
+ void QDnsRecordDataSOA::setRetryInterval(quint32 retryInterval)
|
|
142
|
+ {
|
|
143
|
+ m_retryInterval = retryInterval;
|
|
144
|
+ }
|
|
145
|
+
|
|
146
|
+ quint32 QDnsRecordDataSOA::getExpirationLimit() const
|
|
147
|
+ {
|
|
148
|
+ return m_expirationLimit;
|
|
149
|
+ }
|
|
150
|
+
|
|
151
|
+ void QDnsRecordDataSOA::setExpirationLimit(quint32 expirationLimit)
|
|
152
|
+ {
|
|
153
|
+ m_expirationLimit = expirationLimit;
|
|
154
|
+ }
|
|
155
|
+
|
|
156
|
+ quint32 QDnsRecordDataSOA::getMinimumTtl() const
|
|
157
|
+ {
|
|
158
|
+ return m_minimumTtl;
|
|
159
|
+ }
|
|
160
|
+
|
|
161
|
+ void QDnsRecordDataSOA::setMinimumTtl(quint32 minimumTtl)
|
|
162
|
+ {
|
|
163
|
+ m_minimumTtl = minimumTtl;
|
|
164
|
+ }
|
|
165
|
+ }
|
|
166
|
+}
|