View Javadoc
1   /*
2    * Copyright 2013 The Netty Project
3    *
4    * The Netty Project licenses this file to you under the Apache License,
5    * version 2.0 (the "License"); you may not use this file except in compliance
6    * with the License. You may obtain a copy of the License at:
7    *
8    *   http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13   * License for the specific language governing permissions and limitations
14   * under the License.
15   */
16  package io.netty.handler.codec.dns;
17  
18  import java.net.InetSocketAddress;
19  
20  /**
21   * A DNS response packet which is sent to a client after a server receives a
22   * query.
23   */
24  public final class DnsResponse extends DnsMessage {
25  
26      private final InetSocketAddress sender;
27  
28      public DnsResponse(int id, InetSocketAddress sender) {
29          super(id);
30          if (sender == null) {
31              throw new NullPointerException("sender");
32          }
33          this.sender = sender;
34      }
35  
36      /**
37       * The {@link InetSocketAddress} of the sender of this {@link DnsResponse}
38       */
39      public InetSocketAddress sender() {
40          return sender;
41      }
42  
43      @Override
44      public DnsResponse addAnswer(DnsResource answer) {
45          super.addAnswer(answer);
46          return this;
47      }
48  
49      @Override
50      public DnsResponse addQuestion(DnsQuestion question) {
51          super.addQuestion(question);
52          return this;
53      }
54  
55      @Override
56      public DnsResponse addAuthorityResource(DnsResource resource) {
57          super.addAuthorityResource(resource);
58          return this;
59      }
60  
61      @Override
62      public DnsResponse addAdditionalResource(DnsResource resource) {
63          super.addAdditionalResource(resource);
64          return this;
65      }
66  
67      @Override
68      public DnsResponse touch(Object hint) {
69          super.touch(hint);
70          return this;
71      }
72  
73      @Override
74      public DnsResponse retain() {
75          super.retain();
76          return this;
77      }
78  
79      @Override
80      public DnsResponse retain(int increment) {
81          super.retain(increment);
82          return this;
83      }
84  
85      @Override
86      public DnsResponse touch() {
87          super.touch();
88          return this;
89      }
90  
91      @Override
92      public DnsResponseHeader header() {
93          return (DnsResponseHeader) super.header();
94      }
95  
96      @Override
97      protected DnsResponseHeader newHeader(int id) {
98          return new DnsResponseHeader(this, id);
99      }
100 }