NameQueryResponse.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // This code is derived from jcifs smb client library <jcifs at samba dot org>
  2. // Ported by J. Arturo <webmaster at komodosoft dot net>
  3. //
  4. // This library is free software; you can redistribute it and/or
  5. // modify it under the terms of the GNU Lesser General Public
  6. // License as published by the Free Software Foundation; either
  7. // version 2.1 of the License, or (at your option) any later version.
  8. //
  9. // This library is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. // Lesser General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU Lesser General Public
  15. // License along with this library; if not, write to the Free Software
  16. // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  17. namespace SharpCifs.Netbios
  18. {
  19. internal class NameQueryResponse : NameServicePacket
  20. {
  21. public NameQueryResponse()
  22. {
  23. RecordName = new Name();
  24. }
  25. internal override int WriteBodyWireFormat(byte[] dst, int dstIndex)
  26. {
  27. return 0;
  28. }
  29. internal override int ReadBodyWireFormat(byte[] src, int srcIndex)
  30. {
  31. return ReadResourceRecordWireFormat(src, srcIndex);
  32. }
  33. internal override int WriteRDataWireFormat(byte[] dst, int dstIndex)
  34. {
  35. return 0;
  36. }
  37. internal override int ReadRDataWireFormat(byte[] src, int srcIndex)
  38. {
  39. if (ResultCode != 0 || OpCode != Query)
  40. {
  41. return 0;
  42. }
  43. bool groupName = ((src[srcIndex] & unchecked(0x80)) == unchecked(0x80)) ? true : false;
  44. int nodeType = (src[srcIndex] & unchecked(0x60)) >> 5;
  45. srcIndex += 2;
  46. int address = ReadInt4(src, srcIndex);
  47. if (address != 0)
  48. {
  49. AddrEntry[AddrIndex] = new NbtAddress(RecordName, address, groupName, nodeType);
  50. }
  51. else
  52. {
  53. AddrEntry[AddrIndex] = null;
  54. }
  55. return 6;
  56. }
  57. public override string ToString()
  58. {
  59. return "NameQueryResponse[" + base.ToString() + ",addrEntry=" + AddrEntry
  60. + "]";
  61. }
  62. }
  63. }