⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tcpip.h

📁 Ubuntu packages of security software。 相当不错的源码
💻 H
📖 第 1 页 / 共 3 页
字号:
     packet tracing is enabled.  'frame' must point to the 14-byte     ethernet header (e.g. starting with destination addr). The     direction must be PacketTrace::SENT or PacketTrace::RCVD .     Optional 'now' argument makes this function slightly more     efficient by avoiding a gettimeofday() call. */  static void traceArp(pdirection pdir, const u8 *frame, u32 len,				    struct timeval *now);};class PacketCounter { public:  PacketCounter() : sendPackets(0), sendBytes(0), recvPackets(0), recvBytes(0) {}#if WIN32  unsigned __int64#else  unsigned long long#endif	  sendPackets, sendBytes, recvPackets, recvBytes;};#define MAX_LINK_HEADERSZ 24struct link_header {  int datalinktype; /* pcap_datalink(), such as DLT_EN10MB */  int headerlen; /* 0 if header was too big or unavailaable */  u8 header[MAX_LINK_HEADERSZ];};/* Relevant (to Nmap) information about an interface */struct interface_info {  char devname[16];  char devfullname[16]; /* can include alias info, such as eth0:2. */  struct sockaddr_storage addr;  u16 netmask_bits; /* CIDR-style.  So 24 means class C (255.255.255.0)*/  devtype device_type; /* devt_ethernet, devt_loopback, devt_p2p, devt_other */  bool device_up; /* True if the device is up (enabled) */  u8 mac[6]; /* Interface MAC address if device_type is devt_ethernet */};struct route_nfo {  struct interface_info ii;/* true if the target is directly connected on the network (no routing   required). */  bool direct_connect; /* This is the source address that should be used by the packets.  It   may be different than ii.addr if you are using localhost interface   to scan the IP of another interface on the machine */  struct sockaddr_storage srcaddr;   /* If direct_connect is 0, this is filled in with the next hop     required to route to the target */  struct sockaddr_storage nexthop;};struct sys_route {  struct interface_info *device;  u32 dest;  u32 netmask;  struct in_addr gw; /* gateway - 0 if none */};struct eth_nfo {  char srcmac[6];  char dstmac[6];  eth_t *ethsd; // Optional, but improves performance.  Set to NULL if unavail  char devname[16]; // Only needed if ethsd is NULL.};#ifndef HAVE_STRUCT_IP#define HAVE_STRUCT_IP/* From Linux glibc, which apparently borrowed it from   BSD code.  Slightly modified for portability --fyodor@insecure.org *//* * Structure of an internet header, naked of options. */struct ip  {#if WORDS_BIGENDIAN    u_int8_t ip_v:4;                    /* version */    u_int8_t ip_hl:4;                   /* header length */#else    u_int8_t ip_hl:4;                   /* header length */    u_int8_t ip_v:4;                    /* version */ #endif    u_int8_t ip_tos;                    /* type of service */    u_short ip_len;                     /* total length */    u_short ip_id;                      /* identification */    u_short ip_off;                     /* fragment offset field */#define IP_RF 0x8000                    /* reserved fragment flag */#define IP_DF 0x4000                    /* dont fragment flag */#define IP_MF 0x2000                    /* more fragments flag */#define IP_OFFMASK 0x1fff               /* mask for fragmenting bits */    u_int8_t ip_ttl;                    /* time to live */    u_int8_t ip_p;                      /* protocol */    u_short ip_sum;                     /* checksum */    struct in_addr ip_src, ip_dst;      /* source and dest address */  };#endif /* HAVE_STRUCT_IP */#ifndef HAVE_STRUCT_ICMP#define HAVE_STRUCT_ICMP/* From Linux /usr/include/netinet/ip_icmp.h GLIBC *//* * Internal of an ICMP Router Advertisement */struct icmp_ra_addr{  u_int32_t ira_addr;  u_int32_t ira_preference;};struct icmp{  u_int8_t  icmp_type;  /* type of message, see below */  u_int8_t  icmp_code;  /* type sub code */  u_int16_t icmp_cksum; /* ones complement checksum of struct */  union  {    struct ih_idseq             /* echo datagram */    {      u_int16_t icd_id;      u_int16_t icd_seq;    } ih_idseq;    u_int32_t ih_void;    /* ICMP_UNREACH_NEEDFRAG -- Path MTU Discovery (RFC1191) */    struct ih_pmtu    {      u_int16_t ipm_void;      u_int16_t ipm_nextmtu;    } ih_pmtu;    struct ih_rtradv    {      u_int8_t irt_num_addrs;      u_int8_t irt_wpa;      u_int16_t irt_lifetime;    } ih_rtradv;  } icmp_hun;  /* Removed icmp_pptr and icmp_gwaddr from union and #defines because they conflict with dnet */#define icmp_id         icmp_hun.ih_idseq.icd_id#define icmp_seq        icmp_hun.ih_idseq.icd_seq#define icmp_void       icmp_hun.ih_void#define icmp_pmvoid     icmp_hun.ih_pmtu.ipm_void#define icmp_nextmtu    icmp_hun.ih_pmtu.ipm_nextmtu#define icmp_num_addrs  icmp_hun.ih_rtradv.irt_num_addrs#define icmp_wpa        icmp_hun.ih_rtradv.irt_wpa#define icmp_lifetime   icmp_hun.ih_rtradv.irt_lifetime  union  {    struct    {      u_int32_t its_otime;      u_int32_t its_rtime;      u_int32_t its_ttime;    } id_ts;    struct    {      struct ip idi_ip;      /* options and then 64 bits of data */    } id_ip;    struct icmp_ra_addr id_radv;    u_int32_t   id_mask;    u_int8_t    id_data[1];  } icmp_dun;#define icmp_otime      icmp_dun.id_ts.its_otime#define icmp_rtime      icmp_dun.id_ts.its_rtime#define icmp_ttime      icmp_dun.id_ts.its_ttime#define icmp_ip         icmp_dun.id_ip.idi_ip#define icmp_radv       icmp_dun.id_radv#define icmp_mask       icmp_dun.id_mask#define icmp_data       icmp_dun.id_data};#endif /* HAVE_STRUCT_ICMP *//* Some systems might not have this */#ifndef IPPROTO_IGMP#define IPPROTO_IGMP 2#endif/* Prototypes *//* Converts an IP address given in a sockaddr_storage to an IPv4 or   IPv6 IP address string.  Since a static buffer is returned, this is   not thread-safe and can only be used once in calls like printf() */const char *inet_socktop(struct sockaddr_storage *ss);/* Tries to resolve the given name (or literal IP) into a sockaddr   structure.  The af should be PF_INET (for IPv4) or PF_INET6.  Returns 0   if hostname cannot be resolved.  It is OK to pass in a sockaddr_in or    sockaddr_in6 casted to a sockaddr_storage as long as you use the matching    pf.*/int resolve(char *hostname, struct sockaddr_storage *ss, size_t *sslen,	    int pf);/* LEGACY resolve() function that only supports IPv4 -- see IPv6 version   above.  Tries to resolve given hostname and stores   result in ip .  returns 0 if hostname cannot   be resolved */int resolve(char *hostname, struct in_addr *ip);/* Takes a destination address (dst) and tries to determine the   source address and interface necessary to route to this address.   If no route is found, false is returned and rnfo is undefined.  If   a route is found, true is returned and rnfo is filled in with all   of the routing details.  This function takes into account -S and -e   options set by user (o.spoofsource, o.device) */bool route_dst(const struct sockaddr_storage *const dst, struct route_nfo *rnfo);/* Determines what interface packets destined to 'dest' should be   routed through.  It can also discover the appropriate next hop (if   any) for ethernet routing.  If direct_connect is passed in, it will   be set to 1 if dst is directly connected on the ifentry network and   0 if it requires routing.  If nexthop_ip is not NULL, and routing   is required, the next hop is filled into nexthop_ip.  This function   returns false if no appropiate interface or route was found and   true if it succeeds. */bool routethrough(const struct sockaddr_storage * const dest, 		  struct intf_entry *ifentry, 		  int *direct_connect, struct sockaddr_storage *nexthop_ip);unsigned short in_cksum(u16 *ptr,int nbytes);unsigned short magic_tcpudp_cksum(const struct in_addr *src,				  const struct in_addr *dst,				  u8 proto, u16 len, char *hstart);/* Build and send a raw tcp packet.  If TTL is -1, a partially random   (but likely large enough) one is chosen */int send_tcp_raw( int sd, struct eth_nfo *eth,		  const struct in_addr *source, const struct in_addr *victim, 		  int ttl, bool df,		  u8* ipopt, int ipoptlen,		  u16 sport, u16 dport,		  u32 seq, u32 ack, u8 reserved, u8 flags, u16 window, u16 urp,		  u8 *options, int optlen,		  char *data, u16 datalen);int send_udp_raw( int sd, struct eth_nfo *eth,		  struct in_addr *source, const struct in_addr *victim,		  int ttl, u16 ipid,		  u8* ipopt, int ipoptlen,		  u16 sport, u16 dport,		  char *data, u16 datalen);int send_ip_raw( int sd, struct eth_nfo *eth,		 struct in_addr *source, const struct in_addr *victim,		 u8 proto, int ttl,		 u8* ipopt, int ipoptlen,		 char *data, u16 datalen);/* Builds a TCP packet (including an IP header) by packing the fields   with the given information.  It allocates a new buffer to store the   packet contents, and then returns that buffer.  The packet is not   actually sent by this function.  Caller must delete the buffer when

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -