mirror of
https://github.com/TalAloni/SMBLibrary.git
synced 2025-08-03 06:21:49 +02:00
Add missing usings
This commit is contained in:
parent
0b98e1f754
commit
513566a45f
3 changed files with 38 additions and 25 deletions
|
@ -8,6 +8,7 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Threading;
|
||||
using SMBLibrary.NetBios;
|
||||
|
||||
namespace SMBLibrary.Client
|
||||
|
@ -43,14 +44,20 @@ namespace SMBLibrary.Client
|
|||
|
||||
private NodeStatusResponse SendNodeStatusRequest(NodeStatusRequest request)
|
||||
{
|
||||
UdpClient client = new UdpClient();
|
||||
IPEndPoint serverEndPoint = new IPEndPoint(m_serverAddress, NetBiosNameServicePort);
|
||||
client.Connect(serverEndPoint);
|
||||
|
||||
byte[] requestBytes = request.GetBytes();
|
||||
client.Send(requestBytes, requestBytes.Length);
|
||||
byte[] responseBytes = client.Receive(ref serverEndPoint);
|
||||
return new NodeStatusResponse(responseBytes, 0);
|
||||
using (UdpClient client = new UdpClient())
|
||||
{
|
||||
IPEndPoint serverEndPoint = new IPEndPoint(m_serverAddress, NetBiosNameServicePort);
|
||||
client.Connect(serverEndPoint);
|
||||
byte[] requestBytes = request.GetBytes();
|
||||
client.Send(requestBytes, requestBytes.Length);
|
||||
Thread.Sleep(100);
|
||||
if (client.Available > 0)
|
||||
{
|
||||
var responseBytes = client.Receive(ref serverEndPoint);
|
||||
return new NodeStatusResponse(responseBytes, 0);
|
||||
}
|
||||
}
|
||||
return new NodeStatusResponse();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,10 +36,12 @@ namespace SMBLibrary.NetBios
|
|||
|
||||
public byte[] GetBytes()
|
||||
{
|
||||
MemoryStream stream = new MemoryStream();
|
||||
Header.WriteBytes(stream);
|
||||
Question.WriteBytes(stream);
|
||||
return stream.ToArray();
|
||||
using (MemoryStream stream = new MemoryStream())
|
||||
{
|
||||
Header.WriteBytes(stream);
|
||||
Question.WriteBytes(stream);
|
||||
return stream.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,25 +54,29 @@ namespace SMBLibrary.NetBios
|
|||
{
|
||||
Resource.Data = GetData();
|
||||
|
||||
MemoryStream stream = new MemoryStream();
|
||||
Header.WriteBytes(stream);
|
||||
Resource.WriteBytes(stream);
|
||||
return stream.ToArray();
|
||||
using (MemoryStream stream = new MemoryStream())
|
||||
{
|
||||
Header.WriteBytes(stream);
|
||||
Resource.WriteBytes(stream);
|
||||
return stream.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
private byte[] GetData()
|
||||
{
|
||||
MemoryStream stream = new MemoryStream();
|
||||
stream.WriteByte((byte)Names.Count);
|
||||
foreach (KeyValuePair<string, NameFlags> entry in Names)
|
||||
using (MemoryStream stream = new MemoryStream())
|
||||
{
|
||||
ByteWriter.WriteAnsiString(stream, entry.Key);
|
||||
BigEndianWriter.WriteUInt16(stream, (ushort)entry.Value);
|
||||
stream.WriteByte((byte)Names.Count);
|
||||
foreach (KeyValuePair<string, NameFlags> entry in Names)
|
||||
{
|
||||
ByteWriter.WriteAnsiString(stream, entry.Key);
|
||||
BigEndianWriter.WriteUInt16(stream, (ushort)entry.Value);
|
||||
}
|
||||
|
||||
ByteWriter.WriteBytes(stream, Statistics.GetBytes());
|
||||
|
||||
return stream.ToArray();
|
||||
}
|
||||
|
||||
ByteWriter.WriteBytes(stream, Statistics.GetBytes());
|
||||
|
||||
return stream.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue