Converts the wire format of an EDNS Option (including code and length) into the type-specific format. @param out The input stream.
(DNSInput in)
| 114 | * @param out The input stream. |
| 115 | */ |
| 116 | static EDNSOption |
| 117 | fromWire(DNSInput in) throws IOException { |
| 118 | int code, length; |
| 119 | |
| 120 | code = in.readU16(); |
| 121 | length = in.readU16(); |
| 122 | if (in.remaining() < length) |
| 123 | throw new WireParseException("truncated option"); |
| 124 | int save = in.saveActive(); |
| 125 | in.setActive(length); |
| 126 | EDNSOption option; |
| 127 | switch (code) { |
| 128 | case Code.NSID: |
| 129 | option = new NSIDOption(); |
| 130 | break; |
| 131 | case Code.CLIENT_SUBNET: |
| 132 | option = new ClientSubnetOption(); |
| 133 | break; |
| 134 | default: |
| 135 | option = new GenericEDNSOption(code); |
| 136 | break; |
| 137 | } |
| 138 | option.optionFromWire(in); |
| 139 | in.restoreActive(save); |
| 140 | |
| 141 | return option; |
| 142 | } |
| 143 | |
| 144 | /** |
| 145 | * Converts the wire format of an EDNS Option (including code and length) into |
no test coverage detected