ec_inet_forge.h
上传用户:nilegod
上传日期:2007-01-08
资源大小:220k
文件大小:3k
源码类别:

网络截获/分析

开发平台:

C/C++

  1. #include <sys/types.h>
  2. extern u_char * Inet_Forge_packet( u_short size ); // size of the allocated mem
  3. extern int Inet_Forge_packet_destroy( u_char *buf );
  4. extern int Inet_Forge_ethernet( u_char *buf,
  5.                                 u_char *source,    // source mac address
  6.                                 u_char *dest,      // dest mac address
  7.                                 u_short type );    // protocol type
  8. extern int Inet_Forge_arp( u_char *buf,
  9.                            u_short op,             // arp opcode
  10.                            u_char *sa,             // source mac address
  11.                            u_long sip,             // sourde ip address
  12.                            u_char *da,             // dest mac address
  13.                            u_long dip );           // dest ip address
  14. extern int Inet_Forge_ip( u_char *buf,
  15.                           u_long src,              // source ip
  16.                           u_long dst,              // dest ip
  17.                           u_short len,             // len of the payload
  18.                           u_short ident,           // ident
  19.                           u_short f_f,             // fragments and flags
  20.                           u_char proto );          // transport protocol
  21. extern int Inet_Forge_icmp( u_char *buf,
  22.                             u_char type,           // icmp type
  23.                             u_char code,           // icmp code
  24.                             u_char *data,          // data
  25.                             int data_len );        // data length
  26. extern int Inet_Forge_tcp( u_char *buf,
  27.                            u_short sp,             // source port
  28.                            u_short dp,             // dest port
  29.                            u_long seq,             // sequence number
  30.                            u_long ack,             // acknowledgement number
  31.                            u_char flags,           // tcp flags
  32.                            u_char *data,           // payload
  33.                            int data_len );         // payload len
  34. extern int Inet_Forge_udp( u_char *buf,
  35.                            u_short sp,             // source port
  36.                            u_short dp,             // dest port
  37.                            u_char *data,           // payload
  38.                            int data_len );         // payload len
  39. extern int Inet_Forge_Insert_TCPOpt( u_char *buf,
  40.                                      u_char *options, // raw options buffer
  41.                                      int optlen );    // options length
  42. extern u_short Inet_Forge_ChecksumIP( u_short *buffer,
  43.                                       int size);         // size of ip header
  44. extern u_short Inet_Forge_Checksum( u_short *buffer,
  45.                                     u_short proto,    // protocol type (TCP or UDP)
  46.                                     u_short size,     // size of tcp packet (header + payload)
  47.                                     u_long IPsource,  // ip source (for pseudoheader)
  48.                                     u_long IPdest);   // ip dest (for pseudoheader)
  49. extern void Inet_Forge_RemoveTimeStamp( char *opt,    // options pointer
  50.                                         int len);     // options length
  51. extern u_long Inet_Forge_CRC(u_char *buffer, // the buffer
  52.                              int len);       // buffer lenght
  53. /* EOF */