Beispiel #1
0
 //����ǰ�ip����תΪ�ֽ������õ�
 public Int32 pshto(psdHeader psh, byte[] buffer, int size)
 {
     Int32 rtn;
     int index = 0;
     byte[] b_psh_saddr = BitConverter.GetBytes(psh.saddr);
     byte[] b_psh_daddr = BitConverter.GetBytes(psh.daddr);
     byte[] b_psh_mbz = new byte[1];
     b_psh_mbz[0] = psh.mbz;
     byte[] b_psh_ptcl = new byte[1];
     b_psh_ptcl[0] = psh.ptcl;
     byte[] b_psh_tcpl = BitConverter.GetBytes(psh.tcpl);
     Array.Copy(b_psh_saddr, 0, buffer, index, b_psh_saddr.Length);
     index += b_psh_saddr.Length;
     Array.Copy(b_psh_daddr, 0, buffer, index, b_psh_daddr.Length);
     index += b_psh_daddr.Length;
     Array.Copy(b_psh_mbz, 0, buffer, index, b_psh_mbz.Length);
     index += b_psh_mbz.Length;
     Array.Copy(b_psh_ptcl, 0, buffer, index, b_psh_ptcl.Length);
     index += b_psh_ptcl.Length;
     Array.Copy(b_psh_tcpl, 0, buffer, index, b_psh_tcpl.Length);
     index += b_psh_tcpl.Length;
     if (index != size)
     {
         rtn = -1;
         return rtn;
     }
     else
     {
         rtn = index;
         return rtn;
     }
 }
Beispiel #2
0
 public syn(uint _ip, ushort _port, EndPoint _ep, Random _rand)
 {
     ip = _ip;
     port = _port;
     ep = _ep;
     rand = _rand;
     ipHeader iph = new ipHeader();
     psh = new psdHeader();
     tch = new tcpHeader();
     sock = new Socket(AddressFamily.InterNetwork, SocketType.Raw, ProtocolType.IP);
     sock.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.HeaderIncluded, 1);
     //��2��ͦ��Ҫ�����������ſ����Լ��ṩipͷ
 }