Socket socket1 = new Socket(AddressFamily.InterNetwork, SocketType.Raw, ProtocolType.IP);
socket1.Bind(new IPEndPoint(ipAddress, 0));
socket1.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.HeaderIncluded, true);
byte[] byTrue = new byte[] { 1, 0, 0, 0 };
byte[] byOut = new byte[] { 1, 0, 0, 0 };
socket1.IOControl(IOControlCode.ReceiveAll, byTrue, byOut);
byte[] buffer1 = new byte[4096];
socket1.BeginReceive(buffer1, 0, buffer1.Length, SocketFlags.None, new AsyncCallback(OnReceive), new Tuple<Socket, byte[]>(socket1, buffer1));
我使用此代码在所有端口上的适配器上捕获 IP 数据包。
我将如何修改此代码以捕获 SMB/CIFS 数据包?最好不要在项目/代码中添加额外的数据包捕获库。