| 1 |
/* |
| 2 |
* Copyright 2015-2020 the original author or authors |
| 3 |
* |
| 4 |
* This software is licensed under the Apache License, Version 2.0, |
| 5 |
* the GNU Lesser General Public License version 2 or later ("LGPL") |
| 6 |
* and the WTFPL. |
| 7 |
* You may choose either license to govern your use of this software only |
| 8 |
* upon the condition that you accept all of the terms of either |
| 9 |
* the Apache License 2.0, the LGPL 2.1+ or the WTFPL. |
| 10 |
*/ |
| 11 |
package org.minidns.edns; |
| 12 |
|
| 13 |
import java.nio.charset.StandardCharsets; |
| 14 |
|
| 15 |
import org.minidns.edns.Edns.OptionCode; |
| 16 |
import org.minidns.util.Hex; |
| 17 |
|
| 18 |
public class Nsid extends EdnsOption { |
| 19 |
|
| 20 |
public static final Nsid REQUEST = new Nsid(); |
| 21 |
|
| 22 |
private Nsid() { |
| 23 |
this(new byte[0]); |
| 24 |
} |
| 25 |
|
| 26 |
public Nsid(byte[] payload) { |
| 27 |
super(payload); |
| 28 |
} |
| 29 |
|
| 30 |
@Override |
| 31 |
public OptionCode getOptionCode() { |
| 32 |
return OptionCode.NSID; |
| 33 |
} |
| 34 |
|
| 35 |
@Override |
| 36 |
protected CharSequence toStringInternal() { |
| 37 |
String res = OptionCode.NSID + ": "; |
| 38 |
res += new String(optionData, StandardCharsets.US_ASCII); |
| 39 |
return res; |
| 40 |
} |
| 41 |
|
| 42 |
@Override |
| 43 |
protected CharSequence asTerminalOutputInternal() { |
| 44 |
return Hex.from(optionData); |
| 45 |
} |
| 46 |
|
| 47 |
} |