共 15 篇文章 |
|
ip(struct)struct ip { unsigned int ip_hl:4;IP header length expressed as a multiple of 32-bit octets or DWORDS (i.e. header length in bytes = value set in ip_hl x 4 [each # counts for 4 octets]).The first 3 bits are the fragment flags, the first one always 0, the second the do-not-fragment bit (set by ip_off |= 0x4000... 阅1207 转17 评0 公众公开 11-10-26 13:00 |
struct ethhdr、ether_header、iphdr、tcphdr、udphdr.// destination eth addr u_int8_t ether_shost[ETH_ALEN];***********************IP的结构***********************************struct iphdr{#if __BYTE_ORDER == __LITTLE_ENDIAN unsigned int ihl:4; unsigned int version:4;#elif __BYTE_ORDER == __BIG_ENDIAN unsigned int version... 阅397 转8 评0 公众公开 11-10-24 15:41 |
1高级套接字函数 getsockopt和setsockopt.SO_OOBINLINE 带外数据放入正常数据流 int SO_RCVBUF 接收缓冲区大小 int SO_SNDBUF 发送缓冲区大小 int SO_RCVLOWAT 接收缓冲区下限 int SO_SNDLOWAT 发送缓冲区下限 int SO_RCVTIMEO 接收超时 struct timeval SO_SNDTIMEO 发送超时 struct timeval SO_REUSERADDR 允许重用本地地址和端口 int SO_TYPE... 阅434 转1 评0 公众公开 11-10-21 17:20 |
ai_flags:AI_PASSIVE,AI_CANONNAME,AI_NUMERICHOST.在getaddrinfo函数之前通常需要对以下6个参数进行以下设置:nodename、servname、hints的ai_flags、ai_family、ai_socktype、ai_protocol.而ai_family只是有地址为v4地址或v6地址的区别。其中ai_flags、ai_family、ai_socktype说明如下:如上表所示,ai_flagsde值范围为0~7,取决于程序如何设... 阅648 转1 评0 公众公开 11-10-20 10:32 |
#include "unistd.h"#include "sys/types.h"#include "sys/socket.h"#include "netinet/in.h"#include "netinet/ip.h"#include "netinet/ip_icmp.h"#include "netdb.h"#include "errno.h"#include "arpa/inet.h"#include "signal.h"#inc... 阅1033 转24 评0 公众公开 11-10-19 17:32 |
阅612 转10 评0 公众公开 11-10-19 17:03 |
#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};顺序号?D?Dping命令的icmp_seq便由这里读出,代表ICM... 阅57 转2 评0 公众公开 11-10-18 10:15 |
} addr.sin_addr=*(struct in_addr *)(host->h_addr_list[0]);/** 你不知道我是从那里来的,慢慢的去等吧! **/ ip->ip_src.s_addr=random(); /** 什么都让系统做了,也没有多大的意思,还是让我们自己来校验头部吧 */ /** 下面这条可有可无 */ tcp->check=check_sum((unsigned short *)tcp, sizeof(struct tcphdr)); sendto(sockfd,buffe... 阅84 转0 评0 公众公开 11-10-18 09:36 |
注意:sockaddr和sockaddr_in之间的强制类型转换职能通过指针来转换.(原因:两个内存大小相同而结构体重的数据类型不同)sockaddr向sockaddr_in转换时:sockaddr sa(sockaddr_in*)&sa;sockaddr_in向sockaddr转换时:sokcaddr_in sai; (sockaddr*)&sai++++++++++++++++++++++++++++++++++++++++++++++++++in_addr结构:The in_addr structure ... 阅1731 转1 评0 公众公开 11-10-17 16:35 |
addrinfo,getaddrinfoaddrinfo.//length of ai_addrchar* ai_canonname;//addr of hoststruct addrinfo* ai_next;定义函数: int getaddrinfo( const char *hostname, const char *service, const struct addrinfo *hints, struct addrinfo **result );定义函数: void freeaddrinfo( struct addrinfo *ai );函数说明: 由getaddrinfo返回的所有存... 阅133 转1 评0 公众公开 11-10-17 16:13 |