11
11
* @license http://www.opensource.org/licenses/mit-license.html MIT License
12
12
* @version 2.0.0
13
13
*/
14
- namespace LibDNS \Decoder ;
15
-
16
- use LibDNS \Messages \Message ;
17
- use LibDNS \Messages \MessageFactory ;
18
- use LibDNS \Packets \Packet ;
19
- use LibDNS \Packets \PacketFactory ;
20
- use LibDNS \Records \Question ;
21
- use LibDNS \Records \QuestionFactory ;
22
- use LibDNS \Records \Resource ;
23
- use LibDNS \Records \ResourceBuilder ;
24
- use LibDNS \Records \Types \Anything ;
25
- use LibDNS \Records \Types \BitMap ;
26
- use LibDNS \Records \Types \Char ;
27
- use LibDNS \Records \Types \CharacterString ;
28
- use LibDNS \Records \Types \DomainName ;
29
- use LibDNS \Records \Types \IPv4Address ;
30
- use LibDNS \Records \Types \IPv6Address ;
31
- use LibDNS \Records \Types \Long ;
32
- use LibDNS \Records \Types \Short ;
33
- use LibDNS \Records \Types \Type ;
34
- use LibDNS \Records \Types \TypeBuilder ;
35
- use LibDNS \Records \Types \Types ;
14
+ namespace DaveRandom \ LibDNS \Decoder ;
15
+
16
+ use DaveRandom \ LibDNS \Messages \Message ;
17
+ use DaveRandom \ LibDNS \Messages \MessageFactory ;
18
+ use DaveRandom \ LibDNS \Packets \Packet ;
19
+ use DaveRandom \ LibDNS \Packets \PacketFactory ;
20
+ use DaveRandom \ LibDNS \Records \Question ;
21
+ use DaveRandom \ LibDNS \Records \QuestionFactory ;
22
+ use DaveRandom \ LibDNS \Records \Resource as ResourceRecord ;
23
+ use DaveRandom \ LibDNS \Records \ResourceBuilder ;
24
+ use DaveRandom \ LibDNS \Records \Types \Anything ;
25
+ use DaveRandom \ LibDNS \Records \Types \BitMap ;
26
+ use DaveRandom \ LibDNS \Records \Types \Char ;
27
+ use DaveRandom \ LibDNS \Records \Types \CharacterString ;
28
+ use DaveRandom \ LibDNS \Records \Types \DomainName ;
29
+ use DaveRandom \ LibDNS \Records \Types \IPv4Address ;
30
+ use DaveRandom \ LibDNS \Records \Types \IPv6Address ;
31
+ use DaveRandom \ LibDNS \Records \Types \Long ;
32
+ use DaveRandom \ LibDNS \Records \Types \Short ;
33
+ use DaveRandom \ LibDNS \Records \Types \Type ;
34
+ use DaveRandom \ LibDNS \Records \Types \TypeBuilder ;
35
+ use DaveRandom \ LibDNS \Records \Types \Types ;
36
36
37
37
/**
38
38
* Decodes raw network data to Message objects
44
44
class Decoder
45
45
{
46
46
/**
47
- * @var \LibDNS\Packets\PacketFactory
47
+ * @var \DaveRandom\ LibDNS\Packets\PacketFactory
48
48
*/
49
49
private $ packetFactory ;
50
50
51
51
/**
52
- * @var \LibDNS\Messages\MessageFactory
52
+ * @var \DaveRandom\ LibDNS\Messages\MessageFactory
53
53
*/
54
54
private $ messageFactory ;
55
55
56
56
/**
57
- * @var \LibDNS\Records\QuestionFactory
57
+ * @var \DaveRandom\ LibDNS\Records\QuestionFactory
58
58
*/
59
59
private $ questionFactory ;
60
60
61
61
/**
62
- * @var \LibDNS\Records\ResourceBuilder
62
+ * @var \DaveRandom\ LibDNS\Records\ResourceBuilder
63
63
*/
64
64
private $ resourceBuilder ;
65
65
66
66
/**
67
- * @var \LibDNS\Records\Types\TypeBuilder
67
+ * @var \DaveRandom\ LibDNS\Records\Types\TypeBuilder
68
68
*/
69
69
private $ typeBuilder ;
70
70
71
71
/**
72
- * @var \LibDNS\Decoder\DecodingContextFactory
72
+ * @var \DaveRandom\ LibDNS\Decoder\DecodingContextFactory
73
73
*/
74
74
private $ decodingContextFactory ;
75
75
@@ -81,12 +81,12 @@ class Decoder
81
81
/**
82
82
* Constructor
83
83
*
84
- * @param \LibDNS\Packets\PacketFactory $packetFactory
85
- * @param \LibDNS\Messages\MessageFactory $messageFactory
86
- * @param \LibDNS\Records\QuestionFactory $questionFactory
87
- * @param \LibDNS\Records\ResourceBuilder $resourceBuilder
88
- * @param \LibDNS\Records\Types\TypeBuilder $typeBuilder
89
- * @param \LibDNS\Decoder\DecodingContextFactory $decodingContextFactory
84
+ * @param \DaveRandom\ LibDNS\Packets\PacketFactory $packetFactory
85
+ * @param \DaveRandom\ LibDNS\Messages\MessageFactory $messageFactory
86
+ * @param \DaveRandom\ LibDNS\Records\QuestionFactory $questionFactory
87
+ * @param \DaveRandom\ LibDNS\Records\ResourceBuilder $resourceBuilder
88
+ * @param \DaveRandom\ LibDNS\Records\Types\TypeBuilder $typeBuilder
89
+ * @param \DaveRandom\ LibDNS\Decoder\DecodingContextFactory $decodingContextFactory
90
90
* @param bool $allowTrailingData
91
91
*/
92
92
public function __construct (
@@ -110,7 +110,7 @@ public function __construct(
110
110
/**
111
111
* Read a specified number of bytes of data from a packet
112
112
*
113
- * @param \LibDNS\Packets\Packet $packet
113
+ * @param \DaveRandom\ LibDNS\Packets\Packet $packet
114
114
* @param int $length
115
115
* @return string
116
116
* @throws \UnexpectedValueException When the read operation does not result in the requested number of bytes
@@ -127,8 +127,8 @@ private function readDataFromPacket(Packet $packet, int $length): string
127
127
/**
128
128
* Decode the header section of the message
129
129
*
130
- * @param \LibDNS\Decoder\DecodingContext $decodingContext
131
- * @param \LibDNS\Messages\Message $message
130
+ * @param \DaveRandom\ LibDNS\Decoder\DecodingContext $decodingContext
131
+ * @param \DaveRandom\ LibDNS\Messages\Message $message
132
132
* @throws \UnexpectedValueException When the header section is invalid
133
133
*/
134
134
private function decodeHeader (DecodingContext $ decodingContext , Message $ message )
@@ -157,8 +157,8 @@ private function decodeHeader(DecodingContext $decodingContext, Message $message
157
157
/**
158
158
* Decode an Anything field
159
159
*
160
- * @param \LibDNS\Decoder\DecodingContext $decodingContext
161
- * @param \LibDNS\Records\Types\Anything $anything The object to populate with the result
160
+ * @param \DaveRandom\ LibDNS\Decoder\DecodingContext $decodingContext
161
+ * @param \DaveRandom\ LibDNS\Records\Types\Anything $anything The object to populate with the result
162
162
* @param int $length
163
163
* @return int The number of packet bytes consumed by the operation
164
164
* @throws \UnexpectedValueException When the packet data is invalid
@@ -173,8 +173,8 @@ private function decodeAnything(DecodingContext $decodingContext, Anything $anyt
173
173
/**
174
174
* Decode a BitMap field
175
175
*
176
- * @param \LibDNS\Decoder\DecodingContext $decodingContext
177
- * @param \LibDNS\Records\Types\BitMap $bitMap The object to populate with the result
176
+ * @param \DaveRandom\ LibDNS\Decoder\DecodingContext $decodingContext
177
+ * @param \DaveRandom\ LibDNS\Records\Types\BitMap $bitMap The object to populate with the result
178
178
* @param int $length
179
179
* @return int The number of packet bytes consumed by the operation
180
180
* @throws \UnexpectedValueException When the packet data is invalid
@@ -189,8 +189,8 @@ private function decodeBitMap(DecodingContext $decodingContext, BitMap $bitMap,
189
189
/**
190
190
* Decode a Char field
191
191
*
192
- * @param \LibDNS\Decoder\DecodingContext $decodingContext
193
- * @param \LibDNS\Records\Types\Char $char The object to populate with the result
192
+ * @param \DaveRandom\ LibDNS\Decoder\DecodingContext $decodingContext
193
+ * @param \DaveRandom\ LibDNS\Records\Types\Char $char The object to populate with the result
194
194
* @return int The number of packet bytes consumed by the operation
195
195
* @throws \UnexpectedValueException When the packet data is invalid
196
196
*/
@@ -205,8 +205,8 @@ private function decodeChar(DecodingContext $decodingContext, Char $char): int
205
205
/**
206
206
* Decode a CharacterString field
207
207
*
208
- * @param \LibDNS\Decoder\DecodingContext $decodingContext
209
- * @param \LibDNS\Records\Types\CharacterString $characterString The object to populate with the result
208
+ * @param \DaveRandom\ LibDNS\Decoder\DecodingContext $decodingContext
209
+ * @param \DaveRandom\ LibDNS\Records\Types\CharacterString $characterString The object to populate with the result
210
210
* @return int The number of packet bytes consumed by the operation
211
211
* @throws \UnexpectedValueException When the packet data is invalid
212
212
*/
@@ -222,8 +222,8 @@ private function decodeCharacterString(DecodingContext $decodingContext, Charact
222
222
/**
223
223
* Decode a DomainName field
224
224
*
225
- * @param \LibDNS\Decoder\DecodingContext $decodingContext
226
- * @param \LibDNS\Records\Types\DomainName $domainName The object to populate with the result
225
+ * @param \DaveRandom\ LibDNS\Decoder\DecodingContext $decodingContext
226
+ * @param \DaveRandom\ LibDNS\Records\Types\DomainName $domainName The object to populate with the result
227
227
* @return int The number of packet bytes consumed by the operation
228
228
* @throws \UnexpectedValueException When the packet data is invalid
229
229
*/
@@ -278,8 +278,8 @@ private function decodeDomainName(DecodingContext $decodingContext, DomainName $
278
278
/**
279
279
* Decode an IPv4Address field
280
280
*
281
- * @param \LibDNS\Decoder\DecodingContext $decodingContext
282
- * @param \LibDNS\Records\Types\IPv4Address $ipv4Address The object to populate with the result
281
+ * @param \DaveRandom\ LibDNS\Decoder\DecodingContext $decodingContext
282
+ * @param \DaveRandom\ LibDNS\Records\Types\IPv4Address $ipv4Address The object to populate with the result
283
283
* @return int The number of packet bytes consumed by the operation
284
284
* @throws \UnexpectedValueException When the packet data is invalid
285
285
*/
@@ -294,8 +294,8 @@ private function decodeIPv4Address(DecodingContext $decodingContext, IPv4Address
294
294
/**
295
295
* Decode an IPv6Address field
296
296
*
297
- * @param \LibDNS\Decoder\DecodingContext $decodingContext
298
- * @param \LibDNS\Records\Types\IPv6Address $ipv6Address The object to populate with the result
297
+ * @param \DaveRandom\ LibDNS\Decoder\DecodingContext $decodingContext
298
+ * @param \DaveRandom\ LibDNS\Records\Types\IPv6Address $ipv6Address The object to populate with the result
299
299
* @return int The number of packet bytes consumed by the operation
300
300
* @throws \UnexpectedValueException When the packet data is invalid
301
301
*/
@@ -310,8 +310,8 @@ private function decodeIPv6Address(DecodingContext $decodingContext, IPv6Address
310
310
/**
311
311
* Decode a Long field
312
312
*
313
- * @param \LibDNS\Decoder\DecodingContext $decodingContext
314
- * @param \LibDNS\Records\Types\Long $long The object to populate with the result
313
+ * @param \DaveRandom\ LibDNS\Decoder\DecodingContext $decodingContext
314
+ * @param \DaveRandom\ LibDNS\Records\Types\Long $long The object to populate with the result
315
315
* @return int The number of packet bytes consumed by the operation
316
316
* @throws \UnexpectedValueException When the packet data is invalid
317
317
*/
@@ -326,8 +326,8 @@ private function decodeLong(DecodingContext $decodingContext, Long $long): int
326
326
/**
327
327
* Decode a Short field
328
328
*
329
- * @param \LibDNS\Decoder\DecodingContext $decodingContext
330
- * @param \LibDNS\Records\Types\Short $short The object to populate with the result
329
+ * @param \DaveRandom\ LibDNS\Decoder\DecodingContext $decodingContext
330
+ * @param \DaveRandom\ LibDNS\Records\Types\Short $short The object to populate with the result
331
331
* @return int The number of packet bytes consumed by the operation
332
332
* @throws \UnexpectedValueException When the packet data is invalid
333
333
*/
@@ -342,8 +342,8 @@ private function decodeShort(DecodingContext $decodingContext, Short $short): in
342
342
/**
343
343
* Decode a Type field
344
344
*
345
- * @param \LibDNS\Decoder\DecodingContext $decodingContext
346
- * @param \LibDNS\Records\Types\Type $type The object to populate with the result
345
+ * @param \DaveRandom\ LibDNS\Decoder\DecodingContext $decodingContext
346
+ * @param \DaveRandom\ LibDNS\Records\Types\Type $type The object to populate with the result
347
347
* @param int $length Expected data length
348
348
* @return int The number of packet bytes consumed by the operation
349
349
* @throws \UnexpectedValueException When the packet data is invalid
@@ -379,13 +379,13 @@ private function decodeType(DecodingContext $decodingContext, Type $type, int $l
379
379
/**
380
380
* Decode a question record
381
381
*
382
- * @param \LibDNS\Decoder\DecodingContext $decodingContext
383
- * @return \LibDNS\Records\Question
382
+ * @param \DaveRandom\ LibDNS\Decoder\DecodingContext $decodingContext
383
+ * @return \DaveRandom\ LibDNS\Records\Question
384
384
* @throws \UnexpectedValueException When the record is invalid
385
385
*/
386
386
private function decodeQuestionRecord (DecodingContext $ decodingContext ): Question
387
387
{
388
- /** @var \LibDNS\Records\Types\DomainName $domainName */
388
+ /** @var \DaveRandom\ LibDNS\Records\Types\DomainName $domainName */
389
389
$ domainName = $ this ->typeBuilder ->build (Types::DOMAIN_NAME );
390
390
$ this ->decodeDomainName ($ decodingContext , $ domainName );
391
391
$ meta = \unpack ('ntype/nclass ' , $ this ->readDataFromPacket ($ decodingContext ->getPacket (), 4 ));
@@ -400,14 +400,14 @@ private function decodeQuestionRecord(DecodingContext $decodingContext): Questio
400
400
/**
401
401
* Decode a resource record
402
402
*
403
- * @param \LibDNS\Decoder\DecodingContext $decodingContext
404
- * @return \LibDNS\Records\Resource
403
+ * @param \DaveRandom\ LibDNS\Decoder\DecodingContext $decodingContext
404
+ * @return \DaveRandom\ LibDNS\Records\Resource
405
405
* @throws \UnexpectedValueException When the record is invalid
406
406
* @throws \InvalidArgumentException When a type subtype is unknown
407
407
*/
408
- private function decodeResourceRecord (DecodingContext $ decodingContext ): Resource
408
+ private function decodeResourceRecord (DecodingContext $ decodingContext ): ResourceRecord
409
409
{
410
- /** @var \LibDNS\Records\Types\DomainName $domainName */
410
+ /** @var \DaveRandom\ LibDNS\Records\Types\DomainName $domainName */
411
411
$ domainName = $ this ->typeBuilder ->build (Types::DOMAIN_NAME );
412
412
$ this ->decodeDomainName ($ decodingContext , $ domainName );
413
413
$ meta = \unpack ('ntype/nclass/Nttl/nlength ' , $ this ->readDataFromPacket ($ decodingContext ->getPacket (), 10 ));
@@ -446,7 +446,7 @@ private function decodeResourceRecord(DecodingContext $decodingContext): Resourc
446
446
* Decode a Message from raw network data
447
447
*
448
448
* @param string $data The data string to decode
449
- * @return \LibDNS\Messages\Message
449
+ * @return \DaveRandom\ LibDNS\Messages\Message
450
450
* @throws \UnexpectedValueException When the packet data is invalid
451
451
* @throws \InvalidArgumentException When a type subtype is unknown
452
452
*/
0 commit comments